aboutsummaryrefslogtreecommitdiffstats
path: root/package
diff options
context:
space:
mode:
Diffstat (limited to 'package')
-rw-r--r--package/.svn/dir-prop-base7
-rw-r--r--package/.svn/entries164
-rw-r--r--package/.svn/prop-base/Makefile.svn-base5
-rw-r--r--package/.svn/text-base/Makefile.svn-base134
-rw-r--r--package/Makefile134
-rw-r--r--package/acx-mac80211/.svn/entries65
-rw-r--r--package/acx-mac80211/.svn/prop-base/Makefile.svn-base5
-rw-r--r--package/acx-mac80211/.svn/text-base/Makefile.svn-base254
-rw-r--r--package/acx-mac80211/Makefile254
-rw-r--r--package/acx-mac80211/patches/.svn/entries164
-rw-r--r--package/acx-mac80211/patches/.svn/text-base/001-make-compatible-with-recent-mac80211.patch.svn-base30
-rw-r--r--package/acx-mac80211/patches/.svn/text-base/002-remove-usage-of__dev.patch.svn-base85
-rw-r--r--package/acx-mac80211/patches/.svn/text-base/100-hw-queue-check-fix.patch.svn-base42
-rw-r--r--package/acx-mac80211/patches/.svn/text-base/200-initial-macaddr.patch.svn-base31
-rw-r--r--package/acx-mac80211/patches/001-make-compatible-with-recent-mac80211.patch30
-rw-r--r--package/acx-mac80211/patches/002-remove-usage-of__dev.patch85
-rw-r--r--package/acx-mac80211/patches/100-hw-queue-check-fix.patch42
-rw-r--r--package/acx-mac80211/patches/200-initial-macaddr.patch31
-rw-r--r--package/admswconfig/.svn/entries68
-rw-r--r--package/admswconfig/.svn/text-base/Makefile.svn-base52
-rw-r--r--package/admswconfig/Makefile52
-rw-r--r--package/admswconfig/files/.svn/entries96
-rw-r--r--package/admswconfig/files/.svn/text-base/admswconfig.svn-base68
-rw-r--r--package/admswconfig/files/.svn/text-base/admswswitch.sh.svn-base28
-rw-r--r--package/admswconfig/files/admswconfig68
-rw-r--r--package/admswconfig/files/admswswitch.sh28
-rw-r--r--package/admswconfig/patches/.svn/entries62
-rw-r--r--package/admswconfig/patches/.svn/text-base/001-matrix.patch.svn-base15
-rw-r--r--package/admswconfig/patches/001-matrix.patch15
-rw-r--r--package/apex/.svn/entries65
-rw-r--r--package/apex/.svn/text-base/Makefile.svn-base58
-rw-r--r--package/apex/Makefile58
-rw-r--r--package/apex/patches/.svn/entries232
-rw-r--r--package/apex/patches/.svn/prop-base/100-openwrt_nslu2_armeb_config.patch.svn-base5
-rw-r--r--package/apex/patches/.svn/text-base/001-compile_fix.patch.svn-base20
-rw-r--r--package/apex/patches/.svn/text-base/100-openwrt_nslu2_armeb_config.patch.svn-base23
-rw-r--r--package/apex/patches/.svn/text-base/120-openwrt_nslu2_16mb_armeb_config.patch.svn-base23
-rw-r--r--package/apex/patches/.svn/text-base/140-openwrt_fsg3_armeb_config.patch.svn-base23
-rw-r--r--package/apex/patches/.svn/text-base/150-limit_ram_to_64mb.patch.svn-base22
-rw-r--r--package/apex/patches/.svn/text-base/160-openwrt_nas100d_armeb_config.patch.svn-base20
-rw-r--r--package/apex/patches/001-compile_fix.patch20
-rw-r--r--package/apex/patches/100-openwrt_nslu2_armeb_config.patch23
-rw-r--r--package/apex/patches/120-openwrt_nslu2_16mb_armeb_config.patch23
-rw-r--r--package/apex/patches/140-openwrt_fsg3_armeb_config.patch23
-rw-r--r--package/apex/patches/150-limit_ram_to_64mb.patch22
-rw-r--r--package/apex/patches/160-openwrt_nas100d_armeb_config.patch20
-rw-r--r--package/base-files/.svn/entries102
-rw-r--r--package/base-files/.svn/prop-base/Makefile.svn-base9
-rw-r--r--package/base-files/.svn/text-base/Makefile.svn-base169
-rw-r--r--package/base-files/.svn/text-base/image-config.in.svn-base185
-rw-r--r--package/base-files/Makefile169
-rw-r--r--package/base-files/files.old/.svn/entries68
-rw-r--r--package/base-files/files.old/.svn/prop-base/init.svn-base5
-rw-r--r--package/base-files/files.old/.svn/text-base/init.svn-base96
-rw-r--r--package/base-files/files.old/etc/.svn/entries201
-rw-r--r--package/base-files/files.old/etc/.svn/prop-base/inittab.svn-base5
-rw-r--r--package/base-files/files.old/etc/.svn/prop-base/preinit.svn-base9
-rw-r--r--package/base-files/files.old/etc/.svn/prop-base/watchdog.svn-base5
-rw-r--r--package/base-files/files.old/etc/.svn/text-base/hotplug2-common.rules.svn-base43
-rw-r--r--package/base-files/files.old/etc/.svn/text-base/hotplug2-init.rules.svn-base5
-rw-r--r--package/base-files/files.old/etc/.svn/text-base/inittab.svn-base4
-rw-r--r--package/base-files/files.old/etc/.svn/text-base/preinit.svn-base43
-rw-r--r--package/base-files/files.old/etc/.svn/text-base/watchdog.svn-base13
-rw-r--r--package/base-files/files.old/etc/hotplug2-common.rules43
-rw-r--r--package/base-files/files.old/etc/hotplug2-init.rules5
-rw-r--r--package/base-files/files.old/etc/init.d/.svn/entries130
-rw-r--r--package/base-files/files.old/etc/init.d/.svn/prop-base/boot.svn-base9
-rw-r--r--package/base-files/files.old/etc/init.d/.svn/prop-base/rcS.svn-base9
-rw-r--r--package/base-files/files.old/etc/init.d/.svn/prop-base/watchdog.svn-base5
-rw-r--r--package/base-files/files.old/etc/init.d/.svn/text-base/boot.svn-base110
-rw-r--r--package/base-files/files.old/etc/init.d/.svn/text-base/rcS.svn-base26
-rw-r--r--package/base-files/files.old/etc/init.d/.svn/text-base/watchdog.svn-base13
-rwxr-xr-xpackage/base-files/files.old/etc/init.d/boot110
-rwxr-xr-xpackage/base-files/files.old/etc/init.d/rcS26
-rwxr-xr-xpackage/base-files/files.old/etc/init.d/watchdog13
-rw-r--r--package/base-files/files.old/etc/inittab4
-rwxr-xr-xpackage/base-files/files.old/etc/preinit43
-rwxr-xr-xpackage/base-files/files.old/etc/watchdog13
-rwxr-xr-xpackage/base-files/files.old/init96
-rw-r--r--package/base-files/files.old/lib/.svn/entries37
-rw-r--r--package/base-files/files.old/lib/firstboot/.svn/entries62
-rw-r--r--package/base-files/files.old/lib/firstboot/.svn/text-base/99_10_with_fo_cleanup.svn-base25
-rw-r--r--package/base-files/files.old/lib/firstboot/99_10_with_fo_cleanup25
-rw-r--r--package/base-files/files.old/lib/preinit/.svn/entries436
-rw-r--r--package/base-files/files.old/lib/preinit/.svn/text-base/10_essential_fs.svn-base25
-rw-r--r--package/base-files/files.old/lib/preinit/.svn/text-base/10_indicate_preinit.svn-base51
-rw-r--r--package/base-files/files.old/lib/preinit/.svn/text-base/20_device_fs_mount.svn-base37
-rw-r--r--package/base-files/files.old/lib/preinit/.svn/text-base/30_device_fs_daemons.svn-base36
-rw-r--r--package/base-files/files.old/lib/preinit/.svn/text-base/40_init_shm.svn-base10
-rw-r--r--package/base-files/files.old/lib/preinit/.svn/text-base/40_mount_devpts.svn-base15
-rw-r--r--package/base-files/files.old/lib/preinit/.svn/text-base/50_choose_console.svn-base31
-rw-r--r--package/base-files/files.old/lib/preinit/.svn/text-base/50_indicate_regular_preinit.svn-base12
-rw-r--r--package/base-files/files.old/lib/preinit/.svn/text-base/60_init_hotplug.svn-base10
-rw-r--r--package/base-files/files.old/lib/preinit/.svn/text-base/80_mount_root.svn-base10
-rw-r--r--package/base-files/files.old/lib/preinit/.svn/text-base/90_init_console.svn-base14
-rw-r--r--package/base-files/files.old/lib/preinit/.svn/text-base/99_10_run_init.svn-base16
-rw-r--r--package/base-files/files.old/lib/preinit/10_essential_fs25
-rw-r--r--package/base-files/files.old/lib/preinit/10_indicate_preinit51
-rw-r--r--package/base-files/files.old/lib/preinit/20_device_fs_mount37
-rw-r--r--package/base-files/files.old/lib/preinit/30_device_fs_daemons36
-rw-r--r--package/base-files/files.old/lib/preinit/40_init_shm10
-rw-r--r--package/base-files/files.old/lib/preinit/40_mount_devpts15
-rw-r--r--package/base-files/files.old/lib/preinit/50_choose_console31
-rw-r--r--package/base-files/files.old/lib/preinit/50_indicate_regular_preinit12
-rw-r--r--package/base-files/files.old/lib/preinit/60_init_hotplug10
-rw-r--r--package/base-files/files.old/lib/preinit/80_mount_root10
-rw-r--r--package/base-files/files.old/lib/preinit/90_init_console14
-rw-r--r--package/base-files/files.old/lib/preinit/99_10_run_init16
-rw-r--r--package/base-files/files.old/lib/upgrade/.svn/entries62
-rw-r--r--package/base-files/files.old/lib/upgrade/.svn/text-base/common.sh.svn-base230
-rw-r--r--package/base-files/files.old/lib/upgrade/common.sh230
-rw-r--r--package/base-files/files/.svn/entries43
-rw-r--r--package/base-files/files/bin/.svn/entries96
-rw-r--r--package/base-files/files/bin/.svn/prop-base/ipcalc.sh.svn-base9
-rw-r--r--package/base-files/files/bin/.svn/prop-base/login.sh.svn-base9
-rw-r--r--package/base-files/files/bin/.svn/text-base/ipcalc.sh.svn-base67
-rw-r--r--package/base-files/files/bin/.svn/text-base/login.sh.svn-base19
-rwxr-xr-xpackage/base-files/files/bin/ipcalc.sh67
-rwxr-xr-xpackage/base-files/files/bin/login.sh19
-rw-r--r--package/base-files/files/etc/.svn/entries655
-rw-r--r--package/base-files/files/etc/.svn/prop-base/banner.svn-base5
-rw-r--r--package/base-files/files/etc/.svn/prop-base/group.svn-base5
-rw-r--r--package/base-files/files/etc/.svn/prop-base/hosts.svn-base5
-rw-r--r--package/base-files/files/etc/.svn/prop-base/inittab.svn-base5
-rw-r--r--package/base-files/files/etc/.svn/prop-base/passwd.svn-base5
-rw-r--r--package/base-files/files/etc/.svn/prop-base/preinit.svn-base9
-rw-r--r--package/base-files/files/etc/.svn/prop-base/profile.svn-base5
-rw-r--r--package/base-files/files/etc/.svn/prop-base/protocols.svn-base5
-rw-r--r--package/base-files/files/etc/.svn/prop-base/rc.common.svn-base9
-rw-r--r--package/base-files/files/etc/.svn/prop-base/shells.svn-base5
-rw-r--r--package/base-files/files/etc/.svn/prop-base/sysctl.conf.svn-base5
-rw-r--r--package/base-files/files/etc/.svn/text-base/banner.svn-base13
-rw-r--r--package/base-files/files/etc/.svn/text-base/diag.sh.svn-base4
-rw-r--r--package/base-files/files/etc/.svn/text-base/group.svn-base10
-rw-r--r--package/base-files/files/etc/.svn/text-base/hosts.svn-base1
-rw-r--r--package/base-files/files/etc/.svn/text-base/inittab.svn-base3
-rw-r--r--package/base-files/files/etc/.svn/text-base/openwrt_release.svn-base6
-rw-r--r--package/base-files/files/etc/.svn/text-base/openwrt_version.svn-base1
-rw-r--r--package/base-files/files/etc/.svn/text-base/passwd.svn-base5
-rw-r--r--package/base-files/files/etc/.svn/text-base/preinit.svn-base45
-rw-r--r--package/base-files/files/etc/.svn/text-base/profile.svn-base15
-rw-r--r--package/base-files/files/etc/.svn/text-base/protocols.svn-base56
-rw-r--r--package/base-files/files/etc/.svn/text-base/rc.common.svn-base116
-rw-r--r--package/base-files/files/etc/.svn/text-base/rc.local.svn-base4
-rw-r--r--package/base-files/files/etc/.svn/text-base/services.svn-base171
-rw-r--r--package/base-files/files/etc/.svn/text-base/shadow.svn-base5
-rw-r--r--package/base-files/files/etc/.svn/text-base/shells.svn-base1
-rw-r--r--package/base-files/files/etc/.svn/text-base/sysctl.conf.svn-base28
-rw-r--r--package/base-files/files/etc/.svn/text-base/sysupgrade.conf.svn-base5
-rw-r--r--package/base-files/files/etc/banner13
-rw-r--r--package/base-files/files/etc/config/.svn/entries96
-rw-r--r--package/base-files/files/etc/config/.svn/prop-base/network.svn-base5
-rw-r--r--package/base-files/files/etc/config/.svn/text-base/network.svn-base14
-rw-r--r--package/base-files/files/etc/config/.svn/text-base/system.svn-base10
-rw-r--r--package/base-files/files/etc/config/network14
-rw-r--r--package/base-files/files/etc/config/system10
-rw-r--r--package/base-files/files/etc/diag.sh4
-rw-r--r--package/base-files/files/etc/group10
-rw-r--r--package/base-files/files/etc/hosts1
-rw-r--r--package/base-files/files/etc/hotplug.d/.svn/entries37
-rw-r--r--package/base-files/files/etc/hotplug.d/ieee1394/.svn/entries62
-rw-r--r--package/base-files/files/etc/hotplug.d/ieee1394/.svn/text-base/10-ieee1394.svn-base13
-rw-r--r--package/base-files/files/etc/hotplug.d/ieee1394/10-ieee139413
-rw-r--r--package/base-files/files/etc/hotplug.d/iface/.svn/entries28
-rw-r--r--package/base-files/files/etc/hotplug.d/usb/.svn/entries62
-rw-r--r--package/base-files/files/etc/hotplug.d/usb/.svn/text-base/10-usb.svn-base13
-rw-r--r--package/base-files/files/etc/hotplug.d/usb/10-usb13
-rw-r--r--package/base-files/files/etc/init.d/.svn/entries300
-rw-r--r--package/base-files/files/etc/init.d/.svn/prop-base/boot.svn-base9
-rw-r--r--package/base-files/files/etc/init.d/.svn/prop-base/done.svn-base5
-rw-r--r--package/base-files/files/etc/init.d/.svn/prop-base/led.svn-base5
-rw-r--r--package/base-files/files/etc/init.d/.svn/prop-base/rcS.svn-base9
-rw-r--r--package/base-files/files/etc/init.d/.svn/prop-base/sysctl.svn-base5
-rw-r--r--package/base-files/files/etc/init.d/.svn/prop-base/sysntpd.svn-base5
-rw-r--r--package/base-files/files/etc/init.d/.svn/prop-base/umount.svn-base5
-rw-r--r--package/base-files/files/etc/init.d/.svn/prop-base/usb.svn-base9
-rw-r--r--package/base-files/files/etc/init.d/.svn/text-base/boot.svn-base78
-rw-r--r--package/base-files/files/etc/init.d/.svn/text-base/done.svn-base20
-rw-r--r--package/base-files/files/etc/init.d/.svn/text-base/led.svn-base92
-rw-r--r--package/base-files/files/etc/init.d/.svn/text-base/rcS.svn-base9
-rw-r--r--package/base-files/files/etc/init.d/.svn/text-base/sysctl.svn-base7
-rw-r--r--package/base-files/files/etc/init.d/.svn/text-base/sysntpd.svn-base37
-rw-r--r--package/base-files/files/etc/init.d/.svn/text-base/umount.svn-base8
-rw-r--r--package/base-files/files/etc/init.d/.svn/text-base/usb.svn-base9
-rwxr-xr-xpackage/base-files/files/etc/init.d/boot78
-rwxr-xr-xpackage/base-files/files/etc/init.d/done20
-rwxr-xr-xpackage/base-files/files/etc/init.d/led92
-rwxr-xr-xpackage/base-files/files/etc/init.d/rcS9
-rwxr-xr-xpackage/base-files/files/etc/init.d/sysctl7
-rwxr-xr-xpackage/base-files/files/etc/init.d/sysntpd37
-rwxr-xr-xpackage/base-files/files/etc/init.d/umount8
-rwxr-xr-xpackage/base-files/files/etc/init.d/usb9
-rw-r--r--package/base-files/files/etc/inittab3
-rw-r--r--package/base-files/files/etc/openwrt_release6
-rw-r--r--package/base-files/files/etc/openwrt_version1
-rw-r--r--package/base-files/files/etc/passwd5
-rwxr-xr-xpackage/base-files/files/etc/preinit45
-rw-r--r--package/base-files/files/etc/profile15
-rw-r--r--package/base-files/files/etc/protocols56
-rw-r--r--package/base-files/files/etc/rc.button/.svn/entries130
-rw-r--r--package/base-files/files/etc/rc.button/.svn/prop-base/failsafe.svn-base5
-rw-r--r--package/base-files/files/etc/rc.button/.svn/prop-base/reset.svn-base5
-rw-r--r--package/base-files/files/etc/rc.button/.svn/prop-base/rfkill.svn-base5
-rw-r--r--package/base-files/files/etc/rc.button/.svn/text-base/failsafe.svn-base2
-rw-r--r--package/base-files/files/etc/rc.button/.svn/text-base/reset.svn-base18
-rw-r--r--package/base-files/files/etc/rc.button/.svn/text-base/rfkill.svn-base23
-rwxr-xr-xpackage/base-files/files/etc/rc.button/failsafe2
-rwxr-xr-xpackage/base-files/files/etc/rc.button/reset18
-rwxr-xr-xpackage/base-files/files/etc/rc.button/rfkill23
-rwxr-xr-xpackage/base-files/files/etc/rc.common116
-rw-r--r--package/base-files/files/etc/rc.local4
-rw-r--r--package/base-files/files/etc/services171
-rw-r--r--package/base-files/files/etc/shadow5
-rw-r--r--package/base-files/files/etc/shells1
-rw-r--r--package/base-files/files/etc/sysctl.conf28
-rw-r--r--package/base-files/files/etc/sysupgrade.conf5
-rw-r--r--package/base-files/files/etc/uci-defaults/.svn/entries130
-rw-r--r--package/base-files/files/etc/uci-defaults/.svn/text-base/10_migrate-shadow.svn-base12
-rw-r--r--package/base-files/files/etc/uci-defaults/.svn/text-base/11_migrate-sysctl.svn-base17
-rw-r--r--package/base-files/files/etc/uci-defaults/.svn/text-base/12_network-generate-ula.svn-base18
-rw-r--r--package/base-files/files/etc/uci-defaults/10_migrate-shadow12
-rw-r--r--package/base-files/files/etc/uci-defaults/11_migrate-sysctl17
-rw-r--r--package/base-files/files/etc/uci-defaults/12_network-generate-ula18
-rw-r--r--package/base-files/files/lib/.svn/entries74
-rw-r--r--package/base-files/files/lib/.svn/prop-base/functions.sh.svn-base9
-rw-r--r--package/base-files/files/lib/.svn/text-base/functions.sh.svn-base543
-rw-r--r--package/base-files/files/lib/firstboot/.svn/entries538
-rw-r--r--package/base-files/files/lib/firstboot/.svn/text-base/05_firstboot_skip.svn-base10
-rw-r--r--package/base-files/files/lib/firstboot/.svn/text-base/10_determine_parts.svn-base46
-rw-r--r--package/base-files/files/lib/firstboot/.svn/text-base/10_no_fo_clear_overlay.svn-base17
-rw-r--r--package/base-files/files/lib/firstboot/.svn/text-base/10_reset_has_mini_fo.svn-base12
-rw-r--r--package/base-files/files/lib/firstboot/.svn/text-base/20_has_mini_fo.svn-base13
-rw-r--r--package/base-files/files/lib/firstboot/.svn/text-base/20_no_fo_mount_jffs.svn-base15
-rw-r--r--package/base-files/files/lib/firstboot/.svn/text-base/20_reset_clear_jffs.svn-base14
-rw-r--r--package/base-files/files/lib/firstboot/.svn/text-base/30_is_rootfs_mounted.svn-base10
-rw-r--r--package/base-files/files/lib/firstboot/.svn/text-base/30_no_fo_pivot.svn-base11
-rw-r--r--package/base-files/files/lib/firstboot/.svn/text-base/30_reset_copy_rom.svn-base13
-rw-r--r--package/base-files/files/lib/firstboot/.svn/text-base/40_copy_ramoverlay.svn-base15
-rw-r--r--package/base-files/files/lib/firstboot/.svn/text-base/40_no_fo_copy_ramoverlay.svn-base14
-rw-r--r--package/base-files/files/lib/firstboot/.svn/text-base/50_pivot.svn-base17
-rw-r--r--package/base-files/files/lib/firstboot/.svn/text-base/99_10_no_fo_cleanup.svn-base13
-rw-r--r--package/base-files/files/lib/firstboot/.svn/text-base/99_10_with_fo_cleanup.svn-base25
-rw-r--r--package/base-files/files/lib/firstboot/05_firstboot_skip10
-rw-r--r--package/base-files/files/lib/firstboot/10_determine_parts46
-rw-r--r--package/base-files/files/lib/firstboot/10_no_fo_clear_overlay17
-rw-r--r--package/base-files/files/lib/firstboot/10_reset_has_mini_fo12
-rw-r--r--package/base-files/files/lib/firstboot/20_has_mini_fo13
-rw-r--r--package/base-files/files/lib/firstboot/20_no_fo_mount_jffs15
-rw-r--r--package/base-files/files/lib/firstboot/20_reset_clear_jffs14
-rw-r--r--package/base-files/files/lib/firstboot/30_is_rootfs_mounted10
-rw-r--r--package/base-files/files/lib/firstboot/30_no_fo_pivot11
-rw-r--r--package/base-files/files/lib/firstboot/30_reset_copy_rom13
-rw-r--r--package/base-files/files/lib/firstboot/40_copy_ramoverlay15
-rw-r--r--package/base-files/files/lib/firstboot/40_no_fo_copy_ramoverlay14
-rw-r--r--package/base-files/files/lib/firstboot/50_pivot17
-rw-r--r--package/base-files/files/lib/firstboot/99_10_no_fo_cleanup13
-rw-r--r--package/base-files/files/lib/firstboot/99_10_with_fo_cleanup25
-rwxr-xr-xpackage/base-files/files/lib/functions.sh543
-rw-r--r--package/base-files/files/lib/functions/.svn/entries164
-rw-r--r--package/base-files/files/lib/functions/.svn/prop-base/leds.sh.svn-base5
-rw-r--r--package/base-files/files/lib/functions/.svn/prop-base/uci-defaults.sh.svn-base5
-rw-r--r--package/base-files/files/lib/functions/.svn/text-base/leds.sh.svn-base68
-rw-r--r--package/base-files/files/lib/functions/.svn/text-base/network.sh.svn-base350
-rw-r--r--package/base-files/files/lib/functions/.svn/text-base/service.sh.svn-base129
-rw-r--r--package/base-files/files/lib/functions/.svn/text-base/uci-defaults.sh.svn-base230
-rw-r--r--package/base-files/files/lib/functions/leds.sh68
-rw-r--r--package/base-files/files/lib/functions/network.sh350
-rw-r--r--package/base-files/files/lib/functions/service.sh129
-rw-r--r--package/base-files/files/lib/functions/uci-defaults.sh230
-rw-r--r--package/base-files/files/lib/preinit/.svn/entries674
-rw-r--r--package/base-files/files/lib/preinit/.svn/text-base/02_default_set_state.svn-base7
-rw-r--r--package/base-files/files/lib/preinit/.svn/text-base/05_mount_skip.svn-base13
-rw-r--r--package/base-files/files/lib/preinit/.svn/text-base/10_check_for_mtd.svn-base20
-rw-r--r--package/base-files/files/lib/preinit/.svn/text-base/10_indicate_failsafe.svn-base18
-rw-r--r--package/base-files/files/lib/preinit/.svn/text-base/10_indicate_preinit.svn-base50
-rw-r--r--package/base-files/files/lib/preinit/.svn/text-base/20_check_jffs2_ready.svn-base19
-rw-r--r--package/base-files/files/lib/preinit/.svn/text-base/30_failsafe_wait.svn-base84
-rw-r--r--package/base-files/files/lib/preinit/.svn/text-base/40_mount_jffs2.svn-base26
-rw-r--r--package/base-files/files/lib/preinit/.svn/text-base/40_run_failsafe_hook.svn-base13
-rw-r--r--package/base-files/files/lib/preinit/.svn/text-base/41_merge_overlay_hooks.svn-base24
-rw-r--r--package/base-files/files/lib/preinit/.svn/text-base/50_indicate_regular_preinit.svn-base11
-rw-r--r--package/base-files/files/lib/preinit/.svn/text-base/70_initramfs_test.svn-base14
-rw-r--r--package/base-files/files/lib/preinit/.svn/text-base/70_pivot_jffs2_root.svn-base14
-rw-r--r--package/base-files/files/lib/preinit/.svn/text-base/80_mount_root.svn-base9
-rw-r--r--package/base-files/files/lib/preinit/.svn/text-base/90_mount_no_jffs2.svn-base12
-rw-r--r--package/base-files/files/lib/preinit/.svn/text-base/90_restore_config.svn-base17
-rw-r--r--package/base-files/files/lib/preinit/.svn/text-base/99_10_failsafe_login.svn-base18
-rw-r--r--package/base-files/files/lib/preinit/.svn/text-base/99_10_mount_no_mtd.svn-base12
-rw-r--r--package/base-files/files/lib/preinit/.svn/text-base/99_10_run_init.svn-base10
-rw-r--r--package/base-files/files/lib/preinit/02_default_set_state7
-rw-r--r--package/base-files/files/lib/preinit/05_mount_skip13
-rw-r--r--package/base-files/files/lib/preinit/10_check_for_mtd20
-rw-r--r--package/base-files/files/lib/preinit/10_indicate_failsafe18
-rw-r--r--package/base-files/files/lib/preinit/10_indicate_preinit50
-rw-r--r--package/base-files/files/lib/preinit/20_check_jffs2_ready19
-rw-r--r--package/base-files/files/lib/preinit/30_failsafe_wait84
-rw-r--r--package/base-files/files/lib/preinit/40_mount_jffs226
-rw-r--r--package/base-files/files/lib/preinit/40_run_failsafe_hook13
-rw-r--r--package/base-files/files/lib/preinit/41_merge_overlay_hooks24
-rw-r--r--package/base-files/files/lib/preinit/50_indicate_regular_preinit11
-rw-r--r--package/base-files/files/lib/preinit/70_initramfs_test14
-rw-r--r--package/base-files/files/lib/preinit/70_pivot_jffs2_root14
-rw-r--r--package/base-files/files/lib/preinit/80_mount_root9
-rw-r--r--package/base-files/files/lib/preinit/90_mount_no_jffs212
-rw-r--r--package/base-files/files/lib/preinit/90_restore_config17
-rw-r--r--package/base-files/files/lib/preinit/99_10_failsafe_login18
-rw-r--r--package/base-files/files/lib/preinit/99_10_mount_no_mtd12
-rw-r--r--package/base-files/files/lib/preinit/99_10_run_init10
-rw-r--r--package/base-files/files/lib/upgrade/.svn/entries65
-rw-r--r--package/base-files/files/lib/upgrade/.svn/text-base/common.sh.svn-base230
-rw-r--r--package/base-files/files/lib/upgrade/common.sh230
-rw-r--r--package/base-files/files/lib/upgrade/keep.d/.svn/entries62
-rw-r--r--package/base-files/files/lib/upgrade/keep.d/.svn/text-base/base-files-essential.svn-base9
-rw-r--r--package/base-files/files/lib/upgrade/keep.d/base-files-essential9
-rw-r--r--package/base-files/files/rom/.svn/entries62
-rw-r--r--package/base-files/files/rom/.svn/prop-base/note.svn-base5
-rw-r--r--package/base-files/files/rom/.svn/text-base/note.svn-base3
-rw-r--r--package/base-files/files/rom/note3
-rw-r--r--package/base-files/files/sbin/.svn/entries232
-rw-r--r--package/base-files/files/sbin/.svn/prop-base/firstboot.svn-base9
-rw-r--r--package/base-files/files/sbin/.svn/prop-base/hotplug-call.svn-base9
-rw-r--r--package/base-files/files/sbin/.svn/prop-base/led.sh.svn-base5
-rw-r--r--package/base-files/files/sbin/.svn/prop-base/mount_root.svn-base9
-rw-r--r--package/base-files/files/sbin/.svn/prop-base/sysupgrade.svn-base5
-rw-r--r--package/base-files/files/sbin/.svn/prop-base/wifi.svn-base9
-rw-r--r--package/base-files/files/sbin/.svn/text-base/firstboot.svn-base42
-rw-r--r--package/base-files/files/sbin/.svn/text-base/hotplug-call.svn-base17
-rw-r--r--package/base-files/files/sbin/.svn/text-base/led.sh.svn-base25
-rw-r--r--package/base-files/files/sbin/.svn/text-base/mount_root.svn-base26
-rw-r--r--package/base-files/files/sbin/.svn/text-base/sysupgrade.svn-base191
-rw-r--r--package/base-files/files/sbin/.svn/text-base/wifi.svn-base204
-rwxr-xr-xpackage/base-files/files/sbin/firstboot42
-rwxr-xr-xpackage/base-files/files/sbin/hotplug-call17
-rwxr-xr-xpackage/base-files/files/sbin/led.sh25
-rwxr-xr-xpackage/base-files/files/sbin/mount_root26
-rwxr-xr-xpackage/base-files/files/sbin/sysupgrade191
-rwxr-xr-xpackage/base-files/files/sbin/wifi204
-rw-r--r--package/base-files/image-config.in185
-rw-r--r--package/block-mount/.svn/entries99
-rw-r--r--package/block-mount/.svn/text-base/Config.in.svn-base17
-rw-r--r--package/block-mount/.svn/text-base/Makefile.svn-base70
-rw-r--r--package/block-mount/Config.in17
-rw-r--r--package/block-mount/Makefile70
-rw-r--r--package/block-mount/files/.svn/entries436
-rw-r--r--package/block-mount/files/.svn/text-base/10-swap.svn-base78
-rw-r--r--package/block-mount/files/.svn/text-base/20-fsck.svn-base83
-rw-r--r--package/block-mount/files/.svn/text-base/40-mount.svn-base91
-rw-r--r--package/block-mount/files/.svn/text-base/50_determine_usb_root.svn-base65
-rw-r--r--package/block-mount/files/.svn/text-base/55_determine_extroot_sysupgrade.svn-base63
-rw-r--r--package/block-mount/files/.svn/text-base/60_pivot_usb_root.svn-base27
-rw-r--r--package/block-mount/files/.svn/text-base/block.sh.svn-base264
-rw-r--r--package/block-mount/files/.svn/text-base/extmount.sh.svn-base37
-rw-r--r--package/block-mount/files/.svn/text-base/fsck.sh.svn-base34
-rw-r--r--package/block-mount/files/.svn/text-base/fstab.config.svn-base20
-rw-r--r--package/block-mount/files/.svn/text-base/fstab.init.svn-base92
-rw-r--r--package/block-mount/files/.svn/text-base/mount.sh.svn-base103
-rw-r--r--package/block-mount/files/10-swap78
-rw-r--r--package/block-mount/files/20-fsck83
-rw-r--r--package/block-mount/files/40-mount91
-rw-r--r--package/block-mount/files/50_determine_usb_root65
-rw-r--r--package/block-mount/files/55_determine_extroot_sysupgrade63
-rw-r--r--package/block-mount/files/60_pivot_usb_root27
-rw-r--r--package/block-mount/files/block.sh264
-rw-r--r--package/block-mount/files/extmount.sh37
-rw-r--r--package/block-mount/files/fsck.sh34
-rw-r--r--package/block-mount/files/fstab.config20
-rw-r--r--package/block-mount/files/fstab.init92
-rw-r--r--package/block-mount/files/mount.sh103
-rw-r--r--package/boot/.svn/entries67
-rw-r--r--package/boot/fconfig/.svn/entries62
-rw-r--r--package/boot/fconfig/.svn/prop-base/Makefile.svn-base9
-rw-r--r--package/boot/fconfig/.svn/text-base/Makefile.svn-base45
-rw-r--r--package/boot/fconfig/Makefile45
-rw-r--r--package/boot/grub2/.svn/entries65
-rw-r--r--package/boot/grub2/.svn/text-base/Makefile.svn-base51
-rw-r--r--package/boot/grub2/Makefile51
-rw-r--r--package/boot/grub2/patches/.svn/entries130
-rw-r--r--package/boot/grub2/patches/.svn/text-base/100-grub_setup_root.patch.svn-base77
-rw-r--r--package/boot/grub2/patches/.svn/text-base/200-fix-gets-removal.patch.svn-base15
-rw-r--r--package/boot/grub2/patches/.svn/text-base/200-grub_musl.patch.svn-base22
-rw-r--r--package/boot/grub2/patches/100-grub_setup_root.patch77
-rw-r--r--package/boot/grub2/patches/200-fix-gets-removal.patch15
-rw-r--r--package/boot/grub2/patches/200-grub_musl.patch22
-rw-r--r--package/boot/kexec-tools/.svn/entries99
-rw-r--r--package/boot/kexec-tools/.svn/prop-base/Config.in.svn-base5
-rw-r--r--package/boot/kexec-tools/.svn/prop-base/Makefile.svn-base9
-rw-r--r--package/boot/kexec-tools/.svn/text-base/Config.in.svn-base21
-rw-r--r--package/boot/kexec-tools/.svn/text-base/Makefile.svn-base80
-rw-r--r--package/boot/kexec-tools/Config.in21
-rw-r--r--package/boot/kexec-tools/Makefile80
-rw-r--r--package/boot/kexec-tools/patches/.svn/entries62
-rw-r--r--package/boot/kexec-tools/patches/.svn/text-base/0004-mips_regdefs.patch.svn-base103
-rw-r--r--package/boot/kexec-tools/patches/0004-mips_regdefs.patch103
-rw-r--r--package/boot/rbcfg/.svn/entries65
-rw-r--r--package/boot/rbcfg/.svn/prop-base/Makefile.svn-base5
-rw-r--r--package/boot/rbcfg/.svn/text-base/Makefile.svn-base49
-rw-r--r--package/boot/rbcfg/Makefile49
-rw-r--r--package/boot/rbcfg/src/.svn/entries198
-rw-r--r--package/boot/rbcfg/src/.svn/prop-base/Makefile.svn-base5
-rw-r--r--package/boot/rbcfg/src/.svn/prop-base/cyg_crc.h.svn-base5
-rw-r--r--package/boot/rbcfg/src/.svn/prop-base/cyg_crc32.c.svn-base5
-rw-r--r--package/boot/rbcfg/src/.svn/prop-base/main.c.svn-base5
-rw-r--r--package/boot/rbcfg/src/.svn/prop-base/rbcfg.h.svn-base5
-rw-r--r--package/boot/rbcfg/src/.svn/text-base/Makefile.svn-base14
-rw-r--r--package/boot/rbcfg/src/.svn/text-base/cyg_crc.h.svn-base109
-rw-r--r--package/boot/rbcfg/src/.svn/text-base/cyg_crc32.c.svn-base172
-rw-r--r--package/boot/rbcfg/src/.svn/text-base/main.c.svn-base791
-rw-r--r--package/boot/rbcfg/src/.svn/text-base/rbcfg.h.svn-base75
-rw-r--r--package/boot/rbcfg/src/Makefile14
-rw-r--r--package/boot/rbcfg/src/cyg_crc.h109
-rw-r--r--package/boot/rbcfg/src/cyg_crc32.c172
-rw-r--r--package/boot/rbcfg/src/main.c791
-rw-r--r--package/boot/rbcfg/src/rbcfg.h75
-rw-r--r--package/boot/uboot-ar71xx/.svn/entries68
-rw-r--r--package/boot/uboot-ar71xx/.svn/prop-base/Makefile.svn-base5
-rw-r--r--package/boot/uboot-ar71xx/.svn/text-base/Makefile.svn-base90
-rw-r--r--package/boot/uboot-ar71xx/Makefile90
-rw-r--r--package/boot/uboot-ar71xx/files/.svn/entries40
-rw-r--r--package/boot/uboot-ar71xx/files/board/.svn/entries31
-rw-r--r--package/boot/uboot-ar71xx/files/board/zyxel/.svn/entries31
-rw-r--r--package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/.svn/entries198
-rw-r--r--package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/.svn/prop-base/Makefile.svn-base5
-rw-r--r--package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/.svn/prop-base/config.mk.svn-base5
-rw-r--r--package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/.svn/prop-base/nbg460n.c.svn-base5
-rw-r--r--package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/.svn/text-base/Makefile.svn-base46
-rw-r--r--package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/.svn/text-base/config.mk.svn-base1
-rw-r--r--package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/.svn/text-base/lowlevel_init.S.svn-base39
-rw-r--r--package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/.svn/text-base/nbg460n.c.svn-base96
-rw-r--r--package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/.svn/text-base/u-boot.lds.svn-base42
-rw-r--r--package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/Makefile46
-rw-r--r--package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/config.mk1
-rw-r--r--package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/lowlevel_init.S39
-rw-r--r--package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/nbg460n.c96
-rw-r--r--package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/u-boot.lds42
-rw-r--r--package/boot/uboot-ar71xx/files/cpu/.svn/entries31
-rw-r--r--package/boot/uboot-ar71xx/files/cpu/mips/.svn/entries62
-rw-r--r--package/boot/uboot-ar71xx/files/cpu/mips/.svn/prop-base/ar71xx_serial.c.svn-base5
-rw-r--r--package/boot/uboot-ar71xx/files/cpu/mips/.svn/text-base/ar71xx_serial.c.svn-base177
-rw-r--r--package/boot/uboot-ar71xx/files/cpu/mips/ar71xx_serial.c177
-rw-r--r--package/boot/uboot-ar71xx/files/drivers/.svn/entries34
-rw-r--r--package/boot/uboot-ar71xx/files/drivers/net/.svn/entries99
-rw-r--r--package/boot/uboot-ar71xx/files/drivers/net/.svn/prop-base/ag71xx.c.svn-base5
-rw-r--r--package/boot/uboot-ar71xx/files/drivers/net/.svn/prop-base/ag71xx.h.svn-base5
-rw-r--r--package/boot/uboot-ar71xx/files/drivers/net/.svn/text-base/ag71xx.c.svn-base809
-rw-r--r--package/boot/uboot-ar71xx/files/drivers/net/.svn/text-base/ag71xx.h.svn-base374
-rw-r--r--package/boot/uboot-ar71xx/files/drivers/net/ag71xx.c809
-rw-r--r--package/boot/uboot-ar71xx/files/drivers/net/ag71xx.h374
-rw-r--r--package/boot/uboot-ar71xx/files/drivers/net/phy/.svn/entries96
-rw-r--r--package/boot/uboot-ar71xx/files/drivers/net/phy/.svn/prop-base/rtl8366.h.svn-base5
-rw-r--r--package/boot/uboot-ar71xx/files/drivers/net/phy/.svn/prop-base/rtl8366_mii.c.svn-base5
-rw-r--r--package/boot/uboot-ar71xx/files/drivers/net/phy/.svn/text-base/rtl8366.h.svn-base188
-rw-r--r--package/boot/uboot-ar71xx/files/drivers/net/phy/.svn/text-base/rtl8366_mii.c.svn-base786
-rw-r--r--package/boot/uboot-ar71xx/files/drivers/net/phy/rtl8366.h188
-rw-r--r--package/boot/uboot-ar71xx/files/drivers/net/phy/rtl8366_mii.c786
-rw-r--r--package/boot/uboot-ar71xx/files/drivers/spi/.svn/entries62
-rw-r--r--package/boot/uboot-ar71xx/files/drivers/spi/.svn/prop-base/ar71xx_spi.c.svn-base5
-rw-r--r--package/boot/uboot-ar71xx/files/drivers/spi/.svn/text-base/ar71xx_spi.c.svn-base191
-rw-r--r--package/boot/uboot-ar71xx/files/drivers/spi/ar71xx_spi.c191
-rw-r--r--package/boot/uboot-ar71xx/files/include/.svn/entries34
-rw-r--r--package/boot/uboot-ar71xx/files/include/asm-mips/.svn/entries96
-rw-r--r--package/boot/uboot-ar71xx/files/include/asm-mips/.svn/prop-base/ar71xx.h.svn-base5
-rw-r--r--package/boot/uboot-ar71xx/files/include/asm-mips/.svn/prop-base/ar71xx_gpio.h.svn-base5
-rw-r--r--package/boot/uboot-ar71xx/files/include/asm-mips/.svn/text-base/ar71xx.h.svn-base515
-rw-r--r--package/boot/uboot-ar71xx/files/include/asm-mips/.svn/text-base/ar71xx_gpio.h.svn-base65
-rw-r--r--package/boot/uboot-ar71xx/files/include/asm-mips/ar71xx.h515
-rw-r--r--package/boot/uboot-ar71xx/files/include/asm-mips/ar71xx_gpio.h65
-rw-r--r--package/boot/uboot-ar71xx/files/include/configs/.svn/entries62
-rw-r--r--package/boot/uboot-ar71xx/files/include/configs/.svn/prop-base/nbg460n.h.svn-base5
-rw-r--r--package/boot/uboot-ar71xx/files/include/configs/.svn/text-base/nbg460n.h.svn-base136
-rw-r--r--package/boot/uboot-ar71xx/files/include/configs/nbg460n.h136
-rw-r--r--package/boot/uboot-ar71xx/patches/.svn/entries266
-rw-r--r--package/boot/uboot-ar71xx/patches/.svn/text-base/001-ar71xx.patch.svn-base28
-rw-r--r--package/boot/uboot-ar71xx/patches/.svn/text-base/002-ar71xx-spi.patch.svn-base11
-rw-r--r--package/boot/uboot-ar71xx/patches/.svn/text-base/010-enet-ag71xx.patch.svn-base22
-rw-r--r--package/boot/uboot-ar71xx/patches/.svn/text-base/011-switch-rtl8366sr.patch.svn-base28
-rw-r--r--package/boot/uboot-ar71xx/patches/.svn/text-base/020-freebsd-compat.patch.svn-base11
-rw-r--r--package/boot/uboot-ar71xx/patches/.svn/text-base/021-darwin_compat.patch.svn-base23
-rw-r--r--package/boot/uboot-ar71xx/patches/.svn/text-base/022-getline_backport.patch.svn-base21
-rw-r--r--package/boot/uboot-ar71xx/patches/001-ar71xx.patch28
-rw-r--r--package/boot/uboot-ar71xx/patches/002-ar71xx-spi.patch11
-rw-r--r--package/boot/uboot-ar71xx/patches/010-enet-ag71xx.patch22
-rw-r--r--package/boot/uboot-ar71xx/patches/011-switch-rtl8366sr.patch28
-rw-r--r--package/boot/uboot-ar71xx/patches/020-freebsd-compat.patch11
-rw-r--r--package/boot/uboot-ar71xx/patches/021-darwin_compat.patch23
-rw-r--r--package/boot/uboot-ar71xx/patches/022-getline_backport.patch21
-rw-r--r--package/boot/uboot-envtools/.svn/entries68
-rw-r--r--package/boot/uboot-envtools/.svn/text-base/Makefile.svn-base74
-rw-r--r--package/boot/uboot-envtools/Makefile74
-rw-r--r--package/boot/uboot-envtools/files/.svn/entries198
-rw-r--r--package/boot/uboot-envtools/files/.svn/text-base/ar71xx.svn-base38
-rw-r--r--package/boot/uboot-envtools/files/.svn/text-base/kirkwood.svn-base25
-rw-r--r--package/boot/uboot-envtools/files/.svn/text-base/lantiq.svn-base25
-rw-r--r--package/boot/uboot-envtools/files/.svn/text-base/ramips.svn-base32
-rw-r--r--package/boot/uboot-envtools/files/.svn/text-base/uboot-envtools.sh.svn-base36
-rw-r--r--package/boot/uboot-envtools/files/ar71xx38
-rw-r--r--package/boot/uboot-envtools/files/kirkwood25
-rw-r--r--package/boot/uboot-envtools/files/lantiq25
-rw-r--r--package/boot/uboot-envtools/files/ramips32
-rw-r--r--package/boot/uboot-envtools/files/uboot-envtools.sh36
-rw-r--r--package/boot/uboot-envtools/patches/.svn/entries28
-rw-r--r--package/boot/uboot-kirkwood/.svn/entries68
-rw-r--r--package/boot/uboot-kirkwood/.svn/text-base/Makefile.svn-base104
-rw-r--r--package/boot/uboot-kirkwood/Makefile104
-rw-r--r--package/boot/uboot-kirkwood/files/.svn/entries34
-rw-r--r--package/boot/uboot-kirkwood/files/board/.svn/entries31
-rw-r--r--package/boot/uboot-kirkwood/files/board/iomega/.svn/entries31
-rw-r--r--package/boot/uboot-kirkwood/files/board/iomega/iconnect/.svn/entries28
-rw-r--r--package/boot/uboot-kirkwood/files/include/.svn/entries31
-rw-r--r--package/boot/uboot-kirkwood/files/include/configs/.svn/entries28
-rw-r--r--package/boot/uboot-kirkwood/patches/.svn/entries62
-rw-r--r--package/boot/uboot-kirkwood/patches/.svn/text-base/110-dockstar.patch.svn-base35
-rw-r--r--package/boot/uboot-kirkwood/patches/110-dockstar.patch35
-rw-r--r--package/boot/uboot-lantiq/.svn/entries65
-rw-r--r--package/boot/uboot-lantiq/.svn/text-base/Makefile.svn-base123
-rw-r--r--package/boot/uboot-lantiq/Makefile123
-rw-r--r--package/boot/uboot-lantiq/patches/.svn/entries980
-rw-r--r--package/boot/uboot-lantiq/patches/.svn/text-base/0002-sf-handle-CONFIG_MANUAL_RELOC.patch.svn-base46
-rw-r--r--package/boot/uboot-lantiq/patches/.svn/text-base/0003-sf-factor-out-malloc-from-SPI-flash-drivers.patch.svn-base719
-rw-r--r--package/boot/uboot-lantiq/patches/.svn/text-base/0004-sf-add-malloc-free-probe-functions-dedicated-for-SPL.patch.svn-base131
-rw-r--r--package/boot/uboot-lantiq/patches/.svn/text-base/0005-sf-factor-out-the-flash-address-calculation.patch.svn-base107
-rw-r--r--package/boot/uboot-lantiq/patches/.svn/text-base/0006-sf-add-generic-support-for-4-byte-address-mode.patch.svn-base161
-rw-r--r--package/boot/uboot-lantiq/patches/.svn/text-base/0007-sf-eon-use-16-bit-ID-for-comparison.patch.svn-base45
-rw-r--r--package/boot/uboot-lantiq/patches/.svn/text-base/0008-sf-eon-add-support-for-4-byte-address-mode.patch.svn-base43
-rw-r--r--package/boot/uboot-lantiq/patches/.svn/text-base/0009-sf-eon-add-support-for-EN25QH256.patch.svn-base21
-rw-r--r--package/boot/uboot-lantiq/patches/.svn/text-base/0010-sf-spansion-fix-device-IDs-and-sector-architecture-f.patch.svn-base30
-rw-r--r--package/boot/uboot-lantiq/patches/.svn/text-base/0011-sf-spansion-add-support-for-4-byte-address-mode.patch.svn-base55
-rw-r--r--package/boot/uboot-lantiq/patches/.svn/text-base/0012-sf-spansion-add-support-for-S25FL512S.patch.svn-base23
-rw-r--r--package/boot/uboot-lantiq/patches/.svn/text-base/0013-sf-macronix-add-support-for-4-byte-address-mode.patch.svn-base44
-rw-r--r--package/boot/uboot-lantiq/patches/.svn/text-base/0014-sf-macronix-add-support-for-MX25L25635E.patch.svn-base21
-rw-r--r--package/boot/uboot-lantiq/patches/.svn/text-base/0015-sf-macronix-add-support-for-MX66L51235L.patch.svn-base21
-rw-r--r--package/boot/uboot-lantiq/patches/.svn/text-base/0016-sf-add-MTD-layer-driver-for-SPI-flash-devices.patch.svn-base133
-rw-r--r--package/boot/uboot-lantiq/patches/.svn/text-base/0017-sf-add-init-function.patch.svn-base57
-rw-r--r--package/boot/uboot-lantiq/patches/.svn/text-base/0018-MIPS-add-SPI-flash-init-hook.patch.svn-base47
-rw-r--r--package/boot/uboot-lantiq/patches/.svn/text-base/0019-net-switchlib-add-framework-for-ethernet-switch-driv.patch.svn-base239
-rw-r--r--package/boot/uboot-lantiq/patches/.svn/text-base/0020-net-switchlib-add-driver-for-Lantiq-PSB697X-switch-f.patch.svn-base162
-rw-r--r--package/boot/uboot-lantiq/patches/.svn/text-base/0021-net-switchlib-add-driver-for-Lantiq-ADM6996I-switch-.patch.svn-base158
-rw-r--r--package/boot/uboot-lantiq/patches/.svn/text-base/0022-net-switchlib-add-driver-for-Atheros-AR8216.patch.svn-base158
-rw-r--r--package/boot/uboot-lantiq/patches/.svn/text-base/0023-MIPS-add-support-for-Lantiq-XWAY-SoCs.patch.svn-base9496
-rw-r--r--package/boot/uboot-lantiq/patches/.svn/text-base/0024-MIPS-VRX200-add-option-to-boot-from-AVM-EVA-loader.patch.svn-base33
-rw-r--r--package/boot/uboot-lantiq/patches/.svn/text-base/0025-MIPS-add-board-support-for-AVM-FritzBox-3370.patch.svn-base355
-rw-r--r--package/boot/uboot-lantiq/patches/.svn/text-base/0026-MIPS-add-board-support-for-Gigaset-SX76X.patch.svn-base264
-rw-r--r--package/boot/uboot-lantiq/patches/.svn/text-base/0027-MIPS-add-board-support-for-Arcadyan-ARV7518.patch.svn-base248
-rw-r--r--package/boot/uboot-lantiq/patches/.svn/text-base/0028-MIPS-add-board-support-for-Arcadyan-ARV4519.patch.svn-base248
-rw-r--r--package/boot/uboot-lantiq/patches/.svn/text-base/0029-tools-add-some-helper-tools-for-Lantiq-SoCs.patch.svn-base361
-rw-r--r--package/boot/uboot-lantiq/patches/0002-sf-handle-CONFIG_MANUAL_RELOC.patch46
-rw-r--r--package/boot/uboot-lantiq/patches/0003-sf-factor-out-malloc-from-SPI-flash-drivers.patch719
-rw-r--r--package/boot/uboot-lantiq/patches/0004-sf-add-malloc-free-probe-functions-dedicated-for-SPL.patch131
-rw-r--r--package/boot/uboot-lantiq/patches/0005-sf-factor-out-the-flash-address-calculation.patch107
-rw-r--r--package/boot/uboot-lantiq/patches/0006-sf-add-generic-support-for-4-byte-address-mode.patch161
-rw-r--r--package/boot/uboot-lantiq/patches/0007-sf-eon-use-16-bit-ID-for-comparison.patch45
-rw-r--r--package/boot/uboot-lantiq/patches/0008-sf-eon-add-support-for-4-byte-address-mode.patch43
-rw-r--r--package/boot/uboot-lantiq/patches/0009-sf-eon-add-support-for-EN25QH256.patch21
-rw-r--r--package/boot/uboot-lantiq/patches/0010-sf-spansion-fix-device-IDs-and-sector-architecture-f.patch30
-rw-r--r--package/boot/uboot-lantiq/patches/0011-sf-spansion-add-support-for-4-byte-address-mode.patch55
-rw-r--r--package/boot/uboot-lantiq/patches/0012-sf-spansion-add-support-for-S25FL512S.patch23
-rw-r--r--package/boot/uboot-lantiq/patches/0013-sf-macronix-add-support-for-4-byte-address-mode.patch44
-rw-r--r--package/boot/uboot-lantiq/patches/0014-sf-macronix-add-support-for-MX25L25635E.patch21
-rw-r--r--package/boot/uboot-lantiq/patches/0015-sf-macronix-add-support-for-MX66L51235L.patch21
-rw-r--r--package/boot/uboot-lantiq/patches/0016-sf-add-MTD-layer-driver-for-SPI-flash-devices.patch133
-rw-r--r--package/boot/uboot-lantiq/patches/0017-sf-add-init-function.patch57
-rw-r--r--package/boot/uboot-lantiq/patches/0018-MIPS-add-SPI-flash-init-hook.patch47
-rw-r--r--package/boot/uboot-lantiq/patches/0019-net-switchlib-add-framework-for-ethernet-switch-driv.patch239
-rw-r--r--package/boot/uboot-lantiq/patches/0020-net-switchlib-add-driver-for-Lantiq-PSB697X-switch-f.patch162
-rw-r--r--package/boot/uboot-lantiq/patches/0021-net-switchlib-add-driver-for-Lantiq-ADM6996I-switch-.patch158
-rw-r--r--package/boot/uboot-lantiq/patches/0022-net-switchlib-add-driver-for-Atheros-AR8216.patch158
-rw-r--r--package/boot/uboot-lantiq/patches/0023-MIPS-add-support-for-Lantiq-XWAY-SoCs.patch9496
-rw-r--r--package/boot/uboot-lantiq/patches/0024-MIPS-VRX200-add-option-to-boot-from-AVM-EVA-loader.patch33
-rw-r--r--package/boot/uboot-lantiq/patches/0025-MIPS-add-board-support-for-AVM-FritzBox-3370.patch355
-rw-r--r--package/boot/uboot-lantiq/patches/0026-MIPS-add-board-support-for-Gigaset-SX76X.patch264
-rw-r--r--package/boot/uboot-lantiq/patches/0027-MIPS-add-board-support-for-Arcadyan-ARV7518.patch248
-rw-r--r--package/boot/uboot-lantiq/patches/0028-MIPS-add-board-support-for-Arcadyan-ARV4519.patch248
-rw-r--r--package/boot/uboot-lantiq/patches/0029-tools-add-some-helper-tools-for-Lantiq-SoCs.patch361
-rw-r--r--package/boot/uboot-omap35xx/.svn/entries65
-rw-r--r--package/boot/uboot-omap35xx/.svn/text-base/Makefile.svn-base89
-rw-r--r--package/boot/uboot-omap35xx/Makefile89
-rw-r--r--package/boot/uboot-omap35xx/files/.svn/entries31
-rw-r--r--package/boot/uboot-omap35xx/files/include/.svn/entries31
-rw-r--r--package/boot/uboot-omap35xx/files/include/configs/.svn/entries62
-rw-r--r--package/boot/uboot-omap35xx/files/include/configs/.svn/text-base/omap3_overo.h.svn-base316
-rw-r--r--package/boot/uboot-omap35xx/files/include/configs/omap3_overo.h316
-rw-r--r--package/boot/uboot-omap4/.svn/entries62
-rw-r--r--package/boot/uboot-omap4/.svn/text-base/Makefile.svn-base90
-rw-r--r--package/boot/uboot-omap4/Makefile90
-rw-r--r--package/boot/uboot-pxa/.svn/entries65
-rw-r--r--package/boot/uboot-pxa/.svn/text-base/Makefile.svn-base89
-rw-r--r--package/boot/uboot-pxa/Makefile89
-rw-r--r--package/boot/uboot-pxa/patches/.svn/entries62
-rw-r--r--package/boot/uboot-pxa/patches/.svn/text-base/001-squashfs_rootfstype_cmdline.patch.svn-base13
-rw-r--r--package/boot/uboot-pxa/patches/001-squashfs_rootfstype_cmdline.patch13
-rw-r--r--package/boot/uboot-xburst/.svn/entries68
-rw-r--r--package/boot/uboot-xburst/.svn/text-base/Makefile.svn-base83
-rw-r--r--package/boot/uboot-xburst/Makefile83
-rw-r--r--package/boot/uboot-xburst/files/.svn/entries40
-rw-r--r--package/boot/uboot-xburst/files/board/.svn/entries37
-rw-r--r--package/boot/uboot-xburst/files/board/n516/.svn/entries28
-rw-r--r--package/boot/uboot-xburst/files/board/nanonote/.svn/entries28
-rw-r--r--package/boot/uboot-xburst/files/board/sakc/.svn/entries28
-rw-r--r--package/boot/uboot-xburst/files/cpu/.svn/entries31
-rw-r--r--package/boot/uboot-xburst/files/cpu/mips/.svn/entries28
-rw-r--r--package/boot/uboot-xburst/files/include/.svn/entries34
-rw-r--r--package/boot/uboot-xburst/files/include/asm-mips/.svn/entries28
-rw-r--r--package/boot/uboot-xburst/files/include/configs/.svn/entries28
-rw-r--r--package/boot/uboot-xburst/files/nand_spl/.svn/entries31
-rw-r--r--package/boot/uboot-xburst/files/nand_spl/board/.svn/entries37
-rw-r--r--package/boot/uboot-xburst/files/nand_spl/board/n516/.svn/entries28
-rw-r--r--package/boot/uboot-xburst/files/nand_spl/board/nanonote/.svn/entries28
-rw-r--r--package/boot/uboot-xburst/files/nand_spl/board/sakc/.svn/entries28
-rw-r--r--package/boot/uboot-xburst/patches/.svn/entries232
-rw-r--r--package/boot/uboot-xburst/patches/.svn/text-base/0001-qi_lb60-add-nand-spl-support.patch.svn-base894
-rw-r--r--package/boot/uboot-xburst/patches/.svn/text-base/0002-qi_lb60-add-software-usbboot-support.patch.svn-base916
-rw-r--r--package/boot/uboot-xburst/patches/.svn/text-base/0003-add-mmc-support.patch.svn-base1664
-rw-r--r--package/boot/uboot-xburst/patches/.svn/text-base/0004-add-more-boot-options-F1-F2-F3-F4-M-S.patch.svn-base200
-rw-r--r--package/boot/uboot-xburst/patches/.svn/text-base/0005-add-nanonote-lcd-support.patch.svn-base847
-rw-r--r--package/boot/uboot-xburst/patches/.svn/text-base/0006-enable-silent-console.patch.svn-base60
-rw-r--r--package/boot/uboot-xburst/patches/0001-qi_lb60-add-nand-spl-support.patch894
-rw-r--r--package/boot/uboot-xburst/patches/0002-qi_lb60-add-software-usbboot-support.patch916
-rw-r--r--package/boot/uboot-xburst/patches/0003-add-mmc-support.patch1664
-rw-r--r--package/boot/uboot-xburst/patches/0004-add-more-boot-options-F1-F2-F3-F4-M-S.patch200
-rw-r--r--package/boot/uboot-xburst/patches/0005-add-nanonote-lcd-support.patch847
-rw-r--r--package/boot/uboot-xburst/patches/0006-enable-silent-console.patch60
-rw-r--r--package/boot/yamonenv/.svn/entries65
-rw-r--r--package/boot/yamonenv/.svn/prop-base/Makefile.svn-base9
-rw-r--r--package/boot/yamonenv/.svn/text-base/Makefile.svn-base39
-rw-r--r--package/boot/yamonenv/Makefile39
-rw-r--r--package/boot/yamonenv/patches/.svn/entries62
-rw-r--r--package/boot/yamonenv/patches/.svn/text-base/001-yamonenv_mtd_partition.patch.svn-base11
-rw-r--r--package/boot/yamonenv/patches/001-yamonenv_mtd_partition.patch11
-rw-r--r--package/broadcom-diag/.svn/entries65
-rw-r--r--package/broadcom-diag/.svn/prop-base/Makefile.svn-base9
-rw-r--r--package/broadcom-diag/.svn/text-base/Makefile.svn-base37
-rw-r--r--package/broadcom-diag/Makefile37
-rw-r--r--package/broadcom-diag/src/.svn/entries164
-rw-r--r--package/broadcom-diag/src/.svn/prop-base/Makefile.svn-base5
-rw-r--r--package/broadcom-diag/src/.svn/prop-base/diag.c.svn-base5
-rw-r--r--package/broadcom-diag/src/.svn/prop-base/diag.h.svn-base5
-rw-r--r--package/broadcom-diag/src/.svn/prop-base/gpio.h.svn-base5
-rw-r--r--package/broadcom-diag/src/.svn/text-base/Makefile.svn-base17
-rw-r--r--package/broadcom-diag/src/.svn/text-base/diag.c.svn-base1723
-rw-r--r--package/broadcom-diag/src/.svn/text-base/diag.h.svn-base134
-rw-r--r--package/broadcom-diag/src/.svn/text-base/gpio.h.svn-base16
-rw-r--r--package/broadcom-diag/src/Makefile17
-rw-r--r--package/broadcom-diag/src/diag.c1723
-rw-r--r--package/broadcom-diag/src/diag.h134
-rw-r--r--package/broadcom-diag/src/gpio.h16
-rw-r--r--package/broadcom-wl/.svn/entries71
-rw-r--r--package/broadcom-wl/.svn/text-base/Makefile.svn-base175
-rw-r--r--package/broadcom-wl/Makefile175
-rw-r--r--package/broadcom-wl/files/.svn/entries34
-rw-r--r--package/broadcom-wl/files/etc/.svn/entries34
-rw-r--r--package/broadcom-wl/files/etc/hotplug.d/.svn/entries31
-rw-r--r--package/broadcom-wl/files/etc/hotplug.d/net/.svn/entries62
-rw-r--r--package/broadcom-wl/files/etc/hotplug.d/net/.svn/text-base/20-broadcom_wds.svn-base61
-rw-r--r--package/broadcom-wl/files/etc/hotplug.d/net/20-broadcom_wds61
-rw-r--r--package/broadcom-wl/files/etc/init.d/.svn/entries62
-rw-r--r--package/broadcom-wl/files/etc/init.d/.svn/prop-base/wlunbind.svn-base5
-rw-r--r--package/broadcom-wl/files/etc/init.d/.svn/text-base/wlunbind.svn-base29
-rwxr-xr-xpackage/broadcom-wl/files/etc/init.d/wlunbind29
-rw-r--r--package/broadcom-wl/files/lib/.svn/entries31
-rw-r--r--package/broadcom-wl/files/lib/wifi/.svn/entries62
-rw-r--r--package/broadcom-wl/files/lib/wifi/.svn/text-base/broadcom.sh.svn-base392
-rw-r--r--package/broadcom-wl/files/lib/wifi/broadcom.sh392
-rw-r--r--package/broadcom-wl/patches/.svn/entries504
-rw-r--r--package/broadcom-wl/patches/.svn/text-base/003-compat-2.6.35.patch.svn-base39
-rw-r--r--package/broadcom-wl/patches/.svn/text-base/004-remove-pcmcia.patch.svn-base22
-rw-r--r--package/broadcom-wl/patches/.svn/text-base/005-fix-mem-leak-on-unload.patch.svn-base31
-rw-r--r--package/broadcom-wl/patches/.svn/text-base/006-generic-dma-api.patch.svn-base88
-rw-r--r--package/broadcom-wl/patches/.svn/text-base/007-use-glue-driver.patch.svn-base184
-rw-r--r--package/broadcom-wl/patches/.svn/text-base/008-fix_virtual_interfaces.patch.svn-base11
-rw-r--r--package/broadcom-wl/patches/.svn/text-base/009-fix_compile_3_2.patch.svn-base27
-rw-r--r--package/broadcom-wl/patches/.svn/text-base/010-remove_irqf_samble_random.patch.svn-base11
-rw-r--r--package/broadcom-wl/patches/.svn/text-base/011-fix_compile_3_4.patch.svn-base12
-rw-r--r--package/broadcom-wl/patches/.svn/text-base/100-fix_nvram_two_devices.patch.svn-base32
-rw-r--r--package/broadcom-wl/patches/.svn/text-base/110-add_number_to_dev_name.patch.svn-base11
-rw-r--r--package/broadcom-wl/patches/.svn/text-base/910-fallback-sprom.patch.svn-base84
-rw-r--r--package/broadcom-wl/patches/.svn/text-base/912-pci-bus-nvram-hack.patch.svn-base11
-rw-r--r--package/broadcom-wl/patches/.svn/text-base/913-avoid-dbe-on-ifs_ctl-readw-hack.patch.svn-base12
-rw-r--r--package/broadcom-wl/patches/003-compat-2.6.35.patch39
-rw-r--r--package/broadcom-wl/patches/004-remove-pcmcia.patch22
-rw-r--r--package/broadcom-wl/patches/005-fix-mem-leak-on-unload.patch31
-rw-r--r--package/broadcom-wl/patches/006-generic-dma-api.patch88
-rw-r--r--package/broadcom-wl/patches/007-use-glue-driver.patch184
-rw-r--r--package/broadcom-wl/patches/008-fix_virtual_interfaces.patch11
-rw-r--r--package/broadcom-wl/patches/009-fix_compile_3_2.patch27
-rw-r--r--package/broadcom-wl/patches/010-remove_irqf_samble_random.patch11
-rw-r--r--package/broadcom-wl/patches/011-fix_compile_3_4.patch12
-rw-r--r--package/broadcom-wl/patches/100-fix_nvram_two_devices.patch32
-rw-r--r--package/broadcom-wl/patches/110-add_number_to_dev_name.patch11
-rw-r--r--package/broadcom-wl/patches/910-fallback-sprom.patch84
-rw-r--r--package/broadcom-wl/patches/912-pci-bus-nvram-hack.patch11
-rw-r--r--package/broadcom-wl/patches/913-avoid-dbe-on-ifs_ctl-readw-hack.patch12
-rw-r--r--package/broadcom-wl/src/.svn/entries65
-rw-r--r--package/broadcom-wl/src/.svn/text-base/wlc.c.svn-base1086
-rw-r--r--package/broadcom-wl/src/glue/.svn/entries130
-rw-r--r--package/broadcom-wl/src/glue/.svn/text-base/Makefile.svn-base17
-rw-r--r--package/broadcom-wl/src/glue/.svn/text-base/wl_glue.c.svn-base315
-rw-r--r--package/broadcom-wl/src/glue/.svn/text-base/wl_glue.h.svn-base22
-rw-r--r--package/broadcom-wl/src/glue/Makefile17
-rw-r--r--package/broadcom-wl/src/glue/wl_glue.c315
-rw-r--r--package/broadcom-wl/src/glue/wl_glue.h22
-rw-r--r--package/broadcom-wl/src/wlc.c1086
-rw-r--r--package/busybox/.svn/entries139
-rw-r--r--package/busybox/.svn/prop-base/Config.in.svn-base9
-rw-r--r--package/busybox/.svn/prop-base/Makefile.svn-base9
-rw-r--r--package/busybox/.svn/prop-base/convert_menuconfig.pl.svn-base9
-rw-r--r--package/busybox/.svn/text-base/Config.in.svn-base24
-rw-r--r--package/busybox/.svn/text-base/Makefile.svn-base118
-rw-r--r--package/busybox/.svn/text-base/convert_menuconfig.pl.svn-base78
-rw-r--r--package/busybox/Config.in24
-rw-r--r--package/busybox/Makefile118
-rw-r--r--package/busybox/config/.svn/entries125
-rw-r--r--package/busybox/config/.svn/prop-base/Config.in.svn-base5
-rw-r--r--package/busybox/config/.svn/text-base/Config.in.svn-base778
-rw-r--r--package/busybox/config/Config.in778
-rw-r--r--package/busybox/config/archival/.svn/entries62
-rw-r--r--package/busybox/config/archival/.svn/prop-base/Config.in.svn-base5
-rw-r--r--package/busybox/config/archival/.svn/text-base/Config.in.svn-base380
-rw-r--r--package/busybox/config/archival/Config.in380
-rw-r--r--package/busybox/config/console-tools/.svn/entries62
-rw-r--r--package/busybox/config/console-tools/.svn/prop-base/Config.in.svn-base5
-rw-r--r--package/busybox/config/console-tools/.svn/text-base/Config.in.svn-base177
-rw-r--r--package/busybox/config/console-tools/Config.in177
-rw-r--r--package/busybox/config/coreutils/.svn/entries62
-rw-r--r--package/busybox/config/coreutils/.svn/prop-base/Config.in.svn-base5
-rw-r--r--package/busybox/config/coreutils/.svn/text-base/Config.in.svn-base913
-rw-r--r--package/busybox/config/coreutils/Config.in913
-rw-r--r--package/busybox/config/debianutils/.svn/entries62
-rw-r--r--package/busybox/config/debianutils/.svn/prop-base/Config.in.svn-base5
-rw-r--r--package/busybox/config/debianutils/.svn/text-base/Config.in.svn-base86
-rw-r--r--package/busybox/config/debianutils/Config.in86
-rw-r--r--package/busybox/config/e2fsprogs/.svn/entries65
-rw-r--r--package/busybox/config/e2fsprogs/.svn/prop-base/Config.in.svn-base5
-rw-r--r--package/busybox/config/e2fsprogs/.svn/text-base/Config.in.svn-base72
-rw-r--r--package/busybox/config/e2fsprogs/Config.in72
-rw-r--r--package/busybox/config/e2fsprogs/old_e2fsprogs/.svn/entries62
-rw-r--r--package/busybox/config/e2fsprogs/old_e2fsprogs/.svn/prop-base/Config.in.svn-base5
-rw-r--r--package/busybox/config/e2fsprogs/old_e2fsprogs/.svn/text-base/Config.in.svn-base70
-rw-r--r--package/busybox/config/e2fsprogs/old_e2fsprogs/Config.in70
-rw-r--r--package/busybox/config/editors/.svn/entries62
-rw-r--r--package/busybox/config/editors/.svn/prop-base/Config.in.svn-base5
-rw-r--r--package/busybox/config/editors/.svn/text-base/Config.in.svn-base206
-rw-r--r--package/busybox/config/editors/Config.in206
-rw-r--r--package/busybox/config/findutils/.svn/entries62
-rw-r--r--package/busybox/config/findutils/.svn/prop-base/Config.in.svn-base5
-rw-r--r--package/busybox/config/findutils/.svn/text-base/Config.in.svn-base252
-rw-r--r--package/busybox/config/findutils/Config.in252
-rw-r--r--package/busybox/config/init/.svn/entries62
-rw-r--r--package/busybox/config/init/.svn/prop-base/Config.in.svn-base5
-rw-r--r--package/busybox/config/init/.svn/text-base/Config.in.svn-base185
-rw-r--r--package/busybox/config/init/Config.in185
-rw-r--r--package/busybox/config/libbb/.svn/entries62
-rw-r--r--package/busybox/config/libbb/.svn/prop-base/Config.in.svn-base5
-rw-r--r--package/busybox/config/libbb/.svn/text-base/Config.in.svn-base232
-rw-r--r--package/busybox/config/libbb/Config.in232
-rw-r--r--package/busybox/config/loginutils/.svn/entries62
-rw-r--r--package/busybox/config/loginutils/.svn/prop-base/Config.in.svn-base5
-rw-r--r--package/busybox/config/loginutils/.svn/text-base/Config.in.svn-base329
-rw-r--r--package/busybox/config/loginutils/Config.in329
-rw-r--r--package/busybox/config/mailutils/.svn/entries62
-rw-r--r--package/busybox/config/mailutils/.svn/text-base/Config.in.svn-base56
-rw-r--r--package/busybox/config/mailutils/Config.in56
-rw-r--r--package/busybox/config/miscutils/.svn/entries62
-rw-r--r--package/busybox/config/miscutils/.svn/prop-base/Config.in.svn-base5
-rw-r--r--package/busybox/config/miscutils/.svn/text-base/Config.in.svn-base766
-rw-r--r--package/busybox/config/miscutils/Config.in766
-rw-r--r--package/busybox/config/modutils/.svn/entries62
-rw-r--r--package/busybox/config/modutils/.svn/prop-base/Config.in.svn-base5
-rw-r--r--package/busybox/config/modutils/.svn/text-base/Config.in.svn-base269
-rw-r--r--package/busybox/config/modutils/Config.in269
-rw-r--r--package/busybox/config/networking/.svn/entries65
-rw-r--r--package/busybox/config/networking/.svn/prop-base/Config.in.svn-base5
-rw-r--r--package/busybox/config/networking/.svn/text-base/Config.in.svn-base1088
-rw-r--r--package/busybox/config/networking/Config.in1088
-rw-r--r--package/busybox/config/networking/udhcp/.svn/entries62
-rw-r--r--package/busybox/config/networking/udhcp/.svn/prop-base/Config.in.svn-base5
-rw-r--r--package/busybox/config/networking/udhcp/.svn/text-base/Config.in.svn-base155
-rw-r--r--package/busybox/config/networking/udhcp/Config.in155
-rw-r--r--package/busybox/config/printutils/.svn/entries62
-rw-r--r--package/busybox/config/printutils/.svn/text-base/Config.in.svn-base29
-rw-r--r--package/busybox/config/printutils/Config.in29
-rw-r--r--package/busybox/config/procps/.svn/entries62
-rw-r--r--package/busybox/config/procps/.svn/prop-base/Config.in.svn-base5
-rw-r--r--package/busybox/config/procps/.svn/text-base/Config.in.svn-base260
-rw-r--r--package/busybox/config/procps/Config.in260
-rw-r--r--package/busybox/config/runit/.svn/entries62
-rw-r--r--package/busybox/config/runit/.svn/prop-base/Config.in.svn-base5
-rw-r--r--package/busybox/config/runit/.svn/text-base/Config.in.svn-base90
-rw-r--r--package/busybox/config/runit/Config.in90
-rw-r--r--package/busybox/config/selinux/.svn/entries62
-rw-r--r--package/busybox/config/selinux/.svn/text-base/Config.in.svn-base125
-rw-r--r--package/busybox/config/selinux/Config.in125
-rw-r--r--package/busybox/config/shell/.svn/entries62
-rw-r--r--package/busybox/config/shell/.svn/prop-base/Config.in.svn-base5
-rw-r--r--package/busybox/config/shell/.svn/text-base/Config.in.svn-base433
-rw-r--r--package/busybox/config/shell/Config.in433
-rw-r--r--package/busybox/config/sysklogd/.svn/entries62
-rw-r--r--package/busybox/config/sysklogd/.svn/prop-base/Config.in.svn-base5
-rw-r--r--package/busybox/config/sysklogd/.svn/text-base/Config.in.svn-base154
-rw-r--r--package/busybox/config/sysklogd/Config.in154
-rw-r--r--package/busybox/config/util-linux/.svn/entries62
-rw-r--r--package/busybox/config/util-linux/.svn/prop-base/Config.in.svn-base5
-rw-r--r--package/busybox/config/util-linux/.svn/text-base/Config.in.svn-base985
-rw-r--r--package/busybox/config/util-linux/Config.in985
-rwxr-xr-xpackage/busybox/convert_menuconfig.pl78
-rw-r--r--package/busybox/files/.svn/entries96
-rw-r--r--package/busybox/files/.svn/prop-base/cron.svn-base9
-rw-r--r--package/busybox/files/.svn/prop-base/telnet.svn-base9
-rw-r--r--package/busybox/files/.svn/text-base/cron.svn-base18
-rw-r--r--package/busybox/files/.svn/text-base/telnet.svn-base37
-rwxr-xr-xpackage/busybox/files/cron18
-rwxr-xr-xpackage/busybox/files/telnet37
-rw-r--r--package/busybox/patches/.svn/entries1422
-rw-r--r--package/busybox/patches/.svn/prop-base/110-wget_getopt_fix.patch.svn-base5
-rw-r--r--package/busybox/patches/.svn/prop-base/140-trylink_bash.patch.svn-base5
-rw-r--r--package/busybox/patches/.svn/prop-base/200-etc_crontabs.patch.svn-base5
-rw-r--r--package/busybox/patches/.svn/prop-base/240-udhcpc_retries.patch.svn-base5
-rw-r--r--package/busybox/patches/.svn/prop-base/241-udhcpc-oversized_packets.patch.svn-base5
-rw-r--r--package/busybox/patches/.svn/prop-base/250-ash_export-n.patch.svn-base5
-rw-r--r--package/busybox/patches/.svn/prop-base/300-netmsg.patch.svn-base5
-rw-r--r--package/busybox/patches/.svn/prop-base/340-lock_util.patch.svn-base5
-rw-r--r--package/busybox/patches/.svn/prop-base/410-httpd_cgi_headers.patch.svn-base5
-rw-r--r--package/busybox/patches/.svn/prop-base/440-httpd_chdir.patch.svn-base5
-rw-r--r--package/busybox/patches/.svn/text-base/001-init_avoid_loop_opening_tty.patch.svn-base15
-rw-r--r--package/busybox/patches/.svn/text-base/002-passwd_use_md5_hash_by_default_like_it_used_to_be.patch.svn-base20
-rw-r--r--package/busybox/patches/.svn/text-base/003-brctl_show_fix.patch.svn-base37
-rw-r--r--package/busybox/patches/.svn/text-base/004-upstream-percent_decode_in_place.patch.svn-base237
-rw-r--r--package/busybox/patches/.svn/text-base/005-resource_h_include.patch.svn-base10
-rw-r--r--package/busybox/patches/.svn/text-base/006-upstream_CVE-2011-2716_fixes.patch.svn-base164
-rw-r--r--package/busybox/patches/.svn/text-base/007-upstream_mkfs_ext2_fixes.patch.svn-base1441
-rw-r--r--package/busybox/patches/.svn/text-base/110-wget_getopt_fix.patch.svn-base11
-rw-r--r--package/busybox/patches/.svn/text-base/140-trylink_bash.patch.svn-base8
-rw-r--r--package/busybox/patches/.svn/text-base/141-gen_build_files_bash.patch.svn-base8
-rw-r--r--package/busybox/patches/.svn/text-base/150-no_static_libgcc.patch.svn-base11
-rw-r--r--package/busybox/patches/.svn/text-base/200-etc_crontabs.patch.svn-base22
-rw-r--r--package/busybox/patches/.svn/text-base/240-udhcpc_retries.patch.svn-base20
-rw-r--r--package/busybox/patches/.svn/text-base/241-udhcpc-oversized_packets.patch.svn-base99
-rw-r--r--package/busybox/patches/.svn/text-base/242-udhcpc_msgs.patch.svn-base18
-rw-r--r--package/busybox/patches/.svn/text-base/243-udhcpc_changed_ifindex.patch.svn-base15
-rw-r--r--package/busybox/patches/.svn/text-base/244-udhcpc_add_6rd_option.patch.svn-base143
-rw-r--r--package/busybox/patches/.svn/text-base/250-ash_export-n.patch.svn-base34
-rw-r--r--package/busybox/patches/.svn/text-base/251-ash_fix-redir-substitution.patch.svn-base12
-rw-r--r--package/busybox/patches/.svn/text-base/260-vconfig_proc.patch.svn-base22
-rw-r--r--package/busybox/patches/.svn/text-base/300-netmsg.patch.svn-base103
-rw-r--r--package/busybox/patches/.svn/text-base/310-passwd_access.patch.svn-base41
-rw-r--r--package/busybox/patches/.svn/text-base/340-lock_util.patch.svn-base172
-rw-r--r--package/busybox/patches/.svn/text-base/350-httpd_redir.patch.svn-base90
-rw-r--r--package/busybox/patches/.svn/text-base/410-httpd_cgi_headers.patch.svn-base16
-rw-r--r--package/busybox/patches/.svn/text-base/440-httpd_chdir.patch.svn-base10
-rw-r--r--package/busybox/patches/.svn/text-base/470-insmod_search.patch.svn-base137
-rw-r--r--package/busybox/patches/.svn/text-base/490-mount_disable_check.patch.svn-base12
-rw-r--r--package/busybox/patches/.svn/text-base/510-awk_include.patch.svn-base217
-rw-r--r--package/busybox/patches/.svn/text-base/524-udhcpc_renew.patch.svn-base10
-rw-r--r--package/busybox/patches/.svn/text-base/610-ntpd_delayed_resolve.patch.svn-base48
-rw-r--r--package/busybox/patches/.svn/text-base/611-upstream_ntpd_version_fix.patch.svn-base29
-rw-r--r--package/busybox/patches/.svn/text-base/700-hexdump_segfault_fix.patch.svn-base11
-rw-r--r--package/busybox/patches/.svn/text-base/802-brctl_linux24.patch.svn-base74
-rw-r--r--package/busybox/patches/.svn/text-base/902-telnetd_intr.patch.svn-base10
-rw-r--r--package/busybox/patches/.svn/text-base/910-insmod-q-flag.patch.svn-base33
-rw-r--r--package/busybox/patches/.svn/text-base/911-date-k-flag.patch.svn-base87
-rw-r--r--package/busybox/patches/.svn/text-base/920-portability.patch.svn-base13
-rw-r--r--package/busybox/patches/.svn/text-base/950-partial-checksum.patch.svn-base86
-rw-r--r--package/busybox/patches/.svn/text-base/998-arping_missing_includes.patch.svn-base11
-rw-r--r--package/busybox/patches/.svn/text-base/999-musl-fixes.patch.svn-base16
-rw-r--r--package/busybox/patches/001-init_avoid_loop_opening_tty.patch15
-rw-r--r--package/busybox/patches/002-passwd_use_md5_hash_by_default_like_it_used_to_be.patch20
-rw-r--r--package/busybox/patches/003-brctl_show_fix.patch37
-rw-r--r--package/busybox/patches/004-upstream-percent_decode_in_place.patch237
-rw-r--r--package/busybox/patches/005-resource_h_include.patch10
-rw-r--r--package/busybox/patches/006-upstream_CVE-2011-2716_fixes.patch164
-rw-r--r--package/busybox/patches/007-upstream_mkfs_ext2_fixes.patch1441
-rw-r--r--package/busybox/patches/110-wget_getopt_fix.patch11
-rw-r--r--package/busybox/patches/140-trylink_bash.patch8
-rw-r--r--package/busybox/patches/141-gen_build_files_bash.patch8
-rw-r--r--package/busybox/patches/150-no_static_libgcc.patch11
-rw-r--r--package/busybox/patches/200-etc_crontabs.patch22
-rw-r--r--package/busybox/patches/240-udhcpc_retries.patch20
-rw-r--r--package/busybox/patches/241-udhcpc-oversized_packets.patch99
-rw-r--r--package/busybox/patches/242-udhcpc_msgs.patch18
-rw-r--r--package/busybox/patches/243-udhcpc_changed_ifindex.patch15
-rw-r--r--package/busybox/patches/244-udhcpc_add_6rd_option.patch143
-rw-r--r--package/busybox/patches/250-ash_export-n.patch34
-rw-r--r--package/busybox/patches/251-ash_fix-redir-substitution.patch12
-rw-r--r--package/busybox/patches/260-vconfig_proc.patch22
-rw-r--r--package/busybox/patches/300-netmsg.patch103
-rw-r--r--package/busybox/patches/310-passwd_access.patch41
-rw-r--r--package/busybox/patches/340-lock_util.patch172
-rw-r--r--package/busybox/patches/350-httpd_redir.patch90
-rw-r--r--package/busybox/patches/410-httpd_cgi_headers.patch16
-rw-r--r--package/busybox/patches/440-httpd_chdir.patch10
-rw-r--r--package/busybox/patches/470-insmod_search.patch137
-rw-r--r--package/busybox/patches/490-mount_disable_check.patch12
-rw-r--r--package/busybox/patches/510-awk_include.patch217
-rw-r--r--package/busybox/patches/524-udhcpc_renew.patch10
-rw-r--r--package/busybox/patches/610-ntpd_delayed_resolve.patch48
-rw-r--r--package/busybox/patches/611-upstream_ntpd_version_fix.patch29
-rw-r--r--package/busybox/patches/700-hexdump_segfault_fix.patch11
-rw-r--r--package/busybox/patches/802-brctl_linux24.patch74
-rw-r--r--package/busybox/patches/902-telnetd_intr.patch10
-rw-r--r--package/busybox/patches/910-insmod-q-flag.patch33
-rw-r--r--package/busybox/patches/911-date-k-flag.patch87
-rw-r--r--package/busybox/patches/920-portability.patch13
-rw-r--r--package/busybox/patches/950-partial-checksum.patch86
-rw-r--r--package/busybox/patches/998-arping_missing_includes.patch11
-rw-r--r--package/busybox/patches/999-musl-fixes.patch16
-rw-r--r--package/devel/.svn/entries43
-rw-r--r--package/devel/binutils/.svn/entries62
-rw-r--r--package/devel/binutils/.svn/text-base/Makefile.svn-base115
-rw-r--r--package/devel/binutils/Makefile115
-rw-r--r--package/devel/gdb/.svn/entries65
-rw-r--r--package/devel/gdb/.svn/text-base/Makefile.svn-base86
-rw-r--r--package/devel/gdb/Makefile86
-rw-r--r--package/devel/gdb/patches/.svn/entries62
-rw-r--r--package/devel/gdb/patches/.svn/text-base/001-gdb-pr14523-mips-signal-number.patch.svn-base16
-rw-r--r--package/devel/gdb/patches/001-gdb-pr14523-mips-signal-number.patch16
-rw-r--r--package/devel/oprofile/.svn/entries65
-rw-r--r--package/devel/oprofile/.svn/text-base/Makefile.svn-base91
-rw-r--r--package/devel/oprofile/Makefile91
-rw-r--r--package/devel/oprofile/patches/.svn/entries96
-rw-r--r--package/devel/oprofile/patches/.svn/text-base/100-use_insmod_instead_of_modprobe.patch.svn-base20
-rw-r--r--package/devel/oprofile/patches/.svn/text-base/101-remove_24_support.patch.svn-base64
-rw-r--r--package/devel/oprofile/patches/100-use_insmod_instead_of_modprobe.patch20
-rw-r--r--package/devel/oprofile/patches/101-remove_24_support.patch64
-rw-r--r--package/devel/trace-cmd/.svn/entries65
-rw-r--r--package/devel/trace-cmd/.svn/text-base/Makefile.svn-base61
-rw-r--r--package/devel/trace-cmd/Makefile61
-rw-r--r--package/devel/trace-cmd/patches/.svn/entries96
-rw-r--r--package/devel/trace-cmd/patches/.svn/text-base/100-compile_fix.patch.svn-base30
-rw-r--r--package/devel/trace-cmd/patches/.svn/text-base/110-fix_sscanf_alloc.patch.svn-base20
-rw-r--r--package/devel/trace-cmd/patches/100-compile_fix.patch30
-rw-r--r--package/devel/trace-cmd/patches/110-fix_sscanf_alloc.patch20
-rw-r--r--package/devel/valgrind/.svn/entries71
-rw-r--r--package/devel/valgrind/.svn/text-base/Makefile.svn-base164
-rw-r--r--package/devel/valgrind/Makefile164
-rw-r--r--package/devel/valgrind/files/.svn/entries62
-rw-r--r--package/devel/valgrind/files/.svn/text-base/default.supp.svn-base42
-rw-r--r--package/devel/valgrind/files/default.supp42
-rw-r--r--package/devel/valgrind/patches/.svn/entries96
-rw-r--r--package/devel/valgrind/patches/.svn/text-base/100-fix_configure_check.patch.svn-base11
-rw-r--r--package/devel/valgrind/patches/.svn/text-base/110-add_a_out_h.patch.svn-base157
-rw-r--r--package/devel/valgrind/patches/100-fix_configure_check.patch11
-rw-r--r--package/devel/valgrind/patches/110-add_a_out_h.patch157
-rw-r--r--package/devel/valgrind/src/.svn/entries62
-rw-r--r--package/devel/valgrind/src/.svn/text-base/abort.c.svn-base3
-rw-r--r--package/devel/valgrind/src/abort.c3
-rw-r--r--package/fuse/.svn/entries65
-rw-r--r--package/fuse/.svn/prop-base/Makefile.svn-base9
-rw-r--r--package/fuse/.svn/text-base/Makefile.svn-base111
-rw-r--r--package/fuse/Makefile111
-rw-r--r--package/fuse/patches/.svn/entries62
-rw-r--r--package/fuse/patches/.svn/prop-base/112-no_break_on_mknod.patch.svn-base5
-rw-r--r--package/fuse/patches/.svn/text-base/112-no_break_on_mknod.patch.svn-base11
-rw-r--r--package/fuse/patches/112-no_break_on_mknod.patch11
-rw-r--r--package/hotplug2/.svn/entries71
-rw-r--r--package/hotplug2/.svn/text-base/Makefile.svn-base66
-rw-r--r--package/hotplug2/Makefile66
-rw-r--r--package/hotplug2/files/.svn/entries62
-rw-r--r--package/hotplug2/files/.svn/text-base/hotplug2.rules.svn-base10
-rw-r--r--package/hotplug2/files/hotplug2.rules10
-rw-r--r--package/hotplug2/patches/.svn/entries232
-rw-r--r--package/hotplug2/patches/.svn/text-base/100-env_memleak.patch.svn-base63
-rw-r--r--package/hotplug2/patches/.svn/text-base/110-static_worker.patch.svn-base20
-rw-r--r--package/hotplug2/patches/.svn/text-base/120-sysfs_path_fix.patch.svn-base14
-rw-r--r--package/hotplug2/patches/.svn/text-base/130-cancel_download_fix.patch.svn-base18
-rw-r--r--package/hotplug2/patches/.svn/text-base/140-worker_fork_fix.patch.svn-base237
-rw-r--r--package/hotplug2/patches/.svn/text-base/170-non_fatal_include.patch.svn-base21
-rw-r--r--package/hotplug2/patches/100-env_memleak.patch63
-rw-r--r--package/hotplug2/patches/110-static_worker.patch20
-rw-r--r--package/hotplug2/patches/120-sysfs_path_fix.patch14
-rw-r--r--package/hotplug2/patches/130-cancel_download_fix.patch18
-rw-r--r--package/hotplug2/patches/140-worker_fork_fix.patch237
-rw-r--r--package/hotplug2/patches/170-non_fatal_include.patch21
-rw-r--r--package/hotplug2/src/.svn/entries62
-rw-r--r--package/hotplug2/src/.svn/text-base/udevtrigger.c.svn-base345
-rw-r--r--package/hotplug2/src/udevtrigger.c345
-rw-r--r--package/kernel/.svn/entries65
-rw-r--r--package/kernel/.svn/prop-base/Makefile.svn-base9
-rw-r--r--package/kernel/.svn/text-base/Makefile.svn-base52
-rw-r--r--package/kernel/Makefile52
-rw-r--r--package/kernel/modules/.svn/entries810
-rw-r--r--package/kernel/modules/.svn/prop-base/block.mk.svn-base5
-rw-r--r--package/kernel/modules/.svn/prop-base/crypto.mk.svn-base5
-rw-r--r--package/kernel/modules/.svn/prop-base/fs.mk.svn-base5
-rw-r--r--package/kernel/modules/.svn/prop-base/hwmon.mk.svn-base5
-rw-r--r--package/kernel/modules/.svn/prop-base/i2c.mk.svn-base5
-rw-r--r--package/kernel/modules/.svn/prop-base/netfilter.mk.svn-base5
-rw-r--r--package/kernel/modules/.svn/prop-base/nls.mk.svn-base9
-rw-r--r--package/kernel/modules/.svn/prop-base/other.mk.svn-base5
-rw-r--r--package/kernel/modules/.svn/prop-base/pcmcia.mk.svn-base9
-rw-r--r--package/kernel/modules/.svn/prop-base/spi.mk.svn-base5
-rw-r--r--package/kernel/modules/.svn/prop-base/usb.mk.svn-base5
-rw-r--r--package/kernel/modules/.svn/prop-base/w1.mk.svn-base5
-rw-r--r--package/kernel/modules/.svn/prop-base/wireless.mk.svn-base5
-rw-r--r--package/kernel/modules/.svn/text-base/001-depends.mk.svn-base37
-rw-r--r--package/kernel/modules/.svn/text-base/block.mk.svn-base606
-rw-r--r--package/kernel/modules/.svn/text-base/crypto.mk.svn-base496
-rw-r--r--package/kernel/modules/.svn/text-base/firewire.mk.svn-base77
-rw-r--r--package/kernel/modules/.svn/text-base/fs.mk.svn-base371
-rw-r--r--package/kernel/modules/.svn/text-base/hwmon.mk.svn-base192
-rw-r--r--package/kernel/modules/.svn/text-base/i2c.mk.svn-base283
-rw-r--r--package/kernel/modules/.svn/text-base/input.mk.svn-base192
-rw-r--r--package/kernel/modules/.svn/text-base/leds.mk.svn-base169
-rw-r--r--package/kernel/modules/.svn/text-base/lib.mk.svn-base165
-rw-r--r--package/kernel/modules/.svn/text-base/netdevices.mk.svn-base726
-rw-r--r--package/kernel/modules/.svn/text-base/netfilter.mk.svn-base575
-rw-r--r--package/kernel/modules/.svn/text-base/netsupport.mk.svn-base891
-rw-r--r--package/kernel/modules/.svn/text-base/nls.mk.svn-base228
-rw-r--r--package/kernel/modules/.svn/text-base/other.mk.svn-base655
-rw-r--r--package/kernel/modules/.svn/text-base/pcmcia.mk.svn-base80
-rw-r--r--package/kernel/modules/.svn/text-base/sound.mk.svn-base211
-rw-r--r--package/kernel/modules/.svn/text-base/spi.mk.svn-base90
-rw-r--r--package/kernel/modules/.svn/text-base/usb.mk.svn-base985
-rw-r--r--package/kernel/modules/.svn/text-base/video.mk.svn-base730
-rw-r--r--package/kernel/modules/.svn/text-base/virtual.mk.svn-base171
-rw-r--r--package/kernel/modules/.svn/text-base/w1.mk.svn-base160
-rw-r--r--package/kernel/modules/.svn/text-base/wireless.mk.svn-base109
-rw-r--r--package/kernel/modules/001-depends.mk37
-rw-r--r--package/kernel/modules/block.mk606
-rw-r--r--package/kernel/modules/crypto.mk496
-rw-r--r--package/kernel/modules/firewire.mk77
-rw-r--r--package/kernel/modules/fs.mk371
-rw-r--r--package/kernel/modules/hwmon.mk192
-rw-r--r--package/kernel/modules/i2c.mk283
-rw-r--r--package/kernel/modules/input.mk192
-rw-r--r--package/kernel/modules/leds.mk169
-rw-r--r--package/kernel/modules/lib.mk165
-rw-r--r--package/kernel/modules/netdevices.mk726
-rw-r--r--package/kernel/modules/netfilter.mk575
-rw-r--r--package/kernel/modules/netsupport.mk891
-rw-r--r--package/kernel/modules/nls.mk228
-rw-r--r--package/kernel/modules/other.mk655
-rw-r--r--package/kernel/modules/pcmcia.mk80
-rw-r--r--package/kernel/modules/sound.mk211
-rw-r--r--package/kernel/modules/spi.mk90
-rw-r--r--package/kernel/modules/usb.mk985
-rw-r--r--package/kernel/modules/video.mk730
-rw-r--r--package/kernel/modules/virtual.mk171
-rw-r--r--package/kernel/modules/w1.mk160
-rw-r--r--package/kernel/modules/wireless.mk109
-rw-r--r--package/libs/.svn/entries118
-rw-r--r--package/libs/cyassl/.svn/entries65
-rw-r--r--package/libs/cyassl/.svn/text-base/Makefile.svn-base56
-rw-r--r--package/libs/cyassl/Makefile56
-rw-r--r--package/libs/cyassl/patches/.svn/entries164
-rw-r--r--package/libs/cyassl/patches/.svn/text-base/110-makefile_disable_examples_tests.patch.svn-base46
-rw-r--r--package/libs/cyassl/patches/.svn/text-base/120-makefile_destdir.patch.svn-base71
-rw-r--r--package/libs/cyassl/patches/.svn/text-base/130-configure_disable_pthreads_tests.patch.svn-base444
-rw-r--r--package/libs/cyassl/patches/.svn/text-base/200-SSL_accept-handle-hello-garbage.patch.svn-base13
-rw-r--r--package/libs/cyassl/patches/110-makefile_disable_examples_tests.patch46
-rw-r--r--package/libs/cyassl/patches/120-makefile_destdir.patch71
-rw-r--r--package/libs/cyassl/patches/130-configure_disable_pthreads_tests.patch444
-rw-r--r--package/libs/cyassl/patches/200-SSL_accept-handle-hello-garbage.patch13
-rw-r--r--package/libs/gettext-full/.svn/entries65
-rw-r--r--package/libs/gettext-full/.svn/prop-base/Makefile.svn-base9
-rw-r--r--package/libs/gettext-full/.svn/text-base/Makefile.svn-base72
-rw-r--r--package/libs/gettext-full/Makefile72
-rw-r--r--package/libs/gettext-full/patches/.svn/entries334
-rw-r--r--package/libs/gettext-full/patches/.svn/text-base/001-autotools.patch.svn-base35
-rw-r--r--package/libs/gettext-full/patches/.svn/text-base/001-no_examples_and_tests.patch.svn-base22
-rw-r--r--package/libs/gettext-full/patches/.svn/text-base/003-gettext-error_print_progname.patch.svn-base11
-rw-r--r--package/libs/gettext-full/patches/.svn/text-base/004-gnulib-uclibc-sched_param-def.patch.svn-base17
-rw-r--r--package/libs/gettext-full/patches/.svn/text-base/005-uclibc-0.9.30-compat.patch.svn-base22
-rw-r--r--package/libs/gettext-full/patches/.svn/text-base/100-error_progname.patch.svn-base10
-rw-r--r--package/libs/gettext-full/patches/.svn/text-base/120-uclibc-nolocale.patch.svn-base11
-rw-r--r--package/libs/gettext-full/patches/.svn/text-base/150-disable_libxml_iconv.patch.svn-base22
-rw-r--r--package/libs/gettext-full/patches/.svn/text-base/160-eglibc_stdio.patch.svn-base36
-rw-r--r--package/libs/gettext-full/patches/001-autotools.patch35
-rw-r--r--package/libs/gettext-full/patches/001-no_examples_and_tests.patch22
-rw-r--r--package/libs/gettext-full/patches/003-gettext-error_print_progname.patch11
-rw-r--r--package/libs/gettext-full/patches/004-gnulib-uclibc-sched_param-def.patch17
-rw-r--r--package/libs/gettext-full/patches/005-uclibc-0.9.30-compat.patch22
-rw-r--r--package/libs/gettext-full/patches/100-error_progname.patch10
-rw-r--r--package/libs/gettext-full/patches/120-uclibc-nolocale.patch11
-rw-r--r--package/libs/gettext-full/patches/150-disable_libxml_iconv.patch22
-rw-r--r--package/libs/gettext-full/patches/160-eglibc_stdio.patch36
-rw-r--r--package/libs/gettext/.svn/entries65
-rw-r--r--package/libs/gettext/.svn/text-base/Makefile.svn-base68
-rw-r--r--package/libs/gettext/Makefile68
-rw-r--r--package/libs/gettext/src/.svn/entries68
-rw-r--r--package/libs/gettext/src/.svn/text-base/LICENSE.svn-base7
-rw-r--r--package/libs/gettext/src/LICENSE7
-rw-r--r--package/libs/gettext/src/include/.svn/entries62
-rw-r--r--package/libs/gettext/src/include/.svn/text-base/libintl.h.svn-base53
-rw-r--r--package/libs/gettext/src/include/libintl.h53
-rw-r--r--package/libs/gettext/src/m4/.svn/entries300
-rw-r--r--package/libs/gettext/src/m4/.svn/text-base/codeset.m4.svn-base21
-rw-r--r--package/libs/gettext/src/m4/.svn/text-base/gettext.m4.svn-base383
-rw-r--r--package/libs/gettext/src/m4/.svn/text-base/intl.m4.svn-base294
-rw-r--r--package/libs/gettext/src/m4/.svn/text-base/intldir.m4.svn-base19
-rw-r--r--package/libs/gettext/src/m4/.svn/text-base/intlmacosx.m4.svn-base51
-rw-r--r--package/libs/gettext/src/m4/.svn/text-base/lcmessage.m4.svn-base31
-rw-r--r--package/libs/gettext/src/m4/.svn/text-base/nls.m4.svn-base32
-rw-r--r--package/libs/gettext/src/m4/.svn/text-base/po.m4.svn-base449
-rw-r--r--package/libs/gettext/src/m4/codeset.m421
-rw-r--r--package/libs/gettext/src/m4/gettext.m4383
-rw-r--r--package/libs/gettext/src/m4/intl.m4294
-rw-r--r--package/libs/gettext/src/m4/intldir.m419
-rw-r--r--package/libs/gettext/src/m4/intlmacosx.m451
-rw-r--r--package/libs/gettext/src/m4/lcmessage.m431
-rw-r--r--package/libs/gettext/src/m4/nls.m432
-rw-r--r--package/libs/gettext/src/m4/po.m4449
-rw-r--r--package/libs/libbsd/.svn/entries62
-rw-r--r--package/libs/libbsd/.svn/text-base/Makefile.svn-base57
-rw-r--r--package/libs/libbsd/Makefile57
-rw-r--r--package/libs/libevent2/.svn/entries62
-rw-r--r--package/libs/libevent2/.svn/text-base/Makefile.svn-base156
-rw-r--r--package/libs/libevent2/Makefile156
-rw-r--r--package/libs/libiconv-full/.svn/entries65
-rw-r--r--package/libs/libiconv-full/.svn/prop-base/Makefile.svn-base13
-rw-r--r--package/libs/libiconv-full/.svn/text-base/Makefile.svn-base93
-rw-r--r--package/libs/libiconv-full/Makefile93
-rw-r--r--package/libs/libiconv-full/patches/.svn/entries164
-rw-r--r--package/libs/libiconv-full/patches/.svn/prop-base/100-strip_charsets.patch.svn-base5
-rw-r--r--package/libs/libiconv-full/patches/.svn/text-base/100-strip_charsets.patch.svn-base3438
-rw-r--r--package/libs/libiconv-full/patches/.svn/text-base/101-autotools.patch.svn-base26014
-rw-r--r--package/libs/libiconv-full/patches/.svn/text-base/103-configure_ac_fix.patch.svn-base31
-rw-r--r--package/libs/libiconv-full/patches/.svn/text-base/200-work-with-libtool2.patch.svn-base17
-rw-r--r--package/libs/libiconv-full/patches/100-strip_charsets.patch3438
-rw-r--r--package/libs/libiconv-full/patches/101-autotools.patch26014
-rw-r--r--package/libs/libiconv-full/patches/103-configure_ac_fix.patch31
-rw-r--r--package/libs/libiconv-full/patches/200-work-with-libtool2.patch17
-rw-r--r--package/libs/libiconv/.svn/entries133
-rw-r--r--package/libs/libiconv/.svn/text-base/COPYING.svn-base504
-rw-r--r--package/libs/libiconv/.svn/text-base/COPYRIGHT.svn-base20
-rw-r--r--package/libs/libiconv/.svn/text-base/Makefile.svn-base84
-rw-r--r--package/libs/libiconv/COPYING504
-rw-r--r--package/libs/libiconv/COPYRIGHT20
-rw-r--r--package/libs/libiconv/Makefile84
-rw-r--r--package/libs/libiconv/src/.svn/entries102
-rw-r--r--package/libs/libiconv/src/.svn/text-base/LICENSE.svn-base6
-rw-r--r--package/libs/libiconv/src/.svn/text-base/iconv.c.svn-base440
-rw-r--r--package/libs/libiconv/src/LICENSE6
-rw-r--r--package/libs/libiconv/src/iconv.c440
-rw-r--r--package/libs/libiconv/src/include/.svn/entries99
-rw-r--r--package/libs/libiconv/src/include/.svn/text-base/charmaps.h.svn-base80
-rw-r--r--package/libs/libiconv/src/include/.svn/text-base/iconv.h.svn-base32
-rw-r--r--package/libs/libiconv/src/include/charmaps.h80
-rw-r--r--package/libs/libiconv/src/include/charmaps/.svn/entries810
-rw-r--r--package/libs/libiconv/src/include/charmaps/.svn/text-base/iso-8859-10.h.svn-base24
-rw-r--r--package/libs/libiconv/src/include/charmaps/.svn/text-base/iso-8859-13.h.svn-base24
-rw-r--r--package/libs/libiconv/src/include/charmaps/.svn/text-base/iso-8859-14.h.svn-base25
-rw-r--r--package/libs/libiconv/src/include/charmaps/.svn/text-base/iso-8859-16.h.svn-base24
-rw-r--r--package/libs/libiconv/src/include/charmaps/.svn/text-base/iso-8859-2.h.svn-base24
-rw-r--r--package/libs/libiconv/src/include/charmaps/.svn/text-base/iso-8859-3.h.svn-base24
-rw-r--r--package/libs/libiconv/src/include/charmaps/.svn/text-base/iso-8859-4.h.svn-base24
-rw-r--r--package/libs/libiconv/src/include/charmaps/.svn/text-base/iso-8859-5.h.svn-base24
-rw-r--r--package/libs/libiconv/src/include/charmaps/.svn/text-base/iso-8859-6.h.svn-base24
-rw-r--r--package/libs/libiconv/src/include/charmaps/.svn/text-base/iso-8859-7.h.svn-base24
-rw-r--r--package/libs/libiconv/src/include/charmaps/.svn/text-base/iso-8859-8.h.svn-base24
-rw-r--r--package/libs/libiconv/src/include/charmaps/.svn/text-base/iso-8859-9.h.svn-base24
-rw-r--r--package/libs/libiconv/src/include/charmaps/.svn/text-base/koi8-r.h.svn-base24
-rw-r--r--package/libs/libiconv/src/include/charmaps/.svn/text-base/windows-1250.h.svn-base24
-rw-r--r--package/libs/libiconv/src/include/charmaps/.svn/text-base/windows-1251.h.svn-base24
-rw-r--r--package/libs/libiconv/src/include/charmaps/.svn/text-base/windows-1252.h.svn-base25
-rw-r--r--package/libs/libiconv/src/include/charmaps/.svn/text-base/windows-1253.h.svn-base24
-rw-r--r--package/libs/libiconv/src/include/charmaps/.svn/text-base/windows-1254.h.svn-base24
-rw-r--r--package/libs/libiconv/src/include/charmaps/.svn/text-base/windows-1255.h.svn-base24
-rw-r--r--package/libs/libiconv/src/include/charmaps/.svn/text-base/windows-1256.h.svn-base24
-rw-r--r--package/libs/libiconv/src/include/charmaps/.svn/text-base/windows-1257.h.svn-base24
-rw-r--r--package/libs/libiconv/src/include/charmaps/.svn/text-base/windows-1258.h.svn-base24
-rw-r--r--package/libs/libiconv/src/include/charmaps/.svn/text-base/windows-874.h.svn-base24
-rw-r--r--package/libs/libiconv/src/include/charmaps/iso-8859-10.h24
-rw-r--r--package/libs/libiconv/src/include/charmaps/iso-8859-13.h24
-rw-r--r--package/libs/libiconv/src/include/charmaps/iso-8859-14.h25
-rw-r--r--package/libs/libiconv/src/include/charmaps/iso-8859-16.h24
-rw-r--r--package/libs/libiconv/src/include/charmaps/iso-8859-2.h24
-rw-r--r--package/libs/libiconv/src/include/charmaps/iso-8859-3.h24
-rw-r--r--package/libs/libiconv/src/include/charmaps/iso-8859-4.h24
-rw-r--r--package/libs/libiconv/src/include/charmaps/iso-8859-5.h24
-rw-r--r--package/libs/libiconv/src/include/charmaps/iso-8859-6.h24
-rw-r--r--package/libs/libiconv/src/include/charmaps/iso-8859-7.h24
-rw-r--r--package/libs/libiconv/src/include/charmaps/iso-8859-8.h24
-rw-r--r--package/libs/libiconv/src/include/charmaps/iso-8859-9.h24
-rw-r--r--package/libs/libiconv/src/include/charmaps/koi8-r.h24
-rw-r--r--package/libs/libiconv/src/include/charmaps/windows-1250.h24
-rw-r--r--package/libs/libiconv/src/include/charmaps/windows-1251.h24
-rw-r--r--package/libs/libiconv/src/include/charmaps/windows-1252.h25
-rw-r--r--package/libs/libiconv/src/include/charmaps/windows-1253.h24
-rw-r--r--package/libs/libiconv/src/include/charmaps/windows-1254.h24
-rw-r--r--package/libs/libiconv/src/include/charmaps/windows-1255.h24
-rw-r--r--package/libs/libiconv/src/include/charmaps/windows-1256.h24
-rw-r--r--package/libs/libiconv/src/include/charmaps/windows-1257.h24
-rw-r--r--package/libs/libiconv/src/include/charmaps/windows-1258.h24
-rw-r--r--package/libs/libiconv/src/include/charmaps/windows-874.h24
-rw-r--r--package/libs/libiconv/src/include/iconv.h32
-rw-r--r--package/libs/libiconv/src/m4/.svn/entries62
-rw-r--r--package/libs/libiconv/src/m4/.svn/text-base/iconv.m4.svn-base214
-rw-r--r--package/libs/libiconv/src/m4/iconv.m4214
-rw-r--r--package/libs/libjson-c/.svn/entries62
-rw-r--r--package/libs/libjson-c/.svn/text-base/Makefile.svn-base55
-rw-r--r--package/libs/libjson-c/Makefile55
-rw-r--r--package/libs/libmnl/.svn/entries62
-rw-r--r--package/libs/libmnl/.svn/text-base/Makefile.svn-base76
-rw-r--r--package/libs/libmnl/Makefile76
-rw-r--r--package/libs/libnetfilter-conntrack/.svn/entries62
-rw-r--r--package/libs/libnetfilter-conntrack/.svn/text-base/Makefile.svn-base73
-rw-r--r--package/libs/libnetfilter-conntrack/Makefile73
-rw-r--r--package/libs/libnfnetlink/.svn/entries62
-rw-r--r--package/libs/libnfnetlink/.svn/text-base/Makefile.svn-base70
-rw-r--r--package/libs/libnfnetlink/Makefile70
-rw-r--r--package/libs/libnl-tiny/.svn/entries68
-rw-r--r--package/libs/libnl-tiny/.svn/text-base/Makefile.svn-base57
-rw-r--r--package/libs/libnl-tiny/Makefile57
-rw-r--r--package/libs/libnl-tiny/files/.svn/entries62
-rw-r--r--package/libs/libnl-tiny/files/.svn/text-base/libnl-tiny.pc.svn-base10
-rw-r--r--package/libs/libnl-tiny/files/libnl-tiny.pc10
-rw-r--r--package/libs/libnl-tiny/src/.svn/entries541
-rw-r--r--package/libs/libnl-tiny/src/.svn/text-base/Makefile.svn-base17
-rw-r--r--package/libs/libnl-tiny/src/.svn/text-base/attr.c.svn-base668
-rw-r--r--package/libs/libnl-tiny/src/.svn/text-base/cache.c.svn-base839
-rw-r--r--package/libs/libnl-tiny/src/.svn/text-base/cache_mngt.c.svn-base253
-rw-r--r--package/libs/libnl-tiny/src/.svn/text-base/error.c.svn-base108
-rw-r--r--package/libs/libnl-tiny/src/.svn/text-base/genl.c.svn-base268
-rw-r--r--package/libs/libnl-tiny/src/.svn/text-base/genl_ctrl.c.svn-base302
-rw-r--r--package/libs/libnl-tiny/src/.svn/text-base/genl_family.c.svn-base136
-rw-r--r--package/libs/libnl-tiny/src/.svn/text-base/genl_mngt.c.svn-base274
-rw-r--r--package/libs/libnl-tiny/src/.svn/text-base/handlers.c.svn-base162
-rw-r--r--package/libs/libnl-tiny/src/.svn/text-base/msg.c.svn-base566
-rw-r--r--package/libs/libnl-tiny/src/.svn/text-base/nl.c.svn-base720
-rw-r--r--package/libs/libnl-tiny/src/.svn/text-base/object.c.svn-base279
-rw-r--r--package/libs/libnl-tiny/src/.svn/text-base/socket.c.svn-base406
-rw-r--r--package/libs/libnl-tiny/src/.svn/text-base/unl.c.svn-base290
-rw-r--r--package/libs/libnl-tiny/src/Makefile17
-rw-r--r--package/libs/libnl-tiny/src/attr.c668
-rw-r--r--package/libs/libnl-tiny/src/cache.c839
-rw-r--r--package/libs/libnl-tiny/src/cache_mngt.c253
-rw-r--r--package/libs/libnl-tiny/src/error.c108
-rw-r--r--package/libs/libnl-tiny/src/genl.c268
-rw-r--r--package/libs/libnl-tiny/src/genl_ctrl.c302
-rw-r--r--package/libs/libnl-tiny/src/genl_family.c136
-rw-r--r--package/libs/libnl-tiny/src/genl_mngt.c274
-rw-r--r--package/libs/libnl-tiny/src/handlers.c162
-rw-r--r--package/libs/libnl-tiny/src/include/.svn/entries170
-rw-r--r--package/libs/libnl-tiny/src/include/.svn/text-base/netlink-generic.h.svn-base20
-rw-r--r--package/libs/libnl-tiny/src/include/.svn/text-base/netlink-local.h.svn-base158
-rw-r--r--package/libs/libnl-tiny/src/include/.svn/text-base/netlink-types.h.svn-base81
-rw-r--r--package/libs/libnl-tiny/src/include/.svn/text-base/unl.h.svn-base47
-rw-r--r--package/libs/libnl-tiny/src/include/linux/.svn/entries198
-rw-r--r--package/libs/libnl-tiny/src/include/linux/.svn/text-base/gen_stats.h.svn-base67
-rw-r--r--package/libs/libnl-tiny/src/include/linux/.svn/text-base/genetlink.h.svn-base83
-rw-r--r--package/libs/libnl-tiny/src/include/linux/.svn/text-base/if.h.svn-base131
-rw-r--r--package/libs/libnl-tiny/src/include/linux/.svn/text-base/if_addr.h.svn-base62
-rw-r--r--package/libs/libnl-tiny/src/include/linux/.svn/text-base/netlink.h.svn-base150
-rw-r--r--package/libs/libnl-tiny/src/include/linux/gen_stats.h67
-rw-r--r--package/libs/libnl-tiny/src/include/linux/genetlink.h83
-rw-r--r--package/libs/libnl-tiny/src/include/linux/if.h131
-rw-r--r--package/libs/libnl-tiny/src/include/linux/if_addr.h62
-rw-r--r--package/libs/libnl-tiny/src/include/linux/netlink.h150
-rw-r--r--package/libs/libnl-tiny/src/include/netlink-generic.h20
-rw-r--r--package/libs/libnl-tiny/src/include/netlink-local.h158
-rw-r--r--package/libs/libnl-tiny/src/include/netlink-types.h81
-rw-r--r--package/libs/libnl-tiny/src/include/netlink/.svn/entries643
-rw-r--r--package/libs/libnl-tiny/src/include/netlink/.svn/text-base/addr.h.svn-base69
-rw-r--r--package/libs/libnl-tiny/src/include/netlink/.svn/text-base/attr.h.svn-base726
-rw-r--r--package/libs/libnl-tiny/src/include/netlink/.svn/text-base/cache-api.h.svn-base199
-rw-r--r--package/libs/libnl-tiny/src/include/netlink/.svn/text-base/cache.h.svn-base128
-rw-r--r--package/libs/libnl-tiny/src/include/netlink/.svn/text-base/data.h.svn-base41
-rw-r--r--package/libs/libnl-tiny/src/include/netlink/.svn/text-base/errno.h.svn-base59
-rw-r--r--package/libs/libnl-tiny/src/include/netlink/.svn/text-base/handlers.h.svn-base230
-rw-r--r--package/libs/libnl-tiny/src/include/netlink/.svn/text-base/list.h.svn-base88
-rw-r--r--package/libs/libnl-tiny/src/include/netlink/.svn/text-base/msg.h.svn-base308
-rw-r--r--package/libs/libnl-tiny/src/include/netlink/.svn/text-base/netlink-compat.h.svn-base50
-rw-r--r--package/libs/libnl-tiny/src/include/netlink/.svn/text-base/netlink-kernel.h.svn-base196
-rw-r--r--package/libs/libnl-tiny/src/include/netlink/.svn/text-base/netlink.h.svn-base82
-rw-r--r--package/libs/libnl-tiny/src/include/netlink/.svn/text-base/object-api.h.svn-base331
-rw-r--r--package/libs/libnl-tiny/src/include/netlink/.svn/text-base/object.h.svn-base164
-rw-r--r--package/libs/libnl-tiny/src/include/netlink/.svn/text-base/socket.h.svn-base221
-rw-r--r--package/libs/libnl-tiny/src/include/netlink/.svn/text-base/types.h.svn-base121
-rw-r--r--package/libs/libnl-tiny/src/include/netlink/.svn/text-base/utils.h.svn-base78
-rw-r--r--package/libs/libnl-tiny/src/include/netlink/.svn/text-base/version.h.svn-base18
-rw-r--r--package/libs/libnl-tiny/src/include/netlink/addr.h69
-rw-r--r--package/libs/libnl-tiny/src/include/netlink/attr.h726
-rw-r--r--package/libs/libnl-tiny/src/include/netlink/cache-api.h199
-rw-r--r--package/libs/libnl-tiny/src/include/netlink/cache.h128
-rw-r--r--package/libs/libnl-tiny/src/include/netlink/data.h41
-rw-r--r--package/libs/libnl-tiny/src/include/netlink/errno.h59
-rw-r--r--package/libs/libnl-tiny/src/include/netlink/genl/.svn/entries164
-rw-r--r--package/libs/libnl-tiny/src/include/netlink/genl/.svn/text-base/ctrl.h.svn-base37
-rw-r--r--package/libs/libnl-tiny/src/include/netlink/genl/.svn/text-base/family.h.svn-base130
-rw-r--r--package/libs/libnl-tiny/src/include/netlink/genl/.svn/text-base/genl.h.svn-base47
-rw-r--r--package/libs/libnl-tiny/src/include/netlink/genl/.svn/text-base/mngt.h.svn-base87
-rw-r--r--package/libs/libnl-tiny/src/include/netlink/genl/ctrl.h37
-rw-r--r--package/libs/libnl-tiny/src/include/netlink/genl/family.h130
-rw-r--r--package/libs/libnl-tiny/src/include/netlink/genl/genl.h47
-rw-r--r--package/libs/libnl-tiny/src/include/netlink/genl/mngt.h87
-rw-r--r--package/libs/libnl-tiny/src/include/netlink/handlers.h230
-rw-r--r--package/libs/libnl-tiny/src/include/netlink/list.h88
-rw-r--r--package/libs/libnl-tiny/src/include/netlink/msg.h308
-rw-r--r--package/libs/libnl-tiny/src/include/netlink/netlink-compat.h50
-rw-r--r--package/libs/libnl-tiny/src/include/netlink/netlink-kernel.h196
-rw-r--r--package/libs/libnl-tiny/src/include/netlink/netlink.h82
-rw-r--r--package/libs/libnl-tiny/src/include/netlink/object-api.h331
-rw-r--r--package/libs/libnl-tiny/src/include/netlink/object.h164
-rw-r--r--package/libs/libnl-tiny/src/include/netlink/socket.h221
-rw-r--r--package/libs/libnl-tiny/src/include/netlink/types.h121
-rw-r--r--package/libs/libnl-tiny/src/include/netlink/utils.h78
-rw-r--r--package/libs/libnl-tiny/src/include/netlink/version.h18
-rw-r--r--package/libs/libnl-tiny/src/include/unl.h47
-rw-r--r--package/libs/libnl-tiny/src/msg.c566
-rw-r--r--package/libs/libnl-tiny/src/nl.c720
-rw-r--r--package/libs/libnl-tiny/src/object.c279
-rw-r--r--package/libs/libnl-tiny/src/socket.c406
-rw-r--r--package/libs/libnl-tiny/src/unl.c290
-rw-r--r--package/libs/libnl/.svn/entries65
-rw-r--r--package/libs/libnl/.svn/prop-base/Makefile.svn-base5
-rw-r--r--package/libs/libnl/.svn/text-base/Makefile.svn-base56
-rw-r--r--package/libs/libnl/Makefile56
-rw-r--r--package/libs/libnl/patches/.svn/entries96
-rw-r--r--package/libs/libnl/patches/.svn/text-base/110-offsetof.patch.svn-base12
-rw-r--r--package/libs/libnl/patches/.svn/text-base/160-update_includes_for_iw.patch.svn-base34
-rw-r--r--package/libs/libnl/patches/110-offsetof.patch12
-rw-r--r--package/libs/libnl/patches/160-update_includes_for_iw.patch34
-rw-r--r--package/libs/libpcap/.svn/entries99
-rw-r--r--package/libs/libpcap/.svn/prop-base/Makefile.svn-base9
-rw-r--r--package/libs/libpcap/.svn/text-base/Config.in.svn-base15
-rw-r--r--package/libs/libpcap/.svn/text-base/Makefile.svn-base85
-rw-r--r--package/libs/libpcap/Config.in15
-rw-r--r--package/libs/libpcap/Makefile85
-rw-r--r--package/libs/libpcap/patches/.svn/entries232
-rw-r--r--package/libs/libpcap/patches/.svn/prop-base/100-debian_shared_lib.patch.svn-base5
-rw-r--r--package/libs/libpcap/patches/.svn/text-base/100-debian_shared_lib.patch.svn-base178
-rw-r--r--package/libs/libpcap/patches/.svn/text-base/102-makefile_disable_manpages.patch.svn-base89
-rw-r--r--package/libs/libpcap/patches/.svn/text-base/103-makefile_flex_workaround.patch.svn-base14
-rw-r--r--package/libs/libpcap/patches/.svn/text-base/201-space_optimization.patch.svn-base133
-rw-r--r--package/libs/libpcap/patches/.svn/text-base/202-protocol_api.patch.svn-base141
-rw-r--r--package/libs/libpcap/patches/.svn/text-base/203-undef_iw_mode_monitor.patch.svn-base11
-rw-r--r--package/libs/libpcap/patches/100-debian_shared_lib.patch178
-rw-r--r--package/libs/libpcap/patches/102-makefile_disable_manpages.patch89
-rw-r--r--package/libs/libpcap/patches/103-makefile_flex_workaround.patch14
-rw-r--r--package/libs/libpcap/patches/201-space_optimization.patch133
-rw-r--r--package/libs/libpcap/patches/202-protocol_api.patch141
-rw-r--r--package/libs/libpcap/patches/203-undef_iw_mode_monitor.patch11
-rw-r--r--package/libs/libreadline/.svn/entries62
-rw-r--r--package/libs/libreadline/.svn/text-base/Makefile.svn-base72
-rw-r--r--package/libs/libreadline/Makefile72
-rw-r--r--package/libs/librpc/.svn/entries65
-rw-r--r--package/libs/librpc/.svn/text-base/Makefile.svn-base33
-rw-r--r--package/libs/librpc/Makefile33
-rw-r--r--package/libs/librpc/patches/.svn/entries62
-rw-r--r--package/libs/librpc/patches/.svn/text-base/100-compat_fix.patch.svn-base214
-rw-r--r--package/libs/librpc/patches/100-compat_fix.patch214
-rw-r--r--package/libs/libtool/.svn/entries62
-rw-r--r--package/libs/libtool/.svn/text-base/Makefile.svn-base52
-rw-r--r--package/libs/libtool/Makefile52
-rw-r--r--package/libs/libubox/.svn/entries62
-rw-r--r--package/libs/libubox/.svn/text-base/Makefile.svn-base85
-rw-r--r--package/libs/libubox/Makefile85
-rw-r--r--package/libs/libusb-compat/.svn/entries62
-rw-r--r--package/libs/libusb-compat/.svn/text-base/Makefile.svn-base49
-rw-r--r--package/libs/libusb-compat/Makefile49
-rw-r--r--package/libs/libusb/.svn/entries65
-rw-r--r--package/libs/libusb/.svn/text-base/Makefile.svn-base49
-rw-r--r--package/libs/libusb/Makefile49
-rw-r--r--package/libs/libusb/patches/.svn/entries62
-rw-r--r--package/libs/libusb/patches/.svn/text-base/001-timerfd.patch.svn-base33
-rw-r--r--package/libs/libusb/patches/001-timerfd.patch33
-rw-r--r--package/libs/lzo/.svn/entries62
-rw-r--r--package/libs/lzo/.svn/prop-base/Makefile.svn-base13
-rw-r--r--package/libs/lzo/.svn/text-base/Makefile.svn-base56
-rw-r--r--package/libs/lzo/Makefile56
-rw-r--r--package/libs/ncurses/.svn/entries65
-rw-r--r--package/libs/ncurses/.svn/prop-base/Makefile.svn-base13
-rw-r--r--package/libs/ncurses/.svn/text-base/Makefile.svn-base159
-rw-r--r--package/libs/ncurses/Makefile159
-rw-r--r--package/libs/ncurses/patches/.svn/entries198
-rw-r--r--package/libs/ncurses/patches/.svn/prop-base/500-cross.patch.svn-base5
-rw-r--r--package/libs/ncurses/patches/.svn/text-base/100-ncurses-5.6-20080112-urxvt.patch.svn-base175
-rw-r--r--package/libs/ncurses/patches/.svn/text-base/101-ncurses-5.6-20080628-kbs.patch.svn-base52
-rw-r--r--package/libs/ncurses/patches/.svn/text-base/200-fix_missing_include.patch.svn-base14
-rw-r--r--package/libs/ncurses/patches/.svn/text-base/500-cross.patch.svn-base11
-rw-r--r--package/libs/ncurses/patches/.svn/text-base/900-terminfo.patch.svn-base20
-rw-r--r--package/libs/ncurses/patches/100-ncurses-5.6-20080112-urxvt.patch175
-rw-r--r--package/libs/ncurses/patches/101-ncurses-5.6-20080628-kbs.patch52
-rw-r--r--package/libs/ncurses/patches/200-fix_missing_include.patch14
-rw-r--r--package/libs/ncurses/patches/500-cross.patch11
-rw-r--r--package/libs/ncurses/patches/900-terminfo.patch20
-rw-r--r--package/libs/ocf-crypto-headers/.svn/entries65
-rw-r--r--package/libs/ocf-crypto-headers/.svn/prop-base/Makefile.svn-base5
-rw-r--r--package/libs/ocf-crypto-headers/.svn/text-base/Makefile.svn-base39
-rw-r--r--package/libs/ocf-crypto-headers/Makefile39
-rw-r--r--package/libs/ocf-crypto-headers/src/.svn/entries62
-rw-r--r--package/libs/ocf-crypto-headers/src/.svn/prop-base/cryptodev.h.svn-base5
-rw-r--r--package/libs/ocf-crypto-headers/src/.svn/text-base/cryptodev.h.svn-base480
-rw-r--r--package/libs/ocf-crypto-headers/src/cryptodev.h480
-rw-r--r--package/libs/openssl/.svn/entries99
-rw-r--r--package/libs/openssl/.svn/prop-base/Makefile.svn-base9
-rw-r--r--package/libs/openssl/.svn/text-base/Config.in.svn-base13
-rw-r--r--package/libs/openssl/.svn/text-base/Makefile.svn-base180
-rw-r--r--package/libs/openssl/Config.in13
-rw-r--r--package/libs/openssl/Makefile180
-rw-r--r--package/libs/openssl/patches/.svn/entries334
-rw-r--r--package/libs/openssl/patches/.svn/prop-base/110-optimize-for-size.patch.svn-base5
-rw-r--r--package/libs/openssl/patches/.svn/prop-base/130-perl-path.patch.svn-base5
-rw-r--r--package/libs/openssl/patches/.svn/prop-base/140-makefile-dirs.patch.svn-base5
-rw-r--r--package/libs/openssl/patches/.svn/prop-base/150-no_engines.patch.svn-base5
-rw-r--r--package/libs/openssl/patches/.svn/prop-base/160-disable_doc_tests.patch.svn-base5
-rw-r--r--package/libs/openssl/patches/.svn/prop-base/170-bash_path.patch.svn-base5
-rw-r--r--package/libs/openssl/patches/.svn/text-base/110-optimize-for-size.patch.svn-base13
-rw-r--r--package/libs/openssl/patches/.svn/text-base/120-cisco-dtls-fix.patch.svn-base31
-rw-r--r--package/libs/openssl/patches/.svn/text-base/130-perl-path.patch.svn-base64
-rw-r--r--package/libs/openssl/patches/.svn/text-base/140-makefile-dirs.patch.svn-base11
-rw-r--r--package/libs/openssl/patches/.svn/text-base/150-no_engines.patch.svn-base81
-rw-r--r--package/libs/openssl/patches/.svn/text-base/160-disable_doc_tests.patch.svn-base58
-rw-r--r--package/libs/openssl/patches/.svn/text-base/170-bash_path.patch.svn-base8
-rw-r--r--package/libs/openssl/patches/.svn/text-base/180-fix_link_segfault.patch.svn-base18
-rw-r--r--package/libs/openssl/patches/.svn/text-base/190-remove_timestamp_check.patch.svn-base23
-rw-r--r--package/libs/openssl/patches/110-optimize-for-size.patch13
-rw-r--r--package/libs/openssl/patches/120-cisco-dtls-fix.patch31
-rw-r--r--package/libs/openssl/patches/130-perl-path.patch64
-rw-r--r--package/libs/openssl/patches/140-makefile-dirs.patch11
-rw-r--r--package/libs/openssl/patches/150-no_engines.patch81
-rw-r--r--package/libs/openssl/patches/160-disable_doc_tests.patch58
-rw-r--r--package/libs/openssl/patches/170-bash_path.patch8
-rw-r--r--package/libs/openssl/patches/180-fix_link_segfault.patch18
-rw-r--r--package/libs/openssl/patches/190-remove_timestamp_check.patch23
-rw-r--r--package/libs/polarssl/.svn/entries65
-rw-r--r--package/libs/polarssl/.svn/text-base/Makefile.svn-base81
-rw-r--r--package/libs/polarssl/Makefile81
-rw-r--r--package/libs/polarssl/patches/.svn/entries164
-rw-r--r--package/libs/polarssl/patches/.svn/text-base/100-disable-testsuites.patch.svn-base21
-rw-r--r--package/libs/polarssl/patches/.svn/text-base/200-reduce_config.patch.svn-base112
-rw-r--r--package/libs/polarssl/patches/.svn/text-base/300-openssl_cipher_name_compat.patch.svn-base53
-rw-r--r--package/libs/polarssl/patches/.svn/text-base/310-fix_blowfish_key_len.patch.svn-base29
-rw-r--r--package/libs/polarssl/patches/100-disable-testsuites.patch21
-rw-r--r--package/libs/polarssl/patches/200-reduce_config.patch112
-rw-r--r--package/libs/polarssl/patches/300-openssl_cipher_name_compat.patch53
-rw-r--r--package/libs/polarssl/patches/310-fix_blowfish_key_len.patch29
-rw-r--r--package/libs/popt/.svn/entries65
-rw-r--r--package/libs/popt/.svn/prop-base/Makefile.svn-base13
-rw-r--r--package/libs/popt/.svn/text-base/Makefile.svn-base59
-rw-r--r--package/libs/popt/Makefile59
-rw-r--r--package/libs/popt/patches/.svn/entries62
-rw-r--r--package/libs/popt/patches/.svn/text-base/002-no-intl.patch.svn-base81
-rw-r--r--package/libs/popt/patches/002-no-intl.patch81
-rw-r--r--package/libs/sysfsutils/.svn/entries65
-rw-r--r--package/libs/sysfsutils/.svn/text-base/Makefile.svn-base73
-rw-r--r--package/libs/sysfsutils/Makefile73
-rw-r--r--package/libs/sysfsutils/patches/.svn/entries62
-rw-r--r--package/libs/sysfsutils/patches/.svn/text-base/200-mnt_path_check.patch.svn-base55
-rw-r--r--package/libs/sysfsutils/patches/200-mnt_path_check.patch55
-rw-r--r--package/libs/uclibc++/.svn/entries68
-rw-r--r--package/libs/uclibc++/.svn/text-base/Makefile.svn-base92
-rw-r--r--package/libs/uclibc++/Makefile92
-rw-r--r--package/libs/uclibc++/files/.svn/entries62
-rw-r--r--package/libs/uclibc++/files/.svn/text-base/config.default.svn-base58
-rw-r--r--package/libs/uclibc++/files/config.default58
-rw-r--r--package/libs/uclibc++/patches/.svn/entries96
-rw-r--r--package/libs/uclibc++/patches/.svn/text-base/002-path_to_bash.patch.svn-base11
-rw-r--r--package/libs/uclibc++/patches/.svn/text-base/006-eabi_fix.patch.svn-base38
-rw-r--r--package/libs/uclibc++/patches/002-path_to_bash.patch11
-rw-r--r--package/libs/uclibc++/patches/006-eabi_fix.patch38
-rw-r--r--package/libs/ustream-ssl/.svn/entries62
-rw-r--r--package/libs/ustream-ssl/.svn/text-base/Makefile.svn-base59
-rw-r--r--package/libs/ustream-ssl/Makefile59
-rw-r--r--package/libs/zlib/.svn/entries62
-rw-r--r--package/libs/zlib/.svn/prop-base/Makefile.svn-base9
-rw-r--r--package/libs/zlib/.svn/text-base/Makefile.svn-base72
-rw-r--r--package/libs/zlib/Makefile72
-rw-r--r--package/linux-atm/.svn/entries68
-rw-r--r--package/linux-atm/.svn/prop-base/Makefile.svn-base9
-rw-r--r--package/linux-atm/.svn/text-base/Makefile.svn-base190
-rw-r--r--package/linux-atm/Makefile190
-rw-r--r--package/linux-atm/files/.svn/entries62
-rw-r--r--package/linux-atm/files/.svn/prop-base/br2684ctl.svn-base5
-rw-r--r--package/linux-atm/files/.svn/text-base/br2684ctl.svn-base89
-rwxr-xr-xpackage/linux-atm/files/br2684ctl89
-rw-r--r--package/linux-atm/patches/.svn/entries164
-rw-r--r--package/linux-atm/patches/.svn/prop-base/000-debian_16.patch.svn-base5
-rw-r--r--package/linux-atm/patches/.svn/text-base/000-debian_16.patch.svn-base270
-rw-r--r--package/linux-atm/patches/.svn/text-base/200-no_libfl.patch.svn-base179
-rw-r--r--package/linux-atm/patches/.svn/text-base/300-objcopy_path.patch.svn-base40
-rw-r--r--package/linux-atm/patches/.svn/text-base/400-portability_fixes.patch.svn-base60
-rw-r--r--package/linux-atm/patches/000-debian_16.patch270
-rw-r--r--package/linux-atm/patches/200-no_libfl.patch179
-rw-r--r--package/linux-atm/patches/300-objcopy_path.patch40
-rw-r--r--package/linux-atm/patches/400-portability_fixes.patch60
-rw-r--r--package/lua/.svn/entries68
-rw-r--r--package/lua/.svn/prop-base/Makefile.svn-base13
-rw-r--r--package/lua/.svn/text-base/Makefile.svn-base183
-rw-r--r--package/lua/Makefile183
-rw-r--r--package/lua/patches-host/.svn/entries198
-rw-r--r--package/lua/patches-host/.svn/text-base/010-lua-5.1.3-lnum-full-260308.patch.svn-base3736
-rw-r--r--package/lua/patches-host/.svn/text-base/011-lnum-use-double.patch.svn-base11
-rw-r--r--package/lua/patches-host/.svn/text-base/015-lnum-ppc-compat.patch.svn-base11
-rw-r--r--package/lua/patches-host/.svn/text-base/030-archindependent-bytecode.patch.svn-base111
-rw-r--r--package/lua/patches-host/.svn/text-base/100-no_readline.patch.svn-base49
-rw-r--r--package/lua/patches-host/010-lua-5.1.3-lnum-full-260308.patch3736
-rw-r--r--package/lua/patches-host/011-lnum-use-double.patch11
-rw-r--r--package/lua/patches-host/015-lnum-ppc-compat.patch11
-rw-r--r--package/lua/patches-host/030-archindependent-bytecode.patch111
-rw-r--r--package/lua/patches-host/100-no_readline.patch49
-rw-r--r--package/lua/patches/.svn/entries300
-rw-r--r--package/lua/patches/.svn/prop-base/020-shared_liblua.patch.svn-base5
-rw-r--r--package/lua/patches/.svn/text-base/010-lua-5.1.3-lnum-full-260308.patch.svn-base3736
-rw-r--r--package/lua/patches/.svn/text-base/011-lnum-use-double.patch.svn-base11
-rw-r--r--package/lua/patches/.svn/text-base/015-lnum-ppc-compat.patch.svn-base11
-rw-r--r--package/lua/patches/.svn/text-base/020-shared_liblua.patch.svn-base140
-rw-r--r--package/lua/patches/.svn/text-base/030-archindependent-bytecode.patch.svn-base111
-rw-r--r--package/lua/patches/.svn/text-base/100-no_readline.patch.svn-base49
-rw-r--r--package/lua/patches/.svn/text-base/200-lua-path.patch.svn-base15
-rw-r--r--package/lua/patches/.svn/text-base/300-opcode_performance.patch.svn-base363
-rw-r--r--package/lua/patches/010-lua-5.1.3-lnum-full-260308.patch3736
-rw-r--r--package/lua/patches/011-lnum-use-double.patch11
-rw-r--r--package/lua/patches/015-lnum-ppc-compat.patch11
-rw-r--r--package/lua/patches/020-shared_liblua.patch140
-rw-r--r--package/lua/patches/030-archindependent-bytecode.patch111
-rw-r--r--package/lua/patches/100-no_readline.patch49
-rw-r--r--package/lua/patches/200-lua-path.patch15
-rw-r--r--package/lua/patches/300-opcode_performance.patch363
-rw-r--r--package/mac80211/.svn/entries68
-rw-r--r--package/mac80211/.svn/text-base/Makefile.svn-base1701
-rw-r--r--package/mac80211/Makefile1701
-rw-r--r--package/mac80211/files/.svn/entries68
-rw-r--r--package/mac80211/files/.svn/text-base/regdb.txt.svn-base697
-rw-r--r--package/mac80211/files/host_bin/.svn/entries28
-rw-r--r--package/mac80211/files/lib/.svn/entries31
-rw-r--r--package/mac80211/files/lib/wifi/.svn/entries62
-rw-r--r--package/mac80211/files/lib/wifi/.svn/text-base/mac80211.sh.svn-base606
-rw-r--r--package/mac80211/files/lib/wifi/mac80211.sh606
-rw-r--r--package/mac80211/files/regdb.txt697
-rw-r--r--package/mac80211/patches/.svn/entries2782
-rw-r--r--package/mac80211/patches/.svn/text-base/001-disable_rfkill.patch.svn-base13
-rw-r--r--package/mac80211/patches/.svn/text-base/002-disable_ssb_build.patch.svn-base21
-rw-r--r--package/mac80211/patches/.svn/text-base/003-disable_codel.patch.svn-base19
-rw-r--r--package/mac80211/patches/.svn/text-base/004-use_env_for_bash.patch.svn-base8
-rw-r--r--package/mac80211/patches/.svn/text-base/010-add_include_for_bcma.patch.svn-base11
-rw-r--r--package/mac80211/patches/.svn/text-base/020-disable_tty_set_termios.patch.svn-base16
-rw-r--r--package/mac80211/patches/.svn/text-base/030-wext.patch.svn-base18
-rw-r--r--package/mac80211/patches/.svn/text-base/040-linux_3_9_compat.patch.svn-base153
-rw-r--r--package/mac80211/patches/.svn/text-base/130-mesh_pathtbl_backport.patch.svn-base212
-rw-r--r--package/mac80211/patches/.svn/text-base/150-disable_addr_notifier.patch.svn-base67
-rw-r--r--package/mac80211/patches/.svn/text-base/201-ath5k-WAR-for-AR71xx-PCI-bug.patch.svn-base38
-rw-r--r--package/mac80211/patches/.svn/text-base/300-pending_work.patch.svn-base963
-rw-r--r--package/mac80211/patches/.svn/text-base/310-ap_scan.patch.svn-base11
-rw-r--r--package/mac80211/patches/.svn/text-base/400-ath_move_debug_code.patch.svn-base28
-rw-r--r--package/mac80211/patches/.svn/text-base/401-ath9k_blink_default.patch.svn-base11
-rw-r--r--package/mac80211/patches/.svn/text-base/402-ath9k-fix-invalid-mac-address-handling.patch.svn-base29
-rw-r--r--package/mac80211/patches/.svn/text-base/403-ath_regd_optional.patch.svn-base46
-rw-r--r--package/mac80211/patches/.svn/text-base/404-world_regd_fixup.patch.svn-base84
-rw-r--r--package/mac80211/patches/.svn/text-base/405-regd_no_assoc_hints.patch.svn-base19
-rw-r--r--package/mac80211/patches/.svn/text-base/406-ath_regd_us.patch.svn-base26
-rw-r--r--package/mac80211/patches/.svn/text-base/410-ath9k_allow_adhoc_and_ap.patch.svn-base10
-rw-r--r--package/mac80211/patches/.svn/text-base/411-ath5k_allow_adhoc_and_ap.patch.svn-base46
-rw-r--r--package/mac80211/patches/.svn/text-base/420-ath5k_disable_fast_cc.patch.svn-base18
-rw-r--r--package/mac80211/patches/.svn/text-base/430-add_ath5k_platform.patch.svn-base33
-rw-r--r--package/mac80211/patches/.svn/text-base/431-add_platform_eeprom_support_to_ath5k.patch.svn-base56
-rw-r--r--package/mac80211/patches/.svn/text-base/432-ath5k_add_pciids.patch.svn-base11
-rw-r--r--package/mac80211/patches/.svn/text-base/440-ath5k_channel_bw_debugfs.patch.svn-base113
-rw-r--r--package/mac80211/patches/.svn/text-base/500-ath9k_eeprom_debugfs.patch.svn-base65
-rw-r--r--package/mac80211/patches/.svn/text-base/501-ath9k-eeprom_endianess.patch.svn-base102
-rw-r--r--package/mac80211/patches/.svn/text-base/502-ath9k_ahb_init.patch.svn-base32
-rw-r--r--package/mac80211/patches/.svn/text-base/510-ath9k_intr_mitigation_tweak.patch.svn-base13
-rw-r--r--package/mac80211/patches/.svn/text-base/511-ath9k_reduce_rxbuf.patch.svn-base11
-rw-r--r--package/mac80211/patches/.svn/text-base/512-ath9k_channelbw_debugfs.patch.svn-base128
-rw-r--r--package/mac80211/patches/.svn/text-base/513-mac80211_reduce_txqueuelen.patch.svn-base10
-rw-r--r--package/mac80211/patches/.svn/text-base/520-mac80211_cur_txpower.patch.svn-base33
-rw-r--r--package/mac80211/patches/.svn/text-base/521-ath9k_cur_txpower.patch.svn-base19
-rw-r--r--package/mac80211/patches/.svn/text-base/522-ath9k_per_chain_signal_strength.patch.svn-base393
-rw-r--r--package/mac80211/patches/.svn/text-base/523-mac80211_configure_antenna_gain.patch.svn-base162
-rw-r--r--package/mac80211/patches/.svn/text-base/524-ath9k_use_configured_antenna_gain.patch.svn-base34
-rw-r--r--package/mac80211/patches/.svn/text-base/530-ath9k_extra_leds.patch.svn-base248
-rw-r--r--package/mac80211/patches/.svn/text-base/531-ath9k_extra_platform_leds.patch.svn-base71
-rw-r--r--package/mac80211/patches/.svn/text-base/540-mac80211_optimize_mcs_rate_mask.patch.svn-base98
-rw-r--r--package/mac80211/patches/.svn/text-base/541-ath9k_optimize_interrupt_mitigation.patch.svn-base30
-rw-r--r--package/mac80211/patches/.svn/text-base/550-ath9k_reduce_ani_interval.patch.svn-base11
-rw-r--r--package/mac80211/patches/.svn/text-base/551-ath9k_revert_initval_change.patch.svn-base19
-rw-r--r--package/mac80211/patches/.svn/text-base/552-ath9k_rx_dma_stop_check.patch.svn-base28
-rw-r--r--package/mac80211/patches/.svn/text-base/553-ath9k_debugfs_diag.patch.svn-base139
-rw-r--r--package/mac80211/patches/.svn/text-base/554-ath9k_ani_mrc_fix.patch.svn-base13
-rw-r--r--package/mac80211/patches/.svn/text-base/555-ath9k-allow-to-disable-bands-via-platform-data.patch.svn-base70
-rw-r--r--package/mac80211/patches/.svn/text-base/600-rt2x00-disable-pci-code-if-CONFIG_PCI-not-defined.patch.svn-base18
-rw-r--r--package/mac80211/patches/.svn/text-base/601-rt2x00-set_pci_mwi.patch.svn-base13
-rw-r--r--package/mac80211/patches/.svn/text-base/602-rt2x00-introduce-rt2x00_platform_h.patch.svn-base32
-rw-r--r--package/mac80211/patches/.svn/text-base/603-rt2x00-introduce-rt2x00eeprom.patch.svn-base279
-rw-r--r--package/mac80211/patches/.svn/text-base/604-rt2x00-add-CONFIG_RT2X00_LIB_EEPROM-option.patch.svn-base10
-rw-r--r--package/mac80211/patches/.svn/text-base/605-rt2x00-pci-eeprom.patch.svn-base46
-rw-r--r--package/mac80211/patches/.svn/text-base/606-rt2x00_no_realign.patch.svn-base67
-rw-r--r--package/mac80211/patches/.svn/text-base/607-rt2x00-allow_disabling_bands_through_platform_data.patch.svn-base47
-rw-r--r--package/mac80211/patches/.svn/text-base/608-add_platform_data_mac_addr.patch.svn-base63
-rw-r--r--package/mac80211/patches/.svn/text-base/610-rt2x00-fix-rt3352-ext-pa.patch.svn-base214
-rw-r--r--package/mac80211/patches/.svn/text-base/611-rt2x00-rf_vals-rt3352-xtal20.patch.svn-base115
-rw-r--r--package/mac80211/patches/.svn/text-base/700-mwl8k-missing-pci-id-for-WNR854T.patch.svn-base10
-rw-r--r--package/mac80211/patches/.svn/text-base/800-b43-gpio-mask-module-option.patch.svn-base37
-rw-r--r--package/mac80211/patches/.svn/text-base/810-b43_no_pio.patch.svn-base75
-rw-r--r--package/mac80211/patches/.svn/text-base/820-b43-add-antenna-control.patch.svn-base131
-rw-r--r--package/mac80211/patches/.svn/text-base/830-b43-workaround-pcie-bcm4716.patch.svn-base134
-rw-r--r--package/mac80211/patches/.svn/text-base/840-b43-increase_number_of_rx_dma_slots.patch.svn-base11
-rw-r--r--package/mac80211/patches/.svn/text-base/850-brcmsmac-start-adding-support-for-core-rev-28.patch.svn-base75
-rw-r--r--package/mac80211/patches/.svn/text-base/860-brcmsmac-implement-ieee80211_ops-get_tsf-and-set_tsf.patch.svn-base121
-rw-r--r--package/mac80211/patches/.svn/text-base/861-brcmsmac-add-interface-type-to-brcms_bss_cfg.patch.svn-base66
-rw-r--r--package/mac80211/patches/.svn/text-base/862-brcmsmac-remove-brcms_bss_cfg-BSS.patch.svn-base77
-rw-r--r--package/mac80211/patches/.svn/text-base/863-brcmsmac-remove-brcms_bss_cfg-associated.patch.svn-base74
-rw-r--r--package/mac80211/patches/.svn/text-base/864-brcmsmac-remove-brcms_bss_cfg-enable.patch.svn-base32
-rw-r--r--package/mac80211/patches/.svn/text-base/865-brcmsmac-remove-brcms_bss_cfg-up.patch.svn-base47
-rw-r--r--package/mac80211/patches/.svn/text-base/866-brcmsmac-remove-brcms_bss_cfg-cur_etheraddr.patch.svn-base30
-rw-r--r--package/mac80211/patches/.svn/text-base/867-brcmsmac-remove-brcms_pub-bcmerr.patch.svn-base21
-rw-r--r--package/mac80211/patches/.svn/text-base/868-brcmsmac-write-beacon-period-to-hardware.patch.svn-base23
-rw-r--r--package/mac80211/patches/.svn/text-base/869-brcmsmac-add-beacon-template-support.patch.svn-base266
-rw-r--r--package/mac80211/patches/.svn/text-base/870-brcmsmac-react-on-changing-SSID.patch.svn-base43
-rw-r--r--package/mac80211/patches/.svn/text-base/871-brcmsmac-add-support-for-probe-response-template.patch.svn-base216
-rw-r--r--package/mac80211/patches/.svn/text-base/872-brcmsmac-activate-AP-support.patch.svn-base74
-rw-r--r--package/mac80211/patches/.svn/text-base/873-brcmsmac-remove-extra-regulation-restriction.patch.svn-base31
-rw-r--r--package/mac80211/patches/001-disable_rfkill.patch13
-rw-r--r--package/mac80211/patches/002-disable_ssb_build.patch21
-rw-r--r--package/mac80211/patches/003-disable_codel.patch19
-rw-r--r--package/mac80211/patches/004-use_env_for_bash.patch8
-rw-r--r--package/mac80211/patches/010-add_include_for_bcma.patch11
-rw-r--r--package/mac80211/patches/020-disable_tty_set_termios.patch16
-rw-r--r--package/mac80211/patches/030-wext.patch18
-rw-r--r--package/mac80211/patches/040-linux_3_9_compat.patch153
-rw-r--r--package/mac80211/patches/130-mesh_pathtbl_backport.patch212
-rw-r--r--package/mac80211/patches/150-disable_addr_notifier.patch67
-rw-r--r--package/mac80211/patches/201-ath5k-WAR-for-AR71xx-PCI-bug.patch38
-rw-r--r--package/mac80211/patches/300-pending_work.patch963
-rw-r--r--package/mac80211/patches/310-ap_scan.patch11
-rw-r--r--package/mac80211/patches/400-ath_move_debug_code.patch28
-rw-r--r--package/mac80211/patches/401-ath9k_blink_default.patch11
-rw-r--r--package/mac80211/patches/402-ath9k-fix-invalid-mac-address-handling.patch29
-rw-r--r--package/mac80211/patches/403-ath_regd_optional.patch46
-rw-r--r--package/mac80211/patches/404-world_regd_fixup.patch84
-rw-r--r--package/mac80211/patches/405-regd_no_assoc_hints.patch19
-rw-r--r--package/mac80211/patches/406-ath_regd_us.patch26
-rw-r--r--package/mac80211/patches/410-ath9k_allow_adhoc_and_ap.patch10
-rw-r--r--package/mac80211/patches/411-ath5k_allow_adhoc_and_ap.patch46
-rw-r--r--package/mac80211/patches/420-ath5k_disable_fast_cc.patch18
-rw-r--r--package/mac80211/patches/430-add_ath5k_platform.patch33
-rw-r--r--package/mac80211/patches/431-add_platform_eeprom_support_to_ath5k.patch56
-rw-r--r--package/mac80211/patches/432-ath5k_add_pciids.patch11
-rw-r--r--package/mac80211/patches/440-ath5k_channel_bw_debugfs.patch113
-rw-r--r--package/mac80211/patches/500-ath9k_eeprom_debugfs.patch65
-rw-r--r--package/mac80211/patches/501-ath9k-eeprom_endianess.patch102
-rw-r--r--package/mac80211/patches/502-ath9k_ahb_init.patch32
-rw-r--r--package/mac80211/patches/510-ath9k_intr_mitigation_tweak.patch13
-rw-r--r--package/mac80211/patches/511-ath9k_reduce_rxbuf.patch11
-rw-r--r--package/mac80211/patches/512-ath9k_channelbw_debugfs.patch128
-rw-r--r--package/mac80211/patches/513-mac80211_reduce_txqueuelen.patch10
-rw-r--r--package/mac80211/patches/520-mac80211_cur_txpower.patch33
-rw-r--r--package/mac80211/patches/521-ath9k_cur_txpower.patch19
-rw-r--r--package/mac80211/patches/522-ath9k_per_chain_signal_strength.patch393
-rw-r--r--package/mac80211/patches/523-mac80211_configure_antenna_gain.patch162
-rw-r--r--package/mac80211/patches/524-ath9k_use_configured_antenna_gain.patch34
-rw-r--r--package/mac80211/patches/530-ath9k_extra_leds.patch248
-rw-r--r--package/mac80211/patches/531-ath9k_extra_platform_leds.patch71
-rw-r--r--package/mac80211/patches/540-mac80211_optimize_mcs_rate_mask.patch98
-rw-r--r--package/mac80211/patches/541-ath9k_optimize_interrupt_mitigation.patch30
-rw-r--r--package/mac80211/patches/550-ath9k_reduce_ani_interval.patch11
-rw-r--r--package/mac80211/patches/551-ath9k_revert_initval_change.patch19
-rw-r--r--package/mac80211/patches/552-ath9k_rx_dma_stop_check.patch28
-rw-r--r--package/mac80211/patches/553-ath9k_debugfs_diag.patch139
-rw-r--r--package/mac80211/patches/554-ath9k_ani_mrc_fix.patch13
-rw-r--r--package/mac80211/patches/555-ath9k-allow-to-disable-bands-via-platform-data.patch70
-rw-r--r--package/mac80211/patches/600-rt2x00-disable-pci-code-if-CONFIG_PCI-not-defined.patch18
-rw-r--r--package/mac80211/patches/601-rt2x00-set_pci_mwi.patch13
-rw-r--r--package/mac80211/patches/602-rt2x00-introduce-rt2x00_platform_h.patch32
-rw-r--r--package/mac80211/patches/603-rt2x00-introduce-rt2x00eeprom.patch279
-rw-r--r--package/mac80211/patches/604-rt2x00-add-CONFIG_RT2X00_LIB_EEPROM-option.patch10
-rw-r--r--package/mac80211/patches/605-rt2x00-pci-eeprom.patch46
-rw-r--r--package/mac80211/patches/606-rt2x00_no_realign.patch67
-rw-r--r--package/mac80211/patches/607-rt2x00-allow_disabling_bands_through_platform_data.patch47
-rw-r--r--package/mac80211/patches/608-add_platform_data_mac_addr.patch63
-rw-r--r--package/mac80211/patches/610-rt2x00-fix-rt3352-ext-pa.patch214
-rw-r--r--package/mac80211/patches/611-rt2x00-rf_vals-rt3352-xtal20.patch115
-rw-r--r--package/mac80211/patches/700-mwl8k-missing-pci-id-for-WNR854T.patch10
-rw-r--r--package/mac80211/patches/800-b43-gpio-mask-module-option.patch37
-rw-r--r--package/mac80211/patches/810-b43_no_pio.patch75
-rw-r--r--package/mac80211/patches/820-b43-add-antenna-control.patch131
-rw-r--r--package/mac80211/patches/830-b43-workaround-pcie-bcm4716.patch134
-rw-r--r--package/mac80211/patches/840-b43-increase_number_of_rx_dma_slots.patch11
-rw-r--r--package/mac80211/patches/850-brcmsmac-start-adding-support-for-core-rev-28.patch75
-rw-r--r--package/mac80211/patches/860-brcmsmac-implement-ieee80211_ops-get_tsf-and-set_tsf.patch121
-rw-r--r--package/mac80211/patches/861-brcmsmac-add-interface-type-to-brcms_bss_cfg.patch66
-rw-r--r--package/mac80211/patches/862-brcmsmac-remove-brcms_bss_cfg-BSS.patch77
-rw-r--r--package/mac80211/patches/863-brcmsmac-remove-brcms_bss_cfg-associated.patch74
-rw-r--r--package/mac80211/patches/864-brcmsmac-remove-brcms_bss_cfg-enable.patch32
-rw-r--r--package/mac80211/patches/865-brcmsmac-remove-brcms_bss_cfg-up.patch47
-rw-r--r--package/mac80211/patches/866-brcmsmac-remove-brcms_bss_cfg-cur_etheraddr.patch30
-rw-r--r--package/mac80211/patches/867-brcmsmac-remove-brcms_pub-bcmerr.patch21
-rw-r--r--package/mac80211/patches/868-brcmsmac-write-beacon-period-to-hardware.patch23
-rw-r--r--package/mac80211/patches/869-brcmsmac-add-beacon-template-support.patch266
-rw-r--r--package/mac80211/patches/870-brcmsmac-react-on-changing-SSID.patch43
-rw-r--r--package/mac80211/patches/871-brcmsmac-add-support-for-probe-response-template.patch216
-rw-r--r--package/mac80211/patches/872-brcmsmac-activate-AP-support.patch74
-rw-r--r--package/mac80211/patches/873-brcmsmac-remove-extra-regulation-restriction.patch31
-rw-r--r--package/mkelfimage/.svn/entries65
-rw-r--r--package/mkelfimage/.svn/text-base/Makefile.svn-base35
-rw-r--r--package/mkelfimage/Makefile35
-rw-r--r--package/mkelfimage/patches/.svn/entries62
-rw-r--r--package/mkelfimage/patches/.svn/text-base/no-stack-protector.patch.svn-base11
-rw-r--r--package/mkelfimage/patches/no-stack-protector.patch11
-rw-r--r--package/mountd/.svn/entries68
-rw-r--r--package/mountd/.svn/text-base/Makefile.svn-base47
-rw-r--r--package/mountd/Makefile47
-rw-r--r--package/mountd/files/.svn/entries96
-rw-r--r--package/mountd/files/.svn/prop-base/mountd.init.svn-base5
-rw-r--r--package/mountd/files/.svn/text-base/mountd.config.svn-base3
-rw-r--r--package/mountd/files/.svn/text-base/mountd.init.svn-base19
-rw-r--r--package/mountd/files/mountd.config3
-rwxr-xr-xpackage/mountd/files/mountd.init19
-rw-r--r--package/mountd/patches/.svn/entries164
-rw-r--r--package/mountd/patches/.svn/text-base/010-uci_rename_history_to_delta.patch.svn-base27
-rw-r--r--package/mountd/patches/.svn/text-base/020-handle_timeout.patch.svn-base32
-rw-r--r--package/mountd/patches/.svn/text-base/030-ext4_support.patch.svn-base85
-rw-r--r--package/mountd/patches/.svn/text-base/040-optional-daemonize.patch.svn-base13
-rw-r--r--package/mountd/patches/010-uci_rename_history_to_delta.patch27
-rw-r--r--package/mountd/patches/020-handle_timeout.patch32
-rw-r--r--package/mountd/patches/030-ext4_support.patch85
-rw-r--r--package/mountd/patches/040-optional-daemonize.patch13
-rw-r--r--package/mtd/.svn/entries65
-rw-r--r--package/mtd/.svn/prop-base/Makefile.svn-base9
-rw-r--r--package/mtd/.svn/text-base/Makefile.svn-base53
-rw-r--r--package/mtd/Makefile53
-rw-r--r--package/mtd/src/.svn/entries538
-rw-r--r--package/mtd/src/.svn/prop-base/Makefile.svn-base5
-rw-r--r--package/mtd/src/.svn/prop-base/md5.c.svn-base5
-rw-r--r--package/mtd/src/.svn/prop-base/md5.h.svn-base5
-rw-r--r--package/mtd/src/.svn/prop-base/mtd.c.svn-base5
-rw-r--r--package/mtd/src/.svn/prop-base/seama.c.svn-base5
-rw-r--r--package/mtd/src/.svn/prop-base/seama.h.svn-base5
-rw-r--r--package/mtd/src/.svn/text-base/Makefile.svn-base18
-rw-r--r--package/mtd/src/.svn/text-base/crc32.c.svn-base95
-rw-r--r--package/mtd/src/.svn/text-base/crc32.h.svn-base26
-rw-r--r--package/mtd/src/.svn/text-base/fis.c.svn-base262
-rw-r--r--package/mtd/src/.svn/text-base/fis.h.svn-base14
-rw-r--r--package/mtd/src/.svn/text-base/imagetag.c.svn-base316
-rw-r--r--package/mtd/src/.svn/text-base/jffs2.c.svn-base357
-rw-r--r--package/mtd/src/.svn/text-base/jffs2.h.svn-base216
-rw-r--r--package/mtd/src/.svn/text-base/md5.c.svn-base307
-rw-r--r--package/mtd/src/.svn/text-base/md5.h.svn-base65
-rw-r--r--package/mtd/src/.svn/text-base/mtd.c.svn-base761
-rw-r--r--package/mtd/src/.svn/text-base/mtd.h.svn-base29
-rw-r--r--package/mtd/src/.svn/text-base/seama.c.svn-base179
-rw-r--r--package/mtd/src/.svn/text-base/seama.h.svn-base108
-rw-r--r--package/mtd/src/.svn/text-base/trx.c.svn-base220
-rw-r--r--package/mtd/src/Makefile18
-rw-r--r--package/mtd/src/crc32.c95
-rw-r--r--package/mtd/src/crc32.h26
-rw-r--r--package/mtd/src/fis.c262
-rw-r--r--package/mtd/src/fis.h14
-rw-r--r--package/mtd/src/imagetag.c316
-rw-r--r--package/mtd/src/jffs2.c357
-rw-r--r--package/mtd/src/jffs2.h216
-rw-r--r--package/mtd/src/md5.c307
-rw-r--r--package/mtd/src/md5.h65
-rw-r--r--package/mtd/src/mtd.c761
-rw-r--r--package/mtd/src/mtd.h29
-rw-r--r--package/mtd/src/seama.c179
-rw-r--r--package/mtd/src/seama.h108
-rw-r--r--package/mtd/src/trx.c220
-rw-r--r--package/network/.svn/entries40
-rw-r--r--package/network/config/.svn/entries49
-rw-r--r--package/network/config/firewall/.svn/entries65
-rw-r--r--package/network/config/firewall/.svn/text-base/Makefile.svn-base58
-rw-r--r--package/network/config/firewall/Makefile58
-rw-r--r--package/network/config/firewall/files/.svn/entries238
-rw-r--r--package/network/config/firewall/files/.svn/prop-base/firewall.config.svn-base5
-rw-r--r--package/network/config/firewall/files/.svn/prop-base/firewall.init.svn-base9
-rw-r--r--package/network/config/firewall/files/.svn/text-base/firewall.config.svn-base195
-rw-r--r--package/network/config/firewall/files/.svn/text-base/firewall.hotplug.svn-base22
-rw-r--r--package/network/config/firewall/files/.svn/text-base/firewall.init.svn-base27
-rw-r--r--package/network/config/firewall/files/.svn/text-base/firewall.upgrade.svn-base1
-rw-r--r--package/network/config/firewall/files/.svn/text-base/firewall.user.svn-base4
-rw-r--r--package/network/config/firewall/files/.svn/text-base/reflection.hotplug.svn-base169
-rw-r--r--package/network/config/firewall/files/bin/.svn/entries62
-rw-r--r--package/network/config/firewall/files/bin/.svn/text-base/fw.svn-base49
-rw-r--r--package/network/config/firewall/files/bin/fw49
-rw-r--r--package/network/config/firewall/files/firewall.config195
-rw-r--r--package/network/config/firewall/files/firewall.hotplug22
-rwxr-xr-xpackage/network/config/firewall/files/firewall.init27
-rw-r--r--package/network/config/firewall/files/firewall.upgrade1
-rw-r--r--package/network/config/firewall/files/firewall.user4
-rw-r--r--package/network/config/firewall/files/lib/.svn/entries334
-rw-r--r--package/network/config/firewall/files/lib/.svn/text-base/config.sh.svn-base101
-rw-r--r--package/network/config/firewall/files/lib/.svn/text-base/core.sh.svn-base159
-rw-r--r--package/network/config/firewall/files/lib/.svn/text-base/core_forwarding.sh.svn-base44
-rw-r--r--package/network/config/firewall/files/lib/.svn/text-base/core_init.sh.svn-base361
-rw-r--r--package/network/config/firewall/files/lib/.svn/text-base/core_interface.sh.svn-base214
-rw-r--r--package/network/config/firewall/files/lib/.svn/text-base/core_redirect.sh.svn-base130
-rw-r--r--package/network/config/firewall/files/lib/.svn/text-base/core_rule.sh.svn-base117
-rw-r--r--package/network/config/firewall/files/lib/.svn/text-base/fw.sh.svn-base324
-rw-r--r--package/network/config/firewall/files/lib/.svn/text-base/uci_firewall.sh.svn-base5
-rw-r--r--package/network/config/firewall/files/lib/config.sh101
-rw-r--r--package/network/config/firewall/files/lib/core.sh159
-rw-r--r--package/network/config/firewall/files/lib/core_forwarding.sh44
-rw-r--r--package/network/config/firewall/files/lib/core_init.sh361
-rw-r--r--package/network/config/firewall/files/lib/core_interface.sh214
-rw-r--r--package/network/config/firewall/files/lib/core_redirect.sh130
-rw-r--r--package/network/config/firewall/files/lib/core_rule.sh117
-rw-r--r--package/network/config/firewall/files/lib/fw.sh324
-rw-r--r--package/network/config/firewall/files/lib/uci_firewall.sh5
-rw-r--r--package/network/config/firewall/files/reflection.hotplug169
-rw-r--r--package/network/config/firewall3/.svn/entries65
-rw-r--r--package/network/config/firewall3/.svn/text-base/Makefile.svn-base54
-rw-r--r--package/network/config/firewall3/Makefile54
-rw-r--r--package/network/config/firewall3/files/.svn/entries164
-rw-r--r--package/network/config/firewall3/files/.svn/prop-base/firewall.config.svn-base5
-rw-r--r--package/network/config/firewall3/files/.svn/prop-base/firewall.init.svn-base5
-rw-r--r--package/network/config/firewall3/files/.svn/text-base/firewall.config.svn-base195
-rw-r--r--package/network/config/firewall3/files/.svn/text-base/firewall.hotplug.svn-base10
-rw-r--r--package/network/config/firewall3/files/.svn/text-base/firewall.init.svn-base25
-rw-r--r--package/network/config/firewall3/files/.svn/text-base/firewall.user.svn-base7
-rw-r--r--package/network/config/firewall3/files/firewall.config195
-rw-r--r--package/network/config/firewall3/files/firewall.hotplug10
-rwxr-xr-xpackage/network/config/firewall3/files/firewall.init25
-rw-r--r--package/network/config/firewall3/files/firewall.user7
-rw-r--r--package/network/config/ltq-dsl-app/.svn/entries31
-rw-r--r--package/network/config/ltq-dsl-app/patches/.svn/entries62
-rw-r--r--package/network/config/ltq-dsl-app/patches/.svn/text-base/010-eglibc_compile_fix.patch.svn-base23
-rw-r--r--package/network/config/ltq-dsl-app/patches/010-eglibc_compile_fix.patch23
-rw-r--r--package/network/config/netifd/.svn/entries68
-rw-r--r--package/network/config/netifd/.svn/text-base/Makefile.svn-base46
-rw-r--r--package/network/config/netifd/Makefile46
-rw-r--r--package/network/config/netifd/files/.svn/entries40
-rw-r--r--package/network/config/netifd/files/etc/.svn/entries34
-rw-r--r--package/network/config/netifd/files/etc/hotplug.d/.svn/entries31
-rw-r--r--package/network/config/netifd/files/etc/hotplug.d/iface/.svn/entries96
-rw-r--r--package/network/config/netifd/files/etc/hotplug.d/iface/.svn/text-base/00-netstate.svn-base8
-rw-r--r--package/network/config/netifd/files/etc/hotplug.d/iface/.svn/text-base/10-ipv6-static.svn-base19
-rw-r--r--package/network/config/netifd/files/etc/hotplug.d/iface/00-netstate8
-rw-r--r--package/network/config/netifd/files/etc/hotplug.d/iface/10-ipv6-static19
-rw-r--r--package/network/config/netifd/files/etc/init.d/.svn/entries62
-rw-r--r--package/network/config/netifd/files/etc/init.d/.svn/prop-base/network.svn-base5
-rw-r--r--package/network/config/netifd/files/etc/init.d/.svn/text-base/network.svn-base47
-rwxr-xr-xpackage/network/config/netifd/files/etc/init.d/network47
-rw-r--r--package/network/config/netifd/files/lib/.svn/entries34
-rw-r--r--package/network/config/netifd/files/lib/netifd/.svn/entries65
-rw-r--r--package/network/config/netifd/files/lib/netifd/.svn/prop-base/dhcp.script.svn-base5
-rw-r--r--package/network/config/netifd/files/lib/netifd/.svn/text-base/dhcp.script.svn-base62
-rwxr-xr-xpackage/network/config/netifd/files/lib/netifd/dhcp.script62
-rw-r--r--package/network/config/netifd/files/lib/netifd/proto/.svn/entries62
-rw-r--r--package/network/config/netifd/files/lib/netifd/proto/.svn/prop-base/dhcp.sh.svn-base5
-rw-r--r--package/network/config/netifd/files/lib/netifd/proto/.svn/text-base/dhcp.sh.svn-base49
-rwxr-xr-xpackage/network/config/netifd/files/lib/netifd/proto/dhcp.sh49
-rw-r--r--package/network/config/netifd/files/lib/network/.svn/entries62
-rw-r--r--package/network/config/netifd/files/lib/network/.svn/prop-base/config.sh.svn-base5
-rw-r--r--package/network/config/netifd/files/lib/network/.svn/text-base/config.sh.svn-base79
-rwxr-xr-xpackage/network/config/netifd/files/lib/network/config.sh79
-rw-r--r--package/network/config/netifd/files/sbin/.svn/entries164
-rw-r--r--package/network/config/netifd/files/sbin/.svn/prop-base/devstatus.svn-base5
-rw-r--r--package/network/config/netifd/files/sbin/.svn/prop-base/ifdown.svn-base5
-rw-r--r--package/network/config/netifd/files/sbin/.svn/prop-base/ifstatus.svn-base5
-rw-r--r--package/network/config/netifd/files/sbin/.svn/prop-base/ifup.svn-base5
-rw-r--r--package/network/config/netifd/files/sbin/.svn/text-base/devstatus.svn-base12
-rw-r--r--package/network/config/netifd/files/sbin/.svn/text-base/ifdown.svn-base1
-rw-r--r--package/network/config/netifd/files/sbin/.svn/text-base/ifstatus.svn-base13
-rw-r--r--package/network/config/netifd/files/sbin/.svn/text-base/ifup.svn-base79
-rwxr-xr-xpackage/network/config/netifd/files/sbin/devstatus12
l---------package/network/config/netifd/files/sbin/ifdown1
-rwxr-xr-xpackage/network/config/netifd/files/sbin/ifstatus13
-rwxr-xr-xpackage/network/config/netifd/files/sbin/ifup79
-rw-r--r--package/network/config/netifd/files/usr/.svn/entries31
-rw-r--r--package/network/config/netifd/files/usr/share/.svn/entries31
-rw-r--r--package/network/config/netifd/files/usr/share/udhcpc/.svn/entries62
-rw-r--r--package/network/config/netifd/files/usr/share/udhcpc/.svn/prop-base/default.script.svn-base5
-rw-r--r--package/network/config/netifd/files/usr/share/udhcpc/.svn/text-base/default.script.svn-base57
-rwxr-xr-xpackage/network/config/netifd/files/usr/share/udhcpc/default.script57
-rw-r--r--package/network/config/netifd/patches/.svn/entries62
-rw-r--r--package/network/config/netifd/patches/.svn/text-base/001-musl_af_inet_include.patch.svn-base11
-rw-r--r--package/network/config/netifd/patches/001-musl_af_inet_include.patch11
-rw-r--r--package/network/config/qos-scripts/.svn/entries65
-rw-r--r--package/network/config/qos-scripts/.svn/prop-base/Makefile.svn-base9
-rw-r--r--package/network/config/qos-scripts/.svn/text-base/Makefile.svn-base52
-rw-r--r--package/network/config/qos-scripts/Makefile52
-rw-r--r--package/network/config/qos-scripts/files/.svn/entries34
-rw-r--r--package/network/config/qos-scripts/files/etc/.svn/entries37
-rw-r--r--package/network/config/qos-scripts/files/etc/config/.svn/entries62
-rw-r--r--package/network/config/qos-scripts/files/etc/config/.svn/prop-base/qos.svn-base5
-rw-r--r--package/network/config/qos-scripts/files/etc/config/.svn/text-base/qos.svn-base79
-rw-r--r--package/network/config/qos-scripts/files/etc/config/qos79
-rw-r--r--package/network/config/qos-scripts/files/etc/hotplug.d/.svn/entries31
-rw-r--r--package/network/config/qos-scripts/files/etc/hotplug.d/iface/.svn/entries62
-rw-r--r--package/network/config/qos-scripts/files/etc/hotplug.d/iface/.svn/prop-base/10-qos.svn-base9
-rw-r--r--package/network/config/qos-scripts/files/etc/hotplug.d/iface/.svn/text-base/10-qos.svn-base2
-rwxr-xr-xpackage/network/config/qos-scripts/files/etc/hotplug.d/iface/10-qos2
-rw-r--r--package/network/config/qos-scripts/files/etc/init.d/.svn/entries62
-rw-r--r--package/network/config/qos-scripts/files/etc/init.d/.svn/prop-base/qos.svn-base9
-rw-r--r--package/network/config/qos-scripts/files/etc/init.d/.svn/text-base/qos.svn-base16
-rwxr-xr-xpackage/network/config/qos-scripts/files/etc/init.d/qos16
-rw-r--r--package/network/config/qos-scripts/files/usr/.svn/entries34
-rw-r--r--package/network/config/qos-scripts/files/usr/bin/.svn/entries130
-rw-r--r--package/network/config/qos-scripts/files/usr/bin/.svn/prop-base/qos-start.svn-base9
-rw-r--r--package/network/config/qos-scripts/files/usr/bin/.svn/prop-base/qos-stat.svn-base9
-rw-r--r--package/network/config/qos-scripts/files/usr/bin/.svn/prop-base/qos-stop.svn-base9
-rw-r--r--package/network/config/qos-scripts/files/usr/bin/.svn/text-base/qos-start.svn-base4
-rw-r--r--package/network/config/qos-scripts/files/usr/bin/.svn/text-base/qos-stat.svn-base67
-rw-r--r--package/network/config/qos-scripts/files/usr/bin/.svn/text-base/qos-stop.svn-base6
-rwxr-xr-xpackage/network/config/qos-scripts/files/usr/bin/qos-start4
-rwxr-xr-xpackage/network/config/qos-scripts/files/usr/bin/qos-stat67
-rwxr-xr-xpackage/network/config/qos-scripts/files/usr/bin/qos-stop6
-rw-r--r--package/network/config/qos-scripts/files/usr/lib/.svn/entries31
-rw-r--r--package/network/config/qos-scripts/files/usr/lib/qos/.svn/entries96
-rw-r--r--package/network/config/qos-scripts/files/usr/lib/qos/.svn/prop-base/generate.sh.svn-base9
-rw-r--r--package/network/config/qos-scripts/files/usr/lib/qos/.svn/text-base/generate.sh.svn-base497
-rw-r--r--package/network/config/qos-scripts/files/usr/lib/qos/.svn/text-base/tcrules.awk.svn-base95
-rwxr-xr-xpackage/network/config/qos-scripts/files/usr/lib/qos/generate.sh497
-rw-r--r--package/network/config/qos-scripts/files/usr/lib/qos/tcrules.awk95
-rw-r--r--package/network/config/soloscli/.svn/entries68
-rw-r--r--package/network/config/soloscli/.svn/text-base/Makefile.svn-base45
-rw-r--r--package/network/config/soloscli/Makefile45
-rw-r--r--package/network/config/soloscli/files/.svn/entries65
-rw-r--r--package/network/config/soloscli/files/.svn/text-base/solos-log-stats.svn-base19
-rw-r--r--package/network/config/soloscli/files/etc/.svn/entries34
-rw-r--r--package/network/config/soloscli/files/etc/hotplug.d/.svn/entries31
-rw-r--r--package/network/config/soloscli/files/etc/hotplug.d/atm/.svn/entries62
-rw-r--r--package/network/config/soloscli/files/etc/hotplug.d/atm/.svn/text-base/15-solos-init.svn-base26
-rw-r--r--package/network/config/soloscli/files/etc/hotplug.d/atm/15-solos-init26
-rw-r--r--package/network/config/soloscli/files/etc/uci-default/.svn/entries62
-rw-r--r--package/network/config/soloscli/files/etc/uci-default/.svn/text-base/solos.svn-base15
-rw-r--r--package/network/config/soloscli/files/etc/uci-default/solos15
-rw-r--r--package/network/config/soloscli/files/solos-log-stats19
-rw-r--r--package/network/config/soloscli/patches/.svn/entries96
-rw-r--r--package/network/config/soloscli/patches/.svn/text-base/000-Makefile.patch.svn-base21
-rw-r--r--package/network/config/soloscli/patches/.svn/text-base/001-newline.patch.svn-base15
-rw-r--r--package/network/config/soloscli/patches/000-Makefile.patch21
-rw-r--r--package/network/config/soloscli/patches/001-newline.patch15
-rw-r--r--package/network/config/swconfig/.svn/entries68
-rw-r--r--package/network/config/swconfig/.svn/text-base/Makefile.svn-base49
-rw-r--r--package/network/config/swconfig/Makefile49
-rw-r--r--package/network/config/swconfig/files/.svn/entries62
-rw-r--r--package/network/config/swconfig/files/.svn/text-base/switch.sh.svn-base14
-rw-r--r--package/network/config/swconfig/files/switch.sh14
-rw-r--r--package/network/config/swconfig/src/.svn/entries198
-rw-r--r--package/network/config/swconfig/src/.svn/text-base/Makefile.svn-base12
-rw-r--r--package/network/config/swconfig/src/.svn/text-base/cli.c.svn-base340
-rw-r--r--package/network/config/swconfig/src/.svn/text-base/swlib.c.svn-base686
-rw-r--r--package/network/config/swconfig/src/.svn/text-base/swlib.h.svn-base234
-rw-r--r--package/network/config/swconfig/src/.svn/text-base/uci.c.svn-base248
-rw-r--r--package/network/config/swconfig/src/Makefile12
-rw-r--r--package/network/config/swconfig/src/cli.c340
-rw-r--r--package/network/config/swconfig/src/swlib.c686
-rw-r--r--package/network/config/swconfig/src/swlib.h234
-rw-r--r--package/network/config/swconfig/src/uci.c248
-rw-r--r--package/network/ipv6/.svn/entries49
-rw-r--r--package/network/ipv6/6in4/.svn/entries65
-rw-r--r--package/network/ipv6/6in4/.svn/text-base/Makefile.svn-base42
-rw-r--r--package/network/ipv6/6in4/Makefile42
-rw-r--r--package/network/ipv6/6in4/files/.svn/entries62
-rw-r--r--package/network/ipv6/6in4/files/.svn/prop-base/6in4.sh.svn-base5
-rw-r--r--package/network/ipv6/6in4/files/.svn/text-base/6in4.sh.svn-base97
-rwxr-xr-xpackage/network/ipv6/6in4/files/6in4.sh97
-rw-r--r--package/network/ipv6/6rd/.svn/entries68
-rw-r--r--package/network/ipv6/6rd/.svn/text-base/Makefile.svn-base53
-rw-r--r--package/network/ipv6/6rd/Makefile53
-rw-r--r--package/network/ipv6/6rd/files/.svn/entries62
-rw-r--r--package/network/ipv6/6rd/files/.svn/text-base/6rd.sh.svn-base84
-rw-r--r--package/network/ipv6/6rd/files/6rd.sh84
-rw-r--r--package/network/ipv6/6rd/src/.svn/entries96
-rw-r--r--package/network/ipv6/6rd/src/.svn/text-base/6rdcalc.c.svn-base126
-rw-r--r--package/network/ipv6/6rd/src/.svn/text-base/Makefile.svn-base7
-rw-r--r--package/network/ipv6/6rd/src/6rdcalc.c126
-rw-r--r--package/network/ipv6/6rd/src/Makefile7
-rw-r--r--package/network/ipv6/6relayd/.svn/entries65
-rw-r--r--package/network/ipv6/6relayd/.svn/text-base/Makefile.svn-base57
-rw-r--r--package/network/ipv6/6relayd/Makefile57
-rw-r--r--package/network/ipv6/6relayd/files/.svn/entries130
-rw-r--r--package/network/ipv6/6relayd/files/.svn/text-base/6relayd.config.svn-base28
-rw-r--r--package/network/ipv6/6relayd/files/.svn/text-base/6relayd.hotplug.svn-base6
-rw-r--r--package/network/ipv6/6relayd/files/.svn/text-base/6relayd.init.svn-base135
-rw-r--r--package/network/ipv6/6relayd/files/6relayd.config28
-rw-r--r--package/network/ipv6/6relayd/files/6relayd.hotplug6
-rw-r--r--package/network/ipv6/6relayd/files/6relayd.init135
-rw-r--r--package/network/ipv6/6to4/.svn/entries65
-rw-r--r--package/network/ipv6/6to4/.svn/text-base/Makefile.svn-base42
-rw-r--r--package/network/ipv6/6to4/Makefile42
-rw-r--r--package/network/ipv6/6to4/files/.svn/entries62
-rw-r--r--package/network/ipv6/6to4/files/.svn/prop-base/6to4.sh.svn-base5
-rw-r--r--package/network/ipv6/6to4/files/.svn/text-base/6to4.sh.svn-base94
-rwxr-xr-xpackage/network/ipv6/6to4/files/6to4.sh94
-rw-r--r--package/network/ipv6/ipv6-support/.svn/entries65
-rw-r--r--package/network/ipv6/ipv6-support/.svn/text-base/Makefile.svn-base41
-rw-r--r--package/network/ipv6/ipv6-support/Makefile41
-rw-r--r--package/network/ipv6/ipv6-support/files/.svn/entries62
-rw-r--r--package/network/ipv6/ipv6-support/files/.svn/text-base/network-enable-ipv6.defaults.svn-base14
-rw-r--r--package/network/ipv6/ipv6-support/files/network-enable-ipv6.defaults14
-rw-r--r--package/network/ipv6/odhcp6c/.svn/entries65
-rw-r--r--package/network/ipv6/odhcp6c/.svn/text-base/Makefile.svn-base39
-rw-r--r--package/network/ipv6/odhcp6c/Makefile39
-rw-r--r--package/network/ipv6/odhcp6c/files/.svn/entries96
-rw-r--r--package/network/ipv6/odhcp6c/files/.svn/prop-base/dhcpv6.script.svn-base5
-rw-r--r--package/network/ipv6/odhcp6c/files/.svn/prop-base/dhcpv6.sh.svn-base5
-rw-r--r--package/network/ipv6/odhcp6c/files/.svn/text-base/dhcpv6.script.svn-base92
-rw-r--r--package/network/ipv6/odhcp6c/files/.svn/text-base/dhcpv6.sh.svn-base56
-rwxr-xr-xpackage/network/ipv6/odhcp6c/files/dhcpv6.script92
-rwxr-xr-xpackage/network/ipv6/odhcp6c/files/dhcpv6.sh56
-rw-r--r--package/network/ipv6/thc-ipv6/.svn/entries65
-rw-r--r--package/network/ipv6/thc-ipv6/.svn/text-base/Makefile.svn-base59
-rw-r--r--package/network/ipv6/thc-ipv6/Makefile59
-rw-r--r--package/network/ipv6/thc-ipv6/patches/.svn/entries62
-rw-r--r--package/network/ipv6/thc-ipv6/patches/.svn/text-base/100-no-ssl.patch.svn-base11
-rw-r--r--package/network/ipv6/thc-ipv6/patches/100-no-ssl.patch11
-rw-r--r--package/network/services/.svn/entries61
-rw-r--r--package/network/services/dnsmasq/.svn/entries68
-rw-r--r--package/network/services/dnsmasq/.svn/prop-base/Makefile.svn-base9
-rw-r--r--package/network/services/dnsmasq/.svn/text-base/Makefile.svn-base91
-rw-r--r--package/network/services/dnsmasq/Makefile91
-rw-r--r--package/network/services/dnsmasq/files/.svn/entries130
-rw-r--r--package/network/services/dnsmasq/files/.svn/prop-base/dnsmasq.init.svn-base5
-rw-r--r--package/network/services/dnsmasq/files/.svn/text-base/dhcp.conf.svn-base31
-rw-r--r--package/network/services/dnsmasq/files/.svn/text-base/dnsmasq.conf.svn-base37
-rw-r--r--package/network/services/dnsmasq/files/.svn/text-base/dnsmasq.init.svn-base534
-rw-r--r--package/network/services/dnsmasq/files/dhcp.conf31
-rw-r--r--package/network/services/dnsmasq/files/dnsmasq.conf37
-rw-r--r--package/network/services/dnsmasq/files/dnsmasq.init534
-rw-r--r--package/network/services/dnsmasq/patches/.svn/entries96
-rw-r--r--package/network/services/dnsmasq/patches/.svn/text-base/0001-Set-prefix-on-link-bit-in-RAs.patch.svn-base42
-rw-r--r--package/network/services/dnsmasq/patches/.svn/text-base/100-fix-dhcp-no-address-warning.patch.svn-base49
-rw-r--r--package/network/services/dnsmasq/patches/0001-Set-prefix-on-link-bit-in-RAs.patch42
-rw-r--r--package/network/services/dnsmasq/patches/100-fix-dhcp-no-address-warning.patch49
-rw-r--r--package/network/services/dropbear/.svn/entries68
-rw-r--r--package/network/services/dropbear/.svn/prop-base/Makefile.svn-base9
-rw-r--r--package/network/services/dropbear/.svn/text-base/Makefile.svn-base109
-rw-r--r--package/network/services/dropbear/Makefile109
-rw-r--r--package/network/services/dropbear/files/.svn/entries96
-rw-r--r--package/network/services/dropbear/files/.svn/prop-base/dropbear.config.svn-base5
-rw-r--r--package/network/services/dropbear/files/.svn/prop-base/dropbear.init.svn-base9
-rw-r--r--package/network/services/dropbear/files/.svn/text-base/dropbear.config.svn-base5
-rw-r--r--package/network/services/dropbear/files/.svn/text-base/dropbear.init.svn-base176
-rw-r--r--package/network/services/dropbear/files/dropbear.config5
-rwxr-xr-xpackage/network/services/dropbear/files/dropbear.init176
-rw-r--r--package/network/services/dropbear/patches/.svn/entries334
-rw-r--r--package/network/services/dropbear/patches/.svn/prop-base/100-pubkey_path.patch.svn-base5
-rw-r--r--package/network/services/dropbear/patches/.svn/prop-base/110-change_user.patch.svn-base5
-rw-r--r--package/network/services/dropbear/patches/.svn/prop-base/130-ssh_ignore_o_and_x_args.patch.svn-base5
-rw-r--r--package/network/services/dropbear/patches/.svn/prop-base/150-dbconvert_standalone.patch.svn-base5
-rw-r--r--package/network/services/dropbear/patches/.svn/text-base/100-pubkey_path.patch.svn-base91
-rw-r--r--package/network/services/dropbear/patches/.svn/text-base/110-change_user.patch.svn-base18
-rw-r--r--package/network/services/dropbear/patches/.svn/text-base/120-openwrt_options.patch.svn-base72
-rw-r--r--package/network/services/dropbear/patches/.svn/text-base/130-ssh_ignore_o_and_x_args.patch.svn-base21
-rw-r--r--package/network/services/dropbear/patches/.svn/text-base/140-disable_assert.patch.svn-base14
-rw-r--r--package/network/services/dropbear/patches/.svn/text-base/150-dbconvert_standalone.patch.svn-base14
-rw-r--r--package/network/services/dropbear/patches/.svn/text-base/200-lcrypt_bsdfix.patch.svn-base29
-rw-r--r--package/network/services/dropbear/patches/.svn/text-base/300-ipv6_addr_port_split.patch.svn-base11
-rw-r--r--package/network/services/dropbear/patches/.svn/text-base/500-set-default-path.patch.svn-base11
-rw-r--r--package/network/services/dropbear/patches/100-pubkey_path.patch91
-rw-r--r--package/network/services/dropbear/patches/110-change_user.patch18
-rw-r--r--package/network/services/dropbear/patches/120-openwrt_options.patch72
-rw-r--r--package/network/services/dropbear/patches/130-ssh_ignore_o_and_x_args.patch21
-rw-r--r--package/network/services/dropbear/patches/140-disable_assert.patch14
-rw-r--r--package/network/services/dropbear/patches/150-dbconvert_standalone.patch14
-rw-r--r--package/network/services/dropbear/patches/200-lcrypt_bsdfix.patch29
-rw-r--r--package/network/services/dropbear/patches/300-ipv6_addr_port_split.patch11
-rw-r--r--package/network/services/dropbear/patches/500-set-default-path.patch11
-rw-r--r--package/network/services/ead/.svn/entries65
-rw-r--r--package/network/services/ead/.svn/text-base/Makefile.svn-base57
-rw-r--r--package/network/services/ead/Makefile57
-rw-r--r--package/network/services/ead/src/.svn/entries609
-rw-r--r--package/network/services/ead/src/.svn/text-base/Makefile.svn-base33
-rw-r--r--package/network/services/ead/src/.svn/text-base/aes.c.svn-base1061
-rw-r--r--package/network/services/ead/src/.svn/text-base/ead-client.c.svn-base433
-rw-r--r--package/network/services/ead/src/.svn/text-base/ead-crypt.c.svn-base179
-rw-r--r--package/network/services/ead/src/.svn/text-base/ead-crypt.h.svn-base21
-rw-r--r--package/network/services/ead/src/.svn/text-base/ead-pcap.h.svn-base71
-rw-r--r--package/network/services/ead/src/.svn/text-base/ead.c.svn-base991
-rw-r--r--package/network/services/ead/src/.svn/text-base/ead.h.svn-base139
-rw-r--r--package/network/services/ead/src/.svn/text-base/filter.c.svn-base25
-rw-r--r--package/network/services/ead/src/.svn/text-base/libbridge.h.svn-base84
-rw-r--r--package/network/services/ead/src/.svn/text-base/libbridge_init.c.svn-base208
-rw-r--r--package/network/services/ead/src/.svn/text-base/libbridge_private.h.svn-base35
-rw-r--r--package/network/services/ead/src/.svn/text-base/list.h.svn-base602
-rw-r--r--package/network/services/ead/src/.svn/text-base/passwd.svn-base3
-rw-r--r--package/network/services/ead/src/.svn/text-base/pfc.c.svn-base54
-rw-r--r--package/network/services/ead/src/.svn/text-base/pw_encrypt_md5.c.svn-base646
-rw-r--r--package/network/services/ead/src/.svn/text-base/sha1.c.svn-base104
-rw-r--r--package/network/services/ead/src/Makefile33
-rw-r--r--package/network/services/ead/src/aes.c1061
-rw-r--r--package/network/services/ead/src/ead-client.c433
-rw-r--r--package/network/services/ead/src/ead-crypt.c179
-rw-r--r--package/network/services/ead/src/ead-crypt.h21
-rw-r--r--package/network/services/ead/src/ead-pcap.h71
-rw-r--r--package/network/services/ead/src/ead.c991
-rw-r--r--package/network/services/ead/src/ead.h139
-rw-r--r--package/network/services/ead/src/filter.c25
-rw-r--r--package/network/services/ead/src/libbridge.h84
-rw-r--r--package/network/services/ead/src/libbridge_init.c208
-rw-r--r--package/network/services/ead/src/libbridge_private.h35
-rw-r--r--package/network/services/ead/src/list.h602
-rw-r--r--package/network/services/ead/src/passwd3
-rw-r--r--package/network/services/ead/src/pfc.c54
-rw-r--r--package/network/services/ead/src/pw_encrypt_md5.c646
-rw-r--r--package/network/services/ead/src/sha1.c104
-rw-r--r--package/network/services/ead/src/tinysrp/.svn/entries1762
-rw-r--r--package/network/services/ead/src/tinysrp/.svn/prop-base/configure.svn-base5
-rw-r--r--package/network/services/ead/src/tinysrp/.svn/prop-base/install-sh.svn-base5
-rw-r--r--package/network/services/ead/src/tinysrp/.svn/prop-base/missing.svn-base5
-rw-r--r--package/network/services/ead/src/tinysrp/.svn/prop-base/mkinstalldirs.svn-base5
-rw-r--r--package/network/services/ead/src/tinysrp/.svn/text-base/Makefile.am.svn-base28
-rw-r--r--package/network/services/ead/src/tinysrp/.svn/text-base/Makefile.in.svn-base477
-rw-r--r--package/network/services/ead/src/tinysrp/.svn/text-base/Notes.svn-base110
-rw-r--r--package/network/services/ead/src/tinysrp/.svn/text-base/acconfig.h.svn-base9
-rw-r--r--package/network/services/ead/src/tinysrp/.svn/text-base/acinclude.m4.svn-base27
-rw-r--r--package/network/services/ead/src/tinysrp/.svn/text-base/aclocal.m4.svn-base157
-rw-r--r--package/network/services/ead/src/tinysrp/.svn/text-base/bn.h.svn-base471
-rw-r--r--package/network/services/ead/src/tinysrp/.svn/text-base/bn_add.c.svn-base305
-rw-r--r--package/network/services/ead/src/tinysrp/.svn/text-base/bn_asm.c.svn-base382
-rw-r--r--package/network/services/ead/src/tinysrp/.svn/text-base/bn_ctx.c.svn-base142
-rw-r--r--package/network/services/ead/src/tinysrp/.svn/text-base/bn_div.c.svn-base378
-rw-r--r--package/network/services/ead/src/tinysrp/.svn/text-base/bn_exp.c.svn-base395
-rw-r--r--package/network/services/ead/src/tinysrp/.svn/text-base/bn_lcl.h.svn-base419
-rw-r--r--package/network/services/ead/src/tinysrp/.svn/text-base/bn_lib.c.svn-base576
-rw-r--r--package/network/services/ead/src/tinysrp/.svn/text-base/bn_mul.c.svn-base176
-rw-r--r--package/network/services/ead/src/tinysrp/.svn/text-base/bn_prime.h.svn-base325
-rw-r--r--package/network/services/ead/src/tinysrp/.svn/text-base/bn_shift.c.svn-base139
-rw-r--r--package/network/services/ead/src/tinysrp/.svn/text-base/bn_sqr.c.svn-base160
-rw-r--r--package/network/services/ead/src/tinysrp/.svn/text-base/bn_word.c.svn-base130
-rw-r--r--package/network/services/ead/src/tinysrp/.svn/text-base/clitest.c.svn-base112
-rw-r--r--package/network/services/ead/src/tinysrp/.svn/text-base/config.h.in.svn-base79
-rw-r--r--package/network/services/ead/src/tinysrp/.svn/text-base/configure.in.svn-base52
-rw-r--r--package/network/services/ead/src/tinysrp/.svn/text-base/configure.svn-base2421
-rw-r--r--package/network/services/ead/src/tinysrp/.svn/text-base/install-sh.svn-base250
-rw-r--r--package/network/services/ead/src/tinysrp/.svn/text-base/missing.svn-base134
-rw-r--r--package/network/services/ead/src/tinysrp/.svn/text-base/mkinstalldirs.svn-base39
-rw-r--r--package/network/services/ead/src/tinysrp/.svn/text-base/srvtest.c.svn-base111
-rw-r--r--package/network/services/ead/src/tinysrp/.svn/text-base/stamp-h.in.svn-base1
-rw-r--r--package/network/services/ead/src/tinysrp/.svn/text-base/t_client.c.svn-base287
-rw-r--r--package/network/services/ead/src/tinysrp/.svn/text-base/t_client.h.svn-base148
-rw-r--r--package/network/services/ead/src/tinysrp/.svn/text-base/t_conf.c.svn-base1080
-rw-r--r--package/network/services/ead/src/tinysrp/.svn/text-base/t_conv.c.svn-base226
-rw-r--r--package/network/services/ead/src/tinysrp/.svn/text-base/t_defines.h.svn-base169
-rw-r--r--package/network/services/ead/src/tinysrp/.svn/text-base/t_getconf.c.svn-base118
-rw-r--r--package/network/services/ead/src/tinysrp/.svn/text-base/t_getpass.c.svn-base191
-rw-r--r--package/network/services/ead/src/tinysrp/.svn/text-base/t_math.c.svn-base177
-rw-r--r--package/network/services/ead/src/tinysrp/.svn/text-base/t_misc.c.svn-base338
-rw-r--r--package/network/services/ead/src/tinysrp/.svn/text-base/t_pw.c.svn-base262
-rw-r--r--package/network/services/ead/src/tinysrp/.svn/text-base/t_pwd.h.svn-base310
-rw-r--r--package/network/services/ead/src/tinysrp/.svn/text-base/t_read.c.svn-base81
-rw-r--r--package/network/services/ead/src/tinysrp/.svn/text-base/t_read.h.svn-base55
-rw-r--r--package/network/services/ead/src/tinysrp/.svn/text-base/t_server.c.svn-base259
-rw-r--r--package/network/services/ead/src/tinysrp/.svn/text-base/t_server.h.svn-base138
-rw-r--r--package/network/services/ead/src/tinysrp/.svn/text-base/t_sha.c.svn-base166
-rw-r--r--package/network/services/ead/src/tinysrp/.svn/text-base/t_sha.h.svn-base26
-rw-r--r--package/network/services/ead/src/tinysrp/.svn/text-base/t_truerand.c.svn-base151
-rw-r--r--package/network/services/ead/src/tinysrp/.svn/text-base/tconf.c.svn-base157
-rw-r--r--package/network/services/ead/src/tinysrp/.svn/text-base/tinysrp.c.svn-base235
-rw-r--r--package/network/services/ead/src/tinysrp/.svn/text-base/tinysrp.h.svn-base18
-rw-r--r--package/network/services/ead/src/tinysrp/.svn/text-base/tpasswd.svn-base2
-rw-r--r--package/network/services/ead/src/tinysrp/.svn/text-base/tphrase.c.svn-base348
-rw-r--r--package/network/services/ead/src/tinysrp/Makefile.am28
-rw-r--r--package/network/services/ead/src/tinysrp/Makefile.in477
-rw-r--r--package/network/services/ead/src/tinysrp/Notes110
-rw-r--r--package/network/services/ead/src/tinysrp/acconfig.h9
-rw-r--r--package/network/services/ead/src/tinysrp/acinclude.m427
-rw-r--r--package/network/services/ead/src/tinysrp/aclocal.m4157
-rw-r--r--package/network/services/ead/src/tinysrp/bn.h471
-rw-r--r--package/network/services/ead/src/tinysrp/bn_add.c305
-rw-r--r--package/network/services/ead/src/tinysrp/bn_asm.c382
-rw-r--r--package/network/services/ead/src/tinysrp/bn_ctx.c142
-rw-r--r--package/network/services/ead/src/tinysrp/bn_div.c378
-rw-r--r--package/network/services/ead/src/tinysrp/bn_exp.c395
-rw-r--r--package/network/services/ead/src/tinysrp/bn_lcl.h419
-rw-r--r--package/network/services/ead/src/tinysrp/bn_lib.c576
-rw-r--r--package/network/services/ead/src/tinysrp/bn_mul.c176
-rw-r--r--package/network/services/ead/src/tinysrp/bn_prime.h325
-rw-r--r--package/network/services/ead/src/tinysrp/bn_shift.c139
-rw-r--r--package/network/services/ead/src/tinysrp/bn_sqr.c160
-rw-r--r--package/network/services/ead/src/tinysrp/bn_word.c130
-rw-r--r--package/network/services/ead/src/tinysrp/clitest.c112
-rw-r--r--package/network/services/ead/src/tinysrp/config.h.in79
-rwxr-xr-xpackage/network/services/ead/src/tinysrp/configure2421
-rw-r--r--package/network/services/ead/src/tinysrp/configure.in52
-rwxr-xr-xpackage/network/services/ead/src/tinysrp/install-sh250
-rwxr-xr-xpackage/network/services/ead/src/tinysrp/missing134
-rwxr-xr-xpackage/network/services/ead/src/tinysrp/mkinstalldirs39
-rw-r--r--package/network/services/ead/src/tinysrp/srvtest.c111
-rw-r--r--package/network/services/ead/src/tinysrp/stamp-h.in1
-rw-r--r--package/network/services/ead/src/tinysrp/t_client.c287
-rw-r--r--package/network/services/ead/src/tinysrp/t_client.h148
-rw-r--r--package/network/services/ead/src/tinysrp/t_conf.c1080
-rw-r--r--package/network/services/ead/src/tinysrp/t_conv.c226
-rw-r--r--package/network/services/ead/src/tinysrp/t_defines.h169
-rw-r--r--package/network/services/ead/src/tinysrp/t_getconf.c118
-rw-r--r--package/network/services/ead/src/tinysrp/t_getpass.c191
-rw-r--r--package/network/services/ead/src/tinysrp/t_math.c177
-rw-r--r--package/network/services/ead/src/tinysrp/t_misc.c338
-rw-r--r--package/network/services/ead/src/tinysrp/t_pw.c262
-rw-r--r--package/network/services/ead/src/tinysrp/t_pwd.h310
-rw-r--r--package/network/services/ead/src/tinysrp/t_read.c81
-rw-r--r--package/network/services/ead/src/tinysrp/t_read.h55
-rw-r--r--package/network/services/ead/src/tinysrp/t_server.c259
-rw-r--r--package/network/services/ead/src/tinysrp/t_server.h138
-rw-r--r--package/network/services/ead/src/tinysrp/t_sha.c166
-rw-r--r--package/network/services/ead/src/tinysrp/t_sha.h26
-rw-r--r--package/network/services/ead/src/tinysrp/t_truerand.c151
-rw-r--r--package/network/services/ead/src/tinysrp/tconf.c157
-rw-r--r--package/network/services/ead/src/tinysrp/tinysrp.c235
-rw-r--r--package/network/services/ead/src/tinysrp/tinysrp.h18
-rw-r--r--package/network/services/ead/src/tinysrp/tpasswd2
-rw-r--r--package/network/services/ead/src/tinysrp/tphrase.c348
-rw-r--r--package/network/services/hostapd/.svn/entries105
-rw-r--r--package/network/services/hostapd/.svn/prop-base/Makefile.svn-base9
-rw-r--r--package/network/services/hostapd/.svn/text-base/Config.in.svn-base47
-rw-r--r--package/network/services/hostapd/.svn/text-base/Makefile.svn-base343
-rw-r--r--package/network/services/hostapd/Config.in47
-rw-r--r--package/network/services/hostapd/Makefile343
-rw-r--r--package/network/services/hostapd/files/.svn/entries300
-rw-r--r--package/network/services/hostapd/files/.svn/prop-base/hostapd-full.config.svn-base5
-rw-r--r--package/network/services/hostapd/files/.svn/prop-base/hostapd-mini.config.svn-base5
-rw-r--r--package/network/services/hostapd/files/.svn/prop-base/hostapd.sh.svn-base5
-rw-r--r--package/network/services/hostapd/files/.svn/prop-base/wpa_supplicant-mini.config.svn-base5
-rw-r--r--package/network/services/hostapd/files/.svn/text-base/hostapd-full.config.svn-base164
-rw-r--r--package/network/services/hostapd/files/.svn/text-base/hostapd-mini.config.svn-base157
-rw-r--r--package/network/services/hostapd/files/.svn/text-base/hostapd.sh.svn-base301
-rw-r--r--package/network/services/hostapd/files/.svn/text-base/multicall.c.svn-base28
-rw-r--r--package/network/services/hostapd/files/.svn/text-base/wpa_supplicant-full.config.svn-base408
-rw-r--r--package/network/services/hostapd/files/.svn/text-base/wpa_supplicant-mini.config.svn-base406
-rw-r--r--package/network/services/hostapd/files/.svn/text-base/wpa_supplicant.sh.svn-base194
-rw-r--r--package/network/services/hostapd/files/.svn/text-base/wps-hotplug.sh.svn-base8
-rw-r--r--package/network/services/hostapd/files/hostapd-full.config164
-rw-r--r--package/network/services/hostapd/files/hostapd-mini.config157
-rw-r--r--package/network/services/hostapd/files/hostapd.sh301
-rw-r--r--package/network/services/hostapd/files/multicall.c28
-rw-r--r--package/network/services/hostapd/files/wpa_supplicant-full.config408
-rw-r--r--package/network/services/hostapd/files/wpa_supplicant-mini.config406
-rw-r--r--package/network/services/hostapd/files/wpa_supplicant.sh194
-rw-r--r--package/network/services/hostapd/files/wps-hotplug.sh8
-rw-r--r--package/network/services/hostapd/madwifi/.svn/entries34
-rw-r--r--package/network/services/hostapd/madwifi/include/.svn/entries62
-rw-r--r--package/network/services/hostapd/madwifi/include/.svn/text-base/compat.h.svn-base209
-rw-r--r--package/network/services/hostapd/madwifi/include/compat.h209
-rw-r--r--package/network/services/hostapd/madwifi/net80211/.svn/entries164
-rw-r--r--package/network/services/hostapd/madwifi/net80211/.svn/text-base/_ieee80211.h.svn-base325
-rw-r--r--package/network/services/hostapd/madwifi/net80211/.svn/text-base/ieee80211.h.svn-base997
-rw-r--r--package/network/services/hostapd/madwifi/net80211/.svn/text-base/ieee80211_crypto.h.svn-base207
-rw-r--r--package/network/services/hostapd/madwifi/net80211/.svn/text-base/ieee80211_ioctl.h.svn-base715
-rw-r--r--package/network/services/hostapd/madwifi/net80211/_ieee80211.h325
-rw-r--r--package/network/services/hostapd/madwifi/net80211/ieee80211.h997
-rw-r--r--package/network/services/hostapd/madwifi/net80211/ieee80211_crypto.h207
-rw-r--r--package/network/services/hostapd/madwifi/net80211/ieee80211_ioctl.h715
-rw-r--r--package/network/services/hostapd/patches/.svn/entries1048
-rw-r--r--package/network/services/hostapd/patches/.svn/text-base/300-nl80211_multicall_fixes.patch.svn-base60
-rw-r--r--package/network/services/hostapd/patches/.svn/text-base/310-multicall_bridge_fix.patch.svn-base45
-rw-r--r--package/network/services/hostapd/patches/.svn/text-base/320-madwifi_key_fixes.patch.svn-base34
-rw-r--r--package/network/services/hostapd/patches/.svn/text-base/330-fix_reassoc_after_ack_failure.patch.svn-base11
-rw-r--r--package/network/services/hostapd/patches/.svn/text-base/400-noscan.patch.svn-base32
-rw-r--r--package/network/services/hostapd/patches/.svn/text-base/410-multicall.patch.svn-base246
-rw-r--r--package/network/services/hostapd/patches/.svn/text-base/420-timestamp_check.patch.svn-base12
-rw-r--r--package/network/services/hostapd/patches/.svn/text-base/430-rescan_immediately.patch.svn-base11
-rw-r--r--package/network/services/hostapd/patches/.svn/text-base/440-optional_rfkill.patch.svn-base261
-rw-r--r--package/network/services/hostapd/patches/.svn/text-base/450-reload_freq_change.patch.svn-base27
-rw-r--r--package/network/services/hostapd/patches/.svn/text-base/451-nl80211_del_beacon_bss.patch.svn-base63
-rw-r--r--package/network/services/hostapd/patches/.svn/text-base/452-ctrl_iface_reload.patch.svn-base98
-rw-r--r--package/network/services/hostapd/patches/.svn/text-base/453-ap_sta_support.patch.svn-base222
-rw-r--r--package/network/services/hostapd/patches/.svn/text-base/460-disable_ctrl_iface_mib.patch.svn-base168
-rw-r--r--package/network/services/hostapd/patches/.svn/text-base/470-wpa_ie_cap_workaround.patch.svn-base56
-rw-r--r--package/network/services/hostapd/patches/.svn/text-base/480-terminate_on_setup_failure.patch.svn-base81
-rw-r--r--package/network/services/hostapd/patches/.svn/text-base/500-random_pool_add_kernel.patch.svn-base176
-rw-r--r--package/network/services/hostapd/patches/.svn/text-base/510-bring_down_interface.patch.svn-base19
-rw-r--r--package/network/services/hostapd/patches/.svn/text-base/520-fix_wps_pin_crash.patch.svn-base12
-rw-r--r--package/network/services/hostapd/patches/.svn/text-base/530-wps_single_auth_enc_type.patch.svn-base25
-rw-r--r--package/network/services/hostapd/patches/.svn/text-base/540-dynamic_20_40_mhz.patch.svn-base206
-rw-r--r--package/network/services/hostapd/patches/.svn/text-base/550-limit_debug_messages.patch.svn-base213
-rw-r--r--package/network/services/hostapd/patches/.svn/text-base/560-indicate-features.patch.svn-base82
-rw-r--r--package/network/services/hostapd/patches/.svn/text-base/570-genl_connect_debug.patch.svn-base11
-rw-r--r--package/network/services/hostapd/patches/.svn/text-base/590-hostapd_cli_ifdef.patch.svn-base50
-rw-r--r--package/network/services/hostapd/patches/.svn/text-base/601-wpa_supplicant-add-new-config-params-to-be-used-with.patch.svn-base209
-rw-r--r--package/network/services/hostapd/patches/.svn/text-base/602-driver_nl80211-use-new-parameters-during-ibss-join.patch.svn-base59
-rw-r--r--package/network/services/hostapd/patches/.svn/text-base/604-wpa_s-support-htmode-param.patch.svn-base156
-rw-r--r--package/network/services/hostapd/patches/.svn/text-base/610-max_num_sta_probe.patch.svn-base13
-rw-r--r--package/network/services/hostapd/patches/.svn/text-base/620-scan_wait.patch.svn-base65
-rw-r--r--package/network/services/hostapd/patches/300-nl80211_multicall_fixes.patch60
-rw-r--r--package/network/services/hostapd/patches/310-multicall_bridge_fix.patch45
-rw-r--r--package/network/services/hostapd/patches/320-madwifi_key_fixes.patch34
-rw-r--r--package/network/services/hostapd/patches/330-fix_reassoc_after_ack_failure.patch11
-rw-r--r--package/network/services/hostapd/patches/400-noscan.patch32
-rw-r--r--package/network/services/hostapd/patches/410-multicall.patch246
-rw-r--r--package/network/services/hostapd/patches/420-timestamp_check.patch12
-rw-r--r--package/network/services/hostapd/patches/430-rescan_immediately.patch11
-rw-r--r--package/network/services/hostapd/patches/440-optional_rfkill.patch261
-rw-r--r--package/network/services/hostapd/patches/450-reload_freq_change.patch27
-rw-r--r--package/network/services/hostapd/patches/451-nl80211_del_beacon_bss.patch63
-rw-r--r--package/network/services/hostapd/patches/452-ctrl_iface_reload.patch98
-rw-r--r--package/network/services/hostapd/patches/453-ap_sta_support.patch222
-rw-r--r--package/network/services/hostapd/patches/460-disable_ctrl_iface_mib.patch168
-rw-r--r--package/network/services/hostapd/patches/470-wpa_ie_cap_workaround.patch56
-rw-r--r--package/network/services/hostapd/patches/480-terminate_on_setup_failure.patch81
-rw-r--r--package/network/services/hostapd/patches/500-random_pool_add_kernel.patch176
-rw-r--r--package/network/services/hostapd/patches/510-bring_down_interface.patch19
-rw-r--r--package/network/services/hostapd/patches/520-fix_wps_pin_crash.patch12
-rw-r--r--package/network/services/hostapd/patches/530-wps_single_auth_enc_type.patch25
-rw-r--r--package/network/services/hostapd/patches/540-dynamic_20_40_mhz.patch206
-rw-r--r--package/network/services/hostapd/patches/550-limit_debug_messages.patch213
-rw-r--r--package/network/services/hostapd/patches/560-indicate-features.patch82
-rw-r--r--package/network/services/hostapd/patches/570-genl_connect_debug.patch11
-rw-r--r--package/network/services/hostapd/patches/590-hostapd_cli_ifdef.patch50
-rw-r--r--package/network/services/hostapd/patches/601-wpa_supplicant-add-new-config-params-to-be-used-with.patch209
-rw-r--r--package/network/services/hostapd/patches/602-driver_nl80211-use-new-parameters-during-ibss-join.patch59
-rw-r--r--package/network/services/hostapd/patches/604-wpa_s-support-htmode-param.patch156
-rw-r--r--package/network/services/hostapd/patches/610-max_num_sta_probe.patch13
-rw-r--r--package/network/services/hostapd/patches/620-scan_wait.patch65
-rw-r--r--package/network/services/lldpd/.svn/entries68
-rw-r--r--package/network/services/lldpd/.svn/text-base/Makefile.svn-base62
-rw-r--r--package/network/services/lldpd/Makefile62
-rw-r--r--package/network/services/lldpd/files/.svn/entries96
-rw-r--r--package/network/services/lldpd/files/.svn/text-base/lldpd.config.svn-base15
-rw-r--r--package/network/services/lldpd/files/.svn/text-base/lldpd.init.svn-base72
-rw-r--r--package/network/services/lldpd/files/lldpd.config15
-rw-r--r--package/network/services/lldpd/files/lldpd.init72
-rw-r--r--package/network/services/lldpd/patches/.svn/entries62
-rw-r--r--package/network/services/lldpd/patches/.svn/text-base/002-no-stack-protector.patch.svn-base10
-rw-r--r--package/network/services/lldpd/patches/002-no-stack-protector.patch10
-rw-r--r--package/network/services/openvpn-easy-rsa/.svn/entries65
-rw-r--r--package/network/services/openvpn-easy-rsa/.svn/text-base/Makefile.svn-base60
-rw-r--r--package/network/services/openvpn-easy-rsa/Makefile60
-rw-r--r--package/network/services/openvpn-easy-rsa/files/.svn/entries96
-rw-r--r--package/network/services/openvpn-easy-rsa/files/.svn/text-base/easy-rsa.index.svn-base0
-rw-r--r--package/network/services/openvpn-easy-rsa/files/.svn/text-base/easy-rsa.serial.svn-base1
-rw-r--r--package/network/services/openvpn-easy-rsa/files/easy-rsa.index0
-rw-r--r--package/network/services/openvpn-easy-rsa/files/easy-rsa.serial1
-rw-r--r--package/network/services/openvpn/.svn/entries170
-rw-r--r--package/network/services/openvpn/.svn/text-base/Config-nossl.in.svn-base47
-rw-r--r--package/network/services/openvpn/.svn/text-base/Config-openssl.in.svn-base59
-rw-r--r--package/network/services/openvpn/.svn/text-base/Config-polarssl.in.svn-base59
-rw-r--r--package/network/services/openvpn/.svn/text-base/Makefile.svn-base122
-rw-r--r--package/network/services/openvpn/Config-nossl.in47
-rw-r--r--package/network/services/openvpn/Config-openssl.in59
-rw-r--r--package/network/services/openvpn/Config-polarssl.in59
-rw-r--r--package/network/services/openvpn/Makefile122
-rw-r--r--package/network/services/openvpn/files/.svn/entries130
-rw-r--r--package/network/services/openvpn/files/.svn/text-base/openvpn.config.svn-base398
-rw-r--r--package/network/services/openvpn/files/.svn/text-base/openvpn.init.svn-base154
-rw-r--r--package/network/services/openvpn/files/.svn/text-base/openvpn.upgrade.svn-base1
-rw-r--r--package/network/services/openvpn/files/openvpn.config398
-rw-r--r--package/network/services/openvpn/files/openvpn.init154
-rw-r--r--package/network/services/openvpn/files/openvpn.upgrade1
-rw-r--r--package/network/services/openvpn/patches/.svn/entries62
-rw-r--r--package/network/services/openvpn/patches/.svn/text-base/100-polarssl_update.patch.svn-base60
-rw-r--r--package/network/services/openvpn/patches/100-polarssl_update.patch60
-rw-r--r--package/network/services/ppp/.svn/entries71
-rw-r--r--package/network/services/ppp/.svn/prop-base/Makefile.svn-base9
-rw-r--r--package/network/services/ppp/.svn/text-base/Makefile.svn-base263
-rw-r--r--package/network/services/ppp/Makefile263
-rw-r--r--package/network/services/ppp/files/.svn/entries68
-rw-r--r--package/network/services/ppp/files/.svn/prop-base/ppp.sh.svn-base9
-rw-r--r--package/network/services/ppp/files/.svn/text-base/ppp.sh.svn-base215
-rw-r--r--package/network/services/ppp/files/etc/.svn/entries31
-rw-r--r--package/network/services/ppp/files/etc/ppp/.svn/entries201
-rw-r--r--package/network/services/ppp/files/etc/ppp/.svn/prop-base/chap-secrets.svn-base5
-rw-r--r--package/network/services/ppp/files/etc/ppp/.svn/prop-base/filter.svn-base5
-rw-r--r--package/network/services/ppp/files/etc/ppp/.svn/prop-base/options.svn-base5
-rw-r--r--package/network/services/ppp/files/etc/ppp/.svn/prop-base/radius.conf.svn-base5
-rw-r--r--package/network/services/ppp/files/etc/ppp/.svn/text-base/chap-secrets.svn-base1
-rw-r--r--package/network/services/ppp/files/etc/ppp/.svn/text-base/filter.svn-base23
-rw-r--r--package/network/services/ppp/files/etc/ppp/.svn/text-base/options.pptp.svn-base7
-rw-r--r--package/network/services/ppp/files/etc/ppp/.svn/text-base/options.svn-base10
-rw-r--r--package/network/services/ppp/files/etc/ppp/.svn/text-base/radius.conf.svn-base8
-rw-r--r--package/network/services/ppp/files/etc/ppp/chap-secrets1
-rw-r--r--package/network/services/ppp/files/etc/ppp/filter23
-rw-r--r--package/network/services/ppp/files/etc/ppp/options10
-rw-r--r--package/network/services/ppp/files/etc/ppp/options.pptp7
-rw-r--r--package/network/services/ppp/files/etc/ppp/radius.conf8
-rw-r--r--package/network/services/ppp/files/etc/ppp/radius/.svn/entries164
-rw-r--r--package/network/services/ppp/files/etc/ppp/radius/.svn/prop-base/dictionary.asnet.svn-base5
-rw-r--r--package/network/services/ppp/files/etc/ppp/radius/.svn/prop-base/dictionary.microsoft.svn-base5
-rw-r--r--package/network/services/ppp/files/etc/ppp/radius/.svn/prop-base/dictionary.svn-base5
-rw-r--r--package/network/services/ppp/files/etc/ppp/radius/.svn/prop-base/servers.svn-base5
-rw-r--r--package/network/services/ppp/files/etc/ppp/radius/.svn/text-base/dictionary.asnet.svn-base3
-rw-r--r--package/network/services/ppp/files/etc/ppp/radius/.svn/text-base/dictionary.microsoft.svn-base80
-rw-r--r--package/network/services/ppp/files/etc/ppp/radius/.svn/text-base/dictionary.svn-base253
-rw-r--r--package/network/services/ppp/files/etc/ppp/radius/.svn/text-base/servers.svn-base2
-rw-r--r--package/network/services/ppp/files/etc/ppp/radius/dictionary253
-rw-r--r--package/network/services/ppp/files/etc/ppp/radius/dictionary.asnet3
-rw-r--r--package/network/services/ppp/files/etc/ppp/radius/dictionary.microsoft80
-rw-r--r--package/network/services/ppp/files/etc/ppp/radius/servers2
-rw-r--r--package/network/services/ppp/files/lib/.svn/entries31
-rw-r--r--package/network/services/ppp/files/lib/netifd/.svn/entries96
-rw-r--r--package/network/services/ppp/files/lib/netifd/.svn/prop-base/ppp-down.svn-base5
-rw-r--r--package/network/services/ppp/files/lib/netifd/.svn/prop-base/ppp-up.svn-base5
-rw-r--r--package/network/services/ppp/files/lib/netifd/.svn/text-base/ppp-down.svn-base13
-rw-r--r--package/network/services/ppp/files/lib/netifd/.svn/text-base/ppp-up.svn-base21
-rwxr-xr-xpackage/network/services/ppp/files/lib/netifd/ppp-down13
-rwxr-xr-xpackage/network/services/ppp/files/lib/netifd/ppp-up21
-rwxr-xr-xpackage/network/services/ppp/files/ppp.sh215
-rw-r--r--package/network/services/ppp/patches/.svn/entries1082
-rw-r--r--package/network/services/ppp/patches/.svn/prop-base/010-use_target_for_configure.patch.svn-base5
-rw-r--r--package/network/services/ppp/patches/.svn/prop-base/200-makefile.patch.svn-base5
-rw-r--r--package/network/services/ppp/patches/.svn/prop-base/201-mppe_mppc_1.1.patch.svn-base5
-rw-r--r--package/network/services/ppp/patches/.svn/prop-base/300-filter-pcap-includes-lib.patch.svn-base5
-rw-r--r--package/network/services/ppp/patches/.svn/text-base/010-use_target_for_configure.patch.svn-base24
-rw-r--r--package/network/services/ppp/patches/.svn/text-base/100-debian_ip-ip_option.patch.svn-base96
-rw-r--r--package/network/services/ppp/patches/.svn/text-base/101-debian_close_dev_ppp.patch.svn-base28
-rw-r--r--package/network/services/ppp/patches/.svn/text-base/103-debian_fix_link_pidfile.patch.svn-base23
-rw-r--r--package/network/services/ppp/patches/.svn/text-base/105-debian_demand.patch.svn-base172
-rw-r--r--package/network/services/ppp/patches/.svn/text-base/106-debian_stripMSdomain.patch.svn-base47
-rw-r--r--package/network/services/ppp/patches/.svn/text-base/107-debian_pppoatm_wildcard.patch.svn-base25
-rw-r--r--package/network/services/ppp/patches/.svn/text-base/110-debian_defaultroute.patch.svn-base313
-rw-r--r--package/network/services/ppp/patches/.svn/text-base/120-debian_ipv6_updown_option.patch.svn-base95
-rw-r--r--package/network/services/ppp/patches/.svn/text-base/200-makefile.patch.svn-base55
-rw-r--r--package/network/services/ppp/patches/.svn/text-base/201-mppe_mppc_1.1.patch.svn-base1495
-rw-r--r--package/network/services/ppp/patches/.svn/text-base/202-no_strip.patch.svn-base88
-rw-r--r--package/network/services/ppp/patches/.svn/text-base/203-opt_flags.patch.svn-base32
-rw-r--r--package/network/services/ppp/patches/.svn/text-base/204-radius_config.patch.svn-base72
-rw-r--r--package/network/services/ppp/patches/.svn/text-base/205-no_exponential_timeout.patch.svn-base29
-rw-r--r--package/network/services/ppp/patches/.svn/text-base/206-compensate_time_change.patch.svn-base94
-rw-r--r--package/network/services/ppp/patches/.svn/text-base/207-lcp_mtu_max.patch.svn-base25
-rw-r--r--package/network/services/ppp/patches/.svn/text-base/208-fix_status_code.patch.svn-base24
-rw-r--r--package/network/services/ppp/patches/.svn/text-base/300-filter-pcap-includes-lib.patch.svn-base20
-rw-r--r--package/network/services/ppp/patches/.svn/text-base/310-precompile_filter.patch.svn-base196
-rw-r--r--package/network/services/ppp/patches/.svn/text-base/320-custom_iface_names.patch.svn-base135
-rw-r--r--package/network/services/ppp/patches/.svn/text-base/321-multilink_support_custom_iface_names.patch.svn-base146
-rw-r--r--package/network/services/ppp/patches/.svn/text-base/330-retain_foreign_default_routes.patch.svn-base22
-rw-r--r--package/network/services/ppp/patches/.svn/text-base/340-populate_default_gateway.patch.svn-base34
-rw-r--r--package/network/services/ppp/patches/.svn/text-base/400-simplify_kernel_checks.patch.svn-base154
-rw-r--r--package/network/services/ppp/patches/.svn/text-base/401-no_record_file.patch.svn-base39
-rw-r--r--package/network/services/ppp/patches/.svn/text-base/403-no_wtmp.patch.svn-base25
-rw-r--r--package/network/services/ppp/patches/.svn/text-base/404-remove_obsolete_protocol_names.patch.svn-base151
-rw-r--r--package/network/services/ppp/patches/.svn/text-base/405-no_multilink_option.patch.svn-base28
-rw-r--r--package/network/services/ppp/patches/.svn/text-base/430-pppol2tpv3-struct.patch.svn-base56
-rw-r--r--package/network/services/ppp/patches/.svn/text-base/500-add-pptp-plugin.patch.svn-base3065
-rw-r--r--package/network/services/ppp/patches/010-use_target_for_configure.patch24
-rw-r--r--package/network/services/ppp/patches/100-debian_ip-ip_option.patch96
-rw-r--r--package/network/services/ppp/patches/101-debian_close_dev_ppp.patch28
-rw-r--r--package/network/services/ppp/patches/103-debian_fix_link_pidfile.patch23
-rw-r--r--package/network/services/ppp/patches/105-debian_demand.patch172
-rw-r--r--package/network/services/ppp/patches/106-debian_stripMSdomain.patch47
-rw-r--r--package/network/services/ppp/patches/107-debian_pppoatm_wildcard.patch25
-rw-r--r--package/network/services/ppp/patches/110-debian_defaultroute.patch313
-rw-r--r--package/network/services/ppp/patches/120-debian_ipv6_updown_option.patch95
-rw-r--r--package/network/services/ppp/patches/200-makefile.patch55
-rw-r--r--package/network/services/ppp/patches/201-mppe_mppc_1.1.patch1495
-rw-r--r--package/network/services/ppp/patches/202-no_strip.patch88
-rw-r--r--package/network/services/ppp/patches/203-opt_flags.patch32
-rw-r--r--package/network/services/ppp/patches/204-radius_config.patch72
-rw-r--r--package/network/services/ppp/patches/205-no_exponential_timeout.patch29
-rw-r--r--package/network/services/ppp/patches/206-compensate_time_change.patch94
-rw-r--r--package/network/services/ppp/patches/207-lcp_mtu_max.patch25
-rw-r--r--package/network/services/ppp/patches/208-fix_status_code.patch24
-rw-r--r--package/network/services/ppp/patches/300-filter-pcap-includes-lib.patch20
-rw-r--r--package/network/services/ppp/patches/310-precompile_filter.patch196
-rw-r--r--package/network/services/ppp/patches/320-custom_iface_names.patch135
-rw-r--r--package/network/services/ppp/patches/321-multilink_support_custom_iface_names.patch146
-rw-r--r--package/network/services/ppp/patches/330-retain_foreign_default_routes.patch22
-rw-r--r--package/network/services/ppp/patches/340-populate_default_gateway.patch34
-rw-r--r--package/network/services/ppp/patches/400-simplify_kernel_checks.patch154
-rw-r--r--package/network/services/ppp/patches/401-no_record_file.patch39
-rw-r--r--package/network/services/ppp/patches/403-no_wtmp.patch25
-rw-r--r--package/network/services/ppp/patches/404-remove_obsolete_protocol_names.patch151
-rw-r--r--package/network/services/ppp/patches/405-no_multilink_option.patch28
-rw-r--r--package/network/services/ppp/patches/430-pppol2tpv3-struct.patch56
-rw-r--r--package/network/services/ppp/patches/500-add-pptp-plugin.patch3065
-rw-r--r--package/network/services/ppp/utils/.svn/entries62
-rw-r--r--package/network/services/ppp/utils/.svn/prop-base/pfc.c.svn-base5
-rw-r--r--package/network/services/ppp/utils/.svn/text-base/pfc.c.svn-base51
-rw-r--r--package/network/services/ppp/utils/pfc.c51
-rw-r--r--package/network/services/relayd/.svn/entries65
-rw-r--r--package/network/services/relayd/.svn/text-base/Makefile.svn-base44
-rw-r--r--package/network/services/relayd/Makefile44
-rw-r--r--package/network/services/relayd/files/.svn/entries96
-rw-r--r--package/network/services/relayd/files/.svn/text-base/relay.hotplug.svn-base2
-rw-r--r--package/network/services/relayd/files/.svn/text-base/relay.init.svn-base97
-rw-r--r--package/network/services/relayd/files/relay.hotplug2
-rw-r--r--package/network/services/relayd/files/relay.init97
-rw-r--r--package/network/services/samba36/.svn/entries68
-rw-r--r--package/network/services/samba36/.svn/text-base/Makefile.svn-base147
-rw-r--r--package/network/services/samba36/Makefile147
-rw-r--r--package/network/services/samba36/files/.svn/entries130
-rw-r--r--package/network/services/samba36/files/.svn/prop-base/samba.init.svn-base5
-rw-r--r--package/network/services/samba36/files/.svn/text-base/samba.config.svn-base6
-rw-r--r--package/network/services/samba36/files/.svn/text-base/samba.init.svn-base97
-rw-r--r--package/network/services/samba36/files/.svn/text-base/smb.conf.template.svn-base34
-rw-r--r--package/network/services/samba36/files/samba.config6
-rwxr-xr-xpackage/network/services/samba36/files/samba.init97
-rw-r--r--package/network/services/samba36/files/smb.conf.template34
-rw-r--r--package/network/services/samba36/patches/.svn/entries640
-rw-r--r--package/network/services/samba36/patches/.svn/text-base/100-configure_fixes.patch.svn-base14
-rw-r--r--package/network/services/samba36/patches/.svn/text-base/110-multicall.patch.svn-base117
-rw-r--r--package/network/services/samba36/patches/.svn/text-base/111-owrt_smbpasswd.patch.svn-base277
-rw-r--r--package/network/services/samba36/patches/.svn/text-base/120-add_missing_ifdef.patch.svn-base26
-rw-r--r--package/network/services/samba36/patches/.svn/text-base/200-remove_printer_support.patch.svn-base346
-rw-r--r--package/network/services/samba36/patches/.svn/text-base/210-remove_ad_support.patch.svn-base88
-rw-r--r--package/network/services/samba36/patches/.svn/text-base/220-remove_services.patch.svn-base98
-rw-r--r--package/network/services/samba36/patches/.svn/text-base/230-remove_winreg_support.patch.svn-base146
-rw-r--r--package/network/services/samba36/patches/.svn/text-base/240-remove_dfs_api.patch.svn-base71
-rw-r--r--package/network/services/samba36/patches/.svn/text-base/250-remove_domain_logon.patch.svn-base185
-rw-r--r--package/network/services/samba36/patches/.svn/text-base/260-remove_samr.patch.svn-base155
-rw-r--r--package/network/services/samba36/patches/.svn/text-base/270-remove_registry_backend.patch.svn-base43
-rw-r--r--package/network/services/samba36/patches/.svn/text-base/280-strip_srvsvc.patch.svn-base143
-rw-r--r--package/network/services/samba36/patches/.svn/text-base/290-remove_lsa.patch.svn-base73
-rw-r--r--package/network/services/samba36/patches/.svn/text-base/300-assert_debug_level.patch.svn-base11
-rw-r--r--package/network/services/samba36/patches/.svn/text-base/310-remove_error_strings.patch.svn-base253
-rw-r--r--package/network/services/samba36/patches/.svn/text-base/320-debug_level_checks.patch.svn-base22
-rw-r--r--package/network/services/samba36/patches/.svn/text-base/330-librpc_default_print.patch.svn-base8854
-rw-r--r--package/network/services/samba36/patches/100-configure_fixes.patch14
-rw-r--r--package/network/services/samba36/patches/110-multicall.patch117
-rw-r--r--package/network/services/samba36/patches/111-owrt_smbpasswd.patch277
-rw-r--r--package/network/services/samba36/patches/120-add_missing_ifdef.patch26
-rw-r--r--package/network/services/samba36/patches/200-remove_printer_support.patch346
-rw-r--r--package/network/services/samba36/patches/210-remove_ad_support.patch88
-rw-r--r--package/network/services/samba36/patches/220-remove_services.patch98
-rw-r--r--package/network/services/samba36/patches/230-remove_winreg_support.patch146
-rw-r--r--package/network/services/samba36/patches/240-remove_dfs_api.patch71
-rw-r--r--package/network/services/samba36/patches/250-remove_domain_logon.patch185
-rw-r--r--package/network/services/samba36/patches/260-remove_samr.patch155
-rw-r--r--package/network/services/samba36/patches/270-remove_registry_backend.patch43
-rw-r--r--package/network/services/samba36/patches/280-strip_srvsvc.patch143
-rw-r--r--package/network/services/samba36/patches/290-remove_lsa.patch73
-rw-r--r--package/network/services/samba36/patches/300-assert_debug_level.patch11
-rw-r--r--package/network/services/samba36/patches/310-remove_error_strings.patch253
-rw-r--r--package/network/services/samba36/patches/320-debug_level_checks.patch22
-rw-r--r--package/network/services/samba36/patches/330-librpc_default_print.patch8854
-rw-r--r--package/network/services/uhttpd/.svn/entries65
-rw-r--r--package/network/services/uhttpd/.svn/text-base/Makefile.svn-base134
-rw-r--r--package/network/services/uhttpd/Makefile134
-rw-r--r--package/network/services/uhttpd/files/.svn/entries96
-rw-r--r--package/network/services/uhttpd/files/.svn/prop-base/uhttpd.init.svn-base5
-rw-r--r--package/network/services/uhttpd/files/.svn/text-base/uhttpd.config.svn-base89
-rw-r--r--package/network/services/uhttpd/files/.svn/text-base/uhttpd.init.svn-base139
-rw-r--r--package/network/services/uhttpd/files/uhttpd.config89
-rwxr-xr-xpackage/network/services/uhttpd/files/uhttpd.init139
-rw-r--r--package/network/utils/.svn/entries94
-rw-r--r--package/network/utils/arptables/.svn/entries65
-rw-r--r--package/network/utils/arptables/.svn/prop-base/Makefile.svn-base9
-rw-r--r--package/network/utils/arptables/.svn/text-base/Makefile.svn-base42
-rw-r--r--package/network/utils/arptables/Makefile42
-rw-r--r--package/network/utils/arptables/patches/.svn/entries62
-rw-r--r--package/network/utils/arptables/patches/.svn/text-base/100-always_optimize.patch.svn-base19
-rw-r--r--package/network/utils/arptables/patches/100-always_optimize.patch19
-rw-r--r--package/network/utils/comgt/.svn/entries68
-rw-r--r--package/network/utils/comgt/.svn/prop-base/Makefile.svn-base357
-rw-r--r--package/network/utils/comgt/.svn/text-base/Makefile.svn-base67
-rw-r--r--package/network/utils/comgt/Makefile67
-rw-r--r--package/network/utils/comgt/files/.svn/entries402
-rw-r--r--package/network/utils/comgt/files/.svn/prop-base/3g.chat.svn-base5
-rw-r--r--package/network/utils/comgt/files/.svn/prop-base/getcardinfo.gcom.svn-base5
-rw-r--r--package/network/utils/comgt/files/.svn/prop-base/getimsi.gcom.svn-base5
-rw-r--r--package/network/utils/comgt/files/.svn/prop-base/getstrength.gcom.svn-base5
-rw-r--r--package/network/utils/comgt/files/.svn/prop-base/setmode.gcom.svn-base5
-rw-r--r--package/network/utils/comgt/files/.svn/prop-base/setpin.gcom.svn-base5
-rw-r--r--package/network/utils/comgt/files/.svn/text-base/3g.chat.svn-base12
-rw-r--r--package/network/utils/comgt/files/.svn/text-base/3g.sh.svn-base97
-rw-r--r--package/network/utils/comgt/files/.svn/text-base/3g.usb.svn-base33
-rw-r--r--package/network/utils/comgt/files/.svn/text-base/evdo.chat.svn-base17
-rw-r--r--package/network/utils/comgt/files/.svn/text-base/getcardinfo.gcom.svn-base14
-rw-r--r--package/network/utils/comgt/files/.svn/text-base/getcarrier.gcom.svn-base20
-rw-r--r--package/network/utils/comgt/files/.svn/text-base/getcnum.gcom.svn-base20
-rw-r--r--package/network/utils/comgt/files/.svn/text-base/getimsi.gcom.svn-base17
-rw-r--r--package/network/utils/comgt/files/.svn/text-base/getstrength.gcom.svn-base14
-rw-r--r--package/network/utils/comgt/files/.svn/text-base/setmode.gcom.svn-base26
-rw-r--r--package/network/utils/comgt/files/.svn/text-base/setpin.gcom.svn-base55
-rw-r--r--package/network/utils/comgt/files/3g.chat12
-rw-r--r--package/network/utils/comgt/files/3g.sh97
-rw-r--r--package/network/utils/comgt/files/3g.usb33
-rw-r--r--package/network/utils/comgt/files/evdo.chat17
-rw-r--r--package/network/utils/comgt/files/getcardinfo.gcom14
-rw-r--r--package/network/utils/comgt/files/getcarrier.gcom20
-rw-r--r--package/network/utils/comgt/files/getcnum.gcom20
-rw-r--r--package/network/utils/comgt/files/getimsi.gcom17
-rw-r--r--package/network/utils/comgt/files/getstrength.gcom14
-rw-r--r--package/network/utils/comgt/files/setmode.gcom26
-rw-r--r--package/network/utils/comgt/files/setpin.gcom55
-rw-r--r--package/network/utils/comgt/patches/.svn/entries62
-rw-r--r--package/network/utils/comgt/patches/.svn/text-base/001-compile_fix.patch.svn-base23
-rw-r--r--package/network/utils/comgt/patches/001-compile_fix.patch23
-rw-r--r--package/network/utils/conntrack-tools/.svn/entries62
-rw-r--r--package/network/utils/conntrack-tools/.svn/text-base/Makefile.svn-base61
-rw-r--r--package/network/utils/conntrack-tools/Makefile61
-rw-r--r--package/network/utils/dante/.svn/entries65
-rw-r--r--package/network/utils/dante/.svn/text-base/Makefile.svn-base116
-rw-r--r--package/network/utils/dante/Makefile116
-rw-r--r--package/network/utils/dante/patches/.svn/entries130
-rw-r--r--package/network/utils/dante/patches/.svn/text-base/001-automake-compat.patch.svn-base482
-rw-r--r--package/network/utils/dante/patches/.svn/text-base/100-do-not-use-defdname.patch.svn-base42
-rw-r--r--package/network/utils/dante/patches/.svn/text-base/200-fix-RTLD_NEXT.patch.svn-base36
-rw-r--r--package/network/utils/dante/patches/001-automake-compat.patch482
-rw-r--r--package/network/utils/dante/patches/100-do-not-use-defdname.patch42
-rw-r--r--package/network/utils/dante/patches/200-fix-RTLD_NEXT.patch36
-rw-r--r--package/network/utils/ebtables/.svn/entries62
-rw-r--r--package/network/utils/ebtables/.svn/prop-base/Makefile.svn-base9
-rw-r--r--package/network/utils/ebtables/.svn/text-base/Makefile.svn-base71
-rw-r--r--package/network/utils/ebtables/Makefile71
-rw-r--r--package/network/utils/ifenslave/.svn/entries62
-rw-r--r--package/network/utils/ifenslave/.svn/prop-base/Makefile.svn-base9
-rw-r--r--package/network/utils/ifenslave/.svn/text-base/Makefile.svn-base42
-rw-r--r--package/network/utils/ifenslave/Makefile42
-rw-r--r--package/network/utils/iftop/.svn/entries65
-rw-r--r--package/network/utils/iftop/.svn/prop-base/Makefile.svn-base13
-rw-r--r--package/network/utils/iftop/.svn/text-base/Makefile.svn-base42
-rw-r--r--package/network/utils/iftop/Makefile42
-rw-r--r--package/network/utils/iftop/patches/.svn/entries62
-rw-r--r--package/network/utils/iftop/patches/.svn/text-base/0001-force-ncurses.patch.svn-base12
-rw-r--r--package/network/utils/iftop/patches/0001-force-ncurses.patch12
-rw-r--r--package/network/utils/iperf/.svn/entries65
-rw-r--r--package/network/utils/iperf/.svn/prop-base/Makefile.svn-base13
-rw-r--r--package/network/utils/iperf/.svn/text-base/Makefile.svn-base86
-rw-r--r--package/network/utils/iperf/Makefile86
-rw-r--r--package/network/utils/iperf/patches/.svn/entries62
-rw-r--r--package/network/utils/iperf/patches/.svn/text-base/001-set-report-next-time-in-single-thread-mode.patch.svn-base14
-rw-r--r--package/network/utils/iperf/patches/001-set-report-next-time-in-single-thread-mode.patch14
-rw-r--r--package/network/utils/iproute2/.svn/entries68
-rw-r--r--package/network/utils/iproute2/.svn/prop-base/Makefile.svn-base9
-rw-r--r--package/network/utils/iproute2/.svn/text-base/Makefile.svn-base115
-rw-r--r--package/network/utils/iproute2/Makefile115
-rw-r--r--package/network/utils/iproute2/files/.svn/entries62
-rw-r--r--package/network/utils/iproute2/files/.svn/text-base/15-teql.svn-base23
-rw-r--r--package/network/utils/iproute2/files/15-teql23
-rw-r--r--package/network/utils/iproute2/patches/.svn/entries436
-rw-r--r--package/network/utils/iproute2/patches/.svn/prop-base/002-iproute2-ipxfrm_no_sctp.patch.svn-base5
-rw-r--r--package/network/utils/iproute2/patches/.svn/text-base/000-sync_pkt_sched_h.patch.svn-base36
-rw-r--r--package/network/utils/iproute2/patches/.svn/text-base/001-iproute2-2.6.11_Config.patch.svn-base7
-rw-r--r--package/network/utils/iproute2/patches/.svn/text-base/002-iproute2-ipxfrm_no_sctp.patch.svn-base22
-rw-r--r--package/network/utils/iproute2/patches/.svn/text-base/004-darwin_fixes.patch.svn-base59
-rw-r--r--package/network/utils/iproute2/patches/.svn/text-base/006-iproute2-tc_esfq.patch.svn-base219
-rw-r--r--package/network/utils/iproute2/patches/.svn/text-base/007-no_arpd.patch.svn-base11
-rw-r--r--package/network/utils/iproute2/patches/.svn/text-base/008-no_netem.patch.svn-base11
-rw-r--r--package/network/utils/iproute2/patches/.svn/text-base/100-allow_pfifo_fast.patch.svn-base13
-rw-r--r--package/network/utils/iproute2/patches/.svn/text-base/110-extra-ccopts.patch.svn-base11
-rw-r--r--package/network/utils/iproute2/patches/.svn/text-base/120-libnetlink-pic.patch.svn-base8
-rw-r--r--package/network/utils/iproute2/patches/.svn/text-base/200-act_connmark.patch.svn-base84
-rw-r--r--package/network/utils/iproute2/patches/.svn/text-base/210-build-unbreak-linkage-of-m_xt.so.patch.svn-base58
-rw-r--r--package/network/utils/iproute2/patches/000-sync_pkt_sched_h.patch36
-rw-r--r--package/network/utils/iproute2/patches/001-iproute2-2.6.11_Config.patch7
-rw-r--r--package/network/utils/iproute2/patches/002-iproute2-ipxfrm_no_sctp.patch22
-rw-r--r--package/network/utils/iproute2/patches/004-darwin_fixes.patch59
-rw-r--r--package/network/utils/iproute2/patches/006-iproute2-tc_esfq.patch219
-rw-r--r--package/network/utils/iproute2/patches/007-no_arpd.patch11
-rw-r--r--package/network/utils/iproute2/patches/008-no_netem.patch11
-rw-r--r--package/network/utils/iproute2/patches/100-allow_pfifo_fast.patch13
-rw-r--r--package/network/utils/iproute2/patches/110-extra-ccopts.patch11
-rw-r--r--package/network/utils/iproute2/patches/120-libnetlink-pic.patch8
-rw-r--r--package/network/utils/iproute2/patches/200-act_connmark.patch84
-rw-r--r--package/network/utils/iproute2/patches/210-build-unbreak-linkage-of-m_xt.so.patch58
-rw-r--r--package/network/utils/ipset/.svn/entries62
-rw-r--r--package/network/utils/ipset/.svn/text-base/Makefile.svn-base82
-rw-r--r--package/network/utils/ipset/Makefile82
-rw-r--r--package/network/utils/iptables/.svn/entries68
-rw-r--r--package/network/utils/iptables/.svn/prop-base/Makefile.svn-base9
-rw-r--r--package/network/utils/iptables/.svn/text-base/Makefile.svn-base453
-rw-r--r--package/network/utils/iptables/Makefile453
-rw-r--r--package/network/utils/iptables/files/.svn/entries31
-rw-r--r--package/network/utils/iptables/files/l7/.svn/entries572
-rw-r--r--package/network/utils/iptables/files/l7/.svn/prop-base/aim.pat.svn-base5
-rw-r--r--package/network/utils/iptables/files/l7/.svn/prop-base/bittorrent.pat.svn-base5
-rw-r--r--package/network/utils/iptables/files/l7/.svn/prop-base/edonkey.pat.svn-base5
-rw-r--r--package/network/utils/iptables/files/l7/.svn/prop-base/fasttrack.pat.svn-base5
-rw-r--r--package/network/utils/iptables/files/l7/.svn/prop-base/ftp.pat.svn-base5
-rw-r--r--package/network/utils/iptables/files/l7/.svn/prop-base/gnutella.pat.svn-base5
-rw-r--r--package/network/utils/iptables/files/l7/.svn/prop-base/http.pat.svn-base5
-rw-r--r--package/network/utils/iptables/files/l7/.svn/prop-base/ident.pat.svn-base5
-rw-r--r--package/network/utils/iptables/files/l7/.svn/prop-base/irc.pat.svn-base5
-rw-r--r--package/network/utils/iptables/files/l7/.svn/prop-base/jabber.pat.svn-base5
-rw-r--r--package/network/utils/iptables/files/l7/.svn/prop-base/msnmessenger.pat.svn-base5
-rw-r--r--package/network/utils/iptables/files/l7/.svn/prop-base/ntp.pat.svn-base5
-rw-r--r--package/network/utils/iptables/files/l7/.svn/prop-base/pop3.pat.svn-base5
-rw-r--r--package/network/utils/iptables/files/l7/.svn/prop-base/smtp.pat.svn-base5
-rw-r--r--package/network/utils/iptables/files/l7/.svn/prop-base/ssl.pat.svn-base5
-rw-r--r--package/network/utils/iptables/files/l7/.svn/prop-base/vnc.pat.svn-base5
-rw-r--r--package/network/utils/iptables/files/l7/.svn/text-base/aim.pat.svn-base28
-rw-r--r--package/network/utils/iptables/files/l7/.svn/text-base/bittorrent.pat.svn-base25
-rw-r--r--package/network/utils/iptables/files/l7/.svn/text-base/edonkey.pat.svn-base37
-rw-r--r--package/network/utils/iptables/files/l7/.svn/text-base/fasttrack.pat.svn-base23
-rw-r--r--package/network/utils/iptables/files/l7/.svn/text-base/ftp.pat.svn-base46
-rw-r--r--package/network/utils/iptables/files/l7/.svn/text-base/gnutella.pat.svn-base34
-rw-r--r--package/network/utils/iptables/files/l7/.svn/text-base/http.pat.svn-base28
-rw-r--r--package/network/utils/iptables/files/l7/.svn/text-base/ident.pat.svn-base15
-rw-r--r--package/network/utils/iptables/files/l7/.svn/text-base/irc.pat.svn-base20
-rw-r--r--package/network/utils/iptables/files/l7/.svn/text-base/jabber.pat.svn-base24
-rw-r--r--package/network/utils/iptables/files/l7/.svn/text-base/msnmessenger.pat.svn-base28
-rw-r--r--package/network/utils/iptables/files/l7/.svn/text-base/ntp.pat.svn-base17
-rw-r--r--package/network/utils/iptables/files/l7/.svn/text-base/pop3.pat.svn-base50
-rw-r--r--package/network/utils/iptables/files/l7/.svn/text-base/smtp.pat.svn-base40
-rw-r--r--package/network/utils/iptables/files/l7/.svn/text-base/ssl.pat.svn-base16
-rw-r--r--package/network/utils/iptables/files/l7/.svn/text-base/vnc.pat.svn-base23
-rw-r--r--package/network/utils/iptables/files/l7/aim.pat28
-rw-r--r--package/network/utils/iptables/files/l7/bittorrent.pat25
-rw-r--r--package/network/utils/iptables/files/l7/edonkey.pat37
-rw-r--r--package/network/utils/iptables/files/l7/fasttrack.pat23
-rw-r--r--package/network/utils/iptables/files/l7/ftp.pat46
-rw-r--r--package/network/utils/iptables/files/l7/gnutella.pat34
-rw-r--r--package/network/utils/iptables/files/l7/http.pat28
-rw-r--r--package/network/utils/iptables/files/l7/ident.pat15
-rw-r--r--package/network/utils/iptables/files/l7/irc.pat20
-rw-r--r--package/network/utils/iptables/files/l7/jabber.pat24
-rw-r--r--package/network/utils/iptables/files/l7/msnmessenger.pat28
-rw-r--r--package/network/utils/iptables/files/l7/ntp.pat17
-rw-r--r--package/network/utils/iptables/files/l7/pop3.pat50
-rw-r--r--package/network/utils/iptables/files/l7/smtp.pat40
-rw-r--r--package/network/utils/iptables/files/l7/ssl.pat16
-rw-r--r--package/network/utils/iptables/files/l7/vnc.pat23
-rw-r--r--package/network/utils/iptables/patches/.svn/entries300
-rw-r--r--package/network/utils/iptables/patches/.svn/text-base/002-layer7_2.22.patch.svn-base371
-rw-r--r--package/network/utils/iptables/patches/.svn/text-base/010-use-old-linking.patch.svn-base51
-rw-r--r--package/network/utils/iptables/patches/.svn/text-base/020-iptables-disable-modprobe.patch.svn-base18
-rw-r--r--package/network/utils/iptables/patches/.svn/text-base/030-no-libnfnetlink.patch.svn-base94
-rw-r--r--package/network/utils/iptables/patches/.svn/text-base/100-bash-location.patch.svn-base8
-rw-r--r--package/network/utils/iptables/patches/.svn/text-base/200-configurable_builtin.patch.svn-base62
-rw-r--r--package/network/utils/iptables/patches/.svn/text-base/300-musl_fixes.patch.svn-base139
-rw-r--r--package/network/utils/iptables/patches/.svn/text-base/400-lenient-restore.patch.svn-base176
-rw-r--r--package/network/utils/iptables/patches/002-layer7_2.22.patch371
-rw-r--r--package/network/utils/iptables/patches/010-use-old-linking.patch51
-rw-r--r--package/network/utils/iptables/patches/020-iptables-disable-modprobe.patch18
-rw-r--r--package/network/utils/iptables/patches/030-no-libnfnetlink.patch94
-rw-r--r--package/network/utils/iptables/patches/100-bash-location.patch8
-rw-r--r--package/network/utils/iptables/patches/200-configurable_builtin.patch62
-rw-r--r--package/network/utils/iptables/patches/300-musl_fixes.patch139
-rw-r--r--package/network/utils/iptables/patches/400-lenient-restore.patch176
-rw-r--r--package/network/utils/iputils/.svn/entries65
-rw-r--r--package/network/utils/iputils/.svn/text-base/Makefile.svn-base180
-rw-r--r--package/network/utils/iputils/Makefile180
-rw-r--r--package/network/utils/iputils/patches/.svn/entries198
-rw-r--r--package/network/utils/iputils/patches/.svn/text-base/001-iputils.patch.svn-base14
-rw-r--r--package/network/utils/iputils/patches/.svn/text-base/002-fix-ipv6.patch.svn-base14
-rw-r--r--package/network/utils/iputils/patches/.svn/text-base/003-fix-makefile.patch.svn-base18
-rw-r--r--package/network/utils/iputils/patches/.svn/text-base/010-ping6_uclibc_resolv.patch.svn-base200
-rw-r--r--package/network/utils/iputils/patches/.svn/text-base/011-ping6_use_gnu_source.patch.svn-base11
-rw-r--r--package/network/utils/iputils/patches/001-iputils.patch14
-rw-r--r--package/network/utils/iputils/patches/002-fix-ipv6.patch14
-rw-r--r--package/network/utils/iputils/patches/003-fix-makefile.patch18
-rw-r--r--package/network/utils/iputils/patches/010-ping6_uclibc_resolv.patch200
-rw-r--r--package/network/utils/iputils/patches/011-ping6_use_gnu_source.patch11
-rw-r--r--package/network/utils/iw/.svn/entries65
-rw-r--r--package/network/utils/iw/.svn/prop-base/Makefile.svn-base5
-rw-r--r--package/network/utils/iw/.svn/text-base/Makefile.svn-base56
-rw-r--r--package/network/utils/iw/Makefile56
-rw-r--r--package/network/utils/iw/patches/.svn/entries198
-rw-r--r--package/network/utils/iw/patches/.svn/text-base/001-nl80211_h_sync.patch.svn-base416
-rw-r--r--package/network/utils/iw/patches/.svn/text-base/100-rx_rate.patch.svn-base105
-rw-r--r--package/network/utils/iw/patches/.svn/text-base/110-per_chain_signal_strength.patch.svn-base71
-rw-r--r--package/network/utils/iw/patches/.svn/text-base/120-tdls_peer_indentation.patch.svn-base11
-rw-r--r--package/network/utils/iw/patches/.svn/text-base/130-antenna_gain.patch.svn-base34
-rw-r--r--package/network/utils/iw/patches/001-nl80211_h_sync.patch416
-rw-r--r--package/network/utils/iw/patches/100-rx_rate.patch105
-rw-r--r--package/network/utils/iw/patches/110-per_chain_signal_strength.patch71
-rw-r--r--package/network/utils/iw/patches/120-tdls_peer_indentation.patch11
-rw-r--r--package/network/utils/iw/patches/130-antenna_gain.patch34
-rw-r--r--package/network/utils/iwcap/.svn/entries65
-rw-r--r--package/network/utils/iwcap/.svn/text-base/Makefile.svn-base50
-rw-r--r--package/network/utils/iwcap/Makefile50
-rw-r--r--package/network/utils/iwcap/src/.svn/entries62
-rw-r--r--package/network/utils/iwcap/src/.svn/text-base/iwcap.c.svn-base582
-rw-r--r--package/network/utils/iwcap/src/iwcap.c582
-rw-r--r--package/network/utils/iwinfo/.svn/entries65
-rw-r--r--package/network/utils/iwinfo/.svn/text-base/Makefile.svn-base118
-rw-r--r--package/network/utils/iwinfo/Makefile118
-rw-r--r--package/network/utils/iwinfo/src/.svn/entries405
-rw-r--r--package/network/utils/iwinfo/src/.svn/text-base/COPYING.svn-base339
-rw-r--r--package/network/utils/iwinfo/src/.svn/text-base/Makefile.svn-base44
-rw-r--r--package/network/utils/iwinfo/src/.svn/text-base/iwinfo_cli.c.svn-base800
-rw-r--r--package/network/utils/iwinfo/src/.svn/text-base/iwinfo_lib.c.svn-base458
-rw-r--r--package/network/utils/iwinfo/src/.svn/text-base/iwinfo_lua.c.svn-base886
-rw-r--r--package/network/utils/iwinfo/src/.svn/text-base/iwinfo_madwifi.c.svn-base1082
-rw-r--r--package/network/utils/iwinfo/src/.svn/text-base/iwinfo_nl80211.c.svn-base2246
-rw-r--r--package/network/utils/iwinfo/src/.svn/text-base/iwinfo_utils.c.svn-base349
-rw-r--r--package/network/utils/iwinfo/src/.svn/text-base/iwinfo_wext.c.svn-base520
-rw-r--r--package/network/utils/iwinfo/src/.svn/text-base/iwinfo_wext_scan.c.svn-base527
-rw-r--r--package/network/utils/iwinfo/src/.svn/text-base/iwinfo_wl.c.svn-base645
-rw-r--r--package/network/utils/iwinfo/src/COPYING339
-rw-r--r--package/network/utils/iwinfo/src/Makefile44
-rw-r--r--package/network/utils/iwinfo/src/include/.svn/entries65
-rw-r--r--package/network/utils/iwinfo/src/include/.svn/text-base/iwinfo.h.svn-base195
-rw-r--r--package/network/utils/iwinfo/src/include/iwinfo.h195
-rw-r--r--package/network/utils/iwinfo/src/include/iwinfo/.svn/entries269
-rw-r--r--package/network/utils/iwinfo/src/include/iwinfo/.svn/text-base/lua.h.svn-base80
-rw-r--r--package/network/utils/iwinfo/src/include/iwinfo/.svn/text-base/madwifi.h.svn-base83
-rw-r--r--package/network/utils/iwinfo/src/include/iwinfo/.svn/text-base/nl80211.h.svn-base125
-rw-r--r--package/network/utils/iwinfo/src/include/iwinfo/.svn/text-base/utils.h.svn-base47
-rw-r--r--package/network/utils/iwinfo/src/include/iwinfo/.svn/text-base/wext.h.svn-base84
-rw-r--r--package/network/utils/iwinfo/src/include/iwinfo/.svn/text-base/wext_scan.h.svn-base380
-rw-r--r--package/network/utils/iwinfo/src/include/iwinfo/.svn/text-base/wl.h.svn-base84
-rw-r--r--package/network/utils/iwinfo/src/include/iwinfo/api/.svn/entries164
-rw-r--r--package/network/utils/iwinfo/src/include/iwinfo/api/.svn/text-base/broadcom.h.svn-base131
-rw-r--r--package/network/utils/iwinfo/src/include/iwinfo/api/.svn/text-base/madwifi.h.svn-base160
-rw-r--r--package/network/utils/iwinfo/src/include/iwinfo/api/.svn/text-base/nl80211.h.svn-base2834
-rw-r--r--package/network/utils/iwinfo/src/include/iwinfo/api/.svn/text-base/wext.h.svn-base1139
-rw-r--r--package/network/utils/iwinfo/src/include/iwinfo/api/broadcom.h131
-rw-r--r--package/network/utils/iwinfo/src/include/iwinfo/api/madwifi.h160
-rw-r--r--package/network/utils/iwinfo/src/include/iwinfo/api/nl80211.h2834
-rw-r--r--package/network/utils/iwinfo/src/include/iwinfo/api/wext.h1139
-rw-r--r--package/network/utils/iwinfo/src/include/iwinfo/lua.h80
-rw-r--r--package/network/utils/iwinfo/src/include/iwinfo/madwifi.h83
-rw-r--r--package/network/utils/iwinfo/src/include/iwinfo/nl80211.h125
-rw-r--r--package/network/utils/iwinfo/src/include/iwinfo/utils.h47
-rw-r--r--package/network/utils/iwinfo/src/include/iwinfo/wext.h84
-rw-r--r--package/network/utils/iwinfo/src/include/iwinfo/wext_scan.h380
-rw-r--r--package/network/utils/iwinfo/src/include/iwinfo/wl.h84
-rw-r--r--package/network/utils/iwinfo/src/iwinfo_cli.c800
-rw-r--r--package/network/utils/iwinfo/src/iwinfo_lib.c458
-rw-r--r--package/network/utils/iwinfo/src/iwinfo_lua.c886
-rw-r--r--package/network/utils/iwinfo/src/iwinfo_madwifi.c1082
-rw-r--r--package/network/utils/iwinfo/src/iwinfo_nl80211.c2246
-rw-r--r--package/network/utils/iwinfo/src/iwinfo_utils.c349
-rw-r--r--package/network/utils/iwinfo/src/iwinfo_wext.c520
-rw-r--r--package/network/utils/iwinfo/src/iwinfo_wext_scan.c527
-rw-r--r--package/network/utils/iwinfo/src/iwinfo_wl.c645
-rw-r--r--package/network/utils/maccalc/.svn/entries65
-rw-r--r--package/network/utils/maccalc/.svn/prop-base/Makefile.svn-base5
-rw-r--r--package/network/utils/maccalc/.svn/text-base/Makefile.svn-base47
-rw-r--r--package/network/utils/maccalc/Makefile47
-rw-r--r--package/network/utils/maccalc/src/.svn/entries96
-rw-r--r--package/network/utils/maccalc/src/.svn/prop-base/Makefile.svn-base5
-rw-r--r--package/network/utils/maccalc/src/.svn/prop-base/main.c.svn-base5
-rw-r--r--package/network/utils/maccalc/src/.svn/text-base/Makefile.svn-base14
-rw-r--r--package/network/utils/maccalc/src/.svn/text-base/main.c.svn-base256
-rw-r--r--package/network/utils/maccalc/src/Makefile14
-rw-r--r--package/network/utils/maccalc/src/main.c256
-rw-r--r--package/network/utils/owipcalc/.svn/entries65
-rw-r--r--package/network/utils/owipcalc/.svn/text-base/Makefile.svn-base49
-rw-r--r--package/network/utils/owipcalc/Makefile49
-rw-r--r--package/network/utils/owipcalc/src/.svn/entries62
-rw-r--r--package/network/utils/owipcalc/src/.svn/text-base/owipcalc.c.svn-base951
-rw-r--r--package/network/utils/owipcalc/src/owipcalc.c951
-rw-r--r--package/network/utils/resolveip/.svn/entries65
-rw-r--r--package/network/utils/resolveip/.svn/text-base/Makefile.svn-base45
-rw-r--r--package/network/utils/resolveip/Makefile45
-rw-r--r--package/network/utils/resolveip/src/.svn/entries62
-rw-r--r--package/network/utils/resolveip/src/.svn/text-base/resolveip.c.svn-base98
-rw-r--r--package/network/utils/resolveip/src/resolveip.c98
-rw-r--r--package/network/utils/rssileds/.svn/entries68
-rw-r--r--package/network/utils/rssileds/.svn/prop-base/Makefile.svn-base5
-rw-r--r--package/network/utils/rssileds/.svn/text-base/Makefile.svn-base48
-rw-r--r--package/network/utils/rssileds/Makefile48
-rw-r--r--package/network/utils/rssileds/files/.svn/entries62
-rw-r--r--package/network/utils/rssileds/files/.svn/text-base/rssileds.init.svn-base75
-rw-r--r--package/network/utils/rssileds/files/rssileds.init75
-rw-r--r--package/network/utils/rssileds/src/.svn/entries62
-rw-r--r--package/network/utils/rssileds/src/.svn/prop-base/rssileds.c.svn-base5
-rw-r--r--package/network/utils/rssileds/src/.svn/text-base/rssileds.c.svn-base290
-rw-r--r--package/network/utils/rssileds/src/rssileds.c290
-rw-r--r--package/network/utils/tcpdump/.svn/entries65
-rw-r--r--package/network/utils/tcpdump/.svn/prop-base/Makefile.svn-base13
-rw-r--r--package/network/utils/tcpdump/.svn/text-base/Makefile.svn-base89
-rw-r--r--package/network/utils/tcpdump/Makefile89
-rw-r--r--package/network/utils/tcpdump/patches/.svn/entries164
-rw-r--r--package/network/utils/tcpdump/patches/.svn/prop-base/001-remove_pcap_debug.patch.svn-base5
-rw-r--r--package/network/utils/tcpdump/patches/.svn/text-base/001-remove_pcap_debug.patch.svn-base23
-rw-r--r--package/network/utils/tcpdump/patches/.svn/text-base/002-remove_static_libpcap_check.patch.svn-base77
-rw-r--r--package/network/utils/tcpdump/patches/.svn/text-base/004-fix_3g_iface.patch.svn-base28
-rw-r--r--package/network/utils/tcpdump/patches/.svn/text-base/100-tcpdump_mini.patch.svn-base763
-rw-r--r--package/network/utils/tcpdump/patches/001-remove_pcap_debug.patch23
-rw-r--r--package/network/utils/tcpdump/patches/002-remove_static_libpcap_check.patch77
-rw-r--r--package/network/utils/tcpdump/patches/004-fix_3g_iface.patch28
-rw-r--r--package/network/utils/tcpdump/patches/100-tcpdump_mini.patch763
-rw-r--r--package/network/utils/wireless-tools/.svn/entries65
-rw-r--r--package/network/utils/wireless-tools/.svn/prop-base/Makefile.svn-base9
-rw-r--r--package/network/utils/wireless-tools/.svn/text-base/Makefile.svn-base91
-rw-r--r--package/network/utils/wireless-tools/Makefile91
-rw-r--r--package/network/utils/wireless-tools/patches/.svn/entries164
-rw-r--r--package/network/utils/wireless-tools/patches/.svn/prop-base/001-debian.patch.svn-base5
-rw-r--r--package/network/utils/wireless-tools/patches/.svn/text-base/001-debian.patch.svn-base35
-rw-r--r--package/network/utils/wireless-tools/patches/.svn/text-base/002-fix-iwconfig-power-argument-parsing.patch.svn-base13
-rw-r--r--package/network/utils/wireless-tools/patches/.svn/text-base/003-we_essential_def.patch.svn-base359
-rw-r--r--package/network/utils/wireless-tools/patches/.svn/text-base/004-increase_iwlist_buffer.patch.svn-base46
-rw-r--r--package/network/utils/wireless-tools/patches/001-debian.patch35
-rw-r--r--package/network/utils/wireless-tools/patches/002-fix-iwconfig-power-argument-parsing.patch13
-rw-r--r--package/network/utils/wireless-tools/patches/003-we_essential_def.patch359
-rw-r--r--package/network/utils/wireless-tools/patches/004-increase_iwlist_buffer.patch46
-rw-r--r--package/network/utils/xtables-addons/.svn/entries68
-rw-r--r--package/network/utils/xtables-addons/.svn/text-base/Makefile.svn-base160
-rw-r--r--package/network/utils/xtables-addons/Makefile160
-rw-r--r--package/network/utils/xtables-addons/patches-1.x/.svn/entries300
-rw-r--r--package/network/utils/xtables-addons/patches-1.x/.svn/text-base/001-no_depmod.patch.svn-base16
-rw-r--r--package/network/utils/xtables-addons/patches-1.x/.svn/text-base/002-fix-kernel-version-detection.patch.svn-base22
-rw-r--r--package/network/utils/xtables-addons/patches-1.x/.svn/text-base/003-redundant-bracket.patch.svn-base11
-rw-r--r--package/network/utils/xtables-addons/patches-1.x/.svn/text-base/100-add-rtsp-conntrack.patch.svn-base1334
-rw-r--r--package/network/utils/xtables-addons/patches-1.x/.svn/text-base/101-rtsp-linux-3.6-compat.patch.svn-base22
-rw-r--r--package/network/utils/xtables-addons/patches-1.x/.svn/text-base/200-add-lua-packetscript.patch.svn-base18230
-rw-r--r--package/network/utils/xtables-addons/patches-1.x/.svn/text-base/201-fix-lua-packetscript.patch.svn-base89
-rw-r--r--package/network/utils/xtables-addons/patches-1.x/.svn/text-base/300-geoip-endian-detection.patch.svn-base18
-rw-r--r--package/network/utils/xtables-addons/patches-1.x/001-no_depmod.patch16
-rw-r--r--package/network/utils/xtables-addons/patches-1.x/002-fix-kernel-version-detection.patch22
-rw-r--r--package/network/utils/xtables-addons/patches-1.x/003-redundant-bracket.patch11
-rw-r--r--package/network/utils/xtables-addons/patches-1.x/100-add-rtsp-conntrack.patch1334
-rw-r--r--package/network/utils/xtables-addons/patches-1.x/101-rtsp-linux-3.6-compat.patch22
-rw-r--r--package/network/utils/xtables-addons/patches-1.x/200-add-lua-packetscript.patch18230
-rw-r--r--package/network/utils/xtables-addons/patches-1.x/201-fix-lua-packetscript.patch89
-rw-r--r--package/network/utils/xtables-addons/patches-1.x/300-geoip-endian-detection.patch18
-rw-r--r--package/network/utils/xtables-addons/patches/.svn/entries334
-rw-r--r--package/network/utils/xtables-addons/patches/.svn/text-base/001-no_depmod.patch.svn-base16
-rw-r--r--package/network/utils/xtables-addons/patches/.svn/text-base/002-fix-kernel-version-detection.patch.svn-base22
-rw-r--r--package/network/utils/xtables-addons/patches/.svn/text-base/100-add-rtsp-conntrack.patch.svn-base1334
-rw-r--r--package/network/utils/xtables-addons/patches/.svn/text-base/101-rtsp-linux-3.6-compat.patch.svn-base22
-rw-r--r--package/network/utils/xtables-addons/patches/.svn/text-base/102-rtsp-linux-3.7-compat.patch.svn-base155
-rw-r--r--package/network/utils/xtables-addons/patches/.svn/text-base/200-add-lua-packetscript.patch.svn-base18230
-rw-r--r--package/network/utils/xtables-addons/patches/.svn/text-base/201-fix-lua-packetscript.patch.svn-base89
-rw-r--r--package/network/utils/xtables-addons/patches/.svn/text-base/300-geoip-endian-detection.patch.svn-base18
-rw-r--r--package/network/utils/xtables-addons/patches/.svn/text-base/400-uid-gid-linux-3.7-compat.patch.svn-base83
-rw-r--r--package/network/utils/xtables-addons/patches/001-no_depmod.patch16
-rw-r--r--package/network/utils/xtables-addons/patches/002-fix-kernel-version-detection.patch22
-rw-r--r--package/network/utils/xtables-addons/patches/100-add-rtsp-conntrack.patch1334
-rw-r--r--package/network/utils/xtables-addons/patches/101-rtsp-linux-3.6-compat.patch22
-rw-r--r--package/network/utils/xtables-addons/patches/102-rtsp-linux-3.7-compat.patch155
-rw-r--r--package/network/utils/xtables-addons/patches/200-add-lua-packetscript.patch18230
-rw-r--r--package/network/utils/xtables-addons/patches/201-fix-lua-packetscript.patch89
-rw-r--r--package/network/utils/xtables-addons/patches/300-geoip-endian-detection.patch18
-rw-r--r--package/network/utils/xtables-addons/patches/400-uid-gid-linux-3.7-compat.patch83
-rw-r--r--package/opkg/.svn/entries68
-rw-r--r--package/opkg/.svn/text-base/Makefile.svn-base102
-rw-r--r--package/opkg/Makefile102
-rw-r--r--package/opkg/files/.svn/entries62
-rw-r--r--package/opkg/files/.svn/text-base/opkg.conf.svn-base5
-rw-r--r--package/opkg/files/opkg.conf5
-rw-r--r--package/opkg/patches/.svn/entries504
-rw-r--r--package/opkg/patches/.svn/text-base/001-ship-pkg-m4.patch.svn-base168
-rw-r--r--package/opkg/patches/.svn/text-base/002-no-shave.patch.svn-base37
-rw-r--r--package/opkg/patches/.svn/text-base/004-host_cpu.patch.svn-base20
-rw-r--r--package/opkg/patches/.svn/text-base/007-force_static.patch.svn-base71
-rw-r--r--package/opkg/patches/.svn/text-base/009-remove-upgrade-all.patch.svn-base41
-rw-r--r--package/opkg/patches/.svn/text-base/011-old-config-location.patch.svn-base12
-rw-r--r--package/opkg/patches/.svn/text-base/012-strip-trailing-conffiles-whitespace.patch.svn-base23
-rw-r--r--package/opkg/patches/.svn/text-base/014-errors-to-stderr.patch.svn-base15
-rw-r--r--package/opkg/patches/.svn/text-base/020-avoid_getline.patch.svn-base317
-rw-r--r--package/opkg/patches/.svn/text-base/030-fix-double-free.patch.svn-base10
-rw-r--r--package/opkg/patches/.svn/text-base/040-wrap-descriptions-only-on-ttys.patch.svn-base31
-rw-r--r--package/opkg/patches/.svn/text-base/050-add-case-insensitive-flag.patch.svn-base169
-rw-r--r--package/opkg/patches/.svn/text-base/060-add-find-command.patch.svn-base58
-rw-r--r--package/opkg/patches/.svn/text-base/070-use_gzipped_pkg_list.patch.svn-base120
-rw-r--r--package/opkg/patches/001-ship-pkg-m4.patch168
-rw-r--r--package/opkg/patches/002-no-shave.patch37
-rw-r--r--package/opkg/patches/004-host_cpu.patch20
-rw-r--r--package/opkg/patches/007-force_static.patch71
-rw-r--r--package/opkg/patches/009-remove-upgrade-all.patch41
-rw-r--r--package/opkg/patches/011-old-config-location.patch12
-rw-r--r--package/opkg/patches/012-strip-trailing-conffiles-whitespace.patch23
-rw-r--r--package/opkg/patches/014-errors-to-stderr.patch15
-rw-r--r--package/opkg/patches/020-avoid_getline.patch317
-rw-r--r--package/opkg/patches/030-fix-double-free.patch10
-rw-r--r--package/opkg/patches/040-wrap-descriptions-only-on-ttys.patch31
-rw-r--r--package/opkg/patches/050-add-case-insensitive-flag.patch169
-rw-r--r--package/opkg/patches/060-add-find-command.patch58
-rw-r--r--package/opkg/patches/070-use_gzipped_pkg_list.patch120
-rw-r--r--package/platform/.svn/entries31
-rw-r--r--package/platform/lantiq/.svn/entries73
-rw-r--r--package/platform/lantiq/ltq-adsl-app/.svn/entries99
-rw-r--r--package/platform/lantiq/ltq-adsl-app/.svn/text-base/Config.in.svn-base9
-rw-r--r--package/platform/lantiq/ltq-adsl-app/.svn/text-base/Makefile.svn-base98
-rw-r--r--package/platform/lantiq/ltq-adsl-app/Config.in9
-rw-r--r--package/platform/lantiq/ltq-adsl-app/Makefile98
-rw-r--r--package/platform/lantiq/ltq-adsl-app/files/.svn/entries96
-rw-r--r--package/platform/lantiq/ltq-adsl-app/files/.svn/text-base/dsl_control.svn-base311
-rw-r--r--package/platform/lantiq/ltq-adsl-app/files/.svn/text-base/dsl_notify.sh.svn-base44
-rw-r--r--package/platform/lantiq/ltq-adsl-app/files/dsl_control311
-rw-r--r--package/platform/lantiq/ltq-adsl-app/files/dsl_notify.sh44
-rw-r--r--package/platform/lantiq/ltq-adsl-fw/.svn/entries62
-rw-r--r--package/platform/lantiq/ltq-adsl-fw/.svn/text-base/Makefile.svn-base55
-rw-r--r--package/platform/lantiq/ltq-adsl-fw/Makefile55
-rw-r--r--package/platform/lantiq/ltq-adsl-mei/.svn/entries65
-rw-r--r--package/platform/lantiq/ltq-adsl-mei/.svn/text-base/Makefile.svn-base49
-rw-r--r--package/platform/lantiq/ltq-adsl-mei/Makefile49
-rw-r--r--package/platform/lantiq/ltq-adsl-mei/src/.svn/entries130
-rw-r--r--package/platform/lantiq/ltq-adsl-mei/src/.svn/text-base/Makefile.svn-base17
-rw-r--r--package/platform/lantiq/ltq-adsl-mei/src/.svn/text-base/ifxmips_mei_interface.h.svn-base702
-rw-r--r--package/platform/lantiq/ltq-adsl-mei/src/.svn/text-base/lantiq_mei.c.svn-base2805
-rw-r--r--package/platform/lantiq/ltq-adsl-mei/src/Makefile17
-rw-r--r--package/platform/lantiq/ltq-adsl-mei/src/ifxmips_mei_interface.h702
-rw-r--r--package/platform/lantiq/ltq-adsl-mei/src/lantiq_mei.c2805
-rw-r--r--package/platform/lantiq/ltq-adsl/.svn/entries99
-rw-r--r--package/platform/lantiq/ltq-adsl/.svn/text-base/Config.in.svn-base5
-rw-r--r--package/platform/lantiq/ltq-adsl/.svn/text-base/Makefile.svn-base96
-rw-r--r--package/platform/lantiq/ltq-adsl/Config.in5
-rw-r--r--package/platform/lantiq/ltq-adsl/Makefile96
-rw-r--r--package/platform/lantiq/ltq-adsl/patches/.svn/entries164
-rw-r--r--package/platform/lantiq/ltq-adsl/patches/.svn/text-base/100-dsl_compat.patch.svn-base1065
-rw-r--r--package/platform/lantiq/ltq-adsl/patches/.svn/text-base/110-fix_status_polling_loop.patch.svn-base11
-rw-r--r--package/platform/lantiq/ltq-adsl/patches/.svn/text-base/120-platform.patch.svn-base72
-rw-r--r--package/platform/lantiq/ltq-adsl/patches/.svn/text-base/130-linux3.8.patch.svn-base152
-rw-r--r--package/platform/lantiq/ltq-adsl/patches/100-dsl_compat.patch1065
-rw-r--r--package/platform/lantiq/ltq-adsl/patches/110-fix_status_polling_loop.patch11
-rw-r--r--package/platform/lantiq/ltq-adsl/patches/120-platform.patch72
-rw-r--r--package/platform/lantiq/ltq-adsl/patches/130-linux3.8.patch152
-rw-r--r--package/platform/lantiq/ltq-atm/.svn/entries65
-rw-r--r--package/platform/lantiq/ltq-atm/.svn/text-base/Makefile.svn-base51
-rw-r--r--package/platform/lantiq/ltq-atm/Makefile51
-rw-r--r--package/platform/lantiq/ltq-atm/src/.svn/entries810
-rw-r--r--package/platform/lantiq/ltq-atm/src/.svn/text-base/Makefile.svn-base23
-rw-r--r--package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_amazon_se.c.svn-base341
-rw-r--r--package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_ar9.c.svn-base244
-rw-r--r--package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_core.h.svn-base245
-rw-r--r--package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_danube.c.svn-base231
-rw-r--r--package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_fw_amazon_se.h.svn-base457
-rw-r--r--package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_fw_ar9.h.svn-base439
-rw-r--r--package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_fw_ar9_retx.h.svn-base611
-rw-r--r--package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_fw_danube.h.svn-base442
-rw-r--r--package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_fw_danube_retx.h.svn-base612
-rw-r--r--package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_fw_regs_amazon_se.h.svn-base57
-rw-r--r--package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_fw_regs_ar9.h.svn-base172
-rw-r--r--package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_fw_regs_common.h.svn-base549
-rw-r--r--package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_fw_regs_danube.h.svn-base51
-rw-r--r--package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_fw_regs_vr9.h.svn-base72
-rw-r--r--package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_fw_vr9.h.svn-base427
-rw-r--r--package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_ppe_amazon_se.h.svn-base121
-rw-r--r--package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_ppe_ar9.h.svn-base188
-rw-r--r--package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_ppe_common.h.svn-base368
-rw-r--r--package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_ppe_danube.h.svn-base129
-rw-r--r--package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_ppe_vr9.h.svn-base192
-rw-r--r--package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_vr9.c.svn-base190
-rw-r--r--package/platform/lantiq/ltq-atm/src/.svn/text-base/ltq_atm.c.svn-base1897
-rw-r--r--package/platform/lantiq/ltq-atm/src/Makefile23
-rw-r--r--package/platform/lantiq/ltq-atm/src/ifxmips_atm_amazon_se.c341
-rw-r--r--package/platform/lantiq/ltq-atm/src/ifxmips_atm_ar9.c244
-rw-r--r--package/platform/lantiq/ltq-atm/src/ifxmips_atm_core.h245
-rw-r--r--package/platform/lantiq/ltq-atm/src/ifxmips_atm_danube.c231
-rw-r--r--package/platform/lantiq/ltq-atm/src/ifxmips_atm_fw_amazon_se.h457
-rw-r--r--package/platform/lantiq/ltq-atm/src/ifxmips_atm_fw_ar9.h439
-rw-r--r--package/platform/lantiq/ltq-atm/src/ifxmips_atm_fw_ar9_retx.h611
-rw-r--r--package/platform/lantiq/ltq-atm/src/ifxmips_atm_fw_danube.h442
-rw-r--r--package/platform/lantiq/ltq-atm/src/ifxmips_atm_fw_danube_retx.h612
-rw-r--r--package/platform/lantiq/ltq-atm/src/ifxmips_atm_fw_regs_amazon_se.h57
-rw-r--r--package/platform/lantiq/ltq-atm/src/ifxmips_atm_fw_regs_ar9.h172
-rw-r--r--package/platform/lantiq/ltq-atm/src/ifxmips_atm_fw_regs_common.h549
-rw-r--r--package/platform/lantiq/ltq-atm/src/ifxmips_atm_fw_regs_danube.h51
-rw-r--r--package/platform/lantiq/ltq-atm/src/ifxmips_atm_fw_regs_vr9.h72
-rw-r--r--package/platform/lantiq/ltq-atm/src/ifxmips_atm_fw_vr9.h427
-rw-r--r--package/platform/lantiq/ltq-atm/src/ifxmips_atm_ppe_amazon_se.h121
-rw-r--r--package/platform/lantiq/ltq-atm/src/ifxmips_atm_ppe_ar9.h188
-rw-r--r--package/platform/lantiq/ltq-atm/src/ifxmips_atm_ppe_common.h368
-rw-r--r--package/platform/lantiq/ltq-atm/src/ifxmips_atm_ppe_danube.h129
-rw-r--r--package/platform/lantiq/ltq-atm/src/ifxmips_atm_ppe_vr9.h192
-rw-r--r--package/platform/lantiq/ltq-atm/src/ifxmips_atm_vr9.c190
-rw-r--r--package/platform/lantiq/ltq-atm/src/ltq_atm.c1897
-rw-r--r--package/platform/lantiq/ltq-deu/.svn/entries65
-rw-r--r--package/platform/lantiq/ltq-deu/.svn/text-base/Makefile.svn-base49
-rw-r--r--package/platform/lantiq/ltq-deu/Makefile49
-rw-r--r--package/platform/lantiq/ltq-deu/src/.svn/entries844
-rw-r--r--package/platform/lantiq/ltq-deu/src/.svn/text-base/Makefile.svn-base26
-rw-r--r--package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_aes.c.svn-base904
-rw-r--r--package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_arc4.c.svn-base389
-rw-r--r--package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_async_aes.c.svn-base1137
-rw-r--r--package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_async_des.c.svn-base954
-rw-r--r--package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_des.c.svn-base768
-rw-r--r--package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_deu.c.svn-base210
-rw-r--r--package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_deu.h.svn-base232
-rw-r--r--package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_deu_ar9.c.svn-base135
-rw-r--r--package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_deu_ar9.h.svn-base299
-rw-r--r--package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_deu_danube.c.svn-base168
-rw-r--r--package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_deu_danube.h.svn-base250
-rw-r--r--package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_deu_dma.c.svn-base42
-rw-r--r--package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_deu_dma.h.svn-base69
-rw-r--r--package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_deu_vr9.c.svn-base144
-rw-r--r--package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_deu_vr9.h.svn-base324
-rw-r--r--package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_md5.c.svn-base310
-rw-r--r--package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_md5_hmac.c.svn-base386
-rw-r--r--package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_sha1.c.svn-base301
-rw-r--r--package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_sha1_hmac.c.svn-base378
-rw-r--r--package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_tcrypt.h.svn-base92
-rw-r--r--package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_testmgr.h.svn-base9598
-rw-r--r--package/platform/lantiq/ltq-deu/src/.svn/text-base/internal.h.svn-base141
-rw-r--r--package/platform/lantiq/ltq-deu/src/.svn/text-base/ltq_deu_testmgr.c.svn-base3957
-rw-r--r--package/platform/lantiq/ltq-deu/src/Makefile26
-rw-r--r--package/platform/lantiq/ltq-deu/src/ifxmips_aes.c904
-rw-r--r--package/platform/lantiq/ltq-deu/src/ifxmips_arc4.c389
-rw-r--r--package/platform/lantiq/ltq-deu/src/ifxmips_async_aes.c1137
-rw-r--r--package/platform/lantiq/ltq-deu/src/ifxmips_async_des.c954
-rw-r--r--package/platform/lantiq/ltq-deu/src/ifxmips_des.c768
-rw-r--r--package/platform/lantiq/ltq-deu/src/ifxmips_deu.c210
-rw-r--r--package/platform/lantiq/ltq-deu/src/ifxmips_deu.h232
-rw-r--r--package/platform/lantiq/ltq-deu/src/ifxmips_deu_ar9.c135
-rw-r--r--package/platform/lantiq/ltq-deu/src/ifxmips_deu_ar9.h299
-rw-r--r--package/platform/lantiq/ltq-deu/src/ifxmips_deu_danube.c168
-rw-r--r--package/platform/lantiq/ltq-deu/src/ifxmips_deu_danube.h250
-rw-r--r--package/platform/lantiq/ltq-deu/src/ifxmips_deu_dma.c42
-rw-r--r--package/platform/lantiq/ltq-deu/src/ifxmips_deu_dma.h69
-rw-r--r--package/platform/lantiq/ltq-deu/src/ifxmips_deu_vr9.c144
-rw-r--r--package/platform/lantiq/ltq-deu/src/ifxmips_deu_vr9.h324
-rw-r--r--package/platform/lantiq/ltq-deu/src/ifxmips_md5.c310
-rw-r--r--package/platform/lantiq/ltq-deu/src/ifxmips_md5_hmac.c386
-rw-r--r--package/platform/lantiq/ltq-deu/src/ifxmips_sha1.c301
-rw-r--r--package/platform/lantiq/ltq-deu/src/ifxmips_sha1_hmac.c378
-rw-r--r--package/platform/lantiq/ltq-deu/src/ifxmips_tcrypt.h92
-rw-r--r--package/platform/lantiq/ltq-deu/src/ifxmips_testmgr.h9598
-rw-r--r--package/platform/lantiq/ltq-deu/src/internal.h141
-rw-r--r--package/platform/lantiq/ltq-deu/src/ltq_deu_testmgr.c3957
-rw-r--r--package/platform/lantiq/ltq-hcd/.svn/entries65
-rw-r--r--package/platform/lantiq/ltq-hcd/.svn/text-base/Makefile.svn-base53
-rw-r--r--package/platform/lantiq/ltq-hcd/Makefile53
-rw-r--r--package/platform/lantiq/ltq-hcd/src/.svn/entries606
-rw-r--r--package/platform/lantiq/ltq-hcd/src/.svn/text-base/Kconfig.svn-base104
-rw-r--r--package/platform/lantiq/ltq-hcd/src/.svn/text-base/Makefile.svn-base74
-rw-r--r--package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxhcd.c.svn-base2141
-rw-r--r--package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxhcd.h.svn-base758
-rw-r--r--package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxhcd_es.c.svn-base599
-rw-r--r--package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxhcd_intr.c.svn-base4844
-rw-r--r--package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxhcd_queue.c.svn-base485
-rw-r--r--package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxusb_cif.c.svn-base1686
-rw-r--r--package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxusb_cif.h.svn-base767
-rw-r--r--package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxusb_cif_d.c.svn-base535
-rw-r--r--package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxusb_cif_h.c.svn-base1599
-rw-r--r--package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxusb_ctl.c.svn-base3825
-rw-r--r--package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxusb_driver.c.svn-base1286
-rw-r--r--package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxusb_host.ko.svn-basebin0 -> 181257 bytes
-rw-r--r--package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxusb_plat.h.svn-base1184
-rw-r--r--package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxusb_regs.h.svn-base1471
-rw-r--r--package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxusb_version.h.svn-base5
-rw-r--r--package/platform/lantiq/ltq-hcd/src/Kconfig104
-rw-r--r--package/platform/lantiq/ltq-hcd/src/Makefile74
-rw-r--r--package/platform/lantiq/ltq-hcd/src/ifxhcd.c2141
-rw-r--r--package/platform/lantiq/ltq-hcd/src/ifxhcd.h758
-rw-r--r--package/platform/lantiq/ltq-hcd/src/ifxhcd_es.c599
-rw-r--r--package/platform/lantiq/ltq-hcd/src/ifxhcd_intr.c4844
-rw-r--r--package/platform/lantiq/ltq-hcd/src/ifxhcd_queue.c485
-rw-r--r--package/platform/lantiq/ltq-hcd/src/ifxusb_cif.c1686
-rw-r--r--package/platform/lantiq/ltq-hcd/src/ifxusb_cif.h767
-rw-r--r--package/platform/lantiq/ltq-hcd/src/ifxusb_cif_d.c535
-rw-r--r--package/platform/lantiq/ltq-hcd/src/ifxusb_cif_h.c1599
-rw-r--r--package/platform/lantiq/ltq-hcd/src/ifxusb_ctl.c3825
-rw-r--r--package/platform/lantiq/ltq-hcd/src/ifxusb_driver.c1286
-rw-r--r--package/platform/lantiq/ltq-hcd/src/ifxusb_host.kobin0 -> 181257 bytes
-rw-r--r--package/platform/lantiq/ltq-hcd/src/ifxusb_plat.h1184
-rw-r--r--package/platform/lantiq/ltq-hcd/src/ifxusb_regs.h1471
-rw-r--r--package/platform/lantiq/ltq-hcd/src/ifxusb_version.h5
-rw-r--r--package/platform/lantiq/ltq-ifxos/.svn/entries65
-rw-r--r--package/platform/lantiq/ltq-ifxos/.svn/text-base/Makefile.svn-base51
-rw-r--r--package/platform/lantiq/ltq-ifxos/Makefile51
-rw-r--r--package/platform/lantiq/ltq-ifxos/patches/.svn/entries62
-rw-r--r--package/platform/lantiq/ltq-ifxos/patches/.svn/text-base/100-compat.patch.svn-base96
-rw-r--r--package/platform/lantiq/ltq-ifxos/patches/100-compat.patch96
-rw-r--r--package/platform/lantiq/ltq-ptm/.svn/entries65
-rw-r--r--package/platform/lantiq/ltq-ptm/.svn/text-base/Makefile.svn-base52
-rw-r--r--package/platform/lantiq/ltq-ptm/Makefile52
-rw-r--r--package/platform/lantiq/ltq-ptm/src/.svn/entries912
-rw-r--r--package/platform/lantiq/ltq-ptm/src/.svn/text-base/Makefile.svn-base23
-rw-r--r--package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_adsl.c.svn-base1551
-rw-r--r--package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_adsl.h.svn-base137
-rw-r--r--package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_amazon_se.c.svn-base322
-rw-r--r--package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_ar9.c.svn-base376
-rw-r--r--package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_common.h.svn-base102
-rw-r--r--package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_danube.c.svn-base317
-rw-r--r--package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_fw_amazon_se.h.svn-base493
-rw-r--r--package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_fw_ar9.h.svn-base473
-rw-r--r--package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_fw_danube.h.svn-base489
-rw-r--r--package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_fw_regs_adsl.h.svn-base284
-rw-r--r--package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_fw_regs_amazon_se.h.svn-base48
-rw-r--r--package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_fw_regs_ar9.h.svn-base48
-rw-r--r--package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_fw_regs_danube.h.svn-base48
-rw-r--r--package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_fw_regs_vdsl.h.svn-base278
-rw-r--r--package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_fw_regs_vr9.h.svn-base90
-rw-r--r--package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_fw_vr9.h.svn-base380
-rw-r--r--package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_ppe_amazon_se.h.svn-base186
-rw-r--r--package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_ppe_ar9.h.svn-base213
-rw-r--r--package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_ppe_common.h.svn-base311
-rw-r--r--package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_ppe_danube.h.svn-base135
-rw-r--r--package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_ppe_vr9.h.svn-base205
-rw-r--r--package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_test.c.svn-base943
-rw-r--r--package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_vdsl.c.svn-base1080
-rw-r--r--package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_vdsl.h.svn-base126
-rw-r--r--package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_vr9.c.svn-base295
-rw-r--r--package/platform/lantiq/ltq-ptm/src/Makefile23
-rw-r--r--package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_adsl.c1551
-rw-r--r--package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_adsl.h137
-rw-r--r--package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_amazon_se.c322
-rw-r--r--package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_ar9.c376
-rw-r--r--package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_common.h102
-rw-r--r--package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_danube.c317
-rw-r--r--package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_fw_amazon_se.h493
-rw-r--r--package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_fw_ar9.h473
-rw-r--r--package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_fw_danube.h489
-rw-r--r--package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_fw_regs_adsl.h284
-rw-r--r--package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_fw_regs_amazon_se.h48
-rw-r--r--package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_fw_regs_ar9.h48
-rw-r--r--package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_fw_regs_danube.h48
-rw-r--r--package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_fw_regs_vdsl.h278
-rw-r--r--package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_fw_regs_vr9.h90
-rw-r--r--package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_fw_vr9.h380
-rw-r--r--package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_ppe_amazon_se.h186
-rw-r--r--package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_ppe_ar9.h213
-rw-r--r--package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_ppe_common.h311
-rw-r--r--package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_ppe_danube.h135
-rw-r--r--package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_ppe_vr9.h205
-rw-r--r--package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_test.c943
-rw-r--r--package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_vdsl.c1080
-rw-r--r--package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_vdsl.h126
-rw-r--r--package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_vr9.c295
-rw-r--r--package/platform/lantiq/ltq-tapi/.svn/entries99
-rw-r--r--package/platform/lantiq/ltq-tapi/.svn/text-base/Config.in.svn-base88
-rw-r--r--package/platform/lantiq/ltq-tapi/.svn/text-base/Makefile.svn-base70
-rw-r--r--package/platform/lantiq/ltq-tapi/Config.in88
-rw-r--r--package/platform/lantiq/ltq-tapi/Makefile70
-rw-r--r--package/platform/lantiq/ltq-tapi/patches/.svn/entries130
-rw-r--r--package/platform/lantiq/ltq-tapi/patches/.svn/text-base/000-portability.patch.svn-base82
-rw-r--r--package/platform/lantiq/ltq-tapi/patches/.svn/text-base/100-ifxmips.patch.svn-base96
-rw-r--r--package/platform/lantiq/ltq-tapi/patches/.svn/text-base/200-linux-37.patch.svn-base108
-rw-r--r--package/platform/lantiq/ltq-tapi/patches/000-portability.patch82
-rw-r--r--package/platform/lantiq/ltq-tapi/patches/100-ifxmips.patch96
-rw-r--r--package/platform/lantiq/ltq-tapi/patches/200-linux-37.patch108
-rw-r--r--package/platform/lantiq/ltq-vdsl-app/.svn/entries68
-rw-r--r--package/platform/lantiq/ltq-vdsl-app/.svn/text-base/Makefile.svn-base75
-rw-r--r--package/platform/lantiq/ltq-vdsl-app/Makefile75
-rw-r--r--package/platform/lantiq/ltq-vdsl-app/files/.svn/entries96
-rw-r--r--package/platform/lantiq/ltq-vdsl-app/files/.svn/text-base/dsl_control.svn-base311
-rw-r--r--package/platform/lantiq/ltq-vdsl-app/files/.svn/text-base/dsl_notify.sh.svn-base44
-rw-r--r--package/platform/lantiq/ltq-vdsl-app/files/dsl_control311
-rw-r--r--package/platform/lantiq/ltq-vdsl-app/files/dsl_notify.sh44
-rw-r--r--package/platform/lantiq/ltq-vdsl-app/patches/.svn/entries62
-rw-r--r--package/platform/lantiq/ltq-vdsl-app/patches/.svn/text-base/100-compat.patch.svn-base26
-rw-r--r--package/platform/lantiq/ltq-vdsl-app/patches/100-compat.patch26
-rw-r--r--package/platform/lantiq/ltq-vdsl-fw/.svn/entries65
-rw-r--r--package/platform/lantiq/ltq-vdsl-fw/.svn/text-base/Makefile.svn-base40
-rw-r--r--package/platform/lantiq/ltq-vdsl-fw/Makefile40
-rw-r--r--package/platform/lantiq/ltq-vdsl-fw/src/.svn/entries300
-rw-r--r--package/platform/lantiq/ltq-vdsl-fw/src/.svn/prop-base/LzmaDecode.c.svn-base5
-rw-r--r--package/platform/lantiq/ltq-vdsl-fw/src/.svn/prop-base/LzmaDecode.h.svn-base5
-rw-r--r--package/platform/lantiq/ltq-vdsl-fw/src/.svn/prop-base/LzmaTypes.h.svn-base5
-rw-r--r--package/platform/lantiq/ltq-vdsl-fw/src/.svn/prop-base/vdsl_fw_install.sh.svn-base5
-rw-r--r--package/platform/lantiq/ltq-vdsl-fw/src/.svn/text-base/LzmaDecode.c.svn-base584
-rw-r--r--package/platform/lantiq/ltq-vdsl-fw/src/.svn/text-base/LzmaDecode.h.svn-base113
-rw-r--r--package/platform/lantiq/ltq-vdsl-fw/src/.svn/text-base/LzmaTypes.h.svn-base45
-rw-r--r--package/platform/lantiq/ltq-vdsl-fw/src/.svn/text-base/LzmaWrapper.c.svn-base206
-rw-r--r--package/platform/lantiq/ltq-vdsl-fw/src/.svn/text-base/LzmaWrapper.h.svn-base36
-rw-r--r--package/platform/lantiq/ltq-vdsl-fw/src/.svn/text-base/Makefile.svn-base13
-rw-r--r--package/platform/lantiq/ltq-vdsl-fw/src/.svn/text-base/vdsl_fw_install.sh.svn-base48
-rw-r--r--package/platform/lantiq/ltq-vdsl-fw/src/.svn/text-base/w921v_fw_cutter.c.svn-base164
-rw-r--r--package/platform/lantiq/ltq-vdsl-fw/src/LzmaDecode.c584
-rw-r--r--package/platform/lantiq/ltq-vdsl-fw/src/LzmaDecode.h113
-rw-r--r--package/platform/lantiq/ltq-vdsl-fw/src/LzmaTypes.h45
-rw-r--r--package/platform/lantiq/ltq-vdsl-fw/src/LzmaWrapper.c206
-rw-r--r--package/platform/lantiq/ltq-vdsl-fw/src/LzmaWrapper.h36
-rw-r--r--package/platform/lantiq/ltq-vdsl-fw/src/Makefile13
-rwxr-xr-xpackage/platform/lantiq/ltq-vdsl-fw/src/vdsl_fw_install.sh48
-rw-r--r--package/platform/lantiq/ltq-vdsl-fw/src/w921v_fw_cutter.c164
-rw-r--r--package/platform/lantiq/ltq-vdsl-mei/.svn/entries65
-rw-r--r--package/platform/lantiq/ltq-vdsl-mei/.svn/text-base/Makefile.svn-base60
-rw-r--r--package/platform/lantiq/ltq-vdsl-mei/Makefile60
-rw-r--r--package/platform/lantiq/ltq-vdsl-mei/patches/.svn/entries62
-rw-r--r--package/platform/lantiq/ltq-vdsl-mei/patches/.svn/text-base/100-compat.patch.svn-base298
-rw-r--r--package/platform/lantiq/ltq-vdsl-mei/patches/100-compat.patch298
-rw-r--r--package/platform/lantiq/ltq-vdsl/.svn/entries65
-rw-r--r--package/platform/lantiq/ltq-vdsl/.svn/text-base/Makefile.svn-base69
-rw-r--r--package/platform/lantiq/ltq-vdsl/Makefile69
-rw-r--r--package/platform/lantiq/ltq-vdsl/patches/.svn/entries62
-rw-r--r--package/platform/lantiq/ltq-vdsl/patches/.svn/text-base/100-compat.patch.svn-base148
-rw-r--r--package/platform/lantiq/ltq-vdsl/patches/100-compat.patch148
-rw-r--r--package/platform/lantiq/ltq-vmmc/.svn/entries102
-rw-r--r--package/platform/lantiq/ltq-vmmc/.svn/text-base/Config.in.svn-base95
-rw-r--r--package/platform/lantiq/ltq-vmmc/.svn/text-base/Makefile.svn-base166
-rw-r--r--package/platform/lantiq/ltq-vmmc/Config.in95
-rw-r--r--package/platform/lantiq/ltq-vmmc/Makefile166
-rw-r--r--package/platform/lantiq/ltq-vmmc/files/.svn/entries62
-rw-r--r--package/platform/lantiq/ltq-vmmc/files/.svn/text-base/vmmc.init.svn-base19
-rw-r--r--package/platform/lantiq/ltq-vmmc/files/vmmc.init19
-rw-r--r--package/platform/lantiq/ltq-vmmc/patches/.svn/entries130
-rw-r--r--package/platform/lantiq/ltq-vmmc/patches/.svn/text-base/000-portability.patch.svn-base287
-rw-r--r--package/platform/lantiq/ltq-vmmc/patches/.svn/text-base/100-target.patch.svn-base751
-rw-r--r--package/platform/lantiq/ltq-vmmc/patches/.svn/text-base/400-falcon.patch.svn-base968
-rw-r--r--package/platform/lantiq/ltq-vmmc/patches/000-portability.patch287
-rw-r--r--package/platform/lantiq/ltq-vmmc/patches/100-target.patch751
-rw-r--r--package/platform/lantiq/ltq-vmmc/patches/400-falcon.patch968
-rw-r--r--package/procd/.svn/entries65
-rw-r--r--package/procd/.svn/text-base/Makefile.svn-base50
-rw-r--r--package/procd/Makefile50
-rw-r--r--package/procd/files/.svn/entries164
-rw-r--r--package/procd/files/.svn/text-base/hotplug-preinit.json.svn-base21
-rw-r--r--package/procd/files/.svn/text-base/hotplug.json.svn-base80
-rw-r--r--package/procd/files/.svn/text-base/procd.init.svn-base19
-rw-r--r--package/procd/files/.svn/text-base/procd.sh.svn-base171
-rw-r--r--package/procd/files/hotplug-preinit.json21
-rw-r--r--package/procd/files/hotplug.json80
-rw-r--r--package/procd/files/procd.init19
-rw-r--r--package/procd/files/procd.sh171
-rw-r--r--package/px5g/.svn/entries65
-rw-r--r--package/px5g/.svn/text-base/Makefile.svn-base40
-rw-r--r--package/px5g/Makefile40
-rw-r--r--package/px5g/src/.svn/entries102
-rw-r--r--package/px5g/src/.svn/text-base/Makefile.svn-base14
-rw-r--r--package/px5g/src/.svn/text-base/px5g.c.svn-base197
-rw-r--r--package/px5g/src/Makefile14
-rw-r--r--package/px5g/src/library/.svn/entries266
-rw-r--r--package/px5g/src/library/.svn/text-base/base64.c.svn-base264
-rw-r--r--package/px5g/src/library/.svn/text-base/bignum.c.svn-base2010
-rw-r--r--package/px5g/src/library/.svn/text-base/havege.c.svn-base276
-rw-r--r--package/px5g/src/library/.svn/text-base/rsa.c.svn-base750
-rw-r--r--package/px5g/src/library/.svn/text-base/sha1.c.svn-base622
-rw-r--r--package/px5g/src/library/.svn/text-base/timing.c.svn-base265
-rw-r--r--package/px5g/src/library/.svn/text-base/x509write.c.svn-base1139
-rw-r--r--package/px5g/src/library/base64.c264
-rw-r--r--package/px5g/src/library/bignum.c2010
-rw-r--r--package/px5g/src/library/havege.c276
-rw-r--r--package/px5g/src/library/rsa.c750
-rw-r--r--package/px5g/src/library/sha1.c622
-rw-r--r--package/px5g/src/library/timing.c265
-rw-r--r--package/px5g/src/library/x509write.c1139
-rw-r--r--package/px5g/src/polarssl/.svn/entries334
-rw-r--r--package/px5g/src/polarssl/.svn/text-base/base64.h.svn-base93
-rw-r--r--package/px5g/src/polarssl/.svn/text-base/bignum.h.svn-base437
-rw-r--r--package/px5g/src/polarssl/.svn/text-base/bn_mul.h.svn-base731
-rw-r--r--package/px5g/src/polarssl/.svn/text-base/config.h.svn-base329
-rw-r--r--package/px5g/src/polarssl/.svn/text-base/havege.h.svn-base75
-rw-r--r--package/px5g/src/polarssl/.svn/text-base/rsa.h.svn-base309
-rw-r--r--package/px5g/src/polarssl/.svn/text-base/sha1.h.svn-base150
-rw-r--r--package/px5g/src/polarssl/.svn/text-base/timing.h.svn-base81
-rw-r--r--package/px5g/src/polarssl/.svn/text-base/x509.h.svn-base549
-rw-r--r--package/px5g/src/polarssl/base64.h93
-rw-r--r--package/px5g/src/polarssl/bignum.h437
-rw-r--r--package/px5g/src/polarssl/bn_mul.h731
-rw-r--r--package/px5g/src/polarssl/config.h329
-rw-r--r--package/px5g/src/polarssl/havege.h75
-rw-r--r--package/px5g/src/polarssl/rsa.h309
-rw-r--r--package/px5g/src/polarssl/sha1.h150
-rw-r--r--package/px5g/src/polarssl/timing.h81
-rw-r--r--package/px5g/src/polarssl/x509.h549
-rw-r--r--package/px5g/src/px5g.c197
-rw-r--r--package/switch/.svn/entries68
-rw-r--r--package/switch/.svn/prop-base/Makefile.svn-base9
-rw-r--r--package/switch/.svn/text-base/Makefile.svn-base59
-rw-r--r--package/switch/Makefile59
-rw-r--r--package/switch/files/.svn/entries62
-rw-r--r--package/switch/files/.svn/prop-base/switch.sh.svn-base5
-rw-r--r--package/switch/files/.svn/text-base/switch.sh.svn-base53
-rw-r--r--package/switch/files/switch.sh53
-rw-r--r--package/switch/src/.svn/entries266
-rw-r--r--package/switch/src/.svn/prop-base/Makefile.svn-base5
-rw-r--r--package/switch/src/.svn/prop-base/etc53xx.h.svn-base5
-rw-r--r--package/switch/src/.svn/prop-base/gpio.h.svn-base5
-rw-r--r--package/switch/src/.svn/prop-base/switch-adm.c.svn-base5
-rw-r--r--package/switch/src/.svn/prop-base/switch-core.c.svn-base5
-rw-r--r--package/switch/src/.svn/prop-base/switch-core.h.svn-base5
-rw-r--r--package/switch/src/.svn/prop-base/switch-robo.c.svn-base5
-rw-r--r--package/switch/src/.svn/text-base/Makefile.svn-base18
-rw-r--r--package/switch/src/.svn/text-base/etc53xx.h.svn-base624
-rw-r--r--package/switch/src/.svn/text-base/gpio.h.svn-base25
-rw-r--r--package/switch/src/.svn/text-base/switch-adm.c.svn-base596
-rw-r--r--package/switch/src/.svn/text-base/switch-core.c.svn-base527
-rw-r--r--package/switch/src/.svn/text-base/switch-core.h.svn-base55
-rw-r--r--package/switch/src/.svn/text-base/switch-robo.c.svn-base892
-rw-r--r--package/switch/src/Makefile18
-rw-r--r--package/switch/src/etc53xx.h624
-rw-r--r--package/switch/src/gpio.h25
-rw-r--r--package/switch/src/switch-adm.c596
-rw-r--r--package/switch/src/switch-core.c527
-rw-r--r--package/switch/src/switch-core.h55
-rw-r--r--package/switch/src/switch-robo.c892
-rw-r--r--package/system/.svn/entries85
-rw-r--r--package/system/ar7-atm/.svn/entries102
-rw-r--r--package/system/ar7-atm/.svn/prop-base/Makefile.svn-base9
-rw-r--r--package/system/ar7-atm/.svn/text-base/Config.in.svn-base22
-rw-r--r--package/system/ar7-atm/.svn/text-base/Makefile.svn-base100
-rw-r--r--package/system/ar7-atm/Config.in22
-rw-r--r--package/system/ar7-atm/Makefile100
-rw-r--r--package/system/ar7-atm/patches-D7.04.03.00/.svn/entries436
-rw-r--r--package/system/ar7-atm/patches-D7.04.03.00/.svn/prop-base/100-compile_fix.patch.svn-base5
-rw-r--r--package/system/ar7-atm/patches-D7.04.03.00/.svn/text-base/100-compile_fix.patch.svn-base768
-rw-r--r--package/system/ar7-atm/patches-D7.04.03.00/.svn/text-base/110-interrupt_fix.patch.svn-base37
-rw-r--r--package/system/ar7-atm/patches-D7.04.03.00/.svn/text-base/120-no_dumb_inline.patch.svn-base11
-rw-r--r--package/system/ar7-atm/patches-D7.04.03.00/.svn/text-base/130-powercutback.patch.svn-base44
-rw-r--r--package/system/ar7-atm/patches-D7.04.03.00/.svn/text-base/140-debug_mode.patch.svn-base16
-rw-r--r--package/system/ar7-atm/patches-D7.04.03.00/.svn/text-base/150-tasklet_mode.patch.svn-base11
-rw-r--r--package/system/ar7-atm/patches-D7.04.03.00/.svn/text-base/160-module-params.patch.svn-base589
-rw-r--r--package/system/ar7-atm/patches-D7.04.03.00/.svn/text-base/170-bus_id_removal.patch.svn-base30
-rw-r--r--package/system/ar7-atm/patches-D7.04.03.00/.svn/text-base/180-git_headers_include.patch.svn-base54
-rw-r--r--package/system/ar7-atm/patches-D7.04.03.00/.svn/text-base/190-2.6.32_proc_fixes.patch.svn-base79
-rw-r--r--package/system/ar7-atm/patches-D7.04.03.00/.svn/text-base/200-2.6.37_args.patch.svn-base36
-rw-r--r--package/system/ar7-atm/patches-D7.04.03.00/.svn/text-base/210-3.3-remove-smp_lock.h.patch.svn-base33
-rw-r--r--package/system/ar7-atm/patches-D7.04.03.00/100-compile_fix.patch768
-rw-r--r--package/system/ar7-atm/patches-D7.04.03.00/110-interrupt_fix.patch37
-rw-r--r--package/system/ar7-atm/patches-D7.04.03.00/120-no_dumb_inline.patch11
-rw-r--r--package/system/ar7-atm/patches-D7.04.03.00/130-powercutback.patch44
-rw-r--r--package/system/ar7-atm/patches-D7.04.03.00/140-debug_mode.patch16
-rw-r--r--package/system/ar7-atm/patches-D7.04.03.00/150-tasklet_mode.patch11
-rw-r--r--package/system/ar7-atm/patches-D7.04.03.00/160-module-params.patch589
-rw-r--r--package/system/ar7-atm/patches-D7.04.03.00/170-bus_id_removal.patch30
-rw-r--r--package/system/ar7-atm/patches-D7.04.03.00/180-git_headers_include.patch54
-rw-r--r--package/system/ar7-atm/patches-D7.04.03.00/190-2.6.32_proc_fixes.patch79
-rw-r--r--package/system/ar7-atm/patches-D7.04.03.00/200-2.6.37_args.patch36
-rw-r--r--package/system/ar7-atm/patches-D7.04.03.00/210-3.3-remove-smp_lock.h.patch33
-rw-r--r--package/system/ar7-atm/patches-D7.05.01.00/.svn/entries436
-rw-r--r--package/system/ar7-atm/patches-D7.05.01.00/.svn/prop-base/100-compile_fix.patch.svn-base5
-rw-r--r--package/system/ar7-atm/patches-D7.05.01.00/.svn/text-base/100-compile_fix.patch.svn-base808
-rw-r--r--package/system/ar7-atm/patches-D7.05.01.00/.svn/text-base/110-interrupt_fix.patch.svn-base37
-rw-r--r--package/system/ar7-atm/patches-D7.05.01.00/.svn/text-base/120-no_dumb_inline.patch.svn-base11
-rw-r--r--package/system/ar7-atm/patches-D7.05.01.00/.svn/text-base/130-powercutback.patch.svn-base44
-rw-r--r--package/system/ar7-atm/patches-D7.05.01.00/.svn/text-base/140-debug_mode.patch.svn-base16
-rw-r--r--package/system/ar7-atm/patches-D7.05.01.00/.svn/text-base/150-tasklet_mode.patch.svn-base11
-rw-r--r--package/system/ar7-atm/patches-D7.05.01.00/.svn/text-base/160-module-params.patch.svn-base675
-rw-r--r--package/system/ar7-atm/patches-D7.05.01.00/.svn/text-base/170-bus_id_removal.patch.svn-base30
-rw-r--r--package/system/ar7-atm/patches-D7.05.01.00/.svn/text-base/180-git_headers_include.patch.svn-base54
-rw-r--r--package/system/ar7-atm/patches-D7.05.01.00/.svn/text-base/190-2.6.32_proc_fixes.patch.svn-base79
-rw-r--r--package/system/ar7-atm/patches-D7.05.01.00/.svn/text-base/200-2.6.37_args.patch.svn-base36
-rw-r--r--package/system/ar7-atm/patches-D7.05.01.00/.svn/text-base/210-3.3-remove-smp_lock.h.patch.svn-base33
-rw-r--r--package/system/ar7-atm/patches-D7.05.01.00/100-compile_fix.patch808
-rw-r--r--package/system/ar7-atm/patches-D7.05.01.00/110-interrupt_fix.patch37
-rw-r--r--package/system/ar7-atm/patches-D7.05.01.00/120-no_dumb_inline.patch11
-rw-r--r--package/system/ar7-atm/patches-D7.05.01.00/130-powercutback.patch44
-rw-r--r--package/system/ar7-atm/patches-D7.05.01.00/140-debug_mode.patch16
-rw-r--r--package/system/ar7-atm/patches-D7.05.01.00/150-tasklet_mode.patch11
-rw-r--r--package/system/ar7-atm/patches-D7.05.01.00/160-module-params.patch675
-rw-r--r--package/system/ar7-atm/patches-D7.05.01.00/170-bus_id_removal.patch30
-rw-r--r--package/system/ar7-atm/patches-D7.05.01.00/180-git_headers_include.patch54
-rw-r--r--package/system/ar7-atm/patches-D7.05.01.00/190-2.6.32_proc_fixes.patch79
-rw-r--r--package/system/ar7-atm/patches-D7.05.01.00/200-2.6.37_args.patch36
-rw-r--r--package/system/ar7-atm/patches-D7.05.01.00/210-3.3-remove-smp_lock.h.patch33
-rw-r--r--package/system/avila-wdt/.svn/entries65
-rw-r--r--package/system/avila-wdt/.svn/text-base/Makefile.svn-base40
-rw-r--r--package/system/avila-wdt/Makefile40
-rw-r--r--package/system/avila-wdt/src/.svn/entries96
-rw-r--r--package/system/avila-wdt/src/.svn/text-base/Makefile.svn-base1
-rw-r--r--package/system/avila-wdt/src/.svn/text-base/avila-wdt.c.svn-base231
-rw-r--r--package/system/avila-wdt/src/Makefile1
-rw-r--r--package/system/avila-wdt/src/avila-wdt.c231
-rw-r--r--package/system/brcm2708-gpu-fw/.svn/entries62
-rw-r--r--package/system/brcm2708-gpu-fw/.svn/text-base/Makefile.svn-base46
-rw-r--r--package/system/brcm2708-gpu-fw/Makefile46
-rw-r--r--package/system/button-hotplug/.svn/entries65
-rw-r--r--package/system/button-hotplug/.svn/prop-base/Makefile.svn-base5
-rw-r--r--package/system/button-hotplug/.svn/text-base/Makefile.svn-base53
-rw-r--r--package/system/button-hotplug/Makefile53
-rw-r--r--package/system/button-hotplug/src/.svn/entries130
-rw-r--r--package/system/button-hotplug/src/.svn/prop-base/Makefile.svn-base5
-rw-r--r--package/system/button-hotplug/src/.svn/prop-base/button-hotplug.c.svn-base5
-rw-r--r--package/system/button-hotplug/src/.svn/text-base/Kconfig.svn-base2
-rw-r--r--package/system/button-hotplug/src/.svn/text-base/Makefile.svn-base1
-rw-r--r--package/system/button-hotplug/src/.svn/text-base/button-hotplug.c.svn-base349
-rw-r--r--package/system/button-hotplug/src/Kconfig2
-rw-r--r--package/system/button-hotplug/src/Makefile1
-rw-r--r--package/system/button-hotplug/src/button-hotplug.c349
-rw-r--r--package/system/ep80579-drivers/.svn/entries65
-rw-r--r--package/system/ep80579-drivers/.svn/text-base/Makefile.svn-base92
-rw-r--r--package/system/ep80579-drivers/Makefile92
-rw-r--r--package/system/ep80579-drivers/patches/.svn/entries980
-rw-r--r--package/system/ep80579-drivers/patches/.svn/text-base/001-igbe_update.patch.svn-base11755
-rw-r--r--package/system/ep80579-drivers/patches/.svn/text-base/002-cflags_cleanup.patch.svn-base22
-rw-r--r--package/system/ep80579-drivers/patches/.svn/text-base/003-new_irqf_constants.patch.svn-base53
-rw-r--r--package/system/ep80579-drivers/patches/.svn/text-base/100-iegbe_netdev_ops.patch.svn-base56
-rw-r--r--package/system/ep80579-drivers/patches/.svn/text-base/101-iegbe_fix_napi_interface.patch.svn-base41
-rw-r--r--package/system/ep80579-drivers/patches/.svn/text-base/102-iegbe_nuke_polling_netdev.patch.svn-base103
-rw-r--r--package/system/ep80579-drivers/patches/.svn/text-base/103-iegbe_convert_unicast_addr_list.patch.svn-base60
-rw-r--r--package/system/ep80579-drivers/patches/.svn/text-base/104-iegbe_group_address_list_and_its_count.patch.svn-base20
-rw-r--r--package/system/ep80579-drivers/patches/.svn/text-base/105-iegbe_new_dma_masks.patch.svn-base20
-rw-r--r--package/system/ep80579-drivers/patches/.svn/text-base/106-iegbe_new_irqf_constant.patch.svn-base12
-rw-r--r--package/system/ep80579-drivers/patches/.svn/text-base/150-ocracoke_island.patch.svn-base747
-rw-r--r--package/system/ep80579-drivers/patches/.svn/text-base/200-can_fix_ioctl_numbers.patch.svn-base11
-rw-r--r--package/system/ep80579-drivers/patches/.svn/text-base/210-can_include_linux_fs_h.patch.svn-base11
-rw-r--r--package/system/ep80579-drivers/patches/.svn/text-base/220-can_fix_irq_request.patch.svn-base23
-rw-r--r--package/system/ep80579-drivers/patches/.svn/text-base/230-can_remove_driver_data_direct_access.patch.svn-base40
-rw-r--r--package/system/ep80579-drivers/patches/.svn/text-base/300-wdt_compile_fix.patch.svn-base59
-rw-r--r--package/system/ep80579-drivers/patches/.svn/text-base/400-edma_fix_irq_request_warning.patch.svn-base22
-rw-r--r--package/system/ep80579-drivers/patches/.svn/text-base/500-1588_fix_irq_request_warning.patch.svn-base22
-rw-r--r--package/system/ep80579-drivers/patches/.svn/text-base/600-2.6.27_includes.patch.svn-base22
-rw-r--r--package/system/ep80579-drivers/patches/.svn/text-base/601-2.6.32_includes.patch.svn-base30
-rw-r--r--package/system/ep80579-drivers/patches/.svn/text-base/700-iegbe_kcompat_2.6.30.patch.svn-base31
-rw-r--r--package/system/ep80579-drivers/patches/.svn/text-base/701-iegbe_poll_dev.patch.svn-base11
-rw-r--r--package/system/ep80579-drivers/patches/.svn/text-base/710-3.3-fix-generated-header-locations.patch.svn-base91
-rw-r--r--package/system/ep80579-drivers/patches/.svn/text-base/711-3.3-gbe-fixes.patch.svn-base392
-rw-r--r--package/system/ep80579-drivers/patches/.svn/text-base/712-3.3-can-fixes.patch.svn-base41
-rw-r--r--package/system/ep80579-drivers/patches/.svn/text-base/713-3.3-gpio-fixes.patch.svn-base33
-rw-r--r--package/system/ep80579-drivers/patches/.svn/text-base/714-3.3-wdt-fixes.patch.svn-base31
-rw-r--r--package/system/ep80579-drivers/patches/.svn/text-base/715-3.3-1588-fixes.patch.svn-base33
-rw-r--r--package/system/ep80579-drivers/patches/001-igbe_update.patch11755
-rw-r--r--package/system/ep80579-drivers/patches/002-cflags_cleanup.patch22
-rw-r--r--package/system/ep80579-drivers/patches/003-new_irqf_constants.patch53
-rw-r--r--package/system/ep80579-drivers/patches/100-iegbe_netdev_ops.patch56
-rw-r--r--package/system/ep80579-drivers/patches/101-iegbe_fix_napi_interface.patch41
-rw-r--r--package/system/ep80579-drivers/patches/102-iegbe_nuke_polling_netdev.patch103
-rw-r--r--package/system/ep80579-drivers/patches/103-iegbe_convert_unicast_addr_list.patch60
-rw-r--r--package/system/ep80579-drivers/patches/104-iegbe_group_address_list_and_its_count.patch20
-rw-r--r--package/system/ep80579-drivers/patches/105-iegbe_new_dma_masks.patch20
-rw-r--r--package/system/ep80579-drivers/patches/106-iegbe_new_irqf_constant.patch12
-rw-r--r--package/system/ep80579-drivers/patches/150-ocracoke_island.patch747
-rw-r--r--package/system/ep80579-drivers/patches/200-can_fix_ioctl_numbers.patch11
-rw-r--r--package/system/ep80579-drivers/patches/210-can_include_linux_fs_h.patch11
-rw-r--r--package/system/ep80579-drivers/patches/220-can_fix_irq_request.patch23
-rw-r--r--package/system/ep80579-drivers/patches/230-can_remove_driver_data_direct_access.patch40
-rw-r--r--package/system/ep80579-drivers/patches/300-wdt_compile_fix.patch59
-rw-r--r--package/system/ep80579-drivers/patches/400-edma_fix_irq_request_warning.patch22
-rw-r--r--package/system/ep80579-drivers/patches/500-1588_fix_irq_request_warning.patch22
-rw-r--r--package/system/ep80579-drivers/patches/600-2.6.27_includes.patch22
-rw-r--r--package/system/ep80579-drivers/patches/601-2.6.32_includes.patch30
-rw-r--r--package/system/ep80579-drivers/patches/700-iegbe_kcompat_2.6.30.patch31
-rw-r--r--package/system/ep80579-drivers/patches/701-iegbe_poll_dev.patch11
-rw-r--r--package/system/ep80579-drivers/patches/710-3.3-fix-generated-header-locations.patch91
-rw-r--r--package/system/ep80579-drivers/patches/711-3.3-gbe-fixes.patch392
-rw-r--r--package/system/ep80579-drivers/patches/712-3.3-can-fixes.patch41
-rw-r--r--package/system/ep80579-drivers/patches/713-3.3-gpio-fixes.patch33
-rw-r--r--package/system/ep80579-drivers/patches/714-3.3-wdt-fixes.patch31
-rw-r--r--package/system/ep80579-drivers/patches/715-3.3-1588-fixes.patch33
-rw-r--r--package/system/gpio-button-hotplug/.svn/entries65
-rw-r--r--package/system/gpio-button-hotplug/.svn/text-base/Makefile.svn-base44
-rw-r--r--package/system/gpio-button-hotplug/Makefile44
-rw-r--r--package/system/gpio-button-hotplug/src/.svn/entries96
-rw-r--r--package/system/gpio-button-hotplug/src/.svn/text-base/Makefile.svn-base1
-rw-r--r--package/system/gpio-button-hotplug/src/.svn/text-base/gpio-button-hotplug.c.svn-base564
-rw-r--r--package/system/gpio-button-hotplug/src/Makefile1
-rw-r--r--package/system/gpio-button-hotplug/src/gpio-button-hotplug.c564
-rw-r--r--package/system/hostap-driver/.svn/entries68
-rw-r--r--package/system/hostap-driver/.svn/prop-base/Makefile.svn-base9
-rw-r--r--package/system/hostap-driver/.svn/text-base/Makefile.svn-base117
-rw-r--r--package/system/hostap-driver/Makefile117
-rw-r--r--package/system/hostap-driver/files/.svn/entries31
-rw-r--r--package/system/hostap-driver/files/lib/.svn/entries31
-rw-r--r--package/system/hostap-driver/files/lib/wifi/.svn/entries62
-rw-r--r--package/system/hostap-driver/files/lib/wifi/.svn/prop-base/hostap.sh.svn-base5
-rw-r--r--package/system/hostap-driver/files/lib/wifi/.svn/text-base/hostap.sh.svn-base270
-rwxr-xr-xpackage/system/hostap-driver/files/lib/wifi/hostap.sh270
-rw-r--r--package/system/hostap-driver/patches/.svn/entries62
-rw-r--r--package/system/hostap-driver/patches/.svn/text-base/001-fix-txpower.patch.svn-base175
-rw-r--r--package/system/hostap-driver/patches/001-fix-txpower.patch175
-rw-r--r--package/system/i2c-gpio-custom/.svn/entries65
-rw-r--r--package/system/i2c-gpio-custom/.svn/prop-base/Makefile.svn-base5
-rw-r--r--package/system/i2c-gpio-custom/.svn/text-base/Makefile.svn-base53
-rw-r--r--package/system/i2c-gpio-custom/Makefile53
-rw-r--r--package/system/i2c-gpio-custom/src/.svn/entries130
-rw-r--r--package/system/i2c-gpio-custom/src/.svn/prop-base/Makefile.svn-base5
-rw-r--r--package/system/i2c-gpio-custom/src/.svn/prop-base/i2c-gpio-custom.c.svn-base5
-rw-r--r--package/system/i2c-gpio-custom/src/.svn/text-base/Kconfig.svn-base10
-rw-r--r--package/system/i2c-gpio-custom/src/.svn/text-base/Makefile.svn-base1
-rw-r--r--package/system/i2c-gpio-custom/src/.svn/text-base/i2c-gpio-custom.c.svn-base198
-rw-r--r--package/system/i2c-gpio-custom/src/Kconfig10
-rw-r--r--package/system/i2c-gpio-custom/src/Makefile1
-rw-r--r--package/system/i2c-gpio-custom/src/i2c-gpio-custom.c198
-rw-r--r--package/system/ixp4xx-microcode/.svn/entries65
-rw-r--r--package/system/ixp4xx-microcode/.svn/text-base/Makefile.svn-base57
-rw-r--r--package/system/ixp4xx-microcode/Makefile57
-rw-r--r--package/system/ixp4xx-microcode/src/.svn/entries96
-rw-r--r--package/system/ixp4xx-microcode/src/.svn/text-base/IxNpeMicrocode.h.svn-base148
-rw-r--r--package/system/ixp4xx-microcode/src/.svn/text-base/LICENSE.IPL.svn-base27
-rw-r--r--package/system/ixp4xx-microcode/src/IxNpeMicrocode.h148
-rw-r--r--package/system/ixp4xx-microcode/src/LICENSE.IPL27
-rw-r--r--package/system/mmc_over_gpio/.svn/entries65
-rw-r--r--package/system/mmc_over_gpio/.svn/text-base/Makefile.svn-base77
-rw-r--r--package/system/mmc_over_gpio/Makefile77
-rw-r--r--package/system/mmc_over_gpio/files/.svn/entries96
-rw-r--r--package/system/mmc_over_gpio/files/.svn/text-base/mmc_over_gpio.config.svn-base8
-rw-r--r--package/system/mmc_over_gpio/files/.svn/text-base/mmc_over_gpio.init.svn-base83
-rw-r--r--package/system/mmc_over_gpio/files/mmc_over_gpio.config8
-rw-r--r--package/system/mmc_over_gpio/files/mmc_over_gpio.init83
-rw-r--r--package/system/om-watchdog/.svn/entries65
-rw-r--r--package/system/om-watchdog/.svn/prop-base/Makefile.svn-base5
-rw-r--r--package/system/om-watchdog/.svn/text-base/Makefile.svn-base45
-rw-r--r--package/system/om-watchdog/Makefile45
-rw-r--r--package/system/om-watchdog/files/.svn/entries96
-rw-r--r--package/system/om-watchdog/files/.svn/text-base/om-watchdog.init.svn-base30
-rw-r--r--package/system/om-watchdog/files/.svn/text-base/om-watchdog.svn-base15
-rw-r--r--package/system/om-watchdog/files/om-watchdog15
-rw-r--r--package/system/om-watchdog/files/om-watchdog.init30
-rw-r--r--package/system/rotary-gpio-custom/.svn/entries65
-rw-r--r--package/system/rotary-gpio-custom/.svn/text-base/Makefile.svn-base53
-rw-r--r--package/system/rotary-gpio-custom/Makefile53
-rw-r--r--package/system/rotary-gpio-custom/src/.svn/entries130
-rw-r--r--package/system/rotary-gpio-custom/src/.svn/text-base/Kconfig.svn-base9
-rw-r--r--package/system/rotary-gpio-custom/src/.svn/text-base/Makefile.svn-base1
-rw-r--r--package/system/rotary-gpio-custom/src/.svn/text-base/rotary-gpio-custom.c.svn-base188
-rw-r--r--package/system/rotary-gpio-custom/src/Kconfig9
-rw-r--r--package/system/rotary-gpio-custom/src/Makefile1
-rw-r--r--package/system/rotary-gpio-custom/src/rotary-gpio-custom.c188
-rw-r--r--package/system/rtc-rv5c386a/.svn/entries65
-rw-r--r--package/system/rtc-rv5c386a/.svn/text-base/Makefile.svn-base38
-rw-r--r--package/system/rtc-rv5c386a/Makefile38
-rw-r--r--package/system/rtc-rv5c386a/src/.svn/entries96
-rw-r--r--package/system/rtc-rv5c386a/src/.svn/text-base/Makefile.svn-base18
-rw-r--r--package/system/rtc-rv5c386a/src/.svn/text-base/rtc.c.svn-base613
-rw-r--r--package/system/rtc-rv5c386a/src/Makefile18
-rw-r--r--package/system/rtc-rv5c386a/src/rtc.c613
-rw-r--r--package/system/spi-ks8995/.svn/entries65
-rw-r--r--package/system/spi-ks8995/.svn/prop-base/Makefile.svn-base5
-rw-r--r--package/system/spi-ks8995/.svn/text-base/Makefile.svn-base54
-rw-r--r--package/system/spi-ks8995/Makefile54
-rw-r--r--package/system/spi-ks8995/src/.svn/entries130
-rw-r--r--package/system/spi-ks8995/src/.svn/prop-base/Makefile.svn-base5
-rw-r--r--package/system/spi-ks8995/src/.svn/prop-base/spi_ks8995.c.svn-base5
-rw-r--r--package/system/spi-ks8995/src/.svn/text-base/Kconfig.svn-base3
-rw-r--r--package/system/spi-ks8995/src/.svn/text-base/Makefile.svn-base1
-rw-r--r--package/system/spi-ks8995/src/.svn/text-base/spi_ks8995.c.svn-base419
-rw-r--r--package/system/spi-ks8995/src/Kconfig3
-rw-r--r--package/system/spi-ks8995/src/Makefile1
-rw-r--r--package/system/spi-ks8995/src/spi_ks8995.c419
-rw-r--r--package/system/spidev_test/.svn/entries62
-rw-r--r--package/system/spidev_test/.svn/text-base/Makefile.svn-base43
-rw-r--r--package/system/spidev_test/Makefile43
-rw-r--r--package/system/utils/.svn/entries55
-rw-r--r--package/system/utils/e2fsprogs/.svn/entries68
-rw-r--r--package/system/utils/e2fsprogs/.svn/prop-base/Makefile.svn-base17
-rw-r--r--package/system/utils/e2fsprogs/.svn/text-base/Makefile.svn-base169
-rw-r--r--package/system/utils/e2fsprogs/Makefile169
-rw-r--r--package/system/utils/e2fsprogs/files/.svn/entries96
-rw-r--r--package/system/utils/e2fsprogs/files/.svn/text-base/e2fsck.conf.svn-base3
-rw-r--r--package/system/utils/e2fsprogs/files/.svn/text-base/e2fsck.sh.svn-base38
-rw-r--r--package/system/utils/e2fsprogs/files/e2fsck.conf3
-rw-r--r--package/system/utils/e2fsprogs/files/e2fsck.sh38
-rw-r--r--package/system/utils/e2fsprogs/patches/.svn/entries96
-rw-r--r--package/system/utils/e2fsprogs/patches/.svn/text-base/001-link-against-libuuid.patch.svn-base38
-rw-r--r--package/system/utils/e2fsprogs/patches/.svn/text-base/002-no_malloc_h.patch.svn-base10
-rw-r--r--package/system/utils/e2fsprogs/patches/001-link-against-libuuid.patch38
-rw-r--r--package/system/utils/e2fsprogs/patches/002-no_malloc_h.patch10
-rw-r--r--package/system/utils/fbtest/.svn/entries65
-rw-r--r--package/system/utils/fbtest/.svn/text-base/Makefile.svn-base44
-rw-r--r--package/system/utils/fbtest/Makefile44
-rw-r--r--package/system/utils/fbtest/src/.svn/entries96
-rw-r--r--package/system/utils/fbtest/src/.svn/text-base/Makefile.svn-base14
-rw-r--r--package/system/utils/fbtest/src/.svn/text-base/fbtest.c.svn-base448
-rw-r--r--package/system/utils/fbtest/src/Makefile14
-rw-r--r--package/system/utils/fbtest/src/fbtest.c448
-rw-r--r--package/system/utils/hostap-utils/.svn/entries62
-rw-r--r--package/system/utils/hostap-utils/.svn/prop-base/Makefile.svn-base9
-rw-r--r--package/system/utils/hostap-utils/.svn/text-base/Makefile.svn-base44
-rw-r--r--package/system/utils/hostap-utils/Makefile44
-rw-r--r--package/system/utils/nvram/.svn/entries68
-rw-r--r--package/system/utils/nvram/.svn/text-base/Makefile.svn-base60
-rw-r--r--package/system/utils/nvram/Makefile60
-rw-r--r--package/system/utils/nvram/files/.svn/entries62
-rw-r--r--package/system/utils/nvram/files/.svn/prop-base/nvram.init.svn-base5
-rw-r--r--package/system/utils/nvram/files/.svn/text-base/nvram.init.svn-base98
-rwxr-xr-xpackage/system/utils/nvram/files/nvram.init98
-rw-r--r--package/system/utils/nvram/src/.svn/entries232
-rw-r--r--package/system/utils/nvram/src/.svn/text-base/Makefile.svn-base33
-rw-r--r--package/system/utils/nvram/src/.svn/text-base/cli.c.svn-base246
-rw-r--r--package/system/utils/nvram/src/.svn/text-base/crc.c.svn-base69
-rw-r--r--package/system/utils/nvram/src/.svn/text-base/nvram.c.svn-base556
-rw-r--r--package/system/utils/nvram/src/.svn/text-base/nvram.h.svn-base123
-rw-r--r--package/system/utils/nvram/src/.svn/text-base/sdinitvals.h.svn-base30
-rw-r--r--package/system/utils/nvram/src/Makefile33
-rw-r--r--package/system/utils/nvram/src/cli.c246
-rw-r--r--package/system/utils/nvram/src/crc.c69
-rw-r--r--package/system/utils/nvram/src/nvram.c556
-rw-r--r--package/system/utils/nvram/src/nvram.h123
-rw-r--r--package/system/utils/nvram/src/sdinitvals.h30
-rw-r--r--package/system/utils/robocfg/.svn/entries65
-rw-r--r--package/system/utils/robocfg/.svn/prop-base/Makefile.svn-base9
-rw-r--r--package/system/utils/robocfg/.svn/text-base/Makefile.svn-base39
-rw-r--r--package/system/utils/robocfg/Makefile39
-rw-r--r--package/system/utils/robocfg/src/.svn/entries130
-rw-r--r--package/system/utils/robocfg/src/.svn/prop-base/Makefile.svn-base5
-rw-r--r--package/system/utils/robocfg/src/.svn/prop-base/etc53xx.h.svn-base5
-rw-r--r--package/system/utils/robocfg/src/.svn/prop-base/robocfg.c.svn-base5
-rw-r--r--package/system/utils/robocfg/src/.svn/text-base/Makefile.svn-base11
-rw-r--r--package/system/utils/robocfg/src/.svn/text-base/etc53xx.h.svn-base619
-rw-r--r--package/system/utils/robocfg/src/.svn/text-base/robocfg.c.svn-base581
-rw-r--r--package/system/utils/robocfg/src/Makefile11
-rw-r--r--package/system/utils/robocfg/src/etc53xx.h619
-rw-r--r--package/system/utils/robocfg/src/robocfg.c581
-rw-r--r--package/system/utils/usb-modeswitch/.svn/entries65
-rw-r--r--package/system/utils/usb-modeswitch/.svn/text-base/Makefile.svn-base82
-rw-r--r--package/system/utils/usb-modeswitch/Makefile82
-rw-r--r--package/system/utils/usb-modeswitch/files/.svn/entries62
-rw-r--r--package/system/utils/usb-modeswitch/files/.svn/text-base/modeswitch.hotplug.svn-base140
-rw-r--r--package/system/utils/usb-modeswitch/files/modeswitch.hotplug140
-rw-r--r--package/system/utils/usbreset/.svn/entries65
-rw-r--r--package/system/utils/usbreset/.svn/text-base/Makefile.svn-base44
-rw-r--r--package/system/utils/usbreset/Makefile44
-rw-r--r--package/system/utils/usbreset/src/.svn/entries62
-rw-r--r--package/system/utils/usbreset/src/.svn/text-base/usbreset.c.svn-base253
-rw-r--r--package/system/utils/usbreset/src/usbreset.c253
-rw-r--r--package/system/utils/usbutils/.svn/entries62
-rw-r--r--package/system/utils/usbutils/.svn/text-base/Makefile.svn-base57
-rw-r--r--package/system/utils/usbutils/Makefile57
-rw-r--r--package/system/utils/xfsprogs/.svn/entries65
-rw-r--r--package/system/utils/xfsprogs/.svn/text-base/Makefile.svn-base87
-rw-r--r--package/system/utils/xfsprogs/Makefile87
-rw-r--r--package/system/utils/xfsprogs/patches/.svn/entries232
-rw-r--r--package/system/utils/xfsprogs/patches/.svn/text-base/001-automake-compat.patch.svn-base84
-rw-r--r--package/system/utils/xfsprogs/patches/.svn/text-base/100-no_aio.patch.svn-base21
-rw-r--r--package/system/utils/xfsprogs/patches/.svn/text-base/110-uclibc_no_ustat.patch.svn-base36
-rw-r--r--package/system/utils/xfsprogs/patches/.svn/text-base/120-portability.patch.svn-base47
-rw-r--r--package/system/utils/xfsprogs/patches/.svn/text-base/130-uclibc_no_xattr.patch.svn-base36
-rw-r--r--package/system/utils/xfsprogs/patches/.svn/text-base/140-no_po.patch.svn-base20
-rw-r--r--package/system/utils/xfsprogs/patches/001-automake-compat.patch84
-rw-r--r--package/system/utils/xfsprogs/patches/100-no_aio.patch21
-rw-r--r--package/system/utils/xfsprogs/patches/110-uclibc_no_ustat.patch36
-rw-r--r--package/system/utils/xfsprogs/patches/120-portability.patch47
-rw-r--r--package/system/utils/xfsprogs/patches/130-uclibc_no_xattr.patch36
-rw-r--r--package/system/utils/xfsprogs/patches/140-no_po.patch20
-rw-r--r--package/system/vsc73x5-ucode/.svn/entries65
-rw-r--r--package/system/vsc73x5-ucode/.svn/text-base/Makefile.svn-base94
-rw-r--r--package/system/vsc73x5-ucode/Makefile94
-rw-r--r--package/system/vsc73x5-ucode/files/.svn/entries62
-rw-r--r--package/system/vsc73x5-ucode/files/.svn/text-base/Makefile.svn-base20
-rw-r--r--package/system/vsc73x5-ucode/files/Makefile20
-rw-r--r--package/system/w1-gpio-custom/.svn/entries65
-rw-r--r--package/system/w1-gpio-custom/.svn/prop-base/Makefile.svn-base5
-rw-r--r--package/system/w1-gpio-custom/.svn/text-base/Makefile.svn-base54
-rw-r--r--package/system/w1-gpio-custom/Makefile54
-rw-r--r--package/system/w1-gpio-custom/src/.svn/entries130
-rw-r--r--package/system/w1-gpio-custom/src/.svn/prop-base/Makefile.svn-base5
-rw-r--r--package/system/w1-gpio-custom/src/.svn/prop-base/w1-gpio-custom.c.svn-base5
-rw-r--r--package/system/w1-gpio-custom/src/.svn/text-base/Kconfig.svn-base4
-rw-r--r--package/system/w1-gpio-custom/src/.svn/text-base/Makefile.svn-base1
-rw-r--r--package/system/w1-gpio-custom/src/.svn/text-base/w1-gpio-custom.c.svn-base185
-rw-r--r--package/system/w1-gpio-custom/src/Kconfig4
-rw-r--r--package/system/w1-gpio-custom/src/Makefile1
-rw-r--r--package/system/w1-gpio-custom/src/w1-gpio-custom.c185
-rw-r--r--package/system/wrt55agv2-spidevs/.svn/entries65
-rw-r--r--package/system/wrt55agv2-spidevs/.svn/prop-base/Makefile.svn-base5
-rw-r--r--package/system/wrt55agv2-spidevs/.svn/text-base/Makefile.svn-base53
-rw-r--r--package/system/wrt55agv2-spidevs/Makefile53
-rw-r--r--package/system/wrt55agv2-spidevs/src/.svn/entries130
-rw-r--r--package/system/wrt55agv2-spidevs/src/.svn/prop-base/Makefile.svn-base5
-rw-r--r--package/system/wrt55agv2-spidevs/src/.svn/prop-base/wrt55agv2_spidevs.c.svn-base5
-rw-r--r--package/system/wrt55agv2-spidevs/src/.svn/text-base/Kconfig.svn-base3
-rw-r--r--package/system/wrt55agv2-spidevs/src/.svn/text-base/Makefile.svn-base1
-rw-r--r--package/system/wrt55agv2-spidevs/src/.svn/text-base/wrt55agv2_spidevs.c.svn-base114
-rw-r--r--package/system/wrt55agv2-spidevs/src/Kconfig3
-rw-r--r--package/system/wrt55agv2-spidevs/src/Makefile1
-rw-r--r--package/system/wrt55agv2-spidevs/src/wrt55agv2_spidevs.c114
-rw-r--r--package/toolchain/.svn/entries65
-rw-r--r--package/toolchain/.svn/prop-base/Makefile.svn-base9
-rw-r--r--package/toolchain/.svn/text-base/Makefile.svn-base596
-rw-r--r--package/toolchain/Makefile596
-rw-r--r--package/toolchain/eglibc-files/.svn/entries31
-rw-r--r--package/toolchain/eglibc-files/etc/.svn/entries62
-rw-r--r--package/toolchain/eglibc-files/etc/.svn/text-base/nsswitch.conf.svn-base13
-rw-r--r--package/toolchain/eglibc-files/etc/nsswitch.conf13
-rw-r--r--package/trelay/.svn/entries68
-rw-r--r--package/trelay/.svn/text-base/Makefile.svn-base50
-rw-r--r--package/trelay/Makefile50
-rw-r--r--package/trelay/files/.svn/entries130
-rw-r--r--package/trelay/files/.svn/text-base/trelay.config.svn-base4
-rw-r--r--package/trelay/files/.svn/text-base/trelay.hotplug.svn-base5
-rw-r--r--package/trelay/files/.svn/text-base/trelay.init.svn-base32
-rw-r--r--package/trelay/files/trelay.config4
-rw-r--r--package/trelay/files/trelay.hotplug5
-rw-r--r--package/trelay/files/trelay.init32
-rw-r--r--package/trelay/src/.svn/entries96
-rw-r--r--package/trelay/src/.svn/text-base/Makefile.svn-base1
-rw-r--r--package/trelay/src/.svn/text-base/trelay.c.svn-base272
-rw-r--r--package/trelay/src/Makefile1
-rw-r--r--package/trelay/src/trelay.c272
-rw-r--r--package/ubus/.svn/entries65
-rw-r--r--package/ubus/.svn/text-base/Makefile.svn-base84
-rw-r--r--package/ubus/Makefile84
-rw-r--r--package/ubus/files/.svn/entries62
-rw-r--r--package/ubus/files/.svn/prop-base/ubus.init.svn-base5
-rw-r--r--package/ubus/files/.svn/text-base/ubus.init.svn-base14
-rwxr-xr-xpackage/ubus/files/ubus.init14
-rw-r--r--package/uci/.svn/entries65
-rw-r--r--package/uci/.svn/text-base/Makefile.svn-base92
-rw-r--r--package/uci/Makefile92
-rw-r--r--package/uci/files/.svn/entries31
-rw-r--r--package/uci/files/lib/.svn/entries31
-rw-r--r--package/uci/files/lib/config/.svn/entries62
-rw-r--r--package/uci/files/lib/config/.svn/text-base/uci.sh.svn-base137
-rw-r--r--package/uci/files/lib/config/uci.sh137
-rw-r--r--package/udev/.svn/entries99
-rw-r--r--package/udev/.svn/prop-base/Config.in.svn-base5
-rw-r--r--package/udev/.svn/prop-base/Makefile.svn-base9
-rw-r--r--package/udev/.svn/text-base/Config.in.svn-base118
-rw-r--r--package/udev/.svn/text-base/Makefile.svn-base156
-rw-r--r--package/udev/Config.in118
-rw-r--r--package/udev/Makefile156
-rw-r--r--package/udev/patches/.svn/entries130
-rw-r--r--package/udev/patches/.svn/text-base/0001-build-don-t-use-gc-sections.patch.svn-base31
-rw-r--r--package/udev/patches/.svn/text-base/0002-udevd-add-lrt-for-message-queue-symbols.patch.svn-base25
-rw-r--r--package/udev/patches/.svn/text-base/0003-add_btn_trigger_happy_define.patch.svn-base13
-rw-r--r--package/udev/patches/0001-build-don-t-use-gc-sections.patch31
-rw-r--r--package/udev/patches/0002-udevd-add-lrt-for-message-queue-symbols.patch25
-rw-r--r--package/udev/patches/0003-add_btn_trigger_happy_define.patch13
-rw-r--r--package/util-linux/.svn/entries65
-rw-r--r--package/util-linux/.svn/text-base/Makefile.svn-base594
-rw-r--r--package/util-linux/Makefile594
-rw-r--r--package/util-linux/patches/.svn/entries96
-rw-r--r--package/util-linux/patches/.svn/text-base/000-compile.patch.svn-base44
-rw-r--r--package/util-linux/patches/.svn/text-base/001-no-printf-alloc.patch.svn-base108
-rw-r--r--package/util-linux/patches/000-compile.patch44
-rw-r--r--package/util-linux/patches/001-no-printf-alloc.patch108
-rw-r--r--package/zram-swap/.svn/entries65
-rw-r--r--package/zram-swap/.svn/text-base/Makefile.svn-base46
-rw-r--r--package/zram-swap/Makefile46
-rw-r--r--package/zram-swap/files/.svn/entries62
-rw-r--r--package/zram-swap/files/.svn/text-base/zram.init.svn-base123
-rw-r--r--package/zram-swap/files/zram.init123
3739 files changed, 778474 insertions, 0 deletions
diff --git a/package/.svn/dir-prop-base b/package/.svn/dir-prop-base
new file mode 100644
index 0000000..2e7f9aa
--- /dev/null
+++ b/package/.svn/dir-prop-base
@@ -0,0 +1,7 @@
+K 10
+svn:ignore
+V 23
+feeds
+openwrt-packages
+
+END
diff --git a/package/.svn/entries b/package/.svn/entries
new file mode 100644
index 0000000..7a0f0e4
--- /dev/null
+++ b/package/.svn/entries
@@ -0,0 +1,164 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-16T16:11:43.462930Z
+36056
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+kernel
+dir
+
+toolchain
+dir
+
+zram-swap
+dir
+
+mtd
+dir
+
+system
+dir
+
+platform
+dir
+
+broadcom-diag
+dir
+
+network
+dir
+
+block-mount
+dir
+
+mac80211
+dir
+
+devel
+dir
+
+trelay
+dir
+
+mkelfimage
+dir
+
+fuse
+dir
+
+boot
+dir
+
+hotplug2
+dir
+
+acx-mac80211
+dir
+
+broadcom-wl
+dir
+
+mountd
+dir
+
+base-files
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+787dc561c0f96e9aeda6055b9c7bf813
+2012-12-13T13:07:01.478099Z
+34656
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4511
+
+uci
+dir
+
+lua
+dir
+
+px5g
+dir
+
+libs
+dir
+
+busybox
+dir
+
+apex
+dir
+
+opkg
+dir
+
+admswconfig
+dir
+
+switch
+dir
+
+udev
+dir
+
+procd
+dir
+
+util-linux
+dir
+
+linux-atm
+dir
+
+ubus
+dir
+
diff --git a/package/.svn/prop-base/Makefile.svn-base b/package/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/.svn/text-base/Makefile.svn-base b/package/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..df7cf79
--- /dev/null
+++ b/package/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,134 @@
+#
+# Copyright (C) 2006-2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+curdir:=package
+
+-include $(TMP_DIR)/.packagedeps
+$(curdir)/builddirs:=$(sort $(package-) $(package-y) $(package-m))
+$(curdir)/builddirs-install:=.
+ifeq ($(SDK),1)
+else
+ $(curdir)/builddirs-default:=. $(sort $(package-y) $(package-m))
+ $(curdir)/builddirs-prereq:=. $(sort $(prereq-y) $(prereq-m))
+endif
+ifneq ($(IGNORE_ERRORS),)
+ $(curdir)/builddirs-ignore-compile:= $(if $(filter n m y, $(IGNORE_ERRORS)),$(foreach m,$(IGNORE_ERRORS),$(package-$(subst n,,$(m)))),$(package-m) $(package-))
+endif
+
+ifdef CONFIG_USE_MKLIBS
+ define mklibs
+ rm -rf $(TMP_DIR)/mklibs-progs $(TMP_DIR)/mklibs-out
+ # first find all programs and add them to the mklibs list
+ find $(STAGING_DIR_ROOT) -type f -perm +100 -exec \
+ file -r -N -F '' {} + | \
+ awk ' /executable.*dynamically/ { print $$1 }' > $(TMP_DIR)/mklibs-progs
+ # find all loadable objects that are not regular libraries and add them to the list as well
+ find $(STAGING_DIR_ROOT) -type f -name \*.so\* -exec \
+ file -r -N -F '' {} + | \
+ awk ' /shared object/ { print $$1 }' >> $(TMP_DIR)/mklibs-progs
+ mkdir -p $(TMP_DIR)/mklibs-out
+ $(STAGING_DIR_HOST)/bin/mklibs -D \
+ -d $(TMP_DIR)/mklibs-out \
+ --sysroot $(STAGING_DIR_ROOT) \
+ -L /lib \
+ -L /usr/lib \
+ -L /usr/lib/ebtables \
+ --ldlib $(patsubst $(STAGING_DIR_ROOT)/%,/%,$(firstword $(wildcard \
+ $(foreach name,ld-uClibc.so.* ld-linux.so.* ld-*.so, \
+ $(STAGING_DIR_ROOT)/lib/$(name) \
+ )))) \
+ --target $(REAL_GNU_TARGET_NAME) \
+ `cat $(TMP_DIR)/mklibs-progs` 2>&1
+ $(RSTRIP) $(TMP_DIR)/mklibs-out
+ for lib in `ls $(TMP_DIR)/mklibs-out/*.so.* 2>/dev/null`; do \
+ LIB="$${lib##*/}"; \
+ DEST="`ls "$(TARGET_DIR)/lib/$$LIB" "$(TARGET_DIR)/usr/lib/$$LIB" 2>/dev/null`"; \
+ [ -n "$$DEST" ] || continue; \
+ echo "Copying stripped library $$lib to $$DEST"; \
+ cp "$$lib" "$$DEST" || exit 1; \
+ done
+ endef
+endif
+
+# where to build (and put) .ipk packages
+OPKG:= \
+ IPKG_TMP=$(TMP_DIR)/ipkg \
+ IPKG_INSTROOT=$(TARGET_DIR) \
+ IPKG_CONF_DIR=$(STAGING_DIR)/etc \
+ IPKG_OFFLINE_ROOT=$(TARGET_DIR) \
+ $(XARGS) $(STAGING_DIR_HOST)/bin/opkg \
+ --offline-root $(TARGET_DIR) \
+ --force-depends \
+ --force-overwrite \
+ --force-postinstall \
+ --force-maintainer \
+ --add-dest root:/ \
+ --add-arch all:100 \
+ --add-arch $(if $(ARCH_PACKAGES),$(ARCH_PACKAGES),$(BOARD)):200
+
+PACKAGE_INSTALL_FILES:= \
+ $(foreach pkg,$(sort $(package-y)), \
+ $(foreach variant, \
+ $(if $(package/$(pkg)/variants), \
+ $(package/$(pkg)/variants), \
+ $(if $(package/$(pkg)/default-variant), \
+ $(package/$(pkg)/default-variant), \
+ default \
+ ) \
+ ), \
+ $(PKG_INFO_DIR)/$(lastword $(subst /,$(space),$(pkg))).$(variant).install \
+ ) \
+ )
+
+$(curdir)/cleanup: $(TMP_DIR)/.build
+ rm -rf $(STAGING_DIR_ROOT)
+
+$(curdir)/install: $(TMP_DIR)/.build
+ - find $(STAGING_DIR_ROOT) -type d | $(XARGS) chmod 0755
+ rm -rf $(TARGET_DIR)
+ [ -d $(TARGET_DIR)/tmp ] || mkdir -p $(TARGET_DIR)/tmp
+ @$(FIND) `sed -e 's|.*|$(PACKAGE_DIR)/&_*.ipk|' $(PACKAGE_INSTALL_FILES)` | sort -u | $(OPKG) install
+ @for file in $(PACKAGE_INSTALL_FILES); do \
+ [ -s $$file.flags ] || continue; \
+ for flag in `cat $$file.flags`; do \
+ $(OPKG) flag $$flag < $$file; \
+ done; \
+ done || true
+ @-$(MAKE) package/preconfig
+ @if [ -d $(TOPDIR)/files ]; then \
+ $(call file_copy,$(TOPDIR)/files/.,$(TARGET_DIR)); \
+ fi
+ @mkdir -p $(TARGET_DIR)/etc/rc.d
+ @( \
+ cd $(TARGET_DIR); \
+ for script in ./etc/init.d/*; do \
+ grep '#!/bin/sh /etc/rc.common' $$script >/dev/null || continue; \
+ IPKG_INSTROOT=$(TARGET_DIR) $$(which bash) ./etc/rc.common $$script enable; \
+ done || true \
+ )
+ @-find $(TARGET_DIR) -name CVS | $(XARGS) rm -rf
+ @-find $(TARGET_DIR) -name .svn | $(XARGS) rm -rf
+ @-find $(TARGET_DIR) -name '.#*' | $(XARGS) rm -f
+ rm -f $(TARGET_DIR)/usr/lib/opkg/info/*.postinst
+ $(if $(CONFIG_CLEAN_IPKG),rm -rf $(TARGET_DIR)/usr/lib/opkg)
+ $(call mklibs)
+
+$(curdir)/index: FORCE
+ @(cd $(PACKAGE_DIR); $(SCRIPT_DIR)/ipkg-make-index.sh . 2>&1 > Packages && \
+ gzip -9c Packages > Packages.gz \
+ )
+
+$(curdir)/preconfig:
+
+$(curdir)/flags-install:= -j1
+
+$(eval $(call stampfile,$(curdir),package,prereq,.config))
+$(eval $(call stampfile,$(curdir),package,cleanup,$(TMP_DIR)/.build))
+$(eval $(call stampfile,$(curdir),package,compile,$(TMP_DIR)/.build))
+$(eval $(call stampfile,$(curdir),package,install,$(TMP_DIR)/.build))
+
+$(eval $(call subdir,$(curdir)))
diff --git a/package/Makefile b/package/Makefile
new file mode 100644
index 0000000..df7cf79
--- /dev/null
+++ b/package/Makefile
@@ -0,0 +1,134 @@
+#
+# Copyright (C) 2006-2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+curdir:=package
+
+-include $(TMP_DIR)/.packagedeps
+$(curdir)/builddirs:=$(sort $(package-) $(package-y) $(package-m))
+$(curdir)/builddirs-install:=.
+ifeq ($(SDK),1)
+else
+ $(curdir)/builddirs-default:=. $(sort $(package-y) $(package-m))
+ $(curdir)/builddirs-prereq:=. $(sort $(prereq-y) $(prereq-m))
+endif
+ifneq ($(IGNORE_ERRORS),)
+ $(curdir)/builddirs-ignore-compile:= $(if $(filter n m y, $(IGNORE_ERRORS)),$(foreach m,$(IGNORE_ERRORS),$(package-$(subst n,,$(m)))),$(package-m) $(package-))
+endif
+
+ifdef CONFIG_USE_MKLIBS
+ define mklibs
+ rm -rf $(TMP_DIR)/mklibs-progs $(TMP_DIR)/mklibs-out
+ # first find all programs and add them to the mklibs list
+ find $(STAGING_DIR_ROOT) -type f -perm +100 -exec \
+ file -r -N -F '' {} + | \
+ awk ' /executable.*dynamically/ { print $$1 }' > $(TMP_DIR)/mklibs-progs
+ # find all loadable objects that are not regular libraries and add them to the list as well
+ find $(STAGING_DIR_ROOT) -type f -name \*.so\* -exec \
+ file -r -N -F '' {} + | \
+ awk ' /shared object/ { print $$1 }' >> $(TMP_DIR)/mklibs-progs
+ mkdir -p $(TMP_DIR)/mklibs-out
+ $(STAGING_DIR_HOST)/bin/mklibs -D \
+ -d $(TMP_DIR)/mklibs-out \
+ --sysroot $(STAGING_DIR_ROOT) \
+ -L /lib \
+ -L /usr/lib \
+ -L /usr/lib/ebtables \
+ --ldlib $(patsubst $(STAGING_DIR_ROOT)/%,/%,$(firstword $(wildcard \
+ $(foreach name,ld-uClibc.so.* ld-linux.so.* ld-*.so, \
+ $(STAGING_DIR_ROOT)/lib/$(name) \
+ )))) \
+ --target $(REAL_GNU_TARGET_NAME) \
+ `cat $(TMP_DIR)/mklibs-progs` 2>&1
+ $(RSTRIP) $(TMP_DIR)/mklibs-out
+ for lib in `ls $(TMP_DIR)/mklibs-out/*.so.* 2>/dev/null`; do \
+ LIB="$${lib##*/}"; \
+ DEST="`ls "$(TARGET_DIR)/lib/$$LIB" "$(TARGET_DIR)/usr/lib/$$LIB" 2>/dev/null`"; \
+ [ -n "$$DEST" ] || continue; \
+ echo "Copying stripped library $$lib to $$DEST"; \
+ cp "$$lib" "$$DEST" || exit 1; \
+ done
+ endef
+endif
+
+# where to build (and put) .ipk packages
+OPKG:= \
+ IPKG_TMP=$(TMP_DIR)/ipkg \
+ IPKG_INSTROOT=$(TARGET_DIR) \
+ IPKG_CONF_DIR=$(STAGING_DIR)/etc \
+ IPKG_OFFLINE_ROOT=$(TARGET_DIR) \
+ $(XARGS) $(STAGING_DIR_HOST)/bin/opkg \
+ --offline-root $(TARGET_DIR) \
+ --force-depends \
+ --force-overwrite \
+ --force-postinstall \
+ --force-maintainer \
+ --add-dest root:/ \
+ --add-arch all:100 \
+ --add-arch $(if $(ARCH_PACKAGES),$(ARCH_PACKAGES),$(BOARD)):200
+
+PACKAGE_INSTALL_FILES:= \
+ $(foreach pkg,$(sort $(package-y)), \
+ $(foreach variant, \
+ $(if $(package/$(pkg)/variants), \
+ $(package/$(pkg)/variants), \
+ $(if $(package/$(pkg)/default-variant), \
+ $(package/$(pkg)/default-variant), \
+ default \
+ ) \
+ ), \
+ $(PKG_INFO_DIR)/$(lastword $(subst /,$(space),$(pkg))).$(variant).install \
+ ) \
+ )
+
+$(curdir)/cleanup: $(TMP_DIR)/.build
+ rm -rf $(STAGING_DIR_ROOT)
+
+$(curdir)/install: $(TMP_DIR)/.build
+ - find $(STAGING_DIR_ROOT) -type d | $(XARGS) chmod 0755
+ rm -rf $(TARGET_DIR)
+ [ -d $(TARGET_DIR)/tmp ] || mkdir -p $(TARGET_DIR)/tmp
+ @$(FIND) `sed -e 's|.*|$(PACKAGE_DIR)/&_*.ipk|' $(PACKAGE_INSTALL_FILES)` | sort -u | $(OPKG) install
+ @for file in $(PACKAGE_INSTALL_FILES); do \
+ [ -s $$file.flags ] || continue; \
+ for flag in `cat $$file.flags`; do \
+ $(OPKG) flag $$flag < $$file; \
+ done; \
+ done || true
+ @-$(MAKE) package/preconfig
+ @if [ -d $(TOPDIR)/files ]; then \
+ $(call file_copy,$(TOPDIR)/files/.,$(TARGET_DIR)); \
+ fi
+ @mkdir -p $(TARGET_DIR)/etc/rc.d
+ @( \
+ cd $(TARGET_DIR); \
+ for script in ./etc/init.d/*; do \
+ grep '#!/bin/sh /etc/rc.common' $$script >/dev/null || continue; \
+ IPKG_INSTROOT=$(TARGET_DIR) $$(which bash) ./etc/rc.common $$script enable; \
+ done || true \
+ )
+ @-find $(TARGET_DIR) -name CVS | $(XARGS) rm -rf
+ @-find $(TARGET_DIR) -name .svn | $(XARGS) rm -rf
+ @-find $(TARGET_DIR) -name '.#*' | $(XARGS) rm -f
+ rm -f $(TARGET_DIR)/usr/lib/opkg/info/*.postinst
+ $(if $(CONFIG_CLEAN_IPKG),rm -rf $(TARGET_DIR)/usr/lib/opkg)
+ $(call mklibs)
+
+$(curdir)/index: FORCE
+ @(cd $(PACKAGE_DIR); $(SCRIPT_DIR)/ipkg-make-index.sh . 2>&1 > Packages && \
+ gzip -9c Packages > Packages.gz \
+ )
+
+$(curdir)/preconfig:
+
+$(curdir)/flags-install:= -j1
+
+$(eval $(call stampfile,$(curdir),package,prereq,.config))
+$(eval $(call stampfile,$(curdir),package,cleanup,$(TMP_DIR)/.build))
+$(eval $(call stampfile,$(curdir),package,compile,$(TMP_DIR)/.build))
+$(eval $(call stampfile,$(curdir),package,install,$(TMP_DIR)/.build))
+
+$(eval $(call subdir,$(curdir)))
diff --git a/package/acx-mac80211/.svn/entries b/package/acx-mac80211/.svn/entries
new file mode 100644
index 0000000..c3d68de
--- /dev/null
+++ b/package/acx-mac80211/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/acx-mac80211
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-27T21:16:35.211662Z
+35334
+hauke
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+b014cce557c74fd83e872de5af4f34ea
+2013-01-27T21:16:35.211662Z
+35334
+hauke
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+6816
+
diff --git a/package/acx-mac80211/.svn/prop-base/Makefile.svn-base b/package/acx-mac80211/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..f07be99
--- /dev/null
+++ b/package/acx-mac80211/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:copyright
+V 30
+Copyright (C) 2007 OpenWrt.org
+END
diff --git a/package/acx-mac80211/.svn/text-base/Makefile.svn-base b/package/acx-mac80211/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..35f7e39
--- /dev/null
+++ b/package/acx-mac80211/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,254 @@
+#
+# Copyright (C) 2007-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=acx-mac80211
+PKG_REV:=v2012-09-23-WIP
+PKG_VERSION:=20121004
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=git://acx100.git.sourceforge.net/gitroot/acx100/acx-mac80211
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE_VERSION:=$(PKG_REV)
+PKG_MIRROR_MD5SUM:=8d6bc84239059fd938ff4d989579f622
+PKG_BUILD_DEPENDS:=mac80211
+
+PKG_CONFIG_DEPENDS:= \
+ CONFIG_PACKAGE_MAC80211_DEBUGFS \
+ CONFIG_PACKAGE_MAC80211_MESH \
+
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/acx-mac80211
+ SUBMENU:=Wireless Drivers
+ TITLE:=ACX1xx mac80211 driver
+ DEPENDS:=@(PCI_SUPPORT||TARGET_ar7) @mipsel +kmod-mac80211
+ FILES:=$(PKG_BUILD_DIR)/acx-mac80211.ko
+ AUTOLOAD:=$(call AutoLoad,50,acx-mac80211)
+ MAINTAINER:=Florian Fainelli <florian@openwrt.org>
+ MENU:=1
+endef
+
+define KernelPackage/acx-mac80211/config
+ menu "Configuration"
+ depends on PACKAGE_kmod-acx-mac80211
+
+ config ACX_ID_0D
+ bool "ACX1xx Radio ID 0D firmware"
+ help
+ Download and install firmware for:
+ ACX1xx cards with Radio ID 0D into /lib/firmware.
+
+ config ACX_ID_11
+ bool "ACX1xx Radio ID 11 firmware"
+ help
+ Download and install firmware for:
+ ACX1xx cards with Radio ID 11 into /lib/firmware.
+
+ config ACX_ID_15
+ bool "ACX1xx Radio ID 15 firmware"
+ help
+ Download and install firmware for:
+ ACX1xx cards with Radio ID 15 into /lib/firmware.
+
+ config ACX_ID_16
+ bool "ACX1xx Radio ID 16 firmware"
+ default y
+ help
+ Download and install firmware for:
+ ACX1xx cards with Radio ID 16 into /lib/firmware.
+
+ choice
+ prompt "ACX111 firmware version"
+ depends on ACX_ID_16
+ default ACX_DEFAULT if !TARGET_adm5120
+ default ACX_1_2_1_34 if TARGET_adm5120
+ help
+ This option allows you to select the version of the acx firmware.
+
+ config ACX_DEFAULT
+ bool "Default"
+ help
+ Default firmware for ACX111 devices.
+
+ If unsure, select this.
+
+ config ACX_1_2_1_34
+ bool "1.2.1_34"
+ help
+ 1.2.1_34 firmware for ACX111 devices. Works with Zyxel P-334WT.
+
+ If unsure, select the "default" firmware.
+
+ endchoice
+
+ config ACX_ID_17
+ bool "ACX1xx Radio ID 17 firmware"
+ help
+ Download and install firmware for:
+ ACX1xx cards with Radio ID 17 into /lib/firmware.
+
+ config ACX_ID_19
+ bool "ACX1xx Radio ID 19 firmware"
+ default y
+ help
+ Download and install firmware for:
+ ACX1xx cards with Radio ID 19 into /lib/firmware.
+
+ config ACX_ID_1B
+ bool "ACX1xx Radio ID 1B firmware"
+ help
+ Download and install firmware for:
+ ACX1xx cards with Radio ID 1b into /lib/firmware.
+
+ endmenu
+endef
+
+define KernelPackage/acx-mac80211/description
+ Driver for acx111 cards (mac80211 version)
+endef
+
+define Download/tiacx100
+ FILE:=tiacx100
+ URL:=http://acx100.erley.org/fw/acx100_1.9.8.b/
+ MD5SUM:=24a54fd30f7658fcbffc825b0dd7aa5b
+endef
+
+define Download/tiacx100r0d
+ FILE:=tiacx100r0D
+ URL:=http://acx100.erley.org/fw/acx100_1.9.8.b/
+ MD5SUM:=1c7413e7b0be4ef7d1e424a132e17fab
+endef
+
+define Download/tiacx100r11
+ FILE:=tiacx100r11
+ URL:=http://acx100.erley.org/fw/acx100_1.9.8.b/
+ MD5SUM:=a150750ad33c512edc4afee5270b37cb
+endef
+
+define Download/tiacx100r15
+ FILE:=tiacx100r15
+ URL:=http://acx100.erley.org/fw/acx100_1.9.8.b/
+ MD5SUM:=c99d01d4fcf0d6cc00441aff60690be4
+endef
+
+define Download/tiacx111c16
+ FILE:=tiacx111c16
+ URL:=http://acx100.erley.org/fw/acx111_2.3.1.31/
+ MD5SUM:=7026826460376f6b174f9225bd7781b9
+endef
+
+define Download/tiacx111c16_1
+ FILE:=tiacx111c16_1.2.1_34
+ URL:=http://sites.google.com/site/atorkhov/files/
+ MD5SUM:=fcd07de4b25e1d2aaf3b78b27c5b7ee9
+endef
+
+define Download/tiacx111c17
+ FILE:=tiacx111c17
+ URL:=http://acx100.erley.org/fw/acx111_2.3.1.31/
+ MD5SUM:=95552544ca6d2b4e8c6aeb80b8ae7fdf
+endef
+
+define Download/tiacx111c19
+ FILE:=tiacx111c19
+ URL:=http://acx100.erley.org/fw/acx111_2.3.1.31/
+ MD5SUM:=a1fa9681e297b4e36e257090fc12265a
+endef
+
+define Download/tiacx111usbc1b
+ FILE:=tiacx111usbc1B
+ URL:=http://acx100.erley.org/fw/acx111_2.4.0.70-USB/
+ MD5SUM:=c4edecd912b2417779d0b65e3a7dc86d
+endef
+
+PKG_EXTRA_KCONFIG:= \
+ CONFIG_ACX_MAC80211=m \
+ CONFIG_ACX_MAC80211_PCI=m \
+
+PKG_EXTRA_CFLAGS:= \
+ $(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=m,%,$(filter %=m,$(PKG_EXTRA_KCONFIG)))) \
+ $(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=y,%,$(filter %=y,$(PKG_EXTRA_KCONFIG)))) \
+ $(if $(CONFIG_LEDS_TRIGGERS), -DCONFIG_MAC80211_LEDS -DCONFIG_LEDS_TRIGGERS) \
+ $(if $(CONFIG_PACKAGE_MAC80211_DEBUGFS), -DCONFIG_CFG80211_DEBUGFS -DCONFIG_MAC80211_DEBUGFS) \
+ $(if $(CONFIG_PACKAGE_MAC80211_MESH), -DCONFIG_MAC80211_MESH) \
+
+define Build/Compile
+ $(MAKE) -C "$(LINUX_DIR)" \
+ ARCH="$(LINUX_KARCH)" \
+ CROSS_COMPILE="$(TARGET_CROSS)" \
+ SUBDIRS="$(PKG_BUILD_DIR)" \
+ $(PKG_EXTRA_KCONFIG) \
+ EXTRA_CFLAGS="$(PKG_EXTRA_CFLAGS) -DCONFIG_ACX_MAC80211_VERSION=\"KERNEL_VERSION(3,8,0)\"" \
+ LINUXINCLUDE="-I$(STAGING_DIR)/usr/include/mac80211/uapi -I$(STAGING_DIR)/usr/include/mac80211 \
+ -I$(LINUX_DIR)/include -I$(LINUX_DIR)/include/$(LINUX_UAPI_DIR) \
+ -I$(LINUX_DIR)/include/generated/uapi/ -Iarch/$(LINUX_KARCH)/include \
+ -Iarch/$(LINUX_KARCH)/include/$(LINUX_UAPI_DIR) \
+ -include generated/autoconf.h \
+ -include linux/compat-2.6.h" \
+ V="$(V)" \
+ modules
+endef
+
+define Build/Configure
+endef
+
+define KernelPackage/acx-mac80211/install
+ $(INSTALL_DIR) $(1)/lib/firmware
+
+ifneq ($(CONFIG_ACX_ID_0D)$(CONFIG_ACX_ID_11)$(CONFIG_ACX_ID_15),)
+ $(INSTALL_DATA) $(DL_DIR)/tiacx100 $(1)/lib/firmware/
+endif
+
+ifneq ($(CONFIG_ACX_ID_0D),)
+ $(INSTALL_DATA) $(DL_DIR)/tiacx100r0D $(1)/lib/firmware/
+endif
+
+ifneq ($(CONFIG_ACX_ID_11),)
+ $(INSTALL_DATA) $(DL_DIR)/tiacx100r11 $(1)/lib/firmware/
+endif
+
+ifneq ($(CONFIG_ACX_ID_15),)
+ $(INSTALL_DATA) $(DL_DIR)/tiacx100r15 $(1)/lib/firmware/
+endif
+
+ifneq ($(CONFIG_ACX_DEFAULT),)
+ $(INSTALL_DATA) $(DL_DIR)/tiacx111c16 $(1)/lib/firmware/
+endif
+
+ifneq ($(CONFIG_ACX_1_2_1_34),)
+ $(INSTALL_DATA) $(DL_DIR)/tiacx111c16_1.2.1_34 $(1)/lib/firmware/tiacx111c16
+endif
+
+ifneq ($(CONFIG_ACX_ID_17),)
+ $(INSTALL_DATA) $(DL_DIR)/tiacx111c17 $(1)/lib/firmware/
+endif
+
+ifneq ($(CONFIG_ACX_ID_19),)
+ $(INSTALL_DATA) $(DL_DIR)/tiacx111c19 $(1)/lib/firmware/
+endif
+
+ifneq ($(CONFIG_ACX_ID_1B),)
+ $(INSTALL_DATA) $(DL_DIR)/tiacx111usbc1B $(1)/lib/firmware/
+endif
+
+endef
+
+$(eval $(call KernelPackage,acx-mac80211))
+$(eval $(call Download,tiacx100))
+$(eval $(call Download,tiacx100r0d))
+$(eval $(call Download,tiacx100r11))
+$(eval $(call Download,tiacx100r15))
+$(eval $(call Download,tiacx111c16))
+$(eval $(call Download,tiacx111c16_1))
+$(eval $(call Download,tiacx111c17))
+$(eval $(call Download,tiacx111c19))
+$(eval $(call Download,tiacx111usbc1b))
diff --git a/package/acx-mac80211/Makefile b/package/acx-mac80211/Makefile
new file mode 100644
index 0000000..35f7e39
--- /dev/null
+++ b/package/acx-mac80211/Makefile
@@ -0,0 +1,254 @@
+#
+# Copyright (C) 2007-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=acx-mac80211
+PKG_REV:=v2012-09-23-WIP
+PKG_VERSION:=20121004
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=git://acx100.git.sourceforge.net/gitroot/acx100/acx-mac80211
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE_VERSION:=$(PKG_REV)
+PKG_MIRROR_MD5SUM:=8d6bc84239059fd938ff4d989579f622
+PKG_BUILD_DEPENDS:=mac80211
+
+PKG_CONFIG_DEPENDS:= \
+ CONFIG_PACKAGE_MAC80211_DEBUGFS \
+ CONFIG_PACKAGE_MAC80211_MESH \
+
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/acx-mac80211
+ SUBMENU:=Wireless Drivers
+ TITLE:=ACX1xx mac80211 driver
+ DEPENDS:=@(PCI_SUPPORT||TARGET_ar7) @mipsel +kmod-mac80211
+ FILES:=$(PKG_BUILD_DIR)/acx-mac80211.ko
+ AUTOLOAD:=$(call AutoLoad,50,acx-mac80211)
+ MAINTAINER:=Florian Fainelli <florian@openwrt.org>
+ MENU:=1
+endef
+
+define KernelPackage/acx-mac80211/config
+ menu "Configuration"
+ depends on PACKAGE_kmod-acx-mac80211
+
+ config ACX_ID_0D
+ bool "ACX1xx Radio ID 0D firmware"
+ help
+ Download and install firmware for:
+ ACX1xx cards with Radio ID 0D into /lib/firmware.
+
+ config ACX_ID_11
+ bool "ACX1xx Radio ID 11 firmware"
+ help
+ Download and install firmware for:
+ ACX1xx cards with Radio ID 11 into /lib/firmware.
+
+ config ACX_ID_15
+ bool "ACX1xx Radio ID 15 firmware"
+ help
+ Download and install firmware for:
+ ACX1xx cards with Radio ID 15 into /lib/firmware.
+
+ config ACX_ID_16
+ bool "ACX1xx Radio ID 16 firmware"
+ default y
+ help
+ Download and install firmware for:
+ ACX1xx cards with Radio ID 16 into /lib/firmware.
+
+ choice
+ prompt "ACX111 firmware version"
+ depends on ACX_ID_16
+ default ACX_DEFAULT if !TARGET_adm5120
+ default ACX_1_2_1_34 if TARGET_adm5120
+ help
+ This option allows you to select the version of the acx firmware.
+
+ config ACX_DEFAULT
+ bool "Default"
+ help
+ Default firmware for ACX111 devices.
+
+ If unsure, select this.
+
+ config ACX_1_2_1_34
+ bool "1.2.1_34"
+ help
+ 1.2.1_34 firmware for ACX111 devices. Works with Zyxel P-334WT.
+
+ If unsure, select the "default" firmware.
+
+ endchoice
+
+ config ACX_ID_17
+ bool "ACX1xx Radio ID 17 firmware"
+ help
+ Download and install firmware for:
+ ACX1xx cards with Radio ID 17 into /lib/firmware.
+
+ config ACX_ID_19
+ bool "ACX1xx Radio ID 19 firmware"
+ default y
+ help
+ Download and install firmware for:
+ ACX1xx cards with Radio ID 19 into /lib/firmware.
+
+ config ACX_ID_1B
+ bool "ACX1xx Radio ID 1B firmware"
+ help
+ Download and install firmware for:
+ ACX1xx cards with Radio ID 1b into /lib/firmware.
+
+ endmenu
+endef
+
+define KernelPackage/acx-mac80211/description
+ Driver for acx111 cards (mac80211 version)
+endef
+
+define Download/tiacx100
+ FILE:=tiacx100
+ URL:=http://acx100.erley.org/fw/acx100_1.9.8.b/
+ MD5SUM:=24a54fd30f7658fcbffc825b0dd7aa5b
+endef
+
+define Download/tiacx100r0d
+ FILE:=tiacx100r0D
+ URL:=http://acx100.erley.org/fw/acx100_1.9.8.b/
+ MD5SUM:=1c7413e7b0be4ef7d1e424a132e17fab
+endef
+
+define Download/tiacx100r11
+ FILE:=tiacx100r11
+ URL:=http://acx100.erley.org/fw/acx100_1.9.8.b/
+ MD5SUM:=a150750ad33c512edc4afee5270b37cb
+endef
+
+define Download/tiacx100r15
+ FILE:=tiacx100r15
+ URL:=http://acx100.erley.org/fw/acx100_1.9.8.b/
+ MD5SUM:=c99d01d4fcf0d6cc00441aff60690be4
+endef
+
+define Download/tiacx111c16
+ FILE:=tiacx111c16
+ URL:=http://acx100.erley.org/fw/acx111_2.3.1.31/
+ MD5SUM:=7026826460376f6b174f9225bd7781b9
+endef
+
+define Download/tiacx111c16_1
+ FILE:=tiacx111c16_1.2.1_34
+ URL:=http://sites.google.com/site/atorkhov/files/
+ MD5SUM:=fcd07de4b25e1d2aaf3b78b27c5b7ee9
+endef
+
+define Download/tiacx111c17
+ FILE:=tiacx111c17
+ URL:=http://acx100.erley.org/fw/acx111_2.3.1.31/
+ MD5SUM:=95552544ca6d2b4e8c6aeb80b8ae7fdf
+endef
+
+define Download/tiacx111c19
+ FILE:=tiacx111c19
+ URL:=http://acx100.erley.org/fw/acx111_2.3.1.31/
+ MD5SUM:=a1fa9681e297b4e36e257090fc12265a
+endef
+
+define Download/tiacx111usbc1b
+ FILE:=tiacx111usbc1B
+ URL:=http://acx100.erley.org/fw/acx111_2.4.0.70-USB/
+ MD5SUM:=c4edecd912b2417779d0b65e3a7dc86d
+endef
+
+PKG_EXTRA_KCONFIG:= \
+ CONFIG_ACX_MAC80211=m \
+ CONFIG_ACX_MAC80211_PCI=m \
+
+PKG_EXTRA_CFLAGS:= \
+ $(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=m,%,$(filter %=m,$(PKG_EXTRA_KCONFIG)))) \
+ $(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=y,%,$(filter %=y,$(PKG_EXTRA_KCONFIG)))) \
+ $(if $(CONFIG_LEDS_TRIGGERS), -DCONFIG_MAC80211_LEDS -DCONFIG_LEDS_TRIGGERS) \
+ $(if $(CONFIG_PACKAGE_MAC80211_DEBUGFS), -DCONFIG_CFG80211_DEBUGFS -DCONFIG_MAC80211_DEBUGFS) \
+ $(if $(CONFIG_PACKAGE_MAC80211_MESH), -DCONFIG_MAC80211_MESH) \
+
+define Build/Compile
+ $(MAKE) -C "$(LINUX_DIR)" \
+ ARCH="$(LINUX_KARCH)" \
+ CROSS_COMPILE="$(TARGET_CROSS)" \
+ SUBDIRS="$(PKG_BUILD_DIR)" \
+ $(PKG_EXTRA_KCONFIG) \
+ EXTRA_CFLAGS="$(PKG_EXTRA_CFLAGS) -DCONFIG_ACX_MAC80211_VERSION=\"KERNEL_VERSION(3,8,0)\"" \
+ LINUXINCLUDE="-I$(STAGING_DIR)/usr/include/mac80211/uapi -I$(STAGING_DIR)/usr/include/mac80211 \
+ -I$(LINUX_DIR)/include -I$(LINUX_DIR)/include/$(LINUX_UAPI_DIR) \
+ -I$(LINUX_DIR)/include/generated/uapi/ -Iarch/$(LINUX_KARCH)/include \
+ -Iarch/$(LINUX_KARCH)/include/$(LINUX_UAPI_DIR) \
+ -include generated/autoconf.h \
+ -include linux/compat-2.6.h" \
+ V="$(V)" \
+ modules
+endef
+
+define Build/Configure
+endef
+
+define KernelPackage/acx-mac80211/install
+ $(INSTALL_DIR) $(1)/lib/firmware
+
+ifneq ($(CONFIG_ACX_ID_0D)$(CONFIG_ACX_ID_11)$(CONFIG_ACX_ID_15),)
+ $(INSTALL_DATA) $(DL_DIR)/tiacx100 $(1)/lib/firmware/
+endif
+
+ifneq ($(CONFIG_ACX_ID_0D),)
+ $(INSTALL_DATA) $(DL_DIR)/tiacx100r0D $(1)/lib/firmware/
+endif
+
+ifneq ($(CONFIG_ACX_ID_11),)
+ $(INSTALL_DATA) $(DL_DIR)/tiacx100r11 $(1)/lib/firmware/
+endif
+
+ifneq ($(CONFIG_ACX_ID_15),)
+ $(INSTALL_DATA) $(DL_DIR)/tiacx100r15 $(1)/lib/firmware/
+endif
+
+ifneq ($(CONFIG_ACX_DEFAULT),)
+ $(INSTALL_DATA) $(DL_DIR)/tiacx111c16 $(1)/lib/firmware/
+endif
+
+ifneq ($(CONFIG_ACX_1_2_1_34),)
+ $(INSTALL_DATA) $(DL_DIR)/tiacx111c16_1.2.1_34 $(1)/lib/firmware/tiacx111c16
+endif
+
+ifneq ($(CONFIG_ACX_ID_17),)
+ $(INSTALL_DATA) $(DL_DIR)/tiacx111c17 $(1)/lib/firmware/
+endif
+
+ifneq ($(CONFIG_ACX_ID_19),)
+ $(INSTALL_DATA) $(DL_DIR)/tiacx111c19 $(1)/lib/firmware/
+endif
+
+ifneq ($(CONFIG_ACX_ID_1B),)
+ $(INSTALL_DATA) $(DL_DIR)/tiacx111usbc1B $(1)/lib/firmware/
+endif
+
+endef
+
+$(eval $(call KernelPackage,acx-mac80211))
+$(eval $(call Download,tiacx100))
+$(eval $(call Download,tiacx100r0d))
+$(eval $(call Download,tiacx100r11))
+$(eval $(call Download,tiacx100r15))
+$(eval $(call Download,tiacx111c16))
+$(eval $(call Download,tiacx111c16_1))
+$(eval $(call Download,tiacx111c17))
+$(eval $(call Download,tiacx111c19))
+$(eval $(call Download,tiacx111usbc1b))
diff --git a/package/acx-mac80211/patches/.svn/entries b/package/acx-mac80211/patches/.svn/entries
new file mode 100644
index 0000000..25fdc64
--- /dev/null
+++ b/package/acx-mac80211/patches/.svn/entries
@@ -0,0 +1,164 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/acx-mac80211/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-27T21:16:35.211662Z
+35334
+hauke
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+200-initial-macaddr.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+bb93bcae5733f6b37428028a3c8e9bee
+2013-01-27T21:15:48.247678Z
+35333
+hauke
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+958
+
+001-make-compatible-with-recent-mac80211.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+1af339f8463ecd47a73f0f736bbeac22
+2013-01-27T21:15:48.247678Z
+35333
+hauke
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+956
+
+002-remove-usage-of__dev.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+3702d4c533e6e78d550bbba01277a052
+2013-01-27T21:16:35.211662Z
+35334
+hauke
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2674
+
+100-hw-queue-check-fix.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+f27adfc451037dafa81f84d9e03af09b
+2013-01-27T21:15:48.247678Z
+35333
+hauke
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1395
+
diff --git a/package/acx-mac80211/patches/.svn/text-base/001-make-compatible-with-recent-mac80211.patch.svn-base b/package/acx-mac80211/patches/.svn/text-base/001-make-compatible-with-recent-mac80211.patch.svn-base
new file mode 100644
index 0000000..707ba8b
--- /dev/null
+++ b/package/acx-mac80211/patches/.svn/text-base/001-make-compatible-with-recent-mac80211.patch.svn-base
@@ -0,0 +1,30 @@
+--- a/main.h
++++ b/main.h
+@@ -44,8 +44,11 @@ int acx_e_op_get_tx_stats(struct ieee802
+
+ #if CONFIG_ACX_MAC80211_VERSION < KERNEL_VERSION(2, 6, 39)
+ int acx_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb);
+-#else
++#elif CONFIG_ACX_MAC80211_VERSION < KERNEL_VERSION(3, 7, 0)
+ void acx_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb);
++#else
++void acx_op_tx(struct ieee80211_hw *hw, struct ieee80211_tx_control *control,
++ struct sk_buff *skb);
+ #endif
+
+
+--- a/main.c
++++ b/main.c
+@@ -1024,7 +1024,12 @@ int acx_e_op_get_tx_stats(struct ieee802
+ * acx_compat, and hiding this #if/else. OTOH, inclusion doesnt care
+ * about old kernels
+ */
++#if CONFIG_ACX_MAC80211_VERSION < KERNEL_VERSION(3, 7, 0)
+ OP_TX_RET_TYPE acx_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
++#else
++void acx_op_tx(struct ieee80211_hw *hw, struct ieee80211_tx_control *control,
++ struct sk_buff *skb)
++#endif
+ {
+ acx_device_t *adev = ieee2adev(hw);
+
diff --git a/package/acx-mac80211/patches/.svn/text-base/002-remove-usage-of__dev.patch.svn-base b/package/acx-mac80211/patches/.svn/text-base/002-remove-usage-of__dev.patch.svn-base
new file mode 100644
index 0000000..f16d3b6
--- /dev/null
+++ b/package/acx-mac80211/patches/.svn/text-base/002-remove-usage-of__dev.patch.svn-base
@@ -0,0 +1,85 @@
+--- a/mem.c
++++ b/mem.c
+@@ -2002,7 +2002,7 @@ int acx100mem_ioctl_set_phy_amp_bias(str
+ * configuration
+ * id - ptr to the device id entry that matched this device
+ */
+-static int __devinit acxmem_probe(struct platform_device *pdev)
++static int acxmem_probe(struct platform_device *pdev)
+ {
+ acx_device_t *adev = NULL;
+ const char *chip_name;
+@@ -2268,7 +2268,7 @@ done:
+ * pdev - ptr to PCI device structure containing info about pci
+ * configuration
+ */
+-static int __devexit acxmem_remove(struct platform_device *pdev)
++static int acxmem_remove(struct platform_device *pdev)
+ {
+ struct ieee80211_hw *hw = (struct ieee80211_hw *)
+ platform_get_drvdata(pdev);
+@@ -2470,7 +2470,7 @@ static struct platform_driver acxmem_dri
+ .name = "acx-mem",
+ },
+ .probe = acxmem_probe,
+- .remove = __devexit_p(acxmem_remove),
++ .remove = acxmem_remove,
+
+ #ifdef CONFIG_PM
+ .suspend = acxmem_e_suspend,
+--- a/pci.c
++++ b/pci.c
+@@ -982,7 +982,7 @@ int acx100pci_ioctl_set_phy_amp_bias(str
+ * id - ptr to the device id entry that matched this device
+ */
+ #ifdef CONFIG_PCI
+-static int __devinit acxpci_probe(struct pci_dev *pdev,
++static int acxpci_probe(struct pci_dev *pdev,
+ const struct pci_device_id *id)
+ {
+ acx111_ie_configoption_t co;
+@@ -1346,7 +1346,7 @@ done:
+ *
+ * pdev - ptr to PCI device structure containing info about pci configuration
+ */
+-static void __devexit acxpci_remove(struct pci_dev *pdev)
++static void acxpci_remove(struct pci_dev *pdev)
+ {
+ struct ieee80211_hw *hw
+ = (struct ieee80211_hw *) pci_get_drvdata(pdev);
+@@ -1537,7 +1537,7 @@ static int acxpci_e_resume(struct pci_de
+ */
+
+ #if 0 // use later ?
+-static struct acxpci_device_info acxpci_info_tbl[] __devinitdata = {
++static struct acxpci_device_info acxpci_info_tbl[] = {
+ [0] = {
+ .part_name = "acx111",
+ .helper_image = "tiacx1111r16", // probly wrong !!
+@@ -1564,7 +1564,7 @@ static struct pci_driver acxpci_driver =
+ .name = "acx_pci",
+ .id_table = acxpci_id_tbl,
+ .probe = acxpci_probe,
+- .remove = __devexit_p(acxpci_remove),
++ .remove = acxpci_remove,
+ #ifdef CONFIG_PM
+ .suspend = acxpci_e_suspend,
+ .resume = acxpci_e_resume
+@@ -1662,7 +1662,7 @@ static struct vlynq_device_id acx_vlynq_
+ };
+
+
+-static __devinit int vlynq_probe(struct vlynq_device *vdev,
++static int vlynq_probe(struct vlynq_device *vdev,
+ struct vlynq_device_id *id)
+ {
+ int result = -EIO, i;
+@@ -1971,7 +1971,7 @@ static struct vlynq_driver vlynq_acx = {
+ .name = "acx_vlynq",
+ .id_table = acx_vlynq_id,
+ .probe = vlynq_probe,
+- .remove = __devexit_p(vlynq_remove),
++ .remove = vlynq_remove,
+ };
+ #endif /* CONFIG_VLYNQ */
+
diff --git a/package/acx-mac80211/patches/.svn/text-base/100-hw-queue-check-fix.patch.svn-base b/package/acx-mac80211/patches/.svn/text-base/100-hw-queue-check-fix.patch.svn-base
new file mode 100644
index 0000000..73366f3
--- /dev/null
+++ b/package/acx-mac80211/patches/.svn/text-base/100-hw-queue-check-fix.patch.svn-base
@@ -0,0 +1,42 @@
+--- a/mem.c
++++ b/mem.c
+@@ -2036,7 +2036,7 @@ static int acxmem_probe(struct platform_
+ */
+ ieee->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION)
+ | BIT(NL80211_IFTYPE_ADHOC);
+- ieee->queues = 1;
++ ieee->queues = 4;
+ /* OW TODO Check if RTS/CTS threshold can be included here */
+
+ /* TODO: although in the original driver the maximum value was
+--- a/pci.c
++++ b/pci.c
+@@ -1022,7 +1022,7 @@ static int acxpci_probe(struct pci_dev *
+ BIT(NL80211_IFTYPE_STATION) |
+ BIT(NL80211_IFTYPE_ADHOC) |
+ BIT(NL80211_IFTYPE_AP);
+- ieee->queues = 1;
++ ieee->queues = 4;
+ /* OW TODO Check if RTS/CTS threshold can be included here */
+
+ /* TODO: although in the original driver the maximum value was
+@@ -1691,7 +1691,7 @@ static int vlynq_probe(struct vlynq_devi
+ BIT(NL80211_IFTYPE_STATION) |
+ BIT(NL80211_IFTYPE_ADHOC) |
+ BIT(NL80211_IFTYPE_AP);
+- ieee->queues = 1;
++ ieee->queues = 4;
+
+ /* We base signal quality on winlevel approach of previous driver
+ * TODO OW 20100615 This should into a common init code
+--- a/usb.c
++++ b/usb.c
+@@ -1624,7 +1624,7 @@ acxusb_probe(struct usb_interface *intf,
+ */
+ ieee->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION)
+ | BIT(NL80211_IFTYPE_ADHOC);
+- ieee->queues = 1;
++ ieee->queues = 4;
+ // OW TODO Check if RTS/CTS threshold can be included here
+
+ // We base signal quality on winlevel approach of previous driver
diff --git a/package/acx-mac80211/patches/.svn/text-base/200-initial-macaddr.patch.svn-base b/package/acx-mac80211/patches/.svn/text-base/200-initial-macaddr.patch.svn-base
new file mode 100644
index 0000000..cc82fec
--- /dev/null
+++ b/package/acx-mac80211/patches/.svn/text-base/200-initial-macaddr.patch.svn-base
@@ -0,0 +1,31 @@
+--- a/cardsetting.c
++++ b/cardsetting.c
+@@ -710,12 +710,27 @@ static int acx1xx_get_station_id(acx_dev
+ u8 stationID[4 + acx_ie_descs[ACX1xx_IE_DOT11_STATION_ID].len];
+ const u8 *paddr;
+ int i, res;
++ const char *prom_addr;
++ char *prom_getenv(const char *name);
+
+
+
+ res = acx_interrogate(adev, &stationID, ACX1xx_IE_DOT11_STATION_ID);
+ paddr = &stationID[4];
+- for (i = 0; i < ETH_ALEN; i++) {
++ prom_addr = NULL;
++#ifdef CONFIG_VLYNQ
++ prom_addr = prom_getenv("macwlan");
++ if (prom_addr == NULL)
++ prom_addr = prom_getenv("mac_ap");
++#endif
++ if (prom_addr)
++ sscanf(prom_addr, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", adev->dev_addr,
++ adev->dev_addr + 1,
++ adev->dev_addr + 2,
++ adev->dev_addr + 3,
++ adev->dev_addr + 4,
++ adev->dev_addr + 5);
++ else for (i = 0; i < ETH_ALEN; i++) {
+ /* we copy the MAC address (reversed in the card) to
+ * the netdevice's MAC address, and on ifup it will be
+ * copied into iwadev->dev_addr */
diff --git a/package/acx-mac80211/patches/001-make-compatible-with-recent-mac80211.patch b/package/acx-mac80211/patches/001-make-compatible-with-recent-mac80211.patch
new file mode 100644
index 0000000..707ba8b
--- /dev/null
+++ b/package/acx-mac80211/patches/001-make-compatible-with-recent-mac80211.patch
@@ -0,0 +1,30 @@
+--- a/main.h
++++ b/main.h
+@@ -44,8 +44,11 @@ int acx_e_op_get_tx_stats(struct ieee802
+
+ #if CONFIG_ACX_MAC80211_VERSION < KERNEL_VERSION(2, 6, 39)
+ int acx_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb);
+-#else
++#elif CONFIG_ACX_MAC80211_VERSION < KERNEL_VERSION(3, 7, 0)
+ void acx_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb);
++#else
++void acx_op_tx(struct ieee80211_hw *hw, struct ieee80211_tx_control *control,
++ struct sk_buff *skb);
+ #endif
+
+
+--- a/main.c
++++ b/main.c
+@@ -1024,7 +1024,12 @@ int acx_e_op_get_tx_stats(struct ieee802
+ * acx_compat, and hiding this #if/else. OTOH, inclusion doesnt care
+ * about old kernels
+ */
++#if CONFIG_ACX_MAC80211_VERSION < KERNEL_VERSION(3, 7, 0)
+ OP_TX_RET_TYPE acx_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
++#else
++void acx_op_tx(struct ieee80211_hw *hw, struct ieee80211_tx_control *control,
++ struct sk_buff *skb)
++#endif
+ {
+ acx_device_t *adev = ieee2adev(hw);
+
diff --git a/package/acx-mac80211/patches/002-remove-usage-of__dev.patch b/package/acx-mac80211/patches/002-remove-usage-of__dev.patch
new file mode 100644
index 0000000..f16d3b6
--- /dev/null
+++ b/package/acx-mac80211/patches/002-remove-usage-of__dev.patch
@@ -0,0 +1,85 @@
+--- a/mem.c
++++ b/mem.c
+@@ -2002,7 +2002,7 @@ int acx100mem_ioctl_set_phy_amp_bias(str
+ * configuration
+ * id - ptr to the device id entry that matched this device
+ */
+-static int __devinit acxmem_probe(struct platform_device *pdev)
++static int acxmem_probe(struct platform_device *pdev)
+ {
+ acx_device_t *adev = NULL;
+ const char *chip_name;
+@@ -2268,7 +2268,7 @@ done:
+ * pdev - ptr to PCI device structure containing info about pci
+ * configuration
+ */
+-static int __devexit acxmem_remove(struct platform_device *pdev)
++static int acxmem_remove(struct platform_device *pdev)
+ {
+ struct ieee80211_hw *hw = (struct ieee80211_hw *)
+ platform_get_drvdata(pdev);
+@@ -2470,7 +2470,7 @@ static struct platform_driver acxmem_dri
+ .name = "acx-mem",
+ },
+ .probe = acxmem_probe,
+- .remove = __devexit_p(acxmem_remove),
++ .remove = acxmem_remove,
+
+ #ifdef CONFIG_PM
+ .suspend = acxmem_e_suspend,
+--- a/pci.c
++++ b/pci.c
+@@ -982,7 +982,7 @@ int acx100pci_ioctl_set_phy_amp_bias(str
+ * id - ptr to the device id entry that matched this device
+ */
+ #ifdef CONFIG_PCI
+-static int __devinit acxpci_probe(struct pci_dev *pdev,
++static int acxpci_probe(struct pci_dev *pdev,
+ const struct pci_device_id *id)
+ {
+ acx111_ie_configoption_t co;
+@@ -1346,7 +1346,7 @@ done:
+ *
+ * pdev - ptr to PCI device structure containing info about pci configuration
+ */
+-static void __devexit acxpci_remove(struct pci_dev *pdev)
++static void acxpci_remove(struct pci_dev *pdev)
+ {
+ struct ieee80211_hw *hw
+ = (struct ieee80211_hw *) pci_get_drvdata(pdev);
+@@ -1537,7 +1537,7 @@ static int acxpci_e_resume(struct pci_de
+ */
+
+ #if 0 // use later ?
+-static struct acxpci_device_info acxpci_info_tbl[] __devinitdata = {
++static struct acxpci_device_info acxpci_info_tbl[] = {
+ [0] = {
+ .part_name = "acx111",
+ .helper_image = "tiacx1111r16", // probly wrong !!
+@@ -1564,7 +1564,7 @@ static struct pci_driver acxpci_driver =
+ .name = "acx_pci",
+ .id_table = acxpci_id_tbl,
+ .probe = acxpci_probe,
+- .remove = __devexit_p(acxpci_remove),
++ .remove = acxpci_remove,
+ #ifdef CONFIG_PM
+ .suspend = acxpci_e_suspend,
+ .resume = acxpci_e_resume
+@@ -1662,7 +1662,7 @@ static struct vlynq_device_id acx_vlynq_
+ };
+
+
+-static __devinit int vlynq_probe(struct vlynq_device *vdev,
++static int vlynq_probe(struct vlynq_device *vdev,
+ struct vlynq_device_id *id)
+ {
+ int result = -EIO, i;
+@@ -1971,7 +1971,7 @@ static struct vlynq_driver vlynq_acx = {
+ .name = "acx_vlynq",
+ .id_table = acx_vlynq_id,
+ .probe = vlynq_probe,
+- .remove = __devexit_p(vlynq_remove),
++ .remove = vlynq_remove,
+ };
+ #endif /* CONFIG_VLYNQ */
+
diff --git a/package/acx-mac80211/patches/100-hw-queue-check-fix.patch b/package/acx-mac80211/patches/100-hw-queue-check-fix.patch
new file mode 100644
index 0000000..73366f3
--- /dev/null
+++ b/package/acx-mac80211/patches/100-hw-queue-check-fix.patch
@@ -0,0 +1,42 @@
+--- a/mem.c
++++ b/mem.c
+@@ -2036,7 +2036,7 @@ static int acxmem_probe(struct platform_
+ */
+ ieee->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION)
+ | BIT(NL80211_IFTYPE_ADHOC);
+- ieee->queues = 1;
++ ieee->queues = 4;
+ /* OW TODO Check if RTS/CTS threshold can be included here */
+
+ /* TODO: although in the original driver the maximum value was
+--- a/pci.c
++++ b/pci.c
+@@ -1022,7 +1022,7 @@ static int acxpci_probe(struct pci_dev *
+ BIT(NL80211_IFTYPE_STATION) |
+ BIT(NL80211_IFTYPE_ADHOC) |
+ BIT(NL80211_IFTYPE_AP);
+- ieee->queues = 1;
++ ieee->queues = 4;
+ /* OW TODO Check if RTS/CTS threshold can be included here */
+
+ /* TODO: although in the original driver the maximum value was
+@@ -1691,7 +1691,7 @@ static int vlynq_probe(struct vlynq_devi
+ BIT(NL80211_IFTYPE_STATION) |
+ BIT(NL80211_IFTYPE_ADHOC) |
+ BIT(NL80211_IFTYPE_AP);
+- ieee->queues = 1;
++ ieee->queues = 4;
+
+ /* We base signal quality on winlevel approach of previous driver
+ * TODO OW 20100615 This should into a common init code
+--- a/usb.c
++++ b/usb.c
+@@ -1624,7 +1624,7 @@ acxusb_probe(struct usb_interface *intf,
+ */
+ ieee->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION)
+ | BIT(NL80211_IFTYPE_ADHOC);
+- ieee->queues = 1;
++ ieee->queues = 4;
+ // OW TODO Check if RTS/CTS threshold can be included here
+
+ // We base signal quality on winlevel approach of previous driver
diff --git a/package/acx-mac80211/patches/200-initial-macaddr.patch b/package/acx-mac80211/patches/200-initial-macaddr.patch
new file mode 100644
index 0000000..cc82fec
--- /dev/null
+++ b/package/acx-mac80211/patches/200-initial-macaddr.patch
@@ -0,0 +1,31 @@
+--- a/cardsetting.c
++++ b/cardsetting.c
+@@ -710,12 +710,27 @@ static int acx1xx_get_station_id(acx_dev
+ u8 stationID[4 + acx_ie_descs[ACX1xx_IE_DOT11_STATION_ID].len];
+ const u8 *paddr;
+ int i, res;
++ const char *prom_addr;
++ char *prom_getenv(const char *name);
+
+
+
+ res = acx_interrogate(adev, &stationID, ACX1xx_IE_DOT11_STATION_ID);
+ paddr = &stationID[4];
+- for (i = 0; i < ETH_ALEN; i++) {
++ prom_addr = NULL;
++#ifdef CONFIG_VLYNQ
++ prom_addr = prom_getenv("macwlan");
++ if (prom_addr == NULL)
++ prom_addr = prom_getenv("mac_ap");
++#endif
++ if (prom_addr)
++ sscanf(prom_addr, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", adev->dev_addr,
++ adev->dev_addr + 1,
++ adev->dev_addr + 2,
++ adev->dev_addr + 3,
++ adev->dev_addr + 4,
++ adev->dev_addr + 5);
++ else for (i = 0; i < ETH_ALEN; i++) {
+ /* we copy the MAC address (reversed in the card) to
+ * the netdevice's MAC address, and on ifup it will be
+ * copied into iwadev->dev_addr */
diff --git a/package/admswconfig/.svn/entries b/package/admswconfig/.svn/entries
new file mode 100644
index 0000000..ec67a60
--- /dev/null
+++ b/package/admswconfig/.svn/entries
@@ -0,0 +1,68 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/admswconfig
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-10T13:21:54.109631Z
+33703
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+files
+dir
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+8b0f3f51c8f9149cbb208343369928d9
+2012-10-10T13:21:54.109631Z
+33703
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1506
+
diff --git a/package/admswconfig/.svn/text-base/Makefile.svn-base b/package/admswconfig/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..e16258f
--- /dev/null
+++ b/package/admswconfig/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,52 @@
+#
+# Copyright (C) 2007 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=admswconfig
+PKG_VERSION:=0.1
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://downloads.openwrt.org/sources
+PKG_MD5SUM:=faafd4618f970119a665b11b21ac6a26
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/admswconfig
+ SECTION:=utils
+ CATEGORY:=Utilities
+ TITLE:=ADM5120 Switch configuration tool
+ DEPENDS:=@TARGET_adm5120
+ URL:=http://sharon.esrac.ele.tue.nl/users/pe1rxq/linux-adm/admswconfig/
+ MAINTAINER:=Florian Fainelli <florian@openwrt.org>
+endef
+
+define Package/admswconfig/description
+ A program to configure the internal ethernet switch of an ADM5120 processor.
+ You need the corresponding driver for the switch in the kernel.
+ With this program you can configure which ports of the switch belong
+ to the different ethernet devices.
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+ $(TARGET_CC) $(TARGET_CFLAGS) -Os $(PKG_BUILD_DIR)/admswconfig.c -o $(PKG_BUILD_DIR)/$(PKG_NAME)
+endef
+
+define Package/admswconfig/install
+ $(INSTALL_DIR) $(1)/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/admswconfig $(1)/sbin/
+ $(INSTALL_DIR) $(1)/lib/network/
+ $(INSTALL_DATA) ./files/admswswitch.sh $(1)/lib/network/admswswitch.sh
+ $(INSTALL_DIR) $(1)/etc/init.d
+ $(INSTALL_BIN) ./files/admswconfig $(1)/etc/init.d/admswconfig
+endef
+
+$(eval $(call BuildPackage,admswconfig))
diff --git a/package/admswconfig/Makefile b/package/admswconfig/Makefile
new file mode 100644
index 0000000..e16258f
--- /dev/null
+++ b/package/admswconfig/Makefile
@@ -0,0 +1,52 @@
+#
+# Copyright (C) 2007 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=admswconfig
+PKG_VERSION:=0.1
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://downloads.openwrt.org/sources
+PKG_MD5SUM:=faafd4618f970119a665b11b21ac6a26
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/admswconfig
+ SECTION:=utils
+ CATEGORY:=Utilities
+ TITLE:=ADM5120 Switch configuration tool
+ DEPENDS:=@TARGET_adm5120
+ URL:=http://sharon.esrac.ele.tue.nl/users/pe1rxq/linux-adm/admswconfig/
+ MAINTAINER:=Florian Fainelli <florian@openwrt.org>
+endef
+
+define Package/admswconfig/description
+ A program to configure the internal ethernet switch of an ADM5120 processor.
+ You need the corresponding driver for the switch in the kernel.
+ With this program you can configure which ports of the switch belong
+ to the different ethernet devices.
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+ $(TARGET_CC) $(TARGET_CFLAGS) -Os $(PKG_BUILD_DIR)/admswconfig.c -o $(PKG_BUILD_DIR)/$(PKG_NAME)
+endef
+
+define Package/admswconfig/install
+ $(INSTALL_DIR) $(1)/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/admswconfig $(1)/sbin/
+ $(INSTALL_DIR) $(1)/lib/network/
+ $(INSTALL_DATA) ./files/admswswitch.sh $(1)/lib/network/admswswitch.sh
+ $(INSTALL_DIR) $(1)/etc/init.d
+ $(INSTALL_BIN) ./files/admswconfig $(1)/etc/init.d/admswconfig
+endef
+
+$(eval $(call BuildPackage,admswconfig))
diff --git a/package/admswconfig/files/.svn/entries b/package/admswconfig/files/.svn/entries
new file mode 100644
index 0000000..3b8fe7d
--- /dev/null
+++ b/package/admswconfig/files/.svn/entries
@@ -0,0 +1,96 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/admswconfig/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2011-01-27T21:49:50.030327Z
+25173
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+admswconfig
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+8d17c96209c6c9f3e9334e393040d629
+2008-03-20T20:11:21.745522Z
+10635
+thepeople
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1460
+
+admswswitch.sh
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+c9dc70f83d4bd6e997a5828bad6d4578
+2011-01-27T21:49:50.030327Z
+25173
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+456
+
diff --git a/package/admswconfig/files/.svn/text-base/admswconfig.svn-base b/package/admswconfig/files/.svn/text-base/admswconfig.svn-base
new file mode 100644
index 0000000..7231030
--- /dev/null
+++ b/package/admswconfig/files/.svn/text-base/admswconfig.svn-base
@@ -0,0 +1,68 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2006 OpenWrt.org
+
+START=05
+
+start() {
+ [ -e /etc/config/network ] && exit 0
+
+ mkdir -p /etc/config
+
+ board_name=$(awk 'BEGIN{FS="[ \t]+:[ \t]"} /system type/ {print $2}' /proc/cpuinfo)
+
+ case "$board_name" in
+ "Compex WP54"*)
+ board="Compex WP54";;
+ esac
+
+ echo "$board" |awk '
+ function p(cfgname, name) {
+ if (c[name] != "") print " option " cfgname " \"" c[name] "\""
+ }
+
+ BEGIN {
+ FS="="
+ c["lan_ifname"]="eth0"
+ c["wan_ifname"]="eth1"
+ c["eth0ports"]="1 2 3 4"
+ c["eth1ports"]="0"
+ }
+ END {
+ board=$1
+ if (board == "Compex WP54") {
+ c["eth0ports"]="0"
+ c["eth1ports"]="1"
+ }
+
+ print "#### VLAN configuration "
+ print "config switch"
+ p("eth0", "eth0ports")
+ p("eth1", "eth1ports")
+ print ""
+ print ""
+ print "#### Loopback configuration"
+ print "config interface loopback"
+ print " option ifname \"lo\""
+ print " option proto static"
+ print " option ipaddr 127.0.0.1"
+ print " option netmask 255.0.0.0"
+ print ""
+ print ""
+ print "#### LAN configuration"
+ print "config interface lan"
+ print " option type bridge"
+ p("ifname", "lan_ifname")
+ p("macaddr", "lan_macaddr")
+ print " option proto static"
+ print " option ipaddr 192.168.1.1"
+ print " option netmask 255.255.255.0"
+ print ""
+ print ""
+ print "#### WAN configuration"
+ print "config interface wan"
+ p("ifname", "wan_ifname")
+ p("macaddr", "wan_macaddr")
+ print " option proto dhcp"
+ }' > /etc/config/network
+}
+
diff --git a/package/admswconfig/files/.svn/text-base/admswswitch.sh.svn-base b/package/admswconfig/files/.svn/text-base/admswswitch.sh.svn-base
new file mode 100644
index 0000000..984d7ee
--- /dev/null
+++ b/package/admswconfig/files/.svn/text-base/admswswitch.sh.svn-base
@@ -0,0 +1,28 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+
+setup_switch_vlan() {
+ config_get ports "$CONFIG_SECTION" "eth$1"
+ ports=`echo "$ports"| sed s/" "/""/g`
+ ifconfig eth$1 down
+ admswconfig eth$1 ${ports}c
+ ifconfig eth$1 up
+}
+
+setup_switch() {
+ config_cb() {
+ case "$1" in
+ switch)
+ option_cb() {
+ case "$1" in
+ eth*) setup_switch_vlan "${1##eth}";;
+ esac
+ }
+ ;;
+ *)
+ option_cb() { return 0; }
+ ;;
+ esac
+ }
+ config_load network
+}
diff --git a/package/admswconfig/files/admswconfig b/package/admswconfig/files/admswconfig
new file mode 100644
index 0000000..7231030
--- /dev/null
+++ b/package/admswconfig/files/admswconfig
@@ -0,0 +1,68 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2006 OpenWrt.org
+
+START=05
+
+start() {
+ [ -e /etc/config/network ] && exit 0
+
+ mkdir -p /etc/config
+
+ board_name=$(awk 'BEGIN{FS="[ \t]+:[ \t]"} /system type/ {print $2}' /proc/cpuinfo)
+
+ case "$board_name" in
+ "Compex WP54"*)
+ board="Compex WP54";;
+ esac
+
+ echo "$board" |awk '
+ function p(cfgname, name) {
+ if (c[name] != "") print " option " cfgname " \"" c[name] "\""
+ }
+
+ BEGIN {
+ FS="="
+ c["lan_ifname"]="eth0"
+ c["wan_ifname"]="eth1"
+ c["eth0ports"]="1 2 3 4"
+ c["eth1ports"]="0"
+ }
+ END {
+ board=$1
+ if (board == "Compex WP54") {
+ c["eth0ports"]="0"
+ c["eth1ports"]="1"
+ }
+
+ print "#### VLAN configuration "
+ print "config switch"
+ p("eth0", "eth0ports")
+ p("eth1", "eth1ports")
+ print ""
+ print ""
+ print "#### Loopback configuration"
+ print "config interface loopback"
+ print " option ifname \"lo\""
+ print " option proto static"
+ print " option ipaddr 127.0.0.1"
+ print " option netmask 255.0.0.0"
+ print ""
+ print ""
+ print "#### LAN configuration"
+ print "config interface lan"
+ print " option type bridge"
+ p("ifname", "lan_ifname")
+ p("macaddr", "lan_macaddr")
+ print " option proto static"
+ print " option ipaddr 192.168.1.1"
+ print " option netmask 255.255.255.0"
+ print ""
+ print ""
+ print "#### WAN configuration"
+ print "config interface wan"
+ p("ifname", "wan_ifname")
+ p("macaddr", "wan_macaddr")
+ print " option proto dhcp"
+ }' > /etc/config/network
+}
+
diff --git a/package/admswconfig/files/admswswitch.sh b/package/admswconfig/files/admswswitch.sh
new file mode 100644
index 0000000..984d7ee
--- /dev/null
+++ b/package/admswconfig/files/admswswitch.sh
@@ -0,0 +1,28 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+
+setup_switch_vlan() {
+ config_get ports "$CONFIG_SECTION" "eth$1"
+ ports=`echo "$ports"| sed s/" "/""/g`
+ ifconfig eth$1 down
+ admswconfig eth$1 ${ports}c
+ ifconfig eth$1 up
+}
+
+setup_switch() {
+ config_cb() {
+ case "$1" in
+ switch)
+ option_cb() {
+ case "$1" in
+ eth*) setup_switch_vlan "${1##eth}";;
+ esac
+ }
+ ;;
+ *)
+ option_cb() { return 0; }
+ ;;
+ esac
+ }
+ config_load network
+}
diff --git a/package/admswconfig/patches/.svn/entries b/package/admswconfig/patches/.svn/entries
new file mode 100644
index 0000000..b8b9a4a
--- /dev/null
+++ b/package/admswconfig/patches/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/admswconfig/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2010-03-26T14:27:16.438756Z
+20450
+juhosg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+001-matrix.patch
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+728023700fc2530fe88998cc89f71bae
+2010-03-26T14:27:16.438756Z
+20450
+juhosg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+396
+
diff --git a/package/admswconfig/patches/.svn/text-base/001-matrix.patch.svn-base b/package/admswconfig/patches/.svn/text-base/001-matrix.patch.svn-base
new file mode 100644
index 0000000..e50d515
--- /dev/null
+++ b/package/admswconfig/patches/.svn/text-base/001-matrix.patch.svn-base
@@ -0,0 +1,15 @@
+--- a/admswconfig.c
++++ b/admswconfig.c
+@@ -111,9 +111,9 @@ int main(int argc, char **argv)
+ }
+ } else {
+ /* display matrix */
+- printf("ethX\tport0\tport1\tport2\tport3\tport4");
+- if (info.ports == 6)
+- printf("\tport5");
++ printf("ethX");
++ for (i = 0; i < info.ports; i++)
++ printf("\tport%d", i);
+ printf("\tCPU\n");
+ for (i = 0; i < info.ports; i++) {
+ printf("%d", i);
diff --git a/package/admswconfig/patches/001-matrix.patch b/package/admswconfig/patches/001-matrix.patch
new file mode 100644
index 0000000..e50d515
--- /dev/null
+++ b/package/admswconfig/patches/001-matrix.patch
@@ -0,0 +1,15 @@
+--- a/admswconfig.c
++++ b/admswconfig.c
+@@ -111,9 +111,9 @@ int main(int argc, char **argv)
+ }
+ } else {
+ /* display matrix */
+- printf("ethX\tport0\tport1\tport2\tport3\tport4");
+- if (info.ports == 6)
+- printf("\tport5");
++ printf("ethX");
++ for (i = 0; i < info.ports; i++)
++ printf("\tport%d", i);
+ printf("\tCPU\n");
+ for (i = 0; i < info.ports; i++) {
+ printf("%d", i);
diff --git a/package/apex/.svn/entries b/package/apex/.svn/entries
new file mode 100644
index 0000000..d42b75e
--- /dev/null
+++ b/package/apex/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/apex
+svn://svn.openwrt.org/openwrt
+
+
+
+2011-03-07T12:59:19.899892Z
+25928
+kaloz
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+d7321cdfb9ce523732df57abcef8338d
+2011-03-07T12:59:19.899892Z
+25928
+kaloz
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1413
+
diff --git a/package/apex/.svn/text-base/Makefile.svn-base b/package/apex/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..f17118e
--- /dev/null
+++ b/package/apex/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,58 @@
+#
+# Copyright (C) 2006-2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=apex
+PKG_VERSION:=1.6.9
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=ftp://ftp.buici.com/pub/apex/ \
+ ftp://metalab.unc.edu/pub/Linux/system/boot/apex/
+PKG_MD5SUM:=9606cf2e3fd2c9a86fe0b61388509a30
+PKG_TARGETS:=bin
+
+include $(INCLUDE_DIR)/package.mk
+
+export GCC_HONOUR_COPTS=s
+
+define Package/apex
+ SECTION:=boot
+ CATEGORY:=Boot Loaders
+ DEPENDS:=@TARGET_ixp4xx
+ DEFAULT:=y
+ TITLE:=Boot loader for NSLU2, FSG3, NAS100D and others
+ URL:=http://wiki.buici.com/wiki/Apex_Bootloader
+endef
+
+define build_apex
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ ARCH=arm \
+ $(1)_config
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ $(TARGET_CONFIGURE_OPTS) \
+ KBUILD_HAVE_NLS=no \
+ ARCH=arm \
+ clean all
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/apex.bin $(PKG_BUILD_DIR)/out/apex-$(2).bin
+endef
+
+define Build/Compile
+ $(INSTALL_DIR) $(PKG_BUILD_DIR)/out
+ $(call build_apex,slugos-nslu2-armeb,nslu2-armeb)
+ $(call build_apex,slugos-nslu2-16mb-armeb,nslu2-16mb-armeb)
+ $(call build_apex,slugos-fsg3-armeb,fsg3-armeb)
+ $(call build_apex,slugos-nas100d-armeb,nas100d-armeb)
+endef
+
+define Package/apex/install
+ $(INSTALL_DIR) $(STAGING_DIR)/apex
+ $(CP) $(PKG_BUILD_DIR)/out/*.bin $(1)/
+endef
+
+$(eval $(call BuildPackage,apex))
diff --git a/package/apex/Makefile b/package/apex/Makefile
new file mode 100644
index 0000000..f17118e
--- /dev/null
+++ b/package/apex/Makefile
@@ -0,0 +1,58 @@
+#
+# Copyright (C) 2006-2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=apex
+PKG_VERSION:=1.6.9
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=ftp://ftp.buici.com/pub/apex/ \
+ ftp://metalab.unc.edu/pub/Linux/system/boot/apex/
+PKG_MD5SUM:=9606cf2e3fd2c9a86fe0b61388509a30
+PKG_TARGETS:=bin
+
+include $(INCLUDE_DIR)/package.mk
+
+export GCC_HONOUR_COPTS=s
+
+define Package/apex
+ SECTION:=boot
+ CATEGORY:=Boot Loaders
+ DEPENDS:=@TARGET_ixp4xx
+ DEFAULT:=y
+ TITLE:=Boot loader for NSLU2, FSG3, NAS100D and others
+ URL:=http://wiki.buici.com/wiki/Apex_Bootloader
+endef
+
+define build_apex
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ ARCH=arm \
+ $(1)_config
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ $(TARGET_CONFIGURE_OPTS) \
+ KBUILD_HAVE_NLS=no \
+ ARCH=arm \
+ clean all
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/apex.bin $(PKG_BUILD_DIR)/out/apex-$(2).bin
+endef
+
+define Build/Compile
+ $(INSTALL_DIR) $(PKG_BUILD_DIR)/out
+ $(call build_apex,slugos-nslu2-armeb,nslu2-armeb)
+ $(call build_apex,slugos-nslu2-16mb-armeb,nslu2-16mb-armeb)
+ $(call build_apex,slugos-fsg3-armeb,fsg3-armeb)
+ $(call build_apex,slugos-nas100d-armeb,nas100d-armeb)
+endef
+
+define Package/apex/install
+ $(INSTALL_DIR) $(STAGING_DIR)/apex
+ $(CP) $(PKG_BUILD_DIR)/out/*.bin $(1)/
+endef
+
+$(eval $(call BuildPackage,apex))
diff --git a/package/apex/patches/.svn/entries b/package/apex/patches/.svn/entries
new file mode 100644
index 0000000..40e8b24
--- /dev/null
+++ b/package/apex/patches/.svn/entries
@@ -0,0 +1,232 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/apex/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2010-11-02T08:37:46.822980Z
+23768
+acoul
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+120-openwrt_nslu2_16mb_armeb_config.patch
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+039656dbef5ac403ee5620e96dacf5c2
+2010-09-04T17:02:18.401938Z
+22900
+acoul
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1107
+
+160-openwrt_nas100d_armeb_config.patch
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+09c05b5cb135d38c52969ee0583d353a
+2010-09-04T17:02:18.401938Z
+22900
+acoul
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+785
+
+100-openwrt_nslu2_armeb_config.patch
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+60256afb56a939341945b7ffb8e2b7fa
+2010-09-04T17:02:18.401938Z
+22900
+acoul
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1091
+
+150-limit_ram_to_64mb.patch
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+6a5d7aaae1ebd6fd55ecf66dadcb060f
+2010-03-26T14:27:22.385650Z
+20451
+juhosg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+782
+
+001-compile_fix.patch
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+69084a0af38c1a8bd561fcfaa2614793
+2010-11-02T08:37:46.822980Z
+23768
+acoul
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+599
+
+140-openwrt_fsg3_armeb_config.patch
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+c143fcc28ecb1ee220434f0f429d1018
+2010-03-26T14:27:22.385650Z
+20451
+juhosg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+986
+
diff --git a/package/apex/patches/.svn/prop-base/100-openwrt_nslu2_armeb_config.patch.svn-base b/package/apex/patches/.svn/prop-base/100-openwrt_nslu2_armeb_config.patch.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/apex/patches/.svn/prop-base/100-openwrt_nslu2_armeb_config.patch.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/apex/patches/.svn/text-base/001-compile_fix.patch.svn-base b/package/apex/patches/.svn/text-base/001-compile_fix.patch.svn-base
new file mode 100644
index 0000000..8a25de6
--- /dev/null
+++ b/package/apex/patches/.svn/text-base/001-compile_fix.patch.svn-base
@@ -0,0 +1,20 @@
+--- a/Makefile
++++ b/Makefile
+@@ -444,7 +444,7 @@ ifeq ($(config-targets),1)
+ include $(srctree)/src/arch-$(SRCARCH)/Makefile
+ export KBUILD_DEFCONFIG
+
+-config %config: scripts_basic outputmakefile FORCE
++%config: scripts_basic outputmakefile FORCE
+ $(Q)mkdir -p include/linux include/config
+ $(Q)$(MAKE) $(build)=scripts/kconfig $@
+
+@@ -1585,7 +1585,7 @@ endif
+ $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
+
+ # Modules
+-/ %/: prepare scripts FORCE
++%/: prepare scripts FORCE
+ $(cmd_crmodverdir)
+ $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
+ $(build)=$(build-dir)
diff --git a/package/apex/patches/.svn/text-base/100-openwrt_nslu2_armeb_config.patch.svn-base b/package/apex/patches/.svn/text-base/100-openwrt_nslu2_armeb_config.patch.svn-base
new file mode 100644
index 0000000..7e9cfdf
--- /dev/null
+++ b/package/apex/patches/.svn/text-base/100-openwrt_nslu2_armeb_config.patch.svn-base
@@ -0,0 +1,23 @@
+--- a/src/mach-ixp42x/slugos-nslu2-armeb_config
++++ b/src/mach-ixp42x/slugos-nslu2-armeb_config
+@@ -19,7 +19,7 @@ CONFIG_EXPERIMENTAL=y
+ #
+ # General Setup
+ #
+-CONFIG_TARGET_DESCRIPTION="SlugOS NSLU2 (bigendian)"
++CONFIG_TARGET_DESCRIPTION="OpenWRT NSLU2 (8MiB Flash)"
+ CONFIG_CROSS_COMPILE=""
+ CONFIG_AEABI=y
+ # CONFIG_DRIVER_LONG_LONG_SIZE is not set
+@@ -163,9 +163,9 @@ CONFIG_ENV_REGION_KERNEL_ALT="fis://kern
+ # Overrides
+ #
+ CONFIG_ENV_DEFAULT_CMDLINE_OVERRIDE=y
+-CONFIG_ENV_DEFAULT_CMDLINE="root=/dev/mtdblock4 rootfstype=jffs2 console=ttyS0,115200 init=/linuxrc"
++CONFIG_ENV_DEFAULT_CMDLINE="root=/dev/mtdblock4 rootfstype=squashfs,jffs2 console=ttyS0,115200 init=/etc/preinit noinitrd"
+ CONFIG_ENV_DEFAULT_CMDLINE_ALT_P=y
+-CONFIG_ENV_DEFAULT_CMDLINE_ALT="root=/dev/mtdblock4 rootfstype=jffs2 console=ttyS0,115200 init=/linuxrc"
++CONFIG_ENV_DEFAULT_CMDLINE_ALT="root=/dev/mtdblock4 rootfstype=squashfs,jffs2 console=ttyS0,115200 init=/etc/preinit noinitrd"
+ # CONFIG_ENV_DEFAULT_STARTUP_OVERRIDE is not set
+ # CONFIG_ENV_DEFAULT_STARTUP_ALT_P is not set
+ CONFIG_USES_NOR_BOOTFLASH=y
diff --git a/package/apex/patches/.svn/text-base/120-openwrt_nslu2_16mb_armeb_config.patch.svn-base b/package/apex/patches/.svn/text-base/120-openwrt_nslu2_16mb_armeb_config.patch.svn-base
new file mode 100644
index 0000000..614ef7f
--- /dev/null
+++ b/package/apex/patches/.svn/text-base/120-openwrt_nslu2_16mb_armeb_config.patch.svn-base
@@ -0,0 +1,23 @@
+--- a/src/mach-ixp42x/slugos-nslu2-16mb-armeb_config
++++ b/src/mach-ixp42x/slugos-nslu2-16mb-armeb_config
+@@ -19,7 +19,7 @@ CONFIG_EXPERIMENTAL=y
+ #
+ # General Setup
+ #
+-CONFIG_TARGET_DESCRIPTION="SlugOS NSLU2/BE (16MiB Flash)"
++CONFIG_TARGET_DESCRIPTION="OpenWRT NSLU2 (16MiB Flash)"
+ CONFIG_CROSS_COMPILE=""
+ CONFIG_AEABI=y
+ # CONFIG_DRIVER_LONG_LONG_SIZE is not set
+@@ -163,9 +163,9 @@ CONFIG_ENV_REGION_KERNEL_ALT="fis://kern
+ # Overrides
+ #
+ CONFIG_ENV_DEFAULT_CMDLINE_OVERRIDE=y
+-CONFIG_ENV_DEFAULT_CMDLINE="root=/dev/mtdblock4 rootfstype=jffs2 console=ttyS0,115200 init=/linuxrc"
++CONFIG_ENV_DEFAULT_CMDLINE="root=/dev/mtdblock4 rootfstype=squashfs,jffs2 console=ttyS0,115200 init=/etc/preinit noinitrd"
+ CONFIG_ENV_DEFAULT_CMDLINE_ALT_P=y
+-CONFIG_ENV_DEFAULT_CMDLINE_ALT="root=/dev/mtdblock4 rootfstype=jffs2 console=ttyS0,115200 init=/linuxrc"
++CONFIG_ENV_DEFAULT_CMDLINE_ALT="root=/dev/mtdblock4 rootfstype=squashfs,jffs2 console=ttyS0,115200 init=/etc/preinit noinitrd"
+ # CONFIG_ENV_DEFAULT_STARTUP_OVERRIDE is not set
+ # CONFIG_ENV_DEFAULT_STARTUP_ALT_P is not set
+ CONFIG_USES_NOR_BOOTFLASH=y
diff --git a/package/apex/patches/.svn/text-base/140-openwrt_fsg3_armeb_config.patch.svn-base b/package/apex/patches/.svn/text-base/140-openwrt_fsg3_armeb_config.patch.svn-base
new file mode 100644
index 0000000..a1651e6
--- /dev/null
+++ b/package/apex/patches/.svn/text-base/140-openwrt_fsg3_armeb_config.patch.svn-base
@@ -0,0 +1,23 @@
+--- a/src/mach-ixp42x/slugos-fsg3-armeb_config
++++ b/src/mach-ixp42x/slugos-fsg3-armeb_config
+@@ -17,7 +17,7 @@ CONFIG_EXPERIMENTAL=y
+ #
+ # General Setup
+ #
+-CONFIG_TARGET_DESCRIPTION="SlugOS FSG3/BE"
++CONFIG_TARGET_DESCRIPTION="OpenWRT FSG3"
+ CONFIG_CROSS_COMPILE=""
+ CONFIG_AEABI=y
+ CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+@@ -148,9 +148,9 @@ CONFIG_ENV_REGION_KERNEL_ALT="fis://kern
+ # Overrides
+ #
+ CONFIG_ENV_DEFAULT_CMDLINE_OVERRIDE=y
+-CONFIG_ENV_DEFAULT_CMDLINE="root=/dev/sda1 rootdelay=10 console=ttyS0,115200"
++CONFIG_ENV_DEFAULT_CMDLINE="root=/dev/sda1 rootdelay=10 console=ttyS0,115200 init=/etc/preinit noinitrd"
+ CONFIG_ENV_DEFAULT_CMDLINE_ALT_P=y
+-CONFIG_ENV_DEFAULT_CMDLINE_ALT="root=/dev/sda2 rootdelay=10 console=ttyS0,115200"
++CONFIG_ENV_DEFAULT_CMDLINE_ALT="root=/dev/mtdblock2 rootfstype=squashfs console=ttyS0,115200 init=/etc/preinit noinitrd"
+ # CONFIG_ENV_DEFAULT_STARTUP_OVERRIDE is not set
+ # CONFIG_ENV_DEFAULT_STARTUP_ALT_P is not set
+ CONFIG_USES_NOR_BOOTFLASH=y
diff --git a/package/apex/patches/.svn/text-base/150-limit_ram_to_64mb.patch.svn-base b/package/apex/patches/.svn/text-base/150-limit_ram_to_64mb.patch.svn-base
new file mode 100644
index 0000000..3e17816
--- /dev/null
+++ b/package/apex/patches/.svn/text-base/150-limit_ram_to_64mb.patch.svn-base
@@ -0,0 +1,22 @@
+--- a/src/mach-ixp42x/slugos-nslu2-armeb_config
++++ b/src/mach-ixp42x/slugos-nslu2-armeb_config
+@@ -137,7 +137,7 @@ CONFIG_AUTOBOOT_DELAY=10
+ CONFIG_ENV_STARTUP_KERNEL_COPY=y
+ # CONFIG_ENV_REGION_KERNEL_SWAP is not set
+ CONFIG_ENV_STARTUP_PREFIX_P=y
+-CONFIG_ENV_STARTUP_PREFIX="sdram-init; memscan -u 0+256m"
++CONFIG_ENV_STARTUP_PREFIX="sdram-init; memscan -u 0+64m"
+
+ #
+ # Regions
+--- a/src/mach-ixp42x/slugos-nslu2-16mb-armeb_config
++++ b/src/mach-ixp42x/slugos-nslu2-16mb-armeb_config
+@@ -137,7 +137,7 @@ CONFIG_AUTOBOOT_DELAY=10
+ CONFIG_ENV_STARTUP_KERNEL_COPY=y
+ # CONFIG_ENV_REGION_KERNEL_SWAP is not set
+ CONFIG_ENV_STARTUP_PREFIX_P=y
+-CONFIG_ENV_STARTUP_PREFIX="sdram-init; memscan -u 0+256m"
++CONFIG_ENV_STARTUP_PREFIX="sdram-init; memscan -u 0+64m"
+
+ #
+ # Regions
diff --git a/package/apex/patches/.svn/text-base/160-openwrt_nas100d_armeb_config.patch.svn-base b/package/apex/patches/.svn/text-base/160-openwrt_nas100d_armeb_config.patch.svn-base
new file mode 100644
index 0000000..0b0c985
--- /dev/null
+++ b/package/apex/patches/.svn/text-base/160-openwrt_nas100d_armeb_config.patch.svn-base
@@ -0,0 +1,20 @@
+--- a/src/mach-ixp42x/slugos-nas100d-armeb_config
++++ b/src/mach-ixp42x/slugos-nas100d-armeb_config
+@@ -19,7 +19,7 @@ CONFIG_EXPERIMENTAL=y
+ #
+ # General Setup
+ #
+-CONFIG_TARGET_DESCRIPTION="SlugOS NAS100D/BE"
++CONFIG_TARGET_DESCRIPTION="OpenWRT NAS100D"
+ CONFIG_CROSS_COMPILE=""
+ CONFIG_AEABI=y
+ # CONFIG_DRIVER_LONG_LONG_SIZE is not set
+@@ -158,7 +158,7 @@ CONFIG_ENV_REGION_KERNEL="fis://kernel"
+ # Overrides
+ #
+ CONFIG_ENV_DEFAULT_CMDLINE_OVERRIDE=y
+-CONFIG_ENV_DEFAULT_CMDLINE="root=/dev/mtdblock2 rootfstype=jffs2 console=ttyS0,115200 init=/linuxrc"
++CONFIG_ENV_DEFAULT_CMDLINE="root=/dev/mtdblock2 rootfstype=squashfs,jffs2 console=ttyS0,115200 init=/etc/preinit noinitrd"
+ # CONFIG_ENV_DEFAULT_STARTUP_OVERRIDE is not set
+ CONFIG_USES_NOR_BOOTFLASH=y
+ CONFIG_RELOCATE_SIMPLE=y
diff --git a/package/apex/patches/001-compile_fix.patch b/package/apex/patches/001-compile_fix.patch
new file mode 100644
index 0000000..8a25de6
--- /dev/null
+++ b/package/apex/patches/001-compile_fix.patch
@@ -0,0 +1,20 @@
+--- a/Makefile
++++ b/Makefile
+@@ -444,7 +444,7 @@ ifeq ($(config-targets),1)
+ include $(srctree)/src/arch-$(SRCARCH)/Makefile
+ export KBUILD_DEFCONFIG
+
+-config %config: scripts_basic outputmakefile FORCE
++%config: scripts_basic outputmakefile FORCE
+ $(Q)mkdir -p include/linux include/config
+ $(Q)$(MAKE) $(build)=scripts/kconfig $@
+
+@@ -1585,7 +1585,7 @@ endif
+ $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
+
+ # Modules
+-/ %/: prepare scripts FORCE
++%/: prepare scripts FORCE
+ $(cmd_crmodverdir)
+ $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
+ $(build)=$(build-dir)
diff --git a/package/apex/patches/100-openwrt_nslu2_armeb_config.patch b/package/apex/patches/100-openwrt_nslu2_armeb_config.patch
new file mode 100644
index 0000000..7e9cfdf
--- /dev/null
+++ b/package/apex/patches/100-openwrt_nslu2_armeb_config.patch
@@ -0,0 +1,23 @@
+--- a/src/mach-ixp42x/slugos-nslu2-armeb_config
++++ b/src/mach-ixp42x/slugos-nslu2-armeb_config
+@@ -19,7 +19,7 @@ CONFIG_EXPERIMENTAL=y
+ #
+ # General Setup
+ #
+-CONFIG_TARGET_DESCRIPTION="SlugOS NSLU2 (bigendian)"
++CONFIG_TARGET_DESCRIPTION="OpenWRT NSLU2 (8MiB Flash)"
+ CONFIG_CROSS_COMPILE=""
+ CONFIG_AEABI=y
+ # CONFIG_DRIVER_LONG_LONG_SIZE is not set
+@@ -163,9 +163,9 @@ CONFIG_ENV_REGION_KERNEL_ALT="fis://kern
+ # Overrides
+ #
+ CONFIG_ENV_DEFAULT_CMDLINE_OVERRIDE=y
+-CONFIG_ENV_DEFAULT_CMDLINE="root=/dev/mtdblock4 rootfstype=jffs2 console=ttyS0,115200 init=/linuxrc"
++CONFIG_ENV_DEFAULT_CMDLINE="root=/dev/mtdblock4 rootfstype=squashfs,jffs2 console=ttyS0,115200 init=/etc/preinit noinitrd"
+ CONFIG_ENV_DEFAULT_CMDLINE_ALT_P=y
+-CONFIG_ENV_DEFAULT_CMDLINE_ALT="root=/dev/mtdblock4 rootfstype=jffs2 console=ttyS0,115200 init=/linuxrc"
++CONFIG_ENV_DEFAULT_CMDLINE_ALT="root=/dev/mtdblock4 rootfstype=squashfs,jffs2 console=ttyS0,115200 init=/etc/preinit noinitrd"
+ # CONFIG_ENV_DEFAULT_STARTUP_OVERRIDE is not set
+ # CONFIG_ENV_DEFAULT_STARTUP_ALT_P is not set
+ CONFIG_USES_NOR_BOOTFLASH=y
diff --git a/package/apex/patches/120-openwrt_nslu2_16mb_armeb_config.patch b/package/apex/patches/120-openwrt_nslu2_16mb_armeb_config.patch
new file mode 100644
index 0000000..614ef7f
--- /dev/null
+++ b/package/apex/patches/120-openwrt_nslu2_16mb_armeb_config.patch
@@ -0,0 +1,23 @@
+--- a/src/mach-ixp42x/slugos-nslu2-16mb-armeb_config
++++ b/src/mach-ixp42x/slugos-nslu2-16mb-armeb_config
+@@ -19,7 +19,7 @@ CONFIG_EXPERIMENTAL=y
+ #
+ # General Setup
+ #
+-CONFIG_TARGET_DESCRIPTION="SlugOS NSLU2/BE (16MiB Flash)"
++CONFIG_TARGET_DESCRIPTION="OpenWRT NSLU2 (16MiB Flash)"
+ CONFIG_CROSS_COMPILE=""
+ CONFIG_AEABI=y
+ # CONFIG_DRIVER_LONG_LONG_SIZE is not set
+@@ -163,9 +163,9 @@ CONFIG_ENV_REGION_KERNEL_ALT="fis://kern
+ # Overrides
+ #
+ CONFIG_ENV_DEFAULT_CMDLINE_OVERRIDE=y
+-CONFIG_ENV_DEFAULT_CMDLINE="root=/dev/mtdblock4 rootfstype=jffs2 console=ttyS0,115200 init=/linuxrc"
++CONFIG_ENV_DEFAULT_CMDLINE="root=/dev/mtdblock4 rootfstype=squashfs,jffs2 console=ttyS0,115200 init=/etc/preinit noinitrd"
+ CONFIG_ENV_DEFAULT_CMDLINE_ALT_P=y
+-CONFIG_ENV_DEFAULT_CMDLINE_ALT="root=/dev/mtdblock4 rootfstype=jffs2 console=ttyS0,115200 init=/linuxrc"
++CONFIG_ENV_DEFAULT_CMDLINE_ALT="root=/dev/mtdblock4 rootfstype=squashfs,jffs2 console=ttyS0,115200 init=/etc/preinit noinitrd"
+ # CONFIG_ENV_DEFAULT_STARTUP_OVERRIDE is not set
+ # CONFIG_ENV_DEFAULT_STARTUP_ALT_P is not set
+ CONFIG_USES_NOR_BOOTFLASH=y
diff --git a/package/apex/patches/140-openwrt_fsg3_armeb_config.patch b/package/apex/patches/140-openwrt_fsg3_armeb_config.patch
new file mode 100644
index 0000000..a1651e6
--- /dev/null
+++ b/package/apex/patches/140-openwrt_fsg3_armeb_config.patch
@@ -0,0 +1,23 @@
+--- a/src/mach-ixp42x/slugos-fsg3-armeb_config
++++ b/src/mach-ixp42x/slugos-fsg3-armeb_config
+@@ -17,7 +17,7 @@ CONFIG_EXPERIMENTAL=y
+ #
+ # General Setup
+ #
+-CONFIG_TARGET_DESCRIPTION="SlugOS FSG3/BE"
++CONFIG_TARGET_DESCRIPTION="OpenWRT FSG3"
+ CONFIG_CROSS_COMPILE=""
+ CONFIG_AEABI=y
+ CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+@@ -148,9 +148,9 @@ CONFIG_ENV_REGION_KERNEL_ALT="fis://kern
+ # Overrides
+ #
+ CONFIG_ENV_DEFAULT_CMDLINE_OVERRIDE=y
+-CONFIG_ENV_DEFAULT_CMDLINE="root=/dev/sda1 rootdelay=10 console=ttyS0,115200"
++CONFIG_ENV_DEFAULT_CMDLINE="root=/dev/sda1 rootdelay=10 console=ttyS0,115200 init=/etc/preinit noinitrd"
+ CONFIG_ENV_DEFAULT_CMDLINE_ALT_P=y
+-CONFIG_ENV_DEFAULT_CMDLINE_ALT="root=/dev/sda2 rootdelay=10 console=ttyS0,115200"
++CONFIG_ENV_DEFAULT_CMDLINE_ALT="root=/dev/mtdblock2 rootfstype=squashfs console=ttyS0,115200 init=/etc/preinit noinitrd"
+ # CONFIG_ENV_DEFAULT_STARTUP_OVERRIDE is not set
+ # CONFIG_ENV_DEFAULT_STARTUP_ALT_P is not set
+ CONFIG_USES_NOR_BOOTFLASH=y
diff --git a/package/apex/patches/150-limit_ram_to_64mb.patch b/package/apex/patches/150-limit_ram_to_64mb.patch
new file mode 100644
index 0000000..3e17816
--- /dev/null
+++ b/package/apex/patches/150-limit_ram_to_64mb.patch
@@ -0,0 +1,22 @@
+--- a/src/mach-ixp42x/slugos-nslu2-armeb_config
++++ b/src/mach-ixp42x/slugos-nslu2-armeb_config
+@@ -137,7 +137,7 @@ CONFIG_AUTOBOOT_DELAY=10
+ CONFIG_ENV_STARTUP_KERNEL_COPY=y
+ # CONFIG_ENV_REGION_KERNEL_SWAP is not set
+ CONFIG_ENV_STARTUP_PREFIX_P=y
+-CONFIG_ENV_STARTUP_PREFIX="sdram-init; memscan -u 0+256m"
++CONFIG_ENV_STARTUP_PREFIX="sdram-init; memscan -u 0+64m"
+
+ #
+ # Regions
+--- a/src/mach-ixp42x/slugos-nslu2-16mb-armeb_config
++++ b/src/mach-ixp42x/slugos-nslu2-16mb-armeb_config
+@@ -137,7 +137,7 @@ CONFIG_AUTOBOOT_DELAY=10
+ CONFIG_ENV_STARTUP_KERNEL_COPY=y
+ # CONFIG_ENV_REGION_KERNEL_SWAP is not set
+ CONFIG_ENV_STARTUP_PREFIX_P=y
+-CONFIG_ENV_STARTUP_PREFIX="sdram-init; memscan -u 0+256m"
++CONFIG_ENV_STARTUP_PREFIX="sdram-init; memscan -u 0+64m"
+
+ #
+ # Regions
diff --git a/package/apex/patches/160-openwrt_nas100d_armeb_config.patch b/package/apex/patches/160-openwrt_nas100d_armeb_config.patch
new file mode 100644
index 0000000..0b0c985
--- /dev/null
+++ b/package/apex/patches/160-openwrt_nas100d_armeb_config.patch
@@ -0,0 +1,20 @@
+--- a/src/mach-ixp42x/slugos-nas100d-armeb_config
++++ b/src/mach-ixp42x/slugos-nas100d-armeb_config
+@@ -19,7 +19,7 @@ CONFIG_EXPERIMENTAL=y
+ #
+ # General Setup
+ #
+-CONFIG_TARGET_DESCRIPTION="SlugOS NAS100D/BE"
++CONFIG_TARGET_DESCRIPTION="OpenWRT NAS100D"
+ CONFIG_CROSS_COMPILE=""
+ CONFIG_AEABI=y
+ # CONFIG_DRIVER_LONG_LONG_SIZE is not set
+@@ -158,7 +158,7 @@ CONFIG_ENV_REGION_KERNEL="fis://kernel"
+ # Overrides
+ #
+ CONFIG_ENV_DEFAULT_CMDLINE_OVERRIDE=y
+-CONFIG_ENV_DEFAULT_CMDLINE="root=/dev/mtdblock2 rootfstype=jffs2 console=ttyS0,115200 init=/linuxrc"
++CONFIG_ENV_DEFAULT_CMDLINE="root=/dev/mtdblock2 rootfstype=squashfs,jffs2 console=ttyS0,115200 init=/etc/preinit noinitrd"
+ # CONFIG_ENV_DEFAULT_STARTUP_OVERRIDE is not set
+ CONFIG_USES_NOR_BOOTFLASH=y
+ CONFIG_RELOCATE_SIMPLE=y
diff --git a/package/base-files/.svn/entries b/package/base-files/.svn/entries
new file mode 100644
index 0000000..9777fa5
--- /dev/null
+++ b/package/base-files/.svn/entries
@@ -0,0 +1,102 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/base-files
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-14T18:43:58.957223Z
+36031
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+files.old
+dir
+
+files
+dir
+
+image-config.in
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+f4bec8a874e1a5647111fb944c1768a5
+2012-04-15T15:21:55.512126Z
+31289
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+6267
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+d09db315c9510e88b742d040605e1299
+2013-03-13T18:11:19.892934Z
+36003
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5304
+
diff --git a/package/base-files/.svn/prop-base/Makefile.svn-base b/package/base-files/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..8e522ae
--- /dev/null
+++ b/package/base-files/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:copyright
+V 30
+Copyright (C) 2006 OpenWrt.org
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/base-files/.svn/text-base/Makefile.svn-base b/package/base-files/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..90c2806
--- /dev/null
+++ b/package/base-files/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,169 @@
+#
+# Copyright (C) 2007-2013 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+include $(INCLUDE_DIR)/version.mk
+
+PKG_NAME:=base-files
+PKG_RELEASE:=134
+
+PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/
+PKG_BUILD_DEPENDS:=opkg/host
+PKG_CONFIG_DEPENDS:=CONFIG_PROCD_INIT
+
+include $(INCLUDE_DIR)/package.mk
+
+ifneq ($(DUMP),1)
+ TARGET:=-$(BOARD)
+ ifneq ($(wildcard $(PLATFORM_DIR)/base-files-$(PROFILE) $(PLATFORM_SUBDIR)/base-files-$(PROFILE)),)
+ TARGET:=$(TARGET)-$(PROFILE)
+ endif
+endif
+
+define Package/base-files
+ SECTION:=base
+ CATEGORY:=Base system
+ DEPENDS:=+netifd +libc +procd
+ TITLE:=Base filesystem for OpenWrt
+ URL:=http://openwrt.org/
+ VERSION:=$(PKG_RELEASE)-$(REVISION)
+endef
+
+define Package/base-files/conffiles
+/etc/hosts
+/etc/inittab
+/etc/group
+/etc/passwd
+/etc/shadow
+/etc/profile
+/etc/shells
+/etc/sysctl.conf
+/etc/rc.local
+/etc/sysupgrade.conf
+/etc/config/
+/etc/dropbear/
+/etc/crontabs/
+$(call $(TARGET)/conffiles)
+endef
+
+define Package/base-files/description
+ This package contains a base filesystem and system scripts for OpenWrt.
+endef
+
+define Package/base-files/config
+config PROCD_INIT
+ bool "Use procd as the init process"
+ default n
+endef
+
+ifeq ($(CONFIG_PROCD_INIT),)
+define InstallOldFiles
+ $(CP) ./files.old/* $(1)/
+endef
+endif
+
+ifneq ($(CONFIG_PREINITOPT),)
+define ImageConfigOptions
+ mkdir -p $(1)/lib/preinit
+ echo 'pi_suppress_stderr="$(CONFIG_TARGET_PREINIT_SUPPRESS_STDERR)"' >$(1)/lib/preinit/00_preinit.conf
+ echo 'fs_failsafe_wait_timeout=$(if $(CONFIG_TARGET_PREINIT_TIMEOUT),$(CONFIG_TARGET_PREINIT_TIMEOUT),2)' >>$(1)/lib/preinit/00_preinit.conf
+ echo 'pi_init_path=$(if $(CONFIG_TARGET_INIT_PATH),$(CONFIG_TARGET_INIT_PATH),"/bin:/sbin:/usr/bin:/usr/sbin")' >>$(1)/lib/preinit/00_preinit.conf
+ echo 'pi_init_env=$(if $(CONFIG_TARGET_INIT_ENV),$(CONFIG_TARGET_INIT_ENV),"")' >>$(1)/lib/preinit/00_preinit.conf
+ echo 'pi_init_cmd=$(if $(CONFIG_TARGET_INIT_CMD),$(CONFIG_TARGET_INIT_CMD),"/sbin/init")' >>$(1)/lib/preinit/00_preinit.conf
+ echo 'pi_init_suppress_stderr="$(CONFIG_TARGET_INIT_SUPPRESS_STDERR)"' >>$(1)/lib/preinit/00_preinit.conf
+ echo 'pi_ifname=$(if $(CONFIG_TARGET_PREINIT_IFNAME),$(CONFIG_TARGET_PREINIT_IFNAME),"")' >>$(1)/lib/preinit/00_preinit.conf
+ echo 'pi_ip=$(if $(CONFIG_TARGET_PREINIT_IP),$(CONFIG_TARGET_PREINIT_IP),"192.168.1.1")' >>$(1)/lib/preinit/00_preinit.conf
+ echo 'pi_netmask=$(if $(CONFIG_TARGET_PREINIT_NETMASK),$(CONFIG_TARGET_PREINIT_NETMASK),"255.255.255.0")' >>$(1)/lib/preinit/00_preinit.conf
+ echo 'pi_broadcast=$(if $(CONFIG_TARGET_PREINIT_BROADCAST),$(CONFIG_TARGET_PREINIT_BROADCAST),"192.168.1.255")' >>$(1)/lib/preinit/00_preinit.conf
+ echo 'pi_preinit_net_messages="$(CONFIG_TARGET_PREINIT_SHOW_NETMSG)"' >>$(1)/lib/preinit/00_preinit.conf
+ echo 'pi_preinit_no_failsafe_netmsg="$(CONFIG_TARGET_PREINIT_SUPPRESS_FAILSAFE_NETMSG)"' >>$(1)/lib/preinit/00_preinit.conf
+endef
+endif
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+endef
+
+define Build/Compile/Default
+
+endef
+Build/Compile = $(Build/Compile/Default)
+
+define Package/base-files/install
+ $(CP) ./files/* $(1)/
+ if [ -d $(GENERIC_PLATFORM_DIR)/base-files/. ]; then \
+ $(CP) $(GENERIC_PLATFORM_DIR)/base-files/* $(1)/; \
+ fi
+ $(call InstallOldFiles,$(1))
+ if [ -d $(PLATFORM_DIR)/base-files/. ]; then \
+ $(CP) $(PLATFORM_DIR)/base-files/* $(1)/; \
+ fi
+ if [ -d $(PLATFORM_DIR)/base-files-$(PROFILE)/. ]; then \
+ $(CP) $(PLATFORM_DIR)/base-files-$(PROFILE)/* $(1)/; \
+ fi
+ if [ -d $(PLATFORM_DIR)/$(PROFILE)/base-files/. ]; then \
+ $(CP) $(PLATFORM_DIR)/$(PROFILE)/base-files/* $(1)/; \
+ fi
+ $(if $(filter-out $(PLATFORM_DIR),$(PLATFORM_SUBDIR)), \
+ if [ -d $(PLATFORM_SUBDIR)/base-files/. ]; then \
+ $(CP) $(PLATFORM_SUBDIR)/base-files/* $(1)/; \
+ fi; \
+ if [ -d $(PLATFORM_SUBDIR)/base-files-$(PROFILE)/. ]; then \
+ $(CP) $(PLATFORM_SUBDIR)/base-files-$(PROFILE)/* $(1)/; \
+ fi; \
+ if [ -d $(PLATFORM_SUBDIR)/$(PROFILE)/base-files/. ]; then \
+ $(CP) $(PLATFORM_SUBDIR)/$(PROFILE)/base-files/* $(1)/; \
+ fi \
+ )
+
+ $(VERSION_SED) \
+ $(1)/etc/banner \
+ $(1)/etc/openwrt_version \
+ $(1)/etc/openwrt_release
+
+ mkdir -p $(1)/CONTROL
+ mkdir -p $(1)/dev
+ mkdir -p $(1)/etc/crontabs
+ mkdir -p $(1)/etc/rc.d
+ mkdir -p $(1)/overlay
+ mkdir -p $(1)/lib/firmware
+ $(if $(LIB_SUFFIX),-ln -s lib $(1)/lib$(LIB_SUFFIX))
+ mkdir -p $(1)/mnt
+ mkdir -p $(1)/proc
+ mkdir -p $(1)/tmp
+ mkdir -p $(1)/usr/lib
+ $(if $(LIB_SUFFIX),-ln -s lib $(1)/usr/lib$(LIB_SUFFIX))
+ mkdir -p $(1)/usr/bin
+ mkdir -p $(1)/sys
+ mkdir -p $(1)/www
+ mkdir -p $(1)/root
+ ln -sf /proc/mounts $(1)/etc/mtab
+ rm -f $(1)/var
+ ln -sf /tmp $(1)/var
+ mkdir -p $(1)/etc
+ ln -sf /tmp/resolv.conf /tmp/fstab /tmp/TZ $(1)/etc/
+
+ chmod 0600 $(1)/etc/shadow
+ chmod 1777 $(1)/tmp
+
+ $(call ImageConfigOptions,$(1))
+ $(call Package/base-files/install-target,$(1))
+ for conffile in $(1)/etc/config/*; do \
+ if [ -f "$$$$conffile" ]; then \
+ grep "$$$${conffile##$(1)}" $(1)/CONTROL/conffiles || \
+ echo "$$$${conffile##$(1)}" >> $(1)/CONTROL/conffiles; \
+ fi \
+ done
+endef
+
+ifneq ($(DUMP),1)
+ -include $(PLATFORM_DIR)/base-files.mk
+endif
+
+$(eval $(call BuildPackage,base-files))
diff --git a/package/base-files/.svn/text-base/image-config.in.svn-base b/package/base-files/.svn/text-base/image-config.in.svn-base
new file mode 100644
index 0000000..ac08c8d
--- /dev/null
+++ b/package/base-files/.svn/text-base/image-config.in.svn-base
@@ -0,0 +1,185 @@
+# Copyright (C) 2006-2012 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+menuconfig PREINITOPT
+ bool "Preinit configuration options" if IMAGEOPT
+ default n
+ help
+ These options are used to control the environment used to initialize
+ the system before running init (which typically mean /sbin/init which
+ switches to multiuser mode).
+
+config TARGET_PREINIT_SUPPRESS_STDERR
+ bool "Suppress stderr messages during preinit" if PREINITOPT
+ default y
+ help
+ Sends stderr to null during preinit. This is the default behaviour
+ in previous versions of OpenWRT. This also prevents init process
+ itself from displaying stderr, however processes launched by init
+ in multiuser through inittab will use the current terminal (e.g.
+ the ash shell launched by inittab will display stderr). That's
+ the same behaviour as seen in previous version of OpenWRT.
+
+config TARGET_PREINIT_TIMEOUT
+ int
+ prompt "Failsafe wait timeout" if PREINITOPT
+ default 2
+ help
+ How long to wait for failsafe mode to be entered before
+ continuing with a regular boot if failsafe not selected.
+
+config TARGET_PREINIT_SHOW_NETMSG
+ bool
+ prompt "Show all preinit network messages" if PREINITOPT
+ default n
+ help
+ Show preinit all network messages (via netmsg broadcast), not only
+ the message indicating to press reset to enter failsafe. Note that
+ if the architecture doesn't define an interface, and there is no
+ 'Preinit network interface' defined, then no messages will be
+ emitted, even if this is set.
+
+config TARGET_PREINIT_SUPPRESS_FAILSAFE_NETMSG
+ bool
+ prompt "Suppress network message indicating failsafe" if PREINITOPT
+ default n
+ help
+ If "Show all preinit network messages" above is not set, then
+ setting this option suppresses the only message that would be
+ emitted otherwise, name the network message to enter failsafe
+ (via netmsg).
+
+config TARGET_PREINIT_IFNAME
+ string
+ prompt "Preinit network interface" if PREINITOPT
+ default ""
+ help
+ Interface for sending preinit messages to network, and any other
+ default networking in failsafe or preinit. If empty
+ uses $ifname (if defined in /etc/preinit.arch).
+
+config TARGET_PREINIT_IP
+ string
+ prompt "IP address for preinit network messages" if PREINITOPT
+ default "192.168.1.1"
+ help
+ IP address used to configure interface for preinit network
+ messages, including failsafe messages
+
+config TARGET_PREINIT_NETMASK
+ string
+ prompt "Netmask for preinit network messages" if PREINITOPT
+ default "255.255.255.0"
+ help
+ Netmask used to configure interface for preinit network
+ messages, including failsafes messages
+
+config TARGET_PREINIT_BROADCAST
+ string
+ prompt "Broadcast address for preinit network messages" if PREINITOPT
+ default "192.168.1.255"
+ help
+ Broadcast address to which to send preinit network messages, as
+ as failsafe messages
+
+
+menuconfig INITOPT
+ bool "Init configuration options" if IMAGEOPT
+ default n
+ help
+ These option choose the command that will run as the 'init' command
+ (that is which is responsible for controlling the system once preinit
+ transfers control to it) as well as some options controlling its
+ behaviour. Normally init is /sbin/init.
+
+ config TARGET_INIT_PATH
+ string
+ prompt "PATH for regular boot" if INITOPT
+ default "/bin:/sbin:/usr/bin:/usr/sbin"
+ help
+ Default PATH used during normal operation
+
+ config TARGET_INIT_ENV
+ string
+ prompt "Environment variables to set when starting init (start with none)" if INITOPT
+ default ""
+ help
+ Should be a space seperated list of variable assignments. These
+ variables will be present in the environment. Spaces may not be
+ present (including through expansion) even in a quoted string
+ (env doesn't understanding quoting).
+
+ config TARGET_INIT_CMD
+ string
+ prompt "Init command" if INITOPT
+ default "/sbin/init"
+ help
+ The executable to run as the init process. Is 'exec'd by
+ preinit (which is the init that the kernel launches on boot).
+
+ config TARGET_INIT_SUPPRESS_STDERR
+ bool
+ prompt "Suppress stderr messages of init" if INITOPT
+ default y
+ help
+ Prevents showing stderr messages for init command if not already
+ suppressed during preinit. This is the default behaviour in
+ previous versions of OpenWRT. Removing this does nothing if
+ stderr is suppressed during preinit (which is the default).
+
+
+menuconfig VERSIONOPT
+ bool "Version configuration options" if IMAGEOPT
+ default n
+ help
+ These options allow to override the version information embedded in
+ the /etc/openwrt_version, /etc/openwrt_release, /etc/banner and
+ /etc/opkg.conf files. Usually there is no need to set these, but
+ they're useful for release builds or custom OpenWrt redistributions
+ that should carry custom version tags.
+
+ config VERSION_DIST
+ string
+ prompt "Release distribution" if VERSIONOPT
+ default "OpenWrt" if VERSIONOPT
+ help
+ This is the name of the release distribution.
+ If unspecified, it defaults to OpenWrt.
+
+ config VERSION_NICK
+ string
+ prompt "Release version nickname" if VERSIONOPT
+ help
+ This is the release codename embedded in the image.
+ If unspecified, it defaults to the name of source branch.
+
+ config VERSION_NUMBER
+ string
+ prompt "Release version number" if VERSIONOPT
+ help
+ This is the release version number embedded in the image.
+ If unspecified, it defaults to the svn or git-svn revision
+ of the build tree.
+
+ config VERSION_REPO
+ string
+ prompt "Release repository" if VERSIONOPT
+ default "http://downloads.openwrt.org/snapshots/trunk/%T/packages" if VERSIONOPT
+ help
+ This is the repository address embedded in the image, it defaults
+ to the trunk snapshot repo; the url may contain the following placeholders:
+ %R .. Revision number
+ %V .. Release version or revision number, uppercase
+ %v .. Release version or revision number, lowercase
+ %C .. Release version or "Bleeding Edge", uppercase
+ %c .. Release version or "bleeding_edge", lowercase
+ %N .. Release name, uppercase
+ %n .. Release name, lowercase
+ %D .. Distribution name or "OpenWrt", uppercase
+ %d .. Distribution name or "openwrt", lowercase
+ %T .. Target name
+ %S .. Target/Subtarget name
diff --git a/package/base-files/Makefile b/package/base-files/Makefile
new file mode 100644
index 0000000..90c2806
--- /dev/null
+++ b/package/base-files/Makefile
@@ -0,0 +1,169 @@
+#
+# Copyright (C) 2007-2013 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+include $(INCLUDE_DIR)/version.mk
+
+PKG_NAME:=base-files
+PKG_RELEASE:=134
+
+PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/
+PKG_BUILD_DEPENDS:=opkg/host
+PKG_CONFIG_DEPENDS:=CONFIG_PROCD_INIT
+
+include $(INCLUDE_DIR)/package.mk
+
+ifneq ($(DUMP),1)
+ TARGET:=-$(BOARD)
+ ifneq ($(wildcard $(PLATFORM_DIR)/base-files-$(PROFILE) $(PLATFORM_SUBDIR)/base-files-$(PROFILE)),)
+ TARGET:=$(TARGET)-$(PROFILE)
+ endif
+endif
+
+define Package/base-files
+ SECTION:=base
+ CATEGORY:=Base system
+ DEPENDS:=+netifd +libc +procd
+ TITLE:=Base filesystem for OpenWrt
+ URL:=http://openwrt.org/
+ VERSION:=$(PKG_RELEASE)-$(REVISION)
+endef
+
+define Package/base-files/conffiles
+/etc/hosts
+/etc/inittab
+/etc/group
+/etc/passwd
+/etc/shadow
+/etc/profile
+/etc/shells
+/etc/sysctl.conf
+/etc/rc.local
+/etc/sysupgrade.conf
+/etc/config/
+/etc/dropbear/
+/etc/crontabs/
+$(call $(TARGET)/conffiles)
+endef
+
+define Package/base-files/description
+ This package contains a base filesystem and system scripts for OpenWrt.
+endef
+
+define Package/base-files/config
+config PROCD_INIT
+ bool "Use procd as the init process"
+ default n
+endef
+
+ifeq ($(CONFIG_PROCD_INIT),)
+define InstallOldFiles
+ $(CP) ./files.old/* $(1)/
+endef
+endif
+
+ifneq ($(CONFIG_PREINITOPT),)
+define ImageConfigOptions
+ mkdir -p $(1)/lib/preinit
+ echo 'pi_suppress_stderr="$(CONFIG_TARGET_PREINIT_SUPPRESS_STDERR)"' >$(1)/lib/preinit/00_preinit.conf
+ echo 'fs_failsafe_wait_timeout=$(if $(CONFIG_TARGET_PREINIT_TIMEOUT),$(CONFIG_TARGET_PREINIT_TIMEOUT),2)' >>$(1)/lib/preinit/00_preinit.conf
+ echo 'pi_init_path=$(if $(CONFIG_TARGET_INIT_PATH),$(CONFIG_TARGET_INIT_PATH),"/bin:/sbin:/usr/bin:/usr/sbin")' >>$(1)/lib/preinit/00_preinit.conf
+ echo 'pi_init_env=$(if $(CONFIG_TARGET_INIT_ENV),$(CONFIG_TARGET_INIT_ENV),"")' >>$(1)/lib/preinit/00_preinit.conf
+ echo 'pi_init_cmd=$(if $(CONFIG_TARGET_INIT_CMD),$(CONFIG_TARGET_INIT_CMD),"/sbin/init")' >>$(1)/lib/preinit/00_preinit.conf
+ echo 'pi_init_suppress_stderr="$(CONFIG_TARGET_INIT_SUPPRESS_STDERR)"' >>$(1)/lib/preinit/00_preinit.conf
+ echo 'pi_ifname=$(if $(CONFIG_TARGET_PREINIT_IFNAME),$(CONFIG_TARGET_PREINIT_IFNAME),"")' >>$(1)/lib/preinit/00_preinit.conf
+ echo 'pi_ip=$(if $(CONFIG_TARGET_PREINIT_IP),$(CONFIG_TARGET_PREINIT_IP),"192.168.1.1")' >>$(1)/lib/preinit/00_preinit.conf
+ echo 'pi_netmask=$(if $(CONFIG_TARGET_PREINIT_NETMASK),$(CONFIG_TARGET_PREINIT_NETMASK),"255.255.255.0")' >>$(1)/lib/preinit/00_preinit.conf
+ echo 'pi_broadcast=$(if $(CONFIG_TARGET_PREINIT_BROADCAST),$(CONFIG_TARGET_PREINIT_BROADCAST),"192.168.1.255")' >>$(1)/lib/preinit/00_preinit.conf
+ echo 'pi_preinit_net_messages="$(CONFIG_TARGET_PREINIT_SHOW_NETMSG)"' >>$(1)/lib/preinit/00_preinit.conf
+ echo 'pi_preinit_no_failsafe_netmsg="$(CONFIG_TARGET_PREINIT_SUPPRESS_FAILSAFE_NETMSG)"' >>$(1)/lib/preinit/00_preinit.conf
+endef
+endif
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+endef
+
+define Build/Compile/Default
+
+endef
+Build/Compile = $(Build/Compile/Default)
+
+define Package/base-files/install
+ $(CP) ./files/* $(1)/
+ if [ -d $(GENERIC_PLATFORM_DIR)/base-files/. ]; then \
+ $(CP) $(GENERIC_PLATFORM_DIR)/base-files/* $(1)/; \
+ fi
+ $(call InstallOldFiles,$(1))
+ if [ -d $(PLATFORM_DIR)/base-files/. ]; then \
+ $(CP) $(PLATFORM_DIR)/base-files/* $(1)/; \
+ fi
+ if [ -d $(PLATFORM_DIR)/base-files-$(PROFILE)/. ]; then \
+ $(CP) $(PLATFORM_DIR)/base-files-$(PROFILE)/* $(1)/; \
+ fi
+ if [ -d $(PLATFORM_DIR)/$(PROFILE)/base-files/. ]; then \
+ $(CP) $(PLATFORM_DIR)/$(PROFILE)/base-files/* $(1)/; \
+ fi
+ $(if $(filter-out $(PLATFORM_DIR),$(PLATFORM_SUBDIR)), \
+ if [ -d $(PLATFORM_SUBDIR)/base-files/. ]; then \
+ $(CP) $(PLATFORM_SUBDIR)/base-files/* $(1)/; \
+ fi; \
+ if [ -d $(PLATFORM_SUBDIR)/base-files-$(PROFILE)/. ]; then \
+ $(CP) $(PLATFORM_SUBDIR)/base-files-$(PROFILE)/* $(1)/; \
+ fi; \
+ if [ -d $(PLATFORM_SUBDIR)/$(PROFILE)/base-files/. ]; then \
+ $(CP) $(PLATFORM_SUBDIR)/$(PROFILE)/base-files/* $(1)/; \
+ fi \
+ )
+
+ $(VERSION_SED) \
+ $(1)/etc/banner \
+ $(1)/etc/openwrt_version \
+ $(1)/etc/openwrt_release
+
+ mkdir -p $(1)/CONTROL
+ mkdir -p $(1)/dev
+ mkdir -p $(1)/etc/crontabs
+ mkdir -p $(1)/etc/rc.d
+ mkdir -p $(1)/overlay
+ mkdir -p $(1)/lib/firmware
+ $(if $(LIB_SUFFIX),-ln -s lib $(1)/lib$(LIB_SUFFIX))
+ mkdir -p $(1)/mnt
+ mkdir -p $(1)/proc
+ mkdir -p $(1)/tmp
+ mkdir -p $(1)/usr/lib
+ $(if $(LIB_SUFFIX),-ln -s lib $(1)/usr/lib$(LIB_SUFFIX))
+ mkdir -p $(1)/usr/bin
+ mkdir -p $(1)/sys
+ mkdir -p $(1)/www
+ mkdir -p $(1)/root
+ ln -sf /proc/mounts $(1)/etc/mtab
+ rm -f $(1)/var
+ ln -sf /tmp $(1)/var
+ mkdir -p $(1)/etc
+ ln -sf /tmp/resolv.conf /tmp/fstab /tmp/TZ $(1)/etc/
+
+ chmod 0600 $(1)/etc/shadow
+ chmod 1777 $(1)/tmp
+
+ $(call ImageConfigOptions,$(1))
+ $(call Package/base-files/install-target,$(1))
+ for conffile in $(1)/etc/config/*; do \
+ if [ -f "$$$$conffile" ]; then \
+ grep "$$$${conffile##$(1)}" $(1)/CONTROL/conffiles || \
+ echo "$$$${conffile##$(1)}" >> $(1)/CONTROL/conffiles; \
+ fi \
+ done
+endef
+
+ifneq ($(DUMP),1)
+ -include $(PLATFORM_DIR)/base-files.mk
+endif
+
+$(eval $(call BuildPackage,base-files))
diff --git a/package/base-files/files.old/.svn/entries b/package/base-files/files.old/.svn/entries
new file mode 100644
index 0000000..62bfb98
--- /dev/null
+++ b/package/base-files/files.old/.svn/entries
@@ -0,0 +1,68 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/base-files/files.old
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-13T18:11:19.892934Z
+36003
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+init
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+d9c3e031201dfb83d616c63c9194e512
+2013-03-13T18:11:19.892934Z
+36003
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2418
+
+lib
+dir
+
+etc
+dir
+
diff --git a/package/base-files/files.old/.svn/prop-base/init.svn-base b/package/base-files/files.old/.svn/prop-base/init.svn-base
new file mode 100644
index 0000000..869ac71
--- /dev/null
+++ b/package/base-files/files.old/.svn/prop-base/init.svn-base
@@ -0,0 +1,5 @@
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/base-files/files.old/.svn/text-base/init.svn-base b/package/base-files/files.old/.svn/text-base/init.svn-base
new file mode 100644
index 0000000..b4ef4fe
--- /dev/null
+++ b/package/base-files/files.old/.svn/text-base/init.svn-base
@@ -0,0 +1,96 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+
+INITRAMFS=1
+
+. /etc/preinit
+
+set_state init
+echo "- init -"
+
+[ -n "$SWITCH_ROOT_TMPFS" ] && {
+ mount -o noatime none /mnt -t tmpfs
+ ( cd /; find -xdev -type d ) | ( cd /mnt; xargs mkdir -p )
+ find / \! -type d -xdev | tar -cT /proc/self/fd/0 | tar -xC /mnt
+ mkdir /mnt/proc /mnt/dev /mnt/tmp /mnt/sys
+ mount -o noatime,move /proc /mnt/proc
+ mount -o noatime,move /dev /mnt/dev
+ mount -o noatime,move /tmp /mnt/tmp
+ mount -o noatime,move /sys /mnt/sys
+ rm -rf /proc /dev /tmp /sys
+ exec switch_root -c /dev/console /mnt /sbin/init
+}
+
+# if we have no root parameter, just go to running from ramfs
+[ -z $rootfs ] && {
+ export NOMOUNT="No Root"
+ exec /sbin/init
+}
+
+#if we have a failsafe boot selected, dont bother
+#trying to find or wait for a root mount point
+[ -z "$FAILSAFE" ] || {
+ exec /bin/busybox init
+}
+
+# Load the modules we have in initramfs, this should
+# make the media accessible, but, it may take some time
+. /lib/functions.sh
+load_modules /etc/modules /etc/modules.d/*
+
+#wait 10 seconds for the disc to show up
+#usb stick typically takes 4 to 6 seconds
+#till it's readable
+#it's quite possible the disc never shows up
+#if we netbooted this kernel
+COUNTER=0
+while [ $COUNTER -lt 10 ]; do
+ sleep 1
+ [ -e $rootfs ] && let COUNTER=10;
+ let COUNTER=COUNTER+1
+done
+[ -e $rootfs ] || {
+ export FAILSAFE="NoDisc"
+ exec /bin/busybox init
+}
+
+# now we'll try mount it, again with a timeout
+# This will fail if the inserted stick is formatted
+# in a manner we dont understand
+COUNTER=0
+while [ $COUNTER -lt 10 ]; do
+ sleep 1
+ mount -o noatime $rootfs /mnt
+ [ $? -eq "0" ] && let COUNTER=100;
+ let COUNTER=COUNTER+1
+done
+[ $? -ne "0" ] && {
+ export FAILSAFE="MountFail"
+ exec /bin/busybox init
+}
+
+#It mounted, lets look for a postinit file, again, give it time
+#I've seen this take 6 seconds to actually complete
+COUNTER=0
+while [ $COUNTER -lt 10 ]; do
+ sleep 1
+ [ -e /mnt/etc/banner ] && let COUNTER=10;
+ let COUNTER=COUNTER+1
+done
+[ -e /mnt/etc/banner ] || {
+ export FAILSAFE="No Openwrt FS"
+ exec /bin/busybox init
+}
+
+unset rootfs
+
+mount -o noatime,move /proc /mnt/proc
+mount -o noatime,move /dev /mnt/dev
+mount -o noatime,move /dev/pts /mnt/dev/pts
+mount -o noatime,move /tmp /mnt/tmp
+mount -o noatime,move /sys /mnt/sys
+mount -o noatime none /tmp -t tmpfs
+killall -q hotplug2
+exec switch_root -c /dev/console /mnt /sbin/init
+
+set_state done
diff --git a/package/base-files/files.old/etc/.svn/entries b/package/base-files/files.old/etc/.svn/entries
new file mode 100644
index 0000000..04c3fc6
--- /dev/null
+++ b/package/base-files/files.old/etc/.svn/entries
@@ -0,0 +1,201 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/base-files/files.old/etc
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-13T18:11:19.892934Z
+36003
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+watchdog
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+300a69f7642d80a4ba07c477902f874c
+2013-03-13T18:11:19.892934Z
+36003
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+244
+
+hotplug2-common.rules
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+a06e84d10bca4a31ac97c00a6236bfd9
+2013-03-13T18:11:19.892934Z
+36003
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+833
+
+init.d
+dir
+
+inittab
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+3fafaa42fdc6218dea5c2d54d5b2f291
+2013-03-13T18:11:19.892934Z
+36003
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+136
+
+preinit
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+0305ad466d161bc80ac997cda9c1e8c2
+2013-03-13T18:11:19.892934Z
+36003
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+863
+
+hotplug2-init.rules
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+8dff805e4ada6565d9494849b9287562
+2013-03-13T18:11:19.892934Z
+36003
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+80
+
diff --git a/package/base-files/files.old/etc/.svn/prop-base/inittab.svn-base b/package/base-files/files.old/etc/.svn/prop-base/inittab.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/base-files/files.old/etc/.svn/prop-base/inittab.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/base-files/files.old/etc/.svn/prop-base/preinit.svn-base b/package/base-files/files.old/etc/.svn/prop-base/preinit.svn-base
new file mode 100644
index 0000000..03b5bfa
--- /dev/null
+++ b/package/base-files/files.old/etc/.svn/prop-base/preinit.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:eol-style
+V 6
+native
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/base-files/files.old/etc/.svn/prop-base/watchdog.svn-base b/package/base-files/files.old/etc/.svn/prop-base/watchdog.svn-base
new file mode 100644
index 0000000..869ac71
--- /dev/null
+++ b/package/base-files/files.old/etc/.svn/prop-base/watchdog.svn-base
@@ -0,0 +1,5 @@
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/base-files/files.old/etc/.svn/text-base/hotplug2-common.rules.svn-base b/package/base-files/files.old/etc/.svn/text-base/hotplug2-common.rules.svn-base
new file mode 100644
index 0000000..c284f8f
--- /dev/null
+++ b/package/base-files/files.old/etc/.svn/text-base/hotplug2-common.rules.svn-base
@@ -0,0 +1,43 @@
+
+# uncomment me to log hotplug events
+# DEVPATH is set {
+# exec logger -s -t hotplug -p daemon.info "name=%DEVNAME%, path=%DEVPATH%"
+# }
+
+$include /etc/hotplug2-platform.rules
+
+DEVNAME ~~ (^null$|^full$|^ptmx$|^zero$|^gpio|^hvc) {
+ makedev /dev/%DEVNAME% 0666
+ next-event
+}
+
+DEVNAME == mapper/control {
+ makedev /dev/%DEVNAME% 0600
+ next-event
+}
+
+ACTION == add, DEVPATH is set {
+ makedev /dev/%DEVNAME% 0644
+}
+
+ACTION == add, DEVPATH is set, DEVNAME ~~ ^tty {
+ chmod 0666 /dev/%DEVNAME%
+}
+
+ACTION == add, DEVPATH is set, DEVNAME ~~ ^ppp {
+ chmod 0600 /dev/%DEVNAME%
+}
+
+ACTION == remove, DEVPATH is set, MAJOR is set, MINOR is set {
+ remove /dev/%DEVNAME%
+}
+
+FIRMWARE is set, ACTION == add {
+ exec /sbin/hotplug-call firmware
+ load-firmware /lib/firmware
+ next-event
+}
+
+SUBSYSTEM == platform {
+ exec /sbin/hotplug-call %SUBSYSTEM%
+}
diff --git a/package/base-files/files.old/etc/.svn/text-base/hotplug2-init.rules.svn-base b/package/base-files/files.old/etc/.svn/text-base/hotplug2-init.rules.svn-base
new file mode 100644
index 0000000..f011697
--- /dev/null
+++ b/package/base-files/files.old/etc/.svn/text-base/hotplug2-init.rules.svn-base
@@ -0,0 +1,5 @@
+$include /etc/hotplug2-common.rules
+
+SUBSYSTEM == button {
+ exec kill -USR1 1
+}
diff --git a/package/base-files/files.old/etc/.svn/text-base/inittab.svn-base b/package/base-files/files.old/etc/.svn/text-base/inittab.svn-base
new file mode 100644
index 0000000..ca90fd8
--- /dev/null
+++ b/package/base-files/files.old/etc/.svn/text-base/inittab.svn-base
@@ -0,0 +1,4 @@
+::sysinit:/etc/init.d/rcS S boot
+::shutdown:/etc/init.d/rcS K shutdown
+ttyS0::askfirst:/bin/ash --login
+tty1::askfirst:/bin/ash --login
diff --git a/package/base-files/files.old/etc/.svn/text-base/preinit.svn-base b/package/base-files/files.old/etc/.svn/text-base/preinit.svn-base
new file mode 100644
index 0000000..b237c2e
--- /dev/null
+++ b/package/base-files/files.old/etc/.svn/text-base/preinit.svn-base
@@ -0,0 +1,43 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+export PATH=/bin:/sbin:/usr/bin:/usr/sbin
+
+pi_ifname=
+pi_ip=192.168.1.1
+pi_broadcast=192.168.1.255
+pi_netmask=255.255.255.0
+
+fs_failsafe_ifname=
+fs_failsafe_ip=192.168.1.1
+fs_failsafe_broadcast=192.168.1.255
+fs_failsafe_netmask=255.255.255.0
+
+fs_failsafe_wait_timeout=2
+
+pi_suppress_stderr="y"
+pi_init_suppress_stderr="y"
+pi_init_path="/bin:/sbin:/usr/bin:/usr/sbin"
+pi_init_cmd="/sbin/init"
+
+. /lib/functions.sh
+
+boot_hook_init preinit_essential
+boot_hook_init preinit_main
+boot_hook_init failsafe
+boot_hook_init initramfs
+boot_hook_init preinit_mount_root
+
+for pi_source_file in /lib/preinit/*; do
+ . $pi_source_file
+done
+
+boot_run_hook preinit_essential
+
+pi_mount_skip_next=false
+pi_jffs2_mount_success=false
+pi_failsafe_net_message=false
+
+boot_run_hook preinit_main
+
diff --git a/package/base-files/files.old/etc/.svn/text-base/watchdog.svn-base b/package/base-files/files.old/etc/.svn/text-base/watchdog.svn-base
new file mode 100644
index 0000000..299c891
--- /dev/null
+++ b/package/base-files/files.old/etc/.svn/text-base/watchdog.svn-base
@@ -0,0 +1,13 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2008-2011 OpenWrt.org
+
+START=97
+
+start() {
+ [ -c /dev/watchdog ] || return 1
+ [ -x /sbin/watchdog ] || return 1
+ service_start /sbin/watchdog -t 5 /dev/watchdog
+}
+stop() {
+ service_stop /sbin/watchdog
+}
diff --git a/package/base-files/files.old/etc/hotplug2-common.rules b/package/base-files/files.old/etc/hotplug2-common.rules
new file mode 100644
index 0000000..c284f8f
--- /dev/null
+++ b/package/base-files/files.old/etc/hotplug2-common.rules
@@ -0,0 +1,43 @@
+
+# uncomment me to log hotplug events
+# DEVPATH is set {
+# exec logger -s -t hotplug -p daemon.info "name=%DEVNAME%, path=%DEVPATH%"
+# }
+
+$include /etc/hotplug2-platform.rules
+
+DEVNAME ~~ (^null$|^full$|^ptmx$|^zero$|^gpio|^hvc) {
+ makedev /dev/%DEVNAME% 0666
+ next-event
+}
+
+DEVNAME == mapper/control {
+ makedev /dev/%DEVNAME% 0600
+ next-event
+}
+
+ACTION == add, DEVPATH is set {
+ makedev /dev/%DEVNAME% 0644
+}
+
+ACTION == add, DEVPATH is set, DEVNAME ~~ ^tty {
+ chmod 0666 /dev/%DEVNAME%
+}
+
+ACTION == add, DEVPATH is set, DEVNAME ~~ ^ppp {
+ chmod 0600 /dev/%DEVNAME%
+}
+
+ACTION == remove, DEVPATH is set, MAJOR is set, MINOR is set {
+ remove /dev/%DEVNAME%
+}
+
+FIRMWARE is set, ACTION == add {
+ exec /sbin/hotplug-call firmware
+ load-firmware /lib/firmware
+ next-event
+}
+
+SUBSYSTEM == platform {
+ exec /sbin/hotplug-call %SUBSYSTEM%
+}
diff --git a/package/base-files/files.old/etc/hotplug2-init.rules b/package/base-files/files.old/etc/hotplug2-init.rules
new file mode 100644
index 0000000..f011697
--- /dev/null
+++ b/package/base-files/files.old/etc/hotplug2-init.rules
@@ -0,0 +1,5 @@
+$include /etc/hotplug2-common.rules
+
+SUBSYSTEM == button {
+ exec kill -USR1 1
+}
diff --git a/package/base-files/files.old/etc/init.d/.svn/entries b/package/base-files/files.old/etc/init.d/.svn/entries
new file mode 100644
index 0000000..be2abe8
--- /dev/null
+++ b/package/base-files/files.old/etc/init.d/.svn/entries
@@ -0,0 +1,130 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/base-files/files.old/etc/init.d
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-13T18:11:19.892934Z
+36003
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+watchdog
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+300a69f7642d80a4ba07c477902f874c
+2013-03-13T18:11:19.892934Z
+36003
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+244
+
+boot
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+eada5ecef70f8b8e7c5cf3fceb6e79ec
+2013-03-13T18:11:19.892934Z
+36003
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3059
+
+rcS
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+33227a3732a76d71e098c64deed1f4f8
+2013-03-13T18:11:19.892934Z
+36003
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+454
+
diff --git a/package/base-files/files.old/etc/init.d/.svn/prop-base/boot.svn-base b/package/base-files/files.old/etc/init.d/.svn/prop-base/boot.svn-base
new file mode 100644
index 0000000..03b5bfa
--- /dev/null
+++ b/package/base-files/files.old/etc/init.d/.svn/prop-base/boot.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:eol-style
+V 6
+native
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/base-files/files.old/etc/init.d/.svn/prop-base/rcS.svn-base b/package/base-files/files.old/etc/init.d/.svn/prop-base/rcS.svn-base
new file mode 100644
index 0000000..03b5bfa
--- /dev/null
+++ b/package/base-files/files.old/etc/init.d/.svn/prop-base/rcS.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:eol-style
+V 6
+native
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/base-files/files.old/etc/init.d/.svn/prop-base/watchdog.svn-base b/package/base-files/files.old/etc/init.d/.svn/prop-base/watchdog.svn-base
new file mode 100644
index 0000000..869ac71
--- /dev/null
+++ b/package/base-files/files.old/etc/init.d/.svn/prop-base/watchdog.svn-base
@@ -0,0 +1,5 @@
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/base-files/files.old/etc/init.d/.svn/text-base/boot.svn-base b/package/base-files/files.old/etc/init.d/.svn/text-base/boot.svn-base
new file mode 100644
index 0000000..005c4ad
--- /dev/null
+++ b/package/base-files/files.old/etc/init.d/.svn/text-base/boot.svn-base
@@ -0,0 +1,110 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2006-2011 OpenWrt.org
+
+START=10
+STOP=98
+
+system_config() {
+ local cfg="$1"
+
+ local hostname conloglevel timezone
+
+ config_get hostname "$cfg" hostname 'OpenWrt'
+ echo "$hostname" > /proc/sys/kernel/hostname
+
+ config_get conloglevel "$cfg" conloglevel
+ config_get buffersize "$cfg" buffersize
+ [ -z "$conloglevel" -a -z "$buffersize" ] || dmesg ${conloglevel:+-n $conloglevel} ${buffersize:+-s $buffersize}
+
+ config_get timezone "$cfg" timezone 'UTC'
+ echo "$timezone" > /tmp/TZ
+
+ config_get zonename "$cfg" zonename
+ [ -n "$zonename" ] && [ -f "/usr/share/zoneinfo/$zonename" ] && ln -s "/usr/share/zoneinfo/$zonename" /tmp/localtime
+
+ # apply timezone to kernel
+ date -k
+
+ if [ -x /sbin/syslogd ]; then
+ local args log_ip log_size log_port log_type log_file
+ config_get log_ip "$cfg" log_ip
+ config_get log_size "$cfg" log_size 16
+ config_get log_port "$cfg" log_port 514
+ config_get log_type "$cfg" log_type circular
+ config_get log_file "$cfg" log_file "/var/log/messages"
+ args="${log_ip:+-L -R ${log_ip}:${log_port}} ${conloglevel:+-l $conloglevel}"
+ if [ "$log_type" = "file" ]; then
+ args="$args -s $log_size -O $log_file -S"
+ else
+ args="$args -C${log_size}"
+ fi
+ service_start /sbin/syslogd $args
+ fi
+ if [ -x /sbin/klogd ]; then
+ config_get klogconloglevel "$cfg" klogconloglevel
+ args="${klogconloglevel:+-c $klogconloglevel}"
+ service_start /sbin/klogd $args
+ fi
+}
+
+apply_uci_config() {
+ sh -c '. /lib/functions.sh; include /lib/config; uci_apply_defaults'
+}
+
+start() {
+ [ -f /proc/mounts ] || /sbin/mount_root
+ [ -f /proc/jffs2_bbc ] && echo "S" > /proc/jffs2_bbc
+ [ -f /proc/net/vlan/config ] && vconfig set_name_type DEV_PLUS_VID_NO_PAD
+
+ mkdir -p /var/run
+ mkdir -p /var/log
+ mkdir -p /var/lock
+ mkdir -p /var/state
+ mkdir -p /tmp/.uci
+ chmod 0700 /tmp/.uci
+ touch /var/log/wtmp
+ touch /var/log/lastlog
+ touch /tmp/resolv.conf.auto
+ ln -sf /tmp/resolv.conf.auto /tmp/resolv.conf
+ grep -q debugfs /proc/filesystems && mount -o noatime -t debugfs debugfs /sys/kernel/debug
+ [ "$FAILSAFE" = "true" ] && touch /tmp/.failsafe
+
+ load_modules /etc/modules.d/*
+
+ # allow wifi modules time to settle
+ sleep 1
+
+ /sbin/wifi detect > /tmp/wireless.tmp
+ [ -s /tmp/wireless.tmp ] && {
+ cat /tmp/wireless.tmp >> /etc/config/wireless
+ }
+ rm -f /tmp/wireless.tmp
+
+ apply_uci_config
+ config_load system
+ config_foreach system_config system
+
+ killall -q hotplug2
+ [ -x /sbin/hotplug2 ] && /sbin/hotplug2 --override --persistent \
+ --set-rules-file /etc/hotplug2.rules \
+ --set-coldplug-cmd /sbin/udevtrigger \
+ --max-children 1 >/dev/null 2>&1 &
+
+ # create /dev/root if it doesn't exist
+ [ -e /dev/root -o -h /dev/root ] || {
+ rootdev=$(awk 'BEGIN { RS=" "; FS="="; } $1 == "root" { print $2 }' < /proc/cmdline)
+ [ -n "$rootdev" ] && ln -s "$rootdev" /dev/root
+ }
+
+ # early sysctl to avoid networking races
+ if [ -d /proc/sys/net/ipv6/conf ]; then
+ for i in /proc/sys/net/ipv6/conf/*/accept_ra; do
+ echo 0 > $i
+ done
+ fi
+}
+
+stop() {
+ service_stop /sbin/klogd
+ service_stop /sbin/syslogd
+}
diff --git a/package/base-files/files.old/etc/init.d/.svn/text-base/rcS.svn-base b/package/base-files/files.old/etc/init.d/.svn/text-base/rcS.svn-base
new file mode 100644
index 0000000..3ec9bfe
--- /dev/null
+++ b/package/base-files/files.old/etc/init.d/.svn/text-base/rcS.svn-base
@@ -0,0 +1,26 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+
+run_scripts() {
+ for i in /etc/rc.d/$1*; do
+ [ -x $i ] && $i $2 2>&1
+ done | $LOGGER
+}
+
+system_config() {
+ config_get_bool foreground $1 foreground 0
+}
+
+LOGGER="cat"
+[ -x /usr/bin/logger ] && LOGGER="logger -s -p 6 -t sysinit"
+
+. /lib/functions.sh
+
+config_load system
+config_foreach system_config system
+
+if [ "$1" = "S" -a "$foreground" != "1" ]; then
+ run_scripts "$1" "$2" &
+else
+ run_scripts "$1" "$2"
+fi
diff --git a/package/base-files/files.old/etc/init.d/.svn/text-base/watchdog.svn-base b/package/base-files/files.old/etc/init.d/.svn/text-base/watchdog.svn-base
new file mode 100644
index 0000000..299c891
--- /dev/null
+++ b/package/base-files/files.old/etc/init.d/.svn/text-base/watchdog.svn-base
@@ -0,0 +1,13 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2008-2011 OpenWrt.org
+
+START=97
+
+start() {
+ [ -c /dev/watchdog ] || return 1
+ [ -x /sbin/watchdog ] || return 1
+ service_start /sbin/watchdog -t 5 /dev/watchdog
+}
+stop() {
+ service_stop /sbin/watchdog
+}
diff --git a/package/base-files/files.old/etc/init.d/boot b/package/base-files/files.old/etc/init.d/boot
new file mode 100755
index 0000000..005c4ad
--- /dev/null
+++ b/package/base-files/files.old/etc/init.d/boot
@@ -0,0 +1,110 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2006-2011 OpenWrt.org
+
+START=10
+STOP=98
+
+system_config() {
+ local cfg="$1"
+
+ local hostname conloglevel timezone
+
+ config_get hostname "$cfg" hostname 'OpenWrt'
+ echo "$hostname" > /proc/sys/kernel/hostname
+
+ config_get conloglevel "$cfg" conloglevel
+ config_get buffersize "$cfg" buffersize
+ [ -z "$conloglevel" -a -z "$buffersize" ] || dmesg ${conloglevel:+-n $conloglevel} ${buffersize:+-s $buffersize}
+
+ config_get timezone "$cfg" timezone 'UTC'
+ echo "$timezone" > /tmp/TZ
+
+ config_get zonename "$cfg" zonename
+ [ -n "$zonename" ] && [ -f "/usr/share/zoneinfo/$zonename" ] && ln -s "/usr/share/zoneinfo/$zonename" /tmp/localtime
+
+ # apply timezone to kernel
+ date -k
+
+ if [ -x /sbin/syslogd ]; then
+ local args log_ip log_size log_port log_type log_file
+ config_get log_ip "$cfg" log_ip
+ config_get log_size "$cfg" log_size 16
+ config_get log_port "$cfg" log_port 514
+ config_get log_type "$cfg" log_type circular
+ config_get log_file "$cfg" log_file "/var/log/messages"
+ args="${log_ip:+-L -R ${log_ip}:${log_port}} ${conloglevel:+-l $conloglevel}"
+ if [ "$log_type" = "file" ]; then
+ args="$args -s $log_size -O $log_file -S"
+ else
+ args="$args -C${log_size}"
+ fi
+ service_start /sbin/syslogd $args
+ fi
+ if [ -x /sbin/klogd ]; then
+ config_get klogconloglevel "$cfg" klogconloglevel
+ args="${klogconloglevel:+-c $klogconloglevel}"
+ service_start /sbin/klogd $args
+ fi
+}
+
+apply_uci_config() {
+ sh -c '. /lib/functions.sh; include /lib/config; uci_apply_defaults'
+}
+
+start() {
+ [ -f /proc/mounts ] || /sbin/mount_root
+ [ -f /proc/jffs2_bbc ] && echo "S" > /proc/jffs2_bbc
+ [ -f /proc/net/vlan/config ] && vconfig set_name_type DEV_PLUS_VID_NO_PAD
+
+ mkdir -p /var/run
+ mkdir -p /var/log
+ mkdir -p /var/lock
+ mkdir -p /var/state
+ mkdir -p /tmp/.uci
+ chmod 0700 /tmp/.uci
+ touch /var/log/wtmp
+ touch /var/log/lastlog
+ touch /tmp/resolv.conf.auto
+ ln -sf /tmp/resolv.conf.auto /tmp/resolv.conf
+ grep -q debugfs /proc/filesystems && mount -o noatime -t debugfs debugfs /sys/kernel/debug
+ [ "$FAILSAFE" = "true" ] && touch /tmp/.failsafe
+
+ load_modules /etc/modules.d/*
+
+ # allow wifi modules time to settle
+ sleep 1
+
+ /sbin/wifi detect > /tmp/wireless.tmp
+ [ -s /tmp/wireless.tmp ] && {
+ cat /tmp/wireless.tmp >> /etc/config/wireless
+ }
+ rm -f /tmp/wireless.tmp
+
+ apply_uci_config
+ config_load system
+ config_foreach system_config system
+
+ killall -q hotplug2
+ [ -x /sbin/hotplug2 ] && /sbin/hotplug2 --override --persistent \
+ --set-rules-file /etc/hotplug2.rules \
+ --set-coldplug-cmd /sbin/udevtrigger \
+ --max-children 1 >/dev/null 2>&1 &
+
+ # create /dev/root if it doesn't exist
+ [ -e /dev/root -o -h /dev/root ] || {
+ rootdev=$(awk 'BEGIN { RS=" "; FS="="; } $1 == "root" { print $2 }' < /proc/cmdline)
+ [ -n "$rootdev" ] && ln -s "$rootdev" /dev/root
+ }
+
+ # early sysctl to avoid networking races
+ if [ -d /proc/sys/net/ipv6/conf ]; then
+ for i in /proc/sys/net/ipv6/conf/*/accept_ra; do
+ echo 0 > $i
+ done
+ fi
+}
+
+stop() {
+ service_stop /sbin/klogd
+ service_stop /sbin/syslogd
+}
diff --git a/package/base-files/files.old/etc/init.d/rcS b/package/base-files/files.old/etc/init.d/rcS
new file mode 100755
index 0000000..3ec9bfe
--- /dev/null
+++ b/package/base-files/files.old/etc/init.d/rcS
@@ -0,0 +1,26 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+
+run_scripts() {
+ for i in /etc/rc.d/$1*; do
+ [ -x $i ] && $i $2 2>&1
+ done | $LOGGER
+}
+
+system_config() {
+ config_get_bool foreground $1 foreground 0
+}
+
+LOGGER="cat"
+[ -x /usr/bin/logger ] && LOGGER="logger -s -p 6 -t sysinit"
+
+. /lib/functions.sh
+
+config_load system
+config_foreach system_config system
+
+if [ "$1" = "S" -a "$foreground" != "1" ]; then
+ run_scripts "$1" "$2" &
+else
+ run_scripts "$1" "$2"
+fi
diff --git a/package/base-files/files.old/etc/init.d/watchdog b/package/base-files/files.old/etc/init.d/watchdog
new file mode 100755
index 0000000..299c891
--- /dev/null
+++ b/package/base-files/files.old/etc/init.d/watchdog
@@ -0,0 +1,13 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2008-2011 OpenWrt.org
+
+START=97
+
+start() {
+ [ -c /dev/watchdog ] || return 1
+ [ -x /sbin/watchdog ] || return 1
+ service_start /sbin/watchdog -t 5 /dev/watchdog
+}
+stop() {
+ service_stop /sbin/watchdog
+}
diff --git a/package/base-files/files.old/etc/inittab b/package/base-files/files.old/etc/inittab
new file mode 100644
index 0000000..ca90fd8
--- /dev/null
+++ b/package/base-files/files.old/etc/inittab
@@ -0,0 +1,4 @@
+::sysinit:/etc/init.d/rcS S boot
+::shutdown:/etc/init.d/rcS K shutdown
+ttyS0::askfirst:/bin/ash --login
+tty1::askfirst:/bin/ash --login
diff --git a/package/base-files/files.old/etc/preinit b/package/base-files/files.old/etc/preinit
new file mode 100755
index 0000000..b237c2e
--- /dev/null
+++ b/package/base-files/files.old/etc/preinit
@@ -0,0 +1,43 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+export PATH=/bin:/sbin:/usr/bin:/usr/sbin
+
+pi_ifname=
+pi_ip=192.168.1.1
+pi_broadcast=192.168.1.255
+pi_netmask=255.255.255.0
+
+fs_failsafe_ifname=
+fs_failsafe_ip=192.168.1.1
+fs_failsafe_broadcast=192.168.1.255
+fs_failsafe_netmask=255.255.255.0
+
+fs_failsafe_wait_timeout=2
+
+pi_suppress_stderr="y"
+pi_init_suppress_stderr="y"
+pi_init_path="/bin:/sbin:/usr/bin:/usr/sbin"
+pi_init_cmd="/sbin/init"
+
+. /lib/functions.sh
+
+boot_hook_init preinit_essential
+boot_hook_init preinit_main
+boot_hook_init failsafe
+boot_hook_init initramfs
+boot_hook_init preinit_mount_root
+
+for pi_source_file in /lib/preinit/*; do
+ . $pi_source_file
+done
+
+boot_run_hook preinit_essential
+
+pi_mount_skip_next=false
+pi_jffs2_mount_success=false
+pi_failsafe_net_message=false
+
+boot_run_hook preinit_main
+
diff --git a/package/base-files/files.old/etc/watchdog b/package/base-files/files.old/etc/watchdog
new file mode 100755
index 0000000..299c891
--- /dev/null
+++ b/package/base-files/files.old/etc/watchdog
@@ -0,0 +1,13 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2008-2011 OpenWrt.org
+
+START=97
+
+start() {
+ [ -c /dev/watchdog ] || return 1
+ [ -x /sbin/watchdog ] || return 1
+ service_start /sbin/watchdog -t 5 /dev/watchdog
+}
+stop() {
+ service_stop /sbin/watchdog
+}
diff --git a/package/base-files/files.old/init b/package/base-files/files.old/init
new file mode 100755
index 0000000..b4ef4fe
--- /dev/null
+++ b/package/base-files/files.old/init
@@ -0,0 +1,96 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+
+INITRAMFS=1
+
+. /etc/preinit
+
+set_state init
+echo "- init -"
+
+[ -n "$SWITCH_ROOT_TMPFS" ] && {
+ mount -o noatime none /mnt -t tmpfs
+ ( cd /; find -xdev -type d ) | ( cd /mnt; xargs mkdir -p )
+ find / \! -type d -xdev | tar -cT /proc/self/fd/0 | tar -xC /mnt
+ mkdir /mnt/proc /mnt/dev /mnt/tmp /mnt/sys
+ mount -o noatime,move /proc /mnt/proc
+ mount -o noatime,move /dev /mnt/dev
+ mount -o noatime,move /tmp /mnt/tmp
+ mount -o noatime,move /sys /mnt/sys
+ rm -rf /proc /dev /tmp /sys
+ exec switch_root -c /dev/console /mnt /sbin/init
+}
+
+# if we have no root parameter, just go to running from ramfs
+[ -z $rootfs ] && {
+ export NOMOUNT="No Root"
+ exec /sbin/init
+}
+
+#if we have a failsafe boot selected, dont bother
+#trying to find or wait for a root mount point
+[ -z "$FAILSAFE" ] || {
+ exec /bin/busybox init
+}
+
+# Load the modules we have in initramfs, this should
+# make the media accessible, but, it may take some time
+. /lib/functions.sh
+load_modules /etc/modules /etc/modules.d/*
+
+#wait 10 seconds for the disc to show up
+#usb stick typically takes 4 to 6 seconds
+#till it's readable
+#it's quite possible the disc never shows up
+#if we netbooted this kernel
+COUNTER=0
+while [ $COUNTER -lt 10 ]; do
+ sleep 1
+ [ -e $rootfs ] && let COUNTER=10;
+ let COUNTER=COUNTER+1
+done
+[ -e $rootfs ] || {
+ export FAILSAFE="NoDisc"
+ exec /bin/busybox init
+}
+
+# now we'll try mount it, again with a timeout
+# This will fail if the inserted stick is formatted
+# in a manner we dont understand
+COUNTER=0
+while [ $COUNTER -lt 10 ]; do
+ sleep 1
+ mount -o noatime $rootfs /mnt
+ [ $? -eq "0" ] && let COUNTER=100;
+ let COUNTER=COUNTER+1
+done
+[ $? -ne "0" ] && {
+ export FAILSAFE="MountFail"
+ exec /bin/busybox init
+}
+
+#It mounted, lets look for a postinit file, again, give it time
+#I've seen this take 6 seconds to actually complete
+COUNTER=0
+while [ $COUNTER -lt 10 ]; do
+ sleep 1
+ [ -e /mnt/etc/banner ] && let COUNTER=10;
+ let COUNTER=COUNTER+1
+done
+[ -e /mnt/etc/banner ] || {
+ export FAILSAFE="No Openwrt FS"
+ exec /bin/busybox init
+}
+
+unset rootfs
+
+mount -o noatime,move /proc /mnt/proc
+mount -o noatime,move /dev /mnt/dev
+mount -o noatime,move /dev/pts /mnt/dev/pts
+mount -o noatime,move /tmp /mnt/tmp
+mount -o noatime,move /sys /mnt/sys
+mount -o noatime none /tmp -t tmpfs
+killall -q hotplug2
+exec switch_root -c /dev/console /mnt /sbin/init
+
+set_state done
diff --git a/package/base-files/files.old/lib/.svn/entries b/package/base-files/files.old/lib/.svn/entries
new file mode 100644
index 0000000..ea9a69d
--- /dev/null
+++ b/package/base-files/files.old/lib/.svn/entries
@@ -0,0 +1,37 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/base-files/files.old/lib
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-13T18:11:19.892934Z
+36003
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+upgrade
+dir
+
+preinit
+dir
+
+firstboot
+dir
+
diff --git a/package/base-files/files.old/lib/firstboot/.svn/entries b/package/base-files/files.old/lib/firstboot/.svn/entries
new file mode 100644
index 0000000..480b63b
--- /dev/null
+++ b/package/base-files/files.old/lib/firstboot/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/base-files/files.old/lib/firstboot
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-13T18:11:19.892934Z
+36003
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+99_10_with_fo_cleanup
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+2d246a5212e96570c9633aeba3ccb2e7
+2013-03-13T18:11:19.892934Z
+36003
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+498
+
diff --git a/package/base-files/files.old/lib/firstboot/.svn/text-base/99_10_with_fo_cleanup.svn-base b/package/base-files/files.old/lib/firstboot/.svn/text-base/99_10_with_fo_cleanup.svn-base
new file mode 100644
index 0000000..0181b39
--- /dev/null
+++ b/package/base-files/files.old/lib/firstboot/.svn/text-base/99_10_with_fo_cleanup.svn-base
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+with_fo_cleanup() {
+ # try to get rid of /tmp/root
+ # this will almost always fail
+ umount /tmp/root 2>&-
+ grep -q overlay /proc/filesystems && {
+ cd /
+ (
+ cd /overlay
+ find -type l
+ ) | while read FILE; do
+ [ -z "$FILE" ] && break
+ if ls -la "$FILE" 2>&- | grep -q '(overlay-whiteout)'; then
+ rm -f "$FILE"
+ fi
+ done
+ }
+ exit 0
+}
+
+boot_hook_add switch2jffs with_fo_cleanup
diff --git a/package/base-files/files.old/lib/firstboot/99_10_with_fo_cleanup b/package/base-files/files.old/lib/firstboot/99_10_with_fo_cleanup
new file mode 100644
index 0000000..0181b39
--- /dev/null
+++ b/package/base-files/files.old/lib/firstboot/99_10_with_fo_cleanup
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+with_fo_cleanup() {
+ # try to get rid of /tmp/root
+ # this will almost always fail
+ umount /tmp/root 2>&-
+ grep -q overlay /proc/filesystems && {
+ cd /
+ (
+ cd /overlay
+ find -type l
+ ) | while read FILE; do
+ [ -z "$FILE" ] && break
+ if ls -la "$FILE" 2>&- | grep -q '(overlay-whiteout)'; then
+ rm -f "$FILE"
+ fi
+ done
+ }
+ exit 0
+}
+
+boot_hook_add switch2jffs with_fo_cleanup
diff --git a/package/base-files/files.old/lib/preinit/.svn/entries b/package/base-files/files.old/lib/preinit/.svn/entries
new file mode 100644
index 0000000..def37f2
--- /dev/null
+++ b/package/base-files/files.old/lib/preinit/.svn/entries
@@ -0,0 +1,436 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/base-files/files.old/lib/preinit
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-13T18:11:19.892934Z
+36003
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+10_essential_fs
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+9c15e362fa00b05d2bb18bcca1e65307
+2013-03-13T18:11:19.892934Z
+36003
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+607
+
+30_device_fs_daemons
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+37a8eb0da658b97d50e8754b16670d8f
+2013-03-13T18:11:19.892934Z
+36003
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+948
+
+50_indicate_regular_preinit
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+a3ddeb98a9e57373d3245e3063955830
+2013-03-13T18:11:19.892934Z
+36003
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+282
+
+50_choose_console
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+ffa607ae2d534e521b5c6273d3cdaa5a
+2013-03-13T18:11:19.892934Z
+36003
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+766
+
+99_10_run_init
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+93c0f80a6054bca387c09ee4e6f99f3a
+2013-03-13T18:11:19.892934Z
+36003
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+379
+
+10_indicate_preinit
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+b7620c301b089c9b6f8a609568248a36
+2013-03-13T18:11:19.892934Z
+36003
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1182
+
+20_device_fs_mount
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+97d976564787de8a1a52d8f45fedded4
+2013-03-13T18:11:19.892934Z
+36003
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+821
+
+40_mount_devpts
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+59efcb6eb5436fa447a3b2497ec09c4c
+2013-03-13T18:11:19.892934Z
+36003
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+312
+
+60_init_hotplug
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+780b925ca1f5475b249ebd0abb09564c
+2013-03-13T18:11:19.892934Z
+36003
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+196
+
+80_mount_root
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+0733c44aa481aa9fdc689a6a75450127
+2013-03-13T18:11:19.892934Z
+36003
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+189
+
+40_init_shm
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+a4946afc8f58103c9f9f3c125db6e49f
+2013-03-13T18:11:19.892934Z
+36003
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+188
+
+90_init_console
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+3e28746c996a5f8bab36246a8bd2910a
+2013-03-13T18:11:19.892934Z
+36003
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+265
+
diff --git a/package/base-files/files.old/lib/preinit/.svn/text-base/10_essential_fs.svn-base b/package/base-files/files.old/lib/preinit/.svn/text-base/10_essential_fs.svn-base
new file mode 100644
index 0000000..fc04eb7
--- /dev/null
+++ b/package/base-files/files.old/lib/preinit/.svn/text-base/10_essential_fs.svn-base
@@ -0,0 +1,25 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+do_mount_procfs() {
+ mount -o noatime -t proc proc /proc
+}
+
+do_mount_sysfs() {
+ mount -o noatime -tsysfs sysfs /sys
+}
+
+calc_tmpfs_size() {
+ pi_size=$(awk '/MemTotal:/ {l=5242880;mt=($2*1024);print((s=mt/2)<l)&&(mt>l)?mt-l:s}' /proc/meminfo)
+}
+
+do_mount_tmpfs() {
+ calc_tmpfs_size
+ mount -o noatime -t tmpfs -o size=$pi_size,nosuid,nodev,mode=1777 tmpfs /tmp
+}
+
+boot_hook_add preinit_essential do_mount_procfs
+boot_hook_add preinit_essential do_mount_sysfs
+boot_hook_add preinit_essential do_mount_tmpfs
+
diff --git a/package/base-files/files.old/lib/preinit/.svn/text-base/10_indicate_preinit.svn-base b/package/base-files/files.old/lib/preinit/.svn/text-base/10_indicate_preinit.svn-base
new file mode 100644
index 0000000..4a0109c
--- /dev/null
+++ b/package/base-files/files.old/lib/preinit/.svn/text-base/10_indicate_preinit.svn-base
@@ -0,0 +1,51 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+preinit_ip() {
+ # if the preinit interface isn't specified and ifname is set in
+ # preinit.arch use that interface
+ if [ -z "$pi_ifname" ]; then
+ pi_ifname=$ifname
+ fi
+
+ [ -n "$pi_ifname" ] && grep -q "$pi_ifname" /proc/net/dev && {
+ ifconfig $pi_ifname $pi_ip netmask $pi_netmask broadcast $pi_broadcast up
+ }
+}
+
+preinit_ip_deconfig() {
+ [ -n "$pi_ifname" ] && grep -q "$pi_ifname" /proc/net/dev && {
+ ifconfig $pi_ifname 0.0.0.0 down
+ }
+}
+
+preinit_net_echo() {
+ [ -n "$pi_ifname" ] && grep -q "$pi_ifname" /proc/net/dev && {
+ {
+ [ "$pi_preinit_net_messages" = "y" ] || {
+ [ "$pi_failsafe_net_message" = "true" ] &&
+ [ "$pi_preinit_no_failsafe_netmsg" != "y" ]
+ }
+ } && netmsg $pi_broadcast "$1"
+ }
+}
+
+preinit_echo() {
+ preinit_net_echo $1
+ echo $1
+}
+
+pi_indicate_led() {
+ set_state preinit
+}
+
+pi_indicate_preinit() {
+ echo "- preinit -"
+ preinit_net_echo "Doing OpenWRT Preinit\n"
+ pi_indicate_led
+}
+
+boot_hook_add preinit_main preinit_ip
+boot_hook_add preinit_main pi_indicate_preinit
+
diff --git a/package/base-files/files.old/lib/preinit/.svn/text-base/20_device_fs_mount.svn-base b/package/base-files/files.old/lib/preinit/.svn/text-base/20_device_fs_mount.svn-base
new file mode 100644
index 0000000..7535b3f
--- /dev/null
+++ b/package/base-files/files.old/lib/preinit/.svn/text-base/20_device_fs_mount.svn-base
@@ -0,0 +1,37 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+do_move_devtmpfs() {
+ local mnt="$(grep devtmpfs /proc/mounts)"
+ mnt="${mnt#* }"; mnt="${mnt%% *}"
+
+ [ "$mnt" = "/dev" ] || mount -o noatime,move "$mnt" /dev
+}
+
+do_mount_devfs() {
+ mount -o noatime -t devfs devfs /dev
+}
+
+do_mount_hotplug() {
+ mount -t tmpfs -o noatime,mode=0755,size=512K tmpfs /dev
+}
+
+do_mount_udev() {
+ mount -n -t tmpfs -o noatime,mode=0755 udev /dev
+}
+
+choose_device_fs() {
+ if grep -q devtmpfs /proc/mounts; then
+ do_move_devtmpfs
+ elif grep -q devfs /proc/filesystems; then
+ do_mount_devfs
+ elif [ -x /sbin/hotplug2 ]; then
+ do_mount_hotplug
+ elif [ -x /sbin/udevd ]; then
+ do_mount_udev
+ fi
+}
+
+boot_hook_add preinit_essential choose_device_fs
+
diff --git a/package/base-files/files.old/lib/preinit/.svn/text-base/30_device_fs_daemons.svn-base b/package/base-files/files.old/lib/preinit/.svn/text-base/30_device_fs_daemons.svn-base
new file mode 100644
index 0000000..8379e5e
--- /dev/null
+++ b/package/base-files/files.old/lib/preinit/.svn/text-base/30_device_fs_daemons.svn-base
@@ -0,0 +1,36 @@
+#!/bin/sh
+# Copyright (C) 2006-2013 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+init_devfs() {
+ HOTPLUG=/sbin/hotplug-call
+}
+
+init_hotplug2() {
+ [ -c /dev/console ] || mknod /dev/console c 5 1
+ /sbin/hotplug2 --set-rules-file /etc/hotplug2-init.rules --no-persistent --set-coldplug-cmd /sbin/udevtrigger
+ /sbin/hotplug2 --set-rules-file /etc/hotplug2-init.rules --persistent &
+}
+
+init_udev() {
+ [ -d /lib/udev/devices ] && cp -af /lib/udev/devices/* /dev/
+ [ -c /dev/console ] || mknod -m 0600 /dev/console c 5 1
+ [ -c /dev/null ] || mknod -m 0666 /dev/null c 1 3
+ /sbin/udevd --daemon --resolve-names=never
+ /sbin/udevadm trigger
+ /sbin/udevadm settle
+}
+
+init_device_fs() {
+ HOTPLUG=
+ if grep -q devfs /proc/filesystems; then
+ init_devfs
+ elif [ -x /sbin/hotplug2 ]; then
+ init_hotplug2
+ elif [ -x /sbin/udevd ]; then
+ init_udev
+ fi
+}
+
+boot_hook_add preinit_essential init_device_fs
+
diff --git a/package/base-files/files.old/lib/preinit/.svn/text-base/40_init_shm.svn-base b/package/base-files/files.old/lib/preinit/.svn/text-base/40_init_shm.svn-base
new file mode 100644
index 0000000..8971116
--- /dev/null
+++ b/package/base-files/files.old/lib/preinit/.svn/text-base/40_init_shm.svn-base
@@ -0,0 +1,10 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+init_shm() {
+ [ -d /dev/shm ] || mkdir -p /dev/shm
+}
+
+boot_hook_add preinit_essential init_shm
+
diff --git a/package/base-files/files.old/lib/preinit/.svn/text-base/40_mount_devpts.svn-base b/package/base-files/files.old/lib/preinit/.svn/text-base/40_mount_devpts.svn-base
new file mode 100644
index 0000000..b55a7f2
--- /dev/null
+++ b/package/base-files/files.old/lib/preinit/.svn/text-base/40_mount_devpts.svn-base
@@ -0,0 +1,15 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+init_devpts() {
+ [ -d /dev/pts ] || mkdir -p /dev/pts
+}
+
+do_mount_devpts() {
+ mount -o noatime -t devpts devpts /dev/pts
+}
+
+boot_hook_add preinit_essential init_devpts
+boot_hook_add preinit_essential do_mount_devpts
+
diff --git a/package/base-files/files.old/lib/preinit/.svn/text-base/50_choose_console.svn-base b/package/base-files/files.old/lib/preinit/.svn/text-base/50_choose_console.svn-base
new file mode 100644
index 0000000..ecbc2ea
--- /dev/null
+++ b/package/base-files/files.old/lib/preinit/.svn/text-base/50_choose_console.svn-base
@@ -0,0 +1,31 @@
+#!/bin/sh
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+choose_console() {
+ # the shell really doesn't like having stdin/out closed
+ # that's why we use /dev/pty/m0 and m1 (or equivalent) as replacement
+ # for /dev/console if there's no serial console available
+
+ if grep -q devfs /proc/filesystems; then
+ M0=/dev/pty/m0
+ M1=/dev/pty/m1
+ M2=/dev/pty/m1
+ elif [ -x /sbin/hotplug2 ]; then
+ M0=/dev/ptmx
+ M1=/dev/ptmx
+ M2=/dev/ptmx
+ elif [ -x /sbin/udevd ]; then
+ M0=/dev/pty/ptmx
+ M1=/dev/pty/ptmx
+ M2=/dev/pty/ptmx
+ fi
+ dd if=/dev/console of=/dev/null bs=1 count=0 >/dev/null 2>/dev/null && {
+ M0=/dev/console
+ M1=/dev/console
+ M2=/dev/console
+ }
+}
+
+boot_hook_add preinit_essential choose_console
+
diff --git a/package/base-files/files.old/lib/preinit/.svn/text-base/50_indicate_regular_preinit.svn-base b/package/base-files/files.old/lib/preinit/.svn/text-base/50_indicate_regular_preinit.svn-base
new file mode 100644
index 0000000..9cc01f2
--- /dev/null
+++ b/package/base-files/files.old/lib/preinit/.svn/text-base/50_indicate_regular_preinit.svn-base
@@ -0,0 +1,12 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+indicate_regular_preinit() {
+ echo "- regular preinit -"
+ preinit_net_echo "Continuing with Regular Preinit\n"
+ pi_indicate_led
+}
+
+boot_hook_add preinit_main indicate_regular_preinit
+
diff --git a/package/base-files/files.old/lib/preinit/.svn/text-base/60_init_hotplug.svn-base b/package/base-files/files.old/lib/preinit/.svn/text-base/60_init_hotplug.svn-base
new file mode 100644
index 0000000..dc05e0e
--- /dev/null
+++ b/package/base-files/files.old/lib/preinit/.svn/text-base/60_init_hotplug.svn-base
@@ -0,0 +1,10 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+init_hotplug() {
+ echo "$HOTPLUG" > /proc/sys/kernel/hotplug
+}
+
+boot_hook_add preinit_main init_hotplug
+
diff --git a/package/base-files/files.old/lib/preinit/.svn/text-base/80_mount_root.svn-base b/package/base-files/files.old/lib/preinit/.svn/text-base/80_mount_root.svn-base
new file mode 100644
index 0000000..ad24fb8
--- /dev/null
+++ b/package/base-files/files.old/lib/preinit/.svn/text-base/80_mount_root.svn-base
@@ -0,0 +1,10 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+do_mount_root() {
+ boot_run_hook preinit_mount_root
+}
+
+boot_hook_add preinit_main do_mount_root
+
diff --git a/package/base-files/files.old/lib/preinit/.svn/text-base/90_init_console.svn-base b/package/base-files/files.old/lib/preinit/.svn/text-base/90_init_console.svn-base
new file mode 100644
index 0000000..ca05755
--- /dev/null
+++ b/package/base-files/files.old/lib/preinit/.svn/text-base/90_init_console.svn-base
@@ -0,0 +1,14 @@
+#!/bin/sh
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+init_console() {
+ if [ "$pi_suppress_stderr" = "y" ]; then
+ exec <$M0 >$M1 2>&0
+ else
+ exec <$M0 >$M1 2>$M2
+ fi
+}
+
+boot_hook_add preinit_essential init_console
+
diff --git a/package/base-files/files.old/lib/preinit/.svn/text-base/99_10_run_init.svn-base b/package/base-files/files.old/lib/preinit/.svn/text-base/99_10_run_init.svn-base
new file mode 100644
index 0000000..fef3a50
--- /dev/null
+++ b/package/base-files/files.old/lib/preinit/.svn/text-base/99_10_run_init.svn-base
@@ -0,0 +1,16 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+run_init() {
+ preinit_echo "- init -"
+ preinit_ip_deconfig
+ if [ "$pi_init_suppress_stderr" = "y" ]; then
+ exec env - PATH=$pi_init_path $pi_init_env $pi_init_cmd 2>&0
+ else
+ exec env - PATH=$pi_init_path $pi_init_env $pi_init_cmd
+ fi
+}
+
+boot_hook_add preinit_main run_init
+
diff --git a/package/base-files/files.old/lib/preinit/10_essential_fs b/package/base-files/files.old/lib/preinit/10_essential_fs
new file mode 100644
index 0000000..fc04eb7
--- /dev/null
+++ b/package/base-files/files.old/lib/preinit/10_essential_fs
@@ -0,0 +1,25 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+do_mount_procfs() {
+ mount -o noatime -t proc proc /proc
+}
+
+do_mount_sysfs() {
+ mount -o noatime -tsysfs sysfs /sys
+}
+
+calc_tmpfs_size() {
+ pi_size=$(awk '/MemTotal:/ {l=5242880;mt=($2*1024);print((s=mt/2)<l)&&(mt>l)?mt-l:s}' /proc/meminfo)
+}
+
+do_mount_tmpfs() {
+ calc_tmpfs_size
+ mount -o noatime -t tmpfs -o size=$pi_size,nosuid,nodev,mode=1777 tmpfs /tmp
+}
+
+boot_hook_add preinit_essential do_mount_procfs
+boot_hook_add preinit_essential do_mount_sysfs
+boot_hook_add preinit_essential do_mount_tmpfs
+
diff --git a/package/base-files/files.old/lib/preinit/10_indicate_preinit b/package/base-files/files.old/lib/preinit/10_indicate_preinit
new file mode 100644
index 0000000..4a0109c
--- /dev/null
+++ b/package/base-files/files.old/lib/preinit/10_indicate_preinit
@@ -0,0 +1,51 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+preinit_ip() {
+ # if the preinit interface isn't specified and ifname is set in
+ # preinit.arch use that interface
+ if [ -z "$pi_ifname" ]; then
+ pi_ifname=$ifname
+ fi
+
+ [ -n "$pi_ifname" ] && grep -q "$pi_ifname" /proc/net/dev && {
+ ifconfig $pi_ifname $pi_ip netmask $pi_netmask broadcast $pi_broadcast up
+ }
+}
+
+preinit_ip_deconfig() {
+ [ -n "$pi_ifname" ] && grep -q "$pi_ifname" /proc/net/dev && {
+ ifconfig $pi_ifname 0.0.0.0 down
+ }
+}
+
+preinit_net_echo() {
+ [ -n "$pi_ifname" ] && grep -q "$pi_ifname" /proc/net/dev && {
+ {
+ [ "$pi_preinit_net_messages" = "y" ] || {
+ [ "$pi_failsafe_net_message" = "true" ] &&
+ [ "$pi_preinit_no_failsafe_netmsg" != "y" ]
+ }
+ } && netmsg $pi_broadcast "$1"
+ }
+}
+
+preinit_echo() {
+ preinit_net_echo $1
+ echo $1
+}
+
+pi_indicate_led() {
+ set_state preinit
+}
+
+pi_indicate_preinit() {
+ echo "- preinit -"
+ preinit_net_echo "Doing OpenWRT Preinit\n"
+ pi_indicate_led
+}
+
+boot_hook_add preinit_main preinit_ip
+boot_hook_add preinit_main pi_indicate_preinit
+
diff --git a/package/base-files/files.old/lib/preinit/20_device_fs_mount b/package/base-files/files.old/lib/preinit/20_device_fs_mount
new file mode 100644
index 0000000..7535b3f
--- /dev/null
+++ b/package/base-files/files.old/lib/preinit/20_device_fs_mount
@@ -0,0 +1,37 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+do_move_devtmpfs() {
+ local mnt="$(grep devtmpfs /proc/mounts)"
+ mnt="${mnt#* }"; mnt="${mnt%% *}"
+
+ [ "$mnt" = "/dev" ] || mount -o noatime,move "$mnt" /dev
+}
+
+do_mount_devfs() {
+ mount -o noatime -t devfs devfs /dev
+}
+
+do_mount_hotplug() {
+ mount -t tmpfs -o noatime,mode=0755,size=512K tmpfs /dev
+}
+
+do_mount_udev() {
+ mount -n -t tmpfs -o noatime,mode=0755 udev /dev
+}
+
+choose_device_fs() {
+ if grep -q devtmpfs /proc/mounts; then
+ do_move_devtmpfs
+ elif grep -q devfs /proc/filesystems; then
+ do_mount_devfs
+ elif [ -x /sbin/hotplug2 ]; then
+ do_mount_hotplug
+ elif [ -x /sbin/udevd ]; then
+ do_mount_udev
+ fi
+}
+
+boot_hook_add preinit_essential choose_device_fs
+
diff --git a/package/base-files/files.old/lib/preinit/30_device_fs_daemons b/package/base-files/files.old/lib/preinit/30_device_fs_daemons
new file mode 100644
index 0000000..8379e5e
--- /dev/null
+++ b/package/base-files/files.old/lib/preinit/30_device_fs_daemons
@@ -0,0 +1,36 @@
+#!/bin/sh
+# Copyright (C) 2006-2013 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+init_devfs() {
+ HOTPLUG=/sbin/hotplug-call
+}
+
+init_hotplug2() {
+ [ -c /dev/console ] || mknod /dev/console c 5 1
+ /sbin/hotplug2 --set-rules-file /etc/hotplug2-init.rules --no-persistent --set-coldplug-cmd /sbin/udevtrigger
+ /sbin/hotplug2 --set-rules-file /etc/hotplug2-init.rules --persistent &
+}
+
+init_udev() {
+ [ -d /lib/udev/devices ] && cp -af /lib/udev/devices/* /dev/
+ [ -c /dev/console ] || mknod -m 0600 /dev/console c 5 1
+ [ -c /dev/null ] || mknod -m 0666 /dev/null c 1 3
+ /sbin/udevd --daemon --resolve-names=never
+ /sbin/udevadm trigger
+ /sbin/udevadm settle
+}
+
+init_device_fs() {
+ HOTPLUG=
+ if grep -q devfs /proc/filesystems; then
+ init_devfs
+ elif [ -x /sbin/hotplug2 ]; then
+ init_hotplug2
+ elif [ -x /sbin/udevd ]; then
+ init_udev
+ fi
+}
+
+boot_hook_add preinit_essential init_device_fs
+
diff --git a/package/base-files/files.old/lib/preinit/40_init_shm b/package/base-files/files.old/lib/preinit/40_init_shm
new file mode 100644
index 0000000..8971116
--- /dev/null
+++ b/package/base-files/files.old/lib/preinit/40_init_shm
@@ -0,0 +1,10 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+init_shm() {
+ [ -d /dev/shm ] || mkdir -p /dev/shm
+}
+
+boot_hook_add preinit_essential init_shm
+
diff --git a/package/base-files/files.old/lib/preinit/40_mount_devpts b/package/base-files/files.old/lib/preinit/40_mount_devpts
new file mode 100644
index 0000000..b55a7f2
--- /dev/null
+++ b/package/base-files/files.old/lib/preinit/40_mount_devpts
@@ -0,0 +1,15 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+init_devpts() {
+ [ -d /dev/pts ] || mkdir -p /dev/pts
+}
+
+do_mount_devpts() {
+ mount -o noatime -t devpts devpts /dev/pts
+}
+
+boot_hook_add preinit_essential init_devpts
+boot_hook_add preinit_essential do_mount_devpts
+
diff --git a/package/base-files/files.old/lib/preinit/50_choose_console b/package/base-files/files.old/lib/preinit/50_choose_console
new file mode 100644
index 0000000..ecbc2ea
--- /dev/null
+++ b/package/base-files/files.old/lib/preinit/50_choose_console
@@ -0,0 +1,31 @@
+#!/bin/sh
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+choose_console() {
+ # the shell really doesn't like having stdin/out closed
+ # that's why we use /dev/pty/m0 and m1 (or equivalent) as replacement
+ # for /dev/console if there's no serial console available
+
+ if grep -q devfs /proc/filesystems; then
+ M0=/dev/pty/m0
+ M1=/dev/pty/m1
+ M2=/dev/pty/m1
+ elif [ -x /sbin/hotplug2 ]; then
+ M0=/dev/ptmx
+ M1=/dev/ptmx
+ M2=/dev/ptmx
+ elif [ -x /sbin/udevd ]; then
+ M0=/dev/pty/ptmx
+ M1=/dev/pty/ptmx
+ M2=/dev/pty/ptmx
+ fi
+ dd if=/dev/console of=/dev/null bs=1 count=0 >/dev/null 2>/dev/null && {
+ M0=/dev/console
+ M1=/dev/console
+ M2=/dev/console
+ }
+}
+
+boot_hook_add preinit_essential choose_console
+
diff --git a/package/base-files/files.old/lib/preinit/50_indicate_regular_preinit b/package/base-files/files.old/lib/preinit/50_indicate_regular_preinit
new file mode 100644
index 0000000..9cc01f2
--- /dev/null
+++ b/package/base-files/files.old/lib/preinit/50_indicate_regular_preinit
@@ -0,0 +1,12 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+indicate_regular_preinit() {
+ echo "- regular preinit -"
+ preinit_net_echo "Continuing with Regular Preinit\n"
+ pi_indicate_led
+}
+
+boot_hook_add preinit_main indicate_regular_preinit
+
diff --git a/package/base-files/files.old/lib/preinit/60_init_hotplug b/package/base-files/files.old/lib/preinit/60_init_hotplug
new file mode 100644
index 0000000..dc05e0e
--- /dev/null
+++ b/package/base-files/files.old/lib/preinit/60_init_hotplug
@@ -0,0 +1,10 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+init_hotplug() {
+ echo "$HOTPLUG" > /proc/sys/kernel/hotplug
+}
+
+boot_hook_add preinit_main init_hotplug
+
diff --git a/package/base-files/files.old/lib/preinit/80_mount_root b/package/base-files/files.old/lib/preinit/80_mount_root
new file mode 100644
index 0000000..ad24fb8
--- /dev/null
+++ b/package/base-files/files.old/lib/preinit/80_mount_root
@@ -0,0 +1,10 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+do_mount_root() {
+ boot_run_hook preinit_mount_root
+}
+
+boot_hook_add preinit_main do_mount_root
+
diff --git a/package/base-files/files.old/lib/preinit/90_init_console b/package/base-files/files.old/lib/preinit/90_init_console
new file mode 100644
index 0000000..ca05755
--- /dev/null
+++ b/package/base-files/files.old/lib/preinit/90_init_console
@@ -0,0 +1,14 @@
+#!/bin/sh
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+init_console() {
+ if [ "$pi_suppress_stderr" = "y" ]; then
+ exec <$M0 >$M1 2>&0
+ else
+ exec <$M0 >$M1 2>$M2
+ fi
+}
+
+boot_hook_add preinit_essential init_console
+
diff --git a/package/base-files/files.old/lib/preinit/99_10_run_init b/package/base-files/files.old/lib/preinit/99_10_run_init
new file mode 100644
index 0000000..fef3a50
--- /dev/null
+++ b/package/base-files/files.old/lib/preinit/99_10_run_init
@@ -0,0 +1,16 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+run_init() {
+ preinit_echo "- init -"
+ preinit_ip_deconfig
+ if [ "$pi_init_suppress_stderr" = "y" ]; then
+ exec env - PATH=$pi_init_path $pi_init_env $pi_init_cmd 2>&0
+ else
+ exec env - PATH=$pi_init_path $pi_init_env $pi_init_cmd
+ fi
+}
+
+boot_hook_add preinit_main run_init
+
diff --git a/package/base-files/files.old/lib/upgrade/.svn/entries b/package/base-files/files.old/lib/upgrade/.svn/entries
new file mode 100644
index 0000000..b2ecd37
--- /dev/null
+++ b/package/base-files/files.old/lib/upgrade/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/base-files/files.old/lib/upgrade
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-13T18:11:19.892934Z
+36003
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+common.sh
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+1b578e56b80f018038d4e6f392efc87a
+2013-03-13T18:11:19.892934Z
+36003
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5026
+
diff --git a/package/base-files/files.old/lib/upgrade/.svn/text-base/common.sh.svn-base b/package/base-files/files.old/lib/upgrade/.svn/text-base/common.sh.svn-base
new file mode 100644
index 0000000..2e123ab
--- /dev/null
+++ b/package/base-files/files.old/lib/upgrade/.svn/text-base/common.sh.svn-base
@@ -0,0 +1,230 @@
+#!/bin/sh
+
+RAM_ROOT=/tmp/root
+
+ldd() { LD_TRACE_LOADED_OBJECTS=1 $*; }
+libs() { ldd $* | awk '{print $3}'; }
+
+install_file() { # <file> [ <file> ... ]
+ for file in "$@"; do
+ dest="$RAM_ROOT/$file"
+ [ -f $file -a ! -f $dest ] && {
+ dir="$(dirname $dest)"
+ mkdir -p "$dir"
+ cp $file $dest
+ }
+ done
+}
+
+install_bin() { # <file> [ <symlink> ... ]
+ src=$1
+ files=$1
+ [ -x "$src" ] && files="$src $(libs $src)"
+ install_file $files
+ [ -e /lib/ld-linux.so.3 ] && {
+ install_file /lib/ld-linux.so.3
+ }
+ shift
+ for link in "$@"; do {
+ dest="$RAM_ROOT/$link"
+ dir="$(dirname $dest)"
+ mkdir -p "$dir"
+ [ -f "$dest" ] || ln -s $src $dest
+ }; done
+}
+
+supivot() { # <new_root> <old_root>
+ mount | grep "on $1 type" 2>&- 1>&- || mount -o bind $1 $1
+ mkdir -p $1$2 $1/proc $1/sys $1/dev $1/tmp $1/overlay && \
+ mount -o noatime,move /proc $1/proc && \
+ pivot_root $1 $1$2 || {
+ umount $1 $1
+ return 1
+ }
+
+ mount -o noatime,move $2/sys /sys
+ mount -o noatime,move $2/dev /dev
+ mount -o noatime,move $2/tmp /tmp
+ mount -o noatime,move $2/overlay /overlay 2>&-
+ return 0
+}
+
+run_ramfs() { # <command> [...]
+ install_bin /bin/busybox /bin/ash /bin/sh /bin/mount /bin/umount \
+ /sbin/pivot_root /usr/bin/wget /sbin/reboot /bin/sync /bin/dd \
+ /bin/grep /bin/cp /bin/mv /bin/tar /usr/bin/md5sum "/usr/bin/[" \
+ /bin/vi /bin/ls /bin/cat /usr/bin/awk /usr/bin/hexdump \
+ /bin/sleep /bin/zcat /usr/bin/bzcat /usr/bin/printf /usr/bin/wc
+
+ install_bin /sbin/mtd
+ for file in $RAMFS_COPY_BIN; do
+ install_bin $file
+ done
+ install_file /etc/resolv.conf /lib/functions.sh /lib/functions.sh /lib/upgrade/*.sh $RAMFS_COPY_DATA
+
+ supivot $RAM_ROOT /mnt || {
+ echo "Failed to switch over to ramfs. Please reboot."
+ exit 1
+ }
+
+ mount -o remount,ro /mnt
+ umount -l /mnt
+
+ grep /overlay /proc/mounts > /dev/null && {
+ mount -o noatime,remount,ro /overlay
+ umount -l /overlay
+ }
+
+ # spawn a new shell from ramdisk to reduce the probability of cache issues
+ exec /bin/busybox ash -c "$*"
+}
+
+kill_remaining() { # [ <signal> ]
+ local sig="${1:-TERM}"
+ echo -n "Sending $sig to remaining processes ... "
+
+ local stat
+ for stat in /proc/[0-9]*/stat; do
+ [ -f "$stat" ] || continue
+
+ local pid name state ppid rest
+ read pid name state ppid rest < $stat
+ name="${name#(}"; name="${name%)}"
+
+ local cmdline
+ read cmdline < /proc/$pid/cmdline
+
+ # Skip kernel threads
+ [ -n "$cmdline" ] || continue
+
+ case "$name" in
+ # Skip essential services
+ *ash*|*init*|*watchdog*|*ssh*|*dropbear*|*telnet*|*login*|*hostapd*|*wpa_supplicant*) : ;;
+
+ # Killable process
+ *)
+ if [ $pid -ne $$ ] && [ $ppid -ne $$ ]; then
+ echo -n "$name "
+ kill -$sig $pid 2>/dev/null
+ fi
+ ;;
+ esac
+ done
+ echo ""
+}
+
+run_hooks() {
+ local arg="$1"; shift
+ for func in "$@"; do
+ eval "$func $arg"
+ done
+}
+
+ask_bool() {
+ local default="$1"; shift;
+ local answer="$default"
+
+ [ "$INTERACTIVE" -eq 1 ] && {
+ case "$default" in
+ 0) echo -n "$* (y/N): ";;
+ *) echo -n "$* (Y/n): ";;
+ esac
+ read answer
+ case "$answer" in
+ y*) answer=1;;
+ n*) answer=0;;
+ *) answer="$default";;
+ esac
+ }
+ [ "$answer" -gt 0 ]
+}
+
+v() {
+ [ "$VERBOSE" -ge 1 ] && echo "$@"
+}
+
+rootfs_type() {
+ mount | awk '($3 ~ /^\/$/) && ($5 !~ /rootfs/) { print $5 }'
+}
+
+get_image() { # <source> [ <command> ]
+ local from="$1"
+ local conc="$2"
+ local cmd
+
+ case "$from" in
+ http://*|ftp://*) cmd="wget -O- -q";;
+ *) cmd="cat";;
+ esac
+ if [ -z "$conc" ]; then
+ local magic="$(eval $cmd $from | dd bs=2 count=1 2>/dev/null | hexdump -n 2 -e '1/1 "%02x"')"
+ case "$magic" in
+ 1f8b) conc="zcat";;
+ 425a) conc="bzcat";;
+ esac
+ fi
+
+ eval "$cmd $from ${conc:+| $conc}"
+}
+
+get_magic_word() {
+ get_image "$@" | dd bs=2 count=1 2>/dev/null | hexdump -v -n 2 -e '1/1 "%02x"'
+}
+
+get_magic_long() {
+ get_image "$@" | dd bs=4 count=1 2>/dev/null | hexdump -v -n 4 -e '1/1 "%02x"'
+}
+
+refresh_mtd_partitions() {
+ mtd refresh rootfs
+}
+
+jffs2_copy_config() {
+ if grep rootfs_data /proc/mtd >/dev/null; then
+ # squashfs+jffs2
+ mtd -e rootfs_data jffs2write "$CONF_TAR" rootfs_data
+ else
+ # jffs2
+ mtd jffs2write "$CONF_TAR" rootfs
+ fi
+}
+
+default_do_upgrade() {
+ sync
+ if [ "$SAVE_CONFIG" -eq 1 -a -z "$USE_REFRESH" ]; then
+ get_image "$1" | mtd -j "$CONF_TAR" write - "${PART_NAME:-image}"
+ else
+ get_image "$1" | mtd write - "${PART_NAME:-image}"
+ fi
+}
+
+do_upgrade() {
+ v "Performing system upgrade..."
+ if type 'platform_do_upgrade' >/dev/null 2>/dev/null; then
+ platform_do_upgrade "$ARGV"
+ else
+ default_do_upgrade "$ARGV"
+ fi
+
+ [ "$SAVE_CONFIG" -eq 1 -a -n "$USE_REFRESH" ] && {
+ v "Refreshing partitions"
+ if type 'platform_refresh_partitions' >/dev/null 2>/dev/null; then
+ platform_refresh_partitions
+ else
+ refresh_mtd_partitions
+ fi
+ if type 'platform_copy_config' >/dev/null 2>/dev/null; then
+ platform_copy_config
+ else
+ jffs2_copy_config
+ fi
+ }
+ v "Upgrade completed"
+ [ -n "$DELAY" ] && sleep "$DELAY"
+ ask_bool 1 "Reboot" && {
+ v "Rebooting system..."
+ reboot -f
+ sleep 5
+ echo b 2>/dev/null >/proc/sysrq-trigger
+ }
+}
diff --git a/package/base-files/files.old/lib/upgrade/common.sh b/package/base-files/files.old/lib/upgrade/common.sh
new file mode 100644
index 0000000..2e123ab
--- /dev/null
+++ b/package/base-files/files.old/lib/upgrade/common.sh
@@ -0,0 +1,230 @@
+#!/bin/sh
+
+RAM_ROOT=/tmp/root
+
+ldd() { LD_TRACE_LOADED_OBJECTS=1 $*; }
+libs() { ldd $* | awk '{print $3}'; }
+
+install_file() { # <file> [ <file> ... ]
+ for file in "$@"; do
+ dest="$RAM_ROOT/$file"
+ [ -f $file -a ! -f $dest ] && {
+ dir="$(dirname $dest)"
+ mkdir -p "$dir"
+ cp $file $dest
+ }
+ done
+}
+
+install_bin() { # <file> [ <symlink> ... ]
+ src=$1
+ files=$1
+ [ -x "$src" ] && files="$src $(libs $src)"
+ install_file $files
+ [ -e /lib/ld-linux.so.3 ] && {
+ install_file /lib/ld-linux.so.3
+ }
+ shift
+ for link in "$@"; do {
+ dest="$RAM_ROOT/$link"
+ dir="$(dirname $dest)"
+ mkdir -p "$dir"
+ [ -f "$dest" ] || ln -s $src $dest
+ }; done
+}
+
+supivot() { # <new_root> <old_root>
+ mount | grep "on $1 type" 2>&- 1>&- || mount -o bind $1 $1
+ mkdir -p $1$2 $1/proc $1/sys $1/dev $1/tmp $1/overlay && \
+ mount -o noatime,move /proc $1/proc && \
+ pivot_root $1 $1$2 || {
+ umount $1 $1
+ return 1
+ }
+
+ mount -o noatime,move $2/sys /sys
+ mount -o noatime,move $2/dev /dev
+ mount -o noatime,move $2/tmp /tmp
+ mount -o noatime,move $2/overlay /overlay 2>&-
+ return 0
+}
+
+run_ramfs() { # <command> [...]
+ install_bin /bin/busybox /bin/ash /bin/sh /bin/mount /bin/umount \
+ /sbin/pivot_root /usr/bin/wget /sbin/reboot /bin/sync /bin/dd \
+ /bin/grep /bin/cp /bin/mv /bin/tar /usr/bin/md5sum "/usr/bin/[" \
+ /bin/vi /bin/ls /bin/cat /usr/bin/awk /usr/bin/hexdump \
+ /bin/sleep /bin/zcat /usr/bin/bzcat /usr/bin/printf /usr/bin/wc
+
+ install_bin /sbin/mtd
+ for file in $RAMFS_COPY_BIN; do
+ install_bin $file
+ done
+ install_file /etc/resolv.conf /lib/functions.sh /lib/functions.sh /lib/upgrade/*.sh $RAMFS_COPY_DATA
+
+ supivot $RAM_ROOT /mnt || {
+ echo "Failed to switch over to ramfs. Please reboot."
+ exit 1
+ }
+
+ mount -o remount,ro /mnt
+ umount -l /mnt
+
+ grep /overlay /proc/mounts > /dev/null && {
+ mount -o noatime,remount,ro /overlay
+ umount -l /overlay
+ }
+
+ # spawn a new shell from ramdisk to reduce the probability of cache issues
+ exec /bin/busybox ash -c "$*"
+}
+
+kill_remaining() { # [ <signal> ]
+ local sig="${1:-TERM}"
+ echo -n "Sending $sig to remaining processes ... "
+
+ local stat
+ for stat in /proc/[0-9]*/stat; do
+ [ -f "$stat" ] || continue
+
+ local pid name state ppid rest
+ read pid name state ppid rest < $stat
+ name="${name#(}"; name="${name%)}"
+
+ local cmdline
+ read cmdline < /proc/$pid/cmdline
+
+ # Skip kernel threads
+ [ -n "$cmdline" ] || continue
+
+ case "$name" in
+ # Skip essential services
+ *ash*|*init*|*watchdog*|*ssh*|*dropbear*|*telnet*|*login*|*hostapd*|*wpa_supplicant*) : ;;
+
+ # Killable process
+ *)
+ if [ $pid -ne $$ ] && [ $ppid -ne $$ ]; then
+ echo -n "$name "
+ kill -$sig $pid 2>/dev/null
+ fi
+ ;;
+ esac
+ done
+ echo ""
+}
+
+run_hooks() {
+ local arg="$1"; shift
+ for func in "$@"; do
+ eval "$func $arg"
+ done
+}
+
+ask_bool() {
+ local default="$1"; shift;
+ local answer="$default"
+
+ [ "$INTERACTIVE" -eq 1 ] && {
+ case "$default" in
+ 0) echo -n "$* (y/N): ";;
+ *) echo -n "$* (Y/n): ";;
+ esac
+ read answer
+ case "$answer" in
+ y*) answer=1;;
+ n*) answer=0;;
+ *) answer="$default";;
+ esac
+ }
+ [ "$answer" -gt 0 ]
+}
+
+v() {
+ [ "$VERBOSE" -ge 1 ] && echo "$@"
+}
+
+rootfs_type() {
+ mount | awk '($3 ~ /^\/$/) && ($5 !~ /rootfs/) { print $5 }'
+}
+
+get_image() { # <source> [ <command> ]
+ local from="$1"
+ local conc="$2"
+ local cmd
+
+ case "$from" in
+ http://*|ftp://*) cmd="wget -O- -q";;
+ *) cmd="cat";;
+ esac
+ if [ -z "$conc" ]; then
+ local magic="$(eval $cmd $from | dd bs=2 count=1 2>/dev/null | hexdump -n 2 -e '1/1 "%02x"')"
+ case "$magic" in
+ 1f8b) conc="zcat";;
+ 425a) conc="bzcat";;
+ esac
+ fi
+
+ eval "$cmd $from ${conc:+| $conc}"
+}
+
+get_magic_word() {
+ get_image "$@" | dd bs=2 count=1 2>/dev/null | hexdump -v -n 2 -e '1/1 "%02x"'
+}
+
+get_magic_long() {
+ get_image "$@" | dd bs=4 count=1 2>/dev/null | hexdump -v -n 4 -e '1/1 "%02x"'
+}
+
+refresh_mtd_partitions() {
+ mtd refresh rootfs
+}
+
+jffs2_copy_config() {
+ if grep rootfs_data /proc/mtd >/dev/null; then
+ # squashfs+jffs2
+ mtd -e rootfs_data jffs2write "$CONF_TAR" rootfs_data
+ else
+ # jffs2
+ mtd jffs2write "$CONF_TAR" rootfs
+ fi
+}
+
+default_do_upgrade() {
+ sync
+ if [ "$SAVE_CONFIG" -eq 1 -a -z "$USE_REFRESH" ]; then
+ get_image "$1" | mtd -j "$CONF_TAR" write - "${PART_NAME:-image}"
+ else
+ get_image "$1" | mtd write - "${PART_NAME:-image}"
+ fi
+}
+
+do_upgrade() {
+ v "Performing system upgrade..."
+ if type 'platform_do_upgrade' >/dev/null 2>/dev/null; then
+ platform_do_upgrade "$ARGV"
+ else
+ default_do_upgrade "$ARGV"
+ fi
+
+ [ "$SAVE_CONFIG" -eq 1 -a -n "$USE_REFRESH" ] && {
+ v "Refreshing partitions"
+ if type 'platform_refresh_partitions' >/dev/null 2>/dev/null; then
+ platform_refresh_partitions
+ else
+ refresh_mtd_partitions
+ fi
+ if type 'platform_copy_config' >/dev/null 2>/dev/null; then
+ platform_copy_config
+ else
+ jffs2_copy_config
+ fi
+ }
+ v "Upgrade completed"
+ [ -n "$DELAY" ] && sleep "$DELAY"
+ ask_bool 1 "Reboot" && {
+ v "Rebooting system..."
+ reboot -f
+ sleep 5
+ echo b 2>/dev/null >/proc/sysrq-trigger
+ }
+}
diff --git a/package/base-files/files/.svn/entries b/package/base-files/files/.svn/entries
new file mode 100644
index 0000000..cee7551
--- /dev/null
+++ b/package/base-files/files/.svn/entries
@@ -0,0 +1,43 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/base-files/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-14T18:43:58.957223Z
+36031
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+lib
+dir
+
+bin
+dir
+
+etc
+dir
+
+sbin
+dir
+
+rom
+dir
+
diff --git a/package/base-files/files/bin/.svn/entries b/package/base-files/files/bin/.svn/entries
new file mode 100644
index 0000000..ca70565
--- /dev/null
+++ b/package/base-files/files/bin/.svn/entries
@@ -0,0 +1,96 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/base-files/files/bin
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-12-23T22:18:43.337226Z
+34875
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+login.sh
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+a497a18c3018ef7fe70f088e32c890e7
+2011-11-17T09:40:06.613901Z
+29208
+jow
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+424
+
+ipcalc.sh
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+267ae3ac223b1717a0023773a742b892
+2012-12-23T22:18:43.337226Z
+34875
+jow
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1453
+
diff --git a/package/base-files/files/bin/.svn/prop-base/ipcalc.sh.svn-base b/package/base-files/files/bin/.svn/prop-base/ipcalc.sh.svn-base
new file mode 100644
index 0000000..03b5bfa
--- /dev/null
+++ b/package/base-files/files/bin/.svn/prop-base/ipcalc.sh.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:eol-style
+V 6
+native
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/base-files/files/bin/.svn/prop-base/login.sh.svn-base b/package/base-files/files/bin/.svn/prop-base/login.sh.svn-base
new file mode 100644
index 0000000..03b5bfa
--- /dev/null
+++ b/package/base-files/files/bin/.svn/prop-base/login.sh.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:eol-style
+V 6
+native
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/base-files/files/bin/.svn/text-base/ipcalc.sh.svn-base b/package/base-files/files/bin/.svn/text-base/ipcalc.sh.svn-base
new file mode 100644
index 0000000..7463d6b
--- /dev/null
+++ b/package/base-files/files/bin/.svn/text-base/ipcalc.sh.svn-base
@@ -0,0 +1,67 @@
+#!/bin/sh
+
+awk -f - $* <<EOF
+function bitcount(c) {
+ c=and(rshift(c, 1),0x55555555)+and(c,0x55555555)
+ c=and(rshift(c, 2),0x33333333)+and(c,0x33333333)
+ c=and(rshift(c, 4),0x0f0f0f0f)+and(c,0x0f0f0f0f)
+ c=and(rshift(c, 8),0x00ff00ff)+and(c,0x00ff00ff)
+ c=and(rshift(c,16),0x0000ffff)+and(c,0x0000ffff)
+ return c
+}
+
+function ip2int(ip) {
+ for (ret=0,n=split(ip,a,"\."),x=1;x<=n;x++) ret=or(lshift(ret,8),a[x])
+ return ret
+}
+
+function int2ip(ip,ret,x) {
+ ret=and(ip,255)
+ ip=rshift(ip,8)
+ for(;x<3;ret=and(ip,255)"."ret,ip=rshift(ip,8),x++);
+ return ret
+}
+
+function compl32(v) {
+ ret=xor(v, 0xffffffff)
+ return ret
+}
+
+BEGIN {
+ slpos=index(ARGV[1],"/")
+ if (slpos == 0) {
+ ipaddr=ip2int(ARGV[1])
+ netmask=ip2int(ARGV[2])
+ } else {
+ ipaddr=ip2int(substr(ARGV[1],0,slpos-1))
+ netmask=compl32(2**(32-int(substr(ARGV[1],slpos+1)))-1)
+ ARGV[4]=ARGV[3]
+ ARGV[3]=ARGV[2]
+ }
+
+ network=and(ipaddr,netmask)
+ broadcast=or(network,compl32(netmask))
+
+ start=or(network,and(ip2int(ARGV[3]),compl32(netmask)))
+ limit=network+1
+ if (start<limit) start=limit
+
+ end=start+ARGV[4]
+ limit=or(network,compl32(netmask))-1
+ if (end>limit) end=limit
+
+ print "IP="int2ip(ipaddr)
+ print "NETMASK="int2ip(netmask)
+ print "BROADCAST="int2ip(broadcast)
+ print "NETWORK="int2ip(network)
+ print "PREFIX="32-bitcount(compl32(netmask))
+
+ # range calculations:
+ # ipcalc <ip> <netmask> <start> <num>
+
+ if (ARGC > 3) {
+ print "START="int2ip(start)
+ print "END="int2ip(end)
+ }
+}
+EOF
diff --git a/package/base-files/files/bin/.svn/text-base/login.sh.svn-base b/package/base-files/files/bin/.svn/text-base/login.sh.svn-base
new file mode 100644
index 0000000..04b3fe2
--- /dev/null
+++ b/package/base-files/files/bin/.svn/text-base/login.sh.svn-base
@@ -0,0 +1,19 @@
+#!/bin/sh
+# Copyright (C) 2006-2011 OpenWrt.org
+
+if ( ! grep -qs '^root:[!x]\?:' /etc/shadow || \
+ ! grep -qs '^root:[!x]\?:' /etc/passwd ) && \
+ [ -z "$FAILSAFE" ]
+then
+ echo "Login failed."
+ exit 0
+else
+cat << EOF
+ === IMPORTANT ============================
+ Use 'passwd' to set your login password
+ this will disable telnet and enable SSH
+ ------------------------------------------
+EOF
+fi
+
+exec /bin/ash --login
diff --git a/package/base-files/files/bin/ipcalc.sh b/package/base-files/files/bin/ipcalc.sh
new file mode 100755
index 0000000..7463d6b
--- /dev/null
+++ b/package/base-files/files/bin/ipcalc.sh
@@ -0,0 +1,67 @@
+#!/bin/sh
+
+awk -f - $* <<EOF
+function bitcount(c) {
+ c=and(rshift(c, 1),0x55555555)+and(c,0x55555555)
+ c=and(rshift(c, 2),0x33333333)+and(c,0x33333333)
+ c=and(rshift(c, 4),0x0f0f0f0f)+and(c,0x0f0f0f0f)
+ c=and(rshift(c, 8),0x00ff00ff)+and(c,0x00ff00ff)
+ c=and(rshift(c,16),0x0000ffff)+and(c,0x0000ffff)
+ return c
+}
+
+function ip2int(ip) {
+ for (ret=0,n=split(ip,a,"\."),x=1;x<=n;x++) ret=or(lshift(ret,8),a[x])
+ return ret
+}
+
+function int2ip(ip,ret,x) {
+ ret=and(ip,255)
+ ip=rshift(ip,8)
+ for(;x<3;ret=and(ip,255)"."ret,ip=rshift(ip,8),x++);
+ return ret
+}
+
+function compl32(v) {
+ ret=xor(v, 0xffffffff)
+ return ret
+}
+
+BEGIN {
+ slpos=index(ARGV[1],"/")
+ if (slpos == 0) {
+ ipaddr=ip2int(ARGV[1])
+ netmask=ip2int(ARGV[2])
+ } else {
+ ipaddr=ip2int(substr(ARGV[1],0,slpos-1))
+ netmask=compl32(2**(32-int(substr(ARGV[1],slpos+1)))-1)
+ ARGV[4]=ARGV[3]
+ ARGV[3]=ARGV[2]
+ }
+
+ network=and(ipaddr,netmask)
+ broadcast=or(network,compl32(netmask))
+
+ start=or(network,and(ip2int(ARGV[3]),compl32(netmask)))
+ limit=network+1
+ if (start<limit) start=limit
+
+ end=start+ARGV[4]
+ limit=or(network,compl32(netmask))-1
+ if (end>limit) end=limit
+
+ print "IP="int2ip(ipaddr)
+ print "NETMASK="int2ip(netmask)
+ print "BROADCAST="int2ip(broadcast)
+ print "NETWORK="int2ip(network)
+ print "PREFIX="32-bitcount(compl32(netmask))
+
+ # range calculations:
+ # ipcalc <ip> <netmask> <start> <num>
+
+ if (ARGC > 3) {
+ print "START="int2ip(start)
+ print "END="int2ip(end)
+ }
+}
+EOF
diff --git a/package/base-files/files/bin/login.sh b/package/base-files/files/bin/login.sh
new file mode 100755
index 0000000..04b3fe2
--- /dev/null
+++ b/package/base-files/files/bin/login.sh
@@ -0,0 +1,19 @@
+#!/bin/sh
+# Copyright (C) 2006-2011 OpenWrt.org
+
+if ( ! grep -qs '^root:[!x]\?:' /etc/shadow || \
+ ! grep -qs '^root:[!x]\?:' /etc/passwd ) && \
+ [ -z "$FAILSAFE" ]
+then
+ echo "Login failed."
+ exit 0
+else
+cat << EOF
+ === IMPORTANT ============================
+ Use 'passwd' to set your login password
+ this will disable telnet and enable SSH
+ ------------------------------------------
+EOF
+fi
+
+exec /bin/ash --login
diff --git a/package/base-files/files/etc/.svn/entries b/package/base-files/files/etc/.svn/entries
new file mode 100644
index 0000000..2c24705
--- /dev/null
+++ b/package/base-files/files/etc/.svn/entries
@@ -0,0 +1,655 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/base-files/files/etc
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-13T18:11:19.892934Z
+36003
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+services
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+e30a9085944e0dd94ab277a512298256
+2012-03-18T19:41:57.122166Z
+30982
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3017
+
+protocols
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+e1b2c07d83ff5322a6353945a5c4b7e6
+2009-04-17T14:32:29.989894Z
+15245
+nico
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2478
+
+shadow
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+497b070fd6e487f137756e9bce95b636
+2012-06-05T17:48:41.928094Z
+32064
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+116
+
+init.d
+dir
+
+uci-defaults
+dir
+
+inittab
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+33da9049fd292d4f373c3df77a50c2dc
+2013-03-13T18:11:19.892934Z
+36003
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+101
+
+shells
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+725ba6f40dff0612f61ecd3f171bb3e1
+2009-04-17T14:32:29.989894Z
+15245
+nico
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+9
+
+rc.common
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+81ba79776061c56003b97406beeb576d
+2012-12-22T18:56:09.693743Z
+34866
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1936
+
+group
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+4a116d818b2f49e14939d581ec786de1
+2011-03-13T19:04:32.620549Z
+26136
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+123
+
+rc.local
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+6f8bfdaf36d3ec4aa9be6e96fa61d32b
+2009-09-11T21:35:03.611393Z
+17571
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+132
+
+openwrt_release
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+e65454ea1963a938321e039a13a1133a
+2012-04-12T17:31:16.941025Z
+31262
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+132
+
+profile
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+2729e95cc09e5f2a7ab9daae3d7ba857
+2012-08-08T15:37:34.343715Z
+33057
+florian
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+480
+
+hosts
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+0eea71665fb6890c06421fd13aa3f849
+2010-08-06T08:00:40.788334Z
+22508
+hcg
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+20
+
+passwd
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+8a31e6d3e2d67fc7b99f56055e9d802b
+2011-11-14T19:02:01.362297Z
+29130
+jow
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+190
+
+openwrt_version
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+94281d3c396683cba598dd2864d7f87f
+2012-04-12T17:31:16.941025Z
+31262
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3
+
+hotplug.d
+dir
+
+config
+dir
+
+banner
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+0990d6f5cdf9567cf2db81cec92011be
+2012-10-08T13:12:37.637363Z
+33666
+kaloz
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+629
+
+sysctl.conf
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+4db5363559bbed076aed3f7d176963e8
+2013-01-29T10:13:33.182424Z
+35368
+cyrus
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+838
+
+preinit
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+2fba1ae4a1dfa8fb1d2703c0ce56b84f
+2013-03-13T18:11:19.892934Z
+36003
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+901
+
+sysupgrade.conf
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+f91aef484370cefee501d64b5725c1d2
+2010-10-05T19:24:12.942023Z
+23258
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+128
+
+diag.sh
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+2db344b4341ef3a5b29ad05327a2039a
+2009-04-30T21:00:57.896294Z
+15527
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+68
+
+rc.button
+dir
+
diff --git a/package/base-files/files/etc/.svn/prop-base/banner.svn-base b/package/base-files/files/etc/.svn/prop-base/banner.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/base-files/files/etc/.svn/prop-base/banner.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/base-files/files/etc/.svn/prop-base/group.svn-base b/package/base-files/files/etc/.svn/prop-base/group.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/base-files/files/etc/.svn/prop-base/group.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/base-files/files/etc/.svn/prop-base/hosts.svn-base b/package/base-files/files/etc/.svn/prop-base/hosts.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/base-files/files/etc/.svn/prop-base/hosts.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/base-files/files/etc/.svn/prop-base/inittab.svn-base b/package/base-files/files/etc/.svn/prop-base/inittab.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/base-files/files/etc/.svn/prop-base/inittab.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/base-files/files/etc/.svn/prop-base/passwd.svn-base b/package/base-files/files/etc/.svn/prop-base/passwd.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/base-files/files/etc/.svn/prop-base/passwd.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/base-files/files/etc/.svn/prop-base/preinit.svn-base b/package/base-files/files/etc/.svn/prop-base/preinit.svn-base
new file mode 100644
index 0000000..03b5bfa
--- /dev/null
+++ b/package/base-files/files/etc/.svn/prop-base/preinit.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:eol-style
+V 6
+native
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/base-files/files/etc/.svn/prop-base/profile.svn-base b/package/base-files/files/etc/.svn/prop-base/profile.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/base-files/files/etc/.svn/prop-base/profile.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/base-files/files/etc/.svn/prop-base/protocols.svn-base b/package/base-files/files/etc/.svn/prop-base/protocols.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/base-files/files/etc/.svn/prop-base/protocols.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/base-files/files/etc/.svn/prop-base/rc.common.svn-base b/package/base-files/files/etc/.svn/prop-base/rc.common.svn-base
new file mode 100644
index 0000000..03b5bfa
--- /dev/null
+++ b/package/base-files/files/etc/.svn/prop-base/rc.common.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:eol-style
+V 6
+native
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/base-files/files/etc/.svn/prop-base/shells.svn-base b/package/base-files/files/etc/.svn/prop-base/shells.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/base-files/files/etc/.svn/prop-base/shells.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/base-files/files/etc/.svn/prop-base/sysctl.conf.svn-base b/package/base-files/files/etc/.svn/prop-base/sysctl.conf.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/base-files/files/etc/.svn/prop-base/sysctl.conf.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/base-files/files/etc/.svn/text-base/banner.svn-base b/package/base-files/files/etc/.svn/text-base/banner.svn-base
new file mode 100644
index 0000000..3eed7df
--- /dev/null
+++ b/package/base-files/files/etc/.svn/text-base/banner.svn-base
@@ -0,0 +1,13 @@
+ _______ ________ __
+ | |.-----.-----.-----.| | | |.----.| |_
+ | - || _ | -__| || | | || _|| _|
+ |_______|| __|_____|__|__||________||__| |____|
+ |__| W I R E L E S S F R E E D O M
+ -----------------------------------------------------
+ BARRIER BREAKER (%C, %R)
+ -----------------------------------------------------
+ * 1/2 oz Galliano Pour all ingredients into
+ * 4 oz cold Coffee an irish coffee mug filled
+ * 1 1/2 oz Dark Rum with crushed ice. Stir.
+ * 2 tsp. Creme de Cacao
+ -----------------------------------------------------
diff --git a/package/base-files/files/etc/.svn/text-base/diag.sh.svn-base b/package/base-files/files/etc/.svn/text-base/diag.sh.svn-base
new file mode 100644
index 0000000..8726a43
--- /dev/null
+++ b/package/base-files/files/etc/.svn/text-base/diag.sh.svn-base
@@ -0,0 +1,4 @@
+#!/bin/sh
+# Copyright (C) 2006-2009 OpenWrt.org
+
+set_state() { :; }
diff --git a/package/base-files/files/etc/.svn/text-base/group.svn-base b/package/base-files/files/etc/.svn/text-base/group.svn-base
new file mode 100644
index 0000000..d366851
--- /dev/null
+++ b/package/base-files/files/etc/.svn/text-base/group.svn-base
@@ -0,0 +1,10 @@
+root:x:0:
+daemon:x:1:
+adm:x:4:
+mail:x:8:
+audio:x:29:
+www-data:x:33:
+ftp:x:55:
+users:x:100:
+network:x:101:
+nogroup:x:65534:
diff --git a/package/base-files/files/etc/.svn/text-base/hosts.svn-base b/package/base-files/files/etc/.svn/text-base/hosts.svn-base
new file mode 100644
index 0000000..75721cd
--- /dev/null
+++ b/package/base-files/files/etc/.svn/text-base/hosts.svn-base
@@ -0,0 +1 @@
+127.0.0.1 localhost
diff --git a/package/base-files/files/etc/.svn/text-base/inittab.svn-base b/package/base-files/files/etc/.svn/text-base/inittab.svn-base
new file mode 100644
index 0000000..7817185
--- /dev/null
+++ b/package/base-files/files/etc/.svn/text-base/inittab.svn-base
@@ -0,0 +1,3 @@
+::sysinit:/etc/init.d/rcS S boot
+::shutdown:/etc/init.d/rcS K shutdown
+::askconsole:/bin/ash --login
diff --git a/package/base-files/files/etc/.svn/text-base/openwrt_release.svn-base b/package/base-files/files/etc/.svn/text-base/openwrt_release.svn-base
new file mode 100644
index 0000000..8ad2d9d
--- /dev/null
+++ b/package/base-files/files/etc/.svn/text-base/openwrt_release.svn-base
@@ -0,0 +1,6 @@
+DISTRIB_ID="%D"
+DISTRIB_RELEASE="%C"
+DISTRIB_REVISION="%R"
+DISTRIB_CODENAME="%n"
+DISTRIB_TARGET="%S"
+DISTRIB_DESCRIPTION="%D %N %V"
diff --git a/package/base-files/files/etc/.svn/text-base/openwrt_version.svn-base b/package/base-files/files/etc/.svn/text-base/openwrt_version.svn-base
new file mode 100644
index 0000000..4b14f59
--- /dev/null
+++ b/package/base-files/files/etc/.svn/text-base/openwrt_version.svn-base
@@ -0,0 +1 @@
+%V
diff --git a/package/base-files/files/etc/.svn/text-base/passwd.svn-base b/package/base-files/files/etc/.svn/text-base/passwd.svn-base
new file mode 100644
index 0000000..1d06a80
--- /dev/null
+++ b/package/base-files/files/etc/.svn/text-base/passwd.svn-base
@@ -0,0 +1,5 @@
+root:x:0:0:root:/root:/bin/ash
+daemon:*:1:1:daemon:/var:/bin/false
+ftp:*:55:55:ftp:/home/ftp:/bin/false
+network:*:101:101:network:/var:/bin/false
+nobody:*:65534:65534:nobody:/var:/bin/false
diff --git a/package/base-files/files/etc/.svn/text-base/preinit.svn-base b/package/base-files/files/etc/.svn/text-base/preinit.svn-base
new file mode 100644
index 0000000..ff26f96
--- /dev/null
+++ b/package/base-files/files/etc/.svn/text-base/preinit.svn-base
@@ -0,0 +1,45 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+[ -z "$PREINIT" ] && exec /sbin/init
+
+export PATH=/bin:/sbin:/usr/bin:/usr/sbin
+
+pi_ifname=
+pi_ip=192.168.1.1
+pi_broadcast=192.168.1.255
+pi_netmask=255.255.255.0
+
+fs_failsafe_ifname=
+fs_failsafe_ip=192.168.1.1
+fs_failsafe_broadcast=192.168.1.255
+fs_failsafe_netmask=255.255.255.0
+
+fs_failsafe_wait_timeout=2
+
+pi_suppress_stderr="y"
+pi_init_suppress_stderr="y"
+pi_init_path="/bin:/sbin:/usr/bin:/usr/sbin"
+pi_init_cmd="/sbin/init"
+
+. /lib/functions.sh
+
+boot_hook_init preinit_essential
+boot_hook_init preinit_main
+boot_hook_init failsafe
+boot_hook_init initramfs
+boot_hook_init preinit_mount_root
+
+for pi_source_file in /lib/preinit/*; do
+ . $pi_source_file
+done
+
+boot_run_hook preinit_essential
+
+pi_mount_skip_next=false
+pi_jffs2_mount_success=false
+pi_failsafe_net_message=false
+
+boot_run_hook preinit_main
+
diff --git a/package/base-files/files/etc/.svn/text-base/profile.svn-base b/package/base-files/files/etc/.svn/text-base/profile.svn-base
new file mode 100644
index 0000000..171adc1
--- /dev/null
+++ b/package/base-files/files/etc/.svn/text-base/profile.svn-base
@@ -0,0 +1,15 @@
+#!/bin/sh
+[ -f /etc/banner ] && cat /etc/banner
+
+export PATH=/bin:/sbin:/usr/bin:/usr/sbin
+export HOME=$(grep -e "^${USER:-root}:" /etc/passwd | cut -d ":" -f 6)
+export HOME=${HOME:-/root}
+export PS1='\u@\h:\w\$ '
+
+[ -x /bin/more ] || alias more=less
+[ -x /usr/bin/vim ] && alias vi=vim || alias vim=vi
+
+[ -z "$KSH_VERSION" -o \! -s /etc/mkshrc ] || . /etc/mkshrc
+
+[ -x /usr/bin/arp ] || arp() { cat /proc/net/arp; }
+[ -x /usr/bin/ldd ] || ldd() { LD_TRACE_LOADED_OBJECTS=1 $*; }
diff --git a/package/base-files/files/etc/.svn/text-base/protocols.svn-base b/package/base-files/files/etc/.svn/text-base/protocols.svn-base
new file mode 100644
index 0000000..53fecb6
--- /dev/null
+++ b/package/base-files/files/etc/.svn/text-base/protocols.svn-base
@@ -0,0 +1,56 @@
+# Internet (IP) protocols
+#
+# Updated from http://www.iana.org/assignments/protocol-numbers and other
+# sources.
+# New protocols will be added on request if they have been officially
+# assigned by IANA and are not historical.
+# If you need a huge list of used numbers please install the nmap package.
+
+ip 0 IP # internet protocol, pseudo protocol number
+#hopopt 0 HOPOPT # IPv6 Hop-by-Hop Option [RFC1883]
+icmp 1 ICMP # internet control message protocol
+igmp 2 IGMP # Internet Group Management
+ggp 3 GGP # gateway-gateway protocol
+ipencap 4 IP-ENCAP # IP encapsulated in IP (officially ``IP'')
+st 5 ST # ST datagram mode
+tcp 6 TCP # transmission control protocol
+egp 8 EGP # exterior gateway protocol
+igp 9 IGP # any private interior gateway (Cisco)
+pup 12 PUP # PARC universal packet protocol
+udp 17 UDP # user datagram protocol
+hmp 20 HMP # host monitoring protocol
+xns-idp 22 XNS-IDP # Xerox NS IDP
+rdp 27 RDP # "reliable datagram" protocol
+iso-tp4 29 ISO-TP4 # ISO Transport Protocol class 4 [RFC905]
+xtp 36 XTP # Xpress Transfer Protocol
+ddp 37 DDP # Datagram Delivery Protocol
+idpr-cmtp 38 IDPR-CMTP # IDPR Control Message Transport
+ipv6 41 IPv6 # Internet Protocol, version 6
+ipv6-route 43 IPv6-Route # Routing Header for IPv6
+ipv6-frag 44 IPv6-Frag # Fragment Header for IPv6
+idrp 45 IDRP # Inter-Domain Routing Protocol
+rsvp 46 RSVP # Reservation Protocol
+gre 47 GRE # General Routing Encapsulation
+esp 50 IPSEC-ESP # Encap Security Payload [RFC2046]
+ah 51 IPSEC-AH # Authentication Header [RFC2402]
+skip 57 SKIP # SKIP
+ipv6-icmp 58 IPv6-ICMP # ICMP for IPv6
+ipv6-nonxt 59 IPv6-NoNxt # No Next Header for IPv6
+ipv6-opts 60 IPv6-Opts # Destination Options for IPv6
+rspf 73 RSPF CPHB # Radio Shortest Path First (officially CPHB)
+vmtp 81 VMTP # Versatile Message Transport
+eigrp 88 EIGRP # Enhanced Interior Routing Protocol (Cisco)
+ospf 89 OSPFIGP # Open Shortest Path First IGP
+ax.25 93 AX.25 # AX.25 frames
+ipip 94 IPIP # IP-within-IP Encapsulation Protocol
+etherip 97 ETHERIP # Ethernet-within-IP Encapsulation [RFC3378]
+encap 98 ENCAP # Yet Another IP encapsulation [RFC1241]
+# 99 # any private encryption scheme
+pim 103 PIM # Protocol Independent Multicast
+ipcomp 108 IPCOMP # IP Payload Compression Protocol
+vrrp 112 VRRP # Virtual Router Redundancy Protocol
+l2tp 115 L2TP # Layer Two Tunneling Protocol [RFC2661]
+isis 124 ISIS # IS-IS over IPv4
+sctp 132 SCTP # Stream Control Transmission Protocol
+fc 133 FC # Fibre Channel
+
diff --git a/package/base-files/files/etc/.svn/text-base/rc.common.svn-base b/package/base-files/files/etc/.svn/text-base/rc.common.svn-base
new file mode 100644
index 0000000..78e2dd4
--- /dev/null
+++ b/package/base-files/files/etc/.svn/text-base/rc.common.svn-base
@@ -0,0 +1,116 @@
+#!/bin/sh
+# Copyright (C) 2006-2012 OpenWrt.org
+
+. $IPKG_INSTROOT/lib/functions.sh
+. $IPKG_INSTROOT/lib/functions/service.sh
+
+initscript=$1
+action=${2:-help}
+shift 2
+
+start() {
+ return 0
+}
+
+stop() {
+ return 0
+}
+
+reload() {
+ return 1
+}
+
+restart() {
+ trap '' TERM
+ stop "$@"
+ start "$@"
+}
+
+boot() {
+ start "$@"
+}
+
+shutdown() {
+ stop
+}
+
+disable() {
+ name="$(basename "${initscript}")"
+ rm -f "$IPKG_INSTROOT"/etc/rc.d/S??$name
+ rm -f "$IPKG_INSTROOT"/etc/rc.d/K??$name
+}
+
+enable() {
+ name="$(basename "${initscript}")"
+ disable
+ [ -n "$START" -o -n "$STOP" ] || {
+ echo "/etc/init.d/$name does not have a START or STOP value"
+ return 1
+ }
+ [ "$START" ] && ln -s "../init.d/$name" "$IPKG_INSTROOT/etc/rc.d/S${START}${name##S[0-9][0-9]}"
+ [ "$STOP" ] && ln -s "../init.d/$name" "$IPKG_INSTROOT/etc/rc.d/K${STOP}${name##K[0-9][0-9]}"
+}
+
+enabled() {
+ name="$(basename "${initscript}")"
+ [ -x "$IPKG_INSTROOT/etc/rc.d/S${START}${name##S[0-9][0-9]}" ]
+}
+
+depends() {
+ return 0
+}
+
+help() {
+ cat <<EOF
+Syntax: $initscript [command]
+
+Available commands:
+ start Start the service
+ stop Stop the service
+ restart Restart the service
+ reload Reload configuration files (or restart if that fails)
+ enable Enable service autostart
+ disable Disable service autostart
+$EXTRA_HELP
+EOF
+}
+
+# for procd
+start_service() {
+ return 0
+}
+
+stop_service() {
+ return 0
+}
+
+${INIT_TRACE:+set -x}
+
+. "$initscript"
+
+[ -n "$USE_PROCD" ] && {
+ . $IPKG_INSTROOT/lib/functions/procd.sh
+
+ rc_procd() {
+ procd_open_service "$(basename "$initscript")" "$initscript"
+ "$@"
+ procd_close_service
+ }
+
+ start() {
+ rc_procd start_service "$@"
+ }
+
+ stop() {
+ procd_kill "$(basename "$initscript")" "$1"
+ }
+
+ reload() {
+ start
+ }
+}
+
+ALL_COMMANDS="start stop reload restart boot shutdown enable disable enabled depends ${EXTRA_COMMANDS}"
+list_contains ALL_COMMANDS "$action" || action=help
+[ "$action" = "reload" ] && action='eval reload "$@" || restart "$@" && :'
+$action "$@"
diff --git a/package/base-files/files/etc/.svn/text-base/rc.local.svn-base b/package/base-files/files/etc/.svn/text-base/rc.local.svn-base
new file mode 100644
index 0000000..5639477
--- /dev/null
+++ b/package/base-files/files/etc/.svn/text-base/rc.local.svn-base
@@ -0,0 +1,4 @@
+# Put your custom commands here that should be executed once
+# the system init finished. By default this file does nothing.
+
+exit 0
diff --git a/package/base-files/files/etc/.svn/text-base/services.svn-base b/package/base-files/files/etc/.svn/text-base/services.svn-base
new file mode 100644
index 0000000..a12853e
--- /dev/null
+++ b/package/base-files/files/etc/.svn/text-base/services.svn-base
@@ -0,0 +1,171 @@
+echo 7/tcp
+echo 7/udp
+discard 9/tcp
+discard 9/udp
+daytime 13/tcp
+daytime 13/udp
+netstat 15/tcp
+chargen 19/tcp
+chargen 19/udp
+ftp-data 20/tcp
+ftp 21/tcp
+ssh 22/tcp
+ssh 22/udp
+telnet 23/tcp
+smtp 25/tcp
+time 37/tcp
+time 37/udp
+whois 43/tcp
+domain 53/tcp
+domain 53/udp
+bootps 67/tcp
+bootps 67/udp
+bootpc 68/tcp
+bootpc 68/udp
+tftp 69/udp
+finger 79/tcp
+www 80/tcp http
+kerberos 88/tcp kerberos5 krb5 kerberos-sec
+kerberos 88/udp kerberos5 krb5 kerberos-sec
+pop3 110/tcp
+pop3 110/udp
+sunrpc 111/tcp
+sunrpc 111/udp
+auth 113/tcp ident
+sftp 115/tcp
+nntp 119/tcp
+ntp 123/tcp
+ntp 123/udp
+netbios-ns 137/tcp
+netbios-ns 137/udp
+netbios-dgm 138/tcp
+netbios-dgm 138/udp
+netbios-ssn 139/tcp
+netbios-ssn 139/udp
+imap2 143/tcp imap
+imap2 143/udp imap
+snmp 161/tcp
+snmp 161/udp
+snmp-trap 162/tcp snmptrap
+snmp-trap 162/udp snmptrap
+xdmcp 177/tcp
+xdmcp 177/udp
+bgp 179/tcp
+bgp 179/udp
+imap3 220/tcp
+imap3 220/udp
+ldap 389/tcp
+ldap 389/udp
+https 443/tcp
+https 443/udp
+microsoft-ds 445/tcp
+microsoft-ds 445/udp
+isakmp 500/tcp
+isakmp 500/udp
+rtsp 554/tcp
+rtsp 554/udp
+ipp 631/tcp
+ipp 631/udp
+syslog 514/udp
+printer 515/tcp spooler
+dhcpv6-client 546/tcp
+dhcpv6-client 546/udp
+dhcpv6-server 547/tcp
+dhcpv6-server 547/udp
+afpovertcp 548/tcp
+afpovertcp 548/udp
+nntps 563/tcp snntp
+nntps 563/udp snntp
+ldaps 636/tcp
+ldaps 636/udp
+tinc 655/tcp
+tinc 655/udp
+rsync 873/tcp
+rsync 873/udp
+ftps-data 989/tcp
+ftps 990/tcp
+imaps 993/tcp
+imaps 993/udp
+ircs 994/tcp
+ircs 994/udp
+pop3s 995/tcp
+pop3s 995/udp
+socks 1080/tcp
+socks 1080/udp
+openvpn 1194/tcp
+openvpn 1194/udp
+l2f 1701/tcp l2tp
+l2f 1701/udp l2tp
+radius 1812/tcp
+radius 1812/udp
+radius-acct 1813/tcp radacct
+radius-acct 1813/udp radacct
+nfs 2049/tcp
+nfs 2049/udp
+dict 2628/tcp
+dict 2628/udp
+gpsd 2947/tcp
+gpsd 2947/udp
+icpv2 3130/tcp icp
+icpv2 3130/udp icp
+mysql 3306/tcp
+mysql 3306/udp
+nut 3493/tcp
+nut 3493/udp
+distcc 3632/tcp
+distcc 3632/udp
+daap 3689/tcp
+daap 3689/udp
+svn 3690/tcp subversion
+svn 3690/udp subversion
+epmd 4369/tcp
+epmd 4369/udp
+iax 4569/tcp
+iax 4569/udp
+mtn 4691/tcp
+mtn 4691/udp
+munin 4949/tcp
+sip 5060/tcp
+sip 5060/udp
+sip-tls 5061/tcp
+sip-tls 5061/udp
+xmpp-client 5222/tcp jabber-client
+xmpp-client 5222/udp jabber-client
+xmpp-server 5269/tcp jabber-server
+xmpp-server 5269/udp jabber-server
+mdns 5353/tcp
+mdns 5353/udp
+postgresql 5432/tcp postgres
+postgresql 5432/udp postgres
+x11 6000/tcp
+x11 6000/udp
+mysql-proxy 6446/tcp
+mysql-proxy 6446/udp
+bacula-dir 9101/tcp
+bacula-dir 9101/udp
+bacula-fd 9102/tcp
+bacula-fd 9102/udp
+bacula-sd 9103/tcp
+bacula-sd 9103/udp
+nbd 10809/tcp
+zabbix-agent 10050/tcp
+zabbix-agent 10050/udp
+zabbix-trapper 10051/tcp
+zabbix-trapper 10051/udp
+hkp 11371/tcp
+hkp 11371/udp
+ssmtp 465/tcp smtps
+spamd 783/tcp
+zebrasrv 2600/tcp
+zebra 2601/tcp
+ripd 2602/tcp
+ripngd 2603/tcp
+ospfd 2604/tcp
+bgpd 2605/tcp
+ospf6d 2606/tcp
+ospfapi 2607/tcp
+isisd 2608/tcp
+sane-port 6566/tcp sane saned
+ircd 6667/tcp
+git 9418/tcp
+
diff --git a/package/base-files/files/etc/.svn/text-base/shadow.svn-base b/package/base-files/files/etc/.svn/text-base/shadow.svn-base
new file mode 100644
index 0000000..e989890
--- /dev/null
+++ b/package/base-files/files/etc/.svn/text-base/shadow.svn-base
@@ -0,0 +1,5 @@
+root:x:0:0:99999:7:::
+daemon:*:0:0:99999:7:::
+ftp:*:0:0:99999:7:::
+network:*:0:0:99999:7:::
+nobody:*:0:0:99999:7:::
diff --git a/package/base-files/files/etc/.svn/text-base/shells.svn-base b/package/base-files/files/etc/.svn/text-base/shells.svn-base
new file mode 100644
index 0000000..006aa38
--- /dev/null
+++ b/package/base-files/files/etc/.svn/text-base/shells.svn-base
@@ -0,0 +1 @@
+/bin/ash
diff --git a/package/base-files/files/etc/.svn/text-base/sysctl.conf.svn-base b/package/base-files/files/etc/.svn/text-base/sysctl.conf.svn-base
new file mode 100644
index 0000000..890e77a
--- /dev/null
+++ b/package/base-files/files/etc/.svn/text-base/sysctl.conf.svn-base
@@ -0,0 +1,28 @@
+kernel.panic=3
+net.ipv4.conf.default.arp_ignore=1
+net.ipv4.conf.all.arp_ignore=1
+net.ipv4.ip_forward=1
+net.ipv4.icmp_echo_ignore_broadcasts=1
+net.ipv4.icmp_ignore_bogus_error_responses=1
+net.ipv4.tcp_ecn=0
+net.ipv4.tcp_fin_timeout=30
+net.ipv4.tcp_keepalive_time=120
+net.ipv4.tcp_syncookies=1
+net.ipv4.tcp_timestamps=1
+net.ipv4.tcp_sack=1
+net.ipv4.tcp_dsack=1
+
+net.ipv6.conf.default.forwarding=2
+net.ipv6.conf.all.forwarding=2
+
+net.netfilter.nf_conntrack_acct=1
+net.netfilter.nf_conntrack_checksum=0
+net.netfilter.nf_conntrack_max=16384
+net.netfilter.nf_conntrack_tcp_timeout_established=3600
+net.netfilter.nf_conntrack_udp_timeout=60
+net.netfilter.nf_conntrack_udp_timeout_stream=180
+
+# disable bridge firewalling by default
+net.bridge.bridge-nf-call-arptables=0
+net.bridge.bridge-nf-call-ip6tables=0
+net.bridge.bridge-nf-call-iptables=0
diff --git a/package/base-files/files/etc/.svn/text-base/sysupgrade.conf.svn-base b/package/base-files/files/etc/.svn/text-base/sysupgrade.conf.svn-base
new file mode 100644
index 0000000..e06fd5e
--- /dev/null
+++ b/package/base-files/files/etc/.svn/text-base/sysupgrade.conf.svn-base
@@ -0,0 +1,5 @@
+## This file contains files and directories that should
+## be preserved during an upgrade.
+
+# /etc/example.conf
+# /etc/openvpn/
diff --git a/package/base-files/files/etc/banner b/package/base-files/files/etc/banner
new file mode 100644
index 0000000..3eed7df
--- /dev/null
+++ b/package/base-files/files/etc/banner
@@ -0,0 +1,13 @@
+ _______ ________ __
+ | |.-----.-----.-----.| | | |.----.| |_
+ | - || _ | -__| || | | || _|| _|
+ |_______|| __|_____|__|__||________||__| |____|
+ |__| W I R E L E S S F R E E D O M
+ -----------------------------------------------------
+ BARRIER BREAKER (%C, %R)
+ -----------------------------------------------------
+ * 1/2 oz Galliano Pour all ingredients into
+ * 4 oz cold Coffee an irish coffee mug filled
+ * 1 1/2 oz Dark Rum with crushed ice. Stir.
+ * 2 tsp. Creme de Cacao
+ -----------------------------------------------------
diff --git a/package/base-files/files/etc/config/.svn/entries b/package/base-files/files/etc/config/.svn/entries
new file mode 100644
index 0000000..3648004
--- /dev/null
+++ b/package/base-files/files/etc/config/.svn/entries
@@ -0,0 +1,96 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/base-files/files/etc/config
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-04-20T15:05:38.003118Z
+31374
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+system
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+8195f0ae675038c41766a9ff46e6e22b
+2012-04-20T15:05:38.003118Z
+31374
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+251
+
+network
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+e93532a4bbf699aa1affa01ea827e42c
+2007-10-18T13:20:02.347557Z
+9345
+florian
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+291
+
diff --git a/package/base-files/files/etc/config/.svn/prop-base/network.svn-base b/package/base-files/files/etc/config/.svn/prop-base/network.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/base-files/files/etc/config/.svn/prop-base/network.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/base-files/files/etc/config/.svn/text-base/network.svn-base b/package/base-files/files/etc/config/.svn/text-base/network.svn-base
new file mode 100644
index 0000000..a35fd2e
--- /dev/null
+++ b/package/base-files/files/etc/config/.svn/text-base/network.svn-base
@@ -0,0 +1,14 @@
+# Copyright (C) 2006 OpenWrt.org
+
+config interface loopback
+ option ifname lo
+ option proto static
+ option ipaddr 127.0.0.1
+ option netmask 255.0.0.0
+
+config interface lan
+ option ifname eth0
+ option type bridge
+ option proto static
+ option ipaddr 192.168.1.1
+ option netmask 255.255.255.0
diff --git a/package/base-files/files/etc/config/.svn/text-base/system.svn-base b/package/base-files/files/etc/config/.svn/text-base/system.svn-base
new file mode 100644
index 0000000..d2124e4
--- /dev/null
+++ b/package/base-files/files/etc/config/.svn/text-base/system.svn-base
@@ -0,0 +1,10 @@
+config system
+ option hostname OpenWrt
+ option timezone UTC
+
+config timeserver ntp
+ list server 0.openwrt.pool.ntp.org
+ list server 1.openwrt.pool.ntp.org
+ list server 2.openwrt.pool.ntp.org
+ list server 3.openwrt.pool.ntp.org
+ option enable_server 0
diff --git a/package/base-files/files/etc/config/network b/package/base-files/files/etc/config/network
new file mode 100644
index 0000000..a35fd2e
--- /dev/null
+++ b/package/base-files/files/etc/config/network
@@ -0,0 +1,14 @@
+# Copyright (C) 2006 OpenWrt.org
+
+config interface loopback
+ option ifname lo
+ option proto static
+ option ipaddr 127.0.0.1
+ option netmask 255.0.0.0
+
+config interface lan
+ option ifname eth0
+ option type bridge
+ option proto static
+ option ipaddr 192.168.1.1
+ option netmask 255.255.255.0
diff --git a/package/base-files/files/etc/config/system b/package/base-files/files/etc/config/system
new file mode 100644
index 0000000..d2124e4
--- /dev/null
+++ b/package/base-files/files/etc/config/system
@@ -0,0 +1,10 @@
+config system
+ option hostname OpenWrt
+ option timezone UTC
+
+config timeserver ntp
+ list server 0.openwrt.pool.ntp.org
+ list server 1.openwrt.pool.ntp.org
+ list server 2.openwrt.pool.ntp.org
+ list server 3.openwrt.pool.ntp.org
+ option enable_server 0
diff --git a/package/base-files/files/etc/diag.sh b/package/base-files/files/etc/diag.sh
new file mode 100644
index 0000000..8726a43
--- /dev/null
+++ b/package/base-files/files/etc/diag.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+# Copyright (C) 2006-2009 OpenWrt.org
+
+set_state() { :; }
diff --git a/package/base-files/files/etc/group b/package/base-files/files/etc/group
new file mode 100644
index 0000000..d366851
--- /dev/null
+++ b/package/base-files/files/etc/group
@@ -0,0 +1,10 @@
+root:x:0:
+daemon:x:1:
+adm:x:4:
+mail:x:8:
+audio:x:29:
+www-data:x:33:
+ftp:x:55:
+users:x:100:
+network:x:101:
+nogroup:x:65534:
diff --git a/package/base-files/files/etc/hosts b/package/base-files/files/etc/hosts
new file mode 100644
index 0000000..75721cd
--- /dev/null
+++ b/package/base-files/files/etc/hosts
@@ -0,0 +1 @@
+127.0.0.1 localhost
diff --git a/package/base-files/files/etc/hotplug.d/.svn/entries b/package/base-files/files/etc/hotplug.d/.svn/entries
new file mode 100644
index 0000000..507f6d3
--- /dev/null
+++ b/package/base-files/files/etc/hotplug.d/.svn/entries
@@ -0,0 +1,37 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/base-files/files/etc/hotplug.d
+svn://svn.openwrt.org/openwrt
+
+
+
+2011-10-27T00:21:53.293432Z
+28612
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+iface
+dir
+
+ieee1394
+dir
+
+usb
+dir
+
diff --git a/package/base-files/files/etc/hotplug.d/ieee1394/.svn/entries b/package/base-files/files/etc/hotplug.d/ieee1394/.svn/entries
new file mode 100644
index 0000000..efb6d1a
--- /dev/null
+++ b/package/base-files/files/etc/hotplug.d/ieee1394/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/base-files/files/etc/hotplug.d/ieee1394
+svn://svn.openwrt.org/openwrt
+
+
+
+2009-01-30T20:48:42.263830Z
+14289
+matein4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+10-ieee1394
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+f461c4386f0170459c4fb27076b744ff
+2009-01-30T20:48:42.263830Z
+14289
+matein4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+129
+
diff --git a/package/base-files/files/etc/hotplug.d/ieee1394/.svn/text-base/10-ieee1394.svn-base b/package/base-files/files/etc/hotplug.d/ieee1394/.svn/text-base/10-ieee1394.svn-base
new file mode 100644
index 0000000..7e142a2
--- /dev/null
+++ b/package/base-files/files/etc/hotplug.d/ieee1394/.svn/text-base/10-ieee1394.svn-base
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+# Copyright (C) 2009 OpenWrt.org
+
+case "$ACTION" in
+ add)
+ # update LEDs
+ ;;
+ remove)
+ # update LEDs
+ ;;
+esac
+
diff --git a/package/base-files/files/etc/hotplug.d/ieee1394/10-ieee1394 b/package/base-files/files/etc/hotplug.d/ieee1394/10-ieee1394
new file mode 100644
index 0000000..7e142a2
--- /dev/null
+++ b/package/base-files/files/etc/hotplug.d/ieee1394/10-ieee1394
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+# Copyright (C) 2009 OpenWrt.org
+
+case "$ACTION" in
+ add)
+ # update LEDs
+ ;;
+ remove)
+ # update LEDs
+ ;;
+esac
+
diff --git a/package/base-files/files/etc/hotplug.d/iface/.svn/entries b/package/base-files/files/etc/hotplug.d/iface/.svn/entries
new file mode 100644
index 0000000..32bba92
--- /dev/null
+++ b/package/base-files/files/etc/hotplug.d/iface/.svn/entries
@@ -0,0 +1,28 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/base-files/files/etc/hotplug.d/iface
+svn://svn.openwrt.org/openwrt
+
+
+
+2011-10-27T00:21:53.293432Z
+28612
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
diff --git a/package/base-files/files/etc/hotplug.d/usb/.svn/entries b/package/base-files/files/etc/hotplug.d/usb/.svn/entries
new file mode 100644
index 0000000..9a5db67
--- /dev/null
+++ b/package/base-files/files/etc/hotplug.d/usb/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/base-files/files/etc/hotplug.d/usb
+svn://svn.openwrt.org/openwrt
+
+
+
+2009-01-30T20:48:42.263830Z
+14289
+matein4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+10-usb
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+f461c4386f0170459c4fb27076b744ff
+2009-01-30T20:48:42.263830Z
+14289
+matein4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+129
+
diff --git a/package/base-files/files/etc/hotplug.d/usb/.svn/text-base/10-usb.svn-base b/package/base-files/files/etc/hotplug.d/usb/.svn/text-base/10-usb.svn-base
new file mode 100644
index 0000000..7e142a2
--- /dev/null
+++ b/package/base-files/files/etc/hotplug.d/usb/.svn/text-base/10-usb.svn-base
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+# Copyright (C) 2009 OpenWrt.org
+
+case "$ACTION" in
+ add)
+ # update LEDs
+ ;;
+ remove)
+ # update LEDs
+ ;;
+esac
+
diff --git a/package/base-files/files/etc/hotplug.d/usb/10-usb b/package/base-files/files/etc/hotplug.d/usb/10-usb
new file mode 100644
index 0000000..7e142a2
--- /dev/null
+++ b/package/base-files/files/etc/hotplug.d/usb/10-usb
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+# Copyright (C) 2009 OpenWrt.org
+
+case "$ACTION" in
+ add)
+ # update LEDs
+ ;;
+ remove)
+ # update LEDs
+ ;;
+esac
+
diff --git a/package/base-files/files/etc/init.d/.svn/entries b/package/base-files/files/etc/init.d/.svn/entries
new file mode 100644
index 0000000..a74462f
--- /dev/null
+++ b/package/base-files/files/etc/init.d/.svn/entries
@@ -0,0 +1,300 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/base-files/files/etc/init.d
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-13T18:11:19.892934Z
+36003
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+sysctl
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+61ac774a7ba9ca439a844b8f8f5a87c6
+2010-01-29T02:17:11.561959Z
+19375
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+126
+
+boot
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+ecd43806409d103285be1083496374b9
+2013-03-13T18:11:19.892934Z
+36003
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2060
+
+led
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+c4a6d7e41ae14999903beed3a7020542
+2012-11-25T17:20:49.275876Z
+34380
+juhosg
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2015
+
+sysntpd
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+16886218f83e3a85155e6b113bddbae3
+2012-04-20T15:05:38.003118Z
+31374
+jow
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+586
+
+done
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+55ac6eecca0123b6831d99276b06e20e
+2009-09-11T21:35:03.611393Z
+17571
+jow
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+318
+
+rcS
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+06405a39a9ef1de751366f470d127f77
+2013-03-13T18:11:19.892934Z
+36003
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+183
+
+umount
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+941cc99f8ba618f1725aec2f27d6e42b
+2012-09-19T15:13:44.228696Z
+33477
+florian
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+102
+
+usb
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+12ca6574c481d2ce0483328532f691b3
+2012-12-19T16:07:46.450520Z
+34792
+mirko
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+160
+
diff --git a/package/base-files/files/etc/init.d/.svn/prop-base/boot.svn-base b/package/base-files/files/etc/init.d/.svn/prop-base/boot.svn-base
new file mode 100644
index 0000000..03b5bfa
--- /dev/null
+++ b/package/base-files/files/etc/init.d/.svn/prop-base/boot.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:eol-style
+V 6
+native
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/base-files/files/etc/init.d/.svn/prop-base/done.svn-base b/package/base-files/files/etc/init.d/.svn/prop-base/done.svn-base
new file mode 100644
index 0000000..869ac71
--- /dev/null
+++ b/package/base-files/files/etc/init.d/.svn/prop-base/done.svn-base
@@ -0,0 +1,5 @@
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/base-files/files/etc/init.d/.svn/prop-base/led.svn-base b/package/base-files/files/etc/init.d/.svn/prop-base/led.svn-base
new file mode 100644
index 0000000..869ac71
--- /dev/null
+++ b/package/base-files/files/etc/init.d/.svn/prop-base/led.svn-base
@@ -0,0 +1,5 @@
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/base-files/files/etc/init.d/.svn/prop-base/rcS.svn-base b/package/base-files/files/etc/init.d/.svn/prop-base/rcS.svn-base
new file mode 100644
index 0000000..03b5bfa
--- /dev/null
+++ b/package/base-files/files/etc/init.d/.svn/prop-base/rcS.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:eol-style
+V 6
+native
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/base-files/files/etc/init.d/.svn/prop-base/sysctl.svn-base b/package/base-files/files/etc/init.d/.svn/prop-base/sysctl.svn-base
new file mode 100644
index 0000000..869ac71
--- /dev/null
+++ b/package/base-files/files/etc/init.d/.svn/prop-base/sysctl.svn-base
@@ -0,0 +1,5 @@
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/base-files/files/etc/init.d/.svn/prop-base/sysntpd.svn-base b/package/base-files/files/etc/init.d/.svn/prop-base/sysntpd.svn-base
new file mode 100644
index 0000000..869ac71
--- /dev/null
+++ b/package/base-files/files/etc/init.d/.svn/prop-base/sysntpd.svn-base
@@ -0,0 +1,5 @@
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/base-files/files/etc/init.d/.svn/prop-base/umount.svn-base b/package/base-files/files/etc/init.d/.svn/prop-base/umount.svn-base
new file mode 100644
index 0000000..869ac71
--- /dev/null
+++ b/package/base-files/files/etc/init.d/.svn/prop-base/umount.svn-base
@@ -0,0 +1,5 @@
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/base-files/files/etc/init.d/.svn/prop-base/usb.svn-base b/package/base-files/files/etc/init.d/.svn/prop-base/usb.svn-base
new file mode 100644
index 0000000..03b5bfa
--- /dev/null
+++ b/package/base-files/files/etc/init.d/.svn/prop-base/usb.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:eol-style
+V 6
+native
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/base-files/files/etc/init.d/.svn/text-base/boot.svn-base b/package/base-files/files/etc/init.d/.svn/text-base/boot.svn-base
new file mode 100644
index 0000000..67db0d2
--- /dev/null
+++ b/package/base-files/files/etc/init.d/.svn/text-base/boot.svn-base
@@ -0,0 +1,78 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2006-2011 OpenWrt.org
+
+START=10
+STOP=98
+
+system_config() {
+ local cfg="$1"
+
+ local hostname conloglevel timezone
+
+ config_get hostname "$cfg" hostname 'OpenWrt'
+ echo "$hostname" > /proc/sys/kernel/hostname
+
+ config_get conloglevel "$cfg" conloglevel
+ config_get buffersize "$cfg" buffersize
+ [ -z "$conloglevel" -a -z "$buffersize" ] || dmesg ${conloglevel:+-n $conloglevel} ${buffersize:+-s $buffersize}
+
+ config_get timezone "$cfg" timezone 'UTC'
+ echo "$timezone" > /tmp/TZ
+
+ config_get zonename "$cfg" zonename
+ [ -n "$zonename" ] && [ -f "/usr/share/zoneinfo/$zonename" ] && ln -s "/usr/share/zoneinfo/$zonename" /tmp/localtime
+
+ # apply timezone to kernel
+ date -k
+}
+
+apply_uci_config() {
+ sh -c '. /lib/functions.sh; include /lib/config; uci_apply_defaults'
+}
+
+start() {
+ [ -f /proc/mounts ] || /sbin/mount_root
+ [ -f /proc/jffs2_bbc ] && echo "S" > /proc/jffs2_bbc
+ [ -f /proc/net/vlan/config ] && vconfig set_name_type DEV_PLUS_VID_NO_PAD
+
+ mkdir -p /var/run
+ mkdir -p /var/log
+ mkdir -p /var/lock
+ mkdir -p /var/state
+ mkdir -p /tmp/.uci
+ chmod 0700 /tmp/.uci
+ touch /var/log/wtmp
+ touch /var/log/lastlog
+ touch /tmp/resolv.conf.auto
+ ln -sf /tmp/resolv.conf.auto /tmp/resolv.conf
+ grep -q debugfs /proc/filesystems && mount -o noatime -t debugfs debugfs /sys/kernel/debug
+ [ "$FAILSAFE" = "true" ] && touch /tmp/.failsafe
+
+ load_modules /etc/modules.d/*
+
+ # allow wifi modules time to settle
+ sleep 1
+
+ /sbin/wifi detect > /tmp/wireless.tmp
+ [ -s /tmp/wireless.tmp ] && {
+ cat /tmp/wireless.tmp >> /etc/config/wireless
+ }
+ rm -f /tmp/wireless.tmp
+
+ apply_uci_config
+ config_load system
+ config_foreach system_config system
+
+ # create /dev/root if it doesn't exist
+ [ -e /dev/root -o -h /dev/root ] || {
+ rootdev=$(awk 'BEGIN { RS=" "; FS="="; } $1 == "root" { print $2 }' < /proc/cmdline)
+ [ -n "$rootdev" ] && ln -s "$rootdev" /dev/root
+ }
+
+ # early sysctl to avoid networking races
+ if [ -d /proc/sys/net/ipv6/conf ]; then
+ for i in /proc/sys/net/ipv6/conf/*/accept_ra; do
+ echo 0 > $i
+ done
+ fi
+}
diff --git a/package/base-files/files/etc/init.d/.svn/text-base/done.svn-base b/package/base-files/files/etc/init.d/.svn/text-base/done.svn-base
new file mode 100644
index 0000000..8278669
--- /dev/null
+++ b/package/base-files/files/etc/init.d/.svn/text-base/done.svn-base
@@ -0,0 +1,20 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2006 OpenWrt.org
+
+START=95
+boot() {
+ [ -d /tmp/root ] && {
+ lock /tmp/.switch2jffs
+ firstboot switch2jffs
+ lock -u /tmp/.switch2jffs
+ }
+
+ # process user commands
+ [ -f /etc/rc.local ] && {
+ sh /etc/rc.local
+ }
+
+ # set leds to normal state
+ . /etc/diag.sh
+ set_state done
+}
diff --git a/package/base-files/files/etc/init.d/.svn/text-base/led.svn-base b/package/base-files/files/etc/init.d/.svn/text-base/led.svn-base
new file mode 100644
index 0000000..729796b
--- /dev/null
+++ b/package/base-files/files/etc/init.d/.svn/text-base/led.svn-base
@@ -0,0 +1,92 @@
+#!/bin/sh /etc/rc.common
+# (C) 2008 openwrt.org
+
+START=96
+
+load_led() {
+ local name
+ local sysfs
+ local trigger
+ local dev
+ local mode
+ local default
+ local delayon
+ local delayoff
+ local interval
+
+ config_get sysfs $1 sysfs
+ config_get name $1 name "$sysfs"
+ config_get trigger $1 trigger "none"
+ config_get dev $1 dev
+ config_get mode $1 mode "link"
+ config_get_bool default $1 default "nil"
+ config_get delayon $1 delayon
+ config_get delayoff $1 delayoff
+ config_get interval $1 interval "50"
+ config_get port_state $1 port_state
+ config_get delay $1 delay "150"
+ config_get message $1 message ""
+
+ if [ "$trigger" = "rssi" ]; then
+ # handled by rssileds userspace process
+ return
+ fi
+
+ [ -e /sys/class/leds/${sysfs}/brightness ] && {
+ echo "setting up led ${name}"
+ [ "$default" != nil ] && {
+ [ $default -eq 1 ] &&
+ echo 1 >/sys/class/leds/${sysfs}/brightness
+ [ $default -eq 1 ] ||
+ echo 0 >/sys/class/leds/${sysfs}/brightness
+ }
+ echo $trigger > /sys/class/leds/${sysfs}/trigger
+ case "$trigger" in
+ "netdev")
+ [ -n "$dev" ] && {
+ echo $dev > /sys/class/leds/${sysfs}/device_name
+ echo $mode > /sys/class/leds/${sysfs}/mode
+ }
+ ;;
+
+ "timer")
+ [ -n "$delayon" ] && \
+ echo $delayon > /sys/class/leds/${sysfs}/delay_on
+ [ -n "$delayoff" ] && \
+ echo $delayoff > /sys/class/leds/${sysfs}/delay_off
+ ;;
+
+ "usbdev")
+ [ -n "$dev" ] && {
+ echo $dev > /sys/class/leds/${sysfs}/device_name
+ echo $interval > /sys/class/leds/${sysfs}/activity_interval
+ }
+ ;;
+
+ "port_state")
+ [ -n "$port_state" ] && \
+ echo $port_state > /sys/class/leds/${sysfs}/port_state
+ ;;
+
+ "morse")
+ echo $message > /sys/class/leds/${sysfs}/message
+ echo $delay > /sys/class/leds/${sysfs}/delay
+ ;;
+
+ switch[0-9]*)
+ local port_mask
+
+ config_get port_mask $1 port_mask
+ [ -n "$port_mask" ] && \
+ echo $port_mask > /sys/class/leds/${sysfs}/port_mask
+ ;;
+ esac
+ }
+}
+
+start() {
+ [ -e /sys/class/leds/ ] && {
+ config_load system
+ config_foreach load_led led
+ }
+}
diff --git a/package/base-files/files/etc/init.d/.svn/text-base/rcS.svn-base b/package/base-files/files/etc/init.d/.svn/text-base/rcS.svn-base
new file mode 100644
index 0000000..9599bbf
--- /dev/null
+++ b/package/base-files/files/etc/init.d/.svn/text-base/rcS.svn-base
@@ -0,0 +1,9 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+
+LOGGER="cat"
+[ -x /usr/bin/logger ] && LOGGER="logger -p 6 -t sysinit"
+
+for i in /etc/rc.d/$1*; do
+ [ -x $i ] && $i $2 2>&1
+done | $LOGGER
diff --git a/package/base-files/files/etc/init.d/.svn/text-base/sysctl.svn-base b/package/base-files/files/etc/init.d/.svn/text-base/sysctl.svn-base
new file mode 100644
index 0000000..2397790
--- /dev/null
+++ b/package/base-files/files/etc/init.d/.svn/text-base/sysctl.svn-base
@@ -0,0 +1,7 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2006 OpenWrt.org
+
+START=99
+start() {
+ [ -f /etc/sysctl.conf ] && sysctl -p -e >&-
+}
diff --git a/package/base-files/files/etc/init.d/.svn/text-base/sysntpd.svn-base b/package/base-files/files/etc/init.d/.svn/text-base/sysntpd.svn-base
new file mode 100644
index 0000000..bb42ef7
--- /dev/null
+++ b/package/base-files/files/etc/init.d/.svn/text-base/sysntpd.svn-base
@@ -0,0 +1,37 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2011 OpenWrt.org
+
+START=98
+
+SERVICE_DAEMONIZE=1
+SERVICE_WRITE_PID=1
+SERVICE_PID_FILE=/var/run/sysntpd.pid
+
+start() {
+ local peers
+ local args="-n"
+ local enable_server
+
+ config_load system
+ config_get peers ntp server
+ config_get_bool enable_server ntp enable_server 0
+
+ if [ $enable_server -ne 0 ]; then
+ append args "-l"
+ fi
+
+ if [ -n "$peers" ]; then
+ local peer
+ for peer in $peers; do
+ append args "-p $peer"
+ done
+ fi
+
+ if [ "$args" != "-n" ]; then
+ service_start /usr/sbin/ntpd $args
+ fi
+}
+
+stop() {
+ service_stop /usr/sbin/ntpd
+}
diff --git a/package/base-files/files/etc/init.d/.svn/text-base/umount.svn-base b/package/base-files/files/etc/init.d/.svn/text-base/umount.svn-base
new file mode 100644
index 0000000..5a750b9
--- /dev/null
+++ b/package/base-files/files/etc/init.d/.svn/text-base/umount.svn-base
@@ -0,0 +1,8 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2006 OpenWrt.org
+
+STOP=99
+stop() {
+ sync
+ umount -a -d -r
+}
diff --git a/package/base-files/files/etc/init.d/.svn/text-base/usb.svn-base b/package/base-files/files/etc/init.d/.svn/text-base/usb.svn-base
new file mode 100644
index 0000000..43cdfd9
--- /dev/null
+++ b/package/base-files/files/etc/init.d/.svn/text-base/usb.svn-base
@@ -0,0 +1,9 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2006 OpenWrt.org
+
+START=39
+start() {
+ [ -d /proc/bus/usb ] && {
+ mount -o noatime -t usbfs none /proc/bus/usb
+ }
+}
diff --git a/package/base-files/files/etc/init.d/boot b/package/base-files/files/etc/init.d/boot
new file mode 100755
index 0000000..67db0d2
--- /dev/null
+++ b/package/base-files/files/etc/init.d/boot
@@ -0,0 +1,78 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2006-2011 OpenWrt.org
+
+START=10
+STOP=98
+
+system_config() {
+ local cfg="$1"
+
+ local hostname conloglevel timezone
+
+ config_get hostname "$cfg" hostname 'OpenWrt'
+ echo "$hostname" > /proc/sys/kernel/hostname
+
+ config_get conloglevel "$cfg" conloglevel
+ config_get buffersize "$cfg" buffersize
+ [ -z "$conloglevel" -a -z "$buffersize" ] || dmesg ${conloglevel:+-n $conloglevel} ${buffersize:+-s $buffersize}
+
+ config_get timezone "$cfg" timezone 'UTC'
+ echo "$timezone" > /tmp/TZ
+
+ config_get zonename "$cfg" zonename
+ [ -n "$zonename" ] && [ -f "/usr/share/zoneinfo/$zonename" ] && ln -s "/usr/share/zoneinfo/$zonename" /tmp/localtime
+
+ # apply timezone to kernel
+ date -k
+}
+
+apply_uci_config() {
+ sh -c '. /lib/functions.sh; include /lib/config; uci_apply_defaults'
+}
+
+start() {
+ [ -f /proc/mounts ] || /sbin/mount_root
+ [ -f /proc/jffs2_bbc ] && echo "S" > /proc/jffs2_bbc
+ [ -f /proc/net/vlan/config ] && vconfig set_name_type DEV_PLUS_VID_NO_PAD
+
+ mkdir -p /var/run
+ mkdir -p /var/log
+ mkdir -p /var/lock
+ mkdir -p /var/state
+ mkdir -p /tmp/.uci
+ chmod 0700 /tmp/.uci
+ touch /var/log/wtmp
+ touch /var/log/lastlog
+ touch /tmp/resolv.conf.auto
+ ln -sf /tmp/resolv.conf.auto /tmp/resolv.conf
+ grep -q debugfs /proc/filesystems && mount -o noatime -t debugfs debugfs /sys/kernel/debug
+ [ "$FAILSAFE" = "true" ] && touch /tmp/.failsafe
+
+ load_modules /etc/modules.d/*
+
+ # allow wifi modules time to settle
+ sleep 1
+
+ /sbin/wifi detect > /tmp/wireless.tmp
+ [ -s /tmp/wireless.tmp ] && {
+ cat /tmp/wireless.tmp >> /etc/config/wireless
+ }
+ rm -f /tmp/wireless.tmp
+
+ apply_uci_config
+ config_load system
+ config_foreach system_config system
+
+ # create /dev/root if it doesn't exist
+ [ -e /dev/root -o -h /dev/root ] || {
+ rootdev=$(awk 'BEGIN { RS=" "; FS="="; } $1 == "root" { print $2 }' < /proc/cmdline)
+ [ -n "$rootdev" ] && ln -s "$rootdev" /dev/root
+ }
+
+ # early sysctl to avoid networking races
+ if [ -d /proc/sys/net/ipv6/conf ]; then
+ for i in /proc/sys/net/ipv6/conf/*/accept_ra; do
+ echo 0 > $i
+ done
+ fi
+}
diff --git a/package/base-files/files/etc/init.d/done b/package/base-files/files/etc/init.d/done
new file mode 100755
index 0000000..8278669
--- /dev/null
+++ b/package/base-files/files/etc/init.d/done
@@ -0,0 +1,20 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2006 OpenWrt.org
+
+START=95
+boot() {
+ [ -d /tmp/root ] && {
+ lock /tmp/.switch2jffs
+ firstboot switch2jffs
+ lock -u /tmp/.switch2jffs
+ }
+
+ # process user commands
+ [ -f /etc/rc.local ] && {
+ sh /etc/rc.local
+ }
+
+ # set leds to normal state
+ . /etc/diag.sh
+ set_state done
+}
diff --git a/package/base-files/files/etc/init.d/led b/package/base-files/files/etc/init.d/led
new file mode 100755
index 0000000..729796b
--- /dev/null
+++ b/package/base-files/files/etc/init.d/led
@@ -0,0 +1,92 @@
+#!/bin/sh /etc/rc.common
+# (C) 2008 openwrt.org
+
+START=96
+
+load_led() {
+ local name
+ local sysfs
+ local trigger
+ local dev
+ local mode
+ local default
+ local delayon
+ local delayoff
+ local interval
+
+ config_get sysfs $1 sysfs
+ config_get name $1 name "$sysfs"
+ config_get trigger $1 trigger "none"
+ config_get dev $1 dev
+ config_get mode $1 mode "link"
+ config_get_bool default $1 default "nil"
+ config_get delayon $1 delayon
+ config_get delayoff $1 delayoff
+ config_get interval $1 interval "50"
+ config_get port_state $1 port_state
+ config_get delay $1 delay "150"
+ config_get message $1 message ""
+
+ if [ "$trigger" = "rssi" ]; then
+ # handled by rssileds userspace process
+ return
+ fi
+
+ [ -e /sys/class/leds/${sysfs}/brightness ] && {
+ echo "setting up led ${name}"
+ [ "$default" != nil ] && {
+ [ $default -eq 1 ] &&
+ echo 1 >/sys/class/leds/${sysfs}/brightness
+ [ $default -eq 1 ] ||
+ echo 0 >/sys/class/leds/${sysfs}/brightness
+ }
+ echo $trigger > /sys/class/leds/${sysfs}/trigger
+ case "$trigger" in
+ "netdev")
+ [ -n "$dev" ] && {
+ echo $dev > /sys/class/leds/${sysfs}/device_name
+ echo $mode > /sys/class/leds/${sysfs}/mode
+ }
+ ;;
+
+ "timer")
+ [ -n "$delayon" ] && \
+ echo $delayon > /sys/class/leds/${sysfs}/delay_on
+ [ -n "$delayoff" ] && \
+ echo $delayoff > /sys/class/leds/${sysfs}/delay_off
+ ;;
+
+ "usbdev")
+ [ -n "$dev" ] && {
+ echo $dev > /sys/class/leds/${sysfs}/device_name
+ echo $interval > /sys/class/leds/${sysfs}/activity_interval
+ }
+ ;;
+
+ "port_state")
+ [ -n "$port_state" ] && \
+ echo $port_state > /sys/class/leds/${sysfs}/port_state
+ ;;
+
+ "morse")
+ echo $message > /sys/class/leds/${sysfs}/message
+ echo $delay > /sys/class/leds/${sysfs}/delay
+ ;;
+
+ switch[0-9]*)
+ local port_mask
+
+ config_get port_mask $1 port_mask
+ [ -n "$port_mask" ] && \
+ echo $port_mask > /sys/class/leds/${sysfs}/port_mask
+ ;;
+ esac
+ }
+}
+
+start() {
+ [ -e /sys/class/leds/ ] && {
+ config_load system
+ config_foreach load_led led
+ }
+}
diff --git a/package/base-files/files/etc/init.d/rcS b/package/base-files/files/etc/init.d/rcS
new file mode 100755
index 0000000..9599bbf
--- /dev/null
+++ b/package/base-files/files/etc/init.d/rcS
@@ -0,0 +1,9 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+
+LOGGER="cat"
+[ -x /usr/bin/logger ] && LOGGER="logger -p 6 -t sysinit"
+
+for i in /etc/rc.d/$1*; do
+ [ -x $i ] && $i $2 2>&1
+done | $LOGGER
diff --git a/package/base-files/files/etc/init.d/sysctl b/package/base-files/files/etc/init.d/sysctl
new file mode 100755
index 0000000..2397790
--- /dev/null
+++ b/package/base-files/files/etc/init.d/sysctl
@@ -0,0 +1,7 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2006 OpenWrt.org
+
+START=99
+start() {
+ [ -f /etc/sysctl.conf ] && sysctl -p -e >&-
+}
diff --git a/package/base-files/files/etc/init.d/sysntpd b/package/base-files/files/etc/init.d/sysntpd
new file mode 100755
index 0000000..bb42ef7
--- /dev/null
+++ b/package/base-files/files/etc/init.d/sysntpd
@@ -0,0 +1,37 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2011 OpenWrt.org
+
+START=98
+
+SERVICE_DAEMONIZE=1
+SERVICE_WRITE_PID=1
+SERVICE_PID_FILE=/var/run/sysntpd.pid
+
+start() {
+ local peers
+ local args="-n"
+ local enable_server
+
+ config_load system
+ config_get peers ntp server
+ config_get_bool enable_server ntp enable_server 0
+
+ if [ $enable_server -ne 0 ]; then
+ append args "-l"
+ fi
+
+ if [ -n "$peers" ]; then
+ local peer
+ for peer in $peers; do
+ append args "-p $peer"
+ done
+ fi
+
+ if [ "$args" != "-n" ]; then
+ service_start /usr/sbin/ntpd $args
+ fi
+}
+
+stop() {
+ service_stop /usr/sbin/ntpd
+}
diff --git a/package/base-files/files/etc/init.d/umount b/package/base-files/files/etc/init.d/umount
new file mode 100755
index 0000000..5a750b9
--- /dev/null
+++ b/package/base-files/files/etc/init.d/umount
@@ -0,0 +1,8 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2006 OpenWrt.org
+
+STOP=99
+stop() {
+ sync
+ umount -a -d -r
+}
diff --git a/package/base-files/files/etc/init.d/usb b/package/base-files/files/etc/init.d/usb
new file mode 100755
index 0000000..43cdfd9
--- /dev/null
+++ b/package/base-files/files/etc/init.d/usb
@@ -0,0 +1,9 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2006 OpenWrt.org
+
+START=39
+start() {
+ [ -d /proc/bus/usb ] && {
+ mount -o noatime -t usbfs none /proc/bus/usb
+ }
+}
diff --git a/package/base-files/files/etc/inittab b/package/base-files/files/etc/inittab
new file mode 100644
index 0000000..7817185
--- /dev/null
+++ b/package/base-files/files/etc/inittab
@@ -0,0 +1,3 @@
+::sysinit:/etc/init.d/rcS S boot
+::shutdown:/etc/init.d/rcS K shutdown
+::askconsole:/bin/ash --login
diff --git a/package/base-files/files/etc/openwrt_release b/package/base-files/files/etc/openwrt_release
new file mode 100644
index 0000000..8ad2d9d
--- /dev/null
+++ b/package/base-files/files/etc/openwrt_release
@@ -0,0 +1,6 @@
+DISTRIB_ID="%D"
+DISTRIB_RELEASE="%C"
+DISTRIB_REVISION="%R"
+DISTRIB_CODENAME="%n"
+DISTRIB_TARGET="%S"
+DISTRIB_DESCRIPTION="%D %N %V"
diff --git a/package/base-files/files/etc/openwrt_version b/package/base-files/files/etc/openwrt_version
new file mode 100644
index 0000000..4b14f59
--- /dev/null
+++ b/package/base-files/files/etc/openwrt_version
@@ -0,0 +1 @@
+%V
diff --git a/package/base-files/files/etc/passwd b/package/base-files/files/etc/passwd
new file mode 100644
index 0000000..1d06a80
--- /dev/null
+++ b/package/base-files/files/etc/passwd
@@ -0,0 +1,5 @@
+root:x:0:0:root:/root:/bin/ash
+daemon:*:1:1:daemon:/var:/bin/false
+ftp:*:55:55:ftp:/home/ftp:/bin/false
+network:*:101:101:network:/var:/bin/false
+nobody:*:65534:65534:nobody:/var:/bin/false
diff --git a/package/base-files/files/etc/preinit b/package/base-files/files/etc/preinit
new file mode 100755
index 0000000..ff26f96
--- /dev/null
+++ b/package/base-files/files/etc/preinit
@@ -0,0 +1,45 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+[ -z "$PREINIT" ] && exec /sbin/init
+
+export PATH=/bin:/sbin:/usr/bin:/usr/sbin
+
+pi_ifname=
+pi_ip=192.168.1.1
+pi_broadcast=192.168.1.255
+pi_netmask=255.255.255.0
+
+fs_failsafe_ifname=
+fs_failsafe_ip=192.168.1.1
+fs_failsafe_broadcast=192.168.1.255
+fs_failsafe_netmask=255.255.255.0
+
+fs_failsafe_wait_timeout=2
+
+pi_suppress_stderr="y"
+pi_init_suppress_stderr="y"
+pi_init_path="/bin:/sbin:/usr/bin:/usr/sbin"
+pi_init_cmd="/sbin/init"
+
+. /lib/functions.sh
+
+boot_hook_init preinit_essential
+boot_hook_init preinit_main
+boot_hook_init failsafe
+boot_hook_init initramfs
+boot_hook_init preinit_mount_root
+
+for pi_source_file in /lib/preinit/*; do
+ . $pi_source_file
+done
+
+boot_run_hook preinit_essential
+
+pi_mount_skip_next=false
+pi_jffs2_mount_success=false
+pi_failsafe_net_message=false
+
+boot_run_hook preinit_main
+
diff --git a/package/base-files/files/etc/profile b/package/base-files/files/etc/profile
new file mode 100644
index 0000000..171adc1
--- /dev/null
+++ b/package/base-files/files/etc/profile
@@ -0,0 +1,15 @@
+#!/bin/sh
+[ -f /etc/banner ] && cat /etc/banner
+
+export PATH=/bin:/sbin:/usr/bin:/usr/sbin
+export HOME=$(grep -e "^${USER:-root}:" /etc/passwd | cut -d ":" -f 6)
+export HOME=${HOME:-/root}
+export PS1='\u@\h:\w\$ '
+
+[ -x /bin/more ] || alias more=less
+[ -x /usr/bin/vim ] && alias vi=vim || alias vim=vi
+
+[ -z "$KSH_VERSION" -o \! -s /etc/mkshrc ] || . /etc/mkshrc
+
+[ -x /usr/bin/arp ] || arp() { cat /proc/net/arp; }
+[ -x /usr/bin/ldd ] || ldd() { LD_TRACE_LOADED_OBJECTS=1 $*; }
diff --git a/package/base-files/files/etc/protocols b/package/base-files/files/etc/protocols
new file mode 100644
index 0000000..53fecb6
--- /dev/null
+++ b/package/base-files/files/etc/protocols
@@ -0,0 +1,56 @@
+# Internet (IP) protocols
+#
+# Updated from http://www.iana.org/assignments/protocol-numbers and other
+# sources.
+# New protocols will be added on request if they have been officially
+# assigned by IANA and are not historical.
+# If you need a huge list of used numbers please install the nmap package.
+
+ip 0 IP # internet protocol, pseudo protocol number
+#hopopt 0 HOPOPT # IPv6 Hop-by-Hop Option [RFC1883]
+icmp 1 ICMP # internet control message protocol
+igmp 2 IGMP # Internet Group Management
+ggp 3 GGP # gateway-gateway protocol
+ipencap 4 IP-ENCAP # IP encapsulated in IP (officially ``IP'')
+st 5 ST # ST datagram mode
+tcp 6 TCP # transmission control protocol
+egp 8 EGP # exterior gateway protocol
+igp 9 IGP # any private interior gateway (Cisco)
+pup 12 PUP # PARC universal packet protocol
+udp 17 UDP # user datagram protocol
+hmp 20 HMP # host monitoring protocol
+xns-idp 22 XNS-IDP # Xerox NS IDP
+rdp 27 RDP # "reliable datagram" protocol
+iso-tp4 29 ISO-TP4 # ISO Transport Protocol class 4 [RFC905]
+xtp 36 XTP # Xpress Transfer Protocol
+ddp 37 DDP # Datagram Delivery Protocol
+idpr-cmtp 38 IDPR-CMTP # IDPR Control Message Transport
+ipv6 41 IPv6 # Internet Protocol, version 6
+ipv6-route 43 IPv6-Route # Routing Header for IPv6
+ipv6-frag 44 IPv6-Frag # Fragment Header for IPv6
+idrp 45 IDRP # Inter-Domain Routing Protocol
+rsvp 46 RSVP # Reservation Protocol
+gre 47 GRE # General Routing Encapsulation
+esp 50 IPSEC-ESP # Encap Security Payload [RFC2046]
+ah 51 IPSEC-AH # Authentication Header [RFC2402]
+skip 57 SKIP # SKIP
+ipv6-icmp 58 IPv6-ICMP # ICMP for IPv6
+ipv6-nonxt 59 IPv6-NoNxt # No Next Header for IPv6
+ipv6-opts 60 IPv6-Opts # Destination Options for IPv6
+rspf 73 RSPF CPHB # Radio Shortest Path First (officially CPHB)
+vmtp 81 VMTP # Versatile Message Transport
+eigrp 88 EIGRP # Enhanced Interior Routing Protocol (Cisco)
+ospf 89 OSPFIGP # Open Shortest Path First IGP
+ax.25 93 AX.25 # AX.25 frames
+ipip 94 IPIP # IP-within-IP Encapsulation Protocol
+etherip 97 ETHERIP # Ethernet-within-IP Encapsulation [RFC3378]
+encap 98 ENCAP # Yet Another IP encapsulation [RFC1241]
+# 99 # any private encryption scheme
+pim 103 PIM # Protocol Independent Multicast
+ipcomp 108 IPCOMP # IP Payload Compression Protocol
+vrrp 112 VRRP # Virtual Router Redundancy Protocol
+l2tp 115 L2TP # Layer Two Tunneling Protocol [RFC2661]
+isis 124 ISIS # IS-IS over IPv4
+sctp 132 SCTP # Stream Control Transmission Protocol
+fc 133 FC # Fibre Channel
+
diff --git a/package/base-files/files/etc/rc.button/.svn/entries b/package/base-files/files/etc/rc.button/.svn/entries
new file mode 100644
index 0000000..5af1bb6
--- /dev/null
+++ b/package/base-files/files/etc/rc.button/.svn/entries
@@ -0,0 +1,130 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/base-files/files/etc/rc.button
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-13T18:11:19.892934Z
+36003
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+reset
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+b003e4351c706679936b223b8c0bf036
+2013-03-13T18:11:19.892934Z
+36003
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+277
+
+rfkill
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+581e09365e2fd825aae743ab5e811513
+2013-03-13T18:11:19.892934Z
+36003
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+413
+
+failsafe
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+073ed7a5c2da53d10353ba67f2babdc5
+2013-03-13T18:11:19.892934Z
+36003
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+37
+
diff --git a/package/base-files/files/etc/rc.button/.svn/prop-base/failsafe.svn-base b/package/base-files/files/etc/rc.button/.svn/prop-base/failsafe.svn-base
new file mode 100644
index 0000000..869ac71
--- /dev/null
+++ b/package/base-files/files/etc/rc.button/.svn/prop-base/failsafe.svn-base
@@ -0,0 +1,5 @@
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/base-files/files/etc/rc.button/.svn/prop-base/reset.svn-base b/package/base-files/files/etc/rc.button/.svn/prop-base/reset.svn-base
new file mode 100644
index 0000000..869ac71
--- /dev/null
+++ b/package/base-files/files/etc/rc.button/.svn/prop-base/reset.svn-base
@@ -0,0 +1,5 @@
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/base-files/files/etc/rc.button/.svn/prop-base/rfkill.svn-base b/package/base-files/files/etc/rc.button/.svn/prop-base/rfkill.svn-base
new file mode 100644
index 0000000..869ac71
--- /dev/null
+++ b/package/base-files/files/etc/rc.button/.svn/prop-base/rfkill.svn-base
@@ -0,0 +1,5 @@
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/base-files/files/etc/rc.button/.svn/text-base/failsafe.svn-base b/package/base-files/files/etc/rc.button/.svn/text-base/failsafe.svn-base
new file mode 100644
index 0000000..dcdf7de
--- /dev/null
+++ b/package/base-files/files/etc/rc.button/.svn/text-base/failsafe.svn-base
@@ -0,0 +1,2 @@
+#!/bin/sh
+touch /tmp/failsafe_button
diff --git a/package/base-files/files/etc/rc.button/.svn/text-base/reset.svn-base b/package/base-files/files/etc/rc.button/.svn/text-base/reset.svn-base
new file mode 100644
index 0000000..763994d
--- /dev/null
+++ b/package/base-files/files/etc/rc.button/.svn/text-base/reset.svn-base
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+[ "${ACTION}" = "released" ] || exit 0
+
+. /lib/functions.sh
+
+logger "$BUTTON pressed for $SEEN seconds"
+
+if [ "$SEEN" -lt 1 ]
+then
+ echo "REBOOT" > /dev/console
+ sync
+ reboot
+elif [ "$SEEN" -gt 5 ]
+then
+ echo "FACTORY RESET" > /dev/console
+ firstboot && reboot &
+fi
diff --git a/package/base-files/files/etc/rc.button/.svn/text-base/rfkill.svn-base b/package/base-files/files/etc/rc.button/.svn/text-base/rfkill.svn-base
new file mode 100644
index 0000000..7a8cfe9
--- /dev/null
+++ b/package/base-files/files/etc/rc.button/.svn/text-base/rfkill.svn-base
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+[ "${ACTION}" = "released" ] || exit 0
+
+. /lib/functions.sh
+
+local rfkill_state=0
+
+wifi_rfkill_set() {
+ uci set wireless.$1.disabled=$rfkill_state
+}
+
+wifi_rfkill_check() {
+ local disabled
+ config_get disabled $1 disabled
+ [ "$disabled" = "1" ] || rfkill_state=1
+}
+
+config_load wireless
+config_foreach wifi_rfkill_check wifi-device
+config_foreach wifi_rfkill_set wifi-device
+uci commit wireless
+wifi up
diff --git a/package/base-files/files/etc/rc.button/failsafe b/package/base-files/files/etc/rc.button/failsafe
new file mode 100755
index 0000000..dcdf7de
--- /dev/null
+++ b/package/base-files/files/etc/rc.button/failsafe
@@ -0,0 +1,2 @@
+#!/bin/sh
+touch /tmp/failsafe_button
diff --git a/package/base-files/files/etc/rc.button/reset b/package/base-files/files/etc/rc.button/reset
new file mode 100755
index 0000000..763994d
--- /dev/null
+++ b/package/base-files/files/etc/rc.button/reset
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+[ "${ACTION}" = "released" ] || exit 0
+
+. /lib/functions.sh
+
+logger "$BUTTON pressed for $SEEN seconds"
+
+if [ "$SEEN" -lt 1 ]
+then
+ echo "REBOOT" > /dev/console
+ sync
+ reboot
+elif [ "$SEEN" -gt 5 ]
+then
+ echo "FACTORY RESET" > /dev/console
+ firstboot && reboot &
+fi
diff --git a/package/base-files/files/etc/rc.button/rfkill b/package/base-files/files/etc/rc.button/rfkill
new file mode 100755
index 0000000..7a8cfe9
--- /dev/null
+++ b/package/base-files/files/etc/rc.button/rfkill
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+[ "${ACTION}" = "released" ] || exit 0
+
+. /lib/functions.sh
+
+local rfkill_state=0
+
+wifi_rfkill_set() {
+ uci set wireless.$1.disabled=$rfkill_state
+}
+
+wifi_rfkill_check() {
+ local disabled
+ config_get disabled $1 disabled
+ [ "$disabled" = "1" ] || rfkill_state=1
+}
+
+config_load wireless
+config_foreach wifi_rfkill_check wifi-device
+config_foreach wifi_rfkill_set wifi-device
+uci commit wireless
+wifi up
diff --git a/package/base-files/files/etc/rc.common b/package/base-files/files/etc/rc.common
new file mode 100755
index 0000000..78e2dd4
--- /dev/null
+++ b/package/base-files/files/etc/rc.common
@@ -0,0 +1,116 @@
+#!/bin/sh
+# Copyright (C) 2006-2012 OpenWrt.org
+
+. $IPKG_INSTROOT/lib/functions.sh
+. $IPKG_INSTROOT/lib/functions/service.sh
+
+initscript=$1
+action=${2:-help}
+shift 2
+
+start() {
+ return 0
+}
+
+stop() {
+ return 0
+}
+
+reload() {
+ return 1
+}
+
+restart() {
+ trap '' TERM
+ stop "$@"
+ start "$@"
+}
+
+boot() {
+ start "$@"
+}
+
+shutdown() {
+ stop
+}
+
+disable() {
+ name="$(basename "${initscript}")"
+ rm -f "$IPKG_INSTROOT"/etc/rc.d/S??$name
+ rm -f "$IPKG_INSTROOT"/etc/rc.d/K??$name
+}
+
+enable() {
+ name="$(basename "${initscript}")"
+ disable
+ [ -n "$START" -o -n "$STOP" ] || {
+ echo "/etc/init.d/$name does not have a START or STOP value"
+ return 1
+ }
+ [ "$START" ] && ln -s "../init.d/$name" "$IPKG_INSTROOT/etc/rc.d/S${START}${name##S[0-9][0-9]}"
+ [ "$STOP" ] && ln -s "../init.d/$name" "$IPKG_INSTROOT/etc/rc.d/K${STOP}${name##K[0-9][0-9]}"
+}
+
+enabled() {
+ name="$(basename "${initscript}")"
+ [ -x "$IPKG_INSTROOT/etc/rc.d/S${START}${name##S[0-9][0-9]}" ]
+}
+
+depends() {
+ return 0
+}
+
+help() {
+ cat <<EOF
+Syntax: $initscript [command]
+
+Available commands:
+ start Start the service
+ stop Stop the service
+ restart Restart the service
+ reload Reload configuration files (or restart if that fails)
+ enable Enable service autostart
+ disable Disable service autostart
+$EXTRA_HELP
+EOF
+}
+
+# for procd
+start_service() {
+ return 0
+}
+
+stop_service() {
+ return 0
+}
+
+${INIT_TRACE:+set -x}
+
+. "$initscript"
+
+[ -n "$USE_PROCD" ] && {
+ . $IPKG_INSTROOT/lib/functions/procd.sh
+
+ rc_procd() {
+ procd_open_service "$(basename "$initscript")" "$initscript"
+ "$@"
+ procd_close_service
+ }
+
+ start() {
+ rc_procd start_service "$@"
+ }
+
+ stop() {
+ procd_kill "$(basename "$initscript")" "$1"
+ }
+
+ reload() {
+ start
+ }
+}
+
+ALL_COMMANDS="start stop reload restart boot shutdown enable disable enabled depends ${EXTRA_COMMANDS}"
+list_contains ALL_COMMANDS "$action" || action=help
+[ "$action" = "reload" ] && action='eval reload "$@" || restart "$@" && :'
+$action "$@"
diff --git a/package/base-files/files/etc/rc.local b/package/base-files/files/etc/rc.local
new file mode 100644
index 0000000..5639477
--- /dev/null
+++ b/package/base-files/files/etc/rc.local
@@ -0,0 +1,4 @@
+# Put your custom commands here that should be executed once
+# the system init finished. By default this file does nothing.
+
+exit 0
diff --git a/package/base-files/files/etc/services b/package/base-files/files/etc/services
new file mode 100644
index 0000000..a12853e
--- /dev/null
+++ b/package/base-files/files/etc/services
@@ -0,0 +1,171 @@
+echo 7/tcp
+echo 7/udp
+discard 9/tcp
+discard 9/udp
+daytime 13/tcp
+daytime 13/udp
+netstat 15/tcp
+chargen 19/tcp
+chargen 19/udp
+ftp-data 20/tcp
+ftp 21/tcp
+ssh 22/tcp
+ssh 22/udp
+telnet 23/tcp
+smtp 25/tcp
+time 37/tcp
+time 37/udp
+whois 43/tcp
+domain 53/tcp
+domain 53/udp
+bootps 67/tcp
+bootps 67/udp
+bootpc 68/tcp
+bootpc 68/udp
+tftp 69/udp
+finger 79/tcp
+www 80/tcp http
+kerberos 88/tcp kerberos5 krb5 kerberos-sec
+kerberos 88/udp kerberos5 krb5 kerberos-sec
+pop3 110/tcp
+pop3 110/udp
+sunrpc 111/tcp
+sunrpc 111/udp
+auth 113/tcp ident
+sftp 115/tcp
+nntp 119/tcp
+ntp 123/tcp
+ntp 123/udp
+netbios-ns 137/tcp
+netbios-ns 137/udp
+netbios-dgm 138/tcp
+netbios-dgm 138/udp
+netbios-ssn 139/tcp
+netbios-ssn 139/udp
+imap2 143/tcp imap
+imap2 143/udp imap
+snmp 161/tcp
+snmp 161/udp
+snmp-trap 162/tcp snmptrap
+snmp-trap 162/udp snmptrap
+xdmcp 177/tcp
+xdmcp 177/udp
+bgp 179/tcp
+bgp 179/udp
+imap3 220/tcp
+imap3 220/udp
+ldap 389/tcp
+ldap 389/udp
+https 443/tcp
+https 443/udp
+microsoft-ds 445/tcp
+microsoft-ds 445/udp
+isakmp 500/tcp
+isakmp 500/udp
+rtsp 554/tcp
+rtsp 554/udp
+ipp 631/tcp
+ipp 631/udp
+syslog 514/udp
+printer 515/tcp spooler
+dhcpv6-client 546/tcp
+dhcpv6-client 546/udp
+dhcpv6-server 547/tcp
+dhcpv6-server 547/udp
+afpovertcp 548/tcp
+afpovertcp 548/udp
+nntps 563/tcp snntp
+nntps 563/udp snntp
+ldaps 636/tcp
+ldaps 636/udp
+tinc 655/tcp
+tinc 655/udp
+rsync 873/tcp
+rsync 873/udp
+ftps-data 989/tcp
+ftps 990/tcp
+imaps 993/tcp
+imaps 993/udp
+ircs 994/tcp
+ircs 994/udp
+pop3s 995/tcp
+pop3s 995/udp
+socks 1080/tcp
+socks 1080/udp
+openvpn 1194/tcp
+openvpn 1194/udp
+l2f 1701/tcp l2tp
+l2f 1701/udp l2tp
+radius 1812/tcp
+radius 1812/udp
+radius-acct 1813/tcp radacct
+radius-acct 1813/udp radacct
+nfs 2049/tcp
+nfs 2049/udp
+dict 2628/tcp
+dict 2628/udp
+gpsd 2947/tcp
+gpsd 2947/udp
+icpv2 3130/tcp icp
+icpv2 3130/udp icp
+mysql 3306/tcp
+mysql 3306/udp
+nut 3493/tcp
+nut 3493/udp
+distcc 3632/tcp
+distcc 3632/udp
+daap 3689/tcp
+daap 3689/udp
+svn 3690/tcp subversion
+svn 3690/udp subversion
+epmd 4369/tcp
+epmd 4369/udp
+iax 4569/tcp
+iax 4569/udp
+mtn 4691/tcp
+mtn 4691/udp
+munin 4949/tcp
+sip 5060/tcp
+sip 5060/udp
+sip-tls 5061/tcp
+sip-tls 5061/udp
+xmpp-client 5222/tcp jabber-client
+xmpp-client 5222/udp jabber-client
+xmpp-server 5269/tcp jabber-server
+xmpp-server 5269/udp jabber-server
+mdns 5353/tcp
+mdns 5353/udp
+postgresql 5432/tcp postgres
+postgresql 5432/udp postgres
+x11 6000/tcp
+x11 6000/udp
+mysql-proxy 6446/tcp
+mysql-proxy 6446/udp
+bacula-dir 9101/tcp
+bacula-dir 9101/udp
+bacula-fd 9102/tcp
+bacula-fd 9102/udp
+bacula-sd 9103/tcp
+bacula-sd 9103/udp
+nbd 10809/tcp
+zabbix-agent 10050/tcp
+zabbix-agent 10050/udp
+zabbix-trapper 10051/tcp
+zabbix-trapper 10051/udp
+hkp 11371/tcp
+hkp 11371/udp
+ssmtp 465/tcp smtps
+spamd 783/tcp
+zebrasrv 2600/tcp
+zebra 2601/tcp
+ripd 2602/tcp
+ripngd 2603/tcp
+ospfd 2604/tcp
+bgpd 2605/tcp
+ospf6d 2606/tcp
+ospfapi 2607/tcp
+isisd 2608/tcp
+sane-port 6566/tcp sane saned
+ircd 6667/tcp
+git 9418/tcp
+
diff --git a/package/base-files/files/etc/shadow b/package/base-files/files/etc/shadow
new file mode 100644
index 0000000..e989890
--- /dev/null
+++ b/package/base-files/files/etc/shadow
@@ -0,0 +1,5 @@
+root:x:0:0:99999:7:::
+daemon:*:0:0:99999:7:::
+ftp:*:0:0:99999:7:::
+network:*:0:0:99999:7:::
+nobody:*:0:0:99999:7:::
diff --git a/package/base-files/files/etc/shells b/package/base-files/files/etc/shells
new file mode 100644
index 0000000..006aa38
--- /dev/null
+++ b/package/base-files/files/etc/shells
@@ -0,0 +1 @@
+/bin/ash
diff --git a/package/base-files/files/etc/sysctl.conf b/package/base-files/files/etc/sysctl.conf
new file mode 100644
index 0000000..890e77a
--- /dev/null
+++ b/package/base-files/files/etc/sysctl.conf
@@ -0,0 +1,28 @@
+kernel.panic=3
+net.ipv4.conf.default.arp_ignore=1
+net.ipv4.conf.all.arp_ignore=1
+net.ipv4.ip_forward=1
+net.ipv4.icmp_echo_ignore_broadcasts=1
+net.ipv4.icmp_ignore_bogus_error_responses=1
+net.ipv4.tcp_ecn=0
+net.ipv4.tcp_fin_timeout=30
+net.ipv4.tcp_keepalive_time=120
+net.ipv4.tcp_syncookies=1
+net.ipv4.tcp_timestamps=1
+net.ipv4.tcp_sack=1
+net.ipv4.tcp_dsack=1
+
+net.ipv6.conf.default.forwarding=2
+net.ipv6.conf.all.forwarding=2
+
+net.netfilter.nf_conntrack_acct=1
+net.netfilter.nf_conntrack_checksum=0
+net.netfilter.nf_conntrack_max=16384
+net.netfilter.nf_conntrack_tcp_timeout_established=3600
+net.netfilter.nf_conntrack_udp_timeout=60
+net.netfilter.nf_conntrack_udp_timeout_stream=180
+
+# disable bridge firewalling by default
+net.bridge.bridge-nf-call-arptables=0
+net.bridge.bridge-nf-call-ip6tables=0
+net.bridge.bridge-nf-call-iptables=0
diff --git a/package/base-files/files/etc/sysupgrade.conf b/package/base-files/files/etc/sysupgrade.conf
new file mode 100644
index 0000000..e06fd5e
--- /dev/null
+++ b/package/base-files/files/etc/sysupgrade.conf
@@ -0,0 +1,5 @@
+## This file contains files and directories that should
+## be preserved during an upgrade.
+
+# /etc/example.conf
+# /etc/openvpn/
diff --git a/package/base-files/files/etc/uci-defaults/.svn/entries b/package/base-files/files/etc/uci-defaults/.svn/entries
new file mode 100644
index 0000000..684e703
--- /dev/null
+++ b/package/base-files/files/etc/uci-defaults/.svn/entries
@@ -0,0 +1,130 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/base-files/files/etc/uci-defaults
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-18T12:46:43.271056Z
+35218
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+12_network-generate-ula
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+78decd5e0f603eb024b4f4ad020ab3fe
+2013-01-18T12:46:43.271056Z
+35218
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+565
+
+11_migrate-sysctl
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+971ed444a917abd1be86faa1ae82e868
+2013-01-18T12:46:43.271056Z
+35218
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+451
+
+10_migrate-shadow
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+83550010e2d2318b21225909bb42e771
+2013-01-18T12:46:43.271056Z
+35218
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+418
+
diff --git a/package/base-files/files/etc/uci-defaults/.svn/text-base/10_migrate-shadow.svn-base b/package/base-files/files/etc/uci-defaults/.svn/text-base/10_migrate-shadow.svn-base
new file mode 100644
index 0000000..b7ea571
--- /dev/null
+++ b/package/base-files/files/etc/uci-defaults/.svn/text-base/10_migrate-shadow.svn-base
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+local ppwd="$(sed -ne '/^root:/s/^root:\([^:]*\):.*$/\1/p' /etc/passwd)"
+local spwd="$(sed -ne '/^root:/s/^root:\([^:]*\):.*$/\1/p' /etc/shadow)"
+
+if [ -n "${ppwd#[\!x]}" ] && [ -z "${spwd#[\!x]}" ]; then
+ logger -t migrate-shadow "Moving root password hash into shadow database"
+ sed -i -e "s:^root\:[^\:]*\::root\:x\::" /etc/passwd
+ sed -i -e "s:^root\:[^\:]*\::root\:$ppwd\::" /etc/shadow
+fi
+
+exit 0
diff --git a/package/base-files/files/etc/uci-defaults/.svn/text-base/11_migrate-sysctl.svn-base b/package/base-files/files/etc/uci-defaults/.svn/text-base/11_migrate-sysctl.svn-base
new file mode 100644
index 0000000..b3796a4
--- /dev/null
+++ b/package/base-files/files/etc/uci-defaults/.svn/text-base/11_migrate-sysctl.svn-base
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+if [ ! -f "/rom/etc/sysctl.conf" ] || cmp -s "/rom/etc/sysctl.conf" "/etc/sysctl.conf"; then
+ exit 0
+fi
+
+fingerprint="$(md5sum /etc/sysctl.conf)"
+fingerprint="${fingerprint%% *}"
+
+if [ "$fingerprint" = "1b05ebb41f72cb84e5510573cd4aca26" ] || \
+ [ "$fingerprint" = "62deb895be1a7f496040187b7c930e4e" ]; then
+ logger -t migrate-sysctl "Updating sysctl.conf to use current defaults"
+ cp "/rom/etc/sysctl.conf" "/etc/sysctl.conf"
+fi
+
+exit 0
+
diff --git a/package/base-files/files/etc/uci-defaults/.svn/text-base/12_network-generate-ula.svn-base b/package/base-files/files/etc/uci-defaults/.svn/text-base/12_network-generate-ula.svn-base
new file mode 100644
index 0000000..f3e4931
--- /dev/null
+++ b/package/base-files/files/etc/uci-defaults/.svn/text-base/12_network-generate-ula.svn-base
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+[ "$(uci get network.globals.ula_prefix)" != "auto" ] && exit 0
+# Sometimes results are empty, therefore try until it works...
+local r1 r2 r3
+while [ -z "$r1" -o -z "$r2" -o -z "$r3" ]; do
+ r1=$(printf "%02x" $(($(</dev/urandom tr -dc 0-9 | dd bs=9 count=1) % 256)))
+ r2=$(printf "%01x" $(($(</dev/urandom tr -dc 0-9 | dd bs=9 count=1) % 65536)))
+ r3=$(printf "%01x" $(($(</dev/urandom tr -dc 0-9 | dd bs=9 count=1) % 65536)))
+done
+
+uci -q batch <<-EOF >/dev/null
+ set network.globals.ula_prefix=fd$r1:$r2:$r3::/48
+ commit network
+EOF
+
+exit 0
+
diff --git a/package/base-files/files/etc/uci-defaults/10_migrate-shadow b/package/base-files/files/etc/uci-defaults/10_migrate-shadow
new file mode 100644
index 0000000..b7ea571
--- /dev/null
+++ b/package/base-files/files/etc/uci-defaults/10_migrate-shadow
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+local ppwd="$(sed -ne '/^root:/s/^root:\([^:]*\):.*$/\1/p' /etc/passwd)"
+local spwd="$(sed -ne '/^root:/s/^root:\([^:]*\):.*$/\1/p' /etc/shadow)"
+
+if [ -n "${ppwd#[\!x]}" ] && [ -z "${spwd#[\!x]}" ]; then
+ logger -t migrate-shadow "Moving root password hash into shadow database"
+ sed -i -e "s:^root\:[^\:]*\::root\:x\::" /etc/passwd
+ sed -i -e "s:^root\:[^\:]*\::root\:$ppwd\::" /etc/shadow
+fi
+
+exit 0
diff --git a/package/base-files/files/etc/uci-defaults/11_migrate-sysctl b/package/base-files/files/etc/uci-defaults/11_migrate-sysctl
new file mode 100644
index 0000000..b3796a4
--- /dev/null
+++ b/package/base-files/files/etc/uci-defaults/11_migrate-sysctl
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+if [ ! -f "/rom/etc/sysctl.conf" ] || cmp -s "/rom/etc/sysctl.conf" "/etc/sysctl.conf"; then
+ exit 0
+fi
+
+fingerprint="$(md5sum /etc/sysctl.conf)"
+fingerprint="${fingerprint%% *}"
+
+if [ "$fingerprint" = "1b05ebb41f72cb84e5510573cd4aca26" ] || \
+ [ "$fingerprint" = "62deb895be1a7f496040187b7c930e4e" ]; then
+ logger -t migrate-sysctl "Updating sysctl.conf to use current defaults"
+ cp "/rom/etc/sysctl.conf" "/etc/sysctl.conf"
+fi
+
+exit 0
+
diff --git a/package/base-files/files/etc/uci-defaults/12_network-generate-ula b/package/base-files/files/etc/uci-defaults/12_network-generate-ula
new file mode 100644
index 0000000..f3e4931
--- /dev/null
+++ b/package/base-files/files/etc/uci-defaults/12_network-generate-ula
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+[ "$(uci get network.globals.ula_prefix)" != "auto" ] && exit 0
+# Sometimes results are empty, therefore try until it works...
+local r1 r2 r3
+while [ -z "$r1" -o -z "$r2" -o -z "$r3" ]; do
+ r1=$(printf "%02x" $(($(</dev/urandom tr -dc 0-9 | dd bs=9 count=1) % 256)))
+ r2=$(printf "%01x" $(($(</dev/urandom tr -dc 0-9 | dd bs=9 count=1) % 65536)))
+ r3=$(printf "%01x" $(($(</dev/urandom tr -dc 0-9 | dd bs=9 count=1) % 65536)))
+done
+
+uci -q batch <<-EOF >/dev/null
+ set network.globals.ula_prefix=fd$r1:$r2:$r3::/48
+ commit network
+EOF
+
+exit 0
+
diff --git a/package/base-files/files/lib/.svn/entries b/package/base-files/files/lib/.svn/entries
new file mode 100644
index 0000000..21f5ce2
--- /dev/null
+++ b/package/base-files/files/lib/.svn/entries
@@ -0,0 +1,74 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/base-files/files/lib
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-14T18:43:58.957223Z
+36031
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+functions.sh
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+fe79064449aba26886754ab55bcb160c
+2013-02-17T21:47:03.007046Z
+35646
+juhosg
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+11174
+
+upgrade
+dir
+
+functions
+dir
+
+preinit
+dir
+
+firstboot
+dir
+
diff --git a/package/base-files/files/lib/.svn/prop-base/functions.sh.svn-base b/package/base-files/files/lib/.svn/prop-base/functions.sh.svn-base
new file mode 100644
index 0000000..03b5bfa
--- /dev/null
+++ b/package/base-files/files/lib/.svn/prop-base/functions.sh.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:eol-style
+V 6
+native
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/base-files/files/lib/.svn/text-base/functions.sh.svn-base b/package/base-files/files/lib/.svn/text-base/functions.sh.svn-base
new file mode 100644
index 0000000..f51bfea
--- /dev/null
+++ b/package/base-files/files/lib/.svn/text-base/functions.sh.svn-base
@@ -0,0 +1,543 @@
+#!/bin/sh
+# Copyright (C) 2006-2013 OpenWrt.org
+# Copyright (C) 2006 Fokus Fraunhofer <carsten.tittel@fokus.fraunhofer.de>
+# Copyright (C) 2010 Vertical Communications
+
+
+debug () {
+ ${DEBUG:-:} "$@"
+}
+
+# newline
+N="
+"
+
+_C=0
+NO_EXPORT=1
+LOAD_STATE=1
+LIST_SEP=" "
+
+hotplug_dev() {
+ env -i ACTION=$1 INTERFACE=$2 /sbin/hotplug-call net
+}
+
+append() {
+ local var="$1"
+ local value="$2"
+ local sep="${3:- }"
+
+ eval "export ${NO_EXPORT:+-n} -- \"$var=\${$var:+\${$var}\${value:+\$sep}}\$value\""
+}
+
+list_contains() {
+ local var="$1"
+ local str="$2"
+ local val
+
+ eval "val=\" \${$var} \""
+ [ "${val%% $str *}" != "$val" ]
+}
+
+list_remove() {
+ local var="$1"
+ local remove="$2"
+ local val
+
+ eval "val=\" \${$var} \""
+ val1="${val%% $remove *}"
+ [ "$val1" = "$val" ] && return
+ val2="${val##* $remove }"
+ [ "$val2" = "$val" ] && return
+ val="${val1## } ${val2%% }"
+ val="${val%% }"
+ eval "export ${NO_EXPORT:+-n} -- \"$var=\$val\""
+}
+
+config_load() {
+ [ -n "$IPKG_INSTROOT" ] && return 0
+ uci_load "$@"
+}
+
+reset_cb() {
+ config_cb() { return 0; }
+ option_cb() { return 0; }
+ list_cb() { return 0; }
+}
+reset_cb
+
+package() {
+ return 0
+}
+
+config () {
+ local cfgtype="$1"
+ local name="$2"
+
+ export ${NO_EXPORT:+-n} CONFIG_NUM_SECTIONS=$(($CONFIG_NUM_SECTIONS + 1))
+ name="${name:-cfg$CONFIG_NUM_SECTIONS}"
+ append CONFIG_SECTIONS "$name"
+ [ -n "$NO_CALLBACK" ] || config_cb "$cfgtype" "$name"
+ export ${NO_EXPORT:+-n} CONFIG_SECTION="$name"
+ export ${NO_EXPORT:+-n} "CONFIG_${CONFIG_SECTION}_TYPE=$cfgtype"
+}
+
+option () {
+ local varname="$1"; shift
+ local value="$*"
+
+ export ${NO_EXPORT:+-n} "CONFIG_${CONFIG_SECTION}_${varname}=$value"
+ [ -n "$NO_CALLBACK" ] || option_cb "$varname" "$*"
+}
+
+list() {
+ local varname="$1"; shift
+ local value="$*"
+ local len
+
+ config_get len "$CONFIG_SECTION" "${varname}_LENGTH" 0
+ [ $len = 0 ] && append CONFIG_LIST_STATE "${CONFIG_SECTION}_${varname}"
+ len=$(($len + 1))
+ config_set "$CONFIG_SECTION" "${varname}_ITEM$len" "$value"
+ config_set "$CONFIG_SECTION" "${varname}_LENGTH" "$len"
+ append "CONFIG_${CONFIG_SECTION}_${varname}" "$value" "$LIST_SEP"
+ list_cb "$varname" "$*"
+}
+
+config_rename() {
+ local OLD="$1"
+ local NEW="$2"
+ local oldvar
+ local newvar
+
+ [ -n "$OLD" -a -n "$NEW" ] || return
+ for oldvar in `set | grep ^CONFIG_${OLD}_ | \
+ sed -e 's/\(.*\)=.*$/\1/'` ; do
+ newvar="CONFIG_${NEW}_${oldvar##CONFIG_${OLD}_}"
+ eval "export ${NO_EXPORT:+-n} \"$newvar=\${$oldvar}\""
+ unset "$oldvar"
+ done
+ export ${NO_EXPORT:+-n} CONFIG_SECTIONS="$(echo " $CONFIG_SECTIONS " | sed -e "s, $OLD , $NEW ,")"
+
+ [ "$CONFIG_SECTION" = "$OLD" ] && export ${NO_EXPORT:+-n} CONFIG_SECTION="$NEW"
+}
+
+config_unset() {
+ config_set "$1" "$2" ""
+}
+
+config_clear() {
+ local SECTION="$1"
+ local oldvar
+
+ list_remove CONFIG_SECTIONS "$SECTION"
+ export ${NO_EXPORT:+-n} CONFIG_SECTIONS="${SECTION:+$CONFIG_SECTIONS}"
+
+ for oldvar in `set | grep ^CONFIG_${SECTION:+${SECTION}_} | \
+ sed -e 's/\(.*\)=.*$/\1/'` ; do
+ unset $oldvar
+ done
+}
+
+# config_get <variable> <section> <option> [<default>]
+# config_get <section> <option>
+config_get() {
+ case "$3" in
+ "") eval echo "\${CONFIG_${1}_${2}:-\${4}}";;
+ *) eval export ${NO_EXPORT:+-n} -- "${1}=\${CONFIG_${2}_${3}:-\${4}}";;
+ esac
+}
+
+# config_get_bool <variable> <section> <option> [<default>]
+config_get_bool() {
+ local _tmp
+ config_get _tmp "$2" "$3" "$4"
+ case "$_tmp" in
+ 1|on|true|enabled) _tmp=1;;
+ 0|off|false|disabled) _tmp=0;;
+ *) _tmp="$4";;
+ esac
+ export ${NO_EXPORT:+-n} "$1=$_tmp"
+}
+
+config_set() {
+ local section="$1"
+ local option="$2"
+ local value="$3"
+ local old_section="$CONFIG_SECTION"
+
+ CONFIG_SECTION="$section"
+ option "$option" "$value"
+ CONFIG_SECTION="$old_section"
+}
+
+config_foreach() {
+ local ___function="$1"
+ [ "$#" -ge 1 ] && shift
+ local ___type="$1"
+ [ "$#" -ge 1 ] && shift
+ local section cfgtype
+
+ [ -z "$CONFIG_SECTIONS" ] && return 0
+ for section in ${CONFIG_SECTIONS}; do
+ config_get cfgtype "$section" TYPE
+ [ -n "$___type" -a "x$cfgtype" != "x$___type" ] && continue
+ eval "$___function \"\$section\" \"\$@\""
+ done
+}
+
+config_list_foreach() {
+ [ "$#" -ge 3 ] || return 0
+ local section="$1"; shift
+ local option="$1"; shift
+ local function="$1"; shift
+ local val
+ local len
+ local c=1
+
+ config_get len "${section}" "${option}_LENGTH"
+ [ -z "$len" ] && return 0
+ while [ $c -le "$len" ]; do
+ config_get val "${section}" "${option}_ITEM$c"
+ eval "$function \"\$val\" \"\$@\""
+ c="$(($c + 1))"
+ done
+}
+
+load_modules() {
+ [ -d /etc/modules.d ] && {
+ cd /etc/modules.d
+ sed 's/^[^#]/insmod &/' $* | ash 2>&- || :
+ }
+}
+
+include() {
+ local file
+
+ for file in $(ls $1/*.sh 2>/dev/null); do
+ . $file
+ done
+}
+
+find_mtd_index() {
+ local PART="$(grep "\"$1\"" /proc/mtd | awk -F: '{print $1}')"
+ local INDEX="${PART##mtd}"
+
+ echo ${INDEX}
+}
+
+find_mtd_part() {
+ local INDEX=$(find_mtd_index "$1")
+ local PREFIX=/dev/mtdblock
+
+ [ -d /dev/mtdblock ] && PREFIX=/dev/mtdblock/
+ echo "${INDEX:+$PREFIX$INDEX}"
+}
+
+find_mtd_chardev() {
+ local INDEX=$(find_mtd_index "$1")
+ local PREFIX=/dev/mtd
+
+ [ -d /dev/mtd ] && PREFIX=/dev/mtd/
+ echo "${INDEX:+$PREFIX$INDEX}"
+}
+
+mtd_get_mac_ascii()
+{
+ local mtdname="$1"
+ local key="$2"
+ local part
+ local mac_dirty
+
+ . /lib/functions.sh
+
+ part=$(find_mtd_part "$mtdname")
+ if [ -z "$part" ]; then
+ echo "mtd_get_mac_ascii: partition $mtdname not found!" >&2
+ return
+ fi
+
+ mac_dirty=$(strings "$part" | sed -n 's/'"$key"'=//p')
+ # "canonicalize" mac
+ printf "%02x:%02x:%02x:%02x:%02x:%02x" 0x${mac_dirty//:/ 0x}
+}
+
+mtd_get_mac_binary() {
+ local mtdname="$1"
+ local offset="$2"
+ local part
+
+ part=$(find_mtd_part "$mtdname")
+ if [ -z "$part" ]; then
+ echo "mtd_get_mac_binary: partition $mtdname not found!" >&2
+ return
+ fi
+
+ dd bs=1 skip=$offset count=6 if=$part 2>/dev/null | hexdump -v -n 6 -e '5/1 "%02x:" 1/1 "%02x"'
+}
+
+macaddr_add() {
+ local mac=$1
+ local val=$2
+ local oui=${mac%:*:*:*}
+ local nic=${mac#*:*:*:}
+
+ nic=$(printf "%06x" $((0x${nic//:/} + $val & 0xffffff)) | sed 's/^\(.\{2\}\)\(.\{2\}\)\(.\{2\}\)/\1:\2:\3/')
+ echo $oui:$nic
+}
+
+macaddr_setbit_la()
+{
+ local mac=$1
+
+ printf "%02x:%s" $((0x${mac%%:*} | 0x02)) ${mac#*:}
+}
+
+macaddr_2bin()
+{
+ local mac=$1
+
+ echo -ne \\x${mac//:/\\x}
+}
+
+strtok() { # <string> { <variable> [<separator>] ... }
+ local tmp
+ local val="$1"
+ local count=0
+
+ shift
+
+ while [ $# -gt 1 ]; do
+ tmp="${val%%$2*}"
+
+ [ "$tmp" = "$val" ] && break
+
+ val="${val#$tmp$2}"
+
+ export ${NO_EXPORT:+-n} "$1=$tmp"; count=$((count+1))
+ shift 2
+ done
+
+ if [ $# -gt 0 -a -n "$val" ]; then
+ export ${NO_EXPORT:+-n} "$1=$val"; count=$((count+1))
+ fi
+
+ return $count
+}
+
+
+jffs2_mark_erase() {
+ local part="$(find_mtd_part "$1")"
+ [ -z "$part" ] && {
+ echo Partition not found.
+ return 1
+ }
+ echo -e "\xde\xad\xc0\xde" | mtd -qq write - "$1"
+}
+
+uci_apply_defaults() {
+ cd /etc/uci-defaults || return 0
+ files="$(ls)"
+ [ -z "$files" ] && return 0
+ mkdir -p /tmp/.uci
+ for file in $files; do
+ ( . "./$(basename $file)" ) && rm -f "$file"
+ done
+ uci commit
+}
+
+group_add() {
+ local name="$1"
+ local gid="$2"
+ local rc
+ [ -f "${IPKG_INSTROOT}/etc/group" ] || return 1
+ [ -n "$IPKG_INSTROOT" ] || lock /var/lock/group
+ echo "${name}:x:${gid}:" >> ${IPKG_INSTROOT}/etc/group
+ rc=$?
+ [ -n "$IPKG_INSTROOT" ] || lock -u /var/lock/group
+ return $rc
+}
+
+group_exists() {
+ grep -qs "^${1}:" ${IPKG_INSTROOT}/etc/group
+}
+
+user_add() {
+ local name="${1}"
+ local uid="${2}"
+ local gid="${3:-$2}"
+ local desc="${4:-$1}"
+ local home="${5:-/var/run/$1}"
+ local shell="${6:-/bin/false}"
+ local rc
+ [ -f "${IPKG_INSTROOT}/etc/passwd" ] || return 1
+ [ -n "$IPKG_INSTROOT" ] || lock /var/lock/passwd
+ echo "${name}:x:${uid}:${gid}:${desc}:${home}:${shell}" >> ${IPKG_INSTROOT}/etc/passwd
+ echo "${name}:x:0:0:99999:7:::" >> ${IPKG_INSTROOT}/etc/shadow
+ rc=$?
+ [ -n "$IPKG_INSTROOT" ] || lock -u /var/lock/passwd
+ return $rc
+}
+
+user_exists() {
+ grep -qs "^${1}:" ${IPKG_INSTROOT}/etc/passwd
+}
+
+
+pi_include() {
+ if [ -f "/tmp/overlay/$1" ]; then
+ . "/tmp/overlay/$1"
+ elif [ -f "$1" ]; then
+ . "$1"
+ elif [ -d "/tmp/overlay/$1" ]; then
+ if [ -n "$(ls /tmp/overlay/$1/*.sh 2>/dev/null)" ]; then
+ for src_script in /tmp/overlay/$1/*.sh; do
+ . "$src_script"
+ done
+ fi
+ elif [ -d "$1" ]; then
+ if [ -n "$(ls $1/*.sh 2>/dev/null)" ]; then
+ for src_script in $1/*.sh; do
+ . "$src_script"
+ done
+ fi
+ else
+ echo "WARNING: $1 not found"
+ return 1
+ fi
+ return 0
+}
+
+boot_hook_splice_start() {
+ export -n PI_HOOK_SPLICE=1
+}
+
+boot_hook_splice_finish() {
+ local hook
+ for hook in $PI_STACK_LIST; do
+ local v; eval "v=\${${hook}_splice:+\$${hook}_splice }$hook"
+ export -n "${hook}=${v% }"
+ export -n "${hook}_splice="
+ done
+ export -n PI_HOOK_SPLICE=
+}
+
+boot_hook_init() {
+ local hook="${1}_hook"
+ export -n "PI_STACK_LIST=${PI_STACK_LIST:+$PI_STACK_LIST }$hook"
+ export -n "$hook="
+}
+
+boot_hook_add() {
+ local hook="${1}_hook${PI_HOOK_SPLICE:+_splice}"
+ local func="${2}"
+
+ [ -n "$func" ] && {
+ local v; eval "v=\$$hook"
+ export -n "$hook=${v:+$v }$func"
+ }
+}
+
+boot_hook_shift() {
+ local hook="${1}_hook"
+ local rvar="${2}"
+
+ local v; eval "v=\$$hook"
+ [ -n "$v" ] && {
+ local first="${v%% *}"
+
+ [ "$v" != "${v#* }" ] && \
+ export -n "$hook=${v#* }" || \
+ export -n "$hook="
+
+ export -n "$rvar=$first"
+ return 0
+ }
+
+ return 1
+}
+
+boot_run_hook() {
+ local hook="$1"
+ local func
+
+ while boot_hook_shift "$hook" func; do
+ local ran; eval "ran=\$PI_RAN_$func"
+ [ -n "$ran" ] || {
+ export -n "PI_RAN_$func=1"
+ $func "$1" "$2"
+ }
+ done
+}
+
+jffs2_ready() {
+ mtdpart="$(find_mtd_part rootfs_data)"
+ [ -z "$mtdpart" ] && return 1
+ magic=$(hexdump $mtdpart -n 4 -e '4/1 "%02x"')
+ [ "$magic" != "deadc0de" ]
+}
+
+dupe() { # <new_root> <old_root>
+ cd $1
+ echo -n "creating directories... "
+ {
+ cd $2
+ find . -xdev -type d
+ echo "./dev ./overlay ./mnt ./proc ./tmp"
+ # xdev skips mounted directories
+ cd $1
+ } | xargs mkdir -p
+ echo "done"
+
+ echo -n "setting up symlinks... "
+ for file in $(cd $2; find . -xdev -type f;); do
+ case "$file" in
+ ./rom/note) ;; #nothing
+ ./etc/config*|\
+ ./usr/lib/opkg/info/*) cp -af $2/$file $file;;
+ *) ln -sf /rom/${file#./*} $file;;
+ esac
+ done
+ for file in $(cd $2; find . -xdev -type l;); do
+ cp -af $2/${file#./*} $file
+ done
+ echo "done"
+}
+
+pivot() { # <new_root> <old_root>
+ mount -o noatime,move /proc $1/proc && \
+ pivot_root $1 $1$2 && {
+ mount -o noatime,move $2/dev /dev
+ mount -o noatime,move $2/tmp /tmp
+ mount -o noatime,move $2/sys /sys 2>&-
+ mount -o noatime,move $2/overlay /overlay 2>&-
+ return 0
+ }
+}
+
+fopivot() { # <rw_root> <ro_root> <dupe?>
+ root=$1
+ {
+ if grep -q overlay /proc/filesystems; then
+ mount -o noatime,lowerdir=/,upperdir=$1 -t overlayfs "overlayfs:$1" /mnt && root=/mnt
+ elif grep -q mini_fo /proc/filesystems; then
+ mount -t mini_fo -o noatime,base=/,sto=$1 "mini_fo:$1" /mnt 2>&- && root=/mnt
+ else
+ mount --bind -o noatime / /mnt
+ mount --bind -o noatime,union "$1" /mnt && root=/mnt
+ fi
+ } || {
+ [ "$3" = "1" ] && {
+ mount | grep "on $1 type" 2>&- 1>&- || mount -o noatime,bind $1 $1
+ dupe $1 $rom
+ }
+ }
+ pivot $root $2
+}
+
+ramoverlay() {
+ mkdir -p /tmp/root
+ mount -t tmpfs -o noatime,mode=0755 root /tmp/root
+ fopivot /tmp/root /rom 1
+}
+
+[ -z "$IPKG_INSTROOT" -a -f /lib/config/uci.sh ] && . /lib/config/uci.sh
diff --git a/package/base-files/files/lib/firstboot/.svn/entries b/package/base-files/files/lib/firstboot/.svn/entries
new file mode 100644
index 0000000..4faa8cf
--- /dev/null
+++ b/package/base-files/files/lib/firstboot/.svn/entries
@@ -0,0 +1,538 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/base-files/files/lib/firstboot
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-13T18:11:19.892934Z
+36003
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+30_no_fo_pivot
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+05dcf8be4db74ee8bf91ec6cc9290a8c
+2010-03-21T17:16:50.184472Z
+20356
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+212
+
+10_determine_parts
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+7f4e5a91337ee98efcaf044da7a46ea0
+2010-01-25T17:11:17.955488Z
+19331
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+932
+
+99_10_with_fo_cleanup
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+933a1c84006796789185495083cfe600
+2013-03-13T18:11:19.892934Z
+36003
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+501
+
+99_10_no_fo_cleanup
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+13db248c34fa69a6b000921a1e76da9e
+2010-03-21T17:16:50.184472Z
+20356
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+224
+
+30_reset_copy_rom
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+c906820b468d1bc036969053ecc84e2a
+2010-01-25T17:11:17.955488Z
+19331
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+228
+
+20_no_fo_mount_jffs
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+93874189d29461ca4c5538a9c8281f1f
+2012-12-19T16:07:46.450520Z
+34792
+mirko
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+332
+
+40_no_fo_copy_ramoverlay
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+ccce2620aa1dafc38d4a3831b32f65f7
+2010-01-25T17:11:17.955488Z
+19331
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+365
+
+20_reset_clear_jffs
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+8dfe331ce8ca348071cecfe496c58dfe
+2010-01-25T17:11:17.955488Z
+19331
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+287
+
+30_is_rootfs_mounted
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+066662c53f60a607cbaba59c235586cf
+2012-12-19T16:07:46.450520Z
+34792
+mirko
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+236
+
+50_pivot
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+287023c3965c0a0c060dcb974c56e4f7
+2010-03-21T17:16:50.184472Z
+20356
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+383
+
+05_firstboot_skip
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+3e218d08ebd04fa51c73d6a0bbce0361
+2012-04-27T16:49:16.916618Z
+31492
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+115
+
+10_no_fo_clear_overlay
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+6bf3c0e457e23f335337ea54e566fd4e
+2010-01-25T17:11:17.955488Z
+19331
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+356
+
+20_has_mini_fo
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+8f0c67354bd0b422d58579d6cb10b25d
+2011-03-17T19:09:39.292493Z
+26207
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+262
+
+10_reset_has_mini_fo
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+5e47572006d901d63617729a6a35fb5b
+2011-03-17T19:09:39.292493Z
+26207
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+261
+
+40_copy_ramoverlay
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+8f418a269c3912825daae204264a8f9b
+2010-03-21T17:16:50.184472Z
+20356
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+361
+
diff --git a/package/base-files/files/lib/firstboot/.svn/text-base/05_firstboot_skip.svn-base b/package/base-files/files/lib/firstboot/.svn/text-base/05_firstboot_skip.svn-base
new file mode 100644
index 0000000..5f44df6
--- /dev/null
+++ b/package/base-files/files/lib/firstboot/.svn/text-base/05_firstboot_skip.svn-base
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+check_skip() {
+ if [ "$firstboot_skip_next" = "true" ]; then
+ return 0
+ else
+ return 1
+ fi
+}
+
diff --git a/package/base-files/files/lib/firstboot/.svn/text-base/10_determine_parts.svn-base b/package/base-files/files/lib/firstboot/.svn/text-base/10_determine_parts.svn-base
new file mode 100644
index 0000000..3f56e32
--- /dev/null
+++ b/package/base-files/files/lib/firstboot/.svn/text-base/10_determine_parts.svn-base
@@ -0,0 +1,46 @@
+#!/bin/sh
+
+set_mtd_part() {
+ partname="rootfs_data"
+ mtdpart="$(find_mtd_part $partname)"
+}
+
+set_rom_part() {
+ rom=$(awk '/squashfs/ {print $2}' /proc/mounts)
+}
+
+set_jffs_part() {
+ jffs=$(awk '/jffs2/ {print $2}' /proc/mounts)
+}
+
+determine_mtd_part() {
+ set_mtd_part
+ if [ -z "$mtdpart" ]; then
+ echo "MTD partition not found."
+ exit 1
+ fi
+}
+
+determine_rom_part() {
+ check_skip || {
+ set_rom_part
+ if [ -z "$rom" ]; then
+ echo "You do not have a squashfs partition; aborting"
+ echo "(firstboot cannot be run on jffs2 based firmwares)"
+ exit 1
+ fi
+ }
+}
+
+determine_jffs2_part() {
+ check_skip || {
+ set_jffs_part
+ }
+}
+
+boot_hook_add switch2jffs determine_mtd_part
+boot_hook_add jffs2reset determine_mtd_part
+boot_hook_add switch2jffs determine_rom_part
+boot_hook_add jffs2reset determine_rom_part
+boot_hook_add switch2jffs determine_jffs2_part
+boot_hook_add jffs2reset determine_jffs2_part
diff --git a/package/base-files/files/lib/firstboot/.svn/text-base/10_no_fo_clear_overlay.svn-base b/package/base-files/files/lib/firstboot/.svn/text-base/10_no_fo_clear_overlay.svn-base
new file mode 100644
index 0000000..8a7d9b0
--- /dev/null
+++ b/package/base-files/files/lib/firstboot/.svn/text-base/10_no_fo_clear_overlay.svn-base
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+no_fo_clear_overlay() {
+ # switch back to squashfs temporarily
+ pivot /rom /mnt
+
+ # get rid of the old overlay
+ umount -l /mnt
+
+ # another umount to get rid of the bind from /tmp/root
+ umount -l /mnt
+}
+
+boot_hook_add no_fo no_fo_clear_overlay
diff --git a/package/base-files/files/lib/firstboot/.svn/text-base/10_reset_has_mini_fo.svn-base b/package/base-files/files/lib/firstboot/.svn/text-base/10_reset_has_mini_fo.svn-base
new file mode 100644
index 0000000..4e28584
--- /dev/null
+++ b/package/base-files/files/lib/firstboot/.svn/text-base/10_reset_has_mini_fo.svn-base
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+reset_check_for_overlay() {
+ if grep -qE '(mini_fo|overlay)' /proc/filesystems; then
+ reset_has_fo=true
+ fi
+}
+
+boot_hook_add jffs2reset reset_check_for_overlay
diff --git a/package/base-files/files/lib/firstboot/.svn/text-base/20_has_mini_fo.svn-base b/package/base-files/files/lib/firstboot/.svn/text-base/20_has_mini_fo.svn-base
new file mode 100644
index 0000000..8ca6a4f
--- /dev/null
+++ b/package/base-files/files/lib/firstboot/.svn/text-base/20_has_mini_fo.svn-base
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+check_for_overlay() {
+ if ! grep -qE '(mini_fo|overlay)' /proc/filesystems; then
+ boot_run_hook no_fo
+ exit 1
+ fi
+}
+
+boot_hook_add switch2jffs check_for_overlay
diff --git a/package/base-files/files/lib/firstboot/.svn/text-base/20_no_fo_mount_jffs.svn-base b/package/base-files/files/lib/firstboot/.svn/text-base/20_no_fo_mount_jffs.svn-base
new file mode 100644
index 0000000..c03714f
--- /dev/null
+++ b/package/base-files/files/lib/firstboot/.svn/text-base/20_no_fo_mount_jffs.svn-base
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+no_fo_mount_jffs() {
+ # initialize jffs2
+ mount -o noatime "$mtdpart" /overlay -t jffs2 || exit
+
+ # workaround to ensure that union can attach properly
+ sync
+ ls /overlay >/dev/null
+}
+
+boot_hook_add no_fo no_fo_mount_jffs
diff --git a/package/base-files/files/lib/firstboot/.svn/text-base/20_reset_clear_jffs.svn-base b/package/base-files/files/lib/firstboot/.svn/text-base/20_reset_clear_jffs.svn-base
new file mode 100644
index 0000000..a3cd24f
--- /dev/null
+++ b/package/base-files/files/lib/firstboot/.svn/text-base/20_reset_clear_jffs.svn-base
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+reset_clear_jffs() {
+ [ "$reset_has_fo" = "true" ] && {
+ rm -rf $jffs/* 2>&-
+ mount -o remount $jffs / 2>&-
+ exit 0
+ } || reset_has_fo=false
+}
+
+boot_hook_add jffs2reset reset_clear_jffs
diff --git a/package/base-files/files/lib/firstboot/.svn/text-base/30_is_rootfs_mounted.svn-base b/package/base-files/files/lib/firstboot/.svn/text-base/30_is_rootfs_mounted.svn-base
new file mode 100644
index 0000000..7233fd9
--- /dev/null
+++ b/package/base-files/files/lib/firstboot/.svn/text-base/30_is_rootfs_mounted.svn-base
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+skip_if_rootfs_mounted() {
+ mount -o noatime -t jffs2 "$mtdpart" /rom/overlay || exit
+}
+
+boot_hook_add switch2jffs skip_if_rootfs_mounted
diff --git a/package/base-files/files/lib/firstboot/.svn/text-base/30_no_fo_pivot.svn-base b/package/base-files/files/lib/firstboot/.svn/text-base/30_no_fo_pivot.svn-base
new file mode 100644
index 0000000..b5c2601
--- /dev/null
+++ b/package/base-files/files/lib/firstboot/.svn/text-base/30_no_fo_pivot.svn-base
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+no_fo_pivot() {
+ # switch to the new (empty) jffs2
+ fopivot /overlay /rom 1
+}
+
+boot_hook_add no_fo no_fo_pivot
diff --git a/package/base-files/files/lib/firstboot/.svn/text-base/30_reset_copy_rom.svn-base b/package/base-files/files/lib/firstboot/.svn/text-base/30_reset_copy_rom.svn-base
new file mode 100644
index 0000000..d91c689
--- /dev/null
+++ b/package/base-files/files/lib/firstboot/.svn/text-base/30_reset_copy_rom.svn-base
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+reset_copy_rom() {
+ [ "$reset_has_fo" != "true" ] && {
+ dupe $jffs $rom
+ exit 0
+ }
+}
+
+boot_hook_add jffs2reset reset_copy_rom
diff --git a/package/base-files/files/lib/firstboot/.svn/text-base/40_copy_ramoverlay.svn-base b/package/base-files/files/lib/firstboot/.svn/text-base/40_copy_ramoverlay.svn-base
new file mode 100644
index 0000000..39c2eda
--- /dev/null
+++ b/package/base-files/files/lib/firstboot/.svn/text-base/40_copy_ramoverlay.svn-base
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+copy_ramoverlay() {
+ # try to avoid fs changing while copying
+ mount -o remount,ro none / 2>&-
+ # copy ramoverlay to jffs2
+ echo -n "copying files ... "
+ cp -a /tmp/root/* /rom/overlay 2>&-
+ echo "done"
+}
+
+boot_hook_add switch2jffs copy_ramoverlay
diff --git a/package/base-files/files/lib/firstboot/.svn/text-base/40_no_fo_copy_ramoverlay.svn-base b/package/base-files/files/lib/firstboot/.svn/text-base/40_no_fo_copy_ramoverlay.svn-base
new file mode 100644
index 0000000..ced7c1b
--- /dev/null
+++ b/package/base-files/files/lib/firstboot/.svn/text-base/40_no_fo_copy_ramoverlay.svn-base
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+no_fo_copy_ramoverlay() {
+ # copy ramoverlay to jffs2, must be done after switching
+ # to the new rootfs to avoid creating opaque directories
+ echo -n "copying files ... "
+ cp -a /tmp/root/* / >/dev/null 2>&1
+ sync
+}
+
+boot_hook_add no_fo no_fo_ramoverlay
diff --git a/package/base-files/files/lib/firstboot/.svn/text-base/50_pivot.svn-base b/package/base-files/files/lib/firstboot/.svn/text-base/50_pivot.svn-base
new file mode 100644
index 0000000..53801d7
--- /dev/null
+++ b/package/base-files/files/lib/firstboot/.svn/text-base/50_pivot.svn-base
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+with_fo_pivot() {
+ # switch back to squashfs (temporarily)
+ # and park the ramdisk ontop of /tmp/root
+ pivot /rom /mnt
+ mount -o move /mnt /tmp/root
+
+ # /overlay is the overlay
+ # /rom is the readonly
+ fopivot /overlay /rom
+}
+
+boot_hook_add switch2jffs with_fo_pivot
diff --git a/package/base-files/files/lib/firstboot/.svn/text-base/99_10_no_fo_cleanup.svn-base b/package/base-files/files/lib/firstboot/.svn/text-base/99_10_no_fo_cleanup.svn-base
new file mode 100644
index 0000000..6dedcb1
--- /dev/null
+++ b/package/base-files/files/lib/firstboot/.svn/text-base/99_10_no_fo_cleanup.svn-base
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+no_fo_cleanup() {
+ echo "done"
+ umount -l /overlay
+ umount -l /tmp/root
+ exit 0
+}
+
+boot_hook_add no_fo no_fo_cleanup
diff --git a/package/base-files/files/lib/firstboot/.svn/text-base/99_10_with_fo_cleanup.svn-base b/package/base-files/files/lib/firstboot/.svn/text-base/99_10_with_fo_cleanup.svn-base
new file mode 100644
index 0000000..5601699
--- /dev/null
+++ b/package/base-files/files/lib/firstboot/.svn/text-base/99_10_with_fo_cleanup.svn-base
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+with_fo_cleanup() {
+ # try to get rid of /tmp/root
+ # this will almost always fail
+ umount -l /tmp/root 2>&-
+ grep -q overlay /proc/filesystems && {
+ cd /
+ (
+ cd /overlay
+ find -type l
+ ) | while read FILE; do
+ [ -z "$FILE" ] && break
+ if ls -la "$FILE" 2>&- | grep -q '(overlay-whiteout)'; then
+ rm -f "$FILE"
+ fi
+ done
+ }
+ exit 0
+}
+
+boot_hook_add switch2jffs with_fo_cleanup
diff --git a/package/base-files/files/lib/firstboot/05_firstboot_skip b/package/base-files/files/lib/firstboot/05_firstboot_skip
new file mode 100644
index 0000000..5f44df6
--- /dev/null
+++ b/package/base-files/files/lib/firstboot/05_firstboot_skip
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+check_skip() {
+ if [ "$firstboot_skip_next" = "true" ]; then
+ return 0
+ else
+ return 1
+ fi
+}
+
diff --git a/package/base-files/files/lib/firstboot/10_determine_parts b/package/base-files/files/lib/firstboot/10_determine_parts
new file mode 100644
index 0000000..3f56e32
--- /dev/null
+++ b/package/base-files/files/lib/firstboot/10_determine_parts
@@ -0,0 +1,46 @@
+#!/bin/sh
+
+set_mtd_part() {
+ partname="rootfs_data"
+ mtdpart="$(find_mtd_part $partname)"
+}
+
+set_rom_part() {
+ rom=$(awk '/squashfs/ {print $2}' /proc/mounts)
+}
+
+set_jffs_part() {
+ jffs=$(awk '/jffs2/ {print $2}' /proc/mounts)
+}
+
+determine_mtd_part() {
+ set_mtd_part
+ if [ -z "$mtdpart" ]; then
+ echo "MTD partition not found."
+ exit 1
+ fi
+}
+
+determine_rom_part() {
+ check_skip || {
+ set_rom_part
+ if [ -z "$rom" ]; then
+ echo "You do not have a squashfs partition; aborting"
+ echo "(firstboot cannot be run on jffs2 based firmwares)"
+ exit 1
+ fi
+ }
+}
+
+determine_jffs2_part() {
+ check_skip || {
+ set_jffs_part
+ }
+}
+
+boot_hook_add switch2jffs determine_mtd_part
+boot_hook_add jffs2reset determine_mtd_part
+boot_hook_add switch2jffs determine_rom_part
+boot_hook_add jffs2reset determine_rom_part
+boot_hook_add switch2jffs determine_jffs2_part
+boot_hook_add jffs2reset determine_jffs2_part
diff --git a/package/base-files/files/lib/firstboot/10_no_fo_clear_overlay b/package/base-files/files/lib/firstboot/10_no_fo_clear_overlay
new file mode 100644
index 0000000..8a7d9b0
--- /dev/null
+++ b/package/base-files/files/lib/firstboot/10_no_fo_clear_overlay
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+no_fo_clear_overlay() {
+ # switch back to squashfs temporarily
+ pivot /rom /mnt
+
+ # get rid of the old overlay
+ umount -l /mnt
+
+ # another umount to get rid of the bind from /tmp/root
+ umount -l /mnt
+}
+
+boot_hook_add no_fo no_fo_clear_overlay
diff --git a/package/base-files/files/lib/firstboot/10_reset_has_mini_fo b/package/base-files/files/lib/firstboot/10_reset_has_mini_fo
new file mode 100644
index 0000000..4e28584
--- /dev/null
+++ b/package/base-files/files/lib/firstboot/10_reset_has_mini_fo
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+reset_check_for_overlay() {
+ if grep -qE '(mini_fo|overlay)' /proc/filesystems; then
+ reset_has_fo=true
+ fi
+}
+
+boot_hook_add jffs2reset reset_check_for_overlay
diff --git a/package/base-files/files/lib/firstboot/20_has_mini_fo b/package/base-files/files/lib/firstboot/20_has_mini_fo
new file mode 100644
index 0000000..8ca6a4f
--- /dev/null
+++ b/package/base-files/files/lib/firstboot/20_has_mini_fo
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+check_for_overlay() {
+ if ! grep -qE '(mini_fo|overlay)' /proc/filesystems; then
+ boot_run_hook no_fo
+ exit 1
+ fi
+}
+
+boot_hook_add switch2jffs check_for_overlay
diff --git a/package/base-files/files/lib/firstboot/20_no_fo_mount_jffs b/package/base-files/files/lib/firstboot/20_no_fo_mount_jffs
new file mode 100644
index 0000000..c03714f
--- /dev/null
+++ b/package/base-files/files/lib/firstboot/20_no_fo_mount_jffs
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+no_fo_mount_jffs() {
+ # initialize jffs2
+ mount -o noatime "$mtdpart" /overlay -t jffs2 || exit
+
+ # workaround to ensure that union can attach properly
+ sync
+ ls /overlay >/dev/null
+}
+
+boot_hook_add no_fo no_fo_mount_jffs
diff --git a/package/base-files/files/lib/firstboot/20_reset_clear_jffs b/package/base-files/files/lib/firstboot/20_reset_clear_jffs
new file mode 100644
index 0000000..a3cd24f
--- /dev/null
+++ b/package/base-files/files/lib/firstboot/20_reset_clear_jffs
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+reset_clear_jffs() {
+ [ "$reset_has_fo" = "true" ] && {
+ rm -rf $jffs/* 2>&-
+ mount -o remount $jffs / 2>&-
+ exit 0
+ } || reset_has_fo=false
+}
+
+boot_hook_add jffs2reset reset_clear_jffs
diff --git a/package/base-files/files/lib/firstboot/30_is_rootfs_mounted b/package/base-files/files/lib/firstboot/30_is_rootfs_mounted
new file mode 100644
index 0000000..7233fd9
--- /dev/null
+++ b/package/base-files/files/lib/firstboot/30_is_rootfs_mounted
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+skip_if_rootfs_mounted() {
+ mount -o noatime -t jffs2 "$mtdpart" /rom/overlay || exit
+}
+
+boot_hook_add switch2jffs skip_if_rootfs_mounted
diff --git a/package/base-files/files/lib/firstboot/30_no_fo_pivot b/package/base-files/files/lib/firstboot/30_no_fo_pivot
new file mode 100644
index 0000000..b5c2601
--- /dev/null
+++ b/package/base-files/files/lib/firstboot/30_no_fo_pivot
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+no_fo_pivot() {
+ # switch to the new (empty) jffs2
+ fopivot /overlay /rom 1
+}
+
+boot_hook_add no_fo no_fo_pivot
diff --git a/package/base-files/files/lib/firstboot/30_reset_copy_rom b/package/base-files/files/lib/firstboot/30_reset_copy_rom
new file mode 100644
index 0000000..d91c689
--- /dev/null
+++ b/package/base-files/files/lib/firstboot/30_reset_copy_rom
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+reset_copy_rom() {
+ [ "$reset_has_fo" != "true" ] && {
+ dupe $jffs $rom
+ exit 0
+ }
+}
+
+boot_hook_add jffs2reset reset_copy_rom
diff --git a/package/base-files/files/lib/firstboot/40_copy_ramoverlay b/package/base-files/files/lib/firstboot/40_copy_ramoverlay
new file mode 100644
index 0000000..39c2eda
--- /dev/null
+++ b/package/base-files/files/lib/firstboot/40_copy_ramoverlay
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+copy_ramoverlay() {
+ # try to avoid fs changing while copying
+ mount -o remount,ro none / 2>&-
+ # copy ramoverlay to jffs2
+ echo -n "copying files ... "
+ cp -a /tmp/root/* /rom/overlay 2>&-
+ echo "done"
+}
+
+boot_hook_add switch2jffs copy_ramoverlay
diff --git a/package/base-files/files/lib/firstboot/40_no_fo_copy_ramoverlay b/package/base-files/files/lib/firstboot/40_no_fo_copy_ramoverlay
new file mode 100644
index 0000000..ced7c1b
--- /dev/null
+++ b/package/base-files/files/lib/firstboot/40_no_fo_copy_ramoverlay
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+no_fo_copy_ramoverlay() {
+ # copy ramoverlay to jffs2, must be done after switching
+ # to the new rootfs to avoid creating opaque directories
+ echo -n "copying files ... "
+ cp -a /tmp/root/* / >/dev/null 2>&1
+ sync
+}
+
+boot_hook_add no_fo no_fo_ramoverlay
diff --git a/package/base-files/files/lib/firstboot/50_pivot b/package/base-files/files/lib/firstboot/50_pivot
new file mode 100644
index 0000000..53801d7
--- /dev/null
+++ b/package/base-files/files/lib/firstboot/50_pivot
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+with_fo_pivot() {
+ # switch back to squashfs (temporarily)
+ # and park the ramdisk ontop of /tmp/root
+ pivot /rom /mnt
+ mount -o move /mnt /tmp/root
+
+ # /overlay is the overlay
+ # /rom is the readonly
+ fopivot /overlay /rom
+}
+
+boot_hook_add switch2jffs with_fo_pivot
diff --git a/package/base-files/files/lib/firstboot/99_10_no_fo_cleanup b/package/base-files/files/lib/firstboot/99_10_no_fo_cleanup
new file mode 100644
index 0000000..6dedcb1
--- /dev/null
+++ b/package/base-files/files/lib/firstboot/99_10_no_fo_cleanup
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+no_fo_cleanup() {
+ echo "done"
+ umount -l /overlay
+ umount -l /tmp/root
+ exit 0
+}
+
+boot_hook_add no_fo no_fo_cleanup
diff --git a/package/base-files/files/lib/firstboot/99_10_with_fo_cleanup b/package/base-files/files/lib/firstboot/99_10_with_fo_cleanup
new file mode 100644
index 0000000..5601699
--- /dev/null
+++ b/package/base-files/files/lib/firstboot/99_10_with_fo_cleanup
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+with_fo_cleanup() {
+ # try to get rid of /tmp/root
+ # this will almost always fail
+ umount -l /tmp/root 2>&-
+ grep -q overlay /proc/filesystems && {
+ cd /
+ (
+ cd /overlay
+ find -type l
+ ) | while read FILE; do
+ [ -z "$FILE" ] && break
+ if ls -la "$FILE" 2>&- | grep -q '(overlay-whiteout)'; then
+ rm -f "$FILE"
+ fi
+ done
+ }
+ exit 0
+}
+
+boot_hook_add switch2jffs with_fo_cleanup
diff --git a/package/base-files/files/lib/functions.sh b/package/base-files/files/lib/functions.sh
new file mode 100755
index 0000000..f51bfea
--- /dev/null
+++ b/package/base-files/files/lib/functions.sh
@@ -0,0 +1,543 @@
+#!/bin/sh
+# Copyright (C) 2006-2013 OpenWrt.org
+# Copyright (C) 2006 Fokus Fraunhofer <carsten.tittel@fokus.fraunhofer.de>
+# Copyright (C) 2010 Vertical Communications
+
+
+debug () {
+ ${DEBUG:-:} "$@"
+}
+
+# newline
+N="
+"
+
+_C=0
+NO_EXPORT=1
+LOAD_STATE=1
+LIST_SEP=" "
+
+hotplug_dev() {
+ env -i ACTION=$1 INTERFACE=$2 /sbin/hotplug-call net
+}
+
+append() {
+ local var="$1"
+ local value="$2"
+ local sep="${3:- }"
+
+ eval "export ${NO_EXPORT:+-n} -- \"$var=\${$var:+\${$var}\${value:+\$sep}}\$value\""
+}
+
+list_contains() {
+ local var="$1"
+ local str="$2"
+ local val
+
+ eval "val=\" \${$var} \""
+ [ "${val%% $str *}" != "$val" ]
+}
+
+list_remove() {
+ local var="$1"
+ local remove="$2"
+ local val
+
+ eval "val=\" \${$var} \""
+ val1="${val%% $remove *}"
+ [ "$val1" = "$val" ] && return
+ val2="${val##* $remove }"
+ [ "$val2" = "$val" ] && return
+ val="${val1## } ${val2%% }"
+ val="${val%% }"
+ eval "export ${NO_EXPORT:+-n} -- \"$var=\$val\""
+}
+
+config_load() {
+ [ -n "$IPKG_INSTROOT" ] && return 0
+ uci_load "$@"
+}
+
+reset_cb() {
+ config_cb() { return 0; }
+ option_cb() { return 0; }
+ list_cb() { return 0; }
+}
+reset_cb
+
+package() {
+ return 0
+}
+
+config () {
+ local cfgtype="$1"
+ local name="$2"
+
+ export ${NO_EXPORT:+-n} CONFIG_NUM_SECTIONS=$(($CONFIG_NUM_SECTIONS + 1))
+ name="${name:-cfg$CONFIG_NUM_SECTIONS}"
+ append CONFIG_SECTIONS "$name"
+ [ -n "$NO_CALLBACK" ] || config_cb "$cfgtype" "$name"
+ export ${NO_EXPORT:+-n} CONFIG_SECTION="$name"
+ export ${NO_EXPORT:+-n} "CONFIG_${CONFIG_SECTION}_TYPE=$cfgtype"
+}
+
+option () {
+ local varname="$1"; shift
+ local value="$*"
+
+ export ${NO_EXPORT:+-n} "CONFIG_${CONFIG_SECTION}_${varname}=$value"
+ [ -n "$NO_CALLBACK" ] || option_cb "$varname" "$*"
+}
+
+list() {
+ local varname="$1"; shift
+ local value="$*"
+ local len
+
+ config_get len "$CONFIG_SECTION" "${varname}_LENGTH" 0
+ [ $len = 0 ] && append CONFIG_LIST_STATE "${CONFIG_SECTION}_${varname}"
+ len=$(($len + 1))
+ config_set "$CONFIG_SECTION" "${varname}_ITEM$len" "$value"
+ config_set "$CONFIG_SECTION" "${varname}_LENGTH" "$len"
+ append "CONFIG_${CONFIG_SECTION}_${varname}" "$value" "$LIST_SEP"
+ list_cb "$varname" "$*"
+}
+
+config_rename() {
+ local OLD="$1"
+ local NEW="$2"
+ local oldvar
+ local newvar
+
+ [ -n "$OLD" -a -n "$NEW" ] || return
+ for oldvar in `set | grep ^CONFIG_${OLD}_ | \
+ sed -e 's/\(.*\)=.*$/\1/'` ; do
+ newvar="CONFIG_${NEW}_${oldvar##CONFIG_${OLD}_}"
+ eval "export ${NO_EXPORT:+-n} \"$newvar=\${$oldvar}\""
+ unset "$oldvar"
+ done
+ export ${NO_EXPORT:+-n} CONFIG_SECTIONS="$(echo " $CONFIG_SECTIONS " | sed -e "s, $OLD , $NEW ,")"
+
+ [ "$CONFIG_SECTION" = "$OLD" ] && export ${NO_EXPORT:+-n} CONFIG_SECTION="$NEW"
+}
+
+config_unset() {
+ config_set "$1" "$2" ""
+}
+
+config_clear() {
+ local SECTION="$1"
+ local oldvar
+
+ list_remove CONFIG_SECTIONS "$SECTION"
+ export ${NO_EXPORT:+-n} CONFIG_SECTIONS="${SECTION:+$CONFIG_SECTIONS}"
+
+ for oldvar in `set | grep ^CONFIG_${SECTION:+${SECTION}_} | \
+ sed -e 's/\(.*\)=.*$/\1/'` ; do
+ unset $oldvar
+ done
+}
+
+# config_get <variable> <section> <option> [<default>]
+# config_get <section> <option>
+config_get() {
+ case "$3" in
+ "") eval echo "\${CONFIG_${1}_${2}:-\${4}}";;
+ *) eval export ${NO_EXPORT:+-n} -- "${1}=\${CONFIG_${2}_${3}:-\${4}}";;
+ esac
+}
+
+# config_get_bool <variable> <section> <option> [<default>]
+config_get_bool() {
+ local _tmp
+ config_get _tmp "$2" "$3" "$4"
+ case "$_tmp" in
+ 1|on|true|enabled) _tmp=1;;
+ 0|off|false|disabled) _tmp=0;;
+ *) _tmp="$4";;
+ esac
+ export ${NO_EXPORT:+-n} "$1=$_tmp"
+}
+
+config_set() {
+ local section="$1"
+ local option="$2"
+ local value="$3"
+ local old_section="$CONFIG_SECTION"
+
+ CONFIG_SECTION="$section"
+ option "$option" "$value"
+ CONFIG_SECTION="$old_section"
+}
+
+config_foreach() {
+ local ___function="$1"
+ [ "$#" -ge 1 ] && shift
+ local ___type="$1"
+ [ "$#" -ge 1 ] && shift
+ local section cfgtype
+
+ [ -z "$CONFIG_SECTIONS" ] && return 0
+ for section in ${CONFIG_SECTIONS}; do
+ config_get cfgtype "$section" TYPE
+ [ -n "$___type" -a "x$cfgtype" != "x$___type" ] && continue
+ eval "$___function \"\$section\" \"\$@\""
+ done
+}
+
+config_list_foreach() {
+ [ "$#" -ge 3 ] || return 0
+ local section="$1"; shift
+ local option="$1"; shift
+ local function="$1"; shift
+ local val
+ local len
+ local c=1
+
+ config_get len "${section}" "${option}_LENGTH"
+ [ -z "$len" ] && return 0
+ while [ $c -le "$len" ]; do
+ config_get val "${section}" "${option}_ITEM$c"
+ eval "$function \"\$val\" \"\$@\""
+ c="$(($c + 1))"
+ done
+}
+
+load_modules() {
+ [ -d /etc/modules.d ] && {
+ cd /etc/modules.d
+ sed 's/^[^#]/insmod &/' $* | ash 2>&- || :
+ }
+}
+
+include() {
+ local file
+
+ for file in $(ls $1/*.sh 2>/dev/null); do
+ . $file
+ done
+}
+
+find_mtd_index() {
+ local PART="$(grep "\"$1\"" /proc/mtd | awk -F: '{print $1}')"
+ local INDEX="${PART##mtd}"
+
+ echo ${INDEX}
+}
+
+find_mtd_part() {
+ local INDEX=$(find_mtd_index "$1")
+ local PREFIX=/dev/mtdblock
+
+ [ -d /dev/mtdblock ] && PREFIX=/dev/mtdblock/
+ echo "${INDEX:+$PREFIX$INDEX}"
+}
+
+find_mtd_chardev() {
+ local INDEX=$(find_mtd_index "$1")
+ local PREFIX=/dev/mtd
+
+ [ -d /dev/mtd ] && PREFIX=/dev/mtd/
+ echo "${INDEX:+$PREFIX$INDEX}"
+}
+
+mtd_get_mac_ascii()
+{
+ local mtdname="$1"
+ local key="$2"
+ local part
+ local mac_dirty
+
+ . /lib/functions.sh
+
+ part=$(find_mtd_part "$mtdname")
+ if [ -z "$part" ]; then
+ echo "mtd_get_mac_ascii: partition $mtdname not found!" >&2
+ return
+ fi
+
+ mac_dirty=$(strings "$part" | sed -n 's/'"$key"'=//p')
+ # "canonicalize" mac
+ printf "%02x:%02x:%02x:%02x:%02x:%02x" 0x${mac_dirty//:/ 0x}
+}
+
+mtd_get_mac_binary() {
+ local mtdname="$1"
+ local offset="$2"
+ local part
+
+ part=$(find_mtd_part "$mtdname")
+ if [ -z "$part" ]; then
+ echo "mtd_get_mac_binary: partition $mtdname not found!" >&2
+ return
+ fi
+
+ dd bs=1 skip=$offset count=6 if=$part 2>/dev/null | hexdump -v -n 6 -e '5/1 "%02x:" 1/1 "%02x"'
+}
+
+macaddr_add() {
+ local mac=$1
+ local val=$2
+ local oui=${mac%:*:*:*}
+ local nic=${mac#*:*:*:}
+
+ nic=$(printf "%06x" $((0x${nic//:/} + $val & 0xffffff)) | sed 's/^\(.\{2\}\)\(.\{2\}\)\(.\{2\}\)/\1:\2:\3/')
+ echo $oui:$nic
+}
+
+macaddr_setbit_la()
+{
+ local mac=$1
+
+ printf "%02x:%s" $((0x${mac%%:*} | 0x02)) ${mac#*:}
+}
+
+macaddr_2bin()
+{
+ local mac=$1
+
+ echo -ne \\x${mac//:/\\x}
+}
+
+strtok() { # <string> { <variable> [<separator>] ... }
+ local tmp
+ local val="$1"
+ local count=0
+
+ shift
+
+ while [ $# -gt 1 ]; do
+ tmp="${val%%$2*}"
+
+ [ "$tmp" = "$val" ] && break
+
+ val="${val#$tmp$2}"
+
+ export ${NO_EXPORT:+-n} "$1=$tmp"; count=$((count+1))
+ shift 2
+ done
+
+ if [ $# -gt 0 -a -n "$val" ]; then
+ export ${NO_EXPORT:+-n} "$1=$val"; count=$((count+1))
+ fi
+
+ return $count
+}
+
+
+jffs2_mark_erase() {
+ local part="$(find_mtd_part "$1")"
+ [ -z "$part" ] && {
+ echo Partition not found.
+ return 1
+ }
+ echo -e "\xde\xad\xc0\xde" | mtd -qq write - "$1"
+}
+
+uci_apply_defaults() {
+ cd /etc/uci-defaults || return 0
+ files="$(ls)"
+ [ -z "$files" ] && return 0
+ mkdir -p /tmp/.uci
+ for file in $files; do
+ ( . "./$(basename $file)" ) && rm -f "$file"
+ done
+ uci commit
+}
+
+group_add() {
+ local name="$1"
+ local gid="$2"
+ local rc
+ [ -f "${IPKG_INSTROOT}/etc/group" ] || return 1
+ [ -n "$IPKG_INSTROOT" ] || lock /var/lock/group
+ echo "${name}:x:${gid}:" >> ${IPKG_INSTROOT}/etc/group
+ rc=$?
+ [ -n "$IPKG_INSTROOT" ] || lock -u /var/lock/group
+ return $rc
+}
+
+group_exists() {
+ grep -qs "^${1}:" ${IPKG_INSTROOT}/etc/group
+}
+
+user_add() {
+ local name="${1}"
+ local uid="${2}"
+ local gid="${3:-$2}"
+ local desc="${4:-$1}"
+ local home="${5:-/var/run/$1}"
+ local shell="${6:-/bin/false}"
+ local rc
+ [ -f "${IPKG_INSTROOT}/etc/passwd" ] || return 1
+ [ -n "$IPKG_INSTROOT" ] || lock /var/lock/passwd
+ echo "${name}:x:${uid}:${gid}:${desc}:${home}:${shell}" >> ${IPKG_INSTROOT}/etc/passwd
+ echo "${name}:x:0:0:99999:7:::" >> ${IPKG_INSTROOT}/etc/shadow
+ rc=$?
+ [ -n "$IPKG_INSTROOT" ] || lock -u /var/lock/passwd
+ return $rc
+}
+
+user_exists() {
+ grep -qs "^${1}:" ${IPKG_INSTROOT}/etc/passwd
+}
+
+
+pi_include() {
+ if [ -f "/tmp/overlay/$1" ]; then
+ . "/tmp/overlay/$1"
+ elif [ -f "$1" ]; then
+ . "$1"
+ elif [ -d "/tmp/overlay/$1" ]; then
+ if [ -n "$(ls /tmp/overlay/$1/*.sh 2>/dev/null)" ]; then
+ for src_script in /tmp/overlay/$1/*.sh; do
+ . "$src_script"
+ done
+ fi
+ elif [ -d "$1" ]; then
+ if [ -n "$(ls $1/*.sh 2>/dev/null)" ]; then
+ for src_script in $1/*.sh; do
+ . "$src_script"
+ done
+ fi
+ else
+ echo "WARNING: $1 not found"
+ return 1
+ fi
+ return 0
+}
+
+boot_hook_splice_start() {
+ export -n PI_HOOK_SPLICE=1
+}
+
+boot_hook_splice_finish() {
+ local hook
+ for hook in $PI_STACK_LIST; do
+ local v; eval "v=\${${hook}_splice:+\$${hook}_splice }$hook"
+ export -n "${hook}=${v% }"
+ export -n "${hook}_splice="
+ done
+ export -n PI_HOOK_SPLICE=
+}
+
+boot_hook_init() {
+ local hook="${1}_hook"
+ export -n "PI_STACK_LIST=${PI_STACK_LIST:+$PI_STACK_LIST }$hook"
+ export -n "$hook="
+}
+
+boot_hook_add() {
+ local hook="${1}_hook${PI_HOOK_SPLICE:+_splice}"
+ local func="${2}"
+
+ [ -n "$func" ] && {
+ local v; eval "v=\$$hook"
+ export -n "$hook=${v:+$v }$func"
+ }
+}
+
+boot_hook_shift() {
+ local hook="${1}_hook"
+ local rvar="${2}"
+
+ local v; eval "v=\$$hook"
+ [ -n "$v" ] && {
+ local first="${v%% *}"
+
+ [ "$v" != "${v#* }" ] && \
+ export -n "$hook=${v#* }" || \
+ export -n "$hook="
+
+ export -n "$rvar=$first"
+ return 0
+ }
+
+ return 1
+}
+
+boot_run_hook() {
+ local hook="$1"
+ local func
+
+ while boot_hook_shift "$hook" func; do
+ local ran; eval "ran=\$PI_RAN_$func"
+ [ -n "$ran" ] || {
+ export -n "PI_RAN_$func=1"
+ $func "$1" "$2"
+ }
+ done
+}
+
+jffs2_ready() {
+ mtdpart="$(find_mtd_part rootfs_data)"
+ [ -z "$mtdpart" ] && return 1
+ magic=$(hexdump $mtdpart -n 4 -e '4/1 "%02x"')
+ [ "$magic" != "deadc0de" ]
+}
+
+dupe() { # <new_root> <old_root>
+ cd $1
+ echo -n "creating directories... "
+ {
+ cd $2
+ find . -xdev -type d
+ echo "./dev ./overlay ./mnt ./proc ./tmp"
+ # xdev skips mounted directories
+ cd $1
+ } | xargs mkdir -p
+ echo "done"
+
+ echo -n "setting up symlinks... "
+ for file in $(cd $2; find . -xdev -type f;); do
+ case "$file" in
+ ./rom/note) ;; #nothing
+ ./etc/config*|\
+ ./usr/lib/opkg/info/*) cp -af $2/$file $file;;
+ *) ln -sf /rom/${file#./*} $file;;
+ esac
+ done
+ for file in $(cd $2; find . -xdev -type l;); do
+ cp -af $2/${file#./*} $file
+ done
+ echo "done"
+}
+
+pivot() { # <new_root> <old_root>
+ mount -o noatime,move /proc $1/proc && \
+ pivot_root $1 $1$2 && {
+ mount -o noatime,move $2/dev /dev
+ mount -o noatime,move $2/tmp /tmp
+ mount -o noatime,move $2/sys /sys 2>&-
+ mount -o noatime,move $2/overlay /overlay 2>&-
+ return 0
+ }
+}
+
+fopivot() { # <rw_root> <ro_root> <dupe?>
+ root=$1
+ {
+ if grep -q overlay /proc/filesystems; then
+ mount -o noatime,lowerdir=/,upperdir=$1 -t overlayfs "overlayfs:$1" /mnt && root=/mnt
+ elif grep -q mini_fo /proc/filesystems; then
+ mount -t mini_fo -o noatime,base=/,sto=$1 "mini_fo:$1" /mnt 2>&- && root=/mnt
+ else
+ mount --bind -o noatime / /mnt
+ mount --bind -o noatime,union "$1" /mnt && root=/mnt
+ fi
+ } || {
+ [ "$3" = "1" ] && {
+ mount | grep "on $1 type" 2>&- 1>&- || mount -o noatime,bind $1 $1
+ dupe $1 $rom
+ }
+ }
+ pivot $root $2
+}
+
+ramoverlay() {
+ mkdir -p /tmp/root
+ mount -t tmpfs -o noatime,mode=0755 root /tmp/root
+ fopivot /tmp/root /rom 1
+}
+
+[ -z "$IPKG_INSTROOT" -a -f /lib/config/uci.sh ] && . /lib/config/uci.sh
diff --git a/package/base-files/files/lib/functions/.svn/entries b/package/base-files/files/lib/functions/.svn/entries
new file mode 100644
index 0000000..be2fb75
--- /dev/null
+++ b/package/base-files/files/lib/functions/.svn/entries
@@ -0,0 +1,164 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/base-files/files/lib/functions
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-02-18T09:56:23.456396Z
+35648
+juhosg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+leds.sh
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+4d196ba7aab9d848e0da8505d8c20ffb
+2013-02-18T09:56:23.456396Z
+35648
+juhosg
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1274
+
+network.sh
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+2eb07029c2d3f87fbb517a87ef1f1a4e
+2013-01-22T16:47:16.091518Z
+35300
+cyrus
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+7941
+
+service.sh
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+cffa973cb0e71e1d12967d843ee92179
+2012-03-20T14:29:50.022402Z
+31042
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3488
+
+uci-defaults.sh
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+dd38ca259ffd0916168f7869ebff55e8
+2012-08-13T14:01:37.239528Z
+33164
+juhosg
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4252
+
diff --git a/package/base-files/files/lib/functions/.svn/prop-base/leds.sh.svn-base b/package/base-files/files/lib/functions/.svn/prop-base/leds.sh.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/base-files/files/lib/functions/.svn/prop-base/leds.sh.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/base-files/files/lib/functions/.svn/prop-base/uci-defaults.sh.svn-base b/package/base-files/files/lib/functions/.svn/prop-base/uci-defaults.sh.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/base-files/files/lib/functions/.svn/prop-base/uci-defaults.sh.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/base-files/files/lib/functions/.svn/text-base/leds.sh.svn-base b/package/base-files/files/lib/functions/.svn/text-base/leds.sh.svn-base
new file mode 100644
index 0000000..743c7da
--- /dev/null
+++ b/package/base-files/files/lib/functions/.svn/text-base/leds.sh.svn-base
@@ -0,0 +1,68 @@
+#!/bin/sh
+# Copyright (C) 2013 OpenWrt.org
+
+led_set_attr() {
+ [ -f "/sys/class/leds/$1/$2" ] && echo "$3" > "/sys/class/leds/$1/$2"
+}
+
+led_timer() {
+ led_set_attr $1 "trigger" "timer"
+ led_set_attr $1 "delay_on" "$2"
+ led_set_attr $1 "delay_off" "$3"
+}
+
+led_on() {
+ led_set_attr $1 "trigger" "none"
+ led_set_attr $1 "brightness" 255
+}
+
+led_off() {
+ led_set_attr $1 "trigger" "none"
+ led_set_attr $1 "brightness" 0
+}
+
+led_morse() {
+ led_set_attr $1 "trigger" "morse"
+ led_set_attr $1 "delay" "$2"
+ led_set_attr $1 "message" "$3"
+}
+
+status_led_set_timer() {
+ led_timer $status_led "$1" "$2"
+ [ -n "$status_led2" ] && led_timer $status_led2 "$1" "$2"
+}
+
+status_led_set_heartbeat() {
+ led_set_attr $status_led "trigger" "heartbeat"
+}
+
+status_led_set_morse() {
+ led_morse $status_led "$1" "$2"
+ [ -n "$status_led2" ] && led_morse $status_led2 "$1" "$2"
+}
+
+status_led_on() {
+ led_on $status_led
+ [ -n "$status_led2" ] && led_on $status_led2
+}
+
+status_led_off() {
+ led_off $status_led
+ [ -n "$status_led2" ] && led_off $status_led2
+}
+
+status_led_blink_slow() {
+ led_timer $status_led 1000 1000
+}
+
+status_led_blink_fast() {
+ led_timer $status_led 100 100
+}
+
+status_led_blink_preinit() {
+ led_timer $status_led 200 200
+}
+
+status_led_blink_failsafe() {
+ led_timer $status_led 50 50
+}
diff --git a/package/base-files/files/lib/functions/.svn/text-base/network.sh.svn-base b/package/base-files/files/lib/functions/.svn/text-base/network.sh.svn-base
new file mode 100644
index 0000000..369fa3d
--- /dev/null
+++ b/package/base-files/files/lib/functions/.svn/text-base/network.sh.svn-base
@@ -0,0 +1,350 @@
+. /usr/share/libubox/jshn.sh
+
+__network_set_cache()
+{
+ if [ -n "$3" ]; then
+ eval "export -- __NETWORK_CV_$1='$3'"
+ __NETWORK_CACHE="${__NETWORK_CACHE:+$__NETWORK_CACHE }__NETWORK_CV_$1"
+ elif json_get_var "__NETWORK_CV_$1" "$2"; then
+ __NETWORK_CACHE="${__NETWORK_CACHE:+$__NETWORK_CACHE }__NETWORK_CV_$1"
+ fi
+}
+
+__network_export()
+{
+ local __v="__NETWORK_CV_$2"
+ eval "export -- \"$1=\${$__v:+\$$__v$3}\"; [ -n \"\${$__v+x}\" ]"
+}
+
+__network_parse_ifstatus()
+{
+ local __iface="$1"
+ local __key="${__iface}"
+ local __tmp
+ local __old_ns
+
+ __network_export __tmp "${__key}__parsed" && return 0
+ __tmp="$(ubus call network.interface."$__iface" status 2>/dev/null)"
+ [ -n "$__tmp" ] || return 1
+
+ json_set_namespace "network" __old_ns
+ json_load "$__tmp"
+
+ __network_set_cache "${__key}__parsed" "" "1"
+
+ for __tmp in "" "_inactive"; do
+
+ __key="${__key}${__tmp}"
+
+ # parse addresses
+ local __family
+ for __family in 4 6; do
+ if json_is_a "ipv${__family}_address" array; then
+
+ json_select "ipv${__family}_address"
+
+ if json_is_a 1 object; then
+
+ json_select 1
+ __network_set_cache "${__key}_address${__family}" address
+ __network_set_cache "${__key}_mask${__family}" mask
+ json_select ".."
+
+ fi
+
+ json_select ".."
+
+ fi
+ done
+
+ # parse prefixes
+ if json_is_a "ipv6_prefix" array; then
+ json_select "ipv6_prefix"
+
+ if json_is_a 1 object; then
+ json_select 1
+ __network_set_cache "${__key}_prefix6_address" address
+ __network_set_cache "${__key}_prefix6_mask" mask
+ json_select ".."
+ fi
+
+ json_select ".."
+ fi
+
+ # parse routes
+ if json_is_a route array; then
+
+ json_select "route"
+
+ local __idx=1
+ while json_is_a "$__idx" object; do
+
+ json_select "$((__idx++))"
+ json_get_var __tmp target
+
+ case "${__tmp}" in
+ 0.0.0.0)
+ __network_set_cache "${__key}_gateway4" nexthop
+ ;;
+ ::)
+ __network_set_cache "${__key}_gateway6" nexthop
+ ;;
+ esac
+
+ json_select ".."
+
+ done
+
+ json_select ".."
+
+ fi
+
+ # parse dns info
+ local __field
+ for __field in "dns_server" "dns_search"; do
+ if json_is_a "$__field" array; then
+
+ json_select "$__field"
+
+ local __idx=1
+ local __dns=""
+
+ while json_is_a "$__idx" string; do
+
+ json_get_var __tmp "$((__idx++))"
+ __dns="${__dns:+$__dns }$__tmp"
+
+ done
+
+ json_select ".."
+
+ if [ -n "$__dns" ]; then
+ __network_set_cache "${__key}_${__field}" "" "$__dns"
+ fi
+ fi
+ done
+
+ # parse up state, device and physdev
+ for __field in "up" "l3_device" "device"; do
+ if json_get_type __tmp "$__field"; then
+ __network_set_cache "${__key}_${__field}" "$__field"
+ fi
+ done
+
+ # descend into inactive table
+ json_is_a "inactive" object && json_select "inactive"
+
+ done
+
+ json_cleanup
+ json_set_namespace "$__old_ns"
+
+ return 0
+}
+
+
+__network_ipaddr()
+{
+ local __var="$1"
+ local __iface="$2"
+ local __family="$3"
+ local __prefix="$4"
+ local __tmp
+
+ __network_parse_ifstatus "$__iface" || return 1
+
+ if [ $__prefix -eq 1 ]; then
+ __network_export __tmp "${__iface}_mask${__family}" && \
+ __network_export "$__var" "${__iface}_address${__family}" "/$__tmp"
+ return $?
+ fi
+
+ __network_export "$__var" "${__iface}_address${__family}"
+ return $?
+
+}
+
+# determine IPv4 address of given logical interface
+# 1: destination variable
+# 2: interface
+network_get_ipaddr() { __network_ipaddr "$1" "$2" 4 0; }
+
+# determine IPv6 address of given logical interface
+# 1: destination variable
+# 2: interface
+network_get_ipaddr6() { __network_ipaddr "$1" "$2" 6 0; }
+
+# determine IPv4 subnet of given logical interface
+# 1: destination variable
+# 2: interface
+network_get_subnet() { __network_ipaddr "$1" "$2" 4 1; }
+
+# determine IPv6 subnet of given logical interface
+# 1: destination variable
+# 2: interface
+network_get_subnet6() { __network_ipaddr "$1" "$2" 6 1; }
+
+# determine IPv6 prefix
+network_get_prefix6() {
+ local __var="$1"
+ local __iface="$2"
+ local __address
+ local __mask
+
+ __network_parse_ifstatus "$__iface" || return 1
+ __network_export __mask "${__iface}_prefix6_mask" || return 1
+ __network_export "$__var" "${__iface}_prefix6_address" "/$__mask"
+ return $?
+}
+
+
+__network_gateway()
+{
+ local __var="$1"
+ local __iface="$2"
+ local __family="$3"
+ local __inactive="$4"
+
+ __network_parse_ifstatus "$__iface" || return 1
+
+ if [ "$__inactive" = 1 -o "$__inactive" = "true" ]; then
+ __network_export "$__var" "${__iface}_inactive_gateway${__family}" && \
+ return 0
+ fi
+
+ __network_export "$__var" "${__iface}_gateway${__family}"
+ return $?
+}
+
+# determine IPv4 gateway of given logical interface
+# 1: destination variable
+# 2: interface
+# 3: consider inactive gateway if "true" (optional)
+network_get_gateway() { __network_gateway "$1" "$2" 4 "${3:-0}"; }
+
+# determine IPv6 gateway of given logical interface
+# 1: destination variable
+# 2: interface
+# 3: consider inactive gateway if "true" (optional)
+network_get_gateway6() { __network_gateway "$1" "$2" 6 "${3:-0}"; }
+
+
+__network_dns() {
+ local __var="$1"
+ local __iface="$2"
+ local __field="$3"
+ local __inactive="$4"
+
+ __network_parse_ifstatus "$__iface" || return 1
+
+ if [ "$__inactive" = 1 -o "$__inactive" = "true" ]; then
+ __network_export "$__var" "${__iface}_inactive_${__field}" && \
+ return 0
+ fi
+
+ __network_export "$__var" "${__iface}_${__field}"
+ return $?
+}
+
+# determine the DNS servers of the given logical interface
+# 1: destination variable
+# 2: interface
+# 3: consider inactive servers if "true" (optional)
+network_get_dnsserver() { __network_dns "$1" "$2" dns_server "${3:-0}"; }
+
+# determine the domains of the given logical interface
+# 1: destination variable
+# 2: interface
+# 3: consider inactive domains if "true" (optional)
+network_get_dnssearch() { __network_dns "$1" "$2" dns_search "${3:-0}"; }
+
+
+__network_wan()
+{
+ local __var="$1"
+ local __family="$2"
+ local __inactive="$3"
+ local __iface
+
+ for __iface in $(ubus list | sed -ne 's/^network\.interface\.//p'); do
+ if [ "$__iface" != loopback ]; then
+ if __network_gateway "$__var" "$__iface" "$__family" "$__inactive"; then
+ eval "export -- \"$__var=$__iface\""
+ return 0
+ fi
+ fi
+ done
+
+ eval "export -- \"$__var=\""
+ return 1
+}
+
+# find the logical interface which holds the current IPv4 default route
+# 1: destination variable
+# 2: consider inactive default routes if "true" (optional)
+network_find_wan() { __network_wan "$1" 4 "${2:-0}"; }
+
+# find the logical interface which holds the current IPv6 default route
+# 1: destination variable
+# 2: consider inactive dafault routes if "true" (optional)
+network_find_wan6() { __network_wan "$1" 6 "${2:-0}"; }
+
+
+__network_device()
+{
+ local __var="$1"
+ local __iface="$2"
+ local __field="$3"
+
+ __network_parse_ifstatus "$__iface" || return 1
+ __network_export "$__var" "${__iface}_${__field}"
+ return $?
+}
+
+# test whether the given logical interface is running
+# 1: interface
+network_is_up()
+{
+ local __up
+ __network_device __up "$1" up && [ $__up -eq 1 ]
+}
+
+# determine the layer 3 linux network device of the given logical interface
+# 1: destination variable
+# 2: interface
+network_get_device() { __network_device "$1" "$2" l3_device; }
+
+# determine the layer 2 linux network device of the given logical interface
+# 1: destination variable
+# 2: interface
+network_get_physdev() { __network_device "$1" "$2" device; }
+
+
+__network_defer()
+{
+ local __device="$1"
+ local __defer="$2"
+
+ json_init
+ json_add_string name "$__device"
+ json_add_boolean defer "$__defer"
+
+ ubus call network.device set_state "$(json_dump)" 2>/dev/null
+}
+
+# defer netifd actions on the given linux network device
+# 1: device name
+network_defer_device() { __network_defer "$1" 1; }
+
+# continue netifd actions on the given linux network device
+# 1: device name
+network_ready_device() { __network_defer "$1" 0; }
+
+# flush the internal value cache to force re-reading values from ubus
+network_flush_cache()
+{
+ local __tmp
+ for __tmp in $__NETWORK_CACHE __NETWORK_CACHE; do
+ unset "$__tmp"
+ done
+}
diff --git a/package/base-files/files/lib/functions/.svn/text-base/service.sh.svn-base b/package/base-files/files/lib/functions/.svn/text-base/service.sh.svn-base
new file mode 100644
index 0000000..cbb717d
--- /dev/null
+++ b/package/base-files/files/lib/functions/.svn/text-base/service.sh.svn-base
@@ -0,0 +1,129 @@
+#
+# service: simple wrapper around start-stop-daemon
+#
+# Usage: service ACTION EXEC ARGS...
+#
+# Action:
+# -C check if EXEC is alive
+# -S start EXEC, passing it ARGS as its arguments
+# -K kill EXEC, sending it a TERM signal if not specified otherwise
+#
+# Environment variables exposed:
+# SERVICE_DAEMONIZE run EXEC in background
+# SERVICE_WRITE_PID create a pid-file and use it for matching
+# SERVICE_MATCH_EXEC use EXEC command-line for matching (default)
+# SERVICE_MATCH_NAME use EXEC process name for matching
+# SERVICE_USE_PID assume EXEC create its own pid-file and use it for matching
+# SERVICE_NAME process name to use (default to EXEC file part)
+# SERVICE_PID_FILE pid file to use (default to /var/run/$SERVICE_NAME.pid)
+# SERVICE_SIG signal to send when using -K
+# SERVICE_SIG_RELOAD default signal used when reloading
+# SERVICE_SIG_STOP default signal used when stopping
+# SERVICE_STOP_TIME time to wait for a process to stop gracefully before killing it
+# SERVICE_UID user EXEC should be run as
+# SERVICE_GID group EXEC should be run as
+#
+# SERVICE_DEBUG don't do anything, but show what would be done
+# SERVICE_QUIET don't print anything
+#
+
+SERVICE_QUIET=1
+SERVICE_SIG_RELOAD="HUP"
+SERVICE_SIG_STOP="TERM"
+SERVICE_STOP_TIME=5
+SERVICE_MATCH_EXEC=1
+
+service() {
+ local ssd
+ local exec
+ local name
+ local start
+ ssd="${SERVICE_DEBUG:+echo }start-stop-daemon${SERVICE_QUIET:+ -q}"
+ case "$1" in
+ -C)
+ ssd="$ssd -K -t"
+ ;;
+ -S)
+ ssd="$ssd -S${SERVICE_DAEMONIZE:+ -b}${SERVICE_WRITE_PID:+ -m}"
+ start=1
+ ;;
+ -K)
+ ssd="$ssd -K${SERVICE_SIG:+ -s $SERVICE_SIG}"
+ ;;
+ *)
+ echo "service: unknown ACTION '$1'" 1>&2
+ return 1
+ esac
+ shift
+ exec="$1"
+ [ -n "$exec" ] || {
+ echo "service: missing argument" 1>&2
+ return 1
+ }
+ [ -x "$exec" ] || {
+ echo "service: file '$exec' is not executable" 1>&2
+ return 1
+ }
+ name="${SERVICE_NAME:-${exec##*/}}"
+ [ -z "$SERVICE_USE_PID$SERVICE_WRITE_PID$SERVICE_PID_FILE" ] \
+ || ssd="$ssd -p ${SERVICE_PID_FILE:-/var/run/$name.pid}"
+ [ -z "$SERVICE_MATCH_NAME" ] || ssd="$ssd -n $name"
+ ssd="$ssd${SERVICE_UID:+ -c $SERVICE_UID${SERVICE_GID:+:$SERVICE_GID}}"
+ [ -z "$SERVICE_MATCH_EXEC$start" ] || ssd="$ssd -x $exec"
+ shift
+ $ssd${1:+ -- "$@"}
+}
+
+service_check() {
+ service -C "$@"
+}
+
+service_signal() {
+ SERVICE_SIG="${SERVICE_SIG:-USR1}" service -K "$@"
+}
+
+service_start() {
+ service -S "$@"
+}
+
+service_stop() {
+ local try
+ SERVICE_SIG="${SERVICE_SIG:-$SERVICE_SIG_STOP}" service -K "$@" || return 1
+ while [ $((try++)) -lt $SERVICE_STOP_TIME ]; do
+ service -C "$@" || return 0
+ sleep 1
+ done
+ SERVICE_SIG="KILL" service -K "$@"
+ sleep 1
+ ! service -C "$@"
+}
+
+service_reload() {
+ SERVICE_SIG="${SERVICE_SIG:-$SERVICE_SIG_RELOAD}" service -K "$@"
+}
+
+service_kill() {
+ cat 1>&2 << __END_OF_WARNING__
+#
+# WARNING: the 'service_kill' function is now deprecated and might be
+# removed soon. Consider using the other new service_* wrappers instead.
+#
+__END_OF_WARNING__
+ local name="${1}"
+ local pid="${2:-$(pidof "$name")}"
+ local grace="${3:-5}"
+
+ [ -f "$pid" ] && pid="$(head -n1 "$pid" 2>/dev/null)"
+
+ for pid in $pid; do
+ [ -d "/proc/$pid" ] || continue
+ local try=0
+ kill -TERM $pid 2>/dev/null && \
+ while grep -qs "$name" "/proc/$pid/cmdline" && [ $((try++)) -lt $grace ]; do sleep 1; done
+ kill -KILL $pid 2>/dev/null && \
+ while grep -qs "$name" "/proc/$pid/cmdline"; do sleep 1; done
+ done
+}
+
+
+
diff --git a/package/base-files/files/lib/functions/.svn/text-base/uci-defaults.sh.svn-base b/package/base-files/files/lib/functions/.svn/text-base/uci-defaults.sh.svn-base
new file mode 100644
index 0000000..477c00c
--- /dev/null
+++ b/package/base-files/files/lib/functions/.svn/text-base/uci-defaults.sh.svn-base
@@ -0,0 +1,230 @@
+#!/bin/sh
+# Copyright (C) 2011 OpenWrt.org
+
+UCIDEF_LEDS_CHANGED=0
+
+ucidef_set_led_netdev() {
+ local cfg="led_$1"
+ local name=$2
+ local sysfs=$3
+ local dev=$4
+
+ uci -q get system.$cfg && return 0
+
+ uci batch <<EOF
+set system.$cfg='led'
+set system.$cfg.name='$name'
+set system.$cfg.sysfs='$sysfs'
+set system.$cfg.trigger='netdev'
+set system.$cfg.dev='$dev'
+set system.$cfg.mode='link tx rx'
+EOF
+ UCIDEF_LEDS_CHANGED=1
+}
+
+ucidef_set_led_usbdev() {
+ local cfg="led_$1"
+ local name=$2
+ local sysfs=$3
+ local dev=$4
+
+ uci -q get system.$cfg && return 0
+
+ uci batch <<EOF
+set system.$cfg='led'
+set system.$cfg.name='$name'
+set system.$cfg.sysfs='$sysfs'
+set system.$cfg.trigger='usbdev'
+set system.$cfg.dev='$dev'
+set system.$cfg.interval='50'
+EOF
+ UCIDEF_LEDS_CHANGED=1
+}
+
+ucidef_set_led_wlan() {
+ local cfg="led_$1"
+ local name=$2
+ local sysfs=$3
+ local trigger=$4
+
+ uci -q get system.$cfg && return 0
+
+ uci batch <<EOF
+set system.$cfg='led'
+set system.$cfg.name='$name'
+set system.$cfg.sysfs='$sysfs'
+set system.$cfg.trigger='$trigger'
+EOF
+ UCIDEF_LEDS_CHANGED=1
+}
+
+ucidef_set_led_switch() {
+ local cfg="led_$1"
+ local name=$2
+ local sysfs=$3
+ local trigger=$4
+ local port_mask=$5
+
+ uci -q get system.$cfg && return 0
+
+ uci batch <<EOF
+set system.$cfg='led'
+set system.$cfg.name='$name'
+set system.$cfg.sysfs='$sysfs'
+set system.$cfg.trigger='$trigger'
+set system.$cfg.port_mask='$port_mask'
+EOF
+ UCIDEF_LEDS_CHANGED=1
+}
+
+ucidef_set_led_default() {
+ local cfg="led_$1"
+ local name=$2
+ local sysfs=$3
+ local default=$4
+
+ uci -q get system.$cfg && return 0
+
+ uci batch <<EOF
+set system.$cfg='led'
+set system.$cfg.name='$name'
+set system.$cfg.sysfs='$sysfs'
+set system.$cfg.default='$default'
+EOF
+ UCIDEF_LEDS_CHANGED=1
+}
+
+ucidef_set_led_rssi() {
+ local cfg="led_$1"
+ local name=$2
+ local sysfs=$3
+ local iface=$4
+ local minq=$5
+ local maxq=$6
+ local offset=$7
+ local factor=$8
+
+ uci -q get system.$cfg && return 0
+
+ uci batch <<EOF
+set system.$cfg='led'
+set system.$cfg.name='$name'
+set system.$cfg.sysfs='$sysfs'
+set system.$cfg.trigger='rssi'
+set system.$cfg.iface='rssid_$iface'
+set system.$cfg.minq='$minq'
+set system.$cfg.maxq='$maxq'
+set system.$cfg.offset='$offset'
+set system.$cfg.factor='$factor'
+EOF
+ UCIDEF_LEDS_CHANGED=1
+}
+
+ucidef_set_rssimon() {
+ local dev="$1"
+ local refresh="$2"
+ local threshold="$3"
+
+ local cfg="rssid_$dev"
+
+ uci -q get system.$cfg && return 0
+
+ uci batch <<EOF
+set system.$cfg='rssid'
+set system.$cfg.dev='$dev'
+set system.$cfg.refresh='$refresh'
+set system.$cfg.threshold='$threshold'
+EOF
+ UCIDEF_LEDS_CHANGED=1
+}
+
+ucidef_commit_leds()
+{
+ [ "$UCIDEF_LEDS_CHANGED" == "1" ] && uci commit system
+}
+
+ucidef_set_interface_loopback() {
+ uci batch <<EOF
+set network.loopback='interface'
+set network.loopback.ifname='lo'
+set network.loopback.proto='static'
+set network.loopback.ipaddr='127.0.0.1'
+set network.loopback.netmask='255.0.0.0'
+EOF
+}
+
+ucidef_set_interface_raw() {
+ local cfg=$1
+ local ifname=$2
+
+ uci batch <<EOF
+set network.$cfg='interface'
+set network.$cfg.ifname='$ifname'
+set network.$cfg.proto='none'
+EOF
+}
+
+ucidef_set_interface_lan() {
+ local ifname=$1
+
+ uci batch <<EOF
+set network.lan='interface'
+set network.lan.ifname='$ifname'
+set network.lan.type='bridge'
+set network.lan.proto='static'
+set network.lan.ipaddr='192.168.1.1'
+set network.lan.netmask='255.255.255.0'
+EOF
+}
+
+ucidef_set_interface_wan() {
+ local ifname=$1
+
+ uci batch <<EOF
+set network.wan='interface'
+set network.wan.ifname='$ifname'
+set network.wan.proto='dhcp'
+EOF
+}
+
+ucidef_set_interfaces_lan_wan() {
+ local lan_ifname=$1
+ local wan_ifname=$2
+
+ ucidef_set_interface_lan "$lan_ifname"
+ ucidef_set_interface_wan "$wan_ifname"
+}
+
+ucidef_set_interface_macaddr() {
+ local ifname=$1
+ local mac=$2
+
+ uci batch <<EOF
+set network.$ifname.macaddr='$mac'
+EOF
+}
+
+ucidef_add_switch() {
+ local name=$1
+ local reset=$2
+ local enable=$3
+ uci batch <<EOF
+add network switch
+set network.@switch[-1].name='$name'
+set network.@switch[-1].reset='$reset'
+set network.@switch[-1].enable_vlan='$enable'
+EOF
+}
+
+ucidef_add_switch_vlan() {
+ local device=$1
+ local vlan=$2
+ local ports=$3
+ uci batch <<EOF
+add network switch_vlan
+set network.@switch_vlan[-1].device='$device'
+set network.@switch_vlan[-1].vlan='$vlan'
+set network.@switch_vlan[-1].ports='$ports'
+EOF
+}
+
diff --git a/package/base-files/files/lib/functions/leds.sh b/package/base-files/files/lib/functions/leds.sh
new file mode 100644
index 0000000..743c7da
--- /dev/null
+++ b/package/base-files/files/lib/functions/leds.sh
@@ -0,0 +1,68 @@
+#!/bin/sh
+# Copyright (C) 2013 OpenWrt.org
+
+led_set_attr() {
+ [ -f "/sys/class/leds/$1/$2" ] && echo "$3" > "/sys/class/leds/$1/$2"
+}
+
+led_timer() {
+ led_set_attr $1 "trigger" "timer"
+ led_set_attr $1 "delay_on" "$2"
+ led_set_attr $1 "delay_off" "$3"
+}
+
+led_on() {
+ led_set_attr $1 "trigger" "none"
+ led_set_attr $1 "brightness" 255
+}
+
+led_off() {
+ led_set_attr $1 "trigger" "none"
+ led_set_attr $1 "brightness" 0
+}
+
+led_morse() {
+ led_set_attr $1 "trigger" "morse"
+ led_set_attr $1 "delay" "$2"
+ led_set_attr $1 "message" "$3"
+}
+
+status_led_set_timer() {
+ led_timer $status_led "$1" "$2"
+ [ -n "$status_led2" ] && led_timer $status_led2 "$1" "$2"
+}
+
+status_led_set_heartbeat() {
+ led_set_attr $status_led "trigger" "heartbeat"
+}
+
+status_led_set_morse() {
+ led_morse $status_led "$1" "$2"
+ [ -n "$status_led2" ] && led_morse $status_led2 "$1" "$2"
+}
+
+status_led_on() {
+ led_on $status_led
+ [ -n "$status_led2" ] && led_on $status_led2
+}
+
+status_led_off() {
+ led_off $status_led
+ [ -n "$status_led2" ] && led_off $status_led2
+}
+
+status_led_blink_slow() {
+ led_timer $status_led 1000 1000
+}
+
+status_led_blink_fast() {
+ led_timer $status_led 100 100
+}
+
+status_led_blink_preinit() {
+ led_timer $status_led 200 200
+}
+
+status_led_blink_failsafe() {
+ led_timer $status_led 50 50
+}
diff --git a/package/base-files/files/lib/functions/network.sh b/package/base-files/files/lib/functions/network.sh
new file mode 100644
index 0000000..369fa3d
--- /dev/null
+++ b/package/base-files/files/lib/functions/network.sh
@@ -0,0 +1,350 @@
+. /usr/share/libubox/jshn.sh
+
+__network_set_cache()
+{
+ if [ -n "$3" ]; then
+ eval "export -- __NETWORK_CV_$1='$3'"
+ __NETWORK_CACHE="${__NETWORK_CACHE:+$__NETWORK_CACHE }__NETWORK_CV_$1"
+ elif json_get_var "__NETWORK_CV_$1" "$2"; then
+ __NETWORK_CACHE="${__NETWORK_CACHE:+$__NETWORK_CACHE }__NETWORK_CV_$1"
+ fi
+}
+
+__network_export()
+{
+ local __v="__NETWORK_CV_$2"
+ eval "export -- \"$1=\${$__v:+\$$__v$3}\"; [ -n \"\${$__v+x}\" ]"
+}
+
+__network_parse_ifstatus()
+{
+ local __iface="$1"
+ local __key="${__iface}"
+ local __tmp
+ local __old_ns
+
+ __network_export __tmp "${__key}__parsed" && return 0
+ __tmp="$(ubus call network.interface."$__iface" status 2>/dev/null)"
+ [ -n "$__tmp" ] || return 1
+
+ json_set_namespace "network" __old_ns
+ json_load "$__tmp"
+
+ __network_set_cache "${__key}__parsed" "" "1"
+
+ for __tmp in "" "_inactive"; do
+
+ __key="${__key}${__tmp}"
+
+ # parse addresses
+ local __family
+ for __family in 4 6; do
+ if json_is_a "ipv${__family}_address" array; then
+
+ json_select "ipv${__family}_address"
+
+ if json_is_a 1 object; then
+
+ json_select 1
+ __network_set_cache "${__key}_address${__family}" address
+ __network_set_cache "${__key}_mask${__family}" mask
+ json_select ".."
+
+ fi
+
+ json_select ".."
+
+ fi
+ done
+
+ # parse prefixes
+ if json_is_a "ipv6_prefix" array; then
+ json_select "ipv6_prefix"
+
+ if json_is_a 1 object; then
+ json_select 1
+ __network_set_cache "${__key}_prefix6_address" address
+ __network_set_cache "${__key}_prefix6_mask" mask
+ json_select ".."
+ fi
+
+ json_select ".."
+ fi
+
+ # parse routes
+ if json_is_a route array; then
+
+ json_select "route"
+
+ local __idx=1
+ while json_is_a "$__idx" object; do
+
+ json_select "$((__idx++))"
+ json_get_var __tmp target
+
+ case "${__tmp}" in
+ 0.0.0.0)
+ __network_set_cache "${__key}_gateway4" nexthop
+ ;;
+ ::)
+ __network_set_cache "${__key}_gateway6" nexthop
+ ;;
+ esac
+
+ json_select ".."
+
+ done
+
+ json_select ".."
+
+ fi
+
+ # parse dns info
+ local __field
+ for __field in "dns_server" "dns_search"; do
+ if json_is_a "$__field" array; then
+
+ json_select "$__field"
+
+ local __idx=1
+ local __dns=""
+
+ while json_is_a "$__idx" string; do
+
+ json_get_var __tmp "$((__idx++))"
+ __dns="${__dns:+$__dns }$__tmp"
+
+ done
+
+ json_select ".."
+
+ if [ -n "$__dns" ]; then
+ __network_set_cache "${__key}_${__field}" "" "$__dns"
+ fi
+ fi
+ done
+
+ # parse up state, device and physdev
+ for __field in "up" "l3_device" "device"; do
+ if json_get_type __tmp "$__field"; then
+ __network_set_cache "${__key}_${__field}" "$__field"
+ fi
+ done
+
+ # descend into inactive table
+ json_is_a "inactive" object && json_select "inactive"
+
+ done
+
+ json_cleanup
+ json_set_namespace "$__old_ns"
+
+ return 0
+}
+
+
+__network_ipaddr()
+{
+ local __var="$1"
+ local __iface="$2"
+ local __family="$3"
+ local __prefix="$4"
+ local __tmp
+
+ __network_parse_ifstatus "$__iface" || return 1
+
+ if [ $__prefix -eq 1 ]; then
+ __network_export __tmp "${__iface}_mask${__family}" && \
+ __network_export "$__var" "${__iface}_address${__family}" "/$__tmp"
+ return $?
+ fi
+
+ __network_export "$__var" "${__iface}_address${__family}"
+ return $?
+
+}
+
+# determine IPv4 address of given logical interface
+# 1: destination variable
+# 2: interface
+network_get_ipaddr() { __network_ipaddr "$1" "$2" 4 0; }
+
+# determine IPv6 address of given logical interface
+# 1: destination variable
+# 2: interface
+network_get_ipaddr6() { __network_ipaddr "$1" "$2" 6 0; }
+
+# determine IPv4 subnet of given logical interface
+# 1: destination variable
+# 2: interface
+network_get_subnet() { __network_ipaddr "$1" "$2" 4 1; }
+
+# determine IPv6 subnet of given logical interface
+# 1: destination variable
+# 2: interface
+network_get_subnet6() { __network_ipaddr "$1" "$2" 6 1; }
+
+# determine IPv6 prefix
+network_get_prefix6() {
+ local __var="$1"
+ local __iface="$2"
+ local __address
+ local __mask
+
+ __network_parse_ifstatus "$__iface" || return 1
+ __network_export __mask "${__iface}_prefix6_mask" || return 1
+ __network_export "$__var" "${__iface}_prefix6_address" "/$__mask"
+ return $?
+}
+
+
+__network_gateway()
+{
+ local __var="$1"
+ local __iface="$2"
+ local __family="$3"
+ local __inactive="$4"
+
+ __network_parse_ifstatus "$__iface" || return 1
+
+ if [ "$__inactive" = 1 -o "$__inactive" = "true" ]; then
+ __network_export "$__var" "${__iface}_inactive_gateway${__family}" && \
+ return 0
+ fi
+
+ __network_export "$__var" "${__iface}_gateway${__family}"
+ return $?
+}
+
+# determine IPv4 gateway of given logical interface
+# 1: destination variable
+# 2: interface
+# 3: consider inactive gateway if "true" (optional)
+network_get_gateway() { __network_gateway "$1" "$2" 4 "${3:-0}"; }
+
+# determine IPv6 gateway of given logical interface
+# 1: destination variable
+# 2: interface
+# 3: consider inactive gateway if "true" (optional)
+network_get_gateway6() { __network_gateway "$1" "$2" 6 "${3:-0}"; }
+
+
+__network_dns() {
+ local __var="$1"
+ local __iface="$2"
+ local __field="$3"
+ local __inactive="$4"
+
+ __network_parse_ifstatus "$__iface" || return 1
+
+ if [ "$__inactive" = 1 -o "$__inactive" = "true" ]; then
+ __network_export "$__var" "${__iface}_inactive_${__field}" && \
+ return 0
+ fi
+
+ __network_export "$__var" "${__iface}_${__field}"
+ return $?
+}
+
+# determine the DNS servers of the given logical interface
+# 1: destination variable
+# 2: interface
+# 3: consider inactive servers if "true" (optional)
+network_get_dnsserver() { __network_dns "$1" "$2" dns_server "${3:-0}"; }
+
+# determine the domains of the given logical interface
+# 1: destination variable
+# 2: interface
+# 3: consider inactive domains if "true" (optional)
+network_get_dnssearch() { __network_dns "$1" "$2" dns_search "${3:-0}"; }
+
+
+__network_wan()
+{
+ local __var="$1"
+ local __family="$2"
+ local __inactive="$3"
+ local __iface
+
+ for __iface in $(ubus list | sed -ne 's/^network\.interface\.//p'); do
+ if [ "$__iface" != loopback ]; then
+ if __network_gateway "$__var" "$__iface" "$__family" "$__inactive"; then
+ eval "export -- \"$__var=$__iface\""
+ return 0
+ fi
+ fi
+ done
+
+ eval "export -- \"$__var=\""
+ return 1
+}
+
+# find the logical interface which holds the current IPv4 default route
+# 1: destination variable
+# 2: consider inactive default routes if "true" (optional)
+network_find_wan() { __network_wan "$1" 4 "${2:-0}"; }
+
+# find the logical interface which holds the current IPv6 default route
+# 1: destination variable
+# 2: consider inactive dafault routes if "true" (optional)
+network_find_wan6() { __network_wan "$1" 6 "${2:-0}"; }
+
+
+__network_device()
+{
+ local __var="$1"
+ local __iface="$2"
+ local __field="$3"
+
+ __network_parse_ifstatus "$__iface" || return 1
+ __network_export "$__var" "${__iface}_${__field}"
+ return $?
+}
+
+# test whether the given logical interface is running
+# 1: interface
+network_is_up()
+{
+ local __up
+ __network_device __up "$1" up && [ $__up -eq 1 ]
+}
+
+# determine the layer 3 linux network device of the given logical interface
+# 1: destination variable
+# 2: interface
+network_get_device() { __network_device "$1" "$2" l3_device; }
+
+# determine the layer 2 linux network device of the given logical interface
+# 1: destination variable
+# 2: interface
+network_get_physdev() { __network_device "$1" "$2" device; }
+
+
+__network_defer()
+{
+ local __device="$1"
+ local __defer="$2"
+
+ json_init
+ json_add_string name "$__device"
+ json_add_boolean defer "$__defer"
+
+ ubus call network.device set_state "$(json_dump)" 2>/dev/null
+}
+
+# defer netifd actions on the given linux network device
+# 1: device name
+network_defer_device() { __network_defer "$1" 1; }
+
+# continue netifd actions on the given linux network device
+# 1: device name
+network_ready_device() { __network_defer "$1" 0; }
+
+# flush the internal value cache to force re-reading values from ubus
+network_flush_cache()
+{
+ local __tmp
+ for __tmp in $__NETWORK_CACHE __NETWORK_CACHE; do
+ unset "$__tmp"
+ done
+}
diff --git a/package/base-files/files/lib/functions/service.sh b/package/base-files/files/lib/functions/service.sh
new file mode 100644
index 0000000..cbb717d
--- /dev/null
+++ b/package/base-files/files/lib/functions/service.sh
@@ -0,0 +1,129 @@
+#
+# service: simple wrapper around start-stop-daemon
+#
+# Usage: service ACTION EXEC ARGS...
+#
+# Action:
+# -C check if EXEC is alive
+# -S start EXEC, passing it ARGS as its arguments
+# -K kill EXEC, sending it a TERM signal if not specified otherwise
+#
+# Environment variables exposed:
+# SERVICE_DAEMONIZE run EXEC in background
+# SERVICE_WRITE_PID create a pid-file and use it for matching
+# SERVICE_MATCH_EXEC use EXEC command-line for matching (default)
+# SERVICE_MATCH_NAME use EXEC process name for matching
+# SERVICE_USE_PID assume EXEC create its own pid-file and use it for matching
+# SERVICE_NAME process name to use (default to EXEC file part)
+# SERVICE_PID_FILE pid file to use (default to /var/run/$SERVICE_NAME.pid)
+# SERVICE_SIG signal to send when using -K
+# SERVICE_SIG_RELOAD default signal used when reloading
+# SERVICE_SIG_STOP default signal used when stopping
+# SERVICE_STOP_TIME time to wait for a process to stop gracefully before killing it
+# SERVICE_UID user EXEC should be run as
+# SERVICE_GID group EXEC should be run as
+#
+# SERVICE_DEBUG don't do anything, but show what would be done
+# SERVICE_QUIET don't print anything
+#
+
+SERVICE_QUIET=1
+SERVICE_SIG_RELOAD="HUP"
+SERVICE_SIG_STOP="TERM"
+SERVICE_STOP_TIME=5
+SERVICE_MATCH_EXEC=1
+
+service() {
+ local ssd
+ local exec
+ local name
+ local start
+ ssd="${SERVICE_DEBUG:+echo }start-stop-daemon${SERVICE_QUIET:+ -q}"
+ case "$1" in
+ -C)
+ ssd="$ssd -K -t"
+ ;;
+ -S)
+ ssd="$ssd -S${SERVICE_DAEMONIZE:+ -b}${SERVICE_WRITE_PID:+ -m}"
+ start=1
+ ;;
+ -K)
+ ssd="$ssd -K${SERVICE_SIG:+ -s $SERVICE_SIG}"
+ ;;
+ *)
+ echo "service: unknown ACTION '$1'" 1>&2
+ return 1
+ esac
+ shift
+ exec="$1"
+ [ -n "$exec" ] || {
+ echo "service: missing argument" 1>&2
+ return 1
+ }
+ [ -x "$exec" ] || {
+ echo "service: file '$exec' is not executable" 1>&2
+ return 1
+ }
+ name="${SERVICE_NAME:-${exec##*/}}"
+ [ -z "$SERVICE_USE_PID$SERVICE_WRITE_PID$SERVICE_PID_FILE" ] \
+ || ssd="$ssd -p ${SERVICE_PID_FILE:-/var/run/$name.pid}"
+ [ -z "$SERVICE_MATCH_NAME" ] || ssd="$ssd -n $name"
+ ssd="$ssd${SERVICE_UID:+ -c $SERVICE_UID${SERVICE_GID:+:$SERVICE_GID}}"
+ [ -z "$SERVICE_MATCH_EXEC$start" ] || ssd="$ssd -x $exec"
+ shift
+ $ssd${1:+ -- "$@"}
+}
+
+service_check() {
+ service -C "$@"
+}
+
+service_signal() {
+ SERVICE_SIG="${SERVICE_SIG:-USR1}" service -K "$@"
+}
+
+service_start() {
+ service -S "$@"
+}
+
+service_stop() {
+ local try
+ SERVICE_SIG="${SERVICE_SIG:-$SERVICE_SIG_STOP}" service -K "$@" || return 1
+ while [ $((try++)) -lt $SERVICE_STOP_TIME ]; do
+ service -C "$@" || return 0
+ sleep 1
+ done
+ SERVICE_SIG="KILL" service -K "$@"
+ sleep 1
+ ! service -C "$@"
+}
+
+service_reload() {
+ SERVICE_SIG="${SERVICE_SIG:-$SERVICE_SIG_RELOAD}" service -K "$@"
+}
+
+service_kill() {
+ cat 1>&2 << __END_OF_WARNING__
+#
+# WARNING: the 'service_kill' function is now deprecated and might be
+# removed soon. Consider using the other new service_* wrappers instead.
+#
+__END_OF_WARNING__
+ local name="${1}"
+ local pid="${2:-$(pidof "$name")}"
+ local grace="${3:-5}"
+
+ [ -f "$pid" ] && pid="$(head -n1 "$pid" 2>/dev/null)"
+
+ for pid in $pid; do
+ [ -d "/proc/$pid" ] || continue
+ local try=0
+ kill -TERM $pid 2>/dev/null && \
+ while grep -qs "$name" "/proc/$pid/cmdline" && [ $((try++)) -lt $grace ]; do sleep 1; done
+ kill -KILL $pid 2>/dev/null && \
+ while grep -qs "$name" "/proc/$pid/cmdline"; do sleep 1; done
+ done
+}
+
+
+
diff --git a/package/base-files/files/lib/functions/uci-defaults.sh b/package/base-files/files/lib/functions/uci-defaults.sh
new file mode 100644
index 0000000..477c00c
--- /dev/null
+++ b/package/base-files/files/lib/functions/uci-defaults.sh
@@ -0,0 +1,230 @@
+#!/bin/sh
+# Copyright (C) 2011 OpenWrt.org
+
+UCIDEF_LEDS_CHANGED=0
+
+ucidef_set_led_netdev() {
+ local cfg="led_$1"
+ local name=$2
+ local sysfs=$3
+ local dev=$4
+
+ uci -q get system.$cfg && return 0
+
+ uci batch <<EOF
+set system.$cfg='led'
+set system.$cfg.name='$name'
+set system.$cfg.sysfs='$sysfs'
+set system.$cfg.trigger='netdev'
+set system.$cfg.dev='$dev'
+set system.$cfg.mode='link tx rx'
+EOF
+ UCIDEF_LEDS_CHANGED=1
+}
+
+ucidef_set_led_usbdev() {
+ local cfg="led_$1"
+ local name=$2
+ local sysfs=$3
+ local dev=$4
+
+ uci -q get system.$cfg && return 0
+
+ uci batch <<EOF
+set system.$cfg='led'
+set system.$cfg.name='$name'
+set system.$cfg.sysfs='$sysfs'
+set system.$cfg.trigger='usbdev'
+set system.$cfg.dev='$dev'
+set system.$cfg.interval='50'
+EOF
+ UCIDEF_LEDS_CHANGED=1
+}
+
+ucidef_set_led_wlan() {
+ local cfg="led_$1"
+ local name=$2
+ local sysfs=$3
+ local trigger=$4
+
+ uci -q get system.$cfg && return 0
+
+ uci batch <<EOF
+set system.$cfg='led'
+set system.$cfg.name='$name'
+set system.$cfg.sysfs='$sysfs'
+set system.$cfg.trigger='$trigger'
+EOF
+ UCIDEF_LEDS_CHANGED=1
+}
+
+ucidef_set_led_switch() {
+ local cfg="led_$1"
+ local name=$2
+ local sysfs=$3
+ local trigger=$4
+ local port_mask=$5
+
+ uci -q get system.$cfg && return 0
+
+ uci batch <<EOF
+set system.$cfg='led'
+set system.$cfg.name='$name'
+set system.$cfg.sysfs='$sysfs'
+set system.$cfg.trigger='$trigger'
+set system.$cfg.port_mask='$port_mask'
+EOF
+ UCIDEF_LEDS_CHANGED=1
+}
+
+ucidef_set_led_default() {
+ local cfg="led_$1"
+ local name=$2
+ local sysfs=$3
+ local default=$4
+
+ uci -q get system.$cfg && return 0
+
+ uci batch <<EOF
+set system.$cfg='led'
+set system.$cfg.name='$name'
+set system.$cfg.sysfs='$sysfs'
+set system.$cfg.default='$default'
+EOF
+ UCIDEF_LEDS_CHANGED=1
+}
+
+ucidef_set_led_rssi() {
+ local cfg="led_$1"
+ local name=$2
+ local sysfs=$3
+ local iface=$4
+ local minq=$5
+ local maxq=$6
+ local offset=$7
+ local factor=$8
+
+ uci -q get system.$cfg && return 0
+
+ uci batch <<EOF
+set system.$cfg='led'
+set system.$cfg.name='$name'
+set system.$cfg.sysfs='$sysfs'
+set system.$cfg.trigger='rssi'
+set system.$cfg.iface='rssid_$iface'
+set system.$cfg.minq='$minq'
+set system.$cfg.maxq='$maxq'
+set system.$cfg.offset='$offset'
+set system.$cfg.factor='$factor'
+EOF
+ UCIDEF_LEDS_CHANGED=1
+}
+
+ucidef_set_rssimon() {
+ local dev="$1"
+ local refresh="$2"
+ local threshold="$3"
+
+ local cfg="rssid_$dev"
+
+ uci -q get system.$cfg && return 0
+
+ uci batch <<EOF
+set system.$cfg='rssid'
+set system.$cfg.dev='$dev'
+set system.$cfg.refresh='$refresh'
+set system.$cfg.threshold='$threshold'
+EOF
+ UCIDEF_LEDS_CHANGED=1
+}
+
+ucidef_commit_leds()
+{
+ [ "$UCIDEF_LEDS_CHANGED" == "1" ] && uci commit system
+}
+
+ucidef_set_interface_loopback() {
+ uci batch <<EOF
+set network.loopback='interface'
+set network.loopback.ifname='lo'
+set network.loopback.proto='static'
+set network.loopback.ipaddr='127.0.0.1'
+set network.loopback.netmask='255.0.0.0'
+EOF
+}
+
+ucidef_set_interface_raw() {
+ local cfg=$1
+ local ifname=$2
+
+ uci batch <<EOF
+set network.$cfg='interface'
+set network.$cfg.ifname='$ifname'
+set network.$cfg.proto='none'
+EOF
+}
+
+ucidef_set_interface_lan() {
+ local ifname=$1
+
+ uci batch <<EOF
+set network.lan='interface'
+set network.lan.ifname='$ifname'
+set network.lan.type='bridge'
+set network.lan.proto='static'
+set network.lan.ipaddr='192.168.1.1'
+set network.lan.netmask='255.255.255.0'
+EOF
+}
+
+ucidef_set_interface_wan() {
+ local ifname=$1
+
+ uci batch <<EOF
+set network.wan='interface'
+set network.wan.ifname='$ifname'
+set network.wan.proto='dhcp'
+EOF
+}
+
+ucidef_set_interfaces_lan_wan() {
+ local lan_ifname=$1
+ local wan_ifname=$2
+
+ ucidef_set_interface_lan "$lan_ifname"
+ ucidef_set_interface_wan "$wan_ifname"
+}
+
+ucidef_set_interface_macaddr() {
+ local ifname=$1
+ local mac=$2
+
+ uci batch <<EOF
+set network.$ifname.macaddr='$mac'
+EOF
+}
+
+ucidef_add_switch() {
+ local name=$1
+ local reset=$2
+ local enable=$3
+ uci batch <<EOF
+add network switch
+set network.@switch[-1].name='$name'
+set network.@switch[-1].reset='$reset'
+set network.@switch[-1].enable_vlan='$enable'
+EOF
+}
+
+ucidef_add_switch_vlan() {
+ local device=$1
+ local vlan=$2
+ local ports=$3
+ uci batch <<EOF
+add network switch_vlan
+set network.@switch_vlan[-1].device='$device'
+set network.@switch_vlan[-1].vlan='$vlan'
+set network.@switch_vlan[-1].ports='$ports'
+EOF
+}
+
diff --git a/package/base-files/files/lib/preinit/.svn/entries b/package/base-files/files/lib/preinit/.svn/entries
new file mode 100644
index 0000000..8270063
--- /dev/null
+++ b/package/base-files/files/lib/preinit/.svn/entries
@@ -0,0 +1,674 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/base-files/files/lib/preinit
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-13T18:11:19.892934Z
+36003
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+90_restore_config
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+04e69cc1da4d81832d27a2cb7ab5358a
+2010-01-25T17:11:17.955488Z
+19331
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+311
+
+40_run_failsafe_hook
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+17269a4ab7d6cf87d0cfaa9c66dd45c6
+2010-01-25T17:11:17.955488Z
+19331
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+258
+
+99_10_failsafe_login
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+70069fee1421e423b4b1b32fe8d41275
+2010-01-25T17:11:17.955488Z
+19331
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+380
+
+99_10_mount_no_mtd
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+6609d58567732864df67793fbd87673f
+2010-01-25T17:11:17.955488Z
+19331
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+207
+
+10_check_for_mtd
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+d3b129644d4e887c14362fd50cc3a0b2
+2012-12-19T16:07:46.450520Z
+34792
+mirko
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+361
+
+05_mount_skip
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+1653d3e10ce2fa0bb19b9a2bc3512a1b
+2010-01-25T17:11:17.955488Z
+19331
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+193
+
+20_check_jffs2_ready
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+64b8f9758cf25e80af122a3e458ba2ce
+2010-01-25T17:11:17.955488Z
+19331
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+344
+
+40_mount_jffs2
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+b52a12f4e1f86507ced5a17c68721415
+2012-12-19T16:07:46.450520Z
+34792
+mirko
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+509
+
+50_indicate_regular_preinit
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+2b9a9ccda822a0f7b9d57458ca31efe2
+2013-03-13T18:11:19.892934Z
+36003
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+251
+
+02_default_set_state
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+193b1e9516b1755f8bd6e23f580e9314
+2011-07-07T02:52:02.172369Z
+27501
+cshore
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+111
+
+30_failsafe_wait
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+fbfc634f57e24a2b818a68731e7d06bb
+2013-03-13T18:11:19.892934Z
+36003
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2107
+
+90_mount_no_jffs2
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+c18d18f6906e46760fa4a7bc641f5e3a
+2010-01-25T17:11:17.955488Z
+19331
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+240
+
+70_initramfs_test
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+e18ec6f31f263f2d83ba91d1968ee4ad
+2010-03-12T14:37:19.807154Z
+20159
+juhosg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+247
+
+70_pivot_jffs2_root
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+45c359724eec192a210abb1faa4d5c2f
+2012-12-19T16:07:46.450520Z
+34792
+mirko
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+335
+
+41_merge_overlay_hooks
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+db40ab6d5b24c82854843cb41f41f80e
+2010-09-23T17:32:58.124136Z
+23114
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+518
+
+99_10_run_init
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+98ebebf030a69b8c25a7e47a0464755c
+2013-03-13T18:11:19.892934Z
+36003
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+166
+
+10_indicate_preinit
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+4c0cb2401ca1ddfb08398be732832f04
+2013-03-13T18:11:19.892934Z
+36003
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1159
+
+10_indicate_failsafe
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+da886213883c1e3827b041891063609a
+2010-01-25T17:11:17.955488Z
+19331
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+365
+
+80_mount_root
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+d40c6fa4ce55e2fc41ab815263b95f16
+2013-03-13T18:11:19.892934Z
+36003
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+214
+
diff --git a/package/base-files/files/lib/preinit/.svn/text-base/02_default_set_state.svn-base b/package/base-files/files/lib/preinit/.svn/text-base/02_default_set_state.svn-base
new file mode 100644
index 0000000..df43395
--- /dev/null
+++ b/package/base-files/files/lib/preinit/.svn/text-base/02_default_set_state.svn-base
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+define_default_set_state() {
+ . /etc/diag.sh
+}
+
+boot_hook_add preinit_main define_default_set_state
diff --git a/package/base-files/files/lib/preinit/.svn/text-base/05_mount_skip.svn-base b/package/base-files/files/lib/preinit/.svn/text-base/05_mount_skip.svn-base
new file mode 100644
index 0000000..c2b7ee7
--- /dev/null
+++ b/package/base-files/files/lib/preinit/.svn/text-base/05_mount_skip.svn-base
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+check_skip() {
+ if [ "$pi_mount_skip_next" = "true" ]; then
+ return 0
+ else
+ return 1
+ fi
+}
+
diff --git a/package/base-files/files/lib/preinit/.svn/text-base/10_check_for_mtd.svn-base b/package/base-files/files/lib/preinit/.svn/text-base/10_check_for_mtd.svn-base
new file mode 100644
index 0000000..6a7bd30
--- /dev/null
+++ b/package/base-files/files/lib/preinit/.svn/text-base/10_check_for_mtd.svn-base
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+mount_no_mtd() {
+ mtd unlock rootfs
+ mount -o noatime,remount,rw /dev/root /
+}
+
+check_for_mtd() {
+ check_skip || {
+ grep -qs rootfs_data /proc/mtd || {
+ mount_no_mtd && pi_mount_skip_next=true
+ }
+ }
+}
+
+boot_hook_add preinit_mount_root check_for_mtd
+
diff --git a/package/base-files/files/lib/preinit/.svn/text-base/10_indicate_failsafe.svn-base b/package/base-files/files/lib/preinit/.svn/text-base/10_indicate_failsafe.svn-base
new file mode 100644
index 0000000..7761fd3
--- /dev/null
+++ b/package/base-files/files/lib/preinit/.svn/text-base/10_indicate_failsafe.svn-base
@@ -0,0 +1,18 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+# commands for emitting messages to network in failsafe mode
+
+indicate_failsafe_led () {
+ set_state failsafe
+}
+
+indicate_failsafe() {
+ echo "- failsafe -"
+ preinit_net_echo "Entering Failsafe!\n"
+ indicate_failsafe_led
+}
+
+boot_hook_add failsafe indicate_failsafe
+
diff --git a/package/base-files/files/lib/preinit/.svn/text-base/10_indicate_preinit.svn-base b/package/base-files/files/lib/preinit/.svn/text-base/10_indicate_preinit.svn-base
new file mode 100644
index 0000000..da70b97
--- /dev/null
+++ b/package/base-files/files/lib/preinit/.svn/text-base/10_indicate_preinit.svn-base
@@ -0,0 +1,50 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+preinit_ip() {
+ # if the preinit interface isn't specified and ifname is set in
+ # preinit.arch use that interface
+ if [ -z "$pi_ifname" ]; then
+ pi_ifname=$ifname
+ fi
+
+ [ -n "$pi_ifname" ] && grep -q "$pi_ifname" /proc/net/dev && {
+ ifconfig $pi_ifname $pi_ip netmask $pi_netmask broadcast $pi_broadcast up
+ }
+}
+
+preinit_ip_deconfig() {
+ [ -n "$pi_ifname" ] && grep -q "$pi_ifname" /proc/net/dev && {
+ ifconfig $pi_ifname 0.0.0.0 down
+ }
+}
+
+preinit_net_echo() {
+ [ -n "$pi_ifname" ] && grep -q "$pi_ifname" /proc/net/dev && {
+ {
+ [ "$pi_preinit_net_messages" = "y" ] || {
+ [ "$pi_failsafe_net_message" = "true" ] &&
+ [ "$pi_preinit_no_failsafe_netmsg" != "y" ]
+ }
+ } && netmsg $pi_broadcast "$1"
+ }
+}
+
+preinit_echo() {
+ preinit_net_echo $1
+ echo $1
+}
+
+pi_indicate_led() {
+ set_state preinit
+}
+
+pi_indicate_preinit() {
+ preinit_net_echo "Doing OpenWRT Preinit\n"
+ pi_indicate_led
+}
+
+boot_hook_add preinit_main preinit_ip
+boot_hook_add preinit_main pi_indicate_preinit
+
diff --git a/package/base-files/files/lib/preinit/.svn/text-base/20_check_jffs2_ready.svn-base b/package/base-files/files/lib/preinit/.svn/text-base/20_check_jffs2_ready.svn-base
new file mode 100644
index 0000000..3c5cf67
--- /dev/null
+++ b/package/base-files/files/lib/preinit/.svn/text-base/20_check_jffs2_ready.svn-base
@@ -0,0 +1,19 @@
+#!/bin/sh
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+mount_no_jffs2() {
+ echo "jffs2 not ready yet; using ramdisk"
+ ramoverlay
+}
+
+check_for_jffs2() {
+ check_skip || {
+ jffs2_ready || {
+ mount_no_jffs2 && pi_mount_skip_next=true
+ }
+ }
+}
+
+boot_hook_add preinit_mount_root check_for_jffs2
+
diff --git a/package/base-files/files/lib/preinit/.svn/text-base/30_failsafe_wait.svn-base b/package/base-files/files/lib/preinit/.svn/text-base/30_failsafe_wait.svn-base
new file mode 100644
index 0000000..808d973
--- /dev/null
+++ b/package/base-files/files/lib/preinit/.svn/text-base/30_failsafe_wait.svn-base
@@ -0,0 +1,84 @@
+#!/bin/sh
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+fs_wait_for_key () {
+ local timeout=$3
+ local timer
+ local do_failsafe
+ local keypress_true="$(mktemp)"
+ local keypress_wait="$(mktemp)"
+ local keypress_sec="$(mktemp)"
+ if [ -z "$keypress_wait" ]; then
+ keypress_wait=/tmp/.keypress_wait
+ touch $keypress_wait
+ fi
+ if [ -z "$keypress_true" ]; then
+ keypress_true=/tmp/.keypress_true
+ touch $keypress_true
+ fi
+ if [ -z "$keypress_sec" ]; then
+ keypress_sec=/tmp/.keypress_sec
+ touch $keypress_sec
+ fi
+
+ trap "echo 'true' >$keypress_true; lock -u $keypress_wait ; rm -f $keypress_wait" INT
+ trap "echo 'true' >$keypress_true; lock -u $keypress_wait ; rm -f $keypress_wait" USR1
+
+ [ -n "$timeout" ] || timeout=1
+ [ $timeout -ge 1 ] || timeout=1
+ timer=$timeout
+ lock $keypress_wait
+ {
+ while [ $timer -gt 0 ]; do
+ echo "$timer" >$keypress_sec
+ timer=$(($timer - 1))
+ sleep 1
+ done
+ lock -u $keypress_wait
+ rm -f $keypress_wait
+ } &
+
+ echo "Press the [$1] key and hit [enter] $2"
+ # if we're on the console we wait for input
+ {
+ while [ -r $keypress_wait ]; do
+ timer="$(cat $keypress_sec)"
+
+ [ -n "$timer" ] || timer=1
+ timer="${timer%%\ *}"
+ [ $timer -ge 1 ] || timer=1
+ do_failsafe=""
+ {
+ read -t "$timer" do_failsafe
+ if [ "$do_failsafe" = "$1" ]; then
+ echo "true" >$keypress_true
+ lock -u $keypress_wait
+ rm -f $keypress_wait
+ fi
+ }
+ done
+ }
+ lock -w $keypress_wait
+
+ keypressed=1
+ [ "$(cat $keypress_true)" = "true" ] && keypressed=0
+ [ -f "/tmp/failsafe_button" ] && keypressed=1
+
+ rm -f $keypress_true
+ rm -f $keypress_wait
+ rm -f $keypress_sec
+
+ return $keypressed
+}
+
+failsafe_wait() {
+ FAILSAFE=
+ pi_failsafe_net_message=true
+ preinit_net_echo "Please press button now to enter failsafe"
+ pi_failsafe_net_message=false
+ fs_wait_for_key f 'to enter failsafe mode' $fs_failsafe_wait_timeout && FAILSAFE=true && export FAILSAFE
+}
+
+boot_hook_add preinit_main failsafe_wait
+
diff --git a/package/base-files/files/lib/preinit/.svn/text-base/40_mount_jffs2.svn-base b/package/base-files/files/lib/preinit/.svn/text-base/40_mount_jffs2.svn-base
new file mode 100644
index 0000000..ded785e
--- /dev/null
+++ b/package/base-files/files/lib/preinit/.svn/text-base/40_mount_jffs2.svn-base
@@ -0,0 +1,26 @@
+#!/bin/sh
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+find_mount_jffs2() {
+ mkdir -p /tmp/overlay
+ mount -o noatime -t jffs2 "$(find_mtd_part rootfs_data)" /tmp/overlay
+ mtd -qq unlock rootfs_data
+}
+
+jffs2_not_mounted() {
+ if [ "$pi_jffs2_mount_success" != "true" ]; then
+ return 0
+ else
+ return 1
+ fi
+}
+
+do_mount_jffs2() {
+ check_skip || {
+ find_mount_jffs2 && pi_jffs2_mount_success=true
+ }
+}
+
+boot_hook_add preinit_mount_root do_mount_jffs2
+
diff --git a/package/base-files/files/lib/preinit/.svn/text-base/40_run_failsafe_hook.svn-base b/package/base-files/files/lib/preinit/.svn/text-base/40_run_failsafe_hook.svn-base
new file mode 100644
index 0000000..faa043c
--- /dev/null
+++ b/package/base-files/files/lib/preinit/.svn/text-base/40_run_failsafe_hook.svn-base
@@ -0,0 +1,13 @@
+#!/bin/sh
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+run_failsafe_hook() {
+ if [ "$FAILSAFE" = "true" ]; then
+ boot_run_hook failsafe
+ lock -w /tmp/.failsafe
+ fi
+}
+
+boot_hook_add preinit_main run_failsafe_hook
+
diff --git a/package/base-files/files/lib/preinit/.svn/text-base/41_merge_overlay_hooks.svn-base b/package/base-files/files/lib/preinit/.svn/text-base/41_merge_overlay_hooks.svn-base
new file mode 100644
index 0000000..4ca6877
--- /dev/null
+++ b/package/base-files/files/lib/preinit/.svn/text-base/41_merge_overlay_hooks.svn-base
@@ -0,0 +1,24 @@
+#!/bin/sh
+# Copyright (C) 2010 OpenWrt.org
+
+merge_overlay_hooks() {
+ jffs2_not_mounted || [ ! -d /tmp/overlay/lib/preinit ] || {
+ echo "- merge overlay components -"
+
+ mkdir -p /tmp/preinit-hook-merge
+ ln -sf /lib/preinit/* /tmp/overlay/lib/preinit/[0-9][0-9]_* /tmp/preinit-hook-merge/
+
+ boot_hook_splice_start
+
+ local pipart
+ for pipart in /tmp/preinit-hook-merge/*; do
+ . $pipart
+ done
+
+ boot_hook_splice_finish
+
+ rm -rf /tmp/preinit-hook-merge
+ }
+}
+
+boot_hook_add preinit_mount_root merge_overlay_hooks
diff --git a/package/base-files/files/lib/preinit/.svn/text-base/50_indicate_regular_preinit.svn-base b/package/base-files/files/lib/preinit/.svn/text-base/50_indicate_regular_preinit.svn-base
new file mode 100644
index 0000000..c200dad
--- /dev/null
+++ b/package/base-files/files/lib/preinit/.svn/text-base/50_indicate_regular_preinit.svn-base
@@ -0,0 +1,11 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+indicate_regular_preinit() {
+ preinit_net_echo "Continuing with Regular Preinit\n"
+ pi_indicate_led
+}
+
+boot_hook_add preinit_main indicate_regular_preinit
+
diff --git a/package/base-files/files/lib/preinit/.svn/text-base/70_initramfs_test.svn-base b/package/base-files/files/lib/preinit/.svn/text-base/70_initramfs_test.svn-base
new file mode 100644
index 0000000..15c0dcd
--- /dev/null
+++ b/package/base-files/files/lib/preinit/.svn/text-base/70_initramfs_test.svn-base
@@ -0,0 +1,14 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+initramfs_test() {
+ if [ -n "$INITRAMFS" ]; then
+ boot_run_hook initramfs
+ preinit_ip_deconfig
+ break
+ fi
+}
+
+boot_hook_add preinit_main initramfs_test
+
diff --git a/package/base-files/files/lib/preinit/.svn/text-base/70_pivot_jffs2_root.svn-base b/package/base-files/files/lib/preinit/.svn/text-base/70_pivot_jffs2_root.svn-base
new file mode 100644
index 0000000..b76f111
--- /dev/null
+++ b/package/base-files/files/lib/preinit/.svn/text-base/70_pivot_jffs2_root.svn-base
@@ -0,0 +1,14 @@
+#!/bin/sh
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+rootfs_pivot() {
+ check_skip || jffs2_not_mounted || {
+ echo "switching to jffs2"
+ mount -o noatime,move /tmp/overlay /overlay 2>&-
+ fopivot /overlay /rom && pi_mount_skip_next=true
+ }
+}
+
+boot_hook_add preinit_mount_root rootfs_pivot
+
diff --git a/package/base-files/files/lib/preinit/.svn/text-base/80_mount_root.svn-base b/package/base-files/files/lib/preinit/.svn/text-base/80_mount_root.svn-base
new file mode 100644
index 0000000..9a99ee9
--- /dev/null
+++ b/package/base-files/files/lib/preinit/.svn/text-base/80_mount_root.svn-base
@@ -0,0 +1,9 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+do_mount_root() {
+ boot_run_hook preinit_mount_root
+}
+
+[ "$INITRAMFS" = "1" ] || boot_hook_add preinit_main do_mount_root
diff --git a/package/base-files/files/lib/preinit/.svn/text-base/90_mount_no_jffs2.svn-base b/package/base-files/files/lib/preinit/.svn/text-base/90_mount_no_jffs2.svn-base
new file mode 100644
index 0000000..d8ad4ae
--- /dev/null
+++ b/package/base-files/files/lib/preinit/.svn/text-base/90_mount_no_jffs2.svn-base
@@ -0,0 +1,12 @@
+#!/bin/sh
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+do_mount_no_jffs2() {
+ check_skip || {
+ mount_no_jffs2 && pi_mount_skip_next=true
+ }
+}
+
+boot_hook_add preinit_mount_root do_mount_no_jffs2
+
diff --git a/package/base-files/files/lib/preinit/.svn/text-base/90_restore_config.svn-base b/package/base-files/files/lib/preinit/.svn/text-base/90_restore_config.svn-base
new file mode 100644
index 0000000..210bf61
--- /dev/null
+++ b/package/base-files/files/lib/preinit/.svn/text-base/90_restore_config.svn-base
@@ -0,0 +1,17 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+restore_config() {
+ [ -f /sysupgrade.tgz ] && {
+ echo "- config restore -"
+ cd /
+ mv sysupgrade.tgz /tmp
+ tar xzf /tmp/sysupgrade.tgz
+ rm -f /tmp/sysupgrade.tgz
+ sync
+ }
+}
+
+boot_hook_add preinit_main restore_config
+
diff --git a/package/base-files/files/lib/preinit/.svn/text-base/99_10_failsafe_login.svn-base b/package/base-files/files/lib/preinit/.svn/text-base/99_10_failsafe_login.svn-base
new file mode 100644
index 0000000..05d6b77
--- /dev/null
+++ b/package/base-files/files/lib/preinit/.svn/text-base/99_10_failsafe_login.svn-base
@@ -0,0 +1,18 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+failsafe_netlogin () {
+ telnetd -l /bin/login.sh <> /dev/null 2>&1
+}
+
+failsafe_shell() {
+ lock /tmp/.failsafe
+ ash --login
+ echo "Please reboot system when done with failsafe network logins"
+}
+
+
+boot_hook_add failsafe failsafe_netlogin
+boot_hook_add failsafe failsafe_shell
+
diff --git a/package/base-files/files/lib/preinit/.svn/text-base/99_10_mount_no_mtd.svn-base b/package/base-files/files/lib/preinit/.svn/text-base/99_10_mount_no_mtd.svn-base
new file mode 100644
index 0000000..c4f38e4
--- /dev/null
+++ b/package/base-files/files/lib/preinit/.svn/text-base/99_10_mount_no_mtd.svn-base
@@ -0,0 +1,12 @@
+#!/bin/sh
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+do_mount_no_mtd() {
+ check_skip || {
+ mount_no_mtd
+ }
+}
+
+boot_hook_add preinit_mount_root do_mount_no_mtd
+
diff --git a/package/base-files/files/lib/preinit/.svn/text-base/99_10_run_init.svn-base b/package/base-files/files/lib/preinit/.svn/text-base/99_10_run_init.svn-base
new file mode 100644
index 0000000..a8f330f
--- /dev/null
+++ b/package/base-files/files/lib/preinit/.svn/text-base/99_10_run_init.svn-base
@@ -0,0 +1,10 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+run_init() {
+ preinit_ip_deconfig
+}
+
+boot_hook_add preinit_main run_init
+
diff --git a/package/base-files/files/lib/preinit/02_default_set_state b/package/base-files/files/lib/preinit/02_default_set_state
new file mode 100644
index 0000000..df43395
--- /dev/null
+++ b/package/base-files/files/lib/preinit/02_default_set_state
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+define_default_set_state() {
+ . /etc/diag.sh
+}
+
+boot_hook_add preinit_main define_default_set_state
diff --git a/package/base-files/files/lib/preinit/05_mount_skip b/package/base-files/files/lib/preinit/05_mount_skip
new file mode 100644
index 0000000..c2b7ee7
--- /dev/null
+++ b/package/base-files/files/lib/preinit/05_mount_skip
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+check_skip() {
+ if [ "$pi_mount_skip_next" = "true" ]; then
+ return 0
+ else
+ return 1
+ fi
+}
+
diff --git a/package/base-files/files/lib/preinit/10_check_for_mtd b/package/base-files/files/lib/preinit/10_check_for_mtd
new file mode 100644
index 0000000..6a7bd30
--- /dev/null
+++ b/package/base-files/files/lib/preinit/10_check_for_mtd
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+mount_no_mtd() {
+ mtd unlock rootfs
+ mount -o noatime,remount,rw /dev/root /
+}
+
+check_for_mtd() {
+ check_skip || {
+ grep -qs rootfs_data /proc/mtd || {
+ mount_no_mtd && pi_mount_skip_next=true
+ }
+ }
+}
+
+boot_hook_add preinit_mount_root check_for_mtd
+
diff --git a/package/base-files/files/lib/preinit/10_indicate_failsafe b/package/base-files/files/lib/preinit/10_indicate_failsafe
new file mode 100644
index 0000000..7761fd3
--- /dev/null
+++ b/package/base-files/files/lib/preinit/10_indicate_failsafe
@@ -0,0 +1,18 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+# commands for emitting messages to network in failsafe mode
+
+indicate_failsafe_led () {
+ set_state failsafe
+}
+
+indicate_failsafe() {
+ echo "- failsafe -"
+ preinit_net_echo "Entering Failsafe!\n"
+ indicate_failsafe_led
+}
+
+boot_hook_add failsafe indicate_failsafe
+
diff --git a/package/base-files/files/lib/preinit/10_indicate_preinit b/package/base-files/files/lib/preinit/10_indicate_preinit
new file mode 100644
index 0000000..da70b97
--- /dev/null
+++ b/package/base-files/files/lib/preinit/10_indicate_preinit
@@ -0,0 +1,50 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+preinit_ip() {
+ # if the preinit interface isn't specified and ifname is set in
+ # preinit.arch use that interface
+ if [ -z "$pi_ifname" ]; then
+ pi_ifname=$ifname
+ fi
+
+ [ -n "$pi_ifname" ] && grep -q "$pi_ifname" /proc/net/dev && {
+ ifconfig $pi_ifname $pi_ip netmask $pi_netmask broadcast $pi_broadcast up
+ }
+}
+
+preinit_ip_deconfig() {
+ [ -n "$pi_ifname" ] && grep -q "$pi_ifname" /proc/net/dev && {
+ ifconfig $pi_ifname 0.0.0.0 down
+ }
+}
+
+preinit_net_echo() {
+ [ -n "$pi_ifname" ] && grep -q "$pi_ifname" /proc/net/dev && {
+ {
+ [ "$pi_preinit_net_messages" = "y" ] || {
+ [ "$pi_failsafe_net_message" = "true" ] &&
+ [ "$pi_preinit_no_failsafe_netmsg" != "y" ]
+ }
+ } && netmsg $pi_broadcast "$1"
+ }
+}
+
+preinit_echo() {
+ preinit_net_echo $1
+ echo $1
+}
+
+pi_indicate_led() {
+ set_state preinit
+}
+
+pi_indicate_preinit() {
+ preinit_net_echo "Doing OpenWRT Preinit\n"
+ pi_indicate_led
+}
+
+boot_hook_add preinit_main preinit_ip
+boot_hook_add preinit_main pi_indicate_preinit
+
diff --git a/package/base-files/files/lib/preinit/20_check_jffs2_ready b/package/base-files/files/lib/preinit/20_check_jffs2_ready
new file mode 100644
index 0000000..3c5cf67
--- /dev/null
+++ b/package/base-files/files/lib/preinit/20_check_jffs2_ready
@@ -0,0 +1,19 @@
+#!/bin/sh
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+mount_no_jffs2() {
+ echo "jffs2 not ready yet; using ramdisk"
+ ramoverlay
+}
+
+check_for_jffs2() {
+ check_skip || {
+ jffs2_ready || {
+ mount_no_jffs2 && pi_mount_skip_next=true
+ }
+ }
+}
+
+boot_hook_add preinit_mount_root check_for_jffs2
+
diff --git a/package/base-files/files/lib/preinit/30_failsafe_wait b/package/base-files/files/lib/preinit/30_failsafe_wait
new file mode 100644
index 0000000..808d973
--- /dev/null
+++ b/package/base-files/files/lib/preinit/30_failsafe_wait
@@ -0,0 +1,84 @@
+#!/bin/sh
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+fs_wait_for_key () {
+ local timeout=$3
+ local timer
+ local do_failsafe
+ local keypress_true="$(mktemp)"
+ local keypress_wait="$(mktemp)"
+ local keypress_sec="$(mktemp)"
+ if [ -z "$keypress_wait" ]; then
+ keypress_wait=/tmp/.keypress_wait
+ touch $keypress_wait
+ fi
+ if [ -z "$keypress_true" ]; then
+ keypress_true=/tmp/.keypress_true
+ touch $keypress_true
+ fi
+ if [ -z "$keypress_sec" ]; then
+ keypress_sec=/tmp/.keypress_sec
+ touch $keypress_sec
+ fi
+
+ trap "echo 'true' >$keypress_true; lock -u $keypress_wait ; rm -f $keypress_wait" INT
+ trap "echo 'true' >$keypress_true; lock -u $keypress_wait ; rm -f $keypress_wait" USR1
+
+ [ -n "$timeout" ] || timeout=1
+ [ $timeout -ge 1 ] || timeout=1
+ timer=$timeout
+ lock $keypress_wait
+ {
+ while [ $timer -gt 0 ]; do
+ echo "$timer" >$keypress_sec
+ timer=$(($timer - 1))
+ sleep 1
+ done
+ lock -u $keypress_wait
+ rm -f $keypress_wait
+ } &
+
+ echo "Press the [$1] key and hit [enter] $2"
+ # if we're on the console we wait for input
+ {
+ while [ -r $keypress_wait ]; do
+ timer="$(cat $keypress_sec)"
+
+ [ -n "$timer" ] || timer=1
+ timer="${timer%%\ *}"
+ [ $timer -ge 1 ] || timer=1
+ do_failsafe=""
+ {
+ read -t "$timer" do_failsafe
+ if [ "$do_failsafe" = "$1" ]; then
+ echo "true" >$keypress_true
+ lock -u $keypress_wait
+ rm -f $keypress_wait
+ fi
+ }
+ done
+ }
+ lock -w $keypress_wait
+
+ keypressed=1
+ [ "$(cat $keypress_true)" = "true" ] && keypressed=0
+ [ -f "/tmp/failsafe_button" ] && keypressed=1
+
+ rm -f $keypress_true
+ rm -f $keypress_wait
+ rm -f $keypress_sec
+
+ return $keypressed
+}
+
+failsafe_wait() {
+ FAILSAFE=
+ pi_failsafe_net_message=true
+ preinit_net_echo "Please press button now to enter failsafe"
+ pi_failsafe_net_message=false
+ fs_wait_for_key f 'to enter failsafe mode' $fs_failsafe_wait_timeout && FAILSAFE=true && export FAILSAFE
+}
+
+boot_hook_add preinit_main failsafe_wait
+
diff --git a/package/base-files/files/lib/preinit/40_mount_jffs2 b/package/base-files/files/lib/preinit/40_mount_jffs2
new file mode 100644
index 0000000..ded785e
--- /dev/null
+++ b/package/base-files/files/lib/preinit/40_mount_jffs2
@@ -0,0 +1,26 @@
+#!/bin/sh
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+find_mount_jffs2() {
+ mkdir -p /tmp/overlay
+ mount -o noatime -t jffs2 "$(find_mtd_part rootfs_data)" /tmp/overlay
+ mtd -qq unlock rootfs_data
+}
+
+jffs2_not_mounted() {
+ if [ "$pi_jffs2_mount_success" != "true" ]; then
+ return 0
+ else
+ return 1
+ fi
+}
+
+do_mount_jffs2() {
+ check_skip || {
+ find_mount_jffs2 && pi_jffs2_mount_success=true
+ }
+}
+
+boot_hook_add preinit_mount_root do_mount_jffs2
+
diff --git a/package/base-files/files/lib/preinit/40_run_failsafe_hook b/package/base-files/files/lib/preinit/40_run_failsafe_hook
new file mode 100644
index 0000000..faa043c
--- /dev/null
+++ b/package/base-files/files/lib/preinit/40_run_failsafe_hook
@@ -0,0 +1,13 @@
+#!/bin/sh
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+run_failsafe_hook() {
+ if [ "$FAILSAFE" = "true" ]; then
+ boot_run_hook failsafe
+ lock -w /tmp/.failsafe
+ fi
+}
+
+boot_hook_add preinit_main run_failsafe_hook
+
diff --git a/package/base-files/files/lib/preinit/41_merge_overlay_hooks b/package/base-files/files/lib/preinit/41_merge_overlay_hooks
new file mode 100644
index 0000000..4ca6877
--- /dev/null
+++ b/package/base-files/files/lib/preinit/41_merge_overlay_hooks
@@ -0,0 +1,24 @@
+#!/bin/sh
+# Copyright (C) 2010 OpenWrt.org
+
+merge_overlay_hooks() {
+ jffs2_not_mounted || [ ! -d /tmp/overlay/lib/preinit ] || {
+ echo "- merge overlay components -"
+
+ mkdir -p /tmp/preinit-hook-merge
+ ln -sf /lib/preinit/* /tmp/overlay/lib/preinit/[0-9][0-9]_* /tmp/preinit-hook-merge/
+
+ boot_hook_splice_start
+
+ local pipart
+ for pipart in /tmp/preinit-hook-merge/*; do
+ . $pipart
+ done
+
+ boot_hook_splice_finish
+
+ rm -rf /tmp/preinit-hook-merge
+ }
+}
+
+boot_hook_add preinit_mount_root merge_overlay_hooks
diff --git a/package/base-files/files/lib/preinit/50_indicate_regular_preinit b/package/base-files/files/lib/preinit/50_indicate_regular_preinit
new file mode 100644
index 0000000..c200dad
--- /dev/null
+++ b/package/base-files/files/lib/preinit/50_indicate_regular_preinit
@@ -0,0 +1,11 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+indicate_regular_preinit() {
+ preinit_net_echo "Continuing with Regular Preinit\n"
+ pi_indicate_led
+}
+
+boot_hook_add preinit_main indicate_regular_preinit
+
diff --git a/package/base-files/files/lib/preinit/70_initramfs_test b/package/base-files/files/lib/preinit/70_initramfs_test
new file mode 100644
index 0000000..15c0dcd
--- /dev/null
+++ b/package/base-files/files/lib/preinit/70_initramfs_test
@@ -0,0 +1,14 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+initramfs_test() {
+ if [ -n "$INITRAMFS" ]; then
+ boot_run_hook initramfs
+ preinit_ip_deconfig
+ break
+ fi
+}
+
+boot_hook_add preinit_main initramfs_test
+
diff --git a/package/base-files/files/lib/preinit/70_pivot_jffs2_root b/package/base-files/files/lib/preinit/70_pivot_jffs2_root
new file mode 100644
index 0000000..b76f111
--- /dev/null
+++ b/package/base-files/files/lib/preinit/70_pivot_jffs2_root
@@ -0,0 +1,14 @@
+#!/bin/sh
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+rootfs_pivot() {
+ check_skip || jffs2_not_mounted || {
+ echo "switching to jffs2"
+ mount -o noatime,move /tmp/overlay /overlay 2>&-
+ fopivot /overlay /rom && pi_mount_skip_next=true
+ }
+}
+
+boot_hook_add preinit_mount_root rootfs_pivot
+
diff --git a/package/base-files/files/lib/preinit/80_mount_root b/package/base-files/files/lib/preinit/80_mount_root
new file mode 100644
index 0000000..9a99ee9
--- /dev/null
+++ b/package/base-files/files/lib/preinit/80_mount_root
@@ -0,0 +1,9 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+do_mount_root() {
+ boot_run_hook preinit_mount_root
+}
+
+[ "$INITRAMFS" = "1" ] || boot_hook_add preinit_main do_mount_root
diff --git a/package/base-files/files/lib/preinit/90_mount_no_jffs2 b/package/base-files/files/lib/preinit/90_mount_no_jffs2
new file mode 100644
index 0000000..d8ad4ae
--- /dev/null
+++ b/package/base-files/files/lib/preinit/90_mount_no_jffs2
@@ -0,0 +1,12 @@
+#!/bin/sh
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+do_mount_no_jffs2() {
+ check_skip || {
+ mount_no_jffs2 && pi_mount_skip_next=true
+ }
+}
+
+boot_hook_add preinit_mount_root do_mount_no_jffs2
+
diff --git a/package/base-files/files/lib/preinit/90_restore_config b/package/base-files/files/lib/preinit/90_restore_config
new file mode 100644
index 0000000..210bf61
--- /dev/null
+++ b/package/base-files/files/lib/preinit/90_restore_config
@@ -0,0 +1,17 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+restore_config() {
+ [ -f /sysupgrade.tgz ] && {
+ echo "- config restore -"
+ cd /
+ mv sysupgrade.tgz /tmp
+ tar xzf /tmp/sysupgrade.tgz
+ rm -f /tmp/sysupgrade.tgz
+ sync
+ }
+}
+
+boot_hook_add preinit_main restore_config
+
diff --git a/package/base-files/files/lib/preinit/99_10_failsafe_login b/package/base-files/files/lib/preinit/99_10_failsafe_login
new file mode 100644
index 0000000..05d6b77
--- /dev/null
+++ b/package/base-files/files/lib/preinit/99_10_failsafe_login
@@ -0,0 +1,18 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+failsafe_netlogin () {
+ telnetd -l /bin/login.sh <> /dev/null 2>&1
+}
+
+failsafe_shell() {
+ lock /tmp/.failsafe
+ ash --login
+ echo "Please reboot system when done with failsafe network logins"
+}
+
+
+boot_hook_add failsafe failsafe_netlogin
+boot_hook_add failsafe failsafe_shell
+
diff --git a/package/base-files/files/lib/preinit/99_10_mount_no_mtd b/package/base-files/files/lib/preinit/99_10_mount_no_mtd
new file mode 100644
index 0000000..c4f38e4
--- /dev/null
+++ b/package/base-files/files/lib/preinit/99_10_mount_no_mtd
@@ -0,0 +1,12 @@
+#!/bin/sh
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+do_mount_no_mtd() {
+ check_skip || {
+ mount_no_mtd
+ }
+}
+
+boot_hook_add preinit_mount_root do_mount_no_mtd
+
diff --git a/package/base-files/files/lib/preinit/99_10_run_init b/package/base-files/files/lib/preinit/99_10_run_init
new file mode 100644
index 0000000..a8f330f
--- /dev/null
+++ b/package/base-files/files/lib/preinit/99_10_run_init
@@ -0,0 +1,10 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+run_init() {
+ preinit_ip_deconfig
+}
+
+boot_hook_add preinit_main run_init
+
diff --git a/package/base-files/files/lib/upgrade/.svn/entries b/package/base-files/files/lib/upgrade/.svn/entries
new file mode 100644
index 0000000..9d0891d
--- /dev/null
+++ b/package/base-files/files/lib/upgrade/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/base-files/files/lib/upgrade
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-14T18:43:58.957223Z
+36031
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+common.sh
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+5671955731b7ddeb547f916ec53d4129
+2013-03-14T18:43:58.957223Z
+36031
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5037
+
+keep.d
+dir
+
diff --git a/package/base-files/files/lib/upgrade/.svn/text-base/common.sh.svn-base b/package/base-files/files/lib/upgrade/.svn/text-base/common.sh.svn-base
new file mode 100644
index 0000000..df842bf
--- /dev/null
+++ b/package/base-files/files/lib/upgrade/.svn/text-base/common.sh.svn-base
@@ -0,0 +1,230 @@
+#!/bin/sh
+
+RAM_ROOT=/tmp/root
+
+ldd() { LD_TRACE_LOADED_OBJECTS=1 $*; }
+libs() { ldd $* | awk '{print $3}'; }
+
+install_file() { # <file> [ <file> ... ]
+ for file in "$@"; do
+ dest="$RAM_ROOT/$file"
+ [ -f $file -a ! -f $dest ] && {
+ dir="$(dirname $dest)"
+ mkdir -p "$dir"
+ cp $file $dest
+ }
+ done
+}
+
+install_bin() { # <file> [ <symlink> ... ]
+ src=$1
+ files=$1
+ [ -x "$src" ] && files="$src $(libs $src)"
+ install_file $files
+ [ -e /lib/ld-linux.so.3 ] && {
+ install_file /lib/ld-linux.so.3
+ }
+ shift
+ for link in "$@"; do {
+ dest="$RAM_ROOT/$link"
+ dir="$(dirname $dest)"
+ mkdir -p "$dir"
+ [ -f "$dest" ] || ln -s $src $dest
+ }; done
+}
+
+supivot() { # <new_root> <old_root>
+ mount | grep "on $1 type" 2>&- 1>&- || mount -o bind $1 $1
+ mkdir -p $1$2 $1/proc $1/sys $1/dev $1/tmp $1/overlay && \
+ mount -o noatime,move /proc $1/proc && \
+ pivot_root $1 $1$2 || {
+ umount -l $1 $1
+ return 1
+ }
+
+ mount -o noatime,move $2/sys /sys
+ mount -o noatime,move $2/dev /dev
+ mount -o noatime,move $2/tmp /tmp
+ mount -o noatime,move $2/overlay /overlay 2>&-
+ return 0
+}
+
+run_ramfs() { # <command> [...]
+ install_bin /bin/busybox /bin/ash /bin/sh /bin/mount /bin/umount \
+ /sbin/pivot_root /usr/bin/wget /sbin/reboot /bin/sync /bin/dd \
+ /bin/grep /bin/cp /bin/mv /bin/tar /usr/bin/md5sum "/usr/bin/[" \
+ /bin/vi /bin/ls /bin/cat /usr/bin/awk /usr/bin/hexdump \
+ /bin/sleep /bin/zcat /usr/bin/bzcat /usr/bin/printf /usr/bin/wc
+
+ install_bin /sbin/mtd
+ for file in $RAMFS_COPY_BIN; do
+ install_bin $file
+ done
+ install_file /etc/resolv.conf /lib/functions.sh /lib/functions.sh /lib/upgrade/*.sh $RAMFS_COPY_DATA
+
+ supivot $RAM_ROOT /mnt || {
+ echo "Failed to switch over to ramfs. Please reboot."
+ exit 1
+ }
+
+ mount -o remount,ro /mnt
+ umount -l /mnt
+
+ grep /overlay /proc/mounts > /dev/null && {
+ mount -o noatime,remount,ro /overlay
+ umount -l /overlay
+ }
+
+ # spawn a new shell from ramdisk to reduce the probability of cache issues
+ exec /bin/busybox ash -c "$*"
+}
+
+kill_remaining() { # [ <signal> ]
+ local sig="${1:-TERM}"
+ echo -n "Sending $sig to remaining processes ... "
+
+ local stat
+ for stat in /proc/[0-9]*/stat; do
+ [ -f "$stat" ] || continue
+
+ local pid name state ppid rest
+ read pid name state ppid rest < $stat
+ name="${name#(}"; name="${name%)}"
+
+ local cmdline
+ read cmdline < /proc/$pid/cmdline
+
+ # Skip kernel threads
+ [ -n "$cmdline" ] || continue
+
+ case "$name" in
+ # Skip essential services
+ *procd*|*ash*|*init*|*watchdog*|*ssh*|*dropbear*|*telnet*|*login*|*hostapd*|*wpa_supplicant*) : ;;
+
+ # Killable process
+ *)
+ if [ $pid -ne $$ ] && [ $ppid -ne $$ ]; then
+ echo -n "$name "
+ kill -$sig $pid 2>/dev/null
+ fi
+ ;;
+ esac
+ done
+ echo ""
+}
+
+run_hooks() {
+ local arg="$1"; shift
+ for func in "$@"; do
+ eval "$func $arg"
+ done
+}
+
+ask_bool() {
+ local default="$1"; shift;
+ local answer="$default"
+
+ [ "$INTERACTIVE" -eq 1 ] && {
+ case "$default" in
+ 0) echo -n "$* (y/N): ";;
+ *) echo -n "$* (Y/n): ";;
+ esac
+ read answer
+ case "$answer" in
+ y*) answer=1;;
+ n*) answer=0;;
+ *) answer="$default";;
+ esac
+ }
+ [ "$answer" -gt 0 ]
+}
+
+v() {
+ [ "$VERBOSE" -ge 1 ] && echo "$@"
+}
+
+rootfs_type() {
+ mount | awk '($3 ~ /^\/$/) && ($5 !~ /rootfs/) { print $5 }'
+}
+
+get_image() { # <source> [ <command> ]
+ local from="$1"
+ local conc="$2"
+ local cmd
+
+ case "$from" in
+ http://*|ftp://*) cmd="wget -O- -q";;
+ *) cmd="cat";;
+ esac
+ if [ -z "$conc" ]; then
+ local magic="$(eval $cmd $from | dd bs=2 count=1 2>/dev/null | hexdump -n 2 -e '1/1 "%02x"')"
+ case "$magic" in
+ 1f8b) conc="zcat";;
+ 425a) conc="bzcat";;
+ esac
+ fi
+
+ eval "$cmd $from ${conc:+| $conc}"
+}
+
+get_magic_word() {
+ get_image "$@" | dd bs=2 count=1 2>/dev/null | hexdump -v -n 2 -e '1/1 "%02x"'
+}
+
+get_magic_long() {
+ get_image "$@" | dd bs=4 count=1 2>/dev/null | hexdump -v -n 4 -e '1/1 "%02x"'
+}
+
+refresh_mtd_partitions() {
+ mtd refresh rootfs
+}
+
+jffs2_copy_config() {
+ if grep rootfs_data /proc/mtd >/dev/null; then
+ # squashfs+jffs2
+ mtd -e rootfs_data jffs2write "$CONF_TAR" rootfs_data
+ else
+ # jffs2
+ mtd jffs2write "$CONF_TAR" rootfs
+ fi
+}
+
+default_do_upgrade() {
+ sync
+ if [ "$SAVE_CONFIG" -eq 1 -a -z "$USE_REFRESH" ]; then
+ get_image "$1" | mtd -j "$CONF_TAR" write - "${PART_NAME:-image}"
+ else
+ get_image "$1" | mtd write - "${PART_NAME:-image}"
+ fi
+}
+
+do_upgrade() {
+ v "Performing system upgrade..."
+ if type 'platform_do_upgrade' >/dev/null 2>/dev/null; then
+ platform_do_upgrade "$ARGV"
+ else
+ default_do_upgrade "$ARGV"
+ fi
+
+ [ "$SAVE_CONFIG" -eq 1 -a -n "$USE_REFRESH" ] && {
+ v "Refreshing partitions"
+ if type 'platform_refresh_partitions' >/dev/null 2>/dev/null; then
+ platform_refresh_partitions
+ else
+ refresh_mtd_partitions
+ fi
+ if type 'platform_copy_config' >/dev/null 2>/dev/null; then
+ platform_copy_config
+ else
+ jffs2_copy_config
+ fi
+ }
+ v "Upgrade completed"
+ [ -n "$DELAY" ] && sleep "$DELAY"
+ ask_bool 1 "Reboot" && {
+ v "Rebooting system..."
+ reboot -f
+ sleep 5
+ echo b 2>/dev/null >/proc/sysrq-trigger
+ }
+}
diff --git a/package/base-files/files/lib/upgrade/common.sh b/package/base-files/files/lib/upgrade/common.sh
new file mode 100644
index 0000000..df842bf
--- /dev/null
+++ b/package/base-files/files/lib/upgrade/common.sh
@@ -0,0 +1,230 @@
+#!/bin/sh
+
+RAM_ROOT=/tmp/root
+
+ldd() { LD_TRACE_LOADED_OBJECTS=1 $*; }
+libs() { ldd $* | awk '{print $3}'; }
+
+install_file() { # <file> [ <file> ... ]
+ for file in "$@"; do
+ dest="$RAM_ROOT/$file"
+ [ -f $file -a ! -f $dest ] && {
+ dir="$(dirname $dest)"
+ mkdir -p "$dir"
+ cp $file $dest
+ }
+ done
+}
+
+install_bin() { # <file> [ <symlink> ... ]
+ src=$1
+ files=$1
+ [ -x "$src" ] && files="$src $(libs $src)"
+ install_file $files
+ [ -e /lib/ld-linux.so.3 ] && {
+ install_file /lib/ld-linux.so.3
+ }
+ shift
+ for link in "$@"; do {
+ dest="$RAM_ROOT/$link"
+ dir="$(dirname $dest)"
+ mkdir -p "$dir"
+ [ -f "$dest" ] || ln -s $src $dest
+ }; done
+}
+
+supivot() { # <new_root> <old_root>
+ mount | grep "on $1 type" 2>&- 1>&- || mount -o bind $1 $1
+ mkdir -p $1$2 $1/proc $1/sys $1/dev $1/tmp $1/overlay && \
+ mount -o noatime,move /proc $1/proc && \
+ pivot_root $1 $1$2 || {
+ umount -l $1 $1
+ return 1
+ }
+
+ mount -o noatime,move $2/sys /sys
+ mount -o noatime,move $2/dev /dev
+ mount -o noatime,move $2/tmp /tmp
+ mount -o noatime,move $2/overlay /overlay 2>&-
+ return 0
+}
+
+run_ramfs() { # <command> [...]
+ install_bin /bin/busybox /bin/ash /bin/sh /bin/mount /bin/umount \
+ /sbin/pivot_root /usr/bin/wget /sbin/reboot /bin/sync /bin/dd \
+ /bin/grep /bin/cp /bin/mv /bin/tar /usr/bin/md5sum "/usr/bin/[" \
+ /bin/vi /bin/ls /bin/cat /usr/bin/awk /usr/bin/hexdump \
+ /bin/sleep /bin/zcat /usr/bin/bzcat /usr/bin/printf /usr/bin/wc
+
+ install_bin /sbin/mtd
+ for file in $RAMFS_COPY_BIN; do
+ install_bin $file
+ done
+ install_file /etc/resolv.conf /lib/functions.sh /lib/functions.sh /lib/upgrade/*.sh $RAMFS_COPY_DATA
+
+ supivot $RAM_ROOT /mnt || {
+ echo "Failed to switch over to ramfs. Please reboot."
+ exit 1
+ }
+
+ mount -o remount,ro /mnt
+ umount -l /mnt
+
+ grep /overlay /proc/mounts > /dev/null && {
+ mount -o noatime,remount,ro /overlay
+ umount -l /overlay
+ }
+
+ # spawn a new shell from ramdisk to reduce the probability of cache issues
+ exec /bin/busybox ash -c "$*"
+}
+
+kill_remaining() { # [ <signal> ]
+ local sig="${1:-TERM}"
+ echo -n "Sending $sig to remaining processes ... "
+
+ local stat
+ for stat in /proc/[0-9]*/stat; do
+ [ -f "$stat" ] || continue
+
+ local pid name state ppid rest
+ read pid name state ppid rest < $stat
+ name="${name#(}"; name="${name%)}"
+
+ local cmdline
+ read cmdline < /proc/$pid/cmdline
+
+ # Skip kernel threads
+ [ -n "$cmdline" ] || continue
+
+ case "$name" in
+ # Skip essential services
+ *procd*|*ash*|*init*|*watchdog*|*ssh*|*dropbear*|*telnet*|*login*|*hostapd*|*wpa_supplicant*) : ;;
+
+ # Killable process
+ *)
+ if [ $pid -ne $$ ] && [ $ppid -ne $$ ]; then
+ echo -n "$name "
+ kill -$sig $pid 2>/dev/null
+ fi
+ ;;
+ esac
+ done
+ echo ""
+}
+
+run_hooks() {
+ local arg="$1"; shift
+ for func in "$@"; do
+ eval "$func $arg"
+ done
+}
+
+ask_bool() {
+ local default="$1"; shift;
+ local answer="$default"
+
+ [ "$INTERACTIVE" -eq 1 ] && {
+ case "$default" in
+ 0) echo -n "$* (y/N): ";;
+ *) echo -n "$* (Y/n): ";;
+ esac
+ read answer
+ case "$answer" in
+ y*) answer=1;;
+ n*) answer=0;;
+ *) answer="$default";;
+ esac
+ }
+ [ "$answer" -gt 0 ]
+}
+
+v() {
+ [ "$VERBOSE" -ge 1 ] && echo "$@"
+}
+
+rootfs_type() {
+ mount | awk '($3 ~ /^\/$/) && ($5 !~ /rootfs/) { print $5 }'
+}
+
+get_image() { # <source> [ <command> ]
+ local from="$1"
+ local conc="$2"
+ local cmd
+
+ case "$from" in
+ http://*|ftp://*) cmd="wget -O- -q";;
+ *) cmd="cat";;
+ esac
+ if [ -z "$conc" ]; then
+ local magic="$(eval $cmd $from | dd bs=2 count=1 2>/dev/null | hexdump -n 2 -e '1/1 "%02x"')"
+ case "$magic" in
+ 1f8b) conc="zcat";;
+ 425a) conc="bzcat";;
+ esac
+ fi
+
+ eval "$cmd $from ${conc:+| $conc}"
+}
+
+get_magic_word() {
+ get_image "$@" | dd bs=2 count=1 2>/dev/null | hexdump -v -n 2 -e '1/1 "%02x"'
+}
+
+get_magic_long() {
+ get_image "$@" | dd bs=4 count=1 2>/dev/null | hexdump -v -n 4 -e '1/1 "%02x"'
+}
+
+refresh_mtd_partitions() {
+ mtd refresh rootfs
+}
+
+jffs2_copy_config() {
+ if grep rootfs_data /proc/mtd >/dev/null; then
+ # squashfs+jffs2
+ mtd -e rootfs_data jffs2write "$CONF_TAR" rootfs_data
+ else
+ # jffs2
+ mtd jffs2write "$CONF_TAR" rootfs
+ fi
+}
+
+default_do_upgrade() {
+ sync
+ if [ "$SAVE_CONFIG" -eq 1 -a -z "$USE_REFRESH" ]; then
+ get_image "$1" | mtd -j "$CONF_TAR" write - "${PART_NAME:-image}"
+ else
+ get_image "$1" | mtd write - "${PART_NAME:-image}"
+ fi
+}
+
+do_upgrade() {
+ v "Performing system upgrade..."
+ if type 'platform_do_upgrade' >/dev/null 2>/dev/null; then
+ platform_do_upgrade "$ARGV"
+ else
+ default_do_upgrade "$ARGV"
+ fi
+
+ [ "$SAVE_CONFIG" -eq 1 -a -n "$USE_REFRESH" ] && {
+ v "Refreshing partitions"
+ if type 'platform_refresh_partitions' >/dev/null 2>/dev/null; then
+ platform_refresh_partitions
+ else
+ refresh_mtd_partitions
+ fi
+ if type 'platform_copy_config' >/dev/null 2>/dev/null; then
+ platform_copy_config
+ else
+ jffs2_copy_config
+ fi
+ }
+ v "Upgrade completed"
+ [ -n "$DELAY" ] && sleep "$DELAY"
+ ask_bool 1 "Reboot" && {
+ v "Rebooting system..."
+ reboot -f
+ sleep 5
+ echo b 2>/dev/null >/proc/sysrq-trigger
+ }
+}
diff --git a/package/base-files/files/lib/upgrade/keep.d/.svn/entries b/package/base-files/files/lib/upgrade/keep.d/.svn/entries
new file mode 100644
index 0000000..4e66190
--- /dev/null
+++ b/package/base-files/files/lib/upgrade/keep.d/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/base-files/files/lib/upgrade/keep.d
+svn://svn.openwrt.org/openwrt
+
+
+
+2010-12-20T19:51:05.233718Z
+24742
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+base-files-essential
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+9290cfe4776fdf4e40a00d21ca852014
+2010-12-20T19:51:05.233718Z
+24742
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+146
+
diff --git a/package/base-files/files/lib/upgrade/keep.d/.svn/text-base/base-files-essential.svn-base b/package/base-files/files/lib/upgrade/keep.d/.svn/text-base/base-files-essential.svn-base
new file mode 100644
index 0000000..2c611d2
--- /dev/null
+++ b/package/base-files/files/lib/upgrade/keep.d/.svn/text-base/base-files-essential.svn-base
@@ -0,0 +1,9 @@
+# Essential files that will be always kept
+/etc/hosts
+/etc/inittab
+/etc/group
+/etc/passwd
+/etc/profile
+/etc/shells
+/etc/sysctl.conf
+/etc/rc.local
diff --git a/package/base-files/files/lib/upgrade/keep.d/base-files-essential b/package/base-files/files/lib/upgrade/keep.d/base-files-essential
new file mode 100644
index 0000000..2c611d2
--- /dev/null
+++ b/package/base-files/files/lib/upgrade/keep.d/base-files-essential
@@ -0,0 +1,9 @@
+# Essential files that will be always kept
+/etc/hosts
+/etc/inittab
+/etc/group
+/etc/passwd
+/etc/profile
+/etc/shells
+/etc/sysctl.conf
+/etc/rc.local
diff --git a/package/base-files/files/rom/.svn/entries b/package/base-files/files/rom/.svn/entries
new file mode 100644
index 0000000..891d42d
--- /dev/null
+++ b/package/base-files/files/rom/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/base-files/files/rom
+svn://svn.openwrt.org/openwrt
+
+
+
+2009-04-17T14:32:29.989894Z
+15245
+nico
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+note
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+6e5a89f15dded527d05ebae365b50041
+2009-04-17T14:32:29.989894Z
+15245
+nico
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+116
+
diff --git a/package/base-files/files/rom/.svn/prop-base/note.svn-base b/package/base-files/files/rom/.svn/prop-base/note.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/base-files/files/rom/.svn/prop-base/note.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/base-files/files/rom/.svn/text-base/note.svn-base b/package/base-files/files/rom/.svn/text-base/note.svn-base
new file mode 100644
index 0000000..1746eb0
--- /dev/null
+++ b/package/base-files/files/rom/.svn/text-base/note.svn-base
@@ -0,0 +1,3 @@
+SQUASHFS USERS:
+After firstboot has been run, / will be jffs2 and /rom will be squashfs
+(* except when in failsafe)
diff --git a/package/base-files/files/rom/note b/package/base-files/files/rom/note
new file mode 100644
index 0000000..1746eb0
--- /dev/null
+++ b/package/base-files/files/rom/note
@@ -0,0 +1,3 @@
+SQUASHFS USERS:
+After firstboot has been run, / will be jffs2 and /rom will be squashfs
+(* except when in failsafe)
diff --git a/package/base-files/files/sbin/.svn/entries b/package/base-files/files/sbin/.svn/entries
new file mode 100644
index 0000000..977ed47
--- /dev/null
+++ b/package/base-files/files/sbin/.svn/entries
@@ -0,0 +1,232 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/base-files/files/sbin
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-02-21T11:45:14.787839Z
+35712
+jogo
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+mount_root
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+ef6b97908416845d1ebb9d697c3e8594
+2012-12-19T16:07:53.948034Z
+34794
+mirko
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+512
+
+sysupgrade
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+80dd8b00b37af0da40d9b0ca20534dfe
+2013-01-02T16:21:30.448164Z
+34975
+jow
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4780
+
+firstboot
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+e758da5c290339b002ad110ebefb67e5
+2013-02-21T11:45:14.787839Z
+35712
+jogo
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+850
+
+hotplug-call
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+391bb18bb651ae8339f16d8314216ea2
+2012-06-05T16:04:23.055438Z
+32062
+jow
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+317
+
+led.sh
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+9ce20c80054eec2b3f1dd983a397f979
+2012-06-05T16:04:23.055438Z
+32062
+jow
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+500
+
+wifi
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+833e83b54896be7375af57286730b587
+2012-06-26T15:25:33.271356Z
+32503
+jow
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3944
+
diff --git a/package/base-files/files/sbin/.svn/prop-base/firstboot.svn-base b/package/base-files/files/sbin/.svn/prop-base/firstboot.svn-base
new file mode 100644
index 0000000..03b5bfa
--- /dev/null
+++ b/package/base-files/files/sbin/.svn/prop-base/firstboot.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:eol-style
+V 6
+native
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/base-files/files/sbin/.svn/prop-base/hotplug-call.svn-base b/package/base-files/files/sbin/.svn/prop-base/hotplug-call.svn-base
new file mode 100644
index 0000000..03b5bfa
--- /dev/null
+++ b/package/base-files/files/sbin/.svn/prop-base/hotplug-call.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:eol-style
+V 6
+native
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/base-files/files/sbin/.svn/prop-base/led.sh.svn-base b/package/base-files/files/sbin/.svn/prop-base/led.sh.svn-base
new file mode 100644
index 0000000..869ac71
--- /dev/null
+++ b/package/base-files/files/sbin/.svn/prop-base/led.sh.svn-base
@@ -0,0 +1,5 @@
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/base-files/files/sbin/.svn/prop-base/mount_root.svn-base b/package/base-files/files/sbin/.svn/prop-base/mount_root.svn-base
new file mode 100644
index 0000000..03b5bfa
--- /dev/null
+++ b/package/base-files/files/sbin/.svn/prop-base/mount_root.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:eol-style
+V 6
+native
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/base-files/files/sbin/.svn/prop-base/sysupgrade.svn-base b/package/base-files/files/sbin/.svn/prop-base/sysupgrade.svn-base
new file mode 100644
index 0000000..869ac71
--- /dev/null
+++ b/package/base-files/files/sbin/.svn/prop-base/sysupgrade.svn-base
@@ -0,0 +1,5 @@
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/base-files/files/sbin/.svn/prop-base/wifi.svn-base b/package/base-files/files/sbin/.svn/prop-base/wifi.svn-base
new file mode 100644
index 0000000..03b5bfa
--- /dev/null
+++ b/package/base-files/files/sbin/.svn/prop-base/wifi.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:eol-style
+V 6
+native
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/base-files/files/sbin/.svn/text-base/firstboot.svn-base b/package/base-files/files/sbin/.svn/text-base/firstboot.svn-base
new file mode 100644
index 0000000..e7c0851
--- /dev/null
+++ b/package/base-files/files/sbin/.svn/text-base/firstboot.svn-base
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+switch2jffs_hook=
+jffs2reset_hook=
+no_fo_hook=
+
+. /lib/functions.sh
+
+firstboot_skip_next=false
+
+for fb_source_file in /lib/firstboot/*; do
+ . $fb_source_file
+done
+
+set_mtd_part
+set_rom_part
+set_jffs_part
+
+# invoked as an executable
+if [ "${0##*/}" = "firstboot" ]; then
+ if [ "$1" = "switch2jffs" ]; then
+ boot_run_hook switch2jffs
+ else
+ local input
+
+ echo -n "firstboot will erase all settings and remove any installed packages. Are you sure? [N/y]"
+ read input
+ [ "$input" = "y" ] || [ "$input" = "Y" ] || return 0
+
+ if [ -n "$jffs" ]; then
+ reset_has_fo=true
+ echo "firstboot has already been run"
+ echo "jffs2 partition is mounted, only resetting files"
+ boot_run_hook jffs2reset
+ else
+ mtd erase "$partname"
+ mount -o noatime "$mtdpart" /overlay -t jffs2
+ fopivot /overlay /rom 1
+ fi
+ fi
+fi
+
diff --git a/package/base-files/files/sbin/.svn/text-base/hotplug-call.svn-base b/package/base-files/files/sbin/.svn/text-base/hotplug-call.svn-base
new file mode 100644
index 0000000..d627bec
--- /dev/null
+++ b/package/base-files/files/sbin/.svn/text-base/hotplug-call.svn-base
@@ -0,0 +1,17 @@
+#!/bin/sh
+# Copyright (C) 2006-2010 OpenWrt.org
+
+export HOTPLUG_TYPE="$1"
+
+. /lib/functions.sh
+
+PATH=/bin:/sbin:/usr/bin:/usr/sbin
+LOGNAME=root
+USER=root
+export PATH LOGNAME USER
+
+[ \! -z "$1" -a -d /etc/hotplug.d/$1 ] && {
+ for script in $(ls /etc/hotplug.d/$1/* 2>&-); do (
+ [ -f $script ] && . $script
+ ); done
+}
diff --git a/package/base-files/files/sbin/.svn/text-base/led.sh.svn-base b/package/base-files/files/sbin/.svn/text-base/led.sh.svn-base
new file mode 100644
index 0000000..d67a0f5
--- /dev/null
+++ b/package/base-files/files/sbin/.svn/text-base/led.sh.svn-base
@@ -0,0 +1,25 @@
+#!/bin/sh
+# (C) 2008 openwrt.org
+
+. /lib/functions.sh
+ACTION=$1
+NAME=$2
+do_led() {
+ local name
+ local sysfs
+ config_get name $1 name
+ config_get sysfs $1 sysfs
+ [ "$name" == "$NAME" -o "$sysfs" = "$NAME" -a -e "/sys/class/leds/${sysfs}" ] && {
+ [ "$ACTION" == "set" ] &&
+ echo 1 >/sys/class/leds/${sysfs}/brightness \
+ || echo 0 >/sys/class/leds/${sysfs}/brightness
+ exit 0
+ }
+}
+
+[ "$1" == "clear" -o "$1" == "set" ] &&
+ [ -n "$2" ] &&{
+ config_load system
+ config_foreach do_led
+ exit 1
+ }
diff --git a/package/base-files/files/sbin/.svn/text-base/mount_root.svn-base b/package/base-files/files/sbin/.svn/text-base/mount_root.svn-base
new file mode 100644
index 0000000..1c48eba
--- /dev/null
+++ b/package/base-files/files/sbin/.svn/text-base/mount_root.svn-base
@@ -0,0 +1,26 @@
+#!/bin/sh
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+# Initialize hook variables et by pulling in from preinit
+
+preinit_essential_hook=
+preinit_main_hook=
+failsafe_hook=
+initramfs_hook=
+preinit_mount_root=
+
+. /lib/functions.sh
+
+for pi_source_file in /lib/preinit/*; do
+ . $pi_source_file
+done
+
+# Override function that doesn't apply to use of mount_root as a command rather
+# than as part of preinit
+
+preinit_echo() {
+ echo "$@"
+}
+
+boot_run_hook preinit_mount_root
diff --git a/package/base-files/files/sbin/.svn/text-base/sysupgrade.svn-base b/package/base-files/files/sbin/.svn/text-base/sysupgrade.svn-base
new file mode 100644
index 0000000..6701930
--- /dev/null
+++ b/package/base-files/files/sbin/.svn/text-base/sysupgrade.svn-base
@@ -0,0 +1,191 @@
+#!/bin/sh
+. /lib/functions.sh
+
+# initialize defaults
+RAMFS_COPY_BIN="" # extra programs for temporary ramfs root
+RAMFS_COPY_DATA="" # extra data files
+export INTERACTIVE=0
+export VERBOSE=1
+export SAVE_CONFIG=1
+export SAVE_OVERLAY=0
+export DELAY=
+export CONF_IMAGE=
+export CONF_BACKUP=
+export CONF_RESTORE=
+export NEED_IMAGE=
+export HELP=0
+export FORCE=0
+
+# parse options
+while [ -n "$1" ]; do
+ case "$1" in
+ -i) export INTERACTIVE=1;;
+ -d) export DELAY="$2"; shift;;
+ -v) export VERBOSE="$(($VERBOSE + 1))";;
+ -q) export VERBOSE="$(($VERBOSE - 1))";;
+ -n) export SAVE_CONFIG=0;;
+ -c) export SAVE_OVERLAY=1;;
+ -b|--create-backup) export CONF_BACKUP="$2" NEED_IMAGE=1; shift;;
+ -r|--restore-backup) export CONF_RESTORE="$2" NEED_IMAGE=1; shift;;
+ -f) export CONF_IMAGE="$2"; shift;;
+ -F|--force) export FORCE=1;;
+ -h|--help) export HELP=1; break;;
+ -*)
+ echo "Invalid option: $1"
+ exit 1
+ ;;
+ *) break;;
+ esac
+ shift;
+done
+
+export CONFFILES=/tmp/sysupgrade.conffiles
+export CONF_TAR=/tmp/sysupgrade.tgz
+
+export ARGV="$*"
+export ARGC="$#"
+
+[ -z "$ARGV" -a -z "$NEED_IMAGE" -o $HELP -gt 0 ] && {
+ cat <<EOF
+Usage: $0 [<upgrade-option>...] <image file or URL>
+ $0 [-q] [-i] <backup-command> <file>
+
+upgrade-option:
+ -d <delay> add a delay before rebooting
+ -f <config> restore configuration from .tar.gz (file or url)
+ -i interactive mode
+ -c attempt to preserve all changed files in /etc/
+ -n do not save configuration over reflash
+ -F | --force
+ Flash image even if image checks fail, this is dangerous!
+ -q less verbose
+ -v more verbose
+ -h | --help display this help
+
+backup-command:
+ -b | --create-backup <file>
+ create .tar.gz of files specified in sysupgrade.conf
+ then exit. Does not flash an image. If file is '-',
+ i.e. stdout, verbosity is set to 0 (i.e. quiet).
+ -r | --restore-backup <file>
+ restore a .tar.gz created with sysupgrade -b
+ then exit. Does not flash an image. If file is '-',
+ the archive is read from stdin.
+
+EOF
+ exit 1
+}
+
+[ -n "$ARGV" -a -n "$NEED_IMAGE" ] && {
+ cat <<-EOF
+ -b|--create-backup and -r|--restore-backup do not perform a firmware upgrade.
+ Do not specify both -b|-r and a firmware image.
+ EOF
+ exit 1
+}
+
+# prevent messages from clobbering the tarball when using stdout
+[ "$CONF_BACKUP" = "-" ] && export VERBOSE=0
+
+add_uci_conffiles() {
+ local file="$1"
+ ( find $(sed -ne '/^[[:space:]]*$/d; /^#/d; p' \
+ /etc/sysupgrade.conf /lib/upgrade/keep.d/* 2>/dev/null) \
+ -type f 2>/dev/null;
+ opkg list-changed-conffiles ) | sort -u > "$file"
+ return 0
+}
+
+add_overlayfiles() {
+ local file="$1"
+ find /overlay/etc/ -type f | sed \
+ -e 's,^/overlay/,/,' \
+ -e '\,/META_[a-zA-Z0-9]*$,d' \
+ -e '\,/functions.sh$,d' \
+ -e '\,/[^/]*-opkg$,d' \
+ > "$file"
+ return 0
+}
+
+# hooks
+sysupgrade_image_check="platform_check_image"
+[ $SAVE_OVERLAY = 0 -o ! -d /overlay/etc ] && \
+ sysupgrade_init_conffiles="add_uci_conffiles" || \
+ sysupgrade_init_conffiles="add_overlayfiles"
+
+include /lib/upgrade
+
+do_save_conffiles() {
+ local conf_tar="${1:-$CONF_TAR}"
+
+ [ -z "$(rootfs_type)" ] && {
+ echo "Cannot save config while running from ramdisk."
+ ask_bool 0 "Abort" && exit
+ return 0
+ }
+ run_hooks "$CONFFILES" $sysupgrade_init_conffiles
+ ask_bool 0 "Edit config file list" && vi "$CONFFILES"
+
+ v "Saving config files..."
+ [ "$VERBOSE" -gt 1 ] && TAR_V="v" || TAR_V=""
+ tar c${TAR_V}zf "$conf_tar" -T "$CONFFILES" 2>/dev/null
+}
+
+if [ -n "$CONF_BACKUP" ]; then
+ do_save_conffiles "$CONF_BACKUP"
+ exit $?
+fi
+
+if [ -f "$CONF_RESTORE" ] || [ "$CONF_RESTORE" = "-" ]; then
+ [ "$VERBOSE" -gt 1 ] && TAR_V="v" || TAR_V=""
+ tar -C / -x${TAR_V}zf "$CONF_RESTORE"
+ exit $?
+fi
+
+type platform_check_image >/dev/null 2>/dev/null || {
+ echo "Firmware upgrade is not implemented for this platform."
+ exit 1
+}
+
+for check in $sysupgrade_image_check; do
+ ( eval "$check \"\$ARGV\"" ) || {
+ if [ $FORCE -eq 1 ]; then
+ echo "Image check '$check' failed but --force given - will update anyway!"
+ break
+ else
+ echo "Image check '$check' failed."
+ exit 1
+ fi
+ }
+done
+
+if [ -n "$CONF_IMAGE" ]; then
+ case "$(get_magic_word $CONF_IMAGE cat)" in
+ # .gz files
+ 1f8b) ;;
+ *)
+ echo "Invalid config file. Please use only .tar.gz files"
+ exit 1
+ ;;
+ esac
+ get_image "$CONF_IMAGE" "cat" > "$CONF_TAR"
+ export SAVE_CONFIG=1
+elif ask_bool $SAVE_CONFIG "Keep config files over reflash"; then
+ do_save_conffiles
+ export SAVE_CONFIG=1
+else
+ export SAVE_CONFIG=0
+fi
+
+run_hooks "" $sysupgrade_pre_upgrade
+
+kill_remaining TERM
+sleep 3
+kill_remaining KILL
+
+if [ -n "$(rootfs_type)" ]; then
+ v "Switching to ramdisk..."
+ run_ramfs '. /lib/functions.sh; include /lib/upgrade; do_upgrade'
+else
+ do_upgrade
+fi
diff --git a/package/base-files/files/sbin/.svn/text-base/wifi.svn-base b/package/base-files/files/sbin/.svn/text-base/wifi.svn-base
new file mode 100644
index 0000000..ef20787
--- /dev/null
+++ b/package/base-files/files/sbin/.svn/text-base/wifi.svn-base
@@ -0,0 +1,204 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+
+. /lib/functions.sh
+
+usage() {
+ cat <<EOF
+Usage: $0 [down|detect]
+enables (default), disables or detects a wifi configuration.
+EOF
+ exit 1
+}
+
+find_net_config() {(
+ local vif="$1"
+ local cfg
+ local ifname
+
+ config_get cfg "$vif" network
+
+ [ -z "$cfg" ] && {
+ include /lib/network
+ scan_interfaces
+
+ config_get ifname "$vif" ifname
+
+ cfg="$(find_config "$ifname")"
+ }
+ [ -z "$cfg" ] && return 0
+ echo "$cfg"
+)}
+
+
+bridge_interface() {(
+ local cfg="$1"
+ [ -z "$cfg" ] && return 0
+
+ include /lib/network
+ scan_interfaces
+
+ for cfg in $cfg; do
+ config_get iftype "$cfg" type
+ [ "$iftype" = bridge ] && config_get "$cfg" ifname
+ prepare_interface_bridge "$cfg"
+ return $?
+ done
+)}
+
+prepare_key_wep() {
+ local key="$1"
+ local hex=1
+
+ echo -n "$key" | grep -qE "[^a-fA-F0-9]" && hex=0
+ [ "${#key}" -eq 10 -a $hex -eq 1 ] || \
+ [ "${#key}" -eq 26 -a $hex -eq 1 ] || {
+ [ "${key:0:2}" = "s:" ] && key="${key#s:}"
+ key="$(echo -n "$key" | hexdump -ve '1/1 "%02x" ""')"
+ }
+ echo "$key"
+}
+
+wifi_fixup_hwmode() {
+ local device="$1"
+ local default="$2"
+ local hwmode hwmode_11n
+
+ config_get channel "$device" channel
+ config_get hwmode "$device" hwmode
+ case "$hwmode" in
+ 11bg) hwmode=bg;;
+ 11a) hwmode=a;;
+ 11b) hwmode=b;;
+ 11g) hwmode=g;;
+ 11n*)
+ hwmode_11n="${hwmode##11n}"
+ case "$hwmode_11n" in
+ a|g) ;;
+ default) hwmode_11n="$default"
+ esac
+ config_set "$device" hwmode_11n "$hwmode_11n"
+ ;;
+ *)
+ hwmode=
+ if [ "${channel:-0}" -gt 0 ]; then
+ if [ "${channel:-0}" -gt 14 ]; then
+ hwmode=a
+ else
+ hwmode=g
+ fi
+ else
+ hwmode="$default"
+ fi
+ ;;
+ esac
+ config_set "$device" hwmode "$hwmode"
+}
+
+wifi_updown() {
+ [ enable = "$1" ] && {
+ wifi_updown disable "$2"
+ scan_wifi
+ }
+ for device in ${2:-$DEVICES}; do (
+ config_get disabled "$device" disabled
+ [ 1 == "$disabled" ] && {
+ echo "'$device' is disabled"
+ set disable
+ }
+ config_get iftype "$device" type
+ if eval "type ${1}_$iftype" 2>/dev/null >/dev/null; then
+ eval "scan_$iftype '$device'"
+ eval "${1}_$iftype '$device'" || echo "$device($iftype): ${1} failed"
+ else
+ echo "$device($iftype): Interface type not supported"
+ fi
+ ); done
+}
+
+wifi_detect() {
+ for driver in ${2:-$DRIVERS}; do (
+ if eval "type detect_$driver" 2>/dev/null >/dev/null; then
+ eval "detect_$driver" || echo "$driver: Detect failed" >&2
+ else
+ echo "$driver: Hardware detection not supported" >&2
+ fi
+ ); done
+}
+
+start_net() {(
+ local iface="$1"
+ local config="$2"
+ local vifmac="$3"
+
+ [ -f "/var/run/$iface.pid" ] && kill "$(cat /var/run/${iface}.pid)" 2>/dev/null
+ [ -z "$config" ] || {
+ include /lib/network
+ scan_interfaces
+ for config in $config; do
+ setup_interface "$iface" "$config" "" "$vifmac"
+ done
+ }
+)}
+
+set_wifi_up() {
+ local cfg="$1"
+ local ifname="$2"
+ uci_set_state wireless "$cfg" up 1
+ uci_set_state wireless "$cfg" ifname "$ifname"
+}
+
+set_wifi_down() {
+ local cfg="$1"
+ local vifs vif vifstr
+
+ [ -f "/var/run/wifi-${cfg}.pid" ] &&
+ kill "$(cat "/var/run/wifi-${cfg}.pid")" 2>/dev/null
+ uci_revert_state wireless "$cfg"
+ config_get vifs "$cfg" vifs
+ for vif in $vifs; do
+ uci_revert_state wireless "$vif"
+ done
+}
+
+scan_wifi() {
+ local cfgfile="$1"
+ DEVICES=
+ config_cb() {
+ local type="$1"
+ local section="$2"
+
+ # section start
+ case "$type" in
+ wifi-device)
+ append DEVICES "$section"
+ config_set "$section" vifs ""
+ config_set "$section" ht_capab ""
+ ;;
+ esac
+
+ # section end
+ config_get TYPE "$CONFIG_SECTION" TYPE
+ case "$TYPE" in
+ wifi-iface)
+ config_get device "$CONFIG_SECTION" device
+ config_get vifs "$device" vifs
+ append vifs "$CONFIG_SECTION"
+ config_set "$device" vifs "$vifs"
+ ;;
+ esac
+ }
+ config_load "${cfgfile:-wireless}"
+}
+
+DEVICES=
+DRIVERS=
+include /lib/wifi
+scan_wifi
+
+case "$1" in
+ down) wifi_updown "disable" "$2";;
+ detect) wifi_detect "$2";;
+ --help|help) usage;;
+ *) wifi_updown "enable" "$2";;
+esac
diff --git a/package/base-files/files/sbin/firstboot b/package/base-files/files/sbin/firstboot
new file mode 100755
index 0000000..e7c0851
--- /dev/null
+++ b/package/base-files/files/sbin/firstboot
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+switch2jffs_hook=
+jffs2reset_hook=
+no_fo_hook=
+
+. /lib/functions.sh
+
+firstboot_skip_next=false
+
+for fb_source_file in /lib/firstboot/*; do
+ . $fb_source_file
+done
+
+set_mtd_part
+set_rom_part
+set_jffs_part
+
+# invoked as an executable
+if [ "${0##*/}" = "firstboot" ]; then
+ if [ "$1" = "switch2jffs" ]; then
+ boot_run_hook switch2jffs
+ else
+ local input
+
+ echo -n "firstboot will erase all settings and remove any installed packages. Are you sure? [N/y]"
+ read input
+ [ "$input" = "y" ] || [ "$input" = "Y" ] || return 0
+
+ if [ -n "$jffs" ]; then
+ reset_has_fo=true
+ echo "firstboot has already been run"
+ echo "jffs2 partition is mounted, only resetting files"
+ boot_run_hook jffs2reset
+ else
+ mtd erase "$partname"
+ mount -o noatime "$mtdpart" /overlay -t jffs2
+ fopivot /overlay /rom 1
+ fi
+ fi
+fi
+
diff --git a/package/base-files/files/sbin/hotplug-call b/package/base-files/files/sbin/hotplug-call
new file mode 100755
index 0000000..d627bec
--- /dev/null
+++ b/package/base-files/files/sbin/hotplug-call
@@ -0,0 +1,17 @@
+#!/bin/sh
+# Copyright (C) 2006-2010 OpenWrt.org
+
+export HOTPLUG_TYPE="$1"
+
+. /lib/functions.sh
+
+PATH=/bin:/sbin:/usr/bin:/usr/sbin
+LOGNAME=root
+USER=root
+export PATH LOGNAME USER
+
+[ \! -z "$1" -a -d /etc/hotplug.d/$1 ] && {
+ for script in $(ls /etc/hotplug.d/$1/* 2>&-); do (
+ [ -f $script ] && . $script
+ ); done
+}
diff --git a/package/base-files/files/sbin/led.sh b/package/base-files/files/sbin/led.sh
new file mode 100755
index 0000000..d67a0f5
--- /dev/null
+++ b/package/base-files/files/sbin/led.sh
@@ -0,0 +1,25 @@
+#!/bin/sh
+# (C) 2008 openwrt.org
+
+. /lib/functions.sh
+ACTION=$1
+NAME=$2
+do_led() {
+ local name
+ local sysfs
+ config_get name $1 name
+ config_get sysfs $1 sysfs
+ [ "$name" == "$NAME" -o "$sysfs" = "$NAME" -a -e "/sys/class/leds/${sysfs}" ] && {
+ [ "$ACTION" == "set" ] &&
+ echo 1 >/sys/class/leds/${sysfs}/brightness \
+ || echo 0 >/sys/class/leds/${sysfs}/brightness
+ exit 0
+ }
+}
+
+[ "$1" == "clear" -o "$1" == "set" ] &&
+ [ -n "$2" ] &&{
+ config_load system
+ config_foreach do_led
+ exit 1
+ }
diff --git a/package/base-files/files/sbin/mount_root b/package/base-files/files/sbin/mount_root
new file mode 100755
index 0000000..1c48eba
--- /dev/null
+++ b/package/base-files/files/sbin/mount_root
@@ -0,0 +1,26 @@
+#!/bin/sh
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+# Initialize hook variables et by pulling in from preinit
+
+preinit_essential_hook=
+preinit_main_hook=
+failsafe_hook=
+initramfs_hook=
+preinit_mount_root=
+
+. /lib/functions.sh
+
+for pi_source_file in /lib/preinit/*; do
+ . $pi_source_file
+done
+
+# Override function that doesn't apply to use of mount_root as a command rather
+# than as part of preinit
+
+preinit_echo() {
+ echo "$@"
+}
+
+boot_run_hook preinit_mount_root
diff --git a/package/base-files/files/sbin/sysupgrade b/package/base-files/files/sbin/sysupgrade
new file mode 100755
index 0000000..6701930
--- /dev/null
+++ b/package/base-files/files/sbin/sysupgrade
@@ -0,0 +1,191 @@
+#!/bin/sh
+. /lib/functions.sh
+
+# initialize defaults
+RAMFS_COPY_BIN="" # extra programs for temporary ramfs root
+RAMFS_COPY_DATA="" # extra data files
+export INTERACTIVE=0
+export VERBOSE=1
+export SAVE_CONFIG=1
+export SAVE_OVERLAY=0
+export DELAY=
+export CONF_IMAGE=
+export CONF_BACKUP=
+export CONF_RESTORE=
+export NEED_IMAGE=
+export HELP=0
+export FORCE=0
+
+# parse options
+while [ -n "$1" ]; do
+ case "$1" in
+ -i) export INTERACTIVE=1;;
+ -d) export DELAY="$2"; shift;;
+ -v) export VERBOSE="$(($VERBOSE + 1))";;
+ -q) export VERBOSE="$(($VERBOSE - 1))";;
+ -n) export SAVE_CONFIG=0;;
+ -c) export SAVE_OVERLAY=1;;
+ -b|--create-backup) export CONF_BACKUP="$2" NEED_IMAGE=1; shift;;
+ -r|--restore-backup) export CONF_RESTORE="$2" NEED_IMAGE=1; shift;;
+ -f) export CONF_IMAGE="$2"; shift;;
+ -F|--force) export FORCE=1;;
+ -h|--help) export HELP=1; break;;
+ -*)
+ echo "Invalid option: $1"
+ exit 1
+ ;;
+ *) break;;
+ esac
+ shift;
+done
+
+export CONFFILES=/tmp/sysupgrade.conffiles
+export CONF_TAR=/tmp/sysupgrade.tgz
+
+export ARGV="$*"
+export ARGC="$#"
+
+[ -z "$ARGV" -a -z "$NEED_IMAGE" -o $HELP -gt 0 ] && {
+ cat <<EOF
+Usage: $0 [<upgrade-option>...] <image file or URL>
+ $0 [-q] [-i] <backup-command> <file>
+
+upgrade-option:
+ -d <delay> add a delay before rebooting
+ -f <config> restore configuration from .tar.gz (file or url)
+ -i interactive mode
+ -c attempt to preserve all changed files in /etc/
+ -n do not save configuration over reflash
+ -F | --force
+ Flash image even if image checks fail, this is dangerous!
+ -q less verbose
+ -v more verbose
+ -h | --help display this help
+
+backup-command:
+ -b | --create-backup <file>
+ create .tar.gz of files specified in sysupgrade.conf
+ then exit. Does not flash an image. If file is '-',
+ i.e. stdout, verbosity is set to 0 (i.e. quiet).
+ -r | --restore-backup <file>
+ restore a .tar.gz created with sysupgrade -b
+ then exit. Does not flash an image. If file is '-',
+ the archive is read from stdin.
+
+EOF
+ exit 1
+}
+
+[ -n "$ARGV" -a -n "$NEED_IMAGE" ] && {
+ cat <<-EOF
+ -b|--create-backup and -r|--restore-backup do not perform a firmware upgrade.
+ Do not specify both -b|-r and a firmware image.
+ EOF
+ exit 1
+}
+
+# prevent messages from clobbering the tarball when using stdout
+[ "$CONF_BACKUP" = "-" ] && export VERBOSE=0
+
+add_uci_conffiles() {
+ local file="$1"
+ ( find $(sed -ne '/^[[:space:]]*$/d; /^#/d; p' \
+ /etc/sysupgrade.conf /lib/upgrade/keep.d/* 2>/dev/null) \
+ -type f 2>/dev/null;
+ opkg list-changed-conffiles ) | sort -u > "$file"
+ return 0
+}
+
+add_overlayfiles() {
+ local file="$1"
+ find /overlay/etc/ -type f | sed \
+ -e 's,^/overlay/,/,' \
+ -e '\,/META_[a-zA-Z0-9]*$,d' \
+ -e '\,/functions.sh$,d' \
+ -e '\,/[^/]*-opkg$,d' \
+ > "$file"
+ return 0
+}
+
+# hooks
+sysupgrade_image_check="platform_check_image"
+[ $SAVE_OVERLAY = 0 -o ! -d /overlay/etc ] && \
+ sysupgrade_init_conffiles="add_uci_conffiles" || \
+ sysupgrade_init_conffiles="add_overlayfiles"
+
+include /lib/upgrade
+
+do_save_conffiles() {
+ local conf_tar="${1:-$CONF_TAR}"
+
+ [ -z "$(rootfs_type)" ] && {
+ echo "Cannot save config while running from ramdisk."
+ ask_bool 0 "Abort" && exit
+ return 0
+ }
+ run_hooks "$CONFFILES" $sysupgrade_init_conffiles
+ ask_bool 0 "Edit config file list" && vi "$CONFFILES"
+
+ v "Saving config files..."
+ [ "$VERBOSE" -gt 1 ] && TAR_V="v" || TAR_V=""
+ tar c${TAR_V}zf "$conf_tar" -T "$CONFFILES" 2>/dev/null
+}
+
+if [ -n "$CONF_BACKUP" ]; then
+ do_save_conffiles "$CONF_BACKUP"
+ exit $?
+fi
+
+if [ -f "$CONF_RESTORE" ] || [ "$CONF_RESTORE" = "-" ]; then
+ [ "$VERBOSE" -gt 1 ] && TAR_V="v" || TAR_V=""
+ tar -C / -x${TAR_V}zf "$CONF_RESTORE"
+ exit $?
+fi
+
+type platform_check_image >/dev/null 2>/dev/null || {
+ echo "Firmware upgrade is not implemented for this platform."
+ exit 1
+}
+
+for check in $sysupgrade_image_check; do
+ ( eval "$check \"\$ARGV\"" ) || {
+ if [ $FORCE -eq 1 ]; then
+ echo "Image check '$check' failed but --force given - will update anyway!"
+ break
+ else
+ echo "Image check '$check' failed."
+ exit 1
+ fi
+ }
+done
+
+if [ -n "$CONF_IMAGE" ]; then
+ case "$(get_magic_word $CONF_IMAGE cat)" in
+ # .gz files
+ 1f8b) ;;
+ *)
+ echo "Invalid config file. Please use only .tar.gz files"
+ exit 1
+ ;;
+ esac
+ get_image "$CONF_IMAGE" "cat" > "$CONF_TAR"
+ export SAVE_CONFIG=1
+elif ask_bool $SAVE_CONFIG "Keep config files over reflash"; then
+ do_save_conffiles
+ export SAVE_CONFIG=1
+else
+ export SAVE_CONFIG=0
+fi
+
+run_hooks "" $sysupgrade_pre_upgrade
+
+kill_remaining TERM
+sleep 3
+kill_remaining KILL
+
+if [ -n "$(rootfs_type)" ]; then
+ v "Switching to ramdisk..."
+ run_ramfs '. /lib/functions.sh; include /lib/upgrade; do_upgrade'
+else
+ do_upgrade
+fi
diff --git a/package/base-files/files/sbin/wifi b/package/base-files/files/sbin/wifi
new file mode 100755
index 0000000..ef20787
--- /dev/null
+++ b/package/base-files/files/sbin/wifi
@@ -0,0 +1,204 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+
+. /lib/functions.sh
+
+usage() {
+ cat <<EOF
+Usage: $0 [down|detect]
+enables (default), disables or detects a wifi configuration.
+EOF
+ exit 1
+}
+
+find_net_config() {(
+ local vif="$1"
+ local cfg
+ local ifname
+
+ config_get cfg "$vif" network
+
+ [ -z "$cfg" ] && {
+ include /lib/network
+ scan_interfaces
+
+ config_get ifname "$vif" ifname
+
+ cfg="$(find_config "$ifname")"
+ }
+ [ -z "$cfg" ] && return 0
+ echo "$cfg"
+)}
+
+
+bridge_interface() {(
+ local cfg="$1"
+ [ -z "$cfg" ] && return 0
+
+ include /lib/network
+ scan_interfaces
+
+ for cfg in $cfg; do
+ config_get iftype "$cfg" type
+ [ "$iftype" = bridge ] && config_get "$cfg" ifname
+ prepare_interface_bridge "$cfg"
+ return $?
+ done
+)}
+
+prepare_key_wep() {
+ local key="$1"
+ local hex=1
+
+ echo -n "$key" | grep -qE "[^a-fA-F0-9]" && hex=0
+ [ "${#key}" -eq 10 -a $hex -eq 1 ] || \
+ [ "${#key}" -eq 26 -a $hex -eq 1 ] || {
+ [ "${key:0:2}" = "s:" ] && key="${key#s:}"
+ key="$(echo -n "$key" | hexdump -ve '1/1 "%02x" ""')"
+ }
+ echo "$key"
+}
+
+wifi_fixup_hwmode() {
+ local device="$1"
+ local default="$2"
+ local hwmode hwmode_11n
+
+ config_get channel "$device" channel
+ config_get hwmode "$device" hwmode
+ case "$hwmode" in
+ 11bg) hwmode=bg;;
+ 11a) hwmode=a;;
+ 11b) hwmode=b;;
+ 11g) hwmode=g;;
+ 11n*)
+ hwmode_11n="${hwmode##11n}"
+ case "$hwmode_11n" in
+ a|g) ;;
+ default) hwmode_11n="$default"
+ esac
+ config_set "$device" hwmode_11n "$hwmode_11n"
+ ;;
+ *)
+ hwmode=
+ if [ "${channel:-0}" -gt 0 ]; then
+ if [ "${channel:-0}" -gt 14 ]; then
+ hwmode=a
+ else
+ hwmode=g
+ fi
+ else
+ hwmode="$default"
+ fi
+ ;;
+ esac
+ config_set "$device" hwmode "$hwmode"
+}
+
+wifi_updown() {
+ [ enable = "$1" ] && {
+ wifi_updown disable "$2"
+ scan_wifi
+ }
+ for device in ${2:-$DEVICES}; do (
+ config_get disabled "$device" disabled
+ [ 1 == "$disabled" ] && {
+ echo "'$device' is disabled"
+ set disable
+ }
+ config_get iftype "$device" type
+ if eval "type ${1}_$iftype" 2>/dev/null >/dev/null; then
+ eval "scan_$iftype '$device'"
+ eval "${1}_$iftype '$device'" || echo "$device($iftype): ${1} failed"
+ else
+ echo "$device($iftype): Interface type not supported"
+ fi
+ ); done
+}
+
+wifi_detect() {
+ for driver in ${2:-$DRIVERS}; do (
+ if eval "type detect_$driver" 2>/dev/null >/dev/null; then
+ eval "detect_$driver" || echo "$driver: Detect failed" >&2
+ else
+ echo "$driver: Hardware detection not supported" >&2
+ fi
+ ); done
+}
+
+start_net() {(
+ local iface="$1"
+ local config="$2"
+ local vifmac="$3"
+
+ [ -f "/var/run/$iface.pid" ] && kill "$(cat /var/run/${iface}.pid)" 2>/dev/null
+ [ -z "$config" ] || {
+ include /lib/network
+ scan_interfaces
+ for config in $config; do
+ setup_interface "$iface" "$config" "" "$vifmac"
+ done
+ }
+)}
+
+set_wifi_up() {
+ local cfg="$1"
+ local ifname="$2"
+ uci_set_state wireless "$cfg" up 1
+ uci_set_state wireless "$cfg" ifname "$ifname"
+}
+
+set_wifi_down() {
+ local cfg="$1"
+ local vifs vif vifstr
+
+ [ -f "/var/run/wifi-${cfg}.pid" ] &&
+ kill "$(cat "/var/run/wifi-${cfg}.pid")" 2>/dev/null
+ uci_revert_state wireless "$cfg"
+ config_get vifs "$cfg" vifs
+ for vif in $vifs; do
+ uci_revert_state wireless "$vif"
+ done
+}
+
+scan_wifi() {
+ local cfgfile="$1"
+ DEVICES=
+ config_cb() {
+ local type="$1"
+ local section="$2"
+
+ # section start
+ case "$type" in
+ wifi-device)
+ append DEVICES "$section"
+ config_set "$section" vifs ""
+ config_set "$section" ht_capab ""
+ ;;
+ esac
+
+ # section end
+ config_get TYPE "$CONFIG_SECTION" TYPE
+ case "$TYPE" in
+ wifi-iface)
+ config_get device "$CONFIG_SECTION" device
+ config_get vifs "$device" vifs
+ append vifs "$CONFIG_SECTION"
+ config_set "$device" vifs "$vifs"
+ ;;
+ esac
+ }
+ config_load "${cfgfile:-wireless}"
+}
+
+DEVICES=
+DRIVERS=
+include /lib/wifi
+scan_wifi
+
+case "$1" in
+ down) wifi_updown "disable" "$2";;
+ detect) wifi_detect "$2";;
+ --help|help) usage;;
+ *) wifi_updown "enable" "$2";;
+esac
diff --git a/package/base-files/image-config.in b/package/base-files/image-config.in
new file mode 100644
index 0000000..ac08c8d
--- /dev/null
+++ b/package/base-files/image-config.in
@@ -0,0 +1,185 @@
+# Copyright (C) 2006-2012 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+menuconfig PREINITOPT
+ bool "Preinit configuration options" if IMAGEOPT
+ default n
+ help
+ These options are used to control the environment used to initialize
+ the system before running init (which typically mean /sbin/init which
+ switches to multiuser mode).
+
+config TARGET_PREINIT_SUPPRESS_STDERR
+ bool "Suppress stderr messages during preinit" if PREINITOPT
+ default y
+ help
+ Sends stderr to null during preinit. This is the default behaviour
+ in previous versions of OpenWRT. This also prevents init process
+ itself from displaying stderr, however processes launched by init
+ in multiuser through inittab will use the current terminal (e.g.
+ the ash shell launched by inittab will display stderr). That's
+ the same behaviour as seen in previous version of OpenWRT.
+
+config TARGET_PREINIT_TIMEOUT
+ int
+ prompt "Failsafe wait timeout" if PREINITOPT
+ default 2
+ help
+ How long to wait for failsafe mode to be entered before
+ continuing with a regular boot if failsafe not selected.
+
+config TARGET_PREINIT_SHOW_NETMSG
+ bool
+ prompt "Show all preinit network messages" if PREINITOPT
+ default n
+ help
+ Show preinit all network messages (via netmsg broadcast), not only
+ the message indicating to press reset to enter failsafe. Note that
+ if the architecture doesn't define an interface, and there is no
+ 'Preinit network interface' defined, then no messages will be
+ emitted, even if this is set.
+
+config TARGET_PREINIT_SUPPRESS_FAILSAFE_NETMSG
+ bool
+ prompt "Suppress network message indicating failsafe" if PREINITOPT
+ default n
+ help
+ If "Show all preinit network messages" above is not set, then
+ setting this option suppresses the only message that would be
+ emitted otherwise, name the network message to enter failsafe
+ (via netmsg).
+
+config TARGET_PREINIT_IFNAME
+ string
+ prompt "Preinit network interface" if PREINITOPT
+ default ""
+ help
+ Interface for sending preinit messages to network, and any other
+ default networking in failsafe or preinit. If empty
+ uses $ifname (if defined in /etc/preinit.arch).
+
+config TARGET_PREINIT_IP
+ string
+ prompt "IP address for preinit network messages" if PREINITOPT
+ default "192.168.1.1"
+ help
+ IP address used to configure interface for preinit network
+ messages, including failsafe messages
+
+config TARGET_PREINIT_NETMASK
+ string
+ prompt "Netmask for preinit network messages" if PREINITOPT
+ default "255.255.255.0"
+ help
+ Netmask used to configure interface for preinit network
+ messages, including failsafes messages
+
+config TARGET_PREINIT_BROADCAST
+ string
+ prompt "Broadcast address for preinit network messages" if PREINITOPT
+ default "192.168.1.255"
+ help
+ Broadcast address to which to send preinit network messages, as
+ as failsafe messages
+
+
+menuconfig INITOPT
+ bool "Init configuration options" if IMAGEOPT
+ default n
+ help
+ These option choose the command that will run as the 'init' command
+ (that is which is responsible for controlling the system once preinit
+ transfers control to it) as well as some options controlling its
+ behaviour. Normally init is /sbin/init.
+
+ config TARGET_INIT_PATH
+ string
+ prompt "PATH for regular boot" if INITOPT
+ default "/bin:/sbin:/usr/bin:/usr/sbin"
+ help
+ Default PATH used during normal operation
+
+ config TARGET_INIT_ENV
+ string
+ prompt "Environment variables to set when starting init (start with none)" if INITOPT
+ default ""
+ help
+ Should be a space seperated list of variable assignments. These
+ variables will be present in the environment. Spaces may not be
+ present (including through expansion) even in a quoted string
+ (env doesn't understanding quoting).
+
+ config TARGET_INIT_CMD
+ string
+ prompt "Init command" if INITOPT
+ default "/sbin/init"
+ help
+ The executable to run as the init process. Is 'exec'd by
+ preinit (which is the init that the kernel launches on boot).
+
+ config TARGET_INIT_SUPPRESS_STDERR
+ bool
+ prompt "Suppress stderr messages of init" if INITOPT
+ default y
+ help
+ Prevents showing stderr messages for init command if not already
+ suppressed during preinit. This is the default behaviour in
+ previous versions of OpenWRT. Removing this does nothing if
+ stderr is suppressed during preinit (which is the default).
+
+
+menuconfig VERSIONOPT
+ bool "Version configuration options" if IMAGEOPT
+ default n
+ help
+ These options allow to override the version information embedded in
+ the /etc/openwrt_version, /etc/openwrt_release, /etc/banner and
+ /etc/opkg.conf files. Usually there is no need to set these, but
+ they're useful for release builds or custom OpenWrt redistributions
+ that should carry custom version tags.
+
+ config VERSION_DIST
+ string
+ prompt "Release distribution" if VERSIONOPT
+ default "OpenWrt" if VERSIONOPT
+ help
+ This is the name of the release distribution.
+ If unspecified, it defaults to OpenWrt.
+
+ config VERSION_NICK
+ string
+ prompt "Release version nickname" if VERSIONOPT
+ help
+ This is the release codename embedded in the image.
+ If unspecified, it defaults to the name of source branch.
+
+ config VERSION_NUMBER
+ string
+ prompt "Release version number" if VERSIONOPT
+ help
+ This is the release version number embedded in the image.
+ If unspecified, it defaults to the svn or git-svn revision
+ of the build tree.
+
+ config VERSION_REPO
+ string
+ prompt "Release repository" if VERSIONOPT
+ default "http://downloads.openwrt.org/snapshots/trunk/%T/packages" if VERSIONOPT
+ help
+ This is the repository address embedded in the image, it defaults
+ to the trunk snapshot repo; the url may contain the following placeholders:
+ %R .. Revision number
+ %V .. Release version or revision number, uppercase
+ %v .. Release version or revision number, lowercase
+ %C .. Release version or "Bleeding Edge", uppercase
+ %c .. Release version or "bleeding_edge", lowercase
+ %N .. Release name, uppercase
+ %n .. Release name, lowercase
+ %D .. Distribution name or "OpenWrt", uppercase
+ %d .. Distribution name or "openwrt", lowercase
+ %T .. Target name
+ %S .. Target/Subtarget name
diff --git a/package/block-mount/.svn/entries b/package/block-mount/.svn/entries
new file mode 100644
index 0000000..a87275b
--- /dev/null
+++ b/package/block-mount/.svn/entries
@@ -0,0 +1,99 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/block-mount
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-12-19T09:41:28.797677Z
+34784
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+files
+dir
+
+Config.in
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+37163b77640aac51e0658e2253e62371
+2011-03-27T06:40:51.125191Z
+26314
+cshore
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+478
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+4c88b619bb7f6fa787f5377f746d3f12
+2012-12-19T09:41:28.797677Z
+34784
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2248
+
diff --git a/package/block-mount/.svn/text-base/Config.in.svn-base b/package/block-mount/.svn/text-base/Config.in.svn-base
new file mode 100644
index 0000000..2fa10b6
--- /dev/null
+++ b/package/block-mount/.svn/text-base/Config.in.svn-base
@@ -0,0 +1,17 @@
+#
+# Copyright (C) 2010 Vertical Communications
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+config EXTROOT_SETTLETIME
+ int
+ prompt "Settle time for root block device (s)" if PACKAGE_block-mount
+ default 20
+ help
+ This is the amount of time, in seconds, to wait for the block device
+ the root filesystem is on to become available, after the kernel that
+ modules for the rootfs and device are loaded.
+
+
diff --git a/package/block-mount/.svn/text-base/Makefile.svn-base b/package/block-mount/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..06deb94
--- /dev/null
+++ b/package/block-mount/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,70 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=block-mount
+PKG_VERSION:=0.2.0
+PKG_RELEASE:=10
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/block-mount/Default
+ SECTION:=base
+ CATEGORY:=Base system
+endef
+
+define Package/block-mount
+ $(call Package/block-mount/Default)
+ TITLE:=Block device mounting and checking
+ DEPENDS:= +blkid +swap-utils
+ MENU:=1
+endef
+
+define Package/block-mount/description
+ Scripts used to mount and check block devices (filesystems and swap), as well
+ as hotplug scripts to automount and check block devices when hotplug event (e.g.
+ from plugging in a device) occurs.
+ Also includes preinit scripts for mounting a block device as the root filesystem.
+ This allows one to have the root filesystem on devices other than the built in flash
+ device.
+endef
+
+define Package/block-mount/config
+ source "$(SOURCE)/Config.in"
+endef
+
+define Build/Compile
+endef
+
+define Package/block-mount/conffiles
+/etc/config/fstab
+endef
+
+define Package/block-mount/install
+ $(INSTALL_DIR) $(1)/etc/init.d
+ $(INSTALL_BIN) ./files/fstab.init $(1)/etc/init.d/fstab
+ $(INSTALL_DIR) $(1)/etc/config
+ $(INSTALL_DATA) ./files/fstab.config $(1)/etc/config/fstab
+ $(INSTALL_DIR) $(1)/lib/functions/fsck
+ $(INSTALL_DATA) ./files/mount.sh $(1)/lib/functions/
+ $(INSTALL_DATA) ./files/fsck.sh $(1)/lib/functions/
+ $(INSTALL_DATA) ./files/block.sh $(1)/lib/functions/
+ $(INSTALL_DIR) $(1)/etc/hotplug.d/block
+ $(INSTALL_DATA) ./files/10-swap $(1)/etc/hotplug.d/block/
+ $(INSTALL_DATA) ./files/20-fsck $(1)/etc/hotplug.d/block/
+ $(INSTALL_DATA) ./files/40-mount $(1)/etc/hotplug.d/block/
+ $(INSTALL_DATA) ./files/extmount.sh $(1)/lib/functions/
+ $(INSTALL_DIR) $(1)/lib/preinit
+ $(INSTALL_DATA) ./files/50_determine_usb_root $(1)/lib/preinit/
+ $(INSTALL_DATA) ./files/55_determine_extroot_sysupgrade $(1)/lib/preinit/
+ $(INSTALL_DATA) ./files/60_pivot_usb_root $(1)/lib/preinit/
+ echo "extroot_settle_time=\"$(CONFIG_EXTROOT_SETTLETIME)\"" >$(1)/lib/preinit/00_extroot.conf
+ $(INSTALL_DIR) $(1)/overlay
+endef
+
+$(eval $(call BuildPackage,block-mount))
diff --git a/package/block-mount/Config.in b/package/block-mount/Config.in
new file mode 100644
index 0000000..2fa10b6
--- /dev/null
+++ b/package/block-mount/Config.in
@@ -0,0 +1,17 @@
+#
+# Copyright (C) 2010 Vertical Communications
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+config EXTROOT_SETTLETIME
+ int
+ prompt "Settle time for root block device (s)" if PACKAGE_block-mount
+ default 20
+ help
+ This is the amount of time, in seconds, to wait for the block device
+ the root filesystem is on to become available, after the kernel that
+ modules for the rootfs and device are loaded.
+
+
diff --git a/package/block-mount/Makefile b/package/block-mount/Makefile
new file mode 100644
index 0000000..06deb94
--- /dev/null
+++ b/package/block-mount/Makefile
@@ -0,0 +1,70 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=block-mount
+PKG_VERSION:=0.2.0
+PKG_RELEASE:=10
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/block-mount/Default
+ SECTION:=base
+ CATEGORY:=Base system
+endef
+
+define Package/block-mount
+ $(call Package/block-mount/Default)
+ TITLE:=Block device mounting and checking
+ DEPENDS:= +blkid +swap-utils
+ MENU:=1
+endef
+
+define Package/block-mount/description
+ Scripts used to mount and check block devices (filesystems and swap), as well
+ as hotplug scripts to automount and check block devices when hotplug event (e.g.
+ from plugging in a device) occurs.
+ Also includes preinit scripts for mounting a block device as the root filesystem.
+ This allows one to have the root filesystem on devices other than the built in flash
+ device.
+endef
+
+define Package/block-mount/config
+ source "$(SOURCE)/Config.in"
+endef
+
+define Build/Compile
+endef
+
+define Package/block-mount/conffiles
+/etc/config/fstab
+endef
+
+define Package/block-mount/install
+ $(INSTALL_DIR) $(1)/etc/init.d
+ $(INSTALL_BIN) ./files/fstab.init $(1)/etc/init.d/fstab
+ $(INSTALL_DIR) $(1)/etc/config
+ $(INSTALL_DATA) ./files/fstab.config $(1)/etc/config/fstab
+ $(INSTALL_DIR) $(1)/lib/functions/fsck
+ $(INSTALL_DATA) ./files/mount.sh $(1)/lib/functions/
+ $(INSTALL_DATA) ./files/fsck.sh $(1)/lib/functions/
+ $(INSTALL_DATA) ./files/block.sh $(1)/lib/functions/
+ $(INSTALL_DIR) $(1)/etc/hotplug.d/block
+ $(INSTALL_DATA) ./files/10-swap $(1)/etc/hotplug.d/block/
+ $(INSTALL_DATA) ./files/20-fsck $(1)/etc/hotplug.d/block/
+ $(INSTALL_DATA) ./files/40-mount $(1)/etc/hotplug.d/block/
+ $(INSTALL_DATA) ./files/extmount.sh $(1)/lib/functions/
+ $(INSTALL_DIR) $(1)/lib/preinit
+ $(INSTALL_DATA) ./files/50_determine_usb_root $(1)/lib/preinit/
+ $(INSTALL_DATA) ./files/55_determine_extroot_sysupgrade $(1)/lib/preinit/
+ $(INSTALL_DATA) ./files/60_pivot_usb_root $(1)/lib/preinit/
+ echo "extroot_settle_time=\"$(CONFIG_EXTROOT_SETTLETIME)\"" >$(1)/lib/preinit/00_extroot.conf
+ $(INSTALL_DIR) $(1)/overlay
+endef
+
+$(eval $(call BuildPackage,block-mount))
diff --git a/package/block-mount/files/.svn/entries b/package/block-mount/files/.svn/entries
new file mode 100644
index 0000000..235f8b8
--- /dev/null
+++ b/package/block-mount/files/.svn/entries
@@ -0,0 +1,436 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/block-mount/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-12-19T09:41:28.797677Z
+34784
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+55_determine_extroot_sysupgrade
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+c0f2eb27b9103c59e91144b23616a084
+2011-03-27T06:40:51.125191Z
+26314
+cshore
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1630
+
+fsck.sh
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+82feb8625c8bfc54a3750bcd37191af7
+2011-04-07T01:00:14.659704Z
+26505
+cshore
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+794
+
+fstab.init
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+ceda18a9d3be60bc1a1bd5dea869c925
+2012-12-19T09:41:28.797677Z
+34784
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2039
+
+60_pivot_usb_root
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+49b60cf4ee295df2fc2e3bd409dee370
+2011-03-27T06:40:51.125191Z
+26314
+cshore
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+802
+
+40-mount
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+4acbdbf6a78496c97878acf23a479fb0
+2012-09-10T09:48:31.485181Z
+33357
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2212
+
+block.sh
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+1835e85854bf9a76a61f0186533dbd53
+2012-06-05T16:04:23.055438Z
+32062
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+6588
+
+fstab.config
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+3ecb7964010421fcdb950de110748345
+2011-06-08T20:45:19.620413Z
+27139
+mirko
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+335
+
+20-fsck
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+c5662d81fba3f02a430f29eceb3634bb
+2010-02-26T22:45:39.935987Z
+19877
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1861
+
+10-swap
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+1a91d8df222ab37b88be1677e644ebf5
+2010-02-26T22:45:39.935987Z
+19877
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1668
+
+mount.sh
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+4340f9f1b973d4d5d1cbe61134efd620
+2011-03-27T05:39:47.950566Z
+26311
+cshore
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2650
+
+50_determine_usb_root
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+660f1c3030dfe8d609c52c20e8456de8
+2012-07-01T11:06:32.015945Z
+32567
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2274
+
+extmount.sh
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+2b5a790e3c5dd854a1b8e119ed0afd55
+2011-11-02T18:38:38.913628Z
+28717
+cshore
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1092
+
diff --git a/package/block-mount/files/.svn/text-base/10-swap.svn-base b/package/block-mount/files/.svn/text-base/10-swap.svn-base
new file mode 100644
index 0000000..2837d27
--- /dev/null
+++ b/package/block-mount/files/.svn/text-base/10-swap.svn-base
@@ -0,0 +1,78 @@
+#!/bin/sh
+# Copyright (C) 2009-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+. /lib/functions/block.sh
+
+blkdev=`dirname $DEVPATH`
+
+if [ `basename $blkdev` != "block" ]; then
+
+ device=`basename $DEVPATH`
+
+
+ case "$ACTION" in
+ add)
+ local autoswap_from_fstab
+ local automount_from_fstab
+ local from_fstab
+ local anon_mount
+ local anon_swap
+ local anon_fsck
+ local mds_mount_device
+ local sds_swap_device
+ local sds_swap_enabled
+ local use_device
+ local do_swap=0
+
+ mount_dev_section_cb() {
+ mds_mount_device="$3"
+ }
+
+ swap_dev_section_cb() {
+ sds_swap_device="$2"
+ sds_swap_enabled="$3"
+ return 0
+ }
+
+ config_get_automount
+ automount_from_fstab="$from_fstab"
+
+ [ "$automount_from_fstab" -eq 1 ] && {
+ config_get_mount_section_by_device "/dev/$device"
+ }
+
+ # skip trying swap if this device is defined as a mount point
+ [ -z "$mds_mount_device" ] && {
+ config_get_autoswap
+ autoswap_from_fstab="$from_fstab"
+
+ [ "$autoswap_from_fstab" -eq 1 ] && {
+ config_get_swap_section_by_device "/dev/$device"
+ use_device="$sds_swap_device"
+ do_swap="$sds_swap_enabled"
+ }
+
+ [ -z "$use_device" ] && [ "$anon_swap" -eq 1 ] && {
+ use_device="/dev/$device" && do_swap=1
+ }
+ }
+
+ [ -n "$use_device" ] && [ "$do_swap" -eq 1 ] && {
+ grep -q "$use_device" /proc/swaps || grep -q "$use_device" /proc/mounts || {
+ swapon "$use_device"
+ }
+ }
+ reset_dev_section_cb
+ ;;
+ remove)
+ grep -q "/dev/$device" /proc/swaps && {
+ swapoff "/dev/$device"
+ }
+ ;;
+ esac
+fi
+
diff --git a/package/block-mount/files/.svn/text-base/20-fsck.svn-base b/package/block-mount/files/.svn/text-base/20-fsck.svn-base
new file mode 100644
index 0000000..c59e5ab
--- /dev/null
+++ b/package/block-mount/files/.svn/text-base/20-fsck.svn-base
@@ -0,0 +1,83 @@
+#!/bin/sh
+# Copyright (C) 2009-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+. /lib/functions/block.sh
+. /lib/functions/fsck.sh
+
+blkdev=`dirname $DEVPATH`
+
+if [ `basename $blkdev` != "block" ]; then
+
+ device=`basename $DEVPATH`
+
+ case "$ACTION" in
+ add)
+ local from_fstab
+ local anon_mount
+ local anon_swap
+ local anon_fsck
+ local mds_mount_target
+ local mds_mount_device
+ local mds_mount_fstype
+ local mds_mount_enabled_fsck
+ local sds_swap_device
+ local use_device
+ local do_fsck=0
+ local fsck_type
+
+ local autoswap_from_fstab
+ local automount_from_fstab
+ local hotplug_blkid_fstype_match
+
+ mount_dev_section_cb() {
+ mds_mount_device="$3"
+ mds_mount_fstype="$4"
+ mds_mount_enabled_fsck="$7"
+ }
+
+ swap_dev_section_cb() {
+ sds_swap_device="$2"
+ return 0
+ }
+
+ config_get_automount
+ automount_from_fstab="$from_fstab"
+
+ [ "$automount_from_fstab" -eq 1 ] && {
+ config_get_mount_section_by_device "/dev/$device"
+ use_device="$mds_mount_device"
+ [ "$mds_mount_enabled_fsck" -eq 1 ] && {
+ do_fsck=1
+ fsck_type="$mds_mount_fstype"
+ }
+ }
+
+ [ -z "$use_device" ] && {
+ config_get_autoswap
+ autoswap_from_fstab="$from_fstab"
+
+ [ "$autoswap_from_fstab" -eq 1 ] && {
+ config_get_swap_section_by_device "/dev/$device"
+ use_device="$sds_swap_device" && do_fsck=0
+ }
+ }
+
+ grep -q "/dev/$device" /proc/swaps || grep -q "/dev/$device" /proc/mounts || {
+ [ "$anon_fsck" -eq 1 ] && [ -z "$use_device" ] && {
+ use_device="/dev/$device" && do_fsck=1 && mds_mount_fstype="" && hotplug_blkid_fstype_match=0
+ }
+ }
+
+ [ "$do_fsck" -eq 1 ] && {
+ libmount_fsck "$use_device" "$fsck_type" "$do_fsck"
+ }
+
+ reset_dev_section_cb
+ ;;
+ esac
+fi
+
diff --git a/package/block-mount/files/.svn/text-base/40-mount.svn-base b/package/block-mount/files/.svn/text-base/40-mount.svn-base
new file mode 100644
index 0000000..f1d63eb
--- /dev/null
+++ b/package/block-mount/files/.svn/text-base/40-mount.svn-base
@@ -0,0 +1,91 @@
+#!/bin/sh
+# Copyright (C) 2009-2012 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+. /lib/functions/block.sh
+
+blkdev=`dirname $DEVPATH`
+if [ `basename $blkdev` != "block" ]; then
+
+ device=`basename $DEVPATH`
+ mountpoint=`sed -ne "s|^[^ ]*/$device ||; T; s/ .*//p" /proc/self/mounts`
+
+ case "$ACTION" in
+ add)
+
+ local from_fstab
+ local anon_mount
+ local anon_swap
+ local anon_fsck
+ local mds_mount_target
+ local mds_mount_device
+ local mds_mount_fstype
+ local sds_swap_device
+ local use_device
+ local do_fsck=0
+ local fsck_type
+
+ local autoswap_from_fstab
+ local automount_from_fstab
+
+ mount_dev_section_cb() {
+ mds_mount_target="$2"
+ mds_mount_device="$3"
+ mds_mount_fstype="$4"
+ mds_mount_enabled="$6"
+ }
+
+ swap_dev_section_cb() {
+ sds_swap_device="$2"
+ return 0
+ }
+
+ config_get_automount
+ automount_from_fstab="$from_fstab"
+ [ "$automount_from_fstab" -eq 1 ] && {
+ config_get_mount_section_by_device "/dev/$device"
+ use_device="$mds_mount_device"
+ [ "$mds_mount_enabled" -eq 1 ] && {
+ if [ -n "$mds_mount_target" ]; then
+ grep -q "/dev/$device" /proc/swaps || grep -q "/dev/$device" /proc/mounts || {
+ ( mkdir -p "$mds_mount_target" && mount "$mds_mount_target" ) 2>&1 | tee /proc/self/fd/2 | logger -t 'fstab'
+ }
+ else
+ logger -t 'fstab' "Mount enabled for $mds_mount_device but it doesn't have a defined mountpoint (target)"
+ fi
+ }
+ }
+
+ [ -z "$use_device" ] && {
+ config_get_autoswap
+ autoswap_from_fstab="$from_fstab"
+
+ [ "$autoswap_from_fstab" -eq 1 ] && {
+ config_get_swap_section_by_device "/dev/$device"
+ use_device="$sds_swap_device"
+ }
+ }
+
+ grep -q "/dev/$device" /proc/swaps || grep -q "/dev/$device" /proc/mounts || {
+ [ "$anon_mount" -eq 1 -a -z "$use_device" ] && {
+ case "$device" in
+ mtdblock*) ;;
+ *)
+ ( mkdir -p /mnt/$device && mount /dev/$device /mnt/$device ) 2>&1 | tee /proc/self/fd/2 | logger -t 'fstab'
+ ;;
+ esac
+ }
+ }
+ reset_dev_section_cb
+ ;;
+ remove)
+ umount /dev/$device
+ umount $mountpoint
+ ;;
+ esac
+
+fi
+
diff --git a/package/block-mount/files/.svn/text-base/50_determine_usb_root.svn-base b/package/block-mount/files/.svn/text-base/50_determine_usb_root.svn-base
new file mode 100644
index 0000000..d398062
--- /dev/null
+++ b/package/block-mount/files/.svn/text-base/50_determine_usb_root.svn-base
@@ -0,0 +1,65 @@
+#!/bin/sh
+# Copyright (C) 2010 Vertical Communications
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+
+
+determine_external_root() {
+ pi_include /lib/functions/extmount.sh
+ pi_include /lib/functions/mount.sh
+
+ local OLD_UCI_CONFIG_DIR="$UCI_CONFIG_DIR"
+ local OLD_PATH="$PATH"
+ local OLD_LD_LIBRARY_PATH="$LD_LIBRARY_PATH"
+ set_jffs_mp
+ determine_root_device
+
+ # extroot requires extroot and fstab config files, therefore
+ # we assume configuration is incomplete and not to be used if either of them
+ # is missing (for jffs versions of these files on squashfs image)
+ if [ "$jffs" = "/tmp/overlay" ] && [ -r "/tmp/overlay/etc/config/fstab" ]; then
+ UCI_CONFIG_DIR="/tmp/overlay/etc/config"
+ ER_IS_SQUASHFS=true
+ ER_OVERLAY_PREFIX="/tmp/overlay"
+ PATH=$ER_OVERLAY_PREFIX/sbin:$PATH
+ LD_LIBRARY_PATH=$ER_OVERLAY_PREFIX/usr/lib:$LD_LIBRARY_PATH
+ export PATH LD_LIBRARY_PATH
+ fi
+
+ # For squashfs on firstboot root_device will be tmpfs for the ramoverlay,
+ # unless there is a saved config, in which case it will be /dev/root,
+ # however in the case of a saved config, it won't be restored until after
+ # this script, so there won't be a config on the first boot after
+ # flashing a squashfs-based filesystem
+ # For ext2, ramdisk, or jffs2 root filesystems root_device is /dev/root
+ # For squashfs after firstboot, root filesystem is /dev/root
+ # We only use the config from the root or jffs if the root_device is
+ # /dev/root
+ [ "$root_device" = "/dev/root" ] && {
+ er_load_modules
+ [ -n "$extroot_settle_time" ] && [ "$extroot_settle_time" -gt 0 ] && {
+ sleep $extroot_settle_time
+ }
+ config_load fstab
+ config_foreach config_mount_by_section mount 1
+ ER_OVERLAY_ROM="/no-extroot"
+
+ [ "$rootfs_found" = "1" ] && grep -q ' /overlay ' /proc/mounts && {
+ pi_extroot_mount_success=true
+ pi_mount_skip_next=false
+ ER_OVERLAY_ROM="/overlay"
+ }
+ [ "$rootfs_found" = "1" ] && grep -q ' /rom ' /proc/mounts && {
+ pi_extroot_mount_success=true
+ pi_mount_skip_next=false
+ ER_OVERLAY_ROM="/rom"
+ }
+ }
+ UCI_CONFIG_DIR="$OLD_UCI_CONFIG_DIR"
+ PATH="$OLD_PATH"
+ LD_LIBRARY_PATH="$OLD_LD_LIBRARY_PATH"
+ export PATH LD_LIBRARY_PATH
+}
+
+boot_hook_add preinit_mount_root determine_external_root
+
diff --git a/package/block-mount/files/.svn/text-base/55_determine_extroot_sysupgrade.svn-base b/package/block-mount/files/.svn/text-base/55_determine_extroot_sysupgrade.svn-base
new file mode 100644
index 0000000..b0cd903
--- /dev/null
+++ b/package/block-mount/files/.svn/text-base/55_determine_extroot_sysupgrade.svn-base
@@ -0,0 +1,63 @@
+#!/bin/sh
+# Copyright (C) 2010 Daniel Dickinson
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+
+
+check_set_md5sum() {
+ local er_md5sum_file
+ er_md5sum_file="${ER_OVERLAY_PREFIX}/.extroot.md5sum"
+ local er_disabled
+ if [ "${ER_OVERLAY_ROM}" = "/rom" ]; then
+ er_disabled=/tmp/whole_root-disabled
+ else
+ er_disabled=/tmp${ER_OVERLAY_ROM}-disabled
+ fi
+
+ local er_extroot_md5sum
+ if [ -f $md5sum_file ]; then
+ er_extroot_md5sum="$(cat $er_md5sum_file)"
+ fi
+
+ local er_overlay_file="${ER_OVERLAY_ROM}/etc/extroot.md5sum"
+
+ local er_extroot_overlay_md5sum
+ if [ -f "$er_overlay_file" ]; then
+ er_extroot_overlay_md5sum="$(cat $er_overlay_file)"
+ fi
+
+ if [ -z "$er_extroot_overlay_md5sum" ]; then
+ cat $er_md5sum_file >$er_overlay_file
+ elif [ "$er_extroot_overlay_md5sum" != "$er_extroot_md5sum" ]; then
+ pi_extroot_mount_success="false"
+ mkdir -p $er_disabled
+ mount --move ${ER_OVERLAY_ROM} $er_disabled
+ fi
+}
+
+set_jffs_md5sum() {
+ # We do this anytime block-extroot exists, even on the first boot with
+ # no extroot defined.
+
+ local er_md5sum_file
+ er_md5sum_file="${ER_OVERLAY_PREFIX}/.extroot.md5sum"
+
+ local er_extroot_md5sum
+ if [ -f $er_md5sum_file ]; then
+ er_extroot_md5sum="$(cat $er_md5sum_file)"
+ fi
+ if [ -z "$er_extroot_md5sum" ]; then
+ dd if=/dev/urandom count=32 bs=1k 2>/dev/null | md5sum | cut -f1 -d\ >$er_md5sum_file
+ fi
+}
+
+determine_extroot_sysupgrade() {
+ check_skip || set_jffs_md5sum
+
+ check_skip || [ "$pi_extroot_mount_success" != "true" ] || {
+ check_set_md5sum
+ }
+}
+
+boot_hook_add preinit_mount_root determine_extroot_sysupgrade
+
diff --git a/package/block-mount/files/.svn/text-base/60_pivot_usb_root.svn-base b/package/block-mount/files/.svn/text-base/60_pivot_usb_root.svn-base
new file mode 100644
index 0000000..b610a4a
--- /dev/null
+++ b/package/block-mount/files/.svn/text-base/60_pivot_usb_root.svn-base
@@ -0,0 +1,27 @@
+#!/bin/sh
+# Copyright (C) 2010 Vertical Communications
+
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+
+# Determine if we are requested to mount external root
+
+external_root_pivot() {
+ check_skip || [ "$pi_extroot_mount_success" != "true" ] || {
+ echo "switching to external rootfs"
+ if [ "$ER_OVERLAY_ROM" = "/overlay" ]; then
+ if [ "$ER_IS_SQUASHFS" = "true" ]; then
+ umount /tmp/overlay
+ fi
+ mount -o remount,ro / && fopivot /overlay /rom && pi_mount_skip_next=true
+ elif [ "$ER_OVERLAY_ROM" = "/rom" ]; then
+ if [ "$ER_IS_SQUASHFS" = "true" ]; then
+ umount /tmp/overlay
+ fi
+ mount -o remount,ro / && pivot_rom /rom /rom && pi_mount_skip_next=true
+ fi
+ }
+}
+
+boot_hook_add preinit_mount_root external_root_pivot
+
diff --git a/package/block-mount/files/.svn/text-base/block.sh.svn-base b/package/block-mount/files/.svn/text-base/block.sh.svn-base
new file mode 100644
index 0000000..2b679a8
--- /dev/null
+++ b/package/block-mount/files/.svn/text-base/block.sh.svn-base
@@ -0,0 +1,264 @@
+#!/bin/sh
+# Copyright 2010 Vertical Communications
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+. /lib/functions.sh
+
+reset_block_cb() {
+ mount_cb() {
+ dmc_mount_cfg="$1"
+ shift # skip optional param
+ dmc_target="$2"
+ dmc_mount_device="$3"
+ dmc_fstype="$4"
+ dmc_options="$5"
+ dmc_enabled="$6"
+ dmc_enabled_fsck="$7"
+ dmc_uuid="$8"
+ dmc_label="$9"
+ shift
+ dmc_is_rootfs="$9"
+ return 0
+ }
+ swap_cb() {
+ dsc_swap_cfg="$1"
+ shift # skip optional param
+ dsc_swap_device="$2"
+ dsc_enabled="$3"
+ dsc_uuid="$4"
+ dsc_label="$5"
+ return 0
+ }
+}
+reset_block_cb
+
+reset_dev_section_cb() {
+ mount_dev_section_cb() {
+ dmds_mount_cfg="$1"
+ dmds_mount_target="$2"
+ dmds_mount_device="$3"
+ dmds_mount_fstype="$4"
+ dmds_mount_options="$5"
+ dmds_mount_enabled="$6"
+ dmds_mount_enabled_fsck="$7"
+ dmds_mount_uuid="$8"
+ dmds_mount_label="$9"
+ shift
+ dmds_is_rootfs="$9"
+ return 0
+ }
+ swap_dev_section_cb() {
+ dsds_swap_cfg="$1"
+ dsds_swap_device="$2"
+ dsds_swap_enabled="$3"
+ dsds_swap_uuid="$4"
+ dsds_swap_label="$5"
+ return 0
+ }
+}
+reset_dev_section_cb
+
+config_get_mount() {
+ local gm_cfg="$1"
+ local gm_param="$2"
+ local gm_target
+ local gm_device
+ local gm_fstype
+ local gm_options
+ local gm_enabled
+ local gm_enabled_fsck
+ local gm_uuid
+ local gm_label
+ local gm_is_rootfs
+ config_get gm_target "$1" target
+ config_get gm_device "$1" device
+ config_get gm_fstype "$1" fstype 'auto'
+ config_get gm_options "$1" options 'rw'
+ config_get_bool gm_enabled "$1" enabled 1
+ config_get_bool gm_enabled_fsck "$1" enabled_fsck 0
+ config_get gm_uuid "$1" uuid
+ config_get gm_label "$1" label
+ config_get_bool gm_is_rootfs "$1" is_rootfs 0
+ mount_cb "$gm_cfg" "$gm_param" "$gm_target" "$gm_device" "$gm_fstype" "$gm_options" "$gm_enabled" "$gm_enabled_fsck" "$gm_uuid" "$gm_label" "$gm_is_rootfs"
+}
+
+config_get_swap() {
+ local gs_cfg="$1"
+ local gs_param="$2"
+ local gs_device
+ local gs_enabled
+ local gs_uuid
+ local gs_label
+ config_get gs_device "$1" device
+ config_get_bool gs_enabled "$1" enabled 1
+ config_get gs_uuid "$1" uuid
+ config_get gs_label "$1" label
+
+ swap_cb "$gs_cfg" "$gs_param" "$gs_device" "$gs_enabled" "$gs_uuid" "$gs_label"
+}
+
+config_get_automount() {
+ config_load fstab
+ config_get_bool from_fstab "automount" from_fstab 1
+ config_get_bool anon_mount "automount" anon_mount 1
+ config_get_bool anon_fsck "automount" anon_fsck 0
+}
+
+config_get_autoswap() {
+ config_load fstab
+ config_get_bool from_fstab "autoswap" from_fstab 1
+ config_get_bool anon_swap "autoswap" anon_swap 0
+}
+
+config_create_swap_fstab_entry() {
+ local device="$1"
+ local enabled="$2"
+
+ [ -n "$device" ] || return 0
+
+ local fstabnew
+
+ mkdir -p /var/lock
+ lock /var/lock/fstab.lck
+ fstabnew="$(mktemp -t '.fstab.XXXXXXXX')"
+ cat /tmp/fstab | grep -E -v "^$device[[:blank:]]" >>"$fstabnew"
+ [ "$enabled" -eq 1 ] && echo "$device none swap sw 0 0" >> "$fstabnew"
+ cat "$fstabnew" >/tmp/fstab
+ rm -f $fstabnew
+ lock -u /var/lock/fstab.lck
+}
+
+config_create_mount_fstab_entry() {
+ local device="$1"
+ local target="$2"
+ local fstype="$3"
+ local options="$4"
+ local enabled="$5"
+ options="${options:-rw}"
+ [ "$enabled" -eq 0 ] && options="noauto,$options"
+ [ -n "$target" ] || return 0
+ [ -n "$device" ] || return 0
+
+ local fstabnew
+
+ mkdir -p /var/lock
+ lock /var/lock/fstab.lck
+ fstabnew="$(mktemp -t '.fstab.XXXXXXXX')"
+ cat /tmp/fstab | grep -E -v "^$device[[:blank:]]" | grep -v "$target" >>"$fstabnew"
+ echo "$device $target $fstype $options 0 0" >>"$fstabnew"
+ cat "$fstabnew" >/tmp/fstab
+ rm -f $fstabnew
+ lock -u /var/lock/fstab.lck
+}
+
+libmount_find_token() {
+ local token="$1"
+ local value="$2"
+ local device
+ device="$(blkid -w /dev/null -c /dev/null | grep "$token=\"$value\"" | cut -f1 -d:)"
+ echo "$device"
+}
+
+libmount_find_device_by_id() {
+ local uuid="$1"
+ local label="$2"
+ local device="$3"
+ local cfg_device="$4"
+ local found_device
+
+ if [ -n "$uuid" ]; then
+ found_device="$(libmount_find_token "UUID" "$uuid")"
+ elif [ -n "$label" ]; then
+ found_device="$(libmount_find_token "LABEL" "$label")"
+ elif [ "$device" = "$cfg_device" ]; then
+ found_device="$device"
+ elif [ -z "$device" ] && [ -e "$cfg_device" ]; then
+ found_device="$cfg_device"
+ fi
+ [ -n "$device" ] && [ "$device" != "$found_device" ] && {
+ found_device=""
+ }
+ echo "$found_device"
+}
+
+config_get_mount_section_by_device() {
+ local msbd_device="$1"
+ local msbd_mount_cfg=
+ local msbd_target=
+ local msbd_mount_device=
+ local msbd_fstype=
+ local msbd_options=
+ local msbd_enabled=
+ local msbd_enabled_fsck=
+ local msbd_uuid=
+ local msbd_label=
+ local msbd_is_rootfs
+ local msbd_blkid_fstype_match=
+ mount_cb() {
+ local mc_cfg="$1"
+ local mc_device="$2"
+ shift
+ local mc_target="$2"
+ local mc_cfgdevice="$3"
+ local mc_fstype="$4"
+ local mc_uuid="$8"
+ local mc_label="$9"
+ shift
+ local mc_is_rootfs="$9"
+ local mc_found_device=""
+
+ mc_found_device="$(libmount_find_device_by_id "$mc_uuid" "$mc_label" "$mc_device" "$mc_cfgdevice")"
+ if [ -n "$mc_found_device" ]; then
+ msbd_mount_cfg="$mc_cfg"
+ msbd_target="$mc_target"
+ msbd_mount_device="$mc_found_device"
+ msbd_fstype="$mc_fstype"
+ msbd_options="$4"
+ msbd_enabled="$5"
+ msbd_enabled_fsck="$6"
+ msbd_uuid="$7"
+ msbd_label="$8"
+ msbd_is_rootfs="$9"
+ fi
+ return 0
+ }
+ config_foreach config_get_mount mount "$msbd_device"
+ [ -n "$msbd_mount_device" ] && config_create_mount_fstab_entry "$msbd_mount_device" "$msbd_target" "$msbd_fstype" "$msbd_options" "$msbd_enabled"
+ mount_dev_section_cb "$msbd_mount_cfg" "$msbd_target" "$msbd_mount_device" "$msbd_fstype" "$msbd_options" "$msbd_enabled" "$msbd_enabled_fsck" "$msbd_uuid" "$msbd_label" "$msbd_is_rootfs"
+ reset_block_cb
+}
+
+config_get_swap_section_by_device() {
+ local ssbd_device="$1"
+ local ssbd_swap_cfg=
+ local ssbd_swap_device=
+ local ssbd_enabled=
+ local ssbd_uuid=
+ local ssbd_label=
+ swap_cb() {
+ local sc_cfg="$1"
+ local sc_device="$2"
+ local sc_uuid="$5"
+ local sc_label="$6"
+ local sc_cfgdevice="$3"
+ local sc_found_device
+
+ sc_found_device="$(libmount_find_device_by_id "$sc_uuid" "$sc_label" "$sc_device" "$sc_cfgdevice")"
+ if [ -n "$sc_found_device" ]; then
+ ssbd_swap_cfg="$sc_cfg"
+ ssbd_swap_device="$sc_found_device"
+ ssbd_enabled="$4"
+ ssbd_uuid="$5"
+ ssbd_label="$6"
+ fi
+ return 0
+ }
+ config_foreach config_get_swap swap "$ssbd_device"
+ [ -n "$ssbd_swap_device" ] && config_create_swap_fstab_entry "$ssbd_swap_device" "$ssbd_enabled"
+ swap_dev_section_cb "$ssbd_swap_cfg" "$ssbd_swap_device" "$ssbd_enabled" "$ssbd_uuid" "$ssbd_label"
+ reset_block_cb
+}
+
+
diff --git a/package/block-mount/files/.svn/text-base/extmount.sh.svn-base b/package/block-mount/files/.svn/text-base/extmount.sh.svn-base
new file mode 100644
index 0000000..d6387cc
--- /dev/null
+++ b/package/block-mount/files/.svn/text-base/extmount.sh.svn-base
@@ -0,0 +1,37 @@
+#!/bin/sh
+# Copyright (C) 2006-2011 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+
+determine_root_device() {
+ root_device="$(mount | grep ' / ' | cut -f1 -d\ | grep -v rootfs )"
+}
+
+set_jffs_mp() {
+ jffs="$(awk '/jffs2/ {print $2}' /proc/mounts)"
+}
+
+er_load_modules() {
+ mkdir -p /tmp/extroot_modules/modules.d
+ mkdir -p /tmp/extroot_modules/modules
+ cp -L /etc/modules-boot.d/* /tmp/overlay/etc/modules-boot.d/* /tmp/extroot_modules/modules.d
+ ln -sf /lib/modules/*/* /tmp/overlay/lib/modules/*/* /tmp/extroot_modules/modules
+ local modules="$(cat /tmp/extroot_modules/modules.d/* 2>/dev/null)"
+ cd /tmp/extroot_modules/modules && [ -n "$modules" ] && {
+ echo "$modules" | sed -e 's/^\([^#].*\)/insmod \.\/\1.ko/'| sh 2>&- || :
+ }
+ rm -rf /tmp/extroot_modules
+}
+
+pivot_rom() { # <new_root> <old_root>
+ mount -o move /proc $1/proc && \
+ pivot_root $1 $1$2 && {
+ mount -o move $2/dev /dev
+ mount -o move $2/tmp /tmp
+ mount -o move $2/sys /sys 2>&-
+ return 0
+ }
+}
+
diff --git a/package/block-mount/files/.svn/text-base/fsck.sh.svn-base b/package/block-mount/files/.svn/text-base/fsck.sh.svn-base
new file mode 100644
index 0000000..3011160
--- /dev/null
+++ b/package/block-mount/files/.svn/text-base/fsck.sh.svn-base
@@ -0,0 +1,34 @@
+#!/bin/sh
+# Copyright 2010 Vertical Communications
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+libmount_fsck() {
+ local device="$1"
+ local fsck_fstype="$2"
+ local fsck_enabled="$3"
+ local known_type
+ local found_fsck=0
+
+
+ grep -q "$device" /proc/swaps || grep -q "$device" /proc/mounts || {
+ [ -e "$device" ] && [ "$fsck_enabled" -eq 1 ] && {
+ for known_type in $libmount_known_fsck; do
+ if [ "$known_type" = "$fsck_fstype" ]; then
+ fsck_${known_type} "$device"
+ found_fsck=1
+ break
+ fi
+ done
+ if [ "$found_fsck" -ne 1 ]; then
+ logger -t 'fstab' "Unable to check/repair $device; no known fsck for filesystem type $fstype"
+ fi
+ }
+ }
+}
+
+libmount_known_fsck=""
+
+pi_include /lib/functions/fsck
+
diff --git a/package/block-mount/files/.svn/text-base/fstab.config.svn-base b/package/block-mount/files/.svn/text-base/fstab.config.svn-base
new file mode 100644
index 0000000..de52e20
--- /dev/null
+++ b/package/block-mount/files/.svn/text-base/fstab.config.svn-base
@@ -0,0 +1,20 @@
+config global automount
+ option from_fstab 1
+ option anon_mount 1
+
+config global autoswap
+ option from_fstab 1
+ option anon_swap 0
+
+config mount
+ option target /home
+ option device /dev/sda1
+ option fstype ext4
+ option options rw,sync
+ option enabled 0
+ option enabled_fsck 0
+
+config swap
+ option device /dev/sda2
+ option enabled 0
+
diff --git a/package/block-mount/files/.svn/text-base/fstab.init.svn-base b/package/block-mount/files/.svn/text-base/fstab.init.svn-base
new file mode 100644
index 0000000..4f1f6fb
--- /dev/null
+++ b/package/block-mount/files/.svn/text-base/fstab.init.svn-base
@@ -0,0 +1,92 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2007 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+
+START=20
+
+EXTRA_COMMANDS="overlay_enable whole_root_enable"
+EXTRA_HELP=" overlay_enable Reenable overlay rootfs. (After you fix it).
+ whole_root_enable Reenable whole-disk rootfs. (After you fix it)."
+
+rootfs_enable() {
+ local extroot_type="$1"
+
+ if [ ! -d /tmp/${extroot_type}-disabled ]; then
+ echo "No disabled ${extroot_type} present (/tmp/${extroot_type}-disabled). Can't renable."
+ exit 1
+ fi
+
+ rm -f /tmp/${extroot_type}-disabled/.extroot.md5sum
+ rm -f /tmp/${extroot_type}-disabled/etc/extroot.md5sum
+ echo "Please reboot router to complete re-enabling external rootfs."
+}
+
+overlay_enable() {
+ rootfs_enable overlay
+}
+
+whole_root_enable() {
+ rootfs_enable whole_root
+}
+
+do_mount() {
+ local cfg="$1"
+ config_mount_by_section "$cfg"
+}
+
+do_swapon() {
+ local cfg="$1"
+ config_swapon_by_section "$cfg"
+}
+
+do_unmount() {
+ local cfg="$1"
+
+ config_get target "$cfg" target
+ config_get_bool enabled "$cfg" "enabled" '1'
+ [ -n "$target" -a "$enabled" -gt 0 ] || return 0
+ umount $target
+}
+
+do_swapoff() {
+ local cfg="$1"
+
+ config_get device "$cfg" device
+ config_get_bool enabled "$cfg" "enabled" '1'
+ [ -n "$device" -a "$enabled" -gt 0 ] && type swapoff >/dev/null || return 0
+ swapoff $device
+}
+
+start() {
+ . /lib/functions/mount.sh
+
+ config_load fstab
+ mkdir -p /var/lock
+ lock /var/lock/fstab.lck
+ [ -e /tmp/fstab ] || {
+ echo '# WARNING: this is an auto generated file, please use uci to set defined filesystems' > /tmp/fstab
+ }
+ lock -u /var/lock/fstab.lck
+ config_foreach do_swapon swap
+ config_foreach do_mount mount
+ config_foreach do_swapon swap # do swap a second time so that swap on filesystems is enabled
+}
+
+stop() {
+ . /lib/functions/mount.sh
+
+ config_load fstab
+ config_foreach do_unmount mount
+ config_foreach do_swapoff swap
+ swapoff -a
+}
+
+restart() {
+ stop
+ sleep 1
+ start
+}
diff --git a/package/block-mount/files/.svn/text-base/mount.sh.svn-base b/package/block-mount/files/.svn/text-base/mount.sh.svn-base
new file mode 100644
index 0000000..e96174c
--- /dev/null
+++ b/package/block-mount/files/.svn/text-base/mount.sh.svn-base
@@ -0,0 +1,103 @@
+#!/bin/sh
+# Copyright 2010 Vertical Communications
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+
+pi_include /lib/functions/block.sh
+pi_include /lib/functions/fsck.sh
+
+config_mount_by_section() {
+ local cfg="$1"
+ local find_rootfs="$2"
+
+ mount_cb() {
+ local cfg="$1"
+ local device="$2"
+ shift
+ local target="$2"
+ local cfgdevice="$3"
+ local fstype="$4"
+ local options="$5"
+ local enabled="$6"
+ local enabled_fsck="$7"
+ local uuid="$8"
+ local label="$9"
+ shift
+ local is_rootfs="$9"
+ shift
+ local found_device=""
+
+ found_device="$(libmount_find_device_by_id "$uuid" "$label" "$device" "$cfgdevice")"
+ if [ -n "$found_device" ]; then
+ if [ "$find_rootfs" != "1" ] || ( [ "$is_rootfs" -eq 1 ] || [ "$target" = "/" ] || [ "$target" = "/overlay" ] ); then
+ [ "$enabled_fsck" -eq 1 ] && {
+ grep -q "$found_device" /proc/swaps || grep -q "$found_device" /proc/mounts || {
+ libmount_fsck "$found_device" "$fstype" "$enabled_fsck"
+ }
+ }
+
+ if [ "$find_rootfs" = "1" ]; then
+ if [ "$is_rootfs" -eq 1 ]; then
+ target=/overlay
+ elif [ "$target" = "/" ]; then
+ target=/rom
+ fi
+ else
+ if [ "$is_rootfs" -eq 1 ] || [ "$target" = "/overlay" ]; then
+ target=/tmp/overlay-disabled
+ elif [ "$target" = "/" ] || [ "$target" = "/rom" ]; then
+ target="/tmp/whole_root-disabled"
+ fi
+ fi
+
+ config_create_mount_fstab_entry "$found_device" "$target" "$fstype" "$options" "$enabled"
+ grep -q "$found_device" /proc/swaps || grep -q "$found_device" /proc/mounts || {
+ [ "$enabled" -eq 1 ] && mkdir -p "$target" && mount "$target" 2>&1 | tee /proc/self/fd/2 | logger -t 'fstab'
+ }
+
+ fi
+ fi
+ [ "$find_rootfs" = "1" ] && {
+ [ "$target" = "/overlay" ] && {
+ rootfs_found=1
+ }
+ [ "$target" = "/rom" ] && {
+ rootfs_found=1
+ }
+ }
+ return 0
+ }
+ config_get_mount "$cfg"
+ reset_block_cb
+}
+
+config_swapon_by_section() {
+ local cfg="$1"
+
+ swap_cb() {
+ local cfg="$1"
+ local device="$2"
+ local cfgdevice="$3"
+ local enabled="$4"
+ local uuid="$5"
+ local label="$6"
+ local uuid
+ local label
+
+ local found_device=""
+
+ found_device="$(libmount_find_device_by_id "$uuid" "$label" "$device" "$cfgdevice")"
+
+ if [ -n "$found_device" ]; then
+ config_create_swap_fstab_entry "$found_device" "$enabled"
+ grep -q "$found_device" /proc/swaps || grep -q "$found_device" /proc/mounts || {
+ [ "$enabled" -eq 1 ] && swapon "$found_device" | tee /proc/self/fd/2 | logger -t 'fstab'
+ }
+ fi
+ return 0
+ }
+ config_get_swap "$cfg"
+ reset_block_cb
+}
diff --git a/package/block-mount/files/10-swap b/package/block-mount/files/10-swap
new file mode 100644
index 0000000..2837d27
--- /dev/null
+++ b/package/block-mount/files/10-swap
@@ -0,0 +1,78 @@
+#!/bin/sh
+# Copyright (C) 2009-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+. /lib/functions/block.sh
+
+blkdev=`dirname $DEVPATH`
+
+if [ `basename $blkdev` != "block" ]; then
+
+ device=`basename $DEVPATH`
+
+
+ case "$ACTION" in
+ add)
+ local autoswap_from_fstab
+ local automount_from_fstab
+ local from_fstab
+ local anon_mount
+ local anon_swap
+ local anon_fsck
+ local mds_mount_device
+ local sds_swap_device
+ local sds_swap_enabled
+ local use_device
+ local do_swap=0
+
+ mount_dev_section_cb() {
+ mds_mount_device="$3"
+ }
+
+ swap_dev_section_cb() {
+ sds_swap_device="$2"
+ sds_swap_enabled="$3"
+ return 0
+ }
+
+ config_get_automount
+ automount_from_fstab="$from_fstab"
+
+ [ "$automount_from_fstab" -eq 1 ] && {
+ config_get_mount_section_by_device "/dev/$device"
+ }
+
+ # skip trying swap if this device is defined as a mount point
+ [ -z "$mds_mount_device" ] && {
+ config_get_autoswap
+ autoswap_from_fstab="$from_fstab"
+
+ [ "$autoswap_from_fstab" -eq 1 ] && {
+ config_get_swap_section_by_device "/dev/$device"
+ use_device="$sds_swap_device"
+ do_swap="$sds_swap_enabled"
+ }
+
+ [ -z "$use_device" ] && [ "$anon_swap" -eq 1 ] && {
+ use_device="/dev/$device" && do_swap=1
+ }
+ }
+
+ [ -n "$use_device" ] && [ "$do_swap" -eq 1 ] && {
+ grep -q "$use_device" /proc/swaps || grep -q "$use_device" /proc/mounts || {
+ swapon "$use_device"
+ }
+ }
+ reset_dev_section_cb
+ ;;
+ remove)
+ grep -q "/dev/$device" /proc/swaps && {
+ swapoff "/dev/$device"
+ }
+ ;;
+ esac
+fi
+
diff --git a/package/block-mount/files/20-fsck b/package/block-mount/files/20-fsck
new file mode 100644
index 0000000..c59e5ab
--- /dev/null
+++ b/package/block-mount/files/20-fsck
@@ -0,0 +1,83 @@
+#!/bin/sh
+# Copyright (C) 2009-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+. /lib/functions/block.sh
+. /lib/functions/fsck.sh
+
+blkdev=`dirname $DEVPATH`
+
+if [ `basename $blkdev` != "block" ]; then
+
+ device=`basename $DEVPATH`
+
+ case "$ACTION" in
+ add)
+ local from_fstab
+ local anon_mount
+ local anon_swap
+ local anon_fsck
+ local mds_mount_target
+ local mds_mount_device
+ local mds_mount_fstype
+ local mds_mount_enabled_fsck
+ local sds_swap_device
+ local use_device
+ local do_fsck=0
+ local fsck_type
+
+ local autoswap_from_fstab
+ local automount_from_fstab
+ local hotplug_blkid_fstype_match
+
+ mount_dev_section_cb() {
+ mds_mount_device="$3"
+ mds_mount_fstype="$4"
+ mds_mount_enabled_fsck="$7"
+ }
+
+ swap_dev_section_cb() {
+ sds_swap_device="$2"
+ return 0
+ }
+
+ config_get_automount
+ automount_from_fstab="$from_fstab"
+
+ [ "$automount_from_fstab" -eq 1 ] && {
+ config_get_mount_section_by_device "/dev/$device"
+ use_device="$mds_mount_device"
+ [ "$mds_mount_enabled_fsck" -eq 1 ] && {
+ do_fsck=1
+ fsck_type="$mds_mount_fstype"
+ }
+ }
+
+ [ -z "$use_device" ] && {
+ config_get_autoswap
+ autoswap_from_fstab="$from_fstab"
+
+ [ "$autoswap_from_fstab" -eq 1 ] && {
+ config_get_swap_section_by_device "/dev/$device"
+ use_device="$sds_swap_device" && do_fsck=0
+ }
+ }
+
+ grep -q "/dev/$device" /proc/swaps || grep -q "/dev/$device" /proc/mounts || {
+ [ "$anon_fsck" -eq 1 ] && [ -z "$use_device" ] && {
+ use_device="/dev/$device" && do_fsck=1 && mds_mount_fstype="" && hotplug_blkid_fstype_match=0
+ }
+ }
+
+ [ "$do_fsck" -eq 1 ] && {
+ libmount_fsck "$use_device" "$fsck_type" "$do_fsck"
+ }
+
+ reset_dev_section_cb
+ ;;
+ esac
+fi
+
diff --git a/package/block-mount/files/40-mount b/package/block-mount/files/40-mount
new file mode 100644
index 0000000..f1d63eb
--- /dev/null
+++ b/package/block-mount/files/40-mount
@@ -0,0 +1,91 @@
+#!/bin/sh
+# Copyright (C) 2009-2012 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+. /lib/functions/block.sh
+
+blkdev=`dirname $DEVPATH`
+if [ `basename $blkdev` != "block" ]; then
+
+ device=`basename $DEVPATH`
+ mountpoint=`sed -ne "s|^[^ ]*/$device ||; T; s/ .*//p" /proc/self/mounts`
+
+ case "$ACTION" in
+ add)
+
+ local from_fstab
+ local anon_mount
+ local anon_swap
+ local anon_fsck
+ local mds_mount_target
+ local mds_mount_device
+ local mds_mount_fstype
+ local sds_swap_device
+ local use_device
+ local do_fsck=0
+ local fsck_type
+
+ local autoswap_from_fstab
+ local automount_from_fstab
+
+ mount_dev_section_cb() {
+ mds_mount_target="$2"
+ mds_mount_device="$3"
+ mds_mount_fstype="$4"
+ mds_mount_enabled="$6"
+ }
+
+ swap_dev_section_cb() {
+ sds_swap_device="$2"
+ return 0
+ }
+
+ config_get_automount
+ automount_from_fstab="$from_fstab"
+ [ "$automount_from_fstab" -eq 1 ] && {
+ config_get_mount_section_by_device "/dev/$device"
+ use_device="$mds_mount_device"
+ [ "$mds_mount_enabled" -eq 1 ] && {
+ if [ -n "$mds_mount_target" ]; then
+ grep -q "/dev/$device" /proc/swaps || grep -q "/dev/$device" /proc/mounts || {
+ ( mkdir -p "$mds_mount_target" && mount "$mds_mount_target" ) 2>&1 | tee /proc/self/fd/2 | logger -t 'fstab'
+ }
+ else
+ logger -t 'fstab' "Mount enabled for $mds_mount_device but it doesn't have a defined mountpoint (target)"
+ fi
+ }
+ }
+
+ [ -z "$use_device" ] && {
+ config_get_autoswap
+ autoswap_from_fstab="$from_fstab"
+
+ [ "$autoswap_from_fstab" -eq 1 ] && {
+ config_get_swap_section_by_device "/dev/$device"
+ use_device="$sds_swap_device"
+ }
+ }
+
+ grep -q "/dev/$device" /proc/swaps || grep -q "/dev/$device" /proc/mounts || {
+ [ "$anon_mount" -eq 1 -a -z "$use_device" ] && {
+ case "$device" in
+ mtdblock*) ;;
+ *)
+ ( mkdir -p /mnt/$device && mount /dev/$device /mnt/$device ) 2>&1 | tee /proc/self/fd/2 | logger -t 'fstab'
+ ;;
+ esac
+ }
+ }
+ reset_dev_section_cb
+ ;;
+ remove)
+ umount /dev/$device
+ umount $mountpoint
+ ;;
+ esac
+
+fi
+
diff --git a/package/block-mount/files/50_determine_usb_root b/package/block-mount/files/50_determine_usb_root
new file mode 100644
index 0000000..d398062
--- /dev/null
+++ b/package/block-mount/files/50_determine_usb_root
@@ -0,0 +1,65 @@
+#!/bin/sh
+# Copyright (C) 2010 Vertical Communications
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+
+
+determine_external_root() {
+ pi_include /lib/functions/extmount.sh
+ pi_include /lib/functions/mount.sh
+
+ local OLD_UCI_CONFIG_DIR="$UCI_CONFIG_DIR"
+ local OLD_PATH="$PATH"
+ local OLD_LD_LIBRARY_PATH="$LD_LIBRARY_PATH"
+ set_jffs_mp
+ determine_root_device
+
+ # extroot requires extroot and fstab config files, therefore
+ # we assume configuration is incomplete and not to be used if either of them
+ # is missing (for jffs versions of these files on squashfs image)
+ if [ "$jffs" = "/tmp/overlay" ] && [ -r "/tmp/overlay/etc/config/fstab" ]; then
+ UCI_CONFIG_DIR="/tmp/overlay/etc/config"
+ ER_IS_SQUASHFS=true
+ ER_OVERLAY_PREFIX="/tmp/overlay"
+ PATH=$ER_OVERLAY_PREFIX/sbin:$PATH
+ LD_LIBRARY_PATH=$ER_OVERLAY_PREFIX/usr/lib:$LD_LIBRARY_PATH
+ export PATH LD_LIBRARY_PATH
+ fi
+
+ # For squashfs on firstboot root_device will be tmpfs for the ramoverlay,
+ # unless there is a saved config, in which case it will be /dev/root,
+ # however in the case of a saved config, it won't be restored until after
+ # this script, so there won't be a config on the first boot after
+ # flashing a squashfs-based filesystem
+ # For ext2, ramdisk, or jffs2 root filesystems root_device is /dev/root
+ # For squashfs after firstboot, root filesystem is /dev/root
+ # We only use the config from the root or jffs if the root_device is
+ # /dev/root
+ [ "$root_device" = "/dev/root" ] && {
+ er_load_modules
+ [ -n "$extroot_settle_time" ] && [ "$extroot_settle_time" -gt 0 ] && {
+ sleep $extroot_settle_time
+ }
+ config_load fstab
+ config_foreach config_mount_by_section mount 1
+ ER_OVERLAY_ROM="/no-extroot"
+
+ [ "$rootfs_found" = "1" ] && grep -q ' /overlay ' /proc/mounts && {
+ pi_extroot_mount_success=true
+ pi_mount_skip_next=false
+ ER_OVERLAY_ROM="/overlay"
+ }
+ [ "$rootfs_found" = "1" ] && grep -q ' /rom ' /proc/mounts && {
+ pi_extroot_mount_success=true
+ pi_mount_skip_next=false
+ ER_OVERLAY_ROM="/rom"
+ }
+ }
+ UCI_CONFIG_DIR="$OLD_UCI_CONFIG_DIR"
+ PATH="$OLD_PATH"
+ LD_LIBRARY_PATH="$OLD_LD_LIBRARY_PATH"
+ export PATH LD_LIBRARY_PATH
+}
+
+boot_hook_add preinit_mount_root determine_external_root
+
diff --git a/package/block-mount/files/55_determine_extroot_sysupgrade b/package/block-mount/files/55_determine_extroot_sysupgrade
new file mode 100644
index 0000000..b0cd903
--- /dev/null
+++ b/package/block-mount/files/55_determine_extroot_sysupgrade
@@ -0,0 +1,63 @@
+#!/bin/sh
+# Copyright (C) 2010 Daniel Dickinson
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+
+
+check_set_md5sum() {
+ local er_md5sum_file
+ er_md5sum_file="${ER_OVERLAY_PREFIX}/.extroot.md5sum"
+ local er_disabled
+ if [ "${ER_OVERLAY_ROM}" = "/rom" ]; then
+ er_disabled=/tmp/whole_root-disabled
+ else
+ er_disabled=/tmp${ER_OVERLAY_ROM}-disabled
+ fi
+
+ local er_extroot_md5sum
+ if [ -f $md5sum_file ]; then
+ er_extroot_md5sum="$(cat $er_md5sum_file)"
+ fi
+
+ local er_overlay_file="${ER_OVERLAY_ROM}/etc/extroot.md5sum"
+
+ local er_extroot_overlay_md5sum
+ if [ -f "$er_overlay_file" ]; then
+ er_extroot_overlay_md5sum="$(cat $er_overlay_file)"
+ fi
+
+ if [ -z "$er_extroot_overlay_md5sum" ]; then
+ cat $er_md5sum_file >$er_overlay_file
+ elif [ "$er_extroot_overlay_md5sum" != "$er_extroot_md5sum" ]; then
+ pi_extroot_mount_success="false"
+ mkdir -p $er_disabled
+ mount --move ${ER_OVERLAY_ROM} $er_disabled
+ fi
+}
+
+set_jffs_md5sum() {
+ # We do this anytime block-extroot exists, even on the first boot with
+ # no extroot defined.
+
+ local er_md5sum_file
+ er_md5sum_file="${ER_OVERLAY_PREFIX}/.extroot.md5sum"
+
+ local er_extroot_md5sum
+ if [ -f $er_md5sum_file ]; then
+ er_extroot_md5sum="$(cat $er_md5sum_file)"
+ fi
+ if [ -z "$er_extroot_md5sum" ]; then
+ dd if=/dev/urandom count=32 bs=1k 2>/dev/null | md5sum | cut -f1 -d\ >$er_md5sum_file
+ fi
+}
+
+determine_extroot_sysupgrade() {
+ check_skip || set_jffs_md5sum
+
+ check_skip || [ "$pi_extroot_mount_success" != "true" ] || {
+ check_set_md5sum
+ }
+}
+
+boot_hook_add preinit_mount_root determine_extroot_sysupgrade
+
diff --git a/package/block-mount/files/60_pivot_usb_root b/package/block-mount/files/60_pivot_usb_root
new file mode 100644
index 0000000..b610a4a
--- /dev/null
+++ b/package/block-mount/files/60_pivot_usb_root
@@ -0,0 +1,27 @@
+#!/bin/sh
+# Copyright (C) 2010 Vertical Communications
+
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+
+# Determine if we are requested to mount external root
+
+external_root_pivot() {
+ check_skip || [ "$pi_extroot_mount_success" != "true" ] || {
+ echo "switching to external rootfs"
+ if [ "$ER_OVERLAY_ROM" = "/overlay" ]; then
+ if [ "$ER_IS_SQUASHFS" = "true" ]; then
+ umount /tmp/overlay
+ fi
+ mount -o remount,ro / && fopivot /overlay /rom && pi_mount_skip_next=true
+ elif [ "$ER_OVERLAY_ROM" = "/rom" ]; then
+ if [ "$ER_IS_SQUASHFS" = "true" ]; then
+ umount /tmp/overlay
+ fi
+ mount -o remount,ro / && pivot_rom /rom /rom && pi_mount_skip_next=true
+ fi
+ }
+}
+
+boot_hook_add preinit_mount_root external_root_pivot
+
diff --git a/package/block-mount/files/block.sh b/package/block-mount/files/block.sh
new file mode 100644
index 0000000..2b679a8
--- /dev/null
+++ b/package/block-mount/files/block.sh
@@ -0,0 +1,264 @@
+#!/bin/sh
+# Copyright 2010 Vertical Communications
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+. /lib/functions.sh
+
+reset_block_cb() {
+ mount_cb() {
+ dmc_mount_cfg="$1"
+ shift # skip optional param
+ dmc_target="$2"
+ dmc_mount_device="$3"
+ dmc_fstype="$4"
+ dmc_options="$5"
+ dmc_enabled="$6"
+ dmc_enabled_fsck="$7"
+ dmc_uuid="$8"
+ dmc_label="$9"
+ shift
+ dmc_is_rootfs="$9"
+ return 0
+ }
+ swap_cb() {
+ dsc_swap_cfg="$1"
+ shift # skip optional param
+ dsc_swap_device="$2"
+ dsc_enabled="$3"
+ dsc_uuid="$4"
+ dsc_label="$5"
+ return 0
+ }
+}
+reset_block_cb
+
+reset_dev_section_cb() {
+ mount_dev_section_cb() {
+ dmds_mount_cfg="$1"
+ dmds_mount_target="$2"
+ dmds_mount_device="$3"
+ dmds_mount_fstype="$4"
+ dmds_mount_options="$5"
+ dmds_mount_enabled="$6"
+ dmds_mount_enabled_fsck="$7"
+ dmds_mount_uuid="$8"
+ dmds_mount_label="$9"
+ shift
+ dmds_is_rootfs="$9"
+ return 0
+ }
+ swap_dev_section_cb() {
+ dsds_swap_cfg="$1"
+ dsds_swap_device="$2"
+ dsds_swap_enabled="$3"
+ dsds_swap_uuid="$4"
+ dsds_swap_label="$5"
+ return 0
+ }
+}
+reset_dev_section_cb
+
+config_get_mount() {
+ local gm_cfg="$1"
+ local gm_param="$2"
+ local gm_target
+ local gm_device
+ local gm_fstype
+ local gm_options
+ local gm_enabled
+ local gm_enabled_fsck
+ local gm_uuid
+ local gm_label
+ local gm_is_rootfs
+ config_get gm_target "$1" target
+ config_get gm_device "$1" device
+ config_get gm_fstype "$1" fstype 'auto'
+ config_get gm_options "$1" options 'rw'
+ config_get_bool gm_enabled "$1" enabled 1
+ config_get_bool gm_enabled_fsck "$1" enabled_fsck 0
+ config_get gm_uuid "$1" uuid
+ config_get gm_label "$1" label
+ config_get_bool gm_is_rootfs "$1" is_rootfs 0
+ mount_cb "$gm_cfg" "$gm_param" "$gm_target" "$gm_device" "$gm_fstype" "$gm_options" "$gm_enabled" "$gm_enabled_fsck" "$gm_uuid" "$gm_label" "$gm_is_rootfs"
+}
+
+config_get_swap() {
+ local gs_cfg="$1"
+ local gs_param="$2"
+ local gs_device
+ local gs_enabled
+ local gs_uuid
+ local gs_label
+ config_get gs_device "$1" device
+ config_get_bool gs_enabled "$1" enabled 1
+ config_get gs_uuid "$1" uuid
+ config_get gs_label "$1" label
+
+ swap_cb "$gs_cfg" "$gs_param" "$gs_device" "$gs_enabled" "$gs_uuid" "$gs_label"
+}
+
+config_get_automount() {
+ config_load fstab
+ config_get_bool from_fstab "automount" from_fstab 1
+ config_get_bool anon_mount "automount" anon_mount 1
+ config_get_bool anon_fsck "automount" anon_fsck 0
+}
+
+config_get_autoswap() {
+ config_load fstab
+ config_get_bool from_fstab "autoswap" from_fstab 1
+ config_get_bool anon_swap "autoswap" anon_swap 0
+}
+
+config_create_swap_fstab_entry() {
+ local device="$1"
+ local enabled="$2"
+
+ [ -n "$device" ] || return 0
+
+ local fstabnew
+
+ mkdir -p /var/lock
+ lock /var/lock/fstab.lck
+ fstabnew="$(mktemp -t '.fstab.XXXXXXXX')"
+ cat /tmp/fstab | grep -E -v "^$device[[:blank:]]" >>"$fstabnew"
+ [ "$enabled" -eq 1 ] && echo "$device none swap sw 0 0" >> "$fstabnew"
+ cat "$fstabnew" >/tmp/fstab
+ rm -f $fstabnew
+ lock -u /var/lock/fstab.lck
+}
+
+config_create_mount_fstab_entry() {
+ local device="$1"
+ local target="$2"
+ local fstype="$3"
+ local options="$4"
+ local enabled="$5"
+ options="${options:-rw}"
+ [ "$enabled" -eq 0 ] && options="noauto,$options"
+ [ -n "$target" ] || return 0
+ [ -n "$device" ] || return 0
+
+ local fstabnew
+
+ mkdir -p /var/lock
+ lock /var/lock/fstab.lck
+ fstabnew="$(mktemp -t '.fstab.XXXXXXXX')"
+ cat /tmp/fstab | grep -E -v "^$device[[:blank:]]" | grep -v "$target" >>"$fstabnew"
+ echo "$device $target $fstype $options 0 0" >>"$fstabnew"
+ cat "$fstabnew" >/tmp/fstab
+ rm -f $fstabnew
+ lock -u /var/lock/fstab.lck
+}
+
+libmount_find_token() {
+ local token="$1"
+ local value="$2"
+ local device
+ device="$(blkid -w /dev/null -c /dev/null | grep "$token=\"$value\"" | cut -f1 -d:)"
+ echo "$device"
+}
+
+libmount_find_device_by_id() {
+ local uuid="$1"
+ local label="$2"
+ local device="$3"
+ local cfg_device="$4"
+ local found_device
+
+ if [ -n "$uuid" ]; then
+ found_device="$(libmount_find_token "UUID" "$uuid")"
+ elif [ -n "$label" ]; then
+ found_device="$(libmount_find_token "LABEL" "$label")"
+ elif [ "$device" = "$cfg_device" ]; then
+ found_device="$device"
+ elif [ -z "$device" ] && [ -e "$cfg_device" ]; then
+ found_device="$cfg_device"
+ fi
+ [ -n "$device" ] && [ "$device" != "$found_device" ] && {
+ found_device=""
+ }
+ echo "$found_device"
+}
+
+config_get_mount_section_by_device() {
+ local msbd_device="$1"
+ local msbd_mount_cfg=
+ local msbd_target=
+ local msbd_mount_device=
+ local msbd_fstype=
+ local msbd_options=
+ local msbd_enabled=
+ local msbd_enabled_fsck=
+ local msbd_uuid=
+ local msbd_label=
+ local msbd_is_rootfs
+ local msbd_blkid_fstype_match=
+ mount_cb() {
+ local mc_cfg="$1"
+ local mc_device="$2"
+ shift
+ local mc_target="$2"
+ local mc_cfgdevice="$3"
+ local mc_fstype="$4"
+ local mc_uuid="$8"
+ local mc_label="$9"
+ shift
+ local mc_is_rootfs="$9"
+ local mc_found_device=""
+
+ mc_found_device="$(libmount_find_device_by_id "$mc_uuid" "$mc_label" "$mc_device" "$mc_cfgdevice")"
+ if [ -n "$mc_found_device" ]; then
+ msbd_mount_cfg="$mc_cfg"
+ msbd_target="$mc_target"
+ msbd_mount_device="$mc_found_device"
+ msbd_fstype="$mc_fstype"
+ msbd_options="$4"
+ msbd_enabled="$5"
+ msbd_enabled_fsck="$6"
+ msbd_uuid="$7"
+ msbd_label="$8"
+ msbd_is_rootfs="$9"
+ fi
+ return 0
+ }
+ config_foreach config_get_mount mount "$msbd_device"
+ [ -n "$msbd_mount_device" ] && config_create_mount_fstab_entry "$msbd_mount_device" "$msbd_target" "$msbd_fstype" "$msbd_options" "$msbd_enabled"
+ mount_dev_section_cb "$msbd_mount_cfg" "$msbd_target" "$msbd_mount_device" "$msbd_fstype" "$msbd_options" "$msbd_enabled" "$msbd_enabled_fsck" "$msbd_uuid" "$msbd_label" "$msbd_is_rootfs"
+ reset_block_cb
+}
+
+config_get_swap_section_by_device() {
+ local ssbd_device="$1"
+ local ssbd_swap_cfg=
+ local ssbd_swap_device=
+ local ssbd_enabled=
+ local ssbd_uuid=
+ local ssbd_label=
+ swap_cb() {
+ local sc_cfg="$1"
+ local sc_device="$2"
+ local sc_uuid="$5"
+ local sc_label="$6"
+ local sc_cfgdevice="$3"
+ local sc_found_device
+
+ sc_found_device="$(libmount_find_device_by_id "$sc_uuid" "$sc_label" "$sc_device" "$sc_cfgdevice")"
+ if [ -n "$sc_found_device" ]; then
+ ssbd_swap_cfg="$sc_cfg"
+ ssbd_swap_device="$sc_found_device"
+ ssbd_enabled="$4"
+ ssbd_uuid="$5"
+ ssbd_label="$6"
+ fi
+ return 0
+ }
+ config_foreach config_get_swap swap "$ssbd_device"
+ [ -n "$ssbd_swap_device" ] && config_create_swap_fstab_entry "$ssbd_swap_device" "$ssbd_enabled"
+ swap_dev_section_cb "$ssbd_swap_cfg" "$ssbd_swap_device" "$ssbd_enabled" "$ssbd_uuid" "$ssbd_label"
+ reset_block_cb
+}
+
+
diff --git a/package/block-mount/files/extmount.sh b/package/block-mount/files/extmount.sh
new file mode 100644
index 0000000..d6387cc
--- /dev/null
+++ b/package/block-mount/files/extmount.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+# Copyright (C) 2006-2011 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+
+determine_root_device() {
+ root_device="$(mount | grep ' / ' | cut -f1 -d\ | grep -v rootfs )"
+}
+
+set_jffs_mp() {
+ jffs="$(awk '/jffs2/ {print $2}' /proc/mounts)"
+}
+
+er_load_modules() {
+ mkdir -p /tmp/extroot_modules/modules.d
+ mkdir -p /tmp/extroot_modules/modules
+ cp -L /etc/modules-boot.d/* /tmp/overlay/etc/modules-boot.d/* /tmp/extroot_modules/modules.d
+ ln -sf /lib/modules/*/* /tmp/overlay/lib/modules/*/* /tmp/extroot_modules/modules
+ local modules="$(cat /tmp/extroot_modules/modules.d/* 2>/dev/null)"
+ cd /tmp/extroot_modules/modules && [ -n "$modules" ] && {
+ echo "$modules" | sed -e 's/^\([^#].*\)/insmod \.\/\1.ko/'| sh 2>&- || :
+ }
+ rm -rf /tmp/extroot_modules
+}
+
+pivot_rom() { # <new_root> <old_root>
+ mount -o move /proc $1/proc && \
+ pivot_root $1 $1$2 && {
+ mount -o move $2/dev /dev
+ mount -o move $2/tmp /tmp
+ mount -o move $2/sys /sys 2>&-
+ return 0
+ }
+}
+
diff --git a/package/block-mount/files/fsck.sh b/package/block-mount/files/fsck.sh
new file mode 100644
index 0000000..3011160
--- /dev/null
+++ b/package/block-mount/files/fsck.sh
@@ -0,0 +1,34 @@
+#!/bin/sh
+# Copyright 2010 Vertical Communications
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+libmount_fsck() {
+ local device="$1"
+ local fsck_fstype="$2"
+ local fsck_enabled="$3"
+ local known_type
+ local found_fsck=0
+
+
+ grep -q "$device" /proc/swaps || grep -q "$device" /proc/mounts || {
+ [ -e "$device" ] && [ "$fsck_enabled" -eq 1 ] && {
+ for known_type in $libmount_known_fsck; do
+ if [ "$known_type" = "$fsck_fstype" ]; then
+ fsck_${known_type} "$device"
+ found_fsck=1
+ break
+ fi
+ done
+ if [ "$found_fsck" -ne 1 ]; then
+ logger -t 'fstab' "Unable to check/repair $device; no known fsck for filesystem type $fstype"
+ fi
+ }
+ }
+}
+
+libmount_known_fsck=""
+
+pi_include /lib/functions/fsck
+
diff --git a/package/block-mount/files/fstab.config b/package/block-mount/files/fstab.config
new file mode 100644
index 0000000..de52e20
--- /dev/null
+++ b/package/block-mount/files/fstab.config
@@ -0,0 +1,20 @@
+config global automount
+ option from_fstab 1
+ option anon_mount 1
+
+config global autoswap
+ option from_fstab 1
+ option anon_swap 0
+
+config mount
+ option target /home
+ option device /dev/sda1
+ option fstype ext4
+ option options rw,sync
+ option enabled 0
+ option enabled_fsck 0
+
+config swap
+ option device /dev/sda2
+ option enabled 0
+
diff --git a/package/block-mount/files/fstab.init b/package/block-mount/files/fstab.init
new file mode 100644
index 0000000..4f1f6fb
--- /dev/null
+++ b/package/block-mount/files/fstab.init
@@ -0,0 +1,92 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2007 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+
+START=20
+
+EXTRA_COMMANDS="overlay_enable whole_root_enable"
+EXTRA_HELP=" overlay_enable Reenable overlay rootfs. (After you fix it).
+ whole_root_enable Reenable whole-disk rootfs. (After you fix it)."
+
+rootfs_enable() {
+ local extroot_type="$1"
+
+ if [ ! -d /tmp/${extroot_type}-disabled ]; then
+ echo "No disabled ${extroot_type} present (/tmp/${extroot_type}-disabled). Can't renable."
+ exit 1
+ fi
+
+ rm -f /tmp/${extroot_type}-disabled/.extroot.md5sum
+ rm -f /tmp/${extroot_type}-disabled/etc/extroot.md5sum
+ echo "Please reboot router to complete re-enabling external rootfs."
+}
+
+overlay_enable() {
+ rootfs_enable overlay
+}
+
+whole_root_enable() {
+ rootfs_enable whole_root
+}
+
+do_mount() {
+ local cfg="$1"
+ config_mount_by_section "$cfg"
+}
+
+do_swapon() {
+ local cfg="$1"
+ config_swapon_by_section "$cfg"
+}
+
+do_unmount() {
+ local cfg="$1"
+
+ config_get target "$cfg" target
+ config_get_bool enabled "$cfg" "enabled" '1'
+ [ -n "$target" -a "$enabled" -gt 0 ] || return 0
+ umount $target
+}
+
+do_swapoff() {
+ local cfg="$1"
+
+ config_get device "$cfg" device
+ config_get_bool enabled "$cfg" "enabled" '1'
+ [ -n "$device" -a "$enabled" -gt 0 ] && type swapoff >/dev/null || return 0
+ swapoff $device
+}
+
+start() {
+ . /lib/functions/mount.sh
+
+ config_load fstab
+ mkdir -p /var/lock
+ lock /var/lock/fstab.lck
+ [ -e /tmp/fstab ] || {
+ echo '# WARNING: this is an auto generated file, please use uci to set defined filesystems' > /tmp/fstab
+ }
+ lock -u /var/lock/fstab.lck
+ config_foreach do_swapon swap
+ config_foreach do_mount mount
+ config_foreach do_swapon swap # do swap a second time so that swap on filesystems is enabled
+}
+
+stop() {
+ . /lib/functions/mount.sh
+
+ config_load fstab
+ config_foreach do_unmount mount
+ config_foreach do_swapoff swap
+ swapoff -a
+}
+
+restart() {
+ stop
+ sleep 1
+ start
+}
diff --git a/package/block-mount/files/mount.sh b/package/block-mount/files/mount.sh
new file mode 100644
index 0000000..e96174c
--- /dev/null
+++ b/package/block-mount/files/mount.sh
@@ -0,0 +1,103 @@
+#!/bin/sh
+# Copyright 2010 Vertical Communications
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+
+pi_include /lib/functions/block.sh
+pi_include /lib/functions/fsck.sh
+
+config_mount_by_section() {
+ local cfg="$1"
+ local find_rootfs="$2"
+
+ mount_cb() {
+ local cfg="$1"
+ local device="$2"
+ shift
+ local target="$2"
+ local cfgdevice="$3"
+ local fstype="$4"
+ local options="$5"
+ local enabled="$6"
+ local enabled_fsck="$7"
+ local uuid="$8"
+ local label="$9"
+ shift
+ local is_rootfs="$9"
+ shift
+ local found_device=""
+
+ found_device="$(libmount_find_device_by_id "$uuid" "$label" "$device" "$cfgdevice")"
+ if [ -n "$found_device" ]; then
+ if [ "$find_rootfs" != "1" ] || ( [ "$is_rootfs" -eq 1 ] || [ "$target" = "/" ] || [ "$target" = "/overlay" ] ); then
+ [ "$enabled_fsck" -eq 1 ] && {
+ grep -q "$found_device" /proc/swaps || grep -q "$found_device" /proc/mounts || {
+ libmount_fsck "$found_device" "$fstype" "$enabled_fsck"
+ }
+ }
+
+ if [ "$find_rootfs" = "1" ]; then
+ if [ "$is_rootfs" -eq 1 ]; then
+ target=/overlay
+ elif [ "$target" = "/" ]; then
+ target=/rom
+ fi
+ else
+ if [ "$is_rootfs" -eq 1 ] || [ "$target" = "/overlay" ]; then
+ target=/tmp/overlay-disabled
+ elif [ "$target" = "/" ] || [ "$target" = "/rom" ]; then
+ target="/tmp/whole_root-disabled"
+ fi
+ fi
+
+ config_create_mount_fstab_entry "$found_device" "$target" "$fstype" "$options" "$enabled"
+ grep -q "$found_device" /proc/swaps || grep -q "$found_device" /proc/mounts || {
+ [ "$enabled" -eq 1 ] && mkdir -p "$target" && mount "$target" 2>&1 | tee /proc/self/fd/2 | logger -t 'fstab'
+ }
+
+ fi
+ fi
+ [ "$find_rootfs" = "1" ] && {
+ [ "$target" = "/overlay" ] && {
+ rootfs_found=1
+ }
+ [ "$target" = "/rom" ] && {
+ rootfs_found=1
+ }
+ }
+ return 0
+ }
+ config_get_mount "$cfg"
+ reset_block_cb
+}
+
+config_swapon_by_section() {
+ local cfg="$1"
+
+ swap_cb() {
+ local cfg="$1"
+ local device="$2"
+ local cfgdevice="$3"
+ local enabled="$4"
+ local uuid="$5"
+ local label="$6"
+ local uuid
+ local label
+
+ local found_device=""
+
+ found_device="$(libmount_find_device_by_id "$uuid" "$label" "$device" "$cfgdevice")"
+
+ if [ -n "$found_device" ]; then
+ config_create_swap_fstab_entry "$found_device" "$enabled"
+ grep -q "$found_device" /proc/swaps || grep -q "$found_device" /proc/mounts || {
+ [ "$enabled" -eq 1 ] && swapon "$found_device" | tee /proc/self/fd/2 | logger -t 'fstab'
+ }
+ fi
+ return 0
+ }
+ config_get_swap "$cfg"
+ reset_block_cb
+}
diff --git a/package/boot/.svn/entries b/package/boot/.svn/entries
new file mode 100644
index 0000000..4d0cef9
--- /dev/null
+++ b/package/boot/.svn/entries
@@ -0,0 +1,67 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-15T01:36:53.833391Z
+36033
+luka
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+uboot-envtools
+dir
+
+uboot-kirkwood
+dir
+
+uboot-ar71xx
+dir
+
+grub2
+dir
+
+rbcfg
+dir
+
+uboot-omap4
+dir
+
+uboot-omap35xx
+dir
+
+fconfig
+dir
+
+yamonenv
+dir
+
+kexec-tools
+dir
+
+uboot-xburst
+dir
+
+uboot-lantiq
+dir
+
+uboot-pxa
+dir
+
diff --git a/package/boot/fconfig/.svn/entries b/package/boot/fconfig/.svn/entries
new file mode 100644
index 0000000..43502aa
--- /dev/null
+++ b/package/boot/fconfig/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/fconfig
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+ce975dc74a1a3684527983fd088edae2
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+990
+
diff --git a/package/boot/fconfig/.svn/prop-base/Makefile.svn-base b/package/boot/fconfig/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..4179626
--- /dev/null
+++ b/package/boot/fconfig/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,9 @@
+K 9
+copyright
+V 30
+Copyright (C) 2006 OpenWrt.org
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/boot/fconfig/.svn/text-base/Makefile.svn-base b/package/boot/fconfig/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..14bbec5
--- /dev/null
+++ b/package/boot/fconfig/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,45 @@
+#
+# Copyright (C) 2006-2008 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=fconfig
+PKG_VERSION:=20080329
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://andrzejekiert.ovh.org/software/fconfig/
+PKG_MD5SUM:=dac355e9f2a0f48c414c52e2034b6346
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/fconfig
+ SECTION:=utils
+ CATEGORY:=Utilities
+ TITLE:=RedBoot configuration editor
+ URL:=http://andrzejekiert.ovh.org/software.html.en
+endef
+
+define Package/fconfig/description
+ displays and (if writable) also edits the RedBoot configuration.
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+ $(call Build/Compile/Default)
+endef
+
+define Package/fconfig/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/fconfig $(1)/usr/sbin/
+endef
+
+$(eval $(call BuildPackage,fconfig))
diff --git a/package/boot/fconfig/Makefile b/package/boot/fconfig/Makefile
new file mode 100644
index 0000000..14bbec5
--- /dev/null
+++ b/package/boot/fconfig/Makefile
@@ -0,0 +1,45 @@
+#
+# Copyright (C) 2006-2008 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=fconfig
+PKG_VERSION:=20080329
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://andrzejekiert.ovh.org/software/fconfig/
+PKG_MD5SUM:=dac355e9f2a0f48c414c52e2034b6346
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/fconfig
+ SECTION:=utils
+ CATEGORY:=Utilities
+ TITLE:=RedBoot configuration editor
+ URL:=http://andrzejekiert.ovh.org/software.html.en
+endef
+
+define Package/fconfig/description
+ displays and (if writable) also edits the RedBoot configuration.
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+ $(call Build/Compile/Default)
+endef
+
+define Package/fconfig/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/fconfig $(1)/usr/sbin/
+endef
+
+$(eval $(call BuildPackage,fconfig))
diff --git a/package/boot/grub2/.svn/entries b/package/boot/grub2/.svn/entries
new file mode 100644
index 0000000..1fbbf4b
--- /dev/null
+++ b/package/boot/grub2/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/grub2
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-11-26T16:03:40.540832Z
+34389
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+0b28cdcaf03ae3f53f28ce7026102dcb
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1147
+
diff --git a/package/boot/grub2/.svn/text-base/Makefile.svn-base b/package/boot/grub2/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..b606f54
--- /dev/null
+++ b/package/boot/grub2/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,51 @@
+#
+# Copyright (C) 2006-2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=grub
+PKG_VERSION:=2.00
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=@GNU/grub
+PKG_MD5SUM:=e927540b6eda8b024fb0391eeaa4091c
+
+PKG_HOST_ONLY:=1
+HOST_BUILD_PARALLEL:=1
+PKG_BUILD_DEPENDS:=grub2/host
+
+include $(INCLUDE_DIR)/host-build.mk
+include $(INCLUDE_DIR)/package.mk
+
+define Package/grub2
+ SUBMENU:=Boot Loaders
+ CATEGORY:=Utilities
+ SECTION:=utils
+ TITLE:=GRand Unified Bootloader
+ URL:=http://www.gnu.org/software/grub/
+ DEPENDS:=@TARGET_x86
+endef
+
+HOST_CONFIGURE_ARGS += \
+ --target=$(REAL_GNU_TARGET_NAME) \
+ --sbindir="$(STAGING_DIR_HOST)/bin" \
+ --disable-werror \
+ --disable-nls
+
+HOST_MAKE_FLAGS += \
+ TARGET_RANLIB=$(TARGET_RANLIB) \
+ LIBLZMA=$(STAGING_DIR_HOST)/lib/liblzma.a
+
+define Host/Configure
+ $(SED) 's,(RANLIB),(TARGET_RANLIB),' $(HOST_BUILD_DIR)/grub-core/Makefile.in
+ $(Host/Configure/Default)
+endef
+
+$(eval $(call HostBuild))
+$(eval $(call BuildPackage,grub2))
diff --git a/package/boot/grub2/Makefile b/package/boot/grub2/Makefile
new file mode 100644
index 0000000..b606f54
--- /dev/null
+++ b/package/boot/grub2/Makefile
@@ -0,0 +1,51 @@
+#
+# Copyright (C) 2006-2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=grub
+PKG_VERSION:=2.00
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=@GNU/grub
+PKG_MD5SUM:=e927540b6eda8b024fb0391eeaa4091c
+
+PKG_HOST_ONLY:=1
+HOST_BUILD_PARALLEL:=1
+PKG_BUILD_DEPENDS:=grub2/host
+
+include $(INCLUDE_DIR)/host-build.mk
+include $(INCLUDE_DIR)/package.mk
+
+define Package/grub2
+ SUBMENU:=Boot Loaders
+ CATEGORY:=Utilities
+ SECTION:=utils
+ TITLE:=GRand Unified Bootloader
+ URL:=http://www.gnu.org/software/grub/
+ DEPENDS:=@TARGET_x86
+endef
+
+HOST_CONFIGURE_ARGS += \
+ --target=$(REAL_GNU_TARGET_NAME) \
+ --sbindir="$(STAGING_DIR_HOST)/bin" \
+ --disable-werror \
+ --disable-nls
+
+HOST_MAKE_FLAGS += \
+ TARGET_RANLIB=$(TARGET_RANLIB) \
+ LIBLZMA=$(STAGING_DIR_HOST)/lib/liblzma.a
+
+define Host/Configure
+ $(SED) 's,(RANLIB),(TARGET_RANLIB),' $(HOST_BUILD_DIR)/grub-core/Makefile.in
+ $(Host/Configure/Default)
+endef
+
+$(eval $(call HostBuild))
+$(eval $(call BuildPackage,grub2))
diff --git a/package/boot/grub2/patches/.svn/entries b/package/boot/grub2/patches/.svn/entries
new file mode 100644
index 0000000..aa580af
--- /dev/null
+++ b/package/boot/grub2/patches/.svn/entries
@@ -0,0 +1,130 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/grub2/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-11-26T16:03:40.540832Z
+34389
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+200-fix-gets-removal.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+4347c13528381c1ebf68d183a9cc0165
+2012-11-26T16:03:40.540832Z
+34389
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+560
+
+200-grub_musl.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+eae2474dbd84e1bcbe72e4b91f9f79be
+2012-11-23T20:01:53.954168Z
+34306
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1059
+
+100-grub_setup_root.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+aec4834762dc8e05bb7c862cc82aab40
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2328
+
diff --git a/package/boot/grub2/patches/.svn/text-base/100-grub_setup_root.patch.svn-base b/package/boot/grub2/patches/.svn/text-base/100-grub_setup_root.patch.svn-base
new file mode 100644
index 0000000..7775b2a
--- /dev/null
+++ b/package/boot/grub2/patches/.svn/text-base/100-grub_setup_root.patch.svn-base
@@ -0,0 +1,77 @@
+--- a/util/grub-setup.c
++++ b/util/grub-setup.c
+@@ -141,12 +141,11 @@ write_rootdev (char *core_img, grub_devi
+ static void
+ setup (const char *dir,
+ const char *boot_file, const char *core_file,
+- const char *dest, int force,
++ const char *root, const char *dest, int force,
+ int fs_probe, int allow_floppy)
+ {
+ char *boot_path, *core_path, *core_path_dev, *core_path_dev_full;
+ char *boot_img, *core_img;
+- char *root = 0;
+ size_t boot_size, core_size;
+ grub_uint16_t core_sectors;
+ grub_device_t root_dev = 0, dest_dev, core_dev;
+@@ -253,7 +252,10 @@ setup (const char *dir,
+
+ core_dev = dest_dev;
+
+- {
++ if (root)
++ root_dev = grub_device_open(root);
++
++ if (!root_dev) {
+ char **root_devices = grub_guess_root_devices (dir);
+ char **cur;
+ int found = 0;
+@@ -263,6 +265,8 @@ setup (const char *dir,
+ char *drive;
+ grub_device_t try_dev;
+
++ if (root_dev)
++ break;
+ drive = grub_util_get_grub_dev (*cur);
+ if (!drive)
+ continue;
+@@ -956,6 +960,8 @@ static struct argp_option options[] = {
+ N_("install even if problems are detected"), 0},
+ {"skip-fs-probe",'s',0, 0,
+ N_("do not probe for filesystems in DEVICE"), 0},
++ {"root-device", 'r', N_("DEVICE"), 0,
++ N_("use DEVICE as the root device"), 0},
+ {"verbose", 'v', 0, 0, N_("print verbose messages."), 0},
+ {"allow-floppy", 'a', 0, 0,
+ /* TRANSLATORS: The potential breakage isn't limited to floppies but it's
+@@ -993,6 +999,7 @@ struct arguments
+ char *core_file;
+ char *dir;
+ char *dev_map;
++ char *root_dev;
+ int force;
+ int fs_probe;
+ int allow_floppy;
+@@ -1040,6 +1047,13 @@ argp_parser (int key, char *arg, struct
+ arguments->dev_map = xstrdup (arg);
+ break;
+
++ case 'r':
++ if (arguments->root_dev)
++ free (arguments->root_dev);
++
++ arguments->root_dev = xstrdup (arg);
++ break;
++
+ case 'f':
+ arguments->force = 1;
+ break;
+@@ -1172,7 +1186,7 @@ main (int argc, char *argv[])
+ setup (arguments.dir ? : DEFAULT_DIRECTORY,
+ arguments.boot_file ? : DEFAULT_BOOT_FILE,
+ arguments.core_file ? : DEFAULT_CORE_FILE,
+- dest_dev, arguments.force,
++ arguments.root_dev, dest_dev, arguments.force,
+ arguments.fs_probe, arguments.allow_floppy);
+
+ /* Free resources. */
diff --git a/package/boot/grub2/patches/.svn/text-base/200-fix-gets-removal.patch.svn-base b/package/boot/grub2/patches/.svn/text-base/200-fix-gets-removal.patch.svn-base
new file mode 100644
index 0000000..4370fb5
--- /dev/null
+++ b/package/boot/grub2/patches/.svn/text-base/200-fix-gets-removal.patch.svn-base
@@ -0,0 +1,15 @@
+--- a/grub-core/gnulib/stdio.in.h
++++ b/grub-core/gnulib/stdio.in.h
+@@ -137,12 +137,6 @@
+ "use gnulib module fflush for portable POSIX compliance");
+ #endif
+
+-/* It is very rare that the developer ever has full control of stdin,
+- so any use of gets warrants an unconditional warning. Assume it is
+- always declared, since it is required by C89. */
+-#undef gets
+-_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
+-
+ #if @GNULIB_FOPEN@
+ # if @REPLACE_FOPEN@
+ # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
diff --git a/package/boot/grub2/patches/.svn/text-base/200-grub_musl.patch.svn-base b/package/boot/grub2/patches/.svn/text-base/200-grub_musl.patch.svn-base
new file mode 100644
index 0000000..b1ff63a
--- /dev/null
+++ b/package/boot/grub2/patches/.svn/text-base/200-grub_musl.patch.svn-base
@@ -0,0 +1,22 @@
+diff -urN grub-2.00/build-aux/config.sub grub-2.00.new/build-aux/config.sub
+--- grub-2.00/build-aux/config.sub 2012-06-18 23:08:46.000000000 +0200
++++ grub-2.00.new/build-aux/config.sub 2012-11-22 14:12:12.190748353 +0100
+@@ -126,7 +126,8 @@
+ linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
+ knetbsd*-gnu* | netbsd*-gnu* | \
+ kopensolaris*-gnu* | \
+- storm-chaos* | os2-emx* | rtmk-nova*)
++ storm-chaos* | os2-emx* | rtmk-nova* | \
++ linux-musl*)
+ os=-$maybe_os
+ basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
+ ;;
+@@ -1360,7 +1361,7 @@
+ | -chorusos* | -chorusrdb* | -cegcc* \
+ | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+ | -mingw32* | -linux-gnu* | -linux-android* \
+- | -linux-newlib* | -linux-uclibc* \
++ | -linux-newlib* | -linux-uclibc* | -linux-musl* \
+ | -uxpv* | -beos* | -mpeix* | -udk* \
+ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
+ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
diff --git a/package/boot/grub2/patches/100-grub_setup_root.patch b/package/boot/grub2/patches/100-grub_setup_root.patch
new file mode 100644
index 0000000..7775b2a
--- /dev/null
+++ b/package/boot/grub2/patches/100-grub_setup_root.patch
@@ -0,0 +1,77 @@
+--- a/util/grub-setup.c
++++ b/util/grub-setup.c
+@@ -141,12 +141,11 @@ write_rootdev (char *core_img, grub_devi
+ static void
+ setup (const char *dir,
+ const char *boot_file, const char *core_file,
+- const char *dest, int force,
++ const char *root, const char *dest, int force,
+ int fs_probe, int allow_floppy)
+ {
+ char *boot_path, *core_path, *core_path_dev, *core_path_dev_full;
+ char *boot_img, *core_img;
+- char *root = 0;
+ size_t boot_size, core_size;
+ grub_uint16_t core_sectors;
+ grub_device_t root_dev = 0, dest_dev, core_dev;
+@@ -253,7 +252,10 @@ setup (const char *dir,
+
+ core_dev = dest_dev;
+
+- {
++ if (root)
++ root_dev = grub_device_open(root);
++
++ if (!root_dev) {
+ char **root_devices = grub_guess_root_devices (dir);
+ char **cur;
+ int found = 0;
+@@ -263,6 +265,8 @@ setup (const char *dir,
+ char *drive;
+ grub_device_t try_dev;
+
++ if (root_dev)
++ break;
+ drive = grub_util_get_grub_dev (*cur);
+ if (!drive)
+ continue;
+@@ -956,6 +960,8 @@ static struct argp_option options[] = {
+ N_("install even if problems are detected"), 0},
+ {"skip-fs-probe",'s',0, 0,
+ N_("do not probe for filesystems in DEVICE"), 0},
++ {"root-device", 'r', N_("DEVICE"), 0,
++ N_("use DEVICE as the root device"), 0},
+ {"verbose", 'v', 0, 0, N_("print verbose messages."), 0},
+ {"allow-floppy", 'a', 0, 0,
+ /* TRANSLATORS: The potential breakage isn't limited to floppies but it's
+@@ -993,6 +999,7 @@ struct arguments
+ char *core_file;
+ char *dir;
+ char *dev_map;
++ char *root_dev;
+ int force;
+ int fs_probe;
+ int allow_floppy;
+@@ -1040,6 +1047,13 @@ argp_parser (int key, char *arg, struct
+ arguments->dev_map = xstrdup (arg);
+ break;
+
++ case 'r':
++ if (arguments->root_dev)
++ free (arguments->root_dev);
++
++ arguments->root_dev = xstrdup (arg);
++ break;
++
+ case 'f':
+ arguments->force = 1;
+ break;
+@@ -1172,7 +1186,7 @@ main (int argc, char *argv[])
+ setup (arguments.dir ? : DEFAULT_DIRECTORY,
+ arguments.boot_file ? : DEFAULT_BOOT_FILE,
+ arguments.core_file ? : DEFAULT_CORE_FILE,
+- dest_dev, arguments.force,
++ arguments.root_dev, dest_dev, arguments.force,
+ arguments.fs_probe, arguments.allow_floppy);
+
+ /* Free resources. */
diff --git a/package/boot/grub2/patches/200-fix-gets-removal.patch b/package/boot/grub2/patches/200-fix-gets-removal.patch
new file mode 100644
index 0000000..4370fb5
--- /dev/null
+++ b/package/boot/grub2/patches/200-fix-gets-removal.patch
@@ -0,0 +1,15 @@
+--- a/grub-core/gnulib/stdio.in.h
++++ b/grub-core/gnulib/stdio.in.h
+@@ -137,12 +137,6 @@
+ "use gnulib module fflush for portable POSIX compliance");
+ #endif
+
+-/* It is very rare that the developer ever has full control of stdin,
+- so any use of gets warrants an unconditional warning. Assume it is
+- always declared, since it is required by C89. */
+-#undef gets
+-_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
+-
+ #if @GNULIB_FOPEN@
+ # if @REPLACE_FOPEN@
+ # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
diff --git a/package/boot/grub2/patches/200-grub_musl.patch b/package/boot/grub2/patches/200-grub_musl.patch
new file mode 100644
index 0000000..b1ff63a
--- /dev/null
+++ b/package/boot/grub2/patches/200-grub_musl.patch
@@ -0,0 +1,22 @@
+diff -urN grub-2.00/build-aux/config.sub grub-2.00.new/build-aux/config.sub
+--- grub-2.00/build-aux/config.sub 2012-06-18 23:08:46.000000000 +0200
++++ grub-2.00.new/build-aux/config.sub 2012-11-22 14:12:12.190748353 +0100
+@@ -126,7 +126,8 @@
+ linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
+ knetbsd*-gnu* | netbsd*-gnu* | \
+ kopensolaris*-gnu* | \
+- storm-chaos* | os2-emx* | rtmk-nova*)
++ storm-chaos* | os2-emx* | rtmk-nova* | \
++ linux-musl*)
+ os=-$maybe_os
+ basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
+ ;;
+@@ -1360,7 +1361,7 @@
+ | -chorusos* | -chorusrdb* | -cegcc* \
+ | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+ | -mingw32* | -linux-gnu* | -linux-android* \
+- | -linux-newlib* | -linux-uclibc* \
++ | -linux-newlib* | -linux-uclibc* | -linux-musl* \
+ | -uxpv* | -beos* | -mpeix* | -udk* \
+ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
+ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
diff --git a/package/boot/kexec-tools/.svn/entries b/package/boot/kexec-tools/.svn/entries
new file mode 100644
index 0000000..491df3a
--- /dev/null
+++ b/package/boot/kexec-tools/.svn/entries
@@ -0,0 +1,99 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/kexec-tools
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+patches
+dir
+
+Config.in
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+feb1f5431985cc3122a22da7a6949801
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+450
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+9cf805153359d6a9fd758b0ba696c92c
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1988
+
diff --git a/package/boot/kexec-tools/.svn/prop-base/Config.in.svn-base b/package/boot/kexec-tools/.svn/prop-base/Config.in.svn-base
new file mode 100644
index 0000000..3160658
--- /dev/null
+++ b/package/boot/kexec-tools/.svn/prop-base/Config.in.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:mergeinfo
+V 0
+
+END
diff --git a/package/boot/kexec-tools/.svn/prop-base/Makefile.svn-base b/package/boot/kexec-tools/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..8e522ae
--- /dev/null
+++ b/package/boot/kexec-tools/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:copyright
+V 30
+Copyright (C) 2006 OpenWrt.org
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/boot/kexec-tools/.svn/text-base/Config.in.svn-base b/package/boot/kexec-tools/.svn/text-base/Config.in.svn-base
new file mode 100644
index 0000000..60c819d
--- /dev/null
+++ b/package/boot/kexec-tools/.svn/text-base/Config.in.svn-base
@@ -0,0 +1,21 @@
+menu "Configuration"
+ depends on PACKAGE_kexec-tools
+
+config KEXEC_TOOLS_TARGET_NAME
+ string
+ prompt "Target name for kexec kernel"
+ default EXTRA_TARGET_ARCH_NAME if powerpc64
+ default ARCH
+ help
+ Defines the target type of the kernels that kexec deals
+ with. This should be the target specification of
+ the kernel you're booting.
+
+config KEXEC_TOOLS_kdump
+ bool
+ prompt "kdump support"
+ default n
+ help
+ Include the kdump utility.
+
+endmenu
diff --git a/package/boot/kexec-tools/.svn/text-base/Makefile.svn-base b/package/boot/kexec-tools/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..fa4f4d8
--- /dev/null
+++ b/package/boot/kexec-tools/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,80 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=kexec-tools
+PKG_VERSION:=2.0.3
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=@KERNEL/linux/utils/kernel/kexec
+PKG_MD5SUM:=b3ced2097ce3981abba38ceedc84f939
+
+PKG_FIXUP:=autoreconf
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/kexec-tools
+ SECTION:=utils
+ CATEGORY:=Utilities
+ DEPENDS:=@armeb||@arm||@i386||@powerpc64||@mipsel||@mips +zlib
+ TITLE:=Kernel boots kernel
+ URL:=http://kernel.org/pub/linux/kernel/people/horms/kexec-tools/
+ MAINTAINER:=Florian Fainelli <florian@openwrt.org>
+ MENU:=1
+endef
+
+define Package/kexec-tools/description
+ kexec is a set of systems call that allows you to load
+ another kernel from the currently executing Linux kernel.
+endef
+
+define Package/kexec-tools/config
+ source "$(SOURCE)/Config.in"
+endef
+
+KEXEC_TARGET_NAME:=$(call qstrip,$(CONFIG_KEXEC_TOOLS_TARGET_NAME))-linux-$(TARGET_SUFFIX)
+
+CONFIGURE_ARGS = \
+ --target=$(KEXEC_TARGET_NAME) \
+ --host=$(REAL_GNU_TARGET_NAME) \
+ --build=$(GNU_HOST_NAME) \
+ --program-prefix="" \
+ --program-suffix="" \
+ --prefix=/usr \
+ --exec-prefix=/usr \
+ --bindir=/usr/bin \
+ --sbindir=/usr/sbin \
+ --libexecdir=/usr/lib \
+ --sysconfdir=/etc
+
+CONFIGURE_VARS += \
+ BUILD_CC="$(HOSTCC)" \
+ TARGET_CC="$(TARGET_CC)"
+
+kexec-extra-sbin-$(CONFIG_KEXEC_TOOLS_kdump) += kdump
+
+define Build/Compile
+ $(MAKE) -C $(PKG_BUILD_DIR) DESTDIR="$(PKG_INSTALL_DIR)" all install
+endef
+
+define Package/kexec-tools/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) \
+ $(addprefix $(PKG_INSTALL_DIR)/usr/sbin/, \
+ $(kexec-extra-sbin-y)) \
+ $(kexec-extra-bin-y) \
+ $(PKG_INSTALL_DIR)/usr/sbin/kexec \
+ $(1)/usr/sbin
+
+# make a link for compatability with other distros
+ $(INSTALL_DIR) $(1)/sbin
+ ln -s /usr/sbin/kexec $(1)/sbin/kexec
+endef
+
+$(eval $(call BuildPackage,kexec-tools))
diff --git a/package/boot/kexec-tools/Config.in b/package/boot/kexec-tools/Config.in
new file mode 100644
index 0000000..60c819d
--- /dev/null
+++ b/package/boot/kexec-tools/Config.in
@@ -0,0 +1,21 @@
+menu "Configuration"
+ depends on PACKAGE_kexec-tools
+
+config KEXEC_TOOLS_TARGET_NAME
+ string
+ prompt "Target name for kexec kernel"
+ default EXTRA_TARGET_ARCH_NAME if powerpc64
+ default ARCH
+ help
+ Defines the target type of the kernels that kexec deals
+ with. This should be the target specification of
+ the kernel you're booting.
+
+config KEXEC_TOOLS_kdump
+ bool
+ prompt "kdump support"
+ default n
+ help
+ Include the kdump utility.
+
+endmenu
diff --git a/package/boot/kexec-tools/Makefile b/package/boot/kexec-tools/Makefile
new file mode 100644
index 0000000..fa4f4d8
--- /dev/null
+++ b/package/boot/kexec-tools/Makefile
@@ -0,0 +1,80 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=kexec-tools
+PKG_VERSION:=2.0.3
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=@KERNEL/linux/utils/kernel/kexec
+PKG_MD5SUM:=b3ced2097ce3981abba38ceedc84f939
+
+PKG_FIXUP:=autoreconf
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/kexec-tools
+ SECTION:=utils
+ CATEGORY:=Utilities
+ DEPENDS:=@armeb||@arm||@i386||@powerpc64||@mipsel||@mips +zlib
+ TITLE:=Kernel boots kernel
+ URL:=http://kernel.org/pub/linux/kernel/people/horms/kexec-tools/
+ MAINTAINER:=Florian Fainelli <florian@openwrt.org>
+ MENU:=1
+endef
+
+define Package/kexec-tools/description
+ kexec is a set of systems call that allows you to load
+ another kernel from the currently executing Linux kernel.
+endef
+
+define Package/kexec-tools/config
+ source "$(SOURCE)/Config.in"
+endef
+
+KEXEC_TARGET_NAME:=$(call qstrip,$(CONFIG_KEXEC_TOOLS_TARGET_NAME))-linux-$(TARGET_SUFFIX)
+
+CONFIGURE_ARGS = \
+ --target=$(KEXEC_TARGET_NAME) \
+ --host=$(REAL_GNU_TARGET_NAME) \
+ --build=$(GNU_HOST_NAME) \
+ --program-prefix="" \
+ --program-suffix="" \
+ --prefix=/usr \
+ --exec-prefix=/usr \
+ --bindir=/usr/bin \
+ --sbindir=/usr/sbin \
+ --libexecdir=/usr/lib \
+ --sysconfdir=/etc
+
+CONFIGURE_VARS += \
+ BUILD_CC="$(HOSTCC)" \
+ TARGET_CC="$(TARGET_CC)"
+
+kexec-extra-sbin-$(CONFIG_KEXEC_TOOLS_kdump) += kdump
+
+define Build/Compile
+ $(MAKE) -C $(PKG_BUILD_DIR) DESTDIR="$(PKG_INSTALL_DIR)" all install
+endef
+
+define Package/kexec-tools/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) \
+ $(addprefix $(PKG_INSTALL_DIR)/usr/sbin/, \
+ $(kexec-extra-sbin-y)) \
+ $(kexec-extra-bin-y) \
+ $(PKG_INSTALL_DIR)/usr/sbin/kexec \
+ $(1)/usr/sbin
+
+# make a link for compatability with other distros
+ $(INSTALL_DIR) $(1)/sbin
+ ln -s /usr/sbin/kexec $(1)/sbin/kexec
+endef
+
+$(eval $(call BuildPackage,kexec-tools))
diff --git a/package/boot/kexec-tools/patches/.svn/entries b/package/boot/kexec-tools/patches/.svn/entries
new file mode 100644
index 0000000..a6d2354
--- /dev/null
+++ b/package/boot/kexec-tools/patches/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/kexec-tools/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+0004-mips_regdefs.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+33113e08f846ec68e08370825d881eab
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2919
+
diff --git a/package/boot/kexec-tools/patches/.svn/text-base/0004-mips_regdefs.patch.svn-base b/package/boot/kexec-tools/patches/.svn/text-base/0004-mips_regdefs.patch.svn-base
new file mode 100644
index 0000000..7e21349
--- /dev/null
+++ b/package/boot/kexec-tools/patches/.svn/text-base/0004-mips_regdefs.patch.svn-base
@@ -0,0 +1,103 @@
+--- /dev/null
++++ b/kexec/arch/mips/regdef.h
+@@ -0,0 +1,100 @@
++/*
++ * This file is subject to the terms and conditions of the GNU General Public
++ * License. See the file "COPYING" in the main directory of this archive
++ * for more details.
++ *
++ * Copyright (C) 1985 MIPS Computer Systems, Inc.
++ * Copyright (C) 1994, 95, 99, 2003 by Ralf Baechle
++ * Copyright (C) 1990 - 1992, 1999 Silicon Graphics, Inc.
++ */
++#ifndef _ASM_REGDEF_H
++#define _ASM_REGDEF_H
++
++#include <asm/sgidefs.h>
++
++#if _MIPS_SIM == _MIPS_SIM_ABI32
++
++/*
++ * Symbolic register names for 32 bit ABI
++ */
++#define zero $0 /* wired zero */
++#define AT $1 /* assembler temp - uppercase because of ".set at" */
++#define v0 $2 /* return value */
++#define v1 $3
++#define a0 $4 /* argument registers */
++#define a1 $5
++#define a2 $6
++#define a3 $7
++#define t0 $8 /* caller saved */
++#define t1 $9
++#define t2 $10
++#define t3 $11
++#define t4 $12
++#define t5 $13
++#define t6 $14
++#define t7 $15
++#define s0 $16 /* callee saved */
++#define s1 $17
++#define s2 $18
++#define s3 $19
++#define s4 $20
++#define s5 $21
++#define s6 $22
++#define s7 $23
++#define t8 $24 /* caller saved */
++#define t9 $25
++#define jp $25 /* PIC jump register */
++#define k0 $26 /* kernel scratch */
++#define k1 $27
++#define gp $28 /* global pointer */
++#define sp $29 /* stack pointer */
++#define fp $30 /* frame pointer */
++#define s8 $30 /* same like fp! */
++#define ra $31 /* return address */
++
++#endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */
++
++#if _MIPS_SIM == _MIPS_SIM_ABI64 || _MIPS_SIM == _MIPS_SIM_NABI32
++
++#define zero $0 /* wired zero */
++#define AT $at /* assembler temp - uppercase because of ".set at" */
++#define v0 $2 /* return value - caller saved */
++#define v1 $3
++#define a0 $4 /* argument registers */
++#define a1 $5
++#define a2 $6
++#define a3 $7
++#define a4 $8 /* arg reg 64 bit; caller saved in 32 bit */
++#define ta0 $8
++#define a5 $9
++#define ta1 $9
++#define a6 $10
++#define ta2 $10
++#define a7 $11
++#define ta3 $11
++#define t0 $12 /* caller saved */
++#define t1 $13
++#define t2 $14
++#define t3 $15
++#define s0 $16 /* callee saved */
++#define s1 $17
++#define s2 $18
++#define s3 $19
++#define s4 $20
++#define s5 $21
++#define s6 $22
++#define s7 $23
++#define t8 $24 /* caller saved */
++#define t9 $25 /* callee address for PIC/temp */
++#define jp $25 /* PIC jump register */
++#define k0 $26 /* kernel temporary */
++#define k1 $27
++#define gp $28 /* global pointer - caller saved for PIC */
++#define sp $29 /* stack pointer */
++#define fp $30 /* frame pointer */
++#define s8 $30 /* callee saved */
++#define ra $31 /* return address */
++
++#endif /* _MIPS_SIM == _MIPS_SIM_ABI64 || _MIPS_SIM == _MIPS_SIM_NABI32 */
++
++#endif /* _ASM_REGDEF_H */
diff --git a/package/boot/kexec-tools/patches/0004-mips_regdefs.patch b/package/boot/kexec-tools/patches/0004-mips_regdefs.patch
new file mode 100644
index 0000000..7e21349
--- /dev/null
+++ b/package/boot/kexec-tools/patches/0004-mips_regdefs.patch
@@ -0,0 +1,103 @@
+--- /dev/null
++++ b/kexec/arch/mips/regdef.h
+@@ -0,0 +1,100 @@
++/*
++ * This file is subject to the terms and conditions of the GNU General Public
++ * License. See the file "COPYING" in the main directory of this archive
++ * for more details.
++ *
++ * Copyright (C) 1985 MIPS Computer Systems, Inc.
++ * Copyright (C) 1994, 95, 99, 2003 by Ralf Baechle
++ * Copyright (C) 1990 - 1992, 1999 Silicon Graphics, Inc.
++ */
++#ifndef _ASM_REGDEF_H
++#define _ASM_REGDEF_H
++
++#include <asm/sgidefs.h>
++
++#if _MIPS_SIM == _MIPS_SIM_ABI32
++
++/*
++ * Symbolic register names for 32 bit ABI
++ */
++#define zero $0 /* wired zero */
++#define AT $1 /* assembler temp - uppercase because of ".set at" */
++#define v0 $2 /* return value */
++#define v1 $3
++#define a0 $4 /* argument registers */
++#define a1 $5
++#define a2 $6
++#define a3 $7
++#define t0 $8 /* caller saved */
++#define t1 $9
++#define t2 $10
++#define t3 $11
++#define t4 $12
++#define t5 $13
++#define t6 $14
++#define t7 $15
++#define s0 $16 /* callee saved */
++#define s1 $17
++#define s2 $18
++#define s3 $19
++#define s4 $20
++#define s5 $21
++#define s6 $22
++#define s7 $23
++#define t8 $24 /* caller saved */
++#define t9 $25
++#define jp $25 /* PIC jump register */
++#define k0 $26 /* kernel scratch */
++#define k1 $27
++#define gp $28 /* global pointer */
++#define sp $29 /* stack pointer */
++#define fp $30 /* frame pointer */
++#define s8 $30 /* same like fp! */
++#define ra $31 /* return address */
++
++#endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */
++
++#if _MIPS_SIM == _MIPS_SIM_ABI64 || _MIPS_SIM == _MIPS_SIM_NABI32
++
++#define zero $0 /* wired zero */
++#define AT $at /* assembler temp - uppercase because of ".set at" */
++#define v0 $2 /* return value - caller saved */
++#define v1 $3
++#define a0 $4 /* argument registers */
++#define a1 $5
++#define a2 $6
++#define a3 $7
++#define a4 $8 /* arg reg 64 bit; caller saved in 32 bit */
++#define ta0 $8
++#define a5 $9
++#define ta1 $9
++#define a6 $10
++#define ta2 $10
++#define a7 $11
++#define ta3 $11
++#define t0 $12 /* caller saved */
++#define t1 $13
++#define t2 $14
++#define t3 $15
++#define s0 $16 /* callee saved */
++#define s1 $17
++#define s2 $18
++#define s3 $19
++#define s4 $20
++#define s5 $21
++#define s6 $22
++#define s7 $23
++#define t8 $24 /* caller saved */
++#define t9 $25 /* callee address for PIC/temp */
++#define jp $25 /* PIC jump register */
++#define k0 $26 /* kernel temporary */
++#define k1 $27
++#define gp $28 /* global pointer - caller saved for PIC */
++#define sp $29 /* stack pointer */
++#define fp $30 /* frame pointer */
++#define s8 $30 /* callee saved */
++#define ra $31 /* return address */
++
++#endif /* _MIPS_SIM == _MIPS_SIM_ABI64 || _MIPS_SIM == _MIPS_SIM_NABI32 */
++
++#endif /* _ASM_REGDEF_H */
diff --git a/package/boot/rbcfg/.svn/entries b/package/boot/rbcfg/.svn/entries
new file mode 100644
index 0000000..a16907b
--- /dev/null
+++ b/package/boot/rbcfg/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/rbcfg
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-17T21:53:23.143554Z
+33824
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+src
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+54ebd1734c602f5d5c63ed6b37cd830c
+2012-10-17T21:53:23.143554Z
+33824
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1009
+
diff --git a/package/boot/rbcfg/.svn/prop-base/Makefile.svn-base b/package/boot/rbcfg/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/boot/rbcfg/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/boot/rbcfg/.svn/text-base/Makefile.svn-base b/package/boot/rbcfg/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..51fefd5
--- /dev/null
+++ b/package/boot/rbcfg/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,49 @@
+#
+# Copyright (C) 2010 Gabor Juhos <juhosg@openwrt.org>
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=rbcfg
+PKG_RELEASE:=1
+
+PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/rbcfg
+ SECTION:=utils
+ CATEGORY:=Utilities
+ TITLE:=RouterBOOT configuration tool
+ DEPENDS:=@TARGET_ar71xx
+endef
+
+define Package/rbcfg/description
+ This package contains an utility to manipulate RouterBOOT configuration on the
+ MikroTIK RB-4XX devices.
+endef
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ CC="$(TARGET_CC)" \
+ CFLAGS="$(TARGET_CFLAGS) -Wall" \
+ LDFLAGS="$(TARGET_LDFLAGS)"
+endef
+
+define Package/rbcfg/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/rbcfg $(1)/usr/sbin/
+endef
+
+$(eval $(call BuildPackage,rbcfg))
diff --git a/package/boot/rbcfg/Makefile b/package/boot/rbcfg/Makefile
new file mode 100644
index 0000000..51fefd5
--- /dev/null
+++ b/package/boot/rbcfg/Makefile
@@ -0,0 +1,49 @@
+#
+# Copyright (C) 2010 Gabor Juhos <juhosg@openwrt.org>
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=rbcfg
+PKG_RELEASE:=1
+
+PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/rbcfg
+ SECTION:=utils
+ CATEGORY:=Utilities
+ TITLE:=RouterBOOT configuration tool
+ DEPENDS:=@TARGET_ar71xx
+endef
+
+define Package/rbcfg/description
+ This package contains an utility to manipulate RouterBOOT configuration on the
+ MikroTIK RB-4XX devices.
+endef
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ CC="$(TARGET_CC)" \
+ CFLAGS="$(TARGET_CFLAGS) -Wall" \
+ LDFLAGS="$(TARGET_LDFLAGS)"
+endef
+
+define Package/rbcfg/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/rbcfg $(1)/usr/sbin/
+endef
+
+$(eval $(call BuildPackage,rbcfg))
diff --git a/package/boot/rbcfg/src/.svn/entries b/package/boot/rbcfg/src/.svn/entries
new file mode 100644
index 0000000..2f111cd
--- /dev/null
+++ b/package/boot/rbcfg/src/.svn/entries
@@ -0,0 +1,198 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/rbcfg/src
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-17T21:53:23.143554Z
+33824
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+cyg_crc.h
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+ba9d1cf06e7d26d19e67fff283506d18
+2012-10-17T21:53:23.143554Z
+33824
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3372
+
+cyg_crc32.c
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+2005e143bb82ddc198ca4e919a800aee
+2012-10-17T21:53:23.143554Z
+33824
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+7963
+
+main.c
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+7acc0c5073dc83633e151d35618baa2f
+2012-10-17T21:53:23.143554Z
+33824
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+15073
+
+rbcfg.h
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+c2945a0eae01cc2749251ab0e3c959b2
+2012-10-17T21:53:23.143554Z
+33824
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1759
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+0496a56c341577ddcd18f510c963447f
+2012-10-17T21:53:23.143554Z
+33824
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+163
+
diff --git a/package/boot/rbcfg/src/.svn/prop-base/Makefile.svn-base b/package/boot/rbcfg/src/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/boot/rbcfg/src/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/boot/rbcfg/src/.svn/prop-base/cyg_crc.h.svn-base b/package/boot/rbcfg/src/.svn/prop-base/cyg_crc.h.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/boot/rbcfg/src/.svn/prop-base/cyg_crc.h.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/boot/rbcfg/src/.svn/prop-base/cyg_crc32.c.svn-base b/package/boot/rbcfg/src/.svn/prop-base/cyg_crc32.c.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/boot/rbcfg/src/.svn/prop-base/cyg_crc32.c.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/boot/rbcfg/src/.svn/prop-base/main.c.svn-base b/package/boot/rbcfg/src/.svn/prop-base/main.c.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/boot/rbcfg/src/.svn/prop-base/main.c.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/boot/rbcfg/src/.svn/prop-base/rbcfg.h.svn-base b/package/boot/rbcfg/src/.svn/prop-base/rbcfg.h.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/boot/rbcfg/src/.svn/prop-base/rbcfg.h.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/boot/rbcfg/src/.svn/text-base/Makefile.svn-base b/package/boot/rbcfg/src/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..62c74b2
--- /dev/null
+++ b/package/boot/rbcfg/src/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,14 @@
+CC = gcc
+CFLAGS = -Wall
+OBJS = main.o cyg_crc32.o
+
+all: rbcfg
+
+%.o: %.c
+ $(CC) $(CFLAGS) -c -o $@ $<
+
+rbcfg: $(OBJS)
+ $(CC) -o $@ $(OBJS)
+
+clean:
+ rm -f rbcfg *.o
diff --git a/package/boot/rbcfg/src/.svn/text-base/cyg_crc.h.svn-base b/package/boot/rbcfg/src/.svn/text-base/cyg_crc.h.svn-base
new file mode 100644
index 0000000..7b59803
--- /dev/null
+++ b/package/boot/rbcfg/src/.svn/text-base/cyg_crc.h.svn-base
@@ -0,0 +1,109 @@
+//==========================================================================
+//
+// crc.h
+//
+// Interface for the CRC algorithms.
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 2002 Andrew Lunn
+//
+// eCos 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.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): Andrew Lunn
+// Contributors: Andrew Lunn
+// Date: 2002-08-06
+// Purpose:
+// Description:
+//
+// This code is part of eCos (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#ifndef _SERVICES_CRC_CRC_H_
+#define _SERVICES_CRC_CRC_H_
+
+#if 0
+#include <cyg/infra/cyg_type.h>
+#else
+#include <stdint.h>
+typedef uint32_t cyg_uint32;
+typedef uint16_t cyg_uint16;
+#endif
+
+#ifndef __externC
+# ifdef __cplusplus
+# define __externC extern "C"
+# else
+# define __externC extern
+# endif
+#endif
+
+// Compute a CRC, using the POSIX 1003 definition
+
+__externC cyg_uint32
+cyg_posix_crc32(unsigned char *s, int len);
+
+// Gary S. Brown's 32 bit CRC
+
+__externC cyg_uint32
+cyg_crc32(unsigned char *s, int len);
+
+// Gary S. Brown's 32 bit CRC, but accumulate the result from a
+// previous CRC calculation
+
+__externC cyg_uint32
+cyg_crc32_accumulate(cyg_uint32 crc, unsigned char *s, int len);
+
+// Ethernet FCS Algorithm
+
+__externC cyg_uint32
+cyg_ether_crc32(unsigned char *s, int len);
+
+// Ethernet FCS algorithm, but accumulate the result from a previous
+// CRC calculation.
+
+__externC cyg_uint32
+cyg_ether_crc32_accumulate(cyg_uint32 crc, unsigned char *s, int len);
+
+// 16 bit CRC with polynomial x^16+x^12+x^5+1
+
+__externC cyg_uint16
+cyg_crc16(unsigned char *s, int len);
+
+#endif // _SERVICES_CRC_CRC_H_
+
+
+
diff --git a/package/boot/rbcfg/src/.svn/text-base/cyg_crc32.c.svn-base b/package/boot/rbcfg/src/.svn/text-base/cyg_crc32.c.svn-base
new file mode 100644
index 0000000..9462598
--- /dev/null
+++ b/package/boot/rbcfg/src/.svn/text-base/cyg_crc32.c.svn-base
@@ -0,0 +1,172 @@
+//==========================================================================
+//
+// crc32.c
+//
+// Gary S. Brown's 32 bit CRC
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+// Copyright (C) 2002 Gary Thomas
+//
+// eCos 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.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): gthomas
+// Contributors: gthomas,asl
+// Date: 2001-01-31
+// Purpose:
+// Description:
+//
+// This code is part of eCos (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#if 0
+#include <cyg/crc/crc.h>
+#else
+#include "cyg_crc.h"
+#endif
+
+ /* ====================================================================== */
+ /* COPYRIGHT (C) 1986 Gary S. Brown. You may use this program, or */
+ /* code or tables extracted from it, as desired without restriction. */
+ /* */
+ /* First, the polynomial itself and its table of feedback terms. The */
+ /* polynomial is */
+ /* X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0 */
+ /* */
+ /* ====================================================================== */
+
+static const cyg_uint32 crc32_tab[] = {
+ 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
+ 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
+ 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
+ 0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL,
+ 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L,
+ 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L,
+ 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L,
+ 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,
+ 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L,
+ 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL,
+ 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L,
+ 0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L,
+ 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L,
+ 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL,
+ 0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL,
+ 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,
+ 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL,
+ 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L,
+ 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L,
+ 0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L,
+ 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL,
+ 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L,
+ 0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L,
+ 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,
+ 0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L,
+ 0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L,
+ 0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L,
+ 0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L,
+ 0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L,
+ 0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL,
+ 0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL,
+ 0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,
+ 0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L,
+ 0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL,
+ 0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL,
+ 0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L,
+ 0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL,
+ 0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L,
+ 0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL,
+ 0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,
+ 0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL,
+ 0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L,
+ 0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L,
+ 0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL,
+ 0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L,
+ 0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L,
+ 0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L,
+ 0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,
+ 0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L,
+ 0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L,
+ 0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL,
+ 0x2d02ef8dL
+ };
+
+/* This is the standard Gary S. Brown's 32 bit CRC algorithm, but
+ accumulate the CRC into the result of a previous CRC. */
+cyg_uint32
+cyg_crc32_accumulate(cyg_uint32 crc32val, unsigned char *s, int len)
+{
+ int i;
+
+ for (i = 0; i < len; i++) {
+ crc32val = crc32_tab[(crc32val ^ s[i]) & 0xff] ^ (crc32val >> 8);
+ }
+ return crc32val;
+}
+
+/* This is the standard Gary S. Brown's 32 bit CRC algorithm */
+cyg_uint32
+cyg_crc32(unsigned char *s, int len)
+{
+ return (cyg_crc32_accumulate(0,s,len));
+}
+
+/* Return a 32-bit CRC of the contents of the buffer accumulating the
+ result from a previous CRC calculation. This uses the Ethernet FCS
+ algorithm.*/
+cyg_uint32
+cyg_ether_crc32_accumulate(cyg_uint32 crc32val, unsigned char *s, int len)
+{
+ int i;
+
+ if (s == 0) return 0L;
+
+ crc32val = crc32val ^ 0xffffffff;
+ for (i = 0; i < len; i++) {
+ crc32val = crc32_tab[(crc32val ^ s[i]) & 0xff] ^ (crc32val >> 8);
+ }
+ return crc32val ^ 0xffffffff;
+}
+
+/* Return a 32-bit CRC of the contents of the buffer, using the
+ Ethernet FCS algorithm. */
+cyg_uint32
+cyg_ether_crc32(unsigned char *s, int len)
+{
+ return cyg_ether_crc32_accumulate(0,s,len);
+}
+
+
diff --git a/package/boot/rbcfg/src/.svn/text-base/main.c.svn-base b/package/boot/rbcfg/src/.svn/text-base/main.c.svn-base
new file mode 100644
index 0000000..5614a6c
--- /dev/null
+++ b/package/boot/rbcfg/src/.svn/text-base/main.c.svn-base
@@ -0,0 +1,791 @@
+/*
+ * RouterBOOT configuration utility
+ *
+ * Copyright (C) 2010 Gabor Juhos <juhosg@openwrt.org>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <string.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <linux/limits.h>
+
+#include "rbcfg.h"
+#include "cyg_crc.h"
+
+#define RBCFG_TMP_FILE "/tmp/.rbcfg"
+#define RBCFG_MTD_NAME "soft_config"
+
+#define RB_ERR_NOTFOUND 1
+#define RB_ERR_INVALID 2
+#define RB_ERR_NOMEM 3
+#define RB_ERR_IO 4
+
+#define ARRAY_SIZE(_a) (sizeof((_a)) / sizeof((_a)[0]))
+
+struct rbcfg_ctx {
+ char *mtd_device;
+ char *tmp_file;
+ char *buf;
+ unsigned buflen;
+};
+
+struct rbcfg_value {
+ const char *name;
+ const char *desc;
+ union {
+ uint32_t u32;
+ const char *raw;
+ } val;
+};
+
+#define RBCFG_ENV_TYPE_U32 0
+
+struct rbcfg_env {
+ const char *name;
+ int type;
+ uint16_t id;
+ const struct rbcfg_value *values;
+ int num_values;
+};
+
+#define CMD_FLAG_USES_CFG 0x01
+
+struct rbcfg_command {
+ const char *command;
+ const char *usage;
+ int flags;
+ int (*exec)(int argc, const char *argv[]);
+};
+
+static void usage(void);
+
+/* Globals */
+
+static struct rbcfg_ctx *rbcfg_ctx;
+static char *rbcfg_name;
+
+#define CFG_U32(_name, _desc, _val) { \
+ .name = (_name), \
+ .desc = (_desc), \
+ .val.u32 = (_val), \
+}
+
+static const struct rbcfg_value rbcfg_boot_delay[] = {
+ CFG_U32("1", "1 second", RB_BOOT_DELAY_1SEC),
+ CFG_U32("2", "2 seconds", RB_BOOT_DELAY_2SEC),
+ CFG_U32("3", "3 seconds", RB_BOOT_DELAY_3SEC),
+ CFG_U32("4", "4 seconds", RB_BOOT_DELAY_4SEC),
+ CFG_U32("5", "5 seconds", RB_BOOT_DELAY_5SEC),
+ CFG_U32("6", "6 seconds", RB_BOOT_DELAY_6SEC),
+ CFG_U32("7", "7 seconds", RB_BOOT_DELAY_7SEC),
+ CFG_U32("8", "8 seconds", RB_BOOT_DELAY_8SEC),
+ CFG_U32("9", "9 seconds", RB_BOOT_DELAY_9SEC),
+};
+
+static const struct rbcfg_value rbcfg_boot_device[] = {
+ CFG_U32("eth", "boot over Ethernet",
+ RB_BOOT_DEVICE_ETHER),
+ CFG_U32("nandeth", "boot from NAND, if fail then Ethernet",
+ RB_BOOT_DEVICE_NANDETH),
+ CFG_U32("ethnand", "boot Ethernet once, then NAND",
+ RB_BOOT_DEVICE_ETHONCE),
+ CFG_U32("nand", "boot from NAND only",
+ RB_BOOT_DEVICE_NANDONLY),
+};
+
+static const struct rbcfg_value rbcfg_boot_key[] = {
+ CFG_U32("any", "any key", RB_BOOT_KEY_ANY),
+ CFG_U32("del", "<Delete> key only", RB_BOOT_KEY_DEL),
+};
+
+static const struct rbcfg_value rbcfg_boot_protocol[] = {
+ CFG_U32("bootp", "BOOTP protocol", RB_BOOT_PROTOCOL_BOOTP),
+ CFG_U32("dhcp", "DHCP protocol", RB_BOOT_PROTOCOL_DHCP),
+};
+
+static const struct rbcfg_value rbcfg_uart_speed[] = {
+ CFG_U32("115200", "", RB_UART_SPEED_115200),
+ CFG_U32("57600", "", RB_UART_SPEED_57600),
+ CFG_U32("38400", "", RB_UART_SPEED_38400),
+ CFG_U32("19200", "", RB_UART_SPEED_19200),
+ CFG_U32("9600", "", RB_UART_SPEED_9600),
+ CFG_U32("4800", "", RB_UART_SPEED_4800),
+ CFG_U32("2400", "", RB_UART_SPEED_2400),
+ CFG_U32("1200", "", RB_UART_SPEED_1200),
+ CFG_U32("off", "disable console output", RB_UART_SPEED_OFF),
+};
+
+static const struct rbcfg_value rbcfg_cpu_mode[] = {
+ CFG_U32("powersave", "power save", RB_CPU_MODE_POWERSAVE),
+ CFG_U32("regular", "regular (better for -0c environment)",
+ RB_CPU_MODE_REGULAR),
+};
+
+static const struct rbcfg_value rbcfg_booter[] = {
+ CFG_U32("regular", "load regular booter", RB_BOOTER_REGULAR),
+ CFG_U32("backup", "force backup-booter loading", RB_BOOTER_BACKUP),
+};
+
+static const struct rbcfg_env rbcfg_envs[] = {
+ {
+ .name = "boot_delay",
+ .id = RB_ID_BOOT_DELAY,
+ .type = RBCFG_ENV_TYPE_U32,
+ .values = rbcfg_boot_delay,
+ .num_values = ARRAY_SIZE(rbcfg_boot_delay),
+ }, {
+ .name = "boot_device",
+ .id = RB_ID_BOOT_DEVICE,
+ .type = RBCFG_ENV_TYPE_U32,
+ .values = rbcfg_boot_device,
+ .num_values = ARRAY_SIZE(rbcfg_boot_device),
+ }, {
+ .name = "boot_key",
+ .id = RB_ID_BOOT_KEY,
+ .type = RBCFG_ENV_TYPE_U32,
+ .values = rbcfg_boot_key,
+ .num_values = ARRAY_SIZE(rbcfg_boot_key),
+ }, {
+ .name = "boot_protocol",
+ .id = RB_ID_BOOT_PROTOCOL,
+ .type = RBCFG_ENV_TYPE_U32,
+ .values = rbcfg_boot_protocol,
+ .num_values = ARRAY_SIZE(rbcfg_boot_protocol),
+ }, {
+ .name = "booter",
+ .id = RB_ID_BOOTER,
+ .type = RBCFG_ENV_TYPE_U32,
+ .values = rbcfg_booter,
+ .num_values = ARRAY_SIZE(rbcfg_booter),
+ }, {
+ .name = "cpu_mode",
+ .id = RB_ID_CPU_MODE,
+ .type = RBCFG_ENV_TYPE_U32,
+ .values = rbcfg_cpu_mode,
+ .num_values = ARRAY_SIZE(rbcfg_cpu_mode),
+ }, {
+ .name = "uart_speed",
+ .id = RB_ID_UART_SPEED,
+ .type = RBCFG_ENV_TYPE_U32,
+ .values = rbcfg_uart_speed,
+ .num_values = ARRAY_SIZE(rbcfg_uart_speed),
+ }
+};
+
+static inline uint16_t
+get_u16(const void *buf)
+{
+ const uint8_t *p = buf;
+
+ return ((uint16_t) p[1] + ((uint16_t) p[0] << 8));
+}
+
+static inline uint32_t
+get_u32(const void *buf)
+{
+ const uint8_t *p = buf;
+
+ return ((uint32_t) p[3] + ((uint32_t) p[2] << 8) +
+ ((uint32_t) p[1] << 16) + ((uint32_t) p[0] << 24));
+}
+
+static inline void
+put_u32(void *buf, uint32_t val)
+{
+ uint8_t *p = buf;
+
+ p[3] = val & 0xff;
+ p[2] = (val >> 8) & 0xff;
+ p[1] = (val >> 16) & 0xff;
+ p[0] = (val >> 24) & 0xff;
+}
+
+static int
+rbcfg_find_tag(struct rbcfg_ctx *ctx, uint16_t tag_id, uint16_t *tag_len,
+ void **tag_data)
+{
+ uint16_t id;
+ uint16_t len;
+ char *buf = ctx->buf;
+ unsigned int buflen = ctx->buflen;
+ int ret = RB_ERR_NOTFOUND;
+
+ /* skip magic and CRC value */
+ buf += 8;
+ buflen -= 8;
+
+ while (buflen > 2) {
+ len = get_u16(buf);
+ buf += 2;
+ buflen -= 2;
+
+ if (buflen < 2)
+ break;
+
+ id = get_u16(buf);
+ buf += 2;
+ buflen -= 2;
+
+ if (id == RB_ID_TERMINATOR)
+ break;
+
+ if (buflen < len)
+ break;
+
+ if (id == tag_id) {
+ *tag_len = len;
+ *tag_data = buf;
+ ret = 0;
+ break;
+ }
+
+ buf += len;
+ buflen -= len;
+ }
+
+ if (ret)
+ fprintf(stderr, "no tag found with id=%u\n", tag_id);
+
+ return ret;
+}
+
+static int
+rbcfg_get_u32(struct rbcfg_ctx *ctx, uint16_t id, uint32_t *val)
+{
+ void *tag_data;
+ uint16_t tag_len;
+ int err;
+
+ err = rbcfg_find_tag(ctx, id, &tag_len, &tag_data);
+ if (err)
+ return err;
+
+ *val = get_u32(tag_data);
+ return 0;
+}
+
+static int
+rbcfg_set_u32(struct rbcfg_ctx *ctx, uint16_t id, uint32_t val)
+{
+ void *tag_data;
+ uint16_t tag_len;
+ int err;
+
+ err = rbcfg_find_tag(ctx, id, &tag_len, &tag_data);
+ if (err)
+ return err;
+
+ put_u32(tag_data, val);
+ return 0;
+}
+
+char *rbcfg_find_mtd(const char *name, int *erase_size)
+{
+ FILE *f;
+ int mtd_num;
+ char dev[PATH_MAX];
+ char *ret = NULL;
+ struct stat s;
+ int err;
+
+ f = fopen("/proc/mtd", "r");
+ if (!f)
+ return NULL;
+
+ while (1) {
+ char *p;
+ p = fgets(dev, sizeof(dev), f);
+ if (!p)
+ break;
+
+ if (!strstr(dev, name))
+ continue;
+
+ err = sscanf(dev, "mtd%d: %08x", &mtd_num, erase_size);
+ if (err != 2)
+ break;
+
+ sprintf(dev, "/dev/mtdblock%d", mtd_num);
+ err = stat(dev, &s);
+ if (err < 0)
+ break;
+
+ if ((s.st_mode & S_IFBLK) == 0)
+ break;
+
+ ret = malloc(strlen(dev) + 1);
+ if (ret == NULL)
+ break;
+
+ strncpy(ret, dev, strlen(dev) + 1);
+ break;
+ }
+
+ fclose(f);
+ return ret;
+}
+
+static int
+rbcfg_check_tmp(struct rbcfg_ctx *ctx)
+{
+ struct stat s;
+ int err;
+
+ err = stat(ctx->tmp_file, &s);
+ if (err < 0)
+ return 0;
+
+ if ((s.st_mode & S_IFREG) == 0)
+ return 0;
+
+ if (s.st_size != ctx->buflen)
+ return 0;
+
+ return 1;
+}
+
+static int
+rbcfg_load(struct rbcfg_ctx *ctx)
+{
+ uint32_t magic;
+ uint32_t crc_orig, crc;
+ char *name;
+ int tmp;
+ int fd;
+ int err;
+
+ tmp = rbcfg_check_tmp(ctx);
+ name = (tmp) ? ctx->tmp_file : ctx->mtd_device;
+
+ fd = open(name, O_RDONLY);
+ if (fd < 0) {
+ fprintf(stderr, "unable to open %s\n", name);
+ err = RB_ERR_IO;
+ goto err;
+ }
+
+ err = read(fd, ctx->buf, ctx->buflen);
+ if (err != ctx->buflen) {
+ fprintf(stderr, "unable to read from %s\n", name);
+ err = RB_ERR_IO;
+ goto err_close;
+ }
+
+ magic = get_u32(ctx->buf);
+ if (magic != RB_MAGIC_SOFT) {
+ fprintf(stderr, "invalid configuration\n");
+ err = RB_ERR_INVALID;
+ goto err_close;
+ }
+
+ crc_orig = get_u32(ctx->buf + 4);
+ put_u32(ctx->buf + 4, 0);
+ crc = cyg_ether_crc32((unsigned char *) ctx->buf, ctx->buflen);
+ if (crc != crc_orig) {
+ fprintf(stderr, "configuration has CRC error\n");
+ err = RB_ERR_INVALID;
+ goto err_close;
+ }
+
+ err = 0;
+
+ err_close:
+ close(fd);
+ err:
+ return err;
+}
+
+static int
+rbcfg_open()
+{
+ char *mtd_device;
+ struct rbcfg_ctx *ctx;
+ int buflen;
+ int err;
+
+ mtd_device = rbcfg_find_mtd(RBCFG_MTD_NAME, &buflen);
+ if (!mtd_device) {
+ fprintf(stderr, "unable to find configuration\n");
+ return RB_ERR_NOTFOUND;
+ }
+
+ ctx = malloc(sizeof(struct rbcfg_ctx) + buflen);
+ if (ctx == NULL) {
+ err = RB_ERR_NOMEM;
+ goto err_free_mtd;
+ }
+
+ ctx->mtd_device = mtd_device;
+ ctx->tmp_file = RBCFG_TMP_FILE;
+ ctx->buflen = buflen;
+ ctx->buf = (char *) &ctx[1];
+
+ err = rbcfg_load(ctx);
+ if (err)
+ goto err_free_ctx;
+
+ rbcfg_ctx = ctx;
+ return 0;
+
+ err_free_ctx:
+ free(ctx);
+ err_free_mtd:
+ free(mtd_device);
+ return err;
+}
+
+static int
+rbcfg_update(int tmp)
+{
+ struct rbcfg_ctx *ctx = rbcfg_ctx;
+ char *name;
+ uint32_t crc;
+ int fd;
+ int err;
+
+ put_u32(ctx->buf, RB_MAGIC_SOFT);
+ put_u32(ctx->buf + 4, 0);
+ crc = cyg_ether_crc32((unsigned char *) ctx->buf, ctx->buflen);
+ put_u32(ctx->buf + 4, crc);
+
+ name = (tmp) ? ctx->tmp_file : ctx->mtd_device;
+ fd = open(name, O_WRONLY | O_CREAT);
+ if (fd < 0) {
+ fprintf(stderr, "unable to open %s for writing\n", name);
+ err = RB_ERR_IO;
+ goto out;
+ }
+
+ err = write(fd, ctx->buf, ctx->buflen);
+ if (err != ctx->buflen) {
+ err = RB_ERR_IO;
+ goto out_close;
+ }
+
+ fsync(fd);
+ err = 0;
+
+ out_close:
+ close(fd);
+ out:
+ return err;
+}
+
+static void
+rbcfg_close(void)
+{
+ struct rbcfg_ctx *ctx;
+
+ ctx = rbcfg_ctx;
+ free(ctx->mtd_device);
+ free(ctx);
+}
+
+static const struct rbcfg_value *
+rbcfg_env_find(const struct rbcfg_env *env, const char *name)
+{
+ unsigned i;
+
+ for (i = 0; i < env->num_values; i++) {
+ const struct rbcfg_value *v = &env->values[i];
+
+ if (strcmp(v->name, name) == 0)
+ return v;
+ }
+
+ return NULL;
+}
+
+static const struct rbcfg_value *
+rbcfg_env_find_u32(const struct rbcfg_env *env, uint32_t val)
+{
+ unsigned i;
+
+ for (i = 0; i < env->num_values; i++) {
+ const struct rbcfg_value *v = &env->values[i];
+
+ if (v->val.u32 == val)
+ return v;
+ }
+
+ return NULL;
+}
+
+static const char *
+rbcfg_env_get_u32(const struct rbcfg_env *env)
+{
+ const struct rbcfg_value *v;
+ uint32_t val;
+ int err;
+
+ err = rbcfg_get_u32(rbcfg_ctx, env->id, &val);
+ if (err)
+ return NULL;
+
+ v = rbcfg_env_find_u32(env, val);
+ if (v == NULL) {
+ fprintf(stderr, "unknown value %08x found for %s\n",
+ val, env->name);
+ return NULL;
+ }
+
+ return v->name;
+}
+
+static int
+rbcfg_env_set_u32(const struct rbcfg_env *env, const char *data)
+{
+ const struct rbcfg_value *v;
+ int err;
+
+ v = rbcfg_env_find(env, data);
+ if (v == NULL) {
+ fprintf(stderr, "invalid value '%s'\n", data);
+ return RB_ERR_INVALID;
+ }
+
+ err = rbcfg_set_u32(rbcfg_ctx, env->id, v->val.u32);
+ return err;
+}
+
+static const char *
+rbcfg_env_get(const struct rbcfg_env *env)
+{
+ const char *ret = NULL;
+
+ switch (env->type) {
+ case RBCFG_ENV_TYPE_U32:
+ ret = rbcfg_env_get_u32(env);
+ break;
+ }
+
+ return ret;
+}
+
+static int
+rbcfg_env_set(const struct rbcfg_env *env, const char *data)
+{
+ int ret = 0;
+
+ switch (env->type) {
+ case RBCFG_ENV_TYPE_U32:
+ ret = rbcfg_env_set_u32(env, data);
+ break;
+ }
+
+ return ret;
+}
+
+static int
+rbcfg_cmd_apply(int argc, const char *argv[])
+{
+ return rbcfg_update(0);
+}
+
+static int
+rbcfg_cmd_help(int argc, const char *argv[])
+{
+ usage();
+ return 0;
+}
+
+static int
+rbcfg_cmd_get(int argc, const char *argv[])
+{
+ int err = RB_ERR_NOTFOUND;
+ int i;
+
+ if (argc != 1) {
+ usage();
+ return RB_ERR_INVALID;
+ }
+
+ for (i = 0; i < ARRAY_SIZE(rbcfg_envs); i++) {
+ const struct rbcfg_env *env = &rbcfg_envs[i];
+ const char *value;
+
+ if (strcmp(env->name, argv[0]))
+ continue;
+
+ value = rbcfg_env_get(env);
+ if (value) {
+ fprintf(stdout, "%s\n", value);
+ err = 0;
+ }
+ break;
+ }
+
+ return err;
+}
+
+static int
+rbcfg_cmd_set(int argc, const char *argv[])
+{
+ int err = RB_ERR_INVALID;
+ int i;
+
+ if (argc != 2) {
+ /* not enough parameters */
+ usage();
+ return RB_ERR_INVALID;
+ }
+
+ for (i = 0; i < ARRAY_SIZE(rbcfg_envs); i++) {
+ const struct rbcfg_env *env = &rbcfg_envs[i];
+
+ if (strcmp(env->name, argv[0]))
+ continue;
+
+ err = rbcfg_env_set(env, argv[1]);
+ if (err == 0)
+ err = rbcfg_update(1);
+ break;
+ }
+
+ return err;
+}
+
+static int
+rbcfg_cmd_show(int argc, const char *argv[])
+{
+ int i;
+
+ if (argc != 0) {
+ usage();
+ return RB_ERR_INVALID;
+ }
+
+ for (i = 0; i < ARRAY_SIZE(rbcfg_envs); i++) {
+ const struct rbcfg_env *env = &rbcfg_envs[i];
+ const char *value;
+
+ value = rbcfg_env_get(env);
+ if (value)
+ fprintf(stdout, "%s=%s\n", env->name, value);
+ }
+
+ return 0;
+}
+
+static const struct rbcfg_command rbcfg_commands[] = {
+ {
+ .command = "apply",
+ .usage = "apply\n"
+ "\t- write configuration to the mtd device",
+ .flags = CMD_FLAG_USES_CFG,
+ .exec = rbcfg_cmd_apply,
+ }, {
+ .command = "help",
+ .usage = "help\n"
+ "\t- show this screen",
+ .exec = rbcfg_cmd_help,
+ }, {
+ .command = "get",
+ .usage = "get <name>\n"
+ "\t- get value of the configuration option <name>",
+ .flags = CMD_FLAG_USES_CFG,
+ .exec = rbcfg_cmd_get,
+ }, {
+ .command = "set",
+ .usage = "set <name> <value>\n"
+ "\t- set value of the configuration option <name> to <value>",
+ .flags = CMD_FLAG_USES_CFG,
+ .exec = rbcfg_cmd_set,
+ }, {
+ .command = "show",
+ .usage = "show\n"
+ "\t- show value of all configuration options",
+ .flags = CMD_FLAG_USES_CFG,
+ .exec = rbcfg_cmd_show,
+ }
+};
+
+static void
+usage(void)
+{
+ char buf[255];
+ int len;
+ int i;
+
+ fprintf(stderr, "Usage: %s <command>\n", rbcfg_name);
+
+ fprintf(stderr, "\nCommands:\n");
+ for (i = 0; i < ARRAY_SIZE(rbcfg_commands); i++) {
+ const struct rbcfg_command *cmd;
+ cmd = &rbcfg_commands[i];
+
+ len = snprintf(buf, sizeof(buf), cmd->usage);
+ buf[len] = '\0';
+ fprintf(stderr, "%s\n", buf);
+ }
+
+ fprintf(stderr, "\nConfiguration options:\n");
+ for (i = 0; i < ARRAY_SIZE(rbcfg_envs); i++) {
+ const struct rbcfg_env *env;
+ int j;
+
+ env = &rbcfg_envs[i];
+ fprintf(stderr, "\n%s:\n", env->name);
+ for (j = 0; j < env->num_values; j++) {
+ const struct rbcfg_value *v = &env->values[j];
+ fprintf(stderr, "\t%-12s %s\n", v->name, v->desc);
+ }
+ }
+ fprintf(stderr, "\n");
+}
+
+int main(int argc, const char *argv[])
+{
+ const struct rbcfg_command *cmd = NULL;
+ int ret;
+ int i;
+
+ rbcfg_name = (char *) argv[0];
+
+ if (argc < 2) {
+ usage();
+ return EXIT_FAILURE;
+ }
+
+ for (i = 0; i < ARRAY_SIZE(rbcfg_commands); i++) {
+ if (strcmp(rbcfg_commands[i].command, argv[1]) == 0) {
+ cmd = &rbcfg_commands[i];
+ break;
+ }
+ }
+
+ if (cmd == NULL) {
+ fprintf(stderr, "unknown command '%s'\n", argv[1]);
+ usage();
+ return EXIT_FAILURE;
+ }
+
+ argc -= 2;
+ argv += 2;
+
+ if (cmd->flags & CMD_FLAG_USES_CFG) {
+ ret = rbcfg_open();
+ if (ret)
+ return EXIT_FAILURE;
+ }
+
+ ret = cmd->exec(argc, argv);
+
+ if (cmd->flags & CMD_FLAG_USES_CFG)
+ rbcfg_close();
+
+ if (ret)
+ return EXIT_FAILURE;
+
+ return EXIT_SUCCESS;
+}
diff --git a/package/boot/rbcfg/src/.svn/text-base/rbcfg.h.svn-base b/package/boot/rbcfg/src/.svn/text-base/rbcfg.h.svn-base
new file mode 100644
index 0000000..899161a
--- /dev/null
+++ b/package/boot/rbcfg/src/.svn/text-base/rbcfg.h.svn-base
@@ -0,0 +1,75 @@
+/*
+ * Mikrotik's RouterBOOT configuration defines
+ *
+ * Copyright (C) 2010 Gabor Juhos <juhosg@openwrt.org>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ *
+ */
+
+#ifndef _RBCFG_H
+#define _RBCFG_H
+
+/*
+ * Magic numbers
+ */
+#define RB_MAGIC_SOFT 0x74666f53 /* 'Soft' */
+
+/*
+ * ID values for Software settings
+ */
+#define RB_ID_TERMINATOR 0
+#define RB_ID_UART_SPEED 1
+#define RB_ID_BOOT_DELAY 2
+#define RB_ID_BOOT_DEVICE 3
+#define RB_ID_BOOT_KEY 4
+#define RB_ID_CPU_MODE 5
+#define RB_ID_FW_VERSION 6
+#define RB_ID_SOFT_07 7
+#define RB_ID_SOFT_08 8
+#define RB_ID_BOOT_PROTOCOL 9
+#define RB_ID_SOFT_10 10
+#define RB_ID_SOFT_11 11
+#define RB_ID_BOOTER 13
+
+#define RB_UART_SPEED_115200 0
+#define RB_UART_SPEED_57600 1
+#define RB_UART_SPEED_38400 2
+#define RB_UART_SPEED_19200 3
+#define RB_UART_SPEED_9600 4
+#define RB_UART_SPEED_4800 5
+#define RB_UART_SPEED_2400 6
+#define RB_UART_SPEED_1200 7
+#define RB_UART_SPEED_OFF 8
+
+#define RB_BOOT_DELAY_1SEC 1
+#define RB_BOOT_DELAY_2SEC 2
+#define RB_BOOT_DELAY_3SEC 3
+#define RB_BOOT_DELAY_4SEC 4
+#define RB_BOOT_DELAY_5SEC 5
+#define RB_BOOT_DELAY_6SEC 6
+#define RB_BOOT_DELAY_7SEC 7
+#define RB_BOOT_DELAY_8SEC 8
+#define RB_BOOT_DELAY_9SEC 9
+
+#define RB_BOOT_DEVICE_ETHER 0
+#define RB_BOOT_DEVICE_NANDETH 1
+#define RB_BOOT_DEVICE_CFCARD 2
+#define RB_BOOT_DEVICE_ETHONCE 3
+#define RB_BOOT_DEVICE_NANDONLY 5
+
+#define RB_BOOT_KEY_ANY 0
+#define RB_BOOT_KEY_DEL 1
+
+#define RB_CPU_MODE_POWERSAVE 0
+#define RB_CPU_MODE_REGULAR 1
+
+#define RB_BOOT_PROTOCOL_BOOTP 0
+#define RB_BOOT_PROTOCOL_DHCP 1
+
+#define RB_BOOTER_REGULAR 0
+#define RB_BOOTER_BACKUP 1
+
+#endif /* _RBCFG_H */
diff --git a/package/boot/rbcfg/src/Makefile b/package/boot/rbcfg/src/Makefile
new file mode 100644
index 0000000..62c74b2
--- /dev/null
+++ b/package/boot/rbcfg/src/Makefile
@@ -0,0 +1,14 @@
+CC = gcc
+CFLAGS = -Wall
+OBJS = main.o cyg_crc32.o
+
+all: rbcfg
+
+%.o: %.c
+ $(CC) $(CFLAGS) -c -o $@ $<
+
+rbcfg: $(OBJS)
+ $(CC) -o $@ $(OBJS)
+
+clean:
+ rm -f rbcfg *.o
diff --git a/package/boot/rbcfg/src/cyg_crc.h b/package/boot/rbcfg/src/cyg_crc.h
new file mode 100644
index 0000000..7b59803
--- /dev/null
+++ b/package/boot/rbcfg/src/cyg_crc.h
@@ -0,0 +1,109 @@
+//==========================================================================
+//
+// crc.h
+//
+// Interface for the CRC algorithms.
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 2002 Andrew Lunn
+//
+// eCos 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.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): Andrew Lunn
+// Contributors: Andrew Lunn
+// Date: 2002-08-06
+// Purpose:
+// Description:
+//
+// This code is part of eCos (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#ifndef _SERVICES_CRC_CRC_H_
+#define _SERVICES_CRC_CRC_H_
+
+#if 0
+#include <cyg/infra/cyg_type.h>
+#else
+#include <stdint.h>
+typedef uint32_t cyg_uint32;
+typedef uint16_t cyg_uint16;
+#endif
+
+#ifndef __externC
+# ifdef __cplusplus
+# define __externC extern "C"
+# else
+# define __externC extern
+# endif
+#endif
+
+// Compute a CRC, using the POSIX 1003 definition
+
+__externC cyg_uint32
+cyg_posix_crc32(unsigned char *s, int len);
+
+// Gary S. Brown's 32 bit CRC
+
+__externC cyg_uint32
+cyg_crc32(unsigned char *s, int len);
+
+// Gary S. Brown's 32 bit CRC, but accumulate the result from a
+// previous CRC calculation
+
+__externC cyg_uint32
+cyg_crc32_accumulate(cyg_uint32 crc, unsigned char *s, int len);
+
+// Ethernet FCS Algorithm
+
+__externC cyg_uint32
+cyg_ether_crc32(unsigned char *s, int len);
+
+// Ethernet FCS algorithm, but accumulate the result from a previous
+// CRC calculation.
+
+__externC cyg_uint32
+cyg_ether_crc32_accumulate(cyg_uint32 crc, unsigned char *s, int len);
+
+// 16 bit CRC with polynomial x^16+x^12+x^5+1
+
+__externC cyg_uint16
+cyg_crc16(unsigned char *s, int len);
+
+#endif // _SERVICES_CRC_CRC_H_
+
+
+
diff --git a/package/boot/rbcfg/src/cyg_crc32.c b/package/boot/rbcfg/src/cyg_crc32.c
new file mode 100644
index 0000000..9462598
--- /dev/null
+++ b/package/boot/rbcfg/src/cyg_crc32.c
@@ -0,0 +1,172 @@
+//==========================================================================
+//
+// crc32.c
+//
+// Gary S. Brown's 32 bit CRC
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+// Copyright (C) 2002 Gary Thomas
+//
+// eCos 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.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): gthomas
+// Contributors: gthomas,asl
+// Date: 2001-01-31
+// Purpose:
+// Description:
+//
+// This code is part of eCos (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#if 0
+#include <cyg/crc/crc.h>
+#else
+#include "cyg_crc.h"
+#endif
+
+ /* ====================================================================== */
+ /* COPYRIGHT (C) 1986 Gary S. Brown. You may use this program, or */
+ /* code or tables extracted from it, as desired without restriction. */
+ /* */
+ /* First, the polynomial itself and its table of feedback terms. The */
+ /* polynomial is */
+ /* X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0 */
+ /* */
+ /* ====================================================================== */
+
+static const cyg_uint32 crc32_tab[] = {
+ 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
+ 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
+ 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
+ 0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL,
+ 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L,
+ 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L,
+ 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L,
+ 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,
+ 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L,
+ 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL,
+ 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L,
+ 0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L,
+ 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L,
+ 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL,
+ 0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL,
+ 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,
+ 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL,
+ 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L,
+ 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L,
+ 0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L,
+ 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL,
+ 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L,
+ 0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L,
+ 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,
+ 0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L,
+ 0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L,
+ 0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L,
+ 0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L,
+ 0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L,
+ 0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL,
+ 0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL,
+ 0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,
+ 0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L,
+ 0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL,
+ 0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL,
+ 0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L,
+ 0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL,
+ 0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L,
+ 0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL,
+ 0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,
+ 0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL,
+ 0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L,
+ 0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L,
+ 0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL,
+ 0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L,
+ 0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L,
+ 0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L,
+ 0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,
+ 0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L,
+ 0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L,
+ 0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL,
+ 0x2d02ef8dL
+ };
+
+/* This is the standard Gary S. Brown's 32 bit CRC algorithm, but
+ accumulate the CRC into the result of a previous CRC. */
+cyg_uint32
+cyg_crc32_accumulate(cyg_uint32 crc32val, unsigned char *s, int len)
+{
+ int i;
+
+ for (i = 0; i < len; i++) {
+ crc32val = crc32_tab[(crc32val ^ s[i]) & 0xff] ^ (crc32val >> 8);
+ }
+ return crc32val;
+}
+
+/* This is the standard Gary S. Brown's 32 bit CRC algorithm */
+cyg_uint32
+cyg_crc32(unsigned char *s, int len)
+{
+ return (cyg_crc32_accumulate(0,s,len));
+}
+
+/* Return a 32-bit CRC of the contents of the buffer accumulating the
+ result from a previous CRC calculation. This uses the Ethernet FCS
+ algorithm.*/
+cyg_uint32
+cyg_ether_crc32_accumulate(cyg_uint32 crc32val, unsigned char *s, int len)
+{
+ int i;
+
+ if (s == 0) return 0L;
+
+ crc32val = crc32val ^ 0xffffffff;
+ for (i = 0; i < len; i++) {
+ crc32val = crc32_tab[(crc32val ^ s[i]) & 0xff] ^ (crc32val >> 8);
+ }
+ return crc32val ^ 0xffffffff;
+}
+
+/* Return a 32-bit CRC of the contents of the buffer, using the
+ Ethernet FCS algorithm. */
+cyg_uint32
+cyg_ether_crc32(unsigned char *s, int len)
+{
+ return cyg_ether_crc32_accumulate(0,s,len);
+}
+
+
diff --git a/package/boot/rbcfg/src/main.c b/package/boot/rbcfg/src/main.c
new file mode 100644
index 0000000..5614a6c
--- /dev/null
+++ b/package/boot/rbcfg/src/main.c
@@ -0,0 +1,791 @@
+/*
+ * RouterBOOT configuration utility
+ *
+ * Copyright (C) 2010 Gabor Juhos <juhosg@openwrt.org>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <string.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <linux/limits.h>
+
+#include "rbcfg.h"
+#include "cyg_crc.h"
+
+#define RBCFG_TMP_FILE "/tmp/.rbcfg"
+#define RBCFG_MTD_NAME "soft_config"
+
+#define RB_ERR_NOTFOUND 1
+#define RB_ERR_INVALID 2
+#define RB_ERR_NOMEM 3
+#define RB_ERR_IO 4
+
+#define ARRAY_SIZE(_a) (sizeof((_a)) / sizeof((_a)[0]))
+
+struct rbcfg_ctx {
+ char *mtd_device;
+ char *tmp_file;
+ char *buf;
+ unsigned buflen;
+};
+
+struct rbcfg_value {
+ const char *name;
+ const char *desc;
+ union {
+ uint32_t u32;
+ const char *raw;
+ } val;
+};
+
+#define RBCFG_ENV_TYPE_U32 0
+
+struct rbcfg_env {
+ const char *name;
+ int type;
+ uint16_t id;
+ const struct rbcfg_value *values;
+ int num_values;
+};
+
+#define CMD_FLAG_USES_CFG 0x01
+
+struct rbcfg_command {
+ const char *command;
+ const char *usage;
+ int flags;
+ int (*exec)(int argc, const char *argv[]);
+};
+
+static void usage(void);
+
+/* Globals */
+
+static struct rbcfg_ctx *rbcfg_ctx;
+static char *rbcfg_name;
+
+#define CFG_U32(_name, _desc, _val) { \
+ .name = (_name), \
+ .desc = (_desc), \
+ .val.u32 = (_val), \
+}
+
+static const struct rbcfg_value rbcfg_boot_delay[] = {
+ CFG_U32("1", "1 second", RB_BOOT_DELAY_1SEC),
+ CFG_U32("2", "2 seconds", RB_BOOT_DELAY_2SEC),
+ CFG_U32("3", "3 seconds", RB_BOOT_DELAY_3SEC),
+ CFG_U32("4", "4 seconds", RB_BOOT_DELAY_4SEC),
+ CFG_U32("5", "5 seconds", RB_BOOT_DELAY_5SEC),
+ CFG_U32("6", "6 seconds", RB_BOOT_DELAY_6SEC),
+ CFG_U32("7", "7 seconds", RB_BOOT_DELAY_7SEC),
+ CFG_U32("8", "8 seconds", RB_BOOT_DELAY_8SEC),
+ CFG_U32("9", "9 seconds", RB_BOOT_DELAY_9SEC),
+};
+
+static const struct rbcfg_value rbcfg_boot_device[] = {
+ CFG_U32("eth", "boot over Ethernet",
+ RB_BOOT_DEVICE_ETHER),
+ CFG_U32("nandeth", "boot from NAND, if fail then Ethernet",
+ RB_BOOT_DEVICE_NANDETH),
+ CFG_U32("ethnand", "boot Ethernet once, then NAND",
+ RB_BOOT_DEVICE_ETHONCE),
+ CFG_U32("nand", "boot from NAND only",
+ RB_BOOT_DEVICE_NANDONLY),
+};
+
+static const struct rbcfg_value rbcfg_boot_key[] = {
+ CFG_U32("any", "any key", RB_BOOT_KEY_ANY),
+ CFG_U32("del", "<Delete> key only", RB_BOOT_KEY_DEL),
+};
+
+static const struct rbcfg_value rbcfg_boot_protocol[] = {
+ CFG_U32("bootp", "BOOTP protocol", RB_BOOT_PROTOCOL_BOOTP),
+ CFG_U32("dhcp", "DHCP protocol", RB_BOOT_PROTOCOL_DHCP),
+};
+
+static const struct rbcfg_value rbcfg_uart_speed[] = {
+ CFG_U32("115200", "", RB_UART_SPEED_115200),
+ CFG_U32("57600", "", RB_UART_SPEED_57600),
+ CFG_U32("38400", "", RB_UART_SPEED_38400),
+ CFG_U32("19200", "", RB_UART_SPEED_19200),
+ CFG_U32("9600", "", RB_UART_SPEED_9600),
+ CFG_U32("4800", "", RB_UART_SPEED_4800),
+ CFG_U32("2400", "", RB_UART_SPEED_2400),
+ CFG_U32("1200", "", RB_UART_SPEED_1200),
+ CFG_U32("off", "disable console output", RB_UART_SPEED_OFF),
+};
+
+static const struct rbcfg_value rbcfg_cpu_mode[] = {
+ CFG_U32("powersave", "power save", RB_CPU_MODE_POWERSAVE),
+ CFG_U32("regular", "regular (better for -0c environment)",
+ RB_CPU_MODE_REGULAR),
+};
+
+static const struct rbcfg_value rbcfg_booter[] = {
+ CFG_U32("regular", "load regular booter", RB_BOOTER_REGULAR),
+ CFG_U32("backup", "force backup-booter loading", RB_BOOTER_BACKUP),
+};
+
+static const struct rbcfg_env rbcfg_envs[] = {
+ {
+ .name = "boot_delay",
+ .id = RB_ID_BOOT_DELAY,
+ .type = RBCFG_ENV_TYPE_U32,
+ .values = rbcfg_boot_delay,
+ .num_values = ARRAY_SIZE(rbcfg_boot_delay),
+ }, {
+ .name = "boot_device",
+ .id = RB_ID_BOOT_DEVICE,
+ .type = RBCFG_ENV_TYPE_U32,
+ .values = rbcfg_boot_device,
+ .num_values = ARRAY_SIZE(rbcfg_boot_device),
+ }, {
+ .name = "boot_key",
+ .id = RB_ID_BOOT_KEY,
+ .type = RBCFG_ENV_TYPE_U32,
+ .values = rbcfg_boot_key,
+ .num_values = ARRAY_SIZE(rbcfg_boot_key),
+ }, {
+ .name = "boot_protocol",
+ .id = RB_ID_BOOT_PROTOCOL,
+ .type = RBCFG_ENV_TYPE_U32,
+ .values = rbcfg_boot_protocol,
+ .num_values = ARRAY_SIZE(rbcfg_boot_protocol),
+ }, {
+ .name = "booter",
+ .id = RB_ID_BOOTER,
+ .type = RBCFG_ENV_TYPE_U32,
+ .values = rbcfg_booter,
+ .num_values = ARRAY_SIZE(rbcfg_booter),
+ }, {
+ .name = "cpu_mode",
+ .id = RB_ID_CPU_MODE,
+ .type = RBCFG_ENV_TYPE_U32,
+ .values = rbcfg_cpu_mode,
+ .num_values = ARRAY_SIZE(rbcfg_cpu_mode),
+ }, {
+ .name = "uart_speed",
+ .id = RB_ID_UART_SPEED,
+ .type = RBCFG_ENV_TYPE_U32,
+ .values = rbcfg_uart_speed,
+ .num_values = ARRAY_SIZE(rbcfg_uart_speed),
+ }
+};
+
+static inline uint16_t
+get_u16(const void *buf)
+{
+ const uint8_t *p = buf;
+
+ return ((uint16_t) p[1] + ((uint16_t) p[0] << 8));
+}
+
+static inline uint32_t
+get_u32(const void *buf)
+{
+ const uint8_t *p = buf;
+
+ return ((uint32_t) p[3] + ((uint32_t) p[2] << 8) +
+ ((uint32_t) p[1] << 16) + ((uint32_t) p[0] << 24));
+}
+
+static inline void
+put_u32(void *buf, uint32_t val)
+{
+ uint8_t *p = buf;
+
+ p[3] = val & 0xff;
+ p[2] = (val >> 8) & 0xff;
+ p[1] = (val >> 16) & 0xff;
+ p[0] = (val >> 24) & 0xff;
+}
+
+static int
+rbcfg_find_tag(struct rbcfg_ctx *ctx, uint16_t tag_id, uint16_t *tag_len,
+ void **tag_data)
+{
+ uint16_t id;
+ uint16_t len;
+ char *buf = ctx->buf;
+ unsigned int buflen = ctx->buflen;
+ int ret = RB_ERR_NOTFOUND;
+
+ /* skip magic and CRC value */
+ buf += 8;
+ buflen -= 8;
+
+ while (buflen > 2) {
+ len = get_u16(buf);
+ buf += 2;
+ buflen -= 2;
+
+ if (buflen < 2)
+ break;
+
+ id = get_u16(buf);
+ buf += 2;
+ buflen -= 2;
+
+ if (id == RB_ID_TERMINATOR)
+ break;
+
+ if (buflen < len)
+ break;
+
+ if (id == tag_id) {
+ *tag_len = len;
+ *tag_data = buf;
+ ret = 0;
+ break;
+ }
+
+ buf += len;
+ buflen -= len;
+ }
+
+ if (ret)
+ fprintf(stderr, "no tag found with id=%u\n", tag_id);
+
+ return ret;
+}
+
+static int
+rbcfg_get_u32(struct rbcfg_ctx *ctx, uint16_t id, uint32_t *val)
+{
+ void *tag_data;
+ uint16_t tag_len;
+ int err;
+
+ err = rbcfg_find_tag(ctx, id, &tag_len, &tag_data);
+ if (err)
+ return err;
+
+ *val = get_u32(tag_data);
+ return 0;
+}
+
+static int
+rbcfg_set_u32(struct rbcfg_ctx *ctx, uint16_t id, uint32_t val)
+{
+ void *tag_data;
+ uint16_t tag_len;
+ int err;
+
+ err = rbcfg_find_tag(ctx, id, &tag_len, &tag_data);
+ if (err)
+ return err;
+
+ put_u32(tag_data, val);
+ return 0;
+}
+
+char *rbcfg_find_mtd(const char *name, int *erase_size)
+{
+ FILE *f;
+ int mtd_num;
+ char dev[PATH_MAX];
+ char *ret = NULL;
+ struct stat s;
+ int err;
+
+ f = fopen("/proc/mtd", "r");
+ if (!f)
+ return NULL;
+
+ while (1) {
+ char *p;
+ p = fgets(dev, sizeof(dev), f);
+ if (!p)
+ break;
+
+ if (!strstr(dev, name))
+ continue;
+
+ err = sscanf(dev, "mtd%d: %08x", &mtd_num, erase_size);
+ if (err != 2)
+ break;
+
+ sprintf(dev, "/dev/mtdblock%d", mtd_num);
+ err = stat(dev, &s);
+ if (err < 0)
+ break;
+
+ if ((s.st_mode & S_IFBLK) == 0)
+ break;
+
+ ret = malloc(strlen(dev) + 1);
+ if (ret == NULL)
+ break;
+
+ strncpy(ret, dev, strlen(dev) + 1);
+ break;
+ }
+
+ fclose(f);
+ return ret;
+}
+
+static int
+rbcfg_check_tmp(struct rbcfg_ctx *ctx)
+{
+ struct stat s;
+ int err;
+
+ err = stat(ctx->tmp_file, &s);
+ if (err < 0)
+ return 0;
+
+ if ((s.st_mode & S_IFREG) == 0)
+ return 0;
+
+ if (s.st_size != ctx->buflen)
+ return 0;
+
+ return 1;
+}
+
+static int
+rbcfg_load(struct rbcfg_ctx *ctx)
+{
+ uint32_t magic;
+ uint32_t crc_orig, crc;
+ char *name;
+ int tmp;
+ int fd;
+ int err;
+
+ tmp = rbcfg_check_tmp(ctx);
+ name = (tmp) ? ctx->tmp_file : ctx->mtd_device;
+
+ fd = open(name, O_RDONLY);
+ if (fd < 0) {
+ fprintf(stderr, "unable to open %s\n", name);
+ err = RB_ERR_IO;
+ goto err;
+ }
+
+ err = read(fd, ctx->buf, ctx->buflen);
+ if (err != ctx->buflen) {
+ fprintf(stderr, "unable to read from %s\n", name);
+ err = RB_ERR_IO;
+ goto err_close;
+ }
+
+ magic = get_u32(ctx->buf);
+ if (magic != RB_MAGIC_SOFT) {
+ fprintf(stderr, "invalid configuration\n");
+ err = RB_ERR_INVALID;
+ goto err_close;
+ }
+
+ crc_orig = get_u32(ctx->buf + 4);
+ put_u32(ctx->buf + 4, 0);
+ crc = cyg_ether_crc32((unsigned char *) ctx->buf, ctx->buflen);
+ if (crc != crc_orig) {
+ fprintf(stderr, "configuration has CRC error\n");
+ err = RB_ERR_INVALID;
+ goto err_close;
+ }
+
+ err = 0;
+
+ err_close:
+ close(fd);
+ err:
+ return err;
+}
+
+static int
+rbcfg_open()
+{
+ char *mtd_device;
+ struct rbcfg_ctx *ctx;
+ int buflen;
+ int err;
+
+ mtd_device = rbcfg_find_mtd(RBCFG_MTD_NAME, &buflen);
+ if (!mtd_device) {
+ fprintf(stderr, "unable to find configuration\n");
+ return RB_ERR_NOTFOUND;
+ }
+
+ ctx = malloc(sizeof(struct rbcfg_ctx) + buflen);
+ if (ctx == NULL) {
+ err = RB_ERR_NOMEM;
+ goto err_free_mtd;
+ }
+
+ ctx->mtd_device = mtd_device;
+ ctx->tmp_file = RBCFG_TMP_FILE;
+ ctx->buflen = buflen;
+ ctx->buf = (char *) &ctx[1];
+
+ err = rbcfg_load(ctx);
+ if (err)
+ goto err_free_ctx;
+
+ rbcfg_ctx = ctx;
+ return 0;
+
+ err_free_ctx:
+ free(ctx);
+ err_free_mtd:
+ free(mtd_device);
+ return err;
+}
+
+static int
+rbcfg_update(int tmp)
+{
+ struct rbcfg_ctx *ctx = rbcfg_ctx;
+ char *name;
+ uint32_t crc;
+ int fd;
+ int err;
+
+ put_u32(ctx->buf, RB_MAGIC_SOFT);
+ put_u32(ctx->buf + 4, 0);
+ crc = cyg_ether_crc32((unsigned char *) ctx->buf, ctx->buflen);
+ put_u32(ctx->buf + 4, crc);
+
+ name = (tmp) ? ctx->tmp_file : ctx->mtd_device;
+ fd = open(name, O_WRONLY | O_CREAT);
+ if (fd < 0) {
+ fprintf(stderr, "unable to open %s for writing\n", name);
+ err = RB_ERR_IO;
+ goto out;
+ }
+
+ err = write(fd, ctx->buf, ctx->buflen);
+ if (err != ctx->buflen) {
+ err = RB_ERR_IO;
+ goto out_close;
+ }
+
+ fsync(fd);
+ err = 0;
+
+ out_close:
+ close(fd);
+ out:
+ return err;
+}
+
+static void
+rbcfg_close(void)
+{
+ struct rbcfg_ctx *ctx;
+
+ ctx = rbcfg_ctx;
+ free(ctx->mtd_device);
+ free(ctx);
+}
+
+static const struct rbcfg_value *
+rbcfg_env_find(const struct rbcfg_env *env, const char *name)
+{
+ unsigned i;
+
+ for (i = 0; i < env->num_values; i++) {
+ const struct rbcfg_value *v = &env->values[i];
+
+ if (strcmp(v->name, name) == 0)
+ return v;
+ }
+
+ return NULL;
+}
+
+static const struct rbcfg_value *
+rbcfg_env_find_u32(const struct rbcfg_env *env, uint32_t val)
+{
+ unsigned i;
+
+ for (i = 0; i < env->num_values; i++) {
+ const struct rbcfg_value *v = &env->values[i];
+
+ if (v->val.u32 == val)
+ return v;
+ }
+
+ return NULL;
+}
+
+static const char *
+rbcfg_env_get_u32(const struct rbcfg_env *env)
+{
+ const struct rbcfg_value *v;
+ uint32_t val;
+ int err;
+
+ err = rbcfg_get_u32(rbcfg_ctx, env->id, &val);
+ if (err)
+ return NULL;
+
+ v = rbcfg_env_find_u32(env, val);
+ if (v == NULL) {
+ fprintf(stderr, "unknown value %08x found for %s\n",
+ val, env->name);
+ return NULL;
+ }
+
+ return v->name;
+}
+
+static int
+rbcfg_env_set_u32(const struct rbcfg_env *env, const char *data)
+{
+ const struct rbcfg_value *v;
+ int err;
+
+ v = rbcfg_env_find(env, data);
+ if (v == NULL) {
+ fprintf(stderr, "invalid value '%s'\n", data);
+ return RB_ERR_INVALID;
+ }
+
+ err = rbcfg_set_u32(rbcfg_ctx, env->id, v->val.u32);
+ return err;
+}
+
+static const char *
+rbcfg_env_get(const struct rbcfg_env *env)
+{
+ const char *ret = NULL;
+
+ switch (env->type) {
+ case RBCFG_ENV_TYPE_U32:
+ ret = rbcfg_env_get_u32(env);
+ break;
+ }
+
+ return ret;
+}
+
+static int
+rbcfg_env_set(const struct rbcfg_env *env, const char *data)
+{
+ int ret = 0;
+
+ switch (env->type) {
+ case RBCFG_ENV_TYPE_U32:
+ ret = rbcfg_env_set_u32(env, data);
+ break;
+ }
+
+ return ret;
+}
+
+static int
+rbcfg_cmd_apply(int argc, const char *argv[])
+{
+ return rbcfg_update(0);
+}
+
+static int
+rbcfg_cmd_help(int argc, const char *argv[])
+{
+ usage();
+ return 0;
+}
+
+static int
+rbcfg_cmd_get(int argc, const char *argv[])
+{
+ int err = RB_ERR_NOTFOUND;
+ int i;
+
+ if (argc != 1) {
+ usage();
+ return RB_ERR_INVALID;
+ }
+
+ for (i = 0; i < ARRAY_SIZE(rbcfg_envs); i++) {
+ const struct rbcfg_env *env = &rbcfg_envs[i];
+ const char *value;
+
+ if (strcmp(env->name, argv[0]))
+ continue;
+
+ value = rbcfg_env_get(env);
+ if (value) {
+ fprintf(stdout, "%s\n", value);
+ err = 0;
+ }
+ break;
+ }
+
+ return err;
+}
+
+static int
+rbcfg_cmd_set(int argc, const char *argv[])
+{
+ int err = RB_ERR_INVALID;
+ int i;
+
+ if (argc != 2) {
+ /* not enough parameters */
+ usage();
+ return RB_ERR_INVALID;
+ }
+
+ for (i = 0; i < ARRAY_SIZE(rbcfg_envs); i++) {
+ const struct rbcfg_env *env = &rbcfg_envs[i];
+
+ if (strcmp(env->name, argv[0]))
+ continue;
+
+ err = rbcfg_env_set(env, argv[1]);
+ if (err == 0)
+ err = rbcfg_update(1);
+ break;
+ }
+
+ return err;
+}
+
+static int
+rbcfg_cmd_show(int argc, const char *argv[])
+{
+ int i;
+
+ if (argc != 0) {
+ usage();
+ return RB_ERR_INVALID;
+ }
+
+ for (i = 0; i < ARRAY_SIZE(rbcfg_envs); i++) {
+ const struct rbcfg_env *env = &rbcfg_envs[i];
+ const char *value;
+
+ value = rbcfg_env_get(env);
+ if (value)
+ fprintf(stdout, "%s=%s\n", env->name, value);
+ }
+
+ return 0;
+}
+
+static const struct rbcfg_command rbcfg_commands[] = {
+ {
+ .command = "apply",
+ .usage = "apply\n"
+ "\t- write configuration to the mtd device",
+ .flags = CMD_FLAG_USES_CFG,
+ .exec = rbcfg_cmd_apply,
+ }, {
+ .command = "help",
+ .usage = "help\n"
+ "\t- show this screen",
+ .exec = rbcfg_cmd_help,
+ }, {
+ .command = "get",
+ .usage = "get <name>\n"
+ "\t- get value of the configuration option <name>",
+ .flags = CMD_FLAG_USES_CFG,
+ .exec = rbcfg_cmd_get,
+ }, {
+ .command = "set",
+ .usage = "set <name> <value>\n"
+ "\t- set value of the configuration option <name> to <value>",
+ .flags = CMD_FLAG_USES_CFG,
+ .exec = rbcfg_cmd_set,
+ }, {
+ .command = "show",
+ .usage = "show\n"
+ "\t- show value of all configuration options",
+ .flags = CMD_FLAG_USES_CFG,
+ .exec = rbcfg_cmd_show,
+ }
+};
+
+static void
+usage(void)
+{
+ char buf[255];
+ int len;
+ int i;
+
+ fprintf(stderr, "Usage: %s <command>\n", rbcfg_name);
+
+ fprintf(stderr, "\nCommands:\n");
+ for (i = 0; i < ARRAY_SIZE(rbcfg_commands); i++) {
+ const struct rbcfg_command *cmd;
+ cmd = &rbcfg_commands[i];
+
+ len = snprintf(buf, sizeof(buf), cmd->usage);
+ buf[len] = '\0';
+ fprintf(stderr, "%s\n", buf);
+ }
+
+ fprintf(stderr, "\nConfiguration options:\n");
+ for (i = 0; i < ARRAY_SIZE(rbcfg_envs); i++) {
+ const struct rbcfg_env *env;
+ int j;
+
+ env = &rbcfg_envs[i];
+ fprintf(stderr, "\n%s:\n", env->name);
+ for (j = 0; j < env->num_values; j++) {
+ const struct rbcfg_value *v = &env->values[j];
+ fprintf(stderr, "\t%-12s %s\n", v->name, v->desc);
+ }
+ }
+ fprintf(stderr, "\n");
+}
+
+int main(int argc, const char *argv[])
+{
+ const struct rbcfg_command *cmd = NULL;
+ int ret;
+ int i;
+
+ rbcfg_name = (char *) argv[0];
+
+ if (argc < 2) {
+ usage();
+ return EXIT_FAILURE;
+ }
+
+ for (i = 0; i < ARRAY_SIZE(rbcfg_commands); i++) {
+ if (strcmp(rbcfg_commands[i].command, argv[1]) == 0) {
+ cmd = &rbcfg_commands[i];
+ break;
+ }
+ }
+
+ if (cmd == NULL) {
+ fprintf(stderr, "unknown command '%s'\n", argv[1]);
+ usage();
+ return EXIT_FAILURE;
+ }
+
+ argc -= 2;
+ argv += 2;
+
+ if (cmd->flags & CMD_FLAG_USES_CFG) {
+ ret = rbcfg_open();
+ if (ret)
+ return EXIT_FAILURE;
+ }
+
+ ret = cmd->exec(argc, argv);
+
+ if (cmd->flags & CMD_FLAG_USES_CFG)
+ rbcfg_close();
+
+ if (ret)
+ return EXIT_FAILURE;
+
+ return EXIT_SUCCESS;
+}
diff --git a/package/boot/rbcfg/src/rbcfg.h b/package/boot/rbcfg/src/rbcfg.h
new file mode 100644
index 0000000..899161a
--- /dev/null
+++ b/package/boot/rbcfg/src/rbcfg.h
@@ -0,0 +1,75 @@
+/*
+ * Mikrotik's RouterBOOT configuration defines
+ *
+ * Copyright (C) 2010 Gabor Juhos <juhosg@openwrt.org>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ *
+ */
+
+#ifndef _RBCFG_H
+#define _RBCFG_H
+
+/*
+ * Magic numbers
+ */
+#define RB_MAGIC_SOFT 0x74666f53 /* 'Soft' */
+
+/*
+ * ID values for Software settings
+ */
+#define RB_ID_TERMINATOR 0
+#define RB_ID_UART_SPEED 1
+#define RB_ID_BOOT_DELAY 2
+#define RB_ID_BOOT_DEVICE 3
+#define RB_ID_BOOT_KEY 4
+#define RB_ID_CPU_MODE 5
+#define RB_ID_FW_VERSION 6
+#define RB_ID_SOFT_07 7
+#define RB_ID_SOFT_08 8
+#define RB_ID_BOOT_PROTOCOL 9
+#define RB_ID_SOFT_10 10
+#define RB_ID_SOFT_11 11
+#define RB_ID_BOOTER 13
+
+#define RB_UART_SPEED_115200 0
+#define RB_UART_SPEED_57600 1
+#define RB_UART_SPEED_38400 2
+#define RB_UART_SPEED_19200 3
+#define RB_UART_SPEED_9600 4
+#define RB_UART_SPEED_4800 5
+#define RB_UART_SPEED_2400 6
+#define RB_UART_SPEED_1200 7
+#define RB_UART_SPEED_OFF 8
+
+#define RB_BOOT_DELAY_1SEC 1
+#define RB_BOOT_DELAY_2SEC 2
+#define RB_BOOT_DELAY_3SEC 3
+#define RB_BOOT_DELAY_4SEC 4
+#define RB_BOOT_DELAY_5SEC 5
+#define RB_BOOT_DELAY_6SEC 6
+#define RB_BOOT_DELAY_7SEC 7
+#define RB_BOOT_DELAY_8SEC 8
+#define RB_BOOT_DELAY_9SEC 9
+
+#define RB_BOOT_DEVICE_ETHER 0
+#define RB_BOOT_DEVICE_NANDETH 1
+#define RB_BOOT_DEVICE_CFCARD 2
+#define RB_BOOT_DEVICE_ETHONCE 3
+#define RB_BOOT_DEVICE_NANDONLY 5
+
+#define RB_BOOT_KEY_ANY 0
+#define RB_BOOT_KEY_DEL 1
+
+#define RB_CPU_MODE_POWERSAVE 0
+#define RB_CPU_MODE_REGULAR 1
+
+#define RB_BOOT_PROTOCOL_BOOTP 0
+#define RB_BOOT_PROTOCOL_DHCP 1
+
+#define RB_BOOTER_REGULAR 0
+#define RB_BOOTER_BACKUP 1
+
+#endif /* _RBCFG_H */
diff --git a/package/boot/uboot-ar71xx/.svn/entries b/package/boot/uboot-ar71xx/.svn/entries
new file mode 100644
index 0000000..c22743c
--- /dev/null
+++ b/package/boot/uboot-ar71xx/.svn/entries
@@ -0,0 +1,68 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/uboot-ar71xx
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+files
+dir
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+0bd109b1804aa08c7b5d06154eec7560
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2105
+
diff --git a/package/boot/uboot-ar71xx/.svn/prop-base/Makefile.svn-base b/package/boot/uboot-ar71xx/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/boot/uboot-ar71xx/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/boot/uboot-ar71xx/.svn/text-base/Makefile.svn-base b/package/boot/uboot-ar71xx/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..ab692d5
--- /dev/null
+++ b/package/boot/uboot-ar71xx/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,90 @@
+#
+# Copyright (C) 2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=u-boot
+PKG_VERSION:=2010.03
+PKG_RELEASE:=1
+
+PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=ftp://ftp.denx.de/pub/u-boot
+PKG_MD5SUM:=
+PKG_TARGETS:=bin
+
+include $(INCLUDE_DIR)/package.mk
+
+define uboot/Default
+ TITLE:=
+ CONFIG:=
+ IMAGE:=
+endef
+
+define uboot/nbg460n_550n_550nh
+ TITLE:=U-boot for the NBG460N/550N/550NH routers
+endef
+
+UBOOTS:=nbg460n_550n_550nh
+
+define Package/uboot/template
+define Package/uboot-ar71xx-$(1)
+ SECTION:=boot
+ CATEGORY:=Boot Loaders
+ TITLE:=$(2)
+ DEPENDS:=@TARGET_ar71xx
+ URL:=http://www.denx.de/wiki/U-Boot
+ DEFAULT:=y if (TARGET_ar71xx_generic_NBG_460N_550N_550NH || TARGET_ar71xx_generic_Default || CONFIG_TARGET_ar71xx_generic_Minimal)
+ VARIANT:=$(1)
+endef
+endef
+
+define BuildUbootPackage
+ $(eval $(uboot/Default))
+ $(eval $(uboot/$(1)))
+ $(call Package/uboot/template,$(1),$(TITLE))
+endef
+
+
+ifdef BUILD_VARIANT
+$(eval $(call uboot/$(BUILD_VARIANT)))
+UBOOT_CONFIG:=$(if $(CONFIG),$(CONFIG),$(BUILD_VARIANT))
+UBOOT_IMAGE:=$(if $(IMAGE),$(IMAGE),openwrt-$(BOARD)-$(BUILD_VARIANT)-u-boot.bin)
+endif
+
+define Build/Prepare
+ $(call Build/Prepare/Default)
+ $(CP) ./files/* $(PKG_BUILD_DIR)
+ find $(PKG_BUILD_DIR) -name .svn | $(XARGS) rm -rf
+endef
+
+define Build/Configure
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ $(UBOOT_CONFIG)_config
+endef
+
+define Build/Compile
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ CROSS_COMPILE=$(TARGET_CROSS)
+endef
+
+define Package/uboot/install/template
+define Package/uboot-ar71xx-$(1)/install
+ $(INSTALL_DIR) $$(1)
+ $(CP) $(PKG_BUILD_DIR)/u-boot.bin $(BIN_DIR)/$(2)
+endef
+endef
+
+$(foreach u,$(UBOOTS), \
+ $(eval $(call Package/uboot/install/template,$(u),openwrt-$(BOARD)-$(SUBTARGET)-$(u)-u-boot.bin)) \
+)
+
+$(foreach u,$(UBOOTS), \
+ $(eval $(call BuildUbootPackage,$(u))) \
+ $(eval $(call BuildPackage,uboot-ar71xx-$(u))) \
+)
diff --git a/package/boot/uboot-ar71xx/Makefile b/package/boot/uboot-ar71xx/Makefile
new file mode 100644
index 0000000..ab692d5
--- /dev/null
+++ b/package/boot/uboot-ar71xx/Makefile
@@ -0,0 +1,90 @@
+#
+# Copyright (C) 2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=u-boot
+PKG_VERSION:=2010.03
+PKG_RELEASE:=1
+
+PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=ftp://ftp.denx.de/pub/u-boot
+PKG_MD5SUM:=
+PKG_TARGETS:=bin
+
+include $(INCLUDE_DIR)/package.mk
+
+define uboot/Default
+ TITLE:=
+ CONFIG:=
+ IMAGE:=
+endef
+
+define uboot/nbg460n_550n_550nh
+ TITLE:=U-boot for the NBG460N/550N/550NH routers
+endef
+
+UBOOTS:=nbg460n_550n_550nh
+
+define Package/uboot/template
+define Package/uboot-ar71xx-$(1)
+ SECTION:=boot
+ CATEGORY:=Boot Loaders
+ TITLE:=$(2)
+ DEPENDS:=@TARGET_ar71xx
+ URL:=http://www.denx.de/wiki/U-Boot
+ DEFAULT:=y if (TARGET_ar71xx_generic_NBG_460N_550N_550NH || TARGET_ar71xx_generic_Default || CONFIG_TARGET_ar71xx_generic_Minimal)
+ VARIANT:=$(1)
+endef
+endef
+
+define BuildUbootPackage
+ $(eval $(uboot/Default))
+ $(eval $(uboot/$(1)))
+ $(call Package/uboot/template,$(1),$(TITLE))
+endef
+
+
+ifdef BUILD_VARIANT
+$(eval $(call uboot/$(BUILD_VARIANT)))
+UBOOT_CONFIG:=$(if $(CONFIG),$(CONFIG),$(BUILD_VARIANT))
+UBOOT_IMAGE:=$(if $(IMAGE),$(IMAGE),openwrt-$(BOARD)-$(BUILD_VARIANT)-u-boot.bin)
+endif
+
+define Build/Prepare
+ $(call Build/Prepare/Default)
+ $(CP) ./files/* $(PKG_BUILD_DIR)
+ find $(PKG_BUILD_DIR) -name .svn | $(XARGS) rm -rf
+endef
+
+define Build/Configure
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ $(UBOOT_CONFIG)_config
+endef
+
+define Build/Compile
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ CROSS_COMPILE=$(TARGET_CROSS)
+endef
+
+define Package/uboot/install/template
+define Package/uboot-ar71xx-$(1)/install
+ $(INSTALL_DIR) $$(1)
+ $(CP) $(PKG_BUILD_DIR)/u-boot.bin $(BIN_DIR)/$(2)
+endef
+endef
+
+$(foreach u,$(UBOOTS), \
+ $(eval $(call Package/uboot/install/template,$(u),openwrt-$(BOARD)-$(SUBTARGET)-$(u)-u-boot.bin)) \
+)
+
+$(foreach u,$(UBOOTS), \
+ $(eval $(call BuildUbootPackage,$(u))) \
+ $(eval $(call BuildPackage,uboot-ar71xx-$(u))) \
+)
diff --git a/package/boot/uboot-ar71xx/files/.svn/entries b/package/boot/uboot-ar71xx/files/.svn/entries
new file mode 100644
index 0000000..11e092f
--- /dev/null
+++ b/package/boot/uboot-ar71xx/files/.svn/entries
@@ -0,0 +1,40 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/uboot-ar71xx/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+include
+dir
+
+board
+dir
+
+cpu
+dir
+
+drivers
+dir
+
diff --git a/package/boot/uboot-ar71xx/files/board/.svn/entries b/package/boot/uboot-ar71xx/files/board/.svn/entries
new file mode 100644
index 0000000..fe48131
--- /dev/null
+++ b/package/boot/uboot-ar71xx/files/board/.svn/entries
@@ -0,0 +1,31 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/uboot-ar71xx/files/board
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+zyxel
+dir
+
diff --git a/package/boot/uboot-ar71xx/files/board/zyxel/.svn/entries b/package/boot/uboot-ar71xx/files/board/zyxel/.svn/entries
new file mode 100644
index 0000000..2067997
--- /dev/null
+++ b/package/boot/uboot-ar71xx/files/board/zyxel/.svn/entries
@@ -0,0 +1,31 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/uboot-ar71xx/files/board/zyxel
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+nbg460n
+dir
+
diff --git a/package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/.svn/entries b/package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/.svn/entries
new file mode 100644
index 0000000..2cd7eba
--- /dev/null
+++ b/package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/.svn/entries
@@ -0,0 +1,198 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/uboot-ar71xx/files/board/zyxel/nbg460n
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+nbg460n.c
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+4ca6c195407e477c7ce5e894b0047bd7
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2519
+
+u-boot.lds
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+189327e68f6732474873394c31ecb392
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+644
+
+config.mk
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+e0a9c9382bb06ca19e6e6277bd6cb25e
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+23
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+adb668f790f345afd4d82777c8bd28e0
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1403
+
+lowlevel_init.S
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+6bcc57bddec47e9957d0b00bd2755913
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1089
+
diff --git a/package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/.svn/prop-base/Makefile.svn-base b/package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/.svn/prop-base/config.mk.svn-base b/package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/.svn/prop-base/config.mk.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/.svn/prop-base/config.mk.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/.svn/prop-base/nbg460n.c.svn-base b/package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/.svn/prop-base/nbg460n.c.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/.svn/prop-base/nbg460n.c.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/.svn/text-base/Makefile.svn-base b/package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..b0a385b
--- /dev/null
+++ b/package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,46 @@
+#
+# (C) Copyright 2003-2008
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# 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 of
+# the License, 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; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+include $(TOPDIR)/config.mk
+
+LIB = $(obj)lib$(BOARD).a
+
+COBJS-y += $(BOARD).o
+SOBJS-y += lowlevel_init.o
+
+SRCS := $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c)
+OBJS := $(addprefix $(obj),$(COBJS-y))
+SOBJS := $(addprefix $(obj),$(SOBJS-y))
+
+$(LIB): $(obj).depend $(OBJS) $(SOBJS)
+ $(AR) $(ARFLAGS) $@ $(OBJS) $(SOBJS)
+
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
diff --git a/package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/.svn/text-base/config.mk.svn-base b/package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/.svn/text-base/config.mk.svn-base
new file mode 100644
index 0000000..e042e78
--- /dev/null
+++ b/package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/.svn/text-base/config.mk.svn-base
@@ -0,0 +1 @@
+TEXT_BASE = 0x81E00000
diff --git a/package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/.svn/text-base/lowlevel_init.S.svn-base b/package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/.svn/text-base/lowlevel_init.S.svn-base
new file mode 100644
index 0000000..83084c8
--- /dev/null
+++ b/package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/.svn/text-base/lowlevel_init.S.svn-base
@@ -0,0 +1,39 @@
+/*
+ * (C) Copyright 2010
+ * Michael Kurz <michi.kurz@googlemail.com>.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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 of
+ * the License, 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <config.h>
+#include <version.h>
+#include <asm/regdef.h>
+#include <asm/mipsregs.h>
+#include <asm/addrspace.h>
+
+
+
+.globl lowlevel_init
+/*
+ All done by Bootbase, nothing to do
+*/
+lowlevel_init:
+ jr ra
+ nop
+
diff --git a/package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/.svn/text-base/nbg460n.c.svn-base b/package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/.svn/text-base/nbg460n.c.svn-base
new file mode 100644
index 0000000..03a479d
--- /dev/null
+++ b/package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/.svn/text-base/nbg460n.c.svn-base
@@ -0,0 +1,96 @@
+/*
+ * (C) Copyright 2010
+ * Michael Kurz <michi.kurz@googlemail.com>.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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 of
+ * the License, 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <netdev.h>
+#include <asm/mipsregs.h>
+#include <asm/addrspace.h>
+#include <asm/reboot.h>
+#include <asm/ar71xx.h>
+#include <asm/ar71xx_gpio.h>
+
+#define NBG460N_WAN_LED 19
+
+phys_size_t initdram(int board_type)
+{
+ return (32*1024*1024);
+}
+
+int checkboard(void)
+{
+ // Set pin 19 to 1, to stop WAN LED blinking
+ ar71xx_setpindir(NBG460N_WAN_LED, 1);
+ ar71xx_setpin(NBG460N_WAN_LED, 1);
+
+ printf("U-boot on Zyxel NBG460N\n");
+ return 0;
+}
+
+void _machine_restart(void)
+{
+ for (;;) {
+ writel((RESET_MODULE_FULL_CHIP | RESET_MODULE_DDR),
+ KSEG1ADDR(AR71XX_RESET_BASE + AR91XX_RESET_REG_RESET_MODULE));
+ readl(KSEG1ADDR(AR71XX_RESET_BASE + AR91XX_RESET_REG_RESET_MODULE));
+ }
+}
+
+int board_eth_init(bd_t *bis)
+{
+ char *phynames[] = {RTL8366_DEVNAME, RTL8366_DEVNAME};
+ u16 phyids[] = {RTL8366_LANPHY_ID, RTL8366_WANPHY_ID};
+ u16 phyfixed[] = {1, 0};
+
+ if (ag71xx_register(bis, phynames, phyids, phyfixed) <= 0)
+ return -1;
+
+ if (rtl8366s_initialize())
+ return -1;
+
+ if (rtl8366_mii_register(bis))
+ return -1;
+
+ return 0;
+}
+
+int misc_init_r(void) {
+ uint8_t macaddr[6];
+ uint8_t enetaddr[6];
+
+ debug("Testing mac addresses\n");
+
+ memcpy(macaddr, (uint8_t *) CONFIG_ETHADDR_ADDR, 6);
+
+ if (!eth_getenv_enetaddr("ethaddr", enetaddr)) {
+ debug("Setting eth0 mac addr to %pM\n", macaddr);
+ eth_setenv_enetaddr("ethaddr", macaddr);
+ }
+
+ if (!eth_getenv_enetaddr("eth1addr", enetaddr)) {
+ macaddr[5] += 1;
+ debug("Setting eth1 mac addr to %pM\n", macaddr);
+ eth_setenv_enetaddr("eth1addr", macaddr);
+ }
+
+ return 0;
+}
diff --git a/package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/.svn/text-base/u-boot.lds.svn-base b/package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/.svn/text-base/u-boot.lds.svn-base
new file mode 100644
index 0000000..8dc2b76
--- /dev/null
+++ b/package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/.svn/text-base/u-boot.lds.svn-base
@@ -0,0 +1,42 @@
+OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradbigmips")
+OUTPUT_ARCH(mips)
+ENTRY(_start)
+SECTIONS
+{
+ . = 0x00000000;
+
+ . = ALIGN(4);
+ .text :
+ {
+ *(.text)
+ }
+
+ . = ALIGN(4);
+ .rodata : { *(.rodata) }
+
+ . = ALIGN(4);
+ .data : { *(.data) }
+
+ . = ALIGN(4);
+ .sdata : { *(.sdata) }
+
+ _gp = ALIGN(16);
+
+ __got_start = .;
+ .got : { *(.got) }
+ __got_end = .;
+
+ .sdata : { *(.sdata) }
+
+ __u_boot_cmd_start = .;
+ .u_boot_cmd : { *(.u_boot_cmd) }
+ __u_boot_cmd_end = .;
+
+ uboot_end_data = .;
+ num_got_entries = (__got_end - __got_start) >> 2;
+
+ . = ALIGN(4);
+ .sbss : { *(.sbss) }
+ .bss : { *(.bss) }
+ uboot_end = .;
+}
diff --git a/package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/Makefile b/package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/Makefile
new file mode 100644
index 0000000..b0a385b
--- /dev/null
+++ b/package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/Makefile
@@ -0,0 +1,46 @@
+#
+# (C) Copyright 2003-2008
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# 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 of
+# the License, 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; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+include $(TOPDIR)/config.mk
+
+LIB = $(obj)lib$(BOARD).a
+
+COBJS-y += $(BOARD).o
+SOBJS-y += lowlevel_init.o
+
+SRCS := $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c)
+OBJS := $(addprefix $(obj),$(COBJS-y))
+SOBJS := $(addprefix $(obj),$(SOBJS-y))
+
+$(LIB): $(obj).depend $(OBJS) $(SOBJS)
+ $(AR) $(ARFLAGS) $@ $(OBJS) $(SOBJS)
+
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
diff --git a/package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/config.mk b/package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/config.mk
new file mode 100644
index 0000000..e042e78
--- /dev/null
+++ b/package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/config.mk
@@ -0,0 +1 @@
+TEXT_BASE = 0x81E00000
diff --git a/package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/lowlevel_init.S b/package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/lowlevel_init.S
new file mode 100644
index 0000000..83084c8
--- /dev/null
+++ b/package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/lowlevel_init.S
@@ -0,0 +1,39 @@
+/*
+ * (C) Copyright 2010
+ * Michael Kurz <michi.kurz@googlemail.com>.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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 of
+ * the License, 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <config.h>
+#include <version.h>
+#include <asm/regdef.h>
+#include <asm/mipsregs.h>
+#include <asm/addrspace.h>
+
+
+
+.globl lowlevel_init
+/*
+ All done by Bootbase, nothing to do
+*/
+lowlevel_init:
+ jr ra
+ nop
+
diff --git a/package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/nbg460n.c b/package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/nbg460n.c
new file mode 100644
index 0000000..03a479d
--- /dev/null
+++ b/package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/nbg460n.c
@@ -0,0 +1,96 @@
+/*
+ * (C) Copyright 2010
+ * Michael Kurz <michi.kurz@googlemail.com>.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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 of
+ * the License, 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <netdev.h>
+#include <asm/mipsregs.h>
+#include <asm/addrspace.h>
+#include <asm/reboot.h>
+#include <asm/ar71xx.h>
+#include <asm/ar71xx_gpio.h>
+
+#define NBG460N_WAN_LED 19
+
+phys_size_t initdram(int board_type)
+{
+ return (32*1024*1024);
+}
+
+int checkboard(void)
+{
+ // Set pin 19 to 1, to stop WAN LED blinking
+ ar71xx_setpindir(NBG460N_WAN_LED, 1);
+ ar71xx_setpin(NBG460N_WAN_LED, 1);
+
+ printf("U-boot on Zyxel NBG460N\n");
+ return 0;
+}
+
+void _machine_restart(void)
+{
+ for (;;) {
+ writel((RESET_MODULE_FULL_CHIP | RESET_MODULE_DDR),
+ KSEG1ADDR(AR71XX_RESET_BASE + AR91XX_RESET_REG_RESET_MODULE));
+ readl(KSEG1ADDR(AR71XX_RESET_BASE + AR91XX_RESET_REG_RESET_MODULE));
+ }
+}
+
+int board_eth_init(bd_t *bis)
+{
+ char *phynames[] = {RTL8366_DEVNAME, RTL8366_DEVNAME};
+ u16 phyids[] = {RTL8366_LANPHY_ID, RTL8366_WANPHY_ID};
+ u16 phyfixed[] = {1, 0};
+
+ if (ag71xx_register(bis, phynames, phyids, phyfixed) <= 0)
+ return -1;
+
+ if (rtl8366s_initialize())
+ return -1;
+
+ if (rtl8366_mii_register(bis))
+ return -1;
+
+ return 0;
+}
+
+int misc_init_r(void) {
+ uint8_t macaddr[6];
+ uint8_t enetaddr[6];
+
+ debug("Testing mac addresses\n");
+
+ memcpy(macaddr, (uint8_t *) CONFIG_ETHADDR_ADDR, 6);
+
+ if (!eth_getenv_enetaddr("ethaddr", enetaddr)) {
+ debug("Setting eth0 mac addr to %pM\n", macaddr);
+ eth_setenv_enetaddr("ethaddr", macaddr);
+ }
+
+ if (!eth_getenv_enetaddr("eth1addr", enetaddr)) {
+ macaddr[5] += 1;
+ debug("Setting eth1 mac addr to %pM\n", macaddr);
+ eth_setenv_enetaddr("eth1addr", macaddr);
+ }
+
+ return 0;
+}
diff --git a/package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/u-boot.lds b/package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/u-boot.lds
new file mode 100644
index 0000000..8dc2b76
--- /dev/null
+++ b/package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/u-boot.lds
@@ -0,0 +1,42 @@
+OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradbigmips")
+OUTPUT_ARCH(mips)
+ENTRY(_start)
+SECTIONS
+{
+ . = 0x00000000;
+
+ . = ALIGN(4);
+ .text :
+ {
+ *(.text)
+ }
+
+ . = ALIGN(4);
+ .rodata : { *(.rodata) }
+
+ . = ALIGN(4);
+ .data : { *(.data) }
+
+ . = ALIGN(4);
+ .sdata : { *(.sdata) }
+
+ _gp = ALIGN(16);
+
+ __got_start = .;
+ .got : { *(.got) }
+ __got_end = .;
+
+ .sdata : { *(.sdata) }
+
+ __u_boot_cmd_start = .;
+ .u_boot_cmd : { *(.u_boot_cmd) }
+ __u_boot_cmd_end = .;
+
+ uboot_end_data = .;
+ num_got_entries = (__got_end - __got_start) >> 2;
+
+ . = ALIGN(4);
+ .sbss : { *(.sbss) }
+ .bss : { *(.bss) }
+ uboot_end = .;
+}
diff --git a/package/boot/uboot-ar71xx/files/cpu/.svn/entries b/package/boot/uboot-ar71xx/files/cpu/.svn/entries
new file mode 100644
index 0000000..b2aff8b
--- /dev/null
+++ b/package/boot/uboot-ar71xx/files/cpu/.svn/entries
@@ -0,0 +1,31 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/uboot-ar71xx/files/cpu
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+mips
+dir
+
diff --git a/package/boot/uboot-ar71xx/files/cpu/mips/.svn/entries b/package/boot/uboot-ar71xx/files/cpu/mips/.svn/entries
new file mode 100644
index 0000000..d93fd35
--- /dev/null
+++ b/package/boot/uboot-ar71xx/files/cpu/mips/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/uboot-ar71xx/files/cpu/mips
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+ar71xx_serial.c
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+f5711b1fa72d76b55261c16e7d73d225
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4579
+
diff --git a/package/boot/uboot-ar71xx/files/cpu/mips/.svn/prop-base/ar71xx_serial.c.svn-base b/package/boot/uboot-ar71xx/files/cpu/mips/.svn/prop-base/ar71xx_serial.c.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/boot/uboot-ar71xx/files/cpu/mips/.svn/prop-base/ar71xx_serial.c.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/boot/uboot-ar71xx/files/cpu/mips/.svn/text-base/ar71xx_serial.c.svn-base b/package/boot/uboot-ar71xx/files/cpu/mips/.svn/text-base/ar71xx_serial.c.svn-base
new file mode 100644
index 0000000..f093318
--- /dev/null
+++ b/package/boot/uboot-ar71xx/files/cpu/mips/.svn/text-base/ar71xx_serial.c.svn-base
@@ -0,0 +1,177 @@
+/*
+ * (C) Copyright 2010
+ * Michael Kurz <michi.kurz@googlemail.com>.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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 of
+ * the License, 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <asm/addrspace.h>
+#include <asm/types.h>
+#include <config.h>
+#include <asm/ar71xx.h>
+
+#define REG_SIZE 4
+
+/* === END OF CONFIG === */
+
+/* register offset */
+#define OFS_RCV_BUFFER (0*REG_SIZE)
+#define OFS_TRANS_HOLD (0*REG_SIZE)
+#define OFS_SEND_BUFFER (0*REG_SIZE)
+#define OFS_INTR_ENABLE (1*REG_SIZE)
+#define OFS_INTR_ID (2*REG_SIZE)
+#define OFS_DATA_FORMAT (3*REG_SIZE)
+#define OFS_LINE_CONTROL (3*REG_SIZE)
+#define OFS_MODEM_CONTROL (4*REG_SIZE)
+#define OFS_RS232_OUTPUT (4*REG_SIZE)
+#define OFS_LINE_STATUS (5*REG_SIZE)
+#define OFS_MODEM_STATUS (6*REG_SIZE)
+#define OFS_RS232_INPUT (6*REG_SIZE)
+#define OFS_SCRATCH_PAD (7*REG_SIZE)
+
+#define OFS_DIVISOR_LSB (0*REG_SIZE)
+#define OFS_DIVISOR_MSB (1*REG_SIZE)
+
+#define UART16550_READ(y) readl(KSEG1ADDR(AR71XX_UART_BASE+y))
+#define UART16550_WRITE(x, z) writel(z, KSEG1ADDR((AR71XX_UART_BASE+x)))
+
+void
+ar71xx_sys_frequency(u32 *cpu_freq, u32 *ddr_freq, u32 *ahb_freq)
+{
+#ifndef CONFIG_AR91XX
+ u32 pll, pll_div, cpu_div, ahb_div, ddr_div, freq;
+
+ pll = readl(KSEG1ADDR(AR71XX_PLL_REG_CPU_CONFIG + AR71XX_PLL_BASE));
+
+ pll_div =
+ ((pll & AR71XX_PLL_DIV_MASK) >> AR71XX_PLL_DIV_SHIFT) + 1;
+
+ cpu_div =
+ ((pll & AR71XX_CPU_DIV_MASK) >> AR71XX_CPU_DIV_SHIFT) + 1;
+
+ ddr_div =
+ ((pll & AR71XX_DDR_DIV_MASK) >> AR71XX_DDR_DIV_SHIFT) + 1;
+
+ ahb_div =
+ (((pll & AR71XX_AHB_DIV_MASK) >> AR71XX_AHB_DIV_SHIFT) + 1)*2;
+
+ freq = pll_div * 40000000;
+
+ if (cpu_freq)
+ *cpu_freq = freq/cpu_div;
+
+ if (ddr_freq)
+ *ddr_freq = freq/ddr_div;
+
+ if (ahb_freq)
+ *ahb_freq = (freq/cpu_div)/ahb_div;
+
+#else
+ u32 pll, pll_div, ahb_div, ddr_div, freq;
+
+ pll = readl(KSEG1ADDR(AR91XX_PLL_REG_CPU_CONFIG + AR71XX_PLL_BASE));
+
+ pll_div =
+ ((pll & AR91XX_PLL_DIV_MASK) >> AR91XX_PLL_DIV_SHIFT);
+
+ ddr_div =
+ ((pll & AR91XX_DDR_DIV_MASK) >> AR91XX_DDR_DIV_SHIFT) + 1;
+
+ ahb_div =
+ (((pll & AR91XX_AHB_DIV_MASK) >> AR91XX_AHB_DIV_SHIFT) + 1)*2;
+
+ freq = pll_div * 5000000;
+
+ if (cpu_freq)
+ *cpu_freq = freq;
+
+ if (ddr_freq)
+ *ddr_freq = freq/ddr_div;
+
+ if (ahb_freq)
+ *ahb_freq = freq/ahb_div;
+#endif
+}
+
+
+int serial_init(void)
+{
+ u32 div;
+ u32 ahb_freq = 100000000;
+
+ ar71xx_sys_frequency (0, 0, &ahb_freq);
+ div = ahb_freq/(16 * CONFIG_BAUDRATE);
+
+ // enable uart pins
+#ifndef CONFIG_AR91XX
+ writel(AR71XX_GPIO_FUNC_UART_EN, KSEG1ADDR(AR71XX_GPIO_BASE + GPIO_REG_FUNC));
+#else
+ writel(AR91XX_GPIO_FUNC_UART_EN, KSEG1ADDR(AR71XX_GPIO_BASE + GPIO_REG_FUNC));
+#endif
+
+ /* set DIAB bit */
+ UART16550_WRITE(OFS_LINE_CONTROL, 0x80);
+
+ /* set divisor */
+ UART16550_WRITE(OFS_DIVISOR_LSB, (div & 0xff));
+ UART16550_WRITE(OFS_DIVISOR_MSB, ((div >> 8) & 0xff));
+
+ /* clear DIAB bit*/
+ UART16550_WRITE(OFS_LINE_CONTROL, 0x00);
+
+ /* set data format */
+ UART16550_WRITE(OFS_DATA_FORMAT, 0x3);
+
+ UART16550_WRITE(OFS_INTR_ENABLE, 0);
+
+ return 0;
+}
+
+int serial_tstc (void)
+{
+ return(UART16550_READ(OFS_LINE_STATUS) & 0x1);
+}
+
+int serial_getc(void)
+{
+ while(!serial_tstc());
+
+ return UART16550_READ(OFS_RCV_BUFFER);
+}
+
+
+void serial_putc(const char byte)
+{
+ if (byte == '\n') serial_putc ('\r');
+
+ while (((UART16550_READ(OFS_LINE_STATUS)) & 0x20) == 0x0);
+ UART16550_WRITE(OFS_SEND_BUFFER, byte);
+}
+
+void serial_setbrg (void)
+{
+}
+
+void serial_puts (const char *s)
+{
+ while (*s)
+ {
+ serial_putc (*s++);
+ }
+}
diff --git a/package/boot/uboot-ar71xx/files/cpu/mips/ar71xx_serial.c b/package/boot/uboot-ar71xx/files/cpu/mips/ar71xx_serial.c
new file mode 100644
index 0000000..f093318
--- /dev/null
+++ b/package/boot/uboot-ar71xx/files/cpu/mips/ar71xx_serial.c
@@ -0,0 +1,177 @@
+/*
+ * (C) Copyright 2010
+ * Michael Kurz <michi.kurz@googlemail.com>.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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 of
+ * the License, 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <asm/addrspace.h>
+#include <asm/types.h>
+#include <config.h>
+#include <asm/ar71xx.h>
+
+#define REG_SIZE 4
+
+/* === END OF CONFIG === */
+
+/* register offset */
+#define OFS_RCV_BUFFER (0*REG_SIZE)
+#define OFS_TRANS_HOLD (0*REG_SIZE)
+#define OFS_SEND_BUFFER (0*REG_SIZE)
+#define OFS_INTR_ENABLE (1*REG_SIZE)
+#define OFS_INTR_ID (2*REG_SIZE)
+#define OFS_DATA_FORMAT (3*REG_SIZE)
+#define OFS_LINE_CONTROL (3*REG_SIZE)
+#define OFS_MODEM_CONTROL (4*REG_SIZE)
+#define OFS_RS232_OUTPUT (4*REG_SIZE)
+#define OFS_LINE_STATUS (5*REG_SIZE)
+#define OFS_MODEM_STATUS (6*REG_SIZE)
+#define OFS_RS232_INPUT (6*REG_SIZE)
+#define OFS_SCRATCH_PAD (7*REG_SIZE)
+
+#define OFS_DIVISOR_LSB (0*REG_SIZE)
+#define OFS_DIVISOR_MSB (1*REG_SIZE)
+
+#define UART16550_READ(y) readl(KSEG1ADDR(AR71XX_UART_BASE+y))
+#define UART16550_WRITE(x, z) writel(z, KSEG1ADDR((AR71XX_UART_BASE+x)))
+
+void
+ar71xx_sys_frequency(u32 *cpu_freq, u32 *ddr_freq, u32 *ahb_freq)
+{
+#ifndef CONFIG_AR91XX
+ u32 pll, pll_div, cpu_div, ahb_div, ddr_div, freq;
+
+ pll = readl(KSEG1ADDR(AR71XX_PLL_REG_CPU_CONFIG + AR71XX_PLL_BASE));
+
+ pll_div =
+ ((pll & AR71XX_PLL_DIV_MASK) >> AR71XX_PLL_DIV_SHIFT) + 1;
+
+ cpu_div =
+ ((pll & AR71XX_CPU_DIV_MASK) >> AR71XX_CPU_DIV_SHIFT) + 1;
+
+ ddr_div =
+ ((pll & AR71XX_DDR_DIV_MASK) >> AR71XX_DDR_DIV_SHIFT) + 1;
+
+ ahb_div =
+ (((pll & AR71XX_AHB_DIV_MASK) >> AR71XX_AHB_DIV_SHIFT) + 1)*2;
+
+ freq = pll_div * 40000000;
+
+ if (cpu_freq)
+ *cpu_freq = freq/cpu_div;
+
+ if (ddr_freq)
+ *ddr_freq = freq/ddr_div;
+
+ if (ahb_freq)
+ *ahb_freq = (freq/cpu_div)/ahb_div;
+
+#else
+ u32 pll, pll_div, ahb_div, ddr_div, freq;
+
+ pll = readl(KSEG1ADDR(AR91XX_PLL_REG_CPU_CONFIG + AR71XX_PLL_BASE));
+
+ pll_div =
+ ((pll & AR91XX_PLL_DIV_MASK) >> AR91XX_PLL_DIV_SHIFT);
+
+ ddr_div =
+ ((pll & AR91XX_DDR_DIV_MASK) >> AR91XX_DDR_DIV_SHIFT) + 1;
+
+ ahb_div =
+ (((pll & AR91XX_AHB_DIV_MASK) >> AR91XX_AHB_DIV_SHIFT) + 1)*2;
+
+ freq = pll_div * 5000000;
+
+ if (cpu_freq)
+ *cpu_freq = freq;
+
+ if (ddr_freq)
+ *ddr_freq = freq/ddr_div;
+
+ if (ahb_freq)
+ *ahb_freq = freq/ahb_div;
+#endif
+}
+
+
+int serial_init(void)
+{
+ u32 div;
+ u32 ahb_freq = 100000000;
+
+ ar71xx_sys_frequency (0, 0, &ahb_freq);
+ div = ahb_freq/(16 * CONFIG_BAUDRATE);
+
+ // enable uart pins
+#ifndef CONFIG_AR91XX
+ writel(AR71XX_GPIO_FUNC_UART_EN, KSEG1ADDR(AR71XX_GPIO_BASE + GPIO_REG_FUNC));
+#else
+ writel(AR91XX_GPIO_FUNC_UART_EN, KSEG1ADDR(AR71XX_GPIO_BASE + GPIO_REG_FUNC));
+#endif
+
+ /* set DIAB bit */
+ UART16550_WRITE(OFS_LINE_CONTROL, 0x80);
+
+ /* set divisor */
+ UART16550_WRITE(OFS_DIVISOR_LSB, (div & 0xff));
+ UART16550_WRITE(OFS_DIVISOR_MSB, ((div >> 8) & 0xff));
+
+ /* clear DIAB bit*/
+ UART16550_WRITE(OFS_LINE_CONTROL, 0x00);
+
+ /* set data format */
+ UART16550_WRITE(OFS_DATA_FORMAT, 0x3);
+
+ UART16550_WRITE(OFS_INTR_ENABLE, 0);
+
+ return 0;
+}
+
+int serial_tstc (void)
+{
+ return(UART16550_READ(OFS_LINE_STATUS) & 0x1);
+}
+
+int serial_getc(void)
+{
+ while(!serial_tstc());
+
+ return UART16550_READ(OFS_RCV_BUFFER);
+}
+
+
+void serial_putc(const char byte)
+{
+ if (byte == '\n') serial_putc ('\r');
+
+ while (((UART16550_READ(OFS_LINE_STATUS)) & 0x20) == 0x0);
+ UART16550_WRITE(OFS_SEND_BUFFER, byte);
+}
+
+void serial_setbrg (void)
+{
+}
+
+void serial_puts (const char *s)
+{
+ while (*s)
+ {
+ serial_putc (*s++);
+ }
+}
diff --git a/package/boot/uboot-ar71xx/files/drivers/.svn/entries b/package/boot/uboot-ar71xx/files/drivers/.svn/entries
new file mode 100644
index 0000000..47154e2
--- /dev/null
+++ b/package/boot/uboot-ar71xx/files/drivers/.svn/entries
@@ -0,0 +1,34 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/uboot-ar71xx/files/drivers
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+net
+dir
+
+spi
+dir
+
diff --git a/package/boot/uboot-ar71xx/files/drivers/net/.svn/entries b/package/boot/uboot-ar71xx/files/drivers/net/.svn/entries
new file mode 100644
index 0000000..66da141
--- /dev/null
+++ b/package/boot/uboot-ar71xx/files/drivers/net/.svn/entries
@@ -0,0 +1,99 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/uboot-ar71xx/files/drivers/net
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+phy
+dir
+
+ag71xx.c
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+6e570423f54b0897dd2636e34c017bda
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+19204
+
+ag71xx.h
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+a50b2a6d1638274b6bd66f8718d059e3
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+10463
+
diff --git a/package/boot/uboot-ar71xx/files/drivers/net/.svn/prop-base/ag71xx.c.svn-base b/package/boot/uboot-ar71xx/files/drivers/net/.svn/prop-base/ag71xx.c.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/boot/uboot-ar71xx/files/drivers/net/.svn/prop-base/ag71xx.c.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/boot/uboot-ar71xx/files/drivers/net/.svn/prop-base/ag71xx.h.svn-base b/package/boot/uboot-ar71xx/files/drivers/net/.svn/prop-base/ag71xx.h.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/boot/uboot-ar71xx/files/drivers/net/.svn/prop-base/ag71xx.h.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/boot/uboot-ar71xx/files/drivers/net/.svn/text-base/ag71xx.c.svn-base b/package/boot/uboot-ar71xx/files/drivers/net/.svn/text-base/ag71xx.c.svn-base
new file mode 100644
index 0000000..b3324c0
--- /dev/null
+++ b/package/boot/uboot-ar71xx/files/drivers/net/.svn/text-base/ag71xx.c.svn-base
@@ -0,0 +1,809 @@
+/*
+ * Atheros AR71xx built-in ethernet mac driver
+ *
+ * Copyright (C) 2010 Michael Kurz <michi.kurz@googlemail.com>
+ * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
+ * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
+ *
+ * Based on Atheros' AG7100 driver
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ */
+
+#include <common.h>
+#include <malloc.h>
+#include <net.h>
+#include <miiphy.h>
+
+#include <asm/ar71xx.h>
+
+#include "ag71xx.h"
+
+#ifdef AG71XX_DEBUG
+#define DBG(fmt,args...) printf(fmt ,##args)
+#else
+#define DBG(fmt,args...)
+#endif
+
+
+static struct ag71xx agtable[] = {
+ {
+ .mac_base = KSEG1ADDR(AR71XX_GE0_BASE),
+ .mii_ctrl = KSEG1ADDR(AR71XX_MII_BASE + MII_REG_MII0_CTRL),
+ .mii_if = CONFIG_AG71XX_MII0_IIF,
+ } , {
+ .mac_base = KSEG1ADDR(AR71XX_GE1_BASE),
+ .mii_ctrl = KSEG1ADDR(AR71XX_MII_BASE + MII_REG_MII1_CTRL),
+ .mii_if = CONFIG_AG71XX_MII1_IIF,
+ }
+};
+
+static int ag71xx_ring_alloc(struct ag71xx_ring *ring, unsigned int size)
+{
+ int err;
+ int i;
+ int rsize;
+
+ ring->desc_size = sizeof(struct ag71xx_desc);
+ if (ring->desc_size % (CONFIG_SYS_CACHELINE_SIZE)) {
+ rsize = roundup(ring->desc_size, CONFIG_SYS_CACHELINE_SIZE);
+ DBG("ag71xx: ring %p, desc size %u rounded to %u\n",
+ ring, ring->desc_size,
+ rsize);
+ ring->desc_size = rsize;
+ }
+
+ ring->descs_cpu = (u8 *) malloc((size * ring->desc_size)
+ + CONFIG_SYS_CACHELINE_SIZE - 1);
+ if (!ring->descs_cpu) {
+ err = -1;
+ goto err;
+ }
+ ring->descs_cpu = (u8 *) UNCACHED_SDRAM((((u32) ring->descs_cpu +
+ CONFIG_SYS_CACHELINE_SIZE - 1) & ~(CONFIG_SYS_CACHELINE_SIZE - 1)));
+ ring->descs_dma = (u8 *) virt_to_phys(ring->descs_cpu);
+
+ ring->size = size;
+
+ ring->buf = malloc(size * sizeof(*ring->buf));
+ if (!ring->buf) {
+ err = -1;
+ goto err;
+ }
+ memset(ring->buf, 0, size * sizeof(*ring->buf));
+
+ for (i = 0; i < size; i++) {
+ ring->buf[i].desc =
+ (struct ag71xx_desc *)&ring->descs_cpu[i * ring->desc_size];
+ DBG("ag71xx: ring %p, desc %d at %p\n",
+ ring, i, ring->buf[i].desc);
+ }
+
+ flush_cache( (u32) ring->buf, size * sizeof(*ring->buf));
+
+ return 0;
+
+ err:
+ return err;
+}
+
+static void ag71xx_ring_tx_init(struct ag71xx *ag)
+{
+ struct ag71xx_ring *ring = &ag->tx_ring;
+ int i;
+
+ for (i = 0; i < AG71XX_TX_RING_SIZE; i++) {
+ ring->buf[i].desc->next = (u32) virt_to_phys((ring->descs_dma +
+ ring->desc_size * ((i + 1) % AG71XX_TX_RING_SIZE)));
+
+ ring->buf[i].desc->ctrl = DESC_EMPTY;
+ ring->buf[i].skb = NULL;
+ }
+
+ ring->curr = 0;
+}
+
+static void ag71xx_ring_rx_clean(struct ag71xx *ag)
+{
+ struct ag71xx_ring *ring = &ag->rx_ring;
+ int i;
+
+ if (!ring->buf)
+ return;
+
+ for (i = 0; i < AG71XX_RX_RING_SIZE; i++) {
+ ring->buf[i].desc->data = (u32) virt_to_phys(NetRxPackets[i]);
+ flush_cache((u32) NetRxPackets[i], PKTSIZE_ALIGN);
+ ring->buf[i].desc->ctrl = DESC_EMPTY;
+ }
+
+ ring->curr = 0;
+}
+
+static int ag71xx_ring_rx_init(struct ag71xx *ag)
+{
+ struct ag71xx_ring *ring = &ag->rx_ring;
+ unsigned int i;
+
+ for (i = 0; i < AG71XX_RX_RING_SIZE; i++) {
+ ring->buf[i].desc->next = (u32) virt_to_phys((ring->descs_dma +
+ ring->desc_size * ((i + 1) % AG71XX_RX_RING_SIZE)));
+
+ DBG("ag71xx: RX desc at %p, next is %08x\n",
+ ring->buf[i].desc,
+ ring->buf[i].desc->next);
+ }
+
+ for (i = 0; i < AG71XX_RX_RING_SIZE; i++) {
+ ring->buf[i].desc->data = (u32) virt_to_phys(NetRxPackets[i]);
+ ring->buf[i].desc->ctrl = DESC_EMPTY;
+ }
+
+ ring->curr = 0;
+
+ return 0;
+}
+
+static int ag71xx_rings_init(struct ag71xx *ag)
+{
+ int ret;
+
+ ret = ag71xx_ring_alloc(&ag->tx_ring, AG71XX_TX_RING_SIZE);
+ if (ret)
+ return ret;
+
+ ag71xx_ring_tx_init(ag);
+
+ ret = ag71xx_ring_alloc(&ag->rx_ring, AG71XX_RX_RING_SIZE);
+ if (ret)
+ return ret;
+
+ ret = ag71xx_ring_rx_init(ag);
+ return ret;
+}
+
+static void ar71xx_set_pll(u32 cfg_reg, u32 pll_reg, u32 pll_val, u32 shift)
+{
+ uint32_t base = KSEG1ADDR(AR71XX_PLL_BASE);
+ u32 t;
+
+ t = readl(base + cfg_reg);
+ t &= ~(3 << shift);
+ t |= (2 << shift);
+ writel(t, base + cfg_reg);
+ udelay(100);
+
+ writel(pll_val, base + pll_reg);
+
+ t |= (3 << shift);
+ writel(t, base + cfg_reg);
+ udelay(100);
+
+ t &= ~(3 << shift);
+ writel(t, base + cfg_reg);
+ udelay(100);
+
+ debug("ar71xx: pll_reg %#x: %#x\n", (unsigned int)(base + pll_reg),
+ readl(base + pll_reg));
+}
+
+static void ar91xx_set_pll_ge0(int speed)
+{
+ //u32 val = ar71xx_get_eth_pll(0, speed);
+ u32 pll_val;
+
+ switch (speed) {
+ case SPEED_10:
+ pll_val = 0x00441099;
+ break;
+ case SPEED_100:
+ pll_val = 0x13000a44;
+ break;
+ case SPEED_1000:
+ pll_val = 0x1a000000;
+ break;
+ default:
+ BUG();
+ }
+
+ ar71xx_set_pll(AR91XX_PLL_REG_ETH_CONFIG, AR91XX_PLL_REG_ETH0_INT_CLOCK,
+ pll_val, AR91XX_ETH0_PLL_SHIFT);
+}
+
+static void ar91xx_set_pll_ge1(int speed)
+{
+ //u32 val = ar71xx_get_eth_pll(1, speed);
+ u32 pll_val;
+
+ switch (speed) {
+ case SPEED_10:
+ pll_val = 0x00441099;
+ break;
+ case SPEED_100:
+ pll_val = 0x13000a44;
+ break;
+ case SPEED_1000:
+ pll_val = 0x1a000000;
+ break;
+ default:
+ BUG();
+ }
+
+ ar71xx_set_pll(AR91XX_PLL_REG_ETH_CONFIG, AR91XX_PLL_REG_ETH1_INT_CLOCK,
+ pll_val, AR91XX_ETH1_PLL_SHIFT);
+}
+
+static void ag71xx_hw_set_macaddr(struct ag71xx *ag, unsigned char *mac)
+{
+ u32 t;
+
+ t = (((u32) mac[5]) << 24) | (((u32) mac[4]) << 16)
+ | (((u32) mac[3]) << 8) | ((u32) mac[2]);
+
+ ag71xx_wr(ag, AG71XX_REG_MAC_ADDR1, t);
+
+ t = (((u32) mac[1]) << 24) | (((u32) mac[0]) << 16);
+ ag71xx_wr(ag, AG71XX_REG_MAC_ADDR2, t);
+}
+
+static void ag71xx_dma_reset(struct ag71xx *ag)
+{
+ u32 val;
+ int i;
+
+ DBG("%s: txdesc reg: 0x%08x rxdesc reg: 0x%08x\n",
+ ag->dev->name,
+ ag71xx_rr(ag, AG71XX_REG_TX_DESC),
+ ag71xx_rr(ag, AG71XX_REG_RX_DESC));
+
+ /* stop RX and TX */
+ ag71xx_wr(ag, AG71XX_REG_RX_CTRL, 0);
+ ag71xx_wr(ag, AG71XX_REG_TX_CTRL, 0);
+
+ /* clear descriptor addresses */
+ ag71xx_wr(ag, AG71XX_REG_TX_DESC, 0);
+ ag71xx_wr(ag, AG71XX_REG_RX_DESC, 0);
+
+ /* clear pending RX/TX interrupts */
+ for (i = 0; i < 256; i++) {
+ ag71xx_wr(ag, AG71XX_REG_RX_STATUS, RX_STATUS_PR);
+ ag71xx_wr(ag, AG71XX_REG_TX_STATUS, TX_STATUS_PS);
+ }
+
+ /* clear pending errors */
+ ag71xx_wr(ag, AG71XX_REG_RX_STATUS, RX_STATUS_BE | RX_STATUS_OF);
+ ag71xx_wr(ag, AG71XX_REG_TX_STATUS, TX_STATUS_BE | TX_STATUS_UR);
+
+ val = ag71xx_rr(ag, AG71XX_REG_RX_STATUS);
+ if (val)
+ printf("%s: unable to clear DMA Rx status: %08x\n",
+ ag->dev->name, val);
+
+ val = ag71xx_rr(ag, AG71XX_REG_TX_STATUS);
+
+ /* mask out reserved bits */
+ val &= ~0xff000000;
+
+ if (val)
+ printf("%s: unable to clear DMA Tx status: %08x\n",
+ ag->dev->name, val);
+}
+
+static void ag71xx_halt(struct eth_device *dev)
+{
+ struct ag71xx *ag = (struct ag71xx *) dev->priv;
+
+ /* stop RX engine */
+ ag71xx_wr(ag, AG71XX_REG_RX_CTRL, 0);
+
+ ag71xx_dma_reset(ag);
+}
+
+#define MAX_WAIT 1000
+
+static int ag71xx_send(struct eth_device *dev, volatile void *packet,
+ int length)
+{
+ struct ag71xx *ag = (struct ag71xx *) dev->priv;
+ struct ag71xx_ring *ring = &ag->tx_ring;
+ struct ag71xx_desc *desc;
+ int i;
+
+ i = ring->curr % AG71XX_TX_RING_SIZE;
+ desc = ring->buf[i].desc;
+
+ if (!ag71xx_desc_empty(desc)) {
+ printf("%s: tx buffer full\n", ag->dev->name);
+ return 1;
+ }
+
+ flush_cache((u32) packet, length);
+ desc->data = (u32) virt_to_phys(packet);
+ desc->ctrl = (length & DESC_PKTLEN_M);
+
+ DBG("%s: sending %#08x length %#08x\n",
+ ag->dev->name, desc->data, desc->ctrl);
+
+ ring->curr++;
+ if (ring->curr >= AG71XX_TX_RING_SIZE){
+ ring->curr = 0;
+ }
+
+ /* enable TX engine */
+ ag71xx_wr(ag, AG71XX_REG_TX_CTRL, TX_CTRL_TXE);
+
+ for (i = 0; i < MAX_WAIT; i++)
+ {
+ if (ag71xx_desc_empty(desc))
+ break;
+ udelay(10);
+ }
+ if (i == MAX_WAIT) {
+ printf("%s: tx timed out!\n", ag->dev->name);
+ return -1;
+ }
+
+ /* disable TX engine */
+ ag71xx_wr(ag, AG71XX_REG_TX_CTRL, 0);
+ desc->data = 0;
+ desc->ctrl = DESC_EMPTY;
+
+ return 0;
+}
+
+static int ag71xx_recv(struct eth_device *dev)
+{
+ struct ag71xx *ag = (struct ag71xx *) dev->priv;
+ struct ag71xx_ring *ring = &ag->rx_ring;
+
+ for (;;) {
+ unsigned int i = ring->curr % AG71XX_RX_RING_SIZE;
+ struct ag71xx_desc *desc = ring->buf[i].desc;
+ int pktlen;
+
+ if (ag71xx_desc_empty(desc))
+ break;
+
+ DBG("%s: rx packets, curr=%u\n", dev->name, ring->curr);
+
+ pktlen = ag71xx_desc_pktlen(desc);
+ pktlen -= ETH_FCS_LEN;
+
+
+ NetReceive(NetRxPackets[i] , pktlen);
+ flush_cache( (u32) NetRxPackets[i], PKTSIZE_ALIGN);
+
+ ring->buf[i].desc->ctrl = DESC_EMPTY;
+ ring->curr++;
+ if (ring->curr >= AG71XX_RX_RING_SIZE){
+ ring->curr = 0;
+ }
+
+ }
+
+ if ((ag71xx_rr(ag, AG71XX_REG_RX_CTRL) & RX_CTRL_RXE) == 0) {
+ /* start RX engine */
+ ag71xx_wr(ag, AG71XX_REG_RX_CTRL, RX_CTRL_RXE);
+ }
+
+ return 0;
+}
+
+#ifdef AG71XX_DEBUG
+static char *ag71xx_speed_str(struct ag71xx *ag)
+{
+ switch (ag->speed) {
+ case SPEED_1000:
+ return "1000";
+ case SPEED_100:
+ return "100";
+ case SPEED_10:
+ return "10";
+ }
+
+ return "?";
+}
+#endif
+
+void ag71xx_link_adjust(struct ag71xx *ag)
+{
+ u32 cfg2;
+ u32 ifctl;
+ u32 fifo5;
+ u32 mii_speed;
+
+ if (!ag->link) {
+ DBG("%s: link down\n", ag->dev->name);
+ return;
+ }
+
+ cfg2 = ag71xx_rr(ag, AG71XX_REG_MAC_CFG2);
+ cfg2 &= ~(MAC_CFG2_IF_1000 | MAC_CFG2_IF_10_100 | MAC_CFG2_FDX);
+ cfg2 |= (ag->duplex) ? MAC_CFG2_FDX : 0;
+
+ ifctl = ag71xx_rr(ag, AG71XX_REG_MAC_IFCTL);
+ ifctl &= ~(MAC_IFCTL_SPEED);
+
+ fifo5 = ag71xx_rr(ag, AG71XX_REG_FIFO_CFG5);
+ fifo5 &= ~FIFO_CFG5_BM;
+
+ switch (ag->speed) {
+ case SPEED_1000:
+ mii_speed = MII_CTRL_SPEED_1000;
+ cfg2 |= MAC_CFG2_IF_1000;
+ fifo5 |= FIFO_CFG5_BM;
+ break;
+ case SPEED_100:
+ mii_speed = MII_CTRL_SPEED_100;
+ cfg2 |= MAC_CFG2_IF_10_100;
+ ifctl |= MAC_IFCTL_SPEED;
+ break;
+ case SPEED_10:
+ mii_speed = MII_CTRL_SPEED_10;
+ cfg2 |= MAC_CFG2_IF_10_100;
+ break;
+ default:
+ BUG();
+ return;
+ }
+
+ ag71xx_wr(ag, AG71XX_REG_FIFO_CFG3, 0x00780fff);
+
+ if (ag->macNum == 0)
+ ar91xx_set_pll_ge0(ag->speed);
+ else
+ ar91xx_set_pll_ge1(ag->speed);
+
+ ag71xx_mii_ctrl_set_speed(ag, mii_speed);
+
+ ag71xx_wr(ag, AG71XX_REG_MAC_CFG2, cfg2);
+ ag71xx_wr(ag, AG71XX_REG_FIFO_CFG5, fifo5);
+ ag71xx_wr(ag, AG71XX_REG_MAC_IFCTL, ifctl);
+
+ DBG("%s: link up (%sMbps/%s duplex)\n",
+ ag->dev->name,
+ ag71xx_speed_str(ag),
+ (1 == ag->duplex) ? "Full" : "Half");
+
+ DBG("%s: fifo_cfg0=%#x, fifo_cfg1=%#x, fifo_cfg2=%#x\n",
+ ag->dev->name,
+ ag71xx_rr(ag, AG71XX_REG_FIFO_CFG0),
+ ag71xx_rr(ag, AG71XX_REG_FIFO_CFG1),
+ ag71xx_rr(ag, AG71XX_REG_FIFO_CFG2));
+
+ DBG("%s: fifo_cfg3=%#x, fifo_cfg4=%#x, fifo_cfg5=%#x\n",
+ ag->dev->name,
+ ag71xx_rr(ag, AG71XX_REG_FIFO_CFG3),
+ ag71xx_rr(ag, AG71XX_REG_FIFO_CFG4),
+ ag71xx_rr(ag, AG71XX_REG_FIFO_CFG5));
+
+ DBG("%s: mac_cfg2=%#x, mac_ifctl=%#x, mii_ctrl=%#x\n",
+ ag->dev->name,
+ ag71xx_rr(ag, AG71XX_REG_MAC_CFG2),
+ ag71xx_rr(ag, AG71XX_REG_MAC_IFCTL),
+ ag71xx_mii_ctrl_rr(ag));
+}
+
+#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
+static int ag71xx_getMiiSpeed(struct ag71xx *ag)
+{
+ uint16_t phyreg, cap;
+
+ if (miiphy_read(ag->phyname, ag->phyid,
+ PHY_BMSR, &phyreg)) {
+ puts("PHY_BMSR read failed, assuming no link\n");
+ return -1;
+ }
+
+ if ((phyreg & PHY_BMSR_LS) == 0) {
+ return -1;
+ }
+
+ if (miiphy_read(ag->phyname, ag->phyid,
+ PHY_1000BTSR, &phyreg))
+ return -1;
+
+ if (phyreg & PHY_1000BTSR_1000FD) {
+ ag->speed = SPEED_1000;
+ ag->duplex = 1;
+ } else if (phyreg & PHY_1000BTSR_1000HD) {
+ ag->speed = SPEED_1000;
+ ag->duplex = 0;
+ } else {
+ if (miiphy_read(ag->phyname, ag->phyid,
+ PHY_ANAR, &cap))
+ return -1;
+
+ if (miiphy_read(ag->phyname, ag->phyid,
+ PHY_ANLPAR, &phyreg))
+ return -1;
+
+ cap &= phyreg;
+ if (cap & PHY_ANLPAR_TXFD) {
+ ag->speed = SPEED_100;
+ ag->duplex = 1;
+ } else if (cap & PHY_ANLPAR_TX) {
+ ag->speed = SPEED_100;
+ ag->duplex = 0;
+ } else if (cap & PHY_ANLPAR_10FD) {
+ ag->speed = SPEED_10;
+ ag->duplex = 1;
+ } else {
+ ag->speed = SPEED_10;
+ ag->duplex = 0;
+ }
+ }
+
+ ag->link = 1;
+
+ return 0;
+}
+#endif
+
+static int ag71xx_hw_start(struct eth_device *dev, bd_t * bd)
+{
+ struct ag71xx *ag = (struct ag71xx *) dev->priv;
+
+ ag71xx_dma_reset(ag);
+
+ ag71xx_ring_rx_clean(ag);
+ ag71xx_ring_tx_init(ag);
+
+ ag71xx_wr(ag, AG71XX_REG_TX_DESC,
+ (u32) virt_to_phys(ag->tx_ring.descs_dma));
+ ag71xx_wr(ag, AG71XX_REG_RX_DESC,
+ (u32) virt_to_phys(ag->rx_ring.descs_dma));
+
+ ag71xx_hw_set_macaddr(ag, ag->dev->enetaddr);
+
+ if (ag->phyfixed) {
+ ag->link = 1;
+ ag->duplex = 1;
+ ag->speed = SPEED_1000;
+ } else {
+
+#if (defined(CONFIG_MII) || defined(CONFIG_CMD_MII))
+ if (ag71xx_getMiiSpeed(ag))
+ return -1;
+#else
+ /* only fixed, without mii */
+ return -1;
+#endif
+
+ }
+ ag71xx_link_adjust(ag);
+
+ DBG("%s: txdesc reg: %#08x rxdesc reg: %#08x\n",
+ ag->dev->name,
+ ag71xx_rr(ag, AG71XX_REG_TX_DESC),
+ ag71xx_rr(ag, AG71XX_REG_RX_DESC));
+
+ /* start RX engine */
+ ag71xx_wr(ag, AG71XX_REG_RX_CTRL, RX_CTRL_RXE);
+
+ return 0;
+}
+
+#define FIFO_CFG0_INIT (FIFO_CFG0_ALL << FIFO_CFG0_ENABLE_SHIFT)
+
+#define FIFO_CFG4_INIT (FIFO_CFG4_DE | FIFO_CFG4_DV | FIFO_CFG4_FC | \
+ FIFO_CFG4_CE | FIFO_CFG4_CR | FIFO_CFG4_LM | \
+ FIFO_CFG4_LO | FIFO_CFG4_OK | FIFO_CFG4_MC | \
+ FIFO_CFG4_BC | FIFO_CFG4_DR | FIFO_CFG4_LE | \
+ FIFO_CFG4_CF | FIFO_CFG4_PF | FIFO_CFG4_UO | \
+ FIFO_CFG4_VT)
+
+#define FIFO_CFG5_INIT (FIFO_CFG5_DE | FIFO_CFG5_DV | FIFO_CFG5_FC | \
+ FIFO_CFG5_CE | FIFO_CFG5_LO | FIFO_CFG5_OK | \
+ FIFO_CFG5_MC | FIFO_CFG5_BC | FIFO_CFG5_DR | \
+ FIFO_CFG5_CF | FIFO_CFG5_PF | FIFO_CFG5_VT | \
+ FIFO_CFG5_LE | FIFO_CFG5_FT | FIFO_CFG5_16 | \
+ FIFO_CFG5_17 | FIFO_CFG5_SF)
+
+static int ag71xx_hw_init(struct ag71xx *ag)
+{
+ int ret = 0;
+ uint32_t reg;
+ uint32_t mask, mii_type;
+
+ if (ag->macNum == 0) {
+ mask = (RESET_MODULE_GE0_MAC | RESET_MODULE_GE0_PHY);
+ mii_type = 0x13;
+ } else {
+ mask = (RESET_MODULE_GE1_MAC | RESET_MODULE_GE1_PHY);
+ mii_type = 0x11;
+ }
+
+ // mac soft reset
+ ag71xx_sb(ag, AG71XX_REG_MAC_CFG1, MAC_CFG1_SR);
+ udelay(20);
+
+ // device stop
+ reg = ar71xx_reset_rr(AR91XX_RESET_REG_RESET_MODULE);
+ ar71xx_reset_wr(AR91XX_RESET_REG_RESET_MODULE, reg | mask);
+ udelay(100 * 1000);
+
+ // device start
+ reg = ar71xx_reset_rr(AR91XX_RESET_REG_RESET_MODULE);
+ ar71xx_reset_wr(AR91XX_RESET_REG_RESET_MODULE, reg & ~mask);
+ udelay(100 * 1000);
+
+ /* setup MAC configuration registers */
+ ag71xx_wr(ag, AG71XX_REG_MAC_CFG1, (MAC_CFG1_RXE | MAC_CFG1_TXE));
+
+ ag71xx_sb(ag, AG71XX_REG_MAC_CFG2,
+ MAC_CFG2_PAD_CRC_EN | MAC_CFG2_LEN_CHECK);
+
+ /* setup FIFO configuration register 0 */
+ ag71xx_wr(ag, AG71XX_REG_FIFO_CFG0, FIFO_CFG0_INIT);
+
+ /* setup MII interface type */
+ ag71xx_mii_ctrl_set_if(ag, ag->mii_if);
+
+ /* setup mdio clock divisor */
+ ag71xx_wr(ag, AG71XX_REG_MII_CFG, MII_CFG_CLK_DIV_20);
+
+ /* setup FIFO configuration registers */
+ ag71xx_sb(ag, AG71XX_REG_FIFO_CFG4, FIFO_CFG4_INIT);
+ ag71xx_wr(ag, AG71XX_REG_FIFO_CFG1, 0x0fff0000);
+ ag71xx_wr(ag, AG71XX_REG_FIFO_CFG2, 0x00001fff);
+ ag71xx_wr(ag, AG71XX_REG_FIFO_CFG5, FIFO_CFG5_INIT);
+
+ ag71xx_dma_reset(ag);
+
+ ret = ag71xx_rings_init(ag);
+ if (ret)
+ return -1;
+
+ ag71xx_wr(ag, AG71XX_REG_TX_DESC,
+ (u32) virt_to_phys(ag->tx_ring.descs_dma));
+ ag71xx_wr(ag, AG71XX_REG_RX_DESC,
+ (u32) virt_to_phys(ag->rx_ring.descs_dma));
+
+ ag71xx_hw_set_macaddr(ag, ag->dev->enetaddr);
+
+ return 0;
+}
+
+#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
+#define AG71XX_MDIO_RETRY 1000
+#define AG71XX_MDIO_DELAY 5
+
+static inline struct ag71xx *ag71xx_name2mac(char *devname)
+{
+ if (strcmp(devname, agtable[0].dev->name) == 0)
+ return &agtable[0];
+ else if (strcmp(devname, agtable[1].dev->name) == 0)
+ return &agtable[1];
+ else
+ return NULL;
+}
+
+static inline void ag71xx_mdio_wr(struct ag71xx *ag, unsigned reg,
+ u32 value)
+{
+ uint32_t r;
+
+ r = ag->mac_base + reg;
+ writel(value, r);
+
+ /* flush write */
+ (void) readl(r);
+}
+
+static inline u32 ag71xx_mdio_rr(struct ag71xx *ag, unsigned reg)
+{
+ return readl(ag->mac_base + reg);
+}
+
+static int ag71xx_mdio_read(char *devname, unsigned char addr,
+ unsigned char reg, unsigned short *val)
+{
+ struct ag71xx *ag = ag71xx_name2mac(devname);
+ uint16_t regData;
+ int i;
+
+ ag71xx_mdio_wr(ag, AG71XX_REG_MII_CMD, MII_CMD_WRITE);
+ ag71xx_mdio_wr(ag, AG71XX_REG_MII_ADDR,
+ ((addr & 0xff) << MII_ADDR_SHIFT) | (reg & 0xff));
+ ag71xx_mdio_wr(ag, AG71XX_REG_MII_CMD, MII_CMD_READ);
+
+ i = AG71XX_MDIO_RETRY;
+ while (ag71xx_mdio_rr(ag, AG71XX_REG_MII_IND) & MII_IND_BUSY) {
+ if (i-- == 0) {
+ printf("%s: mii_read timed out\n",
+ ag->dev->name);
+ return -1;
+ }
+ udelay(AG71XX_MDIO_DELAY);
+ }
+
+ regData = (uint16_t) ag71xx_mdio_rr(ag, AG71XX_REG_MII_STATUS) & 0xffff;
+ ag71xx_mdio_wr(ag, AG71XX_REG_MII_CMD, MII_CMD_WRITE);
+
+ DBG("mii_read: addr=%04x, reg=%04x, value=%04x\n", addr, reg, regData);
+
+ if (val)
+ *val = regData;
+
+ return 0;
+}
+
+static int ag71xx_mdio_write(char *devname, unsigned char addr,
+ unsigned char reg, unsigned short val)
+{
+ struct ag71xx *ag = ag71xx_name2mac(devname);
+ int i;
+
+ if (ag == NULL)
+ return 1;
+
+ DBG("mii_write: addr=%04x, reg=%04x, value=%04x\n", addr, reg, val);
+
+ ag71xx_mdio_wr(ag, AG71XX_REG_MII_ADDR,
+ ((addr & 0xff) << MII_ADDR_SHIFT) | (reg & 0xff));
+ ag71xx_mdio_wr(ag, AG71XX_REG_MII_CTRL, val);
+
+ i = AG71XX_MDIO_RETRY;
+ while (ag71xx_mdio_rr(ag, AG71XX_REG_MII_IND) & MII_IND_BUSY) {
+ if (i-- == 0) {
+ printf("%s: mii_write timed out\n",
+ ag->dev->name);
+ break;
+ }
+ udelay(AG71XX_MDIO_DELAY);
+ }
+
+ return 0;
+}
+#endif
+
+int ag71xx_register(bd_t * bis, char *phyname[], uint16_t phyid[], uint16_t phyfixed[])
+{
+ int i, num = 0;
+ u8 used_ports[MAX_AG71XX_DEVS] = CONFIG_AG71XX_PORTS;
+
+ for (i = 0; i < MAX_AG71XX_DEVS; i++) {
+ /*skip if port is configured not to use */
+ if (used_ports[i] == 0)
+ continue;
+
+ agtable[i].dev = malloc(sizeof(struct eth_device));
+ if (agtable[i].dev == NULL) {
+ puts("malloc failed\n");
+ return 0;
+ }
+ memset(agtable[i].dev, 0, sizeof(struct eth_device));
+ sprintf(agtable[i].dev->name, "eth%d", i);
+
+ agtable[i].dev->iobase = 0;
+ agtable[i].dev->init = ag71xx_hw_start;
+ agtable[i].dev->halt = ag71xx_halt;
+ agtable[i].dev->send = ag71xx_send;
+ agtable[i].dev->recv = ag71xx_recv;
+ agtable[i].dev->priv = (void *) (&agtable[i]);
+ agtable[i].macNum = i;
+ eth_register(agtable[i].dev);
+#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
+
+ if ((phyname == NULL) || (phyid == NULL) || (phyfixed == NULL))
+ return -1;
+
+ agtable[i].phyname = strdup(phyname[i]);
+ agtable[i].phyid = phyid[i];
+ agtable[i].phyfixed = phyfixed[i];
+
+ miiphy_register(agtable[i].dev->name, ag71xx_mdio_read,
+ ag71xx_mdio_write);
+#endif
+
+ if (ag71xx_hw_init(&agtable[i]))
+ continue;
+
+ num++;
+ }
+
+ return num;
+}
diff --git a/package/boot/uboot-ar71xx/files/drivers/net/.svn/text-base/ag71xx.h.svn-base b/package/boot/uboot-ar71xx/files/drivers/net/.svn/text-base/ag71xx.h.svn-base
new file mode 100644
index 0000000..edce429
--- /dev/null
+++ b/package/boot/uboot-ar71xx/files/drivers/net/.svn/text-base/ag71xx.h.svn-base
@@ -0,0 +1,374 @@
+/*
+ * Atheros AR71xx built-in ethernet mac driver
+ *
+ * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
+ * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
+ *
+ * Based on Atheros' AG7100 driver
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ */
+
+#ifndef __AG71XX_H
+#define __AG71XX_H
+
+#include <linux/types.h>
+#include <linux/bitops.h>
+
+#include <asm/ar71xx.h>
+
+// controller has 2 ports
+#define MAX_AG71XX_DEVS 2
+
+#define ETH_FCS_LEN 4
+
+#define SPEED_10 10
+#define SPEED_100 100
+#define SPEED_1000 1000
+
+
+#define AG71XX_INT_ERR (AG71XX_INT_RX_BE | AG71XX_INT_TX_BE)
+#define AG71XX_INT_TX (AG71XX_INT_TX_PS)
+#define AG71XX_INT_RX (AG71XX_INT_RX_PR | AG71XX_INT_RX_OF)
+
+#define AG71XX_INT_POLL (AG71XX_INT_RX | AG71XX_INT_TX)
+#define AG71XX_INT_INIT (AG71XX_INT_ERR | AG71XX_INT_POLL)
+
+#define AG71XX_TX_FIFO_LEN 2048
+#define AG71XX_TX_MTU_LEN 1536
+#define AG71XX_RX_PKT_RESERVE 64
+#define AG71XX_RX_PKT_SIZE \
+ (AG71XX_RX_PKT_RESERVE + ETH_HLEN + ETH_FRAME_LEN + ETH_FCS_LEN)
+
+#ifndef CONFIG_SYS_RX_ETH_BUFFER
+#define AG71XX_TX_RING_SIZE 4
+#define AG71XX_RX_RING_SIZE 4
+#else
+#define AG71XX_TX_RING_SIZE CONFIG_SYS_RX_ETH_BUFFER
+#define AG71XX_RX_RING_SIZE CONFIG_SYS_RX_ETH_BUFFER
+#endif
+
+#define AG71XX_TX_THRES_STOP (AG71XX_TX_RING_SIZE - 4)
+#define AG71XX_TX_THRES_WAKEUP \
+ (AG71XX_TX_RING_SIZE - (AG71XX_TX_RING_SIZE / 4))
+
+
+
+
+struct ag71xx_desc {
+ u32 data;
+ u32 ctrl;
+#define DESC_EMPTY BIT(31)
+#define DESC_MORE BIT(24)
+#define DESC_PKTLEN_M 0xfff
+ u32 next;
+ u32 pad;
+} __attribute__((aligned(4)));
+
+struct ag71xx_buf {
+ struct sk_buff *skb;
+ struct ag71xx_desc *desc;
+ dma_addr_t dma_addr;
+ u32 pad;
+};
+
+struct ag71xx_ring {
+ struct ag71xx_buf *buf;
+ u8 *descs_cpu;
+ u8 *descs_dma;
+ unsigned int desc_size;
+ unsigned int curr;
+ unsigned int size;
+};
+
+struct ag71xx {
+ uint32_t mac_base;
+ uint32_t mii_ctrl;
+
+ struct eth_device *dev;
+
+ struct ag71xx_ring rx_ring;
+ struct ag71xx_ring tx_ring;
+
+ char *phyname;
+ u16 phyid;
+ u16 phyfixed;
+ uint32_t link;
+ uint32_t speed;
+ int32_t duplex;
+ uint32_t macNum;
+ uint32_t mii_if;
+};
+
+void ag71xx_link_adjust(struct ag71xx *ag);
+
+int ag71xx_phy_connect(struct ag71xx *ag);
+void ag71xx_phy_disconnect(struct ag71xx *ag);
+void ag71xx_phy_start(struct ag71xx *ag);
+void ag71xx_phy_stop(struct ag71xx *ag);
+
+static inline int ag71xx_desc_empty(struct ag71xx_desc *desc)
+{
+ return ((desc->ctrl & DESC_EMPTY) != 0);
+}
+
+static inline int ag71xx_desc_pktlen(struct ag71xx_desc *desc)
+{
+ return (desc->ctrl & DESC_PKTLEN_M);
+}
+
+/* Register offsets */
+#define AG71XX_REG_MAC_CFG1 0x0000
+#define AG71XX_REG_MAC_CFG2 0x0004
+#define AG71XX_REG_MAC_IPG 0x0008
+#define AG71XX_REG_MAC_HDX 0x000c
+#define AG71XX_REG_MAC_MFL 0x0010
+#define AG71XX_REG_MII_CFG 0x0020
+#define AG71XX_REG_MII_CMD 0x0024
+#define AG71XX_REG_MII_ADDR 0x0028
+#define AG71XX_REG_MII_CTRL 0x002c
+#define AG71XX_REG_MII_STATUS 0x0030
+#define AG71XX_REG_MII_IND 0x0034
+#define AG71XX_REG_MAC_IFCTL 0x0038
+#define AG71XX_REG_MAC_ADDR1 0x0040
+#define AG71XX_REG_MAC_ADDR2 0x0044
+#define AG71XX_REG_FIFO_CFG0 0x0048
+#define AG71XX_REG_FIFO_CFG1 0x004c
+#define AG71XX_REG_FIFO_CFG2 0x0050
+#define AG71XX_REG_FIFO_CFG3 0x0054
+#define AG71XX_REG_FIFO_CFG4 0x0058
+#define AG71XX_REG_FIFO_CFG5 0x005c
+#define AG71XX_REG_FIFO_RAM0 0x0060
+#define AG71XX_REG_FIFO_RAM1 0x0064
+#define AG71XX_REG_FIFO_RAM2 0x0068
+#define AG71XX_REG_FIFO_RAM3 0x006c
+#define AG71XX_REG_FIFO_RAM4 0x0070
+#define AG71XX_REG_FIFO_RAM5 0x0074
+#define AG71XX_REG_FIFO_RAM6 0x0078
+#define AG71XX_REG_FIFO_RAM7 0x007c
+
+#define AG71XX_REG_TX_CTRL 0x0180
+#define AG71XX_REG_TX_DESC 0x0184
+#define AG71XX_REG_TX_STATUS 0x0188
+#define AG71XX_REG_RX_CTRL 0x018c
+#define AG71XX_REG_RX_DESC 0x0190
+#define AG71XX_REG_RX_STATUS 0x0194
+#define AG71XX_REG_INT_ENABLE 0x0198
+#define AG71XX_REG_INT_STATUS 0x019c
+
+#define MAC_CFG1_TXE BIT(0) /* Tx Enable */
+#define MAC_CFG1_STX BIT(1) /* Synchronize Tx Enable */
+#define MAC_CFG1_RXE BIT(2) /* Rx Enable */
+#define MAC_CFG1_SRX BIT(3) /* Synchronize Rx Enable */
+#define MAC_CFG1_TFC BIT(4) /* Tx Flow Control Enable */
+#define MAC_CFG1_RFC BIT(5) /* Rx Flow Control Enable */
+#define MAC_CFG1_LB BIT(8) /* Loopback mode */
+#define MAC_CFG1_SR BIT(31) /* Soft Reset */
+
+#define MAC_CFG2_FDX BIT(0)
+#define MAC_CFG2_CRC_EN BIT(1)
+#define MAC_CFG2_PAD_CRC_EN BIT(2)
+#define MAC_CFG2_LEN_CHECK BIT(4)
+#define MAC_CFG2_HUGE_FRAME_EN BIT(5)
+#define MAC_CFG2_IF_1000 BIT(9)
+#define MAC_CFG2_IF_10_100 BIT(8)
+
+#define FIFO_CFG0_WTM BIT(0) /* Watermark Module */
+#define FIFO_CFG0_RXS BIT(1) /* Rx System Module */
+#define FIFO_CFG0_RXF BIT(2) /* Rx Fabric Module */
+#define FIFO_CFG0_TXS BIT(3) /* Tx System Module */
+#define FIFO_CFG0_TXF BIT(4) /* Tx Fabric Module */
+#define FIFO_CFG0_ALL (FIFO_CFG0_WTM | FIFO_CFG0_RXS | FIFO_CFG0_RXF \
+ | FIFO_CFG0_TXS | FIFO_CFG0_TXF)
+
+#define FIFO_CFG0_ENABLE_SHIFT 8
+
+#define FIFO_CFG4_DE BIT(0) /* Drop Event */
+#define FIFO_CFG4_DV BIT(1) /* RX_DV Event */
+#define FIFO_CFG4_FC BIT(2) /* False Carrier */
+#define FIFO_CFG4_CE BIT(3) /* Code Error */
+#define FIFO_CFG4_CR BIT(4) /* CRC error */
+#define FIFO_CFG4_LM BIT(5) /* Length Mismatch */
+#define FIFO_CFG4_LO BIT(6) /* Length out of range */
+#define FIFO_CFG4_OK BIT(7) /* Packet is OK */
+#define FIFO_CFG4_MC BIT(8) /* Multicast Packet */
+#define FIFO_CFG4_BC BIT(9) /* Broadcast Packet */
+#define FIFO_CFG4_DR BIT(10) /* Dribble */
+#define FIFO_CFG4_LE BIT(11) /* Long Event */
+#define FIFO_CFG4_CF BIT(12) /* Control Frame */
+#define FIFO_CFG4_PF BIT(13) /* Pause Frame */
+#define FIFO_CFG4_UO BIT(14) /* Unsupported Opcode */
+#define FIFO_CFG4_VT BIT(15) /* VLAN tag detected */
+#define FIFO_CFG4_FT BIT(16) /* Frame Truncated */
+#define FIFO_CFG4_UC BIT(17) /* Unicast Packet */
+
+#define FIFO_CFG5_DE BIT(0) /* Drop Event */
+#define FIFO_CFG5_DV BIT(1) /* RX_DV Event */
+#define FIFO_CFG5_FC BIT(2) /* False Carrier */
+#define FIFO_CFG5_CE BIT(3) /* Code Error */
+#define FIFO_CFG5_LM BIT(4) /* Length Mismatch */
+#define FIFO_CFG5_LO BIT(5) /* Length Out of Range */
+#define FIFO_CFG5_OK BIT(6) /* Packet is OK */
+#define FIFO_CFG5_MC BIT(7) /* Multicast Packet */
+#define FIFO_CFG5_BC BIT(8) /* Broadcast Packet */
+#define FIFO_CFG5_DR BIT(9) /* Dribble */
+#define FIFO_CFG5_CF BIT(10) /* Control Frame */
+#define FIFO_CFG5_PF BIT(11) /* Pause Frame */
+#define FIFO_CFG5_UO BIT(12) /* Unsupported Opcode */
+#define FIFO_CFG5_VT BIT(13) /* VLAN tag detected */
+#define FIFO_CFG5_LE BIT(14) /* Long Event */
+#define FIFO_CFG5_FT BIT(15) /* Frame Truncated */
+#define FIFO_CFG5_16 BIT(16) /* unknown */
+#define FIFO_CFG5_17 BIT(17) /* unknown */
+#define FIFO_CFG5_SF BIT(18) /* Short Frame */
+#define FIFO_CFG5_BM BIT(19) /* Byte Mode */
+
+#define AG71XX_INT_TX_PS BIT(0)
+#define AG71XX_INT_TX_UR BIT(1)
+#define AG71XX_INT_TX_BE BIT(3)
+#define AG71XX_INT_RX_PR BIT(4)
+#define AG71XX_INT_RX_OF BIT(6)
+#define AG71XX_INT_RX_BE BIT(7)
+
+#define MAC_IFCTL_SPEED BIT(16)
+
+#define MII_CFG_CLK_DIV_4 0
+#define MII_CFG_CLK_DIV_6 2
+#define MII_CFG_CLK_DIV_8 3
+#define MII_CFG_CLK_DIV_10 4
+#define MII_CFG_CLK_DIV_14 5
+#define MII_CFG_CLK_DIV_20 6
+#define MII_CFG_CLK_DIV_28 7
+#define MII_CFG_RESET BIT(31)
+
+#define MII_CMD_WRITE 0x0
+#define MII_CMD_READ 0x1
+#define MII_ADDR_SHIFT 8
+#define MII_IND_BUSY BIT(0)
+#define MII_IND_INVALID BIT(2)
+
+#define TX_CTRL_TXE BIT(0) /* Tx Enable */
+
+#define TX_STATUS_PS BIT(0) /* Packet Sent */
+#define TX_STATUS_UR BIT(1) /* Tx Underrun */
+#define TX_STATUS_BE BIT(3) /* Bus Error */
+
+#define RX_CTRL_RXE BIT(0) /* Rx Enable */
+
+#define RX_STATUS_PR BIT(0) /* Packet Received */
+#define RX_STATUS_OF BIT(2) /* Rx Overflow */
+#define RX_STATUS_BE BIT(3) /* Bus Error */
+
+#define MII_CTRL_IF_MASK 3
+#define MII_CTRL_SPEED_SHIFT 4
+#define MII_CTRL_SPEED_MASK 3
+#define MII_CTRL_SPEED_10 0
+#define MII_CTRL_SPEED_100 1
+#define MII_CTRL_SPEED_1000 2
+
+static inline void ag71xx_wr(struct ag71xx *ag, unsigned reg, u32 value)
+{
+ __raw_writel(value, ag->mac_base + reg);
+ /* flush write */
+ (void) __raw_readl(ag->mac_base + reg);
+}
+
+static inline u32 ag71xx_rr(struct ag71xx *ag, unsigned reg)
+{
+ return __raw_readl(ag->mac_base + reg);
+}
+
+static inline void ag71xx_sb(struct ag71xx *ag, unsigned reg, u32 mask)
+{
+ uint32_t r;
+
+ r = ag->mac_base + reg;
+ __raw_writel(__raw_readl(r) | mask, r);
+ /* flush write */
+ (void)__raw_readl(r);
+}
+
+static inline void ag71xx_cb(struct ag71xx *ag, unsigned reg, u32 mask)
+{
+ uint32_t r;
+
+ r = ag->mac_base + reg;
+ __raw_writel(__raw_readl(r) & ~mask, r);
+ /* flush write */
+ (void) __raw_readl(r);
+}
+
+static inline void ag71xx_int_enable(struct ag71xx *ag, u32 ints)
+{
+ ag71xx_sb(ag, AG71XX_REG_INT_ENABLE, ints);
+}
+
+static inline void ag71xx_int_disable(struct ag71xx *ag, u32 ints)
+{
+ ag71xx_cb(ag, AG71XX_REG_INT_ENABLE, ints);
+}
+
+static inline void ag71xx_mii_ctrl_wr(struct ag71xx *ag, u32 value)
+{
+ __raw_writel(value, ag->mii_ctrl);
+
+ /* flush write */
+ __raw_readl(ag->mii_ctrl);
+}
+
+static inline u32 ag71xx_mii_ctrl_rr(struct ag71xx *ag)
+{
+ return __raw_readl(ag->mii_ctrl);
+}
+
+static void inline ag71xx_mii_ctrl_set_if(struct ag71xx *ag,
+ unsigned int mii_if)
+{
+ u32 t;
+
+ t = ag71xx_mii_ctrl_rr(ag);
+ t &= ~(MII_CTRL_IF_MASK);
+ t |= (mii_if & MII_CTRL_IF_MASK);
+ ag71xx_mii_ctrl_wr(ag, t);
+}
+
+static void inline ag71xx_mii_ctrl_set_speed(struct ag71xx *ag,
+ unsigned int speed)
+{
+ u32 t;
+
+ t = ag71xx_mii_ctrl_rr(ag);
+ t &= ~(MII_CTRL_SPEED_MASK << MII_CTRL_SPEED_SHIFT);
+ t |= (speed & MII_CTRL_SPEED_MASK) << MII_CTRL_SPEED_SHIFT;
+ ag71xx_mii_ctrl_wr(ag, t);
+}
+
+#ifdef CONFIG_AG71XX_AR8216_SUPPORT
+void ag71xx_add_ar8216_header(struct ag71xx *ag, struct sk_buff *skb);
+int ag71xx_remove_ar8216_header(struct ag71xx *ag, struct sk_buff *skb,
+ int pktlen);
+static inline int ag71xx_has_ar8216(struct ag71xx *ag)
+{
+ return ag71xx_get_pdata(ag)->has_ar8216;
+}
+#else
+static inline void ag71xx_add_ar8216_header(struct ag71xx *ag,
+ struct sk_buff *skb)
+{
+}
+
+static inline int ag71xx_remove_ar8216_header(struct ag71xx *ag,
+ struct sk_buff *skb,
+ int pktlen)
+{
+ return 0;
+}
+static inline int ag71xx_has_ar8216(struct ag71xx *ag)
+{
+ return 0;
+}
+#endif
+
+#endif /* _AG71XX_H */
diff --git a/package/boot/uboot-ar71xx/files/drivers/net/ag71xx.c b/package/boot/uboot-ar71xx/files/drivers/net/ag71xx.c
new file mode 100644
index 0000000..b3324c0
--- /dev/null
+++ b/package/boot/uboot-ar71xx/files/drivers/net/ag71xx.c
@@ -0,0 +1,809 @@
+/*
+ * Atheros AR71xx built-in ethernet mac driver
+ *
+ * Copyright (C) 2010 Michael Kurz <michi.kurz@googlemail.com>
+ * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
+ * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
+ *
+ * Based on Atheros' AG7100 driver
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ */
+
+#include <common.h>
+#include <malloc.h>
+#include <net.h>
+#include <miiphy.h>
+
+#include <asm/ar71xx.h>
+
+#include "ag71xx.h"
+
+#ifdef AG71XX_DEBUG
+#define DBG(fmt,args...) printf(fmt ,##args)
+#else
+#define DBG(fmt,args...)
+#endif
+
+
+static struct ag71xx agtable[] = {
+ {
+ .mac_base = KSEG1ADDR(AR71XX_GE0_BASE),
+ .mii_ctrl = KSEG1ADDR(AR71XX_MII_BASE + MII_REG_MII0_CTRL),
+ .mii_if = CONFIG_AG71XX_MII0_IIF,
+ } , {
+ .mac_base = KSEG1ADDR(AR71XX_GE1_BASE),
+ .mii_ctrl = KSEG1ADDR(AR71XX_MII_BASE + MII_REG_MII1_CTRL),
+ .mii_if = CONFIG_AG71XX_MII1_IIF,
+ }
+};
+
+static int ag71xx_ring_alloc(struct ag71xx_ring *ring, unsigned int size)
+{
+ int err;
+ int i;
+ int rsize;
+
+ ring->desc_size = sizeof(struct ag71xx_desc);
+ if (ring->desc_size % (CONFIG_SYS_CACHELINE_SIZE)) {
+ rsize = roundup(ring->desc_size, CONFIG_SYS_CACHELINE_SIZE);
+ DBG("ag71xx: ring %p, desc size %u rounded to %u\n",
+ ring, ring->desc_size,
+ rsize);
+ ring->desc_size = rsize;
+ }
+
+ ring->descs_cpu = (u8 *) malloc((size * ring->desc_size)
+ + CONFIG_SYS_CACHELINE_SIZE - 1);
+ if (!ring->descs_cpu) {
+ err = -1;
+ goto err;
+ }
+ ring->descs_cpu = (u8 *) UNCACHED_SDRAM((((u32) ring->descs_cpu +
+ CONFIG_SYS_CACHELINE_SIZE - 1) & ~(CONFIG_SYS_CACHELINE_SIZE - 1)));
+ ring->descs_dma = (u8 *) virt_to_phys(ring->descs_cpu);
+
+ ring->size = size;
+
+ ring->buf = malloc(size * sizeof(*ring->buf));
+ if (!ring->buf) {
+ err = -1;
+ goto err;
+ }
+ memset(ring->buf, 0, size * sizeof(*ring->buf));
+
+ for (i = 0; i < size; i++) {
+ ring->buf[i].desc =
+ (struct ag71xx_desc *)&ring->descs_cpu[i * ring->desc_size];
+ DBG("ag71xx: ring %p, desc %d at %p\n",
+ ring, i, ring->buf[i].desc);
+ }
+
+ flush_cache( (u32) ring->buf, size * sizeof(*ring->buf));
+
+ return 0;
+
+ err:
+ return err;
+}
+
+static void ag71xx_ring_tx_init(struct ag71xx *ag)
+{
+ struct ag71xx_ring *ring = &ag->tx_ring;
+ int i;
+
+ for (i = 0; i < AG71XX_TX_RING_SIZE; i++) {
+ ring->buf[i].desc->next = (u32) virt_to_phys((ring->descs_dma +
+ ring->desc_size * ((i + 1) % AG71XX_TX_RING_SIZE)));
+
+ ring->buf[i].desc->ctrl = DESC_EMPTY;
+ ring->buf[i].skb = NULL;
+ }
+
+ ring->curr = 0;
+}
+
+static void ag71xx_ring_rx_clean(struct ag71xx *ag)
+{
+ struct ag71xx_ring *ring = &ag->rx_ring;
+ int i;
+
+ if (!ring->buf)
+ return;
+
+ for (i = 0; i < AG71XX_RX_RING_SIZE; i++) {
+ ring->buf[i].desc->data = (u32) virt_to_phys(NetRxPackets[i]);
+ flush_cache((u32) NetRxPackets[i], PKTSIZE_ALIGN);
+ ring->buf[i].desc->ctrl = DESC_EMPTY;
+ }
+
+ ring->curr = 0;
+}
+
+static int ag71xx_ring_rx_init(struct ag71xx *ag)
+{
+ struct ag71xx_ring *ring = &ag->rx_ring;
+ unsigned int i;
+
+ for (i = 0; i < AG71XX_RX_RING_SIZE; i++) {
+ ring->buf[i].desc->next = (u32) virt_to_phys((ring->descs_dma +
+ ring->desc_size * ((i + 1) % AG71XX_RX_RING_SIZE)));
+
+ DBG("ag71xx: RX desc at %p, next is %08x\n",
+ ring->buf[i].desc,
+ ring->buf[i].desc->next);
+ }
+
+ for (i = 0; i < AG71XX_RX_RING_SIZE; i++) {
+ ring->buf[i].desc->data = (u32) virt_to_phys(NetRxPackets[i]);
+ ring->buf[i].desc->ctrl = DESC_EMPTY;
+ }
+
+ ring->curr = 0;
+
+ return 0;
+}
+
+static int ag71xx_rings_init(struct ag71xx *ag)
+{
+ int ret;
+
+ ret = ag71xx_ring_alloc(&ag->tx_ring, AG71XX_TX_RING_SIZE);
+ if (ret)
+ return ret;
+
+ ag71xx_ring_tx_init(ag);
+
+ ret = ag71xx_ring_alloc(&ag->rx_ring, AG71XX_RX_RING_SIZE);
+ if (ret)
+ return ret;
+
+ ret = ag71xx_ring_rx_init(ag);
+ return ret;
+}
+
+static void ar71xx_set_pll(u32 cfg_reg, u32 pll_reg, u32 pll_val, u32 shift)
+{
+ uint32_t base = KSEG1ADDR(AR71XX_PLL_BASE);
+ u32 t;
+
+ t = readl(base + cfg_reg);
+ t &= ~(3 << shift);
+ t |= (2 << shift);
+ writel(t, base + cfg_reg);
+ udelay(100);
+
+ writel(pll_val, base + pll_reg);
+
+ t |= (3 << shift);
+ writel(t, base + cfg_reg);
+ udelay(100);
+
+ t &= ~(3 << shift);
+ writel(t, base + cfg_reg);
+ udelay(100);
+
+ debug("ar71xx: pll_reg %#x: %#x\n", (unsigned int)(base + pll_reg),
+ readl(base + pll_reg));
+}
+
+static void ar91xx_set_pll_ge0(int speed)
+{
+ //u32 val = ar71xx_get_eth_pll(0, speed);
+ u32 pll_val;
+
+ switch (speed) {
+ case SPEED_10:
+ pll_val = 0x00441099;
+ break;
+ case SPEED_100:
+ pll_val = 0x13000a44;
+ break;
+ case SPEED_1000:
+ pll_val = 0x1a000000;
+ break;
+ default:
+ BUG();
+ }
+
+ ar71xx_set_pll(AR91XX_PLL_REG_ETH_CONFIG, AR91XX_PLL_REG_ETH0_INT_CLOCK,
+ pll_val, AR91XX_ETH0_PLL_SHIFT);
+}
+
+static void ar91xx_set_pll_ge1(int speed)
+{
+ //u32 val = ar71xx_get_eth_pll(1, speed);
+ u32 pll_val;
+
+ switch (speed) {
+ case SPEED_10:
+ pll_val = 0x00441099;
+ break;
+ case SPEED_100:
+ pll_val = 0x13000a44;
+ break;
+ case SPEED_1000:
+ pll_val = 0x1a000000;
+ break;
+ default:
+ BUG();
+ }
+
+ ar71xx_set_pll(AR91XX_PLL_REG_ETH_CONFIG, AR91XX_PLL_REG_ETH1_INT_CLOCK,
+ pll_val, AR91XX_ETH1_PLL_SHIFT);
+}
+
+static void ag71xx_hw_set_macaddr(struct ag71xx *ag, unsigned char *mac)
+{
+ u32 t;
+
+ t = (((u32) mac[5]) << 24) | (((u32) mac[4]) << 16)
+ | (((u32) mac[3]) << 8) | ((u32) mac[2]);
+
+ ag71xx_wr(ag, AG71XX_REG_MAC_ADDR1, t);
+
+ t = (((u32) mac[1]) << 24) | (((u32) mac[0]) << 16);
+ ag71xx_wr(ag, AG71XX_REG_MAC_ADDR2, t);
+}
+
+static void ag71xx_dma_reset(struct ag71xx *ag)
+{
+ u32 val;
+ int i;
+
+ DBG("%s: txdesc reg: 0x%08x rxdesc reg: 0x%08x\n",
+ ag->dev->name,
+ ag71xx_rr(ag, AG71XX_REG_TX_DESC),
+ ag71xx_rr(ag, AG71XX_REG_RX_DESC));
+
+ /* stop RX and TX */
+ ag71xx_wr(ag, AG71XX_REG_RX_CTRL, 0);
+ ag71xx_wr(ag, AG71XX_REG_TX_CTRL, 0);
+
+ /* clear descriptor addresses */
+ ag71xx_wr(ag, AG71XX_REG_TX_DESC, 0);
+ ag71xx_wr(ag, AG71XX_REG_RX_DESC, 0);
+
+ /* clear pending RX/TX interrupts */
+ for (i = 0; i < 256; i++) {
+ ag71xx_wr(ag, AG71XX_REG_RX_STATUS, RX_STATUS_PR);
+ ag71xx_wr(ag, AG71XX_REG_TX_STATUS, TX_STATUS_PS);
+ }
+
+ /* clear pending errors */
+ ag71xx_wr(ag, AG71XX_REG_RX_STATUS, RX_STATUS_BE | RX_STATUS_OF);
+ ag71xx_wr(ag, AG71XX_REG_TX_STATUS, TX_STATUS_BE | TX_STATUS_UR);
+
+ val = ag71xx_rr(ag, AG71XX_REG_RX_STATUS);
+ if (val)
+ printf("%s: unable to clear DMA Rx status: %08x\n",
+ ag->dev->name, val);
+
+ val = ag71xx_rr(ag, AG71XX_REG_TX_STATUS);
+
+ /* mask out reserved bits */
+ val &= ~0xff000000;
+
+ if (val)
+ printf("%s: unable to clear DMA Tx status: %08x\n",
+ ag->dev->name, val);
+}
+
+static void ag71xx_halt(struct eth_device *dev)
+{
+ struct ag71xx *ag = (struct ag71xx *) dev->priv;
+
+ /* stop RX engine */
+ ag71xx_wr(ag, AG71XX_REG_RX_CTRL, 0);
+
+ ag71xx_dma_reset(ag);
+}
+
+#define MAX_WAIT 1000
+
+static int ag71xx_send(struct eth_device *dev, volatile void *packet,
+ int length)
+{
+ struct ag71xx *ag = (struct ag71xx *) dev->priv;
+ struct ag71xx_ring *ring = &ag->tx_ring;
+ struct ag71xx_desc *desc;
+ int i;
+
+ i = ring->curr % AG71XX_TX_RING_SIZE;
+ desc = ring->buf[i].desc;
+
+ if (!ag71xx_desc_empty(desc)) {
+ printf("%s: tx buffer full\n", ag->dev->name);
+ return 1;
+ }
+
+ flush_cache((u32) packet, length);
+ desc->data = (u32) virt_to_phys(packet);
+ desc->ctrl = (length & DESC_PKTLEN_M);
+
+ DBG("%s: sending %#08x length %#08x\n",
+ ag->dev->name, desc->data, desc->ctrl);
+
+ ring->curr++;
+ if (ring->curr >= AG71XX_TX_RING_SIZE){
+ ring->curr = 0;
+ }
+
+ /* enable TX engine */
+ ag71xx_wr(ag, AG71XX_REG_TX_CTRL, TX_CTRL_TXE);
+
+ for (i = 0; i < MAX_WAIT; i++)
+ {
+ if (ag71xx_desc_empty(desc))
+ break;
+ udelay(10);
+ }
+ if (i == MAX_WAIT) {
+ printf("%s: tx timed out!\n", ag->dev->name);
+ return -1;
+ }
+
+ /* disable TX engine */
+ ag71xx_wr(ag, AG71XX_REG_TX_CTRL, 0);
+ desc->data = 0;
+ desc->ctrl = DESC_EMPTY;
+
+ return 0;
+}
+
+static int ag71xx_recv(struct eth_device *dev)
+{
+ struct ag71xx *ag = (struct ag71xx *) dev->priv;
+ struct ag71xx_ring *ring = &ag->rx_ring;
+
+ for (;;) {
+ unsigned int i = ring->curr % AG71XX_RX_RING_SIZE;
+ struct ag71xx_desc *desc = ring->buf[i].desc;
+ int pktlen;
+
+ if (ag71xx_desc_empty(desc))
+ break;
+
+ DBG("%s: rx packets, curr=%u\n", dev->name, ring->curr);
+
+ pktlen = ag71xx_desc_pktlen(desc);
+ pktlen -= ETH_FCS_LEN;
+
+
+ NetReceive(NetRxPackets[i] , pktlen);
+ flush_cache( (u32) NetRxPackets[i], PKTSIZE_ALIGN);
+
+ ring->buf[i].desc->ctrl = DESC_EMPTY;
+ ring->curr++;
+ if (ring->curr >= AG71XX_RX_RING_SIZE){
+ ring->curr = 0;
+ }
+
+ }
+
+ if ((ag71xx_rr(ag, AG71XX_REG_RX_CTRL) & RX_CTRL_RXE) == 0) {
+ /* start RX engine */
+ ag71xx_wr(ag, AG71XX_REG_RX_CTRL, RX_CTRL_RXE);
+ }
+
+ return 0;
+}
+
+#ifdef AG71XX_DEBUG
+static char *ag71xx_speed_str(struct ag71xx *ag)
+{
+ switch (ag->speed) {
+ case SPEED_1000:
+ return "1000";
+ case SPEED_100:
+ return "100";
+ case SPEED_10:
+ return "10";
+ }
+
+ return "?";
+}
+#endif
+
+void ag71xx_link_adjust(struct ag71xx *ag)
+{
+ u32 cfg2;
+ u32 ifctl;
+ u32 fifo5;
+ u32 mii_speed;
+
+ if (!ag->link) {
+ DBG("%s: link down\n", ag->dev->name);
+ return;
+ }
+
+ cfg2 = ag71xx_rr(ag, AG71XX_REG_MAC_CFG2);
+ cfg2 &= ~(MAC_CFG2_IF_1000 | MAC_CFG2_IF_10_100 | MAC_CFG2_FDX);
+ cfg2 |= (ag->duplex) ? MAC_CFG2_FDX : 0;
+
+ ifctl = ag71xx_rr(ag, AG71XX_REG_MAC_IFCTL);
+ ifctl &= ~(MAC_IFCTL_SPEED);
+
+ fifo5 = ag71xx_rr(ag, AG71XX_REG_FIFO_CFG5);
+ fifo5 &= ~FIFO_CFG5_BM;
+
+ switch (ag->speed) {
+ case SPEED_1000:
+ mii_speed = MII_CTRL_SPEED_1000;
+ cfg2 |= MAC_CFG2_IF_1000;
+ fifo5 |= FIFO_CFG5_BM;
+ break;
+ case SPEED_100:
+ mii_speed = MII_CTRL_SPEED_100;
+ cfg2 |= MAC_CFG2_IF_10_100;
+ ifctl |= MAC_IFCTL_SPEED;
+ break;
+ case SPEED_10:
+ mii_speed = MII_CTRL_SPEED_10;
+ cfg2 |= MAC_CFG2_IF_10_100;
+ break;
+ default:
+ BUG();
+ return;
+ }
+
+ ag71xx_wr(ag, AG71XX_REG_FIFO_CFG3, 0x00780fff);
+
+ if (ag->macNum == 0)
+ ar91xx_set_pll_ge0(ag->speed);
+ else
+ ar91xx_set_pll_ge1(ag->speed);
+
+ ag71xx_mii_ctrl_set_speed(ag, mii_speed);
+
+ ag71xx_wr(ag, AG71XX_REG_MAC_CFG2, cfg2);
+ ag71xx_wr(ag, AG71XX_REG_FIFO_CFG5, fifo5);
+ ag71xx_wr(ag, AG71XX_REG_MAC_IFCTL, ifctl);
+
+ DBG("%s: link up (%sMbps/%s duplex)\n",
+ ag->dev->name,
+ ag71xx_speed_str(ag),
+ (1 == ag->duplex) ? "Full" : "Half");
+
+ DBG("%s: fifo_cfg0=%#x, fifo_cfg1=%#x, fifo_cfg2=%#x\n",
+ ag->dev->name,
+ ag71xx_rr(ag, AG71XX_REG_FIFO_CFG0),
+ ag71xx_rr(ag, AG71XX_REG_FIFO_CFG1),
+ ag71xx_rr(ag, AG71XX_REG_FIFO_CFG2));
+
+ DBG("%s: fifo_cfg3=%#x, fifo_cfg4=%#x, fifo_cfg5=%#x\n",
+ ag->dev->name,
+ ag71xx_rr(ag, AG71XX_REG_FIFO_CFG3),
+ ag71xx_rr(ag, AG71XX_REG_FIFO_CFG4),
+ ag71xx_rr(ag, AG71XX_REG_FIFO_CFG5));
+
+ DBG("%s: mac_cfg2=%#x, mac_ifctl=%#x, mii_ctrl=%#x\n",
+ ag->dev->name,
+ ag71xx_rr(ag, AG71XX_REG_MAC_CFG2),
+ ag71xx_rr(ag, AG71XX_REG_MAC_IFCTL),
+ ag71xx_mii_ctrl_rr(ag));
+}
+
+#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
+static int ag71xx_getMiiSpeed(struct ag71xx *ag)
+{
+ uint16_t phyreg, cap;
+
+ if (miiphy_read(ag->phyname, ag->phyid,
+ PHY_BMSR, &phyreg)) {
+ puts("PHY_BMSR read failed, assuming no link\n");
+ return -1;
+ }
+
+ if ((phyreg & PHY_BMSR_LS) == 0) {
+ return -1;
+ }
+
+ if (miiphy_read(ag->phyname, ag->phyid,
+ PHY_1000BTSR, &phyreg))
+ return -1;
+
+ if (phyreg & PHY_1000BTSR_1000FD) {
+ ag->speed = SPEED_1000;
+ ag->duplex = 1;
+ } else if (phyreg & PHY_1000BTSR_1000HD) {
+ ag->speed = SPEED_1000;
+ ag->duplex = 0;
+ } else {
+ if (miiphy_read(ag->phyname, ag->phyid,
+ PHY_ANAR, &cap))
+ return -1;
+
+ if (miiphy_read(ag->phyname, ag->phyid,
+ PHY_ANLPAR, &phyreg))
+ return -1;
+
+ cap &= phyreg;
+ if (cap & PHY_ANLPAR_TXFD) {
+ ag->speed = SPEED_100;
+ ag->duplex = 1;
+ } else if (cap & PHY_ANLPAR_TX) {
+ ag->speed = SPEED_100;
+ ag->duplex = 0;
+ } else if (cap & PHY_ANLPAR_10FD) {
+ ag->speed = SPEED_10;
+ ag->duplex = 1;
+ } else {
+ ag->speed = SPEED_10;
+ ag->duplex = 0;
+ }
+ }
+
+ ag->link = 1;
+
+ return 0;
+}
+#endif
+
+static int ag71xx_hw_start(struct eth_device *dev, bd_t * bd)
+{
+ struct ag71xx *ag = (struct ag71xx *) dev->priv;
+
+ ag71xx_dma_reset(ag);
+
+ ag71xx_ring_rx_clean(ag);
+ ag71xx_ring_tx_init(ag);
+
+ ag71xx_wr(ag, AG71XX_REG_TX_DESC,
+ (u32) virt_to_phys(ag->tx_ring.descs_dma));
+ ag71xx_wr(ag, AG71XX_REG_RX_DESC,
+ (u32) virt_to_phys(ag->rx_ring.descs_dma));
+
+ ag71xx_hw_set_macaddr(ag, ag->dev->enetaddr);
+
+ if (ag->phyfixed) {
+ ag->link = 1;
+ ag->duplex = 1;
+ ag->speed = SPEED_1000;
+ } else {
+
+#if (defined(CONFIG_MII) || defined(CONFIG_CMD_MII))
+ if (ag71xx_getMiiSpeed(ag))
+ return -1;
+#else
+ /* only fixed, without mii */
+ return -1;
+#endif
+
+ }
+ ag71xx_link_adjust(ag);
+
+ DBG("%s: txdesc reg: %#08x rxdesc reg: %#08x\n",
+ ag->dev->name,
+ ag71xx_rr(ag, AG71XX_REG_TX_DESC),
+ ag71xx_rr(ag, AG71XX_REG_RX_DESC));
+
+ /* start RX engine */
+ ag71xx_wr(ag, AG71XX_REG_RX_CTRL, RX_CTRL_RXE);
+
+ return 0;
+}
+
+#define FIFO_CFG0_INIT (FIFO_CFG0_ALL << FIFO_CFG0_ENABLE_SHIFT)
+
+#define FIFO_CFG4_INIT (FIFO_CFG4_DE | FIFO_CFG4_DV | FIFO_CFG4_FC | \
+ FIFO_CFG4_CE | FIFO_CFG4_CR | FIFO_CFG4_LM | \
+ FIFO_CFG4_LO | FIFO_CFG4_OK | FIFO_CFG4_MC | \
+ FIFO_CFG4_BC | FIFO_CFG4_DR | FIFO_CFG4_LE | \
+ FIFO_CFG4_CF | FIFO_CFG4_PF | FIFO_CFG4_UO | \
+ FIFO_CFG4_VT)
+
+#define FIFO_CFG5_INIT (FIFO_CFG5_DE | FIFO_CFG5_DV | FIFO_CFG5_FC | \
+ FIFO_CFG5_CE | FIFO_CFG5_LO | FIFO_CFG5_OK | \
+ FIFO_CFG5_MC | FIFO_CFG5_BC | FIFO_CFG5_DR | \
+ FIFO_CFG5_CF | FIFO_CFG5_PF | FIFO_CFG5_VT | \
+ FIFO_CFG5_LE | FIFO_CFG5_FT | FIFO_CFG5_16 | \
+ FIFO_CFG5_17 | FIFO_CFG5_SF)
+
+static int ag71xx_hw_init(struct ag71xx *ag)
+{
+ int ret = 0;
+ uint32_t reg;
+ uint32_t mask, mii_type;
+
+ if (ag->macNum == 0) {
+ mask = (RESET_MODULE_GE0_MAC | RESET_MODULE_GE0_PHY);
+ mii_type = 0x13;
+ } else {
+ mask = (RESET_MODULE_GE1_MAC | RESET_MODULE_GE1_PHY);
+ mii_type = 0x11;
+ }
+
+ // mac soft reset
+ ag71xx_sb(ag, AG71XX_REG_MAC_CFG1, MAC_CFG1_SR);
+ udelay(20);
+
+ // device stop
+ reg = ar71xx_reset_rr(AR91XX_RESET_REG_RESET_MODULE);
+ ar71xx_reset_wr(AR91XX_RESET_REG_RESET_MODULE, reg | mask);
+ udelay(100 * 1000);
+
+ // device start
+ reg = ar71xx_reset_rr(AR91XX_RESET_REG_RESET_MODULE);
+ ar71xx_reset_wr(AR91XX_RESET_REG_RESET_MODULE, reg & ~mask);
+ udelay(100 * 1000);
+
+ /* setup MAC configuration registers */
+ ag71xx_wr(ag, AG71XX_REG_MAC_CFG1, (MAC_CFG1_RXE | MAC_CFG1_TXE));
+
+ ag71xx_sb(ag, AG71XX_REG_MAC_CFG2,
+ MAC_CFG2_PAD_CRC_EN | MAC_CFG2_LEN_CHECK);
+
+ /* setup FIFO configuration register 0 */
+ ag71xx_wr(ag, AG71XX_REG_FIFO_CFG0, FIFO_CFG0_INIT);
+
+ /* setup MII interface type */
+ ag71xx_mii_ctrl_set_if(ag, ag->mii_if);
+
+ /* setup mdio clock divisor */
+ ag71xx_wr(ag, AG71XX_REG_MII_CFG, MII_CFG_CLK_DIV_20);
+
+ /* setup FIFO configuration registers */
+ ag71xx_sb(ag, AG71XX_REG_FIFO_CFG4, FIFO_CFG4_INIT);
+ ag71xx_wr(ag, AG71XX_REG_FIFO_CFG1, 0x0fff0000);
+ ag71xx_wr(ag, AG71XX_REG_FIFO_CFG2, 0x00001fff);
+ ag71xx_wr(ag, AG71XX_REG_FIFO_CFG5, FIFO_CFG5_INIT);
+
+ ag71xx_dma_reset(ag);
+
+ ret = ag71xx_rings_init(ag);
+ if (ret)
+ return -1;
+
+ ag71xx_wr(ag, AG71XX_REG_TX_DESC,
+ (u32) virt_to_phys(ag->tx_ring.descs_dma));
+ ag71xx_wr(ag, AG71XX_REG_RX_DESC,
+ (u32) virt_to_phys(ag->rx_ring.descs_dma));
+
+ ag71xx_hw_set_macaddr(ag, ag->dev->enetaddr);
+
+ return 0;
+}
+
+#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
+#define AG71XX_MDIO_RETRY 1000
+#define AG71XX_MDIO_DELAY 5
+
+static inline struct ag71xx *ag71xx_name2mac(char *devname)
+{
+ if (strcmp(devname, agtable[0].dev->name) == 0)
+ return &agtable[0];
+ else if (strcmp(devname, agtable[1].dev->name) == 0)
+ return &agtable[1];
+ else
+ return NULL;
+}
+
+static inline void ag71xx_mdio_wr(struct ag71xx *ag, unsigned reg,
+ u32 value)
+{
+ uint32_t r;
+
+ r = ag->mac_base + reg;
+ writel(value, r);
+
+ /* flush write */
+ (void) readl(r);
+}
+
+static inline u32 ag71xx_mdio_rr(struct ag71xx *ag, unsigned reg)
+{
+ return readl(ag->mac_base + reg);
+}
+
+static int ag71xx_mdio_read(char *devname, unsigned char addr,
+ unsigned char reg, unsigned short *val)
+{
+ struct ag71xx *ag = ag71xx_name2mac(devname);
+ uint16_t regData;
+ int i;
+
+ ag71xx_mdio_wr(ag, AG71XX_REG_MII_CMD, MII_CMD_WRITE);
+ ag71xx_mdio_wr(ag, AG71XX_REG_MII_ADDR,
+ ((addr & 0xff) << MII_ADDR_SHIFT) | (reg & 0xff));
+ ag71xx_mdio_wr(ag, AG71XX_REG_MII_CMD, MII_CMD_READ);
+
+ i = AG71XX_MDIO_RETRY;
+ while (ag71xx_mdio_rr(ag, AG71XX_REG_MII_IND) & MII_IND_BUSY) {
+ if (i-- == 0) {
+ printf("%s: mii_read timed out\n",
+ ag->dev->name);
+ return -1;
+ }
+ udelay(AG71XX_MDIO_DELAY);
+ }
+
+ regData = (uint16_t) ag71xx_mdio_rr(ag, AG71XX_REG_MII_STATUS) & 0xffff;
+ ag71xx_mdio_wr(ag, AG71XX_REG_MII_CMD, MII_CMD_WRITE);
+
+ DBG("mii_read: addr=%04x, reg=%04x, value=%04x\n", addr, reg, regData);
+
+ if (val)
+ *val = regData;
+
+ return 0;
+}
+
+static int ag71xx_mdio_write(char *devname, unsigned char addr,
+ unsigned char reg, unsigned short val)
+{
+ struct ag71xx *ag = ag71xx_name2mac(devname);
+ int i;
+
+ if (ag == NULL)
+ return 1;
+
+ DBG("mii_write: addr=%04x, reg=%04x, value=%04x\n", addr, reg, val);
+
+ ag71xx_mdio_wr(ag, AG71XX_REG_MII_ADDR,
+ ((addr & 0xff) << MII_ADDR_SHIFT) | (reg & 0xff));
+ ag71xx_mdio_wr(ag, AG71XX_REG_MII_CTRL, val);
+
+ i = AG71XX_MDIO_RETRY;
+ while (ag71xx_mdio_rr(ag, AG71XX_REG_MII_IND) & MII_IND_BUSY) {
+ if (i-- == 0) {
+ printf("%s: mii_write timed out\n",
+ ag->dev->name);
+ break;
+ }
+ udelay(AG71XX_MDIO_DELAY);
+ }
+
+ return 0;
+}
+#endif
+
+int ag71xx_register(bd_t * bis, char *phyname[], uint16_t phyid[], uint16_t phyfixed[])
+{
+ int i, num = 0;
+ u8 used_ports[MAX_AG71XX_DEVS] = CONFIG_AG71XX_PORTS;
+
+ for (i = 0; i < MAX_AG71XX_DEVS; i++) {
+ /*skip if port is configured not to use */
+ if (used_ports[i] == 0)
+ continue;
+
+ agtable[i].dev = malloc(sizeof(struct eth_device));
+ if (agtable[i].dev == NULL) {
+ puts("malloc failed\n");
+ return 0;
+ }
+ memset(agtable[i].dev, 0, sizeof(struct eth_device));
+ sprintf(agtable[i].dev->name, "eth%d", i);
+
+ agtable[i].dev->iobase = 0;
+ agtable[i].dev->init = ag71xx_hw_start;
+ agtable[i].dev->halt = ag71xx_halt;
+ agtable[i].dev->send = ag71xx_send;
+ agtable[i].dev->recv = ag71xx_recv;
+ agtable[i].dev->priv = (void *) (&agtable[i]);
+ agtable[i].macNum = i;
+ eth_register(agtable[i].dev);
+#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
+
+ if ((phyname == NULL) || (phyid == NULL) || (phyfixed == NULL))
+ return -1;
+
+ agtable[i].phyname = strdup(phyname[i]);
+ agtable[i].phyid = phyid[i];
+ agtable[i].phyfixed = phyfixed[i];
+
+ miiphy_register(agtable[i].dev->name, ag71xx_mdio_read,
+ ag71xx_mdio_write);
+#endif
+
+ if (ag71xx_hw_init(&agtable[i]))
+ continue;
+
+ num++;
+ }
+
+ return num;
+}
diff --git a/package/boot/uboot-ar71xx/files/drivers/net/ag71xx.h b/package/boot/uboot-ar71xx/files/drivers/net/ag71xx.h
new file mode 100644
index 0000000..edce429
--- /dev/null
+++ b/package/boot/uboot-ar71xx/files/drivers/net/ag71xx.h
@@ -0,0 +1,374 @@
+/*
+ * Atheros AR71xx built-in ethernet mac driver
+ *
+ * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
+ * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
+ *
+ * Based on Atheros' AG7100 driver
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ */
+
+#ifndef __AG71XX_H
+#define __AG71XX_H
+
+#include <linux/types.h>
+#include <linux/bitops.h>
+
+#include <asm/ar71xx.h>
+
+// controller has 2 ports
+#define MAX_AG71XX_DEVS 2
+
+#define ETH_FCS_LEN 4
+
+#define SPEED_10 10
+#define SPEED_100 100
+#define SPEED_1000 1000
+
+
+#define AG71XX_INT_ERR (AG71XX_INT_RX_BE | AG71XX_INT_TX_BE)
+#define AG71XX_INT_TX (AG71XX_INT_TX_PS)
+#define AG71XX_INT_RX (AG71XX_INT_RX_PR | AG71XX_INT_RX_OF)
+
+#define AG71XX_INT_POLL (AG71XX_INT_RX | AG71XX_INT_TX)
+#define AG71XX_INT_INIT (AG71XX_INT_ERR | AG71XX_INT_POLL)
+
+#define AG71XX_TX_FIFO_LEN 2048
+#define AG71XX_TX_MTU_LEN 1536
+#define AG71XX_RX_PKT_RESERVE 64
+#define AG71XX_RX_PKT_SIZE \
+ (AG71XX_RX_PKT_RESERVE + ETH_HLEN + ETH_FRAME_LEN + ETH_FCS_LEN)
+
+#ifndef CONFIG_SYS_RX_ETH_BUFFER
+#define AG71XX_TX_RING_SIZE 4
+#define AG71XX_RX_RING_SIZE 4
+#else
+#define AG71XX_TX_RING_SIZE CONFIG_SYS_RX_ETH_BUFFER
+#define AG71XX_RX_RING_SIZE CONFIG_SYS_RX_ETH_BUFFER
+#endif
+
+#define AG71XX_TX_THRES_STOP (AG71XX_TX_RING_SIZE - 4)
+#define AG71XX_TX_THRES_WAKEUP \
+ (AG71XX_TX_RING_SIZE - (AG71XX_TX_RING_SIZE / 4))
+
+
+
+
+struct ag71xx_desc {
+ u32 data;
+ u32 ctrl;
+#define DESC_EMPTY BIT(31)
+#define DESC_MORE BIT(24)
+#define DESC_PKTLEN_M 0xfff
+ u32 next;
+ u32 pad;
+} __attribute__((aligned(4)));
+
+struct ag71xx_buf {
+ struct sk_buff *skb;
+ struct ag71xx_desc *desc;
+ dma_addr_t dma_addr;
+ u32 pad;
+};
+
+struct ag71xx_ring {
+ struct ag71xx_buf *buf;
+ u8 *descs_cpu;
+ u8 *descs_dma;
+ unsigned int desc_size;
+ unsigned int curr;
+ unsigned int size;
+};
+
+struct ag71xx {
+ uint32_t mac_base;
+ uint32_t mii_ctrl;
+
+ struct eth_device *dev;
+
+ struct ag71xx_ring rx_ring;
+ struct ag71xx_ring tx_ring;
+
+ char *phyname;
+ u16 phyid;
+ u16 phyfixed;
+ uint32_t link;
+ uint32_t speed;
+ int32_t duplex;
+ uint32_t macNum;
+ uint32_t mii_if;
+};
+
+void ag71xx_link_adjust(struct ag71xx *ag);
+
+int ag71xx_phy_connect(struct ag71xx *ag);
+void ag71xx_phy_disconnect(struct ag71xx *ag);
+void ag71xx_phy_start(struct ag71xx *ag);
+void ag71xx_phy_stop(struct ag71xx *ag);
+
+static inline int ag71xx_desc_empty(struct ag71xx_desc *desc)
+{
+ return ((desc->ctrl & DESC_EMPTY) != 0);
+}
+
+static inline int ag71xx_desc_pktlen(struct ag71xx_desc *desc)
+{
+ return (desc->ctrl & DESC_PKTLEN_M);
+}
+
+/* Register offsets */
+#define AG71XX_REG_MAC_CFG1 0x0000
+#define AG71XX_REG_MAC_CFG2 0x0004
+#define AG71XX_REG_MAC_IPG 0x0008
+#define AG71XX_REG_MAC_HDX 0x000c
+#define AG71XX_REG_MAC_MFL 0x0010
+#define AG71XX_REG_MII_CFG 0x0020
+#define AG71XX_REG_MII_CMD 0x0024
+#define AG71XX_REG_MII_ADDR 0x0028
+#define AG71XX_REG_MII_CTRL 0x002c
+#define AG71XX_REG_MII_STATUS 0x0030
+#define AG71XX_REG_MII_IND 0x0034
+#define AG71XX_REG_MAC_IFCTL 0x0038
+#define AG71XX_REG_MAC_ADDR1 0x0040
+#define AG71XX_REG_MAC_ADDR2 0x0044
+#define AG71XX_REG_FIFO_CFG0 0x0048
+#define AG71XX_REG_FIFO_CFG1 0x004c
+#define AG71XX_REG_FIFO_CFG2 0x0050
+#define AG71XX_REG_FIFO_CFG3 0x0054
+#define AG71XX_REG_FIFO_CFG4 0x0058
+#define AG71XX_REG_FIFO_CFG5 0x005c
+#define AG71XX_REG_FIFO_RAM0 0x0060
+#define AG71XX_REG_FIFO_RAM1 0x0064
+#define AG71XX_REG_FIFO_RAM2 0x0068
+#define AG71XX_REG_FIFO_RAM3 0x006c
+#define AG71XX_REG_FIFO_RAM4 0x0070
+#define AG71XX_REG_FIFO_RAM5 0x0074
+#define AG71XX_REG_FIFO_RAM6 0x0078
+#define AG71XX_REG_FIFO_RAM7 0x007c
+
+#define AG71XX_REG_TX_CTRL 0x0180
+#define AG71XX_REG_TX_DESC 0x0184
+#define AG71XX_REG_TX_STATUS 0x0188
+#define AG71XX_REG_RX_CTRL 0x018c
+#define AG71XX_REG_RX_DESC 0x0190
+#define AG71XX_REG_RX_STATUS 0x0194
+#define AG71XX_REG_INT_ENABLE 0x0198
+#define AG71XX_REG_INT_STATUS 0x019c
+
+#define MAC_CFG1_TXE BIT(0) /* Tx Enable */
+#define MAC_CFG1_STX BIT(1) /* Synchronize Tx Enable */
+#define MAC_CFG1_RXE BIT(2) /* Rx Enable */
+#define MAC_CFG1_SRX BIT(3) /* Synchronize Rx Enable */
+#define MAC_CFG1_TFC BIT(4) /* Tx Flow Control Enable */
+#define MAC_CFG1_RFC BIT(5) /* Rx Flow Control Enable */
+#define MAC_CFG1_LB BIT(8) /* Loopback mode */
+#define MAC_CFG1_SR BIT(31) /* Soft Reset */
+
+#define MAC_CFG2_FDX BIT(0)
+#define MAC_CFG2_CRC_EN BIT(1)
+#define MAC_CFG2_PAD_CRC_EN BIT(2)
+#define MAC_CFG2_LEN_CHECK BIT(4)
+#define MAC_CFG2_HUGE_FRAME_EN BIT(5)
+#define MAC_CFG2_IF_1000 BIT(9)
+#define MAC_CFG2_IF_10_100 BIT(8)
+
+#define FIFO_CFG0_WTM BIT(0) /* Watermark Module */
+#define FIFO_CFG0_RXS BIT(1) /* Rx System Module */
+#define FIFO_CFG0_RXF BIT(2) /* Rx Fabric Module */
+#define FIFO_CFG0_TXS BIT(3) /* Tx System Module */
+#define FIFO_CFG0_TXF BIT(4) /* Tx Fabric Module */
+#define FIFO_CFG0_ALL (FIFO_CFG0_WTM | FIFO_CFG0_RXS | FIFO_CFG0_RXF \
+ | FIFO_CFG0_TXS | FIFO_CFG0_TXF)
+
+#define FIFO_CFG0_ENABLE_SHIFT 8
+
+#define FIFO_CFG4_DE BIT(0) /* Drop Event */
+#define FIFO_CFG4_DV BIT(1) /* RX_DV Event */
+#define FIFO_CFG4_FC BIT(2) /* False Carrier */
+#define FIFO_CFG4_CE BIT(3) /* Code Error */
+#define FIFO_CFG4_CR BIT(4) /* CRC error */
+#define FIFO_CFG4_LM BIT(5) /* Length Mismatch */
+#define FIFO_CFG4_LO BIT(6) /* Length out of range */
+#define FIFO_CFG4_OK BIT(7) /* Packet is OK */
+#define FIFO_CFG4_MC BIT(8) /* Multicast Packet */
+#define FIFO_CFG4_BC BIT(9) /* Broadcast Packet */
+#define FIFO_CFG4_DR BIT(10) /* Dribble */
+#define FIFO_CFG4_LE BIT(11) /* Long Event */
+#define FIFO_CFG4_CF BIT(12) /* Control Frame */
+#define FIFO_CFG4_PF BIT(13) /* Pause Frame */
+#define FIFO_CFG4_UO BIT(14) /* Unsupported Opcode */
+#define FIFO_CFG4_VT BIT(15) /* VLAN tag detected */
+#define FIFO_CFG4_FT BIT(16) /* Frame Truncated */
+#define FIFO_CFG4_UC BIT(17) /* Unicast Packet */
+
+#define FIFO_CFG5_DE BIT(0) /* Drop Event */
+#define FIFO_CFG5_DV BIT(1) /* RX_DV Event */
+#define FIFO_CFG5_FC BIT(2) /* False Carrier */
+#define FIFO_CFG5_CE BIT(3) /* Code Error */
+#define FIFO_CFG5_LM BIT(4) /* Length Mismatch */
+#define FIFO_CFG5_LO BIT(5) /* Length Out of Range */
+#define FIFO_CFG5_OK BIT(6) /* Packet is OK */
+#define FIFO_CFG5_MC BIT(7) /* Multicast Packet */
+#define FIFO_CFG5_BC BIT(8) /* Broadcast Packet */
+#define FIFO_CFG5_DR BIT(9) /* Dribble */
+#define FIFO_CFG5_CF BIT(10) /* Control Frame */
+#define FIFO_CFG5_PF BIT(11) /* Pause Frame */
+#define FIFO_CFG5_UO BIT(12) /* Unsupported Opcode */
+#define FIFO_CFG5_VT BIT(13) /* VLAN tag detected */
+#define FIFO_CFG5_LE BIT(14) /* Long Event */
+#define FIFO_CFG5_FT BIT(15) /* Frame Truncated */
+#define FIFO_CFG5_16 BIT(16) /* unknown */
+#define FIFO_CFG5_17 BIT(17) /* unknown */
+#define FIFO_CFG5_SF BIT(18) /* Short Frame */
+#define FIFO_CFG5_BM BIT(19) /* Byte Mode */
+
+#define AG71XX_INT_TX_PS BIT(0)
+#define AG71XX_INT_TX_UR BIT(1)
+#define AG71XX_INT_TX_BE BIT(3)
+#define AG71XX_INT_RX_PR BIT(4)
+#define AG71XX_INT_RX_OF BIT(6)
+#define AG71XX_INT_RX_BE BIT(7)
+
+#define MAC_IFCTL_SPEED BIT(16)
+
+#define MII_CFG_CLK_DIV_4 0
+#define MII_CFG_CLK_DIV_6 2
+#define MII_CFG_CLK_DIV_8 3
+#define MII_CFG_CLK_DIV_10 4
+#define MII_CFG_CLK_DIV_14 5
+#define MII_CFG_CLK_DIV_20 6
+#define MII_CFG_CLK_DIV_28 7
+#define MII_CFG_RESET BIT(31)
+
+#define MII_CMD_WRITE 0x0
+#define MII_CMD_READ 0x1
+#define MII_ADDR_SHIFT 8
+#define MII_IND_BUSY BIT(0)
+#define MII_IND_INVALID BIT(2)
+
+#define TX_CTRL_TXE BIT(0) /* Tx Enable */
+
+#define TX_STATUS_PS BIT(0) /* Packet Sent */
+#define TX_STATUS_UR BIT(1) /* Tx Underrun */
+#define TX_STATUS_BE BIT(3) /* Bus Error */
+
+#define RX_CTRL_RXE BIT(0) /* Rx Enable */
+
+#define RX_STATUS_PR BIT(0) /* Packet Received */
+#define RX_STATUS_OF BIT(2) /* Rx Overflow */
+#define RX_STATUS_BE BIT(3) /* Bus Error */
+
+#define MII_CTRL_IF_MASK 3
+#define MII_CTRL_SPEED_SHIFT 4
+#define MII_CTRL_SPEED_MASK 3
+#define MII_CTRL_SPEED_10 0
+#define MII_CTRL_SPEED_100 1
+#define MII_CTRL_SPEED_1000 2
+
+static inline void ag71xx_wr(struct ag71xx *ag, unsigned reg, u32 value)
+{
+ __raw_writel(value, ag->mac_base + reg);
+ /* flush write */
+ (void) __raw_readl(ag->mac_base + reg);
+}
+
+static inline u32 ag71xx_rr(struct ag71xx *ag, unsigned reg)
+{
+ return __raw_readl(ag->mac_base + reg);
+}
+
+static inline void ag71xx_sb(struct ag71xx *ag, unsigned reg, u32 mask)
+{
+ uint32_t r;
+
+ r = ag->mac_base + reg;
+ __raw_writel(__raw_readl(r) | mask, r);
+ /* flush write */
+ (void)__raw_readl(r);
+}
+
+static inline void ag71xx_cb(struct ag71xx *ag, unsigned reg, u32 mask)
+{
+ uint32_t r;
+
+ r = ag->mac_base + reg;
+ __raw_writel(__raw_readl(r) & ~mask, r);
+ /* flush write */
+ (void) __raw_readl(r);
+}
+
+static inline void ag71xx_int_enable(struct ag71xx *ag, u32 ints)
+{
+ ag71xx_sb(ag, AG71XX_REG_INT_ENABLE, ints);
+}
+
+static inline void ag71xx_int_disable(struct ag71xx *ag, u32 ints)
+{
+ ag71xx_cb(ag, AG71XX_REG_INT_ENABLE, ints);
+}
+
+static inline void ag71xx_mii_ctrl_wr(struct ag71xx *ag, u32 value)
+{
+ __raw_writel(value, ag->mii_ctrl);
+
+ /* flush write */
+ __raw_readl(ag->mii_ctrl);
+}
+
+static inline u32 ag71xx_mii_ctrl_rr(struct ag71xx *ag)
+{
+ return __raw_readl(ag->mii_ctrl);
+}
+
+static void inline ag71xx_mii_ctrl_set_if(struct ag71xx *ag,
+ unsigned int mii_if)
+{
+ u32 t;
+
+ t = ag71xx_mii_ctrl_rr(ag);
+ t &= ~(MII_CTRL_IF_MASK);
+ t |= (mii_if & MII_CTRL_IF_MASK);
+ ag71xx_mii_ctrl_wr(ag, t);
+}
+
+static void inline ag71xx_mii_ctrl_set_speed(struct ag71xx *ag,
+ unsigned int speed)
+{
+ u32 t;
+
+ t = ag71xx_mii_ctrl_rr(ag);
+ t &= ~(MII_CTRL_SPEED_MASK << MII_CTRL_SPEED_SHIFT);
+ t |= (speed & MII_CTRL_SPEED_MASK) << MII_CTRL_SPEED_SHIFT;
+ ag71xx_mii_ctrl_wr(ag, t);
+}
+
+#ifdef CONFIG_AG71XX_AR8216_SUPPORT
+void ag71xx_add_ar8216_header(struct ag71xx *ag, struct sk_buff *skb);
+int ag71xx_remove_ar8216_header(struct ag71xx *ag, struct sk_buff *skb,
+ int pktlen);
+static inline int ag71xx_has_ar8216(struct ag71xx *ag)
+{
+ return ag71xx_get_pdata(ag)->has_ar8216;
+}
+#else
+static inline void ag71xx_add_ar8216_header(struct ag71xx *ag,
+ struct sk_buff *skb)
+{
+}
+
+static inline int ag71xx_remove_ar8216_header(struct ag71xx *ag,
+ struct sk_buff *skb,
+ int pktlen)
+{
+ return 0;
+}
+static inline int ag71xx_has_ar8216(struct ag71xx *ag)
+{
+ return 0;
+}
+#endif
+
+#endif /* _AG71XX_H */
diff --git a/package/boot/uboot-ar71xx/files/drivers/net/phy/.svn/entries b/package/boot/uboot-ar71xx/files/drivers/net/phy/.svn/entries
new file mode 100644
index 0000000..ad8ef18
--- /dev/null
+++ b/package/boot/uboot-ar71xx/files/drivers/net/phy/.svn/entries
@@ -0,0 +1,96 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/uboot-ar71xx/files/drivers/net/phy
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+rtl8366_mii.c
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+2075819b75c9da42261c89c49b53bf2d
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+18599
+
+rtl8366.h
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+6bca21a0bce104b8b2de10207b04b584
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+6036
+
diff --git a/package/boot/uboot-ar71xx/files/drivers/net/phy/.svn/prop-base/rtl8366.h.svn-base b/package/boot/uboot-ar71xx/files/drivers/net/phy/.svn/prop-base/rtl8366.h.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/boot/uboot-ar71xx/files/drivers/net/phy/.svn/prop-base/rtl8366.h.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/boot/uboot-ar71xx/files/drivers/net/phy/.svn/prop-base/rtl8366_mii.c.svn-base b/package/boot/uboot-ar71xx/files/drivers/net/phy/.svn/prop-base/rtl8366_mii.c.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/boot/uboot-ar71xx/files/drivers/net/phy/.svn/prop-base/rtl8366_mii.c.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/boot/uboot-ar71xx/files/drivers/net/phy/.svn/text-base/rtl8366.h.svn-base b/package/boot/uboot-ar71xx/files/drivers/net/phy/.svn/text-base/rtl8366.h.svn-base
new file mode 100644
index 0000000..f0567dd
--- /dev/null
+++ b/package/boot/uboot-ar71xx/files/drivers/net/phy/.svn/text-base/rtl8366.h.svn-base
@@ -0,0 +1,188 @@
+/*
+ * (C) Copyright 2010
+ * Michael Kurz <michi.kurz@googlemail.com>.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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 of
+ * the License, 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef RTL8366_MII_H
+#define RTL8366_MII_H
+
+#define MII_CONTROL_REG 0
+#define MII_STATUS_REG 1
+#define MII_PHY_ID0 2
+#define MII_PHY_ID1 3
+#define MII_LOCAL_CAP 4
+#define MII_REMOTE_CAP 5
+#define MII_EXT_AUTONEG 6
+#define MII_LOCAL_NEXT_PAGE 7
+#define MII_REMOTE_NEXT_PAGE 8
+#define MII_GIGA_CONTROL 9
+#define MII_GIGA_STATUS 10
+#define MII_EXT_STATUS_REG 15
+
+/* Control register */
+#define MII_CONTROL_1000MBPS 6
+#define MII_CONTROL_COLL_TEST 7
+#define MII_CONTROL_FULLDUPLEX 8
+#define MII_CONTROL_RENEG 9
+#define MII_CONTROL_ISOLATE 10
+#define MII_CONTROL_POWERDOWN 11
+#define MII_CONTROL_AUTONEG 12
+#define MII_CONTROL_100MBPS 13
+#define MII_CONTROL_LOOPBACK 14
+#define MII_CONTROL_RESET 15
+
+/* Status/Extended status register */
+/* Basic status */
+#define MII_STATUS_CAPABILITY 0
+#define MII_STATUS_JABBER 1
+#define MII_STATUS_LINK_UP 2
+#define MII_STATUS_AUTONEG_ABLE 3
+#define MII_STATUS_REMOTE_FAULT 4
+#define MII_STATUS_AUTONEG_DONE 5
+#define MII_STATUS_NO_PREAMBLE 6
+#define MII_STATUS_RESERVED 7
+#define MII_STATUS_EXTENDED 8
+#define MII_STATUS_100_T2_HALF 9
+#define MII_STATUS_100_T2_FULL 10
+#define MII_STATUS_10_TX_HALF 11
+#define MII_STATUS_10_TX_FULL 12
+#define MII_STATUS_100_TX_HALF 13
+#define MII_STATUS_100_TX_FULL 14
+#define MII_STATUS_100_T4 15
+
+#define MII_GIGA_CONTROL_HALF 8
+#define MII_GIGA_CONTROL_FULL 9
+#define MII_GIGA_STATUS_HALF 10
+#define MII_GIGA_STATUS_FULL 11
+
+/* Extended status */
+#define MII_STATUS_1000_T_HALF 12
+#define MII_STATUS_1000_T_FULL 13
+#define MII_STATUS_1000_X_HALF 14
+#define MII_STATUS_1000_X_FULL 15
+
+/* Local/Remmote capability register */
+#define MII_CAP_10BASE_TX 5
+#define MII_CAP_10BASE_TX_FULL 6
+#define MII_CAP_100BASE_TX 7
+#define MII_CAP_100BASE_TX_FULL 8
+#define MII_CAP_100BASE_T4 9
+#define MII_CAP_SYMM_PAUSE 10
+#define MII_CAP_ASYMM_PAUSE 11
+#define MII_CAP_RESERVED 12
+#define MII_CAP_REMOTE_FAULT 13
+#define MII_CAP_ACKNOWLEDGE 14
+#define MII_CAP_NEXT_PAGE 15
+#define MII_CAP_IEEE_802_3 0x0001
+
+#define MII_LINK_MODE_MASK 0x1f
+
+#define REALTEK_RTL8366_CHIP_ID0 0x001C
+#define REALTEK_RTL8366_CHIP_ID1 0xC940
+#define REALTEK_RTL8366_CHIP_ID1_MP 0xC960
+
+#define REALTEK_MIN_PORT_ID 0
+#define REALTEK_MAX_PORT_ID 5
+#define REALTEK_MIN_PHY_ID REALTEK_MIN_PORT_ID
+#define REALTEK_MAX_PHY_ID 4
+#define REALTEK_CPU_PORT_ID REALTEK_MAX_PORT_ID
+#define REALTEK_PHY_PORT_MASK ((1<<(REALTEK_MAX_PHY_ID+1)) - (1<<REALTEK_MIN_PHY_ID))
+#define REALTEK_CPU_PORT_MASK (1<<REALTEK_CPU_PORT_ID)
+#define REALTEK_ALL_PORT_MASK (REALTEK_PHY_PORT_MASK | REALTEK_CPU_PORT_MASK)
+
+/* port ability */
+#define RTL8366S_PORT_ABILITY_BASE 0x0011
+
+/* port vlan control register */
+#define RTL8366S_PORT_VLAN_CTRL_BASE 0x0058
+
+/* port linking status */
+#define RTL8366S_PORT_LINK_STATUS_BASE 0x0060
+#define RTL8366S_PORT_STATUS_SPEED_BIT 0
+#define RTL8366S_PORT_STATUS_SPEED_MSK 0x0003
+#define RTL8366S_PORT_STATUS_DUPLEX_BIT 2
+#define RTL8366S_PORT_STATUS_DUPLEX_MSK 0x0004
+#define RTL8366S_PORT_STATUS_LINK_BIT 4
+#define RTL8366S_PORT_STATUS_LINK_MSK 0x0010
+#define RTL8366S_PORT_STATUS_TXPAUSE_BIT 5
+#define RTL8366S_PORT_STATUS_TXPAUSE_MSK 0x0020
+#define RTL8366S_PORT_STATUS_RXPAUSE_BIT 6
+#define RTL8366S_PORT_STATUS_RXPAUSE_MSK 0x0040
+#define RTL8366S_PORT_STATUS_AN_BIT 7
+#define RTL8366S_PORT_STATUS_AN_MSK 0x0080
+
+/* internal control */
+#define RTL8366S_RESET_CONTROL_REG 0x0100
+#define RTL8366S_RESET_QUEUE_BIT 2
+
+#define RTL8366S_CHIP_ID_REG 0x0105
+
+/* MAC control */
+#define RTL8366S_MAC_FORCE_CTRL0_REG 0x0F04
+#define RTL8366S_MAC_FORCE_CTRL1_REG 0x0F05
+
+
+/* PHY registers control */
+#define RTL8366S_PHY_ACCESS_CTRL_REG 0x8028
+#define RTL8366S_PHY_ACCESS_DATA_REG 0x8029
+
+#define RTL8366S_PHY_CTRL_READ 1
+#define RTL8366S_PHY_CTRL_WRITE 0
+
+#define RTL8366S_PHY_REG_MASK 0x1F
+#define RTL8366S_PHY_PAGE_OFFSET 5
+#define RTL8366S_PHY_PAGE_MASK (0x7<<5)
+#define RTL8366S_PHY_NO_OFFSET 9
+#define RTL8366S_PHY_NO_MASK (0x1F<<9)
+
+#define RTL8366S_PHY_NO_MAX 4
+#define RTL8366S_PHY_PAGE_MAX 7
+#define RTL8366S_PHY_ADDR_MAX 31
+
+/* cpu port control reg */
+#define RTL8366S_CPU_CTRL_REG 0x004F
+#define RTL8366S_CPU_DRP_BIT 14
+#define RTL8366S_CPU_DRP_MSK 0x4000
+#define RTL8366S_CPU_INSTAG_BIT 15
+#define RTL8366S_CPU_INSTAG_MSK 0x8000
+
+/* LED registers*/
+#define RTL8366S_LED_BLINK_REG 0x420
+#define RTL8366S_LED_BLINKRATE_BIT 0
+#define RTL8366S_LED_BLINKRATE_MSK 0x0007
+#define RTL8366S_LED_INDICATED_CONF_REG 0x421
+#define RTL8366S_LED_0_1_FORCE_REG 0x422
+#define RTL8366S_LED_2_3_FORCE_REG 0x423
+#define RTL8366S_LEDCONF_LEDFORCE 0x1F
+#define RTL8366S_LED_GROUP_MAX 4
+
+#define RTL8366S_GREEN_FEATURE_REG 0x000A
+#define RTL8366S_GREEN_FEATURE_TX_BIT 3
+#define RTL8366S_GREEN_FEATURE_TX_MSK 0x0008
+#define RTL8366S_GREEN_FEATURE_RX_BIT 4
+#define RTL8366S_GREEN_FEATURE_RX_MSK 0x0010
+
+#define RTL8366S_MODEL_ID_REG 0x5C
+#define RTL8366S_REV_ID_REG 0x5D
+#define RTL8366S_MODEL_8366SR 0x6027
+#define RTL8366S_MODEL_8366RB 0x5937
+
+#endif
diff --git a/package/boot/uboot-ar71xx/files/drivers/net/phy/.svn/text-base/rtl8366_mii.c.svn-base b/package/boot/uboot-ar71xx/files/drivers/net/phy/.svn/text-base/rtl8366_mii.c.svn-base
new file mode 100644
index 0000000..e3c5316
--- /dev/null
+++ b/package/boot/uboot-ar71xx/files/drivers/net/phy/.svn/text-base/rtl8366_mii.c.svn-base
@@ -0,0 +1,786 @@
+/*
+ * (C) Copyright 2010
+ * Michael Kurz <michi.kurz@googlemail.com>.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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 of
+ * the License, 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+
+#include <common.h>
+#include <net.h>
+#include <netdev.h>
+#include <miiphy.h>
+#include MII_GPIOINCLUDE
+
+#include "rtl8366.h"
+
+#ifdef DEBUG_RTL8366
+ #define DBG(fmt,args...) printf (fmt ,##args)
+#else
+ #define DBG(fmt,args...)
+#endif
+
+
+//-------------------------------------------------------------------
+// Soft SMI functions
+//-------------------------------------------------------------------
+
+#define DELAY 2
+
+static void smi_init(void)
+{
+ MII_SDAINPUT;
+ MII_SCKINPUT;
+
+ MII_SETSDA(1);
+ MII_SETSCK(1);
+
+ udelay(20);
+}
+
+static void smi_start(void)
+{
+/*
+ * rtl8366 chip needs a extra clock with
+ * SDA high before start condition
+ */
+
+ /* set gpio pins output */
+ MII_SDAOUTPUT;
+ MII_SCKOUTPUT;
+ udelay(DELAY);
+
+ /* set initial state: SCK:0, SDA:1 */
+ MII_SETSCK(0);
+ MII_SETSDA(1);
+ udelay(DELAY);
+
+ /* toggle clock */
+ MII_SETSCK(1);
+ udelay(DELAY);
+ MII_SETSCK(0);
+ udelay(DELAY);
+
+ /* start condition */
+ MII_SETSCK(1);
+ udelay(DELAY);
+ MII_SETSDA(0);
+ udelay(DELAY);
+ MII_SETSCK(0);
+ udelay(DELAY);
+ MII_SETSDA(1);
+}
+
+static void smi_stop(void)
+{
+/*
+ * rtl8366 chip needs a extra clock with
+ * SDA high after stop condition
+ */
+
+ /* stop condition */
+ udelay(DELAY);
+ MII_SETSDA(0);
+ MII_SETSCK(1);
+ udelay(DELAY);
+ MII_SETSDA(1);
+ udelay(DELAY);
+ MII_SETSCK(1);
+ udelay(DELAY);
+ MII_SETSCK(0);
+ udelay(DELAY);
+
+ /* toggle clock */
+ MII_SETSCK(1);
+ udelay(DELAY);
+ MII_SETSCK(0);
+ udelay(DELAY);
+ MII_SETSCK(1);
+
+ /* set gpio pins input */
+ MII_SDAINPUT;
+ MII_SCKINPUT;
+}
+
+static void smi_writeBits(uint32_t data, uint8_t length)
+{
+ uint8_t test;
+
+ for( ; length > 0; length--) {
+ udelay(DELAY);
+
+ /* output data */
+ test = (((data & (1 << (length - 1))) != 0) ? 1 : 0);
+ MII_SETSDA(test);
+ udelay(DELAY);
+
+ /* toogle clock */
+ MII_SETSCK(1);
+ udelay(DELAY);
+ MII_SETSCK(0);
+ }
+}
+
+static uint32_t smi_readBits(uint8_t length)
+{
+ uint32_t ret;
+
+ MII_SDAINPUT;
+
+ for(ret = 0 ; length > 0; length--) {
+ udelay(DELAY);
+
+ ret <<= 1;
+
+ /* toogle clock */
+ MII_SETSCK(1);
+ udelay(DELAY);
+ ret |= MII_GETSDA;
+ MII_SETSCK(0);
+ }
+
+ MII_SDAOUTPUT;
+
+ return ret;
+}
+
+static int smi_waitAck(void)
+{
+ uint32_t retry = 0;
+
+ while (smi_readBits(1)) {
+ if (retry++ == 5)
+ return -1;
+ }
+
+ return 0;
+
+}
+
+static int smi_read(uint32_t reg, uint32_t *data)
+{
+ uint32_t rawData;
+
+ /* send start condition */
+ smi_start();
+ /* send CTRL1 code: 0b1010*/
+ smi_writeBits(0x0a, 4);
+ /* send CTRL2 code: 0b100 */
+ smi_writeBits(0x04, 3);
+ /* send READ command */
+ smi_writeBits(0x01, 1);
+
+ /* wait for ACK */
+ if (smi_waitAck())
+ return -1;
+
+ /* send address low */
+ smi_writeBits(reg & 0xFF, 8);
+ /* wait for ACK */
+ if (smi_waitAck())
+ return -1;
+ /* send address high */
+ smi_writeBits((reg & 0xFF00) >> 8, 8);
+ /* wait for ACK */
+ if (smi_waitAck())
+ return -1;
+
+ /* read data low */
+ rawData = (smi_readBits(8) & 0xFF);
+ /* send ACK */
+ smi_writeBits(0, 1);
+ /* read data high */
+ rawData |= (smi_readBits(8) & 0xFF) << 8;
+ /* send NACK */
+ smi_writeBits(1, 1);
+
+ /* send stop condition */
+ smi_stop();
+
+ if (data)
+ *data = rawData;
+
+ return 0;
+}
+
+static int smi_write(uint32_t reg, uint32_t data)
+{
+ /* send start condition */
+ smi_start();
+ /* send CTRL1 code: 0b1010*/
+ smi_writeBits(0x0a, 4);
+ /* send CTRL2 code: 0b100 */
+ smi_writeBits(0x04, 3);
+ /* send WRITE command */
+ smi_writeBits(0x00, 1);
+
+ /* wait for ACK */
+ if (smi_waitAck())
+ return -1;
+
+ /* send address low */
+ smi_writeBits(reg & 0xFF, 8);
+ /* wait for ACK */
+ if (smi_waitAck())
+ return -1;
+ /* send address high */
+ smi_writeBits((reg & 0xFF00) >> 8, 8);
+ /* wait for ACK */
+ if (smi_waitAck())
+ return -1;
+
+ /* send data low */
+ smi_writeBits(data & 0xFF, 8);
+ /* wait for ACK */
+ if (smi_waitAck())
+ return -1;
+ /* send data high */
+ smi_writeBits((data & 0xFF00) >> 8, 8);
+ /* wait for ACK */
+ if (smi_waitAck())
+ return -1;
+
+ /* send stop condition */
+ smi_stop();
+
+ return 0;
+}
+
+
+//-------------------------------------------------------------------
+// Switch register read / write functions
+//-------------------------------------------------------------------
+static int rtl8366_readRegister(uint32_t reg, uint16_t *data)
+{
+ uint32_t regData;
+
+ DBG("rtl8366: read register=%#04x, data=", reg);
+
+ if (smi_read(reg, &regData)) {
+ printf("\nrtl8366 smi read failed!\n");
+ return -1;
+ }
+
+ if (data)
+ *data = regData;
+
+ DBG("%#04x\n", regData);
+
+ return 0;
+}
+
+static int rtl8366_writeRegister(uint32_t reg, uint16_t data)
+{
+ DBG("rtl8366: write register=%#04x, data=%#04x\n", reg, data);
+
+ if (smi_write(reg, data)) {
+ printf("rtl8366 smi write failed!\n");
+ return -1;
+ }
+
+ return 0;
+}
+
+static int rtl8366_setRegisterBit(uint32_t reg, uint32_t bitNum, uint32_t value)
+{
+ uint16_t regData;
+
+ if (bitNum >= 16)
+ return -1;
+
+ if (rtl8366_readRegister(reg, &regData))
+ return -1;
+
+ if (value)
+ regData |= (1 << bitNum);
+ else
+ regData &= ~(1 << bitNum);
+
+ if (rtl8366_writeRegister(reg, regData))
+ return -1;
+
+ return 0;
+}
+
+//-------------------------------------------------------------------
+// MII PHY read / write functions
+//-------------------------------------------------------------------
+static int rtl8366_getPhyReg(uint32_t phyNum, uint32_t reg, uint16_t *data)
+{
+ uint16_t phyAddr, regData;
+
+ if (phyNum > RTL8366S_PHY_NO_MAX) {
+ printf("rtl8366s: invalid phy number!\n");
+ return -1;
+ }
+
+ if (phyNum > RTL8366S_PHY_ADDR_MAX) {
+ printf("rtl8366s: invalid phy register number!\n");
+ return -1;
+ }
+
+ if (rtl8366_writeRegister(RTL8366S_PHY_ACCESS_CTRL_REG,
+ RTL8366S_PHY_CTRL_READ))
+ return -1;
+
+ phyAddr = 0x8000 | (1 << (phyNum + RTL8366S_PHY_NO_OFFSET))
+ | (reg & RTL8366S_PHY_REG_MASK);
+ if (rtl8366_writeRegister(phyAddr, 0))
+ return -1;
+
+ if (rtl8366_readRegister(RTL8366S_PHY_ACCESS_DATA_REG, &regData))
+ return -1;
+
+ if (data)
+ *data = regData;
+
+ return 0;
+}
+
+static int rtl8366_setPhyReg(uint32_t phyNum, uint32_t reg, uint16_t data)
+{
+ uint16_t phyAddr;
+
+ if (phyNum > RTL8366S_PHY_NO_MAX) {
+ printf("rtl8366s: invalid phy number!\n");
+ return -1;
+ }
+
+ if (phyNum > RTL8366S_PHY_ADDR_MAX) {
+ printf("rtl8366s: invalid phy register number!\n");
+ return -1;
+ }
+
+ if (rtl8366_writeRegister(RTL8366S_PHY_ACCESS_CTRL_REG,
+ RTL8366S_PHY_CTRL_WRITE))
+ return -1;
+
+ phyAddr = 0x8000 | (1 << (phyNum + RTL8366S_PHY_NO_OFFSET))
+ | (reg & RTL8366S_PHY_REG_MASK);
+ if (rtl8366_writeRegister(phyAddr, data))
+ return -1;
+
+ return 0;
+}
+
+static int rtl8366_miiread(char *devname, uchar phy_adr, uchar reg, ushort *data)
+{
+ uint16_t regData;
+
+ DBG("rtl8366_miiread: devname=%s, addr=%#02x, reg=%#02x\n",
+ devname, phy_adr, reg);
+
+ if (strcmp(devname, RTL8366_DEVNAME) != 0)
+ return -1;
+
+ if (rtl8366_getPhyReg(phy_adr, reg, &regData)) {
+ printf("rtl8366_miiread: write failed!\n");
+ return -1;
+ }
+
+ if (data)
+ *data = regData;
+
+ return 0;
+}
+
+static int rtl8366_miiwrite(char *devname, uchar phy_adr, uchar reg, ushort data)
+{
+ DBG("rtl8366_miiwrite: devname=%s, addr=%#02x, reg=%#02x, data=%#04x\n",
+ devname, phy_adr, reg, data);
+
+ if (strcmp(devname, RTL8366_DEVNAME) != 0)
+ return -1;
+
+ if (rtl8366_setPhyReg(phy_adr, reg, data)) {
+ printf("rtl8366_miiwrite: write failed!\n");
+ return -1;
+ }
+
+ return 0;
+}
+
+int rtl8366_mii_register(bd_t *bis)
+{
+ miiphy_register(strdup(RTL8366_DEVNAME), rtl8366_miiread,
+ rtl8366_miiwrite);
+
+ return 0;
+}
+
+
+//-------------------------------------------------------------------
+// Switch management functions
+//-------------------------------------------------------------------
+
+int rtl8366s_setGreenFeature(uint32_t tx, uint32_t rx)
+{
+ if (rtl8366_setRegisterBit(RTL8366S_GREEN_FEATURE_REG,
+ RTL8366S_GREEN_FEATURE_TX_BIT, tx))
+ return -1;
+
+ if (rtl8366_setRegisterBit(RTL8366S_GREEN_FEATURE_REG,
+ RTL8366S_GREEN_FEATURE_RX_BIT, rx))
+ return -1;
+
+ return 0;
+}
+
+int rtl8366s_setPowerSaving(uint32_t phyNum, uint32_t enabled)
+{
+ uint16_t regData;
+
+ if (phyNum > RTL8366S_PHY_NO_MAX)
+ return -1;
+
+ if (rtl8366_getPhyReg(phyNum, 12, &regData))
+ return -1;
+
+ if (enabled)
+ regData |= (1 << 12);
+ else
+ regData &= ~(1 << 12);
+
+ if (rtl8366_setPhyReg(phyNum, 12, regData))
+ return -1;
+
+ return 0;
+}
+
+int rtl8366s_setGreenEthernet(uint32_t greenFeature, uint32_t powerSaving)
+{
+ uint32_t phyNum, i;
+ uint16_t regData;
+
+ const uint16_t greenSettings[][2] =
+ {
+ {0xBE5B,0x3500},
+ {0xBE5C,0xB975},
+ {0xBE5D,0xB9B9},
+ {0xBE77,0xA500},
+ {0xBE78,0x5A78},
+ {0xBE79,0x6478}
+ };
+
+ if (rtl8366_readRegister(RTL8366S_MODEL_ID_REG, &regData))
+ return -1;
+
+ switch (regData)
+ {
+ case 0x0000:
+ for (i = 0; i < 6; i++) {
+ if (rtl8366_writeRegister(RTL8366S_PHY_ACCESS_CTRL_REG, RTL8366S_PHY_CTRL_WRITE))
+ return -1;
+ if (rtl8366_writeRegister(greenSettings[i][0], greenSettings[i][1]))
+ return -1;
+ }
+ break;
+
+ case RTL8366S_MODEL_8366SR:
+ if (rtl8366_writeRegister(RTL8366S_PHY_ACCESS_CTRL_REG, RTL8366S_PHY_CTRL_WRITE))
+ return -1;
+ if (rtl8366_writeRegister(greenSettings[0][0], greenSettings[0][1]))
+ return -1;
+ break;
+
+ default:
+ printf("rtl8366s_initChip: unsupported chip found!\n");
+ return -1;
+ }
+
+ if (rtl8366s_setGreenFeature(greenFeature, powerSaving))
+ return -1;
+
+ for (phyNum = 0; phyNum <= RTL8366S_PHY_NO_MAX; phyNum++) {
+ if (rtl8366s_setPowerSaving(phyNum, powerSaving))
+ return -1;
+ }
+
+ return 0;
+}
+
+int rtl8366s_setCPUPortMask(uint8_t port, uint32_t enabled)
+{
+ if(port >= 6){
+ printf("rtl8366s_setCPUPortMask: invalid port number\n");
+ return -1;
+ }
+
+ return rtl8366_setRegisterBit(RTL8366S_CPU_CTRL_REG, port, enabled);
+}
+
+int rtl8366s_setCPUDisableInsTag(uint32_t enable)
+{
+ return rtl8366_setRegisterBit(RTL8366S_CPU_CTRL_REG,
+ RTL8366S_CPU_INSTAG_BIT, enable);
+}
+
+int rtl8366s_setCPUDropUnda(uint32_t enable)
+{
+ return rtl8366_setRegisterBit(RTL8366S_CPU_CTRL_REG,
+ RTL8366S_CPU_DRP_BIT, enable);
+}
+
+int rtl8366s_setCPUPort(uint8_t port, uint32_t noTag, uint32_t dropUnda)
+{
+ uint32_t i;
+
+ if(port >= 6){
+ printf("rtl8366s_setCPUPort: invalid port number\n");
+ return -1;
+ }
+
+ /* reset register */
+ for(i = 0; i < 6; i++)
+ {
+ if(rtl8366s_setCPUPortMask(i, 0)){
+ printf("rtl8366s_setCPUPort: rtl8366s_setCPUPortMask failed\n");
+ return -1;
+ }
+ }
+
+ if(rtl8366s_setCPUPortMask(port, 1)){
+ printf("rtl8366s_setCPUPort: rtl8366s_setCPUPortMask failed\n");
+ return -1;
+ }
+
+ if(rtl8366s_setCPUDisableInsTag(noTag)){
+ printf("rtl8366s_setCPUPort: rtl8366s_setCPUDisableInsTag fail\n");
+ return -1;
+ }
+
+ if(rtl8366s_setCPUDropUnda(dropUnda)){
+ printf("rtl8366s_setCPUPort: rtl8366s_setCPUDropUnda fail\n");
+ return -1;
+ }
+
+ return 0;
+}
+
+int rtl8366s_setLedConfig(uint32_t ledNum, uint8_t config)
+{
+ uint16_t regData;
+
+ if(ledNum >= RTL8366S_LED_GROUP_MAX) {
+ DBG("rtl8366s_setLedConfig: invalid led group\n");
+ return -1;
+ }
+
+ if(config > RTL8366S_LEDCONF_LEDFORCE) {
+ DBG("rtl8366s_setLedConfig: invalid led config\n");
+ return -1;
+ }
+
+ if (rtl8366_readRegister(RTL8366S_LED_INDICATED_CONF_REG, &regData)) {
+ printf("rtl8366s_setLedConfig: failed to get led register!\n");
+ return -1;
+ }
+
+ regData &= ~(0xF << (ledNum * 4));
+ regData |= config << (ledNum * 4);
+
+ if (rtl8366_writeRegister(RTL8366S_LED_INDICATED_CONF_REG, regData)) {
+ printf("rtl8366s_setLedConfig: failed to set led register!\n");
+ return -1;
+ }
+
+ return 0;
+}
+
+int rtl8366s_getLedConfig(uint32_t ledNum, uint8_t *config)
+{
+ uint16_t regData;
+
+ if(ledNum >= RTL8366S_LED_GROUP_MAX) {
+ DBG("rtl8366s_getLedConfig: invalid led group\n");
+ return -1;
+ }
+
+ if (rtl8366_readRegister(RTL8366S_LED_INDICATED_CONF_REG, &regData)) {
+ printf("rtl8366s_getLedConfig: failed to get led register!\n");
+ return -1;
+ }
+
+ if (config)
+ *config = (regData >> (ledNum * 4)) & 0xF;
+
+ return 0;
+}
+
+int rtl8366s_setLedForceValue(uint32_t group0, uint32_t group1,
+ uint32_t group2, uint32_t group3)
+{
+ uint16_t regData;
+
+ regData = (group0 & 0x3F) | ((group1 & 0x3F) << 6);
+ if (rtl8366_writeRegister(RTL8366S_LED_0_1_FORCE_REG, regData)) {
+ printf("rtl8366s_setLedForceValue: failed to set led register!\n");
+ return -1;
+ }
+
+ regData = (group2 & 0x3F) | ((group3 & 0x3F) << 6);
+ if (rtl8366_writeRegister(RTL8366S_LED_2_3_FORCE_REG, regData)) {
+ printf("rtl8366s_setLedForceValue: failed to set led register!\n");
+ return -1;
+ }
+
+ return 0;
+}
+
+int rtl8366s_initChip(void)
+{
+ uint32_t ledGroup, i = 0;
+ uint16_t regData;
+ uint8_t ledData[RTL8366S_LED_GROUP_MAX];
+ const uint16_t (*chipData)[2];
+
+ const uint16_t chipB[][2] =
+ {
+ {0x0000, 0x0038},{0x8100, 0x1B37},{0xBE2E, 0x7B9F},{0xBE2B, 0xA4C8},
+ {0xBE74, 0xAD14},{0xBE2C, 0xDC00},{0xBE69, 0xD20F},{0xBE3B, 0xB414},
+ {0xBE24, 0x0000},{0xBE23, 0x00A1},{0xBE22, 0x0008},{0xBE21, 0x0120},
+ {0xBE20, 0x1000},{0xBE24, 0x0800},{0xBE24, 0x0000},{0xBE24, 0xF000},
+ {0xBE23, 0xDF01},{0xBE22, 0xDF20},{0xBE21, 0x101A},{0xBE20, 0xA0FF},
+ {0xBE24, 0xF800},{0xBE24, 0xF000},{0x0242, 0x02BF},{0x0245, 0x02BF},
+ {0x0248, 0x02BF},{0x024B, 0x02BF},{0x024E, 0x02BF},{0x0251, 0x02BF},
+ {0x0230, 0x0A32},{0x0233, 0x0A32},{0x0236, 0x0A32},{0x0239, 0x0A32},
+ {0x023C, 0x0A32},{0x023F, 0x0A32},{0x0254, 0x0A3F},{0x0255, 0x0064},
+ {0x0256, 0x0A3F},{0x0257, 0x0064},{0x0258, 0x0A3F},{0x0259, 0x0064},
+ {0x025A, 0x0A3F},{0x025B, 0x0064},{0x025C, 0x0A3F},{0x025D, 0x0064},
+ {0x025E, 0x0A3F},{0x025F, 0x0064},{0x0260, 0x0178},{0x0261, 0x01F4},
+ {0x0262, 0x0320},{0x0263, 0x0014},{0x021D, 0x9249},{0x021E, 0x0000},
+ {0x0100, 0x0004},{0xBE4A, 0xA0B4},{0xBE40, 0x9C00},{0xBE41, 0x501D},
+ {0xBE48, 0x3602},{0xBE47, 0x8051},{0xBE4C, 0x6465},{0x8000, 0x1F00},
+ {0x8001, 0x000C},{0x8008, 0x0000},{0x8007, 0x0000},{0x800C, 0x00A5},
+ {0x8101, 0x02BC},{0xBE53, 0x0005},{0x8E45, 0xAFE8},{0x8013, 0x0005},
+ {0xBE4B, 0x6700},{0x800B, 0x7000},{0xBE09, 0x0E00},
+ {0xFFFF, 0xABCD}
+ };
+
+ const uint16_t chipDefault[][2] =
+ {
+ {0x0242, 0x02BF},{0x0245, 0x02BF},{0x0248, 0x02BF},{0x024B, 0x02BF},
+ {0x024E, 0x02BF},{0x0251, 0x02BF},
+ {0x0254, 0x0A3F},{0x0256, 0x0A3F},{0x0258, 0x0A3F},{0x025A, 0x0A3F},
+ {0x025C, 0x0A3F},{0x025E, 0x0A3F},
+ {0x0263, 0x007C},{0x0100, 0x0004},
+ {0xBE5B, 0x3500},{0x800E, 0x200F},{0xBE1D, 0x0F00},{0x8001, 0x5011},
+ {0x800A, 0xA2F4},{0x800B, 0x17A3},{0xBE4B, 0x17A3},{0xBE41, 0x5011},
+ {0xBE17, 0x2100},{0x8000, 0x8304},{0xBE40, 0x8304},{0xBE4A, 0xA2F4},
+ {0x800C, 0xA8D5},{0x8014, 0x5500},{0x8015, 0x0004},{0xBE4C, 0xA8D5},
+ {0xBE59, 0x0008},{0xBE09, 0x0E00},{0xBE36, 0x1036},{0xBE37, 0x1036},
+ {0x800D, 0x00FF},{0xBE4D, 0x00FF},
+ {0xFFFF, 0xABCD}
+ };
+
+ DBG("rtl8366s_initChip\n");
+
+ /* save current led config and set to led force */
+ for (ledGroup = 0; ledGroup < RTL8366S_LED_GROUP_MAX; ledGroup++) {
+ if (rtl8366s_getLedConfig(ledGroup, &ledData[ledGroup]))
+ return -1;
+
+ if (rtl8366s_setLedConfig(ledGroup, RTL8366S_LEDCONF_LEDFORCE))
+ return -1;
+ }
+
+ if (rtl8366s_setLedForceValue(0,0,0,0))
+ return -1;
+
+ if (rtl8366_readRegister(RTL8366S_MODEL_ID_REG, &regData))
+ return -1;
+
+ switch (regData)
+ {
+ case 0x0000:
+ chipData = chipB;
+ break;
+
+ case RTL8366S_MODEL_8366SR:
+ chipData = chipDefault;
+ break;
+
+ default:
+ printf("rtl8366s_initChip: unsupported chip found!\n");
+ return -1;
+ }
+
+ DBG("rtl8366s_initChip: found %x chip\n", regData);
+
+ while ((chipData[i][0] != 0xFFFF) && (chipData[i][1] != 0xABCD)) {
+
+ /* phy settings*/
+ if ((chipData[i][0] & 0xBE00) == 0xBE00) {
+ if (rtl8366_writeRegister(RTL8366S_PHY_ACCESS_CTRL_REG,
+ RTL8366S_PHY_CTRL_WRITE))
+ return -1;
+ }
+
+ if (rtl8366_writeRegister(chipData[i][0], chipData[i][1]))
+ return -1;
+
+ i++;
+ }
+
+ /* chip needs some time */
+ udelay(100 * 1000);
+
+ /* restore led config */
+ for (ledGroup = 0; ledGroup < RTL8366S_LED_GROUP_MAX; ledGroup++) {
+ if (rtl8366s_setLedConfig(ledGroup, ledData[ledGroup]))
+ return -1;
+ }
+
+ return 0;
+}
+
+int rtl8366s_initialize(void)
+{
+ uint16_t regData;
+
+ DBG("rtl8366s_initialize: start setup\n");
+
+ smi_init();
+
+ rtl8366_readRegister(RTL8366S_CHIP_ID_REG, &regData);
+ DBG("Realtek 8366SR switch ID %#04x\n", regData);
+
+ if (regData != 0x8366) {
+ printf("rtl8366s_initialize: found unsupported switch\n");
+ return -1;
+ }
+
+ if (rtl8366s_initChip()) {
+ printf("rtl8366s_initialize: init chip failed\n");
+ return -1;
+ }
+
+ if (rtl8366s_setGreenEthernet(1, 1)) {
+ printf("rtl8366s_initialize: set green ethernet failed\n");
+ return -1;
+ }
+
+ /* Set port 5 noTag and don't dropUnda */
+ if (rtl8366s_setCPUPort(5, 1, 0)) {
+ printf("rtl8366s_initialize: set CPU port failed\n");
+ return -1;
+ }
+
+ return 0;
+}
diff --git a/package/boot/uboot-ar71xx/files/drivers/net/phy/rtl8366.h b/package/boot/uboot-ar71xx/files/drivers/net/phy/rtl8366.h
new file mode 100644
index 0000000..f0567dd
--- /dev/null
+++ b/package/boot/uboot-ar71xx/files/drivers/net/phy/rtl8366.h
@@ -0,0 +1,188 @@
+/*
+ * (C) Copyright 2010
+ * Michael Kurz <michi.kurz@googlemail.com>.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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 of
+ * the License, 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef RTL8366_MII_H
+#define RTL8366_MII_H
+
+#define MII_CONTROL_REG 0
+#define MII_STATUS_REG 1
+#define MII_PHY_ID0 2
+#define MII_PHY_ID1 3
+#define MII_LOCAL_CAP 4
+#define MII_REMOTE_CAP 5
+#define MII_EXT_AUTONEG 6
+#define MII_LOCAL_NEXT_PAGE 7
+#define MII_REMOTE_NEXT_PAGE 8
+#define MII_GIGA_CONTROL 9
+#define MII_GIGA_STATUS 10
+#define MII_EXT_STATUS_REG 15
+
+/* Control register */
+#define MII_CONTROL_1000MBPS 6
+#define MII_CONTROL_COLL_TEST 7
+#define MII_CONTROL_FULLDUPLEX 8
+#define MII_CONTROL_RENEG 9
+#define MII_CONTROL_ISOLATE 10
+#define MII_CONTROL_POWERDOWN 11
+#define MII_CONTROL_AUTONEG 12
+#define MII_CONTROL_100MBPS 13
+#define MII_CONTROL_LOOPBACK 14
+#define MII_CONTROL_RESET 15
+
+/* Status/Extended status register */
+/* Basic status */
+#define MII_STATUS_CAPABILITY 0
+#define MII_STATUS_JABBER 1
+#define MII_STATUS_LINK_UP 2
+#define MII_STATUS_AUTONEG_ABLE 3
+#define MII_STATUS_REMOTE_FAULT 4
+#define MII_STATUS_AUTONEG_DONE 5
+#define MII_STATUS_NO_PREAMBLE 6
+#define MII_STATUS_RESERVED 7
+#define MII_STATUS_EXTENDED 8
+#define MII_STATUS_100_T2_HALF 9
+#define MII_STATUS_100_T2_FULL 10
+#define MII_STATUS_10_TX_HALF 11
+#define MII_STATUS_10_TX_FULL 12
+#define MII_STATUS_100_TX_HALF 13
+#define MII_STATUS_100_TX_FULL 14
+#define MII_STATUS_100_T4 15
+
+#define MII_GIGA_CONTROL_HALF 8
+#define MII_GIGA_CONTROL_FULL 9
+#define MII_GIGA_STATUS_HALF 10
+#define MII_GIGA_STATUS_FULL 11
+
+/* Extended status */
+#define MII_STATUS_1000_T_HALF 12
+#define MII_STATUS_1000_T_FULL 13
+#define MII_STATUS_1000_X_HALF 14
+#define MII_STATUS_1000_X_FULL 15
+
+/* Local/Remmote capability register */
+#define MII_CAP_10BASE_TX 5
+#define MII_CAP_10BASE_TX_FULL 6
+#define MII_CAP_100BASE_TX 7
+#define MII_CAP_100BASE_TX_FULL 8
+#define MII_CAP_100BASE_T4 9
+#define MII_CAP_SYMM_PAUSE 10
+#define MII_CAP_ASYMM_PAUSE 11
+#define MII_CAP_RESERVED 12
+#define MII_CAP_REMOTE_FAULT 13
+#define MII_CAP_ACKNOWLEDGE 14
+#define MII_CAP_NEXT_PAGE 15
+#define MII_CAP_IEEE_802_3 0x0001
+
+#define MII_LINK_MODE_MASK 0x1f
+
+#define REALTEK_RTL8366_CHIP_ID0 0x001C
+#define REALTEK_RTL8366_CHIP_ID1 0xC940
+#define REALTEK_RTL8366_CHIP_ID1_MP 0xC960
+
+#define REALTEK_MIN_PORT_ID 0
+#define REALTEK_MAX_PORT_ID 5
+#define REALTEK_MIN_PHY_ID REALTEK_MIN_PORT_ID
+#define REALTEK_MAX_PHY_ID 4
+#define REALTEK_CPU_PORT_ID REALTEK_MAX_PORT_ID
+#define REALTEK_PHY_PORT_MASK ((1<<(REALTEK_MAX_PHY_ID+1)) - (1<<REALTEK_MIN_PHY_ID))
+#define REALTEK_CPU_PORT_MASK (1<<REALTEK_CPU_PORT_ID)
+#define REALTEK_ALL_PORT_MASK (REALTEK_PHY_PORT_MASK | REALTEK_CPU_PORT_MASK)
+
+/* port ability */
+#define RTL8366S_PORT_ABILITY_BASE 0x0011
+
+/* port vlan control register */
+#define RTL8366S_PORT_VLAN_CTRL_BASE 0x0058
+
+/* port linking status */
+#define RTL8366S_PORT_LINK_STATUS_BASE 0x0060
+#define RTL8366S_PORT_STATUS_SPEED_BIT 0
+#define RTL8366S_PORT_STATUS_SPEED_MSK 0x0003
+#define RTL8366S_PORT_STATUS_DUPLEX_BIT 2
+#define RTL8366S_PORT_STATUS_DUPLEX_MSK 0x0004
+#define RTL8366S_PORT_STATUS_LINK_BIT 4
+#define RTL8366S_PORT_STATUS_LINK_MSK 0x0010
+#define RTL8366S_PORT_STATUS_TXPAUSE_BIT 5
+#define RTL8366S_PORT_STATUS_TXPAUSE_MSK 0x0020
+#define RTL8366S_PORT_STATUS_RXPAUSE_BIT 6
+#define RTL8366S_PORT_STATUS_RXPAUSE_MSK 0x0040
+#define RTL8366S_PORT_STATUS_AN_BIT 7
+#define RTL8366S_PORT_STATUS_AN_MSK 0x0080
+
+/* internal control */
+#define RTL8366S_RESET_CONTROL_REG 0x0100
+#define RTL8366S_RESET_QUEUE_BIT 2
+
+#define RTL8366S_CHIP_ID_REG 0x0105
+
+/* MAC control */
+#define RTL8366S_MAC_FORCE_CTRL0_REG 0x0F04
+#define RTL8366S_MAC_FORCE_CTRL1_REG 0x0F05
+
+
+/* PHY registers control */
+#define RTL8366S_PHY_ACCESS_CTRL_REG 0x8028
+#define RTL8366S_PHY_ACCESS_DATA_REG 0x8029
+
+#define RTL8366S_PHY_CTRL_READ 1
+#define RTL8366S_PHY_CTRL_WRITE 0
+
+#define RTL8366S_PHY_REG_MASK 0x1F
+#define RTL8366S_PHY_PAGE_OFFSET 5
+#define RTL8366S_PHY_PAGE_MASK (0x7<<5)
+#define RTL8366S_PHY_NO_OFFSET 9
+#define RTL8366S_PHY_NO_MASK (0x1F<<9)
+
+#define RTL8366S_PHY_NO_MAX 4
+#define RTL8366S_PHY_PAGE_MAX 7
+#define RTL8366S_PHY_ADDR_MAX 31
+
+/* cpu port control reg */
+#define RTL8366S_CPU_CTRL_REG 0x004F
+#define RTL8366S_CPU_DRP_BIT 14
+#define RTL8366S_CPU_DRP_MSK 0x4000
+#define RTL8366S_CPU_INSTAG_BIT 15
+#define RTL8366S_CPU_INSTAG_MSK 0x8000
+
+/* LED registers*/
+#define RTL8366S_LED_BLINK_REG 0x420
+#define RTL8366S_LED_BLINKRATE_BIT 0
+#define RTL8366S_LED_BLINKRATE_MSK 0x0007
+#define RTL8366S_LED_INDICATED_CONF_REG 0x421
+#define RTL8366S_LED_0_1_FORCE_REG 0x422
+#define RTL8366S_LED_2_3_FORCE_REG 0x423
+#define RTL8366S_LEDCONF_LEDFORCE 0x1F
+#define RTL8366S_LED_GROUP_MAX 4
+
+#define RTL8366S_GREEN_FEATURE_REG 0x000A
+#define RTL8366S_GREEN_FEATURE_TX_BIT 3
+#define RTL8366S_GREEN_FEATURE_TX_MSK 0x0008
+#define RTL8366S_GREEN_FEATURE_RX_BIT 4
+#define RTL8366S_GREEN_FEATURE_RX_MSK 0x0010
+
+#define RTL8366S_MODEL_ID_REG 0x5C
+#define RTL8366S_REV_ID_REG 0x5D
+#define RTL8366S_MODEL_8366SR 0x6027
+#define RTL8366S_MODEL_8366RB 0x5937
+
+#endif
diff --git a/package/boot/uboot-ar71xx/files/drivers/net/phy/rtl8366_mii.c b/package/boot/uboot-ar71xx/files/drivers/net/phy/rtl8366_mii.c
new file mode 100644
index 0000000..e3c5316
--- /dev/null
+++ b/package/boot/uboot-ar71xx/files/drivers/net/phy/rtl8366_mii.c
@@ -0,0 +1,786 @@
+/*
+ * (C) Copyright 2010
+ * Michael Kurz <michi.kurz@googlemail.com>.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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 of
+ * the License, 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+
+#include <common.h>
+#include <net.h>
+#include <netdev.h>
+#include <miiphy.h>
+#include MII_GPIOINCLUDE
+
+#include "rtl8366.h"
+
+#ifdef DEBUG_RTL8366
+ #define DBG(fmt,args...) printf (fmt ,##args)
+#else
+ #define DBG(fmt,args...)
+#endif
+
+
+//-------------------------------------------------------------------
+// Soft SMI functions
+//-------------------------------------------------------------------
+
+#define DELAY 2
+
+static void smi_init(void)
+{
+ MII_SDAINPUT;
+ MII_SCKINPUT;
+
+ MII_SETSDA(1);
+ MII_SETSCK(1);
+
+ udelay(20);
+}
+
+static void smi_start(void)
+{
+/*
+ * rtl8366 chip needs a extra clock with
+ * SDA high before start condition
+ */
+
+ /* set gpio pins output */
+ MII_SDAOUTPUT;
+ MII_SCKOUTPUT;
+ udelay(DELAY);
+
+ /* set initial state: SCK:0, SDA:1 */
+ MII_SETSCK(0);
+ MII_SETSDA(1);
+ udelay(DELAY);
+
+ /* toggle clock */
+ MII_SETSCK(1);
+ udelay(DELAY);
+ MII_SETSCK(0);
+ udelay(DELAY);
+
+ /* start condition */
+ MII_SETSCK(1);
+ udelay(DELAY);
+ MII_SETSDA(0);
+ udelay(DELAY);
+ MII_SETSCK(0);
+ udelay(DELAY);
+ MII_SETSDA(1);
+}
+
+static void smi_stop(void)
+{
+/*
+ * rtl8366 chip needs a extra clock with
+ * SDA high after stop condition
+ */
+
+ /* stop condition */
+ udelay(DELAY);
+ MII_SETSDA(0);
+ MII_SETSCK(1);
+ udelay(DELAY);
+ MII_SETSDA(1);
+ udelay(DELAY);
+ MII_SETSCK(1);
+ udelay(DELAY);
+ MII_SETSCK(0);
+ udelay(DELAY);
+
+ /* toggle clock */
+ MII_SETSCK(1);
+ udelay(DELAY);
+ MII_SETSCK(0);
+ udelay(DELAY);
+ MII_SETSCK(1);
+
+ /* set gpio pins input */
+ MII_SDAINPUT;
+ MII_SCKINPUT;
+}
+
+static void smi_writeBits(uint32_t data, uint8_t length)
+{
+ uint8_t test;
+
+ for( ; length > 0; length--) {
+ udelay(DELAY);
+
+ /* output data */
+ test = (((data & (1 << (length - 1))) != 0) ? 1 : 0);
+ MII_SETSDA(test);
+ udelay(DELAY);
+
+ /* toogle clock */
+ MII_SETSCK(1);
+ udelay(DELAY);
+ MII_SETSCK(0);
+ }
+}
+
+static uint32_t smi_readBits(uint8_t length)
+{
+ uint32_t ret;
+
+ MII_SDAINPUT;
+
+ for(ret = 0 ; length > 0; length--) {
+ udelay(DELAY);
+
+ ret <<= 1;
+
+ /* toogle clock */
+ MII_SETSCK(1);
+ udelay(DELAY);
+ ret |= MII_GETSDA;
+ MII_SETSCK(0);
+ }
+
+ MII_SDAOUTPUT;
+
+ return ret;
+}
+
+static int smi_waitAck(void)
+{
+ uint32_t retry = 0;
+
+ while (smi_readBits(1)) {
+ if (retry++ == 5)
+ return -1;
+ }
+
+ return 0;
+
+}
+
+static int smi_read(uint32_t reg, uint32_t *data)
+{
+ uint32_t rawData;
+
+ /* send start condition */
+ smi_start();
+ /* send CTRL1 code: 0b1010*/
+ smi_writeBits(0x0a, 4);
+ /* send CTRL2 code: 0b100 */
+ smi_writeBits(0x04, 3);
+ /* send READ command */
+ smi_writeBits(0x01, 1);
+
+ /* wait for ACK */
+ if (smi_waitAck())
+ return -1;
+
+ /* send address low */
+ smi_writeBits(reg & 0xFF, 8);
+ /* wait for ACK */
+ if (smi_waitAck())
+ return -1;
+ /* send address high */
+ smi_writeBits((reg & 0xFF00) >> 8, 8);
+ /* wait for ACK */
+ if (smi_waitAck())
+ return -1;
+
+ /* read data low */
+ rawData = (smi_readBits(8) & 0xFF);
+ /* send ACK */
+ smi_writeBits(0, 1);
+ /* read data high */
+ rawData |= (smi_readBits(8) & 0xFF) << 8;
+ /* send NACK */
+ smi_writeBits(1, 1);
+
+ /* send stop condition */
+ smi_stop();
+
+ if (data)
+ *data = rawData;
+
+ return 0;
+}
+
+static int smi_write(uint32_t reg, uint32_t data)
+{
+ /* send start condition */
+ smi_start();
+ /* send CTRL1 code: 0b1010*/
+ smi_writeBits(0x0a, 4);
+ /* send CTRL2 code: 0b100 */
+ smi_writeBits(0x04, 3);
+ /* send WRITE command */
+ smi_writeBits(0x00, 1);
+
+ /* wait for ACK */
+ if (smi_waitAck())
+ return -1;
+
+ /* send address low */
+ smi_writeBits(reg & 0xFF, 8);
+ /* wait for ACK */
+ if (smi_waitAck())
+ return -1;
+ /* send address high */
+ smi_writeBits((reg & 0xFF00) >> 8, 8);
+ /* wait for ACK */
+ if (smi_waitAck())
+ return -1;
+
+ /* send data low */
+ smi_writeBits(data & 0xFF, 8);
+ /* wait for ACK */
+ if (smi_waitAck())
+ return -1;
+ /* send data high */
+ smi_writeBits((data & 0xFF00) >> 8, 8);
+ /* wait for ACK */
+ if (smi_waitAck())
+ return -1;
+
+ /* send stop condition */
+ smi_stop();
+
+ return 0;
+}
+
+
+//-------------------------------------------------------------------
+// Switch register read / write functions
+//-------------------------------------------------------------------
+static int rtl8366_readRegister(uint32_t reg, uint16_t *data)
+{
+ uint32_t regData;
+
+ DBG("rtl8366: read register=%#04x, data=", reg);
+
+ if (smi_read(reg, &regData)) {
+ printf("\nrtl8366 smi read failed!\n");
+ return -1;
+ }
+
+ if (data)
+ *data = regData;
+
+ DBG("%#04x\n", regData);
+
+ return 0;
+}
+
+static int rtl8366_writeRegister(uint32_t reg, uint16_t data)
+{
+ DBG("rtl8366: write register=%#04x, data=%#04x\n", reg, data);
+
+ if (smi_write(reg, data)) {
+ printf("rtl8366 smi write failed!\n");
+ return -1;
+ }
+
+ return 0;
+}
+
+static int rtl8366_setRegisterBit(uint32_t reg, uint32_t bitNum, uint32_t value)
+{
+ uint16_t regData;
+
+ if (bitNum >= 16)
+ return -1;
+
+ if (rtl8366_readRegister(reg, &regData))
+ return -1;
+
+ if (value)
+ regData |= (1 << bitNum);
+ else
+ regData &= ~(1 << bitNum);
+
+ if (rtl8366_writeRegister(reg, regData))
+ return -1;
+
+ return 0;
+}
+
+//-------------------------------------------------------------------
+// MII PHY read / write functions
+//-------------------------------------------------------------------
+static int rtl8366_getPhyReg(uint32_t phyNum, uint32_t reg, uint16_t *data)
+{
+ uint16_t phyAddr, regData;
+
+ if (phyNum > RTL8366S_PHY_NO_MAX) {
+ printf("rtl8366s: invalid phy number!\n");
+ return -1;
+ }
+
+ if (phyNum > RTL8366S_PHY_ADDR_MAX) {
+ printf("rtl8366s: invalid phy register number!\n");
+ return -1;
+ }
+
+ if (rtl8366_writeRegister(RTL8366S_PHY_ACCESS_CTRL_REG,
+ RTL8366S_PHY_CTRL_READ))
+ return -1;
+
+ phyAddr = 0x8000 | (1 << (phyNum + RTL8366S_PHY_NO_OFFSET))
+ | (reg & RTL8366S_PHY_REG_MASK);
+ if (rtl8366_writeRegister(phyAddr, 0))
+ return -1;
+
+ if (rtl8366_readRegister(RTL8366S_PHY_ACCESS_DATA_REG, &regData))
+ return -1;
+
+ if (data)
+ *data = regData;
+
+ return 0;
+}
+
+static int rtl8366_setPhyReg(uint32_t phyNum, uint32_t reg, uint16_t data)
+{
+ uint16_t phyAddr;
+
+ if (phyNum > RTL8366S_PHY_NO_MAX) {
+ printf("rtl8366s: invalid phy number!\n");
+ return -1;
+ }
+
+ if (phyNum > RTL8366S_PHY_ADDR_MAX) {
+ printf("rtl8366s: invalid phy register number!\n");
+ return -1;
+ }
+
+ if (rtl8366_writeRegister(RTL8366S_PHY_ACCESS_CTRL_REG,
+ RTL8366S_PHY_CTRL_WRITE))
+ return -1;
+
+ phyAddr = 0x8000 | (1 << (phyNum + RTL8366S_PHY_NO_OFFSET))
+ | (reg & RTL8366S_PHY_REG_MASK);
+ if (rtl8366_writeRegister(phyAddr, data))
+ return -1;
+
+ return 0;
+}
+
+static int rtl8366_miiread(char *devname, uchar phy_adr, uchar reg, ushort *data)
+{
+ uint16_t regData;
+
+ DBG("rtl8366_miiread: devname=%s, addr=%#02x, reg=%#02x\n",
+ devname, phy_adr, reg);
+
+ if (strcmp(devname, RTL8366_DEVNAME) != 0)
+ return -1;
+
+ if (rtl8366_getPhyReg(phy_adr, reg, &regData)) {
+ printf("rtl8366_miiread: write failed!\n");
+ return -1;
+ }
+
+ if (data)
+ *data = regData;
+
+ return 0;
+}
+
+static int rtl8366_miiwrite(char *devname, uchar phy_adr, uchar reg, ushort data)
+{
+ DBG("rtl8366_miiwrite: devname=%s, addr=%#02x, reg=%#02x, data=%#04x\n",
+ devname, phy_adr, reg, data);
+
+ if (strcmp(devname, RTL8366_DEVNAME) != 0)
+ return -1;
+
+ if (rtl8366_setPhyReg(phy_adr, reg, data)) {
+ printf("rtl8366_miiwrite: write failed!\n");
+ return -1;
+ }
+
+ return 0;
+}
+
+int rtl8366_mii_register(bd_t *bis)
+{
+ miiphy_register(strdup(RTL8366_DEVNAME), rtl8366_miiread,
+ rtl8366_miiwrite);
+
+ return 0;
+}
+
+
+//-------------------------------------------------------------------
+// Switch management functions
+//-------------------------------------------------------------------
+
+int rtl8366s_setGreenFeature(uint32_t tx, uint32_t rx)
+{
+ if (rtl8366_setRegisterBit(RTL8366S_GREEN_FEATURE_REG,
+ RTL8366S_GREEN_FEATURE_TX_BIT, tx))
+ return -1;
+
+ if (rtl8366_setRegisterBit(RTL8366S_GREEN_FEATURE_REG,
+ RTL8366S_GREEN_FEATURE_RX_BIT, rx))
+ return -1;
+
+ return 0;
+}
+
+int rtl8366s_setPowerSaving(uint32_t phyNum, uint32_t enabled)
+{
+ uint16_t regData;
+
+ if (phyNum > RTL8366S_PHY_NO_MAX)
+ return -1;
+
+ if (rtl8366_getPhyReg(phyNum, 12, &regData))
+ return -1;
+
+ if (enabled)
+ regData |= (1 << 12);
+ else
+ regData &= ~(1 << 12);
+
+ if (rtl8366_setPhyReg(phyNum, 12, regData))
+ return -1;
+
+ return 0;
+}
+
+int rtl8366s_setGreenEthernet(uint32_t greenFeature, uint32_t powerSaving)
+{
+ uint32_t phyNum, i;
+ uint16_t regData;
+
+ const uint16_t greenSettings[][2] =
+ {
+ {0xBE5B,0x3500},
+ {0xBE5C,0xB975},
+ {0xBE5D,0xB9B9},
+ {0xBE77,0xA500},
+ {0xBE78,0x5A78},
+ {0xBE79,0x6478}
+ };
+
+ if (rtl8366_readRegister(RTL8366S_MODEL_ID_REG, &regData))
+ return -1;
+
+ switch (regData)
+ {
+ case 0x0000:
+ for (i = 0; i < 6; i++) {
+ if (rtl8366_writeRegister(RTL8366S_PHY_ACCESS_CTRL_REG, RTL8366S_PHY_CTRL_WRITE))
+ return -1;
+ if (rtl8366_writeRegister(greenSettings[i][0], greenSettings[i][1]))
+ return -1;
+ }
+ break;
+
+ case RTL8366S_MODEL_8366SR:
+ if (rtl8366_writeRegister(RTL8366S_PHY_ACCESS_CTRL_REG, RTL8366S_PHY_CTRL_WRITE))
+ return -1;
+ if (rtl8366_writeRegister(greenSettings[0][0], greenSettings[0][1]))
+ return -1;
+ break;
+
+ default:
+ printf("rtl8366s_initChip: unsupported chip found!\n");
+ return -1;
+ }
+
+ if (rtl8366s_setGreenFeature(greenFeature, powerSaving))
+ return -1;
+
+ for (phyNum = 0; phyNum <= RTL8366S_PHY_NO_MAX; phyNum++) {
+ if (rtl8366s_setPowerSaving(phyNum, powerSaving))
+ return -1;
+ }
+
+ return 0;
+}
+
+int rtl8366s_setCPUPortMask(uint8_t port, uint32_t enabled)
+{
+ if(port >= 6){
+ printf("rtl8366s_setCPUPortMask: invalid port number\n");
+ return -1;
+ }
+
+ return rtl8366_setRegisterBit(RTL8366S_CPU_CTRL_REG, port, enabled);
+}
+
+int rtl8366s_setCPUDisableInsTag(uint32_t enable)
+{
+ return rtl8366_setRegisterBit(RTL8366S_CPU_CTRL_REG,
+ RTL8366S_CPU_INSTAG_BIT, enable);
+}
+
+int rtl8366s_setCPUDropUnda(uint32_t enable)
+{
+ return rtl8366_setRegisterBit(RTL8366S_CPU_CTRL_REG,
+ RTL8366S_CPU_DRP_BIT, enable);
+}
+
+int rtl8366s_setCPUPort(uint8_t port, uint32_t noTag, uint32_t dropUnda)
+{
+ uint32_t i;
+
+ if(port >= 6){
+ printf("rtl8366s_setCPUPort: invalid port number\n");
+ return -1;
+ }
+
+ /* reset register */
+ for(i = 0; i < 6; i++)
+ {
+ if(rtl8366s_setCPUPortMask(i, 0)){
+ printf("rtl8366s_setCPUPort: rtl8366s_setCPUPortMask failed\n");
+ return -1;
+ }
+ }
+
+ if(rtl8366s_setCPUPortMask(port, 1)){
+ printf("rtl8366s_setCPUPort: rtl8366s_setCPUPortMask failed\n");
+ return -1;
+ }
+
+ if(rtl8366s_setCPUDisableInsTag(noTag)){
+ printf("rtl8366s_setCPUPort: rtl8366s_setCPUDisableInsTag fail\n");
+ return -1;
+ }
+
+ if(rtl8366s_setCPUDropUnda(dropUnda)){
+ printf("rtl8366s_setCPUPort: rtl8366s_setCPUDropUnda fail\n");
+ return -1;
+ }
+
+ return 0;
+}
+
+int rtl8366s_setLedConfig(uint32_t ledNum, uint8_t config)
+{
+ uint16_t regData;
+
+ if(ledNum >= RTL8366S_LED_GROUP_MAX) {
+ DBG("rtl8366s_setLedConfig: invalid led group\n");
+ return -1;
+ }
+
+ if(config > RTL8366S_LEDCONF_LEDFORCE) {
+ DBG("rtl8366s_setLedConfig: invalid led config\n");
+ return -1;
+ }
+
+ if (rtl8366_readRegister(RTL8366S_LED_INDICATED_CONF_REG, &regData)) {
+ printf("rtl8366s_setLedConfig: failed to get led register!\n");
+ return -1;
+ }
+
+ regData &= ~(0xF << (ledNum * 4));
+ regData |= config << (ledNum * 4);
+
+ if (rtl8366_writeRegister(RTL8366S_LED_INDICATED_CONF_REG, regData)) {
+ printf("rtl8366s_setLedConfig: failed to set led register!\n");
+ return -1;
+ }
+
+ return 0;
+}
+
+int rtl8366s_getLedConfig(uint32_t ledNum, uint8_t *config)
+{
+ uint16_t regData;
+
+ if(ledNum >= RTL8366S_LED_GROUP_MAX) {
+ DBG("rtl8366s_getLedConfig: invalid led group\n");
+ return -1;
+ }
+
+ if (rtl8366_readRegister(RTL8366S_LED_INDICATED_CONF_REG, &regData)) {
+ printf("rtl8366s_getLedConfig: failed to get led register!\n");
+ return -1;
+ }
+
+ if (config)
+ *config = (regData >> (ledNum * 4)) & 0xF;
+
+ return 0;
+}
+
+int rtl8366s_setLedForceValue(uint32_t group0, uint32_t group1,
+ uint32_t group2, uint32_t group3)
+{
+ uint16_t regData;
+
+ regData = (group0 & 0x3F) | ((group1 & 0x3F) << 6);
+ if (rtl8366_writeRegister(RTL8366S_LED_0_1_FORCE_REG, regData)) {
+ printf("rtl8366s_setLedForceValue: failed to set led register!\n");
+ return -1;
+ }
+
+ regData = (group2 & 0x3F) | ((group3 & 0x3F) << 6);
+ if (rtl8366_writeRegister(RTL8366S_LED_2_3_FORCE_REG, regData)) {
+ printf("rtl8366s_setLedForceValue: failed to set led register!\n");
+ return -1;
+ }
+
+ return 0;
+}
+
+int rtl8366s_initChip(void)
+{
+ uint32_t ledGroup, i = 0;
+ uint16_t regData;
+ uint8_t ledData[RTL8366S_LED_GROUP_MAX];
+ const uint16_t (*chipData)[2];
+
+ const uint16_t chipB[][2] =
+ {
+ {0x0000, 0x0038},{0x8100, 0x1B37},{0xBE2E, 0x7B9F},{0xBE2B, 0xA4C8},
+ {0xBE74, 0xAD14},{0xBE2C, 0xDC00},{0xBE69, 0xD20F},{0xBE3B, 0xB414},
+ {0xBE24, 0x0000},{0xBE23, 0x00A1},{0xBE22, 0x0008},{0xBE21, 0x0120},
+ {0xBE20, 0x1000},{0xBE24, 0x0800},{0xBE24, 0x0000},{0xBE24, 0xF000},
+ {0xBE23, 0xDF01},{0xBE22, 0xDF20},{0xBE21, 0x101A},{0xBE20, 0xA0FF},
+ {0xBE24, 0xF800},{0xBE24, 0xF000},{0x0242, 0x02BF},{0x0245, 0x02BF},
+ {0x0248, 0x02BF},{0x024B, 0x02BF},{0x024E, 0x02BF},{0x0251, 0x02BF},
+ {0x0230, 0x0A32},{0x0233, 0x0A32},{0x0236, 0x0A32},{0x0239, 0x0A32},
+ {0x023C, 0x0A32},{0x023F, 0x0A32},{0x0254, 0x0A3F},{0x0255, 0x0064},
+ {0x0256, 0x0A3F},{0x0257, 0x0064},{0x0258, 0x0A3F},{0x0259, 0x0064},
+ {0x025A, 0x0A3F},{0x025B, 0x0064},{0x025C, 0x0A3F},{0x025D, 0x0064},
+ {0x025E, 0x0A3F},{0x025F, 0x0064},{0x0260, 0x0178},{0x0261, 0x01F4},
+ {0x0262, 0x0320},{0x0263, 0x0014},{0x021D, 0x9249},{0x021E, 0x0000},
+ {0x0100, 0x0004},{0xBE4A, 0xA0B4},{0xBE40, 0x9C00},{0xBE41, 0x501D},
+ {0xBE48, 0x3602},{0xBE47, 0x8051},{0xBE4C, 0x6465},{0x8000, 0x1F00},
+ {0x8001, 0x000C},{0x8008, 0x0000},{0x8007, 0x0000},{0x800C, 0x00A5},
+ {0x8101, 0x02BC},{0xBE53, 0x0005},{0x8E45, 0xAFE8},{0x8013, 0x0005},
+ {0xBE4B, 0x6700},{0x800B, 0x7000},{0xBE09, 0x0E00},
+ {0xFFFF, 0xABCD}
+ };
+
+ const uint16_t chipDefault[][2] =
+ {
+ {0x0242, 0x02BF},{0x0245, 0x02BF},{0x0248, 0x02BF},{0x024B, 0x02BF},
+ {0x024E, 0x02BF},{0x0251, 0x02BF},
+ {0x0254, 0x0A3F},{0x0256, 0x0A3F},{0x0258, 0x0A3F},{0x025A, 0x0A3F},
+ {0x025C, 0x0A3F},{0x025E, 0x0A3F},
+ {0x0263, 0x007C},{0x0100, 0x0004},
+ {0xBE5B, 0x3500},{0x800E, 0x200F},{0xBE1D, 0x0F00},{0x8001, 0x5011},
+ {0x800A, 0xA2F4},{0x800B, 0x17A3},{0xBE4B, 0x17A3},{0xBE41, 0x5011},
+ {0xBE17, 0x2100},{0x8000, 0x8304},{0xBE40, 0x8304},{0xBE4A, 0xA2F4},
+ {0x800C, 0xA8D5},{0x8014, 0x5500},{0x8015, 0x0004},{0xBE4C, 0xA8D5},
+ {0xBE59, 0x0008},{0xBE09, 0x0E00},{0xBE36, 0x1036},{0xBE37, 0x1036},
+ {0x800D, 0x00FF},{0xBE4D, 0x00FF},
+ {0xFFFF, 0xABCD}
+ };
+
+ DBG("rtl8366s_initChip\n");
+
+ /* save current led config and set to led force */
+ for (ledGroup = 0; ledGroup < RTL8366S_LED_GROUP_MAX; ledGroup++) {
+ if (rtl8366s_getLedConfig(ledGroup, &ledData[ledGroup]))
+ return -1;
+
+ if (rtl8366s_setLedConfig(ledGroup, RTL8366S_LEDCONF_LEDFORCE))
+ return -1;
+ }
+
+ if (rtl8366s_setLedForceValue(0,0,0,0))
+ return -1;
+
+ if (rtl8366_readRegister(RTL8366S_MODEL_ID_REG, &regData))
+ return -1;
+
+ switch (regData)
+ {
+ case 0x0000:
+ chipData = chipB;
+ break;
+
+ case RTL8366S_MODEL_8366SR:
+ chipData = chipDefault;
+ break;
+
+ default:
+ printf("rtl8366s_initChip: unsupported chip found!\n");
+ return -1;
+ }
+
+ DBG("rtl8366s_initChip: found %x chip\n", regData);
+
+ while ((chipData[i][0] != 0xFFFF) && (chipData[i][1] != 0xABCD)) {
+
+ /* phy settings*/
+ if ((chipData[i][0] & 0xBE00) == 0xBE00) {
+ if (rtl8366_writeRegister(RTL8366S_PHY_ACCESS_CTRL_REG,
+ RTL8366S_PHY_CTRL_WRITE))
+ return -1;
+ }
+
+ if (rtl8366_writeRegister(chipData[i][0], chipData[i][1]))
+ return -1;
+
+ i++;
+ }
+
+ /* chip needs some time */
+ udelay(100 * 1000);
+
+ /* restore led config */
+ for (ledGroup = 0; ledGroup < RTL8366S_LED_GROUP_MAX; ledGroup++) {
+ if (rtl8366s_setLedConfig(ledGroup, ledData[ledGroup]))
+ return -1;
+ }
+
+ return 0;
+}
+
+int rtl8366s_initialize(void)
+{
+ uint16_t regData;
+
+ DBG("rtl8366s_initialize: start setup\n");
+
+ smi_init();
+
+ rtl8366_readRegister(RTL8366S_CHIP_ID_REG, &regData);
+ DBG("Realtek 8366SR switch ID %#04x\n", regData);
+
+ if (regData != 0x8366) {
+ printf("rtl8366s_initialize: found unsupported switch\n");
+ return -1;
+ }
+
+ if (rtl8366s_initChip()) {
+ printf("rtl8366s_initialize: init chip failed\n");
+ return -1;
+ }
+
+ if (rtl8366s_setGreenEthernet(1, 1)) {
+ printf("rtl8366s_initialize: set green ethernet failed\n");
+ return -1;
+ }
+
+ /* Set port 5 noTag and don't dropUnda */
+ if (rtl8366s_setCPUPort(5, 1, 0)) {
+ printf("rtl8366s_initialize: set CPU port failed\n");
+ return -1;
+ }
+
+ return 0;
+}
diff --git a/package/boot/uboot-ar71xx/files/drivers/spi/.svn/entries b/package/boot/uboot-ar71xx/files/drivers/spi/.svn/entries
new file mode 100644
index 0000000..cce4027
--- /dev/null
+++ b/package/boot/uboot-ar71xx/files/drivers/spi/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/uboot-ar71xx/files/drivers/spi
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+ar71xx_spi.c
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+05e08eafb6374d1bcb71b0086f1da38f
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4553
+
diff --git a/package/boot/uboot-ar71xx/files/drivers/spi/.svn/prop-base/ar71xx_spi.c.svn-base b/package/boot/uboot-ar71xx/files/drivers/spi/.svn/prop-base/ar71xx_spi.c.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/boot/uboot-ar71xx/files/drivers/spi/.svn/prop-base/ar71xx_spi.c.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/boot/uboot-ar71xx/files/drivers/spi/.svn/text-base/ar71xx_spi.c.svn-base b/package/boot/uboot-ar71xx/files/drivers/spi/.svn/text-base/ar71xx_spi.c.svn-base
new file mode 100644
index 0000000..bbe27b1
--- /dev/null
+++ b/package/boot/uboot-ar71xx/files/drivers/spi/.svn/text-base/ar71xx_spi.c.svn-base
@@ -0,0 +1,191 @@
+/*
+ * (C) Copyright 2010
+ * Michael Kurz <michi.kurz@googlemail.com>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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 of
+ * the License, 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <malloc.h>
+#include <spi.h>
+
+#include <asm/addrspace.h>
+#include <asm/types.h>
+#include <asm/ar71xx.h>
+
+/*-----------------------------------------------------------------------
+ * Definitions
+ */
+
+#ifdef DEBUG_SPI
+#define PRINTD(fmt,args...) printf (fmt ,##args)
+#else
+#define PRINTD(fmt,args...)
+#endif
+
+struct ar71xx_spi_slave {
+ struct spi_slave slave;
+ unsigned int mode;
+};
+
+static inline struct ar71xx_spi_slave *to_ar71xx_spi(struct spi_slave *slave)
+{
+ return container_of(slave, struct ar71xx_spi_slave, slave);
+}
+
+/*=====================================================================*/
+/* Public Functions */
+/*=====================================================================*/
+
+/*-----------------------------------------------------------------------
+ * Initialization
+ */
+
+void spi_init()
+{
+ PRINTD("ar71xx_spi: spi_init");
+
+ // Init SPI Hardware, disable remap, set clock
+ __raw_writel(0x43, KSEG1ADDR(AR71XX_SPI_BASE + SPI_REG_CTRL));
+
+ PRINTD(" ---> out\n");
+}
+
+struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
+ unsigned int max_hz, unsigned int mode)
+{
+ struct ar71xx_spi_slave *ss;
+
+ PRINTD("ar71xx_spi: spi_setup_slave");
+
+ if ((bus != 0) || (cs > 2))
+ return NULL;
+
+ ss = malloc(sizeof(struct ar71xx_spi_slave));
+ if (!ss)
+ return NULL;
+
+ ss->slave.bus = bus;
+ ss->slave.cs = cs;
+ ss->mode = mode;
+
+ /* TODO: Use max_hz to limit the SCK rate */
+
+ PRINTD(" ---> out\n");
+
+ return &ss->slave;
+}
+
+void spi_free_slave(struct spi_slave *slave)
+{
+ struct ar71xx_spi_slave *ss = to_ar71xx_spi(slave);
+
+ free(ss);
+}
+
+int spi_claim_bus(struct spi_slave *slave)
+{
+
+ return 0;
+}
+
+void spi_release_bus(struct spi_slave *slave)
+{
+
+}
+
+int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
+ void *din, unsigned long flags)
+{
+ struct ar71xx_spi_slave *ss = to_ar71xx_spi(slave);
+ uint8_t *rx = din;
+ const uint8_t *tx = dout;
+ uint8_t curbyte, curbitlen, restbits;
+ uint32_t bytes = bitlen / 8;
+ uint32_t out;
+ uint32_t in;
+
+ PRINTD("ar71xx_spi: spi_xfer: slave:%p bitlen:%08x dout:%p din:%p flags:%08x\n", slave, bitlen, dout, din, flags);
+
+ if (flags & SPI_XFER_BEGIN) {
+ __raw_writel(SPI_FS_GPIO, KSEG1ADDR(AR71XX_SPI_BASE + SPI_REG_FS));
+ __raw_writel(SPI_IOC_CS_ALL, KSEG1ADDR(AR71XX_SPI_BASE + SPI_REG_IOC));
+ }
+
+ restbits = (bitlen % 8);
+ if (restbits != 0)
+ bytes++;
+
+ // enable chip select
+ out = SPI_IOC_CS_ALL & ~(SPI_IOC_CS(slave->cs));
+
+ while (bytes--) {
+
+ curbyte = 0;
+ if (tx) {
+ curbyte = *tx++;
+ }
+
+ if (restbits != 0) {
+ curbitlen = restbits;
+ curbyte <<= 8 - restbits;
+ } else {
+ curbitlen = 8;
+ }
+
+ PRINTD("ar71xx_spi: sending: data:%02x length:%d\n", curbyte, curbitlen);
+
+ /* clock starts at inactive polarity */
+ for (curbyte <<= (8 - curbitlen); curbitlen; curbitlen--) {
+
+ if (curbyte & (1 << 7))
+ out |= SPI_IOC_DO;
+ else
+ out &= ~(SPI_IOC_DO);
+
+ /* setup MSB (to slave) on trailing edge */
+ __raw_writel(out, KSEG1ADDR(AR71XX_SPI_BASE + SPI_REG_IOC));
+
+ __raw_writel(out | SPI_IOC_CLK, KSEG1ADDR(AR71XX_SPI_BASE + SPI_REG_IOC));
+
+ curbyte <<= 1;
+ }
+
+ in = __raw_readl(KSEG1ADDR(AR71XX_SPI_BASE + SPI_REG_RDS));
+ PRINTD("ar71xx_spi: received:%02x\n", in);
+
+ if (rx) {
+ if (restbits == 0) {
+ *rx++ = in;
+ } else {
+ *rx++ = (in << (8 - restbits));
+ }
+ }
+ }
+
+ if (flags & SPI_XFER_END) {
+ __raw_writel(SPI_IOC_CS(slave->cs), KSEG1ADDR(AR71XX_SPI_BASE + SPI_REG_IOC));
+ __raw_writel(SPI_IOC_CS_ALL, KSEG1ADDR(AR71XX_SPI_BASE + SPI_REG_IOC));
+ __raw_writel(0, KSEG1ADDR(AR71XX_SPI_BASE + SPI_REG_FS));
+ }
+
+ PRINTD(" ---> out\n");
+
+ return 0;
+}
diff --git a/package/boot/uboot-ar71xx/files/drivers/spi/ar71xx_spi.c b/package/boot/uboot-ar71xx/files/drivers/spi/ar71xx_spi.c
new file mode 100644
index 0000000..bbe27b1
--- /dev/null
+++ b/package/boot/uboot-ar71xx/files/drivers/spi/ar71xx_spi.c
@@ -0,0 +1,191 @@
+/*
+ * (C) Copyright 2010
+ * Michael Kurz <michi.kurz@googlemail.com>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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 of
+ * the License, 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <malloc.h>
+#include <spi.h>
+
+#include <asm/addrspace.h>
+#include <asm/types.h>
+#include <asm/ar71xx.h>
+
+/*-----------------------------------------------------------------------
+ * Definitions
+ */
+
+#ifdef DEBUG_SPI
+#define PRINTD(fmt,args...) printf (fmt ,##args)
+#else
+#define PRINTD(fmt,args...)
+#endif
+
+struct ar71xx_spi_slave {
+ struct spi_slave slave;
+ unsigned int mode;
+};
+
+static inline struct ar71xx_spi_slave *to_ar71xx_spi(struct spi_slave *slave)
+{
+ return container_of(slave, struct ar71xx_spi_slave, slave);
+}
+
+/*=====================================================================*/
+/* Public Functions */
+/*=====================================================================*/
+
+/*-----------------------------------------------------------------------
+ * Initialization
+ */
+
+void spi_init()
+{
+ PRINTD("ar71xx_spi: spi_init");
+
+ // Init SPI Hardware, disable remap, set clock
+ __raw_writel(0x43, KSEG1ADDR(AR71XX_SPI_BASE + SPI_REG_CTRL));
+
+ PRINTD(" ---> out\n");
+}
+
+struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
+ unsigned int max_hz, unsigned int mode)
+{
+ struct ar71xx_spi_slave *ss;
+
+ PRINTD("ar71xx_spi: spi_setup_slave");
+
+ if ((bus != 0) || (cs > 2))
+ return NULL;
+
+ ss = malloc(sizeof(struct ar71xx_spi_slave));
+ if (!ss)
+ return NULL;
+
+ ss->slave.bus = bus;
+ ss->slave.cs = cs;
+ ss->mode = mode;
+
+ /* TODO: Use max_hz to limit the SCK rate */
+
+ PRINTD(" ---> out\n");
+
+ return &ss->slave;
+}
+
+void spi_free_slave(struct spi_slave *slave)
+{
+ struct ar71xx_spi_slave *ss = to_ar71xx_spi(slave);
+
+ free(ss);
+}
+
+int spi_claim_bus(struct spi_slave *slave)
+{
+
+ return 0;
+}
+
+void spi_release_bus(struct spi_slave *slave)
+{
+
+}
+
+int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
+ void *din, unsigned long flags)
+{
+ struct ar71xx_spi_slave *ss = to_ar71xx_spi(slave);
+ uint8_t *rx = din;
+ const uint8_t *tx = dout;
+ uint8_t curbyte, curbitlen, restbits;
+ uint32_t bytes = bitlen / 8;
+ uint32_t out;
+ uint32_t in;
+
+ PRINTD("ar71xx_spi: spi_xfer: slave:%p bitlen:%08x dout:%p din:%p flags:%08x\n", slave, bitlen, dout, din, flags);
+
+ if (flags & SPI_XFER_BEGIN) {
+ __raw_writel(SPI_FS_GPIO, KSEG1ADDR(AR71XX_SPI_BASE + SPI_REG_FS));
+ __raw_writel(SPI_IOC_CS_ALL, KSEG1ADDR(AR71XX_SPI_BASE + SPI_REG_IOC));
+ }
+
+ restbits = (bitlen % 8);
+ if (restbits != 0)
+ bytes++;
+
+ // enable chip select
+ out = SPI_IOC_CS_ALL & ~(SPI_IOC_CS(slave->cs));
+
+ while (bytes--) {
+
+ curbyte = 0;
+ if (tx) {
+ curbyte = *tx++;
+ }
+
+ if (restbits != 0) {
+ curbitlen = restbits;
+ curbyte <<= 8 - restbits;
+ } else {
+ curbitlen = 8;
+ }
+
+ PRINTD("ar71xx_spi: sending: data:%02x length:%d\n", curbyte, curbitlen);
+
+ /* clock starts at inactive polarity */
+ for (curbyte <<= (8 - curbitlen); curbitlen; curbitlen--) {
+
+ if (curbyte & (1 << 7))
+ out |= SPI_IOC_DO;
+ else
+ out &= ~(SPI_IOC_DO);
+
+ /* setup MSB (to slave) on trailing edge */
+ __raw_writel(out, KSEG1ADDR(AR71XX_SPI_BASE + SPI_REG_IOC));
+
+ __raw_writel(out | SPI_IOC_CLK, KSEG1ADDR(AR71XX_SPI_BASE + SPI_REG_IOC));
+
+ curbyte <<= 1;
+ }
+
+ in = __raw_readl(KSEG1ADDR(AR71XX_SPI_BASE + SPI_REG_RDS));
+ PRINTD("ar71xx_spi: received:%02x\n", in);
+
+ if (rx) {
+ if (restbits == 0) {
+ *rx++ = in;
+ } else {
+ *rx++ = (in << (8 - restbits));
+ }
+ }
+ }
+
+ if (flags & SPI_XFER_END) {
+ __raw_writel(SPI_IOC_CS(slave->cs), KSEG1ADDR(AR71XX_SPI_BASE + SPI_REG_IOC));
+ __raw_writel(SPI_IOC_CS_ALL, KSEG1ADDR(AR71XX_SPI_BASE + SPI_REG_IOC));
+ __raw_writel(0, KSEG1ADDR(AR71XX_SPI_BASE + SPI_REG_FS));
+ }
+
+ PRINTD(" ---> out\n");
+
+ return 0;
+}
diff --git a/package/boot/uboot-ar71xx/files/include/.svn/entries b/package/boot/uboot-ar71xx/files/include/.svn/entries
new file mode 100644
index 0000000..cbf4917
--- /dev/null
+++ b/package/boot/uboot-ar71xx/files/include/.svn/entries
@@ -0,0 +1,34 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/uboot-ar71xx/files/include
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+asm-mips
+dir
+
+configs
+dir
+
diff --git a/package/boot/uboot-ar71xx/files/include/asm-mips/.svn/entries b/package/boot/uboot-ar71xx/files/include/asm-mips/.svn/entries
new file mode 100644
index 0000000..809e843
--- /dev/null
+++ b/package/boot/uboot-ar71xx/files/include/asm-mips/.svn/entries
@@ -0,0 +1,96 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/uboot-ar71xx/files/include/asm-mips
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+ar71xx.h
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+e270582146693e6df5a2d8040e54fb39
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+15446
+
+ar71xx_gpio.h
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+7cdaa64219ae76e79afff6ad44338dc2
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1842
+
diff --git a/package/boot/uboot-ar71xx/files/include/asm-mips/.svn/prop-base/ar71xx.h.svn-base b/package/boot/uboot-ar71xx/files/include/asm-mips/.svn/prop-base/ar71xx.h.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/boot/uboot-ar71xx/files/include/asm-mips/.svn/prop-base/ar71xx.h.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/boot/uboot-ar71xx/files/include/asm-mips/.svn/prop-base/ar71xx_gpio.h.svn-base b/package/boot/uboot-ar71xx/files/include/asm-mips/.svn/prop-base/ar71xx_gpio.h.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/boot/uboot-ar71xx/files/include/asm-mips/.svn/prop-base/ar71xx_gpio.h.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/boot/uboot-ar71xx/files/include/asm-mips/.svn/text-base/ar71xx.h.svn-base b/package/boot/uboot-ar71xx/files/include/asm-mips/.svn/text-base/ar71xx.h.svn-base
new file mode 100644
index 0000000..e8f3f61
--- /dev/null
+++ b/package/boot/uboot-ar71xx/files/include/asm-mips/.svn/text-base/ar71xx.h.svn-base
@@ -0,0 +1,515 @@
+/*
+ * Atheros AR71xx SoC specific definitions
+ *
+ * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
+ * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
+ *
+ * Parts of this file are based on Atheros' 2.6.15 BSP
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ */
+
+#ifndef __ASM_MACH_AR71XX_H
+#define __ASM_MACH_AR71XX_H
+
+#include <linux/types.h>
+#include <asm/io.h>
+#include <linux/bitops.h>
+
+#ifndef __ASSEMBLER__
+
+#define BIT(x) (1<<(x))
+
+#define AR71XX_PCI_MEM_BASE 0x10000000
+#define AR71XX_PCI_MEM_SIZE 0x08000000
+#define AR71XX_APB_BASE 0x18000000
+#define AR71XX_GE0_BASE 0x19000000
+#define AR71XX_GE0_SIZE 0x01000000
+#define AR71XX_GE1_BASE 0x1a000000
+#define AR71XX_GE1_SIZE 0x01000000
+#define AR71XX_EHCI_BASE 0x1b000000
+#define AR71XX_EHCI_SIZE 0x01000000
+#define AR71XX_OHCI_BASE 0x1c000000
+#define AR71XX_OHCI_SIZE 0x01000000
+#define AR7240_OHCI_BASE 0x1b000000
+#define AR7240_OHCI_SIZE 0x01000000
+#define AR71XX_SPI_BASE 0x1f000000
+#define AR71XX_SPI_SIZE 0x01000000
+
+#define AR71XX_DDR_CTRL_BASE (AR71XX_APB_BASE + 0x00000000)
+#define AR71XX_DDR_CTRL_SIZE 0x10000
+#define AR71XX_CPU_BASE (AR71XX_APB_BASE + 0x00010000)
+#define AR71XX_UART_BASE (AR71XX_APB_BASE + 0x00020000)
+#define AR71XX_UART_SIZE 0x10000
+#define AR71XX_USB_CTRL_BASE (AR71XX_APB_BASE + 0x00030000)
+#define AR71XX_USB_CTRL_SIZE 0x10000
+#define AR71XX_GPIO_BASE (AR71XX_APB_BASE + 0x00040000)
+#define AR71XX_GPIO_SIZE 0x10000
+#define AR71XX_PLL_BASE (AR71XX_APB_BASE + 0x00050000)
+#define AR71XX_PLL_SIZE 0x10000
+#define AR71XX_RESET_BASE (AR71XX_APB_BASE + 0x00060000)
+#define AR71XX_RESET_SIZE 0x10000
+#define AR71XX_MII_BASE (AR71XX_APB_BASE + 0x00070000)
+#define AR71XX_MII_SIZE 0x10000
+#define AR71XX_SLIC_BASE (AR71XX_APB_BASE + 0x00090000)
+#define AR71XX_SLIC_SIZE 0x10000
+#define AR71XX_DMA_BASE (AR71XX_APB_BASE + 0x000A0000)
+#define AR71XX_DMA_SIZE 0x10000
+#define AR71XX_STEREO_BASE (AR71XX_APB_BASE + 0x000B0000)
+#define AR71XX_STEREO_SIZE 0x10000
+
+#define AR724X_PCI_CRP_BASE (AR71XX_APB_BASE + 0x000C0000)
+#define AR724X_PCI_CRP_SIZE 0x100
+
+#define AR724X_PCI_CTRL_BASE (AR71XX_APB_BASE + 0x000F0000)
+#define AR724X_PCI_CTRL_SIZE 0x100
+
+#define AR91XX_WMAC_BASE (AR71XX_APB_BASE + 0x000C0000)
+#define AR91XX_WMAC_SIZE 0x30000
+
+#define AR71XX_MEM_SIZE_MIN 0x0200000
+#define AR71XX_MEM_SIZE_MAX 0x10000000
+
+#define AR71XX_CPU_IRQ_BASE 0
+#define AR71XX_MISC_IRQ_BASE 8
+#define AR71XX_MISC_IRQ_COUNT 8
+#define AR71XX_GPIO_IRQ_BASE 16
+#define AR71XX_GPIO_IRQ_COUNT 32
+#define AR71XX_PCI_IRQ_BASE 48
+#define AR71XX_PCI_IRQ_COUNT 8
+
+#define AR71XX_CPU_IRQ_IP2 (AR71XX_CPU_IRQ_BASE + 2)
+#define AR71XX_CPU_IRQ_USB (AR71XX_CPU_IRQ_BASE + 3)
+#define AR71XX_CPU_IRQ_GE0 (AR71XX_CPU_IRQ_BASE + 4)
+#define AR71XX_CPU_IRQ_GE1 (AR71XX_CPU_IRQ_BASE + 5)
+#define AR71XX_CPU_IRQ_MISC (AR71XX_CPU_IRQ_BASE + 6)
+#define AR71XX_CPU_IRQ_TIMER (AR71XX_CPU_IRQ_BASE + 7)
+
+#define AR71XX_MISC_IRQ_TIMER (AR71XX_MISC_IRQ_BASE + 0)
+#define AR71XX_MISC_IRQ_ERROR (AR71XX_MISC_IRQ_BASE + 1)
+#define AR71XX_MISC_IRQ_GPIO (AR71XX_MISC_IRQ_BASE + 2)
+#define AR71XX_MISC_IRQ_UART (AR71XX_MISC_IRQ_BASE + 3)
+#define AR71XX_MISC_IRQ_WDOG (AR71XX_MISC_IRQ_BASE + 4)
+#define AR71XX_MISC_IRQ_PERFC (AR71XX_MISC_IRQ_BASE + 5)
+#define AR71XX_MISC_IRQ_OHCI (AR71XX_MISC_IRQ_BASE + 6)
+#define AR71XX_MISC_IRQ_DMA (AR71XX_MISC_IRQ_BASE + 7)
+
+#define AR71XX_GPIO_IRQ(_x) (AR71XX_GPIO_IRQ_BASE + (_x))
+
+#define AR71XX_PCI_IRQ_DEV0 (AR71XX_PCI_IRQ_BASE + 0)
+#define AR71XX_PCI_IRQ_DEV1 (AR71XX_PCI_IRQ_BASE + 1)
+#define AR71XX_PCI_IRQ_DEV2 (AR71XX_PCI_IRQ_BASE + 2)
+#define AR71XX_PCI_IRQ_CORE (AR71XX_PCI_IRQ_BASE + 4)
+
+extern u32 ar71xx_ahb_freq;
+extern u32 ar71xx_cpu_freq;
+extern u32 ar71xx_ddr_freq;
+
+enum ar71xx_soc_type {
+ AR71XX_SOC_UNKNOWN,
+ AR71XX_SOC_AR7130,
+ AR71XX_SOC_AR7141,
+ AR71XX_SOC_AR7161,
+ AR71XX_SOC_AR7240,
+ AR71XX_SOC_AR7241,
+ AR71XX_SOC_AR7242,
+ AR71XX_SOC_AR9130,
+ AR71XX_SOC_AR9132
+};
+
+extern enum ar71xx_soc_type ar71xx_soc;
+
+/*
+ * PLL block
+ */
+#define AR71XX_PLL_REG_CPU_CONFIG 0x00
+#define AR71XX_PLL_REG_SEC_CONFIG 0x04
+#define AR71XX_PLL_REG_ETH0_INT_CLOCK 0x10
+#define AR71XX_PLL_REG_ETH1_INT_CLOCK 0x14
+
+#define AR71XX_PLL_DIV_SHIFT 3
+#define AR71XX_PLL_DIV_MASK 0x1f
+#define AR71XX_CPU_DIV_SHIFT 16
+#define AR71XX_CPU_DIV_MASK 0x3
+#define AR71XX_DDR_DIV_SHIFT 18
+#define AR71XX_DDR_DIV_MASK 0x3
+#define AR71XX_AHB_DIV_SHIFT 20
+#define AR71XX_AHB_DIV_MASK 0x7
+
+#define AR71XX_ETH0_PLL_SHIFT 17
+#define AR71XX_ETH1_PLL_SHIFT 19
+
+#define AR724X_PLL_REG_CPU_CONFIG 0x00
+#define AR724X_PLL_REG_PCIE_CONFIG 0x18
+
+#define AR724X_PLL_DIV_SHIFT 0
+#define AR724X_PLL_DIV_MASK 0x3ff
+#define AR724X_PLL_REF_DIV_SHIFT 10
+#define AR724X_PLL_REF_DIV_MASK 0xf
+#define AR724X_AHB_DIV_SHIFT 19
+#define AR724X_AHB_DIV_MASK 0x1
+#define AR724X_DDR_DIV_SHIFT 22
+#define AR724X_DDR_DIV_MASK 0x3
+
+#define AR91XX_PLL_REG_CPU_CONFIG 0x00
+#define AR91XX_PLL_REG_ETH_CONFIG 0x04
+#define AR91XX_PLL_REG_ETH0_INT_CLOCK 0x14
+#define AR91XX_PLL_REG_ETH1_INT_CLOCK 0x18
+
+#define AR91XX_PLL_DIV_SHIFT 0
+#define AR91XX_PLL_DIV_MASK 0x3ff
+#define AR91XX_DDR_DIV_SHIFT 22
+#define AR91XX_DDR_DIV_MASK 0x3
+#define AR91XX_AHB_DIV_SHIFT 19
+#define AR91XX_AHB_DIV_MASK 0x1
+
+#define AR91XX_ETH0_PLL_SHIFT 20
+#define AR91XX_ETH1_PLL_SHIFT 22
+
+// extern void __iomem *ar71xx_pll_base;
+
+// static inline void ar71xx_pll_wr(unsigned reg, u32 val)
+// {
+ // __raw_writel(val, ar71xx_pll_base + reg);
+// }
+
+// static inline u32 ar71xx_pll_rr(unsigned reg)
+// {
+ // return __raw_readl(ar71xx_pll_base + reg);
+// }
+
+/*
+ * USB_CONFIG block
+ */
+#define USB_CTRL_REG_FLADJ 0x00
+#define USB_CTRL_REG_CONFIG 0x04
+
+// extern void __iomem *ar71xx_usb_ctrl_base;
+
+// static inline void ar71xx_usb_ctrl_wr(unsigned reg, u32 val)
+// {
+ // __raw_writel(val, ar71xx_usb_ctrl_base + reg);
+// }
+
+// static inline u32 ar71xx_usb_ctrl_rr(unsigned reg)
+// {
+ // return __raw_readl(ar71xx_usb_ctrl_base + reg);
+// }
+
+/*
+ * GPIO block
+ */
+#define GPIO_REG_OE 0x00
+#define GPIO_REG_IN 0x04
+#define GPIO_REG_OUT 0x08
+#define GPIO_REG_SET 0x0c
+#define GPIO_REG_CLEAR 0x10
+#define GPIO_REG_INT_MODE 0x14
+#define GPIO_REG_INT_TYPE 0x18
+#define GPIO_REG_INT_POLARITY 0x1c
+#define GPIO_REG_INT_PENDING 0x20
+#define GPIO_REG_INT_ENABLE 0x24
+#define GPIO_REG_FUNC 0x28
+
+#define AR71XX_GPIO_FUNC_STEREO_EN BIT(17)
+#define AR71XX_GPIO_FUNC_SLIC_EN BIT(16)
+#define AR71XX_GPIO_FUNC_SPI_CS2_EN BIT(13)
+#define AR71XX_GPIO_FUNC_SPI_CS1_EN BIT(12)
+#define AR71XX_GPIO_FUNC_UART_EN BIT(8)
+#define AR71XX_GPIO_FUNC_USB_OC_EN BIT(4)
+#define AR71XX_GPIO_FUNC_USB_CLK_EN BIT(0)
+
+#define AR71XX_GPIO_COUNT 16
+
+#define AR724X_GPIO_FUNC_GE0_MII_CLK_EN BIT(19)
+#define AR724X_GPIO_FUNC_SPI_EN BIT(18)
+#define AR724X_GPIO_FUNC_SPI_CS_EN2 BIT(14)
+#define AR724X_GPIO_FUNC_SPI_CS_EN1 BIT(13)
+#define AR724X_GPIO_FUNC_CLK_OBS5_EN BIT(12)
+#define AR724X_GPIO_FUNC_CLK_OBS4_EN BIT(11)
+#define AR724X_GPIO_FUNC_CLK_OBS3_EN BIT(10)
+#define AR724X_GPIO_FUNC_CLK_OBS2_EN BIT(9)
+#define AR724X_GPIO_FUNC_CLK_OBS1_EN BIT(8)
+#define AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN BIT(7)
+#define AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN BIT(6)
+#define AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN BIT(5)
+#define AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN BIT(4)
+#define AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN BIT(3)
+#define AR724X_GPIO_FUNC_UART_RTS_CTS_EN BIT(2)
+#define AR724X_GPIO_FUNC_UART_EN BIT(1)
+#define AR724X_GPIO_FUNC_JTAG_DISABLE BIT(0)
+
+#define AR724X_GPIO_COUNT 18
+
+#define AR91XX_GPIO_FUNC_WMAC_LED_EN BIT(22)
+#define AR91XX_GPIO_FUNC_EXP_PORT_CS_EN BIT(21)
+#define AR91XX_GPIO_FUNC_I2S_REFCLKEN BIT(20)
+#define AR91XX_GPIO_FUNC_I2S_MCKEN BIT(19)
+#define AR91XX_GPIO_FUNC_I2S1_EN BIT(18)
+#define AR91XX_GPIO_FUNC_I2S0_EN BIT(17)
+#define AR91XX_GPIO_FUNC_SLIC_EN BIT(16)
+#define AR91XX_GPIO_FUNC_UART_RTSCTS_EN BIT(9)
+#define AR91XX_GPIO_FUNC_UART_EN BIT(8)
+#define AR91XX_GPIO_FUNC_USB_CLK_EN BIT(4)
+
+#define AR91XX_GPIO_COUNT 22
+
+// extern void __iomem *ar71xx_gpio_base;
+
+// static inline void ar71xx_gpio_wr(unsigned reg, u32 value)
+// {
+ // __raw_writel(value, ar71xx_gpio_base + reg);
+// }
+
+// static inline u32 ar71xx_gpio_rr(unsigned reg)
+// {
+ // return __raw_readl(ar71xx_gpio_base + reg);
+// }
+
+// void ar71xx_gpio_init(void) __init;
+// void ar71xx_gpio_function_enable(u32 mask);
+// void ar71xx_gpio_function_disable(u32 mask);
+// void ar71xx_gpio_function_setup(u32 set, u32 clear);
+
+/*
+ * DDR_CTRL block
+ */
+#define AR71XX_DDR_REG_PCI_WIN0 0x7c
+#define AR71XX_DDR_REG_PCI_WIN1 0x80
+#define AR71XX_DDR_REG_PCI_WIN2 0x84
+#define AR71XX_DDR_REG_PCI_WIN3 0x88
+#define AR71XX_DDR_REG_PCI_WIN4 0x8c
+#define AR71XX_DDR_REG_PCI_WIN5 0x90
+#define AR71XX_DDR_REG_PCI_WIN6 0x94
+#define AR71XX_DDR_REG_PCI_WIN7 0x98
+#define AR71XX_DDR_REG_FLUSH_GE0 0x9c
+#define AR71XX_DDR_REG_FLUSH_GE1 0xa0
+#define AR71XX_DDR_REG_FLUSH_USB 0xa4
+#define AR71XX_DDR_REG_FLUSH_PCI 0xa8
+
+#define AR724X_DDR_REG_FLUSH_GE0 0x7c
+#define AR724X_DDR_REG_FLUSH_GE1 0x80
+#define AR724X_DDR_REG_FLUSH_USB 0x84
+#define AR724X_DDR_REG_FLUSH_PCIE 0x88
+
+#define AR91XX_DDR_REG_FLUSH_GE0 0x7c
+#define AR91XX_DDR_REG_FLUSH_GE1 0x80
+#define AR91XX_DDR_REG_FLUSH_USB 0x84
+#define AR91XX_DDR_REG_FLUSH_WMAC 0x88
+
+#define PCI_WIN0_OFFS 0x10000000
+#define PCI_WIN1_OFFS 0x11000000
+#define PCI_WIN2_OFFS 0x12000000
+#define PCI_WIN3_OFFS 0x13000000
+#define PCI_WIN4_OFFS 0x14000000
+#define PCI_WIN5_OFFS 0x15000000
+#define PCI_WIN6_OFFS 0x16000000
+#define PCI_WIN7_OFFS 0x07000000
+
+// extern void __iomem *ar71xx_ddr_base;
+
+// static inline void ar71xx_ddr_wr(unsigned reg, u32 val)
+// {
+ // __raw_writel(val, ar71xx_ddr_base + reg);
+// }
+
+// static inline u32 ar71xx_ddr_rr(unsigned reg)
+// {
+ // return __raw_readl(ar71xx_ddr_base + reg);
+// }
+
+// void ar71xx_ddr_flush(u32 reg);
+
+/*
+ * PCI block
+ */
+#define AR71XX_PCI_CFG_BASE (AR71XX_PCI_MEM_BASE + PCI_WIN7_OFFS + 0x10000)
+#define AR71XX_PCI_CFG_SIZE 0x100
+
+#define PCI_REG_CRP_AD_CBE 0x00
+#define PCI_REG_CRP_WRDATA 0x04
+#define PCI_REG_CRP_RDDATA 0x08
+#define PCI_REG_CFG_AD 0x0c
+#define PCI_REG_CFG_CBE 0x10
+#define PCI_REG_CFG_WRDATA 0x14
+#define PCI_REG_CFG_RDDATA 0x18
+#define PCI_REG_PCI_ERR 0x1c
+#define PCI_REG_PCI_ERR_ADDR 0x20
+#define PCI_REG_AHB_ERR 0x24
+#define PCI_REG_AHB_ERR_ADDR 0x28
+
+#define PCI_CRP_CMD_WRITE 0x00010000
+#define PCI_CRP_CMD_READ 0x00000000
+#define PCI_CFG_CMD_READ 0x0000000a
+#define PCI_CFG_CMD_WRITE 0x0000000b
+
+#define PCI_IDSEL_ADL_START 17
+
+#define AR724X_PCI_CFG_BASE (AR71XX_PCI_MEM_BASE + 0x4000000)
+#define AR724X_PCI_CFG_SIZE 0x1000
+
+#define AR724X_PCI_REG_APP 0x00
+#define AR724X_PCI_REG_RESET 0x18
+#define AR724X_PCI_REG_INT_STATUS 0x4c
+#define AR724X_PCI_REG_INT_MASK 0x50
+
+#define AR724X_PCI_APP_LTSSM_ENABLE BIT(0)
+#define AR724X_PCI_RESET_LINK_UP BIT(0)
+
+#define AR724X_PCI_INT_DEV0 BIT(14)
+
+/*
+ * RESET block
+ */
+#define AR71XX_RESET_REG_TIMER 0x00
+#define AR71XX_RESET_REG_TIMER_RELOAD 0x04
+#define AR71XX_RESET_REG_WDOG_CTRL 0x08
+#define AR71XX_RESET_REG_WDOG 0x0c
+#define AR71XX_RESET_REG_MISC_INT_STATUS 0x10
+#define AR71XX_RESET_REG_MISC_INT_ENABLE 0x14
+#define AR71XX_RESET_REG_PCI_INT_STATUS 0x18
+#define AR71XX_RESET_REG_PCI_INT_ENABLE 0x1c
+#define AR71XX_RESET_REG_GLOBAL_INT_STATUS 0x20
+#define AR71XX_RESET_REG_RESET_MODULE 0x24
+#define AR71XX_RESET_REG_PERFC_CTRL 0x2c
+#define AR71XX_RESET_REG_PERFC0 0x30
+#define AR71XX_RESET_REG_PERFC1 0x34
+#define AR71XX_RESET_REG_REV_ID 0x90
+
+#define AR91XX_RESET_REG_GLOBAL_INT_STATUS 0x18
+#define AR91XX_RESET_REG_RESET_MODULE 0x1c
+#define AR91XX_RESET_REG_PERF_CTRL 0x20
+#define AR91XX_RESET_REG_PERFC0 0x24
+#define AR91XX_RESET_REG_PERFC1 0x28
+
+#define AR724X_RESET_REG_RESET_MODULE 0x1c
+
+#define WDOG_CTRL_LAST_RESET BIT(31)
+#define WDOG_CTRL_ACTION_MASK 3
+#define WDOG_CTRL_ACTION_NONE 0 /* no action */
+#define WDOG_CTRL_ACTION_GPI 1 /* general purpose interrupt */
+#define WDOG_CTRL_ACTION_NMI 2 /* NMI */
+#define WDOG_CTRL_ACTION_FCR 3 /* full chip reset */
+
+#define MISC_INT_DMA BIT(7)
+#define MISC_INT_OHCI BIT(6)
+#define MISC_INT_PERFC BIT(5)
+#define MISC_INT_WDOG BIT(4)
+#define MISC_INT_UART BIT(3)
+#define MISC_INT_GPIO BIT(2)
+#define MISC_INT_ERROR BIT(1)
+#define MISC_INT_TIMER BIT(0)
+
+#define PCI_INT_CORE BIT(4)
+#define PCI_INT_DEV2 BIT(2)
+#define PCI_INT_DEV1 BIT(1)
+#define PCI_INT_DEV0 BIT(0)
+
+#define RESET_MODULE_EXTERNAL BIT(28)
+#define RESET_MODULE_FULL_CHIP BIT(24)
+#define RESET_MODULE_AMBA2WMAC BIT(22)
+#define RESET_MODULE_CPU_NMI BIT(21)
+#define RESET_MODULE_CPU_COLD BIT(20)
+#define RESET_MODULE_DMA BIT(19)
+#define RESET_MODULE_SLIC BIT(18)
+#define RESET_MODULE_STEREO BIT(17)
+#define RESET_MODULE_DDR BIT(16)
+#define RESET_MODULE_GE1_MAC BIT(13)
+#define RESET_MODULE_GE1_PHY BIT(12)
+#define RESET_MODULE_USBSUS_OVERRIDE BIT(10)
+#define RESET_MODULE_GE0_MAC BIT(9)
+#define RESET_MODULE_GE0_PHY BIT(8)
+#define RESET_MODULE_USB_OHCI_DLL BIT(6)
+#define RESET_MODULE_USB_HOST BIT(5)
+#define RESET_MODULE_USB_PHY BIT(4)
+#define RESET_MODULE_USB_OHCI_DLL_7240 BIT(3)
+#define RESET_MODULE_PCI_BUS BIT(1)
+#define RESET_MODULE_PCI_CORE BIT(0)
+
+#define AR724X_RESET_GE1_MDIO BIT(23)
+#define AR724X_RESET_GE0_MDIO BIT(22)
+#define AR724X_RESET_PCIE_PHY_SERIAL BIT(10)
+#define AR724X_RESET_PCIE_PHY BIT(7)
+#define AR724X_RESET_PCIE BIT(6)
+
+#define REV_ID_MAJOR_MASK 0xfff0
+#define REV_ID_MAJOR_AR71XX 0x00a0
+#define REV_ID_MAJOR_AR913X 0x00b0
+#define REV_ID_MAJOR_AR7240 0x00c0
+#define REV_ID_MAJOR_AR7241 0x0100
+#define REV_ID_MAJOR_AR7242 0x1100
+
+#define AR71XX_REV_ID_MINOR_MASK 0x3
+#define AR71XX_REV_ID_MINOR_AR7130 0x0
+#define AR71XX_REV_ID_MINOR_AR7141 0x1
+#define AR71XX_REV_ID_MINOR_AR7161 0x2
+#define AR71XX_REV_ID_REVISION_MASK 0x3
+#define AR71XX_REV_ID_REVISION_SHIFT 2
+
+#define AR91XX_REV_ID_MINOR_MASK 0x3
+#define AR91XX_REV_ID_MINOR_AR9130 0x0
+#define AR91XX_REV_ID_MINOR_AR9132 0x1
+#define AR91XX_REV_ID_REVISION_MASK 0x3
+#define AR91XX_REV_ID_REVISION_SHIFT 2
+
+#define AR724X_REV_ID_REVISION_MASK 0x3
+
+// extern void __iomem *ar71xx_reset_base;
+
+static inline void ar71xx_reset_wr(unsigned reg, u32 val)
+{
+ __raw_writel(val, KSEG1ADDR(AR71XX_RESET_BASE) + reg);
+}
+
+static inline u32 ar71xx_reset_rr(unsigned reg)
+{
+ return __raw_readl(KSEG1ADDR(AR71XX_RESET_BASE) + reg);
+}
+
+// void ar71xx_device_stop(u32 mask);
+// void ar71xx_device_start(u32 mask);
+// int ar71xx_device_stopped(u32 mask);
+
+/*
+ * SPI block
+ */
+#define SPI_REG_FS 0x00 /* Function Select */
+#define SPI_REG_CTRL 0x04 /* SPI Control */
+#define SPI_REG_IOC 0x08 /* SPI I/O Control */
+#define SPI_REG_RDS 0x0c /* Read Data Shift */
+
+#define SPI_FS_GPIO BIT(0) /* Enable GPIO mode */
+
+#define SPI_CTRL_RD BIT(6) /* Remap Disable */
+#define SPI_CTRL_DIV_MASK 0x3f
+
+#define SPI_IOC_DO BIT(0) /* Data Out pin */
+#define SPI_IOC_CLK BIT(8) /* CLK pin */
+#define SPI_IOC_CS(n) BIT(16 + (n))
+#define SPI_IOC_CS0 SPI_IOC_CS(0)
+#define SPI_IOC_CS1 SPI_IOC_CS(1)
+#define SPI_IOC_CS2 SPI_IOC_CS(2)
+#define SPI_IOC_CS_ALL (SPI_IOC_CS0 | SPI_IOC_CS1 | SPI_IOC_CS2)
+
+// void ar71xx_flash_acquire(void);
+// void ar71xx_flash_release(void);
+
+/*
+ * MII_CTRL block
+ */
+#define MII_REG_MII0_CTRL 0x00
+#define MII_REG_MII1_CTRL 0x04
+
+#define MII0_CTRL_IF_GMII 0
+#define MII0_CTRL_IF_MII 1
+#define MII0_CTRL_IF_RGMII 2
+#define MII0_CTRL_IF_RMII 3
+
+#define MII1_CTRL_IF_RGMII 0
+#define MII1_CTRL_IF_RMII 1
+
+#endif /* __ASSEMBLER__ */
+
+#endif /* __ASM_MACH_AR71XX_H */
diff --git a/package/boot/uboot-ar71xx/files/include/asm-mips/.svn/text-base/ar71xx_gpio.h.svn-base b/package/boot/uboot-ar71xx/files/include/asm-mips/.svn/text-base/ar71xx_gpio.h.svn-base
new file mode 100644
index 0000000..c92364b
--- /dev/null
+++ b/package/boot/uboot-ar71xx/files/include/asm-mips/.svn/text-base/ar71xx_gpio.h.svn-base
@@ -0,0 +1,65 @@
+/*
+ * (C) Copyright 2010
+ * Michael Kurz <michi.kurz@googlemail.com>.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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 of
+ * the License, 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef _AR71XX_GPIO_H
+#define _AR71XX_GPIO_H
+
+#include <common.h>
+#include <asm/ar71xx.h>
+
+static inline void ar71xx_setpin(uint8_t pin, uint8_t state)
+{
+ uint32_t reg = readl(KSEG1ADDR(AR71XX_GPIO_BASE + GPIO_REG_OUT));
+
+ if (state != 0) {
+ reg |= (1 << pin);
+ } else {
+ reg &= ~(1 << pin);
+ }
+
+ writel(reg, KSEG1ADDR(AR71XX_GPIO_BASE + GPIO_REG_OUT));
+ readl(KSEG1ADDR(AR71XX_GPIO_BASE + GPIO_REG_OUT));
+}
+
+static inline uint32_t ar71xx_getpin(uint8_t pin)
+{
+ uint32_t reg = readl(KSEG1ADDR(AR71XX_GPIO_BASE + GPIO_REG_IN));
+ return (((reg & (1 << pin)) != 0) ? 1 : 0);
+}
+
+static inline void ar71xx_setpindir(uint8_t pin, uint8_t direction)
+{
+ uint32_t reg = readl(KSEG1ADDR(AR71XX_GPIO_BASE + GPIO_REG_OE));
+
+ if (direction != 0) {
+ reg |= (1 << pin);
+ } else {
+ reg &= ~(1 << pin);
+ }
+
+ writel(reg, KSEG1ADDR(AR71XX_GPIO_BASE + GPIO_REG_OE));
+ readl(KSEG1ADDR(AR71XX_GPIO_BASE + GPIO_REG_OE));
+}
+
+
+#endif /* AR71XX_GPIO_H */
diff --git a/package/boot/uboot-ar71xx/files/include/asm-mips/ar71xx.h b/package/boot/uboot-ar71xx/files/include/asm-mips/ar71xx.h
new file mode 100644
index 0000000..e8f3f61
--- /dev/null
+++ b/package/boot/uboot-ar71xx/files/include/asm-mips/ar71xx.h
@@ -0,0 +1,515 @@
+/*
+ * Atheros AR71xx SoC specific definitions
+ *
+ * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
+ * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
+ *
+ * Parts of this file are based on Atheros' 2.6.15 BSP
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ */
+
+#ifndef __ASM_MACH_AR71XX_H
+#define __ASM_MACH_AR71XX_H
+
+#include <linux/types.h>
+#include <asm/io.h>
+#include <linux/bitops.h>
+
+#ifndef __ASSEMBLER__
+
+#define BIT(x) (1<<(x))
+
+#define AR71XX_PCI_MEM_BASE 0x10000000
+#define AR71XX_PCI_MEM_SIZE 0x08000000
+#define AR71XX_APB_BASE 0x18000000
+#define AR71XX_GE0_BASE 0x19000000
+#define AR71XX_GE0_SIZE 0x01000000
+#define AR71XX_GE1_BASE 0x1a000000
+#define AR71XX_GE1_SIZE 0x01000000
+#define AR71XX_EHCI_BASE 0x1b000000
+#define AR71XX_EHCI_SIZE 0x01000000
+#define AR71XX_OHCI_BASE 0x1c000000
+#define AR71XX_OHCI_SIZE 0x01000000
+#define AR7240_OHCI_BASE 0x1b000000
+#define AR7240_OHCI_SIZE 0x01000000
+#define AR71XX_SPI_BASE 0x1f000000
+#define AR71XX_SPI_SIZE 0x01000000
+
+#define AR71XX_DDR_CTRL_BASE (AR71XX_APB_BASE + 0x00000000)
+#define AR71XX_DDR_CTRL_SIZE 0x10000
+#define AR71XX_CPU_BASE (AR71XX_APB_BASE + 0x00010000)
+#define AR71XX_UART_BASE (AR71XX_APB_BASE + 0x00020000)
+#define AR71XX_UART_SIZE 0x10000
+#define AR71XX_USB_CTRL_BASE (AR71XX_APB_BASE + 0x00030000)
+#define AR71XX_USB_CTRL_SIZE 0x10000
+#define AR71XX_GPIO_BASE (AR71XX_APB_BASE + 0x00040000)
+#define AR71XX_GPIO_SIZE 0x10000
+#define AR71XX_PLL_BASE (AR71XX_APB_BASE + 0x00050000)
+#define AR71XX_PLL_SIZE 0x10000
+#define AR71XX_RESET_BASE (AR71XX_APB_BASE + 0x00060000)
+#define AR71XX_RESET_SIZE 0x10000
+#define AR71XX_MII_BASE (AR71XX_APB_BASE + 0x00070000)
+#define AR71XX_MII_SIZE 0x10000
+#define AR71XX_SLIC_BASE (AR71XX_APB_BASE + 0x00090000)
+#define AR71XX_SLIC_SIZE 0x10000
+#define AR71XX_DMA_BASE (AR71XX_APB_BASE + 0x000A0000)
+#define AR71XX_DMA_SIZE 0x10000
+#define AR71XX_STEREO_BASE (AR71XX_APB_BASE + 0x000B0000)
+#define AR71XX_STEREO_SIZE 0x10000
+
+#define AR724X_PCI_CRP_BASE (AR71XX_APB_BASE + 0x000C0000)
+#define AR724X_PCI_CRP_SIZE 0x100
+
+#define AR724X_PCI_CTRL_BASE (AR71XX_APB_BASE + 0x000F0000)
+#define AR724X_PCI_CTRL_SIZE 0x100
+
+#define AR91XX_WMAC_BASE (AR71XX_APB_BASE + 0x000C0000)
+#define AR91XX_WMAC_SIZE 0x30000
+
+#define AR71XX_MEM_SIZE_MIN 0x0200000
+#define AR71XX_MEM_SIZE_MAX 0x10000000
+
+#define AR71XX_CPU_IRQ_BASE 0
+#define AR71XX_MISC_IRQ_BASE 8
+#define AR71XX_MISC_IRQ_COUNT 8
+#define AR71XX_GPIO_IRQ_BASE 16
+#define AR71XX_GPIO_IRQ_COUNT 32
+#define AR71XX_PCI_IRQ_BASE 48
+#define AR71XX_PCI_IRQ_COUNT 8
+
+#define AR71XX_CPU_IRQ_IP2 (AR71XX_CPU_IRQ_BASE + 2)
+#define AR71XX_CPU_IRQ_USB (AR71XX_CPU_IRQ_BASE + 3)
+#define AR71XX_CPU_IRQ_GE0 (AR71XX_CPU_IRQ_BASE + 4)
+#define AR71XX_CPU_IRQ_GE1 (AR71XX_CPU_IRQ_BASE + 5)
+#define AR71XX_CPU_IRQ_MISC (AR71XX_CPU_IRQ_BASE + 6)
+#define AR71XX_CPU_IRQ_TIMER (AR71XX_CPU_IRQ_BASE + 7)
+
+#define AR71XX_MISC_IRQ_TIMER (AR71XX_MISC_IRQ_BASE + 0)
+#define AR71XX_MISC_IRQ_ERROR (AR71XX_MISC_IRQ_BASE + 1)
+#define AR71XX_MISC_IRQ_GPIO (AR71XX_MISC_IRQ_BASE + 2)
+#define AR71XX_MISC_IRQ_UART (AR71XX_MISC_IRQ_BASE + 3)
+#define AR71XX_MISC_IRQ_WDOG (AR71XX_MISC_IRQ_BASE + 4)
+#define AR71XX_MISC_IRQ_PERFC (AR71XX_MISC_IRQ_BASE + 5)
+#define AR71XX_MISC_IRQ_OHCI (AR71XX_MISC_IRQ_BASE + 6)
+#define AR71XX_MISC_IRQ_DMA (AR71XX_MISC_IRQ_BASE + 7)
+
+#define AR71XX_GPIO_IRQ(_x) (AR71XX_GPIO_IRQ_BASE + (_x))
+
+#define AR71XX_PCI_IRQ_DEV0 (AR71XX_PCI_IRQ_BASE + 0)
+#define AR71XX_PCI_IRQ_DEV1 (AR71XX_PCI_IRQ_BASE + 1)
+#define AR71XX_PCI_IRQ_DEV2 (AR71XX_PCI_IRQ_BASE + 2)
+#define AR71XX_PCI_IRQ_CORE (AR71XX_PCI_IRQ_BASE + 4)
+
+extern u32 ar71xx_ahb_freq;
+extern u32 ar71xx_cpu_freq;
+extern u32 ar71xx_ddr_freq;
+
+enum ar71xx_soc_type {
+ AR71XX_SOC_UNKNOWN,
+ AR71XX_SOC_AR7130,
+ AR71XX_SOC_AR7141,
+ AR71XX_SOC_AR7161,
+ AR71XX_SOC_AR7240,
+ AR71XX_SOC_AR7241,
+ AR71XX_SOC_AR7242,
+ AR71XX_SOC_AR9130,
+ AR71XX_SOC_AR9132
+};
+
+extern enum ar71xx_soc_type ar71xx_soc;
+
+/*
+ * PLL block
+ */
+#define AR71XX_PLL_REG_CPU_CONFIG 0x00
+#define AR71XX_PLL_REG_SEC_CONFIG 0x04
+#define AR71XX_PLL_REG_ETH0_INT_CLOCK 0x10
+#define AR71XX_PLL_REG_ETH1_INT_CLOCK 0x14
+
+#define AR71XX_PLL_DIV_SHIFT 3
+#define AR71XX_PLL_DIV_MASK 0x1f
+#define AR71XX_CPU_DIV_SHIFT 16
+#define AR71XX_CPU_DIV_MASK 0x3
+#define AR71XX_DDR_DIV_SHIFT 18
+#define AR71XX_DDR_DIV_MASK 0x3
+#define AR71XX_AHB_DIV_SHIFT 20
+#define AR71XX_AHB_DIV_MASK 0x7
+
+#define AR71XX_ETH0_PLL_SHIFT 17
+#define AR71XX_ETH1_PLL_SHIFT 19
+
+#define AR724X_PLL_REG_CPU_CONFIG 0x00
+#define AR724X_PLL_REG_PCIE_CONFIG 0x18
+
+#define AR724X_PLL_DIV_SHIFT 0
+#define AR724X_PLL_DIV_MASK 0x3ff
+#define AR724X_PLL_REF_DIV_SHIFT 10
+#define AR724X_PLL_REF_DIV_MASK 0xf
+#define AR724X_AHB_DIV_SHIFT 19
+#define AR724X_AHB_DIV_MASK 0x1
+#define AR724X_DDR_DIV_SHIFT 22
+#define AR724X_DDR_DIV_MASK 0x3
+
+#define AR91XX_PLL_REG_CPU_CONFIG 0x00
+#define AR91XX_PLL_REG_ETH_CONFIG 0x04
+#define AR91XX_PLL_REG_ETH0_INT_CLOCK 0x14
+#define AR91XX_PLL_REG_ETH1_INT_CLOCK 0x18
+
+#define AR91XX_PLL_DIV_SHIFT 0
+#define AR91XX_PLL_DIV_MASK 0x3ff
+#define AR91XX_DDR_DIV_SHIFT 22
+#define AR91XX_DDR_DIV_MASK 0x3
+#define AR91XX_AHB_DIV_SHIFT 19
+#define AR91XX_AHB_DIV_MASK 0x1
+
+#define AR91XX_ETH0_PLL_SHIFT 20
+#define AR91XX_ETH1_PLL_SHIFT 22
+
+// extern void __iomem *ar71xx_pll_base;
+
+// static inline void ar71xx_pll_wr(unsigned reg, u32 val)
+// {
+ // __raw_writel(val, ar71xx_pll_base + reg);
+// }
+
+// static inline u32 ar71xx_pll_rr(unsigned reg)
+// {
+ // return __raw_readl(ar71xx_pll_base + reg);
+// }
+
+/*
+ * USB_CONFIG block
+ */
+#define USB_CTRL_REG_FLADJ 0x00
+#define USB_CTRL_REG_CONFIG 0x04
+
+// extern void __iomem *ar71xx_usb_ctrl_base;
+
+// static inline void ar71xx_usb_ctrl_wr(unsigned reg, u32 val)
+// {
+ // __raw_writel(val, ar71xx_usb_ctrl_base + reg);
+// }
+
+// static inline u32 ar71xx_usb_ctrl_rr(unsigned reg)
+// {
+ // return __raw_readl(ar71xx_usb_ctrl_base + reg);
+// }
+
+/*
+ * GPIO block
+ */
+#define GPIO_REG_OE 0x00
+#define GPIO_REG_IN 0x04
+#define GPIO_REG_OUT 0x08
+#define GPIO_REG_SET 0x0c
+#define GPIO_REG_CLEAR 0x10
+#define GPIO_REG_INT_MODE 0x14
+#define GPIO_REG_INT_TYPE 0x18
+#define GPIO_REG_INT_POLARITY 0x1c
+#define GPIO_REG_INT_PENDING 0x20
+#define GPIO_REG_INT_ENABLE 0x24
+#define GPIO_REG_FUNC 0x28
+
+#define AR71XX_GPIO_FUNC_STEREO_EN BIT(17)
+#define AR71XX_GPIO_FUNC_SLIC_EN BIT(16)
+#define AR71XX_GPIO_FUNC_SPI_CS2_EN BIT(13)
+#define AR71XX_GPIO_FUNC_SPI_CS1_EN BIT(12)
+#define AR71XX_GPIO_FUNC_UART_EN BIT(8)
+#define AR71XX_GPIO_FUNC_USB_OC_EN BIT(4)
+#define AR71XX_GPIO_FUNC_USB_CLK_EN BIT(0)
+
+#define AR71XX_GPIO_COUNT 16
+
+#define AR724X_GPIO_FUNC_GE0_MII_CLK_EN BIT(19)
+#define AR724X_GPIO_FUNC_SPI_EN BIT(18)
+#define AR724X_GPIO_FUNC_SPI_CS_EN2 BIT(14)
+#define AR724X_GPIO_FUNC_SPI_CS_EN1 BIT(13)
+#define AR724X_GPIO_FUNC_CLK_OBS5_EN BIT(12)
+#define AR724X_GPIO_FUNC_CLK_OBS4_EN BIT(11)
+#define AR724X_GPIO_FUNC_CLK_OBS3_EN BIT(10)
+#define AR724X_GPIO_FUNC_CLK_OBS2_EN BIT(9)
+#define AR724X_GPIO_FUNC_CLK_OBS1_EN BIT(8)
+#define AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN BIT(7)
+#define AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN BIT(6)
+#define AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN BIT(5)
+#define AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN BIT(4)
+#define AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN BIT(3)
+#define AR724X_GPIO_FUNC_UART_RTS_CTS_EN BIT(2)
+#define AR724X_GPIO_FUNC_UART_EN BIT(1)
+#define AR724X_GPIO_FUNC_JTAG_DISABLE BIT(0)
+
+#define AR724X_GPIO_COUNT 18
+
+#define AR91XX_GPIO_FUNC_WMAC_LED_EN BIT(22)
+#define AR91XX_GPIO_FUNC_EXP_PORT_CS_EN BIT(21)
+#define AR91XX_GPIO_FUNC_I2S_REFCLKEN BIT(20)
+#define AR91XX_GPIO_FUNC_I2S_MCKEN BIT(19)
+#define AR91XX_GPIO_FUNC_I2S1_EN BIT(18)
+#define AR91XX_GPIO_FUNC_I2S0_EN BIT(17)
+#define AR91XX_GPIO_FUNC_SLIC_EN BIT(16)
+#define AR91XX_GPIO_FUNC_UART_RTSCTS_EN BIT(9)
+#define AR91XX_GPIO_FUNC_UART_EN BIT(8)
+#define AR91XX_GPIO_FUNC_USB_CLK_EN BIT(4)
+
+#define AR91XX_GPIO_COUNT 22
+
+// extern void __iomem *ar71xx_gpio_base;
+
+// static inline void ar71xx_gpio_wr(unsigned reg, u32 value)
+// {
+ // __raw_writel(value, ar71xx_gpio_base + reg);
+// }
+
+// static inline u32 ar71xx_gpio_rr(unsigned reg)
+// {
+ // return __raw_readl(ar71xx_gpio_base + reg);
+// }
+
+// void ar71xx_gpio_init(void) __init;
+// void ar71xx_gpio_function_enable(u32 mask);
+// void ar71xx_gpio_function_disable(u32 mask);
+// void ar71xx_gpio_function_setup(u32 set, u32 clear);
+
+/*
+ * DDR_CTRL block
+ */
+#define AR71XX_DDR_REG_PCI_WIN0 0x7c
+#define AR71XX_DDR_REG_PCI_WIN1 0x80
+#define AR71XX_DDR_REG_PCI_WIN2 0x84
+#define AR71XX_DDR_REG_PCI_WIN3 0x88
+#define AR71XX_DDR_REG_PCI_WIN4 0x8c
+#define AR71XX_DDR_REG_PCI_WIN5 0x90
+#define AR71XX_DDR_REG_PCI_WIN6 0x94
+#define AR71XX_DDR_REG_PCI_WIN7 0x98
+#define AR71XX_DDR_REG_FLUSH_GE0 0x9c
+#define AR71XX_DDR_REG_FLUSH_GE1 0xa0
+#define AR71XX_DDR_REG_FLUSH_USB 0xa4
+#define AR71XX_DDR_REG_FLUSH_PCI 0xa8
+
+#define AR724X_DDR_REG_FLUSH_GE0 0x7c
+#define AR724X_DDR_REG_FLUSH_GE1 0x80
+#define AR724X_DDR_REG_FLUSH_USB 0x84
+#define AR724X_DDR_REG_FLUSH_PCIE 0x88
+
+#define AR91XX_DDR_REG_FLUSH_GE0 0x7c
+#define AR91XX_DDR_REG_FLUSH_GE1 0x80
+#define AR91XX_DDR_REG_FLUSH_USB 0x84
+#define AR91XX_DDR_REG_FLUSH_WMAC 0x88
+
+#define PCI_WIN0_OFFS 0x10000000
+#define PCI_WIN1_OFFS 0x11000000
+#define PCI_WIN2_OFFS 0x12000000
+#define PCI_WIN3_OFFS 0x13000000
+#define PCI_WIN4_OFFS 0x14000000
+#define PCI_WIN5_OFFS 0x15000000
+#define PCI_WIN6_OFFS 0x16000000
+#define PCI_WIN7_OFFS 0x07000000
+
+// extern void __iomem *ar71xx_ddr_base;
+
+// static inline void ar71xx_ddr_wr(unsigned reg, u32 val)
+// {
+ // __raw_writel(val, ar71xx_ddr_base + reg);
+// }
+
+// static inline u32 ar71xx_ddr_rr(unsigned reg)
+// {
+ // return __raw_readl(ar71xx_ddr_base + reg);
+// }
+
+// void ar71xx_ddr_flush(u32 reg);
+
+/*
+ * PCI block
+ */
+#define AR71XX_PCI_CFG_BASE (AR71XX_PCI_MEM_BASE + PCI_WIN7_OFFS + 0x10000)
+#define AR71XX_PCI_CFG_SIZE 0x100
+
+#define PCI_REG_CRP_AD_CBE 0x00
+#define PCI_REG_CRP_WRDATA 0x04
+#define PCI_REG_CRP_RDDATA 0x08
+#define PCI_REG_CFG_AD 0x0c
+#define PCI_REG_CFG_CBE 0x10
+#define PCI_REG_CFG_WRDATA 0x14
+#define PCI_REG_CFG_RDDATA 0x18
+#define PCI_REG_PCI_ERR 0x1c
+#define PCI_REG_PCI_ERR_ADDR 0x20
+#define PCI_REG_AHB_ERR 0x24
+#define PCI_REG_AHB_ERR_ADDR 0x28
+
+#define PCI_CRP_CMD_WRITE 0x00010000
+#define PCI_CRP_CMD_READ 0x00000000
+#define PCI_CFG_CMD_READ 0x0000000a
+#define PCI_CFG_CMD_WRITE 0x0000000b
+
+#define PCI_IDSEL_ADL_START 17
+
+#define AR724X_PCI_CFG_BASE (AR71XX_PCI_MEM_BASE + 0x4000000)
+#define AR724X_PCI_CFG_SIZE 0x1000
+
+#define AR724X_PCI_REG_APP 0x00
+#define AR724X_PCI_REG_RESET 0x18
+#define AR724X_PCI_REG_INT_STATUS 0x4c
+#define AR724X_PCI_REG_INT_MASK 0x50
+
+#define AR724X_PCI_APP_LTSSM_ENABLE BIT(0)
+#define AR724X_PCI_RESET_LINK_UP BIT(0)
+
+#define AR724X_PCI_INT_DEV0 BIT(14)
+
+/*
+ * RESET block
+ */
+#define AR71XX_RESET_REG_TIMER 0x00
+#define AR71XX_RESET_REG_TIMER_RELOAD 0x04
+#define AR71XX_RESET_REG_WDOG_CTRL 0x08
+#define AR71XX_RESET_REG_WDOG 0x0c
+#define AR71XX_RESET_REG_MISC_INT_STATUS 0x10
+#define AR71XX_RESET_REG_MISC_INT_ENABLE 0x14
+#define AR71XX_RESET_REG_PCI_INT_STATUS 0x18
+#define AR71XX_RESET_REG_PCI_INT_ENABLE 0x1c
+#define AR71XX_RESET_REG_GLOBAL_INT_STATUS 0x20
+#define AR71XX_RESET_REG_RESET_MODULE 0x24
+#define AR71XX_RESET_REG_PERFC_CTRL 0x2c
+#define AR71XX_RESET_REG_PERFC0 0x30
+#define AR71XX_RESET_REG_PERFC1 0x34
+#define AR71XX_RESET_REG_REV_ID 0x90
+
+#define AR91XX_RESET_REG_GLOBAL_INT_STATUS 0x18
+#define AR91XX_RESET_REG_RESET_MODULE 0x1c
+#define AR91XX_RESET_REG_PERF_CTRL 0x20
+#define AR91XX_RESET_REG_PERFC0 0x24
+#define AR91XX_RESET_REG_PERFC1 0x28
+
+#define AR724X_RESET_REG_RESET_MODULE 0x1c
+
+#define WDOG_CTRL_LAST_RESET BIT(31)
+#define WDOG_CTRL_ACTION_MASK 3
+#define WDOG_CTRL_ACTION_NONE 0 /* no action */
+#define WDOG_CTRL_ACTION_GPI 1 /* general purpose interrupt */
+#define WDOG_CTRL_ACTION_NMI 2 /* NMI */
+#define WDOG_CTRL_ACTION_FCR 3 /* full chip reset */
+
+#define MISC_INT_DMA BIT(7)
+#define MISC_INT_OHCI BIT(6)
+#define MISC_INT_PERFC BIT(5)
+#define MISC_INT_WDOG BIT(4)
+#define MISC_INT_UART BIT(3)
+#define MISC_INT_GPIO BIT(2)
+#define MISC_INT_ERROR BIT(1)
+#define MISC_INT_TIMER BIT(0)
+
+#define PCI_INT_CORE BIT(4)
+#define PCI_INT_DEV2 BIT(2)
+#define PCI_INT_DEV1 BIT(1)
+#define PCI_INT_DEV0 BIT(0)
+
+#define RESET_MODULE_EXTERNAL BIT(28)
+#define RESET_MODULE_FULL_CHIP BIT(24)
+#define RESET_MODULE_AMBA2WMAC BIT(22)
+#define RESET_MODULE_CPU_NMI BIT(21)
+#define RESET_MODULE_CPU_COLD BIT(20)
+#define RESET_MODULE_DMA BIT(19)
+#define RESET_MODULE_SLIC BIT(18)
+#define RESET_MODULE_STEREO BIT(17)
+#define RESET_MODULE_DDR BIT(16)
+#define RESET_MODULE_GE1_MAC BIT(13)
+#define RESET_MODULE_GE1_PHY BIT(12)
+#define RESET_MODULE_USBSUS_OVERRIDE BIT(10)
+#define RESET_MODULE_GE0_MAC BIT(9)
+#define RESET_MODULE_GE0_PHY BIT(8)
+#define RESET_MODULE_USB_OHCI_DLL BIT(6)
+#define RESET_MODULE_USB_HOST BIT(5)
+#define RESET_MODULE_USB_PHY BIT(4)
+#define RESET_MODULE_USB_OHCI_DLL_7240 BIT(3)
+#define RESET_MODULE_PCI_BUS BIT(1)
+#define RESET_MODULE_PCI_CORE BIT(0)
+
+#define AR724X_RESET_GE1_MDIO BIT(23)
+#define AR724X_RESET_GE0_MDIO BIT(22)
+#define AR724X_RESET_PCIE_PHY_SERIAL BIT(10)
+#define AR724X_RESET_PCIE_PHY BIT(7)
+#define AR724X_RESET_PCIE BIT(6)
+
+#define REV_ID_MAJOR_MASK 0xfff0
+#define REV_ID_MAJOR_AR71XX 0x00a0
+#define REV_ID_MAJOR_AR913X 0x00b0
+#define REV_ID_MAJOR_AR7240 0x00c0
+#define REV_ID_MAJOR_AR7241 0x0100
+#define REV_ID_MAJOR_AR7242 0x1100
+
+#define AR71XX_REV_ID_MINOR_MASK 0x3
+#define AR71XX_REV_ID_MINOR_AR7130 0x0
+#define AR71XX_REV_ID_MINOR_AR7141 0x1
+#define AR71XX_REV_ID_MINOR_AR7161 0x2
+#define AR71XX_REV_ID_REVISION_MASK 0x3
+#define AR71XX_REV_ID_REVISION_SHIFT 2
+
+#define AR91XX_REV_ID_MINOR_MASK 0x3
+#define AR91XX_REV_ID_MINOR_AR9130 0x0
+#define AR91XX_REV_ID_MINOR_AR9132 0x1
+#define AR91XX_REV_ID_REVISION_MASK 0x3
+#define AR91XX_REV_ID_REVISION_SHIFT 2
+
+#define AR724X_REV_ID_REVISION_MASK 0x3
+
+// extern void __iomem *ar71xx_reset_base;
+
+static inline void ar71xx_reset_wr(unsigned reg, u32 val)
+{
+ __raw_writel(val, KSEG1ADDR(AR71XX_RESET_BASE) + reg);
+}
+
+static inline u32 ar71xx_reset_rr(unsigned reg)
+{
+ return __raw_readl(KSEG1ADDR(AR71XX_RESET_BASE) + reg);
+}
+
+// void ar71xx_device_stop(u32 mask);
+// void ar71xx_device_start(u32 mask);
+// int ar71xx_device_stopped(u32 mask);
+
+/*
+ * SPI block
+ */
+#define SPI_REG_FS 0x00 /* Function Select */
+#define SPI_REG_CTRL 0x04 /* SPI Control */
+#define SPI_REG_IOC 0x08 /* SPI I/O Control */
+#define SPI_REG_RDS 0x0c /* Read Data Shift */
+
+#define SPI_FS_GPIO BIT(0) /* Enable GPIO mode */
+
+#define SPI_CTRL_RD BIT(6) /* Remap Disable */
+#define SPI_CTRL_DIV_MASK 0x3f
+
+#define SPI_IOC_DO BIT(0) /* Data Out pin */
+#define SPI_IOC_CLK BIT(8) /* CLK pin */
+#define SPI_IOC_CS(n) BIT(16 + (n))
+#define SPI_IOC_CS0 SPI_IOC_CS(0)
+#define SPI_IOC_CS1 SPI_IOC_CS(1)
+#define SPI_IOC_CS2 SPI_IOC_CS(2)
+#define SPI_IOC_CS_ALL (SPI_IOC_CS0 | SPI_IOC_CS1 | SPI_IOC_CS2)
+
+// void ar71xx_flash_acquire(void);
+// void ar71xx_flash_release(void);
+
+/*
+ * MII_CTRL block
+ */
+#define MII_REG_MII0_CTRL 0x00
+#define MII_REG_MII1_CTRL 0x04
+
+#define MII0_CTRL_IF_GMII 0
+#define MII0_CTRL_IF_MII 1
+#define MII0_CTRL_IF_RGMII 2
+#define MII0_CTRL_IF_RMII 3
+
+#define MII1_CTRL_IF_RGMII 0
+#define MII1_CTRL_IF_RMII 1
+
+#endif /* __ASSEMBLER__ */
+
+#endif /* __ASM_MACH_AR71XX_H */
diff --git a/package/boot/uboot-ar71xx/files/include/asm-mips/ar71xx_gpio.h b/package/boot/uboot-ar71xx/files/include/asm-mips/ar71xx_gpio.h
new file mode 100644
index 0000000..c92364b
--- /dev/null
+++ b/package/boot/uboot-ar71xx/files/include/asm-mips/ar71xx_gpio.h
@@ -0,0 +1,65 @@
+/*
+ * (C) Copyright 2010
+ * Michael Kurz <michi.kurz@googlemail.com>.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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 of
+ * the License, 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef _AR71XX_GPIO_H
+#define _AR71XX_GPIO_H
+
+#include <common.h>
+#include <asm/ar71xx.h>
+
+static inline void ar71xx_setpin(uint8_t pin, uint8_t state)
+{
+ uint32_t reg = readl(KSEG1ADDR(AR71XX_GPIO_BASE + GPIO_REG_OUT));
+
+ if (state != 0) {
+ reg |= (1 << pin);
+ } else {
+ reg &= ~(1 << pin);
+ }
+
+ writel(reg, KSEG1ADDR(AR71XX_GPIO_BASE + GPIO_REG_OUT));
+ readl(KSEG1ADDR(AR71XX_GPIO_BASE + GPIO_REG_OUT));
+}
+
+static inline uint32_t ar71xx_getpin(uint8_t pin)
+{
+ uint32_t reg = readl(KSEG1ADDR(AR71XX_GPIO_BASE + GPIO_REG_IN));
+ return (((reg & (1 << pin)) != 0) ? 1 : 0);
+}
+
+static inline void ar71xx_setpindir(uint8_t pin, uint8_t direction)
+{
+ uint32_t reg = readl(KSEG1ADDR(AR71XX_GPIO_BASE + GPIO_REG_OE));
+
+ if (direction != 0) {
+ reg |= (1 << pin);
+ } else {
+ reg &= ~(1 << pin);
+ }
+
+ writel(reg, KSEG1ADDR(AR71XX_GPIO_BASE + GPIO_REG_OE));
+ readl(KSEG1ADDR(AR71XX_GPIO_BASE + GPIO_REG_OE));
+}
+
+
+#endif /* AR71XX_GPIO_H */
diff --git a/package/boot/uboot-ar71xx/files/include/configs/.svn/entries b/package/boot/uboot-ar71xx/files/include/configs/.svn/entries
new file mode 100644
index 0000000..240eb56
--- /dev/null
+++ b/package/boot/uboot-ar71xx/files/include/configs/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/uboot-ar71xx/files/include/configs
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+nbg460n.h
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+85e62ebf6a2d7d9a9fb3a787bb7e0ec1
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4386
+
diff --git a/package/boot/uboot-ar71xx/files/include/configs/.svn/prop-base/nbg460n.h.svn-base b/package/boot/uboot-ar71xx/files/include/configs/.svn/prop-base/nbg460n.h.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/boot/uboot-ar71xx/files/include/configs/.svn/prop-base/nbg460n.h.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/boot/uboot-ar71xx/files/include/configs/.svn/text-base/nbg460n.h.svn-base b/package/boot/uboot-ar71xx/files/include/configs/.svn/text-base/nbg460n.h.svn-base
new file mode 100644
index 0000000..dd9b4c3
--- /dev/null
+++ b/package/boot/uboot-ar71xx/files/include/configs/.svn/text-base/nbg460n.h.svn-base
@@ -0,0 +1,136 @@
+/*
+ * (C) Copyright 2010
+ * Michael Kurz <michi.kurz@googlemail.com>.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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 of
+ * the License, 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+/* This file contains the configuration parameters for the zyxel nbg460n board. */
+
+#ifndef _NBG460N_CONFIG_H
+#define _NBG460N_CONFIG_H
+
+#define CONFIG_MIPS32 1 /* MIPS32 CPU core */
+#define CONFIG_AR71XX 1
+#define CONFIG_AR91XX 1
+#define CONFIG_SYS_HZ 1000
+#define CONFIG_SYS_MIPS_TIMER_FREQ (400000000/2)
+
+/* Cache Configuration */
+#define CONFIG_SYS_DCACHE_SIZE 32768
+#define CONFIG_SYS_ICACHE_SIZE 65536
+#define CONFIG_SYS_CACHELINE_SIZE 32
+/* Cache lock for stack */
+#define CONFIG_SYS_INIT_SP_OFFSET 0x1000
+
+#define CONFIG_SYS_MONITOR_BASE (TEXT_BASE)
+
+#define CONFIG_BAUDRATE 115200
+#define CONFIG_SYS_BAUDRATE_TABLE {115200}
+
+#define CONFIG_MISC_INIT_R
+
+/* SPI-Flash support */
+#define CONFIG_SPI_FLASH
+#define CONFIG_AR71XX_SPI
+#define CONFIG_SPI_FLASH_MACRONIX
+#define CONFIG_SF_DEFAULT_HZ 25000000
+
+#define CONFIG_ENV_SPI_MAX_HZ 25000000
+#define CONFIG_ENV_SPI_BUS 0
+#define CONFIG_ENV_SPI_CS 0
+
+#define CONFIG_ENV_IS_IN_SPI_FLASH
+#define CONFIG_ENV_ADDR 0xbfc20000
+#define CONFIG_ENV_OFFSET 0x20000
+#define CONFIG_ENV_SIZE 0x01000
+#define CONFIG_ENV_SECT_SIZE 0x10000
+#define CONFIG_SYS_MAX_FLASH_BANKS 1
+#define CONFIG_SYS_MAX_FLASH_SECT 64
+#define CONFIG_SYS_FLASH_BASE 0xbfc00000
+
+/* Net support */
+#define CONFIG_ETHADDR_ADDR 0xbfc0fff8
+#define CONFIG_SYS_RX_ETH_BUFFER 16
+#define CONFIG_AG71XX
+#define CONFIG_AG71XX_PORTS { 1, 1 }
+#define CONFIG_AG71XX_MII0_IIF MII0_CTRL_IF_RGMII
+#define CONFIG_AG71XX_MII1_IIF MII1_CTRL_IF_RGMII
+#define CONFIG_NET_MULTI
+#define CONFIG_IPADDR 192.168.1.254
+#define CONFIG_SERVERIP 192.168.1.42
+
+/* Switch support */
+#define CONFIG_MII
+#define CONFIG_RTL8366_MII
+#define RTL8366_PIN_SDA 16
+#define RTL8366_PIN_SCK 18
+#define MII_GPIOINCLUDE <asm/ar71xx_gpio.h>
+#define MII_SETSDA(x) ar71xx_setpin(RTL8366_PIN_SDA, x)
+#define MII_GETSDA ar71xx_getpin(RTL8366_PIN_SDA)
+#define MII_SETSCK(x) ar71xx_setpin(RTL8366_PIN_SCK, x)
+#define MII_SDAINPUT ar71xx_setpindir(RTL8366_PIN_SDA, 0)
+#define MII_SDAOUTPUT ar71xx_setpindir(RTL8366_PIN_SDA, 1)
+#define MII_SCKINPUT ar71xx_setpindir(RTL8366_PIN_SCK, 0)
+#define MII_SCKOUTPUT ar71xx_setpindir(RTL8366_PIN_SCK, 1)
+
+#define CONFIG_BOOTDELAY 3
+#define CONFIG_BOOTARGS "console=ttyS0,115200 rootfstype==squashfs,jffs2 noinitrd machtype=NBG460N"
+#define CONFIG_BOOTCOMMAND "bootm 0xbfc70000"
+#define CONFIG_LZMA
+
+
+/* Commands */
+#define CONFIG_SYS_NO_FLASH
+#include <config_cmd_default.h>
+#undef CONFIG_CMD_BDI
+#undef CONFIG_CMD_FPGA
+#undef CONFIG_CMD_IMI
+#undef CONFIG_CMD_IMLS
+#undef CONFIG_CMD_LOADS
+#define CONFIG_CMD_SF
+#define CONFIG_CMD_MII
+#define CONFIG_CMD_PING
+#define CONFIG_CMD_DHCP
+#define CONFIG_CMD_SPI
+
+/* Miscellaneous configurable options */
+#define CONFIG_SYS_PROMPT "U-Boot> "
+#define CONFIG_SYS_CBSIZE 256
+#define CONFIG_SYS_MAXARGS 16
+#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE + sizeof(CONFIG_SYS_PROMPT) + 16)
+#define CONFIG_SYS_LONGHELP 1
+#define CONFIG_CMDLINE_EDITING 1
+#define CONFIG_AUTO_COMPLETE
+#define CONFIG_SYS_HUSH_PARSER
+#define CONFIG_SYS_PROMPT_HUSH_PS2 "> "
+
+/* Size of malloc() pool */
+#define CONFIG_SYS_MALLOC_LEN ROUND(3 * 0x10000 + 128*1024, 0x1000)
+#define CONFIG_SYS_GBL_DATA_SIZE 128 /* 128 bytes for initial data */
+
+#define CONFIG_SYS_BOOTPARAMS_LEN 128*1024
+
+#define CONFIG_SYS_SDRAM_BASE 0x80000000 /* Cached addr */
+#define CONFIG_SYS_LOAD_ADDR 0x80060000 /* default load address */
+
+#define CONFIG_SYS_MEMTEST_START 0x80000800
+#define CONFIG_SYS_MEMTEST_END 0x81E00000
+
+#endif /* _NBG460N_CONFIG_H */
diff --git a/package/boot/uboot-ar71xx/files/include/configs/nbg460n.h b/package/boot/uboot-ar71xx/files/include/configs/nbg460n.h
new file mode 100644
index 0000000..dd9b4c3
--- /dev/null
+++ b/package/boot/uboot-ar71xx/files/include/configs/nbg460n.h
@@ -0,0 +1,136 @@
+/*
+ * (C) Copyright 2010
+ * Michael Kurz <michi.kurz@googlemail.com>.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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 of
+ * the License, 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+/* This file contains the configuration parameters for the zyxel nbg460n board. */
+
+#ifndef _NBG460N_CONFIG_H
+#define _NBG460N_CONFIG_H
+
+#define CONFIG_MIPS32 1 /* MIPS32 CPU core */
+#define CONFIG_AR71XX 1
+#define CONFIG_AR91XX 1
+#define CONFIG_SYS_HZ 1000
+#define CONFIG_SYS_MIPS_TIMER_FREQ (400000000/2)
+
+/* Cache Configuration */
+#define CONFIG_SYS_DCACHE_SIZE 32768
+#define CONFIG_SYS_ICACHE_SIZE 65536
+#define CONFIG_SYS_CACHELINE_SIZE 32
+/* Cache lock for stack */
+#define CONFIG_SYS_INIT_SP_OFFSET 0x1000
+
+#define CONFIG_SYS_MONITOR_BASE (TEXT_BASE)
+
+#define CONFIG_BAUDRATE 115200
+#define CONFIG_SYS_BAUDRATE_TABLE {115200}
+
+#define CONFIG_MISC_INIT_R
+
+/* SPI-Flash support */
+#define CONFIG_SPI_FLASH
+#define CONFIG_AR71XX_SPI
+#define CONFIG_SPI_FLASH_MACRONIX
+#define CONFIG_SF_DEFAULT_HZ 25000000
+
+#define CONFIG_ENV_SPI_MAX_HZ 25000000
+#define CONFIG_ENV_SPI_BUS 0
+#define CONFIG_ENV_SPI_CS 0
+
+#define CONFIG_ENV_IS_IN_SPI_FLASH
+#define CONFIG_ENV_ADDR 0xbfc20000
+#define CONFIG_ENV_OFFSET 0x20000
+#define CONFIG_ENV_SIZE 0x01000
+#define CONFIG_ENV_SECT_SIZE 0x10000
+#define CONFIG_SYS_MAX_FLASH_BANKS 1
+#define CONFIG_SYS_MAX_FLASH_SECT 64
+#define CONFIG_SYS_FLASH_BASE 0xbfc00000
+
+/* Net support */
+#define CONFIG_ETHADDR_ADDR 0xbfc0fff8
+#define CONFIG_SYS_RX_ETH_BUFFER 16
+#define CONFIG_AG71XX
+#define CONFIG_AG71XX_PORTS { 1, 1 }
+#define CONFIG_AG71XX_MII0_IIF MII0_CTRL_IF_RGMII
+#define CONFIG_AG71XX_MII1_IIF MII1_CTRL_IF_RGMII
+#define CONFIG_NET_MULTI
+#define CONFIG_IPADDR 192.168.1.254
+#define CONFIG_SERVERIP 192.168.1.42
+
+/* Switch support */
+#define CONFIG_MII
+#define CONFIG_RTL8366_MII
+#define RTL8366_PIN_SDA 16
+#define RTL8366_PIN_SCK 18
+#define MII_GPIOINCLUDE <asm/ar71xx_gpio.h>
+#define MII_SETSDA(x) ar71xx_setpin(RTL8366_PIN_SDA, x)
+#define MII_GETSDA ar71xx_getpin(RTL8366_PIN_SDA)
+#define MII_SETSCK(x) ar71xx_setpin(RTL8366_PIN_SCK, x)
+#define MII_SDAINPUT ar71xx_setpindir(RTL8366_PIN_SDA, 0)
+#define MII_SDAOUTPUT ar71xx_setpindir(RTL8366_PIN_SDA, 1)
+#define MII_SCKINPUT ar71xx_setpindir(RTL8366_PIN_SCK, 0)
+#define MII_SCKOUTPUT ar71xx_setpindir(RTL8366_PIN_SCK, 1)
+
+#define CONFIG_BOOTDELAY 3
+#define CONFIG_BOOTARGS "console=ttyS0,115200 rootfstype==squashfs,jffs2 noinitrd machtype=NBG460N"
+#define CONFIG_BOOTCOMMAND "bootm 0xbfc70000"
+#define CONFIG_LZMA
+
+
+/* Commands */
+#define CONFIG_SYS_NO_FLASH
+#include <config_cmd_default.h>
+#undef CONFIG_CMD_BDI
+#undef CONFIG_CMD_FPGA
+#undef CONFIG_CMD_IMI
+#undef CONFIG_CMD_IMLS
+#undef CONFIG_CMD_LOADS
+#define CONFIG_CMD_SF
+#define CONFIG_CMD_MII
+#define CONFIG_CMD_PING
+#define CONFIG_CMD_DHCP
+#define CONFIG_CMD_SPI
+
+/* Miscellaneous configurable options */
+#define CONFIG_SYS_PROMPT "U-Boot> "
+#define CONFIG_SYS_CBSIZE 256
+#define CONFIG_SYS_MAXARGS 16
+#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE + sizeof(CONFIG_SYS_PROMPT) + 16)
+#define CONFIG_SYS_LONGHELP 1
+#define CONFIG_CMDLINE_EDITING 1
+#define CONFIG_AUTO_COMPLETE
+#define CONFIG_SYS_HUSH_PARSER
+#define CONFIG_SYS_PROMPT_HUSH_PS2 "> "
+
+/* Size of malloc() pool */
+#define CONFIG_SYS_MALLOC_LEN ROUND(3 * 0x10000 + 128*1024, 0x1000)
+#define CONFIG_SYS_GBL_DATA_SIZE 128 /* 128 bytes for initial data */
+
+#define CONFIG_SYS_BOOTPARAMS_LEN 128*1024
+
+#define CONFIG_SYS_SDRAM_BASE 0x80000000 /* Cached addr */
+#define CONFIG_SYS_LOAD_ADDR 0x80060000 /* default load address */
+
+#define CONFIG_SYS_MEMTEST_START 0x80000800
+#define CONFIG_SYS_MEMTEST_END 0x81E00000
+
+#endif /* _NBG460N_CONFIG_H */
diff --git a/package/boot/uboot-ar71xx/patches/.svn/entries b/package/boot/uboot-ar71xx/patches/.svn/entries
new file mode 100644
index 0000000..f3d8b90
--- /dev/null
+++ b/package/boot/uboot-ar71xx/patches/.svn/entries
@@ -0,0 +1,266 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/uboot-ar71xx/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+002-ar71xx-spi.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+c93e74225de2389588d6c1b4d30fc2d3
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+458
+
+010-enet-ag71xx.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+ca96c86b1b5a1e69d9574118712b38de
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1055
+
+021-darwin_compat.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+4bd7c68770a42e7fa70cdf0e902d99f8
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+881
+
+001-ar71xx.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+2dc4f04e60b981ffe9ad13993f924f23
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1243
+
+020-freebsd-compat.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+690ab49ce8bb8ad88ce2a16976f89b5e
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+313
+
+011-switch-rtl8366sr.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+d85aa0315186eeac81cbba96f5c83314
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1139
+
+022-getline_backport.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+88d64f3c9686f9d3de6a3d4ae2f4cafc
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+436
+
diff --git a/package/boot/uboot-ar71xx/patches/.svn/text-base/001-ar71xx.patch.svn-base b/package/boot/uboot-ar71xx/patches/.svn/text-base/001-ar71xx.patch.svn-base
new file mode 100644
index 0000000..409f67a
--- /dev/null
+++ b/package/boot/uboot-ar71xx/patches/.svn/text-base/001-ar71xx.patch.svn-base
@@ -0,0 +1,28 @@
+diff -ur u-boot-2010.03/cpu/mips/Makefile u-boot-nbg/cpu/mips/Makefile
+--- u-boot-2010.03/cpu/mips/Makefile 2010-03-31 23:54:39.000000000 +0200
++++ u-boot-nbg/cpu/mips/Makefile 2010-04-15 18:58:01.000000000 +0200
+@@ -33,6 +33,7 @@
+ COBJS-$(CONFIG_INCA_IP) += asc_serial.o incaip_clock.o
+ COBJS-$(CONFIG_PURPLE) += asc_serial.o
+ COBJS-$(CONFIG_SOC_AU1X00) += au1x00_eth.o au1x00_serial.o au1x00_usb_ohci.o
++COBJS-$(CONFIG_AR71XX) += ar71xx_serial.o
+
+ SRCS := $(START:.o=.S) $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c)
+ OBJS := $(addprefix $(obj),$(SOBJS-y) $(COBJS-y))
+diff -ur u-boot-2010.03/Makefile u-boot-nbg/Makefile
+--- u-boot-2010.03/Makefile 2010-03-31 23:54:39.000000000 +0200
++++ u-boot-nbg/Makefile 2010-04-11 23:31:29.000000000 +0200
+@@ -3455,6 +3455,13 @@
+ @$(MKCONFIG) -a qemu-mips mips mips qemu-mips
+
+ #########################################################################
++## MIPS32 AR71XX (24K)
++#########################################################################
++
++nbg460n_550n_550nh_config : unconfig
++ @$(MKCONFIG) -a nbg460n mips mips nbg460n zyxel
++
++#########################################################################
+ ## MIPS64 5Kc
+ #########################################################################
+
diff --git a/package/boot/uboot-ar71xx/patches/.svn/text-base/002-ar71xx-spi.patch.svn-base b/package/boot/uboot-ar71xx/patches/.svn/text-base/002-ar71xx-spi.patch.svn-base
new file mode 100644
index 0000000..2bb1ba2
--- /dev/null
+++ b/package/boot/uboot-ar71xx/patches/.svn/text-base/002-ar71xx-spi.patch.svn-base
@@ -0,0 +1,11 @@
+diff -ur u-boot-2010.03/drivers/spi/Makefile u-boot-nbg/drivers/spi/Makefile
+--- u-boot-2010.03/drivers/spi/Makefile 2010-03-31 23:54:39.000000000 +0200
++++ u-boot-nbg/drivers/spi/Makefile 2010-04-15 19:31:27.000000000 +0200
+@@ -25,6 +25,7 @@
+
+ LIB := $(obj)libspi.a
+
++COBJS-$(CONFIG_AR71XX_SPI) += ar71xx_spi.o
+ COBJS-$(CONFIG_ATMEL_DATAFLASH_SPI) += atmel_dataflash_spi.o
+ COBJS-$(CONFIG_ATMEL_SPI) += atmel_spi.o
+ COBJS-$(CONFIG_BFIN_SPI) += bfin_spi.o
diff --git a/package/boot/uboot-ar71xx/patches/.svn/text-base/010-enet-ag71xx.patch.svn-base b/package/boot/uboot-ar71xx/patches/.svn/text-base/010-enet-ag71xx.patch.svn-base
new file mode 100644
index 0000000..ee90e32
--- /dev/null
+++ b/package/boot/uboot-ar71xx/patches/.svn/text-base/010-enet-ag71xx.patch.svn-base
@@ -0,0 +1,22 @@
+diff -ur u-boot-2010.03/drivers/net/Makefile u-boot-nbg/drivers/net/Makefile
+--- u-boot-2010.03/drivers/net/Makefile 2010-03-31 23:54:39.000000000 +0200
++++ u-boot-nbg/drivers/net/Makefile 2010-04-19 23:30:01.000000000 +0200
+@@ -27,6 +27,7 @@
+
+ COBJS-$(CONFIG_DRIVER_3C589) += 3c589.o
+ COBJS-$(CONFIG_PPC4xx_EMAC) += 4xx_enet.o
++COBJS-$(CONFIG_AG71XX) += ag71xx.o
+ COBJS-$(CONFIG_DRIVER_AT91EMAC) += at91_emac.o
+ COBJS-$(CONFIG_DRIVER_AX88180) += ax88180.o
+ COBJS-$(CONFIG_BCM570x) += bcm570x.o bcm570x_autoneg.o 5701rls.o
+diff -ur u-boot-2010.03/include/netdev.h u-boot-nbg/include/netdev.h
+--- u-boot-2010.03/include/netdev.h 2010-03-31 23:54:39.000000000 +0200
++++ u-boot-nbg/include/netdev.h 2010-05-02 11:30:58.000000000 +0200
+@@ -42,6 +42,7 @@
+
+ /* Driver initialization prototypes */
+ int au1x00_enet_initialize(bd_t*);
++int ag71xx_register(bd_t * bis, char *phyname[], u16 phyid[], u16 phyfixed[]);
+ int at91emac_register(bd_t *bis, unsigned long iobase);
+ int bfin_EMAC_initialize(bd_t *bis);
+ int cs8900_initialize(u8 dev_num, int base_addr);
diff --git a/package/boot/uboot-ar71xx/patches/.svn/text-base/011-switch-rtl8366sr.patch.svn-base b/package/boot/uboot-ar71xx/patches/.svn/text-base/011-switch-rtl8366sr.patch.svn-base
new file mode 100644
index 0000000..5d2ba41
--- /dev/null
+++ b/package/boot/uboot-ar71xx/patches/.svn/text-base/011-switch-rtl8366sr.patch.svn-base
@@ -0,0 +1,28 @@
+diff -ur u-boot-2010.03/drivers/net/Makefile u-boot-nbg/drivers/net/Makefile
+--- u-boot-2010.03/drivers/net/Makefile 2010-03-31 23:54:39.000000000 +0200
++++ u-boot-nbg/drivers/net/Makefile 2010-04-19 23:30:01.000000000 +0200
+@@ -65,6 +65,7 @@
+ COBJS-$(CONFIG_DRIVER_RTL8019) += rtl8019.o
+ COBJS-$(CONFIG_RTL8139) += rtl8139.o
+ COBJS-$(CONFIG_RTL8169) += rtl8169.o
++COBJS-$(CONFIG_RTL8366_MII) += phy/rtl8366_mii.o
+ COBJS-$(CONFIG_DRIVER_S3C4510_ETH) += s3c4510b_eth.o
+ COBJS-$(CONFIG_SH_ETHER) += sh_eth.o
+ COBJS-$(CONFIG_SMC91111) += smc91111.o
+diff -ur u-boot-2010.03/include/netdev.h u-boot-nbg/include/netdev.h
+--- u-boot-2010.03/include/netdev.h 2010-03-31 23:54:39.000000000 +0200
++++ u-boot-nbg/include/netdev.h 2010-05-02 11:30:58.000000000 +0200
+@@ -175,5 +175,13 @@
+
+ int mv88e61xx_switch_initialize(struct mv88e61xx_config *swconfig);
+ #endif /* CONFIG_MV88E61XX_SWITCH */
++
++#if defined(CONFIG_RTL8366_MII)
++#define RTL8366_DEVNAME "rtl8366"
++#define RTL8366_WANPHY_ID 4
++#define RTL8366_LANPHY_ID -1
++int rtl8366_mii_register(bd_t *bis);
++int rtl8366s_initialize(void);
++#endif
+
+ #endif /* _NETDEV_H_ */
diff --git a/package/boot/uboot-ar71xx/patches/.svn/text-base/020-freebsd-compat.patch.svn-base b/package/boot/uboot-ar71xx/patches/.svn/text-base/020-freebsd-compat.patch.svn-base
new file mode 100644
index 0000000..fee0669
--- /dev/null
+++ b/package/boot/uboot-ar71xx/patches/.svn/text-base/020-freebsd-compat.patch.svn-base
@@ -0,0 +1,11 @@
+--- a/include/compiler.h
++++ b/include/compiler.h
+@@ -46,7 +46,7 @@ extern int errno;
+ #ifdef __linux__
+ # include <endian.h>
+ # include <byteswap.h>
+-#elif defined(__MACH__)
++#elif defined(__MACH__) || defined(__FreeBSD__)
+ # include <machine/endian.h>
+ typedef unsigned long ulong;
+ typedef unsigned int uint;
diff --git a/package/boot/uboot-ar71xx/patches/.svn/text-base/021-darwin_compat.patch.svn-base b/package/boot/uboot-ar71xx/patches/.svn/text-base/021-darwin_compat.patch.svn-base
new file mode 100644
index 0000000..dde83d4
--- /dev/null
+++ b/package/boot/uboot-ar71xx/patches/.svn/text-base/021-darwin_compat.patch.svn-base
@@ -0,0 +1,23 @@
+--- a/config.mk
++++ b/config.mk
+@@ -64,9 +64,17 @@ HOSTSTRIP = strip
+ #
+
+ ifeq ($(HOSTOS),darwin)
+-HOSTCC = cc
+-HOSTCFLAGS += -traditional-cpp
+-HOSTLDFLAGS += -multiply_defined suppress
++#get the major and minor product version (e.g. '10' and '6' for Snow Leopard)
++DARWIN_MAJOR_VERSION = $(shell sw_vers -productVersion | cut -f 1 -d '.')
++DARWIN_MINOR_VERSION = $(shell sw_vers -productVersion | cut -f 2 -d '.')
++
++before-snow-leopard = $(shell if [ $(DARWIN_MAJOR_VERSION) -le 10 -a \
++ $(DARWIN_MINOR_VERSION) -le 5 ] ; then echo "$(1)"; else echo "$(2)"; fi ;)
++
++# Snow Leopards build environment has no longer restrictions as described above
++HOSTCC = $(call before-snow-leopard, "cc", "gcc")
++HOSTCFLAGS += $(call before-snow-leopard, "-traditional-cpp")
++HOSTLDFLAGS += $(call before-snow-leopard, "-multiply_defined suppress")
+ else
+ HOSTCC = gcc
+ endif
diff --git a/package/boot/uboot-ar71xx/patches/.svn/text-base/022-getline_backport.patch.svn-base b/package/boot/uboot-ar71xx/patches/.svn/text-base/022-getline_backport.patch.svn-base
new file mode 100644
index 0000000..2ce2b61
--- /dev/null
+++ b/package/boot/uboot-ar71xx/patches/.svn/text-base/022-getline_backport.patch.svn-base
@@ -0,0 +1,21 @@
+--- a/tools/os_support.c
++++ b/tools/os_support.c
+@@ -23,6 +23,6 @@
+ #ifdef __MINGW32__
+ #include "mingw_support.c"
+ #endif
+-#ifdef __APPLE__
++#if defined(__APPLE__) && __DARWIN_C_LEVEL < 200809L
+ #include "getline.c"
+ #endif
+--- a/tools/os_support.h
++++ b/tools/os_support.h
+@@ -28,7 +28,7 @@
+ #include "mingw_support.h"
+ #endif
+
+-#ifdef __APPLE__
++#if defined(__APPLE__) && __DARWIN_C_LEVEL < 200809L
+ #include "getline.h"
+ #endif
+
diff --git a/package/boot/uboot-ar71xx/patches/001-ar71xx.patch b/package/boot/uboot-ar71xx/patches/001-ar71xx.patch
new file mode 100644
index 0000000..409f67a
--- /dev/null
+++ b/package/boot/uboot-ar71xx/patches/001-ar71xx.patch
@@ -0,0 +1,28 @@
+diff -ur u-boot-2010.03/cpu/mips/Makefile u-boot-nbg/cpu/mips/Makefile
+--- u-boot-2010.03/cpu/mips/Makefile 2010-03-31 23:54:39.000000000 +0200
++++ u-boot-nbg/cpu/mips/Makefile 2010-04-15 18:58:01.000000000 +0200
+@@ -33,6 +33,7 @@
+ COBJS-$(CONFIG_INCA_IP) += asc_serial.o incaip_clock.o
+ COBJS-$(CONFIG_PURPLE) += asc_serial.o
+ COBJS-$(CONFIG_SOC_AU1X00) += au1x00_eth.o au1x00_serial.o au1x00_usb_ohci.o
++COBJS-$(CONFIG_AR71XX) += ar71xx_serial.o
+
+ SRCS := $(START:.o=.S) $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c)
+ OBJS := $(addprefix $(obj),$(SOBJS-y) $(COBJS-y))
+diff -ur u-boot-2010.03/Makefile u-boot-nbg/Makefile
+--- u-boot-2010.03/Makefile 2010-03-31 23:54:39.000000000 +0200
++++ u-boot-nbg/Makefile 2010-04-11 23:31:29.000000000 +0200
+@@ -3455,6 +3455,13 @@
+ @$(MKCONFIG) -a qemu-mips mips mips qemu-mips
+
+ #########################################################################
++## MIPS32 AR71XX (24K)
++#########################################################################
++
++nbg460n_550n_550nh_config : unconfig
++ @$(MKCONFIG) -a nbg460n mips mips nbg460n zyxel
++
++#########################################################################
+ ## MIPS64 5Kc
+ #########################################################################
+
diff --git a/package/boot/uboot-ar71xx/patches/002-ar71xx-spi.patch b/package/boot/uboot-ar71xx/patches/002-ar71xx-spi.patch
new file mode 100644
index 0000000..2bb1ba2
--- /dev/null
+++ b/package/boot/uboot-ar71xx/patches/002-ar71xx-spi.patch
@@ -0,0 +1,11 @@
+diff -ur u-boot-2010.03/drivers/spi/Makefile u-boot-nbg/drivers/spi/Makefile
+--- u-boot-2010.03/drivers/spi/Makefile 2010-03-31 23:54:39.000000000 +0200
++++ u-boot-nbg/drivers/spi/Makefile 2010-04-15 19:31:27.000000000 +0200
+@@ -25,6 +25,7 @@
+
+ LIB := $(obj)libspi.a
+
++COBJS-$(CONFIG_AR71XX_SPI) += ar71xx_spi.o
+ COBJS-$(CONFIG_ATMEL_DATAFLASH_SPI) += atmel_dataflash_spi.o
+ COBJS-$(CONFIG_ATMEL_SPI) += atmel_spi.o
+ COBJS-$(CONFIG_BFIN_SPI) += bfin_spi.o
diff --git a/package/boot/uboot-ar71xx/patches/010-enet-ag71xx.patch b/package/boot/uboot-ar71xx/patches/010-enet-ag71xx.patch
new file mode 100644
index 0000000..ee90e32
--- /dev/null
+++ b/package/boot/uboot-ar71xx/patches/010-enet-ag71xx.patch
@@ -0,0 +1,22 @@
+diff -ur u-boot-2010.03/drivers/net/Makefile u-boot-nbg/drivers/net/Makefile
+--- u-boot-2010.03/drivers/net/Makefile 2010-03-31 23:54:39.000000000 +0200
++++ u-boot-nbg/drivers/net/Makefile 2010-04-19 23:30:01.000000000 +0200
+@@ -27,6 +27,7 @@
+
+ COBJS-$(CONFIG_DRIVER_3C589) += 3c589.o
+ COBJS-$(CONFIG_PPC4xx_EMAC) += 4xx_enet.o
++COBJS-$(CONFIG_AG71XX) += ag71xx.o
+ COBJS-$(CONFIG_DRIVER_AT91EMAC) += at91_emac.o
+ COBJS-$(CONFIG_DRIVER_AX88180) += ax88180.o
+ COBJS-$(CONFIG_BCM570x) += bcm570x.o bcm570x_autoneg.o 5701rls.o
+diff -ur u-boot-2010.03/include/netdev.h u-boot-nbg/include/netdev.h
+--- u-boot-2010.03/include/netdev.h 2010-03-31 23:54:39.000000000 +0200
++++ u-boot-nbg/include/netdev.h 2010-05-02 11:30:58.000000000 +0200
+@@ -42,6 +42,7 @@
+
+ /* Driver initialization prototypes */
+ int au1x00_enet_initialize(bd_t*);
++int ag71xx_register(bd_t * bis, char *phyname[], u16 phyid[], u16 phyfixed[]);
+ int at91emac_register(bd_t *bis, unsigned long iobase);
+ int bfin_EMAC_initialize(bd_t *bis);
+ int cs8900_initialize(u8 dev_num, int base_addr);
diff --git a/package/boot/uboot-ar71xx/patches/011-switch-rtl8366sr.patch b/package/boot/uboot-ar71xx/patches/011-switch-rtl8366sr.patch
new file mode 100644
index 0000000..5d2ba41
--- /dev/null
+++ b/package/boot/uboot-ar71xx/patches/011-switch-rtl8366sr.patch
@@ -0,0 +1,28 @@
+diff -ur u-boot-2010.03/drivers/net/Makefile u-boot-nbg/drivers/net/Makefile
+--- u-boot-2010.03/drivers/net/Makefile 2010-03-31 23:54:39.000000000 +0200
++++ u-boot-nbg/drivers/net/Makefile 2010-04-19 23:30:01.000000000 +0200
+@@ -65,6 +65,7 @@
+ COBJS-$(CONFIG_DRIVER_RTL8019) += rtl8019.o
+ COBJS-$(CONFIG_RTL8139) += rtl8139.o
+ COBJS-$(CONFIG_RTL8169) += rtl8169.o
++COBJS-$(CONFIG_RTL8366_MII) += phy/rtl8366_mii.o
+ COBJS-$(CONFIG_DRIVER_S3C4510_ETH) += s3c4510b_eth.o
+ COBJS-$(CONFIG_SH_ETHER) += sh_eth.o
+ COBJS-$(CONFIG_SMC91111) += smc91111.o
+diff -ur u-boot-2010.03/include/netdev.h u-boot-nbg/include/netdev.h
+--- u-boot-2010.03/include/netdev.h 2010-03-31 23:54:39.000000000 +0200
++++ u-boot-nbg/include/netdev.h 2010-05-02 11:30:58.000000000 +0200
+@@ -175,5 +175,13 @@
+
+ int mv88e61xx_switch_initialize(struct mv88e61xx_config *swconfig);
+ #endif /* CONFIG_MV88E61XX_SWITCH */
++
++#if defined(CONFIG_RTL8366_MII)
++#define RTL8366_DEVNAME "rtl8366"
++#define RTL8366_WANPHY_ID 4
++#define RTL8366_LANPHY_ID -1
++int rtl8366_mii_register(bd_t *bis);
++int rtl8366s_initialize(void);
++#endif
+
+ #endif /* _NETDEV_H_ */
diff --git a/package/boot/uboot-ar71xx/patches/020-freebsd-compat.patch b/package/boot/uboot-ar71xx/patches/020-freebsd-compat.patch
new file mode 100644
index 0000000..fee0669
--- /dev/null
+++ b/package/boot/uboot-ar71xx/patches/020-freebsd-compat.patch
@@ -0,0 +1,11 @@
+--- a/include/compiler.h
++++ b/include/compiler.h
+@@ -46,7 +46,7 @@ extern int errno;
+ #ifdef __linux__
+ # include <endian.h>
+ # include <byteswap.h>
+-#elif defined(__MACH__)
++#elif defined(__MACH__) || defined(__FreeBSD__)
+ # include <machine/endian.h>
+ typedef unsigned long ulong;
+ typedef unsigned int uint;
diff --git a/package/boot/uboot-ar71xx/patches/021-darwin_compat.patch b/package/boot/uboot-ar71xx/patches/021-darwin_compat.patch
new file mode 100644
index 0000000..dde83d4
--- /dev/null
+++ b/package/boot/uboot-ar71xx/patches/021-darwin_compat.patch
@@ -0,0 +1,23 @@
+--- a/config.mk
++++ b/config.mk
+@@ -64,9 +64,17 @@ HOSTSTRIP = strip
+ #
+
+ ifeq ($(HOSTOS),darwin)
+-HOSTCC = cc
+-HOSTCFLAGS += -traditional-cpp
+-HOSTLDFLAGS += -multiply_defined suppress
++#get the major and minor product version (e.g. '10' and '6' for Snow Leopard)
++DARWIN_MAJOR_VERSION = $(shell sw_vers -productVersion | cut -f 1 -d '.')
++DARWIN_MINOR_VERSION = $(shell sw_vers -productVersion | cut -f 2 -d '.')
++
++before-snow-leopard = $(shell if [ $(DARWIN_MAJOR_VERSION) -le 10 -a \
++ $(DARWIN_MINOR_VERSION) -le 5 ] ; then echo "$(1)"; else echo "$(2)"; fi ;)
++
++# Snow Leopards build environment has no longer restrictions as described above
++HOSTCC = $(call before-snow-leopard, "cc", "gcc")
++HOSTCFLAGS += $(call before-snow-leopard, "-traditional-cpp")
++HOSTLDFLAGS += $(call before-snow-leopard, "-multiply_defined suppress")
+ else
+ HOSTCC = gcc
+ endif
diff --git a/package/boot/uboot-ar71xx/patches/022-getline_backport.patch b/package/boot/uboot-ar71xx/patches/022-getline_backport.patch
new file mode 100644
index 0000000..2ce2b61
--- /dev/null
+++ b/package/boot/uboot-ar71xx/patches/022-getline_backport.patch
@@ -0,0 +1,21 @@
+--- a/tools/os_support.c
++++ b/tools/os_support.c
+@@ -23,6 +23,6 @@
+ #ifdef __MINGW32__
+ #include "mingw_support.c"
+ #endif
+-#ifdef __APPLE__
++#if defined(__APPLE__) && __DARWIN_C_LEVEL < 200809L
+ #include "getline.c"
+ #endif
+--- a/tools/os_support.h
++++ b/tools/os_support.h
+@@ -28,7 +28,7 @@
+ #include "mingw_support.h"
+ #endif
+
+-#ifdef __APPLE__
++#if defined(__APPLE__) && __DARWIN_C_LEVEL < 200809L
+ #include "getline.h"
+ #endif
+
diff --git a/package/boot/uboot-envtools/.svn/entries b/package/boot/uboot-envtools/.svn/entries
new file mode 100644
index 0000000..dd03750
--- /dev/null
+++ b/package/boot/uboot-envtools/.svn/entries
@@ -0,0 +1,68 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/uboot-envtools
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-15T01:36:53.833391Z
+36033
+luka
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+files
+dir
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+c912a9069ac7b571a308a7eb4a9a1dc4
+2013-03-15T01:36:53.833391Z
+36033
+luka
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2018
+
diff --git a/package/boot/uboot-envtools/.svn/text-base/Makefile.svn-base b/package/boot/uboot-envtools/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..55aaf88
--- /dev/null
+++ b/package/boot/uboot-envtools/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,74 @@
+#
+# Copyright (C) 2006-2013 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=uboot-envtools
+PKG_DISTNAME:=u-boot
+PKG_VERSION:=2013.01.01
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_DISTNAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=ftp://ftp.denx.de/pub/u-boot
+PKG_MD5SUM:=73939f78606f89a1775c7e9acb2ca617
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/u-boot-$(PKG_VERSION)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/uboot-envtools
+ SECTION:=utils
+ CATEGORY:=Utilities
+ TITLE:=read/modify U-Boot bootloader environment
+ URL:=http://www.denx.de/wiki/U-Boot
+endef
+
+define Package/uboot-envtools/description
+ This package includes tools to read and modify U-Boot bootloader environment.
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+ touch $(PKG_BUILD_DIR)/include/config.h
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ HOSTCC="$(TOOLCHAIN_DIR)/bin/$(TARGET_CROSS)gcc" \
+ HOSTSTRIP="$(TOOLCHAIN_DIR)/bin/$(TARGET_CROSS)strip" \
+ env
+endef
+
+define Package/uboot-envtools/conffiles
+/etc/config/ubootenv
+/etc/fw_env.config
+endef
+
+define Package/uboot-envtools/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/tools/env/fw_printenv $(1)/usr/sbin
+ ln -s fw_printenv $(1)/usr/sbin/fw_setenv
+ $(INSTALL_DIR) $(1)/lib
+ $(INSTALL_DATA) ./files/uboot-envtools.sh $(1)/lib
+ifneq ($(CONFIG_TARGET_ar71xx),)
+ $(INSTALL_DIR) $(1)/etc/uci-defaults
+ $(INSTALL_BIN) ./files/ar71xx $(1)/etc/uci-defaults/uboot-envtools
+endif
+ifneq ($(CONFIG_TARGET_kirkwood),)
+ $(INSTALL_DIR) $(1)/etc/uci-defaults
+ $(INSTALL_BIN) ./files/kirkwood $(1)/etc/uci-defaults/uboot-envtools
+endif
+ifneq ($(CONFIG_TARGET_lantiq),)
+ $(INSTALL_DIR) $(1)/etc/uci-defaults
+ $(INSTALL_BIN) ./files/lantiq $(1)/etc/uci-defaults/uboot-envtools
+endif
+ifneq ($(CONFIG_TARGET_ramips),)
+ $(INSTALL_DIR) $(1)/etc/uci-defaults
+ $(INSTALL_BIN) ./files/ramips $(1)/etc/uci-defaults/uboot-envtools
+endif
+endef
+
+$(eval $(call BuildPackage,uboot-envtools))
diff --git a/package/boot/uboot-envtools/Makefile b/package/boot/uboot-envtools/Makefile
new file mode 100644
index 0000000..55aaf88
--- /dev/null
+++ b/package/boot/uboot-envtools/Makefile
@@ -0,0 +1,74 @@
+#
+# Copyright (C) 2006-2013 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=uboot-envtools
+PKG_DISTNAME:=u-boot
+PKG_VERSION:=2013.01.01
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_DISTNAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=ftp://ftp.denx.de/pub/u-boot
+PKG_MD5SUM:=73939f78606f89a1775c7e9acb2ca617
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/u-boot-$(PKG_VERSION)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/uboot-envtools
+ SECTION:=utils
+ CATEGORY:=Utilities
+ TITLE:=read/modify U-Boot bootloader environment
+ URL:=http://www.denx.de/wiki/U-Boot
+endef
+
+define Package/uboot-envtools/description
+ This package includes tools to read and modify U-Boot bootloader environment.
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+ touch $(PKG_BUILD_DIR)/include/config.h
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ HOSTCC="$(TOOLCHAIN_DIR)/bin/$(TARGET_CROSS)gcc" \
+ HOSTSTRIP="$(TOOLCHAIN_DIR)/bin/$(TARGET_CROSS)strip" \
+ env
+endef
+
+define Package/uboot-envtools/conffiles
+/etc/config/ubootenv
+/etc/fw_env.config
+endef
+
+define Package/uboot-envtools/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/tools/env/fw_printenv $(1)/usr/sbin
+ ln -s fw_printenv $(1)/usr/sbin/fw_setenv
+ $(INSTALL_DIR) $(1)/lib
+ $(INSTALL_DATA) ./files/uboot-envtools.sh $(1)/lib
+ifneq ($(CONFIG_TARGET_ar71xx),)
+ $(INSTALL_DIR) $(1)/etc/uci-defaults
+ $(INSTALL_BIN) ./files/ar71xx $(1)/etc/uci-defaults/uboot-envtools
+endif
+ifneq ($(CONFIG_TARGET_kirkwood),)
+ $(INSTALL_DIR) $(1)/etc/uci-defaults
+ $(INSTALL_BIN) ./files/kirkwood $(1)/etc/uci-defaults/uboot-envtools
+endif
+ifneq ($(CONFIG_TARGET_lantiq),)
+ $(INSTALL_DIR) $(1)/etc/uci-defaults
+ $(INSTALL_BIN) ./files/lantiq $(1)/etc/uci-defaults/uboot-envtools
+endif
+ifneq ($(CONFIG_TARGET_ramips),)
+ $(INSTALL_DIR) $(1)/etc/uci-defaults
+ $(INSTALL_BIN) ./files/ramips $(1)/etc/uci-defaults/uboot-envtools
+endif
+endef
+
+$(eval $(call BuildPackage,uboot-envtools))
diff --git a/package/boot/uboot-envtools/files/.svn/entries b/package/boot/uboot-envtools/files/.svn/entries
new file mode 100644
index 0000000..b8b2ee3
--- /dev/null
+++ b/package/boot/uboot-envtools/files/.svn/entries
@@ -0,0 +1,198 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/uboot-envtools/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-03T21:59:35.671819Z
+35866
+luka
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+lantiq
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+feaeaee38e5a27cd3fdb620527e84a40
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+388
+
+uboot-envtools.sh
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+4c8999ee23b10578d350fc5a58690e02
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+771
+
+kirkwood
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+be3738327f58fad9f27bd01a23ae277a
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+418
+
+ar71xx
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+10b2cf77277fa90f3966c145ff410c23
+2013-03-03T21:59:35.671819Z
+35866
+luka
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+630
+
+ramips
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+e8cb5e6fbb48539d2d9d74f7e858737d
+2013-02-02T17:01:52.502693Z
+35464
+juhosg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+495
+
diff --git a/package/boot/uboot-envtools/files/.svn/text-base/ar71xx.svn-base b/package/boot/uboot-envtools/files/.svn/text-base/ar71xx.svn-base
new file mode 100644
index 0000000..1803a9f
--- /dev/null
+++ b/package/boot/uboot-envtools/files/.svn/text-base/ar71xx.svn-base
@@ -0,0 +1,38 @@
+#!/bin/sh
+#
+# Copyright (C) 2011-2013 OpenWrt.org
+#
+
+[ -e /etc/config/ubootenv ] && exit 0
+
+touch /etc/config/ubootenv
+
+. /lib/ar71xx.sh
+. /lib/uboot-envtools.sh
+. /lib/functions.sh
+
+board=$(ar71xx_board_name)
+
+case "$board" in
+all0258n | \
+cap4200ag | \
+mr600 | \
+mr600v2)
+ ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x10000" "0x10000"
+ ;;
+alfa-ap96 | \
+all0315n | \
+om2p | \
+om2p-hs | \
+om2p-lc)
+ ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x40000" "0x40000"
+ ;;
+wzr-hp-ag300h)
+ ubootenv_add_uci_config "/dev/mtd3" "0x0" "0x10000" "0x10000"
+ ;;
+esac
+
+config_load ubootenv
+config_foreach ubootenv_add_app_config ubootenv
+
+exit 0
diff --git a/package/boot/uboot-envtools/files/.svn/text-base/kirkwood.svn-base b/package/boot/uboot-envtools/files/.svn/text-base/kirkwood.svn-base
new file mode 100644
index 0000000..cad53aa
--- /dev/null
+++ b/package/boot/uboot-envtools/files/.svn/text-base/kirkwood.svn-base
@@ -0,0 +1,25 @@
+#!/bin/sh
+#
+# Copyright (C) 2012 OpenWrt.org
+#
+
+[ -e /etc/config/ubootenv ] && exit 0
+
+touch /etc/config/ubootenv
+
+. /lib/kirkwood.sh
+. /lib/uboot-envtools.sh
+. /lib/functions.sh
+
+hardware=$(kirkwood_hardware_name)
+
+case "$hardware" in
+"RaidSonic ICY BOX IB-NAS6210")
+ ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x20000" "0x20000"
+ ;;
+esac
+
+config_load ubootenv
+config_foreach ubootenv_add_app_config ubootenv
+
+exit 0
diff --git a/package/boot/uboot-envtools/files/.svn/text-base/lantiq.svn-base b/package/boot/uboot-envtools/files/.svn/text-base/lantiq.svn-base
new file mode 100644
index 0000000..40befc3
--- /dev/null
+++ b/package/boot/uboot-envtools/files/.svn/text-base/lantiq.svn-base
@@ -0,0 +1,25 @@
+#!/bin/sh
+#
+# Copyright (C) 2012 OpenWrt.org
+#
+
+[ -e /etc/config/ubootenv ] && exit 0
+
+touch /etc/config/ubootenv
+
+. /lib/lantiq.sh
+. /lib/uboot-envtools.sh
+. /lib/functions.sh
+
+board=$(lantiq_board_name)
+
+case "$board" in
+GIGASX76X)
+ ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x10000" "0x10000" "1"
+ ;;
+esac
+
+config_load ubootenv
+config_foreach ubootenv_add_app_config ubootenv
+
+exit 0
diff --git a/package/boot/uboot-envtools/files/.svn/text-base/ramips.svn-base b/package/boot/uboot-envtools/files/.svn/text-base/ramips.svn-base
new file mode 100644
index 0000000..3599f68
--- /dev/null
+++ b/package/boot/uboot-envtools/files/.svn/text-base/ramips.svn-base
@@ -0,0 +1,32 @@
+#!/bin/sh
+#
+# Copyright (C) 2011-2012 OpenWrt.org
+#
+
+[ -e /etc/config/ubootenv ] && exit 0
+
+touch /etc/config/ubootenv
+
+. /lib/ramips.sh
+. /lib/uboot-envtools.sh
+. /lib/functions.sh
+
+board=$(ramips_board_name)
+
+case "$board" in
+all0239-3g | \
+all0256n | \
+all5002)
+ ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x10000" "0x10000"
+ ;;
+esac
+
+br6425)
+ ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x1000" "0x10000"
+ ;;
+esac
+
+config_load ubootenv
+config_foreach ubootenv_add_app_config ubootenv
+
+exit 0
diff --git a/package/boot/uboot-envtools/files/.svn/text-base/uboot-envtools.sh.svn-base b/package/boot/uboot-envtools/files/.svn/text-base/uboot-envtools.sh.svn-base
new file mode 100644
index 0000000..e21b283
--- /dev/null
+++ b/package/boot/uboot-envtools/files/.svn/text-base/uboot-envtools.sh.svn-base
@@ -0,0 +1,36 @@
+#!/bin/sh
+#
+# Copyright (C) 2011-2012 OpenWrt.org
+#
+
+ubootenv_add_uci_config() {
+ local dev=$1
+ local offset=$2
+ local envsize=$3
+ local secsize=$4
+ local numsec=$5
+ uci batch <<EOF
+add ubootenv ubootenv
+set ubootenv.@ubootenv[-1].dev='$dev'
+set ubootenv.@ubootenv[-1].offset='$offset'
+set ubootenv.@ubootenv[-1].envsize='$envsize'
+set ubootenv.@ubootenv[-1].secsize='$secsize'
+set ubootenv.@ubootenv[-1].numsec='$numsec'
+EOF
+ uci commit ubootenv
+}
+
+ubootenv_add_app_config() {
+ local dev
+ local offset
+ local envsize
+ local secsize
+ local numsec
+ config_get dev "$1" dev
+ config_get offset "$1" offset
+ config_get envsize "$1" envsize
+ config_get secsize "$1" secsize
+ config_get numsec "$1" numsec
+ echo "$dev $offset $envsize $secsize $numsec" >>/etc/fw_env.config
+}
+
diff --git a/package/boot/uboot-envtools/files/ar71xx b/package/boot/uboot-envtools/files/ar71xx
new file mode 100644
index 0000000..1803a9f
--- /dev/null
+++ b/package/boot/uboot-envtools/files/ar71xx
@@ -0,0 +1,38 @@
+#!/bin/sh
+#
+# Copyright (C) 2011-2013 OpenWrt.org
+#
+
+[ -e /etc/config/ubootenv ] && exit 0
+
+touch /etc/config/ubootenv
+
+. /lib/ar71xx.sh
+. /lib/uboot-envtools.sh
+. /lib/functions.sh
+
+board=$(ar71xx_board_name)
+
+case "$board" in
+all0258n | \
+cap4200ag | \
+mr600 | \
+mr600v2)
+ ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x10000" "0x10000"
+ ;;
+alfa-ap96 | \
+all0315n | \
+om2p | \
+om2p-hs | \
+om2p-lc)
+ ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x40000" "0x40000"
+ ;;
+wzr-hp-ag300h)
+ ubootenv_add_uci_config "/dev/mtd3" "0x0" "0x10000" "0x10000"
+ ;;
+esac
+
+config_load ubootenv
+config_foreach ubootenv_add_app_config ubootenv
+
+exit 0
diff --git a/package/boot/uboot-envtools/files/kirkwood b/package/boot/uboot-envtools/files/kirkwood
new file mode 100644
index 0000000..cad53aa
--- /dev/null
+++ b/package/boot/uboot-envtools/files/kirkwood
@@ -0,0 +1,25 @@
+#!/bin/sh
+#
+# Copyright (C) 2012 OpenWrt.org
+#
+
+[ -e /etc/config/ubootenv ] && exit 0
+
+touch /etc/config/ubootenv
+
+. /lib/kirkwood.sh
+. /lib/uboot-envtools.sh
+. /lib/functions.sh
+
+hardware=$(kirkwood_hardware_name)
+
+case "$hardware" in
+"RaidSonic ICY BOX IB-NAS6210")
+ ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x20000" "0x20000"
+ ;;
+esac
+
+config_load ubootenv
+config_foreach ubootenv_add_app_config ubootenv
+
+exit 0
diff --git a/package/boot/uboot-envtools/files/lantiq b/package/boot/uboot-envtools/files/lantiq
new file mode 100644
index 0000000..40befc3
--- /dev/null
+++ b/package/boot/uboot-envtools/files/lantiq
@@ -0,0 +1,25 @@
+#!/bin/sh
+#
+# Copyright (C) 2012 OpenWrt.org
+#
+
+[ -e /etc/config/ubootenv ] && exit 0
+
+touch /etc/config/ubootenv
+
+. /lib/lantiq.sh
+. /lib/uboot-envtools.sh
+. /lib/functions.sh
+
+board=$(lantiq_board_name)
+
+case "$board" in
+GIGASX76X)
+ ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x10000" "0x10000" "1"
+ ;;
+esac
+
+config_load ubootenv
+config_foreach ubootenv_add_app_config ubootenv
+
+exit 0
diff --git a/package/boot/uboot-envtools/files/ramips b/package/boot/uboot-envtools/files/ramips
new file mode 100644
index 0000000..3599f68
--- /dev/null
+++ b/package/boot/uboot-envtools/files/ramips
@@ -0,0 +1,32 @@
+#!/bin/sh
+#
+# Copyright (C) 2011-2012 OpenWrt.org
+#
+
+[ -e /etc/config/ubootenv ] && exit 0
+
+touch /etc/config/ubootenv
+
+. /lib/ramips.sh
+. /lib/uboot-envtools.sh
+. /lib/functions.sh
+
+board=$(ramips_board_name)
+
+case "$board" in
+all0239-3g | \
+all0256n | \
+all5002)
+ ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x10000" "0x10000"
+ ;;
+esac
+
+br6425)
+ ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x1000" "0x10000"
+ ;;
+esac
+
+config_load ubootenv
+config_foreach ubootenv_add_app_config ubootenv
+
+exit 0
diff --git a/package/boot/uboot-envtools/files/uboot-envtools.sh b/package/boot/uboot-envtools/files/uboot-envtools.sh
new file mode 100644
index 0000000..e21b283
--- /dev/null
+++ b/package/boot/uboot-envtools/files/uboot-envtools.sh
@@ -0,0 +1,36 @@
+#!/bin/sh
+#
+# Copyright (C) 2011-2012 OpenWrt.org
+#
+
+ubootenv_add_uci_config() {
+ local dev=$1
+ local offset=$2
+ local envsize=$3
+ local secsize=$4
+ local numsec=$5
+ uci batch <<EOF
+add ubootenv ubootenv
+set ubootenv.@ubootenv[-1].dev='$dev'
+set ubootenv.@ubootenv[-1].offset='$offset'
+set ubootenv.@ubootenv[-1].envsize='$envsize'
+set ubootenv.@ubootenv[-1].secsize='$secsize'
+set ubootenv.@ubootenv[-1].numsec='$numsec'
+EOF
+ uci commit ubootenv
+}
+
+ubootenv_add_app_config() {
+ local dev
+ local offset
+ local envsize
+ local secsize
+ local numsec
+ config_get dev "$1" dev
+ config_get offset "$1" offset
+ config_get envsize "$1" envsize
+ config_get secsize "$1" secsize
+ config_get numsec "$1" numsec
+ echo "$dev $offset $envsize $secsize $numsec" >>/etc/fw_env.config
+}
+
diff --git a/package/boot/uboot-envtools/patches/.svn/entries b/package/boot/uboot-envtools/patches/.svn/entries
new file mode 100644
index 0000000..d5b8a2a
--- /dev/null
+++ b/package/boot/uboot-envtools/patches/.svn/entries
@@ -0,0 +1,28 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/uboot-envtools/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-15T01:36:53.833391Z
+36033
+luka
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
diff --git a/package/boot/uboot-kirkwood/.svn/entries b/package/boot/uboot-kirkwood/.svn/entries
new file mode 100644
index 0000000..3077356
--- /dev/null
+++ b/package/boot/uboot-kirkwood/.svn/entries
@@ -0,0 +1,68 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/uboot-kirkwood
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-11-29T01:04:37.686581Z
+34401
+luka
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+files
+dir
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+b1a0c2e2c531d535f679f4ef6296f475
+2012-11-29T01:04:37.686581Z
+34401
+luka
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2412
+
diff --git a/package/boot/uboot-kirkwood/.svn/text-base/Makefile.svn-base b/package/boot/uboot-kirkwood/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..dc66450
--- /dev/null
+++ b/package/boot/uboot-kirkwood/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,104 @@
+#
+# Copyright (C) 2010-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=u-boot
+PKG_VERSION:=2012.10
+PKG_RELEASE:=1
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=ftp://ftp.denx.de/pub/u-boot
+PKG_MD5SUM:=8655f63b1e5c4647295ac9ce44660be3
+PKG_TARGETS:=bin
+
+include $(INCLUDE_DIR)/package.mk
+
+define uboot/Default
+ TITLE:=
+ CONFIG:=
+ IMAGE:=
+endef
+
+define uboot/sheevaplug
+ TITLE:=U-Boot for the SheevaPlug
+endef
+
+define uboot/dockstar
+ TITLE:=U-Boot for the Seagate DockStar
+endef
+
+define uboot/iconnect
+ TITLE:=U-Boot for the Iomega iConnect Wireless
+endef
+
+define uboot/ib62x0
+ TITLE:=U-Boot for the RaidSonic ICY BOX NAS6210 and NAS6220
+endef
+
+UBOOTS:=sheevaplug dockstar iconnect ib62x0
+
+define Package/uboot/template
+define Package/uboot-kirkwood-$(1)
+ SECTION:=boot
+ CATEGORY:=Boot Loaders
+ DEPENDS:=@TARGET_kirkwood
+ TITLE:=$(2)
+ URL:=http://www.denx.de/wiki/U-Boot
+ VARIANT:=$(1)
+endef
+endef
+
+define BuildUBootPackage
+ $(eval $(uboot/Default))
+ $(eval $(uboot/$(1)))
+ $(call Package/uboot/template,$(1),$(TITLE))
+endef
+
+ifdef BUILD_VARIANT
+$(eval $(call uboot/$(BUILD_VARIANT)))
+UBOOT_CONFIG:=$(if $(CONFIG),$(CONFIG),$(BUILD_VARIANT))
+UBOOT_IMAGE:=$(if $(IMAGE),$(IMAGE),openwrt-$(BOARD)-$(BUILD_VARIANT)-u-boot.bin)
+endif
+
+define Build/Configure
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ $(UBOOT_CONFIG)_config
+endef
+
+define Build/Compile
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ u-boot.kwb \
+ CROSS_COMPILE=$(TARGET_CROSS)
+endef
+
+define Package/uboot/install/default
+ $(INSTALL_DIR) $(BIN_DIR)/uboot-$(BOARD)-$(1)
+ $(CP) $(PKG_BUILD_DIR)/u-boot.bin \
+ $(BIN_DIR)/uboot-$(BOARD)-$(1)/openwrt-$(BOARD)-$(1)-u-boot.bin
+ $(CP) $(PKG_BUILD_DIR)/u-boot.kwb \
+ $(BIN_DIR)/uboot-$(BOARD)-$(1)/openwrt-$(BOARD)-$(1)-u-boot.kwb
+ $(INSTALL_DIR) $(BIN_DIR)/u-boot-kwboot/
+ $(CP) $(PKG_BUILD_DIR)/tools/kwboot \
+ $(BIN_DIR)/u-boot-kwboot/
+endef
+
+define Package/uboot/install/template
+define Package/uboot-kirkwood-$(1)/install
+ $(call Package/uboot/install/default,$(2))
+endef
+endef
+
+$(foreach u,$(UBOOTS), \
+ $(eval $(call Package/uboot/install/template,$(u),$(u))) \
+)
+
+$(foreach u,$(UBOOTS), \
+ $(eval $(call BuildUBootPackage,$(u))) \
+ $(eval $(call BuildPackage,uboot-kirkwood-$(u))) \
+)
diff --git a/package/boot/uboot-kirkwood/Makefile b/package/boot/uboot-kirkwood/Makefile
new file mode 100644
index 0000000..dc66450
--- /dev/null
+++ b/package/boot/uboot-kirkwood/Makefile
@@ -0,0 +1,104 @@
+#
+# Copyright (C) 2010-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=u-boot
+PKG_VERSION:=2012.10
+PKG_RELEASE:=1
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=ftp://ftp.denx.de/pub/u-boot
+PKG_MD5SUM:=8655f63b1e5c4647295ac9ce44660be3
+PKG_TARGETS:=bin
+
+include $(INCLUDE_DIR)/package.mk
+
+define uboot/Default
+ TITLE:=
+ CONFIG:=
+ IMAGE:=
+endef
+
+define uboot/sheevaplug
+ TITLE:=U-Boot for the SheevaPlug
+endef
+
+define uboot/dockstar
+ TITLE:=U-Boot for the Seagate DockStar
+endef
+
+define uboot/iconnect
+ TITLE:=U-Boot for the Iomega iConnect Wireless
+endef
+
+define uboot/ib62x0
+ TITLE:=U-Boot for the RaidSonic ICY BOX NAS6210 and NAS6220
+endef
+
+UBOOTS:=sheevaplug dockstar iconnect ib62x0
+
+define Package/uboot/template
+define Package/uboot-kirkwood-$(1)
+ SECTION:=boot
+ CATEGORY:=Boot Loaders
+ DEPENDS:=@TARGET_kirkwood
+ TITLE:=$(2)
+ URL:=http://www.denx.de/wiki/U-Boot
+ VARIANT:=$(1)
+endef
+endef
+
+define BuildUBootPackage
+ $(eval $(uboot/Default))
+ $(eval $(uboot/$(1)))
+ $(call Package/uboot/template,$(1),$(TITLE))
+endef
+
+ifdef BUILD_VARIANT
+$(eval $(call uboot/$(BUILD_VARIANT)))
+UBOOT_CONFIG:=$(if $(CONFIG),$(CONFIG),$(BUILD_VARIANT))
+UBOOT_IMAGE:=$(if $(IMAGE),$(IMAGE),openwrt-$(BOARD)-$(BUILD_VARIANT)-u-boot.bin)
+endif
+
+define Build/Configure
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ $(UBOOT_CONFIG)_config
+endef
+
+define Build/Compile
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ u-boot.kwb \
+ CROSS_COMPILE=$(TARGET_CROSS)
+endef
+
+define Package/uboot/install/default
+ $(INSTALL_DIR) $(BIN_DIR)/uboot-$(BOARD)-$(1)
+ $(CP) $(PKG_BUILD_DIR)/u-boot.bin \
+ $(BIN_DIR)/uboot-$(BOARD)-$(1)/openwrt-$(BOARD)-$(1)-u-boot.bin
+ $(CP) $(PKG_BUILD_DIR)/u-boot.kwb \
+ $(BIN_DIR)/uboot-$(BOARD)-$(1)/openwrt-$(BOARD)-$(1)-u-boot.kwb
+ $(INSTALL_DIR) $(BIN_DIR)/u-boot-kwboot/
+ $(CP) $(PKG_BUILD_DIR)/tools/kwboot \
+ $(BIN_DIR)/u-boot-kwboot/
+endef
+
+define Package/uboot/install/template
+define Package/uboot-kirkwood-$(1)/install
+ $(call Package/uboot/install/default,$(2))
+endef
+endef
+
+$(foreach u,$(UBOOTS), \
+ $(eval $(call Package/uboot/install/template,$(u),$(u))) \
+)
+
+$(foreach u,$(UBOOTS), \
+ $(eval $(call BuildUBootPackage,$(u))) \
+ $(eval $(call BuildPackage,uboot-kirkwood-$(u))) \
+)
diff --git a/package/boot/uboot-kirkwood/files/.svn/entries b/package/boot/uboot-kirkwood/files/.svn/entries
new file mode 100644
index 0000000..beb8916
--- /dev/null
+++ b/package/boot/uboot-kirkwood/files/.svn/entries
@@ -0,0 +1,34 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/uboot-kirkwood/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-11-22T21:16:04.130323Z
+34303
+luka
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+include
+dir
+
+board
+dir
+
diff --git a/package/boot/uboot-kirkwood/files/board/.svn/entries b/package/boot/uboot-kirkwood/files/board/.svn/entries
new file mode 100644
index 0000000..87dc985
--- /dev/null
+++ b/package/boot/uboot-kirkwood/files/board/.svn/entries
@@ -0,0 +1,31 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/uboot-kirkwood/files/board
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-11-22T21:16:04.130323Z
+34303
+luka
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+iomega
+dir
+
diff --git a/package/boot/uboot-kirkwood/files/board/iomega/.svn/entries b/package/boot/uboot-kirkwood/files/board/iomega/.svn/entries
new file mode 100644
index 0000000..4656309
--- /dev/null
+++ b/package/boot/uboot-kirkwood/files/board/iomega/.svn/entries
@@ -0,0 +1,31 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/uboot-kirkwood/files/board/iomega
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-11-22T21:16:04.130323Z
+34303
+luka
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+iconnect
+dir
+
diff --git a/package/boot/uboot-kirkwood/files/board/iomega/iconnect/.svn/entries b/package/boot/uboot-kirkwood/files/board/iomega/iconnect/.svn/entries
new file mode 100644
index 0000000..9056757
--- /dev/null
+++ b/package/boot/uboot-kirkwood/files/board/iomega/iconnect/.svn/entries
@@ -0,0 +1,28 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/uboot-kirkwood/files/board/iomega/iconnect
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-11-22T21:16:04.130323Z
+34303
+luka
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
diff --git a/package/boot/uboot-kirkwood/files/include/.svn/entries b/package/boot/uboot-kirkwood/files/include/.svn/entries
new file mode 100644
index 0000000..ee6253a
--- /dev/null
+++ b/package/boot/uboot-kirkwood/files/include/.svn/entries
@@ -0,0 +1,31 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/uboot-kirkwood/files/include
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-11-22T21:16:04.130323Z
+34303
+luka
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+configs
+dir
+
diff --git a/package/boot/uboot-kirkwood/files/include/configs/.svn/entries b/package/boot/uboot-kirkwood/files/include/configs/.svn/entries
new file mode 100644
index 0000000..84be5da
--- /dev/null
+++ b/package/boot/uboot-kirkwood/files/include/configs/.svn/entries
@@ -0,0 +1,28 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/uboot-kirkwood/files/include/configs
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-11-22T21:16:04.130323Z
+34303
+luka
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
diff --git a/package/boot/uboot-kirkwood/patches/.svn/entries b/package/boot/uboot-kirkwood/patches/.svn/entries
new file mode 100644
index 0000000..38b5197
--- /dev/null
+++ b/package/boot/uboot-kirkwood/patches/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/uboot-kirkwood/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-11-22T21:16:04.130323Z
+34303
+luka
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+110-dockstar.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+11b1822c2274e5ec31c4552b382fe2f2
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1224
+
diff --git a/package/boot/uboot-kirkwood/patches/.svn/text-base/110-dockstar.patch.svn-base b/package/boot/uboot-kirkwood/patches/.svn/text-base/110-dockstar.patch.svn-base
new file mode 100644
index 0000000..4ff7e57
--- /dev/null
+++ b/package/boot/uboot-kirkwood/patches/.svn/text-base/110-dockstar.patch.svn-base
@@ -0,0 +1,35 @@
+--- a/include/configs/dockstar.h
++++ b/include/configs/dockstar.h
+@@ -83,22 +83,19 @@
+ * Default environment variables
+ */
+ #define CONFIG_BOOTCOMMAND \
+- "setenv bootargs ${console} ${mtdparts} ${bootargs_root}; " \
+- "ubi part root; " \
+- "ubifsmount root; " \
+- "ubifsload 0x800000 ${kernel}; " \
+- "ubifsload 0x1100000 ${initrd}; " \
+- "bootm 0x800000 0x1100000"
++ "${x_bootcmd_kernel}; " \
++ "setenv bootargs ${x_bootargs} ${x_bootargs_root}; " \
++ "${x_bootcmd_usb}; bootm 0x6400000;"
+
+-#define CONFIG_MTDPARTS "mtdparts=orion_nand:1m(uboot),-(root)\0"
++#define CONFIG_MTDPARTS \
++ "orion_nand:1M(u-boot),1M@1M(second_stage_u-boot)," \
++ "3M@2M(kernel),32M@5M(rootfs),219M@37M(data) rw\0"
+
+ #define CONFIG_EXTRA_ENV_SETTINGS \
+- "console=console=ttyS0,115200\0" \
+- "mtdids=nand0=orion_nand\0" \
+- "mtdparts="CONFIG_MTDPARTS \
+- "kernel=/boot/uImage\0" \
+- "initrd=/boot/uInitrd\0" \
+- "bootargs_root=ubi.mtd=1 root=ubi0:root rootfstype=ubifs ro\0"
++ "x_bootargs=console=ttyS0,115200 mtdparts="CONFIG_MTDPARTS \
++ "x_bootcmd_kernel=nand read 0x6400000 0x200000 0x300000\0" \
++ "x_bootargs_root=root=/dev/mtdblock3 rw rootfstype=jffs2\0" \
++ "x_bootcmd_usb=usb start\0"
+
+ /*
+ * Ethernet Driver configuration
diff --git a/package/boot/uboot-kirkwood/patches/110-dockstar.patch b/package/boot/uboot-kirkwood/patches/110-dockstar.patch
new file mode 100644
index 0000000..4ff7e57
--- /dev/null
+++ b/package/boot/uboot-kirkwood/patches/110-dockstar.patch
@@ -0,0 +1,35 @@
+--- a/include/configs/dockstar.h
++++ b/include/configs/dockstar.h
+@@ -83,22 +83,19 @@
+ * Default environment variables
+ */
+ #define CONFIG_BOOTCOMMAND \
+- "setenv bootargs ${console} ${mtdparts} ${bootargs_root}; " \
+- "ubi part root; " \
+- "ubifsmount root; " \
+- "ubifsload 0x800000 ${kernel}; " \
+- "ubifsload 0x1100000 ${initrd}; " \
+- "bootm 0x800000 0x1100000"
++ "${x_bootcmd_kernel}; " \
++ "setenv bootargs ${x_bootargs} ${x_bootargs_root}; " \
++ "${x_bootcmd_usb}; bootm 0x6400000;"
+
+-#define CONFIG_MTDPARTS "mtdparts=orion_nand:1m(uboot),-(root)\0"
++#define CONFIG_MTDPARTS \
++ "orion_nand:1M(u-boot),1M@1M(second_stage_u-boot)," \
++ "3M@2M(kernel),32M@5M(rootfs),219M@37M(data) rw\0"
+
+ #define CONFIG_EXTRA_ENV_SETTINGS \
+- "console=console=ttyS0,115200\0" \
+- "mtdids=nand0=orion_nand\0" \
+- "mtdparts="CONFIG_MTDPARTS \
+- "kernel=/boot/uImage\0" \
+- "initrd=/boot/uInitrd\0" \
+- "bootargs_root=ubi.mtd=1 root=ubi0:root rootfstype=ubifs ro\0"
++ "x_bootargs=console=ttyS0,115200 mtdparts="CONFIG_MTDPARTS \
++ "x_bootcmd_kernel=nand read 0x6400000 0x200000 0x300000\0" \
++ "x_bootargs_root=root=/dev/mtdblock3 rw rootfstype=jffs2\0" \
++ "x_bootcmd_usb=usb start\0"
+
+ /*
+ * Ethernet Driver configuration
diff --git a/package/boot/uboot-lantiq/.svn/entries b/package/boot/uboot-lantiq/.svn/entries
new file mode 100644
index 0000000..b679bd3
--- /dev/null
+++ b/package/boot/uboot-lantiq/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/uboot-lantiq
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-22T12:55:01.537267Z
+35292
+luka
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+bb017dc208140158e17d27f258ff37f8
+2013-01-22T12:55:01.537267Z
+35292
+luka
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2983
+
diff --git a/package/boot/uboot-lantiq/.svn/text-base/Makefile.svn-base b/package/boot/uboot-lantiq/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..b3d9173
--- /dev/null
+++ b/package/boot/uboot-lantiq/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,123 @@
+#
+# Copyright (C) 2012-2013 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=u-boot
+PKG_VERSION:=2013.01
+PKG_RELEASE:=1
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=ftp://ftp.denx.de/pub/u-boot
+PKG_MD5SUM:=e58a8a7f78972248190d83de0dc362ce
+PKG_TARGETS:=bin
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
+
+include $(INCLUDE_DIR)/package.mk
+
+define uboot/Default
+ TITLE:=
+ SOC:=
+ DDR_SETTINGS:=
+ IMAGE:=
+endef
+
+define uboot/arv4519pw_ram
+ TITLE:=U-Boot for Arcadyan arv4519pw (RAM)
+ SOC:=danube
+ DDR_SETTINGS:=board/arcadyan/arv4519pw/ddr_settings.h
+endef
+
+define uboot/arv4519pw_nor
+ TITLE:=U-Boot for Arcadyan arv4519pw (NOR)
+ SOC:=danube
+endef
+
+define uboot/arv7518pw_ram
+ TITLE:=U-Boot for Arcadyan arv7518pw (RAM)
+ SOC:=danube
+ DDR_SETTINGS:=board/arcadyan/arv7518pw/ddr_settings.h
+endef
+
+define uboot/arv7518pw_nor
+ TITLE:=U-Boot for Arcadyan arv7518pw (NOR)
+ SOC:=danube
+endef
+
+define uboot/gigasx76x_ram
+ TITLE:=U-Boot for Siemens Gigaset sx76x (RAM)
+ SOC:=danube
+ DDR_SETTINGS:=board/gigaset/sx76x/ddr_settings.h
+endef
+
+define uboot/gigasx76x_nor
+ TITLE:=U-Boot for Siemens Gigaset sx76x (NOR)
+ SOC:=danube
+endef
+
+UBOOTS:= \
+ arv4519pw_ram arv4519pw_nor \
+ arv7518pw_ram arv7518pw_nor \
+ gigasx76x_ram gigasx76x_nor
+
+define Package/uboot/template
+define Package/uboot-lantiq-$(1)
+ SECTION:=boot
+ CATEGORY:=Boot Loaders
+ DEPENDS:=@TARGET_lantiq_xway
+ TITLE:=$(2)
+ URL:=http://www.denx.de/wiki/U-Boot
+ VARIANT:=$(1)
+ MAINTAINER:=Luka Perkov <luka@openwrt.org>
+endef
+endef
+
+define BuildUBootPackage
+ $(eval $(uboot/Default))
+ $(eval $(uboot/$(1)))
+ $(call Package/uboot/template,$(1),$(TITLE))
+endef
+
+define Build/Configure
+ $(MAKE) -C $(PKG_BUILD_DIR) $(BUILD_VARIANT)_config
+endef
+
+define Build/Compile
+ $(MAKE) -C $(PKG_BUILD_DIR) CROSS_COMPILE=$(TARGET_CROSS)
+endef
+
+define Package/uboot/install/default
+ $(CP) \
+ $(PKG_BUILD_DIR)/$(2) \
+ $(BIN_DIR)/uboot-$(BOARD)-$(1)/openwrt-$(BOARD)-$(1)-u-boot.img
+endef
+
+define Package/uboot/install/uart
+ awk -f $(PKG_BUILD_DIR)/tools/lantiq_ram_init_uart.awk \
+ -v soc=$(2) $(PKG_BUILD_DIR)/$(3) \
+ > $(PKG_BUILD_DIR)/ddr_settings
+ perl $(PKG_BUILD_DIR)/tools/gct.pl \
+ $(PKG_BUILD_DIR)/ddr_settings $(PKG_BUILD_DIR)/u-boot.srec \
+ $(BIN_DIR)/uboot-$(BOARD)-$(1)/openwrt-$(BOARD)-$(1)-u-boot.asc
+ endef
+
+define Package/uboot/install/template
+define Package/uboot-lantiq-$(1)/install
+ $(call Package/uboot/install/default,$(1),$(if $(IMAGE),$(IMAGE),u-boot.bin))
+ $(if $(DDR_SETTINGS), \
+ $(call Package/uboot/install/uart,$(1),$(SOC),$(DDR_SETTINGS)) \
+ )
+endef
+endef
+
+$(foreach u,$(UBOOTS), \
+ $(eval $(call BuildUBootPackage,$(u))) \
+ $(eval $(call Package/uboot/install/template,$(u))) \
+ $(eval $(call BuildPackage,uboot-lantiq-$(u))) \
+)
diff --git a/package/boot/uboot-lantiq/Makefile b/package/boot/uboot-lantiq/Makefile
new file mode 100644
index 0000000..b3d9173
--- /dev/null
+++ b/package/boot/uboot-lantiq/Makefile
@@ -0,0 +1,123 @@
+#
+# Copyright (C) 2012-2013 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=u-boot
+PKG_VERSION:=2013.01
+PKG_RELEASE:=1
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=ftp://ftp.denx.de/pub/u-boot
+PKG_MD5SUM:=e58a8a7f78972248190d83de0dc362ce
+PKG_TARGETS:=bin
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
+
+include $(INCLUDE_DIR)/package.mk
+
+define uboot/Default
+ TITLE:=
+ SOC:=
+ DDR_SETTINGS:=
+ IMAGE:=
+endef
+
+define uboot/arv4519pw_ram
+ TITLE:=U-Boot for Arcadyan arv4519pw (RAM)
+ SOC:=danube
+ DDR_SETTINGS:=board/arcadyan/arv4519pw/ddr_settings.h
+endef
+
+define uboot/arv4519pw_nor
+ TITLE:=U-Boot for Arcadyan arv4519pw (NOR)
+ SOC:=danube
+endef
+
+define uboot/arv7518pw_ram
+ TITLE:=U-Boot for Arcadyan arv7518pw (RAM)
+ SOC:=danube
+ DDR_SETTINGS:=board/arcadyan/arv7518pw/ddr_settings.h
+endef
+
+define uboot/arv7518pw_nor
+ TITLE:=U-Boot for Arcadyan arv7518pw (NOR)
+ SOC:=danube
+endef
+
+define uboot/gigasx76x_ram
+ TITLE:=U-Boot for Siemens Gigaset sx76x (RAM)
+ SOC:=danube
+ DDR_SETTINGS:=board/gigaset/sx76x/ddr_settings.h
+endef
+
+define uboot/gigasx76x_nor
+ TITLE:=U-Boot for Siemens Gigaset sx76x (NOR)
+ SOC:=danube
+endef
+
+UBOOTS:= \
+ arv4519pw_ram arv4519pw_nor \
+ arv7518pw_ram arv7518pw_nor \
+ gigasx76x_ram gigasx76x_nor
+
+define Package/uboot/template
+define Package/uboot-lantiq-$(1)
+ SECTION:=boot
+ CATEGORY:=Boot Loaders
+ DEPENDS:=@TARGET_lantiq_xway
+ TITLE:=$(2)
+ URL:=http://www.denx.de/wiki/U-Boot
+ VARIANT:=$(1)
+ MAINTAINER:=Luka Perkov <luka@openwrt.org>
+endef
+endef
+
+define BuildUBootPackage
+ $(eval $(uboot/Default))
+ $(eval $(uboot/$(1)))
+ $(call Package/uboot/template,$(1),$(TITLE))
+endef
+
+define Build/Configure
+ $(MAKE) -C $(PKG_BUILD_DIR) $(BUILD_VARIANT)_config
+endef
+
+define Build/Compile
+ $(MAKE) -C $(PKG_BUILD_DIR) CROSS_COMPILE=$(TARGET_CROSS)
+endef
+
+define Package/uboot/install/default
+ $(CP) \
+ $(PKG_BUILD_DIR)/$(2) \
+ $(BIN_DIR)/uboot-$(BOARD)-$(1)/openwrt-$(BOARD)-$(1)-u-boot.img
+endef
+
+define Package/uboot/install/uart
+ awk -f $(PKG_BUILD_DIR)/tools/lantiq_ram_init_uart.awk \
+ -v soc=$(2) $(PKG_BUILD_DIR)/$(3) \
+ > $(PKG_BUILD_DIR)/ddr_settings
+ perl $(PKG_BUILD_DIR)/tools/gct.pl \
+ $(PKG_BUILD_DIR)/ddr_settings $(PKG_BUILD_DIR)/u-boot.srec \
+ $(BIN_DIR)/uboot-$(BOARD)-$(1)/openwrt-$(BOARD)-$(1)-u-boot.asc
+ endef
+
+define Package/uboot/install/template
+define Package/uboot-lantiq-$(1)/install
+ $(call Package/uboot/install/default,$(1),$(if $(IMAGE),$(IMAGE),u-boot.bin))
+ $(if $(DDR_SETTINGS), \
+ $(call Package/uboot/install/uart,$(1),$(SOC),$(DDR_SETTINGS)) \
+ )
+endef
+endef
+
+$(foreach u,$(UBOOTS), \
+ $(eval $(call BuildUBootPackage,$(u))) \
+ $(eval $(call Package/uboot/install/template,$(u))) \
+ $(eval $(call BuildPackage,uboot-lantiq-$(u))) \
+)
diff --git a/package/boot/uboot-lantiq/patches/.svn/entries b/package/boot/uboot-lantiq/patches/.svn/entries
new file mode 100644
index 0000000..0113087
--- /dev/null
+++ b/package/boot/uboot-lantiq/patches/.svn/entries
@@ -0,0 +1,980 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/uboot-lantiq/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-22T12:55:01.537267Z
+35292
+luka
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+0015-sf-macronix-add-support-for-MX66L51235L.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+602fb08450d9ee680150b4b6378ed147
+2013-01-22T12:55:01.537267Z
+35292
+luka
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+620
+
+0022-net-switchlib-add-driver-for-Atheros-AR8216.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+578fbe6f2d625581bdab30ad15aceacb
+2013-01-22T12:55:01.537267Z
+35292
+luka
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3946
+
+0026-MIPS-add-board-support-for-Gigaset-SX76X.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+c557b83b9f972af2fe018d7e8bceb2d9
+2013-01-22T12:55:01.537267Z
+35292
+luka
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+7688
+
+0019-net-switchlib-add-framework-for-ethernet-switch-driv.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+4f4c2ba4ecb1006a500ea6693062c0a8
+2013-01-22T12:55:01.537267Z
+35292
+luka
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5685
+
+0025-MIPS-add-board-support-for-AVM-FritzBox-3370.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+d6df3ee4d0d1bb634d515eaf3c1d0bf1
+2013-01-22T12:55:01.537267Z
+35292
+luka
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+10840
+
+0020-net-switchlib-add-driver-for-Lantiq-PSB697X-switch-f.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+49e21898d73d7e2914bbc83bdd486086
+2013-01-22T12:55:01.537267Z
+35292
+luka
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4439
+
+0007-sf-eon-use-16-bit-ID-for-comparison.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+f5c77287a92ace9da6ab48ac0c8307b9
+2013-01-22T12:55:01.537267Z
+35292
+luka
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1098
+
+0009-sf-eon-add-support-for-EN25QH256.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+0a18abd1ee5dda839e36b9ea148a7766
+2013-01-22T12:55:01.537267Z
+35292
+luka
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+596
+
+0016-sf-add-MTD-layer-driver-for-SPI-flash-devices.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+be788cc7364980b8d4b8a3840c8324fa
+2013-01-22T12:55:01.537267Z
+35292
+luka
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3471
+
+0023-MIPS-add-support-for-Lantiq-XWAY-SoCs.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+d9e3240b34b482e402e2cd8993fad402
+2013-01-22T12:55:01.537267Z
+35292
+luka
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+248589
+
+0006-sf-add-generic-support-for-4-byte-address-mode.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+bb9f6b4f62ba46f9a635360abaaa0039
+2013-01-22T12:55:01.537267Z
+35292
+luka
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4669
+
+0028-MIPS-add-board-support-for-Arcadyan-ARV4519.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+cf814d35e34cb938873ec8ae40bea6c7
+2013-01-22T12:55:01.537267Z
+35292
+luka
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+7484
+
+0013-sf-macronix-add-support-for-4-byte-address-mode.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+f85f2f23cede590205ce320e42968c10
+2013-01-22T12:55:01.537267Z
+35292
+luka
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1269
+
+0004-sf-add-malloc-free-probe-functions-dedicated-for-SPL.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+82e2ab95e1eee1895db8cf3a457863a2
+2013-01-22T12:55:01.537267Z
+35292
+luka
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3369
+
+0027-MIPS-add-board-support-for-Arcadyan-ARV7518.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+ca4ecb71ceab421e44e9305c09e7e0d1
+2013-01-22T12:55:01.537267Z
+35292
+luka
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+7474
+
+0005-sf-factor-out-the-flash-address-calculation.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+b75411af756e141f6998390ec2700c88
+2013-01-22T12:55:01.537267Z
+35292
+luka
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3263
+
+0002-sf-handle-CONFIG_MANUAL_RELOC.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+e3f49d1615edf5a441a17fe1af0901c0
+2013-01-22T12:55:01.537267Z
+35292
+luka
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1309
+
+0024-MIPS-VRX200-add-option-to-boot-from-AVM-EVA-loader.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+0dda929b094582fe39387a9923b77e90
+2013-01-22T12:55:01.537267Z
+35292
+luka
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1044
+
+0008-sf-eon-add-support-for-4-byte-address-mode.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+40bc8aa4f9847b3c858cd2c3748a4dc2
+2013-01-22T12:55:01.537267Z
+35292
+luka
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1117
+
+0018-MIPS-add-SPI-flash-init-hook.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+6b48b2e832bb1185a77cdd6c6bbbfd2b
+2013-01-22T12:55:01.537267Z
+35292
+luka
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1183
+
+0021-net-switchlib-add-driver-for-Lantiq-ADM6996I-switch-.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+fd730dc30a31d6c47027115a403069dc
+2013-01-22T12:55:01.537267Z
+35292
+luka
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4602
+
+0017-sf-add-init-function.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+9aa02a17e92e047ec05be9695b1056fe
+2013-01-22T12:55:01.537267Z
+35292
+luka
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1257
+
+0012-sf-spansion-add-support-for-S25FL512S.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+7cc84fd8eca16c98369a40613da48f24
+2013-01-22T12:55:01.537267Z
+35292
+luka
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+679
+
+0029-tools-add-some-helper-tools-for-Lantiq-SoCs.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+a21e1f8f3ca4336f6b8bef85efa6e2b2
+2013-01-22T12:55:01.537267Z
+35292
+luka
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+8788
+
+0011-sf-spansion-add-support-for-4-byte-address-mode.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+6856262a607d534b2cfe33e8859409d3
+2013-01-22T12:55:01.537267Z
+35292
+luka
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1517
+
+0014-sf-macronix-add-support-for-MX25L25635E.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+0ec732bb910a790afe321d1aaee9df87
+2013-01-22T12:55:01.537267Z
+35292
+luka
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+619
+
+0010-sf-spansion-fix-device-IDs-and-sector-architecture-f.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+bc39484ed9eea8e820f295f582343406
+2013-01-22T12:55:01.537267Z
+35292
+luka
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+783
+
+0003-sf-factor-out-malloc-from-SPI-flash-drivers.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+35f88c1039b8799350ce6eee51270d2f
+2013-01-22T12:55:01.537267Z
+35292
+luka
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+21472
+
diff --git a/package/boot/uboot-lantiq/patches/.svn/text-base/0002-sf-handle-CONFIG_MANUAL_RELOC.patch.svn-base b/package/boot/uboot-lantiq/patches/.svn/text-base/0002-sf-handle-CONFIG_MANUAL_RELOC.patch.svn-base
new file mode 100644
index 0000000..63a21af
--- /dev/null
+++ b/package/boot/uboot-lantiq/patches/.svn/text-base/0002-sf-handle-CONFIG_MANUAL_RELOC.patch.svn-base
@@ -0,0 +1,46 @@
+From 60e8a35f0efa5a7e5d797a3f239971c84061ef11 Mon Sep 17 00:00:00 2001
+From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+Date: Tue, 6 Nov 2012 21:39:47 +0100
+Subject: sf: handle CONFIG_MANUAL_RELOC
+
+Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+
+--- a/drivers/mtd/spi/spi_flash.c
++++ b/drivers/mtd/spi/spi_flash.c
+@@ -293,7 +293,7 @@ int spi_flash_cmd_write_status(struct sp
+ */
+ #define IDCODE_CONT_LEN 0
+ #define IDCODE_PART_LEN 5
+-static const struct {
++static struct {
+ const u8 shift;
+ const u8 idcode;
+ struct spi_flash *(*probe) (struct spi_slave *spi, u8 *idcode);
+@@ -335,6 +335,10 @@ static const struct {
+ };
+ #define IDCODE_LEN (IDCODE_CONT_LEN + IDCODE_PART_LEN)
+
++#ifdef CONFIG_NEEDS_MANUAL_RELOC
++DECLARE_GLOBAL_DATA_PTR;
++#endif
++
+ struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
+ unsigned int max_hz, unsigned int spi_mode)
+ {
+@@ -342,6 +346,16 @@ struct spi_flash *spi_flash_probe(unsign
+ struct spi_flash *flash = NULL;
+ int ret, i, shift;
+ u8 idcode[IDCODE_LEN], *idp;
++#ifdef CONFIG_NEEDS_MANUAL_RELOC
++ static int relocated;
++
++ if (!relocated) {
++ for (i = 0; i < ARRAY_SIZE(flashes); i++)
++ flashes[i].probe += gd->reloc_off;
++
++ relocated = 1;
++ }
++#endif
+
+ spi = spi_setup_slave(bus, cs, max_hz, spi_mode);
+ if (!spi) {
diff --git a/package/boot/uboot-lantiq/patches/.svn/text-base/0003-sf-factor-out-malloc-from-SPI-flash-drivers.patch.svn-base b/package/boot/uboot-lantiq/patches/.svn/text-base/0003-sf-factor-out-malloc-from-SPI-flash-drivers.patch.svn-base
new file mode 100644
index 0000000..7f44675
--- /dev/null
+++ b/package/boot/uboot-lantiq/patches/.svn/text-base/0003-sf-factor-out-malloc-from-SPI-flash-drivers.patch.svn-base
@@ -0,0 +1,719 @@
+From 73d127565b5a4b19bcaacabc505689ee039f16fd Mon Sep 17 00:00:00 2001
+From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+Date: Sun, 11 Nov 2012 03:11:38 +0100
+Subject: sf: factor out malloc from SPI flash drivers
+
+Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+
+--- a/drivers/mtd/spi/atmel.c
++++ b/drivers/mtd/spi/atmel.c
+@@ -40,18 +40,6 @@ struct atmel_spi_flash_params {
+ const char *name;
+ };
+
+-/* spi_flash needs to be first so upper layers can free() it */
+-struct atmel_spi_flash {
+- struct spi_flash flash;
+- const struct atmel_spi_flash_params *params;
+-};
+-
+-static inline struct atmel_spi_flash *
+-to_atmel_spi_flash(struct spi_flash *flash)
+-{
+- return container_of(flash, struct atmel_spi_flash, flash);
+-}
+-
+ static const struct atmel_spi_flash_params atmel_spi_flash_table[] = {
+ {
+ .idcode1 = 0x22,
+@@ -156,7 +144,8 @@ static int at45_wait_ready(struct spi_fl
+ * Assemble the address part of a command for AT45 devices in
+ * non-power-of-two page size mode.
+ */
+-static void at45_build_address(struct atmel_spi_flash *asf, u8 *cmd, u32 offset)
++static void at45_build_address(const struct atmel_spi_flash_params *params,
++ u8 *cmd, u32 offset)
+ {
+ unsigned long page_addr;
+ unsigned long byte_addr;
+@@ -167,7 +156,7 @@ static void at45_build_address(struct at
+ * The "extra" space per page is the power-of-two page size
+ * divided by 32.
+ */
+- page_shift = asf->params->l2_page_size;
++ page_shift = params->l2_page_size;
+ page_size = (1 << page_shift) + (1 << (page_shift - 5));
+ page_shift++;
+ page_addr = offset / page_size;
+@@ -181,11 +170,11 @@ static void at45_build_address(struct at
+ static int dataflash_read_fast_at45(struct spi_flash *flash,
+ u32 offset, size_t len, void *buf)
+ {
+- struct atmel_spi_flash *asf = to_atmel_spi_flash(flash);
++ const struct atmel_spi_flash_params *params = flash->priv;
+ u8 cmd[5];
+
+ cmd[0] = CMD_READ_ARRAY_FAST;
+- at45_build_address(asf, cmd + 1, offset);
++ at45_build_address(params, cmd + 1, offset);
+ cmd[4] = 0x00;
+
+ return spi_flash_read_common(flash, cmd, sizeof(cmd), buf, len);
+@@ -197,7 +186,7 @@ static int dataflash_read_fast_at45(stru
+ static int dataflash_write_p2(struct spi_flash *flash,
+ u32 offset, size_t len, const void *buf)
+ {
+- struct atmel_spi_flash *asf = to_atmel_spi_flash(flash);
++ const struct atmel_spi_flash_params *params = flash->priv;
+ unsigned long page_size;
+ u32 addr = offset;
+ size_t chunk_len;
+@@ -211,7 +200,7 @@ static int dataflash_write_p2(struct spi
+ * the other is being programmed into main memory.
+ */
+
+- page_size = (1 << asf->params->l2_page_size);
++ page_size = (1 << params->l2_page_size);
+
+ ret = spi_claim_bus(flash->spi);
+ if (ret) {
+@@ -263,7 +252,7 @@ out:
+ static int dataflash_write_at45(struct spi_flash *flash,
+ u32 offset, size_t len, const void *buf)
+ {
+- struct atmel_spi_flash *asf = to_atmel_spi_flash(flash);
++ const struct atmel_spi_flash_params *params = flash->priv;
+ unsigned long page_addr;
+ unsigned long byte_addr;
+ unsigned long page_size;
+@@ -279,7 +268,7 @@ static int dataflash_write_at45(struct s
+ * the other is being programmed into main memory.
+ */
+
+- page_shift = asf->params->l2_page_size;
++ page_shift = params->l2_page_size;
+ page_size = (1 << page_shift) + (1 << (page_shift - 5));
+ page_shift++;
+ page_addr = offset / page_size;
+@@ -338,7 +327,7 @@ out:
+ */
+ static int dataflash_erase_p2(struct spi_flash *flash, u32 offset, size_t len)
+ {
+- struct atmel_spi_flash *asf = to_atmel_spi_flash(flash);
++ const struct atmel_spi_flash_params *params = flash->priv;
+ unsigned long page_size;
+
+ size_t actual;
+@@ -351,7 +340,7 @@ static int dataflash_erase_p2(struct spi
+ * when possible.
+ */
+
+- page_size = (1 << asf->params->l2_page_size);
++ page_size = (1 << params->l2_page_size);
+
+ if (offset % page_size || len % page_size) {
+ debug("SF: Erase offset/length not multiple of page size\n");
+@@ -397,7 +386,7 @@ out:
+
+ static int dataflash_erase_at45(struct spi_flash *flash, u32 offset, size_t len)
+ {
+- struct atmel_spi_flash *asf = to_atmel_spi_flash(flash);
++ const struct atmel_spi_flash_params *params = flash->priv;
+ unsigned long page_addr;
+ unsigned long page_size;
+ unsigned int page_shift;
+@@ -411,7 +400,7 @@ static int dataflash_erase_at45(struct s
+ * when possible.
+ */
+
+- page_shift = asf->params->l2_page_size;
++ page_shift = params->l2_page_size;
+ page_size = (1 << page_shift) + (1 << (page_shift - 5));
+ page_shift++;
+ page_addr = offset / page_size;
+@@ -458,12 +447,12 @@ out:
+ return ret;
+ }
+
+-struct spi_flash *spi_flash_probe_atmel(struct spi_slave *spi, u8 *idcode)
++int spi_flash_probe_atmel(struct spi_flash *flash, u8 *idcode)
+ {
+ const struct atmel_spi_flash_params *params;
++ struct spi_slave *spi = flash->spi;
+ unsigned page_size;
+ unsigned int family;
+- struct atmel_spi_flash *asf;
+ unsigned int i;
+ int ret;
+ u8 status;
+@@ -477,18 +466,11 @@ struct spi_flash *spi_flash_probe_atmel(
+ if (i == ARRAY_SIZE(atmel_spi_flash_table)) {
+ debug("SF: Unsupported DataFlash ID %02x\n",
+ idcode[1]);
+- return NULL;
+- }
+-
+- asf = malloc(sizeof(struct atmel_spi_flash));
+- if (!asf) {
+- debug("SF: Failed to allocate memory\n");
+- return NULL;
++ return 0;
+ }
+
+- asf->params = params;
+- asf->flash.spi = spi;
+- asf->flash.name = params->name;
++ flash->priv = (void *)params;
++ flash->name = params->name;
+
+ /* Assuming power-of-two page size initially. */
+ page_size = 1 << params->l2_page_size;
+@@ -503,48 +485,44 @@ struct spi_flash *spi_flash_probe_atmel(
+ */
+ ret = spi_flash_cmd(spi, CMD_AT45_READ_STATUS, &status, 1);
+ if (ret)
+- goto err;
++ return -1;
+
+ debug("SF: AT45 status register: %02x\n", status);
+
+ if (!(status & AT45_STATUS_P2_PAGE_SIZE)) {
+- asf->flash.read = dataflash_read_fast_at45;
+- asf->flash.write = dataflash_write_at45;
+- asf->flash.erase = dataflash_erase_at45;
++ flash->read = dataflash_read_fast_at45;
++ flash->write = dataflash_write_at45;
++ flash->erase = dataflash_erase_at45;
+ page_size += 1 << (params->l2_page_size - 5);
+ } else {
+- asf->flash.read = spi_flash_cmd_read_fast;
+- asf->flash.write = dataflash_write_p2;
+- asf->flash.erase = dataflash_erase_p2;
++ flash->read = spi_flash_cmd_read_fast;
++ flash->write = dataflash_write_p2;
++ flash->erase = dataflash_erase_p2;
+ }
+
+- asf->flash.page_size = page_size;
+- asf->flash.sector_size = page_size;
++ flash->page_size = page_size;
++ flash->sector_size = page_size;
+ break;
+
+ case DF_FAMILY_AT26F:
+ case DF_FAMILY_AT26DF:
+- asf->flash.read = spi_flash_cmd_read_fast;
+- asf->flash.write = spi_flash_cmd_write_multi;
+- asf->flash.erase = spi_flash_cmd_erase;
+- asf->flash.page_size = page_size;
+- asf->flash.sector_size = 4096;
++ flash->read = spi_flash_cmd_read_fast;
++ flash->write = spi_flash_cmd_write_multi;
++ flash->erase = spi_flash_cmd_erase;
++ flash->page_size = page_size;
++ flash->sector_size = 4096;
+ /* clear SPRL# bit for locked flash */
+- spi_flash_cmd_write_status(&asf->flash, 0);
++ spi_flash_cmd_write_status(flash, 0);
+ break;
+
+ default:
+ debug("SF: Unsupported DataFlash family %u\n", family);
+- goto err;
++ return -1;
+ }
+
+- asf->flash.size = page_size * params->pages_per_block
++ flash->size = page_size * params->pages_per_block
+ * params->blocks_per_sector
+ * params->nr_sectors;
+
+- return &asf->flash;
+-
+-err:
+- free(asf);
+- return NULL;
++ return 1;
+ }
+--- a/drivers/mtd/spi/eon.c
++++ b/drivers/mtd/spi/eon.c
+@@ -29,10 +29,9 @@ static const struct eon_spi_flash_params
+ },
+ };
+
+-struct spi_flash *spi_flash_probe_eon(struct spi_slave *spi, u8 *idcode)
++int spi_flash_probe_eon(struct spi_flash *flash, u8 *idcode)
+ {
+ const struct eon_spi_flash_params *params;
+- struct spi_flash *flash;
+ unsigned int i;
+
+ for (i = 0; i < ARRAY_SIZE(eon_spi_flash_table); ++i) {
+@@ -43,16 +42,10 @@ struct spi_flash *spi_flash_probe_eon(st
+
+ if (i == ARRAY_SIZE(eon_spi_flash_table)) {
+ debug("SF: Unsupported EON ID %02x\n", idcode[1]);
+- return NULL;
++ return 0;
+ }
+
+- flash = malloc(sizeof(*flash));
+- if (!flash) {
+- debug("SF: Failed to allocate memory\n");
+- return NULL;
+- }
+-
+- flash->spi = spi;
++ flash->priv = (void *)params;
+ flash->name = params->name;
+
+ flash->write = spi_flash_cmd_write_multi;
+@@ -63,5 +56,5 @@ struct spi_flash *spi_flash_probe_eon(st
+ flash->size = 256 * 16
+ * params->nr_sectors;
+
+- return flash;
++ return 1;
+ }
+--- a/drivers/mtd/spi/macronix.c
++++ b/drivers/mtd/spi/macronix.c
+@@ -79,10 +79,9 @@ static const struct macronix_spi_flash_p
+ },
+ };
+
+-struct spi_flash *spi_flash_probe_macronix(struct spi_slave *spi, u8 *idcode)
++int spi_flash_probe_macronix(struct spi_flash *flash, u8 *idcode)
+ {
+ const struct macronix_spi_flash_params *params;
+- struct spi_flash *flash;
+ unsigned int i;
+ u16 id = idcode[2] | idcode[1] << 8;
+
+@@ -94,16 +93,10 @@ struct spi_flash *spi_flash_probe_macron
+
+ if (i == ARRAY_SIZE(macronix_spi_flash_table)) {
+ debug("SF: Unsupported Macronix ID %04x\n", id);
+- return NULL;
++ return 0;
+ }
+
+- flash = malloc(sizeof(*flash));
+- if (!flash) {
+- debug("SF: Failed to allocate memory\n");
+- return NULL;
+- }
+-
+- flash->spi = spi;
++ flash->priv = (void *)params;
+ flash->name = params->name;
+
+ flash->write = spi_flash_cmd_write_multi;
+@@ -116,5 +109,5 @@ struct spi_flash *spi_flash_probe_macron
+ /* Clear BP# bits for read-only flash */
+ spi_flash_cmd_write_status(flash, 0);
+
+- return flash;
++ return 1;
+ }
+--- a/drivers/mtd/spi/ramtron.c
++++ b/drivers/mtd/spi/ramtron.c
+@@ -69,17 +69,6 @@ struct ramtron_spi_fram_params {
+ const char *name; /* name for display and/or matching */
+ };
+
+-struct ramtron_spi_fram {
+- struct spi_flash flash;
+- const struct ramtron_spi_fram_params *params;
+-};
+-
+-static inline struct ramtron_spi_fram *to_ramtron_spi_fram(struct spi_flash
+- *flash)
+-{
+- return container_of(flash, struct ramtron_spi_fram, flash);
+-}
+-
+ /*
+ * table describing supported FRAM chips:
+ * chips without RDID command must have the values 0xff for id1 and id2
+@@ -155,18 +144,18 @@ static const struct ramtron_spi_fram_par
+ static int ramtron_common(struct spi_flash *flash,
+ u32 offset, size_t len, void *buf, u8 command)
+ {
+- struct ramtron_spi_fram *sn = to_ramtron_spi_fram(flash);
++ const struct ramtron_spi_fram_params *params = flash->priv;
+ u8 cmd[4];
+ int cmd_len;
+ int ret;
+
+- if (sn->params->addr_len == 3 && sn->params->merge_cmd == 0) {
++ if (params->addr_len == 3 && params->merge_cmd == 0) {
+ cmd[0] = command;
+ cmd[1] = offset >> 16;
+ cmd[2] = offset >> 8;
+ cmd[3] = offset;
+ cmd_len = 4;
+- } else if (sn->params->addr_len == 2 && sn->params->merge_cmd == 0) {
++ } else if (params->addr_len == 2 && params->merge_cmd == 0) {
+ cmd[0] = command;
+ cmd[1] = offset >> 8;
+ cmd[2] = offset;
+@@ -230,10 +219,9 @@ static int ramtron_erase(struct spi_flas
+ * nore: we are called here with idcode pointing to the first non-0x7f byte
+ * already!
+ */
+-struct spi_flash *spi_fram_probe_ramtron(struct spi_slave *spi, u8 *idcode)
++int spi_fram_probe_ramtron(struct spi_flash *flash, u8 *idcode)
+ {
+ const struct ramtron_spi_fram_params *params;
+- struct ramtron_spi_fram *sn;
+ unsigned int i;
+ #ifdef CONFIG_SPI_FRAM_RAMTRON_NON_JEDEC
+ int ret;
+@@ -259,11 +247,11 @@ struct spi_flash *spi_fram_probe_ramtron
+ */
+ ret = spi_flash_cmd(spi, CMD_READ_STATUS, &sr, 1);
+ if (ret)
+- return NULL;
++ return 0;
+
+ /* Bits 5,4,0 are fixed 0 for all devices */
+ if ((sr & 0x31) != 0x00)
+- return NULL;
++ return 0;
+ /* now find the device */
+ for (i = 0; i < ARRAY_SIZE(ramtron_spi_fram_table); i++) {
+ params = &ramtron_spi_fram_table[i];
+@@ -281,23 +269,16 @@ struct spi_flash *spi_fram_probe_ramtron
+ /* arriving here means no method has found a device we can handle */
+ debug("SF/ramtron: unsupported device id0=%02x id1=%02x id2=%02x\n",
+ idcode[0], idcode[1], idcode[2]);
+- return NULL;
++ return 0;
+
+ found:
+- sn = malloc(sizeof(*sn));
+- if (!sn) {
+- debug("SF: Failed to allocate memory\n");
+- return NULL;
+- }
++ flash->priv = (void *)params;
++ flash->name = params->name;
+
+- sn->params = params;
+- sn->flash.spi = spi;
+- sn->flash.name = params->name;
+-
+- sn->flash.write = ramtron_write;
+- sn->flash.read = ramtron_read;
+- sn->flash.erase = ramtron_erase;
+- sn->flash.size = params->size;
++ flash->write = ramtron_write;
++ flash->read = ramtron_read;
++ flash->erase = ramtron_erase;
++ flash->size = params->size;
+
+- return &sn->flash;
++ return 1;
+ }
+--- a/drivers/mtd/spi/spansion.c
++++ b/drivers/mtd/spi/spansion.c
+@@ -105,10 +105,9 @@ static const struct spansion_spi_flash_p
+ },
+ };
+
+-struct spi_flash *spi_flash_probe_spansion(struct spi_slave *spi, u8 *idcode)
++int spi_flash_probe_spansion(struct spi_flash *flash, u8 *idcode)
+ {
+ const struct spansion_spi_flash_params *params;
+- struct spi_flash *flash;
+ unsigned int i;
+ unsigned short jedec, ext_jedec;
+
+@@ -125,16 +124,10 @@ struct spi_flash *spi_flash_probe_spansi
+
+ if (i == ARRAY_SIZE(spansion_spi_flash_table)) {
+ debug("SF: Unsupported SPANSION ID %04x %04x\n", jedec, ext_jedec);
+- return NULL;
++ return 0;
+ }
+
+- flash = malloc(sizeof(*flash));
+- if (!flash) {
+- debug("SF: Failed to allocate memory\n");
+- return NULL;
+- }
+-
+- flash->spi = spi;
++ flash->priv = (void *)params;
+ flash->name = params->name;
+
+ flash->write = spi_flash_cmd_write_multi;
+@@ -144,5 +137,5 @@ struct spi_flash *spi_flash_probe_spansi
+ flash->sector_size = 256 * params->pages_per_sector;
+ flash->size = flash->sector_size * params->nr_sectors;
+
+- return flash;
++ return 1;
+ }
+--- a/drivers/mtd/spi/spi_flash.c
++++ b/drivers/mtd/spi/spi_flash.c
+@@ -296,7 +296,7 @@ int spi_flash_cmd_write_status(struct sp
+ static struct {
+ const u8 shift;
+ const u8 idcode;
+- struct spi_flash *(*probe) (struct spi_slave *spi, u8 *idcode);
++ int (*probe) (struct spi_flash *flash, u8 *idcode);
+ } flashes[] = {
+ /* Keep it sorted by define name */
+ #ifdef CONFIG_SPI_FLASH_ATMEL
+@@ -343,7 +343,7 @@ struct spi_flash *spi_flash_probe(unsign
+ unsigned int max_hz, unsigned int spi_mode)
+ {
+ struct spi_slave *spi;
+- struct spi_flash *flash = NULL;
++ struct spi_flash *flash;
+ int ret, i, shift;
+ u8 idcode[IDCODE_LEN], *idp;
+ #ifdef CONFIG_NEEDS_MANUAL_RELOC
+@@ -379,6 +379,15 @@ struct spi_flash *spi_flash_probe(unsign
+ print_buffer(0, idcode, 1, sizeof(idcode), 0);
+ #endif
+
++ flash = malloc(sizeof(*flash));
++ if (!flash) {
++ debug("SF: failed to alloc memory\n");
++ goto err_malloc;
++ }
++
++ memset(flash, 0, sizeof(*flash));
++ flash->spi = spi;
++
+ /* count the number of continuation bytes */
+ for (shift = 0, idp = idcode;
+ shift < IDCODE_CONT_LEN && *idp == 0x7f;
+@@ -389,12 +398,12 @@ struct spi_flash *spi_flash_probe(unsign
+ for (i = 0; i < ARRAY_SIZE(flashes); ++i)
+ if (flashes[i].shift == shift && flashes[i].idcode == *idp) {
+ /* we have a match, call probe */
+- flash = flashes[i].probe(spi, idp);
+- if (flash)
++ ret = flashes[i].probe(flash, idp);
++ if (ret)
+ break;
+ }
+
+- if (!flash) {
++ if (ret <= 0) {
+ printf("SF: Unsupported manufacturer %02x\n", *idp);
+ goto err_manufacturer_probe;
+ }
+@@ -408,6 +417,8 @@ struct spi_flash *spi_flash_probe(unsign
+ return flash;
+
+ err_manufacturer_probe:
++ free(flash);
++err_malloc:
+ err_read_id:
+ spi_release_bus(spi);
+ err_claim_bus:
+--- a/drivers/mtd/spi/spi_flash_internal.h
++++ b/drivers/mtd/spi/spi_flash_internal.h
+@@ -98,11 +98,11 @@ int spi_flash_cmd_wait_ready(struct spi_
+ int spi_flash_cmd_erase(struct spi_flash *flash, u32 offset, size_t len);
+
+ /* Manufacturer-specific probe functions */
+-struct spi_flash *spi_flash_probe_spansion(struct spi_slave *spi, u8 *idcode);
+-struct spi_flash *spi_flash_probe_atmel(struct spi_slave *spi, u8 *idcode);
+-struct spi_flash *spi_flash_probe_eon(struct spi_slave *spi, u8 *idcode);
+-struct spi_flash *spi_flash_probe_macronix(struct spi_slave *spi, u8 *idcode);
+-struct spi_flash *spi_flash_probe_sst(struct spi_slave *spi, u8 *idcode);
+-struct spi_flash *spi_flash_probe_stmicro(struct spi_slave *spi, u8 *idcode);
+-struct spi_flash *spi_flash_probe_winbond(struct spi_slave *spi, u8 *idcode);
+-struct spi_flash *spi_fram_probe_ramtron(struct spi_slave *spi, u8 *idcode);
++int spi_flash_probe_spansion(struct spi_flash *flash, u8 *idcode);
++int spi_flash_probe_atmel(struct spi_flash *flash, u8 *idcode);
++int spi_flash_probe_eon(struct spi_flash *flash, u8 *idcode);
++int spi_flash_probe_macronix(struct spi_flash *flash, u8 *idcode);
++int spi_flash_probe_sst(struct spi_flash *flash, u8 *idcode);
++int spi_flash_probe_stmicro(struct spi_flash *flash, u8 *idcode);
++int spi_flash_probe_winbond(struct spi_flash *flash, u8 *idcode);
++int spi_fram_probe_ramtron(struct spi_flash *flash, u8 *idcode);
+--- a/drivers/mtd/spi/sst.c
++++ b/drivers/mtd/spi/sst.c
+@@ -39,11 +39,6 @@ struct sst_spi_flash_params {
+ const char *name;
+ };
+
+-struct sst_spi_flash {
+- struct spi_flash flash;
+- const struct sst_spi_flash_params *params;
+-};
+-
+ static const struct sst_spi_flash_params sst_spi_flash_table[] = {
+ {
+ .idcode1 = 0x8d,
+@@ -185,11 +180,9 @@ sst_write_wp(struct spi_flash *flash, u3
+ return ret;
+ }
+
+-struct spi_flash *
+-spi_flash_probe_sst(struct spi_slave *spi, u8 *idcode)
++int spi_flash_probe_sst(struct spi_flash *flash, u8 *idcode)
+ {
+ const struct sst_spi_flash_params *params;
+- struct sst_spi_flash *stm;
+ size_t i;
+
+ for (i = 0; i < ARRAY_SIZE(sst_spi_flash_table); ++i) {
+@@ -200,31 +193,24 @@ spi_flash_probe_sst(struct spi_slave *sp
+
+ if (i == ARRAY_SIZE(sst_spi_flash_table)) {
+ debug("SF: Unsupported SST ID %02x\n", idcode[1]);
+- return NULL;
+- }
+-
+- stm = malloc(sizeof(*stm));
+- if (!stm) {
+- debug("SF: Failed to allocate memory\n");
+- return NULL;
++ return 0;
+ }
+
+- stm->params = params;
+- stm->flash.spi = spi;
+- stm->flash.name = params->name;
++ flash->priv = (void *)params;
++ flash->name = params->name;
+
+- if (stm->params->flags & SST_FEAT_WP)
+- stm->flash.write = sst_write_wp;
++ if (params->flags & SST_FEAT_WP)
++ flash->write = sst_write_wp;
+ else
+- stm->flash.write = spi_flash_cmd_write_multi;
+- stm->flash.erase = spi_flash_cmd_erase;
+- stm->flash.read = spi_flash_cmd_read_fast;
+- stm->flash.page_size = 256;
+- stm->flash.sector_size = 4096;
+- stm->flash.size = stm->flash.sector_size * params->nr_sectors;
++ flash->write = spi_flash_cmd_write_multi;
++ flash->erase = spi_flash_cmd_erase;
++ flash->read = spi_flash_cmd_read_fast;
++ flash->page_size = 256;
++ flash->sector_size = 4096;
++ flash->size = flash->sector_size * params->nr_sectors;
+
+ /* Flash powers up read-only, so clear BP# bits */
+- spi_flash_cmd_write_status(&stm->flash, 0);
++ spi_flash_cmd_write_status(flash, 0);
+
+- return &stm->flash;
++ return 1;
+ }
+--- a/drivers/mtd/spi/stmicro.c
++++ b/drivers/mtd/spi/stmicro.c
+@@ -112,10 +112,10 @@ static const struct stmicro_spi_flash_pa
+ },
+ };
+
+-struct spi_flash *spi_flash_probe_stmicro(struct spi_slave *spi, u8 * idcode)
++int spi_flash_probe_stmicro(struct spi_flash *flash, u8 * idcode)
+ {
+ const struct stmicro_spi_flash_params *params;
+- struct spi_flash *flash;
++ struct spi_slave *spi = flash->spi;
+ unsigned int i;
+ u16 id;
+
+@@ -123,13 +123,13 @@ struct spi_flash *spi_flash_probe_stmicr
+ i = spi_flash_cmd(spi, CMD_M25PXX_RES,
+ idcode, 4);
+ if (i)
+- return NULL;
++ return 0;
+ if ((idcode[3] & 0xf0) == 0x10) {
+ idcode[0] = 0x20;
+ idcode[1] = 0x20;
+ idcode[2] = idcode[3] + 1;
+ } else
+- return NULL;
++ return 0;
+ }
+
+ id = ((idcode[1] << 8) | idcode[2]);
+@@ -143,16 +143,10 @@ struct spi_flash *spi_flash_probe_stmicr
+
+ if (i == ARRAY_SIZE(stmicro_spi_flash_table)) {
+ debug("SF: Unsupported STMicro ID %04x\n", id);
+- return NULL;
++ return 0;
+ }
+
+- flash = malloc(sizeof(*flash));
+- if (!flash) {
+- debug("SF: Failed to allocate memory\n");
+- return NULL;
+- }
+-
+- flash->spi = spi;
++ flash->priv = (void *)params;
+ flash->name = params->name;
+
+ flash->write = spi_flash_cmd_write_multi;
+@@ -162,5 +156,5 @@ struct spi_flash *spi_flash_probe_stmicr
+ flash->sector_size = 256 * params->pages_per_sector;
+ flash->size = flash->sector_size * params->nr_sectors;
+
+- return flash;
++ return 1;
+ }
+--- a/drivers/mtd/spi/winbond.c
++++ b/drivers/mtd/spi/winbond.c
+@@ -69,10 +69,9 @@ static const struct winbond_spi_flash_pa
+ },
+ };
+
+-struct spi_flash *spi_flash_probe_winbond(struct spi_slave *spi, u8 *idcode)
++int spi_flash_probe_winbond(struct spi_flash *flash, u8 *idcode)
+ {
+ const struct winbond_spi_flash_params *params;
+- struct spi_flash *flash;
+ unsigned int i;
+
+ for (i = 0; i < ARRAY_SIZE(winbond_spi_flash_table); i++) {
+@@ -84,16 +83,10 @@ struct spi_flash *spi_flash_probe_winbon
+ if (i == ARRAY_SIZE(winbond_spi_flash_table)) {
+ debug("SF: Unsupported Winbond ID %02x%02x\n",
+ idcode[1], idcode[2]);
+- return NULL;
++ return 0;
+ }
+
+- flash = malloc(sizeof(*flash));
+- if (!flash) {
+- debug("SF: Failed to allocate memory\n");
+- return NULL;
+- }
+-
+- flash->spi = spi;
++ flash->priv = (void *)params;
+ flash->name = params->name;
+
+ flash->write = spi_flash_cmd_write_multi;
+@@ -103,5 +96,5 @@ struct spi_flash *spi_flash_probe_winbon
+ flash->sector_size = 4096;
+ flash->size = 4096 * 16 * params->nr_blocks;
+
+- return flash;
++ return 1;
+ }
+--- a/include/spi_flash.h
++++ b/include/spi_flash.h
+@@ -31,6 +31,7 @@ struct spi_flash {
+ struct spi_slave *spi;
+
+ const char *name;
++ void *priv;
+
+ /* Total flash size */
+ u32 size;
diff --git a/package/boot/uboot-lantiq/patches/.svn/text-base/0004-sf-add-malloc-free-probe-functions-dedicated-for-SPL.patch.svn-base b/package/boot/uboot-lantiq/patches/.svn/text-base/0004-sf-add-malloc-free-probe-functions-dedicated-for-SPL.patch.svn-base
new file mode 100644
index 0000000..7a1ef3b
--- /dev/null
+++ b/package/boot/uboot-lantiq/patches/.svn/text-base/0004-sf-add-malloc-free-probe-functions-dedicated-for-SPL.patch.svn-base
@@ -0,0 +1,131 @@
+From f9ab44c271fbd82a5702b6ba067fa90e33a30089 Mon Sep 17 00:00:00 2001
+From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+Date: Wed, 7 Nov 2012 15:29:27 +0100
+Subject: sf: add malloc-free probe functions dedicated for SPL
+
+Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+
+--- a/drivers/mtd/spi/spi_flash.c
++++ b/drivers/mtd/spi/spi_flash.c
+@@ -339,11 +339,11 @@ static struct {
+ DECLARE_GLOBAL_DATA_PTR;
+ #endif
+
+-struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
+- unsigned int max_hz, unsigned int spi_mode)
++int spi_flash_probe_spl(struct spi_flash *flash, unsigned int bus,
++ unsigned int cs, unsigned int max_hz,
++ unsigned int spi_mode)
+ {
+ struct spi_slave *spi;
+- struct spi_flash *flash;
+ int ret, i, shift;
+ u8 idcode[IDCODE_LEN], *idp;
+ #ifdef CONFIG_NEEDS_MANUAL_RELOC
+@@ -359,8 +359,8 @@ struct spi_flash *spi_flash_probe(unsign
+
+ spi = spi_setup_slave(bus, cs, max_hz, spi_mode);
+ if (!spi) {
+- printf("SF: Failed to set up slave\n");
+- return NULL;
++ debug("SF: Failed to set up slave\n");
++ return -1;
+ }
+
+ ret = spi_claim_bus(spi);
+@@ -379,13 +379,6 @@ struct spi_flash *spi_flash_probe(unsign
+ print_buffer(0, idcode, 1, sizeof(idcode), 0);
+ #endif
+
+- flash = malloc(sizeof(*flash));
+- if (!flash) {
+- debug("SF: failed to alloc memory\n");
+- goto err_malloc;
+- }
+-
+- memset(flash, 0, sizeof(*flash));
+ flash->spi = spi;
+
+ /* count the number of continuation bytes */
+@@ -404,30 +397,58 @@ struct spi_flash *spi_flash_probe(unsign
+ }
+
+ if (ret <= 0) {
+- printf("SF: Unsupported manufacturer %02x\n", *idp);
++ debug("SF: Unsupported manufacturer %02x\n", *idp);
+ goto err_manufacturer_probe;
+ }
+
+- printf("SF: Detected %s with page size ", flash->name);
+- print_size(flash->sector_size, ", total ");
+- print_size(flash->size, "\n");
+-
+ spi_release_bus(spi);
+
+- return flash;
++ return 0;
+
+ err_manufacturer_probe:
+- free(flash);
+-err_malloc:
+ err_read_id:
+ spi_release_bus(spi);
+ err_claim_bus:
+ spi_free_slave(spi);
++
++ return ret;
++}
++
++struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
++ unsigned int max_hz, unsigned int spi_mode)
++{
++ struct spi_flash *flash;
++ int ret;
++
++ flash = malloc(sizeof(*flash));
++ if (!flash) {
++ debug("SF: Failed to malloc spi_flash\n");
++ return NULL;
++ }
++ memset(flash, 0, sizeof(*flash));
++
++ ret = spi_flash_probe_spl(flash, bus, cs, max_hz, spi_mode);
++ if (ret)
++ goto err_probe;
++
++ printf("SF: %s, page size ", flash->name);
++ print_size(flash->sector_size, ", total ");
++ print_size(flash->size, "\n");
++
++ return flash;
++
++err_probe:
++ free(flash);
+ return NULL;
+ }
+
+-void spi_flash_free(struct spi_flash *flash)
++void spi_flash_free_spl(struct spi_flash *flash)
+ {
+ spi_free_slave(flash->spi);
++}
++
++void spi_flash_free(struct spi_flash *flash)
++{
++ spi_flash_free_spl(flash);
+ free(flash);
+ }
+--- a/include/spi_flash.h
++++ b/include/spi_flash.h
+@@ -52,6 +52,11 @@ struct spi_flash *spi_flash_probe(unsign
+ unsigned int max_hz, unsigned int spi_mode);
+ void spi_flash_free(struct spi_flash *flash);
+
++int spi_flash_probe_spl(struct spi_flash *flash, unsigned int bus,
++ unsigned int cs, unsigned int max_hz,
++ unsigned int spi_mode);
++void spi_flash_free_spl(struct spi_flash *flash);
++
+ static inline int spi_flash_read(struct spi_flash *flash, u32 offset,
+ size_t len, void *buf)
+ {
diff --git a/package/boot/uboot-lantiq/patches/.svn/text-base/0005-sf-factor-out-the-flash-address-calculation.patch.svn-base b/package/boot/uboot-lantiq/patches/.svn/text-base/0005-sf-factor-out-the-flash-address-calculation.patch.svn-base
new file mode 100644
index 0000000..356db59
--- /dev/null
+++ b/package/boot/uboot-lantiq/patches/.svn/text-base/0005-sf-factor-out-the-flash-address-calculation.patch.svn-base
@@ -0,0 +1,107 @@
+From acb2721e1cd2e7488a7b08a4ed590177369a1689 Mon Sep 17 00:00:00 2001
+From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+Date: Tue, 6 Nov 2012 19:10:40 +0100
+Subject: sf: factor out the flash address calculation
+
+Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+
+--- a/drivers/mtd/spi/spi_flash.c
++++ b/drivers/mtd/spi/spi_flash.c
+@@ -15,12 +15,22 @@
+
+ #include "spi_flash_internal.h"
+
+-static void spi_flash_addr(u32 addr, u8 *cmd)
++static void spi_flash_addr(struct spi_flash *flash, u32 addr, u8 *cmd, u8 *cmd_len)
+ {
+ /* cmd[0] is actual command */
+ cmd[1] = addr >> 16;
+ cmd[2] = addr >> 8;
+ cmd[3] = addr >> 0;
++ *cmd_len = 4;
++}
++
++static void spi_flash_page_addr(struct spi_flash *flash, u32 page_addr, u32 byte_addr, u8 *cmd, u8 *cmd_len)
++{
++ /* cmd[0] is actual command */
++ cmd[1] = page_addr >> 8;
++ cmd[2] = page_addr >> 0;
++ cmd[3] = byte_addr;
++ *cmd_len = 4;
+ }
+
+ static int spi_flash_read_write(struct spi_slave *spi,
+@@ -71,7 +81,7 @@ int spi_flash_cmd_write_multi(struct spi
+ unsigned long page_addr, byte_addr, page_size;
+ size_t chunk_len, actual;
+ int ret;
+- u8 cmd[4];
++ u8 cmd[4], cmd_len;
+
+ page_size = flash->page_size;
+ page_addr = offset / page_size;
+@@ -87,9 +97,7 @@ int spi_flash_cmd_write_multi(struct spi
+ for (actual = 0; actual < len; actual += chunk_len) {
+ chunk_len = min(len - actual, page_size - byte_addr);
+
+- cmd[1] = page_addr >> 8;
+- cmd[2] = page_addr;
+- cmd[3] = byte_addr;
++ spi_flash_page_addr(flash, page_addr, byte_addr, cmd, &cmd_len);
+
+ debug("PP: 0x%p => cmd = { 0x%02x 0x%02x%02x%02x } chunk_len = %zu\n",
+ buf + actual, cmd[0], cmd[1], cmd[2], cmd[3], chunk_len);
+@@ -100,7 +108,7 @@ int spi_flash_cmd_write_multi(struct spi
+ break;
+ }
+
+- ret = spi_flash_cmd_write(flash->spi, cmd, 4,
++ ret = spi_flash_cmd_write(flash->spi, cmd, cmd_len,
+ buf + actual, chunk_len);
+ if (ret < 0) {
+ debug("SF: write failed\n");
+@@ -138,13 +146,13 @@ int spi_flash_read_common(struct spi_fla
+ int spi_flash_cmd_read_fast(struct spi_flash *flash, u32 offset,
+ size_t len, void *data)
+ {
+- u8 cmd[5];
++ u8 cmd[5], cmd_len;
+
+ cmd[0] = CMD_READ_ARRAY_FAST;
+- spi_flash_addr(offset, cmd);
+- cmd[4] = 0x00;
++ spi_flash_addr(flash, offset, cmd, &cmd_len);
++ cmd[cmd_len] = 0x00;
+
+- return spi_flash_read_common(flash, cmd, sizeof(cmd), data, len);
++ return spi_flash_read_common(flash, cmd, cmd_len + 1, data, len);
+ }
+
+ int spi_flash_cmd_poll_bit(struct spi_flash *flash, unsigned long timeout,
+@@ -194,7 +202,7 @@ int spi_flash_cmd_erase(struct spi_flash
+ {
+ u32 start, end, erase_size;
+ int ret;
+- u8 cmd[4];
++ u8 cmd[4], cmd_len;
+
+ erase_size = flash->sector_size;
+ if (offset % erase_size || len % erase_size) {
+@@ -216,7 +224,7 @@ int spi_flash_cmd_erase(struct spi_flash
+ end = start + len;
+
+ while (offset < end) {
+- spi_flash_addr(offset, cmd);
++ spi_flash_addr(flash, offset, cmd, &cmd_len);
+ offset += erase_size;
+
+ debug("SF: erase %2x %2x %2x %2x (%x)\n", cmd[0], cmd[1],
+@@ -226,7 +234,7 @@ int spi_flash_cmd_erase(struct spi_flash
+ if (ret)
+ goto out;
+
+- ret = spi_flash_cmd_write(flash->spi, cmd, sizeof(cmd), NULL, 0);
++ ret = spi_flash_cmd_write(flash->spi, cmd, cmd_len, NULL, 0);
+ if (ret)
+ goto out;
+
diff --git a/package/boot/uboot-lantiq/patches/.svn/text-base/0006-sf-add-generic-support-for-4-byte-address-mode.patch.svn-base b/package/boot/uboot-lantiq/patches/.svn/text-base/0006-sf-add-generic-support-for-4-byte-address-mode.patch.svn-base
new file mode 100644
index 0000000..1623b15
--- /dev/null
+++ b/package/boot/uboot-lantiq/patches/.svn/text-base/0006-sf-add-generic-support-for-4-byte-address-mode.patch.svn-base
@@ -0,0 +1,161 @@
+From fb9ed0ef6f0ba6b6535c64dcfcf45c161723e56f Mon Sep 17 00:00:00 2001
+From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+Date: Tue, 6 Nov 2012 19:31:38 +0100
+Subject: sf: add generic support for 4-byte address mode
+
+Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+
+--- a/drivers/mtd/spi/spi_flash.c
++++ b/drivers/mtd/spi/spi_flash.c
+@@ -18,19 +18,35 @@
+ static void spi_flash_addr(struct spi_flash *flash, u32 addr, u8 *cmd, u8 *cmd_len)
+ {
+ /* cmd[0] is actual command */
+- cmd[1] = addr >> 16;
+- cmd[2] = addr >> 8;
+- cmd[3] = addr >> 0;
+- *cmd_len = 4;
++ if (spi_flash_use_4byte_mode(flash)) {
++ cmd[1] = addr >> 24;
++ cmd[2] = addr >> 16;
++ cmd[3] = addr >> 8;
++ cmd[4] = addr >> 0;
++ *cmd_len = 5;
++ } else {
++ cmd[1] = addr >> 16;
++ cmd[2] = addr >> 8;
++ cmd[3] = addr >> 0;
++ *cmd_len = 4;
++ }
+ }
+
+ static void spi_flash_page_addr(struct spi_flash *flash, u32 page_addr, u32 byte_addr, u8 *cmd, u8 *cmd_len)
+ {
+ /* cmd[0] is actual command */
+- cmd[1] = page_addr >> 8;
+- cmd[2] = page_addr >> 0;
+- cmd[3] = byte_addr;
+- *cmd_len = 4;
++ if (spi_flash_use_4byte_mode(flash)) {
++ cmd[1] = page_addr >> 16;
++ cmd[2] = page_addr >> 8;
++ cmd[3] = page_addr >> 0;
++ cmd[4] = byte_addr;
++ *cmd_len = 5;
++ } else {
++ cmd[1] = page_addr >> 8;
++ cmd[2] = page_addr >> 0;
++ cmd[3] = byte_addr;
++ *cmd_len = 4;
++ }
+ }
+
+ static int spi_flash_read_write(struct spi_slave *spi,
+@@ -81,7 +97,7 @@ int spi_flash_cmd_write_multi(struct spi
+ unsigned long page_addr, byte_addr, page_size;
+ size_t chunk_len, actual;
+ int ret;
+- u8 cmd[4], cmd_len;
++ u8 cmd[5], cmd_len;
+
+ page_size = flash->page_size;
+ page_addr = offset / page_size;
+@@ -99,8 +115,8 @@ int spi_flash_cmd_write_multi(struct spi
+
+ spi_flash_page_addr(flash, page_addr, byte_addr, cmd, &cmd_len);
+
+- debug("PP: 0x%p => cmd = { 0x%02x 0x%02x%02x%02x } chunk_len = %zu\n",
+- buf + actual, cmd[0], cmd[1], cmd[2], cmd[3], chunk_len);
++ debug("PP: 0x%p => cmd = { 0x%02x 0x%02x%02x%02x%02x } chunk_len = %zu\n",
++ buf + actual, cmd[0], cmd[1], cmd[2], cmd[3], cmd[4], chunk_len);
+
+ ret = spi_flash_cmd_write_enable(flash);
+ if (ret < 0) {
+@@ -146,7 +162,7 @@ int spi_flash_read_common(struct spi_fla
+ int spi_flash_cmd_read_fast(struct spi_flash *flash, u32 offset,
+ size_t len, void *data)
+ {
+- u8 cmd[5], cmd_len;
++ u8 cmd[6], cmd_len;
+
+ cmd[0] = CMD_READ_ARRAY_FAST;
+ spi_flash_addr(flash, offset, cmd, &cmd_len);
+@@ -202,7 +218,7 @@ int spi_flash_cmd_erase(struct spi_flash
+ {
+ u32 start, end, erase_size;
+ int ret;
+- u8 cmd[4], cmd_len;
++ u8 cmd[5], cmd_len;
+
+ erase_size = flash->sector_size;
+ if (offset % erase_size || len % erase_size) {
+@@ -227,8 +243,8 @@ int spi_flash_cmd_erase(struct spi_flash
+ spi_flash_addr(flash, offset, cmd, &cmd_len);
+ offset += erase_size;
+
+- debug("SF: erase %2x %2x %2x %2x (%x)\n", cmd[0], cmd[1],
+- cmd[2], cmd[3], offset);
++ debug("SF: erase %2x %2x %2x %2x %2x (%x)\n", cmd[0], cmd[1],
++ cmd[2], cmd[3], cmd[4], offset);
+
+ ret = spi_flash_cmd_write_enable(flash);
+ if (ret)
+@@ -409,6 +425,12 @@ int spi_flash_probe_spl(struct spi_flash
+ goto err_manufacturer_probe;
+ }
+
++ ret = spi_flash_set_4byte_mode(flash);
++ if (ret) {
++ debug("SF: Failed to enable 4 byte mode: %d\n", ret);
++ goto err_manufacturer_probe;
++ }
++
+ spi_release_bus(spi);
+
+ return 0;
+--- a/drivers/mtd/spi/spi_flash_internal.h
++++ b/drivers/mtd/spi/spi_flash_internal.h
+@@ -97,6 +97,31 @@ int spi_flash_cmd_wait_ready(struct spi_
+ /* Erase sectors. */
+ int spi_flash_cmd_erase(struct spi_flash *flash, u32 offset, size_t len);
+
++#ifdef CONFIG_SPI_FLASH_4BYTE_MODE
++static inline int spi_flash_use_4byte_mode(struct spi_flash *flash)
++{
++ return NULL != flash->set_4byte_mode;
++}
++
++static inline int spi_flash_set_4byte_mode(struct spi_flash *flash)
++{
++ if (spi_flash_use_4byte_mode(flash))
++ return flash->set_4byte_mode(flash);
++
++ return 0;
++}
++#else
++static inline int spi_flash_use_4byte_mode(struct spi_flash *flash)
++{
++ return 0;
++}
++
++static inline int spi_flash_set_4byte_mode(struct spi_flash *flash)
++{
++ return 0;
++}
++#endif
++
+ /* Manufacturer-specific probe functions */
+ int spi_flash_probe_spansion(struct spi_flash *flash, u8 *idcode);
+ int spi_flash_probe_atmel(struct spi_flash *flash, u8 *idcode);
+--- a/include/spi_flash.h
++++ b/include/spi_flash.h
+@@ -46,6 +46,9 @@ struct spi_flash {
+ size_t len, const void *buf);
+ int (*erase)(struct spi_flash *flash, u32 offset,
+ size_t len);
++#ifdef CONFIG_SPI_FLASH_4BYTE_MODE
++ int (*set_4byte_mode)(struct spi_flash *flash);
++#endif
+ };
+
+ struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
diff --git a/package/boot/uboot-lantiq/patches/.svn/text-base/0007-sf-eon-use-16-bit-ID-for-comparison.patch.svn-base b/package/boot/uboot-lantiq/patches/.svn/text-base/0007-sf-eon-use-16-bit-ID-for-comparison.patch.svn-base
new file mode 100644
index 0000000..6836674
--- /dev/null
+++ b/package/boot/uboot-lantiq/patches/.svn/text-base/0007-sf-eon-use-16-bit-ID-for-comparison.patch.svn-base
@@ -0,0 +1,45 @@
+From d32f45357f0475a2f810752eeb9412fe692e1c0a Mon Sep 17 00:00:00 2001
+From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+Date: Wed, 7 Nov 2012 14:09:21 +0100
+Subject: sf: eon: use 16 bit ID for comparison
+
+Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+
+--- a/drivers/mtd/spi/eon.c
++++ b/drivers/mtd/spi/eon.c
+@@ -11,19 +11,19 @@
+ #include "spi_flash_internal.h"
+
+ struct eon_spi_flash_params {
+- u8 idcode1;
++ u16 idcode;
+ u16 nr_sectors;
+ const char *name;
+ };
+
+ static const struct eon_spi_flash_params eon_spi_flash_table[] = {
+ {
+- .idcode1 = 0x16,
++ .idcode = 0x3016,
+ .nr_sectors = 1024,
+ .name = "EN25Q32B",
+ },
+ {
+- .idcode1 = 0x18,
++ .idcode = 0x3018,
+ .nr_sectors = 4096,
+ .name = "EN25Q128",
+ },
+@@ -33,10 +33,11 @@ int spi_flash_probe_eon(struct spi_flash
+ {
+ const struct eon_spi_flash_params *params;
+ unsigned int i;
++ u16 id = idcode[2] | idcode[1] << 8;
+
+ for (i = 0; i < ARRAY_SIZE(eon_spi_flash_table); ++i) {
+ params = &eon_spi_flash_table[i];
+- if (params->idcode1 == idcode[2])
++ if (params->idcode == id)
+ break;
+ }
+
diff --git a/package/boot/uboot-lantiq/patches/.svn/text-base/0008-sf-eon-add-support-for-4-byte-address-mode.patch.svn-base b/package/boot/uboot-lantiq/patches/.svn/text-base/0008-sf-eon-add-support-for-4-byte-address-mode.patch.svn-base
new file mode 100644
index 0000000..c037a86
--- /dev/null
+++ b/package/boot/uboot-lantiq/patches/.svn/text-base/0008-sf-eon-add-support-for-4-byte-address-mode.patch.svn-base
@@ -0,0 +1,43 @@
+From 37254e3284f61ea495f73a78b7c8efae983781e2 Mon Sep 17 00:00:00 2001
+From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+Date: Wed, 7 Nov 2012 14:10:07 +0100
+Subject: sf: eon: add support for 4-byte address mode
+
+Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+
+--- a/drivers/mtd/spi/eon.c
++++ b/drivers/mtd/spi/eon.c
+@@ -10,6 +10,8 @@
+
+ #include "spi_flash_internal.h"
+
++#define EN25XX_EN4B 0xb7 /* Enter 4-byte mode */
++
+ struct eon_spi_flash_params {
+ u16 idcode;
+ u16 nr_sectors;
+@@ -29,6 +31,13 @@ static const struct eon_spi_flash_params
+ },
+ };
+
++static __maybe_unused int eon_set_4byte_mode(struct spi_flash *flash)
++{
++ struct spi_slave *spi = flash->spi;
++
++ return spi_flash_cmd(spi, EN25XX_EN4B, NULL, 0);
++}
++
+ int spi_flash_probe_eon(struct spi_flash *flash, u8 *idcode)
+ {
+ const struct eon_spi_flash_params *params;
+@@ -57,5 +66,10 @@ int spi_flash_probe_eon(struct spi_flash
+ flash->size = 256 * 16
+ * params->nr_sectors;
+
++#ifdef CONFIG_SPI_FLASH_4BYTE_MODE
++ if (flash->size > (1 << 24))
++ flash->set_4byte_mode = eon_set_4byte_mode;
++#endif
++
+ return 1;
+ }
diff --git a/package/boot/uboot-lantiq/patches/.svn/text-base/0009-sf-eon-add-support-for-EN25QH256.patch.svn-base b/package/boot/uboot-lantiq/patches/.svn/text-base/0009-sf-eon-add-support-for-EN25QH256.patch.svn-base
new file mode 100644
index 0000000..18f5823
--- /dev/null
+++ b/package/boot/uboot-lantiq/patches/.svn/text-base/0009-sf-eon-add-support-for-EN25QH256.patch.svn-base
@@ -0,0 +1,21 @@
+From e510be1145796cd44cf5800e187a94ad7c19e764 Mon Sep 17 00:00:00 2001
+From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+Date: Wed, 7 Nov 2012 14:10:34 +0100
+Subject: sf: eon: add support for EN25QH256
+
+Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+
+--- a/drivers/mtd/spi/eon.c
++++ b/drivers/mtd/spi/eon.c
+@@ -29,6 +29,11 @@ static const struct eon_spi_flash_params
+ .nr_sectors = 4096,
+ .name = "EN25Q128",
+ },
++ {
++ .idcode = 0x7019,
++ .nr_sectors = 8192,
++ .name = "EN25QH256",
++ },
+ };
+
+ static __maybe_unused int eon_set_4byte_mode(struct spi_flash *flash)
diff --git a/package/boot/uboot-lantiq/patches/.svn/text-base/0010-sf-spansion-fix-device-IDs-and-sector-architecture-f.patch.svn-base b/package/boot/uboot-lantiq/patches/.svn/text-base/0010-sf-spansion-fix-device-IDs-and-sector-architecture-f.patch.svn-base
new file mode 100644
index 0000000..af8c7a1
--- /dev/null
+++ b/package/boot/uboot-lantiq/patches/.svn/text-base/0010-sf-spansion-fix-device-IDs-and-sector-architecture-f.patch.svn-base
@@ -0,0 +1,30 @@
+From 81a8e9e192d53ce8b5cafd47190d6c6826519d09 Mon Sep 17 00:00:00 2001
+From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+Date: Wed, 7 Nov 2012 14:58:59 +0100
+Subject: sf: spansion: fix device IDs and sector architecture for S25FL256S
+
+Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+
+--- a/drivers/mtd/spi/spansion.c
++++ b/drivers/mtd/spi/spansion.c
+@@ -97,11 +97,18 @@ static const struct spansion_spi_flash_p
+ .name = "S25FL129P_64K",
+ },
+ {
+- .idcode1 = 0x2019,
++ .idcode1 = 0x0219,
+ .idcode2 = 0x4d01,
+ .pages_per_sector = 256,
+ .nr_sectors = 512,
+- .name = "S25FL256S",
++ .name = "S25FL256S_64K",
++ },
++ {
++ .idcode1 = 0x0219,
++ .idcode2 = 0x4d00,
++ .pages_per_sector = 1024,
++ .nr_sectors = 128,
++ .name = "S25FL256S_256K",
+ },
+ };
+
diff --git a/package/boot/uboot-lantiq/patches/.svn/text-base/0011-sf-spansion-add-support-for-4-byte-address-mode.patch.svn-base b/package/boot/uboot-lantiq/patches/.svn/text-base/0011-sf-spansion-add-support-for-4-byte-address-mode.patch.svn-base
new file mode 100644
index 0000000..9471d47
--- /dev/null
+++ b/package/boot/uboot-lantiq/patches/.svn/text-base/0011-sf-spansion-add-support-for-4-byte-address-mode.patch.svn-base
@@ -0,0 +1,55 @@
+From 0add8e5c60961d2b99174610df8d3d9d6d192b74 Mon Sep 17 00:00:00 2001
+From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+Date: Wed, 7 Nov 2012 14:16:11 +0100
+Subject: sf: spansion: add support for 4-byte address mode
+
+Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+
+--- a/drivers/mtd/spi/spansion.c
++++ b/drivers/mtd/spi/spansion.c
+@@ -31,6 +31,10 @@
+
+ #include "spi_flash_internal.h"
+
++#define S25FLXX_BRRD 0x16 /* Read Bank Register */
++#define S25FLXX_BRWR 0x17 /* Write Bank Register */
++#define S25FLXX_BAR_EXTADD (1 << 7) /* Extended address enable */
++
+ struct spansion_spi_flash_params {
+ u16 idcode1;
+ u16 idcode2;
+@@ -112,6 +116,23 @@ static const struct spansion_spi_flash_p
+ },
+ };
+
++static __maybe_unused int spansion_set_4byte_mode(struct spi_flash *flash)
++{
++ struct spi_slave *spi = flash->spi;
++ u8 bar, cmd;
++ int err;
++
++ cmd = S25FLXX_BRRD;
++ err = spi_flash_cmd(spi, cmd, &bar, 1);
++ if (err)
++ return err;
++
++ bar |= S25FLXX_BAR_EXTADD;
++ cmd = S25FLXX_BRWR;
++
++ return spi_flash_cmd_write(spi, &cmd, 1, &bar, 1);
++}
++
+ int spi_flash_probe_spansion(struct spi_flash *flash, u8 *idcode)
+ {
+ const struct spansion_spi_flash_params *params;
+@@ -144,5 +165,10 @@ int spi_flash_probe_spansion(struct spi_
+ flash->sector_size = 256 * params->pages_per_sector;
+ flash->size = flash->sector_size * params->nr_sectors;
+
++#ifdef CONFIG_SPI_FLASH_4BYTE_MODE
++ if (flash->size > (1 << 24))
++ flash->set_4byte_mode = spansion_set_4byte_mode;
++#endif
++
+ return 1;
+ }
diff --git a/package/boot/uboot-lantiq/patches/.svn/text-base/0012-sf-spansion-add-support-for-S25FL512S.patch.svn-base b/package/boot/uboot-lantiq/patches/.svn/text-base/0012-sf-spansion-add-support-for-S25FL512S.patch.svn-base
new file mode 100644
index 0000000..5f415a9
--- /dev/null
+++ b/package/boot/uboot-lantiq/patches/.svn/text-base/0012-sf-spansion-add-support-for-S25FL512S.patch.svn-base
@@ -0,0 +1,23 @@
+From bff335ac524843bc90163c3b231091a5016f8670 Mon Sep 17 00:00:00 2001
+From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+Date: Wed, 7 Nov 2012 15:07:54 +0100
+Subject: sf: spansion: add support for S25FL512S
+
+Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+
+--- a/drivers/mtd/spi/spansion.c
++++ b/drivers/mtd/spi/spansion.c
+@@ -114,6 +114,13 @@ static const struct spansion_spi_flash_p
+ .nr_sectors = 128,
+ .name = "S25FL256S_256K",
+ },
++ {
++ .idcode1 = 0x0220,
++ .idcode2 = 0x4d00,
++ .pages_per_sector = 1024,
++ .nr_sectors = 256,
++ .name = "S25FL512S_256K",
++ },
+ };
+
+ static __maybe_unused int spansion_set_4byte_mode(struct spi_flash *flash)
diff --git a/package/boot/uboot-lantiq/patches/.svn/text-base/0013-sf-macronix-add-support-for-4-byte-address-mode.patch.svn-base b/package/boot/uboot-lantiq/patches/.svn/text-base/0013-sf-macronix-add-support-for-4-byte-address-mode.patch.svn-base
new file mode 100644
index 0000000..70015c9
--- /dev/null
+++ b/package/boot/uboot-lantiq/patches/.svn/text-base/0013-sf-macronix-add-support-for-4-byte-address-mode.patch.svn-base
@@ -0,0 +1,44 @@
+From 207662a9270cc542709fbab0d25fbc361b39748c Mon Sep 17 00:00:00 2001
+From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+Date: Wed, 7 Nov 2012 15:13:49 +0100
+Subject: sf: macronix: add support for 4-byte address mode
+
+Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+
+--- a/drivers/mtd/spi/macronix.c
++++ b/drivers/mtd/spi/macronix.c
+@@ -35,6 +35,8 @@
+
+ #include "spi_flash_internal.h"
+
++#define MX25XX_EN4B 0xb7 /* Enter 4-byte mode */
++
+ struct macronix_spi_flash_params {
+ u16 idcode;
+ u16 nr_blocks;
+@@ -79,6 +81,13 @@ static const struct macronix_spi_flash_p
+ },
+ };
+
++static __maybe_unused int macronix_set_4byte_mode(struct spi_flash *flash)
++{
++ struct spi_slave *spi = flash->spi;
++
++ return spi_flash_cmd(spi, MX25XX_EN4B, NULL, 0);
++}
++
+ int spi_flash_probe_macronix(struct spi_flash *flash, u8 *idcode)
+ {
+ const struct macronix_spi_flash_params *params;
+@@ -106,6 +115,11 @@ int spi_flash_probe_macronix(struct spi_
+ flash->sector_size = 256 * 16 * 16;
+ flash->size = flash->sector_size * params->nr_blocks;
+
++#ifdef CONFIG_SPI_FLASH_4BYTE_MODE
++ if (flash->size > (1 << 24))
++ flash->set_4byte_mode = macronix_set_4byte_mode;
++#endif
++
+ /* Clear BP# bits for read-only flash */
+ spi_flash_cmd_write_status(flash, 0);
+
diff --git a/package/boot/uboot-lantiq/patches/.svn/text-base/0014-sf-macronix-add-support-for-MX25L25635E.patch.svn-base b/package/boot/uboot-lantiq/patches/.svn/text-base/0014-sf-macronix-add-support-for-MX25L25635E.patch.svn-base
new file mode 100644
index 0000000..8e33836
--- /dev/null
+++ b/package/boot/uboot-lantiq/patches/.svn/text-base/0014-sf-macronix-add-support-for-MX25L25635E.patch.svn-base
@@ -0,0 +1,21 @@
+From 0f31fef3d6a5110684ea31c5064c45fc448013d6 Mon Sep 17 00:00:00 2001
+From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+Date: Wed, 7 Nov 2012 15:14:24 +0100
+Subject: sf: macronix: add support for MX25L25635E
+
+Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+
+--- a/drivers/mtd/spi/macronix.c
++++ b/drivers/mtd/spi/macronix.c
+@@ -79,6 +79,11 @@ static const struct macronix_spi_flash_p
+ .nr_blocks = 256,
+ .name = "MX25L12855E",
+ },
++ {
++ .idcode = 0x2019,
++ .nr_blocks = 512,
++ .name = "MX25L25635E",
++ },
+ };
+
+ static __maybe_unused int macronix_set_4byte_mode(struct spi_flash *flash)
diff --git a/package/boot/uboot-lantiq/patches/.svn/text-base/0015-sf-macronix-add-support-for-MX66L51235L.patch.svn-base b/package/boot/uboot-lantiq/patches/.svn/text-base/0015-sf-macronix-add-support-for-MX66L51235L.patch.svn-base
new file mode 100644
index 0000000..fbc22e4
--- /dev/null
+++ b/package/boot/uboot-lantiq/patches/.svn/text-base/0015-sf-macronix-add-support-for-MX66L51235L.patch.svn-base
@@ -0,0 +1,21 @@
+From a2d80b6b91ac63beea31455ce8d136230c030500 Mon Sep 17 00:00:00 2001
+From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+Date: Wed, 7 Nov 2012 15:14:40 +0100
+Subject: sf: macronix: add support for MX66L51235L
+
+Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+
+--- a/drivers/mtd/spi/macronix.c
++++ b/drivers/mtd/spi/macronix.c
+@@ -84,6 +84,11 @@ static const struct macronix_spi_flash_p
+ .nr_blocks = 512,
+ .name = "MX25L25635E",
+ },
++ {
++ .idcode = 0x201A,
++ .nr_blocks = 1024,
++ .name = "MX66L51235L",
++ },
+ };
+
+ static __maybe_unused int macronix_set_4byte_mode(struct spi_flash *flash)
diff --git a/package/boot/uboot-lantiq/patches/.svn/text-base/0016-sf-add-MTD-layer-driver-for-SPI-flash-devices.patch.svn-base b/package/boot/uboot-lantiq/patches/.svn/text-base/0016-sf-add-MTD-layer-driver-for-SPI-flash-devices.patch.svn-base
new file mode 100644
index 0000000..a9ee560
--- /dev/null
+++ b/package/boot/uboot-lantiq/patches/.svn/text-base/0016-sf-add-MTD-layer-driver-for-SPI-flash-devices.patch.svn-base
@@ -0,0 +1,133 @@
+From 7f6ded11965b09daf6da44d4fa98da17b9fba36c Mon Sep 17 00:00:00 2001
+From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+Date: Tue, 6 Nov 2012 19:41:26 +0100
+Subject: sf: add MTD layer driver for SPI flash devices
+
+Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+
+--- a/drivers/mtd/spi/Makefile
++++ b/drivers/mtd/spi/Makefile
+@@ -30,6 +30,7 @@ COBJS-$(CONFIG_SPL_SPI_LOAD) += spi_spl_
+ endif
+
+ COBJS-$(CONFIG_SPI_FLASH) += spi_flash.o
++COBJS-$(CONFIG_SPI_FLASH_MTD) += spi_flash_mtd.o
+ COBJS-$(CONFIG_SPI_FLASH_ATMEL) += atmel.o
+ COBJS-$(CONFIG_SPI_FLASH_EON) += eon.o
+ COBJS-$(CONFIG_SPI_FLASH_MACRONIX) += macronix.o
+--- a/drivers/mtd/spi/spi_flash_internal.h
++++ b/drivers/mtd/spi/spi_flash_internal.h
+@@ -122,6 +122,9 @@ static inline int spi_flash_set_4byte_mo
+ }
+ #endif
+
++/* SPI flash MTD adapter init */
++int spi_flash_mtd_init(struct spi_flash *flash);
++
+ /* Manufacturer-specific probe functions */
+ int spi_flash_probe_spansion(struct spi_flash *flash, u8 *idcode);
+ int spi_flash_probe_atmel(struct spi_flash *flash, u8 *idcode);
+--- /dev/null
++++ b/drivers/mtd/spi/spi_flash_mtd.c
+@@ -0,0 +1,101 @@
++/*
++ * (C) Copyright 2012 Daniel Schwierzeck, daniel.schwierzeck@gmail.com
++ *
++ * MTD layer driver for SPI flash devices
++ *
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ */
++
++#include <common.h>
++#include <malloc.h>
++#include <asm/errno.h>
++#include <linux/mtd/mtd.h>
++#include <spi_flash.h>
++
++static struct mtd_info sf_mtd_info;
++static char sf_mtd_name[8];
++
++static int spi_flash_mtd_erase(struct mtd_info *mtd, struct erase_info *instr)
++{
++ struct spi_flash *flash = mtd->priv;
++ int err;
++
++ instr->state = MTD_ERASING;
++
++ err = spi_flash_erase(flash, instr->addr, instr->len);
++ if (err) {
++ instr->state = MTD_ERASE_FAILED;
++ instr->fail_addr = MTD_FAIL_ADDR_UNKNOWN;
++ return -EIO;
++ }
++
++ instr->state = MTD_ERASE_DONE;
++ mtd_erase_callback(instr);
++
++ return 0;
++}
++
++static int spi_flash_mtd_read(struct mtd_info *mtd, loff_t from, size_t len,
++ size_t *retlen, u_char *buf)
++{
++ struct spi_flash *flash = mtd->priv;
++ int err;
++
++ err = spi_flash_read(flash, from, len, buf);
++ if (!err)
++ *retlen = len;
++
++ return err;
++}
++
++static int spi_flash_mtd_write(struct mtd_info *mtd, loff_t to, size_t len,
++ size_t *retlen, const u_char *buf)
++{
++ struct spi_flash *flash = mtd->priv;
++ int err;
++
++ err = spi_flash_write(flash, to, len, buf);
++ if (!err)
++ *retlen = len;
++
++ return err;
++}
++
++static void spi_flash_mtd_sync(struct mtd_info *mtd)
++{
++}
++
++static int spi_flash_mtd_number(void)
++{
++#ifdef CONFIG_SYS_MAX_FLASH_BANKS
++ return CONFIG_SYS_MAX_FLASH_BANKS;
++#else
++ return 0;
++#endif
++}
++
++int spi_flash_mtd_init(struct spi_flash *flash)
++{
++ memset(&sf_mtd_info, 0, sizeof(sf_mtd_info));
++ sprintf(sf_mtd_name, "nor%d", spi_flash_mtd_number());
++
++ sf_mtd_info.name = sf_mtd_name;
++ sf_mtd_info.type = MTD_NORFLASH;
++ sf_mtd_info.flags = MTD_CAP_NORFLASH;
++ sf_mtd_info.writesize = 1;
++
++ sf_mtd_info.erase = spi_flash_mtd_erase;
++ sf_mtd_info.read = spi_flash_mtd_read;
++ sf_mtd_info.write = spi_flash_mtd_write;
++ sf_mtd_info.sync = spi_flash_mtd_sync;
++
++ sf_mtd_info.size = flash->size;
++ sf_mtd_info.priv = flash;
++
++ /* Only uniform flash devices for now */
++ sf_mtd_info.numeraseregions = 0;
++ sf_mtd_info.erasesize = flash->sector_size;
++
++ return add_mtd_device(&sf_mtd_info);
++}
diff --git a/package/boot/uboot-lantiq/patches/.svn/text-base/0017-sf-add-init-function.patch.svn-base b/package/boot/uboot-lantiq/patches/.svn/text-base/0017-sf-add-init-function.patch.svn-base
new file mode 100644
index 0000000..2d29051
--- /dev/null
+++ b/package/boot/uboot-lantiq/patches/.svn/text-base/0017-sf-add-init-function.patch.svn-base
@@ -0,0 +1,57 @@
+From aa9d5d64ca6441cb24e22dc3c1f707da62da2887 Mon Sep 17 00:00:00 2001
+From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+Date: Tue, 6 Nov 2012 19:35:17 +0100
+Subject: sf: add init function
+
+Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+
+--- a/drivers/mtd/spi/spi_flash.c
++++ b/drivers/mtd/spi/spi_flash.c
+@@ -482,3 +482,36 @@ void spi_flash_free(struct spi_flash *fl
+ spi_flash_free_spl(flash);
+ free(flash);
+ }
++
++#ifdef CONFIG_SPI_FLASH_MTD
++static int spi_flash_mtd_register(void)
++{
++ struct spi_flash *flash;
++ int err;
++
++ flash = spi_flash_probe(CONFIG_ENV_SPI_BUS, CONFIG_ENV_SPI_CS,
++ CONFIG_ENV_SPI_MAX_HZ, CONFIG_ENV_SPI_MODE);
++ if (!flash)
++ return -1;
++
++ err = spi_flash_mtd_init(flash);
++ if (err)
++ spi_flash_free(flash);
++
++ return err;
++}
++#else
++static int spi_flash_mtd_register(void)
++{
++ return 0;
++}
++#endif
++
++int spi_flash_init(void)
++{
++ int err;
++
++ err = spi_flash_mtd_register();
++
++ return err;
++}
+--- a/include/spi_flash.h
++++ b/include/spi_flash.h
+@@ -51,6 +51,8 @@ struct spi_flash {
+ #endif
+ };
+
++int spi_flash_init(void);
++
+ struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
+ unsigned int max_hz, unsigned int spi_mode);
+ void spi_flash_free(struct spi_flash *flash);
diff --git a/package/boot/uboot-lantiq/patches/.svn/text-base/0018-MIPS-add-SPI-flash-init-hook.patch.svn-base b/package/boot/uboot-lantiq/patches/.svn/text-base/0018-MIPS-add-SPI-flash-init-hook.patch.svn-base
new file mode 100644
index 0000000..71f094b
--- /dev/null
+++ b/package/boot/uboot-lantiq/patches/.svn/text-base/0018-MIPS-add-SPI-flash-init-hook.patch.svn-base
@@ -0,0 +1,47 @@
+From 888b33e84082fe72d60d528c05c885c0c9d70bc4 Mon Sep 17 00:00:00 2001
+From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+Date: Tue, 6 Nov 2012 21:19:43 +0100
+Subject: MIPS: add SPI flash init hook
+
+Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+
+--- a/arch/mips/lib/board.c
++++ b/arch/mips/lib/board.c
+@@ -32,6 +32,7 @@
+ #include <nand.h>
+ #include <onenand_uboot.h>
+ #include <spi.h>
++#include <spi_flash.h>
+
+ #ifdef CONFIG_BITBANGMII
+ #include <miiphy.h>
+@@ -312,6 +313,16 @@ void board_init_r(gd_t *id, ulong dest_a
+ onenand_init();
+ #endif
+
++#ifdef CONFIG_CMD_SPI
++ puts("SPI: ");
++ spi_init(); /* go init the SPI */
++ puts("ready\n");
++#endif
++
++#if defined(CONFIG_SPI_FLASH)
++ spi_flash_init();
++#endif
++
+ /* relocate environment function pointers etc. */
+ env_relocate();
+
+@@ -335,12 +346,6 @@ void board_init_r(gd_t *id, ulong dest_a
+ /* Initialize from environment */
+ load_addr = getenv_ulong("loadaddr", 16, load_addr);
+
+-#ifdef CONFIG_CMD_SPI
+- puts("SPI: ");
+- spi_init(); /* go init the SPI */
+- puts("ready\n");
+-#endif
+-
+ #if defined(CONFIG_MISC_INIT_R)
+ /* miscellaneous platform dependent initialisations */
+ misc_init_r();
diff --git a/package/boot/uboot-lantiq/patches/.svn/text-base/0019-net-switchlib-add-framework-for-ethernet-switch-driv.patch.svn-base b/package/boot/uboot-lantiq/patches/.svn/text-base/0019-net-switchlib-add-framework-for-ethernet-switch-driv.patch.svn-base
new file mode 100644
index 0000000..a215d1a
--- /dev/null
+++ b/package/boot/uboot-lantiq/patches/.svn/text-base/0019-net-switchlib-add-framework-for-ethernet-switch-driv.patch.svn-base
@@ -0,0 +1,239 @@
+From d8b1597130d228bc7e2bafd0c8d097529018c833 Mon Sep 17 00:00:00 2001
+From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+Date: Wed, 29 Aug 2012 22:08:15 +0200
+Subject: net: switchlib: add framework for ethernet switch drivers
+
+Add a generic framework similar to phylib for ethernet switch
+drivers and devices. This is useful to share the init and
+setup code for switch devices across different boards.
+
+Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+Cc: Joe Hershberger <joe.hershberger@gmail.com>
+
+--- a/Makefile
++++ b/Makefile
+@@ -291,6 +291,7 @@ LIBS-y += drivers/mtd/ubi/libubi.o
+ LIBS-y += drivers/mtd/spi/libspi_flash.o
+ LIBS-y += drivers/net/libnet.o
+ LIBS-y += drivers/net/phy/libphy.o
++LIBS-y += drivers/net/switch/libswitch.o
+ LIBS-y += drivers/pci/libpci.o
+ LIBS-y += drivers/pcmcia/libpcmcia.o
+ LIBS-y += drivers/power/libpower.o \
+--- /dev/null
++++ b/drivers/net/switch/Makefile
+@@ -0,0 +1,31 @@
++#
++# This file is released under the terms of GPL v2 and any later version.
++# See the file COPYING in the root directory of the source tree for details.
++#
++# Copyright (C) 2000-2011 Wolfgang Denk, DENX Software Engineering, wd@denx.de
++# Copyright (C) 2011-2012 Daniel Schwierzeck, daniel.schwierzeck@gmail.com
++#
++
++include $(TOPDIR)/config.mk
++
++LIB := $(obj)libswitch.o
++
++COBJS-$(CONFIG_SWITCH_MULTI) += switch.o
++
++COBJS := $(COBJS-y)
++SRCS := $(COBJS:.o=.c)
++OBJS := $(addprefix $(obj),$(COBJS))
++
++all: $(LIB)
++
++$(LIB): $(obj).depend $(OBJS)
++ $(call cmd_link_o_target, $(OBJS))
++
++#########################################################################
++
++# defines $(obj).depend target
++include $(SRCTREE)/rules.mk
++
++sinclude $(obj).depend
++
++#########################################################################
+--- /dev/null
++++ b/drivers/net/switch/switch.c
+@@ -0,0 +1,63 @@
++/*
++ * Copyright (C) 2011-2012 Daniel Schwierzeck, daniel.schwierzeck@gmail.com
++ *
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ */
++
++#include <common.h>
++#include <netdev.h>
++#include <miiphy.h>
++#include <switch.h>
++
++static struct list_head switch_drivers;
++static struct list_head switch_devices;
++
++void switch_init(void)
++{
++ INIT_LIST_HEAD(&switch_drivers);
++ INIT_LIST_HEAD(&switch_devices);
++
++ board_switch_init();
++}
++
++void switch_driver_register(struct switch_driver *drv)
++{
++ INIT_LIST_HEAD(&drv->list);
++ list_add_tail(&drv->list, &switch_drivers);
++}
++
++int switch_device_register(struct switch_device *dev)
++{
++ struct switch_driver *drv;
++
++ /* Add switch device only, if an adequate driver is registered */
++ list_for_each_entry(drv, &switch_drivers, list) {
++ if (!strcmp(drv->name, dev->name)) {
++ dev->drv = drv;
++
++ INIT_LIST_HEAD(&dev->list);
++ list_add_tail(&dev->list, &switch_devices);
++
++ return 0;
++ }
++ }
++
++ return -1;
++}
++
++struct switch_device *switch_connect(struct mii_dev *bus)
++{
++ struct switch_device *sw;
++ int err;
++
++ list_for_each_entry(sw, &switch_devices, list) {
++ sw->bus = bus;
++
++ err = sw->drv->probe(sw);
++ if (!err)
++ return sw;
++ }
++
++ return NULL;
++}
+--- /dev/null
++++ b/include/switch.h
+@@ -0,0 +1,95 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#ifndef __SWITCH_H
++#define __SWITCH_H
++
++#include <linux/list.h>
++
++#define SWITCH_NAME_SIZE 32
++
++struct switch_device;
++struct mii_dev;
++
++struct switch_driver {
++ struct list_head list;
++
++ /* Switch device name */
++ const char name[SWITCH_NAME_SIZE];
++
++ /*
++ * Called to probe the switch chip. Must return 0 if the switch
++ * chip matches the given switch device/driver combination. Otherwise
++ * 1 must be returned.
++ */
++ int (*probe) (struct switch_device *dev);
++
++ /*
++ * Called to initialize the switch chip.
++ */
++ void (*setup) (struct switch_device *dev);
++};
++
++struct switch_device {
++ struct list_head list;
++ struct switch_driver *drv;
++
++ /* MII bus the switch chip is connected to */
++ struct mii_dev *bus;
++
++ /* Switch device name */
++ const char name[SWITCH_NAME_SIZE];
++
++ /* Bitmask for board specific setup of used switch ports */
++ u16 port_mask;
++
++ /* Number of switch port that is connected to host CPU */
++ u16 cpu_port;
++};
++
++/*
++ * Board specific switch initialization.
++ *
++ * Called from switch_init to register the board specific switch_device
++ * structure.
++ */
++extern int board_switch_init(void);
++
++/* Initialize switch subsystem */
++#ifdef CONFIG_SWITCH_MULTI
++extern void switch_init(void);
++#else
++static inline void switch_init(void)
++{
++}
++#endif
++
++/* Register a switch driver */
++extern void switch_driver_register(struct switch_driver *drv);
++
++/* Register a switch device */
++extern int switch_device_register(struct switch_device *dev);
++
++/*
++ * Probe the available switch chips and connect the found one
++ * with the given MII bus
++ */
++extern struct switch_device *switch_connect(struct mii_dev *bus);
++
++/*
++ * Setup the given switch device
++ */
++static inline void switch_setup(struct switch_device *dev)
++{
++ if (dev->drv->setup)
++ dev->drv->setup(dev);
++}
++
++/* Init functions for supported Switch drivers */
++
++#endif /* __SWITCH_H */
++
+--- a/net/eth.c
++++ b/net/eth.c
+@@ -26,6 +26,7 @@
+ #include <net.h>
+ #include <miiphy.h>
+ #include <phy.h>
++#include <switch.h>
+
+ void eth_parse_enetaddr(const char *addr, uchar *enetaddr)
+ {
+@@ -303,6 +304,8 @@ int eth_initialize(bd_t *bis)
+ phy_init();
+ #endif
+
++ switch_init();
++
+ eth_env_init(bis);
+
+ /*
diff --git a/package/boot/uboot-lantiq/patches/.svn/text-base/0020-net-switchlib-add-driver-for-Lantiq-PSB697X-switch-f.patch.svn-base b/package/boot/uboot-lantiq/patches/.svn/text-base/0020-net-switchlib-add-driver-for-Lantiq-PSB697X-switch-f.patch.svn-base
new file mode 100644
index 0000000..c017e0f
--- /dev/null
+++ b/package/boot/uboot-lantiq/patches/.svn/text-base/0020-net-switchlib-add-driver-for-Lantiq-PSB697X-switch-f.patch.svn-base
@@ -0,0 +1,162 @@
+From b8c666eda693906488637c414db9db35b6760e4a Mon Sep 17 00:00:00 2001
+From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+Date: Wed, 29 Aug 2012 22:08:15 +0200
+Subject: net: switchlib: add driver for Lantiq PSB697X switch family
+
+Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+
+--- a/drivers/net/switch/Makefile
++++ b/drivers/net/switch/Makefile
+@@ -11,6 +11,7 @@ include $(TOPDIR)/config.mk
+ LIB := $(obj)libswitch.o
+
+ COBJS-$(CONFIG_SWITCH_MULTI) += switch.o
++COBJS-$(CONFIG_SWITCH_PSB697X) += psb697x.o
+
+ COBJS := $(COBJS-y)
+ SRCS := $(COBJS:.o=.c)
+--- /dev/null
++++ b/drivers/net/switch/psb697x.c
+@@ -0,0 +1,119 @@
++/*
++ * Copyright (C) 2011-2012 Daniel Schwierzeck, daniel.schwierzeck@gmail.com
++ *
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ */
++
++#include <common.h>
++#include <malloc.h>
++#include <switch.h>
++#include <miiphy.h>
++
++#define PSB697X_CHIPID1 0x2599
++#define PSB697X_PORT_COUNT 7
++
++#define PSB697X_PORT_BASE(p) (p * 0x20)
++#define PSB697X_REG_PS(p) (PSB697X_PORT_BASE(p) + 0x00)
++#define PSB697X_REG_PBC(p) (PSB697X_PORT_BASE(p) + 0x01)
++#define PSB697X_REG_PEC(p) (PSB697X_PORT_BASE(p) + 0x02)
++
++#define PSB697X_REG_SGC1 0x0E0 /* Switch Global Control Register 1 */
++#define PSB697X_REG_SGC2 0x0E1 /* Switch Global Control Register 2 */
++#define PSB697X_REG_CMH 0x0E2 /* CPU Port & Mirror Control */
++#define PSB697X_REG_MIICR 0x0F5 /* MII Port Control */
++#define PSB697X_REG_CI0 0x100 /* Chip Identifier 0 */
++#define PSB697X_REG_CI1 0x101 /* Chip Identifier 1 */
++#define PSB697X_REG_MIIAC 0x120 /* MII Indirect Access Control */
++#define PSB697X_REG_MIIWD 0x121 /* MII Indirect Write Data */
++#define PSB697X_REG_MIIRD 0x122 /* MII Indirect Read Data */
++
++#define PSB697X_REG_PORT_FLP (1 << 2) /* Force link up */
++#define PSB697X_REG_PORT_FLD (1 << 1) /* Force link down */
++
++#define PSB697X_REG_SGC2_SE (1 << 15) /* Switch enable */
++
++#define PSB697X_REG_CMH_CPN_MASK 0x7
++#define PSB697X_REG_CMH_CPN_SHIFT 5
++
++
++static inline int psb697x_mii_read(struct mii_dev *bus, u16 reg)
++{
++ int ret;
++
++ ret = bus->read(bus, (reg >> 5) & 0x1f, MDIO_DEVAD_NONE, reg & 0x1f);
++
++ return ret;
++}
++
++static inline int psb697x_mii_write(struct mii_dev *bus, u16 reg, u16 val)
++{
++ int ret;
++
++ ret = bus->write(bus, (reg >> 5) & 0x1f, MDIO_DEVAD_NONE,
++ reg & 0x1f, val);
++
++ return ret;
++}
++
++static int psb697x_probe(struct switch_device *dev)
++{
++ struct mii_dev *bus = dev->bus;
++ int ci1;
++
++ ci1 = psb697x_mii_read(bus, PSB697X_REG_CI1);
++
++ if (ci1 == PSB697X_CHIPID1)
++ return 0;
++
++ return 1;
++}
++
++static void psb697x_setup(struct switch_device *dev)
++{
++ struct mii_dev *bus = dev->bus;
++ int i, state;
++
++ /* Enable switch */
++ psb697x_mii_write(bus, PSB697X_REG_SGC2, PSB697X_REG_SGC2_SE);
++
++ /*
++ * Force 100 Mbps as default value for CPU ports 5 and 6 to get
++ * full speed.
++ */
++ psb697x_mii_write(bus, PSB697X_REG_MIICR, 0x0773);
++
++ for (i = 0; i < PSB697X_PORT_COUNT; i++) {
++ state = dev->port_mask & (1 << i);
++
++ /*
++ * Software workaround from Errata Sheet:
++ * Force link down and reset internal PHY, keep that state
++ * for all unconnected ports and disable force link down
++ * for all connected ports
++ */
++ psb697x_mii_write(bus, PSB697X_REG_PBC(i),
++ PSB697X_REG_PORT_FLD);
++
++ if (i == dev->cpu_port)
++ /* Force link up for CPU port */
++ psb697x_mii_write(bus, PSB697X_REG_PBC(i),
++ PSB697X_REG_PORT_FLP);
++ else if (state)
++ /* Disable force link down for active LAN ports */
++ psb697x_mii_write(bus, PSB697X_REG_PBC(i), 0);
++ }
++}
++
++static struct switch_driver psb697x_drv = {
++ .name = "psb697x",
++};
++
++void switch_psb697x_init(void)
++{
++ /* For archs with manual relocation */
++ psb697x_drv.probe = psb697x_probe;
++ psb697x_drv.setup = psb697x_setup;
++
++ switch_driver_register(&psb697x_drv);
++}
+--- a/drivers/net/switch/switch.c
++++ b/drivers/net/switch/switch.c
+@@ -18,6 +18,10 @@ void switch_init(void)
+ INIT_LIST_HEAD(&switch_drivers);
+ INIT_LIST_HEAD(&switch_devices);
+
++#if defined(CONFIG_SWITCH_PSB697X)
++ switch_psb697x_init();
++#endif
++
+ board_switch_init();
+ }
+
+--- a/include/switch.h
++++ b/include/switch.h
+@@ -90,6 +90,7 @@ static inline void switch_setup(struct s
+ }
+
+ /* Init functions for supported Switch drivers */
++extern void switch_psb697x_init(void);
+
+ #endif /* __SWITCH_H */
+
diff --git a/package/boot/uboot-lantiq/patches/.svn/text-base/0021-net-switchlib-add-driver-for-Lantiq-ADM6996I-switch-.patch.svn-base b/package/boot/uboot-lantiq/patches/.svn/text-base/0021-net-switchlib-add-driver-for-Lantiq-ADM6996I-switch-.patch.svn-base
new file mode 100644
index 0000000..342fa46
--- /dev/null
+++ b/package/boot/uboot-lantiq/patches/.svn/text-base/0021-net-switchlib-add-driver-for-Lantiq-ADM6996I-switch-.patch.svn-base
@@ -0,0 +1,158 @@
+From fcbbb1beb2ae862f5c703c5719ed0e155cbbf82f Mon Sep 17 00:00:00 2001
+From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+Date: Wed, 29 Aug 2012 22:08:16 +0200
+Subject: net: switchlib: add driver for Lantiq ADM6996I switch family
+
+Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+
+--- a/drivers/net/switch/Makefile
++++ b/drivers/net/switch/Makefile
+@@ -12,6 +12,7 @@ LIB := $(obj)libswitch.o
+
+ COBJS-$(CONFIG_SWITCH_MULTI) += switch.o
+ COBJS-$(CONFIG_SWITCH_PSB697X) += psb697x.o
++COBJS-$(CONFIG_SWITCH_ADM6996I) += adm6996i.o
+
+ COBJS := $(COBJS-y)
+ SRCS := $(COBJS:.o=.c)
+--- /dev/null
++++ b/drivers/net/switch/adm6996i.c
+@@ -0,0 +1,116 @@
++/*
++ * Copyright (C) 2011-2012 Daniel Schwierzeck, daniel.schwierzeck@gmail.com
++ *
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ */
++
++#include <common.h>
++#include <malloc.h>
++#include <switch.h>
++#include <miiphy.h>
++
++#define ADM6996I_CHIPID0 0x1020
++#define ADM6996I_CHIPID1 0x0007
++#define ADM6996I_PORT_COUNT 6
++
++#define ADM6996I_REG_P0BC 0x001 /* P0 Basic Control */
++#define ADM6996I_REG_P1BC 0x003 /* P1 Basic Control */
++#define ADM6996I_REG_P2BC 0x005 /* P2 Basic Control */
++#define ADM6996I_REG_P3BC 0x007 /* P3 Basic Control */
++#define ADM6996I_REG_P4BC 0x008 /* P4 Basic Control */
++#define ADM6996I_REG_P5BC 0x009 /* P5 Basic Control */
++
++#define ADM6996I_REG_P0EC 0x002 /* P0 Extended Control */
++#define ADM6996I_REG_P1EC 0x002 /* P1 Extended Control */
++#define ADM6996I_REG_P2EC 0x004 /* P2 Extended Control */
++#define ADM6996I_REG_P3EC 0x004 /* P3 Extended Control */
++#define ADM6996I_REG_P4EC 0x006 /* P4 Extended Control */
++#define ADM6996I_REG_P5EC 0x006 /* P5 Extended Control */
++
++#define ADM6996I_REG_SC4 0x012 /* System Control 4 */
++
++#define ADM6996I_REG_CI0 0xA0 /* Chip Identifier 0 */
++#define ADM6996I_REG_CI1 0xA1 /* Chip Identifier 1 */
++
++#define ADM6996I_REG_PXBC_DEFAULT 0x040F
++#define ADM6996I_REG_PXBC_CROSS_EE (1 << 15)
++#define ADM6996I_REG_PXBC_PD (1 << 5)
++
++#define ADM6996I_REG_SC4_DEFAULT 0x3600
++#define ADM6996I_REG_SC4_LED_ENABLE (1 << 1)
++
++#define ADM6996I_REG_CI0_PC_MASK 0xFFF0
++#define ADM6996I_REG_CI0_VN_MASK 0xF
++#define ADM6996I_REG_CI1_PC_MASK 0xF
++
++
++static inline int adm6996i_mii_read(struct mii_dev *bus, u16 reg)
++{
++ int ret;
++
++ ret = bus->read(bus, (reg >> 5) & 0x1f, MDIO_DEVAD_NONE, reg & 0x1f);
++
++ return ret;
++}
++
++static inline int adm6996i_mii_write(struct mii_dev *bus, u16 reg, u16 val)
++{
++ int ret;
++
++ ret = bus->write(bus, (reg >> 5) & 0x1f, MDIO_DEVAD_NONE,
++ reg & 0x1f, val);
++
++ return ret;
++}
++
++static int adm6996i_probe(struct switch_device *dev)
++{
++ struct mii_dev *bus = dev->bus;
++ u16 ci0, ci1;
++
++ ci0 = adm6996i_mii_read(bus, ADM6996I_REG_CI0);
++ ci1 = adm6996i_mii_read(bus, ADM6996I_REG_CI1);
++
++ ci0 &= ADM6996I_REG_CI0_PC_MASK;
++ ci1 &= ADM6996I_REG_CI1_PC_MASK;
++
++ if (ci0 == ADM6996I_CHIPID0 && ci1 == ADM6996I_CHIPID1)
++ return 0;
++
++ return 1;
++}
++
++static void adm6996i_setup(struct switch_device *dev)
++{
++ struct mii_dev *bus = dev->bus;
++ u16 val;
++
++ /*
++ * Write default values (Port enable, 100 Mbps, Full Duplex,
++ * Auto negotiation, Flow control) and enable crossover auto-detect
++ */
++ val = ADM6996I_REG_PXBC_DEFAULT | ADM6996I_REG_PXBC_CROSS_EE;
++ adm6996i_mii_write(bus, ADM6996I_REG_P0BC, val);
++ adm6996i_mii_write(bus, ADM6996I_REG_P1BC, val);
++ adm6996i_mii_write(bus, ADM6996I_REG_P2BC, val);
++ adm6996i_mii_write(bus, ADM6996I_REG_P3BC, val);
++ adm6996i_mii_write(bus, ADM6996I_REG_P4BC, val);
++ adm6996i_mii_write(bus, ADM6996I_REG_P5BC, val);
++
++ val = ADM6996I_REG_SC4_DEFAULT | ADM6996I_REG_SC4_LED_ENABLE;
++ adm6996i_mii_write(bus, ADM6996I_REG_SC4, val);
++}
++
++static struct switch_driver adm6996i_drv = {
++ .name = "adm6996i",
++};
++
++void switch_adm6996i_init(void)
++{
++ /* For archs with manual relocation */
++ adm6996i_drv.probe = adm6996i_probe;
++ adm6996i_drv.setup = adm6996i_setup;
++
++ switch_driver_register(&adm6996i_drv);
++}
+--- a/drivers/net/switch/switch.c
++++ b/drivers/net/switch/switch.c
+@@ -21,6 +21,9 @@ void switch_init(void)
+ #if defined(CONFIG_SWITCH_PSB697X)
+ switch_psb697x_init();
+ #endif
++#if defined(CONFIG_SWITCH_ADM6996I)
++ switch_adm6996i_init();
++#endif
+
+ board_switch_init();
+ }
+--- a/include/switch.h
++++ b/include/switch.h
+@@ -91,6 +91,7 @@ static inline void switch_setup(struct s
+
+ /* Init functions for supported Switch drivers */
+ extern void switch_psb697x_init(void);
++extern void switch_adm6996i_init(void);
+
+ #endif /* __SWITCH_H */
+
diff --git a/package/boot/uboot-lantiq/patches/.svn/text-base/0022-net-switchlib-add-driver-for-Atheros-AR8216.patch.svn-base b/package/boot/uboot-lantiq/patches/.svn/text-base/0022-net-switchlib-add-driver-for-Atheros-AR8216.patch.svn-base
new file mode 100644
index 0000000..127c0d8
--- /dev/null
+++ b/package/boot/uboot-lantiq/patches/.svn/text-base/0022-net-switchlib-add-driver-for-Atheros-AR8216.patch.svn-base
@@ -0,0 +1,158 @@
+From 16b8c52f80f20e07866e397ff52ff9658766437b Mon Sep 17 00:00:00 2001
+From: Luka Perkov <luka@openwrt.org>
+Date: Wed, 29 Aug 2012 22:08:16 +0200
+Subject: net: switchlib: add driver for Atheros AR8216
+
+Signed-off-by: Luka Perkov <luka@openwrt.org>
+Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+
+--- a/drivers/net/switch/Makefile
++++ b/drivers/net/switch/Makefile
+@@ -13,6 +13,7 @@ LIB := $(obj)libswitch.o
+ COBJS-$(CONFIG_SWITCH_MULTI) += switch.o
+ COBJS-$(CONFIG_SWITCH_PSB697X) += psb697x.o
+ COBJS-$(CONFIG_SWITCH_ADM6996I) += adm6996i.o
++COBJS-$(CONFIG_SWITCH_AR8216) += ar8216.o
+
+ COBJS := $(COBJS-y)
+ SRCS := $(COBJS:.o=.c)
+--- /dev/null
++++ b/drivers/net/switch/ar8216.c
+@@ -0,0 +1,115 @@
++/*
++ * Copyright (C) 2012 Luka Perkov <luka@openwrt.org>
++ *
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ */
++
++#include <common.h>
++#include <malloc.h>
++#include <miiphy.h>
++#include <switch.h>
++#include <netdev.h>
++
++#define BITS(_s, _n) (((1UL << (_n)) - 1) << _s)
++
++#define AR8216_REG_CTRL 0x0000
++#define AR8216_CTRL_REVISION BITS(0, 8)
++#define AR8216_CTRL_VERSION BITS(8, 8)
++
++#define AR8216_PROBE_RETRIES 10
++
++static void split_addr(u32 regaddr, u16 *r1, u16 *r2, u16 *page)
++{
++ regaddr >>= 1;
++ *r1 = regaddr & 0x1e;
++
++ regaddr >>= 5;
++ *r2 = regaddr & 0x7;
++
++ regaddr >>= 3;
++ *page = regaddr & 0x1ff;
++}
++
++static int ar8216_mii_read(struct mii_dev *bus, u32 reg)
++{
++ u16 r1, r2, page;
++ u16 lo, hi;
++
++ split_addr(reg, &r1, &r2, &page);
++
++ bus->write(bus, 0x18, MDIO_DEVAD_NONE, 0, page);
++ __udelay(1000);
++
++ lo = bus->read(bus, 0x10 | r2, MDIO_DEVAD_NONE, r1);
++ hi = bus->read(bus, 0x10 | r2, MDIO_DEVAD_NONE, r1 + 1);
++
++ return (hi << 16) | lo;
++}
++
++static void ar8216_mii_write(struct mii_dev *bus, u16 reg, u32 val)
++{
++ u16 r1, r2, r3;
++ u16 lo, hi;
++
++ split_addr((u32) reg, &r1, &r2, &r3);
++
++ bus->write(bus, 0x18, MDIO_DEVAD_NONE, 0, r3);
++ __udelay(1000);
++
++ lo = val & 0xffff;
++ hi = (u16) (val >> 16);
++ bus->write(bus, 0x10 | r2, MDIO_DEVAD_NONE, r1 + 1, hi);
++ bus->write(bus, 0x10 | r2, MDIO_DEVAD_NONE, r1, lo);
++}
++
++static int ar8216_probe(struct switch_device *dev)
++{
++ struct mii_dev *bus = dev->bus;
++ u32 val;
++ u16 id;
++
++ val = ar8216_mii_read(bus, AR8216_REG_CTRL);
++ if (val == ~0)
++ return 1;
++
++ id = val & (AR8216_CTRL_REVISION | AR8216_CTRL_VERSION);
++
++ switch (id) {
++ case 0x0101:
++ return 0;
++ default:
++ return 1;
++ }
++}
++
++static void ar8216_setup(struct switch_device *dev)
++{
++ struct mii_dev *bus = dev->bus;
++
++ ar8216_mii_write(bus, 0x200, 0x200);
++ ar8216_mii_write(bus, 0x300, 0x200);
++ ar8216_mii_write(bus, 0x400, 0x200);
++ ar8216_mii_write(bus, 0x500, 0x200);
++ ar8216_mii_write(bus, 0x600, 0x7d);
++ ar8216_mii_write(bus, 0x38, 0xc000050e);
++ ar8216_mii_write(bus, 0x104, 0x4004);
++ ar8216_mii_write(bus, 0x60, 0xffffffff);
++ ar8216_mii_write(bus, 0x64, 0xaaaaaaaa);
++ ar8216_mii_write(bus, 0x68, 0x55555555);
++ ar8216_mii_write(bus, 0x6c, 0x0);
++ ar8216_mii_write(bus, 0x70, 0x41af);
++}
++
++static struct switch_driver ar8216_drv = {
++ .name = "ar8216",
++};
++
++void switch_ar8216_init(void)
++{
++ /* for archs with manual relocation */
++ ar8216_drv.probe = ar8216_probe;
++ ar8216_drv.setup = ar8216_setup;
++
++ switch_driver_register(&ar8216_drv);
++}
+--- a/drivers/net/switch/switch.c
++++ b/drivers/net/switch/switch.c
+@@ -24,6 +24,9 @@ void switch_init(void)
+ #if defined(CONFIG_SWITCH_ADM6996I)
+ switch_adm6996i_init();
+ #endif
++#if defined(CONFIG_SWITCH_AR8216)
++ switch_ar8216_init();
++#endif
+
+ board_switch_init();
+ }
+--- a/include/switch.h
++++ b/include/switch.h
+@@ -92,6 +92,7 @@ static inline void switch_setup(struct s
+ /* Init functions for supported Switch drivers */
+ extern void switch_psb697x_init(void);
+ extern void switch_adm6996i_init(void);
++extern void switch_ar8216_init(void);
+
+ #endif /* __SWITCH_H */
+
diff --git a/package/boot/uboot-lantiq/patches/.svn/text-base/0023-MIPS-add-support-for-Lantiq-XWAY-SoCs.patch.svn-base b/package/boot/uboot-lantiq/patches/.svn/text-base/0023-MIPS-add-support-for-Lantiq-XWAY-SoCs.patch.svn-base
new file mode 100644
index 0000000..2582c16
--- /dev/null
+++ b/package/boot/uboot-lantiq/patches/.svn/text-base/0023-MIPS-add-support-for-Lantiq-XWAY-SoCs.patch.svn-base
@@ -0,0 +1,9496 @@
+From ed2effe0839929d00f05ec0e1e16fb467f324e1b Mon Sep 17 00:00:00 2001
+From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+Date: Thu, 20 Dec 2012 19:05:54 +0100
+Subject: MIPS: add support for Lantiq XWAY SoCs
+
+Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+
+--- a/.gitignore
++++ b/.gitignore
+@@ -44,6 +44,13 @@
+ /u-boot.sb
+ /u-boot.geany
+ /include/u-boot.lst
++/u-boot.bin.lzma
++/u-boot.bin.lzo
++/u-boot.ltq.lzma.norspl
++/u-boot.ltq.lzo.norspl
++/u-boot.ltq.norspl
++/u-boot.lzma.img
++/u-boot.lzo.img
+
+ #
+ # Generated files
+--- a/Makefile
++++ b/Makefile
+@@ -441,6 +441,12 @@ $(obj)u-boot.bin: $(obj)u-boot
+ $(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
+ $(BOARD_SIZE_CHECK)
+
++$(obj)u-boot.bin.lzma: $(obj)u-boot.bin
++ cat $< | lzma -9 -f - > $@
++
++$(obj)u-boot.bin.lzo: $(obj)u-boot.bin
++ cat $< | lzop -9 -f - > $@
++
+ $(obj)u-boot.ldr: $(obj)u-boot
+ $(CREATE_LDR_ENV)
+ $(LDR) -T $(CONFIG_BFIN_CPU) -c $@ $< $(LDR_FLAGS)
+@@ -460,13 +466,23 @@ ifndef CONFIG_SYS_UBOOT_START
+ CONFIG_SYS_UBOOT_START := 0
+ endif
+
+-$(obj)u-boot.img: $(obj)u-boot.bin
+- $(obj)tools/mkimage -A $(ARCH) -T firmware -C none \
++define GEN_UBOOT_IMAGE
++ $(obj)tools/mkimage -A $(ARCH) -T firmware -C $(1) \
+ -O u-boot -a $(CONFIG_SYS_TEXT_BASE) \
+ -e $(CONFIG_SYS_UBOOT_START) \
+ -n $(shell sed -n -e 's/.*U_BOOT_VERSION//p' $(VERSION_FILE) | \
+ sed -e 's/"[ ]*$$/ for $(BOARD) board"/') \
+ -d $< $@
++endef
++
++$(obj)u-boot.img: $(obj)u-boot.bin
++ $(call GEN_UBOOT_IMAGE,none)
++
++$(obj)u-boot.lzma.img: $(obj)u-boot.bin.lzma
++ $(call GEN_UBOOT_IMAGE,lzma)
++
++$(obj)u-boot.lzo.img: $(obj)u-boot.bin.lzo
++ $(call GEN_UBOOT_IMAGE,lzo)
+
+ $(obj)u-boot.imx: $(obj)u-boot.bin
+ $(obj)tools/mkimage -n $(CONFIG_IMX_CONFIG) -T imximage \
+@@ -549,6 +565,27 @@ endif
+ $(obj)u-boot-img.bin: $(obj)spl/u-boot-spl.bin $(obj)u-boot.img
+ cat $(obj)spl/u-boot-spl.bin $(obj)u-boot.img > $@
+
++$(obj)u-boot.ltq.sfspl: $(obj)u-boot.img $(obj)spl/u-boot-spl.bin
++ $(obj)tools/ltq-boot-image -t sfspl -e $(CONFIG_SPL_TEXT_BASE) \
++ -s $(obj)spl/u-boot-spl.bin -u $< -o $@
++
++$(obj)u-boot.ltq.lzo.sfspl: $(obj)u-boot.lzo.img $(obj)spl/u-boot-spl.bin
++ $(obj)tools/ltq-boot-image -t sfspl -e $(CONFIG_SPL_TEXT_BASE) \
++ -s $(obj)spl/u-boot-spl.bin -u $< -o $@
++
++$(obj)u-boot.ltq.lzma.sfspl: $(obj)u-boot.lzma.img $(obj)spl/u-boot-spl.bin
++ $(obj)tools/ltq-boot-image -t sfspl -e $(CONFIG_SPL_TEXT_BASE) \
++ -s $(obj)spl/u-boot-spl.bin -u $< -o $@
++
++$(obj)u-boot.ltq.norspl: $(obj)u-boot.img $(obj)spl/u-boot-spl.bin
++ cat $(obj)spl/u-boot-spl.bin $< > $@
++
++$(obj)u-boot.ltq.lzo.norspl: $(obj)u-boot.lzo.img $(obj)spl/u-boot-spl.bin
++ cat $(obj)spl/u-boot-spl.bin $< > $@
++
++$(obj)u-boot.ltq.lzma.norspl: $(obj)u-boot.lzma.img $(obj)spl/u-boot-spl.bin
++ cat $(obj)spl/u-boot-spl.bin $< > $@
++
+ ifeq ($(CONFIG_SANDBOX),y)
+ GEN_UBOOT = \
+ cd $(LNDIR) && $(CC) $(SYMS) -T $(obj)u-boot.lds \
+--- a/README
++++ b/README
+@@ -460,6 +460,11 @@ The following options need to be configu
+ CONF_CM_CACHABLE_CUW
+ CONF_CM_CACHABLE_ACCELERATED
+
++ CONFIG_SYS_MIPS_CACHE_EXT_INIT
++
++ Enable this to use extended cache initialization for recent
++ MIPS CPU cores.
++
+ CONFIG_SYS_XWAY_EBU_BOOTCFG
+
+ Special option for Lantiq XWAY SoCs for booting from NOR flash.
+--- a/arch/mips/config.mk
++++ b/arch/mips/config.mk
+@@ -61,7 +61,10 @@ PLATFORM_CPPFLAGS += -DCONFIG_MIPS -D__M
+ # On the other hand, we want PIC in the U-Boot code to relocate it from ROM
+ # to RAM. $28 is always used as gp.
+ #
+-PLATFORM_CPPFLAGS += -G 0 -mabicalls -fpic $(ENDIANNESS)
++PF_ABICALLS ?= -mabicalls
++PF_PIC ?= -fpic
++
++PLATFORM_CPPFLAGS += -G 0 $(PF_ABICALLS) $(PF_PIC) $(ENDIANNESS)
+ PLATFORM_CPPFLAGS += -msoft-float
+ PLATFORM_LDFLAGS += -G 0 -static -n -nostdlib $(ENDIANNESS)
+ PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections
+--- a/arch/mips/cpu/mips32/cache.S
++++ b/arch/mips/cpu/mips32/cache.S
+@@ -45,7 +45,11 @@
+ */
+ #define MIPS_MAX_CACHE_SIZE 0x10000
+
++#ifdef CONFIG_SYS_MIPS_CACHE_EXT_INIT
++#define INDEX_BASE 0x9fc00000
++#else
+ #define INDEX_BASE CKSEG0
++#endif
+
+ .macro cache_op op addr
+ .set push
+@@ -81,7 +85,11 @@
+ */
+ LEAF(mips_init_icache)
+ blez a1, 9f
++#ifdef CONFIG_SYS_MIPS_CACHE_EXT_INIT
++ mtc0 zero, CP0_ITAGLO
++#else
+ mtc0 zero, CP0_TAGLO
++#endif
+ /* clear tag to invalidate */
+ PTR_LI t0, INDEX_BASE
+ PTR_ADDU t1, t0, a1
+@@ -106,7 +114,11 @@ LEAF(mips_init_icache)
+ */
+ LEAF(mips_init_dcache)
+ blez a1, 9f
++#ifdef CONFIG_SYS_MIPS_CACHE_EXT_INIT
++ mtc0 zero, CP0_DTAGLO
++#else
+ mtc0 zero, CP0_TAGLO
++#endif
+ /* clear all tags */
+ PTR_LI t0, INDEX_BASE
+ PTR_ADDU t1, t0, a1
+--- /dev/null
++++ b/arch/mips/cpu/mips32/danube/Makefile
+@@ -0,0 +1,33 @@
++#
++# This file is released under the terms of GPL v2 and any later version.
++# See the file COPYING in the root directory of the source tree for details.
++#
++# Copyright (C) 2000-2011 Wolfgang Denk, DENX Software Engineering, wd@denx.de
++# Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++#
++
++include $(TOPDIR)/config.mk
++
++LIB = $(obj)lib$(SOC).o
++
++COBJS-y += cgu.o chipid.o ebu.o mem.o pmu.o rcu.o
++SOBJS-y += cgu_init.o mem_init.o
++
++COBJS := $(COBJS-y)
++SOBJS := $(SOBJS-y)
++SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c)
++OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS))
++
++all: $(LIB)
++
++$(LIB): $(obj).depend $(OBJS)
++ $(call cmd_link_o_target, $(OBJS))
++
++#########################################################################
++
++# defines $(obj).depend target
++include $(SRCTREE)/rules.mk
++
++sinclude $(obj).depend
++
++#########################################################################
+--- /dev/null
++++ b/arch/mips/cpu/mips32/danube/cgu.c
+@@ -0,0 +1,118 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2007-2010 Lantiq Deutschland GmbH
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <common.h>
++#include <asm/arch/soc.h>
++#include <asm/lantiq/clk.h>
++#include <asm/lantiq/io.h>
++
++#define LTQ_CGU_SYS_DDR_MASK 0x0003
++#define LTQ_CGU_SYS_DDR_SHIFT 0
++#define LTQ_CGU_SYS_CPU0_MASK 0x000C
++#define LTQ_CGU_SYS_CPU0_SHIFT 2
++#define LTQ_CGU_SYS_FPI_MASK 0x0040
++#define LTQ_CGU_SYS_FPI_SHIFT 6
++
++struct ltq_cgu_regs {
++ u32 rsvd0;
++ u32 pll0_cfg; /* PLL0 config */
++ u32 pll1_cfg; /* PLL1 config */
++ u32 pll2_cfg; /* PLL2 config */
++ u32 sys; /* System clock */
++ u32 update; /* CGU update control */
++ u32 if_clk; /* Interface clock */
++ u32 osc_con; /* Update OSC Control */
++ u32 smd; /* SDRAM Memory Control */
++ u32 rsvd1[3];
++ u32 pcm_cr; /* PCM control */
++ u32 pci_cr; /* PCI clock control */
++};
++
++static struct ltq_cgu_regs *ltq_cgu_regs =
++ (struct ltq_cgu_regs *) CKSEG1ADDR(LTQ_CGU_BASE);
++
++static inline u32 ltq_cgu_sys_readl(u32 mask, u32 shift)
++{
++ return (ltq_readl(&ltq_cgu_regs->sys) & mask) >> shift;
++}
++
++unsigned long ltq_get_io_region_clock(void)
++{
++ u32 ddr_sel;
++ unsigned long clk;
++
++ ddr_sel = ltq_cgu_sys_readl(LTQ_CGU_SYS_DDR_MASK,
++ LTQ_CGU_SYS_DDR_SHIFT);
++
++ switch (ddr_sel) {
++ case 0:
++ clk = CLOCK_166_MHZ;
++ break;
++ case 1:
++ clk = CLOCK_133_MHZ;
++ break;
++ case 2:
++ clk = CLOCK_111_MHZ;
++ break;
++ case 3:
++ clk = CLOCK_83_MHZ;
++ break;
++ default:
++ clk = 0;
++ break;
++ }
++
++ return clk;
++}
++
++unsigned long ltq_get_cpu_clock(void)
++{
++ u32 cpu0_sel;
++ unsigned long clk;
++
++ cpu0_sel = ltq_cgu_sys_readl(LTQ_CGU_SYS_CPU0_MASK,
++ LTQ_CGU_SYS_CPU0_SHIFT);
++
++ switch (cpu0_sel) {
++ /* Same as PLL0 output (333,33 MHz) */
++ case 0:
++ clk = CLOCK_333_MHZ;
++ break;
++ /* 1/1 fixed ratio to DDR clock */
++ case 1:
++ clk = ltq_get_io_region_clock();
++ break;
++ /* 1/2 fixed ratio to DDR clock */
++ case 2:
++ clk = ltq_get_io_region_clock() << 1;
++ break;
++ default:
++ clk = 0;
++ break;
++ }
++
++ return clk;
++}
++
++unsigned long ltq_get_bus_clock(void)
++{
++ u32 fpi_sel;
++ unsigned long clk;
++
++ fpi_sel = ltq_cgu_sys_readl(LTQ_CGU_SYS_FPI_MASK,
++ LTQ_CGU_SYS_FPI_SHIFT);
++
++ if (fpi_sel)
++ /* Half the DDR clock */
++ clk = ltq_get_io_region_clock() >> 1;
++ else
++ /* Same as DDR clock */
++ clk = ltq_get_io_region_clock();
++
++ return clk;
++}
+--- /dev/null
++++ b/arch/mips/cpu/mips32/danube/cgu_init.S
+@@ -0,0 +1,143 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2007-2010 Lantiq Deutschland GmbH
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <config.h>
++#include <asm/asm.h>
++#include <asm/regdef.h>
++#include <asm/addrspace.h>
++#include <asm/arch/soc.h>
++
++/* RCU module register */
++#define LTQ_RCU_RST_REQ 0x0010
++#define LTQ_RCU_RST_STAT 0x0014
++#define LTQ_RCU_RST_REQ_VALUE 0x40000008
++#define LTQ_RCU_RST_STAT_XTAL_F 0x20000
++
++/* CGU module register */
++#define LTQ_CGU_PLL0_CFG 0x0004 /* PLL0 config */
++#define LTQ_CGU_PLL1_CFG 0x0008 /* PLL1 config */
++#define LTQ_CGU_PLL2_CFG 0x000C /* PLL2 config */
++#define LTQ_CGU_SYS 0x0010 /* System clock */
++
++/* Valid SYS.CPU0/1 values */
++#define LTQ_CGU_SYS_CPU0_SHIFT 2
++#define LTQ_CGU_SYS_CPU1_SHIFT 4
++#define LTQ_CGU_SYS_CPU_PLL0 0x0
++#define LTQ_CGU_SYS_CPU_DDR_EQUAL 0x1
++#define LTQ_CGU_SYS_CPU_DDR_TWICE 0x2
++
++/* Valid SYS.DDR values */
++#define LTQ_CGU_SYS_DDR_SHIFT 0
++#define LTQ_CGU_SYS_DDR_167_MHZ 0x0
++#define LTQ_CGU_SYS_DDR_133_MHZ 0x1
++#define LTQ_CGU_SYS_DDR_111_MHZ 0x2
++#define LTQ_CGU_SYS_DDR_83_MHZ 0x3
++
++/* Valid SYS.FPI values */
++#define LTQ_CGU_SYS_FPI_SHIFT 6
++#define LTQ_CGU_SYS_FPI_DDR_EQUAL 0x0
++#define LTQ_CGU_SYS_FPI_DDR_HALF 0x1
++
++/* Valid SYS.PPE values */
++#define LTQ_CGU_SYS_PPE_SHIFT 7
++#define LTQ_CGU_SYS_PPE_266_MHZ 0x0
++#define LTQ_CGU_SYS_PPE_240_MHZ 0x1
++#define LTQ_CGU_SYS_PPE_222_MHZ 0x2
++#define LTQ_CGU_SYS_PPE_133_MHZ 0x3
++
++#if (CONFIG_SYS_CLOCK_MODE == LTQ_CLK_CPU_333_DDR_167)
++#define LTQ_CGU_SYS_CPU_CONFIG LTQ_CGU_SYS_CPU_DDR_TWICE
++#define LTQ_CGU_SYS_DDR_CONFIG LTQ_CGU_SYS_DDR_167_MHZ
++#define LTQ_CGU_SYS_FPI_CONFIG LTQ_CGU_SYS_FPI_DDR_HALF
++#define LTQ_CGU_SYS_PPE_CONFIG LTQ_CGU_SYS_PPE_266_MHZ
++#elif (CONFIG_SYS_CLOCK_MODE == LTQ_CLK_CPU_111_DDR_111)
++#define LTQ_CGU_SYS_CPU_CONFIG LTQ_CGU_SYS_CPU_DDR_EQUAL
++#define LTQ_CGU_SYS_DDR_CONFIG LTQ_CGU_SYS_DDR_111_MHZ
++#define LTQ_CGU_SYS_FPI_CONFIG LTQ_CGU_SYS_FPI_DDR_HALF
++#define LTQ_CGU_SYS_PPE_CONFIG LTQ_CGU_SYS_PPE_133_MHZ
++#else
++#error "Invalid system clock configuration!"
++#endif
++
++/* Build register values */
++#define LTQ_CGU_SYS_VALUE ((LTQ_CGU_SYS_PPE_CONFIG << \
++ LTQ_CGU_SYS_PPE_SHIFT) | \
++ (LTQ_CGU_SYS_FPI_CONFIG << \
++ LTQ_CGU_SYS_FPI_SHIFT) | \
++ (LTQ_CGU_SYS_CPU_CONFIG << \
++ LTQ_CGU_SYS_CPU1_SHIFT) | \
++ (LTQ_CGU_SYS_CPU_CONFIG << \
++ LTQ_CGU_SYS_CPU0_SHIFT) | \
++ LTQ_CGU_SYS_DDR_CONFIG)
++
++/* Reset values for PLL registers for usage with 35.328 MHz crystal */
++#define PLL0_35MHZ_CONFIG 0x9D861059
++#define PLL1_35MHZ_CONFIG 0x1A260CD9
++#define PLL2_35MHZ_CONFIG 0x8000f1e5
++
++/* Reset values for PLL registers for usage with 36 MHz crystal */
++#define PLL0_36MHZ_CONFIG 0x1000125D
++#define PLL1_36MHZ_CONFIG 0x1B1E0C99
++#define PLL2_36MHZ_CONFIG 0x8002f2a1
++
++LEAF(ltq_cgu_init)
++ /* Load current CGU register value */
++ li t0, (LTQ_CGU_BASE | KSEG1)
++ lw t1, LTQ_CGU_SYS(t0)
++
++ /* Load target CGU register values */
++ li t3, LTQ_CGU_SYS_VALUE
++
++ /* Only update registers if values differ */
++ beq t1, t3, finished
++
++ /*
++ * Check whether the XTAL_F bit in RST_STAT register is set or not.
++ * This bit is latched in via pin strapping. If bit is set then
++ * clock source is a 36 MHz crystal. Otherwise a 35.328 MHz crystal.
++ */
++ li t1, (LTQ_RCU_BASE | KSEG1)
++ lw t2, LTQ_RCU_RST_STAT(t1)
++ and t2, t2, LTQ_RCU_RST_STAT_XTAL_F
++ beq t2, LTQ_RCU_RST_STAT_XTAL_F, boot_36mhz
++
++boot_35mhz:
++ /* Configure PLL for 35.328 MHz */
++ li t2, PLL0_35MHZ_CONFIG
++ sw t2, LTQ_CGU_PLL0_CFG(t0)
++ li t2, PLL1_35MHZ_CONFIG
++ sw t2, LTQ_CGU_PLL1_CFG(t0)
++ li t2, PLL2_35MHZ_CONFIG
++ sw t2, LTQ_CGU_PLL2_CFG(t0)
++
++ b do_reset
++
++boot_36mhz:
++ /* Configure PLL for 36 MHz */
++ li t2, PLL0_36MHZ_CONFIG
++ sw t2, LTQ_CGU_PLL0_CFG(t0)
++ li t2, PLL1_36MHZ_CONFIG
++ sw t2, LTQ_CGU_PLL1_CFG(t0)
++ li t2, PLL2_36MHZ_CONFIG
++ sw t2, LTQ_CGU_PLL2_CFG(t0)
++
++do_reset:
++ /* Store new clock config */
++ sw t3, LTQ_CGU_SYS(t0)
++
++ /* Perform software reset to activate new clock config */
++ li t2, LTQ_RCU_RST_REQ_VALUE
++ sw t2, LTQ_RCU_RST_REQ(t1)
++
++wait_reset:
++ b wait_reset
++
++finished:
++ jr ra
++
++ END(ltq_cgu_init)
+--- /dev/null
++++ b/arch/mips/cpu/mips32/danube/chipid.c
+@@ -0,0 +1,60 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <common.h>
++#include <asm/lantiq/io.h>
++#include <asm/lantiq/chipid.h>
++#include <asm/arch/soc.h>
++
++#define LTQ_CHIPID_VERSION_SHIFT 28
++#define LTQ_CHIPID_VERSION_MASK (0xF << LTQ_CHIPID_VERSION_SHIFT)
++#define LTQ_CHIPID_PNUM_SHIFT 12
++#define LTQ_CHIPID_PNUM_MASK (0xFFFF << LTQ_CHIPID_PNUM_SHIFT)
++
++struct ltq_chipid_regs {
++ u32 manid; /* Manufacturer identification */
++ u32 chipid; /* Chip identification */
++};
++
++static struct ltq_chipid_regs *ltq_chipid_regs =
++ (struct ltq_chipid_regs *) CKSEG1ADDR(LTQ_CHIPID_BASE);
++
++unsigned int ltq_chip_version_get(void)
++{
++ u32 chipid;
++
++ chipid = ltq_readl(&ltq_chipid_regs->chipid);
++
++ return (chipid & LTQ_CHIPID_VERSION_MASK) >> LTQ_CHIPID_VERSION_SHIFT;
++}
++
++unsigned int ltq_chip_partnum_get(void)
++{
++ u32 chipid;
++
++ chipid = ltq_readl(&ltq_chipid_regs->chipid);
++
++ return (chipid & LTQ_CHIPID_PNUM_MASK) >> LTQ_CHIPID_PNUM_SHIFT;
++}
++
++const char *ltq_chip_partnum_str(void)
++{
++ enum ltq_chip_partnum partnum = ltq_chip_partnum_get();
++
++ switch (partnum) {
++ case LTQ_SOC_DANUBE:
++ return "Danube";
++ case LTQ_SOC_DANUBE_S:
++ return "Danube-S";
++ case LTQ_SOC_TWINPASS:
++ return "Twinpass";
++ default:
++ printf("Unknown partnum: %x\n", partnum);
++ }
++
++ return "";
++}
+--- /dev/null
++++ b/arch/mips/cpu/mips32/danube/config.mk
+@@ -0,0 +1,27 @@
++#
++# This file is released under the terms of GPL v2 and any later version.
++# See the file COPYING in the root directory of the source tree for details.
++#
++# Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++#
++
++PF_CPPFLAGS_DANUBE := $(call cc-option,-mtune=24kec,)
++PLATFORM_CPPFLAGS += $(PF_CPPFLAGS_DANUBE)
++
++ifdef CONFIG_SPL_BUILD
++PF_ABICALLS := -mno-abicalls
++PF_PIC := -fno-pic
++USE_PRIVATE_LIBGCC := yes
++endif
++
++LIBS-y += $(CPUDIR)/lantiq-common/liblantiq-common.o
++
++ifndef CONFIG_SPL_BUILD
++ifdef CONFIG_SYS_BOOT_NORSPL
++ALL-y += $(obj)u-boot.ltq.norspl
++ALL-$(CONFIG_SPL_LZO_SUPPORT) += $(obj)u-boot.ltq.lzo.norspl
++ALL-$(CONFIG_SPL_LZMA_SUPPORT) += $(obj)u-boot.ltq.lzma.norspl
++endif
++endif
++
++LDSCRIPT := $(TOPDIR)/$(CPUDIR)/$(SOC)/u-boot.lds
+--- /dev/null
++++ b/arch/mips/cpu/mips32/danube/ebu.c
+@@ -0,0 +1,51 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <common.h>
++#include <asm/arch/soc.h>
++#include <asm/lantiq/io.h>
++
++#define LTQ_EBU_CON_0_RST_VAL 0x8001F7FF
++
++#define LTQ_EBU_CON_WRDIS (1 << 31)
++
++struct ltq_ebu_regs {
++ u32 clc;
++ u32 rsvd0[3];
++ u32 con;
++ u32 rsvd1[3];
++ u32 addr_sel_0;
++ u32 addr_sel_1;
++ u32 rsvd2[14];
++ u32 con_0;
++ u32 con_1;
++};
++
++static struct ltq_ebu_regs *ltq_ebu_regs =
++ (struct ltq_ebu_regs *) CKSEG1ADDR(LTQ_EBU_BASE);
++
++void ltq_ebu_init(void)
++{
++ /*
++ * Map EBU region 0 to range 0x10000000-0x13ffffff and enable
++ * region control. This supports up to 32 MiB NOR flash in
++ * bank 0.
++ */
++ ltq_writel(&ltq_ebu_regs->addr_sel_0, 0x10000011);
++
++ /*
++ * Restore reset value to fix modifications by internal BootROM.
++ * Also disable write protection.
++ */
++ ltq_writel(&ltq_ebu_regs->con_0,
++ LTQ_EBU_CON_0_RST_VAL & ~LTQ_EBU_CON_WRDIS);
++}
++
++void *flash_swap_addr(unsigned long addr)
++{
++ return (void *)(addr ^ 2);
++}
+--- /dev/null
++++ b/arch/mips/cpu/mips32/danube/mem.c
+@@ -0,0 +1,31 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <common.h>
++#include <asm/arch/soc.h>
++#include <asm/lantiq/io.h>
++
++static void *ltq_mc_ddr_base = (void *) CKSEG1ADDR(LTQ_MC_DDR_BASE);
++
++static inline u32 ltq_mc_dc_read(u32 index)
++{
++ return ltq_readl(ltq_mc_ddr_base + LTQ_MC_DDR_DC_OFFSET(index));
++}
++
++phys_size_t initdram(int board_type)
++{
++ u32 col, row, dc04, dc19, dc20;
++
++ dc04 = ltq_mc_dc_read(4);
++ dc19 = ltq_mc_dc_read(19);
++ dc20 = ltq_mc_dc_read(20);
++
++ row = (dc04 & 0xF) - ((dc19 & 0x700) >> 8);
++ col = ((dc04 & 0xF00) >> 8) - (dc20 & 0x7);
++
++ return (1 << (row + col)) * 4 * 2;
++}
+--- /dev/null
++++ b/arch/mips/cpu/mips32/danube/mem_init.S
+@@ -0,0 +1,115 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2007-2010 Lantiq Deutschland GmbH
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <config.h>
++#include <asm/asm.h>
++#include <asm/regdef.h>
++#include <asm/addrspace.h>
++#include <asm/arch/soc.h>
++
++/* Must be configured in BOARDDIR */
++#include <ddr_settings.h>
++
++#define LTQ_MC_GEN_ERRCAUSE 0x0010
++#define LTQ_MC_GEN_ERRADDR 0x0020
++#define LTQ_MC_GEN_CON 0x0060
++#define LTQ_MC_GEN_STAT 0x0070
++#define LTQ_MC_GEN_CON_SRAM_DDR_ENABLE 0x5
++#define LTQ_MC_GEN_STAT_DLCK_PWRON 0xC
++
++#define LTQ_MC_DDR_DC03_MC_START 0x100
++
++ /* Store given value in MC DDR CCRx register */
++ .macro dc_sw num, val
++ li t2, \val
++ sw t2, LTQ_MC_DDR_DC_OFFSET(\num)(t1)
++ .endm
++
++LEAF(ltq_mem_init)
++ /* Load MC General and MC DDR module base */
++ li t0, (LTQ_MC_GEN_BASE | KSEG1)
++ li t1, (LTQ_MC_DDR_BASE | KSEG1)
++
++ /* Clear access error log registers */
++ sw zero, LTQ_MC_GEN_ERRCAUSE(t0)
++ sw zero, LTQ_MC_GEN_ERRADDR(t0)
++
++ /* Enable DDR and SRAM module in memory controller */
++ li t2, LTQ_MC_GEN_CON_SRAM_DDR_ENABLE
++ sw t2, LTQ_MC_GEN_CON(t0)
++
++ /* Clear start bit of DDR memory controller */
++ sw zero, LTQ_MC_DDR_DC_OFFSET(3)(t1)
++
++ /* Init memory controller registers with values ddr_settings.h */
++ dc_sw 0, MC_DC00_VALUE
++ dc_sw 1, MC_DC01_VALUE
++ dc_sw 2, MC_DC02_VALUE
++ dc_sw 4, MC_DC04_VALUE
++ dc_sw 5, MC_DC05_VALUE
++ dc_sw 6, MC_DC06_VALUE
++ dc_sw 7, MC_DC07_VALUE
++ dc_sw 8, MC_DC08_VALUE
++ dc_sw 9, MC_DC09_VALUE
++
++ dc_sw 10, MC_DC10_VALUE
++ dc_sw 11, MC_DC11_VALUE
++ dc_sw 12, MC_DC12_VALUE
++ dc_sw 13, MC_DC13_VALUE
++ dc_sw 14, MC_DC14_VALUE
++ dc_sw 15, MC_DC15_VALUE
++ dc_sw 16, MC_DC16_VALUE
++ dc_sw 17, MC_DC17_VALUE
++ dc_sw 18, MC_DC18_VALUE
++ dc_sw 19, MC_DC19_VALUE
++
++ dc_sw 20, MC_DC20_VALUE
++ dc_sw 21, MC_DC21_VALUE
++ dc_sw 22, MC_DC22_VALUE
++ dc_sw 23, MC_DC23_VALUE
++ dc_sw 24, MC_DC24_VALUE
++ dc_sw 25, MC_DC25_VALUE
++ dc_sw 26, MC_DC26_VALUE
++ dc_sw 27, MC_DC27_VALUE
++ dc_sw 28, MC_DC28_VALUE
++ dc_sw 29, MC_DC29_VALUE
++
++ dc_sw 30, MC_DC30_VALUE
++ dc_sw 31, MC_DC31_VALUE
++ dc_sw 32, MC_DC32_VALUE
++ dc_sw 33, MC_DC33_VALUE
++ dc_sw 34, MC_DC34_VALUE
++ dc_sw 35, MC_DC35_VALUE
++ dc_sw 36, MC_DC36_VALUE
++ dc_sw 37, MC_DC37_VALUE
++ dc_sw 38, MC_DC38_VALUE
++ dc_sw 39, MC_DC39_VALUE
++
++ dc_sw 40, MC_DC40_VALUE
++ dc_sw 41, MC_DC41_VALUE
++ dc_sw 42, MC_DC42_VALUE
++ dc_sw 43, MC_DC43_VALUE
++ dc_sw 44, MC_DC44_VALUE
++ dc_sw 45, MC_DC45_VALUE
++ dc_sw 46, MC_DC46_VALUE
++
++ /* Set start bit of DDR memory controller */
++ li t2, LTQ_MC_DDR_DC03_MC_START
++ sw t2, LTQ_MC_DDR_DC_OFFSET(3)(t1)
++
++ /* Wait until DLL has locked and core is ready for data transfers */
++wait_ready:
++ lw t2, LTQ_MC_GEN_STAT(t0)
++ li t3, LTQ_MC_GEN_STAT_DLCK_PWRON
++ and t2, t3
++ bne t2, t3, wait_ready
++
++finished:
++ jr ra
++
++ END(ltq_mem_init)
+--- /dev/null
++++ b/arch/mips/cpu/mips32/danube/pmu.c
+@@ -0,0 +1,118 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <common.h>
++#include <asm/lantiq/io.h>
++#include <asm/lantiq/pm.h>
++#include <asm/arch/soc.h>
++
++#define LTQ_PMU_PWDCR_RESERVED 0xFD0C001C
++
++#define LTQ_PMU_PWDCR_TDM (1 << 25)
++#define LTQ_PMU_PWDCR_PPE_ENET0 (1 << 23)
++#define LTQ_PMU_PWDCR_PPE_ENET1 (1 << 22)
++#define LTQ_PMU_PWDCR_PPE_TC (1 << 21)
++#define LTQ_PMU_PWDCR_DEU (1 << 20)
++#define LTQ_PMU_PWDCR_UART1 (1 << 17)
++#define LTQ_PMU_PWDCR_SDIO (1 << 16)
++#define LTQ_PMU_PWDCR_AHB (1 << 15)
++#define LTQ_PMU_PWDCR_FPI0 (1 << 14)
++#define LTQ_PMU_PWDCR_PPE (1 << 13)
++#define LTQ_PMU_PWDCR_GPTC (1 << 12)
++#define LTQ_PMU_PWDCR_LEDC (1 << 11)
++#define LTQ_PMU_PWDCR_EBU (1 << 10)
++#define LTQ_PMU_PWDCR_DSL (1 << 9)
++#define LTQ_PMU_PWDCR_SPI (1 << 8)
++#define LTQ_PMU_PWDCR_UART0 (1 << 7)
++#define LTQ_PMU_PWDCR_USB (1 << 6)
++#define LTQ_PMU_PWDCR_DMA (1 << 5)
++#define LTQ_PMU_PWDCR_FPI1 (1 << 1)
++#define LTQ_PMU_PWDCR_USB_PHY (1 << 0)
++
++struct ltq_pmu_regs {
++ u32 rsvd0[7];
++ u32 pwdcr;
++ u32 sr;
++ u32 pwdcr1;
++ u32 sr1;
++};
++
++static struct ltq_pmu_regs *ltq_pmu_regs =
++ (struct ltq_pmu_regs *) CKSEG1ADDR(LTQ_PMU_BASE);
++
++u32 ltq_pm_map(enum ltq_pm_modules module)
++{
++ u32 val;
++
++ switch (module) {
++ case LTQ_PM_CORE:
++ val = LTQ_PMU_PWDCR_UART1 | LTQ_PMU_PWDCR_FPI0 |
++ LTQ_PMU_PWDCR_LEDC | LTQ_PMU_PWDCR_EBU;
++ break;
++ case LTQ_PM_DMA:
++ val = LTQ_PMU_PWDCR_DMA;
++ break;
++ case LTQ_PM_ETH:
++ val = LTQ_PMU_PWDCR_PPE_ENET0 | LTQ_PMU_PWDCR_PPE_TC |
++ LTQ_PMU_PWDCR_PPE;
++ break;
++ case LTQ_PM_SPI:
++ val = LTQ_PMU_PWDCR_SPI;
++ break;
++ default:
++ val = 0;
++ break;
++ }
++
++ return val;
++}
++
++int ltq_pm_enable(enum ltq_pm_modules module)
++{
++ const unsigned long timeout = 1000;
++ unsigned long timebase;
++ u32 sr, val;
++
++ val = ltq_pm_map(module);
++ if (unlikely(!val))
++ return 1;
++
++ ltq_clrbits(&ltq_pmu_regs->pwdcr, val);
++
++ timebase = get_timer(0);
++
++ do {
++ sr = ltq_readl(&ltq_pmu_regs->sr);
++ if (~sr & val)
++ return 0;
++ } while (get_timer(timebase) < timeout);
++
++ return 1;
++}
++
++int ltq_pm_disable(enum ltq_pm_modules module)
++{
++ u32 val;
++
++ val = ltq_pm_map(module);
++ if (unlikely(!val))
++ return 1;
++
++ ltq_setbits(&ltq_pmu_regs->pwdcr, val);
++
++ return 0;
++}
++
++void ltq_pmu_init(void)
++{
++ u32 set, clr;
++
++ clr = ltq_pm_map(LTQ_PM_CORE);
++ set = ~(LTQ_PMU_PWDCR_RESERVED | clr);
++
++ ltq_clrsetbits(&ltq_pmu_regs->pwdcr, clr, set);
++}
+--- /dev/null
++++ b/arch/mips/cpu/mips32/danube/rcu.c
+@@ -0,0 +1,126 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <common.h>
++#include <asm/lantiq/io.h>
++#include <asm/lantiq/reset.h>
++#include <asm/lantiq/cpu.h>
++#include <asm/arch/soc.h>
++
++#define LTQ_RCU_RD_SRST (1 << 30) /* Global SW Reset */
++#define LTQ_RCU_RD_MC (1 << 14) /* Memory Controller */
++#define LTQ_RCU_RD_PCI (1 << 13) /* PCI core */
++#define LTQ_RCU_RD_DFE_AFE (1 << 12) /* Voice DFE/AFE */
++#define LTQ_RCU_RD_DSL_AFE (1 << 11) /* DSL AFE */
++#define LTQ_RCU_RD_SDIO (1 << 10) /* SDIO core */
++#define LTQ_RCU_RD_DMA (1 << 9) /* DMA core */
++#define LTQ_RCU_RD_PPE (1 << 8) /* PPE core */
++#define LTQ_RCU_RD_ARC_DFE (1 << 7) /* ARC/DFE core */
++#define LTQ_RCU_RD_AHB (1 << 6) /* AHB bus */
++#define LTQ_RCU_RD_ENET_MAC1 (1 << 5) /* Ethernet MAC1 */
++#define LTQ_RCU_RD_USB (1 << 4) /* USB and Phy core */
++#define LTQ_RCU_RD_CPU1 (1 << 3) /* CPU1 subsystem */
++#define LTQ_RCU_RD_FPI (1 << 2) /* FPI bus */
++#define LTQ_RCU_RD_CPU0 (1 << 1) /* CPU0 subsystem */
++#define LTQ_RCU_RD_HRST (1 << 0) /* HW reset via HRST pin */
++
++#define LTQ_RCU_STAT_BOOT_SHIFT 18
++#define LTQ_RCU_STAT_BOOT_MASK (0x7 << LTQ_RCU_STAT_BOOT_SHIFT)
++
++struct ltq_rcu_regs {
++ u32 rsvd0[4];
++ u32 req; /* Reset request */
++ u32 stat; /* Reset status */
++ u32 usb_cfg; /* USB configure */
++ u32 rsvd1[2];
++ u32 pci_rdy; /* PCI boot ready */
++};
++
++static struct ltq_rcu_regs *ltq_rcu_regs =
++ (struct ltq_rcu_regs *) CKSEG1ADDR(LTQ_RCU_BASE);
++
++u32 ltq_reset_map(enum ltq_reset_modules module)
++{
++ u32 val;
++
++ switch (module) {
++ case LTQ_RESET_CORE:
++ case LTQ_RESET_SOFT:
++ val = LTQ_RCU_RD_SRST | LTQ_RCU_RD_CPU1;
++ break;
++ case LTQ_RESET_DMA:
++ val = LTQ_RCU_RD_DMA;
++ break;
++ case LTQ_RESET_ETH:
++ val = LTQ_RCU_RD_PPE;
++ break;
++ case LTQ_RESET_HARD:
++ val = LTQ_RCU_RD_HRST;
++ break;
++ default:
++ val = 0;
++ break;
++ }
++
++ return val;
++}
++
++int ltq_reset_activate(enum ltq_reset_modules module)
++{
++ u32 val;
++
++ val = ltq_reset_map(module);
++ if (unlikely(!val))
++ return 1;
++
++ ltq_setbits(&ltq_rcu_regs->req, val);
++
++ return 0;
++}
++
++int ltq_reset_deactivate(enum ltq_reset_modules module)
++{
++ u32 val;
++
++ val = ltq_reset_map(module);
++ if (unlikely(!val))
++ return 1;
++
++ ltq_clrbits(&ltq_rcu_regs->req, val);
++
++ return 0;
++}
++
++enum ltq_boot_select ltq_boot_select(void)
++{
++ u32 stat;
++ unsigned int bootstrap;
++
++ stat = ltq_readl(&ltq_rcu_regs->stat);
++ bootstrap = (stat & LTQ_RCU_STAT_BOOT_MASK) >> LTQ_RCU_STAT_BOOT_SHIFT;
++
++ switch (bootstrap) {
++ case 0:
++ return BOOT_NOR_NO_BOOTROM;
++ case 1:
++ return BOOT_NOR;
++ case 2:
++ return BOOT_MII0;
++ case 3:
++ return BOOT_PCI;
++ case 4:
++ return BOOT_UART;
++ case 5:
++ return BOOT_SPI;
++ case 6:
++ return BOOT_NAND;
++ case 7:
++ return BOOT_RMII0;
++ default:
++ return BOOT_UNKNOWN;
++ }
++}
+--- /dev/null
++++ b/arch/mips/cpu/mips32/danube/u-boot.lds
+@@ -0,0 +1,69 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2003 Wolfgang Denk, DENX Software Engineering, wd@denx.de
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradlittlemips")
++OUTPUT_ARCH(mips)
++ENTRY(_start)
++SECTIONS
++{
++ . = 0x00000000;
++
++ . = ALIGN(4);
++ .text : {
++ *(.text*)
++ }
++
++ . = ALIGN(4);
++ .rodata : {
++ *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*)))
++ }
++
++ . = ALIGN(4);
++ .data : {
++ *(.data*)
++ }
++
++ . = ALIGN(4);
++ .sdata : {
++ *(.sdata*)
++ }
++
++ . = .;
++ _gp = ALIGN(16) + 0x7ff0;
++
++ .got : {
++ __got_start = .;
++ *(.got)
++ __got_end = .;
++ }
++
++ num_got_entries = (__got_end - __got_start) >> 2;
++
++#ifndef CONFIG_SPL_BUILD
++ . = ALIGN(4);
++ .u_boot_list : {
++ #include <u-boot.lst>
++ }
++#endif
++
++ . = ALIGN(4);
++ __image_copy_end = .;
++ uboot_end_data = .;
++
++ .bss (NOLOAD) : {
++ __bss_start = .;
++ *(.bss*)
++ *(.sbss*)
++ . = ALIGN(4);
++ __bss_end = .;
++ }
++
++ . = ALIGN(4);
++ __end = .;
++ uboot_end = .;
++}
+--- /dev/null
++++ b/arch/mips/cpu/mips32/lantiq-common/Makefile
+@@ -0,0 +1,36 @@
++#
++# This file is released under the terms of GPL v2 and any later version.
++# See the file COPYING in the root directory of the source tree for details.
++#
++# Copyright (C) 2000-2011 Wolfgang Denk, DENX Software Engineering, wd@denx.de
++# Copyright (C) 2012 Daniel Schwierzeck, daniel.schwierzeck@gmail.com
++#
++
++include $(TOPDIR)/config.mk
++
++LIB = $(obj)liblantiq-common.o
++
++START = start.o
++COBJS-y = cpu.o pmu.o
++COBJS-$(CONFIG_SPL_BUILD) += spl.o
++SOBJS-y = lowlevel_init.o
++
++COBJS := $(COBJS-y)
++SOBJS := $(SOBJS-y)
++SRCS := $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
++OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS))
++START := $(addprefix $(obj),$(START))
++
++all: $(LIB)
++
++$(LIB): $(obj).depend $(OBJS)
++ $(call cmd_link_o_target, $(OBJS))
++
++#########################################################################
++
++# defines $(obj).depend target
++include $(SRCTREE)/rules.mk
++
++sinclude $(obj).depend
++
++#########################################################################
+--- /dev/null
++++ b/arch/mips/cpu/mips32/lantiq-common/cpu.c
+@@ -0,0 +1,60 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2012 Daniel Schwierzeck, daniel.schwierzeck@gmail.com
++ */
++
++#include <common.h>
++#include <asm/lantiq/chipid.h>
++#include <asm/lantiq/clk.h>
++#include <asm/lantiq/reset.h>
++#include <asm/lantiq/cpu.h>
++
++static const char ltq_bootsel_strings[][16] = {
++ "NOR",
++ "NOR w/o BootROM",
++ "UART",
++ "UART w/o EEPROM",
++ "SPI",
++ "NAND",
++ "PCI",
++ "MII0",
++ "RMII0",
++ "RGMII1",
++ "unknown",
++};
++
++const char *ltq_boot_select_str(void)
++{ enum ltq_boot_select bootsel = ltq_boot_select();
++
++ if (bootsel > BOOT_UNKNOWN)
++ bootsel = BOOT_UNKNOWN;
++
++ return ltq_bootsel_strings[bootsel];
++}
++
++void ltq_chip_print_info(void)
++{
++ char buf[32];
++
++ printf("SoC: Lantiq %s v1.%u\n", ltq_chip_partnum_str(),
++ ltq_chip_version_get());
++ printf("CPU: %s MHz\n", strmhz(buf, ltq_get_cpu_clock()));
++ printf("IO: %s MHz\n", strmhz(buf, ltq_get_io_region_clock()));
++ printf("BUS: %s MHz\n", strmhz(buf, ltq_get_bus_clock()));
++ printf("BOOT: %s\n", ltq_boot_select_str());
++}
++
++int arch_cpu_init(void)
++{
++ ltq_pmu_init();
++ ltq_ebu_init();
++
++ return 0;
++}
++
++void _machine_restart(void)
++{
++ ltq_reset_activate(LTQ_RESET_CORE);
++}
+--- /dev/null
++++ b/arch/mips/cpu/mips32/lantiq-common/lowlevel_init.S
+@@ -0,0 +1,21 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <asm/asm.h>
++#include <asm/regdef.h>
++
++NESTED(lowlevel_init, 0, ra)
++ move t8, ra
++
++ la t7, ltq_cgu_init
++ jalr t7
++
++ la t7, ltq_mem_init
++ jalr t7
++
++ jr t8
++ END(lowlevel_init)
+--- /dev/null
++++ b/arch/mips/cpu/mips32/lantiq-common/pmu.c
+@@ -0,0 +1,10 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011-2012 Daniel Schwierzeck, daniel.schwierzeck@gmail.com
++ */
++
++#include <common.h>
++#include <asm/lantiq/pm.h>
++
+--- /dev/null
++++ b/arch/mips/cpu/mips32/lantiq-common/spl.c
+@@ -0,0 +1,385 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <common.h>
++#include <image.h>
++#include <version.h>
++#include <spi_flash.h>
++#include <linux/compiler.h>
++#include <lzma/LzmaDec.h>
++#include <linux/lzo.h>
++#include <asm/mipsregs.h>
++
++#if defined(CONFIG_LTQ_SPL_CONSOLE)
++#define spl_has_console 1
++
++#if defined(CONFIG_LTQ_SPL_DEBUG)
++#define spl_has_debug 1
++#else
++#define spl_has_debug 0
++#endif
++
++#else
++#define spl_has_console 0
++#endif
++
++#define spl_debug(fmt, args...) \
++ do { \
++ if (spl_has_debug) \
++ printf(fmt, ##args); \
++ } while (0)
++
++#define spl_puts(msg) \
++ do { \
++ if (spl_has_console) \
++ puts(msg); \
++ } while (0)
++
++#if defined(CONFIG_LTQ_SUPPORT_SPL_SPI_FLASH) && defined(CONFIG_SYS_BOOT_SFSPL)
++#define spl_boot_spi_flash 1
++#else
++#define spl_boot_spi_flash 0
++#ifndef CONFIG_SPL_SPI_BUS
++#define CONFIG_SPL_SPI_BUS 0
++#endif
++#ifndef CONFIG_SPL_SPI_CS
++#define CONFIG_SPL_SPI_CS 0
++#endif
++#ifndef CONFIG_SPL_SPI_MAX_HZ
++#define CONFIG_SPL_SPI_MAX_HZ 0
++#endif
++#ifndef CONFIG_SPL_SPI_MODE
++#define CONFIG_SPL_SPI_MODE 0
++#endif
++#endif
++
++#if defined(CONFIG_LTQ_SUPPORT_SPL_NOR_FLASH) && defined(CONFIG_SYS_BOOT_NORSPL)
++#define spl_boot_nor_flash 1
++#else
++#define spl_boot_nor_flash 0
++#endif
++
++#define spl_sync() __asm__ __volatile__("sync");
++
++struct spl_image {
++ ulong data_addr;
++ ulong entry_addr;
++ size_t data_size;
++ size_t entry_size;
++ u8 comp;
++};
++
++extern ulong __image_copy_end;
++
++DECLARE_GLOBAL_DATA_PTR;
++
++/* Emulated malloc area needed for LZMA allocator in BSS */
++static u8 *spl_mem_ptr __maybe_unused;
++static size_t spl_mem_size __maybe_unused;
++
++static int spl_is_comp_lzma(const struct spl_image *spl)
++{
++#if defined(CONFIG_LTQ_SPL_COMP_LZMA)
++ return spl->comp == IH_COMP_LZMA;
++#else
++ return 0;
++#endif
++}
++
++static int spl_is_comp_lzo(const struct spl_image *spl)
++{
++#if defined(CONFIG_LTQ_SPL_COMP_LZO)
++ return spl->comp == IH_COMP_LZO;
++#else
++ return 0;
++#endif
++}
++
++static int spl_is_compressed(const struct spl_image *spl)
++{
++ if (spl_is_comp_lzma(spl))
++ return 1;
++
++ if (spl_is_comp_lzo(spl))
++ return 1;
++
++ return 0;
++}
++
++static void spl_console_init(void)
++{
++ if (!spl_has_console)
++ return;
++
++ gd->flags |= GD_FLG_RELOC;
++ gd->baudrate = CONFIG_BAUDRATE;
++
++ serial_init();
++
++ gd->have_console = 1;
++
++ spl_puts("\nU-Boot SPL " PLAIN_VERSION " (" U_BOOT_DATE " - " \
++ U_BOOT_TIME ")\n");
++}
++
++static int spl_parse_image(const image_header_t *hdr, struct spl_image *spl)
++{
++ u32 magic;
++
++ spl_puts("SPL: checking U-Boot image\n");
++
++ magic = image_get_magic(hdr);
++ if (magic != IH_MAGIC)
++ return -1;
++
++ spl->data_addr += image_get_header_size();
++ spl->entry_addr = image_get_load(hdr);
++ spl->data_size = image_get_data_size(hdr);
++ spl->comp = image_get_comp(hdr);
++
++ spl_debug("SPL: data %08lx, size %zu, entry %08lx, comp %u\n",
++ spl->data_addr, spl->data_size, spl->entry_addr, spl->comp);
++
++ return 0;
++}
++
++static void *spl_lzma_alloc(void *p, size_t size)
++{
++ u8 *ret;
++
++ if (size > spl_mem_size)
++ return NULL;
++
++ ret = spl_mem_ptr;
++ spl_mem_ptr += size;
++ spl_mem_size -= size;
++
++ return ret;
++}
++
++static void spl_lzma_free(void *p, void *addr)
++{
++}
++
++static int spl_copy_image(struct spl_image *spl)
++{
++ spl_puts("SPL: copying U-Boot to RAM\n");
++
++ memcpy((void *) spl->entry_addr, (const void *) spl->data_addr,
++ spl->data_size);
++
++ spl->entry_size = spl->data_size;
++
++ return 0;
++}
++
++static int spl_uncompress_lzma(struct spl_image *spl, unsigned long loadaddr)
++{
++ SRes res;
++ const Byte *prop = (const Byte *) loadaddr;
++ const Byte *src = (const Byte *) loadaddr + LZMA_PROPS_SIZE +
++ sizeof(uint64_t);
++ Byte *dest = (Byte *) spl->entry_addr;
++ SizeT dest_len = 0xFFFFFFFF;
++ SizeT src_len = spl->data_size - LZMA_PROPS_SIZE;
++ ELzmaStatus status = 0;
++ ISzAlloc alloc;
++
++ spl_puts("SPL: decompressing U-Boot with LZMA\n");
++
++ alloc.Alloc = spl_lzma_alloc;
++ alloc.Free = spl_lzma_free;
++ spl_mem_ptr = (u8 *) CONFIG_SPL_MALLOC_BASE;
++ spl_mem_size = CONFIG_SPL_MALLOC_MAX_SIZE;
++
++ res = LzmaDecode(dest, &dest_len, src, &src_len, prop, LZMA_PROPS_SIZE,
++ LZMA_FINISH_ANY, &status, &alloc);
++ if (res != SZ_OK)
++ return 1;
++
++ spl->entry_size = dest_len;
++
++ return 0;
++}
++
++static int spl_uncompress_lzo(struct spl_image *spl, unsigned long loadaddr)
++{
++ size_t len;
++ int ret;
++
++ spl_puts("SPL: decompressing U-Boot with LZO\n");
++
++ ret = lzop_decompress(
++ (const unsigned char*) loadaddr, spl->data_size,
++ (unsigned char *) spl->entry_addr, &len);
++
++ spl->entry_size = len;
++
++ return ret;
++}
++
++static int spl_uncompress(struct spl_image *spl, unsigned long loadaddr)
++{
++ int ret;
++
++ if (spl_is_comp_lzma(spl))
++ ret = spl_uncompress_lzma(spl, loadaddr);
++ else if (spl_is_comp_lzo(spl))
++ ret = spl_uncompress_lzo(spl, loadaddr);
++ else
++ ret = 1;
++
++ return ret;
++}
++
++static int spl_load_spi_flash(struct spl_image *spl)
++{
++ struct spi_flash sf;
++ image_header_t hdr;
++ int ret;
++ unsigned long loadaddr;
++
++ /*
++ * Image format:
++ *
++ * - 12 byte non-volatile bootstrap header
++ * - SPL binary
++ * - 12 byte non-volatile bootstrap header
++ * - 64 byte U-Boot mkimage header
++ * - U-Boot binary
++ */
++ spl->data_addr = (ulong) &__image_copy_end - CONFIG_SPL_TEXT_BASE + 24;
++
++ spl_puts("SPL: probing SPI flash\n");
++
++ spi_init();
++ ret = spi_flash_probe_spl(&sf, CONFIG_SPL_SPI_BUS, CONFIG_SPL_SPI_CS,
++ CONFIG_SPL_SPI_MAX_HZ, CONFIG_SPL_SPI_MODE);
++ if (ret)
++ return ret;
++
++ spl_debug("SPL: reading image header at offset %lx\n", spl->data_addr);
++
++ ret = spi_flash_read(&sf, spl->data_addr, sizeof(hdr), &hdr);
++ if (ret)
++ return ret;
++
++ spl_debug("SPL: checking image header at offset %lx\n", spl->data_addr);
++
++ ret = spl_parse_image(&hdr, spl);
++ if (ret)
++ return ret;
++
++ if (spl_is_compressed(spl))
++ loadaddr = CONFIG_LOADADDR;
++ else
++ loadaddr = spl->entry_addr;
++
++ spl_puts("SPL: loading U-Boot to RAM\n");
++
++ ret = spi_flash_read(&sf, spl->data_addr, spl->data_size,
++ (void *) loadaddr);
++
++ if (spl_is_compressed(spl))
++ ret = spl_uncompress(spl, loadaddr);
++
++ return ret;
++}
++
++static int spl_load_nor_flash(struct spl_image *spl)
++{
++ const image_header_t *hdr;
++ int ret;
++
++ /*
++ * Image format:
++ *
++ * - SPL binary
++ * - 64 byte U-Boot mkimage header
++ * - U-Boot binary
++ */
++ spl->data_addr = (ulong) &__image_copy_end;
++ hdr = (const image_header_t *) &__image_copy_end;
++
++ spl_debug("SPL: checking image header at address %p\n", hdr);
++
++ ret = spl_parse_image(hdr, spl);
++ if (ret)
++ return ret;
++
++ if (spl_is_compressed(spl))
++ ret = spl_uncompress(spl, spl->data_addr);
++ else
++ ret = spl_copy_image(spl);
++
++ return ret;
++}
++
++static int spl_load(struct spl_image *spl)
++{
++ int ret;
++
++ if (spl_boot_spi_flash)
++ ret = spl_load_spi_flash(spl);
++ else if (spl_boot_nor_flash)
++ ret = spl_load_nor_flash(spl);
++ else
++ ret = 1;
++
++ return ret;
++}
++
++void __noreturn spl_lantiq_init(void)
++{
++ void (*uboot)(void) __noreturn;
++ struct spl_image spl;
++ gd_t gd_data;
++ int ret;
++
++ gd = &gd_data;
++ barrier();
++ memset((void *)gd, 0, sizeof(gd_t));
++
++ spl_console_init();
++
++ spl_debug("SPL: initializing\n");
++
++#if 0
++ spl_debug("CP0_CONFIG: %08x\n", read_c0_config());
++ spl_debug("CP0_CONFIG1: %08x\n", read_c0_config1());
++ spl_debug("CP0_CONFIG2: %08x\n", read_c0_config2());
++ spl_debug("CP0_CONFIG3: %08x\n", read_c0_config3());
++ spl_debug("CP0_CONFIG6: %08x\n", read_c0_config6());
++ spl_debug("CP0_CONFIG7: %08x\n", read_c0_config7());
++ spl_debug("CP0_STATUS: %08x\n", read_c0_status());
++ spl_debug("CP0_PRID: %08x\n", read_c0_prid());
++#endif
++
++ board_early_init_f();
++ timer_init();
++
++ memset(&spl, 0, sizeof(spl));
++
++ ret = spl_load(&spl);
++ if (ret)
++ goto hang;
++
++ spl_debug("SPL: U-Boot entry %08lx\n", spl.entry_addr);
++ spl_puts("SPL: jumping to U-Boot\n");
++
++ flush_cache(spl.entry_addr, spl.entry_size);
++ spl_sync();
++
++ uboot = (void *) spl.entry_addr;
++ uboot();
++
++hang:
++ spl_puts("SPL: cannot start U-Boot\n");
++
++ for (;;)
++ ;
++}
+--- /dev/null
++++ b/arch/mips/cpu/mips32/lantiq-common/start.S
+@@ -0,0 +1,144 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2003 Wolfgang Denk, wd@denx.de
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <config.h>
++#include <asm/regdef.h>
++#include <asm/mipsregs.h>
++
++#define S_PRIdCoID 16 /* Company ID (R) */
++#define M_PRIdCoID (0xff << S_PRIdCoID)
++#define S_PRIdImp 8 /* Implementation ID (R) */
++#define M_PRIdImp (0xff << S_PRIdImp)
++
++#define K_CacheAttrCWTnWA 0 /* Cacheable, write-thru, no write allocate */
++#define K_CacheAttrCWTWA 1 /* Cacheable, write-thru, write allocate */
++#define K_CacheAttrU 2 /* Uncached */
++#define K_CacheAttrC 3 /* Cacheable */
++#define K_CacheAttrCN 3 /* Cacheable, non-coherent */
++#define K_CacheAttrCCE 4 /* Cacheable, coherent, exclusive */
++#define K_CacheAttrCCS 5 /* Cacheable, coherent, shared */
++#define K_CacheAttrCCU 6 /* Cacheable, coherent, update */
++#define K_CacheAttrUA 7 /* Uncached accelerated */
++
++#define S_ConfigK23 28 /* Kseg2/3 coherency algorithm (FM MMU only) (R/W) */
++#define M_ConfigK23 (0x7 << S_ConfigK23)
++#define W_ConfigK23 3
++#define S_ConfigKU 25 /* Kuseg coherency algorithm (FM MMU only) (R/W) */
++#define M_ConfigKU (0x7 << S_ConfigKU)
++#define W_ConfigKU 3
++
++#define S_ConfigMM 18 /* Merge mode (implementation specific) */
++#define M_ConfigMM (0x1 << S_ConfigMM)
++
++#define S_StatusBEV 22 /* Enable Boot Exception Vectors (R/W) */
++#define M_StatusBEV (0x1 << S_StatusBEV)
++
++#define S_StatusFR 26 /* Enable 64-bit FPRs (R/W) */
++#define M_StatusFR (0x1 << S_StatusFR)
++
++#define S_ConfigK0 0 /* Kseg0 coherency algorithm (R/W) */
++#define M_ConfigK0 (0x7 << S_ConfigK0)
++
++#define CONFIG0_MIPS32_64_MSK 0x8000ffff
++#define STATUS_MIPS32_64_MSK 0xfffcffff
++
++#define STATUS_MIPS24K 0
++#define CONFIG0_MIPS24K ((K_CacheAttrCN << S_ConfigK23) |\
++ (K_CacheAttrCN << S_ConfigKU) |\
++ (M_ConfigMM))
++
++#define STATUS_MIPS34K 0
++#define CONFIG0_MIPS34K ((K_CacheAttrCN << S_ConfigK23) |\
++ (K_CacheAttrCN << S_ConfigKU) |\
++ (M_ConfigMM))
++
++#define STATUS_MIPS32_64 (M_StatusBEV | M_StatusFR)
++#define CONFIG0_MIPS32_64 (K_CacheAttrCN << S_ConfigK0)
++
++#ifdef CONFIG_SOC_XWAY_DANUBE
++#define CONFIG0_LANTIQ (CONFIG0_MIPS24K | CONFIG0_MIPS32_64)
++#define STATUS_LANTIQ (STATUS_MIPS24K | STATUS_MIPS32_64)
++#endif
++
++#ifdef CONFIG_SOC_XWAY_VRX200
++#define CONFIG0_LANTIQ (CONFIG0_MIPS34K | CONFIG0_MIPS32_64)
++#define STATUS_LANTIQ (STATUS_MIPS34K | STATUS_MIPS32_64)
++#endif
++
++
++ .set noreorder
++
++ .globl _start
++ .text
++_start:
++ /* Entry point */
++ b main
++ nop
++
++ /* Lantiq SoC Boot config word */
++ .org 0x10
++#ifdef CONFIG_SYS_XWAY_EBU_BOOTCFG
++ .word CONFIG_SYS_XWAY_EBU_BOOTCFG
++#else
++ .word 0
++#endif
++ .word 0
++
++ .align 4
++main:
++
++ /* Init Timer */
++ mtc0 zero, CP0_COUNT
++ mtc0 zero, CP0_COMPARE
++
++ /* Setup MIPS24K/MIPS34K specifics (implementation dependent fields) */
++ mfc0 t0, CP0_CONFIG
++ li t1, CONFIG0_MIPS32_64_MSK
++ and t0, t1
++ li t1, CONFIG0_LANTIQ
++ or t0, t1
++ mtc0 t0, CP0_CONFIG
++
++ mfc0 t0, CP0_STATUS
++ li t1, STATUS_MIPS32_64_MSK
++ and t0, t1
++ li t1, STATUS_LANTIQ
++ or t0, t1
++ mtc0 t0, CP0_STATUS
++
++ /* Initialize CGU */
++ la t9, ltq_cgu_init
++ jalr t9
++ nop
++
++ /* Initialize memory controller */
++ la t9, ltq_mem_init
++ jalr t9
++ nop
++
++ /* Initialize caches... */
++ la t9, mips_cache_reset
++ jalr t9
++ nop
++
++ /* Clear BSS */
++ la t1, __bss_start
++ la t2, __bss_end
++ sub t1, 4
++1:
++ addi t1, 4
++ bltl t1, t2, 1b
++ sw zero, 0(t1)
++
++ /* Setup stack pointer and force alignment on a 16 byte boundary */
++ li t0, (CONFIG_SPL_STACK_BASE & ~0xF)
++ la sp, 0(t0)
++
++ la t9, spl_lantiq_init
++ jr t9
++ nop
+--- /dev/null
++++ b/arch/mips/cpu/mips32/lantiq-common/u-boot-spl.lds
+@@ -0,0 +1,49 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011-2012 Daniel Schwierzeck, daniel.schwierzeck@gmail.com
++ */
++
++MEMORY { .spl_mem : ORIGIN = CONFIG_SPL_TEXT_BASE, \
++ LENGTH = CONFIG_SPL_MAX_SIZE }
++MEMORY { .bss_mem : ORIGIN = CONFIG_SPL_BSS_BASE, \
++ LENGTH = CONFIG_SPL_BSS_MAX_SIZE }
++
++OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradlittlemips")
++OUTPUT_ARCH(mips)
++ENTRY(_start)
++SECTIONS
++{
++ . = ALIGN(4);
++ .text : {
++ *(.text*)
++ } > .spl_mem
++
++ . = ALIGN(4);
++ .rodata : {
++ *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*)))
++ } > .spl_mem
++
++ . = ALIGN(4);
++ .data : {
++ *(SORT_BY_ALIGNMENT(.data*))
++ *(SORT_BY_ALIGNMENT(.sdata*))
++ } > .spl_mem
++
++ . = ALIGN(4);
++ __image_copy_end = .;
++ uboot_end_data = .;
++
++ .bss : {
++ __bss_start = .;
++ *(.bss*)
++ *(.sbss*)
++ . = ALIGN(4);
++ __bss_end = .;
++ } > .bss_mem
++
++ . = ALIGN(4);
++ __end = .;
++ uboot_end = .;
++}
+--- a/arch/mips/cpu/mips32/start.S
++++ b/arch/mips/cpu/mips32/start.S
+@@ -55,166 +55,63 @@
+ #endif
+ .endm
+
+-#define RVECENT(f,n) \
+- b f; nop
+-#define XVECENT(f,bev) \
+- b f ; \
+- li k0,bev
+-
+- .set noreorder
+-
+- .globl _start
+- .text
+-_start:
+- RVECENT(reset,0) # U-boot entry point
+- RVECENT(reset,1) # software reboot
+-#ifdef CONFIG_SYS_XWAY_EBU_BOOTCFG
+ /*
+ * Almost all Lantiq XWAY SoC devices have an external bus unit (EBU) to
+ * access external NOR flashes. If the board boots from NOR flash the
+ * internal BootROM does a blind read at address 0xB0000010 to read the
+ * initial configuration for that EBU in order to access the flash
+ * device with correct parameters. This config option is board-specific.
++ * Default to 0 if this option is not set.
+ */
+- .word CONFIG_SYS_XWAY_EBU_BOOTCFG
+- .word 0x00000000
++ .macro lantiq_soc_bootcfg
++ .set push
++ .set noreorder
++ .org 0x10
++#ifdef CONFIG_SYS_XWAY_EBU_BOOTCFG
++ .word CONFIG_SYS_XWAY_EBU_BOOTCFG
+ #else
+- RVECENT(romReserved,2)
++ .word 0
+ #endif
+- RVECENT(romReserved,3)
+- RVECENT(romReserved,4)
+- RVECENT(romReserved,5)
+- RVECENT(romReserved,6)
+- RVECENT(romReserved,7)
+- RVECENT(romReserved,8)
+- RVECENT(romReserved,9)
+- RVECENT(romReserved,10)
+- RVECENT(romReserved,11)
+- RVECENT(romReserved,12)
+- RVECENT(romReserved,13)
+- RVECENT(romReserved,14)
+- RVECENT(romReserved,15)
+- RVECENT(romReserved,16)
+- RVECENT(romReserved,17)
+- RVECENT(romReserved,18)
+- RVECENT(romReserved,19)
+- RVECENT(romReserved,20)
+- RVECENT(romReserved,21)
+- RVECENT(romReserved,22)
+- RVECENT(romReserved,23)
+- RVECENT(romReserved,24)
+- RVECENT(romReserved,25)
+- RVECENT(romReserved,26)
+- RVECENT(romReserved,27)
+- RVECENT(romReserved,28)
+- RVECENT(romReserved,29)
+- RVECENT(romReserved,30)
+- RVECENT(romReserved,31)
+- RVECENT(romReserved,32)
+- RVECENT(romReserved,33)
+- RVECENT(romReserved,34)
+- RVECENT(romReserved,35)
+- RVECENT(romReserved,36)
+- RVECENT(romReserved,37)
+- RVECENT(romReserved,38)
+- RVECENT(romReserved,39)
+- RVECENT(romReserved,40)
+- RVECENT(romReserved,41)
+- RVECENT(romReserved,42)
+- RVECENT(romReserved,43)
+- RVECENT(romReserved,44)
+- RVECENT(romReserved,45)
+- RVECENT(romReserved,46)
+- RVECENT(romReserved,47)
+- RVECENT(romReserved,48)
+- RVECENT(romReserved,49)
+- RVECENT(romReserved,50)
+- RVECENT(romReserved,51)
+- RVECENT(romReserved,52)
+- RVECENT(romReserved,53)
+- RVECENT(romReserved,54)
+- RVECENT(romReserved,55)
+- RVECENT(romReserved,56)
+- RVECENT(romReserved,57)
+- RVECENT(romReserved,58)
+- RVECENT(romReserved,59)
+- RVECENT(romReserved,60)
+- RVECENT(romReserved,61)
+- RVECENT(romReserved,62)
+- RVECENT(romReserved,63)
+- XVECENT(romExcHandle,0x200) # bfc00200: R4000 tlbmiss vector
+- RVECENT(romReserved,65)
+- RVECENT(romReserved,66)
+- RVECENT(romReserved,67)
+- RVECENT(romReserved,68)
+- RVECENT(romReserved,69)
+- RVECENT(romReserved,70)
+- RVECENT(romReserved,71)
+- RVECENT(romReserved,72)
+- RVECENT(romReserved,73)
+- RVECENT(romReserved,74)
+- RVECENT(romReserved,75)
+- RVECENT(romReserved,76)
+- RVECENT(romReserved,77)
+- RVECENT(romReserved,78)
+- RVECENT(romReserved,79)
+- XVECENT(romExcHandle,0x280) # bfc00280: R4000 xtlbmiss vector
+- RVECENT(romReserved,81)
+- RVECENT(romReserved,82)
+- RVECENT(romReserved,83)
+- RVECENT(romReserved,84)
+- RVECENT(romReserved,85)
+- RVECENT(romReserved,86)
+- RVECENT(romReserved,87)
+- RVECENT(romReserved,88)
+- RVECENT(romReserved,89)
+- RVECENT(romReserved,90)
+- RVECENT(romReserved,91)
+- RVECENT(romReserved,92)
+- RVECENT(romReserved,93)
+- RVECENT(romReserved,94)
+- RVECENT(romReserved,95)
+- XVECENT(romExcHandle,0x300) # bfc00300: R4000 cache vector
+- RVECENT(romReserved,97)
+- RVECENT(romReserved,98)
+- RVECENT(romReserved,99)
+- RVECENT(romReserved,100)
+- RVECENT(romReserved,101)
+- RVECENT(romReserved,102)
+- RVECENT(romReserved,103)
+- RVECENT(romReserved,104)
+- RVECENT(romReserved,105)
+- RVECENT(romReserved,106)
+- RVECENT(romReserved,107)
+- RVECENT(romReserved,108)
+- RVECENT(romReserved,109)
+- RVECENT(romReserved,110)
+- RVECENT(romReserved,111)
+- XVECENT(romExcHandle,0x380) # bfc00380: R4000 general vector
+- RVECENT(romReserved,113)
+- RVECENT(romReserved,114)
+- RVECENT(romReserved,115)
+- RVECENT(romReserved,116)
+- RVECENT(romReserved,116)
+- RVECENT(romReserved,118)
+- RVECENT(romReserved,119)
+- RVECENT(romReserved,120)
+- RVECENT(romReserved,121)
+- RVECENT(romReserved,122)
+- RVECENT(romReserved,123)
+- RVECENT(romReserved,124)
+- RVECENT(romReserved,125)
+- RVECENT(romReserved,126)
+- RVECENT(romReserved,127)
++ .word 0
++ .set pop
++ .endm
++
++ .macro reset_vector branch
++ .set push
++ .set noreorder
++ b \branch
++ nop
++ .set pop
++ .endm
++
++ .macro exception_vector offset branch
++ .set push
++ .set noreorder
++ .org \offset
++ b \branch
++ li k0, \offset
++ .set pop
++ .endm
++
++ .set noreorder
++
++ .globl _start
++ .text
++_start:
++ reset_vector reset # U-boot entry point
++ reset_vector reset # software reboot
++
++ lantiq_soc_bootcfg # Lantiq SoC Boot config word
++
++ exception_vector 0x200, halt # TLB miss
++ exception_vector 0x280, halt # XTLB miss
++ exception_vector 0x300, halt # Cache error
++ exception_vector 0x380, halt # General
++ exception_vector 0x400, halt # Interrupt, CauseIV
++ exception_vector 0x480, ejtag_exception # EJTAG debug
+
+- /*
+- * We hope there are no more reserved vectors!
+- * 128 * 8 == 1024 == 0x400
+- * so this is address R_VEC+0x400 == 0xbfc00400
+- */
+ .align 4
+ reset:
+-
+ /* Clear watch registers */
+ mtc0 zero, CP0_WATCHLO
+ mtc0 zero, CP0_WATCHHI
+@@ -222,13 +119,15 @@ reset:
+ /* WP(Watch Pending), SW0/1 should be cleared */
+ mtc0 zero, CP0_CAUSE
+
++#if 0
+ setup_c0_status_reset
++#endif
+
+ /* Init Timer */
+ mtc0 zero, CP0_COUNT
+ mtc0 zero, CP0_COMPARE
+
+-#ifndef CONFIG_SKIP_LOWLEVEL_INIT
++#if !defined(CONFIG_SKIP_LOWLEVEL_INIT) || defined(CONFIG_SYS_DISABLE_CACHE)
+ /* CONFIG0 register */
+ li t0, CONF_CM_UNCACHED
+ mtc0 t0, CP0_CONFIG
+@@ -323,6 +222,8 @@ relocate_code:
+ jalr t9
+ nop
+
++ sync
++
+ /* Jump to where we've relocated ourselves */
+ addi t0, s2, in_ram - _start
+ jr t0
+@@ -378,8 +279,12 @@ in_ram:
+ .end relocate_code
+
+ /* Exception handlers */
+-romReserved:
+- b romReserved
++ejtag_exception:
++ /* Set DEPC to halt and exit debug mode */
++ la k1, halt
++ mtc0 k1, CP0_DEPC
++ deret
++ nop
+
+-romExcHandle:
+- b romExcHandle
++halt:
++ b halt
+--- /dev/null
++++ b/arch/mips/cpu/mips32/vrx200/Makefile
+@@ -0,0 +1,34 @@
++#
++# This file is released under the terms of GPL v2 and any later version.
++# See the file COPYING in the root directory of the source tree for details.
++#
++# Copyright (C) 2000-2011 Wolfgang Denk, DENX Software Engineering, wd@denx.de
++# Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++#
++
++include $(TOPDIR)/config.mk
++
++LIB = $(obj)lib$(SOC).o
++
++COBJS-y += cgu.o chipid.o dcdc.o ebu.o gphy.o mem.o pmu.o rcu.o
++SOBJS-y += cgu_init.o mem_init.o
++SOBJS-y += gphy_fw.o
++
++COBJS := $(COBJS-y)
++SOBJS := $(SOBJS-y)
++SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c)
++OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS))
++
++all: $(LIB)
++
++$(LIB): $(obj).depend $(OBJS)
++ $(call cmd_link_o_target, $(OBJS))
++
++#########################################################################
++
++# defines $(obj).depend target
++include $(SRCTREE)/rules.mk
++
++sinclude $(obj).depend
++
++#########################################################################
+--- /dev/null
++++ b/arch/mips/cpu/mips32/vrx200/cgu.c
+@@ -0,0 +1,209 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2010 Lantiq Deutschland GmbH
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <common.h>
++#include <asm/arch/soc.h>
++#include <asm/arch/gphy.h>
++#include <asm/lantiq/clk.h>
++#include <asm/lantiq/io.h>
++
++#define LTQ_CGU_PLL1_PLLN_SHIFT 6
++#define LTQ_CGU_PLL1_PLLN_MASK (0x3F << LTQ_CGU_PLL1_PLLN_SHIFT)
++#define LTQ_CGU_PLL1_PLLM_SHIFT 2
++#define LTQ_CGU_PLL1_PLLM_MASK (0xF << LTQ_CGU_PLL1_PLLM_SHIFT)
++#define LTQ_CGU_PLL1_PLLL (1 << 1)
++#define LTQ_CGU_PLL1_PLL_EN 1
++
++#define LTQ_CGU_SYS_OCP_SHIFT 0
++#define LTQ_CGU_SYS_OCP_MASK (0x3 << LTQ_CGU_SYS_OCP_SHIFT)
++#define LTQ_CGU_SYS_CPU_SHIFT 4
++#define LTQ_CGU_SYS_CPU_MASK (0xF << LTQ_CGU_SYS_CPU_SHIFT)
++
++#define LTQ_CGU_UPDATE 1
++
++#define LTQ_CGU_IFCLK_GPHY_SEL_SHIFT 2
++#define LTQ_CGU_IFCLK_GPHY_SEL_MASK (0x7 << LTQ_CGU_IFCLK_GPHY_SEL_SHIFT)
++
++struct ltq_cgu_regs {
++ u32 rsvd0;
++ u32 pll0_cfg; /* PLL0 config */
++ u32 pll1_cfg; /* PLL1 config */
++ u32 sys; /* System clock */
++ u32 clk_fsr; /* Clock frequency select */
++ u32 clk_gsr; /* Clock gating status */
++ u32 clk_gcr0; /* Clock gating control 0 */
++ u32 clk_gcr1; /* Clock gating control 1 */
++ u32 update; /* CGU update control */
++ u32 if_clk; /* Interface clock */
++ u32 ddr; /* DDR memory control */
++ u32 ct1_sr; /* CT status 1 */
++ u32 ct_kval; /* CT K value */
++ u32 pcm_cr; /* PCM control */
++ u32 pci_cr; /* PCI clock control */
++ u32 rsvd1;
++ u32 gphy1_cfg; /* GPHY1 config */
++ u32 gphy0_cfg; /* GPHY0 config */
++ u32 rsvd2[6];
++ u32 pll2_cfg; /* PLL2 config */
++};
++
++static struct ltq_cgu_regs *ltq_cgu_regs =
++ (struct ltq_cgu_regs *) CKSEG1ADDR(LTQ_CGU_BASE);
++
++static inline u32 ltq_cgu_sys_readl(u32 mask, u32 shift)
++{
++ return (ltq_readl(&ltq_cgu_regs->sys) & mask) >> shift;
++}
++
++unsigned long ltq_get_io_region_clock(void)
++{
++ unsigned int ocp_sel;
++ unsigned long clk, cpu_clk;
++
++ cpu_clk = ltq_get_cpu_clock();
++
++ ocp_sel = ltq_cgu_sys_readl(LTQ_CGU_SYS_OCP_MASK,
++ LTQ_CGU_SYS_OCP_SHIFT);
++
++ switch (ocp_sel) {
++ case 0:
++ /* OCP ratio 1 */
++ clk = cpu_clk;
++ break;
++ case 2:
++ /* OCP ratio 2 */
++ clk = cpu_clk / 2;
++ break;
++ case 3:
++ /* OCP ratio 2.5 */
++ clk = (cpu_clk * 2) / 5;
++ break;
++ case 4:
++ /* OCP ratio 3 */
++ clk = cpu_clk / 3;
++ break;
++ default:
++ clk = 0;
++ break;
++ }
++
++ return clk;
++}
++
++unsigned long ltq_get_cpu_clock(void)
++{
++ unsigned int cpu_sel;
++ unsigned long clk;
++
++ cpu_sel = ltq_cgu_sys_readl(LTQ_CGU_SYS_CPU_MASK,
++ LTQ_CGU_SYS_CPU_SHIFT);
++
++ switch (cpu_sel) {
++ case 0:
++ clk = CLOCK_600_MHZ;
++ break;
++ case 1:
++ clk = CLOCK_500_MHZ;
++ break;
++ case 2:
++ clk = CLOCK_393_MHZ;
++ break;
++ case 3:
++ clk = CLOCK_333_MHZ;
++ break;
++ case 5:
++ case 6:
++ clk = CLOCK_197_MHZ;
++ break;
++ case 7:
++ clk = CLOCK_166_MHZ;
++ break;
++ case 4:
++ case 8:
++ case 9:
++ clk = CLOCK_125_MHZ;
++ break;
++ default:
++ clk = 0;
++ break;
++ }
++
++ return clk;
++}
++
++unsigned long ltq_get_bus_clock(void)
++{
++ return ltq_get_io_region_clock();
++}
++
++void ltq_cgu_gphy_clk_src(enum ltq_gphy_clk clk)
++{
++ ltq_clrbits(&ltq_cgu_regs->if_clk, LTQ_CGU_IFCLK_GPHY_SEL_MASK);
++ ltq_setbits(&ltq_cgu_regs->if_clk, clk << LTQ_CGU_IFCLK_GPHY_SEL_SHIFT);
++}
++
++static inline int ltq_cgu_pll1_locked(void)
++{
++ u32 pll1_cfg = ltq_readl(&ltq_cgu_regs->pll1_cfg);
++
++ return pll1_cfg & LTQ_CGU_PLL1_PLLL;
++}
++
++static inline void ltq_cgu_pll1_restart(unsigned m, unsigned n)
++{
++ u32 pll1_cfg;
++
++ ltq_clrbits(&ltq_cgu_regs->pll1_cfg, LTQ_CGU_PLL1_PLL_EN);
++ ltq_setbits(&ltq_cgu_regs->update, LTQ_CGU_UPDATE);
++
++ pll1_cfg = ltq_readl(&ltq_cgu_regs->pll1_cfg);
++ pll1_cfg &= ~(LTQ_CGU_PLL1_PLLN_MASK | LTQ_CGU_PLL1_PLLM_MASK);
++ pll1_cfg |= n << LTQ_CGU_PLL1_PLLN_SHIFT;
++ pll1_cfg |= m << LTQ_CGU_PLL1_PLLM_SHIFT;
++ pll1_cfg |= LTQ_CGU_PLL1_PLL_EN;
++ ltq_writel(&ltq_cgu_regs->pll1_cfg, pll1_cfg);
++ ltq_setbits(&ltq_cgu_regs->update, LTQ_CGU_UPDATE);
++
++ __udelay(1000);
++}
++
++/*
++ * From chapter 9 in errata sheet:
++ *
++ * Under certain condition, the PLL1 may failed to enter into lock
++ * status by hardware default N, M setting.
++ *
++ * Since system always starts from PLL0, the system software can run
++ * and re-program the PLL1 settings.
++ */
++static void ltq_cgu_pll1_init(void)
++{
++ unsigned i;
++ const unsigned pll1_m[] = { 1, 2, 3, 4 };
++ const unsigned pll1_n[] = { 21, 32, 43, 54 };
++
++ /* Check if PLL1 has locked with hardware default settings */
++ if (ltq_cgu_pll1_locked())
++ return;
++
++ for (i = 0; i < 4; i++) {
++ ltq_cgu_pll1_restart(pll1_m[i], pll1_n[i]);
++
++ if (ltq_cgu_pll1_locked())
++ goto done;
++ }
++
++done:
++ /* Restart with hardware default values M=5, N=64 */
++ ltq_cgu_pll1_restart(5, 64);
++}
++
++void ltq_pll_init(void)
++{
++ ltq_cgu_pll1_init();
++}
+--- /dev/null
++++ b/arch/mips/cpu/mips32/vrx200/cgu_init.S
+@@ -0,0 +1,120 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2010 Lantiq Deutschland GmbH
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <config.h>
++#include <asm/asm.h>
++#include <asm/regdef.h>
++#include <asm/addrspace.h>
++#include <asm/arch/soc.h>
++
++/* RCU module register */
++#define LTQ_RCU_RST_REQ 0x0010 /* Reset request */
++#define LTQ_RCU_RST_REQ_VALUE ((1 << 14) | (1 << 1))
++
++/* CGU module register */
++#define LTQ_CGU_PLL0_CFG 0x0004 /* PLL0 config */
++#define LTQ_CGU_PLL1_CFG 0x0008 /* PLL1 config */
++#define LTQ_CGU_PLL2_CFG 0x0060 /* PLL2 config */
++#define LTQ_CGU_SYS 0x000C /* System clock */
++#define LTQ_CGU_CLK_FSR 0x0010 /* Clock frequency select */
++#define LTQ_CGU_UPDATE 0x0020 /* Clock update control */
++
++/* Valid SYS.CPU values */
++#define LTQ_CGU_SYS_CPU_SHIFT 4
++#define LTQ_CGU_SYS_CPU_600_MHZ 0x0
++#define LTQ_CGU_SYS_CPU_500_MHZ 0x1
++#define LTQ_CGU_SYS_CPU_393_MHZ 0x2
++#define LTQ_CGU_SYS_CPU_333_MHZ 0x3
++#define LTQ_CGU_SYS_CPU_197_MHZ 0x5
++#define LTQ_CGU_SYS_CPU_166_MHZ 0x7
++#define LTQ_CGU_SYS_CPU_125_MHZ 0x9
++
++/* Valid SYS.OCP values */
++#define LTQ_CGU_SYS_OCP_SHIFT 0
++#define LTQ_CGU_SYS_OCP_1 0x0
++#define LTQ_CGU_SYS_OCP_2 0x2
++#define LTQ_CGU_SYS_OCP_2_5 0x3
++#define LTQ_CGU_SYS_OCP_3 0x4
++
++/* Valid CLK_FSR.ETH values */
++#define LTQ_CGU_CLK_FSR_ETH_SHIFT 24
++#define LTQ_CGU_CLK_FSR_ETH_50_MHZ 0x0
++#define LTQ_CGU_CLK_FSR_ETH_25_MHZ 0x1
++#define LTQ_CGU_CLK_FSR_ETH_2_5_MHZ 0x2
++#define LTQ_CGU_CLK_FSR_ETH_125_MHZ 0x3
++
++/* Valid CLK_FSR.PPE values */
++#define LTQ_CGU_CLK_FSR_PPE_SHIFT 16
++#define LTQ_CGU_CLK_FSR_PPE_500_MHZ 0x0 /* Overclock frequency */
++#define LTQ_CGU_CLK_FSR_PPE_450_MHZ 0x1 /* High frequency */
++#define LTQ_CGU_CLK_FSR_PPE_400_MHZ 0x2 /* Low frequency */
++
++#if (CONFIG_SYS_CLOCK_MODE == LTQ_CLK_CPU_500_DDR_250)
++#define LTQ_CGU_SYS_CPU_CONFIG LTQ_CGU_SYS_CPU_500_MHZ
++#define LTQ_CGU_SYS_OCP_CONFIG LTQ_CGU_SYS_OCP_2
++#define LTQ_CGU_CLK_FSR_ETH_CONFIG LTQ_CGU_CLK_FSR_ETH_125_MHZ
++#define LTQ_CGU_CLK_FSR_PPE_CONFIG LTQ_CGU_CLK_FSR_PPE_450_MHZ
++#else
++#error "Invalid system clock configuration!"
++#endif
++
++/* Build register values */
++#define LTQ_CGU_SYS_VALUE ((LTQ_CGU_SYS_CPU_CONFIG << \
++ LTQ_CGU_SYS_CPU_SHIFT) | \
++ LTQ_CGU_SYS_OCP_CONFIG)
++
++#define LTQ_CGU_CLK_FSR_VALUE ((LTQ_CGU_CLK_FSR_ETH_CONFIG << \
++ LTQ_CGU_CLK_FSR_ETH_SHIFT) | \
++ (LTQ_CGU_CLK_FSR_PPE_CONFIG << \
++ LTQ_CGU_CLK_FSR_PPE_SHIFT))
++
++ .set noreorder
++
++LEAF(ltq_cgu_init)
++ /* Load current CGU register values */
++ li t0, (LTQ_CGU_BASE | KSEG1)
++ lw t1, LTQ_CGU_SYS(t0)
++ lw t2, LTQ_CGU_CLK_FSR(t0)
++
++ /* Load target CGU register values */
++ li t3, LTQ_CGU_SYS_VALUE
++ li t4, LTQ_CGU_CLK_FSR_VALUE
++
++ /* Only update registers if values differ */
++ bne t1, t3, update
++ nop
++ beq t2, t4, finished
++ nop
++
++update:
++ /* Store target register values */
++ sw t3, LTQ_CGU_SYS(t0)
++ sw t4, LTQ_CGU_CLK_FSR(t0)
++
++ /* Perform software reset to activate new clock config */
++#if 0
++ li t0, (LTQ_RCU_BASE | KSEG1)
++ lw t1, LTQ_RCU_RST_REQ(t0)
++ or t1, LTQ_RCU_RST_REQ_VALUE
++ sw t1, LTQ_RCU_RST_REQ(t0)
++#else
++ li t1, 1
++ sw t1, LTQ_CGU_UPDATE(t0)
++#endif
++
++#if 0
++wait_reset:
++ b wait_reset
++ nop
++#endif
++
++finished:
++ jr ra
++ nop
++
++ END(ltq_cgu_init)
+--- /dev/null
++++ b/arch/mips/cpu/mips32/vrx200/chipid.c
+@@ -0,0 +1,63 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <common.h>
++#include <asm/lantiq/io.h>
++#include <asm/lantiq/chipid.h>
++#include <asm/arch/soc.h>
++
++#define LTQ_CHIPID_VERSION_SHIFT 28
++#define LTQ_CHIPID_VERSION_MASK (0x7 << LTQ_CHIPID_VERSION_SHIFT)
++#define LTQ_CHIPID_PNUM_SHIFT 12
++#define LTQ_CHIPID_PNUM_MASK (0xFFFF << LTQ_CHIPID_PNUM_SHIFT)
++
++struct ltq_chipid_regs {
++ u32 manid; /* Manufacturer identification */
++ u32 chipid; /* Chip identification */
++};
++
++static struct ltq_chipid_regs *ltq_chipid_regs =
++ (struct ltq_chipid_regs *) CKSEG1ADDR(LTQ_CHIPID_BASE);
++
++unsigned int ltq_chip_version_get(void)
++{
++ u32 chipid;
++
++ chipid = ltq_readl(&ltq_chipid_regs->chipid);
++
++ return (chipid & LTQ_CHIPID_VERSION_MASK) >> LTQ_CHIPID_VERSION_SHIFT;
++}
++
++unsigned int ltq_chip_partnum_get(void)
++{
++ u32 chipid;
++
++ chipid = ltq_readl(&ltq_chipid_regs->chipid);
++
++ return (chipid & LTQ_CHIPID_PNUM_MASK) >> LTQ_CHIPID_PNUM_SHIFT;
++}
++
++const char *ltq_chip_partnum_str(void)
++{
++ enum ltq_chip_partnum partnum = ltq_chip_partnum_get();
++
++ switch (partnum) {
++ case LTQ_SOC_VRX268:
++ case LTQ_SOC_VRX268_2:
++ return "VRX268";
++ case LTQ_SOC_VRX288:
++ case LTQ_SOC_VRX288_2:
++ return "VRX288";
++ case LTQ_SOC_GRX288:
++ case LTQ_SOC_GRX288_2:
++ return "GRX288";
++ default:
++ printf("Unknown partnum: %x\n", partnum);
++ }
++
++ return "";
++}
+--- /dev/null
++++ b/arch/mips/cpu/mips32/vrx200/config.mk
+@@ -0,0 +1,32 @@
++#
++# This file is released under the terms of GPL v2 and any later version.
++# See the file COPYING in the root directory of the source tree for details.
++#
++# Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++#
++
++PF_CPPFLAGS_XRX := $(call cc-option,-mtune=34kc,)
++PLATFORM_CPPFLAGS += $(PF_CPPFLAGS_XRX)
++
++ifdef CONFIG_SPL_BUILD
++PF_ABICALLS := -mno-abicalls
++PF_PIC := -fno-pic
++USE_PRIVATE_LIBGCC := yes
++endif
++
++LIBS-y += $(CPUDIR)/lantiq-common/liblantiq-common.o
++
++ifndef CONFIG_SPL_BUILD
++ifdef CONFIG_SYS_BOOT_SFSPL
++ALL-y += $(obj)u-boot.ltq.sfspl
++ALL-$(CONFIG_SPL_LZO_SUPPORT) += $(obj)u-boot.ltq.lzo.sfspl
++ALL-$(CONFIG_SPL_LZMA_SUPPORT) += $(obj)u-boot.ltq.lzma.sfspl
++endif
++ifdef CONFIG_SYS_BOOT_NORSPL
++ALL-y += $(obj)u-boot.ltq.norspl
++ALL-$(CONFIG_SPL_LZO_SUPPORT) += $(obj)u-boot.ltq.lzo.norspl
++ALL-$(CONFIG_SPL_LZMA_SUPPORT) += $(obj)u-boot.ltq.lzma.norspl
++endif
++endif
++
++LDSCRIPT := $(TOPDIR)/$(CPUDIR)/$(SOC)/u-boot.lds
+--- /dev/null
++++ b/arch/mips/cpu/mips32/vrx200/dcdc.c
+@@ -0,0 +1,107 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2010 Lantiq Deutschland GmbH
++ * Copyright (C) 2011-2012 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <common.h>
++#include <asm/arch/soc.h>
++#include <asm/lantiq/io.h>
++
++#define LTQ_DCDC_CLK_SET0_CLK_SEL_P (1 << 6)
++#define LTQ_DCDC_CLK_SET1_SEL_DIV25 (1 << 5)
++#define LTQ_DCDC_CONF_TEST_DIG_PID_FREEZE (1 << 5)
++
++struct ltq_dcdc_regs {
++ u8 b0_coeh; /* Coefficient b0 */
++ u8 b0_coel; /* Coefficient b0 */
++ u8 b1_coeh; /* Coefficient b1 */
++ u8 b1_coel; /* Coefficient b1 */
++ u8 b2_coeh; /* Coefficient b2 */
++ u8 b2_coel; /* Coefficient b2 */
++ u8 clk_set0; /* Clock setup */
++ u8 clk_set1; /* Clock setup */
++ u8 pwm_confh; /* Configure PWM */
++ u8 pwm_confl; /* Configure PWM */
++ u8 bias_vreg0; /* Bias and regulator setup */
++ u8 bias_vreg1; /* Bias and regulator setup */
++ u8 adc_gen0; /* ADC and general control */
++ u8 adc_gen1; /* ADC and general control */
++ u8 adc_con0; /* ADC and general config */
++ u8 adc_con1; /* ADC and general config */
++ u8 conf_test_ana; /* not documented */
++ u8 conf_test_dig; /* not documented */
++ u8 dcdc_status; /* not documented */
++ u8 pid_status; /* not documented */
++ u8 duty_cycle; /* not documented */
++ u8 non_ov_delay; /* not documented */
++ u8 analog_gain; /* not documented */
++ u8 duty_cycle_max_sat; /* not documented */
++ u8 duty_cycle_min_sat; /* not documented */
++ u8 duty_cycle_max; /* not documented */
++ u8 duty_cycle_min; /* not documented */
++ u8 error_max; /* not documented */
++ u8 error_read; /* not documented */
++ u8 delay_deglitch; /* not documented */
++ u8 latch_control; /* not documented */
++ u8 rsvd[240];
++ u8 osc_conf; /* OSC general config */
++ u8 osc_stat; /* OSC general status */
++};
++
++static struct ltq_dcdc_regs *ltq_dcdc_regs =
++ (struct ltq_dcdc_regs *) CKSEG1ADDR(LTQ_DCDC_BASE);
++
++void ltq_dcdc_init(unsigned int dig_ref)
++{
++ u8 dig_ref_cur, val;
++
++ /* Set duty cycle max sat. to 70/90, enable PID freeze */
++ ltq_writeb(&ltq_dcdc_regs->duty_cycle_max_sat, 0x5A);
++ ltq_writeb(&ltq_dcdc_regs->duty_cycle_min_sat, 0x46);
++ val = ltq_readb(&ltq_dcdc_regs->conf_test_dig);
++ val |= LTQ_DCDC_CONF_TEST_DIG_PID_FREEZE;
++ ltq_writeb(&ltq_dcdc_regs->conf_test_dig, val);
++
++ /* Program new coefficients */
++ ltq_writeb(&ltq_dcdc_regs->b0_coeh, 0x00);
++ ltq_writeb(&ltq_dcdc_regs->b0_coel, 0x00);
++ ltq_writeb(&ltq_dcdc_regs->b1_coeh, 0xFF);
++ ltq_writeb(&ltq_dcdc_regs->b1_coel, 0xE6);
++ ltq_writeb(&ltq_dcdc_regs->b2_coeh, 0x00);
++ ltq_writeb(&ltq_dcdc_regs->b2_coel, 0x1B);
++ ltq_writeb(&ltq_dcdc_regs->non_ov_delay, 0x8B);
++
++ /* Set duty cycle max sat. to 60/108, disable PID freeze */
++ ltq_writeb(&ltq_dcdc_regs->duty_cycle_max_sat, 0x6C);
++ ltq_writeb(&ltq_dcdc_regs->duty_cycle_min_sat, 0x3C);
++ val = ltq_readb(&ltq_dcdc_regs->conf_test_dig);
++ val &= ~LTQ_DCDC_CONF_TEST_DIG_PID_FREEZE;
++ ltq_writeb(&ltq_dcdc_regs->conf_test_dig, val);
++
++ /* Init clock and DLL settings */
++ val = ltq_readb(&ltq_dcdc_regs->clk_set0);
++ val |= LTQ_DCDC_CLK_SET0_CLK_SEL_P;
++ ltq_writeb(&ltq_dcdc_regs->clk_set0, val);
++ val = ltq_readb(&ltq_dcdc_regs->clk_set1);
++ val |= LTQ_DCDC_CLK_SET1_SEL_DIV25;
++ ltq_writeb(&ltq_dcdc_regs->clk_set1, val);
++ ltq_writeb(&ltq_dcdc_regs->pwm_confh, 0xF9);
++
++ wmb();
++
++ /* Adapt value of digital reference of DCDC converter */
++ dig_ref_cur = ltq_readb(&ltq_dcdc_regs->bias_vreg1);
++
++ while (dig_ref_cur != dig_ref) {
++ if (dig_ref >= dig_ref_cur)
++ dig_ref_cur++;
++ else if (dig_ref < dig_ref_cur)
++ dig_ref_cur--;
++
++ ltq_writeb(&ltq_dcdc_regs->bias_vreg1, dig_ref_cur);
++ __udelay(1000);
++ }
++}
+--- /dev/null
++++ b/arch/mips/cpu/mips32/vrx200/ebu.c
+@@ -0,0 +1,112 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <common.h>
++#include <asm/arch/soc.h>
++#include <asm/lantiq/io.h>
++
++#define EBU_ADDRSEL_MASK(mask) ((mask & 0xf) << 4)
++#define EBU_ADDRSEL_REGEN (1 << 0)
++
++#define EBU_CON_WRDIS (1 << 31)
++#define EBU_CON_AGEN_DEMUX (0x0 << 24)
++#define EBU_CON_AGEN_MUX (0x2 << 24)
++#define EBU_CON_SETUP (1 << 22)
++#define EBU_CON_WAIT_DIS (0x0 << 20)
++#define EBU_CON_WAIT_ASYNC (0x1 << 20)
++#define EBU_CON_WAIT_SYNC (0x2 << 20)
++#define EBU_CON_WINV (1 << 19)
++#define EBU_CON_PW_8BIT (0x0 << 16)
++#define EBU_CON_PW_16BIT (0x1 << 16)
++#define EBU_CON_ALEC(cycles) ((cycles & 0x3) << 14)
++#define EBU_CON_BCGEN_CS (0x0 << 12)
++#define EBU_CON_BCGEN_INTEL (0x1 << 12)
++#define EBU_CON_BCGEN_MOTOROLA (0x2 << 12)
++#define EBU_CON_WAITWRC(cycles) ((cycles & 0x7) << 8)
++#define EBU_CON_WAITRDC(cycles) ((cycles & 0x3) << 6)
++#define EBU_CON_HOLDC(cycles) ((cycles & 0x3) << 4)
++#define EBU_CON_RECOVC(cycles) ((cycles & 0x3) << 2)
++#define EBU_CON_CMULT_1 0x0
++#define EBU_CON_CMULT_4 0x1
++#define EBU_CON_CMULT_8 0x2
++#define EBU_CON_CMULT_16 0x3
++
++#if defined(CONFIG_LTQ_SUPPORT_NOR_FLASH)
++#define ebu_region0_enable 1
++#else
++#define ebu_region0_enable 0
++#endif
++
++#if defined(CONFIG_LTQ_SUPPORT_NAND_FLASH)
++#define ebu_region1_enable 1
++#else
++#define ebu_region1_enable 0
++#endif
++
++struct ltq_ebu_regs {
++ u32 clc;
++ u32 rsvd0;
++ u32 id;
++ u32 rsvd1;
++ u32 con;
++ u32 rsvd2[3];
++ u32 addr_sel_0;
++ u32 addr_sel_1;
++ u32 addr_sel_2;
++ u32 addr_sel_3;
++ u32 rsvd3[12];
++ u32 con_0;
++ u32 con_1;
++ u32 con_2;
++ u32 con_3;
++};
++
++static struct ltq_ebu_regs *ltq_ebu_regs =
++ (struct ltq_ebu_regs *) CKSEG1ADDR(LTQ_EBU_BASE);
++
++void ltq_ebu_init(void)
++{
++ if (ebu_region0_enable) {
++ /*
++ * Map EBU region 0 to range 0x10000000-0x13ffffff and enable
++ * region control. This supports up to 32 MiB NOR flash in
++ * bank 0.
++ */
++ ltq_writel(&ltq_ebu_regs->addr_sel_0, LTQ_EBU_REGION0_BASE |
++ EBU_ADDRSEL_MASK(1) | EBU_ADDRSEL_REGEN);
++
++ ltq_writel(&ltq_ebu_regs->con_0, EBU_CON_AGEN_DEMUX |
++ EBU_CON_WAIT_DIS | EBU_CON_PW_16BIT |
++ EBU_CON_ALEC(3) | EBU_CON_BCGEN_INTEL |
++ EBU_CON_WAITWRC(7) | EBU_CON_WAITRDC(3) |
++ EBU_CON_HOLDC(3) | EBU_CON_RECOVC(3) |
++ EBU_CON_CMULT_16);
++ } else
++ ltq_clrbits(&ltq_ebu_regs->addr_sel_0, EBU_ADDRSEL_REGEN);
++
++ if (ebu_region1_enable) {
++ /*
++ * Map EBU region 1 to range 0x14000000-0x13ffffff and enable
++ * region control. This supports NAND flash in bank 1.
++ */
++ ltq_writel(&ltq_ebu_regs->addr_sel_1, LTQ_EBU_REGION1_BASE |
++ EBU_ADDRSEL_MASK(3) | EBU_ADDRSEL_REGEN);
++
++ ltq_writel(&ltq_ebu_regs->con_1, EBU_CON_AGEN_DEMUX |
++ EBU_CON_SETUP | EBU_CON_WAIT_DIS | EBU_CON_PW_8BIT |
++ EBU_CON_ALEC(3) | EBU_CON_BCGEN_INTEL |
++ EBU_CON_WAITWRC(2) | EBU_CON_WAITRDC(2) |
++ EBU_CON_HOLDC(1) | EBU_CON_RECOVC(1) |
++ EBU_CON_CMULT_4);
++ } else
++ ltq_clrbits(&ltq_ebu_regs->addr_sel_1, EBU_ADDRSEL_REGEN);
++}
++
++void *flash_swap_addr(unsigned long addr)
++{
++ return (void *)(addr ^ 2);
++}
+--- /dev/null
++++ b/arch/mips/cpu/mips32/vrx200/gphy.c
+@@ -0,0 +1,59 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <common.h>
++#include <asm/lantiq/io.h>
++#include <asm/arch/soc.h>
++#include <asm/arch/gphy.h>
++
++static inline void ltq_gphy_copy(const void *fw_start, const void *fw_end,
++ ulong dst_addr)
++{
++ const ulong fw_len = (ulong) fw_end - (ulong) fw_start;
++ const ulong addr = CKSEG1ADDR(dst_addr);
++
++ debug("ltq_gphy_copy: addr %08lx, fw_start %p, fw_end %p\n",
++ addr, fw_start, fw_end);
++
++ memcpy((void *) addr, fw_start, fw_len);
++}
++
++void ltq_gphy_phy11g_a1x_load(ulong addr)
++{
++ extern ulong __ltq_fw_phy11g_a1x_start;
++ extern ulong __ltq_fw_phy11g_a1x_end;
++
++ ltq_gphy_copy(&__ltq_fw_phy11g_a1x_start, &__ltq_fw_phy11g_a1x_end,
++ addr);
++}
++
++void ltq_gphy_phy11g_a2x_load(ulong addr)
++{
++ extern ulong __ltq_fw_phy11g_a2x_start;
++ extern ulong __ltq_fw_phy11g_a2x_end;
++
++ ltq_gphy_copy(&__ltq_fw_phy11g_a2x_start, &__ltq_fw_phy11g_a2x_end,
++ addr);
++}
++
++void ltq_gphy_phy22f_a1x_load(ulong addr)
++{
++ extern ulong __ltq_fw_phy22f_a1x_start;
++ extern ulong __ltq_fw_phy22f_a1x_end;
++
++ ltq_gphy_copy(&__ltq_fw_phy22f_a1x_start, &__ltq_fw_phy22f_a1x_end,
++ addr);
++}
++
++void ltq_gphy_phy22f_a2x_load(ulong addr)
++{
++ extern ulong __ltq_fw_phy22f_a2x_start;
++ extern ulong __ltq_fw_phy22f_a2x_end;
++
++ ltq_gphy_copy(&__ltq_fw_phy22f_a2x_start, &__ltq_fw_phy22f_a2x_end,
++ addr);
++}
+--- /dev/null
++++ b/arch/mips/cpu/mips32/vrx200/gphy_fw.S
+@@ -0,0 +1,28 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <asm/asm.h>
++
++ .section .rodata.__ltq_fw_phy11g_a1x
++EXPORT(__ltq_fw_phy11g_a1x_start)
++ .incbin "fw_phy11g_a1x.bin"
++EXPORT(__ltq_fw_phy11g_a1x_end)
++
++ .section .rodata.__ltq_fw_phy11g_a2x
++EXPORT(__ltq_fw_phy11g_a2x_start)
++ .incbin "fw_phy11g_a2x.bin"
++EXPORT(__ltq_fw_phy11g_a2x_end)
++
++ .section .rodata.__ltq_fw_phy22f_a1x
++EXPORT(__ltq_fw_phy22f_a1x_start)
++ .incbin "fw_phy22f_a1x.bin"
++EXPORT(__ltq_fw_phy22f_a1x_end)
++
++ .section .rodata.__ltq_fw_phy22f_a2x
++EXPORT(__ltq_fw_phy22f_a2x_start)
++ .incbin "fw_phy22f_a2x.bin"
++EXPORT(__ltq_fw_phy22f_a2x_end)
+--- /dev/null
++++ b/arch/mips/cpu/mips32/vrx200/mem.c
+@@ -0,0 +1,58 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <common.h>
++#include <asm/arch/soc.h>
++#include <asm/lantiq/io.h>
++
++#define LTQ_CCR03_EIGHT_BANK_MODE (1 << 0)
++#define LTQ_CCR08_CS_MAP_SHIFT 24
++#define LTQ_CCR08_CS_MAP_MASK (0x3 << LTQ_CCR08_CS_MAP_SHIFT)
++#define LTQ_CCR11_COLUMN_SIZE_SHIFT 24
++#define LTQ_CCR11_COLUMN_SIZE_MASK (0x7 << LTQ_CCR11_COLUMN_SIZE_SHIFT)
++#define LTQ_CCR11_ADDR_PINS_MASK 0x7
++#define LTQ_CCR15_MAX_COL_REG_SHIFT 24
++#define LTQ_CCR15_MAX_COL_REG_MASK (0xF << LTQ_CCR15_MAX_COL_REG_SHIFT)
++#define LTQ_CCR16_MAX_ROW_REG_MASK 0xF
++
++static void *ltq_mc_ddr_base = (void *) CKSEG1ADDR(LTQ_MC_DDR_BASE);
++
++static inline u32 ltq_mc_ccr_read(u32 index)
++{
++ return ltq_readl(ltq_mc_ddr_base + LTQ_MC_DDR_CCR_OFFSET(index));
++}
++
++phys_size_t initdram(int board_type)
++{
++ u32 max_col_reg, max_row_reg, column_size, addr_pins;
++ u32 banks, cs_map;
++ phys_size_t size;
++
++ banks = (ltq_mc_ccr_read(3) & LTQ_CCR03_EIGHT_BANK_MODE) ? 8 : 4;
++
++ cs_map = (ltq_mc_ccr_read(8) & LTQ_CCR08_CS_MAP_MASK) >>
++ LTQ_CCR08_CS_MAP_SHIFT;
++
++ column_size = (ltq_mc_ccr_read(11) & LTQ_CCR11_COLUMN_SIZE_MASK) >>
++ LTQ_CCR11_COLUMN_SIZE_SHIFT;
++
++ addr_pins = ltq_mc_ccr_read(11) & LTQ_CCR11_ADDR_PINS_MASK;
++
++ max_col_reg = (ltq_mc_ccr_read(15) & LTQ_CCR15_MAX_COL_REG_MASK) >>
++ LTQ_CCR15_MAX_COL_REG_SHIFT;
++
++ max_row_reg = ltq_mc_ccr_read(16) & LTQ_CCR16_MAX_ROW_REG_MASK;
++
++ /*
++ * size (bytes) = 2 ^ rowsize * 2 ^ colsize * banks * chipselects
++ * * datawidth (bytes)
++ */
++ size = (2 << (max_col_reg - column_size - 1)) *
++ (2 << (max_row_reg - addr_pins - 1)) * banks * cs_map * 2;
++
++ return size;
++}
+--- /dev/null
++++ b/arch/mips/cpu/mips32/vrx200/mem_init.S
+@@ -0,0 +1,234 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2010 Lantiq Deutschland GmbH
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <config.h>
++#include <asm/asm.h>
++#include <asm/regdef.h>
++#include <asm/addrspace.h>
++#include <asm/arch/soc.h>
++
++/* Must be configured in BOARDDIR */
++#include <ddr_settings.h>
++
++#define LTQ_MC_DDR_START (1 << 8)
++#define LTQ_MC_DDR_DLL_LOCK_IND 1
++
++#define CCS_ALWAYS_LAST 0x0430
++#define CCS_AHBM_CR_BURST_EN (1 << 2)
++#define CCS_FPIM_CR_BURST_EN (1 << 1)
++
++#define CCR03_EIGHT_BANK_MODE (1 << 0)
++
++ /* Store given value in MC DDR CCRx register */
++ .macro ccr_sw num, val
++ li t1, \val
++ sw t1, LTQ_MC_DDR_CCR_OFFSET(\num)(t0)
++ .endm
++
++LEAF(ltq_mem_init)
++ /* Load MC DDR module base */
++ li t0, (LTQ_MC_DDR_BASE | KSEG1)
++
++ /* Put memory controller in inactive mode */
++ sw zero, LTQ_MC_DDR_CCR_OFFSET(7)(t0)
++
++ /* Init MC DDR CCR registers with values from ddr_settings.h */
++ ccr_sw 0, MC_CCR00_VALUE
++ ccr_sw 1, MC_CCR01_VALUE
++ ccr_sw 2, MC_CCR02_VALUE
++ ccr_sw 3, MC_CCR03_VALUE
++ ccr_sw 4, MC_CCR04_VALUE
++ ccr_sw 5, MC_CCR05_VALUE
++ ccr_sw 6, MC_CCR06_VALUE
++ ccr_sw 7, MC_CCR07_VALUE
++ ccr_sw 8, MC_CCR08_VALUE
++ ccr_sw 9, MC_CCR09_VALUE
++
++ ccr_sw 10, MC_CCR10_VALUE
++ ccr_sw 11, MC_CCR11_VALUE
++ ccr_sw 12, MC_CCR12_VALUE
++ ccr_sw 13, MC_CCR13_VALUE
++ ccr_sw 14, MC_CCR14_VALUE
++ ccr_sw 15, MC_CCR15_VALUE
++ ccr_sw 16, MC_CCR16_VALUE
++ ccr_sw 17, MC_CCR17_VALUE
++ ccr_sw 18, MC_CCR18_VALUE
++ ccr_sw 19, MC_CCR19_VALUE
++
++ ccr_sw 20, MC_CCR20_VALUE
++ ccr_sw 21, MC_CCR21_VALUE
++ ccr_sw 22, MC_CCR22_VALUE
++ ccr_sw 23, MC_CCR23_VALUE
++ ccr_sw 24, MC_CCR24_VALUE
++ ccr_sw 25, MC_CCR25_VALUE
++ ccr_sw 26, MC_CCR26_VALUE
++ ccr_sw 27, MC_CCR27_VALUE
++ ccr_sw 28, MC_CCR28_VALUE
++ ccr_sw 29, MC_CCR29_VALUE
++
++ ccr_sw 30, MC_CCR30_VALUE
++ ccr_sw 31, MC_CCR31_VALUE
++ ccr_sw 32, MC_CCR32_VALUE
++ ccr_sw 33, MC_CCR33_VALUE
++ ccr_sw 34, MC_CCR34_VALUE
++ ccr_sw 35, MC_CCR35_VALUE
++ ccr_sw 36, MC_CCR36_VALUE
++ ccr_sw 37, MC_CCR37_VALUE
++ ccr_sw 38, MC_CCR38_VALUE
++ ccr_sw 39, MC_CCR39_VALUE
++
++ ccr_sw 40, MC_CCR40_VALUE
++ ccr_sw 41, MC_CCR41_VALUE
++ ccr_sw 42, MC_CCR42_VALUE
++ ccr_sw 43, MC_CCR43_VALUE
++ ccr_sw 44, MC_CCR44_VALUE
++ ccr_sw 45, MC_CCR45_VALUE
++ ccr_sw 46, MC_CCR46_VALUE
++
++ ccr_sw 52, MC_CCR52_VALUE
++ ccr_sw 53, MC_CCR53_VALUE
++ ccr_sw 54, MC_CCR54_VALUE
++ ccr_sw 55, MC_CCR55_VALUE
++ ccr_sw 56, MC_CCR56_VALUE
++ ccr_sw 57, MC_CCR57_VALUE
++ ccr_sw 58, MC_CCR58_VALUE
++ ccr_sw 59, MC_CCR59_VALUE
++
++ ccr_sw 60, MC_CCR60_VALUE
++ ccr_sw 61, MC_CCR61_VALUE
++
++ /* Disable bursts between FPI Master bus and XBAR bus */
++ li t4, (LTQ_MC_GLOBAL_BASE | KSEG1)
++ li t5, CCS_AHBM_CR_BURST_EN
++ sw t5, CCS_ALWAYS_LAST(t4)
++
++ /* Init abort condition for DRAM probe */
++ move t4, zero
++
++ /*
++ * Put memory controller in active mode and start initialitation
++ * sequence for connected DDR-SDRAM device
++ */
++mc_start:
++ lw t1, LTQ_MC_DDR_CCR_OFFSET(7)(t0)
++ li t2, LTQ_MC_DDR_START
++ or t1, t1, t2
++ sw t1, LTQ_MC_DDR_CCR_OFFSET(7)(t0)
++
++ /*
++ * Wait until DLL has locked and core is ready for data transfers.
++ * DLL lock indication is in register CCR47 and CCR48
++ */
++wait_ready:
++ li t1, LTQ_MC_DDR_DLL_LOCK_IND
++ lw t2, LTQ_MC_DDR_CCR_OFFSET(47)(t0)
++ and t2, t2, t1
++ bne t1, t2, wait_ready
++
++ lw t2, LTQ_MC_DDR_CCR_OFFSET(48)(t0)
++ and t2, t2, t1
++ bne t1, t2, wait_ready
++
++#ifdef CONFIG_SYS_DRAM_PROBE
++dram_probe:
++ /* Initialization is finished after the second MC start */
++ bnez t4, mc_finished
++
++ /*
++ * Preload register values for CCR03 and CCR11. Initial settings
++ * are 8-bank mode enabled, 14 use address row bits, 10 used
++ * column address bits.
++ */
++ li t1, CONFIG_SYS_SDRAM_BASE_UC
++ li t5, MC_CCR03_VALUE
++ li t6, MC_CCR11_VALUE
++ addi t4, t4, 1
++
++ /*
++ * Store test values to DRAM at offsets 0 and 2^13 (bit 2 in bank select
++ * address BA[3]) and read back the value at offset 0. If the resulting
++ * value is equal to 1 we can skip to the next test. Otherwise
++ * the 8-bank mode does not work with the current DRAM device,
++ * thus we need to clear the according bit in register CCR03.
++ */
++ li t2, 1
++ sw t2, 0x0(t1)
++ li t3, (1 << 13)
++ add t3, t3, t1
++ sw zero, 0(t3)
++ lw t3, 0(t1)
++ bnez t3, row_col_test
++
++ /* Clear CCR03.EIGHT_BANK_MODE */
++ li t3, ~CCR03_EIGHT_BANK_MODE
++ and t5, t5, t3
++
++row_col_test:
++ /*
++ * Store test values to DRAM at offsets 0, 2^27 (bit 13 of row address
++ * RA[14]) and 2^26 (bit 12 of RA[14]). The chosen test values
++ * represent the difference between max. row address bits (14) and used
++ * row address bits. Then the read back value at offset 0 indicates
++ * the useable row address bits with the current DRAM device. This
++ * value must be set in the CCR11 register.
++ */
++ sw zero, 0(t1)
++
++ li t2, 1
++ li t3, (1 << 27)
++ add t3, t3, t1
++ sw t2, 0(t3)
++
++ li t2, 2
++ li t3, (1 << 26)
++ add t3, t3, t1
++ sw t2, 0(t3)
++
++ /* Update CCR11.ADDR_PINS */
++ lw t3, 0(t1)
++ add t6, t6, t3
++
++ /*
++ * Store test values to DRAM at offsets 0, 2^10 (bit 9 of column address
++ * CA[10]) and 2^9 (bit 8 of CA[10]). The chosen test values represent
++ * the difference between max. column address bits (12) and used
++ * column address bits. Then the read back value at offset 0 indicates
++ * the useable column address bits with the current DRAM device. This
++ * value must be set in the CCR11 register.
++ */
++ sw zero, 0(t1)
++
++ li t2, 1
++ li t3, (1 << 10)
++ add t3, t3, t1
++ sw t2, 0(t3)
++
++ li t2, 2
++ li t3, (1 << 9)
++ add t3, t3, t1
++ sw t2, 0(t3)
++
++ /* Update CCR11.COLUMN_SIZE */
++ lw t3, 0(t1)
++ sll t3, t3, 24
++ add t6, t6, t3
++
++ /* Put memory controller in inactive mode */
++ sw zero, LTQ_MC_DDR_CCR_OFFSET(7)(t0)
++
++ /* Update CCR03 and CCR11 and restart memory controller initialiation */
++ sw t5, LTQ_MC_DDR_CCR_OFFSET(3)(t0)
++ sw t6, LTQ_MC_DDR_CCR_OFFSET(11)(t0)
++ b mc_start
++
++mc_finished:
++#endif /* CONFIG_SYS_DRAM_PROBE */
++
++ jr ra
++
++ END(ltq_mem_init)
+--- /dev/null
++++ b/arch/mips/cpu/mips32/vrx200/pmu.c
+@@ -0,0 +1,131 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <common.h>
++#include <asm/lantiq/io.h>
++#include <asm/lantiq/pm.h>
++#include <asm/arch/soc.h>
++
++#define LTQ_PMU_PWDCR_RESERVED ((1 << 13) | (1 << 4))
++
++#define LTQ_PMU_PWDCR_PCIELOC_EN (1 << 31)
++#define LTQ_PMU_PWDCR_GPHY (1 << 30)
++#define LTQ_PMU_PWDCR_PPE_TOP (1 << 29)
++#define LTQ_PMU_PWDCR_SWITCH (1 << 28)
++#define LTQ_PMU_PWDCR_USB1 (1 << 27)
++#define LTQ_PMU_PWDCR_USB1_PHY (1 << 26)
++#define LTQ_PMU_PWDCR_TDM (1 << 25)
++#define LTQ_PMU_PWDCR_PPE_DPLUS (1 << 24)
++#define LTQ_PMU_PWDCR_PPE_DPLUM (1 << 23)
++#define LTQ_PMU_PWDCR_PPE_EMA (1 << 22)
++#define LTQ_PMU_PWDCR_PPE_TC (1 << 21)
++#define LTQ_PMU_PWDCR_DEU (1 << 20)
++#define LTQ_PMU_PWDCR_PPE_SLL01 (1 << 19)
++#define LTQ_PMU_PWDCR_PPE_QSB (1 << 18)
++#define LTQ_PMU_PWDCR_UART1 (1 << 17)
++#define LTQ_PMU_PWDCR_SDIO (1 << 16)
++#define LTQ_PMU_PWDCR_AHBM (1 << 15)
++#define LTQ_PMU_PWDCR_FPIM (1 << 14)
++#define LTQ_PMU_PWDCR_GPTC (1 << 12)
++#define LTQ_PMU_PWDCR_LEDC (1 << 11)
++#define LTQ_PMU_PWDCR_EBU (1 << 10)
++#define LTQ_PMU_PWDCR_DSL (1 << 9)
++#define LTQ_PMU_PWDCR_SPI (1 << 8)
++#define LTQ_PMU_PWDCR_USIF (1 << 7)
++#define LTQ_PMU_PWDCR_USB0 (1 << 6)
++#define LTQ_PMU_PWDCR_DMA (1 << 5)
++#define LTQ_PMU_PWDCR_DFEV1 (1 << 3)
++#define LTQ_PMU_PWDCR_DFEV0 (1 << 2)
++#define LTQ_PMU_PWDCR_FPIS (1 << 1)
++#define LTQ_PMU_PWDCR_USB0_PHY (1 << 0)
++
++struct ltq_pmu_regs {
++ u32 rsvd0[7];
++ u32 pwdcr; /* Power down control */
++ u32 sr; /* Power down status */
++ u32 pwdcr1; /* Power down control 1 */
++ u32 sr1; /* Power down status 1 */
++};
++
++static struct ltq_pmu_regs *ltq_pmu_regs =
++ (struct ltq_pmu_regs *) CKSEG1ADDR(LTQ_PMU_BASE);
++
++u32 ltq_pm_map(enum ltq_pm_modules module)
++{
++ u32 val;
++
++ switch (module) {
++ case LTQ_PM_CORE:
++ val = LTQ_PMU_PWDCR_UART1 | LTQ_PMU_PWDCR_FPIM |
++ LTQ_PMU_PWDCR_LEDC | LTQ_PMU_PWDCR_EBU;
++ break;
++ case LTQ_PM_DMA:
++ val = LTQ_PMU_PWDCR_DMA;
++ break;
++ case LTQ_PM_ETH:
++ val = LTQ_PMU_PWDCR_GPHY | LTQ_PMU_PWDCR_PPE_TOP |
++ LTQ_PMU_PWDCR_SWITCH | LTQ_PMU_PWDCR_PPE_DPLUS |
++ LTQ_PMU_PWDCR_PPE_DPLUM | LTQ_PMU_PWDCR_PPE_EMA |
++ LTQ_PMU_PWDCR_PPE_TC | LTQ_PMU_PWDCR_PPE_SLL01 |
++ LTQ_PMU_PWDCR_PPE_QSB;
++ break;
++ case LTQ_PM_SPI:
++ val = LTQ_PMU_PWDCR_SPI;
++ break;
++ default:
++ val = 0;
++ break;
++ }
++
++ return val;
++}
++
++int ltq_pm_enable(enum ltq_pm_modules module)
++{
++ const unsigned long timeout = 1000;
++ unsigned long timebase;
++ u32 sr, val;
++
++ val = ltq_pm_map(module);
++ if (unlikely(!val))
++ return 1;
++
++ ltq_clrbits(&ltq_pmu_regs->pwdcr, val);
++
++ timebase = get_timer(0);
++
++ do {
++ sr = ltq_readl(&ltq_pmu_regs->sr);
++ if (~sr & val)
++ return 0;
++ } while (get_timer(timebase) < timeout);
++
++ return 1;
++}
++
++int ltq_pm_disable(enum ltq_pm_modules module)
++{
++ u32 val;
++
++ val = ltq_pm_map(module);
++ if (unlikely(!val))
++ return 1;
++
++ ltq_setbits(&ltq_pmu_regs->pwdcr, val);
++
++ return 0;
++}
++
++void ltq_pmu_init(void)
++{
++ u32 set, clr;
++
++ clr = ltq_pm_map(LTQ_PM_CORE);
++ set = ~(LTQ_PMU_PWDCR_RESERVED | clr);
++
++ ltq_clrsetbits(&ltq_pmu_regs->pwdcr, clr, set);
++}
+--- /dev/null
++++ b/arch/mips/cpu/mips32/vrx200/rcu.c
+@@ -0,0 +1,195 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <common.h>
++#include <asm/lantiq/io.h>
++#include <asm/lantiq/reset.h>
++#include <asm/lantiq/cpu.h>
++#include <asm/arch/soc.h>
++
++#define LTQ_RCU_RD_GPHY0 (1 << 31) /* GPHY0 */
++#define LTQ_RCU_RD_SRST (1 << 30) /* Global SW Reset */
++#define LTQ_RCU_RD_GPHY1 (1 << 29) /* GPHY1 */
++#define LTQ_RCU_RD_ENMIP2 (1 << 28) /* Enable NMI of PLL2 */
++#define LTQ_RCU_RD_REG25_PD (1 << 26) /* Power down 2.5V regulator */
++#define LTQ_RCU_RD_ENDINIT (1 << 25) /* FPI slave bus access */
++#define LTQ_RCU_RD_PPE_ATM_TC (1 << 23) /* PPE ATM TC */
++#define LTQ_RCU_RD_PCIE (1 << 22) /* PCI-E core */
++#define LTQ_RCU_RD_ETHSW (1 << 21) /* Ethernet switch */
++#define LTQ_RCU_RD_DSP_DEN (1 << 20) /* Enable DSP JTAG */
++#define LTQ_RCU_RD_TDM (1 << 19) /* TDM module interface */
++#define LTQ_RCU_RD_ENMIP1 (1 << 18) /* Enable NMI of PLL1 */
++#define LTQ_RCU_RD_SWBCK (1 << 17) /* Switch backward compat */
++#define LTQ_RCU_RD_HSNAND (1 << 16) /* HSNAND controller */
++#define LTQ_RCU_RD_ENMIP0 (1 << 15) /* Enable NMI of PLL0 */
++#define LTQ_RCU_RD_MC (1 << 14) /* Memory Controller */
++#define LTQ_RCU_RD_PCI (1 << 13) /* PCI core */
++#define LTQ_RCU_RD_PCIE_PHY (1 << 12) /* PCI-E Phy */
++#define LTQ_RCU_RD_DFE_CORE (1 << 11) /* DFE core */
++#define LTQ_RCU_RD_SDIO (1 << 10) /* SDIO core */
++#define LTQ_RCU_RD_DMA (1 << 9) /* DMA core */
++#define LTQ_RCU_RD_PPE (1 << 8) /* PPE core */
++#define LTQ_RCU_RD_DFE (1 << 7) /* DFE core */
++#define LTQ_RCU_RD_AHB (1 << 6) /* AHB bus */
++#define LTQ_RCU_RD_HRST_CFG (1 << 5) /* HW reset configuration */
++#define LTQ_RCU_RD_USB (1 << 4) /* USB and Phy core */
++#define LTQ_RCU_RD_PPE_DSP (1 << 3) /* PPE DSP interface */
++#define LTQ_RCU_RD_FPI (1 << 2) /* FPI bus */
++#define LTQ_RCU_RD_CPU (1 << 1) /* CPU subsystem */
++#define LTQ_RCU_RD_HRST (1 << 0) /* HW reset via HRST pin */
++
++#define LTQ_RCU_STAT_BOOT_SHIFT 17
++#define LTQ_RCU_STAT_BOOT_MASK (0xF << LTQ_RCU_STAT_BOOT_SHIFT)
++#define LTQ_RCU_STAT_BOOT_H (1 << 12)
++
++#define LTQ_RCU_GP_STRAP_CLOCKSOURCE (1 << 15)
++
++struct ltq_rcu_regs {
++ u32 rsvd0[4];
++ u32 req; /* Reset request */
++ u32 stat; /* Reset status */
++ u32 usb0_cfg; /* USB0 configure */
++ u32 gp_strap; /* GPIO strapping */
++ u32 gfs_add0; /* GPHY0 firmware base addr */
++ u32 stat2; /* SLIC and USB reset status */
++ u32 pci_rdy; /* PCI boot ready */
++ u32 ppe_conf; /* PPE ethernet config */
++ u32 pcie_phy_con; /* PCIE PHY config/status */
++ u32 usb1_cfg; /* USB1 configure */
++ u32 usb_ana_cfg1a; /* USB analog config 1a */
++ u32 usb_ana_cfg1b; /* USB analog config 1b */
++ u32 rsvd1;
++ u32 gf_mdio_add; /* GPHY0/1 MDIO address */
++ u32 req2; /* SLIC and USB reset request */
++ u32 ahb_endian; /* AHB bus endianess */
++ u32 rsvd2[4];
++ u32 gcc; /* General CPU config */
++ u32 rsvd3;
++ u32 gfs_add1; /* GPHY1 firmware base addr */
++};
++
++static struct ltq_rcu_regs *ltq_rcu_regs =
++ (struct ltq_rcu_regs *) CKSEG1ADDR(LTQ_RCU_BASE);
++
++u32 ltq_reset_map(enum ltq_reset_modules module)
++{
++ u32 val;
++
++ switch (module) {
++ case LTQ_RESET_CORE:
++ case LTQ_RESET_SOFT:
++ val = LTQ_RCU_RD_SRST | LTQ_RCU_RD_CPU | LTQ_RCU_RD_ENMIP2 |
++ LTQ_RCU_RD_GPHY1 | LTQ_RCU_RD_GPHY0;
++ break;
++ case LTQ_RESET_DMA:
++ val = LTQ_RCU_RD_DMA;
++ break;
++ case LTQ_RESET_ETH:
++ val = LTQ_RCU_RD_PPE | LTQ_RCU_RD_ETHSW;
++ break;
++ case LTQ_RESET_PHY:
++ val = LTQ_RCU_RD_GPHY1 | LTQ_RCU_RD_GPHY0;
++ break;
++ case LTQ_RESET_HARD:
++ val = LTQ_RCU_RD_HRST;
++ break;
++ default:
++ val = 0;
++ break;
++ }
++
++ return val;
++}
++
++int ltq_reset_activate(enum ltq_reset_modules module)
++{
++ u32 val;
++
++ val = ltq_reset_map(module);
++ if (unlikely(!val))
++ return 1;
++
++ ltq_setbits(&ltq_rcu_regs->req, val);
++
++ return 0;
++}
++
++int ltq_reset_deactivate(enum ltq_reset_modules module)
++{
++ u32 val;
++
++ val = ltq_reset_map(module);
++ if (unlikely(!val))
++ return 1;
++
++ ltq_clrbits(&ltq_rcu_regs->req, val);
++
++ return 0;
++}
++
++enum ltq_boot_select ltq_boot_select(void)
++{
++ u32 stat;
++ unsigned int bootstrap;
++
++ /*
++ * Boot select value is built from bits 20-17 and bit 12.
++ * The bit sequence is read as 4-2-1-0-3.
++ */
++ stat = ltq_readl(&ltq_rcu_regs->stat);
++ bootstrap = ((stat & LTQ_RCU_STAT_BOOT_H) << 4) |
++ ((stat & LTQ_RCU_STAT_BOOT_MASK) >> LTQ_RCU_STAT_BOOT_SHIFT);
++
++ switch (bootstrap) {
++ case 0:
++ return BOOT_NOR_NO_BOOTROM;
++ case 1:
++ return BOOT_RGMII1;
++ case 2:
++ return BOOT_NOR;
++ case 4:
++ return BOOT_UART_NO_EEPROM;
++ case 6:
++ return BOOT_PCI;
++ case 8:
++ return BOOT_UART;
++ case 10:
++ return BOOT_SPI;
++ case 12:
++ return BOOT_NAND;
++ default:
++ return BOOT_UNKNOWN;
++ }
++}
++
++void ltq_rcu_gphy_boot(unsigned int id, ulong addr)
++{
++ u32 module;
++ void *gfs_add;
++
++ switch (id) {
++ case 0:
++ module = LTQ_RCU_RD_GPHY0;
++ gfs_add = &ltq_rcu_regs->gfs_add0;
++ break;
++ case 1:
++ module = LTQ_RCU_RD_GPHY1;
++ gfs_add = &ltq_rcu_regs->gfs_add1;
++ break;
++ default:
++ BUG();
++ }
++
++ /* Stop and reset GPHY */
++ ltq_setbits(&ltq_rcu_regs->req, module);
++
++ /* Configure firmware and boot address */
++ ltq_writel(gfs_add, CPHYSADDR(addr & 0xFFFFC000));
++
++ /* Start GPHY by releasing reset */
++ ltq_clrbits(&ltq_rcu_regs->req, module);
++}
+--- /dev/null
++++ b/arch/mips/cpu/mips32/vrx200/u-boot.lds
+@@ -0,0 +1,69 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2003 Wolfgang Denk, DENX Software Engineering, wd@denx.de
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradlittlemips")
++OUTPUT_ARCH(mips)
++ENTRY(_start)
++SECTIONS
++{
++ . = 0x00000000;
++
++ . = ALIGN(4);
++ .text : {
++ *(.text*)
++ }
++
++ . = ALIGN(4);
++ .rodata : {
++ *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*)))
++ }
++
++ . = ALIGN(4);
++ .data : {
++ *(.data*)
++ }
++
++ . = ALIGN(4);
++ .sdata : {
++ *(.sdata*)
++ }
++
++ . = .;
++ _gp = ALIGN(16) + 0x7ff0;
++
++ .got : {
++ __got_start = .;
++ *(.got)
++ __got_end = .;
++ }
++
++ num_got_entries = (__got_end - __got_start) >> 2;
++
++#ifndef CONFIG_SPL_BUILD
++ . = ALIGN(4);
++ .u_boot_list : {
++ #include <u-boot.lst>
++ }
++#endif
++
++ . = ALIGN(4);
++ __image_copy_end = .;
++ uboot_end_data = .;
++
++ .bss (NOLOAD) : {
++ __bss_start = .;
++ *(.bss*)
++ *(.sbss*)
++ . = ALIGN(4);
++ __bss_end = .;
++ }
++
++ . = ALIGN(4);
++ __end = .;
++ uboot_end = .;
++}
+--- /dev/null
++++ b/arch/mips/include/asm/arch-danube/config.h
+@@ -0,0 +1,156 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2007-2010 Lantiq Deutschland GmbH
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ *
++ * Common board configuration for Lantiq XWAY Danube family
++ *
++ * Use following defines in your board config to enable specific features
++ * and drivers for this SoC:
++ *
++ * CONFIG_LTQ_SUPPORT_UART
++ * - support the Danube ASC/UART interface and console
++ *
++ * CONFIG_LTQ_SUPPORT_NOR_FLASH
++ * - support a parallel NOR flash via the CFI interface in flash bank 0
++ *
++ * CONFIG_LTQ_SUPPORT_ETHERNET
++ * - support the Danube ETOP and MAC interface
++ *
++ * CONFIG_LTQ_SUPPORT_SPI_FLASH
++ * - support the Danube SPI interface and serial flash drivers
++ * - specific SPI flash drivers must be configured separately
++ */
++
++#ifndef __DANUBE_CONFIG_H__
++#define __DANUBE_CONFIG_H__
++
++/* CPU and SoC type */
++#define CONFIG_SOC_LANTIQ
++#define CONFIG_SOC_XWAY_DANUBE
++
++/* Cache configuration */
++#define CONFIG_SYS_MIPS_CACHE_MODE CONF_CM_CACHABLE_NONCOHERENT
++#define CONFIG_SYS_DCACHE_SIZE (16 * 1024)
++#define CONFIG_SYS_ICACHE_SIZE (16 * 1024)
++#define CONFIG_SYS_CACHELINE_SIZE 32
++#define CONFIG_SYS_MIPS_CACHE_EXT_INIT
++
++/*
++ * Supported clock modes
++ * PLL0 clock output is 333 MHz
++ * PLL1 clock output is 262.144 MHz
++ */
++#define LTQ_CLK_CPU_333_DDR_167 0 /* Base PLL0, OCP 2 */
++#define LTQ_CLK_CPU_111_DDR_111 1 /* Base PLL0, OCP 1 */
++
++/* CPU speed */
++#define CONFIG_SYS_CLOCK_MODE LTQ_CLK_CPU_333_DDR_167
++#define CONFIG_SYS_MIPS_TIMER_FREQ 166666667
++#define CONFIG_SYS_HZ 1000
++
++/* RAM */
++#define CONFIG_NR_DRAM_BANKS 1
++#define CONFIG_SYS_SDRAM_BASE 0x80000000
++#define CONFIG_SYS_MEMTEST_START 0x81000000
++#define CONFIG_SYS_MEMTEST_END 0x82000000
++#define CONFIG_SYS_LOAD_ADDR 0x81000000
++#define CONFIG_SYS_INIT_SP_OFFSET 0x4000
++
++/* SRAM */
++#define CONFIG_SYS_SRAM_BASE 0xBE180000
++#define CONFIG_SYS_SRAM_SIZE 0x10000
++
++/* ASC/UART driver and console */
++#define CONFIG_LANTIQ_SERIAL
++#define CONFIG_SYS_BAUDRATE_TABLE { 9600, 19200, 38400, 57600, 115200 }
++
++/* GPIO */
++#define CONFIG_LANTIQ_GPIO
++#define CONFIG_LTQ_GPIO_MAX_BANKS 2
++
++/* FLASH driver */
++#if defined(CONFIG_LTQ_SUPPORT_NOR_FLASH)
++#define CONFIG_SYS_MAX_FLASH_BANKS 1
++#define CONFIG_SYS_MAX_FLASH_SECT 256
++#define CONFIG_SYS_FLASH_BASE 0xB0000000
++#define CONFIG_FLASH_16BIT
++#define CONFIG_SYS_FLASH_CFI
++#define CONFIG_FLASH_CFI_DRIVER
++#define CONFIG_SYS_FLASH_CFI_WIDTH FLASH_CFI_16BIT
++#define CONFIG_SYS_FLASH_USE_BUFFER_WRITE
++#define CONFIG_FLASH_SHOW_PROGRESS 50
++#define CONFIG_SYS_FLASH_PROTECTION
++#define CONFIG_CFI_FLASH_USE_WEAK_ADDR_SWAP
++
++#define CONFIG_CMD_FLASH
++#else
++#define CONFIG_SYS_NO_FLASH
++#endif /* CONFIG_NOR_FLASH */
++
++#if defined(CONFIG_LTQ_SUPPORT_SPI_FLASH)
++#define CONFIG_LANTIQ_SPI
++#define CONFIG_SPI_FLASH
++
++#define CONFIG_CMD_SF
++#define CONFIG_CMD_SPI
++#endif
++
++#if defined(CONFIG_LTQ_SUPPORT_ETHERNET)
++#define CONFIG_LANTIQ_DMA
++#define CONFIG_LANTIQ_DANUBE_ETOP
++
++#define CONFIG_PHYLIB
++#define CONFIG_MII
++
++#define CONFIG_CMD_MII
++#define CONFIG_CMD_NET
++#endif
++
++#define CONFIG_SPL_MAX_SIZE (32 * 1024)
++#define CONFIG_SPL_BSS_MAX_SIZE (8 * 1024)
++#define CONFIG_SPL_STACK_MAX_SIZE (8 * 1024)
++#define CONFIG_SPL_MALLOC_MAX_SIZE (32 * 1024)
++/*#define CONFIG_SPL_STACK_BSS_IN_SRAM*/
++
++#if defined(CONFIG_SPL_STACK_BSS_IN_SRAM)
++#define CONFIG_SPL_STACK_BASE (CONFIG_SYS_SRAM_BASE + \
++ CONFIG_SPL_MAX_SIZE + \
++ CONFIG_SPL_STACK_MAX_SIZE - 1)
++#define CONFIG_SPL_BSS_BASE (CONFIG_SPL_STACK_BASE + 1)
++#define CONFIG_SPL_MALLOC_BASE (CONFIG_SYS_SDRAM_BASE + \
++ CONFIG_SYS_INIT_SP_OFFSET)
++#else
++#define CONFIG_SPL_STACK_BASE (CONFIG_SYS_SDRAM_BASE + \
++ CONFIG_SYS_INIT_SP_OFFSET + \
++ CONFIG_SPL_STACK_MAX_SIZE - 1)
++#define CONFIG_SPL_BSS_BASE (CONFIG_SPL_STACK_BASE + 1)
++#define CONFIG_SPL_MALLOC_BASE (CONFIG_SPL_BSS_BASE + \
++ CONFIG_SPL_BSS_MAX_SIZE)
++#endif
++
++#if defined(CONFIG_SYS_BOOT_RAM)
++#define CONFIG_SYS_TEXT_BASE 0xa0100000
++#define CONFIG_SKIP_LOWLEVEL_INIT
++#define CONFIG_SYS_DISABLE_CACHE
++#endif
++
++#if defined(CONFIG_SYS_BOOT_NOR)
++#define CONFIG_SYS_TEXT_BASE 0xB0000000
++#endif
++
++#if defined(CONFIG_SYS_BOOT_NORSPL)
++#define CONFIG_SYS_TEXT_BASE 0x80100000
++#define CONFIG_SPL_TEXT_BASE 0xB0000000
++#endif
++
++#if defined(CONFIG_SYS_BOOT_NOR) || defined(CONFIG_SYS_BOOT_NORSPL)
++#define CONFIG_SYS_XWAY_EBU_BOOTCFG 0x688C688C
++#define CONFIG_XWAY_SWAP_BYTES
++#endif
++
++#define CONFIG_SYS_MONITOR_BASE CONFIG_SYS_TEXT_BASE
++
++#endif /* __DANUBE_CONFIG_H__ */
+--- /dev/null
++++ b/arch/mips/include/asm/arch-danube/gpio.h
+@@ -0,0 +1,13 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#ifndef __DANUBE_GPIO_H__
++#define __DANUBE_GPIO_H__
++
++#include <asm/lantiq/gpio.h>
++
++#endif /* __DANUBE_GPIO_H__ */
+--- /dev/null
++++ b/arch/mips/include/asm/arch-danube/soc.h
+@@ -0,0 +1,40 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2007-2010 Lantiq Deutschland GmbH
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#ifndef __DANUBE_SOC_H__
++#define __DANUBE_SOC_H__
++
++#define LTQ_ASC0_BASE 0x1E100400
++#define LTQ_SPI_BASE 0x1E100800
++#define LTQ_GPIO_BASE 0x1E100B00
++#define LTQ_SSIO_BASE 0x1E100BB0
++#define LTQ_ASC1_BASE 0x1E100C00
++#define LTQ_DMA_BASE 0x1E104100
++
++#define LTQ_EBU_BASE 0x1E105300
++#define LTQ_EBU_REGION0_BASE 0x10000000
++#define LTQ_EBU_REGION0_SIZE (64 * 1024 * 1024)
++#define LTQ_EBU_REGION1_BASE 0x14000000
++#define LTQ_EBU_REGION1_SIZE (32 * 1024 * 1024)
++
++#define LTQ_PPE_BASE 0x1E180000
++#define LTQ_PPE_ETOP_BASE (LTQ_PPE_BASE + 0x11800)
++#define LTQ_PPE_ENET0_BASE (LTQ_PPE_BASE + 0x11840)
++
++#define LTQ_PMU_BASE 0x1F102000
++#define LTQ_CGU_BASE 0x1F103000
++#define LTQ_MPS_BASE 0x1F107000
++#define LTQ_CHIPID_BASE (LTQ_MPS_BASE + 0x340)
++#define LTQ_RCU_BASE 0x1F203000
++
++#define LTQ_MC_GEN_BASE 0x1F800000
++#define LTQ_MC_SDR_BASE 0x1F800200
++#define LTQ_MC_DDR_BASE 0x1F801000
++#define LTQ_MC_DDR_DC_OFFSET(x) (x * 0x10)
++
++#endif /* __DANUBE_SOC_H__ */
+--- /dev/null
++++ b/arch/mips/include/asm/arch-vrx200/config.h
+@@ -0,0 +1,185 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2010 Lantiq Deutschland GmbH
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ *
++ * Common board configuration for Lantiq XWAY VRX200 family
++ *
++ * Use following defines in your board config to enable specific features
++ * and drivers for this SoC:
++ *
++ * CONFIG_LTQ_SUPPORT_UART
++ * - support the VRX200 ASC/UART interface and console
++ *
++ * CONFIG_LTQ_SUPPORT_NOR_FLASH
++ * - support a parallel NOR flash via the CFI interface in flash bank 0
++ *
++ * CONFIG_LTQ_SUPPORT_SPI_FLASH
++ * - support the VRX200 SPI interface and serial flash drivers
++ * - specific SPI flash drivers must be configured separately
++ *
++ * CONFIG_LTQ_SUPPORT_ETHERNET
++ * - support the VRX200 internal switch
++ *
++ * CONFIG_LTQ_SUPPORT_SPL_SPI_FLASH
++ * - build a preloader that runs in the internal SRAM and loads
++ * the U-Boot from SPI flash into RAM
++ */
++
++#ifndef __VRX200_CONFIG_H__
++#define __VRX200_CONFIG_H__
++
++/* CPU and SoC type */
++#define CONFIG_SOC_LANTIQ
++#define CONFIG_SOC_XWAY_VRX200
++
++/* Cache configuration */
++#define CONFIG_SYS_MIPS_CACHE_MODE CONF_CM_CACHABLE_NONCOHERENT
++#define CONFIG_SYS_DCACHE_SIZE (32 * 1024)
++#define CONFIG_SYS_ICACHE_SIZE (32 * 1024)
++#define CONFIG_SYS_CACHELINE_SIZE 32
++#define CONFIG_SYS_MIPS_CACHE_EXT_INIT
++
++/*
++ * Supported clock modes
++ * PLL0 clock output is 1000 MHz
++ * PLL1 clock output is 393.219 MHz
++ */
++#define LTQ_CLK_CPU_600_DDR_300 0 /* Base PLL0, OCP 2 */
++#define LTQ_CLK_CPU_600_DDR_200 1 /* Base PLL0, OCP 3 */
++#define LTQ_CLK_CPU_500_DDR_250 2 /* Base PLL0, OCP 2 */
++#define LTQ_CLK_CPU_500_DDR_200 3 /* Base PLL0, OCP 2.5 */
++#define LTQ_CLK_CPU_333_DDR_167 4 /* Base PLL0, OCP 2 */
++#define LTQ_CLK_CPU_167_DDR_167 5 /* Base PLL0, OCP 1 */
++#define LTQ_CLK_CPU_125_DDR_125 6 /* Base PLL0, OCP 1 */
++#define LTQ_CLK_CPU_393_DDR_197 7 /* Base PLL1, OCP 2 */
++#define LTQ_CLK_CPU_197_DDR_197 8 /* Base PLL1, OCP 1 */
++
++/* CPU speed */
++#define CONFIG_SYS_CLOCK_MODE LTQ_CLK_CPU_500_DDR_250
++#define CONFIG_SYS_MIPS_TIMER_FREQ 250000000
++#define CONFIG_SYS_HZ 1000
++
++/* RAM */
++#define CONFIG_NR_DRAM_BANKS 1
++#define CONFIG_SYS_SDRAM_BASE 0x80000000
++#define CONFIG_SYS_SDRAM_BASE_UC 0xa0000000
++#define CONFIG_SYS_MEMTEST_START 0x81000000
++#define CONFIG_SYS_MEMTEST_END 0x82000000
++#define CONFIG_SYS_LOAD_ADDR 0x81000000
++#define CONFIG_SYS_INIT_SP_OFFSET (32 * 1024)
++
++/* SRAM */
++#define CONFIG_SYS_SRAM_BASE 0xBE220000
++#define CONFIG_SYS_SRAM_SIZE 0x10000
++
++/* ASC/UART driver and console */
++#define CONFIG_LANTIQ_SERIAL
++#define CONFIG_SYS_BAUDRATE_TABLE { 9600, 19200, 38400, 57600, 115200 }
++
++/* GPIO */
++#define CONFIG_LANTIQ_GPIO
++#define CONFIG_LTQ_GPIO_MAX_BANKS 3
++#define CONFIG_LTQ_HAS_GPIO_BANK3
++
++/* FLASH driver */
++#if defined(CONFIG_LTQ_SUPPORT_NOR_FLASH)
++#define CONFIG_SYS_MAX_FLASH_BANKS 1
++#define CONFIG_SYS_MAX_FLASH_SECT 256
++#define CONFIG_SYS_FLASH_BASE 0xB0000000
++#define CONFIG_FLASH_16BIT
++#define CONFIG_SYS_FLASH_CFI
++#define CONFIG_FLASH_CFI_DRIVER
++#define CONFIG_SYS_FLASH_CFI_WIDTH FLASH_CFI_16BIT
++#define CONFIG_SYS_FLASH_USE_BUFFER_WRITE
++#define CONFIG_FLASH_SHOW_PROGRESS 50
++#define CONFIG_SYS_FLASH_PROTECTION
++#define CONFIG_CFI_FLASH_USE_WEAK_ADDR_SWAP
++
++#define CONFIG_CMD_FLASH
++#else
++#define CONFIG_SYS_NO_FLASH
++#endif /* CONFIG_NOR_FLASH */
++
++#if defined(CONFIG_LTQ_SUPPORT_SPI_FLASH)
++#define CONFIG_LANTIQ_SPI
++#define CONFIG_SPI_FLASH
++
++#define CONFIG_CMD_SF
++#define CONFIG_CMD_SPI
++#endif
++
++#if defined(CONFIG_LTQ_SUPPORT_NAND_FLASH)
++#define CONFIG_NAND_LANTIQ
++#define CONFIG_SYS_MAX_NAND_DEVICE 1
++#define CONFIG_SYS_NAND_BASE 0xB4000000
++
++#define CONFIG_CMD_NAND
++#endif
++
++#if defined(CONFIG_LTQ_SUPPORT_ETHERNET)
++#define CONFIG_LANTIQ_DMA
++#define CONFIG_LANTIQ_VRX200_SWITCH
++#define CONFIG_PHY_LANTIQ
++
++#define CONFIG_SYS_RX_ETH_BUFFER 8
++#define CONFIG_PHYLIB
++#define CONFIG_MII
++#define CONFIG_UDP_CHECKSUM
++
++#define CONFIG_CMD_MII
++#define CONFIG_CMD_NET
++#endif
++
++#define CONFIG_SPL_MAX_SIZE (32 * 1024)
++#define CONFIG_SPL_BSS_MAX_SIZE (8 * 1024)
++#define CONFIG_SPL_STACK_MAX_SIZE (8 * 1024)
++#define CONFIG_SPL_MALLOC_MAX_SIZE (32 * 1024)
++#define CONFIG_SPL_STACK_BSS_IN_SRAM
++
++#if defined(CONFIG_SPL_STACK_BSS_IN_SRAM)
++#define CONFIG_SPL_STACK_BASE (CONFIG_SYS_SRAM_BASE + \
++ CONFIG_SPL_MAX_SIZE + \
++ CONFIG_SPL_STACK_MAX_SIZE - 1)
++#define CONFIG_SPL_BSS_BASE (CONFIG_SPL_STACK_BASE + 1)
++#define CONFIG_SPL_MALLOC_BASE (CONFIG_SYS_SDRAM_BASE + \
++ CONFIG_SYS_INIT_SP_OFFSET)
++#else
++#define CONFIG_SPL_STACK_BASE (CONFIG_SYS_SDRAM_BASE + \
++ CONFIG_SYS_INIT_SP_OFFSET + \
++ CONFIG_SPL_STACK_MAX_SIZE - 1)
++#define CONFIG_SPL_BSS_BASE (CONFIG_SPL_STACK_BASE + 1)
++#define CONFIG_SPL_MALLOC_BASE (CONFIG_SPL_BSS_BASE + \
++ CONFIG_SPL_BSS_MAX_SIZE)
++#endif
++
++#if defined(CONFIG_SYS_BOOT_RAM)
++#define CONFIG_SYS_TEXT_BASE 0xA0100000
++#define CONFIG_SKIP_LOWLEVEL_INIT
++#define CONFIG_SYS_DISABLE_CACHE
++#endif
++
++#if defined(CONFIG_SYS_BOOT_NOR)
++#define CONFIG_SYS_TEXT_BASE 0xB0000000
++#endif
++
++#if defined(CONFIG_SYS_BOOT_SFSPL)
++#define CONFIG_SYS_TEXT_BASE 0x80100000
++#define CONFIG_SPL_TEXT_BASE 0xBE220000
++#endif
++
++#if defined(CONFIG_SYS_BOOT_NORSPL)
++#define CONFIG_SYS_TEXT_BASE 0x80100000
++#define CONFIG_SPL_TEXT_BASE 0xB0000000
++#endif
++
++#if defined(CONFIG_SYS_BOOT_NOR) || defined(CONFIG_SYS_BOOT_NORSPL)
++#define CONFIG_SYS_XWAY_EBU_BOOTCFG 0x688C688C
++#define CONFIG_XWAY_SWAP_BYTES
++#endif
++
++#define CONFIG_SYS_MONITOR_BASE CONFIG_SYS_TEXT_BASE
++
++#endif /* __VRX200_CONFIG_H__ */
+--- /dev/null
++++ b/arch/mips/include/asm/arch-vrx200/gphy.h
+@@ -0,0 +1,66 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#ifndef __VRX200_GPHY_H__
++#define __VRX200_GPHY_H__
++
++enum ltq_gphy_clk {
++ /* XTAL 36 MHz input */
++ LTQ_GPHY_CLK_36MHZ_XTAL = 1,
++ /* 25 MHz from PLL0 with divider */
++ LTQ_GPHY_CLK_25MHZ_PLL0 = 2,
++ /* derived from PLL2 output (XTAL is 36 MHz) */
++ LTQ_GPHY_CLK_24MHZ_PLL2 = 3,
++ /* 25 MHz Clock from Pin GPIO3 */
++ LTQ_GPHY_CLK_25MHZ_GPIO3 = 4,
++};
++
++/*
++ * Load PHY11G firmware for VRX200 v1.1 to given RAM address
++ *
++ * Address must be 16k aligned!
++ */
++extern void ltq_gphy_phy11g_a1x_load(ulong addr);
++
++/*
++ * Load PHY11G firmware for VRX200 v1.2 to given RAM address
++ *
++ * Address must be 16k aligned!
++ */
++extern void ltq_gphy_phy11g_a2x_load(ulong addr);
++
++/*
++ * Load PHY22F firmware for VRX200 v1.1 to given RAM address
++ *
++ * Address must be 16k aligned!
++ */
++extern void ltq_gphy_phy22f_a1x_load(ulong addr);
++
++/*
++ * Load PHY22F firmware for VRX200 v1.2 to given RAM address
++ *
++ * Address must be 16k aligned!
++ */
++extern void ltq_gphy_phy22f_a2x_load(ulong addr);
++
++/*
++ * Set clock source of internal GPHYs
++ *
++ * According registers resides in CGU address space. Thus this function
++ * is implemented by the CGU driver.
++ */
++extern void ltq_cgu_gphy_clk_src(enum ltq_gphy_clk clk);
++
++/*
++ * Boot internal GPHY with id from given RAM address
++ *
++ * According registers resides in RCU address space. Thus this function
++ * is implemented by the RCU driver.
++ */
++extern void ltq_rcu_gphy_boot(unsigned int id, ulong addr);
++
++#endif /* __VRX200_GPHY_H__ */
+--- /dev/null
++++ b/arch/mips/include/asm/arch-vrx200/gpio.h
+@@ -0,0 +1,13 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#ifndef __VRX200_GPIO_H__
++#define __VRX200_GPIO_H__
++
++#include <asm/lantiq/gpio.h>
++
++#endif /* __VRX200_GPIO_H__ */
+--- /dev/null
++++ b/arch/mips/include/asm/arch-vrx200/nand.h
+@@ -0,0 +1,14 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2012 Daniel Schwierzeck, daniel.schwierzeck@gmail.com
++ */
++
++#ifndef __VRX200_NAND_H__
++#define __VRX200_NAND_H__
++
++struct nand_chip;
++int ltq_nand_init(struct nand_chip *nand);
++
++#endif /* __VRX200_NAND_H__ */
+--- /dev/null
++++ b/arch/mips/include/asm/arch-vrx200/soc.h
+@@ -0,0 +1,46 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2010 Lantiq Deutschland GmbH
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#ifndef __VRX200_SOC_H__
++#define __VRX200_SOC_H__
++
++#define LTQ_ASC0_BASE 0x1E100400
++#define LTQ_SPI_BASE 0x1E100800
++#define LTQ_GPIO_BASE 0x1E100B00
++#define LTQ_SSIO_BASE 0x1E100BB0
++#define LTQ_ASC1_BASE 0x1E100C00
++#define LTQ_DMA_BASE 0x1E104100
++
++#define LTQ_EBU_BASE 0x1E105300
++#define LTQ_EBU_REGION0_BASE 0x10000000
++#define LTQ_EBU_REGION1_BASE 0x14000000
++#define LTQ_EBU_NAND_BASE (LTQ_EBU_BASE + 0xB0)
++
++#define LTQ_SWITCH_BASE 0x1E108000
++#define LTQ_SWITCH_CORE_BASE LTQ_SWITCH_BASE
++#define LTQ_SWITCH_TOP_PDI_BASE LTQ_SWITCH_CORE_BASE
++#define LTQ_SWITCH_BM_PDI_BASE (LTQ_SWITCH_CORE_BASE + 4 * 0x40)
++#define LTQ_SWITCH_MAC_PDI_0_BASE (LTQ_SWITCH_CORE_BASE + 4 * 0x900)
++#define LTQ_SWITCH_MAC_PDI_X_BASE(x) (LTQ_SWITCH_MAC_PDI_0_BASE + x * 0x30)
++#define LTQ_SWITCH_TOPLEVEL_BASE (LTQ_SWITCH_BASE + 4 * 0xC40)
++#define LTQ_SWITCH_MDIO_PDI_BASE (LTQ_SWITCH_TOPLEVEL_BASE)
++#define LTQ_SWITCH_MII_PDI_BASE (LTQ_SWITCH_TOPLEVEL_BASE + 4 * 0x36)
++#define LTQ_SWITCH_PMAC_PDI_BASE (LTQ_SWITCH_TOPLEVEL_BASE + 4 * 0x82)
++
++#define LTQ_PMU_BASE 0x1F102000
++#define LTQ_CGU_BASE 0x1F103000
++#define LTQ_DCDC_BASE 0x1F106A00
++#define LTQ_MPS_BASE 0x1F107000
++#define LTQ_CHIPID_BASE (LTQ_MPS_BASE + 0x340)
++#define LTQ_RCU_BASE 0x1F203000
++
++#define LTQ_MC_GLOBAL_BASE 0x1F400000
++#define LTQ_MC_DDR_BASE 0x1F401000
++#define LTQ_MC_DDR_CCR_OFFSET(x) (x * 0x10)
++
++#endif /* __VRX200_SOC_H__ */
+--- /dev/null
++++ b/arch/mips/include/asm/arch-vrx200/switch.h
+@@ -0,0 +1,514 @@
++/*
++ * 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 of the License, 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; if not, write to the Free Software
++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
++ *
++ * Copyright (C) 2012 Daniel Schwierzeck <daniel.schwierzeck@googlemail.com>
++ */
++
++#ifndef __VR9_SWITCH_H__
++#define __VR9_SWITCH_H__
++
++/* Switch core registers */
++struct vr9_switch_core_regs {
++ __be32 swres;
++ /* TODO: implement registers */
++ __be32 rsvd0[0x3f];
++};
++
++/* Switch buffer management registers */
++struct vr9_switch_bm_regs {
++ struct bm_core {
++ __be32 ram_val3; /* RAM value 3 */
++ __be32 ram_val2; /* RAM value 2 */
++ __be32 ram_val1; /* RAM value 1 */
++ __be32 ram_val0; /* RAM value 0 */
++ __be32 ram_addr; /* RAM address */
++ __be32 ram_ctrl; /* RAM access control */
++ __be32 fsqm_gctrl; /* Free segment queue global control */
++ __be32 cons_sel; /* Number of consumed segments */
++ __be32 cons_pkt; /* Number of consumed packet pointers */
++ __be32 gctrl; /* Global control */
++ __be32 queue_gctrl; /* Queue manager global control */
++ /* TODO: implement registers */
++ __be32 rsvd0[0x35];
++ } core;
++
++ struct bm_port {
++ __be32 pcfg; /* Port config */
++ __be32 rmon_ctrl; /* RMON control */
++ } port[13];
++
++ __be32 rsvd0[0x66];
++
++ struct bm_queue {
++ __be32 rsvd0;
++ __be32 pqm_rs; /* Packet queue manager rate shape assignment */
++ } queue[32];
++
++ struct bm_shaper {
++ __be32 ctrl; /* Rate shaper control */
++ __be32 cbs; /* Rate shaper committed burst size */
++ __be32 ibs; /* Rate shaper instantaneous burst size */
++ __be32 cir_ext; /* Rate shaper rate exponent */
++ __be32 cir_mant; /* Rate shaper rate mantissa */
++ } shaper[16];
++
++ __be32 rsvd1[0x2a8];
++};
++
++/* Switch parser and classification engine registers */
++struct vr9_switch_pce_regs {
++ struct pce_core {
++ __be32 tbl_key[16]; /* Table key data */
++ __be32 tbl_mask; /* Table mask */
++ __be32 tbl_val[5]; /* Table value */
++ __be32 tbl_addr; /* Table entry address */
++ __be32 tbl_ctrl; /* Table access control */
++ __be32 tbl_stat; /* Table general status */
++ __be32 age_0; /* Aging counter config 0 */
++ __be32 age_1; /* Aging counter config 1 */
++ __be32 pmap_1; /* Port map (monitoring) */
++ __be32 pmap_2; /* Port map (multicast) */
++ __be32 pmap_3; /* Port map (unknown unicast) */
++ __be32 gctrl_0; /* Global control 0 */
++ __be32 gctrl_1; /* Global control 1 */
++ __be32 tcm_gctrl; /* Three-color marker global control */
++ __be32 igmp_ctrl; /* IGMP control */
++ __be32 igmp_drpm; /* IGMP default router port map */
++ __be32 igmp_age_0; /* IGMP aging 0 */
++ __be32 igmp_age_1; /* IGMP aging 1 */
++ __be32 igmp_stat; /* IGMP status */
++ __be32 wol_gctrl; /* Wake-on-LAN control */
++ __be32 wol_da_0; /* Wake-on-LAN destination address 0 */
++ __be32 wol_da_1; /* Wake-on-LAN destination address 1 */
++ __be32 wol_da_2; /* Wake-on-LAN destination address 2 */
++ __be32 wol_pw_0; /* Wake-on-LAN password 0 */
++ __be32 wol_pw_1; /* Wake-on-LAN password 1 */
++ __be32 wol_pw_2; /* Wake-on-LAN password 2 */
++ __be32 ier_0; /* PCE global interrupt enable 0 */
++ __be32 ier_1; /* PCE global interrupt enable 1 */
++ __be32 isr_0; /* PCE global interrupt status 0 */
++ __be32 isr_1; /* PCE global interrupt status 1 */
++ __be32 parser_stat; /* Parser status */
++ __be32 rsvd0[0x6];
++ } core;
++
++ __be32 rsvd0[0x10];
++
++ struct pce_port {
++ __be32 pctrl_0; /* Port control 0 */
++ __be32 pctrl_1; /* Port control 1 */
++ __be32 pctrl_2; /* Port control 2 */
++ __be32 pctrl_3; /* Port control 3 */
++ __be32 wol_ctrl; /* Wake-on-LAN control */
++ __be32 vlan_ctrl; /* VLAN control */
++ __be32 def_pvid; /* Default port VID */
++ __be32 pstat; /* Port status */
++ __be32 pier; /* Interrupt enable */
++ __be32 pisr; /* Interrupt status */
++ } port[13];
++
++ __be32 rsvd1[0x7e];
++
++ struct pce_meter {
++ /* TODO: implement registers */
++ __be32 rsvd0[0x7];
++ } meter[8];
++
++ __be32 rsvd2[0x308];
++};
++
++static inline unsigned int to_pce_tbl_key_id(unsigned int id)
++{
++ BUG_ON(id > 15);
++
++ return 15 - id;
++}
++
++static inline unsigned int to_pce_tbl_value_id(unsigned int id)
++{
++ BUG_ON(id > 4);
++
++ return 4 - id;
++}
++
++/* Switch ethernet MAC registers */
++struct vr9_switch_mac_regs {
++ struct mac_core {
++ __be32 test; /* MAC test */
++ __be32 pfad_cfg; /* Pause frame source address config */
++ __be32 pfsa_0; /* Pause frame source address 0 */
++ __be32 pfsa_1; /* Pause frame source address 1 */
++ __be32 pfsa_2; /* Pause frame source address 2 */
++ __be32 flen; /* Frame length */
++ __be32 vlan_etype_0; /* VLAN ethertype 0 */
++ __be32 vlan_etype_1; /* VLAN ethertype 1 */
++ __be32 ier; /* Interrupt enable */
++ __be32 isr; /* Interrupt status */
++ __be32 rsvd0[0x36];
++ } core;
++
++ struct mac_port {
++ __be32 pstat; /* Port status */
++ __be32 pisr; /* Interrupt status */
++ __be32 pier; /* Interrupt enable */
++ __be32 ctrl_0; /* Control 0 */
++ __be32 ctrl_1; /* Control 1 */
++ __be32 ctrl_2; /* Control 2 */
++ __be32 ctrl_3; /* Control 3 */
++ __be32 ctrl_4; /* Control 4 */
++ __be32 ctrl_5; /* Control 5 */
++ __be32 rsvd0[0x2];
++ __be32 testen; /* Test enable */
++ } port[13];
++
++ __be32 rsvd0[0xa4];
++};
++
++/* Switch Fetch DMA registers */
++struct vr9_switch_fdma_regs {
++ struct fdma_core {
++ __be32 ctrl; /* FDMA control */
++ __be32 stetype; /* Special tag ethertype control */
++ __be32 vtetype; /* VLAN tag ethertype control */
++ __be32 stat; /* FDMA status */
++ __be32 ier; /* FDMA interrupt enable */
++ __be32 isr; /* FDMA interrupt status */
++ } core;
++
++ __be32 rsvd0[0x3a];
++
++ struct fdma_port {
++ __be32 pctrl; /* Port control */
++ __be32 prio; /* Port priority */
++ __be32 pstat_0; /* Port status 0 */
++ __be32 pstat_1; /* Port status 1 */
++ __be32 tstamp_0; /* Egress time stamp 0 */
++ __be32 tstamp_1; /* Egress time stamp 1 */
++ } port[13];
++
++ __be32 rsvd1[0x72];
++};
++
++/* Switch Store DMA registers */
++struct vr9_switch_sdma_regs {
++ struct sdma_core {
++ __be32 ctrl; /* SDMA Control */
++ __be32 fcthr_1; /* Flow control threshold 1 */
++ __be32 rsvd0;
++ __be32 fcthr_3; /* Flow control threshold 3 */
++ __be32 fcthr_4; /* Flow control threshold 4 */
++ __be32 fcthr_5; /* Flow control threshold 5 */
++ __be32 fcthr_6; /* Flow control threshold 6 */
++ __be32 fcthr_7; /* Flow control threshold 7 */
++ __be32 stat_0; /* SDMA status 0 */
++ __be32 stat_1; /* SDMA status 1 */
++ __be32 stat_2; /* SDMA status 2 */
++ __be32 ier; /* SDMA interrupt enable */
++ __be32 isr; /* SDMA interrupt status */
++ } core;
++
++ __be32 rsvd0[0x73];
++
++ struct sdma_port {
++ __be32 pctrl; /* Port control */
++ __be32 prio; /* Port priority */
++ __be32 pstat_0; /* Port status 0 */
++ __be32 pstat_1; /* Port status 1 */
++ __be32 tstamp_0; /* Ingress time stamp 0 */
++ __be32 tstamp_1; /* Ingress time stamp 1 */
++ } port[13];
++
++ __be32 rsvd1[0x32];
++};
++
++/* Switch MDIO control and status registers */
++struct vr9_switch_mdio_regs {
++ __be32 glob_ctrl; /* Global control 0 */
++ __be32 rsvd0[7];
++ __be32 mdio_ctrl; /* MDIO control */
++ __be32 mdio_read; /* MDIO read data */
++ __be32 mdio_write; /* MDIO write data */
++ __be32 mdc_cfg_0; /* MDC clock configuration 0 */
++ __be32 mdc_cfg_1; /* MDC clock configuration 1 */
++ __be32 rsvd1[0x3];
++ __be32 phy_addr[6]; /* PHY address port 5..0 */
++ __be32 mdio_stat[6]; /* MDIO PHY polling status port 0..5 */
++ __be32 aneg_eee[6]; /* EEE auto-neg overrides port 0..5 */
++ __be32 rsvd2[0x14];
++};
++
++static inline unsigned int to_mdio_phyaddr_id(unsigned int id)
++{
++ BUG_ON(id > 5);
++
++ return 5 - id;
++}
++
++/* Switch xMII control registers */
++struct vr9_switch_mii_regs {
++ __be32 mii_cfg0; /* xMII port 0 configuration */
++ __be32 pcdu0; /* Port 0 clock delay configuration */
++ __be32 mii_cfg1; /* xMII port 1 configuration */
++ __be32 pcdu1; /* Port 1 clock delay configuration */
++ __be32 rsvd0[0x6];
++ __be32 mii_cfg5; /* xMII port 5 configuration */
++ __be32 pcdu5; /* Port 5 clock delay configuration */
++ __be32 rsvd1[0x14];
++ __be32 rxb_ctl_0; /* Port 0 receive buffer control */
++ __be32 rxb_ctl_1; /* Port 1 receive buffer control */
++ __be32 rxb_ctl_5; /* Port 5 receive buffer control */
++ __be32 rsvd2[0x28];
++ __be32 dbg_ctl; /* Debug control */
++};
++
++/* Switch Pseudo-MAC registers */
++struct vr9_switch_pmac_regs {
++ __be32 hd_ctl; /* PMAC header control */
++ __be32 tl; /* PMAC type/length */
++ __be32 sa1; /* PMAC source address 1 */
++ __be32 sa2; /* PMAC source address 2 */
++ __be32 sa3; /* PMAC source address 3 */
++ __be32 da1; /* PMAC destination address 1 */
++ __be32 da2; /* PMAC destination address 2 */
++ __be32 da3; /* PMAC destination address 3 */
++ __be32 vlan; /* PMAC VLAN */
++ __be32 rx_ipg; /* PMAC interpacket gap in RX direction */
++ __be32 st_etype; /* PMAC special tag ethertype */
++ __be32 ewan; /* PMAC ethernet WAN group */
++ __be32 ctl; /* PMAC control */
++ __be32 rsvd0[0x2];
++};
++
++struct vr9_switch_regs {
++ struct vr9_switch_core_regs core;
++ struct vr9_switch_bm_regs bm;
++ struct vr9_switch_pce_regs pce;
++ struct vr9_switch_mac_regs mac;
++ struct vr9_switch_fdma_regs fdma;
++ struct vr9_switch_sdma_regs sdma;
++ struct vr9_switch_mdio_regs mdio;
++ struct vr9_switch_mii_regs mii;
++ struct vr9_switch_pmac_regs pmac;
++};
++
++static inline void *to_pce_tbl_key(struct vr9_switch_regs *regs,
++ unsigned int id)
++{
++ return &regs->pce.core.tbl_key[to_pce_tbl_key_id(id)];
++}
++
++static inline void *to_pce_tbl_value(struct vr9_switch_regs *regs,
++ unsigned int id)
++{
++ return &regs->pce.core.tbl_val[to_pce_tbl_value_id(id)];
++}
++
++static inline void *to_mac_ctrl(struct vr9_switch_regs *regs,
++ unsigned int id, unsigned int ctrl)
++{
++ struct mac_port *mac = &regs->mac.port[id];
++
++ switch (ctrl) {
++ case 0:
++ return &mac->ctrl_0;
++ case 1:
++ return &mac->ctrl_1;
++ case 2:
++ return &mac->ctrl_2;
++ case 3:
++ return &mac->ctrl_3;
++ case 4:
++ return &mac->ctrl_4;
++ case 5:
++ return &mac->ctrl_5;
++ default:
++ return NULL;
++ }
++}
++
++static inline void *to_mdio_phyaddr(struct vr9_switch_regs *regs,
++ unsigned int id)
++{
++ return &regs->mdio.phy_addr[to_mdio_phyaddr_id(id)];
++}
++
++static inline void *to_mii_miicfg(struct vr9_switch_regs *regs,
++ unsigned int id)
++{
++ switch (id) {
++ case 0:
++ return &regs->mii.mii_cfg0;
++ case 1:
++ return &regs->mii.mii_cfg1;
++ case 5:
++ return &regs->mii.mii_cfg5;
++ default:
++ return NULL;
++ }
++}
++
++static inline void *to_mii_pcdu(struct vr9_switch_regs *regs,
++ unsigned int id)
++{
++ switch (id) {
++ case 0:
++ return &regs->mii.pcdu0;
++ case 1:
++ return &regs->mii.pcdu1;
++ case 5:
++ return &regs->mii.pcdu5;
++ default:
++ return NULL;
++ }
++}
++
++#define VR9_SWITCH_REG_OFFSET(reg) (4 * (reg))
++
++#define BUILD_CHECK_VR9_REG(name, offset) \
++ BUILD_BUG_ON(offsetof(struct vr9_switch_regs, name) != (4 * offset))
++
++static inline void build_check_vr9_registers(void)
++{
++ BUILD_CHECK_VR9_REG(core, 0x0);
++ BUILD_CHECK_VR9_REG(bm.core, 0x40);
++ BUILD_CHECK_VR9_REG(bm.core.queue_gctrl, 0x4a);
++ BUILD_CHECK_VR9_REG(bm.port[0], 0x80);
++ BUILD_CHECK_VR9_REG(bm.queue, 0x100);
++ BUILD_CHECK_VR9_REG(bm.shaper, 0x140);
++ BUILD_CHECK_VR9_REG(pce.core, 0x438);
++ BUILD_CHECK_VR9_REG(pce.core.tbl_ctrl, 0x44f);
++ BUILD_CHECK_VR9_REG(pce.core.parser_stat, 0x469);
++ BUILD_CHECK_VR9_REG(pce.port[0], 0x480);
++ BUILD_CHECK_VR9_REG(pce.meter[0], 0x580);
++ BUILD_CHECK_VR9_REG(mac.core, 0x8c0);
++ BUILD_CHECK_VR9_REG(mac.port[0].pstat, 0x900);
++ BUILD_CHECK_VR9_REG(mac.port[0].ctrl_0, 0x903);
++ BUILD_CHECK_VR9_REG(mac.port[1].pstat, 0x90c);
++ BUILD_CHECK_VR9_REG(mac.port[1].ctrl_0, 0x90f);
++ BUILD_CHECK_VR9_REG(mac.port[2].pstat, 0x918);
++ BUILD_CHECK_VR9_REG(mac.port[2].ctrl_0, 0x91b);
++ BUILD_CHECK_VR9_REG(fdma.core, 0xa40);
++ BUILD_CHECK_VR9_REG(fdma.port[0], 0xa80);
++ BUILD_CHECK_VR9_REG(sdma.core, 0xb40);
++ BUILD_CHECK_VR9_REG(sdma.port[0], 0xbc0);
++ BUILD_CHECK_VR9_REG(mdio, 0xc40);
++ BUILD_CHECK_VR9_REG(mii, (0xc40 + 0x36));
++ BUILD_CHECK_VR9_REG(pmac, (0xc40 + 0x82));
++}
++
++#define BM_GCTRL_F_SRES 1
++
++#define MAC_CTRL0_BM (1 << 12)
++#define MAC_CTRL0_APADEN (1 << 11)
++#define MAC_CTRL0_VPAD2EN (1 << 10)
++#define MAC_CTRL0_VPADEN (1 << 9)
++#define MAC_CTRL0_PADEN (1 << 8)
++#define MAC_CTRL0_FCS (1 << 7)
++#define MAC_CTRL0_FCON_SHIFT 4
++#define MAC_CTRL0_FCON_AUTO (0x0 << MAC_CTRL0_FCON_SHIFT)
++#define MAC_CTRL0_FCON_RX (0x1 << MAC_CTRL0_FCON_SHIFT)
++#define MAC_CTRL0_FCON_TX (0x2 << MAC_CTRL0_FCON_SHIFT)
++#define MAC_CTRL0_FCON_RXTX (0x3 << MAC_CTRL0_FCON_SHIFT)
++#define MAC_CTRL0_FCON_NONE (0x4 << MAC_CTRL0_FCON_SHIFT)
++#define MAC_CTRL0_FDUP_SHIFT 2
++#define MAC_CTRL0_FDUP_AUTO (0x0 << MAC_CTRL0_FDUP_SHIFT)
++#define MAC_CTRL0_FDUP_EN (0x1 << MAC_CTRL0_FDUP_SHIFT)
++#define MAC_CTRL0_FDUP_DIS (0x3 << MAC_CTRL0_FDUP_SHIFT)
++#define MAC_CTRL0_GMII_AUTO 0x0
++#define MAC_CTRL0_GMII_MII 0x1
++#define MAC_CTRL0_GMII_GMII 0x2
++#define MAC_CTRL0_GMII_GMII_2G 0x3
++
++#define MAC_CTRL1_DEFERMODE (1 << 15)
++#define MAC_CTRL1_SHORTPRE (1 << 8)
++
++#define MAC_CTRL2_MLEN (1 << 3)
++#define MAC_CTRL2_LCHKL (1 << 2)
++#define MAC_CTRL2_LCHKS_DIS 0x0
++#define MAC_CTRL2_LCHKS_UNTAG 0x1
++#define MAC_CTRL2_LCHKS_TAG 0x2
++
++#define PHY_ADDR_LNKST_SHIFT 13
++#define PHY_ADDR_LNKST_AUTO (0x0 << PHY_ADDR_LNKST_SHIFT)
++#define PHY_ADDR_LNKST_UP (0x1 << PHY_ADDR_LNKST_SHIFT)
++#define PHY_ADDR_LNKST_DOWN (0x2 << PHY_ADDR_LNKST_SHIFT)
++#define PHY_ADDR_SPEED_SHIFT 11
++#define PHY_ADDR_SPEED_M10 (0x0 << PHY_ADDR_SPEED_SHIFT)
++#define PHY_ADDR_SPEED_M100 (0x1 << PHY_ADDR_SPEED_SHIFT)
++#define PHY_ADDR_SPEED_G1 (0x2 << PHY_ADDR_SPEED_SHIFT)
++#define PHY_ADDR_SPEED_AUTO (0x3 << PHY_ADDR_SPEED_SHIFT)
++#define PHY_ADDR_FDUP_SHIFT 9
++#define PHY_ADDR_FDUP_AUTO (0x0 << PHY_ADDR_FDUP_SHIFT)
++#define PHY_ADDR_FDUP_EN (0x1 << PHY_ADDR_FDUP_SHIFT)
++#define PHY_ADDR_FDUP_DIS (0x3 << PHY_ADDR_FDUP_SHIFT)
++#define PHY_ADDR_FCONTX_SHIFT 7
++#define PHY_ADDR_FCONTX_AUTO (0x0 << PHY_ADDR_FCONTX_SHIFT)
++#define PHY_ADDR_FCONTX_EN (0x1 << PHY_ADDR_FCONTX_SHIFT)
++#define PHY_ADDR_FCONTX_DIS (0x3 << PHY_ADDR_FCONTX_SHIFT)
++#define PHY_ADDR_FCONRX_SHIFT 5
++#define PHY_ADDR_FCONRX_AUTO (0x0 << PHY_ADDR_FCONRX_SHIFT)
++#define PHY_ADDR_FCONRX_EN (0x1 << PHY_ADDR_FCONRX_SHIFT)
++#define PHY_ADDR_FCONRX_DIS (0x3 << PHY_ADDR_FCONRX_SHIFT)
++
++#define MII_CFG_RES (1 << 15)
++#define MII_CFG_EN (1 << 14)
++#define MII_CFG_LDCLKDIS (1 << 12)
++#define MII_CFG_MIIRATE_SHIFT 4
++#define MII_CFG_MIIRATE_MASK (0x7 << MII_CFG_MIIRATE_SHIFT)
++#define MII_CFG_MIIRATE_M2P5 (0x0 << MII_CFG_MIIRATE_SHIFT)
++#define MII_CFG_MIIRATE_M25 (0x1 << MII_CFG_MIIRATE_SHIFT)
++#define MII_CFG_MIIRATE_M125 (0x2 << MII_CFG_MIIRATE_SHIFT)
++#define MII_CFG_MIIRATE_M50 (0x3 << MII_CFG_MIIRATE_SHIFT)
++#define MII_CFG_MIIRATE_AUTO (0x4 << MII_CFG_MIIRATE_SHIFT)
++#define MII_CFG_MIIMODE_MASK 0xf
++#define MII_CFG_MIIMODE_MIIP 0x0
++#define MII_CFG_MIIMODE_MIIM 0x1
++#define MII_CFG_MIIMODE_RMIIP 0x2
++#define MII_CFG_MIIMODE_RMIIM 0x3
++#define MII_CFG_MIIMODE_RGMII 0x4
++
++#define PCDU_RXDLY_SHIFT 7
++#define PCDU_RXDLY_MASK (0x7 << PCDU_RXDLY_SHIFT)
++#define PCDU_TXDLY_MASK 0x7
++
++#define PMAC_HD_CTL_FC (1 << 10)
++#define PMAC_HD_CTL_CCRC (1 << 9)
++#define PMAC_HD_CTL_RST (1 << 8)
++#define PMAC_HD_CTL_AST (1 << 7)
++#define PMAC_HD_CTL_RXSH (1 << 6)
++#define PMAC_HD_CTL_RC (1 << 4)
++#define PMAC_HD_CTL_AS (1 << 3)
++#define PMAC_HD_CTL_AC (1 << 2)
++
++#define PCE_PCTRL_0_IGSTEN (1 << 11)
++
++#define FDMA_PCTRL_STEN (1 << 1)
++#define FDMA_PCTRL_EN (1 << 0)
++
++#define SDMA_PCTRL_EN (1 << 0)
++
++#define MDIO_GLOB_CTRL_SE (1 << 15)
++
++#define MDIO_MDC_CFG1_RES (1 << 15)
++#define MDIO_MDC_CFG1_MCEN (1 << 8)
++
++#define MDIO_CTRL_MBUSY (1 << 12)
++#define MDIO_CTRL_OP_READ (1 << 11)
++#define MDIO_CTRL_OP_WRITE (1 << 10)
++#define MDIO_CTRL_PHYAD_SHIFT 5
++#define MDIO_CTRL_PHYAD_MASK (0x1f << MDIO_CTRL_PHYAD_SHIFT)
++#define MDIO_CTRL_REGAD_MASK 0x1f
++
++#endif
+--- a/arch/mips/include/asm/asm.h
++++ b/arch/mips/include/asm/asm.h
+@@ -53,6 +53,7 @@
+ .align 2; \
+ .type symbol, @function; \
+ .ent symbol, 0; \
++ .section .text.symbol,"x"; \
+ symbol: .frame sp, 0, ra
+
+ /*
+@@ -62,7 +63,8 @@ symbol: .frame sp, 0, ra
+ .globl symbol; \
+ .align 2; \
+ .type symbol, @function; \
+- .ent symbol, 0; \
++ .ent symbol, 0; \
++ .section .text.symbol,"x"; \
+ symbol: .frame sp, framesize, rpc
+
+ /*
+--- /dev/null
++++ b/arch/mips/include/asm/gpio.h
+@@ -0,0 +1,7 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ */
++
++#include <asm/arch/gpio.h>
++#include <asm-generic/gpio.h>
+--- /dev/null
++++ b/arch/mips/include/asm/lantiq/chipid.h
+@@ -0,0 +1,74 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#ifndef __LANTIQ_CHIPID_H__
++#define __LANTIQ_CHIPID_H__
++
++enum ltq_chip_partnum {
++ LTQ_SOC_UNKNOWN = 0,
++ LTQ_SOC_VRX288_2 = 0x000B, /* VRX288 v1.2 */
++ LTQ_SOC_VRX268_2 = 0x000C, /* VRX268 v1.2 */
++ LTQ_SOC_GRX288_2 = 0x000D, /* GRX288 v1.2 */
++ LTQ_SOC_DANUBE = 0x0129,
++ LTQ_SOC_DANUBE_S = 0x012B,
++ LTQ_SOC_TWINPASS = 0x012D,
++ LTQ_SOC_VRX288 = 0x01C0, /* VRX288 v1.1 */
++ LTQ_SOC_VRX268 = 0x01C2, /* VRX268 v1.1 */
++ LTQ_SOC_GRX288 = 0x01C9, /* GRX288 v1.1 */
++};
++
++extern unsigned int ltq_chip_version_get(void);
++extern unsigned int ltq_chip_partnum_get(void);
++extern const char *ltq_chip_partnum_str(void);
++
++extern void ltq_chip_print_info(void);
++
++#ifdef CONFIG_SOC_XWAY_DANUBE
++static inline int ltq_soc_is_danube(void)
++{
++ return 1;
++}
++#else
++static inline int ltq_soc_is_danube(void)
++{
++ return 0;
++}
++#endif
++
++#ifdef CONFIG_SOC_XWAY_VRX200
++static inline int ltq_soc_is_vrx200(void)
++{
++ return 1;
++}
++
++static inline int ltq_soc_is_vrx200_v1(void)
++{
++ return ltq_chip_version_get() == 1;
++}
++
++static inline int ltq_soc_is_vrx200_v2(void)
++{
++ return ltq_chip_version_get() == 2;
++}
++#else
++static inline int ltq_soc_is_vrx200(void)
++{
++ return 0;
++}
++
++static inline int ltq_soc_is_vrx200_v1(void)
++{
++ return 0;
++}
++
++static inline int ltq_soc_is_vrx200_v2(void)
++{
++ return 0;
++}
++#endif
++
++#endif /* __LANTIQ_CHIPID_H__ */
+--- /dev/null
++++ b/arch/mips/include/asm/lantiq/clk.h
+@@ -0,0 +1,33 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2007-2010 Lantiq Deutschland GmbH
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ *
++ * Based on Lantiq port in Linux kernel
++ */
++
++#ifndef __LANTIQ_CLK_H__
++#define __LANTIQ_CLK_H__
++
++/* Symbolic clock speeds */
++enum ltq_clk {
++ CLOCK_83_MHZ = 83333333,
++ CLOCK_111_MHZ = 111111111,
++ CLOCK_125_MHZ = 125000000,
++ CLOCK_133_MHZ = 133333333,
++ CLOCK_166_MHZ = 166666667,
++ CLOCK_197_MHZ = 197000000,
++ CLOCK_333_MHZ = 333333333,
++ CLOCK_393_MHZ = 393219000,
++ CLOCK_500_MHZ = 500000000,
++ CLOCK_600_MHZ = 600000000,
++ CLOCK_1000_MHZ = 1000000000,
++};
++
++extern unsigned long ltq_get_cpu_clock(void);
++extern unsigned long ltq_get_bus_clock(void);
++extern unsigned long ltq_get_io_region_clock(void);
++
++#endif /* __LANTIQ_CLK_H__ */
+--- /dev/null
++++ b/arch/mips/include/asm/lantiq/config.h
+@@ -0,0 +1,166 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2007-2010 Lantiq Deutschland GmbH
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#ifndef __LANTIQ_CONFIG_H__
++#define __LANTIQ_CONFIG_H__
++
++/* Memory usage */
++#define CONFIG_SYS_MAXARGS 24
++#define CONFIG_SYS_MALLOC_LEN 1024*1024
++#define CONFIG_SYS_BOOTPARAMS_LEN 128*1024
++
++/* Command line */
++#define CONFIG_SYS_PROMPT CONFIG_MACH_TYPE " # "
++#define CONFIG_SYS_CBSIZE 512
++#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE + \
++ sizeof(CONFIG_SYS_PROMPT)+16)
++
++#define CONFIG_SYS_HUSH_PARSER
++#define CONFIG_SYS_PROMPT_HUSH_PS2 "> "
++
++/*
++ * Enable advanced console features on demand to reduce
++ * flash and RAM footprint
++ */
++#if defined(CONFIG_LTQ_ADVANCED_CONSOLE)
++#define CONFIG_SYS_LONGHELP
++#define CONFIG_AUTO_COMPLETE
++#define CONFIG_CMDLINE_EDITING
++#endif
++
++/* SPI flash SPL */
++#if defined(CONFIG_LTQ_SUPPORT_SPL_SPI_FLASH) && defined(CONFIG_SYS_BOOT_SFSPL)
++#define CONFIG_SPL
++#define CONFIG_SPL_SPI_SUPPORT
++#define CONFIG_SPL_SPI_FLASH_SUPPORT
++#endif
++
++#if defined(CONFIG_LTQ_SUPPORT_SPL_NOR_FLASH) && defined(CONFIG_SYS_BOOT_NORSPL)
++#define CONFIG_SPL
++#endif
++
++/* Common SPL */
++#if defined(CONFIG_SPL)
++#define CONFIG_SKIP_LOWLEVEL_INIT
++#define CONFIG_SPL_LIBGENERIC_SUPPORT
++#define CONFIG_SPL_GPIO_SUPPORT
++#define CONFIG_SPL_START_S_PATH \
++ "arch/mips/cpu/mips32/lantiq-common"
++#define CONFIG_SPL_LDSCRIPT \
++ "arch/mips/cpu/mips32/lantiq-common/u-boot-spl.lds"
++#endif
++
++#if defined(CONFIG_LTQ_SPL_CONSOLE)
++#define CONFIG_SPL_SERIAL_SUPPORT
++#define CONFIG_SPL_LIBCOMMON_SUPPORT
++#endif
++
++#if defined(CONFIG_LTQ_SPL_COMP_LZMA)
++#define CONFIG_LZMA
++#define CONFIG_SPL_LZMA_SUPPORT
++#endif
++
++#if defined(CONFIG_LTQ_SPL_COMP_LZO)
++#define CONFIG_LZO
++#define CONFIG_SPL_LZO_SUPPORT
++#endif
++
++/* Basic commands */
++#define CONFIG_CMD_BDI
++#define CONFIG_CMD_EDITENV
++#define CONFIG_CMD_IMI
++#define CONFIG_CMD_MEMORY
++#define CONFIG_CMD_RUN
++#define CONFIG_CMD_SAVEENV
++#define CONFIG_CMD_LOADS
++#define CONFIG_CMD_LOADB
++
++/* Other U-Boot settings */
++#define CONFIG_UBOOT_VERSION
++#define CONFIG_TIMESTAMP
++
++/* Default environment */
++#define CONFIG_ENV_CONSOLEDEV \
++ "consoledev=" CONFIG_CONSOLE_DEV "\0"
++
++#define CONFIG_ENV_ADDCONSOLE \
++ "addconsole=setenv bootargs $bootargs" \
++ " console=$consoledev,$baudrate\0"
++
++#if defined(CONFIG_NET_DEV)
++#define CONFIG_ENV_NETDEV \
++ "netdev=" CONFIG_NET_DEV "\0"
++#else
++#define CONFIG_ENV_NETDEV \
++ "netdev=eth0\0"
++#endif
++
++#define CONFIG_ENV_ADDIP \
++ "addip=setenv bootargs $bootargs" \
++ " ip=$ipaddr:$serverip::::$netdev:off\0"
++
++#define CONFIG_ENV_ADDETH \
++ "addeth=setenv bootargs $bootargs" \
++ " ethaddr=$ethaddr\0"
++
++#define CONFIG_ENV_ADDMACHTYPE \
++ "addmachtype=setenv bootargs $bootargs" \
++ " machtype=" CONFIG_MACH_TYPE "\0"
++
++#if defined(CONFIG_LTQ_SUPPORT_NOR_FLASH)
++#define CONFIG_ENV_WRITE_UBOOT_NOR \
++ "write-uboot-nor=" \
++ "protect off " __stringify(CONFIG_SYS_FLASH_BASE) " +$filesize && " \
++ "erase " __stringify(CONFIG_SYS_FLASH_BASE) " +$filesize && " \
++ "cp.b $fileaddr " __stringify(CONFIG_SYS_FLASH_BASE) " $filesize\0"
++
++#define CONFIG_ENV_LOAD_UBOOT_NOR \
++ "load-uboot-nor=tftpboot u-boot.bin\0" \
++ "load-uboot-norspl=tftpboot u-boot.ltq.norspl\0" \
++ "load-uboot-norspl-lzo=tftpboot u-boot.ltq.lzo.norspl\0" \
++ "load-uboot-norspl-lzma=tftpboot u-boot.ltq.lzma.norspl\0"
++#else
++#define CONFIG_ENV_WRITE_UBOOT_NOR
++#define CONFIG_ENV_LOAD_UBOOT_NOR
++#endif
++
++#if defined(CONFIG_LTQ_SUPPORT_SPI_FLASH)
++#define CONFIG_ENV_SF_PROBE \
++ "sf-probe=sf probe " __stringify(CONFIG_ENV_SPI_CS) " " \
++ __stringify(CONFIG_ENV_SPI_MAX_HZ) " " \
++ __stringify(CONFIG_ENV_SPI_MODE) " \0"
++
++#define CONFIG_ENV_WRITE_UBOOT_SF \
++ "write-uboot-sf=" \
++ "run sf-probe && sf erase 0 +$filesize && " \
++ "sf write $fileaddr 0 $filesize\0"
++
++#define CONFIG_ENV_LOAD_UBOOT_SF \
++ "load-uboot-sfspl=tftpboot u-boot.ltq.sfspl\0" \
++ "load-uboot-sfspl-lzo=tftpboot u-boot.ltq.lzo.sfspl\0" \
++ "load-uboot-sfspl-lzma=tftpboot u-boot.ltq.lzma.sfspl\0"
++#else
++#define CONFIG_ENV_SF_PROBE
++#define CONFIG_ENV_WRITE_UBOOT_SF
++#define CONFIG_ENV_LOAD_UBOOT_SF
++#endif
++
++#define CONFIG_ENV_LANTIQ_DEFAULTS \
++ CONFIG_ENV_CONSOLEDEV \
++ CONFIG_ENV_ADDCONSOLE \
++ CONFIG_ENV_NETDEV \
++ CONFIG_ENV_ADDIP \
++ CONFIG_ENV_ADDETH \
++ CONFIG_ENV_ADDMACHTYPE \
++ CONFIG_ENV_WRITE_UBOOT_NOR \
++ CONFIG_ENV_LOAD_UBOOT_NOR \
++ CONFIG_ENV_SF_PROBE \
++ CONFIG_ENV_WRITE_UBOOT_SF \
++ CONFIG_ENV_LOAD_UBOOT_SF
++
++#endif /* __LANTIQ_CONFIG_H__ */
+--- /dev/null
++++ b/arch/mips/include/asm/lantiq/cpu.h
+@@ -0,0 +1,35 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011-2012 Daniel Schwierzeck, daniel.schwierzeck@gmail.com
++ */
++
++#ifndef __LANTIQ_CPU_H__
++#define __LANTIQ_CPU_H__
++
++enum ltq_boot_select {
++ BOOT_NOR,
++ BOOT_NOR_NO_BOOTROM,
++ BOOT_UART,
++ BOOT_UART_NO_EEPROM,
++ BOOT_SPI,
++ BOOT_NAND,
++ BOOT_PCI,
++ BOOT_MII0,
++ BOOT_RMII0,
++ BOOT_RGMII1,
++ BOOT_UNKNOWN,
++};
++
++enum ltq_boot_select ltq_boot_select(void);
++const char *ltq_boot_select_str(void);
++
++void ltq_pmu_init(void);
++void ltq_ebu_init(void);
++void ltq_gpio_init(void);
++
++void ltq_pll_init(void);
++void ltq_dcdc_init(unsigned int dig_ref);
++
++#endif /* __LANTIQ_CPU_H__ */
+--- /dev/null
++++ b/arch/mips/include/asm/lantiq/dma.h
+@@ -0,0 +1,95 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#ifndef __LANTIQ_DMA_H__
++#define __LANTIQ_DMA_H__
++
++enum ltq_dma_endianess {
++ LTQ_DMA_ENDIANESS_B0_B1_B2_B3, /* No byte swapping */
++ LTQ_DMA_ENDIANESS_B1_B0_B3_B2, /* B0B1B2B3 => B1B0B3B2 */
++ LTQ_DMA_ENDIANESS_B2_B3_B0_B1, /* B0B1B2B3 => B2B3B0B1 */
++ LTQ_DMA_ENDIANESS_B3_B2_B1_B0, /* B0B1B2B3 => B3B2B1B0 */
++};
++
++enum ltq_dma_burst_len {
++ LTQ_DMA_BURST_2WORDS = 1,
++ LTQ_DMA_BURST_4WORDS = 2,
++ LTQ_DMA_BURST_8WORDS = 3,
++};
++
++struct ltq_dma_desc {
++ u32 ctl;
++ u32 addr;
++};
++
++struct ltq_dma_channel {
++ struct ltq_dma_device *dev;
++ u8 chan_no;
++ u8 class;
++ u16 num_desc;
++ struct ltq_dma_desc *desc_base;
++ void *mem_base;
++ u32 dma_addr;
++};
++
++struct ltq_dma_device {
++ enum ltq_dma_endianess rx_endian_swap;
++ enum ltq_dma_endianess tx_endian_swap;
++ enum ltq_dma_burst_len rx_burst_len;
++ enum ltq_dma_burst_len tx_burst_len;
++ struct ltq_dma_channel rx_chan;
++ struct ltq_dma_channel tx_chan;
++ u8 port;
++};
++
++/**
++ * Initialize DMA hardware and driver
++ */
++void ltq_dma_init(void);
++
++/**
++ * Register given DMA client context
++ *
++ * @returns 0 on success, negative value otherwise
++ */
++int ltq_dma_register(struct ltq_dma_device *dev);
++
++/**
++ * Reset and halt all channels related to given DMA client
++ */
++void ltq_dma_reset(struct ltq_dma_device *dev);
++void ltq_dma_enable(struct ltq_dma_device *dev);
++void ltq_dma_disable(struct ltq_dma_device *dev);
++
++/**
++ * Map RX DMA descriptor to memory region
++ *
++ * @returns 0 on success, negative value otherwise
++ */
++int ltq_dma_rx_map(struct ltq_dma_device *dev, int index, void *data, int len);
++
++/**
++ * Check if new data is available.
++ *
++ * @returns length of received data, 0 otherwise
++ */
++int ltq_dma_rx_poll(struct ltq_dma_device *dev, int index);
++
++int ltq_dma_rx_length(struct ltq_dma_device *dev, int index);
++
++/**
++ * Map TX DMA descriptor to memory region
++ *
++ * @returns 0 on success, negative value otherwise
++ */
++int ltq_dma_tx_map(struct ltq_dma_device *dev, int index, void *data, int len,
++ unsigned long timeout);
++
++int ltq_dma_tx_wait(struct ltq_dma_device *dev, int index,
++ unsigned long timeout);
++
++#endif /* __LANTIQ_DMA_H__ */
+--- /dev/null
++++ b/arch/mips/include/asm/lantiq/eth.h
+@@ -0,0 +1,36 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#ifndef __LANTIQ_ETH_H__
++#define __LANTIQ_ETH_H__
++
++#include <phy.h>
++
++enum LTQ_ETH_PORT_FLAGS {
++ LTQ_ETH_PORT_NONE = 0,
++ LTQ_ETH_PORT_PHY = 1,
++ LTQ_ETH_PORT_SWITCH = (1 << 1),
++ LTQ_ETH_PORT_MAC = (1 << 2),
++};
++
++struct ltq_eth_port_config {
++ u8 num;
++ u8 phy_addr;
++ u16 flags;
++ phy_interface_t phy_if;
++ u8 rgmii_rx_delay;
++ u8 rgmii_tx_delay;
++};
++
++struct ltq_eth_board_config {
++ const struct ltq_eth_port_config *ports;
++ int num_ports;
++};
++
++extern int ltq_eth_initialize(const struct ltq_eth_board_config *board_config);
++
++#endif /* __LANTIQ_ETH_H__ */
+--- /dev/null
++++ b/arch/mips/include/asm/lantiq/gpio.h
+@@ -0,0 +1,51 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#ifndef __LANTIQ_GPIO_H__
++#define __LANTIQ_GPIO_H__
++
++enum ltq_gpio_dir {
++ GPIO_DIR_IN = 0,
++ GPIO_DIR_OUT
++};
++
++enum ltq_gpio_od {
++ GPIO_OD_ACTIVE = 0,
++ GPIO_OD_NORMAL
++};
++
++enum ltq_gpio_altsel {
++ GPIO_ALTSEL_CLR = 0,
++ GPIO_ALTSEL_SET
++};
++
++extern int gpio_set_altfunc(unsigned gpio, int altsel0, int altsel1, int dir);
++extern int gpio_set_opendrain(unsigned gpio, int od);
++
++static inline int gpio_to_port(unsigned gpio)
++{
++ return gpio >> 4;
++}
++
++static inline int gpio_to_pin(unsigned gpio)
++{
++ return gpio & 0xF;
++}
++
++static inline int gpio_to_bit(unsigned gpio)
++{
++ return 1 << gpio_to_pin(gpio);
++}
++
++static inline int gpio_to_gpio(unsigned port, unsigned pin)
++{
++ return (port << 4) | (pin & 0xF);
++}
++
++#include <asm-generic/gpio.h>
++
++#endif /* __LANTIQ_GPIO_H__ */
+--- /dev/null
++++ b/arch/mips/include/asm/lantiq/io.h
+@@ -0,0 +1,38 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#ifndef __LANTIQ_IO_H__
++#define __LANTIQ_IO_H__
++
++#include <asm/io.h>
++
++#define ltq_readb(a) __raw_readb(a)
++#define ltq_writeb(a, v) __raw_writeb(v, a)
++
++#define ltq_readl(a) __raw_readl(a)
++#define ltq_writel(a, v) __raw_writel(v, a)
++
++#define ltq_clrbits(a, clear) \
++ ltq_writel(a, ltq_readl(a) & ~(clear))
++
++#define ltq_setbits(a, set) \
++ ltq_writel(a, ltq_readl(a) | (set))
++
++#define ltq_clrsetbits(a, clear, set) \
++ ltq_writel(a, (ltq_readl(a) & ~(clear)) | (set))
++
++static inline void ltq_reg_dump(const void *addr, const char *desc)
++{
++ u32 data;
++
++ data = ltq_readl(addr);
++ printf("ltq_reg_dump: %s 0x%p = 0x%08x\n",
++ desc, addr, data);
++}
++
++#endif /* __LANTIQ_IO_H__ */
+--- /dev/null
++++ b/arch/mips/include/asm/lantiq/pm.h
+@@ -0,0 +1,22 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#ifndef __LANTIQ_PM_H__
++#define __LANTIQ_PM_H__
++
++enum ltq_pm_modules {
++ LTQ_PM_CORE,
++ LTQ_PM_DMA,
++ LTQ_PM_ETH,
++ LTQ_PM_SPI,
++};
++
++u32 ltq_pm_map(enum ltq_pm_modules module);
++int ltq_pm_enable(enum ltq_pm_modules module);
++int ltq_pm_disable(enum ltq_pm_modules module);
++
++#endif /* __LANTIQ_PM_H__ */
+--- /dev/null
++++ b/arch/mips/include/asm/lantiq/reset.h
+@@ -0,0 +1,38 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#ifndef __LANTIQ_RESET_H__
++#define __LANTIQ_RESET_H__
++
++enum ltq_reset_modules {
++ LTQ_RESET_CORE,
++ LTQ_RESET_DMA,
++ LTQ_RESET_ETH,
++ LTQ_RESET_PHY,
++ LTQ_RESET_HARD,
++ LTQ_RESET_SOFT,
++};
++
++extern u32 ltq_reset_map(enum ltq_reset_modules module);
++extern int ltq_reset_activate(enum ltq_reset_modules module);
++extern int ltq_reset_deactivate(enum ltq_reset_modules module);
++
++static inline int ltq_reset_once(enum ltq_reset_modules module, ulong usec)
++{
++ int ret;
++
++ ret = ltq_reset_activate(module);
++ if (ret)
++ return ret;
++
++ __udelay(usec);
++ ret = ltq_reset_deactivate(module);
++
++ return ret;
++}
++
++#endif /* __LANTIQ_RESET_H__ */
+--- a/arch/mips/include/asm/mipsregs.h
++++ b/arch/mips/include/asm/mipsregs.h
+@@ -46,7 +46,10 @@
+ #define CP0_ENTRYLO1 $3
+ #define CP0_CONF $3
+ #define CP0_CONTEXT $4
++#define CP0_CONTEXTCONFIG $4,1
++#define CP0_USERLOCAL $4,1
+ #define CP0_PAGEMASK $5
++#define CP0_PAGEGRAIN $5,1
+ #define CP0_WIRED $6
+ #define CP0_INFO $7
+ #define CP0_BADVADDR $8
+@@ -54,10 +57,19 @@
+ #define CP0_ENTRYHI $10
+ #define CP0_COMPARE $11
+ #define CP0_STATUS $12
++#define CP0_INTCTL $12,1
++#define CP0_SRSCTL $12,2
++#define CP0_SRSMAP $12,3
++#define CP0_SRSHIGH $12,4
+ #define CP0_CAUSE $13
+ #define CP0_EPC $14
+ #define CP0_PRID $15
++#define CP0_EBASE $15,1
+ #define CP0_CONFIG $16
++#define CP0_CONFIG1 $16,1
++#define CP0_CONFIG2 $16,2
++#define CP0_CONFIG3 $16,3
++#define CP0_CONFIG7 $16,7
+ #define CP0_LLADDR $17
+ #define CP0_WATCHLO $18
+ #define CP0_WATCHHI $19
+@@ -70,7 +82,17 @@
+ #define CP0_ECC $26
+ #define CP0_CACHEERR $27
+ #define CP0_TAGLO $28
++#define CP0_ITAGLO $28
++#define CP0_IDATALO $28,1
++#define CP0_DTAGLO $28,2
++#define CP0_DDATALO $28,3
++#define CP0_L23TAGLO $28,4
++#define CP0_L23DATALO $28,5
+ #define CP0_TAGHI $29
++#define CP0_IDATAHI $29,1
++#define CP0_DTAGHI $29,2
++#define CP0_L23TAGHI $29,4
++#define CP0_L23DATAHI $29,5
+ #define CP0_ERROREPC $30
+ #define CP0_DESAVE $31
+
+@@ -395,6 +417,12 @@
+ #define CAUSEF_BD (_ULCAST_(1) << 31)
+
+ /*
++ * Bits in the coprocessor 0 EBase register.
++ */
++#define EBASEB_CPUNUM 0
++#define EBASEF_CPUNUM (_ULCAST_(1023))
++
++/*
+ * Bits in the coprocessor 0 config register.
+ */
+ /* Generic bits. */
+--- a/arch/mips/include/asm/u-boot-mips.h
++++ b/arch/mips/include/asm/u-boot-mips.h
+@@ -9,3 +9,4 @@ extern ulong uboot_end_data;
+ extern ulong uboot_end;
+
+ extern int incaip_set_cpuclk(void);
++extern int arch_cpu_init(void);
+--- a/arch/mips/lib/board.c
++++ b/arch/mips/lib/board.c
+@@ -50,6 +50,16 @@ static char *failed = "*** failed ***\n"
+ */
+ const unsigned long mips_io_port_base = -1;
+
++int __arch_cpu_init(void)
++{
++ /*
++ * Nothing to do in this dummy implementation
++ */
++ return 0;
++}
++int arch_cpu_init(void)
++ __attribute__((weak, alias("__arch_cpu_init")));
++
+ int __board_early_init_f(void)
+ {
+ /*
+@@ -123,6 +133,7 @@ static int init_baudrate(void)
+ typedef int (init_fnc_t)(void);
+
+ init_fnc_t *init_sequence[] = {
++ arch_cpu_init,
+ board_early_init_f,
+ timer_init,
+ env_init, /* initialize environment */
+--- /dev/null
++++ b/board/lantiq/easy50712/Makefile
+@@ -0,0 +1,29 @@
++#
++# This file is released under the terms of GPL v2 and any later version.
++# See the file COPYING in the root directory of the source tree for details.
++#
++# Copyright (C) 2000-2011 Wolfgang Denk, DENX Software Engineering, wd@denx.de
++# Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++#
++
++include $(TOPDIR)/config.mk
++
++LIB = $(obj)lib$(BOARD).o
++
++COBJS = $(BOARD).o
++
++SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c)
++OBJS := $(addprefix $(obj),$(COBJS))
++SOBJS := $(addprefix $(obj),$(SOBJS))
++
++$(LIB): $(obj).depend $(OBJS) $(SOBJS)
++ $(call cmd_link_o_target, $(OBJS) $(SOBJS))
++
++#########################################################################
++
++# defines $(obj).depend target
++include $(SRCTREE)/rules.mk
++
++sinclude $(obj).depend
++
++#########################################################################
+--- /dev/null
++++ b/board/lantiq/easy50712/config.mk
+@@ -0,0 +1,8 @@
++#
++# This file is released under the terms of GPL v2 and any later version.
++# See the file COPYING in the root directory of the source tree for details.
++#
++# Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++#
++
++PLATFORM_CPPFLAGS += -I$(TOPDIR)/board/$(BOARDDIR)
+--- /dev/null
++++ b/board/lantiq/easy50712/ddr_settings.h
+@@ -0,0 +1,55 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2007-2010 Lantiq Deutschland GmbH
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#define MC_DC00_VALUE 0x1B1B
++#define MC_DC01_VALUE 0x0
++#define MC_DC02_VALUE 0x0
++#define MC_DC03_VALUE 0x0
++#define MC_DC04_VALUE 0x0
++#define MC_DC05_VALUE 0x200
++#define MC_DC06_VALUE 0x605
++#define MC_DC07_VALUE 0x303
++#define MC_DC08_VALUE 0x102
++#define MC_DC09_VALUE 0x70a
++#define MC_DC10_VALUE 0x203
++#define MC_DC11_VALUE 0xc02
++#define MC_DC12_VALUE 0x1C8
++#define MC_DC13_VALUE 0x1
++#define MC_DC14_VALUE 0x0
++#define MC_DC15_VALUE 0x13c
++#define MC_DC16_VALUE 0xC800
++#define MC_DC17_VALUE 0xd
++#define MC_DC18_VALUE 0x300
++#define MC_DC19_VALUE 0x200
++#define MC_DC20_VALUE 0xA04
++#define MC_DC21_VALUE 0xd00
++#define MC_DC22_VALUE 0xd0d
++#define MC_DC23_VALUE 0x0
++#define MC_DC24_VALUE 0x62
++#define MC_DC25_VALUE 0x0
++#define MC_DC26_VALUE 0x0
++#define MC_DC27_VALUE 0x0
++#define MC_DC28_VALUE 0x510
++#define MC_DC29_VALUE 0x2d89
++#define MC_DC30_VALUE 0x8300
++#define MC_DC31_VALUE 0x0
++#define MC_DC32_VALUE 0x0
++#define MC_DC33_VALUE 0x0
++#define MC_DC34_VALUE 0x0
++#define MC_DC35_VALUE 0x0
++#define MC_DC36_VALUE 0x0
++#define MC_DC37_VALUE 0x0
++#define MC_DC38_VALUE 0x0
++#define MC_DC39_VALUE 0x0
++#define MC_DC40_VALUE 0x0
++#define MC_DC41_VALUE 0x0
++#define MC_DC42_VALUE 0x0
++#define MC_DC43_VALUE 0x0
++#define MC_DC44_VALUE 0x0
++#define MC_DC45_VALUE 0x500
++#define MC_DC46_VALUE 0x0
+--- /dev/null
++++ b/board/lantiq/easy50712/easy50712.c
+@@ -0,0 +1,106 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2010 Thomas Langer <thomas.langer@lantiq.com>
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <common.h>
++#include <switch.h>
++#include <spi.h>
++#include <asm/gpio.h>
++#include <asm/lantiq/eth.h>
++#include <asm/lantiq/reset.h>
++#include <asm/lantiq/chipid.h>
++
++static void gpio_init(void)
++{
++ /* SPI/CS output (low-active) for serial flash */
++ gpio_direction_output(22, 1);
++
++ /* enable CLK_OUT2 for external switch */
++ gpio_set_altfunc(3, GPIO_ALTSEL_SET, GPIO_ALTSEL_CLR, GPIO_DIR_OUT);
++}
++
++int board_early_init_f(void)
++{
++ gpio_init();
++
++ return 0;
++}
++
++int checkboard(void)
++{
++ puts("Board: " CONFIG_BOARD_NAME "\n");
++ ltq_chip_print_info();
++
++ return 0;
++}
++
++static const struct ltq_eth_port_config eth_port_config[] = {
++ /* MAC0: Lantiq ADM6996I switch */
++ { 0, 0x0, LTQ_ETH_PORT_SWITCH, PHY_INTERFACE_MODE_RMII },
++};
++
++static const struct ltq_eth_board_config eth_board_config = {
++ .ports = eth_port_config,
++ .num_ports = ARRAY_SIZE(eth_port_config),
++};
++
++int board_eth_init(bd_t *bis)
++{
++ return ltq_eth_initialize(&eth_board_config);
++}
++
++static struct switch_device adm6996i_dev = {
++ .name = "adm6996i",
++ .cpu_port = 5,
++ .port_mask = 0xF,
++};
++
++int board_switch_init(void)
++{
++ /* Deactivate HRST line to release reset of ADM6996I switch */
++ ltq_reset_once(LTQ_RESET_HARD, 200000);
++
++ /* ADM6996I needs some time to come out of reset */
++ __udelay(50000);
++
++ return switch_device_register(&adm6996i_dev);
++}
++
++int spi_cs_is_valid(unsigned int bus, unsigned int cs)
++{
++ if (bus)
++ return 0;
++
++ switch (cs) {
++ case 2:
++ return 1;
++ default:
++ return 0;
++ }
++}
++
++void spi_cs_activate(struct spi_slave *slave)
++{
++ switch (slave->cs) {
++ case 2:
++ gpio_set_value(22, 0);
++ break;
++ default:
++ break;
++ }
++}
++
++void spi_cs_deactivate(struct spi_slave *slave)
++{
++ switch (slave->cs) {
++ case 2:
++ gpio_set_value(22, 1);
++ break;
++ default:
++ break;
++ }
++}
+--- /dev/null
++++ b/board/lantiq/easy80920/Makefile
+@@ -0,0 +1,29 @@
++#
++# This file is released under the terms of GPL v2 and any later version.
++# See the file COPYING in the root directory of the source tree for details.
++#
++# Copyright (C) 2000-2011 Wolfgang Denk, DENX Software Engineering, wd@denx.de
++# Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++#
++
++include $(TOPDIR)/config.mk
++
++LIB = $(obj)lib$(BOARD).o
++
++COBJS = $(BOARD).o
++
++SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c)
++OBJS := $(addprefix $(obj),$(COBJS))
++SOBJS := $(addprefix $(obj),$(SOBJS))
++
++$(LIB): $(obj).depend $(OBJS) $(SOBJS)
++ $(call cmd_link_o_target, $(OBJS) $(SOBJS))
++
++#########################################################################
++
++# defines $(obj).depend target
++include $(SRCTREE)/rules.mk
++
++sinclude $(obj).depend
++
++#########################################################################
+--- /dev/null
++++ b/board/lantiq/easy80920/config.mk
+@@ -0,0 +1,8 @@
++#
++# This file is released under the terms of GPL v2 and any later version.
++# See the file COPYING in the root directory of the source tree for details.
++#
++# Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++#
++
++PLATFORM_CPPFLAGS += -I$(TOPDIR)/board/$(BOARDDIR)
+--- /dev/null
++++ b/board/lantiq/easy80920/ddr_settings.h
+@@ -0,0 +1,70 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2007-2010 Lantiq Deutschland GmbH
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#define MC_CCR00_VALUE 0x101
++#define MC_CCR01_VALUE 0x1000100
++#define MC_CCR02_VALUE 0x1010000
++#define MC_CCR03_VALUE 0x101
++#define MC_CCR04_VALUE 0x1000000
++#define MC_CCR05_VALUE 0x1000101
++#define MC_CCR06_VALUE 0x1000100
++#define MC_CCR07_VALUE 0x1010000
++#define MC_CCR08_VALUE 0x1000101
++#define MC_CCR09_VALUE 0x0
++#define MC_CCR10_VALUE 0x2000100
++#define MC_CCR11_VALUE 0x2000300
++#define MC_CCR12_VALUE 0x30000
++#define MC_CCR13_VALUE 0x202
++#define MC_CCR14_VALUE 0x7080A0F
++#define MC_CCR15_VALUE 0x2040F
++#define MC_CCR16_VALUE 0x40000
++#define MC_CCR17_VALUE 0x70102
++#define MC_CCR18_VALUE 0x4020002
++#define MC_CCR19_VALUE 0x30302
++#define MC_CCR20_VALUE 0x8000700
++#define MC_CCR21_VALUE 0x40F020A
++#define MC_CCR22_VALUE 0x0
++#define MC_CCR23_VALUE 0xC020000
++#define MC_CCR24_VALUE 0x4401B04
++#define MC_CCR25_VALUE 0x0
++#define MC_CCR26_VALUE 0x0
++#define MC_CCR27_VALUE 0x6420000
++#define MC_CCR28_VALUE 0x0
++#define MC_CCR29_VALUE 0x0
++#define MC_CCR30_VALUE 0x798
++#define MC_CCR31_VALUE 0x0
++#define MC_CCR32_VALUE 0x0
++#define MC_CCR33_VALUE 0x650000
++#define MC_CCR34_VALUE 0x200C8
++#define MC_CCR35_VALUE 0x1D445D
++#define MC_CCR36_VALUE 0xC8
++#define MC_CCR37_VALUE 0xC351
++#define MC_CCR38_VALUE 0x0
++#define MC_CCR39_VALUE 0x141F04
++#define MC_CCR40_VALUE 0x142704
++#define MC_CCR41_VALUE 0x141b42
++#define MC_CCR42_VALUE 0x141b42
++#define MC_CCR43_VALUE 0x566504
++#define MC_CCR44_VALUE 0x566504
++#define MC_CCR45_VALUE 0x565F17
++#define MC_CCR46_VALUE 0x565F17
++#define MC_CCR47_VALUE 0x0
++#define MC_CCR48_VALUE 0x0
++#define MC_CCR49_VALUE 0x0
++#define MC_CCR50_VALUE 0x0
++#define MC_CCR51_VALUE 0x0
++#define MC_CCR52_VALUE 0x133
++#define MC_CCR53_VALUE 0xF3014B27
++#define MC_CCR54_VALUE 0xF3014B27
++#define MC_CCR55_VALUE 0xF3014B27
++#define MC_CCR56_VALUE 0xF3014B27
++#define MC_CCR57_VALUE 0x7800301
++#define MC_CCR58_VALUE 0x7800301
++#define MC_CCR59_VALUE 0x7800301
++#define MC_CCR60_VALUE 0x7800301
++#define MC_CCR61_VALUE 0x4
+--- /dev/null
++++ b/board/lantiq/easy80920/easy80920.c
+@@ -0,0 +1,139 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <common.h>
++#include <spi.h>
++#include <asm/gpio.h>
++#include <asm/lantiq/eth.h>
++#include <asm/lantiq/chipid.h>
++#include <asm/lantiq/cpu.h>
++#include <asm/arch/gphy.h>
++
++#if defined(CONFIG_SPL_BUILD)
++#define do_gpio_init 1
++#define do_pll_init 1
++#define do_dcdc_init 0
++#elif defined(CONFIG_SYS_BOOT_RAM)
++#define do_gpio_init 1
++#define do_pll_init 0
++#define do_dcdc_init 1
++#elif defined(CONFIG_SYS_BOOT_NOR)
++#define do_gpio_init 1
++#define do_pll_init 1
++#define do_dcdc_init 1
++#else
++#define do_gpio_init 0
++#define do_pll_init 0
++#define do_dcdc_init 1
++#endif
++
++static void gpio_init(void)
++{
++ /* SPI CS 0.4 to serial flash */
++ gpio_direction_output(10, 1);
++
++ /* EBU.FL_CS1 as output for NAND CE */
++ gpio_set_altfunc(23, GPIO_ALTSEL_SET, GPIO_ALTSEL_CLR, GPIO_DIR_OUT);
++ /* EBU.FL_A23 as output for NAND CLE */
++ gpio_set_altfunc(24, GPIO_ALTSEL_SET, GPIO_ALTSEL_CLR, GPIO_DIR_OUT);
++ /* EBU.FL_A24 as output for NAND ALE */
++ gpio_set_altfunc(13, GPIO_ALTSEL_SET, GPIO_ALTSEL_CLR, GPIO_DIR_OUT);
++ /* GPIO 3.0 as input for NAND Ready Busy */
++ gpio_set_altfunc(48, GPIO_ALTSEL_SET, GPIO_ALTSEL_CLR, GPIO_DIR_IN);
++ /* GPIO 3.1 as output for NAND Read */
++ gpio_set_altfunc(49, GPIO_ALTSEL_SET, GPIO_ALTSEL_CLR, GPIO_DIR_OUT);
++}
++
++int board_early_init_f(void)
++{
++ if (do_gpio_init)
++ gpio_init();
++
++ if (do_pll_init)
++ ltq_pll_init();
++
++ if (do_dcdc_init)
++ ltq_dcdc_init(0x7F);
++
++ return 0;
++}
++
++int checkboard(void)
++{
++ puts("Board: " CONFIG_BOARD_NAME "\n");
++ ltq_chip_print_info();
++
++ return 0;
++}
++
++static const struct ltq_eth_port_config eth_port_config[] = {
++ /* GMAC0: external Lantiq PEF7071 10/100/1000 PHY for LAN port 0 */
++ { 0, 0x0, LTQ_ETH_PORT_PHY, PHY_INTERFACE_MODE_RGMII },
++ /* GMAC1: external Lantiq PEF7071 10/100/1000 PHY for LAN port 1 */
++ { 1, 0x1, LTQ_ETH_PORT_PHY, PHY_INTERFACE_MODE_RGMII },
++ /* GMAC2: internal GPHY0 with 10/100/1000 firmware for LAN port 2 */
++ { 2, 0x11, LTQ_ETH_PORT_PHY, PHY_INTERFACE_MODE_GMII },
++ /* GMAC3: unused */
++ { 3, 0x0, LTQ_ETH_PORT_NONE, PHY_INTERFACE_MODE_NONE },
++ /* GMAC4: internal GPHY1 with 10/100/1000 firmware for LAN port 3 */
++ { 4, 0x13, LTQ_ETH_PORT_PHY, PHY_INTERFACE_MODE_GMII },
++ /* GMAC5: external Lantiq PEF7071 10/100/1000 PHY for WANoE port */
++ { 5, 0x5, LTQ_ETH_PORT_PHY, PHY_INTERFACE_MODE_RGMII },
++};
++
++static const struct ltq_eth_board_config eth_board_config = {
++ .ports = eth_port_config,
++ .num_ports = ARRAY_SIZE(eth_port_config),
++};
++
++int board_eth_init(bd_t * bis)
++{
++ const enum ltq_gphy_clk clk = LTQ_GPHY_CLK_25MHZ_PLL0;
++ const ulong fw_addr = 0x80FF0000;
++
++ ltq_gphy_phy11g_a1x_load(fw_addr);
++
++ ltq_cgu_gphy_clk_src(clk);
++
++ ltq_rcu_gphy_boot(0, fw_addr);
++ ltq_rcu_gphy_boot(1, fw_addr);
++
++ return ltq_eth_initialize(&eth_board_config);
++}
++
++int spi_cs_is_valid(unsigned int bus, unsigned int cs)
++{
++ if (bus)
++ return 0;
++
++ if (cs == 4)
++ return 1;
++
++ return 0;
++}
++
++void spi_cs_activate(struct spi_slave *slave)
++{
++ switch (slave->cs) {
++ case 4:
++ gpio_set_value(10, 0);
++ break;
++ default:
++ break;
++ }
++}
++
++void spi_cs_deactivate(struct spi_slave *slave)
++{
++ switch (slave->cs) {
++ case 4:
++ gpio_set_value(10, 1);
++ break;
++ default:
++ break;
++ }
++}
+--- a/boards.cfg
++++ b/boards.cfg
+@@ -444,10 +444,17 @@ dbau1500 mips
+ dbau1550 mips mips32 dbau1x00 - au1x00 dbau1x00:DBAU1550
+ dbau1550_el mips mips32 dbau1x00 - au1x00 dbau1x00:DBAU1550,SYS_LITTLE_ENDIAN
+ pb1000 mips mips32 pb1x00 - au1x00 pb1x00:PB1000
++easy50712_nor mips mips32 easy50712 lantiq danube easy50712:SYS_BOOT_NOR
++easy50712_norspl mips mips32 easy50712 lantiq danube easy50712:SYS_BOOT_NORSPL
++easy50712_ram mips mips32 easy50712 lantiq danube easy50712:SYS_BOOT_RAM
+ incaip mips mips32 incaip - incaip
+ incaip_100MHz mips mips32 incaip - incaip incaip:CPU_CLOCK_RATE=100000000
+ incaip_133MHz mips mips32 incaip - incaip incaip:CPU_CLOCK_RATE=133000000
+ incaip_150MHz mips mips32 incaip - incaip incaip:CPU_CLOCK_RATE=150000000
++easy80920_nor mips mips32 easy80920 lantiq vrx200 easy80920:SYS_BOOT_NOR
++easy80920_norspl mips mips32 easy80920 lantiq vrx200 easy80920:SYS_BOOT_NORSPL
++easy80920_ram mips mips32 easy80920 lantiq vrx200 easy80920:SYS_BOOT_RAM
++easy80920_sfspl mips mips32 easy80920 lantiq vrx200 easy80920:SYS_BOOT_SFSPL
+ qi_lb60 mips xburst qi_lb60 qi
+ adp-ag101 nds32 n1213 adp-ag101 AndesTech ag101
+ adp-ag101p nds32 n1213 adp-ag101p AndesTech ag101
+--- a/drivers/dma/Makefile
++++ b/drivers/dma/Makefile
+@@ -28,6 +28,7 @@ LIB := $(obj)libdma.o
+ COBJS-$(CONFIG_FSLDMAFEC) += MCD_tasksInit.o MCD_dmaApi.o MCD_tasks.o
+ COBJS-$(CONFIG_APBH_DMA) += apbh_dma.o
+ COBJS-$(CONFIG_FSL_DMA) += fsl_dma.o
++COBJS-$(CONFIG_LANTIQ_DMA) += lantiq_dma.o
+ COBJS-$(CONFIG_OMAP3_DMA) += omap3_dma.o
+
+ COBJS := $(COBJS-y)
+--- /dev/null
++++ b/drivers/dma/lantiq_dma.c
+@@ -0,0 +1,388 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011-2012 Daniel Schwierzeck, daniel.schwierzeck@gmail.com
++ */
++
++#include <common.h>
++#include <malloc.h>
++#include <watchdog.h>
++#include <linux/compiler.h>
++#include <asm/lantiq/io.h>
++#include <asm/lantiq/dma.h>
++#include <asm/lantiq/pm.h>
++#include <asm/lantiq/reset.h>
++#include <asm/arch/soc.h>
++#include <asm/processor.h>
++
++#define DMA_CTRL_PKTARB (1 << 31)
++#define DMA_CTRL_MBRSTARB (1 << 30)
++#define DMA_CTRL_MBRSTCNT_SHIFT 16
++#define DMA_CTRL_MBRSTCNT_MASK (0x3ff << DMA_CTRL_MBRSTCNT_SHIFT)
++#define DMA_CTRL_DRB (1 << 8)
++#define DMA_CTRL_RESET (1 << 0)
++
++#define DMA_CPOLL_EN (1 << 31)
++#define DMA_CPOLL_CNT_SHIFT 4
++#define DMA_CPOLL_CNT_MASK (0xFFF << DMA_CPOLL_CNT_SHIFT)
++
++#define DMA_CCTRL_TXWGT_SHIFT 16
++#define DMA_CCTRL_TXWGT_MASK (0x3 << DMA_CCTRL_TXWGT_SHIFT)
++#define DMA_CCTRL_CLASS_SHIFT 9
++#define DMA_CCTRL_CLASS_MASK (0x3 << DMA_CCTRL_CLASS_SHIFT)
++#define DMA_CCTRL_RST (1 << 1)
++#define DMA_CCTRL_ONOFF (1 << 0)
++
++#define DMA_PCTRL_TXBL_SHIFT 4
++#define DMA_PCTRL_TXBL_2WORDS (1 << DMA_PCTRL_TXBL_SHIFT)
++#define DMA_PCTRL_TXBL_4WORDS (2 << DMA_PCTRL_TXBL_SHIFT)
++#define DMA_PCTRL_TXBL_8WORDS (3 << DMA_PCTRL_TXBL_SHIFT)
++#define DMA_PCTRL_RXBL_SHIFT 2
++#define DMA_PCTRL_RXBL_2WORDS (1 << DMA_PCTRL_RXBL_SHIFT)
++#define DMA_PCTRL_RXBL_4WORDS (2 << DMA_PCTRL_RXBL_SHIFT)
++#define DMA_PCTRL_RXBL_8WORDS (3 << DMA_PCTRL_RXBL_SHIFT)
++#define DMA_PCTRL_TXENDI_SHIFT 10
++#define DMA_PCTRL_TXENDI_MASK (0x3 << DMA_PCTRL_TXENDI_SHIFT)
++#define DMA_PCTRL_RXENDI_SHIFT 8
++#define DMA_PCTRL_RXENDI_MASK (0x3 << DMA_PCTRL_RXENDI_SHIFT)
++
++#define DMA_DESC_OWN (1 << 31)
++#define DMA_DESC_C (1 << 30)
++#define DMA_DESC_SOP (1 << 29)
++#define DMA_DESC_EOP (1 << 28)
++#define DMA_DESC_TX_OFFSET(x) ((x & 0x1f) << 23)
++#define DMA_DESC_RX_OFFSET(x) ((x & 0x3) << 23)
++#define DMA_DESC_LENGTH(x) (x & 0xffff)
++
++#define PTR_ALIGN(p, a) ((typeof(p))ALIGN((unsigned long)(p), (a)))
++
++struct ltq_dma_regs {
++ u32 clc; /* Clock control */
++ u32 rsvd0;
++ u32 id; /* Identification */
++ u32 rsvd1;
++ u32 ctrl; /* Control */
++ u32 cpoll; /* Channel polling */
++ u32 cs; /* Channel select */
++ u32 cctrl; /* Channel control */
++ u32 cdba; /* Channel descriptor base address */
++ u32 cdlen; /* Channel descriptor length */
++ u32 cis; /* Channel interrupt status */
++ u32 cie; /* Channel interrupt enable */
++ u32 cgbl; /* Channel global buffer length */
++ u32 cdptnrd; /* Current descriptor pointer */
++ u32 rsvd2[2];
++ u32 ps; /* Port select */
++ u32 pctrl; /* Port control */
++ u32 rsvd3[43];
++ u32 irnen; /* Interrupt node enable */
++ u32 irncr; /* Interrupt node control */
++ u32 irnicr; /* Interrupt capture */
++};
++
++static struct ltq_dma_regs *ltq_dma_regs =
++ (struct ltq_dma_regs *) CKSEG1ADDR(LTQ_DMA_BASE);
++
++static inline unsigned long ltq_dma_addr_to_virt(u32 dma_addr)
++{
++ return KSEG0ADDR(dma_addr);
++}
++
++static inline u32 ltq_virt_to_dma_addr(void *addr)
++{
++ return CPHYSADDR(addr);
++}
++
++static inline int ltq_dma_burst_align(enum ltq_dma_burst_len burst_len)
++{
++ switch (burst_len) {
++ case LTQ_DMA_BURST_2WORDS:
++ return 2 * 4;
++ case LTQ_DMA_BURST_4WORDS:
++ return 4 * 4;
++ case LTQ_DMA_BURST_8WORDS:
++ return 8 * 4;
++ }
++
++ return 0;
++}
++
++static inline void ltq_dma_sync(void)
++{
++ __asm__ __volatile__("sync");
++}
++
++static inline void ltq_dma_dcache_wb_inv(const void *ptr, size_t size)
++{
++ unsigned long addr = (unsigned long) ptr;
++
++ flush_dcache_range(addr, addr + size);
++ ltq_dma_sync();
++}
++
++static inline void ltq_dma_dcache_inv(const void *ptr, size_t size)
++{
++ unsigned long addr = (unsigned long) ptr;
++
++ invalidate_dcache_range(addr, addr + size);
++}
++
++void ltq_dma_init(void)
++{
++ /* Power up DMA */
++ ltq_pm_enable(LTQ_PM_DMA);
++
++ /* Reset DMA */
++ ltq_setbits(&ltq_dma_regs->ctrl, DMA_CTRL_RESET);
++
++ /* Disable and clear all interrupts */
++ ltq_writel(&ltq_dma_regs->irnen, 0);
++ ltq_writel(&ltq_dma_regs->irncr, 0xFFFFF);
++
++#if 0
++ /* Enable packet arbitration */
++ ltq_setbits(&ltq_dma_regs->ctrl, DMA_CTRL_PKTARB);
++#endif
++
++#if 0
++ /* Enable descriptor read back */
++ ltq_setbits(&ltq_dma_regs->ctrl, DMA_CTRL_DRB);
++#endif
++
++ /* Enable polling for descriptor fetching for all channels */
++ ltq_writel(&ltq_dma_regs->cpoll, DMA_CPOLL_EN |
++ (4 << DMA_CPOLL_CNT_SHIFT));
++}
++
++static void ltq_dma_channel_reset(struct ltq_dma_channel *chan)
++{
++ ltq_writel(&ltq_dma_regs->cs, chan->chan_no);
++ ltq_setbits(&ltq_dma_regs->cctrl, DMA_CCTRL_RST);
++}
++
++static void ltq_dma_channel_enable(struct ltq_dma_channel *chan)
++{
++ ltq_writel(&ltq_dma_regs->cs, chan->chan_no);
++ ltq_setbits(&ltq_dma_regs->cctrl, DMA_CCTRL_ONOFF);
++}
++
++static void ltq_dma_channel_disable(struct ltq_dma_channel *chan)
++{
++ ltq_writel(&ltq_dma_regs->cs, chan->chan_no);
++ ltq_clrbits(&ltq_dma_regs->cctrl, DMA_CCTRL_ONOFF);
++}
++
++static void ltq_dma_port_init(struct ltq_dma_device *dev)
++{
++ u32 pctrl;
++
++ pctrl = dev->tx_endian_swap << DMA_PCTRL_TXENDI_SHIFT;
++ pctrl |= dev->rx_endian_swap << DMA_PCTRL_RXENDI_SHIFT;
++ pctrl |= dev->tx_burst_len << DMA_PCTRL_TXBL_SHIFT;
++ pctrl |= dev->rx_burst_len << DMA_PCTRL_RXBL_SHIFT;
++
++ ltq_writel(&ltq_dma_regs->ps, dev->port);
++ ltq_writel(&ltq_dma_regs->pctrl, pctrl);
++}
++
++static int ltq_dma_alloc_descriptors(struct ltq_dma_device *dev,
++ struct ltq_dma_channel *chan)
++{
++ size_t size;
++ void *desc_base;
++
++ size = ALIGN(sizeof(struct ltq_dma_desc) * chan->num_desc +
++ ARCH_DMA_MINALIGN, ARCH_DMA_MINALIGN);
++
++ chan->mem_base = malloc(size);
++ if (!chan->mem_base)
++ return 1;
++
++ memset(chan->mem_base, 0, size);
++ ltq_dma_dcache_wb_inv(chan->mem_base, size);
++
++ desc_base = PTR_ALIGN(chan->mem_base, ARCH_DMA_MINALIGN);
++
++ debug("DMA: mem %p, desc %p\n", chan->mem_base, desc_base);
++
++ /* Align descriptor base to 8 bytes */
++ chan->desc_base = (void *) CKSEG1ADDR(desc_base);
++ chan->dma_addr = CPHYSADDR(desc_base);
++ chan->dev = dev;
++
++ debug("DMA: desc_base %p, size %u\n", chan->desc_base, size);
++
++ /* Configure hardware with location of descriptor list */
++ ltq_writel(&ltq_dma_regs->cs, chan->chan_no);
++ ltq_writel(&ltq_dma_regs->cdba, chan->dma_addr);
++ ltq_writel(&ltq_dma_regs->cdlen, chan->num_desc);
++ ltq_writel(&ltq_dma_regs->cctrl, (3 << DMA_CCTRL_TXWGT_SHIFT) |
++ (chan->class << DMA_CCTRL_CLASS_SHIFT));
++ ltq_writel(&ltq_dma_regs->cctrl, DMA_CCTRL_RST);
++
++ return 0;
++}
++
++static void ltq_dma_free_descriptors(struct ltq_dma_channel *chan)
++{
++ ltq_writel(&ltq_dma_regs->cs, chan->chan_no);
++ ltq_writel(&ltq_dma_regs->cdba, 0);
++ ltq_writel(&ltq_dma_regs->cdlen, 0);
++
++ ltq_dma_channel_reset(chan);
++
++ free(chan->mem_base);
++}
++
++int ltq_dma_register(struct ltq_dma_device *dev)
++{
++ int ret;
++
++ ltq_dma_port_init(dev);
++
++ ret = ltq_dma_alloc_descriptors(dev, &dev->rx_chan);
++ if (ret)
++ return ret;
++
++ ret = ltq_dma_alloc_descriptors(dev, &dev->tx_chan);
++ if (ret) {
++ ltq_dma_free_descriptors(&dev->rx_chan);
++ return ret;
++ }
++
++ return 0;
++}
++
++void ltq_dma_reset(struct ltq_dma_device *dev)
++{
++ ltq_dma_channel_reset(&dev->rx_chan);
++ ltq_dma_channel_reset(&dev->tx_chan);
++}
++
++void ltq_dma_enable(struct ltq_dma_device *dev)
++{
++ ltq_dma_channel_enable(&dev->rx_chan);
++ ltq_dma_channel_enable(&dev->tx_chan);
++}
++
++void ltq_dma_disable(struct ltq_dma_device *dev)
++{
++ ltq_dma_channel_disable(&dev->rx_chan);
++ ltq_dma_channel_disable(&dev->tx_chan);
++}
++
++int ltq_dma_rx_map(struct ltq_dma_device *dev, int index, void *data, int len)
++{
++ struct ltq_dma_channel *chan = &dev->rx_chan;
++ struct ltq_dma_desc *desc = &chan->desc_base[index];
++ u32 dma_addr = ltq_virt_to_dma_addr(data);
++ unsigned int offset;
++
++ offset = dma_addr % ltq_dma_burst_align(dev->rx_burst_len);
++
++ ltq_dma_dcache_inv(data, len);
++
++#if 0
++ printf("%s: index %d, data %p, dma_addr %08x, offset %u, len %d\n",
++ __func__, index, data, dma_addr, offset, len);
++#endif
++
++
++ desc->addr = dma_addr - offset;
++ desc->ctl = DMA_DESC_OWN | DMA_DESC_RX_OFFSET(offset) |
++ DMA_DESC_LENGTH(len);
++
++#if 0
++ printf("%s: index %d, desc %p, desc->ctl %08x\n",
++ __func__, index, desc, desc->ctl);
++#endif
++
++ return 0;
++}
++
++int ltq_dma_rx_poll(struct ltq_dma_device *dev, int index)
++{
++ struct ltq_dma_channel *chan = &dev->rx_chan;
++ struct ltq_dma_desc *desc = &chan->desc_base[index];
++
++#if 0
++ printf("%s: index %d, desc %p, desc->ctl %08x\n",
++ __func__, index, desc, desc->ctl);
++#endif
++
++ if (desc->ctl & DMA_DESC_OWN)
++ return 0;
++
++ if (desc->ctl & DMA_DESC_C)
++ return 1;
++
++ return 0;
++}
++
++int ltq_dma_rx_length(struct ltq_dma_device *dev, int index)
++{
++ struct ltq_dma_channel *chan = &dev->rx_chan;
++ struct ltq_dma_desc *desc = &chan->desc_base[index];
++
++ return DMA_DESC_LENGTH(desc->ctl);
++}
++
++int ltq_dma_tx_map(struct ltq_dma_device *dev, int index, void *data, int len,
++ unsigned long timeout)
++{
++ struct ltq_dma_channel *chan = &dev->tx_chan;
++ struct ltq_dma_desc *desc = &chan->desc_base[index];
++ unsigned int offset;
++ unsigned long timebase = get_timer(0);
++ u32 dma_addr = ltq_virt_to_dma_addr(data);
++
++ while (desc->ctl & DMA_DESC_OWN) {
++ WATCHDOG_RESET();
++
++ if (get_timer(timebase) >= timeout) {
++#if 0
++ printf("%s: timeout: index %d, desc %p, desc->ctl %08x\n",
++ __func__, index, desc, desc->ctl);
++#endif
++ return -1;
++ }
++ }
++
++ offset = dma_addr % ltq_dma_burst_align(dev->rx_burst_len);
++
++#if 0
++ printf("%s: index %d, desc %p, data %p, dma_addr %08x, offset %u, len %d\n",
++ __func__, index, desc, data, dma_addr, offset, len);
++#endif
++
++ ltq_dma_dcache_wb_inv(data, len);
++
++ desc->addr = dma_addr - offset;
++ desc->ctl = DMA_DESC_OWN | DMA_DESC_SOP | DMA_DESC_EOP |
++ DMA_DESC_TX_OFFSET(offset) | DMA_DESC_LENGTH(len);
++
++#if 0
++ printf("%s: index %d, desc %p, desc->ctl %08x\n",
++ __func__, index, desc, desc->ctl);
++#endif
++
++ return 0;
++}
++
++int ltq_dma_tx_wait(struct ltq_dma_device *dev, int index,
++ unsigned long timeout)
++{
++ struct ltq_dma_channel *chan = &dev->tx_chan;
++ struct ltq_dma_desc *desc = &chan->desc_base[index];
++ unsigned long timebase = get_timer(0);
++
++ while ((desc->ctl & (DMA_DESC_OWN | DMA_DESC_C)) != DMA_DESC_C) {
++ WATCHDOG_RESET();
++
++ if (get_timer(timebase) >= timeout)
++ return -1;
++ }
++
++ return 0;
++}
+--- a/drivers/gpio/Makefile
++++ b/drivers/gpio/Makefile
+@@ -28,6 +28,7 @@ LIB := $(obj)libgpio.o
+ COBJS-$(CONFIG_AT91_GPIO) += at91_gpio.o
+ COBJS-$(CONFIG_INTEL_ICH6_GPIO) += intel_ich6_gpio.o
+ COBJS-$(CONFIG_KIRKWOOD_GPIO) += kw_gpio.o
++COBJS-$(CONFIG_LANTIQ_GPIO) += lantiq_gpio.o
+ COBJS-$(CONFIG_MARVELL_GPIO) += mvgpio.o
+ COBJS-$(CONFIG_MARVELL_MFP) += mvmfp.o
+ COBJS-$(CONFIG_MXC_GPIO) += mxc_gpio.o
+--- /dev/null
++++ b/drivers/gpio/lantiq_gpio.c
+@@ -0,0 +1,330 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <common.h>
++#include <asm/arch/soc.h>
++#include <asm/arch/gpio.h>
++#include <asm/lantiq/io.h>
++
++#define SSIO_GPIO_BASE 64
++
++#define SSIO_CON0_SWU (1 << 31)
++#define SSIO_CON0_RZFL (1 << 26)
++#define SSIO_CON0_GPHY1_SHIFT 27
++#define SSIO_CON0_GPHY1_CONFIG ((CONFIG_LTQ_SSIO_GPHY1_MODE & 0x7) << 27)
++
++#define SSIO_CON1_US_FPI (2 << 30)
++#define SSIO_CON1_FPID_2HZ (0 << 23)
++#define SSIO_CON1_FPID_4HZ (1 << 23)
++#define SSIO_CON1_FPID_8HZ (2 << 23)
++#define SSIO_CON1_FPID_10HZ (3 << 23)
++#define SSIO_CON1_FPIS_1_2 (1 << 20)
++#define SSIO_CON1_FPIS_1_32 (2 << 20)
++#define SSIO_CON1_FPIS_1_64 (3 << 20)
++
++#define SSIO_CON1_GPHY2_SHIFT 15
++#define SSIO_CON1_GPHY2_CONFIG ((CONFIG_LTQ_SSIO_GPHY2_MODE & 0x7) << 15)
++
++#define SSIO_CON1_GROUP2 (1 << 2)
++#define SSIO_CON1_GROUP1 (1 << 1)
++#define SSIO_CON1_GROUP0 (1 << 0)
++#define SSIO_CON1_GROUP_CONFIG (0x3)
++
++#ifdef CONFIG_LTQ_SSIO_SHIFT_REGS
++#define enable_ssio 1
++#else
++#define enable_ssio 0
++
++#define CONFIG_LTQ_SSIO_GPHY1_MODE 0
++#define CONFIG_LTQ_SSIO_GPHY2_MODE 0
++#define CONFIG_LTQ_SSIO_INIT_VALUE 0
++#endif
++
++#ifdef CONFIG_LTQ_SSIO_EDGE_FALLING
++#define SSIO_RZFL_CONFIG SSIO_CON0_RZFL
++#else
++#define SSIO_RZFL_CONFIG 0
++#endif
++
++struct ltq_gpio_port_regs {
++ __be32 out;
++ __be32 in;
++ __be32 dir;
++ __be32 altsel0;
++ __be32 altsel1;
++ __be32 od;
++ __be32 stoff;
++ __be32 pudsel;
++ __be32 puden;
++ __be32 rsvd1[3];
++};
++
++struct ltq_gpio_regs {
++ u32 rsvd[4];
++ struct ltq_gpio_port_regs ports[CONFIG_LTQ_GPIO_MAX_BANKS];
++};
++
++struct ltq_gpio3_regs {
++ u32 rsvd0[13];
++ __be32 od;
++ __be32 pudsel;
++ __be32 puden;
++ u32 rsvd1[9];
++ __be32 altsel1;
++ u32 rsvd2[14];
++ __be32 out;
++ __be32 in;
++ __be32 dir;
++ __be32 altsel0;
++};
++
++struct ltq_ssio_regs {
++ __be32 con0;
++ __be32 con1;
++ __be32 cpu0;
++ __be32 cpu1;
++ __be32 ar;
++};
++
++static struct ltq_gpio_regs *ltq_gpio_regs =
++ (struct ltq_gpio_regs *) CKSEG1ADDR(LTQ_GPIO_BASE);
++
++static struct ltq_gpio3_regs *ltq_gpio3_regs =
++ (struct ltq_gpio3_regs *) CKSEG1ADDR(LTQ_GPIO_BASE);
++
++static struct ltq_ssio_regs *ltq_ssio_regs =
++ (struct ltq_ssio_regs *) CKSEG1ADDR(LTQ_SSIO_BASE);
++
++static int is_gpio_bank3(unsigned int port)
++{
++#ifdef CONFIG_LTQ_HAS_GPIO_BANK3
++ return port == 3;
++#else
++ return 0;
++#endif
++}
++
++static int is_gpio_ssio(unsigned int gpio)
++{
++#ifdef CONFIG_LTQ_SSIO_SHIFT_REGS
++ return gpio >= SSIO_GPIO_BASE;
++#else
++ return 0;
++#endif
++}
++
++static inline int ssio_gpio_to_bit(unsigned gpio)
++{
++ return 1 << (gpio - SSIO_GPIO_BASE);
++}
++
++int ltq_gpio_init(void)
++{
++ ltq_writel(&ltq_ssio_regs->ar, 0);
++ ltq_writel(&ltq_ssio_regs->cpu0, CONFIG_LTQ_SSIO_INIT_VALUE);
++ ltq_writel(&ltq_ssio_regs->cpu1, 0);
++ ltq_writel(&ltq_ssio_regs->con0, SSIO_CON0_SWU);
++
++ if (enable_ssio) {
++ ltq_writel(&ltq_ssio_regs->con0, SSIO_CON0_GPHY1_CONFIG |
++ SSIO_RZFL_CONFIG);
++ ltq_writel(&ltq_ssio_regs->con1, SSIO_CON1_US_FPI |
++ SSIO_CON1_FPID_8HZ | SSIO_CON1_GPHY2_CONFIG |
++ SSIO_CON1_GROUP_CONFIG);
++ }
++
++ return 0;
++}
++
++int gpio_request(unsigned gpio, const char *label)
++{
++ return 0;
++}
++
++int gpio_free(unsigned gpio)
++{
++ return 0;
++}
++
++int gpio_direction_input(unsigned gpio)
++{
++ unsigned port = gpio_to_port(gpio);
++ const void *gpio_od = &ltq_gpio_regs->ports[port].od;
++ const void *gpio_altsel0 = &ltq_gpio_regs->ports[port].altsel0;
++ const void *gpio_altsel1 = &ltq_gpio_regs->ports[port].altsel1;
++ const void *gpio_dir = &ltq_gpio_regs->ports[port].dir;
++
++ if (is_gpio_ssio(gpio))
++ return 0;
++
++ if (is_gpio_bank3(port)) {
++ gpio_od = &ltq_gpio3_regs->od;
++ gpio_altsel0 = &ltq_gpio3_regs->altsel0;
++ gpio_altsel1 = &ltq_gpio3_regs->altsel1;
++ gpio_dir = &ltq_gpio3_regs->dir;
++ }
++
++ /*
++ * Reset open drain and altsel configs to workaround improper
++ * reset values or unwanted modifications by BootROM
++ */
++ ltq_clrbits(gpio_od, gpio_to_bit(gpio));
++ ltq_clrbits(gpio_altsel0, gpio_to_bit(gpio));
++ ltq_clrbits(gpio_altsel1, gpio_to_bit(gpio));
++
++ /* Switch to input */
++ ltq_clrbits(gpio_dir, gpio_to_bit(gpio));
++
++ return 0;
++}
++
++int gpio_direction_output(unsigned gpio, int value)
++{
++ unsigned port = gpio_to_port(gpio);
++ const void *gpio_od = &ltq_gpio_regs->ports[port].od;
++ const void *gpio_altsel0 = &ltq_gpio_regs->ports[port].altsel0;
++ const void *gpio_altsel1 = &ltq_gpio_regs->ports[port].altsel1;
++ const void *gpio_dir = &ltq_gpio_regs->ports[port].dir;
++ const void *gpio_out = &ltq_gpio_regs->ports[port].out;
++ u32 data = gpio_to_bit(gpio);
++
++ if (is_gpio_ssio(gpio)) {
++ data = ssio_gpio_to_bit(gpio);
++ if (value)
++ ltq_setbits(&ltq_ssio_regs->cpu0, data);
++ else
++ ltq_clrbits(&ltq_ssio_regs->cpu0, data);
++
++ return 0;
++ }
++
++ if (is_gpio_bank3(port)) {
++ gpio_od = &ltq_gpio3_regs->od;
++ gpio_altsel0 = &ltq_gpio3_regs->altsel0;
++ gpio_altsel1 = &ltq_gpio3_regs->altsel1;
++ gpio_dir = &ltq_gpio3_regs->dir;
++ gpio_out = &ltq_gpio3_regs->out;
++ }
++
++ /*
++ * Reset open drain and altsel configs to workaround improper
++ * reset values or unwanted modifications by BootROM
++ */
++ ltq_setbits(gpio_od, data);
++ ltq_clrbits(gpio_altsel0, data);
++ ltq_clrbits(gpio_altsel1, data);
++
++ if (value)
++ ltq_setbits(gpio_out, data);
++ else
++ ltq_clrbits(gpio_out, data);
++
++ /* Switch to output */
++ ltq_setbits(gpio_dir, data);
++
++ return 0;
++}
++
++int gpio_get_value(unsigned gpio)
++{
++ unsigned port = gpio_to_port(gpio);
++ const void *gpio_in = &ltq_gpio_regs->ports[port].in;
++ u32 data = gpio_to_bit(gpio);
++ u32 val;
++
++ if (is_gpio_ssio(gpio)) {
++ gpio_in = &ltq_ssio_regs->cpu0;
++ data = ssio_gpio_to_bit(gpio);
++ }
++
++ if (is_gpio_bank3(port))
++ gpio_in = &ltq_gpio3_regs->in;
++
++ val = ltq_readl(gpio_in);
++
++ return !!(val & data);
++}
++
++int gpio_set_value(unsigned gpio, int value)
++{
++ unsigned port = gpio_to_port(gpio);
++ const void *gpio_out = &ltq_gpio_regs->ports[port].out;
++ u32 data = gpio_to_bit(gpio);
++
++ if (is_gpio_ssio(gpio)) {
++ gpio_out = &ltq_ssio_regs->cpu0;
++ data = ssio_gpio_to_bit(gpio);
++ }
++
++ if (is_gpio_bank3(port))
++ gpio_out = &ltq_gpio3_regs->out;
++
++ if (value)
++ ltq_setbits(gpio_out, data);
++ else
++ ltq_clrbits(gpio_out, data);
++
++ return 0;
++}
++
++int gpio_set_altfunc(unsigned gpio, int altsel0, int altsel1, int dir)
++{
++ unsigned port = gpio_to_port(gpio);
++ const void *gpio_od = &ltq_gpio_regs->ports[port].od;
++ const void *gpio_altsel0 = &ltq_gpio_regs->ports[port].altsel0;
++ const void *gpio_altsel1 = &ltq_gpio_regs->ports[port].altsel1;
++ const void *gpio_dir = &ltq_gpio_regs->ports[port].dir;
++
++ if (is_gpio_ssio(gpio))
++ return 0;
++
++ if (is_gpio_bank3(port)) {
++ gpio_od = &ltq_gpio3_regs->od;
++ gpio_altsel0 = &ltq_gpio3_regs->altsel0;
++ gpio_altsel1 = &ltq_gpio3_regs->altsel1;
++ gpio_dir = &ltq_gpio3_regs->dir;
++ }
++
++ if (altsel0)
++ ltq_setbits(gpio_altsel0, gpio_to_bit(gpio));
++ else
++ ltq_clrbits(gpio_altsel0, gpio_to_bit(gpio));
++
++ if (altsel1)
++ ltq_setbits(gpio_altsel1, gpio_to_bit(gpio));
++ else
++ ltq_clrbits(gpio_altsel1, gpio_to_bit(gpio));
++
++ if (dir) {
++ ltq_setbits(gpio_od, gpio_to_bit(gpio));
++ ltq_setbits(gpio_dir, gpio_to_bit(gpio));
++ } else {
++ ltq_clrbits(gpio_od, gpio_to_bit(gpio));
++ ltq_clrbits(gpio_dir, gpio_to_bit(gpio));
++ }
++
++ return 0;
++}
++
++int gpio_set_opendrain(unsigned gpio, int od)
++{
++ unsigned port = gpio_to_port(gpio);
++ const void *gpio_od = &ltq_gpio_regs->ports[port].od;
++
++ if (is_gpio_ssio(gpio))
++ return 0;
++
++ if (is_gpio_bank3(port))
++ gpio_od = &ltq_gpio3_regs->od;
++
++ if (od)
++ ltq_setbits(gpio_od, gpio_to_bit(gpio));
++ else
++ ltq_clrbits(gpio_od, gpio_to_bit(gpio));
++
++ return 0;
++}
+--- a/drivers/mtd/cfi_flash.c
++++ b/drivers/mtd/cfi_flash.c
+@@ -177,6 +177,18 @@ u64 flash_read64(void *addr)__attribute_
+ #define flash_read64 __flash_read64
+ #endif
+
++static inline void *__flash_swap_addr(unsigned long addr)
++{
++ return (void *) addr;
++}
++
++#ifdef CONFIG_CFI_FLASH_USE_WEAK_ADDR_SWAP
++void *flash_swap_addr(unsigned long addr)
++ __attribute__((weak, alias("__flash_swap_addr")));
++#else
++#define flash_swap_addr __flash_swap_addr
++#endif
++
+ /*-----------------------------------------------------------------------
+ */
+ #if defined(CONFIG_ENV_IS_IN_FLASH) || defined(CONFIG_ENV_ADDR_REDUND) || (CONFIG_SYS_MONITOR_BASE >= CONFIG_SYS_FLASH_BASE)
+@@ -212,7 +224,7 @@ flash_map (flash_info_t * info, flash_se
+ {
+ unsigned int byte_offset = offset * info->portwidth;
+
+- return (void *)(info->start[sect] + byte_offset);
++ return flash_swap_addr(info->start[sect] + byte_offset);
+ }
+
+ static inline void flash_unmap(flash_info_t *info, flash_sect_t sect,
+--- a/drivers/mtd/nand/Makefile
++++ b/drivers/mtd/nand/Makefile
+@@ -67,6 +67,7 @@ COBJS-$(CONFIG_NAND_JZ4740) += jz4740_na
+ COBJS-$(CONFIG_NAND_KB9202) += kb9202_nand.o
+ COBJS-$(CONFIG_NAND_KIRKWOOD) += kirkwood_nand.o
+ COBJS-$(CONFIG_NAND_KMETER1) += kmeter1_nand.o
++COBJS-$(CONFIG_NAND_LANTIQ) += lantiq_nand.o
+ COBJS-$(CONFIG_NAND_MPC5121_NFC) += mpc5121_nfc.o
+ COBJS-$(CONFIG_NAND_MXC) += mxc_nand.o
+ COBJS-$(CONFIG_NAND_MXS) += mxs_nand.o
+--- /dev/null
++++ b/drivers/mtd/nand/lantiq_nand.c
+@@ -0,0 +1,127 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2012 Daniel Schwierzeck, daniel.schwierzeck@gmail.com
++ */
++
++#include <common.h>
++#include <linux/mtd/nand.h>
++#include <linux/compiler.h>
++#include <asm/arch/soc.h>
++#include <asm/arch/nand.h>
++#include <asm/lantiq/io.h>
++
++#define NAND_CON_ECC_ON (1 << 31)
++#define NAND_CON_LATCH_PRE (1 << 23)
++#define NAND_CON_LATCH_WP (1 << 22)
++#define NAND_CON_LATCH_SE (1 << 21)
++#define NAND_CON_LATCH_CS (1 << 20)
++#define NAND_CON_LATCH_CLE (1 << 19)
++#define NAND_CON_LATCH_ALE (1 << 18)
++#define NAND_CON_OUT_CS1 (1 << 10)
++#define NAND_CON_IN_CS1 (1 << 8)
++#define NAND_CON_PRE_P (1 << 7)
++#define NAND_CON_WP_P (1 << 6)
++#define NAND_CON_SE_P (1 << 5)
++#define NAND_CON_CS_P (1 << 4)
++#define NAND_CON_CLE_P (1 << 3)
++#define NAND_CON_ALE_P (1 << 2)
++#define NAND_CON_CSMUX (1 << 1)
++#define NAND_CON_NANDM (1 << 0)
++
++#define NAND_WAIT_WR_C (1 << 3)
++#define NAND_WAIT_RDBY (1 << 0)
++
++#define NAND_CMD_ALE (1 << 2)
++#define NAND_CMD_CLE (1 << 3)
++#define NAND_CMD_CS (1 << 4)
++#define NAND_CMD_SE (1 << 5)
++#define NAND_CMD_WP (1 << 6)
++#define NAND_CMD_PRE (1 << 7)
++
++struct ltq_nand_regs {
++ __be32 con; /* NAND controller control */
++ __be32 wait; /* NAND Flash Device RD/BY State */
++ __be32 ecc0; /* NAND Flash ECC Register 0 */
++ __be32 ecc_ac; /* NAND Flash ECC Register address counter */
++ __be32 ecc_cr; /* NAND Flash ECC Comparison */
++};
++
++static struct ltq_nand_regs *ltq_nand_regs =
++ (struct ltq_nand_regs *) CKSEG1ADDR(LTQ_EBU_NAND_BASE);
++
++static void ltq_nand_wait_ready(void)
++{
++ while ((ltq_readl(&ltq_nand_regs->wait) & NAND_WAIT_WR_C) == 0)
++ ;
++}
++
++static int ltq_nand_dev_ready(struct mtd_info *mtd)
++{
++ u32 data = ltq_readl(&ltq_nand_regs->wait);
++ return data & NAND_WAIT_RDBY;
++}
++
++static void ltq_nand_select_chip(struct mtd_info *mtd, int chip)
++{
++ if (chip == 0) {
++ ltq_setbits(&ltq_nand_regs->con, NAND_CON_NANDM);
++ ltq_setbits(&ltq_nand_regs->con, NAND_CON_LATCH_CS);
++ } else {
++ ltq_clrbits(&ltq_nand_regs->con, NAND_CON_LATCH_CS);
++ ltq_clrbits(&ltq_nand_regs->con, NAND_CON_NANDM);
++ }
++}
++
++static void ltq_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
++{
++ struct nand_chip *chip = mtd->priv;
++ unsigned long addr = (unsigned long) chip->IO_ADDR_W;
++
++ if (ctrl & NAND_CTRL_CHANGE) {
++ if (ctrl & NAND_ALE)
++ addr |= NAND_CMD_ALE;
++ else
++ addr &= ~NAND_CMD_ALE;
++
++ if (ctrl & NAND_CLE)
++ addr |= NAND_CMD_CLE;
++ else
++ addr &= ~NAND_CMD_CLE;
++
++ chip->IO_ADDR_W = (void __iomem *) addr;
++ }
++
++ if (cmd != NAND_CMD_NONE) {
++ writeb(cmd, chip->IO_ADDR_W);
++ ltq_nand_wait_ready();
++ }
++}
++
++int ltq_nand_init(struct nand_chip *nand)
++{
++ /* Enable NAND, set NAND CS to EBU CS1, enable EBU CS mux */
++ ltq_writel(&ltq_nand_regs->con, NAND_CON_OUT_CS1 | NAND_CON_IN_CS1 |
++ NAND_CON_PRE_P | NAND_CON_WP_P | NAND_CON_SE_P |
++ NAND_CON_CS_P | NAND_CON_CSMUX);
++
++ nand->dev_ready = ltq_nand_dev_ready;
++ nand->select_chip = ltq_nand_select_chip;
++ nand->cmd_ctrl = ltq_nand_cmd_ctrl;
++
++ nand->chip_delay = 30;
++ nand->options = 0;
++ nand->ecc.mode = NAND_ECC_SOFT;
++
++ /* Enable CS bit in address offset */
++ nand->IO_ADDR_R = nand->IO_ADDR_R + NAND_CMD_CS;
++ nand->IO_ADDR_W = nand->IO_ADDR_W + NAND_CMD_CS;
++
++ return 0;
++}
++
++__weak int board_nand_init(struct nand_chip *chip)
++{
++ return ltq_nand_init(chip);
++}
+--- a/drivers/net/Makefile
++++ b/drivers/net/Makefile
+@@ -51,6 +51,8 @@ COBJS-$(CONFIG_GRETH) += greth.o
+ COBJS-$(CONFIG_INCA_IP_SWITCH) += inca-ip_sw.o
+ COBJS-$(CONFIG_DRIVER_KS8695ETH) += ks8695eth.o
+ COBJS-$(CONFIG_LAN91C96) += lan91c96.o
++COBJS-$(CONFIG_LANTIQ_DANUBE_ETOP) += lantiq_danube_etop.o
++COBJS-$(CONFIG_LANTIQ_VRX200_SWITCH) += lantiq_vrx200_switch.o
+ COBJS-$(CONFIG_MACB) += macb.o
+ COBJS-$(CONFIG_MCFFEC) += mcffec.o mcfmii.o
+ COBJS-$(CONFIG_MPC5xxx_FEC) += mpc5xxx_fec.o
+--- /dev/null
++++ b/drivers/net/lantiq_danube_etop.c
+@@ -0,0 +1,411 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <common.h>
++#include <malloc.h>
++#include <netdev.h>
++#include <miiphy.h>
++#include <switch.h>
++#include <asm/lantiq/io.h>
++#include <asm/lantiq/eth.h>
++#include <asm/lantiq/pm.h>
++#include <asm/lantiq/reset.h>
++#include <asm/lantiq/dma.h>
++#include <asm/arch/soc.h>
++
++#define LTQ_PPE_ETOP_MDIO_ACC_RA (1 << 31)
++#define LTQ_PPE_ETOP_MDIO_CFG_UMM1 (1 << 2)
++#define LTQ_PPE_ETOP_MDIO_CFG_UMM0 (1 << 1)
++
++#define LTQ_PPE_ETOP_CFG_TCKINV1 (1 << 11)
++#define LTQ_PPE_ETOP_CFG_TCKINV0 (1 << 10)
++#define LTQ_PPE_ETOP_CFG_FEN1 (1 << 9)
++#define LTQ_PPE_ETOP_CFG_FEN0 (1 << 8)
++#define LTQ_PPE_ETOP_CFG_SEN1 (1 << 7)
++#define LTQ_PPE_ETOP_CFG_SEN0 (1 << 6)
++#define LTQ_PPE_ETOP_CFG_TURBO1 (1 << 5)
++#define LTQ_PPE_ETOP_CFG_REMII1 (1 << 4)
++#define LTQ_PPE_ETOP_CFG_OFF1 (1 << 3)
++#define LTQ_PPE_ETOP_CFG_TURBO0 (1 << 2)
++#define LTQ_PPE_ETOP_CFG_REMII0 (1 << 1)
++#define LTQ_PPE_ETOP_CFG_OFF0 (1 << 0)
++
++#define LTQ_PPE_ENET0_MAC_CFG_CGEN (1 << 11)
++#define LTQ_PPE_ENET0_MAC_CFG_DUPLEX (1 << 2)
++#define LTQ_PPE_ENET0_MAC_CFG_SPEED (1 << 1)
++#define LTQ_PPE_ENET0_MAC_CFG_LINK (1 << 0)
++
++#define LTQ_PPE_ENETS0_CFG_FTUC (1 << 28)
++
++#define LTQ_ETH_RX_BUFFER_CNT PKTBUFSRX
++#define LTQ_ETH_TX_BUFFER_CNT 8
++#define LTQ_ETH_RX_DATA_SIZE PKTSIZE_ALIGN
++#define LTQ_ETH_IP_ALIGN 2
++
++#define LTQ_MDIO_DRV_NAME "ltq-mdio"
++#define LTQ_ETH_DRV_NAME "ltq-eth"
++
++struct ltq_ppe_etop_regs {
++ u32 mdio_cfg; /* MDIO configuration */
++ u32 mdio_acc; /* MDIO access */
++ u32 cfg; /* ETOP configuration */
++ u32 ig_vlan_cos; /* IG VLAN priority CoS mapping */
++ u32 ig_dscp_cos3; /* IG DSCP CoS mapping 3 */
++ u32 ig_dscp_cos2; /* IG DSCP CoS mapping 2 */
++ u32 ig_dscp_cos1; /* IG DSCP CoS mapping 1 */
++ u32 ig_dscp_cos0; /* IG DSCP CoS mapping 0 */
++ u32 ig_plen_ctrl; /* IG frame length control */
++ u32 rsvd0[3];
++ u32 vpid; /* VLAN protocol ID */
++};
++
++struct ltq_ppe_enet_regs {
++ u32 mac_cfg; /* MAC configuration */
++ u32 rsvd0[3];
++ u32 ig_cfg; /* Ingress configuration */
++ u32 ig_pgcnt; /* Ingress buffer used page count */
++ u32 rsvd1;
++ u32 ig_buf_ctrl; /* Ingress buffer backpressure ctrl */
++ u32 cos_cfg; /* Classification configuration */
++ u32 ig_drop; /* Total ingress drop frames */
++ u32 ig_err; /* Total ingress error frames */
++ u32 mac_da0; /* Ingress MAC address 0 */
++ u32 mac_da1; /* Ingress MAC address 1 */
++ u32 rsvd2[22];
++ u32 pgcnt; /* Page counter */
++ u32 rsvd3;
++ u32 hf_ctrl; /* Half duplex control */
++ u32 tx_ctrl; /* Transmit control */
++ u32 rsvd4;
++ u32 vlcos0; /* VLAN insertion config CoS 0 */
++ u32 vlcos1; /* VLAN insertion config CoS 1 */
++ u32 vlcos2; /* VLAN insertion config CoS 2 */
++ u32 vlcos3; /* VLAN insertion config CoS 3 */
++ u32 eg_col; /* Total egress collision frames */
++ u32 eg_drop; /* Total egress drop frames */
++};
++
++struct ltq_eth_priv {
++ struct ltq_dma_device dma_dev;
++ struct mii_dev *bus;
++ struct eth_device *dev;
++ int rx_num;
++ int tx_num;
++};
++
++struct ltq_mdio_access {
++ union {
++ struct {
++ unsigned ra:1;
++ unsigned rw:1;
++ unsigned rsvd:4;
++ unsigned phya:5;
++ unsigned rega:5;
++ unsigned phyd:16;
++ } reg;
++ u32 val;
++ };
++};
++
++static struct ltq_ppe_etop_regs *ltq_ppe_etop_regs =
++ (struct ltq_ppe_etop_regs *) CKSEG1ADDR(LTQ_PPE_ETOP_BASE);
++
++static struct ltq_ppe_enet_regs *ltq_ppe_enet0_regs =
++ (struct ltq_ppe_enet_regs *) CKSEG1ADDR(LTQ_PPE_ENET0_BASE);
++
++static inline int ltq_mdio_poll(void)
++{
++ struct ltq_mdio_access acc;
++ unsigned cnt = 10000;
++
++ while (likely(cnt--)) {
++ acc.val = ltq_readl(&ltq_ppe_etop_regs->mdio_acc);
++ if (!acc.reg.ra)
++ return 0;
++ }
++
++ return 1;
++}
++
++static int ltq_mdio_read(struct mii_dev *bus, int addr, int dev_addr,
++ int regnum)
++{
++ struct ltq_mdio_access acc;
++ int ret;
++
++ acc.val = 0;
++ acc.reg.ra = 1;
++ acc.reg.rw = 1;
++ acc.reg.phya = addr;
++ acc.reg.rega = regnum;
++
++ ret = ltq_mdio_poll();
++ if (ret)
++ return ret;
++
++ ltq_writel(&ltq_ppe_etop_regs->mdio_acc, acc.val);
++
++ ret = ltq_mdio_poll();
++ if (ret)
++ return ret;
++
++ acc.val = ltq_readl(&ltq_ppe_etop_regs->mdio_acc);
++
++ return acc.reg.phyd;
++}
++
++static int ltq_mdio_write(struct mii_dev *bus, int addr, int dev_addr,
++ int regnum, u16 val)
++{
++ struct ltq_mdio_access acc;
++ int ret;
++
++ acc.val = 0;
++ acc.reg.ra = 1;
++ acc.reg.rw = 0;
++ acc.reg.phya = addr;
++ acc.reg.rega = regnum;
++ acc.reg.phyd = val;
++
++ ret = ltq_mdio_poll();
++ if (ret)
++ return ret;
++
++ ltq_writel(&ltq_ppe_etop_regs->mdio_acc, acc.val);
++
++ return 0;
++}
++
++static inline void ltq_eth_write_hwaddr(const struct eth_device *dev)
++{
++ u32 da0, da1;
++
++ da0 = (dev->enetaddr[0] << 24) + (dev->enetaddr[1] << 16) +
++ (dev->enetaddr[2] << 8) + dev->enetaddr[3];
++ da1 = (dev->enetaddr[4] << 24) + (dev->enetaddr[5] << 16);
++
++ ltq_writel(&ltq_ppe_enet0_regs->mac_da0, da0);
++ ltq_writel(&ltq_ppe_enet0_regs->mac_da1, da1);
++}
++
++static inline u8 *ltq_eth_rx_packet_align(int rx_num)
++{
++ u8 *packet = (u8 *) NetRxPackets[rx_num];
++
++ /*
++ * IP header needs
++ */
++ return packet + LTQ_ETH_IP_ALIGN;
++}
++
++static int ltq_eth_init(struct eth_device *dev, bd_t *bis)
++{
++ struct ltq_eth_priv *priv = dev->priv;
++ struct ltq_dma_device *dma_dev = &priv->dma_dev;
++ int i;
++
++ ltq_eth_write_hwaddr(dev);
++
++ for (i = 0; i < LTQ_ETH_RX_BUFFER_CNT; i++)
++ ltq_dma_rx_map(dma_dev, i, ltq_eth_rx_packet_align(i),
++ LTQ_ETH_RX_DATA_SIZE);
++
++ ltq_dma_enable(dma_dev);
++
++ priv->rx_num = 0;
++ priv->tx_num = 0;
++
++ return 0;
++}
++
++static void ltq_eth_halt(struct eth_device *dev)
++{
++ struct ltq_eth_priv *priv = dev->priv;
++ struct ltq_dma_device *dma_dev = &priv->dma_dev;
++
++ ltq_dma_reset(dma_dev);
++}
++
++static int ltq_eth_send(struct eth_device *dev, void *packet, int length)
++{
++ struct ltq_eth_priv *priv = dev->priv;
++ struct ltq_dma_device *dma_dev = &priv->dma_dev;
++ int err;
++
++ /* Minimum payload length w/ CRC is 60 bytes */
++ if (length < 60)
++ length = 60;
++
++ err = ltq_dma_tx_map(dma_dev, priv->tx_num, packet, length, 10);
++ if (err) {
++ puts("NET: timeout on waiting for TX descriptor\n");
++ return -1;
++ }
++
++ priv->tx_num = (priv->tx_num + 1) % LTQ_ETH_TX_BUFFER_CNT;
++
++ return err;
++}
++
++static int ltq_eth_recv(struct eth_device *dev)
++{
++ struct ltq_eth_priv *priv = dev->priv;
++ struct ltq_dma_device *dma_dev = &priv->dma_dev;
++ u8 *packet;
++ int len;
++
++ if (!ltq_dma_rx_poll(dma_dev, priv->rx_num))
++ return 0;
++
++#if 0
++ printf("%s: rx_num %d\n", __func__, priv->rx_num);
++#endif
++
++ len = ltq_dma_rx_length(dma_dev, priv->rx_num);
++ packet = ltq_eth_rx_packet_align(priv->rx_num);
++
++#if 0
++ printf("%s: received: packet %p, len %u, rx_num %d\n",
++ __func__, packet, len, priv->rx_num);
++#endif
++
++ if (len)
++ NetReceive(packet, len);
++
++ ltq_dma_rx_map(dma_dev, priv->rx_num, packet,
++ LTQ_ETH_RX_DATA_SIZE);
++
++ priv->rx_num = (priv->rx_num + 1) % LTQ_ETH_RX_BUFFER_CNT;
++
++ return 0;
++}
++
++static void ltq_eth_hw_init(const struct ltq_eth_port_config *port)
++{
++ u32 data;
++
++ /* Power up ethernet subsystems */
++ ltq_pm_enable(LTQ_PM_ETH);
++
++ /* Reset ethernet subsystems */
++ ltq_reset_once(LTQ_RESET_ETH, 1);
++
++ /* Disable MDIO auto-detection */
++ ltq_clrbits(&ltq_ppe_etop_regs->mdio_cfg, LTQ_PPE_ETOP_MDIO_CFG_UMM1 |
++ LTQ_PPE_ETOP_MDIO_CFG_UMM0);
++
++ /* Enable CRC generation, Full Duplex, 100Mbps, Link up */
++ ltq_writel(&ltq_ppe_enet0_regs->mac_cfg, LTQ_PPE_ENET0_MAC_CFG_CGEN |
++ LTQ_PPE_ENET0_MAC_CFG_DUPLEX |
++ LTQ_PPE_ENET0_MAC_CFG_SPEED |
++ LTQ_PPE_ENET0_MAC_CFG_LINK);
++
++ /* Reset ETOP cfg and disable all */
++ data = LTQ_PPE_ETOP_CFG_OFF0 | LTQ_PPE_ETOP_CFG_OFF1;
++
++ /* Enable ENET0, enable store and fetch */
++ data &= ~LTQ_PPE_ETOP_CFG_OFF0;
++ data |= LTQ_PPE_ETOP_CFG_SEN0 | LTQ_PPE_ETOP_CFG_FEN0;
++
++ if (port->phy_if == PHY_INTERFACE_MODE_RMII)
++ data |= LTQ_PPE_ETOP_CFG_REMII0;
++ else
++ data &= ~LTQ_PPE_ETOP_CFG_REMII0;
++
++ ltq_writel(&ltq_ppe_etop_regs->cfg, data);
++
++ /* Set allowed packet length from 64 bytes to 1518 bytes */
++ ltq_writel(&ltq_ppe_etop_regs->ig_plen_ctrl, (64 << 16) | 1518);
++
++ /* Enable filter for unicast packets */
++ ltq_setbits(&ltq_ppe_enet0_regs->ig_cfg, LTQ_PPE_ENETS0_CFG_FTUC);
++}
++
++int ltq_eth_initialize(const struct ltq_eth_board_config *board_config)
++{
++ struct eth_device *dev;
++ struct mii_dev *bus;
++ struct ltq_eth_priv *priv;
++ struct ltq_dma_device *dma_dev;
++ const struct ltq_eth_port_config *port = &board_config->ports[0];
++ struct phy_device *phy;
++ struct switch_device *sw;
++ int ret;
++
++ ltq_dma_init();
++ ltq_eth_hw_init(port);
++
++ dev = calloc(1, sizeof(*dev));
++ if (!dev)
++ return -1;
++
++ priv = calloc(1, sizeof(*priv));
++ if (!priv)
++ return -1;
++
++ bus = mdio_alloc();
++ if (!bus)
++ return -1;
++
++ sprintf(dev->name, LTQ_ETH_DRV_NAME);
++ dev->priv = priv;
++ dev->init = ltq_eth_init;
++ dev->halt = ltq_eth_halt;
++ dev->recv = ltq_eth_recv;
++ dev->send = ltq_eth_send;
++
++ sprintf(bus->name, LTQ_MDIO_DRV_NAME);
++ bus->read = ltq_mdio_read;
++ bus->write = ltq_mdio_write;
++ bus->priv = priv;
++
++ dma_dev = &priv->dma_dev;
++ dma_dev->port = 0;
++ dma_dev->rx_chan.chan_no = 6;
++ dma_dev->rx_chan.class = 3;
++ dma_dev->rx_chan.num_desc = LTQ_ETH_RX_BUFFER_CNT;
++ dma_dev->rx_endian_swap = LTQ_DMA_ENDIANESS_B3_B2_B1_B0;
++ dma_dev->rx_burst_len = LTQ_DMA_BURST_2WORDS;
++ dma_dev->tx_chan.chan_no = 7;
++ dma_dev->tx_chan.class = 3;
++ dma_dev->tx_chan.num_desc = LTQ_ETH_TX_BUFFER_CNT;
++ dma_dev->tx_endian_swap = LTQ_DMA_ENDIANESS_B3_B2_B1_B0;
++ dma_dev->tx_burst_len = LTQ_DMA_BURST_2WORDS;
++
++ priv->bus = bus;
++ priv->dev = dev;
++
++ ret = ltq_dma_register(dma_dev);
++ if (ret)
++ return ret;
++
++ ret = mdio_register(bus);
++ if (ret)
++ return ret;
++
++ ret = eth_register(dev);
++ if (ret)
++ return ret;
++
++ if (port->flags & LTQ_ETH_PORT_SWITCH) {
++ sw = switch_connect(bus);
++ if (!sw)
++ return -1;
++
++ switch_setup(sw);
++ }
++
++ if (port->flags & LTQ_ETH_PORT_PHY) {
++ phy = phy_connect(bus, port->phy_addr, dev, port->phy_if);
++ if (!phy)
++ return -1;
++
++ phy_config(phy);
++ }
++
++ return 0;
++}
+--- /dev/null
++++ b/drivers/net/lantiq_vrx200_switch.c
+@@ -0,0 +1,676 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2010-2011 Lantiq Deutschland GmbH
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#define DEBUG
++
++#include <common.h>
++#include <malloc.h>
++#include <netdev.h>
++#include <miiphy.h>
++#include <linux/compiler.h>
++#include <asm/gpio.h>
++#include <asm/processor.h>
++#include <asm/lantiq/io.h>
++#include <asm/lantiq/eth.h>
++#include <asm/lantiq/pm.h>
++#include <asm/lantiq/reset.h>
++#include <asm/lantiq/dma.h>
++#include <asm/arch/soc.h>
++#include <asm/arch/switch.h>
++
++#define LTQ_ETH_RX_BUFFER_CNT PKTBUFSRX
++#define LTQ_ETH_TX_BUFFER_CNT 8
++#define LTQ_ETH_RX_DATA_SIZE PKTSIZE_ALIGN
++#define LTQ_ETH_IP_ALIGN 2
++
++#define LTQ_MDIO_DRV_NAME "ltq-mdio"
++#define LTQ_ETH_DRV_NAME "ltq-eth"
++
++#define LTQ_ETHSW_MAX_GMAC 6
++#define LTQ_ETHSW_PMAC 6
++
++struct ltq_mdio_phy_addr_reg {
++ union {
++ struct {
++ unsigned rsvd:1;
++ unsigned lnkst:2; /* Link status control */
++ unsigned speed:2; /* Speed control */
++ unsigned fdup:2; /* Full duplex control */
++ unsigned fcontx:2; /* Flow control mode TX */
++ unsigned fconrx:2; /* Flow control mode RX */
++ unsigned addr:5; /* PHY address */
++ } bits;
++ u16 val;
++ };
++};
++
++enum ltq_mdio_phy_addr_lnkst {
++ LTQ_MDIO_PHY_ADDR_LNKST_AUTO = 0,
++ LTQ_MDIO_PHY_ADDR_LNKST_UP = 1,
++ LTQ_MDIO_PHY_ADDR_LNKST_DOWN = 2,
++};
++
++enum ltq_mdio_phy_addr_speed {
++ LTQ_MDIO_PHY_ADDR_SPEED_M10 = 0,
++ LTQ_MDIO_PHY_ADDR_SPEED_M100 = 1,
++ LTQ_MDIO_PHY_ADDR_SPEED_G1 = 2,
++ LTQ_MDIO_PHY_ADDR_SPEED_AUTO = 3,
++};
++
++enum ltq_mdio_phy_addr_fdup {
++ LTQ_MDIO_PHY_ADDR_FDUP_AUTO = 0,
++ LTQ_MDIO_PHY_ADDR_FDUP_ENABLE = 1,
++ LTQ_MDIO_PHY_ADDR_FDUP_DISABLE = 3,
++};
++
++enum ltq_mdio_phy_addr_fcon {
++ LTQ_MDIO_PHY_ADDR_FCON_AUTO = 0,
++ LTQ_MDIO_PHY_ADDR_FCON_ENABLE = 1,
++ LTQ_MDIO_PHY_ADDR_FCON_DISABLE = 3,
++};
++
++struct ltq_mii_mii_cfg_reg {
++ union {
++ struct {
++ unsigned res:1; /* Hardware reset */
++ unsigned en:1; /* xMII interface enable */
++ unsigned isol:1; /* xMII interface isolate */
++ unsigned ldclkdis:1; /* Link down clock disable */
++ unsigned rsvd:1;
++ unsigned crs:2; /* CRS sensitivity config */
++ unsigned rgmii_ibs:1; /* RGMII In Band status */
++ unsigned rmii:1; /* RMII ref clock direction */
++ unsigned miirate:3; /* xMII interface clock rate */
++ unsigned miimode:4; /* xMII interface mode */
++ } bits;
++ u16 val;
++ };
++};
++
++enum ltq_mii_mii_cfg_miirate {
++ LTQ_MII_MII_CFG_MIIRATE_M2P5 = 0,
++ LTQ_MII_MII_CFG_MIIRATE_M25 = 1,
++ LTQ_MII_MII_CFG_MIIRATE_M125 = 2,
++ LTQ_MII_MII_CFG_MIIRATE_M50 = 3,
++ LTQ_MII_MII_CFG_MIIRATE_AUTO = 4,
++};
++
++enum ltq_mii_mii_cfg_miimode {
++ LTQ_MII_MII_CFG_MIIMODE_MIIP = 0,
++ LTQ_MII_MII_CFG_MIIMODE_MIIM = 1,
++ LTQ_MII_MII_CFG_MIIMODE_RMIIP = 2,
++ LTQ_MII_MII_CFG_MIIMODE_RMIIM = 3,
++ LTQ_MII_MII_CFG_MIIMODE_RGMII = 4,
++};
++
++struct ltq_eth_priv {
++ struct ltq_dma_device dma_dev;
++ struct mii_dev *bus;
++ struct eth_device *dev;
++ struct phy_device *phymap[LTQ_ETHSW_MAX_GMAC];
++ int rx_num;
++ int tx_num;
++};
++
++static struct vr9_switch_regs *switch_regs =
++ (struct vr9_switch_regs *) CKSEG1ADDR(LTQ_SWITCH_BASE);
++
++static inline void vr9_switch_sync(void)
++{
++ __asm__("sync");
++}
++
++static inline int vr9_switch_mdio_is_busy(void)
++{
++ u32 mdio_ctrl = ltq_readl(&switch_regs->mdio.mdio_ctrl);
++
++ return mdio_ctrl & MDIO_CTRL_MBUSY;
++}
++
++static inline void vr9_switch_mdio_poll(void)
++{
++ while (vr9_switch_mdio_is_busy())
++ cpu_relax();
++}
++
++static int vr9_switch_mdio_read(struct mii_dev *bus, int phyad, int devad,
++ int regad)
++{
++ u32 mdio_ctrl;
++ int retval;
++
++ mdio_ctrl = MDIO_CTRL_OP_READ |
++ ((phyad << MDIO_CTRL_PHYAD_SHIFT) & MDIO_CTRL_PHYAD_MASK) |
++ (regad & MDIO_CTRL_REGAD_MASK);
++
++ vr9_switch_mdio_poll();
++ ltq_writel(&switch_regs->mdio.mdio_ctrl, mdio_ctrl);
++ vr9_switch_mdio_poll();
++ retval = ltq_readl(&switch_regs->mdio.mdio_read);
++
++ return retval;
++}
++
++static int vr9_switch_mdio_write(struct mii_dev *bus, int phyad, int devad,
++ int regad, u16 val)
++{
++ u32 mdio_ctrl;
++
++ mdio_ctrl = MDIO_CTRL_OP_WRITE |
++ ((phyad << MDIO_CTRL_PHYAD_SHIFT) & MDIO_CTRL_PHYAD_MASK) |
++ (regad & MDIO_CTRL_REGAD_MASK);
++
++ vr9_switch_mdio_poll();
++ ltq_writel(&switch_regs->mdio.mdio_write, val);
++ ltq_writel(&switch_regs->mdio.mdio_ctrl, mdio_ctrl);
++
++ return 0;
++}
++
++static void ltq_eth_gmac_update(struct phy_device *phydev, int num)
++{
++ struct ltq_mdio_phy_addr_reg phy_addr_reg;
++ struct ltq_mii_mii_cfg_reg mii_cfg_reg;
++
++ phy_addr_reg.val = ltq_readl(to_mdio_phyaddr(switch_regs, num));
++
++ switch (num) {
++ case 0:
++ case 1:
++ case 5:
++ mii_cfg_reg.val = ltq_readl(to_mii_miicfg(switch_regs, num));
++ break;
++ default:
++ mii_cfg_reg.val = 0;
++ break;
++ }
++
++ phy_addr_reg.bits.addr = phydev->addr;
++
++ if (phydev->link)
++ phy_addr_reg.bits.lnkst = LTQ_MDIO_PHY_ADDR_LNKST_UP;
++ else
++ phy_addr_reg.bits.lnkst = LTQ_MDIO_PHY_ADDR_LNKST_DOWN;
++
++ switch (phydev->speed) {
++ case SPEED_1000:
++ phy_addr_reg.bits.speed = LTQ_MDIO_PHY_ADDR_SPEED_G1;
++ mii_cfg_reg.bits.miirate = LTQ_MII_MII_CFG_MIIRATE_M125;
++ break;
++ case SPEED_100:
++ phy_addr_reg.bits.speed = LTQ_MDIO_PHY_ADDR_SPEED_M100;
++ switch (mii_cfg_reg.bits.miimode) {
++ case LTQ_MII_MII_CFG_MIIMODE_RMIIM:
++ case LTQ_MII_MII_CFG_MIIMODE_RMIIP:
++ mii_cfg_reg.bits.miirate = LTQ_MII_MII_CFG_MIIRATE_M50;
++ break;
++ default:
++ mii_cfg_reg.bits.miirate = LTQ_MII_MII_CFG_MIIRATE_M25;
++ break;
++ }
++ break;
++ default:
++ phy_addr_reg.bits.speed = LTQ_MDIO_PHY_ADDR_SPEED_M10;
++ mii_cfg_reg.bits.miirate = LTQ_MII_MII_CFG_MIIRATE_M2P5;
++ break;
++ }
++
++ if (phydev->duplex == DUPLEX_FULL)
++ phy_addr_reg.bits.fdup = LTQ_MDIO_PHY_ADDR_FDUP_ENABLE;
++ else
++ phy_addr_reg.bits.fdup = LTQ_MDIO_PHY_ADDR_FDUP_DISABLE;
++
++ ltq_writel(to_mdio_phyaddr(switch_regs, num), phy_addr_reg.val);
++
++ switch (num) {
++ case 0:
++ case 1:
++ case 5:
++ ltq_writel(to_mii_miicfg(switch_regs, num), mii_cfg_reg.val);
++ break;
++ default:
++ break;
++ }
++}
++
++static inline u8 *ltq_eth_rx_packet_align(int rx_num)
++{
++ u8 *packet = (u8 *) NetRxPackets[rx_num];
++
++ /*
++ * IP header needs
++ */
++ return packet + LTQ_ETH_IP_ALIGN;
++}
++
++static int ltq_eth_init(struct eth_device *dev, bd_t * bis)
++{
++ struct ltq_eth_priv *priv = dev->priv;
++ struct ltq_dma_device *dma_dev = &priv->dma_dev;
++ struct phy_device *phydev;
++ int i;
++
++ for (i = 0; i < LTQ_ETHSW_MAX_GMAC; i++) {
++ phydev = priv->phymap[i];
++ if (!phydev)
++ continue;
++
++ phy_startup(phydev);
++ ltq_eth_gmac_update(phydev, i);
++ }
++
++ for (i = 0; i < LTQ_ETH_RX_BUFFER_CNT; i++)
++ ltq_dma_rx_map(dma_dev, i, ltq_eth_rx_packet_align(i),
++ LTQ_ETH_RX_DATA_SIZE);
++
++ ltq_dma_enable(dma_dev);
++
++ priv->rx_num = 0;
++ priv->tx_num = 0;
++
++ return 0;
++}
++
++static void ltq_eth_halt(struct eth_device *dev)
++{
++ struct ltq_eth_priv *priv = dev->priv;
++ struct ltq_dma_device *dma_dev = &priv->dma_dev;
++ struct phy_device *phydev;
++ int i;
++
++ ltq_dma_reset(dma_dev);
++
++ for (i = 0; i < LTQ_ETHSW_MAX_GMAC; i++) {
++ phydev = priv->phymap[i];
++ if (!phydev)
++ continue;
++
++ phy_shutdown(phydev);
++ phydev->link = 0;
++ ltq_eth_gmac_update(phydev, i);
++ }
++}
++
++static int ltq_eth_send(struct eth_device *dev, void *packet, int length)
++{
++ struct ltq_eth_priv *priv = dev->priv;
++ struct ltq_dma_device *dma_dev = &priv->dma_dev;
++
++#if 0
++ printf("%s: packet %p, len %d\n", __func__, packet, length);
++#endif
++
++ ltq_dma_tx_map(dma_dev, priv->tx_num, packet, length, 10);
++ priv->tx_num = (priv->tx_num + 1) % LTQ_ETH_TX_BUFFER_CNT;
++
++ return 0;
++}
++
++static int ltq_eth_recv(struct eth_device *dev)
++{
++ struct ltq_eth_priv *priv = dev->priv;
++ struct ltq_dma_device *dma_dev = &priv->dma_dev;
++ u8 *packet;
++ int len;
++
++ if (!ltq_dma_rx_poll(dma_dev, priv->rx_num))
++ return 0;
++
++#if 0
++ printf("%s: rx_num %d\n", __func__, priv->rx_num);
++#endif
++
++ len = ltq_dma_rx_length(dma_dev, priv->rx_num);
++ packet = ltq_eth_rx_packet_align(priv->rx_num);
++
++#if 0
++ printf("%s: received: packet %p, len %u, rx_num %d\n",
++ __func__, packet, len, priv->rx_num);
++#endif
++
++ if (len)
++ NetReceive(packet, len);
++
++ ltq_dma_rx_map(dma_dev, priv->rx_num, packet,
++ LTQ_ETH_RX_DATA_SIZE);
++
++ priv->rx_num = (priv->rx_num + 1) % LTQ_ETH_RX_BUFFER_CNT;
++
++ return 0;
++}
++
++static void ltq_eth_gmac_init(int num)
++{
++ struct ltq_mdio_phy_addr_reg phy_addr_reg;
++ struct ltq_mii_mii_cfg_reg mii_cfg_reg;
++
++ /* Reset PHY status to link down */
++ phy_addr_reg.val = ltq_readl(to_mdio_phyaddr(switch_regs, num));
++ phy_addr_reg.bits.addr = num;
++ phy_addr_reg.bits.lnkst = LTQ_MDIO_PHY_ADDR_LNKST_DOWN;
++ phy_addr_reg.bits.speed = LTQ_MDIO_PHY_ADDR_SPEED_M10;
++ phy_addr_reg.bits.fdup = LTQ_MDIO_PHY_ADDR_FDUP_DISABLE;
++ ltq_writel(to_mdio_phyaddr(switch_regs, num), phy_addr_reg.val);
++
++ /* Reset and disable MII interface */
++ switch (num) {
++ case 0:
++ case 1:
++ case 5:
++ mii_cfg_reg.val = ltq_readl(to_mii_miicfg(switch_regs, num));
++ mii_cfg_reg.bits.en = 0;
++ mii_cfg_reg.bits.res = 1;
++ mii_cfg_reg.bits.miirate = LTQ_MII_MII_CFG_MIIRATE_M2P5;
++ ltq_writel(to_mii_miicfg(switch_regs, num), mii_cfg_reg.val);
++ break;
++ default:
++ break;
++ }
++
++ /*
++ * - enable frame checksum generation
++ * - enable padding of short frames
++ * - disable flow control
++ */
++ ltq_writel(to_mac_ctrl(switch_regs, num, 0),
++ MAC_CTRL0_PADEN | MAC_CTRL0_FCS | MAC_CTRL0_FCON_NONE);
++
++ vr9_switch_sync();
++}
++
++static void ltq_eth_pmac_init(void)
++{
++ /*
++ * WAR: buffer congestion:
++ * - shorten preambel to 1 byte
++ * - set TX IPG to 7 bytes
++ */
++#if 1
++ ltq_writel(to_mac_ctrl(switch_regs, LTQ_ETHSW_PMAC, 1),
++ MAC_CTRL1_SHORTPRE | 7);
++#endif
++
++ /*
++ * WAR: systematical concept weakness ACM bug
++ * - set maximum number of used buffer segments to 254
++ * - soft-reset BM FSQM
++ */
++#if 1
++ ltq_writel(&switch_regs->bm.core.fsqm_gctrl, 253);
++ ltq_setbits(&switch_regs->bm.core.gctrl, BM_GCTRL_F_SRES);
++ ltq_clrbits(&switch_regs->bm.core.gctrl, BM_GCTRL_F_SRES);
++#endif
++
++ /*
++ * WAR: switch MAC drop bug
++ */
++#if 1
++ ltq_writel(to_pce_tbl_key(switch_regs, 0), 0xf);
++ ltq_writel(to_pce_tbl_value(switch_regs, 0), 0x40);
++ ltq_writel(&switch_regs->pce.core.tbl_addr, 0x3);
++ ltq_writel(&switch_regs->pce.core.tbl_ctrl, 0x902f);
++#endif
++
++ /*
++ * Configure frame header control:
++ * - enable flow control
++ * - enable CRC check for packets from DMA to PMAC
++ * - remove special tag from packets from PMAC to DMA
++ * - add CRC for packets from DMA to PMAC
++ */
++ ltq_writel(&switch_regs->pmac.hd_ctl, /*PMAC_HD_CTL_FC |*/
++ PMAC_HD_CTL_CCRC | PMAC_HD_CTL_RST | PMAC_HD_CTL_AC |
++ PMAC_HD_CTL_RC);
++
++#if 1
++ ltq_writel(&switch_regs->pmac.rx_ipg, 0x8b);
++#endif
++
++ /*
++ * - enable frame checksum generation
++ * - enable padding of short frames
++ * - disable flow control
++ */
++ ltq_writel(to_mac_ctrl(switch_regs, LTQ_ETHSW_PMAC, 0),
++ MAC_CTRL0_PADEN | MAC_CTRL0_FCS | MAC_CTRL0_FCON_NONE);
++
++ vr9_switch_sync();
++}
++
++static void ltq_eth_hw_init(void)
++{
++ int i;
++
++ /* Power up ethernet and switch subsystems */
++ ltq_pm_enable(LTQ_PM_ETH);
++
++ /* Reset ethernet and switch subsystems */
++#if 0
++ ltq_reset_once(LTQ_RESET_ETH, 10);
++#endif
++
++ /* Enable switch macro */
++ ltq_setbits(&switch_regs->mdio.glob_ctrl, MDIO_GLOB_CTRL_SE);
++
++ /* Disable MDIO auto-polling for all ports */
++ ltq_writel(&switch_regs->mdio.mdc_cfg_0, 0);
++
++ /*
++ * Enable and set MDIO management clock to 2.5 MHz. This is the
++ * maximum clock for FE PHYs.
++ * Formula for clock is:
++ *
++ * 50 MHz
++ * x = ----------- - 1
++ * 2 * f_MDC
++ */
++ ltq_writel(&switch_regs->mdio.mdc_cfg_1, MDIO_MDC_CFG1_RES |
++ MDIO_MDC_CFG1_MCEN | 5);
++
++ vr9_switch_sync();
++
++ /* Init MAC connected to CPU */
++ ltq_eth_pmac_init();
++
++ /* Init MACs connected to external MII interfaces */
++ for (i = 0; i < LTQ_ETHSW_MAX_GMAC; i++)
++ ltq_eth_gmac_init(i);
++}
++
++static void ltq_eth_port_config(struct ltq_eth_priv *priv,
++ const struct ltq_eth_port_config *port)
++{
++ struct ltq_mii_mii_cfg_reg mii_cfg_reg;
++ struct phy_device *phydev;
++ int setup_gpio = 0;
++
++ switch (port->num) {
++ case 0: /* xMII0 */
++ case 1: /* xMII1 */
++ mii_cfg_reg.val = ltq_readl(to_mii_miicfg(switch_regs,
++ port->num));
++ mii_cfg_reg.bits.en = port->flags ? 1 : 0;
++
++ switch (port->phy_if) {
++ case PHY_INTERFACE_MODE_MII:
++ if (port->flags & LTQ_ETH_PORT_PHY)
++ /* MII MAC mode, connected to external PHY */
++ mii_cfg_reg.bits.miimode =
++ LTQ_MII_MII_CFG_MIIMODE_MIIM;
++ else
++ /* MII PHY mode, connected to external MAC */
++ mii_cfg_reg.bits.miimode =
++ LTQ_MII_MII_CFG_MIIMODE_MIIP;
++ setup_gpio = 1;
++ break;
++ case PHY_INTERFACE_MODE_RMII:
++ if (port->flags & LTQ_ETH_PORT_PHY)
++ /* RMII MAC mode, connected to external PHY */
++ mii_cfg_reg.bits.miimode =
++ LTQ_MII_MII_CFG_MIIMODE_RMIIM;
++ else
++ /* RMII PHY mode, connected to external MAC */
++ mii_cfg_reg.bits.miimode =
++ LTQ_MII_MII_CFG_MIIMODE_RMIIP;
++ setup_gpio = 1;
++ break;
++ case PHY_INTERFACE_MODE_RGMII:
++ /* RGMII MAC mode, connected to external PHY */
++ mii_cfg_reg.bits.miimode =
++ LTQ_MII_MII_CFG_MIIMODE_RGMII;
++ setup_gpio = 1;
++
++ /* RGMII clock delays */
++ ltq_writel(to_mii_pcdu(switch_regs, port->num),
++ port->rgmii_rx_delay << PCDU_RXDLY_SHIFT |
++ port->rgmii_tx_delay);
++ break;
++ default:
++ break;
++ }
++
++ ltq_writel(to_mii_miicfg(switch_regs, port->num),
++ mii_cfg_reg.val);
++ break;
++ case 2: /* internal GPHY0 */
++ case 3: /* internal GPHY0 */
++ case 4: /* internal GPHY1 */
++ switch (port->phy_if) {
++ case PHY_INTERFACE_MODE_MII:
++ case PHY_INTERFACE_MODE_GMII:
++ setup_gpio = 1;
++ break;
++ default:
++ break;
++ }
++ break;
++ case 5: /* internal GPHY1 or xMII2 */
++ mii_cfg_reg.val = ltq_readl(to_mii_miicfg(switch_regs,
++ port->num));
++ mii_cfg_reg.bits.en = port->flags ? 1 : 0;
++
++ switch (port->phy_if) {
++ case PHY_INTERFACE_MODE_MII:
++ /* MII MAC mode, connected to internal GPHY */
++ mii_cfg_reg.bits.miimode =
++ LTQ_MII_MII_CFG_MIIMODE_MIIM;
++ setup_gpio = 1;
++ break;
++ case PHY_INTERFACE_MODE_RGMII:
++ /* RGMII MAC mode, connected to external PHY */
++ mii_cfg_reg.bits.miimode =
++ LTQ_MII_MII_CFG_MIIMODE_RGMII;
++ setup_gpio = 1;
++
++ /* RGMII clock delays */
++ ltq_writel(to_mii_pcdu(switch_regs, port->num),
++ port->rgmii_rx_delay << PCDU_RXDLY_SHIFT |
++ port->rgmii_tx_delay);
++ break;
++ default:
++ break;
++ }
++
++ ltq_writel(to_mii_miicfg(switch_regs, port->num),
++ mii_cfg_reg.val);
++ break;
++ default:
++ break;
++ }
++
++ /* Setup GPIOs for MII with external PHYs/MACs */
++ if (setup_gpio) {
++ /* MII/MDIO */
++ gpio_set_altfunc(42, GPIO_ALTSEL_SET, GPIO_ALTSEL_CLR,
++ GPIO_DIR_OUT);
++ /* MII/MDC */
++ gpio_set_altfunc(43, GPIO_ALTSEL_SET, GPIO_ALTSEL_CLR,
++ GPIO_DIR_OUT);
++ }
++
++ /* Connect to internal/external PHYs */
++ if (port->flags & LTQ_ETH_PORT_PHY) {
++ phydev = phy_connect(priv->bus, port->phy_addr, priv->dev,
++ port->phy_if);
++ if (phydev)
++ phy_config(phydev);
++
++ priv->phymap[port->num] = phydev;
++ }
++}
++
++int ltq_eth_initialize(const struct ltq_eth_board_config *board_config)
++{
++ struct eth_device *dev;
++ struct mii_dev *bus;
++ struct ltq_eth_priv *priv;
++ struct ltq_dma_device *dma_dev;
++ int i, ret;
++
++ build_check_vr9_registers();
++
++ ltq_dma_init();
++ ltq_eth_hw_init();
++
++ dev = calloc(1, sizeof(struct eth_device));
++ if (!dev)
++ return -1;
++
++ priv = calloc(1, sizeof(struct ltq_eth_priv));
++ if (!priv)
++ return -1;
++
++ bus = mdio_alloc();
++ if (!bus)
++ return -1;
++
++ sprintf(dev->name, LTQ_ETH_DRV_NAME);
++ dev->priv = priv;
++ dev->init = ltq_eth_init;
++ dev->halt = ltq_eth_halt;
++ dev->recv = ltq_eth_recv;
++ dev->send = ltq_eth_send;
++
++ sprintf(bus->name, LTQ_MDIO_DRV_NAME);
++ bus->read = vr9_switch_mdio_read;
++ bus->write = vr9_switch_mdio_write;
++ bus->priv = priv;
++
++ dma_dev = &priv->dma_dev;
++ dma_dev->port = 0;
++ dma_dev->rx_chan.chan_no = 0;
++ dma_dev->rx_chan.class = 0;
++ dma_dev->rx_chan.num_desc = LTQ_ETH_RX_BUFFER_CNT;
++ dma_dev->rx_endian_swap = LTQ_DMA_ENDIANESS_B3_B2_B1_B0;
++ dma_dev->rx_burst_len = LTQ_DMA_BURST_2WORDS;
++ dma_dev->tx_chan.chan_no = 1;
++ dma_dev->tx_chan.class = 0;
++ dma_dev->tx_chan.num_desc = LTQ_ETH_TX_BUFFER_CNT;
++ dma_dev->tx_endian_swap = LTQ_DMA_ENDIANESS_B3_B2_B1_B0;
++ dma_dev->tx_burst_len = LTQ_DMA_BURST_2WORDS;
++
++ priv->bus = bus;
++ priv->dev = dev;
++
++ ret = ltq_dma_register(dma_dev);
++ if (ret)
++ return -1;
++
++ ret = mdio_register(bus);
++ if (ret)
++ return -1;
++
++ ret = eth_register(dev);
++ if (ret)
++ return -1;
++
++ for (i = 0; i < board_config->num_ports; i++)
++ ltq_eth_port_config(priv, &board_config->ports[i]);
++
++ return 0;
++}
+--- a/drivers/net/phy/Makefile
++++ b/drivers/net/phy/Makefile
+@@ -34,6 +34,7 @@ COBJS-$(CONFIG_PHYLIB_10G) += generic_10
+ COBJS-$(CONFIG_PHY_ATHEROS) += atheros.o
+ COBJS-$(CONFIG_PHY_BROADCOM) += broadcom.o
+ COBJS-$(CONFIG_PHY_DAVICOM) += davicom.o
++COBJS-$(CONFIG_PHY_LANTIQ) += lantiq.o
+ COBJS-$(CONFIG_PHY_LXT) += lxt.o
+ COBJS-$(CONFIG_PHY_MARVELL) += marvell.o
+ COBJS-$(CONFIG_PHY_MICREL) += micrel.o
+--- /dev/null
++++ b/drivers/net/phy/lantiq.c
+@@ -0,0 +1,239 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#define DEBUG
++
++#include <common.h>
++#include <miiphy.h>
++
++#define ADVERTIZE_MPD (1 << 10)
++
++DECLARE_GLOBAL_DATA_PTR;
++
++/*
++ * Update link status.
++ *
++ * Based on genphy_update_link in phylib.c
++ */
++static int ltq_phy_update_link(struct phy_device *phydev)
++{
++ unsigned int mii_reg;
++
++ mii_reg = phy_read(phydev, MDIO_DEVAD_NONE, MII_BMSR);
++
++ /*
++ * If we already saw the link up, and it hasn't gone down, then
++ * we don't need to wait for autoneg again
++ */
++ if (phydev->link && mii_reg & BMSR_LSTATUS)
++ return 0;
++
++ if ((mii_reg & BMSR_ANEGCAPABLE) && !(mii_reg & BMSR_ANEGCOMPLETE)) {
++ phydev->link = 0;
++ return 0;
++ } else {
++ /* Read the link a second time to clear the latched state */
++ mii_reg = phy_read(phydev, MDIO_DEVAD_NONE, MII_BMSR);
++
++ if (mii_reg & BMSR_LSTATUS)
++ phydev->link = 1;
++ else
++ phydev->link = 0;
++ }
++
++ return 0;
++}
++
++/*
++ * Update speed and duplex.
++ *
++ * Based on genphy_parse_link in phylib.c
++ */
++static int ltq_phy_parse_link(struct phy_device *phydev)
++{
++ unsigned int mii_reg;
++
++ mii_reg = phy_read(phydev, MDIO_DEVAD_NONE, MII_BMSR);
++
++ /* We're using autonegotiation */
++ if (mii_reg & BMSR_ANEGCAPABLE) {
++ u32 lpa = 0;
++ u32 gblpa = 0;
++
++ /* Check for gigabit capability */
++ if (mii_reg & BMSR_ERCAP) {
++ /* We want a list of states supported by
++ * both PHYs in the link
++ */
++ gblpa = phy_read(phydev, MDIO_DEVAD_NONE, MII_STAT1000);
++ gblpa &= phy_read(phydev,
++ MDIO_DEVAD_NONE, MII_CTRL1000) << 2;
++ }
++
++ /* Set the baseline so we only have to set them
++ * if they're different
++ */
++ phydev->speed = SPEED_10;
++ phydev->duplex = DUPLEX_HALF;
++
++ /* Check the gigabit fields */
++ if (gblpa & (PHY_1000BTSR_1000FD | PHY_1000BTSR_1000HD)) {
++ phydev->speed = SPEED_1000;
++
++ if (gblpa & PHY_1000BTSR_1000FD)
++ phydev->duplex = DUPLEX_FULL;
++
++ /* We're done! */
++ return 0;
++ }
++
++ lpa = phy_read(phydev, MDIO_DEVAD_NONE, MII_ADVERTISE);
++ lpa &= phy_read(phydev, MDIO_DEVAD_NONE, MII_LPA);
++
++ if (lpa & (LPA_100FULL | LPA_100HALF)) {
++ phydev->speed = SPEED_100;
++
++ if (lpa & LPA_100FULL)
++ phydev->duplex = DUPLEX_FULL;
++
++ } else if (lpa & LPA_10FULL)
++ phydev->duplex = DUPLEX_FULL;
++ } else {
++ u32 bmcr = phy_read(phydev, MDIO_DEVAD_NONE, MII_BMCR);
++
++ phydev->speed = SPEED_10;
++ phydev->duplex = DUPLEX_HALF;
++
++ if (bmcr & BMCR_FULLDPLX)
++ phydev->duplex = DUPLEX_FULL;
++
++ if (bmcr & BMCR_SPEED1000)
++ phydev->speed = SPEED_1000;
++ else if (bmcr & BMCR_SPEED100)
++ phydev->speed = SPEED_100;
++ }
++
++ return 0;
++}
++
++static int ltq_phy_config(struct phy_device *phydev)
++{
++ u16 val;
++
++ /* Advertise as Multi-port device */
++ val = phy_read(phydev, MDIO_DEVAD_NONE, MII_CTRL1000);
++ val |= ADVERTIZE_MPD;
++ phy_write(phydev, MDIO_DEVAD_NONE, MII_CTRL1000, val);
++
++ genphy_config_aneg(phydev);
++
++ return 0;
++}
++
++static int ltq_phy_startup(struct phy_device *phydev)
++{
++ /*
++ * Update PHY status immediately without any delays as genphy_startup
++ * does because VRX200 switch needs to be configured dependent
++ * on this information.
++ */
++ ltq_phy_update_link(phydev);
++ ltq_phy_parse_link(phydev);
++
++ debug("ltq_phy: addr %d, link %d, speed %d, duplex %d\n",
++ phydev->addr, phydev->link, phydev->speed, phydev->duplex);
++
++ return 0;
++}
++
++static struct phy_driver xrx_11g_13_driver = {
++ .name = "Lantiq XWAY XRX PHY11G v1.3 and earlier",
++ .uid = 0x030260D0,
++ .mask = 0xFFFFFFF0,
++ .features = PHY_GBIT_FEATURES,
++ .config = ltq_phy_config,
++ .startup = ltq_phy_startup,
++ .shutdown = genphy_shutdown,
++};
++
++static struct phy_driver xrx_11g_14_driver = {
++ .name = "Lantiq XWAY XRX PHY11G v1.4 and later",
++ .uid = 0xd565a408,
++ .mask = 0xFFFFFFF8,
++ .features = PHY_GBIT_FEATURES,
++ .config = ltq_phy_config,
++ .startup = ltq_phy_startup,
++ .shutdown = genphy_shutdown,
++};
++
++static struct phy_driver xrx_22f_14_driver = {
++ .name = "Lantiq XWAY XRX PHY22F v1.4 and later",
++ .uid = 0xd565a418,
++ .mask = 0xFFFFFFF8,
++ .features = PHY_BASIC_FEATURES,
++ .config = ltq_phy_config,
++ .startup = ltq_phy_startup,
++ .shutdown = genphy_shutdown,
++};
++
++static struct phy_driver pef7071_driver = {
++ .name = "Lantiq XWAY PEF7071",
++ .uid = 0xd565a400,
++ .mask = 0xFFFFFFFF,
++ .features = PHY_GBIT_FEATURES,
++ .config = ltq_phy_config,
++ .startup = ltq_phy_startup,
++ .shutdown = genphy_shutdown,
++};
++
++static struct phy_driver xrx_genphy_driver = {
++ .name = "Generic PHY at Lantiq XWAY XRX switch",
++ .uid = 0,
++ .mask = 0,
++ .features = 0,
++ .config = genphy_config,
++ .startup = ltq_phy_startup,
++ .shutdown = genphy_shutdown,
++};
++
++int phy_lantiq_init(void)
++{
++#ifdef CONFIG_NEEDS_MANUAL_RELOC
++ xrx_11g_13_driver.config = ltq_phy_config;
++ xrx_11g_13_driver.startup = ltq_phy_startup;
++ xrx_11g_13_driver.shutdown = genphy_shutdown;
++ xrx_11g_13_driver.name += gd->reloc_off;
++
++ xrx_11g_14_driver.config = ltq_phy_config;
++ xrx_11g_14_driver.startup = ltq_phy_startup;
++ xrx_11g_14_driver.shutdown = genphy_shutdown;
++ xrx_11g_14_driver.name += gd->reloc_off;
++
++ xrx_22f_14_driver.config = ltq_phy_config;
++ xrx_22f_14_driver.startup = ltq_phy_startup;
++ xrx_22f_14_driver.shutdown = genphy_shutdown;
++ xrx_22f_14_driver.name += gd->reloc_off;
++
++ pef7071_driver.config = ltq_phy_config;
++ pef7071_driver.startup = ltq_phy_startup;
++ pef7071_driver.shutdown = genphy_shutdown;
++ pef7071_driver.name += gd->reloc_off;
++
++ xrx_genphy_driver.config = genphy_config;
++ xrx_genphy_driver.startup = ltq_phy_startup;
++ xrx_genphy_driver.shutdown = genphy_shutdown;
++ xrx_genphy_driver.name += gd->reloc_off;
++#endif
++
++ phy_register(&xrx_11g_13_driver);
++ phy_register(&xrx_11g_14_driver);
++ phy_register(&xrx_22f_14_driver);
++ phy_register(&pef7071_driver);
++ phy_register(&xrx_genphy_driver);
++
++ return 0;
++}
+--- a/drivers/net/phy/phy.c
++++ b/drivers/net/phy/phy.c
+@@ -32,6 +32,8 @@
+ #include <phy.h>
+ #include <errno.h>
+
++DECLARE_GLOBAL_DATA_PTR;
++
+ /* Generic PHY support and helper functions */
+
+ /**
+@@ -420,6 +422,16 @@ static LIST_HEAD(phy_drivers);
+
+ int phy_init(void)
+ {
++#ifdef CONFIG_NEEDS_MANUAL_RELOC
++ INIT_LIST_HEAD(&phy_drivers);
++
++ genphy_driver.config = genphy_config;
++ genphy_driver.startup = genphy_startup;
++ genphy_driver.shutdown = genphy_shutdown;
++
++ genphy_driver.name += gd->reloc_off;
++#endif
++
+ #ifdef CONFIG_PHY_ATHEROS
+ phy_atheros_init();
+ #endif
+@@ -429,6 +441,9 @@ int phy_init(void)
+ #ifdef CONFIG_PHY_DAVICOM
+ phy_davicom_init();
+ #endif
++#ifdef CONFIG_PHY_LANTIQ
++ phy_lantiq_init();
++#endif
+ #ifdef CONFIG_PHY_LXT
+ phy_lxt_init();
+ #endif
+--- a/drivers/serial/Makefile
++++ b/drivers/serial/Makefile
+@@ -42,6 +42,7 @@ COBJS-$(CONFIG_SYS_NS16550_SERIAL) += se
+ COBJS-$(CONFIG_IMX_SERIAL) += serial_imx.o
+ COBJS-$(CONFIG_IXP_SERIAL) += serial_ixp.o
+ COBJS-$(CONFIG_KS8695_SERIAL) += serial_ks8695.o
++COBJS-$(CONFIG_LANTIQ_SERIAL) += serial_lantiq.o
+ COBJS-$(CONFIG_MAX3100_SERIAL) += serial_max3100.o
+ COBJS-$(CONFIG_MXC_UART) += serial_mxc.o
+ COBJS-$(CONFIG_PL010_SERIAL) += serial_pl01x.o
+--- /dev/null
++++ b/drivers/serial/serial_lantiq.c
+@@ -0,0 +1,264 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2010 Thomas Langer <thomas.langer@lantiq.com>
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <common.h>
++#include <serial.h>
++#include <asm/errno.h>
++#include <asm/arch/soc.h>
++#include <asm/lantiq/clk.h>
++#include <asm/lantiq/io.h>
++
++#if CONFIG_CONSOLE_ASC == 0
++#define LTQ_ASC_BASE LTQ_ASC0_BASE
++#else
++#define LTQ_ASC_BASE LTQ_ASC1_BASE
++#endif
++
++#define LTQ_ASC_ID_TXFS_SHIFT 24
++#define LTQ_ASC_ID_TXFS_MASK (0x3F << LTQ_ASC_ID_TXFS_SHIFT)
++#define LTQ_ASC_ID_RXFS_SHIFT 16
++#define LTQ_ASC_ID_RXFS_MASK (0x3F << LTQ_ASC_ID_RXFS_SHIFT)
++
++#define LTQ_ASC_MCON_R (1 << 15)
++#define LTQ_ASC_MCON_FDE (1 << 9)
++
++#define LTQ_ASC_WHBSTATE_SETREN (1 << 1)
++#define LTQ_ASC_WHBSTATE_CLRREN (1 << 0)
++
++#define LTQ_ASC_RXFCON_RXFITL_SHIFT 8
++#define LTQ_ASC_RXFCON_RXFITL_MASK (0x3F << LTQ_ASC_RXFCON_RXFITL_SHIFT)
++#define LTQ_ASC_RXFCON_RXFITL_RXFFLU (1 << 1)
++#define LTQ_ASC_RXFCON_RXFITL_RXFEN (1 << 0)
++
++#define LTQ_ASC_TXFCON_TXFITL_SHIFT 8
++#define LTQ_ASC_TXFCON_TXFITL_MASK (0x3F << LTQ_ASC_TXFCON_TXFITL_SHIFT)
++#define LTQ_ASC_TXFCON_TXFITL_TXFFLU (1 << 1)
++#define LTQ_ASC_TXFCON_TXFITL_TXFEN (1 << 0)
++
++#define LTQ_ASC_FSTAT_TXFREE_SHIFT 24
++#define LTQ_ASC_FSTAT_TXFREE_MASK (0x3F << LTQ_ASC_FSTAT_TXFREE_SHIFT)
++#define LTQ_ASC_FSTAT_RXFREE_SHIFT 16
++#define LTQ_ASC_FSTAT_RXFREE_MASK (0x3F << LTQ_ASC_FSTAT_RXFREE_SHIFT)
++#define LTQ_ASC_FSTAT_TXFFL_SHIFT 8
++#define LTQ_ASC_FSTAT_TXFFL_MASK (0x3F << LTQ_ASC_FSTAT_TXFFL_SHIFT)
++#define LTQ_ASC_FSTAT_RXFFL_MASK 0x3F
++
++#ifdef __BIG_ENDIAN
++#define LTQ_ASC_RBUF_OFFSET 3
++#define LTQ_ASC_TBUF_OFFSET 3
++#else
++#define LTQ_ASC_RBUF_OFFSET 0
++#define LTQ_ASC_TBUF_OFFSET 0
++#endif
++
++struct ltq_asc_regs {
++ u32 clc;
++ u32 pisel;
++ u32 id;
++ u32 rsvd0;
++ u32 mcon;
++ u32 state;
++ u32 whbstate;
++ u32 rsvd1;
++ u8 tbuf[4];
++ u8 rbuf[4];
++ u32 rsvd2[2];
++ u32 abcon;
++ u32 abstat;
++ u32 whbabcon;
++ u32 whbabstat;
++ u32 rxfcon;
++ u32 txfcon;
++ u32 fstat;
++ u32 rsvd3;
++ u32 bg;
++ u32 bg_timer;
++ u32 fdv;
++ u32 pmw;
++ u32 modcon;
++ u32 modstat;
++};
++
++DECLARE_GLOBAL_DATA_PTR;
++
++static struct ltq_asc_regs *ltq_asc_regs =
++ (struct ltq_asc_regs *) CKSEG1ADDR(LTQ_ASC_BASE);
++
++static int ltq_serial_init(void)
++{
++ /* Set clock divider for normal run mode to 1 and enable module */
++ ltq_writel(&ltq_asc_regs->clc, 0x100);
++
++ /* Reset MCON register */
++ ltq_writel(&ltq_asc_regs->mcon, 0);
++
++ /* Use Port A as receiver input */
++ ltq_writel(&ltq_asc_regs->pisel, 0);
++
++ /* Enable and flush RX/TX FIFOs */
++ ltq_setbits(&ltq_asc_regs->rxfcon,
++ LTQ_ASC_RXFCON_RXFITL_RXFFLU | LTQ_ASC_RXFCON_RXFITL_RXFEN);
++ ltq_setbits(&ltq_asc_regs->txfcon,
++ LTQ_ASC_TXFCON_TXFITL_TXFFLU | LTQ_ASC_TXFCON_TXFITL_TXFEN);
++
++ serial_setbrg();
++
++ /* Disable error flags, enable receiver */
++ ltq_writel(&ltq_asc_regs->whbstate, LTQ_ASC_WHBSTATE_SETREN);
++
++ return 0;
++}
++
++/*
++ * fdv asc_clk
++ * Baudrate = ----- * -------------
++ * 512 16 * (bg + 1)
++ */
++static void ltq_serial_calc_br_fdv(unsigned long asc_clk,
++ unsigned long baudrate, u16 *fdv,
++ u16 *bg)
++{
++ const u32 c = asc_clk / (16 * 512);
++ u32 diff1, diff2;
++ u32 bg_calc, br_calc, i;
++
++ diff1 = baudrate;
++ for (i = 512; i > 0; i--) {
++ /* Calc bg for current fdv value */
++ bg_calc = i * c / baudrate;
++
++ /* Impossible baudrate */
++ if (!bg_calc)
++ return;
++
++ /*
++ * Calc diff to target baudrate dependent on current
++ * bg and fdv values
++ */
++ br_calc = i * c / bg_calc;
++ if (br_calc > baudrate)
++ diff2 = br_calc - baudrate;
++ else
++ diff2 = baudrate - br_calc;
++
++ /* Perfect values found */
++ if (diff2 == 0) {
++ *fdv = i;
++ *bg = bg_calc - 1;
++ return;
++ }
++
++ if (diff2 < diff1) {
++ *fdv = i;
++ *bg = bg_calc - 1;
++ diff1 = diff2;
++ }
++ }
++}
++
++static void ltq_serial_setbrg(void)
++{
++ unsigned long asc_clk, baudrate;
++ u16 bg = 0;
++ u16 fdv = 511;
++
++ /* ASC clock is same as FPI clock with CLC.RMS = 1 */
++ asc_clk = ltq_get_bus_clock();
++ baudrate = gd->baudrate;
++
++ /* Calculate FDV and BG values */
++ ltq_serial_calc_br_fdv(asc_clk, baudrate, &fdv, &bg);
++
++ /* Disable baudrate generator */
++ ltq_clrbits(&ltq_asc_regs->mcon, LTQ_ASC_MCON_R);
++
++ /* Enable fractional divider */
++ ltq_setbits(&ltq_asc_regs->mcon, LTQ_ASC_MCON_FDE);
++
++ /* Set fdv and bg values */
++ ltq_writel(&ltq_asc_regs->fdv, fdv);
++ ltq_writel(&ltq_asc_regs->bg, bg);
++
++ /* Enable baudrate generator */
++ ltq_setbits(&ltq_asc_regs->mcon, LTQ_ASC_MCON_R);
++}
++
++static unsigned int ltq_serial_tx_free(void)
++{
++ unsigned int txfree;
++
++ txfree = (ltq_readl(&ltq_asc_regs->fstat) &
++ LTQ_ASC_FSTAT_TXFREE_MASK) >>
++ LTQ_ASC_FSTAT_TXFREE_SHIFT;
++
++ return txfree;
++}
++
++static unsigned int ltq_serial_rx_fill(void)
++{
++ unsigned int rxffl;
++
++ rxffl = ltq_readl(&ltq_asc_regs->fstat) & LTQ_ASC_FSTAT_RXFFL_MASK;
++
++ return rxffl;
++}
++
++static void ltq_serial_tx(const char c)
++{
++ ltq_writeb(&ltq_asc_regs->tbuf[LTQ_ASC_TBUF_OFFSET], c);
++}
++
++static u8 ltq_serial_rx(void)
++{
++ return ltq_readb(&ltq_asc_regs->rbuf[LTQ_ASC_RBUF_OFFSET]);
++}
++
++static void ltq_serial_putc(const char c)
++{
++ if (c == '\n')
++ ltq_serial_putc('\r');
++
++ while (!ltq_serial_tx_free())
++ ;
++
++ ltq_serial_tx(c);
++}
++
++static int ltq_serial_getc(void)
++{
++ while (!ltq_serial_rx_fill())
++ ;
++
++ return ltq_serial_rx();
++}
++
++static int ltq_serial_tstc(void)
++{
++ return (0 != ltq_serial_rx_fill());
++}
++
++static struct serial_device ltq_serial_drv = {
++ .name = "ixp_serial",
++ .start = ltq_serial_init,
++ .stop = NULL,
++ .setbrg = ltq_serial_setbrg,
++ .putc = ltq_serial_putc,
++ .puts = default_serial_puts,
++ .getc = ltq_serial_getc,
++ .tstc = ltq_serial_tstc,
++};
++
++void ixp_serial_initialize(void)
++{
++ serial_register(&ltq_serial_drv);
++}
++
++__weak struct serial_device *default_serial_console(void)
++{
++ return &ltq_serial_drv;
++}
+--- a/drivers/spi/Makefile
++++ b/drivers/spi/Makefile
+@@ -36,6 +36,7 @@ COBJS-$(CONFIG_CF_QSPI) += cf_qspi.o
+ COBJS-$(CONFIG_DAVINCI_SPI) += davinci_spi.o
+ COBJS-$(CONFIG_EXYNOS_SPI) += exynos_spi.o
+ COBJS-$(CONFIG_KIRKWOOD_SPI) += kirkwood_spi.o
++COBJS-$(CONFIG_LANTIQ_SPI) += lantiq_spi.o
+ COBJS-$(CONFIG_MPC52XX_SPI) += mpc52xx_spi.o
+ COBJS-$(CONFIG_MPC8XXX_SPI) += mpc8xxx_spi.o
+ COBJS-$(CONFIG_MXC_SPI) += mxc_spi.o
+--- /dev/null
++++ b/drivers/spi/lantiq_spi.c
+@@ -0,0 +1,476 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <common.h>
++#include <spi.h>
++#include <malloc.h>
++#include <watchdog.h>
++#include <asm/gpio.h>
++#include <asm/lantiq/io.h>
++#include <asm/lantiq/clk.h>
++#include <asm/lantiq/pm.h>
++#include <asm/arch/soc.h>
++
++#define LTQ_SPI_CLC_RMC_SHIFT 8
++#define LTQ_SPI_CLC_RMC_MASK (0xFF << LTQ_SPI_CLC_RMC_SHIFT)
++#define LTQ_SPI_CLC_DISS (1 << 1)
++#define LTQ_SPI_CLC_DISR 1
++
++#define LTQ_SPI_ID_TXFS_SHIFT 24
++#define LTQ_SPI_ID_TXFS_MASK (0x3F << LTQ_SPI_ID_TXFS_SHIFT)
++#define LTQ_SPI_ID_RXFS_SHIFT 16
++#define LTQ_SPI_ID_RXFS_MASK (0x3F << LTQ_SPI_ID_RXFS_SHIFT)
++
++#define LTQ_SPI_CON_ENBV (1 << 22)
++#define LTQ_SPI_CON_BM_SHIFT 16
++#define LTQ_SPI_CON_BM_MASK (0x1F << LTQ_SPI_CON_BM_SHIFT)
++#define LTQ_SPI_CON_LB (1 << 7)
++#define LTQ_SPI_CON_PO (1 << 6)
++#define LTQ_SPI_CON_PH (1 << 5)
++#define LTQ_SPI_CON_HB (1 << 4)
++#define LTQ_SPI_CON_RXOFF (1 << 1)
++#define LTQ_SPI_CON_TXOFF 1
++
++#define LTQ_SPI_STAT_RXBV_SHIFT 28
++#define LTQ_SPI_STAT_RXBV_MASK (0x7 << LTQ_SPI_STAT_RXBV_SHIFT)
++#define LTQ_SPI_STAT_BSY (1 << 13)
++
++#define LTQ_SPI_WHBSTATE_SETMS (1 << 3)
++#define LTQ_SPI_WHBSTATE_CLRMS (1 << 2)
++#define LTQ_SPI_WHBSTATE_SETEN (1 << 1)
++#define LTQ_SPI_WHBSTATE_CLREN 1
++
++#define LTQ_SPI_TXFCON_TXFLU (1 << 1)
++#define LTQ_SPI_TXFCON_TXFEN 1
++
++#define LTQ_SPI_RXFCON_RXFLU (1 << 1)
++#define LTQ_SPI_RXFCON_RXFEN 1
++
++#define LTQ_SPI_FSTAT_RXFFL_MASK 0x3f
++#define LTQ_SPI_FSTAT_TXFFL_SHIFT 8
++#define LTQ_SPI_FSTAT_TXFFL_MASK (0x3f << LTQ_SPI_FSTAT_TXFFL_SHIFT)
++
++#define LTQ_SPI_RXREQ_RXCNT_MASK 0xFFFF
++#define LTQ_SPI_RXCNT_TODO_MASK 0xFFFF
++
++#define LTQ_SPI_GPIO_DIN 16
++#define LTQ_SPI_GPIO_DOUT 17
++#define LTQ_SPI_GPIO_CLK 18
++
++struct ltq_spi_regs {
++ u32 clc; /* Clock control */
++ u32 pisel; /* Port input select */
++ u32 id; /* Identification */
++ u32 rsvd0;
++ u32 con; /* Control */
++ u32 stat; /* Status */
++ u32 whbstate; /* Write HW modified state */
++ u32 rsvd1;
++ u32 tb; /* Transmit buffer */
++ u32 rb; /* Receive buffer */
++ u32 rsvd2[2];
++ u32 rxfcon; /* Recevie FIFO control */
++ u32 txfcon; /* Transmit FIFO control */
++ u32 fstat; /* FIFO status */
++ u32 rsvd3;
++ u32 brt; /* Baudrate timer */
++ u32 brstat; /* Baudrate timer status */
++ u32 rsvd4[6];
++ u32 sfcon; /* Serial frame control */
++ u32 sfstat; /* Serial frame status */
++ u32 rsvd5[2];
++ u32 gpocon; /* General purpose output control */
++ u32 gpostat; /* General purpose output status */
++ u32 fgpo; /* Force general purpose output */
++ u32 rsvd6;
++ u32 rxreq; /* Receive request */
++ u32 rxcnt; /* Receive count */
++ u32 rsvd7[25];
++ u32 dmacon; /* DMA control */
++};
++
++struct ltq_spi_slave {
++ struct spi_slave slave;
++ unsigned int max_hz;
++ unsigned int mode;
++ unsigned int len;
++ unsigned int brt;
++ unsigned int tx_cnt;
++ unsigned int rx_cnt;
++ unsigned int rx_req;
++ const u8 *tx;
++ u8 *rx;
++ u8 txfs;
++ u8 rxfs;
++};
++
++static inline struct ltq_spi_slave *to_ltq_spi_slave(struct spi_slave *slave)
++{
++ return container_of(slave, struct ltq_spi_slave, slave);
++}
++
++#ifdef CONFIG_SPL_BUILD
++/*
++ * We do not have or want malloc in a SPI flash SPL.
++ * Neither we have to support multiple SPI slaves. Thus we put the
++ * SPI slave context in BSS for SPL builds.
++ */
++static struct ltq_spi_slave ltq_spi_slave;
++
++static inline struct ltq_spi_slave *ltq_spi_slave_alloc(void)
++{
++ return &ltq_spi_slave;
++}
++
++static inline void ltq_spi_slave_free(struct spi_slave *slave)
++{
++}
++#else
++static inline struct ltq_spi_slave *ltq_spi_slave_alloc(void)
++{
++ return malloc(sizeof(struct ltq_spi_slave));
++}
++
++static inline void ltq_spi_slave_free(struct spi_slave *slave)
++{
++ struct ltq_spi_slave *sl;
++
++ if (slave) {
++ sl = to_ltq_spi_slave(slave);
++ free(sl);
++ }
++}
++#endif
++
++static struct ltq_spi_regs *ltq_spi_regs =
++ (struct ltq_spi_regs *) CKSEG1ADDR(LTQ_SPI_BASE);
++
++void spi_init(void)
++{
++ /* Power up SPI subsystem */
++ ltq_pm_enable(LTQ_PM_SPI);
++
++ /* Enable module and set clock divider to 1 */
++ ltq_writel(&ltq_spi_regs->clc, 1 << LTQ_SPI_CLC_RMC_SHIFT);
++
++ /* SPI/DIN input */
++ gpio_set_altfunc(16, GPIO_ALTSEL_SET, GPIO_ALTSEL_CLR, GPIO_DIR_IN);
++ /* SPI/DOUT output */
++ gpio_set_altfunc(17, GPIO_ALTSEL_SET, GPIO_ALTSEL_CLR, GPIO_DIR_OUT);
++ /* SPI/CLK output */
++ gpio_set_altfunc(18, GPIO_ALTSEL_SET, GPIO_ALTSEL_CLR, GPIO_DIR_OUT);
++}
++
++static inline u32 ltq_spi_calc_br(unsigned int max_hz)
++{
++ u32 speed_hz, spi_hz;
++ u16 brt;
++
++ /* SPI module clock is same as FPI bus clock */
++ spi_hz = ltq_get_bus_clock();
++
++ /*
++ * f_SPI
++ * baudrate = --------------
++ * 2 * (BR + 1)
++ */
++ spi_hz /= 2;
++
++ for (brt = 0; brt < 0xFFFF; brt++) {
++ speed_hz = spi_hz / (brt + 1);
++ if (speed_hz <= max_hz)
++ break;
++ }
++
++ return brt;
++}
++
++struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
++ unsigned int max_hz, unsigned int mode)
++{
++ u32 id;
++ struct ltq_spi_slave *sl;
++
++ if (!spi_cs_is_valid(bus, cs))
++ return NULL;
++
++ sl = ltq_spi_slave_alloc();
++ if (!sl)
++ return NULL;
++
++ /* Read HW capabilities */
++ id = ltq_readl(&ltq_spi_regs->id);
++ sl->txfs = (id & LTQ_SPI_ID_TXFS_MASK) >> LTQ_SPI_ID_TXFS_SHIFT;
++ sl->rxfs = (id & LTQ_SPI_ID_RXFS_MASK) >> LTQ_SPI_ID_RXFS_SHIFT;
++
++ sl->slave.bus = bus;
++ sl->slave.cs = cs;
++ sl->max_hz = max_hz;
++ sl->mode = mode;
++
++ sl->brt = ltq_spi_calc_br(max_hz);
++
++ return &sl->slave;
++}
++
++void spi_free_slave(struct spi_slave *slave)
++{
++ ltq_spi_slave_free(slave);
++}
++
++static int ltq_spi_wait_ready(struct ltq_spi_slave *sl)
++{
++ u32 stat;
++ const unsigned long timeout = 20000;
++ unsigned long timebase;
++
++ timebase = get_timer(0);
++
++ do {
++ WATCHDOG_RESET();
++
++ stat = ltq_readl(&ltq_spi_regs->stat);
++
++ if (!(stat & LTQ_SPI_STAT_BSY))
++ return 0;
++ } while (get_timer(timebase) < timeout);
++
++ return 1;
++}
++
++int spi_claim_bus(struct spi_slave *slave)
++{
++ struct ltq_spi_slave *sl = to_ltq_spi_slave(slave);
++ u32 con;
++ int ret;
++
++ /* Put module in configuration mode */
++ ltq_setbits(&ltq_spi_regs->whbstate, LTQ_SPI_WHBSTATE_CLREN);
++
++ /* Enable and flush RX and TX FIFOs */
++ ltq_setbits(&ltq_spi_regs->txfcon,
++ LTQ_SPI_TXFCON_TXFLU | LTQ_SPI_TXFCON_TXFEN);
++ ltq_setbits(&ltq_spi_regs->rxfcon,
++ LTQ_SPI_RXFCON_RXFLU | LTQ_SPI_RXFCON_RXFEN);
++
++ ret = ltq_spi_wait_ready(sl);
++ if (ret)
++ return ret;
++
++ /* Set baudrate */
++ ltq_writel(&ltq_spi_regs->brt, sl->brt);
++
++ /*
++ * Disable byte valid control (ENBV = 0) and
++ * set data width to 8 bit (BM = 7)
++ */
++ con = (7 << LTQ_SPI_CON_BM_SHIFT);
++
++ /* Disable transmitter and receiver */
++ con |= (LTQ_SPI_CON_RXOFF | LTQ_SPI_CON_TXOFF);
++
++ /* Set SPI mode
++ * Mapping: Mode CPOL CPHA CON.PO CON.PH
++ * 0 0 0 0 1
++ * 1 0 1 0 0
++ * 2 1 0 1 1
++ * 3 1 1 1 0
++ */
++ if (sl->mode & SPI_CPHA)
++ con &= ~LTQ_SPI_CON_PH;
++ else
++ con |= LTQ_SPI_CON_PH;
++
++ if (sl->mode & SPI_CPOL)
++ con |= LTQ_SPI_CON_PO;
++ else
++ con &= ~LTQ_SPI_CON_PO;
++
++ /* Set heading control */
++ if (sl->mode & SPI_LSB_FIRST)
++ con &= ~LTQ_SPI_CON_HB;
++ else
++ con |= LTQ_SPI_CON_HB;
++
++ /* Set loopback control */
++ if (sl->mode & SPI_LOOP)
++ con |= LTQ_SPI_CON_LB;
++ else
++ con &= ~LTQ_SPI_CON_LB;
++
++ ltq_writel(&ltq_spi_regs->con, con);
++
++ /* Set SPI master mode and enable SPI */
++ ltq_setbits(&ltq_spi_regs->whbstate,
++ LTQ_SPI_WHBSTATE_SETEN | LTQ_SPI_WHBSTATE_SETMS);
++
++ return 0;
++}
++
++void spi_release_bus(struct spi_slave *slave)
++{
++ /* Put module in configuration mode */
++ ltq_setbits(&ltq_spi_regs->whbstate, LTQ_SPI_WHBSTATE_CLREN);
++
++ /* Flush RX and TX FIFOs */
++ ltq_setbits(&ltq_spi_regs->txfcon, LTQ_SPI_TXFCON_TXFLU);
++ ltq_setbits(&ltq_spi_regs->rxfcon, LTQ_SPI_RXFCON_RXFLU);
++}
++
++static inline void ltq_spi_txfifo_write(struct ltq_spi_slave *sl)
++{
++ u32 fstat, tb;
++ u16 fifo_space;
++
++ fstat = ltq_readl(&ltq_spi_regs->fstat);
++ fifo_space = sl->txfs - ((fstat & LTQ_SPI_FSTAT_TXFFL_MASK) >>
++ LTQ_SPI_FSTAT_TXFFL_SHIFT);
++
++ while (sl->tx_cnt < sl->len && fifo_space) {
++ tb = *sl->tx++;
++ ltq_writel(&ltq_spi_regs->tb, tb);
++ fifo_space--;
++ sl->tx_cnt++;
++ }
++}
++
++static inline void ltq_spi_rx_request(struct ltq_spi_slave *sl)
++{
++ u32 rxreq, rxreq_max;
++
++ /*
++ * In RX-only mode the serial clock is activated only after writing
++ * the expected amount of RX bytes into RXREQ register.
++ * To avoid receive overflows at high clocks it is better to request
++ * only the amount of bytes that fits into all FIFOs. This value
++ * depends on the FIFO size implemented in hardware.
++ */
++ rxreq = sl->len - sl->rx_cnt;
++ rxreq_max = sl->rxfs << 2;
++ rxreq = min(rxreq_max, rxreq);
++
++ if (!sl->rx_req && rxreq && sl->rx_cnt < sl->len) {
++ ltq_writel(&ltq_spi_regs->rxreq, rxreq);
++ sl->rx_req = rxreq;
++ }
++}
++
++static void ltq_spi_rxfifo_read(struct ltq_spi_slave *sl)
++{
++ u32 fstat, data, *rx32;
++ u16 fifo_fill;
++ u8 rxbv, shift, *rx8;
++
++ /* Determine how much FIFOs are filled with RX data */
++ fstat = ltq_readl(&ltq_spi_regs->fstat);
++ fifo_fill = fstat & LTQ_SPI_FSTAT_RXFFL_MASK;
++
++ /*
++ * The 32 bit FIFO is always used completely independent from the
++ * bits_per_word value. Thus four bytes have to be read at once
++ * per FIFO.
++ */
++ rx32 = (u32 *) sl->rx;
++ while (sl->len - sl->rx_cnt >= 4 && fifo_fill) {
++ data = ltq_readl(&ltq_spi_regs->rb);
++ *rx32++ = data;
++ sl->rx_cnt += 4;
++ sl->rx_req -= 4;
++ sl->rx += 4;
++ fifo_fill--;
++ }
++
++ /*
++ * If there are remaining bytes, read byte count from STAT.RXBV
++ * register and read the data byte-wise.
++ */
++ while (fifo_fill && sl->rx_cnt < sl->len) {
++ fstat = ltq_readl(&ltq_spi_regs->stat);
++ rxbv = (fstat & LTQ_SPI_STAT_RXBV_MASK) >>
++ LTQ_SPI_STAT_RXBV_SHIFT;
++
++ if (!rxbv)
++ break;
++
++ data = ltq_readl(&ltq_spi_regs->rb);
++
++ shift = (rxbv - 1) * 8;
++ rx8 = sl->rx;
++
++ while (rxbv) {
++ *rx8++ = (data >> shift) & 0xFF;
++ rxbv--;
++ shift -= 8;
++ sl->rx_cnt++;
++ sl->rx_req--;
++ sl->rx++;
++ }
++
++ fifo_fill--;
++ }
++}
++
++int spi_xfer(struct spi_slave *slave, unsigned int bitlen,
++ const void *dout, void *din, unsigned long flags)
++{
++ struct ltq_spi_slave *sl = to_ltq_spi_slave(slave);
++ int ret;
++
++ if (bitlen % 8)
++ return 1;
++
++ if (!bitlen) {
++ ret = 0;
++ goto done;
++ }
++
++ sl->len = bitlen / 8;
++ sl->tx = dout;
++ sl->rx = din;
++ sl->tx_cnt = 0;
++ sl->rx_cnt = 0;
++ sl->rx_req = 0;
++
++ if (flags & SPI_XFER_BEGIN)
++ spi_cs_activate(slave);
++
++ /* Enable transmitter */
++ if (sl->tx)
++ ltq_clrbits(&ltq_spi_regs->con, LTQ_SPI_CON_TXOFF);
++
++ /* Enable receiver */
++ if (sl->rx)
++ ltq_clrbits(&ltq_spi_regs->con, LTQ_SPI_CON_RXOFF);
++
++ if (sl->tx)
++ ltq_spi_txfifo_write(sl);
++ else if (sl->rx)
++ ltq_spi_rx_request(sl);
++
++ while (sl->tx_cnt != sl->len && sl->rx_cnt != sl->len) {
++ if (sl->rx) {
++ ltq_spi_rxfifo_read(sl);
++
++ if (sl->tx)
++ ltq_spi_txfifo_write(sl);
++ else
++ ltq_spi_rx_request(sl);
++ } else if (sl->tx)
++ ltq_spi_txfifo_write(sl);
++ }
++
++ ret = ltq_spi_wait_ready(sl);
++
++done:
++ /* Disable transmitter and receiver */
++ ltq_setbits(&ltq_spi_regs->con, LTQ_SPI_CON_TXOFF | LTQ_SPI_CON_RXOFF);
++
++ if (flags & SPI_XFER_END)
++ spi_cs_deactivate(slave);
++
++ return ret;
++}
+--- /dev/null
++++ b/include/configs/easy50712.h
+@@ -0,0 +1,78 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#ifndef __CONFIG_H
++#define __CONFIG_H
++
++#define CONFIG_MACH_TYPE "EASY50712"
++#define CONFIG_IDENT_STRING " "CONFIG_MACH_TYPE
++#define CONFIG_BOARD_NAME "Lantiq EASY50712 Danube Reference Board"
++
++/* Configure SoC */
++#define CONFIG_LTQ_SUPPORT_UART /* Enable ASC and UART */
++
++#define CONFIG_LTQ_SUPPORT_ETHERNET /* Enable ethernet */
++
++#define CONFIG_LTQ_SUPPORT_NOR_FLASH /* Have a parallel NOR flash */
++
++#define CONFIG_LTQ_SUPPORT_SPI_FLASH
++#define CONFIG_SPI_FLASH_ATMEL /* Have an AT45DB321D serial flash */
++
++#define CONFIG_LTQ_SUPPORT_SPL_NOR_FLASH /* Build NOR flash SPL */
++
++#define CONFIG_LTQ_SPL_COMP_LZO
++#define CONFIG_LTQ_SPL_CONSOLE
++
++/* Switch devices */
++#define CONFIG_SWITCH_MULTI
++#define CONFIG_SWITCH_ADM6996I
++
++/* Environment */
++#define CONFIG_ENV_SPI_BUS 0
++#define CONFIG_ENV_SPI_CS 2
++#define CONFIG_ENV_SPI_MAX_HZ 20000000
++#define CONFIG_ENV_SPI_MODE 0
++
++#if defined(CONFIG_SYS_BOOT_NOR)
++#define CONFIG_ENV_IS_IN_FLASH
++#define CONFIG_ENV_OVERWRITE
++#define CONFIG_ENV_OFFSET (256 * 1024)
++#define CONFIG_ENV_SECT_SIZE (64 * 1024)
++#elif defined(CONFIG_SYS_BOOT_NORSPL)
++#define CONFIG_ENV_IS_IN_FLASH
++#define CONFIG_ENV_OVERWRITE
++#define CONFIG_ENV_OFFSET (128 * 1024)
++#define CONFIG_ENV_SECT_SIZE (64 * 1024)
++#else
++#define CONFIG_ENV_IS_NOWHERE
++#endif
++
++#define CONFIG_ENV_SIZE (8 * 1024)
++
++#define CONFIG_LOADADDR CONFIG_SYS_LOAD_ADDR
++
++/* Console */
++#define CONFIG_LTQ_ADVANCED_CONSOLE
++#define CONFIG_BAUDRATE 115200
++#define CONFIG_CONSOLE_ASC 1
++#define CONFIG_CONSOLE_DEV "ttyLTQ1"
++
++/* Commands */
++#define CONFIG_CMD_PING
++
++/* Pull in default board configs for Lantiq XWAY Danube */
++#include <asm/lantiq/config.h>
++#include <asm/arch/config.h>
++
++#define CONFIG_ENV_UPDATE_UBOOT_NOR \
++ "update-uboot-nor=run load-uboot-norspl-lzo write-uboot-nor\0"
++
++#define CONFIG_EXTRA_ENV_SETTINGS \
++ CONFIG_ENV_LANTIQ_DEFAULTS \
++ CONFIG_ENV_UPDATE_UBOOT_NOR
++
++#endif /* __CONFIG_H */
+--- /dev/null
++++ b/include/configs/easy80920.h
+@@ -0,0 +1,93 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#ifndef __CONFIG_H
++#define __CONFIG_H
++
++#define CONFIG_MACH_TYPE "EASY80920"
++#define CONFIG_IDENT_STRING " "CONFIG_MACH_TYPE
++#define CONFIG_BOARD_NAME "Lantiq EASY80920 VRX200 Family Board"
++
++/* Configure SoC */
++#define CONFIG_LTQ_SUPPORT_UART /* Enable ASC and UART */
++
++#define CONFIG_LTQ_SUPPORT_ETHERNET /* Enable ethernet */
++
++#define CONFIG_LTQ_SUPPORT_NOR_FLASH /* Have a parallel NOR flash */
++
++#define CONFIG_LTQ_SUPPORT_SPI_FLASH
++#define CONFIG_SPI_FLASH_MACRONIX /* Have a MX29LV620 serial flash */
++
++#define CONFIG_LTQ_SUPPORT_NAND_FLASH
++
++#define CONFIG_LTQ_SUPPORT_SPL_SPI_FLASH /* Build SPI flash SPL */
++#define CONFIG_SPL_SPI_BUS 0
++#define CONFIG_SPL_SPI_CS 4
++#define CONFIG_SPL_SPI_MAX_HZ 25000000
++#define CONFIG_SPL_SPI_MODE 0
++
++#define CONFIG_LTQ_SUPPORT_SPL_NOR_FLASH /* Build NOR flash SPL */
++
++#define CONFIG_LTQ_SPL_COMP_LZO
++#define CONFIG_LTQ_SPL_CONSOLE
++
++#define CONFIG_SYS_DRAM_PROBE
++
++/* Environment */
++#define CONFIG_ENV_SPI_BUS CONFIG_SPL_SPI_BUS
++#define CONFIG_ENV_SPI_CS CONFIG_SPL_SPI_CS
++#define CONFIG_ENV_SPI_MAX_HZ CONFIG_SPL_SPI_MAX_HZ
++#define CONFIG_ENV_SPI_MODE CONFIG_SPL_SPI_MODE
++
++#if defined(CONFIG_SYS_BOOT_NOR)
++#define CONFIG_ENV_IS_IN_FLASH
++#define CONFIG_ENV_OVERWRITE
++#define CONFIG_ENV_OFFSET (384 * 1024)
++#define CONFIG_ENV_SECT_SIZE (64 * 1024)
++#elif defined(CONFIG_SYS_BOOT_NORSPL)
++#define CONFIG_ENV_IS_IN_FLASH
++#define CONFIG_ENV_OVERWRITE
++#define CONFIG_ENV_OFFSET (192 * 1024)
++#define CONFIG_ENV_SECT_SIZE (64 * 1024)
++#elif defined(CONFIG_SYS_BOOT_SFSPL)
++#define CONFIG_ENV_IS_IN_SPI_FLASH
++#define CONFIG_ENV_OVERWRITE
++#define CONFIG_ENV_OFFSET (192 * 1024)
++#define CONFIG_ENV_SECT_SIZE (64 * 1024)
++#else
++#define CONFIG_ENV_IS_NOWHERE
++#endif
++
++#define CONFIG_ENV_SIZE (8 * 1024)
++
++#define CONFIG_LOADADDR CONFIG_SYS_LOAD_ADDR
++
++/* Console */
++#define CONFIG_LTQ_ADVANCED_CONSOLE
++#define CONFIG_BAUDRATE 115200
++#define CONFIG_CONSOLE_ASC 1
++#define CONFIG_CONSOLE_DEV "ttyLTQ1"
++
++/* Commands */
++#define CONFIG_CMD_PING
++
++/* Pull in default board configs for Lantiq XWAY VRX200 */
++#include <asm/lantiq/config.h>
++#include <asm/arch/config.h>
++
++#define CONFIG_ENV_UPDATE_UBOOT_NOR \
++ "update-uboot-nor=run load-uboot-norspl-lzo write-uboot-nor\0"
++
++#define CONFIG_ENV_UPDATE_UBOOT_SF \
++ "update-uboot-sf=run load-uboot-sfspl-lzo write-uboot-sf\0"
++
++#define CONFIG_EXTRA_ENV_SETTINGS \
++ CONFIG_ENV_LANTIQ_DEFAULTS \
++ CONFIG_ENV_UPDATE_UBOOT_NOR \
++ CONFIG_ENV_UPDATE_UBOOT_SF
++
++#endif /* __CONFIG_H */
+--- a/include/phy.h
++++ b/include/phy.h
+@@ -220,6 +220,7 @@ int gen10g_discover_mmds(struct phy_devi
+ int phy_atheros_init(void);
+ int phy_broadcom_init(void);
+ int phy_davicom_init(void);
++int phy_lantiq_init(void);
+ int phy_lxt_init(void);
+ int phy_marvell_init(void);
+ int phy_micrel_init(void);
+--- a/spl/Makefile
++++ b/spl/Makefile
+@@ -81,6 +81,8 @@ LIBS-$(CONFIG_SPL_POST_MEM_SUPPORT) += p
+ LIBS-$(CONFIG_SPL_NET_SUPPORT) += net/libnet.o
+ LIBS-$(CONFIG_SPL_ETH_SUPPORT) += drivers/net/libnet.o
+ LIBS-$(CONFIG_SPL_ETH_SUPPORT) += drivers/net/phy/libphy.o
++LIBS-$(CONFIG_SPL_LZMA_SUPPORT) += lib/lzma/liblzma.o
++LIBS-$(CONFIG_SPL_LZO_SUPPORT) += lib/lzo/liblzo.o
+
+ ifneq ($(CONFIG_AM33XX)$(CONFIG_OMAP34XX)$(CONFIG_OMAP44XX)$(CONFIG_OMAP54XX),)
+ LIBS-y += $(CPUDIR)/omap-common/libomap-common.o
+--- a/tools/.gitignore
++++ b/tools/.gitignore
+@@ -2,6 +2,7 @@
+ /envcrc
+ /gen_eth_addr
+ /img2srec
++/ltq-boot-image
+ /kwboot
+ /mkenvimage
+ /mkimage
+--- a/tools/Makefile
++++ b/tools/Makefile
+@@ -65,6 +65,7 @@ BIN_FILES-$(CONFIG_VIDEO_LOGO) += bmp_lo
+ BIN_FILES-$(CONFIG_BUILD_ENVCRC) += envcrc$(SFX)
+ BIN_FILES-$(CONFIG_CMD_NET) += gen_eth_addr$(SFX)
+ BIN_FILES-$(CONFIG_CMD_LOADS) += img2srec$(SFX)
++BIN_FILES-$(CONFIG_SOC_LANTIQ) += ltq-boot-image$(SFX)
+ BIN_FILES-$(CONFIG_XWAY_SWAP_BYTES) += xway-swap-bytes$(SFX)
+ BIN_FILES-y += mkenvimage$(SFX)
+ BIN_FILES-y += mkimage$(SFX)
+@@ -89,6 +90,7 @@ OBJ_FILES-$(CONFIG_BUILD_ENVCRC) += envc
+ NOPED_OBJ_FILES-y += fit_image.o
+ OBJ_FILES-$(CONFIG_CMD_NET) += gen_eth_addr.o
+ OBJ_FILES-$(CONFIG_CMD_LOADS) += img2srec.o
++OBJ_FILES-$(CONFIG_SOC_LANTIQ) += ltq-boot-image.o
+ OBJ_FILES-$(CONFIG_XWAY_SWAP_BYTES) += xway-swap-bytes.o
+ NOPED_OBJ_FILES-y += aisimage.o
+ NOPED_OBJ_FILES-y += kwbimage.o
+@@ -193,6 +195,10 @@ $(obj)img2srec$(SFX): $(obj)img2srec.o
+ $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
+ $(HOSTSTRIP) $@
+
++$(obj)ltq-boot-image$(SFX): $(obj)ltq-boot-image.o
++ $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
++ $(HOSTSTRIP) $@
++
+ $(obj)xway-swap-bytes$(SFX): $(obj)xway-swap-bytes.o
+ $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
+ $(HOSTSTRIP) $@
+--- /dev/null
++++ b/tools/ltq-boot-image.c
+@@ -0,0 +1,316 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
++#include <unistd.h>
++#include <getopt.h>
++#include <compiler.h>
++#include <sys/stat.h>
++
++enum image_types {
++ IMAGE_NONE,
++ IMAGE_SFSPL
++};
++
++/* Lantiq non-volatile bootstrap command IDs */
++enum nvb_cmd_ids {
++ NVB_CMD_DEBUG = 0x11,
++ NVB_CMD_REGCFG = 0x22,
++ NVB_CMD_IDWNLD = 0x33,
++ NVB_CMD_CDWNLD = 0x44,
++ NVB_CMD_DWNLD = 0x55,
++ NVB_CMD_IFCFG = 0x66,
++ NVB_CMD_START = 0x77
++};
++
++/* Lantiq non-volatile bootstrap command flags */
++enum nvb_cmd_flags {
++ NVB_FLAG_START = 1,
++ NVB_FLAG_DEC = (1 << 1),
++ NVB_FLAG_DBG = (1 << 2),
++ NVB_FLAG_SDBG = (1 << 3),
++ NVB_FLAG_CFG0 = (1 << 4),
++ NVB_FLAG_CFG1 = (1 << 5),
++ NVB_FLAG_CFG2 = (1 << 6),
++ NVB_FLAG_RST = (1 << 7)
++};
++
++struct args {
++ enum image_types type;
++ __u32 entry_addr;
++ const char *uboot_bin;
++ const char *spl_bin;
++ const char *out_bin;
++};
++
++static void usage_msg(const char *name)
++{
++ fprintf(stderr, "%s: [-h] -t type -e entry-addr -u uboot-bin [-s spl-bin] -o out-bin\n",
++ name);
++ fprintf(stderr, " Image types:\n"
++ " sfspl - SPL + [compressed] U-Boot for SPI flash\n");
++}
++
++static enum image_types parse_image_type(const char *type)
++{
++ if (!type)
++ return IMAGE_NONE;
++
++ if (!strncmp(type, "sfspl", 6))
++ return IMAGE_SFSPL;
++
++ return IMAGE_NONE;
++}
++
++static int parse_args(int argc, char *argv[], struct args *arg)
++{
++ int opt;
++
++ memset(arg, 0, sizeof(*arg));
++
++ while ((opt = getopt(argc, argv, "ht:e:u:s:o:")) != -1) {
++ switch (opt) {
++ case 'h':
++ usage_msg(argv[0]);
++ return 1;
++ case 't':
++ arg->type = parse_image_type(optarg);
++ break;
++ case 'e':
++ arg->entry_addr = strtoul(optarg, NULL, 16);
++ break;
++ case 'u':
++ arg->uboot_bin = optarg;
++ break;
++ case 's':
++ arg->spl_bin = optarg;
++ break;
++ case 'o':
++ arg->out_bin = optarg;
++ break;
++ default:
++ fprintf(stderr, "Invalid option -%c\n", opt);
++ goto parse_error;
++ }
++ }
++
++ if (arg->type == IMAGE_NONE) {
++ fprintf(stderr, "Invalid image type\n");
++ goto parse_error;
++ }
++
++ if (!arg->uboot_bin) {
++ fprintf(stderr, "Missing U-Boot binary\n");
++ goto parse_error;
++ }
++
++ if (!arg->out_bin) {
++ fprintf(stderr, "Missing output binary\n");
++ goto parse_error;
++ }
++
++ if (arg->type == IMAGE_SFSPL && !arg->spl_bin) {
++ fprintf(stderr, "Missing SPL binary\n");
++ goto parse_error;
++ }
++
++ return 0;
++
++parse_error:
++ usage_msg(argv[0]);
++ return -1;
++}
++
++static __u32 build_nvb_command(unsigned cmdid, unsigned cmdflags)
++{
++ __u32 cmd;
++ __u16 tag;
++
++ tag = (cmdid << 8) | cmdflags;
++ cmd = (tag << 16) | (0xFFFF - tag);
++
++ return cpu_to_be32(cmd);
++}
++
++static int write_header(int fd, const void *hdr, size_t size)
++{
++ ssize_t n;
++
++ n = write(fd, hdr, size);
++ if (n != size) {
++ fprintf(stderr, "Cannot write header: %s\n",
++ strerror(errno));
++ return -1;
++ }
++
++ return 0;
++}
++
++static int write_nvb_dwnld_header(int fd, size_t size, __u32 addr)
++{
++ __u32 hdr[3];
++
++ hdr[0] = build_nvb_command(NVB_CMD_DWNLD, NVB_FLAG_START |
++ NVB_FLAG_SDBG);
++ hdr[1] = cpu_to_be32(size + 4);
++ hdr[2] = cpu_to_be32(addr);
++
++ return write_header(fd, hdr, sizeof(hdr));
++}
++
++static int write_nvb_start_header(int fd, __u32 addr)
++{
++ __u32 hdr[3];
++
++ hdr[0] = build_nvb_command(NVB_CMD_START, NVB_FLAG_SDBG);
++ hdr[1] = cpu_to_be32(4);
++ hdr[2] = cpu_to_be32(addr);
++
++ return write_header(fd, hdr, sizeof(hdr));
++}
++
++static int open_input_bin(const char *name, void **ptr, size_t *size)
++{
++ struct stat sbuf;
++ int ret, fd;
++
++ fd = open(name, O_RDONLY | O_BINARY);
++ if (0 > fd) {
++ fprintf(stderr, "Cannot open %s: %s\n", name,
++ strerror(errno));
++ return -1;
++ }
++
++ ret = fstat(fd, &sbuf);
++ if (0 > ret) {
++ fprintf(stderr, "Cannot fstat %s: %s\n", name,
++ strerror(errno));
++ return -1;
++ }
++
++ *ptr = mmap(0, sbuf.st_size, PROT_READ, MAP_SHARED, fd, 0);
++ if (*ptr == MAP_FAILED) {
++ fprintf(stderr, "Cannot mmap %s: %s\n", name,
++ strerror(errno));
++ return -1;
++ }
++
++ *size = sbuf.st_size;
++
++ return fd;
++}
++
++static void close_input_bin(int fd, void *ptr, size_t size)
++{
++ munmap(ptr, size);
++ close(fd);
++}
++
++static int copy_bin(int fd, void *ptr, size_t size)
++{
++ ssize_t n;
++
++ n = write(fd, ptr, size);
++ if (n != size) {
++ fprintf(stderr, "Cannot copy binary: %s\n", strerror(errno));
++ return -1;
++ }
++
++ return 0;
++}
++
++static int open_output_bin(const char *name)
++{
++ int fd;
++
++ fd = open(name, O_RDWR | O_CREAT | O_TRUNC | O_SYNC | O_BINARY, 0666);
++ if (0 > fd) {
++ fprintf(stderr, "Cannot open %s: %s\n", name,
++ strerror(errno));
++ return -1;
++ }
++
++ return fd;
++}
++
++static int create_sfspl(const struct args *arg)
++{
++ int out_fd, uboot_fd, spl_fd, ret;
++ void *uboot_ptr, *spl_ptr;
++ size_t uboot_size, spl_size;
++
++ out_fd = open_output_bin(arg->out_bin);
++ if (0 > out_fd)
++ goto err;
++
++ spl_fd = open_input_bin(arg->spl_bin, &spl_ptr, &spl_size);
++ if (0 > spl_fd)
++ goto err_spl;
++
++ uboot_fd = open_input_bin(arg->uboot_bin, &uboot_ptr, &uboot_size);
++ if (0 > uboot_fd)
++ goto err_uboot;
++
++ ret = write_nvb_dwnld_header(out_fd, spl_size, arg->entry_addr);
++ if (ret)
++ goto err_write;
++
++ ret = copy_bin(out_fd, spl_ptr, spl_size);
++ if (ret)
++ goto err_write;
++
++ ret = write_nvb_start_header(out_fd, arg->entry_addr);
++ if (ret)
++ goto err_write;
++
++ ret = copy_bin(out_fd, uboot_ptr, uboot_size);
++ if (ret)
++ goto err_write;
++
++ close_input_bin(uboot_fd, uboot_ptr, uboot_size);
++ close_input_bin(spl_fd, spl_ptr, spl_size);
++ close(out_fd);
++
++ return 0;
++
++err_write:
++ close_input_bin(uboot_fd, uboot_ptr, uboot_size);
++err_uboot:
++ close_input_bin(spl_fd, spl_ptr, spl_size);
++err_spl:
++ close(out_fd);
++err:
++ return -1;
++}
++
++int main(int argc, char *argv[])
++{
++ int ret;
++ struct args arg;
++
++ ret = parse_args(argc, argv, &arg);
++ if (ret)
++ goto done;
++
++ switch (arg.type) {
++ case IMAGE_SFSPL:
++ ret = create_sfspl(&arg);
++ break;
++ default:
++ fprintf(stderr, "Image type not implemented\n");
++ ret = -1;
++ break;
++ }
++
++done:
++ if (ret >= 0)
++ return EXIT_SUCCESS;
++
++ return EXIT_FAILURE;
++}
diff --git a/package/boot/uboot-lantiq/patches/.svn/text-base/0024-MIPS-VRX200-add-option-to-boot-from-AVM-EVA-loader.patch.svn-base b/package/boot/uboot-lantiq/patches/.svn/text-base/0024-MIPS-VRX200-add-option-to-boot-from-AVM-EVA-loader.patch.svn-base
new file mode 100644
index 0000000..ba24bae
--- /dev/null
+++ b/package/boot/uboot-lantiq/patches/.svn/text-base/0024-MIPS-VRX200-add-option-to-boot-from-AVM-EVA-loader.patch.svn-base
@@ -0,0 +1,33 @@
+From 2c6115188c7353a601835885a6c544240cfc479e Mon Sep 17 00:00:00 2001
+From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+Date: Fri, 30 Nov 2012 18:09:25 +0100
+Subject: MIPS: VRX200: add option to boot from AVM EVA loader
+
+Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+
+--- a/arch/mips/cpu/mips32/vrx200/config.mk
++++ b/arch/mips/cpu/mips32/vrx200/config.mk
+@@ -17,6 +17,9 @@ endif
+ LIBS-y += $(CPUDIR)/lantiq-common/liblantiq-common.o
+
+ ifndef CONFIG_SPL_BUILD
++ifdef CONFIG_SYS_BOOT_EVA
++ALL-y += $(obj)u-boot.bin.lzma
++endif
+ ifdef CONFIG_SYS_BOOT_SFSPL
+ ALL-y += $(obj)u-boot.ltq.sfspl
+ ALL-$(CONFIG_SPL_LZO_SUPPORT) += $(obj)u-boot.ltq.lzo.sfspl
+--- a/arch/mips/include/asm/arch-vrx200/config.h
++++ b/arch/mips/include/asm/arch-vrx200/config.h
+@@ -161,6 +161,11 @@
+ #define CONFIG_SYS_DISABLE_CACHE
+ #endif
+
++#if defined(CONFIG_SYS_BOOT_EVA)
++#define CONFIG_SYS_TEXT_BASE 0x80100000
++#define CONFIG_SKIP_LOWLEVEL_INIT
++#endif
++
+ #if defined(CONFIG_SYS_BOOT_NOR)
+ #define CONFIG_SYS_TEXT_BASE 0xB0000000
+ #endif
diff --git a/package/boot/uboot-lantiq/patches/.svn/text-base/0025-MIPS-add-board-support-for-AVM-FritzBox-3370.patch.svn-base b/package/boot/uboot-lantiq/patches/.svn/text-base/0025-MIPS-add-board-support-for-AVM-FritzBox-3370.patch.svn-base
new file mode 100644
index 0000000..b680a97
--- /dev/null
+++ b/package/boot/uboot-lantiq/patches/.svn/text-base/0025-MIPS-add-board-support-for-AVM-FritzBox-3370.patch.svn-base
@@ -0,0 +1,355 @@
+From 51f04c00e831b49587f9f766ff1af67d2122feb2 Mon Sep 17 00:00:00 2001
+From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+Date: Fri, 30 Nov 2012 18:09:47 +0100
+Subject: MIPS: add board support for AVM FritzBox 3370
+
+Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+
+--- /dev/null
++++ b/board/avm/fb3370/Makefile
+@@ -0,0 +1,29 @@
++#
++# This file is released under the terms of GPL v2 and any later version.
++# See the file COPYING in the root directory of the source tree for details.
++#
++# Copyright (C) 2000-2011 Wolfgang Denk, DENX Software Engineering, wd@denx.de
++# Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++#
++
++include $(TOPDIR)/config.mk
++
++LIB = $(obj)lib$(BOARD).o
++
++COBJS = $(BOARD).o
++
++SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c)
++OBJS := $(addprefix $(obj),$(COBJS))
++SOBJS := $(addprefix $(obj),$(SOBJS))
++
++$(LIB): $(obj).depend $(OBJS) $(SOBJS)
++ $(call cmd_link_o_target, $(OBJS) $(SOBJS))
++
++#########################################################################
++
++# defines $(obj).depend target
++include $(SRCTREE)/rules.mk
++
++sinclude $(obj).depend
++
++#########################################################################
+--- /dev/null
++++ b/board/avm/fb3370/config.mk
+@@ -0,0 +1,8 @@
++#
++# This file is released under the terms of GPL v2 and any later version.
++# See the file COPYING in the root directory of the source tree for details.
++#
++# Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++#
++
++PLATFORM_CPPFLAGS += -I$(TOPDIR)/board/$(BOARDDIR)
+--- /dev/null
++++ b/board/avm/fb3370/ddr_settings.h
+@@ -0,0 +1,70 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2007-2010 Lantiq Deutschland GmbH
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#define MC_CCR00_VALUE 0x101
++#define MC_CCR01_VALUE 0x1000100
++#define MC_CCR02_VALUE 0x1010000
++#define MC_CCR03_VALUE 0x101
++#define MC_CCR04_VALUE 0x1000000
++#define MC_CCR05_VALUE 0x1000101
++#define MC_CCR06_VALUE 0x1000100
++#define MC_CCR07_VALUE 0x1010000
++#define MC_CCR08_VALUE 0x1000101
++#define MC_CCR09_VALUE 0x0
++#define MC_CCR10_VALUE 0x2000100
++#define MC_CCR11_VALUE 0x2000300
++#define MC_CCR12_VALUE 0x30000
++#define MC_CCR13_VALUE 0x202
++#define MC_CCR14_VALUE 0x7080A0F
++#define MC_CCR15_VALUE 0x2040F
++#define MC_CCR16_VALUE 0x40000
++#define MC_CCR17_VALUE 0x70102
++#define MC_CCR18_VALUE 0x4020002
++#define MC_CCR19_VALUE 0x30302
++#define MC_CCR20_VALUE 0x8000700
++#define MC_CCR21_VALUE 0x40F020A
++#define MC_CCR22_VALUE 0x0
++#define MC_CCR23_VALUE 0xC020000
++#define MC_CCR24_VALUE 0x4401B04
++#define MC_CCR25_VALUE 0x0
++#define MC_CCR26_VALUE 0x0
++#define MC_CCR27_VALUE 0x6420000
++#define MC_CCR28_VALUE 0x0
++#define MC_CCR29_VALUE 0x0
++#define MC_CCR30_VALUE 0x798
++#define MC_CCR31_VALUE 0x0
++#define MC_CCR32_VALUE 0x0
++#define MC_CCR33_VALUE 0x650000
++#define MC_CCR34_VALUE 0x200C8
++#define MC_CCR35_VALUE 0x1D445D
++#define MC_CCR36_VALUE 0xC8
++#define MC_CCR37_VALUE 0xC351
++#define MC_CCR38_VALUE 0x0
++#define MC_CCR39_VALUE 0x141F04
++#define MC_CCR40_VALUE 0x142704
++#define MC_CCR41_VALUE 0x141b42
++#define MC_CCR42_VALUE 0x141b42
++#define MC_CCR43_VALUE 0x566504
++#define MC_CCR44_VALUE 0x566504
++#define MC_CCR45_VALUE 0x565F17
++#define MC_CCR46_VALUE 0x565F17
++#define MC_CCR47_VALUE 0x0
++#define MC_CCR48_VALUE 0x0
++#define MC_CCR49_VALUE 0x0
++#define MC_CCR50_VALUE 0x0
++#define MC_CCR51_VALUE 0x0
++#define MC_CCR52_VALUE 0x133
++#define MC_CCR53_VALUE 0xF3014B27
++#define MC_CCR54_VALUE 0xF3014B27
++#define MC_CCR55_VALUE 0xF3014B27
++#define MC_CCR56_VALUE 0xF3014B27
++#define MC_CCR57_VALUE 0x7800301
++#define MC_CCR58_VALUE 0x7800301
++#define MC_CCR59_VALUE 0x7800301
++#define MC_CCR60_VALUE 0x7800301
++#define MC_CCR61_VALUE 0x4
+--- /dev/null
++++ b/board/avm/fb3370/fb3370.c
+@@ -0,0 +1,139 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <common.h>
++#include <spi.h>
++#include <asm/gpio.h>
++#include <asm/lantiq/eth.h>
++#include <asm/lantiq/chipid.h>
++#include <asm/lantiq/cpu.h>
++#include <asm/arch/gphy.h>
++
++#if defined(CONFIG_SPL_BUILD)
++#define do_gpio_init 1
++#define do_pll_init 1
++#define do_dcdc_init 0
++#elif defined(CONFIG_SYS_BOOT_RAM)
++#define do_gpio_init 1
++#define do_pll_init 0
++#define do_dcdc_init 1
++#elif defined(CONFIG_SYS_BOOT_NOR)
++#define do_gpio_init 1
++#define do_pll_init 1
++#define do_dcdc_init 1
++#else
++#define do_gpio_init 0
++#define do_pll_init 0
++#define do_dcdc_init 1
++#endif
++
++static void gpio_init(void)
++{
++ /* SPI CS 0.4 to serial flash */
++ gpio_direction_output(10, 1);
++
++ /* EBU.FL_CS1 as output for NAND CE */
++ gpio_set_altfunc(23, GPIO_ALTSEL_SET, GPIO_ALTSEL_CLR, GPIO_DIR_OUT);
++ /* EBU.FL_A23 as output for NAND CLE */
++ gpio_set_altfunc(24, GPIO_ALTSEL_SET, GPIO_ALTSEL_CLR, GPIO_DIR_OUT);
++ /* EBU.FL_A24 as output for NAND ALE */
++ gpio_set_altfunc(13, GPIO_ALTSEL_SET, GPIO_ALTSEL_CLR, GPIO_DIR_OUT);
++ /* GPIO 3.0 as input for NAND Ready Busy */
++ gpio_set_altfunc(48, GPIO_ALTSEL_SET, GPIO_ALTSEL_CLR, GPIO_DIR_IN);
++ /* GPIO 3.1 as output for NAND Read */
++ gpio_set_altfunc(49, GPIO_ALTSEL_SET, GPIO_ALTSEL_CLR, GPIO_DIR_OUT);
++}
++
++int board_early_init_f(void)
++{
++ if (do_gpio_init)
++ gpio_init();
++
++ if (do_pll_init)
++ ltq_pll_init();
++
++ if (do_dcdc_init)
++ ltq_dcdc_init(0x7F);
++
++ return 0;
++}
++
++int checkboard(void)
++{
++ puts("Board: " CONFIG_BOARD_NAME "\n");
++ ltq_chip_print_info();
++
++ return 0;
++}
++
++static const struct ltq_eth_port_config eth_port_config[] = {
++ /* GMAC0: external Lantiq PEF7071 10/100/1000 PHY for LAN port 0 */
++ { 0, 0x0, LTQ_ETH_PORT_PHY, PHY_INTERFACE_MODE_RGMII },
++ /* GMAC1: external Lantiq PEF7071 10/100/1000 PHY for LAN port 1 */
++ { 1, 0x1, LTQ_ETH_PORT_PHY, PHY_INTERFACE_MODE_RGMII },
++ /* GMAC2: internal GPHY0 with 10/100/1000 firmware for LAN port 2 */
++ { 2, 0x11, LTQ_ETH_PORT_PHY, PHY_INTERFACE_MODE_GMII },
++ /* GMAC3: unused */
++ { 3, 0x0, LTQ_ETH_PORT_NONE, PHY_INTERFACE_MODE_NONE },
++ /* GMAC4: internal GPHY1 with 10/100/1000 firmware for LAN port 3 */
++ { 4, 0x13, LTQ_ETH_PORT_PHY, PHY_INTERFACE_MODE_GMII },
++ /* GMAC5: external Lantiq PEF7071 10/100/1000 PHY for WANoE port */
++ { 5, 0x5, LTQ_ETH_PORT_PHY, PHY_INTERFACE_MODE_RGMII },
++};
++
++static const struct ltq_eth_board_config eth_board_config = {
++ .ports = eth_port_config,
++ .num_ports = ARRAY_SIZE(eth_port_config),
++};
++
++int board_eth_init(bd_t * bis)
++{
++ const enum ltq_gphy_clk clk = LTQ_GPHY_CLK_25MHZ_PLL0;
++ const ulong fw_addr = 0x80FF0000;
++
++ ltq_gphy_phy11g_a1x_load(fw_addr);
++
++ ltq_cgu_gphy_clk_src(clk);
++
++ ltq_rcu_gphy_boot(0, fw_addr);
++ ltq_rcu_gphy_boot(1, fw_addr);
++
++ return ltq_eth_initialize(&eth_board_config);
++}
++
++int spi_cs_is_valid(unsigned int bus, unsigned int cs)
++{
++ if (bus)
++ return 0;
++
++ if (cs == 4)
++ return 1;
++
++ return 0;
++}
++
++void spi_cs_activate(struct spi_slave *slave)
++{
++ switch (slave->cs) {
++ case 4:
++ gpio_set_value(10, 0);
++ break;
++ default:
++ break;
++ }
++}
++
++void spi_cs_deactivate(struct spi_slave *slave)
++{
++ switch (slave->cs) {
++ case 4:
++ gpio_set_value(10, 1);
++ break;
++ default:
++ break;
++ }
++}
+--- a/boards.cfg
++++ b/boards.cfg
+@@ -451,6 +451,9 @@ incaip mips
+ incaip_100MHz mips mips32 incaip - incaip incaip:CPU_CLOCK_RATE=100000000
+ incaip_133MHz mips mips32 incaip - incaip incaip:CPU_CLOCK_RATE=133000000
+ incaip_150MHz mips mips32 incaip - incaip incaip:CPU_CLOCK_RATE=150000000
++fb3370_ram mips mips32 fb3370 avm vrx200 fb3370:SYS_BOOT_RAM
++fb3370_eva mips mips32 fb3370 avm vrx200 fb3370:SYS_BOOT_EVA
++fb3370_sfspl mips mips32 fb3370 avm vrx200 fb3370:SYS_BOOT_SFSPL
+ easy80920_nor mips mips32 easy80920 lantiq vrx200 easy80920:SYS_BOOT_NOR
+ easy80920_norspl mips mips32 easy80920 lantiq vrx200 easy80920:SYS_BOOT_NORSPL
+ easy80920_ram mips mips32 easy80920 lantiq vrx200 easy80920:SYS_BOOT_RAM
+--- /dev/null
++++ b/include/configs/fb3370.h
+@@ -0,0 +1,75 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#ifndef __CONFIG_H
++#define __CONFIG_H
++
++#define CONFIG_MACH_TYPE "FB3370"
++#define CONFIG_IDENT_STRING " "CONFIG_MACH_TYPE
++#define CONFIG_BOARD_NAME "AVM FritzBox 3370"
++
++/* Configure SoC */
++#define CONFIG_LTQ_SUPPORT_UART /* Enable ASC and UART */
++
++#define CONFIG_LTQ_SUPPORT_ETHERNET /* Enable ethernet */
++
++#define CONFIG_LTQ_SUPPORT_SPI_FLASH
++#define CONFIG_SPI_FLASH_MACRONIX /* Have a MX29LV620 serial flash */
++
++#define CONFIG_LTQ_SUPPORT_NAND_FLASH
++
++#define CONFIG_LTQ_SUPPORT_SPL_SPI_FLASH /* Build SPI flash SPL */
++#define CONFIG_SPL_SPI_BUS 0
++#define CONFIG_SPL_SPI_CS 4
++#define CONFIG_SPL_SPI_MAX_HZ 25000000
++#define CONFIG_SPL_SPI_MODE 0
++
++#define CONFIG_LTQ_SPL_COMP_LZO
++#define CONFIG_LTQ_SPL_CONSOLE
++
++#define CONFIG_SYS_DRAM_PROBE
++
++/* Environment */
++#define CONFIG_ENV_SPI_BUS CONFIG_SPL_SPI_BUS
++#define CONFIG_ENV_SPI_CS CONFIG_SPL_SPI_CS
++#define CONFIG_ENV_SPI_MAX_HZ CONFIG_SPL_SPI_MAX_HZ
++#define CONFIG_ENV_SPI_MODE CONFIG_SPL_SPI_MODE
++
++#if defined(CONFIG_SYS_BOOT_SFSPL)
++#define CONFIG_ENV_IS_IN_SPI_FLASH
++#define CONFIG_ENV_OVERWRITE
++#define CONFIG_ENV_OFFSET (192 * 1024)
++#define CONFIG_ENV_SECT_SIZE (64 * 1024)
++#else
++#define CONFIG_ENV_IS_NOWHERE
++#endif
++
++#define CONFIG_ENV_SIZE (8 * 1024)
++
++#define CONFIG_LOADADDR CONFIG_SYS_LOAD_ADDR
++
++/* Console */
++#define CONFIG_LTQ_ADVANCED_CONSOLE
++#define CONFIG_BAUDRATE 115200
++#define CONFIG_CONSOLE_ASC 1
++#define CONFIG_CONSOLE_DEV "ttyLTQ1"
++
++/* Commands */
++#define CONFIG_CMD_PING
++
++/* Pull in default board configs for Lantiq XWAY VRX200 */
++#include <asm/lantiq/config.h>
++#include <asm/arch/config.h>
++
++#define CONFIG_ENV_UPDATE_UBOOT_SF \
++ "update-uboot-sf=run load-uboot-sfspl-lzo write-uboot-sf\0"
++
++#define CONFIG_EXTRA_ENV_SETTINGS \
++ CONFIG_ENV_LANTIQ_DEFAULTS \
++ CONFIG_ENV_UPDATE_UBOOT_SF
++
++#endif /* __CONFIG_H */
diff --git a/package/boot/uboot-lantiq/patches/.svn/text-base/0026-MIPS-add-board-support-for-Gigaset-SX76X.patch.svn-base b/package/boot/uboot-lantiq/patches/.svn/text-base/0026-MIPS-add-board-support-for-Gigaset-SX76X.patch.svn-base
new file mode 100644
index 0000000..810770a
--- /dev/null
+++ b/package/boot/uboot-lantiq/patches/.svn/text-base/0026-MIPS-add-board-support-for-Gigaset-SX76X.patch.svn-base
@@ -0,0 +1,264 @@
+From 66b56aa3a4810f10e0b0c77bb87279a8d64b566b Mon Sep 17 00:00:00 2001
+From: Luka Perkov <luka@openwrt.org>
+Date: Fri, 16 Dec 2011 11:55:45 +0100
+Subject: MIPS: add board support for Gigaset SX76X
+
+Signed-off-by: Luka Perkov <luka@openwrt.org>
+Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+
+--- /dev/null
++++ b/board/gigaset/sx76x/Makefile
+@@ -0,0 +1,29 @@
++#
++# This file is released under the terms of GPL v2 and any later version.
++# See the file COPYING in the root directory of the source tree for details.
++#
++# Copyright (C) 2000-2011 Wolfgang Denk, DENX Software Engineering, wd@denx.de
++# Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++#
++
++include $(TOPDIR)/config.mk
++
++LIB = $(obj)lib$(BOARD).o
++
++COBJS = $(BOARD).o
++
++SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c)
++OBJS := $(addprefix $(obj),$(COBJS))
++SOBJS := $(addprefix $(obj),$(SOBJS))
++
++$(LIB): $(obj).depend $(OBJS) $(SOBJS)
++ $(call cmd_link_o_target, $(OBJS) $(SOBJS))
++
++#########################################################################
++
++# defines $(obj).depend target
++include $(SRCTREE)/rules.mk
++
++sinclude $(obj).depend
++
++#########################################################################
+--- /dev/null
++++ b/board/gigaset/sx76x/config.mk
+@@ -0,0 +1,8 @@
++#
++# This file is released under the terms of GPL v2 and any later version.
++# See the file COPYING in the root directory of the source tree for details.
++#
++# Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++#
++
++PLATFORM_CPPFLAGS += -I$(TOPDIR)/board/$(BOARDDIR)
+--- /dev/null
++++ b/board/gigaset/sx76x/ddr_settings.h
+@@ -0,0 +1,56 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * generated with lantiq_ram_extract_magic.awk
++ *
++ * Copyright (C) 2011 Luka Perkov <luka@openwrt.org>
++ */
++
++#define MC_DC00_VALUE 0x1B1B
++#define MC_DC01_VALUE 0x0
++#define MC_DC02_VALUE 0x0
++#define MC_DC03_VALUE 0x0
++#define MC_DC04_VALUE 0x0
++#define MC_DC05_VALUE 0x200
++#define MC_DC06_VALUE 0x605
++#define MC_DC07_VALUE 0x303
++#define MC_DC08_VALUE 0x202
++#define MC_DC09_VALUE 0x70A
++#define MC_DC10_VALUE 0x203
++#define MC_DC11_VALUE 0xC02
++#define MC_DC12_VALUE 0x1C8
++#define MC_DC13_VALUE 0x1
++#define MC_DC14_VALUE 0x0
++#define MC_DC15_VALUE 0xF3E
++#define MC_DC16_VALUE 0xC800
++#define MC_DC17_VALUE 0xD
++#define MC_DC18_VALUE 0x300
++#define MC_DC19_VALUE 0x200
++#define MC_DC20_VALUE 0xA04
++#define MC_DC21_VALUE 0xF00
++#define MC_DC22_VALUE 0xF0F
++#define MC_DC23_VALUE 0x0
++#define MC_DC24_VALUE 0x63
++#define MC_DC25_VALUE 0x0
++#define MC_DC26_VALUE 0x100
++#define MC_DC27_VALUE 0x0
++#define MC_DC28_VALUE 0x514
++#define MC_DC29_VALUE 0x2D89
++#define MC_DC30_VALUE 0x8300
++#define MC_DC31_VALUE 0x2002
++#define MC_DC32_VALUE 0x0
++#define MC_DC33_VALUE 0x0
++#define MC_DC34_VALUE 0x0
++#define MC_DC35_VALUE 0x0
++#define MC_DC36_VALUE 0x0
++#define MC_DC37_VALUE 0x0
++#define MC_DC38_VALUE 0x0
++#define MC_DC39_VALUE 0x0
++#define MC_DC40_VALUE 0x0
++#define MC_DC41_VALUE 0x0
++#define MC_DC42_VALUE 0x0
++#define MC_DC43_VALUE 0x0
++#define MC_DC44_VALUE 0x0
++#define MC_DC45_VALUE 0x500
++#define MC_DC46_VALUE 0x0
+--- /dev/null
++++ b/board/gigaset/sx76x/sx76x.c
+@@ -0,0 +1,66 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Luka Perkov <luka@openwrt.org>
++ */
++
++#include <common.h>
++#include <switch.h>
++#include <asm/gpio.h>
++#include <asm/lantiq/eth.h>
++#include <asm/lantiq/reset.h>
++#include <asm/lantiq/chipid.h>
++
++static void gpio_init(void)
++{
++ /* Activate reset line of ADM6996I switch */
++ gpio_direction_output(19, 0);
++}
++
++int board_early_init_f(void)
++{
++ gpio_init();
++
++ return 0;
++}
++
++int checkboard(void)
++{
++ puts("Board: " CONFIG_BOARD_NAME "\n");
++ ltq_chip_print_info();
++
++ return 0;
++}
++
++static const struct ltq_eth_port_config eth_port_config[] = {
++ /* MAC0: Lantiq ADM6996I switch */
++ { 0, 0x0, LTQ_ETH_PORT_SWITCH, PHY_INTERFACE_MODE_RMII },
++};
++
++static const struct ltq_eth_board_config eth_board_config = {
++ .ports = eth_port_config,
++ .num_ports = ARRAY_SIZE(eth_port_config),
++};
++
++int board_eth_init(bd_t *bis)
++{
++ return ltq_eth_initialize(&eth_board_config);
++}
++
++static struct switch_device adm6996i_dev = {
++ .name = "adm6996i",
++ .cpu_port = 5,
++ .port_mask = 0xF,
++};
++
++int board_switch_init(void)
++{
++ /* Deactivate reset line of ADM6996I switch */
++ gpio_set_value(19, 1);
++
++ /* ADM6996I needs some time to come out of reset */
++ __udelay(50000);
++
++ return switch_device_register(&adm6996i_dev);
++}
+--- a/boards.cfg
++++ b/boards.cfg
+@@ -447,6 +447,8 @@ pb1000 mips
+ easy50712_nor mips mips32 easy50712 lantiq danube easy50712:SYS_BOOT_NOR
+ easy50712_norspl mips mips32 easy50712 lantiq danube easy50712:SYS_BOOT_NORSPL
+ easy50712_ram mips mips32 easy50712 lantiq danube easy50712:SYS_BOOT_RAM
++gigasx76x_nor mips mips32 sx76x gigaset danube sx76x:SYS_BOOT_NOR
++gigasx76x_ram mips mips32 sx76x gigaset danube sx76x:SYS_BOOT_RAM
+ incaip mips mips32 incaip - incaip
+ incaip_100MHz mips mips32 incaip - incaip incaip:CPU_CLOCK_RATE=100000000
+ incaip_133MHz mips mips32 incaip - incaip incaip:CPU_CLOCK_RATE=133000000
+--- /dev/null
++++ b/include/configs/sx76x.h
+@@ -0,0 +1,71 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Luka Perkov <luka@openwrt.org>
++ */
++
++#ifndef __CONFIG_H
++#define __CONFIG_H
++
++#define CONFIG_MACH_TYPE "GIGASX76X"
++#define CONFIG_IDENT_STRING " sx76x"
++#define CONFIG_BOARD_NAME "Gigaset sx76x"
++
++/* Configure SoC */
++#define CONFIG_LTQ_SUPPORT_UART /* Enable ASC and UART */
++
++#define CONFIG_LTQ_SUPPORT_ETHERNET /* Enable ethernet */
++
++#define CONFIG_LTQ_SUPPORT_NOR_FLASH /* Have a parallel NOR flash */
++
++/* Switch devices */
++#define CONFIG_SWITCH_MULTI
++#define CONFIG_SWITCH_ADM6996I
++
++/* Environment */
++#if defined(CONFIG_SYS_BOOT_NOR)
++#define CONFIG_ENV_IS_IN_FLASH
++#define CONFIG_ENV_OVERWRITE
++#define CONFIG_ENV_OFFSET (256 * 1024)
++#define CONFIG_ENV_SIZE (8 * 1024)
++#define CONFIG_ENV_SECT_SIZE (64 * 1024)
++#else
++#define CONFIG_ENV_IS_NOWHERE
++#define CONFIG_ENV_SIZE (2 * 1024)
++#endif
++
++#define CONFIG_LOADADDR CONFIG_SYS_LOAD_ADDR
++
++/* Console */
++#define CONFIG_LTQ_ADVANCED_CONSOLE
++#define CONFIG_BAUDRATE 115200
++#define CONFIG_CONSOLE_ASC 1
++#define CONFIG_CONSOLE_DEV "ttyLTQ1"
++
++/* Commands */
++#define CONFIG_CMD_PING
++
++/* Pull in default board configs for Lantiq XWAY Danube */
++#include <asm/lantiq/config.h>
++#include <asm/arch/config.h>
++
++/* Compression */
++#define CONFIG_LZMA
++
++/* Auto boot */
++#define CONFIG_BOOTDELAY 2
++
++/* Environment configuration */
++#define CONFIG_BOOTCOMMAND \
++ "run addeth; bootm ${kernel_addr}"
++
++#define CONFIG_ENV_UPDATE_UBOOT_NOR \
++ "update-uboot-nor=run load-uboot-nor write-uboot-nor\0"
++
++#define CONFIG_EXTRA_ENV_SETTINGS \
++ CONFIG_ENV_LANTIQ_DEFAULTS \
++ CONFIG_ENV_UPDATE_UBOOT_NOR \
++ "kernel_addr=0xB0040000\0"
++
++#endif /* __CONFIG_H */
diff --git a/package/boot/uboot-lantiq/patches/.svn/text-base/0027-MIPS-add-board-support-for-Arcadyan-ARV7518.patch.svn-base b/package/boot/uboot-lantiq/patches/.svn/text-base/0027-MIPS-add-board-support-for-Arcadyan-ARV7518.patch.svn-base
new file mode 100644
index 0000000..4156089
--- /dev/null
+++ b/package/boot/uboot-lantiq/patches/.svn/text-base/0027-MIPS-add-board-support-for-Arcadyan-ARV7518.patch.svn-base
@@ -0,0 +1,248 @@
+From 289f7ed5d725067b4eb4b1a105bb63d55bf20392 Mon Sep 17 00:00:00 2001
+From: Luka Perkov <luka@openwrt.org>
+Date: Wed, 29 Aug 2012 22:08:41 +0200
+Subject: MIPS: add board support for Arcadyan ARV7518
+
+Signed-off-by: Luka Perkov <luka@openwrt.org>
+Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+
+--- /dev/null
++++ b/board/arcadyan/arv7518pw/Makefile
+@@ -0,0 +1,29 @@
++#
++# This file is released under the terms of GPL v2 and any later version.
++# See the file COPYING in the root directory of the source tree for details.
++#
++# Copyright (C) 2000-2011 Wolfgang Denk, DENX Software Engineering, wd@denx.de
++# Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++#
++
++include $(TOPDIR)/config.mk
++
++LIB = $(obj)lib$(BOARD).o
++
++COBJS = $(BOARD).o
++
++SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c)
++OBJS := $(addprefix $(obj),$(COBJS))
++SOBJS := $(addprefix $(obj),$(SOBJS))
++
++$(LIB): $(obj).depend $(OBJS) $(SOBJS)
++ $(call cmd_link_o_target, $(OBJS) $(SOBJS))
++
++#########################################################################
++
++# defines $(obj).depend target
++include $(SRCTREE)/rules.mk
++
++sinclude $(obj).depend
++
++#########################################################################
+--- /dev/null
++++ b/board/arcadyan/arv7518pw/arv7518pw.c
+@@ -0,0 +1,52 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2012 Luka Perkov <luka@openwrt.org>
++ */
++
++#include <common.h>
++#include <switch.h>
++#include <asm/gpio.h>
++#include <asm/lantiq/eth.h>
++#include <asm/lantiq/reset.h>
++#include <asm/lantiq/chipid.h>
++
++int board_early_init_f(void)
++{
++ return 0;
++}
++
++int checkboard(void)
++{
++ puts("Board: " CONFIG_BOARD_NAME "\n");
++ ltq_chip_print_info();
++
++ return 0;
++}
++
++static const struct ltq_eth_port_config eth_port_config[] = {
++ /* MAC0: Atheros ar8216 switch */
++ { 0, 0x0, LTQ_ETH_PORT_SWITCH, PHY_INTERFACE_MODE_NONE },
++};
++
++static const struct ltq_eth_board_config eth_board_config = {
++ .ports = eth_port_config,
++ .num_ports = ARRAY_SIZE(eth_port_config),
++};
++
++int board_eth_init(bd_t *bis)
++{
++ return ltq_eth_initialize(&eth_board_config);
++}
++
++static struct switch_device ar8216_dev = {
++ .name = "ar8216",
++ .cpu_port = 0,
++ .port_mask = 0xF,
++};
++
++int board_switch_init(void)
++{
++ return switch_device_register(&ar8216_dev);
++}
+--- /dev/null
++++ b/board/arcadyan/arv7518pw/config.mk
+@@ -0,0 +1,8 @@
++#
++# This file is released under the terms of GPL v2 and any later version.
++# See the file COPYING in the root directory of the source tree for details.
++#
++# Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++#
++
++PLATFORM_CPPFLAGS += -I$(TOPDIR)/board/$(BOARDDIR)
+--- /dev/null
++++ b/board/arcadyan/arv7518pw/ddr_settings.h
+@@ -0,0 +1,56 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * generated with lantiq_ram_extract_magic.awk
++ *
++ * Copyright (C) 2012 Luka Perkov <luka@openwrt.org>
++ */
++
++#define MC_DC00_VALUE 0x1B1B
++#define MC_DC01_VALUE 0x0
++#define MC_DC02_VALUE 0x0
++#define MC_DC03_VALUE 0x0
++#define MC_DC04_VALUE 0x0
++#define MC_DC05_VALUE 0x200
++#define MC_DC06_VALUE 0x605
++#define MC_DC07_VALUE 0x303
++#define MC_DC08_VALUE 0x102
++#define MC_DC09_VALUE 0x70A
++#define MC_DC10_VALUE 0x203
++#define MC_DC11_VALUE 0xC02
++#define MC_DC12_VALUE 0x1C8
++#define MC_DC13_VALUE 0x1
++#define MC_DC14_VALUE 0x0
++#define MC_DC15_VALUE 0x134
++#define MC_DC16_VALUE 0xC800
++#define MC_DC17_VALUE 0xD
++#define MC_DC18_VALUE 0x301
++#define MC_DC19_VALUE 0x200
++#define MC_DC20_VALUE 0xA03
++#define MC_DC21_VALUE 0x1400
++#define MC_DC22_VALUE 0x1414
++#define MC_DC23_VALUE 0x0
++#define MC_DC24_VALUE 0x5B
++#define MC_DC25_VALUE 0x0
++#define MC_DC26_VALUE 0x0
++#define MC_DC27_VALUE 0x0
++#define MC_DC28_VALUE 0x510
++#define MC_DC29_VALUE 0x4E20
++#define MC_DC30_VALUE 0x8235
++#define MC_DC31_VALUE 0x0
++#define MC_DC32_VALUE 0x0
++#define MC_DC33_VALUE 0x0
++#define MC_DC34_VALUE 0x0
++#define MC_DC35_VALUE 0x0
++#define MC_DC36_VALUE 0x0
++#define MC_DC37_VALUE 0x0
++#define MC_DC38_VALUE 0x0
++#define MC_DC39_VALUE 0x0
++#define MC_DC40_VALUE 0x0
++#define MC_DC41_VALUE 0x0
++#define MC_DC42_VALUE 0x0
++#define MC_DC43_VALUE 0x0
++#define MC_DC44_VALUE 0x0
++#define MC_DC45_VALUE 0x500
++#define MC_DC46_VALUE 0x0
+--- a/boards.cfg
++++ b/boards.cfg
+@@ -438,6 +438,8 @@ vct_premium mips
+ vct_premium_onenand mips mips32 vct micronas - vct:VCT_PREMIUM,VCT_ONENAND
+ vct_premium_onenand_small mips mips32 vct micronas - vct:VCT_PREMIUM,VCT_ONENAND,VCT_SMALL_IMAGE
+ vct_premium_small mips mips32 vct micronas - vct:VCT_PREMIUM,VCT_SMALL_IMAGE
++arv7518pw_ram mips mips32 arv7518pw arcadyan danube arv7518pw:SYS_BOOT_RAM
++arv7518pw_nor mips mips32 arv7518pw arcadyan danube arv7518pw:SYS_BOOT_NOR
+ dbau1000 mips mips32 dbau1x00 - au1x00 dbau1x00:DBAU1000
+ dbau1100 mips mips32 dbau1x00 - au1x00 dbau1x00:DBAU1100
+ dbau1500 mips mips32 dbau1x00 - au1x00 dbau1x00:DBAU1500
+--- /dev/null
++++ b/include/configs/arv7518pw.h
+@@ -0,0 +1,69 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2012 Luka Perkov <luka@openwrt.org>
++ */
++
++#ifndef __CONFIG_H
++#define __CONFIG_H
++
++#define CONFIG_MACH_TYPE "ARV7518PW"
++#define CONFIG_IDENT_STRING " "CONFIG_MACH_TYPE
++#define CONFIG_BOARD_NAME "Arcadyan ARV7518PW"
++
++/* Configure SoC */
++#define CONFIG_LTQ_SUPPORT_UART /* Enable ASC and UART */
++#define CONFIG_LTQ_SUPPORT_ETHERNET /* Enable ethernet */
++#define CONFIG_LTQ_SUPPORT_NOR_FLASH /* Have a parallel NOR flash */
++
++/* Switch devices */
++#define CONFIG_SWITCH_MULTI
++#define CONFIG_SWITCH_AR8216
++
++/* Environment */
++#if defined(CONFIG_SYS_BOOT_NOR)
++#define CONFIG_ENV_IS_IN_FLASH
++#define CONFIG_ENV_OVERWRITE
++#define CONFIG_ENV_OFFSET (192 * 1024)
++#define CONFIG_ENV_SIZE (64 * 1024)
++#define CONFIG_ENV_SECT_SIZE (64 * 1024)
++#else
++#define CONFIG_ENV_IS_NOWHERE
++#define CONFIG_ENV_SIZE (2 * 1024)
++#endif
++
++#define CONFIG_LOADADDR CONFIG_SYS_LOAD_ADDR
++
++/* Console */
++#define CONFIG_LTQ_ADVANCED_CONSOLE
++#define CONFIG_BAUDRATE 115200
++#define CONFIG_CONSOLE_ASC 1
++#define CONFIG_CONSOLE_DEV "ttyLTQ1"
++
++/* Commands */
++#define CONFIG_CMD_PING
++
++/* Pull in default board configs for Lantiq XWAY Danube */
++#include <asm/lantiq/config.h>
++#include <asm/arch/config.h>
++
++/* Compression */
++#define CONFIG_LZMA
++
++/* Auto boot */
++#define CONFIG_BOOTDELAY 2
++
++/* Environment configuration */
++#define CONFIG_BOOTCOMMAND \
++ "run addeth; bootm ${kernel_addr}"
++
++#define CONFIG_ENV_UPDATE_UBOOT_NOR \
++ "update-uboot-nor=run load-uboot-nor write-uboot-nor\0"
++
++#define CONFIG_EXTRA_ENV_SETTINGS \
++ CONFIG_ENV_LANTIQ_DEFAULTS \
++ CONFIG_ENV_UPDATE_UBOOT_NOR \
++ "kernel_addr=0xB0040000\0"
++
++#endif /* __CONFIG_H */
diff --git a/package/boot/uboot-lantiq/patches/.svn/text-base/0028-MIPS-add-board-support-for-Arcadyan-ARV4519.patch.svn-base b/package/boot/uboot-lantiq/patches/.svn/text-base/0028-MIPS-add-board-support-for-Arcadyan-ARV4519.patch.svn-base
new file mode 100644
index 0000000..4698e67
--- /dev/null
+++ b/package/boot/uboot-lantiq/patches/.svn/text-base/0028-MIPS-add-board-support-for-Arcadyan-ARV4519.patch.svn-base
@@ -0,0 +1,248 @@
+From 4a738c02a7190756e01ba58c93c4b07bc6d6c2aa Mon Sep 17 00:00:00 2001
+From: Luka Perkov <luka@openwrt.org>
+Date: Wed, 29 Aug 2012 22:08:42 +0200
+Subject: MIPS: add board support for Arcadyan ARV4519
+
+Signed-off-by: Luka Perkov <luka@openwrt.org>
+Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+
+--- /dev/null
++++ b/board/arcadyan/arv4519pw/Makefile
+@@ -0,0 +1,29 @@
++#
++# This file is released under the terms of GPL v2 and any later version.
++# See the file COPYING in the root directory of the source tree for details.
++#
++# Copyright (C) 2000-2011 Wolfgang Denk, DENX Software Engineering, wd@denx.de
++# Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++#
++
++include $(TOPDIR)/config.mk
++
++LIB = $(obj)lib$(BOARD).o
++
++COBJS = $(BOARD).o
++
++SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c)
++OBJS := $(addprefix $(obj),$(COBJS))
++SOBJS := $(addprefix $(obj),$(SOBJS))
++
++$(LIB): $(obj).depend $(OBJS) $(SOBJS)
++ $(call cmd_link_o_target, $(OBJS) $(SOBJS))
++
++#########################################################################
++
++# defines $(obj).depend target
++include $(SRCTREE)/rules.mk
++
++sinclude $(obj).depend
++
++#########################################################################
+--- /dev/null
++++ b/board/arcadyan/arv4519pw/arv4519pw.c
+@@ -0,0 +1,52 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2012 Luka Perkov <luka@openwrt.org>
++ */
++
++#include <common.h>
++#include <switch.h>
++#include <asm/gpio.h>
++#include <asm/lantiq/eth.h>
++#include <asm/lantiq/reset.h>
++#include <asm/lantiq/chipid.h>
++
++int board_early_init_f(void)
++{
++ return 0;
++}
++
++int checkboard(void)
++{
++ puts("Board: " CONFIG_BOARD_NAME "\n");
++ ltq_chip_print_info();
++
++ return 0;
++}
++
++static const struct ltq_eth_port_config eth_port_config[] = {
++ /* MAC0: Atheros ar8216 switch */
++ { 0, 0x0, LTQ_ETH_PORT_SWITCH, PHY_INTERFACE_MODE_NONE },
++};
++
++static const struct ltq_eth_board_config eth_board_config = {
++ .ports = eth_port_config,
++ .num_ports = ARRAY_SIZE(eth_port_config),
++};
++
++int board_eth_init(bd_t *bis)
++{
++ return ltq_eth_initialize(&eth_board_config);
++}
++
++static struct switch_device ar8216_dev = {
++ .name = "ar8216",
++ .cpu_port = 0,
++ .port_mask = 0xF,
++};
++
++int board_switch_init(void)
++{
++ return switch_device_register(&ar8216_dev);
++}
+--- /dev/null
++++ b/board/arcadyan/arv4519pw/config.mk
+@@ -0,0 +1,8 @@
++#
++# This file is released under the terms of GPL v2 and any later version.
++# See the file COPYING in the root directory of the source tree for details.
++#
++# Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++#
++
++PLATFORM_CPPFLAGS += -I$(TOPDIR)/board/$(BOARDDIR)
+--- /dev/null
++++ b/board/arcadyan/arv4519pw/ddr_settings.h
+@@ -0,0 +1,56 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * generated with lantiq_ram_extract_magic.awk
++ *
++ * Copyright (C) 2011 Luka Perkov <luka@openwrt.org>
++ */
++
++#define MC_DC00_VALUE 0x1B1B
++#define MC_DC01_VALUE 0x0
++#define MC_DC02_VALUE 0x0
++#define MC_DC03_VALUE 0x0
++#define MC_DC04_VALUE 0x0
++#define MC_DC05_VALUE 0x200
++#define MC_DC06_VALUE 0x605
++#define MC_DC07_VALUE 0x303
++#define MC_DC08_VALUE 0x102
++#define MC_DC09_VALUE 0x70A
++#define MC_DC10_VALUE 0x203
++#define MC_DC11_VALUE 0xC02
++#define MC_DC12_VALUE 0x1C8
++#define MC_DC13_VALUE 0x1
++#define MC_DC14_VALUE 0x0
++#define MC_DC15_VALUE 0x131
++#define MC_DC16_VALUE 0xC800
++#define MC_DC17_VALUE 0xD
++#define MC_DC18_VALUE 0x301
++#define MC_DC19_VALUE 0x200
++#define MC_DC20_VALUE 0xA04
++#define MC_DC21_VALUE 0x1700
++#define MC_DC22_VALUE 0x1717
++#define MC_DC23_VALUE 0x0
++#define MC_DC24_VALUE 0x5A
++#define MC_DC25_VALUE 0x0
++#define MC_DC26_VALUE 0x0
++#define MC_DC27_VALUE 0x0
++#define MC_DC28_VALUE 0x510
++#define MC_DC29_VALUE 0x4E20
++#define MC_DC30_VALUE 0x8235
++#define MC_DC31_VALUE 0x0
++#define MC_DC32_VALUE 0x0
++#define MC_DC33_VALUE 0x0
++#define MC_DC34_VALUE 0x0
++#define MC_DC35_VALUE 0x0
++#define MC_DC36_VALUE 0x0
++#define MC_DC37_VALUE 0x0
++#define MC_DC38_VALUE 0x0
++#define MC_DC39_VALUE 0x0
++#define MC_DC40_VALUE 0x0
++#define MC_DC41_VALUE 0x0
++#define MC_DC42_VALUE 0x0
++#define MC_DC43_VALUE 0x0
++#define MC_DC44_VALUE 0x0
++#define MC_DC45_VALUE 0x500
++#define MC_DC46_VALUE 0x0
+--- a/boards.cfg
++++ b/boards.cfg
+@@ -438,6 +438,8 @@ vct_premium mips
+ vct_premium_onenand mips mips32 vct micronas - vct:VCT_PREMIUM,VCT_ONENAND
+ vct_premium_onenand_small mips mips32 vct micronas - vct:VCT_PREMIUM,VCT_ONENAND,VCT_SMALL_IMAGE
+ vct_premium_small mips mips32 vct micronas - vct:VCT_PREMIUM,VCT_SMALL_IMAGE
++arv4519pw_ram mips mips32 arv4519pw arcadyan danube arv4519pw:SYS_BOOT_RAM
++arv4519pw_nor mips mips32 arv4519pw arcadyan danube arv4519pw:SYS_BOOT_NOR
+ arv7518pw_ram mips mips32 arv7518pw arcadyan danube arv7518pw:SYS_BOOT_RAM
+ arv7518pw_nor mips mips32 arv7518pw arcadyan danube arv7518pw:SYS_BOOT_NOR
+ dbau1000 mips mips32 dbau1x00 - au1x00 dbau1x00:DBAU1000
+--- /dev/null
++++ b/include/configs/arv4519pw.h
+@@ -0,0 +1,69 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2012 Luka Perkov <luka@openwrt.org>
++ */
++
++#ifndef __CONFIG_H
++#define __CONFIG_H
++
++#define CONFIG_MACH_TYPE "ARV4519PW"
++#define CONFIG_IDENT_STRING " "CONFIG_MACH_TYPE
++#define CONFIG_BOARD_NAME "Arcadyan ARV4519PW"
++
++/* Configure SoC */
++#define CONFIG_LTQ_SUPPORT_UART /* Enable ASC and UART */
++#define CONFIG_LTQ_SUPPORT_ETHERNET /* Enable ethernet */
++#define CONFIG_LTQ_SUPPORT_NOR_FLASH /* Have a parallel NOR flash */
++
++/* Switch devices */
++#define CONFIG_SWITCH_MULTI
++#define CONFIG_SWITCH_AR8216
++
++/* Environment */
++#if defined(CONFIG_SYS_BOOT_NOR)
++#define CONFIG_ENV_IS_IN_FLASH
++#define CONFIG_ENV_OVERWRITE
++#define CONFIG_ENV_OFFSET (192 * 1024)
++#define CONFIG_ENV_SIZE (64 * 1024)
++#define CONFIG_ENV_SECT_SIZE (64 * 1024)
++#else
++#define CONFIG_ENV_IS_NOWHERE
++#define CONFIG_ENV_SIZE (2 * 1024)
++#endif
++
++#define CONFIG_LOADADDR CONFIG_SYS_LOAD_ADDR
++
++/* Console */
++#define CONFIG_LTQ_ADVANCED_CONSOLE
++#define CONFIG_BAUDRATE 115200
++#define CONFIG_CONSOLE_ASC 1
++#define CONFIG_CONSOLE_DEV "ttyLTQ1"
++
++/* Commands */
++#define CONFIG_CMD_PING
++
++/* Pull in default board configs for Lantiq XWAY Danube */
++#include <asm/lantiq/config.h>
++#include <asm/arch/config.h>
++
++/* Compression */
++#define CONFIG_LZMA
++
++/* Auto boot */
++#define CONFIG_BOOTDELAY 2
++
++/* Environment configuration */
++#define CONFIG_BOOTCOMMAND \
++ "run addeth; bootm ${kernel_addr}"
++
++#define CONFIG_ENV_UPDATE_UBOOT_NOR \
++ "update-uboot-nor=run load-uboot-nor write-uboot-nor\0"
++
++#define CONFIG_EXTRA_ENV_SETTINGS \
++ CONFIG_ENV_LANTIQ_DEFAULTS \
++ CONFIG_ENV_UPDATE_UBOOT_NOR \
++ "kernel_addr=0xB0040000\0"
++
++#endif /* __CONFIG_H */
diff --git a/package/boot/uboot-lantiq/patches/.svn/text-base/0029-tools-add-some-helper-tools-for-Lantiq-SoCs.patch.svn-base b/package/boot/uboot-lantiq/patches/.svn/text-base/0029-tools-add-some-helper-tools-for-Lantiq-SoCs.patch.svn-base
new file mode 100644
index 0000000..77d48d1
--- /dev/null
+++ b/package/boot/uboot-lantiq/patches/.svn/text-base/0029-tools-add-some-helper-tools-for-Lantiq-SoCs.patch.svn-base
@@ -0,0 +1,361 @@
+From 1b77d4249b5addbf3b0848db6992a445019a1865 Mon Sep 17 00:00:00 2001
+From: Luka Perkov <luka@openwrt.org>
+Date: Wed, 29 Aug 2012 22:08:42 +0200
+Subject: tools: add some helper tools for Lantiq SoCs
+
+Signed-off-by: Luka Perkov Luka Perkov <luka@openwrt.org>
+Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+
+--- /dev/null
++++ b/tools/gct.pl
+@@ -0,0 +1,155 @@
++#!/usr/bin/perl
++
++#use strict;
++#use Cwd;
++#use Env;
++
++my $aline;
++my $lineid;
++my $length;
++my $address;
++my @bytes;
++my $addstr;
++my $chsum=0;
++my $count=0;
++my $firstime=1;
++my $i;
++my $currentaddr;
++my $tmp;
++my $holder="";
++my $loadaddr;
++
++if(@ARGV < 2){
++ die("\n Syntax: perl gct.pl uart_ddr_settings.conf u-boot.srec u-boot.asc\n");
++}
++
++open(IN_UART_DDR_SETTINGS, "<$ARGV[0]") || die("failed to open uart_ddr_settings.conf\n");
++open(IN_UART_SREC, "<$ARGV[1]") || die("failed to open u-boot.srec\n");
++open(OUT_UBOOT_ASC, ">$ARGV[2]") || die("failed to open u-boot.asc\n");
++
++$i=0;
++while ($line = <IN_UART_DDR_SETTINGS>){
++ if($line=~/\w/){
++ if($line!~/[;#\*]/){
++ if($i eq 0){
++ printf OUT_UBOOT_ASC ("33333333");
++ }
++ chomp($line);
++ $line=~s/\t//;
++ @array=split(/ +/,$line);
++ $j=0;
++ while(@array[$j]!~/\w/){
++ $j=$j+1;
++ }
++ $addr=@array[$j];
++ $regval=@array[$j+1];
++ $addr=~s/0x//;
++ $regval=~s/0x//;
++ printf OUT_UBOOT_ASC ("%08x%08x",hex($addr),hex($regval));
++ $i=$i+1;
++ if($i eq 8){
++ $i=0;
++ printf OUT_UBOOT_ASC ("\n");
++ }
++ }
++ }
++}
++
++while($i lt 8 && $i gt 0){
++ printf OUT_UBOOT_ASC "00"x8;
++ $i=$i+1;
++}
++
++if($i eq 8){
++ printf OUT_UBOOT_ASC ("\n");
++}
++
++while($aline=<IN_UART_SREC>){
++ $aline=uc($aline);
++ chomp($aline);
++ next if(($aline=~/^S0/) || ($aline=~/^S7/));
++ ($lineid, $length, $address, @bytes) = unpack"A2A2A8"."A2"x300, $aline;
++ $length = hex($length);
++ $address = hex($address);
++ $length -=5;
++ $i=0;
++
++ while($length>0){
++ if($firstime==1){
++ $addstr = sprintf("%x", $address);
++ $addstr = "0"x(8-length($addstr)).$addstr;
++ print OUT_UBOOT_ASC $addstr;
++ addchsum($addstr);
++ $firstime=0;
++ $currentaddr=$address;
++ $loadaddr = $addstr;
++ }
++ else{
++ if($count==64){
++ $addstr = sprintf("%x", $currentaddr);
++ $addstr = "0"x(8-length($addstr)).$addstr;
++ print OUT_UBOOT_ASC $addstr;
++ addchsum($addstr);
++ $count=0;
++ }
++#printf("*** %x != %x\n", $address, $currentaddr) if $address != $currentaddr;
++ }
++ if($currentaddr < $address) {
++ print OUT_UBOOT_ASC "00";
++ addchsum("00");
++ $count++;
++ $currentaddr++;
++ }
++ else {
++ while($count<64){
++ $bytes[$i]=~tr/ABCDEF/abcdef/;
++ print OUT_UBOOT_ASC "$bytes[$i]";
++ addchsum($bytes[$i]);
++ $i++;
++ $count++;
++ $currentaddr++;
++ $length--;
++ last if($length==0);
++ }
++ }
++ if($count==64){
++ print OUT_UBOOT_ASC "\n";
++ }
++ }
++}
++if($count != 64){
++ $tmp = "00";
++ for($i=0;$i<(64-$count);$i++){
++ print OUT_UBOOT_ASC "00";
++ addchsum($tmp);
++ }
++ print OUT_UBOOT_ASC "\n";
++}
++
++
++print OUT_UBOOT_ASC "11"x4;
++use integer;
++$chsum=$chsum & 0xffffffff;
++$chsum = sprintf("%X", $chsum);
++$chsum = "0"x(8-length($chsum)).$chsum;
++$chsum =~tr/ABCDEF/abcdef/;
++print OUT_UBOOT_ASC $chsum;
++print OUT_UBOOT_ASC "00"x60;
++print OUT_UBOOT_ASC "\n";
++
++print OUT_UBOOT_ASC "99"x4;
++print OUT_UBOOT_ASC $loadaddr;
++print OUT_UBOOT_ASC "00"x60;
++print OUT_UBOOT_ASC "\n";
++
++close OUT_UBOOT_ASC;
++
++sub addchsum{
++ my $cc=$_[0];
++ $holder=$holder.$cc;
++ if(length($holder)==8){
++ $holder = hex($holder);
++ $chsum+=$holder;
++ $holder="";
++ }
++}
+--- /dev/null
++++ b/tools/lantiq_extract_openwrt_patches.sh
+@@ -0,0 +1,15 @@
++#!/bin/bash
++
++set -e
++set -x
++
++test $# -eq 1
++
++openwrt_root=$(readlink -f $1)
++test -d $openwrt_root
++
++uboot_lantiq_dir=$openwrt_root/package/boot/uboot-lantiq/patches
++test -d $uboot_lantiq_dir
++
++rm -vf $uboot_lantiq_dir/*
++git format-patch -k -p --no-renames --text --full-index -o $uboot_lantiq_dir v2012.10..openwrt/v2013.01
+--- /dev/null
++++ b/tools/lantiq_ram_extract_magic.awk
+@@ -0,0 +1,70 @@
++#
++# This file is released under the terms of GPL v2 and any later version.
++# See the file COPYING in the root directory of the source tree for details.
++#
++# Copyright (C) 2011 Luka Perkov <luka@openwrt.org>
++#
++# usage: mips-openwrt-linux-objdump -EB -b binary -m mips:isa32r2 -D YOUR_IMAGE_DUMP | awk -f lantiq_ram_extract_magic.awk
++#
++
++BEGIN {
++ print "/* "
++ print " * This file is released under the terms of GPL v2 and any later version. "
++ print " * See the file COPYING in the root directory of the source tree for details. "
++ print " * "
++ print " * generated with lantiq_ram_extract_magic.awk "
++ print " * "
++ print " * Copyright (C) 2011 Luka Perkov <luka@openwrt.org> "
++ print " */ "
++ print ""
++
++ mc_dc_value=0
++ mc_dc_number=0
++ right_section=0
++ mc_dc_value_print=0
++ mc_dc_number_print=0
++}
++
++/t2,[0-9]+$/ {
++ if (right_section) {
++ split($4, tmp, ",")
++ mc_dc_value=sprintf("%X", tmp[2])
++ mc_dc_value_print=1
++ }
++}
++
++/t2,0x[0-9a-f]+$/ {
++ if (right_section) {
++ split($4, tmp, ",0x")
++ mc_dc_value=sprintf("%s", tmp[2])
++ mc_dc_value=toupper(mc_dc_value)
++ mc_dc_value_print=1
++ }
++}
++
++/t2,[0-9]+\(t1\)$/ {
++ if (right_section) {
++ split($4, tmp, ",")
++ split(tmp[2], tmp, "(")
++ mc_dc_number=tmp[1]/16
++ mc_dc_number_print=1
++ }
++}
++
++{
++ if (right_section && mc_dc_number_print && mc_dc_value_print) {
++ if (mc_dc_number < 10)
++ print "#define MC_DC0" mc_dc_number "_VALUE\t0x" mc_dc_value
++ else
++ print "#define MC_DC" mc_dc_number "_VALUE\t0x" mc_dc_value
++ mc_dc_value_print=0
++ mc_dc_number_print=0
++ }
++
++ if ($4 == "t1,t1,0x1000")
++ right_section=1
++
++
++ if ($4 == "t2,736(t1)")
++ right_section=0
++}
+--- /dev/null
++++ b/tools/lantiq_ram_init_uart.awk
+@@ -0,0 +1,101 @@
++#!/usr/bin/awk -f
++#
++# This file is released under the terms of GPL v2 and any later version.
++# See the file COPYING in the root directory of the source tree for details.
++#
++# Copyright (C) 2011-2012 Luka Perkov <luka@openwrt.org>
++# Copyright (C) 2012 Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
++#
++# usage: awk -f lantiq_ram_init_uart.awk -v soc=<danube|ar9|vr9> PATH_TO_BOARD/ddr_settings.h
++#
++
++function print_header()
++{
++ print "; "
++ print "; This file is released under the terms of GPL v2 and any later version. "
++ print "; See the file COPYING in the root directory of the source tree for details. "
++ print "; "
++ print "; generated with lantiq_ram_init_uart.awk "
++ print "; "
++ print "; Copyright (C) 2011-2012 Luka Perkov <luka@openwrt.org> "
++ print "; Copyright (C) 2012 Daniel Schwierzeck <daniel.schwierzeck@gmail.com> "
++ print "; "
++ print ""
++}
++
++function mc_ddr1_prologue()
++{
++ /* Clear access error log registers */
++ print "0xbf800010", "0x0"
++ print "0xbf800020", "0x0"
++
++ /* Enable DDR and SRAM module in memory controller */
++ print "0xbf800060", "0x5"
++
++ /* Clear start bit of DDR memory controller */
++ print "0xbf801030", "0x0"
++}
++
++function mc_ddr1_epilogue()
++{
++ /* Set start bit of DDR memory controller */
++ print "0xbf801030", "0x100"
++}
++
++function mc_ddr2_prologue()
++{
++ /* Put memory controller in inactive mode */
++ print "0xbf401070", "0x0"
++}
++
++function mc_ddr2_epilogue(mc_ccr07_value)
++{
++ /* Put memory controller in active mode */
++ mc_ccr07_value = or(mc_ccr07_value, 0x100)
++ printf("0xbf401070 0x%x\n", mc_ccr07_value)
++}
++
++BEGIN {
++ switch (soc) {
++ case "danube":
++ case "ar9":
++ reg_base = 0xbf801000
++ print_header()
++ mc_ddr1_prologue()
++ break
++ case "vr9":
++ reg_base = 0xbf401000
++ print_header()
++ mc_ddr2_prologue()
++ break
++ default:
++ print "Invalid or no value for soc specified!"
++ exit 1
++ }
++
++ mc_ccr07_value = 0
++}
++
++/^#define/ {
++ printf("0x%x %s\n", reg_base, tolower($3))
++ reg_base += 0x10
++}
++
++/^#define(.*)MC_CCR07_VALUE/ {
++ printf("0x%x %s\n", reg_base, tolower($3))
++ reg_base += 0x10
++ mc_ccr07_value = strtonum($3)
++}
++
++END {
++ switch (soc) {
++ case "danube":
++ case "ar9":
++ mc_ddr1_epilogue()
++ break
++ case "vr9":
++ mc_ddr2_epilogue(mc_ccr07_value)
++ break
++ default:
++ }
++}
diff --git a/package/boot/uboot-lantiq/patches/0002-sf-handle-CONFIG_MANUAL_RELOC.patch b/package/boot/uboot-lantiq/patches/0002-sf-handle-CONFIG_MANUAL_RELOC.patch
new file mode 100644
index 0000000..63a21af
--- /dev/null
+++ b/package/boot/uboot-lantiq/patches/0002-sf-handle-CONFIG_MANUAL_RELOC.patch
@@ -0,0 +1,46 @@
+From 60e8a35f0efa5a7e5d797a3f239971c84061ef11 Mon Sep 17 00:00:00 2001
+From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+Date: Tue, 6 Nov 2012 21:39:47 +0100
+Subject: sf: handle CONFIG_MANUAL_RELOC
+
+Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+
+--- a/drivers/mtd/spi/spi_flash.c
++++ b/drivers/mtd/spi/spi_flash.c
+@@ -293,7 +293,7 @@ int spi_flash_cmd_write_status(struct sp
+ */
+ #define IDCODE_CONT_LEN 0
+ #define IDCODE_PART_LEN 5
+-static const struct {
++static struct {
+ const u8 shift;
+ const u8 idcode;
+ struct spi_flash *(*probe) (struct spi_slave *spi, u8 *idcode);
+@@ -335,6 +335,10 @@ static const struct {
+ };
+ #define IDCODE_LEN (IDCODE_CONT_LEN + IDCODE_PART_LEN)
+
++#ifdef CONFIG_NEEDS_MANUAL_RELOC
++DECLARE_GLOBAL_DATA_PTR;
++#endif
++
+ struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
+ unsigned int max_hz, unsigned int spi_mode)
+ {
+@@ -342,6 +346,16 @@ struct spi_flash *spi_flash_probe(unsign
+ struct spi_flash *flash = NULL;
+ int ret, i, shift;
+ u8 idcode[IDCODE_LEN], *idp;
++#ifdef CONFIG_NEEDS_MANUAL_RELOC
++ static int relocated;
++
++ if (!relocated) {
++ for (i = 0; i < ARRAY_SIZE(flashes); i++)
++ flashes[i].probe += gd->reloc_off;
++
++ relocated = 1;
++ }
++#endif
+
+ spi = spi_setup_slave(bus, cs, max_hz, spi_mode);
+ if (!spi) {
diff --git a/package/boot/uboot-lantiq/patches/0003-sf-factor-out-malloc-from-SPI-flash-drivers.patch b/package/boot/uboot-lantiq/patches/0003-sf-factor-out-malloc-from-SPI-flash-drivers.patch
new file mode 100644
index 0000000..7f44675
--- /dev/null
+++ b/package/boot/uboot-lantiq/patches/0003-sf-factor-out-malloc-from-SPI-flash-drivers.patch
@@ -0,0 +1,719 @@
+From 73d127565b5a4b19bcaacabc505689ee039f16fd Mon Sep 17 00:00:00 2001
+From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+Date: Sun, 11 Nov 2012 03:11:38 +0100
+Subject: sf: factor out malloc from SPI flash drivers
+
+Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+
+--- a/drivers/mtd/spi/atmel.c
++++ b/drivers/mtd/spi/atmel.c
+@@ -40,18 +40,6 @@ struct atmel_spi_flash_params {
+ const char *name;
+ };
+
+-/* spi_flash needs to be first so upper layers can free() it */
+-struct atmel_spi_flash {
+- struct spi_flash flash;
+- const struct atmel_spi_flash_params *params;
+-};
+-
+-static inline struct atmel_spi_flash *
+-to_atmel_spi_flash(struct spi_flash *flash)
+-{
+- return container_of(flash, struct atmel_spi_flash, flash);
+-}
+-
+ static const struct atmel_spi_flash_params atmel_spi_flash_table[] = {
+ {
+ .idcode1 = 0x22,
+@@ -156,7 +144,8 @@ static int at45_wait_ready(struct spi_fl
+ * Assemble the address part of a command for AT45 devices in
+ * non-power-of-two page size mode.
+ */
+-static void at45_build_address(struct atmel_spi_flash *asf, u8 *cmd, u32 offset)
++static void at45_build_address(const struct atmel_spi_flash_params *params,
++ u8 *cmd, u32 offset)
+ {
+ unsigned long page_addr;
+ unsigned long byte_addr;
+@@ -167,7 +156,7 @@ static void at45_build_address(struct at
+ * The "extra" space per page is the power-of-two page size
+ * divided by 32.
+ */
+- page_shift = asf->params->l2_page_size;
++ page_shift = params->l2_page_size;
+ page_size = (1 << page_shift) + (1 << (page_shift - 5));
+ page_shift++;
+ page_addr = offset / page_size;
+@@ -181,11 +170,11 @@ static void at45_build_address(struct at
+ static int dataflash_read_fast_at45(struct spi_flash *flash,
+ u32 offset, size_t len, void *buf)
+ {
+- struct atmel_spi_flash *asf = to_atmel_spi_flash(flash);
++ const struct atmel_spi_flash_params *params = flash->priv;
+ u8 cmd[5];
+
+ cmd[0] = CMD_READ_ARRAY_FAST;
+- at45_build_address(asf, cmd + 1, offset);
++ at45_build_address(params, cmd + 1, offset);
+ cmd[4] = 0x00;
+
+ return spi_flash_read_common(flash, cmd, sizeof(cmd), buf, len);
+@@ -197,7 +186,7 @@ static int dataflash_read_fast_at45(stru
+ static int dataflash_write_p2(struct spi_flash *flash,
+ u32 offset, size_t len, const void *buf)
+ {
+- struct atmel_spi_flash *asf = to_atmel_spi_flash(flash);
++ const struct atmel_spi_flash_params *params = flash->priv;
+ unsigned long page_size;
+ u32 addr = offset;
+ size_t chunk_len;
+@@ -211,7 +200,7 @@ static int dataflash_write_p2(struct spi
+ * the other is being programmed into main memory.
+ */
+
+- page_size = (1 << asf->params->l2_page_size);
++ page_size = (1 << params->l2_page_size);
+
+ ret = spi_claim_bus(flash->spi);
+ if (ret) {
+@@ -263,7 +252,7 @@ out:
+ static int dataflash_write_at45(struct spi_flash *flash,
+ u32 offset, size_t len, const void *buf)
+ {
+- struct atmel_spi_flash *asf = to_atmel_spi_flash(flash);
++ const struct atmel_spi_flash_params *params = flash->priv;
+ unsigned long page_addr;
+ unsigned long byte_addr;
+ unsigned long page_size;
+@@ -279,7 +268,7 @@ static int dataflash_write_at45(struct s
+ * the other is being programmed into main memory.
+ */
+
+- page_shift = asf->params->l2_page_size;
++ page_shift = params->l2_page_size;
+ page_size = (1 << page_shift) + (1 << (page_shift - 5));
+ page_shift++;
+ page_addr = offset / page_size;
+@@ -338,7 +327,7 @@ out:
+ */
+ static int dataflash_erase_p2(struct spi_flash *flash, u32 offset, size_t len)
+ {
+- struct atmel_spi_flash *asf = to_atmel_spi_flash(flash);
++ const struct atmel_spi_flash_params *params = flash->priv;
+ unsigned long page_size;
+
+ size_t actual;
+@@ -351,7 +340,7 @@ static int dataflash_erase_p2(struct spi
+ * when possible.
+ */
+
+- page_size = (1 << asf->params->l2_page_size);
++ page_size = (1 << params->l2_page_size);
+
+ if (offset % page_size || len % page_size) {
+ debug("SF: Erase offset/length not multiple of page size\n");
+@@ -397,7 +386,7 @@ out:
+
+ static int dataflash_erase_at45(struct spi_flash *flash, u32 offset, size_t len)
+ {
+- struct atmel_spi_flash *asf = to_atmel_spi_flash(flash);
++ const struct atmel_spi_flash_params *params = flash->priv;
+ unsigned long page_addr;
+ unsigned long page_size;
+ unsigned int page_shift;
+@@ -411,7 +400,7 @@ static int dataflash_erase_at45(struct s
+ * when possible.
+ */
+
+- page_shift = asf->params->l2_page_size;
++ page_shift = params->l2_page_size;
+ page_size = (1 << page_shift) + (1 << (page_shift - 5));
+ page_shift++;
+ page_addr = offset / page_size;
+@@ -458,12 +447,12 @@ out:
+ return ret;
+ }
+
+-struct spi_flash *spi_flash_probe_atmel(struct spi_slave *spi, u8 *idcode)
++int spi_flash_probe_atmel(struct spi_flash *flash, u8 *idcode)
+ {
+ const struct atmel_spi_flash_params *params;
++ struct spi_slave *spi = flash->spi;
+ unsigned page_size;
+ unsigned int family;
+- struct atmel_spi_flash *asf;
+ unsigned int i;
+ int ret;
+ u8 status;
+@@ -477,18 +466,11 @@ struct spi_flash *spi_flash_probe_atmel(
+ if (i == ARRAY_SIZE(atmel_spi_flash_table)) {
+ debug("SF: Unsupported DataFlash ID %02x\n",
+ idcode[1]);
+- return NULL;
+- }
+-
+- asf = malloc(sizeof(struct atmel_spi_flash));
+- if (!asf) {
+- debug("SF: Failed to allocate memory\n");
+- return NULL;
++ return 0;
+ }
+
+- asf->params = params;
+- asf->flash.spi = spi;
+- asf->flash.name = params->name;
++ flash->priv = (void *)params;
++ flash->name = params->name;
+
+ /* Assuming power-of-two page size initially. */
+ page_size = 1 << params->l2_page_size;
+@@ -503,48 +485,44 @@ struct spi_flash *spi_flash_probe_atmel(
+ */
+ ret = spi_flash_cmd(spi, CMD_AT45_READ_STATUS, &status, 1);
+ if (ret)
+- goto err;
++ return -1;
+
+ debug("SF: AT45 status register: %02x\n", status);
+
+ if (!(status & AT45_STATUS_P2_PAGE_SIZE)) {
+- asf->flash.read = dataflash_read_fast_at45;
+- asf->flash.write = dataflash_write_at45;
+- asf->flash.erase = dataflash_erase_at45;
++ flash->read = dataflash_read_fast_at45;
++ flash->write = dataflash_write_at45;
++ flash->erase = dataflash_erase_at45;
+ page_size += 1 << (params->l2_page_size - 5);
+ } else {
+- asf->flash.read = spi_flash_cmd_read_fast;
+- asf->flash.write = dataflash_write_p2;
+- asf->flash.erase = dataflash_erase_p2;
++ flash->read = spi_flash_cmd_read_fast;
++ flash->write = dataflash_write_p2;
++ flash->erase = dataflash_erase_p2;
+ }
+
+- asf->flash.page_size = page_size;
+- asf->flash.sector_size = page_size;
++ flash->page_size = page_size;
++ flash->sector_size = page_size;
+ break;
+
+ case DF_FAMILY_AT26F:
+ case DF_FAMILY_AT26DF:
+- asf->flash.read = spi_flash_cmd_read_fast;
+- asf->flash.write = spi_flash_cmd_write_multi;
+- asf->flash.erase = spi_flash_cmd_erase;
+- asf->flash.page_size = page_size;
+- asf->flash.sector_size = 4096;
++ flash->read = spi_flash_cmd_read_fast;
++ flash->write = spi_flash_cmd_write_multi;
++ flash->erase = spi_flash_cmd_erase;
++ flash->page_size = page_size;
++ flash->sector_size = 4096;
+ /* clear SPRL# bit for locked flash */
+- spi_flash_cmd_write_status(&asf->flash, 0);
++ spi_flash_cmd_write_status(flash, 0);
+ break;
+
+ default:
+ debug("SF: Unsupported DataFlash family %u\n", family);
+- goto err;
++ return -1;
+ }
+
+- asf->flash.size = page_size * params->pages_per_block
++ flash->size = page_size * params->pages_per_block
+ * params->blocks_per_sector
+ * params->nr_sectors;
+
+- return &asf->flash;
+-
+-err:
+- free(asf);
+- return NULL;
++ return 1;
+ }
+--- a/drivers/mtd/spi/eon.c
++++ b/drivers/mtd/spi/eon.c
+@@ -29,10 +29,9 @@ static const struct eon_spi_flash_params
+ },
+ };
+
+-struct spi_flash *spi_flash_probe_eon(struct spi_slave *spi, u8 *idcode)
++int spi_flash_probe_eon(struct spi_flash *flash, u8 *idcode)
+ {
+ const struct eon_spi_flash_params *params;
+- struct spi_flash *flash;
+ unsigned int i;
+
+ for (i = 0; i < ARRAY_SIZE(eon_spi_flash_table); ++i) {
+@@ -43,16 +42,10 @@ struct spi_flash *spi_flash_probe_eon(st
+
+ if (i == ARRAY_SIZE(eon_spi_flash_table)) {
+ debug("SF: Unsupported EON ID %02x\n", idcode[1]);
+- return NULL;
++ return 0;
+ }
+
+- flash = malloc(sizeof(*flash));
+- if (!flash) {
+- debug("SF: Failed to allocate memory\n");
+- return NULL;
+- }
+-
+- flash->spi = spi;
++ flash->priv = (void *)params;
+ flash->name = params->name;
+
+ flash->write = spi_flash_cmd_write_multi;
+@@ -63,5 +56,5 @@ struct spi_flash *spi_flash_probe_eon(st
+ flash->size = 256 * 16
+ * params->nr_sectors;
+
+- return flash;
++ return 1;
+ }
+--- a/drivers/mtd/spi/macronix.c
++++ b/drivers/mtd/spi/macronix.c
+@@ -79,10 +79,9 @@ static const struct macronix_spi_flash_p
+ },
+ };
+
+-struct spi_flash *spi_flash_probe_macronix(struct spi_slave *spi, u8 *idcode)
++int spi_flash_probe_macronix(struct spi_flash *flash, u8 *idcode)
+ {
+ const struct macronix_spi_flash_params *params;
+- struct spi_flash *flash;
+ unsigned int i;
+ u16 id = idcode[2] | idcode[1] << 8;
+
+@@ -94,16 +93,10 @@ struct spi_flash *spi_flash_probe_macron
+
+ if (i == ARRAY_SIZE(macronix_spi_flash_table)) {
+ debug("SF: Unsupported Macronix ID %04x\n", id);
+- return NULL;
++ return 0;
+ }
+
+- flash = malloc(sizeof(*flash));
+- if (!flash) {
+- debug("SF: Failed to allocate memory\n");
+- return NULL;
+- }
+-
+- flash->spi = spi;
++ flash->priv = (void *)params;
+ flash->name = params->name;
+
+ flash->write = spi_flash_cmd_write_multi;
+@@ -116,5 +109,5 @@ struct spi_flash *spi_flash_probe_macron
+ /* Clear BP# bits for read-only flash */
+ spi_flash_cmd_write_status(flash, 0);
+
+- return flash;
++ return 1;
+ }
+--- a/drivers/mtd/spi/ramtron.c
++++ b/drivers/mtd/spi/ramtron.c
+@@ -69,17 +69,6 @@ struct ramtron_spi_fram_params {
+ const char *name; /* name for display and/or matching */
+ };
+
+-struct ramtron_spi_fram {
+- struct spi_flash flash;
+- const struct ramtron_spi_fram_params *params;
+-};
+-
+-static inline struct ramtron_spi_fram *to_ramtron_spi_fram(struct spi_flash
+- *flash)
+-{
+- return container_of(flash, struct ramtron_spi_fram, flash);
+-}
+-
+ /*
+ * table describing supported FRAM chips:
+ * chips without RDID command must have the values 0xff for id1 and id2
+@@ -155,18 +144,18 @@ static const struct ramtron_spi_fram_par
+ static int ramtron_common(struct spi_flash *flash,
+ u32 offset, size_t len, void *buf, u8 command)
+ {
+- struct ramtron_spi_fram *sn = to_ramtron_spi_fram(flash);
++ const struct ramtron_spi_fram_params *params = flash->priv;
+ u8 cmd[4];
+ int cmd_len;
+ int ret;
+
+- if (sn->params->addr_len == 3 && sn->params->merge_cmd == 0) {
++ if (params->addr_len == 3 && params->merge_cmd == 0) {
+ cmd[0] = command;
+ cmd[1] = offset >> 16;
+ cmd[2] = offset >> 8;
+ cmd[3] = offset;
+ cmd_len = 4;
+- } else if (sn->params->addr_len == 2 && sn->params->merge_cmd == 0) {
++ } else if (params->addr_len == 2 && params->merge_cmd == 0) {
+ cmd[0] = command;
+ cmd[1] = offset >> 8;
+ cmd[2] = offset;
+@@ -230,10 +219,9 @@ static int ramtron_erase(struct spi_flas
+ * nore: we are called here with idcode pointing to the first non-0x7f byte
+ * already!
+ */
+-struct spi_flash *spi_fram_probe_ramtron(struct spi_slave *spi, u8 *idcode)
++int spi_fram_probe_ramtron(struct spi_flash *flash, u8 *idcode)
+ {
+ const struct ramtron_spi_fram_params *params;
+- struct ramtron_spi_fram *sn;
+ unsigned int i;
+ #ifdef CONFIG_SPI_FRAM_RAMTRON_NON_JEDEC
+ int ret;
+@@ -259,11 +247,11 @@ struct spi_flash *spi_fram_probe_ramtron
+ */
+ ret = spi_flash_cmd(spi, CMD_READ_STATUS, &sr, 1);
+ if (ret)
+- return NULL;
++ return 0;
+
+ /* Bits 5,4,0 are fixed 0 for all devices */
+ if ((sr & 0x31) != 0x00)
+- return NULL;
++ return 0;
+ /* now find the device */
+ for (i = 0; i < ARRAY_SIZE(ramtron_spi_fram_table); i++) {
+ params = &ramtron_spi_fram_table[i];
+@@ -281,23 +269,16 @@ struct spi_flash *spi_fram_probe_ramtron
+ /* arriving here means no method has found a device we can handle */
+ debug("SF/ramtron: unsupported device id0=%02x id1=%02x id2=%02x\n",
+ idcode[0], idcode[1], idcode[2]);
+- return NULL;
++ return 0;
+
+ found:
+- sn = malloc(sizeof(*sn));
+- if (!sn) {
+- debug("SF: Failed to allocate memory\n");
+- return NULL;
+- }
++ flash->priv = (void *)params;
++ flash->name = params->name;
+
+- sn->params = params;
+- sn->flash.spi = spi;
+- sn->flash.name = params->name;
+-
+- sn->flash.write = ramtron_write;
+- sn->flash.read = ramtron_read;
+- sn->flash.erase = ramtron_erase;
+- sn->flash.size = params->size;
++ flash->write = ramtron_write;
++ flash->read = ramtron_read;
++ flash->erase = ramtron_erase;
++ flash->size = params->size;
+
+- return &sn->flash;
++ return 1;
+ }
+--- a/drivers/mtd/spi/spansion.c
++++ b/drivers/mtd/spi/spansion.c
+@@ -105,10 +105,9 @@ static const struct spansion_spi_flash_p
+ },
+ };
+
+-struct spi_flash *spi_flash_probe_spansion(struct spi_slave *spi, u8 *idcode)
++int spi_flash_probe_spansion(struct spi_flash *flash, u8 *idcode)
+ {
+ const struct spansion_spi_flash_params *params;
+- struct spi_flash *flash;
+ unsigned int i;
+ unsigned short jedec, ext_jedec;
+
+@@ -125,16 +124,10 @@ struct spi_flash *spi_flash_probe_spansi
+
+ if (i == ARRAY_SIZE(spansion_spi_flash_table)) {
+ debug("SF: Unsupported SPANSION ID %04x %04x\n", jedec, ext_jedec);
+- return NULL;
++ return 0;
+ }
+
+- flash = malloc(sizeof(*flash));
+- if (!flash) {
+- debug("SF: Failed to allocate memory\n");
+- return NULL;
+- }
+-
+- flash->spi = spi;
++ flash->priv = (void *)params;
+ flash->name = params->name;
+
+ flash->write = spi_flash_cmd_write_multi;
+@@ -144,5 +137,5 @@ struct spi_flash *spi_flash_probe_spansi
+ flash->sector_size = 256 * params->pages_per_sector;
+ flash->size = flash->sector_size * params->nr_sectors;
+
+- return flash;
++ return 1;
+ }
+--- a/drivers/mtd/spi/spi_flash.c
++++ b/drivers/mtd/spi/spi_flash.c
+@@ -296,7 +296,7 @@ int spi_flash_cmd_write_status(struct sp
+ static struct {
+ const u8 shift;
+ const u8 idcode;
+- struct spi_flash *(*probe) (struct spi_slave *spi, u8 *idcode);
++ int (*probe) (struct spi_flash *flash, u8 *idcode);
+ } flashes[] = {
+ /* Keep it sorted by define name */
+ #ifdef CONFIG_SPI_FLASH_ATMEL
+@@ -343,7 +343,7 @@ struct spi_flash *spi_flash_probe(unsign
+ unsigned int max_hz, unsigned int spi_mode)
+ {
+ struct spi_slave *spi;
+- struct spi_flash *flash = NULL;
++ struct spi_flash *flash;
+ int ret, i, shift;
+ u8 idcode[IDCODE_LEN], *idp;
+ #ifdef CONFIG_NEEDS_MANUAL_RELOC
+@@ -379,6 +379,15 @@ struct spi_flash *spi_flash_probe(unsign
+ print_buffer(0, idcode, 1, sizeof(idcode), 0);
+ #endif
+
++ flash = malloc(sizeof(*flash));
++ if (!flash) {
++ debug("SF: failed to alloc memory\n");
++ goto err_malloc;
++ }
++
++ memset(flash, 0, sizeof(*flash));
++ flash->spi = spi;
++
+ /* count the number of continuation bytes */
+ for (shift = 0, idp = idcode;
+ shift < IDCODE_CONT_LEN && *idp == 0x7f;
+@@ -389,12 +398,12 @@ struct spi_flash *spi_flash_probe(unsign
+ for (i = 0; i < ARRAY_SIZE(flashes); ++i)
+ if (flashes[i].shift == shift && flashes[i].idcode == *idp) {
+ /* we have a match, call probe */
+- flash = flashes[i].probe(spi, idp);
+- if (flash)
++ ret = flashes[i].probe(flash, idp);
++ if (ret)
+ break;
+ }
+
+- if (!flash) {
++ if (ret <= 0) {
+ printf("SF: Unsupported manufacturer %02x\n", *idp);
+ goto err_manufacturer_probe;
+ }
+@@ -408,6 +417,8 @@ struct spi_flash *spi_flash_probe(unsign
+ return flash;
+
+ err_manufacturer_probe:
++ free(flash);
++err_malloc:
+ err_read_id:
+ spi_release_bus(spi);
+ err_claim_bus:
+--- a/drivers/mtd/spi/spi_flash_internal.h
++++ b/drivers/mtd/spi/spi_flash_internal.h
+@@ -98,11 +98,11 @@ int spi_flash_cmd_wait_ready(struct spi_
+ int spi_flash_cmd_erase(struct spi_flash *flash, u32 offset, size_t len);
+
+ /* Manufacturer-specific probe functions */
+-struct spi_flash *spi_flash_probe_spansion(struct spi_slave *spi, u8 *idcode);
+-struct spi_flash *spi_flash_probe_atmel(struct spi_slave *spi, u8 *idcode);
+-struct spi_flash *spi_flash_probe_eon(struct spi_slave *spi, u8 *idcode);
+-struct spi_flash *spi_flash_probe_macronix(struct spi_slave *spi, u8 *idcode);
+-struct spi_flash *spi_flash_probe_sst(struct spi_slave *spi, u8 *idcode);
+-struct spi_flash *spi_flash_probe_stmicro(struct spi_slave *spi, u8 *idcode);
+-struct spi_flash *spi_flash_probe_winbond(struct spi_slave *spi, u8 *idcode);
+-struct spi_flash *spi_fram_probe_ramtron(struct spi_slave *spi, u8 *idcode);
++int spi_flash_probe_spansion(struct spi_flash *flash, u8 *idcode);
++int spi_flash_probe_atmel(struct spi_flash *flash, u8 *idcode);
++int spi_flash_probe_eon(struct spi_flash *flash, u8 *idcode);
++int spi_flash_probe_macronix(struct spi_flash *flash, u8 *idcode);
++int spi_flash_probe_sst(struct spi_flash *flash, u8 *idcode);
++int spi_flash_probe_stmicro(struct spi_flash *flash, u8 *idcode);
++int spi_flash_probe_winbond(struct spi_flash *flash, u8 *idcode);
++int spi_fram_probe_ramtron(struct spi_flash *flash, u8 *idcode);
+--- a/drivers/mtd/spi/sst.c
++++ b/drivers/mtd/spi/sst.c
+@@ -39,11 +39,6 @@ struct sst_spi_flash_params {
+ const char *name;
+ };
+
+-struct sst_spi_flash {
+- struct spi_flash flash;
+- const struct sst_spi_flash_params *params;
+-};
+-
+ static const struct sst_spi_flash_params sst_spi_flash_table[] = {
+ {
+ .idcode1 = 0x8d,
+@@ -185,11 +180,9 @@ sst_write_wp(struct spi_flash *flash, u3
+ return ret;
+ }
+
+-struct spi_flash *
+-spi_flash_probe_sst(struct spi_slave *spi, u8 *idcode)
++int spi_flash_probe_sst(struct spi_flash *flash, u8 *idcode)
+ {
+ const struct sst_spi_flash_params *params;
+- struct sst_spi_flash *stm;
+ size_t i;
+
+ for (i = 0; i < ARRAY_SIZE(sst_spi_flash_table); ++i) {
+@@ -200,31 +193,24 @@ spi_flash_probe_sst(struct spi_slave *sp
+
+ if (i == ARRAY_SIZE(sst_spi_flash_table)) {
+ debug("SF: Unsupported SST ID %02x\n", idcode[1]);
+- return NULL;
+- }
+-
+- stm = malloc(sizeof(*stm));
+- if (!stm) {
+- debug("SF: Failed to allocate memory\n");
+- return NULL;
++ return 0;
+ }
+
+- stm->params = params;
+- stm->flash.spi = spi;
+- stm->flash.name = params->name;
++ flash->priv = (void *)params;
++ flash->name = params->name;
+
+- if (stm->params->flags & SST_FEAT_WP)
+- stm->flash.write = sst_write_wp;
++ if (params->flags & SST_FEAT_WP)
++ flash->write = sst_write_wp;
+ else
+- stm->flash.write = spi_flash_cmd_write_multi;
+- stm->flash.erase = spi_flash_cmd_erase;
+- stm->flash.read = spi_flash_cmd_read_fast;
+- stm->flash.page_size = 256;
+- stm->flash.sector_size = 4096;
+- stm->flash.size = stm->flash.sector_size * params->nr_sectors;
++ flash->write = spi_flash_cmd_write_multi;
++ flash->erase = spi_flash_cmd_erase;
++ flash->read = spi_flash_cmd_read_fast;
++ flash->page_size = 256;
++ flash->sector_size = 4096;
++ flash->size = flash->sector_size * params->nr_sectors;
+
+ /* Flash powers up read-only, so clear BP# bits */
+- spi_flash_cmd_write_status(&stm->flash, 0);
++ spi_flash_cmd_write_status(flash, 0);
+
+- return &stm->flash;
++ return 1;
+ }
+--- a/drivers/mtd/spi/stmicro.c
++++ b/drivers/mtd/spi/stmicro.c
+@@ -112,10 +112,10 @@ static const struct stmicro_spi_flash_pa
+ },
+ };
+
+-struct spi_flash *spi_flash_probe_stmicro(struct spi_slave *spi, u8 * idcode)
++int spi_flash_probe_stmicro(struct spi_flash *flash, u8 * idcode)
+ {
+ const struct stmicro_spi_flash_params *params;
+- struct spi_flash *flash;
++ struct spi_slave *spi = flash->spi;
+ unsigned int i;
+ u16 id;
+
+@@ -123,13 +123,13 @@ struct spi_flash *spi_flash_probe_stmicr
+ i = spi_flash_cmd(spi, CMD_M25PXX_RES,
+ idcode, 4);
+ if (i)
+- return NULL;
++ return 0;
+ if ((idcode[3] & 0xf0) == 0x10) {
+ idcode[0] = 0x20;
+ idcode[1] = 0x20;
+ idcode[2] = idcode[3] + 1;
+ } else
+- return NULL;
++ return 0;
+ }
+
+ id = ((idcode[1] << 8) | idcode[2]);
+@@ -143,16 +143,10 @@ struct spi_flash *spi_flash_probe_stmicr
+
+ if (i == ARRAY_SIZE(stmicro_spi_flash_table)) {
+ debug("SF: Unsupported STMicro ID %04x\n", id);
+- return NULL;
++ return 0;
+ }
+
+- flash = malloc(sizeof(*flash));
+- if (!flash) {
+- debug("SF: Failed to allocate memory\n");
+- return NULL;
+- }
+-
+- flash->spi = spi;
++ flash->priv = (void *)params;
+ flash->name = params->name;
+
+ flash->write = spi_flash_cmd_write_multi;
+@@ -162,5 +156,5 @@ struct spi_flash *spi_flash_probe_stmicr
+ flash->sector_size = 256 * params->pages_per_sector;
+ flash->size = flash->sector_size * params->nr_sectors;
+
+- return flash;
++ return 1;
+ }
+--- a/drivers/mtd/spi/winbond.c
++++ b/drivers/mtd/spi/winbond.c
+@@ -69,10 +69,9 @@ static const struct winbond_spi_flash_pa
+ },
+ };
+
+-struct spi_flash *spi_flash_probe_winbond(struct spi_slave *spi, u8 *idcode)
++int spi_flash_probe_winbond(struct spi_flash *flash, u8 *idcode)
+ {
+ const struct winbond_spi_flash_params *params;
+- struct spi_flash *flash;
+ unsigned int i;
+
+ for (i = 0; i < ARRAY_SIZE(winbond_spi_flash_table); i++) {
+@@ -84,16 +83,10 @@ struct spi_flash *spi_flash_probe_winbon
+ if (i == ARRAY_SIZE(winbond_spi_flash_table)) {
+ debug("SF: Unsupported Winbond ID %02x%02x\n",
+ idcode[1], idcode[2]);
+- return NULL;
++ return 0;
+ }
+
+- flash = malloc(sizeof(*flash));
+- if (!flash) {
+- debug("SF: Failed to allocate memory\n");
+- return NULL;
+- }
+-
+- flash->spi = spi;
++ flash->priv = (void *)params;
+ flash->name = params->name;
+
+ flash->write = spi_flash_cmd_write_multi;
+@@ -103,5 +96,5 @@ struct spi_flash *spi_flash_probe_winbon
+ flash->sector_size = 4096;
+ flash->size = 4096 * 16 * params->nr_blocks;
+
+- return flash;
++ return 1;
+ }
+--- a/include/spi_flash.h
++++ b/include/spi_flash.h
+@@ -31,6 +31,7 @@ struct spi_flash {
+ struct spi_slave *spi;
+
+ const char *name;
++ void *priv;
+
+ /* Total flash size */
+ u32 size;
diff --git a/package/boot/uboot-lantiq/patches/0004-sf-add-malloc-free-probe-functions-dedicated-for-SPL.patch b/package/boot/uboot-lantiq/patches/0004-sf-add-malloc-free-probe-functions-dedicated-for-SPL.patch
new file mode 100644
index 0000000..7a1ef3b
--- /dev/null
+++ b/package/boot/uboot-lantiq/patches/0004-sf-add-malloc-free-probe-functions-dedicated-for-SPL.patch
@@ -0,0 +1,131 @@
+From f9ab44c271fbd82a5702b6ba067fa90e33a30089 Mon Sep 17 00:00:00 2001
+From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+Date: Wed, 7 Nov 2012 15:29:27 +0100
+Subject: sf: add malloc-free probe functions dedicated for SPL
+
+Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+
+--- a/drivers/mtd/spi/spi_flash.c
++++ b/drivers/mtd/spi/spi_flash.c
+@@ -339,11 +339,11 @@ static struct {
+ DECLARE_GLOBAL_DATA_PTR;
+ #endif
+
+-struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
+- unsigned int max_hz, unsigned int spi_mode)
++int spi_flash_probe_spl(struct spi_flash *flash, unsigned int bus,
++ unsigned int cs, unsigned int max_hz,
++ unsigned int spi_mode)
+ {
+ struct spi_slave *spi;
+- struct spi_flash *flash;
+ int ret, i, shift;
+ u8 idcode[IDCODE_LEN], *idp;
+ #ifdef CONFIG_NEEDS_MANUAL_RELOC
+@@ -359,8 +359,8 @@ struct spi_flash *spi_flash_probe(unsign
+
+ spi = spi_setup_slave(bus, cs, max_hz, spi_mode);
+ if (!spi) {
+- printf("SF: Failed to set up slave\n");
+- return NULL;
++ debug("SF: Failed to set up slave\n");
++ return -1;
+ }
+
+ ret = spi_claim_bus(spi);
+@@ -379,13 +379,6 @@ struct spi_flash *spi_flash_probe(unsign
+ print_buffer(0, idcode, 1, sizeof(idcode), 0);
+ #endif
+
+- flash = malloc(sizeof(*flash));
+- if (!flash) {
+- debug("SF: failed to alloc memory\n");
+- goto err_malloc;
+- }
+-
+- memset(flash, 0, sizeof(*flash));
+ flash->spi = spi;
+
+ /* count the number of continuation bytes */
+@@ -404,30 +397,58 @@ struct spi_flash *spi_flash_probe(unsign
+ }
+
+ if (ret <= 0) {
+- printf("SF: Unsupported manufacturer %02x\n", *idp);
++ debug("SF: Unsupported manufacturer %02x\n", *idp);
+ goto err_manufacturer_probe;
+ }
+
+- printf("SF: Detected %s with page size ", flash->name);
+- print_size(flash->sector_size, ", total ");
+- print_size(flash->size, "\n");
+-
+ spi_release_bus(spi);
+
+- return flash;
++ return 0;
+
+ err_manufacturer_probe:
+- free(flash);
+-err_malloc:
+ err_read_id:
+ spi_release_bus(spi);
+ err_claim_bus:
+ spi_free_slave(spi);
++
++ return ret;
++}
++
++struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
++ unsigned int max_hz, unsigned int spi_mode)
++{
++ struct spi_flash *flash;
++ int ret;
++
++ flash = malloc(sizeof(*flash));
++ if (!flash) {
++ debug("SF: Failed to malloc spi_flash\n");
++ return NULL;
++ }
++ memset(flash, 0, sizeof(*flash));
++
++ ret = spi_flash_probe_spl(flash, bus, cs, max_hz, spi_mode);
++ if (ret)
++ goto err_probe;
++
++ printf("SF: %s, page size ", flash->name);
++ print_size(flash->sector_size, ", total ");
++ print_size(flash->size, "\n");
++
++ return flash;
++
++err_probe:
++ free(flash);
+ return NULL;
+ }
+
+-void spi_flash_free(struct spi_flash *flash)
++void spi_flash_free_spl(struct spi_flash *flash)
+ {
+ spi_free_slave(flash->spi);
++}
++
++void spi_flash_free(struct spi_flash *flash)
++{
++ spi_flash_free_spl(flash);
+ free(flash);
+ }
+--- a/include/spi_flash.h
++++ b/include/spi_flash.h
+@@ -52,6 +52,11 @@ struct spi_flash *spi_flash_probe(unsign
+ unsigned int max_hz, unsigned int spi_mode);
+ void spi_flash_free(struct spi_flash *flash);
+
++int spi_flash_probe_spl(struct spi_flash *flash, unsigned int bus,
++ unsigned int cs, unsigned int max_hz,
++ unsigned int spi_mode);
++void spi_flash_free_spl(struct spi_flash *flash);
++
+ static inline int spi_flash_read(struct spi_flash *flash, u32 offset,
+ size_t len, void *buf)
+ {
diff --git a/package/boot/uboot-lantiq/patches/0005-sf-factor-out-the-flash-address-calculation.patch b/package/boot/uboot-lantiq/patches/0005-sf-factor-out-the-flash-address-calculation.patch
new file mode 100644
index 0000000..356db59
--- /dev/null
+++ b/package/boot/uboot-lantiq/patches/0005-sf-factor-out-the-flash-address-calculation.patch
@@ -0,0 +1,107 @@
+From acb2721e1cd2e7488a7b08a4ed590177369a1689 Mon Sep 17 00:00:00 2001
+From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+Date: Tue, 6 Nov 2012 19:10:40 +0100
+Subject: sf: factor out the flash address calculation
+
+Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+
+--- a/drivers/mtd/spi/spi_flash.c
++++ b/drivers/mtd/spi/spi_flash.c
+@@ -15,12 +15,22 @@
+
+ #include "spi_flash_internal.h"
+
+-static void spi_flash_addr(u32 addr, u8 *cmd)
++static void spi_flash_addr(struct spi_flash *flash, u32 addr, u8 *cmd, u8 *cmd_len)
+ {
+ /* cmd[0] is actual command */
+ cmd[1] = addr >> 16;
+ cmd[2] = addr >> 8;
+ cmd[3] = addr >> 0;
++ *cmd_len = 4;
++}
++
++static void spi_flash_page_addr(struct spi_flash *flash, u32 page_addr, u32 byte_addr, u8 *cmd, u8 *cmd_len)
++{
++ /* cmd[0] is actual command */
++ cmd[1] = page_addr >> 8;
++ cmd[2] = page_addr >> 0;
++ cmd[3] = byte_addr;
++ *cmd_len = 4;
+ }
+
+ static int spi_flash_read_write(struct spi_slave *spi,
+@@ -71,7 +81,7 @@ int spi_flash_cmd_write_multi(struct spi
+ unsigned long page_addr, byte_addr, page_size;
+ size_t chunk_len, actual;
+ int ret;
+- u8 cmd[4];
++ u8 cmd[4], cmd_len;
+
+ page_size = flash->page_size;
+ page_addr = offset / page_size;
+@@ -87,9 +97,7 @@ int spi_flash_cmd_write_multi(struct spi
+ for (actual = 0; actual < len; actual += chunk_len) {
+ chunk_len = min(len - actual, page_size - byte_addr);
+
+- cmd[1] = page_addr >> 8;
+- cmd[2] = page_addr;
+- cmd[3] = byte_addr;
++ spi_flash_page_addr(flash, page_addr, byte_addr, cmd, &cmd_len);
+
+ debug("PP: 0x%p => cmd = { 0x%02x 0x%02x%02x%02x } chunk_len = %zu\n",
+ buf + actual, cmd[0], cmd[1], cmd[2], cmd[3], chunk_len);
+@@ -100,7 +108,7 @@ int spi_flash_cmd_write_multi(struct spi
+ break;
+ }
+
+- ret = spi_flash_cmd_write(flash->spi, cmd, 4,
++ ret = spi_flash_cmd_write(flash->spi, cmd, cmd_len,
+ buf + actual, chunk_len);
+ if (ret < 0) {
+ debug("SF: write failed\n");
+@@ -138,13 +146,13 @@ int spi_flash_read_common(struct spi_fla
+ int spi_flash_cmd_read_fast(struct spi_flash *flash, u32 offset,
+ size_t len, void *data)
+ {
+- u8 cmd[5];
++ u8 cmd[5], cmd_len;
+
+ cmd[0] = CMD_READ_ARRAY_FAST;
+- spi_flash_addr(offset, cmd);
+- cmd[4] = 0x00;
++ spi_flash_addr(flash, offset, cmd, &cmd_len);
++ cmd[cmd_len] = 0x00;
+
+- return spi_flash_read_common(flash, cmd, sizeof(cmd), data, len);
++ return spi_flash_read_common(flash, cmd, cmd_len + 1, data, len);
+ }
+
+ int spi_flash_cmd_poll_bit(struct spi_flash *flash, unsigned long timeout,
+@@ -194,7 +202,7 @@ int spi_flash_cmd_erase(struct spi_flash
+ {
+ u32 start, end, erase_size;
+ int ret;
+- u8 cmd[4];
++ u8 cmd[4], cmd_len;
+
+ erase_size = flash->sector_size;
+ if (offset % erase_size || len % erase_size) {
+@@ -216,7 +224,7 @@ int spi_flash_cmd_erase(struct spi_flash
+ end = start + len;
+
+ while (offset < end) {
+- spi_flash_addr(offset, cmd);
++ spi_flash_addr(flash, offset, cmd, &cmd_len);
+ offset += erase_size;
+
+ debug("SF: erase %2x %2x %2x %2x (%x)\n", cmd[0], cmd[1],
+@@ -226,7 +234,7 @@ int spi_flash_cmd_erase(struct spi_flash
+ if (ret)
+ goto out;
+
+- ret = spi_flash_cmd_write(flash->spi, cmd, sizeof(cmd), NULL, 0);
++ ret = spi_flash_cmd_write(flash->spi, cmd, cmd_len, NULL, 0);
+ if (ret)
+ goto out;
+
diff --git a/package/boot/uboot-lantiq/patches/0006-sf-add-generic-support-for-4-byte-address-mode.patch b/package/boot/uboot-lantiq/patches/0006-sf-add-generic-support-for-4-byte-address-mode.patch
new file mode 100644
index 0000000..1623b15
--- /dev/null
+++ b/package/boot/uboot-lantiq/patches/0006-sf-add-generic-support-for-4-byte-address-mode.patch
@@ -0,0 +1,161 @@
+From fb9ed0ef6f0ba6b6535c64dcfcf45c161723e56f Mon Sep 17 00:00:00 2001
+From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+Date: Tue, 6 Nov 2012 19:31:38 +0100
+Subject: sf: add generic support for 4-byte address mode
+
+Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+
+--- a/drivers/mtd/spi/spi_flash.c
++++ b/drivers/mtd/spi/spi_flash.c
+@@ -18,19 +18,35 @@
+ static void spi_flash_addr(struct spi_flash *flash, u32 addr, u8 *cmd, u8 *cmd_len)
+ {
+ /* cmd[0] is actual command */
+- cmd[1] = addr >> 16;
+- cmd[2] = addr >> 8;
+- cmd[3] = addr >> 0;
+- *cmd_len = 4;
++ if (spi_flash_use_4byte_mode(flash)) {
++ cmd[1] = addr >> 24;
++ cmd[2] = addr >> 16;
++ cmd[3] = addr >> 8;
++ cmd[4] = addr >> 0;
++ *cmd_len = 5;
++ } else {
++ cmd[1] = addr >> 16;
++ cmd[2] = addr >> 8;
++ cmd[3] = addr >> 0;
++ *cmd_len = 4;
++ }
+ }
+
+ static void spi_flash_page_addr(struct spi_flash *flash, u32 page_addr, u32 byte_addr, u8 *cmd, u8 *cmd_len)
+ {
+ /* cmd[0] is actual command */
+- cmd[1] = page_addr >> 8;
+- cmd[2] = page_addr >> 0;
+- cmd[3] = byte_addr;
+- *cmd_len = 4;
++ if (spi_flash_use_4byte_mode(flash)) {
++ cmd[1] = page_addr >> 16;
++ cmd[2] = page_addr >> 8;
++ cmd[3] = page_addr >> 0;
++ cmd[4] = byte_addr;
++ *cmd_len = 5;
++ } else {
++ cmd[1] = page_addr >> 8;
++ cmd[2] = page_addr >> 0;
++ cmd[3] = byte_addr;
++ *cmd_len = 4;
++ }
+ }
+
+ static int spi_flash_read_write(struct spi_slave *spi,
+@@ -81,7 +97,7 @@ int spi_flash_cmd_write_multi(struct spi
+ unsigned long page_addr, byte_addr, page_size;
+ size_t chunk_len, actual;
+ int ret;
+- u8 cmd[4], cmd_len;
++ u8 cmd[5], cmd_len;
+
+ page_size = flash->page_size;
+ page_addr = offset / page_size;
+@@ -99,8 +115,8 @@ int spi_flash_cmd_write_multi(struct spi
+
+ spi_flash_page_addr(flash, page_addr, byte_addr, cmd, &cmd_len);
+
+- debug("PP: 0x%p => cmd = { 0x%02x 0x%02x%02x%02x } chunk_len = %zu\n",
+- buf + actual, cmd[0], cmd[1], cmd[2], cmd[3], chunk_len);
++ debug("PP: 0x%p => cmd = { 0x%02x 0x%02x%02x%02x%02x } chunk_len = %zu\n",
++ buf + actual, cmd[0], cmd[1], cmd[2], cmd[3], cmd[4], chunk_len);
+
+ ret = spi_flash_cmd_write_enable(flash);
+ if (ret < 0) {
+@@ -146,7 +162,7 @@ int spi_flash_read_common(struct spi_fla
+ int spi_flash_cmd_read_fast(struct spi_flash *flash, u32 offset,
+ size_t len, void *data)
+ {
+- u8 cmd[5], cmd_len;
++ u8 cmd[6], cmd_len;
+
+ cmd[0] = CMD_READ_ARRAY_FAST;
+ spi_flash_addr(flash, offset, cmd, &cmd_len);
+@@ -202,7 +218,7 @@ int spi_flash_cmd_erase(struct spi_flash
+ {
+ u32 start, end, erase_size;
+ int ret;
+- u8 cmd[4], cmd_len;
++ u8 cmd[5], cmd_len;
+
+ erase_size = flash->sector_size;
+ if (offset % erase_size || len % erase_size) {
+@@ -227,8 +243,8 @@ int spi_flash_cmd_erase(struct spi_flash
+ spi_flash_addr(flash, offset, cmd, &cmd_len);
+ offset += erase_size;
+
+- debug("SF: erase %2x %2x %2x %2x (%x)\n", cmd[0], cmd[1],
+- cmd[2], cmd[3], offset);
++ debug("SF: erase %2x %2x %2x %2x %2x (%x)\n", cmd[0], cmd[1],
++ cmd[2], cmd[3], cmd[4], offset);
+
+ ret = spi_flash_cmd_write_enable(flash);
+ if (ret)
+@@ -409,6 +425,12 @@ int spi_flash_probe_spl(struct spi_flash
+ goto err_manufacturer_probe;
+ }
+
++ ret = spi_flash_set_4byte_mode(flash);
++ if (ret) {
++ debug("SF: Failed to enable 4 byte mode: %d\n", ret);
++ goto err_manufacturer_probe;
++ }
++
+ spi_release_bus(spi);
+
+ return 0;
+--- a/drivers/mtd/spi/spi_flash_internal.h
++++ b/drivers/mtd/spi/spi_flash_internal.h
+@@ -97,6 +97,31 @@ int spi_flash_cmd_wait_ready(struct spi_
+ /* Erase sectors. */
+ int spi_flash_cmd_erase(struct spi_flash *flash, u32 offset, size_t len);
+
++#ifdef CONFIG_SPI_FLASH_4BYTE_MODE
++static inline int spi_flash_use_4byte_mode(struct spi_flash *flash)
++{
++ return NULL != flash->set_4byte_mode;
++}
++
++static inline int spi_flash_set_4byte_mode(struct spi_flash *flash)
++{
++ if (spi_flash_use_4byte_mode(flash))
++ return flash->set_4byte_mode(flash);
++
++ return 0;
++}
++#else
++static inline int spi_flash_use_4byte_mode(struct spi_flash *flash)
++{
++ return 0;
++}
++
++static inline int spi_flash_set_4byte_mode(struct spi_flash *flash)
++{
++ return 0;
++}
++#endif
++
+ /* Manufacturer-specific probe functions */
+ int spi_flash_probe_spansion(struct spi_flash *flash, u8 *idcode);
+ int spi_flash_probe_atmel(struct spi_flash *flash, u8 *idcode);
+--- a/include/spi_flash.h
++++ b/include/spi_flash.h
+@@ -46,6 +46,9 @@ struct spi_flash {
+ size_t len, const void *buf);
+ int (*erase)(struct spi_flash *flash, u32 offset,
+ size_t len);
++#ifdef CONFIG_SPI_FLASH_4BYTE_MODE
++ int (*set_4byte_mode)(struct spi_flash *flash);
++#endif
+ };
+
+ struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
diff --git a/package/boot/uboot-lantiq/patches/0007-sf-eon-use-16-bit-ID-for-comparison.patch b/package/boot/uboot-lantiq/patches/0007-sf-eon-use-16-bit-ID-for-comparison.patch
new file mode 100644
index 0000000..6836674
--- /dev/null
+++ b/package/boot/uboot-lantiq/patches/0007-sf-eon-use-16-bit-ID-for-comparison.patch
@@ -0,0 +1,45 @@
+From d32f45357f0475a2f810752eeb9412fe692e1c0a Mon Sep 17 00:00:00 2001
+From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+Date: Wed, 7 Nov 2012 14:09:21 +0100
+Subject: sf: eon: use 16 bit ID for comparison
+
+Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+
+--- a/drivers/mtd/spi/eon.c
++++ b/drivers/mtd/spi/eon.c
+@@ -11,19 +11,19 @@
+ #include "spi_flash_internal.h"
+
+ struct eon_spi_flash_params {
+- u8 idcode1;
++ u16 idcode;
+ u16 nr_sectors;
+ const char *name;
+ };
+
+ static const struct eon_spi_flash_params eon_spi_flash_table[] = {
+ {
+- .idcode1 = 0x16,
++ .idcode = 0x3016,
+ .nr_sectors = 1024,
+ .name = "EN25Q32B",
+ },
+ {
+- .idcode1 = 0x18,
++ .idcode = 0x3018,
+ .nr_sectors = 4096,
+ .name = "EN25Q128",
+ },
+@@ -33,10 +33,11 @@ int spi_flash_probe_eon(struct spi_flash
+ {
+ const struct eon_spi_flash_params *params;
+ unsigned int i;
++ u16 id = idcode[2] | idcode[1] << 8;
+
+ for (i = 0; i < ARRAY_SIZE(eon_spi_flash_table); ++i) {
+ params = &eon_spi_flash_table[i];
+- if (params->idcode1 == idcode[2])
++ if (params->idcode == id)
+ break;
+ }
+
diff --git a/package/boot/uboot-lantiq/patches/0008-sf-eon-add-support-for-4-byte-address-mode.patch b/package/boot/uboot-lantiq/patches/0008-sf-eon-add-support-for-4-byte-address-mode.patch
new file mode 100644
index 0000000..c037a86
--- /dev/null
+++ b/package/boot/uboot-lantiq/patches/0008-sf-eon-add-support-for-4-byte-address-mode.patch
@@ -0,0 +1,43 @@
+From 37254e3284f61ea495f73a78b7c8efae983781e2 Mon Sep 17 00:00:00 2001
+From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+Date: Wed, 7 Nov 2012 14:10:07 +0100
+Subject: sf: eon: add support for 4-byte address mode
+
+Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+
+--- a/drivers/mtd/spi/eon.c
++++ b/drivers/mtd/spi/eon.c
+@@ -10,6 +10,8 @@
+
+ #include "spi_flash_internal.h"
+
++#define EN25XX_EN4B 0xb7 /* Enter 4-byte mode */
++
+ struct eon_spi_flash_params {
+ u16 idcode;
+ u16 nr_sectors;
+@@ -29,6 +31,13 @@ static const struct eon_spi_flash_params
+ },
+ };
+
++static __maybe_unused int eon_set_4byte_mode(struct spi_flash *flash)
++{
++ struct spi_slave *spi = flash->spi;
++
++ return spi_flash_cmd(spi, EN25XX_EN4B, NULL, 0);
++}
++
+ int spi_flash_probe_eon(struct spi_flash *flash, u8 *idcode)
+ {
+ const struct eon_spi_flash_params *params;
+@@ -57,5 +66,10 @@ int spi_flash_probe_eon(struct spi_flash
+ flash->size = 256 * 16
+ * params->nr_sectors;
+
++#ifdef CONFIG_SPI_FLASH_4BYTE_MODE
++ if (flash->size > (1 << 24))
++ flash->set_4byte_mode = eon_set_4byte_mode;
++#endif
++
+ return 1;
+ }
diff --git a/package/boot/uboot-lantiq/patches/0009-sf-eon-add-support-for-EN25QH256.patch b/package/boot/uboot-lantiq/patches/0009-sf-eon-add-support-for-EN25QH256.patch
new file mode 100644
index 0000000..18f5823
--- /dev/null
+++ b/package/boot/uboot-lantiq/patches/0009-sf-eon-add-support-for-EN25QH256.patch
@@ -0,0 +1,21 @@
+From e510be1145796cd44cf5800e187a94ad7c19e764 Mon Sep 17 00:00:00 2001
+From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+Date: Wed, 7 Nov 2012 14:10:34 +0100
+Subject: sf: eon: add support for EN25QH256
+
+Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+
+--- a/drivers/mtd/spi/eon.c
++++ b/drivers/mtd/spi/eon.c
+@@ -29,6 +29,11 @@ static const struct eon_spi_flash_params
+ .nr_sectors = 4096,
+ .name = "EN25Q128",
+ },
++ {
++ .idcode = 0x7019,
++ .nr_sectors = 8192,
++ .name = "EN25QH256",
++ },
+ };
+
+ static __maybe_unused int eon_set_4byte_mode(struct spi_flash *flash)
diff --git a/package/boot/uboot-lantiq/patches/0010-sf-spansion-fix-device-IDs-and-sector-architecture-f.patch b/package/boot/uboot-lantiq/patches/0010-sf-spansion-fix-device-IDs-and-sector-architecture-f.patch
new file mode 100644
index 0000000..af8c7a1
--- /dev/null
+++ b/package/boot/uboot-lantiq/patches/0010-sf-spansion-fix-device-IDs-and-sector-architecture-f.patch
@@ -0,0 +1,30 @@
+From 81a8e9e192d53ce8b5cafd47190d6c6826519d09 Mon Sep 17 00:00:00 2001
+From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+Date: Wed, 7 Nov 2012 14:58:59 +0100
+Subject: sf: spansion: fix device IDs and sector architecture for S25FL256S
+
+Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+
+--- a/drivers/mtd/spi/spansion.c
++++ b/drivers/mtd/spi/spansion.c
+@@ -97,11 +97,18 @@ static const struct spansion_spi_flash_p
+ .name = "S25FL129P_64K",
+ },
+ {
+- .idcode1 = 0x2019,
++ .idcode1 = 0x0219,
+ .idcode2 = 0x4d01,
+ .pages_per_sector = 256,
+ .nr_sectors = 512,
+- .name = "S25FL256S",
++ .name = "S25FL256S_64K",
++ },
++ {
++ .idcode1 = 0x0219,
++ .idcode2 = 0x4d00,
++ .pages_per_sector = 1024,
++ .nr_sectors = 128,
++ .name = "S25FL256S_256K",
+ },
+ };
+
diff --git a/package/boot/uboot-lantiq/patches/0011-sf-spansion-add-support-for-4-byte-address-mode.patch b/package/boot/uboot-lantiq/patches/0011-sf-spansion-add-support-for-4-byte-address-mode.patch
new file mode 100644
index 0000000..9471d47
--- /dev/null
+++ b/package/boot/uboot-lantiq/patches/0011-sf-spansion-add-support-for-4-byte-address-mode.patch
@@ -0,0 +1,55 @@
+From 0add8e5c60961d2b99174610df8d3d9d6d192b74 Mon Sep 17 00:00:00 2001
+From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+Date: Wed, 7 Nov 2012 14:16:11 +0100
+Subject: sf: spansion: add support for 4-byte address mode
+
+Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+
+--- a/drivers/mtd/spi/spansion.c
++++ b/drivers/mtd/spi/spansion.c
+@@ -31,6 +31,10 @@
+
+ #include "spi_flash_internal.h"
+
++#define S25FLXX_BRRD 0x16 /* Read Bank Register */
++#define S25FLXX_BRWR 0x17 /* Write Bank Register */
++#define S25FLXX_BAR_EXTADD (1 << 7) /* Extended address enable */
++
+ struct spansion_spi_flash_params {
+ u16 idcode1;
+ u16 idcode2;
+@@ -112,6 +116,23 @@ static const struct spansion_spi_flash_p
+ },
+ };
+
++static __maybe_unused int spansion_set_4byte_mode(struct spi_flash *flash)
++{
++ struct spi_slave *spi = flash->spi;
++ u8 bar, cmd;
++ int err;
++
++ cmd = S25FLXX_BRRD;
++ err = spi_flash_cmd(spi, cmd, &bar, 1);
++ if (err)
++ return err;
++
++ bar |= S25FLXX_BAR_EXTADD;
++ cmd = S25FLXX_BRWR;
++
++ return spi_flash_cmd_write(spi, &cmd, 1, &bar, 1);
++}
++
+ int spi_flash_probe_spansion(struct spi_flash *flash, u8 *idcode)
+ {
+ const struct spansion_spi_flash_params *params;
+@@ -144,5 +165,10 @@ int spi_flash_probe_spansion(struct spi_
+ flash->sector_size = 256 * params->pages_per_sector;
+ flash->size = flash->sector_size * params->nr_sectors;
+
++#ifdef CONFIG_SPI_FLASH_4BYTE_MODE
++ if (flash->size > (1 << 24))
++ flash->set_4byte_mode = spansion_set_4byte_mode;
++#endif
++
+ return 1;
+ }
diff --git a/package/boot/uboot-lantiq/patches/0012-sf-spansion-add-support-for-S25FL512S.patch b/package/boot/uboot-lantiq/patches/0012-sf-spansion-add-support-for-S25FL512S.patch
new file mode 100644
index 0000000..5f415a9
--- /dev/null
+++ b/package/boot/uboot-lantiq/patches/0012-sf-spansion-add-support-for-S25FL512S.patch
@@ -0,0 +1,23 @@
+From bff335ac524843bc90163c3b231091a5016f8670 Mon Sep 17 00:00:00 2001
+From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+Date: Wed, 7 Nov 2012 15:07:54 +0100
+Subject: sf: spansion: add support for S25FL512S
+
+Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+
+--- a/drivers/mtd/spi/spansion.c
++++ b/drivers/mtd/spi/spansion.c
+@@ -114,6 +114,13 @@ static const struct spansion_spi_flash_p
+ .nr_sectors = 128,
+ .name = "S25FL256S_256K",
+ },
++ {
++ .idcode1 = 0x0220,
++ .idcode2 = 0x4d00,
++ .pages_per_sector = 1024,
++ .nr_sectors = 256,
++ .name = "S25FL512S_256K",
++ },
+ };
+
+ static __maybe_unused int spansion_set_4byte_mode(struct spi_flash *flash)
diff --git a/package/boot/uboot-lantiq/patches/0013-sf-macronix-add-support-for-4-byte-address-mode.patch b/package/boot/uboot-lantiq/patches/0013-sf-macronix-add-support-for-4-byte-address-mode.patch
new file mode 100644
index 0000000..70015c9
--- /dev/null
+++ b/package/boot/uboot-lantiq/patches/0013-sf-macronix-add-support-for-4-byte-address-mode.patch
@@ -0,0 +1,44 @@
+From 207662a9270cc542709fbab0d25fbc361b39748c Mon Sep 17 00:00:00 2001
+From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+Date: Wed, 7 Nov 2012 15:13:49 +0100
+Subject: sf: macronix: add support for 4-byte address mode
+
+Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+
+--- a/drivers/mtd/spi/macronix.c
++++ b/drivers/mtd/spi/macronix.c
+@@ -35,6 +35,8 @@
+
+ #include "spi_flash_internal.h"
+
++#define MX25XX_EN4B 0xb7 /* Enter 4-byte mode */
++
+ struct macronix_spi_flash_params {
+ u16 idcode;
+ u16 nr_blocks;
+@@ -79,6 +81,13 @@ static const struct macronix_spi_flash_p
+ },
+ };
+
++static __maybe_unused int macronix_set_4byte_mode(struct spi_flash *flash)
++{
++ struct spi_slave *spi = flash->spi;
++
++ return spi_flash_cmd(spi, MX25XX_EN4B, NULL, 0);
++}
++
+ int spi_flash_probe_macronix(struct spi_flash *flash, u8 *idcode)
+ {
+ const struct macronix_spi_flash_params *params;
+@@ -106,6 +115,11 @@ int spi_flash_probe_macronix(struct spi_
+ flash->sector_size = 256 * 16 * 16;
+ flash->size = flash->sector_size * params->nr_blocks;
+
++#ifdef CONFIG_SPI_FLASH_4BYTE_MODE
++ if (flash->size > (1 << 24))
++ flash->set_4byte_mode = macronix_set_4byte_mode;
++#endif
++
+ /* Clear BP# bits for read-only flash */
+ spi_flash_cmd_write_status(flash, 0);
+
diff --git a/package/boot/uboot-lantiq/patches/0014-sf-macronix-add-support-for-MX25L25635E.patch b/package/boot/uboot-lantiq/patches/0014-sf-macronix-add-support-for-MX25L25635E.patch
new file mode 100644
index 0000000..8e33836
--- /dev/null
+++ b/package/boot/uboot-lantiq/patches/0014-sf-macronix-add-support-for-MX25L25635E.patch
@@ -0,0 +1,21 @@
+From 0f31fef3d6a5110684ea31c5064c45fc448013d6 Mon Sep 17 00:00:00 2001
+From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+Date: Wed, 7 Nov 2012 15:14:24 +0100
+Subject: sf: macronix: add support for MX25L25635E
+
+Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+
+--- a/drivers/mtd/spi/macronix.c
++++ b/drivers/mtd/spi/macronix.c
+@@ -79,6 +79,11 @@ static const struct macronix_spi_flash_p
+ .nr_blocks = 256,
+ .name = "MX25L12855E",
+ },
++ {
++ .idcode = 0x2019,
++ .nr_blocks = 512,
++ .name = "MX25L25635E",
++ },
+ };
+
+ static __maybe_unused int macronix_set_4byte_mode(struct spi_flash *flash)
diff --git a/package/boot/uboot-lantiq/patches/0015-sf-macronix-add-support-for-MX66L51235L.patch b/package/boot/uboot-lantiq/patches/0015-sf-macronix-add-support-for-MX66L51235L.patch
new file mode 100644
index 0000000..fbc22e4
--- /dev/null
+++ b/package/boot/uboot-lantiq/patches/0015-sf-macronix-add-support-for-MX66L51235L.patch
@@ -0,0 +1,21 @@
+From a2d80b6b91ac63beea31455ce8d136230c030500 Mon Sep 17 00:00:00 2001
+From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+Date: Wed, 7 Nov 2012 15:14:40 +0100
+Subject: sf: macronix: add support for MX66L51235L
+
+Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+
+--- a/drivers/mtd/spi/macronix.c
++++ b/drivers/mtd/spi/macronix.c
+@@ -84,6 +84,11 @@ static const struct macronix_spi_flash_p
+ .nr_blocks = 512,
+ .name = "MX25L25635E",
+ },
++ {
++ .idcode = 0x201A,
++ .nr_blocks = 1024,
++ .name = "MX66L51235L",
++ },
+ };
+
+ static __maybe_unused int macronix_set_4byte_mode(struct spi_flash *flash)
diff --git a/package/boot/uboot-lantiq/patches/0016-sf-add-MTD-layer-driver-for-SPI-flash-devices.patch b/package/boot/uboot-lantiq/patches/0016-sf-add-MTD-layer-driver-for-SPI-flash-devices.patch
new file mode 100644
index 0000000..a9ee560
--- /dev/null
+++ b/package/boot/uboot-lantiq/patches/0016-sf-add-MTD-layer-driver-for-SPI-flash-devices.patch
@@ -0,0 +1,133 @@
+From 7f6ded11965b09daf6da44d4fa98da17b9fba36c Mon Sep 17 00:00:00 2001
+From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+Date: Tue, 6 Nov 2012 19:41:26 +0100
+Subject: sf: add MTD layer driver for SPI flash devices
+
+Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+
+--- a/drivers/mtd/spi/Makefile
++++ b/drivers/mtd/spi/Makefile
+@@ -30,6 +30,7 @@ COBJS-$(CONFIG_SPL_SPI_LOAD) += spi_spl_
+ endif
+
+ COBJS-$(CONFIG_SPI_FLASH) += spi_flash.o
++COBJS-$(CONFIG_SPI_FLASH_MTD) += spi_flash_mtd.o
+ COBJS-$(CONFIG_SPI_FLASH_ATMEL) += atmel.o
+ COBJS-$(CONFIG_SPI_FLASH_EON) += eon.o
+ COBJS-$(CONFIG_SPI_FLASH_MACRONIX) += macronix.o
+--- a/drivers/mtd/spi/spi_flash_internal.h
++++ b/drivers/mtd/spi/spi_flash_internal.h
+@@ -122,6 +122,9 @@ static inline int spi_flash_set_4byte_mo
+ }
+ #endif
+
++/* SPI flash MTD adapter init */
++int spi_flash_mtd_init(struct spi_flash *flash);
++
+ /* Manufacturer-specific probe functions */
+ int spi_flash_probe_spansion(struct spi_flash *flash, u8 *idcode);
+ int spi_flash_probe_atmel(struct spi_flash *flash, u8 *idcode);
+--- /dev/null
++++ b/drivers/mtd/spi/spi_flash_mtd.c
+@@ -0,0 +1,101 @@
++/*
++ * (C) Copyright 2012 Daniel Schwierzeck, daniel.schwierzeck@gmail.com
++ *
++ * MTD layer driver for SPI flash devices
++ *
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ */
++
++#include <common.h>
++#include <malloc.h>
++#include <asm/errno.h>
++#include <linux/mtd/mtd.h>
++#include <spi_flash.h>
++
++static struct mtd_info sf_mtd_info;
++static char sf_mtd_name[8];
++
++static int spi_flash_mtd_erase(struct mtd_info *mtd, struct erase_info *instr)
++{
++ struct spi_flash *flash = mtd->priv;
++ int err;
++
++ instr->state = MTD_ERASING;
++
++ err = spi_flash_erase(flash, instr->addr, instr->len);
++ if (err) {
++ instr->state = MTD_ERASE_FAILED;
++ instr->fail_addr = MTD_FAIL_ADDR_UNKNOWN;
++ return -EIO;
++ }
++
++ instr->state = MTD_ERASE_DONE;
++ mtd_erase_callback(instr);
++
++ return 0;
++}
++
++static int spi_flash_mtd_read(struct mtd_info *mtd, loff_t from, size_t len,
++ size_t *retlen, u_char *buf)
++{
++ struct spi_flash *flash = mtd->priv;
++ int err;
++
++ err = spi_flash_read(flash, from, len, buf);
++ if (!err)
++ *retlen = len;
++
++ return err;
++}
++
++static int spi_flash_mtd_write(struct mtd_info *mtd, loff_t to, size_t len,
++ size_t *retlen, const u_char *buf)
++{
++ struct spi_flash *flash = mtd->priv;
++ int err;
++
++ err = spi_flash_write(flash, to, len, buf);
++ if (!err)
++ *retlen = len;
++
++ return err;
++}
++
++static void spi_flash_mtd_sync(struct mtd_info *mtd)
++{
++}
++
++static int spi_flash_mtd_number(void)
++{
++#ifdef CONFIG_SYS_MAX_FLASH_BANKS
++ return CONFIG_SYS_MAX_FLASH_BANKS;
++#else
++ return 0;
++#endif
++}
++
++int spi_flash_mtd_init(struct spi_flash *flash)
++{
++ memset(&sf_mtd_info, 0, sizeof(sf_mtd_info));
++ sprintf(sf_mtd_name, "nor%d", spi_flash_mtd_number());
++
++ sf_mtd_info.name = sf_mtd_name;
++ sf_mtd_info.type = MTD_NORFLASH;
++ sf_mtd_info.flags = MTD_CAP_NORFLASH;
++ sf_mtd_info.writesize = 1;
++
++ sf_mtd_info.erase = spi_flash_mtd_erase;
++ sf_mtd_info.read = spi_flash_mtd_read;
++ sf_mtd_info.write = spi_flash_mtd_write;
++ sf_mtd_info.sync = spi_flash_mtd_sync;
++
++ sf_mtd_info.size = flash->size;
++ sf_mtd_info.priv = flash;
++
++ /* Only uniform flash devices for now */
++ sf_mtd_info.numeraseregions = 0;
++ sf_mtd_info.erasesize = flash->sector_size;
++
++ return add_mtd_device(&sf_mtd_info);
++}
diff --git a/package/boot/uboot-lantiq/patches/0017-sf-add-init-function.patch b/package/boot/uboot-lantiq/patches/0017-sf-add-init-function.patch
new file mode 100644
index 0000000..2d29051
--- /dev/null
+++ b/package/boot/uboot-lantiq/patches/0017-sf-add-init-function.patch
@@ -0,0 +1,57 @@
+From aa9d5d64ca6441cb24e22dc3c1f707da62da2887 Mon Sep 17 00:00:00 2001
+From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+Date: Tue, 6 Nov 2012 19:35:17 +0100
+Subject: sf: add init function
+
+Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+
+--- a/drivers/mtd/spi/spi_flash.c
++++ b/drivers/mtd/spi/spi_flash.c
+@@ -482,3 +482,36 @@ void spi_flash_free(struct spi_flash *fl
+ spi_flash_free_spl(flash);
+ free(flash);
+ }
++
++#ifdef CONFIG_SPI_FLASH_MTD
++static int spi_flash_mtd_register(void)
++{
++ struct spi_flash *flash;
++ int err;
++
++ flash = spi_flash_probe(CONFIG_ENV_SPI_BUS, CONFIG_ENV_SPI_CS,
++ CONFIG_ENV_SPI_MAX_HZ, CONFIG_ENV_SPI_MODE);
++ if (!flash)
++ return -1;
++
++ err = spi_flash_mtd_init(flash);
++ if (err)
++ spi_flash_free(flash);
++
++ return err;
++}
++#else
++static int spi_flash_mtd_register(void)
++{
++ return 0;
++}
++#endif
++
++int spi_flash_init(void)
++{
++ int err;
++
++ err = spi_flash_mtd_register();
++
++ return err;
++}
+--- a/include/spi_flash.h
++++ b/include/spi_flash.h
+@@ -51,6 +51,8 @@ struct spi_flash {
+ #endif
+ };
+
++int spi_flash_init(void);
++
+ struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
+ unsigned int max_hz, unsigned int spi_mode);
+ void spi_flash_free(struct spi_flash *flash);
diff --git a/package/boot/uboot-lantiq/patches/0018-MIPS-add-SPI-flash-init-hook.patch b/package/boot/uboot-lantiq/patches/0018-MIPS-add-SPI-flash-init-hook.patch
new file mode 100644
index 0000000..71f094b
--- /dev/null
+++ b/package/boot/uboot-lantiq/patches/0018-MIPS-add-SPI-flash-init-hook.patch
@@ -0,0 +1,47 @@
+From 888b33e84082fe72d60d528c05c885c0c9d70bc4 Mon Sep 17 00:00:00 2001
+From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+Date: Tue, 6 Nov 2012 21:19:43 +0100
+Subject: MIPS: add SPI flash init hook
+
+Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+
+--- a/arch/mips/lib/board.c
++++ b/arch/mips/lib/board.c
+@@ -32,6 +32,7 @@
+ #include <nand.h>
+ #include <onenand_uboot.h>
+ #include <spi.h>
++#include <spi_flash.h>
+
+ #ifdef CONFIG_BITBANGMII
+ #include <miiphy.h>
+@@ -312,6 +313,16 @@ void board_init_r(gd_t *id, ulong dest_a
+ onenand_init();
+ #endif
+
++#ifdef CONFIG_CMD_SPI
++ puts("SPI: ");
++ spi_init(); /* go init the SPI */
++ puts("ready\n");
++#endif
++
++#if defined(CONFIG_SPI_FLASH)
++ spi_flash_init();
++#endif
++
+ /* relocate environment function pointers etc. */
+ env_relocate();
+
+@@ -335,12 +346,6 @@ void board_init_r(gd_t *id, ulong dest_a
+ /* Initialize from environment */
+ load_addr = getenv_ulong("loadaddr", 16, load_addr);
+
+-#ifdef CONFIG_CMD_SPI
+- puts("SPI: ");
+- spi_init(); /* go init the SPI */
+- puts("ready\n");
+-#endif
+-
+ #if defined(CONFIG_MISC_INIT_R)
+ /* miscellaneous platform dependent initialisations */
+ misc_init_r();
diff --git a/package/boot/uboot-lantiq/patches/0019-net-switchlib-add-framework-for-ethernet-switch-driv.patch b/package/boot/uboot-lantiq/patches/0019-net-switchlib-add-framework-for-ethernet-switch-driv.patch
new file mode 100644
index 0000000..a215d1a
--- /dev/null
+++ b/package/boot/uboot-lantiq/patches/0019-net-switchlib-add-framework-for-ethernet-switch-driv.patch
@@ -0,0 +1,239 @@
+From d8b1597130d228bc7e2bafd0c8d097529018c833 Mon Sep 17 00:00:00 2001
+From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+Date: Wed, 29 Aug 2012 22:08:15 +0200
+Subject: net: switchlib: add framework for ethernet switch drivers
+
+Add a generic framework similar to phylib for ethernet switch
+drivers and devices. This is useful to share the init and
+setup code for switch devices across different boards.
+
+Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+Cc: Joe Hershberger <joe.hershberger@gmail.com>
+
+--- a/Makefile
++++ b/Makefile
+@@ -291,6 +291,7 @@ LIBS-y += drivers/mtd/ubi/libubi.o
+ LIBS-y += drivers/mtd/spi/libspi_flash.o
+ LIBS-y += drivers/net/libnet.o
+ LIBS-y += drivers/net/phy/libphy.o
++LIBS-y += drivers/net/switch/libswitch.o
+ LIBS-y += drivers/pci/libpci.o
+ LIBS-y += drivers/pcmcia/libpcmcia.o
+ LIBS-y += drivers/power/libpower.o \
+--- /dev/null
++++ b/drivers/net/switch/Makefile
+@@ -0,0 +1,31 @@
++#
++# This file is released under the terms of GPL v2 and any later version.
++# See the file COPYING in the root directory of the source tree for details.
++#
++# Copyright (C) 2000-2011 Wolfgang Denk, DENX Software Engineering, wd@denx.de
++# Copyright (C) 2011-2012 Daniel Schwierzeck, daniel.schwierzeck@gmail.com
++#
++
++include $(TOPDIR)/config.mk
++
++LIB := $(obj)libswitch.o
++
++COBJS-$(CONFIG_SWITCH_MULTI) += switch.o
++
++COBJS := $(COBJS-y)
++SRCS := $(COBJS:.o=.c)
++OBJS := $(addprefix $(obj),$(COBJS))
++
++all: $(LIB)
++
++$(LIB): $(obj).depend $(OBJS)
++ $(call cmd_link_o_target, $(OBJS))
++
++#########################################################################
++
++# defines $(obj).depend target
++include $(SRCTREE)/rules.mk
++
++sinclude $(obj).depend
++
++#########################################################################
+--- /dev/null
++++ b/drivers/net/switch/switch.c
+@@ -0,0 +1,63 @@
++/*
++ * Copyright (C) 2011-2012 Daniel Schwierzeck, daniel.schwierzeck@gmail.com
++ *
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ */
++
++#include <common.h>
++#include <netdev.h>
++#include <miiphy.h>
++#include <switch.h>
++
++static struct list_head switch_drivers;
++static struct list_head switch_devices;
++
++void switch_init(void)
++{
++ INIT_LIST_HEAD(&switch_drivers);
++ INIT_LIST_HEAD(&switch_devices);
++
++ board_switch_init();
++}
++
++void switch_driver_register(struct switch_driver *drv)
++{
++ INIT_LIST_HEAD(&drv->list);
++ list_add_tail(&drv->list, &switch_drivers);
++}
++
++int switch_device_register(struct switch_device *dev)
++{
++ struct switch_driver *drv;
++
++ /* Add switch device only, if an adequate driver is registered */
++ list_for_each_entry(drv, &switch_drivers, list) {
++ if (!strcmp(drv->name, dev->name)) {
++ dev->drv = drv;
++
++ INIT_LIST_HEAD(&dev->list);
++ list_add_tail(&dev->list, &switch_devices);
++
++ return 0;
++ }
++ }
++
++ return -1;
++}
++
++struct switch_device *switch_connect(struct mii_dev *bus)
++{
++ struct switch_device *sw;
++ int err;
++
++ list_for_each_entry(sw, &switch_devices, list) {
++ sw->bus = bus;
++
++ err = sw->drv->probe(sw);
++ if (!err)
++ return sw;
++ }
++
++ return NULL;
++}
+--- /dev/null
++++ b/include/switch.h
+@@ -0,0 +1,95 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#ifndef __SWITCH_H
++#define __SWITCH_H
++
++#include <linux/list.h>
++
++#define SWITCH_NAME_SIZE 32
++
++struct switch_device;
++struct mii_dev;
++
++struct switch_driver {
++ struct list_head list;
++
++ /* Switch device name */
++ const char name[SWITCH_NAME_SIZE];
++
++ /*
++ * Called to probe the switch chip. Must return 0 if the switch
++ * chip matches the given switch device/driver combination. Otherwise
++ * 1 must be returned.
++ */
++ int (*probe) (struct switch_device *dev);
++
++ /*
++ * Called to initialize the switch chip.
++ */
++ void (*setup) (struct switch_device *dev);
++};
++
++struct switch_device {
++ struct list_head list;
++ struct switch_driver *drv;
++
++ /* MII bus the switch chip is connected to */
++ struct mii_dev *bus;
++
++ /* Switch device name */
++ const char name[SWITCH_NAME_SIZE];
++
++ /* Bitmask for board specific setup of used switch ports */
++ u16 port_mask;
++
++ /* Number of switch port that is connected to host CPU */
++ u16 cpu_port;
++};
++
++/*
++ * Board specific switch initialization.
++ *
++ * Called from switch_init to register the board specific switch_device
++ * structure.
++ */
++extern int board_switch_init(void);
++
++/* Initialize switch subsystem */
++#ifdef CONFIG_SWITCH_MULTI
++extern void switch_init(void);
++#else
++static inline void switch_init(void)
++{
++}
++#endif
++
++/* Register a switch driver */
++extern void switch_driver_register(struct switch_driver *drv);
++
++/* Register a switch device */
++extern int switch_device_register(struct switch_device *dev);
++
++/*
++ * Probe the available switch chips and connect the found one
++ * with the given MII bus
++ */
++extern struct switch_device *switch_connect(struct mii_dev *bus);
++
++/*
++ * Setup the given switch device
++ */
++static inline void switch_setup(struct switch_device *dev)
++{
++ if (dev->drv->setup)
++ dev->drv->setup(dev);
++}
++
++/* Init functions for supported Switch drivers */
++
++#endif /* __SWITCH_H */
++
+--- a/net/eth.c
++++ b/net/eth.c
+@@ -26,6 +26,7 @@
+ #include <net.h>
+ #include <miiphy.h>
+ #include <phy.h>
++#include <switch.h>
+
+ void eth_parse_enetaddr(const char *addr, uchar *enetaddr)
+ {
+@@ -303,6 +304,8 @@ int eth_initialize(bd_t *bis)
+ phy_init();
+ #endif
+
++ switch_init();
++
+ eth_env_init(bis);
+
+ /*
diff --git a/package/boot/uboot-lantiq/patches/0020-net-switchlib-add-driver-for-Lantiq-PSB697X-switch-f.patch b/package/boot/uboot-lantiq/patches/0020-net-switchlib-add-driver-for-Lantiq-PSB697X-switch-f.patch
new file mode 100644
index 0000000..c017e0f
--- /dev/null
+++ b/package/boot/uboot-lantiq/patches/0020-net-switchlib-add-driver-for-Lantiq-PSB697X-switch-f.patch
@@ -0,0 +1,162 @@
+From b8c666eda693906488637c414db9db35b6760e4a Mon Sep 17 00:00:00 2001
+From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+Date: Wed, 29 Aug 2012 22:08:15 +0200
+Subject: net: switchlib: add driver for Lantiq PSB697X switch family
+
+Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+
+--- a/drivers/net/switch/Makefile
++++ b/drivers/net/switch/Makefile
+@@ -11,6 +11,7 @@ include $(TOPDIR)/config.mk
+ LIB := $(obj)libswitch.o
+
+ COBJS-$(CONFIG_SWITCH_MULTI) += switch.o
++COBJS-$(CONFIG_SWITCH_PSB697X) += psb697x.o
+
+ COBJS := $(COBJS-y)
+ SRCS := $(COBJS:.o=.c)
+--- /dev/null
++++ b/drivers/net/switch/psb697x.c
+@@ -0,0 +1,119 @@
++/*
++ * Copyright (C) 2011-2012 Daniel Schwierzeck, daniel.schwierzeck@gmail.com
++ *
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ */
++
++#include <common.h>
++#include <malloc.h>
++#include <switch.h>
++#include <miiphy.h>
++
++#define PSB697X_CHIPID1 0x2599
++#define PSB697X_PORT_COUNT 7
++
++#define PSB697X_PORT_BASE(p) (p * 0x20)
++#define PSB697X_REG_PS(p) (PSB697X_PORT_BASE(p) + 0x00)
++#define PSB697X_REG_PBC(p) (PSB697X_PORT_BASE(p) + 0x01)
++#define PSB697X_REG_PEC(p) (PSB697X_PORT_BASE(p) + 0x02)
++
++#define PSB697X_REG_SGC1 0x0E0 /* Switch Global Control Register 1 */
++#define PSB697X_REG_SGC2 0x0E1 /* Switch Global Control Register 2 */
++#define PSB697X_REG_CMH 0x0E2 /* CPU Port & Mirror Control */
++#define PSB697X_REG_MIICR 0x0F5 /* MII Port Control */
++#define PSB697X_REG_CI0 0x100 /* Chip Identifier 0 */
++#define PSB697X_REG_CI1 0x101 /* Chip Identifier 1 */
++#define PSB697X_REG_MIIAC 0x120 /* MII Indirect Access Control */
++#define PSB697X_REG_MIIWD 0x121 /* MII Indirect Write Data */
++#define PSB697X_REG_MIIRD 0x122 /* MII Indirect Read Data */
++
++#define PSB697X_REG_PORT_FLP (1 << 2) /* Force link up */
++#define PSB697X_REG_PORT_FLD (1 << 1) /* Force link down */
++
++#define PSB697X_REG_SGC2_SE (1 << 15) /* Switch enable */
++
++#define PSB697X_REG_CMH_CPN_MASK 0x7
++#define PSB697X_REG_CMH_CPN_SHIFT 5
++
++
++static inline int psb697x_mii_read(struct mii_dev *bus, u16 reg)
++{
++ int ret;
++
++ ret = bus->read(bus, (reg >> 5) & 0x1f, MDIO_DEVAD_NONE, reg & 0x1f);
++
++ return ret;
++}
++
++static inline int psb697x_mii_write(struct mii_dev *bus, u16 reg, u16 val)
++{
++ int ret;
++
++ ret = bus->write(bus, (reg >> 5) & 0x1f, MDIO_DEVAD_NONE,
++ reg & 0x1f, val);
++
++ return ret;
++}
++
++static int psb697x_probe(struct switch_device *dev)
++{
++ struct mii_dev *bus = dev->bus;
++ int ci1;
++
++ ci1 = psb697x_mii_read(bus, PSB697X_REG_CI1);
++
++ if (ci1 == PSB697X_CHIPID1)
++ return 0;
++
++ return 1;
++}
++
++static void psb697x_setup(struct switch_device *dev)
++{
++ struct mii_dev *bus = dev->bus;
++ int i, state;
++
++ /* Enable switch */
++ psb697x_mii_write(bus, PSB697X_REG_SGC2, PSB697X_REG_SGC2_SE);
++
++ /*
++ * Force 100 Mbps as default value for CPU ports 5 and 6 to get
++ * full speed.
++ */
++ psb697x_mii_write(bus, PSB697X_REG_MIICR, 0x0773);
++
++ for (i = 0; i < PSB697X_PORT_COUNT; i++) {
++ state = dev->port_mask & (1 << i);
++
++ /*
++ * Software workaround from Errata Sheet:
++ * Force link down and reset internal PHY, keep that state
++ * for all unconnected ports and disable force link down
++ * for all connected ports
++ */
++ psb697x_mii_write(bus, PSB697X_REG_PBC(i),
++ PSB697X_REG_PORT_FLD);
++
++ if (i == dev->cpu_port)
++ /* Force link up for CPU port */
++ psb697x_mii_write(bus, PSB697X_REG_PBC(i),
++ PSB697X_REG_PORT_FLP);
++ else if (state)
++ /* Disable force link down for active LAN ports */
++ psb697x_mii_write(bus, PSB697X_REG_PBC(i), 0);
++ }
++}
++
++static struct switch_driver psb697x_drv = {
++ .name = "psb697x",
++};
++
++void switch_psb697x_init(void)
++{
++ /* For archs with manual relocation */
++ psb697x_drv.probe = psb697x_probe;
++ psb697x_drv.setup = psb697x_setup;
++
++ switch_driver_register(&psb697x_drv);
++}
+--- a/drivers/net/switch/switch.c
++++ b/drivers/net/switch/switch.c
+@@ -18,6 +18,10 @@ void switch_init(void)
+ INIT_LIST_HEAD(&switch_drivers);
+ INIT_LIST_HEAD(&switch_devices);
+
++#if defined(CONFIG_SWITCH_PSB697X)
++ switch_psb697x_init();
++#endif
++
+ board_switch_init();
+ }
+
+--- a/include/switch.h
++++ b/include/switch.h
+@@ -90,6 +90,7 @@ static inline void switch_setup(struct s
+ }
+
+ /* Init functions for supported Switch drivers */
++extern void switch_psb697x_init(void);
+
+ #endif /* __SWITCH_H */
+
diff --git a/package/boot/uboot-lantiq/patches/0021-net-switchlib-add-driver-for-Lantiq-ADM6996I-switch-.patch b/package/boot/uboot-lantiq/patches/0021-net-switchlib-add-driver-for-Lantiq-ADM6996I-switch-.patch
new file mode 100644
index 0000000..342fa46
--- /dev/null
+++ b/package/boot/uboot-lantiq/patches/0021-net-switchlib-add-driver-for-Lantiq-ADM6996I-switch-.patch
@@ -0,0 +1,158 @@
+From fcbbb1beb2ae862f5c703c5719ed0e155cbbf82f Mon Sep 17 00:00:00 2001
+From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+Date: Wed, 29 Aug 2012 22:08:16 +0200
+Subject: net: switchlib: add driver for Lantiq ADM6996I switch family
+
+Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+
+--- a/drivers/net/switch/Makefile
++++ b/drivers/net/switch/Makefile
+@@ -12,6 +12,7 @@ LIB := $(obj)libswitch.o
+
+ COBJS-$(CONFIG_SWITCH_MULTI) += switch.o
+ COBJS-$(CONFIG_SWITCH_PSB697X) += psb697x.o
++COBJS-$(CONFIG_SWITCH_ADM6996I) += adm6996i.o
+
+ COBJS := $(COBJS-y)
+ SRCS := $(COBJS:.o=.c)
+--- /dev/null
++++ b/drivers/net/switch/adm6996i.c
+@@ -0,0 +1,116 @@
++/*
++ * Copyright (C) 2011-2012 Daniel Schwierzeck, daniel.schwierzeck@gmail.com
++ *
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ */
++
++#include <common.h>
++#include <malloc.h>
++#include <switch.h>
++#include <miiphy.h>
++
++#define ADM6996I_CHIPID0 0x1020
++#define ADM6996I_CHIPID1 0x0007
++#define ADM6996I_PORT_COUNT 6
++
++#define ADM6996I_REG_P0BC 0x001 /* P0 Basic Control */
++#define ADM6996I_REG_P1BC 0x003 /* P1 Basic Control */
++#define ADM6996I_REG_P2BC 0x005 /* P2 Basic Control */
++#define ADM6996I_REG_P3BC 0x007 /* P3 Basic Control */
++#define ADM6996I_REG_P4BC 0x008 /* P4 Basic Control */
++#define ADM6996I_REG_P5BC 0x009 /* P5 Basic Control */
++
++#define ADM6996I_REG_P0EC 0x002 /* P0 Extended Control */
++#define ADM6996I_REG_P1EC 0x002 /* P1 Extended Control */
++#define ADM6996I_REG_P2EC 0x004 /* P2 Extended Control */
++#define ADM6996I_REG_P3EC 0x004 /* P3 Extended Control */
++#define ADM6996I_REG_P4EC 0x006 /* P4 Extended Control */
++#define ADM6996I_REG_P5EC 0x006 /* P5 Extended Control */
++
++#define ADM6996I_REG_SC4 0x012 /* System Control 4 */
++
++#define ADM6996I_REG_CI0 0xA0 /* Chip Identifier 0 */
++#define ADM6996I_REG_CI1 0xA1 /* Chip Identifier 1 */
++
++#define ADM6996I_REG_PXBC_DEFAULT 0x040F
++#define ADM6996I_REG_PXBC_CROSS_EE (1 << 15)
++#define ADM6996I_REG_PXBC_PD (1 << 5)
++
++#define ADM6996I_REG_SC4_DEFAULT 0x3600
++#define ADM6996I_REG_SC4_LED_ENABLE (1 << 1)
++
++#define ADM6996I_REG_CI0_PC_MASK 0xFFF0
++#define ADM6996I_REG_CI0_VN_MASK 0xF
++#define ADM6996I_REG_CI1_PC_MASK 0xF
++
++
++static inline int adm6996i_mii_read(struct mii_dev *bus, u16 reg)
++{
++ int ret;
++
++ ret = bus->read(bus, (reg >> 5) & 0x1f, MDIO_DEVAD_NONE, reg & 0x1f);
++
++ return ret;
++}
++
++static inline int adm6996i_mii_write(struct mii_dev *bus, u16 reg, u16 val)
++{
++ int ret;
++
++ ret = bus->write(bus, (reg >> 5) & 0x1f, MDIO_DEVAD_NONE,
++ reg & 0x1f, val);
++
++ return ret;
++}
++
++static int adm6996i_probe(struct switch_device *dev)
++{
++ struct mii_dev *bus = dev->bus;
++ u16 ci0, ci1;
++
++ ci0 = adm6996i_mii_read(bus, ADM6996I_REG_CI0);
++ ci1 = adm6996i_mii_read(bus, ADM6996I_REG_CI1);
++
++ ci0 &= ADM6996I_REG_CI0_PC_MASK;
++ ci1 &= ADM6996I_REG_CI1_PC_MASK;
++
++ if (ci0 == ADM6996I_CHIPID0 && ci1 == ADM6996I_CHIPID1)
++ return 0;
++
++ return 1;
++}
++
++static void adm6996i_setup(struct switch_device *dev)
++{
++ struct mii_dev *bus = dev->bus;
++ u16 val;
++
++ /*
++ * Write default values (Port enable, 100 Mbps, Full Duplex,
++ * Auto negotiation, Flow control) and enable crossover auto-detect
++ */
++ val = ADM6996I_REG_PXBC_DEFAULT | ADM6996I_REG_PXBC_CROSS_EE;
++ adm6996i_mii_write(bus, ADM6996I_REG_P0BC, val);
++ adm6996i_mii_write(bus, ADM6996I_REG_P1BC, val);
++ adm6996i_mii_write(bus, ADM6996I_REG_P2BC, val);
++ adm6996i_mii_write(bus, ADM6996I_REG_P3BC, val);
++ adm6996i_mii_write(bus, ADM6996I_REG_P4BC, val);
++ adm6996i_mii_write(bus, ADM6996I_REG_P5BC, val);
++
++ val = ADM6996I_REG_SC4_DEFAULT | ADM6996I_REG_SC4_LED_ENABLE;
++ adm6996i_mii_write(bus, ADM6996I_REG_SC4, val);
++}
++
++static struct switch_driver adm6996i_drv = {
++ .name = "adm6996i",
++};
++
++void switch_adm6996i_init(void)
++{
++ /* For archs with manual relocation */
++ adm6996i_drv.probe = adm6996i_probe;
++ adm6996i_drv.setup = adm6996i_setup;
++
++ switch_driver_register(&adm6996i_drv);
++}
+--- a/drivers/net/switch/switch.c
++++ b/drivers/net/switch/switch.c
+@@ -21,6 +21,9 @@ void switch_init(void)
+ #if defined(CONFIG_SWITCH_PSB697X)
+ switch_psb697x_init();
+ #endif
++#if defined(CONFIG_SWITCH_ADM6996I)
++ switch_adm6996i_init();
++#endif
+
+ board_switch_init();
+ }
+--- a/include/switch.h
++++ b/include/switch.h
+@@ -91,6 +91,7 @@ static inline void switch_setup(struct s
+
+ /* Init functions for supported Switch drivers */
+ extern void switch_psb697x_init(void);
++extern void switch_adm6996i_init(void);
+
+ #endif /* __SWITCH_H */
+
diff --git a/package/boot/uboot-lantiq/patches/0022-net-switchlib-add-driver-for-Atheros-AR8216.patch b/package/boot/uboot-lantiq/patches/0022-net-switchlib-add-driver-for-Atheros-AR8216.patch
new file mode 100644
index 0000000..127c0d8
--- /dev/null
+++ b/package/boot/uboot-lantiq/patches/0022-net-switchlib-add-driver-for-Atheros-AR8216.patch
@@ -0,0 +1,158 @@
+From 16b8c52f80f20e07866e397ff52ff9658766437b Mon Sep 17 00:00:00 2001
+From: Luka Perkov <luka@openwrt.org>
+Date: Wed, 29 Aug 2012 22:08:16 +0200
+Subject: net: switchlib: add driver for Atheros AR8216
+
+Signed-off-by: Luka Perkov <luka@openwrt.org>
+Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+
+--- a/drivers/net/switch/Makefile
++++ b/drivers/net/switch/Makefile
+@@ -13,6 +13,7 @@ LIB := $(obj)libswitch.o
+ COBJS-$(CONFIG_SWITCH_MULTI) += switch.o
+ COBJS-$(CONFIG_SWITCH_PSB697X) += psb697x.o
+ COBJS-$(CONFIG_SWITCH_ADM6996I) += adm6996i.o
++COBJS-$(CONFIG_SWITCH_AR8216) += ar8216.o
+
+ COBJS := $(COBJS-y)
+ SRCS := $(COBJS:.o=.c)
+--- /dev/null
++++ b/drivers/net/switch/ar8216.c
+@@ -0,0 +1,115 @@
++/*
++ * Copyright (C) 2012 Luka Perkov <luka@openwrt.org>
++ *
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ */
++
++#include <common.h>
++#include <malloc.h>
++#include <miiphy.h>
++#include <switch.h>
++#include <netdev.h>
++
++#define BITS(_s, _n) (((1UL << (_n)) - 1) << _s)
++
++#define AR8216_REG_CTRL 0x0000
++#define AR8216_CTRL_REVISION BITS(0, 8)
++#define AR8216_CTRL_VERSION BITS(8, 8)
++
++#define AR8216_PROBE_RETRIES 10
++
++static void split_addr(u32 regaddr, u16 *r1, u16 *r2, u16 *page)
++{
++ regaddr >>= 1;
++ *r1 = regaddr & 0x1e;
++
++ regaddr >>= 5;
++ *r2 = regaddr & 0x7;
++
++ regaddr >>= 3;
++ *page = regaddr & 0x1ff;
++}
++
++static int ar8216_mii_read(struct mii_dev *bus, u32 reg)
++{
++ u16 r1, r2, page;
++ u16 lo, hi;
++
++ split_addr(reg, &r1, &r2, &page);
++
++ bus->write(bus, 0x18, MDIO_DEVAD_NONE, 0, page);
++ __udelay(1000);
++
++ lo = bus->read(bus, 0x10 | r2, MDIO_DEVAD_NONE, r1);
++ hi = bus->read(bus, 0x10 | r2, MDIO_DEVAD_NONE, r1 + 1);
++
++ return (hi << 16) | lo;
++}
++
++static void ar8216_mii_write(struct mii_dev *bus, u16 reg, u32 val)
++{
++ u16 r1, r2, r3;
++ u16 lo, hi;
++
++ split_addr((u32) reg, &r1, &r2, &r3);
++
++ bus->write(bus, 0x18, MDIO_DEVAD_NONE, 0, r3);
++ __udelay(1000);
++
++ lo = val & 0xffff;
++ hi = (u16) (val >> 16);
++ bus->write(bus, 0x10 | r2, MDIO_DEVAD_NONE, r1 + 1, hi);
++ bus->write(bus, 0x10 | r2, MDIO_DEVAD_NONE, r1, lo);
++}
++
++static int ar8216_probe(struct switch_device *dev)
++{
++ struct mii_dev *bus = dev->bus;
++ u32 val;
++ u16 id;
++
++ val = ar8216_mii_read(bus, AR8216_REG_CTRL);
++ if (val == ~0)
++ return 1;
++
++ id = val & (AR8216_CTRL_REVISION | AR8216_CTRL_VERSION);
++
++ switch (id) {
++ case 0x0101:
++ return 0;
++ default:
++ return 1;
++ }
++}
++
++static void ar8216_setup(struct switch_device *dev)
++{
++ struct mii_dev *bus = dev->bus;
++
++ ar8216_mii_write(bus, 0x200, 0x200);
++ ar8216_mii_write(bus, 0x300, 0x200);
++ ar8216_mii_write(bus, 0x400, 0x200);
++ ar8216_mii_write(bus, 0x500, 0x200);
++ ar8216_mii_write(bus, 0x600, 0x7d);
++ ar8216_mii_write(bus, 0x38, 0xc000050e);
++ ar8216_mii_write(bus, 0x104, 0x4004);
++ ar8216_mii_write(bus, 0x60, 0xffffffff);
++ ar8216_mii_write(bus, 0x64, 0xaaaaaaaa);
++ ar8216_mii_write(bus, 0x68, 0x55555555);
++ ar8216_mii_write(bus, 0x6c, 0x0);
++ ar8216_mii_write(bus, 0x70, 0x41af);
++}
++
++static struct switch_driver ar8216_drv = {
++ .name = "ar8216",
++};
++
++void switch_ar8216_init(void)
++{
++ /* for archs with manual relocation */
++ ar8216_drv.probe = ar8216_probe;
++ ar8216_drv.setup = ar8216_setup;
++
++ switch_driver_register(&ar8216_drv);
++}
+--- a/drivers/net/switch/switch.c
++++ b/drivers/net/switch/switch.c
+@@ -24,6 +24,9 @@ void switch_init(void)
+ #if defined(CONFIG_SWITCH_ADM6996I)
+ switch_adm6996i_init();
+ #endif
++#if defined(CONFIG_SWITCH_AR8216)
++ switch_ar8216_init();
++#endif
+
+ board_switch_init();
+ }
+--- a/include/switch.h
++++ b/include/switch.h
+@@ -92,6 +92,7 @@ static inline void switch_setup(struct s
+ /* Init functions for supported Switch drivers */
+ extern void switch_psb697x_init(void);
+ extern void switch_adm6996i_init(void);
++extern void switch_ar8216_init(void);
+
+ #endif /* __SWITCH_H */
+
diff --git a/package/boot/uboot-lantiq/patches/0023-MIPS-add-support-for-Lantiq-XWAY-SoCs.patch b/package/boot/uboot-lantiq/patches/0023-MIPS-add-support-for-Lantiq-XWAY-SoCs.patch
new file mode 100644
index 0000000..2582c16
--- /dev/null
+++ b/package/boot/uboot-lantiq/patches/0023-MIPS-add-support-for-Lantiq-XWAY-SoCs.patch
@@ -0,0 +1,9496 @@
+From ed2effe0839929d00f05ec0e1e16fb467f324e1b Mon Sep 17 00:00:00 2001
+From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+Date: Thu, 20 Dec 2012 19:05:54 +0100
+Subject: MIPS: add support for Lantiq XWAY SoCs
+
+Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+
+--- a/.gitignore
++++ b/.gitignore
+@@ -44,6 +44,13 @@
+ /u-boot.sb
+ /u-boot.geany
+ /include/u-boot.lst
++/u-boot.bin.lzma
++/u-boot.bin.lzo
++/u-boot.ltq.lzma.norspl
++/u-boot.ltq.lzo.norspl
++/u-boot.ltq.norspl
++/u-boot.lzma.img
++/u-boot.lzo.img
+
+ #
+ # Generated files
+--- a/Makefile
++++ b/Makefile
+@@ -441,6 +441,12 @@ $(obj)u-boot.bin: $(obj)u-boot
+ $(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
+ $(BOARD_SIZE_CHECK)
+
++$(obj)u-boot.bin.lzma: $(obj)u-boot.bin
++ cat $< | lzma -9 -f - > $@
++
++$(obj)u-boot.bin.lzo: $(obj)u-boot.bin
++ cat $< | lzop -9 -f - > $@
++
+ $(obj)u-boot.ldr: $(obj)u-boot
+ $(CREATE_LDR_ENV)
+ $(LDR) -T $(CONFIG_BFIN_CPU) -c $@ $< $(LDR_FLAGS)
+@@ -460,13 +466,23 @@ ifndef CONFIG_SYS_UBOOT_START
+ CONFIG_SYS_UBOOT_START := 0
+ endif
+
+-$(obj)u-boot.img: $(obj)u-boot.bin
+- $(obj)tools/mkimage -A $(ARCH) -T firmware -C none \
++define GEN_UBOOT_IMAGE
++ $(obj)tools/mkimage -A $(ARCH) -T firmware -C $(1) \
+ -O u-boot -a $(CONFIG_SYS_TEXT_BASE) \
+ -e $(CONFIG_SYS_UBOOT_START) \
+ -n $(shell sed -n -e 's/.*U_BOOT_VERSION//p' $(VERSION_FILE) | \
+ sed -e 's/"[ ]*$$/ for $(BOARD) board"/') \
+ -d $< $@
++endef
++
++$(obj)u-boot.img: $(obj)u-boot.bin
++ $(call GEN_UBOOT_IMAGE,none)
++
++$(obj)u-boot.lzma.img: $(obj)u-boot.bin.lzma
++ $(call GEN_UBOOT_IMAGE,lzma)
++
++$(obj)u-boot.lzo.img: $(obj)u-boot.bin.lzo
++ $(call GEN_UBOOT_IMAGE,lzo)
+
+ $(obj)u-boot.imx: $(obj)u-boot.bin
+ $(obj)tools/mkimage -n $(CONFIG_IMX_CONFIG) -T imximage \
+@@ -549,6 +565,27 @@ endif
+ $(obj)u-boot-img.bin: $(obj)spl/u-boot-spl.bin $(obj)u-boot.img
+ cat $(obj)spl/u-boot-spl.bin $(obj)u-boot.img > $@
+
++$(obj)u-boot.ltq.sfspl: $(obj)u-boot.img $(obj)spl/u-boot-spl.bin
++ $(obj)tools/ltq-boot-image -t sfspl -e $(CONFIG_SPL_TEXT_BASE) \
++ -s $(obj)spl/u-boot-spl.bin -u $< -o $@
++
++$(obj)u-boot.ltq.lzo.sfspl: $(obj)u-boot.lzo.img $(obj)spl/u-boot-spl.bin
++ $(obj)tools/ltq-boot-image -t sfspl -e $(CONFIG_SPL_TEXT_BASE) \
++ -s $(obj)spl/u-boot-spl.bin -u $< -o $@
++
++$(obj)u-boot.ltq.lzma.sfspl: $(obj)u-boot.lzma.img $(obj)spl/u-boot-spl.bin
++ $(obj)tools/ltq-boot-image -t sfspl -e $(CONFIG_SPL_TEXT_BASE) \
++ -s $(obj)spl/u-boot-spl.bin -u $< -o $@
++
++$(obj)u-boot.ltq.norspl: $(obj)u-boot.img $(obj)spl/u-boot-spl.bin
++ cat $(obj)spl/u-boot-spl.bin $< > $@
++
++$(obj)u-boot.ltq.lzo.norspl: $(obj)u-boot.lzo.img $(obj)spl/u-boot-spl.bin
++ cat $(obj)spl/u-boot-spl.bin $< > $@
++
++$(obj)u-boot.ltq.lzma.norspl: $(obj)u-boot.lzma.img $(obj)spl/u-boot-spl.bin
++ cat $(obj)spl/u-boot-spl.bin $< > $@
++
+ ifeq ($(CONFIG_SANDBOX),y)
+ GEN_UBOOT = \
+ cd $(LNDIR) && $(CC) $(SYMS) -T $(obj)u-boot.lds \
+--- a/README
++++ b/README
+@@ -460,6 +460,11 @@ The following options need to be configu
+ CONF_CM_CACHABLE_CUW
+ CONF_CM_CACHABLE_ACCELERATED
+
++ CONFIG_SYS_MIPS_CACHE_EXT_INIT
++
++ Enable this to use extended cache initialization for recent
++ MIPS CPU cores.
++
+ CONFIG_SYS_XWAY_EBU_BOOTCFG
+
+ Special option for Lantiq XWAY SoCs for booting from NOR flash.
+--- a/arch/mips/config.mk
++++ b/arch/mips/config.mk
+@@ -61,7 +61,10 @@ PLATFORM_CPPFLAGS += -DCONFIG_MIPS -D__M
+ # On the other hand, we want PIC in the U-Boot code to relocate it from ROM
+ # to RAM. $28 is always used as gp.
+ #
+-PLATFORM_CPPFLAGS += -G 0 -mabicalls -fpic $(ENDIANNESS)
++PF_ABICALLS ?= -mabicalls
++PF_PIC ?= -fpic
++
++PLATFORM_CPPFLAGS += -G 0 $(PF_ABICALLS) $(PF_PIC) $(ENDIANNESS)
+ PLATFORM_CPPFLAGS += -msoft-float
+ PLATFORM_LDFLAGS += -G 0 -static -n -nostdlib $(ENDIANNESS)
+ PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections
+--- a/arch/mips/cpu/mips32/cache.S
++++ b/arch/mips/cpu/mips32/cache.S
+@@ -45,7 +45,11 @@
+ */
+ #define MIPS_MAX_CACHE_SIZE 0x10000
+
++#ifdef CONFIG_SYS_MIPS_CACHE_EXT_INIT
++#define INDEX_BASE 0x9fc00000
++#else
+ #define INDEX_BASE CKSEG0
++#endif
+
+ .macro cache_op op addr
+ .set push
+@@ -81,7 +85,11 @@
+ */
+ LEAF(mips_init_icache)
+ blez a1, 9f
++#ifdef CONFIG_SYS_MIPS_CACHE_EXT_INIT
++ mtc0 zero, CP0_ITAGLO
++#else
+ mtc0 zero, CP0_TAGLO
++#endif
+ /* clear tag to invalidate */
+ PTR_LI t0, INDEX_BASE
+ PTR_ADDU t1, t0, a1
+@@ -106,7 +114,11 @@ LEAF(mips_init_icache)
+ */
+ LEAF(mips_init_dcache)
+ blez a1, 9f
++#ifdef CONFIG_SYS_MIPS_CACHE_EXT_INIT
++ mtc0 zero, CP0_DTAGLO
++#else
+ mtc0 zero, CP0_TAGLO
++#endif
+ /* clear all tags */
+ PTR_LI t0, INDEX_BASE
+ PTR_ADDU t1, t0, a1
+--- /dev/null
++++ b/arch/mips/cpu/mips32/danube/Makefile
+@@ -0,0 +1,33 @@
++#
++# This file is released under the terms of GPL v2 and any later version.
++# See the file COPYING in the root directory of the source tree for details.
++#
++# Copyright (C) 2000-2011 Wolfgang Denk, DENX Software Engineering, wd@denx.de
++# Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++#
++
++include $(TOPDIR)/config.mk
++
++LIB = $(obj)lib$(SOC).o
++
++COBJS-y += cgu.o chipid.o ebu.o mem.o pmu.o rcu.o
++SOBJS-y += cgu_init.o mem_init.o
++
++COBJS := $(COBJS-y)
++SOBJS := $(SOBJS-y)
++SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c)
++OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS))
++
++all: $(LIB)
++
++$(LIB): $(obj).depend $(OBJS)
++ $(call cmd_link_o_target, $(OBJS))
++
++#########################################################################
++
++# defines $(obj).depend target
++include $(SRCTREE)/rules.mk
++
++sinclude $(obj).depend
++
++#########################################################################
+--- /dev/null
++++ b/arch/mips/cpu/mips32/danube/cgu.c
+@@ -0,0 +1,118 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2007-2010 Lantiq Deutschland GmbH
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <common.h>
++#include <asm/arch/soc.h>
++#include <asm/lantiq/clk.h>
++#include <asm/lantiq/io.h>
++
++#define LTQ_CGU_SYS_DDR_MASK 0x0003
++#define LTQ_CGU_SYS_DDR_SHIFT 0
++#define LTQ_CGU_SYS_CPU0_MASK 0x000C
++#define LTQ_CGU_SYS_CPU0_SHIFT 2
++#define LTQ_CGU_SYS_FPI_MASK 0x0040
++#define LTQ_CGU_SYS_FPI_SHIFT 6
++
++struct ltq_cgu_regs {
++ u32 rsvd0;
++ u32 pll0_cfg; /* PLL0 config */
++ u32 pll1_cfg; /* PLL1 config */
++ u32 pll2_cfg; /* PLL2 config */
++ u32 sys; /* System clock */
++ u32 update; /* CGU update control */
++ u32 if_clk; /* Interface clock */
++ u32 osc_con; /* Update OSC Control */
++ u32 smd; /* SDRAM Memory Control */
++ u32 rsvd1[3];
++ u32 pcm_cr; /* PCM control */
++ u32 pci_cr; /* PCI clock control */
++};
++
++static struct ltq_cgu_regs *ltq_cgu_regs =
++ (struct ltq_cgu_regs *) CKSEG1ADDR(LTQ_CGU_BASE);
++
++static inline u32 ltq_cgu_sys_readl(u32 mask, u32 shift)
++{
++ return (ltq_readl(&ltq_cgu_regs->sys) & mask) >> shift;
++}
++
++unsigned long ltq_get_io_region_clock(void)
++{
++ u32 ddr_sel;
++ unsigned long clk;
++
++ ddr_sel = ltq_cgu_sys_readl(LTQ_CGU_SYS_DDR_MASK,
++ LTQ_CGU_SYS_DDR_SHIFT);
++
++ switch (ddr_sel) {
++ case 0:
++ clk = CLOCK_166_MHZ;
++ break;
++ case 1:
++ clk = CLOCK_133_MHZ;
++ break;
++ case 2:
++ clk = CLOCK_111_MHZ;
++ break;
++ case 3:
++ clk = CLOCK_83_MHZ;
++ break;
++ default:
++ clk = 0;
++ break;
++ }
++
++ return clk;
++}
++
++unsigned long ltq_get_cpu_clock(void)
++{
++ u32 cpu0_sel;
++ unsigned long clk;
++
++ cpu0_sel = ltq_cgu_sys_readl(LTQ_CGU_SYS_CPU0_MASK,
++ LTQ_CGU_SYS_CPU0_SHIFT);
++
++ switch (cpu0_sel) {
++ /* Same as PLL0 output (333,33 MHz) */
++ case 0:
++ clk = CLOCK_333_MHZ;
++ break;
++ /* 1/1 fixed ratio to DDR clock */
++ case 1:
++ clk = ltq_get_io_region_clock();
++ break;
++ /* 1/2 fixed ratio to DDR clock */
++ case 2:
++ clk = ltq_get_io_region_clock() << 1;
++ break;
++ default:
++ clk = 0;
++ break;
++ }
++
++ return clk;
++}
++
++unsigned long ltq_get_bus_clock(void)
++{
++ u32 fpi_sel;
++ unsigned long clk;
++
++ fpi_sel = ltq_cgu_sys_readl(LTQ_CGU_SYS_FPI_MASK,
++ LTQ_CGU_SYS_FPI_SHIFT);
++
++ if (fpi_sel)
++ /* Half the DDR clock */
++ clk = ltq_get_io_region_clock() >> 1;
++ else
++ /* Same as DDR clock */
++ clk = ltq_get_io_region_clock();
++
++ return clk;
++}
+--- /dev/null
++++ b/arch/mips/cpu/mips32/danube/cgu_init.S
+@@ -0,0 +1,143 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2007-2010 Lantiq Deutschland GmbH
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <config.h>
++#include <asm/asm.h>
++#include <asm/regdef.h>
++#include <asm/addrspace.h>
++#include <asm/arch/soc.h>
++
++/* RCU module register */
++#define LTQ_RCU_RST_REQ 0x0010
++#define LTQ_RCU_RST_STAT 0x0014
++#define LTQ_RCU_RST_REQ_VALUE 0x40000008
++#define LTQ_RCU_RST_STAT_XTAL_F 0x20000
++
++/* CGU module register */
++#define LTQ_CGU_PLL0_CFG 0x0004 /* PLL0 config */
++#define LTQ_CGU_PLL1_CFG 0x0008 /* PLL1 config */
++#define LTQ_CGU_PLL2_CFG 0x000C /* PLL2 config */
++#define LTQ_CGU_SYS 0x0010 /* System clock */
++
++/* Valid SYS.CPU0/1 values */
++#define LTQ_CGU_SYS_CPU0_SHIFT 2
++#define LTQ_CGU_SYS_CPU1_SHIFT 4
++#define LTQ_CGU_SYS_CPU_PLL0 0x0
++#define LTQ_CGU_SYS_CPU_DDR_EQUAL 0x1
++#define LTQ_CGU_SYS_CPU_DDR_TWICE 0x2
++
++/* Valid SYS.DDR values */
++#define LTQ_CGU_SYS_DDR_SHIFT 0
++#define LTQ_CGU_SYS_DDR_167_MHZ 0x0
++#define LTQ_CGU_SYS_DDR_133_MHZ 0x1
++#define LTQ_CGU_SYS_DDR_111_MHZ 0x2
++#define LTQ_CGU_SYS_DDR_83_MHZ 0x3
++
++/* Valid SYS.FPI values */
++#define LTQ_CGU_SYS_FPI_SHIFT 6
++#define LTQ_CGU_SYS_FPI_DDR_EQUAL 0x0
++#define LTQ_CGU_SYS_FPI_DDR_HALF 0x1
++
++/* Valid SYS.PPE values */
++#define LTQ_CGU_SYS_PPE_SHIFT 7
++#define LTQ_CGU_SYS_PPE_266_MHZ 0x0
++#define LTQ_CGU_SYS_PPE_240_MHZ 0x1
++#define LTQ_CGU_SYS_PPE_222_MHZ 0x2
++#define LTQ_CGU_SYS_PPE_133_MHZ 0x3
++
++#if (CONFIG_SYS_CLOCK_MODE == LTQ_CLK_CPU_333_DDR_167)
++#define LTQ_CGU_SYS_CPU_CONFIG LTQ_CGU_SYS_CPU_DDR_TWICE
++#define LTQ_CGU_SYS_DDR_CONFIG LTQ_CGU_SYS_DDR_167_MHZ
++#define LTQ_CGU_SYS_FPI_CONFIG LTQ_CGU_SYS_FPI_DDR_HALF
++#define LTQ_CGU_SYS_PPE_CONFIG LTQ_CGU_SYS_PPE_266_MHZ
++#elif (CONFIG_SYS_CLOCK_MODE == LTQ_CLK_CPU_111_DDR_111)
++#define LTQ_CGU_SYS_CPU_CONFIG LTQ_CGU_SYS_CPU_DDR_EQUAL
++#define LTQ_CGU_SYS_DDR_CONFIG LTQ_CGU_SYS_DDR_111_MHZ
++#define LTQ_CGU_SYS_FPI_CONFIG LTQ_CGU_SYS_FPI_DDR_HALF
++#define LTQ_CGU_SYS_PPE_CONFIG LTQ_CGU_SYS_PPE_133_MHZ
++#else
++#error "Invalid system clock configuration!"
++#endif
++
++/* Build register values */
++#define LTQ_CGU_SYS_VALUE ((LTQ_CGU_SYS_PPE_CONFIG << \
++ LTQ_CGU_SYS_PPE_SHIFT) | \
++ (LTQ_CGU_SYS_FPI_CONFIG << \
++ LTQ_CGU_SYS_FPI_SHIFT) | \
++ (LTQ_CGU_SYS_CPU_CONFIG << \
++ LTQ_CGU_SYS_CPU1_SHIFT) | \
++ (LTQ_CGU_SYS_CPU_CONFIG << \
++ LTQ_CGU_SYS_CPU0_SHIFT) | \
++ LTQ_CGU_SYS_DDR_CONFIG)
++
++/* Reset values for PLL registers for usage with 35.328 MHz crystal */
++#define PLL0_35MHZ_CONFIG 0x9D861059
++#define PLL1_35MHZ_CONFIG 0x1A260CD9
++#define PLL2_35MHZ_CONFIG 0x8000f1e5
++
++/* Reset values for PLL registers for usage with 36 MHz crystal */
++#define PLL0_36MHZ_CONFIG 0x1000125D
++#define PLL1_36MHZ_CONFIG 0x1B1E0C99
++#define PLL2_36MHZ_CONFIG 0x8002f2a1
++
++LEAF(ltq_cgu_init)
++ /* Load current CGU register value */
++ li t0, (LTQ_CGU_BASE | KSEG1)
++ lw t1, LTQ_CGU_SYS(t0)
++
++ /* Load target CGU register values */
++ li t3, LTQ_CGU_SYS_VALUE
++
++ /* Only update registers if values differ */
++ beq t1, t3, finished
++
++ /*
++ * Check whether the XTAL_F bit in RST_STAT register is set or not.
++ * This bit is latched in via pin strapping. If bit is set then
++ * clock source is a 36 MHz crystal. Otherwise a 35.328 MHz crystal.
++ */
++ li t1, (LTQ_RCU_BASE | KSEG1)
++ lw t2, LTQ_RCU_RST_STAT(t1)
++ and t2, t2, LTQ_RCU_RST_STAT_XTAL_F
++ beq t2, LTQ_RCU_RST_STAT_XTAL_F, boot_36mhz
++
++boot_35mhz:
++ /* Configure PLL for 35.328 MHz */
++ li t2, PLL0_35MHZ_CONFIG
++ sw t2, LTQ_CGU_PLL0_CFG(t0)
++ li t2, PLL1_35MHZ_CONFIG
++ sw t2, LTQ_CGU_PLL1_CFG(t0)
++ li t2, PLL2_35MHZ_CONFIG
++ sw t2, LTQ_CGU_PLL2_CFG(t0)
++
++ b do_reset
++
++boot_36mhz:
++ /* Configure PLL for 36 MHz */
++ li t2, PLL0_36MHZ_CONFIG
++ sw t2, LTQ_CGU_PLL0_CFG(t0)
++ li t2, PLL1_36MHZ_CONFIG
++ sw t2, LTQ_CGU_PLL1_CFG(t0)
++ li t2, PLL2_36MHZ_CONFIG
++ sw t2, LTQ_CGU_PLL2_CFG(t0)
++
++do_reset:
++ /* Store new clock config */
++ sw t3, LTQ_CGU_SYS(t0)
++
++ /* Perform software reset to activate new clock config */
++ li t2, LTQ_RCU_RST_REQ_VALUE
++ sw t2, LTQ_RCU_RST_REQ(t1)
++
++wait_reset:
++ b wait_reset
++
++finished:
++ jr ra
++
++ END(ltq_cgu_init)
+--- /dev/null
++++ b/arch/mips/cpu/mips32/danube/chipid.c
+@@ -0,0 +1,60 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <common.h>
++#include <asm/lantiq/io.h>
++#include <asm/lantiq/chipid.h>
++#include <asm/arch/soc.h>
++
++#define LTQ_CHIPID_VERSION_SHIFT 28
++#define LTQ_CHIPID_VERSION_MASK (0xF << LTQ_CHIPID_VERSION_SHIFT)
++#define LTQ_CHIPID_PNUM_SHIFT 12
++#define LTQ_CHIPID_PNUM_MASK (0xFFFF << LTQ_CHIPID_PNUM_SHIFT)
++
++struct ltq_chipid_regs {
++ u32 manid; /* Manufacturer identification */
++ u32 chipid; /* Chip identification */
++};
++
++static struct ltq_chipid_regs *ltq_chipid_regs =
++ (struct ltq_chipid_regs *) CKSEG1ADDR(LTQ_CHIPID_BASE);
++
++unsigned int ltq_chip_version_get(void)
++{
++ u32 chipid;
++
++ chipid = ltq_readl(&ltq_chipid_regs->chipid);
++
++ return (chipid & LTQ_CHIPID_VERSION_MASK) >> LTQ_CHIPID_VERSION_SHIFT;
++}
++
++unsigned int ltq_chip_partnum_get(void)
++{
++ u32 chipid;
++
++ chipid = ltq_readl(&ltq_chipid_regs->chipid);
++
++ return (chipid & LTQ_CHIPID_PNUM_MASK) >> LTQ_CHIPID_PNUM_SHIFT;
++}
++
++const char *ltq_chip_partnum_str(void)
++{
++ enum ltq_chip_partnum partnum = ltq_chip_partnum_get();
++
++ switch (partnum) {
++ case LTQ_SOC_DANUBE:
++ return "Danube";
++ case LTQ_SOC_DANUBE_S:
++ return "Danube-S";
++ case LTQ_SOC_TWINPASS:
++ return "Twinpass";
++ default:
++ printf("Unknown partnum: %x\n", partnum);
++ }
++
++ return "";
++}
+--- /dev/null
++++ b/arch/mips/cpu/mips32/danube/config.mk
+@@ -0,0 +1,27 @@
++#
++# This file is released under the terms of GPL v2 and any later version.
++# See the file COPYING in the root directory of the source tree for details.
++#
++# Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++#
++
++PF_CPPFLAGS_DANUBE := $(call cc-option,-mtune=24kec,)
++PLATFORM_CPPFLAGS += $(PF_CPPFLAGS_DANUBE)
++
++ifdef CONFIG_SPL_BUILD
++PF_ABICALLS := -mno-abicalls
++PF_PIC := -fno-pic
++USE_PRIVATE_LIBGCC := yes
++endif
++
++LIBS-y += $(CPUDIR)/lantiq-common/liblantiq-common.o
++
++ifndef CONFIG_SPL_BUILD
++ifdef CONFIG_SYS_BOOT_NORSPL
++ALL-y += $(obj)u-boot.ltq.norspl
++ALL-$(CONFIG_SPL_LZO_SUPPORT) += $(obj)u-boot.ltq.lzo.norspl
++ALL-$(CONFIG_SPL_LZMA_SUPPORT) += $(obj)u-boot.ltq.lzma.norspl
++endif
++endif
++
++LDSCRIPT := $(TOPDIR)/$(CPUDIR)/$(SOC)/u-boot.lds
+--- /dev/null
++++ b/arch/mips/cpu/mips32/danube/ebu.c
+@@ -0,0 +1,51 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <common.h>
++#include <asm/arch/soc.h>
++#include <asm/lantiq/io.h>
++
++#define LTQ_EBU_CON_0_RST_VAL 0x8001F7FF
++
++#define LTQ_EBU_CON_WRDIS (1 << 31)
++
++struct ltq_ebu_regs {
++ u32 clc;
++ u32 rsvd0[3];
++ u32 con;
++ u32 rsvd1[3];
++ u32 addr_sel_0;
++ u32 addr_sel_1;
++ u32 rsvd2[14];
++ u32 con_0;
++ u32 con_1;
++};
++
++static struct ltq_ebu_regs *ltq_ebu_regs =
++ (struct ltq_ebu_regs *) CKSEG1ADDR(LTQ_EBU_BASE);
++
++void ltq_ebu_init(void)
++{
++ /*
++ * Map EBU region 0 to range 0x10000000-0x13ffffff and enable
++ * region control. This supports up to 32 MiB NOR flash in
++ * bank 0.
++ */
++ ltq_writel(&ltq_ebu_regs->addr_sel_0, 0x10000011);
++
++ /*
++ * Restore reset value to fix modifications by internal BootROM.
++ * Also disable write protection.
++ */
++ ltq_writel(&ltq_ebu_regs->con_0,
++ LTQ_EBU_CON_0_RST_VAL & ~LTQ_EBU_CON_WRDIS);
++}
++
++void *flash_swap_addr(unsigned long addr)
++{
++ return (void *)(addr ^ 2);
++}
+--- /dev/null
++++ b/arch/mips/cpu/mips32/danube/mem.c
+@@ -0,0 +1,31 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <common.h>
++#include <asm/arch/soc.h>
++#include <asm/lantiq/io.h>
++
++static void *ltq_mc_ddr_base = (void *) CKSEG1ADDR(LTQ_MC_DDR_BASE);
++
++static inline u32 ltq_mc_dc_read(u32 index)
++{
++ return ltq_readl(ltq_mc_ddr_base + LTQ_MC_DDR_DC_OFFSET(index));
++}
++
++phys_size_t initdram(int board_type)
++{
++ u32 col, row, dc04, dc19, dc20;
++
++ dc04 = ltq_mc_dc_read(4);
++ dc19 = ltq_mc_dc_read(19);
++ dc20 = ltq_mc_dc_read(20);
++
++ row = (dc04 & 0xF) - ((dc19 & 0x700) >> 8);
++ col = ((dc04 & 0xF00) >> 8) - (dc20 & 0x7);
++
++ return (1 << (row + col)) * 4 * 2;
++}
+--- /dev/null
++++ b/arch/mips/cpu/mips32/danube/mem_init.S
+@@ -0,0 +1,115 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2007-2010 Lantiq Deutschland GmbH
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <config.h>
++#include <asm/asm.h>
++#include <asm/regdef.h>
++#include <asm/addrspace.h>
++#include <asm/arch/soc.h>
++
++/* Must be configured in BOARDDIR */
++#include <ddr_settings.h>
++
++#define LTQ_MC_GEN_ERRCAUSE 0x0010
++#define LTQ_MC_GEN_ERRADDR 0x0020
++#define LTQ_MC_GEN_CON 0x0060
++#define LTQ_MC_GEN_STAT 0x0070
++#define LTQ_MC_GEN_CON_SRAM_DDR_ENABLE 0x5
++#define LTQ_MC_GEN_STAT_DLCK_PWRON 0xC
++
++#define LTQ_MC_DDR_DC03_MC_START 0x100
++
++ /* Store given value in MC DDR CCRx register */
++ .macro dc_sw num, val
++ li t2, \val
++ sw t2, LTQ_MC_DDR_DC_OFFSET(\num)(t1)
++ .endm
++
++LEAF(ltq_mem_init)
++ /* Load MC General and MC DDR module base */
++ li t0, (LTQ_MC_GEN_BASE | KSEG1)
++ li t1, (LTQ_MC_DDR_BASE | KSEG1)
++
++ /* Clear access error log registers */
++ sw zero, LTQ_MC_GEN_ERRCAUSE(t0)
++ sw zero, LTQ_MC_GEN_ERRADDR(t0)
++
++ /* Enable DDR and SRAM module in memory controller */
++ li t2, LTQ_MC_GEN_CON_SRAM_DDR_ENABLE
++ sw t2, LTQ_MC_GEN_CON(t0)
++
++ /* Clear start bit of DDR memory controller */
++ sw zero, LTQ_MC_DDR_DC_OFFSET(3)(t1)
++
++ /* Init memory controller registers with values ddr_settings.h */
++ dc_sw 0, MC_DC00_VALUE
++ dc_sw 1, MC_DC01_VALUE
++ dc_sw 2, MC_DC02_VALUE
++ dc_sw 4, MC_DC04_VALUE
++ dc_sw 5, MC_DC05_VALUE
++ dc_sw 6, MC_DC06_VALUE
++ dc_sw 7, MC_DC07_VALUE
++ dc_sw 8, MC_DC08_VALUE
++ dc_sw 9, MC_DC09_VALUE
++
++ dc_sw 10, MC_DC10_VALUE
++ dc_sw 11, MC_DC11_VALUE
++ dc_sw 12, MC_DC12_VALUE
++ dc_sw 13, MC_DC13_VALUE
++ dc_sw 14, MC_DC14_VALUE
++ dc_sw 15, MC_DC15_VALUE
++ dc_sw 16, MC_DC16_VALUE
++ dc_sw 17, MC_DC17_VALUE
++ dc_sw 18, MC_DC18_VALUE
++ dc_sw 19, MC_DC19_VALUE
++
++ dc_sw 20, MC_DC20_VALUE
++ dc_sw 21, MC_DC21_VALUE
++ dc_sw 22, MC_DC22_VALUE
++ dc_sw 23, MC_DC23_VALUE
++ dc_sw 24, MC_DC24_VALUE
++ dc_sw 25, MC_DC25_VALUE
++ dc_sw 26, MC_DC26_VALUE
++ dc_sw 27, MC_DC27_VALUE
++ dc_sw 28, MC_DC28_VALUE
++ dc_sw 29, MC_DC29_VALUE
++
++ dc_sw 30, MC_DC30_VALUE
++ dc_sw 31, MC_DC31_VALUE
++ dc_sw 32, MC_DC32_VALUE
++ dc_sw 33, MC_DC33_VALUE
++ dc_sw 34, MC_DC34_VALUE
++ dc_sw 35, MC_DC35_VALUE
++ dc_sw 36, MC_DC36_VALUE
++ dc_sw 37, MC_DC37_VALUE
++ dc_sw 38, MC_DC38_VALUE
++ dc_sw 39, MC_DC39_VALUE
++
++ dc_sw 40, MC_DC40_VALUE
++ dc_sw 41, MC_DC41_VALUE
++ dc_sw 42, MC_DC42_VALUE
++ dc_sw 43, MC_DC43_VALUE
++ dc_sw 44, MC_DC44_VALUE
++ dc_sw 45, MC_DC45_VALUE
++ dc_sw 46, MC_DC46_VALUE
++
++ /* Set start bit of DDR memory controller */
++ li t2, LTQ_MC_DDR_DC03_MC_START
++ sw t2, LTQ_MC_DDR_DC_OFFSET(3)(t1)
++
++ /* Wait until DLL has locked and core is ready for data transfers */
++wait_ready:
++ lw t2, LTQ_MC_GEN_STAT(t0)
++ li t3, LTQ_MC_GEN_STAT_DLCK_PWRON
++ and t2, t3
++ bne t2, t3, wait_ready
++
++finished:
++ jr ra
++
++ END(ltq_mem_init)
+--- /dev/null
++++ b/arch/mips/cpu/mips32/danube/pmu.c
+@@ -0,0 +1,118 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <common.h>
++#include <asm/lantiq/io.h>
++#include <asm/lantiq/pm.h>
++#include <asm/arch/soc.h>
++
++#define LTQ_PMU_PWDCR_RESERVED 0xFD0C001C
++
++#define LTQ_PMU_PWDCR_TDM (1 << 25)
++#define LTQ_PMU_PWDCR_PPE_ENET0 (1 << 23)
++#define LTQ_PMU_PWDCR_PPE_ENET1 (1 << 22)
++#define LTQ_PMU_PWDCR_PPE_TC (1 << 21)
++#define LTQ_PMU_PWDCR_DEU (1 << 20)
++#define LTQ_PMU_PWDCR_UART1 (1 << 17)
++#define LTQ_PMU_PWDCR_SDIO (1 << 16)
++#define LTQ_PMU_PWDCR_AHB (1 << 15)
++#define LTQ_PMU_PWDCR_FPI0 (1 << 14)
++#define LTQ_PMU_PWDCR_PPE (1 << 13)
++#define LTQ_PMU_PWDCR_GPTC (1 << 12)
++#define LTQ_PMU_PWDCR_LEDC (1 << 11)
++#define LTQ_PMU_PWDCR_EBU (1 << 10)
++#define LTQ_PMU_PWDCR_DSL (1 << 9)
++#define LTQ_PMU_PWDCR_SPI (1 << 8)
++#define LTQ_PMU_PWDCR_UART0 (1 << 7)
++#define LTQ_PMU_PWDCR_USB (1 << 6)
++#define LTQ_PMU_PWDCR_DMA (1 << 5)
++#define LTQ_PMU_PWDCR_FPI1 (1 << 1)
++#define LTQ_PMU_PWDCR_USB_PHY (1 << 0)
++
++struct ltq_pmu_regs {
++ u32 rsvd0[7];
++ u32 pwdcr;
++ u32 sr;
++ u32 pwdcr1;
++ u32 sr1;
++};
++
++static struct ltq_pmu_regs *ltq_pmu_regs =
++ (struct ltq_pmu_regs *) CKSEG1ADDR(LTQ_PMU_BASE);
++
++u32 ltq_pm_map(enum ltq_pm_modules module)
++{
++ u32 val;
++
++ switch (module) {
++ case LTQ_PM_CORE:
++ val = LTQ_PMU_PWDCR_UART1 | LTQ_PMU_PWDCR_FPI0 |
++ LTQ_PMU_PWDCR_LEDC | LTQ_PMU_PWDCR_EBU;
++ break;
++ case LTQ_PM_DMA:
++ val = LTQ_PMU_PWDCR_DMA;
++ break;
++ case LTQ_PM_ETH:
++ val = LTQ_PMU_PWDCR_PPE_ENET0 | LTQ_PMU_PWDCR_PPE_TC |
++ LTQ_PMU_PWDCR_PPE;
++ break;
++ case LTQ_PM_SPI:
++ val = LTQ_PMU_PWDCR_SPI;
++ break;
++ default:
++ val = 0;
++ break;
++ }
++
++ return val;
++}
++
++int ltq_pm_enable(enum ltq_pm_modules module)
++{
++ const unsigned long timeout = 1000;
++ unsigned long timebase;
++ u32 sr, val;
++
++ val = ltq_pm_map(module);
++ if (unlikely(!val))
++ return 1;
++
++ ltq_clrbits(&ltq_pmu_regs->pwdcr, val);
++
++ timebase = get_timer(0);
++
++ do {
++ sr = ltq_readl(&ltq_pmu_regs->sr);
++ if (~sr & val)
++ return 0;
++ } while (get_timer(timebase) < timeout);
++
++ return 1;
++}
++
++int ltq_pm_disable(enum ltq_pm_modules module)
++{
++ u32 val;
++
++ val = ltq_pm_map(module);
++ if (unlikely(!val))
++ return 1;
++
++ ltq_setbits(&ltq_pmu_regs->pwdcr, val);
++
++ return 0;
++}
++
++void ltq_pmu_init(void)
++{
++ u32 set, clr;
++
++ clr = ltq_pm_map(LTQ_PM_CORE);
++ set = ~(LTQ_PMU_PWDCR_RESERVED | clr);
++
++ ltq_clrsetbits(&ltq_pmu_regs->pwdcr, clr, set);
++}
+--- /dev/null
++++ b/arch/mips/cpu/mips32/danube/rcu.c
+@@ -0,0 +1,126 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <common.h>
++#include <asm/lantiq/io.h>
++#include <asm/lantiq/reset.h>
++#include <asm/lantiq/cpu.h>
++#include <asm/arch/soc.h>
++
++#define LTQ_RCU_RD_SRST (1 << 30) /* Global SW Reset */
++#define LTQ_RCU_RD_MC (1 << 14) /* Memory Controller */
++#define LTQ_RCU_RD_PCI (1 << 13) /* PCI core */
++#define LTQ_RCU_RD_DFE_AFE (1 << 12) /* Voice DFE/AFE */
++#define LTQ_RCU_RD_DSL_AFE (1 << 11) /* DSL AFE */
++#define LTQ_RCU_RD_SDIO (1 << 10) /* SDIO core */
++#define LTQ_RCU_RD_DMA (1 << 9) /* DMA core */
++#define LTQ_RCU_RD_PPE (1 << 8) /* PPE core */
++#define LTQ_RCU_RD_ARC_DFE (1 << 7) /* ARC/DFE core */
++#define LTQ_RCU_RD_AHB (1 << 6) /* AHB bus */
++#define LTQ_RCU_RD_ENET_MAC1 (1 << 5) /* Ethernet MAC1 */
++#define LTQ_RCU_RD_USB (1 << 4) /* USB and Phy core */
++#define LTQ_RCU_RD_CPU1 (1 << 3) /* CPU1 subsystem */
++#define LTQ_RCU_RD_FPI (1 << 2) /* FPI bus */
++#define LTQ_RCU_RD_CPU0 (1 << 1) /* CPU0 subsystem */
++#define LTQ_RCU_RD_HRST (1 << 0) /* HW reset via HRST pin */
++
++#define LTQ_RCU_STAT_BOOT_SHIFT 18
++#define LTQ_RCU_STAT_BOOT_MASK (0x7 << LTQ_RCU_STAT_BOOT_SHIFT)
++
++struct ltq_rcu_regs {
++ u32 rsvd0[4];
++ u32 req; /* Reset request */
++ u32 stat; /* Reset status */
++ u32 usb_cfg; /* USB configure */
++ u32 rsvd1[2];
++ u32 pci_rdy; /* PCI boot ready */
++};
++
++static struct ltq_rcu_regs *ltq_rcu_regs =
++ (struct ltq_rcu_regs *) CKSEG1ADDR(LTQ_RCU_BASE);
++
++u32 ltq_reset_map(enum ltq_reset_modules module)
++{
++ u32 val;
++
++ switch (module) {
++ case LTQ_RESET_CORE:
++ case LTQ_RESET_SOFT:
++ val = LTQ_RCU_RD_SRST | LTQ_RCU_RD_CPU1;
++ break;
++ case LTQ_RESET_DMA:
++ val = LTQ_RCU_RD_DMA;
++ break;
++ case LTQ_RESET_ETH:
++ val = LTQ_RCU_RD_PPE;
++ break;
++ case LTQ_RESET_HARD:
++ val = LTQ_RCU_RD_HRST;
++ break;
++ default:
++ val = 0;
++ break;
++ }
++
++ return val;
++}
++
++int ltq_reset_activate(enum ltq_reset_modules module)
++{
++ u32 val;
++
++ val = ltq_reset_map(module);
++ if (unlikely(!val))
++ return 1;
++
++ ltq_setbits(&ltq_rcu_regs->req, val);
++
++ return 0;
++}
++
++int ltq_reset_deactivate(enum ltq_reset_modules module)
++{
++ u32 val;
++
++ val = ltq_reset_map(module);
++ if (unlikely(!val))
++ return 1;
++
++ ltq_clrbits(&ltq_rcu_regs->req, val);
++
++ return 0;
++}
++
++enum ltq_boot_select ltq_boot_select(void)
++{
++ u32 stat;
++ unsigned int bootstrap;
++
++ stat = ltq_readl(&ltq_rcu_regs->stat);
++ bootstrap = (stat & LTQ_RCU_STAT_BOOT_MASK) >> LTQ_RCU_STAT_BOOT_SHIFT;
++
++ switch (bootstrap) {
++ case 0:
++ return BOOT_NOR_NO_BOOTROM;
++ case 1:
++ return BOOT_NOR;
++ case 2:
++ return BOOT_MII0;
++ case 3:
++ return BOOT_PCI;
++ case 4:
++ return BOOT_UART;
++ case 5:
++ return BOOT_SPI;
++ case 6:
++ return BOOT_NAND;
++ case 7:
++ return BOOT_RMII0;
++ default:
++ return BOOT_UNKNOWN;
++ }
++}
+--- /dev/null
++++ b/arch/mips/cpu/mips32/danube/u-boot.lds
+@@ -0,0 +1,69 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2003 Wolfgang Denk, DENX Software Engineering, wd@denx.de
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradlittlemips")
++OUTPUT_ARCH(mips)
++ENTRY(_start)
++SECTIONS
++{
++ . = 0x00000000;
++
++ . = ALIGN(4);
++ .text : {
++ *(.text*)
++ }
++
++ . = ALIGN(4);
++ .rodata : {
++ *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*)))
++ }
++
++ . = ALIGN(4);
++ .data : {
++ *(.data*)
++ }
++
++ . = ALIGN(4);
++ .sdata : {
++ *(.sdata*)
++ }
++
++ . = .;
++ _gp = ALIGN(16) + 0x7ff0;
++
++ .got : {
++ __got_start = .;
++ *(.got)
++ __got_end = .;
++ }
++
++ num_got_entries = (__got_end - __got_start) >> 2;
++
++#ifndef CONFIG_SPL_BUILD
++ . = ALIGN(4);
++ .u_boot_list : {
++ #include <u-boot.lst>
++ }
++#endif
++
++ . = ALIGN(4);
++ __image_copy_end = .;
++ uboot_end_data = .;
++
++ .bss (NOLOAD) : {
++ __bss_start = .;
++ *(.bss*)
++ *(.sbss*)
++ . = ALIGN(4);
++ __bss_end = .;
++ }
++
++ . = ALIGN(4);
++ __end = .;
++ uboot_end = .;
++}
+--- /dev/null
++++ b/arch/mips/cpu/mips32/lantiq-common/Makefile
+@@ -0,0 +1,36 @@
++#
++# This file is released under the terms of GPL v2 and any later version.
++# See the file COPYING in the root directory of the source tree for details.
++#
++# Copyright (C) 2000-2011 Wolfgang Denk, DENX Software Engineering, wd@denx.de
++# Copyright (C) 2012 Daniel Schwierzeck, daniel.schwierzeck@gmail.com
++#
++
++include $(TOPDIR)/config.mk
++
++LIB = $(obj)liblantiq-common.o
++
++START = start.o
++COBJS-y = cpu.o pmu.o
++COBJS-$(CONFIG_SPL_BUILD) += spl.o
++SOBJS-y = lowlevel_init.o
++
++COBJS := $(COBJS-y)
++SOBJS := $(SOBJS-y)
++SRCS := $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
++OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS))
++START := $(addprefix $(obj),$(START))
++
++all: $(LIB)
++
++$(LIB): $(obj).depend $(OBJS)
++ $(call cmd_link_o_target, $(OBJS))
++
++#########################################################################
++
++# defines $(obj).depend target
++include $(SRCTREE)/rules.mk
++
++sinclude $(obj).depend
++
++#########################################################################
+--- /dev/null
++++ b/arch/mips/cpu/mips32/lantiq-common/cpu.c
+@@ -0,0 +1,60 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2012 Daniel Schwierzeck, daniel.schwierzeck@gmail.com
++ */
++
++#include <common.h>
++#include <asm/lantiq/chipid.h>
++#include <asm/lantiq/clk.h>
++#include <asm/lantiq/reset.h>
++#include <asm/lantiq/cpu.h>
++
++static const char ltq_bootsel_strings[][16] = {
++ "NOR",
++ "NOR w/o BootROM",
++ "UART",
++ "UART w/o EEPROM",
++ "SPI",
++ "NAND",
++ "PCI",
++ "MII0",
++ "RMII0",
++ "RGMII1",
++ "unknown",
++};
++
++const char *ltq_boot_select_str(void)
++{ enum ltq_boot_select bootsel = ltq_boot_select();
++
++ if (bootsel > BOOT_UNKNOWN)
++ bootsel = BOOT_UNKNOWN;
++
++ return ltq_bootsel_strings[bootsel];
++}
++
++void ltq_chip_print_info(void)
++{
++ char buf[32];
++
++ printf("SoC: Lantiq %s v1.%u\n", ltq_chip_partnum_str(),
++ ltq_chip_version_get());
++ printf("CPU: %s MHz\n", strmhz(buf, ltq_get_cpu_clock()));
++ printf("IO: %s MHz\n", strmhz(buf, ltq_get_io_region_clock()));
++ printf("BUS: %s MHz\n", strmhz(buf, ltq_get_bus_clock()));
++ printf("BOOT: %s\n", ltq_boot_select_str());
++}
++
++int arch_cpu_init(void)
++{
++ ltq_pmu_init();
++ ltq_ebu_init();
++
++ return 0;
++}
++
++void _machine_restart(void)
++{
++ ltq_reset_activate(LTQ_RESET_CORE);
++}
+--- /dev/null
++++ b/arch/mips/cpu/mips32/lantiq-common/lowlevel_init.S
+@@ -0,0 +1,21 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <asm/asm.h>
++#include <asm/regdef.h>
++
++NESTED(lowlevel_init, 0, ra)
++ move t8, ra
++
++ la t7, ltq_cgu_init
++ jalr t7
++
++ la t7, ltq_mem_init
++ jalr t7
++
++ jr t8
++ END(lowlevel_init)
+--- /dev/null
++++ b/arch/mips/cpu/mips32/lantiq-common/pmu.c
+@@ -0,0 +1,10 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011-2012 Daniel Schwierzeck, daniel.schwierzeck@gmail.com
++ */
++
++#include <common.h>
++#include <asm/lantiq/pm.h>
++
+--- /dev/null
++++ b/arch/mips/cpu/mips32/lantiq-common/spl.c
+@@ -0,0 +1,385 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <common.h>
++#include <image.h>
++#include <version.h>
++#include <spi_flash.h>
++#include <linux/compiler.h>
++#include <lzma/LzmaDec.h>
++#include <linux/lzo.h>
++#include <asm/mipsregs.h>
++
++#if defined(CONFIG_LTQ_SPL_CONSOLE)
++#define spl_has_console 1
++
++#if defined(CONFIG_LTQ_SPL_DEBUG)
++#define spl_has_debug 1
++#else
++#define spl_has_debug 0
++#endif
++
++#else
++#define spl_has_console 0
++#endif
++
++#define spl_debug(fmt, args...) \
++ do { \
++ if (spl_has_debug) \
++ printf(fmt, ##args); \
++ } while (0)
++
++#define spl_puts(msg) \
++ do { \
++ if (spl_has_console) \
++ puts(msg); \
++ } while (0)
++
++#if defined(CONFIG_LTQ_SUPPORT_SPL_SPI_FLASH) && defined(CONFIG_SYS_BOOT_SFSPL)
++#define spl_boot_spi_flash 1
++#else
++#define spl_boot_spi_flash 0
++#ifndef CONFIG_SPL_SPI_BUS
++#define CONFIG_SPL_SPI_BUS 0
++#endif
++#ifndef CONFIG_SPL_SPI_CS
++#define CONFIG_SPL_SPI_CS 0
++#endif
++#ifndef CONFIG_SPL_SPI_MAX_HZ
++#define CONFIG_SPL_SPI_MAX_HZ 0
++#endif
++#ifndef CONFIG_SPL_SPI_MODE
++#define CONFIG_SPL_SPI_MODE 0
++#endif
++#endif
++
++#if defined(CONFIG_LTQ_SUPPORT_SPL_NOR_FLASH) && defined(CONFIG_SYS_BOOT_NORSPL)
++#define spl_boot_nor_flash 1
++#else
++#define spl_boot_nor_flash 0
++#endif
++
++#define spl_sync() __asm__ __volatile__("sync");
++
++struct spl_image {
++ ulong data_addr;
++ ulong entry_addr;
++ size_t data_size;
++ size_t entry_size;
++ u8 comp;
++};
++
++extern ulong __image_copy_end;
++
++DECLARE_GLOBAL_DATA_PTR;
++
++/* Emulated malloc area needed for LZMA allocator in BSS */
++static u8 *spl_mem_ptr __maybe_unused;
++static size_t spl_mem_size __maybe_unused;
++
++static int spl_is_comp_lzma(const struct spl_image *spl)
++{
++#if defined(CONFIG_LTQ_SPL_COMP_LZMA)
++ return spl->comp == IH_COMP_LZMA;
++#else
++ return 0;
++#endif
++}
++
++static int spl_is_comp_lzo(const struct spl_image *spl)
++{
++#if defined(CONFIG_LTQ_SPL_COMP_LZO)
++ return spl->comp == IH_COMP_LZO;
++#else
++ return 0;
++#endif
++}
++
++static int spl_is_compressed(const struct spl_image *spl)
++{
++ if (spl_is_comp_lzma(spl))
++ return 1;
++
++ if (spl_is_comp_lzo(spl))
++ return 1;
++
++ return 0;
++}
++
++static void spl_console_init(void)
++{
++ if (!spl_has_console)
++ return;
++
++ gd->flags |= GD_FLG_RELOC;
++ gd->baudrate = CONFIG_BAUDRATE;
++
++ serial_init();
++
++ gd->have_console = 1;
++
++ spl_puts("\nU-Boot SPL " PLAIN_VERSION " (" U_BOOT_DATE " - " \
++ U_BOOT_TIME ")\n");
++}
++
++static int spl_parse_image(const image_header_t *hdr, struct spl_image *spl)
++{
++ u32 magic;
++
++ spl_puts("SPL: checking U-Boot image\n");
++
++ magic = image_get_magic(hdr);
++ if (magic != IH_MAGIC)
++ return -1;
++
++ spl->data_addr += image_get_header_size();
++ spl->entry_addr = image_get_load(hdr);
++ spl->data_size = image_get_data_size(hdr);
++ spl->comp = image_get_comp(hdr);
++
++ spl_debug("SPL: data %08lx, size %zu, entry %08lx, comp %u\n",
++ spl->data_addr, spl->data_size, spl->entry_addr, spl->comp);
++
++ return 0;
++}
++
++static void *spl_lzma_alloc(void *p, size_t size)
++{
++ u8 *ret;
++
++ if (size > spl_mem_size)
++ return NULL;
++
++ ret = spl_mem_ptr;
++ spl_mem_ptr += size;
++ spl_mem_size -= size;
++
++ return ret;
++}
++
++static void spl_lzma_free(void *p, void *addr)
++{
++}
++
++static int spl_copy_image(struct spl_image *spl)
++{
++ spl_puts("SPL: copying U-Boot to RAM\n");
++
++ memcpy((void *) spl->entry_addr, (const void *) spl->data_addr,
++ spl->data_size);
++
++ spl->entry_size = spl->data_size;
++
++ return 0;
++}
++
++static int spl_uncompress_lzma(struct spl_image *spl, unsigned long loadaddr)
++{
++ SRes res;
++ const Byte *prop = (const Byte *) loadaddr;
++ const Byte *src = (const Byte *) loadaddr + LZMA_PROPS_SIZE +
++ sizeof(uint64_t);
++ Byte *dest = (Byte *) spl->entry_addr;
++ SizeT dest_len = 0xFFFFFFFF;
++ SizeT src_len = spl->data_size - LZMA_PROPS_SIZE;
++ ELzmaStatus status = 0;
++ ISzAlloc alloc;
++
++ spl_puts("SPL: decompressing U-Boot with LZMA\n");
++
++ alloc.Alloc = spl_lzma_alloc;
++ alloc.Free = spl_lzma_free;
++ spl_mem_ptr = (u8 *) CONFIG_SPL_MALLOC_BASE;
++ spl_mem_size = CONFIG_SPL_MALLOC_MAX_SIZE;
++
++ res = LzmaDecode(dest, &dest_len, src, &src_len, prop, LZMA_PROPS_SIZE,
++ LZMA_FINISH_ANY, &status, &alloc);
++ if (res != SZ_OK)
++ return 1;
++
++ spl->entry_size = dest_len;
++
++ return 0;
++}
++
++static int spl_uncompress_lzo(struct spl_image *spl, unsigned long loadaddr)
++{
++ size_t len;
++ int ret;
++
++ spl_puts("SPL: decompressing U-Boot with LZO\n");
++
++ ret = lzop_decompress(
++ (const unsigned char*) loadaddr, spl->data_size,
++ (unsigned char *) spl->entry_addr, &len);
++
++ spl->entry_size = len;
++
++ return ret;
++}
++
++static int spl_uncompress(struct spl_image *spl, unsigned long loadaddr)
++{
++ int ret;
++
++ if (spl_is_comp_lzma(spl))
++ ret = spl_uncompress_lzma(spl, loadaddr);
++ else if (spl_is_comp_lzo(spl))
++ ret = spl_uncompress_lzo(spl, loadaddr);
++ else
++ ret = 1;
++
++ return ret;
++}
++
++static int spl_load_spi_flash(struct spl_image *spl)
++{
++ struct spi_flash sf;
++ image_header_t hdr;
++ int ret;
++ unsigned long loadaddr;
++
++ /*
++ * Image format:
++ *
++ * - 12 byte non-volatile bootstrap header
++ * - SPL binary
++ * - 12 byte non-volatile bootstrap header
++ * - 64 byte U-Boot mkimage header
++ * - U-Boot binary
++ */
++ spl->data_addr = (ulong) &__image_copy_end - CONFIG_SPL_TEXT_BASE + 24;
++
++ spl_puts("SPL: probing SPI flash\n");
++
++ spi_init();
++ ret = spi_flash_probe_spl(&sf, CONFIG_SPL_SPI_BUS, CONFIG_SPL_SPI_CS,
++ CONFIG_SPL_SPI_MAX_HZ, CONFIG_SPL_SPI_MODE);
++ if (ret)
++ return ret;
++
++ spl_debug("SPL: reading image header at offset %lx\n", spl->data_addr);
++
++ ret = spi_flash_read(&sf, spl->data_addr, sizeof(hdr), &hdr);
++ if (ret)
++ return ret;
++
++ spl_debug("SPL: checking image header at offset %lx\n", spl->data_addr);
++
++ ret = spl_parse_image(&hdr, spl);
++ if (ret)
++ return ret;
++
++ if (spl_is_compressed(spl))
++ loadaddr = CONFIG_LOADADDR;
++ else
++ loadaddr = spl->entry_addr;
++
++ spl_puts("SPL: loading U-Boot to RAM\n");
++
++ ret = spi_flash_read(&sf, spl->data_addr, spl->data_size,
++ (void *) loadaddr);
++
++ if (spl_is_compressed(spl))
++ ret = spl_uncompress(spl, loadaddr);
++
++ return ret;
++}
++
++static int spl_load_nor_flash(struct spl_image *spl)
++{
++ const image_header_t *hdr;
++ int ret;
++
++ /*
++ * Image format:
++ *
++ * - SPL binary
++ * - 64 byte U-Boot mkimage header
++ * - U-Boot binary
++ */
++ spl->data_addr = (ulong) &__image_copy_end;
++ hdr = (const image_header_t *) &__image_copy_end;
++
++ spl_debug("SPL: checking image header at address %p\n", hdr);
++
++ ret = spl_parse_image(hdr, spl);
++ if (ret)
++ return ret;
++
++ if (spl_is_compressed(spl))
++ ret = spl_uncompress(spl, spl->data_addr);
++ else
++ ret = spl_copy_image(spl);
++
++ return ret;
++}
++
++static int spl_load(struct spl_image *spl)
++{
++ int ret;
++
++ if (spl_boot_spi_flash)
++ ret = spl_load_spi_flash(spl);
++ else if (spl_boot_nor_flash)
++ ret = spl_load_nor_flash(spl);
++ else
++ ret = 1;
++
++ return ret;
++}
++
++void __noreturn spl_lantiq_init(void)
++{
++ void (*uboot)(void) __noreturn;
++ struct spl_image spl;
++ gd_t gd_data;
++ int ret;
++
++ gd = &gd_data;
++ barrier();
++ memset((void *)gd, 0, sizeof(gd_t));
++
++ spl_console_init();
++
++ spl_debug("SPL: initializing\n");
++
++#if 0
++ spl_debug("CP0_CONFIG: %08x\n", read_c0_config());
++ spl_debug("CP0_CONFIG1: %08x\n", read_c0_config1());
++ spl_debug("CP0_CONFIG2: %08x\n", read_c0_config2());
++ spl_debug("CP0_CONFIG3: %08x\n", read_c0_config3());
++ spl_debug("CP0_CONFIG6: %08x\n", read_c0_config6());
++ spl_debug("CP0_CONFIG7: %08x\n", read_c0_config7());
++ spl_debug("CP0_STATUS: %08x\n", read_c0_status());
++ spl_debug("CP0_PRID: %08x\n", read_c0_prid());
++#endif
++
++ board_early_init_f();
++ timer_init();
++
++ memset(&spl, 0, sizeof(spl));
++
++ ret = spl_load(&spl);
++ if (ret)
++ goto hang;
++
++ spl_debug("SPL: U-Boot entry %08lx\n", spl.entry_addr);
++ spl_puts("SPL: jumping to U-Boot\n");
++
++ flush_cache(spl.entry_addr, spl.entry_size);
++ spl_sync();
++
++ uboot = (void *) spl.entry_addr;
++ uboot();
++
++hang:
++ spl_puts("SPL: cannot start U-Boot\n");
++
++ for (;;)
++ ;
++}
+--- /dev/null
++++ b/arch/mips/cpu/mips32/lantiq-common/start.S
+@@ -0,0 +1,144 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2003 Wolfgang Denk, wd@denx.de
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <config.h>
++#include <asm/regdef.h>
++#include <asm/mipsregs.h>
++
++#define S_PRIdCoID 16 /* Company ID (R) */
++#define M_PRIdCoID (0xff << S_PRIdCoID)
++#define S_PRIdImp 8 /* Implementation ID (R) */
++#define M_PRIdImp (0xff << S_PRIdImp)
++
++#define K_CacheAttrCWTnWA 0 /* Cacheable, write-thru, no write allocate */
++#define K_CacheAttrCWTWA 1 /* Cacheable, write-thru, write allocate */
++#define K_CacheAttrU 2 /* Uncached */
++#define K_CacheAttrC 3 /* Cacheable */
++#define K_CacheAttrCN 3 /* Cacheable, non-coherent */
++#define K_CacheAttrCCE 4 /* Cacheable, coherent, exclusive */
++#define K_CacheAttrCCS 5 /* Cacheable, coherent, shared */
++#define K_CacheAttrCCU 6 /* Cacheable, coherent, update */
++#define K_CacheAttrUA 7 /* Uncached accelerated */
++
++#define S_ConfigK23 28 /* Kseg2/3 coherency algorithm (FM MMU only) (R/W) */
++#define M_ConfigK23 (0x7 << S_ConfigK23)
++#define W_ConfigK23 3
++#define S_ConfigKU 25 /* Kuseg coherency algorithm (FM MMU only) (R/W) */
++#define M_ConfigKU (0x7 << S_ConfigKU)
++#define W_ConfigKU 3
++
++#define S_ConfigMM 18 /* Merge mode (implementation specific) */
++#define M_ConfigMM (0x1 << S_ConfigMM)
++
++#define S_StatusBEV 22 /* Enable Boot Exception Vectors (R/W) */
++#define M_StatusBEV (0x1 << S_StatusBEV)
++
++#define S_StatusFR 26 /* Enable 64-bit FPRs (R/W) */
++#define M_StatusFR (0x1 << S_StatusFR)
++
++#define S_ConfigK0 0 /* Kseg0 coherency algorithm (R/W) */
++#define M_ConfigK0 (0x7 << S_ConfigK0)
++
++#define CONFIG0_MIPS32_64_MSK 0x8000ffff
++#define STATUS_MIPS32_64_MSK 0xfffcffff
++
++#define STATUS_MIPS24K 0
++#define CONFIG0_MIPS24K ((K_CacheAttrCN << S_ConfigK23) |\
++ (K_CacheAttrCN << S_ConfigKU) |\
++ (M_ConfigMM))
++
++#define STATUS_MIPS34K 0
++#define CONFIG0_MIPS34K ((K_CacheAttrCN << S_ConfigK23) |\
++ (K_CacheAttrCN << S_ConfigKU) |\
++ (M_ConfigMM))
++
++#define STATUS_MIPS32_64 (M_StatusBEV | M_StatusFR)
++#define CONFIG0_MIPS32_64 (K_CacheAttrCN << S_ConfigK0)
++
++#ifdef CONFIG_SOC_XWAY_DANUBE
++#define CONFIG0_LANTIQ (CONFIG0_MIPS24K | CONFIG0_MIPS32_64)
++#define STATUS_LANTIQ (STATUS_MIPS24K | STATUS_MIPS32_64)
++#endif
++
++#ifdef CONFIG_SOC_XWAY_VRX200
++#define CONFIG0_LANTIQ (CONFIG0_MIPS34K | CONFIG0_MIPS32_64)
++#define STATUS_LANTIQ (STATUS_MIPS34K | STATUS_MIPS32_64)
++#endif
++
++
++ .set noreorder
++
++ .globl _start
++ .text
++_start:
++ /* Entry point */
++ b main
++ nop
++
++ /* Lantiq SoC Boot config word */
++ .org 0x10
++#ifdef CONFIG_SYS_XWAY_EBU_BOOTCFG
++ .word CONFIG_SYS_XWAY_EBU_BOOTCFG
++#else
++ .word 0
++#endif
++ .word 0
++
++ .align 4
++main:
++
++ /* Init Timer */
++ mtc0 zero, CP0_COUNT
++ mtc0 zero, CP0_COMPARE
++
++ /* Setup MIPS24K/MIPS34K specifics (implementation dependent fields) */
++ mfc0 t0, CP0_CONFIG
++ li t1, CONFIG0_MIPS32_64_MSK
++ and t0, t1
++ li t1, CONFIG0_LANTIQ
++ or t0, t1
++ mtc0 t0, CP0_CONFIG
++
++ mfc0 t0, CP0_STATUS
++ li t1, STATUS_MIPS32_64_MSK
++ and t0, t1
++ li t1, STATUS_LANTIQ
++ or t0, t1
++ mtc0 t0, CP0_STATUS
++
++ /* Initialize CGU */
++ la t9, ltq_cgu_init
++ jalr t9
++ nop
++
++ /* Initialize memory controller */
++ la t9, ltq_mem_init
++ jalr t9
++ nop
++
++ /* Initialize caches... */
++ la t9, mips_cache_reset
++ jalr t9
++ nop
++
++ /* Clear BSS */
++ la t1, __bss_start
++ la t2, __bss_end
++ sub t1, 4
++1:
++ addi t1, 4
++ bltl t1, t2, 1b
++ sw zero, 0(t1)
++
++ /* Setup stack pointer and force alignment on a 16 byte boundary */
++ li t0, (CONFIG_SPL_STACK_BASE & ~0xF)
++ la sp, 0(t0)
++
++ la t9, spl_lantiq_init
++ jr t9
++ nop
+--- /dev/null
++++ b/arch/mips/cpu/mips32/lantiq-common/u-boot-spl.lds
+@@ -0,0 +1,49 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011-2012 Daniel Schwierzeck, daniel.schwierzeck@gmail.com
++ */
++
++MEMORY { .spl_mem : ORIGIN = CONFIG_SPL_TEXT_BASE, \
++ LENGTH = CONFIG_SPL_MAX_SIZE }
++MEMORY { .bss_mem : ORIGIN = CONFIG_SPL_BSS_BASE, \
++ LENGTH = CONFIG_SPL_BSS_MAX_SIZE }
++
++OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradlittlemips")
++OUTPUT_ARCH(mips)
++ENTRY(_start)
++SECTIONS
++{
++ . = ALIGN(4);
++ .text : {
++ *(.text*)
++ } > .spl_mem
++
++ . = ALIGN(4);
++ .rodata : {
++ *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*)))
++ } > .spl_mem
++
++ . = ALIGN(4);
++ .data : {
++ *(SORT_BY_ALIGNMENT(.data*))
++ *(SORT_BY_ALIGNMENT(.sdata*))
++ } > .spl_mem
++
++ . = ALIGN(4);
++ __image_copy_end = .;
++ uboot_end_data = .;
++
++ .bss : {
++ __bss_start = .;
++ *(.bss*)
++ *(.sbss*)
++ . = ALIGN(4);
++ __bss_end = .;
++ } > .bss_mem
++
++ . = ALIGN(4);
++ __end = .;
++ uboot_end = .;
++}
+--- a/arch/mips/cpu/mips32/start.S
++++ b/arch/mips/cpu/mips32/start.S
+@@ -55,166 +55,63 @@
+ #endif
+ .endm
+
+-#define RVECENT(f,n) \
+- b f; nop
+-#define XVECENT(f,bev) \
+- b f ; \
+- li k0,bev
+-
+- .set noreorder
+-
+- .globl _start
+- .text
+-_start:
+- RVECENT(reset,0) # U-boot entry point
+- RVECENT(reset,1) # software reboot
+-#ifdef CONFIG_SYS_XWAY_EBU_BOOTCFG
+ /*
+ * Almost all Lantiq XWAY SoC devices have an external bus unit (EBU) to
+ * access external NOR flashes. If the board boots from NOR flash the
+ * internal BootROM does a blind read at address 0xB0000010 to read the
+ * initial configuration for that EBU in order to access the flash
+ * device with correct parameters. This config option is board-specific.
++ * Default to 0 if this option is not set.
+ */
+- .word CONFIG_SYS_XWAY_EBU_BOOTCFG
+- .word 0x00000000
++ .macro lantiq_soc_bootcfg
++ .set push
++ .set noreorder
++ .org 0x10
++#ifdef CONFIG_SYS_XWAY_EBU_BOOTCFG
++ .word CONFIG_SYS_XWAY_EBU_BOOTCFG
+ #else
+- RVECENT(romReserved,2)
++ .word 0
+ #endif
+- RVECENT(romReserved,3)
+- RVECENT(romReserved,4)
+- RVECENT(romReserved,5)
+- RVECENT(romReserved,6)
+- RVECENT(romReserved,7)
+- RVECENT(romReserved,8)
+- RVECENT(romReserved,9)
+- RVECENT(romReserved,10)
+- RVECENT(romReserved,11)
+- RVECENT(romReserved,12)
+- RVECENT(romReserved,13)
+- RVECENT(romReserved,14)
+- RVECENT(romReserved,15)
+- RVECENT(romReserved,16)
+- RVECENT(romReserved,17)
+- RVECENT(romReserved,18)
+- RVECENT(romReserved,19)
+- RVECENT(romReserved,20)
+- RVECENT(romReserved,21)
+- RVECENT(romReserved,22)
+- RVECENT(romReserved,23)
+- RVECENT(romReserved,24)
+- RVECENT(romReserved,25)
+- RVECENT(romReserved,26)
+- RVECENT(romReserved,27)
+- RVECENT(romReserved,28)
+- RVECENT(romReserved,29)
+- RVECENT(romReserved,30)
+- RVECENT(romReserved,31)
+- RVECENT(romReserved,32)
+- RVECENT(romReserved,33)
+- RVECENT(romReserved,34)
+- RVECENT(romReserved,35)
+- RVECENT(romReserved,36)
+- RVECENT(romReserved,37)
+- RVECENT(romReserved,38)
+- RVECENT(romReserved,39)
+- RVECENT(romReserved,40)
+- RVECENT(romReserved,41)
+- RVECENT(romReserved,42)
+- RVECENT(romReserved,43)
+- RVECENT(romReserved,44)
+- RVECENT(romReserved,45)
+- RVECENT(romReserved,46)
+- RVECENT(romReserved,47)
+- RVECENT(romReserved,48)
+- RVECENT(romReserved,49)
+- RVECENT(romReserved,50)
+- RVECENT(romReserved,51)
+- RVECENT(romReserved,52)
+- RVECENT(romReserved,53)
+- RVECENT(romReserved,54)
+- RVECENT(romReserved,55)
+- RVECENT(romReserved,56)
+- RVECENT(romReserved,57)
+- RVECENT(romReserved,58)
+- RVECENT(romReserved,59)
+- RVECENT(romReserved,60)
+- RVECENT(romReserved,61)
+- RVECENT(romReserved,62)
+- RVECENT(romReserved,63)
+- XVECENT(romExcHandle,0x200) # bfc00200: R4000 tlbmiss vector
+- RVECENT(romReserved,65)
+- RVECENT(romReserved,66)
+- RVECENT(romReserved,67)
+- RVECENT(romReserved,68)
+- RVECENT(romReserved,69)
+- RVECENT(romReserved,70)
+- RVECENT(romReserved,71)
+- RVECENT(romReserved,72)
+- RVECENT(romReserved,73)
+- RVECENT(romReserved,74)
+- RVECENT(romReserved,75)
+- RVECENT(romReserved,76)
+- RVECENT(romReserved,77)
+- RVECENT(romReserved,78)
+- RVECENT(romReserved,79)
+- XVECENT(romExcHandle,0x280) # bfc00280: R4000 xtlbmiss vector
+- RVECENT(romReserved,81)
+- RVECENT(romReserved,82)
+- RVECENT(romReserved,83)
+- RVECENT(romReserved,84)
+- RVECENT(romReserved,85)
+- RVECENT(romReserved,86)
+- RVECENT(romReserved,87)
+- RVECENT(romReserved,88)
+- RVECENT(romReserved,89)
+- RVECENT(romReserved,90)
+- RVECENT(romReserved,91)
+- RVECENT(romReserved,92)
+- RVECENT(romReserved,93)
+- RVECENT(romReserved,94)
+- RVECENT(romReserved,95)
+- XVECENT(romExcHandle,0x300) # bfc00300: R4000 cache vector
+- RVECENT(romReserved,97)
+- RVECENT(romReserved,98)
+- RVECENT(romReserved,99)
+- RVECENT(romReserved,100)
+- RVECENT(romReserved,101)
+- RVECENT(romReserved,102)
+- RVECENT(romReserved,103)
+- RVECENT(romReserved,104)
+- RVECENT(romReserved,105)
+- RVECENT(romReserved,106)
+- RVECENT(romReserved,107)
+- RVECENT(romReserved,108)
+- RVECENT(romReserved,109)
+- RVECENT(romReserved,110)
+- RVECENT(romReserved,111)
+- XVECENT(romExcHandle,0x380) # bfc00380: R4000 general vector
+- RVECENT(romReserved,113)
+- RVECENT(romReserved,114)
+- RVECENT(romReserved,115)
+- RVECENT(romReserved,116)
+- RVECENT(romReserved,116)
+- RVECENT(romReserved,118)
+- RVECENT(romReserved,119)
+- RVECENT(romReserved,120)
+- RVECENT(romReserved,121)
+- RVECENT(romReserved,122)
+- RVECENT(romReserved,123)
+- RVECENT(romReserved,124)
+- RVECENT(romReserved,125)
+- RVECENT(romReserved,126)
+- RVECENT(romReserved,127)
++ .word 0
++ .set pop
++ .endm
++
++ .macro reset_vector branch
++ .set push
++ .set noreorder
++ b \branch
++ nop
++ .set pop
++ .endm
++
++ .macro exception_vector offset branch
++ .set push
++ .set noreorder
++ .org \offset
++ b \branch
++ li k0, \offset
++ .set pop
++ .endm
++
++ .set noreorder
++
++ .globl _start
++ .text
++_start:
++ reset_vector reset # U-boot entry point
++ reset_vector reset # software reboot
++
++ lantiq_soc_bootcfg # Lantiq SoC Boot config word
++
++ exception_vector 0x200, halt # TLB miss
++ exception_vector 0x280, halt # XTLB miss
++ exception_vector 0x300, halt # Cache error
++ exception_vector 0x380, halt # General
++ exception_vector 0x400, halt # Interrupt, CauseIV
++ exception_vector 0x480, ejtag_exception # EJTAG debug
+
+- /*
+- * We hope there are no more reserved vectors!
+- * 128 * 8 == 1024 == 0x400
+- * so this is address R_VEC+0x400 == 0xbfc00400
+- */
+ .align 4
+ reset:
+-
+ /* Clear watch registers */
+ mtc0 zero, CP0_WATCHLO
+ mtc0 zero, CP0_WATCHHI
+@@ -222,13 +119,15 @@ reset:
+ /* WP(Watch Pending), SW0/1 should be cleared */
+ mtc0 zero, CP0_CAUSE
+
++#if 0
+ setup_c0_status_reset
++#endif
+
+ /* Init Timer */
+ mtc0 zero, CP0_COUNT
+ mtc0 zero, CP0_COMPARE
+
+-#ifndef CONFIG_SKIP_LOWLEVEL_INIT
++#if !defined(CONFIG_SKIP_LOWLEVEL_INIT) || defined(CONFIG_SYS_DISABLE_CACHE)
+ /* CONFIG0 register */
+ li t0, CONF_CM_UNCACHED
+ mtc0 t0, CP0_CONFIG
+@@ -323,6 +222,8 @@ relocate_code:
+ jalr t9
+ nop
+
++ sync
++
+ /* Jump to where we've relocated ourselves */
+ addi t0, s2, in_ram - _start
+ jr t0
+@@ -378,8 +279,12 @@ in_ram:
+ .end relocate_code
+
+ /* Exception handlers */
+-romReserved:
+- b romReserved
++ejtag_exception:
++ /* Set DEPC to halt and exit debug mode */
++ la k1, halt
++ mtc0 k1, CP0_DEPC
++ deret
++ nop
+
+-romExcHandle:
+- b romExcHandle
++halt:
++ b halt
+--- /dev/null
++++ b/arch/mips/cpu/mips32/vrx200/Makefile
+@@ -0,0 +1,34 @@
++#
++# This file is released under the terms of GPL v2 and any later version.
++# See the file COPYING in the root directory of the source tree for details.
++#
++# Copyright (C) 2000-2011 Wolfgang Denk, DENX Software Engineering, wd@denx.de
++# Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++#
++
++include $(TOPDIR)/config.mk
++
++LIB = $(obj)lib$(SOC).o
++
++COBJS-y += cgu.o chipid.o dcdc.o ebu.o gphy.o mem.o pmu.o rcu.o
++SOBJS-y += cgu_init.o mem_init.o
++SOBJS-y += gphy_fw.o
++
++COBJS := $(COBJS-y)
++SOBJS := $(SOBJS-y)
++SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c)
++OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS))
++
++all: $(LIB)
++
++$(LIB): $(obj).depend $(OBJS)
++ $(call cmd_link_o_target, $(OBJS))
++
++#########################################################################
++
++# defines $(obj).depend target
++include $(SRCTREE)/rules.mk
++
++sinclude $(obj).depend
++
++#########################################################################
+--- /dev/null
++++ b/arch/mips/cpu/mips32/vrx200/cgu.c
+@@ -0,0 +1,209 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2010 Lantiq Deutschland GmbH
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <common.h>
++#include <asm/arch/soc.h>
++#include <asm/arch/gphy.h>
++#include <asm/lantiq/clk.h>
++#include <asm/lantiq/io.h>
++
++#define LTQ_CGU_PLL1_PLLN_SHIFT 6
++#define LTQ_CGU_PLL1_PLLN_MASK (0x3F << LTQ_CGU_PLL1_PLLN_SHIFT)
++#define LTQ_CGU_PLL1_PLLM_SHIFT 2
++#define LTQ_CGU_PLL1_PLLM_MASK (0xF << LTQ_CGU_PLL1_PLLM_SHIFT)
++#define LTQ_CGU_PLL1_PLLL (1 << 1)
++#define LTQ_CGU_PLL1_PLL_EN 1
++
++#define LTQ_CGU_SYS_OCP_SHIFT 0
++#define LTQ_CGU_SYS_OCP_MASK (0x3 << LTQ_CGU_SYS_OCP_SHIFT)
++#define LTQ_CGU_SYS_CPU_SHIFT 4
++#define LTQ_CGU_SYS_CPU_MASK (0xF << LTQ_CGU_SYS_CPU_SHIFT)
++
++#define LTQ_CGU_UPDATE 1
++
++#define LTQ_CGU_IFCLK_GPHY_SEL_SHIFT 2
++#define LTQ_CGU_IFCLK_GPHY_SEL_MASK (0x7 << LTQ_CGU_IFCLK_GPHY_SEL_SHIFT)
++
++struct ltq_cgu_regs {
++ u32 rsvd0;
++ u32 pll0_cfg; /* PLL0 config */
++ u32 pll1_cfg; /* PLL1 config */
++ u32 sys; /* System clock */
++ u32 clk_fsr; /* Clock frequency select */
++ u32 clk_gsr; /* Clock gating status */
++ u32 clk_gcr0; /* Clock gating control 0 */
++ u32 clk_gcr1; /* Clock gating control 1 */
++ u32 update; /* CGU update control */
++ u32 if_clk; /* Interface clock */
++ u32 ddr; /* DDR memory control */
++ u32 ct1_sr; /* CT status 1 */
++ u32 ct_kval; /* CT K value */
++ u32 pcm_cr; /* PCM control */
++ u32 pci_cr; /* PCI clock control */
++ u32 rsvd1;
++ u32 gphy1_cfg; /* GPHY1 config */
++ u32 gphy0_cfg; /* GPHY0 config */
++ u32 rsvd2[6];
++ u32 pll2_cfg; /* PLL2 config */
++};
++
++static struct ltq_cgu_regs *ltq_cgu_regs =
++ (struct ltq_cgu_regs *) CKSEG1ADDR(LTQ_CGU_BASE);
++
++static inline u32 ltq_cgu_sys_readl(u32 mask, u32 shift)
++{
++ return (ltq_readl(&ltq_cgu_regs->sys) & mask) >> shift;
++}
++
++unsigned long ltq_get_io_region_clock(void)
++{
++ unsigned int ocp_sel;
++ unsigned long clk, cpu_clk;
++
++ cpu_clk = ltq_get_cpu_clock();
++
++ ocp_sel = ltq_cgu_sys_readl(LTQ_CGU_SYS_OCP_MASK,
++ LTQ_CGU_SYS_OCP_SHIFT);
++
++ switch (ocp_sel) {
++ case 0:
++ /* OCP ratio 1 */
++ clk = cpu_clk;
++ break;
++ case 2:
++ /* OCP ratio 2 */
++ clk = cpu_clk / 2;
++ break;
++ case 3:
++ /* OCP ratio 2.5 */
++ clk = (cpu_clk * 2) / 5;
++ break;
++ case 4:
++ /* OCP ratio 3 */
++ clk = cpu_clk / 3;
++ break;
++ default:
++ clk = 0;
++ break;
++ }
++
++ return clk;
++}
++
++unsigned long ltq_get_cpu_clock(void)
++{
++ unsigned int cpu_sel;
++ unsigned long clk;
++
++ cpu_sel = ltq_cgu_sys_readl(LTQ_CGU_SYS_CPU_MASK,
++ LTQ_CGU_SYS_CPU_SHIFT);
++
++ switch (cpu_sel) {
++ case 0:
++ clk = CLOCK_600_MHZ;
++ break;
++ case 1:
++ clk = CLOCK_500_MHZ;
++ break;
++ case 2:
++ clk = CLOCK_393_MHZ;
++ break;
++ case 3:
++ clk = CLOCK_333_MHZ;
++ break;
++ case 5:
++ case 6:
++ clk = CLOCK_197_MHZ;
++ break;
++ case 7:
++ clk = CLOCK_166_MHZ;
++ break;
++ case 4:
++ case 8:
++ case 9:
++ clk = CLOCK_125_MHZ;
++ break;
++ default:
++ clk = 0;
++ break;
++ }
++
++ return clk;
++}
++
++unsigned long ltq_get_bus_clock(void)
++{
++ return ltq_get_io_region_clock();
++}
++
++void ltq_cgu_gphy_clk_src(enum ltq_gphy_clk clk)
++{
++ ltq_clrbits(&ltq_cgu_regs->if_clk, LTQ_CGU_IFCLK_GPHY_SEL_MASK);
++ ltq_setbits(&ltq_cgu_regs->if_clk, clk << LTQ_CGU_IFCLK_GPHY_SEL_SHIFT);
++}
++
++static inline int ltq_cgu_pll1_locked(void)
++{
++ u32 pll1_cfg = ltq_readl(&ltq_cgu_regs->pll1_cfg);
++
++ return pll1_cfg & LTQ_CGU_PLL1_PLLL;
++}
++
++static inline void ltq_cgu_pll1_restart(unsigned m, unsigned n)
++{
++ u32 pll1_cfg;
++
++ ltq_clrbits(&ltq_cgu_regs->pll1_cfg, LTQ_CGU_PLL1_PLL_EN);
++ ltq_setbits(&ltq_cgu_regs->update, LTQ_CGU_UPDATE);
++
++ pll1_cfg = ltq_readl(&ltq_cgu_regs->pll1_cfg);
++ pll1_cfg &= ~(LTQ_CGU_PLL1_PLLN_MASK | LTQ_CGU_PLL1_PLLM_MASK);
++ pll1_cfg |= n << LTQ_CGU_PLL1_PLLN_SHIFT;
++ pll1_cfg |= m << LTQ_CGU_PLL1_PLLM_SHIFT;
++ pll1_cfg |= LTQ_CGU_PLL1_PLL_EN;
++ ltq_writel(&ltq_cgu_regs->pll1_cfg, pll1_cfg);
++ ltq_setbits(&ltq_cgu_regs->update, LTQ_CGU_UPDATE);
++
++ __udelay(1000);
++}
++
++/*
++ * From chapter 9 in errata sheet:
++ *
++ * Under certain condition, the PLL1 may failed to enter into lock
++ * status by hardware default N, M setting.
++ *
++ * Since system always starts from PLL0, the system software can run
++ * and re-program the PLL1 settings.
++ */
++static void ltq_cgu_pll1_init(void)
++{
++ unsigned i;
++ const unsigned pll1_m[] = { 1, 2, 3, 4 };
++ const unsigned pll1_n[] = { 21, 32, 43, 54 };
++
++ /* Check if PLL1 has locked with hardware default settings */
++ if (ltq_cgu_pll1_locked())
++ return;
++
++ for (i = 0; i < 4; i++) {
++ ltq_cgu_pll1_restart(pll1_m[i], pll1_n[i]);
++
++ if (ltq_cgu_pll1_locked())
++ goto done;
++ }
++
++done:
++ /* Restart with hardware default values M=5, N=64 */
++ ltq_cgu_pll1_restart(5, 64);
++}
++
++void ltq_pll_init(void)
++{
++ ltq_cgu_pll1_init();
++}
+--- /dev/null
++++ b/arch/mips/cpu/mips32/vrx200/cgu_init.S
+@@ -0,0 +1,120 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2010 Lantiq Deutschland GmbH
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <config.h>
++#include <asm/asm.h>
++#include <asm/regdef.h>
++#include <asm/addrspace.h>
++#include <asm/arch/soc.h>
++
++/* RCU module register */
++#define LTQ_RCU_RST_REQ 0x0010 /* Reset request */
++#define LTQ_RCU_RST_REQ_VALUE ((1 << 14) | (1 << 1))
++
++/* CGU module register */
++#define LTQ_CGU_PLL0_CFG 0x0004 /* PLL0 config */
++#define LTQ_CGU_PLL1_CFG 0x0008 /* PLL1 config */
++#define LTQ_CGU_PLL2_CFG 0x0060 /* PLL2 config */
++#define LTQ_CGU_SYS 0x000C /* System clock */
++#define LTQ_CGU_CLK_FSR 0x0010 /* Clock frequency select */
++#define LTQ_CGU_UPDATE 0x0020 /* Clock update control */
++
++/* Valid SYS.CPU values */
++#define LTQ_CGU_SYS_CPU_SHIFT 4
++#define LTQ_CGU_SYS_CPU_600_MHZ 0x0
++#define LTQ_CGU_SYS_CPU_500_MHZ 0x1
++#define LTQ_CGU_SYS_CPU_393_MHZ 0x2
++#define LTQ_CGU_SYS_CPU_333_MHZ 0x3
++#define LTQ_CGU_SYS_CPU_197_MHZ 0x5
++#define LTQ_CGU_SYS_CPU_166_MHZ 0x7
++#define LTQ_CGU_SYS_CPU_125_MHZ 0x9
++
++/* Valid SYS.OCP values */
++#define LTQ_CGU_SYS_OCP_SHIFT 0
++#define LTQ_CGU_SYS_OCP_1 0x0
++#define LTQ_CGU_SYS_OCP_2 0x2
++#define LTQ_CGU_SYS_OCP_2_5 0x3
++#define LTQ_CGU_SYS_OCP_3 0x4
++
++/* Valid CLK_FSR.ETH values */
++#define LTQ_CGU_CLK_FSR_ETH_SHIFT 24
++#define LTQ_CGU_CLK_FSR_ETH_50_MHZ 0x0
++#define LTQ_CGU_CLK_FSR_ETH_25_MHZ 0x1
++#define LTQ_CGU_CLK_FSR_ETH_2_5_MHZ 0x2
++#define LTQ_CGU_CLK_FSR_ETH_125_MHZ 0x3
++
++/* Valid CLK_FSR.PPE values */
++#define LTQ_CGU_CLK_FSR_PPE_SHIFT 16
++#define LTQ_CGU_CLK_FSR_PPE_500_MHZ 0x0 /* Overclock frequency */
++#define LTQ_CGU_CLK_FSR_PPE_450_MHZ 0x1 /* High frequency */
++#define LTQ_CGU_CLK_FSR_PPE_400_MHZ 0x2 /* Low frequency */
++
++#if (CONFIG_SYS_CLOCK_MODE == LTQ_CLK_CPU_500_DDR_250)
++#define LTQ_CGU_SYS_CPU_CONFIG LTQ_CGU_SYS_CPU_500_MHZ
++#define LTQ_CGU_SYS_OCP_CONFIG LTQ_CGU_SYS_OCP_2
++#define LTQ_CGU_CLK_FSR_ETH_CONFIG LTQ_CGU_CLK_FSR_ETH_125_MHZ
++#define LTQ_CGU_CLK_FSR_PPE_CONFIG LTQ_CGU_CLK_FSR_PPE_450_MHZ
++#else
++#error "Invalid system clock configuration!"
++#endif
++
++/* Build register values */
++#define LTQ_CGU_SYS_VALUE ((LTQ_CGU_SYS_CPU_CONFIG << \
++ LTQ_CGU_SYS_CPU_SHIFT) | \
++ LTQ_CGU_SYS_OCP_CONFIG)
++
++#define LTQ_CGU_CLK_FSR_VALUE ((LTQ_CGU_CLK_FSR_ETH_CONFIG << \
++ LTQ_CGU_CLK_FSR_ETH_SHIFT) | \
++ (LTQ_CGU_CLK_FSR_PPE_CONFIG << \
++ LTQ_CGU_CLK_FSR_PPE_SHIFT))
++
++ .set noreorder
++
++LEAF(ltq_cgu_init)
++ /* Load current CGU register values */
++ li t0, (LTQ_CGU_BASE | KSEG1)
++ lw t1, LTQ_CGU_SYS(t0)
++ lw t2, LTQ_CGU_CLK_FSR(t0)
++
++ /* Load target CGU register values */
++ li t3, LTQ_CGU_SYS_VALUE
++ li t4, LTQ_CGU_CLK_FSR_VALUE
++
++ /* Only update registers if values differ */
++ bne t1, t3, update
++ nop
++ beq t2, t4, finished
++ nop
++
++update:
++ /* Store target register values */
++ sw t3, LTQ_CGU_SYS(t0)
++ sw t4, LTQ_CGU_CLK_FSR(t0)
++
++ /* Perform software reset to activate new clock config */
++#if 0
++ li t0, (LTQ_RCU_BASE | KSEG1)
++ lw t1, LTQ_RCU_RST_REQ(t0)
++ or t1, LTQ_RCU_RST_REQ_VALUE
++ sw t1, LTQ_RCU_RST_REQ(t0)
++#else
++ li t1, 1
++ sw t1, LTQ_CGU_UPDATE(t0)
++#endif
++
++#if 0
++wait_reset:
++ b wait_reset
++ nop
++#endif
++
++finished:
++ jr ra
++ nop
++
++ END(ltq_cgu_init)
+--- /dev/null
++++ b/arch/mips/cpu/mips32/vrx200/chipid.c
+@@ -0,0 +1,63 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <common.h>
++#include <asm/lantiq/io.h>
++#include <asm/lantiq/chipid.h>
++#include <asm/arch/soc.h>
++
++#define LTQ_CHIPID_VERSION_SHIFT 28
++#define LTQ_CHIPID_VERSION_MASK (0x7 << LTQ_CHIPID_VERSION_SHIFT)
++#define LTQ_CHIPID_PNUM_SHIFT 12
++#define LTQ_CHIPID_PNUM_MASK (0xFFFF << LTQ_CHIPID_PNUM_SHIFT)
++
++struct ltq_chipid_regs {
++ u32 manid; /* Manufacturer identification */
++ u32 chipid; /* Chip identification */
++};
++
++static struct ltq_chipid_regs *ltq_chipid_regs =
++ (struct ltq_chipid_regs *) CKSEG1ADDR(LTQ_CHIPID_BASE);
++
++unsigned int ltq_chip_version_get(void)
++{
++ u32 chipid;
++
++ chipid = ltq_readl(&ltq_chipid_regs->chipid);
++
++ return (chipid & LTQ_CHIPID_VERSION_MASK) >> LTQ_CHIPID_VERSION_SHIFT;
++}
++
++unsigned int ltq_chip_partnum_get(void)
++{
++ u32 chipid;
++
++ chipid = ltq_readl(&ltq_chipid_regs->chipid);
++
++ return (chipid & LTQ_CHIPID_PNUM_MASK) >> LTQ_CHIPID_PNUM_SHIFT;
++}
++
++const char *ltq_chip_partnum_str(void)
++{
++ enum ltq_chip_partnum partnum = ltq_chip_partnum_get();
++
++ switch (partnum) {
++ case LTQ_SOC_VRX268:
++ case LTQ_SOC_VRX268_2:
++ return "VRX268";
++ case LTQ_SOC_VRX288:
++ case LTQ_SOC_VRX288_2:
++ return "VRX288";
++ case LTQ_SOC_GRX288:
++ case LTQ_SOC_GRX288_2:
++ return "GRX288";
++ default:
++ printf("Unknown partnum: %x\n", partnum);
++ }
++
++ return "";
++}
+--- /dev/null
++++ b/arch/mips/cpu/mips32/vrx200/config.mk
+@@ -0,0 +1,32 @@
++#
++# This file is released under the terms of GPL v2 and any later version.
++# See the file COPYING in the root directory of the source tree for details.
++#
++# Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++#
++
++PF_CPPFLAGS_XRX := $(call cc-option,-mtune=34kc,)
++PLATFORM_CPPFLAGS += $(PF_CPPFLAGS_XRX)
++
++ifdef CONFIG_SPL_BUILD
++PF_ABICALLS := -mno-abicalls
++PF_PIC := -fno-pic
++USE_PRIVATE_LIBGCC := yes
++endif
++
++LIBS-y += $(CPUDIR)/lantiq-common/liblantiq-common.o
++
++ifndef CONFIG_SPL_BUILD
++ifdef CONFIG_SYS_BOOT_SFSPL
++ALL-y += $(obj)u-boot.ltq.sfspl
++ALL-$(CONFIG_SPL_LZO_SUPPORT) += $(obj)u-boot.ltq.lzo.sfspl
++ALL-$(CONFIG_SPL_LZMA_SUPPORT) += $(obj)u-boot.ltq.lzma.sfspl
++endif
++ifdef CONFIG_SYS_BOOT_NORSPL
++ALL-y += $(obj)u-boot.ltq.norspl
++ALL-$(CONFIG_SPL_LZO_SUPPORT) += $(obj)u-boot.ltq.lzo.norspl
++ALL-$(CONFIG_SPL_LZMA_SUPPORT) += $(obj)u-boot.ltq.lzma.norspl
++endif
++endif
++
++LDSCRIPT := $(TOPDIR)/$(CPUDIR)/$(SOC)/u-boot.lds
+--- /dev/null
++++ b/arch/mips/cpu/mips32/vrx200/dcdc.c
+@@ -0,0 +1,107 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2010 Lantiq Deutschland GmbH
++ * Copyright (C) 2011-2012 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <common.h>
++#include <asm/arch/soc.h>
++#include <asm/lantiq/io.h>
++
++#define LTQ_DCDC_CLK_SET0_CLK_SEL_P (1 << 6)
++#define LTQ_DCDC_CLK_SET1_SEL_DIV25 (1 << 5)
++#define LTQ_DCDC_CONF_TEST_DIG_PID_FREEZE (1 << 5)
++
++struct ltq_dcdc_regs {
++ u8 b0_coeh; /* Coefficient b0 */
++ u8 b0_coel; /* Coefficient b0 */
++ u8 b1_coeh; /* Coefficient b1 */
++ u8 b1_coel; /* Coefficient b1 */
++ u8 b2_coeh; /* Coefficient b2 */
++ u8 b2_coel; /* Coefficient b2 */
++ u8 clk_set0; /* Clock setup */
++ u8 clk_set1; /* Clock setup */
++ u8 pwm_confh; /* Configure PWM */
++ u8 pwm_confl; /* Configure PWM */
++ u8 bias_vreg0; /* Bias and regulator setup */
++ u8 bias_vreg1; /* Bias and regulator setup */
++ u8 adc_gen0; /* ADC and general control */
++ u8 adc_gen1; /* ADC and general control */
++ u8 adc_con0; /* ADC and general config */
++ u8 adc_con1; /* ADC and general config */
++ u8 conf_test_ana; /* not documented */
++ u8 conf_test_dig; /* not documented */
++ u8 dcdc_status; /* not documented */
++ u8 pid_status; /* not documented */
++ u8 duty_cycle; /* not documented */
++ u8 non_ov_delay; /* not documented */
++ u8 analog_gain; /* not documented */
++ u8 duty_cycle_max_sat; /* not documented */
++ u8 duty_cycle_min_sat; /* not documented */
++ u8 duty_cycle_max; /* not documented */
++ u8 duty_cycle_min; /* not documented */
++ u8 error_max; /* not documented */
++ u8 error_read; /* not documented */
++ u8 delay_deglitch; /* not documented */
++ u8 latch_control; /* not documented */
++ u8 rsvd[240];
++ u8 osc_conf; /* OSC general config */
++ u8 osc_stat; /* OSC general status */
++};
++
++static struct ltq_dcdc_regs *ltq_dcdc_regs =
++ (struct ltq_dcdc_regs *) CKSEG1ADDR(LTQ_DCDC_BASE);
++
++void ltq_dcdc_init(unsigned int dig_ref)
++{
++ u8 dig_ref_cur, val;
++
++ /* Set duty cycle max sat. to 70/90, enable PID freeze */
++ ltq_writeb(&ltq_dcdc_regs->duty_cycle_max_sat, 0x5A);
++ ltq_writeb(&ltq_dcdc_regs->duty_cycle_min_sat, 0x46);
++ val = ltq_readb(&ltq_dcdc_regs->conf_test_dig);
++ val |= LTQ_DCDC_CONF_TEST_DIG_PID_FREEZE;
++ ltq_writeb(&ltq_dcdc_regs->conf_test_dig, val);
++
++ /* Program new coefficients */
++ ltq_writeb(&ltq_dcdc_regs->b0_coeh, 0x00);
++ ltq_writeb(&ltq_dcdc_regs->b0_coel, 0x00);
++ ltq_writeb(&ltq_dcdc_regs->b1_coeh, 0xFF);
++ ltq_writeb(&ltq_dcdc_regs->b1_coel, 0xE6);
++ ltq_writeb(&ltq_dcdc_regs->b2_coeh, 0x00);
++ ltq_writeb(&ltq_dcdc_regs->b2_coel, 0x1B);
++ ltq_writeb(&ltq_dcdc_regs->non_ov_delay, 0x8B);
++
++ /* Set duty cycle max sat. to 60/108, disable PID freeze */
++ ltq_writeb(&ltq_dcdc_regs->duty_cycle_max_sat, 0x6C);
++ ltq_writeb(&ltq_dcdc_regs->duty_cycle_min_sat, 0x3C);
++ val = ltq_readb(&ltq_dcdc_regs->conf_test_dig);
++ val &= ~LTQ_DCDC_CONF_TEST_DIG_PID_FREEZE;
++ ltq_writeb(&ltq_dcdc_regs->conf_test_dig, val);
++
++ /* Init clock and DLL settings */
++ val = ltq_readb(&ltq_dcdc_regs->clk_set0);
++ val |= LTQ_DCDC_CLK_SET0_CLK_SEL_P;
++ ltq_writeb(&ltq_dcdc_regs->clk_set0, val);
++ val = ltq_readb(&ltq_dcdc_regs->clk_set1);
++ val |= LTQ_DCDC_CLK_SET1_SEL_DIV25;
++ ltq_writeb(&ltq_dcdc_regs->clk_set1, val);
++ ltq_writeb(&ltq_dcdc_regs->pwm_confh, 0xF9);
++
++ wmb();
++
++ /* Adapt value of digital reference of DCDC converter */
++ dig_ref_cur = ltq_readb(&ltq_dcdc_regs->bias_vreg1);
++
++ while (dig_ref_cur != dig_ref) {
++ if (dig_ref >= dig_ref_cur)
++ dig_ref_cur++;
++ else if (dig_ref < dig_ref_cur)
++ dig_ref_cur--;
++
++ ltq_writeb(&ltq_dcdc_regs->bias_vreg1, dig_ref_cur);
++ __udelay(1000);
++ }
++}
+--- /dev/null
++++ b/arch/mips/cpu/mips32/vrx200/ebu.c
+@@ -0,0 +1,112 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <common.h>
++#include <asm/arch/soc.h>
++#include <asm/lantiq/io.h>
++
++#define EBU_ADDRSEL_MASK(mask) ((mask & 0xf) << 4)
++#define EBU_ADDRSEL_REGEN (1 << 0)
++
++#define EBU_CON_WRDIS (1 << 31)
++#define EBU_CON_AGEN_DEMUX (0x0 << 24)
++#define EBU_CON_AGEN_MUX (0x2 << 24)
++#define EBU_CON_SETUP (1 << 22)
++#define EBU_CON_WAIT_DIS (0x0 << 20)
++#define EBU_CON_WAIT_ASYNC (0x1 << 20)
++#define EBU_CON_WAIT_SYNC (0x2 << 20)
++#define EBU_CON_WINV (1 << 19)
++#define EBU_CON_PW_8BIT (0x0 << 16)
++#define EBU_CON_PW_16BIT (0x1 << 16)
++#define EBU_CON_ALEC(cycles) ((cycles & 0x3) << 14)
++#define EBU_CON_BCGEN_CS (0x0 << 12)
++#define EBU_CON_BCGEN_INTEL (0x1 << 12)
++#define EBU_CON_BCGEN_MOTOROLA (0x2 << 12)
++#define EBU_CON_WAITWRC(cycles) ((cycles & 0x7) << 8)
++#define EBU_CON_WAITRDC(cycles) ((cycles & 0x3) << 6)
++#define EBU_CON_HOLDC(cycles) ((cycles & 0x3) << 4)
++#define EBU_CON_RECOVC(cycles) ((cycles & 0x3) << 2)
++#define EBU_CON_CMULT_1 0x0
++#define EBU_CON_CMULT_4 0x1
++#define EBU_CON_CMULT_8 0x2
++#define EBU_CON_CMULT_16 0x3
++
++#if defined(CONFIG_LTQ_SUPPORT_NOR_FLASH)
++#define ebu_region0_enable 1
++#else
++#define ebu_region0_enable 0
++#endif
++
++#if defined(CONFIG_LTQ_SUPPORT_NAND_FLASH)
++#define ebu_region1_enable 1
++#else
++#define ebu_region1_enable 0
++#endif
++
++struct ltq_ebu_regs {
++ u32 clc;
++ u32 rsvd0;
++ u32 id;
++ u32 rsvd1;
++ u32 con;
++ u32 rsvd2[3];
++ u32 addr_sel_0;
++ u32 addr_sel_1;
++ u32 addr_sel_2;
++ u32 addr_sel_3;
++ u32 rsvd3[12];
++ u32 con_0;
++ u32 con_1;
++ u32 con_2;
++ u32 con_3;
++};
++
++static struct ltq_ebu_regs *ltq_ebu_regs =
++ (struct ltq_ebu_regs *) CKSEG1ADDR(LTQ_EBU_BASE);
++
++void ltq_ebu_init(void)
++{
++ if (ebu_region0_enable) {
++ /*
++ * Map EBU region 0 to range 0x10000000-0x13ffffff and enable
++ * region control. This supports up to 32 MiB NOR flash in
++ * bank 0.
++ */
++ ltq_writel(&ltq_ebu_regs->addr_sel_0, LTQ_EBU_REGION0_BASE |
++ EBU_ADDRSEL_MASK(1) | EBU_ADDRSEL_REGEN);
++
++ ltq_writel(&ltq_ebu_regs->con_0, EBU_CON_AGEN_DEMUX |
++ EBU_CON_WAIT_DIS | EBU_CON_PW_16BIT |
++ EBU_CON_ALEC(3) | EBU_CON_BCGEN_INTEL |
++ EBU_CON_WAITWRC(7) | EBU_CON_WAITRDC(3) |
++ EBU_CON_HOLDC(3) | EBU_CON_RECOVC(3) |
++ EBU_CON_CMULT_16);
++ } else
++ ltq_clrbits(&ltq_ebu_regs->addr_sel_0, EBU_ADDRSEL_REGEN);
++
++ if (ebu_region1_enable) {
++ /*
++ * Map EBU region 1 to range 0x14000000-0x13ffffff and enable
++ * region control. This supports NAND flash in bank 1.
++ */
++ ltq_writel(&ltq_ebu_regs->addr_sel_1, LTQ_EBU_REGION1_BASE |
++ EBU_ADDRSEL_MASK(3) | EBU_ADDRSEL_REGEN);
++
++ ltq_writel(&ltq_ebu_regs->con_1, EBU_CON_AGEN_DEMUX |
++ EBU_CON_SETUP | EBU_CON_WAIT_DIS | EBU_CON_PW_8BIT |
++ EBU_CON_ALEC(3) | EBU_CON_BCGEN_INTEL |
++ EBU_CON_WAITWRC(2) | EBU_CON_WAITRDC(2) |
++ EBU_CON_HOLDC(1) | EBU_CON_RECOVC(1) |
++ EBU_CON_CMULT_4);
++ } else
++ ltq_clrbits(&ltq_ebu_regs->addr_sel_1, EBU_ADDRSEL_REGEN);
++}
++
++void *flash_swap_addr(unsigned long addr)
++{
++ return (void *)(addr ^ 2);
++}
+--- /dev/null
++++ b/arch/mips/cpu/mips32/vrx200/gphy.c
+@@ -0,0 +1,59 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <common.h>
++#include <asm/lantiq/io.h>
++#include <asm/arch/soc.h>
++#include <asm/arch/gphy.h>
++
++static inline void ltq_gphy_copy(const void *fw_start, const void *fw_end,
++ ulong dst_addr)
++{
++ const ulong fw_len = (ulong) fw_end - (ulong) fw_start;
++ const ulong addr = CKSEG1ADDR(dst_addr);
++
++ debug("ltq_gphy_copy: addr %08lx, fw_start %p, fw_end %p\n",
++ addr, fw_start, fw_end);
++
++ memcpy((void *) addr, fw_start, fw_len);
++}
++
++void ltq_gphy_phy11g_a1x_load(ulong addr)
++{
++ extern ulong __ltq_fw_phy11g_a1x_start;
++ extern ulong __ltq_fw_phy11g_a1x_end;
++
++ ltq_gphy_copy(&__ltq_fw_phy11g_a1x_start, &__ltq_fw_phy11g_a1x_end,
++ addr);
++}
++
++void ltq_gphy_phy11g_a2x_load(ulong addr)
++{
++ extern ulong __ltq_fw_phy11g_a2x_start;
++ extern ulong __ltq_fw_phy11g_a2x_end;
++
++ ltq_gphy_copy(&__ltq_fw_phy11g_a2x_start, &__ltq_fw_phy11g_a2x_end,
++ addr);
++}
++
++void ltq_gphy_phy22f_a1x_load(ulong addr)
++{
++ extern ulong __ltq_fw_phy22f_a1x_start;
++ extern ulong __ltq_fw_phy22f_a1x_end;
++
++ ltq_gphy_copy(&__ltq_fw_phy22f_a1x_start, &__ltq_fw_phy22f_a1x_end,
++ addr);
++}
++
++void ltq_gphy_phy22f_a2x_load(ulong addr)
++{
++ extern ulong __ltq_fw_phy22f_a2x_start;
++ extern ulong __ltq_fw_phy22f_a2x_end;
++
++ ltq_gphy_copy(&__ltq_fw_phy22f_a2x_start, &__ltq_fw_phy22f_a2x_end,
++ addr);
++}
+--- /dev/null
++++ b/arch/mips/cpu/mips32/vrx200/gphy_fw.S
+@@ -0,0 +1,28 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <asm/asm.h>
++
++ .section .rodata.__ltq_fw_phy11g_a1x
++EXPORT(__ltq_fw_phy11g_a1x_start)
++ .incbin "fw_phy11g_a1x.bin"
++EXPORT(__ltq_fw_phy11g_a1x_end)
++
++ .section .rodata.__ltq_fw_phy11g_a2x
++EXPORT(__ltq_fw_phy11g_a2x_start)
++ .incbin "fw_phy11g_a2x.bin"
++EXPORT(__ltq_fw_phy11g_a2x_end)
++
++ .section .rodata.__ltq_fw_phy22f_a1x
++EXPORT(__ltq_fw_phy22f_a1x_start)
++ .incbin "fw_phy22f_a1x.bin"
++EXPORT(__ltq_fw_phy22f_a1x_end)
++
++ .section .rodata.__ltq_fw_phy22f_a2x
++EXPORT(__ltq_fw_phy22f_a2x_start)
++ .incbin "fw_phy22f_a2x.bin"
++EXPORT(__ltq_fw_phy22f_a2x_end)
+--- /dev/null
++++ b/arch/mips/cpu/mips32/vrx200/mem.c
+@@ -0,0 +1,58 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <common.h>
++#include <asm/arch/soc.h>
++#include <asm/lantiq/io.h>
++
++#define LTQ_CCR03_EIGHT_BANK_MODE (1 << 0)
++#define LTQ_CCR08_CS_MAP_SHIFT 24
++#define LTQ_CCR08_CS_MAP_MASK (0x3 << LTQ_CCR08_CS_MAP_SHIFT)
++#define LTQ_CCR11_COLUMN_SIZE_SHIFT 24
++#define LTQ_CCR11_COLUMN_SIZE_MASK (0x7 << LTQ_CCR11_COLUMN_SIZE_SHIFT)
++#define LTQ_CCR11_ADDR_PINS_MASK 0x7
++#define LTQ_CCR15_MAX_COL_REG_SHIFT 24
++#define LTQ_CCR15_MAX_COL_REG_MASK (0xF << LTQ_CCR15_MAX_COL_REG_SHIFT)
++#define LTQ_CCR16_MAX_ROW_REG_MASK 0xF
++
++static void *ltq_mc_ddr_base = (void *) CKSEG1ADDR(LTQ_MC_DDR_BASE);
++
++static inline u32 ltq_mc_ccr_read(u32 index)
++{
++ return ltq_readl(ltq_mc_ddr_base + LTQ_MC_DDR_CCR_OFFSET(index));
++}
++
++phys_size_t initdram(int board_type)
++{
++ u32 max_col_reg, max_row_reg, column_size, addr_pins;
++ u32 banks, cs_map;
++ phys_size_t size;
++
++ banks = (ltq_mc_ccr_read(3) & LTQ_CCR03_EIGHT_BANK_MODE) ? 8 : 4;
++
++ cs_map = (ltq_mc_ccr_read(8) & LTQ_CCR08_CS_MAP_MASK) >>
++ LTQ_CCR08_CS_MAP_SHIFT;
++
++ column_size = (ltq_mc_ccr_read(11) & LTQ_CCR11_COLUMN_SIZE_MASK) >>
++ LTQ_CCR11_COLUMN_SIZE_SHIFT;
++
++ addr_pins = ltq_mc_ccr_read(11) & LTQ_CCR11_ADDR_PINS_MASK;
++
++ max_col_reg = (ltq_mc_ccr_read(15) & LTQ_CCR15_MAX_COL_REG_MASK) >>
++ LTQ_CCR15_MAX_COL_REG_SHIFT;
++
++ max_row_reg = ltq_mc_ccr_read(16) & LTQ_CCR16_MAX_ROW_REG_MASK;
++
++ /*
++ * size (bytes) = 2 ^ rowsize * 2 ^ colsize * banks * chipselects
++ * * datawidth (bytes)
++ */
++ size = (2 << (max_col_reg - column_size - 1)) *
++ (2 << (max_row_reg - addr_pins - 1)) * banks * cs_map * 2;
++
++ return size;
++}
+--- /dev/null
++++ b/arch/mips/cpu/mips32/vrx200/mem_init.S
+@@ -0,0 +1,234 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2010 Lantiq Deutschland GmbH
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <config.h>
++#include <asm/asm.h>
++#include <asm/regdef.h>
++#include <asm/addrspace.h>
++#include <asm/arch/soc.h>
++
++/* Must be configured in BOARDDIR */
++#include <ddr_settings.h>
++
++#define LTQ_MC_DDR_START (1 << 8)
++#define LTQ_MC_DDR_DLL_LOCK_IND 1
++
++#define CCS_ALWAYS_LAST 0x0430
++#define CCS_AHBM_CR_BURST_EN (1 << 2)
++#define CCS_FPIM_CR_BURST_EN (1 << 1)
++
++#define CCR03_EIGHT_BANK_MODE (1 << 0)
++
++ /* Store given value in MC DDR CCRx register */
++ .macro ccr_sw num, val
++ li t1, \val
++ sw t1, LTQ_MC_DDR_CCR_OFFSET(\num)(t0)
++ .endm
++
++LEAF(ltq_mem_init)
++ /* Load MC DDR module base */
++ li t0, (LTQ_MC_DDR_BASE | KSEG1)
++
++ /* Put memory controller in inactive mode */
++ sw zero, LTQ_MC_DDR_CCR_OFFSET(7)(t0)
++
++ /* Init MC DDR CCR registers with values from ddr_settings.h */
++ ccr_sw 0, MC_CCR00_VALUE
++ ccr_sw 1, MC_CCR01_VALUE
++ ccr_sw 2, MC_CCR02_VALUE
++ ccr_sw 3, MC_CCR03_VALUE
++ ccr_sw 4, MC_CCR04_VALUE
++ ccr_sw 5, MC_CCR05_VALUE
++ ccr_sw 6, MC_CCR06_VALUE
++ ccr_sw 7, MC_CCR07_VALUE
++ ccr_sw 8, MC_CCR08_VALUE
++ ccr_sw 9, MC_CCR09_VALUE
++
++ ccr_sw 10, MC_CCR10_VALUE
++ ccr_sw 11, MC_CCR11_VALUE
++ ccr_sw 12, MC_CCR12_VALUE
++ ccr_sw 13, MC_CCR13_VALUE
++ ccr_sw 14, MC_CCR14_VALUE
++ ccr_sw 15, MC_CCR15_VALUE
++ ccr_sw 16, MC_CCR16_VALUE
++ ccr_sw 17, MC_CCR17_VALUE
++ ccr_sw 18, MC_CCR18_VALUE
++ ccr_sw 19, MC_CCR19_VALUE
++
++ ccr_sw 20, MC_CCR20_VALUE
++ ccr_sw 21, MC_CCR21_VALUE
++ ccr_sw 22, MC_CCR22_VALUE
++ ccr_sw 23, MC_CCR23_VALUE
++ ccr_sw 24, MC_CCR24_VALUE
++ ccr_sw 25, MC_CCR25_VALUE
++ ccr_sw 26, MC_CCR26_VALUE
++ ccr_sw 27, MC_CCR27_VALUE
++ ccr_sw 28, MC_CCR28_VALUE
++ ccr_sw 29, MC_CCR29_VALUE
++
++ ccr_sw 30, MC_CCR30_VALUE
++ ccr_sw 31, MC_CCR31_VALUE
++ ccr_sw 32, MC_CCR32_VALUE
++ ccr_sw 33, MC_CCR33_VALUE
++ ccr_sw 34, MC_CCR34_VALUE
++ ccr_sw 35, MC_CCR35_VALUE
++ ccr_sw 36, MC_CCR36_VALUE
++ ccr_sw 37, MC_CCR37_VALUE
++ ccr_sw 38, MC_CCR38_VALUE
++ ccr_sw 39, MC_CCR39_VALUE
++
++ ccr_sw 40, MC_CCR40_VALUE
++ ccr_sw 41, MC_CCR41_VALUE
++ ccr_sw 42, MC_CCR42_VALUE
++ ccr_sw 43, MC_CCR43_VALUE
++ ccr_sw 44, MC_CCR44_VALUE
++ ccr_sw 45, MC_CCR45_VALUE
++ ccr_sw 46, MC_CCR46_VALUE
++
++ ccr_sw 52, MC_CCR52_VALUE
++ ccr_sw 53, MC_CCR53_VALUE
++ ccr_sw 54, MC_CCR54_VALUE
++ ccr_sw 55, MC_CCR55_VALUE
++ ccr_sw 56, MC_CCR56_VALUE
++ ccr_sw 57, MC_CCR57_VALUE
++ ccr_sw 58, MC_CCR58_VALUE
++ ccr_sw 59, MC_CCR59_VALUE
++
++ ccr_sw 60, MC_CCR60_VALUE
++ ccr_sw 61, MC_CCR61_VALUE
++
++ /* Disable bursts between FPI Master bus and XBAR bus */
++ li t4, (LTQ_MC_GLOBAL_BASE | KSEG1)
++ li t5, CCS_AHBM_CR_BURST_EN
++ sw t5, CCS_ALWAYS_LAST(t4)
++
++ /* Init abort condition for DRAM probe */
++ move t4, zero
++
++ /*
++ * Put memory controller in active mode and start initialitation
++ * sequence for connected DDR-SDRAM device
++ */
++mc_start:
++ lw t1, LTQ_MC_DDR_CCR_OFFSET(7)(t0)
++ li t2, LTQ_MC_DDR_START
++ or t1, t1, t2
++ sw t1, LTQ_MC_DDR_CCR_OFFSET(7)(t0)
++
++ /*
++ * Wait until DLL has locked and core is ready for data transfers.
++ * DLL lock indication is in register CCR47 and CCR48
++ */
++wait_ready:
++ li t1, LTQ_MC_DDR_DLL_LOCK_IND
++ lw t2, LTQ_MC_DDR_CCR_OFFSET(47)(t0)
++ and t2, t2, t1
++ bne t1, t2, wait_ready
++
++ lw t2, LTQ_MC_DDR_CCR_OFFSET(48)(t0)
++ and t2, t2, t1
++ bne t1, t2, wait_ready
++
++#ifdef CONFIG_SYS_DRAM_PROBE
++dram_probe:
++ /* Initialization is finished after the second MC start */
++ bnez t4, mc_finished
++
++ /*
++ * Preload register values for CCR03 and CCR11. Initial settings
++ * are 8-bank mode enabled, 14 use address row bits, 10 used
++ * column address bits.
++ */
++ li t1, CONFIG_SYS_SDRAM_BASE_UC
++ li t5, MC_CCR03_VALUE
++ li t6, MC_CCR11_VALUE
++ addi t4, t4, 1
++
++ /*
++ * Store test values to DRAM at offsets 0 and 2^13 (bit 2 in bank select
++ * address BA[3]) and read back the value at offset 0. If the resulting
++ * value is equal to 1 we can skip to the next test. Otherwise
++ * the 8-bank mode does not work with the current DRAM device,
++ * thus we need to clear the according bit in register CCR03.
++ */
++ li t2, 1
++ sw t2, 0x0(t1)
++ li t3, (1 << 13)
++ add t3, t3, t1
++ sw zero, 0(t3)
++ lw t3, 0(t1)
++ bnez t3, row_col_test
++
++ /* Clear CCR03.EIGHT_BANK_MODE */
++ li t3, ~CCR03_EIGHT_BANK_MODE
++ and t5, t5, t3
++
++row_col_test:
++ /*
++ * Store test values to DRAM at offsets 0, 2^27 (bit 13 of row address
++ * RA[14]) and 2^26 (bit 12 of RA[14]). The chosen test values
++ * represent the difference between max. row address bits (14) and used
++ * row address bits. Then the read back value at offset 0 indicates
++ * the useable row address bits with the current DRAM device. This
++ * value must be set in the CCR11 register.
++ */
++ sw zero, 0(t1)
++
++ li t2, 1
++ li t3, (1 << 27)
++ add t3, t3, t1
++ sw t2, 0(t3)
++
++ li t2, 2
++ li t3, (1 << 26)
++ add t3, t3, t1
++ sw t2, 0(t3)
++
++ /* Update CCR11.ADDR_PINS */
++ lw t3, 0(t1)
++ add t6, t6, t3
++
++ /*
++ * Store test values to DRAM at offsets 0, 2^10 (bit 9 of column address
++ * CA[10]) and 2^9 (bit 8 of CA[10]). The chosen test values represent
++ * the difference between max. column address bits (12) and used
++ * column address bits. Then the read back value at offset 0 indicates
++ * the useable column address bits with the current DRAM device. This
++ * value must be set in the CCR11 register.
++ */
++ sw zero, 0(t1)
++
++ li t2, 1
++ li t3, (1 << 10)
++ add t3, t3, t1
++ sw t2, 0(t3)
++
++ li t2, 2
++ li t3, (1 << 9)
++ add t3, t3, t1
++ sw t2, 0(t3)
++
++ /* Update CCR11.COLUMN_SIZE */
++ lw t3, 0(t1)
++ sll t3, t3, 24
++ add t6, t6, t3
++
++ /* Put memory controller in inactive mode */
++ sw zero, LTQ_MC_DDR_CCR_OFFSET(7)(t0)
++
++ /* Update CCR03 and CCR11 and restart memory controller initialiation */
++ sw t5, LTQ_MC_DDR_CCR_OFFSET(3)(t0)
++ sw t6, LTQ_MC_DDR_CCR_OFFSET(11)(t0)
++ b mc_start
++
++mc_finished:
++#endif /* CONFIG_SYS_DRAM_PROBE */
++
++ jr ra
++
++ END(ltq_mem_init)
+--- /dev/null
++++ b/arch/mips/cpu/mips32/vrx200/pmu.c
+@@ -0,0 +1,131 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <common.h>
++#include <asm/lantiq/io.h>
++#include <asm/lantiq/pm.h>
++#include <asm/arch/soc.h>
++
++#define LTQ_PMU_PWDCR_RESERVED ((1 << 13) | (1 << 4))
++
++#define LTQ_PMU_PWDCR_PCIELOC_EN (1 << 31)
++#define LTQ_PMU_PWDCR_GPHY (1 << 30)
++#define LTQ_PMU_PWDCR_PPE_TOP (1 << 29)
++#define LTQ_PMU_PWDCR_SWITCH (1 << 28)
++#define LTQ_PMU_PWDCR_USB1 (1 << 27)
++#define LTQ_PMU_PWDCR_USB1_PHY (1 << 26)
++#define LTQ_PMU_PWDCR_TDM (1 << 25)
++#define LTQ_PMU_PWDCR_PPE_DPLUS (1 << 24)
++#define LTQ_PMU_PWDCR_PPE_DPLUM (1 << 23)
++#define LTQ_PMU_PWDCR_PPE_EMA (1 << 22)
++#define LTQ_PMU_PWDCR_PPE_TC (1 << 21)
++#define LTQ_PMU_PWDCR_DEU (1 << 20)
++#define LTQ_PMU_PWDCR_PPE_SLL01 (1 << 19)
++#define LTQ_PMU_PWDCR_PPE_QSB (1 << 18)
++#define LTQ_PMU_PWDCR_UART1 (1 << 17)
++#define LTQ_PMU_PWDCR_SDIO (1 << 16)
++#define LTQ_PMU_PWDCR_AHBM (1 << 15)
++#define LTQ_PMU_PWDCR_FPIM (1 << 14)
++#define LTQ_PMU_PWDCR_GPTC (1 << 12)
++#define LTQ_PMU_PWDCR_LEDC (1 << 11)
++#define LTQ_PMU_PWDCR_EBU (1 << 10)
++#define LTQ_PMU_PWDCR_DSL (1 << 9)
++#define LTQ_PMU_PWDCR_SPI (1 << 8)
++#define LTQ_PMU_PWDCR_USIF (1 << 7)
++#define LTQ_PMU_PWDCR_USB0 (1 << 6)
++#define LTQ_PMU_PWDCR_DMA (1 << 5)
++#define LTQ_PMU_PWDCR_DFEV1 (1 << 3)
++#define LTQ_PMU_PWDCR_DFEV0 (1 << 2)
++#define LTQ_PMU_PWDCR_FPIS (1 << 1)
++#define LTQ_PMU_PWDCR_USB0_PHY (1 << 0)
++
++struct ltq_pmu_regs {
++ u32 rsvd0[7];
++ u32 pwdcr; /* Power down control */
++ u32 sr; /* Power down status */
++ u32 pwdcr1; /* Power down control 1 */
++ u32 sr1; /* Power down status 1 */
++};
++
++static struct ltq_pmu_regs *ltq_pmu_regs =
++ (struct ltq_pmu_regs *) CKSEG1ADDR(LTQ_PMU_BASE);
++
++u32 ltq_pm_map(enum ltq_pm_modules module)
++{
++ u32 val;
++
++ switch (module) {
++ case LTQ_PM_CORE:
++ val = LTQ_PMU_PWDCR_UART1 | LTQ_PMU_PWDCR_FPIM |
++ LTQ_PMU_PWDCR_LEDC | LTQ_PMU_PWDCR_EBU;
++ break;
++ case LTQ_PM_DMA:
++ val = LTQ_PMU_PWDCR_DMA;
++ break;
++ case LTQ_PM_ETH:
++ val = LTQ_PMU_PWDCR_GPHY | LTQ_PMU_PWDCR_PPE_TOP |
++ LTQ_PMU_PWDCR_SWITCH | LTQ_PMU_PWDCR_PPE_DPLUS |
++ LTQ_PMU_PWDCR_PPE_DPLUM | LTQ_PMU_PWDCR_PPE_EMA |
++ LTQ_PMU_PWDCR_PPE_TC | LTQ_PMU_PWDCR_PPE_SLL01 |
++ LTQ_PMU_PWDCR_PPE_QSB;
++ break;
++ case LTQ_PM_SPI:
++ val = LTQ_PMU_PWDCR_SPI;
++ break;
++ default:
++ val = 0;
++ break;
++ }
++
++ return val;
++}
++
++int ltq_pm_enable(enum ltq_pm_modules module)
++{
++ const unsigned long timeout = 1000;
++ unsigned long timebase;
++ u32 sr, val;
++
++ val = ltq_pm_map(module);
++ if (unlikely(!val))
++ return 1;
++
++ ltq_clrbits(&ltq_pmu_regs->pwdcr, val);
++
++ timebase = get_timer(0);
++
++ do {
++ sr = ltq_readl(&ltq_pmu_regs->sr);
++ if (~sr & val)
++ return 0;
++ } while (get_timer(timebase) < timeout);
++
++ return 1;
++}
++
++int ltq_pm_disable(enum ltq_pm_modules module)
++{
++ u32 val;
++
++ val = ltq_pm_map(module);
++ if (unlikely(!val))
++ return 1;
++
++ ltq_setbits(&ltq_pmu_regs->pwdcr, val);
++
++ return 0;
++}
++
++void ltq_pmu_init(void)
++{
++ u32 set, clr;
++
++ clr = ltq_pm_map(LTQ_PM_CORE);
++ set = ~(LTQ_PMU_PWDCR_RESERVED | clr);
++
++ ltq_clrsetbits(&ltq_pmu_regs->pwdcr, clr, set);
++}
+--- /dev/null
++++ b/arch/mips/cpu/mips32/vrx200/rcu.c
+@@ -0,0 +1,195 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <common.h>
++#include <asm/lantiq/io.h>
++#include <asm/lantiq/reset.h>
++#include <asm/lantiq/cpu.h>
++#include <asm/arch/soc.h>
++
++#define LTQ_RCU_RD_GPHY0 (1 << 31) /* GPHY0 */
++#define LTQ_RCU_RD_SRST (1 << 30) /* Global SW Reset */
++#define LTQ_RCU_RD_GPHY1 (1 << 29) /* GPHY1 */
++#define LTQ_RCU_RD_ENMIP2 (1 << 28) /* Enable NMI of PLL2 */
++#define LTQ_RCU_RD_REG25_PD (1 << 26) /* Power down 2.5V regulator */
++#define LTQ_RCU_RD_ENDINIT (1 << 25) /* FPI slave bus access */
++#define LTQ_RCU_RD_PPE_ATM_TC (1 << 23) /* PPE ATM TC */
++#define LTQ_RCU_RD_PCIE (1 << 22) /* PCI-E core */
++#define LTQ_RCU_RD_ETHSW (1 << 21) /* Ethernet switch */
++#define LTQ_RCU_RD_DSP_DEN (1 << 20) /* Enable DSP JTAG */
++#define LTQ_RCU_RD_TDM (1 << 19) /* TDM module interface */
++#define LTQ_RCU_RD_ENMIP1 (1 << 18) /* Enable NMI of PLL1 */
++#define LTQ_RCU_RD_SWBCK (1 << 17) /* Switch backward compat */
++#define LTQ_RCU_RD_HSNAND (1 << 16) /* HSNAND controller */
++#define LTQ_RCU_RD_ENMIP0 (1 << 15) /* Enable NMI of PLL0 */
++#define LTQ_RCU_RD_MC (1 << 14) /* Memory Controller */
++#define LTQ_RCU_RD_PCI (1 << 13) /* PCI core */
++#define LTQ_RCU_RD_PCIE_PHY (1 << 12) /* PCI-E Phy */
++#define LTQ_RCU_RD_DFE_CORE (1 << 11) /* DFE core */
++#define LTQ_RCU_RD_SDIO (1 << 10) /* SDIO core */
++#define LTQ_RCU_RD_DMA (1 << 9) /* DMA core */
++#define LTQ_RCU_RD_PPE (1 << 8) /* PPE core */
++#define LTQ_RCU_RD_DFE (1 << 7) /* DFE core */
++#define LTQ_RCU_RD_AHB (1 << 6) /* AHB bus */
++#define LTQ_RCU_RD_HRST_CFG (1 << 5) /* HW reset configuration */
++#define LTQ_RCU_RD_USB (1 << 4) /* USB and Phy core */
++#define LTQ_RCU_RD_PPE_DSP (1 << 3) /* PPE DSP interface */
++#define LTQ_RCU_RD_FPI (1 << 2) /* FPI bus */
++#define LTQ_RCU_RD_CPU (1 << 1) /* CPU subsystem */
++#define LTQ_RCU_RD_HRST (1 << 0) /* HW reset via HRST pin */
++
++#define LTQ_RCU_STAT_BOOT_SHIFT 17
++#define LTQ_RCU_STAT_BOOT_MASK (0xF << LTQ_RCU_STAT_BOOT_SHIFT)
++#define LTQ_RCU_STAT_BOOT_H (1 << 12)
++
++#define LTQ_RCU_GP_STRAP_CLOCKSOURCE (1 << 15)
++
++struct ltq_rcu_regs {
++ u32 rsvd0[4];
++ u32 req; /* Reset request */
++ u32 stat; /* Reset status */
++ u32 usb0_cfg; /* USB0 configure */
++ u32 gp_strap; /* GPIO strapping */
++ u32 gfs_add0; /* GPHY0 firmware base addr */
++ u32 stat2; /* SLIC and USB reset status */
++ u32 pci_rdy; /* PCI boot ready */
++ u32 ppe_conf; /* PPE ethernet config */
++ u32 pcie_phy_con; /* PCIE PHY config/status */
++ u32 usb1_cfg; /* USB1 configure */
++ u32 usb_ana_cfg1a; /* USB analog config 1a */
++ u32 usb_ana_cfg1b; /* USB analog config 1b */
++ u32 rsvd1;
++ u32 gf_mdio_add; /* GPHY0/1 MDIO address */
++ u32 req2; /* SLIC and USB reset request */
++ u32 ahb_endian; /* AHB bus endianess */
++ u32 rsvd2[4];
++ u32 gcc; /* General CPU config */
++ u32 rsvd3;
++ u32 gfs_add1; /* GPHY1 firmware base addr */
++};
++
++static struct ltq_rcu_regs *ltq_rcu_regs =
++ (struct ltq_rcu_regs *) CKSEG1ADDR(LTQ_RCU_BASE);
++
++u32 ltq_reset_map(enum ltq_reset_modules module)
++{
++ u32 val;
++
++ switch (module) {
++ case LTQ_RESET_CORE:
++ case LTQ_RESET_SOFT:
++ val = LTQ_RCU_RD_SRST | LTQ_RCU_RD_CPU | LTQ_RCU_RD_ENMIP2 |
++ LTQ_RCU_RD_GPHY1 | LTQ_RCU_RD_GPHY0;
++ break;
++ case LTQ_RESET_DMA:
++ val = LTQ_RCU_RD_DMA;
++ break;
++ case LTQ_RESET_ETH:
++ val = LTQ_RCU_RD_PPE | LTQ_RCU_RD_ETHSW;
++ break;
++ case LTQ_RESET_PHY:
++ val = LTQ_RCU_RD_GPHY1 | LTQ_RCU_RD_GPHY0;
++ break;
++ case LTQ_RESET_HARD:
++ val = LTQ_RCU_RD_HRST;
++ break;
++ default:
++ val = 0;
++ break;
++ }
++
++ return val;
++}
++
++int ltq_reset_activate(enum ltq_reset_modules module)
++{
++ u32 val;
++
++ val = ltq_reset_map(module);
++ if (unlikely(!val))
++ return 1;
++
++ ltq_setbits(&ltq_rcu_regs->req, val);
++
++ return 0;
++}
++
++int ltq_reset_deactivate(enum ltq_reset_modules module)
++{
++ u32 val;
++
++ val = ltq_reset_map(module);
++ if (unlikely(!val))
++ return 1;
++
++ ltq_clrbits(&ltq_rcu_regs->req, val);
++
++ return 0;
++}
++
++enum ltq_boot_select ltq_boot_select(void)
++{
++ u32 stat;
++ unsigned int bootstrap;
++
++ /*
++ * Boot select value is built from bits 20-17 and bit 12.
++ * The bit sequence is read as 4-2-1-0-3.
++ */
++ stat = ltq_readl(&ltq_rcu_regs->stat);
++ bootstrap = ((stat & LTQ_RCU_STAT_BOOT_H) << 4) |
++ ((stat & LTQ_RCU_STAT_BOOT_MASK) >> LTQ_RCU_STAT_BOOT_SHIFT);
++
++ switch (bootstrap) {
++ case 0:
++ return BOOT_NOR_NO_BOOTROM;
++ case 1:
++ return BOOT_RGMII1;
++ case 2:
++ return BOOT_NOR;
++ case 4:
++ return BOOT_UART_NO_EEPROM;
++ case 6:
++ return BOOT_PCI;
++ case 8:
++ return BOOT_UART;
++ case 10:
++ return BOOT_SPI;
++ case 12:
++ return BOOT_NAND;
++ default:
++ return BOOT_UNKNOWN;
++ }
++}
++
++void ltq_rcu_gphy_boot(unsigned int id, ulong addr)
++{
++ u32 module;
++ void *gfs_add;
++
++ switch (id) {
++ case 0:
++ module = LTQ_RCU_RD_GPHY0;
++ gfs_add = &ltq_rcu_regs->gfs_add0;
++ break;
++ case 1:
++ module = LTQ_RCU_RD_GPHY1;
++ gfs_add = &ltq_rcu_regs->gfs_add1;
++ break;
++ default:
++ BUG();
++ }
++
++ /* Stop and reset GPHY */
++ ltq_setbits(&ltq_rcu_regs->req, module);
++
++ /* Configure firmware and boot address */
++ ltq_writel(gfs_add, CPHYSADDR(addr & 0xFFFFC000));
++
++ /* Start GPHY by releasing reset */
++ ltq_clrbits(&ltq_rcu_regs->req, module);
++}
+--- /dev/null
++++ b/arch/mips/cpu/mips32/vrx200/u-boot.lds
+@@ -0,0 +1,69 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2003 Wolfgang Denk, DENX Software Engineering, wd@denx.de
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradlittlemips")
++OUTPUT_ARCH(mips)
++ENTRY(_start)
++SECTIONS
++{
++ . = 0x00000000;
++
++ . = ALIGN(4);
++ .text : {
++ *(.text*)
++ }
++
++ . = ALIGN(4);
++ .rodata : {
++ *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*)))
++ }
++
++ . = ALIGN(4);
++ .data : {
++ *(.data*)
++ }
++
++ . = ALIGN(4);
++ .sdata : {
++ *(.sdata*)
++ }
++
++ . = .;
++ _gp = ALIGN(16) + 0x7ff0;
++
++ .got : {
++ __got_start = .;
++ *(.got)
++ __got_end = .;
++ }
++
++ num_got_entries = (__got_end - __got_start) >> 2;
++
++#ifndef CONFIG_SPL_BUILD
++ . = ALIGN(4);
++ .u_boot_list : {
++ #include <u-boot.lst>
++ }
++#endif
++
++ . = ALIGN(4);
++ __image_copy_end = .;
++ uboot_end_data = .;
++
++ .bss (NOLOAD) : {
++ __bss_start = .;
++ *(.bss*)
++ *(.sbss*)
++ . = ALIGN(4);
++ __bss_end = .;
++ }
++
++ . = ALIGN(4);
++ __end = .;
++ uboot_end = .;
++}
+--- /dev/null
++++ b/arch/mips/include/asm/arch-danube/config.h
+@@ -0,0 +1,156 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2007-2010 Lantiq Deutschland GmbH
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ *
++ * Common board configuration for Lantiq XWAY Danube family
++ *
++ * Use following defines in your board config to enable specific features
++ * and drivers for this SoC:
++ *
++ * CONFIG_LTQ_SUPPORT_UART
++ * - support the Danube ASC/UART interface and console
++ *
++ * CONFIG_LTQ_SUPPORT_NOR_FLASH
++ * - support a parallel NOR flash via the CFI interface in flash bank 0
++ *
++ * CONFIG_LTQ_SUPPORT_ETHERNET
++ * - support the Danube ETOP and MAC interface
++ *
++ * CONFIG_LTQ_SUPPORT_SPI_FLASH
++ * - support the Danube SPI interface and serial flash drivers
++ * - specific SPI flash drivers must be configured separately
++ */
++
++#ifndef __DANUBE_CONFIG_H__
++#define __DANUBE_CONFIG_H__
++
++/* CPU and SoC type */
++#define CONFIG_SOC_LANTIQ
++#define CONFIG_SOC_XWAY_DANUBE
++
++/* Cache configuration */
++#define CONFIG_SYS_MIPS_CACHE_MODE CONF_CM_CACHABLE_NONCOHERENT
++#define CONFIG_SYS_DCACHE_SIZE (16 * 1024)
++#define CONFIG_SYS_ICACHE_SIZE (16 * 1024)
++#define CONFIG_SYS_CACHELINE_SIZE 32
++#define CONFIG_SYS_MIPS_CACHE_EXT_INIT
++
++/*
++ * Supported clock modes
++ * PLL0 clock output is 333 MHz
++ * PLL1 clock output is 262.144 MHz
++ */
++#define LTQ_CLK_CPU_333_DDR_167 0 /* Base PLL0, OCP 2 */
++#define LTQ_CLK_CPU_111_DDR_111 1 /* Base PLL0, OCP 1 */
++
++/* CPU speed */
++#define CONFIG_SYS_CLOCK_MODE LTQ_CLK_CPU_333_DDR_167
++#define CONFIG_SYS_MIPS_TIMER_FREQ 166666667
++#define CONFIG_SYS_HZ 1000
++
++/* RAM */
++#define CONFIG_NR_DRAM_BANKS 1
++#define CONFIG_SYS_SDRAM_BASE 0x80000000
++#define CONFIG_SYS_MEMTEST_START 0x81000000
++#define CONFIG_SYS_MEMTEST_END 0x82000000
++#define CONFIG_SYS_LOAD_ADDR 0x81000000
++#define CONFIG_SYS_INIT_SP_OFFSET 0x4000
++
++/* SRAM */
++#define CONFIG_SYS_SRAM_BASE 0xBE180000
++#define CONFIG_SYS_SRAM_SIZE 0x10000
++
++/* ASC/UART driver and console */
++#define CONFIG_LANTIQ_SERIAL
++#define CONFIG_SYS_BAUDRATE_TABLE { 9600, 19200, 38400, 57600, 115200 }
++
++/* GPIO */
++#define CONFIG_LANTIQ_GPIO
++#define CONFIG_LTQ_GPIO_MAX_BANKS 2
++
++/* FLASH driver */
++#if defined(CONFIG_LTQ_SUPPORT_NOR_FLASH)
++#define CONFIG_SYS_MAX_FLASH_BANKS 1
++#define CONFIG_SYS_MAX_FLASH_SECT 256
++#define CONFIG_SYS_FLASH_BASE 0xB0000000
++#define CONFIG_FLASH_16BIT
++#define CONFIG_SYS_FLASH_CFI
++#define CONFIG_FLASH_CFI_DRIVER
++#define CONFIG_SYS_FLASH_CFI_WIDTH FLASH_CFI_16BIT
++#define CONFIG_SYS_FLASH_USE_BUFFER_WRITE
++#define CONFIG_FLASH_SHOW_PROGRESS 50
++#define CONFIG_SYS_FLASH_PROTECTION
++#define CONFIG_CFI_FLASH_USE_WEAK_ADDR_SWAP
++
++#define CONFIG_CMD_FLASH
++#else
++#define CONFIG_SYS_NO_FLASH
++#endif /* CONFIG_NOR_FLASH */
++
++#if defined(CONFIG_LTQ_SUPPORT_SPI_FLASH)
++#define CONFIG_LANTIQ_SPI
++#define CONFIG_SPI_FLASH
++
++#define CONFIG_CMD_SF
++#define CONFIG_CMD_SPI
++#endif
++
++#if defined(CONFIG_LTQ_SUPPORT_ETHERNET)
++#define CONFIG_LANTIQ_DMA
++#define CONFIG_LANTIQ_DANUBE_ETOP
++
++#define CONFIG_PHYLIB
++#define CONFIG_MII
++
++#define CONFIG_CMD_MII
++#define CONFIG_CMD_NET
++#endif
++
++#define CONFIG_SPL_MAX_SIZE (32 * 1024)
++#define CONFIG_SPL_BSS_MAX_SIZE (8 * 1024)
++#define CONFIG_SPL_STACK_MAX_SIZE (8 * 1024)
++#define CONFIG_SPL_MALLOC_MAX_SIZE (32 * 1024)
++/*#define CONFIG_SPL_STACK_BSS_IN_SRAM*/
++
++#if defined(CONFIG_SPL_STACK_BSS_IN_SRAM)
++#define CONFIG_SPL_STACK_BASE (CONFIG_SYS_SRAM_BASE + \
++ CONFIG_SPL_MAX_SIZE + \
++ CONFIG_SPL_STACK_MAX_SIZE - 1)
++#define CONFIG_SPL_BSS_BASE (CONFIG_SPL_STACK_BASE + 1)
++#define CONFIG_SPL_MALLOC_BASE (CONFIG_SYS_SDRAM_BASE + \
++ CONFIG_SYS_INIT_SP_OFFSET)
++#else
++#define CONFIG_SPL_STACK_BASE (CONFIG_SYS_SDRAM_BASE + \
++ CONFIG_SYS_INIT_SP_OFFSET + \
++ CONFIG_SPL_STACK_MAX_SIZE - 1)
++#define CONFIG_SPL_BSS_BASE (CONFIG_SPL_STACK_BASE + 1)
++#define CONFIG_SPL_MALLOC_BASE (CONFIG_SPL_BSS_BASE + \
++ CONFIG_SPL_BSS_MAX_SIZE)
++#endif
++
++#if defined(CONFIG_SYS_BOOT_RAM)
++#define CONFIG_SYS_TEXT_BASE 0xa0100000
++#define CONFIG_SKIP_LOWLEVEL_INIT
++#define CONFIG_SYS_DISABLE_CACHE
++#endif
++
++#if defined(CONFIG_SYS_BOOT_NOR)
++#define CONFIG_SYS_TEXT_BASE 0xB0000000
++#endif
++
++#if defined(CONFIG_SYS_BOOT_NORSPL)
++#define CONFIG_SYS_TEXT_BASE 0x80100000
++#define CONFIG_SPL_TEXT_BASE 0xB0000000
++#endif
++
++#if defined(CONFIG_SYS_BOOT_NOR) || defined(CONFIG_SYS_BOOT_NORSPL)
++#define CONFIG_SYS_XWAY_EBU_BOOTCFG 0x688C688C
++#define CONFIG_XWAY_SWAP_BYTES
++#endif
++
++#define CONFIG_SYS_MONITOR_BASE CONFIG_SYS_TEXT_BASE
++
++#endif /* __DANUBE_CONFIG_H__ */
+--- /dev/null
++++ b/arch/mips/include/asm/arch-danube/gpio.h
+@@ -0,0 +1,13 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#ifndef __DANUBE_GPIO_H__
++#define __DANUBE_GPIO_H__
++
++#include <asm/lantiq/gpio.h>
++
++#endif /* __DANUBE_GPIO_H__ */
+--- /dev/null
++++ b/arch/mips/include/asm/arch-danube/soc.h
+@@ -0,0 +1,40 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2007-2010 Lantiq Deutschland GmbH
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#ifndef __DANUBE_SOC_H__
++#define __DANUBE_SOC_H__
++
++#define LTQ_ASC0_BASE 0x1E100400
++#define LTQ_SPI_BASE 0x1E100800
++#define LTQ_GPIO_BASE 0x1E100B00
++#define LTQ_SSIO_BASE 0x1E100BB0
++#define LTQ_ASC1_BASE 0x1E100C00
++#define LTQ_DMA_BASE 0x1E104100
++
++#define LTQ_EBU_BASE 0x1E105300
++#define LTQ_EBU_REGION0_BASE 0x10000000
++#define LTQ_EBU_REGION0_SIZE (64 * 1024 * 1024)
++#define LTQ_EBU_REGION1_BASE 0x14000000
++#define LTQ_EBU_REGION1_SIZE (32 * 1024 * 1024)
++
++#define LTQ_PPE_BASE 0x1E180000
++#define LTQ_PPE_ETOP_BASE (LTQ_PPE_BASE + 0x11800)
++#define LTQ_PPE_ENET0_BASE (LTQ_PPE_BASE + 0x11840)
++
++#define LTQ_PMU_BASE 0x1F102000
++#define LTQ_CGU_BASE 0x1F103000
++#define LTQ_MPS_BASE 0x1F107000
++#define LTQ_CHIPID_BASE (LTQ_MPS_BASE + 0x340)
++#define LTQ_RCU_BASE 0x1F203000
++
++#define LTQ_MC_GEN_BASE 0x1F800000
++#define LTQ_MC_SDR_BASE 0x1F800200
++#define LTQ_MC_DDR_BASE 0x1F801000
++#define LTQ_MC_DDR_DC_OFFSET(x) (x * 0x10)
++
++#endif /* __DANUBE_SOC_H__ */
+--- /dev/null
++++ b/arch/mips/include/asm/arch-vrx200/config.h
+@@ -0,0 +1,185 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2010 Lantiq Deutschland GmbH
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ *
++ * Common board configuration for Lantiq XWAY VRX200 family
++ *
++ * Use following defines in your board config to enable specific features
++ * and drivers for this SoC:
++ *
++ * CONFIG_LTQ_SUPPORT_UART
++ * - support the VRX200 ASC/UART interface and console
++ *
++ * CONFIG_LTQ_SUPPORT_NOR_FLASH
++ * - support a parallel NOR flash via the CFI interface in flash bank 0
++ *
++ * CONFIG_LTQ_SUPPORT_SPI_FLASH
++ * - support the VRX200 SPI interface and serial flash drivers
++ * - specific SPI flash drivers must be configured separately
++ *
++ * CONFIG_LTQ_SUPPORT_ETHERNET
++ * - support the VRX200 internal switch
++ *
++ * CONFIG_LTQ_SUPPORT_SPL_SPI_FLASH
++ * - build a preloader that runs in the internal SRAM and loads
++ * the U-Boot from SPI flash into RAM
++ */
++
++#ifndef __VRX200_CONFIG_H__
++#define __VRX200_CONFIG_H__
++
++/* CPU and SoC type */
++#define CONFIG_SOC_LANTIQ
++#define CONFIG_SOC_XWAY_VRX200
++
++/* Cache configuration */
++#define CONFIG_SYS_MIPS_CACHE_MODE CONF_CM_CACHABLE_NONCOHERENT
++#define CONFIG_SYS_DCACHE_SIZE (32 * 1024)
++#define CONFIG_SYS_ICACHE_SIZE (32 * 1024)
++#define CONFIG_SYS_CACHELINE_SIZE 32
++#define CONFIG_SYS_MIPS_CACHE_EXT_INIT
++
++/*
++ * Supported clock modes
++ * PLL0 clock output is 1000 MHz
++ * PLL1 clock output is 393.219 MHz
++ */
++#define LTQ_CLK_CPU_600_DDR_300 0 /* Base PLL0, OCP 2 */
++#define LTQ_CLK_CPU_600_DDR_200 1 /* Base PLL0, OCP 3 */
++#define LTQ_CLK_CPU_500_DDR_250 2 /* Base PLL0, OCP 2 */
++#define LTQ_CLK_CPU_500_DDR_200 3 /* Base PLL0, OCP 2.5 */
++#define LTQ_CLK_CPU_333_DDR_167 4 /* Base PLL0, OCP 2 */
++#define LTQ_CLK_CPU_167_DDR_167 5 /* Base PLL0, OCP 1 */
++#define LTQ_CLK_CPU_125_DDR_125 6 /* Base PLL0, OCP 1 */
++#define LTQ_CLK_CPU_393_DDR_197 7 /* Base PLL1, OCP 2 */
++#define LTQ_CLK_CPU_197_DDR_197 8 /* Base PLL1, OCP 1 */
++
++/* CPU speed */
++#define CONFIG_SYS_CLOCK_MODE LTQ_CLK_CPU_500_DDR_250
++#define CONFIG_SYS_MIPS_TIMER_FREQ 250000000
++#define CONFIG_SYS_HZ 1000
++
++/* RAM */
++#define CONFIG_NR_DRAM_BANKS 1
++#define CONFIG_SYS_SDRAM_BASE 0x80000000
++#define CONFIG_SYS_SDRAM_BASE_UC 0xa0000000
++#define CONFIG_SYS_MEMTEST_START 0x81000000
++#define CONFIG_SYS_MEMTEST_END 0x82000000
++#define CONFIG_SYS_LOAD_ADDR 0x81000000
++#define CONFIG_SYS_INIT_SP_OFFSET (32 * 1024)
++
++/* SRAM */
++#define CONFIG_SYS_SRAM_BASE 0xBE220000
++#define CONFIG_SYS_SRAM_SIZE 0x10000
++
++/* ASC/UART driver and console */
++#define CONFIG_LANTIQ_SERIAL
++#define CONFIG_SYS_BAUDRATE_TABLE { 9600, 19200, 38400, 57600, 115200 }
++
++/* GPIO */
++#define CONFIG_LANTIQ_GPIO
++#define CONFIG_LTQ_GPIO_MAX_BANKS 3
++#define CONFIG_LTQ_HAS_GPIO_BANK3
++
++/* FLASH driver */
++#if defined(CONFIG_LTQ_SUPPORT_NOR_FLASH)
++#define CONFIG_SYS_MAX_FLASH_BANKS 1
++#define CONFIG_SYS_MAX_FLASH_SECT 256
++#define CONFIG_SYS_FLASH_BASE 0xB0000000
++#define CONFIG_FLASH_16BIT
++#define CONFIG_SYS_FLASH_CFI
++#define CONFIG_FLASH_CFI_DRIVER
++#define CONFIG_SYS_FLASH_CFI_WIDTH FLASH_CFI_16BIT
++#define CONFIG_SYS_FLASH_USE_BUFFER_WRITE
++#define CONFIG_FLASH_SHOW_PROGRESS 50
++#define CONFIG_SYS_FLASH_PROTECTION
++#define CONFIG_CFI_FLASH_USE_WEAK_ADDR_SWAP
++
++#define CONFIG_CMD_FLASH
++#else
++#define CONFIG_SYS_NO_FLASH
++#endif /* CONFIG_NOR_FLASH */
++
++#if defined(CONFIG_LTQ_SUPPORT_SPI_FLASH)
++#define CONFIG_LANTIQ_SPI
++#define CONFIG_SPI_FLASH
++
++#define CONFIG_CMD_SF
++#define CONFIG_CMD_SPI
++#endif
++
++#if defined(CONFIG_LTQ_SUPPORT_NAND_FLASH)
++#define CONFIG_NAND_LANTIQ
++#define CONFIG_SYS_MAX_NAND_DEVICE 1
++#define CONFIG_SYS_NAND_BASE 0xB4000000
++
++#define CONFIG_CMD_NAND
++#endif
++
++#if defined(CONFIG_LTQ_SUPPORT_ETHERNET)
++#define CONFIG_LANTIQ_DMA
++#define CONFIG_LANTIQ_VRX200_SWITCH
++#define CONFIG_PHY_LANTIQ
++
++#define CONFIG_SYS_RX_ETH_BUFFER 8
++#define CONFIG_PHYLIB
++#define CONFIG_MII
++#define CONFIG_UDP_CHECKSUM
++
++#define CONFIG_CMD_MII
++#define CONFIG_CMD_NET
++#endif
++
++#define CONFIG_SPL_MAX_SIZE (32 * 1024)
++#define CONFIG_SPL_BSS_MAX_SIZE (8 * 1024)
++#define CONFIG_SPL_STACK_MAX_SIZE (8 * 1024)
++#define CONFIG_SPL_MALLOC_MAX_SIZE (32 * 1024)
++#define CONFIG_SPL_STACK_BSS_IN_SRAM
++
++#if defined(CONFIG_SPL_STACK_BSS_IN_SRAM)
++#define CONFIG_SPL_STACK_BASE (CONFIG_SYS_SRAM_BASE + \
++ CONFIG_SPL_MAX_SIZE + \
++ CONFIG_SPL_STACK_MAX_SIZE - 1)
++#define CONFIG_SPL_BSS_BASE (CONFIG_SPL_STACK_BASE + 1)
++#define CONFIG_SPL_MALLOC_BASE (CONFIG_SYS_SDRAM_BASE + \
++ CONFIG_SYS_INIT_SP_OFFSET)
++#else
++#define CONFIG_SPL_STACK_BASE (CONFIG_SYS_SDRAM_BASE + \
++ CONFIG_SYS_INIT_SP_OFFSET + \
++ CONFIG_SPL_STACK_MAX_SIZE - 1)
++#define CONFIG_SPL_BSS_BASE (CONFIG_SPL_STACK_BASE + 1)
++#define CONFIG_SPL_MALLOC_BASE (CONFIG_SPL_BSS_BASE + \
++ CONFIG_SPL_BSS_MAX_SIZE)
++#endif
++
++#if defined(CONFIG_SYS_BOOT_RAM)
++#define CONFIG_SYS_TEXT_BASE 0xA0100000
++#define CONFIG_SKIP_LOWLEVEL_INIT
++#define CONFIG_SYS_DISABLE_CACHE
++#endif
++
++#if defined(CONFIG_SYS_BOOT_NOR)
++#define CONFIG_SYS_TEXT_BASE 0xB0000000
++#endif
++
++#if defined(CONFIG_SYS_BOOT_SFSPL)
++#define CONFIG_SYS_TEXT_BASE 0x80100000
++#define CONFIG_SPL_TEXT_BASE 0xBE220000
++#endif
++
++#if defined(CONFIG_SYS_BOOT_NORSPL)
++#define CONFIG_SYS_TEXT_BASE 0x80100000
++#define CONFIG_SPL_TEXT_BASE 0xB0000000
++#endif
++
++#if defined(CONFIG_SYS_BOOT_NOR) || defined(CONFIG_SYS_BOOT_NORSPL)
++#define CONFIG_SYS_XWAY_EBU_BOOTCFG 0x688C688C
++#define CONFIG_XWAY_SWAP_BYTES
++#endif
++
++#define CONFIG_SYS_MONITOR_BASE CONFIG_SYS_TEXT_BASE
++
++#endif /* __VRX200_CONFIG_H__ */
+--- /dev/null
++++ b/arch/mips/include/asm/arch-vrx200/gphy.h
+@@ -0,0 +1,66 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#ifndef __VRX200_GPHY_H__
++#define __VRX200_GPHY_H__
++
++enum ltq_gphy_clk {
++ /* XTAL 36 MHz input */
++ LTQ_GPHY_CLK_36MHZ_XTAL = 1,
++ /* 25 MHz from PLL0 with divider */
++ LTQ_GPHY_CLK_25MHZ_PLL0 = 2,
++ /* derived from PLL2 output (XTAL is 36 MHz) */
++ LTQ_GPHY_CLK_24MHZ_PLL2 = 3,
++ /* 25 MHz Clock from Pin GPIO3 */
++ LTQ_GPHY_CLK_25MHZ_GPIO3 = 4,
++};
++
++/*
++ * Load PHY11G firmware for VRX200 v1.1 to given RAM address
++ *
++ * Address must be 16k aligned!
++ */
++extern void ltq_gphy_phy11g_a1x_load(ulong addr);
++
++/*
++ * Load PHY11G firmware for VRX200 v1.2 to given RAM address
++ *
++ * Address must be 16k aligned!
++ */
++extern void ltq_gphy_phy11g_a2x_load(ulong addr);
++
++/*
++ * Load PHY22F firmware for VRX200 v1.1 to given RAM address
++ *
++ * Address must be 16k aligned!
++ */
++extern void ltq_gphy_phy22f_a1x_load(ulong addr);
++
++/*
++ * Load PHY22F firmware for VRX200 v1.2 to given RAM address
++ *
++ * Address must be 16k aligned!
++ */
++extern void ltq_gphy_phy22f_a2x_load(ulong addr);
++
++/*
++ * Set clock source of internal GPHYs
++ *
++ * According registers resides in CGU address space. Thus this function
++ * is implemented by the CGU driver.
++ */
++extern void ltq_cgu_gphy_clk_src(enum ltq_gphy_clk clk);
++
++/*
++ * Boot internal GPHY with id from given RAM address
++ *
++ * According registers resides in RCU address space. Thus this function
++ * is implemented by the RCU driver.
++ */
++extern void ltq_rcu_gphy_boot(unsigned int id, ulong addr);
++
++#endif /* __VRX200_GPHY_H__ */
+--- /dev/null
++++ b/arch/mips/include/asm/arch-vrx200/gpio.h
+@@ -0,0 +1,13 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#ifndef __VRX200_GPIO_H__
++#define __VRX200_GPIO_H__
++
++#include <asm/lantiq/gpio.h>
++
++#endif /* __VRX200_GPIO_H__ */
+--- /dev/null
++++ b/arch/mips/include/asm/arch-vrx200/nand.h
+@@ -0,0 +1,14 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2012 Daniel Schwierzeck, daniel.schwierzeck@gmail.com
++ */
++
++#ifndef __VRX200_NAND_H__
++#define __VRX200_NAND_H__
++
++struct nand_chip;
++int ltq_nand_init(struct nand_chip *nand);
++
++#endif /* __VRX200_NAND_H__ */
+--- /dev/null
++++ b/arch/mips/include/asm/arch-vrx200/soc.h
+@@ -0,0 +1,46 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2010 Lantiq Deutschland GmbH
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#ifndef __VRX200_SOC_H__
++#define __VRX200_SOC_H__
++
++#define LTQ_ASC0_BASE 0x1E100400
++#define LTQ_SPI_BASE 0x1E100800
++#define LTQ_GPIO_BASE 0x1E100B00
++#define LTQ_SSIO_BASE 0x1E100BB0
++#define LTQ_ASC1_BASE 0x1E100C00
++#define LTQ_DMA_BASE 0x1E104100
++
++#define LTQ_EBU_BASE 0x1E105300
++#define LTQ_EBU_REGION0_BASE 0x10000000
++#define LTQ_EBU_REGION1_BASE 0x14000000
++#define LTQ_EBU_NAND_BASE (LTQ_EBU_BASE + 0xB0)
++
++#define LTQ_SWITCH_BASE 0x1E108000
++#define LTQ_SWITCH_CORE_BASE LTQ_SWITCH_BASE
++#define LTQ_SWITCH_TOP_PDI_BASE LTQ_SWITCH_CORE_BASE
++#define LTQ_SWITCH_BM_PDI_BASE (LTQ_SWITCH_CORE_BASE + 4 * 0x40)
++#define LTQ_SWITCH_MAC_PDI_0_BASE (LTQ_SWITCH_CORE_BASE + 4 * 0x900)
++#define LTQ_SWITCH_MAC_PDI_X_BASE(x) (LTQ_SWITCH_MAC_PDI_0_BASE + x * 0x30)
++#define LTQ_SWITCH_TOPLEVEL_BASE (LTQ_SWITCH_BASE + 4 * 0xC40)
++#define LTQ_SWITCH_MDIO_PDI_BASE (LTQ_SWITCH_TOPLEVEL_BASE)
++#define LTQ_SWITCH_MII_PDI_BASE (LTQ_SWITCH_TOPLEVEL_BASE + 4 * 0x36)
++#define LTQ_SWITCH_PMAC_PDI_BASE (LTQ_SWITCH_TOPLEVEL_BASE + 4 * 0x82)
++
++#define LTQ_PMU_BASE 0x1F102000
++#define LTQ_CGU_BASE 0x1F103000
++#define LTQ_DCDC_BASE 0x1F106A00
++#define LTQ_MPS_BASE 0x1F107000
++#define LTQ_CHIPID_BASE (LTQ_MPS_BASE + 0x340)
++#define LTQ_RCU_BASE 0x1F203000
++
++#define LTQ_MC_GLOBAL_BASE 0x1F400000
++#define LTQ_MC_DDR_BASE 0x1F401000
++#define LTQ_MC_DDR_CCR_OFFSET(x) (x * 0x10)
++
++#endif /* __VRX200_SOC_H__ */
+--- /dev/null
++++ b/arch/mips/include/asm/arch-vrx200/switch.h
+@@ -0,0 +1,514 @@
++/*
++ * 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 of the License, 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; if not, write to the Free Software
++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
++ *
++ * Copyright (C) 2012 Daniel Schwierzeck <daniel.schwierzeck@googlemail.com>
++ */
++
++#ifndef __VR9_SWITCH_H__
++#define __VR9_SWITCH_H__
++
++/* Switch core registers */
++struct vr9_switch_core_regs {
++ __be32 swres;
++ /* TODO: implement registers */
++ __be32 rsvd0[0x3f];
++};
++
++/* Switch buffer management registers */
++struct vr9_switch_bm_regs {
++ struct bm_core {
++ __be32 ram_val3; /* RAM value 3 */
++ __be32 ram_val2; /* RAM value 2 */
++ __be32 ram_val1; /* RAM value 1 */
++ __be32 ram_val0; /* RAM value 0 */
++ __be32 ram_addr; /* RAM address */
++ __be32 ram_ctrl; /* RAM access control */
++ __be32 fsqm_gctrl; /* Free segment queue global control */
++ __be32 cons_sel; /* Number of consumed segments */
++ __be32 cons_pkt; /* Number of consumed packet pointers */
++ __be32 gctrl; /* Global control */
++ __be32 queue_gctrl; /* Queue manager global control */
++ /* TODO: implement registers */
++ __be32 rsvd0[0x35];
++ } core;
++
++ struct bm_port {
++ __be32 pcfg; /* Port config */
++ __be32 rmon_ctrl; /* RMON control */
++ } port[13];
++
++ __be32 rsvd0[0x66];
++
++ struct bm_queue {
++ __be32 rsvd0;
++ __be32 pqm_rs; /* Packet queue manager rate shape assignment */
++ } queue[32];
++
++ struct bm_shaper {
++ __be32 ctrl; /* Rate shaper control */
++ __be32 cbs; /* Rate shaper committed burst size */
++ __be32 ibs; /* Rate shaper instantaneous burst size */
++ __be32 cir_ext; /* Rate shaper rate exponent */
++ __be32 cir_mant; /* Rate shaper rate mantissa */
++ } shaper[16];
++
++ __be32 rsvd1[0x2a8];
++};
++
++/* Switch parser and classification engine registers */
++struct vr9_switch_pce_regs {
++ struct pce_core {
++ __be32 tbl_key[16]; /* Table key data */
++ __be32 tbl_mask; /* Table mask */
++ __be32 tbl_val[5]; /* Table value */
++ __be32 tbl_addr; /* Table entry address */
++ __be32 tbl_ctrl; /* Table access control */
++ __be32 tbl_stat; /* Table general status */
++ __be32 age_0; /* Aging counter config 0 */
++ __be32 age_1; /* Aging counter config 1 */
++ __be32 pmap_1; /* Port map (monitoring) */
++ __be32 pmap_2; /* Port map (multicast) */
++ __be32 pmap_3; /* Port map (unknown unicast) */
++ __be32 gctrl_0; /* Global control 0 */
++ __be32 gctrl_1; /* Global control 1 */
++ __be32 tcm_gctrl; /* Three-color marker global control */
++ __be32 igmp_ctrl; /* IGMP control */
++ __be32 igmp_drpm; /* IGMP default router port map */
++ __be32 igmp_age_0; /* IGMP aging 0 */
++ __be32 igmp_age_1; /* IGMP aging 1 */
++ __be32 igmp_stat; /* IGMP status */
++ __be32 wol_gctrl; /* Wake-on-LAN control */
++ __be32 wol_da_0; /* Wake-on-LAN destination address 0 */
++ __be32 wol_da_1; /* Wake-on-LAN destination address 1 */
++ __be32 wol_da_2; /* Wake-on-LAN destination address 2 */
++ __be32 wol_pw_0; /* Wake-on-LAN password 0 */
++ __be32 wol_pw_1; /* Wake-on-LAN password 1 */
++ __be32 wol_pw_2; /* Wake-on-LAN password 2 */
++ __be32 ier_0; /* PCE global interrupt enable 0 */
++ __be32 ier_1; /* PCE global interrupt enable 1 */
++ __be32 isr_0; /* PCE global interrupt status 0 */
++ __be32 isr_1; /* PCE global interrupt status 1 */
++ __be32 parser_stat; /* Parser status */
++ __be32 rsvd0[0x6];
++ } core;
++
++ __be32 rsvd0[0x10];
++
++ struct pce_port {
++ __be32 pctrl_0; /* Port control 0 */
++ __be32 pctrl_1; /* Port control 1 */
++ __be32 pctrl_2; /* Port control 2 */
++ __be32 pctrl_3; /* Port control 3 */
++ __be32 wol_ctrl; /* Wake-on-LAN control */
++ __be32 vlan_ctrl; /* VLAN control */
++ __be32 def_pvid; /* Default port VID */
++ __be32 pstat; /* Port status */
++ __be32 pier; /* Interrupt enable */
++ __be32 pisr; /* Interrupt status */
++ } port[13];
++
++ __be32 rsvd1[0x7e];
++
++ struct pce_meter {
++ /* TODO: implement registers */
++ __be32 rsvd0[0x7];
++ } meter[8];
++
++ __be32 rsvd2[0x308];
++};
++
++static inline unsigned int to_pce_tbl_key_id(unsigned int id)
++{
++ BUG_ON(id > 15);
++
++ return 15 - id;
++}
++
++static inline unsigned int to_pce_tbl_value_id(unsigned int id)
++{
++ BUG_ON(id > 4);
++
++ return 4 - id;
++}
++
++/* Switch ethernet MAC registers */
++struct vr9_switch_mac_regs {
++ struct mac_core {
++ __be32 test; /* MAC test */
++ __be32 pfad_cfg; /* Pause frame source address config */
++ __be32 pfsa_0; /* Pause frame source address 0 */
++ __be32 pfsa_1; /* Pause frame source address 1 */
++ __be32 pfsa_2; /* Pause frame source address 2 */
++ __be32 flen; /* Frame length */
++ __be32 vlan_etype_0; /* VLAN ethertype 0 */
++ __be32 vlan_etype_1; /* VLAN ethertype 1 */
++ __be32 ier; /* Interrupt enable */
++ __be32 isr; /* Interrupt status */
++ __be32 rsvd0[0x36];
++ } core;
++
++ struct mac_port {
++ __be32 pstat; /* Port status */
++ __be32 pisr; /* Interrupt status */
++ __be32 pier; /* Interrupt enable */
++ __be32 ctrl_0; /* Control 0 */
++ __be32 ctrl_1; /* Control 1 */
++ __be32 ctrl_2; /* Control 2 */
++ __be32 ctrl_3; /* Control 3 */
++ __be32 ctrl_4; /* Control 4 */
++ __be32 ctrl_5; /* Control 5 */
++ __be32 rsvd0[0x2];
++ __be32 testen; /* Test enable */
++ } port[13];
++
++ __be32 rsvd0[0xa4];
++};
++
++/* Switch Fetch DMA registers */
++struct vr9_switch_fdma_regs {
++ struct fdma_core {
++ __be32 ctrl; /* FDMA control */
++ __be32 stetype; /* Special tag ethertype control */
++ __be32 vtetype; /* VLAN tag ethertype control */
++ __be32 stat; /* FDMA status */
++ __be32 ier; /* FDMA interrupt enable */
++ __be32 isr; /* FDMA interrupt status */
++ } core;
++
++ __be32 rsvd0[0x3a];
++
++ struct fdma_port {
++ __be32 pctrl; /* Port control */
++ __be32 prio; /* Port priority */
++ __be32 pstat_0; /* Port status 0 */
++ __be32 pstat_1; /* Port status 1 */
++ __be32 tstamp_0; /* Egress time stamp 0 */
++ __be32 tstamp_1; /* Egress time stamp 1 */
++ } port[13];
++
++ __be32 rsvd1[0x72];
++};
++
++/* Switch Store DMA registers */
++struct vr9_switch_sdma_regs {
++ struct sdma_core {
++ __be32 ctrl; /* SDMA Control */
++ __be32 fcthr_1; /* Flow control threshold 1 */
++ __be32 rsvd0;
++ __be32 fcthr_3; /* Flow control threshold 3 */
++ __be32 fcthr_4; /* Flow control threshold 4 */
++ __be32 fcthr_5; /* Flow control threshold 5 */
++ __be32 fcthr_6; /* Flow control threshold 6 */
++ __be32 fcthr_7; /* Flow control threshold 7 */
++ __be32 stat_0; /* SDMA status 0 */
++ __be32 stat_1; /* SDMA status 1 */
++ __be32 stat_2; /* SDMA status 2 */
++ __be32 ier; /* SDMA interrupt enable */
++ __be32 isr; /* SDMA interrupt status */
++ } core;
++
++ __be32 rsvd0[0x73];
++
++ struct sdma_port {
++ __be32 pctrl; /* Port control */
++ __be32 prio; /* Port priority */
++ __be32 pstat_0; /* Port status 0 */
++ __be32 pstat_1; /* Port status 1 */
++ __be32 tstamp_0; /* Ingress time stamp 0 */
++ __be32 tstamp_1; /* Ingress time stamp 1 */
++ } port[13];
++
++ __be32 rsvd1[0x32];
++};
++
++/* Switch MDIO control and status registers */
++struct vr9_switch_mdio_regs {
++ __be32 glob_ctrl; /* Global control 0 */
++ __be32 rsvd0[7];
++ __be32 mdio_ctrl; /* MDIO control */
++ __be32 mdio_read; /* MDIO read data */
++ __be32 mdio_write; /* MDIO write data */
++ __be32 mdc_cfg_0; /* MDC clock configuration 0 */
++ __be32 mdc_cfg_1; /* MDC clock configuration 1 */
++ __be32 rsvd1[0x3];
++ __be32 phy_addr[6]; /* PHY address port 5..0 */
++ __be32 mdio_stat[6]; /* MDIO PHY polling status port 0..5 */
++ __be32 aneg_eee[6]; /* EEE auto-neg overrides port 0..5 */
++ __be32 rsvd2[0x14];
++};
++
++static inline unsigned int to_mdio_phyaddr_id(unsigned int id)
++{
++ BUG_ON(id > 5);
++
++ return 5 - id;
++}
++
++/* Switch xMII control registers */
++struct vr9_switch_mii_regs {
++ __be32 mii_cfg0; /* xMII port 0 configuration */
++ __be32 pcdu0; /* Port 0 clock delay configuration */
++ __be32 mii_cfg1; /* xMII port 1 configuration */
++ __be32 pcdu1; /* Port 1 clock delay configuration */
++ __be32 rsvd0[0x6];
++ __be32 mii_cfg5; /* xMII port 5 configuration */
++ __be32 pcdu5; /* Port 5 clock delay configuration */
++ __be32 rsvd1[0x14];
++ __be32 rxb_ctl_0; /* Port 0 receive buffer control */
++ __be32 rxb_ctl_1; /* Port 1 receive buffer control */
++ __be32 rxb_ctl_5; /* Port 5 receive buffer control */
++ __be32 rsvd2[0x28];
++ __be32 dbg_ctl; /* Debug control */
++};
++
++/* Switch Pseudo-MAC registers */
++struct vr9_switch_pmac_regs {
++ __be32 hd_ctl; /* PMAC header control */
++ __be32 tl; /* PMAC type/length */
++ __be32 sa1; /* PMAC source address 1 */
++ __be32 sa2; /* PMAC source address 2 */
++ __be32 sa3; /* PMAC source address 3 */
++ __be32 da1; /* PMAC destination address 1 */
++ __be32 da2; /* PMAC destination address 2 */
++ __be32 da3; /* PMAC destination address 3 */
++ __be32 vlan; /* PMAC VLAN */
++ __be32 rx_ipg; /* PMAC interpacket gap in RX direction */
++ __be32 st_etype; /* PMAC special tag ethertype */
++ __be32 ewan; /* PMAC ethernet WAN group */
++ __be32 ctl; /* PMAC control */
++ __be32 rsvd0[0x2];
++};
++
++struct vr9_switch_regs {
++ struct vr9_switch_core_regs core;
++ struct vr9_switch_bm_regs bm;
++ struct vr9_switch_pce_regs pce;
++ struct vr9_switch_mac_regs mac;
++ struct vr9_switch_fdma_regs fdma;
++ struct vr9_switch_sdma_regs sdma;
++ struct vr9_switch_mdio_regs mdio;
++ struct vr9_switch_mii_regs mii;
++ struct vr9_switch_pmac_regs pmac;
++};
++
++static inline void *to_pce_tbl_key(struct vr9_switch_regs *regs,
++ unsigned int id)
++{
++ return &regs->pce.core.tbl_key[to_pce_tbl_key_id(id)];
++}
++
++static inline void *to_pce_tbl_value(struct vr9_switch_regs *regs,
++ unsigned int id)
++{
++ return &regs->pce.core.tbl_val[to_pce_tbl_value_id(id)];
++}
++
++static inline void *to_mac_ctrl(struct vr9_switch_regs *regs,
++ unsigned int id, unsigned int ctrl)
++{
++ struct mac_port *mac = &regs->mac.port[id];
++
++ switch (ctrl) {
++ case 0:
++ return &mac->ctrl_0;
++ case 1:
++ return &mac->ctrl_1;
++ case 2:
++ return &mac->ctrl_2;
++ case 3:
++ return &mac->ctrl_3;
++ case 4:
++ return &mac->ctrl_4;
++ case 5:
++ return &mac->ctrl_5;
++ default:
++ return NULL;
++ }
++}
++
++static inline void *to_mdio_phyaddr(struct vr9_switch_regs *regs,
++ unsigned int id)
++{
++ return &regs->mdio.phy_addr[to_mdio_phyaddr_id(id)];
++}
++
++static inline void *to_mii_miicfg(struct vr9_switch_regs *regs,
++ unsigned int id)
++{
++ switch (id) {
++ case 0:
++ return &regs->mii.mii_cfg0;
++ case 1:
++ return &regs->mii.mii_cfg1;
++ case 5:
++ return &regs->mii.mii_cfg5;
++ default:
++ return NULL;
++ }
++}
++
++static inline void *to_mii_pcdu(struct vr9_switch_regs *regs,
++ unsigned int id)
++{
++ switch (id) {
++ case 0:
++ return &regs->mii.pcdu0;
++ case 1:
++ return &regs->mii.pcdu1;
++ case 5:
++ return &regs->mii.pcdu5;
++ default:
++ return NULL;
++ }
++}
++
++#define VR9_SWITCH_REG_OFFSET(reg) (4 * (reg))
++
++#define BUILD_CHECK_VR9_REG(name, offset) \
++ BUILD_BUG_ON(offsetof(struct vr9_switch_regs, name) != (4 * offset))
++
++static inline void build_check_vr9_registers(void)
++{
++ BUILD_CHECK_VR9_REG(core, 0x0);
++ BUILD_CHECK_VR9_REG(bm.core, 0x40);
++ BUILD_CHECK_VR9_REG(bm.core.queue_gctrl, 0x4a);
++ BUILD_CHECK_VR9_REG(bm.port[0], 0x80);
++ BUILD_CHECK_VR9_REG(bm.queue, 0x100);
++ BUILD_CHECK_VR9_REG(bm.shaper, 0x140);
++ BUILD_CHECK_VR9_REG(pce.core, 0x438);
++ BUILD_CHECK_VR9_REG(pce.core.tbl_ctrl, 0x44f);
++ BUILD_CHECK_VR9_REG(pce.core.parser_stat, 0x469);
++ BUILD_CHECK_VR9_REG(pce.port[0], 0x480);
++ BUILD_CHECK_VR9_REG(pce.meter[0], 0x580);
++ BUILD_CHECK_VR9_REG(mac.core, 0x8c0);
++ BUILD_CHECK_VR9_REG(mac.port[0].pstat, 0x900);
++ BUILD_CHECK_VR9_REG(mac.port[0].ctrl_0, 0x903);
++ BUILD_CHECK_VR9_REG(mac.port[1].pstat, 0x90c);
++ BUILD_CHECK_VR9_REG(mac.port[1].ctrl_0, 0x90f);
++ BUILD_CHECK_VR9_REG(mac.port[2].pstat, 0x918);
++ BUILD_CHECK_VR9_REG(mac.port[2].ctrl_0, 0x91b);
++ BUILD_CHECK_VR9_REG(fdma.core, 0xa40);
++ BUILD_CHECK_VR9_REG(fdma.port[0], 0xa80);
++ BUILD_CHECK_VR9_REG(sdma.core, 0xb40);
++ BUILD_CHECK_VR9_REG(sdma.port[0], 0xbc0);
++ BUILD_CHECK_VR9_REG(mdio, 0xc40);
++ BUILD_CHECK_VR9_REG(mii, (0xc40 + 0x36));
++ BUILD_CHECK_VR9_REG(pmac, (0xc40 + 0x82));
++}
++
++#define BM_GCTRL_F_SRES 1
++
++#define MAC_CTRL0_BM (1 << 12)
++#define MAC_CTRL0_APADEN (1 << 11)
++#define MAC_CTRL0_VPAD2EN (1 << 10)
++#define MAC_CTRL0_VPADEN (1 << 9)
++#define MAC_CTRL0_PADEN (1 << 8)
++#define MAC_CTRL0_FCS (1 << 7)
++#define MAC_CTRL0_FCON_SHIFT 4
++#define MAC_CTRL0_FCON_AUTO (0x0 << MAC_CTRL0_FCON_SHIFT)
++#define MAC_CTRL0_FCON_RX (0x1 << MAC_CTRL0_FCON_SHIFT)
++#define MAC_CTRL0_FCON_TX (0x2 << MAC_CTRL0_FCON_SHIFT)
++#define MAC_CTRL0_FCON_RXTX (0x3 << MAC_CTRL0_FCON_SHIFT)
++#define MAC_CTRL0_FCON_NONE (0x4 << MAC_CTRL0_FCON_SHIFT)
++#define MAC_CTRL0_FDUP_SHIFT 2
++#define MAC_CTRL0_FDUP_AUTO (0x0 << MAC_CTRL0_FDUP_SHIFT)
++#define MAC_CTRL0_FDUP_EN (0x1 << MAC_CTRL0_FDUP_SHIFT)
++#define MAC_CTRL0_FDUP_DIS (0x3 << MAC_CTRL0_FDUP_SHIFT)
++#define MAC_CTRL0_GMII_AUTO 0x0
++#define MAC_CTRL0_GMII_MII 0x1
++#define MAC_CTRL0_GMII_GMII 0x2
++#define MAC_CTRL0_GMII_GMII_2G 0x3
++
++#define MAC_CTRL1_DEFERMODE (1 << 15)
++#define MAC_CTRL1_SHORTPRE (1 << 8)
++
++#define MAC_CTRL2_MLEN (1 << 3)
++#define MAC_CTRL2_LCHKL (1 << 2)
++#define MAC_CTRL2_LCHKS_DIS 0x0
++#define MAC_CTRL2_LCHKS_UNTAG 0x1
++#define MAC_CTRL2_LCHKS_TAG 0x2
++
++#define PHY_ADDR_LNKST_SHIFT 13
++#define PHY_ADDR_LNKST_AUTO (0x0 << PHY_ADDR_LNKST_SHIFT)
++#define PHY_ADDR_LNKST_UP (0x1 << PHY_ADDR_LNKST_SHIFT)
++#define PHY_ADDR_LNKST_DOWN (0x2 << PHY_ADDR_LNKST_SHIFT)
++#define PHY_ADDR_SPEED_SHIFT 11
++#define PHY_ADDR_SPEED_M10 (0x0 << PHY_ADDR_SPEED_SHIFT)
++#define PHY_ADDR_SPEED_M100 (0x1 << PHY_ADDR_SPEED_SHIFT)
++#define PHY_ADDR_SPEED_G1 (0x2 << PHY_ADDR_SPEED_SHIFT)
++#define PHY_ADDR_SPEED_AUTO (0x3 << PHY_ADDR_SPEED_SHIFT)
++#define PHY_ADDR_FDUP_SHIFT 9
++#define PHY_ADDR_FDUP_AUTO (0x0 << PHY_ADDR_FDUP_SHIFT)
++#define PHY_ADDR_FDUP_EN (0x1 << PHY_ADDR_FDUP_SHIFT)
++#define PHY_ADDR_FDUP_DIS (0x3 << PHY_ADDR_FDUP_SHIFT)
++#define PHY_ADDR_FCONTX_SHIFT 7
++#define PHY_ADDR_FCONTX_AUTO (0x0 << PHY_ADDR_FCONTX_SHIFT)
++#define PHY_ADDR_FCONTX_EN (0x1 << PHY_ADDR_FCONTX_SHIFT)
++#define PHY_ADDR_FCONTX_DIS (0x3 << PHY_ADDR_FCONTX_SHIFT)
++#define PHY_ADDR_FCONRX_SHIFT 5
++#define PHY_ADDR_FCONRX_AUTO (0x0 << PHY_ADDR_FCONRX_SHIFT)
++#define PHY_ADDR_FCONRX_EN (0x1 << PHY_ADDR_FCONRX_SHIFT)
++#define PHY_ADDR_FCONRX_DIS (0x3 << PHY_ADDR_FCONRX_SHIFT)
++
++#define MII_CFG_RES (1 << 15)
++#define MII_CFG_EN (1 << 14)
++#define MII_CFG_LDCLKDIS (1 << 12)
++#define MII_CFG_MIIRATE_SHIFT 4
++#define MII_CFG_MIIRATE_MASK (0x7 << MII_CFG_MIIRATE_SHIFT)
++#define MII_CFG_MIIRATE_M2P5 (0x0 << MII_CFG_MIIRATE_SHIFT)
++#define MII_CFG_MIIRATE_M25 (0x1 << MII_CFG_MIIRATE_SHIFT)
++#define MII_CFG_MIIRATE_M125 (0x2 << MII_CFG_MIIRATE_SHIFT)
++#define MII_CFG_MIIRATE_M50 (0x3 << MII_CFG_MIIRATE_SHIFT)
++#define MII_CFG_MIIRATE_AUTO (0x4 << MII_CFG_MIIRATE_SHIFT)
++#define MII_CFG_MIIMODE_MASK 0xf
++#define MII_CFG_MIIMODE_MIIP 0x0
++#define MII_CFG_MIIMODE_MIIM 0x1
++#define MII_CFG_MIIMODE_RMIIP 0x2
++#define MII_CFG_MIIMODE_RMIIM 0x3
++#define MII_CFG_MIIMODE_RGMII 0x4
++
++#define PCDU_RXDLY_SHIFT 7
++#define PCDU_RXDLY_MASK (0x7 << PCDU_RXDLY_SHIFT)
++#define PCDU_TXDLY_MASK 0x7
++
++#define PMAC_HD_CTL_FC (1 << 10)
++#define PMAC_HD_CTL_CCRC (1 << 9)
++#define PMAC_HD_CTL_RST (1 << 8)
++#define PMAC_HD_CTL_AST (1 << 7)
++#define PMAC_HD_CTL_RXSH (1 << 6)
++#define PMAC_HD_CTL_RC (1 << 4)
++#define PMAC_HD_CTL_AS (1 << 3)
++#define PMAC_HD_CTL_AC (1 << 2)
++
++#define PCE_PCTRL_0_IGSTEN (1 << 11)
++
++#define FDMA_PCTRL_STEN (1 << 1)
++#define FDMA_PCTRL_EN (1 << 0)
++
++#define SDMA_PCTRL_EN (1 << 0)
++
++#define MDIO_GLOB_CTRL_SE (1 << 15)
++
++#define MDIO_MDC_CFG1_RES (1 << 15)
++#define MDIO_MDC_CFG1_MCEN (1 << 8)
++
++#define MDIO_CTRL_MBUSY (1 << 12)
++#define MDIO_CTRL_OP_READ (1 << 11)
++#define MDIO_CTRL_OP_WRITE (1 << 10)
++#define MDIO_CTRL_PHYAD_SHIFT 5
++#define MDIO_CTRL_PHYAD_MASK (0x1f << MDIO_CTRL_PHYAD_SHIFT)
++#define MDIO_CTRL_REGAD_MASK 0x1f
++
++#endif
+--- a/arch/mips/include/asm/asm.h
++++ b/arch/mips/include/asm/asm.h
+@@ -53,6 +53,7 @@
+ .align 2; \
+ .type symbol, @function; \
+ .ent symbol, 0; \
++ .section .text.symbol,"x"; \
+ symbol: .frame sp, 0, ra
+
+ /*
+@@ -62,7 +63,8 @@ symbol: .frame sp, 0, ra
+ .globl symbol; \
+ .align 2; \
+ .type symbol, @function; \
+- .ent symbol, 0; \
++ .ent symbol, 0; \
++ .section .text.symbol,"x"; \
+ symbol: .frame sp, framesize, rpc
+
+ /*
+--- /dev/null
++++ b/arch/mips/include/asm/gpio.h
+@@ -0,0 +1,7 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ */
++
++#include <asm/arch/gpio.h>
++#include <asm-generic/gpio.h>
+--- /dev/null
++++ b/arch/mips/include/asm/lantiq/chipid.h
+@@ -0,0 +1,74 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#ifndef __LANTIQ_CHIPID_H__
++#define __LANTIQ_CHIPID_H__
++
++enum ltq_chip_partnum {
++ LTQ_SOC_UNKNOWN = 0,
++ LTQ_SOC_VRX288_2 = 0x000B, /* VRX288 v1.2 */
++ LTQ_SOC_VRX268_2 = 0x000C, /* VRX268 v1.2 */
++ LTQ_SOC_GRX288_2 = 0x000D, /* GRX288 v1.2 */
++ LTQ_SOC_DANUBE = 0x0129,
++ LTQ_SOC_DANUBE_S = 0x012B,
++ LTQ_SOC_TWINPASS = 0x012D,
++ LTQ_SOC_VRX288 = 0x01C0, /* VRX288 v1.1 */
++ LTQ_SOC_VRX268 = 0x01C2, /* VRX268 v1.1 */
++ LTQ_SOC_GRX288 = 0x01C9, /* GRX288 v1.1 */
++};
++
++extern unsigned int ltq_chip_version_get(void);
++extern unsigned int ltq_chip_partnum_get(void);
++extern const char *ltq_chip_partnum_str(void);
++
++extern void ltq_chip_print_info(void);
++
++#ifdef CONFIG_SOC_XWAY_DANUBE
++static inline int ltq_soc_is_danube(void)
++{
++ return 1;
++}
++#else
++static inline int ltq_soc_is_danube(void)
++{
++ return 0;
++}
++#endif
++
++#ifdef CONFIG_SOC_XWAY_VRX200
++static inline int ltq_soc_is_vrx200(void)
++{
++ return 1;
++}
++
++static inline int ltq_soc_is_vrx200_v1(void)
++{
++ return ltq_chip_version_get() == 1;
++}
++
++static inline int ltq_soc_is_vrx200_v2(void)
++{
++ return ltq_chip_version_get() == 2;
++}
++#else
++static inline int ltq_soc_is_vrx200(void)
++{
++ return 0;
++}
++
++static inline int ltq_soc_is_vrx200_v1(void)
++{
++ return 0;
++}
++
++static inline int ltq_soc_is_vrx200_v2(void)
++{
++ return 0;
++}
++#endif
++
++#endif /* __LANTIQ_CHIPID_H__ */
+--- /dev/null
++++ b/arch/mips/include/asm/lantiq/clk.h
+@@ -0,0 +1,33 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2007-2010 Lantiq Deutschland GmbH
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ *
++ * Based on Lantiq port in Linux kernel
++ */
++
++#ifndef __LANTIQ_CLK_H__
++#define __LANTIQ_CLK_H__
++
++/* Symbolic clock speeds */
++enum ltq_clk {
++ CLOCK_83_MHZ = 83333333,
++ CLOCK_111_MHZ = 111111111,
++ CLOCK_125_MHZ = 125000000,
++ CLOCK_133_MHZ = 133333333,
++ CLOCK_166_MHZ = 166666667,
++ CLOCK_197_MHZ = 197000000,
++ CLOCK_333_MHZ = 333333333,
++ CLOCK_393_MHZ = 393219000,
++ CLOCK_500_MHZ = 500000000,
++ CLOCK_600_MHZ = 600000000,
++ CLOCK_1000_MHZ = 1000000000,
++};
++
++extern unsigned long ltq_get_cpu_clock(void);
++extern unsigned long ltq_get_bus_clock(void);
++extern unsigned long ltq_get_io_region_clock(void);
++
++#endif /* __LANTIQ_CLK_H__ */
+--- /dev/null
++++ b/arch/mips/include/asm/lantiq/config.h
+@@ -0,0 +1,166 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2007-2010 Lantiq Deutschland GmbH
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#ifndef __LANTIQ_CONFIG_H__
++#define __LANTIQ_CONFIG_H__
++
++/* Memory usage */
++#define CONFIG_SYS_MAXARGS 24
++#define CONFIG_SYS_MALLOC_LEN 1024*1024
++#define CONFIG_SYS_BOOTPARAMS_LEN 128*1024
++
++/* Command line */
++#define CONFIG_SYS_PROMPT CONFIG_MACH_TYPE " # "
++#define CONFIG_SYS_CBSIZE 512
++#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE + \
++ sizeof(CONFIG_SYS_PROMPT)+16)
++
++#define CONFIG_SYS_HUSH_PARSER
++#define CONFIG_SYS_PROMPT_HUSH_PS2 "> "
++
++/*
++ * Enable advanced console features on demand to reduce
++ * flash and RAM footprint
++ */
++#if defined(CONFIG_LTQ_ADVANCED_CONSOLE)
++#define CONFIG_SYS_LONGHELP
++#define CONFIG_AUTO_COMPLETE
++#define CONFIG_CMDLINE_EDITING
++#endif
++
++/* SPI flash SPL */
++#if defined(CONFIG_LTQ_SUPPORT_SPL_SPI_FLASH) && defined(CONFIG_SYS_BOOT_SFSPL)
++#define CONFIG_SPL
++#define CONFIG_SPL_SPI_SUPPORT
++#define CONFIG_SPL_SPI_FLASH_SUPPORT
++#endif
++
++#if defined(CONFIG_LTQ_SUPPORT_SPL_NOR_FLASH) && defined(CONFIG_SYS_BOOT_NORSPL)
++#define CONFIG_SPL
++#endif
++
++/* Common SPL */
++#if defined(CONFIG_SPL)
++#define CONFIG_SKIP_LOWLEVEL_INIT
++#define CONFIG_SPL_LIBGENERIC_SUPPORT
++#define CONFIG_SPL_GPIO_SUPPORT
++#define CONFIG_SPL_START_S_PATH \
++ "arch/mips/cpu/mips32/lantiq-common"
++#define CONFIG_SPL_LDSCRIPT \
++ "arch/mips/cpu/mips32/lantiq-common/u-boot-spl.lds"
++#endif
++
++#if defined(CONFIG_LTQ_SPL_CONSOLE)
++#define CONFIG_SPL_SERIAL_SUPPORT
++#define CONFIG_SPL_LIBCOMMON_SUPPORT
++#endif
++
++#if defined(CONFIG_LTQ_SPL_COMP_LZMA)
++#define CONFIG_LZMA
++#define CONFIG_SPL_LZMA_SUPPORT
++#endif
++
++#if defined(CONFIG_LTQ_SPL_COMP_LZO)
++#define CONFIG_LZO
++#define CONFIG_SPL_LZO_SUPPORT
++#endif
++
++/* Basic commands */
++#define CONFIG_CMD_BDI
++#define CONFIG_CMD_EDITENV
++#define CONFIG_CMD_IMI
++#define CONFIG_CMD_MEMORY
++#define CONFIG_CMD_RUN
++#define CONFIG_CMD_SAVEENV
++#define CONFIG_CMD_LOADS
++#define CONFIG_CMD_LOADB
++
++/* Other U-Boot settings */
++#define CONFIG_UBOOT_VERSION
++#define CONFIG_TIMESTAMP
++
++/* Default environment */
++#define CONFIG_ENV_CONSOLEDEV \
++ "consoledev=" CONFIG_CONSOLE_DEV "\0"
++
++#define CONFIG_ENV_ADDCONSOLE \
++ "addconsole=setenv bootargs $bootargs" \
++ " console=$consoledev,$baudrate\0"
++
++#if defined(CONFIG_NET_DEV)
++#define CONFIG_ENV_NETDEV \
++ "netdev=" CONFIG_NET_DEV "\0"
++#else
++#define CONFIG_ENV_NETDEV \
++ "netdev=eth0\0"
++#endif
++
++#define CONFIG_ENV_ADDIP \
++ "addip=setenv bootargs $bootargs" \
++ " ip=$ipaddr:$serverip::::$netdev:off\0"
++
++#define CONFIG_ENV_ADDETH \
++ "addeth=setenv bootargs $bootargs" \
++ " ethaddr=$ethaddr\0"
++
++#define CONFIG_ENV_ADDMACHTYPE \
++ "addmachtype=setenv bootargs $bootargs" \
++ " machtype=" CONFIG_MACH_TYPE "\0"
++
++#if defined(CONFIG_LTQ_SUPPORT_NOR_FLASH)
++#define CONFIG_ENV_WRITE_UBOOT_NOR \
++ "write-uboot-nor=" \
++ "protect off " __stringify(CONFIG_SYS_FLASH_BASE) " +$filesize && " \
++ "erase " __stringify(CONFIG_SYS_FLASH_BASE) " +$filesize && " \
++ "cp.b $fileaddr " __stringify(CONFIG_SYS_FLASH_BASE) " $filesize\0"
++
++#define CONFIG_ENV_LOAD_UBOOT_NOR \
++ "load-uboot-nor=tftpboot u-boot.bin\0" \
++ "load-uboot-norspl=tftpboot u-boot.ltq.norspl\0" \
++ "load-uboot-norspl-lzo=tftpboot u-boot.ltq.lzo.norspl\0" \
++ "load-uboot-norspl-lzma=tftpboot u-boot.ltq.lzma.norspl\0"
++#else
++#define CONFIG_ENV_WRITE_UBOOT_NOR
++#define CONFIG_ENV_LOAD_UBOOT_NOR
++#endif
++
++#if defined(CONFIG_LTQ_SUPPORT_SPI_FLASH)
++#define CONFIG_ENV_SF_PROBE \
++ "sf-probe=sf probe " __stringify(CONFIG_ENV_SPI_CS) " " \
++ __stringify(CONFIG_ENV_SPI_MAX_HZ) " " \
++ __stringify(CONFIG_ENV_SPI_MODE) " \0"
++
++#define CONFIG_ENV_WRITE_UBOOT_SF \
++ "write-uboot-sf=" \
++ "run sf-probe && sf erase 0 +$filesize && " \
++ "sf write $fileaddr 0 $filesize\0"
++
++#define CONFIG_ENV_LOAD_UBOOT_SF \
++ "load-uboot-sfspl=tftpboot u-boot.ltq.sfspl\0" \
++ "load-uboot-sfspl-lzo=tftpboot u-boot.ltq.lzo.sfspl\0" \
++ "load-uboot-sfspl-lzma=tftpboot u-boot.ltq.lzma.sfspl\0"
++#else
++#define CONFIG_ENV_SF_PROBE
++#define CONFIG_ENV_WRITE_UBOOT_SF
++#define CONFIG_ENV_LOAD_UBOOT_SF
++#endif
++
++#define CONFIG_ENV_LANTIQ_DEFAULTS \
++ CONFIG_ENV_CONSOLEDEV \
++ CONFIG_ENV_ADDCONSOLE \
++ CONFIG_ENV_NETDEV \
++ CONFIG_ENV_ADDIP \
++ CONFIG_ENV_ADDETH \
++ CONFIG_ENV_ADDMACHTYPE \
++ CONFIG_ENV_WRITE_UBOOT_NOR \
++ CONFIG_ENV_LOAD_UBOOT_NOR \
++ CONFIG_ENV_SF_PROBE \
++ CONFIG_ENV_WRITE_UBOOT_SF \
++ CONFIG_ENV_LOAD_UBOOT_SF
++
++#endif /* __LANTIQ_CONFIG_H__ */
+--- /dev/null
++++ b/arch/mips/include/asm/lantiq/cpu.h
+@@ -0,0 +1,35 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011-2012 Daniel Schwierzeck, daniel.schwierzeck@gmail.com
++ */
++
++#ifndef __LANTIQ_CPU_H__
++#define __LANTIQ_CPU_H__
++
++enum ltq_boot_select {
++ BOOT_NOR,
++ BOOT_NOR_NO_BOOTROM,
++ BOOT_UART,
++ BOOT_UART_NO_EEPROM,
++ BOOT_SPI,
++ BOOT_NAND,
++ BOOT_PCI,
++ BOOT_MII0,
++ BOOT_RMII0,
++ BOOT_RGMII1,
++ BOOT_UNKNOWN,
++};
++
++enum ltq_boot_select ltq_boot_select(void);
++const char *ltq_boot_select_str(void);
++
++void ltq_pmu_init(void);
++void ltq_ebu_init(void);
++void ltq_gpio_init(void);
++
++void ltq_pll_init(void);
++void ltq_dcdc_init(unsigned int dig_ref);
++
++#endif /* __LANTIQ_CPU_H__ */
+--- /dev/null
++++ b/arch/mips/include/asm/lantiq/dma.h
+@@ -0,0 +1,95 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#ifndef __LANTIQ_DMA_H__
++#define __LANTIQ_DMA_H__
++
++enum ltq_dma_endianess {
++ LTQ_DMA_ENDIANESS_B0_B1_B2_B3, /* No byte swapping */
++ LTQ_DMA_ENDIANESS_B1_B0_B3_B2, /* B0B1B2B3 => B1B0B3B2 */
++ LTQ_DMA_ENDIANESS_B2_B3_B0_B1, /* B0B1B2B3 => B2B3B0B1 */
++ LTQ_DMA_ENDIANESS_B3_B2_B1_B0, /* B0B1B2B3 => B3B2B1B0 */
++};
++
++enum ltq_dma_burst_len {
++ LTQ_DMA_BURST_2WORDS = 1,
++ LTQ_DMA_BURST_4WORDS = 2,
++ LTQ_DMA_BURST_8WORDS = 3,
++};
++
++struct ltq_dma_desc {
++ u32 ctl;
++ u32 addr;
++};
++
++struct ltq_dma_channel {
++ struct ltq_dma_device *dev;
++ u8 chan_no;
++ u8 class;
++ u16 num_desc;
++ struct ltq_dma_desc *desc_base;
++ void *mem_base;
++ u32 dma_addr;
++};
++
++struct ltq_dma_device {
++ enum ltq_dma_endianess rx_endian_swap;
++ enum ltq_dma_endianess tx_endian_swap;
++ enum ltq_dma_burst_len rx_burst_len;
++ enum ltq_dma_burst_len tx_burst_len;
++ struct ltq_dma_channel rx_chan;
++ struct ltq_dma_channel tx_chan;
++ u8 port;
++};
++
++/**
++ * Initialize DMA hardware and driver
++ */
++void ltq_dma_init(void);
++
++/**
++ * Register given DMA client context
++ *
++ * @returns 0 on success, negative value otherwise
++ */
++int ltq_dma_register(struct ltq_dma_device *dev);
++
++/**
++ * Reset and halt all channels related to given DMA client
++ */
++void ltq_dma_reset(struct ltq_dma_device *dev);
++void ltq_dma_enable(struct ltq_dma_device *dev);
++void ltq_dma_disable(struct ltq_dma_device *dev);
++
++/**
++ * Map RX DMA descriptor to memory region
++ *
++ * @returns 0 on success, negative value otherwise
++ */
++int ltq_dma_rx_map(struct ltq_dma_device *dev, int index, void *data, int len);
++
++/**
++ * Check if new data is available.
++ *
++ * @returns length of received data, 0 otherwise
++ */
++int ltq_dma_rx_poll(struct ltq_dma_device *dev, int index);
++
++int ltq_dma_rx_length(struct ltq_dma_device *dev, int index);
++
++/**
++ * Map TX DMA descriptor to memory region
++ *
++ * @returns 0 on success, negative value otherwise
++ */
++int ltq_dma_tx_map(struct ltq_dma_device *dev, int index, void *data, int len,
++ unsigned long timeout);
++
++int ltq_dma_tx_wait(struct ltq_dma_device *dev, int index,
++ unsigned long timeout);
++
++#endif /* __LANTIQ_DMA_H__ */
+--- /dev/null
++++ b/arch/mips/include/asm/lantiq/eth.h
+@@ -0,0 +1,36 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#ifndef __LANTIQ_ETH_H__
++#define __LANTIQ_ETH_H__
++
++#include <phy.h>
++
++enum LTQ_ETH_PORT_FLAGS {
++ LTQ_ETH_PORT_NONE = 0,
++ LTQ_ETH_PORT_PHY = 1,
++ LTQ_ETH_PORT_SWITCH = (1 << 1),
++ LTQ_ETH_PORT_MAC = (1 << 2),
++};
++
++struct ltq_eth_port_config {
++ u8 num;
++ u8 phy_addr;
++ u16 flags;
++ phy_interface_t phy_if;
++ u8 rgmii_rx_delay;
++ u8 rgmii_tx_delay;
++};
++
++struct ltq_eth_board_config {
++ const struct ltq_eth_port_config *ports;
++ int num_ports;
++};
++
++extern int ltq_eth_initialize(const struct ltq_eth_board_config *board_config);
++
++#endif /* __LANTIQ_ETH_H__ */
+--- /dev/null
++++ b/arch/mips/include/asm/lantiq/gpio.h
+@@ -0,0 +1,51 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#ifndef __LANTIQ_GPIO_H__
++#define __LANTIQ_GPIO_H__
++
++enum ltq_gpio_dir {
++ GPIO_DIR_IN = 0,
++ GPIO_DIR_OUT
++};
++
++enum ltq_gpio_od {
++ GPIO_OD_ACTIVE = 0,
++ GPIO_OD_NORMAL
++};
++
++enum ltq_gpio_altsel {
++ GPIO_ALTSEL_CLR = 0,
++ GPIO_ALTSEL_SET
++};
++
++extern int gpio_set_altfunc(unsigned gpio, int altsel0, int altsel1, int dir);
++extern int gpio_set_opendrain(unsigned gpio, int od);
++
++static inline int gpio_to_port(unsigned gpio)
++{
++ return gpio >> 4;
++}
++
++static inline int gpio_to_pin(unsigned gpio)
++{
++ return gpio & 0xF;
++}
++
++static inline int gpio_to_bit(unsigned gpio)
++{
++ return 1 << gpio_to_pin(gpio);
++}
++
++static inline int gpio_to_gpio(unsigned port, unsigned pin)
++{
++ return (port << 4) | (pin & 0xF);
++}
++
++#include <asm-generic/gpio.h>
++
++#endif /* __LANTIQ_GPIO_H__ */
+--- /dev/null
++++ b/arch/mips/include/asm/lantiq/io.h
+@@ -0,0 +1,38 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#ifndef __LANTIQ_IO_H__
++#define __LANTIQ_IO_H__
++
++#include <asm/io.h>
++
++#define ltq_readb(a) __raw_readb(a)
++#define ltq_writeb(a, v) __raw_writeb(v, a)
++
++#define ltq_readl(a) __raw_readl(a)
++#define ltq_writel(a, v) __raw_writel(v, a)
++
++#define ltq_clrbits(a, clear) \
++ ltq_writel(a, ltq_readl(a) & ~(clear))
++
++#define ltq_setbits(a, set) \
++ ltq_writel(a, ltq_readl(a) | (set))
++
++#define ltq_clrsetbits(a, clear, set) \
++ ltq_writel(a, (ltq_readl(a) & ~(clear)) | (set))
++
++static inline void ltq_reg_dump(const void *addr, const char *desc)
++{
++ u32 data;
++
++ data = ltq_readl(addr);
++ printf("ltq_reg_dump: %s 0x%p = 0x%08x\n",
++ desc, addr, data);
++}
++
++#endif /* __LANTIQ_IO_H__ */
+--- /dev/null
++++ b/arch/mips/include/asm/lantiq/pm.h
+@@ -0,0 +1,22 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#ifndef __LANTIQ_PM_H__
++#define __LANTIQ_PM_H__
++
++enum ltq_pm_modules {
++ LTQ_PM_CORE,
++ LTQ_PM_DMA,
++ LTQ_PM_ETH,
++ LTQ_PM_SPI,
++};
++
++u32 ltq_pm_map(enum ltq_pm_modules module);
++int ltq_pm_enable(enum ltq_pm_modules module);
++int ltq_pm_disable(enum ltq_pm_modules module);
++
++#endif /* __LANTIQ_PM_H__ */
+--- /dev/null
++++ b/arch/mips/include/asm/lantiq/reset.h
+@@ -0,0 +1,38 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#ifndef __LANTIQ_RESET_H__
++#define __LANTIQ_RESET_H__
++
++enum ltq_reset_modules {
++ LTQ_RESET_CORE,
++ LTQ_RESET_DMA,
++ LTQ_RESET_ETH,
++ LTQ_RESET_PHY,
++ LTQ_RESET_HARD,
++ LTQ_RESET_SOFT,
++};
++
++extern u32 ltq_reset_map(enum ltq_reset_modules module);
++extern int ltq_reset_activate(enum ltq_reset_modules module);
++extern int ltq_reset_deactivate(enum ltq_reset_modules module);
++
++static inline int ltq_reset_once(enum ltq_reset_modules module, ulong usec)
++{
++ int ret;
++
++ ret = ltq_reset_activate(module);
++ if (ret)
++ return ret;
++
++ __udelay(usec);
++ ret = ltq_reset_deactivate(module);
++
++ return ret;
++}
++
++#endif /* __LANTIQ_RESET_H__ */
+--- a/arch/mips/include/asm/mipsregs.h
++++ b/arch/mips/include/asm/mipsregs.h
+@@ -46,7 +46,10 @@
+ #define CP0_ENTRYLO1 $3
+ #define CP0_CONF $3
+ #define CP0_CONTEXT $4
++#define CP0_CONTEXTCONFIG $4,1
++#define CP0_USERLOCAL $4,1
+ #define CP0_PAGEMASK $5
++#define CP0_PAGEGRAIN $5,1
+ #define CP0_WIRED $6
+ #define CP0_INFO $7
+ #define CP0_BADVADDR $8
+@@ -54,10 +57,19 @@
+ #define CP0_ENTRYHI $10
+ #define CP0_COMPARE $11
+ #define CP0_STATUS $12
++#define CP0_INTCTL $12,1
++#define CP0_SRSCTL $12,2
++#define CP0_SRSMAP $12,3
++#define CP0_SRSHIGH $12,4
+ #define CP0_CAUSE $13
+ #define CP0_EPC $14
+ #define CP0_PRID $15
++#define CP0_EBASE $15,1
+ #define CP0_CONFIG $16
++#define CP0_CONFIG1 $16,1
++#define CP0_CONFIG2 $16,2
++#define CP0_CONFIG3 $16,3
++#define CP0_CONFIG7 $16,7
+ #define CP0_LLADDR $17
+ #define CP0_WATCHLO $18
+ #define CP0_WATCHHI $19
+@@ -70,7 +82,17 @@
+ #define CP0_ECC $26
+ #define CP0_CACHEERR $27
+ #define CP0_TAGLO $28
++#define CP0_ITAGLO $28
++#define CP0_IDATALO $28,1
++#define CP0_DTAGLO $28,2
++#define CP0_DDATALO $28,3
++#define CP0_L23TAGLO $28,4
++#define CP0_L23DATALO $28,5
+ #define CP0_TAGHI $29
++#define CP0_IDATAHI $29,1
++#define CP0_DTAGHI $29,2
++#define CP0_L23TAGHI $29,4
++#define CP0_L23DATAHI $29,5
+ #define CP0_ERROREPC $30
+ #define CP0_DESAVE $31
+
+@@ -395,6 +417,12 @@
+ #define CAUSEF_BD (_ULCAST_(1) << 31)
+
+ /*
++ * Bits in the coprocessor 0 EBase register.
++ */
++#define EBASEB_CPUNUM 0
++#define EBASEF_CPUNUM (_ULCAST_(1023))
++
++/*
+ * Bits in the coprocessor 0 config register.
+ */
+ /* Generic bits. */
+--- a/arch/mips/include/asm/u-boot-mips.h
++++ b/arch/mips/include/asm/u-boot-mips.h
+@@ -9,3 +9,4 @@ extern ulong uboot_end_data;
+ extern ulong uboot_end;
+
+ extern int incaip_set_cpuclk(void);
++extern int arch_cpu_init(void);
+--- a/arch/mips/lib/board.c
++++ b/arch/mips/lib/board.c
+@@ -50,6 +50,16 @@ static char *failed = "*** failed ***\n"
+ */
+ const unsigned long mips_io_port_base = -1;
+
++int __arch_cpu_init(void)
++{
++ /*
++ * Nothing to do in this dummy implementation
++ */
++ return 0;
++}
++int arch_cpu_init(void)
++ __attribute__((weak, alias("__arch_cpu_init")));
++
+ int __board_early_init_f(void)
+ {
+ /*
+@@ -123,6 +133,7 @@ static int init_baudrate(void)
+ typedef int (init_fnc_t)(void);
+
+ init_fnc_t *init_sequence[] = {
++ arch_cpu_init,
+ board_early_init_f,
+ timer_init,
+ env_init, /* initialize environment */
+--- /dev/null
++++ b/board/lantiq/easy50712/Makefile
+@@ -0,0 +1,29 @@
++#
++# This file is released under the terms of GPL v2 and any later version.
++# See the file COPYING in the root directory of the source tree for details.
++#
++# Copyright (C) 2000-2011 Wolfgang Denk, DENX Software Engineering, wd@denx.de
++# Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++#
++
++include $(TOPDIR)/config.mk
++
++LIB = $(obj)lib$(BOARD).o
++
++COBJS = $(BOARD).o
++
++SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c)
++OBJS := $(addprefix $(obj),$(COBJS))
++SOBJS := $(addprefix $(obj),$(SOBJS))
++
++$(LIB): $(obj).depend $(OBJS) $(SOBJS)
++ $(call cmd_link_o_target, $(OBJS) $(SOBJS))
++
++#########################################################################
++
++# defines $(obj).depend target
++include $(SRCTREE)/rules.mk
++
++sinclude $(obj).depend
++
++#########################################################################
+--- /dev/null
++++ b/board/lantiq/easy50712/config.mk
+@@ -0,0 +1,8 @@
++#
++# This file is released under the terms of GPL v2 and any later version.
++# See the file COPYING in the root directory of the source tree for details.
++#
++# Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++#
++
++PLATFORM_CPPFLAGS += -I$(TOPDIR)/board/$(BOARDDIR)
+--- /dev/null
++++ b/board/lantiq/easy50712/ddr_settings.h
+@@ -0,0 +1,55 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2007-2010 Lantiq Deutschland GmbH
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#define MC_DC00_VALUE 0x1B1B
++#define MC_DC01_VALUE 0x0
++#define MC_DC02_VALUE 0x0
++#define MC_DC03_VALUE 0x0
++#define MC_DC04_VALUE 0x0
++#define MC_DC05_VALUE 0x200
++#define MC_DC06_VALUE 0x605
++#define MC_DC07_VALUE 0x303
++#define MC_DC08_VALUE 0x102
++#define MC_DC09_VALUE 0x70a
++#define MC_DC10_VALUE 0x203
++#define MC_DC11_VALUE 0xc02
++#define MC_DC12_VALUE 0x1C8
++#define MC_DC13_VALUE 0x1
++#define MC_DC14_VALUE 0x0
++#define MC_DC15_VALUE 0x13c
++#define MC_DC16_VALUE 0xC800
++#define MC_DC17_VALUE 0xd
++#define MC_DC18_VALUE 0x300
++#define MC_DC19_VALUE 0x200
++#define MC_DC20_VALUE 0xA04
++#define MC_DC21_VALUE 0xd00
++#define MC_DC22_VALUE 0xd0d
++#define MC_DC23_VALUE 0x0
++#define MC_DC24_VALUE 0x62
++#define MC_DC25_VALUE 0x0
++#define MC_DC26_VALUE 0x0
++#define MC_DC27_VALUE 0x0
++#define MC_DC28_VALUE 0x510
++#define MC_DC29_VALUE 0x2d89
++#define MC_DC30_VALUE 0x8300
++#define MC_DC31_VALUE 0x0
++#define MC_DC32_VALUE 0x0
++#define MC_DC33_VALUE 0x0
++#define MC_DC34_VALUE 0x0
++#define MC_DC35_VALUE 0x0
++#define MC_DC36_VALUE 0x0
++#define MC_DC37_VALUE 0x0
++#define MC_DC38_VALUE 0x0
++#define MC_DC39_VALUE 0x0
++#define MC_DC40_VALUE 0x0
++#define MC_DC41_VALUE 0x0
++#define MC_DC42_VALUE 0x0
++#define MC_DC43_VALUE 0x0
++#define MC_DC44_VALUE 0x0
++#define MC_DC45_VALUE 0x500
++#define MC_DC46_VALUE 0x0
+--- /dev/null
++++ b/board/lantiq/easy50712/easy50712.c
+@@ -0,0 +1,106 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2010 Thomas Langer <thomas.langer@lantiq.com>
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <common.h>
++#include <switch.h>
++#include <spi.h>
++#include <asm/gpio.h>
++#include <asm/lantiq/eth.h>
++#include <asm/lantiq/reset.h>
++#include <asm/lantiq/chipid.h>
++
++static void gpio_init(void)
++{
++ /* SPI/CS output (low-active) for serial flash */
++ gpio_direction_output(22, 1);
++
++ /* enable CLK_OUT2 for external switch */
++ gpio_set_altfunc(3, GPIO_ALTSEL_SET, GPIO_ALTSEL_CLR, GPIO_DIR_OUT);
++}
++
++int board_early_init_f(void)
++{
++ gpio_init();
++
++ return 0;
++}
++
++int checkboard(void)
++{
++ puts("Board: " CONFIG_BOARD_NAME "\n");
++ ltq_chip_print_info();
++
++ return 0;
++}
++
++static const struct ltq_eth_port_config eth_port_config[] = {
++ /* MAC0: Lantiq ADM6996I switch */
++ { 0, 0x0, LTQ_ETH_PORT_SWITCH, PHY_INTERFACE_MODE_RMII },
++};
++
++static const struct ltq_eth_board_config eth_board_config = {
++ .ports = eth_port_config,
++ .num_ports = ARRAY_SIZE(eth_port_config),
++};
++
++int board_eth_init(bd_t *bis)
++{
++ return ltq_eth_initialize(&eth_board_config);
++}
++
++static struct switch_device adm6996i_dev = {
++ .name = "adm6996i",
++ .cpu_port = 5,
++ .port_mask = 0xF,
++};
++
++int board_switch_init(void)
++{
++ /* Deactivate HRST line to release reset of ADM6996I switch */
++ ltq_reset_once(LTQ_RESET_HARD, 200000);
++
++ /* ADM6996I needs some time to come out of reset */
++ __udelay(50000);
++
++ return switch_device_register(&adm6996i_dev);
++}
++
++int spi_cs_is_valid(unsigned int bus, unsigned int cs)
++{
++ if (bus)
++ return 0;
++
++ switch (cs) {
++ case 2:
++ return 1;
++ default:
++ return 0;
++ }
++}
++
++void spi_cs_activate(struct spi_slave *slave)
++{
++ switch (slave->cs) {
++ case 2:
++ gpio_set_value(22, 0);
++ break;
++ default:
++ break;
++ }
++}
++
++void spi_cs_deactivate(struct spi_slave *slave)
++{
++ switch (slave->cs) {
++ case 2:
++ gpio_set_value(22, 1);
++ break;
++ default:
++ break;
++ }
++}
+--- /dev/null
++++ b/board/lantiq/easy80920/Makefile
+@@ -0,0 +1,29 @@
++#
++# This file is released under the terms of GPL v2 and any later version.
++# See the file COPYING in the root directory of the source tree for details.
++#
++# Copyright (C) 2000-2011 Wolfgang Denk, DENX Software Engineering, wd@denx.de
++# Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++#
++
++include $(TOPDIR)/config.mk
++
++LIB = $(obj)lib$(BOARD).o
++
++COBJS = $(BOARD).o
++
++SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c)
++OBJS := $(addprefix $(obj),$(COBJS))
++SOBJS := $(addprefix $(obj),$(SOBJS))
++
++$(LIB): $(obj).depend $(OBJS) $(SOBJS)
++ $(call cmd_link_o_target, $(OBJS) $(SOBJS))
++
++#########################################################################
++
++# defines $(obj).depend target
++include $(SRCTREE)/rules.mk
++
++sinclude $(obj).depend
++
++#########################################################################
+--- /dev/null
++++ b/board/lantiq/easy80920/config.mk
+@@ -0,0 +1,8 @@
++#
++# This file is released under the terms of GPL v2 and any later version.
++# See the file COPYING in the root directory of the source tree for details.
++#
++# Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++#
++
++PLATFORM_CPPFLAGS += -I$(TOPDIR)/board/$(BOARDDIR)
+--- /dev/null
++++ b/board/lantiq/easy80920/ddr_settings.h
+@@ -0,0 +1,70 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2007-2010 Lantiq Deutschland GmbH
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#define MC_CCR00_VALUE 0x101
++#define MC_CCR01_VALUE 0x1000100
++#define MC_CCR02_VALUE 0x1010000
++#define MC_CCR03_VALUE 0x101
++#define MC_CCR04_VALUE 0x1000000
++#define MC_CCR05_VALUE 0x1000101
++#define MC_CCR06_VALUE 0x1000100
++#define MC_CCR07_VALUE 0x1010000
++#define MC_CCR08_VALUE 0x1000101
++#define MC_CCR09_VALUE 0x0
++#define MC_CCR10_VALUE 0x2000100
++#define MC_CCR11_VALUE 0x2000300
++#define MC_CCR12_VALUE 0x30000
++#define MC_CCR13_VALUE 0x202
++#define MC_CCR14_VALUE 0x7080A0F
++#define MC_CCR15_VALUE 0x2040F
++#define MC_CCR16_VALUE 0x40000
++#define MC_CCR17_VALUE 0x70102
++#define MC_CCR18_VALUE 0x4020002
++#define MC_CCR19_VALUE 0x30302
++#define MC_CCR20_VALUE 0x8000700
++#define MC_CCR21_VALUE 0x40F020A
++#define MC_CCR22_VALUE 0x0
++#define MC_CCR23_VALUE 0xC020000
++#define MC_CCR24_VALUE 0x4401B04
++#define MC_CCR25_VALUE 0x0
++#define MC_CCR26_VALUE 0x0
++#define MC_CCR27_VALUE 0x6420000
++#define MC_CCR28_VALUE 0x0
++#define MC_CCR29_VALUE 0x0
++#define MC_CCR30_VALUE 0x798
++#define MC_CCR31_VALUE 0x0
++#define MC_CCR32_VALUE 0x0
++#define MC_CCR33_VALUE 0x650000
++#define MC_CCR34_VALUE 0x200C8
++#define MC_CCR35_VALUE 0x1D445D
++#define MC_CCR36_VALUE 0xC8
++#define MC_CCR37_VALUE 0xC351
++#define MC_CCR38_VALUE 0x0
++#define MC_CCR39_VALUE 0x141F04
++#define MC_CCR40_VALUE 0x142704
++#define MC_CCR41_VALUE 0x141b42
++#define MC_CCR42_VALUE 0x141b42
++#define MC_CCR43_VALUE 0x566504
++#define MC_CCR44_VALUE 0x566504
++#define MC_CCR45_VALUE 0x565F17
++#define MC_CCR46_VALUE 0x565F17
++#define MC_CCR47_VALUE 0x0
++#define MC_CCR48_VALUE 0x0
++#define MC_CCR49_VALUE 0x0
++#define MC_CCR50_VALUE 0x0
++#define MC_CCR51_VALUE 0x0
++#define MC_CCR52_VALUE 0x133
++#define MC_CCR53_VALUE 0xF3014B27
++#define MC_CCR54_VALUE 0xF3014B27
++#define MC_CCR55_VALUE 0xF3014B27
++#define MC_CCR56_VALUE 0xF3014B27
++#define MC_CCR57_VALUE 0x7800301
++#define MC_CCR58_VALUE 0x7800301
++#define MC_CCR59_VALUE 0x7800301
++#define MC_CCR60_VALUE 0x7800301
++#define MC_CCR61_VALUE 0x4
+--- /dev/null
++++ b/board/lantiq/easy80920/easy80920.c
+@@ -0,0 +1,139 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <common.h>
++#include <spi.h>
++#include <asm/gpio.h>
++#include <asm/lantiq/eth.h>
++#include <asm/lantiq/chipid.h>
++#include <asm/lantiq/cpu.h>
++#include <asm/arch/gphy.h>
++
++#if defined(CONFIG_SPL_BUILD)
++#define do_gpio_init 1
++#define do_pll_init 1
++#define do_dcdc_init 0
++#elif defined(CONFIG_SYS_BOOT_RAM)
++#define do_gpio_init 1
++#define do_pll_init 0
++#define do_dcdc_init 1
++#elif defined(CONFIG_SYS_BOOT_NOR)
++#define do_gpio_init 1
++#define do_pll_init 1
++#define do_dcdc_init 1
++#else
++#define do_gpio_init 0
++#define do_pll_init 0
++#define do_dcdc_init 1
++#endif
++
++static void gpio_init(void)
++{
++ /* SPI CS 0.4 to serial flash */
++ gpio_direction_output(10, 1);
++
++ /* EBU.FL_CS1 as output for NAND CE */
++ gpio_set_altfunc(23, GPIO_ALTSEL_SET, GPIO_ALTSEL_CLR, GPIO_DIR_OUT);
++ /* EBU.FL_A23 as output for NAND CLE */
++ gpio_set_altfunc(24, GPIO_ALTSEL_SET, GPIO_ALTSEL_CLR, GPIO_DIR_OUT);
++ /* EBU.FL_A24 as output for NAND ALE */
++ gpio_set_altfunc(13, GPIO_ALTSEL_SET, GPIO_ALTSEL_CLR, GPIO_DIR_OUT);
++ /* GPIO 3.0 as input for NAND Ready Busy */
++ gpio_set_altfunc(48, GPIO_ALTSEL_SET, GPIO_ALTSEL_CLR, GPIO_DIR_IN);
++ /* GPIO 3.1 as output for NAND Read */
++ gpio_set_altfunc(49, GPIO_ALTSEL_SET, GPIO_ALTSEL_CLR, GPIO_DIR_OUT);
++}
++
++int board_early_init_f(void)
++{
++ if (do_gpio_init)
++ gpio_init();
++
++ if (do_pll_init)
++ ltq_pll_init();
++
++ if (do_dcdc_init)
++ ltq_dcdc_init(0x7F);
++
++ return 0;
++}
++
++int checkboard(void)
++{
++ puts("Board: " CONFIG_BOARD_NAME "\n");
++ ltq_chip_print_info();
++
++ return 0;
++}
++
++static const struct ltq_eth_port_config eth_port_config[] = {
++ /* GMAC0: external Lantiq PEF7071 10/100/1000 PHY for LAN port 0 */
++ { 0, 0x0, LTQ_ETH_PORT_PHY, PHY_INTERFACE_MODE_RGMII },
++ /* GMAC1: external Lantiq PEF7071 10/100/1000 PHY for LAN port 1 */
++ { 1, 0x1, LTQ_ETH_PORT_PHY, PHY_INTERFACE_MODE_RGMII },
++ /* GMAC2: internal GPHY0 with 10/100/1000 firmware for LAN port 2 */
++ { 2, 0x11, LTQ_ETH_PORT_PHY, PHY_INTERFACE_MODE_GMII },
++ /* GMAC3: unused */
++ { 3, 0x0, LTQ_ETH_PORT_NONE, PHY_INTERFACE_MODE_NONE },
++ /* GMAC4: internal GPHY1 with 10/100/1000 firmware for LAN port 3 */
++ { 4, 0x13, LTQ_ETH_PORT_PHY, PHY_INTERFACE_MODE_GMII },
++ /* GMAC5: external Lantiq PEF7071 10/100/1000 PHY for WANoE port */
++ { 5, 0x5, LTQ_ETH_PORT_PHY, PHY_INTERFACE_MODE_RGMII },
++};
++
++static const struct ltq_eth_board_config eth_board_config = {
++ .ports = eth_port_config,
++ .num_ports = ARRAY_SIZE(eth_port_config),
++};
++
++int board_eth_init(bd_t * bis)
++{
++ const enum ltq_gphy_clk clk = LTQ_GPHY_CLK_25MHZ_PLL0;
++ const ulong fw_addr = 0x80FF0000;
++
++ ltq_gphy_phy11g_a1x_load(fw_addr);
++
++ ltq_cgu_gphy_clk_src(clk);
++
++ ltq_rcu_gphy_boot(0, fw_addr);
++ ltq_rcu_gphy_boot(1, fw_addr);
++
++ return ltq_eth_initialize(&eth_board_config);
++}
++
++int spi_cs_is_valid(unsigned int bus, unsigned int cs)
++{
++ if (bus)
++ return 0;
++
++ if (cs == 4)
++ return 1;
++
++ return 0;
++}
++
++void spi_cs_activate(struct spi_slave *slave)
++{
++ switch (slave->cs) {
++ case 4:
++ gpio_set_value(10, 0);
++ break;
++ default:
++ break;
++ }
++}
++
++void spi_cs_deactivate(struct spi_slave *slave)
++{
++ switch (slave->cs) {
++ case 4:
++ gpio_set_value(10, 1);
++ break;
++ default:
++ break;
++ }
++}
+--- a/boards.cfg
++++ b/boards.cfg
+@@ -444,10 +444,17 @@ dbau1500 mips
+ dbau1550 mips mips32 dbau1x00 - au1x00 dbau1x00:DBAU1550
+ dbau1550_el mips mips32 dbau1x00 - au1x00 dbau1x00:DBAU1550,SYS_LITTLE_ENDIAN
+ pb1000 mips mips32 pb1x00 - au1x00 pb1x00:PB1000
++easy50712_nor mips mips32 easy50712 lantiq danube easy50712:SYS_BOOT_NOR
++easy50712_norspl mips mips32 easy50712 lantiq danube easy50712:SYS_BOOT_NORSPL
++easy50712_ram mips mips32 easy50712 lantiq danube easy50712:SYS_BOOT_RAM
+ incaip mips mips32 incaip - incaip
+ incaip_100MHz mips mips32 incaip - incaip incaip:CPU_CLOCK_RATE=100000000
+ incaip_133MHz mips mips32 incaip - incaip incaip:CPU_CLOCK_RATE=133000000
+ incaip_150MHz mips mips32 incaip - incaip incaip:CPU_CLOCK_RATE=150000000
++easy80920_nor mips mips32 easy80920 lantiq vrx200 easy80920:SYS_BOOT_NOR
++easy80920_norspl mips mips32 easy80920 lantiq vrx200 easy80920:SYS_BOOT_NORSPL
++easy80920_ram mips mips32 easy80920 lantiq vrx200 easy80920:SYS_BOOT_RAM
++easy80920_sfspl mips mips32 easy80920 lantiq vrx200 easy80920:SYS_BOOT_SFSPL
+ qi_lb60 mips xburst qi_lb60 qi
+ adp-ag101 nds32 n1213 adp-ag101 AndesTech ag101
+ adp-ag101p nds32 n1213 adp-ag101p AndesTech ag101
+--- a/drivers/dma/Makefile
++++ b/drivers/dma/Makefile
+@@ -28,6 +28,7 @@ LIB := $(obj)libdma.o
+ COBJS-$(CONFIG_FSLDMAFEC) += MCD_tasksInit.o MCD_dmaApi.o MCD_tasks.o
+ COBJS-$(CONFIG_APBH_DMA) += apbh_dma.o
+ COBJS-$(CONFIG_FSL_DMA) += fsl_dma.o
++COBJS-$(CONFIG_LANTIQ_DMA) += lantiq_dma.o
+ COBJS-$(CONFIG_OMAP3_DMA) += omap3_dma.o
+
+ COBJS := $(COBJS-y)
+--- /dev/null
++++ b/drivers/dma/lantiq_dma.c
+@@ -0,0 +1,388 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011-2012 Daniel Schwierzeck, daniel.schwierzeck@gmail.com
++ */
++
++#include <common.h>
++#include <malloc.h>
++#include <watchdog.h>
++#include <linux/compiler.h>
++#include <asm/lantiq/io.h>
++#include <asm/lantiq/dma.h>
++#include <asm/lantiq/pm.h>
++#include <asm/lantiq/reset.h>
++#include <asm/arch/soc.h>
++#include <asm/processor.h>
++
++#define DMA_CTRL_PKTARB (1 << 31)
++#define DMA_CTRL_MBRSTARB (1 << 30)
++#define DMA_CTRL_MBRSTCNT_SHIFT 16
++#define DMA_CTRL_MBRSTCNT_MASK (0x3ff << DMA_CTRL_MBRSTCNT_SHIFT)
++#define DMA_CTRL_DRB (1 << 8)
++#define DMA_CTRL_RESET (1 << 0)
++
++#define DMA_CPOLL_EN (1 << 31)
++#define DMA_CPOLL_CNT_SHIFT 4
++#define DMA_CPOLL_CNT_MASK (0xFFF << DMA_CPOLL_CNT_SHIFT)
++
++#define DMA_CCTRL_TXWGT_SHIFT 16
++#define DMA_CCTRL_TXWGT_MASK (0x3 << DMA_CCTRL_TXWGT_SHIFT)
++#define DMA_CCTRL_CLASS_SHIFT 9
++#define DMA_CCTRL_CLASS_MASK (0x3 << DMA_CCTRL_CLASS_SHIFT)
++#define DMA_CCTRL_RST (1 << 1)
++#define DMA_CCTRL_ONOFF (1 << 0)
++
++#define DMA_PCTRL_TXBL_SHIFT 4
++#define DMA_PCTRL_TXBL_2WORDS (1 << DMA_PCTRL_TXBL_SHIFT)
++#define DMA_PCTRL_TXBL_4WORDS (2 << DMA_PCTRL_TXBL_SHIFT)
++#define DMA_PCTRL_TXBL_8WORDS (3 << DMA_PCTRL_TXBL_SHIFT)
++#define DMA_PCTRL_RXBL_SHIFT 2
++#define DMA_PCTRL_RXBL_2WORDS (1 << DMA_PCTRL_RXBL_SHIFT)
++#define DMA_PCTRL_RXBL_4WORDS (2 << DMA_PCTRL_RXBL_SHIFT)
++#define DMA_PCTRL_RXBL_8WORDS (3 << DMA_PCTRL_RXBL_SHIFT)
++#define DMA_PCTRL_TXENDI_SHIFT 10
++#define DMA_PCTRL_TXENDI_MASK (0x3 << DMA_PCTRL_TXENDI_SHIFT)
++#define DMA_PCTRL_RXENDI_SHIFT 8
++#define DMA_PCTRL_RXENDI_MASK (0x3 << DMA_PCTRL_RXENDI_SHIFT)
++
++#define DMA_DESC_OWN (1 << 31)
++#define DMA_DESC_C (1 << 30)
++#define DMA_DESC_SOP (1 << 29)
++#define DMA_DESC_EOP (1 << 28)
++#define DMA_DESC_TX_OFFSET(x) ((x & 0x1f) << 23)
++#define DMA_DESC_RX_OFFSET(x) ((x & 0x3) << 23)
++#define DMA_DESC_LENGTH(x) (x & 0xffff)
++
++#define PTR_ALIGN(p, a) ((typeof(p))ALIGN((unsigned long)(p), (a)))
++
++struct ltq_dma_regs {
++ u32 clc; /* Clock control */
++ u32 rsvd0;
++ u32 id; /* Identification */
++ u32 rsvd1;
++ u32 ctrl; /* Control */
++ u32 cpoll; /* Channel polling */
++ u32 cs; /* Channel select */
++ u32 cctrl; /* Channel control */
++ u32 cdba; /* Channel descriptor base address */
++ u32 cdlen; /* Channel descriptor length */
++ u32 cis; /* Channel interrupt status */
++ u32 cie; /* Channel interrupt enable */
++ u32 cgbl; /* Channel global buffer length */
++ u32 cdptnrd; /* Current descriptor pointer */
++ u32 rsvd2[2];
++ u32 ps; /* Port select */
++ u32 pctrl; /* Port control */
++ u32 rsvd3[43];
++ u32 irnen; /* Interrupt node enable */
++ u32 irncr; /* Interrupt node control */
++ u32 irnicr; /* Interrupt capture */
++};
++
++static struct ltq_dma_regs *ltq_dma_regs =
++ (struct ltq_dma_regs *) CKSEG1ADDR(LTQ_DMA_BASE);
++
++static inline unsigned long ltq_dma_addr_to_virt(u32 dma_addr)
++{
++ return KSEG0ADDR(dma_addr);
++}
++
++static inline u32 ltq_virt_to_dma_addr(void *addr)
++{
++ return CPHYSADDR(addr);
++}
++
++static inline int ltq_dma_burst_align(enum ltq_dma_burst_len burst_len)
++{
++ switch (burst_len) {
++ case LTQ_DMA_BURST_2WORDS:
++ return 2 * 4;
++ case LTQ_DMA_BURST_4WORDS:
++ return 4 * 4;
++ case LTQ_DMA_BURST_8WORDS:
++ return 8 * 4;
++ }
++
++ return 0;
++}
++
++static inline void ltq_dma_sync(void)
++{
++ __asm__ __volatile__("sync");
++}
++
++static inline void ltq_dma_dcache_wb_inv(const void *ptr, size_t size)
++{
++ unsigned long addr = (unsigned long) ptr;
++
++ flush_dcache_range(addr, addr + size);
++ ltq_dma_sync();
++}
++
++static inline void ltq_dma_dcache_inv(const void *ptr, size_t size)
++{
++ unsigned long addr = (unsigned long) ptr;
++
++ invalidate_dcache_range(addr, addr + size);
++}
++
++void ltq_dma_init(void)
++{
++ /* Power up DMA */
++ ltq_pm_enable(LTQ_PM_DMA);
++
++ /* Reset DMA */
++ ltq_setbits(&ltq_dma_regs->ctrl, DMA_CTRL_RESET);
++
++ /* Disable and clear all interrupts */
++ ltq_writel(&ltq_dma_regs->irnen, 0);
++ ltq_writel(&ltq_dma_regs->irncr, 0xFFFFF);
++
++#if 0
++ /* Enable packet arbitration */
++ ltq_setbits(&ltq_dma_regs->ctrl, DMA_CTRL_PKTARB);
++#endif
++
++#if 0
++ /* Enable descriptor read back */
++ ltq_setbits(&ltq_dma_regs->ctrl, DMA_CTRL_DRB);
++#endif
++
++ /* Enable polling for descriptor fetching for all channels */
++ ltq_writel(&ltq_dma_regs->cpoll, DMA_CPOLL_EN |
++ (4 << DMA_CPOLL_CNT_SHIFT));
++}
++
++static void ltq_dma_channel_reset(struct ltq_dma_channel *chan)
++{
++ ltq_writel(&ltq_dma_regs->cs, chan->chan_no);
++ ltq_setbits(&ltq_dma_regs->cctrl, DMA_CCTRL_RST);
++}
++
++static void ltq_dma_channel_enable(struct ltq_dma_channel *chan)
++{
++ ltq_writel(&ltq_dma_regs->cs, chan->chan_no);
++ ltq_setbits(&ltq_dma_regs->cctrl, DMA_CCTRL_ONOFF);
++}
++
++static void ltq_dma_channel_disable(struct ltq_dma_channel *chan)
++{
++ ltq_writel(&ltq_dma_regs->cs, chan->chan_no);
++ ltq_clrbits(&ltq_dma_regs->cctrl, DMA_CCTRL_ONOFF);
++}
++
++static void ltq_dma_port_init(struct ltq_dma_device *dev)
++{
++ u32 pctrl;
++
++ pctrl = dev->tx_endian_swap << DMA_PCTRL_TXENDI_SHIFT;
++ pctrl |= dev->rx_endian_swap << DMA_PCTRL_RXENDI_SHIFT;
++ pctrl |= dev->tx_burst_len << DMA_PCTRL_TXBL_SHIFT;
++ pctrl |= dev->rx_burst_len << DMA_PCTRL_RXBL_SHIFT;
++
++ ltq_writel(&ltq_dma_regs->ps, dev->port);
++ ltq_writel(&ltq_dma_regs->pctrl, pctrl);
++}
++
++static int ltq_dma_alloc_descriptors(struct ltq_dma_device *dev,
++ struct ltq_dma_channel *chan)
++{
++ size_t size;
++ void *desc_base;
++
++ size = ALIGN(sizeof(struct ltq_dma_desc) * chan->num_desc +
++ ARCH_DMA_MINALIGN, ARCH_DMA_MINALIGN);
++
++ chan->mem_base = malloc(size);
++ if (!chan->mem_base)
++ return 1;
++
++ memset(chan->mem_base, 0, size);
++ ltq_dma_dcache_wb_inv(chan->mem_base, size);
++
++ desc_base = PTR_ALIGN(chan->mem_base, ARCH_DMA_MINALIGN);
++
++ debug("DMA: mem %p, desc %p\n", chan->mem_base, desc_base);
++
++ /* Align descriptor base to 8 bytes */
++ chan->desc_base = (void *) CKSEG1ADDR(desc_base);
++ chan->dma_addr = CPHYSADDR(desc_base);
++ chan->dev = dev;
++
++ debug("DMA: desc_base %p, size %u\n", chan->desc_base, size);
++
++ /* Configure hardware with location of descriptor list */
++ ltq_writel(&ltq_dma_regs->cs, chan->chan_no);
++ ltq_writel(&ltq_dma_regs->cdba, chan->dma_addr);
++ ltq_writel(&ltq_dma_regs->cdlen, chan->num_desc);
++ ltq_writel(&ltq_dma_regs->cctrl, (3 << DMA_CCTRL_TXWGT_SHIFT) |
++ (chan->class << DMA_CCTRL_CLASS_SHIFT));
++ ltq_writel(&ltq_dma_regs->cctrl, DMA_CCTRL_RST);
++
++ return 0;
++}
++
++static void ltq_dma_free_descriptors(struct ltq_dma_channel *chan)
++{
++ ltq_writel(&ltq_dma_regs->cs, chan->chan_no);
++ ltq_writel(&ltq_dma_regs->cdba, 0);
++ ltq_writel(&ltq_dma_regs->cdlen, 0);
++
++ ltq_dma_channel_reset(chan);
++
++ free(chan->mem_base);
++}
++
++int ltq_dma_register(struct ltq_dma_device *dev)
++{
++ int ret;
++
++ ltq_dma_port_init(dev);
++
++ ret = ltq_dma_alloc_descriptors(dev, &dev->rx_chan);
++ if (ret)
++ return ret;
++
++ ret = ltq_dma_alloc_descriptors(dev, &dev->tx_chan);
++ if (ret) {
++ ltq_dma_free_descriptors(&dev->rx_chan);
++ return ret;
++ }
++
++ return 0;
++}
++
++void ltq_dma_reset(struct ltq_dma_device *dev)
++{
++ ltq_dma_channel_reset(&dev->rx_chan);
++ ltq_dma_channel_reset(&dev->tx_chan);
++}
++
++void ltq_dma_enable(struct ltq_dma_device *dev)
++{
++ ltq_dma_channel_enable(&dev->rx_chan);
++ ltq_dma_channel_enable(&dev->tx_chan);
++}
++
++void ltq_dma_disable(struct ltq_dma_device *dev)
++{
++ ltq_dma_channel_disable(&dev->rx_chan);
++ ltq_dma_channel_disable(&dev->tx_chan);
++}
++
++int ltq_dma_rx_map(struct ltq_dma_device *dev, int index, void *data, int len)
++{
++ struct ltq_dma_channel *chan = &dev->rx_chan;
++ struct ltq_dma_desc *desc = &chan->desc_base[index];
++ u32 dma_addr = ltq_virt_to_dma_addr(data);
++ unsigned int offset;
++
++ offset = dma_addr % ltq_dma_burst_align(dev->rx_burst_len);
++
++ ltq_dma_dcache_inv(data, len);
++
++#if 0
++ printf("%s: index %d, data %p, dma_addr %08x, offset %u, len %d\n",
++ __func__, index, data, dma_addr, offset, len);
++#endif
++
++
++ desc->addr = dma_addr - offset;
++ desc->ctl = DMA_DESC_OWN | DMA_DESC_RX_OFFSET(offset) |
++ DMA_DESC_LENGTH(len);
++
++#if 0
++ printf("%s: index %d, desc %p, desc->ctl %08x\n",
++ __func__, index, desc, desc->ctl);
++#endif
++
++ return 0;
++}
++
++int ltq_dma_rx_poll(struct ltq_dma_device *dev, int index)
++{
++ struct ltq_dma_channel *chan = &dev->rx_chan;
++ struct ltq_dma_desc *desc = &chan->desc_base[index];
++
++#if 0
++ printf("%s: index %d, desc %p, desc->ctl %08x\n",
++ __func__, index, desc, desc->ctl);
++#endif
++
++ if (desc->ctl & DMA_DESC_OWN)
++ return 0;
++
++ if (desc->ctl & DMA_DESC_C)
++ return 1;
++
++ return 0;
++}
++
++int ltq_dma_rx_length(struct ltq_dma_device *dev, int index)
++{
++ struct ltq_dma_channel *chan = &dev->rx_chan;
++ struct ltq_dma_desc *desc = &chan->desc_base[index];
++
++ return DMA_DESC_LENGTH(desc->ctl);
++}
++
++int ltq_dma_tx_map(struct ltq_dma_device *dev, int index, void *data, int len,
++ unsigned long timeout)
++{
++ struct ltq_dma_channel *chan = &dev->tx_chan;
++ struct ltq_dma_desc *desc = &chan->desc_base[index];
++ unsigned int offset;
++ unsigned long timebase = get_timer(0);
++ u32 dma_addr = ltq_virt_to_dma_addr(data);
++
++ while (desc->ctl & DMA_DESC_OWN) {
++ WATCHDOG_RESET();
++
++ if (get_timer(timebase) >= timeout) {
++#if 0
++ printf("%s: timeout: index %d, desc %p, desc->ctl %08x\n",
++ __func__, index, desc, desc->ctl);
++#endif
++ return -1;
++ }
++ }
++
++ offset = dma_addr % ltq_dma_burst_align(dev->rx_burst_len);
++
++#if 0
++ printf("%s: index %d, desc %p, data %p, dma_addr %08x, offset %u, len %d\n",
++ __func__, index, desc, data, dma_addr, offset, len);
++#endif
++
++ ltq_dma_dcache_wb_inv(data, len);
++
++ desc->addr = dma_addr - offset;
++ desc->ctl = DMA_DESC_OWN | DMA_DESC_SOP | DMA_DESC_EOP |
++ DMA_DESC_TX_OFFSET(offset) | DMA_DESC_LENGTH(len);
++
++#if 0
++ printf("%s: index %d, desc %p, desc->ctl %08x\n",
++ __func__, index, desc, desc->ctl);
++#endif
++
++ return 0;
++}
++
++int ltq_dma_tx_wait(struct ltq_dma_device *dev, int index,
++ unsigned long timeout)
++{
++ struct ltq_dma_channel *chan = &dev->tx_chan;
++ struct ltq_dma_desc *desc = &chan->desc_base[index];
++ unsigned long timebase = get_timer(0);
++
++ while ((desc->ctl & (DMA_DESC_OWN | DMA_DESC_C)) != DMA_DESC_C) {
++ WATCHDOG_RESET();
++
++ if (get_timer(timebase) >= timeout)
++ return -1;
++ }
++
++ return 0;
++}
+--- a/drivers/gpio/Makefile
++++ b/drivers/gpio/Makefile
+@@ -28,6 +28,7 @@ LIB := $(obj)libgpio.o
+ COBJS-$(CONFIG_AT91_GPIO) += at91_gpio.o
+ COBJS-$(CONFIG_INTEL_ICH6_GPIO) += intel_ich6_gpio.o
+ COBJS-$(CONFIG_KIRKWOOD_GPIO) += kw_gpio.o
++COBJS-$(CONFIG_LANTIQ_GPIO) += lantiq_gpio.o
+ COBJS-$(CONFIG_MARVELL_GPIO) += mvgpio.o
+ COBJS-$(CONFIG_MARVELL_MFP) += mvmfp.o
+ COBJS-$(CONFIG_MXC_GPIO) += mxc_gpio.o
+--- /dev/null
++++ b/drivers/gpio/lantiq_gpio.c
+@@ -0,0 +1,330 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <common.h>
++#include <asm/arch/soc.h>
++#include <asm/arch/gpio.h>
++#include <asm/lantiq/io.h>
++
++#define SSIO_GPIO_BASE 64
++
++#define SSIO_CON0_SWU (1 << 31)
++#define SSIO_CON0_RZFL (1 << 26)
++#define SSIO_CON0_GPHY1_SHIFT 27
++#define SSIO_CON0_GPHY1_CONFIG ((CONFIG_LTQ_SSIO_GPHY1_MODE & 0x7) << 27)
++
++#define SSIO_CON1_US_FPI (2 << 30)
++#define SSIO_CON1_FPID_2HZ (0 << 23)
++#define SSIO_CON1_FPID_4HZ (1 << 23)
++#define SSIO_CON1_FPID_8HZ (2 << 23)
++#define SSIO_CON1_FPID_10HZ (3 << 23)
++#define SSIO_CON1_FPIS_1_2 (1 << 20)
++#define SSIO_CON1_FPIS_1_32 (2 << 20)
++#define SSIO_CON1_FPIS_1_64 (3 << 20)
++
++#define SSIO_CON1_GPHY2_SHIFT 15
++#define SSIO_CON1_GPHY2_CONFIG ((CONFIG_LTQ_SSIO_GPHY2_MODE & 0x7) << 15)
++
++#define SSIO_CON1_GROUP2 (1 << 2)
++#define SSIO_CON1_GROUP1 (1 << 1)
++#define SSIO_CON1_GROUP0 (1 << 0)
++#define SSIO_CON1_GROUP_CONFIG (0x3)
++
++#ifdef CONFIG_LTQ_SSIO_SHIFT_REGS
++#define enable_ssio 1
++#else
++#define enable_ssio 0
++
++#define CONFIG_LTQ_SSIO_GPHY1_MODE 0
++#define CONFIG_LTQ_SSIO_GPHY2_MODE 0
++#define CONFIG_LTQ_SSIO_INIT_VALUE 0
++#endif
++
++#ifdef CONFIG_LTQ_SSIO_EDGE_FALLING
++#define SSIO_RZFL_CONFIG SSIO_CON0_RZFL
++#else
++#define SSIO_RZFL_CONFIG 0
++#endif
++
++struct ltq_gpio_port_regs {
++ __be32 out;
++ __be32 in;
++ __be32 dir;
++ __be32 altsel0;
++ __be32 altsel1;
++ __be32 od;
++ __be32 stoff;
++ __be32 pudsel;
++ __be32 puden;
++ __be32 rsvd1[3];
++};
++
++struct ltq_gpio_regs {
++ u32 rsvd[4];
++ struct ltq_gpio_port_regs ports[CONFIG_LTQ_GPIO_MAX_BANKS];
++};
++
++struct ltq_gpio3_regs {
++ u32 rsvd0[13];
++ __be32 od;
++ __be32 pudsel;
++ __be32 puden;
++ u32 rsvd1[9];
++ __be32 altsel1;
++ u32 rsvd2[14];
++ __be32 out;
++ __be32 in;
++ __be32 dir;
++ __be32 altsel0;
++};
++
++struct ltq_ssio_regs {
++ __be32 con0;
++ __be32 con1;
++ __be32 cpu0;
++ __be32 cpu1;
++ __be32 ar;
++};
++
++static struct ltq_gpio_regs *ltq_gpio_regs =
++ (struct ltq_gpio_regs *) CKSEG1ADDR(LTQ_GPIO_BASE);
++
++static struct ltq_gpio3_regs *ltq_gpio3_regs =
++ (struct ltq_gpio3_regs *) CKSEG1ADDR(LTQ_GPIO_BASE);
++
++static struct ltq_ssio_regs *ltq_ssio_regs =
++ (struct ltq_ssio_regs *) CKSEG1ADDR(LTQ_SSIO_BASE);
++
++static int is_gpio_bank3(unsigned int port)
++{
++#ifdef CONFIG_LTQ_HAS_GPIO_BANK3
++ return port == 3;
++#else
++ return 0;
++#endif
++}
++
++static int is_gpio_ssio(unsigned int gpio)
++{
++#ifdef CONFIG_LTQ_SSIO_SHIFT_REGS
++ return gpio >= SSIO_GPIO_BASE;
++#else
++ return 0;
++#endif
++}
++
++static inline int ssio_gpio_to_bit(unsigned gpio)
++{
++ return 1 << (gpio - SSIO_GPIO_BASE);
++}
++
++int ltq_gpio_init(void)
++{
++ ltq_writel(&ltq_ssio_regs->ar, 0);
++ ltq_writel(&ltq_ssio_regs->cpu0, CONFIG_LTQ_SSIO_INIT_VALUE);
++ ltq_writel(&ltq_ssio_regs->cpu1, 0);
++ ltq_writel(&ltq_ssio_regs->con0, SSIO_CON0_SWU);
++
++ if (enable_ssio) {
++ ltq_writel(&ltq_ssio_regs->con0, SSIO_CON0_GPHY1_CONFIG |
++ SSIO_RZFL_CONFIG);
++ ltq_writel(&ltq_ssio_regs->con1, SSIO_CON1_US_FPI |
++ SSIO_CON1_FPID_8HZ | SSIO_CON1_GPHY2_CONFIG |
++ SSIO_CON1_GROUP_CONFIG);
++ }
++
++ return 0;
++}
++
++int gpio_request(unsigned gpio, const char *label)
++{
++ return 0;
++}
++
++int gpio_free(unsigned gpio)
++{
++ return 0;
++}
++
++int gpio_direction_input(unsigned gpio)
++{
++ unsigned port = gpio_to_port(gpio);
++ const void *gpio_od = &ltq_gpio_regs->ports[port].od;
++ const void *gpio_altsel0 = &ltq_gpio_regs->ports[port].altsel0;
++ const void *gpio_altsel1 = &ltq_gpio_regs->ports[port].altsel1;
++ const void *gpio_dir = &ltq_gpio_regs->ports[port].dir;
++
++ if (is_gpio_ssio(gpio))
++ return 0;
++
++ if (is_gpio_bank3(port)) {
++ gpio_od = &ltq_gpio3_regs->od;
++ gpio_altsel0 = &ltq_gpio3_regs->altsel0;
++ gpio_altsel1 = &ltq_gpio3_regs->altsel1;
++ gpio_dir = &ltq_gpio3_regs->dir;
++ }
++
++ /*
++ * Reset open drain and altsel configs to workaround improper
++ * reset values or unwanted modifications by BootROM
++ */
++ ltq_clrbits(gpio_od, gpio_to_bit(gpio));
++ ltq_clrbits(gpio_altsel0, gpio_to_bit(gpio));
++ ltq_clrbits(gpio_altsel1, gpio_to_bit(gpio));
++
++ /* Switch to input */
++ ltq_clrbits(gpio_dir, gpio_to_bit(gpio));
++
++ return 0;
++}
++
++int gpio_direction_output(unsigned gpio, int value)
++{
++ unsigned port = gpio_to_port(gpio);
++ const void *gpio_od = &ltq_gpio_regs->ports[port].od;
++ const void *gpio_altsel0 = &ltq_gpio_regs->ports[port].altsel0;
++ const void *gpio_altsel1 = &ltq_gpio_regs->ports[port].altsel1;
++ const void *gpio_dir = &ltq_gpio_regs->ports[port].dir;
++ const void *gpio_out = &ltq_gpio_regs->ports[port].out;
++ u32 data = gpio_to_bit(gpio);
++
++ if (is_gpio_ssio(gpio)) {
++ data = ssio_gpio_to_bit(gpio);
++ if (value)
++ ltq_setbits(&ltq_ssio_regs->cpu0, data);
++ else
++ ltq_clrbits(&ltq_ssio_regs->cpu0, data);
++
++ return 0;
++ }
++
++ if (is_gpio_bank3(port)) {
++ gpio_od = &ltq_gpio3_regs->od;
++ gpio_altsel0 = &ltq_gpio3_regs->altsel0;
++ gpio_altsel1 = &ltq_gpio3_regs->altsel1;
++ gpio_dir = &ltq_gpio3_regs->dir;
++ gpio_out = &ltq_gpio3_regs->out;
++ }
++
++ /*
++ * Reset open drain and altsel configs to workaround improper
++ * reset values or unwanted modifications by BootROM
++ */
++ ltq_setbits(gpio_od, data);
++ ltq_clrbits(gpio_altsel0, data);
++ ltq_clrbits(gpio_altsel1, data);
++
++ if (value)
++ ltq_setbits(gpio_out, data);
++ else
++ ltq_clrbits(gpio_out, data);
++
++ /* Switch to output */
++ ltq_setbits(gpio_dir, data);
++
++ return 0;
++}
++
++int gpio_get_value(unsigned gpio)
++{
++ unsigned port = gpio_to_port(gpio);
++ const void *gpio_in = &ltq_gpio_regs->ports[port].in;
++ u32 data = gpio_to_bit(gpio);
++ u32 val;
++
++ if (is_gpio_ssio(gpio)) {
++ gpio_in = &ltq_ssio_regs->cpu0;
++ data = ssio_gpio_to_bit(gpio);
++ }
++
++ if (is_gpio_bank3(port))
++ gpio_in = &ltq_gpio3_regs->in;
++
++ val = ltq_readl(gpio_in);
++
++ return !!(val & data);
++}
++
++int gpio_set_value(unsigned gpio, int value)
++{
++ unsigned port = gpio_to_port(gpio);
++ const void *gpio_out = &ltq_gpio_regs->ports[port].out;
++ u32 data = gpio_to_bit(gpio);
++
++ if (is_gpio_ssio(gpio)) {
++ gpio_out = &ltq_ssio_regs->cpu0;
++ data = ssio_gpio_to_bit(gpio);
++ }
++
++ if (is_gpio_bank3(port))
++ gpio_out = &ltq_gpio3_regs->out;
++
++ if (value)
++ ltq_setbits(gpio_out, data);
++ else
++ ltq_clrbits(gpio_out, data);
++
++ return 0;
++}
++
++int gpio_set_altfunc(unsigned gpio, int altsel0, int altsel1, int dir)
++{
++ unsigned port = gpio_to_port(gpio);
++ const void *gpio_od = &ltq_gpio_regs->ports[port].od;
++ const void *gpio_altsel0 = &ltq_gpio_regs->ports[port].altsel0;
++ const void *gpio_altsel1 = &ltq_gpio_regs->ports[port].altsel1;
++ const void *gpio_dir = &ltq_gpio_regs->ports[port].dir;
++
++ if (is_gpio_ssio(gpio))
++ return 0;
++
++ if (is_gpio_bank3(port)) {
++ gpio_od = &ltq_gpio3_regs->od;
++ gpio_altsel0 = &ltq_gpio3_regs->altsel0;
++ gpio_altsel1 = &ltq_gpio3_regs->altsel1;
++ gpio_dir = &ltq_gpio3_regs->dir;
++ }
++
++ if (altsel0)
++ ltq_setbits(gpio_altsel0, gpio_to_bit(gpio));
++ else
++ ltq_clrbits(gpio_altsel0, gpio_to_bit(gpio));
++
++ if (altsel1)
++ ltq_setbits(gpio_altsel1, gpio_to_bit(gpio));
++ else
++ ltq_clrbits(gpio_altsel1, gpio_to_bit(gpio));
++
++ if (dir) {
++ ltq_setbits(gpio_od, gpio_to_bit(gpio));
++ ltq_setbits(gpio_dir, gpio_to_bit(gpio));
++ } else {
++ ltq_clrbits(gpio_od, gpio_to_bit(gpio));
++ ltq_clrbits(gpio_dir, gpio_to_bit(gpio));
++ }
++
++ return 0;
++}
++
++int gpio_set_opendrain(unsigned gpio, int od)
++{
++ unsigned port = gpio_to_port(gpio);
++ const void *gpio_od = &ltq_gpio_regs->ports[port].od;
++
++ if (is_gpio_ssio(gpio))
++ return 0;
++
++ if (is_gpio_bank3(port))
++ gpio_od = &ltq_gpio3_regs->od;
++
++ if (od)
++ ltq_setbits(gpio_od, gpio_to_bit(gpio));
++ else
++ ltq_clrbits(gpio_od, gpio_to_bit(gpio));
++
++ return 0;
++}
+--- a/drivers/mtd/cfi_flash.c
++++ b/drivers/mtd/cfi_flash.c
+@@ -177,6 +177,18 @@ u64 flash_read64(void *addr)__attribute_
+ #define flash_read64 __flash_read64
+ #endif
+
++static inline void *__flash_swap_addr(unsigned long addr)
++{
++ return (void *) addr;
++}
++
++#ifdef CONFIG_CFI_FLASH_USE_WEAK_ADDR_SWAP
++void *flash_swap_addr(unsigned long addr)
++ __attribute__((weak, alias("__flash_swap_addr")));
++#else
++#define flash_swap_addr __flash_swap_addr
++#endif
++
+ /*-----------------------------------------------------------------------
+ */
+ #if defined(CONFIG_ENV_IS_IN_FLASH) || defined(CONFIG_ENV_ADDR_REDUND) || (CONFIG_SYS_MONITOR_BASE >= CONFIG_SYS_FLASH_BASE)
+@@ -212,7 +224,7 @@ flash_map (flash_info_t * info, flash_se
+ {
+ unsigned int byte_offset = offset * info->portwidth;
+
+- return (void *)(info->start[sect] + byte_offset);
++ return flash_swap_addr(info->start[sect] + byte_offset);
+ }
+
+ static inline void flash_unmap(flash_info_t *info, flash_sect_t sect,
+--- a/drivers/mtd/nand/Makefile
++++ b/drivers/mtd/nand/Makefile
+@@ -67,6 +67,7 @@ COBJS-$(CONFIG_NAND_JZ4740) += jz4740_na
+ COBJS-$(CONFIG_NAND_KB9202) += kb9202_nand.o
+ COBJS-$(CONFIG_NAND_KIRKWOOD) += kirkwood_nand.o
+ COBJS-$(CONFIG_NAND_KMETER1) += kmeter1_nand.o
++COBJS-$(CONFIG_NAND_LANTIQ) += lantiq_nand.o
+ COBJS-$(CONFIG_NAND_MPC5121_NFC) += mpc5121_nfc.o
+ COBJS-$(CONFIG_NAND_MXC) += mxc_nand.o
+ COBJS-$(CONFIG_NAND_MXS) += mxs_nand.o
+--- /dev/null
++++ b/drivers/mtd/nand/lantiq_nand.c
+@@ -0,0 +1,127 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2012 Daniel Schwierzeck, daniel.schwierzeck@gmail.com
++ */
++
++#include <common.h>
++#include <linux/mtd/nand.h>
++#include <linux/compiler.h>
++#include <asm/arch/soc.h>
++#include <asm/arch/nand.h>
++#include <asm/lantiq/io.h>
++
++#define NAND_CON_ECC_ON (1 << 31)
++#define NAND_CON_LATCH_PRE (1 << 23)
++#define NAND_CON_LATCH_WP (1 << 22)
++#define NAND_CON_LATCH_SE (1 << 21)
++#define NAND_CON_LATCH_CS (1 << 20)
++#define NAND_CON_LATCH_CLE (1 << 19)
++#define NAND_CON_LATCH_ALE (1 << 18)
++#define NAND_CON_OUT_CS1 (1 << 10)
++#define NAND_CON_IN_CS1 (1 << 8)
++#define NAND_CON_PRE_P (1 << 7)
++#define NAND_CON_WP_P (1 << 6)
++#define NAND_CON_SE_P (1 << 5)
++#define NAND_CON_CS_P (1 << 4)
++#define NAND_CON_CLE_P (1 << 3)
++#define NAND_CON_ALE_P (1 << 2)
++#define NAND_CON_CSMUX (1 << 1)
++#define NAND_CON_NANDM (1 << 0)
++
++#define NAND_WAIT_WR_C (1 << 3)
++#define NAND_WAIT_RDBY (1 << 0)
++
++#define NAND_CMD_ALE (1 << 2)
++#define NAND_CMD_CLE (1 << 3)
++#define NAND_CMD_CS (1 << 4)
++#define NAND_CMD_SE (1 << 5)
++#define NAND_CMD_WP (1 << 6)
++#define NAND_CMD_PRE (1 << 7)
++
++struct ltq_nand_regs {
++ __be32 con; /* NAND controller control */
++ __be32 wait; /* NAND Flash Device RD/BY State */
++ __be32 ecc0; /* NAND Flash ECC Register 0 */
++ __be32 ecc_ac; /* NAND Flash ECC Register address counter */
++ __be32 ecc_cr; /* NAND Flash ECC Comparison */
++};
++
++static struct ltq_nand_regs *ltq_nand_regs =
++ (struct ltq_nand_regs *) CKSEG1ADDR(LTQ_EBU_NAND_BASE);
++
++static void ltq_nand_wait_ready(void)
++{
++ while ((ltq_readl(&ltq_nand_regs->wait) & NAND_WAIT_WR_C) == 0)
++ ;
++}
++
++static int ltq_nand_dev_ready(struct mtd_info *mtd)
++{
++ u32 data = ltq_readl(&ltq_nand_regs->wait);
++ return data & NAND_WAIT_RDBY;
++}
++
++static void ltq_nand_select_chip(struct mtd_info *mtd, int chip)
++{
++ if (chip == 0) {
++ ltq_setbits(&ltq_nand_regs->con, NAND_CON_NANDM);
++ ltq_setbits(&ltq_nand_regs->con, NAND_CON_LATCH_CS);
++ } else {
++ ltq_clrbits(&ltq_nand_regs->con, NAND_CON_LATCH_CS);
++ ltq_clrbits(&ltq_nand_regs->con, NAND_CON_NANDM);
++ }
++}
++
++static void ltq_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
++{
++ struct nand_chip *chip = mtd->priv;
++ unsigned long addr = (unsigned long) chip->IO_ADDR_W;
++
++ if (ctrl & NAND_CTRL_CHANGE) {
++ if (ctrl & NAND_ALE)
++ addr |= NAND_CMD_ALE;
++ else
++ addr &= ~NAND_CMD_ALE;
++
++ if (ctrl & NAND_CLE)
++ addr |= NAND_CMD_CLE;
++ else
++ addr &= ~NAND_CMD_CLE;
++
++ chip->IO_ADDR_W = (void __iomem *) addr;
++ }
++
++ if (cmd != NAND_CMD_NONE) {
++ writeb(cmd, chip->IO_ADDR_W);
++ ltq_nand_wait_ready();
++ }
++}
++
++int ltq_nand_init(struct nand_chip *nand)
++{
++ /* Enable NAND, set NAND CS to EBU CS1, enable EBU CS mux */
++ ltq_writel(&ltq_nand_regs->con, NAND_CON_OUT_CS1 | NAND_CON_IN_CS1 |
++ NAND_CON_PRE_P | NAND_CON_WP_P | NAND_CON_SE_P |
++ NAND_CON_CS_P | NAND_CON_CSMUX);
++
++ nand->dev_ready = ltq_nand_dev_ready;
++ nand->select_chip = ltq_nand_select_chip;
++ nand->cmd_ctrl = ltq_nand_cmd_ctrl;
++
++ nand->chip_delay = 30;
++ nand->options = 0;
++ nand->ecc.mode = NAND_ECC_SOFT;
++
++ /* Enable CS bit in address offset */
++ nand->IO_ADDR_R = nand->IO_ADDR_R + NAND_CMD_CS;
++ nand->IO_ADDR_W = nand->IO_ADDR_W + NAND_CMD_CS;
++
++ return 0;
++}
++
++__weak int board_nand_init(struct nand_chip *chip)
++{
++ return ltq_nand_init(chip);
++}
+--- a/drivers/net/Makefile
++++ b/drivers/net/Makefile
+@@ -51,6 +51,8 @@ COBJS-$(CONFIG_GRETH) += greth.o
+ COBJS-$(CONFIG_INCA_IP_SWITCH) += inca-ip_sw.o
+ COBJS-$(CONFIG_DRIVER_KS8695ETH) += ks8695eth.o
+ COBJS-$(CONFIG_LAN91C96) += lan91c96.o
++COBJS-$(CONFIG_LANTIQ_DANUBE_ETOP) += lantiq_danube_etop.o
++COBJS-$(CONFIG_LANTIQ_VRX200_SWITCH) += lantiq_vrx200_switch.o
+ COBJS-$(CONFIG_MACB) += macb.o
+ COBJS-$(CONFIG_MCFFEC) += mcffec.o mcfmii.o
+ COBJS-$(CONFIG_MPC5xxx_FEC) += mpc5xxx_fec.o
+--- /dev/null
++++ b/drivers/net/lantiq_danube_etop.c
+@@ -0,0 +1,411 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <common.h>
++#include <malloc.h>
++#include <netdev.h>
++#include <miiphy.h>
++#include <switch.h>
++#include <asm/lantiq/io.h>
++#include <asm/lantiq/eth.h>
++#include <asm/lantiq/pm.h>
++#include <asm/lantiq/reset.h>
++#include <asm/lantiq/dma.h>
++#include <asm/arch/soc.h>
++
++#define LTQ_PPE_ETOP_MDIO_ACC_RA (1 << 31)
++#define LTQ_PPE_ETOP_MDIO_CFG_UMM1 (1 << 2)
++#define LTQ_PPE_ETOP_MDIO_CFG_UMM0 (1 << 1)
++
++#define LTQ_PPE_ETOP_CFG_TCKINV1 (1 << 11)
++#define LTQ_PPE_ETOP_CFG_TCKINV0 (1 << 10)
++#define LTQ_PPE_ETOP_CFG_FEN1 (1 << 9)
++#define LTQ_PPE_ETOP_CFG_FEN0 (1 << 8)
++#define LTQ_PPE_ETOP_CFG_SEN1 (1 << 7)
++#define LTQ_PPE_ETOP_CFG_SEN0 (1 << 6)
++#define LTQ_PPE_ETOP_CFG_TURBO1 (1 << 5)
++#define LTQ_PPE_ETOP_CFG_REMII1 (1 << 4)
++#define LTQ_PPE_ETOP_CFG_OFF1 (1 << 3)
++#define LTQ_PPE_ETOP_CFG_TURBO0 (1 << 2)
++#define LTQ_PPE_ETOP_CFG_REMII0 (1 << 1)
++#define LTQ_PPE_ETOP_CFG_OFF0 (1 << 0)
++
++#define LTQ_PPE_ENET0_MAC_CFG_CGEN (1 << 11)
++#define LTQ_PPE_ENET0_MAC_CFG_DUPLEX (1 << 2)
++#define LTQ_PPE_ENET0_MAC_CFG_SPEED (1 << 1)
++#define LTQ_PPE_ENET0_MAC_CFG_LINK (1 << 0)
++
++#define LTQ_PPE_ENETS0_CFG_FTUC (1 << 28)
++
++#define LTQ_ETH_RX_BUFFER_CNT PKTBUFSRX
++#define LTQ_ETH_TX_BUFFER_CNT 8
++#define LTQ_ETH_RX_DATA_SIZE PKTSIZE_ALIGN
++#define LTQ_ETH_IP_ALIGN 2
++
++#define LTQ_MDIO_DRV_NAME "ltq-mdio"
++#define LTQ_ETH_DRV_NAME "ltq-eth"
++
++struct ltq_ppe_etop_regs {
++ u32 mdio_cfg; /* MDIO configuration */
++ u32 mdio_acc; /* MDIO access */
++ u32 cfg; /* ETOP configuration */
++ u32 ig_vlan_cos; /* IG VLAN priority CoS mapping */
++ u32 ig_dscp_cos3; /* IG DSCP CoS mapping 3 */
++ u32 ig_dscp_cos2; /* IG DSCP CoS mapping 2 */
++ u32 ig_dscp_cos1; /* IG DSCP CoS mapping 1 */
++ u32 ig_dscp_cos0; /* IG DSCP CoS mapping 0 */
++ u32 ig_plen_ctrl; /* IG frame length control */
++ u32 rsvd0[3];
++ u32 vpid; /* VLAN protocol ID */
++};
++
++struct ltq_ppe_enet_regs {
++ u32 mac_cfg; /* MAC configuration */
++ u32 rsvd0[3];
++ u32 ig_cfg; /* Ingress configuration */
++ u32 ig_pgcnt; /* Ingress buffer used page count */
++ u32 rsvd1;
++ u32 ig_buf_ctrl; /* Ingress buffer backpressure ctrl */
++ u32 cos_cfg; /* Classification configuration */
++ u32 ig_drop; /* Total ingress drop frames */
++ u32 ig_err; /* Total ingress error frames */
++ u32 mac_da0; /* Ingress MAC address 0 */
++ u32 mac_da1; /* Ingress MAC address 1 */
++ u32 rsvd2[22];
++ u32 pgcnt; /* Page counter */
++ u32 rsvd3;
++ u32 hf_ctrl; /* Half duplex control */
++ u32 tx_ctrl; /* Transmit control */
++ u32 rsvd4;
++ u32 vlcos0; /* VLAN insertion config CoS 0 */
++ u32 vlcos1; /* VLAN insertion config CoS 1 */
++ u32 vlcos2; /* VLAN insertion config CoS 2 */
++ u32 vlcos3; /* VLAN insertion config CoS 3 */
++ u32 eg_col; /* Total egress collision frames */
++ u32 eg_drop; /* Total egress drop frames */
++};
++
++struct ltq_eth_priv {
++ struct ltq_dma_device dma_dev;
++ struct mii_dev *bus;
++ struct eth_device *dev;
++ int rx_num;
++ int tx_num;
++};
++
++struct ltq_mdio_access {
++ union {
++ struct {
++ unsigned ra:1;
++ unsigned rw:1;
++ unsigned rsvd:4;
++ unsigned phya:5;
++ unsigned rega:5;
++ unsigned phyd:16;
++ } reg;
++ u32 val;
++ };
++};
++
++static struct ltq_ppe_etop_regs *ltq_ppe_etop_regs =
++ (struct ltq_ppe_etop_regs *) CKSEG1ADDR(LTQ_PPE_ETOP_BASE);
++
++static struct ltq_ppe_enet_regs *ltq_ppe_enet0_regs =
++ (struct ltq_ppe_enet_regs *) CKSEG1ADDR(LTQ_PPE_ENET0_BASE);
++
++static inline int ltq_mdio_poll(void)
++{
++ struct ltq_mdio_access acc;
++ unsigned cnt = 10000;
++
++ while (likely(cnt--)) {
++ acc.val = ltq_readl(&ltq_ppe_etop_regs->mdio_acc);
++ if (!acc.reg.ra)
++ return 0;
++ }
++
++ return 1;
++}
++
++static int ltq_mdio_read(struct mii_dev *bus, int addr, int dev_addr,
++ int regnum)
++{
++ struct ltq_mdio_access acc;
++ int ret;
++
++ acc.val = 0;
++ acc.reg.ra = 1;
++ acc.reg.rw = 1;
++ acc.reg.phya = addr;
++ acc.reg.rega = regnum;
++
++ ret = ltq_mdio_poll();
++ if (ret)
++ return ret;
++
++ ltq_writel(&ltq_ppe_etop_regs->mdio_acc, acc.val);
++
++ ret = ltq_mdio_poll();
++ if (ret)
++ return ret;
++
++ acc.val = ltq_readl(&ltq_ppe_etop_regs->mdio_acc);
++
++ return acc.reg.phyd;
++}
++
++static int ltq_mdio_write(struct mii_dev *bus, int addr, int dev_addr,
++ int regnum, u16 val)
++{
++ struct ltq_mdio_access acc;
++ int ret;
++
++ acc.val = 0;
++ acc.reg.ra = 1;
++ acc.reg.rw = 0;
++ acc.reg.phya = addr;
++ acc.reg.rega = regnum;
++ acc.reg.phyd = val;
++
++ ret = ltq_mdio_poll();
++ if (ret)
++ return ret;
++
++ ltq_writel(&ltq_ppe_etop_regs->mdio_acc, acc.val);
++
++ return 0;
++}
++
++static inline void ltq_eth_write_hwaddr(const struct eth_device *dev)
++{
++ u32 da0, da1;
++
++ da0 = (dev->enetaddr[0] << 24) + (dev->enetaddr[1] << 16) +
++ (dev->enetaddr[2] << 8) + dev->enetaddr[3];
++ da1 = (dev->enetaddr[4] << 24) + (dev->enetaddr[5] << 16);
++
++ ltq_writel(&ltq_ppe_enet0_regs->mac_da0, da0);
++ ltq_writel(&ltq_ppe_enet0_regs->mac_da1, da1);
++}
++
++static inline u8 *ltq_eth_rx_packet_align(int rx_num)
++{
++ u8 *packet = (u8 *) NetRxPackets[rx_num];
++
++ /*
++ * IP header needs
++ */
++ return packet + LTQ_ETH_IP_ALIGN;
++}
++
++static int ltq_eth_init(struct eth_device *dev, bd_t *bis)
++{
++ struct ltq_eth_priv *priv = dev->priv;
++ struct ltq_dma_device *dma_dev = &priv->dma_dev;
++ int i;
++
++ ltq_eth_write_hwaddr(dev);
++
++ for (i = 0; i < LTQ_ETH_RX_BUFFER_CNT; i++)
++ ltq_dma_rx_map(dma_dev, i, ltq_eth_rx_packet_align(i),
++ LTQ_ETH_RX_DATA_SIZE);
++
++ ltq_dma_enable(dma_dev);
++
++ priv->rx_num = 0;
++ priv->tx_num = 0;
++
++ return 0;
++}
++
++static void ltq_eth_halt(struct eth_device *dev)
++{
++ struct ltq_eth_priv *priv = dev->priv;
++ struct ltq_dma_device *dma_dev = &priv->dma_dev;
++
++ ltq_dma_reset(dma_dev);
++}
++
++static int ltq_eth_send(struct eth_device *dev, void *packet, int length)
++{
++ struct ltq_eth_priv *priv = dev->priv;
++ struct ltq_dma_device *dma_dev = &priv->dma_dev;
++ int err;
++
++ /* Minimum payload length w/ CRC is 60 bytes */
++ if (length < 60)
++ length = 60;
++
++ err = ltq_dma_tx_map(dma_dev, priv->tx_num, packet, length, 10);
++ if (err) {
++ puts("NET: timeout on waiting for TX descriptor\n");
++ return -1;
++ }
++
++ priv->tx_num = (priv->tx_num + 1) % LTQ_ETH_TX_BUFFER_CNT;
++
++ return err;
++}
++
++static int ltq_eth_recv(struct eth_device *dev)
++{
++ struct ltq_eth_priv *priv = dev->priv;
++ struct ltq_dma_device *dma_dev = &priv->dma_dev;
++ u8 *packet;
++ int len;
++
++ if (!ltq_dma_rx_poll(dma_dev, priv->rx_num))
++ return 0;
++
++#if 0
++ printf("%s: rx_num %d\n", __func__, priv->rx_num);
++#endif
++
++ len = ltq_dma_rx_length(dma_dev, priv->rx_num);
++ packet = ltq_eth_rx_packet_align(priv->rx_num);
++
++#if 0
++ printf("%s: received: packet %p, len %u, rx_num %d\n",
++ __func__, packet, len, priv->rx_num);
++#endif
++
++ if (len)
++ NetReceive(packet, len);
++
++ ltq_dma_rx_map(dma_dev, priv->rx_num, packet,
++ LTQ_ETH_RX_DATA_SIZE);
++
++ priv->rx_num = (priv->rx_num + 1) % LTQ_ETH_RX_BUFFER_CNT;
++
++ return 0;
++}
++
++static void ltq_eth_hw_init(const struct ltq_eth_port_config *port)
++{
++ u32 data;
++
++ /* Power up ethernet subsystems */
++ ltq_pm_enable(LTQ_PM_ETH);
++
++ /* Reset ethernet subsystems */
++ ltq_reset_once(LTQ_RESET_ETH, 1);
++
++ /* Disable MDIO auto-detection */
++ ltq_clrbits(&ltq_ppe_etop_regs->mdio_cfg, LTQ_PPE_ETOP_MDIO_CFG_UMM1 |
++ LTQ_PPE_ETOP_MDIO_CFG_UMM0);
++
++ /* Enable CRC generation, Full Duplex, 100Mbps, Link up */
++ ltq_writel(&ltq_ppe_enet0_regs->mac_cfg, LTQ_PPE_ENET0_MAC_CFG_CGEN |
++ LTQ_PPE_ENET0_MAC_CFG_DUPLEX |
++ LTQ_PPE_ENET0_MAC_CFG_SPEED |
++ LTQ_PPE_ENET0_MAC_CFG_LINK);
++
++ /* Reset ETOP cfg and disable all */
++ data = LTQ_PPE_ETOP_CFG_OFF0 | LTQ_PPE_ETOP_CFG_OFF1;
++
++ /* Enable ENET0, enable store and fetch */
++ data &= ~LTQ_PPE_ETOP_CFG_OFF0;
++ data |= LTQ_PPE_ETOP_CFG_SEN0 | LTQ_PPE_ETOP_CFG_FEN0;
++
++ if (port->phy_if == PHY_INTERFACE_MODE_RMII)
++ data |= LTQ_PPE_ETOP_CFG_REMII0;
++ else
++ data &= ~LTQ_PPE_ETOP_CFG_REMII0;
++
++ ltq_writel(&ltq_ppe_etop_regs->cfg, data);
++
++ /* Set allowed packet length from 64 bytes to 1518 bytes */
++ ltq_writel(&ltq_ppe_etop_regs->ig_plen_ctrl, (64 << 16) | 1518);
++
++ /* Enable filter for unicast packets */
++ ltq_setbits(&ltq_ppe_enet0_regs->ig_cfg, LTQ_PPE_ENETS0_CFG_FTUC);
++}
++
++int ltq_eth_initialize(const struct ltq_eth_board_config *board_config)
++{
++ struct eth_device *dev;
++ struct mii_dev *bus;
++ struct ltq_eth_priv *priv;
++ struct ltq_dma_device *dma_dev;
++ const struct ltq_eth_port_config *port = &board_config->ports[0];
++ struct phy_device *phy;
++ struct switch_device *sw;
++ int ret;
++
++ ltq_dma_init();
++ ltq_eth_hw_init(port);
++
++ dev = calloc(1, sizeof(*dev));
++ if (!dev)
++ return -1;
++
++ priv = calloc(1, sizeof(*priv));
++ if (!priv)
++ return -1;
++
++ bus = mdio_alloc();
++ if (!bus)
++ return -1;
++
++ sprintf(dev->name, LTQ_ETH_DRV_NAME);
++ dev->priv = priv;
++ dev->init = ltq_eth_init;
++ dev->halt = ltq_eth_halt;
++ dev->recv = ltq_eth_recv;
++ dev->send = ltq_eth_send;
++
++ sprintf(bus->name, LTQ_MDIO_DRV_NAME);
++ bus->read = ltq_mdio_read;
++ bus->write = ltq_mdio_write;
++ bus->priv = priv;
++
++ dma_dev = &priv->dma_dev;
++ dma_dev->port = 0;
++ dma_dev->rx_chan.chan_no = 6;
++ dma_dev->rx_chan.class = 3;
++ dma_dev->rx_chan.num_desc = LTQ_ETH_RX_BUFFER_CNT;
++ dma_dev->rx_endian_swap = LTQ_DMA_ENDIANESS_B3_B2_B1_B0;
++ dma_dev->rx_burst_len = LTQ_DMA_BURST_2WORDS;
++ dma_dev->tx_chan.chan_no = 7;
++ dma_dev->tx_chan.class = 3;
++ dma_dev->tx_chan.num_desc = LTQ_ETH_TX_BUFFER_CNT;
++ dma_dev->tx_endian_swap = LTQ_DMA_ENDIANESS_B3_B2_B1_B0;
++ dma_dev->tx_burst_len = LTQ_DMA_BURST_2WORDS;
++
++ priv->bus = bus;
++ priv->dev = dev;
++
++ ret = ltq_dma_register(dma_dev);
++ if (ret)
++ return ret;
++
++ ret = mdio_register(bus);
++ if (ret)
++ return ret;
++
++ ret = eth_register(dev);
++ if (ret)
++ return ret;
++
++ if (port->flags & LTQ_ETH_PORT_SWITCH) {
++ sw = switch_connect(bus);
++ if (!sw)
++ return -1;
++
++ switch_setup(sw);
++ }
++
++ if (port->flags & LTQ_ETH_PORT_PHY) {
++ phy = phy_connect(bus, port->phy_addr, dev, port->phy_if);
++ if (!phy)
++ return -1;
++
++ phy_config(phy);
++ }
++
++ return 0;
++}
+--- /dev/null
++++ b/drivers/net/lantiq_vrx200_switch.c
+@@ -0,0 +1,676 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2010-2011 Lantiq Deutschland GmbH
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#define DEBUG
++
++#include <common.h>
++#include <malloc.h>
++#include <netdev.h>
++#include <miiphy.h>
++#include <linux/compiler.h>
++#include <asm/gpio.h>
++#include <asm/processor.h>
++#include <asm/lantiq/io.h>
++#include <asm/lantiq/eth.h>
++#include <asm/lantiq/pm.h>
++#include <asm/lantiq/reset.h>
++#include <asm/lantiq/dma.h>
++#include <asm/arch/soc.h>
++#include <asm/arch/switch.h>
++
++#define LTQ_ETH_RX_BUFFER_CNT PKTBUFSRX
++#define LTQ_ETH_TX_BUFFER_CNT 8
++#define LTQ_ETH_RX_DATA_SIZE PKTSIZE_ALIGN
++#define LTQ_ETH_IP_ALIGN 2
++
++#define LTQ_MDIO_DRV_NAME "ltq-mdio"
++#define LTQ_ETH_DRV_NAME "ltq-eth"
++
++#define LTQ_ETHSW_MAX_GMAC 6
++#define LTQ_ETHSW_PMAC 6
++
++struct ltq_mdio_phy_addr_reg {
++ union {
++ struct {
++ unsigned rsvd:1;
++ unsigned lnkst:2; /* Link status control */
++ unsigned speed:2; /* Speed control */
++ unsigned fdup:2; /* Full duplex control */
++ unsigned fcontx:2; /* Flow control mode TX */
++ unsigned fconrx:2; /* Flow control mode RX */
++ unsigned addr:5; /* PHY address */
++ } bits;
++ u16 val;
++ };
++};
++
++enum ltq_mdio_phy_addr_lnkst {
++ LTQ_MDIO_PHY_ADDR_LNKST_AUTO = 0,
++ LTQ_MDIO_PHY_ADDR_LNKST_UP = 1,
++ LTQ_MDIO_PHY_ADDR_LNKST_DOWN = 2,
++};
++
++enum ltq_mdio_phy_addr_speed {
++ LTQ_MDIO_PHY_ADDR_SPEED_M10 = 0,
++ LTQ_MDIO_PHY_ADDR_SPEED_M100 = 1,
++ LTQ_MDIO_PHY_ADDR_SPEED_G1 = 2,
++ LTQ_MDIO_PHY_ADDR_SPEED_AUTO = 3,
++};
++
++enum ltq_mdio_phy_addr_fdup {
++ LTQ_MDIO_PHY_ADDR_FDUP_AUTO = 0,
++ LTQ_MDIO_PHY_ADDR_FDUP_ENABLE = 1,
++ LTQ_MDIO_PHY_ADDR_FDUP_DISABLE = 3,
++};
++
++enum ltq_mdio_phy_addr_fcon {
++ LTQ_MDIO_PHY_ADDR_FCON_AUTO = 0,
++ LTQ_MDIO_PHY_ADDR_FCON_ENABLE = 1,
++ LTQ_MDIO_PHY_ADDR_FCON_DISABLE = 3,
++};
++
++struct ltq_mii_mii_cfg_reg {
++ union {
++ struct {
++ unsigned res:1; /* Hardware reset */
++ unsigned en:1; /* xMII interface enable */
++ unsigned isol:1; /* xMII interface isolate */
++ unsigned ldclkdis:1; /* Link down clock disable */
++ unsigned rsvd:1;
++ unsigned crs:2; /* CRS sensitivity config */
++ unsigned rgmii_ibs:1; /* RGMII In Band status */
++ unsigned rmii:1; /* RMII ref clock direction */
++ unsigned miirate:3; /* xMII interface clock rate */
++ unsigned miimode:4; /* xMII interface mode */
++ } bits;
++ u16 val;
++ };
++};
++
++enum ltq_mii_mii_cfg_miirate {
++ LTQ_MII_MII_CFG_MIIRATE_M2P5 = 0,
++ LTQ_MII_MII_CFG_MIIRATE_M25 = 1,
++ LTQ_MII_MII_CFG_MIIRATE_M125 = 2,
++ LTQ_MII_MII_CFG_MIIRATE_M50 = 3,
++ LTQ_MII_MII_CFG_MIIRATE_AUTO = 4,
++};
++
++enum ltq_mii_mii_cfg_miimode {
++ LTQ_MII_MII_CFG_MIIMODE_MIIP = 0,
++ LTQ_MII_MII_CFG_MIIMODE_MIIM = 1,
++ LTQ_MII_MII_CFG_MIIMODE_RMIIP = 2,
++ LTQ_MII_MII_CFG_MIIMODE_RMIIM = 3,
++ LTQ_MII_MII_CFG_MIIMODE_RGMII = 4,
++};
++
++struct ltq_eth_priv {
++ struct ltq_dma_device dma_dev;
++ struct mii_dev *bus;
++ struct eth_device *dev;
++ struct phy_device *phymap[LTQ_ETHSW_MAX_GMAC];
++ int rx_num;
++ int tx_num;
++};
++
++static struct vr9_switch_regs *switch_regs =
++ (struct vr9_switch_regs *) CKSEG1ADDR(LTQ_SWITCH_BASE);
++
++static inline void vr9_switch_sync(void)
++{
++ __asm__("sync");
++}
++
++static inline int vr9_switch_mdio_is_busy(void)
++{
++ u32 mdio_ctrl = ltq_readl(&switch_regs->mdio.mdio_ctrl);
++
++ return mdio_ctrl & MDIO_CTRL_MBUSY;
++}
++
++static inline void vr9_switch_mdio_poll(void)
++{
++ while (vr9_switch_mdio_is_busy())
++ cpu_relax();
++}
++
++static int vr9_switch_mdio_read(struct mii_dev *bus, int phyad, int devad,
++ int regad)
++{
++ u32 mdio_ctrl;
++ int retval;
++
++ mdio_ctrl = MDIO_CTRL_OP_READ |
++ ((phyad << MDIO_CTRL_PHYAD_SHIFT) & MDIO_CTRL_PHYAD_MASK) |
++ (regad & MDIO_CTRL_REGAD_MASK);
++
++ vr9_switch_mdio_poll();
++ ltq_writel(&switch_regs->mdio.mdio_ctrl, mdio_ctrl);
++ vr9_switch_mdio_poll();
++ retval = ltq_readl(&switch_regs->mdio.mdio_read);
++
++ return retval;
++}
++
++static int vr9_switch_mdio_write(struct mii_dev *bus, int phyad, int devad,
++ int regad, u16 val)
++{
++ u32 mdio_ctrl;
++
++ mdio_ctrl = MDIO_CTRL_OP_WRITE |
++ ((phyad << MDIO_CTRL_PHYAD_SHIFT) & MDIO_CTRL_PHYAD_MASK) |
++ (regad & MDIO_CTRL_REGAD_MASK);
++
++ vr9_switch_mdio_poll();
++ ltq_writel(&switch_regs->mdio.mdio_write, val);
++ ltq_writel(&switch_regs->mdio.mdio_ctrl, mdio_ctrl);
++
++ return 0;
++}
++
++static void ltq_eth_gmac_update(struct phy_device *phydev, int num)
++{
++ struct ltq_mdio_phy_addr_reg phy_addr_reg;
++ struct ltq_mii_mii_cfg_reg mii_cfg_reg;
++
++ phy_addr_reg.val = ltq_readl(to_mdio_phyaddr(switch_regs, num));
++
++ switch (num) {
++ case 0:
++ case 1:
++ case 5:
++ mii_cfg_reg.val = ltq_readl(to_mii_miicfg(switch_regs, num));
++ break;
++ default:
++ mii_cfg_reg.val = 0;
++ break;
++ }
++
++ phy_addr_reg.bits.addr = phydev->addr;
++
++ if (phydev->link)
++ phy_addr_reg.bits.lnkst = LTQ_MDIO_PHY_ADDR_LNKST_UP;
++ else
++ phy_addr_reg.bits.lnkst = LTQ_MDIO_PHY_ADDR_LNKST_DOWN;
++
++ switch (phydev->speed) {
++ case SPEED_1000:
++ phy_addr_reg.bits.speed = LTQ_MDIO_PHY_ADDR_SPEED_G1;
++ mii_cfg_reg.bits.miirate = LTQ_MII_MII_CFG_MIIRATE_M125;
++ break;
++ case SPEED_100:
++ phy_addr_reg.bits.speed = LTQ_MDIO_PHY_ADDR_SPEED_M100;
++ switch (mii_cfg_reg.bits.miimode) {
++ case LTQ_MII_MII_CFG_MIIMODE_RMIIM:
++ case LTQ_MII_MII_CFG_MIIMODE_RMIIP:
++ mii_cfg_reg.bits.miirate = LTQ_MII_MII_CFG_MIIRATE_M50;
++ break;
++ default:
++ mii_cfg_reg.bits.miirate = LTQ_MII_MII_CFG_MIIRATE_M25;
++ break;
++ }
++ break;
++ default:
++ phy_addr_reg.bits.speed = LTQ_MDIO_PHY_ADDR_SPEED_M10;
++ mii_cfg_reg.bits.miirate = LTQ_MII_MII_CFG_MIIRATE_M2P5;
++ break;
++ }
++
++ if (phydev->duplex == DUPLEX_FULL)
++ phy_addr_reg.bits.fdup = LTQ_MDIO_PHY_ADDR_FDUP_ENABLE;
++ else
++ phy_addr_reg.bits.fdup = LTQ_MDIO_PHY_ADDR_FDUP_DISABLE;
++
++ ltq_writel(to_mdio_phyaddr(switch_regs, num), phy_addr_reg.val);
++
++ switch (num) {
++ case 0:
++ case 1:
++ case 5:
++ ltq_writel(to_mii_miicfg(switch_regs, num), mii_cfg_reg.val);
++ break;
++ default:
++ break;
++ }
++}
++
++static inline u8 *ltq_eth_rx_packet_align(int rx_num)
++{
++ u8 *packet = (u8 *) NetRxPackets[rx_num];
++
++ /*
++ * IP header needs
++ */
++ return packet + LTQ_ETH_IP_ALIGN;
++}
++
++static int ltq_eth_init(struct eth_device *dev, bd_t * bis)
++{
++ struct ltq_eth_priv *priv = dev->priv;
++ struct ltq_dma_device *dma_dev = &priv->dma_dev;
++ struct phy_device *phydev;
++ int i;
++
++ for (i = 0; i < LTQ_ETHSW_MAX_GMAC; i++) {
++ phydev = priv->phymap[i];
++ if (!phydev)
++ continue;
++
++ phy_startup(phydev);
++ ltq_eth_gmac_update(phydev, i);
++ }
++
++ for (i = 0; i < LTQ_ETH_RX_BUFFER_CNT; i++)
++ ltq_dma_rx_map(dma_dev, i, ltq_eth_rx_packet_align(i),
++ LTQ_ETH_RX_DATA_SIZE);
++
++ ltq_dma_enable(dma_dev);
++
++ priv->rx_num = 0;
++ priv->tx_num = 0;
++
++ return 0;
++}
++
++static void ltq_eth_halt(struct eth_device *dev)
++{
++ struct ltq_eth_priv *priv = dev->priv;
++ struct ltq_dma_device *dma_dev = &priv->dma_dev;
++ struct phy_device *phydev;
++ int i;
++
++ ltq_dma_reset(dma_dev);
++
++ for (i = 0; i < LTQ_ETHSW_MAX_GMAC; i++) {
++ phydev = priv->phymap[i];
++ if (!phydev)
++ continue;
++
++ phy_shutdown(phydev);
++ phydev->link = 0;
++ ltq_eth_gmac_update(phydev, i);
++ }
++}
++
++static int ltq_eth_send(struct eth_device *dev, void *packet, int length)
++{
++ struct ltq_eth_priv *priv = dev->priv;
++ struct ltq_dma_device *dma_dev = &priv->dma_dev;
++
++#if 0
++ printf("%s: packet %p, len %d\n", __func__, packet, length);
++#endif
++
++ ltq_dma_tx_map(dma_dev, priv->tx_num, packet, length, 10);
++ priv->tx_num = (priv->tx_num + 1) % LTQ_ETH_TX_BUFFER_CNT;
++
++ return 0;
++}
++
++static int ltq_eth_recv(struct eth_device *dev)
++{
++ struct ltq_eth_priv *priv = dev->priv;
++ struct ltq_dma_device *dma_dev = &priv->dma_dev;
++ u8 *packet;
++ int len;
++
++ if (!ltq_dma_rx_poll(dma_dev, priv->rx_num))
++ return 0;
++
++#if 0
++ printf("%s: rx_num %d\n", __func__, priv->rx_num);
++#endif
++
++ len = ltq_dma_rx_length(dma_dev, priv->rx_num);
++ packet = ltq_eth_rx_packet_align(priv->rx_num);
++
++#if 0
++ printf("%s: received: packet %p, len %u, rx_num %d\n",
++ __func__, packet, len, priv->rx_num);
++#endif
++
++ if (len)
++ NetReceive(packet, len);
++
++ ltq_dma_rx_map(dma_dev, priv->rx_num, packet,
++ LTQ_ETH_RX_DATA_SIZE);
++
++ priv->rx_num = (priv->rx_num + 1) % LTQ_ETH_RX_BUFFER_CNT;
++
++ return 0;
++}
++
++static void ltq_eth_gmac_init(int num)
++{
++ struct ltq_mdio_phy_addr_reg phy_addr_reg;
++ struct ltq_mii_mii_cfg_reg mii_cfg_reg;
++
++ /* Reset PHY status to link down */
++ phy_addr_reg.val = ltq_readl(to_mdio_phyaddr(switch_regs, num));
++ phy_addr_reg.bits.addr = num;
++ phy_addr_reg.bits.lnkst = LTQ_MDIO_PHY_ADDR_LNKST_DOWN;
++ phy_addr_reg.bits.speed = LTQ_MDIO_PHY_ADDR_SPEED_M10;
++ phy_addr_reg.bits.fdup = LTQ_MDIO_PHY_ADDR_FDUP_DISABLE;
++ ltq_writel(to_mdio_phyaddr(switch_regs, num), phy_addr_reg.val);
++
++ /* Reset and disable MII interface */
++ switch (num) {
++ case 0:
++ case 1:
++ case 5:
++ mii_cfg_reg.val = ltq_readl(to_mii_miicfg(switch_regs, num));
++ mii_cfg_reg.bits.en = 0;
++ mii_cfg_reg.bits.res = 1;
++ mii_cfg_reg.bits.miirate = LTQ_MII_MII_CFG_MIIRATE_M2P5;
++ ltq_writel(to_mii_miicfg(switch_regs, num), mii_cfg_reg.val);
++ break;
++ default:
++ break;
++ }
++
++ /*
++ * - enable frame checksum generation
++ * - enable padding of short frames
++ * - disable flow control
++ */
++ ltq_writel(to_mac_ctrl(switch_regs, num, 0),
++ MAC_CTRL0_PADEN | MAC_CTRL0_FCS | MAC_CTRL0_FCON_NONE);
++
++ vr9_switch_sync();
++}
++
++static void ltq_eth_pmac_init(void)
++{
++ /*
++ * WAR: buffer congestion:
++ * - shorten preambel to 1 byte
++ * - set TX IPG to 7 bytes
++ */
++#if 1
++ ltq_writel(to_mac_ctrl(switch_regs, LTQ_ETHSW_PMAC, 1),
++ MAC_CTRL1_SHORTPRE | 7);
++#endif
++
++ /*
++ * WAR: systematical concept weakness ACM bug
++ * - set maximum number of used buffer segments to 254
++ * - soft-reset BM FSQM
++ */
++#if 1
++ ltq_writel(&switch_regs->bm.core.fsqm_gctrl, 253);
++ ltq_setbits(&switch_regs->bm.core.gctrl, BM_GCTRL_F_SRES);
++ ltq_clrbits(&switch_regs->bm.core.gctrl, BM_GCTRL_F_SRES);
++#endif
++
++ /*
++ * WAR: switch MAC drop bug
++ */
++#if 1
++ ltq_writel(to_pce_tbl_key(switch_regs, 0), 0xf);
++ ltq_writel(to_pce_tbl_value(switch_regs, 0), 0x40);
++ ltq_writel(&switch_regs->pce.core.tbl_addr, 0x3);
++ ltq_writel(&switch_regs->pce.core.tbl_ctrl, 0x902f);
++#endif
++
++ /*
++ * Configure frame header control:
++ * - enable flow control
++ * - enable CRC check for packets from DMA to PMAC
++ * - remove special tag from packets from PMAC to DMA
++ * - add CRC for packets from DMA to PMAC
++ */
++ ltq_writel(&switch_regs->pmac.hd_ctl, /*PMAC_HD_CTL_FC |*/
++ PMAC_HD_CTL_CCRC | PMAC_HD_CTL_RST | PMAC_HD_CTL_AC |
++ PMAC_HD_CTL_RC);
++
++#if 1
++ ltq_writel(&switch_regs->pmac.rx_ipg, 0x8b);
++#endif
++
++ /*
++ * - enable frame checksum generation
++ * - enable padding of short frames
++ * - disable flow control
++ */
++ ltq_writel(to_mac_ctrl(switch_regs, LTQ_ETHSW_PMAC, 0),
++ MAC_CTRL0_PADEN | MAC_CTRL0_FCS | MAC_CTRL0_FCON_NONE);
++
++ vr9_switch_sync();
++}
++
++static void ltq_eth_hw_init(void)
++{
++ int i;
++
++ /* Power up ethernet and switch subsystems */
++ ltq_pm_enable(LTQ_PM_ETH);
++
++ /* Reset ethernet and switch subsystems */
++#if 0
++ ltq_reset_once(LTQ_RESET_ETH, 10);
++#endif
++
++ /* Enable switch macro */
++ ltq_setbits(&switch_regs->mdio.glob_ctrl, MDIO_GLOB_CTRL_SE);
++
++ /* Disable MDIO auto-polling for all ports */
++ ltq_writel(&switch_regs->mdio.mdc_cfg_0, 0);
++
++ /*
++ * Enable and set MDIO management clock to 2.5 MHz. This is the
++ * maximum clock for FE PHYs.
++ * Formula for clock is:
++ *
++ * 50 MHz
++ * x = ----------- - 1
++ * 2 * f_MDC
++ */
++ ltq_writel(&switch_regs->mdio.mdc_cfg_1, MDIO_MDC_CFG1_RES |
++ MDIO_MDC_CFG1_MCEN | 5);
++
++ vr9_switch_sync();
++
++ /* Init MAC connected to CPU */
++ ltq_eth_pmac_init();
++
++ /* Init MACs connected to external MII interfaces */
++ for (i = 0; i < LTQ_ETHSW_MAX_GMAC; i++)
++ ltq_eth_gmac_init(i);
++}
++
++static void ltq_eth_port_config(struct ltq_eth_priv *priv,
++ const struct ltq_eth_port_config *port)
++{
++ struct ltq_mii_mii_cfg_reg mii_cfg_reg;
++ struct phy_device *phydev;
++ int setup_gpio = 0;
++
++ switch (port->num) {
++ case 0: /* xMII0 */
++ case 1: /* xMII1 */
++ mii_cfg_reg.val = ltq_readl(to_mii_miicfg(switch_regs,
++ port->num));
++ mii_cfg_reg.bits.en = port->flags ? 1 : 0;
++
++ switch (port->phy_if) {
++ case PHY_INTERFACE_MODE_MII:
++ if (port->flags & LTQ_ETH_PORT_PHY)
++ /* MII MAC mode, connected to external PHY */
++ mii_cfg_reg.bits.miimode =
++ LTQ_MII_MII_CFG_MIIMODE_MIIM;
++ else
++ /* MII PHY mode, connected to external MAC */
++ mii_cfg_reg.bits.miimode =
++ LTQ_MII_MII_CFG_MIIMODE_MIIP;
++ setup_gpio = 1;
++ break;
++ case PHY_INTERFACE_MODE_RMII:
++ if (port->flags & LTQ_ETH_PORT_PHY)
++ /* RMII MAC mode, connected to external PHY */
++ mii_cfg_reg.bits.miimode =
++ LTQ_MII_MII_CFG_MIIMODE_RMIIM;
++ else
++ /* RMII PHY mode, connected to external MAC */
++ mii_cfg_reg.bits.miimode =
++ LTQ_MII_MII_CFG_MIIMODE_RMIIP;
++ setup_gpio = 1;
++ break;
++ case PHY_INTERFACE_MODE_RGMII:
++ /* RGMII MAC mode, connected to external PHY */
++ mii_cfg_reg.bits.miimode =
++ LTQ_MII_MII_CFG_MIIMODE_RGMII;
++ setup_gpio = 1;
++
++ /* RGMII clock delays */
++ ltq_writel(to_mii_pcdu(switch_regs, port->num),
++ port->rgmii_rx_delay << PCDU_RXDLY_SHIFT |
++ port->rgmii_tx_delay);
++ break;
++ default:
++ break;
++ }
++
++ ltq_writel(to_mii_miicfg(switch_regs, port->num),
++ mii_cfg_reg.val);
++ break;
++ case 2: /* internal GPHY0 */
++ case 3: /* internal GPHY0 */
++ case 4: /* internal GPHY1 */
++ switch (port->phy_if) {
++ case PHY_INTERFACE_MODE_MII:
++ case PHY_INTERFACE_MODE_GMII:
++ setup_gpio = 1;
++ break;
++ default:
++ break;
++ }
++ break;
++ case 5: /* internal GPHY1 or xMII2 */
++ mii_cfg_reg.val = ltq_readl(to_mii_miicfg(switch_regs,
++ port->num));
++ mii_cfg_reg.bits.en = port->flags ? 1 : 0;
++
++ switch (port->phy_if) {
++ case PHY_INTERFACE_MODE_MII:
++ /* MII MAC mode, connected to internal GPHY */
++ mii_cfg_reg.bits.miimode =
++ LTQ_MII_MII_CFG_MIIMODE_MIIM;
++ setup_gpio = 1;
++ break;
++ case PHY_INTERFACE_MODE_RGMII:
++ /* RGMII MAC mode, connected to external PHY */
++ mii_cfg_reg.bits.miimode =
++ LTQ_MII_MII_CFG_MIIMODE_RGMII;
++ setup_gpio = 1;
++
++ /* RGMII clock delays */
++ ltq_writel(to_mii_pcdu(switch_regs, port->num),
++ port->rgmii_rx_delay << PCDU_RXDLY_SHIFT |
++ port->rgmii_tx_delay);
++ break;
++ default:
++ break;
++ }
++
++ ltq_writel(to_mii_miicfg(switch_regs, port->num),
++ mii_cfg_reg.val);
++ break;
++ default:
++ break;
++ }
++
++ /* Setup GPIOs for MII with external PHYs/MACs */
++ if (setup_gpio) {
++ /* MII/MDIO */
++ gpio_set_altfunc(42, GPIO_ALTSEL_SET, GPIO_ALTSEL_CLR,
++ GPIO_DIR_OUT);
++ /* MII/MDC */
++ gpio_set_altfunc(43, GPIO_ALTSEL_SET, GPIO_ALTSEL_CLR,
++ GPIO_DIR_OUT);
++ }
++
++ /* Connect to internal/external PHYs */
++ if (port->flags & LTQ_ETH_PORT_PHY) {
++ phydev = phy_connect(priv->bus, port->phy_addr, priv->dev,
++ port->phy_if);
++ if (phydev)
++ phy_config(phydev);
++
++ priv->phymap[port->num] = phydev;
++ }
++}
++
++int ltq_eth_initialize(const struct ltq_eth_board_config *board_config)
++{
++ struct eth_device *dev;
++ struct mii_dev *bus;
++ struct ltq_eth_priv *priv;
++ struct ltq_dma_device *dma_dev;
++ int i, ret;
++
++ build_check_vr9_registers();
++
++ ltq_dma_init();
++ ltq_eth_hw_init();
++
++ dev = calloc(1, sizeof(struct eth_device));
++ if (!dev)
++ return -1;
++
++ priv = calloc(1, sizeof(struct ltq_eth_priv));
++ if (!priv)
++ return -1;
++
++ bus = mdio_alloc();
++ if (!bus)
++ return -1;
++
++ sprintf(dev->name, LTQ_ETH_DRV_NAME);
++ dev->priv = priv;
++ dev->init = ltq_eth_init;
++ dev->halt = ltq_eth_halt;
++ dev->recv = ltq_eth_recv;
++ dev->send = ltq_eth_send;
++
++ sprintf(bus->name, LTQ_MDIO_DRV_NAME);
++ bus->read = vr9_switch_mdio_read;
++ bus->write = vr9_switch_mdio_write;
++ bus->priv = priv;
++
++ dma_dev = &priv->dma_dev;
++ dma_dev->port = 0;
++ dma_dev->rx_chan.chan_no = 0;
++ dma_dev->rx_chan.class = 0;
++ dma_dev->rx_chan.num_desc = LTQ_ETH_RX_BUFFER_CNT;
++ dma_dev->rx_endian_swap = LTQ_DMA_ENDIANESS_B3_B2_B1_B0;
++ dma_dev->rx_burst_len = LTQ_DMA_BURST_2WORDS;
++ dma_dev->tx_chan.chan_no = 1;
++ dma_dev->tx_chan.class = 0;
++ dma_dev->tx_chan.num_desc = LTQ_ETH_TX_BUFFER_CNT;
++ dma_dev->tx_endian_swap = LTQ_DMA_ENDIANESS_B3_B2_B1_B0;
++ dma_dev->tx_burst_len = LTQ_DMA_BURST_2WORDS;
++
++ priv->bus = bus;
++ priv->dev = dev;
++
++ ret = ltq_dma_register(dma_dev);
++ if (ret)
++ return -1;
++
++ ret = mdio_register(bus);
++ if (ret)
++ return -1;
++
++ ret = eth_register(dev);
++ if (ret)
++ return -1;
++
++ for (i = 0; i < board_config->num_ports; i++)
++ ltq_eth_port_config(priv, &board_config->ports[i]);
++
++ return 0;
++}
+--- a/drivers/net/phy/Makefile
++++ b/drivers/net/phy/Makefile
+@@ -34,6 +34,7 @@ COBJS-$(CONFIG_PHYLIB_10G) += generic_10
+ COBJS-$(CONFIG_PHY_ATHEROS) += atheros.o
+ COBJS-$(CONFIG_PHY_BROADCOM) += broadcom.o
+ COBJS-$(CONFIG_PHY_DAVICOM) += davicom.o
++COBJS-$(CONFIG_PHY_LANTIQ) += lantiq.o
+ COBJS-$(CONFIG_PHY_LXT) += lxt.o
+ COBJS-$(CONFIG_PHY_MARVELL) += marvell.o
+ COBJS-$(CONFIG_PHY_MICREL) += micrel.o
+--- /dev/null
++++ b/drivers/net/phy/lantiq.c
+@@ -0,0 +1,239 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#define DEBUG
++
++#include <common.h>
++#include <miiphy.h>
++
++#define ADVERTIZE_MPD (1 << 10)
++
++DECLARE_GLOBAL_DATA_PTR;
++
++/*
++ * Update link status.
++ *
++ * Based on genphy_update_link in phylib.c
++ */
++static int ltq_phy_update_link(struct phy_device *phydev)
++{
++ unsigned int mii_reg;
++
++ mii_reg = phy_read(phydev, MDIO_DEVAD_NONE, MII_BMSR);
++
++ /*
++ * If we already saw the link up, and it hasn't gone down, then
++ * we don't need to wait for autoneg again
++ */
++ if (phydev->link && mii_reg & BMSR_LSTATUS)
++ return 0;
++
++ if ((mii_reg & BMSR_ANEGCAPABLE) && !(mii_reg & BMSR_ANEGCOMPLETE)) {
++ phydev->link = 0;
++ return 0;
++ } else {
++ /* Read the link a second time to clear the latched state */
++ mii_reg = phy_read(phydev, MDIO_DEVAD_NONE, MII_BMSR);
++
++ if (mii_reg & BMSR_LSTATUS)
++ phydev->link = 1;
++ else
++ phydev->link = 0;
++ }
++
++ return 0;
++}
++
++/*
++ * Update speed and duplex.
++ *
++ * Based on genphy_parse_link in phylib.c
++ */
++static int ltq_phy_parse_link(struct phy_device *phydev)
++{
++ unsigned int mii_reg;
++
++ mii_reg = phy_read(phydev, MDIO_DEVAD_NONE, MII_BMSR);
++
++ /* We're using autonegotiation */
++ if (mii_reg & BMSR_ANEGCAPABLE) {
++ u32 lpa = 0;
++ u32 gblpa = 0;
++
++ /* Check for gigabit capability */
++ if (mii_reg & BMSR_ERCAP) {
++ /* We want a list of states supported by
++ * both PHYs in the link
++ */
++ gblpa = phy_read(phydev, MDIO_DEVAD_NONE, MII_STAT1000);
++ gblpa &= phy_read(phydev,
++ MDIO_DEVAD_NONE, MII_CTRL1000) << 2;
++ }
++
++ /* Set the baseline so we only have to set them
++ * if they're different
++ */
++ phydev->speed = SPEED_10;
++ phydev->duplex = DUPLEX_HALF;
++
++ /* Check the gigabit fields */
++ if (gblpa & (PHY_1000BTSR_1000FD | PHY_1000BTSR_1000HD)) {
++ phydev->speed = SPEED_1000;
++
++ if (gblpa & PHY_1000BTSR_1000FD)
++ phydev->duplex = DUPLEX_FULL;
++
++ /* We're done! */
++ return 0;
++ }
++
++ lpa = phy_read(phydev, MDIO_DEVAD_NONE, MII_ADVERTISE);
++ lpa &= phy_read(phydev, MDIO_DEVAD_NONE, MII_LPA);
++
++ if (lpa & (LPA_100FULL | LPA_100HALF)) {
++ phydev->speed = SPEED_100;
++
++ if (lpa & LPA_100FULL)
++ phydev->duplex = DUPLEX_FULL;
++
++ } else if (lpa & LPA_10FULL)
++ phydev->duplex = DUPLEX_FULL;
++ } else {
++ u32 bmcr = phy_read(phydev, MDIO_DEVAD_NONE, MII_BMCR);
++
++ phydev->speed = SPEED_10;
++ phydev->duplex = DUPLEX_HALF;
++
++ if (bmcr & BMCR_FULLDPLX)
++ phydev->duplex = DUPLEX_FULL;
++
++ if (bmcr & BMCR_SPEED1000)
++ phydev->speed = SPEED_1000;
++ else if (bmcr & BMCR_SPEED100)
++ phydev->speed = SPEED_100;
++ }
++
++ return 0;
++}
++
++static int ltq_phy_config(struct phy_device *phydev)
++{
++ u16 val;
++
++ /* Advertise as Multi-port device */
++ val = phy_read(phydev, MDIO_DEVAD_NONE, MII_CTRL1000);
++ val |= ADVERTIZE_MPD;
++ phy_write(phydev, MDIO_DEVAD_NONE, MII_CTRL1000, val);
++
++ genphy_config_aneg(phydev);
++
++ return 0;
++}
++
++static int ltq_phy_startup(struct phy_device *phydev)
++{
++ /*
++ * Update PHY status immediately without any delays as genphy_startup
++ * does because VRX200 switch needs to be configured dependent
++ * on this information.
++ */
++ ltq_phy_update_link(phydev);
++ ltq_phy_parse_link(phydev);
++
++ debug("ltq_phy: addr %d, link %d, speed %d, duplex %d\n",
++ phydev->addr, phydev->link, phydev->speed, phydev->duplex);
++
++ return 0;
++}
++
++static struct phy_driver xrx_11g_13_driver = {
++ .name = "Lantiq XWAY XRX PHY11G v1.3 and earlier",
++ .uid = 0x030260D0,
++ .mask = 0xFFFFFFF0,
++ .features = PHY_GBIT_FEATURES,
++ .config = ltq_phy_config,
++ .startup = ltq_phy_startup,
++ .shutdown = genphy_shutdown,
++};
++
++static struct phy_driver xrx_11g_14_driver = {
++ .name = "Lantiq XWAY XRX PHY11G v1.4 and later",
++ .uid = 0xd565a408,
++ .mask = 0xFFFFFFF8,
++ .features = PHY_GBIT_FEATURES,
++ .config = ltq_phy_config,
++ .startup = ltq_phy_startup,
++ .shutdown = genphy_shutdown,
++};
++
++static struct phy_driver xrx_22f_14_driver = {
++ .name = "Lantiq XWAY XRX PHY22F v1.4 and later",
++ .uid = 0xd565a418,
++ .mask = 0xFFFFFFF8,
++ .features = PHY_BASIC_FEATURES,
++ .config = ltq_phy_config,
++ .startup = ltq_phy_startup,
++ .shutdown = genphy_shutdown,
++};
++
++static struct phy_driver pef7071_driver = {
++ .name = "Lantiq XWAY PEF7071",
++ .uid = 0xd565a400,
++ .mask = 0xFFFFFFFF,
++ .features = PHY_GBIT_FEATURES,
++ .config = ltq_phy_config,
++ .startup = ltq_phy_startup,
++ .shutdown = genphy_shutdown,
++};
++
++static struct phy_driver xrx_genphy_driver = {
++ .name = "Generic PHY at Lantiq XWAY XRX switch",
++ .uid = 0,
++ .mask = 0,
++ .features = 0,
++ .config = genphy_config,
++ .startup = ltq_phy_startup,
++ .shutdown = genphy_shutdown,
++};
++
++int phy_lantiq_init(void)
++{
++#ifdef CONFIG_NEEDS_MANUAL_RELOC
++ xrx_11g_13_driver.config = ltq_phy_config;
++ xrx_11g_13_driver.startup = ltq_phy_startup;
++ xrx_11g_13_driver.shutdown = genphy_shutdown;
++ xrx_11g_13_driver.name += gd->reloc_off;
++
++ xrx_11g_14_driver.config = ltq_phy_config;
++ xrx_11g_14_driver.startup = ltq_phy_startup;
++ xrx_11g_14_driver.shutdown = genphy_shutdown;
++ xrx_11g_14_driver.name += gd->reloc_off;
++
++ xrx_22f_14_driver.config = ltq_phy_config;
++ xrx_22f_14_driver.startup = ltq_phy_startup;
++ xrx_22f_14_driver.shutdown = genphy_shutdown;
++ xrx_22f_14_driver.name += gd->reloc_off;
++
++ pef7071_driver.config = ltq_phy_config;
++ pef7071_driver.startup = ltq_phy_startup;
++ pef7071_driver.shutdown = genphy_shutdown;
++ pef7071_driver.name += gd->reloc_off;
++
++ xrx_genphy_driver.config = genphy_config;
++ xrx_genphy_driver.startup = ltq_phy_startup;
++ xrx_genphy_driver.shutdown = genphy_shutdown;
++ xrx_genphy_driver.name += gd->reloc_off;
++#endif
++
++ phy_register(&xrx_11g_13_driver);
++ phy_register(&xrx_11g_14_driver);
++ phy_register(&xrx_22f_14_driver);
++ phy_register(&pef7071_driver);
++ phy_register(&xrx_genphy_driver);
++
++ return 0;
++}
+--- a/drivers/net/phy/phy.c
++++ b/drivers/net/phy/phy.c
+@@ -32,6 +32,8 @@
+ #include <phy.h>
+ #include <errno.h>
+
++DECLARE_GLOBAL_DATA_PTR;
++
+ /* Generic PHY support and helper functions */
+
+ /**
+@@ -420,6 +422,16 @@ static LIST_HEAD(phy_drivers);
+
+ int phy_init(void)
+ {
++#ifdef CONFIG_NEEDS_MANUAL_RELOC
++ INIT_LIST_HEAD(&phy_drivers);
++
++ genphy_driver.config = genphy_config;
++ genphy_driver.startup = genphy_startup;
++ genphy_driver.shutdown = genphy_shutdown;
++
++ genphy_driver.name += gd->reloc_off;
++#endif
++
+ #ifdef CONFIG_PHY_ATHEROS
+ phy_atheros_init();
+ #endif
+@@ -429,6 +441,9 @@ int phy_init(void)
+ #ifdef CONFIG_PHY_DAVICOM
+ phy_davicom_init();
+ #endif
++#ifdef CONFIG_PHY_LANTIQ
++ phy_lantiq_init();
++#endif
+ #ifdef CONFIG_PHY_LXT
+ phy_lxt_init();
+ #endif
+--- a/drivers/serial/Makefile
++++ b/drivers/serial/Makefile
+@@ -42,6 +42,7 @@ COBJS-$(CONFIG_SYS_NS16550_SERIAL) += se
+ COBJS-$(CONFIG_IMX_SERIAL) += serial_imx.o
+ COBJS-$(CONFIG_IXP_SERIAL) += serial_ixp.o
+ COBJS-$(CONFIG_KS8695_SERIAL) += serial_ks8695.o
++COBJS-$(CONFIG_LANTIQ_SERIAL) += serial_lantiq.o
+ COBJS-$(CONFIG_MAX3100_SERIAL) += serial_max3100.o
+ COBJS-$(CONFIG_MXC_UART) += serial_mxc.o
+ COBJS-$(CONFIG_PL010_SERIAL) += serial_pl01x.o
+--- /dev/null
++++ b/drivers/serial/serial_lantiq.c
+@@ -0,0 +1,264 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2010 Thomas Langer <thomas.langer@lantiq.com>
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <common.h>
++#include <serial.h>
++#include <asm/errno.h>
++#include <asm/arch/soc.h>
++#include <asm/lantiq/clk.h>
++#include <asm/lantiq/io.h>
++
++#if CONFIG_CONSOLE_ASC == 0
++#define LTQ_ASC_BASE LTQ_ASC0_BASE
++#else
++#define LTQ_ASC_BASE LTQ_ASC1_BASE
++#endif
++
++#define LTQ_ASC_ID_TXFS_SHIFT 24
++#define LTQ_ASC_ID_TXFS_MASK (0x3F << LTQ_ASC_ID_TXFS_SHIFT)
++#define LTQ_ASC_ID_RXFS_SHIFT 16
++#define LTQ_ASC_ID_RXFS_MASK (0x3F << LTQ_ASC_ID_RXFS_SHIFT)
++
++#define LTQ_ASC_MCON_R (1 << 15)
++#define LTQ_ASC_MCON_FDE (1 << 9)
++
++#define LTQ_ASC_WHBSTATE_SETREN (1 << 1)
++#define LTQ_ASC_WHBSTATE_CLRREN (1 << 0)
++
++#define LTQ_ASC_RXFCON_RXFITL_SHIFT 8
++#define LTQ_ASC_RXFCON_RXFITL_MASK (0x3F << LTQ_ASC_RXFCON_RXFITL_SHIFT)
++#define LTQ_ASC_RXFCON_RXFITL_RXFFLU (1 << 1)
++#define LTQ_ASC_RXFCON_RXFITL_RXFEN (1 << 0)
++
++#define LTQ_ASC_TXFCON_TXFITL_SHIFT 8
++#define LTQ_ASC_TXFCON_TXFITL_MASK (0x3F << LTQ_ASC_TXFCON_TXFITL_SHIFT)
++#define LTQ_ASC_TXFCON_TXFITL_TXFFLU (1 << 1)
++#define LTQ_ASC_TXFCON_TXFITL_TXFEN (1 << 0)
++
++#define LTQ_ASC_FSTAT_TXFREE_SHIFT 24
++#define LTQ_ASC_FSTAT_TXFREE_MASK (0x3F << LTQ_ASC_FSTAT_TXFREE_SHIFT)
++#define LTQ_ASC_FSTAT_RXFREE_SHIFT 16
++#define LTQ_ASC_FSTAT_RXFREE_MASK (0x3F << LTQ_ASC_FSTAT_RXFREE_SHIFT)
++#define LTQ_ASC_FSTAT_TXFFL_SHIFT 8
++#define LTQ_ASC_FSTAT_TXFFL_MASK (0x3F << LTQ_ASC_FSTAT_TXFFL_SHIFT)
++#define LTQ_ASC_FSTAT_RXFFL_MASK 0x3F
++
++#ifdef __BIG_ENDIAN
++#define LTQ_ASC_RBUF_OFFSET 3
++#define LTQ_ASC_TBUF_OFFSET 3
++#else
++#define LTQ_ASC_RBUF_OFFSET 0
++#define LTQ_ASC_TBUF_OFFSET 0
++#endif
++
++struct ltq_asc_regs {
++ u32 clc;
++ u32 pisel;
++ u32 id;
++ u32 rsvd0;
++ u32 mcon;
++ u32 state;
++ u32 whbstate;
++ u32 rsvd1;
++ u8 tbuf[4];
++ u8 rbuf[4];
++ u32 rsvd2[2];
++ u32 abcon;
++ u32 abstat;
++ u32 whbabcon;
++ u32 whbabstat;
++ u32 rxfcon;
++ u32 txfcon;
++ u32 fstat;
++ u32 rsvd3;
++ u32 bg;
++ u32 bg_timer;
++ u32 fdv;
++ u32 pmw;
++ u32 modcon;
++ u32 modstat;
++};
++
++DECLARE_GLOBAL_DATA_PTR;
++
++static struct ltq_asc_regs *ltq_asc_regs =
++ (struct ltq_asc_regs *) CKSEG1ADDR(LTQ_ASC_BASE);
++
++static int ltq_serial_init(void)
++{
++ /* Set clock divider for normal run mode to 1 and enable module */
++ ltq_writel(&ltq_asc_regs->clc, 0x100);
++
++ /* Reset MCON register */
++ ltq_writel(&ltq_asc_regs->mcon, 0);
++
++ /* Use Port A as receiver input */
++ ltq_writel(&ltq_asc_regs->pisel, 0);
++
++ /* Enable and flush RX/TX FIFOs */
++ ltq_setbits(&ltq_asc_regs->rxfcon,
++ LTQ_ASC_RXFCON_RXFITL_RXFFLU | LTQ_ASC_RXFCON_RXFITL_RXFEN);
++ ltq_setbits(&ltq_asc_regs->txfcon,
++ LTQ_ASC_TXFCON_TXFITL_TXFFLU | LTQ_ASC_TXFCON_TXFITL_TXFEN);
++
++ serial_setbrg();
++
++ /* Disable error flags, enable receiver */
++ ltq_writel(&ltq_asc_regs->whbstate, LTQ_ASC_WHBSTATE_SETREN);
++
++ return 0;
++}
++
++/*
++ * fdv asc_clk
++ * Baudrate = ----- * -------------
++ * 512 16 * (bg + 1)
++ */
++static void ltq_serial_calc_br_fdv(unsigned long asc_clk,
++ unsigned long baudrate, u16 *fdv,
++ u16 *bg)
++{
++ const u32 c = asc_clk / (16 * 512);
++ u32 diff1, diff2;
++ u32 bg_calc, br_calc, i;
++
++ diff1 = baudrate;
++ for (i = 512; i > 0; i--) {
++ /* Calc bg for current fdv value */
++ bg_calc = i * c / baudrate;
++
++ /* Impossible baudrate */
++ if (!bg_calc)
++ return;
++
++ /*
++ * Calc diff to target baudrate dependent on current
++ * bg and fdv values
++ */
++ br_calc = i * c / bg_calc;
++ if (br_calc > baudrate)
++ diff2 = br_calc - baudrate;
++ else
++ diff2 = baudrate - br_calc;
++
++ /* Perfect values found */
++ if (diff2 == 0) {
++ *fdv = i;
++ *bg = bg_calc - 1;
++ return;
++ }
++
++ if (diff2 < diff1) {
++ *fdv = i;
++ *bg = bg_calc - 1;
++ diff1 = diff2;
++ }
++ }
++}
++
++static void ltq_serial_setbrg(void)
++{
++ unsigned long asc_clk, baudrate;
++ u16 bg = 0;
++ u16 fdv = 511;
++
++ /* ASC clock is same as FPI clock with CLC.RMS = 1 */
++ asc_clk = ltq_get_bus_clock();
++ baudrate = gd->baudrate;
++
++ /* Calculate FDV and BG values */
++ ltq_serial_calc_br_fdv(asc_clk, baudrate, &fdv, &bg);
++
++ /* Disable baudrate generator */
++ ltq_clrbits(&ltq_asc_regs->mcon, LTQ_ASC_MCON_R);
++
++ /* Enable fractional divider */
++ ltq_setbits(&ltq_asc_regs->mcon, LTQ_ASC_MCON_FDE);
++
++ /* Set fdv and bg values */
++ ltq_writel(&ltq_asc_regs->fdv, fdv);
++ ltq_writel(&ltq_asc_regs->bg, bg);
++
++ /* Enable baudrate generator */
++ ltq_setbits(&ltq_asc_regs->mcon, LTQ_ASC_MCON_R);
++}
++
++static unsigned int ltq_serial_tx_free(void)
++{
++ unsigned int txfree;
++
++ txfree = (ltq_readl(&ltq_asc_regs->fstat) &
++ LTQ_ASC_FSTAT_TXFREE_MASK) >>
++ LTQ_ASC_FSTAT_TXFREE_SHIFT;
++
++ return txfree;
++}
++
++static unsigned int ltq_serial_rx_fill(void)
++{
++ unsigned int rxffl;
++
++ rxffl = ltq_readl(&ltq_asc_regs->fstat) & LTQ_ASC_FSTAT_RXFFL_MASK;
++
++ return rxffl;
++}
++
++static void ltq_serial_tx(const char c)
++{
++ ltq_writeb(&ltq_asc_regs->tbuf[LTQ_ASC_TBUF_OFFSET], c);
++}
++
++static u8 ltq_serial_rx(void)
++{
++ return ltq_readb(&ltq_asc_regs->rbuf[LTQ_ASC_RBUF_OFFSET]);
++}
++
++static void ltq_serial_putc(const char c)
++{
++ if (c == '\n')
++ ltq_serial_putc('\r');
++
++ while (!ltq_serial_tx_free())
++ ;
++
++ ltq_serial_tx(c);
++}
++
++static int ltq_serial_getc(void)
++{
++ while (!ltq_serial_rx_fill())
++ ;
++
++ return ltq_serial_rx();
++}
++
++static int ltq_serial_tstc(void)
++{
++ return (0 != ltq_serial_rx_fill());
++}
++
++static struct serial_device ltq_serial_drv = {
++ .name = "ixp_serial",
++ .start = ltq_serial_init,
++ .stop = NULL,
++ .setbrg = ltq_serial_setbrg,
++ .putc = ltq_serial_putc,
++ .puts = default_serial_puts,
++ .getc = ltq_serial_getc,
++ .tstc = ltq_serial_tstc,
++};
++
++void ixp_serial_initialize(void)
++{
++ serial_register(&ltq_serial_drv);
++}
++
++__weak struct serial_device *default_serial_console(void)
++{
++ return &ltq_serial_drv;
++}
+--- a/drivers/spi/Makefile
++++ b/drivers/spi/Makefile
+@@ -36,6 +36,7 @@ COBJS-$(CONFIG_CF_QSPI) += cf_qspi.o
+ COBJS-$(CONFIG_DAVINCI_SPI) += davinci_spi.o
+ COBJS-$(CONFIG_EXYNOS_SPI) += exynos_spi.o
+ COBJS-$(CONFIG_KIRKWOOD_SPI) += kirkwood_spi.o
++COBJS-$(CONFIG_LANTIQ_SPI) += lantiq_spi.o
+ COBJS-$(CONFIG_MPC52XX_SPI) += mpc52xx_spi.o
+ COBJS-$(CONFIG_MPC8XXX_SPI) += mpc8xxx_spi.o
+ COBJS-$(CONFIG_MXC_SPI) += mxc_spi.o
+--- /dev/null
++++ b/drivers/spi/lantiq_spi.c
+@@ -0,0 +1,476 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <common.h>
++#include <spi.h>
++#include <malloc.h>
++#include <watchdog.h>
++#include <asm/gpio.h>
++#include <asm/lantiq/io.h>
++#include <asm/lantiq/clk.h>
++#include <asm/lantiq/pm.h>
++#include <asm/arch/soc.h>
++
++#define LTQ_SPI_CLC_RMC_SHIFT 8
++#define LTQ_SPI_CLC_RMC_MASK (0xFF << LTQ_SPI_CLC_RMC_SHIFT)
++#define LTQ_SPI_CLC_DISS (1 << 1)
++#define LTQ_SPI_CLC_DISR 1
++
++#define LTQ_SPI_ID_TXFS_SHIFT 24
++#define LTQ_SPI_ID_TXFS_MASK (0x3F << LTQ_SPI_ID_TXFS_SHIFT)
++#define LTQ_SPI_ID_RXFS_SHIFT 16
++#define LTQ_SPI_ID_RXFS_MASK (0x3F << LTQ_SPI_ID_RXFS_SHIFT)
++
++#define LTQ_SPI_CON_ENBV (1 << 22)
++#define LTQ_SPI_CON_BM_SHIFT 16
++#define LTQ_SPI_CON_BM_MASK (0x1F << LTQ_SPI_CON_BM_SHIFT)
++#define LTQ_SPI_CON_LB (1 << 7)
++#define LTQ_SPI_CON_PO (1 << 6)
++#define LTQ_SPI_CON_PH (1 << 5)
++#define LTQ_SPI_CON_HB (1 << 4)
++#define LTQ_SPI_CON_RXOFF (1 << 1)
++#define LTQ_SPI_CON_TXOFF 1
++
++#define LTQ_SPI_STAT_RXBV_SHIFT 28
++#define LTQ_SPI_STAT_RXBV_MASK (0x7 << LTQ_SPI_STAT_RXBV_SHIFT)
++#define LTQ_SPI_STAT_BSY (1 << 13)
++
++#define LTQ_SPI_WHBSTATE_SETMS (1 << 3)
++#define LTQ_SPI_WHBSTATE_CLRMS (1 << 2)
++#define LTQ_SPI_WHBSTATE_SETEN (1 << 1)
++#define LTQ_SPI_WHBSTATE_CLREN 1
++
++#define LTQ_SPI_TXFCON_TXFLU (1 << 1)
++#define LTQ_SPI_TXFCON_TXFEN 1
++
++#define LTQ_SPI_RXFCON_RXFLU (1 << 1)
++#define LTQ_SPI_RXFCON_RXFEN 1
++
++#define LTQ_SPI_FSTAT_RXFFL_MASK 0x3f
++#define LTQ_SPI_FSTAT_TXFFL_SHIFT 8
++#define LTQ_SPI_FSTAT_TXFFL_MASK (0x3f << LTQ_SPI_FSTAT_TXFFL_SHIFT)
++
++#define LTQ_SPI_RXREQ_RXCNT_MASK 0xFFFF
++#define LTQ_SPI_RXCNT_TODO_MASK 0xFFFF
++
++#define LTQ_SPI_GPIO_DIN 16
++#define LTQ_SPI_GPIO_DOUT 17
++#define LTQ_SPI_GPIO_CLK 18
++
++struct ltq_spi_regs {
++ u32 clc; /* Clock control */
++ u32 pisel; /* Port input select */
++ u32 id; /* Identification */
++ u32 rsvd0;
++ u32 con; /* Control */
++ u32 stat; /* Status */
++ u32 whbstate; /* Write HW modified state */
++ u32 rsvd1;
++ u32 tb; /* Transmit buffer */
++ u32 rb; /* Receive buffer */
++ u32 rsvd2[2];
++ u32 rxfcon; /* Recevie FIFO control */
++ u32 txfcon; /* Transmit FIFO control */
++ u32 fstat; /* FIFO status */
++ u32 rsvd3;
++ u32 brt; /* Baudrate timer */
++ u32 brstat; /* Baudrate timer status */
++ u32 rsvd4[6];
++ u32 sfcon; /* Serial frame control */
++ u32 sfstat; /* Serial frame status */
++ u32 rsvd5[2];
++ u32 gpocon; /* General purpose output control */
++ u32 gpostat; /* General purpose output status */
++ u32 fgpo; /* Force general purpose output */
++ u32 rsvd6;
++ u32 rxreq; /* Receive request */
++ u32 rxcnt; /* Receive count */
++ u32 rsvd7[25];
++ u32 dmacon; /* DMA control */
++};
++
++struct ltq_spi_slave {
++ struct spi_slave slave;
++ unsigned int max_hz;
++ unsigned int mode;
++ unsigned int len;
++ unsigned int brt;
++ unsigned int tx_cnt;
++ unsigned int rx_cnt;
++ unsigned int rx_req;
++ const u8 *tx;
++ u8 *rx;
++ u8 txfs;
++ u8 rxfs;
++};
++
++static inline struct ltq_spi_slave *to_ltq_spi_slave(struct spi_slave *slave)
++{
++ return container_of(slave, struct ltq_spi_slave, slave);
++}
++
++#ifdef CONFIG_SPL_BUILD
++/*
++ * We do not have or want malloc in a SPI flash SPL.
++ * Neither we have to support multiple SPI slaves. Thus we put the
++ * SPI slave context in BSS for SPL builds.
++ */
++static struct ltq_spi_slave ltq_spi_slave;
++
++static inline struct ltq_spi_slave *ltq_spi_slave_alloc(void)
++{
++ return &ltq_spi_slave;
++}
++
++static inline void ltq_spi_slave_free(struct spi_slave *slave)
++{
++}
++#else
++static inline struct ltq_spi_slave *ltq_spi_slave_alloc(void)
++{
++ return malloc(sizeof(struct ltq_spi_slave));
++}
++
++static inline void ltq_spi_slave_free(struct spi_slave *slave)
++{
++ struct ltq_spi_slave *sl;
++
++ if (slave) {
++ sl = to_ltq_spi_slave(slave);
++ free(sl);
++ }
++}
++#endif
++
++static struct ltq_spi_regs *ltq_spi_regs =
++ (struct ltq_spi_regs *) CKSEG1ADDR(LTQ_SPI_BASE);
++
++void spi_init(void)
++{
++ /* Power up SPI subsystem */
++ ltq_pm_enable(LTQ_PM_SPI);
++
++ /* Enable module and set clock divider to 1 */
++ ltq_writel(&ltq_spi_regs->clc, 1 << LTQ_SPI_CLC_RMC_SHIFT);
++
++ /* SPI/DIN input */
++ gpio_set_altfunc(16, GPIO_ALTSEL_SET, GPIO_ALTSEL_CLR, GPIO_DIR_IN);
++ /* SPI/DOUT output */
++ gpio_set_altfunc(17, GPIO_ALTSEL_SET, GPIO_ALTSEL_CLR, GPIO_DIR_OUT);
++ /* SPI/CLK output */
++ gpio_set_altfunc(18, GPIO_ALTSEL_SET, GPIO_ALTSEL_CLR, GPIO_DIR_OUT);
++}
++
++static inline u32 ltq_spi_calc_br(unsigned int max_hz)
++{
++ u32 speed_hz, spi_hz;
++ u16 brt;
++
++ /* SPI module clock is same as FPI bus clock */
++ spi_hz = ltq_get_bus_clock();
++
++ /*
++ * f_SPI
++ * baudrate = --------------
++ * 2 * (BR + 1)
++ */
++ spi_hz /= 2;
++
++ for (brt = 0; brt < 0xFFFF; brt++) {
++ speed_hz = spi_hz / (brt + 1);
++ if (speed_hz <= max_hz)
++ break;
++ }
++
++ return brt;
++}
++
++struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
++ unsigned int max_hz, unsigned int mode)
++{
++ u32 id;
++ struct ltq_spi_slave *sl;
++
++ if (!spi_cs_is_valid(bus, cs))
++ return NULL;
++
++ sl = ltq_spi_slave_alloc();
++ if (!sl)
++ return NULL;
++
++ /* Read HW capabilities */
++ id = ltq_readl(&ltq_spi_regs->id);
++ sl->txfs = (id & LTQ_SPI_ID_TXFS_MASK) >> LTQ_SPI_ID_TXFS_SHIFT;
++ sl->rxfs = (id & LTQ_SPI_ID_RXFS_MASK) >> LTQ_SPI_ID_RXFS_SHIFT;
++
++ sl->slave.bus = bus;
++ sl->slave.cs = cs;
++ sl->max_hz = max_hz;
++ sl->mode = mode;
++
++ sl->brt = ltq_spi_calc_br(max_hz);
++
++ return &sl->slave;
++}
++
++void spi_free_slave(struct spi_slave *slave)
++{
++ ltq_spi_slave_free(slave);
++}
++
++static int ltq_spi_wait_ready(struct ltq_spi_slave *sl)
++{
++ u32 stat;
++ const unsigned long timeout = 20000;
++ unsigned long timebase;
++
++ timebase = get_timer(0);
++
++ do {
++ WATCHDOG_RESET();
++
++ stat = ltq_readl(&ltq_spi_regs->stat);
++
++ if (!(stat & LTQ_SPI_STAT_BSY))
++ return 0;
++ } while (get_timer(timebase) < timeout);
++
++ return 1;
++}
++
++int spi_claim_bus(struct spi_slave *slave)
++{
++ struct ltq_spi_slave *sl = to_ltq_spi_slave(slave);
++ u32 con;
++ int ret;
++
++ /* Put module in configuration mode */
++ ltq_setbits(&ltq_spi_regs->whbstate, LTQ_SPI_WHBSTATE_CLREN);
++
++ /* Enable and flush RX and TX FIFOs */
++ ltq_setbits(&ltq_spi_regs->txfcon,
++ LTQ_SPI_TXFCON_TXFLU | LTQ_SPI_TXFCON_TXFEN);
++ ltq_setbits(&ltq_spi_regs->rxfcon,
++ LTQ_SPI_RXFCON_RXFLU | LTQ_SPI_RXFCON_RXFEN);
++
++ ret = ltq_spi_wait_ready(sl);
++ if (ret)
++ return ret;
++
++ /* Set baudrate */
++ ltq_writel(&ltq_spi_regs->brt, sl->brt);
++
++ /*
++ * Disable byte valid control (ENBV = 0) and
++ * set data width to 8 bit (BM = 7)
++ */
++ con = (7 << LTQ_SPI_CON_BM_SHIFT);
++
++ /* Disable transmitter and receiver */
++ con |= (LTQ_SPI_CON_RXOFF | LTQ_SPI_CON_TXOFF);
++
++ /* Set SPI mode
++ * Mapping: Mode CPOL CPHA CON.PO CON.PH
++ * 0 0 0 0 1
++ * 1 0 1 0 0
++ * 2 1 0 1 1
++ * 3 1 1 1 0
++ */
++ if (sl->mode & SPI_CPHA)
++ con &= ~LTQ_SPI_CON_PH;
++ else
++ con |= LTQ_SPI_CON_PH;
++
++ if (sl->mode & SPI_CPOL)
++ con |= LTQ_SPI_CON_PO;
++ else
++ con &= ~LTQ_SPI_CON_PO;
++
++ /* Set heading control */
++ if (sl->mode & SPI_LSB_FIRST)
++ con &= ~LTQ_SPI_CON_HB;
++ else
++ con |= LTQ_SPI_CON_HB;
++
++ /* Set loopback control */
++ if (sl->mode & SPI_LOOP)
++ con |= LTQ_SPI_CON_LB;
++ else
++ con &= ~LTQ_SPI_CON_LB;
++
++ ltq_writel(&ltq_spi_regs->con, con);
++
++ /* Set SPI master mode and enable SPI */
++ ltq_setbits(&ltq_spi_regs->whbstate,
++ LTQ_SPI_WHBSTATE_SETEN | LTQ_SPI_WHBSTATE_SETMS);
++
++ return 0;
++}
++
++void spi_release_bus(struct spi_slave *slave)
++{
++ /* Put module in configuration mode */
++ ltq_setbits(&ltq_spi_regs->whbstate, LTQ_SPI_WHBSTATE_CLREN);
++
++ /* Flush RX and TX FIFOs */
++ ltq_setbits(&ltq_spi_regs->txfcon, LTQ_SPI_TXFCON_TXFLU);
++ ltq_setbits(&ltq_spi_regs->rxfcon, LTQ_SPI_RXFCON_RXFLU);
++}
++
++static inline void ltq_spi_txfifo_write(struct ltq_spi_slave *sl)
++{
++ u32 fstat, tb;
++ u16 fifo_space;
++
++ fstat = ltq_readl(&ltq_spi_regs->fstat);
++ fifo_space = sl->txfs - ((fstat & LTQ_SPI_FSTAT_TXFFL_MASK) >>
++ LTQ_SPI_FSTAT_TXFFL_SHIFT);
++
++ while (sl->tx_cnt < sl->len && fifo_space) {
++ tb = *sl->tx++;
++ ltq_writel(&ltq_spi_regs->tb, tb);
++ fifo_space--;
++ sl->tx_cnt++;
++ }
++}
++
++static inline void ltq_spi_rx_request(struct ltq_spi_slave *sl)
++{
++ u32 rxreq, rxreq_max;
++
++ /*
++ * In RX-only mode the serial clock is activated only after writing
++ * the expected amount of RX bytes into RXREQ register.
++ * To avoid receive overflows at high clocks it is better to request
++ * only the amount of bytes that fits into all FIFOs. This value
++ * depends on the FIFO size implemented in hardware.
++ */
++ rxreq = sl->len - sl->rx_cnt;
++ rxreq_max = sl->rxfs << 2;
++ rxreq = min(rxreq_max, rxreq);
++
++ if (!sl->rx_req && rxreq && sl->rx_cnt < sl->len) {
++ ltq_writel(&ltq_spi_regs->rxreq, rxreq);
++ sl->rx_req = rxreq;
++ }
++}
++
++static void ltq_spi_rxfifo_read(struct ltq_spi_slave *sl)
++{
++ u32 fstat, data, *rx32;
++ u16 fifo_fill;
++ u8 rxbv, shift, *rx8;
++
++ /* Determine how much FIFOs are filled with RX data */
++ fstat = ltq_readl(&ltq_spi_regs->fstat);
++ fifo_fill = fstat & LTQ_SPI_FSTAT_RXFFL_MASK;
++
++ /*
++ * The 32 bit FIFO is always used completely independent from the
++ * bits_per_word value. Thus four bytes have to be read at once
++ * per FIFO.
++ */
++ rx32 = (u32 *) sl->rx;
++ while (sl->len - sl->rx_cnt >= 4 && fifo_fill) {
++ data = ltq_readl(&ltq_spi_regs->rb);
++ *rx32++ = data;
++ sl->rx_cnt += 4;
++ sl->rx_req -= 4;
++ sl->rx += 4;
++ fifo_fill--;
++ }
++
++ /*
++ * If there are remaining bytes, read byte count from STAT.RXBV
++ * register and read the data byte-wise.
++ */
++ while (fifo_fill && sl->rx_cnt < sl->len) {
++ fstat = ltq_readl(&ltq_spi_regs->stat);
++ rxbv = (fstat & LTQ_SPI_STAT_RXBV_MASK) >>
++ LTQ_SPI_STAT_RXBV_SHIFT;
++
++ if (!rxbv)
++ break;
++
++ data = ltq_readl(&ltq_spi_regs->rb);
++
++ shift = (rxbv - 1) * 8;
++ rx8 = sl->rx;
++
++ while (rxbv) {
++ *rx8++ = (data >> shift) & 0xFF;
++ rxbv--;
++ shift -= 8;
++ sl->rx_cnt++;
++ sl->rx_req--;
++ sl->rx++;
++ }
++
++ fifo_fill--;
++ }
++}
++
++int spi_xfer(struct spi_slave *slave, unsigned int bitlen,
++ const void *dout, void *din, unsigned long flags)
++{
++ struct ltq_spi_slave *sl = to_ltq_spi_slave(slave);
++ int ret;
++
++ if (bitlen % 8)
++ return 1;
++
++ if (!bitlen) {
++ ret = 0;
++ goto done;
++ }
++
++ sl->len = bitlen / 8;
++ sl->tx = dout;
++ sl->rx = din;
++ sl->tx_cnt = 0;
++ sl->rx_cnt = 0;
++ sl->rx_req = 0;
++
++ if (flags & SPI_XFER_BEGIN)
++ spi_cs_activate(slave);
++
++ /* Enable transmitter */
++ if (sl->tx)
++ ltq_clrbits(&ltq_spi_regs->con, LTQ_SPI_CON_TXOFF);
++
++ /* Enable receiver */
++ if (sl->rx)
++ ltq_clrbits(&ltq_spi_regs->con, LTQ_SPI_CON_RXOFF);
++
++ if (sl->tx)
++ ltq_spi_txfifo_write(sl);
++ else if (sl->rx)
++ ltq_spi_rx_request(sl);
++
++ while (sl->tx_cnt != sl->len && sl->rx_cnt != sl->len) {
++ if (sl->rx) {
++ ltq_spi_rxfifo_read(sl);
++
++ if (sl->tx)
++ ltq_spi_txfifo_write(sl);
++ else
++ ltq_spi_rx_request(sl);
++ } else if (sl->tx)
++ ltq_spi_txfifo_write(sl);
++ }
++
++ ret = ltq_spi_wait_ready(sl);
++
++done:
++ /* Disable transmitter and receiver */
++ ltq_setbits(&ltq_spi_regs->con, LTQ_SPI_CON_TXOFF | LTQ_SPI_CON_RXOFF);
++
++ if (flags & SPI_XFER_END)
++ spi_cs_deactivate(slave);
++
++ return ret;
++}
+--- /dev/null
++++ b/include/configs/easy50712.h
+@@ -0,0 +1,78 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#ifndef __CONFIG_H
++#define __CONFIG_H
++
++#define CONFIG_MACH_TYPE "EASY50712"
++#define CONFIG_IDENT_STRING " "CONFIG_MACH_TYPE
++#define CONFIG_BOARD_NAME "Lantiq EASY50712 Danube Reference Board"
++
++/* Configure SoC */
++#define CONFIG_LTQ_SUPPORT_UART /* Enable ASC and UART */
++
++#define CONFIG_LTQ_SUPPORT_ETHERNET /* Enable ethernet */
++
++#define CONFIG_LTQ_SUPPORT_NOR_FLASH /* Have a parallel NOR flash */
++
++#define CONFIG_LTQ_SUPPORT_SPI_FLASH
++#define CONFIG_SPI_FLASH_ATMEL /* Have an AT45DB321D serial flash */
++
++#define CONFIG_LTQ_SUPPORT_SPL_NOR_FLASH /* Build NOR flash SPL */
++
++#define CONFIG_LTQ_SPL_COMP_LZO
++#define CONFIG_LTQ_SPL_CONSOLE
++
++/* Switch devices */
++#define CONFIG_SWITCH_MULTI
++#define CONFIG_SWITCH_ADM6996I
++
++/* Environment */
++#define CONFIG_ENV_SPI_BUS 0
++#define CONFIG_ENV_SPI_CS 2
++#define CONFIG_ENV_SPI_MAX_HZ 20000000
++#define CONFIG_ENV_SPI_MODE 0
++
++#if defined(CONFIG_SYS_BOOT_NOR)
++#define CONFIG_ENV_IS_IN_FLASH
++#define CONFIG_ENV_OVERWRITE
++#define CONFIG_ENV_OFFSET (256 * 1024)
++#define CONFIG_ENV_SECT_SIZE (64 * 1024)
++#elif defined(CONFIG_SYS_BOOT_NORSPL)
++#define CONFIG_ENV_IS_IN_FLASH
++#define CONFIG_ENV_OVERWRITE
++#define CONFIG_ENV_OFFSET (128 * 1024)
++#define CONFIG_ENV_SECT_SIZE (64 * 1024)
++#else
++#define CONFIG_ENV_IS_NOWHERE
++#endif
++
++#define CONFIG_ENV_SIZE (8 * 1024)
++
++#define CONFIG_LOADADDR CONFIG_SYS_LOAD_ADDR
++
++/* Console */
++#define CONFIG_LTQ_ADVANCED_CONSOLE
++#define CONFIG_BAUDRATE 115200
++#define CONFIG_CONSOLE_ASC 1
++#define CONFIG_CONSOLE_DEV "ttyLTQ1"
++
++/* Commands */
++#define CONFIG_CMD_PING
++
++/* Pull in default board configs for Lantiq XWAY Danube */
++#include <asm/lantiq/config.h>
++#include <asm/arch/config.h>
++
++#define CONFIG_ENV_UPDATE_UBOOT_NOR \
++ "update-uboot-nor=run load-uboot-norspl-lzo write-uboot-nor\0"
++
++#define CONFIG_EXTRA_ENV_SETTINGS \
++ CONFIG_ENV_LANTIQ_DEFAULTS \
++ CONFIG_ENV_UPDATE_UBOOT_NOR
++
++#endif /* __CONFIG_H */
+--- /dev/null
++++ b/include/configs/easy80920.h
+@@ -0,0 +1,93 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#ifndef __CONFIG_H
++#define __CONFIG_H
++
++#define CONFIG_MACH_TYPE "EASY80920"
++#define CONFIG_IDENT_STRING " "CONFIG_MACH_TYPE
++#define CONFIG_BOARD_NAME "Lantiq EASY80920 VRX200 Family Board"
++
++/* Configure SoC */
++#define CONFIG_LTQ_SUPPORT_UART /* Enable ASC and UART */
++
++#define CONFIG_LTQ_SUPPORT_ETHERNET /* Enable ethernet */
++
++#define CONFIG_LTQ_SUPPORT_NOR_FLASH /* Have a parallel NOR flash */
++
++#define CONFIG_LTQ_SUPPORT_SPI_FLASH
++#define CONFIG_SPI_FLASH_MACRONIX /* Have a MX29LV620 serial flash */
++
++#define CONFIG_LTQ_SUPPORT_NAND_FLASH
++
++#define CONFIG_LTQ_SUPPORT_SPL_SPI_FLASH /* Build SPI flash SPL */
++#define CONFIG_SPL_SPI_BUS 0
++#define CONFIG_SPL_SPI_CS 4
++#define CONFIG_SPL_SPI_MAX_HZ 25000000
++#define CONFIG_SPL_SPI_MODE 0
++
++#define CONFIG_LTQ_SUPPORT_SPL_NOR_FLASH /* Build NOR flash SPL */
++
++#define CONFIG_LTQ_SPL_COMP_LZO
++#define CONFIG_LTQ_SPL_CONSOLE
++
++#define CONFIG_SYS_DRAM_PROBE
++
++/* Environment */
++#define CONFIG_ENV_SPI_BUS CONFIG_SPL_SPI_BUS
++#define CONFIG_ENV_SPI_CS CONFIG_SPL_SPI_CS
++#define CONFIG_ENV_SPI_MAX_HZ CONFIG_SPL_SPI_MAX_HZ
++#define CONFIG_ENV_SPI_MODE CONFIG_SPL_SPI_MODE
++
++#if defined(CONFIG_SYS_BOOT_NOR)
++#define CONFIG_ENV_IS_IN_FLASH
++#define CONFIG_ENV_OVERWRITE
++#define CONFIG_ENV_OFFSET (384 * 1024)
++#define CONFIG_ENV_SECT_SIZE (64 * 1024)
++#elif defined(CONFIG_SYS_BOOT_NORSPL)
++#define CONFIG_ENV_IS_IN_FLASH
++#define CONFIG_ENV_OVERWRITE
++#define CONFIG_ENV_OFFSET (192 * 1024)
++#define CONFIG_ENV_SECT_SIZE (64 * 1024)
++#elif defined(CONFIG_SYS_BOOT_SFSPL)
++#define CONFIG_ENV_IS_IN_SPI_FLASH
++#define CONFIG_ENV_OVERWRITE
++#define CONFIG_ENV_OFFSET (192 * 1024)
++#define CONFIG_ENV_SECT_SIZE (64 * 1024)
++#else
++#define CONFIG_ENV_IS_NOWHERE
++#endif
++
++#define CONFIG_ENV_SIZE (8 * 1024)
++
++#define CONFIG_LOADADDR CONFIG_SYS_LOAD_ADDR
++
++/* Console */
++#define CONFIG_LTQ_ADVANCED_CONSOLE
++#define CONFIG_BAUDRATE 115200
++#define CONFIG_CONSOLE_ASC 1
++#define CONFIG_CONSOLE_DEV "ttyLTQ1"
++
++/* Commands */
++#define CONFIG_CMD_PING
++
++/* Pull in default board configs for Lantiq XWAY VRX200 */
++#include <asm/lantiq/config.h>
++#include <asm/arch/config.h>
++
++#define CONFIG_ENV_UPDATE_UBOOT_NOR \
++ "update-uboot-nor=run load-uboot-norspl-lzo write-uboot-nor\0"
++
++#define CONFIG_ENV_UPDATE_UBOOT_SF \
++ "update-uboot-sf=run load-uboot-sfspl-lzo write-uboot-sf\0"
++
++#define CONFIG_EXTRA_ENV_SETTINGS \
++ CONFIG_ENV_LANTIQ_DEFAULTS \
++ CONFIG_ENV_UPDATE_UBOOT_NOR \
++ CONFIG_ENV_UPDATE_UBOOT_SF
++
++#endif /* __CONFIG_H */
+--- a/include/phy.h
++++ b/include/phy.h
+@@ -220,6 +220,7 @@ int gen10g_discover_mmds(struct phy_devi
+ int phy_atheros_init(void);
+ int phy_broadcom_init(void);
+ int phy_davicom_init(void);
++int phy_lantiq_init(void);
+ int phy_lxt_init(void);
+ int phy_marvell_init(void);
+ int phy_micrel_init(void);
+--- a/spl/Makefile
++++ b/spl/Makefile
+@@ -81,6 +81,8 @@ LIBS-$(CONFIG_SPL_POST_MEM_SUPPORT) += p
+ LIBS-$(CONFIG_SPL_NET_SUPPORT) += net/libnet.o
+ LIBS-$(CONFIG_SPL_ETH_SUPPORT) += drivers/net/libnet.o
+ LIBS-$(CONFIG_SPL_ETH_SUPPORT) += drivers/net/phy/libphy.o
++LIBS-$(CONFIG_SPL_LZMA_SUPPORT) += lib/lzma/liblzma.o
++LIBS-$(CONFIG_SPL_LZO_SUPPORT) += lib/lzo/liblzo.o
+
+ ifneq ($(CONFIG_AM33XX)$(CONFIG_OMAP34XX)$(CONFIG_OMAP44XX)$(CONFIG_OMAP54XX),)
+ LIBS-y += $(CPUDIR)/omap-common/libomap-common.o
+--- a/tools/.gitignore
++++ b/tools/.gitignore
+@@ -2,6 +2,7 @@
+ /envcrc
+ /gen_eth_addr
+ /img2srec
++/ltq-boot-image
+ /kwboot
+ /mkenvimage
+ /mkimage
+--- a/tools/Makefile
++++ b/tools/Makefile
+@@ -65,6 +65,7 @@ BIN_FILES-$(CONFIG_VIDEO_LOGO) += bmp_lo
+ BIN_FILES-$(CONFIG_BUILD_ENVCRC) += envcrc$(SFX)
+ BIN_FILES-$(CONFIG_CMD_NET) += gen_eth_addr$(SFX)
+ BIN_FILES-$(CONFIG_CMD_LOADS) += img2srec$(SFX)
++BIN_FILES-$(CONFIG_SOC_LANTIQ) += ltq-boot-image$(SFX)
+ BIN_FILES-$(CONFIG_XWAY_SWAP_BYTES) += xway-swap-bytes$(SFX)
+ BIN_FILES-y += mkenvimage$(SFX)
+ BIN_FILES-y += mkimage$(SFX)
+@@ -89,6 +90,7 @@ OBJ_FILES-$(CONFIG_BUILD_ENVCRC) += envc
+ NOPED_OBJ_FILES-y += fit_image.o
+ OBJ_FILES-$(CONFIG_CMD_NET) += gen_eth_addr.o
+ OBJ_FILES-$(CONFIG_CMD_LOADS) += img2srec.o
++OBJ_FILES-$(CONFIG_SOC_LANTIQ) += ltq-boot-image.o
+ OBJ_FILES-$(CONFIG_XWAY_SWAP_BYTES) += xway-swap-bytes.o
+ NOPED_OBJ_FILES-y += aisimage.o
+ NOPED_OBJ_FILES-y += kwbimage.o
+@@ -193,6 +195,10 @@ $(obj)img2srec$(SFX): $(obj)img2srec.o
+ $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
+ $(HOSTSTRIP) $@
+
++$(obj)ltq-boot-image$(SFX): $(obj)ltq-boot-image.o
++ $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
++ $(HOSTSTRIP) $@
++
+ $(obj)xway-swap-bytes$(SFX): $(obj)xway-swap-bytes.o
+ $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
+ $(HOSTSTRIP) $@
+--- /dev/null
++++ b/tools/ltq-boot-image.c
+@@ -0,0 +1,316 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
++#include <unistd.h>
++#include <getopt.h>
++#include <compiler.h>
++#include <sys/stat.h>
++
++enum image_types {
++ IMAGE_NONE,
++ IMAGE_SFSPL
++};
++
++/* Lantiq non-volatile bootstrap command IDs */
++enum nvb_cmd_ids {
++ NVB_CMD_DEBUG = 0x11,
++ NVB_CMD_REGCFG = 0x22,
++ NVB_CMD_IDWNLD = 0x33,
++ NVB_CMD_CDWNLD = 0x44,
++ NVB_CMD_DWNLD = 0x55,
++ NVB_CMD_IFCFG = 0x66,
++ NVB_CMD_START = 0x77
++};
++
++/* Lantiq non-volatile bootstrap command flags */
++enum nvb_cmd_flags {
++ NVB_FLAG_START = 1,
++ NVB_FLAG_DEC = (1 << 1),
++ NVB_FLAG_DBG = (1 << 2),
++ NVB_FLAG_SDBG = (1 << 3),
++ NVB_FLAG_CFG0 = (1 << 4),
++ NVB_FLAG_CFG1 = (1 << 5),
++ NVB_FLAG_CFG2 = (1 << 6),
++ NVB_FLAG_RST = (1 << 7)
++};
++
++struct args {
++ enum image_types type;
++ __u32 entry_addr;
++ const char *uboot_bin;
++ const char *spl_bin;
++ const char *out_bin;
++};
++
++static void usage_msg(const char *name)
++{
++ fprintf(stderr, "%s: [-h] -t type -e entry-addr -u uboot-bin [-s spl-bin] -o out-bin\n",
++ name);
++ fprintf(stderr, " Image types:\n"
++ " sfspl - SPL + [compressed] U-Boot for SPI flash\n");
++}
++
++static enum image_types parse_image_type(const char *type)
++{
++ if (!type)
++ return IMAGE_NONE;
++
++ if (!strncmp(type, "sfspl", 6))
++ return IMAGE_SFSPL;
++
++ return IMAGE_NONE;
++}
++
++static int parse_args(int argc, char *argv[], struct args *arg)
++{
++ int opt;
++
++ memset(arg, 0, sizeof(*arg));
++
++ while ((opt = getopt(argc, argv, "ht:e:u:s:o:")) != -1) {
++ switch (opt) {
++ case 'h':
++ usage_msg(argv[0]);
++ return 1;
++ case 't':
++ arg->type = parse_image_type(optarg);
++ break;
++ case 'e':
++ arg->entry_addr = strtoul(optarg, NULL, 16);
++ break;
++ case 'u':
++ arg->uboot_bin = optarg;
++ break;
++ case 's':
++ arg->spl_bin = optarg;
++ break;
++ case 'o':
++ arg->out_bin = optarg;
++ break;
++ default:
++ fprintf(stderr, "Invalid option -%c\n", opt);
++ goto parse_error;
++ }
++ }
++
++ if (arg->type == IMAGE_NONE) {
++ fprintf(stderr, "Invalid image type\n");
++ goto parse_error;
++ }
++
++ if (!arg->uboot_bin) {
++ fprintf(stderr, "Missing U-Boot binary\n");
++ goto parse_error;
++ }
++
++ if (!arg->out_bin) {
++ fprintf(stderr, "Missing output binary\n");
++ goto parse_error;
++ }
++
++ if (arg->type == IMAGE_SFSPL && !arg->spl_bin) {
++ fprintf(stderr, "Missing SPL binary\n");
++ goto parse_error;
++ }
++
++ return 0;
++
++parse_error:
++ usage_msg(argv[0]);
++ return -1;
++}
++
++static __u32 build_nvb_command(unsigned cmdid, unsigned cmdflags)
++{
++ __u32 cmd;
++ __u16 tag;
++
++ tag = (cmdid << 8) | cmdflags;
++ cmd = (tag << 16) | (0xFFFF - tag);
++
++ return cpu_to_be32(cmd);
++}
++
++static int write_header(int fd, const void *hdr, size_t size)
++{
++ ssize_t n;
++
++ n = write(fd, hdr, size);
++ if (n != size) {
++ fprintf(stderr, "Cannot write header: %s\n",
++ strerror(errno));
++ return -1;
++ }
++
++ return 0;
++}
++
++static int write_nvb_dwnld_header(int fd, size_t size, __u32 addr)
++{
++ __u32 hdr[3];
++
++ hdr[0] = build_nvb_command(NVB_CMD_DWNLD, NVB_FLAG_START |
++ NVB_FLAG_SDBG);
++ hdr[1] = cpu_to_be32(size + 4);
++ hdr[2] = cpu_to_be32(addr);
++
++ return write_header(fd, hdr, sizeof(hdr));
++}
++
++static int write_nvb_start_header(int fd, __u32 addr)
++{
++ __u32 hdr[3];
++
++ hdr[0] = build_nvb_command(NVB_CMD_START, NVB_FLAG_SDBG);
++ hdr[1] = cpu_to_be32(4);
++ hdr[2] = cpu_to_be32(addr);
++
++ return write_header(fd, hdr, sizeof(hdr));
++}
++
++static int open_input_bin(const char *name, void **ptr, size_t *size)
++{
++ struct stat sbuf;
++ int ret, fd;
++
++ fd = open(name, O_RDONLY | O_BINARY);
++ if (0 > fd) {
++ fprintf(stderr, "Cannot open %s: %s\n", name,
++ strerror(errno));
++ return -1;
++ }
++
++ ret = fstat(fd, &sbuf);
++ if (0 > ret) {
++ fprintf(stderr, "Cannot fstat %s: %s\n", name,
++ strerror(errno));
++ return -1;
++ }
++
++ *ptr = mmap(0, sbuf.st_size, PROT_READ, MAP_SHARED, fd, 0);
++ if (*ptr == MAP_FAILED) {
++ fprintf(stderr, "Cannot mmap %s: %s\n", name,
++ strerror(errno));
++ return -1;
++ }
++
++ *size = sbuf.st_size;
++
++ return fd;
++}
++
++static void close_input_bin(int fd, void *ptr, size_t size)
++{
++ munmap(ptr, size);
++ close(fd);
++}
++
++static int copy_bin(int fd, void *ptr, size_t size)
++{
++ ssize_t n;
++
++ n = write(fd, ptr, size);
++ if (n != size) {
++ fprintf(stderr, "Cannot copy binary: %s\n", strerror(errno));
++ return -1;
++ }
++
++ return 0;
++}
++
++static int open_output_bin(const char *name)
++{
++ int fd;
++
++ fd = open(name, O_RDWR | O_CREAT | O_TRUNC | O_SYNC | O_BINARY, 0666);
++ if (0 > fd) {
++ fprintf(stderr, "Cannot open %s: %s\n", name,
++ strerror(errno));
++ return -1;
++ }
++
++ return fd;
++}
++
++static int create_sfspl(const struct args *arg)
++{
++ int out_fd, uboot_fd, spl_fd, ret;
++ void *uboot_ptr, *spl_ptr;
++ size_t uboot_size, spl_size;
++
++ out_fd = open_output_bin(arg->out_bin);
++ if (0 > out_fd)
++ goto err;
++
++ spl_fd = open_input_bin(arg->spl_bin, &spl_ptr, &spl_size);
++ if (0 > spl_fd)
++ goto err_spl;
++
++ uboot_fd = open_input_bin(arg->uboot_bin, &uboot_ptr, &uboot_size);
++ if (0 > uboot_fd)
++ goto err_uboot;
++
++ ret = write_nvb_dwnld_header(out_fd, spl_size, arg->entry_addr);
++ if (ret)
++ goto err_write;
++
++ ret = copy_bin(out_fd, spl_ptr, spl_size);
++ if (ret)
++ goto err_write;
++
++ ret = write_nvb_start_header(out_fd, arg->entry_addr);
++ if (ret)
++ goto err_write;
++
++ ret = copy_bin(out_fd, uboot_ptr, uboot_size);
++ if (ret)
++ goto err_write;
++
++ close_input_bin(uboot_fd, uboot_ptr, uboot_size);
++ close_input_bin(spl_fd, spl_ptr, spl_size);
++ close(out_fd);
++
++ return 0;
++
++err_write:
++ close_input_bin(uboot_fd, uboot_ptr, uboot_size);
++err_uboot:
++ close_input_bin(spl_fd, spl_ptr, spl_size);
++err_spl:
++ close(out_fd);
++err:
++ return -1;
++}
++
++int main(int argc, char *argv[])
++{
++ int ret;
++ struct args arg;
++
++ ret = parse_args(argc, argv, &arg);
++ if (ret)
++ goto done;
++
++ switch (arg.type) {
++ case IMAGE_SFSPL:
++ ret = create_sfspl(&arg);
++ break;
++ default:
++ fprintf(stderr, "Image type not implemented\n");
++ ret = -1;
++ break;
++ }
++
++done:
++ if (ret >= 0)
++ return EXIT_SUCCESS;
++
++ return EXIT_FAILURE;
++}
diff --git a/package/boot/uboot-lantiq/patches/0024-MIPS-VRX200-add-option-to-boot-from-AVM-EVA-loader.patch b/package/boot/uboot-lantiq/patches/0024-MIPS-VRX200-add-option-to-boot-from-AVM-EVA-loader.patch
new file mode 100644
index 0000000..ba24bae
--- /dev/null
+++ b/package/boot/uboot-lantiq/patches/0024-MIPS-VRX200-add-option-to-boot-from-AVM-EVA-loader.patch
@@ -0,0 +1,33 @@
+From 2c6115188c7353a601835885a6c544240cfc479e Mon Sep 17 00:00:00 2001
+From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+Date: Fri, 30 Nov 2012 18:09:25 +0100
+Subject: MIPS: VRX200: add option to boot from AVM EVA loader
+
+Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+
+--- a/arch/mips/cpu/mips32/vrx200/config.mk
++++ b/arch/mips/cpu/mips32/vrx200/config.mk
+@@ -17,6 +17,9 @@ endif
+ LIBS-y += $(CPUDIR)/lantiq-common/liblantiq-common.o
+
+ ifndef CONFIG_SPL_BUILD
++ifdef CONFIG_SYS_BOOT_EVA
++ALL-y += $(obj)u-boot.bin.lzma
++endif
+ ifdef CONFIG_SYS_BOOT_SFSPL
+ ALL-y += $(obj)u-boot.ltq.sfspl
+ ALL-$(CONFIG_SPL_LZO_SUPPORT) += $(obj)u-boot.ltq.lzo.sfspl
+--- a/arch/mips/include/asm/arch-vrx200/config.h
++++ b/arch/mips/include/asm/arch-vrx200/config.h
+@@ -161,6 +161,11 @@
+ #define CONFIG_SYS_DISABLE_CACHE
+ #endif
+
++#if defined(CONFIG_SYS_BOOT_EVA)
++#define CONFIG_SYS_TEXT_BASE 0x80100000
++#define CONFIG_SKIP_LOWLEVEL_INIT
++#endif
++
+ #if defined(CONFIG_SYS_BOOT_NOR)
+ #define CONFIG_SYS_TEXT_BASE 0xB0000000
+ #endif
diff --git a/package/boot/uboot-lantiq/patches/0025-MIPS-add-board-support-for-AVM-FritzBox-3370.patch b/package/boot/uboot-lantiq/patches/0025-MIPS-add-board-support-for-AVM-FritzBox-3370.patch
new file mode 100644
index 0000000..b680a97
--- /dev/null
+++ b/package/boot/uboot-lantiq/patches/0025-MIPS-add-board-support-for-AVM-FritzBox-3370.patch
@@ -0,0 +1,355 @@
+From 51f04c00e831b49587f9f766ff1af67d2122feb2 Mon Sep 17 00:00:00 2001
+From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+Date: Fri, 30 Nov 2012 18:09:47 +0100
+Subject: MIPS: add board support for AVM FritzBox 3370
+
+Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+
+--- /dev/null
++++ b/board/avm/fb3370/Makefile
+@@ -0,0 +1,29 @@
++#
++# This file is released under the terms of GPL v2 and any later version.
++# See the file COPYING in the root directory of the source tree for details.
++#
++# Copyright (C) 2000-2011 Wolfgang Denk, DENX Software Engineering, wd@denx.de
++# Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++#
++
++include $(TOPDIR)/config.mk
++
++LIB = $(obj)lib$(BOARD).o
++
++COBJS = $(BOARD).o
++
++SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c)
++OBJS := $(addprefix $(obj),$(COBJS))
++SOBJS := $(addprefix $(obj),$(SOBJS))
++
++$(LIB): $(obj).depend $(OBJS) $(SOBJS)
++ $(call cmd_link_o_target, $(OBJS) $(SOBJS))
++
++#########################################################################
++
++# defines $(obj).depend target
++include $(SRCTREE)/rules.mk
++
++sinclude $(obj).depend
++
++#########################################################################
+--- /dev/null
++++ b/board/avm/fb3370/config.mk
+@@ -0,0 +1,8 @@
++#
++# This file is released under the terms of GPL v2 and any later version.
++# See the file COPYING in the root directory of the source tree for details.
++#
++# Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++#
++
++PLATFORM_CPPFLAGS += -I$(TOPDIR)/board/$(BOARDDIR)
+--- /dev/null
++++ b/board/avm/fb3370/ddr_settings.h
+@@ -0,0 +1,70 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2007-2010 Lantiq Deutschland GmbH
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#define MC_CCR00_VALUE 0x101
++#define MC_CCR01_VALUE 0x1000100
++#define MC_CCR02_VALUE 0x1010000
++#define MC_CCR03_VALUE 0x101
++#define MC_CCR04_VALUE 0x1000000
++#define MC_CCR05_VALUE 0x1000101
++#define MC_CCR06_VALUE 0x1000100
++#define MC_CCR07_VALUE 0x1010000
++#define MC_CCR08_VALUE 0x1000101
++#define MC_CCR09_VALUE 0x0
++#define MC_CCR10_VALUE 0x2000100
++#define MC_CCR11_VALUE 0x2000300
++#define MC_CCR12_VALUE 0x30000
++#define MC_CCR13_VALUE 0x202
++#define MC_CCR14_VALUE 0x7080A0F
++#define MC_CCR15_VALUE 0x2040F
++#define MC_CCR16_VALUE 0x40000
++#define MC_CCR17_VALUE 0x70102
++#define MC_CCR18_VALUE 0x4020002
++#define MC_CCR19_VALUE 0x30302
++#define MC_CCR20_VALUE 0x8000700
++#define MC_CCR21_VALUE 0x40F020A
++#define MC_CCR22_VALUE 0x0
++#define MC_CCR23_VALUE 0xC020000
++#define MC_CCR24_VALUE 0x4401B04
++#define MC_CCR25_VALUE 0x0
++#define MC_CCR26_VALUE 0x0
++#define MC_CCR27_VALUE 0x6420000
++#define MC_CCR28_VALUE 0x0
++#define MC_CCR29_VALUE 0x0
++#define MC_CCR30_VALUE 0x798
++#define MC_CCR31_VALUE 0x0
++#define MC_CCR32_VALUE 0x0
++#define MC_CCR33_VALUE 0x650000
++#define MC_CCR34_VALUE 0x200C8
++#define MC_CCR35_VALUE 0x1D445D
++#define MC_CCR36_VALUE 0xC8
++#define MC_CCR37_VALUE 0xC351
++#define MC_CCR38_VALUE 0x0
++#define MC_CCR39_VALUE 0x141F04
++#define MC_CCR40_VALUE 0x142704
++#define MC_CCR41_VALUE 0x141b42
++#define MC_CCR42_VALUE 0x141b42
++#define MC_CCR43_VALUE 0x566504
++#define MC_CCR44_VALUE 0x566504
++#define MC_CCR45_VALUE 0x565F17
++#define MC_CCR46_VALUE 0x565F17
++#define MC_CCR47_VALUE 0x0
++#define MC_CCR48_VALUE 0x0
++#define MC_CCR49_VALUE 0x0
++#define MC_CCR50_VALUE 0x0
++#define MC_CCR51_VALUE 0x0
++#define MC_CCR52_VALUE 0x133
++#define MC_CCR53_VALUE 0xF3014B27
++#define MC_CCR54_VALUE 0xF3014B27
++#define MC_CCR55_VALUE 0xF3014B27
++#define MC_CCR56_VALUE 0xF3014B27
++#define MC_CCR57_VALUE 0x7800301
++#define MC_CCR58_VALUE 0x7800301
++#define MC_CCR59_VALUE 0x7800301
++#define MC_CCR60_VALUE 0x7800301
++#define MC_CCR61_VALUE 0x4
+--- /dev/null
++++ b/board/avm/fb3370/fb3370.c
+@@ -0,0 +1,139 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#include <common.h>
++#include <spi.h>
++#include <asm/gpio.h>
++#include <asm/lantiq/eth.h>
++#include <asm/lantiq/chipid.h>
++#include <asm/lantiq/cpu.h>
++#include <asm/arch/gphy.h>
++
++#if defined(CONFIG_SPL_BUILD)
++#define do_gpio_init 1
++#define do_pll_init 1
++#define do_dcdc_init 0
++#elif defined(CONFIG_SYS_BOOT_RAM)
++#define do_gpio_init 1
++#define do_pll_init 0
++#define do_dcdc_init 1
++#elif defined(CONFIG_SYS_BOOT_NOR)
++#define do_gpio_init 1
++#define do_pll_init 1
++#define do_dcdc_init 1
++#else
++#define do_gpio_init 0
++#define do_pll_init 0
++#define do_dcdc_init 1
++#endif
++
++static void gpio_init(void)
++{
++ /* SPI CS 0.4 to serial flash */
++ gpio_direction_output(10, 1);
++
++ /* EBU.FL_CS1 as output for NAND CE */
++ gpio_set_altfunc(23, GPIO_ALTSEL_SET, GPIO_ALTSEL_CLR, GPIO_DIR_OUT);
++ /* EBU.FL_A23 as output for NAND CLE */
++ gpio_set_altfunc(24, GPIO_ALTSEL_SET, GPIO_ALTSEL_CLR, GPIO_DIR_OUT);
++ /* EBU.FL_A24 as output for NAND ALE */
++ gpio_set_altfunc(13, GPIO_ALTSEL_SET, GPIO_ALTSEL_CLR, GPIO_DIR_OUT);
++ /* GPIO 3.0 as input for NAND Ready Busy */
++ gpio_set_altfunc(48, GPIO_ALTSEL_SET, GPIO_ALTSEL_CLR, GPIO_DIR_IN);
++ /* GPIO 3.1 as output for NAND Read */
++ gpio_set_altfunc(49, GPIO_ALTSEL_SET, GPIO_ALTSEL_CLR, GPIO_DIR_OUT);
++}
++
++int board_early_init_f(void)
++{
++ if (do_gpio_init)
++ gpio_init();
++
++ if (do_pll_init)
++ ltq_pll_init();
++
++ if (do_dcdc_init)
++ ltq_dcdc_init(0x7F);
++
++ return 0;
++}
++
++int checkboard(void)
++{
++ puts("Board: " CONFIG_BOARD_NAME "\n");
++ ltq_chip_print_info();
++
++ return 0;
++}
++
++static const struct ltq_eth_port_config eth_port_config[] = {
++ /* GMAC0: external Lantiq PEF7071 10/100/1000 PHY for LAN port 0 */
++ { 0, 0x0, LTQ_ETH_PORT_PHY, PHY_INTERFACE_MODE_RGMII },
++ /* GMAC1: external Lantiq PEF7071 10/100/1000 PHY for LAN port 1 */
++ { 1, 0x1, LTQ_ETH_PORT_PHY, PHY_INTERFACE_MODE_RGMII },
++ /* GMAC2: internal GPHY0 with 10/100/1000 firmware for LAN port 2 */
++ { 2, 0x11, LTQ_ETH_PORT_PHY, PHY_INTERFACE_MODE_GMII },
++ /* GMAC3: unused */
++ { 3, 0x0, LTQ_ETH_PORT_NONE, PHY_INTERFACE_MODE_NONE },
++ /* GMAC4: internal GPHY1 with 10/100/1000 firmware for LAN port 3 */
++ { 4, 0x13, LTQ_ETH_PORT_PHY, PHY_INTERFACE_MODE_GMII },
++ /* GMAC5: external Lantiq PEF7071 10/100/1000 PHY for WANoE port */
++ { 5, 0x5, LTQ_ETH_PORT_PHY, PHY_INTERFACE_MODE_RGMII },
++};
++
++static const struct ltq_eth_board_config eth_board_config = {
++ .ports = eth_port_config,
++ .num_ports = ARRAY_SIZE(eth_port_config),
++};
++
++int board_eth_init(bd_t * bis)
++{
++ const enum ltq_gphy_clk clk = LTQ_GPHY_CLK_25MHZ_PLL0;
++ const ulong fw_addr = 0x80FF0000;
++
++ ltq_gphy_phy11g_a1x_load(fw_addr);
++
++ ltq_cgu_gphy_clk_src(clk);
++
++ ltq_rcu_gphy_boot(0, fw_addr);
++ ltq_rcu_gphy_boot(1, fw_addr);
++
++ return ltq_eth_initialize(&eth_board_config);
++}
++
++int spi_cs_is_valid(unsigned int bus, unsigned int cs)
++{
++ if (bus)
++ return 0;
++
++ if (cs == 4)
++ return 1;
++
++ return 0;
++}
++
++void spi_cs_activate(struct spi_slave *slave)
++{
++ switch (slave->cs) {
++ case 4:
++ gpio_set_value(10, 0);
++ break;
++ default:
++ break;
++ }
++}
++
++void spi_cs_deactivate(struct spi_slave *slave)
++{
++ switch (slave->cs) {
++ case 4:
++ gpio_set_value(10, 1);
++ break;
++ default:
++ break;
++ }
++}
+--- a/boards.cfg
++++ b/boards.cfg
+@@ -451,6 +451,9 @@ incaip mips
+ incaip_100MHz mips mips32 incaip - incaip incaip:CPU_CLOCK_RATE=100000000
+ incaip_133MHz mips mips32 incaip - incaip incaip:CPU_CLOCK_RATE=133000000
+ incaip_150MHz mips mips32 incaip - incaip incaip:CPU_CLOCK_RATE=150000000
++fb3370_ram mips mips32 fb3370 avm vrx200 fb3370:SYS_BOOT_RAM
++fb3370_eva mips mips32 fb3370 avm vrx200 fb3370:SYS_BOOT_EVA
++fb3370_sfspl mips mips32 fb3370 avm vrx200 fb3370:SYS_BOOT_SFSPL
+ easy80920_nor mips mips32 easy80920 lantiq vrx200 easy80920:SYS_BOOT_NOR
+ easy80920_norspl mips mips32 easy80920 lantiq vrx200 easy80920:SYS_BOOT_NORSPL
+ easy80920_ram mips mips32 easy80920 lantiq vrx200 easy80920:SYS_BOOT_RAM
+--- /dev/null
++++ b/include/configs/fb3370.h
+@@ -0,0 +1,75 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++ */
++
++#ifndef __CONFIG_H
++#define __CONFIG_H
++
++#define CONFIG_MACH_TYPE "FB3370"
++#define CONFIG_IDENT_STRING " "CONFIG_MACH_TYPE
++#define CONFIG_BOARD_NAME "AVM FritzBox 3370"
++
++/* Configure SoC */
++#define CONFIG_LTQ_SUPPORT_UART /* Enable ASC and UART */
++
++#define CONFIG_LTQ_SUPPORT_ETHERNET /* Enable ethernet */
++
++#define CONFIG_LTQ_SUPPORT_SPI_FLASH
++#define CONFIG_SPI_FLASH_MACRONIX /* Have a MX29LV620 serial flash */
++
++#define CONFIG_LTQ_SUPPORT_NAND_FLASH
++
++#define CONFIG_LTQ_SUPPORT_SPL_SPI_FLASH /* Build SPI flash SPL */
++#define CONFIG_SPL_SPI_BUS 0
++#define CONFIG_SPL_SPI_CS 4
++#define CONFIG_SPL_SPI_MAX_HZ 25000000
++#define CONFIG_SPL_SPI_MODE 0
++
++#define CONFIG_LTQ_SPL_COMP_LZO
++#define CONFIG_LTQ_SPL_CONSOLE
++
++#define CONFIG_SYS_DRAM_PROBE
++
++/* Environment */
++#define CONFIG_ENV_SPI_BUS CONFIG_SPL_SPI_BUS
++#define CONFIG_ENV_SPI_CS CONFIG_SPL_SPI_CS
++#define CONFIG_ENV_SPI_MAX_HZ CONFIG_SPL_SPI_MAX_HZ
++#define CONFIG_ENV_SPI_MODE CONFIG_SPL_SPI_MODE
++
++#if defined(CONFIG_SYS_BOOT_SFSPL)
++#define CONFIG_ENV_IS_IN_SPI_FLASH
++#define CONFIG_ENV_OVERWRITE
++#define CONFIG_ENV_OFFSET (192 * 1024)
++#define CONFIG_ENV_SECT_SIZE (64 * 1024)
++#else
++#define CONFIG_ENV_IS_NOWHERE
++#endif
++
++#define CONFIG_ENV_SIZE (8 * 1024)
++
++#define CONFIG_LOADADDR CONFIG_SYS_LOAD_ADDR
++
++/* Console */
++#define CONFIG_LTQ_ADVANCED_CONSOLE
++#define CONFIG_BAUDRATE 115200
++#define CONFIG_CONSOLE_ASC 1
++#define CONFIG_CONSOLE_DEV "ttyLTQ1"
++
++/* Commands */
++#define CONFIG_CMD_PING
++
++/* Pull in default board configs for Lantiq XWAY VRX200 */
++#include <asm/lantiq/config.h>
++#include <asm/arch/config.h>
++
++#define CONFIG_ENV_UPDATE_UBOOT_SF \
++ "update-uboot-sf=run load-uboot-sfspl-lzo write-uboot-sf\0"
++
++#define CONFIG_EXTRA_ENV_SETTINGS \
++ CONFIG_ENV_LANTIQ_DEFAULTS \
++ CONFIG_ENV_UPDATE_UBOOT_SF
++
++#endif /* __CONFIG_H */
diff --git a/package/boot/uboot-lantiq/patches/0026-MIPS-add-board-support-for-Gigaset-SX76X.patch b/package/boot/uboot-lantiq/patches/0026-MIPS-add-board-support-for-Gigaset-SX76X.patch
new file mode 100644
index 0000000..810770a
--- /dev/null
+++ b/package/boot/uboot-lantiq/patches/0026-MIPS-add-board-support-for-Gigaset-SX76X.patch
@@ -0,0 +1,264 @@
+From 66b56aa3a4810f10e0b0c77bb87279a8d64b566b Mon Sep 17 00:00:00 2001
+From: Luka Perkov <luka@openwrt.org>
+Date: Fri, 16 Dec 2011 11:55:45 +0100
+Subject: MIPS: add board support for Gigaset SX76X
+
+Signed-off-by: Luka Perkov <luka@openwrt.org>
+Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+
+--- /dev/null
++++ b/board/gigaset/sx76x/Makefile
+@@ -0,0 +1,29 @@
++#
++# This file is released under the terms of GPL v2 and any later version.
++# See the file COPYING in the root directory of the source tree for details.
++#
++# Copyright (C) 2000-2011 Wolfgang Denk, DENX Software Engineering, wd@denx.de
++# Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++#
++
++include $(TOPDIR)/config.mk
++
++LIB = $(obj)lib$(BOARD).o
++
++COBJS = $(BOARD).o
++
++SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c)
++OBJS := $(addprefix $(obj),$(COBJS))
++SOBJS := $(addprefix $(obj),$(SOBJS))
++
++$(LIB): $(obj).depend $(OBJS) $(SOBJS)
++ $(call cmd_link_o_target, $(OBJS) $(SOBJS))
++
++#########################################################################
++
++# defines $(obj).depend target
++include $(SRCTREE)/rules.mk
++
++sinclude $(obj).depend
++
++#########################################################################
+--- /dev/null
++++ b/board/gigaset/sx76x/config.mk
+@@ -0,0 +1,8 @@
++#
++# This file is released under the terms of GPL v2 and any later version.
++# See the file COPYING in the root directory of the source tree for details.
++#
++# Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++#
++
++PLATFORM_CPPFLAGS += -I$(TOPDIR)/board/$(BOARDDIR)
+--- /dev/null
++++ b/board/gigaset/sx76x/ddr_settings.h
+@@ -0,0 +1,56 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * generated with lantiq_ram_extract_magic.awk
++ *
++ * Copyright (C) 2011 Luka Perkov <luka@openwrt.org>
++ */
++
++#define MC_DC00_VALUE 0x1B1B
++#define MC_DC01_VALUE 0x0
++#define MC_DC02_VALUE 0x0
++#define MC_DC03_VALUE 0x0
++#define MC_DC04_VALUE 0x0
++#define MC_DC05_VALUE 0x200
++#define MC_DC06_VALUE 0x605
++#define MC_DC07_VALUE 0x303
++#define MC_DC08_VALUE 0x202
++#define MC_DC09_VALUE 0x70A
++#define MC_DC10_VALUE 0x203
++#define MC_DC11_VALUE 0xC02
++#define MC_DC12_VALUE 0x1C8
++#define MC_DC13_VALUE 0x1
++#define MC_DC14_VALUE 0x0
++#define MC_DC15_VALUE 0xF3E
++#define MC_DC16_VALUE 0xC800
++#define MC_DC17_VALUE 0xD
++#define MC_DC18_VALUE 0x300
++#define MC_DC19_VALUE 0x200
++#define MC_DC20_VALUE 0xA04
++#define MC_DC21_VALUE 0xF00
++#define MC_DC22_VALUE 0xF0F
++#define MC_DC23_VALUE 0x0
++#define MC_DC24_VALUE 0x63
++#define MC_DC25_VALUE 0x0
++#define MC_DC26_VALUE 0x100
++#define MC_DC27_VALUE 0x0
++#define MC_DC28_VALUE 0x514
++#define MC_DC29_VALUE 0x2D89
++#define MC_DC30_VALUE 0x8300
++#define MC_DC31_VALUE 0x2002
++#define MC_DC32_VALUE 0x0
++#define MC_DC33_VALUE 0x0
++#define MC_DC34_VALUE 0x0
++#define MC_DC35_VALUE 0x0
++#define MC_DC36_VALUE 0x0
++#define MC_DC37_VALUE 0x0
++#define MC_DC38_VALUE 0x0
++#define MC_DC39_VALUE 0x0
++#define MC_DC40_VALUE 0x0
++#define MC_DC41_VALUE 0x0
++#define MC_DC42_VALUE 0x0
++#define MC_DC43_VALUE 0x0
++#define MC_DC44_VALUE 0x0
++#define MC_DC45_VALUE 0x500
++#define MC_DC46_VALUE 0x0
+--- /dev/null
++++ b/board/gigaset/sx76x/sx76x.c
+@@ -0,0 +1,66 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Luka Perkov <luka@openwrt.org>
++ */
++
++#include <common.h>
++#include <switch.h>
++#include <asm/gpio.h>
++#include <asm/lantiq/eth.h>
++#include <asm/lantiq/reset.h>
++#include <asm/lantiq/chipid.h>
++
++static void gpio_init(void)
++{
++ /* Activate reset line of ADM6996I switch */
++ gpio_direction_output(19, 0);
++}
++
++int board_early_init_f(void)
++{
++ gpio_init();
++
++ return 0;
++}
++
++int checkboard(void)
++{
++ puts("Board: " CONFIG_BOARD_NAME "\n");
++ ltq_chip_print_info();
++
++ return 0;
++}
++
++static const struct ltq_eth_port_config eth_port_config[] = {
++ /* MAC0: Lantiq ADM6996I switch */
++ { 0, 0x0, LTQ_ETH_PORT_SWITCH, PHY_INTERFACE_MODE_RMII },
++};
++
++static const struct ltq_eth_board_config eth_board_config = {
++ .ports = eth_port_config,
++ .num_ports = ARRAY_SIZE(eth_port_config),
++};
++
++int board_eth_init(bd_t *bis)
++{
++ return ltq_eth_initialize(&eth_board_config);
++}
++
++static struct switch_device adm6996i_dev = {
++ .name = "adm6996i",
++ .cpu_port = 5,
++ .port_mask = 0xF,
++};
++
++int board_switch_init(void)
++{
++ /* Deactivate reset line of ADM6996I switch */
++ gpio_set_value(19, 1);
++
++ /* ADM6996I needs some time to come out of reset */
++ __udelay(50000);
++
++ return switch_device_register(&adm6996i_dev);
++}
+--- a/boards.cfg
++++ b/boards.cfg
+@@ -447,6 +447,8 @@ pb1000 mips
+ easy50712_nor mips mips32 easy50712 lantiq danube easy50712:SYS_BOOT_NOR
+ easy50712_norspl mips mips32 easy50712 lantiq danube easy50712:SYS_BOOT_NORSPL
+ easy50712_ram mips mips32 easy50712 lantiq danube easy50712:SYS_BOOT_RAM
++gigasx76x_nor mips mips32 sx76x gigaset danube sx76x:SYS_BOOT_NOR
++gigasx76x_ram mips mips32 sx76x gigaset danube sx76x:SYS_BOOT_RAM
+ incaip mips mips32 incaip - incaip
+ incaip_100MHz mips mips32 incaip - incaip incaip:CPU_CLOCK_RATE=100000000
+ incaip_133MHz mips mips32 incaip - incaip incaip:CPU_CLOCK_RATE=133000000
+--- /dev/null
++++ b/include/configs/sx76x.h
+@@ -0,0 +1,71 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2011 Luka Perkov <luka@openwrt.org>
++ */
++
++#ifndef __CONFIG_H
++#define __CONFIG_H
++
++#define CONFIG_MACH_TYPE "GIGASX76X"
++#define CONFIG_IDENT_STRING " sx76x"
++#define CONFIG_BOARD_NAME "Gigaset sx76x"
++
++/* Configure SoC */
++#define CONFIG_LTQ_SUPPORT_UART /* Enable ASC and UART */
++
++#define CONFIG_LTQ_SUPPORT_ETHERNET /* Enable ethernet */
++
++#define CONFIG_LTQ_SUPPORT_NOR_FLASH /* Have a parallel NOR flash */
++
++/* Switch devices */
++#define CONFIG_SWITCH_MULTI
++#define CONFIG_SWITCH_ADM6996I
++
++/* Environment */
++#if defined(CONFIG_SYS_BOOT_NOR)
++#define CONFIG_ENV_IS_IN_FLASH
++#define CONFIG_ENV_OVERWRITE
++#define CONFIG_ENV_OFFSET (256 * 1024)
++#define CONFIG_ENV_SIZE (8 * 1024)
++#define CONFIG_ENV_SECT_SIZE (64 * 1024)
++#else
++#define CONFIG_ENV_IS_NOWHERE
++#define CONFIG_ENV_SIZE (2 * 1024)
++#endif
++
++#define CONFIG_LOADADDR CONFIG_SYS_LOAD_ADDR
++
++/* Console */
++#define CONFIG_LTQ_ADVANCED_CONSOLE
++#define CONFIG_BAUDRATE 115200
++#define CONFIG_CONSOLE_ASC 1
++#define CONFIG_CONSOLE_DEV "ttyLTQ1"
++
++/* Commands */
++#define CONFIG_CMD_PING
++
++/* Pull in default board configs for Lantiq XWAY Danube */
++#include <asm/lantiq/config.h>
++#include <asm/arch/config.h>
++
++/* Compression */
++#define CONFIG_LZMA
++
++/* Auto boot */
++#define CONFIG_BOOTDELAY 2
++
++/* Environment configuration */
++#define CONFIG_BOOTCOMMAND \
++ "run addeth; bootm ${kernel_addr}"
++
++#define CONFIG_ENV_UPDATE_UBOOT_NOR \
++ "update-uboot-nor=run load-uboot-nor write-uboot-nor\0"
++
++#define CONFIG_EXTRA_ENV_SETTINGS \
++ CONFIG_ENV_LANTIQ_DEFAULTS \
++ CONFIG_ENV_UPDATE_UBOOT_NOR \
++ "kernel_addr=0xB0040000\0"
++
++#endif /* __CONFIG_H */
diff --git a/package/boot/uboot-lantiq/patches/0027-MIPS-add-board-support-for-Arcadyan-ARV7518.patch b/package/boot/uboot-lantiq/patches/0027-MIPS-add-board-support-for-Arcadyan-ARV7518.patch
new file mode 100644
index 0000000..4156089
--- /dev/null
+++ b/package/boot/uboot-lantiq/patches/0027-MIPS-add-board-support-for-Arcadyan-ARV7518.patch
@@ -0,0 +1,248 @@
+From 289f7ed5d725067b4eb4b1a105bb63d55bf20392 Mon Sep 17 00:00:00 2001
+From: Luka Perkov <luka@openwrt.org>
+Date: Wed, 29 Aug 2012 22:08:41 +0200
+Subject: MIPS: add board support for Arcadyan ARV7518
+
+Signed-off-by: Luka Perkov <luka@openwrt.org>
+Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+
+--- /dev/null
++++ b/board/arcadyan/arv7518pw/Makefile
+@@ -0,0 +1,29 @@
++#
++# This file is released under the terms of GPL v2 and any later version.
++# See the file COPYING in the root directory of the source tree for details.
++#
++# Copyright (C) 2000-2011 Wolfgang Denk, DENX Software Engineering, wd@denx.de
++# Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++#
++
++include $(TOPDIR)/config.mk
++
++LIB = $(obj)lib$(BOARD).o
++
++COBJS = $(BOARD).o
++
++SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c)
++OBJS := $(addprefix $(obj),$(COBJS))
++SOBJS := $(addprefix $(obj),$(SOBJS))
++
++$(LIB): $(obj).depend $(OBJS) $(SOBJS)
++ $(call cmd_link_o_target, $(OBJS) $(SOBJS))
++
++#########################################################################
++
++# defines $(obj).depend target
++include $(SRCTREE)/rules.mk
++
++sinclude $(obj).depend
++
++#########################################################################
+--- /dev/null
++++ b/board/arcadyan/arv7518pw/arv7518pw.c
+@@ -0,0 +1,52 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2012 Luka Perkov <luka@openwrt.org>
++ */
++
++#include <common.h>
++#include <switch.h>
++#include <asm/gpio.h>
++#include <asm/lantiq/eth.h>
++#include <asm/lantiq/reset.h>
++#include <asm/lantiq/chipid.h>
++
++int board_early_init_f(void)
++{
++ return 0;
++}
++
++int checkboard(void)
++{
++ puts("Board: " CONFIG_BOARD_NAME "\n");
++ ltq_chip_print_info();
++
++ return 0;
++}
++
++static const struct ltq_eth_port_config eth_port_config[] = {
++ /* MAC0: Atheros ar8216 switch */
++ { 0, 0x0, LTQ_ETH_PORT_SWITCH, PHY_INTERFACE_MODE_NONE },
++};
++
++static const struct ltq_eth_board_config eth_board_config = {
++ .ports = eth_port_config,
++ .num_ports = ARRAY_SIZE(eth_port_config),
++};
++
++int board_eth_init(bd_t *bis)
++{
++ return ltq_eth_initialize(&eth_board_config);
++}
++
++static struct switch_device ar8216_dev = {
++ .name = "ar8216",
++ .cpu_port = 0,
++ .port_mask = 0xF,
++};
++
++int board_switch_init(void)
++{
++ return switch_device_register(&ar8216_dev);
++}
+--- /dev/null
++++ b/board/arcadyan/arv7518pw/config.mk
+@@ -0,0 +1,8 @@
++#
++# This file is released under the terms of GPL v2 and any later version.
++# See the file COPYING in the root directory of the source tree for details.
++#
++# Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++#
++
++PLATFORM_CPPFLAGS += -I$(TOPDIR)/board/$(BOARDDIR)
+--- /dev/null
++++ b/board/arcadyan/arv7518pw/ddr_settings.h
+@@ -0,0 +1,56 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * generated with lantiq_ram_extract_magic.awk
++ *
++ * Copyright (C) 2012 Luka Perkov <luka@openwrt.org>
++ */
++
++#define MC_DC00_VALUE 0x1B1B
++#define MC_DC01_VALUE 0x0
++#define MC_DC02_VALUE 0x0
++#define MC_DC03_VALUE 0x0
++#define MC_DC04_VALUE 0x0
++#define MC_DC05_VALUE 0x200
++#define MC_DC06_VALUE 0x605
++#define MC_DC07_VALUE 0x303
++#define MC_DC08_VALUE 0x102
++#define MC_DC09_VALUE 0x70A
++#define MC_DC10_VALUE 0x203
++#define MC_DC11_VALUE 0xC02
++#define MC_DC12_VALUE 0x1C8
++#define MC_DC13_VALUE 0x1
++#define MC_DC14_VALUE 0x0
++#define MC_DC15_VALUE 0x134
++#define MC_DC16_VALUE 0xC800
++#define MC_DC17_VALUE 0xD
++#define MC_DC18_VALUE 0x301
++#define MC_DC19_VALUE 0x200
++#define MC_DC20_VALUE 0xA03
++#define MC_DC21_VALUE 0x1400
++#define MC_DC22_VALUE 0x1414
++#define MC_DC23_VALUE 0x0
++#define MC_DC24_VALUE 0x5B
++#define MC_DC25_VALUE 0x0
++#define MC_DC26_VALUE 0x0
++#define MC_DC27_VALUE 0x0
++#define MC_DC28_VALUE 0x510
++#define MC_DC29_VALUE 0x4E20
++#define MC_DC30_VALUE 0x8235
++#define MC_DC31_VALUE 0x0
++#define MC_DC32_VALUE 0x0
++#define MC_DC33_VALUE 0x0
++#define MC_DC34_VALUE 0x0
++#define MC_DC35_VALUE 0x0
++#define MC_DC36_VALUE 0x0
++#define MC_DC37_VALUE 0x0
++#define MC_DC38_VALUE 0x0
++#define MC_DC39_VALUE 0x0
++#define MC_DC40_VALUE 0x0
++#define MC_DC41_VALUE 0x0
++#define MC_DC42_VALUE 0x0
++#define MC_DC43_VALUE 0x0
++#define MC_DC44_VALUE 0x0
++#define MC_DC45_VALUE 0x500
++#define MC_DC46_VALUE 0x0
+--- a/boards.cfg
++++ b/boards.cfg
+@@ -438,6 +438,8 @@ vct_premium mips
+ vct_premium_onenand mips mips32 vct micronas - vct:VCT_PREMIUM,VCT_ONENAND
+ vct_premium_onenand_small mips mips32 vct micronas - vct:VCT_PREMIUM,VCT_ONENAND,VCT_SMALL_IMAGE
+ vct_premium_small mips mips32 vct micronas - vct:VCT_PREMIUM,VCT_SMALL_IMAGE
++arv7518pw_ram mips mips32 arv7518pw arcadyan danube arv7518pw:SYS_BOOT_RAM
++arv7518pw_nor mips mips32 arv7518pw arcadyan danube arv7518pw:SYS_BOOT_NOR
+ dbau1000 mips mips32 dbau1x00 - au1x00 dbau1x00:DBAU1000
+ dbau1100 mips mips32 dbau1x00 - au1x00 dbau1x00:DBAU1100
+ dbau1500 mips mips32 dbau1x00 - au1x00 dbau1x00:DBAU1500
+--- /dev/null
++++ b/include/configs/arv7518pw.h
+@@ -0,0 +1,69 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2012 Luka Perkov <luka@openwrt.org>
++ */
++
++#ifndef __CONFIG_H
++#define __CONFIG_H
++
++#define CONFIG_MACH_TYPE "ARV7518PW"
++#define CONFIG_IDENT_STRING " "CONFIG_MACH_TYPE
++#define CONFIG_BOARD_NAME "Arcadyan ARV7518PW"
++
++/* Configure SoC */
++#define CONFIG_LTQ_SUPPORT_UART /* Enable ASC and UART */
++#define CONFIG_LTQ_SUPPORT_ETHERNET /* Enable ethernet */
++#define CONFIG_LTQ_SUPPORT_NOR_FLASH /* Have a parallel NOR flash */
++
++/* Switch devices */
++#define CONFIG_SWITCH_MULTI
++#define CONFIG_SWITCH_AR8216
++
++/* Environment */
++#if defined(CONFIG_SYS_BOOT_NOR)
++#define CONFIG_ENV_IS_IN_FLASH
++#define CONFIG_ENV_OVERWRITE
++#define CONFIG_ENV_OFFSET (192 * 1024)
++#define CONFIG_ENV_SIZE (64 * 1024)
++#define CONFIG_ENV_SECT_SIZE (64 * 1024)
++#else
++#define CONFIG_ENV_IS_NOWHERE
++#define CONFIG_ENV_SIZE (2 * 1024)
++#endif
++
++#define CONFIG_LOADADDR CONFIG_SYS_LOAD_ADDR
++
++/* Console */
++#define CONFIG_LTQ_ADVANCED_CONSOLE
++#define CONFIG_BAUDRATE 115200
++#define CONFIG_CONSOLE_ASC 1
++#define CONFIG_CONSOLE_DEV "ttyLTQ1"
++
++/* Commands */
++#define CONFIG_CMD_PING
++
++/* Pull in default board configs for Lantiq XWAY Danube */
++#include <asm/lantiq/config.h>
++#include <asm/arch/config.h>
++
++/* Compression */
++#define CONFIG_LZMA
++
++/* Auto boot */
++#define CONFIG_BOOTDELAY 2
++
++/* Environment configuration */
++#define CONFIG_BOOTCOMMAND \
++ "run addeth; bootm ${kernel_addr}"
++
++#define CONFIG_ENV_UPDATE_UBOOT_NOR \
++ "update-uboot-nor=run load-uboot-nor write-uboot-nor\0"
++
++#define CONFIG_EXTRA_ENV_SETTINGS \
++ CONFIG_ENV_LANTIQ_DEFAULTS \
++ CONFIG_ENV_UPDATE_UBOOT_NOR \
++ "kernel_addr=0xB0040000\0"
++
++#endif /* __CONFIG_H */
diff --git a/package/boot/uboot-lantiq/patches/0028-MIPS-add-board-support-for-Arcadyan-ARV4519.patch b/package/boot/uboot-lantiq/patches/0028-MIPS-add-board-support-for-Arcadyan-ARV4519.patch
new file mode 100644
index 0000000..4698e67
--- /dev/null
+++ b/package/boot/uboot-lantiq/patches/0028-MIPS-add-board-support-for-Arcadyan-ARV4519.patch
@@ -0,0 +1,248 @@
+From 4a738c02a7190756e01ba58c93c4b07bc6d6c2aa Mon Sep 17 00:00:00 2001
+From: Luka Perkov <luka@openwrt.org>
+Date: Wed, 29 Aug 2012 22:08:42 +0200
+Subject: MIPS: add board support for Arcadyan ARV4519
+
+Signed-off-by: Luka Perkov <luka@openwrt.org>
+Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+
+--- /dev/null
++++ b/board/arcadyan/arv4519pw/Makefile
+@@ -0,0 +1,29 @@
++#
++# This file is released under the terms of GPL v2 and any later version.
++# See the file COPYING in the root directory of the source tree for details.
++#
++# Copyright (C) 2000-2011 Wolfgang Denk, DENX Software Engineering, wd@denx.de
++# Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++#
++
++include $(TOPDIR)/config.mk
++
++LIB = $(obj)lib$(BOARD).o
++
++COBJS = $(BOARD).o
++
++SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c)
++OBJS := $(addprefix $(obj),$(COBJS))
++SOBJS := $(addprefix $(obj),$(SOBJS))
++
++$(LIB): $(obj).depend $(OBJS) $(SOBJS)
++ $(call cmd_link_o_target, $(OBJS) $(SOBJS))
++
++#########################################################################
++
++# defines $(obj).depend target
++include $(SRCTREE)/rules.mk
++
++sinclude $(obj).depend
++
++#########################################################################
+--- /dev/null
++++ b/board/arcadyan/arv4519pw/arv4519pw.c
+@@ -0,0 +1,52 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2012 Luka Perkov <luka@openwrt.org>
++ */
++
++#include <common.h>
++#include <switch.h>
++#include <asm/gpio.h>
++#include <asm/lantiq/eth.h>
++#include <asm/lantiq/reset.h>
++#include <asm/lantiq/chipid.h>
++
++int board_early_init_f(void)
++{
++ return 0;
++}
++
++int checkboard(void)
++{
++ puts("Board: " CONFIG_BOARD_NAME "\n");
++ ltq_chip_print_info();
++
++ return 0;
++}
++
++static const struct ltq_eth_port_config eth_port_config[] = {
++ /* MAC0: Atheros ar8216 switch */
++ { 0, 0x0, LTQ_ETH_PORT_SWITCH, PHY_INTERFACE_MODE_NONE },
++};
++
++static const struct ltq_eth_board_config eth_board_config = {
++ .ports = eth_port_config,
++ .num_ports = ARRAY_SIZE(eth_port_config),
++};
++
++int board_eth_init(bd_t *bis)
++{
++ return ltq_eth_initialize(&eth_board_config);
++}
++
++static struct switch_device ar8216_dev = {
++ .name = "ar8216",
++ .cpu_port = 0,
++ .port_mask = 0xF,
++};
++
++int board_switch_init(void)
++{
++ return switch_device_register(&ar8216_dev);
++}
+--- /dev/null
++++ b/board/arcadyan/arv4519pw/config.mk
+@@ -0,0 +1,8 @@
++#
++# This file is released under the terms of GPL v2 and any later version.
++# See the file COPYING in the root directory of the source tree for details.
++#
++# Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
++#
++
++PLATFORM_CPPFLAGS += -I$(TOPDIR)/board/$(BOARDDIR)
+--- /dev/null
++++ b/board/arcadyan/arv4519pw/ddr_settings.h
+@@ -0,0 +1,56 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * generated with lantiq_ram_extract_magic.awk
++ *
++ * Copyright (C) 2011 Luka Perkov <luka@openwrt.org>
++ */
++
++#define MC_DC00_VALUE 0x1B1B
++#define MC_DC01_VALUE 0x0
++#define MC_DC02_VALUE 0x0
++#define MC_DC03_VALUE 0x0
++#define MC_DC04_VALUE 0x0
++#define MC_DC05_VALUE 0x200
++#define MC_DC06_VALUE 0x605
++#define MC_DC07_VALUE 0x303
++#define MC_DC08_VALUE 0x102
++#define MC_DC09_VALUE 0x70A
++#define MC_DC10_VALUE 0x203
++#define MC_DC11_VALUE 0xC02
++#define MC_DC12_VALUE 0x1C8
++#define MC_DC13_VALUE 0x1
++#define MC_DC14_VALUE 0x0
++#define MC_DC15_VALUE 0x131
++#define MC_DC16_VALUE 0xC800
++#define MC_DC17_VALUE 0xD
++#define MC_DC18_VALUE 0x301
++#define MC_DC19_VALUE 0x200
++#define MC_DC20_VALUE 0xA04
++#define MC_DC21_VALUE 0x1700
++#define MC_DC22_VALUE 0x1717
++#define MC_DC23_VALUE 0x0
++#define MC_DC24_VALUE 0x5A
++#define MC_DC25_VALUE 0x0
++#define MC_DC26_VALUE 0x0
++#define MC_DC27_VALUE 0x0
++#define MC_DC28_VALUE 0x510
++#define MC_DC29_VALUE 0x4E20
++#define MC_DC30_VALUE 0x8235
++#define MC_DC31_VALUE 0x0
++#define MC_DC32_VALUE 0x0
++#define MC_DC33_VALUE 0x0
++#define MC_DC34_VALUE 0x0
++#define MC_DC35_VALUE 0x0
++#define MC_DC36_VALUE 0x0
++#define MC_DC37_VALUE 0x0
++#define MC_DC38_VALUE 0x0
++#define MC_DC39_VALUE 0x0
++#define MC_DC40_VALUE 0x0
++#define MC_DC41_VALUE 0x0
++#define MC_DC42_VALUE 0x0
++#define MC_DC43_VALUE 0x0
++#define MC_DC44_VALUE 0x0
++#define MC_DC45_VALUE 0x500
++#define MC_DC46_VALUE 0x0
+--- a/boards.cfg
++++ b/boards.cfg
+@@ -438,6 +438,8 @@ vct_premium mips
+ vct_premium_onenand mips mips32 vct micronas - vct:VCT_PREMIUM,VCT_ONENAND
+ vct_premium_onenand_small mips mips32 vct micronas - vct:VCT_PREMIUM,VCT_ONENAND,VCT_SMALL_IMAGE
+ vct_premium_small mips mips32 vct micronas - vct:VCT_PREMIUM,VCT_SMALL_IMAGE
++arv4519pw_ram mips mips32 arv4519pw arcadyan danube arv4519pw:SYS_BOOT_RAM
++arv4519pw_nor mips mips32 arv4519pw arcadyan danube arv4519pw:SYS_BOOT_NOR
+ arv7518pw_ram mips mips32 arv7518pw arcadyan danube arv7518pw:SYS_BOOT_RAM
+ arv7518pw_nor mips mips32 arv7518pw arcadyan danube arv7518pw:SYS_BOOT_NOR
+ dbau1000 mips mips32 dbau1x00 - au1x00 dbau1x00:DBAU1000
+--- /dev/null
++++ b/include/configs/arv4519pw.h
+@@ -0,0 +1,69 @@
++/*
++ * This file is released under the terms of GPL v2 and any later version.
++ * See the file COPYING in the root directory of the source tree for details.
++ *
++ * Copyright (C) 2012 Luka Perkov <luka@openwrt.org>
++ */
++
++#ifndef __CONFIG_H
++#define __CONFIG_H
++
++#define CONFIG_MACH_TYPE "ARV4519PW"
++#define CONFIG_IDENT_STRING " "CONFIG_MACH_TYPE
++#define CONFIG_BOARD_NAME "Arcadyan ARV4519PW"
++
++/* Configure SoC */
++#define CONFIG_LTQ_SUPPORT_UART /* Enable ASC and UART */
++#define CONFIG_LTQ_SUPPORT_ETHERNET /* Enable ethernet */
++#define CONFIG_LTQ_SUPPORT_NOR_FLASH /* Have a parallel NOR flash */
++
++/* Switch devices */
++#define CONFIG_SWITCH_MULTI
++#define CONFIG_SWITCH_AR8216
++
++/* Environment */
++#if defined(CONFIG_SYS_BOOT_NOR)
++#define CONFIG_ENV_IS_IN_FLASH
++#define CONFIG_ENV_OVERWRITE
++#define CONFIG_ENV_OFFSET (192 * 1024)
++#define CONFIG_ENV_SIZE (64 * 1024)
++#define CONFIG_ENV_SECT_SIZE (64 * 1024)
++#else
++#define CONFIG_ENV_IS_NOWHERE
++#define CONFIG_ENV_SIZE (2 * 1024)
++#endif
++
++#define CONFIG_LOADADDR CONFIG_SYS_LOAD_ADDR
++
++/* Console */
++#define CONFIG_LTQ_ADVANCED_CONSOLE
++#define CONFIG_BAUDRATE 115200
++#define CONFIG_CONSOLE_ASC 1
++#define CONFIG_CONSOLE_DEV "ttyLTQ1"
++
++/* Commands */
++#define CONFIG_CMD_PING
++
++/* Pull in default board configs for Lantiq XWAY Danube */
++#include <asm/lantiq/config.h>
++#include <asm/arch/config.h>
++
++/* Compression */
++#define CONFIG_LZMA
++
++/* Auto boot */
++#define CONFIG_BOOTDELAY 2
++
++/* Environment configuration */
++#define CONFIG_BOOTCOMMAND \
++ "run addeth; bootm ${kernel_addr}"
++
++#define CONFIG_ENV_UPDATE_UBOOT_NOR \
++ "update-uboot-nor=run load-uboot-nor write-uboot-nor\0"
++
++#define CONFIG_EXTRA_ENV_SETTINGS \
++ CONFIG_ENV_LANTIQ_DEFAULTS \
++ CONFIG_ENV_UPDATE_UBOOT_NOR \
++ "kernel_addr=0xB0040000\0"
++
++#endif /* __CONFIG_H */
diff --git a/package/boot/uboot-lantiq/patches/0029-tools-add-some-helper-tools-for-Lantiq-SoCs.patch b/package/boot/uboot-lantiq/patches/0029-tools-add-some-helper-tools-for-Lantiq-SoCs.patch
new file mode 100644
index 0000000..77d48d1
--- /dev/null
+++ b/package/boot/uboot-lantiq/patches/0029-tools-add-some-helper-tools-for-Lantiq-SoCs.patch
@@ -0,0 +1,361 @@
+From 1b77d4249b5addbf3b0848db6992a445019a1865 Mon Sep 17 00:00:00 2001
+From: Luka Perkov <luka@openwrt.org>
+Date: Wed, 29 Aug 2012 22:08:42 +0200
+Subject: tools: add some helper tools for Lantiq SoCs
+
+Signed-off-by: Luka Perkov Luka Perkov <luka@openwrt.org>
+Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
+
+--- /dev/null
++++ b/tools/gct.pl
+@@ -0,0 +1,155 @@
++#!/usr/bin/perl
++
++#use strict;
++#use Cwd;
++#use Env;
++
++my $aline;
++my $lineid;
++my $length;
++my $address;
++my @bytes;
++my $addstr;
++my $chsum=0;
++my $count=0;
++my $firstime=1;
++my $i;
++my $currentaddr;
++my $tmp;
++my $holder="";
++my $loadaddr;
++
++if(@ARGV < 2){
++ die("\n Syntax: perl gct.pl uart_ddr_settings.conf u-boot.srec u-boot.asc\n");
++}
++
++open(IN_UART_DDR_SETTINGS, "<$ARGV[0]") || die("failed to open uart_ddr_settings.conf\n");
++open(IN_UART_SREC, "<$ARGV[1]") || die("failed to open u-boot.srec\n");
++open(OUT_UBOOT_ASC, ">$ARGV[2]") || die("failed to open u-boot.asc\n");
++
++$i=0;
++while ($line = <IN_UART_DDR_SETTINGS>){
++ if($line=~/\w/){
++ if($line!~/[;#\*]/){
++ if($i eq 0){
++ printf OUT_UBOOT_ASC ("33333333");
++ }
++ chomp($line);
++ $line=~s/\t//;
++ @array=split(/ +/,$line);
++ $j=0;
++ while(@array[$j]!~/\w/){
++ $j=$j+1;
++ }
++ $addr=@array[$j];
++ $regval=@array[$j+1];
++ $addr=~s/0x//;
++ $regval=~s/0x//;
++ printf OUT_UBOOT_ASC ("%08x%08x",hex($addr),hex($regval));
++ $i=$i+1;
++ if($i eq 8){
++ $i=0;
++ printf OUT_UBOOT_ASC ("\n");
++ }
++ }
++ }
++}
++
++while($i lt 8 && $i gt 0){
++ printf OUT_UBOOT_ASC "00"x8;
++ $i=$i+1;
++}
++
++if($i eq 8){
++ printf OUT_UBOOT_ASC ("\n");
++}
++
++while($aline=<IN_UART_SREC>){
++ $aline=uc($aline);
++ chomp($aline);
++ next if(($aline=~/^S0/) || ($aline=~/^S7/));
++ ($lineid, $length, $address, @bytes) = unpack"A2A2A8"."A2"x300, $aline;
++ $length = hex($length);
++ $address = hex($address);
++ $length -=5;
++ $i=0;
++
++ while($length>0){
++ if($firstime==1){
++ $addstr = sprintf("%x", $address);
++ $addstr = "0"x(8-length($addstr)).$addstr;
++ print OUT_UBOOT_ASC $addstr;
++ addchsum($addstr);
++ $firstime=0;
++ $currentaddr=$address;
++ $loadaddr = $addstr;
++ }
++ else{
++ if($count==64){
++ $addstr = sprintf("%x", $currentaddr);
++ $addstr = "0"x(8-length($addstr)).$addstr;
++ print OUT_UBOOT_ASC $addstr;
++ addchsum($addstr);
++ $count=0;
++ }
++#printf("*** %x != %x\n", $address, $currentaddr) if $address != $currentaddr;
++ }
++ if($currentaddr < $address) {
++ print OUT_UBOOT_ASC "00";
++ addchsum("00");
++ $count++;
++ $currentaddr++;
++ }
++ else {
++ while($count<64){
++ $bytes[$i]=~tr/ABCDEF/abcdef/;
++ print OUT_UBOOT_ASC "$bytes[$i]";
++ addchsum($bytes[$i]);
++ $i++;
++ $count++;
++ $currentaddr++;
++ $length--;
++ last if($length==0);
++ }
++ }
++ if($count==64){
++ print OUT_UBOOT_ASC "\n";
++ }
++ }
++}
++if($count != 64){
++ $tmp = "00";
++ for($i=0;$i<(64-$count);$i++){
++ print OUT_UBOOT_ASC "00";
++ addchsum($tmp);
++ }
++ print OUT_UBOOT_ASC "\n";
++}
++
++
++print OUT_UBOOT_ASC "11"x4;
++use integer;
++$chsum=$chsum & 0xffffffff;
++$chsum = sprintf("%X", $chsum);
++$chsum = "0"x(8-length($chsum)).$chsum;
++$chsum =~tr/ABCDEF/abcdef/;
++print OUT_UBOOT_ASC $chsum;
++print OUT_UBOOT_ASC "00"x60;
++print OUT_UBOOT_ASC "\n";
++
++print OUT_UBOOT_ASC "99"x4;
++print OUT_UBOOT_ASC $loadaddr;
++print OUT_UBOOT_ASC "00"x60;
++print OUT_UBOOT_ASC "\n";
++
++close OUT_UBOOT_ASC;
++
++sub addchsum{
++ my $cc=$_[0];
++ $holder=$holder.$cc;
++ if(length($holder)==8){
++ $holder = hex($holder);
++ $chsum+=$holder;
++ $holder="";
++ }
++}
+--- /dev/null
++++ b/tools/lantiq_extract_openwrt_patches.sh
+@@ -0,0 +1,15 @@
++#!/bin/bash
++
++set -e
++set -x
++
++test $# -eq 1
++
++openwrt_root=$(readlink -f $1)
++test -d $openwrt_root
++
++uboot_lantiq_dir=$openwrt_root/package/boot/uboot-lantiq/patches
++test -d $uboot_lantiq_dir
++
++rm -vf $uboot_lantiq_dir/*
++git format-patch -k -p --no-renames --text --full-index -o $uboot_lantiq_dir v2012.10..openwrt/v2013.01
+--- /dev/null
++++ b/tools/lantiq_ram_extract_magic.awk
+@@ -0,0 +1,70 @@
++#
++# This file is released under the terms of GPL v2 and any later version.
++# See the file COPYING in the root directory of the source tree for details.
++#
++# Copyright (C) 2011 Luka Perkov <luka@openwrt.org>
++#
++# usage: mips-openwrt-linux-objdump -EB -b binary -m mips:isa32r2 -D YOUR_IMAGE_DUMP | awk -f lantiq_ram_extract_magic.awk
++#
++
++BEGIN {
++ print "/* "
++ print " * This file is released under the terms of GPL v2 and any later version. "
++ print " * See the file COPYING in the root directory of the source tree for details. "
++ print " * "
++ print " * generated with lantiq_ram_extract_magic.awk "
++ print " * "
++ print " * Copyright (C) 2011 Luka Perkov <luka@openwrt.org> "
++ print " */ "
++ print ""
++
++ mc_dc_value=0
++ mc_dc_number=0
++ right_section=0
++ mc_dc_value_print=0
++ mc_dc_number_print=0
++}
++
++/t2,[0-9]+$/ {
++ if (right_section) {
++ split($4, tmp, ",")
++ mc_dc_value=sprintf("%X", tmp[2])
++ mc_dc_value_print=1
++ }
++}
++
++/t2,0x[0-9a-f]+$/ {
++ if (right_section) {
++ split($4, tmp, ",0x")
++ mc_dc_value=sprintf("%s", tmp[2])
++ mc_dc_value=toupper(mc_dc_value)
++ mc_dc_value_print=1
++ }
++}
++
++/t2,[0-9]+\(t1\)$/ {
++ if (right_section) {
++ split($4, tmp, ",")
++ split(tmp[2], tmp, "(")
++ mc_dc_number=tmp[1]/16
++ mc_dc_number_print=1
++ }
++}
++
++{
++ if (right_section && mc_dc_number_print && mc_dc_value_print) {
++ if (mc_dc_number < 10)
++ print "#define MC_DC0" mc_dc_number "_VALUE\t0x" mc_dc_value
++ else
++ print "#define MC_DC" mc_dc_number "_VALUE\t0x" mc_dc_value
++ mc_dc_value_print=0
++ mc_dc_number_print=0
++ }
++
++ if ($4 == "t1,t1,0x1000")
++ right_section=1
++
++
++ if ($4 == "t2,736(t1)")
++ right_section=0
++}
+--- /dev/null
++++ b/tools/lantiq_ram_init_uart.awk
+@@ -0,0 +1,101 @@
++#!/usr/bin/awk -f
++#
++# This file is released under the terms of GPL v2 and any later version.
++# See the file COPYING in the root directory of the source tree for details.
++#
++# Copyright (C) 2011-2012 Luka Perkov <luka@openwrt.org>
++# Copyright (C) 2012 Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
++#
++# usage: awk -f lantiq_ram_init_uart.awk -v soc=<danube|ar9|vr9> PATH_TO_BOARD/ddr_settings.h
++#
++
++function print_header()
++{
++ print "; "
++ print "; This file is released under the terms of GPL v2 and any later version. "
++ print "; See the file COPYING in the root directory of the source tree for details. "
++ print "; "
++ print "; generated with lantiq_ram_init_uart.awk "
++ print "; "
++ print "; Copyright (C) 2011-2012 Luka Perkov <luka@openwrt.org> "
++ print "; Copyright (C) 2012 Daniel Schwierzeck <daniel.schwierzeck@gmail.com> "
++ print "; "
++ print ""
++}
++
++function mc_ddr1_prologue()
++{
++ /* Clear access error log registers */
++ print "0xbf800010", "0x0"
++ print "0xbf800020", "0x0"
++
++ /* Enable DDR and SRAM module in memory controller */
++ print "0xbf800060", "0x5"
++
++ /* Clear start bit of DDR memory controller */
++ print "0xbf801030", "0x0"
++}
++
++function mc_ddr1_epilogue()
++{
++ /* Set start bit of DDR memory controller */
++ print "0xbf801030", "0x100"
++}
++
++function mc_ddr2_prologue()
++{
++ /* Put memory controller in inactive mode */
++ print "0xbf401070", "0x0"
++}
++
++function mc_ddr2_epilogue(mc_ccr07_value)
++{
++ /* Put memory controller in active mode */
++ mc_ccr07_value = or(mc_ccr07_value, 0x100)
++ printf("0xbf401070 0x%x\n", mc_ccr07_value)
++}
++
++BEGIN {
++ switch (soc) {
++ case "danube":
++ case "ar9":
++ reg_base = 0xbf801000
++ print_header()
++ mc_ddr1_prologue()
++ break
++ case "vr9":
++ reg_base = 0xbf401000
++ print_header()
++ mc_ddr2_prologue()
++ break
++ default:
++ print "Invalid or no value for soc specified!"
++ exit 1
++ }
++
++ mc_ccr07_value = 0
++}
++
++/^#define/ {
++ printf("0x%x %s\n", reg_base, tolower($3))
++ reg_base += 0x10
++}
++
++/^#define(.*)MC_CCR07_VALUE/ {
++ printf("0x%x %s\n", reg_base, tolower($3))
++ reg_base += 0x10
++ mc_ccr07_value = strtonum($3)
++}
++
++END {
++ switch (soc) {
++ case "danube":
++ case "ar9":
++ mc_ddr1_epilogue()
++ break
++ case "vr9":
++ mc_ddr2_epilogue(mc_ccr07_value)
++ break
++ default:
++ }
++}
diff --git a/package/boot/uboot-omap35xx/.svn/entries b/package/boot/uboot-omap35xx/.svn/entries
new file mode 100644
index 0000000..9de4baa
--- /dev/null
+++ b/package/boot/uboot-omap35xx/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/uboot-omap35xx
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+files
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+9740ce10bcacfd7eca1e227f2f9acde9
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1940
+
diff --git a/package/boot/uboot-omap35xx/.svn/text-base/Makefile.svn-base b/package/boot/uboot-omap35xx/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..928acc7
--- /dev/null
+++ b/package/boot/uboot-omap35xx/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,89 @@
+#
+# Copyright (C) 2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=u-boot
+PKG_VERSION:=2010.12
+PKG_RELEASE:=1
+
+PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=ftp://ftp.denx.de/pub/u-boot
+PKG_MD5SUM:=
+PKG_TARGETS:=bin
+
+include $(INCLUDE_DIR)/package.mk
+
+define uboot/Default
+ TITLE:=
+ CONFIG:=
+ IMAGE:=
+endef
+
+define uboot/omap3_overo
+ TITLE:=U-boot for the gumstix board
+endef
+
+UBOOTS:=omap3_overo
+
+define Package/uboot/template
+define Package/uboot-omap35xx-$(1)
+ SECTION:=boot
+ CATEGORY:=Boot Loaders
+ DEPENDS:=@TARGET_omap35xx
+ TITLE:=$(2)
+ URL:=http://www.denx.de/wiki/U-Boot
+ VARIANT:=$(1)
+endef
+endef
+
+define BuildUbootPackage
+ $(eval $(uboot/Default))
+ $(eval $(uboot/$(1)))
+ $(call Package/uboot/template,$(1),$(TITLE))
+endef
+
+
+ifdef BUILD_VARIANT
+$(eval $(call uboot/$(BUILD_VARIANT)))
+UBOOT_CONFIG:=$(if $(CONFIG),$(CONFIG),$(BUILD_VARIANT))
+UBOOT_IMAGE:=$(if $(IMAGE),$(IMAGE),openwrt-$(BOARD)-$(BUILD_VARIANT)-u-boot.bin)
+endif
+
+define Build/Prepare
+ $(call Build/Prepare/Default)
+ $(CP) ./files/* $(PKG_BUILD_DIR)
+ find $(PKG_BUILD_DIR) -name .svn | $(XARGS) rm -rf
+endef
+
+define Build/Configure
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ $(UBOOT_CONFIG)_config
+endef
+
+define Build/Compile
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ CROSS_COMPILE=$(TARGET_CROSS)
+endef
+
+define Package/uboot/install/template
+define Package/uboot-omap35xx-$(1)/install
+ $(INSTALL_DIR) $$(1)
+ $(CP) $(PKG_BUILD_DIR)/u-boot.bin $(BIN_DIR)/$(2)
+endef
+endef
+
+$(foreach u,$(UBOOTS), \
+ $(eval $(call Package/uboot/install/template,$(u),openwrt-$(BOARD)-$(u)-u-boot.bin)) \
+)
+
+$(foreach u,$(UBOOTS), \
+ $(eval $(call BuildUbootPackage,$(u))) \
+ $(eval $(call BuildPackage,uboot-omap35xx-$(u))) \
+)
diff --git a/package/boot/uboot-omap35xx/Makefile b/package/boot/uboot-omap35xx/Makefile
new file mode 100644
index 0000000..928acc7
--- /dev/null
+++ b/package/boot/uboot-omap35xx/Makefile
@@ -0,0 +1,89 @@
+#
+# Copyright (C) 2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=u-boot
+PKG_VERSION:=2010.12
+PKG_RELEASE:=1
+
+PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=ftp://ftp.denx.de/pub/u-boot
+PKG_MD5SUM:=
+PKG_TARGETS:=bin
+
+include $(INCLUDE_DIR)/package.mk
+
+define uboot/Default
+ TITLE:=
+ CONFIG:=
+ IMAGE:=
+endef
+
+define uboot/omap3_overo
+ TITLE:=U-boot for the gumstix board
+endef
+
+UBOOTS:=omap3_overo
+
+define Package/uboot/template
+define Package/uboot-omap35xx-$(1)
+ SECTION:=boot
+ CATEGORY:=Boot Loaders
+ DEPENDS:=@TARGET_omap35xx
+ TITLE:=$(2)
+ URL:=http://www.denx.de/wiki/U-Boot
+ VARIANT:=$(1)
+endef
+endef
+
+define BuildUbootPackage
+ $(eval $(uboot/Default))
+ $(eval $(uboot/$(1)))
+ $(call Package/uboot/template,$(1),$(TITLE))
+endef
+
+
+ifdef BUILD_VARIANT
+$(eval $(call uboot/$(BUILD_VARIANT)))
+UBOOT_CONFIG:=$(if $(CONFIG),$(CONFIG),$(BUILD_VARIANT))
+UBOOT_IMAGE:=$(if $(IMAGE),$(IMAGE),openwrt-$(BOARD)-$(BUILD_VARIANT)-u-boot.bin)
+endif
+
+define Build/Prepare
+ $(call Build/Prepare/Default)
+ $(CP) ./files/* $(PKG_BUILD_DIR)
+ find $(PKG_BUILD_DIR) -name .svn | $(XARGS) rm -rf
+endef
+
+define Build/Configure
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ $(UBOOT_CONFIG)_config
+endef
+
+define Build/Compile
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ CROSS_COMPILE=$(TARGET_CROSS)
+endef
+
+define Package/uboot/install/template
+define Package/uboot-omap35xx-$(1)/install
+ $(INSTALL_DIR) $$(1)
+ $(CP) $(PKG_BUILD_DIR)/u-boot.bin $(BIN_DIR)/$(2)
+endef
+endef
+
+$(foreach u,$(UBOOTS), \
+ $(eval $(call Package/uboot/install/template,$(u),openwrt-$(BOARD)-$(u)-u-boot.bin)) \
+)
+
+$(foreach u,$(UBOOTS), \
+ $(eval $(call BuildUbootPackage,$(u))) \
+ $(eval $(call BuildPackage,uboot-omap35xx-$(u))) \
+)
diff --git a/package/boot/uboot-omap35xx/files/.svn/entries b/package/boot/uboot-omap35xx/files/.svn/entries
new file mode 100644
index 0000000..62713ad
--- /dev/null
+++ b/package/boot/uboot-omap35xx/files/.svn/entries
@@ -0,0 +1,31 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/uboot-omap35xx/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+include
+dir
+
diff --git a/package/boot/uboot-omap35xx/files/include/.svn/entries b/package/boot/uboot-omap35xx/files/include/.svn/entries
new file mode 100644
index 0000000..7b6d6a1
--- /dev/null
+++ b/package/boot/uboot-omap35xx/files/include/.svn/entries
@@ -0,0 +1,31 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/uboot-omap35xx/files/include
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+configs
+dir
+
diff --git a/package/boot/uboot-omap35xx/files/include/configs/.svn/entries b/package/boot/uboot-omap35xx/files/include/configs/.svn/entries
new file mode 100644
index 0000000..8d43469
--- /dev/null
+++ b/package/boot/uboot-omap35xx/files/include/configs/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/uboot-omap35xx/files/include/configs
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+omap3_overo.h
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+3b947b5d726443e694c1a0a5c77058c6
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+9612
+
diff --git a/package/boot/uboot-omap35xx/files/include/configs/.svn/text-base/omap3_overo.h.svn-base b/package/boot/uboot-omap35xx/files/include/configs/.svn/text-base/omap3_overo.h.svn-base
new file mode 100644
index 0000000..e1c930d
--- /dev/null
+++ b/package/boot/uboot-omap35xx/files/include/configs/.svn/text-base/omap3_overo.h.svn-base
@@ -0,0 +1,316 @@
+/*
+ * Configuration settings for the Gumstix Overo board.
+ *
+ * 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 of
+ * the License, 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef __CONFIG_H
+#define __CONFIG_H
+
+/*
+ * High Level Configuration Options
+ */
+#define CONFIG_ARMV7 1 /* This is an ARM V7 CPU core */
+#define CONFIG_OMAP 1 /* in a TI OMAP core */
+#define CONFIG_OMAP34XX 1 /* which is a 34XX */
+#define CONFIG_OMAP3430 1 /* which is in a 3430 */
+#define CONFIG_OMAP3_OVERO 1 /* working with overo */
+
+#define CONFIG_SDRC /* The chip has SDRC controller */
+
+#include <asm/arch/cpu.h> /* get chip and board defs */
+#include <asm/arch/omap3.h>
+
+/*
+ * Display CPU and Board information
+ */
+#define CONFIG_DISPLAY_CPUINFO 1
+#define CONFIG_DISPLAY_BOARDINFO 1
+
+/* Clock Defines */
+#define V_OSCK 26000000 /* Clock output from T2 */
+#define V_SCLK (V_OSCK >> 1)
+
+#undef CONFIG_USE_IRQ /* no support for IRQs */
+#define CONFIG_MISC_INIT_R
+
+#define CONFIG_CMDLINE_TAG 1 /* enable passing of ATAGs */
+#define CONFIG_SETUP_MEMORY_TAGS 1
+#define CONFIG_INITRD_TAG 1
+#define CONFIG_REVISION_TAG 1
+
+/*
+ * Size of malloc() pool
+ */
+#define CONFIG_ENV_SIZE (128 << 10) /* 128 KiB */
+ /* Sector */
+#define CONFIG_SYS_MALLOC_LEN (CONFIG_ENV_SIZE + (128 << 10))
+ /* initial data */
+
+/*
+ * Hardware drivers
+ */
+
+/*
+ * NS16550 Configuration
+ */
+#define V_NS16550_CLK 48000000 /* 48MHz (APLL96/2) */
+
+#define CONFIG_SYS_NS16550
+#define CONFIG_SYS_NS16550_SERIAL
+#define CONFIG_SYS_NS16550_REG_SIZE (-4)
+#define CONFIG_SYS_NS16550_CLK V_NS16550_CLK
+
+/*
+ * select serial console configuration
+ */
+#define CONFIG_CONS_INDEX 3
+#define CONFIG_SYS_NS16550_COM3 OMAP34XX_UART3
+#define CONFIG_SERIAL3 3
+
+/* allow to overwrite serial and ethaddr */
+#define CONFIG_ENV_OVERWRITE
+#define CONFIG_BAUDRATE 115200
+#define CONFIG_SYS_BAUDRATE_TABLE {4800, 9600, 19200, 38400, 57600, \
+ 115200}
+#define CONFIG_GENERIC_MMC 1
+#define CONFIG_MMC 1
+#define CONFIG_OMAP_HSMMC 1
+#define CONFIG_DOS_PARTITION 1
+
+/* DDR - I use Micron DDR */
+#define CONFIG_OMAP3_MICRON_DDR 1
+
+/* commands to include */
+#include <config_cmd_default.h>
+
+#define CONFIG_CMD_CACHE
+#define CONFIG_CMD_EXT2 /* EXT2 Support */
+#define CONFIG_CMD_FAT /* FAT support */
+#define CONFIG_CMD_JFFS2 /* JFFS2 Support */
+
+#define CONFIG_CMD_I2C /* I2C serial bus support */
+#define CONFIG_CMD_MMC /* MMC support */
+#define CONFIG_CMD_NAND /* NAND support */
+
+#undef CONFIG_CMD_FLASH /* flinfo, erase, protect */
+#undef CONFIG_CMD_FPGA /* FPGA configuration Support */
+#undef CONFIG_CMD_IMI /* iminfo */
+#undef CONFIG_CMD_IMLS /* List all found images */
+#undef CONFIG_CMD_NFS /* NFS support */
+#define CONFIG_CMD_NET /* bootp, tftpboot, rarpboot */
+
+#define CONFIG_SYS_NO_FLASH
+#define CONFIG_HARD_I2C 1
+#define CONFIG_SYS_I2C_SPEED 100000
+#define CONFIG_SYS_I2C_SLAVE 1
+#define CONFIG_SYS_I2C_BUS 0
+#define CONFIG_SYS_I2C_BUS_SELECT 1
+#define CONFIG_I2C_MULTI_BUS 1
+#define CONFIG_DRIVER_OMAP34XX_I2C 1
+
+/*
+ * TWL4030
+ */
+#define CONFIG_TWL4030_POWER 1
+#define CONFIG_TWL4030_LED 1
+
+/*
+ * Board NAND Info.
+ */
+#define CONFIG_SYS_NAND_QUIET_TEST 1
+#define CONFIG_NAND_OMAP_GPMC
+#define CONFIG_SYS_NAND_ADDR NAND_BASE /* physical address */
+ /* to access nand */
+#define CONFIG_SYS_NAND_BASE NAND_BASE /* physical address */
+ /* to access nand */
+ /* at CS0 */
+#define GPMC_NAND_ECC_LP_x16_LAYOUT 1
+
+#define CONFIG_SYS_MAX_NAND_DEVICE 1 /* Max number of NAND */
+ /* devices */
+#define CONFIG_JFFS2_NAND
+/* nand device jffs2 lives on */
+#define CONFIG_JFFS2_DEV "nand0"
+/* start of jffs2 partition */
+#define CONFIG_JFFS2_PART_OFFSET 0x680000
+#define CONFIG_JFFS2_PART_SIZE 0xf980000 /* size of jffs2 */
+ /* partition */
+
+/* Environment information */
+#define CONFIG_BOOTDELAY 5
+
+#define CONFIG_EXTRA_ENV_SETTINGS \
+ "loadaddr=0x82000000\0" \
+ "console=ttyO2,115200n8\0" \
+ "mpurate=500\0" \
+ "vram=12M\0" \
+ "dvimode=1024x768MR-16@60\0" \
+ "defaultdisplay=dvi\0" \
+ "mmcdev=0\0" \
+ "mmcroot=/dev/mmcblk0p2 rw\0" \
+ "mmcrootfstype=ext3 rootwait\0" \
+ "nandroot='ubi0:rootfs ubi.mtd=5 ubi.mtd=6 ubi.mtd=7'\0" \
+ "nandrootfstype=ubifs\0" \
+ "mmcargs=setenv bootargs console=${console} " \
+ "mpurate=${mpurate} " \
+ "vram=${vram} " \
+ "omapfb.mode=dvi:${dvimode} " \
+ "omapfb.debug=y " \
+ "omapdss.def_disp=${defaultdisplay} " \
+ "root=${mmcroot} " \
+ "rootfstype=${mmcrootfstype}\0" \
+ "nandargs=setenv bootargs console=${console} " \
+ "mpurate=${mpurate} " \
+ "vram=${vram} " \
+ "omapfb.mode=dvi:${dvimode} " \
+ "omapfb.debug=y " \
+ "omapdss.def_disp=${defaultdisplay} " \
+ "root=${nandroot} " \
+ "rootfstype=${nandrootfstype}\0" \
+ "loadbootscript=fatload mmc ${mmcdev} ${loadaddr} boot.scr\0" \
+ "bootscript=echo Running bootscript from mmc ...; " \
+ "source ${loadaddr}\0" \
+ "loaduimage=fatload mmc ${mmcdev} ${loadaddr} uImage\0" \
+ "mmcboot=echo Booting from mmc ...; " \
+ "run mmcargs; " \
+ "bootm ${loadaddr}\0" \
+ "nandboot=echo Booting from nand ...; " \
+ "run nandargs; " \
+ "nand read ${loadaddr} 280000 200000; " \
+ "bootm ${loadaddr}\0" \
+
+#define CONFIG_BOOTCOMMAND \
+ "if mmc rescan ${mmcdev}; then " \
+ "if run loadbootscript; then " \
+ "run bootscript; " \
+ "else " \
+ "if run loaduimage; then " \
+ "run mmcboot; " \
+ "else run nandboot; " \
+ "fi; " \
+ "fi; " \
+ "else run nandboot; fi"
+
+#define CONFIG_AUTO_COMPLETE 1
+/*
+ * Miscellaneous configurable options
+ */
+#define CONFIG_SYS_LONGHELP /* undef to save memory */
+#define CONFIG_SYS_HUSH_PARSER /* use "hush" command parser */
+#define CONFIG_SYS_PROMPT_HUSH_PS2 "> "
+#define CONFIG_SYS_PROMPT "Overo # "
+#define CONFIG_SYS_CBSIZE 256 /* Console I/O Buffer Size */
+/* Print Buffer Size */
+#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE + \
+ sizeof(CONFIG_SYS_PROMPT) + 16)
+#define CONFIG_SYS_MAXARGS 16 /* max number of command */
+ /* args */
+/* Boot Argument Buffer Size */
+#define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE
+/* memtest works on */
+#define CONFIG_SYS_MEMTEST_START (OMAP34XX_SDRC_CS0)
+#define CONFIG_SYS_MEMTEST_END (OMAP34XX_SDRC_CS0 + \
+ 0x01F00000) /* 31MB */
+
+#define CONFIG_SYS_LOAD_ADDR (OMAP34XX_SDRC_CS0) /* default load */
+ /* address */
+/*
+ * OMAP3 has 12 GP timers, they can be driven by the system clock
+ * (12/13/16.8/19.2/38.4MHz) or by 32KHz clock. We use 13MHz (V_SCLK).
+ * This rate is divided by a local divisor.
+ */
+#define CONFIG_SYS_TIMERBASE OMAP34XX_GPT2
+#define CONFIG_SYS_PTV 2 /* Divisor: 2^(PTV+1) => 8 */
+#define CONFIG_SYS_HZ 1000
+
+/*-----------------------------------------------------------------------
+ * Stack sizes
+ *
+ * The stack sizes are set up in start.S using the settings below
+ */
+#define CONFIG_STACKSIZE (128 << 10) /* regular stack 128 KiB */
+#ifdef CONFIG_USE_IRQ
+#define CONFIG_STACKSIZE_IRQ (4 << 10) /* IRQ stack 4 KiB */
+#define CONFIG_STACKSIZE_FIQ (4 << 10) /* FIQ stack 4 KiB */
+#endif
+
+/*-----------------------------------------------------------------------
+ * Physical Memory Map
+ */
+#define CONFIG_NR_DRAM_BANKS 2 /* CS1 may or may not be populated */
+#define PHYS_SDRAM_1 OMAP34XX_SDRC_CS0
+#define PHYS_SDRAM_1_SIZE (32 << 20) /* at least 32 MiB */
+#define PHYS_SDRAM_2 OMAP34XX_SDRC_CS1
+
+/* SDRAM Bank Allocation method */
+#define SDRC_R_B_C 1
+
+/*-----------------------------------------------------------------------
+ * FLASH and environment organization
+ */
+
+/* **** PISMO SUPPORT *** */
+
+/* Configure the PISMO */
+#define PISMO1_NAND_SIZE GPMC_SIZE_128M
+#define PISMO1_ONEN_SIZE GPMC_SIZE_128M
+
+#define CONFIG_SYS_MONITOR_LEN (256 << 10) /* Reserve 2 sectors */
+
+#define CONFIG_SYS_FLASH_BASE boot_flash_base
+
+/* Monitor at start of flash */
+#define CONFIG_SYS_MONITOR_BASE CONFIG_SYS_FLASH_BASE
+#define CONFIG_SYS_ONENAND_BASE ONENAND_MAP
+
+#define CONFIG_ENV_IS_IN_NAND 1
+#define ONENAND_ENV_OFFSET 0x240000 /* environment starts here */
+#define SMNAND_ENV_OFFSET 0x240000 /* environment starts here */
+
+#define CONFIG_SYS_ENV_SECT_SIZE boot_flash_sec
+#define CONFIG_ENV_OFFSET boot_flash_off
+#define CONFIG_ENV_ADDR SMNAND_ENV_OFFSET
+
+#ifndef __ASSEMBLY__
+extern unsigned int boot_flash_base;
+extern volatile unsigned int boot_flash_env_addr;
+extern unsigned int boot_flash_off;
+extern unsigned int boot_flash_sec;
+extern unsigned int boot_flash_type;
+#endif
+
+#if defined(CONFIG_CMD_NET)
+/*----------------------------------------------------------------------------
+ * SMSC9211 Ethernet from SMSC9118 family
+ *----------------------------------------------------------------------------
+ */
+
+#define CONFIG_NET_MULTI
+#define CONFIG_SMC911X 1
+#define CONFIG_SMC911X_32_BIT
+#define CONFIG_SMC911X_BASE 0x2C000000
+
+#endif /* (CONFIG_CMD_NET) */
+
+#define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM_1
+#define CONFIG_SYS_INIT_RAM_ADDR 0x4020f800
+#define CONFIG_SYS_INIT_RAM_SIZE 0x800
+#define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_INIT_RAM_ADDR + \
+ CONFIG_SYS_INIT_RAM_SIZE - \
+ GENERATED_GBL_DATA_SIZE)
+
+#endif /* __CONFIG_H */
diff --git a/package/boot/uboot-omap35xx/files/include/configs/omap3_overo.h b/package/boot/uboot-omap35xx/files/include/configs/omap3_overo.h
new file mode 100644
index 0000000..e1c930d
--- /dev/null
+++ b/package/boot/uboot-omap35xx/files/include/configs/omap3_overo.h
@@ -0,0 +1,316 @@
+/*
+ * Configuration settings for the Gumstix Overo board.
+ *
+ * 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 of
+ * the License, 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef __CONFIG_H
+#define __CONFIG_H
+
+/*
+ * High Level Configuration Options
+ */
+#define CONFIG_ARMV7 1 /* This is an ARM V7 CPU core */
+#define CONFIG_OMAP 1 /* in a TI OMAP core */
+#define CONFIG_OMAP34XX 1 /* which is a 34XX */
+#define CONFIG_OMAP3430 1 /* which is in a 3430 */
+#define CONFIG_OMAP3_OVERO 1 /* working with overo */
+
+#define CONFIG_SDRC /* The chip has SDRC controller */
+
+#include <asm/arch/cpu.h> /* get chip and board defs */
+#include <asm/arch/omap3.h>
+
+/*
+ * Display CPU and Board information
+ */
+#define CONFIG_DISPLAY_CPUINFO 1
+#define CONFIG_DISPLAY_BOARDINFO 1
+
+/* Clock Defines */
+#define V_OSCK 26000000 /* Clock output from T2 */
+#define V_SCLK (V_OSCK >> 1)
+
+#undef CONFIG_USE_IRQ /* no support for IRQs */
+#define CONFIG_MISC_INIT_R
+
+#define CONFIG_CMDLINE_TAG 1 /* enable passing of ATAGs */
+#define CONFIG_SETUP_MEMORY_TAGS 1
+#define CONFIG_INITRD_TAG 1
+#define CONFIG_REVISION_TAG 1
+
+/*
+ * Size of malloc() pool
+ */
+#define CONFIG_ENV_SIZE (128 << 10) /* 128 KiB */
+ /* Sector */
+#define CONFIG_SYS_MALLOC_LEN (CONFIG_ENV_SIZE + (128 << 10))
+ /* initial data */
+
+/*
+ * Hardware drivers
+ */
+
+/*
+ * NS16550 Configuration
+ */
+#define V_NS16550_CLK 48000000 /* 48MHz (APLL96/2) */
+
+#define CONFIG_SYS_NS16550
+#define CONFIG_SYS_NS16550_SERIAL
+#define CONFIG_SYS_NS16550_REG_SIZE (-4)
+#define CONFIG_SYS_NS16550_CLK V_NS16550_CLK
+
+/*
+ * select serial console configuration
+ */
+#define CONFIG_CONS_INDEX 3
+#define CONFIG_SYS_NS16550_COM3 OMAP34XX_UART3
+#define CONFIG_SERIAL3 3
+
+/* allow to overwrite serial and ethaddr */
+#define CONFIG_ENV_OVERWRITE
+#define CONFIG_BAUDRATE 115200
+#define CONFIG_SYS_BAUDRATE_TABLE {4800, 9600, 19200, 38400, 57600, \
+ 115200}
+#define CONFIG_GENERIC_MMC 1
+#define CONFIG_MMC 1
+#define CONFIG_OMAP_HSMMC 1
+#define CONFIG_DOS_PARTITION 1
+
+/* DDR - I use Micron DDR */
+#define CONFIG_OMAP3_MICRON_DDR 1
+
+/* commands to include */
+#include <config_cmd_default.h>
+
+#define CONFIG_CMD_CACHE
+#define CONFIG_CMD_EXT2 /* EXT2 Support */
+#define CONFIG_CMD_FAT /* FAT support */
+#define CONFIG_CMD_JFFS2 /* JFFS2 Support */
+
+#define CONFIG_CMD_I2C /* I2C serial bus support */
+#define CONFIG_CMD_MMC /* MMC support */
+#define CONFIG_CMD_NAND /* NAND support */
+
+#undef CONFIG_CMD_FLASH /* flinfo, erase, protect */
+#undef CONFIG_CMD_FPGA /* FPGA configuration Support */
+#undef CONFIG_CMD_IMI /* iminfo */
+#undef CONFIG_CMD_IMLS /* List all found images */
+#undef CONFIG_CMD_NFS /* NFS support */
+#define CONFIG_CMD_NET /* bootp, tftpboot, rarpboot */
+
+#define CONFIG_SYS_NO_FLASH
+#define CONFIG_HARD_I2C 1
+#define CONFIG_SYS_I2C_SPEED 100000
+#define CONFIG_SYS_I2C_SLAVE 1
+#define CONFIG_SYS_I2C_BUS 0
+#define CONFIG_SYS_I2C_BUS_SELECT 1
+#define CONFIG_I2C_MULTI_BUS 1
+#define CONFIG_DRIVER_OMAP34XX_I2C 1
+
+/*
+ * TWL4030
+ */
+#define CONFIG_TWL4030_POWER 1
+#define CONFIG_TWL4030_LED 1
+
+/*
+ * Board NAND Info.
+ */
+#define CONFIG_SYS_NAND_QUIET_TEST 1
+#define CONFIG_NAND_OMAP_GPMC
+#define CONFIG_SYS_NAND_ADDR NAND_BASE /* physical address */
+ /* to access nand */
+#define CONFIG_SYS_NAND_BASE NAND_BASE /* physical address */
+ /* to access nand */
+ /* at CS0 */
+#define GPMC_NAND_ECC_LP_x16_LAYOUT 1
+
+#define CONFIG_SYS_MAX_NAND_DEVICE 1 /* Max number of NAND */
+ /* devices */
+#define CONFIG_JFFS2_NAND
+/* nand device jffs2 lives on */
+#define CONFIG_JFFS2_DEV "nand0"
+/* start of jffs2 partition */
+#define CONFIG_JFFS2_PART_OFFSET 0x680000
+#define CONFIG_JFFS2_PART_SIZE 0xf980000 /* size of jffs2 */
+ /* partition */
+
+/* Environment information */
+#define CONFIG_BOOTDELAY 5
+
+#define CONFIG_EXTRA_ENV_SETTINGS \
+ "loadaddr=0x82000000\0" \
+ "console=ttyO2,115200n8\0" \
+ "mpurate=500\0" \
+ "vram=12M\0" \
+ "dvimode=1024x768MR-16@60\0" \
+ "defaultdisplay=dvi\0" \
+ "mmcdev=0\0" \
+ "mmcroot=/dev/mmcblk0p2 rw\0" \
+ "mmcrootfstype=ext3 rootwait\0" \
+ "nandroot='ubi0:rootfs ubi.mtd=5 ubi.mtd=6 ubi.mtd=7'\0" \
+ "nandrootfstype=ubifs\0" \
+ "mmcargs=setenv bootargs console=${console} " \
+ "mpurate=${mpurate} " \
+ "vram=${vram} " \
+ "omapfb.mode=dvi:${dvimode} " \
+ "omapfb.debug=y " \
+ "omapdss.def_disp=${defaultdisplay} " \
+ "root=${mmcroot} " \
+ "rootfstype=${mmcrootfstype}\0" \
+ "nandargs=setenv bootargs console=${console} " \
+ "mpurate=${mpurate} " \
+ "vram=${vram} " \
+ "omapfb.mode=dvi:${dvimode} " \
+ "omapfb.debug=y " \
+ "omapdss.def_disp=${defaultdisplay} " \
+ "root=${nandroot} " \
+ "rootfstype=${nandrootfstype}\0" \
+ "loadbootscript=fatload mmc ${mmcdev} ${loadaddr} boot.scr\0" \
+ "bootscript=echo Running bootscript from mmc ...; " \
+ "source ${loadaddr}\0" \
+ "loaduimage=fatload mmc ${mmcdev} ${loadaddr} uImage\0" \
+ "mmcboot=echo Booting from mmc ...; " \
+ "run mmcargs; " \
+ "bootm ${loadaddr}\0" \
+ "nandboot=echo Booting from nand ...; " \
+ "run nandargs; " \
+ "nand read ${loadaddr} 280000 200000; " \
+ "bootm ${loadaddr}\0" \
+
+#define CONFIG_BOOTCOMMAND \
+ "if mmc rescan ${mmcdev}; then " \
+ "if run loadbootscript; then " \
+ "run bootscript; " \
+ "else " \
+ "if run loaduimage; then " \
+ "run mmcboot; " \
+ "else run nandboot; " \
+ "fi; " \
+ "fi; " \
+ "else run nandboot; fi"
+
+#define CONFIG_AUTO_COMPLETE 1
+/*
+ * Miscellaneous configurable options
+ */
+#define CONFIG_SYS_LONGHELP /* undef to save memory */
+#define CONFIG_SYS_HUSH_PARSER /* use "hush" command parser */
+#define CONFIG_SYS_PROMPT_HUSH_PS2 "> "
+#define CONFIG_SYS_PROMPT "Overo # "
+#define CONFIG_SYS_CBSIZE 256 /* Console I/O Buffer Size */
+/* Print Buffer Size */
+#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE + \
+ sizeof(CONFIG_SYS_PROMPT) + 16)
+#define CONFIG_SYS_MAXARGS 16 /* max number of command */
+ /* args */
+/* Boot Argument Buffer Size */
+#define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE
+/* memtest works on */
+#define CONFIG_SYS_MEMTEST_START (OMAP34XX_SDRC_CS0)
+#define CONFIG_SYS_MEMTEST_END (OMAP34XX_SDRC_CS0 + \
+ 0x01F00000) /* 31MB */
+
+#define CONFIG_SYS_LOAD_ADDR (OMAP34XX_SDRC_CS0) /* default load */
+ /* address */
+/*
+ * OMAP3 has 12 GP timers, they can be driven by the system clock
+ * (12/13/16.8/19.2/38.4MHz) or by 32KHz clock. We use 13MHz (V_SCLK).
+ * This rate is divided by a local divisor.
+ */
+#define CONFIG_SYS_TIMERBASE OMAP34XX_GPT2
+#define CONFIG_SYS_PTV 2 /* Divisor: 2^(PTV+1) => 8 */
+#define CONFIG_SYS_HZ 1000
+
+/*-----------------------------------------------------------------------
+ * Stack sizes
+ *
+ * The stack sizes are set up in start.S using the settings below
+ */
+#define CONFIG_STACKSIZE (128 << 10) /* regular stack 128 KiB */
+#ifdef CONFIG_USE_IRQ
+#define CONFIG_STACKSIZE_IRQ (4 << 10) /* IRQ stack 4 KiB */
+#define CONFIG_STACKSIZE_FIQ (4 << 10) /* FIQ stack 4 KiB */
+#endif
+
+/*-----------------------------------------------------------------------
+ * Physical Memory Map
+ */
+#define CONFIG_NR_DRAM_BANKS 2 /* CS1 may or may not be populated */
+#define PHYS_SDRAM_1 OMAP34XX_SDRC_CS0
+#define PHYS_SDRAM_1_SIZE (32 << 20) /* at least 32 MiB */
+#define PHYS_SDRAM_2 OMAP34XX_SDRC_CS1
+
+/* SDRAM Bank Allocation method */
+#define SDRC_R_B_C 1
+
+/*-----------------------------------------------------------------------
+ * FLASH and environment organization
+ */
+
+/* **** PISMO SUPPORT *** */
+
+/* Configure the PISMO */
+#define PISMO1_NAND_SIZE GPMC_SIZE_128M
+#define PISMO1_ONEN_SIZE GPMC_SIZE_128M
+
+#define CONFIG_SYS_MONITOR_LEN (256 << 10) /* Reserve 2 sectors */
+
+#define CONFIG_SYS_FLASH_BASE boot_flash_base
+
+/* Monitor at start of flash */
+#define CONFIG_SYS_MONITOR_BASE CONFIG_SYS_FLASH_BASE
+#define CONFIG_SYS_ONENAND_BASE ONENAND_MAP
+
+#define CONFIG_ENV_IS_IN_NAND 1
+#define ONENAND_ENV_OFFSET 0x240000 /* environment starts here */
+#define SMNAND_ENV_OFFSET 0x240000 /* environment starts here */
+
+#define CONFIG_SYS_ENV_SECT_SIZE boot_flash_sec
+#define CONFIG_ENV_OFFSET boot_flash_off
+#define CONFIG_ENV_ADDR SMNAND_ENV_OFFSET
+
+#ifndef __ASSEMBLY__
+extern unsigned int boot_flash_base;
+extern volatile unsigned int boot_flash_env_addr;
+extern unsigned int boot_flash_off;
+extern unsigned int boot_flash_sec;
+extern unsigned int boot_flash_type;
+#endif
+
+#if defined(CONFIG_CMD_NET)
+/*----------------------------------------------------------------------------
+ * SMSC9211 Ethernet from SMSC9118 family
+ *----------------------------------------------------------------------------
+ */
+
+#define CONFIG_NET_MULTI
+#define CONFIG_SMC911X 1
+#define CONFIG_SMC911X_32_BIT
+#define CONFIG_SMC911X_BASE 0x2C000000
+
+#endif /* (CONFIG_CMD_NET) */
+
+#define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM_1
+#define CONFIG_SYS_INIT_RAM_ADDR 0x4020f800
+#define CONFIG_SYS_INIT_RAM_SIZE 0x800
+#define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_INIT_RAM_ADDR + \
+ CONFIG_SYS_INIT_RAM_SIZE - \
+ GENERATED_GBL_DATA_SIZE)
+
+#endif /* __CONFIG_H */
diff --git a/package/boot/uboot-omap4/.svn/entries b/package/boot/uboot-omap4/.svn/entries
new file mode 100644
index 0000000..b8dfce9
--- /dev/null
+++ b/package/boot/uboot-omap4/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/uboot-omap4
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+5d245a30082c95e1b75afc31e6884530
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2010
+
diff --git a/package/boot/uboot-omap4/.svn/text-base/Makefile.svn-base b/package/boot/uboot-omap4/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..d128e16
--- /dev/null
+++ b/package/boot/uboot-omap4/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,90 @@
+#
+# Copyright (C) 2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=u-boot
+PKG_VERSION:=2011.12
+PKG_RELEASE:=1
+
+PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=ftp://ftp.denx.de/pub/u-boot
+PKG_MD5SUM:=7f29b9f6da44d6e46e988e7561fd1d5f
+PKG_TARGETS:=bin
+
+include $(INCLUDE_DIR)/package.mk
+
+define uboot/Default
+ TITLE:=
+ CONFIG:=
+ IMAGE:=
+endef
+
+define uboot/omap4_panda
+ TITLE:=U-Boot for the Pandaboard
+endef
+
+UBOOTS:=omap4_panda
+
+define Package/uboot/template
+define Package/uboot-omap4-$(1)
+ SECTION:=boot
+ CATEGORY:=Boot Loaders
+ DEPENDS:=@TARGET_omap4
+ TITLE:=$(2)
+ URL:=http://www.denx.de/wiki/U-Boot
+ VARIANT:=$(1)
+endef
+endef
+
+define BuildUbootPackage
+ $(eval $(uboot/Default))
+ $(eval $(uboot/$(1)))
+ $(call Package/uboot/template,$(1),$(TITLE))
+endef
+
+
+ifdef BUILD_VARIANT
+$(eval $(call uboot/$(BUILD_VARIANT)))
+UBOOT_CONFIG:=$(if $(CONFIG),$(CONFIG),$(BUILD_VARIANT))
+UBOOT_IMAGE:=$(if $(IMAGE),$(IMAGE),openwrt-$(BOARD)-$(BUILD_VARIANT)-u-boot.bin)
+endif
+
+define Build/Prepare
+ $(call Build/Prepare/Default)
+# $(CP) ./files/* $(PKG_BUILD_DIR)
+ find $(PKG_BUILD_DIR) -name .svn | $(XARGS) rm -rf
+endef
+
+define Build/Configure
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ $(UBOOT_CONFIG)_config
+endef
+
+define Build/Compile
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ CROSS_COMPILE=$(TARGET_CROSS)
+endef
+
+define Package/uboot/install/template
+define Package/uboot-omap4-$(1)/install
+ $(INSTALL_DIR) $$(1)
+ $(CP) $(PKG_BUILD_DIR)/MLO $(BIN_DIR)/MLO-$(BOARD)
+ $(CP) $(PKG_BUILD_DIR)/u-boot.img $(BIN_DIR)/$(2)
+endef
+endef
+
+$(foreach u,$(UBOOTS), \
+ $(eval $(call Package/uboot/install/template,$(u),openwrt-$(BOARD)-$(u)-u-boot.img)) \
+)
+
+$(foreach u,$(UBOOTS), \
+ $(eval $(call BuildUbootPackage,$(u))) \
+ $(eval $(call BuildPackage,uboot-omap4-$(u))) \
+)
diff --git a/package/boot/uboot-omap4/Makefile b/package/boot/uboot-omap4/Makefile
new file mode 100644
index 0000000..d128e16
--- /dev/null
+++ b/package/boot/uboot-omap4/Makefile
@@ -0,0 +1,90 @@
+#
+# Copyright (C) 2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=u-boot
+PKG_VERSION:=2011.12
+PKG_RELEASE:=1
+
+PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=ftp://ftp.denx.de/pub/u-boot
+PKG_MD5SUM:=7f29b9f6da44d6e46e988e7561fd1d5f
+PKG_TARGETS:=bin
+
+include $(INCLUDE_DIR)/package.mk
+
+define uboot/Default
+ TITLE:=
+ CONFIG:=
+ IMAGE:=
+endef
+
+define uboot/omap4_panda
+ TITLE:=U-Boot for the Pandaboard
+endef
+
+UBOOTS:=omap4_panda
+
+define Package/uboot/template
+define Package/uboot-omap4-$(1)
+ SECTION:=boot
+ CATEGORY:=Boot Loaders
+ DEPENDS:=@TARGET_omap4
+ TITLE:=$(2)
+ URL:=http://www.denx.de/wiki/U-Boot
+ VARIANT:=$(1)
+endef
+endef
+
+define BuildUbootPackage
+ $(eval $(uboot/Default))
+ $(eval $(uboot/$(1)))
+ $(call Package/uboot/template,$(1),$(TITLE))
+endef
+
+
+ifdef BUILD_VARIANT
+$(eval $(call uboot/$(BUILD_VARIANT)))
+UBOOT_CONFIG:=$(if $(CONFIG),$(CONFIG),$(BUILD_VARIANT))
+UBOOT_IMAGE:=$(if $(IMAGE),$(IMAGE),openwrt-$(BOARD)-$(BUILD_VARIANT)-u-boot.bin)
+endif
+
+define Build/Prepare
+ $(call Build/Prepare/Default)
+# $(CP) ./files/* $(PKG_BUILD_DIR)
+ find $(PKG_BUILD_DIR) -name .svn | $(XARGS) rm -rf
+endef
+
+define Build/Configure
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ $(UBOOT_CONFIG)_config
+endef
+
+define Build/Compile
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ CROSS_COMPILE=$(TARGET_CROSS)
+endef
+
+define Package/uboot/install/template
+define Package/uboot-omap4-$(1)/install
+ $(INSTALL_DIR) $$(1)
+ $(CP) $(PKG_BUILD_DIR)/MLO $(BIN_DIR)/MLO-$(BOARD)
+ $(CP) $(PKG_BUILD_DIR)/u-boot.img $(BIN_DIR)/$(2)
+endef
+endef
+
+$(foreach u,$(UBOOTS), \
+ $(eval $(call Package/uboot/install/template,$(u),openwrt-$(BOARD)-$(u)-u-boot.img)) \
+)
+
+$(foreach u,$(UBOOTS), \
+ $(eval $(call BuildUbootPackage,$(u))) \
+ $(eval $(call BuildPackage,uboot-omap4-$(u))) \
+)
diff --git a/package/boot/uboot-pxa/.svn/entries b/package/boot/uboot-pxa/.svn/entries
new file mode 100644
index 0000000..cd230d0
--- /dev/null
+++ b/package/boot/uboot-pxa/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/uboot-pxa
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+0fadf5838e09edaec577b298d7e9c4eb
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1980
+
diff --git a/package/boot/uboot-pxa/.svn/text-base/Makefile.svn-base b/package/boot/uboot-pxa/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..7fe747c
--- /dev/null
+++ b/package/boot/uboot-pxa/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,89 @@
+#
+# Copyright (C) 2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=u-boot
+PKG_VERSION:=2011.08.25
+PKG_RELEASE:=1
+
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL:=git://github.com/ashcharles/verdex-uboot.git
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE_VERSION:=ca6bf3ef6ac5f5132a359b43dfa31e07076b74b7
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
+
+include $(INCLUDE_DIR)/package.mk
+
+define uboot/Default
+ TITLE:=
+ CONFIG:=
+ IMAGE:=
+endef
+
+define uboot/gumstix
+ TITLE:=U-Boot for the Gumstix Verdex
+endef
+
+UBOOTS:=gumstix
+
+define Package/uboot/template
+define Package/uboot-pxa-$(1)
+ SECTION:=boot
+ CATEGORY:=Boot Loaders
+ DEPENDS:=@TARGET_pxa
+ TITLE:=$(2)
+ URL:=http://www.denx.de/wiki/U-Boot
+ VARIANT:=$(1)
+ MAINTAINER:=Florian Fainelli <florian@openwrt.org>
+endef
+endef
+
+define BuildUBootPackage
+ $(eval $(uboot/Default))
+ $(eval $(uboot/$(1)))
+ $(call Package/uboot/template,$(1),$(TITLE))
+endef
+
+ifdef BUILD_VARIANT
+$(eval $(call uboot/$(BUILD_VARIANT)))
+UBOOT_CONFIG:=$(if $(CONFIG),$(CONFIG),$(BUILD_VARIANT))
+UBOOT_IMAGE:=$(if $(IMAGE),$(IMAGE),openwrt-$(BOARD)-$(BUILD_VARIANT)-u-boot.bin)
+endif
+
+define Build/Configure
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ $(UBOOT_CONFIG)_config
+endef
+
+define Build/Compile
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ u-boot.bin \
+ CROSS_COMPILE=$(TARGET_CROSS)
+endef
+
+define Package/uboot/install/default
+ $(INSTALL_DIR) $(BIN_DIR)
+ $(CP) $(PKG_BUILD_DIR)/u-boot.bin \
+ $(BIN_DIR)/openwrt-$(BOARD)-$(1)-u-boot.bin
+endef
+
+define Package/uboot/install/template
+define Package/uboot-pxa-$(1)/install
+ $(call Package/uboot/install/default,$(2))
+endef
+endef
+
+$(foreach u,$(UBOOTS), \
+ $(eval $(call Package/uboot/install/template,$(u),$(u))) \
+)
+
+$(foreach u,$(UBOOTS), \
+ $(eval $(call BuildUBootPackage,$(u))) \
+ $(eval $(call BuildPackage,uboot-pxa-$(u))) \
+)
diff --git a/package/boot/uboot-pxa/Makefile b/package/boot/uboot-pxa/Makefile
new file mode 100644
index 0000000..7fe747c
--- /dev/null
+++ b/package/boot/uboot-pxa/Makefile
@@ -0,0 +1,89 @@
+#
+# Copyright (C) 2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=u-boot
+PKG_VERSION:=2011.08.25
+PKG_RELEASE:=1
+
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL:=git://github.com/ashcharles/verdex-uboot.git
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE_VERSION:=ca6bf3ef6ac5f5132a359b43dfa31e07076b74b7
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
+
+include $(INCLUDE_DIR)/package.mk
+
+define uboot/Default
+ TITLE:=
+ CONFIG:=
+ IMAGE:=
+endef
+
+define uboot/gumstix
+ TITLE:=U-Boot for the Gumstix Verdex
+endef
+
+UBOOTS:=gumstix
+
+define Package/uboot/template
+define Package/uboot-pxa-$(1)
+ SECTION:=boot
+ CATEGORY:=Boot Loaders
+ DEPENDS:=@TARGET_pxa
+ TITLE:=$(2)
+ URL:=http://www.denx.de/wiki/U-Boot
+ VARIANT:=$(1)
+ MAINTAINER:=Florian Fainelli <florian@openwrt.org>
+endef
+endef
+
+define BuildUBootPackage
+ $(eval $(uboot/Default))
+ $(eval $(uboot/$(1)))
+ $(call Package/uboot/template,$(1),$(TITLE))
+endef
+
+ifdef BUILD_VARIANT
+$(eval $(call uboot/$(BUILD_VARIANT)))
+UBOOT_CONFIG:=$(if $(CONFIG),$(CONFIG),$(BUILD_VARIANT))
+UBOOT_IMAGE:=$(if $(IMAGE),$(IMAGE),openwrt-$(BOARD)-$(BUILD_VARIANT)-u-boot.bin)
+endif
+
+define Build/Configure
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ $(UBOOT_CONFIG)_config
+endef
+
+define Build/Compile
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ u-boot.bin \
+ CROSS_COMPILE=$(TARGET_CROSS)
+endef
+
+define Package/uboot/install/default
+ $(INSTALL_DIR) $(BIN_DIR)
+ $(CP) $(PKG_BUILD_DIR)/u-boot.bin \
+ $(BIN_DIR)/openwrt-$(BOARD)-$(1)-u-boot.bin
+endef
+
+define Package/uboot/install/template
+define Package/uboot-pxa-$(1)/install
+ $(call Package/uboot/install/default,$(2))
+endef
+endef
+
+$(foreach u,$(UBOOTS), \
+ $(eval $(call Package/uboot/install/template,$(u),$(u))) \
+)
+
+$(foreach u,$(UBOOTS), \
+ $(eval $(call BuildUBootPackage,$(u))) \
+ $(eval $(call BuildPackage,uboot-pxa-$(u))) \
+)
diff --git a/package/boot/uboot-pxa/patches/.svn/entries b/package/boot/uboot-pxa/patches/.svn/entries
new file mode 100644
index 0000000..be5d3b6
--- /dev/null
+++ b/package/boot/uboot-pxa/patches/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/uboot-pxa/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+001-squashfs_rootfstype_cmdline.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+cb4baee4e5cf315fe29485e6f3c4d943
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1105
+
diff --git a/package/boot/uboot-pxa/patches/.svn/text-base/001-squashfs_rootfstype_cmdline.patch.svn-base b/package/boot/uboot-pxa/patches/.svn/text-base/001-squashfs_rootfstype_cmdline.patch.svn-base
new file mode 100644
index 0000000..cfef66b
--- /dev/null
+++ b/package/boot/uboot-pxa/patches/.svn/text-base/001-squashfs_rootfstype_cmdline.patch.svn-base
@@ -0,0 +1,13 @@
+diff --git a/include/configs/gumstix.h b/include/configs/gumstix.h
+index 319da63..5483993 100644
+--- a/include/configs/gumstix.h
++++ b/include/configs/gumstix.h
+@@ -136,7 +136,7 @@
+ #define CONFIG_MISC_INIT_R /* misc_init_r function in gumstix sets board serial number */
+
+ #define CONFIG_BOOTFILE boot/uImage
+-#define CONFIG_BOOTARGS "console=ttyS0,115200n8 root=1f01 rootfstype=jffs2 reboot=cold,hard"
++#define CONFIG_BOOTARGS "console=ttyS0,115200n8 root=1f01 rootfstype=squashfs,jffs2 reboot=cold,hard"
+ #define CONFIG_BOOTCOMMAND "icache on; setenv stderr nulldev; setenv stdout nulldev; if pinit on && fatload ide 0 a2000000 gumstix-factory.script; then setenv stdout serial; setenv stderr serial; echo Found gumstix-factory.script on CF...; autoscr; else if mmcinit && fatload mmc 0 a2000000 gumstix-factory.script; then setenv stdout serial; setenv stderr serial; echo Found gumstix-factory.script on MMC...; autoscr; else setenv stdout serial; setenv stderr serial; katload 100000 && bootm; fi; fi"
+ #define CONFIG_BOOTDELAY 2 /* in seconds */
+ #define CONFIG_EXTRA_ENV_SETTINGS "verify=no"
diff --git a/package/boot/uboot-pxa/patches/001-squashfs_rootfstype_cmdline.patch b/package/boot/uboot-pxa/patches/001-squashfs_rootfstype_cmdline.patch
new file mode 100644
index 0000000..cfef66b
--- /dev/null
+++ b/package/boot/uboot-pxa/patches/001-squashfs_rootfstype_cmdline.patch
@@ -0,0 +1,13 @@
+diff --git a/include/configs/gumstix.h b/include/configs/gumstix.h
+index 319da63..5483993 100644
+--- a/include/configs/gumstix.h
++++ b/include/configs/gumstix.h
+@@ -136,7 +136,7 @@
+ #define CONFIG_MISC_INIT_R /* misc_init_r function in gumstix sets board serial number */
+
+ #define CONFIG_BOOTFILE boot/uImage
+-#define CONFIG_BOOTARGS "console=ttyS0,115200n8 root=1f01 rootfstype=jffs2 reboot=cold,hard"
++#define CONFIG_BOOTARGS "console=ttyS0,115200n8 root=1f01 rootfstype=squashfs,jffs2 reboot=cold,hard"
+ #define CONFIG_BOOTCOMMAND "icache on; setenv stderr nulldev; setenv stdout nulldev; if pinit on && fatload ide 0 a2000000 gumstix-factory.script; then setenv stdout serial; setenv stderr serial; echo Found gumstix-factory.script on CF...; autoscr; else if mmcinit && fatload mmc 0 a2000000 gumstix-factory.script; then setenv stdout serial; setenv stderr serial; echo Found gumstix-factory.script on MMC...; autoscr; else setenv stdout serial; setenv stderr serial; katload 100000 && bootm; fi; fi"
+ #define CONFIG_BOOTDELAY 2 /* in seconds */
+ #define CONFIG_EXTRA_ENV_SETTINGS "verify=no"
diff --git a/package/boot/uboot-xburst/.svn/entries b/package/boot/uboot-xburst/.svn/entries
new file mode 100644
index 0000000..f21bf90
--- /dev/null
+++ b/package/boot/uboot-xburst/.svn/entries
@@ -0,0 +1,68 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/uboot-xburst
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-07T17:11:15.287568Z
+35042
+mirko
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+files
+dir
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+e4c7934e9ef907cf8d46a731519a560c
+2013-01-07T17:11:15.287568Z
+35042
+mirko
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1820
+
diff --git a/package/boot/uboot-xburst/.svn/text-base/Makefile.svn-base b/package/boot/uboot-xburst/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..f4c8ad9
--- /dev/null
+++ b/package/boot/uboot-xburst/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,83 @@
+#
+# Copyright (C) 2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=u-boot
+PKG_VERSION:=2012.10-rc2
+PKG_RELEASE:=1
+
+PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=ftp://ftp.denx.de/pub/u-boot
+PKG_MD5SUM:=451c07271940016cec6f5ad8a155263b
+PKG_TARGETS:=bin
+
+include $(INCLUDE_DIR)/package.mk
+
+define uboot/Default
+ TITLE:=
+ CONFIG:=
+ IMAGE:=
+endef
+
+define uboot/qi_lb60
+ TITLE:=U-boot for the qi_lb60 board
+endef
+
+UBOOTS:=qi_lb60
+
+define Package/uboot/template
+define Package/uboot-xburst-$(1)
+ SECTION:=boot
+ CATEGORY:=Boot Loaders
+ DEPENDS:=@TARGET_xburst
+ TITLE:=$(2)
+ URL:=http://www.denx.de/wiki/UBoot/WebHome
+ VARIANT:=$(1)
+endef
+endef
+
+define BuildUbootPackage
+ $(eval $(uboot/Default))
+ $(eval $(uboot/$(1)))
+ $(call Package/uboot/template,$(1),$(TITLE))
+endef
+
+
+ifdef BUILD_VARIANT
+$(eval $(call uboot/$(BUILD_VARIANT)))
+UBOOT_CONFIG:=$(if $(CONFIG),$(CONFIG),$(BUILD_VARIANT))
+UBOOT_IMAGE:=$(if $(IMAGE),$(IMAGE),openwrt-$(BOARD)-$(BUILD_VARIANT)-u-boot.bin)
+endif
+
+define Build/Configure
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ $(UBOOT_CONFIG)_config
+endef
+
+define Build/Compile
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ CROSS_COMPILE=$(TARGET_CROSS)
+endef
+
+define Package/uboot/install/template
+define Package/uboot-xburst-$(1)/install
+ $(CP) $(PKG_BUILD_DIR)/u-boot-xburst.bin $(BIN_DIR)/$(2)
+ rmdir $$(1)
+endef
+endef
+
+$(foreach u,$(UBOOTS), \
+ $(eval $(call Package/uboot/install/template,$(u),openwrt-$(BOARD)-$(u)-u-boot.bin)) \
+)
+
+$(foreach u,$(UBOOTS), \
+ $(eval $(call BuildUbootPackage,$(u))) \
+ $(eval $(call BuildPackage,uboot-xburst-$(u))) \
+)
diff --git a/package/boot/uboot-xburst/Makefile b/package/boot/uboot-xburst/Makefile
new file mode 100644
index 0000000..f4c8ad9
--- /dev/null
+++ b/package/boot/uboot-xburst/Makefile
@@ -0,0 +1,83 @@
+#
+# Copyright (C) 2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=u-boot
+PKG_VERSION:=2012.10-rc2
+PKG_RELEASE:=1
+
+PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=ftp://ftp.denx.de/pub/u-boot
+PKG_MD5SUM:=451c07271940016cec6f5ad8a155263b
+PKG_TARGETS:=bin
+
+include $(INCLUDE_DIR)/package.mk
+
+define uboot/Default
+ TITLE:=
+ CONFIG:=
+ IMAGE:=
+endef
+
+define uboot/qi_lb60
+ TITLE:=U-boot for the qi_lb60 board
+endef
+
+UBOOTS:=qi_lb60
+
+define Package/uboot/template
+define Package/uboot-xburst-$(1)
+ SECTION:=boot
+ CATEGORY:=Boot Loaders
+ DEPENDS:=@TARGET_xburst
+ TITLE:=$(2)
+ URL:=http://www.denx.de/wiki/UBoot/WebHome
+ VARIANT:=$(1)
+endef
+endef
+
+define BuildUbootPackage
+ $(eval $(uboot/Default))
+ $(eval $(uboot/$(1)))
+ $(call Package/uboot/template,$(1),$(TITLE))
+endef
+
+
+ifdef BUILD_VARIANT
+$(eval $(call uboot/$(BUILD_VARIANT)))
+UBOOT_CONFIG:=$(if $(CONFIG),$(CONFIG),$(BUILD_VARIANT))
+UBOOT_IMAGE:=$(if $(IMAGE),$(IMAGE),openwrt-$(BOARD)-$(BUILD_VARIANT)-u-boot.bin)
+endif
+
+define Build/Configure
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ $(UBOOT_CONFIG)_config
+endef
+
+define Build/Compile
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ CROSS_COMPILE=$(TARGET_CROSS)
+endef
+
+define Package/uboot/install/template
+define Package/uboot-xburst-$(1)/install
+ $(CP) $(PKG_BUILD_DIR)/u-boot-xburst.bin $(BIN_DIR)/$(2)
+ rmdir $$(1)
+endef
+endef
+
+$(foreach u,$(UBOOTS), \
+ $(eval $(call Package/uboot/install/template,$(u),openwrt-$(BOARD)-$(u)-u-boot.bin)) \
+)
+
+$(foreach u,$(UBOOTS), \
+ $(eval $(call BuildUbootPackage,$(u))) \
+ $(eval $(call BuildPackage,uboot-xburst-$(u))) \
+)
diff --git a/package/boot/uboot-xburst/files/.svn/entries b/package/boot/uboot-xburst/files/.svn/entries
new file mode 100644
index 0000000..df14e18
--- /dev/null
+++ b/package/boot/uboot-xburst/files/.svn/entries
@@ -0,0 +1,40 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/uboot-xburst/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-07T14:10:01.049177Z
+35034
+mirko
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+include
+dir
+
+board
+dir
+
+cpu
+dir
+
+nand_spl
+dir
+
diff --git a/package/boot/uboot-xburst/files/board/.svn/entries b/package/boot/uboot-xburst/files/board/.svn/entries
new file mode 100644
index 0000000..9c92717
--- /dev/null
+++ b/package/boot/uboot-xburst/files/board/.svn/entries
@@ -0,0 +1,37 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/uboot-xburst/files/board
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-07T14:10:01.049177Z
+35034
+mirko
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+nanonote
+dir
+
+sakc
+dir
+
+n516
+dir
+
diff --git a/package/boot/uboot-xburst/files/board/n516/.svn/entries b/package/boot/uboot-xburst/files/board/n516/.svn/entries
new file mode 100644
index 0000000..7556702
--- /dev/null
+++ b/package/boot/uboot-xburst/files/board/n516/.svn/entries
@@ -0,0 +1,28 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/uboot-xburst/files/board/n516
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-07T14:10:01.049177Z
+35034
+mirko
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
diff --git a/package/boot/uboot-xburst/files/board/nanonote/.svn/entries b/package/boot/uboot-xburst/files/board/nanonote/.svn/entries
new file mode 100644
index 0000000..cd3d211
--- /dev/null
+++ b/package/boot/uboot-xburst/files/board/nanonote/.svn/entries
@@ -0,0 +1,28 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/uboot-xburst/files/board/nanonote
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-07T14:10:01.049177Z
+35034
+mirko
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
diff --git a/package/boot/uboot-xburst/files/board/sakc/.svn/entries b/package/boot/uboot-xburst/files/board/sakc/.svn/entries
new file mode 100644
index 0000000..e22ec07
--- /dev/null
+++ b/package/boot/uboot-xburst/files/board/sakc/.svn/entries
@@ -0,0 +1,28 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/uboot-xburst/files/board/sakc
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-07T14:10:01.049177Z
+35034
+mirko
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
diff --git a/package/boot/uboot-xburst/files/cpu/.svn/entries b/package/boot/uboot-xburst/files/cpu/.svn/entries
new file mode 100644
index 0000000..d6e3dc5
--- /dev/null
+++ b/package/boot/uboot-xburst/files/cpu/.svn/entries
@@ -0,0 +1,31 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/uboot-xburst/files/cpu
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-07T14:10:01.049177Z
+35034
+mirko
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+mips
+dir
+
diff --git a/package/boot/uboot-xburst/files/cpu/mips/.svn/entries b/package/boot/uboot-xburst/files/cpu/mips/.svn/entries
new file mode 100644
index 0000000..05c73eb
--- /dev/null
+++ b/package/boot/uboot-xburst/files/cpu/mips/.svn/entries
@@ -0,0 +1,28 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/uboot-xburst/files/cpu/mips
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-07T14:10:01.049177Z
+35034
+mirko
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
diff --git a/package/boot/uboot-xburst/files/include/.svn/entries b/package/boot/uboot-xburst/files/include/.svn/entries
new file mode 100644
index 0000000..8288f2b
--- /dev/null
+++ b/package/boot/uboot-xburst/files/include/.svn/entries
@@ -0,0 +1,34 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/uboot-xburst/files/include
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-07T14:10:01.049177Z
+35034
+mirko
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+asm-mips
+dir
+
+configs
+dir
+
diff --git a/package/boot/uboot-xburst/files/include/asm-mips/.svn/entries b/package/boot/uboot-xburst/files/include/asm-mips/.svn/entries
new file mode 100644
index 0000000..2a61466
--- /dev/null
+++ b/package/boot/uboot-xburst/files/include/asm-mips/.svn/entries
@@ -0,0 +1,28 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/uboot-xburst/files/include/asm-mips
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-07T14:10:01.049177Z
+35034
+mirko
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
diff --git a/package/boot/uboot-xburst/files/include/configs/.svn/entries b/package/boot/uboot-xburst/files/include/configs/.svn/entries
new file mode 100644
index 0000000..52a7f07
--- /dev/null
+++ b/package/boot/uboot-xburst/files/include/configs/.svn/entries
@@ -0,0 +1,28 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/uboot-xburst/files/include/configs
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-07T14:10:01.049177Z
+35034
+mirko
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
diff --git a/package/boot/uboot-xburst/files/nand_spl/.svn/entries b/package/boot/uboot-xburst/files/nand_spl/.svn/entries
new file mode 100644
index 0000000..b02ad1e
--- /dev/null
+++ b/package/boot/uboot-xburst/files/nand_spl/.svn/entries
@@ -0,0 +1,31 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/uboot-xburst/files/nand_spl
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-07T14:10:01.049177Z
+35034
+mirko
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+board
+dir
+
diff --git a/package/boot/uboot-xburst/files/nand_spl/board/.svn/entries b/package/boot/uboot-xburst/files/nand_spl/board/.svn/entries
new file mode 100644
index 0000000..3aae273
--- /dev/null
+++ b/package/boot/uboot-xburst/files/nand_spl/board/.svn/entries
@@ -0,0 +1,37 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/uboot-xburst/files/nand_spl/board
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-07T14:10:01.049177Z
+35034
+mirko
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+nanonote
+dir
+
+sakc
+dir
+
+n516
+dir
+
diff --git a/package/boot/uboot-xburst/files/nand_spl/board/n516/.svn/entries b/package/boot/uboot-xburst/files/nand_spl/board/n516/.svn/entries
new file mode 100644
index 0000000..081f719
--- /dev/null
+++ b/package/boot/uboot-xburst/files/nand_spl/board/n516/.svn/entries
@@ -0,0 +1,28 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/uboot-xburst/files/nand_spl/board/n516
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-07T14:10:01.049177Z
+35034
+mirko
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
diff --git a/package/boot/uboot-xburst/files/nand_spl/board/nanonote/.svn/entries b/package/boot/uboot-xburst/files/nand_spl/board/nanonote/.svn/entries
new file mode 100644
index 0000000..5e23a35
--- /dev/null
+++ b/package/boot/uboot-xburst/files/nand_spl/board/nanonote/.svn/entries
@@ -0,0 +1,28 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/uboot-xburst/files/nand_spl/board/nanonote
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-07T14:10:01.049177Z
+35034
+mirko
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
diff --git a/package/boot/uboot-xburst/files/nand_spl/board/sakc/.svn/entries b/package/boot/uboot-xburst/files/nand_spl/board/sakc/.svn/entries
new file mode 100644
index 0000000..d7a0ad0
--- /dev/null
+++ b/package/boot/uboot-xburst/files/nand_spl/board/sakc/.svn/entries
@@ -0,0 +1,28 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/uboot-xburst/files/nand_spl/board/sakc
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-07T14:10:01.049177Z
+35034
+mirko
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
diff --git a/package/boot/uboot-xburst/patches/.svn/entries b/package/boot/uboot-xburst/patches/.svn/entries
new file mode 100644
index 0000000..352f1b4
--- /dev/null
+++ b/package/boot/uboot-xburst/patches/.svn/entries
@@ -0,0 +1,232 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/uboot-xburst/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-07T14:10:01.049177Z
+35034
+mirko
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+0004-add-more-boot-options-F1-F2-F3-F4-M-S.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+318bc9342da0200c534c0b1552a9c2d5
+2013-01-07T14:10:01.049177Z
+35034
+mirko
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+6931
+
+0005-add-nanonote-lcd-support.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+9e8ff8de93294556ae1855c647aa3b20
+2013-01-07T14:10:01.049177Z
+35034
+mirko
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+27030
+
+0001-qi_lb60-add-nand-spl-support.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+d3a431d733f776288d3a555a25581e94
+2013-01-07T14:10:01.049177Z
+35034
+mirko
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+27630
+
+0006-enable-silent-console.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+cda7306fbff5de64b84db2e0f5420c5e
+2013-01-07T14:10:01.049177Z
+35034
+mirko
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1788
+
+0003-add-mmc-support.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+c509ed47f09ab80e5ca3be62e6733000
+2013-01-07T14:10:01.049177Z
+35034
+mirko
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+47318
+
+0002-qi_lb60-add-software-usbboot-support.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+d400befeef1d1a82fe35fc586fa32061
+2013-01-07T14:10:01.049177Z
+35034
+mirko
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+22384
+
diff --git a/package/boot/uboot-xburst/patches/.svn/text-base/0001-qi_lb60-add-nand-spl-support.patch.svn-base b/package/boot/uboot-xburst/patches/.svn/text-base/0001-qi_lb60-add-nand-spl-support.patch.svn-base
new file mode 100644
index 0000000..e770243
--- /dev/null
+++ b/package/boot/uboot-xburst/patches/.svn/text-base/0001-qi_lb60-add-nand-spl-support.patch.svn-base
@@ -0,0 +1,894 @@
+From 0329cf7965956a5a7044827e0ce88ae8d5150e54 Mon Sep 17 00:00:00 2001
+From: Xiangfu <xiangfu@openmobilefree.net>
+Date: Fri, 12 Oct 2012 09:46:58 +0800
+Subject: [PATCH 1/6] qi_lb60: add nand spl support
+
+ The JZ4740 CPU can load 8KB from two different addresses:
+ 1. the normal area up to 8KB starting from NAND flash address 0x00000000
+ 2. the backup area up to 8KB starting from NAND flash address 0x00002000
+
+Signed-off-by: Xiangfu <xiangfu@openmobilefree.net>
+---
+ Makefile | 12 +++
+ arch/mips/cpu/xburst/Makefile | 7 +-
+ arch/mips/cpu/xburst/cpu.c | 4 +
+ arch/mips/cpu/xburst/jz4740.c | 82 +++++++----------
+ arch/mips/cpu/xburst/spl/Makefile | 47 ++++++++++
+ arch/mips/cpu/xburst/spl/start.S | 63 +++++++++++++
+ board/qi/qi_lb60/Makefile | 4 +
+ board/qi/qi_lb60/qi_lb60-spl.c | 30 +++++++
+ board/qi/qi_lb60/qi_lb60.c | 8 +-
+ board/qi/qi_lb60/u-boot-spl.lds | 61 +++++++++++++
+ drivers/mtd/nand/jz4740_nand.c | 39 ++++++++-
+ include/configs/qi_lb60.h | 175 ++++++++++++++++++-------------------
+ 12 files changed, 386 insertions(+), 146 deletions(-)
+ create mode 100644 arch/mips/cpu/xburst/spl/Makefile
+ create mode 100644 arch/mips/cpu/xburst/spl/start.S
+ create mode 100644 board/qi/qi_lb60/qi_lb60-spl.c
+ create mode 100644 board/qi/qi_lb60/u-boot-spl.lds
+
+diff --git a/Makefile b/Makefile
+index 34d9075..a22778e 100644
+--- a/Makefile
++++ b/Makefile
+@@ -393,6 +393,10 @@ ALL-y += $(obj)u-boot-nodtb-tegra.bin
+ endif
+ endif
+
++ifeq ($(CPU),xburst)
++ALL-y += $(obj)u-boot-xburst.bin
++endif
++
+ all: $(ALL-y) $(SUBDIR_EXAMPLES)
+
+ $(obj)u-boot.dtb: $(obj)u-boot
+@@ -506,6 +510,14 @@ $(obj)u-boot-nodtb-tegra.bin: $(obj)spl/u-boot-spl.bin $(obj)u-boot.bin
+ endif
+ endif
+
++ifeq ($(CPU),xburst)
++$(obj)u-boot-xburst.bin: $(obj)spl/u-boot-spl.bin $(obj)u-boot.bin
++ dd if=$(obj)spl/u-boot-spl.bin of=$(obj)spl/u-boot-pad.bin conv=sync bs=8192 count=1
++ dd if=$(obj)spl/u-boot-spl.bin of=$(obj)spl/u-boot-pad.bin conv=sync,notrunc oflag=append bs=8192 count=1
++ tr '\0' '\377' < /dev/zero | dd of=$(obj)spl/u-boot-pad.bin conv=sync,notrunc oflag=append bs=16384 count=1
++ cat $(obj)spl/u-boot-pad.bin u-boot.bin > $@
++endif
++
+ ifeq ($(CONFIG_SANDBOX),y)
+ GEN_UBOOT = \
+ cd $(LNDIR) && $(CC) $(SYMS) -T $(obj)u-boot.lds \
+diff --git a/arch/mips/cpu/xburst/Makefile b/arch/mips/cpu/xburst/Makefile
+index b1f2ae4..ec35e55 100644
+--- a/arch/mips/cpu/xburst/Makefile
++++ b/arch/mips/cpu/xburst/Makefile
+@@ -24,9 +24,12 @@ include $(TOPDIR)/config.mk
+
+ LIB = $(obj)lib$(CPU).o
+
++COBJS-y = cpu.o jz_serial.o
++
++ifneq ($(CONFIG_SPL_BUILD),y)
+ START = start.o
+-SOBJS-y =
+-COBJS-y = cpu.o timer.o jz_serial.o
++COBJS-y += timer.o
++endif
+
+ COBJS-$(CONFIG_JZ4740) += jz4740.o
+
+diff --git a/arch/mips/cpu/xburst/cpu.c b/arch/mips/cpu/xburst/cpu.c
+index ddcbfaa..1432838 100644
+--- a/arch/mips/cpu/xburst/cpu.c
++++ b/arch/mips/cpu/xburst/cpu.c
+@@ -42,6 +42,8 @@
+ : \
+ : "i" (op), "R" (*(unsigned char *)(addr)))
+
++#ifndef CONFIG_SPL_BUILD
++
+ void __attribute__((weak)) _machine_restart(void)
+ {
+ struct jz4740_wdt *wdt = (struct jz4740_wdt *)JZ4740_WDT_BASE;
+@@ -109,6 +111,8 @@ void invalidate_dcache_range(ulong start_addr, ulong stop)
+ cache_op(Hit_Invalidate_D, addr);
+ }
+
++#endif
++
+ void flush_icache_all(void)
+ {
+ u32 addr, t = 0;
+diff --git a/arch/mips/cpu/xburst/jz4740.c b/arch/mips/cpu/xburst/jz4740.c
+index c0b9817..8816aa3 100644
+--- a/arch/mips/cpu/xburst/jz4740.c
++++ b/arch/mips/cpu/xburst/jz4740.c
+@@ -32,31 +32,19 @@ int disable_interrupts(void)
+ return 0;
+ }
+
+-/*
+- * PLL output clock = EXTAL * NF / (NR * NO)
+- * NF = FD + 2, NR = RD + 2
+- * NO = 1 (if OD = 0), NO = 2 (if OD = 1 or 2), NO = 4 (if OD = 3)
+- */
+ void pll_init(void)
+ {
+ struct jz4740_cpm *cpm = (struct jz4740_cpm *)JZ4740_CPM_BASE;
+
+- register unsigned int cfcr, plcr1;
+- int n2FR[33] = {
+- 0, 0, 1, 2, 3, 0, 4, 0, 5, 0, 0, 0, 6, 0, 0, 0,
+- 7, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0,
+- 9
+- };
+- int div[5] = {1, 3, 3, 3, 3}; /* divisors of I:S:P:L:M */
+- int nf, pllout2;
++ register unsigned int cfcr, plcr;
++ unsigned int nf, pllout2;
+
+ cfcr = CPM_CPCCR_CLKOEN |
+- CPM_CPCCR_PCS |
+- (n2FR[div[0]] << CPM_CPCCR_CDIV_BIT) |
+- (n2FR[div[1]] << CPM_CPCCR_HDIV_BIT) |
+- (n2FR[div[2]] << CPM_CPCCR_PDIV_BIT) |
+- (n2FR[div[3]] << CPM_CPCCR_MDIV_BIT) |
+- (n2FR[div[4]] << CPM_CPCCR_LDIV_BIT);
++ (0 << CPM_CPCCR_CDIV_BIT) |
++ (2 << CPM_CPCCR_HDIV_BIT) |
++ (2 << CPM_CPCCR_PDIV_BIT) |
++ (2 << CPM_CPCCR_MDIV_BIT) |
++ (2 << CPM_CPCCR_LDIV_BIT);
+
+ pllout2 = (cfcr & CPM_CPCCR_PCS) ?
+ CONFIG_SYS_CPU_SPEED : (CONFIG_SYS_CPU_SPEED / 2);
+@@ -65,15 +53,18 @@ void pll_init(void)
+ writel(pllout2 / 48000000 - 1, &cpm->uhccdr);
+
+ nf = CONFIG_SYS_CPU_SPEED * 2 / CONFIG_SYS_EXTAL;
+- plcr1 = ((nf - 2) << CPM_CPPCR_PLLM_BIT) | /* FD */
++ plcr = ((nf - 2) << CPM_CPPCR_PLLM_BIT) | /* FD */
+ (0 << CPM_CPPCR_PLLN_BIT) | /* RD=0, NR=2 */
+ (0 << CPM_CPPCR_PLLOD_BIT) | /* OD=0, NO=1 */
+- (0x20 << CPM_CPPCR_PLLST_BIT) | /* PLL stable time */
++ (0x32 << CPM_CPPCR_PLLST_BIT) | /* PLL stable time */
+ CPM_CPPCR_PLLEN; /* enable PLL */
+
+ /* init PLL */
+ writel(cfcr, &cpm->cpccr);
+- writel(plcr1, &cpm->cppcr);
++ writel(plcr, &cpm->cppcr);
++
++ while (!(readl(&cpm->cppcr) & CPM_CPPCR_PLLS))
++ ;
+ }
+
+ void sdram_init(void)
+@@ -92,26 +83,12 @@ void sdram_init(void)
+ 2 << EMC_DMCR_TCL_BIT /* CAS latency is 3 */
+ };
+
+- int div[] = {1, 2, 3, 4, 6, 8, 12, 16, 24, 32};
+-
+ cpu_clk = CONFIG_SYS_CPU_SPEED;
+- mem_clk = cpu_clk * div[__cpm_get_cdiv()] / div[__cpm_get_mdiv()];
++ mem_clk = 84000000;
+
+ writel(0, &emc->bcr); /* Disable bus release */
+ writew(0, &emc->rtcsr); /* Disable clock for counting */
+
+- /* Fault DMCR value for mode register setting*/
+-#define SDRAM_ROW0 11
+-#define SDRAM_COL0 8
+-#define SDRAM_BANK40 0
+-
+- dmcr0 = ((SDRAM_ROW0 - 11) << EMC_DMCR_RA_BIT) |
+- ((SDRAM_COL0 - 8) << EMC_DMCR_CA_BIT) |
+- (SDRAM_BANK40 << EMC_DMCR_BA_BIT) |
+- (SDRAM_BW16 << EMC_DMCR_BW_BIT) |
+- EMC_DMCR_EPIN |
+- cas_latency_dmcr[((SDRAM_CASL == 3) ? 1 : 0)];
+-
+ /* Basic DMCR value */
+ dmcr = ((SDRAM_ROW - 11) << EMC_DMCR_RA_BIT) |
+ ((SDRAM_COL - 8) << EMC_DMCR_CA_BIT) |
+@@ -128,31 +105,31 @@ void sdram_init(void)
+ if (tmp > 11)
+ tmp = 11;
+ dmcr |= (tmp - 4) << EMC_DMCR_TRAS_BIT;
+- tmp = SDRAM_RCD / ns;
+
++ tmp = SDRAM_RCD / ns;
+ if (tmp > 3)
+ tmp = 3;
+ dmcr |= tmp << EMC_DMCR_RCD_BIT;
+- tmp = SDRAM_TPC / ns;
+
++ tmp = SDRAM_TPC / ns;
+ if (tmp > 7)
+ tmp = 7;
+ dmcr |= tmp << EMC_DMCR_TPC_BIT;
+- tmp = SDRAM_TRWL / ns;
+
++ tmp = SDRAM_TRWL / ns;
+ if (tmp > 3)
+ tmp = 3;
+ dmcr |= tmp << EMC_DMCR_TRWL_BIT;
+- tmp = (SDRAM_TRAS + SDRAM_TPC) / ns;
+
++ tmp = (SDRAM_TRAS + SDRAM_TPC) / ns;
+ if (tmp > 14)
+ tmp = 14;
+ dmcr |= ((tmp + 1) >> 1) << EMC_DMCR_TRC_BIT;
+
+ /* SDRAM mode value */
+- sdmode = EMC_SDMR_BT_SEQ |
+- EMC_SDMR_OM_NORMAL |
+- EMC_SDMR_BL_4 |
++ sdmode = EMC_SDMR_BT_SEQ |
++ EMC_SDMR_OM_NORMAL |
++ EMC_SDMR_BL_4 |
+ cas_latency_sdmr[((SDRAM_CASL == 3) ? 1 : 0)];
+
+ /* Stage 1. Precharge all banks by writing SDMR with DMCR.MRSET=0 */
+@@ -172,8 +149,8 @@ void sdram_init(void)
+ if (tmp > 0xff)
+ tmp = 0xff;
+ writew(tmp, &emc->rtcor);
++
+ writew(0, &emc->rtcnt);
+- /* Divisor is 64, CKO/64 */
+ writew(EMC_RTCSR_CKS_64, &emc->rtcsr);
+
+ /* Wait for number of auto-refresh cycles */
+@@ -182,13 +159,17 @@ void sdram_init(void)
+ ;
+
+ /* Stage 3. Mode Register Set */
++ dmcr0 = (11 << EMC_DMCR_RA_BIT) |
++ (8 << EMC_DMCR_CA_BIT) |
++ (0 << EMC_DMCR_BA_BIT) |
++ EMC_DMCR_EPIN |
++ (SDRAM_BW16 << EMC_DMCR_BW_BIT) |
++ cas_latency_dmcr[((SDRAM_CASL == 3) ? 1 : 0)];
+ writel(dmcr0 | EMC_DMCR_RFSH | EMC_DMCR_MRSET, &emc->dmcr);
+ writeb(0, JZ4740_EMC_SDMR0 | sdmode);
+
+ /* Set back to basic DMCR value */
+ writel(dmcr | EMC_DMCR_RFSH | EMC_DMCR_MRSET, &emc->dmcr);
+-
+- /* everything is ok now */
+ }
+
+ DECLARE_GLOBAL_DATA_PTR;
+@@ -232,9 +213,10 @@ void rtc_init(void)
+ phys_size_t initdram(int board_type)
+ {
+ struct jz4740_emc *emc = (struct jz4740_emc *)JZ4740_EMC_BASE;
+- u32 dmcr;
+- u32 rows, cols, dw, banks;
+- ulong size;
++
++ unsigned int dmcr;
++ unsigned int rows, cols, dw, banks;
++ unsigned long size;
+
+ dmcr = readl(&emc->dmcr);
+ rows = 11 + ((dmcr & EMC_DMCR_RA_MASK) >> EMC_DMCR_RA_BIT);
+diff --git a/arch/mips/cpu/xburst/spl/Makefile b/arch/mips/cpu/xburst/spl/Makefile
+new file mode 100644
+index 0000000..f45e8c8
+--- /dev/null
++++ b/arch/mips/cpu/xburst/spl/Makefile
+@@ -0,0 +1,47 @@
++#
++# Copyright (C) 2011 Xiangfu Liu <xiangfu@openmobilefree.net>
++#
++# See file CREDITS for list of people who contributed to this
++# project.
++#
++# 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 of
++# the License, 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; if not, write to the Free Software
++# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++# MA 02111-1307 USA
++#
++
++include $(TOPDIR)/config.mk
++
++LIB = $(obj)lib$(CPU).o
++
++START = start.o
++SOBJS-y =
++COBJS-y =
++
++SRCS := $(START:.o=.S) $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c)
++OBJS := $(addprefix $(obj),$(SOBJS-y) $(COBJS-y))
++START := $(addprefix $(obj),$(START))
++
++all: $(obj).depend $(START) $(LIB)
++
++$(LIB): $(OBJS)
++ $(call cmd_link_o_target, $(OBJS))
++
++#########################################################################
++
++# defines $(obj).depend target
++include $(SRCTREE)/rules.mk
++
++sinclude $(obj).depend
++
++#########################################################################
+diff --git a/arch/mips/cpu/xburst/spl/start.S b/arch/mips/cpu/xburst/spl/start.S
+new file mode 100644
+index 0000000..e31c4c8
+--- /dev/null
++++ b/arch/mips/cpu/xburst/spl/start.S
+@@ -0,0 +1,63 @@
++/*
++ * Copyright (c) 2010 Xiangfu Liu <xiangfu@openmobilefree.net>
++ *
++ * See file CREDITS for list of people who contributed to this
++ * project.
++ *
++ * 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 3 of
++ * the License, 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; if not, write to the Free Software
++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ * MA 02111-1307 USA
++ */
++
++#include <config.h>
++#include <version.h>
++#include <asm/regdef.h>
++#include <asm/mipsregs.h>
++#include <asm/addrspace.h>
++#include <asm/cacheops.h>
++
++#include <asm/jz4740.h>
++
++ .set noreorder
++
++ .globl _start
++ .text
++_start:
++ .word JZ4740_NANDBOOT_CFG /* fetched during NAND Boot */
++reset:
++ /*
++ * STATUS register
++ * CU0=UM=EXL=IE=0, BEV=ERL=1, IP2~7=1
++ */
++ li t0, 0x0040FC04
++ mtc0 t0, CP0_STATUS
++ /*
++ * CAUSE register
++ * IV=1, use the specical interrupt vector (0x200)
++ */
++ li t1, 0x00800000
++ mtc0 t1, CP0_CAUSE
++
++ bal 1f
++ nop
++ .word _GLOBAL_OFFSET_TABLE_
++1:
++ move gp, ra
++ lw t1, 0(ra)
++ move gp, t1
++
++ la sp, 0x80004000
++ la t9, nand_spl_boot
++ j t9
++ nop
+diff --git a/board/qi/qi_lb60/Makefile b/board/qi/qi_lb60/Makefile
+index 5dae11b..e399246 100644
+--- a/board/qi/qi_lb60/Makefile
++++ b/board/qi/qi_lb60/Makefile
+@@ -22,7 +22,11 @@ include $(TOPDIR)/config.mk
+
+ LIB = $(obj)lib$(BOARD).o
+
++ifeq ($(CONFIG_SPL_BUILD),y)
++COBJS := $(BOARD)-spl.o
++else
+ COBJS := $(BOARD).o
++endif
+
+ SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c)
+ OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS))
+diff --git a/board/qi/qi_lb60/qi_lb60-spl.c b/board/qi/qi_lb60/qi_lb60-spl.c
+new file mode 100644
+index 0000000..3fe3fa3
+--- /dev/null
++++ b/board/qi/qi_lb60/qi_lb60-spl.c
+@@ -0,0 +1,30 @@
++/*
++ * Authors: Xiangfu Liu <xiangfu@openmobilefree.cc>
++ *
++ * 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
++ * 3 of the License, or (at your option) any later version.
++ */
++
++#include <common.h>
++#include <nand.h>
++#include <asm/io.h>
++#include <asm/jz4740.h>
++
++void nand_spl_boot(void)
++{
++ __gpio_as_sdram_16bit_4720();
++ __gpio_as_uart0();
++ __gpio_jtag_to_uart0();
++
++ serial_init();
++
++ pll_init();
++ sdram_init();
++
++ nand_init();
++
++ puts("\nQi LB60 SPL: Starting U-Boot ...\n");
++ nand_boot();
++}
+diff --git a/board/qi/qi_lb60/qi_lb60.c b/board/qi/qi_lb60/qi_lb60.c
+index d975209..3bd4e2f 100644
+--- a/board/qi/qi_lb60/qi_lb60.c
++++ b/board/qi/qi_lb60/qi_lb60.c
+@@ -1,5 +1,5 @@
+ /*
+- * Authors: Xiangfu Liu <xiangfu@sharism.cc>
++ * Authors: Xiangfu Liu <xiangfu@openmobilefree.net>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+@@ -97,8 +97,10 @@ int board_early_init_f(void)
+ /* U-Boot common routines */
+ int checkboard(void)
+ {
+- printf("Board: Qi LB60 (Ingenic XBurst Jz4740 SoC, Speed %ld MHz)\n",
+- gd->cpu_clk / 1000000);
++ printf("Board: Qi LB60 (Ingenic XBurst Jz4740 SoC)\n");
++ printf(" CPU: %ld\n", gd->cpu_clk);
++ printf(" MEM: %ld\n", gd->mem_clk);
++ printf(" DEV: %ld\n", gd->dev_clk);
+
+ return 0;
+ }
+diff --git a/board/qi/qi_lb60/u-boot-spl.lds b/board/qi/qi_lb60/u-boot-spl.lds
+new file mode 100644
+index 0000000..930537f
+--- /dev/null
++++ b/board/qi/qi_lb60/u-boot-spl.lds
+@@ -0,0 +1,61 @@
++/*
++ * (C) Copyright 2012 Xiangfu Liu <xiangfu@openmobilefree.net>
++ *
++ * 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 of
++ * the License, 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; if not, write to the Free Software
++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ * MA 02111-1307 USA
++ */
++
++OUTPUT_FORMAT("elf32-tradlittlemips", "elf32-tradlittlemips", "elf32-tradlittlemips")
++
++OUTPUT_ARCH(mips)
++ENTRY(_start)
++SECTIONS
++{
++ . = 0x80000000;
++ . = ALIGN(4);
++ .text :
++ {
++ *(.text)
++ }
++
++ . = ALIGN(4);
++ .rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
++
++ . = ALIGN(4);
++ .data : { *(.data) }
++
++ . = ALIGN(4);
++ .sdata : { *(.sdata) }
++
++ _gp = ALIGN(16);
++
++ __got_start = .;
++ .got : { *(.got) }
++ __got_end = .;
++
++ . = .;
++ __u_boot_cmd_start = .;
++ .u_boot_cmd : { *(.u_boot_cmd) }
++ __u_boot_cmd_end = .;
++
++ uboot_end_data = .;
++ num_got_entries = (__got_end - __got_start) >> 2;
++
++ . = ALIGN(4);
++ .sbss : { *(.sbss) }
++ .bss : { *(.bss) }
++ uboot_end = .;
++}
++ASSERT(uboot_end <= 0x80002000, "NAND bootstrap too big");
+diff --git a/drivers/mtd/nand/jz4740_nand.c b/drivers/mtd/nand/jz4740_nand.c
+index 3ec34f3..24a4921 100644
+--- a/drivers/mtd/nand/jz4740_nand.c
++++ b/drivers/mtd/nand/jz4740_nand.c
+@@ -15,6 +15,9 @@
+ #include <asm/io.h>
+ #include <asm/jz4740.h>
+
++#ifdef CONFIG_SPL_BUILD
++#define printf(s) puts(s)
++#endif
+ #define JZ_NAND_DATA_ADDR ((void __iomem *)0xB8000000)
+ #define JZ_NAND_CMD_ADDR (JZ_NAND_DATA_ADDR + 0x8000)
+ #define JZ_NAND_ADDR_ADDR (JZ_NAND_DATA_ADDR + 0x10000)
+@@ -176,7 +179,7 @@ static int jz_nand_rs_correct_data(struct mtd_info *mtd, u_char *dat,
+ for (k = 0; k < 9; k++)
+ writeb(read_ecc[k], &emc->nfpar[k]);
+ }
+- /* Set PRDY */
++
+ writel(readl(&emc->nfecr) | EMC_NFECR_PRDY, &emc->nfecr);
+
+ /* Wait for completion */
+@@ -184,7 +187,7 @@ static int jz_nand_rs_correct_data(struct mtd_info *mtd, u_char *dat,
+ status = readl(&emc->nfints);
+ } while (!(status & EMC_NFINTS_DECF));
+
+- /* disable ecc */
++ /* Disable ECC */
+ writel(readl(&emc->nfecr) & ~EMC_NFECR_ECCE, &emc->nfecr);
+
+ /* Check decoding */
+@@ -192,7 +195,7 @@ static int jz_nand_rs_correct_data(struct mtd_info *mtd, u_char *dat,
+ return 0;
+
+ if (status & EMC_NFINTS_UNCOR) {
+- printf("uncorrectable ecc\n");
++ printf("JZ4740 uncorrectable ECC\n");
+ return -1;
+ }
+
+@@ -230,6 +233,32 @@ static int jz_nand_rs_correct_data(struct mtd_info *mtd, u_char *dat,
+ return errcnt;
+ }
+
++#ifdef CONFIG_SPL_BUILD
++static void jz_nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
++{
++ int i;
++ struct nand_chip *this = mtd->priv;
++
++#if (JZ4740_NANDBOOT_CFG == JZ4740_NANDBOOT_B16R3) || \
++ (JZ4740_NANDBOOT_CFG == JZ4740_NANDBOOT_B16R2)
++ for (i = 0; i < len; i += 2)
++ buf[i] = readw(this->IO_ADDR_R);
++#elif (JZ4740_NANDBOOT_CFG == JZ4740_NANDBOOT_B8R3) || \
++ (JZ4740_NANDBOOT_CFG == JZ4740_NANDBOOT_B8R2)
++ for (i = 0; i < len; i++)
++ buf[i] = readb(this->IO_ADDR_R);
++#else
++ #error JZ4740_NANDBOOT_CFG not defined or wrong
++#endif
++}
++
++static uint8_t jz_nand_read_byte(struct mtd_info *mtd)
++{
++ struct nand_chip *this = mtd->priv;
++ return readb(this->IO_ADDR_R);
++}
++#endif
++
+ /*
+ * Main initialization routine
+ */
+@@ -254,6 +283,10 @@ int board_nand_init(struct nand_chip *nand)
+ nand->ecc.size = CONFIG_SYS_NAND_ECCSIZE;
+ nand->ecc.bytes = CONFIG_SYS_NAND_ECCBYTES;
+ nand->ecc.layout = &qi_lb60_ecclayout_2gb;
++#ifdef CONFIG_SPL_BUILD
++ nand->read_byte = jz_nand_read_byte;
++ nand->read_buf = jz_nand_read_buf;
++#endif
+ nand->chip_delay = 50;
+ nand->options = NAND_USE_FLASH_BBT;
+
+diff --git a/include/configs/qi_lb60.h b/include/configs/qi_lb60.h
+index 4bb5bbc..7bff444 100644
+--- a/include/configs/qi_lb60.h
++++ b/include/configs/qi_lb60.h
+@@ -1,5 +1,5 @@
+ /*
+- * Authors: Xiangfu Liu <xiangfu.z@gmail.com>
++ * Authors: Xiangfu Liu <xiangfu@openmobilefree.net>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+@@ -14,7 +14,6 @@
+ #define CONFIG_SYS_LITTLE_ENDIAN
+ #define CONFIG_JZSOC /* Jz SoC */
+ #define CONFIG_JZ4740 /* Jz4740 SoC */
+-#define CONFIG_NAND_JZ4740
+
+ #define CONFIG_SYS_CPU_SPEED 336000000 /* CPU clock: 336 MHz */
+ #define CONFIG_SYS_EXTAL 12000000 /* EXTAL freq: 12 MHz */
+@@ -24,24 +23,43 @@
+ #define CONFIG_SYS_UART_BASE JZ4740_UART0_BASE /* Base of the UART channel */
+ #define CONFIG_BAUDRATE 57600
+
++#define CONFIG_BOOTP_MASK (CONFIG_BOOTP_DEFAUL)
++#define CONFIG_BOOTDELAY 0
++#define CONFIG_BOOTARGS "mem=32M console=tty0 console=ttyS0,57600n8 ubi.mtd=2 rootfstype=ubifs root=ubi0:rootfs rw rootwait"
++#define CONFIG_BOOTCOMMAND "nand read 0x80600000 0x400000 0x280000;bootm"
++
++/*
++ * Miscellaneous configurable options
++ */
++#define CONFIG_SYS_SDRAM_BASE 0x80000000 /* Cached addr */
++#define CONFIG_SYS_INIT_SP_OFFSET 0x400000
++#define CONFIG_SYS_LOAD_ADDR 0x80600000
++#define CONFIG_SYS_MEMTEST_START 0x80100000
++#define CONFIG_SYS_MEMTEST_END 0x80A00000
++#define CONFIG_SYS_TEXT_BASE 0x80100000
++#define CONFIG_SYS_MONITOR_BASE CONFIG_SYS_TEXT_BASE
++
++#define CONFIG_SYS_MALLOC_LEN (4 * 1024 * 1024)
++#define CONFIG_SYS_BOOTPARAMS_LEN (128 * 1024)
++
++#define CONFIG_SYS_CBSIZE 256 /* Console I/O Buffer Size */
++#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE + sizeof(CONFIG_SYS_PROMPT) + 16)
++
++#define CONFIG_SYS_LONGHELP
++#define CONFIG_SYS_MAXARGS 16
++#define CONFIG_SYS_PROMPT "NanoNote# "
++
+ #define CONFIG_SKIP_LOWLEVEL_INIT
+ #define CONFIG_BOARD_EARLY_INIT_F
+ #define CONFIG_SYS_NO_FLASH
+ #define CONFIG_SYS_FLASH_BASE 0 /* init flash_base as 0 */
+-#define CONFIG_ENV_OVERWRITE
+-
+-#define CONFIG_BOOTP_MASK (CONFIG_BOOTP_DEFAUL)
+-#define CONFIG_BOOTDELAY 0
+-#define CONFIG_BOOTARGS "mem=32M console=tty0 console=ttyS0,57600n8 ubi.mtd=2 rootfstype=ubifs root=ubi0:rootfs rw rootwait"
+-#define CONFIG_BOOTCOMMAND "nand read 0x80600000 0x400000 0x200000;bootm"
+
+ /*
+- * Command line configuration.
++ * Command line configuration
+ */
+ #define CONFIG_CMD_BOOTD /* bootd */
+ #define CONFIG_CMD_CONSOLE /* coninfo */
+ #define CONFIG_CMD_ECHO /* echo arguments */
+-
+ #define CONFIG_CMD_LOADB /* loadb */
+ #define CONFIG_CMD_LOADS /* loads */
+ #define CONFIG_CMD_MEMORY /* md mm nm mw cp cmp crc base loop mtest */
+@@ -58,45 +76,16 @@
+ #define CONFIG_LOADS_ECHO 1 /* echo on for serial download */
+
+ /*
+- * Miscellaneous configurable options
+- */
+-#define CONFIG_SYS_MAXARGS 16
+-#define CONFIG_SYS_LONGHELP
+-#define CONFIG_SYS_PROMPT "NanoNote# "
+-#define CONFIG_SYS_CBSIZE 256 /* Console I/O Buffer Size */
+-#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE + sizeof(CONFIG_SYS_PROMPT) + 16)
+-
+-#define CONFIG_SYS_MALLOC_LEN (4 * 1024 * 1024)
+-#define CONFIG_SYS_BOOTPARAMS_LEN (128 * 1024)
+-
+-#define CONFIG_SYS_SDRAM_BASE 0x80000000 /* Cached addr */
+-#define CONFIG_SYS_INIT_SP_OFFSET 0x400000
+-#define CONFIG_SYS_LOAD_ADDR 0x80600000
+-#define CONFIG_SYS_MEMTEST_START 0x80100000
+-#define CONFIG_SYS_MEMTEST_END 0x80800000
+-
+-/*
+- * Environment
++ * NAND driver configuration
+ */
+-#define CONFIG_ENV_IS_IN_NAND /* use NAND for environment vars */
+-
+-#define CONFIG_SYS_NAND_5_ADDR_CYCLE
+-/*
+- * if board nand flash is 1GB, set to 1
+- * if board nand flash is 2GB, set to 2
+- * for change the PAGE_SIZE and BLOCK_SIZE
+- * will delete when there is no 1GB flash
+- */
+-#define NANONOTE_NAND_SIZE 2
+-
+-#define CONFIG_SYS_NAND_PAGE_SIZE (2048 * NANONOTE_NAND_SIZE)
+-#define CONFIG_SYS_NAND_BLOCK_SIZE (256 * NANONOTE_NAND_SIZE << 10)
+-/* nand bad block was marked at this page in a block, start from 0 */
++#define CONFIG_NAND_JZ4740
++#define CONFIG_SYS_NAND_PAGE_SIZE 4096
++#define CONFIG_SYS_NAND_BLOCK_SIZE (512 << 10)
++/* NAND bad block was marked at this page in a block, start from 0 */
+ #define CONFIG_SYS_NAND_BADBLOCK_PAGE 127
+ #define CONFIG_SYS_NAND_PAGE_COUNT 128
+ #define CONFIG_SYS_NAND_BAD_BLOCK_POS 0
+-/* ECC offset position in oob area, default value is 6 if it isn't defined */
+-#define CONFIG_SYS_NAND_ECC_POS (6 * NANONOTE_NAND_SIZE)
++#define CONFIG_SYS_NAND_ECC_POS 12
+ #define CONFIG_SYS_NAND_ECCSIZE 512
+ #define CONFIG_SYS_NAND_ECCBYTES 9
+ #define CONFIG_SYS_NAND_ECCPOS \
+@@ -115,10 +104,9 @@
+ #define CONFIG_SYS_ONENAND_BASE CONFIG_SYS_NAND_BASE
+ #define CONFIG_SYS_MAX_NAND_DEVICE 1
+ #define CONFIG_SYS_NAND_SELECT_DEVICE 1 /* nand driver supports mutipl.*/
+-#define CONFIG_NAND_SPL_TEXT_BASE 0x80000000
+
+ /*
+- * IPL (Initial Program Loader, integrated inside CPU)
++ * IPL (Initial Program Loader, integrated inside Ingenic Xburst JZ4740 CPU)
+ * Will load first 8k from NAND (SPL) into cache and execute it from there.
+ *
+ * SPL (Secondary Program Loader)
+@@ -130,77 +118,88 @@
+ * NUB (NAND U-Boot)
+ * This NAND U-Boot (NUB) is a special U-Boot version which can be started
+ * from RAM. Therefore it mustn't (re-)configure the SDRAM controller.
+- *
+ */
++
++/*
++ * NAND SPL configuration
++ */
++#define CONFIG_SPL
++#define CONFIG_SPL_LIBGENERIC_SUPPORT
++#define CONFIG_SPL_LIBCOMMON_SUPPORT
++#define CONFIG_SPL_NAND_LOAD
++#define CONFIG_SPL_NAND_SIMPLE
++#define CONFIG_SPL_NAND_SUPPORT
++#define CONFIG_SPL_TEXT_BASE 0x80000000
++#define CONFIG_SPL_START_S_PATH "arch/mips/cpu/xburst/spl"
++
++#define CONFIG_SYS_NAND_5_ADDR_CYCLE
++#define CONFIG_SYS_NAND_HW_ECC_OOBFIRST
++#define JZ4740_NANDBOOT_CFG JZ4740_NANDBOOT_B8R3
++
+ #define CONFIG_SYS_NAND_U_BOOT_DST 0x80100000 /* Load NUB to this addr */
+ #define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_NAND_U_BOOT_DST
+-/* Start NUB from this addr*/
++ /* Start NUB from this addr */
++#define CONFIG_SYS_NAND_U_BOOT_OFFS (32 << 10) /* Offset of NUB */
++#define CONFIG_SYS_NAND_U_BOOT_SIZE (256 << 10) /* Size of NUB */
+
+ /*
+- * Define the partitioning of the NAND chip (only RAM U-Boot is needed here)
++ * Environment configuration
+ */
+-#define CONFIG_SYS_NAND_U_BOOT_OFFS (256 << 10) /* Offset to RAM U-Boot image */
+-#define CONFIG_SYS_NAND_U_BOOT_SIZE (512 << 10) /* Size of RAM U-Boot image */
+-
++#define CONFIG_ENV_OVERWRITE
++#define CONFIG_ENV_IS_IN_NAND
+ #define CONFIG_ENV_SIZE (4 << 10)
+ #define CONFIG_ENV_OFFSET \
+ (CONFIG_SYS_NAND_BLOCK_SIZE + CONFIG_SYS_NAND_U_BOOT_SIZE)
+ #define CONFIG_ENV_OFFSET_REDUND \
+ (CONFIG_ENV_OFFSET + CONFIG_SYS_NAND_BLOCK_SIZE)
+
+-#define CONFIG_SYS_TEXT_BASE 0x80100000
+-#define CONFIG_SYS_MONITOR_BASE CONFIG_SYS_TEXT_BASE
+-
+ /*
+- * SDRAM Info.
++ * CPU cache configuration
+ */
+-#define CONFIG_NR_DRAM_BANKS 1
++#define CONFIG_SYS_DCACHE_SIZE 16384
++#define CONFIG_SYS_ICACHE_SIZE 16384
++#define CONFIG_SYS_CACHELINE_SIZE 32
+
+ /*
+- * Cache Configuration
++ * SDRAM configuration
+ */
+-#define CONFIG_SYS_DCACHE_SIZE 16384
+-#define CONFIG_SYS_ICACHE_SIZE 16384
+-#define CONFIG_SYS_CACHELINE_SIZE 32
++#define CONFIG_NR_DRAM_BANKS 1
++
++#define SDRAM_BW16 1 /* Data bus width: 0-32bit, 1-16bit */
++#define SDRAM_BANK4 1 /* Banks each chip: 0-2bank, 1-4bank */
++#define SDRAM_ROW 13 /* Row address: 11 to 13 */
++#define SDRAM_COL 9 /* Column address: 8 to 12 */
++#define SDRAM_CASL 2 /* CAS latency: 2 or 3 */
++#define SDRAM_TRAS 45 /* RAS# Active Time */
++#define SDRAM_RCD 20 /* RAS# to CAS# Delay */
++#define SDRAM_TPC 20 /* RAS# Precharge Time */
++#define SDRAM_TRWL 7 /* Write Latency Time */
++#define SDRAM_TREF 15625 /* Refresh period: 8192 cycles/64ms */
+
+ /*
+- * GPIO definition
++ * GPIO configuration
+ */
+-#define GPIO_LCD_CS (2 * 32 + 21)
+-#define GPIO_AMP_EN (3 * 32 + 4)
++#define GPIO_LCD_CS (2 * 32 + 21)
++#define GPIO_AMP_EN (3 * 32 + 4)
+
+-#define GPIO_SDPW_EN (3 * 32 + 2)
+-#define GPIO_SD_DETECT (3 * 32 + 0)
++#define GPIO_SDPW_EN (3 * 32 + 2)
++#define GPIO_SD_DETECT (3 * 32 + 0)
+
+-#define GPIO_BUZZ_PWM (3 * 32 + 27)
+-#define GPIO_USB_DETECT (3 * 32 + 28)
++#define GPIO_BUZZ_PWM (3 * 32 + 27)
++#define GPIO_USB_DETECT (3 * 32 + 28)
+
+-#define GPIO_AUDIO_POP (1 * 32 + 29)
+-#define GPIO_COB_TEST (1 * 32 + 30)
++#define GPIO_AUDIO_POP (1 * 32 + 29)
++#define GPIO_COB_TEST (1 * 32 + 30)
+
+ #define GPIO_KEYOUT_BASE (2 * 32 + 10)
+-#define GPIO_KEYIN_BASE (3 * 32 + 18)
+-#define GPIO_KEYIN_8 (3 * 32 + 26)
++#define GPIO_KEYIN_BASE (3 * 32 + 18)
++#define GPIO_KEYIN_8 (3 * 32 + 26)
+
+-#define GPIO_SD_CD_N GPIO_SD_DETECT /* SD Card insert detect */
++#define GPIO_SD_CD_N GPIO_SD_DETECT /* SD Card insert detect */
+ #define GPIO_SD_VCC_EN_N GPIO_SDPW_EN /* SD Card Power Enable */
+
+ #define SPEN GPIO_LCD_CS /* LCDCS :Serial command enable */
+ #define SPDA (2 * 32 + 22) /* LCDSCL:Serial command clock input */
+ #define SPCK (2 * 32 + 23) /* LCDSDA:Serial command data input */
+
+-/* SDRAM paramters */
+-#define SDRAM_BW16 1 /* Data bus width: 0-32bit, 1-16bit */
+-#define SDRAM_BANK4 1 /* Banks each chip: 0-2bank, 1-4bank */
+-#define SDRAM_ROW 13 /* Row address: 11 to 13 */
+-#define SDRAM_COL 9 /* Column address: 8 to 12 */
+-#define SDRAM_CASL 2 /* CAS latency: 2 or 3 */
+-
+-/* SDRAM Timings, unit: ns */
+-#define SDRAM_TRAS 45 /* RAS# Active Time */
+-#define SDRAM_RCD 20 /* RAS# to CAS# Delay */
+-#define SDRAM_TPC 20 /* RAS# Precharge Time */
+-#define SDRAM_TRWL 7 /* Write Latency Time */
+-#define SDRAM_TREF 15625 /* Refresh period: 8192 cycles/64ms */
+-
+ #endif
+--
+1.7.9.5
+
diff --git a/package/boot/uboot-xburst/patches/.svn/text-base/0002-qi_lb60-add-software-usbboot-support.patch.svn-base b/package/boot/uboot-xburst/patches/.svn/text-base/0002-qi_lb60-add-software-usbboot-support.patch.svn-base
new file mode 100644
index 0000000..feaf297
--- /dev/null
+++ b/package/boot/uboot-xburst/patches/.svn/text-base/0002-qi_lb60-add-software-usbboot-support.patch.svn-base
@@ -0,0 +1,916 @@
+From fa51192b912d296b8eec10f7d44c6c17eb1dd368 Mon Sep 17 00:00:00 2001
+From: Xiangfu <xiangfu@openmobilefree.net>
+Date: Fri, 12 Oct 2012 09:47:39 +0800
+Subject: [PATCH 2/6] qi_lb60: add software usbboot support
+
+ JZ4740 CPU have a internal ROM have such kind of code, that make
+ JZ4740 can boot from USB
+
+ usbboot.S can downloads user program from the USB port to internal
+ SRAM and branches to the internal SRAM to execute the program
+
+Signed-off-by: Xiangfu <xiangfu@openmobilefree.net>
+---
+ board/qi/qi_lb60/Makefile | 1 +
+ board/qi/qi_lb60/qi_lb60-spl.c | 20 +
+ board/qi/qi_lb60/usbboot.S | 838 ++++++++++++++++++++++++++++++++++++++++
+ 3 files changed, 859 insertions(+)
+ create mode 100644 board/qi/qi_lb60/usbboot.S
+
+diff --git a/board/qi/qi_lb60/Makefile b/board/qi/qi_lb60/Makefile
+index e399246..6dd8c6f 100644
+--- a/board/qi/qi_lb60/Makefile
++++ b/board/qi/qi_lb60/Makefile
+@@ -23,6 +23,7 @@ include $(TOPDIR)/config.mk
+ LIB = $(obj)lib$(BOARD).o
+
+ ifeq ($(CONFIG_SPL_BUILD),y)
++SOBJS := usbboot.o
+ COBJS := $(BOARD)-spl.o
+ else
+ COBJS := $(BOARD).o
+diff --git a/board/qi/qi_lb60/qi_lb60-spl.c b/board/qi/qi_lb60/qi_lb60-spl.c
+index 3fe3fa3..aea459c 100644
+--- a/board/qi/qi_lb60/qi_lb60-spl.c
++++ b/board/qi/qi_lb60/qi_lb60-spl.c
+@@ -12,6 +12,24 @@
+ #include <asm/io.h>
+ #include <asm/jz4740.h>
+
++#define KEY_U_OUT (32 * 2 + 16)
++#define KEY_U_IN (32 * 3 + 19)
++
++extern void usb_boot(void);
++
++static void check_usb_boot(void)
++{
++ __gpio_as_input(KEY_U_IN);
++ __gpio_enable_pull(KEY_U_IN);
++ __gpio_as_output(KEY_U_OUT);
++ __gpio_clear_pin(KEY_U_OUT);
++
++ if (!__gpio_get_pin(KEY_U_IN)) {
++ puts("[U] pressed, goto USBBOOT mode\n");
++ usb_boot();
++ }
++}
++
+ void nand_spl_boot(void)
+ {
+ __gpio_as_sdram_16bit_4720();
+@@ -23,6 +41,8 @@ void nand_spl_boot(void)
+ pll_init();
+ sdram_init();
+
++ check_usb_boot();
++
+ nand_init();
+
+ puts("\nQi LB60 SPL: Starting U-Boot ...\n");
+diff --git a/board/qi/qi_lb60/usbboot.S b/board/qi/qi_lb60/usbboot.S
+new file mode 100644
+index 0000000..c872266
+--- /dev/null
++++ b/board/qi/qi_lb60/usbboot.S
+@@ -0,0 +1,838 @@
++/*
++ * for jz4740 usb boot
++ *
++ * Copyright (c) 2009 Author: <jlwei@ingenic.cn>
++ *
++ * See file CREDITS for list of people who contributed to this
++ * project.
++ *
++ * 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 of
++ * the License, 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; if not, write to the Free Software
++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ * MA 02111-1307 USA
++ */
++ .set noreorder
++ .globl usb_boot
++ .text
++
++/*
++ * Both NAND and USB boot load data to D-Cache first, then transfer
++ * data from D-Cache to I-Cache, and jump to execute the code in I-Cache.
++ * So init caches first and then dispatch to a proper boot routine.
++ */
++
++.macro load_addr reg addr
++ li \reg, 0x80000000
++ addiu \reg, \reg, \addr
++ la $2, usbboot_begin
++ subu \reg, \reg, $2
++.endm
++
++usb_boot:
++ /* Initialize PLL: set ICLK to 84MHz and HCLK to 42MHz. */
++ la $9, 0xB0000000 /* CPCCR: Clock Control Register */
++ la $8, 0x42041110 /* I:S:M:P=1:2:2:2 */
++ sw $8, 0($9)
++
++ la $9, 0xB0000010 /* CPPCR: PLL Control Register */
++ la $8, 0x06000120 /* M=12 N=0 D=0 CLK=12*(M+2)/(N+2) */
++ sw $8, 0($9)
++
++ mtc0 $0, $26 /* CP0_ERRCTL, restore WST reset state */
++ nop
++
++ mtc0 $0, $16 /* CP0_CONFIG */
++ nop
++
++ /* Relocate code to beginning of the ram */
++
++ la $2, usbboot_begin
++ la $3, usbboot_end
++ li $4, 0x80000000
++
++1:
++ lw $5, 0($2)
++ sw $5, 0($4)
++ addiu $2, $2, 4
++ bne $2, $3, 1b
++ addiu $4, $4, 4
++
++ li $2, 0x80000000
++ ori $3, $2, 0
++ addiu $3, $3, usbboot_end
++ la $4, usbboot_begin
++ subu $3, $3, $4
++
++
++2:
++ cache 0x0, 0($2) /* Index_Invalidate_I */
++ cache 0x1, 0($2) /* Index_Writeback_Inv_D */
++ addiu $2, $2, 32
++ subu $4, $3, $2
++ bgtz $4, 2b
++ nop
++
++ load_addr $3, usb_boot_return
++
++ jr $3
++
++usbboot_begin:
++
++init_caches:
++ li $2, 3 /* cacheable for kseg0 access */
++ mtc0 $2, $16 /* CP0_CONFIG */
++ nop
++
++ li $2, 0x20000000 /* enable idx-store-data cache insn */
++ mtc0 $2, $26 /* CP0_ERRCTL */
++
++ ori $2, $28, 0 /* start address */
++ ori $3, $2, 0x3fe0 /* end address, total 16KB */
++ mtc0 $0, $28, 0 /* CP0_TAGLO */
++ mtc0 $0, $28, 1 /* CP0_DATALO */
++cache_clear_a_line:
++ cache 0x8, 0($2) /* Index_Store_Tag_I */
++ cache 0x9, 0($2) /* Index_Store_Tag_D */
++ bne $2, $3, cache_clear_a_line
++ addiu $2, $2, 32 /* increment CACHE_LINE_SIZE */
++
++ ori $2, $28, 0 /* start address */
++ ori $3, $2, 0x3fe0 /* end address, total 16KB */
++ la $4, 0x1ffff000 /* physical address and 4KB page mask */
++cache_alloc_a_line:
++ and $5, $2, $4
++ ori $5, $5, 1 /* V bit of the physical tag */
++ mtc0 $5, $28, 0 /* CP0_TAGLO */
++ cache 0x8, 0($2) /* Index_Store_Tag_I */
++ cache 0x9, 0($2) /* Index_Store_Tag_D */
++ bne $2, $3, cache_alloc_a_line
++ addiu $2, $2, 32 /* increment CACHE_LINE_SIZE */
++
++ nop
++ nop
++ nop
++ /*
++ * Transfer data from dcache to icache, then jump to icache.
++ * Input parameters:
++ * $19: data length in bytes
++ * $20: jump target address
++ */
++xfer_d2i:
++
++ ori $8, $20, 0
++ addu $9, $8, $19 /* total 16KB */
++
++1:
++ cache 0x0, 0($8) /* Index_Invalidate_I */
++ cache 0x1, 0($8) /* Index_Writeback_Inv_D */
++ bne $8, $9, 1b
++ addiu $8, $8, 32
++
++ /* flush write-buffer */
++ sync
++
++ /* Invalidate BTB */
++ mfc0 $8, $16, 7 /* CP0_CONFIG */
++ nop
++ ori $8, 2
++ mtc0 $8, $16, 7
++ nop
++
++ /* Overwrite config to disable ram initalisation */
++ li $2, 0xff
++ sb $2, 20($20)
++
++ jalr $20
++ nop
++
++icache_return:
++ /* User code can return to here after executing itself in
++ icache, by jumping to $31. */
++ b usb_boot_return
++ nop
++
++
++usb_boot_return:
++ /* Enable the USB PHY */
++ la $9, 0xB0000024 /* CPM_SCR */
++ lw $8, 0($9)
++ ori $8, 0x40 /* USBPHY_ENABLE */
++ sw $8, 0($9)
++
++ /* Initialize USB registers */
++ la $27, 0xb3040000 /* USB registers base address */
++
++ sb $0, 0x0b($27) /* INTRUSBE: disable common USB interrupts */
++ sh $0, 0x06($27) /* INTRINE: disable EPIN interrutps */
++ sh $0, 0x08($27) /* INTROUTE: disable EPOUT interrutps */
++
++ li $9, 0x61
++ sb $9, 0x01($27) /* POWER: HSENAB | SUSPENDM | SOFTCONN */
++
++ /* Initialize USB states */
++ li $22, 0 /* set EP0 to IDLE state */
++ li $23, 1 /* no data stage */
++
++ /* Main loop of polling the usb commands */
++usb_command_loop:
++ lbu $9, 0x0a($27) /* read INTRUSB */
++ andi $9, 0x04 /* check USB_INTR_RESET */
++ beqz $9, check_intr_ep0in
++ nop
++
++ /* 1. Handle USB reset interrupt */
++handle_reset_intr:
++ lbu $9, 0x01($27) /* read POWER */
++ andi $9, 0x10 /* test HS_MODE */
++ bnez $9, _usb_set_maxpktsize
++ li $9, 512 /* max packet size of HS mode */
++ li $9, 64 /* max packet size of FS mode */
++
++_usb_set_maxpktsize:
++ li $8, 1
++ sb $8, 0x0e($27) /* set INDEX 1 */
++
++ sh $9, 0x10($27) /* INMAXP */
++ sb $0, 0x13($27) /* INCSRH */
++ sh $9, 0x14($27) /* OUTMAXP */
++ sb $0, 0x17($27) /* OUTCSRH */
++
++_usb_flush_fifo:
++ li $8, 0x48 /* INCSR_CDT && INCSR_FF */
++ sb $8, 0x12($27) /* INCSR */
++ li $8, 0x90 /* OUTCSR_CDT && OUTCSR_FF */
++ sb $8, 0x16($27) /* OUTCSR */
++
++ li $22, 0 /* set EP0 to IDLE state */
++ li $23, 1 /* no data stage */
++
++ /* 2. Check and handle EP0 interrupt */
++check_intr_ep0in:
++ lhu $10, 0x02($27) /* read INTRIN */
++ andi $9, $10, 0x1 /* check EP0 interrupt */
++ beqz $9, check_intr_ep1in
++ nop
++
++handle_ep0_intr:
++ sb $0, 0x0e($27) /* set INDEX 0 */
++ lbu $11, 0x12($27) /* read CSR0 */
++
++ andi $9, $11, 0x04 /* check SENTSTALL */
++ beqz $9, _ep0_setupend
++ nop
++
++_ep0_sentstall:
++ andi $9, $11, 0xdb
++ sb $9, 0x12($27) /* clear SENDSTALL and SENTSTALL */
++ li $22, 0 /* set EP0 to IDLE state */
++
++_ep0_setupend:
++ andi $9, $11, 0x10 /* check SETUPEND */
++ beqz $9, ep0_idle_state
++ nop
++
++ ori $9, $11, 0x80
++ sb $9, 0x12($27) /* set SVDSETUPEND */
++ li $22, 0 /* set EP0 to IDLE state */
++
++ep0_idle_state:
++ bnez $22, ep0_tx_state
++ nop
++
++ /* 2.1 Handle EP0 IDLE state interrupt */
++ andi $9, $11, 0x01 /* check OUTPKTRDY */
++ beqz $9, check_intr_ep1in
++ nop
++
++ /* Read 8-bytes setup packet from the FIFO */
++ lw $25, 0x20($27) /* first word of setup packet */
++ lw $26, 0x20($27) /* second word of setup packet */
++
++ andi $9, $25, 0x60 /* bRequestType & USB_TYPE_MASK */
++ beqz $9, _ep0_std_req
++ nop
++
++ /* 2.1.1 Vendor-specific setup request */
++_ep0_vend_req:
++ li $22, 0 /* set EP0 to IDLE state */
++ li $23, 1 /* NoData = 1 */
++
++ andi $9, $25, 0xff00 /* check bRequest */
++ srl $9, $9, 8
++ beqz $9, __ep0_get_cpu_info
++ sub $8, $9, 0x1
++ beqz $8, __ep0_set_data_address
++ sub $8, $9, 0x2
++ beqz $8, __ep0_set_data_length
++ sub $8, $9, 0x3
++ beqz $8, __ep0_flush_caches
++ sub $8, $9, 0x4
++ beqz $8, __ep0_prog_start1
++ sub $8, $9, 0x5
++ beqz $8, __ep0_prog_start2
++ nop
++ b _ep0_idle_state_fini /* invalid request */
++ nop
++
++__ep0_get_cpu_info:
++ load_addr $20, cpu_info_data /* data pointer to transfer */
++ li $21, 8 /* bytes left to transfer */
++ li $22, 1 /* set EP0 to TX state */
++ li $23, 0 /* NoData = 0 */
++
++ b _ep0_idle_state_fini
++ nop
++
++__ep0_set_data_address:
++ li $9, 0xffff0000
++ and $9, $25, $9
++ andi $8, $26, 0xffff
++ or $20, $9, $8 /* data address of next transfer */
++
++ b _ep0_idle_state_fini
++ nop
++
++__ep0_set_data_length:
++ li $9, 0xffff0000
++ and $9, $25, $9
++ andi $8, $26, 0xffff
++ or $21, $9, $8 /* data length of next transfer */
++
++ li $9, 0x48 /* SVDOUTPKTRDY and DATAEND */
++ sb $9, 0x12($27) /* CSR0 */
++
++ /* We must write packet to FIFO before EP1-IN interrupt here. */
++ b handle_epin1_intr
++ nop
++
++__ep0_flush_caches:
++ /* Flush dcache and invalidate icache. */
++ li $8, 0x80000000
++ addi $9, $8, 0x3fe0 /* total 16KB */
++
++1:
++ cache 0x0, 0($8) /* Index_Invalidate_I */
++ cache 0x1, 0($8) /* Index_Writeback_Inv_D */
++ bne $8, $9, 1b
++ addiu $8, $8, 32
++
++ /* flush write-buffer */
++ sync
++
++ /* Invalidate BTB */
++ mfc0 $8, $16, 7 /* CP0_CONFIG */
++ nop
++ ori $8, 2
++ mtc0 $8, $16, 7
++ nop
++
++ b _ep0_idle_state_fini
++ nop
++
++__ep0_prog_start1:
++ li $9, 0x48 /* SVDOUTPKTRDY and DATAEND */
++ sb $9, 0x12($27) /* CSR0 */
++
++ li $9, 0xffff0000
++ and $9, $25, $9
++ andi $8, $26, 0xffff
++ or $20, $9, $8 /* target address */
++
++ b xfer_d2i
++ li $19, 0x2000 /* 16KB data length */
++
++__ep0_prog_start2:
++ li $9, 0x48 /* SVDOUTPKTRDY and DATAEND */
++ sb $9, 0x12($27) /* CSR0 */
++
++ li $9, 0xffff0000
++ and $9, $25, $9
++ andi $8, $26, 0xffff
++ or $20, $9, $8 /* target address */
++
++ jalr $20 /* jump, and place the return address in $31 */
++ nop
++
++__ep0_prog_start2_return:
++/* User code can return to here after executing itself, by jumping to $31 */
++ b usb_boot_return
++ nop
++
++ /* 2.1.2 Standard setup request */
++_ep0_std_req:
++ andi $12, $25, 0xff00 /* check bRequest */
++ srl $12, $12, 8
++ sub $9, $12, 0x05 /* check USB_REQ_SET_ADDRESS */
++ bnez $9, __ep0_req_set_config
++ nop
++
++ /* Handle USB_REQ_SET_ADDRESS */
++__ep0_req_set_addr:
++ srl $9, $25, 16 /* get wValue */
++ sb $9, 0x0($27) /* set FADDR */
++ li $23, 1 /* NoData = 1 */
++ b _ep0_idle_state_fini
++ nop
++
++__ep0_req_set_config:
++ sub $9, $12, 0x09 /* check USB_REQ_SET_CONFIGURATION */
++ bnez $9, __ep0_req_get_desc
++ nop
++
++ /* Handle USB_REQ_SET_CONFIGURATION */
++ li $23, 1 /* NoData = 1 */
++ b _ep0_idle_state_fini
++ nop
++
++__ep0_req_get_desc:
++ sub $9, $12, 0x06 /* check USB_REQ_GET_DESCRIPTOR */
++ bnez $9, _ep0_idle_state_fini
++ li $23, 1 /* NoData = 1 */
++
++ /* Handle USB_REQ_GET_DESCRIPTOR */
++ li $23, 0 /* NoData = 0 */
++
++ srl $9, $25, 24 /* wValue >> 8 */
++ sub $8, $9, 0x01 /* check USB_DT_DEVICE */
++ beqz $8, ___ep0_get_dev_desc
++ srl $21, $26, 16 /* get wLength */
++ sub $8, $9, 0x02 /* check USB_DT_CONFIG */
++ beqz $8, ___ep0_get_conf_desc
++ sub $8, $9, 0x03 /* check USB_DT_STRING */
++ beqz $8, ___ep0_get_string_desc
++ sub $8, $9, 0x06 /* check USB_DT_DEVICE_QUALIFIER */
++ beqz $8, ___ep0_get_dev_qualifier
++ nop
++ b _ep0_idle_state_fini
++ nop
++
++___ep0_get_dev_desc:
++ load_addr $20, device_desc /* data pointer */
++ li $22, 1 /* set EP0 to TX state */
++ sub $8, $21, 18
++ blez $8, _ep0_idle_state_fini /* wLength <= 18 */
++ nop
++ li $21, 18 /* max length of device_desc */
++ b _ep0_idle_state_fini
++ nop
++
++___ep0_get_dev_qualifier:
++ load_addr $20, dev_qualifier /* data pointer */
++ li $22, 1 /* set EP0 to TX state */
++ sub $8, $21, 10
++ blez $8, _ep0_idle_state_fini /* wLength <= 10 */
++ nop
++ li $21, 10 /* max length of dev_qualifier */
++ b _ep0_idle_state_fini
++ nop
++
++___ep0_get_conf_desc:
++ load_addr $20, config_desc_fs /* data pointer of FS mode */
++ lbu $8, 0x01($27) /* read POWER */
++ andi $8, 0x10 /* test HS_MODE */
++ beqz $8, ___ep0_get_conf_desc2
++ nop
++ load_addr $20, config_desc_hs /* data pointer of HS mode */
++
++___ep0_get_conf_desc2:
++ li $22, 1 /* set EP0 to TX state */
++ sub $8, $21, 32
++ blez $8, _ep0_idle_state_fini /* wLength <= 32 */
++ nop
++ li $21, 32 /* max length of config_desc */
++ b _ep0_idle_state_fini
++ nop
++
++___ep0_get_string_desc:
++ li $22, 1 /* set EP0 to TX state */
++
++ srl $9, $25, 16 /* wValue & 0xff */
++ andi $9, 0xff
++
++ sub $8, $9, 1
++ beqz $8, ___ep0_get_string_manufacture
++ sub $8, $9, 2
++ beqz $8, ___ep0_get_string_product
++ nop
++
++___ep0_get_string_lang_ids:
++ load_addr $20, string_lang_ids /* data pointer */
++ b _ep0_idle_state_fini
++ li $21, 4 /* data length */
++
++___ep0_get_string_manufacture:
++ load_addr $20, string_manufacture /* data pointer */
++ b _ep0_idle_state_fini
++ li $21, 16 /* data length */
++
++___ep0_get_string_product:
++ load_addr $20, string_product /* data pointer */
++ b _ep0_idle_state_fini
++ li $21, 46 /* data length */
++
++_ep0_idle_state_fini:
++ li $9, 0x40 /* SVDOUTPKTRDY */
++ beqz $23, _ep0_idle_state_fini2
++ nop
++ ori $9, $9, 0x08 /* DATAEND */
++_ep0_idle_state_fini2:
++ sb $9, 0x12($27) /* CSR0 */
++ beqz $22, check_intr_ep1in
++ nop
++
++ /* 2.2 Handle EP0 TX state interrupt */
++ep0_tx_state:
++ sub $9, $22, 1
++ bnez $9, check_intr_ep1in
++ nop
++
++ sub $9, $21, 64 /* max packetsize */
++ blez $9, _ep0_tx_state2 /* data count <= 64 */
++ ori $19, $21, 0
++ li $19, 64
++
++_ep0_tx_state2:
++ beqz $19, _ep0_tx_state3 /* send ZLP */
++ ori $18, $19, 0 /* record bytes to be transferred */
++ sub $21, $21, $19 /* decrement data count */
++
++_ep0_fifo_write_loop:
++ lbu $9, 0($20) /* read data */
++ sb $9, 0x20($27) /* load FIFO */
++ sub $19, $19, 1 /* decrement counter */
++ bnez $19, _ep0_fifo_write_loop
++ addi $20, $20, 1 /* increment data pointer */
++
++ sub $9, $18, 64 /* max packetsize */
++ beqz $9, _ep0_tx_state4
++ nop
++
++_ep0_tx_state3:
++ /* transferred bytes < max packetsize */
++ li $9, 0x0a /* set INPKTRDY and DATAEND */
++ sb $9, 0x12($27) /* CSR0 */
++ li $22, 0 /* set EP0 to IDLE state */
++ b check_intr_ep1in
++ nop
++
++_ep0_tx_state4:
++ /* transferred bytes == max packetsize */
++ li $9, 0x02 /* set INPKTRDY */
++ sb $9, 0x12($27) /* CSR0 */
++ b check_intr_ep1in
++ nop
++
++ /* 3. Check and handle EP1 BULK-IN interrupt */
++check_intr_ep1in:
++ andi $9, $10, 0x2 /* check EP1 IN interrupt */
++ beqz $9, check_intr_ep1out
++ nop
++
++handle_epin1_intr:
++ li $9, 1
++ sb $9, 0x0e($27) /* set INDEX 1 */
++ lbu $9, 0x12($27) /* read INCSR */
++
++ andi $8, $9, 0x2 /* check INCSR_FFNOTEMPT */
++ bnez $8, _epin1_tx_state4
++ nop
++
++_epin1_write_fifo:
++ lhu $9, 0x10($27) /* get INMAXP */
++ sub $8, $21, $9
++ blez $8, _epin1_tx_state1 /* bytes left <= INMAXP */
++ ori $19, $21, 0
++ ori $19, $9, 0
++
++_epin1_tx_state1:
++ beqz $19, _epin1_tx_state4 /* No data */
++ nop
++
++ sub $21, $21, $19 /* decrement data count */
++
++ srl $5, $19, 2 /* # of word */
++ andi $6, $19, 0x3 /* # of byte */
++ beqz $5, _epin1_tx_state2
++ nop
++
++_epin1_fifo_write_word:
++ lw $9, 0($20) /* read data from source address */
++ sw $9, 0x24($27) /* write FIFO */
++ sub $5, $5, 1 /* decrement counter */
++ bnez $5, _epin1_fifo_write_word
++ addiu $20, $20, 4 /* increment dest address */
++
++_epin1_tx_state2:
++ beqz $6, _epin1_tx_state3
++ nop
++
++_epin1_fifo_write_byte:
++ lbu $9, 0($20) /* read data from source address */
++ sb $9, 0x24($27) /* write FIFO */
++ sub $6, $6, 1 /* decrement counter */
++ bnez $6, _epin1_fifo_write_byte
++ addiu $20, $20, 1 /* increment dest address */
++
++_epin1_tx_state3:
++ li $9, 0x1
++ sb $9, 0x12($27) /* INCSR, set INPKTRDY */
++
++_epin1_tx_state4:
++ /* 4. Check and handle EP1 BULK-OUT interrupt */
++check_intr_ep1out:
++ lhu $9, 0x04($27) /* read INTROUT */
++ andi $9, 0x2
++ beqz $9, check_status_next
++ nop
++
++handle_epout1_intr:
++ li $9, 1
++ sb $9, 0x0e($27) /* set INDEX 1 */
++
++ lbu $9, 0x16($27) /* read OUTCSR */
++ andi $9, 0x1 /* check OUTPKTRDY */
++ beqz $9, check_status_next
++ nop
++
++_epout1_read_fifo:
++ lhu $19, 0x18($27) /* read OUTCOUNT */
++ srl $5, $19, 2 /* # of word */
++ andi $6, $19, 0x3 /* # of byte */
++ beqz $5, _epout1_rx_state1
++ nop
++
++_epout1_fifo_read_word:
++ lw $9, 0x24($27) /* read FIFO */
++ sw $9, 0($20) /* store to dest address */
++ sub $5, $5, 1 /* decrement counter */
++ bnez $5, _epout1_fifo_read_word
++ addiu $20, $20, 4 /* increment dest address */
++
++_epout1_rx_state1:
++ beqz $6, _epout1_rx_state2
++ nop
++
++_epout1_fifo_read_byte:
++ lbu $9, 0x24($27) /* read FIFO */
++ sb $9, 0($20) /* store to dest address */
++ sub $6, $6, 1 /* decrement counter */
++ bnez $6, _epout1_fifo_read_byte
++ addiu $20, $20, 1 /* increment dest address */
++
++_epout1_rx_state2:
++ sb $0, 0x16($27) /* clear OUTPKTRDY */
++
++check_status_next:
++ b usb_command_loop
++ nop
++
++/* Device/Configuration/Interface/Endpoint/String Descriptors */
++
++ .align 2
++device_desc:
++ .byte 0x12 /* bLength */
++ .byte 0x01 /* bDescriptorType */
++ .byte 0x00 /* bcdUSB */
++ .byte 0x02 /* bcdUSB */
++ .byte 0x00 /* bDeviceClass */
++ .byte 0x00 /* bDeviceSubClass */
++ .byte 0x00 /* bDeviceProtocol */
++ .byte 0x40 /* bMaxPacketSize0 */
++ .byte 0x1a /* idVendor */
++ .byte 0x60 /* idVendor */
++ .byte 0x40 /* idProduct */
++ .byte 0x47 /* idProduct */
++ .byte 0x00 /* bcdDevice */
++ .byte 0x01 /* bcdDevice */
++ .byte 0x01 /* iManufacturer */
++ .byte 0x02 /* iProduct */
++ .byte 0x00 /* iSerialNumber */
++ .byte 0x01 /* bNumConfigurations */
++
++ .align 2
++dev_qualifier:
++ .byte 0x0a /* bLength */
++ .byte 0x06 /* bDescriptorType */
++ .byte 0x00 /* bcdUSB */
++ .byte 0x02 /* bcdUSB */
++ .byte 0x00 /* bDeviceClass */
++ .byte 0x00 /* bDeviceSubClass */
++ .byte 0x00 /* bDeviceProtocol */
++ .byte 0x40 /* bMaxPacketSize0 */
++ .byte 0x01 /* bNumConfigurations */
++ .byte 0x00 /* bRESERVED */
++
++ .align 2
++config_desc_hs:
++ .byte 0x09 /* bLength */
++ .byte 0x02 /* bDescriptorType */
++ .byte 0x20 /* wTotalLength */
++ .byte 0x00 /* wTotalLength */
++ .byte 0x01 /* bNumInterfaces */
++ .byte 0x01 /* bConfigurationValue */
++ .byte 0x00 /* iConfiguration */
++ .byte 0xc0 /* bmAttributes */
++ .byte 0x01 /* MaxPower */
++intf_desc_hs:
++ .byte 0x09 /* bLength */
++ .byte 0x04 /* bDescriptorType */
++ .byte 0x00 /* bInterfaceNumber */
++ .byte 0x00 /* bAlternateSetting */
++ .byte 0x02 /* bNumEndpoints */
++ .byte 0xff /* bInterfaceClass */
++ .byte 0x00 /* bInterfaceSubClass */
++ .byte 0x50 /* bInterfaceProtocol */
++ .byte 0x00 /* iInterface */
++ep1_desc_hs:
++ .byte 0x07 /* bLength */
++ .byte 0x05 /* bDescriptorType */
++ .byte 0x01 /* bEndpointAddress */
++ .byte 0x02 /* bmAttributes */
++ .byte 0x00 /* wMaxPacketSize */
++ .byte 0x02 /* wMaxPacketSize */
++ .byte 0x00 /* bInterval */
++ep2_desc_hs:
++ .byte 0x07 /* bLength */
++ .byte 0x05 /* bDescriptorType */
++ .byte 0x81 /* bEndpointAddress */
++ .byte 0x02 /* bmAttributes */
++ .byte 0x00 /* wMaxPacketSize */
++ .byte 0x02 /* wMaxPacketSize */
++ .byte 0x00 /* bInterval */
++
++ .align 2
++config_desc_fs:
++ .byte 0x09 /* bLength */
++ .byte 0x02 /* bDescriptorType */
++ .byte 0x20 /* wTotalLength */
++ .byte 0x00 /* wTotalLength */
++ .byte 0x01 /* bNumInterfaces */
++ .byte 0x01 /* bConfigurationValue */
++ .byte 0x00 /* iConfiguration */
++ .byte 0xc0 /* bmAttributes */
++ .byte 0x01 /* MaxPower */
++intf_desc_fs:
++ .byte 0x09 /* bLength */
++ .byte 0x04 /* bDescriptorType */
++ .byte 0x00 /* bInterfaceNumber */
++ .byte 0x00 /* bAlternateSetting */
++ .byte 0x02 /* bNumEndpoints */
++ .byte 0xff /* bInterfaceClass */
++ .byte 0x00 /* bInterfaceSubClass */
++ .byte 0x50 /* bInterfaceProtocol */
++ .byte 0x00 /* iInterface */
++ep1_desc_fs:
++ .byte 0x07 /* bLength */
++ .byte 0x05 /* bDescriptorType */
++ .byte 0x01 /* bEndpointAddress */
++ .byte 0x02 /* bmAttributes */
++ .byte 0x40 /* wMaxPacketSize */
++ .byte 0x00 /* wMaxPacketSize */
++ .byte 0x00 /* bInterval */
++ep2_desc_fs:
++ .byte 0x07 /* bLength */
++ .byte 0x05 /* bDescriptorType */
++ .byte 0x81 /* bEndpointAddress */
++ .byte 0x02 /* bmAttributes */
++ .byte 0x40 /* wMaxPacketSize */
++ .byte 0x00 /* wMaxPacketSize */
++ .byte 0x00 /* bInterval */
++
++ .align 2
++string_lang_ids:
++ .byte 0x04
++ .byte 0x03
++ .byte 0x09
++ .byte 0x04
++
++ .align 2
++string_manufacture:
++ .byte 0x10
++ .byte 0x03
++ .byte 0x49
++ .byte 0x00
++ .byte 0x6e
++ .byte 0x00
++ .byte 0x67
++ .byte 0x00
++ .byte 0x65
++ .byte 0x00
++ .byte 0x6e
++ .byte 0x00
++ .byte 0x69
++ .byte 0x00
++ .byte 0x63
++ .byte 0x00
++
++ .align 2
++string_product:
++ .byte 0x2e
++ .byte 0x03
++ .byte 0x4a
++ .byte 0x00
++ .byte 0x5a
++ .byte 0x00
++ .byte 0x34
++ .byte 0x00
++ .byte 0x37
++ .byte 0x00
++ .byte 0x34
++ .byte 0x00
++ .byte 0x30
++ .byte 0x00
++ .byte 0x20
++ .byte 0x00
++ .byte 0x55
++ .byte 0x00
++ .byte 0x53
++ .byte 0x00
++ .byte 0x42
++ .byte 0x00
++ .byte 0x20
++ .byte 0x00
++ .byte 0x42
++ .byte 0x00
++ .byte 0x6f
++ .byte 0x00
++ .byte 0x6f
++ .byte 0x00
++ .byte 0x74
++ .byte 0x00
++ .byte 0x20
++ .byte 0x00
++ .byte 0x44
++ .byte 0x00
++ .byte 0x65
++ .byte 0x00
++ .byte 0x76
++ .byte 0x00
++ .byte 0x69
++ .byte 0x00
++ .byte 0x63
++ .byte 0x00
++ .byte 0x65
++ .byte 0x00
++
++ .align 2
++cpu_info_data:
++ .byte 0x4a
++ .byte 0x5a
++ .byte 0x34
++ .byte 0x37
++ .byte 0x34
++ .byte 0x30
++ .byte 0x56
++ .byte 0x31
++usbboot_end:
++
++ .set reorder
+--
+1.7.9.5
+
diff --git a/package/boot/uboot-xburst/patches/.svn/text-base/0003-add-mmc-support.patch.svn-base b/package/boot/uboot-xburst/patches/.svn/text-base/0003-add-mmc-support.patch.svn-base
new file mode 100644
index 0000000..e9baa7c
--- /dev/null
+++ b/package/boot/uboot-xburst/patches/.svn/text-base/0003-add-mmc-support.patch.svn-base
@@ -0,0 +1,1664 @@
+From bd36739e77669e8df45c38f6acfe2cea511534d9 Mon Sep 17 00:00:00 2001
+From: Xiangfu <xiangfu@openmobilefree.net>
+Date: Wed, 10 Oct 2012 18:19:41 +0800
+Subject: [PATCH 3/6] add mmc support
+
+---
+ arch/mips/include/asm/jz4740.h | 166 ++++++
+ board/qi/qi_lb60/qi_lb60.c | 9 +-
+ drivers/mmc/Makefile | 1 +
+ drivers/mmc/jz_mmc.c | 1179 ++++++++++++++++++++++++++++++++++++++++
+ drivers/mmc/jz_mmc.h | 176 ++++++
+ include/configs/qi_lb60.h | 9 +
+ include/mmc.h | 40 ++
+ 7 files changed, 1578 insertions(+), 2 deletions(-)
+ create mode 100644 drivers/mmc/jz_mmc.c
+ create mode 100644 drivers/mmc/jz_mmc.h
+
+diff --git a/arch/mips/include/asm/jz4740.h b/arch/mips/include/asm/jz4740.h
+index 7a7cfff..68287fb 100644
+--- a/arch/mips/include/asm/jz4740.h
++++ b/arch/mips/include/asm/jz4740.h
+@@ -1146,5 +1146,171 @@ extern void sdram_init(void);
+ extern void calc_clocks(void);
+ extern void rtc_init(void);
+
++/*************************************************************************
++ * MSC
++ *************************************************************************/
++#define REG8(addr) *((volatile u8 *)(addr))
++#define REG16(addr) *((volatile u16 *)(addr))
++#define REG32(addr) *((volatile u32 *)(addr))
++
++#define CPM_BASE 0xB0000000
++#define CPM_CPCCR (CPM_BASE+0x00)
++#define CPM_MSCCDR (CPM_BASE+0x68)
++#define REG_CPM_MSCCDR REG32(CPM_MSCCDR)
++#define REG_CPM_CPCCR REG32(CPM_CPCCR)
++
++#define MSC_BASE 0xB0021000
++
++#define MSC_STRPCL (MSC_BASE + 0x000)
++#define MSC_STAT (MSC_BASE + 0x004)
++#define MSC_CLKRT (MSC_BASE + 0x008)
++#define MSC_CMDAT (MSC_BASE + 0x00C)
++#define MSC_RESTO (MSC_BASE + 0x010)
++#define MSC_RDTO (MSC_BASE + 0x014)
++#define MSC_BLKLEN (MSC_BASE + 0x018)
++#define MSC_NOB (MSC_BASE + 0x01C)
++#define MSC_SNOB (MSC_BASE + 0x020)
++#define MSC_IMASK (MSC_BASE + 0x024)
++#define MSC_IREG (MSC_BASE + 0x028)
++#define MSC_CMD (MSC_BASE + 0x02C)
++#define MSC_ARG (MSC_BASE + 0x030)
++#define MSC_RES (MSC_BASE + 0x034)
++#define MSC_RXFIFO (MSC_BASE + 0x038)
++#define MSC_TXFIFO (MSC_BASE + 0x03C)
++
++#define REG_MSC_STRPCL REG16(MSC_STRPCL)
++#define REG_MSC_STAT REG32(MSC_STAT)
++#define REG_MSC_CLKRT REG16(MSC_CLKRT)
++#define REG_MSC_CMDAT REG32(MSC_CMDAT)
++#define REG_MSC_RESTO REG16(MSC_RESTO)
++#define REG_MSC_RDTO REG16(MSC_RDTO)
++#define REG_MSC_BLKLEN REG16(MSC_BLKLEN)
++#define REG_MSC_NOB REG16(MSC_NOB)
++#define REG_MSC_SNOB REG16(MSC_SNOB)
++#define REG_MSC_IMASK REG16(MSC_IMASK)
++#define REG_MSC_IREG REG16(MSC_IREG)
++#define REG_MSC_CMD REG8(MSC_CMD)
++#define REG_MSC_ARG REG32(MSC_ARG)
++#define REG_MSC_RES REG16(MSC_RES)
++#define REG_MSC_RXFIFO REG32(MSC_RXFIFO)
++#define REG_MSC_TXFIFO REG32(MSC_TXFIFO)
++
++/* MSC Clock and Control Register (MSC_STRPCL) */
++
++#define MSC_STRPCL_EXIT_MULTIPLE (1 << 7)
++#define MSC_STRPCL_EXIT_TRANSFER (1 << 6)
++#define MSC_STRPCL_START_READWAIT (1 << 5)
++#define MSC_STRPCL_STOP_READWAIT (1 << 4)
++#define MSC_STRPCL_RESET (1 << 3)
++#define MSC_STRPCL_START_OP (1 << 2)
++#define MSC_STRPCL_CLOCK_CONTROL_BIT 0
++#define MSC_STRPCL_CLOCK_CONTROL_MASK (0x3 << MSC_STRPCL_CLOCK_CONTROL_BIT)
++ #define MSC_STRPCL_CLOCK_CONTROL_STOP (0x1 << MSC_STRPCL_CLOCK_CONTROL_BIT) /* Stop MMC/SD clock */
++ #define MSC_STRPCL_CLOCK_CONTROL_START (0x2 << MSC_STRPCL_CLOCK_CONTROL_BIT) /* Start MMC/SD clock */
++
++/* MSC Status Register (MSC_STAT) */
++
++#define MSC_STAT_IS_RESETTING (1 << 15)
++#define MSC_STAT_SDIO_INT_ACTIVE (1 << 14)
++#define MSC_STAT_PRG_DONE (1 << 13)
++#define MSC_STAT_DATA_TRAN_DONE (1 << 12)
++#define MSC_STAT_END_CMD_RES (1 << 11)
++#define MSC_STAT_DATA_FIFO_AFULL (1 << 10)
++#define MSC_STAT_IS_READWAIT (1 << 9)
++#define MSC_STAT_CLK_EN (1 << 8)
++#define MSC_STAT_DATA_FIFO_FULL (1 << 7)
++#define MSC_STAT_DATA_FIFO_EMPTY (1 << 6)
++#define MSC_STAT_CRC_RES_ERR (1 << 5)
++#define MSC_STAT_CRC_READ_ERROR (1 << 4)
++#define MSC_STAT_CRC_WRITE_ERROR_BIT 2
++#define MSC_STAT_CRC_WRITE_ERROR_MASK (0x3 << MSC_STAT_CRC_WRITE_ERROR_BIT)
++ #define MSC_STAT_CRC_WRITE_ERROR_NO (0 << MSC_STAT_CRC_WRITE_ERROR_BIT) /* No error on transmission of data */
++ #define MSC_STAT_CRC_WRITE_ERROR (1 << MSC_STAT_CRC_WRITE_ERROR_BIT) /* Card observed erroneous transmission of data */
++ #define MSC_STAT_CRC_WRITE_ERROR_NOSTS (2 << MSC_STAT_CRC_WRITE_ERROR_BIT) /* No CRC status is sent back */
++#define MSC_STAT_TIME_OUT_RES (1 << 1)
++#define MSC_STAT_TIME_OUT_READ (1 << 0)
++
++/* MSC Bus Clock Control Register (MSC_CLKRT) */
++
++#define MSC_CLKRT_CLK_RATE_BIT 0
++#define MSC_CLKRT_CLK_RATE_MASK (0x7 << MSC_CLKRT_CLK_RATE_BIT)
++ #define MSC_CLKRT_CLK_RATE_DIV_1 (0x0 << MSC_CLKRT_CLK_RATE_BIT) /* CLK_SRC */
++ #define MSC_CLKRT_CLK_RATE_DIV_2 (0x1 << MSC_CLKRT_CLK_RATE_BIT) /* 1/2 of CLK_SRC */
++ #define MSC_CLKRT_CLK_RATE_DIV_4 (0x2 << MSC_CLKRT_CLK_RATE_BIT) /* 1/4 of CLK_SRC */
++ #define MSC_CLKRT_CLK_RATE_DIV_8 (0x3 << MSC_CLKRT_CLK_RATE_BIT) /* 1/8 of CLK_SRC */
++ #define MSC_CLKRT_CLK_RATE_DIV_16 (0x4 << MSC_CLKRT_CLK_RATE_BIT) /* 1/16 of CLK_SRC */
++ #define MSC_CLKRT_CLK_RATE_DIV_32 (0x5 << MSC_CLKRT_CLK_RATE_BIT) /* 1/32 of CLK_SRC */
++ #define MSC_CLKRT_CLK_RATE_DIV_64 (0x6 << MSC_CLKRT_CLK_RATE_BIT) /* 1/64 of CLK_SRC */
++ #define MSC_CLKRT_CLK_RATE_DIV_128 (0x7 << MSC_CLKRT_CLK_RATE_BIT) /* 1/128 of CLK_SRC */
++
++/* MSC Command Sequence Control Register (MSC_CMDAT) */
++
++#define MSC_CMDAT_IO_ABORT (1 << 11)
++#define MSC_CMDAT_BUS_WIDTH_BIT 9
++#define MSC_CMDAT_BUS_WIDTH_MASK (0x3 << MSC_CMDAT_BUS_WIDTH_BIT)
++#define MSC_CMDAT_BUS_WIDTH_1BIT (0x0 << MSC_CMDAT_BUS_WIDTH_BIT)
++#define MSC_CMDAT_BUS_WIDTH_4BIT (0x2 << MSC_CMDAT_BUS_WIDTH_BIT)
++#define MSC_CMDAT_DMA_EN (1 << 8)
++#define MSC_CMDAT_INIT (1 << 7)
++#define MSC_CMDAT_BUSY (1 << 6)
++#define MSC_CMDAT_STREAM_BLOCK (1 << 5)
++#define MSC_CMDAT_WRITE (1 << 4)
++#define MSC_CMDAT_READ (0 << 4)
++#define MSC_CMDAT_DATA_EN (1 << 3)
++#define MSC_CMDAT_RESPONSE_BIT 0
++#define MSC_CMDAT_RESPONSE_MASK (0x7 << MSC_CMDAT_RESPONSE_BIT)
++#define MSC_CMDAT_RESPONSE_NONE (0x0 << MSC_CMDAT_RESPONSE_BIT)
++#define MSC_CMDAT_RESPONSE_R1 (0x1 << MSC_CMDAT_RESPONSE_BIT)
++#define MSC_CMDAT_RESPONSE_R2 (0x2 << MSC_CMDAT_RESPONSE_BIT)
++#define MSC_CMDAT_RESPONSE_R3 (0x3 << MSC_CMDAT_RESPONSE_BIT)
++#define MSC_CMDAT_RESPONSE_R4 (0x4 << MSC_CMDAT_RESPONSE_BIT)
++#define MSC_CMDAT_RESPONSE_R5 (0x5 << MSC_CMDAT_RESPONSE_BIT)
++#define MSC_CMDAT_RESPONSE_R6 (0x6 << MSC_CMDAT_RESPONSE_BIT)
++
++/* MSC Interrupts Mask Register (MSC_IMASK) */
++#define MSC_IMASK_SDIO (1 << 7)
++#define MSC_IMASK_TXFIFO_WR_REQ (1 << 6)
++#define MSC_IMASK_RXFIFO_RD_REQ (1 << 5)
++#define MSC_IMASK_END_CMD_RES (1 << 2)
++#define MSC_IMASK_PRG_DONE (1 << 1)
++#define MSC_IMASK_DATA_TRAN_DONE (1 << 0)
++
++
++/* MSC Interrupts Status Register (MSC_IREG) */
++#define MSC_IREG_SDIO (1 << 7)
++#define MSC_IREG_TXFIFO_WR_REQ (1 << 6)
++#define MSC_IREG_RXFIFO_RD_REQ (1 << 5)
++#define MSC_IREG_END_CMD_RES (1 << 2)
++#define MSC_IREG_PRG_DONE (1 << 1)
++#define MSC_IREG_DATA_TRAN_DONE (1 << 0)
++
++static __inline__ unsigned int __cpm_get_pllout2(void)
++{
++ if (REG_CPM_CPCCR & CPM_CPCCR_PCS)
++ return __cpm_get_pllout();
++ else
++ return __cpm_get_pllout()/2;
++}
++
++static inline void __cpm_select_msc_clk(int sd)
++{
++ unsigned int pllout2 = __cpm_get_pllout2();
++ unsigned int div = 0;
++
++ if (sd) {
++ div = pllout2 / 24000000;
++ }
++ else {
++ div = pllout2 / 16000000;
++ }
++
++ REG_CPM_MSCCDR = div - 1;
++}
++#define __msc_reset() \
++do { \
++ REG_MSC_STRPCL = MSC_STRPCL_RESET; \
++ while (REG_MSC_STAT & MSC_STAT_IS_RESETTING); \
++} while (0)
++
+ #endif /* !__ASSEMBLY__ */
+ #endif /* __JZ4740_H__ */
+diff --git a/board/qi/qi_lb60/qi_lb60.c b/board/qi/qi_lb60/qi_lb60.c
+index 3bd4e2f..a2ba648 100644
+--- a/board/qi/qi_lb60/qi_lb60.c
++++ b/board/qi/qi_lb60/qi_lb60.c
+@@ -40,8 +40,13 @@ static void gpio_init(void)
+ __gpio_clear_pin(GPIO_KEYOUT_BASE + i);
+ }
+
+- __gpio_as_input(GPIO_KEYIN_8);
+- __gpio_enable_pull(GPIO_KEYIN_8);
++ if (__gpio_get_pin(GPIO_KEYIN_BASE + 2) == 0){
++ printf("[S] pressed, enable UART0\n");
++ __gpio_as_uart0();
++ } else {
++ __gpio_as_input(GPIO_KEYIN_8);
++ __gpio_enable_pull(GPIO_KEYIN_8);
++ }
+
+ /* enable the TP4, TP5 as UART0 */
+ __gpio_jtag_to_uart0();
+diff --git a/drivers/mmc/Makefile b/drivers/mmc/Makefile
+index 565ba6a..3c717b1 100644
+--- a/drivers/mmc/Makefile
++++ b/drivers/mmc/Makefile
+@@ -47,6 +47,7 @@ COBJS-$(CONFIG_SDHCI) += sdhci.o
+ COBJS-$(CONFIG_S5P_SDHCI) += s5p_sdhci.o
+ COBJS-$(CONFIG_SH_MMCIF) += sh_mmcif.o
+ COBJS-$(CONFIG_TEGRA_MMC) += tegra_mmc.o
++COBJS-$(CONFIG_JZ4740_MMC) += jz_mmc.o
+
+ COBJS := $(COBJS-y)
+ SRCS := $(COBJS:.o=.c)
+diff --git a/drivers/mmc/jz_mmc.c b/drivers/mmc/jz_mmc.c
+new file mode 100644
+index 0000000..642cecc
+--- /dev/null
++++ b/drivers/mmc/jz_mmc.c
+@@ -0,0 +1,1179 @@
++/*
++ * (C) Copyright 2003
++ * Kyle Harris, Nexus Technologies, Inc. kharris@nexus-tech.net
++ *
++ * See file CREDITS for list of people who contributed to this
++ * project.
++ *
++ * 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 of
++ * the License, 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; if not, write to the Free Software
++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ * MA 02111-1307 USA
++ */
++
++#include <config.h>
++#include <common.h>
++#include <part.h>
++#include <mmc.h>
++
++#include <asm/io.h>
++#include <asm/jz4740.h>
++#include "jz_mmc.h"
++
++static int sd2_0 = 0;
++static int mmc_ready = 0;
++static int use_4bit; /* Use 4-bit data bus */
++/*
++ * MMC Events
++ */
++#define MMC_EVENT_NONE 0x00 /* No events */
++#define MMC_EVENT_RX_DATA_DONE 0x01 /* Rx data done */
++#define MMC_EVENT_TX_DATA_DONE 0x02 /* Tx data done */
++#define MMC_EVENT_PROG_DONE 0x04 /* Programming is done */
++
++
++#define MMC_IRQ_MASK() \
++do { \
++ REG_MSC_IMASK = 0xffff; \
++ REG_MSC_IREG = 0xffff; \
++} while (0)
++
++/*
++ * GPIO definition
++ */
++#if defined(CONFIG_SAKC)
++
++#define __msc_init_io() \
++do { \
++ __gpio_as_input(GPIO_SD_CD_N); \
++} while (0)
++
++#else
++#define __msc_init_io() \
++do { \
++ __gpio_as_output(GPIO_SD_VCC_EN_N); \
++ __gpio_as_input(GPIO_SD_CD_N); \
++} while (0)
++
++#define __msc_enable_power() \
++do { \
++ __gpio_clear_pin(GPIO_SD_VCC_EN_N); \
++} while (0)
++
++#define __msc_disable_power() \
++do { \
++ __gpio_set_pin(GPIO_SD_VCC_EN_N); \
++} while (0)
++
++#endif /* CONFIG_SAKE */
++
++#define __msc_card_detected() \
++({ \
++ int detected = 1; \
++ __gpio_as_input(GPIO_SD_CD_N); \
++ __gpio_disable_pull(GPIO_SD_CD_N); \
++ if (!__gpio_get_pin(GPIO_SD_CD_N)) \
++ detected = 0; \
++ detected; \
++})
++
++/*
++ * Local functions
++ */
++
++extern int
++fat_register_device(block_dev_desc_t *dev_desc, int part_no);
++
++static block_dev_desc_t mmc_dev;
++
++block_dev_desc_t * mmc_get_dev(int dev)
++{
++ return ((block_dev_desc_t *)&mmc_dev);
++}
++
++/* Stop the MMC clock and wait while it happens */
++static inline int jz_mmc_stop_clock(void)
++{
++ int timeout = 1000;
++
++ REG_MSC_STRPCL = MSC_STRPCL_CLOCK_CONTROL_STOP;
++
++ while (timeout && (REG_MSC_STAT & MSC_STAT_CLK_EN)) {
++ timeout--;
++ if (timeout == 0)
++ return MMC_ERROR_TIMEOUT;
++ udelay(1);
++ }
++ return MMC_NO_ERROR;
++}
++
++/* Start the MMC clock and operation */
++static inline int jz_mmc_start_clock(void)
++{
++ REG_MSC_STRPCL = MSC_STRPCL_CLOCK_CONTROL_START | MSC_STRPCL_START_OP;
++ return MMC_NO_ERROR;
++}
++
++static inline u32 jz_mmc_calc_clkrt(int is_sd, u32 rate)
++{
++ u32 clkrt = 0;
++ u32 clk_src = is_sd ? 24000000 : 16000000;
++
++ while (rate < clk_src) {
++ clkrt ++;
++ clk_src >>= 1;
++ }
++
++ return clkrt;
++}
++
++/* Set the MMC clock frequency */
++void jz_mmc_set_clock(int sd, u32 rate)
++{
++ jz_mmc_stop_clock();
++
++ /* Select clock source of MSC */
++ __cpm_select_msc_clk(sd);
++
++ /* Set clock dividor of MSC */
++ REG_MSC_CLKRT = jz_mmc_calc_clkrt(sd, rate);
++}
++
++static int jz_mmc_check_status(struct mmc_request *request)
++{
++ u32 status = REG_MSC_STAT;
++
++ /* Checking for response or data timeout */
++ if (status & (MSC_STAT_TIME_OUT_RES | MSC_STAT_TIME_OUT_READ)) {
++ printf("MMC/SD timeout, MMC_STAT 0x%x CMD %d\n", status, request->cmd);
++ return MMC_ERROR_TIMEOUT;
++ }
++
++ /* Checking for CRC error */
++ if (status & (MSC_STAT_CRC_READ_ERROR | MSC_STAT_CRC_WRITE_ERROR | MSC_STAT_CRC_RES_ERR)) {
++ printf("MMC/CD CRC error, MMC_STAT 0x%x\n", status);
++ return MMC_ERROR_CRC;
++ }
++
++ return MMC_NO_ERROR;
++}
++
++/* Obtain response to the command and store it to response buffer */
++static void jz_mmc_get_response(struct mmc_request *request)
++{
++ int i;
++ u8 *buf;
++ u32 data;
++
++ debug("fetch response for request %d, cmd %d\n",
++ request->rtype, request->cmd);
++
++ buf = request->response;
++ request->result = MMC_NO_ERROR;
++
++ switch (request->rtype) {
++ case RESPONSE_R1: case RESPONSE_R1B: case RESPONSE_R6:
++ case RESPONSE_R3: case RESPONSE_R4: case RESPONSE_R5:
++ {
++ data = REG_MSC_RES;
++ buf[0] = (data >> 8) & 0xff;
++ buf[1] = data & 0xff;
++ data = REG_MSC_RES;
++ buf[2] = (data >> 8) & 0xff;
++ buf[3] = data & 0xff;
++ data = REG_MSC_RES;
++ buf[4] = data & 0xff;
++
++ debug("request %d, response [%02x %02x %02x %02x %02x]\n",
++ request->rtype, buf[0], buf[1], buf[2], buf[3], buf[4]);
++ break;
++ }
++ case RESPONSE_R2_CID: case RESPONSE_R2_CSD:
++ {
++ for (i = 0; i < 16; i += 2) {
++ data = REG_MSC_RES;
++ buf[i] = (data >> 8) & 0xff;
++ buf[i+1] = data & 0xff;
++ }
++ debug("request %d, response [", request->rtype);
++#if CONFIG_MMC_DEBUG_VERBOSE > 2
++ if (g_mmc_debug >= 3) {
++ int n;
++ for (n = 0; n < 17; n++)
++ printk("%02x ", buf[n]);
++ printk("]\n");
++ }
++#endif
++ break;
++ }
++ case RESPONSE_NONE:
++ debug("No response\n");
++ break;
++
++ default:
++ debug("unhandled response type for request %d\n", request->rtype);
++ break;
++ }
++}
++
++static int jz_mmc_receive_data(struct mmc_request *req)
++{
++ u32 stat, timeout, data, cnt;
++ u8 *buf = req->buffer;
++ u32 wblocklen = (u32)(req->block_len + 3) >> 2; /* length in word */
++
++ timeout = 0x3ffffff;
++
++ while (timeout) {
++ timeout--;
++ stat = REG_MSC_STAT;
++
++ if (stat & MSC_STAT_TIME_OUT_READ)
++ return MMC_ERROR_TIMEOUT;
++ else if (stat & MSC_STAT_CRC_READ_ERROR)
++ return MMC_ERROR_CRC;
++ else if (!(stat & MSC_STAT_DATA_FIFO_EMPTY)
++ || (stat & MSC_STAT_DATA_FIFO_AFULL)) {
++ /* Ready to read data */
++ break;
++ }
++ udelay(1);
++ }
++ if (!timeout)
++ return MMC_ERROR_TIMEOUT;
++
++ /* Read data from RXFIFO. It could be FULL or PARTIAL FULL */
++ cnt = wblocklen;
++ while (cnt) {
++ data = REG_MSC_RXFIFO;
++ {
++ *buf++ = (u8)(data >> 0);
++ *buf++ = (u8)(data >> 8);
++ *buf++ = (u8)(data >> 16);
++ *buf++ = (u8)(data >> 24);
++ }
++ cnt --;
++ while (cnt && (REG_MSC_STAT & MSC_STAT_DATA_FIFO_EMPTY))
++ ;
++ }
++ return MMC_NO_ERROR;
++}
++
++static int jz_mmc_transmit_data(struct mmc_request *req)
++{
++#if 0
++ u32 nob = req->nob;
++ u32 wblocklen = (u32)(req->block_len + 3) >> 2; /* length in word */
++ u8 *buf = req->buffer;
++ u32 *wbuf = (u32 *)buf;
++ u32 waligned = (((u32)buf & 0x3) == 0); /* word aligned ? */
++ u32 stat, timeout, data, cnt;
++
++ for (nob; nob >= 1; nob--) {
++ timeout = 0x3FFFFFF;
++
++ while (timeout) {
++ timeout--;
++ stat = REG_MSC_STAT;
++
++ if (stat & (MSC_STAT_CRC_WRITE_ERROR | MSC_STAT_CRC_WRITE_ERROR_NOSTS))
++ return MMC_ERROR_CRC;
++ else if (!(stat & MSC_STAT_DATA_FIFO_FULL)) {
++ /* Ready to write data */
++ break;
++ }
++
++ udelay(1);
++ }
++
++ if (!timeout)
++ return MMC_ERROR_TIMEOUT;
++
++ /* Write data to TXFIFO */
++ cnt = wblocklen;
++ while (cnt) {
++ while (REG_MSC_STAT & MSC_STAT_DATA_FIFO_FULL)
++ ;
++
++ if (waligned) {
++ REG_MSC_TXFIFO = *wbuf++;
++ }
++ else {
++ data = *buf++ | (*buf++ << 8) | (*buf++ << 16) | (*buf++ << 24);
++ REG_MSC_TXFIFO = data;
++ }
++
++ cnt--;
++ }
++ }
++#endif
++ return MMC_NO_ERROR;
++}
++
++
++/*
++ * Name: int jz_mmc_exec_cmd()
++ * Function: send command to the card, and get a response
++ * Input: struct mmc_request *req : MMC/SD request
++ * Output: 0: right >0: error code
++ */
++int jz_mmc_exec_cmd(struct mmc_request *request)
++{
++ u32 cmdat = 0, events = 0;
++ int retval, timeout = 0x3fffff;
++
++ /* Indicate we have no result yet */
++ request->result = MMC_NO_RESPONSE;
++ if (request->cmd == MMC_CIM_RESET) {
++ /* On reset, 1-bit bus width */
++ use_4bit = 0;
++
++ /* Reset MMC/SD controller */
++ __msc_reset();
++
++ /* On reset, drop MMC clock down */
++ jz_mmc_set_clock(0, MMC_CLOCK_SLOW);
++
++ /* On reset, stop MMC clock */
++ jz_mmc_stop_clock();
++ }
++ if (request->cmd == MMC_CMD_SEND_OP_COND) {
++ debug("Have an MMC card\n");
++ /* always use 1bit for MMC */
++ use_4bit = 0;
++ }
++ if (request->cmd == SET_BUS_WIDTH) {
++ if (request->arg == 0x2) {
++ printf("Use 4-bit bus width\n");
++ use_4bit = 1;
++ } else {
++ printf("Use 1-bit bus width\n");
++ use_4bit = 0;
++ }
++ }
++
++ /* stop clock */
++ jz_mmc_stop_clock();
++
++ /* mask all interrupts */
++ REG_MSC_IMASK = 0xffff;
++
++ /* clear status */
++ REG_MSC_IREG = 0xffff;
++
++ /* use 4-bit bus width when possible */
++ if (use_4bit)
++ cmdat |= MSC_CMDAT_BUS_WIDTH_4BIT;
++
++ /* Set command type and events */
++ switch (request->cmd) {
++ /* MMC core extra command */
++ case MMC_CIM_RESET:
++ cmdat |= MSC_CMDAT_INIT; /* Initialization sequence sent prior to command */
++ break;
++
++ /* bc - broadcast - no response */
++ case MMC_CMD_GO_IDLE_STATE:
++ case MMC_CMD_SET_DSR:
++ break;
++
++ /* bcr - broadcast with response */
++ case MMC_CMD_SEND_OP_COND:
++ case MMC_CMD_ALL_SEND_CID:
++ case MMC_GO_IRQ_STATE:
++ break;
++
++ /* adtc - addressed with data transfer */
++ case MMC_READ_DAT_UNTIL_STOP:
++ case MMC_CMD_READ_SINGLE_BLOCK:
++ case MMC_CMD_READ_MULTIPLE_BLOCK:
++ case SD_CMD_APP_SEND_SCR:
++ cmdat |= MSC_CMDAT_DATA_EN | MSC_CMDAT_READ;
++ events = MMC_EVENT_RX_DATA_DONE;
++ break;
++
++ case MMC_WRITE_DAT_UNTIL_STOP:
++ case MMC_CMD_WRITE_SINGLE_BLOCK:
++ case MMC_CMD_WRITE_MULTIPLE_BLOCK:
++ case MMC_PROGRAM_CID:
++ case MMC_PROGRAM_CSD:
++ case MMC_SEND_WRITE_PROT:
++ case MMC_GEN_CMD:
++ case MMC_LOCK_UNLOCK:
++ cmdat |= MSC_CMDAT_DATA_EN | MSC_CMDAT_WRITE;
++ events = MMC_EVENT_TX_DATA_DONE | MMC_EVENT_PROG_DONE;
++
++ break;
++
++ case MMC_CMD_STOP_TRANSMISSION:
++ events = MMC_EVENT_PROG_DONE;
++ break;
++
++ /* ac - no data transfer */
++ default:
++ break;
++ }
++
++ /* Set response type */
++ switch (request->rtype) {
++ case RESPONSE_NONE:
++ break;
++
++ case RESPONSE_R1B:
++ cmdat |= MSC_CMDAT_BUSY;
++ /*FALLTHRU*/
++ case RESPONSE_R1:
++ cmdat |= MSC_CMDAT_RESPONSE_R1;
++ break;
++ case RESPONSE_R2_CID:
++ case RESPONSE_R2_CSD:
++ cmdat |= MSC_CMDAT_RESPONSE_R2;
++ break;
++ case RESPONSE_R3:
++ cmdat |= MSC_CMDAT_RESPONSE_R3;
++ break;
++ case RESPONSE_R4:
++ cmdat |= MSC_CMDAT_RESPONSE_R4;
++ break;
++ case RESPONSE_R5:
++ cmdat |= MSC_CMDAT_RESPONSE_R5;
++ break;
++ case RESPONSE_R6:
++ cmdat |= MSC_CMDAT_RESPONSE_R6;
++ break;
++ default:
++ break;
++ }
++
++ /* Set command index */
++ if (request->cmd == MMC_CIM_RESET) {
++ REG_MSC_CMD = MMC_CMD_GO_IDLE_STATE;
++ } else {
++ REG_MSC_CMD = request->cmd;
++ }
++
++ /* Set argument */
++ REG_MSC_ARG = request->arg;
++
++ /* Set block length and nob */
++ if (request->cmd == SD_CMD_APP_SEND_SCR) { /* get SCR from DataFIFO */
++ REG_MSC_BLKLEN = 8;
++ REG_MSC_NOB = 1;
++ } else {
++ REG_MSC_BLKLEN = request->block_len;
++ REG_MSC_NOB = request->nob;
++ }
++
++ /* Set command */
++ REG_MSC_CMDAT = cmdat;
++
++ debug("Send cmd %d cmdat: %x arg: %x resp %d\n", request->cmd,
++ cmdat, request->arg, request->rtype);
++
++ /* Start MMC/SD clock and send command to card */
++ jz_mmc_start_clock();
++
++ /* Wait for command completion */
++ while (timeout-- && !(REG_MSC_STAT & MSC_STAT_END_CMD_RES))
++ ;
++
++ if (timeout == 0)
++ return MMC_ERROR_TIMEOUT;
++
++ REG_MSC_IREG = MSC_IREG_END_CMD_RES; /* clear flag */
++
++ /* Check for status */
++ retval = jz_mmc_check_status(request);
++ if (retval) {
++ return retval;
++ }
++
++ /* Complete command with no response */
++ if (request->rtype == RESPONSE_NONE) {
++ return MMC_NO_ERROR;
++ }
++
++ /* Get response */
++ jz_mmc_get_response(request);
++
++ /* Start data operation */
++ if (events & (MMC_EVENT_RX_DATA_DONE | MMC_EVENT_TX_DATA_DONE)) {
++ if (events & MMC_EVENT_RX_DATA_DONE) {
++ if (request->cmd == SD_CMD_APP_SEND_SCR) {
++ /* SD card returns SCR register as data.
++ MMC core expect it in the response buffer,
++ after normal response. */
++ request->buffer = (u8 *)((u32)request->response + 5);
++ }
++ jz_mmc_receive_data(request);
++ }
++
++ if (events & MMC_EVENT_TX_DATA_DONE) {
++ jz_mmc_transmit_data(request);
++ }
++
++ /* Wait for Data Done */
++ while (!(REG_MSC_IREG & MSC_IREG_DATA_TRAN_DONE))
++ ;
++ REG_MSC_IREG = MSC_IREG_DATA_TRAN_DONE; /* clear status */
++ }
++
++ /* Wait for Prog Done event */
++ if (events & MMC_EVENT_PROG_DONE) {
++ while (!(REG_MSC_IREG & MSC_IREG_PRG_DONE))
++ ;
++ REG_MSC_IREG = MSC_IREG_PRG_DONE; /* clear status */
++ }
++
++ /* Command completed */
++
++ return MMC_NO_ERROR; /* return successfully */
++}
++
++int mmc_block_read(u8 *dst, ulong src, ulong len)
++{
++
++ struct mmc_request request;
++ struct mmc_response_r1 r1;
++ int retval = 0;
++
++ if (len == 0)
++ goto exit;
++
++ mmc_simple_cmd(&request, MMC_CMD_SEND_STATUS, mmcinfo.rca, RESPONSE_R1);
++ retval = mmc_unpack_r1(&request, &r1, 0);
++ if (retval && (retval != MMC_ERROR_STATE_MISMATCH))
++ goto exit;
++
++ mmc_simple_cmd(&request, MMC_CMD_SET_BLOCKLEN, len, RESPONSE_R1);
++ if (retval = mmc_unpack_r1(&request, &r1, 0))
++ goto exit;
++
++ if (!sd2_0)
++ src *= mmcinfo.block_len;
++
++ mmc_send_cmd(&request, MMC_CMD_READ_SINGLE_BLOCK, src, 1, len, RESPONSE_R1, dst);
++ if (retval = mmc_unpack_r1(&request, &r1, 0))
++ goto exit;
++
++exit:
++ return retval;
++}
++
++ulong mmc_bread(int dev_num, ulong blkstart, ulong blkcnt, ulong *dst)
++{
++ if (!mmc_ready) {
++ printf("Please initial the MMC first\n");
++ return -1;
++ }
++
++ int i = 0;
++ ulong dst_tmp = dst;
++
++ for (i = 0; i < blkcnt; i++) {
++ if ((mmc_block_read((uchar *)(dst_tmp), blkstart, mmcinfo.block_len)) < 0)
++ return -1;
++
++ dst_tmp += mmcinfo.block_len;
++ blkstart++;
++ }
++
++ return i;
++}
++
++int mmc_select_card(void)
++{
++ struct mmc_request request;
++ struct mmc_response_r1 r1;
++ int retval;
++
++ mmc_simple_cmd(&request, MMC_CMD_SELECT_CARD, mmcinfo.rca, RESPONSE_R1B);
++ retval = mmc_unpack_r1(&request, &r1, 0);
++ if (retval) {
++ return retval;
++ }
++
++ if (mmcinfo.sd) {
++ mmc_simple_cmd(&request, MMC_CMD_APP_CMD, mmcinfo.rca, RESPONSE_R1);
++ retval = mmc_unpack_r1(&request,&r1,0);
++ if (retval) {
++ return retval;
++ }
++#if defined(MMC_BUS_WIDTH_1BIT)
++ mmc_simple_cmd(&request, SET_BUS_WIDTH, 1, RESPONSE_R1);
++#else
++ mmc_simple_cmd(&request, SET_BUS_WIDTH, 2, RESPONSE_R1);
++#endif
++ retval = mmc_unpack_r1(&request,&r1,0);
++ if (retval) {
++ return retval;
++ }
++ }
++ return 0;
++}
++
++/*
++ * Configure card
++ */
++static void mmc_configure_card(void)
++{
++ u32 rate;
++
++ /* Get card info */
++ if (sd2_0)
++ mmcinfo.block_num = (mmcinfo.csd.c_size + 1) << 10;
++ else
++ mmcinfo.block_num = (mmcinfo.csd.c_size + 1) * (1 << (mmcinfo.csd.c_size_mult + 2));
++
++ mmcinfo.block_len = 1 << mmcinfo.csd.read_bl_len;
++
++ mmc_dev.if_type = IF_TYPE_SD;
++ mmc_dev.part_type = PART_TYPE_DOS;
++ mmc_dev.dev = 0;
++ mmc_dev.lun = 0;
++ mmc_dev.type = 0;
++ mmc_dev.blksz = mmcinfo.block_len;
++ mmc_dev.lba = mmcinfo.block_num;
++ mmc_dev.removable = 0;
++
++ printf("%s Detected: %lu blocks of %lu bytes\n",
++ sd2_0 == 1 ? "SDHC" : "SD",
++ mmc_dev.lba,
++ mmc_dev.blksz);
++
++ /* Fix the clock rate */
++ rate = mmc_tran_speed(mmcinfo.csd.tran_speed);
++ if (rate < MMC_CLOCK_SLOW)
++ rate = MMC_CLOCK_SLOW;
++ if ((mmcinfo.sd == 0) && (rate > MMC_CLOCK_FAST))
++ rate = MMC_CLOCK_FAST;
++ if ((mmcinfo.sd) && (rate > SD_CLOCK_FAST))
++ rate = SD_CLOCK_FAST;
++
++ debug("%s: block_len=%d block_num=%d rate=%d\n",
++ __func__, mmcinfo.block_len, mmcinfo.block_num, rate);
++
++ jz_mmc_set_clock(mmcinfo.sd, rate);
++}
++
++/*
++ * State machine routines to initialize card(s)
++ */
++
++/*
++ CIM_SINGLE_CARD_ACQ (frequency at 400 kHz)
++ --- Must enter from GO_IDLE_STATE ---
++ 1. SD_SEND_OP_COND (SD Card) [CMD55] + [CMD41]
++ 2. SEND_OP_COND (Full Range) [CMD1] {optional}
++ 3. SEND_OP_COND (Set Range ) [CMD1]
++ If busy, delay and repeat step 2
++ 4. ALL_SEND_CID [CMD2]
++ If timeout, set an error (no cards found)
++ 5. SET_RELATIVE_ADDR [CMD3]
++ 6. SEND_CSD [CMD9]
++ 7. SET_DSR [CMD4] Only call this if (csd.dsr_imp).
++ 8. Set clock frequency (check available in csd.tran_speed)
++ */
++
++#define MMC_INIT_DOING 0
++#define MMC_INIT_PASSED 1
++#define MMC_INIT_FAILED 2
++
++static int mmc_init_card_state(struct mmc_request *request)
++{
++ struct mmc_response_r1 r1;
++ struct mmc_response_r3 r3;
++ int retval;
++ int ocr = 0x40300000;
++ int limit_41 = 0;
++
++ switch (request->cmd) {
++ case MMC_CMD_GO_IDLE_STATE: /* No response to parse */
++ if (mmcinfo.sd)
++ mmc_simple_cmd(request, 8, 0x1aa, RESPONSE_R1);
++ else
++ mmc_simple_cmd(request, MMC_CMD_SEND_OP_COND, MMC_OCR_ARG, RESPONSE_R3);
++ break;
++
++ case 8:
++ retval = mmc_unpack_r1(request,&r1,mmcinfo.state);
++ mmc_simple_cmd(request, MMC_CMD_APP_CMD, 0, RESPONSE_R1);
++ break;
++
++ case MMC_CMD_APP_CMD:
++ retval = mmc_unpack_r1(request,&r1,mmcinfo.state);
++ if (retval & (limit_41 < 100)) {
++ debug("%s: unable to MMC_APP_CMD error=%d (%s)\n",
++ __func__, retval, mmc_result_to_string(retval));
++ limit_41++;
++ mmc_simple_cmd(request, SD_CMD_APP_SEND_OP_COND, ocr, RESPONSE_R3);
++ } else if (limit_41 < 100) {
++ limit_41++;
++ mmc_simple_cmd(request, SD_CMD_APP_SEND_OP_COND, ocr, RESPONSE_R3);
++ } else{
++ /* reset the card to idle*/
++ mmc_simple_cmd(request, MMC_CMD_GO_IDLE_STATE, 0, RESPONSE_NONE);
++ mmcinfo.sd = 0;
++ }
++ break;
++
++ case SD_CMD_APP_SEND_OP_COND:
++ retval = mmc_unpack_r3(request, &r3);
++ if (retval) {
++ debug("%s: try MMC card\n", __func__);
++ mmc_simple_cmd(request, SD_CMD_APP_SEND_OP_COND, MMC_OCR_ARG, RESPONSE_R3);
++ break;
++ }
++
++ debug("%s: read ocr value = 0x%08x\n", __func__, r3.ocr);
++
++ if(!(r3.ocr & MMC_CARD_BUSY || ocr == 0)){
++ udelay(50000);
++ mmc_simple_cmd(request, MMC_CMD_APP_CMD, 0, RESPONSE_R1);
++ } else {
++ mmcinfo.sd = 1; /* SD Card ready */
++ mmcinfo.state = CARD_STATE_READY;
++ mmc_simple_cmd(request, MMC_CMD_ALL_SEND_CID, 0, RESPONSE_R2_CID);
++ }
++ break;
++
++ case MMC_CMD_SEND_OP_COND:
++ retval = mmc_unpack_r3(request, &r3);
++ if (retval) {
++ debug("%s: failed SEND_OP_COND error=%d (%s)\n",
++ __func__, retval, mmc_result_to_string(retval));
++ return MMC_INIT_FAILED;
++ }
++
++ debug("%s: read ocr value = 0x%08x\n", __func__, r3.ocr);
++ if (!(r3.ocr & MMC_CARD_BUSY)) {
++ mmc_simple_cmd(request, MMC_CMD_SEND_OP_COND, MMC_OCR_ARG, RESPONSE_R3);
++ } else {
++ mmcinfo.sd = 0; /* MMC Card ready */
++ mmcinfo.state = CARD_STATE_READY;
++ mmc_simple_cmd(request, MMC_CMD_ALL_SEND_CID, 0, RESPONSE_R2_CID);
++ }
++ break;
++
++ case MMC_CMD_ALL_SEND_CID:
++ retval = mmc_unpack_cid( request, &mmcinfo.cid );
++ /*FIXME:ignore CRC error for CMD2/CMD9/CMD10 */
++ if ( retval && (retval != MMC_ERROR_CRC)) {
++ debug("mmc_init_card_state: unable to ALL_SEND_CID error=%d (%s)\n",
++ retval, mmc_result_to_string(retval));
++ return MMC_INIT_FAILED;
++ }
++ mmcinfo.state = CARD_STATE_IDENT;
++ if(mmcinfo.sd)
++ mmc_simple_cmd(request, MMC_CMD_SET_RELATIVE_ADDR, 0, RESPONSE_R6);
++ else
++ mmc_simple_cmd(request, MMC_CMD_SET_RELATIVE_ADDR, ID_TO_RCA(mmcinfo.id) << 16, RESPONSE_R1);
++ break;
++
++ case MMC_CMD_SET_RELATIVE_ADDR:
++ if (mmcinfo.sd) {
++ retval = mmc_unpack_r6(request, &r1, mmcinfo.state, &mmcinfo.rca);
++ mmcinfo.rca = mmcinfo.rca << 16;
++ debug("%s: Get RCA from SD: 0x%04x Status: %x\n",
++ __func__, mmcinfo.rca, r1.status);
++ } else {
++ retval = mmc_unpack_r1(request,&r1,mmcinfo.state);
++ mmcinfo.rca = ID_TO_RCA(mmcinfo.id) << 16;
++ }
++ if (retval) {
++ debug("%s: unable to SET_RELATIVE_ADDR error=%d (%s)\n",
++ __func__, retval, mmc_result_to_string(retval));
++ return MMC_INIT_FAILED;
++ }
++
++ mmcinfo.state = CARD_STATE_STBY;
++ mmc_simple_cmd(request, MMC_CMD_SEND_CSD, mmcinfo.rca, RESPONSE_R2_CSD);
++
++ break;
++
++ case MMC_CMD_SEND_CSD:
++ retval = mmc_unpack_csd(request, &mmcinfo.csd);
++ mmc_ready = 1;
++ /*FIXME:ignore CRC error for CMD2/CMD9/CMD10 */
++ if (retval && (retval != MMC_ERROR_CRC)) {
++ debug("%s: unable to SEND_CSD error=%d (%s)\n",
++ __func__, retval, mmc_result_to_string(retval));
++ return MMC_INIT_FAILED;
++ }
++ if (mmcinfo.csd.dsr_imp) {
++ debug("%s: driver doesn't support setting DSR\n", __func__);
++ }
++ mmc_configure_card();
++ return MMC_INIT_PASSED;
++
++ default:
++ debug("%s: error! Illegal last cmd %d\n", __func__, request->cmd);
++ return MMC_INIT_FAILED;
++ }
++
++ return MMC_INIT_DOING;
++}
++
++int mmc_init_card(void)
++{
++ struct mmc_request request;
++ int retval;
++
++ mmc_simple_cmd(&request, MMC_CIM_RESET, 0, RESPONSE_NONE); /* reset card */
++ mmc_simple_cmd(&request, MMC_CMD_GO_IDLE_STATE, 0, RESPONSE_NONE);
++ mmcinfo.sd = 1; /* assuming a SD card */
++
++ while ((retval = mmc_init_card_state(&request)) == MMC_INIT_DOING)
++ ;
++
++ if (retval == MMC_INIT_PASSED)
++ return MMC_NO_ERROR;
++ else
++ return MMC_NO_RESPONSE;
++}
++
++int mmc_legacy_init(int verbose)
++{
++ if (!__msc_card_detected())
++ return 1;
++
++ /* Step-1: init GPIO */
++ __gpio_as_msc();
++ __msc_init_io();
++
++ /* Step-2: turn on power of card */
++#if !defined(CONFIG_SAKC)
++ __msc_enable_power();
++#endif
++
++ /* Step-3: Reset MSC Controller. */
++ __msc_reset();
++
++ /* Step-3: mask all IRQs. */
++ MMC_IRQ_MASK();
++
++ /* Step-4: stop MMC/SD clock */
++ jz_mmc_stop_clock();
++ mmc_init_card();
++ mmc_select_card();
++
++ mmc_dev.block_read = mmc_bread;
++ fat_register_device(&mmc_dev,1); /* partitions start counting with 1 */
++
++ return 0;
++}
++
++/*
++ * Debugging functions
++ */
++static char * mmc_result_strings[] = {
++ "NO_RESPONSE",
++ "NO_ERROR",
++ "ERROR_OUT_OF_RANGE",
++ "ERROR_ADDRESS",
++ "ERROR_BLOCK_LEN",
++ "ERROR_ERASE_SEQ",
++ "ERROR_ERASE_PARAM",
++ "ERROR_WP_VIOLATION",
++ "ERROR_CARD_IS_LOCKED",
++ "ERROR_LOCK_UNLOCK_FAILED",
++ "ERROR_COM_CRC",
++ "ERROR_ILLEGAL_COMMAND",
++ "ERROR_CARD_ECC_FAILED",
++ "ERROR_CC",
++ "ERROR_GENERAL",
++ "ERROR_UNDERRUN",
++ "ERROR_OVERRUN",
++ "ERROR_CID_CSD_OVERWRITE",
++ "ERROR_STATE_MISMATCH",
++ "ERROR_HEADER_MISMATCH",
++ "ERROR_TIMEOUT",
++ "ERROR_CRC",
++ "ERROR_DRIVER_FAILURE",
++};
++
++char * mmc_result_to_string(int i)
++{
++ return mmc_result_strings[i+1];
++}
++
++static char * card_state_strings[] = {
++ "empty",
++ "idle",
++ "ready",
++ "ident",
++ "stby",
++ "tran",
++ "data",
++ "rcv",
++ "prg",
++ "dis",
++};
++
++static inline char * card_state_to_string(int i)
++{
++ return card_state_strings[i+1];
++}
++
++/*
++ * Utility functions
++ */
++
++#define PARSE_U32(_buf,_index) \
++ (((u32)_buf[_index]) << 24) | (((u32)_buf[_index+1]) << 16) | \
++ (((u32)_buf[_index+2]) << 8) | ((u32)_buf[_index+3]);
++
++#define PARSE_U16(_buf,_index) \
++ (((u16)_buf[_index]) << 8) | ((u16)_buf[_index+1]);
++
++int mmc_unpack_csd(struct mmc_request *request, struct mmc_csd *csd)
++{
++ u8 *buf = request->response;
++ int num = 0;
++
++ if (request->result)
++ return request->result;
++
++ if (buf[0] != 0x3f)
++ return MMC_ERROR_HEADER_MISMATCH;
++
++ csd->csd_structure = (buf[1] & 0xc0) >> 6;
++ if (csd->csd_structure)
++ sd2_0 = 1;
++ else
++ sd2_0 = 0;
++
++ switch (csd->csd_structure) {
++ case 0 :/* Version 1.01-1.10
++ * Version 2.00/Standard Capacity */
++ csd->taac = buf[2];
++ csd->nsac = buf[3];
++ csd->tran_speed = buf[4];
++ csd->ccc = (((u16)buf[5]) << 4) | ((buf[6] & 0xf0) >> 4);
++ csd->read_bl_len = buf[6] & 0x0f;
++ /* for support 2GB card*/
++ if (csd->read_bl_len >= 10)
++ {
++ num = csd->read_bl_len - 9;
++ csd->read_bl_len = 9;
++ }
++
++ csd->read_bl_partial = (buf[7] & 0x80) ? 1 : 0;
++ csd->write_blk_misalign = (buf[7] & 0x40) ? 1 : 0;
++ csd->read_blk_misalign = (buf[7] & 0x20) ? 1 : 0;
++ csd->dsr_imp = (buf[7] & 0x10) ? 1 : 0;
++ csd->c_size = ((((u16)buf[7]) & 0x03) << 10) | (((u16)buf[8]) << 2) | (((u16)buf[9]) & 0xc0) >> 6;
++
++ if (num)
++ csd->c_size = csd->c_size << num;
++
++
++ csd->vdd_r_curr_min = (buf[9] & 0x38) >> 3;
++ csd->vdd_r_curr_max = buf[9] & 0x07;
++ csd->vdd_w_curr_min = (buf[10] & 0xe0) >> 5;
++ csd->vdd_w_curr_max = (buf[10] & 0x1c) >> 2;
++ csd->c_size_mult = ((buf[10] & 0x03) << 1) | ((buf[11] & 0x80) >> 7);
++ csd->sector_size = (buf[11] & 0x7c) >> 2;
++ csd->erase_grp_size = ((buf[11] & 0x03) << 3) | ((buf[12] & 0xe0) >> 5);
++ csd->wp_grp_size = buf[12] & 0x1f;
++ csd->wp_grp_enable = (buf[13] & 0x80) ? 1 : 0;
++ csd->default_ecc = (buf[13] & 0x60) >> 5;
++ csd->r2w_factor = (buf[13] & 0x1c) >> 2;
++ csd->write_bl_len = ((buf[13] & 0x03) << 2) | ((buf[14] & 0xc0) >> 6);
++ if (csd->write_bl_len >= 10)
++ csd->write_bl_len = 9;
++
++ csd->write_bl_partial = (buf[14] & 0x20) ? 1 : 0;
++ csd->file_format_grp = (buf[15] & 0x80) ? 1 : 0;
++ csd->copy = (buf[15] & 0x40) ? 1 : 0;
++ csd->perm_write_protect = (buf[15] & 0x20) ? 1 : 0;
++ csd->tmp_write_protect = (buf[15] & 0x10) ? 1 : 0;
++ csd->file_format = (buf[15] & 0x0c) >> 2;
++ csd->ecc = buf[15] & 0x03;
++ break;
++ case 1 : /* Version 2.00/High Capacity */
++ csd->taac = 0;
++ csd->nsac = 0;
++ csd->tran_speed = buf[4];
++ csd->ccc = (((u16)buf[5]) << 4) | ((buf[6] & 0xf0) >> 4);
++
++ csd->read_bl_len = 9;
++ csd->read_bl_partial = 0;
++ csd->write_blk_misalign = 0;
++ csd->read_blk_misalign = 0;
++ csd->dsr_imp = (buf[7] & 0x10) ? 1 : 0;
++ csd->c_size = ((((u16)buf[8]) & 0x3f) << 16) | (((u16)buf[9]) << 8) | ((u16)buf[10]) ;
++ csd->sector_size = 0x7f;
++ csd->erase_grp_size = 0;
++ csd->wp_grp_size = 0;
++ csd->wp_grp_enable = 0;
++ csd->default_ecc = (buf[13] & 0x60) >> 5;
++ csd->r2w_factor = 4;/* Unused */
++ csd->write_bl_len = 9;
++
++ csd->write_bl_partial = 0;
++ csd->file_format_grp = 0;
++ csd->copy = (buf[15] & 0x40) ? 1 : 0;
++ csd->perm_write_protect = (buf[15] & 0x20) ? 1 : 0;
++ csd->tmp_write_protect = (buf[15] & 0x10) ? 1 : 0;
++ csd->file_format = 0;
++ csd->ecc = buf[15] & 0x03;
++ }
++
++ return 0;
++}
++
++int mmc_unpack_r1(struct mmc_request *request, struct mmc_response_r1 *r1, enum card_state state)
++{
++ u8 *buf = request->response;
++
++ if (request->result)
++ return request->result;
++
++ r1->cmd = buf[0];
++ r1->status = PARSE_U32(buf,1);
++
++ debug("mmc_unpack_r1: cmd=%d status=%08x\n", r1->cmd, r1->status);
++
++ if (R1_STATUS(r1->status)) {
++ if (r1->status & R1_OUT_OF_RANGE) return MMC_ERROR_OUT_OF_RANGE;
++ if (r1->status & R1_ADDRESS_ERROR) return MMC_ERROR_ADDRESS;
++ if (r1->status & R1_BLOCK_LEN_ERROR) return MMC_ERROR_BLOCK_LEN;
++ if (r1->status & R1_ERASE_SEQ_ERROR) return MMC_ERROR_ERASE_SEQ;
++ if (r1->status & R1_ERASE_PARAM) return MMC_ERROR_ERASE_PARAM;
++ if (r1->status & R1_WP_VIOLATION) return MMC_ERROR_WP_VIOLATION;
++ /*if (r1->status & R1_CARD_IS_LOCKED) return MMC_ERROR_CARD_IS_LOCKED; */
++ if (r1->status & R1_LOCK_UNLOCK_FAILED) return MMC_ERROR_LOCK_UNLOCK_FAILED;
++ if (r1->status & R1_COM_CRC_ERROR) return MMC_ERROR_COM_CRC;
++ if (r1->status & R1_ILLEGAL_COMMAND) return MMC_ERROR_ILLEGAL_COMMAND;
++ if (r1->status & R1_CARD_ECC_FAILED) return MMC_ERROR_CARD_ECC_FAILED;
++ if (r1->status & R1_CC_ERROR) return MMC_ERROR_CC;
++ if (r1->status & R1_ERROR) return MMC_ERROR_GENERAL;
++ if (r1->status & R1_UNDERRUN) return MMC_ERROR_UNDERRUN;
++ if (r1->status & R1_OVERRUN) return MMC_ERROR_OVERRUN;
++ if (r1->status & R1_CID_CSD_OVERWRITE) return MMC_ERROR_CID_CSD_OVERWRITE;
++ }
++
++ if (buf[0] != request->cmd)
++ return MMC_ERROR_HEADER_MISMATCH;
++
++ /* This should be last - it's the least dangerous error */
++
++ return 0;
++}
++
++int mmc_unpack_scr(struct mmc_request *request, struct mmc_response_r1 *r1, enum card_state state, u32 *scr)
++{
++ u8 *buf = request->response;
++ if (request->result)
++ return request->result;
++
++ *scr = PARSE_U32(buf, 5); /* Save SCR returned by the SD Card */
++ return mmc_unpack_r1(request, r1, state);
++
++}
++
++int mmc_unpack_r6(struct mmc_request *request, struct mmc_response_r1 *r1, enum card_state state, int *rca)
++{
++ u8 *buf = request->response;
++
++ if (request->result)
++ return request->result;
++
++ *rca = PARSE_U16(buf,1); /* Save RCA returned by the SD Card */
++
++ *(buf+1) = 0;
++ *(buf+2) = 0;
++
++ return mmc_unpack_r1(request, r1, state);
++}
++
++int mmc_unpack_cid(struct mmc_request *request, struct mmc_cid *cid)
++{
++ int i;
++ u8 *buf = request->response;
++
++ if (request->result)
++ return request->result;
++
++ cid->mid = buf[1];
++ cid->oid = PARSE_U16(buf,2);
++ for (i = 0 ; i < 5 ; i++)
++ cid->pnm[i] = buf[4+i];
++ cid->pnm[6] = 0;
++ cid->prv = buf[10];
++ cid->psn = PARSE_U32(buf,10);
++ cid->mdt = buf[15];
++
++ printf("Man %02x OEM 0x%04x \"%s\" %d.%d 0x%08x "
++ "Date %02u/%04u\n",
++ cid->mid,
++ cid->oid,
++ cid->pnm,
++ cid->prv >> 4,
++ cid->prv & 0xf,
++ cid->psn,
++ cid->mdt & 0xf,
++ (cid->mdt >> 4) + 2000);
++
++ if (buf[0] != 0x3f)
++ return MMC_ERROR_HEADER_MISMATCH;
++ return 0;
++}
++
++int mmc_unpack_r3(struct mmc_request *request, struct mmc_response_r3 *r3)
++{
++ u8 *buf = request->response;
++
++ if (request->result)
++ return request->result;
++
++ r3->ocr = PARSE_U32(buf,1);
++ debug("mmc_unpack_r3: ocr=%08x\n", r3->ocr);
++
++ if (buf[0] != 0x3f) return MMC_ERROR_HEADER_MISMATCH;
++ return 0;
++}
++
++#define KBPS 1
++#define MBPS 1000
++
++static u32 ts_exp[] = { 100*KBPS, 1*MBPS, 10*MBPS, 100*MBPS, 0, 0, 0, 0 };
++static u32 ts_mul[] = { 0, 1000, 1200, 1300, 1500, 2000, 2500, 3000,
++ 3500, 4000, 4500, 5000, 5500, 6000, 7000, 8000 };
++
++u32 mmc_tran_speed(u8 ts)
++{
++ u32 rate = ts_exp[(ts & 0x7)] * ts_mul[(ts & 0x78) >> 3];
++
++ if (rate <= 0) {
++ debug("%s: error - unrecognized speed 0x%02x\n", __func__, ts);
++ return 1;
++ }
++
++ return rate;
++}
++
++void mmc_send_cmd(struct mmc_request *request, int cmd, u32 arg,
++ u16 nob, u16 block_len, enum mmc_rsp_t rtype, u8 *buffer)
++{
++ request->cmd = cmd;
++ request->arg = arg;
++ request->rtype = rtype;
++ request->nob = nob;
++ request->block_len = block_len;
++ request->buffer = buffer;
++ request->cnt = nob * block_len;
++
++ jz_mmc_exec_cmd(request);
++}
+diff --git a/drivers/mmc/jz_mmc.h b/drivers/mmc/jz_mmc.h
+new file mode 100644
+index 0000000..936c514
+--- /dev/null
++++ b/drivers/mmc/jz_mmc.h
+@@ -0,0 +1,176 @@
++/*
++ * linux/drivers/mmc/jz_mmc.h
++ *
++ * Author: Vladimir Shebordaev, Igor Oblakov
++ * Copyright: MontaVista Software Inc.
++ *
++ * $Id: jz_mmc.h,v 1.3 2007-06-15 08:04:20 jlwei Exp $
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License version 2 as
++ * published by the Free Software Foundation.
++ */
++#ifndef __MMC_JZMMC_H__
++#define __MMC_JZMMC_H__
++
++#define ID_TO_RCA(x) ((x)+1)
++#define MMC_OCR_ARG 0x00ff8000 /* Argument of OCR */
++
++/* Standard MMC/SD clock speeds */
++#define MMC_CLOCK_SLOW 400000 /* 400 kHz for initial setup */
++#define MMC_CLOCK_FAST 20000000 /* 20 MHz for maximum for normal operation */
++#define SD_CLOCK_FAST 24000000 /* 24 MHz for SD Cards */
++
++/* Use negative numbers to disambiguate */
++#define MMC_CIM_RESET -1
++#define SET_BUS_WIDTH 6 /* ac [1:0] bus width R1 */
++
++#define R1_OUT_OF_RANGE (1 << 31) /* er, c */
++#define R1_ADDRESS_ERROR (1 << 30) /* erx, c */
++#define R1_BLOCK_LEN_ERROR (1 << 29) /* er, c */
++#define R1_ERASE_SEQ_ERROR (1 << 28) /* er, c */
++#define R1_ERASE_PARAM (1 << 27) /* ex, c */
++#define R1_WP_VIOLATION (1 << 26) /* erx, c */
++#define R1_CARD_IS_LOCKED (1 << 25) /* sx, a */
++#define R1_LOCK_UNLOCK_FAILED (1 << 24) /* erx, c */
++#define R1_COM_CRC_ERROR (1 << 23) /* er, b */
++#define R1_ILLEGAL_COMMAND (1 << 22) /* er, b */
++#define R1_CARD_ECC_FAILED (1 << 21) /* ex, c */
++#define R1_CC_ERROR (1 << 20) /* erx, c */
++#define R1_ERROR (1 << 19) /* erx, c */
++#define R1_UNDERRUN (1 << 18) /* ex, c */
++#define R1_OVERRUN (1 << 17) /* ex, c */
++#define R1_CID_CSD_OVERWRITE (1 << 16) /* erx, c, CID/CSD overwrite */
++#define R1_WP_ERASE_SKIP (1 << 15) /* sx, c */
++#define R1_CARD_ECC_DISABLED (1 << 14) /* sx, a */
++#define R1_ERASE_RESET (1 << 13) /* sr, c */
++#define R1_STATUS(x) (x & 0xFFFFE000)
++
++#define MMC_CARD_BUSY 0x80000000 /* Card Power up status bit */
++
++#define MMC_PROGRAM_CID 26 /* adtc R1 */
++#define MMC_PROGRAM_CSD 27 /* adtc R1 */
++
++#define MMC_GO_IRQ_STATE 40 /* bcr R5 */
++#define MMC_GEN_CMD 56 /* adtc [0] RD/WR R1b */
++#define MMC_LOCK_UNLOCK 42 /* adtc R1b */
++#define MMC_WRITE_DAT_UNTIL_STOP 20 /* adtc [31:0] data addr R1 */
++#define MMC_READ_DAT_UNTIL_STOP 11 /* adtc [31:0] dadr R1 */
++#define MMC_SEND_WRITE_PROT 30 /* adtc [31:0] wpdata addr R1 */
++
++
++enum mmc_result_t {
++ MMC_NO_RESPONSE = -1,
++ MMC_NO_ERROR = 0,
++ MMC_ERROR_OUT_OF_RANGE,
++ MMC_ERROR_ADDRESS,
++ MMC_ERROR_BLOCK_LEN,
++ MMC_ERROR_ERASE_SEQ,
++ MMC_ERROR_ERASE_PARAM,
++ MMC_ERROR_WP_VIOLATION,
++ MMC_ERROR_CARD_IS_LOCKED,
++ MMC_ERROR_LOCK_UNLOCK_FAILED,
++ MMC_ERROR_COM_CRC,
++ MMC_ERROR_ILLEGAL_COMMAND,
++ MMC_ERROR_CARD_ECC_FAILED,
++ MMC_ERROR_CC,
++ MMC_ERROR_GENERAL,
++ MMC_ERROR_UNDERRUN,
++ MMC_ERROR_OVERRUN,
++ MMC_ERROR_CID_CSD_OVERWRITE,
++ MMC_ERROR_STATE_MISMATCH,
++ MMC_ERROR_HEADER_MISMATCH,
++ MMC_ERROR_TIMEOUT,
++ MMC_ERROR_CRC,
++ MMC_ERROR_DRIVER_FAILURE,
++};
++
++enum card_state {
++ CARD_STATE_EMPTY = -1,
++ CARD_STATE_IDLE = 0,
++ CARD_STATE_READY = 1,
++ CARD_STATE_IDENT = 2,
++ CARD_STATE_STBY = 3,
++ CARD_STATE_TRAN = 4,
++ CARD_STATE_DATA = 5,
++ CARD_STATE_RCV = 6,
++ CARD_STATE_PRG = 7,
++ CARD_STATE_DIS = 8,
++};
++
++enum mmc_rsp_t {
++ RESPONSE_NONE = 0,
++ RESPONSE_R1 = 1,
++ RESPONSE_R1B = 2,
++ RESPONSE_R2_CID = 3,
++ RESPONSE_R2_CSD = 4,
++ RESPONSE_R3 = 5,
++ RESPONSE_R4 = 6,
++ RESPONSE_R5 = 7,
++ RESPONSE_R6 = 8,
++};
++
++struct mmc_response_r1 {
++ u8 cmd;
++ u32 status;
++};
++
++struct mmc_response_r3 {
++ u32 ocr;
++};
++
++/* the information structure of MMC/SD Card */
++struct mmc_info {
++ int id; /* Card index */
++ int sd; /* MMC or SD card */
++ int rca; /* RCA */
++ u32 scr; /* SCR 63:32*/
++ int flags; /* Ejected, inserted */
++ enum card_state state; /* empty, ident, ready, whatever */
++
++ /* Card specific information */
++ struct mmc_cid cid;
++ struct mmc_csd csd;
++ u32 block_num;
++ u32 block_len;
++ u32 erase_unit;
++};
++
++struct mmc_info mmcinfo;
++
++struct mmc_request {
++ int index; /* Slot index - used for CS lines */
++ int cmd; /* Command to send */
++ u32 arg; /* Argument to send */
++ enum mmc_rsp_t rtype; /* Response type expected */
++
++ /* Data transfer (these may be modified at the low level) */
++ u16 nob; /* Number of blocks to transfer*/
++ u16 block_len; /* Block length */
++ u8 *buffer; /* Data buffer */
++ u32 cnt; /* Data length, for PIO */
++
++ /* Results */
++ u8 response[18]; /* Buffer to store response - CRC is optional */
++ enum mmc_result_t result;
++};
++
++char * mmc_result_to_string(int);
++int mmc_unpack_csd(struct mmc_request *request, struct mmc_csd *csd);
++int mmc_unpack_r1(struct mmc_request *request, struct mmc_response_r1 *r1, enum card_state state);
++int mmc_unpack_r6(struct mmc_request *request, struct mmc_response_r1 *r1, enum card_state state, int *rca);
++int mmc_unpack_scr(struct mmc_request *request, struct mmc_response_r1 *r1, enum card_state state, u32 *scr);
++int mmc_unpack_cid(struct mmc_request *request, struct mmc_cid *cid);
++int mmc_unpack_r3(struct mmc_request *request, struct mmc_response_r3 *r3);
++
++void mmc_send_cmd(struct mmc_request *request, int cmd, u32 arg,
++ u16 nob, u16 block_len, enum mmc_rsp_t rtype, u8 *buffer);
++u32 mmc_tran_speed(u8 ts);
++void jz_mmc_set_clock(int sd, u32 rate);
++
++static inline void mmc_simple_cmd(struct mmc_request *request, int cmd, u32 arg, enum mmc_rsp_t rtype)
++{
++ mmc_send_cmd( request, cmd, arg, 0, 0, rtype, 0);
++}
++
++#endif /* __MMC_JZMMC_H__ */
+diff --git a/include/configs/qi_lb60.h b/include/configs/qi_lb60.h
+index 7bff444..7b33be0 100644
+--- a/include/configs/qi_lb60.h
++++ b/include/configs/qi_lb60.h
+@@ -31,6 +31,15 @@
+ /*
+ * Miscellaneous configurable options
+ */
++#define CONFIG_JZ4740_MMC
++#define CONFIG_MMC 1
++#define CONFIG_FAT 1
++#define CONFIG_DOS_PARTITION 1
++#define CONFIG_CMD_MMC
++#define CONFIG_CMD_FAT
++#define CONFIG_CMD_EXT2
++
++
+ #define CONFIG_SYS_SDRAM_BASE 0x80000000 /* Cached addr */
+ #define CONFIG_SYS_INIT_SP_OFFSET 0x400000
+ #define CONFIG_SYS_LOAD_ADDR 0x80600000
+diff --git a/include/mmc.h b/include/mmc.h
+index a13e2bd..3c4761c 100644
+--- a/include/mmc.h
++++ b/include/mmc.h
+@@ -283,4 +283,44 @@ struct mmc *mmc_spi_init(uint bus, uint cs, uint speed, uint mode);
+ int mmc_legacy_init(int verbose);
+ #endif
+
++struct mmc_csd
++{
++ u8 csd_structure:2,
++ spec_vers:4,
++ rsvd1:2;
++ u8 taac;
++ u8 nsac;
++ u8 tran_speed;
++ u16 ccc:12,
++ read_bl_len:4;
++ u32 c_size:22;
++ u64 read_bl_partial:1,
++ write_blk_misalign:1,
++ read_blk_misalign:1,
++ dsr_imp:1,
++ rsvd2:2,
++ vdd_r_curr_min:3,
++ vdd_r_curr_max:3,
++ vdd_w_curr_min:3,
++ vdd_w_curr_max:3,
++ c_size_mult:3,
++ sector_size:5,
++ erase_grp_size:5,
++ wp_grp_size:5,
++ wp_grp_enable:1,
++ default_ecc:2,
++ r2w_factor:3,
++ write_bl_len:4,
++ write_bl_partial:1,
++ rsvd3:5;
++ u8 file_format_grp:1,
++ copy:1,
++ perm_write_protect:1,
++ tmp_write_protect:1,
++ file_format:2,
++ ecc:2;
++ u8 crc:7;
++ u8 one:1;
++};
++
+ #endif /* _MMC_H_ */
+--
+1.7.9.5
+
diff --git a/package/boot/uboot-xburst/patches/.svn/text-base/0004-add-more-boot-options-F1-F2-F3-F4-M-S.patch.svn-base b/package/boot/uboot-xburst/patches/.svn/text-base/0004-add-more-boot-options-F1-F2-F3-F4-M-S.patch.svn-base
new file mode 100644
index 0000000..73e0324
--- /dev/null
+++ b/package/boot/uboot-xburst/patches/.svn/text-base/0004-add-more-boot-options-F1-F2-F3-F4-M-S.patch.svn-base
@@ -0,0 +1,200 @@
+From c52b6168979d03fc31205444c3278c537787472a Mon Sep 17 00:00:00 2001
+From: Xiangfu <xiangfu@openmobilefree.net>
+Date: Wed, 10 Oct 2012 18:39:55 +0800
+Subject: [PATCH 4/6] add more boot options(F1/F2/F3/F4/M/S)
+
+---
+ arch/mips/include/asm/global_data.h | 3 +++
+ arch/mips/lib/bootm.c | 17 ++++++++++++++++-
+ board/qi/qi_lb60/qi_lb60.c | 26 +++++++++++++++++++++++---
+ common/main.c | 21 +++++++++++++++++++--
+ include/configs/qi_lb60.h | 32 ++++++++++++++++++++++++++++++++
+ 5 files changed, 93 insertions(+), 6 deletions(-)
+
+diff --git a/arch/mips/include/asm/global_data.h b/arch/mips/include/asm/global_data.h
+index 6e2cdc7..cd03d7e 100644
+--- a/arch/mips/include/asm/global_data.h
++++ b/arch/mips/include/asm/global_data.h
+@@ -59,6 +59,9 @@ typedef struct global_data {
+ unsigned long env_valid; /* Checksum of Environment valid? */
+ void **jt; /* jump table */
+ char env_buf[32]; /* buffer for getenv() before reloc. */
++#if defined(CONFIG_NANONOTE)
++ unsigned long boot_option;
++#endif
+ } gd_t;
+
+ #include <asm-generic/global_data_flags.h>
+diff --git a/arch/mips/lib/bootm.c b/arch/mips/lib/bootm.c
+index 608c1a7..e00416b 100644
+--- a/arch/mips/lib/bootm.c
++++ b/arch/mips/lib/bootm.c
+@@ -47,10 +47,25 @@ int do_bootm_linux(int flag, int argc, char * const argv[],
+ bootm_headers_t *images)
+ {
+ void (*theKernel) (int, char **, char **, int *);
+- char *commandline = getenv("bootargs");
++ char *commandline;
+ char env_buf[12];
+ char *cp;
+
++#if defined(CONFIG_NANONOTE)
++ if (gd->boot_option & BOOT_FROM_MEMCARD)
++ commandline = getenv ("bootargsfromsd");
++ else if (gd->boot_option & BOOT_WITH_F1)
++ commandline = getenv ("bootargsf1");
++ else if (gd->boot_option & BOOT_WITH_F2)
++ commandline = getenv ("bootargsf2");
++ else if (gd->boot_option & BOOT_WITH_F3)
++ commandline = getenv ("bootargsf3");
++ else if (gd->boot_option & BOOT_WITH_F4)
++ commandline = getenv ("bootargsf4");
++ else
++#endif
++ commandline = getenv ("bootargs");
++
+ if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
+ return 1;
+
+diff --git a/board/qi/qi_lb60/qi_lb60.c b/board/qi/qi_lb60/qi_lb60.c
+index a2ba648..d622219 100644
+--- a/board/qi/qi_lb60/qi_lb60.c
++++ b/board/qi/qi_lb60/qi_lb60.c
+@@ -15,7 +15,7 @@ DECLARE_GLOBAL_DATA_PTR;
+
+ static void gpio_init(void)
+ {
+- unsigned int i;
++ unsigned int i, j;
+
+ /* Initialize NAND Flash Pins */
+ __gpio_as_nand();
+@@ -42,14 +42,34 @@ static void gpio_init(void)
+
+ if (__gpio_get_pin(GPIO_KEYIN_BASE + 2) == 0){
+ printf("[S] pressed, enable UART0\n");
++ gd->boot_option |= BOOT_WITH_ENABLE_UART;
+ __gpio_as_uart0();
+ } else {
+ __gpio_as_input(GPIO_KEYIN_8);
+ __gpio_enable_pull(GPIO_KEYIN_8);
+ }
+
+- /* enable the TP4, TP5 as UART0 */
+- __gpio_jtag_to_uart0();
++ if (__gpio_get_pin(GPIO_KEYIN_BASE + 3) == 0) {
++ printf("[M] pressed, boot from memory card\n");
++ gd->boot_option |= BOOT_FROM_MEMCARD;
++ __gpio_jtag_to_uart0();
++ }
++
++ for (j = 0; j < 4; j++) {
++ for (i = 0; i < 4; i++)
++ __gpio_set_pin(GPIO_KEYOUT_BASE + i);
++
++ __gpio_clear_pin(GPIO_KEYOUT_BASE + j);
++
++ if (__gpio_get_pin(GPIO_KEYIN_BASE) == 0) {
++ printf("[F%d] pressed", (j + 1));
++ gd->boot_option |= (1 << (j + 2));
++ /* BOOT_WITH_F1 (1 << 2) */
++ /* BOOT_WITH_F2 (1 << 3) */
++ /* BOOT_WITH_F3 (1 << 4) */
++ /* BOOT_WITH_F4 (1 << 5) */
++ }
++ }
+
+ __gpio_as_output(GPIO_AUDIO_POP);
+ __gpio_set_pin(GPIO_AUDIO_POP);
+diff --git a/common/main.c b/common/main.c
+index 9507cec..dbfb7ca 100644
+--- a/common/main.c
++++ b/common/main.c
+@@ -355,7 +355,11 @@ void main_loop (void)
+ #if defined(CONFIG_BOOTDELAY) && (CONFIG_BOOTDELAY >= 0)
+ s = getenv ("bootdelay");
+ bootdelay = s ? (int)simple_strtol(s, NULL, 10) : CONFIG_BOOTDELAY;
+-
++#if defined(CONFIG_NANONOTE)
++ DECLARE_GLOBAL_DATA_PTR;
++ if (gd->boot_option & BOOT_WITH_ENABLE_UART)
++ bootdelay = 3;
++# endif
+ debug ("### main_loop entered: bootdelay=%d\n\n", bootdelay);
+
+ #if defined(CONFIG_MENU_SHOW)
+@@ -379,7 +383,20 @@ void main_loop (void)
+ }
+ else
+ #endif /* CONFIG_BOOTCOUNT_LIMIT */
+- s = getenv ("bootcmd");
++#if defined(CONFIG_NANONOTE)
++ if (gd->boot_option & BOOT_FROM_MEMCARD)
++ s = getenv ("bootcmdfromsd");
++ else if (gd->boot_option & BOOT_WITH_F1)
++ s = getenv ("bootcmdf1");
++ else if (gd->boot_option & BOOT_WITH_F2)
++ s = getenv ("bootcmdf2");
++ else if (gd->boot_option & BOOT_WITH_F3)
++ s = getenv ("bootcmdf3");
++ else if (gd->boot_option & BOOT_WITH_F4)
++ s = getenv ("bootcmdf4");
++ else
++#endif
++ s = getenv ("bootcmd");
+
+ debug ("### main_loop: bootcmd=\"%s\"\n", s ? s : "<UNDEFINED>");
+
+diff --git a/include/configs/qi_lb60.h b/include/configs/qi_lb60.h
+index 7b33be0..52b370c 100644
+--- a/include/configs/qi_lb60.h
++++ b/include/configs/qi_lb60.h
+@@ -31,6 +31,7 @@
+ /*
+ * Miscellaneous configurable options
+ */
++#define CONFIG_NANONOTE
+ #define CONFIG_JZ4740_MMC
+ #define CONFIG_MMC 1
+ #define CONFIG_FAT 1
+@@ -39,6 +40,37 @@
+ #define CONFIG_CMD_FAT
+ #define CONFIG_CMD_EXT2
+
++#define CONFIG_CMD_UBIFS
++#define CONFIG_CMD_UBI
++#define CONFIG_MTD_PARTITIONS
++#define CONFIG_MTD_DEVICE
++#define CONFIG_CMD_MTDPARTS
++#define CONFIG_CMD_UBI
++#define CONFIG_CMD_UBIFS
++#define CONFIG_LZO
++#define CONFIG_RBTREE
++
++#define MTDIDS_DEFAULT "nand0=jz4740-nand"
++#define MTDPARTS_DEFAULT "mtdparts=jz4740-nand:4M@0(uboot)ro,4M@4M(kernel)ro,512M@8M(rootfs)ro,-(data)ro"
++
++#define BOOT_FROM_MEMCARD 1
++#define BOOT_WITH_ENABLE_UART (1 << 1) /* Vaule for global_data.h gd->boot_option */
++#define BOOT_WITH_F1 (1 << 2)
++#define BOOT_WITH_F2 (1 << 3)
++#define BOOT_WITH_F3 (1 << 4)
++#define BOOT_WITH_F4 (1 << 5)
++
++#define CONFIG_EXTRA_ENV_SETTINGS \
++ "bootcmdfromsd=mmc init; ext2load mmc 0 0x80600000 /boot/uImage; bootm;\0" \
++ "bootargsfromsd=mem=32M console=tty0 console=ttyS0,57600n8 rootfstype=ext2 root=/dev/mmcblk0p1 rw rootwait\0" \
++ "bootcmdf1=mmc init; ext2load mmc 0:1 0x80600000 /boot/uImage; bootm;\0" \
++ "bootargsf1=mem=32M console=tty0 console=ttyS0,57600n8 rootfstype=ext2 root=/dev/mmcblk0p1 rw rootwait\0" \
++ "bootcmdf2=mmc init; ext2load mmc 0:2 0x80600000 /boot/uImage; bootm;\0" \
++ "bootargsf2=mem=32M console=tty0 console=ttyS0,57600n8 rootfstype=ext2 root=/dev/mmcblk0p2 rw rootwait\0" \
++ "bootcmdf3=mmc init; ext2load mmc 0:3 0x80600000 /boot/uImage; bootm;\0" \
++ "bootargsf3=mem=32M console=tty0 console=ttyS0,57600n8 rootfstype=ext2 root=/dev/mmcblk0p3 rw rootwait\0" \
++ "bootcmdf4=mtdparts default;ubi part rootfs;ubifsmount rootfs;ubifsload 0x80600000 /boot/uImage; bootm;\0" \
++ "bootargsf4=mem=32M console=tty0 console=ttyS0,57600n8 ubi.mtd=2 rootfstype=ubifs root=ubi0:rootfs rw rootwait"
+
+ #define CONFIG_SYS_SDRAM_BASE 0x80000000 /* Cached addr */
+ #define CONFIG_SYS_INIT_SP_OFFSET 0x400000
+--
+1.7.9.5
+
diff --git a/package/boot/uboot-xburst/patches/.svn/text-base/0005-add-nanonote-lcd-support.patch.svn-base b/package/boot/uboot-xburst/patches/.svn/text-base/0005-add-nanonote-lcd-support.patch.svn-base
new file mode 100644
index 0000000..2c550f7
--- /dev/null
+++ b/package/boot/uboot-xburst/patches/.svn/text-base/0005-add-nanonote-lcd-support.patch.svn-base
@@ -0,0 +1,847 @@
+From ca8c5216cfd3ad3fda9867ed2d157ae5a209834b Mon Sep 17 00:00:00 2001
+From: Xiangfu <xiangfu@openmobilefree.net>
+Date: Wed, 10 Oct 2012 22:05:27 +0800
+Subject: [PATCH 5/6] add nanonote lcd support
+
+---
+ arch/mips/include/asm/global_data.h | 1 +
+ arch/mips/include/asm/jz4740.h | 90 ++++++++
+ arch/mips/lib/board.c | 6 +
+ common/lcd.c | 9 +-
+ drivers/video/Makefile | 1 +
+ drivers/video/nanonote_gpm940b0.c | 400 +++++++++++++++++++++++++++++++++++
+ drivers/video/nanonote_gpm940b0.h | 135 ++++++++++++
+ include/configs/qi_lb60.h | 7 +
+ include/lcd.h | 52 ++++-
+ 9 files changed, 697 insertions(+), 4 deletions(-)
+ create mode 100644 drivers/video/nanonote_gpm940b0.c
+ create mode 100644 drivers/video/nanonote_gpm940b0.h
+
+diff --git a/arch/mips/include/asm/global_data.h b/arch/mips/include/asm/global_data.h
+index cd03d7e..7cec2de 100644
+--- a/arch/mips/include/asm/global_data.h
++++ b/arch/mips/include/asm/global_data.h
+@@ -44,6 +44,7 @@ typedef struct global_data {
+ unsigned long per_clk; /* Peripheral bus clock */
+ unsigned long mem_clk; /* Memory bus clock */
+ unsigned long dev_clk; /* Device clock */
++ unsigned long fb_base; /* base address of framebuffer */
+ /* "static data" needed by most of timer.c */
+ unsigned long tbl;
+ unsigned long lastinc;
+diff --git a/arch/mips/include/asm/jz4740.h b/arch/mips/include/asm/jz4740.h
+index 68287fb..13724a2 100644
+--- a/arch/mips/include/asm/jz4740.h
++++ b/arch/mips/include/asm/jz4740.h
+@@ -1312,5 +1312,95 @@ do { \
+ while (REG_MSC_STAT & MSC_STAT_IS_RESETTING); \
+ } while (0)
+
++/*************************************************************************
++ * LCD (LCD Controller)
++ *************************************************************************/
++#define REG32(addr) *((volatile u32 *)(addr))
++
++#define CPM_BASE 0xB0000000
++#define CPM_CPCCR (CPM_BASE+0x00)
++#define REG_CPM_CPCCR REG32(CPM_CPCCR)
++
++#define LCD_BASE 0xB3050000
++#define LCD_CFG (LCD_BASE + 0x00) /* LCD Configure Register */
++#define LCD_VSYNC (LCD_BASE + 0x04) /* Vertical Synchronize Register */
++#define LCD_HSYNC (LCD_BASE + 0x08) /* Horizontal Synchronize Register */
++#define LCD_VAT (LCD_BASE + 0x0c) /* Virtual Area Setting Register */
++#define LCD_DAH (LCD_BASE + 0x10) /* Display Area Horizontal Start/End Point */
++#define LCD_DAV (LCD_BASE + 0x14) /* Display Area Vertical Start/End Point */
++#define LCD_PS (LCD_BASE + 0x18) /* PS Signal Setting */
++#define LCD_CLS (LCD_BASE + 0x1c) /* CLS Signal Setting */
++#define LCD_SPL (LCD_BASE + 0x20) /* SPL Signal Setting */
++#define LCD_REV (LCD_BASE + 0x24) /* REV Signal Setting */
++#define LCD_CTRL (LCD_BASE + 0x30) /* LCD Control Register */
++#define LCD_STATE (LCD_BASE + 0x34) /* LCD Status Register */
++#define LCD_IID (LCD_BASE + 0x38) /* Interrupt ID Register */
++#define LCD_DA0 (LCD_BASE + 0x40) /* Descriptor Address Register 0 */
++#define LCD_SA0 (LCD_BASE + 0x44) /* Source Address Register 0 */
++#define LCD_FID0 (LCD_BASE + 0x48) /* Frame ID Register 0 */
++#define LCD_CMD0 (LCD_BASE + 0x4c) /* DMA Command Register 0 */
++#define LCD_DA1 (LCD_BASE + 0x50) /* Descriptor Address Register 1 */
++#define LCD_SA1 (LCD_BASE + 0x54) /* Source Address Register 1 */
++#define LCD_FID1 (LCD_BASE + 0x58) /* Frame ID Register 1 */
++#define LCD_CMD1 (LCD_BASE + 0x5c) /* DMA Command Register 1 */
++
++#define REG_LCD_CFG REG32(LCD_CFG)
++#define REG_LCD_VSYNC REG32(LCD_VSYNC)
++#define REG_LCD_HSYNC REG32(LCD_HSYNC)
++#define REG_LCD_VAT REG32(LCD_VAT)
++#define REG_LCD_DAH REG32(LCD_DAH)
++#define REG_LCD_DAV REG32(LCD_DAV)
++#define REG_LCD_PS REG32(LCD_PS)
++#define REG_LCD_CLS REG32(LCD_CLS)
++#define REG_LCD_SPL REG32(LCD_SPL)
++#define REG_LCD_REV REG32(LCD_REV)
++#define REG_LCD_CTRL REG32(LCD_CTRL)
++#define REG_LCD_STATE REG32(LCD_STATE)
++#define REG_LCD_IID REG32(LCD_IID)
++#define REG_LCD_DA0 REG32(LCD_DA0)
++#define REG_LCD_SA0 REG32(LCD_SA0)
++#define REG_LCD_FID0 REG32(LCD_FID0)
++#define REG_LCD_CMD0 REG32(LCD_CMD0)
++#define REG_LCD_DA1 REG32(LCD_DA1)
++#define REG_LCD_SA1 REG32(LCD_SA1)
++#define REG_LCD_FID1 REG32(LCD_FID1)
++#define REG_LCD_CMD1 REG32(LCD_CMD1)
++
++#define LCD_CTRL_BPP_BIT 0 /* Bits Per Pixel */
++#define LCD_CTRL_BPP_MASK (0x07 << LCD_CTRL_BPP_BIT)
++ #define LCD_CTRL_BPP_1 (0 << LCD_CTRL_BPP_BIT) /* 1 bpp */
++ #define LCD_CTRL_BPP_2 (1 << LCD_CTRL_BPP_BIT) /* 2 bpp */
++ #define LCD_CTRL_BPP_4 (2 << LCD_CTRL_BPP_BIT) /* 4 bpp */
++ #define LCD_CTRL_BPP_8 (3 << LCD_CTRL_BPP_BIT) /* 8 bpp */
++ #define LCD_CTRL_BPP_16 (4 << LCD_CTRL_BPP_BIT) /* 15/16 bpp */
++ #define LCD_CTRL_BPP_18_24 (5 << LCD_CTRL_BPP_BIT) /* 18/24/32 bpp */
++
++#define LCD_CTRL_BST_BIT 28 /* Burst Length Selection */
++#define LCD_CTRL_BST_MASK (0x03 << LCD_CTRL_BST_BIT)
++ #define LCD_CTRL_BST_4 (0 << LCD_CTRL_BST_BIT) /* 4-word */
++ #define LCD_CTRL_BST_8 (1 << LCD_CTRL_BST_BIT) /* 8-word */
++ #define LCD_CTRL_BST_16 (2 << LCD_CTRL_BST_BIT) /* 16-word */
++#define LCD_CTRL_RGB565 (0 << 27) /* RGB565 mode */
++#define LCD_CTRL_RGB555 (1 << 27) /* RGB555 mode */
++#define LCD_CTRL_OFUP (1 << 26) /* Output FIFO underrun protection enable */
++#define LCD_CTRL_FRC_BIT 24 /* STN FRC Algorithm Selection */
++#define LCD_CTRL_FRC_MASK (0x03 << LCD_CTRL_FRC_BIT)
++ #define LCD_CTRL_FRC_16 (0 << LCD_CTRL_FRC_BIT) /* 16 grayscale */
++ #define LCD_CTRL_FRC_4 (1 << LCD_CTRL_FRC_BIT) /* 4 grayscale */
++ #define LCD_CTRL_FRC_2 (2 << LCD_CTRL_FRC_BIT) /* 2 grayscale */
++
++#define CPM_LPCDR (CPM_BASE+0x64)
++#define CPM_CLKGR (CPM_BASE+0x20)
++#define REG_CPM_LPCDR REG32(CPM_LPCDR)
++#define REG_CPM_CLKGR REG32(CPM_CLKGR)
++
++#define __cpm_start_tcu() (REG_CPM_CLKGR &= ~CPM_CLKGR_TCU)
++#define __cpm_stop_lcd() (REG_CPM_CLKGR |= CPM_CLKGR_LCD)
++#define __cpm_set_pixdiv(v) \
++ (REG_CPM_LPCDR = (REG_CPM_LPCDR & ~CPM_LPCDR_PIXDIV_MASK) | ((v) << (CPM_LPCDR_PIXDIV_BIT)))
++#define __cpm_set_ldiv(v) \
++ (REG_CPM_CPCCR = (REG_CPM_CPCCR & ~CPM_CPCCR_LDIV_MASK) | ((v) << (CPM_CPCCR_LDIV_BIT)))
++#define __cpm_start_lcd() (REG_CPM_CLKGR &= ~CPM_CLKGR_LCD)
++
+ #endif /* !__ASSEMBLY__ */
+ #endif /* __JZ4740_H__ */
+diff --git a/arch/mips/lib/board.c b/arch/mips/lib/board.c
+index b14b33e..c2e64d9 100644
+--- a/arch/mips/lib/board.c
++++ b/arch/mips/lib/board.c
+@@ -172,6 +172,12 @@ void board_init_f(ulong bootflag)
+ addr &= ~(4096 - 1);
+ debug("Top of RAM usable for U-Boot at: %08lx\n", addr);
+
++#ifdef CONFIG_LCD
++ /* reserve memory for LCD display (always full pages) */
++ addr = lcd_setmem (addr);
++ gd->fb_base = addr;
++#endif /* CONFIG_LCD */
++
+ /* Reserve memory for U-Boot code, data & bss
+ * round down to next 16 kB limit
+ */
+diff --git a/common/lcd.c b/common/lcd.c
+index b6be800..af1281a 100644
+--- a/common/lcd.c
++++ b/common/lcd.c
+@@ -263,6 +263,13 @@ static void lcd_drawchars(ushort x, ushort y, uchar *str, int count)
+ lcd_color_fg : lcd_color_bg;
+ bits <<= 1;
+ }
++#elif LCD_BPP == LCD_COLOR32
++ uint *m = (uint *)d;
++ for (c=0; c<32; ++c) {
++ *m++ = (bits & 0x80) ?
++ lcd_color_fg : lcd_color_bg;
++ bits <<= 1;
++ }
+ #endif
+ }
+ #if LCD_BPP == LCD_MONOCHROME
+@@ -509,7 +516,7 @@ static inline ushort *configuration_get_cmap(void)
+ return (ushort *)&(cp->lcd_cmap[255 * sizeof(ushort)]);
+ #elif defined(CONFIG_ATMEL_LCD)
+ return (ushort *)(panel_info.mmio + ATMEL_LCDC_LUT(0));
+-#elif !defined(CONFIG_ATMEL_HLCD) && !defined(CONFIG_EXYNOS_FB)
++#elif !defined(CONFIG_ATMEL_HLCD) && !defined(CONFIG_EXYNOS_FB) && !defined(CONFIG_VIDEO_GPM940B0)
+ return panel_info.cmap;
+ #else
+ #if defined(CONFIG_LCD_LOGO)
+diff --git a/drivers/video/Makefile b/drivers/video/Makefile
+index ebb6da8..03625bc 100644
+--- a/drivers/video/Makefile
++++ b/drivers/video/Makefile
+@@ -50,6 +50,7 @@ COBJS-$(CONFIG_VIDEO_SED13806) += sed13806.o
+ COBJS-$(CONFIG_VIDEO_SM501) += sm501.o
+ COBJS-$(CONFIG_VIDEO_SMI_LYNXEM) += smiLynxEM.o videomodes.o
+ COBJS-$(CONFIG_VIDEO_VCXK) += bus_vcxk.o
++COBJS-$(CONFIG_VIDEO_GPM940B0) += nanonote_gpm940b0.o
+
+ COBJS := $(sort $(COBJS-y))
+ SRCS := $(COBJS:.o=.c)
+diff --git a/drivers/video/nanonote_gpm940b0.c b/drivers/video/nanonote_gpm940b0.c
+new file mode 100644
+index 0000000..11efb72
+--- /dev/null
++++ b/drivers/video/nanonote_gpm940b0.c
+@@ -0,0 +1,400 @@
++/*
++ * JzRISC lcd controller
++ *
++ * Xiangfu Liu <xiangfu@sharism.cc>
++ *
++ * 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 of
++ * the License, 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; if not, write to the Free Software
++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ * MA 02111-1307 USA
++ */
++
++#include <config.h>
++#include <common.h>
++#include <lcd.h>
++
++#include <asm/io.h> /* virt_to_phys() */
++#include <asm/jz4740.h>
++
++#include "nanonote_gpm940b0.h"
++
++#define align2(n) (n)=((((n)+1)>>1)<<1)
++#define align4(n) (n)=((((n)+3)>>2)<<2)
++#define align8(n) (n)=((((n)+7)>>3)<<3)
++
++struct jzfb_info {
++ unsigned int cfg; /* panel mode and pin usage etc. */
++ unsigned int w;
++ unsigned int h;
++ unsigned int bpp; /* bit per pixel */
++ unsigned int fclk; /* frame clk */
++ unsigned int hsw; /* hsync width, in pclk */
++ unsigned int vsw; /* vsync width, in line count */
++ unsigned int elw; /* end of line, in pclk */
++ unsigned int blw; /* begin of line, in pclk */
++ unsigned int efw; /* end of frame, in line count */
++ unsigned int bfw; /* begin of frame, in line count */
++};
++
++static struct jzfb_info jzfb = {
++ MODE_8BIT_SERIAL_TFT | PCLK_N | HSYNC_N | VSYNC_N,
++ 320, 240, 32, 70, 1, 1, 273, 140, 1, 20
++};
++
++vidinfo_t panel_info = {
++ 320, 240, LCD_BPP,
++};
++
++void *lcd_base;
++void *lcd_console_address;
++int lcd_line_length;
++int lcd_color_fg;
++int lcd_color_bg;
++short console_col;
++short console_row;
++
++static int jz_lcd_init_mem(void *lcdbase, vidinfo_t *vid)
++{
++ u_long palette_mem_size;
++ struct jz_fb_info *fbi = &vid->jz_fb;
++ int fb_size = vid->vl_row * (vid->vl_col * NBITS (vid->vl_bpix)) / 8;
++
++ fbi->screen = (u_long)lcdbase;
++ fbi->palette_size = 256;
++ palette_mem_size = fbi->palette_size * sizeof(u16);
++
++ debug("jz_lcd.c palette_mem_size = 0x%08lx\n", (u_long) palette_mem_size);
++ /* locate palette and descs at end of page following fb */
++ fbi->palette = (u_long)lcdbase + fb_size + PAGE_SIZE - palette_mem_size;
++
++ return 0;
++}
++
++static void jz_lcd_desc_init(vidinfo_t *vid)
++{
++ struct jz_fb_info * fbi;
++ fbi = &vid->jz_fb;
++ fbi->dmadesc_fblow = (struct jz_fb_dma_descriptor *)((unsigned int)fbi->palette - 3*16);
++ fbi->dmadesc_fbhigh = (struct jz_fb_dma_descriptor *)((unsigned int)fbi->palette - 2*16);
++ fbi->dmadesc_palette = (struct jz_fb_dma_descriptor *)((unsigned int)fbi->palette - 1*16);
++
++ #define BYTES_PER_PANEL (vid->vl_col * vid->vl_row * NBITS(vid->vl_bpix) / 8)
++
++ /* populate descriptors */
++ fbi->dmadesc_fblow->fdadr = virt_to_phys(fbi->dmadesc_fblow);
++ fbi->dmadesc_fblow->fsadr = virt_to_phys((void *)(fbi->screen + BYTES_PER_PANEL));
++ fbi->dmadesc_fblow->fidr = 0;
++ fbi->dmadesc_fblow->ldcmd = BYTES_PER_PANEL / 4 ;
++
++ fbi->fdadr1 = virt_to_phys(fbi->dmadesc_fblow); /* only used in dual-panel mode */
++
++ fbi->dmadesc_fbhigh->fsadr = virt_to_phys((void *)fbi->screen);
++ fbi->dmadesc_fbhigh->fidr = 0;
++ fbi->dmadesc_fbhigh->ldcmd = BYTES_PER_PANEL / 4; /* length in word */
++
++ fbi->dmadesc_palette->fsadr = virt_to_phys((void *)fbi->palette);
++ fbi->dmadesc_palette->fidr = 0;
++ fbi->dmadesc_palette->ldcmd = (fbi->palette_size * 2)/4 | (1<<28);
++
++ if(NBITS(vid->vl_bpix) < 12) {
++ /* assume any mode with <12 bpp is palette driven */
++ fbi->dmadesc_palette->fdadr = virt_to_phys(fbi->dmadesc_fbhigh);
++ fbi->dmadesc_fbhigh->fdadr = virt_to_phys(fbi->dmadesc_palette);
++ /* flips back and forth between pal and fbhigh */
++ fbi->fdadr0 = virt_to_phys(fbi->dmadesc_palette);
++ } else {
++ /* palette shouldn't be loaded in true-color mode */
++ fbi->dmadesc_fbhigh->fdadr = virt_to_phys((void *)fbi->dmadesc_fbhigh);
++ fbi->fdadr0 = virt_to_phys(fbi->dmadesc_fbhigh); /* no pal just fbhigh */
++ }
++}
++
++static int jz_lcd_hw_init(vidinfo_t *vid)
++{
++ struct jz_fb_info *fbi = &vid->jz_fb;
++ unsigned int val = 0;
++ unsigned int pclk;
++ unsigned int stnH;
++ int pll_div;
++
++ /* Setting Control register */
++ switch (jzfb.bpp) {
++ case 1:
++ val |= LCD_CTRL_BPP_1;
++ break;
++ case 2:
++ val |= LCD_CTRL_BPP_2;
++ break;
++ case 4:
++ val |= LCD_CTRL_BPP_4;
++ break;
++ case 8:
++ val |= LCD_CTRL_BPP_8;
++ break;
++ case 15:
++ val |= LCD_CTRL_RGB555;
++ case 16:
++ val |= LCD_CTRL_BPP_16;
++ break;
++ case 17 ... 32:
++ val |= LCD_CTRL_BPP_18_24; /* target is 4bytes/pixel */
++ break;
++
++ default:
++ printf("jz_lcd.c The BPP %d is not supported\n", jzfb.bpp);
++ val |= LCD_CTRL_BPP_16;
++ break;
++ }
++
++ switch (jzfb.cfg & MODE_MASK) {
++ case MODE_STN_MONO_DUAL:
++ case MODE_STN_COLOR_DUAL:
++ case MODE_STN_MONO_SINGLE:
++ case MODE_STN_COLOR_SINGLE:
++ switch (jzfb.bpp) {
++ case 1:
++ /* val |= LCD_CTRL_PEDN; */
++ case 2:
++ val |= LCD_CTRL_FRC_2;
++ break;
++ case 4:
++ val |= LCD_CTRL_FRC_4;
++ break;
++ case 8:
++ default:
++ val |= LCD_CTRL_FRC_16;
++ break;
++ }
++ break;
++ }
++
++ val |= LCD_CTRL_BST_16; /* Burst Length is 16WORD=64Byte */
++ val |= LCD_CTRL_OFUP; /* OutFIFO underrun protect */
++
++ switch (jzfb.cfg & MODE_MASK) {
++ case MODE_STN_MONO_DUAL:
++ case MODE_STN_COLOR_DUAL:
++ case MODE_STN_MONO_SINGLE:
++ case MODE_STN_COLOR_SINGLE:
++ switch (jzfb.cfg & STN_DAT_PINMASK) {
++ case STN_DAT_PIN1:
++ /* Do not adjust the hori-param value. */
++ break;
++ case STN_DAT_PIN2:
++ align2(jzfb.hsw);
++ align2(jzfb.elw);
++ align2(jzfb.blw);
++ break;
++ case STN_DAT_PIN4:
++ align4(jzfb.hsw);
++ align4(jzfb.elw);
++ align4(jzfb.blw);
++ break;
++ case STN_DAT_PIN8:
++ align8(jzfb.hsw);
++ align8(jzfb.elw);
++ align8(jzfb.blw);
++ break;
++ }
++ break;
++ }
++
++ REG_LCD_CTRL = val;
++
++ switch (jzfb.cfg & MODE_MASK) {
++ case MODE_STN_MONO_DUAL:
++ case MODE_STN_COLOR_DUAL:
++ case MODE_STN_MONO_SINGLE:
++ case MODE_STN_COLOR_SINGLE:
++ if (((jzfb.cfg & MODE_MASK) == MODE_STN_MONO_DUAL) ||
++ ((jzfb.cfg & MODE_MASK) == MODE_STN_COLOR_DUAL))
++ stnH = jzfb.h >> 1;
++ else
++ stnH = jzfb.h;
++
++ REG_LCD_VSYNC = (0 << 16) | jzfb.vsw;
++ REG_LCD_HSYNC = ((jzfb.blw+jzfb.w) << 16) | (jzfb.blw+jzfb.w+jzfb.hsw);
++
++ /* Screen setting */
++ REG_LCD_VAT = ((jzfb.blw + jzfb.w + jzfb.hsw + jzfb.elw) << 16) | (stnH + jzfb.vsw + jzfb.bfw + jzfb.efw);
++ REG_LCD_DAH = (jzfb.blw << 16) | (jzfb.blw + jzfb.w);
++ REG_LCD_DAV = (0 << 16) | (stnH);
++
++ /* AC BIAs signal */
++ REG_LCD_PS = (0 << 16) | (stnH+jzfb.vsw+jzfb.efw+jzfb.bfw);
++
++ break;
++
++ case MODE_TFT_GEN:
++ case MODE_TFT_SHARP:
++ case MODE_TFT_CASIO:
++ case MODE_TFT_SAMSUNG:
++ case MODE_8BIT_SERIAL_TFT:
++ case MODE_TFT_18BIT:
++ REG_LCD_VSYNC = (0 << 16) | jzfb.vsw;
++ REG_LCD_HSYNC = (0 << 16) | jzfb.hsw;
++ REG_LCD_DAV =((jzfb.vsw+jzfb.bfw) << 16) | (jzfb.vsw +jzfb.bfw+jzfb.h);
++ REG_LCD_DAH = ((jzfb.hsw + jzfb.blw) << 16) | (jzfb.hsw + jzfb.blw + jzfb.w );
++ REG_LCD_VAT = (((jzfb.blw + jzfb.w + jzfb.elw + jzfb.hsw)) << 16) \
++ | (jzfb.vsw + jzfb.bfw + jzfb.h + jzfb.efw);
++ break;
++ }
++
++ switch (jzfb.cfg & MODE_MASK) {
++ case MODE_TFT_SAMSUNG:
++ {
++ unsigned int total, tp_s, tp_e, ckv_s, ckv_e;
++ unsigned int rev_s, rev_e, inv_s, inv_e;
++
++ pclk = val * (jzfb.w + jzfb.hsw + jzfb.elw + jzfb.blw) *
++ (jzfb.h + jzfb.vsw + jzfb.efw + jzfb.bfw); /* Pixclk */
++
++ total = jzfb.blw + jzfb.w + jzfb.elw + jzfb.hsw;
++ tp_s = jzfb.blw + jzfb.w + 1;
++ tp_e = tp_s + 1;
++ ckv_s = tp_s - pclk/(1000000000/4100);
++ ckv_e = tp_s + total;
++ rev_s = tp_s - 11; /* -11.5 clk */
++ rev_e = rev_s + total;
++ inv_s = tp_s;
++ inv_e = inv_s + total;
++ REG_LCD_CLS = (tp_s << 16) | tp_e;
++ REG_LCD_PS = (ckv_s << 16) | ckv_e;
++ REG_LCD_SPL = (rev_s << 16) | rev_e;
++ REG_LCD_REV = (inv_s << 16) | inv_e;
++ jzfb.cfg |= STFT_REVHI | STFT_SPLHI;
++ break;
++ }
++ case MODE_TFT_SHARP:
++ {
++ unsigned int total, cls_s, cls_e, ps_s, ps_e;
++ unsigned int spl_s, spl_e, rev_s, rev_e;
++ total = jzfb.blw + jzfb.w + jzfb.elw + jzfb.hsw;
++ spl_s = 1;
++ spl_e = spl_s + 1;
++ cls_s = 0;
++ cls_e = total - 60; /* > 4us (pclk = 80ns) */
++ ps_s = cls_s;
++ ps_e = cls_e;
++ rev_s = total - 40; /* > 3us (pclk = 80ns) */
++ rev_e = rev_s + total;
++ jzfb.cfg |= STFT_PSHI;
++ REG_LCD_SPL = (spl_s << 16) | spl_e;
++ REG_LCD_CLS = (cls_s << 16) | cls_e;
++ REG_LCD_PS = (ps_s << 16) | ps_e;
++ REG_LCD_REV = (rev_s << 16) | rev_e;
++ break;
++ }
++ case MODE_TFT_CASIO:
++ break;
++ }
++
++ /* Configure the LCD panel */
++ REG_LCD_CFG = jzfb.cfg;
++
++ /* Timing setting */
++ __cpm_stop_lcd();
++
++ val = jzfb.fclk; /* frame clk */
++ if ( (jzfb.cfg & MODE_MASK) != MODE_8BIT_SERIAL_TFT) {
++ pclk = val * (jzfb.w + jzfb.hsw + jzfb.elw + jzfb.blw) *
++ (jzfb.h + jzfb.vsw + jzfb.efw + jzfb.bfw); /* Pixclk */
++ } else {
++ /* serial mode: Hsync period = 3*Width_Pixel */
++ pclk = val * (jzfb.w*3 + jzfb.hsw + jzfb.elw + jzfb.blw) *
++ (jzfb.h + jzfb.vsw + jzfb.efw + jzfb.bfw); /* Pixclk */
++ }
++
++ if (((jzfb.cfg & MODE_MASK) == MODE_STN_COLOR_SINGLE) ||
++ ((jzfb.cfg & MODE_MASK) == MODE_STN_COLOR_DUAL))
++ pclk = (pclk * 3);
++
++ if (((jzfb.cfg & MODE_MASK) == MODE_STN_COLOR_SINGLE) ||
++ ((jzfb.cfg & MODE_MASK) == MODE_STN_COLOR_DUAL) ||
++ ((jzfb.cfg & MODE_MASK) == MODE_STN_MONO_SINGLE) ||
++ ((jzfb.cfg & MODE_MASK) == MODE_STN_MONO_DUAL))
++ pclk = pclk >> ((jzfb.cfg & STN_DAT_PINMASK) >> 4);
++
++ if (((jzfb.cfg & MODE_MASK) == MODE_STN_COLOR_DUAL) ||
++ ((jzfb.cfg & MODE_MASK) == MODE_STN_MONO_DUAL))
++ pclk >>= 1;
++
++ pll_div = (REG_CPM_CPCCR & CPM_CPCCR_PCS); /* clock source,0:pllout/2 1: pllout */
++ pll_div = pll_div ? 1 : 2;
++ val = (__cpm_get_pllout() / pll_div) / pclk;
++ val--;
++ if (val > 0x1ff) {
++ printf("CPM_LPCDR too large, set it to 0x1ff\n");
++ val = 0x1ff;
++ }
++ __cpm_set_pixdiv(val);
++
++ val = pclk * 3 ; /* LCDClock > 2.5*Pixclock */
++ if (val > 150000000) {
++ printf("Warning: LCDClock=%d\n, LCDClock must less or equal to 150MHz.\n", val);
++ printf("Change LCDClock to 150MHz\n");
++ val = 150000000;
++ }
++ val = (__cpm_get_pllout() / pll_div) / val;
++ val--;
++ if (val > 0x1f) {
++ printf("CPM_CPCCR.LDIV too large, set it to 0x1f\n");
++ val = 0x1f;
++ }
++ __cpm_set_ldiv( val );
++ REG_CPM_CPCCR |= CPM_CPCCR_CE ; /* update divide */
++
++ __cpm_start_lcd();
++ udelay(1000);
++
++ REG_LCD_DA0 = fbi->fdadr0; /* frame descripter*/
++
++ if (((jzfb.cfg & MODE_MASK) == MODE_STN_COLOR_DUAL) ||
++ ((jzfb.cfg & MODE_MASK) == MODE_STN_MONO_DUAL))
++ REG_LCD_DA1 = fbi->fdadr1; /* frame descripter*/
++
++ return 0;
++}
++
++void lcd_ctrl_init (void *lcdbase)
++{
++ __lcd_display_pin_init();
++ __lcd_display_on() ;
++
++ jz_lcd_init_mem(lcdbase, &panel_info);
++ jz_lcd_desc_init(&panel_info);
++ jz_lcd_hw_init(&panel_info);
++
++}
++
++/*
++ * Before enabled lcd controller, lcd registers should be configured correctly.
++ */
++void lcd_enable (void)
++{
++ REG_LCD_CTRL &= ~(1<<4); /* LCDCTRL.DIS */
++ REG_LCD_CTRL |= 1<<3; /* LCDCTRL.ENA*/
++}
++
++void lcd_disable (void)
++{
++ REG_LCD_CTRL |= (1<<4);
++}
++
++void lcd_setcolreg (ushort regno, ushort red, ushort green, ushort blue)
++{
++}
++
++void lcd_initcolregs (void)
++{
++}
+diff --git a/drivers/video/nanonote_gpm940b0.h b/drivers/video/nanonote_gpm940b0.h
+new file mode 100644
+index 0000000..efe491e
+--- /dev/null
++++ b/drivers/video/nanonote_gpm940b0.h
+@@ -0,0 +1,135 @@
++/*
++ * JzRISC lcd controller
++ *
++ * Xiangfu Liu <xiangfu@sharism.cc>
++ *
++ * 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 of
++ * the License, 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; if not, write to the Free Software
++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ * MA 02111-1307 USA
++ */
++
++#ifndef __QI_LB60_GPM940B0_H__
++#define __QI_LB60_GPM940B0_H__
++
++struct lcd_desc{
++ unsigned int next_desc; /* LCDDAx */
++ unsigned int databuf; /* LCDSAx */
++ unsigned int frame_id; /* LCDFIDx */
++ unsigned int cmd; /* LCDCMDx */
++};
++
++#define MODE_MASK 0x0f
++#define MODE_TFT_GEN 0x00
++#define MODE_TFT_SHARP 0x01
++#define MODE_TFT_CASIO 0x02
++#define MODE_TFT_SAMSUNG 0x03
++#define MODE_CCIR656_NONINT 0x04
++#define MODE_CCIR656_INT 0x05
++#define MODE_STN_COLOR_SINGLE 0x08
++#define MODE_STN_MONO_SINGLE 0x09
++#define MODE_STN_COLOR_DUAL 0x0a
++#define MODE_STN_MONO_DUAL 0x0b
++#define MODE_8BIT_SERIAL_TFT 0x0c
++
++#define MODE_TFT_18BIT (1<<7)
++
++#define STN_DAT_PIN1 (0x00 << 4)
++#define STN_DAT_PIN2 (0x01 << 4)
++#define STN_DAT_PIN4 (0x02 << 4)
++#define STN_DAT_PIN8 (0x03 << 4)
++#define STN_DAT_PINMASK STN_DAT_PIN8
++
++#define STFT_PSHI (1 << 15)
++#define STFT_CLSHI (1 << 14)
++#define STFT_SPLHI (1 << 13)
++#define STFT_REVHI (1 << 12)
++
++#define SYNC_MASTER (0 << 16)
++#define SYNC_SLAVE (1 << 16)
++
++#define DE_P (0 << 9)
++#define DE_N (1 << 9)
++
++#define PCLK_P (0 << 10)
++#define PCLK_N (1 << 10)
++
++#define HSYNC_P (0 << 11)
++#define HSYNC_N (1 << 11)
++
++#define VSYNC_P (0 << 8)
++#define VSYNC_N (1 << 8)
++
++#define DATA_NORMAL (0 << 17)
++#define DATA_INVERSE (1 << 17)
++
++
++/* Jz LCDFB supported I/O controls. */
++#define FBIOSETBACKLIGHT 0x4688
++#define FBIODISPON 0x4689
++#define FBIODISPOFF 0x468a
++#define FBIORESET 0x468b
++#define FBIOPRINT_REG 0x468c
++
++/*
++ * LCD panel specific definition
++ */
++#define MODE (0xc9) /* 8bit serial RGB */
++
++#define __spi_write_reg1(reg, val) \
++do { \
++ unsigned char no; \
++ unsigned short value; \
++ unsigned char a=reg; \
++ unsigned char b=val; \
++ __gpio_set_pin(SPEN); \
++ __gpio_set_pin(SPCK); \
++ __gpio_clear_pin(SPDA); \
++ __gpio_clear_pin(SPEN); \
++ value=((a<<8)|(b&0xFF)); \
++ for(no=0;no<16;no++) \
++ { \
++ __gpio_clear_pin(SPCK); \
++ if((value&0x8000)==0x8000) \
++ __gpio_set_pin(SPDA); \
++ else \
++ __gpio_clear_pin(SPDA); \
++ __gpio_set_pin(SPCK); \
++ value=(value<<1); \
++ } \
++ __gpio_set_pin(SPEN); \
++} while (0)
++
++#define __lcd_display_pin_init() \
++do { \
++ __cpm_start_tcu(); \
++ __gpio_as_output(SPEN); /* use SPDA */ \
++ __gpio_as_output(SPCK); /* use SPCK */ \
++ __gpio_as_output(SPDA); /* use SPDA */ \
++} while (0)
++
++#define __lcd_display_on() \
++do { \
++ __spi_write_reg1(0x05, 0x1e); \
++ __spi_write_reg1(0x05, 0x5e); \
++ __spi_write_reg1(0x07, 0x8d); \
++ __spi_write_reg1(0x13, 0x01); \
++ __spi_write_reg1(0x05, 0x5f); \
++} while (0)
++
++#define __lcd_display_off() \
++do { \
++ __spi_write_reg1(0x05, 0x5e); \
++} while (0)
++
++#endif /* __QI_LB60_GPM940B0_H__ */
+diff --git a/include/configs/qi_lb60.h b/include/configs/qi_lb60.h
+index 52b370c..d3e78ad 100644
+--- a/include/configs/qi_lb60.h
++++ b/include/configs/qi_lb60.h
+@@ -32,6 +32,13 @@
+ * Miscellaneous configurable options
+ */
+ #define CONFIG_NANONOTE
++
++#define CONFIG_LCD
++#define CONFIG_SYS_WHITE_ON_BLACK
++#define LCD_BPP LCD_COLOR32
++#define CONFIG_VIDEO_GPM940B0
++
++
+ #define CONFIG_JZ4740_MMC
+ #define CONFIG_MMC 1
+ #define CONFIG_FAT 1
+diff --git a/include/lcd.h b/include/lcd.h
+index 42070d7..6de5482 100644
+--- a/include/lcd.h
++++ b/include/lcd.h
+@@ -263,8 +263,44 @@ typedef struct vidinfo {
+
+ void init_panel_info(vidinfo_t *vid);
+
+-#else
++#elif defined(CONFIG_JZSOC)
++/*
++ * LCD controller stucture for JZSOC: JZ4740
++ */
++struct jz_fb_dma_descriptor {
++ u_long fdadr; /* Frame descriptor address register */
++ u_long fsadr; /* Frame source address register */
++ u_long fidr; /* Frame ID register */
++ u_long ldcmd; /* Command register */
++};
++
++/*
++ * Jz LCD info
++ */
++struct jz_fb_info {
++
++ u_long fdadr0; /* physical address of frame/palette descriptor */
++ u_long fdadr1; /* physical address of frame descriptor */
++
++ /* DMA descriptors */
++ struct jz_fb_dma_descriptor * dmadesc_fblow;
++ struct jz_fb_dma_descriptor * dmadesc_fbhigh;
++ struct jz_fb_dma_descriptor * dmadesc_palette;
++ u_long screen; /* address of frame buffer */
++ u_long palette; /* address of palette memory */
++ u_int palette_size;
++};
++typedef struct vidinfo {
++ ushort vl_col; /* Number of columns (i.e. 640) */
++ ushort vl_row; /* Number of rows (i.e. 480) */
++ u_char vl_bpix; /* Bits per pixel, 0 = 1, 1 = 2, 2 = 4, 3 = 8 */
++
++ struct jz_fb_info jz_fb;
++} vidinfo_t;
++
++extern vidinfo_t panel_info;
+
++#else
+ typedef struct vidinfo {
+ ushort vl_col; /* Number of columns (i.e. 160) */
+ ushort vl_row; /* Number of rows (i.e. 100) */
+@@ -318,6 +354,7 @@ void lcd_show_board_info(void);
+ #define LCD_COLOR4 2
+ #define LCD_COLOR8 3
+ #define LCD_COLOR16 4
++#define LCD_COLOR32 5
+
+ /*----------------------------------------------------------------------*/
+ #if defined(CONFIG_LCD_INFO_BELOW_LOGO)
+@@ -369,7 +406,7 @@ void lcd_show_board_info(void);
+ # define CONSOLE_COLOR_GREY 14
+ # define CONSOLE_COLOR_WHITE 15 /* Must remain last / highest */
+
+-#else
++#elif LCD_BPP == LCD_COLOR16
+
+ /*
+ * 16bpp color definitions
+@@ -377,6 +414,15 @@ void lcd_show_board_info(void);
+ # define CONSOLE_COLOR_BLACK 0x0000
+ # define CONSOLE_COLOR_WHITE 0xffff /* Must remain last / highest */
+
++#elif LCD_BPP == LCD_COLOR32
++/*
++ * 18,24,32 bpp color definitions
++ */
++# define CONSOLE_COLOR_BLACK 0x00000000
++# define CONSOLE_COLOR_WHITE 0xffffffff /* Must remain last / highest */
++
++#else
++
+ #endif /* color definitions */
+
+ /************************************************************************/
+@@ -406,7 +452,7 @@ void lcd_show_board_info(void);
+ #if LCD_BPP == LCD_MONOCHROME
+ # define COLOR_MASK(c) ((c) | (c) << 1 | (c) << 2 | (c) << 3 | \
+ (c) << 4 | (c) << 5 | (c) << 6 | (c) << 7)
+-#elif (LCD_BPP == LCD_COLOR8) || (LCD_BPP == LCD_COLOR16)
++#elif (LCD_BPP == LCD_COLOR8) || (LCD_BPP == LCD_COLOR16) || (LCD_BPP == LCD_COLOR32)
+ # define COLOR_MASK(c) (c)
+ #else
+ # error Unsupported LCD BPP.
+--
+1.7.9.5
+
diff --git a/package/boot/uboot-xburst/patches/.svn/text-base/0006-enable-silent-console.patch.svn-base b/package/boot/uboot-xburst/patches/.svn/text-base/0006-enable-silent-console.patch.svn-base
new file mode 100644
index 0000000..ebd6a6a
--- /dev/null
+++ b/package/boot/uboot-xburst/patches/.svn/text-base/0006-enable-silent-console.patch.svn-base
@@ -0,0 +1,60 @@
+From 5eb4d4c598f2806bd1b3d1140e917bfead7851ad Mon Sep 17 00:00:00 2001
+From: Xiangfu <xiangfu@openmobilefree.net>
+Date: Wed, 10 Oct 2012 23:51:26 +0800
+Subject: [PATCH 6/6] enable silent console
+
+---
+ common/console.c | 16 ++++++++++++++++
+ include/configs/qi_lb60.h | 2 ++
+ 2 files changed, 18 insertions(+)
+
+diff --git a/common/console.c b/common/console.c
+index 1177f7d..e8a2078 100644
+--- a/common/console.c
++++ b/common/console.c
+@@ -685,6 +685,14 @@ done:
+
+ gd->flags |= GD_FLG_DEVINIT; /* device initialization completed */
+
++#ifdef CONFIG_SILENT_CONSOLE
++ /* Check one more time the contents of the silent environment
++ * variable, because if the environment is loaded from NAND it was
++ * not available when console_init_f() was called */
++ if (getenv("silent") != NULL)
++ gd->flags |= GD_FLG_SILENT;
++#endif
++
+ stdio_print_current_devices();
+
+ #ifdef CONFIG_SYS_CONSOLE_ENV_OVERWRITE
+@@ -760,6 +768,14 @@ int console_init_r(void)
+
+ gd->flags |= GD_FLG_DEVINIT; /* device initialization completed */
+
++#ifdef CONFIG_SILENT_CONSOLE
++ /* Check one more time the contents of the silent environment
++ * variable, because if the environment is loaded from NAND it was
++ * not available when console_init_f() was called */
++ if (getenv("silent") != NULL)
++ gd->flags |= GD_FLG_SILENT;
++#endif
++
+ stdio_print_current_devices();
+
+ /* Setting environment variables */
+diff --git a/include/configs/qi_lb60.h b/include/configs/qi_lb60.h
+index d3e78ad..a3534ff 100644
+--- a/include/configs/qi_lb60.h
++++ b/include/configs/qi_lb60.h
+@@ -102,6 +102,8 @@
+ #define CONFIG_SYS_NO_FLASH
+ #define CONFIG_SYS_FLASH_BASE 0 /* init flash_base as 0 */
+
++#define CONFIG_SILENT_CONSOLE 1 /* Enable silent console */
++
+ /*
+ * Command line configuration
+ */
+--
+1.7.9.5
+
diff --git a/package/boot/uboot-xburst/patches/0001-qi_lb60-add-nand-spl-support.patch b/package/boot/uboot-xburst/patches/0001-qi_lb60-add-nand-spl-support.patch
new file mode 100644
index 0000000..e770243
--- /dev/null
+++ b/package/boot/uboot-xburst/patches/0001-qi_lb60-add-nand-spl-support.patch
@@ -0,0 +1,894 @@
+From 0329cf7965956a5a7044827e0ce88ae8d5150e54 Mon Sep 17 00:00:00 2001
+From: Xiangfu <xiangfu@openmobilefree.net>
+Date: Fri, 12 Oct 2012 09:46:58 +0800
+Subject: [PATCH 1/6] qi_lb60: add nand spl support
+
+ The JZ4740 CPU can load 8KB from two different addresses:
+ 1. the normal area up to 8KB starting from NAND flash address 0x00000000
+ 2. the backup area up to 8KB starting from NAND flash address 0x00002000
+
+Signed-off-by: Xiangfu <xiangfu@openmobilefree.net>
+---
+ Makefile | 12 +++
+ arch/mips/cpu/xburst/Makefile | 7 +-
+ arch/mips/cpu/xburst/cpu.c | 4 +
+ arch/mips/cpu/xburst/jz4740.c | 82 +++++++----------
+ arch/mips/cpu/xburst/spl/Makefile | 47 ++++++++++
+ arch/mips/cpu/xburst/spl/start.S | 63 +++++++++++++
+ board/qi/qi_lb60/Makefile | 4 +
+ board/qi/qi_lb60/qi_lb60-spl.c | 30 +++++++
+ board/qi/qi_lb60/qi_lb60.c | 8 +-
+ board/qi/qi_lb60/u-boot-spl.lds | 61 +++++++++++++
+ drivers/mtd/nand/jz4740_nand.c | 39 ++++++++-
+ include/configs/qi_lb60.h | 175 ++++++++++++++++++-------------------
+ 12 files changed, 386 insertions(+), 146 deletions(-)
+ create mode 100644 arch/mips/cpu/xburst/spl/Makefile
+ create mode 100644 arch/mips/cpu/xburst/spl/start.S
+ create mode 100644 board/qi/qi_lb60/qi_lb60-spl.c
+ create mode 100644 board/qi/qi_lb60/u-boot-spl.lds
+
+diff --git a/Makefile b/Makefile
+index 34d9075..a22778e 100644
+--- a/Makefile
++++ b/Makefile
+@@ -393,6 +393,10 @@ ALL-y += $(obj)u-boot-nodtb-tegra.bin
+ endif
+ endif
+
++ifeq ($(CPU),xburst)
++ALL-y += $(obj)u-boot-xburst.bin
++endif
++
+ all: $(ALL-y) $(SUBDIR_EXAMPLES)
+
+ $(obj)u-boot.dtb: $(obj)u-boot
+@@ -506,6 +510,14 @@ $(obj)u-boot-nodtb-tegra.bin: $(obj)spl/u-boot-spl.bin $(obj)u-boot.bin
+ endif
+ endif
+
++ifeq ($(CPU),xburst)
++$(obj)u-boot-xburst.bin: $(obj)spl/u-boot-spl.bin $(obj)u-boot.bin
++ dd if=$(obj)spl/u-boot-spl.bin of=$(obj)spl/u-boot-pad.bin conv=sync bs=8192 count=1
++ dd if=$(obj)spl/u-boot-spl.bin of=$(obj)spl/u-boot-pad.bin conv=sync,notrunc oflag=append bs=8192 count=1
++ tr '\0' '\377' < /dev/zero | dd of=$(obj)spl/u-boot-pad.bin conv=sync,notrunc oflag=append bs=16384 count=1
++ cat $(obj)spl/u-boot-pad.bin u-boot.bin > $@
++endif
++
+ ifeq ($(CONFIG_SANDBOX),y)
+ GEN_UBOOT = \
+ cd $(LNDIR) && $(CC) $(SYMS) -T $(obj)u-boot.lds \
+diff --git a/arch/mips/cpu/xburst/Makefile b/arch/mips/cpu/xburst/Makefile
+index b1f2ae4..ec35e55 100644
+--- a/arch/mips/cpu/xburst/Makefile
++++ b/arch/mips/cpu/xburst/Makefile
+@@ -24,9 +24,12 @@ include $(TOPDIR)/config.mk
+
+ LIB = $(obj)lib$(CPU).o
+
++COBJS-y = cpu.o jz_serial.o
++
++ifneq ($(CONFIG_SPL_BUILD),y)
+ START = start.o
+-SOBJS-y =
+-COBJS-y = cpu.o timer.o jz_serial.o
++COBJS-y += timer.o
++endif
+
+ COBJS-$(CONFIG_JZ4740) += jz4740.o
+
+diff --git a/arch/mips/cpu/xburst/cpu.c b/arch/mips/cpu/xburst/cpu.c
+index ddcbfaa..1432838 100644
+--- a/arch/mips/cpu/xburst/cpu.c
++++ b/arch/mips/cpu/xburst/cpu.c
+@@ -42,6 +42,8 @@
+ : \
+ : "i" (op), "R" (*(unsigned char *)(addr)))
+
++#ifndef CONFIG_SPL_BUILD
++
+ void __attribute__((weak)) _machine_restart(void)
+ {
+ struct jz4740_wdt *wdt = (struct jz4740_wdt *)JZ4740_WDT_BASE;
+@@ -109,6 +111,8 @@ void invalidate_dcache_range(ulong start_addr, ulong stop)
+ cache_op(Hit_Invalidate_D, addr);
+ }
+
++#endif
++
+ void flush_icache_all(void)
+ {
+ u32 addr, t = 0;
+diff --git a/arch/mips/cpu/xburst/jz4740.c b/arch/mips/cpu/xburst/jz4740.c
+index c0b9817..8816aa3 100644
+--- a/arch/mips/cpu/xburst/jz4740.c
++++ b/arch/mips/cpu/xburst/jz4740.c
+@@ -32,31 +32,19 @@ int disable_interrupts(void)
+ return 0;
+ }
+
+-/*
+- * PLL output clock = EXTAL * NF / (NR * NO)
+- * NF = FD + 2, NR = RD + 2
+- * NO = 1 (if OD = 0), NO = 2 (if OD = 1 or 2), NO = 4 (if OD = 3)
+- */
+ void pll_init(void)
+ {
+ struct jz4740_cpm *cpm = (struct jz4740_cpm *)JZ4740_CPM_BASE;
+
+- register unsigned int cfcr, plcr1;
+- int n2FR[33] = {
+- 0, 0, 1, 2, 3, 0, 4, 0, 5, 0, 0, 0, 6, 0, 0, 0,
+- 7, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0,
+- 9
+- };
+- int div[5] = {1, 3, 3, 3, 3}; /* divisors of I:S:P:L:M */
+- int nf, pllout2;
++ register unsigned int cfcr, plcr;
++ unsigned int nf, pllout2;
+
+ cfcr = CPM_CPCCR_CLKOEN |
+- CPM_CPCCR_PCS |
+- (n2FR[div[0]] << CPM_CPCCR_CDIV_BIT) |
+- (n2FR[div[1]] << CPM_CPCCR_HDIV_BIT) |
+- (n2FR[div[2]] << CPM_CPCCR_PDIV_BIT) |
+- (n2FR[div[3]] << CPM_CPCCR_MDIV_BIT) |
+- (n2FR[div[4]] << CPM_CPCCR_LDIV_BIT);
++ (0 << CPM_CPCCR_CDIV_BIT) |
++ (2 << CPM_CPCCR_HDIV_BIT) |
++ (2 << CPM_CPCCR_PDIV_BIT) |
++ (2 << CPM_CPCCR_MDIV_BIT) |
++ (2 << CPM_CPCCR_LDIV_BIT);
+
+ pllout2 = (cfcr & CPM_CPCCR_PCS) ?
+ CONFIG_SYS_CPU_SPEED : (CONFIG_SYS_CPU_SPEED / 2);
+@@ -65,15 +53,18 @@ void pll_init(void)
+ writel(pllout2 / 48000000 - 1, &cpm->uhccdr);
+
+ nf = CONFIG_SYS_CPU_SPEED * 2 / CONFIG_SYS_EXTAL;
+- plcr1 = ((nf - 2) << CPM_CPPCR_PLLM_BIT) | /* FD */
++ plcr = ((nf - 2) << CPM_CPPCR_PLLM_BIT) | /* FD */
+ (0 << CPM_CPPCR_PLLN_BIT) | /* RD=0, NR=2 */
+ (0 << CPM_CPPCR_PLLOD_BIT) | /* OD=0, NO=1 */
+- (0x20 << CPM_CPPCR_PLLST_BIT) | /* PLL stable time */
++ (0x32 << CPM_CPPCR_PLLST_BIT) | /* PLL stable time */
+ CPM_CPPCR_PLLEN; /* enable PLL */
+
+ /* init PLL */
+ writel(cfcr, &cpm->cpccr);
+- writel(plcr1, &cpm->cppcr);
++ writel(plcr, &cpm->cppcr);
++
++ while (!(readl(&cpm->cppcr) & CPM_CPPCR_PLLS))
++ ;
+ }
+
+ void sdram_init(void)
+@@ -92,26 +83,12 @@ void sdram_init(void)
+ 2 << EMC_DMCR_TCL_BIT /* CAS latency is 3 */
+ };
+
+- int div[] = {1, 2, 3, 4, 6, 8, 12, 16, 24, 32};
+-
+ cpu_clk = CONFIG_SYS_CPU_SPEED;
+- mem_clk = cpu_clk * div[__cpm_get_cdiv()] / div[__cpm_get_mdiv()];
++ mem_clk = 84000000;
+
+ writel(0, &emc->bcr); /* Disable bus release */
+ writew(0, &emc->rtcsr); /* Disable clock for counting */
+
+- /* Fault DMCR value for mode register setting*/
+-#define SDRAM_ROW0 11
+-#define SDRAM_COL0 8
+-#define SDRAM_BANK40 0
+-
+- dmcr0 = ((SDRAM_ROW0 - 11) << EMC_DMCR_RA_BIT) |
+- ((SDRAM_COL0 - 8) << EMC_DMCR_CA_BIT) |
+- (SDRAM_BANK40 << EMC_DMCR_BA_BIT) |
+- (SDRAM_BW16 << EMC_DMCR_BW_BIT) |
+- EMC_DMCR_EPIN |
+- cas_latency_dmcr[((SDRAM_CASL == 3) ? 1 : 0)];
+-
+ /* Basic DMCR value */
+ dmcr = ((SDRAM_ROW - 11) << EMC_DMCR_RA_BIT) |
+ ((SDRAM_COL - 8) << EMC_DMCR_CA_BIT) |
+@@ -128,31 +105,31 @@ void sdram_init(void)
+ if (tmp > 11)
+ tmp = 11;
+ dmcr |= (tmp - 4) << EMC_DMCR_TRAS_BIT;
+- tmp = SDRAM_RCD / ns;
+
++ tmp = SDRAM_RCD / ns;
+ if (tmp > 3)
+ tmp = 3;
+ dmcr |= tmp << EMC_DMCR_RCD_BIT;
+- tmp = SDRAM_TPC / ns;
+
++ tmp = SDRAM_TPC / ns;
+ if (tmp > 7)
+ tmp = 7;
+ dmcr |= tmp << EMC_DMCR_TPC_BIT;
+- tmp = SDRAM_TRWL / ns;
+
++ tmp = SDRAM_TRWL / ns;
+ if (tmp > 3)
+ tmp = 3;
+ dmcr |= tmp << EMC_DMCR_TRWL_BIT;
+- tmp = (SDRAM_TRAS + SDRAM_TPC) / ns;
+
++ tmp = (SDRAM_TRAS + SDRAM_TPC) / ns;
+ if (tmp > 14)
+ tmp = 14;
+ dmcr |= ((tmp + 1) >> 1) << EMC_DMCR_TRC_BIT;
+
+ /* SDRAM mode value */
+- sdmode = EMC_SDMR_BT_SEQ |
+- EMC_SDMR_OM_NORMAL |
+- EMC_SDMR_BL_4 |
++ sdmode = EMC_SDMR_BT_SEQ |
++ EMC_SDMR_OM_NORMAL |
++ EMC_SDMR_BL_4 |
+ cas_latency_sdmr[((SDRAM_CASL == 3) ? 1 : 0)];
+
+ /* Stage 1. Precharge all banks by writing SDMR with DMCR.MRSET=0 */
+@@ -172,8 +149,8 @@ void sdram_init(void)
+ if (tmp > 0xff)
+ tmp = 0xff;
+ writew(tmp, &emc->rtcor);
++
+ writew(0, &emc->rtcnt);
+- /* Divisor is 64, CKO/64 */
+ writew(EMC_RTCSR_CKS_64, &emc->rtcsr);
+
+ /* Wait for number of auto-refresh cycles */
+@@ -182,13 +159,17 @@ void sdram_init(void)
+ ;
+
+ /* Stage 3. Mode Register Set */
++ dmcr0 = (11 << EMC_DMCR_RA_BIT) |
++ (8 << EMC_DMCR_CA_BIT) |
++ (0 << EMC_DMCR_BA_BIT) |
++ EMC_DMCR_EPIN |
++ (SDRAM_BW16 << EMC_DMCR_BW_BIT) |
++ cas_latency_dmcr[((SDRAM_CASL == 3) ? 1 : 0)];
+ writel(dmcr0 | EMC_DMCR_RFSH | EMC_DMCR_MRSET, &emc->dmcr);
+ writeb(0, JZ4740_EMC_SDMR0 | sdmode);
+
+ /* Set back to basic DMCR value */
+ writel(dmcr | EMC_DMCR_RFSH | EMC_DMCR_MRSET, &emc->dmcr);
+-
+- /* everything is ok now */
+ }
+
+ DECLARE_GLOBAL_DATA_PTR;
+@@ -232,9 +213,10 @@ void rtc_init(void)
+ phys_size_t initdram(int board_type)
+ {
+ struct jz4740_emc *emc = (struct jz4740_emc *)JZ4740_EMC_BASE;
+- u32 dmcr;
+- u32 rows, cols, dw, banks;
+- ulong size;
++
++ unsigned int dmcr;
++ unsigned int rows, cols, dw, banks;
++ unsigned long size;
+
+ dmcr = readl(&emc->dmcr);
+ rows = 11 + ((dmcr & EMC_DMCR_RA_MASK) >> EMC_DMCR_RA_BIT);
+diff --git a/arch/mips/cpu/xburst/spl/Makefile b/arch/mips/cpu/xburst/spl/Makefile
+new file mode 100644
+index 0000000..f45e8c8
+--- /dev/null
++++ b/arch/mips/cpu/xburst/spl/Makefile
+@@ -0,0 +1,47 @@
++#
++# Copyright (C) 2011 Xiangfu Liu <xiangfu@openmobilefree.net>
++#
++# See file CREDITS for list of people who contributed to this
++# project.
++#
++# 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 of
++# the License, 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; if not, write to the Free Software
++# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++# MA 02111-1307 USA
++#
++
++include $(TOPDIR)/config.mk
++
++LIB = $(obj)lib$(CPU).o
++
++START = start.o
++SOBJS-y =
++COBJS-y =
++
++SRCS := $(START:.o=.S) $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c)
++OBJS := $(addprefix $(obj),$(SOBJS-y) $(COBJS-y))
++START := $(addprefix $(obj),$(START))
++
++all: $(obj).depend $(START) $(LIB)
++
++$(LIB): $(OBJS)
++ $(call cmd_link_o_target, $(OBJS))
++
++#########################################################################
++
++# defines $(obj).depend target
++include $(SRCTREE)/rules.mk
++
++sinclude $(obj).depend
++
++#########################################################################
+diff --git a/arch/mips/cpu/xburst/spl/start.S b/arch/mips/cpu/xburst/spl/start.S
+new file mode 100644
+index 0000000..e31c4c8
+--- /dev/null
++++ b/arch/mips/cpu/xburst/spl/start.S
+@@ -0,0 +1,63 @@
++/*
++ * Copyright (c) 2010 Xiangfu Liu <xiangfu@openmobilefree.net>
++ *
++ * See file CREDITS for list of people who contributed to this
++ * project.
++ *
++ * 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 3 of
++ * the License, 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; if not, write to the Free Software
++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ * MA 02111-1307 USA
++ */
++
++#include <config.h>
++#include <version.h>
++#include <asm/regdef.h>
++#include <asm/mipsregs.h>
++#include <asm/addrspace.h>
++#include <asm/cacheops.h>
++
++#include <asm/jz4740.h>
++
++ .set noreorder
++
++ .globl _start
++ .text
++_start:
++ .word JZ4740_NANDBOOT_CFG /* fetched during NAND Boot */
++reset:
++ /*
++ * STATUS register
++ * CU0=UM=EXL=IE=0, BEV=ERL=1, IP2~7=1
++ */
++ li t0, 0x0040FC04
++ mtc0 t0, CP0_STATUS
++ /*
++ * CAUSE register
++ * IV=1, use the specical interrupt vector (0x200)
++ */
++ li t1, 0x00800000
++ mtc0 t1, CP0_CAUSE
++
++ bal 1f
++ nop
++ .word _GLOBAL_OFFSET_TABLE_
++1:
++ move gp, ra
++ lw t1, 0(ra)
++ move gp, t1
++
++ la sp, 0x80004000
++ la t9, nand_spl_boot
++ j t9
++ nop
+diff --git a/board/qi/qi_lb60/Makefile b/board/qi/qi_lb60/Makefile
+index 5dae11b..e399246 100644
+--- a/board/qi/qi_lb60/Makefile
++++ b/board/qi/qi_lb60/Makefile
+@@ -22,7 +22,11 @@ include $(TOPDIR)/config.mk
+
+ LIB = $(obj)lib$(BOARD).o
+
++ifeq ($(CONFIG_SPL_BUILD),y)
++COBJS := $(BOARD)-spl.o
++else
+ COBJS := $(BOARD).o
++endif
+
+ SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c)
+ OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS))
+diff --git a/board/qi/qi_lb60/qi_lb60-spl.c b/board/qi/qi_lb60/qi_lb60-spl.c
+new file mode 100644
+index 0000000..3fe3fa3
+--- /dev/null
++++ b/board/qi/qi_lb60/qi_lb60-spl.c
+@@ -0,0 +1,30 @@
++/*
++ * Authors: Xiangfu Liu <xiangfu@openmobilefree.cc>
++ *
++ * 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
++ * 3 of the License, or (at your option) any later version.
++ */
++
++#include <common.h>
++#include <nand.h>
++#include <asm/io.h>
++#include <asm/jz4740.h>
++
++void nand_spl_boot(void)
++{
++ __gpio_as_sdram_16bit_4720();
++ __gpio_as_uart0();
++ __gpio_jtag_to_uart0();
++
++ serial_init();
++
++ pll_init();
++ sdram_init();
++
++ nand_init();
++
++ puts("\nQi LB60 SPL: Starting U-Boot ...\n");
++ nand_boot();
++}
+diff --git a/board/qi/qi_lb60/qi_lb60.c b/board/qi/qi_lb60/qi_lb60.c
+index d975209..3bd4e2f 100644
+--- a/board/qi/qi_lb60/qi_lb60.c
++++ b/board/qi/qi_lb60/qi_lb60.c
+@@ -1,5 +1,5 @@
+ /*
+- * Authors: Xiangfu Liu <xiangfu@sharism.cc>
++ * Authors: Xiangfu Liu <xiangfu@openmobilefree.net>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+@@ -97,8 +97,10 @@ int board_early_init_f(void)
+ /* U-Boot common routines */
+ int checkboard(void)
+ {
+- printf("Board: Qi LB60 (Ingenic XBurst Jz4740 SoC, Speed %ld MHz)\n",
+- gd->cpu_clk / 1000000);
++ printf("Board: Qi LB60 (Ingenic XBurst Jz4740 SoC)\n");
++ printf(" CPU: %ld\n", gd->cpu_clk);
++ printf(" MEM: %ld\n", gd->mem_clk);
++ printf(" DEV: %ld\n", gd->dev_clk);
+
+ return 0;
+ }
+diff --git a/board/qi/qi_lb60/u-boot-spl.lds b/board/qi/qi_lb60/u-boot-spl.lds
+new file mode 100644
+index 0000000..930537f
+--- /dev/null
++++ b/board/qi/qi_lb60/u-boot-spl.lds
+@@ -0,0 +1,61 @@
++/*
++ * (C) Copyright 2012 Xiangfu Liu <xiangfu@openmobilefree.net>
++ *
++ * 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 of
++ * the License, 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; if not, write to the Free Software
++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ * MA 02111-1307 USA
++ */
++
++OUTPUT_FORMAT("elf32-tradlittlemips", "elf32-tradlittlemips", "elf32-tradlittlemips")
++
++OUTPUT_ARCH(mips)
++ENTRY(_start)
++SECTIONS
++{
++ . = 0x80000000;
++ . = ALIGN(4);
++ .text :
++ {
++ *(.text)
++ }
++
++ . = ALIGN(4);
++ .rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
++
++ . = ALIGN(4);
++ .data : { *(.data) }
++
++ . = ALIGN(4);
++ .sdata : { *(.sdata) }
++
++ _gp = ALIGN(16);
++
++ __got_start = .;
++ .got : { *(.got) }
++ __got_end = .;
++
++ . = .;
++ __u_boot_cmd_start = .;
++ .u_boot_cmd : { *(.u_boot_cmd) }
++ __u_boot_cmd_end = .;
++
++ uboot_end_data = .;
++ num_got_entries = (__got_end - __got_start) >> 2;
++
++ . = ALIGN(4);
++ .sbss : { *(.sbss) }
++ .bss : { *(.bss) }
++ uboot_end = .;
++}
++ASSERT(uboot_end <= 0x80002000, "NAND bootstrap too big");
+diff --git a/drivers/mtd/nand/jz4740_nand.c b/drivers/mtd/nand/jz4740_nand.c
+index 3ec34f3..24a4921 100644
+--- a/drivers/mtd/nand/jz4740_nand.c
++++ b/drivers/mtd/nand/jz4740_nand.c
+@@ -15,6 +15,9 @@
+ #include <asm/io.h>
+ #include <asm/jz4740.h>
+
++#ifdef CONFIG_SPL_BUILD
++#define printf(s) puts(s)
++#endif
+ #define JZ_NAND_DATA_ADDR ((void __iomem *)0xB8000000)
+ #define JZ_NAND_CMD_ADDR (JZ_NAND_DATA_ADDR + 0x8000)
+ #define JZ_NAND_ADDR_ADDR (JZ_NAND_DATA_ADDR + 0x10000)
+@@ -176,7 +179,7 @@ static int jz_nand_rs_correct_data(struct mtd_info *mtd, u_char *dat,
+ for (k = 0; k < 9; k++)
+ writeb(read_ecc[k], &emc->nfpar[k]);
+ }
+- /* Set PRDY */
++
+ writel(readl(&emc->nfecr) | EMC_NFECR_PRDY, &emc->nfecr);
+
+ /* Wait for completion */
+@@ -184,7 +187,7 @@ static int jz_nand_rs_correct_data(struct mtd_info *mtd, u_char *dat,
+ status = readl(&emc->nfints);
+ } while (!(status & EMC_NFINTS_DECF));
+
+- /* disable ecc */
++ /* Disable ECC */
+ writel(readl(&emc->nfecr) & ~EMC_NFECR_ECCE, &emc->nfecr);
+
+ /* Check decoding */
+@@ -192,7 +195,7 @@ static int jz_nand_rs_correct_data(struct mtd_info *mtd, u_char *dat,
+ return 0;
+
+ if (status & EMC_NFINTS_UNCOR) {
+- printf("uncorrectable ecc\n");
++ printf("JZ4740 uncorrectable ECC\n");
+ return -1;
+ }
+
+@@ -230,6 +233,32 @@ static int jz_nand_rs_correct_data(struct mtd_info *mtd, u_char *dat,
+ return errcnt;
+ }
+
++#ifdef CONFIG_SPL_BUILD
++static void jz_nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
++{
++ int i;
++ struct nand_chip *this = mtd->priv;
++
++#if (JZ4740_NANDBOOT_CFG == JZ4740_NANDBOOT_B16R3) || \
++ (JZ4740_NANDBOOT_CFG == JZ4740_NANDBOOT_B16R2)
++ for (i = 0; i < len; i += 2)
++ buf[i] = readw(this->IO_ADDR_R);
++#elif (JZ4740_NANDBOOT_CFG == JZ4740_NANDBOOT_B8R3) || \
++ (JZ4740_NANDBOOT_CFG == JZ4740_NANDBOOT_B8R2)
++ for (i = 0; i < len; i++)
++ buf[i] = readb(this->IO_ADDR_R);
++#else
++ #error JZ4740_NANDBOOT_CFG not defined or wrong
++#endif
++}
++
++static uint8_t jz_nand_read_byte(struct mtd_info *mtd)
++{
++ struct nand_chip *this = mtd->priv;
++ return readb(this->IO_ADDR_R);
++}
++#endif
++
+ /*
+ * Main initialization routine
+ */
+@@ -254,6 +283,10 @@ int board_nand_init(struct nand_chip *nand)
+ nand->ecc.size = CONFIG_SYS_NAND_ECCSIZE;
+ nand->ecc.bytes = CONFIG_SYS_NAND_ECCBYTES;
+ nand->ecc.layout = &qi_lb60_ecclayout_2gb;
++#ifdef CONFIG_SPL_BUILD
++ nand->read_byte = jz_nand_read_byte;
++ nand->read_buf = jz_nand_read_buf;
++#endif
+ nand->chip_delay = 50;
+ nand->options = NAND_USE_FLASH_BBT;
+
+diff --git a/include/configs/qi_lb60.h b/include/configs/qi_lb60.h
+index 4bb5bbc..7bff444 100644
+--- a/include/configs/qi_lb60.h
++++ b/include/configs/qi_lb60.h
+@@ -1,5 +1,5 @@
+ /*
+- * Authors: Xiangfu Liu <xiangfu.z@gmail.com>
++ * Authors: Xiangfu Liu <xiangfu@openmobilefree.net>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+@@ -14,7 +14,6 @@
+ #define CONFIG_SYS_LITTLE_ENDIAN
+ #define CONFIG_JZSOC /* Jz SoC */
+ #define CONFIG_JZ4740 /* Jz4740 SoC */
+-#define CONFIG_NAND_JZ4740
+
+ #define CONFIG_SYS_CPU_SPEED 336000000 /* CPU clock: 336 MHz */
+ #define CONFIG_SYS_EXTAL 12000000 /* EXTAL freq: 12 MHz */
+@@ -24,24 +23,43 @@
+ #define CONFIG_SYS_UART_BASE JZ4740_UART0_BASE /* Base of the UART channel */
+ #define CONFIG_BAUDRATE 57600
+
++#define CONFIG_BOOTP_MASK (CONFIG_BOOTP_DEFAUL)
++#define CONFIG_BOOTDELAY 0
++#define CONFIG_BOOTARGS "mem=32M console=tty0 console=ttyS0,57600n8 ubi.mtd=2 rootfstype=ubifs root=ubi0:rootfs rw rootwait"
++#define CONFIG_BOOTCOMMAND "nand read 0x80600000 0x400000 0x280000;bootm"
++
++/*
++ * Miscellaneous configurable options
++ */
++#define CONFIG_SYS_SDRAM_BASE 0x80000000 /* Cached addr */
++#define CONFIG_SYS_INIT_SP_OFFSET 0x400000
++#define CONFIG_SYS_LOAD_ADDR 0x80600000
++#define CONFIG_SYS_MEMTEST_START 0x80100000
++#define CONFIG_SYS_MEMTEST_END 0x80A00000
++#define CONFIG_SYS_TEXT_BASE 0x80100000
++#define CONFIG_SYS_MONITOR_BASE CONFIG_SYS_TEXT_BASE
++
++#define CONFIG_SYS_MALLOC_LEN (4 * 1024 * 1024)
++#define CONFIG_SYS_BOOTPARAMS_LEN (128 * 1024)
++
++#define CONFIG_SYS_CBSIZE 256 /* Console I/O Buffer Size */
++#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE + sizeof(CONFIG_SYS_PROMPT) + 16)
++
++#define CONFIG_SYS_LONGHELP
++#define CONFIG_SYS_MAXARGS 16
++#define CONFIG_SYS_PROMPT "NanoNote# "
++
+ #define CONFIG_SKIP_LOWLEVEL_INIT
+ #define CONFIG_BOARD_EARLY_INIT_F
+ #define CONFIG_SYS_NO_FLASH
+ #define CONFIG_SYS_FLASH_BASE 0 /* init flash_base as 0 */
+-#define CONFIG_ENV_OVERWRITE
+-
+-#define CONFIG_BOOTP_MASK (CONFIG_BOOTP_DEFAUL)
+-#define CONFIG_BOOTDELAY 0
+-#define CONFIG_BOOTARGS "mem=32M console=tty0 console=ttyS0,57600n8 ubi.mtd=2 rootfstype=ubifs root=ubi0:rootfs rw rootwait"
+-#define CONFIG_BOOTCOMMAND "nand read 0x80600000 0x400000 0x200000;bootm"
+
+ /*
+- * Command line configuration.
++ * Command line configuration
+ */
+ #define CONFIG_CMD_BOOTD /* bootd */
+ #define CONFIG_CMD_CONSOLE /* coninfo */
+ #define CONFIG_CMD_ECHO /* echo arguments */
+-
+ #define CONFIG_CMD_LOADB /* loadb */
+ #define CONFIG_CMD_LOADS /* loads */
+ #define CONFIG_CMD_MEMORY /* md mm nm mw cp cmp crc base loop mtest */
+@@ -58,45 +76,16 @@
+ #define CONFIG_LOADS_ECHO 1 /* echo on for serial download */
+
+ /*
+- * Miscellaneous configurable options
+- */
+-#define CONFIG_SYS_MAXARGS 16
+-#define CONFIG_SYS_LONGHELP
+-#define CONFIG_SYS_PROMPT "NanoNote# "
+-#define CONFIG_SYS_CBSIZE 256 /* Console I/O Buffer Size */
+-#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE + sizeof(CONFIG_SYS_PROMPT) + 16)
+-
+-#define CONFIG_SYS_MALLOC_LEN (4 * 1024 * 1024)
+-#define CONFIG_SYS_BOOTPARAMS_LEN (128 * 1024)
+-
+-#define CONFIG_SYS_SDRAM_BASE 0x80000000 /* Cached addr */
+-#define CONFIG_SYS_INIT_SP_OFFSET 0x400000
+-#define CONFIG_SYS_LOAD_ADDR 0x80600000
+-#define CONFIG_SYS_MEMTEST_START 0x80100000
+-#define CONFIG_SYS_MEMTEST_END 0x80800000
+-
+-/*
+- * Environment
++ * NAND driver configuration
+ */
+-#define CONFIG_ENV_IS_IN_NAND /* use NAND for environment vars */
+-
+-#define CONFIG_SYS_NAND_5_ADDR_CYCLE
+-/*
+- * if board nand flash is 1GB, set to 1
+- * if board nand flash is 2GB, set to 2
+- * for change the PAGE_SIZE and BLOCK_SIZE
+- * will delete when there is no 1GB flash
+- */
+-#define NANONOTE_NAND_SIZE 2
+-
+-#define CONFIG_SYS_NAND_PAGE_SIZE (2048 * NANONOTE_NAND_SIZE)
+-#define CONFIG_SYS_NAND_BLOCK_SIZE (256 * NANONOTE_NAND_SIZE << 10)
+-/* nand bad block was marked at this page in a block, start from 0 */
++#define CONFIG_NAND_JZ4740
++#define CONFIG_SYS_NAND_PAGE_SIZE 4096
++#define CONFIG_SYS_NAND_BLOCK_SIZE (512 << 10)
++/* NAND bad block was marked at this page in a block, start from 0 */
+ #define CONFIG_SYS_NAND_BADBLOCK_PAGE 127
+ #define CONFIG_SYS_NAND_PAGE_COUNT 128
+ #define CONFIG_SYS_NAND_BAD_BLOCK_POS 0
+-/* ECC offset position in oob area, default value is 6 if it isn't defined */
+-#define CONFIG_SYS_NAND_ECC_POS (6 * NANONOTE_NAND_SIZE)
++#define CONFIG_SYS_NAND_ECC_POS 12
+ #define CONFIG_SYS_NAND_ECCSIZE 512
+ #define CONFIG_SYS_NAND_ECCBYTES 9
+ #define CONFIG_SYS_NAND_ECCPOS \
+@@ -115,10 +104,9 @@
+ #define CONFIG_SYS_ONENAND_BASE CONFIG_SYS_NAND_BASE
+ #define CONFIG_SYS_MAX_NAND_DEVICE 1
+ #define CONFIG_SYS_NAND_SELECT_DEVICE 1 /* nand driver supports mutipl.*/
+-#define CONFIG_NAND_SPL_TEXT_BASE 0x80000000
+
+ /*
+- * IPL (Initial Program Loader, integrated inside CPU)
++ * IPL (Initial Program Loader, integrated inside Ingenic Xburst JZ4740 CPU)
+ * Will load first 8k from NAND (SPL) into cache and execute it from there.
+ *
+ * SPL (Secondary Program Loader)
+@@ -130,77 +118,88 @@
+ * NUB (NAND U-Boot)
+ * This NAND U-Boot (NUB) is a special U-Boot version which can be started
+ * from RAM. Therefore it mustn't (re-)configure the SDRAM controller.
+- *
+ */
++
++/*
++ * NAND SPL configuration
++ */
++#define CONFIG_SPL
++#define CONFIG_SPL_LIBGENERIC_SUPPORT
++#define CONFIG_SPL_LIBCOMMON_SUPPORT
++#define CONFIG_SPL_NAND_LOAD
++#define CONFIG_SPL_NAND_SIMPLE
++#define CONFIG_SPL_NAND_SUPPORT
++#define CONFIG_SPL_TEXT_BASE 0x80000000
++#define CONFIG_SPL_START_S_PATH "arch/mips/cpu/xburst/spl"
++
++#define CONFIG_SYS_NAND_5_ADDR_CYCLE
++#define CONFIG_SYS_NAND_HW_ECC_OOBFIRST
++#define JZ4740_NANDBOOT_CFG JZ4740_NANDBOOT_B8R3
++
+ #define CONFIG_SYS_NAND_U_BOOT_DST 0x80100000 /* Load NUB to this addr */
+ #define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_NAND_U_BOOT_DST
+-/* Start NUB from this addr*/
++ /* Start NUB from this addr */
++#define CONFIG_SYS_NAND_U_BOOT_OFFS (32 << 10) /* Offset of NUB */
++#define CONFIG_SYS_NAND_U_BOOT_SIZE (256 << 10) /* Size of NUB */
+
+ /*
+- * Define the partitioning of the NAND chip (only RAM U-Boot is needed here)
++ * Environment configuration
+ */
+-#define CONFIG_SYS_NAND_U_BOOT_OFFS (256 << 10) /* Offset to RAM U-Boot image */
+-#define CONFIG_SYS_NAND_U_BOOT_SIZE (512 << 10) /* Size of RAM U-Boot image */
+-
++#define CONFIG_ENV_OVERWRITE
++#define CONFIG_ENV_IS_IN_NAND
+ #define CONFIG_ENV_SIZE (4 << 10)
+ #define CONFIG_ENV_OFFSET \
+ (CONFIG_SYS_NAND_BLOCK_SIZE + CONFIG_SYS_NAND_U_BOOT_SIZE)
+ #define CONFIG_ENV_OFFSET_REDUND \
+ (CONFIG_ENV_OFFSET + CONFIG_SYS_NAND_BLOCK_SIZE)
+
+-#define CONFIG_SYS_TEXT_BASE 0x80100000
+-#define CONFIG_SYS_MONITOR_BASE CONFIG_SYS_TEXT_BASE
+-
+ /*
+- * SDRAM Info.
++ * CPU cache configuration
+ */
+-#define CONFIG_NR_DRAM_BANKS 1
++#define CONFIG_SYS_DCACHE_SIZE 16384
++#define CONFIG_SYS_ICACHE_SIZE 16384
++#define CONFIG_SYS_CACHELINE_SIZE 32
+
+ /*
+- * Cache Configuration
++ * SDRAM configuration
+ */
+-#define CONFIG_SYS_DCACHE_SIZE 16384
+-#define CONFIG_SYS_ICACHE_SIZE 16384
+-#define CONFIG_SYS_CACHELINE_SIZE 32
++#define CONFIG_NR_DRAM_BANKS 1
++
++#define SDRAM_BW16 1 /* Data bus width: 0-32bit, 1-16bit */
++#define SDRAM_BANK4 1 /* Banks each chip: 0-2bank, 1-4bank */
++#define SDRAM_ROW 13 /* Row address: 11 to 13 */
++#define SDRAM_COL 9 /* Column address: 8 to 12 */
++#define SDRAM_CASL 2 /* CAS latency: 2 or 3 */
++#define SDRAM_TRAS 45 /* RAS# Active Time */
++#define SDRAM_RCD 20 /* RAS# to CAS# Delay */
++#define SDRAM_TPC 20 /* RAS# Precharge Time */
++#define SDRAM_TRWL 7 /* Write Latency Time */
++#define SDRAM_TREF 15625 /* Refresh period: 8192 cycles/64ms */
+
+ /*
+- * GPIO definition
++ * GPIO configuration
+ */
+-#define GPIO_LCD_CS (2 * 32 + 21)
+-#define GPIO_AMP_EN (3 * 32 + 4)
++#define GPIO_LCD_CS (2 * 32 + 21)
++#define GPIO_AMP_EN (3 * 32 + 4)
+
+-#define GPIO_SDPW_EN (3 * 32 + 2)
+-#define GPIO_SD_DETECT (3 * 32 + 0)
++#define GPIO_SDPW_EN (3 * 32 + 2)
++#define GPIO_SD_DETECT (3 * 32 + 0)
+
+-#define GPIO_BUZZ_PWM (3 * 32 + 27)
+-#define GPIO_USB_DETECT (3 * 32 + 28)
++#define GPIO_BUZZ_PWM (3 * 32 + 27)
++#define GPIO_USB_DETECT (3 * 32 + 28)
+
+-#define GPIO_AUDIO_POP (1 * 32 + 29)
+-#define GPIO_COB_TEST (1 * 32 + 30)
++#define GPIO_AUDIO_POP (1 * 32 + 29)
++#define GPIO_COB_TEST (1 * 32 + 30)
+
+ #define GPIO_KEYOUT_BASE (2 * 32 + 10)
+-#define GPIO_KEYIN_BASE (3 * 32 + 18)
+-#define GPIO_KEYIN_8 (3 * 32 + 26)
++#define GPIO_KEYIN_BASE (3 * 32 + 18)
++#define GPIO_KEYIN_8 (3 * 32 + 26)
+
+-#define GPIO_SD_CD_N GPIO_SD_DETECT /* SD Card insert detect */
++#define GPIO_SD_CD_N GPIO_SD_DETECT /* SD Card insert detect */
+ #define GPIO_SD_VCC_EN_N GPIO_SDPW_EN /* SD Card Power Enable */
+
+ #define SPEN GPIO_LCD_CS /* LCDCS :Serial command enable */
+ #define SPDA (2 * 32 + 22) /* LCDSCL:Serial command clock input */
+ #define SPCK (2 * 32 + 23) /* LCDSDA:Serial command data input */
+
+-/* SDRAM paramters */
+-#define SDRAM_BW16 1 /* Data bus width: 0-32bit, 1-16bit */
+-#define SDRAM_BANK4 1 /* Banks each chip: 0-2bank, 1-4bank */
+-#define SDRAM_ROW 13 /* Row address: 11 to 13 */
+-#define SDRAM_COL 9 /* Column address: 8 to 12 */
+-#define SDRAM_CASL 2 /* CAS latency: 2 or 3 */
+-
+-/* SDRAM Timings, unit: ns */
+-#define SDRAM_TRAS 45 /* RAS# Active Time */
+-#define SDRAM_RCD 20 /* RAS# to CAS# Delay */
+-#define SDRAM_TPC 20 /* RAS# Precharge Time */
+-#define SDRAM_TRWL 7 /* Write Latency Time */
+-#define SDRAM_TREF 15625 /* Refresh period: 8192 cycles/64ms */
+-
+ #endif
+--
+1.7.9.5
+
diff --git a/package/boot/uboot-xburst/patches/0002-qi_lb60-add-software-usbboot-support.patch b/package/boot/uboot-xburst/patches/0002-qi_lb60-add-software-usbboot-support.patch
new file mode 100644
index 0000000..feaf297
--- /dev/null
+++ b/package/boot/uboot-xburst/patches/0002-qi_lb60-add-software-usbboot-support.patch
@@ -0,0 +1,916 @@
+From fa51192b912d296b8eec10f7d44c6c17eb1dd368 Mon Sep 17 00:00:00 2001
+From: Xiangfu <xiangfu@openmobilefree.net>
+Date: Fri, 12 Oct 2012 09:47:39 +0800
+Subject: [PATCH 2/6] qi_lb60: add software usbboot support
+
+ JZ4740 CPU have a internal ROM have such kind of code, that make
+ JZ4740 can boot from USB
+
+ usbboot.S can downloads user program from the USB port to internal
+ SRAM and branches to the internal SRAM to execute the program
+
+Signed-off-by: Xiangfu <xiangfu@openmobilefree.net>
+---
+ board/qi/qi_lb60/Makefile | 1 +
+ board/qi/qi_lb60/qi_lb60-spl.c | 20 +
+ board/qi/qi_lb60/usbboot.S | 838 ++++++++++++++++++++++++++++++++++++++++
+ 3 files changed, 859 insertions(+)
+ create mode 100644 board/qi/qi_lb60/usbboot.S
+
+diff --git a/board/qi/qi_lb60/Makefile b/board/qi/qi_lb60/Makefile
+index e399246..6dd8c6f 100644
+--- a/board/qi/qi_lb60/Makefile
++++ b/board/qi/qi_lb60/Makefile
+@@ -23,6 +23,7 @@ include $(TOPDIR)/config.mk
+ LIB = $(obj)lib$(BOARD).o
+
+ ifeq ($(CONFIG_SPL_BUILD),y)
++SOBJS := usbboot.o
+ COBJS := $(BOARD)-spl.o
+ else
+ COBJS := $(BOARD).o
+diff --git a/board/qi/qi_lb60/qi_lb60-spl.c b/board/qi/qi_lb60/qi_lb60-spl.c
+index 3fe3fa3..aea459c 100644
+--- a/board/qi/qi_lb60/qi_lb60-spl.c
++++ b/board/qi/qi_lb60/qi_lb60-spl.c
+@@ -12,6 +12,24 @@
+ #include <asm/io.h>
+ #include <asm/jz4740.h>
+
++#define KEY_U_OUT (32 * 2 + 16)
++#define KEY_U_IN (32 * 3 + 19)
++
++extern void usb_boot(void);
++
++static void check_usb_boot(void)
++{
++ __gpio_as_input(KEY_U_IN);
++ __gpio_enable_pull(KEY_U_IN);
++ __gpio_as_output(KEY_U_OUT);
++ __gpio_clear_pin(KEY_U_OUT);
++
++ if (!__gpio_get_pin(KEY_U_IN)) {
++ puts("[U] pressed, goto USBBOOT mode\n");
++ usb_boot();
++ }
++}
++
+ void nand_spl_boot(void)
+ {
+ __gpio_as_sdram_16bit_4720();
+@@ -23,6 +41,8 @@ void nand_spl_boot(void)
+ pll_init();
+ sdram_init();
+
++ check_usb_boot();
++
+ nand_init();
+
+ puts("\nQi LB60 SPL: Starting U-Boot ...\n");
+diff --git a/board/qi/qi_lb60/usbboot.S b/board/qi/qi_lb60/usbboot.S
+new file mode 100644
+index 0000000..c872266
+--- /dev/null
++++ b/board/qi/qi_lb60/usbboot.S
+@@ -0,0 +1,838 @@
++/*
++ * for jz4740 usb boot
++ *
++ * Copyright (c) 2009 Author: <jlwei@ingenic.cn>
++ *
++ * See file CREDITS for list of people who contributed to this
++ * project.
++ *
++ * 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 of
++ * the License, 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; if not, write to the Free Software
++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ * MA 02111-1307 USA
++ */
++ .set noreorder
++ .globl usb_boot
++ .text
++
++/*
++ * Both NAND and USB boot load data to D-Cache first, then transfer
++ * data from D-Cache to I-Cache, and jump to execute the code in I-Cache.
++ * So init caches first and then dispatch to a proper boot routine.
++ */
++
++.macro load_addr reg addr
++ li \reg, 0x80000000
++ addiu \reg, \reg, \addr
++ la $2, usbboot_begin
++ subu \reg, \reg, $2
++.endm
++
++usb_boot:
++ /* Initialize PLL: set ICLK to 84MHz and HCLK to 42MHz. */
++ la $9, 0xB0000000 /* CPCCR: Clock Control Register */
++ la $8, 0x42041110 /* I:S:M:P=1:2:2:2 */
++ sw $8, 0($9)
++
++ la $9, 0xB0000010 /* CPPCR: PLL Control Register */
++ la $8, 0x06000120 /* M=12 N=0 D=0 CLK=12*(M+2)/(N+2) */
++ sw $8, 0($9)
++
++ mtc0 $0, $26 /* CP0_ERRCTL, restore WST reset state */
++ nop
++
++ mtc0 $0, $16 /* CP0_CONFIG */
++ nop
++
++ /* Relocate code to beginning of the ram */
++
++ la $2, usbboot_begin
++ la $3, usbboot_end
++ li $4, 0x80000000
++
++1:
++ lw $5, 0($2)
++ sw $5, 0($4)
++ addiu $2, $2, 4
++ bne $2, $3, 1b
++ addiu $4, $4, 4
++
++ li $2, 0x80000000
++ ori $3, $2, 0
++ addiu $3, $3, usbboot_end
++ la $4, usbboot_begin
++ subu $3, $3, $4
++
++
++2:
++ cache 0x0, 0($2) /* Index_Invalidate_I */
++ cache 0x1, 0($2) /* Index_Writeback_Inv_D */
++ addiu $2, $2, 32
++ subu $4, $3, $2
++ bgtz $4, 2b
++ nop
++
++ load_addr $3, usb_boot_return
++
++ jr $3
++
++usbboot_begin:
++
++init_caches:
++ li $2, 3 /* cacheable for kseg0 access */
++ mtc0 $2, $16 /* CP0_CONFIG */
++ nop
++
++ li $2, 0x20000000 /* enable idx-store-data cache insn */
++ mtc0 $2, $26 /* CP0_ERRCTL */
++
++ ori $2, $28, 0 /* start address */
++ ori $3, $2, 0x3fe0 /* end address, total 16KB */
++ mtc0 $0, $28, 0 /* CP0_TAGLO */
++ mtc0 $0, $28, 1 /* CP0_DATALO */
++cache_clear_a_line:
++ cache 0x8, 0($2) /* Index_Store_Tag_I */
++ cache 0x9, 0($2) /* Index_Store_Tag_D */
++ bne $2, $3, cache_clear_a_line
++ addiu $2, $2, 32 /* increment CACHE_LINE_SIZE */
++
++ ori $2, $28, 0 /* start address */
++ ori $3, $2, 0x3fe0 /* end address, total 16KB */
++ la $4, 0x1ffff000 /* physical address and 4KB page mask */
++cache_alloc_a_line:
++ and $5, $2, $4
++ ori $5, $5, 1 /* V bit of the physical tag */
++ mtc0 $5, $28, 0 /* CP0_TAGLO */
++ cache 0x8, 0($2) /* Index_Store_Tag_I */
++ cache 0x9, 0($2) /* Index_Store_Tag_D */
++ bne $2, $3, cache_alloc_a_line
++ addiu $2, $2, 32 /* increment CACHE_LINE_SIZE */
++
++ nop
++ nop
++ nop
++ /*
++ * Transfer data from dcache to icache, then jump to icache.
++ * Input parameters:
++ * $19: data length in bytes
++ * $20: jump target address
++ */
++xfer_d2i:
++
++ ori $8, $20, 0
++ addu $9, $8, $19 /* total 16KB */
++
++1:
++ cache 0x0, 0($8) /* Index_Invalidate_I */
++ cache 0x1, 0($8) /* Index_Writeback_Inv_D */
++ bne $8, $9, 1b
++ addiu $8, $8, 32
++
++ /* flush write-buffer */
++ sync
++
++ /* Invalidate BTB */
++ mfc0 $8, $16, 7 /* CP0_CONFIG */
++ nop
++ ori $8, 2
++ mtc0 $8, $16, 7
++ nop
++
++ /* Overwrite config to disable ram initalisation */
++ li $2, 0xff
++ sb $2, 20($20)
++
++ jalr $20
++ nop
++
++icache_return:
++ /* User code can return to here after executing itself in
++ icache, by jumping to $31. */
++ b usb_boot_return
++ nop
++
++
++usb_boot_return:
++ /* Enable the USB PHY */
++ la $9, 0xB0000024 /* CPM_SCR */
++ lw $8, 0($9)
++ ori $8, 0x40 /* USBPHY_ENABLE */
++ sw $8, 0($9)
++
++ /* Initialize USB registers */
++ la $27, 0xb3040000 /* USB registers base address */
++
++ sb $0, 0x0b($27) /* INTRUSBE: disable common USB interrupts */
++ sh $0, 0x06($27) /* INTRINE: disable EPIN interrutps */
++ sh $0, 0x08($27) /* INTROUTE: disable EPOUT interrutps */
++
++ li $9, 0x61
++ sb $9, 0x01($27) /* POWER: HSENAB | SUSPENDM | SOFTCONN */
++
++ /* Initialize USB states */
++ li $22, 0 /* set EP0 to IDLE state */
++ li $23, 1 /* no data stage */
++
++ /* Main loop of polling the usb commands */
++usb_command_loop:
++ lbu $9, 0x0a($27) /* read INTRUSB */
++ andi $9, 0x04 /* check USB_INTR_RESET */
++ beqz $9, check_intr_ep0in
++ nop
++
++ /* 1. Handle USB reset interrupt */
++handle_reset_intr:
++ lbu $9, 0x01($27) /* read POWER */
++ andi $9, 0x10 /* test HS_MODE */
++ bnez $9, _usb_set_maxpktsize
++ li $9, 512 /* max packet size of HS mode */
++ li $9, 64 /* max packet size of FS mode */
++
++_usb_set_maxpktsize:
++ li $8, 1
++ sb $8, 0x0e($27) /* set INDEX 1 */
++
++ sh $9, 0x10($27) /* INMAXP */
++ sb $0, 0x13($27) /* INCSRH */
++ sh $9, 0x14($27) /* OUTMAXP */
++ sb $0, 0x17($27) /* OUTCSRH */
++
++_usb_flush_fifo:
++ li $8, 0x48 /* INCSR_CDT && INCSR_FF */
++ sb $8, 0x12($27) /* INCSR */
++ li $8, 0x90 /* OUTCSR_CDT && OUTCSR_FF */
++ sb $8, 0x16($27) /* OUTCSR */
++
++ li $22, 0 /* set EP0 to IDLE state */
++ li $23, 1 /* no data stage */
++
++ /* 2. Check and handle EP0 interrupt */
++check_intr_ep0in:
++ lhu $10, 0x02($27) /* read INTRIN */
++ andi $9, $10, 0x1 /* check EP0 interrupt */
++ beqz $9, check_intr_ep1in
++ nop
++
++handle_ep0_intr:
++ sb $0, 0x0e($27) /* set INDEX 0 */
++ lbu $11, 0x12($27) /* read CSR0 */
++
++ andi $9, $11, 0x04 /* check SENTSTALL */
++ beqz $9, _ep0_setupend
++ nop
++
++_ep0_sentstall:
++ andi $9, $11, 0xdb
++ sb $9, 0x12($27) /* clear SENDSTALL and SENTSTALL */
++ li $22, 0 /* set EP0 to IDLE state */
++
++_ep0_setupend:
++ andi $9, $11, 0x10 /* check SETUPEND */
++ beqz $9, ep0_idle_state
++ nop
++
++ ori $9, $11, 0x80
++ sb $9, 0x12($27) /* set SVDSETUPEND */
++ li $22, 0 /* set EP0 to IDLE state */
++
++ep0_idle_state:
++ bnez $22, ep0_tx_state
++ nop
++
++ /* 2.1 Handle EP0 IDLE state interrupt */
++ andi $9, $11, 0x01 /* check OUTPKTRDY */
++ beqz $9, check_intr_ep1in
++ nop
++
++ /* Read 8-bytes setup packet from the FIFO */
++ lw $25, 0x20($27) /* first word of setup packet */
++ lw $26, 0x20($27) /* second word of setup packet */
++
++ andi $9, $25, 0x60 /* bRequestType & USB_TYPE_MASK */
++ beqz $9, _ep0_std_req
++ nop
++
++ /* 2.1.1 Vendor-specific setup request */
++_ep0_vend_req:
++ li $22, 0 /* set EP0 to IDLE state */
++ li $23, 1 /* NoData = 1 */
++
++ andi $9, $25, 0xff00 /* check bRequest */
++ srl $9, $9, 8
++ beqz $9, __ep0_get_cpu_info
++ sub $8, $9, 0x1
++ beqz $8, __ep0_set_data_address
++ sub $8, $9, 0x2
++ beqz $8, __ep0_set_data_length
++ sub $8, $9, 0x3
++ beqz $8, __ep0_flush_caches
++ sub $8, $9, 0x4
++ beqz $8, __ep0_prog_start1
++ sub $8, $9, 0x5
++ beqz $8, __ep0_prog_start2
++ nop
++ b _ep0_idle_state_fini /* invalid request */
++ nop
++
++__ep0_get_cpu_info:
++ load_addr $20, cpu_info_data /* data pointer to transfer */
++ li $21, 8 /* bytes left to transfer */
++ li $22, 1 /* set EP0 to TX state */
++ li $23, 0 /* NoData = 0 */
++
++ b _ep0_idle_state_fini
++ nop
++
++__ep0_set_data_address:
++ li $9, 0xffff0000
++ and $9, $25, $9
++ andi $8, $26, 0xffff
++ or $20, $9, $8 /* data address of next transfer */
++
++ b _ep0_idle_state_fini
++ nop
++
++__ep0_set_data_length:
++ li $9, 0xffff0000
++ and $9, $25, $9
++ andi $8, $26, 0xffff
++ or $21, $9, $8 /* data length of next transfer */
++
++ li $9, 0x48 /* SVDOUTPKTRDY and DATAEND */
++ sb $9, 0x12($27) /* CSR0 */
++
++ /* We must write packet to FIFO before EP1-IN interrupt here. */
++ b handle_epin1_intr
++ nop
++
++__ep0_flush_caches:
++ /* Flush dcache and invalidate icache. */
++ li $8, 0x80000000
++ addi $9, $8, 0x3fe0 /* total 16KB */
++
++1:
++ cache 0x0, 0($8) /* Index_Invalidate_I */
++ cache 0x1, 0($8) /* Index_Writeback_Inv_D */
++ bne $8, $9, 1b
++ addiu $8, $8, 32
++
++ /* flush write-buffer */
++ sync
++
++ /* Invalidate BTB */
++ mfc0 $8, $16, 7 /* CP0_CONFIG */
++ nop
++ ori $8, 2
++ mtc0 $8, $16, 7
++ nop
++
++ b _ep0_idle_state_fini
++ nop
++
++__ep0_prog_start1:
++ li $9, 0x48 /* SVDOUTPKTRDY and DATAEND */
++ sb $9, 0x12($27) /* CSR0 */
++
++ li $9, 0xffff0000
++ and $9, $25, $9
++ andi $8, $26, 0xffff
++ or $20, $9, $8 /* target address */
++
++ b xfer_d2i
++ li $19, 0x2000 /* 16KB data length */
++
++__ep0_prog_start2:
++ li $9, 0x48 /* SVDOUTPKTRDY and DATAEND */
++ sb $9, 0x12($27) /* CSR0 */
++
++ li $9, 0xffff0000
++ and $9, $25, $9
++ andi $8, $26, 0xffff
++ or $20, $9, $8 /* target address */
++
++ jalr $20 /* jump, and place the return address in $31 */
++ nop
++
++__ep0_prog_start2_return:
++/* User code can return to here after executing itself, by jumping to $31 */
++ b usb_boot_return
++ nop
++
++ /* 2.1.2 Standard setup request */
++_ep0_std_req:
++ andi $12, $25, 0xff00 /* check bRequest */
++ srl $12, $12, 8
++ sub $9, $12, 0x05 /* check USB_REQ_SET_ADDRESS */
++ bnez $9, __ep0_req_set_config
++ nop
++
++ /* Handle USB_REQ_SET_ADDRESS */
++__ep0_req_set_addr:
++ srl $9, $25, 16 /* get wValue */
++ sb $9, 0x0($27) /* set FADDR */
++ li $23, 1 /* NoData = 1 */
++ b _ep0_idle_state_fini
++ nop
++
++__ep0_req_set_config:
++ sub $9, $12, 0x09 /* check USB_REQ_SET_CONFIGURATION */
++ bnez $9, __ep0_req_get_desc
++ nop
++
++ /* Handle USB_REQ_SET_CONFIGURATION */
++ li $23, 1 /* NoData = 1 */
++ b _ep0_idle_state_fini
++ nop
++
++__ep0_req_get_desc:
++ sub $9, $12, 0x06 /* check USB_REQ_GET_DESCRIPTOR */
++ bnez $9, _ep0_idle_state_fini
++ li $23, 1 /* NoData = 1 */
++
++ /* Handle USB_REQ_GET_DESCRIPTOR */
++ li $23, 0 /* NoData = 0 */
++
++ srl $9, $25, 24 /* wValue >> 8 */
++ sub $8, $9, 0x01 /* check USB_DT_DEVICE */
++ beqz $8, ___ep0_get_dev_desc
++ srl $21, $26, 16 /* get wLength */
++ sub $8, $9, 0x02 /* check USB_DT_CONFIG */
++ beqz $8, ___ep0_get_conf_desc
++ sub $8, $9, 0x03 /* check USB_DT_STRING */
++ beqz $8, ___ep0_get_string_desc
++ sub $8, $9, 0x06 /* check USB_DT_DEVICE_QUALIFIER */
++ beqz $8, ___ep0_get_dev_qualifier
++ nop
++ b _ep0_idle_state_fini
++ nop
++
++___ep0_get_dev_desc:
++ load_addr $20, device_desc /* data pointer */
++ li $22, 1 /* set EP0 to TX state */
++ sub $8, $21, 18
++ blez $8, _ep0_idle_state_fini /* wLength <= 18 */
++ nop
++ li $21, 18 /* max length of device_desc */
++ b _ep0_idle_state_fini
++ nop
++
++___ep0_get_dev_qualifier:
++ load_addr $20, dev_qualifier /* data pointer */
++ li $22, 1 /* set EP0 to TX state */
++ sub $8, $21, 10
++ blez $8, _ep0_idle_state_fini /* wLength <= 10 */
++ nop
++ li $21, 10 /* max length of dev_qualifier */
++ b _ep0_idle_state_fini
++ nop
++
++___ep0_get_conf_desc:
++ load_addr $20, config_desc_fs /* data pointer of FS mode */
++ lbu $8, 0x01($27) /* read POWER */
++ andi $8, 0x10 /* test HS_MODE */
++ beqz $8, ___ep0_get_conf_desc2
++ nop
++ load_addr $20, config_desc_hs /* data pointer of HS mode */
++
++___ep0_get_conf_desc2:
++ li $22, 1 /* set EP0 to TX state */
++ sub $8, $21, 32
++ blez $8, _ep0_idle_state_fini /* wLength <= 32 */
++ nop
++ li $21, 32 /* max length of config_desc */
++ b _ep0_idle_state_fini
++ nop
++
++___ep0_get_string_desc:
++ li $22, 1 /* set EP0 to TX state */
++
++ srl $9, $25, 16 /* wValue & 0xff */
++ andi $9, 0xff
++
++ sub $8, $9, 1
++ beqz $8, ___ep0_get_string_manufacture
++ sub $8, $9, 2
++ beqz $8, ___ep0_get_string_product
++ nop
++
++___ep0_get_string_lang_ids:
++ load_addr $20, string_lang_ids /* data pointer */
++ b _ep0_idle_state_fini
++ li $21, 4 /* data length */
++
++___ep0_get_string_manufacture:
++ load_addr $20, string_manufacture /* data pointer */
++ b _ep0_idle_state_fini
++ li $21, 16 /* data length */
++
++___ep0_get_string_product:
++ load_addr $20, string_product /* data pointer */
++ b _ep0_idle_state_fini
++ li $21, 46 /* data length */
++
++_ep0_idle_state_fini:
++ li $9, 0x40 /* SVDOUTPKTRDY */
++ beqz $23, _ep0_idle_state_fini2
++ nop
++ ori $9, $9, 0x08 /* DATAEND */
++_ep0_idle_state_fini2:
++ sb $9, 0x12($27) /* CSR0 */
++ beqz $22, check_intr_ep1in
++ nop
++
++ /* 2.2 Handle EP0 TX state interrupt */
++ep0_tx_state:
++ sub $9, $22, 1
++ bnez $9, check_intr_ep1in
++ nop
++
++ sub $9, $21, 64 /* max packetsize */
++ blez $9, _ep0_tx_state2 /* data count <= 64 */
++ ori $19, $21, 0
++ li $19, 64
++
++_ep0_tx_state2:
++ beqz $19, _ep0_tx_state3 /* send ZLP */
++ ori $18, $19, 0 /* record bytes to be transferred */
++ sub $21, $21, $19 /* decrement data count */
++
++_ep0_fifo_write_loop:
++ lbu $9, 0($20) /* read data */
++ sb $9, 0x20($27) /* load FIFO */
++ sub $19, $19, 1 /* decrement counter */
++ bnez $19, _ep0_fifo_write_loop
++ addi $20, $20, 1 /* increment data pointer */
++
++ sub $9, $18, 64 /* max packetsize */
++ beqz $9, _ep0_tx_state4
++ nop
++
++_ep0_tx_state3:
++ /* transferred bytes < max packetsize */
++ li $9, 0x0a /* set INPKTRDY and DATAEND */
++ sb $9, 0x12($27) /* CSR0 */
++ li $22, 0 /* set EP0 to IDLE state */
++ b check_intr_ep1in
++ nop
++
++_ep0_tx_state4:
++ /* transferred bytes == max packetsize */
++ li $9, 0x02 /* set INPKTRDY */
++ sb $9, 0x12($27) /* CSR0 */
++ b check_intr_ep1in
++ nop
++
++ /* 3. Check and handle EP1 BULK-IN interrupt */
++check_intr_ep1in:
++ andi $9, $10, 0x2 /* check EP1 IN interrupt */
++ beqz $9, check_intr_ep1out
++ nop
++
++handle_epin1_intr:
++ li $9, 1
++ sb $9, 0x0e($27) /* set INDEX 1 */
++ lbu $9, 0x12($27) /* read INCSR */
++
++ andi $8, $9, 0x2 /* check INCSR_FFNOTEMPT */
++ bnez $8, _epin1_tx_state4
++ nop
++
++_epin1_write_fifo:
++ lhu $9, 0x10($27) /* get INMAXP */
++ sub $8, $21, $9
++ blez $8, _epin1_tx_state1 /* bytes left <= INMAXP */
++ ori $19, $21, 0
++ ori $19, $9, 0
++
++_epin1_tx_state1:
++ beqz $19, _epin1_tx_state4 /* No data */
++ nop
++
++ sub $21, $21, $19 /* decrement data count */
++
++ srl $5, $19, 2 /* # of word */
++ andi $6, $19, 0x3 /* # of byte */
++ beqz $5, _epin1_tx_state2
++ nop
++
++_epin1_fifo_write_word:
++ lw $9, 0($20) /* read data from source address */
++ sw $9, 0x24($27) /* write FIFO */
++ sub $5, $5, 1 /* decrement counter */
++ bnez $5, _epin1_fifo_write_word
++ addiu $20, $20, 4 /* increment dest address */
++
++_epin1_tx_state2:
++ beqz $6, _epin1_tx_state3
++ nop
++
++_epin1_fifo_write_byte:
++ lbu $9, 0($20) /* read data from source address */
++ sb $9, 0x24($27) /* write FIFO */
++ sub $6, $6, 1 /* decrement counter */
++ bnez $6, _epin1_fifo_write_byte
++ addiu $20, $20, 1 /* increment dest address */
++
++_epin1_tx_state3:
++ li $9, 0x1
++ sb $9, 0x12($27) /* INCSR, set INPKTRDY */
++
++_epin1_tx_state4:
++ /* 4. Check and handle EP1 BULK-OUT interrupt */
++check_intr_ep1out:
++ lhu $9, 0x04($27) /* read INTROUT */
++ andi $9, 0x2
++ beqz $9, check_status_next
++ nop
++
++handle_epout1_intr:
++ li $9, 1
++ sb $9, 0x0e($27) /* set INDEX 1 */
++
++ lbu $9, 0x16($27) /* read OUTCSR */
++ andi $9, 0x1 /* check OUTPKTRDY */
++ beqz $9, check_status_next
++ nop
++
++_epout1_read_fifo:
++ lhu $19, 0x18($27) /* read OUTCOUNT */
++ srl $5, $19, 2 /* # of word */
++ andi $6, $19, 0x3 /* # of byte */
++ beqz $5, _epout1_rx_state1
++ nop
++
++_epout1_fifo_read_word:
++ lw $9, 0x24($27) /* read FIFO */
++ sw $9, 0($20) /* store to dest address */
++ sub $5, $5, 1 /* decrement counter */
++ bnez $5, _epout1_fifo_read_word
++ addiu $20, $20, 4 /* increment dest address */
++
++_epout1_rx_state1:
++ beqz $6, _epout1_rx_state2
++ nop
++
++_epout1_fifo_read_byte:
++ lbu $9, 0x24($27) /* read FIFO */
++ sb $9, 0($20) /* store to dest address */
++ sub $6, $6, 1 /* decrement counter */
++ bnez $6, _epout1_fifo_read_byte
++ addiu $20, $20, 1 /* increment dest address */
++
++_epout1_rx_state2:
++ sb $0, 0x16($27) /* clear OUTPKTRDY */
++
++check_status_next:
++ b usb_command_loop
++ nop
++
++/* Device/Configuration/Interface/Endpoint/String Descriptors */
++
++ .align 2
++device_desc:
++ .byte 0x12 /* bLength */
++ .byte 0x01 /* bDescriptorType */
++ .byte 0x00 /* bcdUSB */
++ .byte 0x02 /* bcdUSB */
++ .byte 0x00 /* bDeviceClass */
++ .byte 0x00 /* bDeviceSubClass */
++ .byte 0x00 /* bDeviceProtocol */
++ .byte 0x40 /* bMaxPacketSize0 */
++ .byte 0x1a /* idVendor */
++ .byte 0x60 /* idVendor */
++ .byte 0x40 /* idProduct */
++ .byte 0x47 /* idProduct */
++ .byte 0x00 /* bcdDevice */
++ .byte 0x01 /* bcdDevice */
++ .byte 0x01 /* iManufacturer */
++ .byte 0x02 /* iProduct */
++ .byte 0x00 /* iSerialNumber */
++ .byte 0x01 /* bNumConfigurations */
++
++ .align 2
++dev_qualifier:
++ .byte 0x0a /* bLength */
++ .byte 0x06 /* bDescriptorType */
++ .byte 0x00 /* bcdUSB */
++ .byte 0x02 /* bcdUSB */
++ .byte 0x00 /* bDeviceClass */
++ .byte 0x00 /* bDeviceSubClass */
++ .byte 0x00 /* bDeviceProtocol */
++ .byte 0x40 /* bMaxPacketSize0 */
++ .byte 0x01 /* bNumConfigurations */
++ .byte 0x00 /* bRESERVED */
++
++ .align 2
++config_desc_hs:
++ .byte 0x09 /* bLength */
++ .byte 0x02 /* bDescriptorType */
++ .byte 0x20 /* wTotalLength */
++ .byte 0x00 /* wTotalLength */
++ .byte 0x01 /* bNumInterfaces */
++ .byte 0x01 /* bConfigurationValue */
++ .byte 0x00 /* iConfiguration */
++ .byte 0xc0 /* bmAttributes */
++ .byte 0x01 /* MaxPower */
++intf_desc_hs:
++ .byte 0x09 /* bLength */
++ .byte 0x04 /* bDescriptorType */
++ .byte 0x00 /* bInterfaceNumber */
++ .byte 0x00 /* bAlternateSetting */
++ .byte 0x02 /* bNumEndpoints */
++ .byte 0xff /* bInterfaceClass */
++ .byte 0x00 /* bInterfaceSubClass */
++ .byte 0x50 /* bInterfaceProtocol */
++ .byte 0x00 /* iInterface */
++ep1_desc_hs:
++ .byte 0x07 /* bLength */
++ .byte 0x05 /* bDescriptorType */
++ .byte 0x01 /* bEndpointAddress */
++ .byte 0x02 /* bmAttributes */
++ .byte 0x00 /* wMaxPacketSize */
++ .byte 0x02 /* wMaxPacketSize */
++ .byte 0x00 /* bInterval */
++ep2_desc_hs:
++ .byte 0x07 /* bLength */
++ .byte 0x05 /* bDescriptorType */
++ .byte 0x81 /* bEndpointAddress */
++ .byte 0x02 /* bmAttributes */
++ .byte 0x00 /* wMaxPacketSize */
++ .byte 0x02 /* wMaxPacketSize */
++ .byte 0x00 /* bInterval */
++
++ .align 2
++config_desc_fs:
++ .byte 0x09 /* bLength */
++ .byte 0x02 /* bDescriptorType */
++ .byte 0x20 /* wTotalLength */
++ .byte 0x00 /* wTotalLength */
++ .byte 0x01 /* bNumInterfaces */
++ .byte 0x01 /* bConfigurationValue */
++ .byte 0x00 /* iConfiguration */
++ .byte 0xc0 /* bmAttributes */
++ .byte 0x01 /* MaxPower */
++intf_desc_fs:
++ .byte 0x09 /* bLength */
++ .byte 0x04 /* bDescriptorType */
++ .byte 0x00 /* bInterfaceNumber */
++ .byte 0x00 /* bAlternateSetting */
++ .byte 0x02 /* bNumEndpoints */
++ .byte 0xff /* bInterfaceClass */
++ .byte 0x00 /* bInterfaceSubClass */
++ .byte 0x50 /* bInterfaceProtocol */
++ .byte 0x00 /* iInterface */
++ep1_desc_fs:
++ .byte 0x07 /* bLength */
++ .byte 0x05 /* bDescriptorType */
++ .byte 0x01 /* bEndpointAddress */
++ .byte 0x02 /* bmAttributes */
++ .byte 0x40 /* wMaxPacketSize */
++ .byte 0x00 /* wMaxPacketSize */
++ .byte 0x00 /* bInterval */
++ep2_desc_fs:
++ .byte 0x07 /* bLength */
++ .byte 0x05 /* bDescriptorType */
++ .byte 0x81 /* bEndpointAddress */
++ .byte 0x02 /* bmAttributes */
++ .byte 0x40 /* wMaxPacketSize */
++ .byte 0x00 /* wMaxPacketSize */
++ .byte 0x00 /* bInterval */
++
++ .align 2
++string_lang_ids:
++ .byte 0x04
++ .byte 0x03
++ .byte 0x09
++ .byte 0x04
++
++ .align 2
++string_manufacture:
++ .byte 0x10
++ .byte 0x03
++ .byte 0x49
++ .byte 0x00
++ .byte 0x6e
++ .byte 0x00
++ .byte 0x67
++ .byte 0x00
++ .byte 0x65
++ .byte 0x00
++ .byte 0x6e
++ .byte 0x00
++ .byte 0x69
++ .byte 0x00
++ .byte 0x63
++ .byte 0x00
++
++ .align 2
++string_product:
++ .byte 0x2e
++ .byte 0x03
++ .byte 0x4a
++ .byte 0x00
++ .byte 0x5a
++ .byte 0x00
++ .byte 0x34
++ .byte 0x00
++ .byte 0x37
++ .byte 0x00
++ .byte 0x34
++ .byte 0x00
++ .byte 0x30
++ .byte 0x00
++ .byte 0x20
++ .byte 0x00
++ .byte 0x55
++ .byte 0x00
++ .byte 0x53
++ .byte 0x00
++ .byte 0x42
++ .byte 0x00
++ .byte 0x20
++ .byte 0x00
++ .byte 0x42
++ .byte 0x00
++ .byte 0x6f
++ .byte 0x00
++ .byte 0x6f
++ .byte 0x00
++ .byte 0x74
++ .byte 0x00
++ .byte 0x20
++ .byte 0x00
++ .byte 0x44
++ .byte 0x00
++ .byte 0x65
++ .byte 0x00
++ .byte 0x76
++ .byte 0x00
++ .byte 0x69
++ .byte 0x00
++ .byte 0x63
++ .byte 0x00
++ .byte 0x65
++ .byte 0x00
++
++ .align 2
++cpu_info_data:
++ .byte 0x4a
++ .byte 0x5a
++ .byte 0x34
++ .byte 0x37
++ .byte 0x34
++ .byte 0x30
++ .byte 0x56
++ .byte 0x31
++usbboot_end:
++
++ .set reorder
+--
+1.7.9.5
+
diff --git a/package/boot/uboot-xburst/patches/0003-add-mmc-support.patch b/package/boot/uboot-xburst/patches/0003-add-mmc-support.patch
new file mode 100644
index 0000000..e9baa7c
--- /dev/null
+++ b/package/boot/uboot-xburst/patches/0003-add-mmc-support.patch
@@ -0,0 +1,1664 @@
+From bd36739e77669e8df45c38f6acfe2cea511534d9 Mon Sep 17 00:00:00 2001
+From: Xiangfu <xiangfu@openmobilefree.net>
+Date: Wed, 10 Oct 2012 18:19:41 +0800
+Subject: [PATCH 3/6] add mmc support
+
+---
+ arch/mips/include/asm/jz4740.h | 166 ++++++
+ board/qi/qi_lb60/qi_lb60.c | 9 +-
+ drivers/mmc/Makefile | 1 +
+ drivers/mmc/jz_mmc.c | 1179 ++++++++++++++++++++++++++++++++++++++++
+ drivers/mmc/jz_mmc.h | 176 ++++++
+ include/configs/qi_lb60.h | 9 +
+ include/mmc.h | 40 ++
+ 7 files changed, 1578 insertions(+), 2 deletions(-)
+ create mode 100644 drivers/mmc/jz_mmc.c
+ create mode 100644 drivers/mmc/jz_mmc.h
+
+diff --git a/arch/mips/include/asm/jz4740.h b/arch/mips/include/asm/jz4740.h
+index 7a7cfff..68287fb 100644
+--- a/arch/mips/include/asm/jz4740.h
++++ b/arch/mips/include/asm/jz4740.h
+@@ -1146,5 +1146,171 @@ extern void sdram_init(void);
+ extern void calc_clocks(void);
+ extern void rtc_init(void);
+
++/*************************************************************************
++ * MSC
++ *************************************************************************/
++#define REG8(addr) *((volatile u8 *)(addr))
++#define REG16(addr) *((volatile u16 *)(addr))
++#define REG32(addr) *((volatile u32 *)(addr))
++
++#define CPM_BASE 0xB0000000
++#define CPM_CPCCR (CPM_BASE+0x00)
++#define CPM_MSCCDR (CPM_BASE+0x68)
++#define REG_CPM_MSCCDR REG32(CPM_MSCCDR)
++#define REG_CPM_CPCCR REG32(CPM_CPCCR)
++
++#define MSC_BASE 0xB0021000
++
++#define MSC_STRPCL (MSC_BASE + 0x000)
++#define MSC_STAT (MSC_BASE + 0x004)
++#define MSC_CLKRT (MSC_BASE + 0x008)
++#define MSC_CMDAT (MSC_BASE + 0x00C)
++#define MSC_RESTO (MSC_BASE + 0x010)
++#define MSC_RDTO (MSC_BASE + 0x014)
++#define MSC_BLKLEN (MSC_BASE + 0x018)
++#define MSC_NOB (MSC_BASE + 0x01C)
++#define MSC_SNOB (MSC_BASE + 0x020)
++#define MSC_IMASK (MSC_BASE + 0x024)
++#define MSC_IREG (MSC_BASE + 0x028)
++#define MSC_CMD (MSC_BASE + 0x02C)
++#define MSC_ARG (MSC_BASE + 0x030)
++#define MSC_RES (MSC_BASE + 0x034)
++#define MSC_RXFIFO (MSC_BASE + 0x038)
++#define MSC_TXFIFO (MSC_BASE + 0x03C)
++
++#define REG_MSC_STRPCL REG16(MSC_STRPCL)
++#define REG_MSC_STAT REG32(MSC_STAT)
++#define REG_MSC_CLKRT REG16(MSC_CLKRT)
++#define REG_MSC_CMDAT REG32(MSC_CMDAT)
++#define REG_MSC_RESTO REG16(MSC_RESTO)
++#define REG_MSC_RDTO REG16(MSC_RDTO)
++#define REG_MSC_BLKLEN REG16(MSC_BLKLEN)
++#define REG_MSC_NOB REG16(MSC_NOB)
++#define REG_MSC_SNOB REG16(MSC_SNOB)
++#define REG_MSC_IMASK REG16(MSC_IMASK)
++#define REG_MSC_IREG REG16(MSC_IREG)
++#define REG_MSC_CMD REG8(MSC_CMD)
++#define REG_MSC_ARG REG32(MSC_ARG)
++#define REG_MSC_RES REG16(MSC_RES)
++#define REG_MSC_RXFIFO REG32(MSC_RXFIFO)
++#define REG_MSC_TXFIFO REG32(MSC_TXFIFO)
++
++/* MSC Clock and Control Register (MSC_STRPCL) */
++
++#define MSC_STRPCL_EXIT_MULTIPLE (1 << 7)
++#define MSC_STRPCL_EXIT_TRANSFER (1 << 6)
++#define MSC_STRPCL_START_READWAIT (1 << 5)
++#define MSC_STRPCL_STOP_READWAIT (1 << 4)
++#define MSC_STRPCL_RESET (1 << 3)
++#define MSC_STRPCL_START_OP (1 << 2)
++#define MSC_STRPCL_CLOCK_CONTROL_BIT 0
++#define MSC_STRPCL_CLOCK_CONTROL_MASK (0x3 << MSC_STRPCL_CLOCK_CONTROL_BIT)
++ #define MSC_STRPCL_CLOCK_CONTROL_STOP (0x1 << MSC_STRPCL_CLOCK_CONTROL_BIT) /* Stop MMC/SD clock */
++ #define MSC_STRPCL_CLOCK_CONTROL_START (0x2 << MSC_STRPCL_CLOCK_CONTROL_BIT) /* Start MMC/SD clock */
++
++/* MSC Status Register (MSC_STAT) */
++
++#define MSC_STAT_IS_RESETTING (1 << 15)
++#define MSC_STAT_SDIO_INT_ACTIVE (1 << 14)
++#define MSC_STAT_PRG_DONE (1 << 13)
++#define MSC_STAT_DATA_TRAN_DONE (1 << 12)
++#define MSC_STAT_END_CMD_RES (1 << 11)
++#define MSC_STAT_DATA_FIFO_AFULL (1 << 10)
++#define MSC_STAT_IS_READWAIT (1 << 9)
++#define MSC_STAT_CLK_EN (1 << 8)
++#define MSC_STAT_DATA_FIFO_FULL (1 << 7)
++#define MSC_STAT_DATA_FIFO_EMPTY (1 << 6)
++#define MSC_STAT_CRC_RES_ERR (1 << 5)
++#define MSC_STAT_CRC_READ_ERROR (1 << 4)
++#define MSC_STAT_CRC_WRITE_ERROR_BIT 2
++#define MSC_STAT_CRC_WRITE_ERROR_MASK (0x3 << MSC_STAT_CRC_WRITE_ERROR_BIT)
++ #define MSC_STAT_CRC_WRITE_ERROR_NO (0 << MSC_STAT_CRC_WRITE_ERROR_BIT) /* No error on transmission of data */
++ #define MSC_STAT_CRC_WRITE_ERROR (1 << MSC_STAT_CRC_WRITE_ERROR_BIT) /* Card observed erroneous transmission of data */
++ #define MSC_STAT_CRC_WRITE_ERROR_NOSTS (2 << MSC_STAT_CRC_WRITE_ERROR_BIT) /* No CRC status is sent back */
++#define MSC_STAT_TIME_OUT_RES (1 << 1)
++#define MSC_STAT_TIME_OUT_READ (1 << 0)
++
++/* MSC Bus Clock Control Register (MSC_CLKRT) */
++
++#define MSC_CLKRT_CLK_RATE_BIT 0
++#define MSC_CLKRT_CLK_RATE_MASK (0x7 << MSC_CLKRT_CLK_RATE_BIT)
++ #define MSC_CLKRT_CLK_RATE_DIV_1 (0x0 << MSC_CLKRT_CLK_RATE_BIT) /* CLK_SRC */
++ #define MSC_CLKRT_CLK_RATE_DIV_2 (0x1 << MSC_CLKRT_CLK_RATE_BIT) /* 1/2 of CLK_SRC */
++ #define MSC_CLKRT_CLK_RATE_DIV_4 (0x2 << MSC_CLKRT_CLK_RATE_BIT) /* 1/4 of CLK_SRC */
++ #define MSC_CLKRT_CLK_RATE_DIV_8 (0x3 << MSC_CLKRT_CLK_RATE_BIT) /* 1/8 of CLK_SRC */
++ #define MSC_CLKRT_CLK_RATE_DIV_16 (0x4 << MSC_CLKRT_CLK_RATE_BIT) /* 1/16 of CLK_SRC */
++ #define MSC_CLKRT_CLK_RATE_DIV_32 (0x5 << MSC_CLKRT_CLK_RATE_BIT) /* 1/32 of CLK_SRC */
++ #define MSC_CLKRT_CLK_RATE_DIV_64 (0x6 << MSC_CLKRT_CLK_RATE_BIT) /* 1/64 of CLK_SRC */
++ #define MSC_CLKRT_CLK_RATE_DIV_128 (0x7 << MSC_CLKRT_CLK_RATE_BIT) /* 1/128 of CLK_SRC */
++
++/* MSC Command Sequence Control Register (MSC_CMDAT) */
++
++#define MSC_CMDAT_IO_ABORT (1 << 11)
++#define MSC_CMDAT_BUS_WIDTH_BIT 9
++#define MSC_CMDAT_BUS_WIDTH_MASK (0x3 << MSC_CMDAT_BUS_WIDTH_BIT)
++#define MSC_CMDAT_BUS_WIDTH_1BIT (0x0 << MSC_CMDAT_BUS_WIDTH_BIT)
++#define MSC_CMDAT_BUS_WIDTH_4BIT (0x2 << MSC_CMDAT_BUS_WIDTH_BIT)
++#define MSC_CMDAT_DMA_EN (1 << 8)
++#define MSC_CMDAT_INIT (1 << 7)
++#define MSC_CMDAT_BUSY (1 << 6)
++#define MSC_CMDAT_STREAM_BLOCK (1 << 5)
++#define MSC_CMDAT_WRITE (1 << 4)
++#define MSC_CMDAT_READ (0 << 4)
++#define MSC_CMDAT_DATA_EN (1 << 3)
++#define MSC_CMDAT_RESPONSE_BIT 0
++#define MSC_CMDAT_RESPONSE_MASK (0x7 << MSC_CMDAT_RESPONSE_BIT)
++#define MSC_CMDAT_RESPONSE_NONE (0x0 << MSC_CMDAT_RESPONSE_BIT)
++#define MSC_CMDAT_RESPONSE_R1 (0x1 << MSC_CMDAT_RESPONSE_BIT)
++#define MSC_CMDAT_RESPONSE_R2 (0x2 << MSC_CMDAT_RESPONSE_BIT)
++#define MSC_CMDAT_RESPONSE_R3 (0x3 << MSC_CMDAT_RESPONSE_BIT)
++#define MSC_CMDAT_RESPONSE_R4 (0x4 << MSC_CMDAT_RESPONSE_BIT)
++#define MSC_CMDAT_RESPONSE_R5 (0x5 << MSC_CMDAT_RESPONSE_BIT)
++#define MSC_CMDAT_RESPONSE_R6 (0x6 << MSC_CMDAT_RESPONSE_BIT)
++
++/* MSC Interrupts Mask Register (MSC_IMASK) */
++#define MSC_IMASK_SDIO (1 << 7)
++#define MSC_IMASK_TXFIFO_WR_REQ (1 << 6)
++#define MSC_IMASK_RXFIFO_RD_REQ (1 << 5)
++#define MSC_IMASK_END_CMD_RES (1 << 2)
++#define MSC_IMASK_PRG_DONE (1 << 1)
++#define MSC_IMASK_DATA_TRAN_DONE (1 << 0)
++
++
++/* MSC Interrupts Status Register (MSC_IREG) */
++#define MSC_IREG_SDIO (1 << 7)
++#define MSC_IREG_TXFIFO_WR_REQ (1 << 6)
++#define MSC_IREG_RXFIFO_RD_REQ (1 << 5)
++#define MSC_IREG_END_CMD_RES (1 << 2)
++#define MSC_IREG_PRG_DONE (1 << 1)
++#define MSC_IREG_DATA_TRAN_DONE (1 << 0)
++
++static __inline__ unsigned int __cpm_get_pllout2(void)
++{
++ if (REG_CPM_CPCCR & CPM_CPCCR_PCS)
++ return __cpm_get_pllout();
++ else
++ return __cpm_get_pllout()/2;
++}
++
++static inline void __cpm_select_msc_clk(int sd)
++{
++ unsigned int pllout2 = __cpm_get_pllout2();
++ unsigned int div = 0;
++
++ if (sd) {
++ div = pllout2 / 24000000;
++ }
++ else {
++ div = pllout2 / 16000000;
++ }
++
++ REG_CPM_MSCCDR = div - 1;
++}
++#define __msc_reset() \
++do { \
++ REG_MSC_STRPCL = MSC_STRPCL_RESET; \
++ while (REG_MSC_STAT & MSC_STAT_IS_RESETTING); \
++} while (0)
++
+ #endif /* !__ASSEMBLY__ */
+ #endif /* __JZ4740_H__ */
+diff --git a/board/qi/qi_lb60/qi_lb60.c b/board/qi/qi_lb60/qi_lb60.c
+index 3bd4e2f..a2ba648 100644
+--- a/board/qi/qi_lb60/qi_lb60.c
++++ b/board/qi/qi_lb60/qi_lb60.c
+@@ -40,8 +40,13 @@ static void gpio_init(void)
+ __gpio_clear_pin(GPIO_KEYOUT_BASE + i);
+ }
+
+- __gpio_as_input(GPIO_KEYIN_8);
+- __gpio_enable_pull(GPIO_KEYIN_8);
++ if (__gpio_get_pin(GPIO_KEYIN_BASE + 2) == 0){
++ printf("[S] pressed, enable UART0\n");
++ __gpio_as_uart0();
++ } else {
++ __gpio_as_input(GPIO_KEYIN_8);
++ __gpio_enable_pull(GPIO_KEYIN_8);
++ }
+
+ /* enable the TP4, TP5 as UART0 */
+ __gpio_jtag_to_uart0();
+diff --git a/drivers/mmc/Makefile b/drivers/mmc/Makefile
+index 565ba6a..3c717b1 100644
+--- a/drivers/mmc/Makefile
++++ b/drivers/mmc/Makefile
+@@ -47,6 +47,7 @@ COBJS-$(CONFIG_SDHCI) += sdhci.o
+ COBJS-$(CONFIG_S5P_SDHCI) += s5p_sdhci.o
+ COBJS-$(CONFIG_SH_MMCIF) += sh_mmcif.o
+ COBJS-$(CONFIG_TEGRA_MMC) += tegra_mmc.o
++COBJS-$(CONFIG_JZ4740_MMC) += jz_mmc.o
+
+ COBJS := $(COBJS-y)
+ SRCS := $(COBJS:.o=.c)
+diff --git a/drivers/mmc/jz_mmc.c b/drivers/mmc/jz_mmc.c
+new file mode 100644
+index 0000000..642cecc
+--- /dev/null
++++ b/drivers/mmc/jz_mmc.c
+@@ -0,0 +1,1179 @@
++/*
++ * (C) Copyright 2003
++ * Kyle Harris, Nexus Technologies, Inc. kharris@nexus-tech.net
++ *
++ * See file CREDITS for list of people who contributed to this
++ * project.
++ *
++ * 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 of
++ * the License, 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; if not, write to the Free Software
++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ * MA 02111-1307 USA
++ */
++
++#include <config.h>
++#include <common.h>
++#include <part.h>
++#include <mmc.h>
++
++#include <asm/io.h>
++#include <asm/jz4740.h>
++#include "jz_mmc.h"
++
++static int sd2_0 = 0;
++static int mmc_ready = 0;
++static int use_4bit; /* Use 4-bit data bus */
++/*
++ * MMC Events
++ */
++#define MMC_EVENT_NONE 0x00 /* No events */
++#define MMC_EVENT_RX_DATA_DONE 0x01 /* Rx data done */
++#define MMC_EVENT_TX_DATA_DONE 0x02 /* Tx data done */
++#define MMC_EVENT_PROG_DONE 0x04 /* Programming is done */
++
++
++#define MMC_IRQ_MASK() \
++do { \
++ REG_MSC_IMASK = 0xffff; \
++ REG_MSC_IREG = 0xffff; \
++} while (0)
++
++/*
++ * GPIO definition
++ */
++#if defined(CONFIG_SAKC)
++
++#define __msc_init_io() \
++do { \
++ __gpio_as_input(GPIO_SD_CD_N); \
++} while (0)
++
++#else
++#define __msc_init_io() \
++do { \
++ __gpio_as_output(GPIO_SD_VCC_EN_N); \
++ __gpio_as_input(GPIO_SD_CD_N); \
++} while (0)
++
++#define __msc_enable_power() \
++do { \
++ __gpio_clear_pin(GPIO_SD_VCC_EN_N); \
++} while (0)
++
++#define __msc_disable_power() \
++do { \
++ __gpio_set_pin(GPIO_SD_VCC_EN_N); \
++} while (0)
++
++#endif /* CONFIG_SAKE */
++
++#define __msc_card_detected() \
++({ \
++ int detected = 1; \
++ __gpio_as_input(GPIO_SD_CD_N); \
++ __gpio_disable_pull(GPIO_SD_CD_N); \
++ if (!__gpio_get_pin(GPIO_SD_CD_N)) \
++ detected = 0; \
++ detected; \
++})
++
++/*
++ * Local functions
++ */
++
++extern int
++fat_register_device(block_dev_desc_t *dev_desc, int part_no);
++
++static block_dev_desc_t mmc_dev;
++
++block_dev_desc_t * mmc_get_dev(int dev)
++{
++ return ((block_dev_desc_t *)&mmc_dev);
++}
++
++/* Stop the MMC clock and wait while it happens */
++static inline int jz_mmc_stop_clock(void)
++{
++ int timeout = 1000;
++
++ REG_MSC_STRPCL = MSC_STRPCL_CLOCK_CONTROL_STOP;
++
++ while (timeout && (REG_MSC_STAT & MSC_STAT_CLK_EN)) {
++ timeout--;
++ if (timeout == 0)
++ return MMC_ERROR_TIMEOUT;
++ udelay(1);
++ }
++ return MMC_NO_ERROR;
++}
++
++/* Start the MMC clock and operation */
++static inline int jz_mmc_start_clock(void)
++{
++ REG_MSC_STRPCL = MSC_STRPCL_CLOCK_CONTROL_START | MSC_STRPCL_START_OP;
++ return MMC_NO_ERROR;
++}
++
++static inline u32 jz_mmc_calc_clkrt(int is_sd, u32 rate)
++{
++ u32 clkrt = 0;
++ u32 clk_src = is_sd ? 24000000 : 16000000;
++
++ while (rate < clk_src) {
++ clkrt ++;
++ clk_src >>= 1;
++ }
++
++ return clkrt;
++}
++
++/* Set the MMC clock frequency */
++void jz_mmc_set_clock(int sd, u32 rate)
++{
++ jz_mmc_stop_clock();
++
++ /* Select clock source of MSC */
++ __cpm_select_msc_clk(sd);
++
++ /* Set clock dividor of MSC */
++ REG_MSC_CLKRT = jz_mmc_calc_clkrt(sd, rate);
++}
++
++static int jz_mmc_check_status(struct mmc_request *request)
++{
++ u32 status = REG_MSC_STAT;
++
++ /* Checking for response or data timeout */
++ if (status & (MSC_STAT_TIME_OUT_RES | MSC_STAT_TIME_OUT_READ)) {
++ printf("MMC/SD timeout, MMC_STAT 0x%x CMD %d\n", status, request->cmd);
++ return MMC_ERROR_TIMEOUT;
++ }
++
++ /* Checking for CRC error */
++ if (status & (MSC_STAT_CRC_READ_ERROR | MSC_STAT_CRC_WRITE_ERROR | MSC_STAT_CRC_RES_ERR)) {
++ printf("MMC/CD CRC error, MMC_STAT 0x%x\n", status);
++ return MMC_ERROR_CRC;
++ }
++
++ return MMC_NO_ERROR;
++}
++
++/* Obtain response to the command and store it to response buffer */
++static void jz_mmc_get_response(struct mmc_request *request)
++{
++ int i;
++ u8 *buf;
++ u32 data;
++
++ debug("fetch response for request %d, cmd %d\n",
++ request->rtype, request->cmd);
++
++ buf = request->response;
++ request->result = MMC_NO_ERROR;
++
++ switch (request->rtype) {
++ case RESPONSE_R1: case RESPONSE_R1B: case RESPONSE_R6:
++ case RESPONSE_R3: case RESPONSE_R4: case RESPONSE_R5:
++ {
++ data = REG_MSC_RES;
++ buf[0] = (data >> 8) & 0xff;
++ buf[1] = data & 0xff;
++ data = REG_MSC_RES;
++ buf[2] = (data >> 8) & 0xff;
++ buf[3] = data & 0xff;
++ data = REG_MSC_RES;
++ buf[4] = data & 0xff;
++
++ debug("request %d, response [%02x %02x %02x %02x %02x]\n",
++ request->rtype, buf[0], buf[1], buf[2], buf[3], buf[4]);
++ break;
++ }
++ case RESPONSE_R2_CID: case RESPONSE_R2_CSD:
++ {
++ for (i = 0; i < 16; i += 2) {
++ data = REG_MSC_RES;
++ buf[i] = (data >> 8) & 0xff;
++ buf[i+1] = data & 0xff;
++ }
++ debug("request %d, response [", request->rtype);
++#if CONFIG_MMC_DEBUG_VERBOSE > 2
++ if (g_mmc_debug >= 3) {
++ int n;
++ for (n = 0; n < 17; n++)
++ printk("%02x ", buf[n]);
++ printk("]\n");
++ }
++#endif
++ break;
++ }
++ case RESPONSE_NONE:
++ debug("No response\n");
++ break;
++
++ default:
++ debug("unhandled response type for request %d\n", request->rtype);
++ break;
++ }
++}
++
++static int jz_mmc_receive_data(struct mmc_request *req)
++{
++ u32 stat, timeout, data, cnt;
++ u8 *buf = req->buffer;
++ u32 wblocklen = (u32)(req->block_len + 3) >> 2; /* length in word */
++
++ timeout = 0x3ffffff;
++
++ while (timeout) {
++ timeout--;
++ stat = REG_MSC_STAT;
++
++ if (stat & MSC_STAT_TIME_OUT_READ)
++ return MMC_ERROR_TIMEOUT;
++ else if (stat & MSC_STAT_CRC_READ_ERROR)
++ return MMC_ERROR_CRC;
++ else if (!(stat & MSC_STAT_DATA_FIFO_EMPTY)
++ || (stat & MSC_STAT_DATA_FIFO_AFULL)) {
++ /* Ready to read data */
++ break;
++ }
++ udelay(1);
++ }
++ if (!timeout)
++ return MMC_ERROR_TIMEOUT;
++
++ /* Read data from RXFIFO. It could be FULL or PARTIAL FULL */
++ cnt = wblocklen;
++ while (cnt) {
++ data = REG_MSC_RXFIFO;
++ {
++ *buf++ = (u8)(data >> 0);
++ *buf++ = (u8)(data >> 8);
++ *buf++ = (u8)(data >> 16);
++ *buf++ = (u8)(data >> 24);
++ }
++ cnt --;
++ while (cnt && (REG_MSC_STAT & MSC_STAT_DATA_FIFO_EMPTY))
++ ;
++ }
++ return MMC_NO_ERROR;
++}
++
++static int jz_mmc_transmit_data(struct mmc_request *req)
++{
++#if 0
++ u32 nob = req->nob;
++ u32 wblocklen = (u32)(req->block_len + 3) >> 2; /* length in word */
++ u8 *buf = req->buffer;
++ u32 *wbuf = (u32 *)buf;
++ u32 waligned = (((u32)buf & 0x3) == 0); /* word aligned ? */
++ u32 stat, timeout, data, cnt;
++
++ for (nob; nob >= 1; nob--) {
++ timeout = 0x3FFFFFF;
++
++ while (timeout) {
++ timeout--;
++ stat = REG_MSC_STAT;
++
++ if (stat & (MSC_STAT_CRC_WRITE_ERROR | MSC_STAT_CRC_WRITE_ERROR_NOSTS))
++ return MMC_ERROR_CRC;
++ else if (!(stat & MSC_STAT_DATA_FIFO_FULL)) {
++ /* Ready to write data */
++ break;
++ }
++
++ udelay(1);
++ }
++
++ if (!timeout)
++ return MMC_ERROR_TIMEOUT;
++
++ /* Write data to TXFIFO */
++ cnt = wblocklen;
++ while (cnt) {
++ while (REG_MSC_STAT & MSC_STAT_DATA_FIFO_FULL)
++ ;
++
++ if (waligned) {
++ REG_MSC_TXFIFO = *wbuf++;
++ }
++ else {
++ data = *buf++ | (*buf++ << 8) | (*buf++ << 16) | (*buf++ << 24);
++ REG_MSC_TXFIFO = data;
++ }
++
++ cnt--;
++ }
++ }
++#endif
++ return MMC_NO_ERROR;
++}
++
++
++/*
++ * Name: int jz_mmc_exec_cmd()
++ * Function: send command to the card, and get a response
++ * Input: struct mmc_request *req : MMC/SD request
++ * Output: 0: right >0: error code
++ */
++int jz_mmc_exec_cmd(struct mmc_request *request)
++{
++ u32 cmdat = 0, events = 0;
++ int retval, timeout = 0x3fffff;
++
++ /* Indicate we have no result yet */
++ request->result = MMC_NO_RESPONSE;
++ if (request->cmd == MMC_CIM_RESET) {
++ /* On reset, 1-bit bus width */
++ use_4bit = 0;
++
++ /* Reset MMC/SD controller */
++ __msc_reset();
++
++ /* On reset, drop MMC clock down */
++ jz_mmc_set_clock(0, MMC_CLOCK_SLOW);
++
++ /* On reset, stop MMC clock */
++ jz_mmc_stop_clock();
++ }
++ if (request->cmd == MMC_CMD_SEND_OP_COND) {
++ debug("Have an MMC card\n");
++ /* always use 1bit for MMC */
++ use_4bit = 0;
++ }
++ if (request->cmd == SET_BUS_WIDTH) {
++ if (request->arg == 0x2) {
++ printf("Use 4-bit bus width\n");
++ use_4bit = 1;
++ } else {
++ printf("Use 1-bit bus width\n");
++ use_4bit = 0;
++ }
++ }
++
++ /* stop clock */
++ jz_mmc_stop_clock();
++
++ /* mask all interrupts */
++ REG_MSC_IMASK = 0xffff;
++
++ /* clear status */
++ REG_MSC_IREG = 0xffff;
++
++ /* use 4-bit bus width when possible */
++ if (use_4bit)
++ cmdat |= MSC_CMDAT_BUS_WIDTH_4BIT;
++
++ /* Set command type and events */
++ switch (request->cmd) {
++ /* MMC core extra command */
++ case MMC_CIM_RESET:
++ cmdat |= MSC_CMDAT_INIT; /* Initialization sequence sent prior to command */
++ break;
++
++ /* bc - broadcast - no response */
++ case MMC_CMD_GO_IDLE_STATE:
++ case MMC_CMD_SET_DSR:
++ break;
++
++ /* bcr - broadcast with response */
++ case MMC_CMD_SEND_OP_COND:
++ case MMC_CMD_ALL_SEND_CID:
++ case MMC_GO_IRQ_STATE:
++ break;
++
++ /* adtc - addressed with data transfer */
++ case MMC_READ_DAT_UNTIL_STOP:
++ case MMC_CMD_READ_SINGLE_BLOCK:
++ case MMC_CMD_READ_MULTIPLE_BLOCK:
++ case SD_CMD_APP_SEND_SCR:
++ cmdat |= MSC_CMDAT_DATA_EN | MSC_CMDAT_READ;
++ events = MMC_EVENT_RX_DATA_DONE;
++ break;
++
++ case MMC_WRITE_DAT_UNTIL_STOP:
++ case MMC_CMD_WRITE_SINGLE_BLOCK:
++ case MMC_CMD_WRITE_MULTIPLE_BLOCK:
++ case MMC_PROGRAM_CID:
++ case MMC_PROGRAM_CSD:
++ case MMC_SEND_WRITE_PROT:
++ case MMC_GEN_CMD:
++ case MMC_LOCK_UNLOCK:
++ cmdat |= MSC_CMDAT_DATA_EN | MSC_CMDAT_WRITE;
++ events = MMC_EVENT_TX_DATA_DONE | MMC_EVENT_PROG_DONE;
++
++ break;
++
++ case MMC_CMD_STOP_TRANSMISSION:
++ events = MMC_EVENT_PROG_DONE;
++ break;
++
++ /* ac - no data transfer */
++ default:
++ break;
++ }
++
++ /* Set response type */
++ switch (request->rtype) {
++ case RESPONSE_NONE:
++ break;
++
++ case RESPONSE_R1B:
++ cmdat |= MSC_CMDAT_BUSY;
++ /*FALLTHRU*/
++ case RESPONSE_R1:
++ cmdat |= MSC_CMDAT_RESPONSE_R1;
++ break;
++ case RESPONSE_R2_CID:
++ case RESPONSE_R2_CSD:
++ cmdat |= MSC_CMDAT_RESPONSE_R2;
++ break;
++ case RESPONSE_R3:
++ cmdat |= MSC_CMDAT_RESPONSE_R3;
++ break;
++ case RESPONSE_R4:
++ cmdat |= MSC_CMDAT_RESPONSE_R4;
++ break;
++ case RESPONSE_R5:
++ cmdat |= MSC_CMDAT_RESPONSE_R5;
++ break;
++ case RESPONSE_R6:
++ cmdat |= MSC_CMDAT_RESPONSE_R6;
++ break;
++ default:
++ break;
++ }
++
++ /* Set command index */
++ if (request->cmd == MMC_CIM_RESET) {
++ REG_MSC_CMD = MMC_CMD_GO_IDLE_STATE;
++ } else {
++ REG_MSC_CMD = request->cmd;
++ }
++
++ /* Set argument */
++ REG_MSC_ARG = request->arg;
++
++ /* Set block length and nob */
++ if (request->cmd == SD_CMD_APP_SEND_SCR) { /* get SCR from DataFIFO */
++ REG_MSC_BLKLEN = 8;
++ REG_MSC_NOB = 1;
++ } else {
++ REG_MSC_BLKLEN = request->block_len;
++ REG_MSC_NOB = request->nob;
++ }
++
++ /* Set command */
++ REG_MSC_CMDAT = cmdat;
++
++ debug("Send cmd %d cmdat: %x arg: %x resp %d\n", request->cmd,
++ cmdat, request->arg, request->rtype);
++
++ /* Start MMC/SD clock and send command to card */
++ jz_mmc_start_clock();
++
++ /* Wait for command completion */
++ while (timeout-- && !(REG_MSC_STAT & MSC_STAT_END_CMD_RES))
++ ;
++
++ if (timeout == 0)
++ return MMC_ERROR_TIMEOUT;
++
++ REG_MSC_IREG = MSC_IREG_END_CMD_RES; /* clear flag */
++
++ /* Check for status */
++ retval = jz_mmc_check_status(request);
++ if (retval) {
++ return retval;
++ }
++
++ /* Complete command with no response */
++ if (request->rtype == RESPONSE_NONE) {
++ return MMC_NO_ERROR;
++ }
++
++ /* Get response */
++ jz_mmc_get_response(request);
++
++ /* Start data operation */
++ if (events & (MMC_EVENT_RX_DATA_DONE | MMC_EVENT_TX_DATA_DONE)) {
++ if (events & MMC_EVENT_RX_DATA_DONE) {
++ if (request->cmd == SD_CMD_APP_SEND_SCR) {
++ /* SD card returns SCR register as data.
++ MMC core expect it in the response buffer,
++ after normal response. */
++ request->buffer = (u8 *)((u32)request->response + 5);
++ }
++ jz_mmc_receive_data(request);
++ }
++
++ if (events & MMC_EVENT_TX_DATA_DONE) {
++ jz_mmc_transmit_data(request);
++ }
++
++ /* Wait for Data Done */
++ while (!(REG_MSC_IREG & MSC_IREG_DATA_TRAN_DONE))
++ ;
++ REG_MSC_IREG = MSC_IREG_DATA_TRAN_DONE; /* clear status */
++ }
++
++ /* Wait for Prog Done event */
++ if (events & MMC_EVENT_PROG_DONE) {
++ while (!(REG_MSC_IREG & MSC_IREG_PRG_DONE))
++ ;
++ REG_MSC_IREG = MSC_IREG_PRG_DONE; /* clear status */
++ }
++
++ /* Command completed */
++
++ return MMC_NO_ERROR; /* return successfully */
++}
++
++int mmc_block_read(u8 *dst, ulong src, ulong len)
++{
++
++ struct mmc_request request;
++ struct mmc_response_r1 r1;
++ int retval = 0;
++
++ if (len == 0)
++ goto exit;
++
++ mmc_simple_cmd(&request, MMC_CMD_SEND_STATUS, mmcinfo.rca, RESPONSE_R1);
++ retval = mmc_unpack_r1(&request, &r1, 0);
++ if (retval && (retval != MMC_ERROR_STATE_MISMATCH))
++ goto exit;
++
++ mmc_simple_cmd(&request, MMC_CMD_SET_BLOCKLEN, len, RESPONSE_R1);
++ if (retval = mmc_unpack_r1(&request, &r1, 0))
++ goto exit;
++
++ if (!sd2_0)
++ src *= mmcinfo.block_len;
++
++ mmc_send_cmd(&request, MMC_CMD_READ_SINGLE_BLOCK, src, 1, len, RESPONSE_R1, dst);
++ if (retval = mmc_unpack_r1(&request, &r1, 0))
++ goto exit;
++
++exit:
++ return retval;
++}
++
++ulong mmc_bread(int dev_num, ulong blkstart, ulong blkcnt, ulong *dst)
++{
++ if (!mmc_ready) {
++ printf("Please initial the MMC first\n");
++ return -1;
++ }
++
++ int i = 0;
++ ulong dst_tmp = dst;
++
++ for (i = 0; i < blkcnt; i++) {
++ if ((mmc_block_read((uchar *)(dst_tmp), blkstart, mmcinfo.block_len)) < 0)
++ return -1;
++
++ dst_tmp += mmcinfo.block_len;
++ blkstart++;
++ }
++
++ return i;
++}
++
++int mmc_select_card(void)
++{
++ struct mmc_request request;
++ struct mmc_response_r1 r1;
++ int retval;
++
++ mmc_simple_cmd(&request, MMC_CMD_SELECT_CARD, mmcinfo.rca, RESPONSE_R1B);
++ retval = mmc_unpack_r1(&request, &r1, 0);
++ if (retval) {
++ return retval;
++ }
++
++ if (mmcinfo.sd) {
++ mmc_simple_cmd(&request, MMC_CMD_APP_CMD, mmcinfo.rca, RESPONSE_R1);
++ retval = mmc_unpack_r1(&request,&r1,0);
++ if (retval) {
++ return retval;
++ }
++#if defined(MMC_BUS_WIDTH_1BIT)
++ mmc_simple_cmd(&request, SET_BUS_WIDTH, 1, RESPONSE_R1);
++#else
++ mmc_simple_cmd(&request, SET_BUS_WIDTH, 2, RESPONSE_R1);
++#endif
++ retval = mmc_unpack_r1(&request,&r1,0);
++ if (retval) {
++ return retval;
++ }
++ }
++ return 0;
++}
++
++/*
++ * Configure card
++ */
++static void mmc_configure_card(void)
++{
++ u32 rate;
++
++ /* Get card info */
++ if (sd2_0)
++ mmcinfo.block_num = (mmcinfo.csd.c_size + 1) << 10;
++ else
++ mmcinfo.block_num = (mmcinfo.csd.c_size + 1) * (1 << (mmcinfo.csd.c_size_mult + 2));
++
++ mmcinfo.block_len = 1 << mmcinfo.csd.read_bl_len;
++
++ mmc_dev.if_type = IF_TYPE_SD;
++ mmc_dev.part_type = PART_TYPE_DOS;
++ mmc_dev.dev = 0;
++ mmc_dev.lun = 0;
++ mmc_dev.type = 0;
++ mmc_dev.blksz = mmcinfo.block_len;
++ mmc_dev.lba = mmcinfo.block_num;
++ mmc_dev.removable = 0;
++
++ printf("%s Detected: %lu blocks of %lu bytes\n",
++ sd2_0 == 1 ? "SDHC" : "SD",
++ mmc_dev.lba,
++ mmc_dev.blksz);
++
++ /* Fix the clock rate */
++ rate = mmc_tran_speed(mmcinfo.csd.tran_speed);
++ if (rate < MMC_CLOCK_SLOW)
++ rate = MMC_CLOCK_SLOW;
++ if ((mmcinfo.sd == 0) && (rate > MMC_CLOCK_FAST))
++ rate = MMC_CLOCK_FAST;
++ if ((mmcinfo.sd) && (rate > SD_CLOCK_FAST))
++ rate = SD_CLOCK_FAST;
++
++ debug("%s: block_len=%d block_num=%d rate=%d\n",
++ __func__, mmcinfo.block_len, mmcinfo.block_num, rate);
++
++ jz_mmc_set_clock(mmcinfo.sd, rate);
++}
++
++/*
++ * State machine routines to initialize card(s)
++ */
++
++/*
++ CIM_SINGLE_CARD_ACQ (frequency at 400 kHz)
++ --- Must enter from GO_IDLE_STATE ---
++ 1. SD_SEND_OP_COND (SD Card) [CMD55] + [CMD41]
++ 2. SEND_OP_COND (Full Range) [CMD1] {optional}
++ 3. SEND_OP_COND (Set Range ) [CMD1]
++ If busy, delay and repeat step 2
++ 4. ALL_SEND_CID [CMD2]
++ If timeout, set an error (no cards found)
++ 5. SET_RELATIVE_ADDR [CMD3]
++ 6. SEND_CSD [CMD9]
++ 7. SET_DSR [CMD4] Only call this if (csd.dsr_imp).
++ 8. Set clock frequency (check available in csd.tran_speed)
++ */
++
++#define MMC_INIT_DOING 0
++#define MMC_INIT_PASSED 1
++#define MMC_INIT_FAILED 2
++
++static int mmc_init_card_state(struct mmc_request *request)
++{
++ struct mmc_response_r1 r1;
++ struct mmc_response_r3 r3;
++ int retval;
++ int ocr = 0x40300000;
++ int limit_41 = 0;
++
++ switch (request->cmd) {
++ case MMC_CMD_GO_IDLE_STATE: /* No response to parse */
++ if (mmcinfo.sd)
++ mmc_simple_cmd(request, 8, 0x1aa, RESPONSE_R1);
++ else
++ mmc_simple_cmd(request, MMC_CMD_SEND_OP_COND, MMC_OCR_ARG, RESPONSE_R3);
++ break;
++
++ case 8:
++ retval = mmc_unpack_r1(request,&r1,mmcinfo.state);
++ mmc_simple_cmd(request, MMC_CMD_APP_CMD, 0, RESPONSE_R1);
++ break;
++
++ case MMC_CMD_APP_CMD:
++ retval = mmc_unpack_r1(request,&r1,mmcinfo.state);
++ if (retval & (limit_41 < 100)) {
++ debug("%s: unable to MMC_APP_CMD error=%d (%s)\n",
++ __func__, retval, mmc_result_to_string(retval));
++ limit_41++;
++ mmc_simple_cmd(request, SD_CMD_APP_SEND_OP_COND, ocr, RESPONSE_R3);
++ } else if (limit_41 < 100) {
++ limit_41++;
++ mmc_simple_cmd(request, SD_CMD_APP_SEND_OP_COND, ocr, RESPONSE_R3);
++ } else{
++ /* reset the card to idle*/
++ mmc_simple_cmd(request, MMC_CMD_GO_IDLE_STATE, 0, RESPONSE_NONE);
++ mmcinfo.sd = 0;
++ }
++ break;
++
++ case SD_CMD_APP_SEND_OP_COND:
++ retval = mmc_unpack_r3(request, &r3);
++ if (retval) {
++ debug("%s: try MMC card\n", __func__);
++ mmc_simple_cmd(request, SD_CMD_APP_SEND_OP_COND, MMC_OCR_ARG, RESPONSE_R3);
++ break;
++ }
++
++ debug("%s: read ocr value = 0x%08x\n", __func__, r3.ocr);
++
++ if(!(r3.ocr & MMC_CARD_BUSY || ocr == 0)){
++ udelay(50000);
++ mmc_simple_cmd(request, MMC_CMD_APP_CMD, 0, RESPONSE_R1);
++ } else {
++ mmcinfo.sd = 1; /* SD Card ready */
++ mmcinfo.state = CARD_STATE_READY;
++ mmc_simple_cmd(request, MMC_CMD_ALL_SEND_CID, 0, RESPONSE_R2_CID);
++ }
++ break;
++
++ case MMC_CMD_SEND_OP_COND:
++ retval = mmc_unpack_r3(request, &r3);
++ if (retval) {
++ debug("%s: failed SEND_OP_COND error=%d (%s)\n",
++ __func__, retval, mmc_result_to_string(retval));
++ return MMC_INIT_FAILED;
++ }
++
++ debug("%s: read ocr value = 0x%08x\n", __func__, r3.ocr);
++ if (!(r3.ocr & MMC_CARD_BUSY)) {
++ mmc_simple_cmd(request, MMC_CMD_SEND_OP_COND, MMC_OCR_ARG, RESPONSE_R3);
++ } else {
++ mmcinfo.sd = 0; /* MMC Card ready */
++ mmcinfo.state = CARD_STATE_READY;
++ mmc_simple_cmd(request, MMC_CMD_ALL_SEND_CID, 0, RESPONSE_R2_CID);
++ }
++ break;
++
++ case MMC_CMD_ALL_SEND_CID:
++ retval = mmc_unpack_cid( request, &mmcinfo.cid );
++ /*FIXME:ignore CRC error for CMD2/CMD9/CMD10 */
++ if ( retval && (retval != MMC_ERROR_CRC)) {
++ debug("mmc_init_card_state: unable to ALL_SEND_CID error=%d (%s)\n",
++ retval, mmc_result_to_string(retval));
++ return MMC_INIT_FAILED;
++ }
++ mmcinfo.state = CARD_STATE_IDENT;
++ if(mmcinfo.sd)
++ mmc_simple_cmd(request, MMC_CMD_SET_RELATIVE_ADDR, 0, RESPONSE_R6);
++ else
++ mmc_simple_cmd(request, MMC_CMD_SET_RELATIVE_ADDR, ID_TO_RCA(mmcinfo.id) << 16, RESPONSE_R1);
++ break;
++
++ case MMC_CMD_SET_RELATIVE_ADDR:
++ if (mmcinfo.sd) {
++ retval = mmc_unpack_r6(request, &r1, mmcinfo.state, &mmcinfo.rca);
++ mmcinfo.rca = mmcinfo.rca << 16;
++ debug("%s: Get RCA from SD: 0x%04x Status: %x\n",
++ __func__, mmcinfo.rca, r1.status);
++ } else {
++ retval = mmc_unpack_r1(request,&r1,mmcinfo.state);
++ mmcinfo.rca = ID_TO_RCA(mmcinfo.id) << 16;
++ }
++ if (retval) {
++ debug("%s: unable to SET_RELATIVE_ADDR error=%d (%s)\n",
++ __func__, retval, mmc_result_to_string(retval));
++ return MMC_INIT_FAILED;
++ }
++
++ mmcinfo.state = CARD_STATE_STBY;
++ mmc_simple_cmd(request, MMC_CMD_SEND_CSD, mmcinfo.rca, RESPONSE_R2_CSD);
++
++ break;
++
++ case MMC_CMD_SEND_CSD:
++ retval = mmc_unpack_csd(request, &mmcinfo.csd);
++ mmc_ready = 1;
++ /*FIXME:ignore CRC error for CMD2/CMD9/CMD10 */
++ if (retval && (retval != MMC_ERROR_CRC)) {
++ debug("%s: unable to SEND_CSD error=%d (%s)\n",
++ __func__, retval, mmc_result_to_string(retval));
++ return MMC_INIT_FAILED;
++ }
++ if (mmcinfo.csd.dsr_imp) {
++ debug("%s: driver doesn't support setting DSR\n", __func__);
++ }
++ mmc_configure_card();
++ return MMC_INIT_PASSED;
++
++ default:
++ debug("%s: error! Illegal last cmd %d\n", __func__, request->cmd);
++ return MMC_INIT_FAILED;
++ }
++
++ return MMC_INIT_DOING;
++}
++
++int mmc_init_card(void)
++{
++ struct mmc_request request;
++ int retval;
++
++ mmc_simple_cmd(&request, MMC_CIM_RESET, 0, RESPONSE_NONE); /* reset card */
++ mmc_simple_cmd(&request, MMC_CMD_GO_IDLE_STATE, 0, RESPONSE_NONE);
++ mmcinfo.sd = 1; /* assuming a SD card */
++
++ while ((retval = mmc_init_card_state(&request)) == MMC_INIT_DOING)
++ ;
++
++ if (retval == MMC_INIT_PASSED)
++ return MMC_NO_ERROR;
++ else
++ return MMC_NO_RESPONSE;
++}
++
++int mmc_legacy_init(int verbose)
++{
++ if (!__msc_card_detected())
++ return 1;
++
++ /* Step-1: init GPIO */
++ __gpio_as_msc();
++ __msc_init_io();
++
++ /* Step-2: turn on power of card */
++#if !defined(CONFIG_SAKC)
++ __msc_enable_power();
++#endif
++
++ /* Step-3: Reset MSC Controller. */
++ __msc_reset();
++
++ /* Step-3: mask all IRQs. */
++ MMC_IRQ_MASK();
++
++ /* Step-4: stop MMC/SD clock */
++ jz_mmc_stop_clock();
++ mmc_init_card();
++ mmc_select_card();
++
++ mmc_dev.block_read = mmc_bread;
++ fat_register_device(&mmc_dev,1); /* partitions start counting with 1 */
++
++ return 0;
++}
++
++/*
++ * Debugging functions
++ */
++static char * mmc_result_strings[] = {
++ "NO_RESPONSE",
++ "NO_ERROR",
++ "ERROR_OUT_OF_RANGE",
++ "ERROR_ADDRESS",
++ "ERROR_BLOCK_LEN",
++ "ERROR_ERASE_SEQ",
++ "ERROR_ERASE_PARAM",
++ "ERROR_WP_VIOLATION",
++ "ERROR_CARD_IS_LOCKED",
++ "ERROR_LOCK_UNLOCK_FAILED",
++ "ERROR_COM_CRC",
++ "ERROR_ILLEGAL_COMMAND",
++ "ERROR_CARD_ECC_FAILED",
++ "ERROR_CC",
++ "ERROR_GENERAL",
++ "ERROR_UNDERRUN",
++ "ERROR_OVERRUN",
++ "ERROR_CID_CSD_OVERWRITE",
++ "ERROR_STATE_MISMATCH",
++ "ERROR_HEADER_MISMATCH",
++ "ERROR_TIMEOUT",
++ "ERROR_CRC",
++ "ERROR_DRIVER_FAILURE",
++};
++
++char * mmc_result_to_string(int i)
++{
++ return mmc_result_strings[i+1];
++}
++
++static char * card_state_strings[] = {
++ "empty",
++ "idle",
++ "ready",
++ "ident",
++ "stby",
++ "tran",
++ "data",
++ "rcv",
++ "prg",
++ "dis",
++};
++
++static inline char * card_state_to_string(int i)
++{
++ return card_state_strings[i+1];
++}
++
++/*
++ * Utility functions
++ */
++
++#define PARSE_U32(_buf,_index) \
++ (((u32)_buf[_index]) << 24) | (((u32)_buf[_index+1]) << 16) | \
++ (((u32)_buf[_index+2]) << 8) | ((u32)_buf[_index+3]);
++
++#define PARSE_U16(_buf,_index) \
++ (((u16)_buf[_index]) << 8) | ((u16)_buf[_index+1]);
++
++int mmc_unpack_csd(struct mmc_request *request, struct mmc_csd *csd)
++{
++ u8 *buf = request->response;
++ int num = 0;
++
++ if (request->result)
++ return request->result;
++
++ if (buf[0] != 0x3f)
++ return MMC_ERROR_HEADER_MISMATCH;
++
++ csd->csd_structure = (buf[1] & 0xc0) >> 6;
++ if (csd->csd_structure)
++ sd2_0 = 1;
++ else
++ sd2_0 = 0;
++
++ switch (csd->csd_structure) {
++ case 0 :/* Version 1.01-1.10
++ * Version 2.00/Standard Capacity */
++ csd->taac = buf[2];
++ csd->nsac = buf[3];
++ csd->tran_speed = buf[4];
++ csd->ccc = (((u16)buf[5]) << 4) | ((buf[6] & 0xf0) >> 4);
++ csd->read_bl_len = buf[6] & 0x0f;
++ /* for support 2GB card*/
++ if (csd->read_bl_len >= 10)
++ {
++ num = csd->read_bl_len - 9;
++ csd->read_bl_len = 9;
++ }
++
++ csd->read_bl_partial = (buf[7] & 0x80) ? 1 : 0;
++ csd->write_blk_misalign = (buf[7] & 0x40) ? 1 : 0;
++ csd->read_blk_misalign = (buf[7] & 0x20) ? 1 : 0;
++ csd->dsr_imp = (buf[7] & 0x10) ? 1 : 0;
++ csd->c_size = ((((u16)buf[7]) & 0x03) << 10) | (((u16)buf[8]) << 2) | (((u16)buf[9]) & 0xc0) >> 6;
++
++ if (num)
++ csd->c_size = csd->c_size << num;
++
++
++ csd->vdd_r_curr_min = (buf[9] & 0x38) >> 3;
++ csd->vdd_r_curr_max = buf[9] & 0x07;
++ csd->vdd_w_curr_min = (buf[10] & 0xe0) >> 5;
++ csd->vdd_w_curr_max = (buf[10] & 0x1c) >> 2;
++ csd->c_size_mult = ((buf[10] & 0x03) << 1) | ((buf[11] & 0x80) >> 7);
++ csd->sector_size = (buf[11] & 0x7c) >> 2;
++ csd->erase_grp_size = ((buf[11] & 0x03) << 3) | ((buf[12] & 0xe0) >> 5);
++ csd->wp_grp_size = buf[12] & 0x1f;
++ csd->wp_grp_enable = (buf[13] & 0x80) ? 1 : 0;
++ csd->default_ecc = (buf[13] & 0x60) >> 5;
++ csd->r2w_factor = (buf[13] & 0x1c) >> 2;
++ csd->write_bl_len = ((buf[13] & 0x03) << 2) | ((buf[14] & 0xc0) >> 6);
++ if (csd->write_bl_len >= 10)
++ csd->write_bl_len = 9;
++
++ csd->write_bl_partial = (buf[14] & 0x20) ? 1 : 0;
++ csd->file_format_grp = (buf[15] & 0x80) ? 1 : 0;
++ csd->copy = (buf[15] & 0x40) ? 1 : 0;
++ csd->perm_write_protect = (buf[15] & 0x20) ? 1 : 0;
++ csd->tmp_write_protect = (buf[15] & 0x10) ? 1 : 0;
++ csd->file_format = (buf[15] & 0x0c) >> 2;
++ csd->ecc = buf[15] & 0x03;
++ break;
++ case 1 : /* Version 2.00/High Capacity */
++ csd->taac = 0;
++ csd->nsac = 0;
++ csd->tran_speed = buf[4];
++ csd->ccc = (((u16)buf[5]) << 4) | ((buf[6] & 0xf0) >> 4);
++
++ csd->read_bl_len = 9;
++ csd->read_bl_partial = 0;
++ csd->write_blk_misalign = 0;
++ csd->read_blk_misalign = 0;
++ csd->dsr_imp = (buf[7] & 0x10) ? 1 : 0;
++ csd->c_size = ((((u16)buf[8]) & 0x3f) << 16) | (((u16)buf[9]) << 8) | ((u16)buf[10]) ;
++ csd->sector_size = 0x7f;
++ csd->erase_grp_size = 0;
++ csd->wp_grp_size = 0;
++ csd->wp_grp_enable = 0;
++ csd->default_ecc = (buf[13] & 0x60) >> 5;
++ csd->r2w_factor = 4;/* Unused */
++ csd->write_bl_len = 9;
++
++ csd->write_bl_partial = 0;
++ csd->file_format_grp = 0;
++ csd->copy = (buf[15] & 0x40) ? 1 : 0;
++ csd->perm_write_protect = (buf[15] & 0x20) ? 1 : 0;
++ csd->tmp_write_protect = (buf[15] & 0x10) ? 1 : 0;
++ csd->file_format = 0;
++ csd->ecc = buf[15] & 0x03;
++ }
++
++ return 0;
++}
++
++int mmc_unpack_r1(struct mmc_request *request, struct mmc_response_r1 *r1, enum card_state state)
++{
++ u8 *buf = request->response;
++
++ if (request->result)
++ return request->result;
++
++ r1->cmd = buf[0];
++ r1->status = PARSE_U32(buf,1);
++
++ debug("mmc_unpack_r1: cmd=%d status=%08x\n", r1->cmd, r1->status);
++
++ if (R1_STATUS(r1->status)) {
++ if (r1->status & R1_OUT_OF_RANGE) return MMC_ERROR_OUT_OF_RANGE;
++ if (r1->status & R1_ADDRESS_ERROR) return MMC_ERROR_ADDRESS;
++ if (r1->status & R1_BLOCK_LEN_ERROR) return MMC_ERROR_BLOCK_LEN;
++ if (r1->status & R1_ERASE_SEQ_ERROR) return MMC_ERROR_ERASE_SEQ;
++ if (r1->status & R1_ERASE_PARAM) return MMC_ERROR_ERASE_PARAM;
++ if (r1->status & R1_WP_VIOLATION) return MMC_ERROR_WP_VIOLATION;
++ /*if (r1->status & R1_CARD_IS_LOCKED) return MMC_ERROR_CARD_IS_LOCKED; */
++ if (r1->status & R1_LOCK_UNLOCK_FAILED) return MMC_ERROR_LOCK_UNLOCK_FAILED;
++ if (r1->status & R1_COM_CRC_ERROR) return MMC_ERROR_COM_CRC;
++ if (r1->status & R1_ILLEGAL_COMMAND) return MMC_ERROR_ILLEGAL_COMMAND;
++ if (r1->status & R1_CARD_ECC_FAILED) return MMC_ERROR_CARD_ECC_FAILED;
++ if (r1->status & R1_CC_ERROR) return MMC_ERROR_CC;
++ if (r1->status & R1_ERROR) return MMC_ERROR_GENERAL;
++ if (r1->status & R1_UNDERRUN) return MMC_ERROR_UNDERRUN;
++ if (r1->status & R1_OVERRUN) return MMC_ERROR_OVERRUN;
++ if (r1->status & R1_CID_CSD_OVERWRITE) return MMC_ERROR_CID_CSD_OVERWRITE;
++ }
++
++ if (buf[0] != request->cmd)
++ return MMC_ERROR_HEADER_MISMATCH;
++
++ /* This should be last - it's the least dangerous error */
++
++ return 0;
++}
++
++int mmc_unpack_scr(struct mmc_request *request, struct mmc_response_r1 *r1, enum card_state state, u32 *scr)
++{
++ u8 *buf = request->response;
++ if (request->result)
++ return request->result;
++
++ *scr = PARSE_U32(buf, 5); /* Save SCR returned by the SD Card */
++ return mmc_unpack_r1(request, r1, state);
++
++}
++
++int mmc_unpack_r6(struct mmc_request *request, struct mmc_response_r1 *r1, enum card_state state, int *rca)
++{
++ u8 *buf = request->response;
++
++ if (request->result)
++ return request->result;
++
++ *rca = PARSE_U16(buf,1); /* Save RCA returned by the SD Card */
++
++ *(buf+1) = 0;
++ *(buf+2) = 0;
++
++ return mmc_unpack_r1(request, r1, state);
++}
++
++int mmc_unpack_cid(struct mmc_request *request, struct mmc_cid *cid)
++{
++ int i;
++ u8 *buf = request->response;
++
++ if (request->result)
++ return request->result;
++
++ cid->mid = buf[1];
++ cid->oid = PARSE_U16(buf,2);
++ for (i = 0 ; i < 5 ; i++)
++ cid->pnm[i] = buf[4+i];
++ cid->pnm[6] = 0;
++ cid->prv = buf[10];
++ cid->psn = PARSE_U32(buf,10);
++ cid->mdt = buf[15];
++
++ printf("Man %02x OEM 0x%04x \"%s\" %d.%d 0x%08x "
++ "Date %02u/%04u\n",
++ cid->mid,
++ cid->oid,
++ cid->pnm,
++ cid->prv >> 4,
++ cid->prv & 0xf,
++ cid->psn,
++ cid->mdt & 0xf,
++ (cid->mdt >> 4) + 2000);
++
++ if (buf[0] != 0x3f)
++ return MMC_ERROR_HEADER_MISMATCH;
++ return 0;
++}
++
++int mmc_unpack_r3(struct mmc_request *request, struct mmc_response_r3 *r3)
++{
++ u8 *buf = request->response;
++
++ if (request->result)
++ return request->result;
++
++ r3->ocr = PARSE_U32(buf,1);
++ debug("mmc_unpack_r3: ocr=%08x\n", r3->ocr);
++
++ if (buf[0] != 0x3f) return MMC_ERROR_HEADER_MISMATCH;
++ return 0;
++}
++
++#define KBPS 1
++#define MBPS 1000
++
++static u32 ts_exp[] = { 100*KBPS, 1*MBPS, 10*MBPS, 100*MBPS, 0, 0, 0, 0 };
++static u32 ts_mul[] = { 0, 1000, 1200, 1300, 1500, 2000, 2500, 3000,
++ 3500, 4000, 4500, 5000, 5500, 6000, 7000, 8000 };
++
++u32 mmc_tran_speed(u8 ts)
++{
++ u32 rate = ts_exp[(ts & 0x7)] * ts_mul[(ts & 0x78) >> 3];
++
++ if (rate <= 0) {
++ debug("%s: error - unrecognized speed 0x%02x\n", __func__, ts);
++ return 1;
++ }
++
++ return rate;
++}
++
++void mmc_send_cmd(struct mmc_request *request, int cmd, u32 arg,
++ u16 nob, u16 block_len, enum mmc_rsp_t rtype, u8 *buffer)
++{
++ request->cmd = cmd;
++ request->arg = arg;
++ request->rtype = rtype;
++ request->nob = nob;
++ request->block_len = block_len;
++ request->buffer = buffer;
++ request->cnt = nob * block_len;
++
++ jz_mmc_exec_cmd(request);
++}
+diff --git a/drivers/mmc/jz_mmc.h b/drivers/mmc/jz_mmc.h
+new file mode 100644
+index 0000000..936c514
+--- /dev/null
++++ b/drivers/mmc/jz_mmc.h
+@@ -0,0 +1,176 @@
++/*
++ * linux/drivers/mmc/jz_mmc.h
++ *
++ * Author: Vladimir Shebordaev, Igor Oblakov
++ * Copyright: MontaVista Software Inc.
++ *
++ * $Id: jz_mmc.h,v 1.3 2007-06-15 08:04:20 jlwei Exp $
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License version 2 as
++ * published by the Free Software Foundation.
++ */
++#ifndef __MMC_JZMMC_H__
++#define __MMC_JZMMC_H__
++
++#define ID_TO_RCA(x) ((x)+1)
++#define MMC_OCR_ARG 0x00ff8000 /* Argument of OCR */
++
++/* Standard MMC/SD clock speeds */
++#define MMC_CLOCK_SLOW 400000 /* 400 kHz for initial setup */
++#define MMC_CLOCK_FAST 20000000 /* 20 MHz for maximum for normal operation */
++#define SD_CLOCK_FAST 24000000 /* 24 MHz for SD Cards */
++
++/* Use negative numbers to disambiguate */
++#define MMC_CIM_RESET -1
++#define SET_BUS_WIDTH 6 /* ac [1:0] bus width R1 */
++
++#define R1_OUT_OF_RANGE (1 << 31) /* er, c */
++#define R1_ADDRESS_ERROR (1 << 30) /* erx, c */
++#define R1_BLOCK_LEN_ERROR (1 << 29) /* er, c */
++#define R1_ERASE_SEQ_ERROR (1 << 28) /* er, c */
++#define R1_ERASE_PARAM (1 << 27) /* ex, c */
++#define R1_WP_VIOLATION (1 << 26) /* erx, c */
++#define R1_CARD_IS_LOCKED (1 << 25) /* sx, a */
++#define R1_LOCK_UNLOCK_FAILED (1 << 24) /* erx, c */
++#define R1_COM_CRC_ERROR (1 << 23) /* er, b */
++#define R1_ILLEGAL_COMMAND (1 << 22) /* er, b */
++#define R1_CARD_ECC_FAILED (1 << 21) /* ex, c */
++#define R1_CC_ERROR (1 << 20) /* erx, c */
++#define R1_ERROR (1 << 19) /* erx, c */
++#define R1_UNDERRUN (1 << 18) /* ex, c */
++#define R1_OVERRUN (1 << 17) /* ex, c */
++#define R1_CID_CSD_OVERWRITE (1 << 16) /* erx, c, CID/CSD overwrite */
++#define R1_WP_ERASE_SKIP (1 << 15) /* sx, c */
++#define R1_CARD_ECC_DISABLED (1 << 14) /* sx, a */
++#define R1_ERASE_RESET (1 << 13) /* sr, c */
++#define R1_STATUS(x) (x & 0xFFFFE000)
++
++#define MMC_CARD_BUSY 0x80000000 /* Card Power up status bit */
++
++#define MMC_PROGRAM_CID 26 /* adtc R1 */
++#define MMC_PROGRAM_CSD 27 /* adtc R1 */
++
++#define MMC_GO_IRQ_STATE 40 /* bcr R5 */
++#define MMC_GEN_CMD 56 /* adtc [0] RD/WR R1b */
++#define MMC_LOCK_UNLOCK 42 /* adtc R1b */
++#define MMC_WRITE_DAT_UNTIL_STOP 20 /* adtc [31:0] data addr R1 */
++#define MMC_READ_DAT_UNTIL_STOP 11 /* adtc [31:0] dadr R1 */
++#define MMC_SEND_WRITE_PROT 30 /* adtc [31:0] wpdata addr R1 */
++
++
++enum mmc_result_t {
++ MMC_NO_RESPONSE = -1,
++ MMC_NO_ERROR = 0,
++ MMC_ERROR_OUT_OF_RANGE,
++ MMC_ERROR_ADDRESS,
++ MMC_ERROR_BLOCK_LEN,
++ MMC_ERROR_ERASE_SEQ,
++ MMC_ERROR_ERASE_PARAM,
++ MMC_ERROR_WP_VIOLATION,
++ MMC_ERROR_CARD_IS_LOCKED,
++ MMC_ERROR_LOCK_UNLOCK_FAILED,
++ MMC_ERROR_COM_CRC,
++ MMC_ERROR_ILLEGAL_COMMAND,
++ MMC_ERROR_CARD_ECC_FAILED,
++ MMC_ERROR_CC,
++ MMC_ERROR_GENERAL,
++ MMC_ERROR_UNDERRUN,
++ MMC_ERROR_OVERRUN,
++ MMC_ERROR_CID_CSD_OVERWRITE,
++ MMC_ERROR_STATE_MISMATCH,
++ MMC_ERROR_HEADER_MISMATCH,
++ MMC_ERROR_TIMEOUT,
++ MMC_ERROR_CRC,
++ MMC_ERROR_DRIVER_FAILURE,
++};
++
++enum card_state {
++ CARD_STATE_EMPTY = -1,
++ CARD_STATE_IDLE = 0,
++ CARD_STATE_READY = 1,
++ CARD_STATE_IDENT = 2,
++ CARD_STATE_STBY = 3,
++ CARD_STATE_TRAN = 4,
++ CARD_STATE_DATA = 5,
++ CARD_STATE_RCV = 6,
++ CARD_STATE_PRG = 7,
++ CARD_STATE_DIS = 8,
++};
++
++enum mmc_rsp_t {
++ RESPONSE_NONE = 0,
++ RESPONSE_R1 = 1,
++ RESPONSE_R1B = 2,
++ RESPONSE_R2_CID = 3,
++ RESPONSE_R2_CSD = 4,
++ RESPONSE_R3 = 5,
++ RESPONSE_R4 = 6,
++ RESPONSE_R5 = 7,
++ RESPONSE_R6 = 8,
++};
++
++struct mmc_response_r1 {
++ u8 cmd;
++ u32 status;
++};
++
++struct mmc_response_r3 {
++ u32 ocr;
++};
++
++/* the information structure of MMC/SD Card */
++struct mmc_info {
++ int id; /* Card index */
++ int sd; /* MMC or SD card */
++ int rca; /* RCA */
++ u32 scr; /* SCR 63:32*/
++ int flags; /* Ejected, inserted */
++ enum card_state state; /* empty, ident, ready, whatever */
++
++ /* Card specific information */
++ struct mmc_cid cid;
++ struct mmc_csd csd;
++ u32 block_num;
++ u32 block_len;
++ u32 erase_unit;
++};
++
++struct mmc_info mmcinfo;
++
++struct mmc_request {
++ int index; /* Slot index - used for CS lines */
++ int cmd; /* Command to send */
++ u32 arg; /* Argument to send */
++ enum mmc_rsp_t rtype; /* Response type expected */
++
++ /* Data transfer (these may be modified at the low level) */
++ u16 nob; /* Number of blocks to transfer*/
++ u16 block_len; /* Block length */
++ u8 *buffer; /* Data buffer */
++ u32 cnt; /* Data length, for PIO */
++
++ /* Results */
++ u8 response[18]; /* Buffer to store response - CRC is optional */
++ enum mmc_result_t result;
++};
++
++char * mmc_result_to_string(int);
++int mmc_unpack_csd(struct mmc_request *request, struct mmc_csd *csd);
++int mmc_unpack_r1(struct mmc_request *request, struct mmc_response_r1 *r1, enum card_state state);
++int mmc_unpack_r6(struct mmc_request *request, struct mmc_response_r1 *r1, enum card_state state, int *rca);
++int mmc_unpack_scr(struct mmc_request *request, struct mmc_response_r1 *r1, enum card_state state, u32 *scr);
++int mmc_unpack_cid(struct mmc_request *request, struct mmc_cid *cid);
++int mmc_unpack_r3(struct mmc_request *request, struct mmc_response_r3 *r3);
++
++void mmc_send_cmd(struct mmc_request *request, int cmd, u32 arg,
++ u16 nob, u16 block_len, enum mmc_rsp_t rtype, u8 *buffer);
++u32 mmc_tran_speed(u8 ts);
++void jz_mmc_set_clock(int sd, u32 rate);
++
++static inline void mmc_simple_cmd(struct mmc_request *request, int cmd, u32 arg, enum mmc_rsp_t rtype)
++{
++ mmc_send_cmd( request, cmd, arg, 0, 0, rtype, 0);
++}
++
++#endif /* __MMC_JZMMC_H__ */
+diff --git a/include/configs/qi_lb60.h b/include/configs/qi_lb60.h
+index 7bff444..7b33be0 100644
+--- a/include/configs/qi_lb60.h
++++ b/include/configs/qi_lb60.h
+@@ -31,6 +31,15 @@
+ /*
+ * Miscellaneous configurable options
+ */
++#define CONFIG_JZ4740_MMC
++#define CONFIG_MMC 1
++#define CONFIG_FAT 1
++#define CONFIG_DOS_PARTITION 1
++#define CONFIG_CMD_MMC
++#define CONFIG_CMD_FAT
++#define CONFIG_CMD_EXT2
++
++
+ #define CONFIG_SYS_SDRAM_BASE 0x80000000 /* Cached addr */
+ #define CONFIG_SYS_INIT_SP_OFFSET 0x400000
+ #define CONFIG_SYS_LOAD_ADDR 0x80600000
+diff --git a/include/mmc.h b/include/mmc.h
+index a13e2bd..3c4761c 100644
+--- a/include/mmc.h
++++ b/include/mmc.h
+@@ -283,4 +283,44 @@ struct mmc *mmc_spi_init(uint bus, uint cs, uint speed, uint mode);
+ int mmc_legacy_init(int verbose);
+ #endif
+
++struct mmc_csd
++{
++ u8 csd_structure:2,
++ spec_vers:4,
++ rsvd1:2;
++ u8 taac;
++ u8 nsac;
++ u8 tran_speed;
++ u16 ccc:12,
++ read_bl_len:4;
++ u32 c_size:22;
++ u64 read_bl_partial:1,
++ write_blk_misalign:1,
++ read_blk_misalign:1,
++ dsr_imp:1,
++ rsvd2:2,
++ vdd_r_curr_min:3,
++ vdd_r_curr_max:3,
++ vdd_w_curr_min:3,
++ vdd_w_curr_max:3,
++ c_size_mult:3,
++ sector_size:5,
++ erase_grp_size:5,
++ wp_grp_size:5,
++ wp_grp_enable:1,
++ default_ecc:2,
++ r2w_factor:3,
++ write_bl_len:4,
++ write_bl_partial:1,
++ rsvd3:5;
++ u8 file_format_grp:1,
++ copy:1,
++ perm_write_protect:1,
++ tmp_write_protect:1,
++ file_format:2,
++ ecc:2;
++ u8 crc:7;
++ u8 one:1;
++};
++
+ #endif /* _MMC_H_ */
+--
+1.7.9.5
+
diff --git a/package/boot/uboot-xburst/patches/0004-add-more-boot-options-F1-F2-F3-F4-M-S.patch b/package/boot/uboot-xburst/patches/0004-add-more-boot-options-F1-F2-F3-F4-M-S.patch
new file mode 100644
index 0000000..73e0324
--- /dev/null
+++ b/package/boot/uboot-xburst/patches/0004-add-more-boot-options-F1-F2-F3-F4-M-S.patch
@@ -0,0 +1,200 @@
+From c52b6168979d03fc31205444c3278c537787472a Mon Sep 17 00:00:00 2001
+From: Xiangfu <xiangfu@openmobilefree.net>
+Date: Wed, 10 Oct 2012 18:39:55 +0800
+Subject: [PATCH 4/6] add more boot options(F1/F2/F3/F4/M/S)
+
+---
+ arch/mips/include/asm/global_data.h | 3 +++
+ arch/mips/lib/bootm.c | 17 ++++++++++++++++-
+ board/qi/qi_lb60/qi_lb60.c | 26 +++++++++++++++++++++++---
+ common/main.c | 21 +++++++++++++++++++--
+ include/configs/qi_lb60.h | 32 ++++++++++++++++++++++++++++++++
+ 5 files changed, 93 insertions(+), 6 deletions(-)
+
+diff --git a/arch/mips/include/asm/global_data.h b/arch/mips/include/asm/global_data.h
+index 6e2cdc7..cd03d7e 100644
+--- a/arch/mips/include/asm/global_data.h
++++ b/arch/mips/include/asm/global_data.h
+@@ -59,6 +59,9 @@ typedef struct global_data {
+ unsigned long env_valid; /* Checksum of Environment valid? */
+ void **jt; /* jump table */
+ char env_buf[32]; /* buffer for getenv() before reloc. */
++#if defined(CONFIG_NANONOTE)
++ unsigned long boot_option;
++#endif
+ } gd_t;
+
+ #include <asm-generic/global_data_flags.h>
+diff --git a/arch/mips/lib/bootm.c b/arch/mips/lib/bootm.c
+index 608c1a7..e00416b 100644
+--- a/arch/mips/lib/bootm.c
++++ b/arch/mips/lib/bootm.c
+@@ -47,10 +47,25 @@ int do_bootm_linux(int flag, int argc, char * const argv[],
+ bootm_headers_t *images)
+ {
+ void (*theKernel) (int, char **, char **, int *);
+- char *commandline = getenv("bootargs");
++ char *commandline;
+ char env_buf[12];
+ char *cp;
+
++#if defined(CONFIG_NANONOTE)
++ if (gd->boot_option & BOOT_FROM_MEMCARD)
++ commandline = getenv ("bootargsfromsd");
++ else if (gd->boot_option & BOOT_WITH_F1)
++ commandline = getenv ("bootargsf1");
++ else if (gd->boot_option & BOOT_WITH_F2)
++ commandline = getenv ("bootargsf2");
++ else if (gd->boot_option & BOOT_WITH_F3)
++ commandline = getenv ("bootargsf3");
++ else if (gd->boot_option & BOOT_WITH_F4)
++ commandline = getenv ("bootargsf4");
++ else
++#endif
++ commandline = getenv ("bootargs");
++
+ if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
+ return 1;
+
+diff --git a/board/qi/qi_lb60/qi_lb60.c b/board/qi/qi_lb60/qi_lb60.c
+index a2ba648..d622219 100644
+--- a/board/qi/qi_lb60/qi_lb60.c
++++ b/board/qi/qi_lb60/qi_lb60.c
+@@ -15,7 +15,7 @@ DECLARE_GLOBAL_DATA_PTR;
+
+ static void gpio_init(void)
+ {
+- unsigned int i;
++ unsigned int i, j;
+
+ /* Initialize NAND Flash Pins */
+ __gpio_as_nand();
+@@ -42,14 +42,34 @@ static void gpio_init(void)
+
+ if (__gpio_get_pin(GPIO_KEYIN_BASE + 2) == 0){
+ printf("[S] pressed, enable UART0\n");
++ gd->boot_option |= BOOT_WITH_ENABLE_UART;
+ __gpio_as_uart0();
+ } else {
+ __gpio_as_input(GPIO_KEYIN_8);
+ __gpio_enable_pull(GPIO_KEYIN_8);
+ }
+
+- /* enable the TP4, TP5 as UART0 */
+- __gpio_jtag_to_uart0();
++ if (__gpio_get_pin(GPIO_KEYIN_BASE + 3) == 0) {
++ printf("[M] pressed, boot from memory card\n");
++ gd->boot_option |= BOOT_FROM_MEMCARD;
++ __gpio_jtag_to_uart0();
++ }
++
++ for (j = 0; j < 4; j++) {
++ for (i = 0; i < 4; i++)
++ __gpio_set_pin(GPIO_KEYOUT_BASE + i);
++
++ __gpio_clear_pin(GPIO_KEYOUT_BASE + j);
++
++ if (__gpio_get_pin(GPIO_KEYIN_BASE) == 0) {
++ printf("[F%d] pressed", (j + 1));
++ gd->boot_option |= (1 << (j + 2));
++ /* BOOT_WITH_F1 (1 << 2) */
++ /* BOOT_WITH_F2 (1 << 3) */
++ /* BOOT_WITH_F3 (1 << 4) */
++ /* BOOT_WITH_F4 (1 << 5) */
++ }
++ }
+
+ __gpio_as_output(GPIO_AUDIO_POP);
+ __gpio_set_pin(GPIO_AUDIO_POP);
+diff --git a/common/main.c b/common/main.c
+index 9507cec..dbfb7ca 100644
+--- a/common/main.c
++++ b/common/main.c
+@@ -355,7 +355,11 @@ void main_loop (void)
+ #if defined(CONFIG_BOOTDELAY) && (CONFIG_BOOTDELAY >= 0)
+ s = getenv ("bootdelay");
+ bootdelay = s ? (int)simple_strtol(s, NULL, 10) : CONFIG_BOOTDELAY;
+-
++#if defined(CONFIG_NANONOTE)
++ DECLARE_GLOBAL_DATA_PTR;
++ if (gd->boot_option & BOOT_WITH_ENABLE_UART)
++ bootdelay = 3;
++# endif
+ debug ("### main_loop entered: bootdelay=%d\n\n", bootdelay);
+
+ #if defined(CONFIG_MENU_SHOW)
+@@ -379,7 +383,20 @@ void main_loop (void)
+ }
+ else
+ #endif /* CONFIG_BOOTCOUNT_LIMIT */
+- s = getenv ("bootcmd");
++#if defined(CONFIG_NANONOTE)
++ if (gd->boot_option & BOOT_FROM_MEMCARD)
++ s = getenv ("bootcmdfromsd");
++ else if (gd->boot_option & BOOT_WITH_F1)
++ s = getenv ("bootcmdf1");
++ else if (gd->boot_option & BOOT_WITH_F2)
++ s = getenv ("bootcmdf2");
++ else if (gd->boot_option & BOOT_WITH_F3)
++ s = getenv ("bootcmdf3");
++ else if (gd->boot_option & BOOT_WITH_F4)
++ s = getenv ("bootcmdf4");
++ else
++#endif
++ s = getenv ("bootcmd");
+
+ debug ("### main_loop: bootcmd=\"%s\"\n", s ? s : "<UNDEFINED>");
+
+diff --git a/include/configs/qi_lb60.h b/include/configs/qi_lb60.h
+index 7b33be0..52b370c 100644
+--- a/include/configs/qi_lb60.h
++++ b/include/configs/qi_lb60.h
+@@ -31,6 +31,7 @@
+ /*
+ * Miscellaneous configurable options
+ */
++#define CONFIG_NANONOTE
+ #define CONFIG_JZ4740_MMC
+ #define CONFIG_MMC 1
+ #define CONFIG_FAT 1
+@@ -39,6 +40,37 @@
+ #define CONFIG_CMD_FAT
+ #define CONFIG_CMD_EXT2
+
++#define CONFIG_CMD_UBIFS
++#define CONFIG_CMD_UBI
++#define CONFIG_MTD_PARTITIONS
++#define CONFIG_MTD_DEVICE
++#define CONFIG_CMD_MTDPARTS
++#define CONFIG_CMD_UBI
++#define CONFIG_CMD_UBIFS
++#define CONFIG_LZO
++#define CONFIG_RBTREE
++
++#define MTDIDS_DEFAULT "nand0=jz4740-nand"
++#define MTDPARTS_DEFAULT "mtdparts=jz4740-nand:4M@0(uboot)ro,4M@4M(kernel)ro,512M@8M(rootfs)ro,-(data)ro"
++
++#define BOOT_FROM_MEMCARD 1
++#define BOOT_WITH_ENABLE_UART (1 << 1) /* Vaule for global_data.h gd->boot_option */
++#define BOOT_WITH_F1 (1 << 2)
++#define BOOT_WITH_F2 (1 << 3)
++#define BOOT_WITH_F3 (1 << 4)
++#define BOOT_WITH_F4 (1 << 5)
++
++#define CONFIG_EXTRA_ENV_SETTINGS \
++ "bootcmdfromsd=mmc init; ext2load mmc 0 0x80600000 /boot/uImage; bootm;\0" \
++ "bootargsfromsd=mem=32M console=tty0 console=ttyS0,57600n8 rootfstype=ext2 root=/dev/mmcblk0p1 rw rootwait\0" \
++ "bootcmdf1=mmc init; ext2load mmc 0:1 0x80600000 /boot/uImage; bootm;\0" \
++ "bootargsf1=mem=32M console=tty0 console=ttyS0,57600n8 rootfstype=ext2 root=/dev/mmcblk0p1 rw rootwait\0" \
++ "bootcmdf2=mmc init; ext2load mmc 0:2 0x80600000 /boot/uImage; bootm;\0" \
++ "bootargsf2=mem=32M console=tty0 console=ttyS0,57600n8 rootfstype=ext2 root=/dev/mmcblk0p2 rw rootwait\0" \
++ "bootcmdf3=mmc init; ext2load mmc 0:3 0x80600000 /boot/uImage; bootm;\0" \
++ "bootargsf3=mem=32M console=tty0 console=ttyS0,57600n8 rootfstype=ext2 root=/dev/mmcblk0p3 rw rootwait\0" \
++ "bootcmdf4=mtdparts default;ubi part rootfs;ubifsmount rootfs;ubifsload 0x80600000 /boot/uImage; bootm;\0" \
++ "bootargsf4=mem=32M console=tty0 console=ttyS0,57600n8 ubi.mtd=2 rootfstype=ubifs root=ubi0:rootfs rw rootwait"
+
+ #define CONFIG_SYS_SDRAM_BASE 0x80000000 /* Cached addr */
+ #define CONFIG_SYS_INIT_SP_OFFSET 0x400000
+--
+1.7.9.5
+
diff --git a/package/boot/uboot-xburst/patches/0005-add-nanonote-lcd-support.patch b/package/boot/uboot-xburst/patches/0005-add-nanonote-lcd-support.patch
new file mode 100644
index 0000000..2c550f7
--- /dev/null
+++ b/package/boot/uboot-xburst/patches/0005-add-nanonote-lcd-support.patch
@@ -0,0 +1,847 @@
+From ca8c5216cfd3ad3fda9867ed2d157ae5a209834b Mon Sep 17 00:00:00 2001
+From: Xiangfu <xiangfu@openmobilefree.net>
+Date: Wed, 10 Oct 2012 22:05:27 +0800
+Subject: [PATCH 5/6] add nanonote lcd support
+
+---
+ arch/mips/include/asm/global_data.h | 1 +
+ arch/mips/include/asm/jz4740.h | 90 ++++++++
+ arch/mips/lib/board.c | 6 +
+ common/lcd.c | 9 +-
+ drivers/video/Makefile | 1 +
+ drivers/video/nanonote_gpm940b0.c | 400 +++++++++++++++++++++++++++++++++++
+ drivers/video/nanonote_gpm940b0.h | 135 ++++++++++++
+ include/configs/qi_lb60.h | 7 +
+ include/lcd.h | 52 ++++-
+ 9 files changed, 697 insertions(+), 4 deletions(-)
+ create mode 100644 drivers/video/nanonote_gpm940b0.c
+ create mode 100644 drivers/video/nanonote_gpm940b0.h
+
+diff --git a/arch/mips/include/asm/global_data.h b/arch/mips/include/asm/global_data.h
+index cd03d7e..7cec2de 100644
+--- a/arch/mips/include/asm/global_data.h
++++ b/arch/mips/include/asm/global_data.h
+@@ -44,6 +44,7 @@ typedef struct global_data {
+ unsigned long per_clk; /* Peripheral bus clock */
+ unsigned long mem_clk; /* Memory bus clock */
+ unsigned long dev_clk; /* Device clock */
++ unsigned long fb_base; /* base address of framebuffer */
+ /* "static data" needed by most of timer.c */
+ unsigned long tbl;
+ unsigned long lastinc;
+diff --git a/arch/mips/include/asm/jz4740.h b/arch/mips/include/asm/jz4740.h
+index 68287fb..13724a2 100644
+--- a/arch/mips/include/asm/jz4740.h
++++ b/arch/mips/include/asm/jz4740.h
+@@ -1312,5 +1312,95 @@ do { \
+ while (REG_MSC_STAT & MSC_STAT_IS_RESETTING); \
+ } while (0)
+
++/*************************************************************************
++ * LCD (LCD Controller)
++ *************************************************************************/
++#define REG32(addr) *((volatile u32 *)(addr))
++
++#define CPM_BASE 0xB0000000
++#define CPM_CPCCR (CPM_BASE+0x00)
++#define REG_CPM_CPCCR REG32(CPM_CPCCR)
++
++#define LCD_BASE 0xB3050000
++#define LCD_CFG (LCD_BASE + 0x00) /* LCD Configure Register */
++#define LCD_VSYNC (LCD_BASE + 0x04) /* Vertical Synchronize Register */
++#define LCD_HSYNC (LCD_BASE + 0x08) /* Horizontal Synchronize Register */
++#define LCD_VAT (LCD_BASE + 0x0c) /* Virtual Area Setting Register */
++#define LCD_DAH (LCD_BASE + 0x10) /* Display Area Horizontal Start/End Point */
++#define LCD_DAV (LCD_BASE + 0x14) /* Display Area Vertical Start/End Point */
++#define LCD_PS (LCD_BASE + 0x18) /* PS Signal Setting */
++#define LCD_CLS (LCD_BASE + 0x1c) /* CLS Signal Setting */
++#define LCD_SPL (LCD_BASE + 0x20) /* SPL Signal Setting */
++#define LCD_REV (LCD_BASE + 0x24) /* REV Signal Setting */
++#define LCD_CTRL (LCD_BASE + 0x30) /* LCD Control Register */
++#define LCD_STATE (LCD_BASE + 0x34) /* LCD Status Register */
++#define LCD_IID (LCD_BASE + 0x38) /* Interrupt ID Register */
++#define LCD_DA0 (LCD_BASE + 0x40) /* Descriptor Address Register 0 */
++#define LCD_SA0 (LCD_BASE + 0x44) /* Source Address Register 0 */
++#define LCD_FID0 (LCD_BASE + 0x48) /* Frame ID Register 0 */
++#define LCD_CMD0 (LCD_BASE + 0x4c) /* DMA Command Register 0 */
++#define LCD_DA1 (LCD_BASE + 0x50) /* Descriptor Address Register 1 */
++#define LCD_SA1 (LCD_BASE + 0x54) /* Source Address Register 1 */
++#define LCD_FID1 (LCD_BASE + 0x58) /* Frame ID Register 1 */
++#define LCD_CMD1 (LCD_BASE + 0x5c) /* DMA Command Register 1 */
++
++#define REG_LCD_CFG REG32(LCD_CFG)
++#define REG_LCD_VSYNC REG32(LCD_VSYNC)
++#define REG_LCD_HSYNC REG32(LCD_HSYNC)
++#define REG_LCD_VAT REG32(LCD_VAT)
++#define REG_LCD_DAH REG32(LCD_DAH)
++#define REG_LCD_DAV REG32(LCD_DAV)
++#define REG_LCD_PS REG32(LCD_PS)
++#define REG_LCD_CLS REG32(LCD_CLS)
++#define REG_LCD_SPL REG32(LCD_SPL)
++#define REG_LCD_REV REG32(LCD_REV)
++#define REG_LCD_CTRL REG32(LCD_CTRL)
++#define REG_LCD_STATE REG32(LCD_STATE)
++#define REG_LCD_IID REG32(LCD_IID)
++#define REG_LCD_DA0 REG32(LCD_DA0)
++#define REG_LCD_SA0 REG32(LCD_SA0)
++#define REG_LCD_FID0 REG32(LCD_FID0)
++#define REG_LCD_CMD0 REG32(LCD_CMD0)
++#define REG_LCD_DA1 REG32(LCD_DA1)
++#define REG_LCD_SA1 REG32(LCD_SA1)
++#define REG_LCD_FID1 REG32(LCD_FID1)
++#define REG_LCD_CMD1 REG32(LCD_CMD1)
++
++#define LCD_CTRL_BPP_BIT 0 /* Bits Per Pixel */
++#define LCD_CTRL_BPP_MASK (0x07 << LCD_CTRL_BPP_BIT)
++ #define LCD_CTRL_BPP_1 (0 << LCD_CTRL_BPP_BIT) /* 1 bpp */
++ #define LCD_CTRL_BPP_2 (1 << LCD_CTRL_BPP_BIT) /* 2 bpp */
++ #define LCD_CTRL_BPP_4 (2 << LCD_CTRL_BPP_BIT) /* 4 bpp */
++ #define LCD_CTRL_BPP_8 (3 << LCD_CTRL_BPP_BIT) /* 8 bpp */
++ #define LCD_CTRL_BPP_16 (4 << LCD_CTRL_BPP_BIT) /* 15/16 bpp */
++ #define LCD_CTRL_BPP_18_24 (5 << LCD_CTRL_BPP_BIT) /* 18/24/32 bpp */
++
++#define LCD_CTRL_BST_BIT 28 /* Burst Length Selection */
++#define LCD_CTRL_BST_MASK (0x03 << LCD_CTRL_BST_BIT)
++ #define LCD_CTRL_BST_4 (0 << LCD_CTRL_BST_BIT) /* 4-word */
++ #define LCD_CTRL_BST_8 (1 << LCD_CTRL_BST_BIT) /* 8-word */
++ #define LCD_CTRL_BST_16 (2 << LCD_CTRL_BST_BIT) /* 16-word */
++#define LCD_CTRL_RGB565 (0 << 27) /* RGB565 mode */
++#define LCD_CTRL_RGB555 (1 << 27) /* RGB555 mode */
++#define LCD_CTRL_OFUP (1 << 26) /* Output FIFO underrun protection enable */
++#define LCD_CTRL_FRC_BIT 24 /* STN FRC Algorithm Selection */
++#define LCD_CTRL_FRC_MASK (0x03 << LCD_CTRL_FRC_BIT)
++ #define LCD_CTRL_FRC_16 (0 << LCD_CTRL_FRC_BIT) /* 16 grayscale */
++ #define LCD_CTRL_FRC_4 (1 << LCD_CTRL_FRC_BIT) /* 4 grayscale */
++ #define LCD_CTRL_FRC_2 (2 << LCD_CTRL_FRC_BIT) /* 2 grayscale */
++
++#define CPM_LPCDR (CPM_BASE+0x64)
++#define CPM_CLKGR (CPM_BASE+0x20)
++#define REG_CPM_LPCDR REG32(CPM_LPCDR)
++#define REG_CPM_CLKGR REG32(CPM_CLKGR)
++
++#define __cpm_start_tcu() (REG_CPM_CLKGR &= ~CPM_CLKGR_TCU)
++#define __cpm_stop_lcd() (REG_CPM_CLKGR |= CPM_CLKGR_LCD)
++#define __cpm_set_pixdiv(v) \
++ (REG_CPM_LPCDR = (REG_CPM_LPCDR & ~CPM_LPCDR_PIXDIV_MASK) | ((v) << (CPM_LPCDR_PIXDIV_BIT)))
++#define __cpm_set_ldiv(v) \
++ (REG_CPM_CPCCR = (REG_CPM_CPCCR & ~CPM_CPCCR_LDIV_MASK) | ((v) << (CPM_CPCCR_LDIV_BIT)))
++#define __cpm_start_lcd() (REG_CPM_CLKGR &= ~CPM_CLKGR_LCD)
++
+ #endif /* !__ASSEMBLY__ */
+ #endif /* __JZ4740_H__ */
+diff --git a/arch/mips/lib/board.c b/arch/mips/lib/board.c
+index b14b33e..c2e64d9 100644
+--- a/arch/mips/lib/board.c
++++ b/arch/mips/lib/board.c
+@@ -172,6 +172,12 @@ void board_init_f(ulong bootflag)
+ addr &= ~(4096 - 1);
+ debug("Top of RAM usable for U-Boot at: %08lx\n", addr);
+
++#ifdef CONFIG_LCD
++ /* reserve memory for LCD display (always full pages) */
++ addr = lcd_setmem (addr);
++ gd->fb_base = addr;
++#endif /* CONFIG_LCD */
++
+ /* Reserve memory for U-Boot code, data & bss
+ * round down to next 16 kB limit
+ */
+diff --git a/common/lcd.c b/common/lcd.c
+index b6be800..af1281a 100644
+--- a/common/lcd.c
++++ b/common/lcd.c
+@@ -263,6 +263,13 @@ static void lcd_drawchars(ushort x, ushort y, uchar *str, int count)
+ lcd_color_fg : lcd_color_bg;
+ bits <<= 1;
+ }
++#elif LCD_BPP == LCD_COLOR32
++ uint *m = (uint *)d;
++ for (c=0; c<32; ++c) {
++ *m++ = (bits & 0x80) ?
++ lcd_color_fg : lcd_color_bg;
++ bits <<= 1;
++ }
+ #endif
+ }
+ #if LCD_BPP == LCD_MONOCHROME
+@@ -509,7 +516,7 @@ static inline ushort *configuration_get_cmap(void)
+ return (ushort *)&(cp->lcd_cmap[255 * sizeof(ushort)]);
+ #elif defined(CONFIG_ATMEL_LCD)
+ return (ushort *)(panel_info.mmio + ATMEL_LCDC_LUT(0));
+-#elif !defined(CONFIG_ATMEL_HLCD) && !defined(CONFIG_EXYNOS_FB)
++#elif !defined(CONFIG_ATMEL_HLCD) && !defined(CONFIG_EXYNOS_FB) && !defined(CONFIG_VIDEO_GPM940B0)
+ return panel_info.cmap;
+ #else
+ #if defined(CONFIG_LCD_LOGO)
+diff --git a/drivers/video/Makefile b/drivers/video/Makefile
+index ebb6da8..03625bc 100644
+--- a/drivers/video/Makefile
++++ b/drivers/video/Makefile
+@@ -50,6 +50,7 @@ COBJS-$(CONFIG_VIDEO_SED13806) += sed13806.o
+ COBJS-$(CONFIG_VIDEO_SM501) += sm501.o
+ COBJS-$(CONFIG_VIDEO_SMI_LYNXEM) += smiLynxEM.o videomodes.o
+ COBJS-$(CONFIG_VIDEO_VCXK) += bus_vcxk.o
++COBJS-$(CONFIG_VIDEO_GPM940B0) += nanonote_gpm940b0.o
+
+ COBJS := $(sort $(COBJS-y))
+ SRCS := $(COBJS:.o=.c)
+diff --git a/drivers/video/nanonote_gpm940b0.c b/drivers/video/nanonote_gpm940b0.c
+new file mode 100644
+index 0000000..11efb72
+--- /dev/null
++++ b/drivers/video/nanonote_gpm940b0.c
+@@ -0,0 +1,400 @@
++/*
++ * JzRISC lcd controller
++ *
++ * Xiangfu Liu <xiangfu@sharism.cc>
++ *
++ * 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 of
++ * the License, 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; if not, write to the Free Software
++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ * MA 02111-1307 USA
++ */
++
++#include <config.h>
++#include <common.h>
++#include <lcd.h>
++
++#include <asm/io.h> /* virt_to_phys() */
++#include <asm/jz4740.h>
++
++#include "nanonote_gpm940b0.h"
++
++#define align2(n) (n)=((((n)+1)>>1)<<1)
++#define align4(n) (n)=((((n)+3)>>2)<<2)
++#define align8(n) (n)=((((n)+7)>>3)<<3)
++
++struct jzfb_info {
++ unsigned int cfg; /* panel mode and pin usage etc. */
++ unsigned int w;
++ unsigned int h;
++ unsigned int bpp; /* bit per pixel */
++ unsigned int fclk; /* frame clk */
++ unsigned int hsw; /* hsync width, in pclk */
++ unsigned int vsw; /* vsync width, in line count */
++ unsigned int elw; /* end of line, in pclk */
++ unsigned int blw; /* begin of line, in pclk */
++ unsigned int efw; /* end of frame, in line count */
++ unsigned int bfw; /* begin of frame, in line count */
++};
++
++static struct jzfb_info jzfb = {
++ MODE_8BIT_SERIAL_TFT | PCLK_N | HSYNC_N | VSYNC_N,
++ 320, 240, 32, 70, 1, 1, 273, 140, 1, 20
++};
++
++vidinfo_t panel_info = {
++ 320, 240, LCD_BPP,
++};
++
++void *lcd_base;
++void *lcd_console_address;
++int lcd_line_length;
++int lcd_color_fg;
++int lcd_color_bg;
++short console_col;
++short console_row;
++
++static int jz_lcd_init_mem(void *lcdbase, vidinfo_t *vid)
++{
++ u_long palette_mem_size;
++ struct jz_fb_info *fbi = &vid->jz_fb;
++ int fb_size = vid->vl_row * (vid->vl_col * NBITS (vid->vl_bpix)) / 8;
++
++ fbi->screen = (u_long)lcdbase;
++ fbi->palette_size = 256;
++ palette_mem_size = fbi->palette_size * sizeof(u16);
++
++ debug("jz_lcd.c palette_mem_size = 0x%08lx\n", (u_long) palette_mem_size);
++ /* locate palette and descs at end of page following fb */
++ fbi->palette = (u_long)lcdbase + fb_size + PAGE_SIZE - palette_mem_size;
++
++ return 0;
++}
++
++static void jz_lcd_desc_init(vidinfo_t *vid)
++{
++ struct jz_fb_info * fbi;
++ fbi = &vid->jz_fb;
++ fbi->dmadesc_fblow = (struct jz_fb_dma_descriptor *)((unsigned int)fbi->palette - 3*16);
++ fbi->dmadesc_fbhigh = (struct jz_fb_dma_descriptor *)((unsigned int)fbi->palette - 2*16);
++ fbi->dmadesc_palette = (struct jz_fb_dma_descriptor *)((unsigned int)fbi->palette - 1*16);
++
++ #define BYTES_PER_PANEL (vid->vl_col * vid->vl_row * NBITS(vid->vl_bpix) / 8)
++
++ /* populate descriptors */
++ fbi->dmadesc_fblow->fdadr = virt_to_phys(fbi->dmadesc_fblow);
++ fbi->dmadesc_fblow->fsadr = virt_to_phys((void *)(fbi->screen + BYTES_PER_PANEL));
++ fbi->dmadesc_fblow->fidr = 0;
++ fbi->dmadesc_fblow->ldcmd = BYTES_PER_PANEL / 4 ;
++
++ fbi->fdadr1 = virt_to_phys(fbi->dmadesc_fblow); /* only used in dual-panel mode */
++
++ fbi->dmadesc_fbhigh->fsadr = virt_to_phys((void *)fbi->screen);
++ fbi->dmadesc_fbhigh->fidr = 0;
++ fbi->dmadesc_fbhigh->ldcmd = BYTES_PER_PANEL / 4; /* length in word */
++
++ fbi->dmadesc_palette->fsadr = virt_to_phys((void *)fbi->palette);
++ fbi->dmadesc_palette->fidr = 0;
++ fbi->dmadesc_palette->ldcmd = (fbi->palette_size * 2)/4 | (1<<28);
++
++ if(NBITS(vid->vl_bpix) < 12) {
++ /* assume any mode with <12 bpp is palette driven */
++ fbi->dmadesc_palette->fdadr = virt_to_phys(fbi->dmadesc_fbhigh);
++ fbi->dmadesc_fbhigh->fdadr = virt_to_phys(fbi->dmadesc_palette);
++ /* flips back and forth between pal and fbhigh */
++ fbi->fdadr0 = virt_to_phys(fbi->dmadesc_palette);
++ } else {
++ /* palette shouldn't be loaded in true-color mode */
++ fbi->dmadesc_fbhigh->fdadr = virt_to_phys((void *)fbi->dmadesc_fbhigh);
++ fbi->fdadr0 = virt_to_phys(fbi->dmadesc_fbhigh); /* no pal just fbhigh */
++ }
++}
++
++static int jz_lcd_hw_init(vidinfo_t *vid)
++{
++ struct jz_fb_info *fbi = &vid->jz_fb;
++ unsigned int val = 0;
++ unsigned int pclk;
++ unsigned int stnH;
++ int pll_div;
++
++ /* Setting Control register */
++ switch (jzfb.bpp) {
++ case 1:
++ val |= LCD_CTRL_BPP_1;
++ break;
++ case 2:
++ val |= LCD_CTRL_BPP_2;
++ break;
++ case 4:
++ val |= LCD_CTRL_BPP_4;
++ break;
++ case 8:
++ val |= LCD_CTRL_BPP_8;
++ break;
++ case 15:
++ val |= LCD_CTRL_RGB555;
++ case 16:
++ val |= LCD_CTRL_BPP_16;
++ break;
++ case 17 ... 32:
++ val |= LCD_CTRL_BPP_18_24; /* target is 4bytes/pixel */
++ break;
++
++ default:
++ printf("jz_lcd.c The BPP %d is not supported\n", jzfb.bpp);
++ val |= LCD_CTRL_BPP_16;
++ break;
++ }
++
++ switch (jzfb.cfg & MODE_MASK) {
++ case MODE_STN_MONO_DUAL:
++ case MODE_STN_COLOR_DUAL:
++ case MODE_STN_MONO_SINGLE:
++ case MODE_STN_COLOR_SINGLE:
++ switch (jzfb.bpp) {
++ case 1:
++ /* val |= LCD_CTRL_PEDN; */
++ case 2:
++ val |= LCD_CTRL_FRC_2;
++ break;
++ case 4:
++ val |= LCD_CTRL_FRC_4;
++ break;
++ case 8:
++ default:
++ val |= LCD_CTRL_FRC_16;
++ break;
++ }
++ break;
++ }
++
++ val |= LCD_CTRL_BST_16; /* Burst Length is 16WORD=64Byte */
++ val |= LCD_CTRL_OFUP; /* OutFIFO underrun protect */
++
++ switch (jzfb.cfg & MODE_MASK) {
++ case MODE_STN_MONO_DUAL:
++ case MODE_STN_COLOR_DUAL:
++ case MODE_STN_MONO_SINGLE:
++ case MODE_STN_COLOR_SINGLE:
++ switch (jzfb.cfg & STN_DAT_PINMASK) {
++ case STN_DAT_PIN1:
++ /* Do not adjust the hori-param value. */
++ break;
++ case STN_DAT_PIN2:
++ align2(jzfb.hsw);
++ align2(jzfb.elw);
++ align2(jzfb.blw);
++ break;
++ case STN_DAT_PIN4:
++ align4(jzfb.hsw);
++ align4(jzfb.elw);
++ align4(jzfb.blw);
++ break;
++ case STN_DAT_PIN8:
++ align8(jzfb.hsw);
++ align8(jzfb.elw);
++ align8(jzfb.blw);
++ break;
++ }
++ break;
++ }
++
++ REG_LCD_CTRL = val;
++
++ switch (jzfb.cfg & MODE_MASK) {
++ case MODE_STN_MONO_DUAL:
++ case MODE_STN_COLOR_DUAL:
++ case MODE_STN_MONO_SINGLE:
++ case MODE_STN_COLOR_SINGLE:
++ if (((jzfb.cfg & MODE_MASK) == MODE_STN_MONO_DUAL) ||
++ ((jzfb.cfg & MODE_MASK) == MODE_STN_COLOR_DUAL))
++ stnH = jzfb.h >> 1;
++ else
++ stnH = jzfb.h;
++
++ REG_LCD_VSYNC = (0 << 16) | jzfb.vsw;
++ REG_LCD_HSYNC = ((jzfb.blw+jzfb.w) << 16) | (jzfb.blw+jzfb.w+jzfb.hsw);
++
++ /* Screen setting */
++ REG_LCD_VAT = ((jzfb.blw + jzfb.w + jzfb.hsw + jzfb.elw) << 16) | (stnH + jzfb.vsw + jzfb.bfw + jzfb.efw);
++ REG_LCD_DAH = (jzfb.blw << 16) | (jzfb.blw + jzfb.w);
++ REG_LCD_DAV = (0 << 16) | (stnH);
++
++ /* AC BIAs signal */
++ REG_LCD_PS = (0 << 16) | (stnH+jzfb.vsw+jzfb.efw+jzfb.bfw);
++
++ break;
++
++ case MODE_TFT_GEN:
++ case MODE_TFT_SHARP:
++ case MODE_TFT_CASIO:
++ case MODE_TFT_SAMSUNG:
++ case MODE_8BIT_SERIAL_TFT:
++ case MODE_TFT_18BIT:
++ REG_LCD_VSYNC = (0 << 16) | jzfb.vsw;
++ REG_LCD_HSYNC = (0 << 16) | jzfb.hsw;
++ REG_LCD_DAV =((jzfb.vsw+jzfb.bfw) << 16) | (jzfb.vsw +jzfb.bfw+jzfb.h);
++ REG_LCD_DAH = ((jzfb.hsw + jzfb.blw) << 16) | (jzfb.hsw + jzfb.blw + jzfb.w );
++ REG_LCD_VAT = (((jzfb.blw + jzfb.w + jzfb.elw + jzfb.hsw)) << 16) \
++ | (jzfb.vsw + jzfb.bfw + jzfb.h + jzfb.efw);
++ break;
++ }
++
++ switch (jzfb.cfg & MODE_MASK) {
++ case MODE_TFT_SAMSUNG:
++ {
++ unsigned int total, tp_s, tp_e, ckv_s, ckv_e;
++ unsigned int rev_s, rev_e, inv_s, inv_e;
++
++ pclk = val * (jzfb.w + jzfb.hsw + jzfb.elw + jzfb.blw) *
++ (jzfb.h + jzfb.vsw + jzfb.efw + jzfb.bfw); /* Pixclk */
++
++ total = jzfb.blw + jzfb.w + jzfb.elw + jzfb.hsw;
++ tp_s = jzfb.blw + jzfb.w + 1;
++ tp_e = tp_s + 1;
++ ckv_s = tp_s - pclk/(1000000000/4100);
++ ckv_e = tp_s + total;
++ rev_s = tp_s - 11; /* -11.5 clk */
++ rev_e = rev_s + total;
++ inv_s = tp_s;
++ inv_e = inv_s + total;
++ REG_LCD_CLS = (tp_s << 16) | tp_e;
++ REG_LCD_PS = (ckv_s << 16) | ckv_e;
++ REG_LCD_SPL = (rev_s << 16) | rev_e;
++ REG_LCD_REV = (inv_s << 16) | inv_e;
++ jzfb.cfg |= STFT_REVHI | STFT_SPLHI;
++ break;
++ }
++ case MODE_TFT_SHARP:
++ {
++ unsigned int total, cls_s, cls_e, ps_s, ps_e;
++ unsigned int spl_s, spl_e, rev_s, rev_e;
++ total = jzfb.blw + jzfb.w + jzfb.elw + jzfb.hsw;
++ spl_s = 1;
++ spl_e = spl_s + 1;
++ cls_s = 0;
++ cls_e = total - 60; /* > 4us (pclk = 80ns) */
++ ps_s = cls_s;
++ ps_e = cls_e;
++ rev_s = total - 40; /* > 3us (pclk = 80ns) */
++ rev_e = rev_s + total;
++ jzfb.cfg |= STFT_PSHI;
++ REG_LCD_SPL = (spl_s << 16) | spl_e;
++ REG_LCD_CLS = (cls_s << 16) | cls_e;
++ REG_LCD_PS = (ps_s << 16) | ps_e;
++ REG_LCD_REV = (rev_s << 16) | rev_e;
++ break;
++ }
++ case MODE_TFT_CASIO:
++ break;
++ }
++
++ /* Configure the LCD panel */
++ REG_LCD_CFG = jzfb.cfg;
++
++ /* Timing setting */
++ __cpm_stop_lcd();
++
++ val = jzfb.fclk; /* frame clk */
++ if ( (jzfb.cfg & MODE_MASK) != MODE_8BIT_SERIAL_TFT) {
++ pclk = val * (jzfb.w + jzfb.hsw + jzfb.elw + jzfb.blw) *
++ (jzfb.h + jzfb.vsw + jzfb.efw + jzfb.bfw); /* Pixclk */
++ } else {
++ /* serial mode: Hsync period = 3*Width_Pixel */
++ pclk = val * (jzfb.w*3 + jzfb.hsw + jzfb.elw + jzfb.blw) *
++ (jzfb.h + jzfb.vsw + jzfb.efw + jzfb.bfw); /* Pixclk */
++ }
++
++ if (((jzfb.cfg & MODE_MASK) == MODE_STN_COLOR_SINGLE) ||
++ ((jzfb.cfg & MODE_MASK) == MODE_STN_COLOR_DUAL))
++ pclk = (pclk * 3);
++
++ if (((jzfb.cfg & MODE_MASK) == MODE_STN_COLOR_SINGLE) ||
++ ((jzfb.cfg & MODE_MASK) == MODE_STN_COLOR_DUAL) ||
++ ((jzfb.cfg & MODE_MASK) == MODE_STN_MONO_SINGLE) ||
++ ((jzfb.cfg & MODE_MASK) == MODE_STN_MONO_DUAL))
++ pclk = pclk >> ((jzfb.cfg & STN_DAT_PINMASK) >> 4);
++
++ if (((jzfb.cfg & MODE_MASK) == MODE_STN_COLOR_DUAL) ||
++ ((jzfb.cfg & MODE_MASK) == MODE_STN_MONO_DUAL))
++ pclk >>= 1;
++
++ pll_div = (REG_CPM_CPCCR & CPM_CPCCR_PCS); /* clock source,0:pllout/2 1: pllout */
++ pll_div = pll_div ? 1 : 2;
++ val = (__cpm_get_pllout() / pll_div) / pclk;
++ val--;
++ if (val > 0x1ff) {
++ printf("CPM_LPCDR too large, set it to 0x1ff\n");
++ val = 0x1ff;
++ }
++ __cpm_set_pixdiv(val);
++
++ val = pclk * 3 ; /* LCDClock > 2.5*Pixclock */
++ if (val > 150000000) {
++ printf("Warning: LCDClock=%d\n, LCDClock must less or equal to 150MHz.\n", val);
++ printf("Change LCDClock to 150MHz\n");
++ val = 150000000;
++ }
++ val = (__cpm_get_pllout() / pll_div) / val;
++ val--;
++ if (val > 0x1f) {
++ printf("CPM_CPCCR.LDIV too large, set it to 0x1f\n");
++ val = 0x1f;
++ }
++ __cpm_set_ldiv( val );
++ REG_CPM_CPCCR |= CPM_CPCCR_CE ; /* update divide */
++
++ __cpm_start_lcd();
++ udelay(1000);
++
++ REG_LCD_DA0 = fbi->fdadr0; /* frame descripter*/
++
++ if (((jzfb.cfg & MODE_MASK) == MODE_STN_COLOR_DUAL) ||
++ ((jzfb.cfg & MODE_MASK) == MODE_STN_MONO_DUAL))
++ REG_LCD_DA1 = fbi->fdadr1; /* frame descripter*/
++
++ return 0;
++}
++
++void lcd_ctrl_init (void *lcdbase)
++{
++ __lcd_display_pin_init();
++ __lcd_display_on() ;
++
++ jz_lcd_init_mem(lcdbase, &panel_info);
++ jz_lcd_desc_init(&panel_info);
++ jz_lcd_hw_init(&panel_info);
++
++}
++
++/*
++ * Before enabled lcd controller, lcd registers should be configured correctly.
++ */
++void lcd_enable (void)
++{
++ REG_LCD_CTRL &= ~(1<<4); /* LCDCTRL.DIS */
++ REG_LCD_CTRL |= 1<<3; /* LCDCTRL.ENA*/
++}
++
++void lcd_disable (void)
++{
++ REG_LCD_CTRL |= (1<<4);
++}
++
++void lcd_setcolreg (ushort regno, ushort red, ushort green, ushort blue)
++{
++}
++
++void lcd_initcolregs (void)
++{
++}
+diff --git a/drivers/video/nanonote_gpm940b0.h b/drivers/video/nanonote_gpm940b0.h
+new file mode 100644
+index 0000000..efe491e
+--- /dev/null
++++ b/drivers/video/nanonote_gpm940b0.h
+@@ -0,0 +1,135 @@
++/*
++ * JzRISC lcd controller
++ *
++ * Xiangfu Liu <xiangfu@sharism.cc>
++ *
++ * 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 of
++ * the License, 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; if not, write to the Free Software
++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ * MA 02111-1307 USA
++ */
++
++#ifndef __QI_LB60_GPM940B0_H__
++#define __QI_LB60_GPM940B0_H__
++
++struct lcd_desc{
++ unsigned int next_desc; /* LCDDAx */
++ unsigned int databuf; /* LCDSAx */
++ unsigned int frame_id; /* LCDFIDx */
++ unsigned int cmd; /* LCDCMDx */
++};
++
++#define MODE_MASK 0x0f
++#define MODE_TFT_GEN 0x00
++#define MODE_TFT_SHARP 0x01
++#define MODE_TFT_CASIO 0x02
++#define MODE_TFT_SAMSUNG 0x03
++#define MODE_CCIR656_NONINT 0x04
++#define MODE_CCIR656_INT 0x05
++#define MODE_STN_COLOR_SINGLE 0x08
++#define MODE_STN_MONO_SINGLE 0x09
++#define MODE_STN_COLOR_DUAL 0x0a
++#define MODE_STN_MONO_DUAL 0x0b
++#define MODE_8BIT_SERIAL_TFT 0x0c
++
++#define MODE_TFT_18BIT (1<<7)
++
++#define STN_DAT_PIN1 (0x00 << 4)
++#define STN_DAT_PIN2 (0x01 << 4)
++#define STN_DAT_PIN4 (0x02 << 4)
++#define STN_DAT_PIN8 (0x03 << 4)
++#define STN_DAT_PINMASK STN_DAT_PIN8
++
++#define STFT_PSHI (1 << 15)
++#define STFT_CLSHI (1 << 14)
++#define STFT_SPLHI (1 << 13)
++#define STFT_REVHI (1 << 12)
++
++#define SYNC_MASTER (0 << 16)
++#define SYNC_SLAVE (1 << 16)
++
++#define DE_P (0 << 9)
++#define DE_N (1 << 9)
++
++#define PCLK_P (0 << 10)
++#define PCLK_N (1 << 10)
++
++#define HSYNC_P (0 << 11)
++#define HSYNC_N (1 << 11)
++
++#define VSYNC_P (0 << 8)
++#define VSYNC_N (1 << 8)
++
++#define DATA_NORMAL (0 << 17)
++#define DATA_INVERSE (1 << 17)
++
++
++/* Jz LCDFB supported I/O controls. */
++#define FBIOSETBACKLIGHT 0x4688
++#define FBIODISPON 0x4689
++#define FBIODISPOFF 0x468a
++#define FBIORESET 0x468b
++#define FBIOPRINT_REG 0x468c
++
++/*
++ * LCD panel specific definition
++ */
++#define MODE (0xc9) /* 8bit serial RGB */
++
++#define __spi_write_reg1(reg, val) \
++do { \
++ unsigned char no; \
++ unsigned short value; \
++ unsigned char a=reg; \
++ unsigned char b=val; \
++ __gpio_set_pin(SPEN); \
++ __gpio_set_pin(SPCK); \
++ __gpio_clear_pin(SPDA); \
++ __gpio_clear_pin(SPEN); \
++ value=((a<<8)|(b&0xFF)); \
++ for(no=0;no<16;no++) \
++ { \
++ __gpio_clear_pin(SPCK); \
++ if((value&0x8000)==0x8000) \
++ __gpio_set_pin(SPDA); \
++ else \
++ __gpio_clear_pin(SPDA); \
++ __gpio_set_pin(SPCK); \
++ value=(value<<1); \
++ } \
++ __gpio_set_pin(SPEN); \
++} while (0)
++
++#define __lcd_display_pin_init() \
++do { \
++ __cpm_start_tcu(); \
++ __gpio_as_output(SPEN); /* use SPDA */ \
++ __gpio_as_output(SPCK); /* use SPCK */ \
++ __gpio_as_output(SPDA); /* use SPDA */ \
++} while (0)
++
++#define __lcd_display_on() \
++do { \
++ __spi_write_reg1(0x05, 0x1e); \
++ __spi_write_reg1(0x05, 0x5e); \
++ __spi_write_reg1(0x07, 0x8d); \
++ __spi_write_reg1(0x13, 0x01); \
++ __spi_write_reg1(0x05, 0x5f); \
++} while (0)
++
++#define __lcd_display_off() \
++do { \
++ __spi_write_reg1(0x05, 0x5e); \
++} while (0)
++
++#endif /* __QI_LB60_GPM940B0_H__ */
+diff --git a/include/configs/qi_lb60.h b/include/configs/qi_lb60.h
+index 52b370c..d3e78ad 100644
+--- a/include/configs/qi_lb60.h
++++ b/include/configs/qi_lb60.h
+@@ -32,6 +32,13 @@
+ * Miscellaneous configurable options
+ */
+ #define CONFIG_NANONOTE
++
++#define CONFIG_LCD
++#define CONFIG_SYS_WHITE_ON_BLACK
++#define LCD_BPP LCD_COLOR32
++#define CONFIG_VIDEO_GPM940B0
++
++
+ #define CONFIG_JZ4740_MMC
+ #define CONFIG_MMC 1
+ #define CONFIG_FAT 1
+diff --git a/include/lcd.h b/include/lcd.h
+index 42070d7..6de5482 100644
+--- a/include/lcd.h
++++ b/include/lcd.h
+@@ -263,8 +263,44 @@ typedef struct vidinfo {
+
+ void init_panel_info(vidinfo_t *vid);
+
+-#else
++#elif defined(CONFIG_JZSOC)
++/*
++ * LCD controller stucture for JZSOC: JZ4740
++ */
++struct jz_fb_dma_descriptor {
++ u_long fdadr; /* Frame descriptor address register */
++ u_long fsadr; /* Frame source address register */
++ u_long fidr; /* Frame ID register */
++ u_long ldcmd; /* Command register */
++};
++
++/*
++ * Jz LCD info
++ */
++struct jz_fb_info {
++
++ u_long fdadr0; /* physical address of frame/palette descriptor */
++ u_long fdadr1; /* physical address of frame descriptor */
++
++ /* DMA descriptors */
++ struct jz_fb_dma_descriptor * dmadesc_fblow;
++ struct jz_fb_dma_descriptor * dmadesc_fbhigh;
++ struct jz_fb_dma_descriptor * dmadesc_palette;
++ u_long screen; /* address of frame buffer */
++ u_long palette; /* address of palette memory */
++ u_int palette_size;
++};
++typedef struct vidinfo {
++ ushort vl_col; /* Number of columns (i.e. 640) */
++ ushort vl_row; /* Number of rows (i.e. 480) */
++ u_char vl_bpix; /* Bits per pixel, 0 = 1, 1 = 2, 2 = 4, 3 = 8 */
++
++ struct jz_fb_info jz_fb;
++} vidinfo_t;
++
++extern vidinfo_t panel_info;
+
++#else
+ typedef struct vidinfo {
+ ushort vl_col; /* Number of columns (i.e. 160) */
+ ushort vl_row; /* Number of rows (i.e. 100) */
+@@ -318,6 +354,7 @@ void lcd_show_board_info(void);
+ #define LCD_COLOR4 2
+ #define LCD_COLOR8 3
+ #define LCD_COLOR16 4
++#define LCD_COLOR32 5
+
+ /*----------------------------------------------------------------------*/
+ #if defined(CONFIG_LCD_INFO_BELOW_LOGO)
+@@ -369,7 +406,7 @@ void lcd_show_board_info(void);
+ # define CONSOLE_COLOR_GREY 14
+ # define CONSOLE_COLOR_WHITE 15 /* Must remain last / highest */
+
+-#else
++#elif LCD_BPP == LCD_COLOR16
+
+ /*
+ * 16bpp color definitions
+@@ -377,6 +414,15 @@ void lcd_show_board_info(void);
+ # define CONSOLE_COLOR_BLACK 0x0000
+ # define CONSOLE_COLOR_WHITE 0xffff /* Must remain last / highest */
+
++#elif LCD_BPP == LCD_COLOR32
++/*
++ * 18,24,32 bpp color definitions
++ */
++# define CONSOLE_COLOR_BLACK 0x00000000
++# define CONSOLE_COLOR_WHITE 0xffffffff /* Must remain last / highest */
++
++#else
++
+ #endif /* color definitions */
+
+ /************************************************************************/
+@@ -406,7 +452,7 @@ void lcd_show_board_info(void);
+ #if LCD_BPP == LCD_MONOCHROME
+ # define COLOR_MASK(c) ((c) | (c) << 1 | (c) << 2 | (c) << 3 | \
+ (c) << 4 | (c) << 5 | (c) << 6 | (c) << 7)
+-#elif (LCD_BPP == LCD_COLOR8) || (LCD_BPP == LCD_COLOR16)
++#elif (LCD_BPP == LCD_COLOR8) || (LCD_BPP == LCD_COLOR16) || (LCD_BPP == LCD_COLOR32)
+ # define COLOR_MASK(c) (c)
+ #else
+ # error Unsupported LCD BPP.
+--
+1.7.9.5
+
diff --git a/package/boot/uboot-xburst/patches/0006-enable-silent-console.patch b/package/boot/uboot-xburst/patches/0006-enable-silent-console.patch
new file mode 100644
index 0000000..ebd6a6a
--- /dev/null
+++ b/package/boot/uboot-xburst/patches/0006-enable-silent-console.patch
@@ -0,0 +1,60 @@
+From 5eb4d4c598f2806bd1b3d1140e917bfead7851ad Mon Sep 17 00:00:00 2001
+From: Xiangfu <xiangfu@openmobilefree.net>
+Date: Wed, 10 Oct 2012 23:51:26 +0800
+Subject: [PATCH 6/6] enable silent console
+
+---
+ common/console.c | 16 ++++++++++++++++
+ include/configs/qi_lb60.h | 2 ++
+ 2 files changed, 18 insertions(+)
+
+diff --git a/common/console.c b/common/console.c
+index 1177f7d..e8a2078 100644
+--- a/common/console.c
++++ b/common/console.c
+@@ -685,6 +685,14 @@ done:
+
+ gd->flags |= GD_FLG_DEVINIT; /* device initialization completed */
+
++#ifdef CONFIG_SILENT_CONSOLE
++ /* Check one more time the contents of the silent environment
++ * variable, because if the environment is loaded from NAND it was
++ * not available when console_init_f() was called */
++ if (getenv("silent") != NULL)
++ gd->flags |= GD_FLG_SILENT;
++#endif
++
+ stdio_print_current_devices();
+
+ #ifdef CONFIG_SYS_CONSOLE_ENV_OVERWRITE
+@@ -760,6 +768,14 @@ int console_init_r(void)
+
+ gd->flags |= GD_FLG_DEVINIT; /* device initialization completed */
+
++#ifdef CONFIG_SILENT_CONSOLE
++ /* Check one more time the contents of the silent environment
++ * variable, because if the environment is loaded from NAND it was
++ * not available when console_init_f() was called */
++ if (getenv("silent") != NULL)
++ gd->flags |= GD_FLG_SILENT;
++#endif
++
+ stdio_print_current_devices();
+
+ /* Setting environment variables */
+diff --git a/include/configs/qi_lb60.h b/include/configs/qi_lb60.h
+index d3e78ad..a3534ff 100644
+--- a/include/configs/qi_lb60.h
++++ b/include/configs/qi_lb60.h
+@@ -102,6 +102,8 @@
+ #define CONFIG_SYS_NO_FLASH
+ #define CONFIG_SYS_FLASH_BASE 0 /* init flash_base as 0 */
+
++#define CONFIG_SILENT_CONSOLE 1 /* Enable silent console */
++
+ /*
+ * Command line configuration
+ */
+--
+1.7.9.5
+
diff --git a/package/boot/yamonenv/.svn/entries b/package/boot/yamonenv/.svn/entries
new file mode 100644
index 0000000..3b96508
--- /dev/null
+++ b/package/boot/yamonenv/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/yamonenv
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+6c2b050e03080e465cf30e3b809c68cd
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+897
+
diff --git a/package/boot/yamonenv/.svn/prop-base/Makefile.svn-base b/package/boot/yamonenv/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..8e522ae
--- /dev/null
+++ b/package/boot/yamonenv/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:copyright
+V 30
+Copyright (C) 2006 OpenWrt.org
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/boot/yamonenv/.svn/text-base/Makefile.svn-base b/package/boot/yamonenv/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..e1d2a4b
--- /dev/null
+++ b/package/boot/yamonenv/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,39 @@
+#
+# Copyright (C) 2006 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=yamonenv
+PKG_VERSION:=20051022
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)_gruen.4g__$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://downloads.openwrt.org/sources/
+PKG_MD5SUM:=a3e4f24155aa3ba5aa502bc63fdaa6ad
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/yamonenv
+ SECTION:=utils
+ CATEGORY:=Utilities
+ DEPENDS:=@TARGET_au1000
+ TITLE:=YAMON configuration utility
+ URL:=http://meshcube.org/nylon/stable/sources/
+ MAINTAINER:=Florian Fainelli <florian@openwrt.org>
+endef
+
+define Build/Configure
+endef
+
+define Package/yamonenv/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(CP) $(PKG_BUILD_DIR)/src/$(PKG_NAME) $(1)/usr/sbin/
+endef
+
+$(eval $(call BuildPackage,yamonenv))
diff --git a/package/boot/yamonenv/Makefile b/package/boot/yamonenv/Makefile
new file mode 100644
index 0000000..e1d2a4b
--- /dev/null
+++ b/package/boot/yamonenv/Makefile
@@ -0,0 +1,39 @@
+#
+# Copyright (C) 2006 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=yamonenv
+PKG_VERSION:=20051022
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)_gruen.4g__$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://downloads.openwrt.org/sources/
+PKG_MD5SUM:=a3e4f24155aa3ba5aa502bc63fdaa6ad
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/yamonenv
+ SECTION:=utils
+ CATEGORY:=Utilities
+ DEPENDS:=@TARGET_au1000
+ TITLE:=YAMON configuration utility
+ URL:=http://meshcube.org/nylon/stable/sources/
+ MAINTAINER:=Florian Fainelli <florian@openwrt.org>
+endef
+
+define Build/Configure
+endef
+
+define Package/yamonenv/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(CP) $(PKG_BUILD_DIR)/src/$(PKG_NAME) $(1)/usr/sbin/
+endef
+
+$(eval $(call BuildPackage,yamonenv))
diff --git a/package/boot/yamonenv/patches/.svn/entries b/package/boot/yamonenv/patches/.svn/entries
new file mode 100644
index 0000000..fe61910
--- /dev/null
+++ b/package/boot/yamonenv/patches/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/boot/yamonenv/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+001-yamonenv_mtd_partition.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+a53d173ddfcc4d3ff0b51638431afcff
+2012-10-16T13:44:25.630275Z
+33781
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+230
+
diff --git a/package/boot/yamonenv/patches/.svn/text-base/001-yamonenv_mtd_partition.patch.svn-base b/package/boot/yamonenv/patches/.svn/text-base/001-yamonenv_mtd_partition.patch.svn-base
new file mode 100644
index 0000000..e1def28
--- /dev/null
+++ b/package/boot/yamonenv/patches/.svn/text-base/001-yamonenv_mtd_partition.patch.svn-base
@@ -0,0 +1,11 @@
+--- a/src/yamonenv.c
++++ b/src/yamonenv.c
+@@ -12,7 +12,7 @@
+ #include <fcntl.h>
+ #include <unistd.h>
+
+-#define DEFAULT_YAMON_ENV_FILE "/dev/mtd/3"
++#define DEFAULT_YAMON_ENV_FILE "/dev/mtd3"
+
+
+ // control byte definitions:
diff --git a/package/boot/yamonenv/patches/001-yamonenv_mtd_partition.patch b/package/boot/yamonenv/patches/001-yamonenv_mtd_partition.patch
new file mode 100644
index 0000000..e1def28
--- /dev/null
+++ b/package/boot/yamonenv/patches/001-yamonenv_mtd_partition.patch
@@ -0,0 +1,11 @@
+--- a/src/yamonenv.c
++++ b/src/yamonenv.c
+@@ -12,7 +12,7 @@
+ #include <fcntl.h>
+ #include <unistd.h>
+
+-#define DEFAULT_YAMON_ENV_FILE "/dev/mtd/3"
++#define DEFAULT_YAMON_ENV_FILE "/dev/mtd3"
+
+
+ // control byte definitions:
diff --git a/package/broadcom-diag/.svn/entries b/package/broadcom-diag/.svn/entries
new file mode 100644
index 0000000..d3414c3
--- /dev/null
+++ b/package/broadcom-diag/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/broadcom-diag
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-02-24T17:57:28.229101Z
+35766
+hauke
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+src
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+533f83be645bf87d43bc7e908efa7d86
+2010-09-13T01:35:39.952214Z
+23043
+jow
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+774
+
diff --git a/package/broadcom-diag/.svn/prop-base/Makefile.svn-base b/package/broadcom-diag/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..8e522ae
--- /dev/null
+++ b/package/broadcom-diag/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:copyright
+V 30
+Copyright (C) 2006 OpenWrt.org
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/broadcom-diag/.svn/text-base/Makefile.svn-base b/package/broadcom-diag/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..61b3529
--- /dev/null
+++ b/package/broadcom-diag/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,37 @@
+#
+# Copyright (C) 2006-2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=broadcom-diag
+PKG_RELEASE:=10
+
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/diag
+ SUBMENU:=Other modules
+ DEPENDS:=@TARGET_brcm47xx
+ TITLE:=Driver for router LEDs and Buttons
+ FILES:=$(PKG_BUILD_DIR)/diag.ko
+endef
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+define Build/Compile
+ $(MAKE) -C "$(LINUX_DIR)" \
+ CROSS_COMPILE="$(TARGET_CROSS)" \
+ ARCH="$(LINUX_KARCH)" \
+ SUBDIRS="$(PKG_BUILD_DIR)" \
+ EXTRA_CFLAGS="$(BUILDFLAGS)" \
+ modules
+endef
+
+$(eval $(call KernelPackage,diag))
diff --git a/package/broadcom-diag/Makefile b/package/broadcom-diag/Makefile
new file mode 100644
index 0000000..61b3529
--- /dev/null
+++ b/package/broadcom-diag/Makefile
@@ -0,0 +1,37 @@
+#
+# Copyright (C) 2006-2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=broadcom-diag
+PKG_RELEASE:=10
+
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/diag
+ SUBMENU:=Other modules
+ DEPENDS:=@TARGET_brcm47xx
+ TITLE:=Driver for router LEDs and Buttons
+ FILES:=$(PKG_BUILD_DIR)/diag.ko
+endef
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+define Build/Compile
+ $(MAKE) -C "$(LINUX_DIR)" \
+ CROSS_COMPILE="$(TARGET_CROSS)" \
+ ARCH="$(LINUX_KARCH)" \
+ SUBDIRS="$(PKG_BUILD_DIR)" \
+ EXTRA_CFLAGS="$(BUILDFLAGS)" \
+ modules
+endef
+
+$(eval $(call KernelPackage,diag))
diff --git a/package/broadcom-diag/src/.svn/entries b/package/broadcom-diag/src/.svn/entries
new file mode 100644
index 0000000..6c3af80
--- /dev/null
+++ b/package/broadcom-diag/src/.svn/entries
@@ -0,0 +1,164 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/broadcom-diag/src
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-02-24T17:57:28.229101Z
+35766
+hauke
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+gpio.h
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+00f19f107d410fe80d3fce4d13a2985e
+2012-08-04T19:46:25.622889Z
+32992
+hauke
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+371
+
+diag.c
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+1f0a550a9bde6f3b607c8cb3300d2c5b
+2013-02-24T17:57:28.229101Z
+35766
+hauke
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+47698
+
+diag.h
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+f23f8e323987a8fa5392aa485d5e4490
+2010-10-05T14:15:46.634832Z
+23245
+kaloz
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3028
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+7c742d0b7a897316adc32d27d0776d0a
+2009-04-17T14:09:46.037367Z
+15242
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+418
+
diff --git a/package/broadcom-diag/src/.svn/prop-base/Makefile.svn-base b/package/broadcom-diag/src/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/broadcom-diag/src/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/broadcom-diag/src/.svn/prop-base/diag.c.svn-base b/package/broadcom-diag/src/.svn/prop-base/diag.c.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/broadcom-diag/src/.svn/prop-base/diag.c.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/broadcom-diag/src/.svn/prop-base/diag.h.svn-base b/package/broadcom-diag/src/.svn/prop-base/diag.h.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/broadcom-diag/src/.svn/prop-base/diag.h.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/broadcom-diag/src/.svn/prop-base/gpio.h.svn-base b/package/broadcom-diag/src/.svn/prop-base/gpio.h.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/broadcom-diag/src/.svn/prop-base/gpio.h.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/broadcom-diag/src/.svn/text-base/Makefile.svn-base b/package/broadcom-diag/src/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..44c80a8
--- /dev/null
+++ b/package/broadcom-diag/src/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,17 @@
+#
+# Makefile for diag driver
+#
+# Copyright (C) 2005 Felix Fietkau <nbd@openwrt.org>
+#
+# 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 of the License, or (at your option) any later version.
+#
+
+obj-m := diag.o
+
+ifeq ($(MAKING_MODULES),1)
+
+-include $(TOPDIR)/Rules.make
+endif
diff --git a/package/broadcom-diag/src/.svn/text-base/diag.c.svn-base b/package/broadcom-diag/src/.svn/text-base/diag.c.svn-base
new file mode 100644
index 0000000..168f81d
--- /dev/null
+++ b/package/broadcom-diag/src/.svn/text-base/diag.c.svn-base
@@ -0,0 +1,1723 @@
+/*
+ * diag.c - GPIO interface driver for Broadcom boards
+ *
+ * Copyright (C) 2006 Mike Baker <mbm@openwrt.org>,
+ * Copyright (C) 2006-2007 Felix Fietkau <nbd@openwrt.org>
+ * Copyright (C) 2008 Andy Boyett <agb@openwrt.org>
+ *
+ * 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
+ * of the License, 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+#include <linux/module.h>
+#include <linux/pci.h>
+#include <linux/kmod.h>
+#include <linux/proc_fs.h>
+#include <linux/timer.h>
+#include <linux/version.h>
+#include <asm/uaccess.h>
+#include <linux/workqueue.h>
+#include <linux/skbuff.h>
+#include <linux/netlink.h>
+#include <linux/kobject.h>
+#include <net/sock.h>
+#include <bcm47xx_board.h>
+extern u64 uevent_next_seqnum(void);
+
+#include "gpio.h"
+#include "diag.h"
+#define getvar(str) (nvram_get(str)?:"")
+
+static inline int startswith (char *source, char *cmp) { return !strncmp(source,cmp,strlen(cmp)); }
+static int fill_event(struct event_t *);
+static unsigned int gpiomask = 0;
+module_param(gpiomask, int, 0644);
+
+enum {
+ /* Linksys */
+ WAP54GV1,
+ WAP54GV2,
+ WAP54GV3,
+ WRT54GV1,
+ WRT54G,
+ WRTSL54GS,
+ WRT54G3G,
+ WRT54G3GV2_VF,
+ WRT150NV1,
+ WRT150NV11,
+ WRT160NV1,
+ WRT160NV3,
+ WRT300NV11,
+ WRT350N,
+ WRT600N,
+ WRT600NV11,
+ WRT610N,
+ WRT610NV2,
+ E1000V1,
+ E3000V1,
+ E3200V1,
+
+ /* ASUS */
+ WLHDD,
+ WL300G,
+ WL320GE,
+ WL330GE,
+ WL500G,
+ WL500GD,
+ WL500GP,
+ WL500GPV2,
+ WL500W,
+ WL520GC,
+ WL520GU,
+ ASUS_4702,
+ WL700GE,
+ RTN16,
+
+ /* Buffalo */
+ WBR2_G54,
+ WHR_G54S,
+ WHR_HP_G54,
+ WHR_G125,
+ WHR2_A54G54,
+ WLA2_G54L,
+ WZR_G300N,
+ WZR_RS_G54,
+ WZR_RS_G54HP,
+ BUFFALO_UNKNOWN,
+ BUFFALO_UNKNOWN_4710,
+
+ /* Siemens */
+ SE505V1,
+ SE505V2,
+
+ /* US Robotics */
+ USR5461,
+
+ /* Dell */
+ TM2300,
+ TM2300V2,
+
+ /* Motorola */
+ WE800G,
+ WR850GV1,
+ WR850GV2V3,
+ WR850GP,
+
+ /* Belkin */
+ BELKIN_UNKNOWN,
+ BELKIN_F7D4301,
+
+ /* Netgear */
+ WGT634U,
+ WNR834BV1,
+ WNR834BV2,
+ WNDR3400V1,
+
+ /* Trendware */
+ TEW411BRPP,
+
+ /* SimpleTech */
+ STI_NAS,
+
+ /* D-Link */
+ DIR130,
+ DIR320,
+ DIR330,
+ DWL3150,
+
+ /* Sitecom */
+ WL105B,
+
+ /* Western Digital */
+ WDNetCenter,
+
+ /* Askey */
+ RT210W,
+
+ /* OvisLink */
+ WL1600GL,
+
+ /* Microsoft */
+ MN700,
+
+ /* Edimax */
+ PS1208MFG,
+};
+
+static void __init bcm4780_init(void) {
+ int pin = 1 << 3;
+
+ /* Enables GPIO 3 that controls HDD and led power on ASUS WL-700gE */
+ printk(MODULE_NAME ": Spinning up HDD and enabling leds\n");
+ bcm47xx_gpio_outen(pin, pin);
+ bcm47xx_gpio_control(pin, 0);
+ bcm47xx_gpio_out(pin, pin);
+
+ /* Wait 5s, so the HDD can spin up */
+ set_current_state(TASK_INTERRUPTIBLE);
+ schedule_timeout(HZ * 5);
+}
+
+static void __init NetCenter_init(void) {
+ /* unset pin 6 (+12V) */
+ int pin = 1 << 6;
+ bcm47xx_gpio_outen(pin, pin);
+ bcm47xx_gpio_control(pin, 0);
+ bcm47xx_gpio_out(pin, pin);
+ /* unset pin 1 (turn off red led, blue will light alone if +5V comes up) */
+ pin = 1 << 1;
+ bcm47xx_gpio_outen(pin, pin);
+ bcm47xx_gpio_control(pin, 0);
+ bcm47xx_gpio_out(pin, pin);
+ /* unset pin 3 (+5V) and wait 5 seconds (harddisk spin up) */
+ bcm4780_init();
+}
+
+static void __init bcm57xx_init(void) {
+ int pin = 1 << 2;
+
+ /* FIXME: switch comes up, but port mappings/vlans not right */
+ bcm47xx_gpio_outen(pin, pin);
+ bcm47xx_gpio_control(pin, 0);
+ bcm47xx_gpio_out(pin, pin);
+}
+
+static struct platform_t __initdata platforms[] = {
+ /* Linksys */
+ [WAP54GV1] = {
+ .name = "Linksys WAP54G V1",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 0 },
+ },
+ .leds = {
+ { .name = "diag", .gpio = 1 << 3 },
+ { .name = "wlan", .gpio = 1 << 4 },
+ },
+ },
+ [WAP54GV2] = {
+ .name = "Linksys WAP54G V2",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 0 },
+ },
+ .leds = {
+ { .name = "wlan", .gpio = 1 << 5, .polarity = REVERSE },
+ /* GPIO 6 is b44 (eth0, LAN) PHY power */
+ },
+ },
+ [WAP54GV3] = {
+ .name = "Linksys WAP54G V3",
+ .buttons = {
+ /* FIXME: verify this */
+ { .name = "reset", .gpio = 1 << 7 },
+ { .name = "ses", .gpio = 1 << 0 },
+ },
+ .leds = {
+ /* FIXME: diag? */
+ { .name = "ses", .gpio = 1 << 1 },
+ },
+ },
+ [WRT54GV1] = {
+ .name = "Linksys WRT54G V1.x",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 6 },
+ },
+ .leds = {
+ { .name = "diag", .gpio = 0x13 | GPIO_TYPE_EXTIF, .polarity = NORMAL },
+ { .name = "dmz", .gpio = 0x12 | GPIO_TYPE_EXTIF, .polarity = NORMAL },
+ },
+ },
+ [WRT54G] = {
+ .name = "Linksys WRT54G/GS/GL",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 6 },
+ { .name = "ses", .gpio = 1 << 4 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 1, .polarity = NORMAL },
+ { .name = "dmz", .gpio = 1 << 7, .polarity = REVERSE },
+ { .name = "ses_white", .gpio = 1 << 2, .polarity = REVERSE },
+ { .name = "ses_orange", .gpio = 1 << 3, .polarity = REVERSE },
+ { .name = "wlan", .gpio = 1 << 0, .polarity = REVERSE },
+ },
+ },
+ [WRTSL54GS] = {
+ .name = "Linksys WRTSL54GS",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 6 },
+ { .name = "ses", .gpio = 1 << 4 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 1, .polarity = NORMAL },
+ { .name = "dmz", .gpio = 1 << 0, .polarity = REVERSE },
+ { .name = "ses_white", .gpio = 1 << 5, .polarity = REVERSE },
+ { .name = "ses_orange", .gpio = 1 << 7, .polarity = REVERSE },
+ },
+ },
+ [WRT54G3G] = {
+ .name = "Linksys WRT54G3G",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 6 },
+ { .name = "3g", .gpio = 1 << 4 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 1, .polarity = NORMAL },
+ { .name = "dmz", .gpio = 1 << 7, .polarity = REVERSE },
+ { .name = "3g_green", .gpio = 1 << 2, .polarity = NORMAL },
+ { .name = "3g_blue", .gpio = 1 << 3, .polarity = NORMAL },
+ { .name = "3g_blink", .gpio = 1 << 5, .polarity = NORMAL },
+ },
+ },
+ [WRT54G3GV2_VF] = {
+ .name = "Linksys WRT54G3GV2-VF",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 6 },
+ { .name = "3g", .gpio = 1 << 5 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 1, .polarity = NORMAL },
+ { .name = "3g_green", .gpio = 1 << 2, .polarity = NORMAL },
+ { .name = "3g_blue", .gpio = 1 << 3, .polarity = NORMAL },
+ },
+ },
+ [WRT150NV1] = {
+ .name = "Linksys WRT150N V1",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 6 },
+ { .name = "ses", .gpio = 1 << 4 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 1, .polarity = NORMAL },
+ { .name = "ses_green", .gpio = 1 << 5, .polarity = REVERSE },
+ { .name = "ses_amber", .gpio = 1 << 3, .polarity = REVERSE },
+ },
+ },
+ [WRT150NV11] = {
+ .name = "Linksys WRT150N V1.1",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 6 },
+ { .name = "ses", .gpio = 1 << 4 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 1, .polarity = NORMAL },
+ { .name = "ses_green", .gpio = 1 << 5, .polarity = REVERSE },
+ { .name = "ses_amber", .gpio = 1 << 3, .polarity = REVERSE },
+ },
+ },
+ [WRT160NV1] = {
+ .name = "Linksys WRT160N v1.x",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 6 },
+ { .name = "ses", .gpio = 1 << 4 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 1, .polarity = NORMAL },
+ { .name = "ses_blue", .gpio = 1 << 5, .polarity = REVERSE },
+ { .name = "ses_orange", .gpio = 1 << 3, .polarity = REVERSE },
+ },
+ },
+ [WRT160NV3] = {
+ .name = "Linksys WRT160N V3",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 6 },
+ { .name = "ses", .gpio = 1 << 5 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 1, .polarity = NORMAL },
+ { .name = "ses_blue", .gpio = 1 << 4, .polarity = REVERSE },
+ { .name = "ses_orange", .gpio = 1 << 2, .polarity = REVERSE },
+ },
+ },
+ [WRT300NV11] = {
+ .name = "Linksys WRT300N V1.1",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 6 }, // "Reset" on back panel
+ { .name = "ses", .gpio = 1 << 4 }, // "Reserved" on top panel
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 1, .polarity = NORMAL }, // "Power"
+ { .name = "ses_amber", .gpio = 1 << 3, .polarity = REVERSE }, // "Security" Amber
+ { .name = "ses_green", .gpio = 1 << 5, .polarity = REVERSE }, // "Security" Green
+ },
+ .platform_init = bcm57xx_init,
+ },
+ [WRT350N] = {
+ .name = "Linksys WRT350N",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 6 },
+ { .name = "ses", .gpio = 1 << 8 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 1, .polarity = NORMAL },
+ { .name = "ses_amber", .gpio = 1 << 3, .polarity = REVERSE },
+ { .name = "ses_green", .gpio = 1 << 9, .polarity = REVERSE },
+ { .name = "usb_blink", .gpio = 1 << 10, .polarity = REVERSE },
+ { .name = "usb", .gpio = 1 << 11, .polarity = REVERSE },
+ },
+ .platform_init = bcm57xx_init,
+ },
+ [WRT600N] = {
+ .name = "Linksys WRT600N",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 6 },
+ { .name = "ses", .gpio = 1 << 7 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 2, .polarity = REVERSE }, // Power LED
+ { .name = "usb", .gpio = 1 << 3, .polarity = REVERSE }, // USB LED
+ { .name = "wl0_ses_amber", .gpio = 1 << 8, .polarity = REVERSE }, // 2.4Ghz LED Amber
+ { .name = "wl0_ses_green", .gpio = 1 << 9, .polarity = REVERSE }, // 2.4Ghz LED Green
+ { .name = "wl1_ses_amber", .gpio = 1 << 10, .polarity = REVERSE }, // 5.6Ghz LED Amber
+ { .name = "wl1_ses_green", .gpio = 1 << 11, .polarity = REVERSE }, // 5.6Ghz LED Green
+ },
+ .platform_init = bcm57xx_init,
+ },
+ [WRT600NV11] = {
+ .name = "Linksys WRT600N V1.1",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 6 },
+ { .name = "ses", .gpio = 1 << 7 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 2, .polarity = REVERSE }, // Power LED
+ { .name = "usb", .gpio = 1 << 3, .polarity = REVERSE }, // USB LED
+ { .name = "wl0_ses_amber", .gpio = 1 << 8, .polarity = REVERSE }, // 2.4Ghz LED Amber
+ { .name = "wl0_ses_green", .gpio = 1 << 9, .polarity = REVERSE }, // 2.4Ghz LED Green
+ { .name = "wl1_ses_amber", .gpio = 1 << 10, .polarity = REVERSE }, // 5.6Ghz LED Amber
+ { .name = "wl1_ses_green", .gpio = 1 << 11, .polarity = REVERSE }, // 5.6Ghz LED Green
+ },
+ .platform_init = bcm57xx_init,
+ },
+ [WRT610N] = {
+ .name = "Linksys WRT610N",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 6 },
+ { .name = "ses", .gpio = 1 << 8 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 1, .polarity = NORMAL }, // Power LED
+ { .name = "usb", .gpio = 1 << 0, .polarity = REVERSE }, // USB LED
+ { .name = "ses_amber", .gpio = 1 << 3, .polarity = REVERSE }, // WiFi protected setup LED amber
+ { .name = "ses_blue", .gpio = 1 << 9, .polarity = REVERSE }, // WiFi protected setup LED blue
+ },
+ },
+ [WRT610NV2] = {
+ .name = "Linksys WRT610N V2",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 6 },
+ { .name = "ses", .gpio = 1 << 4 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 5, .polarity = NORMAL }, // Power LED
+ { .name = "usb", .gpio = 1 << 7, .polarity = NORMAL }, // USB LED
+ { .name = "ses_amber", .gpio = 1 << 0, .polarity = REVERSE }, // WiFi protected setup LED amber
+ { .name = "ses_blue", .gpio = 1 << 3, .polarity = REVERSE }, // WiFi protected setup LED blue
+ { .name = "wlan", .gpio = 1 << 1, .polarity = NORMAL }, // Wireless LED
+ },
+ },
+ /* same hardware as WRT160NV3 and Cisco Valet M10V1, but different board detection, combine? */
+ [E1000V1] = {
+ .name = "Linksys E1000 V1",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 6 },
+ { .name = "wps", .gpio = 1 << 5 }, /* nvram get gpio5=wps_button */
+ },
+ .leds = {
+ /** turns on leds for all ethernet ports (wan too)
+ * this also disconnects some, or maybe all, ethernet ports
+ * 1: leds work normally
+ * 0: all lit all the time */
+ /* nvram get gpio3=robo_reset */
+ { .name = "wlan", .gpio = 1 << 0, .polarity = NORMAL },
+ { .name = "power", .gpio = 1 << 1, .polarity = NORMAL },
+ { .name = "ses_blue", .gpio = 1 << 4, .polarity = REVERSE }, /* nvram get gpio4=wps_led */
+ { .name = "ses_orange", .gpio = 1 << 2, .polarity = REVERSE }, /* nvram get gpio2=wps_status_led */
+ },
+ },
+ [E3000V1] = {
+ .name = "Linksys E3000 V1",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 6 },
+ { .name = "ses", .gpio = 1 << 4 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 5, .polarity = NORMAL }, // Power LED
+ { .name = "usb", .gpio = 1 << 7, .polarity = NORMAL }, // USB LED
+ { .name = "ses_amber", .gpio = 1 << 0, .polarity = REVERSE }, // WiFi protected setup LED amber
+ { .name = "ses_blue", .gpio = 1 << 3, .polarity = REVERSE }, // WiFi protected setup LED blue
+ { .name = "wlan", .gpio = 1 << 1, .polarity = NORMAL }, // Wireless LED
+ },
+ },
+ [E3200V1] = {
+ .name = "Linksys E3200 V1",
+ .buttons = {
+ /* { .name = "switch", .gpio = 1 << 4 },*/ /* nvram get gpio4=robo_reset */
+ { .name = "reset", .gpio = 1 << 5 }, /* nvram get reset_gpio=5 */
+ { .name = "wps", .gpio = 1 << 8 }, /* nvram get gpio8=wps_button */
+ /* { .name = "wombo", .gpio = 1 << 23 },*/ /* nvram get gpio23=wombo_reset - wireless on motherboard */
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 3, .polarity = REVERSE }, /* Power LED */
+ },
+ },
+ /* Asus */
+ [WLHDD] = {
+ .name = "ASUS WL-HDD",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 6 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 0, .polarity = REVERSE },
+ { .name = "usb", .gpio = 1 << 2, .polarity = REVERSE },
+ },
+ },
+ [WL300G] = {
+ .name = "ASUS WL-300g",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 6 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 0, .polarity = REVERSE },
+ },
+ },
+ [WL320GE] = {
+ .name = "ASUS WL-320gE/WL-320gP",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 6 },
+ },
+ .leds = {
+ { .name = "wlan", .gpio = 1 << 0, .polarity = REVERSE },
+ { .name = "power", .gpio = 1 << 2, .polarity = REVERSE },
+ { .name = "link", .gpio = 1 << 11, .polarity = REVERSE },
+ },
+ },
+ [WL330GE] = {
+ .name = "ASUS WL-330gE",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 2 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 0, .polarity = REVERSE },
+ },
+ },
+ [WL500G] = {
+ .name = "ASUS WL-500g",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 6 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 0, .polarity = REVERSE },
+ },
+ },
+ [WL500GD] = {
+ .name = "ASUS WL-500g Deluxe",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 6 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 0, .polarity = REVERSE },
+ },
+ },
+ [WL500GP] = {
+ .name = "ASUS WL-500g Premium",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 0 },
+ { .name = "ses", .gpio = 1 << 4 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 1, .polarity = REVERSE },
+ },
+ },
+ [WL500GPV2] = {
+ .name = "ASUS WL-500g Premium V2",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 2 },
+ { .name = "ses", .gpio = 1 << 3 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 0, .polarity = REVERSE },
+ { .name = "wlan", .gpio = 1 << 1, .polarity = REVERSE },
+ },
+ },
+ [WL500W] = {
+ .name = "ASUS WL-500W",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 6 },
+ { .name = "ses", .gpio = 1 << 7 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 5, .polarity = REVERSE },
+ },
+ },
+ [WL520GC] = {
+ .name = "ASUS WL-520GC",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 2 },
+ { .name = "ses", .gpio = 1 << 3 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 0, .polarity = REVERSE },
+ { .name = "wlan", .gpio = 1 << 1, .polarity = REVERSE },
+ },
+ },
+ [WL520GU] = {
+ .name = "ASUS WL-520gU",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 2 },
+ { .name = "ses", .gpio = 1 << 3 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 0, .polarity = REVERSE },
+ { .name = "wlan", .gpio = 1 << 1, .polarity = REVERSE },
+ },
+ },
+ [ASUS_4702] = {
+ .name = "ASUS (unknown, BCM4702)",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 6 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 0, .polarity = REVERSE },
+ },
+ },
+ [WL700GE] = {
+ .name = "ASUS WL-700gE",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 7 }, // on back, hardwired, always resets device regardless OS state
+ { .name = "ses", .gpio = 1 << 4 }, // on back, actual name ezsetup
+ { .name = "power", .gpio = 1 << 0 }, // on front
+ { .name = "copy", .gpio = 1 << 6 }, // on front
+ },
+ .leds = {
+#if 0
+ // GPIO that controls power led also enables/disables some essential functions
+ // - power to HDD
+ // - switch leds
+ { .name = "power", .gpio = 1 << 3, .polarity = NORMAL }, // actual name power
+#endif
+ { .name = "diag", .gpio = 1 << 1, .polarity = REVERSE }, // actual name ready
+ },
+ .platform_init = bcm4780_init,
+ },
+ [RTN16] = {
+ .name = "ASUS RT-N16",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 8 },
+ { .name = "ses", .gpio = 1 << 5 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 1, .polarity = REVERSE },
+ { .name = "wlan", .gpio = 1 << 7, .polarity = NORMAL },
+ },
+ },
+ /* Buffalo */
+ [WHR_G54S] = {
+ .name = "Buffalo WHR-G54S",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 4 },
+ { .name = "bridge", .gpio = 1 << 5 },
+ { .name = "ses", .gpio = 1 << 0 },
+ },
+ .leds = {
+ { .name = "diag", .gpio = 1 << 7, .polarity = REVERSE },
+ { .name = "internal", .gpio = 1 << 3, .polarity = REVERSE },
+ { .name = "ses", .gpio = 1 << 6, .polarity = REVERSE },
+ { .name = "bridge", .gpio = 1 << 1, .polarity = REVERSE },
+ { .name = "wlan", .gpio = 1 << 2, .polarity = REVERSE },
+ },
+ },
+ [WBR2_G54] = {
+ .name = "Buffalo WBR2-G54",
+ /* FIXME: verify */
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 7 },
+ },
+ .leds = {
+ { .name = "diag", .gpio = 1 << 1, .polarity = REVERSE },
+ },
+ },
+ [WHR_HP_G54] = {
+ .name = "Buffalo WHR-HP-G54",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 4 },
+ { .name = "bridge", .gpio = 1 << 5 },
+ { .name = "ses", .gpio = 1 << 0 },
+ },
+ .leds = {
+ { .name = "diag", .gpio = 1 << 7, .polarity = REVERSE },
+ { .name = "internal", .gpio = 1 << 3, .polarity = REVERSE },
+ { .name = "bridge", .gpio = 1 << 1, .polarity = REVERSE },
+ { .name = "ses", .gpio = 1 << 6, .polarity = REVERSE },
+ { .name = "wlan", .gpio = 1 << 2, .polarity = REVERSE },
+ },
+ },
+ [WHR_G125] = {
+ .name = "Buffalo WHR-G125",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 4 },
+ { .name = "bridge", .gpio = 1 << 5 },
+ { .name = "ses", .gpio = 1 << 0 },
+ },
+ .leds = {
+ { .name = "diag", .gpio = 1 << 7, .polarity = REVERSE },
+ { .name = "internal", .gpio = 1 << 3, .polarity = REVERSE },
+ { .name = "bridge", .gpio = 1 << 1, .polarity = REVERSE },
+ { .name = "ses", .gpio = 1 << 6, .polarity = REVERSE },
+ { .name = "wlan", .gpio = 1 << 2, .polarity = REVERSE },
+ },
+ },
+ [WHR2_A54G54] = {
+ .name = "Buffalo WHR2-A54G54",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 4 },
+ },
+ .leds = {
+ { .name = "diag", .gpio = 1 << 7, .polarity = REVERSE },
+ },
+ },
+ [WLA2_G54L] = {
+ .name = "Buffalo WLA2-G54L",
+ /* FIXME: verify */
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 7 },
+ },
+ .leds = {
+ { .name = "diag", .gpio = 1 << 1, .polarity = REVERSE },
+ },
+ },
+ [WZR_G300N] = {
+ .name = "Buffalo WZR-G300N",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 4 },
+ },
+ .leds = {
+ { .name = "diag", .gpio = 1 << 7, .polarity = REVERSE },
+ { .name = "bridge", .gpio = 1 << 1, .polarity = REVERSE },
+ { .name = "ses", .gpio = 1 << 6, .polarity = REVERSE },
+ },
+ },
+ [WZR_RS_G54] = {
+ .name = "Buffalo WZR-RS-G54",
+ .buttons = {
+ { .name = "ses", .gpio = 1 << 0 },
+ { .name = "reset", .gpio = 1 << 4 },
+ },
+ .leds = {
+ { .name = "diag", .gpio = 1 << 7, .polarity = REVERSE },
+ { .name = "ses", .gpio = 1 << 6, .polarity = REVERSE },
+ { .name = "vpn", .gpio = 1 << 1, .polarity = REVERSE },
+ },
+ },
+ [WZR_RS_G54HP] = {
+ .name = "Buffalo WZR-RS-G54HP",
+ .buttons = {
+ { .name = "ses", .gpio = 1 << 0 },
+ { .name = "reset", .gpio = 1 << 4 },
+ },
+ .leds = {
+ { .name = "diag", .gpio = 1 << 7, .polarity = REVERSE },
+ { .name = "ses", .gpio = 1 << 6, .polarity = REVERSE },
+ { .name = "vpn", .gpio = 1 << 1, .polarity = REVERSE },
+ },
+ },
+ [BUFFALO_UNKNOWN] = {
+ .name = "Buffalo (unknown)",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 7 },
+ },
+ .leds = {
+ { .name = "diag", .gpio = 1 << 1, .polarity = REVERSE },
+ },
+ },
+ [BUFFALO_UNKNOWN_4710] = {
+ .name = "Buffalo (unknown, BCM4710)",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 4 },
+ },
+ .leds = {
+ { .name = "diag", .gpio = 1 << 1, .polarity = REVERSE },
+ },
+ },
+ /* Siemens */
+ [SE505V1] = {
+ .name = "Siemens SE505 V1",
+ .buttons = {
+ /* No usable buttons */
+ },
+ .leds = {
+// { .name = "power", .gpio = 1 << 0 .polarity = REVERSE }, // Usable when retrofitting D26 (?)
+ { .name = "dmz", .gpio = 1 << 4, .polarity = REVERSE }, // actual name WWW
+ { .name = "wlan", .gpio = 1 << 3, .polarity = REVERSE },
+ },
+ },
+ [SE505V2] = {
+ .name = "Siemens SE505 V2",
+ .buttons = {
+ /* No usable buttons */
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 5, .polarity = REVERSE },
+ { .name = "dmz", .gpio = 1 << 0, .polarity = REVERSE }, // actual name WWW
+ { .name = "wlan", .gpio = 1 << 3, .polarity = REVERSE },
+ },
+ },
+ /* US Robotics */
+ [USR5461] = {
+ .name = "U.S. Robotics USR5461",
+ .buttons = {
+ /* No usable buttons */
+ },
+ .leds = {
+ { .name = "wlan", .gpio = 1 << 0, .polarity = REVERSE },
+ { .name = "printer", .gpio = 1 << 1, .polarity = REVERSE },
+ },
+ },
+ /* Dell */
+ [TM2300] = {
+ .name = "Dell TrueMobile 2300",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 0 },
+ },
+ .leds = {
+ { .name = "wlan", .gpio = 1 << 6, .polarity = REVERSE },
+ { .name = "power", .gpio = 1 << 7, .polarity = REVERSE },
+ },
+ },
+ [TM2300V2] = {
+ .name = "Dell TrueMobile 2300 v2",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 0 },
+ },
+ .leds = {
+ { .name = "wlan", .gpio = 1 << 6, .polarity = REVERSE },
+ { .name = "power", .gpio = 1 << 7, .polarity = REVERSE },
+ },
+ },
+ /* Motorola */
+ [WE800G] = {
+ .name = "Motorola WE800G",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 0 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 4, .polarity = NORMAL },
+ { .name = "diag", .gpio = 1 << 2, .polarity = REVERSE },
+ { .name = "wlan_amber", .gpio = 1 << 1, .polarity = NORMAL },
+ },
+ },
+ [WR850GV1] = {
+ .name = "Motorola WR850G V1",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 0 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 4, .polarity = NORMAL },
+ { .name = "diag", .gpio = 1 << 3, .polarity = REVERSE },
+ { .name = "dmz", .gpio = 1 << 6, .polarity = NORMAL },
+ { .name = "wlan_red", .gpio = 1 << 5, .polarity = REVERSE },
+ { .name = "wlan_green", .gpio = 1 << 7, .polarity = REVERSE },
+ },
+ },
+ [WR850GV2V3] = {
+ .name = "Motorola WR850G V2/V3",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 5 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 1, .polarity = NORMAL },
+ { .name = "wlan", .gpio = 1 << 0, .polarity = REVERSE },
+ { .name = "wan", .gpio = 1 << 6, .polarity = INPUT },
+ { .name = "diag", .gpio = 1 << 7, .polarity = REVERSE },
+ },
+ },
+ [WR850GP] = {
+ .name = "Motorola WR850GP",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 5 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 1, .polarity = NORMAL },
+ { .name = "wlan", .gpio = 1 << 0, .polarity = REVERSE },
+ { .name = "dmz", .gpio = 1 << 6, .polarity = REVERSE },
+ { .name = "diag", .gpio = 1 << 7, .polarity = REVERSE },
+ },
+ },
+
+ /* Belkin */
+ [BELKIN_UNKNOWN] = {
+ .name = "Belkin (unknown)",
+ /* FIXME: verify & add detection */
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 7 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 5, .polarity = NORMAL },
+ { .name = "wlan", .gpio = 1 << 3, .polarity = NORMAL },
+ { .name = "connected", .gpio = 1 << 0, .polarity = NORMAL },
+ },
+ },
+ [BELKIN_F7D4301] = {
+ .name = "Belkin PlayMax F7D4301",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 6 },
+ { .name = "wps", .gpio = 1 << 8 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 11, .polarity = REVERSE },
+ { .name = "wlan", .gpio = 1 << 13, .polarity = REVERSE },
+ { .name = "led0", .gpio = 1 << 14, .polarity = REVERSE },
+ { .name = "led1", .gpio = 1 << 15, .polarity = REVERSE },
+ },
+ },
+ /* Netgear */
+ [WGT634U] = {
+ .name = "Netgear WGT634U",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 2 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 3, .polarity = NORMAL },
+ },
+ },
+ /* Netgear */
+ [WNR834BV1] = {
+ .name = "Netgear WNR834B V1",
+ .buttons = { /* TODO: add reset button and confirm LEDs - GPIO from dd-wrt */ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 4, .polarity = REVERSE },
+ { .name = "diag", .gpio = 1 << 5, .polarity = REVERSE },
+ { .name = "wlan", .gpio = 1 << 6, .polarity = REVERSE },
+ },
+ },
+ /* Netgear */
+ [WNR834BV2] = {
+ .name = "Netgear WNR834B V2",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 6 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 2, .polarity = NORMAL },
+ { .name = "diag", .gpio = 1 << 3, .polarity = NORMAL },
+ { .name = "connected", .gpio = 1 << 7, .polarity = NORMAL },
+ },
+ },
+ [WNDR3400V1] = {
+ .name = "Netgear WNDR3400 V1",
+ .buttons = {
+ /* nvram get gpio5=robo_reset */
+ { .name = "reset", .gpio = 1 << 4 },
+ { .name = "wps", .gpio = 1 << 6 },
+ { .name = "wlan", .gpio = 1 << 8 },
+ },
+ .leds = {
+ { .name = "wlan", .gpio = 0 << 0, .polarity = NORMAL },
+ { .name = "connected", .gpio = 1 << 0, .polarity = NORMAL },
+ { .name = "power", .gpio = 1 << 3, .polarity = NORMAL },
+ { .name = "diag", .gpio = 1 << 7, .polarity = NORMAL },
+ { .name = "usb", .gpio = 1 << 2, .polarity = REVERSE },
+ },
+ },
+ /* Trendware */
+ [TEW411BRPP] = {
+ .name = "Trendware TEW411BRP+",
+ .buttons = {
+ { /* No usable buttons */ },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 7, .polarity = NORMAL },
+ { .name = "wlan", .gpio = 1 << 1, .polarity = NORMAL },
+ { .name = "bridge", .gpio = 1 << 6, .polarity = NORMAL },
+ },
+ },
+ /* SimpleTech */
+ [STI_NAS] = {
+ .name = "SimpleTech SimpleShare NAS",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 0 }, // Power button on back, named reset to enable failsafe.
+ },
+ .leds = {
+ { .name = "diag", .gpio = 1 << 1, .polarity = REVERSE }, // actual name ready
+ },
+ .platform_init = bcm4780_init,
+ },
+ /* D-Link */
+ [DIR130] = {
+ .name = "D-Link DIR-130",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 3},
+ { .name = "reserved", .gpio = 1 << 7},
+ },
+ .leds = {
+ { .name = "diag", .gpio = 1 << 0},
+ { .name = "blue", .gpio = 1 << 6},
+ },
+ },
+ [DIR320] = {
+ .name = "D-Link DIR-320",
+ .buttons = {
+ { .name = "reserved", .gpio = 1 << 6},
+ { .name = "reset", .gpio = 1 << 7},
+ },
+ .leds = {
+ { .name = "wlan", .gpio = 1 << 0, .polarity = NORMAL },
+ { .name = "diag", .gpio = 1 << 1, .polarity = NORMAL }, /* "status led */
+ { .name = "red", .gpio = 1 << 3, .polarity = REVERSE },
+ { .name = "blue", .gpio = 1 << 4, .polarity = REVERSE },
+ { .name = "usb", .gpio = 1 << 5, .polarity = NORMAL },
+ },
+ },
+ [DIR330] = {
+ .name = "D-Link DIR-330",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 3},
+ { .name = "reserved", .gpio = 1 << 7},
+ },
+ .leds = {
+ { .name = "diag", .gpio = 1 << 0},
+ { .name = "usb", .gpio = 1 << 4},
+ { .name = "blue", .gpio = 1 << 6},
+ },
+ },
+ [DWL3150] = {
+ .name = "D-Link DWL-3150",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 7},
+ },
+ .leds = {
+ { .name = "diag", .gpio = 1 << 2},
+ { .name = "status", .gpio = 1 << 1},
+ },
+ },
+ /* Double check */
+ [WL105B] = {
+ .name = "Sitecom WL-105b",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 10},
+ },
+ .leds = {
+ { .name = "wlan", .gpio = 1 << 4},
+ { .name = "power", .gpio = 1 << 3},
+ },
+ },
+ /* Western Digital Net Center */
+ [WDNetCenter] = {
+ .name = "Western Digital NetCenter",
+ .buttons = {
+ { .name = "power", .gpio = 1 << 0},
+ { .name = "reset", .gpio = 1 << 7},
+ },
+ .platform_init = NetCenter_init,
+ },
+ /* Askey (and clones) */
+ [RT210W] = {
+ .name = "Askey RT210W",
+ .buttons = {
+ /* Power button is hard-wired to hardware reset */
+ /* but is also connected to GPIO 7 (probably for bootloader recovery) */
+ { .name = "power", .gpio = 1 << 7},
+ },
+ .leds = {
+ /* These were verified and named based on Belkin F5D4230-4 v1112 */
+ { .name = "connected", .gpio = 1 << 0, .polarity = REVERSE },
+ { .name = "wlan", .gpio = 1 << 3, .polarity = REVERSE },
+ { .name = "power", .gpio = 1 << 5, .polarity = REVERSE },
+ },
+ },
+ [WL1600GL] = {
+ .name = "OvisLink WL-1600GL",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 3 },
+ { .name = "ses", .gpio = 1 << 4 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 5, .polarity = REVERSE },
+ { .name = "wps", .gpio = 1 << 2, .polarity = REVERSE },
+ { .name = "wlan", .gpio = 1 << 1, .polarity = REVERSE },
+ { .name = "connected", .gpio = 1 << 0, .polarity = REVERSE },
+ },
+ },
+ /* Microsoft */
+ [MN700] = {
+ .name = "Microsoft MN-700",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 7 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 6, .polarity = NORMAL },
+ },
+ },
+ /* Edimax */
+ [PS1208MFG] = {
+ .name = "Edimax PS-1208MFG",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 4 },
+ },
+ .leds = {
+ { .name = "status", .gpio = 1 << 1, .polarity = NORMAL },
+ { .name = "wlan", .gpio = 1 << 0, .polarity = NORMAL },
+ },
+ },
+};
+
+static struct platform_t __init *platform_detect_legacy(void)
+{
+ char *boardnum, *boardtype, *buf;
+
+ if (strcmp(getvar("nvram_type"), "cfe") == 0)
+ return &platforms[WGT634U];
+
+
+ /* no easy model number, attempt to guess */
+ boardnum = getvar("boardnum");
+ boardtype = getvar("boardtype");
+
+ if (!strcmp(boardnum, "20070615")) { /* Linksys WRT600N v1/V1.1 */
+ if (!strcmp(boardtype, "0x478") && !strcmp(getvar("cardbus"), "0") && !strcmp(getvar("switch_type"),"BCM5395"))
+ return &platforms[WRT600NV11];
+
+ if (!strcmp(boardtype, "0x478") && !strcmp(getvar("cardbus"), "0"))
+ return &platforms[WRT600N];
+ }
+
+ if (startswith(getvar("pmon_ver"), "CFE")) {
+ /* CFE based - newer hardware */
+ if (!strcmp(boardnum, "42")) { /* Linksys */
+ if (!strcmp(boardtype, "0x478") && !strcmp(getvar("cardbus"), "1"))
+ return &platforms[WRT350N];
+
+ if (!strcmp(boardtype, "0x0101") && !strcmp(getvar("boot_ver"), "v3.6"))
+ return &platforms[WRT54G3G];
+
+ if (!strcmp(getvar("et1phyaddr"),"5") && !strcmp(getvar("et1mdcport"), "1"))
+ return &platforms[WRTSL54GS];
+
+ /* default to WRT54G */
+ return &platforms[WRT54G];
+ }
+ if (!strcmp(boardnum, "1024") && !strcmp(boardtype, "0x0446"))
+ return &platforms[WAP54GV2];
+
+ if (!strcmp(boardnum, "8") && !strcmp(boardtype, "0x048e"))
+ return &platforms[WL1600GL];
+
+
+ if (!strcmp(boardnum, "44") || !strcmp(boardnum, "44\r")) {
+ if (!strcmp(boardtype,"0x0101") || !strcmp(boardtype, "0x0101\r"))
+ return &platforms[TM2300V2]; /* Dell TrueMobile 2300 v2 */
+ }
+
+ if (!strcmp(boardnum, "45")) { /* ASUS */
+ if (!strcmp(boardtype,"0x0472"))
+ return &platforms[WL500W];
+ else if (!strcmp(boardtype,"0x467"))
+ return &platforms[WL320GE];
+ else
+ return &platforms[WL500GD];
+ }
+
+ if (!strcmp(boardnum, "10496"))
+ return &platforms[USR5461];
+
+ if (!strcmp(getvar("boardtype"), "0x0101") && !strcmp(getvar("boardrev"), "0x10")) /* SE505V2 With Modified CFE */
+ return &platforms[SE505V2];
+
+ if (!strcmp(boardtype, "0x048e") && !strcmp(getvar("boardrev"),"0x35") &&
+ !strcmp(getvar("boardflags"), "0x750")) /* D-Link DIR-320 */
+ return &platforms[DIR320];
+
+ if (!strncmp(boardnum, "TH",2) && !strcmp(boardtype,"0x042f")) {
+ return &platforms[WDNetCenter];
+ }
+
+ if (!strcmp(boardtype,"0x0472") && !strcmp(getvar("cardbus"), "1")) { /* Netgear WNR834B V1 and V2*/
+ if (!strcmp(boardnum, "08") || !strcmp(boardnum, "8"))
+ return &platforms[WNR834BV1];
+ if (!strcmp(boardnum, "01") || !strcmp(boardnum, "1"))
+ return &platforms[WNR834BV2];
+ }
+
+ } else { /* PMON based - old stuff */
+ if ((simple_strtoul(getvar("GemtekPmonVer"), NULL, 0) == 9) &&
+ (simple_strtoul(getvar("et0phyaddr"), NULL, 0) == 30)) {
+ return &platforms[WR850GV1];
+ }
+ if (startswith(boardtype, "bcm94710dev")) {
+ if (!strcmp(boardnum, "42"))
+ return &platforms[WRT54GV1];
+ if (simple_strtoul(boardnum, NULL, 0) == 2)
+ return &platforms[WAP54GV1];
+ }
+ /* MN-700 has also hardware_version 'WL500-...', so use boardnum */
+ if (startswith(getvar("hardware_version"), "WL500-")) {
+ if (!strcmp(getvar("boardnum"), "mn700"))
+ return &platforms[MN700];
+ else
+ return &platforms[WL500G];
+ }
+ if (startswith(getvar("hardware_version"), "WL300-")) {
+ /* Either WL-300g or WL-HDD, do more extensive checks */
+ if ((simple_strtoul(getvar("et0phyaddr"), NULL, 0) == 0) &&
+ (simple_strtoul(getvar("et1phyaddr"), NULL, 0) == 1))
+ return &platforms[WLHDD];
+ if ((simple_strtoul(getvar("et0phyaddr"), NULL, 0) == 0) &&
+ (simple_strtoul(getvar("et1phyaddr"), NULL, 0) == 10))
+ return &platforms[WL300G];
+ }
+ /* Sitecom WL-105b */
+ if (startswith(boardnum, "2") && simple_strtoul(getvar("GemtekPmonVer"), NULL, 0) == 1)
+ return &platforms[WL105B];
+
+ /* unknown asus stuff, probably bcm4702 */
+ if (startswith(boardnum, "asusX"))
+ return &platforms[ASUS_4702];
+
+ /* bcm4702 based Askey RT210W clones, Including:
+ * Askey RT210W (duh?)
+ * Siemens SE505v1
+ * Belkin F5D7230-4 before version v1444 (MiniPCI slot, not integrated)
+ */
+ if (!strcmp(boardtype,"bcm94710r4")
+ && !strcmp(boardnum ,"100")
+ && !strcmp(getvar("pmon_ver"),"v1.03.12.bk")
+ ){
+ return &platforms[RT210W];
+ }
+ }
+
+ if (buf || !strcmp(boardnum, "00")) {/* probably buffalo */
+ if (startswith(boardtype, "bcm94710ap"))
+ return &platforms[BUFFALO_UNKNOWN_4710];
+ else
+ return &platforms[BUFFALO_UNKNOWN];
+ }
+
+ if (startswith(getvar("CFEver"), "MotoWRv2") ||
+ startswith(getvar("CFEver"), "MotoWRv3") ||
+ !strcmp(getvar("MOTO_BOARD_TYPE"), "WR_FEM1")) {
+
+ return &platforms[WR850GV2V3];
+ }
+
+ if (!strcmp(boardnum, "44") && !strcmp(getvar("boardflags"),"0x0388")) { /* Trendware TEW-411BRP+ */
+ return &platforms[TEW411BRPP];
+ }
+
+ if (startswith(boardnum, "04FN")) /* SimpleTech SimpleShare */
+ return &platforms[STI_NAS];
+
+ if (!strcmp(boardnum, "10") && !strcmp(getvar("boardrev"), "0x13")) /* D-Link DWL-3150 */
+ return &platforms[DWL3150];
+
+ if (!strcmp(boardnum, "01") && !strcmp(boardtype, "0x048e") && /* Edimax PS1208MFG */
+ !strcmp(getvar("status_gpio"), "1")) /* gpio based detection */
+ return &platforms[PS1208MFG];
+
+ /* not found */
+ return NULL;
+}
+
+static struct platform_t __init *platform_detect(void)
+{
+ enum bcm47xx_board board;
+ const char *board_name;
+
+
+ board = bcm47xx_board_get();
+ board_name = bcm47xx_board_get_name();
+ if (board != BCM47XX_BOARD_UNKNOWN && board != BCM47XX_BOARD_NON)
+ printk(MODULE_NAME ": kernel found a \"%s\"\n", board_name);
+
+ switch(board) {
+ case BCM47XX_BOARD_ASUS_RTN16:
+ return &platforms[RTN16];
+ case BCM47XX_BOARD_ASUS_WL330GE:
+ return &platforms[WL330GE];
+ case BCM47XX_BOARD_ASUS_WL500GPV1:
+ return &platforms[WL500GP];
+ case BCM47XX_BOARD_ASUS_WL500GPV2:
+ return &platforms[WL500GPV2];
+ case BCM47XX_BOARD_ASUS_WL520GC:
+ return &platforms[WL520GC];
+ case BCM47XX_BOARD_ASUS_WL520GU:
+ return &platforms[WL520GU];
+ case BCM47XX_BOARD_ASUS_WL700GE:
+ return &platforms[WL700GE];
+ case BCM47XX_BOARD_BELKIN_F7D4301:
+ return &platforms[BELKIN_F7D4301];
+ case BCM47XX_BOARD_BUFFALO_WBR2_G54:
+ return &platforms[WBR2_G54];
+ case BCM47XX_BOARD_BUFFALO_WHR2_A54G54:
+ return &platforms[WHR2_A54G54];
+ case BCM47XX_BOARD_BUFFALO_WHR_G125:
+ return &platforms[WHR_G125];
+ case BCM47XX_BOARD_BUFFALO_WHR_G54S:
+ return &platforms[WHR_G54S];
+ case BCM47XX_BOARD_BUFFALO_WHR_HP_G54:
+ return &platforms[WHR_HP_G54];
+ case BCM47XX_BOARD_BUFFALO_WLA2_G54L:
+ return &platforms[WLA2_G54L];
+ case BCM47XX_BOARD_BUFFALO_WZR_G300N:
+ return &platforms[WZR_G300N];
+ case BCM47XX_BOARD_BUFFALO_WZR_RS_G54:
+ return &platforms[WZR_RS_G54];
+ case BCM47XX_BOARD_BUFFALO_WZR_RS_G54HP:
+ return &platforms[WZR_RS_G54HP];
+ case BCM47XX_BOARD_DELL_TM2300:
+ return &platforms[TM2300];
+ case BCM47XX_BOARD_DLINK_DIR130:
+ return &platforms[DIR130];
+ case BCM47XX_BOARD_DLINK_DIR330:
+ return &platforms[DIR330];
+ case BCM47XX_BOARD_LINKSYS_E1000V1:
+ return &platforms[E1000V1];
+ case BCM47XX_BOARD_LINKSYS_E3000V1:
+ return &platforms[E3000V1];
+ case BCM47XX_BOARD_LINKSYS_E3200V1:
+ return &platforms[E3200V1];
+ case BCM47XX_BOARD_LINKSYS_WRT150NV1:
+ return &platforms[WRT150NV1];
+ case BCM47XX_BOARD_LINKSYS_WRT150NV11:
+ return &platforms[WRT150NV11];
+ case BCM47XX_BOARD_LINKSYS_WRT160NV1:
+ return &platforms[WRT160NV1];
+ case BCM47XX_BOARD_LINKSYS_WRT160NV3:
+ return &platforms[WRT160NV3];
+ case BCM47XX_BOARD_LINKSYS_WRT300NV11:
+ return &platforms[WRT300NV11];
+ case BCM47XX_BOARD_LINKSYS_WRT54G3GV2:
+ return &platforms[WRT54G3GV2_VF];
+ case BCM47XX_BOARD_LINKSYS_WRT610NV1:
+ return &platforms[WRT610N];
+ case BCM47XX_BOARD_LINKSYS_WRT610NV2:
+ return &platforms[WRT610NV2];
+ case BCM47XX_BOARD_MOTOROLA_WE800G:
+ return &platforms[WE800G];
+ case BCM47XX_BOARD_MOTOROLA_WR850GP:
+ return &platforms[WR850GP];
+ case BCM47XX_BOARD_MOTOROLA_WR850GV2V3:
+ return &platforms[WR850GV2V3];
+ case BCM47XX_BOARD_NETGEAR_WNDR3400V1:
+ return &platforms[WNDR3400V1];
+ case BCM47XX_BOARD_UNKNOWN:
+ case BCM47XX_BOARD_NON:
+ printk(MODULE_NAME ": unknown board found, try legacy detect\n");
+ printk(MODULE_NAME ": please open a ticket at https://dev.openwrt.org and attach the complete nvram\n");
+ return platform_detect_legacy();
+ default:
+ printk(MODULE_NAME ": board was detected as \"%s\", but not gpio configuration available\n", board_name);
+ printk(MODULE_NAME ": now trying legacy detect\n");
+ return platform_detect_legacy();
+ }
+}
+
+static inline void ssb_maskset32(struct ssb_device *dev,
+ u16 offset, u32 mask, u32 set)
+{
+ ssb_write32(dev, offset, (ssb_read32(dev, offset) & mask) | set);
+}
+
+static void gpio_set_irqenable(int enabled, irqreturn_t (*handler)(int, void *))
+{
+ int irq;
+
+ irq = gpio_to_irq(0);
+ if (irq == -EINVAL) return;
+
+ if (enabled) {
+ if (request_irq(irq, handler, IRQF_SHARED, "gpio", handler))
+ return;
+ } else {
+ free_irq(irq, handler);
+ }
+
+ switch (bcm47xx_bus_type) {
+#ifdef CONFIG_BCM47XX_SSB
+ case BCM47XX_BUS_TYPE_SSB:
+ if (bcm47xx_bus.ssb.chipco.dev)
+ ssb_maskset32(bcm47xx_bus.ssb.chipco.dev, SSB_CHIPCO_IRQMASK, ~SSB_CHIPCO_IRQ_GPIO, (enabled ? SSB_CHIPCO_IRQ_GPIO : 0));
+ break;
+#endif
+#ifdef CONFIG_BCM47XX_BCMA
+ case BCM47XX_BUS_TYPE_BCMA:
+ if (bcm47xx_bus.bcma.bus.drv_cc.core)
+ bcma_maskset32(bcm47xx_bus.bcma.bus.drv_cc.core, BCMA_CC_IRQMASK, ~BCMA_CC_IRQ_GPIO, (enabled ? BCMA_CC_IRQ_GPIO : 0));
+ break;
+#endif
+ }
+}
+
+static void register_buttons(struct button_t *b)
+{
+ for (; b->name; b++)
+ platform.button_mask |= b->gpio;
+
+ platform.button_mask &= ~gpiomask;
+
+ bcm47xx_gpio_outen(platform.button_mask, 0);
+ bcm47xx_gpio_control(platform.button_mask, 0);
+ platform.button_polarity = bcm47xx_gpio_in(~0) & platform.button_mask;
+ bcm47xx_gpio_polarity(platform.button_mask, platform.button_polarity);
+ bcm47xx_gpio_intmask(platform.button_mask, platform.button_mask);
+
+ gpio_set_irqenable(1, button_handler);
+}
+
+static void unregister_buttons(struct button_t *b)
+{
+ bcm47xx_gpio_intmask(platform.button_mask, 0);
+
+ gpio_set_irqenable(0, button_handler);
+}
+
+
+static void add_msg(struct event_t *event, char *msg, int argv)
+{
+ char *s;
+
+ if (argv)
+ return;
+
+ s = skb_put(event->skb, strlen(msg) + 1);
+ strcpy(s, msg);
+}
+
+static void hotplug_button(struct work_struct *work)
+{
+ struct event_t *event = container_of(work, struct event_t, wq);
+ char *s;
+
+ event->skb = alloc_skb(2048, GFP_KERNEL);
+
+ s = skb_put(event->skb, strlen(event->action) + 2);
+ sprintf(s, "%s@", event->action);
+ fill_event(event);
+
+ NETLINK_CB(event->skb).dst_group = 1;
+ broadcast_uevent(event->skb, 0, 1, GFP_KERNEL);
+
+ kfree(event);
+}
+
+
+static int fill_event (struct event_t *event)
+{
+ static char buf[128];
+
+ add_msg(event, "HOME=/", 0);
+ add_msg(event, "PATH=/sbin:/bin:/usr/sbin:/usr/bin", 0);
+ add_msg(event, "SUBSYSTEM=button", 0);
+ snprintf(buf, 128, "ACTION=%s", event->action);
+ add_msg(event, buf, 0);
+ snprintf(buf, 128, "BUTTON=%s", event->name);
+ add_msg(event, buf, 0);
+ snprintf(buf, 128, "SEEN=%ld", event->seen);
+ add_msg(event, buf, 0);
+ snprintf(buf, 128, "SEQNUM=%llu", uevent_next_seqnum());
+ add_msg(event, buf, 0);
+
+ return 0;
+}
+
+
+static irqreturn_t button_handler(int irq, void *dev_id)
+{
+ struct button_t *b;
+ u32 in, changed;
+
+ in = bcm47xx_gpio_in(~0) & platform.button_mask;
+ bcm47xx_gpio_polarity(platform.button_mask, in);
+ changed = platform.button_polarity ^ in;
+ platform.button_polarity = in;
+
+ changed &= ~bcm47xx_gpio_outen(0, 0);
+
+ for (b = platform.buttons; b->name; b++) {
+ struct event_t *event;
+
+ if (!(b->gpio & changed)) continue;
+
+ b->pressed ^= 1;
+
+ if ((event = (struct event_t *)kzalloc (sizeof(struct event_t), GFP_ATOMIC))) {
+ event->seen = (jiffies - b->seen)/HZ;
+ event->name = b->name;
+ event->action = b->pressed ? "pressed" : "released";
+ INIT_WORK(&event->wq, (void *)(void *)hotplug_button);
+ schedule_work(&event->wq);
+ }
+
+ b->seen = jiffies;
+ }
+ return IRQ_HANDLED;
+}
+
+static void register_leds(struct led_t *l)
+{
+ struct proc_dir_entry *p;
+ u32 mask = 0;
+ u32 oe_mask = 0;
+ u32 val = 0;
+
+ leds = proc_mkdir("led", diag);
+ if (!leds)
+ return;
+
+ for(; l->name; l++) {
+ if (l->gpio & gpiomask)
+ continue;
+
+ if (l->gpio & GPIO_TYPE_EXTIF) {
+ l->state = 0;
+ set_led_extif(l);
+ } else {
+ if (l->polarity != INPUT) oe_mask |= l->gpio;
+ mask |= l->gpio;
+ val |= (l->polarity == NORMAL)?0:l->gpio;
+ }
+
+ if (l->polarity == INPUT) continue;
+
+ if ((p = create_proc_entry(l->name, S_IRUSR, leds))) {
+ l->proc.type = PROC_LED;
+ l->proc.ptr = l;
+ p->data = (void *) &l->proc;
+ p->proc_fops = &diag_proc_fops;
+ }
+ }
+
+ bcm47xx_gpio_outen(mask, oe_mask);
+ bcm47xx_gpio_control(mask, 0);
+ bcm47xx_gpio_out(mask, val);
+ bcm47xx_gpio_intmask(mask, 0);
+}
+
+static void unregister_leds(struct led_t *l)
+{
+ for(; l->name; l++)
+ remove_proc_entry(l->name, leds);
+
+ remove_proc_entry("led", diag);
+}
+
+static void set_led_extif(struct led_t *led)
+{
+ volatile u8 *addr = (volatile u8 *) KSEG1ADDR(EXTIF_UART) + (led->gpio & ~GPIO_TYPE_MASK);
+ if (led->state)
+ *addr = 0xFF;
+ else
+ *addr;
+}
+
+static void led_flash(unsigned long dummy) {
+ struct led_t *l;
+ u32 mask = 0;
+ u8 extif_blink = 0;
+
+ for (l = platform.leds; l->name; l++) {
+ if (l->flash) {
+ if (l->gpio & GPIO_TYPE_EXTIF) {
+ extif_blink = 1;
+ l->state = !l->state;
+ set_led_extif(l);
+ } else {
+ mask |= l->gpio;
+ }
+ }
+ }
+
+ mask &= ~gpiomask;
+ if (mask) {
+ u32 val = ~bcm47xx_gpio_in(~0);
+
+ bcm47xx_gpio_outen(mask, mask);
+ bcm47xx_gpio_control(mask, 0);
+ bcm47xx_gpio_out(mask, val);
+ }
+ if (mask || extif_blink) {
+ mod_timer(&led_timer, jiffies + FLASH_TIME);
+ }
+}
+
+static ssize_t diag_proc_read(struct file *file, char *buf, size_t count, loff_t *ppos)
+{
+ struct proc_dir_entry *dent = PDE(file->f_dentry->d_inode);
+ char *page;
+ int len = 0;
+
+ if ((page = kmalloc(1024, GFP_KERNEL)) == NULL)
+ return -ENOBUFS;
+
+ if (dent->data != NULL) {
+ struct prochandler_t *handler = (struct prochandler_t *) dent->data;
+ switch (handler->type) {
+ case PROC_LED: {
+ struct led_t * led = (struct led_t *) handler->ptr;
+ if (led->flash) {
+ len = sprintf(page, "f\n");
+ } else {
+ if (led->gpio & GPIO_TYPE_EXTIF) {
+ len = sprintf(page, "%d\n", led->state);
+ } else {
+ u32 in = (bcm47xx_gpio_in(~0) & led->gpio ? 1 : 0);
+ u8 p = (led->polarity == NORMAL ? 0 : 1);
+ len = sprintf(page, "%d\n", ((in ^ p) ? 1 : 0));
+ }
+ }
+ break;
+ }
+ case PROC_MODEL:
+ len = sprintf(page, "%s\n", platform.name);
+ break;
+ case PROC_GPIOMASK:
+ len = sprintf(page, "0x%04x\n", gpiomask);
+ break;
+ }
+ }
+ len += 1;
+
+ if (*ppos < len) {
+ len = min_t(int, len - *ppos, count);
+ if (copy_to_user(buf, (page + *ppos), len)) {
+ kfree(page);
+ return -EFAULT;
+ }
+ *ppos += len;
+ } else {
+ len = 0;
+ }
+
+ kfree(page);
+ return len;
+}
+
+
+static ssize_t diag_proc_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
+{
+ struct proc_dir_entry *dent = PDE(file->f_dentry->d_inode);
+ char *page;
+ int ret = -EINVAL;
+
+ if ((page = kmalloc(count + 1, GFP_KERNEL)) == NULL)
+ return -ENOBUFS;
+
+ if (copy_from_user(page, buf, count)) {
+ kfree(page);
+ return -EINVAL;
+ }
+ page[count] = 0;
+
+ if (dent->data != NULL) {
+ struct prochandler_t *handler = (struct prochandler_t *) dent->data;
+ switch (handler->type) {
+ case PROC_LED: {
+ struct led_t *led = (struct led_t *) handler->ptr;
+ int p = (led->polarity == NORMAL ? 0 : 1);
+
+ if (page[0] == 'f') {
+ led->flash = 1;
+ led_flash(0);
+ } else {
+ led->flash = 0;
+ if (led->gpio & GPIO_TYPE_EXTIF) {
+ led->state = p ^ ((page[0] == '1') ? 1 : 0);
+ set_led_extif(led);
+ } else {
+ bcm47xx_gpio_outen(led->gpio, led->gpio);
+ bcm47xx_gpio_control(led->gpio, 0);
+ bcm47xx_gpio_out(led->gpio, ((p ^ (page[0] == '1')) ? led->gpio : 0));
+ }
+ }
+ break;
+ }
+ case PROC_GPIOMASK:
+ gpiomask = simple_strtoul(page, NULL, 0);
+
+ if (platform.buttons) {
+ unregister_buttons(platform.buttons);
+ register_buttons(platform.buttons);
+ }
+
+ if (platform.leds) {
+ unregister_leds(platform.leds);
+ register_leds(platform.leds);
+ }
+ break;
+ }
+ ret = count;
+ }
+
+ kfree(page);
+ return ret;
+}
+
+static int __init diag_init(void)
+{
+ static struct proc_dir_entry *p;
+ static struct platform_t *detected;
+
+ detected = platform_detect();
+ if (!detected) {
+ printk(MODULE_NAME ": Router model not detected.\n");
+ return -ENODEV;
+ }
+ memcpy(&platform, detected, sizeof(struct platform_t));
+
+ printk(MODULE_NAME ": Detected '%s'\n", platform.name);
+ if (platform.platform_init != NULL) {
+ platform.platform_init();
+ }
+
+ if (!(diag = proc_mkdir("diag", NULL))) {
+ printk(MODULE_NAME ": proc_mkdir on /proc/diag failed\n");
+ return -EINVAL;
+ }
+
+ if ((p = create_proc_entry("model", S_IRUSR, diag))) {
+ p->data = (void *) &proc_model;
+ p->proc_fops = &diag_proc_fops;
+ }
+
+ if ((p = create_proc_entry("gpiomask", S_IRUSR | S_IWUSR, diag))) {
+ p->data = (void *) &proc_gpiomask;
+ p->proc_fops = &diag_proc_fops;
+ }
+
+ if (platform.buttons)
+ register_buttons(platform.buttons);
+
+ if (platform.leds)
+ register_leds(platform.leds);
+
+ return 0;
+}
+
+static void __exit diag_exit(void)
+{
+ del_timer(&led_timer);
+
+ if (platform.buttons)
+ unregister_buttons(platform.buttons);
+
+ if (platform.leds)
+ unregister_leds(platform.leds);
+
+ remove_proc_entry("model", diag);
+ remove_proc_entry("gpiomask", diag);
+ remove_proc_entry("diag", NULL);
+}
+
+module_init(diag_init);
+module_exit(diag_exit);
+
+MODULE_AUTHOR("Mike Baker, Felix Fietkau / OpenWrt.org");
+MODULE_LICENSE("GPL");
diff --git a/package/broadcom-diag/src/.svn/text-base/diag.h.svn-base b/package/broadcom-diag/src/.svn/text-base/diag.h.svn-base
new file mode 100644
index 0000000..698c376
--- /dev/null
+++ b/package/broadcom-diag/src/.svn/text-base/diag.h.svn-base
@@ -0,0 +1,134 @@
+/*
+ * diag.h - GPIO interface driver for Broadcom boards
+ *
+ * Copyright (C) 2006 Mike Baker <mbm@openwrt.org>,
+ * Felix Fietkau <nbd@openwrt.org>
+ *
+ * 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
+ * of the License, 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include <linux/irq.h>
+#define MODULE_NAME "diag"
+
+#define MAX_GPIO 16
+#define FLASH_TIME HZ/6
+
+enum polarity_t {
+ REVERSE = 0,
+ NORMAL = 1,
+ INPUT = 2,
+};
+
+enum {
+ PROC_BUTTON,
+ PROC_LED,
+ PROC_MODEL,
+ PROC_GPIOMASK
+};
+
+struct prochandler_t {
+ int type;
+ void *ptr;
+};
+
+struct button_t {
+ struct prochandler_t proc;
+ char *name;
+ u32 gpio;
+ unsigned long seen;
+ u8 pressed;
+};
+
+struct led_t {
+ struct prochandler_t proc;
+ char *name;
+ u32 gpio;
+ u8 polarity;
+ u8 flash;
+ u8 state;
+};
+
+struct platform_t {
+ char *name;
+
+ struct button_t buttons[MAX_GPIO];
+ u32 button_mask;
+ u32 button_polarity;
+ void (*platform_init)(void);
+
+ struct led_t leds[MAX_GPIO];
+};
+
+struct event_t {
+ struct work_struct wq;
+ unsigned long seen;
+ char *name, *action;
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,0)
+ struct sk_buff *skb;
+#else
+ char *scratch;
+ char *argv[4];
+ char *envp[7];
+ u8 enr, anr;
+#endif
+};
+
+extern char *nvram_get(char *str);
+
+static struct platform_t platform;
+
+/* buttons */
+
+static void register_buttons(struct button_t *b);
+static void unregister_buttons(struct button_t *b);
+
+static void hotplug_button(struct work_struct *work);
+static irqreturn_t button_handler(int irq, void *dev_id);
+
+/* leds */
+
+static void register_leds(struct led_t *l);
+static void unregister_leds(struct led_t *l);
+
+static void set_led_extif(struct led_t *led);
+static void led_flash(unsigned long dummy);
+
+/* 2.4 compatibility */
+#ifndef TIMER_INITIALIZER
+#define TIMER_INITIALIZER(_function, _expires, _data) \
+ { \
+ /* _expires and _data currently unused */ \
+ function: _function \
+ }
+#endif
+
+static struct timer_list led_timer = TIMER_INITIALIZER(&led_flash, 0, 0);
+
+/* proc */
+
+static struct proc_dir_entry *diag, *leds;
+
+static ssize_t diag_proc_read(struct file *file, char *buf, size_t count, loff_t *ppos);
+static ssize_t diag_proc_write(struct file *file, const char *buf, size_t count, loff_t *ppos);
+
+static struct file_operations diag_proc_fops = {
+ read: diag_proc_read,
+ write: diag_proc_write
+};
+
+static struct prochandler_t proc_model = { .type = PROC_MODEL };
+static struct prochandler_t proc_gpiomask = { .type = PROC_GPIOMASK };
+
diff --git a/package/broadcom-diag/src/.svn/text-base/gpio.h.svn-base b/package/broadcom-diag/src/.svn/text-base/gpio.h.svn-base
new file mode 100644
index 0000000..d0e3e06
--- /dev/null
+++ b/package/broadcom-diag/src/.svn/text-base/gpio.h.svn-base
@@ -0,0 +1,16 @@
+#ifndef __DIAG_GPIO_H
+#define __DIAG_GPIO_H
+
+#include <linux/interrupt.h>
+#include <linux/ssb/ssb_embedded.h>
+#include <linux/gpio.h>
+#include <bcm47xx.h>
+
+#define EXTIF_ADDR 0x1f000000
+#define EXTIF_UART (EXTIF_ADDR + 0x00800000)
+
+#define GPIO_TYPE_NORMAL (0x0 << 24)
+#define GPIO_TYPE_EXTIF (0x1 << 24)
+#define GPIO_TYPE_MASK (0xf << 24)
+
+#endif /* __DIAG_GPIO_H */
diff --git a/package/broadcom-diag/src/Makefile b/package/broadcom-diag/src/Makefile
new file mode 100644
index 0000000..44c80a8
--- /dev/null
+++ b/package/broadcom-diag/src/Makefile
@@ -0,0 +1,17 @@
+#
+# Makefile for diag driver
+#
+# Copyright (C) 2005 Felix Fietkau <nbd@openwrt.org>
+#
+# 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 of the License, or (at your option) any later version.
+#
+
+obj-m := diag.o
+
+ifeq ($(MAKING_MODULES),1)
+
+-include $(TOPDIR)/Rules.make
+endif
diff --git a/package/broadcom-diag/src/diag.c b/package/broadcom-diag/src/diag.c
new file mode 100644
index 0000000..168f81d
--- /dev/null
+++ b/package/broadcom-diag/src/diag.c
@@ -0,0 +1,1723 @@
+/*
+ * diag.c - GPIO interface driver for Broadcom boards
+ *
+ * Copyright (C) 2006 Mike Baker <mbm@openwrt.org>,
+ * Copyright (C) 2006-2007 Felix Fietkau <nbd@openwrt.org>
+ * Copyright (C) 2008 Andy Boyett <agb@openwrt.org>
+ *
+ * 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
+ * of the License, 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+#include <linux/module.h>
+#include <linux/pci.h>
+#include <linux/kmod.h>
+#include <linux/proc_fs.h>
+#include <linux/timer.h>
+#include <linux/version.h>
+#include <asm/uaccess.h>
+#include <linux/workqueue.h>
+#include <linux/skbuff.h>
+#include <linux/netlink.h>
+#include <linux/kobject.h>
+#include <net/sock.h>
+#include <bcm47xx_board.h>
+extern u64 uevent_next_seqnum(void);
+
+#include "gpio.h"
+#include "diag.h"
+#define getvar(str) (nvram_get(str)?:"")
+
+static inline int startswith (char *source, char *cmp) { return !strncmp(source,cmp,strlen(cmp)); }
+static int fill_event(struct event_t *);
+static unsigned int gpiomask = 0;
+module_param(gpiomask, int, 0644);
+
+enum {
+ /* Linksys */
+ WAP54GV1,
+ WAP54GV2,
+ WAP54GV3,
+ WRT54GV1,
+ WRT54G,
+ WRTSL54GS,
+ WRT54G3G,
+ WRT54G3GV2_VF,
+ WRT150NV1,
+ WRT150NV11,
+ WRT160NV1,
+ WRT160NV3,
+ WRT300NV11,
+ WRT350N,
+ WRT600N,
+ WRT600NV11,
+ WRT610N,
+ WRT610NV2,
+ E1000V1,
+ E3000V1,
+ E3200V1,
+
+ /* ASUS */
+ WLHDD,
+ WL300G,
+ WL320GE,
+ WL330GE,
+ WL500G,
+ WL500GD,
+ WL500GP,
+ WL500GPV2,
+ WL500W,
+ WL520GC,
+ WL520GU,
+ ASUS_4702,
+ WL700GE,
+ RTN16,
+
+ /* Buffalo */
+ WBR2_G54,
+ WHR_G54S,
+ WHR_HP_G54,
+ WHR_G125,
+ WHR2_A54G54,
+ WLA2_G54L,
+ WZR_G300N,
+ WZR_RS_G54,
+ WZR_RS_G54HP,
+ BUFFALO_UNKNOWN,
+ BUFFALO_UNKNOWN_4710,
+
+ /* Siemens */
+ SE505V1,
+ SE505V2,
+
+ /* US Robotics */
+ USR5461,
+
+ /* Dell */
+ TM2300,
+ TM2300V2,
+
+ /* Motorola */
+ WE800G,
+ WR850GV1,
+ WR850GV2V3,
+ WR850GP,
+
+ /* Belkin */
+ BELKIN_UNKNOWN,
+ BELKIN_F7D4301,
+
+ /* Netgear */
+ WGT634U,
+ WNR834BV1,
+ WNR834BV2,
+ WNDR3400V1,
+
+ /* Trendware */
+ TEW411BRPP,
+
+ /* SimpleTech */
+ STI_NAS,
+
+ /* D-Link */
+ DIR130,
+ DIR320,
+ DIR330,
+ DWL3150,
+
+ /* Sitecom */
+ WL105B,
+
+ /* Western Digital */
+ WDNetCenter,
+
+ /* Askey */
+ RT210W,
+
+ /* OvisLink */
+ WL1600GL,
+
+ /* Microsoft */
+ MN700,
+
+ /* Edimax */
+ PS1208MFG,
+};
+
+static void __init bcm4780_init(void) {
+ int pin = 1 << 3;
+
+ /* Enables GPIO 3 that controls HDD and led power on ASUS WL-700gE */
+ printk(MODULE_NAME ": Spinning up HDD and enabling leds\n");
+ bcm47xx_gpio_outen(pin, pin);
+ bcm47xx_gpio_control(pin, 0);
+ bcm47xx_gpio_out(pin, pin);
+
+ /* Wait 5s, so the HDD can spin up */
+ set_current_state(TASK_INTERRUPTIBLE);
+ schedule_timeout(HZ * 5);
+}
+
+static void __init NetCenter_init(void) {
+ /* unset pin 6 (+12V) */
+ int pin = 1 << 6;
+ bcm47xx_gpio_outen(pin, pin);
+ bcm47xx_gpio_control(pin, 0);
+ bcm47xx_gpio_out(pin, pin);
+ /* unset pin 1 (turn off red led, blue will light alone if +5V comes up) */
+ pin = 1 << 1;
+ bcm47xx_gpio_outen(pin, pin);
+ bcm47xx_gpio_control(pin, 0);
+ bcm47xx_gpio_out(pin, pin);
+ /* unset pin 3 (+5V) and wait 5 seconds (harddisk spin up) */
+ bcm4780_init();
+}
+
+static void __init bcm57xx_init(void) {
+ int pin = 1 << 2;
+
+ /* FIXME: switch comes up, but port mappings/vlans not right */
+ bcm47xx_gpio_outen(pin, pin);
+ bcm47xx_gpio_control(pin, 0);
+ bcm47xx_gpio_out(pin, pin);
+}
+
+static struct platform_t __initdata platforms[] = {
+ /* Linksys */
+ [WAP54GV1] = {
+ .name = "Linksys WAP54G V1",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 0 },
+ },
+ .leds = {
+ { .name = "diag", .gpio = 1 << 3 },
+ { .name = "wlan", .gpio = 1 << 4 },
+ },
+ },
+ [WAP54GV2] = {
+ .name = "Linksys WAP54G V2",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 0 },
+ },
+ .leds = {
+ { .name = "wlan", .gpio = 1 << 5, .polarity = REVERSE },
+ /* GPIO 6 is b44 (eth0, LAN) PHY power */
+ },
+ },
+ [WAP54GV3] = {
+ .name = "Linksys WAP54G V3",
+ .buttons = {
+ /* FIXME: verify this */
+ { .name = "reset", .gpio = 1 << 7 },
+ { .name = "ses", .gpio = 1 << 0 },
+ },
+ .leds = {
+ /* FIXME: diag? */
+ { .name = "ses", .gpio = 1 << 1 },
+ },
+ },
+ [WRT54GV1] = {
+ .name = "Linksys WRT54G V1.x",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 6 },
+ },
+ .leds = {
+ { .name = "diag", .gpio = 0x13 | GPIO_TYPE_EXTIF, .polarity = NORMAL },
+ { .name = "dmz", .gpio = 0x12 | GPIO_TYPE_EXTIF, .polarity = NORMAL },
+ },
+ },
+ [WRT54G] = {
+ .name = "Linksys WRT54G/GS/GL",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 6 },
+ { .name = "ses", .gpio = 1 << 4 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 1, .polarity = NORMAL },
+ { .name = "dmz", .gpio = 1 << 7, .polarity = REVERSE },
+ { .name = "ses_white", .gpio = 1 << 2, .polarity = REVERSE },
+ { .name = "ses_orange", .gpio = 1 << 3, .polarity = REVERSE },
+ { .name = "wlan", .gpio = 1 << 0, .polarity = REVERSE },
+ },
+ },
+ [WRTSL54GS] = {
+ .name = "Linksys WRTSL54GS",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 6 },
+ { .name = "ses", .gpio = 1 << 4 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 1, .polarity = NORMAL },
+ { .name = "dmz", .gpio = 1 << 0, .polarity = REVERSE },
+ { .name = "ses_white", .gpio = 1 << 5, .polarity = REVERSE },
+ { .name = "ses_orange", .gpio = 1 << 7, .polarity = REVERSE },
+ },
+ },
+ [WRT54G3G] = {
+ .name = "Linksys WRT54G3G",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 6 },
+ { .name = "3g", .gpio = 1 << 4 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 1, .polarity = NORMAL },
+ { .name = "dmz", .gpio = 1 << 7, .polarity = REVERSE },
+ { .name = "3g_green", .gpio = 1 << 2, .polarity = NORMAL },
+ { .name = "3g_blue", .gpio = 1 << 3, .polarity = NORMAL },
+ { .name = "3g_blink", .gpio = 1 << 5, .polarity = NORMAL },
+ },
+ },
+ [WRT54G3GV2_VF] = {
+ .name = "Linksys WRT54G3GV2-VF",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 6 },
+ { .name = "3g", .gpio = 1 << 5 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 1, .polarity = NORMAL },
+ { .name = "3g_green", .gpio = 1 << 2, .polarity = NORMAL },
+ { .name = "3g_blue", .gpio = 1 << 3, .polarity = NORMAL },
+ },
+ },
+ [WRT150NV1] = {
+ .name = "Linksys WRT150N V1",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 6 },
+ { .name = "ses", .gpio = 1 << 4 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 1, .polarity = NORMAL },
+ { .name = "ses_green", .gpio = 1 << 5, .polarity = REVERSE },
+ { .name = "ses_amber", .gpio = 1 << 3, .polarity = REVERSE },
+ },
+ },
+ [WRT150NV11] = {
+ .name = "Linksys WRT150N V1.1",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 6 },
+ { .name = "ses", .gpio = 1 << 4 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 1, .polarity = NORMAL },
+ { .name = "ses_green", .gpio = 1 << 5, .polarity = REVERSE },
+ { .name = "ses_amber", .gpio = 1 << 3, .polarity = REVERSE },
+ },
+ },
+ [WRT160NV1] = {
+ .name = "Linksys WRT160N v1.x",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 6 },
+ { .name = "ses", .gpio = 1 << 4 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 1, .polarity = NORMAL },
+ { .name = "ses_blue", .gpio = 1 << 5, .polarity = REVERSE },
+ { .name = "ses_orange", .gpio = 1 << 3, .polarity = REVERSE },
+ },
+ },
+ [WRT160NV3] = {
+ .name = "Linksys WRT160N V3",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 6 },
+ { .name = "ses", .gpio = 1 << 5 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 1, .polarity = NORMAL },
+ { .name = "ses_blue", .gpio = 1 << 4, .polarity = REVERSE },
+ { .name = "ses_orange", .gpio = 1 << 2, .polarity = REVERSE },
+ },
+ },
+ [WRT300NV11] = {
+ .name = "Linksys WRT300N V1.1",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 6 }, // "Reset" on back panel
+ { .name = "ses", .gpio = 1 << 4 }, // "Reserved" on top panel
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 1, .polarity = NORMAL }, // "Power"
+ { .name = "ses_amber", .gpio = 1 << 3, .polarity = REVERSE }, // "Security" Amber
+ { .name = "ses_green", .gpio = 1 << 5, .polarity = REVERSE }, // "Security" Green
+ },
+ .platform_init = bcm57xx_init,
+ },
+ [WRT350N] = {
+ .name = "Linksys WRT350N",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 6 },
+ { .name = "ses", .gpio = 1 << 8 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 1, .polarity = NORMAL },
+ { .name = "ses_amber", .gpio = 1 << 3, .polarity = REVERSE },
+ { .name = "ses_green", .gpio = 1 << 9, .polarity = REVERSE },
+ { .name = "usb_blink", .gpio = 1 << 10, .polarity = REVERSE },
+ { .name = "usb", .gpio = 1 << 11, .polarity = REVERSE },
+ },
+ .platform_init = bcm57xx_init,
+ },
+ [WRT600N] = {
+ .name = "Linksys WRT600N",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 6 },
+ { .name = "ses", .gpio = 1 << 7 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 2, .polarity = REVERSE }, // Power LED
+ { .name = "usb", .gpio = 1 << 3, .polarity = REVERSE }, // USB LED
+ { .name = "wl0_ses_amber", .gpio = 1 << 8, .polarity = REVERSE }, // 2.4Ghz LED Amber
+ { .name = "wl0_ses_green", .gpio = 1 << 9, .polarity = REVERSE }, // 2.4Ghz LED Green
+ { .name = "wl1_ses_amber", .gpio = 1 << 10, .polarity = REVERSE }, // 5.6Ghz LED Amber
+ { .name = "wl1_ses_green", .gpio = 1 << 11, .polarity = REVERSE }, // 5.6Ghz LED Green
+ },
+ .platform_init = bcm57xx_init,
+ },
+ [WRT600NV11] = {
+ .name = "Linksys WRT600N V1.1",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 6 },
+ { .name = "ses", .gpio = 1 << 7 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 2, .polarity = REVERSE }, // Power LED
+ { .name = "usb", .gpio = 1 << 3, .polarity = REVERSE }, // USB LED
+ { .name = "wl0_ses_amber", .gpio = 1 << 8, .polarity = REVERSE }, // 2.4Ghz LED Amber
+ { .name = "wl0_ses_green", .gpio = 1 << 9, .polarity = REVERSE }, // 2.4Ghz LED Green
+ { .name = "wl1_ses_amber", .gpio = 1 << 10, .polarity = REVERSE }, // 5.6Ghz LED Amber
+ { .name = "wl1_ses_green", .gpio = 1 << 11, .polarity = REVERSE }, // 5.6Ghz LED Green
+ },
+ .platform_init = bcm57xx_init,
+ },
+ [WRT610N] = {
+ .name = "Linksys WRT610N",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 6 },
+ { .name = "ses", .gpio = 1 << 8 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 1, .polarity = NORMAL }, // Power LED
+ { .name = "usb", .gpio = 1 << 0, .polarity = REVERSE }, // USB LED
+ { .name = "ses_amber", .gpio = 1 << 3, .polarity = REVERSE }, // WiFi protected setup LED amber
+ { .name = "ses_blue", .gpio = 1 << 9, .polarity = REVERSE }, // WiFi protected setup LED blue
+ },
+ },
+ [WRT610NV2] = {
+ .name = "Linksys WRT610N V2",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 6 },
+ { .name = "ses", .gpio = 1 << 4 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 5, .polarity = NORMAL }, // Power LED
+ { .name = "usb", .gpio = 1 << 7, .polarity = NORMAL }, // USB LED
+ { .name = "ses_amber", .gpio = 1 << 0, .polarity = REVERSE }, // WiFi protected setup LED amber
+ { .name = "ses_blue", .gpio = 1 << 3, .polarity = REVERSE }, // WiFi protected setup LED blue
+ { .name = "wlan", .gpio = 1 << 1, .polarity = NORMAL }, // Wireless LED
+ },
+ },
+ /* same hardware as WRT160NV3 and Cisco Valet M10V1, but different board detection, combine? */
+ [E1000V1] = {
+ .name = "Linksys E1000 V1",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 6 },
+ { .name = "wps", .gpio = 1 << 5 }, /* nvram get gpio5=wps_button */
+ },
+ .leds = {
+ /** turns on leds for all ethernet ports (wan too)
+ * this also disconnects some, or maybe all, ethernet ports
+ * 1: leds work normally
+ * 0: all lit all the time */
+ /* nvram get gpio3=robo_reset */
+ { .name = "wlan", .gpio = 1 << 0, .polarity = NORMAL },
+ { .name = "power", .gpio = 1 << 1, .polarity = NORMAL },
+ { .name = "ses_blue", .gpio = 1 << 4, .polarity = REVERSE }, /* nvram get gpio4=wps_led */
+ { .name = "ses_orange", .gpio = 1 << 2, .polarity = REVERSE }, /* nvram get gpio2=wps_status_led */
+ },
+ },
+ [E3000V1] = {
+ .name = "Linksys E3000 V1",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 6 },
+ { .name = "ses", .gpio = 1 << 4 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 5, .polarity = NORMAL }, // Power LED
+ { .name = "usb", .gpio = 1 << 7, .polarity = NORMAL }, // USB LED
+ { .name = "ses_amber", .gpio = 1 << 0, .polarity = REVERSE }, // WiFi protected setup LED amber
+ { .name = "ses_blue", .gpio = 1 << 3, .polarity = REVERSE }, // WiFi protected setup LED blue
+ { .name = "wlan", .gpio = 1 << 1, .polarity = NORMAL }, // Wireless LED
+ },
+ },
+ [E3200V1] = {
+ .name = "Linksys E3200 V1",
+ .buttons = {
+ /* { .name = "switch", .gpio = 1 << 4 },*/ /* nvram get gpio4=robo_reset */
+ { .name = "reset", .gpio = 1 << 5 }, /* nvram get reset_gpio=5 */
+ { .name = "wps", .gpio = 1 << 8 }, /* nvram get gpio8=wps_button */
+ /* { .name = "wombo", .gpio = 1 << 23 },*/ /* nvram get gpio23=wombo_reset - wireless on motherboard */
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 3, .polarity = REVERSE }, /* Power LED */
+ },
+ },
+ /* Asus */
+ [WLHDD] = {
+ .name = "ASUS WL-HDD",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 6 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 0, .polarity = REVERSE },
+ { .name = "usb", .gpio = 1 << 2, .polarity = REVERSE },
+ },
+ },
+ [WL300G] = {
+ .name = "ASUS WL-300g",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 6 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 0, .polarity = REVERSE },
+ },
+ },
+ [WL320GE] = {
+ .name = "ASUS WL-320gE/WL-320gP",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 6 },
+ },
+ .leds = {
+ { .name = "wlan", .gpio = 1 << 0, .polarity = REVERSE },
+ { .name = "power", .gpio = 1 << 2, .polarity = REVERSE },
+ { .name = "link", .gpio = 1 << 11, .polarity = REVERSE },
+ },
+ },
+ [WL330GE] = {
+ .name = "ASUS WL-330gE",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 2 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 0, .polarity = REVERSE },
+ },
+ },
+ [WL500G] = {
+ .name = "ASUS WL-500g",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 6 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 0, .polarity = REVERSE },
+ },
+ },
+ [WL500GD] = {
+ .name = "ASUS WL-500g Deluxe",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 6 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 0, .polarity = REVERSE },
+ },
+ },
+ [WL500GP] = {
+ .name = "ASUS WL-500g Premium",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 0 },
+ { .name = "ses", .gpio = 1 << 4 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 1, .polarity = REVERSE },
+ },
+ },
+ [WL500GPV2] = {
+ .name = "ASUS WL-500g Premium V2",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 2 },
+ { .name = "ses", .gpio = 1 << 3 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 0, .polarity = REVERSE },
+ { .name = "wlan", .gpio = 1 << 1, .polarity = REVERSE },
+ },
+ },
+ [WL500W] = {
+ .name = "ASUS WL-500W",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 6 },
+ { .name = "ses", .gpio = 1 << 7 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 5, .polarity = REVERSE },
+ },
+ },
+ [WL520GC] = {
+ .name = "ASUS WL-520GC",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 2 },
+ { .name = "ses", .gpio = 1 << 3 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 0, .polarity = REVERSE },
+ { .name = "wlan", .gpio = 1 << 1, .polarity = REVERSE },
+ },
+ },
+ [WL520GU] = {
+ .name = "ASUS WL-520gU",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 2 },
+ { .name = "ses", .gpio = 1 << 3 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 0, .polarity = REVERSE },
+ { .name = "wlan", .gpio = 1 << 1, .polarity = REVERSE },
+ },
+ },
+ [ASUS_4702] = {
+ .name = "ASUS (unknown, BCM4702)",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 6 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 0, .polarity = REVERSE },
+ },
+ },
+ [WL700GE] = {
+ .name = "ASUS WL-700gE",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 7 }, // on back, hardwired, always resets device regardless OS state
+ { .name = "ses", .gpio = 1 << 4 }, // on back, actual name ezsetup
+ { .name = "power", .gpio = 1 << 0 }, // on front
+ { .name = "copy", .gpio = 1 << 6 }, // on front
+ },
+ .leds = {
+#if 0
+ // GPIO that controls power led also enables/disables some essential functions
+ // - power to HDD
+ // - switch leds
+ { .name = "power", .gpio = 1 << 3, .polarity = NORMAL }, // actual name power
+#endif
+ { .name = "diag", .gpio = 1 << 1, .polarity = REVERSE }, // actual name ready
+ },
+ .platform_init = bcm4780_init,
+ },
+ [RTN16] = {
+ .name = "ASUS RT-N16",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 8 },
+ { .name = "ses", .gpio = 1 << 5 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 1, .polarity = REVERSE },
+ { .name = "wlan", .gpio = 1 << 7, .polarity = NORMAL },
+ },
+ },
+ /* Buffalo */
+ [WHR_G54S] = {
+ .name = "Buffalo WHR-G54S",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 4 },
+ { .name = "bridge", .gpio = 1 << 5 },
+ { .name = "ses", .gpio = 1 << 0 },
+ },
+ .leds = {
+ { .name = "diag", .gpio = 1 << 7, .polarity = REVERSE },
+ { .name = "internal", .gpio = 1 << 3, .polarity = REVERSE },
+ { .name = "ses", .gpio = 1 << 6, .polarity = REVERSE },
+ { .name = "bridge", .gpio = 1 << 1, .polarity = REVERSE },
+ { .name = "wlan", .gpio = 1 << 2, .polarity = REVERSE },
+ },
+ },
+ [WBR2_G54] = {
+ .name = "Buffalo WBR2-G54",
+ /* FIXME: verify */
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 7 },
+ },
+ .leds = {
+ { .name = "diag", .gpio = 1 << 1, .polarity = REVERSE },
+ },
+ },
+ [WHR_HP_G54] = {
+ .name = "Buffalo WHR-HP-G54",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 4 },
+ { .name = "bridge", .gpio = 1 << 5 },
+ { .name = "ses", .gpio = 1 << 0 },
+ },
+ .leds = {
+ { .name = "diag", .gpio = 1 << 7, .polarity = REVERSE },
+ { .name = "internal", .gpio = 1 << 3, .polarity = REVERSE },
+ { .name = "bridge", .gpio = 1 << 1, .polarity = REVERSE },
+ { .name = "ses", .gpio = 1 << 6, .polarity = REVERSE },
+ { .name = "wlan", .gpio = 1 << 2, .polarity = REVERSE },
+ },
+ },
+ [WHR_G125] = {
+ .name = "Buffalo WHR-G125",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 4 },
+ { .name = "bridge", .gpio = 1 << 5 },
+ { .name = "ses", .gpio = 1 << 0 },
+ },
+ .leds = {
+ { .name = "diag", .gpio = 1 << 7, .polarity = REVERSE },
+ { .name = "internal", .gpio = 1 << 3, .polarity = REVERSE },
+ { .name = "bridge", .gpio = 1 << 1, .polarity = REVERSE },
+ { .name = "ses", .gpio = 1 << 6, .polarity = REVERSE },
+ { .name = "wlan", .gpio = 1 << 2, .polarity = REVERSE },
+ },
+ },
+ [WHR2_A54G54] = {
+ .name = "Buffalo WHR2-A54G54",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 4 },
+ },
+ .leds = {
+ { .name = "diag", .gpio = 1 << 7, .polarity = REVERSE },
+ },
+ },
+ [WLA2_G54L] = {
+ .name = "Buffalo WLA2-G54L",
+ /* FIXME: verify */
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 7 },
+ },
+ .leds = {
+ { .name = "diag", .gpio = 1 << 1, .polarity = REVERSE },
+ },
+ },
+ [WZR_G300N] = {
+ .name = "Buffalo WZR-G300N",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 4 },
+ },
+ .leds = {
+ { .name = "diag", .gpio = 1 << 7, .polarity = REVERSE },
+ { .name = "bridge", .gpio = 1 << 1, .polarity = REVERSE },
+ { .name = "ses", .gpio = 1 << 6, .polarity = REVERSE },
+ },
+ },
+ [WZR_RS_G54] = {
+ .name = "Buffalo WZR-RS-G54",
+ .buttons = {
+ { .name = "ses", .gpio = 1 << 0 },
+ { .name = "reset", .gpio = 1 << 4 },
+ },
+ .leds = {
+ { .name = "diag", .gpio = 1 << 7, .polarity = REVERSE },
+ { .name = "ses", .gpio = 1 << 6, .polarity = REVERSE },
+ { .name = "vpn", .gpio = 1 << 1, .polarity = REVERSE },
+ },
+ },
+ [WZR_RS_G54HP] = {
+ .name = "Buffalo WZR-RS-G54HP",
+ .buttons = {
+ { .name = "ses", .gpio = 1 << 0 },
+ { .name = "reset", .gpio = 1 << 4 },
+ },
+ .leds = {
+ { .name = "diag", .gpio = 1 << 7, .polarity = REVERSE },
+ { .name = "ses", .gpio = 1 << 6, .polarity = REVERSE },
+ { .name = "vpn", .gpio = 1 << 1, .polarity = REVERSE },
+ },
+ },
+ [BUFFALO_UNKNOWN] = {
+ .name = "Buffalo (unknown)",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 7 },
+ },
+ .leds = {
+ { .name = "diag", .gpio = 1 << 1, .polarity = REVERSE },
+ },
+ },
+ [BUFFALO_UNKNOWN_4710] = {
+ .name = "Buffalo (unknown, BCM4710)",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 4 },
+ },
+ .leds = {
+ { .name = "diag", .gpio = 1 << 1, .polarity = REVERSE },
+ },
+ },
+ /* Siemens */
+ [SE505V1] = {
+ .name = "Siemens SE505 V1",
+ .buttons = {
+ /* No usable buttons */
+ },
+ .leds = {
+// { .name = "power", .gpio = 1 << 0 .polarity = REVERSE }, // Usable when retrofitting D26 (?)
+ { .name = "dmz", .gpio = 1 << 4, .polarity = REVERSE }, // actual name WWW
+ { .name = "wlan", .gpio = 1 << 3, .polarity = REVERSE },
+ },
+ },
+ [SE505V2] = {
+ .name = "Siemens SE505 V2",
+ .buttons = {
+ /* No usable buttons */
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 5, .polarity = REVERSE },
+ { .name = "dmz", .gpio = 1 << 0, .polarity = REVERSE }, // actual name WWW
+ { .name = "wlan", .gpio = 1 << 3, .polarity = REVERSE },
+ },
+ },
+ /* US Robotics */
+ [USR5461] = {
+ .name = "U.S. Robotics USR5461",
+ .buttons = {
+ /* No usable buttons */
+ },
+ .leds = {
+ { .name = "wlan", .gpio = 1 << 0, .polarity = REVERSE },
+ { .name = "printer", .gpio = 1 << 1, .polarity = REVERSE },
+ },
+ },
+ /* Dell */
+ [TM2300] = {
+ .name = "Dell TrueMobile 2300",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 0 },
+ },
+ .leds = {
+ { .name = "wlan", .gpio = 1 << 6, .polarity = REVERSE },
+ { .name = "power", .gpio = 1 << 7, .polarity = REVERSE },
+ },
+ },
+ [TM2300V2] = {
+ .name = "Dell TrueMobile 2300 v2",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 0 },
+ },
+ .leds = {
+ { .name = "wlan", .gpio = 1 << 6, .polarity = REVERSE },
+ { .name = "power", .gpio = 1 << 7, .polarity = REVERSE },
+ },
+ },
+ /* Motorola */
+ [WE800G] = {
+ .name = "Motorola WE800G",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 0 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 4, .polarity = NORMAL },
+ { .name = "diag", .gpio = 1 << 2, .polarity = REVERSE },
+ { .name = "wlan_amber", .gpio = 1 << 1, .polarity = NORMAL },
+ },
+ },
+ [WR850GV1] = {
+ .name = "Motorola WR850G V1",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 0 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 4, .polarity = NORMAL },
+ { .name = "diag", .gpio = 1 << 3, .polarity = REVERSE },
+ { .name = "dmz", .gpio = 1 << 6, .polarity = NORMAL },
+ { .name = "wlan_red", .gpio = 1 << 5, .polarity = REVERSE },
+ { .name = "wlan_green", .gpio = 1 << 7, .polarity = REVERSE },
+ },
+ },
+ [WR850GV2V3] = {
+ .name = "Motorola WR850G V2/V3",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 5 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 1, .polarity = NORMAL },
+ { .name = "wlan", .gpio = 1 << 0, .polarity = REVERSE },
+ { .name = "wan", .gpio = 1 << 6, .polarity = INPUT },
+ { .name = "diag", .gpio = 1 << 7, .polarity = REVERSE },
+ },
+ },
+ [WR850GP] = {
+ .name = "Motorola WR850GP",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 5 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 1, .polarity = NORMAL },
+ { .name = "wlan", .gpio = 1 << 0, .polarity = REVERSE },
+ { .name = "dmz", .gpio = 1 << 6, .polarity = REVERSE },
+ { .name = "diag", .gpio = 1 << 7, .polarity = REVERSE },
+ },
+ },
+
+ /* Belkin */
+ [BELKIN_UNKNOWN] = {
+ .name = "Belkin (unknown)",
+ /* FIXME: verify & add detection */
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 7 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 5, .polarity = NORMAL },
+ { .name = "wlan", .gpio = 1 << 3, .polarity = NORMAL },
+ { .name = "connected", .gpio = 1 << 0, .polarity = NORMAL },
+ },
+ },
+ [BELKIN_F7D4301] = {
+ .name = "Belkin PlayMax F7D4301",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 6 },
+ { .name = "wps", .gpio = 1 << 8 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 11, .polarity = REVERSE },
+ { .name = "wlan", .gpio = 1 << 13, .polarity = REVERSE },
+ { .name = "led0", .gpio = 1 << 14, .polarity = REVERSE },
+ { .name = "led1", .gpio = 1 << 15, .polarity = REVERSE },
+ },
+ },
+ /* Netgear */
+ [WGT634U] = {
+ .name = "Netgear WGT634U",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 2 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 3, .polarity = NORMAL },
+ },
+ },
+ /* Netgear */
+ [WNR834BV1] = {
+ .name = "Netgear WNR834B V1",
+ .buttons = { /* TODO: add reset button and confirm LEDs - GPIO from dd-wrt */ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 4, .polarity = REVERSE },
+ { .name = "diag", .gpio = 1 << 5, .polarity = REVERSE },
+ { .name = "wlan", .gpio = 1 << 6, .polarity = REVERSE },
+ },
+ },
+ /* Netgear */
+ [WNR834BV2] = {
+ .name = "Netgear WNR834B V2",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 6 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 2, .polarity = NORMAL },
+ { .name = "diag", .gpio = 1 << 3, .polarity = NORMAL },
+ { .name = "connected", .gpio = 1 << 7, .polarity = NORMAL },
+ },
+ },
+ [WNDR3400V1] = {
+ .name = "Netgear WNDR3400 V1",
+ .buttons = {
+ /* nvram get gpio5=robo_reset */
+ { .name = "reset", .gpio = 1 << 4 },
+ { .name = "wps", .gpio = 1 << 6 },
+ { .name = "wlan", .gpio = 1 << 8 },
+ },
+ .leds = {
+ { .name = "wlan", .gpio = 0 << 0, .polarity = NORMAL },
+ { .name = "connected", .gpio = 1 << 0, .polarity = NORMAL },
+ { .name = "power", .gpio = 1 << 3, .polarity = NORMAL },
+ { .name = "diag", .gpio = 1 << 7, .polarity = NORMAL },
+ { .name = "usb", .gpio = 1 << 2, .polarity = REVERSE },
+ },
+ },
+ /* Trendware */
+ [TEW411BRPP] = {
+ .name = "Trendware TEW411BRP+",
+ .buttons = {
+ { /* No usable buttons */ },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 7, .polarity = NORMAL },
+ { .name = "wlan", .gpio = 1 << 1, .polarity = NORMAL },
+ { .name = "bridge", .gpio = 1 << 6, .polarity = NORMAL },
+ },
+ },
+ /* SimpleTech */
+ [STI_NAS] = {
+ .name = "SimpleTech SimpleShare NAS",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 0 }, // Power button on back, named reset to enable failsafe.
+ },
+ .leds = {
+ { .name = "diag", .gpio = 1 << 1, .polarity = REVERSE }, // actual name ready
+ },
+ .platform_init = bcm4780_init,
+ },
+ /* D-Link */
+ [DIR130] = {
+ .name = "D-Link DIR-130",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 3},
+ { .name = "reserved", .gpio = 1 << 7},
+ },
+ .leds = {
+ { .name = "diag", .gpio = 1 << 0},
+ { .name = "blue", .gpio = 1 << 6},
+ },
+ },
+ [DIR320] = {
+ .name = "D-Link DIR-320",
+ .buttons = {
+ { .name = "reserved", .gpio = 1 << 6},
+ { .name = "reset", .gpio = 1 << 7},
+ },
+ .leds = {
+ { .name = "wlan", .gpio = 1 << 0, .polarity = NORMAL },
+ { .name = "diag", .gpio = 1 << 1, .polarity = NORMAL }, /* "status led */
+ { .name = "red", .gpio = 1 << 3, .polarity = REVERSE },
+ { .name = "blue", .gpio = 1 << 4, .polarity = REVERSE },
+ { .name = "usb", .gpio = 1 << 5, .polarity = NORMAL },
+ },
+ },
+ [DIR330] = {
+ .name = "D-Link DIR-330",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 3},
+ { .name = "reserved", .gpio = 1 << 7},
+ },
+ .leds = {
+ { .name = "diag", .gpio = 1 << 0},
+ { .name = "usb", .gpio = 1 << 4},
+ { .name = "blue", .gpio = 1 << 6},
+ },
+ },
+ [DWL3150] = {
+ .name = "D-Link DWL-3150",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 7},
+ },
+ .leds = {
+ { .name = "diag", .gpio = 1 << 2},
+ { .name = "status", .gpio = 1 << 1},
+ },
+ },
+ /* Double check */
+ [WL105B] = {
+ .name = "Sitecom WL-105b",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 10},
+ },
+ .leds = {
+ { .name = "wlan", .gpio = 1 << 4},
+ { .name = "power", .gpio = 1 << 3},
+ },
+ },
+ /* Western Digital Net Center */
+ [WDNetCenter] = {
+ .name = "Western Digital NetCenter",
+ .buttons = {
+ { .name = "power", .gpio = 1 << 0},
+ { .name = "reset", .gpio = 1 << 7},
+ },
+ .platform_init = NetCenter_init,
+ },
+ /* Askey (and clones) */
+ [RT210W] = {
+ .name = "Askey RT210W",
+ .buttons = {
+ /* Power button is hard-wired to hardware reset */
+ /* but is also connected to GPIO 7 (probably for bootloader recovery) */
+ { .name = "power", .gpio = 1 << 7},
+ },
+ .leds = {
+ /* These were verified and named based on Belkin F5D4230-4 v1112 */
+ { .name = "connected", .gpio = 1 << 0, .polarity = REVERSE },
+ { .name = "wlan", .gpio = 1 << 3, .polarity = REVERSE },
+ { .name = "power", .gpio = 1 << 5, .polarity = REVERSE },
+ },
+ },
+ [WL1600GL] = {
+ .name = "OvisLink WL-1600GL",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 3 },
+ { .name = "ses", .gpio = 1 << 4 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 5, .polarity = REVERSE },
+ { .name = "wps", .gpio = 1 << 2, .polarity = REVERSE },
+ { .name = "wlan", .gpio = 1 << 1, .polarity = REVERSE },
+ { .name = "connected", .gpio = 1 << 0, .polarity = REVERSE },
+ },
+ },
+ /* Microsoft */
+ [MN700] = {
+ .name = "Microsoft MN-700",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 7 },
+ },
+ .leds = {
+ { .name = "power", .gpio = 1 << 6, .polarity = NORMAL },
+ },
+ },
+ /* Edimax */
+ [PS1208MFG] = {
+ .name = "Edimax PS-1208MFG",
+ .buttons = {
+ { .name = "reset", .gpio = 1 << 4 },
+ },
+ .leds = {
+ { .name = "status", .gpio = 1 << 1, .polarity = NORMAL },
+ { .name = "wlan", .gpio = 1 << 0, .polarity = NORMAL },
+ },
+ },
+};
+
+static struct platform_t __init *platform_detect_legacy(void)
+{
+ char *boardnum, *boardtype, *buf;
+
+ if (strcmp(getvar("nvram_type"), "cfe") == 0)
+ return &platforms[WGT634U];
+
+
+ /* no easy model number, attempt to guess */
+ boardnum = getvar("boardnum");
+ boardtype = getvar("boardtype");
+
+ if (!strcmp(boardnum, "20070615")) { /* Linksys WRT600N v1/V1.1 */
+ if (!strcmp(boardtype, "0x478") && !strcmp(getvar("cardbus"), "0") && !strcmp(getvar("switch_type"),"BCM5395"))
+ return &platforms[WRT600NV11];
+
+ if (!strcmp(boardtype, "0x478") && !strcmp(getvar("cardbus"), "0"))
+ return &platforms[WRT600N];
+ }
+
+ if (startswith(getvar("pmon_ver"), "CFE")) {
+ /* CFE based - newer hardware */
+ if (!strcmp(boardnum, "42")) { /* Linksys */
+ if (!strcmp(boardtype, "0x478") && !strcmp(getvar("cardbus"), "1"))
+ return &platforms[WRT350N];
+
+ if (!strcmp(boardtype, "0x0101") && !strcmp(getvar("boot_ver"), "v3.6"))
+ return &platforms[WRT54G3G];
+
+ if (!strcmp(getvar("et1phyaddr"),"5") && !strcmp(getvar("et1mdcport"), "1"))
+ return &platforms[WRTSL54GS];
+
+ /* default to WRT54G */
+ return &platforms[WRT54G];
+ }
+ if (!strcmp(boardnum, "1024") && !strcmp(boardtype, "0x0446"))
+ return &platforms[WAP54GV2];
+
+ if (!strcmp(boardnum, "8") && !strcmp(boardtype, "0x048e"))
+ return &platforms[WL1600GL];
+
+
+ if (!strcmp(boardnum, "44") || !strcmp(boardnum, "44\r")) {
+ if (!strcmp(boardtype,"0x0101") || !strcmp(boardtype, "0x0101\r"))
+ return &platforms[TM2300V2]; /* Dell TrueMobile 2300 v2 */
+ }
+
+ if (!strcmp(boardnum, "45")) { /* ASUS */
+ if (!strcmp(boardtype,"0x0472"))
+ return &platforms[WL500W];
+ else if (!strcmp(boardtype,"0x467"))
+ return &platforms[WL320GE];
+ else
+ return &platforms[WL500GD];
+ }
+
+ if (!strcmp(boardnum, "10496"))
+ return &platforms[USR5461];
+
+ if (!strcmp(getvar("boardtype"), "0x0101") && !strcmp(getvar("boardrev"), "0x10")) /* SE505V2 With Modified CFE */
+ return &platforms[SE505V2];
+
+ if (!strcmp(boardtype, "0x048e") && !strcmp(getvar("boardrev"),"0x35") &&
+ !strcmp(getvar("boardflags"), "0x750")) /* D-Link DIR-320 */
+ return &platforms[DIR320];
+
+ if (!strncmp(boardnum, "TH",2) && !strcmp(boardtype,"0x042f")) {
+ return &platforms[WDNetCenter];
+ }
+
+ if (!strcmp(boardtype,"0x0472") && !strcmp(getvar("cardbus"), "1")) { /* Netgear WNR834B V1 and V2*/
+ if (!strcmp(boardnum, "08") || !strcmp(boardnum, "8"))
+ return &platforms[WNR834BV1];
+ if (!strcmp(boardnum, "01") || !strcmp(boardnum, "1"))
+ return &platforms[WNR834BV2];
+ }
+
+ } else { /* PMON based - old stuff */
+ if ((simple_strtoul(getvar("GemtekPmonVer"), NULL, 0) == 9) &&
+ (simple_strtoul(getvar("et0phyaddr"), NULL, 0) == 30)) {
+ return &platforms[WR850GV1];
+ }
+ if (startswith(boardtype, "bcm94710dev")) {
+ if (!strcmp(boardnum, "42"))
+ return &platforms[WRT54GV1];
+ if (simple_strtoul(boardnum, NULL, 0) == 2)
+ return &platforms[WAP54GV1];
+ }
+ /* MN-700 has also hardware_version 'WL500-...', so use boardnum */
+ if (startswith(getvar("hardware_version"), "WL500-")) {
+ if (!strcmp(getvar("boardnum"), "mn700"))
+ return &platforms[MN700];
+ else
+ return &platforms[WL500G];
+ }
+ if (startswith(getvar("hardware_version"), "WL300-")) {
+ /* Either WL-300g or WL-HDD, do more extensive checks */
+ if ((simple_strtoul(getvar("et0phyaddr"), NULL, 0) == 0) &&
+ (simple_strtoul(getvar("et1phyaddr"), NULL, 0) == 1))
+ return &platforms[WLHDD];
+ if ((simple_strtoul(getvar("et0phyaddr"), NULL, 0) == 0) &&
+ (simple_strtoul(getvar("et1phyaddr"), NULL, 0) == 10))
+ return &platforms[WL300G];
+ }
+ /* Sitecom WL-105b */
+ if (startswith(boardnum, "2") && simple_strtoul(getvar("GemtekPmonVer"), NULL, 0) == 1)
+ return &platforms[WL105B];
+
+ /* unknown asus stuff, probably bcm4702 */
+ if (startswith(boardnum, "asusX"))
+ return &platforms[ASUS_4702];
+
+ /* bcm4702 based Askey RT210W clones, Including:
+ * Askey RT210W (duh?)
+ * Siemens SE505v1
+ * Belkin F5D7230-4 before version v1444 (MiniPCI slot, not integrated)
+ */
+ if (!strcmp(boardtype,"bcm94710r4")
+ && !strcmp(boardnum ,"100")
+ && !strcmp(getvar("pmon_ver"),"v1.03.12.bk")
+ ){
+ return &platforms[RT210W];
+ }
+ }
+
+ if (buf || !strcmp(boardnum, "00")) {/* probably buffalo */
+ if (startswith(boardtype, "bcm94710ap"))
+ return &platforms[BUFFALO_UNKNOWN_4710];
+ else
+ return &platforms[BUFFALO_UNKNOWN];
+ }
+
+ if (startswith(getvar("CFEver"), "MotoWRv2") ||
+ startswith(getvar("CFEver"), "MotoWRv3") ||
+ !strcmp(getvar("MOTO_BOARD_TYPE"), "WR_FEM1")) {
+
+ return &platforms[WR850GV2V3];
+ }
+
+ if (!strcmp(boardnum, "44") && !strcmp(getvar("boardflags"),"0x0388")) { /* Trendware TEW-411BRP+ */
+ return &platforms[TEW411BRPP];
+ }
+
+ if (startswith(boardnum, "04FN")) /* SimpleTech SimpleShare */
+ return &platforms[STI_NAS];
+
+ if (!strcmp(boardnum, "10") && !strcmp(getvar("boardrev"), "0x13")) /* D-Link DWL-3150 */
+ return &platforms[DWL3150];
+
+ if (!strcmp(boardnum, "01") && !strcmp(boardtype, "0x048e") && /* Edimax PS1208MFG */
+ !strcmp(getvar("status_gpio"), "1")) /* gpio based detection */
+ return &platforms[PS1208MFG];
+
+ /* not found */
+ return NULL;
+}
+
+static struct platform_t __init *platform_detect(void)
+{
+ enum bcm47xx_board board;
+ const char *board_name;
+
+
+ board = bcm47xx_board_get();
+ board_name = bcm47xx_board_get_name();
+ if (board != BCM47XX_BOARD_UNKNOWN && board != BCM47XX_BOARD_NON)
+ printk(MODULE_NAME ": kernel found a \"%s\"\n", board_name);
+
+ switch(board) {
+ case BCM47XX_BOARD_ASUS_RTN16:
+ return &platforms[RTN16];
+ case BCM47XX_BOARD_ASUS_WL330GE:
+ return &platforms[WL330GE];
+ case BCM47XX_BOARD_ASUS_WL500GPV1:
+ return &platforms[WL500GP];
+ case BCM47XX_BOARD_ASUS_WL500GPV2:
+ return &platforms[WL500GPV2];
+ case BCM47XX_BOARD_ASUS_WL520GC:
+ return &platforms[WL520GC];
+ case BCM47XX_BOARD_ASUS_WL520GU:
+ return &platforms[WL520GU];
+ case BCM47XX_BOARD_ASUS_WL700GE:
+ return &platforms[WL700GE];
+ case BCM47XX_BOARD_BELKIN_F7D4301:
+ return &platforms[BELKIN_F7D4301];
+ case BCM47XX_BOARD_BUFFALO_WBR2_G54:
+ return &platforms[WBR2_G54];
+ case BCM47XX_BOARD_BUFFALO_WHR2_A54G54:
+ return &platforms[WHR2_A54G54];
+ case BCM47XX_BOARD_BUFFALO_WHR_G125:
+ return &platforms[WHR_G125];
+ case BCM47XX_BOARD_BUFFALO_WHR_G54S:
+ return &platforms[WHR_G54S];
+ case BCM47XX_BOARD_BUFFALO_WHR_HP_G54:
+ return &platforms[WHR_HP_G54];
+ case BCM47XX_BOARD_BUFFALO_WLA2_G54L:
+ return &platforms[WLA2_G54L];
+ case BCM47XX_BOARD_BUFFALO_WZR_G300N:
+ return &platforms[WZR_G300N];
+ case BCM47XX_BOARD_BUFFALO_WZR_RS_G54:
+ return &platforms[WZR_RS_G54];
+ case BCM47XX_BOARD_BUFFALO_WZR_RS_G54HP:
+ return &platforms[WZR_RS_G54HP];
+ case BCM47XX_BOARD_DELL_TM2300:
+ return &platforms[TM2300];
+ case BCM47XX_BOARD_DLINK_DIR130:
+ return &platforms[DIR130];
+ case BCM47XX_BOARD_DLINK_DIR330:
+ return &platforms[DIR330];
+ case BCM47XX_BOARD_LINKSYS_E1000V1:
+ return &platforms[E1000V1];
+ case BCM47XX_BOARD_LINKSYS_E3000V1:
+ return &platforms[E3000V1];
+ case BCM47XX_BOARD_LINKSYS_E3200V1:
+ return &platforms[E3200V1];
+ case BCM47XX_BOARD_LINKSYS_WRT150NV1:
+ return &platforms[WRT150NV1];
+ case BCM47XX_BOARD_LINKSYS_WRT150NV11:
+ return &platforms[WRT150NV11];
+ case BCM47XX_BOARD_LINKSYS_WRT160NV1:
+ return &platforms[WRT160NV1];
+ case BCM47XX_BOARD_LINKSYS_WRT160NV3:
+ return &platforms[WRT160NV3];
+ case BCM47XX_BOARD_LINKSYS_WRT300NV11:
+ return &platforms[WRT300NV11];
+ case BCM47XX_BOARD_LINKSYS_WRT54G3GV2:
+ return &platforms[WRT54G3GV2_VF];
+ case BCM47XX_BOARD_LINKSYS_WRT610NV1:
+ return &platforms[WRT610N];
+ case BCM47XX_BOARD_LINKSYS_WRT610NV2:
+ return &platforms[WRT610NV2];
+ case BCM47XX_BOARD_MOTOROLA_WE800G:
+ return &platforms[WE800G];
+ case BCM47XX_BOARD_MOTOROLA_WR850GP:
+ return &platforms[WR850GP];
+ case BCM47XX_BOARD_MOTOROLA_WR850GV2V3:
+ return &platforms[WR850GV2V3];
+ case BCM47XX_BOARD_NETGEAR_WNDR3400V1:
+ return &platforms[WNDR3400V1];
+ case BCM47XX_BOARD_UNKNOWN:
+ case BCM47XX_BOARD_NON:
+ printk(MODULE_NAME ": unknown board found, try legacy detect\n");
+ printk(MODULE_NAME ": please open a ticket at https://dev.openwrt.org and attach the complete nvram\n");
+ return platform_detect_legacy();
+ default:
+ printk(MODULE_NAME ": board was detected as \"%s\", but not gpio configuration available\n", board_name);
+ printk(MODULE_NAME ": now trying legacy detect\n");
+ return platform_detect_legacy();
+ }
+}
+
+static inline void ssb_maskset32(struct ssb_device *dev,
+ u16 offset, u32 mask, u32 set)
+{
+ ssb_write32(dev, offset, (ssb_read32(dev, offset) & mask) | set);
+}
+
+static void gpio_set_irqenable(int enabled, irqreturn_t (*handler)(int, void *))
+{
+ int irq;
+
+ irq = gpio_to_irq(0);
+ if (irq == -EINVAL) return;
+
+ if (enabled) {
+ if (request_irq(irq, handler, IRQF_SHARED, "gpio", handler))
+ return;
+ } else {
+ free_irq(irq, handler);
+ }
+
+ switch (bcm47xx_bus_type) {
+#ifdef CONFIG_BCM47XX_SSB
+ case BCM47XX_BUS_TYPE_SSB:
+ if (bcm47xx_bus.ssb.chipco.dev)
+ ssb_maskset32(bcm47xx_bus.ssb.chipco.dev, SSB_CHIPCO_IRQMASK, ~SSB_CHIPCO_IRQ_GPIO, (enabled ? SSB_CHIPCO_IRQ_GPIO : 0));
+ break;
+#endif
+#ifdef CONFIG_BCM47XX_BCMA
+ case BCM47XX_BUS_TYPE_BCMA:
+ if (bcm47xx_bus.bcma.bus.drv_cc.core)
+ bcma_maskset32(bcm47xx_bus.bcma.bus.drv_cc.core, BCMA_CC_IRQMASK, ~BCMA_CC_IRQ_GPIO, (enabled ? BCMA_CC_IRQ_GPIO : 0));
+ break;
+#endif
+ }
+}
+
+static void register_buttons(struct button_t *b)
+{
+ for (; b->name; b++)
+ platform.button_mask |= b->gpio;
+
+ platform.button_mask &= ~gpiomask;
+
+ bcm47xx_gpio_outen(platform.button_mask, 0);
+ bcm47xx_gpio_control(platform.button_mask, 0);
+ platform.button_polarity = bcm47xx_gpio_in(~0) & platform.button_mask;
+ bcm47xx_gpio_polarity(platform.button_mask, platform.button_polarity);
+ bcm47xx_gpio_intmask(platform.button_mask, platform.button_mask);
+
+ gpio_set_irqenable(1, button_handler);
+}
+
+static void unregister_buttons(struct button_t *b)
+{
+ bcm47xx_gpio_intmask(platform.button_mask, 0);
+
+ gpio_set_irqenable(0, button_handler);
+}
+
+
+static void add_msg(struct event_t *event, char *msg, int argv)
+{
+ char *s;
+
+ if (argv)
+ return;
+
+ s = skb_put(event->skb, strlen(msg) + 1);
+ strcpy(s, msg);
+}
+
+static void hotplug_button(struct work_struct *work)
+{
+ struct event_t *event = container_of(work, struct event_t, wq);
+ char *s;
+
+ event->skb = alloc_skb(2048, GFP_KERNEL);
+
+ s = skb_put(event->skb, strlen(event->action) + 2);
+ sprintf(s, "%s@", event->action);
+ fill_event(event);
+
+ NETLINK_CB(event->skb).dst_group = 1;
+ broadcast_uevent(event->skb, 0, 1, GFP_KERNEL);
+
+ kfree(event);
+}
+
+
+static int fill_event (struct event_t *event)
+{
+ static char buf[128];
+
+ add_msg(event, "HOME=/", 0);
+ add_msg(event, "PATH=/sbin:/bin:/usr/sbin:/usr/bin", 0);
+ add_msg(event, "SUBSYSTEM=button", 0);
+ snprintf(buf, 128, "ACTION=%s", event->action);
+ add_msg(event, buf, 0);
+ snprintf(buf, 128, "BUTTON=%s", event->name);
+ add_msg(event, buf, 0);
+ snprintf(buf, 128, "SEEN=%ld", event->seen);
+ add_msg(event, buf, 0);
+ snprintf(buf, 128, "SEQNUM=%llu", uevent_next_seqnum());
+ add_msg(event, buf, 0);
+
+ return 0;
+}
+
+
+static irqreturn_t button_handler(int irq, void *dev_id)
+{
+ struct button_t *b;
+ u32 in, changed;
+
+ in = bcm47xx_gpio_in(~0) & platform.button_mask;
+ bcm47xx_gpio_polarity(platform.button_mask, in);
+ changed = platform.button_polarity ^ in;
+ platform.button_polarity = in;
+
+ changed &= ~bcm47xx_gpio_outen(0, 0);
+
+ for (b = platform.buttons; b->name; b++) {
+ struct event_t *event;
+
+ if (!(b->gpio & changed)) continue;
+
+ b->pressed ^= 1;
+
+ if ((event = (struct event_t *)kzalloc (sizeof(struct event_t), GFP_ATOMIC))) {
+ event->seen = (jiffies - b->seen)/HZ;
+ event->name = b->name;
+ event->action = b->pressed ? "pressed" : "released";
+ INIT_WORK(&event->wq, (void *)(void *)hotplug_button);
+ schedule_work(&event->wq);
+ }
+
+ b->seen = jiffies;
+ }
+ return IRQ_HANDLED;
+}
+
+static void register_leds(struct led_t *l)
+{
+ struct proc_dir_entry *p;
+ u32 mask = 0;
+ u32 oe_mask = 0;
+ u32 val = 0;
+
+ leds = proc_mkdir("led", diag);
+ if (!leds)
+ return;
+
+ for(; l->name; l++) {
+ if (l->gpio & gpiomask)
+ continue;
+
+ if (l->gpio & GPIO_TYPE_EXTIF) {
+ l->state = 0;
+ set_led_extif(l);
+ } else {
+ if (l->polarity != INPUT) oe_mask |= l->gpio;
+ mask |= l->gpio;
+ val |= (l->polarity == NORMAL)?0:l->gpio;
+ }
+
+ if (l->polarity == INPUT) continue;
+
+ if ((p = create_proc_entry(l->name, S_IRUSR, leds))) {
+ l->proc.type = PROC_LED;
+ l->proc.ptr = l;
+ p->data = (void *) &l->proc;
+ p->proc_fops = &diag_proc_fops;
+ }
+ }
+
+ bcm47xx_gpio_outen(mask, oe_mask);
+ bcm47xx_gpio_control(mask, 0);
+ bcm47xx_gpio_out(mask, val);
+ bcm47xx_gpio_intmask(mask, 0);
+}
+
+static void unregister_leds(struct led_t *l)
+{
+ for(; l->name; l++)
+ remove_proc_entry(l->name, leds);
+
+ remove_proc_entry("led", diag);
+}
+
+static void set_led_extif(struct led_t *led)
+{
+ volatile u8 *addr = (volatile u8 *) KSEG1ADDR(EXTIF_UART) + (led->gpio & ~GPIO_TYPE_MASK);
+ if (led->state)
+ *addr = 0xFF;
+ else
+ *addr;
+}
+
+static void led_flash(unsigned long dummy) {
+ struct led_t *l;
+ u32 mask = 0;
+ u8 extif_blink = 0;
+
+ for (l = platform.leds; l->name; l++) {
+ if (l->flash) {
+ if (l->gpio & GPIO_TYPE_EXTIF) {
+ extif_blink = 1;
+ l->state = !l->state;
+ set_led_extif(l);
+ } else {
+ mask |= l->gpio;
+ }
+ }
+ }
+
+ mask &= ~gpiomask;
+ if (mask) {
+ u32 val = ~bcm47xx_gpio_in(~0);
+
+ bcm47xx_gpio_outen(mask, mask);
+ bcm47xx_gpio_control(mask, 0);
+ bcm47xx_gpio_out(mask, val);
+ }
+ if (mask || extif_blink) {
+ mod_timer(&led_timer, jiffies + FLASH_TIME);
+ }
+}
+
+static ssize_t diag_proc_read(struct file *file, char *buf, size_t count, loff_t *ppos)
+{
+ struct proc_dir_entry *dent = PDE(file->f_dentry->d_inode);
+ char *page;
+ int len = 0;
+
+ if ((page = kmalloc(1024, GFP_KERNEL)) == NULL)
+ return -ENOBUFS;
+
+ if (dent->data != NULL) {
+ struct prochandler_t *handler = (struct prochandler_t *) dent->data;
+ switch (handler->type) {
+ case PROC_LED: {
+ struct led_t * led = (struct led_t *) handler->ptr;
+ if (led->flash) {
+ len = sprintf(page, "f\n");
+ } else {
+ if (led->gpio & GPIO_TYPE_EXTIF) {
+ len = sprintf(page, "%d\n", led->state);
+ } else {
+ u32 in = (bcm47xx_gpio_in(~0) & led->gpio ? 1 : 0);
+ u8 p = (led->polarity == NORMAL ? 0 : 1);
+ len = sprintf(page, "%d\n", ((in ^ p) ? 1 : 0));
+ }
+ }
+ break;
+ }
+ case PROC_MODEL:
+ len = sprintf(page, "%s\n", platform.name);
+ break;
+ case PROC_GPIOMASK:
+ len = sprintf(page, "0x%04x\n", gpiomask);
+ break;
+ }
+ }
+ len += 1;
+
+ if (*ppos < len) {
+ len = min_t(int, len - *ppos, count);
+ if (copy_to_user(buf, (page + *ppos), len)) {
+ kfree(page);
+ return -EFAULT;
+ }
+ *ppos += len;
+ } else {
+ len = 0;
+ }
+
+ kfree(page);
+ return len;
+}
+
+
+static ssize_t diag_proc_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
+{
+ struct proc_dir_entry *dent = PDE(file->f_dentry->d_inode);
+ char *page;
+ int ret = -EINVAL;
+
+ if ((page = kmalloc(count + 1, GFP_KERNEL)) == NULL)
+ return -ENOBUFS;
+
+ if (copy_from_user(page, buf, count)) {
+ kfree(page);
+ return -EINVAL;
+ }
+ page[count] = 0;
+
+ if (dent->data != NULL) {
+ struct prochandler_t *handler = (struct prochandler_t *) dent->data;
+ switch (handler->type) {
+ case PROC_LED: {
+ struct led_t *led = (struct led_t *) handler->ptr;
+ int p = (led->polarity == NORMAL ? 0 : 1);
+
+ if (page[0] == 'f') {
+ led->flash = 1;
+ led_flash(0);
+ } else {
+ led->flash = 0;
+ if (led->gpio & GPIO_TYPE_EXTIF) {
+ led->state = p ^ ((page[0] == '1') ? 1 : 0);
+ set_led_extif(led);
+ } else {
+ bcm47xx_gpio_outen(led->gpio, led->gpio);
+ bcm47xx_gpio_control(led->gpio, 0);
+ bcm47xx_gpio_out(led->gpio, ((p ^ (page[0] == '1')) ? led->gpio : 0));
+ }
+ }
+ break;
+ }
+ case PROC_GPIOMASK:
+ gpiomask = simple_strtoul(page, NULL, 0);
+
+ if (platform.buttons) {
+ unregister_buttons(platform.buttons);
+ register_buttons(platform.buttons);
+ }
+
+ if (platform.leds) {
+ unregister_leds(platform.leds);
+ register_leds(platform.leds);
+ }
+ break;
+ }
+ ret = count;
+ }
+
+ kfree(page);
+ return ret;
+}
+
+static int __init diag_init(void)
+{
+ static struct proc_dir_entry *p;
+ static struct platform_t *detected;
+
+ detected = platform_detect();
+ if (!detected) {
+ printk(MODULE_NAME ": Router model not detected.\n");
+ return -ENODEV;
+ }
+ memcpy(&platform, detected, sizeof(struct platform_t));
+
+ printk(MODULE_NAME ": Detected '%s'\n", platform.name);
+ if (platform.platform_init != NULL) {
+ platform.platform_init();
+ }
+
+ if (!(diag = proc_mkdir("diag", NULL))) {
+ printk(MODULE_NAME ": proc_mkdir on /proc/diag failed\n");
+ return -EINVAL;
+ }
+
+ if ((p = create_proc_entry("model", S_IRUSR, diag))) {
+ p->data = (void *) &proc_model;
+ p->proc_fops = &diag_proc_fops;
+ }
+
+ if ((p = create_proc_entry("gpiomask", S_IRUSR | S_IWUSR, diag))) {
+ p->data = (void *) &proc_gpiomask;
+ p->proc_fops = &diag_proc_fops;
+ }
+
+ if (platform.buttons)
+ register_buttons(platform.buttons);
+
+ if (platform.leds)
+ register_leds(platform.leds);
+
+ return 0;
+}
+
+static void __exit diag_exit(void)
+{
+ del_timer(&led_timer);
+
+ if (platform.buttons)
+ unregister_buttons(platform.buttons);
+
+ if (platform.leds)
+ unregister_leds(platform.leds);
+
+ remove_proc_entry("model", diag);
+ remove_proc_entry("gpiomask", diag);
+ remove_proc_entry("diag", NULL);
+}
+
+module_init(diag_init);
+module_exit(diag_exit);
+
+MODULE_AUTHOR("Mike Baker, Felix Fietkau / OpenWrt.org");
+MODULE_LICENSE("GPL");
diff --git a/package/broadcom-diag/src/diag.h b/package/broadcom-diag/src/diag.h
new file mode 100644
index 0000000..698c376
--- /dev/null
+++ b/package/broadcom-diag/src/diag.h
@@ -0,0 +1,134 @@
+/*
+ * diag.h - GPIO interface driver for Broadcom boards
+ *
+ * Copyright (C) 2006 Mike Baker <mbm@openwrt.org>,
+ * Felix Fietkau <nbd@openwrt.org>
+ *
+ * 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
+ * of the License, 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include <linux/irq.h>
+#define MODULE_NAME "diag"
+
+#define MAX_GPIO 16
+#define FLASH_TIME HZ/6
+
+enum polarity_t {
+ REVERSE = 0,
+ NORMAL = 1,
+ INPUT = 2,
+};
+
+enum {
+ PROC_BUTTON,
+ PROC_LED,
+ PROC_MODEL,
+ PROC_GPIOMASK
+};
+
+struct prochandler_t {
+ int type;
+ void *ptr;
+};
+
+struct button_t {
+ struct prochandler_t proc;
+ char *name;
+ u32 gpio;
+ unsigned long seen;
+ u8 pressed;
+};
+
+struct led_t {
+ struct prochandler_t proc;
+ char *name;
+ u32 gpio;
+ u8 polarity;
+ u8 flash;
+ u8 state;
+};
+
+struct platform_t {
+ char *name;
+
+ struct button_t buttons[MAX_GPIO];
+ u32 button_mask;
+ u32 button_polarity;
+ void (*platform_init)(void);
+
+ struct led_t leds[MAX_GPIO];
+};
+
+struct event_t {
+ struct work_struct wq;
+ unsigned long seen;
+ char *name, *action;
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,0)
+ struct sk_buff *skb;
+#else
+ char *scratch;
+ char *argv[4];
+ char *envp[7];
+ u8 enr, anr;
+#endif
+};
+
+extern char *nvram_get(char *str);
+
+static struct platform_t platform;
+
+/* buttons */
+
+static void register_buttons(struct button_t *b);
+static void unregister_buttons(struct button_t *b);
+
+static void hotplug_button(struct work_struct *work);
+static irqreturn_t button_handler(int irq, void *dev_id);
+
+/* leds */
+
+static void register_leds(struct led_t *l);
+static void unregister_leds(struct led_t *l);
+
+static void set_led_extif(struct led_t *led);
+static void led_flash(unsigned long dummy);
+
+/* 2.4 compatibility */
+#ifndef TIMER_INITIALIZER
+#define TIMER_INITIALIZER(_function, _expires, _data) \
+ { \
+ /* _expires and _data currently unused */ \
+ function: _function \
+ }
+#endif
+
+static struct timer_list led_timer = TIMER_INITIALIZER(&led_flash, 0, 0);
+
+/* proc */
+
+static struct proc_dir_entry *diag, *leds;
+
+static ssize_t diag_proc_read(struct file *file, char *buf, size_t count, loff_t *ppos);
+static ssize_t diag_proc_write(struct file *file, const char *buf, size_t count, loff_t *ppos);
+
+static struct file_operations diag_proc_fops = {
+ read: diag_proc_read,
+ write: diag_proc_write
+};
+
+static struct prochandler_t proc_model = { .type = PROC_MODEL };
+static struct prochandler_t proc_gpiomask = { .type = PROC_GPIOMASK };
+
diff --git a/package/broadcom-diag/src/gpio.h b/package/broadcom-diag/src/gpio.h
new file mode 100644
index 0000000..d0e3e06
--- /dev/null
+++ b/package/broadcom-diag/src/gpio.h
@@ -0,0 +1,16 @@
+#ifndef __DIAG_GPIO_H
+#define __DIAG_GPIO_H
+
+#include <linux/interrupt.h>
+#include <linux/ssb/ssb_embedded.h>
+#include <linux/gpio.h>
+#include <bcm47xx.h>
+
+#define EXTIF_ADDR 0x1f000000
+#define EXTIF_UART (EXTIF_ADDR + 0x00800000)
+
+#define GPIO_TYPE_NORMAL (0x0 << 24)
+#define GPIO_TYPE_EXTIF (0x1 << 24)
+#define GPIO_TYPE_MASK (0xf << 24)
+
+#endif /* __DIAG_GPIO_H */
diff --git a/package/broadcom-wl/.svn/entries b/package/broadcom-wl/.svn/entries
new file mode 100644
index 0000000..b57ff8c
--- /dev/null
+++ b/package/broadcom-wl/.svn/entries
@@ -0,0 +1,71 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/broadcom-wl
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-02-24T18:01:06.512491Z
+35767
+hauke
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+files
+dir
+
+patches
+dir
+
+src
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+0d425e77f80ddde307abeb991bd374db
+2012-10-04T12:36:45.562552Z
+33617
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4566
+
diff --git a/package/broadcom-wl/.svn/text-base/Makefile.svn-base b/package/broadcom-wl/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..1a7da0f
--- /dev/null
+++ b/package/broadcom-wl/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,175 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=broadcom-wl
+PKG_VERSION:=5.10.56.27.3
+PKG_RELEASE:=5
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)_$(ARCH).tar.bz2
+PKG_SOURCE_URL:=http://downloads.openwrt.org/sources
+
+PKG_MD5SUM.mipsel:=3363e3a6b3d9d73c49dea870c7834eac
+PKG_MD5SUM.mips:=f8de63debc75333d6b4e28193eb051ff
+PKG_MD5SUM:=$(PKG_MD5SUM.$(ARCH))
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/broadcom-wl/Default
+ SECTION:=kernel
+ CATEGORY:=Kernel modules
+ DEPENDS:=@PACKAGE_kmod-brcm-wl||PACKAGE_kmod-brcm-wl-mini
+ SUBMENU:=Proprietary BCM43xx WiFi driver
+ SUBMENUDEP:=@TARGET_brcm47xx||TARGET_brcm63xx
+endef
+
+define KernelPackage/brcm-wl/Default
+ $(call Package/broadcom-wl/Default)
+ SECTION:=kernel
+ DEPENDS:=@TARGET_brcm47xx||TARGET_brcm63xx +wireless-tools
+ TITLE:=Kernel driver for BCM43xx chipsets
+ FILES:=$(PKG_BUILD_DIR)/driver$(1)/wl.ko $(PKG_BUILD_DIR)/glue/wl_glue.ko
+ AUTOLOAD:=$(call AutoLoad,30,wl_glue wl)
+endef
+
+define KernelPackage/brcm-wl/Default/description
+ This package contains the proprietary wireless driver for the Broadcom
+ BCM43xx chipset.
+endef
+
+define KernelPackage/brcm-wl
+$(call KernelPackage/brcm-wl/Default,)
+ TITLE+= (normal version)
+endef
+
+define KernelPackage/brcm-wl/description
+$(call KernelPackage/brcm-wl/Default/description)
+endef
+
+define KernelPackage/brcm-wl-mini
+$(call KernelPackage/brcm-wl/Default,-mini)
+ TITLE+= (Legacy version)
+endef
+
+define KernelPackage/brcm-wl-mini/description
+$(call KernelPackage/brcm-wl/Default/description)
+endef
+
+define Package/wlc
+$(call Package/broadcom-wl/Default)
+ TITLE:=wl driver setup utility
+endef
+
+define Package/wlc/description
+ This package contains an utility for initializing the proprietary Broadcom
+ wl driver.
+endef
+
+define Package/wl
+$(call Package/broadcom-wl/Default)
+ TITLE:=Proprietary Broadcom wl driver config utility
+endef
+
+define Package/wl/description
+ This package contains the proprietary utility (wl) for configuring the
+ proprietary Broadcom wl driver.
+endef
+
+define Package/nas
+$(call Package/broadcom-wl/Default)
+ TITLE:=Proprietary Broadcom WPA/WPA2 authenticator
+endef
+
+define Package/nas/description
+ This package contains the proprietary WPA/WPA2 authenticator (nas) for the
+ proprietary Broadcom wl driver.
+endef
+
+MAKE_KMOD := $(MAKE) -C "$(LINUX_DIR)" \
+ CROSS_COMPILE="$(TARGET_CROSS)" \
+ ARCH="$(LINUX_KARCH)" \
+ PATH="$(TARGET_PATH)" \
+ SUBDIRS="$(PKG_BUILD_DIR)/kmod" \
+
+define Build/Prepare
+ $(call Build/Prepare/Default)
+ $(CP) $(PKG_BUILD_DIR)/driver $(PKG_BUILD_DIR)/driver-mini
+ $(CP) ./src/glue $(PKG_BUILD_DIR)/glue
+endef
+
+define Build/Compile
+ # Compile the kernel part
+ $(MAKE_KMOD) \
+ SUBDIRS="$(PKG_BUILD_DIR)/driver" \
+ MODFLAGS="-DMODULE -mlong-calls" \
+ modules
+
+ $(MAKE_KMOD) \
+ SUBDIRS="$(PKG_BUILD_DIR)/driver-mini" \
+ MODFLAGS="-DMODULE -mlong-calls" \
+ BUILD_TYPE="wl_apsta_mini" \
+ modules
+
+ # Compile glue driver
+ $(MAKE_KMOD) -C "$(LINUX_DIR)" \
+ SUBDIRS="$(PKG_BUILD_DIR)/glue" \
+ modules
+
+ # Compile libshared
+ $(MAKE) -C $(PKG_BUILD_DIR)/shared \
+ $(TARGET_CONFIGURE_OPTS) \
+ CFLAGS="$(TARGET_CFLAGS) -I. -I$(PKG_BUILD_DIR)/driver/include" \
+ all
+
+ $(TARGET_CC) -o $(PKG_BUILD_DIR)/wlc \
+ -I$(PKG_BUILD_DIR)/shared -I$(PKG_BUILD_DIR)/driver/include \
+ ./src/wlc.c $(PKG_BUILD_DIR)/shared/libshared.a
+
+ $(TARGET_CC) -o $(PKG_BUILD_DIR)/nas \
+ $(PKG_BUILD_DIR)/nas_exe.o \
+ $(PKG_BUILD_DIR)/shared/libshared.a
+
+ $(TARGET_CC) -o $(PKG_BUILD_DIR)/wl \
+ $(PKG_BUILD_DIR)/wl_exe.o \
+ $(PKG_BUILD_DIR)/shared/libshared.a
+endef
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_BUILD_DIR)/shared/libshared.a $(1)/usr/lib/
+endef
+
+define Package/wlc/install
+ $(CP) ./files/* $(1)/
+ $(INSTALL_DIR) $(1)/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/wlc $(1)/sbin/
+endef
+
+define Package/wlc/postinst
+#!/bin/sh
+[ -n "$${IPKG_INSTROOT}" ] || /etc/init.d/wlunbind enable || true
+endef
+
+define Package/wl/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/wl $(1)/usr/sbin/
+endef
+
+define Package/nas/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/nas $(1)/usr/sbin/
+ ln -sf nas $(1)/usr/sbin/nas4not
+ ln -sf nas $(1)/usr/sbin/nas4wds
+endef
+
+$(eval $(call KernelPackage,brcm-wl))
+$(eval $(call KernelPackage,brcm-wl-mini))
+$(eval $(call BuildPackage,wlc))
+$(eval $(call BuildPackage,wl))
+$(eval $(call BuildPackage,nas))
diff --git a/package/broadcom-wl/Makefile b/package/broadcom-wl/Makefile
new file mode 100644
index 0000000..1a7da0f
--- /dev/null
+++ b/package/broadcom-wl/Makefile
@@ -0,0 +1,175 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=broadcom-wl
+PKG_VERSION:=5.10.56.27.3
+PKG_RELEASE:=5
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)_$(ARCH).tar.bz2
+PKG_SOURCE_URL:=http://downloads.openwrt.org/sources
+
+PKG_MD5SUM.mipsel:=3363e3a6b3d9d73c49dea870c7834eac
+PKG_MD5SUM.mips:=f8de63debc75333d6b4e28193eb051ff
+PKG_MD5SUM:=$(PKG_MD5SUM.$(ARCH))
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/broadcom-wl/Default
+ SECTION:=kernel
+ CATEGORY:=Kernel modules
+ DEPENDS:=@PACKAGE_kmod-brcm-wl||PACKAGE_kmod-brcm-wl-mini
+ SUBMENU:=Proprietary BCM43xx WiFi driver
+ SUBMENUDEP:=@TARGET_brcm47xx||TARGET_brcm63xx
+endef
+
+define KernelPackage/brcm-wl/Default
+ $(call Package/broadcom-wl/Default)
+ SECTION:=kernel
+ DEPENDS:=@TARGET_brcm47xx||TARGET_brcm63xx +wireless-tools
+ TITLE:=Kernel driver for BCM43xx chipsets
+ FILES:=$(PKG_BUILD_DIR)/driver$(1)/wl.ko $(PKG_BUILD_DIR)/glue/wl_glue.ko
+ AUTOLOAD:=$(call AutoLoad,30,wl_glue wl)
+endef
+
+define KernelPackage/brcm-wl/Default/description
+ This package contains the proprietary wireless driver for the Broadcom
+ BCM43xx chipset.
+endef
+
+define KernelPackage/brcm-wl
+$(call KernelPackage/brcm-wl/Default,)
+ TITLE+= (normal version)
+endef
+
+define KernelPackage/brcm-wl/description
+$(call KernelPackage/brcm-wl/Default/description)
+endef
+
+define KernelPackage/brcm-wl-mini
+$(call KernelPackage/brcm-wl/Default,-mini)
+ TITLE+= (Legacy version)
+endef
+
+define KernelPackage/brcm-wl-mini/description
+$(call KernelPackage/brcm-wl/Default/description)
+endef
+
+define Package/wlc
+$(call Package/broadcom-wl/Default)
+ TITLE:=wl driver setup utility
+endef
+
+define Package/wlc/description
+ This package contains an utility for initializing the proprietary Broadcom
+ wl driver.
+endef
+
+define Package/wl
+$(call Package/broadcom-wl/Default)
+ TITLE:=Proprietary Broadcom wl driver config utility
+endef
+
+define Package/wl/description
+ This package contains the proprietary utility (wl) for configuring the
+ proprietary Broadcom wl driver.
+endef
+
+define Package/nas
+$(call Package/broadcom-wl/Default)
+ TITLE:=Proprietary Broadcom WPA/WPA2 authenticator
+endef
+
+define Package/nas/description
+ This package contains the proprietary WPA/WPA2 authenticator (nas) for the
+ proprietary Broadcom wl driver.
+endef
+
+MAKE_KMOD := $(MAKE) -C "$(LINUX_DIR)" \
+ CROSS_COMPILE="$(TARGET_CROSS)" \
+ ARCH="$(LINUX_KARCH)" \
+ PATH="$(TARGET_PATH)" \
+ SUBDIRS="$(PKG_BUILD_DIR)/kmod" \
+
+define Build/Prepare
+ $(call Build/Prepare/Default)
+ $(CP) $(PKG_BUILD_DIR)/driver $(PKG_BUILD_DIR)/driver-mini
+ $(CP) ./src/glue $(PKG_BUILD_DIR)/glue
+endef
+
+define Build/Compile
+ # Compile the kernel part
+ $(MAKE_KMOD) \
+ SUBDIRS="$(PKG_BUILD_DIR)/driver" \
+ MODFLAGS="-DMODULE -mlong-calls" \
+ modules
+
+ $(MAKE_KMOD) \
+ SUBDIRS="$(PKG_BUILD_DIR)/driver-mini" \
+ MODFLAGS="-DMODULE -mlong-calls" \
+ BUILD_TYPE="wl_apsta_mini" \
+ modules
+
+ # Compile glue driver
+ $(MAKE_KMOD) -C "$(LINUX_DIR)" \
+ SUBDIRS="$(PKG_BUILD_DIR)/glue" \
+ modules
+
+ # Compile libshared
+ $(MAKE) -C $(PKG_BUILD_DIR)/shared \
+ $(TARGET_CONFIGURE_OPTS) \
+ CFLAGS="$(TARGET_CFLAGS) -I. -I$(PKG_BUILD_DIR)/driver/include" \
+ all
+
+ $(TARGET_CC) -o $(PKG_BUILD_DIR)/wlc \
+ -I$(PKG_BUILD_DIR)/shared -I$(PKG_BUILD_DIR)/driver/include \
+ ./src/wlc.c $(PKG_BUILD_DIR)/shared/libshared.a
+
+ $(TARGET_CC) -o $(PKG_BUILD_DIR)/nas \
+ $(PKG_BUILD_DIR)/nas_exe.o \
+ $(PKG_BUILD_DIR)/shared/libshared.a
+
+ $(TARGET_CC) -o $(PKG_BUILD_DIR)/wl \
+ $(PKG_BUILD_DIR)/wl_exe.o \
+ $(PKG_BUILD_DIR)/shared/libshared.a
+endef
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_BUILD_DIR)/shared/libshared.a $(1)/usr/lib/
+endef
+
+define Package/wlc/install
+ $(CP) ./files/* $(1)/
+ $(INSTALL_DIR) $(1)/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/wlc $(1)/sbin/
+endef
+
+define Package/wlc/postinst
+#!/bin/sh
+[ -n "$${IPKG_INSTROOT}" ] || /etc/init.d/wlunbind enable || true
+endef
+
+define Package/wl/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/wl $(1)/usr/sbin/
+endef
+
+define Package/nas/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/nas $(1)/usr/sbin/
+ ln -sf nas $(1)/usr/sbin/nas4not
+ ln -sf nas $(1)/usr/sbin/nas4wds
+endef
+
+$(eval $(call KernelPackage,brcm-wl))
+$(eval $(call KernelPackage,brcm-wl-mini))
+$(eval $(call BuildPackage,wlc))
+$(eval $(call BuildPackage,wl))
+$(eval $(call BuildPackage,nas))
diff --git a/package/broadcom-wl/files/.svn/entries b/package/broadcom-wl/files/.svn/entries
new file mode 100644
index 0000000..f41eddc
--- /dev/null
+++ b/package/broadcom-wl/files/.svn/entries
@@ -0,0 +1,34 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/broadcom-wl/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-06-26T15:43:09.045637Z
+32505
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+lib
+dir
+
+etc
+dir
+
diff --git a/package/broadcom-wl/files/etc/.svn/entries b/package/broadcom-wl/files/etc/.svn/entries
new file mode 100644
index 0000000..d1f38cd
--- /dev/null
+++ b/package/broadcom-wl/files/etc/.svn/entries
@@ -0,0 +1,34 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/broadcom-wl/files/etc
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-06-26T15:43:09.045637Z
+32505
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+hotplug.d
+dir
+
+init.d
+dir
+
diff --git a/package/broadcom-wl/files/etc/hotplug.d/.svn/entries b/package/broadcom-wl/files/etc/hotplug.d/.svn/entries
new file mode 100644
index 0000000..35fd768
--- /dev/null
+++ b/package/broadcom-wl/files/etc/hotplug.d/.svn/entries
@@ -0,0 +1,31 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/broadcom-wl/files/etc/hotplug.d
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-06-26T15:43:09.045637Z
+32505
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+net
+dir
+
diff --git a/package/broadcom-wl/files/etc/hotplug.d/net/.svn/entries b/package/broadcom-wl/files/etc/hotplug.d/net/.svn/entries
new file mode 100644
index 0000000..688ed06
--- /dev/null
+++ b/package/broadcom-wl/files/etc/hotplug.d/net/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/broadcom-wl/files/etc/hotplug.d/net
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-06-26T15:43:09.045637Z
+32505
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+20-broadcom_wds
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+f9619bb9f04722a631311cc4c65a2e14
+2012-06-26T15:43:09.045637Z
+32505
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1351
+
diff --git a/package/broadcom-wl/files/etc/hotplug.d/net/.svn/text-base/20-broadcom_wds.svn-base b/package/broadcom-wl/files/etc/hotplug.d/net/.svn/text-base/20-broadcom_wds.svn-base
new file mode 100644
index 0000000..0a563c2
--- /dev/null
+++ b/package/broadcom-wl/files/etc/hotplug.d/net/.svn/text-base/20-broadcom_wds.svn-base
@@ -0,0 +1,61 @@
+include /lib/wifi
+
+setup_broadcom_wds() {
+ local iface="$1"
+ local remote="$(wlc ifname "$iface" wdsmac)"
+
+ [ -z "$remote" ] && return
+
+ config_cb() {
+ [ -z "$CONFIG_SECTION" ] && return
+
+ config_get type "$CONFIG_SECTION" TYPE
+ [ "$type" = "wifi-iface" ] || return
+
+ config_get network "$CONFIG_SECTION" network
+ [ -z "$network" ] && return
+
+ config_get addr "$CONFIG_SECTION" bssid
+ addr=$(echo "$addr" | tr 'A-F' 'a-f')
+ [ "$addr" = "$remote" ] && {
+ local cfg="$CONFIG_SECTION"
+
+ include /lib/network
+ scan_interfaces
+
+ for network in $network; do
+ setup_interface "$iface" "$network"
+ done
+
+ config_get encryption "$cfg" encryption
+ config_get key "$cfg" key
+ config_get ssid "$cfg" ssid
+
+ [ "$encryption" != "none" ] && {
+ sleep 5
+ case "$encryption" in
+ psk|PSK)
+ nas4not "$network" "$iface" up auto tkip psk "$key" "$ssid"
+ ;;
+ psk2|PSK2)
+ nas4not "$network" "$iface" up auto aes psk "$key" "$ssid"
+ ;;
+ psk+psk2|psk2+psk|PSK+PSK2|PSK2+PSK)
+ nas4not "$network" "$iface" up auto aes+tkip psk "$key" "$ssid"
+ ;;
+ *)
+ nas4not lan "$iface" up auto aes "$encryption" "$key" "$ssid"
+ ;;
+ esac
+ }
+ }
+ }
+
+ config_load wireless
+}
+
+case "$ACTION" in
+ add|register)
+ [ "${INTERFACE%%0.*}" = wds ] && setup_broadcom_wds "$INTERFACE"
+ ;;
+esac
diff --git a/package/broadcom-wl/files/etc/hotplug.d/net/20-broadcom_wds b/package/broadcom-wl/files/etc/hotplug.d/net/20-broadcom_wds
new file mode 100644
index 0000000..0a563c2
--- /dev/null
+++ b/package/broadcom-wl/files/etc/hotplug.d/net/20-broadcom_wds
@@ -0,0 +1,61 @@
+include /lib/wifi
+
+setup_broadcom_wds() {
+ local iface="$1"
+ local remote="$(wlc ifname "$iface" wdsmac)"
+
+ [ -z "$remote" ] && return
+
+ config_cb() {
+ [ -z "$CONFIG_SECTION" ] && return
+
+ config_get type "$CONFIG_SECTION" TYPE
+ [ "$type" = "wifi-iface" ] || return
+
+ config_get network "$CONFIG_SECTION" network
+ [ -z "$network" ] && return
+
+ config_get addr "$CONFIG_SECTION" bssid
+ addr=$(echo "$addr" | tr 'A-F' 'a-f')
+ [ "$addr" = "$remote" ] && {
+ local cfg="$CONFIG_SECTION"
+
+ include /lib/network
+ scan_interfaces
+
+ for network in $network; do
+ setup_interface "$iface" "$network"
+ done
+
+ config_get encryption "$cfg" encryption
+ config_get key "$cfg" key
+ config_get ssid "$cfg" ssid
+
+ [ "$encryption" != "none" ] && {
+ sleep 5
+ case "$encryption" in
+ psk|PSK)
+ nas4not "$network" "$iface" up auto tkip psk "$key" "$ssid"
+ ;;
+ psk2|PSK2)
+ nas4not "$network" "$iface" up auto aes psk "$key" "$ssid"
+ ;;
+ psk+psk2|psk2+psk|PSK+PSK2|PSK2+PSK)
+ nas4not "$network" "$iface" up auto aes+tkip psk "$key" "$ssid"
+ ;;
+ *)
+ nas4not lan "$iface" up auto aes "$encryption" "$key" "$ssid"
+ ;;
+ esac
+ }
+ }
+ }
+
+ config_load wireless
+}
+
+case "$ACTION" in
+ add|register)
+ [ "${INTERFACE%%0.*}" = wds ] && setup_broadcom_wds "$INTERFACE"
+ ;;
+esac
diff --git a/package/broadcom-wl/files/etc/init.d/.svn/entries b/package/broadcom-wl/files/etc/init.d/.svn/entries
new file mode 100644
index 0000000..4fa0082
--- /dev/null
+++ b/package/broadcom-wl/files/etc/init.d/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/broadcom-wl/files/etc/init.d
+svn://svn.openwrt.org/openwrt
+
+
+
+2011-07-24T14:10:39.842012Z
+27751
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+wlunbind
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+b312a1d91e33fdc21069aa017d143c0b
+2011-07-24T14:10:39.842012Z
+27751
+jow
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+522
+
diff --git a/package/broadcom-wl/files/etc/init.d/.svn/prop-base/wlunbind.svn-base b/package/broadcom-wl/files/etc/init.d/.svn/prop-base/wlunbind.svn-base
new file mode 100644
index 0000000..869ac71
--- /dev/null
+++ b/package/broadcom-wl/files/etc/init.d/.svn/prop-base/wlunbind.svn-base
@@ -0,0 +1,5 @@
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/broadcom-wl/files/etc/init.d/.svn/text-base/wlunbind.svn-base b/package/broadcom-wl/files/etc/init.d/.svn/text-base/wlunbind.svn-base
new file mode 100644
index 0000000..0a29db5
--- /dev/null
+++ b/package/broadcom-wl/files/etc/init.d/.svn/text-base/wlunbind.svn-base
@@ -0,0 +1,29 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2010-2011 OpenWrt.org
+
+START=09
+
+unbind_driver() {
+ local driver="$1"
+ local sysfs="/sys/bus/pci/drivers/$driver"
+ if [ -d "$sysfs" ]; then
+ local lnk
+ for lnk in $sysfs/*; do
+ [ -h "$lnk" ] || continue
+ case "${lnk##*/}" in
+ *:*:*.*)
+ logger "Unbinding WL PCI device ${lnk##*/} from $driver"
+ echo -n "${lnk##*/}" > "$sysfs/unbind"
+ ;;
+ esac
+ done
+ fi
+}
+
+boot() {
+ unbind_driver b43-pci-bridge
+ unbind_driver bcma-pci-bridge
+}
+
+start() { :; }
+stop() { :; }
diff --git a/package/broadcom-wl/files/etc/init.d/wlunbind b/package/broadcom-wl/files/etc/init.d/wlunbind
new file mode 100755
index 0000000..0a29db5
--- /dev/null
+++ b/package/broadcom-wl/files/etc/init.d/wlunbind
@@ -0,0 +1,29 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2010-2011 OpenWrt.org
+
+START=09
+
+unbind_driver() {
+ local driver="$1"
+ local sysfs="/sys/bus/pci/drivers/$driver"
+ if [ -d "$sysfs" ]; then
+ local lnk
+ for lnk in $sysfs/*; do
+ [ -h "$lnk" ] || continue
+ case "${lnk##*/}" in
+ *:*:*.*)
+ logger "Unbinding WL PCI device ${lnk##*/} from $driver"
+ echo -n "${lnk##*/}" > "$sysfs/unbind"
+ ;;
+ esac
+ done
+ fi
+}
+
+boot() {
+ unbind_driver b43-pci-bridge
+ unbind_driver bcma-pci-bridge
+}
+
+start() { :; }
+stop() { :; }
diff --git a/package/broadcom-wl/files/lib/.svn/entries b/package/broadcom-wl/files/lib/.svn/entries
new file mode 100644
index 0000000..fee7f06
--- /dev/null
+++ b/package/broadcom-wl/files/lib/.svn/entries
@@ -0,0 +1,31 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/broadcom-wl/files/lib
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-02-07T15:45:56.784176Z
+30362
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+wifi
+dir
+
diff --git a/package/broadcom-wl/files/lib/wifi/.svn/entries b/package/broadcom-wl/files/lib/wifi/.svn/entries
new file mode 100644
index 0000000..66c9d24
--- /dev/null
+++ b/package/broadcom-wl/files/lib/wifi/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/broadcom-wl/files/lib/wifi
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-02-07T15:45:56.784176Z
+30362
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+broadcom.sh
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+61122098cb867ac217766ce96ecc3cb3
+2012-02-07T15:45:56.784176Z
+30362
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+8416
+
diff --git a/package/broadcom-wl/files/lib/wifi/.svn/text-base/broadcom.sh.svn-base b/package/broadcom-wl/files/lib/wifi/.svn/text-base/broadcom.sh.svn-base
new file mode 100644
index 0000000..57e11e4
--- /dev/null
+++ b/package/broadcom-wl/files/lib/wifi/.svn/text-base/broadcom.sh.svn-base
@@ -0,0 +1,392 @@
+append DRIVERS "broadcom"
+
+scan_broadcom() {
+ local device="$1"
+ local wds
+ local adhoc sta apmode mon disabled
+ local adhoc_if sta_if ap_if mon_if
+ local _c=0
+
+ config_get vifs "$device" vifs
+ for vif in $vifs; do
+ config_get_bool disabled "$vif" disabled 0
+ [ $disabled -eq 0 ] || continue
+
+ config_get mode "$vif" mode
+ _c=$(($_c + 1))
+ case "$mode" in
+ adhoc)
+ adhoc=1
+ adhoc_if="$vif"
+ ;;
+ sta)
+ sta=1
+ sta_if="$vif"
+ ;;
+ ap)
+ apmode=1
+ ap_if="${ap_if:+$ap_if }$vif"
+ ;;
+ wds)
+ config_get addr "$vif" bssid
+ [ -z "$addr" ] || {
+ addr=$(echo "$addr" | tr 'A-F' 'a-f')
+ append wds "$addr"
+ }
+ ;;
+ monitor)
+ mon=1
+ mon_if="$vif"
+ ;;
+ *) echo "$device($vif): Invalid mode";;
+ esac
+ done
+ config_set "$device" wds "$wds"
+
+ local _c=
+ for vif in ${adhoc_if:-$sta_if $ap_if $mon_if}; do
+ config_set "$vif" ifname "${device}${_c:+.$_c}"
+ _c=$((${_c:-0} + 1))
+ done
+ config_set "$device" vifs "${adhoc_if:-$sta_if $ap_if $mon_if}"
+
+ ifdown="down"
+ for vif in 0 1 2 3; do
+ append ifdown "vif $vif" "$N"
+ append ifdown "enabled 0" "$N"
+ done
+
+ ap=1
+ infra=1
+ if [ "$_c" -gt 1 ]; then
+ mssid=1
+ else
+ mssid=
+ fi
+ apsta=0
+ radio=1
+ monitor=0
+ case "$adhoc:$sta:$apmode:$mon" in
+ 1*)
+ ap=0
+ mssid=
+ infra=0
+ ;;
+ :1:1:)
+ apsta=1
+ wet=1
+ ;;
+ :1::)
+ wet=1
+ ap=0
+ mssid=
+ ;;
+ :::1)
+ wet=1
+ ap=0
+ mssid=
+ monitor=1
+ ;;
+ ::)
+ radio=0
+ ;;
+ esac
+}
+
+disable_broadcom() {
+ local device="$1"
+ set_wifi_down "$device"
+ wlc ifname "$device" down
+ wlc ifname "$device" bssid `wlc ifname "$device" default_bssid`
+ (
+ include /lib/network
+
+ # make sure the interfaces are down and removed from all bridges
+ for dev in $device ${device}.1 ${device}.2 ${device}.3; do
+ ifconfig "$dev" down 2>/dev/null >/dev/null && {
+ unbridge "$dev"
+ }
+ done
+ )
+ true
+}
+
+enable_broadcom() {
+ local device="$1"
+ local _c
+ config_get channel "$device" channel
+ config_get country "$device" country
+ config_get maxassoc "$device" maxassoc
+ config_get wds "$device" wds
+ config_get vifs "$device" vifs
+ config_get distance "$device" distance
+ config_get slottime "$device" slottime
+ config_get rxantenna "$device" rxantenna
+ config_get txantenna "$device" txantenna
+ config_get_bool frameburst "$device" frameburst
+ config_get macfilter "$device" macfilter
+ config_get maclist "$device" maclist
+ config_get macaddr "$device" macaddr
+ config_get txpower "$device" txpower
+ config_get frag "$device" frag
+ config_get rts "$device" rts
+ config_get hwmode "$device" hwmode
+ local vif_pre_up vif_post_up vif_do_up vif_txpower
+ local doth=0
+ local wmm=1
+
+ _c=0
+ nas="$(which nas)"
+ nas_cmd=
+ if_up=
+
+ [ -z "$slottime" ] && {
+ [ -n "$distance" ] && {
+ # slottime = 9 + (distance / 150) + (distance % 150 ? 1 : 0)
+ slottime="$((9 + ($distance / 150) + 1 - (150 - ($distance % 150)) / 150 ))"
+ }
+ } || {
+ slottime="${slottime:--1}"
+ }
+
+ case "$macfilter" in
+ allow|2)
+ macfilter=2;
+ ;;
+ deny|1)
+ macfilter=1;
+ ;;
+ disable|none|0)
+ macfilter=0;
+ ;;
+ esac
+
+ case "$hwmode" in
+ *b) hwmode=0;;
+ *bg) hwmode=1;;
+ *g) hwmode=2;;
+ *gst) hwmode=4;;
+ *lrs) hwmode=5;;
+ *) hwmode=1;;
+ esac
+
+ for vif in $vifs; do
+ config_get vif_txpower "$vif" txpower
+
+ config_get mode "$vif" mode
+ append vif_pre_up "vif $_c" "$N"
+ append vif_post_up "vif $_c" "$N"
+ append vif_do_up "vif $_c" "$N"
+
+ config_get_bool wmm "$vif" wmm "$wmm"
+ config_get_bool doth "$vif" doth "$doth"
+
+ [ "$mode" = "sta" ] || {
+ config_get_bool hidden "$vif" hidden 0
+ append vif_pre_up "closed $hidden" "$N"
+ config_get_bool isolate "$vif" isolate 0
+ append vif_pre_up "ap_isolate $isolate" "$N"
+ }
+
+ wsec_r=0
+ eap_r=0
+ wsec=0
+ auth=0
+ nasopts=
+ config_get enc "$vif" encryption
+ case "$enc" in
+ *wep*)
+ wsec_r=1
+ wsec=1
+ defkey=1
+ config_get key "$vif" key
+ case "$enc" in
+ *shared*) append vif_do_up "wepauth 1" "$N";;
+ *) append vif_do_up "wepauth 0" "$N";;
+ esac
+ case "$key" in
+ [1234])
+ defkey="$key"
+ for knr in 1 2 3 4; do
+ config_get k "$vif" key$knr
+ [ -n "$k" ] || continue
+ [ "$defkey" = "$knr" ] && def="=" || def=""
+ append vif_do_up "wepkey $def$knr,$k" "$N"
+ done
+ ;;
+ "");;
+ *) append vif_do_up "wepkey =1,$key" "$N";;
+ esac
+ ;;
+ *psk*)
+ wsec_r=1
+ config_get key "$vif" key
+
+ # psk version + default cipher
+ case "$enc" in
+ *mixed*|*psk+psk2*) auth=132; wsec=6;;
+ *psk2*) auth=128; wsec=4;;
+ *) auth=4; wsec=2;;
+ esac
+
+ # cipher override
+ case "$enc" in
+ *tkip+aes*|*tkip+ccmp*|*aes+tkip*|*ccmp+tkip*) wsec=6;;
+ *aes*|*ccmp*) wsec=4;;
+ *tkip*) wsec=2;;
+ esac
+
+ # group rekey interval
+ config_get rekey "$vif" wpa_group_rekey
+
+ eval "${vif}_key=\"\$key\""
+ nasopts="-k \"\$${vif}_key\"${rekey:+ -g $rekey}"
+ ;;
+ *wpa*)
+ wsec_r=1
+ eap_r=1
+ config_get auth_server "$vif" auth_server
+ [ -z "$auth_server" ] && config_get auth_server "$vif" server
+ config_get auth_port "$vif" auth_port
+ [ -z "$auth_port" ] && config_get auth_port "$vif" port
+ config_get auth_secret "$vif" auth_secret
+ [ -z "$auth_secret" ] && config_get auth_secret "$vif" key
+
+ # wpa version + default cipher
+ case "$enc" in
+ *mixed*|*wpa+wpa2*) auth=66; wsec=6;;
+ *wpa2*) auth=64; wsec=4;;
+ *) auth=2; wsec=2;;
+ esac
+
+ # cipher override
+ case "$enc" in
+ *tkip+aes*|*tkip+ccmp*|*aes+tkip*|*ccmp+tkip*) wsec=6;;
+ *aes*|*ccmp*) wsec=4;;
+ *tkip*) wsec=2;;
+ esac
+
+ # group rekey interval
+ config_get rekey "$vif" wpa_group_rekey
+
+ eval "${vif}_key=\"\$auth_secret\""
+ nasopts="-r \"\$${vif}_key\" -h $auth_server -p ${auth_port:-1812}${rekey:+ -g $rekey}"
+ ;;
+ esac
+ append vif_do_up "wsec $wsec" "$N"
+ append vif_do_up "wpa_auth $auth" "$N"
+ append vif_do_up "wsec_restrict $wsec_r" "$N"
+ append vif_do_up "eap_restrict $eap_r" "$N"
+
+ config_get ssid "$vif" ssid
+ append vif_post_up "vlan_mode 0" "$N"
+ append vif_post_up "ssid $ssid" "$N"
+ append vif_do_up "ssid $ssid" "$N"
+
+ [ "$mode" = "monitor" ] && {
+ append vif_post_up "monitor $monitor" "$N"
+ }
+
+ [ "$mode" = "adhoc" ] && {
+ config_get bssid "$vif" bssid
+ [ -n "$bssid" ] && {
+ append vif_pre_up "bssid $bssid" "$N"
+ append vif_pre_up "ibss_merge 0" "$N"
+ } || {
+ append vif_pre_up "ibss_merge 1" "$N"
+ }
+ }
+
+ append vif_post_up "enabled 1" "$N"
+
+ config_get ifname "$vif" ifname
+ #append if_up "ifconfig $ifname up" ";$N"
+
+ local net_cfg
+ net_cfg="$(find_net_config "$vif")"
+ [ -z "$net_cfg" ] || {
+ append if_up "set_wifi_up '$vif' '$ifname'" ";$N"
+ append if_up "start_net '$ifname' '$net_cfg'" ";$N"
+ }
+ [ -z "$nasopts" ] || {
+ eval "${vif}_ssid=\"\$ssid\""
+ nas_mode="-A"
+ [ "$mode" = "sta" ] && nas_mode="-S"
+ [ -z "$nas" ] || {
+ nas_cmd="${nas_cmd:+$nas_cmd$N}start-stop-daemon -S -b -p /var/run/nas.$ifname.pid -x $nas -- -P /var/run/nas.$ifname.pid -H 34954 -i $ifname $nas_mode -m $auth -w $wsec -s \"\$${vif}_ssid\" -g 3600 -F $nasopts"
+ }
+ }
+ _c=$(($_c + 1))
+ done
+ killall -KILL nas >&- 2>&-
+ wlc ifname "$device" stdin <<EOF
+$ifdown
+
+gmode ${hwmode:-1}
+apsta $apsta
+ap $ap
+${mssid:+mssid $mssid}
+infra $infra
+${wet:+wet 1}
+802.11d 0
+802.11h ${doth:-0}
+wme ${wmm:-1}
+rxant ${rxantenna:-3}
+txant ${txantenna:-3}
+fragthresh ${frag:-2346}
+rtsthresh ${rts:-2347}
+monitor ${monitor:-0}
+
+radio ${radio:-1}
+macfilter ${macfilter:-0}
+maclist ${maclist:-none}
+wds none
+${wds:+wds $wds}
+country ${country:-US}
+${channel:+channel $channel}
+maxassoc ${maxassoc:-128}
+slottime ${slottime:--1}
+${frameburst:+frameburst $frameburst}
+
+$vif_pre_up
+up
+$vif_post_up
+EOF
+ eval "$if_up"
+ wlc ifname "$device" stdin <<EOF
+$vif_do_up
+EOF
+
+ # use vif_txpower (from last wifi-iface) instead of txpower (from
+ # wifi-device) if the latter does not exist
+ txpower=${txpower:-$vif_txpower}
+ [ -z "$txpower" ] || iwconfig $device txpower ${txpower}dBm
+
+ eval "$nas_cmd"
+}
+
+
+detect_broadcom() {
+ local i=-1
+
+ while grep -qs "^ *wl$((++i)):" /proc/net/dev; do
+ config_get type wl${i} type
+ [ "$type" = broadcom ] && continue
+ cat <<EOF
+config wifi-device wl${i}
+ option type broadcom
+ option channel 11
+
+ # REMOVE THIS LINE TO ENABLE WIFI:
+ option disabled 1
+
+config wifi-iface
+ option device wl${i}
+ option network lan
+ option mode ap
+ option ssid OpenWrt${i#0}
+ option encryption none
+
+EOF
+ done
+}
diff --git a/package/broadcom-wl/files/lib/wifi/broadcom.sh b/package/broadcom-wl/files/lib/wifi/broadcom.sh
new file mode 100644
index 0000000..57e11e4
--- /dev/null
+++ b/package/broadcom-wl/files/lib/wifi/broadcom.sh
@@ -0,0 +1,392 @@
+append DRIVERS "broadcom"
+
+scan_broadcom() {
+ local device="$1"
+ local wds
+ local adhoc sta apmode mon disabled
+ local adhoc_if sta_if ap_if mon_if
+ local _c=0
+
+ config_get vifs "$device" vifs
+ for vif in $vifs; do
+ config_get_bool disabled "$vif" disabled 0
+ [ $disabled -eq 0 ] || continue
+
+ config_get mode "$vif" mode
+ _c=$(($_c + 1))
+ case "$mode" in
+ adhoc)
+ adhoc=1
+ adhoc_if="$vif"
+ ;;
+ sta)
+ sta=1
+ sta_if="$vif"
+ ;;
+ ap)
+ apmode=1
+ ap_if="${ap_if:+$ap_if }$vif"
+ ;;
+ wds)
+ config_get addr "$vif" bssid
+ [ -z "$addr" ] || {
+ addr=$(echo "$addr" | tr 'A-F' 'a-f')
+ append wds "$addr"
+ }
+ ;;
+ monitor)
+ mon=1
+ mon_if="$vif"
+ ;;
+ *) echo "$device($vif): Invalid mode";;
+ esac
+ done
+ config_set "$device" wds "$wds"
+
+ local _c=
+ for vif in ${adhoc_if:-$sta_if $ap_if $mon_if}; do
+ config_set "$vif" ifname "${device}${_c:+.$_c}"
+ _c=$((${_c:-0} + 1))
+ done
+ config_set "$device" vifs "${adhoc_if:-$sta_if $ap_if $mon_if}"
+
+ ifdown="down"
+ for vif in 0 1 2 3; do
+ append ifdown "vif $vif" "$N"
+ append ifdown "enabled 0" "$N"
+ done
+
+ ap=1
+ infra=1
+ if [ "$_c" -gt 1 ]; then
+ mssid=1
+ else
+ mssid=
+ fi
+ apsta=0
+ radio=1
+ monitor=0
+ case "$adhoc:$sta:$apmode:$mon" in
+ 1*)
+ ap=0
+ mssid=
+ infra=0
+ ;;
+ :1:1:)
+ apsta=1
+ wet=1
+ ;;
+ :1::)
+ wet=1
+ ap=0
+ mssid=
+ ;;
+ :::1)
+ wet=1
+ ap=0
+ mssid=
+ monitor=1
+ ;;
+ ::)
+ radio=0
+ ;;
+ esac
+}
+
+disable_broadcom() {
+ local device="$1"
+ set_wifi_down "$device"
+ wlc ifname "$device" down
+ wlc ifname "$device" bssid `wlc ifname "$device" default_bssid`
+ (
+ include /lib/network
+
+ # make sure the interfaces are down and removed from all bridges
+ for dev in $device ${device}.1 ${device}.2 ${device}.3; do
+ ifconfig "$dev" down 2>/dev/null >/dev/null && {
+ unbridge "$dev"
+ }
+ done
+ )
+ true
+}
+
+enable_broadcom() {
+ local device="$1"
+ local _c
+ config_get channel "$device" channel
+ config_get country "$device" country
+ config_get maxassoc "$device" maxassoc
+ config_get wds "$device" wds
+ config_get vifs "$device" vifs
+ config_get distance "$device" distance
+ config_get slottime "$device" slottime
+ config_get rxantenna "$device" rxantenna
+ config_get txantenna "$device" txantenna
+ config_get_bool frameburst "$device" frameburst
+ config_get macfilter "$device" macfilter
+ config_get maclist "$device" maclist
+ config_get macaddr "$device" macaddr
+ config_get txpower "$device" txpower
+ config_get frag "$device" frag
+ config_get rts "$device" rts
+ config_get hwmode "$device" hwmode
+ local vif_pre_up vif_post_up vif_do_up vif_txpower
+ local doth=0
+ local wmm=1
+
+ _c=0
+ nas="$(which nas)"
+ nas_cmd=
+ if_up=
+
+ [ -z "$slottime" ] && {
+ [ -n "$distance" ] && {
+ # slottime = 9 + (distance / 150) + (distance % 150 ? 1 : 0)
+ slottime="$((9 + ($distance / 150) + 1 - (150 - ($distance % 150)) / 150 ))"
+ }
+ } || {
+ slottime="${slottime:--1}"
+ }
+
+ case "$macfilter" in
+ allow|2)
+ macfilter=2;
+ ;;
+ deny|1)
+ macfilter=1;
+ ;;
+ disable|none|0)
+ macfilter=0;
+ ;;
+ esac
+
+ case "$hwmode" in
+ *b) hwmode=0;;
+ *bg) hwmode=1;;
+ *g) hwmode=2;;
+ *gst) hwmode=4;;
+ *lrs) hwmode=5;;
+ *) hwmode=1;;
+ esac
+
+ for vif in $vifs; do
+ config_get vif_txpower "$vif" txpower
+
+ config_get mode "$vif" mode
+ append vif_pre_up "vif $_c" "$N"
+ append vif_post_up "vif $_c" "$N"
+ append vif_do_up "vif $_c" "$N"
+
+ config_get_bool wmm "$vif" wmm "$wmm"
+ config_get_bool doth "$vif" doth "$doth"
+
+ [ "$mode" = "sta" ] || {
+ config_get_bool hidden "$vif" hidden 0
+ append vif_pre_up "closed $hidden" "$N"
+ config_get_bool isolate "$vif" isolate 0
+ append vif_pre_up "ap_isolate $isolate" "$N"
+ }
+
+ wsec_r=0
+ eap_r=0
+ wsec=0
+ auth=0
+ nasopts=
+ config_get enc "$vif" encryption
+ case "$enc" in
+ *wep*)
+ wsec_r=1
+ wsec=1
+ defkey=1
+ config_get key "$vif" key
+ case "$enc" in
+ *shared*) append vif_do_up "wepauth 1" "$N";;
+ *) append vif_do_up "wepauth 0" "$N";;
+ esac
+ case "$key" in
+ [1234])
+ defkey="$key"
+ for knr in 1 2 3 4; do
+ config_get k "$vif" key$knr
+ [ -n "$k" ] || continue
+ [ "$defkey" = "$knr" ] && def="=" || def=""
+ append vif_do_up "wepkey $def$knr,$k" "$N"
+ done
+ ;;
+ "");;
+ *) append vif_do_up "wepkey =1,$key" "$N";;
+ esac
+ ;;
+ *psk*)
+ wsec_r=1
+ config_get key "$vif" key
+
+ # psk version + default cipher
+ case "$enc" in
+ *mixed*|*psk+psk2*) auth=132; wsec=6;;
+ *psk2*) auth=128; wsec=4;;
+ *) auth=4; wsec=2;;
+ esac
+
+ # cipher override
+ case "$enc" in
+ *tkip+aes*|*tkip+ccmp*|*aes+tkip*|*ccmp+tkip*) wsec=6;;
+ *aes*|*ccmp*) wsec=4;;
+ *tkip*) wsec=2;;
+ esac
+
+ # group rekey interval
+ config_get rekey "$vif" wpa_group_rekey
+
+ eval "${vif}_key=\"\$key\""
+ nasopts="-k \"\$${vif}_key\"${rekey:+ -g $rekey}"
+ ;;
+ *wpa*)
+ wsec_r=1
+ eap_r=1
+ config_get auth_server "$vif" auth_server
+ [ -z "$auth_server" ] && config_get auth_server "$vif" server
+ config_get auth_port "$vif" auth_port
+ [ -z "$auth_port" ] && config_get auth_port "$vif" port
+ config_get auth_secret "$vif" auth_secret
+ [ -z "$auth_secret" ] && config_get auth_secret "$vif" key
+
+ # wpa version + default cipher
+ case "$enc" in
+ *mixed*|*wpa+wpa2*) auth=66; wsec=6;;
+ *wpa2*) auth=64; wsec=4;;
+ *) auth=2; wsec=2;;
+ esac
+
+ # cipher override
+ case "$enc" in
+ *tkip+aes*|*tkip+ccmp*|*aes+tkip*|*ccmp+tkip*) wsec=6;;
+ *aes*|*ccmp*) wsec=4;;
+ *tkip*) wsec=2;;
+ esac
+
+ # group rekey interval
+ config_get rekey "$vif" wpa_group_rekey
+
+ eval "${vif}_key=\"\$auth_secret\""
+ nasopts="-r \"\$${vif}_key\" -h $auth_server -p ${auth_port:-1812}${rekey:+ -g $rekey}"
+ ;;
+ esac
+ append vif_do_up "wsec $wsec" "$N"
+ append vif_do_up "wpa_auth $auth" "$N"
+ append vif_do_up "wsec_restrict $wsec_r" "$N"
+ append vif_do_up "eap_restrict $eap_r" "$N"
+
+ config_get ssid "$vif" ssid
+ append vif_post_up "vlan_mode 0" "$N"
+ append vif_post_up "ssid $ssid" "$N"
+ append vif_do_up "ssid $ssid" "$N"
+
+ [ "$mode" = "monitor" ] && {
+ append vif_post_up "monitor $monitor" "$N"
+ }
+
+ [ "$mode" = "adhoc" ] && {
+ config_get bssid "$vif" bssid
+ [ -n "$bssid" ] && {
+ append vif_pre_up "bssid $bssid" "$N"
+ append vif_pre_up "ibss_merge 0" "$N"
+ } || {
+ append vif_pre_up "ibss_merge 1" "$N"
+ }
+ }
+
+ append vif_post_up "enabled 1" "$N"
+
+ config_get ifname "$vif" ifname
+ #append if_up "ifconfig $ifname up" ";$N"
+
+ local net_cfg
+ net_cfg="$(find_net_config "$vif")"
+ [ -z "$net_cfg" ] || {
+ append if_up "set_wifi_up '$vif' '$ifname'" ";$N"
+ append if_up "start_net '$ifname' '$net_cfg'" ";$N"
+ }
+ [ -z "$nasopts" ] || {
+ eval "${vif}_ssid=\"\$ssid\""
+ nas_mode="-A"
+ [ "$mode" = "sta" ] && nas_mode="-S"
+ [ -z "$nas" ] || {
+ nas_cmd="${nas_cmd:+$nas_cmd$N}start-stop-daemon -S -b -p /var/run/nas.$ifname.pid -x $nas -- -P /var/run/nas.$ifname.pid -H 34954 -i $ifname $nas_mode -m $auth -w $wsec -s \"\$${vif}_ssid\" -g 3600 -F $nasopts"
+ }
+ }
+ _c=$(($_c + 1))
+ done
+ killall -KILL nas >&- 2>&-
+ wlc ifname "$device" stdin <<EOF
+$ifdown
+
+gmode ${hwmode:-1}
+apsta $apsta
+ap $ap
+${mssid:+mssid $mssid}
+infra $infra
+${wet:+wet 1}
+802.11d 0
+802.11h ${doth:-0}
+wme ${wmm:-1}
+rxant ${rxantenna:-3}
+txant ${txantenna:-3}
+fragthresh ${frag:-2346}
+rtsthresh ${rts:-2347}
+monitor ${monitor:-0}
+
+radio ${radio:-1}
+macfilter ${macfilter:-0}
+maclist ${maclist:-none}
+wds none
+${wds:+wds $wds}
+country ${country:-US}
+${channel:+channel $channel}
+maxassoc ${maxassoc:-128}
+slottime ${slottime:--1}
+${frameburst:+frameburst $frameburst}
+
+$vif_pre_up
+up
+$vif_post_up
+EOF
+ eval "$if_up"
+ wlc ifname "$device" stdin <<EOF
+$vif_do_up
+EOF
+
+ # use vif_txpower (from last wifi-iface) instead of txpower (from
+ # wifi-device) if the latter does not exist
+ txpower=${txpower:-$vif_txpower}
+ [ -z "$txpower" ] || iwconfig $device txpower ${txpower}dBm
+
+ eval "$nas_cmd"
+}
+
+
+detect_broadcom() {
+ local i=-1
+
+ while grep -qs "^ *wl$((++i)):" /proc/net/dev; do
+ config_get type wl${i} type
+ [ "$type" = broadcom ] && continue
+ cat <<EOF
+config wifi-device wl${i}
+ option type broadcom
+ option channel 11
+
+ # REMOVE THIS LINE TO ENABLE WIFI:
+ option disabled 1
+
+config wifi-iface
+ option device wl${i}
+ option network lan
+ option mode ap
+ option ssid OpenWrt${i#0}
+ option encryption none
+
+EOF
+ done
+}
diff --git a/package/broadcom-wl/patches/.svn/entries b/package/broadcom-wl/patches/.svn/entries
new file mode 100644
index 0000000..b6e7624
--- /dev/null
+++ b/package/broadcom-wl/patches/.svn/entries
@@ -0,0 +1,504 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/broadcom-wl/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-02-24T18:01:06.512491Z
+35767
+hauke
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+011-fix_compile_3_4.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+673a9f0b6628b1cd0c2f9ca2d293a1d5
+2012-11-18T21:27:00.359060Z
+34252
+hauke
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+256
+
+100-fix_nvram_two_devices.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+eeeda6eab27483ae797da8abb91bc2ae
+2012-11-25T20:11:15.632926Z
+34381
+hauke
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+669
+
+007-use-glue-driver.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+72c6849749aa7986006faa9035b27598
+2011-07-24T14:14:48.520856Z
+27752
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5124
+
+913-avoid-dbe-on-ifs_ctl-readw-hack.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+efbaa0868d232cd448b25ca168b3f9e2
+2013-02-24T18:01:06.512491Z
+35767
+hauke
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+262
+
+008-fix_virtual_interfaces.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+f844cf849bcf24918f737bfae008bee0
+2011-08-01T18:41:05.803467Z
+27868
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+302
+
+910-fallback-sprom.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+4c63341b828854f124b5234d8c7a91e9
+2011-07-24T14:10:39.842012Z
+27751
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2540
+
+006-generic-dma-api.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+951fd8a807dd134e207b2871a2053284
+2011-07-24T14:10:39.842012Z
+27751
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2731
+
+009-fix_compile_3_2.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+c156e30d73f925ab96781bab7e5ee43b
+2012-02-10T17:07:14.611276Z
+30421
+hauke
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+804
+
+004-remove-pcmcia.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+ca5603f0a69035f858375a8a3d808a70
+2010-11-06T18:28:45.832108Z
+23899
+hauke
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+660
+
+005-fix-mem-leak-on-unload.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+516a875c1874c125cea85749098a1347
+2011-07-24T14:10:39.842012Z
+27751
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+779
+
+003-compat-2.6.35.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+8f18098369d7be3d6e03b58c851fe771
+2011-05-19T10:07:57.231351Z
+26948
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1101
+
+010-remove_irqf_samble_random.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+59b8c1a98d83fc653d0964e2816a2b0a
+2012-10-04T12:36:45.562552Z
+33617
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+416
+
+110-add_number_to_dev_name.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+77097be686cd22f016696793ee843375
+2012-11-25T20:11:15.632926Z
+34381
+hauke
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+341
+
+912-pci-bus-nvram-hack.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+a407f1d5442d17dd3610cf2a52e0eff8
+2012-02-10T17:11:17.631471Z
+30422
+hauke
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+412
+
diff --git a/package/broadcom-wl/patches/.svn/text-base/003-compat-2.6.35.patch.svn-base b/package/broadcom-wl/patches/.svn/text-base/003-compat-2.6.35.patch.svn-base
new file mode 100644
index 0000000..89b6653
--- /dev/null
+++ b/package/broadcom-wl/patches/.svn/text-base/003-compat-2.6.35.patch.svn-base
@@ -0,0 +1,39 @@
+--- a/driver/wl_linux.c
++++ b/driver/wl_linux.c
+@@ -2082,7 +2082,11 @@ static void
+ _wl_set_multicast_list(struct net_device *dev)
+ {
+ wl_info_t *wl;
++#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,34)
+ struct dev_mc_list *mclist;
++#else
++ struct netdev_hw_addr *ha;
++#endif
+ int i;
+
+ if (!dev)
+@@ -2098,14 +2102,24 @@ _wl_set_multicast_list(struct net_device
+ wl->pub->allmulti = (dev->flags & IFF_ALLMULTI)? TRUE: FALSE;
+
+ /* copy the list of multicasts into our private table */
++#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,34)
+ for (i = 0, mclist = dev->mc_list; mclist && (i < dev->mc_count);
+ i++, mclist = mclist->next) {
++#else
++ i = 0;
++ netdev_for_each_mc_addr(ha, dev) {
++#endif
+ if (i >= MAXMULTILIST) {
+ wl->pub->allmulti = TRUE;
+ i = 0;
+ break;
+ }
++#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,34)
+ wl->pub->multicast[i] = *((struct ether_addr*) mclist->dmi_addr);
++#else
++ wl->pub->multicast[i] = *((struct ether_addr*) ha->addr);
++ i++;
++#endif
+ }
+ wl->pub->nmulticast = i;
+ wlc_set(wl->wlc, WLC_SET_PROMISC, (dev->flags & IFF_PROMISC));
diff --git a/package/broadcom-wl/patches/.svn/text-base/004-remove-pcmcia.patch.svn-base b/package/broadcom-wl/patches/.svn/text-base/004-remove-pcmcia.patch.svn-base
new file mode 100644
index 0000000..36dda47
--- /dev/null
+++ b/package/broadcom-wl/patches/.svn/text-base/004-remove-pcmcia.patch.svn-base
@@ -0,0 +1,22 @@
+--- a/driver/include/linuxver.h
++++ b/driver/include/linuxver.h
+@@ -111,7 +111,7 @@ typedef irqreturn_t(*FN_ISR) (int irq, v
+ #endif /* not SANDGATE2G */
+ #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 67) */
+
+-#if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE)
++#if 0
+
+ #include <pcmcia/cs_types.h>
+ #include <pcmcia/cs.h>
+--- a/driver/linux_osl.c
++++ b/driver/linux_osl.c
+@@ -62,7 +62,7 @@ struct osl_info {
+ };
+
+ /* PCMCIA attribute space access macros */
+-#if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE)
++#if 0
+ struct pcmcia_dev {
+ dev_link_t link; /* PCMCIA device pointer */
+ dev_node_t node; /* PCMCIA node structure */
diff --git a/package/broadcom-wl/patches/.svn/text-base/005-fix-mem-leak-on-unload.patch.svn-base b/package/broadcom-wl/patches/.svn/text-base/005-fix-mem-leak-on-unload.patch.svn-base
new file mode 100644
index 0000000..41c246f
--- /dev/null
+++ b/package/broadcom-wl/patches/.svn/text-base/005-fix-mem-leak-on-unload.patch.svn-base
@@ -0,0 +1,31 @@
+From: George Kashperko <george@znau.edu.ua>
+
+Release nvram variables buffer.
+Prevent block reserved by alloc_etherdev from being freed.
+Signed-off-by: George Kashperko <george@znau.edu.ua>
+---
+---
+--- a/driver/siutils.c
++++ b/driver/siutils.c
+@@ -647,7 +647,10 @@ si_detach(si_t *sih)
+ #if !defined(BCMBUSTYPE) || (BCMBUSTYPE == SI_BUS)
+ if (sii != &ksii)
+ #endif /* !BCMBUSTYPE || (BCMBUSTYPE == SI_BUS) */
+- MFREE(sii->osh, sii, sizeof(si_info_t));
++ do {
++ MFREE(sii->osh, sii, sizeof(si_info_t));
++ nvram_exit((void *)&(sii->pub));
++ } while (0);
+ }
+
+ void *
+--- a/driver/wl_linux.c
++++ b/driver/wl_linux.c
+@@ -1477,7 +1477,6 @@ wl_free_if(wl_info_t *wl, wl_if_t *wlif)
+ free_netdev(wlif->dev);
+ #endif
+ }
+- MFREE(wl->osh, wlif, sizeof(wl_if_t));
+ }
+
+ #ifdef AP
diff --git a/package/broadcom-wl/patches/.svn/text-base/006-generic-dma-api.patch.svn-base b/package/broadcom-wl/patches/.svn/text-base/006-generic-dma-api.patch.svn-base
new file mode 100644
index 0000000..a90bbe1
--- /dev/null
+++ b/package/broadcom-wl/patches/.svn/text-base/006-generic-dma-api.patch.svn-base
@@ -0,0 +1,88 @@
+From: George Kashperko <george@znau.edu.ua>
+
+broadcom-wl driver bound to ssb device with ssb driver probe
+have osh handle struct pdev pointer value initialized with
+ssb_device pointer. Later on pdev is used with legacy pci
+dma api as pci_dev thus causing oops sometimes.
+
+The patch replaces legacy pci dma api and pass relevant
+device struct pointer to avoid crashes.
+Signed-off-by: George Kashperko <george@znau.edu.ua>
+---
+ driver/linux_osl.c | 28 +++++++++++++++++++++++-----
+ 1 file changed, 23 insertions(+), 5 deletions(-)
+--- a/driver/linux_osl.c
++++ b/driver/linux_osl.c
+@@ -25,6 +25,9 @@
+ #include <asm/paccess.h>
+ #endif /* mips */
+ #include <pcicfg.h>
++#ifdef CONFIG_SSB
++#include <linux/ssb/ssb.h>
++#endif
+
+ #define PCI_CFG_RETRY 10
+
+@@ -364,12 +367,27 @@ osl_dma_consistent_align(void)
+ return (PAGE_SIZE);
+ }
+
++static struct device *
++osl_get_dmadev(osl_t *osh)
++{
++#ifdef CONFIG_SSB
++ if (osh->bustype == SI_BUS) {
++ /* This can be SiliconBackplane emulated as pci with Broadcom or
++ * ssb device. Less harmful is to check for pci_bus_type and if
++ * no match then assume we got ssb */
++ if (((struct pci_dev *)osh->pdev)->dev.bus != &pci_bus_type)
++ return ((struct ssb_device *)osh->pdev)->dma_dev;
++ }
++#endif
++ return &((struct pci_dev *)osh->pdev)->dev;
++}
++
+ void*
+ osl_dma_alloc_consistent(osl_t *osh, uint size, ulong *pap)
+ {
+ ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
+
+- return (pci_alloc_consistent(osh->pdev, size, (dma_addr_t*)pap));
++ return (dma_alloc_coherent(osl_get_dmadev(osh), size, (dma_addr_t*)pap, GFP_ATOMIC));
+ }
+
+ void
+@@ -377,7 +395,7 @@ osl_dma_free_consistent(osl_t *osh, void
+ {
+ ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
+
+- pci_free_consistent(osh->pdev, size, va, (dma_addr_t)pa);
++ dma_free_coherent(osl_get_dmadev(osh), size, va, (dma_addr_t)pa);
+ }
+
+ uint BCMFASTPATH
+@@ -386,13 +404,13 @@ osl_dma_map(osl_t *osh, void *va, uint s
+ ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
+
+ if (direction == DMA_TX)
+- return (pci_map_single(osh->pdev, va, size, PCI_DMA_TODEVICE));
++ return (dma_map_single(osl_get_dmadev(osh), va, size, PCI_DMA_TODEVICE));
+ else {
+ #ifdef mips
+ dma_cache_inv((uint)va, size);
+ return (virt_to_phys(va));
+ #else /* mips */
+- return (pci_map_single(osh->pdev, va, size, PCI_DMA_FROMDEVICE));
++ return (dma_map_single(osl_get_dmadev(osh), va, size, PCI_DMA_FROMDEVICE));
+ #endif /* mips */
+ }
+ }
+@@ -404,7 +422,7 @@ osl_dma_unmap(osl_t *osh, uint pa, uint
+
+ ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
+ dir = (direction == DMA_TX)? PCI_DMA_TODEVICE: PCI_DMA_FROMDEVICE;
+- pci_unmap_single(osh->pdev, (uint32)pa, size, dir);
++ dma_unmap_single(osl_get_dmadev(osh), (uint32)pa, size, dir);
+ }
+
+
diff --git a/package/broadcom-wl/patches/.svn/text-base/007-use-glue-driver.patch.svn-base b/package/broadcom-wl/patches/.svn/text-base/007-use-glue-driver.patch.svn-base
new file mode 100644
index 0000000..2639abc
--- /dev/null
+++ b/package/broadcom-wl/patches/.svn/text-base/007-use-glue-driver.patch.svn-base
@@ -0,0 +1,184 @@
+--- a/driver/wl_linux.c
++++ b/driver/wl_linux.c
+@@ -85,10 +85,9 @@ typedef void wlc_hw_info_t;
+ #include <bcmjtag.h>
+ #endif /* BCMJTAG */
+
+-
+-#ifdef CONFIG_SSB
+-#include <linux/ssb/ssb.h>
+-#endif
++#if defined(CONFIG_SSB) || defined(CONFIG_BCMA)
++#include <wl_glue.h>
++#endif /* defined(CONFIG_SSB) || defined(CONFIG_BCMA) */
+
+ /* Linux wireless extension support */
+ #ifdef CONFIG_WIRELESS_EXT
+@@ -997,62 +996,32 @@ static struct pci_driver wl_pci_driver =
+ #endif /* CONFIG_PCI */
+ #endif
+
++#ifdef BCMJTAG
++static bcmjtag_driver_t wl_jtag_driver = {
++ wl_jtag_probe,
++ wl_jtag_detach,
++ wl_jtag_poll,
++ };
++#endif /* BCMJTAG */
+
+-static int wl_ssb_probe(struct ssb_device *dev, const struct ssb_device_id *id)
++#if defined(CONFIG_SSB) || defined(CONFIG_BCMA)
++static void * glue_attach_cb(u16 vendor, u16 device,
++ ulong mmio, void *dev, u32 irq)
+ {
+- wl_info_t *wl;
+- void *mmio;
+-
+- if (dev->bus->bustype != SSB_BUSTYPE_SSB) {
+- printk("Attaching to SSB behind PCI is not supported. Please remove the b43 ssb bridge\n");
+- return -EINVAL;
+- }
+-
+- mmio = (void *) 0x18000000 + dev->core_index * 0x1000;
+- wl = wl_attach(id->vendor, id->coreid, (ulong) mmio, SI_BUS, dev, dev->irq);
+- if (!wl) {
+- printk("wl_attach failed\n");
+- return -ENODEV;
+- }
+-
+- ssb_set_drvdata(dev, wl);
+-
+- return 0;
++ return wl_attach(vendor, device, mmio, SI_BUS, dev, irq);
+ }
+
+-static void wl_ssb_remove(struct ssb_device *dev)
++static void glue_remove_cb(void *wldev)
+ {
+- wl_info_t *wl = (wl_info_t *) ssb_get_drvdata(dev);
++ wl_info_t *wl = (wl_info_t *)wldev;
+
+ WL_LOCK(wl);
+ WL_APSTA_UPDN(("wl%d (%s): wl_remove() -> wl_down()\n", wl->pub->unit, wl->dev->name));
+ wl_down(wl);
+ WL_UNLOCK(wl);
+ wl_free(wl);
+- ssb_set_drvdata(dev, NULL);
+ }
+-
+-static const struct ssb_device_id wl_ssb_tbl[] = {
+- SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_80211, SSB_ANY_REV),
+- SSB_DEVTABLE_END
+-};
+-
+-#ifdef CONFIG_SSB
+-static struct ssb_driver wl_ssb_driver = {
+- .name = KBUILD_MODNAME,
+- .id_table = wl_ssb_tbl,
+- .probe = wl_ssb_probe,
+- .remove = wl_ssb_remove,
+-};
+-#endif
+-
+-#ifdef BCMJTAG
+-static bcmjtag_driver_t wl_jtag_driver = {
+- wl_jtag_probe,
+- wl_jtag_detach,
+- wl_jtag_poll,
+- };
+-#endif /* BCMJTAG */
++#endif/* defined(CONFIG_SSB) || defined(CONFIG_BCMA) */
+
+
+ /**
+@@ -1067,11 +1036,13 @@ wl_module_init(void)
+ {
+ int error = -ENODEV;
+
+-#ifdef CONFIG_SSB
+- error = ssb_driver_register(&wl_ssb_driver);
++#if defined(CONFIG_SSB) || defined(CONFIG_BCMA)
++ wl_glue_set_attach_callback(&glue_attach_cb);
++ wl_glue_set_remove_callback(&glue_remove_cb);
++ error = wl_glue_register();
+ if (error)
+ return error;
+-#endif /* CONFIG_SSB */
++#endif /* defined(CONFIG_SSB) || defined(CONFIG_BCMA) */
+
+ #ifdef CONFIG_PCI
+ error = pci_register_driver(&wl_pci_driver);
+@@ -1082,7 +1053,9 @@ wl_module_init(void)
+ return 0;
+
+ error_pci:
+- ssb_driver_unregister(&wl_ssb_driver);
++#if defined(CONFIG_SSB) || defined(CONFIG_BCMA)
++ wl_glue_unregister();
++#endif /* defined(CONFIG_SSB) || defined(CONFIG_BCMA) */
+ return error;
+ }
+
+@@ -1099,9 +1072,9 @@ wl_module_exit(void)
+ #ifdef CONFIG_PCI
+ pci_unregister_driver(&wl_pci_driver);
+ #endif /* CONFIG_PCI */
+-#ifdef CONFIG_SSB
+- ssb_driver_unregister(&wl_ssb_driver);
+-#endif /* CONFIG_SSB */
++#if defined(CONFIG_SSB) || defined(CONFIG_BCMA)
++ wl_glue_unregister();
++#endif /* defined(CONFIG_SSB) || defined(CONFIG_BCMA) */
+ }
+
+ module_init(wl_module_init);
+--- a/driver/linux_osl.c
++++ b/driver/linux_osl.c
+@@ -25,9 +25,9 @@
+ #include <asm/paccess.h>
+ #endif /* mips */
+ #include <pcicfg.h>
+-#ifdef CONFIG_SSB
+-#include <linux/ssb/ssb.h>
+-#endif
++#if defined(CONFIG_SSB) || defined(CONFIG_BCMA)
++#include <wl_glue.h>
++#endif /* defined(CONFIG_SSB) || defined(CONFIG_BCMA) */
+
+ #define PCI_CFG_RETRY 10
+
+@@ -370,15 +370,17 @@ osl_dma_consistent_align(void)
+ static struct device *
+ osl_get_dmadev(osl_t *osh)
+ {
+-#ifdef CONFIG_SSB
++#if defined(CONFIG_SSB) || defined(CONFIG_BCMA)
+ if (osh->bustype == SI_BUS) {
+- /* This can be SiliconBackplane emulated as pci with Broadcom or
+- * ssb device. Less harmful is to check for pci_bus_type and if
+- * no match then assume we got ssb */
++ /* This can be SiliconBackplane emulated as pci with Broadcom,
++ * ssb or bcma device. Less harmful is to check for pci_bus_type and if
++ * no match then assume we got either ssb or bcma */
+ if (((struct pci_dev *)osh->pdev)->dev.bus != &pci_bus_type)
+- return ((struct ssb_device *)osh->pdev)->dma_dev;
++ {
++ return wl_glue_get_dmadev(osh->pdev);
++ }
+ }
+-#endif
++#endif /* defined(CONFIG_SSB) || defined(CONFIG_BCMA) */
+ return &((struct pci_dev *)osh->pdev)->dev;
+ }
+
+--- a/driver/Makefile
++++ b/driver/Makefile
+@@ -1,7 +1,7 @@
+ BUILD_TYPE=wl_apsta
+ include $(src)/$(BUILD_TYPE)/buildflags.mk
+
+-EXTRA_CFLAGS += -I$(src)/include -I$(src) -DBCMDRIVER $(WLFLAGS)
++EXTRA_CFLAGS += -I$(src)/include -I$(src) -I$(realpath $(src)/../glue) -DBCMDRIVER $(WLFLAGS)
+
+ wl-objs := $(BUILD_TYPE)/wl_prebuilt.o wl_iw.o wl_linux.o linux_osl.o siutils.o aiutils.o hndpmu.o bcmutils.o sbutils.o nicpci.o hnddma.o bcmsrom.o nvram_stub.o
+
diff --git a/package/broadcom-wl/patches/.svn/text-base/008-fix_virtual_interfaces.patch.svn-base b/package/broadcom-wl/patches/.svn/text-base/008-fix_virtual_interfaces.patch.svn-base
new file mode 100644
index 0000000..6cffa27
--- /dev/null
+++ b/package/broadcom-wl/patches/.svn/text-base/008-fix_virtual_interfaces.patch.svn-base
@@ -0,0 +1,11 @@
+--- a/driver/wl_linux.c
++++ b/driver/wl_linux.c
+@@ -1541,6 +1541,8 @@ wl_add_if(wl_info_t *wl, struct wlc_if*
+ return NULL;
+ }
+
++ wl_if_setup(wlif->dev);
++
+ sprintf(wlif->dev->name, "%s%d.%d", devname, wl->pub->unit, wlif->subunit);
+ if (remote)
+ bcopy(remote, &wlif->remote, ETHER_ADDR_LEN);
diff --git a/package/broadcom-wl/patches/.svn/text-base/009-fix_compile_3_2.patch.svn-base b/package/broadcom-wl/patches/.svn/text-base/009-fix_compile_3_2.patch.svn-base
new file mode 100644
index 0000000..628f2fd
--- /dev/null
+++ b/package/broadcom-wl/patches/.svn/text-base/009-fix_compile_3_2.patch.svn-base
@@ -0,0 +1,27 @@
+--- a/driver/wl_linux.c
++++ b/driver/wl_linux.c
+@@ -462,6 +462,16 @@ wl_schedule_fn(wl_info_t *wl, void (*fn)
+ }
+ #endif /* DSLCPE_DELAY */
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0)
++#define WL_DEFAULT_OPS \
++ .ndo_open = wl_open, \
++ .ndo_stop = wl_close, \
++ .ndo_start_xmit = wl_start, \
++ .ndo_get_stats = wl_get_stats, \
++ .ndo_set_mac_address = wl_set_mac_address, \
++ .ndo_set_rx_mode = wl_set_multicast_list, \
++ .ndo_do_ioctl = wl_ioctl
++#else
+ #define WL_DEFAULT_OPS \
+ .ndo_open = wl_open, \
+ .ndo_stop = wl_close, \
+@@ -470,6 +480,7 @@ wl_schedule_fn(wl_info_t *wl, void (*fn)
+ .ndo_set_mac_address = wl_set_mac_address, \
+ .ndo_set_multicast_list = wl_set_multicast_list, \
+ .ndo_do_ioctl = wl_ioctl
++#endif
+
+ static const struct net_device_ops wl_ops = {
+ WL_DEFAULT_OPS,
diff --git a/package/broadcom-wl/patches/.svn/text-base/010-remove_irqf_samble_random.patch.svn-base b/package/broadcom-wl/patches/.svn/text-base/010-remove_irqf_samble_random.patch.svn-base
new file mode 100644
index 0000000..27b132d
--- /dev/null
+++ b/package/broadcom-wl/patches/.svn/text-base/010-remove_irqf_samble_random.patch.svn-base
@@ -0,0 +1,11 @@
+--- a/driver/wl_linux.c 2012-09-26 20:51:48.099454971 -0400
++++ b/driver/wl_linux.c 2012-09-26 20:53:24.115453441 -0400
+@@ -691,7 +691,7 @@
+ if (wl->bustype != JTAG_BUS)
+ #endif /* BCMJTAG */
+ {
+- if (request_irq(irq, wl_isr, IRQF_SHARED|IRQF_SAMPLE_RANDOM, dev->name, wl)) {
++ if (request_irq(irq, wl_isr, IRQF_SHARED, dev->name, wl)) {
+ WL_ERROR(("wl%d: request_irq() failed\n", unit));
+ goto fail;
+ }
diff --git a/package/broadcom-wl/patches/.svn/text-base/011-fix_compile_3_4.patch.svn-base b/package/broadcom-wl/patches/.svn/text-base/011-fix_compile_3_4.patch.svn-base
new file mode 100644
index 0000000..585d53c
--- /dev/null
+++ b/package/broadcom-wl/patches/.svn/text-base/011-fix_compile_3_4.patch.svn-base
@@ -0,0 +1,12 @@
+--- a/driver/wl_linux.c
++++ b/driver/wl_linux.c
+@@ -49,7 +49,9 @@
+ #include <linux/ieee80211.h>
+ #endif
+
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)
+ #include <asm/system.h>
++#endif
+ #include <asm/io.h>
+ #include <asm/irq.h>
+ #include <asm/pgtable.h>
diff --git a/package/broadcom-wl/patches/.svn/text-base/100-fix_nvram_two_devices.patch.svn-base b/package/broadcom-wl/patches/.svn/text-base/100-fix_nvram_two_devices.patch.svn-base
new file mode 100644
index 0000000..5650862
--- /dev/null
+++ b/package/broadcom-wl/patches/.svn/text-base/100-fix_nvram_two_devices.patch.svn-base
@@ -0,0 +1,32 @@
+--- a/driver/nvram_stub.c
++++ b/driver/nvram_stub.c
+@@ -22,6 +22,7 @@ typedef struct _vars {
+ #define VARS_T_OH sizeof(vars_t)
+
+ static vars_t *vars = NULL;
++static int nvram_init_done = 0;
+ extern char *nvram_buf[];
+
+ int
+@@ -33,6 +34,10 @@ BCMATTACHFN(nvram_init)(void *si)
+ uint nvs, bufsz;
+ vars_t *new;
+
++ nvram_init_done++;
++ if (nvram_init_done != 1)
++ return 0;
++
+ osh = si_osh(sih);
+
+ nvs = R_REG(osh, &nvh->len) - sizeof(struct nvram_header);
+@@ -79,6 +84,10 @@ BCMATTACHFN(nvram_exit)(void *si)
+ vars_t *this, *next;
+ si_t *sih;
+
++ nvram_init_done--;
++ if (nvram_init_done != 0)
++ return 0;
++
+ sih = (si_t *)si;
+ this = vars;
+ while (this) {
diff --git a/package/broadcom-wl/patches/.svn/text-base/110-add_number_to_dev_name.patch.svn-base b/package/broadcom-wl/patches/.svn/text-base/110-add_number_to_dev_name.patch.svn-base
new file mode 100644
index 0000000..13ce727
--- /dev/null
+++ b/package/broadcom-wl/patches/.svn/text-base/110-add_number_to_dev_name.patch.svn-base
@@ -0,0 +1,11 @@
+--- a/driver/wl_linux.c
++++ b/driver/wl_linux.c
+@@ -1412,7 +1412,7 @@ wl_alloc_if(wl_info_t *wl, int iftype, u
+ dev = alloc_etherdev(sizeof(wl_if_t));
+ wlif = netdev_priv(dev);
+ bzero(wlif, sizeof(wl_if_t));
+- strncpy(dev->name, name, IFNAMSIZ);
++ snprintf(dev->name, IFNAMSIZ, name, subunit);
+
+ wlif->type = iftype;
+ wlif->dev = dev;
diff --git a/package/broadcom-wl/patches/.svn/text-base/910-fallback-sprom.patch.svn-base b/package/broadcom-wl/patches/.svn/text-base/910-fallback-sprom.patch.svn-base
new file mode 100644
index 0000000..749ecbf
--- /dev/null
+++ b/package/broadcom-wl/patches/.svn/text-base/910-fallback-sprom.patch.svn-base
@@ -0,0 +1,84 @@
+--- a/driver/bcmsrom.c
++++ b/driver/bcmsrom.c
+@@ -39,6 +39,11 @@
+ #include <sbsdpcmdev.h>
+ #endif
+
++#if defined(CONFIG_SSB_PCIHOST) && defined(CONFIG_BOARD_BCM963XX)
++#include <linux/ssb/ssb.h>
++extern struct ssb_sprom bcm63xx_sprom;
++#endif
++
+ #ifdef WLTEST
+ #include <sbsprom.h>
+ #endif /* WLTEST */
+@@ -2058,6 +2063,10 @@ BCMATTACHFN(initvars_srom_pci)(si_t *sih
+ bool flash = FALSE;
+ int err = 0;
+
++#if defined(CONFIG_SSB_PCIHOST) && defined(CONFIG_BOARD_BCM963XX)
++ char eabuf[18];
++#endif
++
+ /*
+ * Apply CRC over SROM content regardless SROM is present or not,
+ * and use variable <devpath>sromrev's existance in flash to decide
+@@ -2120,6 +2129,58 @@ BCMATTACHFN(initvars_srom_pci)(si_t *sih
+ goto varscont;
+ }
+
++#if defined(CONFIG_SSB_PCIHOST) && defined(CONFIG_BOARD_BCM963XX)
++ base = vp = MALLOC(osh, MAXSZ_NVRAM_VARS);
++
++ if( base != NULL )
++ {
++ varbuf_init(&b, base, MAXSZ_NVRAM_VARS);
++
++ printk("Got version %i SPROM from SSB\n", bcm63xx_sprom.revision);
++
++ varbuf_append(&b, vstr_sromrev, bcm63xx_sprom.revision);
++ varbuf_append(&b, vstr_boardrev, bcm63xx_sprom.board_rev);
++
++ /* ToDo: map bcm63xx_sprom.country_code */
++ varbuf_append(&b, vstr_noccode);
++
++ varbuf_append(&b, vstr_aa2g, bcm63xx_sprom.ant_available_bg);
++
++ varbuf_append(&b, vstr_pa0b[0], bcm63xx_sprom.pa0b0);
++ varbuf_append(&b, vstr_pa1b[0], bcm63xx_sprom.pa1b0);
++ varbuf_append(&b, vstr_pa0b[1], bcm63xx_sprom.pa0b1);
++ varbuf_append(&b, vstr_pa1b[1], bcm63xx_sprom.pa1b1);
++ varbuf_append(&b, vstr_pa0b[2], bcm63xx_sprom.pa0b2);
++ varbuf_append(&b, vstr_pa1b[2], bcm63xx_sprom.pa1b2);
++
++ varbuf_append(&b, vstr_pa0maxpwr, bcm63xx_sprom.maxpwr_bg);
++ varbuf_append(&b, vstr_pa0itssit, bcm63xx_sprom.itssi_bg);
++
++ varbuf_append(&b, vstr_boardflags, (bcm63xx_sprom.boardflags_hi << 16) | bcm63xx_sprom.boardflags_lo);
++ varbuf_append(&b, vstr_boardflags2, (bcm63xx_sprom.boardflags2_hi << 16) | bcm63xx_sprom.boardflags2_lo);
++
++ snprintf(eabuf, sizeof(eabuf), "%02x:%02x:%02x:%02x:%02x:%02x",
++ bcm63xx_sprom.il0mac[0], bcm63xx_sprom.il0mac[1], bcm63xx_sprom.il0mac[2],
++ bcm63xx_sprom.il0mac[3], bcm63xx_sprom.il0mac[4], bcm63xx_sprom.il0mac[5]
++ );
++
++ varbuf_append(&b, vstr_macaddr, eabuf);
++
++ /* final nullbyte terminator */
++ ASSERT(b.size >= 1);
++ vp = b.buf;
++ *vp++ = '\0';
++
++ ASSERT((vp - base) <= MAXSZ_NVRAM_VARS);
++ goto varsdone;
++ }
++ else
++ {
++ err = -2;
++ goto errout;
++ }
++#endif
++
+ BS_ERROR(("SROM CRC Error\n"));
+
+ #if defined(WLTEST)
diff --git a/package/broadcom-wl/patches/.svn/text-base/912-pci-bus-nvram-hack.patch.svn-base b/package/broadcom-wl/patches/.svn/text-base/912-pci-bus-nvram-hack.patch.svn-base
new file mode 100644
index 0000000..65e8bd3
--- /dev/null
+++ b/package/broadcom-wl/patches/.svn/text-base/912-pci-bus-nvram-hack.patch.svn-base
@@ -0,0 +1,11 @@
+--- a/driver/siutils.c
++++ b/driver/siutils.c
+@@ -1859,7 +1859,7 @@ BCMINITFN(si_devpath)(si_t *sih, char *p
+ case PCI_BUS:
+ ASSERT((SI_INFO(sih))->osh != NULL);
+ slen = snprintf(path, (size_t)size, "pci/%u/%u/",
+- OSL_PCI_BUS((SI_INFO(sih))->osh),
++ OSL_PCI_BUS((SI_INFO(sih))->osh) + 1,
+ OSL_PCI_SLOT((SI_INFO(sih))->osh));
+ break;
+ case PCMCIA_BUS:
diff --git a/package/broadcom-wl/patches/.svn/text-base/913-avoid-dbe-on-ifs_ctl-readw-hack.patch.svn-base b/package/broadcom-wl/patches/.svn/text-base/913-avoid-dbe-on-ifs_ctl-readw-hack.patch.svn-base
new file mode 100644
index 0000000..412bce9
--- /dev/null
+++ b/package/broadcom-wl/patches/.svn/text-base/913-avoid-dbe-on-ifs_ctl-readw-hack.patch.svn-base
@@ -0,0 +1,12 @@
+--- a/driver/linux_osl.c
++++ b/driver/linux_osl.c
+@@ -723,6 +723,9 @@ osl_readl(volatile uint32 *r)
+ uint16
+ osl_readw(volatile uint16 *r)
+ {
++ uint32 addr = (uintptr)r & 0xffff3fff;
++ if (addr == 0xa8000688) /* ifs_ctl */
++ readl(r);
+ return (readw(r));
+ }
+
diff --git a/package/broadcom-wl/patches/003-compat-2.6.35.patch b/package/broadcom-wl/patches/003-compat-2.6.35.patch
new file mode 100644
index 0000000..89b6653
--- /dev/null
+++ b/package/broadcom-wl/patches/003-compat-2.6.35.patch
@@ -0,0 +1,39 @@
+--- a/driver/wl_linux.c
++++ b/driver/wl_linux.c
+@@ -2082,7 +2082,11 @@ static void
+ _wl_set_multicast_list(struct net_device *dev)
+ {
+ wl_info_t *wl;
++#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,34)
+ struct dev_mc_list *mclist;
++#else
++ struct netdev_hw_addr *ha;
++#endif
+ int i;
+
+ if (!dev)
+@@ -2098,14 +2102,24 @@ _wl_set_multicast_list(struct net_device
+ wl->pub->allmulti = (dev->flags & IFF_ALLMULTI)? TRUE: FALSE;
+
+ /* copy the list of multicasts into our private table */
++#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,34)
+ for (i = 0, mclist = dev->mc_list; mclist && (i < dev->mc_count);
+ i++, mclist = mclist->next) {
++#else
++ i = 0;
++ netdev_for_each_mc_addr(ha, dev) {
++#endif
+ if (i >= MAXMULTILIST) {
+ wl->pub->allmulti = TRUE;
+ i = 0;
+ break;
+ }
++#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,34)
+ wl->pub->multicast[i] = *((struct ether_addr*) mclist->dmi_addr);
++#else
++ wl->pub->multicast[i] = *((struct ether_addr*) ha->addr);
++ i++;
++#endif
+ }
+ wl->pub->nmulticast = i;
+ wlc_set(wl->wlc, WLC_SET_PROMISC, (dev->flags & IFF_PROMISC));
diff --git a/package/broadcom-wl/patches/004-remove-pcmcia.patch b/package/broadcom-wl/patches/004-remove-pcmcia.patch
new file mode 100644
index 0000000..36dda47
--- /dev/null
+++ b/package/broadcom-wl/patches/004-remove-pcmcia.patch
@@ -0,0 +1,22 @@
+--- a/driver/include/linuxver.h
++++ b/driver/include/linuxver.h
+@@ -111,7 +111,7 @@ typedef irqreturn_t(*FN_ISR) (int irq, v
+ #endif /* not SANDGATE2G */
+ #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 67) */
+
+-#if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE)
++#if 0
+
+ #include <pcmcia/cs_types.h>
+ #include <pcmcia/cs.h>
+--- a/driver/linux_osl.c
++++ b/driver/linux_osl.c
+@@ -62,7 +62,7 @@ struct osl_info {
+ };
+
+ /* PCMCIA attribute space access macros */
+-#if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE)
++#if 0
+ struct pcmcia_dev {
+ dev_link_t link; /* PCMCIA device pointer */
+ dev_node_t node; /* PCMCIA node structure */
diff --git a/package/broadcom-wl/patches/005-fix-mem-leak-on-unload.patch b/package/broadcom-wl/patches/005-fix-mem-leak-on-unload.patch
new file mode 100644
index 0000000..41c246f
--- /dev/null
+++ b/package/broadcom-wl/patches/005-fix-mem-leak-on-unload.patch
@@ -0,0 +1,31 @@
+From: George Kashperko <george@znau.edu.ua>
+
+Release nvram variables buffer.
+Prevent block reserved by alloc_etherdev from being freed.
+Signed-off-by: George Kashperko <george@znau.edu.ua>
+---
+---
+--- a/driver/siutils.c
++++ b/driver/siutils.c
+@@ -647,7 +647,10 @@ si_detach(si_t *sih)
+ #if !defined(BCMBUSTYPE) || (BCMBUSTYPE == SI_BUS)
+ if (sii != &ksii)
+ #endif /* !BCMBUSTYPE || (BCMBUSTYPE == SI_BUS) */
+- MFREE(sii->osh, sii, sizeof(si_info_t));
++ do {
++ MFREE(sii->osh, sii, sizeof(si_info_t));
++ nvram_exit((void *)&(sii->pub));
++ } while (0);
+ }
+
+ void *
+--- a/driver/wl_linux.c
++++ b/driver/wl_linux.c
+@@ -1477,7 +1477,6 @@ wl_free_if(wl_info_t *wl, wl_if_t *wlif)
+ free_netdev(wlif->dev);
+ #endif
+ }
+- MFREE(wl->osh, wlif, sizeof(wl_if_t));
+ }
+
+ #ifdef AP
diff --git a/package/broadcom-wl/patches/006-generic-dma-api.patch b/package/broadcom-wl/patches/006-generic-dma-api.patch
new file mode 100644
index 0000000..a90bbe1
--- /dev/null
+++ b/package/broadcom-wl/patches/006-generic-dma-api.patch
@@ -0,0 +1,88 @@
+From: George Kashperko <george@znau.edu.ua>
+
+broadcom-wl driver bound to ssb device with ssb driver probe
+have osh handle struct pdev pointer value initialized with
+ssb_device pointer. Later on pdev is used with legacy pci
+dma api as pci_dev thus causing oops sometimes.
+
+The patch replaces legacy pci dma api and pass relevant
+device struct pointer to avoid crashes.
+Signed-off-by: George Kashperko <george@znau.edu.ua>
+---
+ driver/linux_osl.c | 28 +++++++++++++++++++++++-----
+ 1 file changed, 23 insertions(+), 5 deletions(-)
+--- a/driver/linux_osl.c
++++ b/driver/linux_osl.c
+@@ -25,6 +25,9 @@
+ #include <asm/paccess.h>
+ #endif /* mips */
+ #include <pcicfg.h>
++#ifdef CONFIG_SSB
++#include <linux/ssb/ssb.h>
++#endif
+
+ #define PCI_CFG_RETRY 10
+
+@@ -364,12 +367,27 @@ osl_dma_consistent_align(void)
+ return (PAGE_SIZE);
+ }
+
++static struct device *
++osl_get_dmadev(osl_t *osh)
++{
++#ifdef CONFIG_SSB
++ if (osh->bustype == SI_BUS) {
++ /* This can be SiliconBackplane emulated as pci with Broadcom or
++ * ssb device. Less harmful is to check for pci_bus_type and if
++ * no match then assume we got ssb */
++ if (((struct pci_dev *)osh->pdev)->dev.bus != &pci_bus_type)
++ return ((struct ssb_device *)osh->pdev)->dma_dev;
++ }
++#endif
++ return &((struct pci_dev *)osh->pdev)->dev;
++}
++
+ void*
+ osl_dma_alloc_consistent(osl_t *osh, uint size, ulong *pap)
+ {
+ ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
+
+- return (pci_alloc_consistent(osh->pdev, size, (dma_addr_t*)pap));
++ return (dma_alloc_coherent(osl_get_dmadev(osh), size, (dma_addr_t*)pap, GFP_ATOMIC));
+ }
+
+ void
+@@ -377,7 +395,7 @@ osl_dma_free_consistent(osl_t *osh, void
+ {
+ ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
+
+- pci_free_consistent(osh->pdev, size, va, (dma_addr_t)pa);
++ dma_free_coherent(osl_get_dmadev(osh), size, va, (dma_addr_t)pa);
+ }
+
+ uint BCMFASTPATH
+@@ -386,13 +404,13 @@ osl_dma_map(osl_t *osh, void *va, uint s
+ ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
+
+ if (direction == DMA_TX)
+- return (pci_map_single(osh->pdev, va, size, PCI_DMA_TODEVICE));
++ return (dma_map_single(osl_get_dmadev(osh), va, size, PCI_DMA_TODEVICE));
+ else {
+ #ifdef mips
+ dma_cache_inv((uint)va, size);
+ return (virt_to_phys(va));
+ #else /* mips */
+- return (pci_map_single(osh->pdev, va, size, PCI_DMA_FROMDEVICE));
++ return (dma_map_single(osl_get_dmadev(osh), va, size, PCI_DMA_FROMDEVICE));
+ #endif /* mips */
+ }
+ }
+@@ -404,7 +422,7 @@ osl_dma_unmap(osl_t *osh, uint pa, uint
+
+ ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
+ dir = (direction == DMA_TX)? PCI_DMA_TODEVICE: PCI_DMA_FROMDEVICE;
+- pci_unmap_single(osh->pdev, (uint32)pa, size, dir);
++ dma_unmap_single(osl_get_dmadev(osh), (uint32)pa, size, dir);
+ }
+
+
diff --git a/package/broadcom-wl/patches/007-use-glue-driver.patch b/package/broadcom-wl/patches/007-use-glue-driver.patch
new file mode 100644
index 0000000..2639abc
--- /dev/null
+++ b/package/broadcom-wl/patches/007-use-glue-driver.patch
@@ -0,0 +1,184 @@
+--- a/driver/wl_linux.c
++++ b/driver/wl_linux.c
+@@ -85,10 +85,9 @@ typedef void wlc_hw_info_t;
+ #include <bcmjtag.h>
+ #endif /* BCMJTAG */
+
+-
+-#ifdef CONFIG_SSB
+-#include <linux/ssb/ssb.h>
+-#endif
++#if defined(CONFIG_SSB) || defined(CONFIG_BCMA)
++#include <wl_glue.h>
++#endif /* defined(CONFIG_SSB) || defined(CONFIG_BCMA) */
+
+ /* Linux wireless extension support */
+ #ifdef CONFIG_WIRELESS_EXT
+@@ -997,62 +996,32 @@ static struct pci_driver wl_pci_driver =
+ #endif /* CONFIG_PCI */
+ #endif
+
++#ifdef BCMJTAG
++static bcmjtag_driver_t wl_jtag_driver = {
++ wl_jtag_probe,
++ wl_jtag_detach,
++ wl_jtag_poll,
++ };
++#endif /* BCMJTAG */
+
+-static int wl_ssb_probe(struct ssb_device *dev, const struct ssb_device_id *id)
++#if defined(CONFIG_SSB) || defined(CONFIG_BCMA)
++static void * glue_attach_cb(u16 vendor, u16 device,
++ ulong mmio, void *dev, u32 irq)
+ {
+- wl_info_t *wl;
+- void *mmio;
+-
+- if (dev->bus->bustype != SSB_BUSTYPE_SSB) {
+- printk("Attaching to SSB behind PCI is not supported. Please remove the b43 ssb bridge\n");
+- return -EINVAL;
+- }
+-
+- mmio = (void *) 0x18000000 + dev->core_index * 0x1000;
+- wl = wl_attach(id->vendor, id->coreid, (ulong) mmio, SI_BUS, dev, dev->irq);
+- if (!wl) {
+- printk("wl_attach failed\n");
+- return -ENODEV;
+- }
+-
+- ssb_set_drvdata(dev, wl);
+-
+- return 0;
++ return wl_attach(vendor, device, mmio, SI_BUS, dev, irq);
+ }
+
+-static void wl_ssb_remove(struct ssb_device *dev)
++static void glue_remove_cb(void *wldev)
+ {
+- wl_info_t *wl = (wl_info_t *) ssb_get_drvdata(dev);
++ wl_info_t *wl = (wl_info_t *)wldev;
+
+ WL_LOCK(wl);
+ WL_APSTA_UPDN(("wl%d (%s): wl_remove() -> wl_down()\n", wl->pub->unit, wl->dev->name));
+ wl_down(wl);
+ WL_UNLOCK(wl);
+ wl_free(wl);
+- ssb_set_drvdata(dev, NULL);
+ }
+-
+-static const struct ssb_device_id wl_ssb_tbl[] = {
+- SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_80211, SSB_ANY_REV),
+- SSB_DEVTABLE_END
+-};
+-
+-#ifdef CONFIG_SSB
+-static struct ssb_driver wl_ssb_driver = {
+- .name = KBUILD_MODNAME,
+- .id_table = wl_ssb_tbl,
+- .probe = wl_ssb_probe,
+- .remove = wl_ssb_remove,
+-};
+-#endif
+-
+-#ifdef BCMJTAG
+-static bcmjtag_driver_t wl_jtag_driver = {
+- wl_jtag_probe,
+- wl_jtag_detach,
+- wl_jtag_poll,
+- };
+-#endif /* BCMJTAG */
++#endif/* defined(CONFIG_SSB) || defined(CONFIG_BCMA) */
+
+
+ /**
+@@ -1067,11 +1036,13 @@ wl_module_init(void)
+ {
+ int error = -ENODEV;
+
+-#ifdef CONFIG_SSB
+- error = ssb_driver_register(&wl_ssb_driver);
++#if defined(CONFIG_SSB) || defined(CONFIG_BCMA)
++ wl_glue_set_attach_callback(&glue_attach_cb);
++ wl_glue_set_remove_callback(&glue_remove_cb);
++ error = wl_glue_register();
+ if (error)
+ return error;
+-#endif /* CONFIG_SSB */
++#endif /* defined(CONFIG_SSB) || defined(CONFIG_BCMA) */
+
+ #ifdef CONFIG_PCI
+ error = pci_register_driver(&wl_pci_driver);
+@@ -1082,7 +1053,9 @@ wl_module_init(void)
+ return 0;
+
+ error_pci:
+- ssb_driver_unregister(&wl_ssb_driver);
++#if defined(CONFIG_SSB) || defined(CONFIG_BCMA)
++ wl_glue_unregister();
++#endif /* defined(CONFIG_SSB) || defined(CONFIG_BCMA) */
+ return error;
+ }
+
+@@ -1099,9 +1072,9 @@ wl_module_exit(void)
+ #ifdef CONFIG_PCI
+ pci_unregister_driver(&wl_pci_driver);
+ #endif /* CONFIG_PCI */
+-#ifdef CONFIG_SSB
+- ssb_driver_unregister(&wl_ssb_driver);
+-#endif /* CONFIG_SSB */
++#if defined(CONFIG_SSB) || defined(CONFIG_BCMA)
++ wl_glue_unregister();
++#endif /* defined(CONFIG_SSB) || defined(CONFIG_BCMA) */
+ }
+
+ module_init(wl_module_init);
+--- a/driver/linux_osl.c
++++ b/driver/linux_osl.c
+@@ -25,9 +25,9 @@
+ #include <asm/paccess.h>
+ #endif /* mips */
+ #include <pcicfg.h>
+-#ifdef CONFIG_SSB
+-#include <linux/ssb/ssb.h>
+-#endif
++#if defined(CONFIG_SSB) || defined(CONFIG_BCMA)
++#include <wl_glue.h>
++#endif /* defined(CONFIG_SSB) || defined(CONFIG_BCMA) */
+
+ #define PCI_CFG_RETRY 10
+
+@@ -370,15 +370,17 @@ osl_dma_consistent_align(void)
+ static struct device *
+ osl_get_dmadev(osl_t *osh)
+ {
+-#ifdef CONFIG_SSB
++#if defined(CONFIG_SSB) || defined(CONFIG_BCMA)
+ if (osh->bustype == SI_BUS) {
+- /* This can be SiliconBackplane emulated as pci with Broadcom or
+- * ssb device. Less harmful is to check for pci_bus_type and if
+- * no match then assume we got ssb */
++ /* This can be SiliconBackplane emulated as pci with Broadcom,
++ * ssb or bcma device. Less harmful is to check for pci_bus_type and if
++ * no match then assume we got either ssb or bcma */
+ if (((struct pci_dev *)osh->pdev)->dev.bus != &pci_bus_type)
+- return ((struct ssb_device *)osh->pdev)->dma_dev;
++ {
++ return wl_glue_get_dmadev(osh->pdev);
++ }
+ }
+-#endif
++#endif /* defined(CONFIG_SSB) || defined(CONFIG_BCMA) */
+ return &((struct pci_dev *)osh->pdev)->dev;
+ }
+
+--- a/driver/Makefile
++++ b/driver/Makefile
+@@ -1,7 +1,7 @@
+ BUILD_TYPE=wl_apsta
+ include $(src)/$(BUILD_TYPE)/buildflags.mk
+
+-EXTRA_CFLAGS += -I$(src)/include -I$(src) -DBCMDRIVER $(WLFLAGS)
++EXTRA_CFLAGS += -I$(src)/include -I$(src) -I$(realpath $(src)/../glue) -DBCMDRIVER $(WLFLAGS)
+
+ wl-objs := $(BUILD_TYPE)/wl_prebuilt.o wl_iw.o wl_linux.o linux_osl.o siutils.o aiutils.o hndpmu.o bcmutils.o sbutils.o nicpci.o hnddma.o bcmsrom.o nvram_stub.o
+
diff --git a/package/broadcom-wl/patches/008-fix_virtual_interfaces.patch b/package/broadcom-wl/patches/008-fix_virtual_interfaces.patch
new file mode 100644
index 0000000..6cffa27
--- /dev/null
+++ b/package/broadcom-wl/patches/008-fix_virtual_interfaces.patch
@@ -0,0 +1,11 @@
+--- a/driver/wl_linux.c
++++ b/driver/wl_linux.c
+@@ -1541,6 +1541,8 @@ wl_add_if(wl_info_t *wl, struct wlc_if*
+ return NULL;
+ }
+
++ wl_if_setup(wlif->dev);
++
+ sprintf(wlif->dev->name, "%s%d.%d", devname, wl->pub->unit, wlif->subunit);
+ if (remote)
+ bcopy(remote, &wlif->remote, ETHER_ADDR_LEN);
diff --git a/package/broadcom-wl/patches/009-fix_compile_3_2.patch b/package/broadcom-wl/patches/009-fix_compile_3_2.patch
new file mode 100644
index 0000000..628f2fd
--- /dev/null
+++ b/package/broadcom-wl/patches/009-fix_compile_3_2.patch
@@ -0,0 +1,27 @@
+--- a/driver/wl_linux.c
++++ b/driver/wl_linux.c
+@@ -462,6 +462,16 @@ wl_schedule_fn(wl_info_t *wl, void (*fn)
+ }
+ #endif /* DSLCPE_DELAY */
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0)
++#define WL_DEFAULT_OPS \
++ .ndo_open = wl_open, \
++ .ndo_stop = wl_close, \
++ .ndo_start_xmit = wl_start, \
++ .ndo_get_stats = wl_get_stats, \
++ .ndo_set_mac_address = wl_set_mac_address, \
++ .ndo_set_rx_mode = wl_set_multicast_list, \
++ .ndo_do_ioctl = wl_ioctl
++#else
+ #define WL_DEFAULT_OPS \
+ .ndo_open = wl_open, \
+ .ndo_stop = wl_close, \
+@@ -470,6 +480,7 @@ wl_schedule_fn(wl_info_t *wl, void (*fn)
+ .ndo_set_mac_address = wl_set_mac_address, \
+ .ndo_set_multicast_list = wl_set_multicast_list, \
+ .ndo_do_ioctl = wl_ioctl
++#endif
+
+ static const struct net_device_ops wl_ops = {
+ WL_DEFAULT_OPS,
diff --git a/package/broadcom-wl/patches/010-remove_irqf_samble_random.patch b/package/broadcom-wl/patches/010-remove_irqf_samble_random.patch
new file mode 100644
index 0000000..27b132d
--- /dev/null
+++ b/package/broadcom-wl/patches/010-remove_irqf_samble_random.patch
@@ -0,0 +1,11 @@
+--- a/driver/wl_linux.c 2012-09-26 20:51:48.099454971 -0400
++++ b/driver/wl_linux.c 2012-09-26 20:53:24.115453441 -0400
+@@ -691,7 +691,7 @@
+ if (wl->bustype != JTAG_BUS)
+ #endif /* BCMJTAG */
+ {
+- if (request_irq(irq, wl_isr, IRQF_SHARED|IRQF_SAMPLE_RANDOM, dev->name, wl)) {
++ if (request_irq(irq, wl_isr, IRQF_SHARED, dev->name, wl)) {
+ WL_ERROR(("wl%d: request_irq() failed\n", unit));
+ goto fail;
+ }
diff --git a/package/broadcom-wl/patches/011-fix_compile_3_4.patch b/package/broadcom-wl/patches/011-fix_compile_3_4.patch
new file mode 100644
index 0000000..585d53c
--- /dev/null
+++ b/package/broadcom-wl/patches/011-fix_compile_3_4.patch
@@ -0,0 +1,12 @@
+--- a/driver/wl_linux.c
++++ b/driver/wl_linux.c
+@@ -49,7 +49,9 @@
+ #include <linux/ieee80211.h>
+ #endif
+
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)
+ #include <asm/system.h>
++#endif
+ #include <asm/io.h>
+ #include <asm/irq.h>
+ #include <asm/pgtable.h>
diff --git a/package/broadcom-wl/patches/100-fix_nvram_two_devices.patch b/package/broadcom-wl/patches/100-fix_nvram_two_devices.patch
new file mode 100644
index 0000000..5650862
--- /dev/null
+++ b/package/broadcom-wl/patches/100-fix_nvram_two_devices.patch
@@ -0,0 +1,32 @@
+--- a/driver/nvram_stub.c
++++ b/driver/nvram_stub.c
+@@ -22,6 +22,7 @@ typedef struct _vars {
+ #define VARS_T_OH sizeof(vars_t)
+
+ static vars_t *vars = NULL;
++static int nvram_init_done = 0;
+ extern char *nvram_buf[];
+
+ int
+@@ -33,6 +34,10 @@ BCMATTACHFN(nvram_init)(void *si)
+ uint nvs, bufsz;
+ vars_t *new;
+
++ nvram_init_done++;
++ if (nvram_init_done != 1)
++ return 0;
++
+ osh = si_osh(sih);
+
+ nvs = R_REG(osh, &nvh->len) - sizeof(struct nvram_header);
+@@ -79,6 +84,10 @@ BCMATTACHFN(nvram_exit)(void *si)
+ vars_t *this, *next;
+ si_t *sih;
+
++ nvram_init_done--;
++ if (nvram_init_done != 0)
++ return 0;
++
+ sih = (si_t *)si;
+ this = vars;
+ while (this) {
diff --git a/package/broadcom-wl/patches/110-add_number_to_dev_name.patch b/package/broadcom-wl/patches/110-add_number_to_dev_name.patch
new file mode 100644
index 0000000..13ce727
--- /dev/null
+++ b/package/broadcom-wl/patches/110-add_number_to_dev_name.patch
@@ -0,0 +1,11 @@
+--- a/driver/wl_linux.c
++++ b/driver/wl_linux.c
+@@ -1412,7 +1412,7 @@ wl_alloc_if(wl_info_t *wl, int iftype, u
+ dev = alloc_etherdev(sizeof(wl_if_t));
+ wlif = netdev_priv(dev);
+ bzero(wlif, sizeof(wl_if_t));
+- strncpy(dev->name, name, IFNAMSIZ);
++ snprintf(dev->name, IFNAMSIZ, name, subunit);
+
+ wlif->type = iftype;
+ wlif->dev = dev;
diff --git a/package/broadcom-wl/patches/910-fallback-sprom.patch b/package/broadcom-wl/patches/910-fallback-sprom.patch
new file mode 100644
index 0000000..749ecbf
--- /dev/null
+++ b/package/broadcom-wl/patches/910-fallback-sprom.patch
@@ -0,0 +1,84 @@
+--- a/driver/bcmsrom.c
++++ b/driver/bcmsrom.c
+@@ -39,6 +39,11 @@
+ #include <sbsdpcmdev.h>
+ #endif
+
++#if defined(CONFIG_SSB_PCIHOST) && defined(CONFIG_BOARD_BCM963XX)
++#include <linux/ssb/ssb.h>
++extern struct ssb_sprom bcm63xx_sprom;
++#endif
++
+ #ifdef WLTEST
+ #include <sbsprom.h>
+ #endif /* WLTEST */
+@@ -2058,6 +2063,10 @@ BCMATTACHFN(initvars_srom_pci)(si_t *sih
+ bool flash = FALSE;
+ int err = 0;
+
++#if defined(CONFIG_SSB_PCIHOST) && defined(CONFIG_BOARD_BCM963XX)
++ char eabuf[18];
++#endif
++
+ /*
+ * Apply CRC over SROM content regardless SROM is present or not,
+ * and use variable <devpath>sromrev's existance in flash to decide
+@@ -2120,6 +2129,58 @@ BCMATTACHFN(initvars_srom_pci)(si_t *sih
+ goto varscont;
+ }
+
++#if defined(CONFIG_SSB_PCIHOST) && defined(CONFIG_BOARD_BCM963XX)
++ base = vp = MALLOC(osh, MAXSZ_NVRAM_VARS);
++
++ if( base != NULL )
++ {
++ varbuf_init(&b, base, MAXSZ_NVRAM_VARS);
++
++ printk("Got version %i SPROM from SSB\n", bcm63xx_sprom.revision);
++
++ varbuf_append(&b, vstr_sromrev, bcm63xx_sprom.revision);
++ varbuf_append(&b, vstr_boardrev, bcm63xx_sprom.board_rev);
++
++ /* ToDo: map bcm63xx_sprom.country_code */
++ varbuf_append(&b, vstr_noccode);
++
++ varbuf_append(&b, vstr_aa2g, bcm63xx_sprom.ant_available_bg);
++
++ varbuf_append(&b, vstr_pa0b[0], bcm63xx_sprom.pa0b0);
++ varbuf_append(&b, vstr_pa1b[0], bcm63xx_sprom.pa1b0);
++ varbuf_append(&b, vstr_pa0b[1], bcm63xx_sprom.pa0b1);
++ varbuf_append(&b, vstr_pa1b[1], bcm63xx_sprom.pa1b1);
++ varbuf_append(&b, vstr_pa0b[2], bcm63xx_sprom.pa0b2);
++ varbuf_append(&b, vstr_pa1b[2], bcm63xx_sprom.pa1b2);
++
++ varbuf_append(&b, vstr_pa0maxpwr, bcm63xx_sprom.maxpwr_bg);
++ varbuf_append(&b, vstr_pa0itssit, bcm63xx_sprom.itssi_bg);
++
++ varbuf_append(&b, vstr_boardflags, (bcm63xx_sprom.boardflags_hi << 16) | bcm63xx_sprom.boardflags_lo);
++ varbuf_append(&b, vstr_boardflags2, (bcm63xx_sprom.boardflags2_hi << 16) | bcm63xx_sprom.boardflags2_lo);
++
++ snprintf(eabuf, sizeof(eabuf), "%02x:%02x:%02x:%02x:%02x:%02x",
++ bcm63xx_sprom.il0mac[0], bcm63xx_sprom.il0mac[1], bcm63xx_sprom.il0mac[2],
++ bcm63xx_sprom.il0mac[3], bcm63xx_sprom.il0mac[4], bcm63xx_sprom.il0mac[5]
++ );
++
++ varbuf_append(&b, vstr_macaddr, eabuf);
++
++ /* final nullbyte terminator */
++ ASSERT(b.size >= 1);
++ vp = b.buf;
++ *vp++ = '\0';
++
++ ASSERT((vp - base) <= MAXSZ_NVRAM_VARS);
++ goto varsdone;
++ }
++ else
++ {
++ err = -2;
++ goto errout;
++ }
++#endif
++
+ BS_ERROR(("SROM CRC Error\n"));
+
+ #if defined(WLTEST)
diff --git a/package/broadcom-wl/patches/912-pci-bus-nvram-hack.patch b/package/broadcom-wl/patches/912-pci-bus-nvram-hack.patch
new file mode 100644
index 0000000..65e8bd3
--- /dev/null
+++ b/package/broadcom-wl/patches/912-pci-bus-nvram-hack.patch
@@ -0,0 +1,11 @@
+--- a/driver/siutils.c
++++ b/driver/siutils.c
+@@ -1859,7 +1859,7 @@ BCMINITFN(si_devpath)(si_t *sih, char *p
+ case PCI_BUS:
+ ASSERT((SI_INFO(sih))->osh != NULL);
+ slen = snprintf(path, (size_t)size, "pci/%u/%u/",
+- OSL_PCI_BUS((SI_INFO(sih))->osh),
++ OSL_PCI_BUS((SI_INFO(sih))->osh) + 1,
+ OSL_PCI_SLOT((SI_INFO(sih))->osh));
+ break;
+ case PCMCIA_BUS:
diff --git a/package/broadcom-wl/patches/913-avoid-dbe-on-ifs_ctl-readw-hack.patch b/package/broadcom-wl/patches/913-avoid-dbe-on-ifs_ctl-readw-hack.patch
new file mode 100644
index 0000000..412bce9
--- /dev/null
+++ b/package/broadcom-wl/patches/913-avoid-dbe-on-ifs_ctl-readw-hack.patch
@@ -0,0 +1,12 @@
+--- a/driver/linux_osl.c
++++ b/driver/linux_osl.c
+@@ -723,6 +723,9 @@ osl_readl(volatile uint32 *r)
+ uint16
+ osl_readw(volatile uint16 *r)
+ {
++ uint32 addr = (uintptr)r & 0xffff3fff;
++ if (addr == 0xa8000688) /* ifs_ctl */
++ readl(r);
+ return (readw(r));
+ }
+
diff --git a/package/broadcom-wl/src/.svn/entries b/package/broadcom-wl/src/.svn/entries
new file mode 100644
index 0000000..6b3442e
--- /dev/null
+++ b/package/broadcom-wl/src/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/broadcom-wl/src
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-12-13T18:55:49.509483Z
+34671
+hauke
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+wlc.c
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+6f7d03464760b3908e2f050665cfcb61
+2010-06-15T11:40:05.314754Z
+21809
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+23761
+
+glue
+dir
+
diff --git a/package/broadcom-wl/src/.svn/text-base/wlc.c.svn-base b/package/broadcom-wl/src/.svn/text-base/wlc.c.svn-base
new file mode 100644
index 0000000..253809c
--- /dev/null
+++ b/package/broadcom-wl/src/.svn/text-base/wlc.c.svn-base
@@ -0,0 +1,1086 @@
+/*
+ * wlc - Broadcom Wireless Driver Control Utility
+ *
+ * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
+ *
+ * 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
+ * of the License, 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.
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#include <glob.h>
+#include <ctype.h>
+
+#include <typedefs.h>
+#include <wlutils.h>
+#include <proto/802.11.h>
+
+#define VERSION "0.1"
+#define BUFSIZE 8192
+#define PTABLE_MAGIC 0xbadc0ded
+#define PTABLE_SLT1 1
+#define PTABLE_SLT2 2
+#define PTABLE_ACKW 3
+#define PTABLE_ADHM 4
+#define PTABLE_END 0xffffffff
+
+/*
+ * Copy each token in wordlist delimited by space into word
+ * Taken from Broadcom shutils.h
+ */
+#define foreach(word, wordlist, next) \
+ for (next = &wordlist[strspn(wordlist, " ")], \
+ strncpy(word, next, sizeof(word)), \
+ word[strcspn(word, " ")] = '\0', \
+ word[sizeof(word) - 1] = '\0', \
+ next = strchr(next, ' '); \
+ strlen(word); \
+ next = next ? &next[strspn(next, " ")] : "", \
+ strncpy(word, next, sizeof(word)), \
+ word[strcspn(word, " ")] = '\0', \
+ word[sizeof(word) - 1] = '\0', \
+ next = strchr(next, ' '))
+
+static char wlbuf[8192];
+static char interface[16] = "wl0";
+static unsigned long kmem_offset = 0;
+static int vif = 0, debug = 1, fromstdin = 0;
+
+typedef enum {
+ NONE = 0x00,
+
+ /* types */
+ PARAM_TYPE = 0x00f,
+ INT = 0x001,
+ STRING = 0x002,
+ MAC = 0x003,
+
+ /* options */
+ PARAM_OPTIONS = 0x0f0,
+ NOARG = 0x010,
+
+ /* modes */
+ PARAM_MODE = 0xf00,
+ GET = 0x100,
+ SET = 0x200,
+} wlc_param;
+
+struct wlc_call {
+ const char *name;
+ wlc_param param;
+ int (*handler)(wlc_param param, void *data, void *value);
+ union {
+ int num;
+ char *str;
+ void *ptr;
+ } data;
+ const char *desc;
+};
+
+/* can't use the system include because of the stupid broadcom header files */
+extern struct ether_addr *ether_aton(const char *asc);
+static inline int my_ether_ntoa(unsigned char *ea, char *buf)
+{
+ return sprintf(buf, "%02x:%02x:%02x:%02x:%02x:%02x",
+ ea[0], ea[1], ea[2], ea[3], ea[4], ea[5]);
+}
+
+static int wlc_ioctl(wlc_param param, void *data, void *value)
+{
+ unsigned int *var = ((unsigned int *) data);
+ unsigned int ioc = *var;
+
+ if (param & NOARG) {
+ return wl_ioctl(interface, ioc, NULL, 0);
+ }
+ switch(param & PARAM_TYPE) {
+ case MAC:
+ return wl_ioctl(interface, ((param & SET) ? (ioc) : (ioc >> 16)) & 0xffff, value, 6);
+ case INT:
+ return wl_ioctl(interface, ((param & SET) ? (ioc) : (ioc >> 16)) & 0xffff, value, sizeof(int));
+ case STRING:
+ return wl_ioctl(interface, ((param & SET) ? (ioc) : (ioc >> 16)) & 0xffff, value, BUFSIZE);
+ }
+ return 0;
+}
+
+static int wlc_iovar(wlc_param param, void *data, void *value)
+{
+ int *val = (int *) value;
+ char *iov = *((char **) data);
+ int ret = 0;
+
+ if (param & SET) {
+ switch(param & PARAM_TYPE) {
+ case INT:
+ ret = wl_iovar_setint(interface, iov, *val);
+ break;
+ case MAC:
+ ret = wl_iovar_set(interface, iov, value, 6);
+ break;
+ }
+ }
+ if (param & GET) {
+ switch(param & PARAM_TYPE) {
+ case INT:
+ ret = wl_iovar_get(interface, iov, val, sizeof(int));
+ break;
+ case MAC:
+ ret = wl_iovar_get(interface, iov, value, 6);
+ break;
+ }
+ }
+
+ return ret;
+}
+
+static int wlc_bssiovar(wlc_param param, void *data, void *value)
+{
+ int *val = (int *) value;
+ char *iov = *((char **) data);
+ int ret = 0;
+
+ if (param & SET) {
+ switch(param & PARAM_TYPE) {
+ case INT:
+ ret = wl_bssiovar_setint(interface, iov, vif, *val);
+ }
+ }
+ if (param & GET) {
+ switch(param & PARAM_TYPE) {
+ case INT:
+ ret = wl_bssiovar_get(interface, iov, vif, val, sizeof(int));
+ }
+ }
+
+ return ret;
+}
+
+static int wlc_vif_enabled(wlc_param param, void *data, void *value)
+{
+ int *val = (int *) value;
+ int buf[3];
+ int ret = 0;
+
+ sprintf((char *) buf, "bss");
+ buf[1] = vif;
+ if (param & SET) {
+ buf[2] = (*val ? 1 : 0);
+ ret = wl_ioctl(interface, WLC_SET_VAR, buf, sizeof(buf));
+ } else if (param & GET) {
+ ret = wl_ioctl(interface, WLC_GET_VAR, buf, sizeof(buf));
+ *val = buf[0];
+ }
+
+ return ret;
+}
+
+static int wlc_ssid(wlc_param param, void *data, void *value)
+{
+ int ret = -1, ret2 = -1;
+ char *dest = (char *) value;
+ wlc_ssid_t ssid;
+
+ if ((param & PARAM_MODE) == GET) {
+ ret = wl_bssiovar_get(interface, "ssid", vif, &ssid, sizeof(ssid));
+
+ if (ret)
+ /* if we can't get the ssid through the bssiovar, try WLC_GET_SSID */
+ ret = wl_ioctl(interface, WLC_GET_SSID, &ssid, sizeof(ssid));
+
+ if (!ret) {
+ memcpy(dest, ssid.SSID, ssid.SSID_len);
+ dest[ssid.SSID_len] = 0;
+ }
+ } else if ((param & PARAM_MODE) == SET) {
+ strncpy(ssid.SSID, value, 32);
+ ssid.SSID_len = strlen(value);
+
+ if (ssid.SSID_len > 32)
+ ssid.SSID_len = 32;
+
+ if (vif == 0) {
+ /* for the main interface, also try the WLC_SET_SSID call */
+ ret2 = wl_ioctl(interface, WLC_SET_SSID, &ssid, sizeof(ssid));
+ }
+
+ ret = wl_bssiovar_set(interface, "ssid", vif, &ssid, sizeof(ssid));
+ ret = (!ret2 ? 0 : ret);
+ }
+
+ return ret;
+}
+
+static int wlc_int(wlc_param param, void *data, void *value)
+{
+ int *var = *((int **) data);
+ int *val = (int *) value;
+
+ if ((param & PARAM_MODE) == SET) {
+ *var = *val;
+ } else if ((param & PARAM_MODE) == GET) {
+ *val = *var;
+ }
+
+ return 0;
+}
+
+static int wlc_flag(wlc_param param, void *data, void *value)
+{
+ int *var = *((int **) data);
+
+ *var = 1;
+
+ return 0;
+}
+
+static int wlc_string(wlc_param param, void *data, void *value)
+{
+ char *var = *((char **) data);
+
+ if ((param & PARAM_MODE) == GET) {
+ strcpy(value, var);
+ }
+
+ return 0;
+}
+
+static int wlc_afterburner(wlc_param param, void *data, void *value)
+{
+ int *val = (int *) value;
+ int ret = 0;
+
+ if ((param & PARAM_MODE) == GET) {
+ ret = wl_iovar_get(interface, "afterburner", val, sizeof(int));
+ } else {
+ wl_iovar_setint(interface, "wlfeatureflag", (*val ? 3 : 0));
+ ret = wl_iovar_setint(interface, "afterburner", (*val ? 1 : 0));
+ wl_iovar_setint(interface, "afterburner_override", *val);
+ }
+
+ return ret;
+}
+
+static int wlc_maclist(wlc_param param, void *data, void *value)
+{
+ unsigned int *var = ((unsigned int *) data);
+ unsigned int ioc = *var;
+ int limit = (sizeof(wlbuf) - 4) / sizeof(struct ether_addr);
+ struct maclist *list = (struct maclist *) wlbuf;
+ char *str = (char *) value;
+ char astr[30], *p;
+ struct ether_addr *addr;
+ int isset = 0;
+ int ret;
+
+ if ((param & PARAM_MODE) == GET) {
+ list->count = limit;
+ ret = wl_ioctl(interface, (ioc >> 16) & 0xffff, wlbuf, sizeof(wlbuf));
+
+ if (!ret)
+ while (list->count) {
+ str += sprintf(str, "%s", ((((char *) value) == str) ? "" : " "));
+ str += my_ether_ntoa((unsigned char *) &list->ea[list->count-- - 1], str);
+ }
+
+ return ret;
+ } else {
+ while (*str && isspace(*str))
+ *str++;
+
+ if (*str == '+') {
+ str++;
+
+ list->count = limit;
+ if (wl_ioctl(interface, (ioc >> 16) & 0xffff, wlbuf, sizeof(wlbuf)) == 0)
+ isset = 1;
+
+ while (*str && isspace(*str))
+ str++;
+ }
+
+ if (!isset)
+ memset(wlbuf, 0, sizeof(wlbuf));
+
+ foreach(astr, str, p) {
+ if (list->count >= limit)
+ break;
+
+ if ((addr = ether_aton(astr)) != NULL)
+ memcpy(&list->ea[list->count++], addr, sizeof(struct ether_addr));
+ }
+
+ return wl_ioctl(interface, ioc & 0xffff, wlbuf, sizeof(wlbuf));
+ }
+}
+
+static int wlc_radio(wlc_param param, void *data, void *value)
+{
+ int *val = (int *) value;
+ int ret;
+
+ if ((param & PARAM_MODE) == GET) {
+ ret = wl_ioctl(interface, WLC_GET_RADIO, val, sizeof(int));
+ *val = ((*val & 1) ? 0 : 1);
+ } else {
+ *val = (1 << 16) | (*val ? 0 : 1);
+ ret = wl_ioctl(interface, WLC_SET_RADIO, val, sizeof(int));
+ }
+
+ return ret;
+}
+
+static int wlc_wsec_key(wlc_param param, void *null, void *value)
+{
+ wl_wsec_key_t wsec_key;
+ unsigned char *index = value;
+ unsigned char *key;
+ unsigned char *data;
+ unsigned char hex[3];
+
+ if ((param & PARAM_MODE) != SET)
+ return 0;
+
+ memset(&wsec_key, 0, sizeof(wsec_key));
+ if (index[0] == '=') {
+ wsec_key.flags = WL_PRIMARY_KEY;
+ index++;
+ }
+
+ if ((index[0] < '1') || (index[0] > '4') || (index[1] != ','))
+ return -1;
+
+ key = index + 2;
+ if (strncmp(key, "d:", 2) == 0) { /* delete key */
+ } else if (strncmp(key, "s:", 2) == 0) { /* ascii key */
+ key += 2;
+ wsec_key.len = strlen(key);
+
+ if ((wsec_key.len != 5) && (wsec_key.len != 13))
+ return -1;
+
+ strcpy(wsec_key.data, key);
+ } else { /* hex key */
+ wsec_key.len = strlen(key);
+ if ((wsec_key.len != 10) && (wsec_key.len != 26))
+ return -1;
+
+ wsec_key.len /= 2;
+ data = wsec_key.data;
+ hex[2] = 0;
+ do {
+ hex[0] = *(key++);
+ hex[1] = *(key++);
+ *(data++) = (unsigned char) strtoul(hex, NULL, 16);
+ } while (*key != 0);
+ }
+
+ return wl_bssiovar_set(interface, "wsec_key", vif, &wsec_key, sizeof(wsec_key));
+}
+
+static inline int cw2ecw(int cw)
+{
+ int i;
+ for (cw++, i = 0; cw; i++) cw >>=1;
+ return i - 1;
+}
+
+static int wlc_wme_ac(wlc_param param, void *data, void *value)
+{
+ char *type = *((char **) data);
+ char *settings = (char *) value;
+ char cmd[100], *p, *val;
+ edcf_acparam_t params[AC_COUNT];
+ int ret;
+ int intval;
+ int cur = -1;
+ char *buf = wlbuf;
+
+ if ((param & PARAM_MODE) != SET)
+ return -1;
+
+ memset(params, 0, sizeof(params));
+ ret = wl_iovar_get(interface, type, params, sizeof(params));
+ memset(buf, 0, BUFSIZE);
+ strcpy(buf, type);
+ buf += strlen(buf) + 1;
+
+ foreach(cmd, settings, p) {
+ val = strchr(cmd, '=');
+ if (val == NULL) {
+ if (strcmp(cmd, "be") == 0)
+ cur = AC_BE;
+ else if (strcmp(cmd, "bk") == 0)
+ cur = AC_BK;
+ else if (strcmp(cmd, "vi") == 0)
+ cur = AC_VI;
+ else if (strcmp(cmd, "vo") == 0)
+ cur = AC_VO;
+ else
+ return -1;
+
+ /* just in case */
+ params[cur].ACI = (params[cur].ACI & (0x3 << 5)) | (cur << 5);
+ } else {
+ *(val++) = 0;
+
+ intval = strtoul(val, NULL, 10);
+ if (strcmp(cmd, "cwmin") == 0)
+ params[cur].ECW = (params[cur].ECW & ~(0xf)) | cw2ecw(intval);
+ else if (strcmp(cmd, "ecwmin") == 0)
+ params[cur].ECW = (params[cur].ECW & ~(0xf)) | (intval & 0xf);
+ else if (strcmp(cmd, "cwmax") == 0)
+ params[cur].ECW = (params[cur].ECW & ~(0xf << 4)) | (cw2ecw(intval) << 4);
+ else if (strcmp(cmd, "ecwmax") == 0)
+ params[cur].ECW = (params[cur].ECW & ~(0xf << 4)) | ((intval & 0xf) << 4);
+ else if (strcmp(cmd, "aifsn") == 0)
+ params[cur].ACI = (params[cur].ACI & ~(0xf)) | (intval & 0xf);
+ else if (strcmp(cmd, "txop") == 0)
+ params[cur].TXOP = intval >> 5;
+ else if (strcmp(cmd, "force") == 0)
+ params[cur].ACI = (params[cur].ACI & ~(1 << 4)) | ((intval) ? (1 << 4) : 0);
+ else return -1;
+
+ memcpy(buf, &params[cur], sizeof(edcf_acparam_t));
+ wl_ioctl(interface, WLC_SET_VAR, wlbuf, BUFSIZE);
+ }
+ }
+ return ret;
+}
+
+static int wlc_ifname(wlc_param param, void *data, void *value)
+{
+ char *val = (char *) value;
+ int ret = 0;
+
+ if (param & SET) {
+ if (strlen(val) < 16)
+ strcpy(interface, val);
+ else ret = -1;
+ }
+ if (param & GET) {
+ strcpy(val, interface);
+ }
+
+ return ret;
+}
+
+static int wlc_wdsmac(wlc_param param, void *data, void *value)
+{
+ unsigned char mac[6];
+ int ret = 0;
+
+ ret = wl_ioctl(interface, WLC_WDS_GET_REMOTE_HWADDR, &mac, 6);
+ if (ret == 0)
+ my_ether_ntoa(mac, value);
+
+ return ret;
+}
+
+static int wlc_pmk(wlc_param param, void *data, void *value)
+{
+ int ret = -1;
+ char *str = (char *) value;
+ wsec_pmk_t pmk;
+
+ /* driver doesn't support GET */
+
+ if ((param & PARAM_MODE) == SET) {
+ strncpy(pmk.key, value, WSEC_MAX_PSK_LEN);
+ pmk.key_len = strlen(value);
+
+ if (pmk.key_len > WSEC_MAX_PSK_LEN)
+ pmk.key_len = WSEC_MAX_PSK_LEN;
+
+ pmk.flags = WSEC_PASSPHRASE;
+
+ ret = wl_ioctl(interface, WLC_SET_WSEC_PMK, &pmk, sizeof(pmk));
+ }
+
+ return ret;
+}
+
+static const struct wlc_call wlc_calls[] = {
+ {
+ .name = "version",
+ .param = STRING|NOARG,
+ .handler = wlc_string,
+ .data.str = VERSION,
+ .desc = "Version of this program"
+ },
+ {
+ .name = "debug",
+ .param = INT,
+ .handler = wlc_int,
+ .data.ptr = &debug,
+ .desc = "wlc debug level"
+ },
+ {
+ .name = "stdin",
+ .param = NOARG,
+ .handler = wlc_flag,
+ .data.ptr = &fromstdin,
+ .desc = "Accept input from stdin"
+ },
+ {
+ .name = "ifname",
+ .param = STRING,
+ .handler = wlc_ifname,
+ .desc = "interface to send commands to"
+ },
+ {
+ .name = "up",
+ .param = NOARG,
+ .handler = wlc_ioctl,
+ .data.num = WLC_UP,
+ .desc = "Bring the interface up"
+ },
+ {
+ .name = "down",
+ .param = NOARG,
+ .handler = wlc_ioctl,
+ .data.num = WLC_DOWN,
+ .desc = "Bring the interface down"
+ },
+ {
+ .name = "radio",
+ .param = INT,
+ .handler = wlc_radio,
+ .desc = "Radio enabled flag"
+ },
+ {
+ .name = "ap",
+ .param = INT,
+ .handler = wlc_ioctl,
+ .data.num = ((WLC_GET_AP << 16) | WLC_SET_AP),
+ .desc = "Access Point mode"
+ },
+ {
+ .name = "mssid",
+ .param = INT,
+ .handler = wlc_iovar,
+ .data.str = "mbss",
+ .desc = "Multi-ssid mode"
+ },
+ {
+ .name = "apsta",
+ .param = INT,
+ .handler = wlc_iovar,
+ .data.str = "apsta",
+ .desc = "AP+STA mode"
+ },
+ {
+ .name = "infra",
+ .param = INT,
+ .handler = wlc_ioctl,
+ .data.num = ((WLC_GET_INFRA << 16) | WLC_SET_INFRA),
+ .desc = "Infrastructure mode"
+ },
+ {
+ .name = "wet",
+ .param = INT,
+ .handler = wlc_ioctl,
+ .data.num = ((WLC_GET_WET << 16) | WLC_SET_WET),
+ .desc = "Wireless repeater mode",
+ },
+ {
+ .name = "statimeout",
+ .param = INT,
+ .handler = wlc_iovar,
+ .data.str = "sta_retry_time",
+ .desc = "STA connection timeout"
+ },
+ {
+ .name = "country",
+ .param = STRING,
+ .handler = wlc_ioctl,
+ .data.num = ((WLC_GET_COUNTRY << 16) | WLC_SET_COUNTRY),
+ .desc = "Country code"
+ },
+ {
+ .name = "channel",
+ .param = INT,
+ .handler = wlc_ioctl,
+ .data.num = ((WLC_GET_CHANNEL << 16) | WLC_SET_CHANNEL),
+ .desc = "Channel",
+ },
+ {
+ .name = "vlan_mode",
+ .param = INT,
+ .handler = wlc_bssiovar,
+ .data.str = "vlan_mode",
+ .desc = "Parse 802.1Q tags",
+ },
+ {
+ .name = "vif",
+ .param = INT,
+ .handler = wlc_int,
+ .data.ptr = &vif,
+ .desc = "Current vif index"
+ },
+ {
+ .name = "enabled",
+ .param = INT,
+ .handler = wlc_vif_enabled,
+ .desc = "vif enabled flag"
+ },
+ {
+ .name = "ssid",
+ .param = STRING,
+ .handler = wlc_ssid,
+ .desc = "Interface ESSID"
+ },
+ {
+ .name = "closed",
+ .param = INT,
+ .handler = wlc_bssiovar,
+ .data.str = "closednet",
+ .desc = "Hidden ESSID flag"
+ },
+ {
+ .name = "wsec",
+ .param = INT,
+ .handler = wlc_bssiovar,
+ .data.str = "wsec",
+ .desc = "Security mode flags"
+ },
+ {
+ .name = "wepkey",
+ .param = STRING,
+ .handler = wlc_wsec_key,
+ .desc = "Set/Remove WEP keys"
+ },
+ {
+ .name = "wepauth",
+ .param = INT,
+ .handler = wlc_ioctl,
+ .data.num = ((WLC_GET_AUTH << 16) | WLC_SET_AUTH),
+ .desc = "WEP authentication type. 0 = OpenSystem, 1 = SharedKey"
+ },
+ {
+ .name = "wsec_restrict",
+ .param = INT,
+ .handler = wlc_bssiovar,
+ .data.str = "wsec_restrict",
+ .desc = "Drop unencrypted traffic"
+ },
+ {
+ .name = "eap_restrict",
+ .param = INT,
+ .handler = wlc_bssiovar,
+ .data.str = "eap_restrict",
+ .desc = "Only allow 802.1X traffic until 802.1X authorized"
+ },
+ {
+ .name = "wpa_auth",
+ .param = INT,
+ .handler = wlc_bssiovar,
+ .data.str = "wpa_auth",
+ .desc = "WPA authentication modes"
+ },
+ {
+ .name = "ap_isolate",
+ .param = INT,
+ .handler = wlc_bssiovar,
+ .data.str = "ap_isolate",
+ .desc = "Isolate connected clients"
+ },
+ {
+ .name = "supplicant",
+ .param = INT,
+ .handler = wlc_iovar,
+ .data.str = "sup_wpa",
+ .desc = "Built-in WPA supplicant"
+ },
+ {
+ .name = "passphrase",
+ .param = STRING,
+ .handler = wlc_pmk,
+ .desc = "Passphrase for built-in WPA supplicant",
+ },
+ {
+ .name = "maxassoc",
+ .param = INT,
+ .handler = wlc_iovar,
+ .data.str = "maxassoc",
+ .desc = "Max. number of associated clients",
+ },
+ {
+ .name = "wme",
+ .param = INT,
+ .handler = wlc_iovar,
+ .data.str = "wme",
+ .desc = "WME enabled"
+ },
+ {
+ .name = "wme_ac_ap",
+ .param = STRING,
+ .handler = wlc_wme_ac,
+ .data.str = "wme_ac_ap",
+ .desc = "Set WME AC options for AP mode",
+ },
+ {
+ .name = "wme_ac_sta",
+ .param = STRING,
+ .handler = wlc_wme_ac,
+ .data.str = "wme_ac_sta",
+ .desc = "Set WME AC options for STA mode",
+ },
+ {
+ .name = "wme_noack",
+ .param = INT,
+ .handler = wlc_iovar,
+ .data.str = "wme_noack",
+ .desc = "WME ACK disable request",
+ },
+ {
+ .name = "802.11d",
+ .param = INT,
+ .handler = wlc_ioctl,
+ .data.num = ((WLC_GET_REGULATORY << 16) | WLC_SET_REGULATORY),
+ .desc = "Enable/disable 802.11d regulatory management",
+ },
+ {
+ .name = "802.11h",
+ .param = INT,
+ .handler = wlc_ioctl,
+ .data.num = ((WLC_GET_SPECT_MANAGMENT << 16) | WLC_SET_SPECT_MANAGMENT),
+ .desc = "Enable/disable 802.11h spectrum management",
+ },
+ {
+ .name = "fragthresh",
+ .param = INT,
+ .handler = wlc_iovar,
+ .data.str = "fragthresh",
+ .desc = "Fragmentation threshold",
+ },
+ {
+ .name = "rtsthresh",
+ .param = INT,
+ .handler = wlc_iovar,
+ .data.str = "rtsthresh",
+ .desc = "RTS threshold"
+ },
+ {
+ .name = "slottime",
+ .param = INT,
+ .handler = wlc_iovar,
+ .data.str = "acktiming",
+ .desc = "Slot time"
+ },
+ {
+ .name = "rxant",
+ .param = INT,
+ .handler = wlc_ioctl,
+ .data.num = ((WLC_GET_ANTDIV << 16) | WLC_SET_ANTDIV),
+ .desc = "Rx antenna selection"
+ },
+ {
+ .name = "txant",
+ .param = INT,
+ .handler = wlc_ioctl,
+ .data.num = ((WLC_GET_TXANT << 16) | WLC_SET_TXANT),
+ .desc = "Tx antenna selection"
+ },
+ {
+ .name = "dtim",
+ .param = INT,
+ .handler = wlc_ioctl,
+ .data.num = ((WLC_GET_DTIMPRD << 16) | WLC_SET_DTIMPRD),
+ .desc = "DTIM period",
+ },
+ {
+ .name = "bcn",
+ .param = INT,
+ .handler = wlc_ioctl,
+ .data.num = ((WLC_GET_BCNPRD << 16) | WLC_SET_BCNPRD),
+ .desc = "Beacon interval"
+ },
+ {
+ .name = "frameburst",
+ .param = INT,
+ .handler = wlc_ioctl,
+ .data.num = ((WLC_GET_FAKEFRAG << 16) | WLC_SET_FAKEFRAG),
+ .desc = "Framebursting"
+ },
+ {
+ .name = "monitor",
+ .param = INT,
+ .handler = wlc_ioctl,
+ .data.num = ((WLC_GET_MONITOR << 16) | WLC_SET_MONITOR),
+ .desc = "Monitor mode"
+ },
+ {
+ .name = "passive_scan",
+ .param = INT,
+ .handler = wlc_ioctl,
+ .data.num = ((WLC_GET_PASSIVE_SCAN << 16) | WLC_SET_PASSIVE_SCAN),
+ .desc = "Passive scan mode"
+ },
+ {
+ .name = "macfilter",
+ .param = INT,
+ .handler = wlc_ioctl,
+ .data.num = ((WLC_GET_MACMODE << 16) | WLC_SET_MACMODE),
+ .desc = "MAC filter mode (0:disabled, 1:deny, 2:allow)"
+ },
+ {
+ .name = "maclist",
+ .param = STRING,
+ .data.num = ((WLC_GET_MACLIST << 16) | WLC_SET_MACLIST),
+ .handler = wlc_maclist,
+ .desc = "MAC filter list"
+ },
+ {
+ .name = "autowds",
+ .param = INT,
+ .handler = wlc_ioctl,
+ .data.num = ((WLC_GET_LAZYWDS << 16) | WLC_SET_LAZYWDS),
+ .desc = "Automatic WDS"
+ },
+ {
+ .name = "wds",
+ .param = STRING,
+ .data.num = ((WLC_GET_WDSLIST << 16) | WLC_SET_WDSLIST),
+ .handler = wlc_maclist,
+ .desc = "WDS connection list"
+ },
+ {
+ .name = "wdstimeout",
+ .param = INT,
+ .handler = wlc_iovar,
+ .data.str = "wdstimeout",
+ .desc = "WDS link detection timeout"
+ },
+ {
+ .name = "wdsmac",
+ .param = STRING|NOARG,
+ .handler = wlc_wdsmac,
+ .desc = "MAC of the remote WDS endpoint (only with wds0.* interfaces)"
+ },
+ {
+ .name = "afterburner",
+ .param = INT,
+ .handler = wlc_afterburner,
+ .desc = "Broadcom Afterburner"
+ },
+ {
+ .name = "ibss_merge",
+ .param = INT,
+ .handler = wlc_iovar,
+ .data.str = "ibss_coalesce_allowed",
+ .desc = "Allow IBSS merges"
+ },
+ {
+ .name = "bssid",
+ .param = MAC,
+ .handler = wlc_ioctl,
+ .data.num = ((WLC_GET_BSSID << 16) | WLC_SET_BSSID),
+ .desc = "BSSID"
+ },
+ {
+ .name = "default_bssid",
+ .param = MAC,
+ .handler = wlc_iovar,
+ .data.str = "perm_etheraddr",
+ .desc = "Default BSSID (read-only)"
+ },
+ {
+ .name = "assoclist",
+ .param = STRING,
+ .data.num = (WLC_GET_ASSOCLIST << 16),
+ .handler = wlc_maclist,
+ .desc = "MACs of associated stations"
+ },
+ {
+ .name = "gmode",
+ .param = INT,
+ .data.num = ((WLC_GET_GMODE << 16) | WLC_SET_GMODE),
+ .handler = wlc_ioctl,
+ .desc = "G Mode"
+ },
+};
+#define wlc_calls_size (sizeof(wlc_calls) / sizeof(struct wlc_call))
+
+static void usage(char *cmd)
+{
+ int i;
+ fprintf(stderr, "Usage: %s <command> [<argument> ...]\n"
+ "\n"
+ "Available commands:\n", cmd);
+ for (i = 0; i < wlc_calls_size; i++) {
+ fprintf(stderr, "\t%-16s\t%s\n", wlc_calls[i].name ?: "", wlc_calls[i].desc ?: "");
+ }
+ fprintf(stderr, "\n");
+ exit(1);
+}
+
+static int do_command(const struct wlc_call *cmd, char *arg)
+{
+ static char buf[BUFSIZE];
+ int set;
+ int ret = 0;
+ char *format, *end;
+ int intval;
+ void *ptr = (void *) buf;
+
+ if (debug >= 10) {
+ fprintf(stderr, "do_command %-16s\t'%s'\n", cmd->name, arg);
+ }
+
+ if ((arg == NULL) && ((cmd->param & PARAM_TYPE) != NONE)) {
+ set = 0;
+ ret = cmd->handler(cmd->param | GET, (void *) &cmd->data, (void *) buf);
+ if (ret == 0) {
+ switch(cmd->param & PARAM_TYPE) {
+ case INT:
+ intval = *((int *) buf);
+
+ if (intval > 65535)
+ format = "0x%08x\n";
+ else if (intval > 255)
+ format = "0x%04x\n";
+ else
+ format = "%d\n";
+
+ fprintf(stdout, format, intval);
+ break;
+ case STRING:
+ fprintf(stdout, "%s\n", buf);
+ break;
+ case MAC:
+ my_ether_ntoa(buf, buf + 6);
+ fprintf(stdout, "%s\n", buf + 6);
+ break;
+ }
+ }
+ } else { /* SET */
+ set = 1;
+ switch(cmd->param & PARAM_TYPE) {
+ case INT:
+ intval = strtoul(arg, &end, 10);
+ if (end && !(*end)) {
+ memcpy(buf, &intval, sizeof(intval));
+ } else {
+ fprintf(stderr, "%s: Invalid argument\n", cmd->name);
+ return -1;
+ }
+ break;
+ case STRING:
+ strncpy(buf, arg, BUFSIZE);
+ buf[BUFSIZE - 1] = 0;
+ break;
+ case MAC:
+ ptr = ether_aton(arg);
+ if (!ptr) {
+ fprintf(stderr, "%s: Invalid mac address '%s'\n", cmd->name, arg);
+ return -1;
+ }
+ break;
+ }
+
+ ret = cmd->handler(cmd->param | SET, (void *) &cmd->data, ptr);
+ }
+
+ if ((debug > 0) && (ret != 0))
+ fprintf(stderr, "Command '%s %s' failed: %d\n", (set == 1 ? "set" : "get"), cmd->name, ret);
+
+ return ret;
+}
+
+static struct wlc_call *find_cmd(char *name)
+{
+ int found = 0, i = 0;
+
+ while (!found && (i < wlc_calls_size)) {
+ if (strcmp(name, wlc_calls[i].name) == 0)
+ found = 1;
+ else
+ i++;
+ }
+
+ return (struct wlc_call *) (found ? &wlc_calls[i] : NULL);
+}
+
+int main(int argc, char **argv)
+{
+ static char buf[BUFSIZE];
+ char *s, *s2;
+ char *cmd = argv[0];
+ struct wlc_call *call;
+ int ret = 0;
+
+ if (argc < 2)
+ usage(argv[0]);
+
+ for(interface[2] = '0'; (interface[2] < '3') && (wl_probe(interface) != 0); interface[2]++);
+ if (interface[2] == '3') {
+ fprintf(stderr, "No Broadcom wl interface found!\n");
+ return -1;
+ }
+
+ argv++;
+ argc--;
+ while ((argc > 0) && (argv[0] != NULL)) {
+ if ((call = find_cmd(argv[0])) == NULL) {
+ fprintf(stderr, "Invalid command: %s\n\n", argv[0]);
+ usage(cmd);
+ }
+ if ((argc > 1) && (!(call->param & NOARG))) {
+ ret = do_command(call, argv[1]);
+ argv += 2;
+ argc -= 2;
+ } else {
+ ret = do_command(call, NULL);
+ argv++;
+ argc--;
+ }
+ }
+
+ while (fromstdin && !feof(stdin)) {
+ *buf = 0;
+ fgets(buf, BUFSIZE - 1, stdin);
+
+ if (*buf == 0)
+ continue;
+
+ if ((s = strchr(buf, '\r')) != NULL)
+ *s = 0;
+ if ((s = strchr(buf, '\n')) != NULL)
+ *s = 0;
+
+ s = buf;
+ while (isspace(*s))
+ s++;
+
+ if (!*s)
+ continue;
+
+ if ((s2 = strchr(buf, ' ')) != NULL)
+ *(s2++) = 0;
+
+ while (s2 && isspace(*s2))
+ s2++;
+
+ if ((call = find_cmd(buf)) == NULL) {
+ fprintf(stderr, "Invalid command: %s\n", buf);
+ ret = -1;
+ } else
+ ret = do_command(call, ((call->param & NOARG) ? NULL : s2));
+ }
+
+ return ret;
+}
diff --git a/package/broadcom-wl/src/glue/.svn/entries b/package/broadcom-wl/src/glue/.svn/entries
new file mode 100644
index 0000000..c1270d1
--- /dev/null
+++ b/package/broadcom-wl/src/glue/.svn/entries
@@ -0,0 +1,130 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/broadcom-wl/src/glue
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-12-13T18:55:49.509483Z
+34671
+hauke
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+wl_glue.c
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+0fdc903f03f49be6a4ed01fd254ac729
+2012-12-13T18:55:49.509483Z
+34671
+hauke
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+6145
+
+wl_glue.h
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+ab40e0de5286fbcad02c28caccd3f9c3
+2011-07-24T14:10:39.842012Z
+27751
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+639
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+4934258a46c0a44ee7acc1c63291b116
+2011-07-24T14:10:39.842012Z
+27751
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+426
+
diff --git a/package/broadcom-wl/src/glue/.svn/text-base/Makefile.svn-base b/package/broadcom-wl/src/glue/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..81f0c8a
--- /dev/null
+++ b/package/broadcom-wl/src/glue/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,17 @@
+#
+# Makefile for wl_glue driver
+#
+# Copyright (C) 2011 Jo-Philipp Wich <jow@openwrt.org>
+#
+# 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 of the License, or (at your option) any later version.
+#
+
+obj-m := wl_glue.o
+
+ifeq ($(MAKING_MODULES),1)
+-include $(TOPDIR)/Rules.make
+endif
+
diff --git a/package/broadcom-wl/src/glue/.svn/text-base/wl_glue.c.svn-base b/package/broadcom-wl/src/glue/.svn/text-base/wl_glue.c.svn-base
new file mode 100644
index 0000000..fc94ac0
--- /dev/null
+++ b/package/broadcom-wl/src/glue/.svn/text-base/wl_glue.c.svn-base
@@ -0,0 +1,315 @@
+/*
+ * wl_glue.c: Broadcom WL support module providing a unified SSB/BCMA handling.
+ * Copyright (C) 2011 Jo-Philipp Wich <jow@openwrt.org>
+ */
+
+#include "wl_glue.h"
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+
+#ifdef CONFIG_BCM47XX
+#include <bcm47xx.h>
+#endif
+
+#ifdef CONFIG_SSB
+#include <linux/ssb/ssb.h>
+#endif
+
+#ifdef CONFIG_BCMA
+#include <linux/bcma/bcma.h>
+#endif
+
+MODULE_AUTHOR("Jo-Philipp Wich (jow@openwrt.org)");
+MODULE_DESCRIPTION("Broadcom WL SSB/BCMA compatibility layer");
+MODULE_LICENSE("GPL");
+
+static wl_glue_attach_cb_t attach_cb = NULL;
+static wl_glue_remove_cb_t remove_cb = NULL;
+static enum wl_glue_bus_type active_bus_type = WL_GLUE_BUS_TYPE_UNSPEC;
+static int wl_glue_attached = 0;
+
+
+#ifdef CONFIG_SSB
+static int wl_glue_ssb_probe(struct ssb_device *dev, const struct ssb_device_id *id)
+{
+ void *mmio;
+ void *wldev;
+
+ if (!attach_cb)
+ {
+ pr_err("No attach callback registered\n");
+ return -ENOSYS;
+ }
+
+ if (dev->bus->bustype != SSB_BUSTYPE_SSB)
+ {
+ pr_err("Attaching to SSB behind PCI is not supported. Please remove the b43 ssb bridge\n");
+ return -EINVAL;
+ }
+
+ mmio = (void *) 0x18000000 + dev->core_index * 0x1000;
+ wldev = attach_cb(id->vendor, id->coreid, (ulong)mmio, dev, dev->irq);
+
+ if (!wldev)
+ {
+ pr_err("The attach callback failed, SSB probe aborted\n");
+ return -ENODEV;
+ }
+
+ ssb_set_drvdata(dev, wldev);
+ return 0;
+}
+
+static void wl_glue_ssb_remove(struct ssb_device *dev)
+{
+ void *wldev = ssb_get_drvdata(dev);
+
+ if (remove_cb)
+ remove_cb(wldev);
+
+ ssb_set_drvdata(dev, NULL);
+}
+
+static const struct ssb_device_id wl_glue_ssb_tbl[] = {
+ SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_80211, SSB_ANY_REV),
+ SSB_DEVTABLE_END
+};
+
+static struct ssb_driver wl_glue_ssb_driver = {
+ .name = KBUILD_MODNAME,
+ .id_table = wl_glue_ssb_tbl,
+ .probe = wl_glue_ssb_probe,
+ .remove = wl_glue_ssb_remove,
+};
+#endif /* CONFIG_SSB */
+
+#ifdef CONFIG_BCMA
+static int wl_glue_bcma_probe(struct bcma_device *dev)
+{
+ void *wldev;
+
+ if (!attach_cb)
+ {
+ pr_err("No attach callback registered\n");
+ return -ENOSYS;
+ }
+
+ if (dev->bus->hosttype != BCMA_HOSTTYPE_SOC)
+ {
+ pr_err("Unsupported BCMA bus type %d\n", dev->bus->hosttype);
+ return -EINVAL;
+ }
+
+ /*
+ * NB:
+ * 0x18000000 = BCMA_ADDR_BASE
+ * 0x1000 = BCMA_CORE_SIZE
+ */
+
+ wldev = attach_cb(dev->id.manuf, dev->id.id, (ulong)dev->addr, dev, dev->irq);
+
+ if (!wldev)
+ {
+ pr_err("The attach callback failed, BCMA probe aborted\n");
+ return -ENODEV;
+ }
+
+ bcma_set_drvdata(dev, wldev);
+ return 0;
+}
+
+static void wl_glue_bcma_remove(struct bcma_device *dev)
+{
+ void *wldev = bcma_get_drvdata(dev);
+
+ if (remove_cb)
+ remove_cb(wldev);
+
+ bcma_set_drvdata(dev, NULL);
+}
+
+static const struct bcma_device_id wl_glue_bcma_tbl[] = {
+ BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_80211, BCMA_ANY_REV, BCMA_ANY_CLASS),
+ BCMA_CORETABLE_END
+};
+
+static struct bcma_driver wl_glue_bcma_driver = {
+ .name = KBUILD_MODNAME,
+ .id_table = wl_glue_bcma_tbl,
+ .probe = wl_glue_bcma_probe,
+ .remove = wl_glue_bcma_remove,
+};
+#endif /* CONFIG_BCMA */
+
+
+void wl_glue_set_attach_callback(wl_glue_attach_cb_t cb)
+{
+ attach_cb = cb;
+}
+EXPORT_SYMBOL(wl_glue_set_attach_callback);
+
+void wl_glue_set_remove_callback(wl_glue_remove_cb_t cb)
+{
+ remove_cb = cb;
+}
+EXPORT_SYMBOL(wl_glue_set_remove_callback);
+
+int wl_glue_register(void)
+{
+ int err;
+
+ switch(active_bus_type)
+ {
+#ifdef CONFIG_SSB
+ case WL_GLUE_BUS_TYPE_SSB:
+ err = ssb_driver_register(&wl_glue_ssb_driver);
+ break;
+#endif /* CONFIG_SSB */
+
+#ifdef CONFIG_BCMA
+ case WL_GLUE_BUS_TYPE_BCMA:
+ err = bcma_driver_register(&wl_glue_bcma_driver);
+ break;
+#endif /* CONFIG_BCMA */
+
+ default:
+ pr_err("Not attaching through glue driver due to unsupported bus\n");
+ err = -ENOSYS;
+ break;
+ }
+
+ if (!err)
+ {
+ pr_info("SSB/BCMA glue driver successfully attached\n");
+ wl_glue_attached = 1;
+ }
+
+ return err;
+}
+EXPORT_SYMBOL(wl_glue_register);
+
+int wl_glue_unregister(void)
+{
+ int err;
+
+ if (!wl_glue_attached)
+ return -ENOSYS;
+
+ switch (active_bus_type)
+ {
+#ifdef CONFIG_SSB
+ case WL_GLUE_BUS_TYPE_SSB:
+ ssb_driver_unregister(&wl_glue_ssb_driver);
+ err = 0;
+ break;
+#endif /* CONFIG_SSB */
+
+#ifdef CONFIG_BCMA
+ case WL_GLUE_BUS_TYPE_BCMA:
+ bcma_driver_unregister(&wl_glue_bcma_driver);
+ err = 0;
+ break;
+#endif /* CONFIG_BCMA */
+
+ default:
+ pr_err("Not removing glue driver due to unsupported bus\n");
+ err = -ENOSYS;
+ break;
+ }
+
+ if (!err)
+ {
+ pr_info("SSB/BCMA glue driver successfully detached\n");
+ wl_glue_attached = 0;
+ }
+
+ return err;
+}
+EXPORT_SYMBOL(wl_glue_unregister);
+
+struct device * wl_glue_get_dmadev(void *dev)
+{
+ struct device *dma_dev;
+
+ switch (active_bus_type)
+ {
+#ifdef CONFIG_SSB
+ case WL_GLUE_BUS_TYPE_SSB:
+ dma_dev = ((struct ssb_device *)dev)->dma_dev;
+ break;
+#endif /* CONFIG_SSB */
+
+#ifdef CONFIG_BCMA
+ case WL_GLUE_BUS_TYPE_BCMA:
+ dma_dev = ((struct bcma_device *)dev)->dma_dev;
+ break;
+#endif /* CONFIG_BCMA */
+
+ default:
+ BUG();
+ dma_dev = NULL;
+ break;
+ }
+
+ return dma_dev;
+}
+EXPORT_SYMBOL(wl_glue_get_dmadev);
+
+
+static int __init wl_glue_init(void)
+{
+#ifdef CONFIG_BCM47XX
+ /*
+ * BCM47xx currently supports either SSB or BCMA bus,
+ * determine the used one from the info set by the
+ * platform setup code.
+ */
+ switch (bcm47xx_bus_type)
+ {
+#ifdef CONFIG_SSB
+ case BCM47XX_BUS_TYPE_SSB:
+ active_bus_type = WL_GLUE_BUS_TYPE_SSB;
+ break;
+#endif /* CONFIG_SSB */
+
+#ifdef CONFIG_BCMA
+ case BCM47XX_BUS_TYPE_BCMA:
+ active_bus_type = WL_GLUE_BUS_TYPE_BCMA;
+ break;
+#endif /* CONFIG_BCMA */
+ }
+#endif /* CONFIG_BCM47XX */
+
+#ifdef CONFIG_BCM63XX
+#ifdef CONFIG_SSB
+ /*
+ * BCM63xx currently only uses SSB, so assume that.
+ */
+ active_bus_type = WL_GLUE_BUS_TYPE_SSB;
+#endif /* CONFIG_SSB */
+#endif /* CONFIG_BCM63XX */
+
+ /* do not fail here, let wl_glue_register() return -ENOSYS later */
+ if (active_bus_type == WL_GLUE_BUS_TYPE_UNSPEC)
+ pr_err("Unable to determine used system bus type\n");
+
+ return 0;
+}
+
+static void __exit wl_glue_exit(void)
+{
+ if (wl_glue_attached)
+ {
+ if (wl_glue_unregister())
+ pr_err("Failed to unregister glue driver\n");
+
+ wl_glue_attached = 0;
+ }
+
+ return;
+}
+
+module_init(wl_glue_init);
+module_exit(wl_glue_exit);
diff --git a/package/broadcom-wl/src/glue/.svn/text-base/wl_glue.h.svn-base b/package/broadcom-wl/src/glue/.svn/text-base/wl_glue.h.svn-base
new file mode 100644
index 0000000..b3c8aa3
--- /dev/null
+++ b/package/broadcom-wl/src/glue/.svn/text-base/wl_glue.h.svn-base
@@ -0,0 +1,22 @@
+/*
+ * wl_glue.h: Broadcom WL support module providing a unified SSB/BCMA handling.
+ * Copyright (C) 2011 Jo-Philipp Wich <jow@openwrt.org>
+ */
+
+#include <linux/types.h>
+
+typedef void * (*wl_glue_attach_cb_t)(u16, u16, ulong, void *, u32);
+typedef void (*wl_glue_remove_cb_t)(void *);
+
+enum wl_glue_bus_type {
+ WL_GLUE_BUS_TYPE_UNSPEC,
+ WL_GLUE_BUS_TYPE_SSB,
+ WL_GLUE_BUS_TYPE_BCMA
+};
+
+extern void wl_glue_set_attach_callback(wl_glue_attach_cb_t cb);
+extern void wl_glue_set_remove_callback(wl_glue_remove_cb_t cb);
+extern int wl_glue_register(void);
+extern int wl_glue_unregister(void);
+extern struct device * wl_glue_get_dmadev(void *);
+
diff --git a/package/broadcom-wl/src/glue/Makefile b/package/broadcom-wl/src/glue/Makefile
new file mode 100644
index 0000000..81f0c8a
--- /dev/null
+++ b/package/broadcom-wl/src/glue/Makefile
@@ -0,0 +1,17 @@
+#
+# Makefile for wl_glue driver
+#
+# Copyright (C) 2011 Jo-Philipp Wich <jow@openwrt.org>
+#
+# 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 of the License, or (at your option) any later version.
+#
+
+obj-m := wl_glue.o
+
+ifeq ($(MAKING_MODULES),1)
+-include $(TOPDIR)/Rules.make
+endif
+
diff --git a/package/broadcom-wl/src/glue/wl_glue.c b/package/broadcom-wl/src/glue/wl_glue.c
new file mode 100644
index 0000000..fc94ac0
--- /dev/null
+++ b/package/broadcom-wl/src/glue/wl_glue.c
@@ -0,0 +1,315 @@
+/*
+ * wl_glue.c: Broadcom WL support module providing a unified SSB/BCMA handling.
+ * Copyright (C) 2011 Jo-Philipp Wich <jow@openwrt.org>
+ */
+
+#include "wl_glue.h"
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+
+#ifdef CONFIG_BCM47XX
+#include <bcm47xx.h>
+#endif
+
+#ifdef CONFIG_SSB
+#include <linux/ssb/ssb.h>
+#endif
+
+#ifdef CONFIG_BCMA
+#include <linux/bcma/bcma.h>
+#endif
+
+MODULE_AUTHOR("Jo-Philipp Wich (jow@openwrt.org)");
+MODULE_DESCRIPTION("Broadcom WL SSB/BCMA compatibility layer");
+MODULE_LICENSE("GPL");
+
+static wl_glue_attach_cb_t attach_cb = NULL;
+static wl_glue_remove_cb_t remove_cb = NULL;
+static enum wl_glue_bus_type active_bus_type = WL_GLUE_BUS_TYPE_UNSPEC;
+static int wl_glue_attached = 0;
+
+
+#ifdef CONFIG_SSB
+static int wl_glue_ssb_probe(struct ssb_device *dev, const struct ssb_device_id *id)
+{
+ void *mmio;
+ void *wldev;
+
+ if (!attach_cb)
+ {
+ pr_err("No attach callback registered\n");
+ return -ENOSYS;
+ }
+
+ if (dev->bus->bustype != SSB_BUSTYPE_SSB)
+ {
+ pr_err("Attaching to SSB behind PCI is not supported. Please remove the b43 ssb bridge\n");
+ return -EINVAL;
+ }
+
+ mmio = (void *) 0x18000000 + dev->core_index * 0x1000;
+ wldev = attach_cb(id->vendor, id->coreid, (ulong)mmio, dev, dev->irq);
+
+ if (!wldev)
+ {
+ pr_err("The attach callback failed, SSB probe aborted\n");
+ return -ENODEV;
+ }
+
+ ssb_set_drvdata(dev, wldev);
+ return 0;
+}
+
+static void wl_glue_ssb_remove(struct ssb_device *dev)
+{
+ void *wldev = ssb_get_drvdata(dev);
+
+ if (remove_cb)
+ remove_cb(wldev);
+
+ ssb_set_drvdata(dev, NULL);
+}
+
+static const struct ssb_device_id wl_glue_ssb_tbl[] = {
+ SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_80211, SSB_ANY_REV),
+ SSB_DEVTABLE_END
+};
+
+static struct ssb_driver wl_glue_ssb_driver = {
+ .name = KBUILD_MODNAME,
+ .id_table = wl_glue_ssb_tbl,
+ .probe = wl_glue_ssb_probe,
+ .remove = wl_glue_ssb_remove,
+};
+#endif /* CONFIG_SSB */
+
+#ifdef CONFIG_BCMA
+static int wl_glue_bcma_probe(struct bcma_device *dev)
+{
+ void *wldev;
+
+ if (!attach_cb)
+ {
+ pr_err("No attach callback registered\n");
+ return -ENOSYS;
+ }
+
+ if (dev->bus->hosttype != BCMA_HOSTTYPE_SOC)
+ {
+ pr_err("Unsupported BCMA bus type %d\n", dev->bus->hosttype);
+ return -EINVAL;
+ }
+
+ /*
+ * NB:
+ * 0x18000000 = BCMA_ADDR_BASE
+ * 0x1000 = BCMA_CORE_SIZE
+ */
+
+ wldev = attach_cb(dev->id.manuf, dev->id.id, (ulong)dev->addr, dev, dev->irq);
+
+ if (!wldev)
+ {
+ pr_err("The attach callback failed, BCMA probe aborted\n");
+ return -ENODEV;
+ }
+
+ bcma_set_drvdata(dev, wldev);
+ return 0;
+}
+
+static void wl_glue_bcma_remove(struct bcma_device *dev)
+{
+ void *wldev = bcma_get_drvdata(dev);
+
+ if (remove_cb)
+ remove_cb(wldev);
+
+ bcma_set_drvdata(dev, NULL);
+}
+
+static const struct bcma_device_id wl_glue_bcma_tbl[] = {
+ BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_80211, BCMA_ANY_REV, BCMA_ANY_CLASS),
+ BCMA_CORETABLE_END
+};
+
+static struct bcma_driver wl_glue_bcma_driver = {
+ .name = KBUILD_MODNAME,
+ .id_table = wl_glue_bcma_tbl,
+ .probe = wl_glue_bcma_probe,
+ .remove = wl_glue_bcma_remove,
+};
+#endif /* CONFIG_BCMA */
+
+
+void wl_glue_set_attach_callback(wl_glue_attach_cb_t cb)
+{
+ attach_cb = cb;
+}
+EXPORT_SYMBOL(wl_glue_set_attach_callback);
+
+void wl_glue_set_remove_callback(wl_glue_remove_cb_t cb)
+{
+ remove_cb = cb;
+}
+EXPORT_SYMBOL(wl_glue_set_remove_callback);
+
+int wl_glue_register(void)
+{
+ int err;
+
+ switch(active_bus_type)
+ {
+#ifdef CONFIG_SSB
+ case WL_GLUE_BUS_TYPE_SSB:
+ err = ssb_driver_register(&wl_glue_ssb_driver);
+ break;
+#endif /* CONFIG_SSB */
+
+#ifdef CONFIG_BCMA
+ case WL_GLUE_BUS_TYPE_BCMA:
+ err = bcma_driver_register(&wl_glue_bcma_driver);
+ break;
+#endif /* CONFIG_BCMA */
+
+ default:
+ pr_err("Not attaching through glue driver due to unsupported bus\n");
+ err = -ENOSYS;
+ break;
+ }
+
+ if (!err)
+ {
+ pr_info("SSB/BCMA glue driver successfully attached\n");
+ wl_glue_attached = 1;
+ }
+
+ return err;
+}
+EXPORT_SYMBOL(wl_glue_register);
+
+int wl_glue_unregister(void)
+{
+ int err;
+
+ if (!wl_glue_attached)
+ return -ENOSYS;
+
+ switch (active_bus_type)
+ {
+#ifdef CONFIG_SSB
+ case WL_GLUE_BUS_TYPE_SSB:
+ ssb_driver_unregister(&wl_glue_ssb_driver);
+ err = 0;
+ break;
+#endif /* CONFIG_SSB */
+
+#ifdef CONFIG_BCMA
+ case WL_GLUE_BUS_TYPE_BCMA:
+ bcma_driver_unregister(&wl_glue_bcma_driver);
+ err = 0;
+ break;
+#endif /* CONFIG_BCMA */
+
+ default:
+ pr_err("Not removing glue driver due to unsupported bus\n");
+ err = -ENOSYS;
+ break;
+ }
+
+ if (!err)
+ {
+ pr_info("SSB/BCMA glue driver successfully detached\n");
+ wl_glue_attached = 0;
+ }
+
+ return err;
+}
+EXPORT_SYMBOL(wl_glue_unregister);
+
+struct device * wl_glue_get_dmadev(void *dev)
+{
+ struct device *dma_dev;
+
+ switch (active_bus_type)
+ {
+#ifdef CONFIG_SSB
+ case WL_GLUE_BUS_TYPE_SSB:
+ dma_dev = ((struct ssb_device *)dev)->dma_dev;
+ break;
+#endif /* CONFIG_SSB */
+
+#ifdef CONFIG_BCMA
+ case WL_GLUE_BUS_TYPE_BCMA:
+ dma_dev = ((struct bcma_device *)dev)->dma_dev;
+ break;
+#endif /* CONFIG_BCMA */
+
+ default:
+ BUG();
+ dma_dev = NULL;
+ break;
+ }
+
+ return dma_dev;
+}
+EXPORT_SYMBOL(wl_glue_get_dmadev);
+
+
+static int __init wl_glue_init(void)
+{
+#ifdef CONFIG_BCM47XX
+ /*
+ * BCM47xx currently supports either SSB or BCMA bus,
+ * determine the used one from the info set by the
+ * platform setup code.
+ */
+ switch (bcm47xx_bus_type)
+ {
+#ifdef CONFIG_SSB
+ case BCM47XX_BUS_TYPE_SSB:
+ active_bus_type = WL_GLUE_BUS_TYPE_SSB;
+ break;
+#endif /* CONFIG_SSB */
+
+#ifdef CONFIG_BCMA
+ case BCM47XX_BUS_TYPE_BCMA:
+ active_bus_type = WL_GLUE_BUS_TYPE_BCMA;
+ break;
+#endif /* CONFIG_BCMA */
+ }
+#endif /* CONFIG_BCM47XX */
+
+#ifdef CONFIG_BCM63XX
+#ifdef CONFIG_SSB
+ /*
+ * BCM63xx currently only uses SSB, so assume that.
+ */
+ active_bus_type = WL_GLUE_BUS_TYPE_SSB;
+#endif /* CONFIG_SSB */
+#endif /* CONFIG_BCM63XX */
+
+ /* do not fail here, let wl_glue_register() return -ENOSYS later */
+ if (active_bus_type == WL_GLUE_BUS_TYPE_UNSPEC)
+ pr_err("Unable to determine used system bus type\n");
+
+ return 0;
+}
+
+static void __exit wl_glue_exit(void)
+{
+ if (wl_glue_attached)
+ {
+ if (wl_glue_unregister())
+ pr_err("Failed to unregister glue driver\n");
+
+ wl_glue_attached = 0;
+ }
+
+ return;
+}
+
+module_init(wl_glue_init);
+module_exit(wl_glue_exit);
diff --git a/package/broadcom-wl/src/glue/wl_glue.h b/package/broadcom-wl/src/glue/wl_glue.h
new file mode 100644
index 0000000..b3c8aa3
--- /dev/null
+++ b/package/broadcom-wl/src/glue/wl_glue.h
@@ -0,0 +1,22 @@
+/*
+ * wl_glue.h: Broadcom WL support module providing a unified SSB/BCMA handling.
+ * Copyright (C) 2011 Jo-Philipp Wich <jow@openwrt.org>
+ */
+
+#include <linux/types.h>
+
+typedef void * (*wl_glue_attach_cb_t)(u16, u16, ulong, void *, u32);
+typedef void (*wl_glue_remove_cb_t)(void *);
+
+enum wl_glue_bus_type {
+ WL_GLUE_BUS_TYPE_UNSPEC,
+ WL_GLUE_BUS_TYPE_SSB,
+ WL_GLUE_BUS_TYPE_BCMA
+};
+
+extern void wl_glue_set_attach_callback(wl_glue_attach_cb_t cb);
+extern void wl_glue_set_remove_callback(wl_glue_remove_cb_t cb);
+extern int wl_glue_register(void);
+extern int wl_glue_unregister(void);
+extern struct device * wl_glue_get_dmadev(void *);
+
diff --git a/package/broadcom-wl/src/wlc.c b/package/broadcom-wl/src/wlc.c
new file mode 100644
index 0000000..253809c
--- /dev/null
+++ b/package/broadcom-wl/src/wlc.c
@@ -0,0 +1,1086 @@
+/*
+ * wlc - Broadcom Wireless Driver Control Utility
+ *
+ * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
+ *
+ * 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
+ * of the License, 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.
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#include <glob.h>
+#include <ctype.h>
+
+#include <typedefs.h>
+#include <wlutils.h>
+#include <proto/802.11.h>
+
+#define VERSION "0.1"
+#define BUFSIZE 8192
+#define PTABLE_MAGIC 0xbadc0ded
+#define PTABLE_SLT1 1
+#define PTABLE_SLT2 2
+#define PTABLE_ACKW 3
+#define PTABLE_ADHM 4
+#define PTABLE_END 0xffffffff
+
+/*
+ * Copy each token in wordlist delimited by space into word
+ * Taken from Broadcom shutils.h
+ */
+#define foreach(word, wordlist, next) \
+ for (next = &wordlist[strspn(wordlist, " ")], \
+ strncpy(word, next, sizeof(word)), \
+ word[strcspn(word, " ")] = '\0', \
+ word[sizeof(word) - 1] = '\0', \
+ next = strchr(next, ' '); \
+ strlen(word); \
+ next = next ? &next[strspn(next, " ")] : "", \
+ strncpy(word, next, sizeof(word)), \
+ word[strcspn(word, " ")] = '\0', \
+ word[sizeof(word) - 1] = '\0', \
+ next = strchr(next, ' '))
+
+static char wlbuf[8192];
+static char interface[16] = "wl0";
+static unsigned long kmem_offset = 0;
+static int vif = 0, debug = 1, fromstdin = 0;
+
+typedef enum {
+ NONE = 0x00,
+
+ /* types */
+ PARAM_TYPE = 0x00f,
+ INT = 0x001,
+ STRING = 0x002,
+ MAC = 0x003,
+
+ /* options */
+ PARAM_OPTIONS = 0x0f0,
+ NOARG = 0x010,
+
+ /* modes */
+ PARAM_MODE = 0xf00,
+ GET = 0x100,
+ SET = 0x200,
+} wlc_param;
+
+struct wlc_call {
+ const char *name;
+ wlc_param param;
+ int (*handler)(wlc_param param, void *data, void *value);
+ union {
+ int num;
+ char *str;
+ void *ptr;
+ } data;
+ const char *desc;
+};
+
+/* can't use the system include because of the stupid broadcom header files */
+extern struct ether_addr *ether_aton(const char *asc);
+static inline int my_ether_ntoa(unsigned char *ea, char *buf)
+{
+ return sprintf(buf, "%02x:%02x:%02x:%02x:%02x:%02x",
+ ea[0], ea[1], ea[2], ea[3], ea[4], ea[5]);
+}
+
+static int wlc_ioctl(wlc_param param, void *data, void *value)
+{
+ unsigned int *var = ((unsigned int *) data);
+ unsigned int ioc = *var;
+
+ if (param & NOARG) {
+ return wl_ioctl(interface, ioc, NULL, 0);
+ }
+ switch(param & PARAM_TYPE) {
+ case MAC:
+ return wl_ioctl(interface, ((param & SET) ? (ioc) : (ioc >> 16)) & 0xffff, value, 6);
+ case INT:
+ return wl_ioctl(interface, ((param & SET) ? (ioc) : (ioc >> 16)) & 0xffff, value, sizeof(int));
+ case STRING:
+ return wl_ioctl(interface, ((param & SET) ? (ioc) : (ioc >> 16)) & 0xffff, value, BUFSIZE);
+ }
+ return 0;
+}
+
+static int wlc_iovar(wlc_param param, void *data, void *value)
+{
+ int *val = (int *) value;
+ char *iov = *((char **) data);
+ int ret = 0;
+
+ if (param & SET) {
+ switch(param & PARAM_TYPE) {
+ case INT:
+ ret = wl_iovar_setint(interface, iov, *val);
+ break;
+ case MAC:
+ ret = wl_iovar_set(interface, iov, value, 6);
+ break;
+ }
+ }
+ if (param & GET) {
+ switch(param & PARAM_TYPE) {
+ case INT:
+ ret = wl_iovar_get(interface, iov, val, sizeof(int));
+ break;
+ case MAC:
+ ret = wl_iovar_get(interface, iov, value, 6);
+ break;
+ }
+ }
+
+ return ret;
+}
+
+static int wlc_bssiovar(wlc_param param, void *data, void *value)
+{
+ int *val = (int *) value;
+ char *iov = *((char **) data);
+ int ret = 0;
+
+ if (param & SET) {
+ switch(param & PARAM_TYPE) {
+ case INT:
+ ret = wl_bssiovar_setint(interface, iov, vif, *val);
+ }
+ }
+ if (param & GET) {
+ switch(param & PARAM_TYPE) {
+ case INT:
+ ret = wl_bssiovar_get(interface, iov, vif, val, sizeof(int));
+ }
+ }
+
+ return ret;
+}
+
+static int wlc_vif_enabled(wlc_param param, void *data, void *value)
+{
+ int *val = (int *) value;
+ int buf[3];
+ int ret = 0;
+
+ sprintf((char *) buf, "bss");
+ buf[1] = vif;
+ if (param & SET) {
+ buf[2] = (*val ? 1 : 0);
+ ret = wl_ioctl(interface, WLC_SET_VAR, buf, sizeof(buf));
+ } else if (param & GET) {
+ ret = wl_ioctl(interface, WLC_GET_VAR, buf, sizeof(buf));
+ *val = buf[0];
+ }
+
+ return ret;
+}
+
+static int wlc_ssid(wlc_param param, void *data, void *value)
+{
+ int ret = -1, ret2 = -1;
+ char *dest = (char *) value;
+ wlc_ssid_t ssid;
+
+ if ((param & PARAM_MODE) == GET) {
+ ret = wl_bssiovar_get(interface, "ssid", vif, &ssid, sizeof(ssid));
+
+ if (ret)
+ /* if we can't get the ssid through the bssiovar, try WLC_GET_SSID */
+ ret = wl_ioctl(interface, WLC_GET_SSID, &ssid, sizeof(ssid));
+
+ if (!ret) {
+ memcpy(dest, ssid.SSID, ssid.SSID_len);
+ dest[ssid.SSID_len] = 0;
+ }
+ } else if ((param & PARAM_MODE) == SET) {
+ strncpy(ssid.SSID, value, 32);
+ ssid.SSID_len = strlen(value);
+
+ if (ssid.SSID_len > 32)
+ ssid.SSID_len = 32;
+
+ if (vif == 0) {
+ /* for the main interface, also try the WLC_SET_SSID call */
+ ret2 = wl_ioctl(interface, WLC_SET_SSID, &ssid, sizeof(ssid));
+ }
+
+ ret = wl_bssiovar_set(interface, "ssid", vif, &ssid, sizeof(ssid));
+ ret = (!ret2 ? 0 : ret);
+ }
+
+ return ret;
+}
+
+static int wlc_int(wlc_param param, void *data, void *value)
+{
+ int *var = *((int **) data);
+ int *val = (int *) value;
+
+ if ((param & PARAM_MODE) == SET) {
+ *var = *val;
+ } else if ((param & PARAM_MODE) == GET) {
+ *val = *var;
+ }
+
+ return 0;
+}
+
+static int wlc_flag(wlc_param param, void *data, void *value)
+{
+ int *var = *((int **) data);
+
+ *var = 1;
+
+ return 0;
+}
+
+static int wlc_string(wlc_param param, void *data, void *value)
+{
+ char *var = *((char **) data);
+
+ if ((param & PARAM_MODE) == GET) {
+ strcpy(value, var);
+ }
+
+ return 0;
+}
+
+static int wlc_afterburner(wlc_param param, void *data, void *value)
+{
+ int *val = (int *) value;
+ int ret = 0;
+
+ if ((param & PARAM_MODE) == GET) {
+ ret = wl_iovar_get(interface, "afterburner", val, sizeof(int));
+ } else {
+ wl_iovar_setint(interface, "wlfeatureflag", (*val ? 3 : 0));
+ ret = wl_iovar_setint(interface, "afterburner", (*val ? 1 : 0));
+ wl_iovar_setint(interface, "afterburner_override", *val);
+ }
+
+ return ret;
+}
+
+static int wlc_maclist(wlc_param param, void *data, void *value)
+{
+ unsigned int *var = ((unsigned int *) data);
+ unsigned int ioc = *var;
+ int limit = (sizeof(wlbuf) - 4) / sizeof(struct ether_addr);
+ struct maclist *list = (struct maclist *) wlbuf;
+ char *str = (char *) value;
+ char astr[30], *p;
+ struct ether_addr *addr;
+ int isset = 0;
+ int ret;
+
+ if ((param & PARAM_MODE) == GET) {
+ list->count = limit;
+ ret = wl_ioctl(interface, (ioc >> 16) & 0xffff, wlbuf, sizeof(wlbuf));
+
+ if (!ret)
+ while (list->count) {
+ str += sprintf(str, "%s", ((((char *) value) == str) ? "" : " "));
+ str += my_ether_ntoa((unsigned char *) &list->ea[list->count-- - 1], str);
+ }
+
+ return ret;
+ } else {
+ while (*str && isspace(*str))
+ *str++;
+
+ if (*str == '+') {
+ str++;
+
+ list->count = limit;
+ if (wl_ioctl(interface, (ioc >> 16) & 0xffff, wlbuf, sizeof(wlbuf)) == 0)
+ isset = 1;
+
+ while (*str && isspace(*str))
+ str++;
+ }
+
+ if (!isset)
+ memset(wlbuf, 0, sizeof(wlbuf));
+
+ foreach(astr, str, p) {
+ if (list->count >= limit)
+ break;
+
+ if ((addr = ether_aton(astr)) != NULL)
+ memcpy(&list->ea[list->count++], addr, sizeof(struct ether_addr));
+ }
+
+ return wl_ioctl(interface, ioc & 0xffff, wlbuf, sizeof(wlbuf));
+ }
+}
+
+static int wlc_radio(wlc_param param, void *data, void *value)
+{
+ int *val = (int *) value;
+ int ret;
+
+ if ((param & PARAM_MODE) == GET) {
+ ret = wl_ioctl(interface, WLC_GET_RADIO, val, sizeof(int));
+ *val = ((*val & 1) ? 0 : 1);
+ } else {
+ *val = (1 << 16) | (*val ? 0 : 1);
+ ret = wl_ioctl(interface, WLC_SET_RADIO, val, sizeof(int));
+ }
+
+ return ret;
+}
+
+static int wlc_wsec_key(wlc_param param, void *null, void *value)
+{
+ wl_wsec_key_t wsec_key;
+ unsigned char *index = value;
+ unsigned char *key;
+ unsigned char *data;
+ unsigned char hex[3];
+
+ if ((param & PARAM_MODE) != SET)
+ return 0;
+
+ memset(&wsec_key, 0, sizeof(wsec_key));
+ if (index[0] == '=') {
+ wsec_key.flags = WL_PRIMARY_KEY;
+ index++;
+ }
+
+ if ((index[0] < '1') || (index[0] > '4') || (index[1] != ','))
+ return -1;
+
+ key = index + 2;
+ if (strncmp(key, "d:", 2) == 0) { /* delete key */
+ } else if (strncmp(key, "s:", 2) == 0) { /* ascii key */
+ key += 2;
+ wsec_key.len = strlen(key);
+
+ if ((wsec_key.len != 5) && (wsec_key.len != 13))
+ return -1;
+
+ strcpy(wsec_key.data, key);
+ } else { /* hex key */
+ wsec_key.len = strlen(key);
+ if ((wsec_key.len != 10) && (wsec_key.len != 26))
+ return -1;
+
+ wsec_key.len /= 2;
+ data = wsec_key.data;
+ hex[2] = 0;
+ do {
+ hex[0] = *(key++);
+ hex[1] = *(key++);
+ *(data++) = (unsigned char) strtoul(hex, NULL, 16);
+ } while (*key != 0);
+ }
+
+ return wl_bssiovar_set(interface, "wsec_key", vif, &wsec_key, sizeof(wsec_key));
+}
+
+static inline int cw2ecw(int cw)
+{
+ int i;
+ for (cw++, i = 0; cw; i++) cw >>=1;
+ return i - 1;
+}
+
+static int wlc_wme_ac(wlc_param param, void *data, void *value)
+{
+ char *type = *((char **) data);
+ char *settings = (char *) value;
+ char cmd[100], *p, *val;
+ edcf_acparam_t params[AC_COUNT];
+ int ret;
+ int intval;
+ int cur = -1;
+ char *buf = wlbuf;
+
+ if ((param & PARAM_MODE) != SET)
+ return -1;
+
+ memset(params, 0, sizeof(params));
+ ret = wl_iovar_get(interface, type, params, sizeof(params));
+ memset(buf, 0, BUFSIZE);
+ strcpy(buf, type);
+ buf += strlen(buf) + 1;
+
+ foreach(cmd, settings, p) {
+ val = strchr(cmd, '=');
+ if (val == NULL) {
+ if (strcmp(cmd, "be") == 0)
+ cur = AC_BE;
+ else if (strcmp(cmd, "bk") == 0)
+ cur = AC_BK;
+ else if (strcmp(cmd, "vi") == 0)
+ cur = AC_VI;
+ else if (strcmp(cmd, "vo") == 0)
+ cur = AC_VO;
+ else
+ return -1;
+
+ /* just in case */
+ params[cur].ACI = (params[cur].ACI & (0x3 << 5)) | (cur << 5);
+ } else {
+ *(val++) = 0;
+
+ intval = strtoul(val, NULL, 10);
+ if (strcmp(cmd, "cwmin") == 0)
+ params[cur].ECW = (params[cur].ECW & ~(0xf)) | cw2ecw(intval);
+ else if (strcmp(cmd, "ecwmin") == 0)
+ params[cur].ECW = (params[cur].ECW & ~(0xf)) | (intval & 0xf);
+ else if (strcmp(cmd, "cwmax") == 0)
+ params[cur].ECW = (params[cur].ECW & ~(0xf << 4)) | (cw2ecw(intval) << 4);
+ else if (strcmp(cmd, "ecwmax") == 0)
+ params[cur].ECW = (params[cur].ECW & ~(0xf << 4)) | ((intval & 0xf) << 4);
+ else if (strcmp(cmd, "aifsn") == 0)
+ params[cur].ACI = (params[cur].ACI & ~(0xf)) | (intval & 0xf);
+ else if (strcmp(cmd, "txop") == 0)
+ params[cur].TXOP = intval >> 5;
+ else if (strcmp(cmd, "force") == 0)
+ params[cur].ACI = (params[cur].ACI & ~(1 << 4)) | ((intval) ? (1 << 4) : 0);
+ else return -1;
+
+ memcpy(buf, &params[cur], sizeof(edcf_acparam_t));
+ wl_ioctl(interface, WLC_SET_VAR, wlbuf, BUFSIZE);
+ }
+ }
+ return ret;
+}
+
+static int wlc_ifname(wlc_param param, void *data, void *value)
+{
+ char *val = (char *) value;
+ int ret = 0;
+
+ if (param & SET) {
+ if (strlen(val) < 16)
+ strcpy(interface, val);
+ else ret = -1;
+ }
+ if (param & GET) {
+ strcpy(val, interface);
+ }
+
+ return ret;
+}
+
+static int wlc_wdsmac(wlc_param param, void *data, void *value)
+{
+ unsigned char mac[6];
+ int ret = 0;
+
+ ret = wl_ioctl(interface, WLC_WDS_GET_REMOTE_HWADDR, &mac, 6);
+ if (ret == 0)
+ my_ether_ntoa(mac, value);
+
+ return ret;
+}
+
+static int wlc_pmk(wlc_param param, void *data, void *value)
+{
+ int ret = -1;
+ char *str = (char *) value;
+ wsec_pmk_t pmk;
+
+ /* driver doesn't support GET */
+
+ if ((param & PARAM_MODE) == SET) {
+ strncpy(pmk.key, value, WSEC_MAX_PSK_LEN);
+ pmk.key_len = strlen(value);
+
+ if (pmk.key_len > WSEC_MAX_PSK_LEN)
+ pmk.key_len = WSEC_MAX_PSK_LEN;
+
+ pmk.flags = WSEC_PASSPHRASE;
+
+ ret = wl_ioctl(interface, WLC_SET_WSEC_PMK, &pmk, sizeof(pmk));
+ }
+
+ return ret;
+}
+
+static const struct wlc_call wlc_calls[] = {
+ {
+ .name = "version",
+ .param = STRING|NOARG,
+ .handler = wlc_string,
+ .data.str = VERSION,
+ .desc = "Version of this program"
+ },
+ {
+ .name = "debug",
+ .param = INT,
+ .handler = wlc_int,
+ .data.ptr = &debug,
+ .desc = "wlc debug level"
+ },
+ {
+ .name = "stdin",
+ .param = NOARG,
+ .handler = wlc_flag,
+ .data.ptr = &fromstdin,
+ .desc = "Accept input from stdin"
+ },
+ {
+ .name = "ifname",
+ .param = STRING,
+ .handler = wlc_ifname,
+ .desc = "interface to send commands to"
+ },
+ {
+ .name = "up",
+ .param = NOARG,
+ .handler = wlc_ioctl,
+ .data.num = WLC_UP,
+ .desc = "Bring the interface up"
+ },
+ {
+ .name = "down",
+ .param = NOARG,
+ .handler = wlc_ioctl,
+ .data.num = WLC_DOWN,
+ .desc = "Bring the interface down"
+ },
+ {
+ .name = "radio",
+ .param = INT,
+ .handler = wlc_radio,
+ .desc = "Radio enabled flag"
+ },
+ {
+ .name = "ap",
+ .param = INT,
+ .handler = wlc_ioctl,
+ .data.num = ((WLC_GET_AP << 16) | WLC_SET_AP),
+ .desc = "Access Point mode"
+ },
+ {
+ .name = "mssid",
+ .param = INT,
+ .handler = wlc_iovar,
+ .data.str = "mbss",
+ .desc = "Multi-ssid mode"
+ },
+ {
+ .name = "apsta",
+ .param = INT,
+ .handler = wlc_iovar,
+ .data.str = "apsta",
+ .desc = "AP+STA mode"
+ },
+ {
+ .name = "infra",
+ .param = INT,
+ .handler = wlc_ioctl,
+ .data.num = ((WLC_GET_INFRA << 16) | WLC_SET_INFRA),
+ .desc = "Infrastructure mode"
+ },
+ {
+ .name = "wet",
+ .param = INT,
+ .handler = wlc_ioctl,
+ .data.num = ((WLC_GET_WET << 16) | WLC_SET_WET),
+ .desc = "Wireless repeater mode",
+ },
+ {
+ .name = "statimeout",
+ .param = INT,
+ .handler = wlc_iovar,
+ .data.str = "sta_retry_time",
+ .desc = "STA connection timeout"
+ },
+ {
+ .name = "country",
+ .param = STRING,
+ .handler = wlc_ioctl,
+ .data.num = ((WLC_GET_COUNTRY << 16) | WLC_SET_COUNTRY),
+ .desc = "Country code"
+ },
+ {
+ .name = "channel",
+ .param = INT,
+ .handler = wlc_ioctl,
+ .data.num = ((WLC_GET_CHANNEL << 16) | WLC_SET_CHANNEL),
+ .desc = "Channel",
+ },
+ {
+ .name = "vlan_mode",
+ .param = INT,
+ .handler = wlc_bssiovar,
+ .data.str = "vlan_mode",
+ .desc = "Parse 802.1Q tags",
+ },
+ {
+ .name = "vif",
+ .param = INT,
+ .handler = wlc_int,
+ .data.ptr = &vif,
+ .desc = "Current vif index"
+ },
+ {
+ .name = "enabled",
+ .param = INT,
+ .handler = wlc_vif_enabled,
+ .desc = "vif enabled flag"
+ },
+ {
+ .name = "ssid",
+ .param = STRING,
+ .handler = wlc_ssid,
+ .desc = "Interface ESSID"
+ },
+ {
+ .name = "closed",
+ .param = INT,
+ .handler = wlc_bssiovar,
+ .data.str = "closednet",
+ .desc = "Hidden ESSID flag"
+ },
+ {
+ .name = "wsec",
+ .param = INT,
+ .handler = wlc_bssiovar,
+ .data.str = "wsec",
+ .desc = "Security mode flags"
+ },
+ {
+ .name = "wepkey",
+ .param = STRING,
+ .handler = wlc_wsec_key,
+ .desc = "Set/Remove WEP keys"
+ },
+ {
+ .name = "wepauth",
+ .param = INT,
+ .handler = wlc_ioctl,
+ .data.num = ((WLC_GET_AUTH << 16) | WLC_SET_AUTH),
+ .desc = "WEP authentication type. 0 = OpenSystem, 1 = SharedKey"
+ },
+ {
+ .name = "wsec_restrict",
+ .param = INT,
+ .handler = wlc_bssiovar,
+ .data.str = "wsec_restrict",
+ .desc = "Drop unencrypted traffic"
+ },
+ {
+ .name = "eap_restrict",
+ .param = INT,
+ .handler = wlc_bssiovar,
+ .data.str = "eap_restrict",
+ .desc = "Only allow 802.1X traffic until 802.1X authorized"
+ },
+ {
+ .name = "wpa_auth",
+ .param = INT,
+ .handler = wlc_bssiovar,
+ .data.str = "wpa_auth",
+ .desc = "WPA authentication modes"
+ },
+ {
+ .name = "ap_isolate",
+ .param = INT,
+ .handler = wlc_bssiovar,
+ .data.str = "ap_isolate",
+ .desc = "Isolate connected clients"
+ },
+ {
+ .name = "supplicant",
+ .param = INT,
+ .handler = wlc_iovar,
+ .data.str = "sup_wpa",
+ .desc = "Built-in WPA supplicant"
+ },
+ {
+ .name = "passphrase",
+ .param = STRING,
+ .handler = wlc_pmk,
+ .desc = "Passphrase for built-in WPA supplicant",
+ },
+ {
+ .name = "maxassoc",
+ .param = INT,
+ .handler = wlc_iovar,
+ .data.str = "maxassoc",
+ .desc = "Max. number of associated clients",
+ },
+ {
+ .name = "wme",
+ .param = INT,
+ .handler = wlc_iovar,
+ .data.str = "wme",
+ .desc = "WME enabled"
+ },
+ {
+ .name = "wme_ac_ap",
+ .param = STRING,
+ .handler = wlc_wme_ac,
+ .data.str = "wme_ac_ap",
+ .desc = "Set WME AC options for AP mode",
+ },
+ {
+ .name = "wme_ac_sta",
+ .param = STRING,
+ .handler = wlc_wme_ac,
+ .data.str = "wme_ac_sta",
+ .desc = "Set WME AC options for STA mode",
+ },
+ {
+ .name = "wme_noack",
+ .param = INT,
+ .handler = wlc_iovar,
+ .data.str = "wme_noack",
+ .desc = "WME ACK disable request",
+ },
+ {
+ .name = "802.11d",
+ .param = INT,
+ .handler = wlc_ioctl,
+ .data.num = ((WLC_GET_REGULATORY << 16) | WLC_SET_REGULATORY),
+ .desc = "Enable/disable 802.11d regulatory management",
+ },
+ {
+ .name = "802.11h",
+ .param = INT,
+ .handler = wlc_ioctl,
+ .data.num = ((WLC_GET_SPECT_MANAGMENT << 16) | WLC_SET_SPECT_MANAGMENT),
+ .desc = "Enable/disable 802.11h spectrum management",
+ },
+ {
+ .name = "fragthresh",
+ .param = INT,
+ .handler = wlc_iovar,
+ .data.str = "fragthresh",
+ .desc = "Fragmentation threshold",
+ },
+ {
+ .name = "rtsthresh",
+ .param = INT,
+ .handler = wlc_iovar,
+ .data.str = "rtsthresh",
+ .desc = "RTS threshold"
+ },
+ {
+ .name = "slottime",
+ .param = INT,
+ .handler = wlc_iovar,
+ .data.str = "acktiming",
+ .desc = "Slot time"
+ },
+ {
+ .name = "rxant",
+ .param = INT,
+ .handler = wlc_ioctl,
+ .data.num = ((WLC_GET_ANTDIV << 16) | WLC_SET_ANTDIV),
+ .desc = "Rx antenna selection"
+ },
+ {
+ .name = "txant",
+ .param = INT,
+ .handler = wlc_ioctl,
+ .data.num = ((WLC_GET_TXANT << 16) | WLC_SET_TXANT),
+ .desc = "Tx antenna selection"
+ },
+ {
+ .name = "dtim",
+ .param = INT,
+ .handler = wlc_ioctl,
+ .data.num = ((WLC_GET_DTIMPRD << 16) | WLC_SET_DTIMPRD),
+ .desc = "DTIM period",
+ },
+ {
+ .name = "bcn",
+ .param = INT,
+ .handler = wlc_ioctl,
+ .data.num = ((WLC_GET_BCNPRD << 16) | WLC_SET_BCNPRD),
+ .desc = "Beacon interval"
+ },
+ {
+ .name = "frameburst",
+ .param = INT,
+ .handler = wlc_ioctl,
+ .data.num = ((WLC_GET_FAKEFRAG << 16) | WLC_SET_FAKEFRAG),
+ .desc = "Framebursting"
+ },
+ {
+ .name = "monitor",
+ .param = INT,
+ .handler = wlc_ioctl,
+ .data.num = ((WLC_GET_MONITOR << 16) | WLC_SET_MONITOR),
+ .desc = "Monitor mode"
+ },
+ {
+ .name = "passive_scan",
+ .param = INT,
+ .handler = wlc_ioctl,
+ .data.num = ((WLC_GET_PASSIVE_SCAN << 16) | WLC_SET_PASSIVE_SCAN),
+ .desc = "Passive scan mode"
+ },
+ {
+ .name = "macfilter",
+ .param = INT,
+ .handler = wlc_ioctl,
+ .data.num = ((WLC_GET_MACMODE << 16) | WLC_SET_MACMODE),
+ .desc = "MAC filter mode (0:disabled, 1:deny, 2:allow)"
+ },
+ {
+ .name = "maclist",
+ .param = STRING,
+ .data.num = ((WLC_GET_MACLIST << 16) | WLC_SET_MACLIST),
+ .handler = wlc_maclist,
+ .desc = "MAC filter list"
+ },
+ {
+ .name = "autowds",
+ .param = INT,
+ .handler = wlc_ioctl,
+ .data.num = ((WLC_GET_LAZYWDS << 16) | WLC_SET_LAZYWDS),
+ .desc = "Automatic WDS"
+ },
+ {
+ .name = "wds",
+ .param = STRING,
+ .data.num = ((WLC_GET_WDSLIST << 16) | WLC_SET_WDSLIST),
+ .handler = wlc_maclist,
+ .desc = "WDS connection list"
+ },
+ {
+ .name = "wdstimeout",
+ .param = INT,
+ .handler = wlc_iovar,
+ .data.str = "wdstimeout",
+ .desc = "WDS link detection timeout"
+ },
+ {
+ .name = "wdsmac",
+ .param = STRING|NOARG,
+ .handler = wlc_wdsmac,
+ .desc = "MAC of the remote WDS endpoint (only with wds0.* interfaces)"
+ },
+ {
+ .name = "afterburner",
+ .param = INT,
+ .handler = wlc_afterburner,
+ .desc = "Broadcom Afterburner"
+ },
+ {
+ .name = "ibss_merge",
+ .param = INT,
+ .handler = wlc_iovar,
+ .data.str = "ibss_coalesce_allowed",
+ .desc = "Allow IBSS merges"
+ },
+ {
+ .name = "bssid",
+ .param = MAC,
+ .handler = wlc_ioctl,
+ .data.num = ((WLC_GET_BSSID << 16) | WLC_SET_BSSID),
+ .desc = "BSSID"
+ },
+ {
+ .name = "default_bssid",
+ .param = MAC,
+ .handler = wlc_iovar,
+ .data.str = "perm_etheraddr",
+ .desc = "Default BSSID (read-only)"
+ },
+ {
+ .name = "assoclist",
+ .param = STRING,
+ .data.num = (WLC_GET_ASSOCLIST << 16),
+ .handler = wlc_maclist,
+ .desc = "MACs of associated stations"
+ },
+ {
+ .name = "gmode",
+ .param = INT,
+ .data.num = ((WLC_GET_GMODE << 16) | WLC_SET_GMODE),
+ .handler = wlc_ioctl,
+ .desc = "G Mode"
+ },
+};
+#define wlc_calls_size (sizeof(wlc_calls) / sizeof(struct wlc_call))
+
+static void usage(char *cmd)
+{
+ int i;
+ fprintf(stderr, "Usage: %s <command> [<argument> ...]\n"
+ "\n"
+ "Available commands:\n", cmd);
+ for (i = 0; i < wlc_calls_size; i++) {
+ fprintf(stderr, "\t%-16s\t%s\n", wlc_calls[i].name ?: "", wlc_calls[i].desc ?: "");
+ }
+ fprintf(stderr, "\n");
+ exit(1);
+}
+
+static int do_command(const struct wlc_call *cmd, char *arg)
+{
+ static char buf[BUFSIZE];
+ int set;
+ int ret = 0;
+ char *format, *end;
+ int intval;
+ void *ptr = (void *) buf;
+
+ if (debug >= 10) {
+ fprintf(stderr, "do_command %-16s\t'%s'\n", cmd->name, arg);
+ }
+
+ if ((arg == NULL) && ((cmd->param & PARAM_TYPE) != NONE)) {
+ set = 0;
+ ret = cmd->handler(cmd->param | GET, (void *) &cmd->data, (void *) buf);
+ if (ret == 0) {
+ switch(cmd->param & PARAM_TYPE) {
+ case INT:
+ intval = *((int *) buf);
+
+ if (intval > 65535)
+ format = "0x%08x\n";
+ else if (intval > 255)
+ format = "0x%04x\n";
+ else
+ format = "%d\n";
+
+ fprintf(stdout, format, intval);
+ break;
+ case STRING:
+ fprintf(stdout, "%s\n", buf);
+ break;
+ case MAC:
+ my_ether_ntoa(buf, buf + 6);
+ fprintf(stdout, "%s\n", buf + 6);
+ break;
+ }
+ }
+ } else { /* SET */
+ set = 1;
+ switch(cmd->param & PARAM_TYPE) {
+ case INT:
+ intval = strtoul(arg, &end, 10);
+ if (end && !(*end)) {
+ memcpy(buf, &intval, sizeof(intval));
+ } else {
+ fprintf(stderr, "%s: Invalid argument\n", cmd->name);
+ return -1;
+ }
+ break;
+ case STRING:
+ strncpy(buf, arg, BUFSIZE);
+ buf[BUFSIZE - 1] = 0;
+ break;
+ case MAC:
+ ptr = ether_aton(arg);
+ if (!ptr) {
+ fprintf(stderr, "%s: Invalid mac address '%s'\n", cmd->name, arg);
+ return -1;
+ }
+ break;
+ }
+
+ ret = cmd->handler(cmd->param | SET, (void *) &cmd->data, ptr);
+ }
+
+ if ((debug > 0) && (ret != 0))
+ fprintf(stderr, "Command '%s %s' failed: %d\n", (set == 1 ? "set" : "get"), cmd->name, ret);
+
+ return ret;
+}
+
+static struct wlc_call *find_cmd(char *name)
+{
+ int found = 0, i = 0;
+
+ while (!found && (i < wlc_calls_size)) {
+ if (strcmp(name, wlc_calls[i].name) == 0)
+ found = 1;
+ else
+ i++;
+ }
+
+ return (struct wlc_call *) (found ? &wlc_calls[i] : NULL);
+}
+
+int main(int argc, char **argv)
+{
+ static char buf[BUFSIZE];
+ char *s, *s2;
+ char *cmd = argv[0];
+ struct wlc_call *call;
+ int ret = 0;
+
+ if (argc < 2)
+ usage(argv[0]);
+
+ for(interface[2] = '0'; (interface[2] < '3') && (wl_probe(interface) != 0); interface[2]++);
+ if (interface[2] == '3') {
+ fprintf(stderr, "No Broadcom wl interface found!\n");
+ return -1;
+ }
+
+ argv++;
+ argc--;
+ while ((argc > 0) && (argv[0] != NULL)) {
+ if ((call = find_cmd(argv[0])) == NULL) {
+ fprintf(stderr, "Invalid command: %s\n\n", argv[0]);
+ usage(cmd);
+ }
+ if ((argc > 1) && (!(call->param & NOARG))) {
+ ret = do_command(call, argv[1]);
+ argv += 2;
+ argc -= 2;
+ } else {
+ ret = do_command(call, NULL);
+ argv++;
+ argc--;
+ }
+ }
+
+ while (fromstdin && !feof(stdin)) {
+ *buf = 0;
+ fgets(buf, BUFSIZE - 1, stdin);
+
+ if (*buf == 0)
+ continue;
+
+ if ((s = strchr(buf, '\r')) != NULL)
+ *s = 0;
+ if ((s = strchr(buf, '\n')) != NULL)
+ *s = 0;
+
+ s = buf;
+ while (isspace(*s))
+ s++;
+
+ if (!*s)
+ continue;
+
+ if ((s2 = strchr(buf, ' ')) != NULL)
+ *(s2++) = 0;
+
+ while (s2 && isspace(*s2))
+ s2++;
+
+ if ((call = find_cmd(buf)) == NULL) {
+ fprintf(stderr, "Invalid command: %s\n", buf);
+ ret = -1;
+ } else
+ ret = do_command(call, ((call->param & NOARG) ? NULL : s2));
+ }
+
+ return ret;
+}
diff --git a/package/busybox/.svn/entries b/package/busybox/.svn/entries
new file mode 100644
index 0000000..0d240c3
--- /dev/null
+++ b/package/busybox/.svn/entries
@@ -0,0 +1,139 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/busybox
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-16T01:25:42.853956Z
+36054
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+files
+dir
+
+convert_menuconfig.pl
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+ef4fbf17c695b947d5fa996ef33a9d39
+2009-04-17T14:32:29.989894Z
+15245
+nico
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2008
+
+config
+dir
+
+patches
+dir
+
+Config.in
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+5e869117455c48abb20855d24fece97f
+2012-06-10T22:24:24.336391Z
+32175
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+413
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+587ae8162d49d362e9004457b9d7a74e
+2013-03-16T01:25:42.853956Z
+36054
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2943
+
diff --git a/package/busybox/.svn/prop-base/Config.in.svn-base b/package/busybox/.svn/prop-base/Config.in.svn-base
new file mode 100644
index 0000000..0bac43c
--- /dev/null
+++ b/package/busybox/.svn/prop-base/Config.in.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:eol-style
+V 6
+native
+K 13
+svn:mergeinfo
+V 0
+
+END
diff --git a/package/busybox/.svn/prop-base/Makefile.svn-base b/package/busybox/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..8e522ae
--- /dev/null
+++ b/package/busybox/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:copyright
+V 30
+Copyright (C) 2006 OpenWrt.org
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/busybox/.svn/prop-base/convert_menuconfig.pl.svn-base b/package/busybox/.svn/prop-base/convert_menuconfig.pl.svn-base
new file mode 100644
index 0000000..03b5bfa
--- /dev/null
+++ b/package/busybox/.svn/prop-base/convert_menuconfig.pl.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:eol-style
+V 6
+native
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/busybox/.svn/text-base/Config.in.svn-base b/package/busybox/.svn/text-base/Config.in.svn-base
new file mode 100644
index 0000000..88d1aa2
--- /dev/null
+++ b/package/busybox/.svn/text-base/Config.in.svn-base
@@ -0,0 +1,24 @@
+
+if PACKAGE_busybox
+
+config BUSYBOX_CONFIG_NOMMU
+ bool
+ depends NOMMU
+ default y if NOMMU
+ deselect BUSYBOX_CONFIG_ASH
+ deselect BUSYBOX_CONFIG_FEATURE_SH_IS_ASH
+ deselect BUSYBOX_CONFIG_LOCK
+
+config CONFIG_BUSYBOX_CONFIG_FEATURE_SH_IS_HUSH
+ bool
+ default y if NOMMU
+ default n if !NOMMU
+
+config BUSYBOX_CONFIG_HUSH
+ bool
+ default y if NOMMU
+ default n if !NOMMU
+
+source "package/busybox/config/Config.in"
+
+endif
diff --git a/package/busybox/.svn/text-base/Makefile.svn-base b/package/busybox/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..ed58fab
--- /dev/null
+++ b/package/busybox/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,118 @@
+#
+# Copyright (C) 2006-2013 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=busybox
+PKG_VERSION:=1.19.4
+PKG_RELEASE:=6
+PKG_FLAGS:=essential
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=http://www.busybox.net/downloads \
+ http://distfiles.gentoo.org/distfiles/
+PKG_MD5SUM:=9c0cae5a0379228e7b55e5b29528df8e
+
+PKG_CONFIG_DEPENDS:=CONFIG_PROCD_INIT
+PKG_BUILD_DEPENDS:=BUSYBOX_CONFIG_FEATURE_HAVE_RPC:librpc
+PKG_BUILD_PARALLEL:=1
+
+PKG_LICENSE:=GPLv2 BSD-4c
+PKG_LICENSE_FILES:=LICENSE archival/libarchive/bz/LICENSE
+
+include $(INCLUDE_DIR)/package.mk
+
+ifeq ($(DUMP),)
+ STAMP_CONFIGURED:=$(strip $(STAMP_CONFIGURED))_$(shell $(SH_FUNC) grep '^CONFIG_BUSYBOX_' $(TOPDIR)/.config | md5s)
+endif
+
+ifneq ($(findstring c,$(OPENWRT_VERBOSE)),)
+ BB_MAKE_VERBOSE := V=1
+else
+ BB_MAKE_VERBOSE :=
+endif
+
+init-y :=
+init-$(CONFIG_BUSYBOX_CONFIG_CROND) += cron
+init-$(CONFIG_BUSYBOX_CONFIG_TELNETD) += telnet
+
+define Package/busybox
+ SECTION:=base
+ CATEGORY:=Base system
+ MAINTAINER:=Nicolas Thill <nico@openwrt.org>
+ TITLE:=Core utilities for embedded Linux
+ URL:=http://busybox.net/
+ DEPENDS:=+BUSYBOX_CONFIG_FEATURE_HAVE_RPC:librpc
+ MENU:=1
+endef
+
+define Package/busybox/description
+ The Swiss Army Knife of embedded Linux.
+ It slices, it dices, it makes Julian Fries.
+endef
+
+define Package/busybox/config
+ source "$(SOURCE)/Config.in"
+endef
+
+define Build/Configure
+ rm -f $(PKG_BUILD_DIR)/.configured*
+ grep 'CONFIG_BUSYBOX_' $(TOPDIR)/.config | sed -e "s,\\(# \)\\?CONFIG_BUSYBOX_\\(.*\\),\\1\\2,g" > $(PKG_BUILD_DIR)/.config
+ yes 'n' | $(MAKE) -C $(PKG_BUILD_DIR) \
+ CC="$(TARGET_CC)" \
+ CROSS_COMPILE="$(TARGET_CROSS)" \
+ KBUILD_HAVE_NLS=no \
+ ARCH="$(ARCH)" \
+ $(BB_MAKE_VERBOSE) \
+ oldconfig
+endef
+
+ifdef CONFIG_GCC_VERSION_LLVM
+ TARGET_CFLAGS += -fnested-functions
+endif
+
+LDLIBS:=m crypt
+ifdef CONFIG_BUSYBOX_CONFIG_FEATURE_HAVE_RPC
+ TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include
+ export LDFLAGS=$(TARGET_LDFLAGS)
+ LDLIBS += rpc
+endif
+
+define Build/Compile
+ +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
+ CC="$(TARGET_CC)" \
+ CROSS_COMPILE="$(TARGET_CROSS)" \
+ KBUILD_HAVE_NLS=no \
+ EXTRA_CFLAGS="$(TARGET_CFLAGS)" \
+ ARCH="$(ARCH)" \
+ SKIP_STRIP=y \
+ LDLIBS="$(LDLIBS)" \
+ $(BB_MAKE_VERBOSE) \
+ all
+ rm -rf $(PKG_INSTALL_DIR)
+ $(FIND) $(PKG_BUILD_DIR) -lname "*busybox" -exec rm \{\} \;
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ CC="$(TARGET_CC)" \
+ CROSS_COMPILE="$(TARGET_CROSS)" \
+ EXTRA_CFLAGS="$(TARGET_CFLAGS)" \
+ ARCH="$(ARCH)" \
+ CONFIG_PREFIX="$(PKG_INSTALL_DIR)" \
+ LDLIBS="$(LDLIBS)" \
+ $(BB_MAKE_VERBOSE) \
+ install
+endef
+
+define Package/busybox/install
+ $(INSTALL_DIR) $(1)/etc/init.d
+ $(CP) $(PKG_INSTALL_DIR)/* $(1)/
+ for tmp in $(init-y); do \
+ $(INSTALL_BIN) ./files/$$$$tmp $(1)/etc/init.d/$$$$tmp; \
+ done
+ -rm -rf $(1)/lib64
+endef
+
+$(eval $(call BuildPackage,busybox))
diff --git a/package/busybox/.svn/text-base/convert_menuconfig.pl.svn-base b/package/busybox/.svn/text-base/convert_menuconfig.pl.svn-base
new file mode 100644
index 0000000..0128bf7
--- /dev/null
+++ b/package/busybox/.svn/text-base/convert_menuconfig.pl.svn-base
@@ -0,0 +1,78 @@
+#!/usr/bin/perl
+#
+# Copyright (C) 2006 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+use strict;
+my $PATH = $ARGV[0];
+($PATH and -d $PATH) or die 'invalid path';
+my $DEFCONFIG = $ARGV[1];
+($DEFCONFIG and -f $DEFCONFIG) or die 'invalid config file';
+
+my %config;
+
+open CONFIG, $DEFCONFIG or die 'cannot open config file';
+while (<CONFIG>) {
+ /^CONFIG_([\w_]+)=([ym])/ and $config{$1} = $2;
+ /^CONFIG_([\w_]+)=(\d+)/ and $config{$1} = $2;
+ /^CONFIG_([\w_]+)=(".+")/ and $config{$1} = $2;
+}
+close CONFIG;
+
+open FIND, "find \"$PATH\" -name Config.in |";
+while (<FIND>) {
+ chomp;
+ my $input = $_;
+ s/^$PATH\///g;
+ s/sysdeps\/linux\///g;
+ my $output = $_;
+ print STDERR "$input => $output\n";
+ $output =~ /^(.+)\/[^\/]+$/ and system("mkdir -p $1");
+
+ open INPUT, $input;
+ open OUTPUT, ">$output";
+ my ($cur, $default_set, $line);
+ while ($line = <INPUT>) {
+ next if $line =~ /^\s*mainmenu/;
+
+ # FIXME: make this dynamic
+ $line =~ s/default FEATURE_BUFFERS_USE_MALLOC/default FEATURE_BUFFERS_GO_ON_STACK/;
+ $line =~ s/default FEATURE_SH_IS_NONE/default FEATURE_SH_IS_ASH/;
+
+ if ($line =~ /^\s*config\s*([\w_]+)/) {
+ $cur = $1;
+ undef $default_set;
+ }
+ if ($line =~ /^\s*(menu|choice|end|source)/) {
+ undef $cur;
+ undef $default_set;
+ }
+ $line =~ s/^(\s*source\s+)/$1package\/busybox\/config\//;
+
+ $line =~ s/^(\s*(prompt "[^"]+" if|config|depends|depends on|select|default|default \w if)\s+\!?)([A-Z_])/$1BUSYBOX_CONFIG_$3/g;
+ $line =~ s/(( \|\| | \&\& | \( )!?)([A-Z_])/$1BUSYBOX_CONFIG_$3/g;
+ $line =~ s/(\( ?!?)([A-Z_]+ (\|\||&&))/$1BUSYBOX_CONFIG_$2/g;
+
+ if ($cur) {
+ ($cur eq 'LFS') and do {
+ $line =~ s/^(\s*(bool|tristate|string))\s*".+"$/$1/;
+ };
+ if ($line =~ /^\s*default/) {
+ my $c;
+ $default_set = 1;
+ $c = $config{$cur} or $c = 'n';
+
+ $line =~ s/^(\s*default\s*)(\w+|"[^"]*")(.*)/$1$c$3/;
+ }
+ }
+
+ print OUTPUT $line;
+ }
+ close OUTPUT;
+ close INPUT;
+
+}
+close FIND;
diff --git a/package/busybox/Config.in b/package/busybox/Config.in
new file mode 100644
index 0000000..88d1aa2
--- /dev/null
+++ b/package/busybox/Config.in
@@ -0,0 +1,24 @@
+
+if PACKAGE_busybox
+
+config BUSYBOX_CONFIG_NOMMU
+ bool
+ depends NOMMU
+ default y if NOMMU
+ deselect BUSYBOX_CONFIG_ASH
+ deselect BUSYBOX_CONFIG_FEATURE_SH_IS_ASH
+ deselect BUSYBOX_CONFIG_LOCK
+
+config CONFIG_BUSYBOX_CONFIG_FEATURE_SH_IS_HUSH
+ bool
+ default y if NOMMU
+ default n if !NOMMU
+
+config BUSYBOX_CONFIG_HUSH
+ bool
+ default y if NOMMU
+ default n if !NOMMU
+
+source "package/busybox/config/Config.in"
+
+endif
diff --git a/package/busybox/Makefile b/package/busybox/Makefile
new file mode 100644
index 0000000..ed58fab
--- /dev/null
+++ b/package/busybox/Makefile
@@ -0,0 +1,118 @@
+#
+# Copyright (C) 2006-2013 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=busybox
+PKG_VERSION:=1.19.4
+PKG_RELEASE:=6
+PKG_FLAGS:=essential
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=http://www.busybox.net/downloads \
+ http://distfiles.gentoo.org/distfiles/
+PKG_MD5SUM:=9c0cae5a0379228e7b55e5b29528df8e
+
+PKG_CONFIG_DEPENDS:=CONFIG_PROCD_INIT
+PKG_BUILD_DEPENDS:=BUSYBOX_CONFIG_FEATURE_HAVE_RPC:librpc
+PKG_BUILD_PARALLEL:=1
+
+PKG_LICENSE:=GPLv2 BSD-4c
+PKG_LICENSE_FILES:=LICENSE archival/libarchive/bz/LICENSE
+
+include $(INCLUDE_DIR)/package.mk
+
+ifeq ($(DUMP),)
+ STAMP_CONFIGURED:=$(strip $(STAMP_CONFIGURED))_$(shell $(SH_FUNC) grep '^CONFIG_BUSYBOX_' $(TOPDIR)/.config | md5s)
+endif
+
+ifneq ($(findstring c,$(OPENWRT_VERBOSE)),)
+ BB_MAKE_VERBOSE := V=1
+else
+ BB_MAKE_VERBOSE :=
+endif
+
+init-y :=
+init-$(CONFIG_BUSYBOX_CONFIG_CROND) += cron
+init-$(CONFIG_BUSYBOX_CONFIG_TELNETD) += telnet
+
+define Package/busybox
+ SECTION:=base
+ CATEGORY:=Base system
+ MAINTAINER:=Nicolas Thill <nico@openwrt.org>
+ TITLE:=Core utilities for embedded Linux
+ URL:=http://busybox.net/
+ DEPENDS:=+BUSYBOX_CONFIG_FEATURE_HAVE_RPC:librpc
+ MENU:=1
+endef
+
+define Package/busybox/description
+ The Swiss Army Knife of embedded Linux.
+ It slices, it dices, it makes Julian Fries.
+endef
+
+define Package/busybox/config
+ source "$(SOURCE)/Config.in"
+endef
+
+define Build/Configure
+ rm -f $(PKG_BUILD_DIR)/.configured*
+ grep 'CONFIG_BUSYBOX_' $(TOPDIR)/.config | sed -e "s,\\(# \)\\?CONFIG_BUSYBOX_\\(.*\\),\\1\\2,g" > $(PKG_BUILD_DIR)/.config
+ yes 'n' | $(MAKE) -C $(PKG_BUILD_DIR) \
+ CC="$(TARGET_CC)" \
+ CROSS_COMPILE="$(TARGET_CROSS)" \
+ KBUILD_HAVE_NLS=no \
+ ARCH="$(ARCH)" \
+ $(BB_MAKE_VERBOSE) \
+ oldconfig
+endef
+
+ifdef CONFIG_GCC_VERSION_LLVM
+ TARGET_CFLAGS += -fnested-functions
+endif
+
+LDLIBS:=m crypt
+ifdef CONFIG_BUSYBOX_CONFIG_FEATURE_HAVE_RPC
+ TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include
+ export LDFLAGS=$(TARGET_LDFLAGS)
+ LDLIBS += rpc
+endif
+
+define Build/Compile
+ +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
+ CC="$(TARGET_CC)" \
+ CROSS_COMPILE="$(TARGET_CROSS)" \
+ KBUILD_HAVE_NLS=no \
+ EXTRA_CFLAGS="$(TARGET_CFLAGS)" \
+ ARCH="$(ARCH)" \
+ SKIP_STRIP=y \
+ LDLIBS="$(LDLIBS)" \
+ $(BB_MAKE_VERBOSE) \
+ all
+ rm -rf $(PKG_INSTALL_DIR)
+ $(FIND) $(PKG_BUILD_DIR) -lname "*busybox" -exec rm \{\} \;
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ CC="$(TARGET_CC)" \
+ CROSS_COMPILE="$(TARGET_CROSS)" \
+ EXTRA_CFLAGS="$(TARGET_CFLAGS)" \
+ ARCH="$(ARCH)" \
+ CONFIG_PREFIX="$(PKG_INSTALL_DIR)" \
+ LDLIBS="$(LDLIBS)" \
+ $(BB_MAKE_VERBOSE) \
+ install
+endef
+
+define Package/busybox/install
+ $(INSTALL_DIR) $(1)/etc/init.d
+ $(CP) $(PKG_INSTALL_DIR)/* $(1)/
+ for tmp in $(init-y); do \
+ $(INSTALL_BIN) ./files/$$$$tmp $(1)/etc/init.d/$$$$tmp; \
+ done
+ -rm -rf $(1)/lib64
+endef
+
+$(eval $(call BuildPackage,busybox))
diff --git a/package/busybox/config/.svn/entries b/package/busybox/config/.svn/entries
new file mode 100644
index 0000000..21525ca
--- /dev/null
+++ b/package/busybox/config/.svn/entries
@@ -0,0 +1,125 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/busybox/config
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-13T18:11:31.576290Z
+36005
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+networking
+dir
+
+selinux
+dir
+
+loginutils
+dir
+
+archival
+dir
+
+sysklogd
+dir
+
+modutils
+dir
+
+console-tools
+dir
+
+findutils
+dir
+
+runit
+dir
+
+mailutils
+dir
+
+init
+dir
+
+debianutils
+dir
+
+procps
+dir
+
+shell
+dir
+
+editors
+dir
+
+coreutils
+dir
+
+libbb
+dir
+
+e2fsprogs
+dir
+
+util-linux
+dir
+
+Config.in
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+c8c6895dc6daaf2a930c4ecd6fe0d8d5
+2011-10-21T23:08:45.031764Z
+28513
+nico
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+27483
+
+miscutils
+dir
+
+printutils
+dir
+
diff --git a/package/busybox/config/.svn/prop-base/Config.in.svn-base b/package/busybox/config/.svn/prop-base/Config.in.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/busybox/config/.svn/prop-base/Config.in.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/busybox/config/.svn/text-base/Config.in.svn-base b/package/busybox/config/.svn/text-base/Config.in.svn-base
new file mode 100644
index 0000000..0045036
--- /dev/null
+++ b/package/busybox/config/.svn/text-base/Config.in.svn-base
@@ -0,0 +1,778 @@
+#
+# For a description of the syntax of this configuration file,
+# see scripts/kbuild/config-language.txt.
+#
+
+
+config BUSYBOX_CONFIG_HAVE_DOT_CONFIG
+ bool
+ default y
+
+menu "Busybox Settings"
+
+menu "General Configuration"
+
+config BUSYBOX_CONFIG_DESKTOP
+ bool "Enable options for full-blown desktop systems"
+ default n
+ help
+ Enable options and features which are not essential.
+ Select this only if you plan to use busybox on full-blown
+ desktop machine with common Linux distro, not on an embedded box.
+
+config BUSYBOX_CONFIG_EXTRA_COMPAT
+ bool "Provide compatible behavior for rare corner cases (bigger code)"
+ default n
+ help
+ This option makes grep, sed etc handle rare corner cases
+ (embedded NUL bytes and such). This makes code bigger and uses
+ some GNU extensions in libc. You probably only need this option
+ if you plan to run busybox on desktop.
+
+config BUSYBOX_CONFIG_INCLUDE_SUSv2
+ bool "Enable obsolete features removed before SUSv3"
+ default y
+ help
+ This option will enable backwards compatibility with SuSv2,
+ specifically, old-style numeric options ('command -1 <file>')
+ will be supported in head, tail, and fold. (Note: should
+ affect renice too.)
+
+config BUSYBOX_CONFIG_USE_PORTABLE_CODE
+ bool "Avoid using GCC-specific code constructs"
+ default n
+ help
+ Use this option if you are trying to compile busybox with
+ compiler other than gcc.
+ If you do use gcc, this option may needlessly increase code size.
+
+config BUSYBOX_CONFIG_PLATFORM_LINUX
+ bool "Enable Linux-specific applets and features"
+ default y
+ help
+ For the most part, busybox requires only POSIX compatibility
+ from the target system, but some applets and features use
+ Linux-specific interfaces.
+
+ Answering 'N' here will disable such applets and hide the
+ corresponding configuration options.
+
+choice
+ prompt "Buffer allocation policy"
+ default BUSYBOX_CONFIG_FEATURE_BUFFERS_GO_ON_STACK
+ help
+ There are 3 ways BusyBox can handle buffer allocations:
+ - Use malloc. This costs code size for the call to xmalloc.
+ - Put them on stack. For some very small machines with limited stack
+ space, this can be deadly. For most folks, this works just fine.
+ - Put them in BSS. This works beautifully for computers with a real
+ MMU (and OS support), but wastes runtime RAM for uCLinux. This
+ behavior was the only one available for BusyBox versions 0.48 and
+ earlier.
+
+config BUSYBOX_CONFIG_FEATURE_BUFFERS_USE_MALLOC
+ bool "Allocate with Malloc"
+
+config BUSYBOX_CONFIG_FEATURE_BUFFERS_GO_ON_STACK
+ bool "Allocate on the Stack"
+
+config BUSYBOX_CONFIG_FEATURE_BUFFERS_GO_IN_BSS
+ bool "Allocate in the .bss section"
+
+endchoice
+
+config BUSYBOX_CONFIG_SHOW_USAGE
+ bool "Show terse applet usage messages"
+ default y
+ help
+ All BusyBox applets will show help messages when invoked with
+ wrong arguments. You can turn off printing these terse usage
+ messages if you say no here.
+ This will save you up to 7k.
+
+config BUSYBOX_CONFIG_FEATURE_VERBOSE_USAGE
+ bool "Show verbose applet usage messages"
+ default y
+ depends on BUSYBOX_CONFIG_SHOW_USAGE
+ help
+ All BusyBox applets will show more verbose help messages when
+ busybox is invoked with --help. This will add a lot of text to the
+ busybox binary. In the default configuration, this will add about
+ 13k, but it can add much more depending on your configuration.
+
+config BUSYBOX_CONFIG_FEATURE_COMPRESS_USAGE
+ bool "Store applet usage messages in compressed form"
+ default y
+ depends on BUSYBOX_CONFIG_SHOW_USAGE
+ help
+ Store usage messages in compressed form, uncompress them on-the-fly
+ when <applet> --help is called.
+
+ If you have a really tiny busybox with few applets enabled (and
+ bunzip2 isn't one of them), the overhead of the decompressor might
+ be noticeable. Also, if you run executables directly from ROM
+ and have very little memory, this might not be a win. Otherwise,
+ you probably want this.
+
+config BUSYBOX_CONFIG_FEATURE_INSTALLER
+ bool "Support --install [-s] to install applet links at runtime"
+ default n
+ help
+ Enable 'busybox --install [-s]' support. This will allow you to use
+ busybox at runtime to create hard links or symlinks for all the
+ applets that are compiled into busybox.
+
+config BUSYBOX_CONFIG_INSTALL_NO_USR
+ bool "Don't use /usr"
+ default n
+ help
+ Disable use of /usr. busybox --install and "make install"
+ will install applets only to /bin and /sbin,
+ never to /usr/bin or /usr/sbin.
+
+config BUSYBOX_CONFIG_LOCALE_SUPPORT
+ bool "Enable locale support (system needs locale for this to work)"
+ default n
+ help
+ Enable this if your system has locale support and you would like
+ busybox to support locale settings.
+
+config BUSYBOX_CONFIG_UNICODE_SUPPORT
+ bool "Support Unicode"
+ default n
+ help
+ This makes various applets aware that one byte is not
+ one character on screen.
+
+ Busybox aims to eventually work correctly with Unicode displays.
+ Any older encodings are not guaranteed to work.
+ Probably by the time when busybox will be fully Unicode-clean,
+ other encodings will be mainly of historic interest.
+
+config BUSYBOX_CONFIG_UNICODE_USING_LOCALE
+ bool "Use libc routines for Unicode (else uses internal ones)"
+ default n
+ depends on BUSYBOX_CONFIG_UNICODE_SUPPORT && BUSYBOX_CONFIG_LOCALE_SUPPORT
+ help
+ With this option on, Unicode support is implemented using libc
+ routines. Otherwise, internal implementation is used.
+ Internal implementation is smaller.
+
+config BUSYBOX_CONFIG_FEATURE_CHECK_UNICODE_IN_ENV
+ bool "Check $LANG environment variable"
+ default n
+ depends on BUSYBOX_CONFIG_UNICODE_SUPPORT && !BUSYBOX_CONFIG_UNICODE_USING_LOCALE
+ help
+ With this option on, Unicode support is activated
+ only if LANG variable has the value of the form "xxxx.utf8"
+
+ Otherwise, Unicode support will be always enabled and active.
+
+config BUSYBOX_CONFIG_SUBST_WCHAR
+ int "Character code to substitute unprintable characters with"
+ depends on BUSYBOX_CONFIG_UNICODE_SUPPORT
+ default 63
+ help
+ Typical values are 63 for '?' (works with any output device),
+ 30 for ASCII substitute control code,
+ 65533 (0xfffd) for Unicode replacement character.
+
+config BUSYBOX_CONFIG_LAST_SUPPORTED_WCHAR
+ int "Range of supported Unicode characters"
+ depends on BUSYBOX_CONFIG_UNICODE_SUPPORT
+ default 767
+ help
+ Any character with Unicode value bigger than this is assumed
+ to be non-printable on output device. Many applets replace
+ such chars with substitution character.
+
+ The idea is that many valid printable Unicode chars are
+ nevertheless are not displayed correctly. Think about
+ combining charachers, double-wide hieroglyphs, obscure
+ characters in dozens of ancient scripts...
+ Many terminals, terminal emulators, xterms etc will fail
+ to handle them correctly. Choose the smallest value
+ which suits your needs.
+
+ Typical values are:
+ 126 - ASCII only
+ 767 (0x2ff) - there are no combining chars in [0..767] range
+ (the range includes Latin 1, Latin Ext. A and B),
+ code is ~700 bytes smaller for this case.
+ 4351 (0x10ff) - there are no double-wide chars in [0..4351] range,
+ code is ~300 bytes smaller for this case.
+ 12799 (0x31ff) - nearly all non-ideographic characters are
+ available in [0..12799] range, including
+ East Asian scripts like katakana, hiragana, hangul,
+ bopomofo...
+ 0 - off, any valid printable Unicode character will be printed.
+
+config BUSYBOX_CONFIG_UNICODE_COMBINING_WCHARS
+ bool "Allow zero-width Unicode characters on output"
+ default n
+ depends on BUSYBOX_CONFIG_UNICODE_SUPPORT
+ help
+ With this option off, any Unicode char with width of 0
+ is substituted on output.
+
+config BUSYBOX_CONFIG_UNICODE_WIDE_WCHARS
+ bool "Allow wide Unicode characters on output"
+ default n
+ depends on BUSYBOX_CONFIG_UNICODE_SUPPORT
+ help
+ With this option off, any Unicode char with width > 1
+ is substituted on output.
+
+config BUSYBOX_CONFIG_UNICODE_BIDI_SUPPORT
+ bool "Bidirectional character-aware line input"
+ default n
+ depends on BUSYBOX_CONFIG_UNICODE_SUPPORT && !BUSYBOX_CONFIG_UNICODE_USING_LOCALE
+ help
+ With this option on, right-to-left Unicode characters
+ are treated differently on input (e.g. cursor movement).
+
+config BUSYBOX_CONFIG_UNICODE_NEUTRAL_TABLE
+ bool "In bidi input, support non-ASCII neutral chars too"
+ default n
+ depends on BUSYBOX_CONFIG_UNICODE_BIDI_SUPPORT
+ help
+ In most cases it's enough to treat only ASCII non-letters
+ (i.e. punctuation, numbers and space) as characters
+ with neutral directionality.
+ With this option on, more extensive (and bigger) table
+ of neutral chars will be used.
+
+config BUSYBOX_CONFIG_UNICODE_PRESERVE_BROKEN
+ bool "Make it possible to enter sequences of chars which are not Unicode"
+ default n
+ depends on BUSYBOX_CONFIG_UNICODE_SUPPORT
+ help
+ With this option on, on line-editing input (such as used by shells)
+ invalid UTF-8 bytes are not substituted with the selected
+ substitution character.
+ For example, this means that entering 'l', 's', ' ', 0xff, [Enter]
+ at shell prompt will list file named 0xff (single char name
+ with char value 255), not file named '?'.
+
+config BUSYBOX_CONFIG_LONG_OPTS
+ bool "Support for --long-options"
+ default y
+ help
+ Enable this if you want busybox applets to use the gnu --long-option
+ style, in addition to single character -a -b -c style options.
+
+config BUSYBOX_CONFIG_FEATURE_DEVPTS
+ bool "Use the devpts filesystem for Unix98 PTYs"
+ default y
+ help
+ Enable if you want BusyBox to use Unix98 PTY support. If enabled,
+ busybox will use /dev/ptmx for the master side of the pseudoterminal
+ and /dev/pts/<number> for the slave side. Otherwise, BSD style
+ /dev/ttyp<number> will be used. To use this option, you should have
+ devpts mounted.
+
+config BUSYBOX_CONFIG_FEATURE_CLEAN_UP
+ bool "Clean up all memory before exiting (usually not needed)"
+ default n
+ help
+ As a size optimization, busybox normally exits without explicitly
+ freeing dynamically allocated memory or closing files. This saves
+ space since the OS will clean up for us, but it can confuse debuggers
+ like valgrind, which report tons of memory and resource leaks.
+
+ Don't enable this unless you have a really good reason to clean
+ things up manually.
+
+config BUSYBOX_CONFIG_FEATURE_UTMP
+ bool "Support utmp file"
+ default n
+ help
+ The file /var/run/utmp is used to track who is currently logged in.
+ With this option on, certain applets (getty, login, telnetd etc)
+ will create and delete entries there.
+ "who" applet requires this option.
+
+config BUSYBOX_CONFIG_FEATURE_WTMP
+ bool "Support wtmp file"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_UTMP
+ help
+ The file /var/run/wtmp is used to track when users have logged into
+ and logged out of the system.
+ With this option on, certain applets (getty, login, telnetd etc)
+ will append new entries there.
+ "last" applet requires this option.
+
+config BUSYBOX_CONFIG_FEATURE_PIDFILE
+ bool "Support writing pidfiles"
+ default y
+ help
+ This option makes some applets (e.g. crond, syslogd, inetd) write
+ a pidfile in /var/run. Some applications rely on them.
+
+config BUSYBOX_CONFIG_FEATURE_SUID
+ bool "Support for SUID/SGID handling"
+ default y
+ help
+ With this option you can install the busybox binary belonging
+ to root with the suid bit set, enabling some applets to perform
+ root-level operations even when run by ordinary users
+ (for example, mounting of user mounts in fstab needs this).
+
+ Busybox will automatically drop priviledges for applets
+ that don't need root access.
+
+ If you are really paranoid and don't want to do this, build two
+ busybox binaries with different applets in them (and the appropriate
+ symlinks pointing to each binary), and only set the suid bit on the
+ one that needs it.
+
+ The applets which require root rights (need suid bit or
+ to be run by root) and will refuse to execute otherwise:
+ crontab, login, passwd, su, vlock, wall.
+
+ The applets which will use root rights if they have them
+ (via suid bit, or because run by root), but would try to work
+ without root right nevertheless:
+ findfs, ping[6], traceroute[6], mount.
+
+ Note that if you DONT select this option, but DO make busybox
+ suid root, ALL applets will run under root, which is a huge
+ security hole (think "cp /some/file /etc/passwd").
+
+config BUSYBOX_CONFIG_FEATURE_SUID_CONFIG
+ bool "Runtime SUID/SGID configuration via /etc/busybox.conf"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_SUID
+ help
+ Allow the SUID / SGID state of an applet to be determined at runtime
+ by checking /etc/busybox.conf. (This is sort of a poor man's sudo.)
+ The format of this file is as follows:
+
+ APPLET = [Ssx-][Ssx-][x-] [USER.GROUP]
+
+ s: USER or GROUP is allowed to execute APPLET.
+ APPLET will run under USER or GROUP
+ (reagardless of who's running it).
+ S: USER or GROUP is NOT allowed to execute APPLET.
+ APPLET will run under USER or GROUP.
+ This option is not very sensical.
+ x: USER/GROUP/others are allowed to execute APPLET.
+ No UID/GID change will be done when it is run.
+ -: USER/GROUP/others are not allowed to execute APPLET.
+
+ An example might help:
+
+ [SUID]
+ su = ssx root.0 # applet su can be run by anyone and runs with
+ # euid=0/egid=0
+ su = ssx # exactly the same
+
+ mount = sx- root.disk # applet mount can be run by root and members
+ # of group disk (but not anyone else)
+ # and runs with euid=0 (egid is not changed)
+
+ cp = --- # disable applet cp for everyone
+
+ The file has to be owned by user root, group root and has to be
+ writeable only by root:
+ (chown 0.0 /etc/busybox.conf; chmod 600 /etc/busybox.conf)
+ The busybox executable has to be owned by user root, group
+ root and has to be setuid root for this to work:
+ (chown 0.0 /bin/busybox; chmod 4755 /bin/busybox)
+
+ Robert 'sandman' Griebl has more information here:
+ <url: http://www.softforge.de/bb/suid.html >.
+
+config BUSYBOX_CONFIG_FEATURE_SUID_CONFIG_QUIET
+ bool "Suppress warning message if /etc/busybox.conf is not readable"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_SUID_CONFIG
+ help
+ /etc/busybox.conf should be readable by the user needing the SUID,
+ check this option to avoid users to be notified about missing
+ permissions.
+
+config BUSYBOX_CONFIG_SELINUX
+ bool "Support NSA Security Enhanced Linux"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Enable support for SELinux in applets ls, ps, and id. Also provide
+ the option of compiling in SELinux applets.
+
+ If you do not have a complete SELinux userland installed, this stuff
+ will not compile. Go visit
+ http://www.nsa.gov/selinux/index.html
+ to download the necessary stuff to allow busybox to compile with
+ this option enabled. Specifially, libselinux 1.28 or better is
+ directly required by busybox. If the installation is located in a
+ non-standard directory, provide it by invoking make as follows:
+ CFLAGS=-I<libselinux-include-path> \
+ LDFLAGS=-L<libselinux-lib-path> \
+ make
+
+ Most people will leave this set to 'N'.
+
+config BUSYBOX_CONFIG_FEATURE_PREFER_APPLETS
+ bool "exec prefers applets"
+ default y
+ help
+ This is an experimental option which directs applets about to
+ call 'exec' to try and find an applicable busybox applet before
+ searching the PATH. This is typically done by exec'ing
+ /proc/self/exe.
+ This may affect shell, find -exec, xargs and similar applets.
+ They will use applets even if /bin/<applet> -> busybox link
+ is missing (or is not a link to busybox). However, this causes
+ problems in chroot jails without mounted /proc and with ps/top
+ (command name can be shown as 'exe' for applets started this way).
+
+config BUSYBOX_CONFIG_BUSYBOX_EXEC_PATH
+ string "Path to BusyBox executable"
+ default "/proc/self/exe"
+ help
+ When Busybox applets need to run other busybox applets, BusyBox
+ sometimes needs to exec() itself. When the /proc filesystem is
+ mounted, /proc/self/exe always points to the currently running
+ executable. If you haven't got /proc, set this to wherever you
+ want to run BusyBox from.
+
+# These are auto-selected by other options
+
+config BUSYBOX_CONFIG_FEATURE_SYSLOG
+ bool #No description makes it a hidden option
+ default y
+ #help
+ # This option is auto-selected when you select any applet which may
+ # send its output to syslog. You do not need to select it manually.
+
+config BUSYBOX_CONFIG_FEATURE_HAVE_RPC
+ bool #No description makes it a hidden option
+ default n
+ #help
+ # This is automatically selected if any of enabled applets need it.
+ # You do not need to select it manually.
+
+endmenu
+
+menu 'Build Options'
+
+config BUSYBOX_CONFIG_STATIC
+ bool "Build BusyBox as a static binary (no shared libs)"
+ default n
+ help
+ If you want to build a static BusyBox binary, which does not
+ use or require any shared libraries, then enable this option.
+ This can cause BusyBox to be considerably larger, so you should
+ leave this option false unless you have a good reason (i.e.
+ your target platform does not support shared libraries, or
+ you are building an initrd which doesn't need anything but
+ BusyBox, etc).
+
+ Most people will leave this set to 'N'.
+
+config BUSYBOX_CONFIG_PIE
+ bool "Build BusyBox as a position independent executable"
+ default n
+ depends on !BUSYBOX_CONFIG_STATIC
+ help
+ Hardened code option. PIE binaries are loaded at a different
+ address at each invocation. This has some overhead,
+ particularly on x86-32 which is short on registers.
+
+ Most people will leave this set to 'N'.
+
+config BUSYBOX_CONFIG_NOMMU
+ bool "Force NOMMU build"
+ default n
+ help
+ Busybox tries to detect whether architecture it is being
+ built against supports MMU or not. If this detection fails,
+ or if you want to build NOMMU version of busybox for testing,
+ you may force NOMMU build here.
+
+ Most people will leave this set to 'N'.
+
+# PIE can be made to work with BUILD_LIBBUSYBOX, but currently
+# build system does not support that
+config BUSYBOX_CONFIG_BUILD_LIBBUSYBOX
+ bool "Build shared libbusybox"
+ default n
+ depends on !BUSYBOX_CONFIG_FEATURE_PREFER_APPLETS && !BUSYBOX_CONFIG_PIE && !BUSYBOX_CONFIG_STATIC
+ help
+ Build a shared library libbusybox.so.N.N.N which contains all
+ busybox code.
+
+ This feature allows every applet to be built as a tiny
+ separate executable. Enabling it for "one big busybox binary"
+ approach serves no purpose and increases code size.
+ You should almost certainly say "no" to this.
+
+### config FEATURE_FULL_LIBBUSYBOX
+### bool "Feature-complete libbusybox"
+### default n if !FEATURE_SHARED_BUSYBOX
+### depends on BUILD_LIBBUSYBOX
+### help
+### Build a libbusybox with the complete feature-set, disregarding
+### the actually selected config.
+###
+### Normally, libbusybox will only contain the features which are
+### used by busybox itself. If you plan to write a separate
+### standalone application which uses libbusybox say 'Y'.
+###
+### Note: libbusybox is GPL, not LGPL, and exports no stable API that
+### might act as a copyright barrier. We can and will modify the
+### exported function set between releases (even minor version number
+### changes), and happily break out-of-tree features.
+###
+### Say 'N' if in doubt.
+
+config BUSYBOX_CONFIG_FEATURE_INDIVIDUAL
+ bool "Produce a binary for each applet, linked against libbusybox"
+ default n
+ depends on BUSYBOX_CONFIG_BUILD_LIBBUSYBOX
+ help
+ If your CPU architecture doesn't allow for sharing text/rodata
+ sections of running binaries, but allows for runtime dynamic
+ libraries, this option will allow you to reduce memory footprint
+ when you have many different applets running at once.
+
+ If your CPU architecture allows for sharing text/rodata,
+ having single binary is more optimal.
+
+ Each applet will be a tiny program, dynamically linked
+ against libbusybox.so.N.N.N.
+
+ You need to have a working dynamic linker.
+
+config BUSYBOX_CONFIG_FEATURE_SHARED_BUSYBOX
+ bool "Produce additional busybox binary linked against libbusybox"
+ default n
+ depends on BUSYBOX_CONFIG_BUILD_LIBBUSYBOX
+ help
+ Build busybox, dynamically linked against libbusybox.so.N.N.N.
+
+ You need to have a working dynamic linker.
+
+### config BUILD_AT_ONCE
+### bool "Compile all sources at once"
+### default n
+### help
+### Normally each source-file is compiled with one invocation of
+### the compiler.
+### If you set this option, all sources are compiled at once.
+### This gives the compiler more opportunities to optimize which can
+### result in smaller and/or faster binaries.
+###
+### Setting this option will consume alot of memory, e.g. if you
+### enable all applets with all features, gcc uses more than 300MB
+### RAM during compilation of busybox.
+###
+### This option is most likely only beneficial for newer compilers
+### such as gcc-4.1 and above.
+###
+### Say 'N' unless you know what you are doing.
+
+config BUSYBOX_CONFIG_LFS
+ bool
+ default y
+ help
+ If you want to build BusyBox with large file support, then enable
+ this option. This will have no effect if your kernel or your C
+ library lacks large file support for large files. Some of the
+ programs that can benefit from large file support include dd, gzip,
+ cp, mount, tar, and many others. If you want to access files larger
+ than 2 Gigabytes, enable this option. Otherwise, leave it set to 'N'.
+
+config BUSYBOX_CONFIG_CROSS_COMPILER_PREFIX
+ string "Cross Compiler prefix"
+ default ""
+ help
+ If you want to build BusyBox with a cross compiler, then you
+ will need to set this to the cross-compiler prefix, for example,
+ "i386-uclibc-".
+
+ Note that CROSS_COMPILE environment variable or
+ "make CROSS_COMPILE=xxx ..." will override this selection.
+
+ Native builds leave this empty.
+
+config BUSYBOX_CONFIG_EXTRA_CFLAGS
+ string "Additional CFLAGS"
+ default ""
+ help
+ Additional CFLAGS to pass to the compiler verbatim.
+
+endmenu
+
+menu 'Debugging Options'
+
+config BUSYBOX_CONFIG_DEBUG
+ bool "Build BusyBox with extra Debugging symbols"
+ default n
+ help
+ Say Y here if you wish to examine BusyBox internals while applets are
+ running. This increases the size of the binary considerably, and
+ should only be used when doing development. If you are doing
+ development and want to debug BusyBox, answer Y.
+
+ Most people should answer N.
+
+config BUSYBOX_CONFIG_DEBUG_PESSIMIZE
+ bool "Disable compiler optimizations"
+ default n
+ depends on BUSYBOX_CONFIG_DEBUG
+ help
+ The compiler's optimization of source code can eliminate and reorder
+ code, resulting in an executable that's hard to understand when
+ stepping through it with a debugger. This switches it off, resulting
+ in a much bigger executable that more closely matches the source
+ code.
+
+config BUSYBOX_CONFIG_WERROR
+ bool "Abort compilation on any warning"
+ default n
+ help
+ Selecting this will add -Werror to gcc command line.
+
+ Most people should answer N.
+
+choice
+ prompt "Additional debugging library"
+ default BUSYBOX_CONFIG_NO_DEBUG_LIB
+ help
+ Using an additional debugging library will make BusyBox become
+ considerable larger and will cause it to run more slowly. You
+ should always leave this option disabled for production use.
+
+ dmalloc support:
+ ----------------
+ This enables compiling with dmalloc ( http://dmalloc.com/ )
+ which is an excellent public domain mem leak and malloc problem
+ detector. To enable dmalloc, before running busybox you will
+ want to properly set your environment, for example:
+ export DMALLOC_OPTIONS=debug=0x34f47d83,inter=100,log=logfile
+ The 'debug=' value is generated using the following command
+ dmalloc -p log-stats -p log-non-free -p log-bad-space \
+ -p log-elapsed-time -p check-fence -p check-heap \
+ -p check-lists -p check-blank -p check-funcs -p realloc-copy \
+ -p allow-free-null
+
+ Electric-fence support:
+ -----------------------
+ This enables compiling with Electric-fence support. Electric
+ fence is another very useful malloc debugging library which uses
+ your computer's virtual memory hardware to detect illegal memory
+ accesses. This support will make BusyBox be considerable larger
+ and run slower, so you should leave this option disabled unless
+ you are hunting a hard to find memory problem.
+
+
+config BUSYBOX_CONFIG_NO_DEBUG_LIB
+ bool "None"
+
+config BUSYBOX_CONFIG_DMALLOC
+ bool "Dmalloc"
+
+config BUSYBOX_CONFIG_EFENCE
+ bool "Electric-fence"
+
+endchoice
+
+endmenu
+
+menu 'Installation Options ("make install" behavior)'
+
+choice
+ prompt "What kind of applet links to install"
+ default BUSYBOX_CONFIG_INSTALL_APPLET_SYMLINKS
+ help
+ Choose what kind of links to applets are created by "make install".
+
+config BUSYBOX_CONFIG_INSTALL_APPLET_SYMLINKS
+ bool "as soft-links"
+ help
+ Install applets as soft-links to the busybox binary. This needs some
+ free inodes on the filesystem, but might help with filesystem
+ generators that can't cope with hard-links.
+
+config BUSYBOX_CONFIG_INSTALL_APPLET_HARDLINKS
+ bool "as hard-links"
+ help
+ Install applets as hard-links to the busybox binary. This might
+ count on a filesystem with few inodes.
+
+config BUSYBOX_CONFIG_INSTALL_APPLET_SCRIPT_WRAPPERS
+ bool "as script wrappers"
+ help
+ Install applets as script wrappers that call the busybox binary.
+
+config BUSYBOX_CONFIG_INSTALL_APPLET_DONT
+ bool "not installed"
+ help
+ Do not install applet links. Useful when you plan to use
+ busybox --install for installing links, or plan to use
+ a standalone shell and thus don't need applet links.
+
+endchoice
+
+choice
+ prompt "/bin/sh applet link"
+ default BUSYBOX_CONFIG_INSTALL_SH_APPLET_SYMLINK
+ depends on BUSYBOX_CONFIG_INSTALL_APPLET_SCRIPT_WRAPPERS
+ help
+ Choose how you install /bin/sh applet link.
+
+config BUSYBOX_CONFIG_INSTALL_SH_APPLET_SYMLINK
+ bool "as soft-link"
+ help
+ Install /bin/sh applet as soft-link to the busybox binary.
+
+config BUSYBOX_CONFIG_INSTALL_SH_APPLET_HARDLINK
+ bool "as hard-link"
+ help
+ Install /bin/sh applet as hard-link to the busybox binary.
+
+config BUSYBOX_CONFIG_INSTALL_SH_APPLET_SCRIPT_WRAPPER
+ bool "as script wrapper"
+ help
+ Install /bin/sh applet as script wrapper that calls
+ the busybox binary.
+
+endchoice
+
+config BUSYBOX_CONFIG_PREFIX
+ string "BusyBox installation prefix"
+ default "./_install"
+ help
+ Define your directory to install BusyBox files/subdirs in.
+
+endmenu
+
+source package/busybox/config/libbb/Config.in
+
+endmenu
+
+comment "Applets"
+
+source package/busybox/config/archival/Config.in
+source package/busybox/config/coreutils/Config.in
+source package/busybox/config/console-tools/Config.in
+source package/busybox/config/debianutils/Config.in
+source package/busybox/config/editors/Config.in
+source package/busybox/config/findutils/Config.in
+source package/busybox/config/init/Config.in
+source package/busybox/config/loginutils/Config.in
+source package/busybox/config/e2fsprogs/Config.in
+source package/busybox/config/modutils/Config.in
+source package/busybox/config/util-linux/Config.in
+source package/busybox/config/miscutils/Config.in
+source package/busybox/config/networking/Config.in
+source package/busybox/config/printutils/Config.in
+source package/busybox/config/mailutils/Config.in
+source package/busybox/config/procps/Config.in
+source package/busybox/config/runit/Config.in
+source package/busybox/config/selinux/Config.in
+source package/busybox/config/shell/Config.in
+source package/busybox/config/sysklogd/Config.in
diff --git a/package/busybox/config/Config.in b/package/busybox/config/Config.in
new file mode 100644
index 0000000..0045036
--- /dev/null
+++ b/package/busybox/config/Config.in
@@ -0,0 +1,778 @@
+#
+# For a description of the syntax of this configuration file,
+# see scripts/kbuild/config-language.txt.
+#
+
+
+config BUSYBOX_CONFIG_HAVE_DOT_CONFIG
+ bool
+ default y
+
+menu "Busybox Settings"
+
+menu "General Configuration"
+
+config BUSYBOX_CONFIG_DESKTOP
+ bool "Enable options for full-blown desktop systems"
+ default n
+ help
+ Enable options and features which are not essential.
+ Select this only if you plan to use busybox on full-blown
+ desktop machine with common Linux distro, not on an embedded box.
+
+config BUSYBOX_CONFIG_EXTRA_COMPAT
+ bool "Provide compatible behavior for rare corner cases (bigger code)"
+ default n
+ help
+ This option makes grep, sed etc handle rare corner cases
+ (embedded NUL bytes and such). This makes code bigger and uses
+ some GNU extensions in libc. You probably only need this option
+ if you plan to run busybox on desktop.
+
+config BUSYBOX_CONFIG_INCLUDE_SUSv2
+ bool "Enable obsolete features removed before SUSv3"
+ default y
+ help
+ This option will enable backwards compatibility with SuSv2,
+ specifically, old-style numeric options ('command -1 <file>')
+ will be supported in head, tail, and fold. (Note: should
+ affect renice too.)
+
+config BUSYBOX_CONFIG_USE_PORTABLE_CODE
+ bool "Avoid using GCC-specific code constructs"
+ default n
+ help
+ Use this option if you are trying to compile busybox with
+ compiler other than gcc.
+ If you do use gcc, this option may needlessly increase code size.
+
+config BUSYBOX_CONFIG_PLATFORM_LINUX
+ bool "Enable Linux-specific applets and features"
+ default y
+ help
+ For the most part, busybox requires only POSIX compatibility
+ from the target system, but some applets and features use
+ Linux-specific interfaces.
+
+ Answering 'N' here will disable such applets and hide the
+ corresponding configuration options.
+
+choice
+ prompt "Buffer allocation policy"
+ default BUSYBOX_CONFIG_FEATURE_BUFFERS_GO_ON_STACK
+ help
+ There are 3 ways BusyBox can handle buffer allocations:
+ - Use malloc. This costs code size for the call to xmalloc.
+ - Put them on stack. For some very small machines with limited stack
+ space, this can be deadly. For most folks, this works just fine.
+ - Put them in BSS. This works beautifully for computers with a real
+ MMU (and OS support), but wastes runtime RAM for uCLinux. This
+ behavior was the only one available for BusyBox versions 0.48 and
+ earlier.
+
+config BUSYBOX_CONFIG_FEATURE_BUFFERS_USE_MALLOC
+ bool "Allocate with Malloc"
+
+config BUSYBOX_CONFIG_FEATURE_BUFFERS_GO_ON_STACK
+ bool "Allocate on the Stack"
+
+config BUSYBOX_CONFIG_FEATURE_BUFFERS_GO_IN_BSS
+ bool "Allocate in the .bss section"
+
+endchoice
+
+config BUSYBOX_CONFIG_SHOW_USAGE
+ bool "Show terse applet usage messages"
+ default y
+ help
+ All BusyBox applets will show help messages when invoked with
+ wrong arguments. You can turn off printing these terse usage
+ messages if you say no here.
+ This will save you up to 7k.
+
+config BUSYBOX_CONFIG_FEATURE_VERBOSE_USAGE
+ bool "Show verbose applet usage messages"
+ default y
+ depends on BUSYBOX_CONFIG_SHOW_USAGE
+ help
+ All BusyBox applets will show more verbose help messages when
+ busybox is invoked with --help. This will add a lot of text to the
+ busybox binary. In the default configuration, this will add about
+ 13k, but it can add much more depending on your configuration.
+
+config BUSYBOX_CONFIG_FEATURE_COMPRESS_USAGE
+ bool "Store applet usage messages in compressed form"
+ default y
+ depends on BUSYBOX_CONFIG_SHOW_USAGE
+ help
+ Store usage messages in compressed form, uncompress them on-the-fly
+ when <applet> --help is called.
+
+ If you have a really tiny busybox with few applets enabled (and
+ bunzip2 isn't one of them), the overhead of the decompressor might
+ be noticeable. Also, if you run executables directly from ROM
+ and have very little memory, this might not be a win. Otherwise,
+ you probably want this.
+
+config BUSYBOX_CONFIG_FEATURE_INSTALLER
+ bool "Support --install [-s] to install applet links at runtime"
+ default n
+ help
+ Enable 'busybox --install [-s]' support. This will allow you to use
+ busybox at runtime to create hard links or symlinks for all the
+ applets that are compiled into busybox.
+
+config BUSYBOX_CONFIG_INSTALL_NO_USR
+ bool "Don't use /usr"
+ default n
+ help
+ Disable use of /usr. busybox --install and "make install"
+ will install applets only to /bin and /sbin,
+ never to /usr/bin or /usr/sbin.
+
+config BUSYBOX_CONFIG_LOCALE_SUPPORT
+ bool "Enable locale support (system needs locale for this to work)"
+ default n
+ help
+ Enable this if your system has locale support and you would like
+ busybox to support locale settings.
+
+config BUSYBOX_CONFIG_UNICODE_SUPPORT
+ bool "Support Unicode"
+ default n
+ help
+ This makes various applets aware that one byte is not
+ one character on screen.
+
+ Busybox aims to eventually work correctly with Unicode displays.
+ Any older encodings are not guaranteed to work.
+ Probably by the time when busybox will be fully Unicode-clean,
+ other encodings will be mainly of historic interest.
+
+config BUSYBOX_CONFIG_UNICODE_USING_LOCALE
+ bool "Use libc routines for Unicode (else uses internal ones)"
+ default n
+ depends on BUSYBOX_CONFIG_UNICODE_SUPPORT && BUSYBOX_CONFIG_LOCALE_SUPPORT
+ help
+ With this option on, Unicode support is implemented using libc
+ routines. Otherwise, internal implementation is used.
+ Internal implementation is smaller.
+
+config BUSYBOX_CONFIG_FEATURE_CHECK_UNICODE_IN_ENV
+ bool "Check $LANG environment variable"
+ default n
+ depends on BUSYBOX_CONFIG_UNICODE_SUPPORT && !BUSYBOX_CONFIG_UNICODE_USING_LOCALE
+ help
+ With this option on, Unicode support is activated
+ only if LANG variable has the value of the form "xxxx.utf8"
+
+ Otherwise, Unicode support will be always enabled and active.
+
+config BUSYBOX_CONFIG_SUBST_WCHAR
+ int "Character code to substitute unprintable characters with"
+ depends on BUSYBOX_CONFIG_UNICODE_SUPPORT
+ default 63
+ help
+ Typical values are 63 for '?' (works with any output device),
+ 30 for ASCII substitute control code,
+ 65533 (0xfffd) for Unicode replacement character.
+
+config BUSYBOX_CONFIG_LAST_SUPPORTED_WCHAR
+ int "Range of supported Unicode characters"
+ depends on BUSYBOX_CONFIG_UNICODE_SUPPORT
+ default 767
+ help
+ Any character with Unicode value bigger than this is assumed
+ to be non-printable on output device. Many applets replace
+ such chars with substitution character.
+
+ The idea is that many valid printable Unicode chars are
+ nevertheless are not displayed correctly. Think about
+ combining charachers, double-wide hieroglyphs, obscure
+ characters in dozens of ancient scripts...
+ Many terminals, terminal emulators, xterms etc will fail
+ to handle them correctly. Choose the smallest value
+ which suits your needs.
+
+ Typical values are:
+ 126 - ASCII only
+ 767 (0x2ff) - there are no combining chars in [0..767] range
+ (the range includes Latin 1, Latin Ext. A and B),
+ code is ~700 bytes smaller for this case.
+ 4351 (0x10ff) - there are no double-wide chars in [0..4351] range,
+ code is ~300 bytes smaller for this case.
+ 12799 (0x31ff) - nearly all non-ideographic characters are
+ available in [0..12799] range, including
+ East Asian scripts like katakana, hiragana, hangul,
+ bopomofo...
+ 0 - off, any valid printable Unicode character will be printed.
+
+config BUSYBOX_CONFIG_UNICODE_COMBINING_WCHARS
+ bool "Allow zero-width Unicode characters on output"
+ default n
+ depends on BUSYBOX_CONFIG_UNICODE_SUPPORT
+ help
+ With this option off, any Unicode char with width of 0
+ is substituted on output.
+
+config BUSYBOX_CONFIG_UNICODE_WIDE_WCHARS
+ bool "Allow wide Unicode characters on output"
+ default n
+ depends on BUSYBOX_CONFIG_UNICODE_SUPPORT
+ help
+ With this option off, any Unicode char with width > 1
+ is substituted on output.
+
+config BUSYBOX_CONFIG_UNICODE_BIDI_SUPPORT
+ bool "Bidirectional character-aware line input"
+ default n
+ depends on BUSYBOX_CONFIG_UNICODE_SUPPORT && !BUSYBOX_CONFIG_UNICODE_USING_LOCALE
+ help
+ With this option on, right-to-left Unicode characters
+ are treated differently on input (e.g. cursor movement).
+
+config BUSYBOX_CONFIG_UNICODE_NEUTRAL_TABLE
+ bool "In bidi input, support non-ASCII neutral chars too"
+ default n
+ depends on BUSYBOX_CONFIG_UNICODE_BIDI_SUPPORT
+ help
+ In most cases it's enough to treat only ASCII non-letters
+ (i.e. punctuation, numbers and space) as characters
+ with neutral directionality.
+ With this option on, more extensive (and bigger) table
+ of neutral chars will be used.
+
+config BUSYBOX_CONFIG_UNICODE_PRESERVE_BROKEN
+ bool "Make it possible to enter sequences of chars which are not Unicode"
+ default n
+ depends on BUSYBOX_CONFIG_UNICODE_SUPPORT
+ help
+ With this option on, on line-editing input (such as used by shells)
+ invalid UTF-8 bytes are not substituted with the selected
+ substitution character.
+ For example, this means that entering 'l', 's', ' ', 0xff, [Enter]
+ at shell prompt will list file named 0xff (single char name
+ with char value 255), not file named '?'.
+
+config BUSYBOX_CONFIG_LONG_OPTS
+ bool "Support for --long-options"
+ default y
+ help
+ Enable this if you want busybox applets to use the gnu --long-option
+ style, in addition to single character -a -b -c style options.
+
+config BUSYBOX_CONFIG_FEATURE_DEVPTS
+ bool "Use the devpts filesystem for Unix98 PTYs"
+ default y
+ help
+ Enable if you want BusyBox to use Unix98 PTY support. If enabled,
+ busybox will use /dev/ptmx for the master side of the pseudoterminal
+ and /dev/pts/<number> for the slave side. Otherwise, BSD style
+ /dev/ttyp<number> will be used. To use this option, you should have
+ devpts mounted.
+
+config BUSYBOX_CONFIG_FEATURE_CLEAN_UP
+ bool "Clean up all memory before exiting (usually not needed)"
+ default n
+ help
+ As a size optimization, busybox normally exits without explicitly
+ freeing dynamically allocated memory or closing files. This saves
+ space since the OS will clean up for us, but it can confuse debuggers
+ like valgrind, which report tons of memory and resource leaks.
+
+ Don't enable this unless you have a really good reason to clean
+ things up manually.
+
+config BUSYBOX_CONFIG_FEATURE_UTMP
+ bool "Support utmp file"
+ default n
+ help
+ The file /var/run/utmp is used to track who is currently logged in.
+ With this option on, certain applets (getty, login, telnetd etc)
+ will create and delete entries there.
+ "who" applet requires this option.
+
+config BUSYBOX_CONFIG_FEATURE_WTMP
+ bool "Support wtmp file"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_UTMP
+ help
+ The file /var/run/wtmp is used to track when users have logged into
+ and logged out of the system.
+ With this option on, certain applets (getty, login, telnetd etc)
+ will append new entries there.
+ "last" applet requires this option.
+
+config BUSYBOX_CONFIG_FEATURE_PIDFILE
+ bool "Support writing pidfiles"
+ default y
+ help
+ This option makes some applets (e.g. crond, syslogd, inetd) write
+ a pidfile in /var/run. Some applications rely on them.
+
+config BUSYBOX_CONFIG_FEATURE_SUID
+ bool "Support for SUID/SGID handling"
+ default y
+ help
+ With this option you can install the busybox binary belonging
+ to root with the suid bit set, enabling some applets to perform
+ root-level operations even when run by ordinary users
+ (for example, mounting of user mounts in fstab needs this).
+
+ Busybox will automatically drop priviledges for applets
+ that don't need root access.
+
+ If you are really paranoid and don't want to do this, build two
+ busybox binaries with different applets in them (and the appropriate
+ symlinks pointing to each binary), and only set the suid bit on the
+ one that needs it.
+
+ The applets which require root rights (need suid bit or
+ to be run by root) and will refuse to execute otherwise:
+ crontab, login, passwd, su, vlock, wall.
+
+ The applets which will use root rights if they have them
+ (via suid bit, or because run by root), but would try to work
+ without root right nevertheless:
+ findfs, ping[6], traceroute[6], mount.
+
+ Note that if you DONT select this option, but DO make busybox
+ suid root, ALL applets will run under root, which is a huge
+ security hole (think "cp /some/file /etc/passwd").
+
+config BUSYBOX_CONFIG_FEATURE_SUID_CONFIG
+ bool "Runtime SUID/SGID configuration via /etc/busybox.conf"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_SUID
+ help
+ Allow the SUID / SGID state of an applet to be determined at runtime
+ by checking /etc/busybox.conf. (This is sort of a poor man's sudo.)
+ The format of this file is as follows:
+
+ APPLET = [Ssx-][Ssx-][x-] [USER.GROUP]
+
+ s: USER or GROUP is allowed to execute APPLET.
+ APPLET will run under USER or GROUP
+ (reagardless of who's running it).
+ S: USER or GROUP is NOT allowed to execute APPLET.
+ APPLET will run under USER or GROUP.
+ This option is not very sensical.
+ x: USER/GROUP/others are allowed to execute APPLET.
+ No UID/GID change will be done when it is run.
+ -: USER/GROUP/others are not allowed to execute APPLET.
+
+ An example might help:
+
+ [SUID]
+ su = ssx root.0 # applet su can be run by anyone and runs with
+ # euid=0/egid=0
+ su = ssx # exactly the same
+
+ mount = sx- root.disk # applet mount can be run by root and members
+ # of group disk (but not anyone else)
+ # and runs with euid=0 (egid is not changed)
+
+ cp = --- # disable applet cp for everyone
+
+ The file has to be owned by user root, group root and has to be
+ writeable only by root:
+ (chown 0.0 /etc/busybox.conf; chmod 600 /etc/busybox.conf)
+ The busybox executable has to be owned by user root, group
+ root and has to be setuid root for this to work:
+ (chown 0.0 /bin/busybox; chmod 4755 /bin/busybox)
+
+ Robert 'sandman' Griebl has more information here:
+ <url: http://www.softforge.de/bb/suid.html >.
+
+config BUSYBOX_CONFIG_FEATURE_SUID_CONFIG_QUIET
+ bool "Suppress warning message if /etc/busybox.conf is not readable"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_SUID_CONFIG
+ help
+ /etc/busybox.conf should be readable by the user needing the SUID,
+ check this option to avoid users to be notified about missing
+ permissions.
+
+config BUSYBOX_CONFIG_SELINUX
+ bool "Support NSA Security Enhanced Linux"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Enable support for SELinux in applets ls, ps, and id. Also provide
+ the option of compiling in SELinux applets.
+
+ If you do not have a complete SELinux userland installed, this stuff
+ will not compile. Go visit
+ http://www.nsa.gov/selinux/index.html
+ to download the necessary stuff to allow busybox to compile with
+ this option enabled. Specifially, libselinux 1.28 or better is
+ directly required by busybox. If the installation is located in a
+ non-standard directory, provide it by invoking make as follows:
+ CFLAGS=-I<libselinux-include-path> \
+ LDFLAGS=-L<libselinux-lib-path> \
+ make
+
+ Most people will leave this set to 'N'.
+
+config BUSYBOX_CONFIG_FEATURE_PREFER_APPLETS
+ bool "exec prefers applets"
+ default y
+ help
+ This is an experimental option which directs applets about to
+ call 'exec' to try and find an applicable busybox applet before
+ searching the PATH. This is typically done by exec'ing
+ /proc/self/exe.
+ This may affect shell, find -exec, xargs and similar applets.
+ They will use applets even if /bin/<applet> -> busybox link
+ is missing (or is not a link to busybox). However, this causes
+ problems in chroot jails without mounted /proc and with ps/top
+ (command name can be shown as 'exe' for applets started this way).
+
+config BUSYBOX_CONFIG_BUSYBOX_EXEC_PATH
+ string "Path to BusyBox executable"
+ default "/proc/self/exe"
+ help
+ When Busybox applets need to run other busybox applets, BusyBox
+ sometimes needs to exec() itself. When the /proc filesystem is
+ mounted, /proc/self/exe always points to the currently running
+ executable. If you haven't got /proc, set this to wherever you
+ want to run BusyBox from.
+
+# These are auto-selected by other options
+
+config BUSYBOX_CONFIG_FEATURE_SYSLOG
+ bool #No description makes it a hidden option
+ default y
+ #help
+ # This option is auto-selected when you select any applet which may
+ # send its output to syslog. You do not need to select it manually.
+
+config BUSYBOX_CONFIG_FEATURE_HAVE_RPC
+ bool #No description makes it a hidden option
+ default n
+ #help
+ # This is automatically selected if any of enabled applets need it.
+ # You do not need to select it manually.
+
+endmenu
+
+menu 'Build Options'
+
+config BUSYBOX_CONFIG_STATIC
+ bool "Build BusyBox as a static binary (no shared libs)"
+ default n
+ help
+ If you want to build a static BusyBox binary, which does not
+ use or require any shared libraries, then enable this option.
+ This can cause BusyBox to be considerably larger, so you should
+ leave this option false unless you have a good reason (i.e.
+ your target platform does not support shared libraries, or
+ you are building an initrd which doesn't need anything but
+ BusyBox, etc).
+
+ Most people will leave this set to 'N'.
+
+config BUSYBOX_CONFIG_PIE
+ bool "Build BusyBox as a position independent executable"
+ default n
+ depends on !BUSYBOX_CONFIG_STATIC
+ help
+ Hardened code option. PIE binaries are loaded at a different
+ address at each invocation. This has some overhead,
+ particularly on x86-32 which is short on registers.
+
+ Most people will leave this set to 'N'.
+
+config BUSYBOX_CONFIG_NOMMU
+ bool "Force NOMMU build"
+ default n
+ help
+ Busybox tries to detect whether architecture it is being
+ built against supports MMU or not. If this detection fails,
+ or if you want to build NOMMU version of busybox for testing,
+ you may force NOMMU build here.
+
+ Most people will leave this set to 'N'.
+
+# PIE can be made to work with BUILD_LIBBUSYBOX, but currently
+# build system does not support that
+config BUSYBOX_CONFIG_BUILD_LIBBUSYBOX
+ bool "Build shared libbusybox"
+ default n
+ depends on !BUSYBOX_CONFIG_FEATURE_PREFER_APPLETS && !BUSYBOX_CONFIG_PIE && !BUSYBOX_CONFIG_STATIC
+ help
+ Build a shared library libbusybox.so.N.N.N which contains all
+ busybox code.
+
+ This feature allows every applet to be built as a tiny
+ separate executable. Enabling it for "one big busybox binary"
+ approach serves no purpose and increases code size.
+ You should almost certainly say "no" to this.
+
+### config FEATURE_FULL_LIBBUSYBOX
+### bool "Feature-complete libbusybox"
+### default n if !FEATURE_SHARED_BUSYBOX
+### depends on BUILD_LIBBUSYBOX
+### help
+### Build a libbusybox with the complete feature-set, disregarding
+### the actually selected config.
+###
+### Normally, libbusybox will only contain the features which are
+### used by busybox itself. If you plan to write a separate
+### standalone application which uses libbusybox say 'Y'.
+###
+### Note: libbusybox is GPL, not LGPL, and exports no stable API that
+### might act as a copyright barrier. We can and will modify the
+### exported function set between releases (even minor version number
+### changes), and happily break out-of-tree features.
+###
+### Say 'N' if in doubt.
+
+config BUSYBOX_CONFIG_FEATURE_INDIVIDUAL
+ bool "Produce a binary for each applet, linked against libbusybox"
+ default n
+ depends on BUSYBOX_CONFIG_BUILD_LIBBUSYBOX
+ help
+ If your CPU architecture doesn't allow for sharing text/rodata
+ sections of running binaries, but allows for runtime dynamic
+ libraries, this option will allow you to reduce memory footprint
+ when you have many different applets running at once.
+
+ If your CPU architecture allows for sharing text/rodata,
+ having single binary is more optimal.
+
+ Each applet will be a tiny program, dynamically linked
+ against libbusybox.so.N.N.N.
+
+ You need to have a working dynamic linker.
+
+config BUSYBOX_CONFIG_FEATURE_SHARED_BUSYBOX
+ bool "Produce additional busybox binary linked against libbusybox"
+ default n
+ depends on BUSYBOX_CONFIG_BUILD_LIBBUSYBOX
+ help
+ Build busybox, dynamically linked against libbusybox.so.N.N.N.
+
+ You need to have a working dynamic linker.
+
+### config BUILD_AT_ONCE
+### bool "Compile all sources at once"
+### default n
+### help
+### Normally each source-file is compiled with one invocation of
+### the compiler.
+### If you set this option, all sources are compiled at once.
+### This gives the compiler more opportunities to optimize which can
+### result in smaller and/or faster binaries.
+###
+### Setting this option will consume alot of memory, e.g. if you
+### enable all applets with all features, gcc uses more than 300MB
+### RAM during compilation of busybox.
+###
+### This option is most likely only beneficial for newer compilers
+### such as gcc-4.1 and above.
+###
+### Say 'N' unless you know what you are doing.
+
+config BUSYBOX_CONFIG_LFS
+ bool
+ default y
+ help
+ If you want to build BusyBox with large file support, then enable
+ this option. This will have no effect if your kernel or your C
+ library lacks large file support for large files. Some of the
+ programs that can benefit from large file support include dd, gzip,
+ cp, mount, tar, and many others. If you want to access files larger
+ than 2 Gigabytes, enable this option. Otherwise, leave it set to 'N'.
+
+config BUSYBOX_CONFIG_CROSS_COMPILER_PREFIX
+ string "Cross Compiler prefix"
+ default ""
+ help
+ If you want to build BusyBox with a cross compiler, then you
+ will need to set this to the cross-compiler prefix, for example,
+ "i386-uclibc-".
+
+ Note that CROSS_COMPILE environment variable or
+ "make CROSS_COMPILE=xxx ..." will override this selection.
+
+ Native builds leave this empty.
+
+config BUSYBOX_CONFIG_EXTRA_CFLAGS
+ string "Additional CFLAGS"
+ default ""
+ help
+ Additional CFLAGS to pass to the compiler verbatim.
+
+endmenu
+
+menu 'Debugging Options'
+
+config BUSYBOX_CONFIG_DEBUG
+ bool "Build BusyBox with extra Debugging symbols"
+ default n
+ help
+ Say Y here if you wish to examine BusyBox internals while applets are
+ running. This increases the size of the binary considerably, and
+ should only be used when doing development. If you are doing
+ development and want to debug BusyBox, answer Y.
+
+ Most people should answer N.
+
+config BUSYBOX_CONFIG_DEBUG_PESSIMIZE
+ bool "Disable compiler optimizations"
+ default n
+ depends on BUSYBOX_CONFIG_DEBUG
+ help
+ The compiler's optimization of source code can eliminate and reorder
+ code, resulting in an executable that's hard to understand when
+ stepping through it with a debugger. This switches it off, resulting
+ in a much bigger executable that more closely matches the source
+ code.
+
+config BUSYBOX_CONFIG_WERROR
+ bool "Abort compilation on any warning"
+ default n
+ help
+ Selecting this will add -Werror to gcc command line.
+
+ Most people should answer N.
+
+choice
+ prompt "Additional debugging library"
+ default BUSYBOX_CONFIG_NO_DEBUG_LIB
+ help
+ Using an additional debugging library will make BusyBox become
+ considerable larger and will cause it to run more slowly. You
+ should always leave this option disabled for production use.
+
+ dmalloc support:
+ ----------------
+ This enables compiling with dmalloc ( http://dmalloc.com/ )
+ which is an excellent public domain mem leak and malloc problem
+ detector. To enable dmalloc, before running busybox you will
+ want to properly set your environment, for example:
+ export DMALLOC_OPTIONS=debug=0x34f47d83,inter=100,log=logfile
+ The 'debug=' value is generated using the following command
+ dmalloc -p log-stats -p log-non-free -p log-bad-space \
+ -p log-elapsed-time -p check-fence -p check-heap \
+ -p check-lists -p check-blank -p check-funcs -p realloc-copy \
+ -p allow-free-null
+
+ Electric-fence support:
+ -----------------------
+ This enables compiling with Electric-fence support. Electric
+ fence is another very useful malloc debugging library which uses
+ your computer's virtual memory hardware to detect illegal memory
+ accesses. This support will make BusyBox be considerable larger
+ and run slower, so you should leave this option disabled unless
+ you are hunting a hard to find memory problem.
+
+
+config BUSYBOX_CONFIG_NO_DEBUG_LIB
+ bool "None"
+
+config BUSYBOX_CONFIG_DMALLOC
+ bool "Dmalloc"
+
+config BUSYBOX_CONFIG_EFENCE
+ bool "Electric-fence"
+
+endchoice
+
+endmenu
+
+menu 'Installation Options ("make install" behavior)'
+
+choice
+ prompt "What kind of applet links to install"
+ default BUSYBOX_CONFIG_INSTALL_APPLET_SYMLINKS
+ help
+ Choose what kind of links to applets are created by "make install".
+
+config BUSYBOX_CONFIG_INSTALL_APPLET_SYMLINKS
+ bool "as soft-links"
+ help
+ Install applets as soft-links to the busybox binary. This needs some
+ free inodes on the filesystem, but might help with filesystem
+ generators that can't cope with hard-links.
+
+config BUSYBOX_CONFIG_INSTALL_APPLET_HARDLINKS
+ bool "as hard-links"
+ help
+ Install applets as hard-links to the busybox binary. This might
+ count on a filesystem with few inodes.
+
+config BUSYBOX_CONFIG_INSTALL_APPLET_SCRIPT_WRAPPERS
+ bool "as script wrappers"
+ help
+ Install applets as script wrappers that call the busybox binary.
+
+config BUSYBOX_CONFIG_INSTALL_APPLET_DONT
+ bool "not installed"
+ help
+ Do not install applet links. Useful when you plan to use
+ busybox --install for installing links, or plan to use
+ a standalone shell and thus don't need applet links.
+
+endchoice
+
+choice
+ prompt "/bin/sh applet link"
+ default BUSYBOX_CONFIG_INSTALL_SH_APPLET_SYMLINK
+ depends on BUSYBOX_CONFIG_INSTALL_APPLET_SCRIPT_WRAPPERS
+ help
+ Choose how you install /bin/sh applet link.
+
+config BUSYBOX_CONFIG_INSTALL_SH_APPLET_SYMLINK
+ bool "as soft-link"
+ help
+ Install /bin/sh applet as soft-link to the busybox binary.
+
+config BUSYBOX_CONFIG_INSTALL_SH_APPLET_HARDLINK
+ bool "as hard-link"
+ help
+ Install /bin/sh applet as hard-link to the busybox binary.
+
+config BUSYBOX_CONFIG_INSTALL_SH_APPLET_SCRIPT_WRAPPER
+ bool "as script wrapper"
+ help
+ Install /bin/sh applet as script wrapper that calls
+ the busybox binary.
+
+endchoice
+
+config BUSYBOX_CONFIG_PREFIX
+ string "BusyBox installation prefix"
+ default "./_install"
+ help
+ Define your directory to install BusyBox files/subdirs in.
+
+endmenu
+
+source package/busybox/config/libbb/Config.in
+
+endmenu
+
+comment "Applets"
+
+source package/busybox/config/archival/Config.in
+source package/busybox/config/coreutils/Config.in
+source package/busybox/config/console-tools/Config.in
+source package/busybox/config/debianutils/Config.in
+source package/busybox/config/editors/Config.in
+source package/busybox/config/findutils/Config.in
+source package/busybox/config/init/Config.in
+source package/busybox/config/loginutils/Config.in
+source package/busybox/config/e2fsprogs/Config.in
+source package/busybox/config/modutils/Config.in
+source package/busybox/config/util-linux/Config.in
+source package/busybox/config/miscutils/Config.in
+source package/busybox/config/networking/Config.in
+source package/busybox/config/printutils/Config.in
+source package/busybox/config/mailutils/Config.in
+source package/busybox/config/procps/Config.in
+source package/busybox/config/runit/Config.in
+source package/busybox/config/selinux/Config.in
+source package/busybox/config/shell/Config.in
+source package/busybox/config/sysklogd/Config.in
diff --git a/package/busybox/config/archival/.svn/entries b/package/busybox/config/archival/.svn/entries
new file mode 100644
index 0000000..2b1d91d
--- /dev/null
+++ b/package/busybox/config/archival/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/busybox/config/archival
+svn://svn.openwrt.org/openwrt
+
+
+
+2011-10-21T23:08:45.031764Z
+28513
+nico
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+Config.in
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+4f786d4cab95f2a5ff9d84d4f39a62f2
+2011-10-21T23:08:45.031764Z
+28513
+nico
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+11858
+
diff --git a/package/busybox/config/archival/.svn/prop-base/Config.in.svn-base b/package/busybox/config/archival/.svn/prop-base/Config.in.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/busybox/config/archival/.svn/prop-base/Config.in.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/busybox/config/archival/.svn/text-base/Config.in.svn-base b/package/busybox/config/archival/.svn/text-base/Config.in.svn-base
new file mode 100644
index 0000000..d2bfa48
--- /dev/null
+++ b/package/busybox/config/archival/.svn/text-base/Config.in.svn-base
@@ -0,0 +1,380 @@
+# DO NOT EDIT. This file is generated from Config.src
+#
+# For a description of the syntax of this configuration file,
+# see scripts/kbuild/config-language.txt.
+#
+
+menu "Archival Utilities"
+
+
+
+config BUSYBOX_CONFIG_FEATURE_SEAMLESS_XZ
+ bool "Make tar, rpm, modprobe etc understand .xz data"
+ default n
+ help
+ Make tar, rpm, modprobe etc understand .xz data.
+
+config BUSYBOX_CONFIG_FEATURE_SEAMLESS_LZMA
+ bool "Make tar, rpm, modprobe etc understand .lzma data"
+ default n
+ help
+ Make tar, rpm, modprobe etc understand .lzma data.
+
+config BUSYBOX_CONFIG_FEATURE_SEAMLESS_BZ2
+ bool "Make tar, rpm, modprobe etc understand .bz2 data"
+ default n
+ help
+ Make tar, rpm, modprobe etc understand .bz2 data.
+
+config BUSYBOX_CONFIG_FEATURE_SEAMLESS_GZ
+ bool "Make tar, rpm, modprobe etc understand .gz data"
+ default y
+ help
+ Make tar, rpm, modprobe etc understand .gz data.
+
+config BUSYBOX_CONFIG_FEATURE_SEAMLESS_Z
+ bool "Make tar and gunzip understand .Z data"
+ default n
+ help
+ Make tar and gunzip understand .Z data.
+
+config BUSYBOX_CONFIG_AR
+ bool "ar"
+ default n # needs to be improved to be able to replace binutils ar
+ help
+ ar is an archival utility program used to create, modify, and
+ extract contents from archives. An archive is a single file holding
+ a collection of other files in a structure that makes it possible to
+ retrieve the original individual files (called archive members).
+ The original files' contents, mode (permissions), timestamp, owner,
+ and group are preserved in the archive, and can be restored on
+ extraction.
+
+ The stored filename is limited to 15 characters. (for more information
+ see long filename support).
+ ar has 60 bytes of overheads for every stored file.
+
+ This implementation of ar can extract archives, it cannot create or
+ modify them.
+ On an x86 system, the ar applet adds about 1K.
+
+ Unless you have a specific application which requires ar, you should
+ probably say N here.
+
+config BUSYBOX_CONFIG_FEATURE_AR_LONG_FILENAMES
+ bool "Support for long filenames (not needed for debs)"
+ default n
+ depends on BUSYBOX_CONFIG_AR
+ help
+ By default the ar format can only store the first 15 characters
+ of the filename, this option removes that limitation.
+ It supports the GNU ar long filename method which moves multiple long
+ filenames into a the data section of a new ar entry.
+
+config BUSYBOX_CONFIG_FEATURE_AR_CREATE
+ bool "Support archive creation"
+ default n
+ depends on BUSYBOX_CONFIG_AR
+ help
+ This enables archive creation (-c and -r) with busybox ar.
+
+config BUSYBOX_CONFIG_BUNZIP2
+ bool "bunzip2"
+ default y
+ help
+ bunzip2 is a compression utility using the Burrows-Wheeler block
+ sorting text compression algorithm, and Huffman coding. Compression
+ is generally considerably better than that achieved by more
+ conventional LZ77/LZ78-based compressors, and approaches the
+ performance of the PPM family of statistical compressors.
+
+ Unless you have a specific application which requires bunzip2, you
+ should probably say N here.
+
+config BUSYBOX_CONFIG_BZIP2
+ bool "bzip2"
+ default n
+ help
+ bzip2 is a compression utility using the Burrows-Wheeler block
+ sorting text compression algorithm, and Huffman coding. Compression
+ is generally considerably better than that achieved by more
+ conventional LZ77/LZ78-based compressors, and approaches the
+ performance of the PPM family of statistical compressors.
+
+ Unless you have a specific application which requires bzip2, you
+ should probably say N here.
+
+config BUSYBOX_CONFIG_CPIO
+ bool "cpio"
+ default n
+ help
+ cpio is an archival utility program used to create, modify, and
+ extract contents from archives.
+ cpio has 110 bytes of overheads for every stored file.
+
+ This implementation of cpio can extract cpio archives created in the
+ "newc" or "crc" format, it cannot create or modify them.
+
+ Unless you have a specific application which requires cpio, you
+ should probably say N here.
+
+config BUSYBOX_CONFIG_FEATURE_CPIO_O
+ bool "Support for archive creation"
+ default n
+ depends on BUSYBOX_CONFIG_CPIO
+ help
+ This implementation of cpio can create cpio archives in the "newc"
+ format only.
+
+config BUSYBOX_CONFIG_FEATURE_CPIO_P
+ bool "Support for passthrough mode"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_CPIO_O
+ help
+ Passthrough mode. Rarely used.
+
+config BUSYBOX_CONFIG_DPKG
+ bool "dpkg"
+ default n
+ select BUSYBOX_CONFIG_FEATURE_SEAMLESS_GZ
+ help
+ dpkg is a medium-level tool to install, build, remove and manage
+ Debian packages.
+
+ This implementation of dpkg has a number of limitations,
+ you should use the official dpkg if possible.
+
+config BUSYBOX_CONFIG_DPKG_DEB
+ bool "dpkg_deb"
+ default n
+ select BUSYBOX_CONFIG_FEATURE_SEAMLESS_GZ
+ help
+ dpkg-deb unpacks and provides information about Debian archives.
+
+ This implementation of dpkg-deb cannot pack archives.
+
+ Unless you have a specific application which requires dpkg-deb,
+ say N here.
+
+config BUSYBOX_CONFIG_FEATURE_DPKG_DEB_EXTRACT_ONLY
+ bool "Extract only (-x)"
+ default n
+ depends on BUSYBOX_CONFIG_DPKG_DEB
+ help
+ This reduces dpkg-deb to the equivalent of
+ "ar -p <deb> data.tar.gz | tar -zx". However it saves space as none
+ of the extra dpkg-deb, ar or tar options are needed, they are linked
+ to internally.
+
+config BUSYBOX_CONFIG_GUNZIP
+ bool "gunzip"
+ default y
+ help
+ gunzip is used to decompress archives created by gzip.
+ You can use the `-t' option to test the integrity of
+ an archive, without decompressing it.
+
+config BUSYBOX_CONFIG_GZIP
+ bool "gzip"
+ default y
+ help
+ gzip is used to compress files.
+ It's probably the most widely used UNIX compression program.
+
+config BUSYBOX_CONFIG_FEATURE_GZIP_LONG_OPTIONS
+ bool "Enable long options"
+ default n
+ depends on BUSYBOX_CONFIG_GZIP && BUSYBOX_CONFIG_LONG_OPTS
+ help
+ Enable use of long options, increases size by about 106 Bytes
+
+config BUSYBOX_CONFIG_LZOP
+ bool "lzop"
+ default n
+ help
+ Lzop compression/decompresion.
+
+config BUSYBOX_CONFIG_LZOP_COMPR_HIGH
+ bool "lzop compression levels 7,8,9 (not very useful)"
+ default n
+ depends on BUSYBOX_CONFIG_LZOP
+ help
+ High levels (7,8,9) of lzop compression. These levels
+ are actually slower than gzip at equivalent compression ratios
+ and take up 3.2K of code.
+
+config BUSYBOX_CONFIG_RPM2CPIO
+ bool "rpm2cpio"
+ default n
+ help
+ Converts a RPM file into a CPIO archive.
+
+config BUSYBOX_CONFIG_RPM
+ bool "rpm"
+ default n
+ help
+ Mini RPM applet - queries and extracts RPM packages.
+
+config BUSYBOX_CONFIG_TAR
+ bool "tar"
+ default y
+ help
+ tar is an archiving program. It's commonly used with gzip to
+ create compressed archives. It's probably the most widely used
+ UNIX archive program.
+
+config BUSYBOX_CONFIG_FEATURE_TAR_CREATE
+ bool "Enable archive creation"
+ default y
+ depends on BUSYBOX_CONFIG_TAR
+ help
+ If you enable this option you'll be able to create
+ tar archives using the `-c' option.
+
+config BUSYBOX_CONFIG_FEATURE_TAR_AUTODETECT
+ bool "Autodetect compressed tarballs"
+ default n
+ depends on BUSYBOX_CONFIG_TAR && (BUSYBOX_CONFIG_FEATURE_SEAMLESS_Z || BUSYBOX_CONFIG_FEATURE_SEAMLESS_GZ || BUSYBOX_CONFIG_FEATURE_SEAMLESS_BZ2 || BUSYBOX_CONFIG_FEATURE_SEAMLESS_LZMA || BUSYBOX_CONFIG_FEATURE_SEAMLESS_XZ)
+ help
+ With this option tar can automatically detect compressed
+ tarballs. Currently it works only on files (not pipes etc).
+
+config BUSYBOX_CONFIG_FEATURE_TAR_FROM
+ bool "Enable -X (exclude from) and -T (include from) options)"
+ default y
+ depends on BUSYBOX_CONFIG_TAR
+ help
+ If you enable this option you'll be able to specify
+ a list of files to include or exclude from an archive.
+
+config BUSYBOX_CONFIG_FEATURE_TAR_OLDGNU_COMPATIBILITY
+ bool "Support for old tar header format"
+ default n
+ depends on BUSYBOX_CONFIG_TAR || BUSYBOX_CONFIG_DPKG
+ help
+ This option is required to unpack archives created in
+ the old GNU format; help to kill this old format by
+ repacking your ancient archives with the new format.
+
+config BUSYBOX_CONFIG_FEATURE_TAR_OLDSUN_COMPATIBILITY
+ bool "Enable untarring of tarballs with checksums produced by buggy Sun tar"
+ default n
+ depends on BUSYBOX_CONFIG_TAR || BUSYBOX_CONFIG_DPKG
+ help
+ This option is required to unpack archives created by some old
+ version of Sun's tar (it was calculating checksum using signed
+ arithmetic). It is said to be fixed in newer Sun tar, but "old"
+ tarballs still exist.
+
+config BUSYBOX_CONFIG_FEATURE_TAR_GNU_EXTENSIONS
+ bool "Support for GNU tar extensions (long filenames)"
+ default y
+ depends on BUSYBOX_CONFIG_TAR || BUSYBOX_CONFIG_DPKG
+ help
+ With this option busybox supports GNU long filenames and
+ linknames.
+
+config BUSYBOX_CONFIG_FEATURE_TAR_LONG_OPTIONS
+ bool "Enable long options"
+ default n
+ depends on BUSYBOX_CONFIG_TAR && BUSYBOX_CONFIG_LONG_OPTS
+ help
+ Enable use of long options, increases size by about 400 Bytes
+
+config BUSYBOX_CONFIG_FEATURE_TAR_TO_COMMAND
+ bool "Support for writing to an external program"
+ default n
+ depends on BUSYBOX_CONFIG_TAR && BUSYBOX_CONFIG_FEATURE_TAR_LONG_OPTIONS
+ help
+ If you enable this option you'll be able to instruct tar to send
+ the contents of each extracted file to the standard input of an
+ external program.
+
+config BUSYBOX_CONFIG_FEATURE_TAR_UNAME_GNAME
+ bool "Enable use of user and group names"
+ default n
+ depends on BUSYBOX_CONFIG_TAR
+ help
+ Enables use of user and group names in tar. This affects contents
+ listings (-t) and preserving permissions when unpacking (-p).
+ +200 bytes.
+
+config BUSYBOX_CONFIG_FEATURE_TAR_NOPRESERVE_TIME
+ bool "Enable -m (do not preserve time) option"
+ default n
+ depends on BUSYBOX_CONFIG_TAR
+ help
+ With this option busybox supports GNU tar -m
+ (do not preserve time) option.
+
+config BUSYBOX_CONFIG_FEATURE_TAR_SELINUX
+ bool "Support for extracting SELinux labels"
+ default n
+ depends on BUSYBOX_CONFIG_TAR && BUSYBOX_CONFIG_SELINUX
+ help
+ With this option busybox supports restoring SELinux labels
+ when extracting files from tar archives.
+
+config BUSYBOX_CONFIG_UNCOMPRESS
+ bool "uncompress"
+ default n
+ help
+ uncompress is used to decompress archives created by compress.
+ Not much used anymore, replaced by gzip/gunzip.
+
+config BUSYBOX_CONFIG_UNLZMA
+ bool "unlzma"
+ default n
+ help
+ unlzma is a compression utility using the Lempel-Ziv-Markov chain
+ compression algorithm, and range coding. Compression
+ is generally considerably better than that achieved by the bzip2
+ compressors.
+
+ The BusyBox unlzma applet is limited to de-compression only.
+ On an x86 system, this applet adds about 4K.
+
+ Unless you have a specific application which requires unlzma, you
+ should probably say N here.
+
+config BUSYBOX_CONFIG_FEATURE_LZMA_FAST
+ bool "Optimize unlzma for speed"
+ default n
+ depends on BUSYBOX_CONFIG_UNLZMA
+ help
+ This option reduces decompression time by about 25% at the cost of
+ a 1K bigger binary.
+
+config BUSYBOX_CONFIG_LZMA
+ bool "Provide lzma alias which supports only unpacking"
+ default n
+ depends on BUSYBOX_CONFIG_UNLZMA
+ help
+ Enable this option if you want commands like "lzma -d" to work.
+ IOW: you'll get lzma applet, but it will always require -d option.
+
+config BUSYBOX_CONFIG_UNXZ
+ bool "unxz"
+ default n
+ help
+ unxz is a unlzma successor.
+
+config BUSYBOX_CONFIG_XZ
+ bool "Provide xz alias which supports only unpacking"
+ default n
+ depends on BUSYBOX_CONFIG_UNXZ
+ help
+ Enable this option if you want commands like "xz -d" to work.
+ IOW: you'll get xz applet, but it will always require -d option.
+
+config BUSYBOX_CONFIG_UNZIP
+ bool "unzip"
+ default n
+ help
+ unzip will list or extract files from a ZIP archive,
+ commonly found on DOS/WIN systems. The default behavior
+ (with no options) is to extract the archive into the
+ current directory. Use the `-d' option to extract to a
+ directory of your choice.
+
+endmenu
diff --git a/package/busybox/config/archival/Config.in b/package/busybox/config/archival/Config.in
new file mode 100644
index 0000000..d2bfa48
--- /dev/null
+++ b/package/busybox/config/archival/Config.in
@@ -0,0 +1,380 @@
+# DO NOT EDIT. This file is generated from Config.src
+#
+# For a description of the syntax of this configuration file,
+# see scripts/kbuild/config-language.txt.
+#
+
+menu "Archival Utilities"
+
+
+
+config BUSYBOX_CONFIG_FEATURE_SEAMLESS_XZ
+ bool "Make tar, rpm, modprobe etc understand .xz data"
+ default n
+ help
+ Make tar, rpm, modprobe etc understand .xz data.
+
+config BUSYBOX_CONFIG_FEATURE_SEAMLESS_LZMA
+ bool "Make tar, rpm, modprobe etc understand .lzma data"
+ default n
+ help
+ Make tar, rpm, modprobe etc understand .lzma data.
+
+config BUSYBOX_CONFIG_FEATURE_SEAMLESS_BZ2
+ bool "Make tar, rpm, modprobe etc understand .bz2 data"
+ default n
+ help
+ Make tar, rpm, modprobe etc understand .bz2 data.
+
+config BUSYBOX_CONFIG_FEATURE_SEAMLESS_GZ
+ bool "Make tar, rpm, modprobe etc understand .gz data"
+ default y
+ help
+ Make tar, rpm, modprobe etc understand .gz data.
+
+config BUSYBOX_CONFIG_FEATURE_SEAMLESS_Z
+ bool "Make tar and gunzip understand .Z data"
+ default n
+ help
+ Make tar and gunzip understand .Z data.
+
+config BUSYBOX_CONFIG_AR
+ bool "ar"
+ default n # needs to be improved to be able to replace binutils ar
+ help
+ ar is an archival utility program used to create, modify, and
+ extract contents from archives. An archive is a single file holding
+ a collection of other files in a structure that makes it possible to
+ retrieve the original individual files (called archive members).
+ The original files' contents, mode (permissions), timestamp, owner,
+ and group are preserved in the archive, and can be restored on
+ extraction.
+
+ The stored filename is limited to 15 characters. (for more information
+ see long filename support).
+ ar has 60 bytes of overheads for every stored file.
+
+ This implementation of ar can extract archives, it cannot create or
+ modify them.
+ On an x86 system, the ar applet adds about 1K.
+
+ Unless you have a specific application which requires ar, you should
+ probably say N here.
+
+config BUSYBOX_CONFIG_FEATURE_AR_LONG_FILENAMES
+ bool "Support for long filenames (not needed for debs)"
+ default n
+ depends on BUSYBOX_CONFIG_AR
+ help
+ By default the ar format can only store the first 15 characters
+ of the filename, this option removes that limitation.
+ It supports the GNU ar long filename method which moves multiple long
+ filenames into a the data section of a new ar entry.
+
+config BUSYBOX_CONFIG_FEATURE_AR_CREATE
+ bool "Support archive creation"
+ default n
+ depends on BUSYBOX_CONFIG_AR
+ help
+ This enables archive creation (-c and -r) with busybox ar.
+
+config BUSYBOX_CONFIG_BUNZIP2
+ bool "bunzip2"
+ default y
+ help
+ bunzip2 is a compression utility using the Burrows-Wheeler block
+ sorting text compression algorithm, and Huffman coding. Compression
+ is generally considerably better than that achieved by more
+ conventional LZ77/LZ78-based compressors, and approaches the
+ performance of the PPM family of statistical compressors.
+
+ Unless you have a specific application which requires bunzip2, you
+ should probably say N here.
+
+config BUSYBOX_CONFIG_BZIP2
+ bool "bzip2"
+ default n
+ help
+ bzip2 is a compression utility using the Burrows-Wheeler block
+ sorting text compression algorithm, and Huffman coding. Compression
+ is generally considerably better than that achieved by more
+ conventional LZ77/LZ78-based compressors, and approaches the
+ performance of the PPM family of statistical compressors.
+
+ Unless you have a specific application which requires bzip2, you
+ should probably say N here.
+
+config BUSYBOX_CONFIG_CPIO
+ bool "cpio"
+ default n
+ help
+ cpio is an archival utility program used to create, modify, and
+ extract contents from archives.
+ cpio has 110 bytes of overheads for every stored file.
+
+ This implementation of cpio can extract cpio archives created in the
+ "newc" or "crc" format, it cannot create or modify them.
+
+ Unless you have a specific application which requires cpio, you
+ should probably say N here.
+
+config BUSYBOX_CONFIG_FEATURE_CPIO_O
+ bool "Support for archive creation"
+ default n
+ depends on BUSYBOX_CONFIG_CPIO
+ help
+ This implementation of cpio can create cpio archives in the "newc"
+ format only.
+
+config BUSYBOX_CONFIG_FEATURE_CPIO_P
+ bool "Support for passthrough mode"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_CPIO_O
+ help
+ Passthrough mode. Rarely used.
+
+config BUSYBOX_CONFIG_DPKG
+ bool "dpkg"
+ default n
+ select BUSYBOX_CONFIG_FEATURE_SEAMLESS_GZ
+ help
+ dpkg is a medium-level tool to install, build, remove and manage
+ Debian packages.
+
+ This implementation of dpkg has a number of limitations,
+ you should use the official dpkg if possible.
+
+config BUSYBOX_CONFIG_DPKG_DEB
+ bool "dpkg_deb"
+ default n
+ select BUSYBOX_CONFIG_FEATURE_SEAMLESS_GZ
+ help
+ dpkg-deb unpacks and provides information about Debian archives.
+
+ This implementation of dpkg-deb cannot pack archives.
+
+ Unless you have a specific application which requires dpkg-deb,
+ say N here.
+
+config BUSYBOX_CONFIG_FEATURE_DPKG_DEB_EXTRACT_ONLY
+ bool "Extract only (-x)"
+ default n
+ depends on BUSYBOX_CONFIG_DPKG_DEB
+ help
+ This reduces dpkg-deb to the equivalent of
+ "ar -p <deb> data.tar.gz | tar -zx". However it saves space as none
+ of the extra dpkg-deb, ar or tar options are needed, they are linked
+ to internally.
+
+config BUSYBOX_CONFIG_GUNZIP
+ bool "gunzip"
+ default y
+ help
+ gunzip is used to decompress archives created by gzip.
+ You can use the `-t' option to test the integrity of
+ an archive, without decompressing it.
+
+config BUSYBOX_CONFIG_GZIP
+ bool "gzip"
+ default y
+ help
+ gzip is used to compress files.
+ It's probably the most widely used UNIX compression program.
+
+config BUSYBOX_CONFIG_FEATURE_GZIP_LONG_OPTIONS
+ bool "Enable long options"
+ default n
+ depends on BUSYBOX_CONFIG_GZIP && BUSYBOX_CONFIG_LONG_OPTS
+ help
+ Enable use of long options, increases size by about 106 Bytes
+
+config BUSYBOX_CONFIG_LZOP
+ bool "lzop"
+ default n
+ help
+ Lzop compression/decompresion.
+
+config BUSYBOX_CONFIG_LZOP_COMPR_HIGH
+ bool "lzop compression levels 7,8,9 (not very useful)"
+ default n
+ depends on BUSYBOX_CONFIG_LZOP
+ help
+ High levels (7,8,9) of lzop compression. These levels
+ are actually slower than gzip at equivalent compression ratios
+ and take up 3.2K of code.
+
+config BUSYBOX_CONFIG_RPM2CPIO
+ bool "rpm2cpio"
+ default n
+ help
+ Converts a RPM file into a CPIO archive.
+
+config BUSYBOX_CONFIG_RPM
+ bool "rpm"
+ default n
+ help
+ Mini RPM applet - queries and extracts RPM packages.
+
+config BUSYBOX_CONFIG_TAR
+ bool "tar"
+ default y
+ help
+ tar is an archiving program. It's commonly used with gzip to
+ create compressed archives. It's probably the most widely used
+ UNIX archive program.
+
+config BUSYBOX_CONFIG_FEATURE_TAR_CREATE
+ bool "Enable archive creation"
+ default y
+ depends on BUSYBOX_CONFIG_TAR
+ help
+ If you enable this option you'll be able to create
+ tar archives using the `-c' option.
+
+config BUSYBOX_CONFIG_FEATURE_TAR_AUTODETECT
+ bool "Autodetect compressed tarballs"
+ default n
+ depends on BUSYBOX_CONFIG_TAR && (BUSYBOX_CONFIG_FEATURE_SEAMLESS_Z || BUSYBOX_CONFIG_FEATURE_SEAMLESS_GZ || BUSYBOX_CONFIG_FEATURE_SEAMLESS_BZ2 || BUSYBOX_CONFIG_FEATURE_SEAMLESS_LZMA || BUSYBOX_CONFIG_FEATURE_SEAMLESS_XZ)
+ help
+ With this option tar can automatically detect compressed
+ tarballs. Currently it works only on files (not pipes etc).
+
+config BUSYBOX_CONFIG_FEATURE_TAR_FROM
+ bool "Enable -X (exclude from) and -T (include from) options)"
+ default y
+ depends on BUSYBOX_CONFIG_TAR
+ help
+ If you enable this option you'll be able to specify
+ a list of files to include or exclude from an archive.
+
+config BUSYBOX_CONFIG_FEATURE_TAR_OLDGNU_COMPATIBILITY
+ bool "Support for old tar header format"
+ default n
+ depends on BUSYBOX_CONFIG_TAR || BUSYBOX_CONFIG_DPKG
+ help
+ This option is required to unpack archives created in
+ the old GNU format; help to kill this old format by
+ repacking your ancient archives with the new format.
+
+config BUSYBOX_CONFIG_FEATURE_TAR_OLDSUN_COMPATIBILITY
+ bool "Enable untarring of tarballs with checksums produced by buggy Sun tar"
+ default n
+ depends on BUSYBOX_CONFIG_TAR || BUSYBOX_CONFIG_DPKG
+ help
+ This option is required to unpack archives created by some old
+ version of Sun's tar (it was calculating checksum using signed
+ arithmetic). It is said to be fixed in newer Sun tar, but "old"
+ tarballs still exist.
+
+config BUSYBOX_CONFIG_FEATURE_TAR_GNU_EXTENSIONS
+ bool "Support for GNU tar extensions (long filenames)"
+ default y
+ depends on BUSYBOX_CONFIG_TAR || BUSYBOX_CONFIG_DPKG
+ help
+ With this option busybox supports GNU long filenames and
+ linknames.
+
+config BUSYBOX_CONFIG_FEATURE_TAR_LONG_OPTIONS
+ bool "Enable long options"
+ default n
+ depends on BUSYBOX_CONFIG_TAR && BUSYBOX_CONFIG_LONG_OPTS
+ help
+ Enable use of long options, increases size by about 400 Bytes
+
+config BUSYBOX_CONFIG_FEATURE_TAR_TO_COMMAND
+ bool "Support for writing to an external program"
+ default n
+ depends on BUSYBOX_CONFIG_TAR && BUSYBOX_CONFIG_FEATURE_TAR_LONG_OPTIONS
+ help
+ If you enable this option you'll be able to instruct tar to send
+ the contents of each extracted file to the standard input of an
+ external program.
+
+config BUSYBOX_CONFIG_FEATURE_TAR_UNAME_GNAME
+ bool "Enable use of user and group names"
+ default n
+ depends on BUSYBOX_CONFIG_TAR
+ help
+ Enables use of user and group names in tar. This affects contents
+ listings (-t) and preserving permissions when unpacking (-p).
+ +200 bytes.
+
+config BUSYBOX_CONFIG_FEATURE_TAR_NOPRESERVE_TIME
+ bool "Enable -m (do not preserve time) option"
+ default n
+ depends on BUSYBOX_CONFIG_TAR
+ help
+ With this option busybox supports GNU tar -m
+ (do not preserve time) option.
+
+config BUSYBOX_CONFIG_FEATURE_TAR_SELINUX
+ bool "Support for extracting SELinux labels"
+ default n
+ depends on BUSYBOX_CONFIG_TAR && BUSYBOX_CONFIG_SELINUX
+ help
+ With this option busybox supports restoring SELinux labels
+ when extracting files from tar archives.
+
+config BUSYBOX_CONFIG_UNCOMPRESS
+ bool "uncompress"
+ default n
+ help
+ uncompress is used to decompress archives created by compress.
+ Not much used anymore, replaced by gzip/gunzip.
+
+config BUSYBOX_CONFIG_UNLZMA
+ bool "unlzma"
+ default n
+ help
+ unlzma is a compression utility using the Lempel-Ziv-Markov chain
+ compression algorithm, and range coding. Compression
+ is generally considerably better than that achieved by the bzip2
+ compressors.
+
+ The BusyBox unlzma applet is limited to de-compression only.
+ On an x86 system, this applet adds about 4K.
+
+ Unless you have a specific application which requires unlzma, you
+ should probably say N here.
+
+config BUSYBOX_CONFIG_FEATURE_LZMA_FAST
+ bool "Optimize unlzma for speed"
+ default n
+ depends on BUSYBOX_CONFIG_UNLZMA
+ help
+ This option reduces decompression time by about 25% at the cost of
+ a 1K bigger binary.
+
+config BUSYBOX_CONFIG_LZMA
+ bool "Provide lzma alias which supports only unpacking"
+ default n
+ depends on BUSYBOX_CONFIG_UNLZMA
+ help
+ Enable this option if you want commands like "lzma -d" to work.
+ IOW: you'll get lzma applet, but it will always require -d option.
+
+config BUSYBOX_CONFIG_UNXZ
+ bool "unxz"
+ default n
+ help
+ unxz is a unlzma successor.
+
+config BUSYBOX_CONFIG_XZ
+ bool "Provide xz alias which supports only unpacking"
+ default n
+ depends on BUSYBOX_CONFIG_UNXZ
+ help
+ Enable this option if you want commands like "xz -d" to work.
+ IOW: you'll get xz applet, but it will always require -d option.
+
+config BUSYBOX_CONFIG_UNZIP
+ bool "unzip"
+ default n
+ help
+ unzip will list or extract files from a ZIP archive,
+ commonly found on DOS/WIN systems. The default behavior
+ (with no options) is to extract the archive into the
+ current directory. Use the `-d' option to extract to a
+ directory of your choice.
+
+endmenu
diff --git a/package/busybox/config/console-tools/.svn/entries b/package/busybox/config/console-tools/.svn/entries
new file mode 100644
index 0000000..9323384
--- /dev/null
+++ b/package/busybox/config/console-tools/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/busybox/config/console-tools
+svn://svn.openwrt.org/openwrt
+
+
+
+2011-10-24T07:39:53.699615Z
+28547
+nico
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+Config.in
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+3045d37ab48f02ae9aa84a362f61d191
+2011-10-24T07:39:53.699615Z
+28547
+nico
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4399
+
diff --git a/package/busybox/config/console-tools/.svn/prop-base/Config.in.svn-base b/package/busybox/config/console-tools/.svn/prop-base/Config.in.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/busybox/config/console-tools/.svn/prop-base/Config.in.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/busybox/config/console-tools/.svn/text-base/Config.in.svn-base b/package/busybox/config/console-tools/.svn/text-base/Config.in.svn-base
new file mode 100644
index 0000000..9069b0f
--- /dev/null
+++ b/package/busybox/config/console-tools/.svn/text-base/Config.in.svn-base
@@ -0,0 +1,177 @@
+# DO NOT EDIT. This file is generated from Config.src
+#
+# For a description of the syntax of this configuration file,
+# see scripts/kbuild/config-language.txt.
+#
+
+menu "Console Utilities"
+
+
+
+config BUSYBOX_CONFIG_CHVT
+ bool "chvt"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ This program is used to change to another terminal.
+ Example: chvt 4 (change to terminal /dev/tty4)
+
+config BUSYBOX_CONFIG_FGCONSOLE
+ bool "fgconsole"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ This program prints active (foreground) console number.
+
+config BUSYBOX_CONFIG_CLEAR
+ bool "clear"
+ default y
+ help
+ This program clears the terminal screen.
+
+config BUSYBOX_CONFIG_DEALLOCVT
+ bool "deallocvt"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ This program deallocates unused virtual consoles.
+
+config BUSYBOX_CONFIG_DUMPKMAP
+ bool "dumpkmap"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ This program dumps the kernel's keyboard translation table to
+ stdout, in binary format. You can then use loadkmap to load it.
+
+config BUSYBOX_CONFIG_KBD_MODE
+ bool "kbd_mode"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ This program reports and sets keyboard mode.
+
+config BUSYBOX_CONFIG_LOADFONT
+ bool "loadfont"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ This program loads a console font from standard input.
+
+config BUSYBOX_CONFIG_LOADKMAP
+ bool "loadkmap"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ This program loads a keyboard translation table from
+ standard input.
+
+config BUSYBOX_CONFIG_OPENVT
+ bool "openvt"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ This program is used to start a command on an unused
+ virtual terminal.
+
+config BUSYBOX_CONFIG_RESET
+ bool "reset"
+ default y
+ help
+ This program is used to reset the terminal screen, if it
+ gets messed up.
+
+config BUSYBOX_CONFIG_RESIZE
+ bool "resize"
+ default n
+ help
+ This program is used to (re)set the width and height of your current
+ terminal.
+
+config BUSYBOX_CONFIG_FEATURE_RESIZE_PRINT
+ bool "Print environment variables"
+ default n
+ depends on BUSYBOX_CONFIG_RESIZE
+ help
+ Prints the newly set size (number of columns and rows) of
+ the terminal.
+ E.g.:
+ COLUMNS=80;LINES=44;export COLUMNS LINES;
+
+config BUSYBOX_CONFIG_SETCONSOLE
+ bool "setconsole"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ This program redirects the system console to another device,
+ like the current tty while logged in via telnet.
+
+config BUSYBOX_CONFIG_FEATURE_SETCONSOLE_LONG_OPTIONS
+ bool "Enable long options"
+ default n
+ depends on BUSYBOX_CONFIG_SETCONSOLE && BUSYBOX_CONFIG_LONG_OPTS
+ help
+ Support long options for the setconsole applet.
+
+config BUSYBOX_CONFIG_SETFONT
+ bool "setfont"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Allows to load console screen map. Useful for i18n.
+
+config BUSYBOX_CONFIG_FEATURE_SETFONT_TEXTUAL_MAP
+ bool "Support reading textual screen maps"
+ default n
+ depends on BUSYBOX_CONFIG_SETFONT
+ help
+ Support reading textual screen maps.
+
+config BUSYBOX_CONFIG_DEFAULT_SETFONT_DIR
+ string "Default directory for console-tools files"
+ default ""
+ depends on BUSYBOX_CONFIG_SETFONT
+ help
+ Directory to use if setfont's params are simple filenames
+ (not /path/to/file or ./file). Default is "" (no default directory).
+
+config BUSYBOX_CONFIG_SETKEYCODES
+ bool "setkeycodes"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ This program loads entries into the kernel's scancode-to-keycode
+ map, allowing unusual keyboards to generate usable keycodes.
+
+config BUSYBOX_CONFIG_SETLOGCONS
+ bool "setlogcons"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ This program redirects the output console of kernel messages.
+
+config BUSYBOX_CONFIG_SHOWKEY
+ bool "showkey"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Shows keys pressed.
+
+comment "Common options for loadfont and setfont"
+ depends on BUSYBOX_CONFIG_LOADFONT || BUSYBOX_CONFIG_SETFONT
+
+config BUSYBOX_CONFIG_FEATURE_LOADFONT_PSF2
+ bool "Support for PSF2 console fonts"
+ default n
+ depends on BUSYBOX_CONFIG_LOADFONT || BUSYBOX_CONFIG_SETFONT
+ help
+ Support PSF2 console fonts.
+
+config BUSYBOX_CONFIG_FEATURE_LOADFONT_RAW
+ bool "Support for old (raw) console fonts"
+ default n
+ depends on BUSYBOX_CONFIG_LOADFONT || BUSYBOX_CONFIG_SETFONT
+ help
+ Support old (raw) console fonts.
+
+endmenu
diff --git a/package/busybox/config/console-tools/Config.in b/package/busybox/config/console-tools/Config.in
new file mode 100644
index 0000000..9069b0f
--- /dev/null
+++ b/package/busybox/config/console-tools/Config.in
@@ -0,0 +1,177 @@
+# DO NOT EDIT. This file is generated from Config.src
+#
+# For a description of the syntax of this configuration file,
+# see scripts/kbuild/config-language.txt.
+#
+
+menu "Console Utilities"
+
+
+
+config BUSYBOX_CONFIG_CHVT
+ bool "chvt"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ This program is used to change to another terminal.
+ Example: chvt 4 (change to terminal /dev/tty4)
+
+config BUSYBOX_CONFIG_FGCONSOLE
+ bool "fgconsole"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ This program prints active (foreground) console number.
+
+config BUSYBOX_CONFIG_CLEAR
+ bool "clear"
+ default y
+ help
+ This program clears the terminal screen.
+
+config BUSYBOX_CONFIG_DEALLOCVT
+ bool "deallocvt"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ This program deallocates unused virtual consoles.
+
+config BUSYBOX_CONFIG_DUMPKMAP
+ bool "dumpkmap"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ This program dumps the kernel's keyboard translation table to
+ stdout, in binary format. You can then use loadkmap to load it.
+
+config BUSYBOX_CONFIG_KBD_MODE
+ bool "kbd_mode"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ This program reports and sets keyboard mode.
+
+config BUSYBOX_CONFIG_LOADFONT
+ bool "loadfont"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ This program loads a console font from standard input.
+
+config BUSYBOX_CONFIG_LOADKMAP
+ bool "loadkmap"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ This program loads a keyboard translation table from
+ standard input.
+
+config BUSYBOX_CONFIG_OPENVT
+ bool "openvt"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ This program is used to start a command on an unused
+ virtual terminal.
+
+config BUSYBOX_CONFIG_RESET
+ bool "reset"
+ default y
+ help
+ This program is used to reset the terminal screen, if it
+ gets messed up.
+
+config BUSYBOX_CONFIG_RESIZE
+ bool "resize"
+ default n
+ help
+ This program is used to (re)set the width and height of your current
+ terminal.
+
+config BUSYBOX_CONFIG_FEATURE_RESIZE_PRINT
+ bool "Print environment variables"
+ default n
+ depends on BUSYBOX_CONFIG_RESIZE
+ help
+ Prints the newly set size (number of columns and rows) of
+ the terminal.
+ E.g.:
+ COLUMNS=80;LINES=44;export COLUMNS LINES;
+
+config BUSYBOX_CONFIG_SETCONSOLE
+ bool "setconsole"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ This program redirects the system console to another device,
+ like the current tty while logged in via telnet.
+
+config BUSYBOX_CONFIG_FEATURE_SETCONSOLE_LONG_OPTIONS
+ bool "Enable long options"
+ default n
+ depends on BUSYBOX_CONFIG_SETCONSOLE && BUSYBOX_CONFIG_LONG_OPTS
+ help
+ Support long options for the setconsole applet.
+
+config BUSYBOX_CONFIG_SETFONT
+ bool "setfont"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Allows to load console screen map. Useful for i18n.
+
+config BUSYBOX_CONFIG_FEATURE_SETFONT_TEXTUAL_MAP
+ bool "Support reading textual screen maps"
+ default n
+ depends on BUSYBOX_CONFIG_SETFONT
+ help
+ Support reading textual screen maps.
+
+config BUSYBOX_CONFIG_DEFAULT_SETFONT_DIR
+ string "Default directory for console-tools files"
+ default ""
+ depends on BUSYBOX_CONFIG_SETFONT
+ help
+ Directory to use if setfont's params are simple filenames
+ (not /path/to/file or ./file). Default is "" (no default directory).
+
+config BUSYBOX_CONFIG_SETKEYCODES
+ bool "setkeycodes"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ This program loads entries into the kernel's scancode-to-keycode
+ map, allowing unusual keyboards to generate usable keycodes.
+
+config BUSYBOX_CONFIG_SETLOGCONS
+ bool "setlogcons"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ This program redirects the output console of kernel messages.
+
+config BUSYBOX_CONFIG_SHOWKEY
+ bool "showkey"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Shows keys pressed.
+
+comment "Common options for loadfont and setfont"
+ depends on BUSYBOX_CONFIG_LOADFONT || BUSYBOX_CONFIG_SETFONT
+
+config BUSYBOX_CONFIG_FEATURE_LOADFONT_PSF2
+ bool "Support for PSF2 console fonts"
+ default n
+ depends on BUSYBOX_CONFIG_LOADFONT || BUSYBOX_CONFIG_SETFONT
+ help
+ Support PSF2 console fonts.
+
+config BUSYBOX_CONFIG_FEATURE_LOADFONT_RAW
+ bool "Support for old (raw) console fonts"
+ default n
+ depends on BUSYBOX_CONFIG_LOADFONT || BUSYBOX_CONFIG_SETFONT
+ help
+ Support old (raw) console fonts.
+
+endmenu
diff --git a/package/busybox/config/coreutils/.svn/entries b/package/busybox/config/coreutils/.svn/entries
new file mode 100644
index 0000000..2ba592a
--- /dev/null
+++ b/package/busybox/config/coreutils/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/busybox/config/coreutils
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-18T00:09:50.538944Z
+33833
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+Config.in
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+b92943addc87dd00ba2acd29652f4545
+2012-10-18T00:09:50.538944Z
+33833
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+23348
+
diff --git a/package/busybox/config/coreutils/.svn/prop-base/Config.in.svn-base b/package/busybox/config/coreutils/.svn/prop-base/Config.in.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/busybox/config/coreutils/.svn/prop-base/Config.in.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/busybox/config/coreutils/.svn/text-base/Config.in.svn-base b/package/busybox/config/coreutils/.svn/text-base/Config.in.svn-base
new file mode 100644
index 0000000..33a5e25
--- /dev/null
+++ b/package/busybox/config/coreutils/.svn/text-base/Config.in.svn-base
@@ -0,0 +1,913 @@
+# DO NOT EDIT. This file is generated from Config.src
+#
+# For a description of the syntax of this configuration file,
+# see scripts/kbuild/config-language.txt.
+#
+
+menu "Coreutils"
+
+config BUSYBOX_CONFIG_BASENAME
+ bool "basename"
+ default y
+ help
+ basename is used to strip the directory and suffix from filenames,
+ leaving just the filename itself. Enable this option if you wish
+ to enable the 'basename' utility.
+config BUSYBOX_CONFIG_CAT
+ bool "cat"
+ default y
+ help
+ cat is used to concatenate files and print them to the standard
+ output. Enable this option if you wish to enable the 'cat' utility.
+config BUSYBOX_CONFIG_DATE
+ bool "date"
+ default y
+ help
+ date is used to set the system date or display the
+ current time in the given format.
+
+config BUSYBOX_CONFIG_FEATURE_DATE_ISOFMT
+ bool "Enable ISO date format output (-I)"
+ default y
+ depends on BUSYBOX_CONFIG_DATE
+ help
+ Enable option (-I) to output an ISO-8601 compliant
+ date/time string.
+
+# defaults to "no": stat's nanosecond field is a bit non-portable
+config BUSYBOX_CONFIG_FEATURE_DATE_NANO
+ bool "Support %[num]N nanosecond format specifier"
+ default n
+ depends on BUSYBOX_CONFIG_DATE # syscall(__NR_clock_gettime)
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Support %[num]N format specifier. Adds ~250 bytes of code.
+
+config BUSYBOX_CONFIG_FEATURE_DATE_COMPAT
+ bool "Support weird 'date MMDDhhmm[[YY]YY][.ss]' format"
+ default n
+ depends on BUSYBOX_CONFIG_DATE
+ help
+ System time can be set by 'date -s DATE' and simply 'date DATE',
+ but formats of DATE string are different. 'date DATE' accepts
+ a rather weird MMDDhhmm[[YY]YY][.ss] format with completely
+ unnatural placement of year between minutes and seconds.
+ date -s (and other commands like touch -d) use more sensible
+ formats (for one, ISO format YYYY-MM-DD hh:mm:ss.ssssss).
+
+ With this option off, 'date DATE' is 'date -s DATE' support
+ the same format. With it on, 'date DATE' additionally supports
+ MMDDhhmm[[YY]YY][.ss] format.
+config BUSYBOX_CONFIG_ID
+ bool "id"
+ default y
+ help
+ id displays the current user and group ID names.
+config BUSYBOX_CONFIG_GROUPS
+ bool "groups"
+ default n
+ help
+ Print the group names associated with current user id.
+config BUSYBOX_CONFIG_TEST
+ bool "test"
+ default y
+ help
+ test is used to check file types and compare values,
+ returning an appropriate exit code. The bash shell
+ has test built in, ash can build it in optionally.
+
+config BUSYBOX_CONFIG_FEATURE_TEST_64
+ bool "Extend test to 64 bit"
+ default y
+ depends on BUSYBOX_CONFIG_TEST || BUSYBOX_CONFIG_ASH_BUILTIN_TEST || BUSYBOX_CONFIG_HUSH
+ help
+ Enable 64-bit support in test.
+config BUSYBOX_CONFIG_TOUCH
+ bool "touch"
+ default y
+ help
+ touch is used to create or change the access and/or
+ modification timestamp of specified files.
+config BUSYBOX_CONFIG_TR
+ bool "tr"
+ default y
+ help
+ tr is used to squeeze, and/or delete characters from standard
+ input, writing to standard output.
+
+config BUSYBOX_CONFIG_FEATURE_TR_CLASSES
+ bool "Enable character classes (such as [:upper:])"
+ default n
+ depends on BUSYBOX_CONFIG_TR
+ help
+ Enable character classes, enabling commands such as:
+ tr [:upper:] [:lower:] to convert input into lowercase.
+
+config BUSYBOX_CONFIG_FEATURE_TR_EQUIV
+ bool "Enable equivalence classes"
+ default n
+ depends on BUSYBOX_CONFIG_TR
+ help
+ Enable equivalence classes, which essentially add the enclosed
+ character to the current set. For instance, tr [=a=] xyz would
+ replace all instances of 'a' with 'xyz'. This option is mainly
+ useful for cases when no other way of expressing a character
+ is possible.
+config BUSYBOX_CONFIG_BASE64
+ bool "base64"
+ default n
+ help
+ Base64 encode and decode
+config BUSYBOX_CONFIG_WHO
+ bool "who"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_UTMP
+ help
+ who is used to show who is logged on.
+config BUSYBOX_CONFIG_USERS
+ bool "users"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_UTMP
+ help
+ Print users currently logged on.
+
+config BUSYBOX_CONFIG_CAL
+ bool "cal"
+ default n
+ help
+ cal is used to display a monthly calender.
+
+config BUSYBOX_CONFIG_CATV
+ bool "catv"
+ default n
+ help
+ Display nonprinting characters as escape sequences (like some
+ implementations' cat -v option).
+
+config BUSYBOX_CONFIG_CHGRP
+ bool "chgrp"
+ default y
+ help
+ chgrp is used to change the group ownership of files.
+
+config BUSYBOX_CONFIG_CHMOD
+ bool "chmod"
+ default y
+ help
+ chmod is used to change the access permission of files.
+
+config BUSYBOX_CONFIG_CHOWN
+ bool "chown"
+ default y
+ help
+ chown is used to change the user and/or group ownership
+ of files.
+
+config BUSYBOX_CONFIG_FEATURE_CHOWN_LONG_OPTIONS
+ bool "Enable long options"
+ default n
+ depends on BUSYBOX_CONFIG_CHOWN && BUSYBOX_CONFIG_LONG_OPTS
+ help
+ Enable use of long options
+
+config BUSYBOX_CONFIG_CHROOT
+ bool "chroot"
+ default y
+ help
+ chroot is used to change the root directory and run a command.
+ The default command is `/bin/sh'.
+
+config BUSYBOX_CONFIG_CKSUM
+ bool "cksum"
+ default n
+ help
+ cksum is used to calculate the CRC32 checksum of a file.
+
+config BUSYBOX_CONFIG_COMM
+ bool "comm"
+ default n
+ help
+ comm is used to compare two files line by line and return
+ a three-column output.
+
+config BUSYBOX_CONFIG_CP
+ bool "cp"
+ default y
+ help
+ cp is used to copy files and directories.
+
+config BUSYBOX_CONFIG_FEATURE_CP_LONG_OPTIONS
+ bool "Enable long options for cp"
+ default n
+ depends on BUSYBOX_CONFIG_CP && BUSYBOX_CONFIG_LONG_OPTS
+ help
+ Enable long options for cp.
+ Also add support for --parents option.
+
+config BUSYBOX_CONFIG_CUT
+ bool "cut"
+ default y
+ help
+ cut is used to print selected parts of lines from
+ each file to stdout.
+
+config BUSYBOX_CONFIG_DD
+ bool "dd"
+ default y
+ help
+ dd copies a file (from standard input to standard output,
+ by default) using specific input and output blocksizes,
+ while optionally performing conversions on it.
+
+config BUSYBOX_CONFIG_FEATURE_DD_SIGNAL_HANDLING
+ bool "Enable DD signal handling for status reporting"
+ default y
+ depends on BUSYBOX_CONFIG_DD
+ help
+ Sending a SIGUSR1 signal to a running `dd' process makes it
+ print to standard error the number of records read and written
+ so far, then to resume copying.
+
+ $ dd if=/dev/zero of=/dev/null&
+ $ pid=$! kill -USR1 $pid; sleep 1; kill $pid
+ 10899206+0 records in
+ 10899206+0 records out
+
+config BUSYBOX_CONFIG_FEATURE_DD_THIRD_STATUS_LINE
+ bool "Enable the third status line upon signal"
+ default n
+ depends on BUSYBOX_CONFIG_DD && BUSYBOX_CONFIG_FEATURE_DD_SIGNAL_HANDLING
+ help
+ Displays a coreutils-like third status line with transferred bytes,
+ elapsed time and speed.
+
+config BUSYBOX_CONFIG_FEATURE_DD_IBS_OBS
+ bool "Enable ibs, obs and conv options"
+ default y
+ depends on BUSYBOX_CONFIG_DD
+ help
+ Enables support for writing a certain number of bytes in and out,
+ at a time, and performing conversions on the data stream.
+
+config BUSYBOX_CONFIG_DF
+ bool "df"
+ default y
+ help
+ df reports the amount of disk space used and available
+ on filesystems.
+
+config BUSYBOX_CONFIG_FEATURE_DF_FANCY
+ bool "Enable -a, -i, -B"
+ default n
+ depends on BUSYBOX_CONFIG_DF
+ help
+ This option enables -a, -i and -B.
+
+ -a Show all filesystems
+ -i Inodes
+ -B <SIZE> Blocksize
+
+config BUSYBOX_CONFIG_DIRNAME
+ bool "dirname"
+ default y
+ help
+ dirname is used to strip a non-directory suffix from
+ a file name.
+
+config BUSYBOX_CONFIG_DOS2UNIX
+ bool "dos2unix/unix2dos"
+ default n
+ help
+ dos2unix is used to convert a text file from DOS format to
+ UNIX format, and vice versa.
+
+config BUSYBOX_CONFIG_UNIX2DOS
+ bool
+ default n
+ depends on BUSYBOX_CONFIG_DOS2UNIX
+ help
+ unix2dos is used to convert a text file from UNIX format to
+ DOS format, and vice versa.
+
+config BUSYBOX_CONFIG_DU
+ bool "du (default blocksize of 512 bytes)"
+ default y
+ help
+ du is used to report the amount of disk space used
+ for specified files.
+
+config BUSYBOX_CONFIG_FEATURE_DU_DEFAULT_BLOCKSIZE_1K
+ bool "Use a default blocksize of 1024 bytes (1K)"
+ default y
+ depends on BUSYBOX_CONFIG_DU
+ help
+ Use a blocksize of (1K) instead of the default 512b.
+
+config BUSYBOX_CONFIG_ECHO
+ bool "echo (basic SuSv3 version taking no options)"
+ default y
+ help
+ echo is used to print a specified string to stdout.
+
+# this entry also appears in shell/Config.in, next to the echo builtin
+config BUSYBOX_CONFIG_FEATURE_FANCY_ECHO
+ bool "Enable echo options (-n and -e)"
+ default y
+ depends on BUSYBOX_CONFIG_ECHO || BUSYBOX_CONFIG_ASH_BUILTIN_ECHO || BUSYBOX_CONFIG_HUSH
+ help
+ This adds options (-n and -e) to echo.
+
+config BUSYBOX_CONFIG_ENV
+ bool "env"
+ default y
+ help
+ env is used to set an environment variable and run
+ a command; without options it displays the current
+ environment.
+
+config BUSYBOX_CONFIG_FEATURE_ENV_LONG_OPTIONS
+ bool "Enable long options"
+ default n
+ depends on BUSYBOX_CONFIG_ENV && BUSYBOX_CONFIG_LONG_OPTS
+ help
+ Support long options for the env applet.
+
+config BUSYBOX_CONFIG_EXPAND
+ bool "expand"
+ default n
+ help
+ By default, convert all tabs to spaces.
+
+config BUSYBOX_CONFIG_FEATURE_EXPAND_LONG_OPTIONS
+ bool "Enable long options"
+ default n
+ depends on BUSYBOX_CONFIG_EXPAND && BUSYBOX_CONFIG_LONG_OPTS
+ help
+ Support long options for the expand applet.
+
+config BUSYBOX_CONFIG_EXPR
+ bool "expr"
+ default y
+ help
+ expr is used to calculate numbers and print the result
+ to standard output.
+
+config BUSYBOX_CONFIG_EXPR_MATH_SUPPORT_64
+ bool "Extend Posix numbers support to 64 bit"
+ default y
+ depends on BUSYBOX_CONFIG_EXPR
+ help
+ Enable 64-bit math support in the expr applet. This will make
+ the applet slightly larger, but will allow computation with very
+ large numbers.
+
+config BUSYBOX_CONFIG_FALSE
+ bool "false"
+ default y
+ help
+ false returns an exit code of FALSE (1).
+
+config BUSYBOX_CONFIG_FOLD
+ bool "fold"
+ default n
+ help
+ Wrap text to fit a specific width.
+
+config BUSYBOX_CONFIG_FSYNC
+ bool "fsync"
+ default y
+ help
+ fsync is used to flush file-related cached blocks to disk.
+
+config BUSYBOX_CONFIG_HEAD
+ bool "head"
+ default y
+ help
+ head is used to print the first specified number of lines
+ from files.
+
+config BUSYBOX_CONFIG_FEATURE_FANCY_HEAD
+ bool "Enable head options (-c, -q, and -v)"
+ default y
+ depends on BUSYBOX_CONFIG_HEAD
+ help
+ This enables the head options (-c, -q, and -v).
+
+config BUSYBOX_CONFIG_HOSTID
+ bool "hostid"
+ default y
+ help
+ hostid prints the numeric identifier (in hexadecimal) for
+ the current host.
+
+config BUSYBOX_CONFIG_INSTALL
+ bool "install"
+ default n
+ help
+ Copy files and set attributes.
+
+config BUSYBOX_CONFIG_FEATURE_INSTALL_LONG_OPTIONS
+ bool "Enable long options"
+ default n
+ depends on BUSYBOX_CONFIG_INSTALL && BUSYBOX_CONFIG_LONG_OPTS
+ help
+ Support long options for the install applet.
+
+####config LENGTH
+#### bool "length"
+#### default y
+#### help
+#### length is used to print out the length of a specified string.
+
+config BUSYBOX_CONFIG_LN
+ bool "ln"
+ default y
+ help
+ ln is used to create hard or soft links between files.
+
+config BUSYBOX_CONFIG_LOGNAME
+ bool "logname"
+ default n
+ help
+ logname is used to print the current user's login name.
+
+config BUSYBOX_CONFIG_LS
+ bool "ls"
+ default y
+ help
+ ls is used to list the contents of directories.
+
+config BUSYBOX_CONFIG_FEATURE_LS_FILETYPES
+ bool "Enable filetyping options (-p and -F)"
+ default y
+ depends on BUSYBOX_CONFIG_LS
+ help
+ Enable the ls options (-p and -F).
+
+config BUSYBOX_CONFIG_FEATURE_LS_FOLLOWLINKS
+ bool "Enable symlinks dereferencing (-L)"
+ default y
+ depends on BUSYBOX_CONFIG_LS
+ help
+ Enable the ls option (-L).
+
+config BUSYBOX_CONFIG_FEATURE_LS_RECURSIVE
+ bool "Enable recursion (-R)"
+ default y
+ depends on BUSYBOX_CONFIG_LS
+ help
+ Enable the ls option (-R).
+
+config BUSYBOX_CONFIG_FEATURE_LS_SORTFILES
+ bool "Sort the file names"
+ default y
+ depends on BUSYBOX_CONFIG_LS
+ help
+ Allow ls to sort file names alphabetically.
+
+config BUSYBOX_CONFIG_FEATURE_LS_TIMESTAMPS
+ bool "Show file timestamps"
+ default y
+ depends on BUSYBOX_CONFIG_LS
+ help
+ Allow ls to display timestamps for files.
+
+config BUSYBOX_CONFIG_FEATURE_LS_USERNAME
+ bool "Show username/groupnames"
+ default y
+ depends on BUSYBOX_CONFIG_LS
+ help
+ Allow ls to display username/groupname for files.
+
+config BUSYBOX_CONFIG_FEATURE_LS_COLOR
+ bool "Allow use of color to identify file types"
+ default y
+ depends on BUSYBOX_CONFIG_LS && BUSYBOX_CONFIG_LONG_OPTS
+ help
+ This enables the --color option to ls.
+
+config BUSYBOX_CONFIG_FEATURE_LS_COLOR_IS_DEFAULT
+ bool "Produce colored ls output by default"
+ default y
+ depends on BUSYBOX_CONFIG_FEATURE_LS_COLOR
+ help
+ Saying yes here will turn coloring on by default,
+ even if no "--color" option is given to the ls command.
+ This is not recommended, since the colors are not
+ configurable, and the output may not be legible on
+ many output screens.
+
+config BUSYBOX_CONFIG_MD5SUM
+ bool "md5sum"
+ default y
+ help
+ md5sum is used to print or check MD5 checksums.
+
+config BUSYBOX_CONFIG_MKDIR
+ bool "mkdir"
+ default y
+ help
+ mkdir is used to create directories with the specified names.
+
+config BUSYBOX_CONFIG_FEATURE_MKDIR_LONG_OPTIONS
+ bool "Enable long options"
+ default n
+ depends on BUSYBOX_CONFIG_MKDIR && BUSYBOX_CONFIG_LONG_OPTS
+ help
+ Support long options for the mkdir applet.
+
+config BUSYBOX_CONFIG_MKFIFO
+ bool "mkfifo"
+ default y
+ help
+ mkfifo is used to create FIFOs (named pipes).
+ The `mknod' program can also create FIFOs.
+
+config BUSYBOX_CONFIG_MKNOD
+ bool "mknod"
+ default y
+ help
+ mknod is used to create FIFOs or block/character special
+ files with the specified names.
+
+config BUSYBOX_CONFIG_MV
+ bool "mv"
+ default y
+ help
+ mv is used to move or rename files or directories.
+
+config BUSYBOX_CONFIG_FEATURE_MV_LONG_OPTIONS
+ bool "Enable long options"
+ default n
+ depends on BUSYBOX_CONFIG_MV && BUSYBOX_CONFIG_LONG_OPTS
+ help
+ Support long options for the mv applet.
+
+config BUSYBOX_CONFIG_NICE
+ bool "nice"
+ default y
+ help
+ nice runs a program with modified scheduling priority.
+
+config BUSYBOX_CONFIG_NOHUP
+ bool "nohup"
+ default n
+ help
+ run a command immune to hangups, with output to a non-tty.
+
+config BUSYBOX_CONFIG_OD
+ bool "od"
+ default n
+ help
+ od is used to dump binary files in octal and other formats.
+
+config BUSYBOX_CONFIG_PRINTENV
+ bool "printenv"
+ default n
+ help
+ printenv is used to print all or part of environment.
+
+config BUSYBOX_CONFIG_PRINTF
+ bool "printf"
+ default y
+ help
+ printf is used to format and print specified strings.
+ It's similar to `echo' except it has more options.
+
+config BUSYBOX_CONFIG_PWD
+ bool "pwd"
+ default y
+ help
+ pwd is used to print the current directory.
+
+config BUSYBOX_CONFIG_READLINK
+ bool "readlink"
+ default y
+ help
+ This program reads a symbolic link and returns the name
+ of the file it points to
+
+config BUSYBOX_CONFIG_FEATURE_READLINK_FOLLOW
+ bool "Enable canonicalization by following all symlinks (-f)"
+ default y
+ depends on BUSYBOX_CONFIG_READLINK
+ help
+ Enable the readlink option (-f).
+
+config BUSYBOX_CONFIG_REALPATH
+ bool "realpath"
+ default n
+ help
+ Return the canonicalized absolute pathname.
+ This isn't provided by GNU shellutils, but where else does it belong.
+
+config BUSYBOX_CONFIG_RM
+ bool "rm"
+ default y
+ help
+ rm is used to remove files or directories.
+
+config BUSYBOX_CONFIG_RMDIR
+ bool "rmdir"
+ default y
+ help
+ rmdir is used to remove empty directories.
+
+config BUSYBOX_CONFIG_FEATURE_RMDIR_LONG_OPTIONS
+ bool "Enable long options"
+ default n
+ depends on BUSYBOX_CONFIG_RMDIR && BUSYBOX_CONFIG_LONG_OPTS
+ help
+ Support long options for the rmdir applet, including
+ --ignore-fail-on-non-empty for compatibility with GNU rmdir.
+
+config BUSYBOX_CONFIG_SEQ
+ bool "seq"
+ default y
+ help
+ print a sequence of numbers
+
+config BUSYBOX_CONFIG_SHA1SUM
+ bool "sha1sum"
+ default n
+ help
+ Compute and check SHA1 message digest
+
+config BUSYBOX_CONFIG_SHA256SUM
+ bool "sha256sum"
+ default n
+ help
+ Compute and check SHA256 message digest
+
+config BUSYBOX_CONFIG_SHA512SUM
+ bool "sha512sum"
+ default n
+ help
+ Compute and check SHA512 message digest
+
+config BUSYBOX_CONFIG_SLEEP
+ bool "sleep"
+ default y
+ help
+ sleep is used to pause for a specified number of seconds.
+ It comes in 3 versions:
+ - small: takes one integer parameter
+ - fancy: takes multiple integer arguments with suffixes:
+ sleep 1d 2h 3m 15s
+ - fancy with fractional numbers:
+ sleep 2.3s 4.5h sleeps for 16202.3 seconds
+ Last one is "the most compatible" with coreutils sleep,
+ but it adds around 1k of code.
+
+config BUSYBOX_CONFIG_FEATURE_FANCY_SLEEP
+ bool "Enable multiple arguments and s/m/h/d suffixes"
+ default y
+ depends on BUSYBOX_CONFIG_SLEEP
+ help
+ Allow sleep to pause for specified minutes, hours, and days.
+
+config BUSYBOX_CONFIG_FEATURE_FLOAT_SLEEP
+ bool "Enable fractional arguments"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_FANCY_SLEEP
+ help
+ Allow for fractional numeric parameters.
+
+config BUSYBOX_CONFIG_SORT
+ bool "sort"
+ default y
+ help
+ sort is used to sort lines of text in specified files.
+
+config BUSYBOX_CONFIG_FEATURE_SORT_BIG
+ bool "Full SuSv3 compliant sort (support -ktcsbdfiozgM)"
+ default n
+ depends on BUSYBOX_CONFIG_SORT
+ help
+ Without this, sort only supports -r, -u, and an integer version
+ of -n. Selecting this adds sort keys, floating point support, and
+ more. This adds a little over 3k to a nonstatic build on x86.
+
+ The SuSv3 sort standard is available at:
+ http://www.opengroup.org/onlinepubs/007904975/utilities/sort.html
+
+config BUSYBOX_CONFIG_SPLIT
+ bool "split"
+ default n
+ help
+ split a file into pieces.
+
+config BUSYBOX_CONFIG_FEATURE_SPLIT_FANCY
+ bool "Fancy extensions"
+ default n
+ depends on BUSYBOX_CONFIG_SPLIT
+ help
+ Add support for features not required by SUSv3.
+ Supports additional suffixes 'b' for 512 bytes,
+ 'g' for 1GiB for the -b option.
+
+config BUSYBOX_CONFIG_STAT
+ bool "stat"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX # statfs()
+ help
+ display file or filesystem status.
+
+config BUSYBOX_CONFIG_FEATURE_STAT_FORMAT
+ bool "Enable custom formats (-c)"
+ default n
+ depends on BUSYBOX_CONFIG_STAT
+ help
+ Without this, stat will not support the '-c format' option where
+ users can pass a custom format string for output. This adds about
+ 7k to a nonstatic build on amd64.
+
+config BUSYBOX_CONFIG_STTY
+ bool "stty"
+ default n
+ help
+ stty is used to change and print terminal line settings.
+
+config BUSYBOX_CONFIG_SUM
+ bool "sum"
+ default n
+ help
+ checksum and count the blocks in a file
+
+config BUSYBOX_CONFIG_SYNC
+ bool "sync"
+ default y
+ help
+ sync is used to flush filesystem buffers.
+
+config BUSYBOX_CONFIG_TAC
+ bool "tac"
+ default n
+ help
+ tac is used to concatenate and print files in reverse.
+
+config BUSYBOX_CONFIG_TAIL
+ bool "tail"
+ default y
+ help
+ tail is used to print the last specified number of lines
+ from files.
+
+config BUSYBOX_CONFIG_FEATURE_FANCY_TAIL
+ bool "Enable extra tail options (-q, -s, -v, and -F)"
+ default y
+ depends on BUSYBOX_CONFIG_TAIL
+ help
+ The options (-q, -s, and -v) are provided by GNU tail, but
+ are not specific in the SUSv3 standard.
+
+ -q Never output headers giving file names
+ -s SEC Wait SEC seconds between reads with -f
+ -v Always output headers giving file names
+
+config BUSYBOX_CONFIG_TEE
+ bool "tee"
+ default y
+ help
+ tee is used to read from standard input and write
+ to standard output and files.
+
+config BUSYBOX_CONFIG_FEATURE_TEE_USE_BLOCK_IO
+ bool "Enable block I/O (larger/faster) instead of byte I/O"
+ default y
+ depends on BUSYBOX_CONFIG_TEE
+ help
+ Enable this option for a faster tee, at expense of size.
+
+config BUSYBOX_CONFIG_TRUE
+ bool "true"
+ default y
+ help
+ true returns an exit code of TRUE (0).
+
+config BUSYBOX_CONFIG_TTY
+ bool "tty"
+ default n
+ help
+ tty is used to print the name of the current terminal to
+ standard output.
+
+config BUSYBOX_CONFIG_UNAME
+ bool "uname"
+ default y
+ help
+ uname is used to print system information.
+
+config BUSYBOX_CONFIG_UNEXPAND
+ bool "unexpand"
+ default n
+ help
+ By default, convert only leading sequences of blanks to tabs.
+
+config BUSYBOX_CONFIG_FEATURE_UNEXPAND_LONG_OPTIONS
+ bool "Enable long options"
+ default n
+ depends on BUSYBOX_CONFIG_UNEXPAND && BUSYBOX_CONFIG_LONG_OPTS
+ help
+ Support long options for the unexpand applet.
+
+config BUSYBOX_CONFIG_UNIQ
+ bool "uniq"
+ default y
+ help
+ uniq is used to remove duplicate lines from a sorted file.
+
+config BUSYBOX_CONFIG_USLEEP
+ bool "usleep"
+ default n
+ help
+ usleep is used to pause for a specified number of microseconds.
+
+config BUSYBOX_CONFIG_UUDECODE
+ bool "uudecode"
+ default n
+ help
+ uudecode is used to decode a uuencoded file.
+
+config BUSYBOX_CONFIG_UUENCODE
+ bool "uuencode"
+ default n
+ help
+ uuencode is used to uuencode a file.
+
+config BUSYBOX_CONFIG_WC
+ bool "wc"
+ default y
+ help
+ wc is used to print the number of bytes, words, and lines,
+ in specified files.
+
+config BUSYBOX_CONFIG_FEATURE_WC_LARGE
+ bool "Support very large files in wc"
+ default n
+ depends on BUSYBOX_CONFIG_WC
+ help
+ Use "unsigned long long" in wc for counter variables.
+
+config BUSYBOX_CONFIG_WHOAMI
+ bool "whoami"
+ default n
+ help
+ whoami is used to print the username of the current
+ user id (same as id -un).
+
+config BUSYBOX_CONFIG_YES
+ bool "yes"
+ default y
+ help
+ yes is used to repeatedly output a specific string, or
+ the default string `y'.
+
+comment "Common options for cp and mv"
+ depends on BUSYBOX_CONFIG_CP || BUSYBOX_CONFIG_MV
+
+config BUSYBOX_CONFIG_FEATURE_PRESERVE_HARDLINKS
+ bool "Preserve hard links"
+ default y
+ depends on BUSYBOX_CONFIG_CP || BUSYBOX_CONFIG_MV
+ help
+ Allow cp and mv to preserve hard links.
+
+comment "Common options for ls, more and telnet"
+ depends on BUSYBOX_CONFIG_LS || BUSYBOX_CONFIG_MORE || BUSYBOX_CONFIG_TELNET
+
+config BUSYBOX_CONFIG_FEATURE_AUTOWIDTH
+ bool "Calculate terminal & column widths"
+ default y
+ depends on BUSYBOX_CONFIG_LS || BUSYBOX_CONFIG_MORE || BUSYBOX_CONFIG_TELNET
+ help
+ This option allows utilities such as 'ls', 'more' and 'telnet'
+ to determine the width of the screen, which can allow them to
+ display additional text or avoid wrapping text onto the next line.
+ If you leave this disabled, your utilities will be especially
+ primitive and will be unable to determine the current screen width.
+
+comment "Common options for df, du, ls"
+ depends on BUSYBOX_CONFIG_DF || BUSYBOX_CONFIG_DU || BUSYBOX_CONFIG_LS
+
+config BUSYBOX_CONFIG_FEATURE_HUMAN_READABLE
+ bool "Support for human readable output (example 13k, 23M, 235G)"
+ default y
+ depends on BUSYBOX_CONFIG_DF || BUSYBOX_CONFIG_DU || BUSYBOX_CONFIG_LS
+ help
+ Allow df, du, and ls to have human readable output.
+
+comment "Common options for md5sum, sha1sum, sha256sum, sha512sum"
+ depends on BUSYBOX_CONFIG_MD5SUM || BUSYBOX_CONFIG_SHA1SUM || BUSYBOX_CONFIG_SHA256SUM || BUSYBOX_CONFIG_SHA512SUM
+
+config BUSYBOX_CONFIG_FEATURE_MD5_SHA1_SUM_CHECK
+ bool "Enable -c, -s and -w options"
+ default y
+ depends on BUSYBOX_CONFIG_MD5SUM || BUSYBOX_CONFIG_SHA1SUM || BUSYBOX_CONFIG_SHA256SUM || BUSYBOX_CONFIG_SHA512SUM
+ help
+ Enabling the -c options allows files to be checked
+ against pre-calculated hash values.
+
+ -s and -w are useful options when verifying checksums.
+
+endmenu
diff --git a/package/busybox/config/coreutils/Config.in b/package/busybox/config/coreutils/Config.in
new file mode 100644
index 0000000..33a5e25
--- /dev/null
+++ b/package/busybox/config/coreutils/Config.in
@@ -0,0 +1,913 @@
+# DO NOT EDIT. This file is generated from Config.src
+#
+# For a description of the syntax of this configuration file,
+# see scripts/kbuild/config-language.txt.
+#
+
+menu "Coreutils"
+
+config BUSYBOX_CONFIG_BASENAME
+ bool "basename"
+ default y
+ help
+ basename is used to strip the directory and suffix from filenames,
+ leaving just the filename itself. Enable this option if you wish
+ to enable the 'basename' utility.
+config BUSYBOX_CONFIG_CAT
+ bool "cat"
+ default y
+ help
+ cat is used to concatenate files and print them to the standard
+ output. Enable this option if you wish to enable the 'cat' utility.
+config BUSYBOX_CONFIG_DATE
+ bool "date"
+ default y
+ help
+ date is used to set the system date or display the
+ current time in the given format.
+
+config BUSYBOX_CONFIG_FEATURE_DATE_ISOFMT
+ bool "Enable ISO date format output (-I)"
+ default y
+ depends on BUSYBOX_CONFIG_DATE
+ help
+ Enable option (-I) to output an ISO-8601 compliant
+ date/time string.
+
+# defaults to "no": stat's nanosecond field is a bit non-portable
+config BUSYBOX_CONFIG_FEATURE_DATE_NANO
+ bool "Support %[num]N nanosecond format specifier"
+ default n
+ depends on BUSYBOX_CONFIG_DATE # syscall(__NR_clock_gettime)
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Support %[num]N format specifier. Adds ~250 bytes of code.
+
+config BUSYBOX_CONFIG_FEATURE_DATE_COMPAT
+ bool "Support weird 'date MMDDhhmm[[YY]YY][.ss]' format"
+ default n
+ depends on BUSYBOX_CONFIG_DATE
+ help
+ System time can be set by 'date -s DATE' and simply 'date DATE',
+ but formats of DATE string are different. 'date DATE' accepts
+ a rather weird MMDDhhmm[[YY]YY][.ss] format with completely
+ unnatural placement of year between minutes and seconds.
+ date -s (and other commands like touch -d) use more sensible
+ formats (for one, ISO format YYYY-MM-DD hh:mm:ss.ssssss).
+
+ With this option off, 'date DATE' is 'date -s DATE' support
+ the same format. With it on, 'date DATE' additionally supports
+ MMDDhhmm[[YY]YY][.ss] format.
+config BUSYBOX_CONFIG_ID
+ bool "id"
+ default y
+ help
+ id displays the current user and group ID names.
+config BUSYBOX_CONFIG_GROUPS
+ bool "groups"
+ default n
+ help
+ Print the group names associated with current user id.
+config BUSYBOX_CONFIG_TEST
+ bool "test"
+ default y
+ help
+ test is used to check file types and compare values,
+ returning an appropriate exit code. The bash shell
+ has test built in, ash can build it in optionally.
+
+config BUSYBOX_CONFIG_FEATURE_TEST_64
+ bool "Extend test to 64 bit"
+ default y
+ depends on BUSYBOX_CONFIG_TEST || BUSYBOX_CONFIG_ASH_BUILTIN_TEST || BUSYBOX_CONFIG_HUSH
+ help
+ Enable 64-bit support in test.
+config BUSYBOX_CONFIG_TOUCH
+ bool "touch"
+ default y
+ help
+ touch is used to create or change the access and/or
+ modification timestamp of specified files.
+config BUSYBOX_CONFIG_TR
+ bool "tr"
+ default y
+ help
+ tr is used to squeeze, and/or delete characters from standard
+ input, writing to standard output.
+
+config BUSYBOX_CONFIG_FEATURE_TR_CLASSES
+ bool "Enable character classes (such as [:upper:])"
+ default n
+ depends on BUSYBOX_CONFIG_TR
+ help
+ Enable character classes, enabling commands such as:
+ tr [:upper:] [:lower:] to convert input into lowercase.
+
+config BUSYBOX_CONFIG_FEATURE_TR_EQUIV
+ bool "Enable equivalence classes"
+ default n
+ depends on BUSYBOX_CONFIG_TR
+ help
+ Enable equivalence classes, which essentially add the enclosed
+ character to the current set. For instance, tr [=a=] xyz would
+ replace all instances of 'a' with 'xyz'. This option is mainly
+ useful for cases when no other way of expressing a character
+ is possible.
+config BUSYBOX_CONFIG_BASE64
+ bool "base64"
+ default n
+ help
+ Base64 encode and decode
+config BUSYBOX_CONFIG_WHO
+ bool "who"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_UTMP
+ help
+ who is used to show who is logged on.
+config BUSYBOX_CONFIG_USERS
+ bool "users"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_UTMP
+ help
+ Print users currently logged on.
+
+config BUSYBOX_CONFIG_CAL
+ bool "cal"
+ default n
+ help
+ cal is used to display a monthly calender.
+
+config BUSYBOX_CONFIG_CATV
+ bool "catv"
+ default n
+ help
+ Display nonprinting characters as escape sequences (like some
+ implementations' cat -v option).
+
+config BUSYBOX_CONFIG_CHGRP
+ bool "chgrp"
+ default y
+ help
+ chgrp is used to change the group ownership of files.
+
+config BUSYBOX_CONFIG_CHMOD
+ bool "chmod"
+ default y
+ help
+ chmod is used to change the access permission of files.
+
+config BUSYBOX_CONFIG_CHOWN
+ bool "chown"
+ default y
+ help
+ chown is used to change the user and/or group ownership
+ of files.
+
+config BUSYBOX_CONFIG_FEATURE_CHOWN_LONG_OPTIONS
+ bool "Enable long options"
+ default n
+ depends on BUSYBOX_CONFIG_CHOWN && BUSYBOX_CONFIG_LONG_OPTS
+ help
+ Enable use of long options
+
+config BUSYBOX_CONFIG_CHROOT
+ bool "chroot"
+ default y
+ help
+ chroot is used to change the root directory and run a command.
+ The default command is `/bin/sh'.
+
+config BUSYBOX_CONFIG_CKSUM
+ bool "cksum"
+ default n
+ help
+ cksum is used to calculate the CRC32 checksum of a file.
+
+config BUSYBOX_CONFIG_COMM
+ bool "comm"
+ default n
+ help
+ comm is used to compare two files line by line and return
+ a three-column output.
+
+config BUSYBOX_CONFIG_CP
+ bool "cp"
+ default y
+ help
+ cp is used to copy files and directories.
+
+config BUSYBOX_CONFIG_FEATURE_CP_LONG_OPTIONS
+ bool "Enable long options for cp"
+ default n
+ depends on BUSYBOX_CONFIG_CP && BUSYBOX_CONFIG_LONG_OPTS
+ help
+ Enable long options for cp.
+ Also add support for --parents option.
+
+config BUSYBOX_CONFIG_CUT
+ bool "cut"
+ default y
+ help
+ cut is used to print selected parts of lines from
+ each file to stdout.
+
+config BUSYBOX_CONFIG_DD
+ bool "dd"
+ default y
+ help
+ dd copies a file (from standard input to standard output,
+ by default) using specific input and output blocksizes,
+ while optionally performing conversions on it.
+
+config BUSYBOX_CONFIG_FEATURE_DD_SIGNAL_HANDLING
+ bool "Enable DD signal handling for status reporting"
+ default y
+ depends on BUSYBOX_CONFIG_DD
+ help
+ Sending a SIGUSR1 signal to a running `dd' process makes it
+ print to standard error the number of records read and written
+ so far, then to resume copying.
+
+ $ dd if=/dev/zero of=/dev/null&
+ $ pid=$! kill -USR1 $pid; sleep 1; kill $pid
+ 10899206+0 records in
+ 10899206+0 records out
+
+config BUSYBOX_CONFIG_FEATURE_DD_THIRD_STATUS_LINE
+ bool "Enable the third status line upon signal"
+ default n
+ depends on BUSYBOX_CONFIG_DD && BUSYBOX_CONFIG_FEATURE_DD_SIGNAL_HANDLING
+ help
+ Displays a coreutils-like third status line with transferred bytes,
+ elapsed time and speed.
+
+config BUSYBOX_CONFIG_FEATURE_DD_IBS_OBS
+ bool "Enable ibs, obs and conv options"
+ default y
+ depends on BUSYBOX_CONFIG_DD
+ help
+ Enables support for writing a certain number of bytes in and out,
+ at a time, and performing conversions on the data stream.
+
+config BUSYBOX_CONFIG_DF
+ bool "df"
+ default y
+ help
+ df reports the amount of disk space used and available
+ on filesystems.
+
+config BUSYBOX_CONFIG_FEATURE_DF_FANCY
+ bool "Enable -a, -i, -B"
+ default n
+ depends on BUSYBOX_CONFIG_DF
+ help
+ This option enables -a, -i and -B.
+
+ -a Show all filesystems
+ -i Inodes
+ -B <SIZE> Blocksize
+
+config BUSYBOX_CONFIG_DIRNAME
+ bool "dirname"
+ default y
+ help
+ dirname is used to strip a non-directory suffix from
+ a file name.
+
+config BUSYBOX_CONFIG_DOS2UNIX
+ bool "dos2unix/unix2dos"
+ default n
+ help
+ dos2unix is used to convert a text file from DOS format to
+ UNIX format, and vice versa.
+
+config BUSYBOX_CONFIG_UNIX2DOS
+ bool
+ default n
+ depends on BUSYBOX_CONFIG_DOS2UNIX
+ help
+ unix2dos is used to convert a text file from UNIX format to
+ DOS format, and vice versa.
+
+config BUSYBOX_CONFIG_DU
+ bool "du (default blocksize of 512 bytes)"
+ default y
+ help
+ du is used to report the amount of disk space used
+ for specified files.
+
+config BUSYBOX_CONFIG_FEATURE_DU_DEFAULT_BLOCKSIZE_1K
+ bool "Use a default blocksize of 1024 bytes (1K)"
+ default y
+ depends on BUSYBOX_CONFIG_DU
+ help
+ Use a blocksize of (1K) instead of the default 512b.
+
+config BUSYBOX_CONFIG_ECHO
+ bool "echo (basic SuSv3 version taking no options)"
+ default y
+ help
+ echo is used to print a specified string to stdout.
+
+# this entry also appears in shell/Config.in, next to the echo builtin
+config BUSYBOX_CONFIG_FEATURE_FANCY_ECHO
+ bool "Enable echo options (-n and -e)"
+ default y
+ depends on BUSYBOX_CONFIG_ECHO || BUSYBOX_CONFIG_ASH_BUILTIN_ECHO || BUSYBOX_CONFIG_HUSH
+ help
+ This adds options (-n and -e) to echo.
+
+config BUSYBOX_CONFIG_ENV
+ bool "env"
+ default y
+ help
+ env is used to set an environment variable and run
+ a command; without options it displays the current
+ environment.
+
+config BUSYBOX_CONFIG_FEATURE_ENV_LONG_OPTIONS
+ bool "Enable long options"
+ default n
+ depends on BUSYBOX_CONFIG_ENV && BUSYBOX_CONFIG_LONG_OPTS
+ help
+ Support long options for the env applet.
+
+config BUSYBOX_CONFIG_EXPAND
+ bool "expand"
+ default n
+ help
+ By default, convert all tabs to spaces.
+
+config BUSYBOX_CONFIG_FEATURE_EXPAND_LONG_OPTIONS
+ bool "Enable long options"
+ default n
+ depends on BUSYBOX_CONFIG_EXPAND && BUSYBOX_CONFIG_LONG_OPTS
+ help
+ Support long options for the expand applet.
+
+config BUSYBOX_CONFIG_EXPR
+ bool "expr"
+ default y
+ help
+ expr is used to calculate numbers and print the result
+ to standard output.
+
+config BUSYBOX_CONFIG_EXPR_MATH_SUPPORT_64
+ bool "Extend Posix numbers support to 64 bit"
+ default y
+ depends on BUSYBOX_CONFIG_EXPR
+ help
+ Enable 64-bit math support in the expr applet. This will make
+ the applet slightly larger, but will allow computation with very
+ large numbers.
+
+config BUSYBOX_CONFIG_FALSE
+ bool "false"
+ default y
+ help
+ false returns an exit code of FALSE (1).
+
+config BUSYBOX_CONFIG_FOLD
+ bool "fold"
+ default n
+ help
+ Wrap text to fit a specific width.
+
+config BUSYBOX_CONFIG_FSYNC
+ bool "fsync"
+ default y
+ help
+ fsync is used to flush file-related cached blocks to disk.
+
+config BUSYBOX_CONFIG_HEAD
+ bool "head"
+ default y
+ help
+ head is used to print the first specified number of lines
+ from files.
+
+config BUSYBOX_CONFIG_FEATURE_FANCY_HEAD
+ bool "Enable head options (-c, -q, and -v)"
+ default y
+ depends on BUSYBOX_CONFIG_HEAD
+ help
+ This enables the head options (-c, -q, and -v).
+
+config BUSYBOX_CONFIG_HOSTID
+ bool "hostid"
+ default y
+ help
+ hostid prints the numeric identifier (in hexadecimal) for
+ the current host.
+
+config BUSYBOX_CONFIG_INSTALL
+ bool "install"
+ default n
+ help
+ Copy files and set attributes.
+
+config BUSYBOX_CONFIG_FEATURE_INSTALL_LONG_OPTIONS
+ bool "Enable long options"
+ default n
+ depends on BUSYBOX_CONFIG_INSTALL && BUSYBOX_CONFIG_LONG_OPTS
+ help
+ Support long options for the install applet.
+
+####config LENGTH
+#### bool "length"
+#### default y
+#### help
+#### length is used to print out the length of a specified string.
+
+config BUSYBOX_CONFIG_LN
+ bool "ln"
+ default y
+ help
+ ln is used to create hard or soft links between files.
+
+config BUSYBOX_CONFIG_LOGNAME
+ bool "logname"
+ default n
+ help
+ logname is used to print the current user's login name.
+
+config BUSYBOX_CONFIG_LS
+ bool "ls"
+ default y
+ help
+ ls is used to list the contents of directories.
+
+config BUSYBOX_CONFIG_FEATURE_LS_FILETYPES
+ bool "Enable filetyping options (-p and -F)"
+ default y
+ depends on BUSYBOX_CONFIG_LS
+ help
+ Enable the ls options (-p and -F).
+
+config BUSYBOX_CONFIG_FEATURE_LS_FOLLOWLINKS
+ bool "Enable symlinks dereferencing (-L)"
+ default y
+ depends on BUSYBOX_CONFIG_LS
+ help
+ Enable the ls option (-L).
+
+config BUSYBOX_CONFIG_FEATURE_LS_RECURSIVE
+ bool "Enable recursion (-R)"
+ default y
+ depends on BUSYBOX_CONFIG_LS
+ help
+ Enable the ls option (-R).
+
+config BUSYBOX_CONFIG_FEATURE_LS_SORTFILES
+ bool "Sort the file names"
+ default y
+ depends on BUSYBOX_CONFIG_LS
+ help
+ Allow ls to sort file names alphabetically.
+
+config BUSYBOX_CONFIG_FEATURE_LS_TIMESTAMPS
+ bool "Show file timestamps"
+ default y
+ depends on BUSYBOX_CONFIG_LS
+ help
+ Allow ls to display timestamps for files.
+
+config BUSYBOX_CONFIG_FEATURE_LS_USERNAME
+ bool "Show username/groupnames"
+ default y
+ depends on BUSYBOX_CONFIG_LS
+ help
+ Allow ls to display username/groupname for files.
+
+config BUSYBOX_CONFIG_FEATURE_LS_COLOR
+ bool "Allow use of color to identify file types"
+ default y
+ depends on BUSYBOX_CONFIG_LS && BUSYBOX_CONFIG_LONG_OPTS
+ help
+ This enables the --color option to ls.
+
+config BUSYBOX_CONFIG_FEATURE_LS_COLOR_IS_DEFAULT
+ bool "Produce colored ls output by default"
+ default y
+ depends on BUSYBOX_CONFIG_FEATURE_LS_COLOR
+ help
+ Saying yes here will turn coloring on by default,
+ even if no "--color" option is given to the ls command.
+ This is not recommended, since the colors are not
+ configurable, and the output may not be legible on
+ many output screens.
+
+config BUSYBOX_CONFIG_MD5SUM
+ bool "md5sum"
+ default y
+ help
+ md5sum is used to print or check MD5 checksums.
+
+config BUSYBOX_CONFIG_MKDIR
+ bool "mkdir"
+ default y
+ help
+ mkdir is used to create directories with the specified names.
+
+config BUSYBOX_CONFIG_FEATURE_MKDIR_LONG_OPTIONS
+ bool "Enable long options"
+ default n
+ depends on BUSYBOX_CONFIG_MKDIR && BUSYBOX_CONFIG_LONG_OPTS
+ help
+ Support long options for the mkdir applet.
+
+config BUSYBOX_CONFIG_MKFIFO
+ bool "mkfifo"
+ default y
+ help
+ mkfifo is used to create FIFOs (named pipes).
+ The `mknod' program can also create FIFOs.
+
+config BUSYBOX_CONFIG_MKNOD
+ bool "mknod"
+ default y
+ help
+ mknod is used to create FIFOs or block/character special
+ files with the specified names.
+
+config BUSYBOX_CONFIG_MV
+ bool "mv"
+ default y
+ help
+ mv is used to move or rename files or directories.
+
+config BUSYBOX_CONFIG_FEATURE_MV_LONG_OPTIONS
+ bool "Enable long options"
+ default n
+ depends on BUSYBOX_CONFIG_MV && BUSYBOX_CONFIG_LONG_OPTS
+ help
+ Support long options for the mv applet.
+
+config BUSYBOX_CONFIG_NICE
+ bool "nice"
+ default y
+ help
+ nice runs a program with modified scheduling priority.
+
+config BUSYBOX_CONFIG_NOHUP
+ bool "nohup"
+ default n
+ help
+ run a command immune to hangups, with output to a non-tty.
+
+config BUSYBOX_CONFIG_OD
+ bool "od"
+ default n
+ help
+ od is used to dump binary files in octal and other formats.
+
+config BUSYBOX_CONFIG_PRINTENV
+ bool "printenv"
+ default n
+ help
+ printenv is used to print all or part of environment.
+
+config BUSYBOX_CONFIG_PRINTF
+ bool "printf"
+ default y
+ help
+ printf is used to format and print specified strings.
+ It's similar to `echo' except it has more options.
+
+config BUSYBOX_CONFIG_PWD
+ bool "pwd"
+ default y
+ help
+ pwd is used to print the current directory.
+
+config BUSYBOX_CONFIG_READLINK
+ bool "readlink"
+ default y
+ help
+ This program reads a symbolic link and returns the name
+ of the file it points to
+
+config BUSYBOX_CONFIG_FEATURE_READLINK_FOLLOW
+ bool "Enable canonicalization by following all symlinks (-f)"
+ default y
+ depends on BUSYBOX_CONFIG_READLINK
+ help
+ Enable the readlink option (-f).
+
+config BUSYBOX_CONFIG_REALPATH
+ bool "realpath"
+ default n
+ help
+ Return the canonicalized absolute pathname.
+ This isn't provided by GNU shellutils, but where else does it belong.
+
+config BUSYBOX_CONFIG_RM
+ bool "rm"
+ default y
+ help
+ rm is used to remove files or directories.
+
+config BUSYBOX_CONFIG_RMDIR
+ bool "rmdir"
+ default y
+ help
+ rmdir is used to remove empty directories.
+
+config BUSYBOX_CONFIG_FEATURE_RMDIR_LONG_OPTIONS
+ bool "Enable long options"
+ default n
+ depends on BUSYBOX_CONFIG_RMDIR && BUSYBOX_CONFIG_LONG_OPTS
+ help
+ Support long options for the rmdir applet, including
+ --ignore-fail-on-non-empty for compatibility with GNU rmdir.
+
+config BUSYBOX_CONFIG_SEQ
+ bool "seq"
+ default y
+ help
+ print a sequence of numbers
+
+config BUSYBOX_CONFIG_SHA1SUM
+ bool "sha1sum"
+ default n
+ help
+ Compute and check SHA1 message digest
+
+config BUSYBOX_CONFIG_SHA256SUM
+ bool "sha256sum"
+ default n
+ help
+ Compute and check SHA256 message digest
+
+config BUSYBOX_CONFIG_SHA512SUM
+ bool "sha512sum"
+ default n
+ help
+ Compute and check SHA512 message digest
+
+config BUSYBOX_CONFIG_SLEEP
+ bool "sleep"
+ default y
+ help
+ sleep is used to pause for a specified number of seconds.
+ It comes in 3 versions:
+ - small: takes one integer parameter
+ - fancy: takes multiple integer arguments with suffixes:
+ sleep 1d 2h 3m 15s
+ - fancy with fractional numbers:
+ sleep 2.3s 4.5h sleeps for 16202.3 seconds
+ Last one is "the most compatible" with coreutils sleep,
+ but it adds around 1k of code.
+
+config BUSYBOX_CONFIG_FEATURE_FANCY_SLEEP
+ bool "Enable multiple arguments and s/m/h/d suffixes"
+ default y
+ depends on BUSYBOX_CONFIG_SLEEP
+ help
+ Allow sleep to pause for specified minutes, hours, and days.
+
+config BUSYBOX_CONFIG_FEATURE_FLOAT_SLEEP
+ bool "Enable fractional arguments"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_FANCY_SLEEP
+ help
+ Allow for fractional numeric parameters.
+
+config BUSYBOX_CONFIG_SORT
+ bool "sort"
+ default y
+ help
+ sort is used to sort lines of text in specified files.
+
+config BUSYBOX_CONFIG_FEATURE_SORT_BIG
+ bool "Full SuSv3 compliant sort (support -ktcsbdfiozgM)"
+ default n
+ depends on BUSYBOX_CONFIG_SORT
+ help
+ Without this, sort only supports -r, -u, and an integer version
+ of -n. Selecting this adds sort keys, floating point support, and
+ more. This adds a little over 3k to a nonstatic build on x86.
+
+ The SuSv3 sort standard is available at:
+ http://www.opengroup.org/onlinepubs/007904975/utilities/sort.html
+
+config BUSYBOX_CONFIG_SPLIT
+ bool "split"
+ default n
+ help
+ split a file into pieces.
+
+config BUSYBOX_CONFIG_FEATURE_SPLIT_FANCY
+ bool "Fancy extensions"
+ default n
+ depends on BUSYBOX_CONFIG_SPLIT
+ help
+ Add support for features not required by SUSv3.
+ Supports additional suffixes 'b' for 512 bytes,
+ 'g' for 1GiB for the -b option.
+
+config BUSYBOX_CONFIG_STAT
+ bool "stat"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX # statfs()
+ help
+ display file or filesystem status.
+
+config BUSYBOX_CONFIG_FEATURE_STAT_FORMAT
+ bool "Enable custom formats (-c)"
+ default n
+ depends on BUSYBOX_CONFIG_STAT
+ help
+ Without this, stat will not support the '-c format' option where
+ users can pass a custom format string for output. This adds about
+ 7k to a nonstatic build on amd64.
+
+config BUSYBOX_CONFIG_STTY
+ bool "stty"
+ default n
+ help
+ stty is used to change and print terminal line settings.
+
+config BUSYBOX_CONFIG_SUM
+ bool "sum"
+ default n
+ help
+ checksum and count the blocks in a file
+
+config BUSYBOX_CONFIG_SYNC
+ bool "sync"
+ default y
+ help
+ sync is used to flush filesystem buffers.
+
+config BUSYBOX_CONFIG_TAC
+ bool "tac"
+ default n
+ help
+ tac is used to concatenate and print files in reverse.
+
+config BUSYBOX_CONFIG_TAIL
+ bool "tail"
+ default y
+ help
+ tail is used to print the last specified number of lines
+ from files.
+
+config BUSYBOX_CONFIG_FEATURE_FANCY_TAIL
+ bool "Enable extra tail options (-q, -s, -v, and -F)"
+ default y
+ depends on BUSYBOX_CONFIG_TAIL
+ help
+ The options (-q, -s, and -v) are provided by GNU tail, but
+ are not specific in the SUSv3 standard.
+
+ -q Never output headers giving file names
+ -s SEC Wait SEC seconds between reads with -f
+ -v Always output headers giving file names
+
+config BUSYBOX_CONFIG_TEE
+ bool "tee"
+ default y
+ help
+ tee is used to read from standard input and write
+ to standard output and files.
+
+config BUSYBOX_CONFIG_FEATURE_TEE_USE_BLOCK_IO
+ bool "Enable block I/O (larger/faster) instead of byte I/O"
+ default y
+ depends on BUSYBOX_CONFIG_TEE
+ help
+ Enable this option for a faster tee, at expense of size.
+
+config BUSYBOX_CONFIG_TRUE
+ bool "true"
+ default y
+ help
+ true returns an exit code of TRUE (0).
+
+config BUSYBOX_CONFIG_TTY
+ bool "tty"
+ default n
+ help
+ tty is used to print the name of the current terminal to
+ standard output.
+
+config BUSYBOX_CONFIG_UNAME
+ bool "uname"
+ default y
+ help
+ uname is used to print system information.
+
+config BUSYBOX_CONFIG_UNEXPAND
+ bool "unexpand"
+ default n
+ help
+ By default, convert only leading sequences of blanks to tabs.
+
+config BUSYBOX_CONFIG_FEATURE_UNEXPAND_LONG_OPTIONS
+ bool "Enable long options"
+ default n
+ depends on BUSYBOX_CONFIG_UNEXPAND && BUSYBOX_CONFIG_LONG_OPTS
+ help
+ Support long options for the unexpand applet.
+
+config BUSYBOX_CONFIG_UNIQ
+ bool "uniq"
+ default y
+ help
+ uniq is used to remove duplicate lines from a sorted file.
+
+config BUSYBOX_CONFIG_USLEEP
+ bool "usleep"
+ default n
+ help
+ usleep is used to pause for a specified number of microseconds.
+
+config BUSYBOX_CONFIG_UUDECODE
+ bool "uudecode"
+ default n
+ help
+ uudecode is used to decode a uuencoded file.
+
+config BUSYBOX_CONFIG_UUENCODE
+ bool "uuencode"
+ default n
+ help
+ uuencode is used to uuencode a file.
+
+config BUSYBOX_CONFIG_WC
+ bool "wc"
+ default y
+ help
+ wc is used to print the number of bytes, words, and lines,
+ in specified files.
+
+config BUSYBOX_CONFIG_FEATURE_WC_LARGE
+ bool "Support very large files in wc"
+ default n
+ depends on BUSYBOX_CONFIG_WC
+ help
+ Use "unsigned long long" in wc for counter variables.
+
+config BUSYBOX_CONFIG_WHOAMI
+ bool "whoami"
+ default n
+ help
+ whoami is used to print the username of the current
+ user id (same as id -un).
+
+config BUSYBOX_CONFIG_YES
+ bool "yes"
+ default y
+ help
+ yes is used to repeatedly output a specific string, or
+ the default string `y'.
+
+comment "Common options for cp and mv"
+ depends on BUSYBOX_CONFIG_CP || BUSYBOX_CONFIG_MV
+
+config BUSYBOX_CONFIG_FEATURE_PRESERVE_HARDLINKS
+ bool "Preserve hard links"
+ default y
+ depends on BUSYBOX_CONFIG_CP || BUSYBOX_CONFIG_MV
+ help
+ Allow cp and mv to preserve hard links.
+
+comment "Common options for ls, more and telnet"
+ depends on BUSYBOX_CONFIG_LS || BUSYBOX_CONFIG_MORE || BUSYBOX_CONFIG_TELNET
+
+config BUSYBOX_CONFIG_FEATURE_AUTOWIDTH
+ bool "Calculate terminal & column widths"
+ default y
+ depends on BUSYBOX_CONFIG_LS || BUSYBOX_CONFIG_MORE || BUSYBOX_CONFIG_TELNET
+ help
+ This option allows utilities such as 'ls', 'more' and 'telnet'
+ to determine the width of the screen, which can allow them to
+ display additional text or avoid wrapping text onto the next line.
+ If you leave this disabled, your utilities will be especially
+ primitive and will be unable to determine the current screen width.
+
+comment "Common options for df, du, ls"
+ depends on BUSYBOX_CONFIG_DF || BUSYBOX_CONFIG_DU || BUSYBOX_CONFIG_LS
+
+config BUSYBOX_CONFIG_FEATURE_HUMAN_READABLE
+ bool "Support for human readable output (example 13k, 23M, 235G)"
+ default y
+ depends on BUSYBOX_CONFIG_DF || BUSYBOX_CONFIG_DU || BUSYBOX_CONFIG_LS
+ help
+ Allow df, du, and ls to have human readable output.
+
+comment "Common options for md5sum, sha1sum, sha256sum, sha512sum"
+ depends on BUSYBOX_CONFIG_MD5SUM || BUSYBOX_CONFIG_SHA1SUM || BUSYBOX_CONFIG_SHA256SUM || BUSYBOX_CONFIG_SHA512SUM
+
+config BUSYBOX_CONFIG_FEATURE_MD5_SHA1_SUM_CHECK
+ bool "Enable -c, -s and -w options"
+ default y
+ depends on BUSYBOX_CONFIG_MD5SUM || BUSYBOX_CONFIG_SHA1SUM || BUSYBOX_CONFIG_SHA256SUM || BUSYBOX_CONFIG_SHA512SUM
+ help
+ Enabling the -c options allows files to be checked
+ against pre-calculated hash values.
+
+ -s and -w are useful options when verifying checksums.
+
+endmenu
diff --git a/package/busybox/config/debianutils/.svn/entries b/package/busybox/config/debianutils/.svn/entries
new file mode 100644
index 0000000..5572329
--- /dev/null
+++ b/package/busybox/config/debianutils/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/busybox/config/debianutils
+svn://svn.openwrt.org/openwrt
+
+
+
+2011-10-21T23:08:45.031764Z
+28513
+nico
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+Config.in
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+470ee3be2c92b7c1916a2acc4397483b
+2011-10-21T23:08:45.031764Z
+28513
+nico
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2298
+
diff --git a/package/busybox/config/debianutils/.svn/prop-base/Config.in.svn-base b/package/busybox/config/debianutils/.svn/prop-base/Config.in.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/busybox/config/debianutils/.svn/prop-base/Config.in.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/busybox/config/debianutils/.svn/text-base/Config.in.svn-base b/package/busybox/config/debianutils/.svn/text-base/Config.in.svn-base
new file mode 100644
index 0000000..be69666
--- /dev/null
+++ b/package/busybox/config/debianutils/.svn/text-base/Config.in.svn-base
@@ -0,0 +1,86 @@
+# DO NOT EDIT. This file is generated from Config.src
+#
+# For a description of the syntax of this configuration file,
+# see scripts/kbuild/config-language.txt.
+#
+
+menu "Debian Utilities"
+
+
+
+config BUSYBOX_CONFIG_MKTEMP
+ bool "mktemp"
+ default y
+ help
+ mktemp is used to create unique temporary files
+
+config BUSYBOX_CONFIG_PIPE_PROGRESS
+ bool "pipe_progress"
+ default n
+ help
+ Display a dot to indicate pipe activity.
+
+config BUSYBOX_CONFIG_RUN_PARTS
+ bool "run-parts"
+ default n
+ help
+ run-parts is a utility designed to run all the scripts in a directory.
+
+ It is useful to set up a directory like cron.daily, where you need to
+ execute all the scripts in that directory.
+
+ In this implementation of run-parts some features (such as report
+ mode) are not implemented.
+
+ Unless you know that run-parts is used in some of your scripts
+ you can safely say N here.
+
+config BUSYBOX_CONFIG_FEATURE_RUN_PARTS_LONG_OPTIONS
+ bool "Enable long options"
+ default n
+ depends on BUSYBOX_CONFIG_RUN_PARTS && BUSYBOX_CONFIG_LONG_OPTS
+ help
+ Support long options for the run-parts applet.
+
+config BUSYBOX_CONFIG_FEATURE_RUN_PARTS_FANCY
+ bool "Support additional arguments"
+ default n
+ depends on BUSYBOX_CONFIG_RUN_PARTS
+ help
+ Support additional options:
+ -l --list print the names of the all matching files (not
+ limited to executables), but don't actually run them.
+
+config BUSYBOX_CONFIG_START_STOP_DAEMON
+ bool "start-stop-daemon"
+ default y
+ help
+ start-stop-daemon is used to control the creation and
+ termination of system-level processes, usually the ones
+ started during the startup of the system.
+
+config BUSYBOX_CONFIG_FEATURE_START_STOP_DAEMON_FANCY
+ bool "Support additional arguments"
+ default n
+ depends on BUSYBOX_CONFIG_START_STOP_DAEMON
+ help
+ Support additional arguments.
+ -o|--oknodo ignored since we exit with 0 anyway
+ -v|--verbose
+ -N|--nicelevel N
+
+config BUSYBOX_CONFIG_FEATURE_START_STOP_DAEMON_LONG_OPTIONS
+ bool "Enable long options"
+ default n
+ depends on BUSYBOX_CONFIG_START_STOP_DAEMON && BUSYBOX_CONFIG_LONG_OPTS
+ help
+ Support long options for the start-stop-daemon applet.
+
+config BUSYBOX_CONFIG_WHICH
+ bool "which"
+ default y
+ help
+ which is used to find programs in your PATH and
+ print out their pathnames.
+
+endmenu
diff --git a/package/busybox/config/debianutils/Config.in b/package/busybox/config/debianutils/Config.in
new file mode 100644
index 0000000..be69666
--- /dev/null
+++ b/package/busybox/config/debianutils/Config.in
@@ -0,0 +1,86 @@
+# DO NOT EDIT. This file is generated from Config.src
+#
+# For a description of the syntax of this configuration file,
+# see scripts/kbuild/config-language.txt.
+#
+
+menu "Debian Utilities"
+
+
+
+config BUSYBOX_CONFIG_MKTEMP
+ bool "mktemp"
+ default y
+ help
+ mktemp is used to create unique temporary files
+
+config BUSYBOX_CONFIG_PIPE_PROGRESS
+ bool "pipe_progress"
+ default n
+ help
+ Display a dot to indicate pipe activity.
+
+config BUSYBOX_CONFIG_RUN_PARTS
+ bool "run-parts"
+ default n
+ help
+ run-parts is a utility designed to run all the scripts in a directory.
+
+ It is useful to set up a directory like cron.daily, where you need to
+ execute all the scripts in that directory.
+
+ In this implementation of run-parts some features (such as report
+ mode) are not implemented.
+
+ Unless you know that run-parts is used in some of your scripts
+ you can safely say N here.
+
+config BUSYBOX_CONFIG_FEATURE_RUN_PARTS_LONG_OPTIONS
+ bool "Enable long options"
+ default n
+ depends on BUSYBOX_CONFIG_RUN_PARTS && BUSYBOX_CONFIG_LONG_OPTS
+ help
+ Support long options for the run-parts applet.
+
+config BUSYBOX_CONFIG_FEATURE_RUN_PARTS_FANCY
+ bool "Support additional arguments"
+ default n
+ depends on BUSYBOX_CONFIG_RUN_PARTS
+ help
+ Support additional options:
+ -l --list print the names of the all matching files (not
+ limited to executables), but don't actually run them.
+
+config BUSYBOX_CONFIG_START_STOP_DAEMON
+ bool "start-stop-daemon"
+ default y
+ help
+ start-stop-daemon is used to control the creation and
+ termination of system-level processes, usually the ones
+ started during the startup of the system.
+
+config BUSYBOX_CONFIG_FEATURE_START_STOP_DAEMON_FANCY
+ bool "Support additional arguments"
+ default n
+ depends on BUSYBOX_CONFIG_START_STOP_DAEMON
+ help
+ Support additional arguments.
+ -o|--oknodo ignored since we exit with 0 anyway
+ -v|--verbose
+ -N|--nicelevel N
+
+config BUSYBOX_CONFIG_FEATURE_START_STOP_DAEMON_LONG_OPTIONS
+ bool "Enable long options"
+ default n
+ depends on BUSYBOX_CONFIG_START_STOP_DAEMON && BUSYBOX_CONFIG_LONG_OPTS
+ help
+ Support long options for the start-stop-daemon applet.
+
+config BUSYBOX_CONFIG_WHICH
+ bool "which"
+ default y
+ help
+ which is used to find programs in your PATH and
+ print out their pathnames.
+
+endmenu
diff --git a/package/busybox/config/e2fsprogs/.svn/entries b/package/busybox/config/e2fsprogs/.svn/entries
new file mode 100644
index 0000000..44fc246
--- /dev/null
+++ b/package/busybox/config/e2fsprogs/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/busybox/config/e2fsprogs
+svn://svn.openwrt.org/openwrt
+
+
+
+2011-10-21T23:08:45.031764Z
+28513
+nico
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+old_e2fsprogs
+dir
+
+Config.in
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+8ff77a02ceb3dd9406764cbd1728acd8
+2011-10-21T23:08:45.031764Z
+28513
+nico
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1963
+
diff --git a/package/busybox/config/e2fsprogs/.svn/prop-base/Config.in.svn-base b/package/busybox/config/e2fsprogs/.svn/prop-base/Config.in.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/busybox/config/e2fsprogs/.svn/prop-base/Config.in.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/busybox/config/e2fsprogs/.svn/text-base/Config.in.svn-base b/package/busybox/config/e2fsprogs/.svn/text-base/Config.in.svn-base
new file mode 100644
index 0000000..282681d
--- /dev/null
+++ b/package/busybox/config/e2fsprogs/.svn/text-base/Config.in.svn-base
@@ -0,0 +1,72 @@
+# DO NOT EDIT. This file is generated from Config.src
+#
+# For a description of the syntax of this configuration file,
+# see scripts/kbuild/config-language.txt.
+#
+
+menu "Linux Ext2 FS Progs"
+
+
+
+config BUSYBOX_CONFIG_CHATTR
+ bool "chattr"
+ default n
+ help
+ chattr changes the file attributes on a second extended file system.
+
+### config E2FSCK
+### bool "e2fsck"
+### default y
+### help
+### e2fsck is used to check Linux second extended file systems (ext2fs).
+### e2fsck also supports ext2 filesystems countaining a journal (ext3).
+### The normal compat symlinks 'fsck.ext2' and 'fsck.ext3' are also
+### provided.
+
+config BUSYBOX_CONFIG_FSCK
+ bool "fsck"
+ default n
+ help
+ fsck is used to check and optionally repair one or more filesystems.
+ In actuality, fsck is simply a front-end for the various file system
+ checkers (fsck.fstype) available under Linux.
+
+config BUSYBOX_CONFIG_LSATTR
+ bool "lsattr"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ lsattr lists the file attributes on a second extended file system.
+
+### config MKE2FS
+### bool "mke2fs"
+### default y
+### help
+### mke2fs is used to create an ext2/ext3 filesystem. The normal compat
+### symlinks 'mkfs.ext2' and 'mkfs.ext3' are also provided.
+
+config BUSYBOX_CONFIG_TUNE2FS
+ bool "tune2fs"
+ default n # off: it is too limited compared to upstream version
+ help
+ tune2fs allows the system administrator to adjust various tunable
+ filesystem parameters on Linux ext2/ext3 filesystems.
+
+### config E2LABEL
+### bool "e2label"
+### default y
+### depends on TUNE2FS
+### help
+### e2label will display or change the filesystem label on the ext2
+### filesystem located on device.
+
+### NB: this one is now provided by util-linux/volume_id/*
+### config FINDFS
+### bool "findfs"
+### default y
+### depends on TUNE2FS
+### help
+### findfs will search the disks in the system looking for a filesystem
+### which has a label matching label or a UUID equal to uuid.
+
+endmenu
diff --git a/package/busybox/config/e2fsprogs/Config.in b/package/busybox/config/e2fsprogs/Config.in
new file mode 100644
index 0000000..282681d
--- /dev/null
+++ b/package/busybox/config/e2fsprogs/Config.in
@@ -0,0 +1,72 @@
+# DO NOT EDIT. This file is generated from Config.src
+#
+# For a description of the syntax of this configuration file,
+# see scripts/kbuild/config-language.txt.
+#
+
+menu "Linux Ext2 FS Progs"
+
+
+
+config BUSYBOX_CONFIG_CHATTR
+ bool "chattr"
+ default n
+ help
+ chattr changes the file attributes on a second extended file system.
+
+### config E2FSCK
+### bool "e2fsck"
+### default y
+### help
+### e2fsck is used to check Linux second extended file systems (ext2fs).
+### e2fsck also supports ext2 filesystems countaining a journal (ext3).
+### The normal compat symlinks 'fsck.ext2' and 'fsck.ext3' are also
+### provided.
+
+config BUSYBOX_CONFIG_FSCK
+ bool "fsck"
+ default n
+ help
+ fsck is used to check and optionally repair one or more filesystems.
+ In actuality, fsck is simply a front-end for the various file system
+ checkers (fsck.fstype) available under Linux.
+
+config BUSYBOX_CONFIG_LSATTR
+ bool "lsattr"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ lsattr lists the file attributes on a second extended file system.
+
+### config MKE2FS
+### bool "mke2fs"
+### default y
+### help
+### mke2fs is used to create an ext2/ext3 filesystem. The normal compat
+### symlinks 'mkfs.ext2' and 'mkfs.ext3' are also provided.
+
+config BUSYBOX_CONFIG_TUNE2FS
+ bool "tune2fs"
+ default n # off: it is too limited compared to upstream version
+ help
+ tune2fs allows the system administrator to adjust various tunable
+ filesystem parameters on Linux ext2/ext3 filesystems.
+
+### config E2LABEL
+### bool "e2label"
+### default y
+### depends on TUNE2FS
+### help
+### e2label will display or change the filesystem label on the ext2
+### filesystem located on device.
+
+### NB: this one is now provided by util-linux/volume_id/*
+### config FINDFS
+### bool "findfs"
+### default y
+### depends on TUNE2FS
+### help
+### findfs will search the disks in the system looking for a filesystem
+### which has a label matching label or a UUID equal to uuid.
+
+endmenu
diff --git a/package/busybox/config/e2fsprogs/old_e2fsprogs/.svn/entries b/package/busybox/config/e2fsprogs/old_e2fsprogs/.svn/entries
new file mode 100644
index 0000000..f85dc6b
--- /dev/null
+++ b/package/busybox/config/e2fsprogs/old_e2fsprogs/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/busybox/config/e2fsprogs/old_e2fsprogs
+svn://svn.openwrt.org/openwrt
+
+
+
+2011-10-21T23:08:45.031764Z
+28513
+nico
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+Config.in
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+4ff20325f4696b6e4ae4db6dda321101
+2011-10-21T23:08:45.031764Z
+28513
+nico
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1813
+
diff --git a/package/busybox/config/e2fsprogs/old_e2fsprogs/.svn/prop-base/Config.in.svn-base b/package/busybox/config/e2fsprogs/old_e2fsprogs/.svn/prop-base/Config.in.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/busybox/config/e2fsprogs/old_e2fsprogs/.svn/prop-base/Config.in.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/busybox/config/e2fsprogs/old_e2fsprogs/.svn/text-base/Config.in.svn-base b/package/busybox/config/e2fsprogs/old_e2fsprogs/.svn/text-base/Config.in.svn-base
new file mode 100644
index 0000000..105c93a
--- /dev/null
+++ b/package/busybox/config/e2fsprogs/old_e2fsprogs/.svn/text-base/Config.in.svn-base
@@ -0,0 +1,70 @@
+# DO NOT EDIT. This file is generated from Config.src
+#
+# For a description of the syntax of this configuration file,
+# see scripts/kbuild/config-language.txt.
+#
+
+menu "Linux Ext2 FS Progs"
+
+
+
+config BUSYBOX_CONFIG_CHATTR
+ bool "chattr"
+ default n
+ help
+ chattr changes the file attributes on a second extended file system.
+
+config BUSYBOX_CONFIG_E2FSCK
+ bool "e2fsck"
+ default n
+ help
+ e2fsck is used to check Linux second extended file systems (ext2fs).
+ e2fsck also supports ext2 filesystems countaining a journal (ext3).
+ The normal compat symlinks 'fsck.ext2' and 'fsck.ext3' are also
+ provided.
+
+config BUSYBOX_CONFIG_FSCK
+ bool "fsck"
+ default n
+ help
+ fsck is used to check and optionally repair one or more filesystems.
+ In actuality, fsck is simply a front-end for the various file system
+ checkers (fsck.fstype) available under Linux.
+
+config BUSYBOX_CONFIG_LSATTR
+ bool "lsattr"
+ default n
+ help
+ lsattr lists the file attributes on a second extended file system.
+
+config BUSYBOX_CONFIG_MKE2FS
+ bool "mke2fs"
+ default n
+ help
+ mke2fs is used to create an ext2/ext3 filesystem. The normal compat
+ symlinks 'mkfs.ext2' and 'mkfs.ext3' are also provided.
+
+config BUSYBOX_CONFIG_TUNE2FS
+ bool "tune2fs"
+ default n
+ help
+ tune2fs allows the system administrator to adjust various tunable
+ filesystem parameters on Linux ext2/ext3 filesystems.
+
+config BUSYBOX_CONFIG_E2LABEL
+ bool "e2label"
+ default n
+ depends on BUSYBOX_CONFIG_TUNE2FS
+ help
+ e2label will display or change the filesystem label on the ext2
+ filesystem located on device.
+
+config BUSYBOX_CONFIG_FINDFS
+ bool "findfs"
+ default n
+ depends on BUSYBOX_CONFIG_TUNE2FS
+ help
+ findfs will search the disks in the system looking for a filesystem
+ which has a label matching label or a UUID equal to uuid.
+
+endmenu
diff --git a/package/busybox/config/e2fsprogs/old_e2fsprogs/Config.in b/package/busybox/config/e2fsprogs/old_e2fsprogs/Config.in
new file mode 100644
index 0000000..105c93a
--- /dev/null
+++ b/package/busybox/config/e2fsprogs/old_e2fsprogs/Config.in
@@ -0,0 +1,70 @@
+# DO NOT EDIT. This file is generated from Config.src
+#
+# For a description of the syntax of this configuration file,
+# see scripts/kbuild/config-language.txt.
+#
+
+menu "Linux Ext2 FS Progs"
+
+
+
+config BUSYBOX_CONFIG_CHATTR
+ bool "chattr"
+ default n
+ help
+ chattr changes the file attributes on a second extended file system.
+
+config BUSYBOX_CONFIG_E2FSCK
+ bool "e2fsck"
+ default n
+ help
+ e2fsck is used to check Linux second extended file systems (ext2fs).
+ e2fsck also supports ext2 filesystems countaining a journal (ext3).
+ The normal compat symlinks 'fsck.ext2' and 'fsck.ext3' are also
+ provided.
+
+config BUSYBOX_CONFIG_FSCK
+ bool "fsck"
+ default n
+ help
+ fsck is used to check and optionally repair one or more filesystems.
+ In actuality, fsck is simply a front-end for the various file system
+ checkers (fsck.fstype) available under Linux.
+
+config BUSYBOX_CONFIG_LSATTR
+ bool "lsattr"
+ default n
+ help
+ lsattr lists the file attributes on a second extended file system.
+
+config BUSYBOX_CONFIG_MKE2FS
+ bool "mke2fs"
+ default n
+ help
+ mke2fs is used to create an ext2/ext3 filesystem. The normal compat
+ symlinks 'mkfs.ext2' and 'mkfs.ext3' are also provided.
+
+config BUSYBOX_CONFIG_TUNE2FS
+ bool "tune2fs"
+ default n
+ help
+ tune2fs allows the system administrator to adjust various tunable
+ filesystem parameters on Linux ext2/ext3 filesystems.
+
+config BUSYBOX_CONFIG_E2LABEL
+ bool "e2label"
+ default n
+ depends on BUSYBOX_CONFIG_TUNE2FS
+ help
+ e2label will display or change the filesystem label on the ext2
+ filesystem located on device.
+
+config BUSYBOX_CONFIG_FINDFS
+ bool "findfs"
+ default n
+ depends on BUSYBOX_CONFIG_TUNE2FS
+ help
+ findfs will search the disks in the system looking for a filesystem
+ which has a label matching label or a UUID equal to uuid.
+
+endmenu
diff --git a/package/busybox/config/editors/.svn/entries b/package/busybox/config/editors/.svn/entries
new file mode 100644
index 0000000..26c0350
--- /dev/null
+++ b/package/busybox/config/editors/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/busybox/config/editors
+svn://svn.openwrt.org/openwrt
+
+
+
+2011-10-21T23:08:45.031764Z
+28513
+nico
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+Config.in
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+7eaea2963956ce4ad3ad0d94e4aa1976
+2011-10-21T23:08:45.031764Z
+28513
+nico
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5898
+
diff --git a/package/busybox/config/editors/.svn/prop-base/Config.in.svn-base b/package/busybox/config/editors/.svn/prop-base/Config.in.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/busybox/config/editors/.svn/prop-base/Config.in.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/busybox/config/editors/.svn/text-base/Config.in.svn-base b/package/busybox/config/editors/.svn/text-base/Config.in.svn-base
new file mode 100644
index 0000000..21321db
--- /dev/null
+++ b/package/busybox/config/editors/.svn/text-base/Config.in.svn-base
@@ -0,0 +1,206 @@
+# DO NOT EDIT. This file is generated from Config.src
+#
+# For a description of the syntax of this configuration file,
+# see scripts/kbuild/config-language.txt.
+#
+
+menu "Editors"
+
+config BUSYBOX_CONFIG_PATCH
+ bool "patch"
+ default n
+ help
+ Apply a unified diff formatted patch.
+config BUSYBOX_CONFIG_VI
+ bool "vi"
+ default y
+ help
+ 'vi' is a text editor. More specifically, it is the One True
+ text editor <grin>. It does, however, have a rather steep
+ learning curve. If you are not already comfortable with 'vi'
+ you may wish to use something else.
+
+config BUSYBOX_CONFIG_FEATURE_VI_MAX_LEN
+ int "Maximum screen width in vi"
+ range 256 16384
+ default 1024
+ depends on BUSYBOX_CONFIG_VI
+ help
+ Contrary to what you may think, this is not eating much.
+ Make it smaller than 4k only if you are very limited on memory.
+
+config BUSYBOX_CONFIG_FEATURE_VI_8BIT
+ bool "Allow vi to display 8-bit chars (otherwise shows dots)"
+ default n
+ depends on BUSYBOX_CONFIG_VI
+ help
+ If your terminal can display characters with high bit set,
+ you may want to enable this. Note: vi is not Unicode-capable.
+ If your terminal combines several 8-bit bytes into one character
+ (as in Unicode mode), this will not work properly.
+
+config BUSYBOX_CONFIG_FEATURE_VI_COLON
+ bool "Enable \":\" colon commands (no \"ex\" mode)"
+ default y
+ depends on BUSYBOX_CONFIG_VI
+ help
+ Enable a limited set of colon commands for vi. This does not
+ provide an "ex" mode.
+
+config BUSYBOX_CONFIG_FEATURE_VI_YANKMARK
+ bool "Enable yank/put commands and mark cmds"
+ default y
+ depends on BUSYBOX_CONFIG_VI
+ help
+ This will enable you to use yank and put, as well as mark in
+ busybox vi.
+
+config BUSYBOX_CONFIG_FEATURE_VI_SEARCH
+ bool "Enable search and replace cmds"
+ default y
+ depends on BUSYBOX_CONFIG_VI
+ help
+ Select this if you wish to be able to do search and replace in
+ busybox vi.
+
+config BUSYBOX_CONFIG_FEATURE_VI_REGEX_SEARCH
+ bool "Enable regex in search and replace"
+ default n # Uses GNU regex, which may be unavailable. FIXME
+ depends on BUSYBOX_CONFIG_FEATURE_VI_SEARCH
+ help
+ Use extended regex search.
+
+config BUSYBOX_CONFIG_FEATURE_VI_USE_SIGNALS
+ bool "Catch signals"
+ default y
+ depends on BUSYBOX_CONFIG_VI
+ help
+ Selecting this option will make busybox vi signal aware. This will
+ make busybox vi support SIGWINCH to deal with Window Changes, catch
+ Ctrl-Z and Ctrl-C and alarms.
+
+config BUSYBOX_CONFIG_FEATURE_VI_DOT_CMD
+ bool "Remember previous cmd and \".\" cmd"
+ default y
+ depends on BUSYBOX_CONFIG_VI
+ help
+ Make busybox vi remember the last command and be able to repeat it.
+
+config BUSYBOX_CONFIG_FEATURE_VI_READONLY
+ bool "Enable -R option and \"view\" mode"
+ default y
+ depends on BUSYBOX_CONFIG_VI
+ help
+ Enable the read-only command line option, which allows the user to
+ open a file in read-only mode.
+
+config BUSYBOX_CONFIG_FEATURE_VI_SETOPTS
+ bool "Enable set-able options, ai ic showmatch"
+ default y
+ depends on BUSYBOX_CONFIG_VI
+ help
+ Enable the editor to set some (ai, ic, showmatch) options.
+
+config BUSYBOX_CONFIG_FEATURE_VI_SET
+ bool "Support for :set"
+ default y
+ depends on BUSYBOX_CONFIG_VI
+ help
+ Support for ":set".
+
+config BUSYBOX_CONFIG_FEATURE_VI_WIN_RESIZE
+ bool "Handle window resize"
+ default y
+ depends on BUSYBOX_CONFIG_VI
+ help
+ Make busybox vi behave nicely with terminals that get resized.
+
+config BUSYBOX_CONFIG_FEATURE_VI_ASK_TERMINAL
+ bool "Use 'tell me cursor position' ESC sequence to measure window"
+ default y
+ depends on BUSYBOX_CONFIG_VI
+ help
+ If terminal size can't be retrieved and $LINES/$COLUMNS are not set,
+ this option makes vi perform a last-ditch effort to find it:
+ position cursor to 999,999 and ask terminal to report real
+ cursor position using "ESC [ 6 n" escape sequence, then read stdin.
+
+ This is not clean but helps a lot on serial lines and such.
+
+config BUSYBOX_CONFIG_FEATURE_VI_OPTIMIZE_CURSOR
+ bool "Optimize cursor movement"
+ default y
+ depends on BUSYBOX_CONFIG_VI
+ help
+ This will make the cursor movement faster, but requires more memory
+ and it makes the applet a tiny bit larger.
+
+config BUSYBOX_CONFIG_AWK
+ bool "awk"
+ default y
+ help
+ Awk is used as a pattern scanning and processing language. This is
+ the BusyBox implementation of that programming language.
+
+config BUSYBOX_CONFIG_FEATURE_AWK_LIBM
+ bool "Enable math functions (requires libm)"
+ default y
+ depends on BUSYBOX_CONFIG_AWK
+ help
+ Enable math functions of the Awk programming language.
+ NOTE: This will require libm to be present for linking.
+
+config BUSYBOX_CONFIG_CMP
+ bool "cmp"
+ default y
+ help
+ cmp is used to compare two files and returns the result
+ to standard output.
+
+config BUSYBOX_CONFIG_DIFF
+ bool "diff"
+ default n
+ help
+ diff compares two files or directories and outputs the
+ differences between them in a form that can be given to
+ the patch command.
+
+config BUSYBOX_CONFIG_FEATURE_DIFF_LONG_OPTIONS
+ bool "Enable long options"
+ default n
+ depends on BUSYBOX_CONFIG_DIFF && BUSYBOX_CONFIG_LONG_OPTS
+ help
+ Enable use of long options.
+
+config BUSYBOX_CONFIG_FEATURE_DIFF_DIR
+ bool "Enable directory support"
+ default n
+ depends on BUSYBOX_CONFIG_DIFF
+ help
+ This option enables support for directory and subdirectory
+ comparison.
+
+config BUSYBOX_CONFIG_ED
+ bool "ed"
+ default n
+ help
+ The original 1970's Unix text editor, from the days of teletypes.
+ Small, simple, evil. Part of SUSv3. If you're not already using
+ this, you don't need it.
+
+config BUSYBOX_CONFIG_SED
+ bool "sed"
+ default y
+ help
+ sed is used to perform text transformations on a file
+ or input from a pipeline.
+
+config BUSYBOX_CONFIG_FEATURE_ALLOW_EXEC
+ bool "Allow vi and awk to execute shell commands"
+ default y
+ depends on BUSYBOX_CONFIG_VI || BUSYBOX_CONFIG_AWK
+ help
+ Enables vi and awk features which allows user to execute
+ shell commands (using system() C call).
+
+endmenu
diff --git a/package/busybox/config/editors/Config.in b/package/busybox/config/editors/Config.in
new file mode 100644
index 0000000..21321db
--- /dev/null
+++ b/package/busybox/config/editors/Config.in
@@ -0,0 +1,206 @@
+# DO NOT EDIT. This file is generated from Config.src
+#
+# For a description of the syntax of this configuration file,
+# see scripts/kbuild/config-language.txt.
+#
+
+menu "Editors"
+
+config BUSYBOX_CONFIG_PATCH
+ bool "patch"
+ default n
+ help
+ Apply a unified diff formatted patch.
+config BUSYBOX_CONFIG_VI
+ bool "vi"
+ default y
+ help
+ 'vi' is a text editor. More specifically, it is the One True
+ text editor <grin>. It does, however, have a rather steep
+ learning curve. If you are not already comfortable with 'vi'
+ you may wish to use something else.
+
+config BUSYBOX_CONFIG_FEATURE_VI_MAX_LEN
+ int "Maximum screen width in vi"
+ range 256 16384
+ default 1024
+ depends on BUSYBOX_CONFIG_VI
+ help
+ Contrary to what you may think, this is not eating much.
+ Make it smaller than 4k only if you are very limited on memory.
+
+config BUSYBOX_CONFIG_FEATURE_VI_8BIT
+ bool "Allow vi to display 8-bit chars (otherwise shows dots)"
+ default n
+ depends on BUSYBOX_CONFIG_VI
+ help
+ If your terminal can display characters with high bit set,
+ you may want to enable this. Note: vi is not Unicode-capable.
+ If your terminal combines several 8-bit bytes into one character
+ (as in Unicode mode), this will not work properly.
+
+config BUSYBOX_CONFIG_FEATURE_VI_COLON
+ bool "Enable \":\" colon commands (no \"ex\" mode)"
+ default y
+ depends on BUSYBOX_CONFIG_VI
+ help
+ Enable a limited set of colon commands for vi. This does not
+ provide an "ex" mode.
+
+config BUSYBOX_CONFIG_FEATURE_VI_YANKMARK
+ bool "Enable yank/put commands and mark cmds"
+ default y
+ depends on BUSYBOX_CONFIG_VI
+ help
+ This will enable you to use yank and put, as well as mark in
+ busybox vi.
+
+config BUSYBOX_CONFIG_FEATURE_VI_SEARCH
+ bool "Enable search and replace cmds"
+ default y
+ depends on BUSYBOX_CONFIG_VI
+ help
+ Select this if you wish to be able to do search and replace in
+ busybox vi.
+
+config BUSYBOX_CONFIG_FEATURE_VI_REGEX_SEARCH
+ bool "Enable regex in search and replace"
+ default n # Uses GNU regex, which may be unavailable. FIXME
+ depends on BUSYBOX_CONFIG_FEATURE_VI_SEARCH
+ help
+ Use extended regex search.
+
+config BUSYBOX_CONFIG_FEATURE_VI_USE_SIGNALS
+ bool "Catch signals"
+ default y
+ depends on BUSYBOX_CONFIG_VI
+ help
+ Selecting this option will make busybox vi signal aware. This will
+ make busybox vi support SIGWINCH to deal with Window Changes, catch
+ Ctrl-Z and Ctrl-C and alarms.
+
+config BUSYBOX_CONFIG_FEATURE_VI_DOT_CMD
+ bool "Remember previous cmd and \".\" cmd"
+ default y
+ depends on BUSYBOX_CONFIG_VI
+ help
+ Make busybox vi remember the last command and be able to repeat it.
+
+config BUSYBOX_CONFIG_FEATURE_VI_READONLY
+ bool "Enable -R option and \"view\" mode"
+ default y
+ depends on BUSYBOX_CONFIG_VI
+ help
+ Enable the read-only command line option, which allows the user to
+ open a file in read-only mode.
+
+config BUSYBOX_CONFIG_FEATURE_VI_SETOPTS
+ bool "Enable set-able options, ai ic showmatch"
+ default y
+ depends on BUSYBOX_CONFIG_VI
+ help
+ Enable the editor to set some (ai, ic, showmatch) options.
+
+config BUSYBOX_CONFIG_FEATURE_VI_SET
+ bool "Support for :set"
+ default y
+ depends on BUSYBOX_CONFIG_VI
+ help
+ Support for ":set".
+
+config BUSYBOX_CONFIG_FEATURE_VI_WIN_RESIZE
+ bool "Handle window resize"
+ default y
+ depends on BUSYBOX_CONFIG_VI
+ help
+ Make busybox vi behave nicely with terminals that get resized.
+
+config BUSYBOX_CONFIG_FEATURE_VI_ASK_TERMINAL
+ bool "Use 'tell me cursor position' ESC sequence to measure window"
+ default y
+ depends on BUSYBOX_CONFIG_VI
+ help
+ If terminal size can't be retrieved and $LINES/$COLUMNS are not set,
+ this option makes vi perform a last-ditch effort to find it:
+ position cursor to 999,999 and ask terminal to report real
+ cursor position using "ESC [ 6 n" escape sequence, then read stdin.
+
+ This is not clean but helps a lot on serial lines and such.
+
+config BUSYBOX_CONFIG_FEATURE_VI_OPTIMIZE_CURSOR
+ bool "Optimize cursor movement"
+ default y
+ depends on BUSYBOX_CONFIG_VI
+ help
+ This will make the cursor movement faster, but requires more memory
+ and it makes the applet a tiny bit larger.
+
+config BUSYBOX_CONFIG_AWK
+ bool "awk"
+ default y
+ help
+ Awk is used as a pattern scanning and processing language. This is
+ the BusyBox implementation of that programming language.
+
+config BUSYBOX_CONFIG_FEATURE_AWK_LIBM
+ bool "Enable math functions (requires libm)"
+ default y
+ depends on BUSYBOX_CONFIG_AWK
+ help
+ Enable math functions of the Awk programming language.
+ NOTE: This will require libm to be present for linking.
+
+config BUSYBOX_CONFIG_CMP
+ bool "cmp"
+ default y
+ help
+ cmp is used to compare two files and returns the result
+ to standard output.
+
+config BUSYBOX_CONFIG_DIFF
+ bool "diff"
+ default n
+ help
+ diff compares two files or directories and outputs the
+ differences between them in a form that can be given to
+ the patch command.
+
+config BUSYBOX_CONFIG_FEATURE_DIFF_LONG_OPTIONS
+ bool "Enable long options"
+ default n
+ depends on BUSYBOX_CONFIG_DIFF && BUSYBOX_CONFIG_LONG_OPTS
+ help
+ Enable use of long options.
+
+config BUSYBOX_CONFIG_FEATURE_DIFF_DIR
+ bool "Enable directory support"
+ default n
+ depends on BUSYBOX_CONFIG_DIFF
+ help
+ This option enables support for directory and subdirectory
+ comparison.
+
+config BUSYBOX_CONFIG_ED
+ bool "ed"
+ default n
+ help
+ The original 1970's Unix text editor, from the days of teletypes.
+ Small, simple, evil. Part of SUSv3. If you're not already using
+ this, you don't need it.
+
+config BUSYBOX_CONFIG_SED
+ bool "sed"
+ default y
+ help
+ sed is used to perform text transformations on a file
+ or input from a pipeline.
+
+config BUSYBOX_CONFIG_FEATURE_ALLOW_EXEC
+ bool "Allow vi and awk to execute shell commands"
+ default y
+ depends on BUSYBOX_CONFIG_VI || BUSYBOX_CONFIG_AWK
+ help
+ Enables vi and awk features which allows user to execute
+ shell commands (using system() C call).
+
+endmenu
diff --git a/package/busybox/config/findutils/.svn/entries b/package/busybox/config/findutils/.svn/entries
new file mode 100644
index 0000000..24d9584
--- /dev/null
+++ b/package/busybox/config/findutils/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/busybox/config/findutils
+svn://svn.openwrt.org/openwrt
+
+
+
+2011-10-21T23:08:45.031764Z
+28513
+nico
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+Config.in
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+8580cce0676f1ddcaa89b0764f9c8443
+2011-10-21T23:08:45.031764Z
+28513
+nico
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+7487
+
diff --git a/package/busybox/config/findutils/.svn/prop-base/Config.in.svn-base b/package/busybox/config/findutils/.svn/prop-base/Config.in.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/busybox/config/findutils/.svn/prop-base/Config.in.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/busybox/config/findutils/.svn/text-base/Config.in.svn-base b/package/busybox/config/findutils/.svn/text-base/Config.in.svn-base
new file mode 100644
index 0000000..8db1fde
--- /dev/null
+++ b/package/busybox/config/findutils/.svn/text-base/Config.in.svn-base
@@ -0,0 +1,252 @@
+# DO NOT EDIT. This file is generated from Config.src
+#
+# For a description of the syntax of this configuration file,
+# see scripts/kbuild/config-language.txt.
+#
+
+menu "Finding Utilities"
+
+config BUSYBOX_CONFIG_FIND
+ bool "find"
+ default y
+ help
+ find is used to search your system to find specified files.
+
+config BUSYBOX_CONFIG_FEATURE_FIND_PRINT0
+ bool "Enable -print0: NUL-terminated output"
+ default y
+ depends on BUSYBOX_CONFIG_FIND
+ help
+ Causes output names to be separated by a NUL character
+ rather than a newline. This allows names that contain
+ newlines and other whitespace to be more easily
+ interpreted by other programs.
+
+config BUSYBOX_CONFIG_FEATURE_FIND_MTIME
+ bool "Enable -mtime: modified time matching"
+ default n
+ depends on BUSYBOX_CONFIG_FIND
+ help
+ Allow searching based on the modification time of
+ files, in days.
+
+config BUSYBOX_CONFIG_FEATURE_FIND_MMIN
+ bool "Enable -mmin: modified time matching by minutes"
+ default n
+ depends on BUSYBOX_CONFIG_FIND
+ help
+ Allow searching based on the modification time of
+ files, in minutes.
+
+config BUSYBOX_CONFIG_FEATURE_FIND_PERM
+ bool "Enable -perm: permissions matching"
+ default y
+ depends on BUSYBOX_CONFIG_FIND
+ help
+ Enable searching based on file permissions.
+
+config BUSYBOX_CONFIG_FEATURE_FIND_TYPE
+ bool "Enable -type: file type matching (file/dir/link/...)"
+ default y
+ depends on BUSYBOX_CONFIG_FIND
+ help
+ Enable searching based on file type (file,
+ directory, socket, device, etc.).
+
+config BUSYBOX_CONFIG_FEATURE_FIND_XDEV
+ bool "Enable -xdev: 'stay in filesystem'"
+ default y
+ depends on BUSYBOX_CONFIG_FIND
+ help
+ This option allows find to restrict searches to a single filesystem.
+
+config BUSYBOX_CONFIG_FEATURE_FIND_MAXDEPTH
+ bool "Enable -mindepth N and -maxdepth N"
+ default y
+ depends on BUSYBOX_CONFIG_FIND
+ help
+ This option enables -mindepth N and -maxdepth N option.
+
+config BUSYBOX_CONFIG_FEATURE_FIND_NEWER
+ bool "Enable -newer: compare file modification times"
+ default n
+ depends on BUSYBOX_CONFIG_FIND
+ help
+ Support the 'find -newer' option for finding any files which have
+ modification time that is more recent than the specified FILE.
+
+config BUSYBOX_CONFIG_FEATURE_FIND_INUM
+ bool "Enable -inum: inode number matching"
+ default n
+ depends on BUSYBOX_CONFIG_FIND
+ help
+ Support the 'find -inum' option for searching by inode number.
+
+config BUSYBOX_CONFIG_FEATURE_FIND_EXEC
+ bool "Enable -exec: execute commands"
+ default y
+ depends on BUSYBOX_CONFIG_FIND
+ help
+ Support the 'find -exec' option for executing commands based upon
+ the files matched.
+
+config BUSYBOX_CONFIG_FEATURE_FIND_USER
+ bool "Enable -user: username/uid matching"
+ default y
+ depends on BUSYBOX_CONFIG_FIND
+ help
+ Support the 'find -user' option for searching by username or uid.
+
+config BUSYBOX_CONFIG_FEATURE_FIND_GROUP
+ bool "Enable -group: group/gid matching"
+ default y
+ depends on BUSYBOX_CONFIG_FIND
+ help
+ Support the 'find -group' option for searching by group name or gid.
+
+config BUSYBOX_CONFIG_FEATURE_FIND_NOT
+ bool "Enable the 'not' (!) operator"
+ default y
+ depends on BUSYBOX_CONFIG_FIND
+ help
+ Support the '!' operator to invert the test results.
+ If 'Enable full-blown desktop' is enabled, then will also support
+ the non-POSIX notation '-not'.
+
+config BUSYBOX_CONFIG_FEATURE_FIND_DEPTH
+ bool "Enable -depth"
+ default y
+ depends on BUSYBOX_CONFIG_FIND
+ help
+ Process each directory's contents before the directory itself.
+
+config BUSYBOX_CONFIG_FEATURE_FIND_PAREN
+ bool "Enable parens in options"
+ default y
+ depends on BUSYBOX_CONFIG_FIND
+ help
+ Enable usage of parens '(' to specify logical order of arguments.
+
+config BUSYBOX_CONFIG_FEATURE_FIND_SIZE
+ bool "Enable -size: file size matching"
+ default y
+ depends on BUSYBOX_CONFIG_FIND
+ help
+ Support the 'find -size' option for searching by file size.
+
+config BUSYBOX_CONFIG_FEATURE_FIND_PRUNE
+ bool "Enable -prune: exclude subdirectories"
+ default y
+ depends on BUSYBOX_CONFIG_FIND
+ help
+ If the file is a directory, dont descend into it. Useful for
+ exclusion .svn and CVS directories.
+
+config BUSYBOX_CONFIG_FEATURE_FIND_DELETE
+ bool "Enable -delete: delete files/dirs"
+ default n
+ depends on BUSYBOX_CONFIG_FIND && BUSYBOX_CONFIG_FEATURE_FIND_DEPTH
+ help
+ Support the 'find -delete' option for deleting files and directories.
+ WARNING: This option can do much harm if used wrong. Busybox will not
+ try to protect the user from doing stupid things. Use with care.
+
+config BUSYBOX_CONFIG_FEATURE_FIND_PATH
+ bool "Enable -path: match pathname with shell pattern"
+ default y
+ depends on BUSYBOX_CONFIG_FIND
+ help
+ The -path option matches whole pathname instead of just filename.
+
+config BUSYBOX_CONFIG_FEATURE_FIND_REGEX
+ bool "Enable -regex: match pathname with regex"
+ default y
+ depends on BUSYBOX_CONFIG_FIND
+ help
+ The -regex option matches whole pathname against regular expression.
+
+config BUSYBOX_CONFIG_FEATURE_FIND_CONTEXT
+ bool "Enable -context: security context matching"
+ default n
+ depends on BUSYBOX_CONFIG_FIND && BUSYBOX_CONFIG_SELINUX
+ help
+ Support the 'find -context' option for matching security context.
+
+config BUSYBOX_CONFIG_FEATURE_FIND_LINKS
+ bool "Enable -links: link count matching"
+ default n
+ depends on BUSYBOX_CONFIG_FIND
+ help
+ Support the 'find -links' option for matching number of links.
+config BUSYBOX_CONFIG_GREP
+ bool "grep"
+ default y
+ help
+ grep is used to search files for a specified pattern.
+
+config BUSYBOX_CONFIG_FEATURE_GREP_EGREP_ALIAS
+ bool "Enable extended regular expressions (egrep & grep -E)"
+ default y
+ depends on BUSYBOX_CONFIG_GREP
+ help
+ Enabled support for extended regular expressions. Extended
+ regular expressions allow for alternation (foo|bar), grouping,
+ and various repetition operators.
+
+config BUSYBOX_CONFIG_FEATURE_GREP_FGREP_ALIAS
+ bool "Alias fgrep to grep -F"
+ default y
+ depends on BUSYBOX_CONFIG_GREP
+ help
+ fgrep sees the search pattern as a normal string rather than
+ regular expressions.
+ grep -F always works, this just creates the fgrep alias.
+
+config BUSYBOX_CONFIG_FEATURE_GREP_CONTEXT
+ bool "Enable before and after context flags (-A, -B and -C)"
+ default y
+ depends on BUSYBOX_CONFIG_GREP
+ help
+ Print the specified number of leading (-B) and/or trailing (-A)
+ context surrounding our matching lines.
+ Print the specified number of context lines (-C).
+config BUSYBOX_CONFIG_XARGS
+ bool "xargs"
+ default y
+ help
+ xargs is used to execute a specified command for
+ every item from standard input.
+
+config BUSYBOX_CONFIG_FEATURE_XARGS_SUPPORT_CONFIRMATION
+ bool "Enable -p: prompt and confirmation"
+ default y
+ depends on BUSYBOX_CONFIG_XARGS
+ help
+ Support -p: prompt the user whether to run each command
+ line and read a line from the terminal.
+
+config BUSYBOX_CONFIG_FEATURE_XARGS_SUPPORT_QUOTES
+ bool "Enable single and double quotes and backslash"
+ default y
+ depends on BUSYBOX_CONFIG_XARGS
+ help
+ Support quoting in the input.
+
+config BUSYBOX_CONFIG_FEATURE_XARGS_SUPPORT_TERMOPT
+ bool "Enable -x: exit if -s or -n is exceeded"
+ default y
+ depends on BUSYBOX_CONFIG_XARGS
+ help
+ Support -x: exit if the command size (see the -s or -n option)
+ is exceeded.
+
+config BUSYBOX_CONFIG_FEATURE_XARGS_SUPPORT_ZERO_TERM
+ bool "Enable -0: NUL-terminated input"
+ default y
+ depends on BUSYBOX_CONFIG_XARGS
+ help
+ Support -0: input items are terminated by a NUL character
+ instead of whitespace, and the quotes and backslash
+ are not special.
+
+endmenu
diff --git a/package/busybox/config/findutils/Config.in b/package/busybox/config/findutils/Config.in
new file mode 100644
index 0000000..8db1fde
--- /dev/null
+++ b/package/busybox/config/findutils/Config.in
@@ -0,0 +1,252 @@
+# DO NOT EDIT. This file is generated from Config.src
+#
+# For a description of the syntax of this configuration file,
+# see scripts/kbuild/config-language.txt.
+#
+
+menu "Finding Utilities"
+
+config BUSYBOX_CONFIG_FIND
+ bool "find"
+ default y
+ help
+ find is used to search your system to find specified files.
+
+config BUSYBOX_CONFIG_FEATURE_FIND_PRINT0
+ bool "Enable -print0: NUL-terminated output"
+ default y
+ depends on BUSYBOX_CONFIG_FIND
+ help
+ Causes output names to be separated by a NUL character
+ rather than a newline. This allows names that contain
+ newlines and other whitespace to be more easily
+ interpreted by other programs.
+
+config BUSYBOX_CONFIG_FEATURE_FIND_MTIME
+ bool "Enable -mtime: modified time matching"
+ default n
+ depends on BUSYBOX_CONFIG_FIND
+ help
+ Allow searching based on the modification time of
+ files, in days.
+
+config BUSYBOX_CONFIG_FEATURE_FIND_MMIN
+ bool "Enable -mmin: modified time matching by minutes"
+ default n
+ depends on BUSYBOX_CONFIG_FIND
+ help
+ Allow searching based on the modification time of
+ files, in minutes.
+
+config BUSYBOX_CONFIG_FEATURE_FIND_PERM
+ bool "Enable -perm: permissions matching"
+ default y
+ depends on BUSYBOX_CONFIG_FIND
+ help
+ Enable searching based on file permissions.
+
+config BUSYBOX_CONFIG_FEATURE_FIND_TYPE
+ bool "Enable -type: file type matching (file/dir/link/...)"
+ default y
+ depends on BUSYBOX_CONFIG_FIND
+ help
+ Enable searching based on file type (file,
+ directory, socket, device, etc.).
+
+config BUSYBOX_CONFIG_FEATURE_FIND_XDEV
+ bool "Enable -xdev: 'stay in filesystem'"
+ default y
+ depends on BUSYBOX_CONFIG_FIND
+ help
+ This option allows find to restrict searches to a single filesystem.
+
+config BUSYBOX_CONFIG_FEATURE_FIND_MAXDEPTH
+ bool "Enable -mindepth N and -maxdepth N"
+ default y
+ depends on BUSYBOX_CONFIG_FIND
+ help
+ This option enables -mindepth N and -maxdepth N option.
+
+config BUSYBOX_CONFIG_FEATURE_FIND_NEWER
+ bool "Enable -newer: compare file modification times"
+ default n
+ depends on BUSYBOX_CONFIG_FIND
+ help
+ Support the 'find -newer' option for finding any files which have
+ modification time that is more recent than the specified FILE.
+
+config BUSYBOX_CONFIG_FEATURE_FIND_INUM
+ bool "Enable -inum: inode number matching"
+ default n
+ depends on BUSYBOX_CONFIG_FIND
+ help
+ Support the 'find -inum' option for searching by inode number.
+
+config BUSYBOX_CONFIG_FEATURE_FIND_EXEC
+ bool "Enable -exec: execute commands"
+ default y
+ depends on BUSYBOX_CONFIG_FIND
+ help
+ Support the 'find -exec' option for executing commands based upon
+ the files matched.
+
+config BUSYBOX_CONFIG_FEATURE_FIND_USER
+ bool "Enable -user: username/uid matching"
+ default y
+ depends on BUSYBOX_CONFIG_FIND
+ help
+ Support the 'find -user' option for searching by username or uid.
+
+config BUSYBOX_CONFIG_FEATURE_FIND_GROUP
+ bool "Enable -group: group/gid matching"
+ default y
+ depends on BUSYBOX_CONFIG_FIND
+ help
+ Support the 'find -group' option for searching by group name or gid.
+
+config BUSYBOX_CONFIG_FEATURE_FIND_NOT
+ bool "Enable the 'not' (!) operator"
+ default y
+ depends on BUSYBOX_CONFIG_FIND
+ help
+ Support the '!' operator to invert the test results.
+ If 'Enable full-blown desktop' is enabled, then will also support
+ the non-POSIX notation '-not'.
+
+config BUSYBOX_CONFIG_FEATURE_FIND_DEPTH
+ bool "Enable -depth"
+ default y
+ depends on BUSYBOX_CONFIG_FIND
+ help
+ Process each directory's contents before the directory itself.
+
+config BUSYBOX_CONFIG_FEATURE_FIND_PAREN
+ bool "Enable parens in options"
+ default y
+ depends on BUSYBOX_CONFIG_FIND
+ help
+ Enable usage of parens '(' to specify logical order of arguments.
+
+config BUSYBOX_CONFIG_FEATURE_FIND_SIZE
+ bool "Enable -size: file size matching"
+ default y
+ depends on BUSYBOX_CONFIG_FIND
+ help
+ Support the 'find -size' option for searching by file size.
+
+config BUSYBOX_CONFIG_FEATURE_FIND_PRUNE
+ bool "Enable -prune: exclude subdirectories"
+ default y
+ depends on BUSYBOX_CONFIG_FIND
+ help
+ If the file is a directory, dont descend into it. Useful for
+ exclusion .svn and CVS directories.
+
+config BUSYBOX_CONFIG_FEATURE_FIND_DELETE
+ bool "Enable -delete: delete files/dirs"
+ default n
+ depends on BUSYBOX_CONFIG_FIND && BUSYBOX_CONFIG_FEATURE_FIND_DEPTH
+ help
+ Support the 'find -delete' option for deleting files and directories.
+ WARNING: This option can do much harm if used wrong. Busybox will not
+ try to protect the user from doing stupid things. Use with care.
+
+config BUSYBOX_CONFIG_FEATURE_FIND_PATH
+ bool "Enable -path: match pathname with shell pattern"
+ default y
+ depends on BUSYBOX_CONFIG_FIND
+ help
+ The -path option matches whole pathname instead of just filename.
+
+config BUSYBOX_CONFIG_FEATURE_FIND_REGEX
+ bool "Enable -regex: match pathname with regex"
+ default y
+ depends on BUSYBOX_CONFIG_FIND
+ help
+ The -regex option matches whole pathname against regular expression.
+
+config BUSYBOX_CONFIG_FEATURE_FIND_CONTEXT
+ bool "Enable -context: security context matching"
+ default n
+ depends on BUSYBOX_CONFIG_FIND && BUSYBOX_CONFIG_SELINUX
+ help
+ Support the 'find -context' option for matching security context.
+
+config BUSYBOX_CONFIG_FEATURE_FIND_LINKS
+ bool "Enable -links: link count matching"
+ default n
+ depends on BUSYBOX_CONFIG_FIND
+ help
+ Support the 'find -links' option for matching number of links.
+config BUSYBOX_CONFIG_GREP
+ bool "grep"
+ default y
+ help
+ grep is used to search files for a specified pattern.
+
+config BUSYBOX_CONFIG_FEATURE_GREP_EGREP_ALIAS
+ bool "Enable extended regular expressions (egrep & grep -E)"
+ default y
+ depends on BUSYBOX_CONFIG_GREP
+ help
+ Enabled support for extended regular expressions. Extended
+ regular expressions allow for alternation (foo|bar), grouping,
+ and various repetition operators.
+
+config BUSYBOX_CONFIG_FEATURE_GREP_FGREP_ALIAS
+ bool "Alias fgrep to grep -F"
+ default y
+ depends on BUSYBOX_CONFIG_GREP
+ help
+ fgrep sees the search pattern as a normal string rather than
+ regular expressions.
+ grep -F always works, this just creates the fgrep alias.
+
+config BUSYBOX_CONFIG_FEATURE_GREP_CONTEXT
+ bool "Enable before and after context flags (-A, -B and -C)"
+ default y
+ depends on BUSYBOX_CONFIG_GREP
+ help
+ Print the specified number of leading (-B) and/or trailing (-A)
+ context surrounding our matching lines.
+ Print the specified number of context lines (-C).
+config BUSYBOX_CONFIG_XARGS
+ bool "xargs"
+ default y
+ help
+ xargs is used to execute a specified command for
+ every item from standard input.
+
+config BUSYBOX_CONFIG_FEATURE_XARGS_SUPPORT_CONFIRMATION
+ bool "Enable -p: prompt and confirmation"
+ default y
+ depends on BUSYBOX_CONFIG_XARGS
+ help
+ Support -p: prompt the user whether to run each command
+ line and read a line from the terminal.
+
+config BUSYBOX_CONFIG_FEATURE_XARGS_SUPPORT_QUOTES
+ bool "Enable single and double quotes and backslash"
+ default y
+ depends on BUSYBOX_CONFIG_XARGS
+ help
+ Support quoting in the input.
+
+config BUSYBOX_CONFIG_FEATURE_XARGS_SUPPORT_TERMOPT
+ bool "Enable -x: exit if -s or -n is exceeded"
+ default y
+ depends on BUSYBOX_CONFIG_XARGS
+ help
+ Support -x: exit if the command size (see the -s or -n option)
+ is exceeded.
+
+config BUSYBOX_CONFIG_FEATURE_XARGS_SUPPORT_ZERO_TERM
+ bool "Enable -0: NUL-terminated input"
+ default y
+ depends on BUSYBOX_CONFIG_XARGS
+ help
+ Support -0: input items are terminated by a NUL character
+ instead of whitespace, and the quotes and backslash
+ are not special.
+
+endmenu
diff --git a/package/busybox/config/init/.svn/entries b/package/busybox/config/init/.svn/entries
new file mode 100644
index 0000000..30e79af
--- /dev/null
+++ b/package/busybox/config/init/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/busybox/config/init
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-13T18:11:31.576290Z
+36005
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+Config.in
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+ce834bc419767ce7a8c0cf67d397d15e
+2013-03-13T18:11:31.576290Z
+36005
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+6509
+
diff --git a/package/busybox/config/init/.svn/prop-base/Config.in.svn-base b/package/busybox/config/init/.svn/prop-base/Config.in.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/busybox/config/init/.svn/prop-base/Config.in.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/busybox/config/init/.svn/text-base/Config.in.svn-base b/package/busybox/config/init/.svn/text-base/Config.in.svn-base
new file mode 100644
index 0000000..4b3c8dd
--- /dev/null
+++ b/package/busybox/config/init/.svn/text-base/Config.in.svn-base
@@ -0,0 +1,185 @@
+# DO NOT EDIT. This file is generated from Config.src
+#
+# For a description of the syntax of this configuration file,
+# see scripts/kbuild/config-language.txt.
+#
+
+menu "Init Utilities"
+
+config BUSYBOX_CONFIG_BOOTCHARTD
+ bool "bootchartd"
+ default n
+ help
+ bootchartd is commonly used to profile the boot process
+ for the purpose of speeding it up. In this case, it is started
+ by the kernel as the init process. This is configured by adding
+ the init=/sbin/bootchartd option to the kernel command line.
+
+ It can also be used to monitor the resource usage of a specific
+ application or the running system in general. In this case,
+ bootchartd is started interactively by running bootchartd start
+ and stopped using bootchartd stop.
+
+config BUSYBOX_CONFIG_FEATURE_BOOTCHARTD_BLOATED_HEADER
+ bool "Compatible, bloated header"
+ default n
+ depends on BUSYBOX_CONFIG_BOOTCHARTD
+ help
+ Create extended header file compatible with "big" bootchartd.
+ "Big" bootchartd is a shell script and it dumps some
+ "convenient" info int the header, such as:
+ title = Boot chart for `hostname` (`date`)
+ system.uname = `uname -srvm`
+ system.release = `cat /etc/DISTRO-release`
+ system.cpu = `grep '^model name' /proc/cpuinfo | head -1` ($cpucount)
+ system.kernel.options = `cat /proc/cmdline`
+ This data is not mandatory for bootchart graph generation,
+ and is considered bloat. Nevertheless, this option
+ makes bootchartd applet to dump a subset of it.
+
+config BUSYBOX_CONFIG_FEATURE_BOOTCHARTD_CONFIG_FILE
+ bool "Support bootchartd.conf"
+ default n
+ depends on BUSYBOX_CONFIG_BOOTCHARTD
+ help
+ Enable reading and parsing of $PWD/bootchartd.conf
+ and /etc/bootchartd.conf files.
+config BUSYBOX_CONFIG_HALT
+ bool "poweroff, halt, and reboot"
+ default y
+ help
+ Stop all processes and either halt, reboot, or power off the system.
+
+config BUSYBOX_CONFIG_FEATURE_CALL_TELINIT
+ bool "Call telinit on shutdown and reboot"
+ default n
+ depends on BUSYBOX_CONFIG_HALT && !BUSYBOX_CONFIG_INIT
+ help
+ Call an external program (normally telinit) to facilitate
+ a switch to a proper runlevel.
+
+ This option is only available if you selected halt and friends,
+ but did not select init.
+
+config BUSYBOX_CONFIG_TELINIT_PATH
+ string "Path to telinit executable"
+ default "/sbin/telinit"
+ depends on BUSYBOX_CONFIG_FEATURE_CALL_TELINIT
+ help
+ When busybox halt and friends have to call external telinit
+ to facilitate proper shutdown, this path is to be used when
+ locating telinit executable.
+config BUSYBOX_CONFIG_INIT
+ bool "init"
+ default y
+ select BUSYBOX_CONFIG_FEATURE_SYSLOG
+ depends on !PROCD_INIT
+ help
+ init is the first program run when the system boots.
+
+config BUSYBOX_CONFIG_FEATURE_USE_INITTAB
+ bool "Support reading an inittab file"
+ default y
+ depends on BUSYBOX_CONFIG_INIT
+ help
+ Allow init to read an inittab file when the system boot.
+
+config BUSYBOX_CONFIG_FEATURE_KILL_REMOVED
+ bool "Support killing processes that have been removed from inittab"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_USE_INITTAB
+ help
+ When respawn entries are removed from inittab and a SIGHUP is
+ sent to init, this option will make init kill the processes
+ that have been removed.
+
+config BUSYBOX_CONFIG_FEATURE_KILL_DELAY
+ int "How long to wait between TERM and KILL (0 - send TERM only)" if FEATURE_KILL_REMOVED
+ range 0 1024
+ default 0
+ depends on BUSYBOX_CONFIG_FEATURE_KILL_REMOVED
+ help
+ With nonzero setting, init sends TERM, forks, child waits N
+ seconds, sends KILL and exits. Setting it too high is unwise
+ (child will hang around for too long and could actually kill
+ the wrong process!)
+
+config BUSYBOX_CONFIG_FEATURE_INIT_SCTTY
+ bool "Run commands with leading dash with controlling tty"
+ default n
+ depends on BUSYBOX_CONFIG_INIT
+ help
+ If this option is enabled, init will try to give a controlling
+ tty to any command which has leading hyphen (often it's "-/bin/sh").
+ More precisely, init will do "ioctl(STDIN_FILENO, TIOCSCTTY, 0)".
+ If device attached to STDIN_FILENO can be a ctty but is not yet
+ a ctty for other session, it will become this process' ctty.
+ This is not the traditional init behavour, but is often what you want
+ in an embedded system where the console is only accessed during
+ development or for maintenance.
+ NB: using cttyhack applet may work better.
+
+config BUSYBOX_CONFIG_FEATURE_INIT_SYSLOG
+ bool "Enable init to write to syslog"
+ default y
+ depends on BUSYBOX_CONFIG_INIT
+
+config BUSYBOX_CONFIG_FEATURE_EXTRA_QUIET
+ bool "Be _extra_ quiet on boot"
+ default n
+ depends on BUSYBOX_CONFIG_INIT
+ help
+ Prevent init from logging some messages to the console during boot.
+
+config BUSYBOX_CONFIG_FEATURE_INIT_COREDUMPS
+ bool "Support dumping core for child processes (debugging only)"
+ default n
+ depends on BUSYBOX_CONFIG_INIT
+ help
+ If this option is enabled and the file /.init_enable_core
+ exists, then init will call setrlimit() to allow unlimited
+ core file sizes. If this option is disabled, processes
+ will not generate any core files.
+
+config BUSYBOX_CONFIG_FEATURE_INITRD
+ bool "Support running init from within an initrd (not initramfs)"
+ default n
+ depends on BUSYBOX_CONFIG_INIT
+ help
+ Legacy support for running init under the old-style initrd. Allows
+ the name linuxrc to act as init, and it doesn't assume init is PID 1.
+
+ This does not apply to initramfs, which runs /init as PID 1 and
+ requires no special support.
+
+config BUSYBOX_CONFIG_INIT_TERMINAL_TYPE
+ string "Initial terminal type"
+ default "linux"
+ depends on BUSYBOX_CONFIG_INIT
+ help
+ This is the initial value set by init for the TERM environment
+ variable. This variable is used by programs which make use of
+ extended terminal capabilities.
+
+ Note that on Linux, init attempts to detect serial terminal and
+ sets TERM to "vt102" if one is found.
+config BUSYBOX_CONFIG_MESG
+ bool "mesg"
+ default n
+ help
+ Mesg controls access to your terminal by others. It is typically
+ used to allow or disallow other users to write to your terminal
+
+config BUSYBOX_CONFIG_FEATURE_MESG_ENABLE_ONLY_GROUP
+ bool "Enable writing to tty only by group, not by everybody"
+ default n
+ depends on BUSYBOX_CONFIG_MESG
+ help
+ Usually, ttys are owned by group "tty", and "write" tool is
+ setgid to this group. This way, "mesg y" only needs to enable
+ "write by owning group" bit in tty mode.
+
+ If you set this option to N, "mesg y" will enable writing
+ by anybody at all. This is not recommended.
+
+endmenu
diff --git a/package/busybox/config/init/Config.in b/package/busybox/config/init/Config.in
new file mode 100644
index 0000000..4b3c8dd
--- /dev/null
+++ b/package/busybox/config/init/Config.in
@@ -0,0 +1,185 @@
+# DO NOT EDIT. This file is generated from Config.src
+#
+# For a description of the syntax of this configuration file,
+# see scripts/kbuild/config-language.txt.
+#
+
+menu "Init Utilities"
+
+config BUSYBOX_CONFIG_BOOTCHARTD
+ bool "bootchartd"
+ default n
+ help
+ bootchartd is commonly used to profile the boot process
+ for the purpose of speeding it up. In this case, it is started
+ by the kernel as the init process. This is configured by adding
+ the init=/sbin/bootchartd option to the kernel command line.
+
+ It can also be used to monitor the resource usage of a specific
+ application or the running system in general. In this case,
+ bootchartd is started interactively by running bootchartd start
+ and stopped using bootchartd stop.
+
+config BUSYBOX_CONFIG_FEATURE_BOOTCHARTD_BLOATED_HEADER
+ bool "Compatible, bloated header"
+ default n
+ depends on BUSYBOX_CONFIG_BOOTCHARTD
+ help
+ Create extended header file compatible with "big" bootchartd.
+ "Big" bootchartd is a shell script and it dumps some
+ "convenient" info int the header, such as:
+ title = Boot chart for `hostname` (`date`)
+ system.uname = `uname -srvm`
+ system.release = `cat /etc/DISTRO-release`
+ system.cpu = `grep '^model name' /proc/cpuinfo | head -1` ($cpucount)
+ system.kernel.options = `cat /proc/cmdline`
+ This data is not mandatory for bootchart graph generation,
+ and is considered bloat. Nevertheless, this option
+ makes bootchartd applet to dump a subset of it.
+
+config BUSYBOX_CONFIG_FEATURE_BOOTCHARTD_CONFIG_FILE
+ bool "Support bootchartd.conf"
+ default n
+ depends on BUSYBOX_CONFIG_BOOTCHARTD
+ help
+ Enable reading and parsing of $PWD/bootchartd.conf
+ and /etc/bootchartd.conf files.
+config BUSYBOX_CONFIG_HALT
+ bool "poweroff, halt, and reboot"
+ default y
+ help
+ Stop all processes and either halt, reboot, or power off the system.
+
+config BUSYBOX_CONFIG_FEATURE_CALL_TELINIT
+ bool "Call telinit on shutdown and reboot"
+ default n
+ depends on BUSYBOX_CONFIG_HALT && !BUSYBOX_CONFIG_INIT
+ help
+ Call an external program (normally telinit) to facilitate
+ a switch to a proper runlevel.
+
+ This option is only available if you selected halt and friends,
+ but did not select init.
+
+config BUSYBOX_CONFIG_TELINIT_PATH
+ string "Path to telinit executable"
+ default "/sbin/telinit"
+ depends on BUSYBOX_CONFIG_FEATURE_CALL_TELINIT
+ help
+ When busybox halt and friends have to call external telinit
+ to facilitate proper shutdown, this path is to be used when
+ locating telinit executable.
+config BUSYBOX_CONFIG_INIT
+ bool "init"
+ default y
+ select BUSYBOX_CONFIG_FEATURE_SYSLOG
+ depends on !PROCD_INIT
+ help
+ init is the first program run when the system boots.
+
+config BUSYBOX_CONFIG_FEATURE_USE_INITTAB
+ bool "Support reading an inittab file"
+ default y
+ depends on BUSYBOX_CONFIG_INIT
+ help
+ Allow init to read an inittab file when the system boot.
+
+config BUSYBOX_CONFIG_FEATURE_KILL_REMOVED
+ bool "Support killing processes that have been removed from inittab"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_USE_INITTAB
+ help
+ When respawn entries are removed from inittab and a SIGHUP is
+ sent to init, this option will make init kill the processes
+ that have been removed.
+
+config BUSYBOX_CONFIG_FEATURE_KILL_DELAY
+ int "How long to wait between TERM and KILL (0 - send TERM only)" if FEATURE_KILL_REMOVED
+ range 0 1024
+ default 0
+ depends on BUSYBOX_CONFIG_FEATURE_KILL_REMOVED
+ help
+ With nonzero setting, init sends TERM, forks, child waits N
+ seconds, sends KILL and exits. Setting it too high is unwise
+ (child will hang around for too long and could actually kill
+ the wrong process!)
+
+config BUSYBOX_CONFIG_FEATURE_INIT_SCTTY
+ bool "Run commands with leading dash with controlling tty"
+ default n
+ depends on BUSYBOX_CONFIG_INIT
+ help
+ If this option is enabled, init will try to give a controlling
+ tty to any command which has leading hyphen (often it's "-/bin/sh").
+ More precisely, init will do "ioctl(STDIN_FILENO, TIOCSCTTY, 0)".
+ If device attached to STDIN_FILENO can be a ctty but is not yet
+ a ctty for other session, it will become this process' ctty.
+ This is not the traditional init behavour, but is often what you want
+ in an embedded system where the console is only accessed during
+ development or for maintenance.
+ NB: using cttyhack applet may work better.
+
+config BUSYBOX_CONFIG_FEATURE_INIT_SYSLOG
+ bool "Enable init to write to syslog"
+ default y
+ depends on BUSYBOX_CONFIG_INIT
+
+config BUSYBOX_CONFIG_FEATURE_EXTRA_QUIET
+ bool "Be _extra_ quiet on boot"
+ default n
+ depends on BUSYBOX_CONFIG_INIT
+ help
+ Prevent init from logging some messages to the console during boot.
+
+config BUSYBOX_CONFIG_FEATURE_INIT_COREDUMPS
+ bool "Support dumping core for child processes (debugging only)"
+ default n
+ depends on BUSYBOX_CONFIG_INIT
+ help
+ If this option is enabled and the file /.init_enable_core
+ exists, then init will call setrlimit() to allow unlimited
+ core file sizes. If this option is disabled, processes
+ will not generate any core files.
+
+config BUSYBOX_CONFIG_FEATURE_INITRD
+ bool "Support running init from within an initrd (not initramfs)"
+ default n
+ depends on BUSYBOX_CONFIG_INIT
+ help
+ Legacy support for running init under the old-style initrd. Allows
+ the name linuxrc to act as init, and it doesn't assume init is PID 1.
+
+ This does not apply to initramfs, which runs /init as PID 1 and
+ requires no special support.
+
+config BUSYBOX_CONFIG_INIT_TERMINAL_TYPE
+ string "Initial terminal type"
+ default "linux"
+ depends on BUSYBOX_CONFIG_INIT
+ help
+ This is the initial value set by init for the TERM environment
+ variable. This variable is used by programs which make use of
+ extended terminal capabilities.
+
+ Note that on Linux, init attempts to detect serial terminal and
+ sets TERM to "vt102" if one is found.
+config BUSYBOX_CONFIG_MESG
+ bool "mesg"
+ default n
+ help
+ Mesg controls access to your terminal by others. It is typically
+ used to allow or disallow other users to write to your terminal
+
+config BUSYBOX_CONFIG_FEATURE_MESG_ENABLE_ONLY_GROUP
+ bool "Enable writing to tty only by group, not by everybody"
+ default n
+ depends on BUSYBOX_CONFIG_MESG
+ help
+ Usually, ttys are owned by group "tty", and "write" tool is
+ setgid to this group. This way, "mesg y" only needs to enable
+ "write by owning group" bit in tty mode.
+
+ If you set this option to N, "mesg y" will enable writing
+ by anybody at all. This is not recommended.
+
+endmenu
diff --git a/package/busybox/config/libbb/.svn/entries b/package/busybox/config/libbb/.svn/entries
new file mode 100644
index 0000000..2e576c6
--- /dev/null
+++ b/package/busybox/config/libbb/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/busybox/config/libbb
+svn://svn.openwrt.org/openwrt
+
+
+
+2011-10-21T23:08:45.031764Z
+28513
+nico
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+Config.in
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+b44992a77fc493bf44f1839fd2108da3
+2011-10-21T23:08:45.031764Z
+28513
+nico
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+7618
+
diff --git a/package/busybox/config/libbb/.svn/prop-base/Config.in.svn-base b/package/busybox/config/libbb/.svn/prop-base/Config.in.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/busybox/config/libbb/.svn/prop-base/Config.in.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/busybox/config/libbb/.svn/text-base/Config.in.svn-base b/package/busybox/config/libbb/.svn/text-base/Config.in.svn-base
new file mode 100644
index 0000000..6475403
--- /dev/null
+++ b/package/busybox/config/libbb/.svn/text-base/Config.in.svn-base
@@ -0,0 +1,232 @@
+# DO NOT EDIT. This file is generated from Config.src
+#
+# For a description of the syntax of this configuration file,
+# see scripts/kbuild/config-language.txt.
+#
+
+menu "Busybox Library Tuning"
+
+config BUSYBOX_CONFIG_FEATURE_SYSTEMD
+ bool "Enable systemd support"
+ default n
+ help
+ If you plan to use busybox daemons on a system where daemons
+ are controlled by systemd, enable this option.
+ If you don't use systemd, it is still safe to enable it,
+ but the downside is increased code size.
+config BUSYBOX_CONFIG_FEATURE_RTMINMAX
+ bool "Support RTMIN[+n] and RTMAX[-n] signal names"
+ default n
+ help
+ Support RTMIN[+n] and RTMAX[-n] signal names
+ in kill, killall etc. This costs ~250 bytes.
+
+config BUSYBOX_CONFIG_PASSWORD_MINLEN
+ int "Minimum password length"
+ default 6
+ range 5 32
+ help
+ Minimum allowable password length.
+
+config BUSYBOX_CONFIG_MD5_SIZE_VS_SPEED
+ int "MD5: Trade bytes for speed (0:fast, 3:slow)"
+ default 2
+ range 0 3
+ help
+ Trade binary size versus speed for the md5sum algorithm.
+ Approximate values running uClibc and hashing
+ linux-2.4.4.tar.bz2 were:
+ user times (sec) text size (386)
+ 0 (fastest) 1.1 6144
+ 1 1.4 5392
+ 2 3.0 5088
+ 3 (smallest) 5.1 4912
+
+config BUSYBOX_CONFIG_FEATURE_FAST_TOP
+ bool "Faster /proc scanning code (+100 bytes)"
+ default y
+ help
+ This option makes top (and ps) ~20% faster (or 20% less CPU hungry),
+ but code size is slightly bigger.
+
+config BUSYBOX_CONFIG_FEATURE_ETC_NETWORKS
+ bool "Support for /etc/networks"
+ default n
+ help
+ Enable support for network names in /etc/networks. This is
+ a rarely used feature which allows you to use names
+ instead of IP/mask pairs in route command.
+
+config BUSYBOX_CONFIG_FEATURE_USE_TERMIOS
+ bool "Use termios to manipulate the screen"
+ default n
+ depends on BUSYBOX_CONFIG_MORE || BUSYBOX_CONFIG_TOP || BUSYBOX_CONFIG_POWERTOP
+ help
+ This option allows utilities such as 'more' and 'top' to determine
+ the size of the screen. If you leave this disabled, your utilities
+ that display things on the screen will be especially primitive and
+ will be unable to determine the current screen size, and will be
+ unable to move the cursor.
+
+config BUSYBOX_CONFIG_FEATURE_EDITING
+ bool "Command line editing"
+ default y
+ help
+ Enable line editing (mainly for shell command line).
+
+config BUSYBOX_CONFIG_FEATURE_EDITING_MAX_LEN
+ int "Maximum length of input"
+ range 128 8192
+ default 512
+ depends on BUSYBOX_CONFIG_FEATURE_EDITING
+ help
+ Line editing code uses on-stack buffers for storage.
+ You may want to decrease this parameter if your target machine
+ benefits from smaller stack usage.
+
+config BUSYBOX_CONFIG_FEATURE_EDITING_VI
+ bool "vi-style line editing commands"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_EDITING
+ help
+ Enable vi-style line editing. In shells, this mode can be
+ turned on and off with "set -o vi" and "set +o vi".
+
+config BUSYBOX_CONFIG_FEATURE_EDITING_HISTORY
+ int "History size"
+ # Don't allow way too big values here, code uses fixed "char *history[N]" struct member
+ range 0 9999
+ default 256
+ depends on BUSYBOX_CONFIG_FEATURE_EDITING
+ help
+ Specify command history size (0 - disable).
+
+config BUSYBOX_CONFIG_FEATURE_EDITING_SAVEHISTORY
+ bool "History saving"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_EDITING
+ help
+ Enable history saving in shells.
+
+config BUSYBOX_CONFIG_FEATURE_REVERSE_SEARCH
+ bool "Reverse history search"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_EDITING_SAVEHISTORY
+ help
+ Enable readline-like Ctrl-R combination for reverse history search.
+ Increases code by about 0.5k.
+
+config BUSYBOX_CONFIG_FEATURE_TAB_COMPLETION
+ bool "Tab completion"
+ default y
+ depends on BUSYBOX_CONFIG_FEATURE_EDITING
+ help
+ Enable tab completion.
+
+config BUSYBOX_CONFIG_FEATURE_USERNAME_COMPLETION
+ bool "Username completion"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_TAB_COMPLETION
+ help
+ Enable username completion.
+
+config BUSYBOX_CONFIG_FEATURE_EDITING_FANCY_PROMPT
+ bool "Fancy shell prompts"
+ default y
+ depends on BUSYBOX_CONFIG_FEATURE_EDITING
+ help
+ Setting this option allows for prompts to use things like \w and
+ \$ and escape codes.
+
+config BUSYBOX_CONFIG_FEATURE_EDITING_ASK_TERMINAL
+ bool "Query cursor position from terminal"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_EDITING
+ help
+ Allow usage of "ESC [ 6 n" sequence. Terminal answers back with
+ current cursor position. This information is used to make line
+ editing more robust in some cases.
+ If you are not sure whether your terminals respond to this code
+ correctly, or want to save on code size (about 400 bytes),
+ then do not turn this option on.
+
+config BUSYBOX_CONFIG_FEATURE_NON_POSIX_CP
+ bool "Non-POSIX, but safer, copying to special nodes"
+ default y
+ help
+ With this option, "cp file symlink" will delete symlink
+ and create a regular file. This does not conform to POSIX,
+ but prevents a symlink attack.
+ Similarly, "cp file device" will not send file's data
+ to the device. (To do that, use "cat file >device")
+
+config BUSYBOX_CONFIG_FEATURE_VERBOSE_CP_MESSAGE
+ bool "Give more precise messages when copy fails (cp, mv etc)"
+ default n
+ help
+ Error messages with this feature enabled:
+ $ cp file /does_not_exist/file
+ cp: cannot create '/does_not_exist/file': Path does not exist
+ $ cp file /vmlinuz/file
+ cp: cannot stat '/vmlinuz/file': Path has non-directory component
+ If this feature is not enabled, they will be, respectively:
+ cp: cannot create '/does_not_exist/file': No such file or directory
+ cp: cannot stat '/vmlinuz/file': Not a directory
+ This will cost you ~60 bytes.
+
+config BUSYBOX_CONFIG_FEATURE_COPYBUF_KB
+ int "Copy buffer size, in kilobytes"
+ range 1 1024
+ default 4
+ help
+ Size of buffer used by cp, mv, install, wget etc.
+ Buffers which are 4 kb or less will be allocated on stack.
+ Bigger buffers will be allocated with mmap, with fallback to 4 kb
+ stack buffer if mmap fails.
+
+config BUSYBOX_CONFIG_FEATURE_SKIP_ROOTFS
+ bool "Skip rootfs in mount table"
+ default n
+ help
+ Ignore rootfs entry in mount table.
+
+ In Linux, kernel has a special filesystem, rootfs, which is initially
+ mounted on /. It contains initramfs data, if kernel is configured
+ to have one. Usually, another file system is mounted over / early
+ in boot process, and therefore most tools which manipulate
+ mount table, such as df, will skip rootfs entry.
+
+ However, some systems do not mount anything on /.
+ If you need to configure busybox for one of these systems,
+ you may find useful to turn this option off to make df show
+ initramfs statistic.
+
+ Otherwise, choose Y.
+
+config BUSYBOX_CONFIG_MONOTONIC_SYSCALL
+ bool "Use clock_gettime(CLOCK_MONOTONIC) syscall"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Use clock_gettime(CLOCK_MONOTONIC) syscall for measuring
+ time intervals (time, ping, traceroute etc need this).
+ Probably requires Linux 2.6+. If not selected, gettimeofday
+ will be used instead (which gives wrong results if date/time
+ is reset).
+
+config BUSYBOX_CONFIG_IOCTL_HEX2STR_ERROR
+ bool "Use ioctl names rather than hex values in error messages"
+ default y
+ help
+ Use ioctl names rather than hex values in error messages
+ (e.g. VT_DISALLOCATE rather than 0x5608). If disabled this
+ saves about 1400 bytes.
+
+config BUSYBOX_CONFIG_FEATURE_HWIB
+ bool "Support infiniband HW"
+ default n
+ help
+ Support for printing infiniband addresses in
+ network applets.
+
+endmenu
diff --git a/package/busybox/config/libbb/Config.in b/package/busybox/config/libbb/Config.in
new file mode 100644
index 0000000..6475403
--- /dev/null
+++ b/package/busybox/config/libbb/Config.in
@@ -0,0 +1,232 @@
+# DO NOT EDIT. This file is generated from Config.src
+#
+# For a description of the syntax of this configuration file,
+# see scripts/kbuild/config-language.txt.
+#
+
+menu "Busybox Library Tuning"
+
+config BUSYBOX_CONFIG_FEATURE_SYSTEMD
+ bool "Enable systemd support"
+ default n
+ help
+ If you plan to use busybox daemons on a system where daemons
+ are controlled by systemd, enable this option.
+ If you don't use systemd, it is still safe to enable it,
+ but the downside is increased code size.
+config BUSYBOX_CONFIG_FEATURE_RTMINMAX
+ bool "Support RTMIN[+n] and RTMAX[-n] signal names"
+ default n
+ help
+ Support RTMIN[+n] and RTMAX[-n] signal names
+ in kill, killall etc. This costs ~250 bytes.
+
+config BUSYBOX_CONFIG_PASSWORD_MINLEN
+ int "Minimum password length"
+ default 6
+ range 5 32
+ help
+ Minimum allowable password length.
+
+config BUSYBOX_CONFIG_MD5_SIZE_VS_SPEED
+ int "MD5: Trade bytes for speed (0:fast, 3:slow)"
+ default 2
+ range 0 3
+ help
+ Trade binary size versus speed for the md5sum algorithm.
+ Approximate values running uClibc and hashing
+ linux-2.4.4.tar.bz2 were:
+ user times (sec) text size (386)
+ 0 (fastest) 1.1 6144
+ 1 1.4 5392
+ 2 3.0 5088
+ 3 (smallest) 5.1 4912
+
+config BUSYBOX_CONFIG_FEATURE_FAST_TOP
+ bool "Faster /proc scanning code (+100 bytes)"
+ default y
+ help
+ This option makes top (and ps) ~20% faster (or 20% less CPU hungry),
+ but code size is slightly bigger.
+
+config BUSYBOX_CONFIG_FEATURE_ETC_NETWORKS
+ bool "Support for /etc/networks"
+ default n
+ help
+ Enable support for network names in /etc/networks. This is
+ a rarely used feature which allows you to use names
+ instead of IP/mask pairs in route command.
+
+config BUSYBOX_CONFIG_FEATURE_USE_TERMIOS
+ bool "Use termios to manipulate the screen"
+ default n
+ depends on BUSYBOX_CONFIG_MORE || BUSYBOX_CONFIG_TOP || BUSYBOX_CONFIG_POWERTOP
+ help
+ This option allows utilities such as 'more' and 'top' to determine
+ the size of the screen. If you leave this disabled, your utilities
+ that display things on the screen will be especially primitive and
+ will be unable to determine the current screen size, and will be
+ unable to move the cursor.
+
+config BUSYBOX_CONFIG_FEATURE_EDITING
+ bool "Command line editing"
+ default y
+ help
+ Enable line editing (mainly for shell command line).
+
+config BUSYBOX_CONFIG_FEATURE_EDITING_MAX_LEN
+ int "Maximum length of input"
+ range 128 8192
+ default 512
+ depends on BUSYBOX_CONFIG_FEATURE_EDITING
+ help
+ Line editing code uses on-stack buffers for storage.
+ You may want to decrease this parameter if your target machine
+ benefits from smaller stack usage.
+
+config BUSYBOX_CONFIG_FEATURE_EDITING_VI
+ bool "vi-style line editing commands"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_EDITING
+ help
+ Enable vi-style line editing. In shells, this mode can be
+ turned on and off with "set -o vi" and "set +o vi".
+
+config BUSYBOX_CONFIG_FEATURE_EDITING_HISTORY
+ int "History size"
+ # Don't allow way too big values here, code uses fixed "char *history[N]" struct member
+ range 0 9999
+ default 256
+ depends on BUSYBOX_CONFIG_FEATURE_EDITING
+ help
+ Specify command history size (0 - disable).
+
+config BUSYBOX_CONFIG_FEATURE_EDITING_SAVEHISTORY
+ bool "History saving"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_EDITING
+ help
+ Enable history saving in shells.
+
+config BUSYBOX_CONFIG_FEATURE_REVERSE_SEARCH
+ bool "Reverse history search"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_EDITING_SAVEHISTORY
+ help
+ Enable readline-like Ctrl-R combination for reverse history search.
+ Increases code by about 0.5k.
+
+config BUSYBOX_CONFIG_FEATURE_TAB_COMPLETION
+ bool "Tab completion"
+ default y
+ depends on BUSYBOX_CONFIG_FEATURE_EDITING
+ help
+ Enable tab completion.
+
+config BUSYBOX_CONFIG_FEATURE_USERNAME_COMPLETION
+ bool "Username completion"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_TAB_COMPLETION
+ help
+ Enable username completion.
+
+config BUSYBOX_CONFIG_FEATURE_EDITING_FANCY_PROMPT
+ bool "Fancy shell prompts"
+ default y
+ depends on BUSYBOX_CONFIG_FEATURE_EDITING
+ help
+ Setting this option allows for prompts to use things like \w and
+ \$ and escape codes.
+
+config BUSYBOX_CONFIG_FEATURE_EDITING_ASK_TERMINAL
+ bool "Query cursor position from terminal"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_EDITING
+ help
+ Allow usage of "ESC [ 6 n" sequence. Terminal answers back with
+ current cursor position. This information is used to make line
+ editing more robust in some cases.
+ If you are not sure whether your terminals respond to this code
+ correctly, or want to save on code size (about 400 bytes),
+ then do not turn this option on.
+
+config BUSYBOX_CONFIG_FEATURE_NON_POSIX_CP
+ bool "Non-POSIX, but safer, copying to special nodes"
+ default y
+ help
+ With this option, "cp file symlink" will delete symlink
+ and create a regular file. This does not conform to POSIX,
+ but prevents a symlink attack.
+ Similarly, "cp file device" will not send file's data
+ to the device. (To do that, use "cat file >device")
+
+config BUSYBOX_CONFIG_FEATURE_VERBOSE_CP_MESSAGE
+ bool "Give more precise messages when copy fails (cp, mv etc)"
+ default n
+ help
+ Error messages with this feature enabled:
+ $ cp file /does_not_exist/file
+ cp: cannot create '/does_not_exist/file': Path does not exist
+ $ cp file /vmlinuz/file
+ cp: cannot stat '/vmlinuz/file': Path has non-directory component
+ If this feature is not enabled, they will be, respectively:
+ cp: cannot create '/does_not_exist/file': No such file or directory
+ cp: cannot stat '/vmlinuz/file': Not a directory
+ This will cost you ~60 bytes.
+
+config BUSYBOX_CONFIG_FEATURE_COPYBUF_KB
+ int "Copy buffer size, in kilobytes"
+ range 1 1024
+ default 4
+ help
+ Size of buffer used by cp, mv, install, wget etc.
+ Buffers which are 4 kb or less will be allocated on stack.
+ Bigger buffers will be allocated with mmap, with fallback to 4 kb
+ stack buffer if mmap fails.
+
+config BUSYBOX_CONFIG_FEATURE_SKIP_ROOTFS
+ bool "Skip rootfs in mount table"
+ default n
+ help
+ Ignore rootfs entry in mount table.
+
+ In Linux, kernel has a special filesystem, rootfs, which is initially
+ mounted on /. It contains initramfs data, if kernel is configured
+ to have one. Usually, another file system is mounted over / early
+ in boot process, and therefore most tools which manipulate
+ mount table, such as df, will skip rootfs entry.
+
+ However, some systems do not mount anything on /.
+ If you need to configure busybox for one of these systems,
+ you may find useful to turn this option off to make df show
+ initramfs statistic.
+
+ Otherwise, choose Y.
+
+config BUSYBOX_CONFIG_MONOTONIC_SYSCALL
+ bool "Use clock_gettime(CLOCK_MONOTONIC) syscall"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Use clock_gettime(CLOCK_MONOTONIC) syscall for measuring
+ time intervals (time, ping, traceroute etc need this).
+ Probably requires Linux 2.6+. If not selected, gettimeofday
+ will be used instead (which gives wrong results if date/time
+ is reset).
+
+config BUSYBOX_CONFIG_IOCTL_HEX2STR_ERROR
+ bool "Use ioctl names rather than hex values in error messages"
+ default y
+ help
+ Use ioctl names rather than hex values in error messages
+ (e.g. VT_DISALLOCATE rather than 0x5608). If disabled this
+ saves about 1400 bytes.
+
+config BUSYBOX_CONFIG_FEATURE_HWIB
+ bool "Support infiniband HW"
+ default n
+ help
+ Support for printing infiniband addresses in
+ network applets.
+
+endmenu
diff --git a/package/busybox/config/loginutils/.svn/entries b/package/busybox/config/loginutils/.svn/entries
new file mode 100644
index 0000000..9853c28
--- /dev/null
+++ b/package/busybox/config/loginutils/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/busybox/config/loginutils
+svn://svn.openwrt.org/openwrt
+
+
+
+2011-11-10T12:55:01.182810Z
+28936
+kaloz
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+Config.in
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+d4dc25e32d832d81269a2eddb39c2d63
+2011-11-10T12:55:01.182810Z
+28936
+kaloz
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+10708
+
diff --git a/package/busybox/config/loginutils/.svn/prop-base/Config.in.svn-base b/package/busybox/config/loginutils/.svn/prop-base/Config.in.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/busybox/config/loginutils/.svn/prop-base/Config.in.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/busybox/config/loginutils/.svn/text-base/Config.in.svn-base b/package/busybox/config/loginutils/.svn/text-base/Config.in.svn-base
new file mode 100644
index 0000000..8c32851
--- /dev/null
+++ b/package/busybox/config/loginutils/.svn/text-base/Config.in.svn-base
@@ -0,0 +1,329 @@
+# DO NOT EDIT. This file is generated from Config.src
+#
+# For a description of the syntax of this configuration file,
+# see scripts/kbuild/config-language.txt.
+#
+
+menu "Login/Password Management Utilities"
+
+config BUSYBOX_CONFIG_ADD_SHELL
+ bool "add-shell"
+ default n if BUSYBOX_CONFIG_DESKTOP
+ help
+ Add shells to /etc/shells.
+
+config BUSYBOX_CONFIG_REMOVE_SHELL
+ bool "remove-shell"
+ default n if BUSYBOX_CONFIG_DESKTOP
+ help
+ Remove shells from /etc/shells.
+
+config BUSYBOX_CONFIG_FEATURE_SHADOWPASSWDS
+ bool "Support for shadow passwords"
+ default y
+ help
+ Build support for shadow password in /etc/shadow. This file is only
+ readable by root and thus the encrypted passwords are no longer
+ publicly readable.
+
+config BUSYBOX_CONFIG_USE_BB_PWD_GRP
+ bool "Use internal password and group functions rather than system functions"
+ default n
+ help
+ If you leave this disabled, busybox will use the system's password
+ and group functions. And if you are using the GNU C library
+ (glibc), you will then need to install the /etc/nsswitch.conf
+ configuration file and the required /lib/libnss_* libraries in
+ order for the password and group functions to work. This generally
+ makes your embedded system quite a bit larger.
+
+ Enabling this option will cause busybox to directly access the
+ system's /etc/password, /etc/group files (and your system will be
+ smaller, and I will get fewer emails asking about how glibc NSS
+ works). When this option is enabled, you will not be able to use
+ PAM to access remote LDAP password servers and whatnot. And if you
+ want hostname resolution to work with glibc, you still need the
+ /lib/libnss_* libraries.
+
+ If you need to use glibc's nsswitch.conf mechanism
+ (e.g. if user/group database is NOT stored in /etc/passwd etc),
+ you must NOT use this option.
+
+ If you enable this option, it will add about 1.5k.
+
+config BUSYBOX_CONFIG_USE_BB_SHADOW
+ bool "Use internal shadow password functions"
+ default n
+ depends on BUSYBOX_CONFIG_USE_BB_PWD_GRP && BUSYBOX_CONFIG_FEATURE_SHADOWPASSWDS
+ help
+ If you leave this disabled, busybox will use the system's shadow
+ password handling functions. And if you are using the GNU C library
+ (glibc), you will then need to install the /etc/nsswitch.conf
+ configuration file and the required /lib/libnss_* libraries in
+ order for the shadow password functions to work. This generally
+ makes your embedded system quite a bit larger.
+
+ Enabling this option will cause busybox to directly access the
+ system's /etc/shadow file when handling shadow passwords. This
+ makes your system smaller (and I will get fewer emails asking about
+ how glibc NSS works). When this option is enabled, you will not be
+ able to use PAM to access shadow passwords from remote LDAP
+ password servers and whatnot.
+
+config BUSYBOX_CONFIG_USE_BB_CRYPT
+ bool "Use internal crypt functions"
+ default n
+ help
+ Busybox has internal DES and MD5 crypt functions.
+ They produce results which are identical to corresponding
+ standard C library functions.
+
+ If you leave this disabled, busybox will use the system's
+ crypt functions. Most C libraries use large (~70k)
+ static buffers there, and also combine them with more general
+ DES encryption/decryption.
+
+ For busybox, having large static buffers is undesirable,
+ especially on NOMMU machines. Busybox also doesn't need
+ DES encryption/decryption and can do with smaller code.
+
+ If you enable this option, it will add about 4.8k of code
+ if you are building dynamically linked executable.
+ In static build, it makes code _smaller_ by about 1.2k,
+ and likely many kilobytes less of bss.
+
+config BUSYBOX_CONFIG_USE_BB_CRYPT_SHA
+ bool "Enable SHA256/512 crypt functions"
+ default n
+ depends on BUSYBOX_CONFIG_USE_BB_CRYPT
+ help
+ Enable this if you have passwords starting with "$5$" or "$6$"
+ in your /etc/passwd or /etc/shadow files. These passwords
+ are hashed using SHA256 and SHA512 algorithms. Support for them
+ was added to glibc in 2008.
+ With this option off, login will fail password check for any
+ user which has password encrypted with these algorithms.
+
+config BUSYBOX_CONFIG_ADDUSER
+ bool "adduser"
+ default n
+ help
+ Utility for creating a new user account.
+
+config BUSYBOX_CONFIG_FEATURE_ADDUSER_LONG_OPTIONS
+ bool "Enable long options"
+ default n
+ depends on BUSYBOX_CONFIG_ADDUSER && BUSYBOX_CONFIG_LONG_OPTS
+ help
+ Support long options for the adduser applet.
+
+config BUSYBOX_CONFIG_FEATURE_CHECK_NAMES
+ bool "Enable sanity check on user/group names in adduser and addgroup"
+ default n
+ depends on BUSYBOX_CONFIG_ADDUSER || BUSYBOX_CONFIG_ADDGROUP
+ help
+ Enable sanity check on user and group names in adduser and addgroup.
+ To avoid problems, the user or group name should consist only of
+ letters, digits, underscores, periods, at signs and dashes,
+ and not start with a dash (as defined by IEEE Std 1003.1-2001).
+ For compatibility with Samba machine accounts "$" is also supported
+ at the end of the user or group name.
+
+config BUSYBOX_CONFIG_FIRST_SYSTEM_ID
+ int "First valid system uid or gid for adduser and addgroup"
+ depends on BUSYBOX_CONFIG_ADDUSER || BUSYBOX_CONFIG_ADDGROUP
+ range 0 64900
+ default 100
+ help
+ First valid system uid or gid for adduser and addgroup
+
+config BUSYBOX_CONFIG_LAST_SYSTEM_ID
+ int "Last valid system uid or gid for adduser and addgroup"
+ depends on BUSYBOX_CONFIG_ADDUSER || BUSYBOX_CONFIG_ADDGROUP
+ range 0 64900
+ default 999
+ help
+ Last valid system uid or gid for adduser and addgroup
+
+config BUSYBOX_CONFIG_ADDGROUP
+ bool "addgroup"
+ default n
+ help
+ Utility for creating a new group account.
+
+config BUSYBOX_CONFIG_FEATURE_ADDGROUP_LONG_OPTIONS
+ bool "Enable long options"
+ default n
+ depends on BUSYBOX_CONFIG_ADDGROUP && BUSYBOX_CONFIG_LONG_OPTS
+ help
+ Support long options for the addgroup applet.
+
+config BUSYBOX_CONFIG_FEATURE_ADDUSER_TO_GROUP
+ bool "Support for adding users to groups"
+ default n
+ depends on BUSYBOX_CONFIG_ADDGROUP
+ help
+ If called with two non-option arguments,
+ addgroup will add an existing user to an
+ existing group.
+
+config BUSYBOX_CONFIG_DELUSER
+ bool "deluser"
+ default n
+ help
+ Utility for deleting a user account.
+
+config BUSYBOX_CONFIG_DELGROUP
+ bool "delgroup"
+ default n
+ help
+ Utility for deleting a group account.
+
+config BUSYBOX_CONFIG_FEATURE_DEL_USER_FROM_GROUP
+ bool "Support for removing users from groups"
+ default n
+ depends on BUSYBOX_CONFIG_DELGROUP
+ help
+ If called with two non-option arguments, deluser
+ or delgroup will remove an user from a specified group.
+
+config BUSYBOX_CONFIG_GETTY
+ bool "getty"
+ default n
+ select BUSYBOX_CONFIG_FEATURE_SYSLOG
+ help
+ getty lets you log in on a tty. It is normally invoked by init.
+
+ Note that you can save a few bytes by disabling it and
+ using login applet directly.
+ If you need to reset tty attributes before calling login,
+ this script approximates getty:
+
+ exec </dev/$1 >/dev/$1 2>&1 || exit 1
+ reset
+ stty sane; stty ispeed 38400; stty ospeed 38400
+ printf "%s login: " "`hostname`"
+ read -r login
+ exec /bin/login "$login"
+
+config BUSYBOX_CONFIG_LOGIN
+ bool "login"
+ default n
+ select BUSYBOX_CONFIG_FEATURE_SYSLOG
+ help
+ login is used when signing onto a system.
+
+ Note that Busybox binary must be setuid root for this applet to
+ work properly.
+
+config BUSYBOX_CONFIG_PAM
+ bool "Support for PAM (Pluggable Authentication Modules)"
+ default n
+ depends on DEVEL
+ depends on BUSYBOX_CONFIG_LOGIN
+ help
+ Use PAM in login(1) instead of direct access to password database.
+
+ OpenWrt specific:
+ You should install libpam from the packages feed and compile it
+ before trying to build busysbox.
+
+config BUSYBOX_CONFIG_LOGIN_SCRIPTS
+ bool "Support for login scripts"
+ depends on BUSYBOX_CONFIG_LOGIN
+ default n
+ help
+ Enable this if you want login to execute $LOGIN_PRE_SUID_SCRIPT
+ just prior to switching from root to logged-in user.
+
+config BUSYBOX_CONFIG_FEATURE_NOLOGIN
+ bool "Support for /etc/nologin"
+ default n
+ depends on BUSYBOX_CONFIG_LOGIN
+ help
+ The file /etc/nologin is used by (some versions of) login(1).
+ If it exists, non-root logins are prohibited.
+
+config BUSYBOX_CONFIG_FEATURE_SECURETTY
+ bool "Support for /etc/securetty"
+ default n
+ depends on BUSYBOX_CONFIG_LOGIN
+ help
+ The file /etc/securetty is used by (some versions of) login(1).
+ The file contains the device names of tty lines (one per line,
+ without leading /dev/) on which root is allowed to login.
+
+config BUSYBOX_CONFIG_PASSWD
+ bool "passwd"
+ default y
+ select BUSYBOX_CONFIG_FEATURE_SYSLOG
+ help
+ passwd changes passwords for user and group accounts. A normal user
+ may only change the password for his/her own account, the super user
+ may change the password for any account. The administrator of a group
+ may change the password for the group.
+
+ Note that Busybox binary must be setuid root for this applet to
+ work properly.
+
+config BUSYBOX_CONFIG_FEATURE_PASSWD_WEAK_CHECK
+ bool "Check new passwords for weakness"
+ default y
+ depends on BUSYBOX_CONFIG_PASSWD
+ help
+ With this option passwd will refuse new passwords which are "weak".
+
+config BUSYBOX_CONFIG_CRYPTPW
+ bool "cryptpw"
+ default n
+ help
+ Encrypts the given password with the crypt(3) libc function
+ using the given salt. Debian has this utility under mkpasswd
+ name. Busybox provides mkpasswd as an alias for cryptpw.
+
+config BUSYBOX_CONFIG_CHPASSWD
+ bool "chpasswd"
+ default n
+ help
+ Reads a file of user name and password pairs from standard input
+ and uses this information to update a group of existing users.
+
+config BUSYBOX_CONFIG_SU
+ bool "su"
+ default n
+ select BUSYBOX_CONFIG_FEATURE_SYSLOG
+ help
+ su is used to become another user during a login session.
+ Invoked without a username, su defaults to becoming the super user.
+
+ Note that Busybox binary must be setuid root for this applet to
+ work properly.
+
+config BUSYBOX_CONFIG_FEATURE_SU_SYSLOG
+ bool "Enable su to write to syslog"
+ default n
+ depends on BUSYBOX_CONFIG_SU
+
+config BUSYBOX_CONFIG_FEATURE_SU_CHECKS_SHELLS
+ bool "Enable su to check user's shell to be listed in /etc/shells"
+ depends on BUSYBOX_CONFIG_SU
+ default n
+
+config BUSYBOX_CONFIG_SULOGIN
+ bool "sulogin"
+ default n
+ select BUSYBOX_CONFIG_FEATURE_SYSLOG
+ help
+ sulogin is invoked when the system goes into single user
+ mode (this is done through an entry in inittab).
+
+config BUSYBOX_CONFIG_VLOCK
+ bool "vlock"
+ default n
+ help
+ Build the "vlock" applet which allows you to lock (virtual) terminals.
+
+ Note that Busybox binary must be setuid root for this applet to
+ work properly.
+
+endmenu
diff --git a/package/busybox/config/loginutils/Config.in b/package/busybox/config/loginutils/Config.in
new file mode 100644
index 0000000..8c32851
--- /dev/null
+++ b/package/busybox/config/loginutils/Config.in
@@ -0,0 +1,329 @@
+# DO NOT EDIT. This file is generated from Config.src
+#
+# For a description of the syntax of this configuration file,
+# see scripts/kbuild/config-language.txt.
+#
+
+menu "Login/Password Management Utilities"
+
+config BUSYBOX_CONFIG_ADD_SHELL
+ bool "add-shell"
+ default n if BUSYBOX_CONFIG_DESKTOP
+ help
+ Add shells to /etc/shells.
+
+config BUSYBOX_CONFIG_REMOVE_SHELL
+ bool "remove-shell"
+ default n if BUSYBOX_CONFIG_DESKTOP
+ help
+ Remove shells from /etc/shells.
+
+config BUSYBOX_CONFIG_FEATURE_SHADOWPASSWDS
+ bool "Support for shadow passwords"
+ default y
+ help
+ Build support for shadow password in /etc/shadow. This file is only
+ readable by root and thus the encrypted passwords are no longer
+ publicly readable.
+
+config BUSYBOX_CONFIG_USE_BB_PWD_GRP
+ bool "Use internal password and group functions rather than system functions"
+ default n
+ help
+ If you leave this disabled, busybox will use the system's password
+ and group functions. And if you are using the GNU C library
+ (glibc), you will then need to install the /etc/nsswitch.conf
+ configuration file and the required /lib/libnss_* libraries in
+ order for the password and group functions to work. This generally
+ makes your embedded system quite a bit larger.
+
+ Enabling this option will cause busybox to directly access the
+ system's /etc/password, /etc/group files (and your system will be
+ smaller, and I will get fewer emails asking about how glibc NSS
+ works). When this option is enabled, you will not be able to use
+ PAM to access remote LDAP password servers and whatnot. And if you
+ want hostname resolution to work with glibc, you still need the
+ /lib/libnss_* libraries.
+
+ If you need to use glibc's nsswitch.conf mechanism
+ (e.g. if user/group database is NOT stored in /etc/passwd etc),
+ you must NOT use this option.
+
+ If you enable this option, it will add about 1.5k.
+
+config BUSYBOX_CONFIG_USE_BB_SHADOW
+ bool "Use internal shadow password functions"
+ default n
+ depends on BUSYBOX_CONFIG_USE_BB_PWD_GRP && BUSYBOX_CONFIG_FEATURE_SHADOWPASSWDS
+ help
+ If you leave this disabled, busybox will use the system's shadow
+ password handling functions. And if you are using the GNU C library
+ (glibc), you will then need to install the /etc/nsswitch.conf
+ configuration file and the required /lib/libnss_* libraries in
+ order for the shadow password functions to work. This generally
+ makes your embedded system quite a bit larger.
+
+ Enabling this option will cause busybox to directly access the
+ system's /etc/shadow file when handling shadow passwords. This
+ makes your system smaller (and I will get fewer emails asking about
+ how glibc NSS works). When this option is enabled, you will not be
+ able to use PAM to access shadow passwords from remote LDAP
+ password servers and whatnot.
+
+config BUSYBOX_CONFIG_USE_BB_CRYPT
+ bool "Use internal crypt functions"
+ default n
+ help
+ Busybox has internal DES and MD5 crypt functions.
+ They produce results which are identical to corresponding
+ standard C library functions.
+
+ If you leave this disabled, busybox will use the system's
+ crypt functions. Most C libraries use large (~70k)
+ static buffers there, and also combine them with more general
+ DES encryption/decryption.
+
+ For busybox, having large static buffers is undesirable,
+ especially on NOMMU machines. Busybox also doesn't need
+ DES encryption/decryption and can do with smaller code.
+
+ If you enable this option, it will add about 4.8k of code
+ if you are building dynamically linked executable.
+ In static build, it makes code _smaller_ by about 1.2k,
+ and likely many kilobytes less of bss.
+
+config BUSYBOX_CONFIG_USE_BB_CRYPT_SHA
+ bool "Enable SHA256/512 crypt functions"
+ default n
+ depends on BUSYBOX_CONFIG_USE_BB_CRYPT
+ help
+ Enable this if you have passwords starting with "$5$" or "$6$"
+ in your /etc/passwd or /etc/shadow files. These passwords
+ are hashed using SHA256 and SHA512 algorithms. Support for them
+ was added to glibc in 2008.
+ With this option off, login will fail password check for any
+ user which has password encrypted with these algorithms.
+
+config BUSYBOX_CONFIG_ADDUSER
+ bool "adduser"
+ default n
+ help
+ Utility for creating a new user account.
+
+config BUSYBOX_CONFIG_FEATURE_ADDUSER_LONG_OPTIONS
+ bool "Enable long options"
+ default n
+ depends on BUSYBOX_CONFIG_ADDUSER && BUSYBOX_CONFIG_LONG_OPTS
+ help
+ Support long options for the adduser applet.
+
+config BUSYBOX_CONFIG_FEATURE_CHECK_NAMES
+ bool "Enable sanity check on user/group names in adduser and addgroup"
+ default n
+ depends on BUSYBOX_CONFIG_ADDUSER || BUSYBOX_CONFIG_ADDGROUP
+ help
+ Enable sanity check on user and group names in adduser and addgroup.
+ To avoid problems, the user or group name should consist only of
+ letters, digits, underscores, periods, at signs and dashes,
+ and not start with a dash (as defined by IEEE Std 1003.1-2001).
+ For compatibility with Samba machine accounts "$" is also supported
+ at the end of the user or group name.
+
+config BUSYBOX_CONFIG_FIRST_SYSTEM_ID
+ int "First valid system uid or gid for adduser and addgroup"
+ depends on BUSYBOX_CONFIG_ADDUSER || BUSYBOX_CONFIG_ADDGROUP
+ range 0 64900
+ default 100
+ help
+ First valid system uid or gid for adduser and addgroup
+
+config BUSYBOX_CONFIG_LAST_SYSTEM_ID
+ int "Last valid system uid or gid for adduser and addgroup"
+ depends on BUSYBOX_CONFIG_ADDUSER || BUSYBOX_CONFIG_ADDGROUP
+ range 0 64900
+ default 999
+ help
+ Last valid system uid or gid for adduser and addgroup
+
+config BUSYBOX_CONFIG_ADDGROUP
+ bool "addgroup"
+ default n
+ help
+ Utility for creating a new group account.
+
+config BUSYBOX_CONFIG_FEATURE_ADDGROUP_LONG_OPTIONS
+ bool "Enable long options"
+ default n
+ depends on BUSYBOX_CONFIG_ADDGROUP && BUSYBOX_CONFIG_LONG_OPTS
+ help
+ Support long options for the addgroup applet.
+
+config BUSYBOX_CONFIG_FEATURE_ADDUSER_TO_GROUP
+ bool "Support for adding users to groups"
+ default n
+ depends on BUSYBOX_CONFIG_ADDGROUP
+ help
+ If called with two non-option arguments,
+ addgroup will add an existing user to an
+ existing group.
+
+config BUSYBOX_CONFIG_DELUSER
+ bool "deluser"
+ default n
+ help
+ Utility for deleting a user account.
+
+config BUSYBOX_CONFIG_DELGROUP
+ bool "delgroup"
+ default n
+ help
+ Utility for deleting a group account.
+
+config BUSYBOX_CONFIG_FEATURE_DEL_USER_FROM_GROUP
+ bool "Support for removing users from groups"
+ default n
+ depends on BUSYBOX_CONFIG_DELGROUP
+ help
+ If called with two non-option arguments, deluser
+ or delgroup will remove an user from a specified group.
+
+config BUSYBOX_CONFIG_GETTY
+ bool "getty"
+ default n
+ select BUSYBOX_CONFIG_FEATURE_SYSLOG
+ help
+ getty lets you log in on a tty. It is normally invoked by init.
+
+ Note that you can save a few bytes by disabling it and
+ using login applet directly.
+ If you need to reset tty attributes before calling login,
+ this script approximates getty:
+
+ exec </dev/$1 >/dev/$1 2>&1 || exit 1
+ reset
+ stty sane; stty ispeed 38400; stty ospeed 38400
+ printf "%s login: " "`hostname`"
+ read -r login
+ exec /bin/login "$login"
+
+config BUSYBOX_CONFIG_LOGIN
+ bool "login"
+ default n
+ select BUSYBOX_CONFIG_FEATURE_SYSLOG
+ help
+ login is used when signing onto a system.
+
+ Note that Busybox binary must be setuid root for this applet to
+ work properly.
+
+config BUSYBOX_CONFIG_PAM
+ bool "Support for PAM (Pluggable Authentication Modules)"
+ default n
+ depends on DEVEL
+ depends on BUSYBOX_CONFIG_LOGIN
+ help
+ Use PAM in login(1) instead of direct access to password database.
+
+ OpenWrt specific:
+ You should install libpam from the packages feed and compile it
+ before trying to build busysbox.
+
+config BUSYBOX_CONFIG_LOGIN_SCRIPTS
+ bool "Support for login scripts"
+ depends on BUSYBOX_CONFIG_LOGIN
+ default n
+ help
+ Enable this if you want login to execute $LOGIN_PRE_SUID_SCRIPT
+ just prior to switching from root to logged-in user.
+
+config BUSYBOX_CONFIG_FEATURE_NOLOGIN
+ bool "Support for /etc/nologin"
+ default n
+ depends on BUSYBOX_CONFIG_LOGIN
+ help
+ The file /etc/nologin is used by (some versions of) login(1).
+ If it exists, non-root logins are prohibited.
+
+config BUSYBOX_CONFIG_FEATURE_SECURETTY
+ bool "Support for /etc/securetty"
+ default n
+ depends on BUSYBOX_CONFIG_LOGIN
+ help
+ The file /etc/securetty is used by (some versions of) login(1).
+ The file contains the device names of tty lines (one per line,
+ without leading /dev/) on which root is allowed to login.
+
+config BUSYBOX_CONFIG_PASSWD
+ bool "passwd"
+ default y
+ select BUSYBOX_CONFIG_FEATURE_SYSLOG
+ help
+ passwd changes passwords for user and group accounts. A normal user
+ may only change the password for his/her own account, the super user
+ may change the password for any account. The administrator of a group
+ may change the password for the group.
+
+ Note that Busybox binary must be setuid root for this applet to
+ work properly.
+
+config BUSYBOX_CONFIG_FEATURE_PASSWD_WEAK_CHECK
+ bool "Check new passwords for weakness"
+ default y
+ depends on BUSYBOX_CONFIG_PASSWD
+ help
+ With this option passwd will refuse new passwords which are "weak".
+
+config BUSYBOX_CONFIG_CRYPTPW
+ bool "cryptpw"
+ default n
+ help
+ Encrypts the given password with the crypt(3) libc function
+ using the given salt. Debian has this utility under mkpasswd
+ name. Busybox provides mkpasswd as an alias for cryptpw.
+
+config BUSYBOX_CONFIG_CHPASSWD
+ bool "chpasswd"
+ default n
+ help
+ Reads a file of user name and password pairs from standard input
+ and uses this information to update a group of existing users.
+
+config BUSYBOX_CONFIG_SU
+ bool "su"
+ default n
+ select BUSYBOX_CONFIG_FEATURE_SYSLOG
+ help
+ su is used to become another user during a login session.
+ Invoked without a username, su defaults to becoming the super user.
+
+ Note that Busybox binary must be setuid root for this applet to
+ work properly.
+
+config BUSYBOX_CONFIG_FEATURE_SU_SYSLOG
+ bool "Enable su to write to syslog"
+ default n
+ depends on BUSYBOX_CONFIG_SU
+
+config BUSYBOX_CONFIG_FEATURE_SU_CHECKS_SHELLS
+ bool "Enable su to check user's shell to be listed in /etc/shells"
+ depends on BUSYBOX_CONFIG_SU
+ default n
+
+config BUSYBOX_CONFIG_SULOGIN
+ bool "sulogin"
+ default n
+ select BUSYBOX_CONFIG_FEATURE_SYSLOG
+ help
+ sulogin is invoked when the system goes into single user
+ mode (this is done through an entry in inittab).
+
+config BUSYBOX_CONFIG_VLOCK
+ bool "vlock"
+ default n
+ help
+ Build the "vlock" applet which allows you to lock (virtual) terminals.
+
+ Note that Busybox binary must be setuid root for this applet to
+ work properly.
+
+endmenu
diff --git a/package/busybox/config/mailutils/.svn/entries b/package/busybox/config/mailutils/.svn/entries
new file mode 100644
index 0000000..7ad08eb
--- /dev/null
+++ b/package/busybox/config/mailutils/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/busybox/config/mailutils
+svn://svn.openwrt.org/openwrt
+
+
+
+2011-10-21T23:08:45.031764Z
+28513
+nico
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+Config.in
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+6af73e817e445629fe529051af1bffd1
+2011-10-21T23:08:45.031764Z
+28513
+nico
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1367
+
diff --git a/package/busybox/config/mailutils/.svn/text-base/Config.in.svn-base b/package/busybox/config/mailutils/.svn/text-base/Config.in.svn-base
new file mode 100644
index 0000000..8db3031
--- /dev/null
+++ b/package/busybox/config/mailutils/.svn/text-base/Config.in.svn-base
@@ -0,0 +1,56 @@
+# DO NOT EDIT. This file is generated from Config.src
+menu "Mail Utilities"
+
+
+
+config BUSYBOX_CONFIG_MAKEMIME
+ bool "makemime"
+ default n
+ help
+ Create MIME-formatted messages.
+
+config BUSYBOX_CONFIG_FEATURE_MIME_CHARSET
+ string "Default charset"
+ default n
+ depends on BUSYBOX_CONFIG_MAKEMIME || BUSYBOX_CONFIG_REFORMIME || BUSYBOX_CONFIG_SENDMAIL
+ help
+ Default charset of the message.
+
+config BUSYBOX_CONFIG_POPMAILDIR
+ bool "popmaildir"
+ default n
+ help
+ Simple yet powerful POP3 mail popper. Delivers content
+ of remote mailboxes to local Maildir.
+
+config BUSYBOX_CONFIG_FEATURE_POPMAILDIR_DELIVERY
+ bool "Allow message filters and custom delivery program"
+ default n
+ depends on BUSYBOX_CONFIG_POPMAILDIR
+ help
+ Allow to use a custom program to filter the content
+ of the message before actual delivery (-F "prog [args...]").
+ Allow to use a custom program for message actual delivery
+ (-M "prog [args...]").
+
+config BUSYBOX_CONFIG_REFORMIME
+ bool "reformime"
+ default n
+ help
+ Parse MIME-formatted messages.
+
+config BUSYBOX_CONFIG_FEATURE_REFORMIME_COMPAT
+ bool "Accept and ignore options other than -x and -X"
+ default n
+ depends on BUSYBOX_CONFIG_REFORMIME
+ help
+ Accept (for compatibility only) and ignore options
+ other than -x and -X.
+
+config BUSYBOX_CONFIG_SENDMAIL
+ bool "sendmail"
+ default n
+ help
+ Barebones sendmail.
+
+endmenu
diff --git a/package/busybox/config/mailutils/Config.in b/package/busybox/config/mailutils/Config.in
new file mode 100644
index 0000000..8db3031
--- /dev/null
+++ b/package/busybox/config/mailutils/Config.in
@@ -0,0 +1,56 @@
+# DO NOT EDIT. This file is generated from Config.src
+menu "Mail Utilities"
+
+
+
+config BUSYBOX_CONFIG_MAKEMIME
+ bool "makemime"
+ default n
+ help
+ Create MIME-formatted messages.
+
+config BUSYBOX_CONFIG_FEATURE_MIME_CHARSET
+ string "Default charset"
+ default n
+ depends on BUSYBOX_CONFIG_MAKEMIME || BUSYBOX_CONFIG_REFORMIME || BUSYBOX_CONFIG_SENDMAIL
+ help
+ Default charset of the message.
+
+config BUSYBOX_CONFIG_POPMAILDIR
+ bool "popmaildir"
+ default n
+ help
+ Simple yet powerful POP3 mail popper. Delivers content
+ of remote mailboxes to local Maildir.
+
+config BUSYBOX_CONFIG_FEATURE_POPMAILDIR_DELIVERY
+ bool "Allow message filters and custom delivery program"
+ default n
+ depends on BUSYBOX_CONFIG_POPMAILDIR
+ help
+ Allow to use a custom program to filter the content
+ of the message before actual delivery (-F "prog [args...]").
+ Allow to use a custom program for message actual delivery
+ (-M "prog [args...]").
+
+config BUSYBOX_CONFIG_REFORMIME
+ bool "reformime"
+ default n
+ help
+ Parse MIME-formatted messages.
+
+config BUSYBOX_CONFIG_FEATURE_REFORMIME_COMPAT
+ bool "Accept and ignore options other than -x and -X"
+ default n
+ depends on BUSYBOX_CONFIG_REFORMIME
+ help
+ Accept (for compatibility only) and ignore options
+ other than -x and -X.
+
+config BUSYBOX_CONFIG_SENDMAIL
+ bool "sendmail"
+ default n
+ help
+ Barebones sendmail.
+
+endmenu
diff --git a/package/busybox/config/miscutils/.svn/entries b/package/busybox/config/miscutils/.svn/entries
new file mode 100644
index 0000000..d4ce043
--- /dev/null
+++ b/package/busybox/config/miscutils/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/busybox/config/miscutils
+svn://svn.openwrt.org/openwrt
+
+
+
+2011-10-21T23:08:45.031764Z
+28513
+nico
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+Config.in
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+7636d4d9a9d2474f949c3585300b3361
+2011-10-21T23:08:45.031764Z
+28513
+nico
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+22374
+
diff --git a/package/busybox/config/miscutils/.svn/prop-base/Config.in.svn-base b/package/busybox/config/miscutils/.svn/prop-base/Config.in.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/busybox/config/miscutils/.svn/prop-base/Config.in.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/busybox/config/miscutils/.svn/text-base/Config.in.svn-base b/package/busybox/config/miscutils/.svn/text-base/Config.in.svn-base
new file mode 100644
index 0000000..e69d684
--- /dev/null
+++ b/package/busybox/config/miscutils/.svn/text-base/Config.in.svn-base
@@ -0,0 +1,766 @@
+# DO NOT EDIT. This file is generated from Config.src
+#
+# For a description of the syntax of this configuration file,
+# see scripts/kbuild/config-language.txt.
+#
+
+menu "Miscellaneous Utilities"
+
+config BUSYBOX_CONFIG_CONSPY
+ bool "conspy"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ A text-mode VNC like program for Linux virtual terminals.
+ example: conspy NUM shared access to console num
+ or conspy -nd NUM screenshot of console num
+ or conspy -cs NUM poor man's GNU screen like
+config BUSYBOX_CONFIG_LESS
+ bool "less"
+ default y
+ help
+ 'less' is a pager, meaning that it displays text files. It possesses
+ a wide array of features, and is an improvement over 'more'.
+
+config BUSYBOX_CONFIG_FEATURE_LESS_MAXLINES
+ int "Max number of input lines less will try to eat"
+ default 9999999
+ depends on BUSYBOX_CONFIG_LESS
+
+config BUSYBOX_CONFIG_FEATURE_LESS_BRACKETS
+ bool "Enable bracket searching"
+ default n
+ depends on BUSYBOX_CONFIG_LESS
+ help
+ This option adds the capability to search for matching left and right
+ brackets, facilitating programming.
+
+config BUSYBOX_CONFIG_FEATURE_LESS_FLAGS
+ bool "Enable extra flags"
+ default n
+ depends on BUSYBOX_CONFIG_LESS
+ help
+ The extra flags provided do the following:
+
+ The -M flag enables a more sophisticated status line.
+ The -m flag enables a simpler status line with a percentage.
+
+config BUSYBOX_CONFIG_FEATURE_LESS_MARKS
+ bool "Enable marks"
+ default n
+ depends on BUSYBOX_CONFIG_LESS
+ help
+ Marks enable positions in a file to be stored for easy reference.
+
+config BUSYBOX_CONFIG_FEATURE_LESS_REGEXP
+ bool "Enable regular expressions"
+ default n
+ depends on BUSYBOX_CONFIG_LESS
+ help
+ Enable regular expressions, allowing complex file searches.
+
+config BUSYBOX_CONFIG_FEATURE_LESS_WINCH
+ bool "Enable automatic resizing on window size changes"
+ default n
+ depends on BUSYBOX_CONFIG_LESS
+ help
+ Makes less track window size changes.
+
+config BUSYBOX_CONFIG_FEATURE_LESS_ASK_TERMINAL
+ bool "Use 'tell me cursor position' ESC sequence to measure window"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_LESS_WINCH
+ help
+ Makes less track window size changes.
+ If terminal size can't be retrieved and $LINES/$COLUMNS are not set,
+ this option makes less perform a last-ditch effort to find it:
+ position cursor to 999,999 and ask terminal to report real
+ cursor position using "ESC [ 6 n" escape sequence, then read stdin.
+
+ This is not clean but helps a lot on serial lines and such.
+
+config BUSYBOX_CONFIG_FEATURE_LESS_DASHCMD
+ bool "Enable flag changes ('-' command)"
+ default n
+ depends on BUSYBOX_CONFIG_LESS
+ help
+ This enables the ability to change command-line flags within
+ less itself ('-' keyboard command).
+
+config BUSYBOX_CONFIG_FEATURE_LESS_LINENUMS
+ bool "Enable dynamic switching of line numbers"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_LESS_DASHCMD
+ help
+ Enables "-N" command.
+config BUSYBOX_CONFIG_NANDWRITE
+ bool "nandwrite"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Write to the specified MTD device, with bad blocks awareness
+
+config BUSYBOX_CONFIG_NANDDUMP
+ bool "nanddump"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Dump the content of raw NAND chip
+config BUSYBOX_CONFIG_SETSERIAL
+ bool "setserial"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Retrieve or set Linux serial port.
+config BUSYBOX_CONFIG_UBIATTACH
+ bool "ubiattach"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Attach MTD device to an UBI device.
+
+config BUSYBOX_CONFIG_UBIDETACH
+ bool "ubidetach"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Detach MTD device from an UBI device.
+
+config BUSYBOX_CONFIG_UBIMKVOL
+ bool "ubimkvol"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Create a UBI volume.
+
+config BUSYBOX_CONFIG_UBIRMVOL
+ bool "ubirmvol"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Delete a UBI volume.
+
+config BUSYBOX_CONFIG_UBIRSVOL
+ bool "ubirsvol"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Resize a UBI volume.
+
+config BUSYBOX_CONFIG_UBIUPDATEVOL
+ bool "ubiupdatevol"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Update a UBI volume.
+
+config BUSYBOX_CONFIG_ADJTIMEX
+ bool "adjtimex"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Adjtimex reads and optionally sets adjustment parameters for
+ the Linux clock adjustment algorithm.
+
+config BUSYBOX_CONFIG_BBCONFIG
+ bool "bbconfig"
+ default n
+ help
+ The bbconfig applet will print the config file with which
+ busybox was built.
+
+config BUSYBOX_CONFIG_FEATURE_COMPRESS_BBCONFIG
+ bool "Compress bbconfig data"
+ default n
+ depends on BUSYBOX_CONFIG_BBCONFIG
+ help
+ Store bbconfig data in compressed form, uncompress them on-the-fly
+ before output.
+
+ If you have a really tiny busybox with few applets enabled (and
+ bunzip2 isn't one of them), the overhead of the decompressor might
+ be noticeable. Also, if you run executables directly from ROM
+ and have very little memory, this might not be a win. Otherwise,
+ you probably want this.
+
+config BUSYBOX_CONFIG_BEEP
+ bool "beep"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ The beep applets beeps in a given freq/Hz.
+
+config BUSYBOX_CONFIG_FEATURE_BEEP_FREQ
+ int "default frequency"
+ range 0 2147483647
+ default 4000
+ depends on BUSYBOX_CONFIG_BEEP
+ help
+ Frequency for default beep.
+
+config BUSYBOX_CONFIG_FEATURE_BEEP_LENGTH_MS
+ int "default length"
+ range 0 2147483647
+ default 30
+ depends on BUSYBOX_CONFIG_BEEP
+ help
+ Length in ms for default beep.
+
+config BUSYBOX_CONFIG_CHAT
+ bool "chat"
+ default n
+ help
+ Simple chat utility.
+
+config BUSYBOX_CONFIG_FEATURE_CHAT_NOFAIL
+ bool "Enable NOFAIL expect strings"
+ depends on BUSYBOX_CONFIG_CHAT
+ default n
+ help
+ When enabled expect strings which are started with a dash trigger
+ no-fail mode. That is when expectation is not met within timeout
+ the script is not terminated but sends next SEND string and waits
+ for next EXPECT string. This allows to compose far more flexible
+ scripts.
+
+config BUSYBOX_CONFIG_FEATURE_CHAT_TTY_HIFI
+ bool "Force STDIN to be a TTY"
+ depends on BUSYBOX_CONFIG_CHAT
+ default n
+ help
+ Original chat always treats STDIN as a TTY device and sets for it
+ so-called raw mode. This option turns on such behaviour.
+
+config BUSYBOX_CONFIG_FEATURE_CHAT_IMPLICIT_CR
+ bool "Enable implicit Carriage Return"
+ depends on BUSYBOX_CONFIG_CHAT
+ default n
+ help
+ When enabled make chat to terminate all SEND strings with a "\r"
+ unless "\c" is met anywhere in the string.
+
+config BUSYBOX_CONFIG_FEATURE_CHAT_SWALLOW_OPTS
+ bool "Swallow options"
+ depends on BUSYBOX_CONFIG_CHAT
+ default n
+ help
+ Busybox chat require no options. To make it not fail when used
+ in place of original chat (which has a bunch of options) turn
+ this on.
+
+config BUSYBOX_CONFIG_FEATURE_CHAT_SEND_ESCAPES
+ bool "Support weird SEND escapes"
+ depends on BUSYBOX_CONFIG_CHAT
+ default n
+ help
+ Original chat uses some escape sequences in SEND arguments which
+ are not sent to device but rather performs special actions.
+ E.g. "\K" means to send a break sequence to device.
+ "\d" delays execution for a second, "\p" -- for a 1/100 of second.
+ Before turning this option on think twice: do you really need them?
+
+config BUSYBOX_CONFIG_FEATURE_CHAT_VAR_ABORT_LEN
+ bool "Support variable-length ABORT conditions"
+ depends on BUSYBOX_CONFIG_CHAT
+ default n
+ help
+ Original chat uses fixed 50-bytes length ABORT conditions. Say N here.
+
+config BUSYBOX_CONFIG_FEATURE_CHAT_CLR_ABORT
+ bool "Support revoking of ABORT conditions"
+ depends on BUSYBOX_CONFIG_CHAT
+ default n
+ help
+ Support CLR_ABORT directive.
+
+config BUSYBOX_CONFIG_CHRT
+ bool "chrt"
+ default n
+ help
+ manipulate real-time attributes of a process.
+ This requires sched_{g,s}etparam support in your libc.
+
+config BUSYBOX_CONFIG_CROND
+ bool "crond"
+ default y
+ select BUSYBOX_CONFIG_FEATURE_SYSLOG
+ help
+ Crond is a background daemon that parses individual crontab
+ files and executes commands on behalf of the users in question.
+ This is a port of dcron from slackware. It uses files of the
+ format /var/spool/cron/crontabs/<username> files, for example:
+ $ cat /var/spool/cron/crontabs/root
+ # Run daily cron jobs at 4:40 every day:
+ 40 4 * * * /etc/cron/daily > /dev/null 2>&1
+
+config BUSYBOX_CONFIG_FEATURE_CROND_D
+ bool "Support option -d to redirect output to stderr"
+ depends on BUSYBOX_CONFIG_CROND
+ default n
+ help
+ -d sets loglevel to 0 (most verbose) and directs all output to stderr.
+
+config BUSYBOX_CONFIG_FEATURE_CROND_CALL_SENDMAIL
+ bool "Report command output via email (using sendmail)"
+ default n
+ depends on BUSYBOX_CONFIG_CROND
+ help
+ Command output will be sent to corresponding user via email.
+
+config BUSYBOX_CONFIG_FEATURE_CROND_DIR
+ string "crond spool directory"
+ default "/var/spool/cron"
+ depends on BUSYBOX_CONFIG_CROND || BUSYBOX_CONFIG_CRONTAB
+ help
+ Location of crond spool.
+
+config BUSYBOX_CONFIG_CRONTAB
+ bool "crontab"
+ default y
+ help
+ Crontab manipulates the crontab for a particular user. Only
+ the superuser may specify a different user and/or crontab directory.
+ Note that Busybox binary must be setuid root for this applet to
+ work properly.
+
+config BUSYBOX_CONFIG_DC
+ bool "dc"
+ default n
+ help
+ Dc is a reverse-polish desk calculator which supports unlimited
+ precision arithmetic.
+
+config BUSYBOX_CONFIG_FEATURE_DC_LIBM
+ bool "Enable power and exp functions (requires libm)"
+ default n
+ depends on BUSYBOX_CONFIG_DC
+ help
+ Enable power and exp functions.
+ NOTE: This will require libm to be present for linking.
+
+config BUSYBOX_CONFIG_DEVFSD
+ bool "devfsd (obsolete)"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ select BUSYBOX_CONFIG_FEATURE_SYSLOG
+ help
+ This is deprecated and should NOT be used anymore.
+ Use linux >= 2.6 (optionally with hotplug) and mdev instead!
+ See docs/mdev.txt for detailed instructions on how to use mdev
+ instead.
+
+ Provides compatibility with old device names on a devfs systems.
+ You should set it to true if you have devfs enabled.
+ The following keywords in devsfd.conf are supported:
+ "CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
+ "PERMISSIONS", "EXECUTE", "COPY", "IGNORE",
+ "MKOLDCOMPAT", "MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
+
+ But only if they are written UPPERCASE!!!!!!!!
+
+config BUSYBOX_CONFIG_DEVFSD_MODLOAD
+ bool "Adds support for MODLOAD keyword in devsfd.conf"
+ default n
+ depends on BUSYBOX_CONFIG_DEVFSD
+ help
+ This actually doesn't work with busybox modutils but needs
+ the external modutils.
+
+config BUSYBOX_CONFIG_DEVFSD_FG_NP
+ bool "Enables the -fg and -np options"
+ default n
+ depends on BUSYBOX_CONFIG_DEVFSD
+ help
+ -fg Run the daemon in the foreground.
+ -np Exit after parsing the configuration file.
+ Do not poll for events.
+
+config BUSYBOX_CONFIG_DEVFSD_VERBOSE
+ bool "Increases logging (and size)"
+ default n
+ depends on BUSYBOX_CONFIG_DEVFSD
+ help
+ Increases logging to stderr or syslog.
+
+config BUSYBOX_CONFIG_FEATURE_DEVFS
+ bool "Use devfs names for all devices (obsolete)"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ This is obsolete and should NOT be used anymore.
+ Use linux >= 2.6 (optionally with hotplug) and mdev instead!
+
+ For legacy systems -- if there is no way around devfsd -- this
+ tells busybox to look for names like /dev/loop/0 instead of
+ /dev/loop0. If your /dev directory has normal names instead of
+ devfs names, you don't want this.
+
+config BUSYBOX_CONFIG_DEVMEM
+ bool "devmem"
+ default n
+ help
+ devmem is a small program that reads and writes from physical
+ memory using /dev/mem.
+
+config BUSYBOX_CONFIG_EJECT
+ bool "eject"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Used to eject cdroms. (defaults to /dev/cdrom)
+
+config BUSYBOX_CONFIG_FEATURE_EJECT_SCSI
+ bool "SCSI support"
+ default n
+ depends on BUSYBOX_CONFIG_EJECT
+ help
+ Add the -s option to eject, this allows to eject SCSI-Devices and
+ usb-storage devices.
+
+config BUSYBOX_CONFIG_FBSPLASH
+ bool "fbsplash"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Shows splash image and progress bar on framebuffer device.
+ Can be used during boot phase of an embedded device. ~2kb.
+ Usage:
+ - use kernel option 'vga=xxx' or otherwise enable fb device.
+ - put somewhere fbsplash.cfg file and an image in .ppm format.
+ - $ setsid fbsplash [params] &
+ -c: hide cursor
+ -d /dev/fbN: framebuffer device (if not /dev/fb0)
+ -s path_to_image_file (can be "-" for stdin)
+ -i path_to_cfg_file (can be "-" for stdin)
+ -f path_to_fifo (can be "-" for stdin)
+ - if you want to run it only in presence of kernel parameter:
+ grep -q "fbsplash=on" </proc/cmdline && setsid fbsplash [params] &
+ - commands for fifo:
+ "NN" (ASCII decimal number) - percentage to show on progress bar
+ "exit" - well you guessed it
+
+config BUSYBOX_CONFIG_FLASHCP
+ bool "flashcp"
+ default n # doesn't build on Ubuntu 8.04
+ help
+ The flashcp binary, inspired by mtd-utils as of git head 5eceb74f7.
+ This utility is used to copy images into a MTD device.
+
+config BUSYBOX_CONFIG_FLASH_LOCK
+ bool "flash_lock"
+ default n # doesn't build on Ubuntu 8.04
+ help
+ The flash_lock binary from mtd-utils as of git head 5ec0c10d0. This
+ utility locks part or all of the flash device.
+
+config BUSYBOX_CONFIG_FLASH_UNLOCK
+ bool "flash_unlock"
+ default n # doesn't build on Ubuntu 8.04
+ help
+ The flash_unlock binary from mtd-utils as of git head 5ec0c10d0. This
+ utility unlocks part or all of the flash device.
+
+config BUSYBOX_CONFIG_FLASH_ERASEALL
+ bool "flash_eraseall"
+ default n # doesn't build on Ubuntu 8.04
+ help
+ The flash_eraseall binary from mtd-utils as of git head c4c6a59eb.
+ This utility is used to erase the whole MTD device.
+
+config BUSYBOX_CONFIG_IONICE
+ bool "ionice"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Set/set program io scheduling class and priority
+ Requires kernel >= 2.6.13
+
+config BUSYBOX_CONFIG_INOTIFYD
+ bool "inotifyd"
+ default n # doesn't build on Knoppix 5
+ help
+ Simple inotify daemon. Reports filesystem changes. Requires
+ kernel >= 2.6.13
+
+config BUSYBOX_CONFIG_LAST
+ bool "last"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_WTMP
+ help
+ 'last' displays a list of the last users that logged into the system.
+
+choice
+ prompt "Choose last implementation"
+ depends on BUSYBOX_CONFIG_LAST
+ default BUSYBOX_CONFIG_FEATURE_LAST_FANCY
+
+config BUSYBOX_CONFIG_FEATURE_LAST_SMALL
+ bool "small"
+ help
+ This is a small version of last with just the basic set of
+ features.
+
+config BUSYBOX_CONFIG_FEATURE_LAST_FANCY
+ bool "huge"
+ help
+ 'last' displays detailed information about the last users that
+ logged into the system (mimics sysvinit last). +900 bytes.
+endchoice
+
+config BUSYBOX_CONFIG_HDPARM
+ bool "hdparm"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Get/Set hard drive parameters. Primarily intended for ATA
+ drives. Adds about 13k (or around 30k if you enable the
+ FEATURE_HDPARM_GET_IDENTITY option)....
+
+config BUSYBOX_CONFIG_FEATURE_HDPARM_GET_IDENTITY
+ bool "Support obtaining detailed information directly from drives"
+ default n
+ depends on BUSYBOX_CONFIG_HDPARM
+ help
+ Enables the -I and -i options to obtain detailed information
+ directly from drives about their capabilities and supported ATA
+ feature set. If no device name is specified, hdparm will read
+ identify data from stdin. Enabling this option will add about 16k...
+
+config BUSYBOX_CONFIG_FEATURE_HDPARM_HDIO_SCAN_HWIF
+ bool "Register an IDE interface (DANGEROUS)"
+ default n
+ depends on BUSYBOX_CONFIG_HDPARM
+ help
+ Enables the 'hdparm -R' option to register an IDE interface.
+ This is dangerous stuff, so you should probably say N.
+
+config BUSYBOX_CONFIG_FEATURE_HDPARM_HDIO_UNREGISTER_HWIF
+ bool "Un-register an IDE interface (DANGEROUS)"
+ default n
+ depends on BUSYBOX_CONFIG_HDPARM
+ help
+ Enables the 'hdparm -U' option to un-register an IDE interface.
+ This is dangerous stuff, so you should probably say N.
+
+config BUSYBOX_CONFIG_FEATURE_HDPARM_HDIO_DRIVE_RESET
+ bool "Perform device reset (DANGEROUS)"
+ default n
+ depends on BUSYBOX_CONFIG_HDPARM
+ help
+ Enables the 'hdparm -w' option to perform a device reset.
+ This is dangerous stuff, so you should probably say N.
+
+config BUSYBOX_CONFIG_FEATURE_HDPARM_HDIO_TRISTATE_HWIF
+ bool "Tristate device for hotswap (DANGEROUS)"
+ default n
+ depends on BUSYBOX_CONFIG_HDPARM
+ help
+ Enables the 'hdparm -x' option to tristate device for hotswap,
+ and the '-b' option to get/set bus state. This is dangerous
+ stuff, so you should probably say N.
+
+config BUSYBOX_CONFIG_FEATURE_HDPARM_HDIO_GETSET_DMA
+ bool "Get/set using_dma flag"
+ default n
+ depends on BUSYBOX_CONFIG_HDPARM
+ help
+ Enables the 'hdparm -d' option to get/set using_dma flag.
+
+config BUSYBOX_CONFIG_LOCK
+ bool "lock"
+ default y
+ help
+ Small utility for using locks in scripts
+
+config BUSYBOX_CONFIG_MAKEDEVS
+ bool "makedevs"
+ default n
+ help
+ 'makedevs' is a utility used to create a batch of devices with
+ one command.
+
+ There are two choices for command line behaviour, the interface
+ as used by LEAF/Linux Router Project, or a device table file.
+
+ 'leaf' is traditionally what busybox follows, it allows multiple
+ devices of a particluar type to be created per command.
+ e.g. /dev/hda[0-9]
+ Device properties are passed as command line arguments.
+
+ 'table' reads device properties from a file or stdin, allowing
+ a batch of unrelated devices to be made with one command.
+ User/group names are allowed as an alternative to uid/gid.
+
+choice
+ prompt "Choose makedevs behaviour"
+ depends on BUSYBOX_CONFIG_MAKEDEVS
+ default BUSYBOX_CONFIG_FEATURE_MAKEDEVS_TABLE
+
+config BUSYBOX_CONFIG_FEATURE_MAKEDEVS_LEAF
+ bool "leaf"
+
+config BUSYBOX_CONFIG_FEATURE_MAKEDEVS_TABLE
+ bool "table"
+
+endchoice
+
+config BUSYBOX_CONFIG_MAN
+ bool "man"
+ default n
+ help
+ Format and display manual pages.
+
+config BUSYBOX_CONFIG_MICROCOM
+ bool "microcom"
+ default n
+ help
+ The poor man's minicom utility for chatting with serial port devices.
+
+config BUSYBOX_CONFIG_MOUNTPOINT
+ bool "mountpoint"
+ default n
+ help
+ mountpoint checks if the directory is a mountpoint.
+
+config BUSYBOX_CONFIG_MT
+ bool "mt"
+ default n
+ help
+ mt is used to control tape devices. You can use the mt utility
+ to advance or rewind a tape past a specified number of archive
+ files on the tape.
+
+config BUSYBOX_CONFIG_RAIDAUTORUN
+ bool "raidautorun"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ raidautorun tells the kernel md driver to
+ search and start RAID arrays.
+
+config BUSYBOX_CONFIG_READAHEAD
+ bool "readahead"
+ default n
+ depends on BUSYBOX_CONFIG_LFS
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Preload the files listed on the command line into RAM cache so that
+ subsequent reads on these files will not block on disk I/O.
+
+ This applet just calls the readahead(2) system call on each file.
+ It is mainly useful in system startup scripts to preload files
+ or executables before they are used. When used at the right time
+ (in particular when a CPU bound process is running) it can
+ significantly speed up system startup.
+
+ As readahead(2) blocks until each file has been read, it is best to
+ run this applet as a background job.
+
+config BUSYBOX_CONFIG_RFKILL
+ bool "rfkill"
+ default n # doesn't build on Ubuntu 9.04
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Enable/disable wireless devices.
+
+ rfkill list : list all wireless devices
+ rfkill list bluetooth : list all bluetooth devices
+ rfkill list 1 : list device corresponding to the given index
+ rfkill block|unblock wlan : block/unblock all wlan(wifi) devices
+
+config BUSYBOX_CONFIG_RUNLEVEL
+ bool "runlevel"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_UTMP
+ help
+ find the current and previous system runlevel.
+
+ This applet uses utmp but does not rely on busybox supporing
+ utmp on purpose. It is used by e.g. emdebian via /etc/init.d/rc.
+
+config BUSYBOX_CONFIG_RX
+ bool "rx"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Receive files using the Xmodem protocol.
+
+config BUSYBOX_CONFIG_SETSID
+ bool "setsid"
+ default n
+ help
+ setsid runs a program in a new session
+
+config BUSYBOX_CONFIG_STRINGS
+ bool "strings"
+ default y
+ help
+ strings prints the printable character sequences for each file
+ specified.
+
+config BUSYBOX_CONFIG_TASKSET
+ bool "taskset"
+ default n # doesn't build on some non-x86 targets (m68k)
+ help
+ Retrieve or set a processes's CPU affinity.
+ This requires sched_{g,s}etaffinity support in your libc.
+
+config BUSYBOX_CONFIG_FEATURE_TASKSET_FANCY
+ bool "Fancy output"
+ default n
+ depends on BUSYBOX_CONFIG_TASKSET
+ help
+ Add code for fancy output. This merely silences a compiler-warning
+ and adds about 135 Bytes. May be needed for machines with alot
+ of CPUs.
+
+config BUSYBOX_CONFIG_TIME
+ bool "time"
+ default y
+ help
+ The time command runs the specified program with the given arguments.
+ When the command finishes, time writes a message to standard output
+ giving timing statistics about this program run.
+
+config BUSYBOX_CONFIG_TIMEOUT
+ bool "timeout"
+ default n
+ help
+ Runs a program and watches it. If it does not terminate in
+ specified number of seconds, it is sent a signal.
+
+config BUSYBOX_CONFIG_TTYSIZE
+ bool "ttysize"
+ default n
+ help
+ A replacement for "stty size". Unlike stty, can report only width,
+ only height, or both, in any order. It also does not complain on
+ error, but returns default 80x24.
+ Usage in shell scripts: width=`ttysize w`.
+
+config BUSYBOX_CONFIG_VOLNAME
+ bool "volname"
+ default n
+ help
+ Prints a CD-ROM volume name.
+
+config BUSYBOX_CONFIG_WALL
+ bool "wall"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_UTMP
+ help
+ Write a message to all users that are logged in.
+
+config BUSYBOX_CONFIG_WATCHDOG
+ bool "watchdog"
+ default y
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ The watchdog utility is used with hardware or software watchdog
+ device drivers. It opens the specified watchdog device special file
+ and periodically writes a magic character to the device. If the
+ watchdog applet ever fails to write the magic character within a
+ certain amount of time, the watchdog device assumes the system has
+ hung, and will cause the hardware to reboot.
+
+endmenu
diff --git a/package/busybox/config/miscutils/Config.in b/package/busybox/config/miscutils/Config.in
new file mode 100644
index 0000000..e69d684
--- /dev/null
+++ b/package/busybox/config/miscutils/Config.in
@@ -0,0 +1,766 @@
+# DO NOT EDIT. This file is generated from Config.src
+#
+# For a description of the syntax of this configuration file,
+# see scripts/kbuild/config-language.txt.
+#
+
+menu "Miscellaneous Utilities"
+
+config BUSYBOX_CONFIG_CONSPY
+ bool "conspy"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ A text-mode VNC like program for Linux virtual terminals.
+ example: conspy NUM shared access to console num
+ or conspy -nd NUM screenshot of console num
+ or conspy -cs NUM poor man's GNU screen like
+config BUSYBOX_CONFIG_LESS
+ bool "less"
+ default y
+ help
+ 'less' is a pager, meaning that it displays text files. It possesses
+ a wide array of features, and is an improvement over 'more'.
+
+config BUSYBOX_CONFIG_FEATURE_LESS_MAXLINES
+ int "Max number of input lines less will try to eat"
+ default 9999999
+ depends on BUSYBOX_CONFIG_LESS
+
+config BUSYBOX_CONFIG_FEATURE_LESS_BRACKETS
+ bool "Enable bracket searching"
+ default n
+ depends on BUSYBOX_CONFIG_LESS
+ help
+ This option adds the capability to search for matching left and right
+ brackets, facilitating programming.
+
+config BUSYBOX_CONFIG_FEATURE_LESS_FLAGS
+ bool "Enable extra flags"
+ default n
+ depends on BUSYBOX_CONFIG_LESS
+ help
+ The extra flags provided do the following:
+
+ The -M flag enables a more sophisticated status line.
+ The -m flag enables a simpler status line with a percentage.
+
+config BUSYBOX_CONFIG_FEATURE_LESS_MARKS
+ bool "Enable marks"
+ default n
+ depends on BUSYBOX_CONFIG_LESS
+ help
+ Marks enable positions in a file to be stored for easy reference.
+
+config BUSYBOX_CONFIG_FEATURE_LESS_REGEXP
+ bool "Enable regular expressions"
+ default n
+ depends on BUSYBOX_CONFIG_LESS
+ help
+ Enable regular expressions, allowing complex file searches.
+
+config BUSYBOX_CONFIG_FEATURE_LESS_WINCH
+ bool "Enable automatic resizing on window size changes"
+ default n
+ depends on BUSYBOX_CONFIG_LESS
+ help
+ Makes less track window size changes.
+
+config BUSYBOX_CONFIG_FEATURE_LESS_ASK_TERMINAL
+ bool "Use 'tell me cursor position' ESC sequence to measure window"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_LESS_WINCH
+ help
+ Makes less track window size changes.
+ If terminal size can't be retrieved and $LINES/$COLUMNS are not set,
+ this option makes less perform a last-ditch effort to find it:
+ position cursor to 999,999 and ask terminal to report real
+ cursor position using "ESC [ 6 n" escape sequence, then read stdin.
+
+ This is not clean but helps a lot on serial lines and such.
+
+config BUSYBOX_CONFIG_FEATURE_LESS_DASHCMD
+ bool "Enable flag changes ('-' command)"
+ default n
+ depends on BUSYBOX_CONFIG_LESS
+ help
+ This enables the ability to change command-line flags within
+ less itself ('-' keyboard command).
+
+config BUSYBOX_CONFIG_FEATURE_LESS_LINENUMS
+ bool "Enable dynamic switching of line numbers"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_LESS_DASHCMD
+ help
+ Enables "-N" command.
+config BUSYBOX_CONFIG_NANDWRITE
+ bool "nandwrite"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Write to the specified MTD device, with bad blocks awareness
+
+config BUSYBOX_CONFIG_NANDDUMP
+ bool "nanddump"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Dump the content of raw NAND chip
+config BUSYBOX_CONFIG_SETSERIAL
+ bool "setserial"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Retrieve or set Linux serial port.
+config BUSYBOX_CONFIG_UBIATTACH
+ bool "ubiattach"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Attach MTD device to an UBI device.
+
+config BUSYBOX_CONFIG_UBIDETACH
+ bool "ubidetach"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Detach MTD device from an UBI device.
+
+config BUSYBOX_CONFIG_UBIMKVOL
+ bool "ubimkvol"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Create a UBI volume.
+
+config BUSYBOX_CONFIG_UBIRMVOL
+ bool "ubirmvol"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Delete a UBI volume.
+
+config BUSYBOX_CONFIG_UBIRSVOL
+ bool "ubirsvol"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Resize a UBI volume.
+
+config BUSYBOX_CONFIG_UBIUPDATEVOL
+ bool "ubiupdatevol"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Update a UBI volume.
+
+config BUSYBOX_CONFIG_ADJTIMEX
+ bool "adjtimex"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Adjtimex reads and optionally sets adjustment parameters for
+ the Linux clock adjustment algorithm.
+
+config BUSYBOX_CONFIG_BBCONFIG
+ bool "bbconfig"
+ default n
+ help
+ The bbconfig applet will print the config file with which
+ busybox was built.
+
+config BUSYBOX_CONFIG_FEATURE_COMPRESS_BBCONFIG
+ bool "Compress bbconfig data"
+ default n
+ depends on BUSYBOX_CONFIG_BBCONFIG
+ help
+ Store bbconfig data in compressed form, uncompress them on-the-fly
+ before output.
+
+ If you have a really tiny busybox with few applets enabled (and
+ bunzip2 isn't one of them), the overhead of the decompressor might
+ be noticeable. Also, if you run executables directly from ROM
+ and have very little memory, this might not be a win. Otherwise,
+ you probably want this.
+
+config BUSYBOX_CONFIG_BEEP
+ bool "beep"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ The beep applets beeps in a given freq/Hz.
+
+config BUSYBOX_CONFIG_FEATURE_BEEP_FREQ
+ int "default frequency"
+ range 0 2147483647
+ default 4000
+ depends on BUSYBOX_CONFIG_BEEP
+ help
+ Frequency for default beep.
+
+config BUSYBOX_CONFIG_FEATURE_BEEP_LENGTH_MS
+ int "default length"
+ range 0 2147483647
+ default 30
+ depends on BUSYBOX_CONFIG_BEEP
+ help
+ Length in ms for default beep.
+
+config BUSYBOX_CONFIG_CHAT
+ bool "chat"
+ default n
+ help
+ Simple chat utility.
+
+config BUSYBOX_CONFIG_FEATURE_CHAT_NOFAIL
+ bool "Enable NOFAIL expect strings"
+ depends on BUSYBOX_CONFIG_CHAT
+ default n
+ help
+ When enabled expect strings which are started with a dash trigger
+ no-fail mode. That is when expectation is not met within timeout
+ the script is not terminated but sends next SEND string and waits
+ for next EXPECT string. This allows to compose far more flexible
+ scripts.
+
+config BUSYBOX_CONFIG_FEATURE_CHAT_TTY_HIFI
+ bool "Force STDIN to be a TTY"
+ depends on BUSYBOX_CONFIG_CHAT
+ default n
+ help
+ Original chat always treats STDIN as a TTY device and sets for it
+ so-called raw mode. This option turns on such behaviour.
+
+config BUSYBOX_CONFIG_FEATURE_CHAT_IMPLICIT_CR
+ bool "Enable implicit Carriage Return"
+ depends on BUSYBOX_CONFIG_CHAT
+ default n
+ help
+ When enabled make chat to terminate all SEND strings with a "\r"
+ unless "\c" is met anywhere in the string.
+
+config BUSYBOX_CONFIG_FEATURE_CHAT_SWALLOW_OPTS
+ bool "Swallow options"
+ depends on BUSYBOX_CONFIG_CHAT
+ default n
+ help
+ Busybox chat require no options. To make it not fail when used
+ in place of original chat (which has a bunch of options) turn
+ this on.
+
+config BUSYBOX_CONFIG_FEATURE_CHAT_SEND_ESCAPES
+ bool "Support weird SEND escapes"
+ depends on BUSYBOX_CONFIG_CHAT
+ default n
+ help
+ Original chat uses some escape sequences in SEND arguments which
+ are not sent to device but rather performs special actions.
+ E.g. "\K" means to send a break sequence to device.
+ "\d" delays execution for a second, "\p" -- for a 1/100 of second.
+ Before turning this option on think twice: do you really need them?
+
+config BUSYBOX_CONFIG_FEATURE_CHAT_VAR_ABORT_LEN
+ bool "Support variable-length ABORT conditions"
+ depends on BUSYBOX_CONFIG_CHAT
+ default n
+ help
+ Original chat uses fixed 50-bytes length ABORT conditions. Say N here.
+
+config BUSYBOX_CONFIG_FEATURE_CHAT_CLR_ABORT
+ bool "Support revoking of ABORT conditions"
+ depends on BUSYBOX_CONFIG_CHAT
+ default n
+ help
+ Support CLR_ABORT directive.
+
+config BUSYBOX_CONFIG_CHRT
+ bool "chrt"
+ default n
+ help
+ manipulate real-time attributes of a process.
+ This requires sched_{g,s}etparam support in your libc.
+
+config BUSYBOX_CONFIG_CROND
+ bool "crond"
+ default y
+ select BUSYBOX_CONFIG_FEATURE_SYSLOG
+ help
+ Crond is a background daemon that parses individual crontab
+ files and executes commands on behalf of the users in question.
+ This is a port of dcron from slackware. It uses files of the
+ format /var/spool/cron/crontabs/<username> files, for example:
+ $ cat /var/spool/cron/crontabs/root
+ # Run daily cron jobs at 4:40 every day:
+ 40 4 * * * /etc/cron/daily > /dev/null 2>&1
+
+config BUSYBOX_CONFIG_FEATURE_CROND_D
+ bool "Support option -d to redirect output to stderr"
+ depends on BUSYBOX_CONFIG_CROND
+ default n
+ help
+ -d sets loglevel to 0 (most verbose) and directs all output to stderr.
+
+config BUSYBOX_CONFIG_FEATURE_CROND_CALL_SENDMAIL
+ bool "Report command output via email (using sendmail)"
+ default n
+ depends on BUSYBOX_CONFIG_CROND
+ help
+ Command output will be sent to corresponding user via email.
+
+config BUSYBOX_CONFIG_FEATURE_CROND_DIR
+ string "crond spool directory"
+ default "/var/spool/cron"
+ depends on BUSYBOX_CONFIG_CROND || BUSYBOX_CONFIG_CRONTAB
+ help
+ Location of crond spool.
+
+config BUSYBOX_CONFIG_CRONTAB
+ bool "crontab"
+ default y
+ help
+ Crontab manipulates the crontab for a particular user. Only
+ the superuser may specify a different user and/or crontab directory.
+ Note that Busybox binary must be setuid root for this applet to
+ work properly.
+
+config BUSYBOX_CONFIG_DC
+ bool "dc"
+ default n
+ help
+ Dc is a reverse-polish desk calculator which supports unlimited
+ precision arithmetic.
+
+config BUSYBOX_CONFIG_FEATURE_DC_LIBM
+ bool "Enable power and exp functions (requires libm)"
+ default n
+ depends on BUSYBOX_CONFIG_DC
+ help
+ Enable power and exp functions.
+ NOTE: This will require libm to be present for linking.
+
+config BUSYBOX_CONFIG_DEVFSD
+ bool "devfsd (obsolete)"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ select BUSYBOX_CONFIG_FEATURE_SYSLOG
+ help
+ This is deprecated and should NOT be used anymore.
+ Use linux >= 2.6 (optionally with hotplug) and mdev instead!
+ See docs/mdev.txt for detailed instructions on how to use mdev
+ instead.
+
+ Provides compatibility with old device names on a devfs systems.
+ You should set it to true if you have devfs enabled.
+ The following keywords in devsfd.conf are supported:
+ "CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
+ "PERMISSIONS", "EXECUTE", "COPY", "IGNORE",
+ "MKOLDCOMPAT", "MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
+
+ But only if they are written UPPERCASE!!!!!!!!
+
+config BUSYBOX_CONFIG_DEVFSD_MODLOAD
+ bool "Adds support for MODLOAD keyword in devsfd.conf"
+ default n
+ depends on BUSYBOX_CONFIG_DEVFSD
+ help
+ This actually doesn't work with busybox modutils but needs
+ the external modutils.
+
+config BUSYBOX_CONFIG_DEVFSD_FG_NP
+ bool "Enables the -fg and -np options"
+ default n
+ depends on BUSYBOX_CONFIG_DEVFSD
+ help
+ -fg Run the daemon in the foreground.
+ -np Exit after parsing the configuration file.
+ Do not poll for events.
+
+config BUSYBOX_CONFIG_DEVFSD_VERBOSE
+ bool "Increases logging (and size)"
+ default n
+ depends on BUSYBOX_CONFIG_DEVFSD
+ help
+ Increases logging to stderr or syslog.
+
+config BUSYBOX_CONFIG_FEATURE_DEVFS
+ bool "Use devfs names for all devices (obsolete)"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ This is obsolete and should NOT be used anymore.
+ Use linux >= 2.6 (optionally with hotplug) and mdev instead!
+
+ For legacy systems -- if there is no way around devfsd -- this
+ tells busybox to look for names like /dev/loop/0 instead of
+ /dev/loop0. If your /dev directory has normal names instead of
+ devfs names, you don't want this.
+
+config BUSYBOX_CONFIG_DEVMEM
+ bool "devmem"
+ default n
+ help
+ devmem is a small program that reads and writes from physical
+ memory using /dev/mem.
+
+config BUSYBOX_CONFIG_EJECT
+ bool "eject"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Used to eject cdroms. (defaults to /dev/cdrom)
+
+config BUSYBOX_CONFIG_FEATURE_EJECT_SCSI
+ bool "SCSI support"
+ default n
+ depends on BUSYBOX_CONFIG_EJECT
+ help
+ Add the -s option to eject, this allows to eject SCSI-Devices and
+ usb-storage devices.
+
+config BUSYBOX_CONFIG_FBSPLASH
+ bool "fbsplash"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Shows splash image and progress bar on framebuffer device.
+ Can be used during boot phase of an embedded device. ~2kb.
+ Usage:
+ - use kernel option 'vga=xxx' or otherwise enable fb device.
+ - put somewhere fbsplash.cfg file and an image in .ppm format.
+ - $ setsid fbsplash [params] &
+ -c: hide cursor
+ -d /dev/fbN: framebuffer device (if not /dev/fb0)
+ -s path_to_image_file (can be "-" for stdin)
+ -i path_to_cfg_file (can be "-" for stdin)
+ -f path_to_fifo (can be "-" for stdin)
+ - if you want to run it only in presence of kernel parameter:
+ grep -q "fbsplash=on" </proc/cmdline && setsid fbsplash [params] &
+ - commands for fifo:
+ "NN" (ASCII decimal number) - percentage to show on progress bar
+ "exit" - well you guessed it
+
+config BUSYBOX_CONFIG_FLASHCP
+ bool "flashcp"
+ default n # doesn't build on Ubuntu 8.04
+ help
+ The flashcp binary, inspired by mtd-utils as of git head 5eceb74f7.
+ This utility is used to copy images into a MTD device.
+
+config BUSYBOX_CONFIG_FLASH_LOCK
+ bool "flash_lock"
+ default n # doesn't build on Ubuntu 8.04
+ help
+ The flash_lock binary from mtd-utils as of git head 5ec0c10d0. This
+ utility locks part or all of the flash device.
+
+config BUSYBOX_CONFIG_FLASH_UNLOCK
+ bool "flash_unlock"
+ default n # doesn't build on Ubuntu 8.04
+ help
+ The flash_unlock binary from mtd-utils as of git head 5ec0c10d0. This
+ utility unlocks part or all of the flash device.
+
+config BUSYBOX_CONFIG_FLASH_ERASEALL
+ bool "flash_eraseall"
+ default n # doesn't build on Ubuntu 8.04
+ help
+ The flash_eraseall binary from mtd-utils as of git head c4c6a59eb.
+ This utility is used to erase the whole MTD device.
+
+config BUSYBOX_CONFIG_IONICE
+ bool "ionice"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Set/set program io scheduling class and priority
+ Requires kernel >= 2.6.13
+
+config BUSYBOX_CONFIG_INOTIFYD
+ bool "inotifyd"
+ default n # doesn't build on Knoppix 5
+ help
+ Simple inotify daemon. Reports filesystem changes. Requires
+ kernel >= 2.6.13
+
+config BUSYBOX_CONFIG_LAST
+ bool "last"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_WTMP
+ help
+ 'last' displays a list of the last users that logged into the system.
+
+choice
+ prompt "Choose last implementation"
+ depends on BUSYBOX_CONFIG_LAST
+ default BUSYBOX_CONFIG_FEATURE_LAST_FANCY
+
+config BUSYBOX_CONFIG_FEATURE_LAST_SMALL
+ bool "small"
+ help
+ This is a small version of last with just the basic set of
+ features.
+
+config BUSYBOX_CONFIG_FEATURE_LAST_FANCY
+ bool "huge"
+ help
+ 'last' displays detailed information about the last users that
+ logged into the system (mimics sysvinit last). +900 bytes.
+endchoice
+
+config BUSYBOX_CONFIG_HDPARM
+ bool "hdparm"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Get/Set hard drive parameters. Primarily intended for ATA
+ drives. Adds about 13k (or around 30k if you enable the
+ FEATURE_HDPARM_GET_IDENTITY option)....
+
+config BUSYBOX_CONFIG_FEATURE_HDPARM_GET_IDENTITY
+ bool "Support obtaining detailed information directly from drives"
+ default n
+ depends on BUSYBOX_CONFIG_HDPARM
+ help
+ Enables the -I and -i options to obtain detailed information
+ directly from drives about their capabilities and supported ATA
+ feature set. If no device name is specified, hdparm will read
+ identify data from stdin. Enabling this option will add about 16k...
+
+config BUSYBOX_CONFIG_FEATURE_HDPARM_HDIO_SCAN_HWIF
+ bool "Register an IDE interface (DANGEROUS)"
+ default n
+ depends on BUSYBOX_CONFIG_HDPARM
+ help
+ Enables the 'hdparm -R' option to register an IDE interface.
+ This is dangerous stuff, so you should probably say N.
+
+config BUSYBOX_CONFIG_FEATURE_HDPARM_HDIO_UNREGISTER_HWIF
+ bool "Un-register an IDE interface (DANGEROUS)"
+ default n
+ depends on BUSYBOX_CONFIG_HDPARM
+ help
+ Enables the 'hdparm -U' option to un-register an IDE interface.
+ This is dangerous stuff, so you should probably say N.
+
+config BUSYBOX_CONFIG_FEATURE_HDPARM_HDIO_DRIVE_RESET
+ bool "Perform device reset (DANGEROUS)"
+ default n
+ depends on BUSYBOX_CONFIG_HDPARM
+ help
+ Enables the 'hdparm -w' option to perform a device reset.
+ This is dangerous stuff, so you should probably say N.
+
+config BUSYBOX_CONFIG_FEATURE_HDPARM_HDIO_TRISTATE_HWIF
+ bool "Tristate device for hotswap (DANGEROUS)"
+ default n
+ depends on BUSYBOX_CONFIG_HDPARM
+ help
+ Enables the 'hdparm -x' option to tristate device for hotswap,
+ and the '-b' option to get/set bus state. This is dangerous
+ stuff, so you should probably say N.
+
+config BUSYBOX_CONFIG_FEATURE_HDPARM_HDIO_GETSET_DMA
+ bool "Get/set using_dma flag"
+ default n
+ depends on BUSYBOX_CONFIG_HDPARM
+ help
+ Enables the 'hdparm -d' option to get/set using_dma flag.
+
+config BUSYBOX_CONFIG_LOCK
+ bool "lock"
+ default y
+ help
+ Small utility for using locks in scripts
+
+config BUSYBOX_CONFIG_MAKEDEVS
+ bool "makedevs"
+ default n
+ help
+ 'makedevs' is a utility used to create a batch of devices with
+ one command.
+
+ There are two choices for command line behaviour, the interface
+ as used by LEAF/Linux Router Project, or a device table file.
+
+ 'leaf' is traditionally what busybox follows, it allows multiple
+ devices of a particluar type to be created per command.
+ e.g. /dev/hda[0-9]
+ Device properties are passed as command line arguments.
+
+ 'table' reads device properties from a file or stdin, allowing
+ a batch of unrelated devices to be made with one command.
+ User/group names are allowed as an alternative to uid/gid.
+
+choice
+ prompt "Choose makedevs behaviour"
+ depends on BUSYBOX_CONFIG_MAKEDEVS
+ default BUSYBOX_CONFIG_FEATURE_MAKEDEVS_TABLE
+
+config BUSYBOX_CONFIG_FEATURE_MAKEDEVS_LEAF
+ bool "leaf"
+
+config BUSYBOX_CONFIG_FEATURE_MAKEDEVS_TABLE
+ bool "table"
+
+endchoice
+
+config BUSYBOX_CONFIG_MAN
+ bool "man"
+ default n
+ help
+ Format and display manual pages.
+
+config BUSYBOX_CONFIG_MICROCOM
+ bool "microcom"
+ default n
+ help
+ The poor man's minicom utility for chatting with serial port devices.
+
+config BUSYBOX_CONFIG_MOUNTPOINT
+ bool "mountpoint"
+ default n
+ help
+ mountpoint checks if the directory is a mountpoint.
+
+config BUSYBOX_CONFIG_MT
+ bool "mt"
+ default n
+ help
+ mt is used to control tape devices. You can use the mt utility
+ to advance or rewind a tape past a specified number of archive
+ files on the tape.
+
+config BUSYBOX_CONFIG_RAIDAUTORUN
+ bool "raidautorun"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ raidautorun tells the kernel md driver to
+ search and start RAID arrays.
+
+config BUSYBOX_CONFIG_READAHEAD
+ bool "readahead"
+ default n
+ depends on BUSYBOX_CONFIG_LFS
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Preload the files listed on the command line into RAM cache so that
+ subsequent reads on these files will not block on disk I/O.
+
+ This applet just calls the readahead(2) system call on each file.
+ It is mainly useful in system startup scripts to preload files
+ or executables before they are used. When used at the right time
+ (in particular when a CPU bound process is running) it can
+ significantly speed up system startup.
+
+ As readahead(2) blocks until each file has been read, it is best to
+ run this applet as a background job.
+
+config BUSYBOX_CONFIG_RFKILL
+ bool "rfkill"
+ default n # doesn't build on Ubuntu 9.04
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Enable/disable wireless devices.
+
+ rfkill list : list all wireless devices
+ rfkill list bluetooth : list all bluetooth devices
+ rfkill list 1 : list device corresponding to the given index
+ rfkill block|unblock wlan : block/unblock all wlan(wifi) devices
+
+config BUSYBOX_CONFIG_RUNLEVEL
+ bool "runlevel"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_UTMP
+ help
+ find the current and previous system runlevel.
+
+ This applet uses utmp but does not rely on busybox supporing
+ utmp on purpose. It is used by e.g. emdebian via /etc/init.d/rc.
+
+config BUSYBOX_CONFIG_RX
+ bool "rx"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Receive files using the Xmodem protocol.
+
+config BUSYBOX_CONFIG_SETSID
+ bool "setsid"
+ default n
+ help
+ setsid runs a program in a new session
+
+config BUSYBOX_CONFIG_STRINGS
+ bool "strings"
+ default y
+ help
+ strings prints the printable character sequences for each file
+ specified.
+
+config BUSYBOX_CONFIG_TASKSET
+ bool "taskset"
+ default n # doesn't build on some non-x86 targets (m68k)
+ help
+ Retrieve or set a processes's CPU affinity.
+ This requires sched_{g,s}etaffinity support in your libc.
+
+config BUSYBOX_CONFIG_FEATURE_TASKSET_FANCY
+ bool "Fancy output"
+ default n
+ depends on BUSYBOX_CONFIG_TASKSET
+ help
+ Add code for fancy output. This merely silences a compiler-warning
+ and adds about 135 Bytes. May be needed for machines with alot
+ of CPUs.
+
+config BUSYBOX_CONFIG_TIME
+ bool "time"
+ default y
+ help
+ The time command runs the specified program with the given arguments.
+ When the command finishes, time writes a message to standard output
+ giving timing statistics about this program run.
+
+config BUSYBOX_CONFIG_TIMEOUT
+ bool "timeout"
+ default n
+ help
+ Runs a program and watches it. If it does not terminate in
+ specified number of seconds, it is sent a signal.
+
+config BUSYBOX_CONFIG_TTYSIZE
+ bool "ttysize"
+ default n
+ help
+ A replacement for "stty size". Unlike stty, can report only width,
+ only height, or both, in any order. It also does not complain on
+ error, but returns default 80x24.
+ Usage in shell scripts: width=`ttysize w`.
+
+config BUSYBOX_CONFIG_VOLNAME
+ bool "volname"
+ default n
+ help
+ Prints a CD-ROM volume name.
+
+config BUSYBOX_CONFIG_WALL
+ bool "wall"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_UTMP
+ help
+ Write a message to all users that are logged in.
+
+config BUSYBOX_CONFIG_WATCHDOG
+ bool "watchdog"
+ default y
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ The watchdog utility is used with hardware or software watchdog
+ device drivers. It opens the specified watchdog device special file
+ and periodically writes a magic character to the device. If the
+ watchdog applet ever fails to write the magic character within a
+ certain amount of time, the watchdog device assumes the system has
+ hung, and will cause the hardware to reboot.
+
+endmenu
diff --git a/package/busybox/config/modutils/.svn/entries b/package/busybox/config/modutils/.svn/entries
new file mode 100644
index 0000000..080c408
--- /dev/null
+++ b/package/busybox/config/modutils/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/busybox/config/modutils
+svn://svn.openwrt.org/openwrt
+
+
+
+2011-11-03T15:55:23.444601Z
+28725
+nico
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+Config.in
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+a2b6bda6e488acb67346f41b873009e7
+2011-11-03T15:55:23.444601Z
+28725
+nico
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+9312
+
diff --git a/package/busybox/config/modutils/.svn/prop-base/Config.in.svn-base b/package/busybox/config/modutils/.svn/prop-base/Config.in.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/busybox/config/modutils/.svn/prop-base/Config.in.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/busybox/config/modutils/.svn/text-base/Config.in.svn-base b/package/busybox/config/modutils/.svn/text-base/Config.in.svn-base
new file mode 100644
index 0000000..77f9858
--- /dev/null
+++ b/package/busybox/config/modutils/.svn/text-base/Config.in.svn-base
@@ -0,0 +1,269 @@
+# DO NOT EDIT. This file is generated from Config.src
+#
+# For a description of the syntax of this configuration file,
+# see scripts/kbuild/config-language.txt.
+#
+
+menu "Linux Module Utilities"
+
+config BUSYBOX_CONFIG_MODINFO
+ bool "modinfo"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Show information about a Linux Kernel module
+
+config BUSYBOX_CONFIG_MODPROBE_SMALL
+ bool "Simplified modutils"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Simplified modutils.
+
+ With this option modprobe does not require modules.dep file
+ and does not use /etc/modules.conf file.
+ It scans module files in /lib/modules/`uname -r` and
+ determines dependencies and module alias names on the fly.
+ This may make module loading slower, most notably
+ when one needs to load module by alias (this requires
+ scanning through module _bodies_).
+
+ At the first attempt to load a module by alias modprobe
+ will try to generate modules.dep.bb file in order to speed up
+ future loads by alias. Failure to do so (read-only /lib/modules,
+ etc) is not reported, and future modprobes will be slow too.
+
+ NB: modules.dep.bb file format is not compatible
+ with modules.dep file as created/used by standard module tools.
+
+ Additional module parameters can be stored in
+ /etc/modules/$module_name files.
+
+ Apart from modprobe, other utilities are also provided:
+ - insmod is an alias to modprobe
+ - rmmod is an alias to modprobe -r
+ - depmod generates modules.dep.bb
+
+ As of 2008-07, this code is experimental. It is 14kb smaller
+ than "non-small" modutils.
+
+config BUSYBOX_CONFIG_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE
+ bool "Accept module options on modprobe command line"
+ default n
+ depends on BUSYBOX_CONFIG_MODPROBE_SMALL
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Allow insmod and modprobe take module options from command line.
+
+config BUSYBOX_CONFIG_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED
+ bool "Skip loading of already loaded modules"
+ default n
+ depends on BUSYBOX_CONFIG_MODPROBE_SMALL
+ help
+ Check if the module is already loaded.
+
+config BUSYBOX_CONFIG_INSMOD
+ bool "insmod"
+ default y
+ depends on !BUSYBOX_CONFIG_MODPROBE_SMALL
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ insmod is used to load specified modules in the running kernel.
+
+config BUSYBOX_CONFIG_RMMOD
+ bool "rmmod"
+ default y
+ depends on !BUSYBOX_CONFIG_MODPROBE_SMALL
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ rmmod is used to unload specified modules from the kernel.
+
+config BUSYBOX_CONFIG_LSMOD
+ bool "lsmod"
+ default y
+ depends on !BUSYBOX_CONFIG_MODPROBE_SMALL
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ lsmod is used to display a list of loaded modules.
+
+config BUSYBOX_CONFIG_FEATURE_LSMOD_PRETTY_2_6_OUTPUT
+ bool "Pretty output"
+ default y
+ depends on BUSYBOX_CONFIG_LSMOD
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ This option makes output format of lsmod adjusted to
+ the format of module-init-tools for Linux kernel 2.6.
+ Increases size somewhat.
+
+config BUSYBOX_CONFIG_MODPROBE
+ bool "modprobe"
+ default n
+ depends on !BUSYBOX_CONFIG_MODPROBE_SMALL
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Handle the loading of modules, and their dependencies on a high
+ level.
+
+config BUSYBOX_CONFIG_FEATURE_MODPROBE_BLACKLIST
+ bool "Blacklist support"
+ default n
+ depends on BUSYBOX_CONFIG_MODPROBE
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Say 'y' here to enable support for the 'blacklist' command in
+ modprobe.conf. This prevents the alias resolver to resolve
+ blacklisted modules. This is useful if you want to prevent your
+ hardware autodetection scripts to load modules like evdev, frame
+ buffer drivers etc.
+
+config BUSYBOX_CONFIG_DEPMOD
+ bool "depmod"
+ default n
+ depends on !BUSYBOX_CONFIG_MODPROBE_SMALL
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ depmod generates modules.dep (and potentially modules.alias
+ and modules.symbols) that contain dependency information
+ for modprobe.
+
+comment "Options common to multiple modutils"
+
+config BUSYBOX_CONFIG_FEATURE_2_4_MODULES
+ bool "Support version 2.2/2.4 Linux kernels"
+ default n
+ depends on BUSYBOX_CONFIG_INSMOD || BUSYBOX_CONFIG_RMMOD || BUSYBOX_CONFIG_LSMOD
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Support module loading for 2.2.x and 2.4.x Linux kernels.
+ This increases size considerably. Say N unless you plan
+ to run ancient kernels.
+
+config BUSYBOX_CONFIG_FEATURE_INSMOD_TRY_MMAP
+ bool "Try to load module from a mmap'ed area"
+ default n
+ depends on BUSYBOX_CONFIG_INSMOD || BUSYBOX_CONFIG_MODPROBE_SMALL
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ This option causes module loading code to try to mmap
+ module first. If it does not work (for example,
+ it does not work for compressed modules), module will be read
+ (and unpacked if needed) into a memory block allocated by malloc.
+
+ The only case when mmap works but malloc does not is when
+ you are trying to load a big module on a very memory-constrained
+ machine. Malloc will momentarily need 2x as much memory as mmap.
+
+ Choosing N saves about 250 bytes of code (on 32-bit x86).
+
+config BUSYBOX_CONFIG_FEATURE_INSMOD_VERSION_CHECKING
+ bool "Enable module version checking"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_2_4_MODULES && (BUSYBOX_CONFIG_INSMOD || BUSYBOX_CONFIG_MODPROBE)
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Support checking of versions for modules. This is used to
+ ensure that the kernel and module are made for each other.
+
+config BUSYBOX_CONFIG_FEATURE_INSMOD_KSYMOOPS_SYMBOLS
+ bool "Add module symbols to kernel symbol table"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_2_4_MODULES && (BUSYBOX_CONFIG_INSMOD || BUSYBOX_CONFIG_MODPROBE)
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ By adding module symbols to the kernel symbol table, Oops messages
+ occuring within kernel modules can be properly debugged. By enabling
+ this feature, module symbols will always be added to the kernel symbol
+ table for proper debugging support. If you are not interested in
+ Oops messages from kernel modules, say N.
+
+config BUSYBOX_CONFIG_FEATURE_INSMOD_LOADINKMEM
+ bool "In kernel memory optimization (uClinux only)"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_2_4_MODULES && (BUSYBOX_CONFIG_INSMOD || BUSYBOX_CONFIG_MODPROBE)
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ This is a special uClinux only memory optimization that lets insmod
+ load the specified kernel module directly into kernel space, reducing
+ memory usage by preventing the need for two copies of the module
+ being loaded into memory.
+
+config BUSYBOX_CONFIG_FEATURE_INSMOD_LOAD_MAP
+ bool "Enable insmod load map (-m) option"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_2_4_MODULES && BUSYBOX_CONFIG_INSMOD
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Enabling this, one would be able to get a load map
+ output on stdout. This makes kernel module debugging
+ easier.
+ If you don't plan to debug kernel modules, you
+ don't need this option.
+
+config BUSYBOX_CONFIG_FEATURE_INSMOD_LOAD_MAP_FULL
+ bool "Symbols in load map"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_INSMOD_LOAD_MAP && !BUSYBOX_CONFIG_MODPROBE_SMALL
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Without this option, -m will only output section
+ load map. With this option, -m will also output
+ symbols load map.
+
+config BUSYBOX_CONFIG_FEATURE_CHECK_TAINTED_MODULE
+ bool "Support tainted module checking with new kernels"
+ default y
+ depends on (BUSYBOX_CONFIG_LSMOD || BUSYBOX_CONFIG_FEATURE_2_4_MODULES) && !BUSYBOX_CONFIG_MODPROBE_SMALL
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Support checking for tainted modules. These are usually binary
+ only modules that will make the linux-kernel list ignore your
+ support request.
+ This option is required to support GPLONLY modules.
+
+config BUSYBOX_CONFIG_FEATURE_MODUTILS_ALIAS
+ bool "Support for module.aliases file"
+ default n
+ depends on BUSYBOX_CONFIG_DEPMOD || BUSYBOX_CONFIG_MODPROBE
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Generate and parse modules.alias containing aliases for bus
+ identifiers:
+ alias pcmcia:m*c*f03fn*pfn*pa*pb*pc*pd* parport_cs
+
+ and aliases for logical modules names e.g.:
+ alias padlock_aes aes
+ alias aes_i586 aes
+ alias aes_generic aes
+
+ Say Y if unsure.
+
+config BUSYBOX_CONFIG_FEATURE_MODUTILS_SYMBOLS
+ bool "Support for module.symbols file"
+ default n
+ depends on BUSYBOX_CONFIG_DEPMOD || BUSYBOX_CONFIG_MODPROBE
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Generate and parse modules.symbols containing aliases for
+ symbol_request() kernel calls, such as:
+ alias symbol:usb_sg_init usbcore
+
+ Say Y if unsure.
+
+config BUSYBOX_CONFIG_DEFAULT_MODULES_DIR
+ string "Default directory containing modules"
+ default "/lib/modules"
+ depends on BUSYBOX_CONFIG_DEPMOD || BUSYBOX_CONFIG_INSMOD || BUSYBOX_CONFIG_MODPROBE || BUSYBOX_CONFIG_MODPROBE_SMALL || BUSYBOX_CONFIG_MODINFO
+ help
+ Directory that contains kernel modules.
+ Defaults to "/lib/modules"
+
+config BUSYBOX_CONFIG_DEFAULT_DEPMOD_FILE
+ string "Default name of modules.dep"
+ default "modules.dep"
+ depends on BUSYBOX_CONFIG_DEPMOD || BUSYBOX_CONFIG_MODPROBE || BUSYBOX_CONFIG_MODPROBE_SMALL || BUSYBOX_CONFIG_MODINFO
+ help
+ Filename that contains kernel modules dependencies.
+ Defaults to "modules.dep"
+
+endmenu
diff --git a/package/busybox/config/modutils/Config.in b/package/busybox/config/modutils/Config.in
new file mode 100644
index 0000000..77f9858
--- /dev/null
+++ b/package/busybox/config/modutils/Config.in
@@ -0,0 +1,269 @@
+# DO NOT EDIT. This file is generated from Config.src
+#
+# For a description of the syntax of this configuration file,
+# see scripts/kbuild/config-language.txt.
+#
+
+menu "Linux Module Utilities"
+
+config BUSYBOX_CONFIG_MODINFO
+ bool "modinfo"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Show information about a Linux Kernel module
+
+config BUSYBOX_CONFIG_MODPROBE_SMALL
+ bool "Simplified modutils"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Simplified modutils.
+
+ With this option modprobe does not require modules.dep file
+ and does not use /etc/modules.conf file.
+ It scans module files in /lib/modules/`uname -r` and
+ determines dependencies and module alias names on the fly.
+ This may make module loading slower, most notably
+ when one needs to load module by alias (this requires
+ scanning through module _bodies_).
+
+ At the first attempt to load a module by alias modprobe
+ will try to generate modules.dep.bb file in order to speed up
+ future loads by alias. Failure to do so (read-only /lib/modules,
+ etc) is not reported, and future modprobes will be slow too.
+
+ NB: modules.dep.bb file format is not compatible
+ with modules.dep file as created/used by standard module tools.
+
+ Additional module parameters can be stored in
+ /etc/modules/$module_name files.
+
+ Apart from modprobe, other utilities are also provided:
+ - insmod is an alias to modprobe
+ - rmmod is an alias to modprobe -r
+ - depmod generates modules.dep.bb
+
+ As of 2008-07, this code is experimental. It is 14kb smaller
+ than "non-small" modutils.
+
+config BUSYBOX_CONFIG_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE
+ bool "Accept module options on modprobe command line"
+ default n
+ depends on BUSYBOX_CONFIG_MODPROBE_SMALL
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Allow insmod and modprobe take module options from command line.
+
+config BUSYBOX_CONFIG_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED
+ bool "Skip loading of already loaded modules"
+ default n
+ depends on BUSYBOX_CONFIG_MODPROBE_SMALL
+ help
+ Check if the module is already loaded.
+
+config BUSYBOX_CONFIG_INSMOD
+ bool "insmod"
+ default y
+ depends on !BUSYBOX_CONFIG_MODPROBE_SMALL
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ insmod is used to load specified modules in the running kernel.
+
+config BUSYBOX_CONFIG_RMMOD
+ bool "rmmod"
+ default y
+ depends on !BUSYBOX_CONFIG_MODPROBE_SMALL
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ rmmod is used to unload specified modules from the kernel.
+
+config BUSYBOX_CONFIG_LSMOD
+ bool "lsmod"
+ default y
+ depends on !BUSYBOX_CONFIG_MODPROBE_SMALL
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ lsmod is used to display a list of loaded modules.
+
+config BUSYBOX_CONFIG_FEATURE_LSMOD_PRETTY_2_6_OUTPUT
+ bool "Pretty output"
+ default y
+ depends on BUSYBOX_CONFIG_LSMOD
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ This option makes output format of lsmod adjusted to
+ the format of module-init-tools for Linux kernel 2.6.
+ Increases size somewhat.
+
+config BUSYBOX_CONFIG_MODPROBE
+ bool "modprobe"
+ default n
+ depends on !BUSYBOX_CONFIG_MODPROBE_SMALL
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Handle the loading of modules, and their dependencies on a high
+ level.
+
+config BUSYBOX_CONFIG_FEATURE_MODPROBE_BLACKLIST
+ bool "Blacklist support"
+ default n
+ depends on BUSYBOX_CONFIG_MODPROBE
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Say 'y' here to enable support for the 'blacklist' command in
+ modprobe.conf. This prevents the alias resolver to resolve
+ blacklisted modules. This is useful if you want to prevent your
+ hardware autodetection scripts to load modules like evdev, frame
+ buffer drivers etc.
+
+config BUSYBOX_CONFIG_DEPMOD
+ bool "depmod"
+ default n
+ depends on !BUSYBOX_CONFIG_MODPROBE_SMALL
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ depmod generates modules.dep (and potentially modules.alias
+ and modules.symbols) that contain dependency information
+ for modprobe.
+
+comment "Options common to multiple modutils"
+
+config BUSYBOX_CONFIG_FEATURE_2_4_MODULES
+ bool "Support version 2.2/2.4 Linux kernels"
+ default n
+ depends on BUSYBOX_CONFIG_INSMOD || BUSYBOX_CONFIG_RMMOD || BUSYBOX_CONFIG_LSMOD
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Support module loading for 2.2.x and 2.4.x Linux kernels.
+ This increases size considerably. Say N unless you plan
+ to run ancient kernels.
+
+config BUSYBOX_CONFIG_FEATURE_INSMOD_TRY_MMAP
+ bool "Try to load module from a mmap'ed area"
+ default n
+ depends on BUSYBOX_CONFIG_INSMOD || BUSYBOX_CONFIG_MODPROBE_SMALL
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ This option causes module loading code to try to mmap
+ module first. If it does not work (for example,
+ it does not work for compressed modules), module will be read
+ (and unpacked if needed) into a memory block allocated by malloc.
+
+ The only case when mmap works but malloc does not is when
+ you are trying to load a big module on a very memory-constrained
+ machine. Malloc will momentarily need 2x as much memory as mmap.
+
+ Choosing N saves about 250 bytes of code (on 32-bit x86).
+
+config BUSYBOX_CONFIG_FEATURE_INSMOD_VERSION_CHECKING
+ bool "Enable module version checking"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_2_4_MODULES && (BUSYBOX_CONFIG_INSMOD || BUSYBOX_CONFIG_MODPROBE)
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Support checking of versions for modules. This is used to
+ ensure that the kernel and module are made for each other.
+
+config BUSYBOX_CONFIG_FEATURE_INSMOD_KSYMOOPS_SYMBOLS
+ bool "Add module symbols to kernel symbol table"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_2_4_MODULES && (BUSYBOX_CONFIG_INSMOD || BUSYBOX_CONFIG_MODPROBE)
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ By adding module symbols to the kernel symbol table, Oops messages
+ occuring within kernel modules can be properly debugged. By enabling
+ this feature, module symbols will always be added to the kernel symbol
+ table for proper debugging support. If you are not interested in
+ Oops messages from kernel modules, say N.
+
+config BUSYBOX_CONFIG_FEATURE_INSMOD_LOADINKMEM
+ bool "In kernel memory optimization (uClinux only)"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_2_4_MODULES && (BUSYBOX_CONFIG_INSMOD || BUSYBOX_CONFIG_MODPROBE)
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ This is a special uClinux only memory optimization that lets insmod
+ load the specified kernel module directly into kernel space, reducing
+ memory usage by preventing the need for two copies of the module
+ being loaded into memory.
+
+config BUSYBOX_CONFIG_FEATURE_INSMOD_LOAD_MAP
+ bool "Enable insmod load map (-m) option"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_2_4_MODULES && BUSYBOX_CONFIG_INSMOD
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Enabling this, one would be able to get a load map
+ output on stdout. This makes kernel module debugging
+ easier.
+ If you don't plan to debug kernel modules, you
+ don't need this option.
+
+config BUSYBOX_CONFIG_FEATURE_INSMOD_LOAD_MAP_FULL
+ bool "Symbols in load map"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_INSMOD_LOAD_MAP && !BUSYBOX_CONFIG_MODPROBE_SMALL
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Without this option, -m will only output section
+ load map. With this option, -m will also output
+ symbols load map.
+
+config BUSYBOX_CONFIG_FEATURE_CHECK_TAINTED_MODULE
+ bool "Support tainted module checking with new kernels"
+ default y
+ depends on (BUSYBOX_CONFIG_LSMOD || BUSYBOX_CONFIG_FEATURE_2_4_MODULES) && !BUSYBOX_CONFIG_MODPROBE_SMALL
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Support checking for tainted modules. These are usually binary
+ only modules that will make the linux-kernel list ignore your
+ support request.
+ This option is required to support GPLONLY modules.
+
+config BUSYBOX_CONFIG_FEATURE_MODUTILS_ALIAS
+ bool "Support for module.aliases file"
+ default n
+ depends on BUSYBOX_CONFIG_DEPMOD || BUSYBOX_CONFIG_MODPROBE
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Generate and parse modules.alias containing aliases for bus
+ identifiers:
+ alias pcmcia:m*c*f03fn*pfn*pa*pb*pc*pd* parport_cs
+
+ and aliases for logical modules names e.g.:
+ alias padlock_aes aes
+ alias aes_i586 aes
+ alias aes_generic aes
+
+ Say Y if unsure.
+
+config BUSYBOX_CONFIG_FEATURE_MODUTILS_SYMBOLS
+ bool "Support for module.symbols file"
+ default n
+ depends on BUSYBOX_CONFIG_DEPMOD || BUSYBOX_CONFIG_MODPROBE
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Generate and parse modules.symbols containing aliases for
+ symbol_request() kernel calls, such as:
+ alias symbol:usb_sg_init usbcore
+
+ Say Y if unsure.
+
+config BUSYBOX_CONFIG_DEFAULT_MODULES_DIR
+ string "Default directory containing modules"
+ default "/lib/modules"
+ depends on BUSYBOX_CONFIG_DEPMOD || BUSYBOX_CONFIG_INSMOD || BUSYBOX_CONFIG_MODPROBE || BUSYBOX_CONFIG_MODPROBE_SMALL || BUSYBOX_CONFIG_MODINFO
+ help
+ Directory that contains kernel modules.
+ Defaults to "/lib/modules"
+
+config BUSYBOX_CONFIG_DEFAULT_DEPMOD_FILE
+ string "Default name of modules.dep"
+ default "modules.dep"
+ depends on BUSYBOX_CONFIG_DEPMOD || BUSYBOX_CONFIG_MODPROBE || BUSYBOX_CONFIG_MODPROBE_SMALL || BUSYBOX_CONFIG_MODINFO
+ help
+ Filename that contains kernel modules dependencies.
+ Defaults to "modules.dep"
+
+endmenu
diff --git a/package/busybox/config/networking/.svn/entries b/package/busybox/config/networking/.svn/entries
new file mode 100644
index 0000000..6a9e2c6
--- /dev/null
+++ b/package/busybox/config/networking/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/busybox/config/networking
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-01-19T01:50:53.341435Z
+29789
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+udhcp
+dir
+
+Config.in
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+d1b5d311b21a1e106deef11b6cdd063f
+2012-01-19T01:50:53.341435Z
+29789
+jow
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+32253
+
diff --git a/package/busybox/config/networking/.svn/prop-base/Config.in.svn-base b/package/busybox/config/networking/.svn/prop-base/Config.in.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/busybox/config/networking/.svn/prop-base/Config.in.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/busybox/config/networking/.svn/text-base/Config.in.svn-base b/package/busybox/config/networking/.svn/text-base/Config.in.svn-base
new file mode 100644
index 0000000..3df7b1f
--- /dev/null
+++ b/package/busybox/config/networking/.svn/text-base/Config.in.svn-base
@@ -0,0 +1,1088 @@
+# DO NOT EDIT. This file is generated from Config.src
+#
+# For a description of the syntax of this configuration file,
+# see scripts/kbuild/config-language.txt.
+#
+
+menu "Networking Utilities"
+
+config BUSYBOX_CONFIG_NAMEIF
+ bool "nameif"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ select BUSYBOX_CONFIG_FEATURE_SYSLOG
+ help
+ nameif is used to rename network interface by its MAC address.
+ Renamed interfaces MUST be in the down state.
+ It is possible to use a file (default: /etc/mactab)
+ with list of new interface names and MACs.
+ Maximum interface name length: IFNAMSIZ = 16
+ File fields are separated by space or tab.
+ File format:
+ # Comment
+ new_interface_name XX:XX:XX:XX:XX:XX
+
+config BUSYBOX_CONFIG_FEATURE_NAMEIF_EXTENDED
+ bool "Extended nameif"
+ default n
+ depends on BUSYBOX_CONFIG_NAMEIF
+ help
+ This extends the nameif syntax to support the bus_info, driver,
+ phyaddr selectors. The syntax is compatible to the normal nameif.
+ File format:
+ new_interface_name driver=asix bus=usb-0000:00:08.2-3
+ new_interface_name bus=usb-0000:00:08.2-3 00:80:C8:38:91:B5
+ new_interface_name phy_address=2 00:80:C8:38:91:B5
+ new_interface_name mac=00:80:C8:38:91:B5
+ new_interface_name 00:80:C8:38:91:B5
+config BUSYBOX_CONFIG_NBDCLIENT
+ bool "nbd-client"
+ default n
+ help
+ Network block device client
+config BUSYBOX_CONFIG_NC
+ bool "nc"
+ default y
+ help
+ A simple Unix utility which reads and writes data across network
+ connections.
+
+config BUSYBOX_CONFIG_NC_SERVER
+ bool "Netcat server options (-l)"
+ default n
+ depends on BUSYBOX_CONFIG_NC
+ help
+ Allow netcat to act as a server.
+
+config BUSYBOX_CONFIG_NC_EXTRA
+ bool "Netcat extensions (-eiw and filename)"
+ default n
+ depends on BUSYBOX_CONFIG_NC
+ help
+ Add -e (support for executing the rest of the command line after
+ making or receiving a successful connection), -i (delay interval for
+ lines sent), -w (timeout for initial connection).
+
+config BUSYBOX_CONFIG_NC_110_COMPAT
+ bool "Netcat 1.10 compatibility (+2.5k)"
+ default n # off specially for Rob
+ depends on BUSYBOX_CONFIG_NC
+ help
+ This option makes nc closely follow original nc-1.10.
+ The code is about 2.5k bigger. It enables
+ -s ADDR, -n, -u, -v, -o FILE, -z options, but loses
+ busybox-specific extensions: -f FILE and -ll.
+config BUSYBOX_CONFIG_PING
+ bool "ping"
+ default y
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ ping uses the ICMP protocol's mandatory ECHO_REQUEST datagram to
+ elicit an ICMP ECHO_RESPONSE from a host or gateway.
+
+config BUSYBOX_CONFIG_PING6
+ bool "ping6"
+ default y
+ depends on BUSYBOX_CONFIG_FEATURE_IPV6 && BUSYBOX_CONFIG_PING
+ help
+ This will give you a ping that can talk IPv6.
+
+config BUSYBOX_CONFIG_FEATURE_FANCY_PING
+ bool "Enable fancy ping output"
+ default y
+ depends on BUSYBOX_CONFIG_PING
+ help
+ Make the output from the ping applet include statistics, and at the
+ same time provide full support for ICMP packets.
+config BUSYBOX_CONFIG_WHOIS
+ bool "whois"
+ default n
+ help
+ whois is a client for the whois directory service
+
+config BUSYBOX_CONFIG_FEATURE_IPV6
+ bool "Enable IPv6 support"
+ default IPV6
+ help
+ Enable IPv6 support in busybox.
+ This adds IPv6 support in the networking applets.
+
+config BUSYBOX_CONFIG_FEATURE_UNIX_LOCAL
+ bool "Enable Unix domain socket support (usually not needed)"
+ default n
+ help
+ Enable Unix domain socket support in all busybox networking
+ applets. Address of the form local:/path/to/unix/socket
+ will be recognized.
+
+ This extension is almost never used in real world usage.
+ You most likely want to say N.
+
+config BUSYBOX_CONFIG_FEATURE_PREFER_IPV4_ADDRESS
+ bool "Prefer IPv4 addresses from DNS queries"
+ default y
+ depends on BUSYBOX_CONFIG_FEATURE_IPV6
+ help
+ Use IPv4 address of network host if it has one.
+
+ If this option is off, the first returned address will be used.
+ This may cause problems when your DNS server is IPv6-capable and
+ is returning IPv6 host addresses too. If IPv6 address
+ precedes IPv4 one in DNS reply, busybox network applets
+ (e.g. wget) will use IPv6 address. On an IPv6-incapable host
+ or network applets will fail to connect to the host
+ using IPv6 address.
+
+config BUSYBOX_CONFIG_VERBOSE_RESOLUTION_ERRORS
+ bool "Verbose resolution errors"
+ default y
+ help
+ Enable if you are not satisfied with simplistic
+ "can't resolve 'hostname.com'" and want to know more.
+ This may increase size of your executable a bit.
+
+config BUSYBOX_CONFIG_ARP
+ bool "arp"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Manipulate the system ARP cache.
+
+config BUSYBOX_CONFIG_ARPING
+ bool "arping"
+ default y
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Ping hosts by ARP packets.
+
+config BUSYBOX_CONFIG_BRCTL
+ bool "brctl"
+ default y
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Manage ethernet bridges.
+ Supports addbr/delbr and addif/delif.
+
+config BUSYBOX_CONFIG_FEATURE_BRCTL_FANCY
+ bool "Fancy options"
+ default y
+ depends on BUSYBOX_CONFIG_BRCTL
+ help
+ Add support for extended option like:
+ setageing, setfd, sethello, setmaxage,
+ setpathcost, setportprio, setbridgeprio,
+ stp
+ This adds about 600 bytes.
+
+config BUSYBOX_CONFIG_FEATURE_BRCTL_SHOW
+ bool "Support show"
+ default y
+ depends on BUSYBOX_CONFIG_BRCTL && BUSYBOX_CONFIG_FEATURE_BRCTL_FANCY
+ help
+ Add support for option which prints the current config:
+ show
+
+config BUSYBOX_CONFIG_DNSD
+ bool "dnsd"
+ default n
+ help
+ Small and static DNS server daemon.
+
+config BUSYBOX_CONFIG_ETHER_WAKE
+ bool "ether-wake"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Send a magic packet to wake up sleeping machines.
+
+config BUSYBOX_CONFIG_FAKEIDENTD
+ bool "fakeidentd"
+ default n
+ select BUSYBOX_CONFIG_FEATURE_SYSLOG
+ help
+ fakeidentd listens on the ident port and returns a predefined
+ fake value on any query.
+
+config BUSYBOX_CONFIG_FTPD
+ bool "ftpd"
+ default n
+ help
+ simple FTP daemon. You have to run it via inetd.
+
+config BUSYBOX_CONFIG_FEATURE_FTP_WRITE
+ bool "Enable upload commands"
+ default n
+ depends on BUSYBOX_CONFIG_FTPD
+ help
+ Enable all kinds of FTP upload commands (-w option)
+
+config BUSYBOX_CONFIG_FEATURE_FTPD_ACCEPT_BROKEN_LIST
+ bool "Enable workaround for RFC-violating clients"
+ default n
+ depends on BUSYBOX_CONFIG_FTPD
+ help
+ Some ftp clients (among them KDE's Konqueror) issue illegal
+ "LIST -l" requests. This option works around such problems.
+ It might prevent you from listing files starting with "-" and
+ it increases the code size by ~40 bytes.
+ Most other ftp servers seem to behave similar to this.
+
+config BUSYBOX_CONFIG_FTPGET
+ bool "ftpget"
+ default n
+ help
+ Retrieve a remote file via FTP.
+
+config BUSYBOX_CONFIG_FTPPUT
+ bool "ftpput"
+ default n
+ help
+ Store a remote file via FTP.
+
+config BUSYBOX_CONFIG_FEATURE_FTPGETPUT_LONG_OPTIONS
+ bool "Enable long options in ftpget/ftpput"
+ default n
+ depends on BUSYBOX_CONFIG_LONG_OPTS && (BUSYBOX_CONFIG_FTPGET || BUSYBOX_CONFIG_FTPPUT)
+ help
+ Support long options for the ftpget/ftpput applet.
+
+config BUSYBOX_CONFIG_HOSTNAME
+ bool "hostname"
+ default n
+ help
+ Show or set the system's host name.
+
+config BUSYBOX_CONFIG_HTTPD
+ bool "httpd"
+ default n
+ help
+ Serve web pages via an HTTP server.
+
+config BUSYBOX_CONFIG_FEATURE_HTTPD_RANGES
+ bool "Support 'Ranges:' header"
+ default n
+ depends on BUSYBOX_CONFIG_HTTPD
+ help
+ Makes httpd emit "Accept-Ranges: bytes" header and understand
+ "Range: bytes=NNN-[MMM]" header. Allows for resuming interrupted
+ downloads, seeking in multimedia players etc.
+
+config BUSYBOX_CONFIG_FEATURE_HTTPD_USE_SENDFILE
+ bool "Use sendfile system call"
+ default n
+ depends on BUSYBOX_CONFIG_HTTPD
+ help
+ When enabled, httpd will use the kernel sendfile() function
+ instead of read/write loop.
+
+config BUSYBOX_CONFIG_FEATURE_HTTPD_SETUID
+ bool "Enable -u <user> option"
+ default n
+ depends on BUSYBOX_CONFIG_HTTPD
+ help
+ This option allows the server to run as a specific user
+ rather than defaulting to the user that starts the server.
+ Use of this option requires special privileges to change to a
+ different user.
+
+config BUSYBOX_CONFIG_FEATURE_HTTPD_BASIC_AUTH
+ bool "Enable Basic http Authentication"
+ default n
+ depends on BUSYBOX_CONFIG_HTTPD
+ help
+ Utilizes password settings from /etc/httpd.conf for basic
+ authentication on a per url basis.
+
+config BUSYBOX_CONFIG_FEATURE_HTTPD_AUTH_MD5
+ bool "Support MD5 crypted passwords for http Authentication"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_HTTPD_BASIC_AUTH
+ help
+ Enables basic per URL authentication from /etc/httpd.conf
+ using md5 passwords.
+
+config BUSYBOX_CONFIG_FEATURE_HTTPD_CGI
+ bool "Support Common Gateway Interface (CGI)"
+ default n
+ depends on BUSYBOX_CONFIG_HTTPD
+ help
+ This option allows scripts and executables to be invoked
+ when specific URLs are requested.
+
+config BUSYBOX_CONFIG_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR
+ bool "Support for running scripts through an interpreter"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_HTTPD_CGI
+ help
+ This option enables support for running scripts through an
+ interpreter. Turn this on if you want PHP scripts to work
+ properly. You need to supply an additional line in your httpd
+ config file:
+ *.php:/path/to/your/php
+
+config BUSYBOX_CONFIG_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV
+ bool "Set REMOTE_PORT environment variable for CGI"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_HTTPD_CGI
+ help
+ Use of this option can assist scripts in generating
+ references that contain a unique port number.
+
+config BUSYBOX_CONFIG_FEATURE_HTTPD_ENCODE_URL_STR
+ bool "Enable -e option (useful for CGIs written as shell scripts)"
+ default n
+ depends on BUSYBOX_CONFIG_HTTPD
+ help
+ This option allows html encoding of arbitrary strings for display
+ by the browser. Output goes to stdout.
+ For example, httpd -e "<Hello World>" produces
+ "&#60Hello&#32World&#62".
+
+config BUSYBOX_CONFIG_FEATURE_HTTPD_ERROR_PAGES
+ bool "Support for custom error pages"
+ default n
+ depends on BUSYBOX_CONFIG_HTTPD
+ help
+ This option allows you to define custom error pages in
+ the configuration file instead of the default HTTP status
+ error pages. For instance, if you add the line:
+ E404:/path/e404.html
+ in the config file, the server will respond the specified
+ '/path/e404.html' file instead of the terse '404 NOT FOUND'
+ message.
+
+config BUSYBOX_CONFIG_FEATURE_HTTPD_PROXY
+ bool "Support for reverse proxy"
+ default n
+ depends on BUSYBOX_CONFIG_HTTPD
+ help
+ This option allows you to define URLs that will be forwarded
+ to another HTTP server. To setup add the following line to the
+ configuration file
+ P:/url/:http://hostname[:port]/new/path/
+ Then a request to /url/myfile will be forwarded to
+ http://hostname[:port]/new/path/myfile.
+
+config BUSYBOX_CONFIG_FEATURE_HTTPD_GZIP
+ bool "Support for GZIP content encoding"
+ default n
+ depends on BUSYBOX_CONFIG_HTTPD
+ help
+ Makes httpd send files using GZIP content encoding if the
+ client supports it and a pre-compressed <file>.gz exists.
+
+config BUSYBOX_CONFIG_IFCONFIG
+ bool "ifconfig"
+ default y
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Ifconfig is used to configure the kernel-resident network interfaces.
+
+config BUSYBOX_CONFIG_FEATURE_IFCONFIG_STATUS
+ bool "Enable status reporting output (+7k)"
+ default y
+ depends on BUSYBOX_CONFIG_IFCONFIG
+ help
+ If ifconfig is called with no arguments it will display the status
+ of the currently active interfaces.
+
+config BUSYBOX_CONFIG_FEATURE_IFCONFIG_SLIP
+ bool "Enable slip-specific options \"keepalive\" and \"outfill\""
+ default n
+ depends on BUSYBOX_CONFIG_IFCONFIG
+ help
+ Allow "keepalive" and "outfill" support for SLIP. If you're not
+ planning on using serial lines, leave this unchecked.
+
+config BUSYBOX_CONFIG_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ
+ bool "Enable options \"mem_start\", \"io_addr\", and \"irq\""
+ default n
+ depends on BUSYBOX_CONFIG_IFCONFIG
+ help
+ Allow the start address for shared memory, start address for I/O,
+ and/or the interrupt line used by the specified device.
+
+config BUSYBOX_CONFIG_FEATURE_IFCONFIG_HW
+ bool "Enable option \"hw\" (ether only)"
+ default y
+ depends on BUSYBOX_CONFIG_IFCONFIG
+ help
+ Set the hardware address of this interface, if the device driver
+ supports this operation. Currently, we only support the 'ether'
+ class.
+
+config BUSYBOX_CONFIG_FEATURE_IFCONFIG_BROADCAST_PLUS
+ bool "Set the broadcast automatically"
+ default y
+ depends on BUSYBOX_CONFIG_IFCONFIG
+ help
+ Setting this will make ifconfig attempt to find the broadcast
+ automatically if the value '+' is used.
+
+config BUSYBOX_CONFIG_IFENSLAVE
+ bool "ifenslave"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Userspace application to bind several interfaces
+ to a logical interface (use with kernel bonding driver).
+
+config BUSYBOX_CONFIG_IFPLUGD
+ bool "ifplugd"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Network interface plug detection daemon.
+
+config BUSYBOX_CONFIG_IFUPDOWN
+ bool "ifupdown"
+ default n
+ help
+ Activate or deactivate the specified interfaces. This applet makes
+ use of either "ifconfig" and "route" or the "ip" command to actually
+ configure network interfaces. Therefore, you will probably also want
+ to enable either IFCONFIG and ROUTE, or enable
+ FEATURE_IFUPDOWN_IP and the various IP options. Of
+ course you could use non-busybox versions of these programs, so
+ against my better judgement (since this will surely result in plenty
+ of support questions on the mailing list), I do not force you to
+ enable these additional options. It is up to you to supply either
+ "ifconfig", "route" and "run-parts" or the "ip" command, either
+ via busybox or via standalone utilities.
+
+config BUSYBOX_CONFIG_IFUPDOWN_IFSTATE_PATH
+ string "Absolute path to ifstate file"
+ default n
+ depends on BUSYBOX_CONFIG_IFUPDOWN
+ help
+ ifupdown keeps state information in a file called ifstate.
+ Typically it is located in /var/run/ifstate, however
+ some distributions tend to put it in other places
+ (debian, for example, uses /etc/network/run/ifstate).
+ This config option defines location of ifstate.
+
+config BUSYBOX_CONFIG_FEATURE_IFUPDOWN_IP
+ bool "Use ip applet"
+ default n
+ depends on BUSYBOX_CONFIG_IFUPDOWN
+ help
+ Use the iproute "ip" command to implement "ifup" and "ifdown", rather
+ than the default of using the older 'ifconfig' and 'route' utilities.
+
+config BUSYBOX_CONFIG_FEATURE_IFUPDOWN_IP_BUILTIN
+ bool "Use busybox ip applet"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_IFUPDOWN_IP
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ select BUSYBOX_CONFIG_IP
+ select BUSYBOX_CONFIG_FEATURE_IP_ADDRESS
+ select BUSYBOX_CONFIG_FEATURE_IP_LINK
+ select BUSYBOX_CONFIG_FEATURE_IP_ROUTE
+ help
+ Use the busybox iproute "ip" applet to implement "ifupdown".
+
+ If left disabled, you must install the full-blown iproute2
+ utility or the "ifup" and "ifdown" applets will not work.
+
+config BUSYBOX_CONFIG_FEATURE_IFUPDOWN_IFCONFIG_BUILTIN
+ bool "Use busybox ifconfig and route applets"
+ default n
+ depends on BUSYBOX_CONFIG_IFUPDOWN && !BUSYBOX_CONFIG_FEATURE_IFUPDOWN_IP
+ select BUSYBOX_CONFIG_IFCONFIG
+ select BUSYBOX_CONFIG_ROUTE
+ help
+ Use the busybox iproute "ifconfig" and "route" applets to
+ implement the "ifup" and "ifdown" utilities.
+
+ If left disabled, you must install the full-blown ifconfig
+ and route utilities, or the "ifup" and "ifdown" applets will not
+ work.
+
+config BUSYBOX_CONFIG_FEATURE_IFUPDOWN_IPV4
+ bool "Support for IPv4"
+ default n
+ depends on BUSYBOX_CONFIG_IFUPDOWN
+ help
+ If you want ifup/ifdown to talk IPv4, leave this on.
+
+config BUSYBOX_CONFIG_FEATURE_IFUPDOWN_IPV6
+ bool "Support for IPv6"
+ default n
+ depends on BUSYBOX_CONFIG_IFUPDOWN && BUSYBOX_CONFIG_FEATURE_IPV6
+ help
+ If you need support for IPv6, turn this option on.
+
+### UNUSED
+###config FEATURE_IFUPDOWN_IPX
+### bool "Support for IPX"
+### default y
+### depends on IFUPDOWN
+### help
+### If this option is selected you can use busybox to work with IPX
+### networks.
+
+config BUSYBOX_CONFIG_FEATURE_IFUPDOWN_MAPPING
+ bool "Enable mapping support"
+ default n
+ depends on BUSYBOX_CONFIG_IFUPDOWN
+ help
+ This enables support for the "mapping" stanza, unless you have
+ a weird network setup you don't need it.
+
+config BUSYBOX_CONFIG_FEATURE_IFUPDOWN_EXTERNAL_DHCP
+ bool "Support for external dhcp clients"
+ default n
+ depends on BUSYBOX_CONFIG_IFUPDOWN
+ help
+ This enables support for the external dhcp clients. Clients are
+ tried in the following order: dhcpcd, dhclient, pump and udhcpc.
+ Otherwise, if udhcpc applet is enabled, it is used.
+ Otherwise, ifup/ifdown will have no support for DHCP.
+
+config BUSYBOX_CONFIG_INETD
+ bool "inetd"
+ default n
+ select BUSYBOX_CONFIG_FEATURE_SYSLOG
+ help
+ Internet superserver daemon
+
+config BUSYBOX_CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_ECHO
+ bool "Support echo service"
+ default n
+ depends on BUSYBOX_CONFIG_INETD
+ help
+ Echo received data internal inetd service
+
+config BUSYBOX_CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DISCARD
+ bool "Support discard service"
+ default n
+ depends on BUSYBOX_CONFIG_INETD
+ help
+ Internet /dev/null internal inetd service
+
+config BUSYBOX_CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_TIME
+ bool "Support time service"
+ default n
+ depends on BUSYBOX_CONFIG_INETD
+ help
+ Return 32 bit time since 1900 internal inetd service
+
+config BUSYBOX_CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DAYTIME
+ bool "Support daytime service"
+ default n
+ depends on BUSYBOX_CONFIG_INETD
+ help
+ Return human-readable time internal inetd service
+
+config BUSYBOX_CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_CHARGEN
+ bool "Support chargen service"
+ default n
+ depends on BUSYBOX_CONFIG_INETD
+ help
+ Familiar character generator internal inetd service
+
+config BUSYBOX_CONFIG_FEATURE_INETD_RPC
+ bool "Support RPC services"
+ default n
+ depends on BUSYBOX_CONFIG_INETD
+ select BUSYBOX_CONFIG_FEATURE_HAVE_RPC
+ help
+ Support Sun-RPC based services
+
+config BUSYBOX_CONFIG_IP
+ bool "ip"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ The "ip" applet is a TCP/IP interface configuration and routing
+ utility. You generally don't need "ip" to use busybox with
+ TCP/IP.
+
+config BUSYBOX_CONFIG_FEATURE_IP_ADDRESS
+ bool "ip address"
+ default n
+ depends on BUSYBOX_CONFIG_IP
+ help
+ Address manipulation support for the "ip" applet.
+
+config BUSYBOX_CONFIG_FEATURE_IP_LINK
+ bool "ip link"
+ default n
+ depends on BUSYBOX_CONFIG_IP
+ help
+ Configure network devices with "ip".
+
+config BUSYBOX_CONFIG_FEATURE_IP_ROUTE
+ bool "ip route"
+ default n
+ depends on BUSYBOX_CONFIG_IP
+ help
+ Add support for routing table management to "ip".
+
+config BUSYBOX_CONFIG_FEATURE_IP_TUNNEL
+ bool "ip tunnel"
+ default n
+ depends on BUSYBOX_CONFIG_IP
+ help
+ Add support for tunneling commands to "ip".
+
+config BUSYBOX_CONFIG_FEATURE_IP_RULE
+ bool "ip rule"
+ default n
+ depends on BUSYBOX_CONFIG_IP
+ help
+ Add support for rule commands to "ip".
+
+config BUSYBOX_CONFIG_FEATURE_IP_SHORT_FORMS
+ bool "Support short forms of ip commands"
+ default n
+ depends on BUSYBOX_CONFIG_IP
+ help
+ Also support short-form of ip <OBJECT> commands:
+ ip addr -> ipaddr
+ ip link -> iplink
+ ip route -> iproute
+ ip tunnel -> iptunnel
+ ip rule -> iprule
+
+ Say N unless you desparately need the short form of the ip
+ object commands.
+
+config BUSYBOX_CONFIG_FEATURE_IP_RARE_PROTOCOLS
+ bool "Support displaying rarely used link types"
+ default n
+ depends on BUSYBOX_CONFIG_IP
+ help
+ If you are not going to use links of type "frad", "econet",
+ "bif" etc, you probably don't need to enable this.
+ Ethernet, wireless, infrared, ppp/slip, ip tunnelling
+ link types are supported without this option selected.
+
+config BUSYBOX_CONFIG_IPADDR
+ bool
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_IP_SHORT_FORMS && BUSYBOX_CONFIG_FEATURE_IP_ADDRESS
+
+config BUSYBOX_CONFIG_IPLINK
+ bool
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_IP_SHORT_FORMS && BUSYBOX_CONFIG_FEATURE_IP_LINK
+
+config BUSYBOX_CONFIG_IPROUTE
+ bool
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_IP_SHORT_FORMS && BUSYBOX_CONFIG_FEATURE_IP_ROUTE
+
+config BUSYBOX_CONFIG_IPTUNNEL
+ bool
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_IP_SHORT_FORMS && BUSYBOX_CONFIG_FEATURE_IP_TUNNEL
+
+config BUSYBOX_CONFIG_IPRULE
+ bool
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_IP_SHORT_FORMS && BUSYBOX_CONFIG_FEATURE_IP_RULE
+
+config BUSYBOX_CONFIG_IPCALC
+ bool "ipcalc"
+ default n
+ help
+ ipcalc takes an IP address and netmask and calculates the
+ resulting broadcast, network, and host range.
+
+config BUSYBOX_CONFIG_FEATURE_IPCALC_FANCY
+ bool "Fancy IPCALC, more options, adds 1 kbyte"
+ default n
+ depends on BUSYBOX_CONFIG_IPCALC
+ help
+ Adds the options hostname, prefix and silent to the output of
+ "ipcalc".
+
+config BUSYBOX_CONFIG_FEATURE_IPCALC_LONG_OPTIONS
+ bool "Enable long options"
+ default n
+ depends on BUSYBOX_CONFIG_IPCALC && BUSYBOX_CONFIG_LONG_OPTS
+ help
+ Support long options for the ipcalc applet.
+
+config BUSYBOX_CONFIG_NETMSG
+ bool "netmsg"
+ default y
+ help
+ simple program for sending udp broadcast messages
+
+config BUSYBOX_CONFIG_NETSTAT
+ bool "netstat"
+ default y
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ netstat prints information about the Linux networking subsystem.
+
+config BUSYBOX_CONFIG_FEATURE_NETSTAT_WIDE
+ bool "Enable wide netstat output"
+ default y
+ depends on BUSYBOX_CONFIG_NETSTAT
+ help
+ Add support for wide columns. Useful when displaying IPv6 addresses
+ (-W option).
+
+config BUSYBOX_CONFIG_FEATURE_NETSTAT_PRG
+ bool "Enable PID/Program name output"
+ default y
+ depends on BUSYBOX_CONFIG_NETSTAT
+ help
+ Add support for -p flag to print out PID and program name.
+ +700 bytes of code.
+
+config BUSYBOX_CONFIG_NSLOOKUP
+ bool "nslookup"
+ default y
+ help
+ nslookup is a tool to query Internet name servers.
+
+config BUSYBOX_CONFIG_NTPD
+ bool "ntpd"
+ default y
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ The NTP client/server daemon.
+
+config BUSYBOX_CONFIG_FEATURE_NTPD_SERVER
+ bool "Make ntpd usable as a NTP server"
+ default y
+ depends on BUSYBOX_CONFIG_NTPD
+ help
+ Make ntpd usable as a NTP server. If you disable this option
+ ntpd will be usable only as a NTP client.
+
+config BUSYBOX_CONFIG_PSCAN
+ bool "pscan"
+ default n
+ help
+ Simple network port scanner.
+
+config BUSYBOX_CONFIG_ROUTE
+ bool "route"
+ default y
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Route displays or manipulates the kernel's IP routing tables.
+
+config BUSYBOX_CONFIG_SLATTACH
+ bool "slattach"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ slattach is a small utility to attach network interfaces to serial
+ lines.
+
+#config TC
+# bool "tc"
+# default y
+# help
+# show / manipulate traffic control settings
+#
+#config FEATURE_TC_INGRESS
+# def_bool n
+# depends on TC
+
+config BUSYBOX_CONFIG_TCPSVD
+ bool "tcpsvd"
+ default n
+ help
+ tcpsvd listens on a TCP port and runs a program for each new
+ connection.
+
+config BUSYBOX_CONFIG_TELNET
+ bool "telnet"
+ default y
+ help
+ Telnet is an interface to the TELNET protocol, but is also commonly
+ used to test other simple protocols.
+
+config BUSYBOX_CONFIG_FEATURE_TELNET_TTYPE
+ bool "Pass TERM type to remote host"
+ default y
+ depends on BUSYBOX_CONFIG_TELNET
+ help
+ Setting this option will forward the TERM environment variable to the
+ remote host you are connecting to. This is useful to make sure that
+ things like ANSI colors and other control sequences behave.
+
+config BUSYBOX_CONFIG_FEATURE_TELNET_AUTOLOGIN
+ bool "Pass USER type to remote host"
+ default n
+ depends on BUSYBOX_CONFIG_TELNET
+ help
+ Setting this option will forward the USER environment variable to the
+ remote host you are connecting to. This is useful when you need to
+ log into a machine without telling the username (autologin). This
+ option enables `-a' and `-l USER' arguments.
+
+config BUSYBOX_CONFIG_TELNETD
+ bool "telnetd"
+ default y
+ select BUSYBOX_CONFIG_FEATURE_SYSLOG
+ help
+ A daemon for the TELNET protocol, allowing you to log onto the host
+ running the daemon. Please keep in mind that the TELNET protocol
+ sends passwords in plain text. If you can't afford the space for an
+ SSH daemon and you trust your network, you may say 'y' here. As a
+ more secure alternative, you should seriously consider installing the
+ very small Dropbear SSH daemon instead:
+ http://matt.ucc.asn.au/dropbear/dropbear.html
+
+ Note that for busybox telnetd to work you need several things:
+ First of all, your kernel needs:
+ UNIX98_PTYS=y
+ DEVPTS_FS=y
+
+ Next, you need a /dev/pts directory on your root filesystem:
+
+ $ ls -ld /dev/pts
+ drwxr-xr-x 2 root root 0 Sep 23 13:21 /dev/pts/
+
+ Next you need the pseudo terminal master multiplexer /dev/ptmx:
+
+ $ ls -la /dev/ptmx
+ crw-rw-rw- 1 root tty 5, 2 Sep 23 13:55 /dev/ptmx
+
+ Any /dev/ttyp[0-9]* files you may have can be removed.
+ Next, you need to mount the devpts filesystem on /dev/pts using:
+
+ mount -t devpts devpts /dev/pts
+
+ You need to be sure that busybox has LOGIN and
+ FEATURE_SUID enabled. And finally, you should make
+ certain that Busybox has been installed setuid root:
+
+ chown root.root /bin/busybox
+ chmod 4755 /bin/busybox
+
+ with all that done, telnetd _should_ work....
+
+
+config BUSYBOX_CONFIG_FEATURE_TELNETD_STANDALONE
+ bool "Support standalone telnetd (not inetd only)"
+ default y
+ depends on BUSYBOX_CONFIG_TELNETD
+ help
+ Selecting this will make telnetd able to run standalone.
+
+config BUSYBOX_CONFIG_FEATURE_TELNETD_INETD_WAIT
+ bool "Support -w SEC option (inetd wait mode)"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_TELNETD_STANDALONE
+ help
+ This option allows you to run telnetd in "inet wait" mode.
+ Example inetd.conf line (note "wait", not usual "nowait"):
+
+ telnet stream tcp wait root /bin/telnetd telnetd -w10
+
+ In this example, inetd passes _listening_ socket_ as fd 0
+ to telnetd when connection appears.
+ telnetd will wait for connections until all existing
+ connections are closed, and no new connections
+ appear during 10 seconds. Then it exits, and inetd continues
+ to listen for new connections.
+
+ This option is rarely used. "tcp nowait" is much more usual
+ way of running tcp services, including telnetd.
+ You most probably want to say N here.
+
+config BUSYBOX_CONFIG_TFTP
+ bool "tftp"
+ default n
+ help
+ This enables the Trivial File Transfer Protocol client program. TFTP
+ is usually used for simple, small transfers such as a root image
+ for a network-enabled bootloader.
+
+config BUSYBOX_CONFIG_TFTPD
+ bool "tftpd"
+ default n
+ help
+ This enables the Trivial File Transfer Protocol server program.
+ It expects that stdin is a datagram socket and a packet
+ is already pending on it. It will exit after one transfer.
+ In other words: it should be run from inetd in nowait mode,
+ or from udpsvd. Example: "udpsvd -E 0 69 tftpd DIR"
+
+comment "Common options for tftp/tftpd"
+ depends on BUSYBOX_CONFIG_TFTP || BUSYBOX_CONFIG_TFTPD
+
+config BUSYBOX_CONFIG_FEATURE_TFTP_GET
+ bool "Enable 'tftp get' and/or tftpd upload code"
+ default n
+ depends on BUSYBOX_CONFIG_TFTP || BUSYBOX_CONFIG_TFTPD
+ help
+ Add support for the GET command within the TFTP client. This allows
+ a client to retrieve a file from a TFTP server.
+ Also enable upload support in tftpd, if tftpd is selected.
+
+ Note: this option does _not_ make tftpd capable of download
+ (the usual operation people need from it)!
+
+config BUSYBOX_CONFIG_FEATURE_TFTP_PUT
+ bool "Enable 'tftp put' and/or tftpd download code"
+ default n
+ depends on BUSYBOX_CONFIG_TFTP || BUSYBOX_CONFIG_TFTPD
+ help
+ Add support for the PUT command within the TFTP client. This allows
+ a client to transfer a file to a TFTP server.
+ Also enable download support in tftpd, if tftpd is selected.
+
+config BUSYBOX_CONFIG_FEATURE_TFTP_BLOCKSIZE
+ bool "Enable 'blksize' and 'tsize' protocol options"
+ default n
+ depends on BUSYBOX_CONFIG_TFTP || BUSYBOX_CONFIG_TFTPD
+ help
+ Allow tftp to specify block size, and tftpd to understand
+ "blksize" and "tsize" options.
+
+config BUSYBOX_CONFIG_FEATURE_TFTP_PROGRESS_BAR
+ bool "Enable tftp progress meter"
+ default n
+ depends on BUSYBOX_CONFIG_TFTP && BUSYBOX_CONFIG_FEATURE_TFTP_BLOCKSIZE
+ help
+ Show progress bar.
+
+config BUSYBOX_CONFIG_TFTP_DEBUG
+ bool "Enable debug"
+ default n
+ depends on BUSYBOX_CONFIG_TFTP || BUSYBOX_CONFIG_TFTPD
+ help
+ Make tftp[d] print debugging messages on stderr.
+ This is useful if you are diagnosing a bug in tftp[d].
+
+config BUSYBOX_CONFIG_TRACEROUTE
+ bool "traceroute"
+ default y
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Utility to trace the route of IP packets.
+
+config BUSYBOX_CONFIG_TRACEROUTE6
+ bool "traceroute6"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_IPV6 && BUSYBOX_CONFIG_TRACEROUTE
+ help
+ Utility to trace the route of IPv6 packets.
+
+config BUSYBOX_CONFIG_FEATURE_TRACEROUTE_VERBOSE
+ bool "Enable verbose output"
+ default y
+ depends on BUSYBOX_CONFIG_TRACEROUTE
+ help
+ Add some verbosity to traceroute. This includes among other things
+ hostnames and ICMP response types.
+
+config BUSYBOX_CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE
+ bool "Enable loose source route"
+ default n
+ depends on BUSYBOX_CONFIG_TRACEROUTE
+ help
+ Add option to specify a loose source route gateway
+ (8 maximum).
+
+config BUSYBOX_CONFIG_FEATURE_TRACEROUTE_USE_ICMP
+ bool "Use ICMP instead of UDP"
+ default n
+ depends on BUSYBOX_CONFIG_TRACEROUTE
+ help
+ Add option -I to use ICMP ECHO instead of UDP datagrams.
+
+config BUSYBOX_CONFIG_TUNCTL
+ bool "tunctl"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ tunctl creates or deletes tun devices.
+
+config BUSYBOX_CONFIG_FEATURE_TUNCTL_UG
+ bool "Support owner:group assignment"
+ default n
+ depends on BUSYBOX_CONFIG_TUNCTL
+ help
+ Allow to specify owner and group of newly created interface.
+ 340 bytes of pure bloat. Say no here.
+
+source package/busybox/config/networking/udhcp/Config.in
+
+config BUSYBOX_CONFIG_IFUPDOWN_UDHCPC_CMD_OPTIONS
+ string "ifup udhcpc command line options"
+ default "-R -n"
+ depends on BUSYBOX_CONFIG_IFUPDOWN && BUSYBOX_CONFIG_UDHCPC
+ help
+ Command line options to pass to udhcpc from ifup.
+ Intended to alter options not available in /etc/network/interfaces.
+ (IE: --syslog --background etc...)
+
+config BUSYBOX_CONFIG_UDPSVD
+ bool "udpsvd"
+ default n
+ help
+ udpsvd listens on an UDP port and runs a program for each new
+ connection.
+
+config BUSYBOX_CONFIG_VCONFIG
+ bool "vconfig"
+ default y
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Creates, removes, and configures VLAN interfaces
+
+config BUSYBOX_CONFIG_WGET
+ bool "wget"
+ default y
+ help
+ wget is a utility for non-interactive download of files from HTTP,
+ HTTPS, and FTP servers.
+
+config BUSYBOX_CONFIG_FEATURE_WGET_STATUSBAR
+ bool "Enable a nifty process meter (+2k)"
+ default y
+ depends on BUSYBOX_CONFIG_WGET
+ help
+ Enable the transfer progress bar for wget transfers.
+
+config BUSYBOX_CONFIG_FEATURE_WGET_AUTHENTICATION
+ bool "Enable HTTP authentication"
+ default y
+ depends on BUSYBOX_CONFIG_WGET
+ help
+ Support authenticated HTTP transfers.
+
+config BUSYBOX_CONFIG_FEATURE_WGET_LONG_OPTIONS
+ bool "Enable long options"
+ default y
+ depends on BUSYBOX_CONFIG_WGET && BUSYBOX_CONFIG_LONG_OPTS
+ help
+ Support long options for the wget applet.
+
+config BUSYBOX_CONFIG_FEATURE_WGET_TIMEOUT
+ bool "Enable read timeout option -T SEC"
+ default n
+ depends on BUSYBOX_CONFIG_WGET
+ help
+ Supports network read timeout for wget, so that wget will give
+ up and timeout when reading network data, through the -T command
+ line option. Currently only network data read timeout is
+ supported (i.e., timeout is not applied to the DNS nor TCP
+ connection initialization). When FEATURE_WGET_LONG_OPTIONS is
+ also enabled, the --timeout option will work in addition to -T.
+
+config BUSYBOX_CONFIG_ZCIP
+ bool "zcip"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ select BUSYBOX_CONFIG_FEATURE_SYSLOG
+ help
+ ZCIP provides ZeroConf IPv4 address selection, according to RFC 3927.
+ It's a daemon that allocates and defends a dynamically assigned
+ address on the 169.254/16 network, requiring no system administrator.
+
+ See http://www.zeroconf.org for further details, and "zcip.script"
+ in the busybox examples.
+
+endmenu
diff --git a/package/busybox/config/networking/Config.in b/package/busybox/config/networking/Config.in
new file mode 100644
index 0000000..3df7b1f
--- /dev/null
+++ b/package/busybox/config/networking/Config.in
@@ -0,0 +1,1088 @@
+# DO NOT EDIT. This file is generated from Config.src
+#
+# For a description of the syntax of this configuration file,
+# see scripts/kbuild/config-language.txt.
+#
+
+menu "Networking Utilities"
+
+config BUSYBOX_CONFIG_NAMEIF
+ bool "nameif"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ select BUSYBOX_CONFIG_FEATURE_SYSLOG
+ help
+ nameif is used to rename network interface by its MAC address.
+ Renamed interfaces MUST be in the down state.
+ It is possible to use a file (default: /etc/mactab)
+ with list of new interface names and MACs.
+ Maximum interface name length: IFNAMSIZ = 16
+ File fields are separated by space or tab.
+ File format:
+ # Comment
+ new_interface_name XX:XX:XX:XX:XX:XX
+
+config BUSYBOX_CONFIG_FEATURE_NAMEIF_EXTENDED
+ bool "Extended nameif"
+ default n
+ depends on BUSYBOX_CONFIG_NAMEIF
+ help
+ This extends the nameif syntax to support the bus_info, driver,
+ phyaddr selectors. The syntax is compatible to the normal nameif.
+ File format:
+ new_interface_name driver=asix bus=usb-0000:00:08.2-3
+ new_interface_name bus=usb-0000:00:08.2-3 00:80:C8:38:91:B5
+ new_interface_name phy_address=2 00:80:C8:38:91:B5
+ new_interface_name mac=00:80:C8:38:91:B5
+ new_interface_name 00:80:C8:38:91:B5
+config BUSYBOX_CONFIG_NBDCLIENT
+ bool "nbd-client"
+ default n
+ help
+ Network block device client
+config BUSYBOX_CONFIG_NC
+ bool "nc"
+ default y
+ help
+ A simple Unix utility which reads and writes data across network
+ connections.
+
+config BUSYBOX_CONFIG_NC_SERVER
+ bool "Netcat server options (-l)"
+ default n
+ depends on BUSYBOX_CONFIG_NC
+ help
+ Allow netcat to act as a server.
+
+config BUSYBOX_CONFIG_NC_EXTRA
+ bool "Netcat extensions (-eiw and filename)"
+ default n
+ depends on BUSYBOX_CONFIG_NC
+ help
+ Add -e (support for executing the rest of the command line after
+ making or receiving a successful connection), -i (delay interval for
+ lines sent), -w (timeout for initial connection).
+
+config BUSYBOX_CONFIG_NC_110_COMPAT
+ bool "Netcat 1.10 compatibility (+2.5k)"
+ default n # off specially for Rob
+ depends on BUSYBOX_CONFIG_NC
+ help
+ This option makes nc closely follow original nc-1.10.
+ The code is about 2.5k bigger. It enables
+ -s ADDR, -n, -u, -v, -o FILE, -z options, but loses
+ busybox-specific extensions: -f FILE and -ll.
+config BUSYBOX_CONFIG_PING
+ bool "ping"
+ default y
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ ping uses the ICMP protocol's mandatory ECHO_REQUEST datagram to
+ elicit an ICMP ECHO_RESPONSE from a host or gateway.
+
+config BUSYBOX_CONFIG_PING6
+ bool "ping6"
+ default y
+ depends on BUSYBOX_CONFIG_FEATURE_IPV6 && BUSYBOX_CONFIG_PING
+ help
+ This will give you a ping that can talk IPv6.
+
+config BUSYBOX_CONFIG_FEATURE_FANCY_PING
+ bool "Enable fancy ping output"
+ default y
+ depends on BUSYBOX_CONFIG_PING
+ help
+ Make the output from the ping applet include statistics, and at the
+ same time provide full support for ICMP packets.
+config BUSYBOX_CONFIG_WHOIS
+ bool "whois"
+ default n
+ help
+ whois is a client for the whois directory service
+
+config BUSYBOX_CONFIG_FEATURE_IPV6
+ bool "Enable IPv6 support"
+ default IPV6
+ help
+ Enable IPv6 support in busybox.
+ This adds IPv6 support in the networking applets.
+
+config BUSYBOX_CONFIG_FEATURE_UNIX_LOCAL
+ bool "Enable Unix domain socket support (usually not needed)"
+ default n
+ help
+ Enable Unix domain socket support in all busybox networking
+ applets. Address of the form local:/path/to/unix/socket
+ will be recognized.
+
+ This extension is almost never used in real world usage.
+ You most likely want to say N.
+
+config BUSYBOX_CONFIG_FEATURE_PREFER_IPV4_ADDRESS
+ bool "Prefer IPv4 addresses from DNS queries"
+ default y
+ depends on BUSYBOX_CONFIG_FEATURE_IPV6
+ help
+ Use IPv4 address of network host if it has one.
+
+ If this option is off, the first returned address will be used.
+ This may cause problems when your DNS server is IPv6-capable and
+ is returning IPv6 host addresses too. If IPv6 address
+ precedes IPv4 one in DNS reply, busybox network applets
+ (e.g. wget) will use IPv6 address. On an IPv6-incapable host
+ or network applets will fail to connect to the host
+ using IPv6 address.
+
+config BUSYBOX_CONFIG_VERBOSE_RESOLUTION_ERRORS
+ bool "Verbose resolution errors"
+ default y
+ help
+ Enable if you are not satisfied with simplistic
+ "can't resolve 'hostname.com'" and want to know more.
+ This may increase size of your executable a bit.
+
+config BUSYBOX_CONFIG_ARP
+ bool "arp"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Manipulate the system ARP cache.
+
+config BUSYBOX_CONFIG_ARPING
+ bool "arping"
+ default y
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Ping hosts by ARP packets.
+
+config BUSYBOX_CONFIG_BRCTL
+ bool "brctl"
+ default y
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Manage ethernet bridges.
+ Supports addbr/delbr and addif/delif.
+
+config BUSYBOX_CONFIG_FEATURE_BRCTL_FANCY
+ bool "Fancy options"
+ default y
+ depends on BUSYBOX_CONFIG_BRCTL
+ help
+ Add support for extended option like:
+ setageing, setfd, sethello, setmaxage,
+ setpathcost, setportprio, setbridgeprio,
+ stp
+ This adds about 600 bytes.
+
+config BUSYBOX_CONFIG_FEATURE_BRCTL_SHOW
+ bool "Support show"
+ default y
+ depends on BUSYBOX_CONFIG_BRCTL && BUSYBOX_CONFIG_FEATURE_BRCTL_FANCY
+ help
+ Add support for option which prints the current config:
+ show
+
+config BUSYBOX_CONFIG_DNSD
+ bool "dnsd"
+ default n
+ help
+ Small and static DNS server daemon.
+
+config BUSYBOX_CONFIG_ETHER_WAKE
+ bool "ether-wake"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Send a magic packet to wake up sleeping machines.
+
+config BUSYBOX_CONFIG_FAKEIDENTD
+ bool "fakeidentd"
+ default n
+ select BUSYBOX_CONFIG_FEATURE_SYSLOG
+ help
+ fakeidentd listens on the ident port and returns a predefined
+ fake value on any query.
+
+config BUSYBOX_CONFIG_FTPD
+ bool "ftpd"
+ default n
+ help
+ simple FTP daemon. You have to run it via inetd.
+
+config BUSYBOX_CONFIG_FEATURE_FTP_WRITE
+ bool "Enable upload commands"
+ default n
+ depends on BUSYBOX_CONFIG_FTPD
+ help
+ Enable all kinds of FTP upload commands (-w option)
+
+config BUSYBOX_CONFIG_FEATURE_FTPD_ACCEPT_BROKEN_LIST
+ bool "Enable workaround for RFC-violating clients"
+ default n
+ depends on BUSYBOX_CONFIG_FTPD
+ help
+ Some ftp clients (among them KDE's Konqueror) issue illegal
+ "LIST -l" requests. This option works around such problems.
+ It might prevent you from listing files starting with "-" and
+ it increases the code size by ~40 bytes.
+ Most other ftp servers seem to behave similar to this.
+
+config BUSYBOX_CONFIG_FTPGET
+ bool "ftpget"
+ default n
+ help
+ Retrieve a remote file via FTP.
+
+config BUSYBOX_CONFIG_FTPPUT
+ bool "ftpput"
+ default n
+ help
+ Store a remote file via FTP.
+
+config BUSYBOX_CONFIG_FEATURE_FTPGETPUT_LONG_OPTIONS
+ bool "Enable long options in ftpget/ftpput"
+ default n
+ depends on BUSYBOX_CONFIG_LONG_OPTS && (BUSYBOX_CONFIG_FTPGET || BUSYBOX_CONFIG_FTPPUT)
+ help
+ Support long options for the ftpget/ftpput applet.
+
+config BUSYBOX_CONFIG_HOSTNAME
+ bool "hostname"
+ default n
+ help
+ Show or set the system's host name.
+
+config BUSYBOX_CONFIG_HTTPD
+ bool "httpd"
+ default n
+ help
+ Serve web pages via an HTTP server.
+
+config BUSYBOX_CONFIG_FEATURE_HTTPD_RANGES
+ bool "Support 'Ranges:' header"
+ default n
+ depends on BUSYBOX_CONFIG_HTTPD
+ help
+ Makes httpd emit "Accept-Ranges: bytes" header and understand
+ "Range: bytes=NNN-[MMM]" header. Allows for resuming interrupted
+ downloads, seeking in multimedia players etc.
+
+config BUSYBOX_CONFIG_FEATURE_HTTPD_USE_SENDFILE
+ bool "Use sendfile system call"
+ default n
+ depends on BUSYBOX_CONFIG_HTTPD
+ help
+ When enabled, httpd will use the kernel sendfile() function
+ instead of read/write loop.
+
+config BUSYBOX_CONFIG_FEATURE_HTTPD_SETUID
+ bool "Enable -u <user> option"
+ default n
+ depends on BUSYBOX_CONFIG_HTTPD
+ help
+ This option allows the server to run as a specific user
+ rather than defaulting to the user that starts the server.
+ Use of this option requires special privileges to change to a
+ different user.
+
+config BUSYBOX_CONFIG_FEATURE_HTTPD_BASIC_AUTH
+ bool "Enable Basic http Authentication"
+ default n
+ depends on BUSYBOX_CONFIG_HTTPD
+ help
+ Utilizes password settings from /etc/httpd.conf for basic
+ authentication on a per url basis.
+
+config BUSYBOX_CONFIG_FEATURE_HTTPD_AUTH_MD5
+ bool "Support MD5 crypted passwords for http Authentication"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_HTTPD_BASIC_AUTH
+ help
+ Enables basic per URL authentication from /etc/httpd.conf
+ using md5 passwords.
+
+config BUSYBOX_CONFIG_FEATURE_HTTPD_CGI
+ bool "Support Common Gateway Interface (CGI)"
+ default n
+ depends on BUSYBOX_CONFIG_HTTPD
+ help
+ This option allows scripts and executables to be invoked
+ when specific URLs are requested.
+
+config BUSYBOX_CONFIG_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR
+ bool "Support for running scripts through an interpreter"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_HTTPD_CGI
+ help
+ This option enables support for running scripts through an
+ interpreter. Turn this on if you want PHP scripts to work
+ properly. You need to supply an additional line in your httpd
+ config file:
+ *.php:/path/to/your/php
+
+config BUSYBOX_CONFIG_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV
+ bool "Set REMOTE_PORT environment variable for CGI"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_HTTPD_CGI
+ help
+ Use of this option can assist scripts in generating
+ references that contain a unique port number.
+
+config BUSYBOX_CONFIG_FEATURE_HTTPD_ENCODE_URL_STR
+ bool "Enable -e option (useful for CGIs written as shell scripts)"
+ default n
+ depends on BUSYBOX_CONFIG_HTTPD
+ help
+ This option allows html encoding of arbitrary strings for display
+ by the browser. Output goes to stdout.
+ For example, httpd -e "<Hello World>" produces
+ "&#60Hello&#32World&#62".
+
+config BUSYBOX_CONFIG_FEATURE_HTTPD_ERROR_PAGES
+ bool "Support for custom error pages"
+ default n
+ depends on BUSYBOX_CONFIG_HTTPD
+ help
+ This option allows you to define custom error pages in
+ the configuration file instead of the default HTTP status
+ error pages. For instance, if you add the line:
+ E404:/path/e404.html
+ in the config file, the server will respond the specified
+ '/path/e404.html' file instead of the terse '404 NOT FOUND'
+ message.
+
+config BUSYBOX_CONFIG_FEATURE_HTTPD_PROXY
+ bool "Support for reverse proxy"
+ default n
+ depends on BUSYBOX_CONFIG_HTTPD
+ help
+ This option allows you to define URLs that will be forwarded
+ to another HTTP server. To setup add the following line to the
+ configuration file
+ P:/url/:http://hostname[:port]/new/path/
+ Then a request to /url/myfile will be forwarded to
+ http://hostname[:port]/new/path/myfile.
+
+config BUSYBOX_CONFIG_FEATURE_HTTPD_GZIP
+ bool "Support for GZIP content encoding"
+ default n
+ depends on BUSYBOX_CONFIG_HTTPD
+ help
+ Makes httpd send files using GZIP content encoding if the
+ client supports it and a pre-compressed <file>.gz exists.
+
+config BUSYBOX_CONFIG_IFCONFIG
+ bool "ifconfig"
+ default y
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Ifconfig is used to configure the kernel-resident network interfaces.
+
+config BUSYBOX_CONFIG_FEATURE_IFCONFIG_STATUS
+ bool "Enable status reporting output (+7k)"
+ default y
+ depends on BUSYBOX_CONFIG_IFCONFIG
+ help
+ If ifconfig is called with no arguments it will display the status
+ of the currently active interfaces.
+
+config BUSYBOX_CONFIG_FEATURE_IFCONFIG_SLIP
+ bool "Enable slip-specific options \"keepalive\" and \"outfill\""
+ default n
+ depends on BUSYBOX_CONFIG_IFCONFIG
+ help
+ Allow "keepalive" and "outfill" support for SLIP. If you're not
+ planning on using serial lines, leave this unchecked.
+
+config BUSYBOX_CONFIG_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ
+ bool "Enable options \"mem_start\", \"io_addr\", and \"irq\""
+ default n
+ depends on BUSYBOX_CONFIG_IFCONFIG
+ help
+ Allow the start address for shared memory, start address for I/O,
+ and/or the interrupt line used by the specified device.
+
+config BUSYBOX_CONFIG_FEATURE_IFCONFIG_HW
+ bool "Enable option \"hw\" (ether only)"
+ default y
+ depends on BUSYBOX_CONFIG_IFCONFIG
+ help
+ Set the hardware address of this interface, if the device driver
+ supports this operation. Currently, we only support the 'ether'
+ class.
+
+config BUSYBOX_CONFIG_FEATURE_IFCONFIG_BROADCAST_PLUS
+ bool "Set the broadcast automatically"
+ default y
+ depends on BUSYBOX_CONFIG_IFCONFIG
+ help
+ Setting this will make ifconfig attempt to find the broadcast
+ automatically if the value '+' is used.
+
+config BUSYBOX_CONFIG_IFENSLAVE
+ bool "ifenslave"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Userspace application to bind several interfaces
+ to a logical interface (use with kernel bonding driver).
+
+config BUSYBOX_CONFIG_IFPLUGD
+ bool "ifplugd"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Network interface plug detection daemon.
+
+config BUSYBOX_CONFIG_IFUPDOWN
+ bool "ifupdown"
+ default n
+ help
+ Activate or deactivate the specified interfaces. This applet makes
+ use of either "ifconfig" and "route" or the "ip" command to actually
+ configure network interfaces. Therefore, you will probably also want
+ to enable either IFCONFIG and ROUTE, or enable
+ FEATURE_IFUPDOWN_IP and the various IP options. Of
+ course you could use non-busybox versions of these programs, so
+ against my better judgement (since this will surely result in plenty
+ of support questions on the mailing list), I do not force you to
+ enable these additional options. It is up to you to supply either
+ "ifconfig", "route" and "run-parts" or the "ip" command, either
+ via busybox or via standalone utilities.
+
+config BUSYBOX_CONFIG_IFUPDOWN_IFSTATE_PATH
+ string "Absolute path to ifstate file"
+ default n
+ depends on BUSYBOX_CONFIG_IFUPDOWN
+ help
+ ifupdown keeps state information in a file called ifstate.
+ Typically it is located in /var/run/ifstate, however
+ some distributions tend to put it in other places
+ (debian, for example, uses /etc/network/run/ifstate).
+ This config option defines location of ifstate.
+
+config BUSYBOX_CONFIG_FEATURE_IFUPDOWN_IP
+ bool "Use ip applet"
+ default n
+ depends on BUSYBOX_CONFIG_IFUPDOWN
+ help
+ Use the iproute "ip" command to implement "ifup" and "ifdown", rather
+ than the default of using the older 'ifconfig' and 'route' utilities.
+
+config BUSYBOX_CONFIG_FEATURE_IFUPDOWN_IP_BUILTIN
+ bool "Use busybox ip applet"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_IFUPDOWN_IP
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ select BUSYBOX_CONFIG_IP
+ select BUSYBOX_CONFIG_FEATURE_IP_ADDRESS
+ select BUSYBOX_CONFIG_FEATURE_IP_LINK
+ select BUSYBOX_CONFIG_FEATURE_IP_ROUTE
+ help
+ Use the busybox iproute "ip" applet to implement "ifupdown".
+
+ If left disabled, you must install the full-blown iproute2
+ utility or the "ifup" and "ifdown" applets will not work.
+
+config BUSYBOX_CONFIG_FEATURE_IFUPDOWN_IFCONFIG_BUILTIN
+ bool "Use busybox ifconfig and route applets"
+ default n
+ depends on BUSYBOX_CONFIG_IFUPDOWN && !BUSYBOX_CONFIG_FEATURE_IFUPDOWN_IP
+ select BUSYBOX_CONFIG_IFCONFIG
+ select BUSYBOX_CONFIG_ROUTE
+ help
+ Use the busybox iproute "ifconfig" and "route" applets to
+ implement the "ifup" and "ifdown" utilities.
+
+ If left disabled, you must install the full-blown ifconfig
+ and route utilities, or the "ifup" and "ifdown" applets will not
+ work.
+
+config BUSYBOX_CONFIG_FEATURE_IFUPDOWN_IPV4
+ bool "Support for IPv4"
+ default n
+ depends on BUSYBOX_CONFIG_IFUPDOWN
+ help
+ If you want ifup/ifdown to talk IPv4, leave this on.
+
+config BUSYBOX_CONFIG_FEATURE_IFUPDOWN_IPV6
+ bool "Support for IPv6"
+ default n
+ depends on BUSYBOX_CONFIG_IFUPDOWN && BUSYBOX_CONFIG_FEATURE_IPV6
+ help
+ If you need support for IPv6, turn this option on.
+
+### UNUSED
+###config FEATURE_IFUPDOWN_IPX
+### bool "Support for IPX"
+### default y
+### depends on IFUPDOWN
+### help
+### If this option is selected you can use busybox to work with IPX
+### networks.
+
+config BUSYBOX_CONFIG_FEATURE_IFUPDOWN_MAPPING
+ bool "Enable mapping support"
+ default n
+ depends on BUSYBOX_CONFIG_IFUPDOWN
+ help
+ This enables support for the "mapping" stanza, unless you have
+ a weird network setup you don't need it.
+
+config BUSYBOX_CONFIG_FEATURE_IFUPDOWN_EXTERNAL_DHCP
+ bool "Support for external dhcp clients"
+ default n
+ depends on BUSYBOX_CONFIG_IFUPDOWN
+ help
+ This enables support for the external dhcp clients. Clients are
+ tried in the following order: dhcpcd, dhclient, pump and udhcpc.
+ Otherwise, if udhcpc applet is enabled, it is used.
+ Otherwise, ifup/ifdown will have no support for DHCP.
+
+config BUSYBOX_CONFIG_INETD
+ bool "inetd"
+ default n
+ select BUSYBOX_CONFIG_FEATURE_SYSLOG
+ help
+ Internet superserver daemon
+
+config BUSYBOX_CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_ECHO
+ bool "Support echo service"
+ default n
+ depends on BUSYBOX_CONFIG_INETD
+ help
+ Echo received data internal inetd service
+
+config BUSYBOX_CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DISCARD
+ bool "Support discard service"
+ default n
+ depends on BUSYBOX_CONFIG_INETD
+ help
+ Internet /dev/null internal inetd service
+
+config BUSYBOX_CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_TIME
+ bool "Support time service"
+ default n
+ depends on BUSYBOX_CONFIG_INETD
+ help
+ Return 32 bit time since 1900 internal inetd service
+
+config BUSYBOX_CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DAYTIME
+ bool "Support daytime service"
+ default n
+ depends on BUSYBOX_CONFIG_INETD
+ help
+ Return human-readable time internal inetd service
+
+config BUSYBOX_CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_CHARGEN
+ bool "Support chargen service"
+ default n
+ depends on BUSYBOX_CONFIG_INETD
+ help
+ Familiar character generator internal inetd service
+
+config BUSYBOX_CONFIG_FEATURE_INETD_RPC
+ bool "Support RPC services"
+ default n
+ depends on BUSYBOX_CONFIG_INETD
+ select BUSYBOX_CONFIG_FEATURE_HAVE_RPC
+ help
+ Support Sun-RPC based services
+
+config BUSYBOX_CONFIG_IP
+ bool "ip"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ The "ip" applet is a TCP/IP interface configuration and routing
+ utility. You generally don't need "ip" to use busybox with
+ TCP/IP.
+
+config BUSYBOX_CONFIG_FEATURE_IP_ADDRESS
+ bool "ip address"
+ default n
+ depends on BUSYBOX_CONFIG_IP
+ help
+ Address manipulation support for the "ip" applet.
+
+config BUSYBOX_CONFIG_FEATURE_IP_LINK
+ bool "ip link"
+ default n
+ depends on BUSYBOX_CONFIG_IP
+ help
+ Configure network devices with "ip".
+
+config BUSYBOX_CONFIG_FEATURE_IP_ROUTE
+ bool "ip route"
+ default n
+ depends on BUSYBOX_CONFIG_IP
+ help
+ Add support for routing table management to "ip".
+
+config BUSYBOX_CONFIG_FEATURE_IP_TUNNEL
+ bool "ip tunnel"
+ default n
+ depends on BUSYBOX_CONFIG_IP
+ help
+ Add support for tunneling commands to "ip".
+
+config BUSYBOX_CONFIG_FEATURE_IP_RULE
+ bool "ip rule"
+ default n
+ depends on BUSYBOX_CONFIG_IP
+ help
+ Add support for rule commands to "ip".
+
+config BUSYBOX_CONFIG_FEATURE_IP_SHORT_FORMS
+ bool "Support short forms of ip commands"
+ default n
+ depends on BUSYBOX_CONFIG_IP
+ help
+ Also support short-form of ip <OBJECT> commands:
+ ip addr -> ipaddr
+ ip link -> iplink
+ ip route -> iproute
+ ip tunnel -> iptunnel
+ ip rule -> iprule
+
+ Say N unless you desparately need the short form of the ip
+ object commands.
+
+config BUSYBOX_CONFIG_FEATURE_IP_RARE_PROTOCOLS
+ bool "Support displaying rarely used link types"
+ default n
+ depends on BUSYBOX_CONFIG_IP
+ help
+ If you are not going to use links of type "frad", "econet",
+ "bif" etc, you probably don't need to enable this.
+ Ethernet, wireless, infrared, ppp/slip, ip tunnelling
+ link types are supported without this option selected.
+
+config BUSYBOX_CONFIG_IPADDR
+ bool
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_IP_SHORT_FORMS && BUSYBOX_CONFIG_FEATURE_IP_ADDRESS
+
+config BUSYBOX_CONFIG_IPLINK
+ bool
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_IP_SHORT_FORMS && BUSYBOX_CONFIG_FEATURE_IP_LINK
+
+config BUSYBOX_CONFIG_IPROUTE
+ bool
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_IP_SHORT_FORMS && BUSYBOX_CONFIG_FEATURE_IP_ROUTE
+
+config BUSYBOX_CONFIG_IPTUNNEL
+ bool
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_IP_SHORT_FORMS && BUSYBOX_CONFIG_FEATURE_IP_TUNNEL
+
+config BUSYBOX_CONFIG_IPRULE
+ bool
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_IP_SHORT_FORMS && BUSYBOX_CONFIG_FEATURE_IP_RULE
+
+config BUSYBOX_CONFIG_IPCALC
+ bool "ipcalc"
+ default n
+ help
+ ipcalc takes an IP address and netmask and calculates the
+ resulting broadcast, network, and host range.
+
+config BUSYBOX_CONFIG_FEATURE_IPCALC_FANCY
+ bool "Fancy IPCALC, more options, adds 1 kbyte"
+ default n
+ depends on BUSYBOX_CONFIG_IPCALC
+ help
+ Adds the options hostname, prefix and silent to the output of
+ "ipcalc".
+
+config BUSYBOX_CONFIG_FEATURE_IPCALC_LONG_OPTIONS
+ bool "Enable long options"
+ default n
+ depends on BUSYBOX_CONFIG_IPCALC && BUSYBOX_CONFIG_LONG_OPTS
+ help
+ Support long options for the ipcalc applet.
+
+config BUSYBOX_CONFIG_NETMSG
+ bool "netmsg"
+ default y
+ help
+ simple program for sending udp broadcast messages
+
+config BUSYBOX_CONFIG_NETSTAT
+ bool "netstat"
+ default y
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ netstat prints information about the Linux networking subsystem.
+
+config BUSYBOX_CONFIG_FEATURE_NETSTAT_WIDE
+ bool "Enable wide netstat output"
+ default y
+ depends on BUSYBOX_CONFIG_NETSTAT
+ help
+ Add support for wide columns. Useful when displaying IPv6 addresses
+ (-W option).
+
+config BUSYBOX_CONFIG_FEATURE_NETSTAT_PRG
+ bool "Enable PID/Program name output"
+ default y
+ depends on BUSYBOX_CONFIG_NETSTAT
+ help
+ Add support for -p flag to print out PID and program name.
+ +700 bytes of code.
+
+config BUSYBOX_CONFIG_NSLOOKUP
+ bool "nslookup"
+ default y
+ help
+ nslookup is a tool to query Internet name servers.
+
+config BUSYBOX_CONFIG_NTPD
+ bool "ntpd"
+ default y
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ The NTP client/server daemon.
+
+config BUSYBOX_CONFIG_FEATURE_NTPD_SERVER
+ bool "Make ntpd usable as a NTP server"
+ default y
+ depends on BUSYBOX_CONFIG_NTPD
+ help
+ Make ntpd usable as a NTP server. If you disable this option
+ ntpd will be usable only as a NTP client.
+
+config BUSYBOX_CONFIG_PSCAN
+ bool "pscan"
+ default n
+ help
+ Simple network port scanner.
+
+config BUSYBOX_CONFIG_ROUTE
+ bool "route"
+ default y
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Route displays or manipulates the kernel's IP routing tables.
+
+config BUSYBOX_CONFIG_SLATTACH
+ bool "slattach"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ slattach is a small utility to attach network interfaces to serial
+ lines.
+
+#config TC
+# bool "tc"
+# default y
+# help
+# show / manipulate traffic control settings
+#
+#config FEATURE_TC_INGRESS
+# def_bool n
+# depends on TC
+
+config BUSYBOX_CONFIG_TCPSVD
+ bool "tcpsvd"
+ default n
+ help
+ tcpsvd listens on a TCP port and runs a program for each new
+ connection.
+
+config BUSYBOX_CONFIG_TELNET
+ bool "telnet"
+ default y
+ help
+ Telnet is an interface to the TELNET protocol, but is also commonly
+ used to test other simple protocols.
+
+config BUSYBOX_CONFIG_FEATURE_TELNET_TTYPE
+ bool "Pass TERM type to remote host"
+ default y
+ depends on BUSYBOX_CONFIG_TELNET
+ help
+ Setting this option will forward the TERM environment variable to the
+ remote host you are connecting to. This is useful to make sure that
+ things like ANSI colors and other control sequences behave.
+
+config BUSYBOX_CONFIG_FEATURE_TELNET_AUTOLOGIN
+ bool "Pass USER type to remote host"
+ default n
+ depends on BUSYBOX_CONFIG_TELNET
+ help
+ Setting this option will forward the USER environment variable to the
+ remote host you are connecting to. This is useful when you need to
+ log into a machine without telling the username (autologin). This
+ option enables `-a' and `-l USER' arguments.
+
+config BUSYBOX_CONFIG_TELNETD
+ bool "telnetd"
+ default y
+ select BUSYBOX_CONFIG_FEATURE_SYSLOG
+ help
+ A daemon for the TELNET protocol, allowing you to log onto the host
+ running the daemon. Please keep in mind that the TELNET protocol
+ sends passwords in plain text. If you can't afford the space for an
+ SSH daemon and you trust your network, you may say 'y' here. As a
+ more secure alternative, you should seriously consider installing the
+ very small Dropbear SSH daemon instead:
+ http://matt.ucc.asn.au/dropbear/dropbear.html
+
+ Note that for busybox telnetd to work you need several things:
+ First of all, your kernel needs:
+ UNIX98_PTYS=y
+ DEVPTS_FS=y
+
+ Next, you need a /dev/pts directory on your root filesystem:
+
+ $ ls -ld /dev/pts
+ drwxr-xr-x 2 root root 0 Sep 23 13:21 /dev/pts/
+
+ Next you need the pseudo terminal master multiplexer /dev/ptmx:
+
+ $ ls -la /dev/ptmx
+ crw-rw-rw- 1 root tty 5, 2 Sep 23 13:55 /dev/ptmx
+
+ Any /dev/ttyp[0-9]* files you may have can be removed.
+ Next, you need to mount the devpts filesystem on /dev/pts using:
+
+ mount -t devpts devpts /dev/pts
+
+ You need to be sure that busybox has LOGIN and
+ FEATURE_SUID enabled. And finally, you should make
+ certain that Busybox has been installed setuid root:
+
+ chown root.root /bin/busybox
+ chmod 4755 /bin/busybox
+
+ with all that done, telnetd _should_ work....
+
+
+config BUSYBOX_CONFIG_FEATURE_TELNETD_STANDALONE
+ bool "Support standalone telnetd (not inetd only)"
+ default y
+ depends on BUSYBOX_CONFIG_TELNETD
+ help
+ Selecting this will make telnetd able to run standalone.
+
+config BUSYBOX_CONFIG_FEATURE_TELNETD_INETD_WAIT
+ bool "Support -w SEC option (inetd wait mode)"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_TELNETD_STANDALONE
+ help
+ This option allows you to run telnetd in "inet wait" mode.
+ Example inetd.conf line (note "wait", not usual "nowait"):
+
+ telnet stream tcp wait root /bin/telnetd telnetd -w10
+
+ In this example, inetd passes _listening_ socket_ as fd 0
+ to telnetd when connection appears.
+ telnetd will wait for connections until all existing
+ connections are closed, and no new connections
+ appear during 10 seconds. Then it exits, and inetd continues
+ to listen for new connections.
+
+ This option is rarely used. "tcp nowait" is much more usual
+ way of running tcp services, including telnetd.
+ You most probably want to say N here.
+
+config BUSYBOX_CONFIG_TFTP
+ bool "tftp"
+ default n
+ help
+ This enables the Trivial File Transfer Protocol client program. TFTP
+ is usually used for simple, small transfers such as a root image
+ for a network-enabled bootloader.
+
+config BUSYBOX_CONFIG_TFTPD
+ bool "tftpd"
+ default n
+ help
+ This enables the Trivial File Transfer Protocol server program.
+ It expects that stdin is a datagram socket and a packet
+ is already pending on it. It will exit after one transfer.
+ In other words: it should be run from inetd in nowait mode,
+ or from udpsvd. Example: "udpsvd -E 0 69 tftpd DIR"
+
+comment "Common options for tftp/tftpd"
+ depends on BUSYBOX_CONFIG_TFTP || BUSYBOX_CONFIG_TFTPD
+
+config BUSYBOX_CONFIG_FEATURE_TFTP_GET
+ bool "Enable 'tftp get' and/or tftpd upload code"
+ default n
+ depends on BUSYBOX_CONFIG_TFTP || BUSYBOX_CONFIG_TFTPD
+ help
+ Add support for the GET command within the TFTP client. This allows
+ a client to retrieve a file from a TFTP server.
+ Also enable upload support in tftpd, if tftpd is selected.
+
+ Note: this option does _not_ make tftpd capable of download
+ (the usual operation people need from it)!
+
+config BUSYBOX_CONFIG_FEATURE_TFTP_PUT
+ bool "Enable 'tftp put' and/or tftpd download code"
+ default n
+ depends on BUSYBOX_CONFIG_TFTP || BUSYBOX_CONFIG_TFTPD
+ help
+ Add support for the PUT command within the TFTP client. This allows
+ a client to transfer a file to a TFTP server.
+ Also enable download support in tftpd, if tftpd is selected.
+
+config BUSYBOX_CONFIG_FEATURE_TFTP_BLOCKSIZE
+ bool "Enable 'blksize' and 'tsize' protocol options"
+ default n
+ depends on BUSYBOX_CONFIG_TFTP || BUSYBOX_CONFIG_TFTPD
+ help
+ Allow tftp to specify block size, and tftpd to understand
+ "blksize" and "tsize" options.
+
+config BUSYBOX_CONFIG_FEATURE_TFTP_PROGRESS_BAR
+ bool "Enable tftp progress meter"
+ default n
+ depends on BUSYBOX_CONFIG_TFTP && BUSYBOX_CONFIG_FEATURE_TFTP_BLOCKSIZE
+ help
+ Show progress bar.
+
+config BUSYBOX_CONFIG_TFTP_DEBUG
+ bool "Enable debug"
+ default n
+ depends on BUSYBOX_CONFIG_TFTP || BUSYBOX_CONFIG_TFTPD
+ help
+ Make tftp[d] print debugging messages on stderr.
+ This is useful if you are diagnosing a bug in tftp[d].
+
+config BUSYBOX_CONFIG_TRACEROUTE
+ bool "traceroute"
+ default y
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Utility to trace the route of IP packets.
+
+config BUSYBOX_CONFIG_TRACEROUTE6
+ bool "traceroute6"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_IPV6 && BUSYBOX_CONFIG_TRACEROUTE
+ help
+ Utility to trace the route of IPv6 packets.
+
+config BUSYBOX_CONFIG_FEATURE_TRACEROUTE_VERBOSE
+ bool "Enable verbose output"
+ default y
+ depends on BUSYBOX_CONFIG_TRACEROUTE
+ help
+ Add some verbosity to traceroute. This includes among other things
+ hostnames and ICMP response types.
+
+config BUSYBOX_CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE
+ bool "Enable loose source route"
+ default n
+ depends on BUSYBOX_CONFIG_TRACEROUTE
+ help
+ Add option to specify a loose source route gateway
+ (8 maximum).
+
+config BUSYBOX_CONFIG_FEATURE_TRACEROUTE_USE_ICMP
+ bool "Use ICMP instead of UDP"
+ default n
+ depends on BUSYBOX_CONFIG_TRACEROUTE
+ help
+ Add option -I to use ICMP ECHO instead of UDP datagrams.
+
+config BUSYBOX_CONFIG_TUNCTL
+ bool "tunctl"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ tunctl creates or deletes tun devices.
+
+config BUSYBOX_CONFIG_FEATURE_TUNCTL_UG
+ bool "Support owner:group assignment"
+ default n
+ depends on BUSYBOX_CONFIG_TUNCTL
+ help
+ Allow to specify owner and group of newly created interface.
+ 340 bytes of pure bloat. Say no here.
+
+source package/busybox/config/networking/udhcp/Config.in
+
+config BUSYBOX_CONFIG_IFUPDOWN_UDHCPC_CMD_OPTIONS
+ string "ifup udhcpc command line options"
+ default "-R -n"
+ depends on BUSYBOX_CONFIG_IFUPDOWN && BUSYBOX_CONFIG_UDHCPC
+ help
+ Command line options to pass to udhcpc from ifup.
+ Intended to alter options not available in /etc/network/interfaces.
+ (IE: --syslog --background etc...)
+
+config BUSYBOX_CONFIG_UDPSVD
+ bool "udpsvd"
+ default n
+ help
+ udpsvd listens on an UDP port and runs a program for each new
+ connection.
+
+config BUSYBOX_CONFIG_VCONFIG
+ bool "vconfig"
+ default y
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Creates, removes, and configures VLAN interfaces
+
+config BUSYBOX_CONFIG_WGET
+ bool "wget"
+ default y
+ help
+ wget is a utility for non-interactive download of files from HTTP,
+ HTTPS, and FTP servers.
+
+config BUSYBOX_CONFIG_FEATURE_WGET_STATUSBAR
+ bool "Enable a nifty process meter (+2k)"
+ default y
+ depends on BUSYBOX_CONFIG_WGET
+ help
+ Enable the transfer progress bar for wget transfers.
+
+config BUSYBOX_CONFIG_FEATURE_WGET_AUTHENTICATION
+ bool "Enable HTTP authentication"
+ default y
+ depends on BUSYBOX_CONFIG_WGET
+ help
+ Support authenticated HTTP transfers.
+
+config BUSYBOX_CONFIG_FEATURE_WGET_LONG_OPTIONS
+ bool "Enable long options"
+ default y
+ depends on BUSYBOX_CONFIG_WGET && BUSYBOX_CONFIG_LONG_OPTS
+ help
+ Support long options for the wget applet.
+
+config BUSYBOX_CONFIG_FEATURE_WGET_TIMEOUT
+ bool "Enable read timeout option -T SEC"
+ default n
+ depends on BUSYBOX_CONFIG_WGET
+ help
+ Supports network read timeout for wget, so that wget will give
+ up and timeout when reading network data, through the -T command
+ line option. Currently only network data read timeout is
+ supported (i.e., timeout is not applied to the DNS nor TCP
+ connection initialization). When FEATURE_WGET_LONG_OPTIONS is
+ also enabled, the --timeout option will work in addition to -T.
+
+config BUSYBOX_CONFIG_ZCIP
+ bool "zcip"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ select BUSYBOX_CONFIG_FEATURE_SYSLOG
+ help
+ ZCIP provides ZeroConf IPv4 address selection, according to RFC 3927.
+ It's a daemon that allocates and defends a dynamically assigned
+ address on the 169.254/16 network, requiring no system administrator.
+
+ See http://www.zeroconf.org for further details, and "zcip.script"
+ in the busybox examples.
+
+endmenu
diff --git a/package/busybox/config/networking/udhcp/.svn/entries b/package/busybox/config/networking/udhcp/.svn/entries
new file mode 100644
index 0000000..a6e493c
--- /dev/null
+++ b/package/busybox/config/networking/udhcp/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/busybox/config/networking/udhcp
+svn://svn.openwrt.org/openwrt
+
+
+
+2011-10-21T23:08:45.031764Z
+28513
+nico
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+Config.in
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+f4e9fed085b402741ff0cfb26a465427
+2011-10-21T23:08:45.031764Z
+28513
+nico
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5497
+
diff --git a/package/busybox/config/networking/udhcp/.svn/prop-base/Config.in.svn-base b/package/busybox/config/networking/udhcp/.svn/prop-base/Config.in.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/busybox/config/networking/udhcp/.svn/prop-base/Config.in.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/busybox/config/networking/udhcp/.svn/text-base/Config.in.svn-base b/package/busybox/config/networking/udhcp/.svn/text-base/Config.in.svn-base
new file mode 100644
index 0000000..f4d26ec
--- /dev/null
+++ b/package/busybox/config/networking/udhcp/.svn/text-base/Config.in.svn-base
@@ -0,0 +1,155 @@
+# DO NOT EDIT. This file is generated from Config.src
+#
+# For a description of the syntax of this configuration file,
+# see scripts/kbuild/config-language.txt.
+#
+
+
+
+config BUSYBOX_CONFIG_UDHCPD
+ bool "udhcp server (udhcpd)"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ udhcpd is a DHCP server geared primarily toward embedded systems,
+ while striving to be fully functional and RFC compliant.
+
+config BUSYBOX_CONFIG_DHCPRELAY
+ bool "dhcprelay"
+ default n
+ depends on BUSYBOX_CONFIG_UDHCPD
+ help
+ dhcprelay listens for dhcp requests on one or more interfaces
+ and forwards these requests to a different interface or dhcp
+ server.
+
+config BUSYBOX_CONFIG_DUMPLEASES
+ bool "Lease display utility (dumpleases)"
+ default n
+ depends on BUSYBOX_CONFIG_UDHCPD
+ help
+ dumpleases displays the leases written out by the udhcpd server.
+ Lease times are stored in the file by time remaining in lease, or
+ by the absolute time that it expires in seconds from epoch.
+
+config BUSYBOX_CONFIG_FEATURE_UDHCPD_WRITE_LEASES_EARLY
+ bool "Rewrite the lease file at every new acknowledge"
+ default n
+ depends on BUSYBOX_CONFIG_UDHCPD
+ help
+ If selected, udhcpd will write a new file with leases every
+ time a new lease has been accepted, thus eliminating the need
+ to send SIGUSR1 for the initial writing or updating. Any timed
+ rewriting remains undisturbed.
+
+config BUSYBOX_CONFIG_FEATURE_UDHCPD_BASE_IP_ON_MAC
+ bool "Select IP address based on client MAC"
+ default n
+ depends on BUSYBOX_CONFIG_UDHCPD
+ help
+ If selected, udhcpd will base its selection of IP address to offer
+ on the client's hardware address. Otherwise udhcpd uses the next
+ consecutive free address.
+
+ This reduces the frequency of IP address changes for clients
+ which let their lease expire, and makes consecutive DHCPOFFERS
+ for the same client to (almost always) contain the same
+ IP address.
+
+config BUSYBOX_CONFIG_DHCPD_LEASES_FILE
+ string "Absolute path to lease file"
+ default "/var/run/udhcpd.leases"
+ depends on BUSYBOX_CONFIG_UDHCPD
+ help
+ udhcpd stores addresses in a lease file. This is the absolute path
+ of the file. Normally it is safe to leave it untouched.
+
+config BUSYBOX_CONFIG_UDHCPC
+ bool "udhcp client (udhcpc)"
+ default y
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ udhcpc is a DHCP client geared primarily toward embedded systems,
+ while striving to be fully functional and RFC compliant.
+
+ The udhcp client negotiates a lease with the DHCP server and
+ runs a script when a lease is obtained or lost.
+
+config BUSYBOX_CONFIG_FEATURE_UDHCPC_ARPING
+ bool "Verify that the offered address is free, using ARP ping"
+ default n
+ depends on BUSYBOX_CONFIG_UDHCPC
+ help
+ If selected, udhcpc will send ARP probes and make sure
+ the offered address is really not in use by anyone. The client
+ will DHCPDECLINE the offer if the address is in use,
+ and restart the discover process.
+
+config BUSYBOX_CONFIG_FEATURE_UDHCP_PORT
+ bool "Enable '-P port' option for udhcpd and udhcpc"
+ default n
+ depends on BUSYBOX_CONFIG_UDHCPD || BUSYBOX_CONFIG_UDHCPC
+ help
+ At the cost of ~300 bytes, enables -P port option.
+ This feature is typically not needed.
+
+config BUSYBOX_CONFIG_UDHCP_DEBUG
+ int "Maximum verbosity level for udhcp applets (0..9)"
+ default 0
+ range 0 9
+ depends on BUSYBOX_CONFIG_UDHCPD || BUSYBOX_CONFIG_UDHCPC || BUSYBOX_CONFIG_DHCPRELAY
+ help
+ Verbosity can be increased with multiple -v options.
+ This option controls how high it can be cranked up.
+
+ Bigger values result in bigger code. Levels above 1
+ are very verbose and useful for debugging only.
+
+config BUSYBOX_CONFIG_FEATURE_UDHCP_RFC3397
+ bool "Support for RFC3397 domain search (experimental)"
+ default y
+ depends on BUSYBOX_CONFIG_UDHCPD || BUSYBOX_CONFIG_UDHCPC
+ help
+ If selected, both client and server will support passing of domain
+ search lists via option 119, specified in RFC 3397,
+ and SIP servers option 120, specified in RFC 3361.
+
+config BUSYBOX_CONFIG_FEATURE_UDHCP_8021Q
+ bool "Support for 802.1Q VLAN parameters"
+ default n
+ depends on BUSYBOX_CONFIG_UDHCPD || BUSYBOX_CONFIG_UDHCPC
+ help
+ If selected, both client and server will support passing of VLAN
+ ID and priority via options 132 and 133 as per 802.1Q.
+
+config BUSYBOX_CONFIG_UDHCPC_DEFAULT_SCRIPT
+ string "Absolute path to config script"
+ default "/usr/share/udhcpc/default.script"
+ depends on BUSYBOX_CONFIG_UDHCPC
+ help
+ This script is called after udhcpc receives an answer. See
+ examples/udhcp for a working example. Normally it is safe
+ to leave this untouched.
+
+config BUSYBOX_CONFIG_UDHCPC_SLACK_FOR_BUGGY_SERVERS
+ int "DHCP options slack buffer size"
+ default 80
+ range 0 924
+ depends on BUSYBOX_CONFIG_UDHCPD || BUSYBOX_CONFIG_UDHCPC
+ help
+ Some buggy DHCP servers send DHCP offer packets with option
+ field larger than we expect (which might also be considered a
+ buffer overflow attempt). These packets are normally discarded.
+ If circumstances beyond your control force you to support such
+ servers, this may help. The upper limit (924) makes dhcpc accept
+ even 1500 byte packets (maximum-sized ethernet packets).
+
+ This option does not make dhcp[cd] emit non-standard
+ sized packets.
+
+ Known buggy DHCP servers:
+ 3Com OfficeConnect Remote 812 ADSL Router:
+ seems to confuse maximum allowed UDP packet size with
+ maximum size of entire IP packet, and sends packets which are
+ 28 bytes too large.
+ Seednet (ISP) VDSL: sends packets 2 bytes too large.
diff --git a/package/busybox/config/networking/udhcp/Config.in b/package/busybox/config/networking/udhcp/Config.in
new file mode 100644
index 0000000..f4d26ec
--- /dev/null
+++ b/package/busybox/config/networking/udhcp/Config.in
@@ -0,0 +1,155 @@
+# DO NOT EDIT. This file is generated from Config.src
+#
+# For a description of the syntax of this configuration file,
+# see scripts/kbuild/config-language.txt.
+#
+
+
+
+config BUSYBOX_CONFIG_UDHCPD
+ bool "udhcp server (udhcpd)"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ udhcpd is a DHCP server geared primarily toward embedded systems,
+ while striving to be fully functional and RFC compliant.
+
+config BUSYBOX_CONFIG_DHCPRELAY
+ bool "dhcprelay"
+ default n
+ depends on BUSYBOX_CONFIG_UDHCPD
+ help
+ dhcprelay listens for dhcp requests on one or more interfaces
+ and forwards these requests to a different interface or dhcp
+ server.
+
+config BUSYBOX_CONFIG_DUMPLEASES
+ bool "Lease display utility (dumpleases)"
+ default n
+ depends on BUSYBOX_CONFIG_UDHCPD
+ help
+ dumpleases displays the leases written out by the udhcpd server.
+ Lease times are stored in the file by time remaining in lease, or
+ by the absolute time that it expires in seconds from epoch.
+
+config BUSYBOX_CONFIG_FEATURE_UDHCPD_WRITE_LEASES_EARLY
+ bool "Rewrite the lease file at every new acknowledge"
+ default n
+ depends on BUSYBOX_CONFIG_UDHCPD
+ help
+ If selected, udhcpd will write a new file with leases every
+ time a new lease has been accepted, thus eliminating the need
+ to send SIGUSR1 for the initial writing or updating. Any timed
+ rewriting remains undisturbed.
+
+config BUSYBOX_CONFIG_FEATURE_UDHCPD_BASE_IP_ON_MAC
+ bool "Select IP address based on client MAC"
+ default n
+ depends on BUSYBOX_CONFIG_UDHCPD
+ help
+ If selected, udhcpd will base its selection of IP address to offer
+ on the client's hardware address. Otherwise udhcpd uses the next
+ consecutive free address.
+
+ This reduces the frequency of IP address changes for clients
+ which let their lease expire, and makes consecutive DHCPOFFERS
+ for the same client to (almost always) contain the same
+ IP address.
+
+config BUSYBOX_CONFIG_DHCPD_LEASES_FILE
+ string "Absolute path to lease file"
+ default "/var/run/udhcpd.leases"
+ depends on BUSYBOX_CONFIG_UDHCPD
+ help
+ udhcpd stores addresses in a lease file. This is the absolute path
+ of the file. Normally it is safe to leave it untouched.
+
+config BUSYBOX_CONFIG_UDHCPC
+ bool "udhcp client (udhcpc)"
+ default y
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ udhcpc is a DHCP client geared primarily toward embedded systems,
+ while striving to be fully functional and RFC compliant.
+
+ The udhcp client negotiates a lease with the DHCP server and
+ runs a script when a lease is obtained or lost.
+
+config BUSYBOX_CONFIG_FEATURE_UDHCPC_ARPING
+ bool "Verify that the offered address is free, using ARP ping"
+ default n
+ depends on BUSYBOX_CONFIG_UDHCPC
+ help
+ If selected, udhcpc will send ARP probes and make sure
+ the offered address is really not in use by anyone. The client
+ will DHCPDECLINE the offer if the address is in use,
+ and restart the discover process.
+
+config BUSYBOX_CONFIG_FEATURE_UDHCP_PORT
+ bool "Enable '-P port' option for udhcpd and udhcpc"
+ default n
+ depends on BUSYBOX_CONFIG_UDHCPD || BUSYBOX_CONFIG_UDHCPC
+ help
+ At the cost of ~300 bytes, enables -P port option.
+ This feature is typically not needed.
+
+config BUSYBOX_CONFIG_UDHCP_DEBUG
+ int "Maximum verbosity level for udhcp applets (0..9)"
+ default 0
+ range 0 9
+ depends on BUSYBOX_CONFIG_UDHCPD || BUSYBOX_CONFIG_UDHCPC || BUSYBOX_CONFIG_DHCPRELAY
+ help
+ Verbosity can be increased with multiple -v options.
+ This option controls how high it can be cranked up.
+
+ Bigger values result in bigger code. Levels above 1
+ are very verbose and useful for debugging only.
+
+config BUSYBOX_CONFIG_FEATURE_UDHCP_RFC3397
+ bool "Support for RFC3397 domain search (experimental)"
+ default y
+ depends on BUSYBOX_CONFIG_UDHCPD || BUSYBOX_CONFIG_UDHCPC
+ help
+ If selected, both client and server will support passing of domain
+ search lists via option 119, specified in RFC 3397,
+ and SIP servers option 120, specified in RFC 3361.
+
+config BUSYBOX_CONFIG_FEATURE_UDHCP_8021Q
+ bool "Support for 802.1Q VLAN parameters"
+ default n
+ depends on BUSYBOX_CONFIG_UDHCPD || BUSYBOX_CONFIG_UDHCPC
+ help
+ If selected, both client and server will support passing of VLAN
+ ID and priority via options 132 and 133 as per 802.1Q.
+
+config BUSYBOX_CONFIG_UDHCPC_DEFAULT_SCRIPT
+ string "Absolute path to config script"
+ default "/usr/share/udhcpc/default.script"
+ depends on BUSYBOX_CONFIG_UDHCPC
+ help
+ This script is called after udhcpc receives an answer. See
+ examples/udhcp for a working example. Normally it is safe
+ to leave this untouched.
+
+config BUSYBOX_CONFIG_UDHCPC_SLACK_FOR_BUGGY_SERVERS
+ int "DHCP options slack buffer size"
+ default 80
+ range 0 924
+ depends on BUSYBOX_CONFIG_UDHCPD || BUSYBOX_CONFIG_UDHCPC
+ help
+ Some buggy DHCP servers send DHCP offer packets with option
+ field larger than we expect (which might also be considered a
+ buffer overflow attempt). These packets are normally discarded.
+ If circumstances beyond your control force you to support such
+ servers, this may help. The upper limit (924) makes dhcpc accept
+ even 1500 byte packets (maximum-sized ethernet packets).
+
+ This option does not make dhcp[cd] emit non-standard
+ sized packets.
+
+ Known buggy DHCP servers:
+ 3Com OfficeConnect Remote 812 ADSL Router:
+ seems to confuse maximum allowed UDP packet size with
+ maximum size of entire IP packet, and sends packets which are
+ 28 bytes too large.
+ Seednet (ISP) VDSL: sends packets 2 bytes too large.
diff --git a/package/busybox/config/printutils/.svn/entries b/package/busybox/config/printutils/.svn/entries
new file mode 100644
index 0000000..c6b6f0e
--- /dev/null
+++ b/package/busybox/config/printutils/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/busybox/config/printutils
+svn://svn.openwrt.org/openwrt
+
+
+
+2011-10-21T23:08:45.031764Z
+28513
+nico
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+Config.in
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+50bd86a1f8a1329a94bf17c709f61b63
+2011-10-21T23:08:45.031764Z
+28513
+nico
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+535
+
diff --git a/package/busybox/config/printutils/.svn/text-base/Config.in.svn-base b/package/busybox/config/printutils/.svn/text-base/Config.in.svn-base
new file mode 100644
index 0000000..ca2ea9f
--- /dev/null
+++ b/package/busybox/config/printutils/.svn/text-base/Config.in.svn-base
@@ -0,0 +1,29 @@
+# DO NOT EDIT. This file is generated from Config.src
+#
+# For a description of the syntax of this configuration file,
+# see scripts/kbuild/config-language.txt.
+#
+
+menu "Print Utilities"
+
+
+
+config BUSYBOX_CONFIG_LPD
+ bool "lpd"
+ default n
+ help
+ lpd is a print spooling daemon.
+
+config BUSYBOX_CONFIG_LPR
+ bool "lpr"
+ default n
+ help
+ lpr sends files (or standard input) to a print spooling daemon.
+
+config BUSYBOX_CONFIG_LPQ
+ bool "lpq"
+ default n
+ help
+ lpq is a print spool queue examination and manipulation program.
+
+endmenu
diff --git a/package/busybox/config/printutils/Config.in b/package/busybox/config/printutils/Config.in
new file mode 100644
index 0000000..ca2ea9f
--- /dev/null
+++ b/package/busybox/config/printutils/Config.in
@@ -0,0 +1,29 @@
+# DO NOT EDIT. This file is generated from Config.src
+#
+# For a description of the syntax of this configuration file,
+# see scripts/kbuild/config-language.txt.
+#
+
+menu "Print Utilities"
+
+
+
+config BUSYBOX_CONFIG_LPD
+ bool "lpd"
+ default n
+ help
+ lpd is a print spooling daemon.
+
+config BUSYBOX_CONFIG_LPR
+ bool "lpr"
+ default n
+ help
+ lpr sends files (or standard input) to a print spooling daemon.
+
+config BUSYBOX_CONFIG_LPQ
+ bool "lpq"
+ default n
+ help
+ lpq is a print spool queue examination and manipulation program.
+
+endmenu
diff --git a/package/busybox/config/procps/.svn/entries b/package/busybox/config/procps/.svn/entries
new file mode 100644
index 0000000..943325c
--- /dev/null
+++ b/package/busybox/config/procps/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/busybox/config/procps
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-09-28T22:37:04.288807Z
+33594
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+Config.in
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+aee9bf80527e3a95a6140f937d2a8b64
+2012-09-28T22:37:04.288807Z
+33594
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+6920
+
diff --git a/package/busybox/config/procps/.svn/prop-base/Config.in.svn-base b/package/busybox/config/procps/.svn/prop-base/Config.in.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/busybox/config/procps/.svn/prop-base/Config.in.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/busybox/config/procps/.svn/text-base/Config.in.svn-base b/package/busybox/config/procps/.svn/text-base/Config.in.svn-base
new file mode 100644
index 0000000..d8d72a7
--- /dev/null
+++ b/package/busybox/config/procps/.svn/text-base/Config.in.svn-base
@@ -0,0 +1,260 @@
+# DO NOT EDIT. This file is generated from Config.src
+#
+# For a description of the syntax of this configuration file,
+# see scripts/kbuild/config-language.txt.
+#
+
+menu "Process Utilities"
+
+config BUSYBOX_CONFIG_IOSTAT
+ bool "iostat"
+ default n
+ help
+ Report CPU and I/O statistics
+config BUSYBOX_CONFIG_MPSTAT
+ bool "mpstat"
+ default n
+ help
+ Per-processor statistics
+config BUSYBOX_CONFIG_NMETER
+ bool "nmeter"
+ default n
+ help
+ Prints selected system stats continuously, one line per update.
+config BUSYBOX_CONFIG_PMAP
+ bool "pmap"
+ default n
+ help
+ Display processes' memory mappings.
+config BUSYBOX_CONFIG_POWERTOP
+ bool "powertop"
+ default n
+ help
+ Analyze power consumption on Intel-based laptops
+config BUSYBOX_CONFIG_PSTREE
+ bool "pstree"
+ default n
+ help
+ Display a tree of processes.
+config BUSYBOX_CONFIG_PWDX
+ bool "pwdx"
+ default n
+ help
+ Report current working directory of a process
+config BUSYBOX_CONFIG_SMEMCAP
+ bool "smemcap"
+ default n
+ help
+ smemcap is a tool for capturing process data for smem,
+ a memory usage statistic tool.
+config BUSYBOX_CONFIG_UPTIME
+ bool "uptime"
+ default y
+ select BUSYBOX_CONFIG_PLATFORM_LINUX #sysinfo()
+ help
+ uptime gives a one line display of the current time, how long
+ the system has been running, how many users are currently logged
+ on, and the system load averages for the past 1, 5, and 15 minutes.
+
+config BUSYBOX_CONFIG_FEATURE_UPTIME_UTMP_SUPPORT
+ bool "Support for showing the number of users"
+ default n
+ depends on BUSYBOX_CONFIG_UPTIME && BUSYBOX_CONFIG_FEATURE_UTMP
+ help
+ Makes uptime display the number of users currently logged on.
+
+config BUSYBOX_CONFIG_FREE
+ bool "free"
+ default y
+ select BUSYBOX_CONFIG_PLATFORM_LINUX #sysinfo()
+ help
+ free displays the total amount of free and used physical and swap
+ memory in the system, as well as the buffers used by the kernel.
+ The shared memory column should be ignored; it is obsolete.
+
+config BUSYBOX_CONFIG_FUSER
+ bool "fuser"
+ default n
+ help
+ fuser lists all PIDs (Process IDs) that currently have a given
+ file open. fuser can also list all PIDs that have a given network
+ (TCP or UDP) port open.
+
+config BUSYBOX_CONFIG_KILL
+ bool "kill"
+ default y
+ help
+ The command kill sends the specified signal to the specified
+ process or process group. If no signal is specified, the TERM
+ signal is sent.
+
+config BUSYBOX_CONFIG_KILLALL
+ bool "killall"
+ default y
+ depends on BUSYBOX_CONFIG_KILL
+ help
+ killall sends a signal to all processes running any of the
+ specified commands. If no signal name is specified, SIGTERM is
+ sent.
+
+config BUSYBOX_CONFIG_KILLALL5
+ bool "killall5"
+ default n
+ depends on BUSYBOX_CONFIG_KILL
+
+config BUSYBOX_CONFIG_PGREP
+ bool "pgrep"
+ default y
+ help
+ Look for processes by name.
+
+config BUSYBOX_CONFIG_PIDOF
+ bool "pidof"
+ default y
+ help
+ Pidof finds the process id's (pids) of the named programs. It prints
+ those id's on the standard output.
+
+config BUSYBOX_CONFIG_FEATURE_PIDOF_SINGLE
+ bool "Enable argument for single shot (-s)"
+ default n
+ depends on BUSYBOX_CONFIG_PIDOF
+ help
+ Support argument '-s' for returning only the first pid found.
+
+config BUSYBOX_CONFIG_FEATURE_PIDOF_OMIT
+ bool "Enable argument for omitting pids (-o)"
+ default n
+ depends on BUSYBOX_CONFIG_PIDOF
+ help
+ Support argument '-o' for omitting the given pids in output.
+ The special pid %PPID can be used to name the parent process
+ of the pidof, in other words the calling shell or shell script.
+
+config BUSYBOX_CONFIG_PKILL
+ bool "pkill"
+ default n
+ help
+ Send signals to processes by name.
+
+config BUSYBOX_CONFIG_PS
+ bool "ps"
+ default y
+ help
+ ps gives a snapshot of the current processes.
+
+config BUSYBOX_CONFIG_FEATURE_PS_WIDE
+ bool "Enable wide output option (-w)"
+ default y
+ depends on BUSYBOX_CONFIG_PS
+ help
+ Support argument 'w' for wide output.
+ If given once, 132 chars are printed, and if given more
+ than once, the length is unlimited.
+
+config BUSYBOX_CONFIG_FEATURE_PS_TIME
+ bool "Enable time and elapsed time output"
+ default n
+ depends on BUSYBOX_CONFIG_PS && BUSYBOX_CONFIG_DESKTOP
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Support -o time and -o etime output specifiers.
+
+config BUSYBOX_CONFIG_FEATURE_PS_ADDITIONAL_COLUMNS
+ bool "Enable additional ps columns"
+ default n
+ depends on BUSYBOX_CONFIG_PS && BUSYBOX_CONFIG_DESKTOP
+ help
+ Support -o rgroup, -o ruser, -o nice output specifiers.
+
+config BUSYBOX_CONFIG_FEATURE_PS_UNUSUAL_SYSTEMS
+ bool "Support Linux prior to 2.4.0 and non-ELF systems"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_PS_TIME
+ help
+ Include support for measuring HZ on old kernels and non-ELF systems
+ (if you are on Linux 2.4.0+ and use ELF, you don't need this)
+
+config BUSYBOX_CONFIG_RENICE
+ bool "renice"
+ default n
+ help
+ Renice alters the scheduling priority of one or more running
+ processes.
+
+config BUSYBOX_CONFIG_BB_SYSCTL
+ bool "sysctl"
+ default y
+ help
+ Configure kernel parameters at runtime.
+
+config BUSYBOX_CONFIG_TOP
+ bool "top"
+ default y
+ help
+ The top program provides a dynamic real-time view of a running
+ system.
+
+config BUSYBOX_CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE
+ bool "Show CPU per-process usage percentage"
+ default y
+ depends on BUSYBOX_CONFIG_TOP
+ help
+ Make top display CPU usage for each process.
+ This adds about 2k.
+
+config BUSYBOX_CONFIG_FEATURE_TOP_CPU_GLOBAL_PERCENTS
+ bool "Show CPU global usage percentage"
+ default y
+ depends on BUSYBOX_CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE
+ help
+ Makes top display "CPU: NN% usr NN% sys..." line.
+ This adds about 0.5k.
+
+config BUSYBOX_CONFIG_FEATURE_TOP_SMP_CPU
+ bool "SMP CPU usage display ('c' key)"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_TOP_CPU_GLOBAL_PERCENTS
+ help
+ Allow 'c' key to switch between individual/cumulative CPU stats
+ This adds about 0.5k.
+
+config BUSYBOX_CONFIG_FEATURE_TOP_DECIMALS
+ bool "Show 1/10th of a percent in CPU/mem statistics"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE
+ help
+ Show 1/10th of a percent in CPU/mem statistics.
+ This adds about 0.3k.
+
+config BUSYBOX_CONFIG_FEATURE_TOP_SMP_PROCESS
+ bool "Show CPU process runs on ('j' field)"
+ default n
+ depends on BUSYBOX_CONFIG_TOP
+ help
+ Show CPU where process was last found running on.
+ This is the 'j' field.
+
+config BUSYBOX_CONFIG_FEATURE_TOPMEM
+ bool "Topmem command ('s' key)"
+ default n
+ depends on BUSYBOX_CONFIG_TOP
+ help
+ Enable 's' in top (gives lots of memory info).
+
+config BUSYBOX_CONFIG_FEATURE_SHOW_THREADS
+ bool "Support for showing threads in ps/pstree/top"
+ default n
+ depends on BUSYBOX_CONFIG_PS || BUSYBOX_CONFIG_TOP || BUSYBOX_CONFIG_PSTREE
+ help
+ Enables the ps -T option, showing of threads in pstree,
+ and 'h' command in top.
+
+config BUSYBOX_CONFIG_WATCH
+ bool "watch"
+ default n
+ help
+ watch is used to execute a program periodically, showing
+ output to the screen.
+
+endmenu
diff --git a/package/busybox/config/procps/Config.in b/package/busybox/config/procps/Config.in
new file mode 100644
index 0000000..d8d72a7
--- /dev/null
+++ b/package/busybox/config/procps/Config.in
@@ -0,0 +1,260 @@
+# DO NOT EDIT. This file is generated from Config.src
+#
+# For a description of the syntax of this configuration file,
+# see scripts/kbuild/config-language.txt.
+#
+
+menu "Process Utilities"
+
+config BUSYBOX_CONFIG_IOSTAT
+ bool "iostat"
+ default n
+ help
+ Report CPU and I/O statistics
+config BUSYBOX_CONFIG_MPSTAT
+ bool "mpstat"
+ default n
+ help
+ Per-processor statistics
+config BUSYBOX_CONFIG_NMETER
+ bool "nmeter"
+ default n
+ help
+ Prints selected system stats continuously, one line per update.
+config BUSYBOX_CONFIG_PMAP
+ bool "pmap"
+ default n
+ help
+ Display processes' memory mappings.
+config BUSYBOX_CONFIG_POWERTOP
+ bool "powertop"
+ default n
+ help
+ Analyze power consumption on Intel-based laptops
+config BUSYBOX_CONFIG_PSTREE
+ bool "pstree"
+ default n
+ help
+ Display a tree of processes.
+config BUSYBOX_CONFIG_PWDX
+ bool "pwdx"
+ default n
+ help
+ Report current working directory of a process
+config BUSYBOX_CONFIG_SMEMCAP
+ bool "smemcap"
+ default n
+ help
+ smemcap is a tool for capturing process data for smem,
+ a memory usage statistic tool.
+config BUSYBOX_CONFIG_UPTIME
+ bool "uptime"
+ default y
+ select BUSYBOX_CONFIG_PLATFORM_LINUX #sysinfo()
+ help
+ uptime gives a one line display of the current time, how long
+ the system has been running, how many users are currently logged
+ on, and the system load averages for the past 1, 5, and 15 minutes.
+
+config BUSYBOX_CONFIG_FEATURE_UPTIME_UTMP_SUPPORT
+ bool "Support for showing the number of users"
+ default n
+ depends on BUSYBOX_CONFIG_UPTIME && BUSYBOX_CONFIG_FEATURE_UTMP
+ help
+ Makes uptime display the number of users currently logged on.
+
+config BUSYBOX_CONFIG_FREE
+ bool "free"
+ default y
+ select BUSYBOX_CONFIG_PLATFORM_LINUX #sysinfo()
+ help
+ free displays the total amount of free and used physical and swap
+ memory in the system, as well as the buffers used by the kernel.
+ The shared memory column should be ignored; it is obsolete.
+
+config BUSYBOX_CONFIG_FUSER
+ bool "fuser"
+ default n
+ help
+ fuser lists all PIDs (Process IDs) that currently have a given
+ file open. fuser can also list all PIDs that have a given network
+ (TCP or UDP) port open.
+
+config BUSYBOX_CONFIG_KILL
+ bool "kill"
+ default y
+ help
+ The command kill sends the specified signal to the specified
+ process or process group. If no signal is specified, the TERM
+ signal is sent.
+
+config BUSYBOX_CONFIG_KILLALL
+ bool "killall"
+ default y
+ depends on BUSYBOX_CONFIG_KILL
+ help
+ killall sends a signal to all processes running any of the
+ specified commands. If no signal name is specified, SIGTERM is
+ sent.
+
+config BUSYBOX_CONFIG_KILLALL5
+ bool "killall5"
+ default n
+ depends on BUSYBOX_CONFIG_KILL
+
+config BUSYBOX_CONFIG_PGREP
+ bool "pgrep"
+ default y
+ help
+ Look for processes by name.
+
+config BUSYBOX_CONFIG_PIDOF
+ bool "pidof"
+ default y
+ help
+ Pidof finds the process id's (pids) of the named programs. It prints
+ those id's on the standard output.
+
+config BUSYBOX_CONFIG_FEATURE_PIDOF_SINGLE
+ bool "Enable argument for single shot (-s)"
+ default n
+ depends on BUSYBOX_CONFIG_PIDOF
+ help
+ Support argument '-s' for returning only the first pid found.
+
+config BUSYBOX_CONFIG_FEATURE_PIDOF_OMIT
+ bool "Enable argument for omitting pids (-o)"
+ default n
+ depends on BUSYBOX_CONFIG_PIDOF
+ help
+ Support argument '-o' for omitting the given pids in output.
+ The special pid %PPID can be used to name the parent process
+ of the pidof, in other words the calling shell or shell script.
+
+config BUSYBOX_CONFIG_PKILL
+ bool "pkill"
+ default n
+ help
+ Send signals to processes by name.
+
+config BUSYBOX_CONFIG_PS
+ bool "ps"
+ default y
+ help
+ ps gives a snapshot of the current processes.
+
+config BUSYBOX_CONFIG_FEATURE_PS_WIDE
+ bool "Enable wide output option (-w)"
+ default y
+ depends on BUSYBOX_CONFIG_PS
+ help
+ Support argument 'w' for wide output.
+ If given once, 132 chars are printed, and if given more
+ than once, the length is unlimited.
+
+config BUSYBOX_CONFIG_FEATURE_PS_TIME
+ bool "Enable time and elapsed time output"
+ default n
+ depends on BUSYBOX_CONFIG_PS && BUSYBOX_CONFIG_DESKTOP
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Support -o time and -o etime output specifiers.
+
+config BUSYBOX_CONFIG_FEATURE_PS_ADDITIONAL_COLUMNS
+ bool "Enable additional ps columns"
+ default n
+ depends on BUSYBOX_CONFIG_PS && BUSYBOX_CONFIG_DESKTOP
+ help
+ Support -o rgroup, -o ruser, -o nice output specifiers.
+
+config BUSYBOX_CONFIG_FEATURE_PS_UNUSUAL_SYSTEMS
+ bool "Support Linux prior to 2.4.0 and non-ELF systems"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_PS_TIME
+ help
+ Include support for measuring HZ on old kernels and non-ELF systems
+ (if you are on Linux 2.4.0+ and use ELF, you don't need this)
+
+config BUSYBOX_CONFIG_RENICE
+ bool "renice"
+ default n
+ help
+ Renice alters the scheduling priority of one or more running
+ processes.
+
+config BUSYBOX_CONFIG_BB_SYSCTL
+ bool "sysctl"
+ default y
+ help
+ Configure kernel parameters at runtime.
+
+config BUSYBOX_CONFIG_TOP
+ bool "top"
+ default y
+ help
+ The top program provides a dynamic real-time view of a running
+ system.
+
+config BUSYBOX_CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE
+ bool "Show CPU per-process usage percentage"
+ default y
+ depends on BUSYBOX_CONFIG_TOP
+ help
+ Make top display CPU usage for each process.
+ This adds about 2k.
+
+config BUSYBOX_CONFIG_FEATURE_TOP_CPU_GLOBAL_PERCENTS
+ bool "Show CPU global usage percentage"
+ default y
+ depends on BUSYBOX_CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE
+ help
+ Makes top display "CPU: NN% usr NN% sys..." line.
+ This adds about 0.5k.
+
+config BUSYBOX_CONFIG_FEATURE_TOP_SMP_CPU
+ bool "SMP CPU usage display ('c' key)"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_TOP_CPU_GLOBAL_PERCENTS
+ help
+ Allow 'c' key to switch between individual/cumulative CPU stats
+ This adds about 0.5k.
+
+config BUSYBOX_CONFIG_FEATURE_TOP_DECIMALS
+ bool "Show 1/10th of a percent in CPU/mem statistics"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE
+ help
+ Show 1/10th of a percent in CPU/mem statistics.
+ This adds about 0.3k.
+
+config BUSYBOX_CONFIG_FEATURE_TOP_SMP_PROCESS
+ bool "Show CPU process runs on ('j' field)"
+ default n
+ depends on BUSYBOX_CONFIG_TOP
+ help
+ Show CPU where process was last found running on.
+ This is the 'j' field.
+
+config BUSYBOX_CONFIG_FEATURE_TOPMEM
+ bool "Topmem command ('s' key)"
+ default n
+ depends on BUSYBOX_CONFIG_TOP
+ help
+ Enable 's' in top (gives lots of memory info).
+
+config BUSYBOX_CONFIG_FEATURE_SHOW_THREADS
+ bool "Support for showing threads in ps/pstree/top"
+ default n
+ depends on BUSYBOX_CONFIG_PS || BUSYBOX_CONFIG_TOP || BUSYBOX_CONFIG_PSTREE
+ help
+ Enables the ps -T option, showing of threads in pstree,
+ and 'h' command in top.
+
+config BUSYBOX_CONFIG_WATCH
+ bool "watch"
+ default n
+ help
+ watch is used to execute a program periodically, showing
+ output to the screen.
+
+endmenu
diff --git a/package/busybox/config/runit/.svn/entries b/package/busybox/config/runit/.svn/entries
new file mode 100644
index 0000000..9becaf0
--- /dev/null
+++ b/package/busybox/config/runit/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/busybox/config/runit
+svn://svn.openwrt.org/openwrt
+
+
+
+2011-10-21T23:08:45.031764Z
+28513
+nico
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+Config.in
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+01b9a0c66b3cc6ee81cf21426bff640b
+2011-10-21T23:08:45.031764Z
+28513
+nico
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2205
+
diff --git a/package/busybox/config/runit/.svn/prop-base/Config.in.svn-base b/package/busybox/config/runit/.svn/prop-base/Config.in.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/busybox/config/runit/.svn/prop-base/Config.in.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/busybox/config/runit/.svn/text-base/Config.in.svn-base b/package/busybox/config/runit/.svn/text-base/Config.in.svn-base
new file mode 100644
index 0000000..9d7c597
--- /dev/null
+++ b/package/busybox/config/runit/.svn/text-base/Config.in.svn-base
@@ -0,0 +1,90 @@
+# DO NOT EDIT. This file is generated from Config.src
+#
+# For a description of the syntax of this configuration file,
+# see scripts/kbuild/config-language.txt.
+#
+
+menu "Runit Utilities"
+
+
+
+config BUSYBOX_CONFIG_RUNSV
+ bool "runsv"
+ default n
+ help
+ runsv starts and monitors a service and optionally an appendant log
+ service.
+
+config BUSYBOX_CONFIG_RUNSVDIR
+ bool "runsvdir"
+ default n
+ help
+ runsvdir starts a runsv process for each subdirectory, or symlink to
+ a directory, in the services directory dir, up to a limit of 1000
+ subdirectories, and restarts a runsv process if it terminates.
+
+config BUSYBOX_CONFIG_FEATURE_RUNSVDIR_LOG
+ bool "Enable scrolling argument log"
+ depends on BUSYBOX_CONFIG_RUNSVDIR
+ default n
+ help
+ Enable feature where second parameter of runsvdir holds last error
+ message (viewable via top/ps). Otherwise (feature is off
+ or no parameter), error messages go to stderr only.
+
+config BUSYBOX_CONFIG_SV
+ bool "sv"
+ default n
+ help
+ sv reports the current status and controls the state of services
+ monitored by the runsv supervisor.
+
+config BUSYBOX_CONFIG_SV_DEFAULT_SERVICE_DIR
+ string "Default directory for services"
+ default "/var/service"
+ depends on BUSYBOX_CONFIG_SV
+ help
+ Default directory for services.
+ Defaults to "/var/service"
+
+config BUSYBOX_CONFIG_SVLOGD
+ bool "svlogd"
+ default n
+ help
+ svlogd continuously reads log data from its standard input, optionally
+ filters log messages, and writes the data to one or more automatically
+ rotated logs.
+
+config BUSYBOX_CONFIG_CHPST
+ bool "chpst"
+ default n
+ help
+ chpst changes the process state according to the given options, and
+ execs specified program.
+
+config BUSYBOX_CONFIG_SETUIDGID
+ bool "setuidgid"
+ default n
+ help
+ Sets soft resource limits as specified by options
+
+config BUSYBOX_CONFIG_ENVUIDGID
+ bool "envuidgid"
+ default n
+ help
+ Sets $UID to account's uid and $GID to account's gid
+
+config BUSYBOX_CONFIG_ENVDIR
+ bool "envdir"
+ default n
+ help
+ Sets various environment variables as specified by files
+ in the given directory
+
+config BUSYBOX_CONFIG_SOFTLIMIT
+ bool "softlimit"
+ default n
+ help
+ Sets soft resource limits as specified by options
+
+endmenu
diff --git a/package/busybox/config/runit/Config.in b/package/busybox/config/runit/Config.in
new file mode 100644
index 0000000..9d7c597
--- /dev/null
+++ b/package/busybox/config/runit/Config.in
@@ -0,0 +1,90 @@
+# DO NOT EDIT. This file is generated from Config.src
+#
+# For a description of the syntax of this configuration file,
+# see scripts/kbuild/config-language.txt.
+#
+
+menu "Runit Utilities"
+
+
+
+config BUSYBOX_CONFIG_RUNSV
+ bool "runsv"
+ default n
+ help
+ runsv starts and monitors a service and optionally an appendant log
+ service.
+
+config BUSYBOX_CONFIG_RUNSVDIR
+ bool "runsvdir"
+ default n
+ help
+ runsvdir starts a runsv process for each subdirectory, or symlink to
+ a directory, in the services directory dir, up to a limit of 1000
+ subdirectories, and restarts a runsv process if it terminates.
+
+config BUSYBOX_CONFIG_FEATURE_RUNSVDIR_LOG
+ bool "Enable scrolling argument log"
+ depends on BUSYBOX_CONFIG_RUNSVDIR
+ default n
+ help
+ Enable feature where second parameter of runsvdir holds last error
+ message (viewable via top/ps). Otherwise (feature is off
+ or no parameter), error messages go to stderr only.
+
+config BUSYBOX_CONFIG_SV
+ bool "sv"
+ default n
+ help
+ sv reports the current status and controls the state of services
+ monitored by the runsv supervisor.
+
+config BUSYBOX_CONFIG_SV_DEFAULT_SERVICE_DIR
+ string "Default directory for services"
+ default "/var/service"
+ depends on BUSYBOX_CONFIG_SV
+ help
+ Default directory for services.
+ Defaults to "/var/service"
+
+config BUSYBOX_CONFIG_SVLOGD
+ bool "svlogd"
+ default n
+ help
+ svlogd continuously reads log data from its standard input, optionally
+ filters log messages, and writes the data to one or more automatically
+ rotated logs.
+
+config BUSYBOX_CONFIG_CHPST
+ bool "chpst"
+ default n
+ help
+ chpst changes the process state according to the given options, and
+ execs specified program.
+
+config BUSYBOX_CONFIG_SETUIDGID
+ bool "setuidgid"
+ default n
+ help
+ Sets soft resource limits as specified by options
+
+config BUSYBOX_CONFIG_ENVUIDGID
+ bool "envuidgid"
+ default n
+ help
+ Sets $UID to account's uid and $GID to account's gid
+
+config BUSYBOX_CONFIG_ENVDIR
+ bool "envdir"
+ default n
+ help
+ Sets various environment variables as specified by files
+ in the given directory
+
+config BUSYBOX_CONFIG_SOFTLIMIT
+ bool "softlimit"
+ default n
+ help
+ Sets soft resource limits as specified by options
+
+endmenu
diff --git a/package/busybox/config/selinux/.svn/entries b/package/busybox/config/selinux/.svn/entries
new file mode 100644
index 0000000..4dbb068
--- /dev/null
+++ b/package/busybox/config/selinux/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/busybox/config/selinux
+svn://svn.openwrt.org/openwrt
+
+
+
+2011-10-21T23:08:45.031764Z
+28513
+nico
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+Config.in
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+bae48505dedda6a6bfdafbfa6b298168
+2011-10-21T23:08:45.031764Z
+28513
+nico
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3122
+
diff --git a/package/busybox/config/selinux/.svn/text-base/Config.in.svn-base b/package/busybox/config/selinux/.svn/text-base/Config.in.svn-base
new file mode 100644
index 0000000..e7317ca
--- /dev/null
+++ b/package/busybox/config/selinux/.svn/text-base/Config.in.svn-base
@@ -0,0 +1,125 @@
+# DO NOT EDIT. This file is generated from Config.src
+#
+# For a description of the syntax of this configuration file,
+# see scripts/kbuild/config-language.txt.
+#
+
+menu "SELinux Utilities"
+ depends on BUSYBOX_CONFIG_SELINUX
+
+
+
+config BUSYBOX_CONFIG_CHCON
+ bool "chcon"
+ default n
+ depends on BUSYBOX_CONFIG_SELINUX
+ help
+ Enable support to change the security context of file.
+
+config BUSYBOX_CONFIG_FEATURE_CHCON_LONG_OPTIONS
+ bool "Enable long options"
+ default n
+ depends on BUSYBOX_CONFIG_CHCON && BUSYBOX_CONFIG_LONG_OPTS
+ help
+ Support long options for the chcon applet.
+
+config BUSYBOX_CONFIG_GETENFORCE
+ bool "getenforce"
+ default n
+ depends on BUSYBOX_CONFIG_SELINUX
+ help
+ Enable support to get the current mode of SELinux.
+
+config BUSYBOX_CONFIG_GETSEBOOL
+ bool "getsebool"
+ default n
+ depends on BUSYBOX_CONFIG_SELINUX
+ help
+ Enable support to get SELinux boolean values.
+
+config BUSYBOX_CONFIG_LOAD_POLICY
+ bool "load_policy"
+ default n
+ depends on BUSYBOX_CONFIG_SELINUX
+ help
+ Enable support to load SELinux policy.
+
+config BUSYBOX_CONFIG_MATCHPATHCON
+ bool "matchpathcon"
+ default n
+ depends on BUSYBOX_CONFIG_SELINUX
+ help
+ Enable support to get default security context of the
+ specified path from the file contexts configuration.
+
+config BUSYBOX_CONFIG_RESTORECON
+ bool "restorecon"
+ default n
+ depends on BUSYBOX_CONFIG_SELINUX
+ help
+ Enable support to relabel files. The feature is almost
+ the same as setfiles, but usage is a little different.
+
+config BUSYBOX_CONFIG_RUNCON
+ bool "runcon"
+ default n
+ depends on BUSYBOX_CONFIG_SELINUX
+ help
+ Enable support to run command in speficied security context.
+
+config BUSYBOX_CONFIG_FEATURE_RUNCON_LONG_OPTIONS
+ bool "Enable long options"
+ default n
+ depends on BUSYBOX_CONFIG_RUNCON && BUSYBOX_CONFIG_LONG_OPTS
+ help
+ Support long options for the runcon applet.
+
+config BUSYBOX_CONFIG_SELINUXENABLED
+ bool "selinuxenabled"
+ default n
+ depends on BUSYBOX_CONFIG_SELINUX
+ help
+ Enable support for this command to be used within shell scripts
+ to determine if selinux is enabled.
+
+config BUSYBOX_CONFIG_SETENFORCE
+ bool "setenforce"
+ default n
+ depends on BUSYBOX_CONFIG_SELINUX
+ help
+ Enable support to modify the mode SELinux is running in.
+
+config BUSYBOX_CONFIG_SETFILES
+ bool "setfiles"
+ default n
+ depends on BUSYBOX_CONFIG_SELINUX
+ help
+ Enable support to modify to relabel files.
+ Notice: If you built libselinux with -D_FILE_OFFSET_BITS=64,
+ (It is default in libselinux's Makefile), you _must_ enable
+ CONFIG_LFS.
+
+config BUSYBOX_CONFIG_FEATURE_SETFILES_CHECK_OPTION
+ bool "Enable check option"
+ default n
+ depends on BUSYBOX_CONFIG_SETFILES
+ help
+ Support "-c" option (check the validity of the contexts against
+ the specified binary policy) for setfiles. Requires libsepol.
+
+config BUSYBOX_CONFIG_SETSEBOOL
+ bool "setsebool"
+ default n
+ depends on BUSYBOX_CONFIG_SELINUX
+ help
+ Enable support for change boolean.
+ semanage and -P option is not supported yet.
+
+config BUSYBOX_CONFIG_SESTATUS
+ bool "sestatus"
+ default n
+ depends on BUSYBOX_CONFIG_SELINUX
+ help
+ Displays the status of SELinux.
+
+endmenu
diff --git a/package/busybox/config/selinux/Config.in b/package/busybox/config/selinux/Config.in
new file mode 100644
index 0000000..e7317ca
--- /dev/null
+++ b/package/busybox/config/selinux/Config.in
@@ -0,0 +1,125 @@
+# DO NOT EDIT. This file is generated from Config.src
+#
+# For a description of the syntax of this configuration file,
+# see scripts/kbuild/config-language.txt.
+#
+
+menu "SELinux Utilities"
+ depends on BUSYBOX_CONFIG_SELINUX
+
+
+
+config BUSYBOX_CONFIG_CHCON
+ bool "chcon"
+ default n
+ depends on BUSYBOX_CONFIG_SELINUX
+ help
+ Enable support to change the security context of file.
+
+config BUSYBOX_CONFIG_FEATURE_CHCON_LONG_OPTIONS
+ bool "Enable long options"
+ default n
+ depends on BUSYBOX_CONFIG_CHCON && BUSYBOX_CONFIG_LONG_OPTS
+ help
+ Support long options for the chcon applet.
+
+config BUSYBOX_CONFIG_GETENFORCE
+ bool "getenforce"
+ default n
+ depends on BUSYBOX_CONFIG_SELINUX
+ help
+ Enable support to get the current mode of SELinux.
+
+config BUSYBOX_CONFIG_GETSEBOOL
+ bool "getsebool"
+ default n
+ depends on BUSYBOX_CONFIG_SELINUX
+ help
+ Enable support to get SELinux boolean values.
+
+config BUSYBOX_CONFIG_LOAD_POLICY
+ bool "load_policy"
+ default n
+ depends on BUSYBOX_CONFIG_SELINUX
+ help
+ Enable support to load SELinux policy.
+
+config BUSYBOX_CONFIG_MATCHPATHCON
+ bool "matchpathcon"
+ default n
+ depends on BUSYBOX_CONFIG_SELINUX
+ help
+ Enable support to get default security context of the
+ specified path from the file contexts configuration.
+
+config BUSYBOX_CONFIG_RESTORECON
+ bool "restorecon"
+ default n
+ depends on BUSYBOX_CONFIG_SELINUX
+ help
+ Enable support to relabel files. The feature is almost
+ the same as setfiles, but usage is a little different.
+
+config BUSYBOX_CONFIG_RUNCON
+ bool "runcon"
+ default n
+ depends on BUSYBOX_CONFIG_SELINUX
+ help
+ Enable support to run command in speficied security context.
+
+config BUSYBOX_CONFIG_FEATURE_RUNCON_LONG_OPTIONS
+ bool "Enable long options"
+ default n
+ depends on BUSYBOX_CONFIG_RUNCON && BUSYBOX_CONFIG_LONG_OPTS
+ help
+ Support long options for the runcon applet.
+
+config BUSYBOX_CONFIG_SELINUXENABLED
+ bool "selinuxenabled"
+ default n
+ depends on BUSYBOX_CONFIG_SELINUX
+ help
+ Enable support for this command to be used within shell scripts
+ to determine if selinux is enabled.
+
+config BUSYBOX_CONFIG_SETENFORCE
+ bool "setenforce"
+ default n
+ depends on BUSYBOX_CONFIG_SELINUX
+ help
+ Enable support to modify the mode SELinux is running in.
+
+config BUSYBOX_CONFIG_SETFILES
+ bool "setfiles"
+ default n
+ depends on BUSYBOX_CONFIG_SELINUX
+ help
+ Enable support to modify to relabel files.
+ Notice: If you built libselinux with -D_FILE_OFFSET_BITS=64,
+ (It is default in libselinux's Makefile), you _must_ enable
+ CONFIG_LFS.
+
+config BUSYBOX_CONFIG_FEATURE_SETFILES_CHECK_OPTION
+ bool "Enable check option"
+ default n
+ depends on BUSYBOX_CONFIG_SETFILES
+ help
+ Support "-c" option (check the validity of the contexts against
+ the specified binary policy) for setfiles. Requires libsepol.
+
+config BUSYBOX_CONFIG_SETSEBOOL
+ bool "setsebool"
+ default n
+ depends on BUSYBOX_CONFIG_SELINUX
+ help
+ Enable support for change boolean.
+ semanage and -P option is not supported yet.
+
+config BUSYBOX_CONFIG_SESTATUS
+ bool "sestatus"
+ default n
+ depends on BUSYBOX_CONFIG_SELINUX
+ help
+ Displays the status of SELinux.
+
+endmenu
diff --git a/package/busybox/config/shell/.svn/entries b/package/busybox/config/shell/.svn/entries
new file mode 100644
index 0000000..5b2e141
--- /dev/null
+++ b/package/busybox/config/shell/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/busybox/config/shell
+svn://svn.openwrt.org/openwrt
+
+
+
+2011-10-21T23:08:45.031764Z
+28513
+nico
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+Config.in
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+5fc8664c4fbcb5fb5d0c8c6c819c84a6
+2011-10-21T23:08:45.031764Z
+28513
+nico
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+13461
+
diff --git a/package/busybox/config/shell/.svn/prop-base/Config.in.svn-base b/package/busybox/config/shell/.svn/prop-base/Config.in.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/busybox/config/shell/.svn/prop-base/Config.in.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/busybox/config/shell/.svn/text-base/Config.in.svn-base b/package/busybox/config/shell/.svn/text-base/Config.in.svn-base
new file mode 100644
index 0000000..a271a38
--- /dev/null
+++ b/package/busybox/config/shell/.svn/text-base/Config.in.svn-base
@@ -0,0 +1,433 @@
+# DO NOT EDIT. This file is generated from Config.src
+#
+# For a description of the syntax of this configuration file,
+# see scripts/kbuild/config-language.txt.
+#
+
+menu "Shells"
+
+config BUSYBOX_CONFIG_ASH
+ bool "ash"
+ default y
+ depends on !BUSYBOX_CONFIG_NOMMU
+ help
+ Tha 'ash' shell adds about 60k in the default configuration and is
+ the most complete and most pedantically correct shell included with
+ busybox. This shell is actually a derivative of the Debian 'dash'
+ shell (by Herbert Xu), which was created by porting the 'ash' shell
+ (written by Kenneth Almquist) from NetBSD.
+
+config BUSYBOX_CONFIG_ASH_BASH_COMPAT
+ bool "bash-compatible extensions"
+ default y
+ depends on BUSYBOX_CONFIG_ASH
+ help
+ Enable bash-compatible extensions.
+
+config BUSYBOX_CONFIG_ASH_IDLE_TIMEOUT
+ bool "Idle timeout variable"
+ default n
+ depends on BUSYBOX_CONFIG_ASH
+ help
+ Enables bash-like auto-logout after $TMOUT seconds of idle time.
+
+config BUSYBOX_CONFIG_ASH_JOB_CONTROL
+ bool "Job control"
+ default y
+ depends on BUSYBOX_CONFIG_ASH
+ help
+ Enable job control in the ash shell.
+
+config BUSYBOX_CONFIG_ASH_ALIAS
+ bool "Alias support"
+ default y
+ depends on BUSYBOX_CONFIG_ASH
+ help
+ Enable alias support in the ash shell.
+
+config BUSYBOX_CONFIG_ASH_GETOPTS
+ bool "Builtin getopt to parse positional parameters"
+ default y
+ depends on BUSYBOX_CONFIG_ASH
+ help
+ Enable support for getopts builtin in ash.
+
+config BUSYBOX_CONFIG_ASH_BUILTIN_ECHO
+ bool "Builtin version of 'echo'"
+ default y
+ depends on BUSYBOX_CONFIG_ASH
+ help
+ Enable support for echo builtin in ash.
+
+config BUSYBOX_CONFIG_ASH_BUILTIN_PRINTF
+ bool "Builtin version of 'printf'"
+ default y
+ depends on BUSYBOX_CONFIG_ASH
+ help
+ Enable support for printf builtin in ash.
+
+config BUSYBOX_CONFIG_ASH_BUILTIN_TEST
+ bool "Builtin version of 'test'"
+ default y
+ depends on BUSYBOX_CONFIG_ASH
+ help
+ Enable support for test builtin in ash.
+
+config BUSYBOX_CONFIG_ASH_CMDCMD
+ bool "'command' command to override shell builtins"
+ default y
+ depends on BUSYBOX_CONFIG_ASH
+ help
+ Enable support for the ash 'command' builtin, which allows
+ you to run the specified command with the specified arguments,
+ even when there is an ash builtin command with the same name.
+
+config BUSYBOX_CONFIG_ASH_MAIL
+ bool "Check for new mail on interactive shells"
+ default n
+ depends on BUSYBOX_CONFIG_ASH
+ help
+ Enable "check for new mail" function in the ash shell.
+
+config BUSYBOX_CONFIG_ASH_OPTIMIZE_FOR_SIZE
+ bool "Optimize for size instead of speed"
+ default n
+ depends on BUSYBOX_CONFIG_ASH
+ help
+ Compile ash for reduced size at the price of speed.
+
+config BUSYBOX_CONFIG_ASH_RANDOM_SUPPORT
+ bool "Pseudorandom generator and $RANDOM variable"
+ default n
+ depends on BUSYBOX_CONFIG_ASH
+ help
+ Enable pseudorandom generator and dynamic variable "$RANDOM".
+ Each read of "$RANDOM" will generate a new pseudorandom value.
+ You can reset the generator by using a specified start value.
+ After "unset RANDOM" the generator will switch off and this
+ variable will no longer have special treatment.
+
+config BUSYBOX_CONFIG_ASH_EXPAND_PRMT
+ bool "Expand prompt string"
+ default y
+ depends on BUSYBOX_CONFIG_ASH
+ help
+ "PS#" may contain volatile content, such as backquote commands.
+ This option recreates the prompt string from the environment
+ variable each time it is displayed.
+
+config BUSYBOX_CONFIG_CTTYHACK
+ bool "cttyhack"
+ default n
+ help
+ One common problem reported on the mailing list is the "can't
+ access tty; job control turned off" error message, which typically
+ appears when one tries to use a shell with stdin/stdout on
+ /dev/console.
+ This device is special - it cannot be a controlling tty.
+
+ The proper solution is to use the correct device instead of
+ /dev/console.
+
+ cttyhack provides a "quick and dirty" solution to this problem.
+ It analyzes stdin with various ioctls, trying to determine whether
+ it is a /dev/ttyN or /dev/ttySN (virtual terminal or serial line).
+ On Linux it also checks sysfs for a pointer to the active console.
+ If cttyhack is able to find the real console device, it closes
+ stdin/out/err and reopens that device.
+ Then it executes the given program. Opening the device will make
+ that device a controlling tty. This may require cttyhack
+ to be a session leader.
+
+ Example for /etc/inittab (for busybox init):
+
+ ::respawn:/bin/cttyhack /bin/sh
+
+ Starting an interactive shell from boot shell script:
+
+ setsid cttyhack sh
+
+ Giving controlling tty to shell running with PID 1:
+
+ # exec cttyhack sh
+
+ Without cttyhack, you need to know exact tty name,
+ and do something like this:
+
+ # exec setsid sh -c 'exec sh </dev/tty1 >/dev/tty1 2>&1'
+
+config BUSYBOX_CONFIG_HUSH
+ bool "hush"
+ default n
+ help
+ hush is a small shell (25k). It handles the normal flow control
+ constructs such as if/then/elif/else/fi, for/in/do/done, while loops,
+ case/esac. Redirections, here documents, $((arithmetic))
+ and functions are supported.
+
+ It will compile and work on no-mmu systems.
+
+ It does not handle select, aliases, tilde expansion,
+ &>file and >&file redirection of stdout+stderr.
+
+config BUSYBOX_CONFIG_HUSH_BASH_COMPAT
+ bool "bash-compatible extensions"
+ default y
+ depends on BUSYBOX_CONFIG_HUSH
+ help
+ Enable bash-compatible extensions.
+
+config BUSYBOX_CONFIG_HUSH_BRACE_EXPANSION
+ bool "Brace expansion"
+ default n
+ depends on BUSYBOX_CONFIG_HUSH_BASH_COMPAT
+ help
+ Enable {abc,def} extension.
+
+config BUSYBOX_CONFIG_HUSH_HELP
+ bool "help builtin"
+ default y
+ depends on BUSYBOX_CONFIG_HUSH
+ help
+ Enable help builtin in hush. Code size + ~1 kbyte.
+
+config BUSYBOX_CONFIG_HUSH_INTERACTIVE
+ bool "Interactive mode"
+ default y
+ depends on BUSYBOX_CONFIG_HUSH
+ help
+ Enable interactive mode (prompt and command editing).
+ Without this, hush simply reads and executes commands
+ from stdin just like a shell script from a file.
+ No prompt, no PS1/PS2 magic shell variables.
+
+config BUSYBOX_CONFIG_HUSH_SAVEHISTORY
+ bool "Save command history to .hush_history"
+ default n
+ depends on BUSYBOX_CONFIG_HUSH_INTERACTIVE && BUSYBOX_CONFIG_FEATURE_EDITING_SAVEHISTORY
+ help
+ Enable history saving in hush.
+
+config BUSYBOX_CONFIG_HUSH_JOB
+ bool "Job control"
+ default y
+ depends on BUSYBOX_CONFIG_HUSH_INTERACTIVE
+ help
+ Enable job control: Ctrl-Z backgrounds, Ctrl-C interrupts current
+ command (not entire shell), fg/bg builtins work. Without this option,
+ "cmd &" still works by simply spawning a process and immediately
+ prompting for next command (or executing next command in a script),
+ but no separate process group is formed.
+
+config BUSYBOX_CONFIG_HUSH_TICK
+ bool "Process substitution"
+ default y
+ depends on BUSYBOX_CONFIG_HUSH
+ help
+ Enable process substitution `command` and $(command) in hush.
+
+config BUSYBOX_CONFIG_HUSH_IF
+ bool "Support if/then/elif/else/fi"
+ default y
+ depends on BUSYBOX_CONFIG_HUSH
+ help
+ Enable if/then/elif/else/fi in hush.
+
+config BUSYBOX_CONFIG_HUSH_LOOPS
+ bool "Support for, while and until loops"
+ default y
+ depends on BUSYBOX_CONFIG_HUSH
+ help
+ Enable for, while and until loops in hush.
+
+config BUSYBOX_CONFIG_HUSH_CASE
+ bool "Support case ... esac statement"
+ default y
+ depends on BUSYBOX_CONFIG_HUSH
+ help
+ Enable case ... esac statement in hush. +400 bytes.
+
+config BUSYBOX_CONFIG_HUSH_FUNCTIONS
+ bool "Support funcname() { commands; } syntax"
+ default y
+ depends on BUSYBOX_CONFIG_HUSH
+ help
+ Enable support for shell functions in hush. +800 bytes.
+
+config BUSYBOX_CONFIG_HUSH_LOCAL
+ bool "Support local builtin"
+ default y
+ depends on BUSYBOX_CONFIG_HUSH_FUNCTIONS
+ help
+ Enable support for local variables in functions.
+
+config BUSYBOX_CONFIG_HUSH_RANDOM_SUPPORT
+ bool "Pseudorandom generator and $RANDOM variable"
+ default n
+ depends on BUSYBOX_CONFIG_HUSH
+ help
+ Enable pseudorandom generator and dynamic variable "$RANDOM".
+ Each read of "$RANDOM" will generate a new pseudorandom value.
+
+config BUSYBOX_CONFIG_HUSH_EXPORT_N
+ bool "Support 'export -n' option"
+ default y
+ depends on BUSYBOX_CONFIG_HUSH
+ help
+ export -n unexports variables. It is a bash extension.
+
+config BUSYBOX_CONFIG_HUSH_MODE_X
+ bool "Support 'hush -x' option and 'set -x' command"
+ default n
+ depends on BUSYBOX_CONFIG_HUSH
+ help
+ This instructs hush to print commands before execution.
+ Adds ~300 bytes.
+
+config BUSYBOX_CONFIG_MSH
+ bool "msh (deprecated: aliased to hush)"
+ default n
+ select BUSYBOX_CONFIG_HUSH
+ help
+ msh is deprecated and will be removed, please migrate to hush.
+
+
+choice
+ prompt "Choose which shell is aliased to 'sh' name"
+ default BUSYBOX_CONFIG_FEATURE_SH_IS_ASH
+ help
+ Choose which shell you want to be executed by 'sh' alias.
+ The ash shell is the most bash compatible and full featured one.
+
+# note: cannot use "select ASH" here, it breaks "make allnoconfig"
+config BUSYBOX_CONFIG_FEATURE_SH_IS_ASH
+ depends on BUSYBOX_CONFIG_ASH
+ bool "ash"
+ depends on !BUSYBOX_CONFIG_NOMMU
+
+config BUSYBOX_CONFIG_FEATURE_SH_IS_HUSH
+ depends on BUSYBOX_CONFIG_HUSH
+ bool "hush"
+
+config BUSYBOX_CONFIG_FEATURE_SH_IS_NONE
+ bool "none"
+
+endchoice
+
+choice
+ prompt "Choose which shell is aliased to 'bash' name"
+ default BUSYBOX_CONFIG_FEATURE_BASH_IS_NONE
+ help
+ Choose which shell you want to be executed by 'bash' alias.
+ The ash shell is the most bash compatible and full featured one.
+
+ Note that selecting this option does not switch on any bash
+ compatibility code. It merely makes it possible to install
+ /bin/bash (sym)link and run scripts which start with
+ #!/bin/bash line.
+
+ Many systems use it in scripts which use bash-specific features,
+ even simple ones like $RANDOM. Without this option, busybox
+ can't be used for running them because it won't recongnize
+ "bash" as a supported applet name.
+
+config BUSYBOX_CONFIG_FEATURE_BASH_IS_ASH
+ depends on BUSYBOX_CONFIG_ASH
+ bool "ash"
+ depends on !BUSYBOX_CONFIG_NOMMU
+
+config BUSYBOX_CONFIG_FEATURE_BASH_IS_HUSH
+ depends on BUSYBOX_CONFIG_HUSH
+ bool "hush"
+
+config BUSYBOX_CONFIG_FEATURE_BASH_IS_NONE
+ bool "none"
+
+endchoice
+
+
+config BUSYBOX_CONFIG_SH_MATH_SUPPORT
+ bool "POSIX math support"
+ default y
+ depends on BUSYBOX_CONFIG_ASH || BUSYBOX_CONFIG_HUSH
+ help
+ Enable math support in the shell via $((...)) syntax.
+
+config BUSYBOX_CONFIG_SH_MATH_SUPPORT_64
+ bool "Extend POSIX math support to 64 bit"
+ default y
+ depends on BUSYBOX_CONFIG_SH_MATH_SUPPORT
+ help
+ Enable 64-bit math support in the shell. This will make the shell
+ slightly larger, but will allow computation with very large numbers.
+ This is not in POSIX, so do not rely on this in portable code.
+
+config BUSYBOX_CONFIG_FEATURE_SH_EXTRA_QUIET
+ bool "Hide message on interactive shell startup"
+ default n
+ depends on BUSYBOX_CONFIG_HUSH || BUSYBOX_CONFIG_ASH
+ help
+ Remove the busybox introduction when starting a shell.
+
+config BUSYBOX_CONFIG_FEATURE_SH_STANDALONE
+ bool "Standalone shell"
+ default n
+ depends on (BUSYBOX_CONFIG_HUSH || BUSYBOX_CONFIG_ASH) && BUSYBOX_CONFIG_FEATURE_PREFER_APPLETS
+ help
+ This option causes busybox shells to use busybox applets
+ in preference to executables in the PATH whenever possible. For
+ example, entering the command 'ifconfig' into the shell would cause
+ busybox to use the ifconfig busybox applet. Specifying the fully
+ qualified executable name, such as '/sbin/ifconfig' will still
+ execute the /sbin/ifconfig executable on the filesystem. This option
+ is generally used when creating a statically linked version of busybox
+ for use as a rescue shell, in the event that you screw up your system.
+
+ This is implemented by re-execing /proc/self/exe (typically)
+ with right parameters. Some selected applets ("NOFORK" applets)
+ can even be executed without creating new process.
+ Instead, busybox will call <applet>_main() internally.
+
+ However, this causes problems in chroot jails without mounted /proc
+ and with ps/top (command name can be shown as 'exe' for applets
+ started this way).
+# untrue?
+# Note that this will *also* cause applets to take precedence
+# over shell builtins of the same name. So turning this on will
+# eliminate any performance gained by turning on the builtin "echo"
+# and "test" commands in ash.
+# untrue?
+# Note that when using this option, the shell will attempt to directly
+# run '/bin/busybox'. If you do not have the busybox binary sitting in
+# that exact location with that exact name, this option will not work at
+# all.
+
+config BUSYBOX_CONFIG_FEATURE_SH_NOFORK
+ bool "Run 'nofork' applets directly"
+ default n
+ depends on (BUSYBOX_CONFIG_HUSH || BUSYBOX_CONFIG_ASH) && BUSYBOX_CONFIG_FEATURE_PREFER_APPLETS
+ help
+ This option causes busybox shells to not execute typical
+ fork/exec/wait sequence, but call <applet>_main directly,
+ if possible. (Sometimes it is not possible: for example,
+ this is not possible in pipes).
+
+ This will be done only for some applets (those which are marked
+ NOFORK in include/applets.h).
+
+ This may significantly speed up some shell scripts.
+
+ This feature is relatively new. Use with care. Report bugs
+ to project mailing list.
+
+config BUSYBOX_CONFIG_FEATURE_SH_HISTFILESIZE
+ bool "Use $HISTFILESIZE"
+ default n
+ depends on BUSYBOX_CONFIG_HUSH || BUSYBOX_CONFIG_ASH
+ help
+ This option makes busybox shells to use $HISTFILESIZE variable
+ to set shell history size. Note that its max value is capped
+ by "History size" setting in library tuning section.
+
+
+endmenu
diff --git a/package/busybox/config/shell/Config.in b/package/busybox/config/shell/Config.in
new file mode 100644
index 0000000..a271a38
--- /dev/null
+++ b/package/busybox/config/shell/Config.in
@@ -0,0 +1,433 @@
+# DO NOT EDIT. This file is generated from Config.src
+#
+# For a description of the syntax of this configuration file,
+# see scripts/kbuild/config-language.txt.
+#
+
+menu "Shells"
+
+config BUSYBOX_CONFIG_ASH
+ bool "ash"
+ default y
+ depends on !BUSYBOX_CONFIG_NOMMU
+ help
+ Tha 'ash' shell adds about 60k in the default configuration and is
+ the most complete and most pedantically correct shell included with
+ busybox. This shell is actually a derivative of the Debian 'dash'
+ shell (by Herbert Xu), which was created by porting the 'ash' shell
+ (written by Kenneth Almquist) from NetBSD.
+
+config BUSYBOX_CONFIG_ASH_BASH_COMPAT
+ bool "bash-compatible extensions"
+ default y
+ depends on BUSYBOX_CONFIG_ASH
+ help
+ Enable bash-compatible extensions.
+
+config BUSYBOX_CONFIG_ASH_IDLE_TIMEOUT
+ bool "Idle timeout variable"
+ default n
+ depends on BUSYBOX_CONFIG_ASH
+ help
+ Enables bash-like auto-logout after $TMOUT seconds of idle time.
+
+config BUSYBOX_CONFIG_ASH_JOB_CONTROL
+ bool "Job control"
+ default y
+ depends on BUSYBOX_CONFIG_ASH
+ help
+ Enable job control in the ash shell.
+
+config BUSYBOX_CONFIG_ASH_ALIAS
+ bool "Alias support"
+ default y
+ depends on BUSYBOX_CONFIG_ASH
+ help
+ Enable alias support in the ash shell.
+
+config BUSYBOX_CONFIG_ASH_GETOPTS
+ bool "Builtin getopt to parse positional parameters"
+ default y
+ depends on BUSYBOX_CONFIG_ASH
+ help
+ Enable support for getopts builtin in ash.
+
+config BUSYBOX_CONFIG_ASH_BUILTIN_ECHO
+ bool "Builtin version of 'echo'"
+ default y
+ depends on BUSYBOX_CONFIG_ASH
+ help
+ Enable support for echo builtin in ash.
+
+config BUSYBOX_CONFIG_ASH_BUILTIN_PRINTF
+ bool "Builtin version of 'printf'"
+ default y
+ depends on BUSYBOX_CONFIG_ASH
+ help
+ Enable support for printf builtin in ash.
+
+config BUSYBOX_CONFIG_ASH_BUILTIN_TEST
+ bool "Builtin version of 'test'"
+ default y
+ depends on BUSYBOX_CONFIG_ASH
+ help
+ Enable support for test builtin in ash.
+
+config BUSYBOX_CONFIG_ASH_CMDCMD
+ bool "'command' command to override shell builtins"
+ default y
+ depends on BUSYBOX_CONFIG_ASH
+ help
+ Enable support for the ash 'command' builtin, which allows
+ you to run the specified command with the specified arguments,
+ even when there is an ash builtin command with the same name.
+
+config BUSYBOX_CONFIG_ASH_MAIL
+ bool "Check for new mail on interactive shells"
+ default n
+ depends on BUSYBOX_CONFIG_ASH
+ help
+ Enable "check for new mail" function in the ash shell.
+
+config BUSYBOX_CONFIG_ASH_OPTIMIZE_FOR_SIZE
+ bool "Optimize for size instead of speed"
+ default n
+ depends on BUSYBOX_CONFIG_ASH
+ help
+ Compile ash for reduced size at the price of speed.
+
+config BUSYBOX_CONFIG_ASH_RANDOM_SUPPORT
+ bool "Pseudorandom generator and $RANDOM variable"
+ default n
+ depends on BUSYBOX_CONFIG_ASH
+ help
+ Enable pseudorandom generator and dynamic variable "$RANDOM".
+ Each read of "$RANDOM" will generate a new pseudorandom value.
+ You can reset the generator by using a specified start value.
+ After "unset RANDOM" the generator will switch off and this
+ variable will no longer have special treatment.
+
+config BUSYBOX_CONFIG_ASH_EXPAND_PRMT
+ bool "Expand prompt string"
+ default y
+ depends on BUSYBOX_CONFIG_ASH
+ help
+ "PS#" may contain volatile content, such as backquote commands.
+ This option recreates the prompt string from the environment
+ variable each time it is displayed.
+
+config BUSYBOX_CONFIG_CTTYHACK
+ bool "cttyhack"
+ default n
+ help
+ One common problem reported on the mailing list is the "can't
+ access tty; job control turned off" error message, which typically
+ appears when one tries to use a shell with stdin/stdout on
+ /dev/console.
+ This device is special - it cannot be a controlling tty.
+
+ The proper solution is to use the correct device instead of
+ /dev/console.
+
+ cttyhack provides a "quick and dirty" solution to this problem.
+ It analyzes stdin with various ioctls, trying to determine whether
+ it is a /dev/ttyN or /dev/ttySN (virtual terminal or serial line).
+ On Linux it also checks sysfs for a pointer to the active console.
+ If cttyhack is able to find the real console device, it closes
+ stdin/out/err and reopens that device.
+ Then it executes the given program. Opening the device will make
+ that device a controlling tty. This may require cttyhack
+ to be a session leader.
+
+ Example for /etc/inittab (for busybox init):
+
+ ::respawn:/bin/cttyhack /bin/sh
+
+ Starting an interactive shell from boot shell script:
+
+ setsid cttyhack sh
+
+ Giving controlling tty to shell running with PID 1:
+
+ # exec cttyhack sh
+
+ Without cttyhack, you need to know exact tty name,
+ and do something like this:
+
+ # exec setsid sh -c 'exec sh </dev/tty1 >/dev/tty1 2>&1'
+
+config BUSYBOX_CONFIG_HUSH
+ bool "hush"
+ default n
+ help
+ hush is a small shell (25k). It handles the normal flow control
+ constructs such as if/then/elif/else/fi, for/in/do/done, while loops,
+ case/esac. Redirections, here documents, $((arithmetic))
+ and functions are supported.
+
+ It will compile and work on no-mmu systems.
+
+ It does not handle select, aliases, tilde expansion,
+ &>file and >&file redirection of stdout+stderr.
+
+config BUSYBOX_CONFIG_HUSH_BASH_COMPAT
+ bool "bash-compatible extensions"
+ default y
+ depends on BUSYBOX_CONFIG_HUSH
+ help
+ Enable bash-compatible extensions.
+
+config BUSYBOX_CONFIG_HUSH_BRACE_EXPANSION
+ bool "Brace expansion"
+ default n
+ depends on BUSYBOX_CONFIG_HUSH_BASH_COMPAT
+ help
+ Enable {abc,def} extension.
+
+config BUSYBOX_CONFIG_HUSH_HELP
+ bool "help builtin"
+ default y
+ depends on BUSYBOX_CONFIG_HUSH
+ help
+ Enable help builtin in hush. Code size + ~1 kbyte.
+
+config BUSYBOX_CONFIG_HUSH_INTERACTIVE
+ bool "Interactive mode"
+ default y
+ depends on BUSYBOX_CONFIG_HUSH
+ help
+ Enable interactive mode (prompt and command editing).
+ Without this, hush simply reads and executes commands
+ from stdin just like a shell script from a file.
+ No prompt, no PS1/PS2 magic shell variables.
+
+config BUSYBOX_CONFIG_HUSH_SAVEHISTORY
+ bool "Save command history to .hush_history"
+ default n
+ depends on BUSYBOX_CONFIG_HUSH_INTERACTIVE && BUSYBOX_CONFIG_FEATURE_EDITING_SAVEHISTORY
+ help
+ Enable history saving in hush.
+
+config BUSYBOX_CONFIG_HUSH_JOB
+ bool "Job control"
+ default y
+ depends on BUSYBOX_CONFIG_HUSH_INTERACTIVE
+ help
+ Enable job control: Ctrl-Z backgrounds, Ctrl-C interrupts current
+ command (not entire shell), fg/bg builtins work. Without this option,
+ "cmd &" still works by simply spawning a process and immediately
+ prompting for next command (or executing next command in a script),
+ but no separate process group is formed.
+
+config BUSYBOX_CONFIG_HUSH_TICK
+ bool "Process substitution"
+ default y
+ depends on BUSYBOX_CONFIG_HUSH
+ help
+ Enable process substitution `command` and $(command) in hush.
+
+config BUSYBOX_CONFIG_HUSH_IF
+ bool "Support if/then/elif/else/fi"
+ default y
+ depends on BUSYBOX_CONFIG_HUSH
+ help
+ Enable if/then/elif/else/fi in hush.
+
+config BUSYBOX_CONFIG_HUSH_LOOPS
+ bool "Support for, while and until loops"
+ default y
+ depends on BUSYBOX_CONFIG_HUSH
+ help
+ Enable for, while and until loops in hush.
+
+config BUSYBOX_CONFIG_HUSH_CASE
+ bool "Support case ... esac statement"
+ default y
+ depends on BUSYBOX_CONFIG_HUSH
+ help
+ Enable case ... esac statement in hush. +400 bytes.
+
+config BUSYBOX_CONFIG_HUSH_FUNCTIONS
+ bool "Support funcname() { commands; } syntax"
+ default y
+ depends on BUSYBOX_CONFIG_HUSH
+ help
+ Enable support for shell functions in hush. +800 bytes.
+
+config BUSYBOX_CONFIG_HUSH_LOCAL
+ bool "Support local builtin"
+ default y
+ depends on BUSYBOX_CONFIG_HUSH_FUNCTIONS
+ help
+ Enable support for local variables in functions.
+
+config BUSYBOX_CONFIG_HUSH_RANDOM_SUPPORT
+ bool "Pseudorandom generator and $RANDOM variable"
+ default n
+ depends on BUSYBOX_CONFIG_HUSH
+ help
+ Enable pseudorandom generator and dynamic variable "$RANDOM".
+ Each read of "$RANDOM" will generate a new pseudorandom value.
+
+config BUSYBOX_CONFIG_HUSH_EXPORT_N
+ bool "Support 'export -n' option"
+ default y
+ depends on BUSYBOX_CONFIG_HUSH
+ help
+ export -n unexports variables. It is a bash extension.
+
+config BUSYBOX_CONFIG_HUSH_MODE_X
+ bool "Support 'hush -x' option and 'set -x' command"
+ default n
+ depends on BUSYBOX_CONFIG_HUSH
+ help
+ This instructs hush to print commands before execution.
+ Adds ~300 bytes.
+
+config BUSYBOX_CONFIG_MSH
+ bool "msh (deprecated: aliased to hush)"
+ default n
+ select BUSYBOX_CONFIG_HUSH
+ help
+ msh is deprecated and will be removed, please migrate to hush.
+
+
+choice
+ prompt "Choose which shell is aliased to 'sh' name"
+ default BUSYBOX_CONFIG_FEATURE_SH_IS_ASH
+ help
+ Choose which shell you want to be executed by 'sh' alias.
+ The ash shell is the most bash compatible and full featured one.
+
+# note: cannot use "select ASH" here, it breaks "make allnoconfig"
+config BUSYBOX_CONFIG_FEATURE_SH_IS_ASH
+ depends on BUSYBOX_CONFIG_ASH
+ bool "ash"
+ depends on !BUSYBOX_CONFIG_NOMMU
+
+config BUSYBOX_CONFIG_FEATURE_SH_IS_HUSH
+ depends on BUSYBOX_CONFIG_HUSH
+ bool "hush"
+
+config BUSYBOX_CONFIG_FEATURE_SH_IS_NONE
+ bool "none"
+
+endchoice
+
+choice
+ prompt "Choose which shell is aliased to 'bash' name"
+ default BUSYBOX_CONFIG_FEATURE_BASH_IS_NONE
+ help
+ Choose which shell you want to be executed by 'bash' alias.
+ The ash shell is the most bash compatible and full featured one.
+
+ Note that selecting this option does not switch on any bash
+ compatibility code. It merely makes it possible to install
+ /bin/bash (sym)link and run scripts which start with
+ #!/bin/bash line.
+
+ Many systems use it in scripts which use bash-specific features,
+ even simple ones like $RANDOM. Without this option, busybox
+ can't be used for running them because it won't recongnize
+ "bash" as a supported applet name.
+
+config BUSYBOX_CONFIG_FEATURE_BASH_IS_ASH
+ depends on BUSYBOX_CONFIG_ASH
+ bool "ash"
+ depends on !BUSYBOX_CONFIG_NOMMU
+
+config BUSYBOX_CONFIG_FEATURE_BASH_IS_HUSH
+ depends on BUSYBOX_CONFIG_HUSH
+ bool "hush"
+
+config BUSYBOX_CONFIG_FEATURE_BASH_IS_NONE
+ bool "none"
+
+endchoice
+
+
+config BUSYBOX_CONFIG_SH_MATH_SUPPORT
+ bool "POSIX math support"
+ default y
+ depends on BUSYBOX_CONFIG_ASH || BUSYBOX_CONFIG_HUSH
+ help
+ Enable math support in the shell via $((...)) syntax.
+
+config BUSYBOX_CONFIG_SH_MATH_SUPPORT_64
+ bool "Extend POSIX math support to 64 bit"
+ default y
+ depends on BUSYBOX_CONFIG_SH_MATH_SUPPORT
+ help
+ Enable 64-bit math support in the shell. This will make the shell
+ slightly larger, but will allow computation with very large numbers.
+ This is not in POSIX, so do not rely on this in portable code.
+
+config BUSYBOX_CONFIG_FEATURE_SH_EXTRA_QUIET
+ bool "Hide message on interactive shell startup"
+ default n
+ depends on BUSYBOX_CONFIG_HUSH || BUSYBOX_CONFIG_ASH
+ help
+ Remove the busybox introduction when starting a shell.
+
+config BUSYBOX_CONFIG_FEATURE_SH_STANDALONE
+ bool "Standalone shell"
+ default n
+ depends on (BUSYBOX_CONFIG_HUSH || BUSYBOX_CONFIG_ASH) && BUSYBOX_CONFIG_FEATURE_PREFER_APPLETS
+ help
+ This option causes busybox shells to use busybox applets
+ in preference to executables in the PATH whenever possible. For
+ example, entering the command 'ifconfig' into the shell would cause
+ busybox to use the ifconfig busybox applet. Specifying the fully
+ qualified executable name, such as '/sbin/ifconfig' will still
+ execute the /sbin/ifconfig executable on the filesystem. This option
+ is generally used when creating a statically linked version of busybox
+ for use as a rescue shell, in the event that you screw up your system.
+
+ This is implemented by re-execing /proc/self/exe (typically)
+ with right parameters. Some selected applets ("NOFORK" applets)
+ can even be executed without creating new process.
+ Instead, busybox will call <applet>_main() internally.
+
+ However, this causes problems in chroot jails without mounted /proc
+ and with ps/top (command name can be shown as 'exe' for applets
+ started this way).
+# untrue?
+# Note that this will *also* cause applets to take precedence
+# over shell builtins of the same name. So turning this on will
+# eliminate any performance gained by turning on the builtin "echo"
+# and "test" commands in ash.
+# untrue?
+# Note that when using this option, the shell will attempt to directly
+# run '/bin/busybox'. If you do not have the busybox binary sitting in
+# that exact location with that exact name, this option will not work at
+# all.
+
+config BUSYBOX_CONFIG_FEATURE_SH_NOFORK
+ bool "Run 'nofork' applets directly"
+ default n
+ depends on (BUSYBOX_CONFIG_HUSH || BUSYBOX_CONFIG_ASH) && BUSYBOX_CONFIG_FEATURE_PREFER_APPLETS
+ help
+ This option causes busybox shells to not execute typical
+ fork/exec/wait sequence, but call <applet>_main directly,
+ if possible. (Sometimes it is not possible: for example,
+ this is not possible in pipes).
+
+ This will be done only for some applets (those which are marked
+ NOFORK in include/applets.h).
+
+ This may significantly speed up some shell scripts.
+
+ This feature is relatively new. Use with care. Report bugs
+ to project mailing list.
+
+config BUSYBOX_CONFIG_FEATURE_SH_HISTFILESIZE
+ bool "Use $HISTFILESIZE"
+ default n
+ depends on BUSYBOX_CONFIG_HUSH || BUSYBOX_CONFIG_ASH
+ help
+ This option makes busybox shells to use $HISTFILESIZE variable
+ to set shell history size. Note that its max value is capped
+ by "History size" setting in library tuning section.
+
+
+endmenu
diff --git a/package/busybox/config/sysklogd/.svn/entries b/package/busybox/config/sysklogd/.svn/entries
new file mode 100644
index 0000000..388b501
--- /dev/null
+++ b/package/busybox/config/sysklogd/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/busybox/config/sysklogd
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-13T18:11:31.576290Z
+36005
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+Config.in
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+99295f40e7a3e6ff8a5704c420fb4444
+2013-03-13T18:11:31.576290Z
+36005
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5031
+
diff --git a/package/busybox/config/sysklogd/.svn/prop-base/Config.in.svn-base b/package/busybox/config/sysklogd/.svn/prop-base/Config.in.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/busybox/config/sysklogd/.svn/prop-base/Config.in.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/busybox/config/sysklogd/.svn/text-base/Config.in.svn-base b/package/busybox/config/sysklogd/.svn/text-base/Config.in.svn-base
new file mode 100644
index 0000000..087a5b4
--- /dev/null
+++ b/package/busybox/config/sysklogd/.svn/text-base/Config.in.svn-base
@@ -0,0 +1,154 @@
+# DO NOT EDIT. This file is generated from Config.src
+#
+# For a description of the syntax of this configuration file,
+# see scripts/kbuild/config-language.txt.
+#
+
+menu "System Logging Utilities"
+
+
+
+config BUSYBOX_CONFIG_SYSLOGD
+ bool "syslogd"
+ default y
+ help
+ The syslogd utility is used to record logs of all the
+ significant events that occur on a system. Every
+ message that is logged records the date and time of the
+ event, and will generally also record the name of the
+ application that generated the message. When used in
+ conjunction with klogd, messages from the Linux kernel
+ can also be recorded. This is terribly useful,
+ especially for finding what happened when something goes
+ wrong. And something almost always will go wrong if
+ you wait long enough....
+
+config BUSYBOX_CONFIG_FEATURE_ROTATE_LOGFILE
+ bool "Rotate message files"
+ default y
+ depends on BUSYBOX_CONFIG_SYSLOGD
+ help
+ This enables syslogd to rotate the message files
+ on his own. No need to use an external rotatescript.
+
+config BUSYBOX_CONFIG_FEATURE_REMOTE_LOG
+ bool "Remote Log support"
+ default y
+ depends on BUSYBOX_CONFIG_SYSLOGD
+ help
+ When you enable this feature, the syslogd utility can
+ be used to send system log messages to another system
+ connected via a network. This allows the remote
+ machine to log all the system messages, which can be
+ terribly useful for reducing the number of serial
+ cables you use. It can also be a very good security
+ measure to prevent system logs from being tampered with
+ by an intruder.
+
+config BUSYBOX_CONFIG_FEATURE_SYSLOGD_DUP
+ bool "Support -D (drop dups) option"
+ default n
+ depends on BUSYBOX_CONFIG_SYSLOGD
+ help
+ Option -D instructs syslogd to drop consecutive messages
+ which are totally the same.
+
+config BUSYBOX_CONFIG_FEATURE_SYSLOGD_CFG
+ bool "Support syslog.conf"
+ default n
+ depends on BUSYBOX_CONFIG_SYSLOGD
+ help
+ Supports restricted syslogd config. See docs/syslog.conf.txt
+
+config BUSYBOX_CONFIG_FEATURE_SYSLOGD_READ_BUFFER_SIZE
+ int "Read buffer size in bytes"
+ default 256
+ range 256 20000
+ depends on BUSYBOX_CONFIG_SYSLOGD
+ help
+ This option sets the size of the syslog read buffer.
+ Actual memory usage increases around five times the
+ change done here.
+
+config BUSYBOX_CONFIG_FEATURE_IPC_SYSLOG
+ bool "Circular Buffer support"
+ default y
+ depends on BUSYBOX_CONFIG_SYSLOGD
+ help
+ When you enable this feature, the syslogd utility will
+ use a circular buffer to record system log messages.
+ When the buffer is filled it will continue to overwrite
+ the oldest messages. This can be very useful for
+ systems with little or no permanent storage, since
+ otherwise system logs can eventually fill up your
+ entire filesystem, which may cause your system to
+ break badly.
+
+config BUSYBOX_CONFIG_FEATURE_IPC_SYSLOG_BUFFER_SIZE
+ int "Circular buffer size in Kbytes (minimum 4KB)"
+ default 16
+ range 4 2147483647
+ depends on BUSYBOX_CONFIG_FEATURE_IPC_SYSLOG
+ help
+ This option sets the size of the circular buffer
+ used to record system log messages.
+
+config BUSYBOX_CONFIG_LOGREAD
+ bool "logread"
+ default y
+ depends on BUSYBOX_CONFIG_FEATURE_IPC_SYSLOG && !PROCD_INIT
+ help
+ If you enabled Circular Buffer support, you almost
+ certainly want to enable this feature as well. This
+ utility will allow you to read the messages that are
+ stored in the syslogd circular buffer.
+
+config BUSYBOX_CONFIG_FEATURE_LOGREAD_REDUCED_LOCKING
+ bool "Double buffering"
+ default n
+ depends on BUSYBOX_CONFIG_LOGREAD
+ help
+ 'logread' ouput to slow serial terminals can have
+ side effects on syslog because of the semaphore.
+ This option make logread to double buffer copy
+ from circular buffer, minimizing semaphore
+ contention at some minor memory expense.
+
+config BUSYBOX_CONFIG_KLOGD
+ bool "klogd"
+ default y
+ help
+ klogd is a utility which intercepts and logs all
+ messages from the Linux kernel and sends the messages
+ out to the 'syslogd' utility so they can be logged. If
+ you wish to record the messages produced by the kernel,
+ you should enable this option.
+
+config BUSYBOX_CONFIG_FEATURE_KLOGD_KLOGCTL
+ bool "Use the klogctl() interface"
+ default y
+ depends on BUSYBOX_CONFIG_KLOGD
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ The klogd applet supports two interfaces for reading
+ kernel messages. Linux provides the klogctl() interface
+ which allows reading messages from the kernel ring buffer
+ independently from the file system.
+
+ If you answer 'N' here, klogd will use the more portable
+ approach of reading them from /proc or a device node.
+ However, this method requires the file to be available.
+
+ If in doubt, say 'Y'.
+
+config BUSYBOX_CONFIG_LOGGER
+ bool "logger"
+ default y
+ select BUSYBOX_CONFIG_FEATURE_SYSLOG
+ help
+ The logger utility allows you to send arbitrary text
+ messages to the system log (i.e. the 'syslogd' utility) so
+ they can be logged. This is generally used to help locate
+ problems that occur within programs and scripts.
+
+endmenu
diff --git a/package/busybox/config/sysklogd/Config.in b/package/busybox/config/sysklogd/Config.in
new file mode 100644
index 0000000..087a5b4
--- /dev/null
+++ b/package/busybox/config/sysklogd/Config.in
@@ -0,0 +1,154 @@
+# DO NOT EDIT. This file is generated from Config.src
+#
+# For a description of the syntax of this configuration file,
+# see scripts/kbuild/config-language.txt.
+#
+
+menu "System Logging Utilities"
+
+
+
+config BUSYBOX_CONFIG_SYSLOGD
+ bool "syslogd"
+ default y
+ help
+ The syslogd utility is used to record logs of all the
+ significant events that occur on a system. Every
+ message that is logged records the date and time of the
+ event, and will generally also record the name of the
+ application that generated the message. When used in
+ conjunction with klogd, messages from the Linux kernel
+ can also be recorded. This is terribly useful,
+ especially for finding what happened when something goes
+ wrong. And something almost always will go wrong if
+ you wait long enough....
+
+config BUSYBOX_CONFIG_FEATURE_ROTATE_LOGFILE
+ bool "Rotate message files"
+ default y
+ depends on BUSYBOX_CONFIG_SYSLOGD
+ help
+ This enables syslogd to rotate the message files
+ on his own. No need to use an external rotatescript.
+
+config BUSYBOX_CONFIG_FEATURE_REMOTE_LOG
+ bool "Remote Log support"
+ default y
+ depends on BUSYBOX_CONFIG_SYSLOGD
+ help
+ When you enable this feature, the syslogd utility can
+ be used to send system log messages to another system
+ connected via a network. This allows the remote
+ machine to log all the system messages, which can be
+ terribly useful for reducing the number of serial
+ cables you use. It can also be a very good security
+ measure to prevent system logs from being tampered with
+ by an intruder.
+
+config BUSYBOX_CONFIG_FEATURE_SYSLOGD_DUP
+ bool "Support -D (drop dups) option"
+ default n
+ depends on BUSYBOX_CONFIG_SYSLOGD
+ help
+ Option -D instructs syslogd to drop consecutive messages
+ which are totally the same.
+
+config BUSYBOX_CONFIG_FEATURE_SYSLOGD_CFG
+ bool "Support syslog.conf"
+ default n
+ depends on BUSYBOX_CONFIG_SYSLOGD
+ help
+ Supports restricted syslogd config. See docs/syslog.conf.txt
+
+config BUSYBOX_CONFIG_FEATURE_SYSLOGD_READ_BUFFER_SIZE
+ int "Read buffer size in bytes"
+ default 256
+ range 256 20000
+ depends on BUSYBOX_CONFIG_SYSLOGD
+ help
+ This option sets the size of the syslog read buffer.
+ Actual memory usage increases around five times the
+ change done here.
+
+config BUSYBOX_CONFIG_FEATURE_IPC_SYSLOG
+ bool "Circular Buffer support"
+ default y
+ depends on BUSYBOX_CONFIG_SYSLOGD
+ help
+ When you enable this feature, the syslogd utility will
+ use a circular buffer to record system log messages.
+ When the buffer is filled it will continue to overwrite
+ the oldest messages. This can be very useful for
+ systems with little or no permanent storage, since
+ otherwise system logs can eventually fill up your
+ entire filesystem, which may cause your system to
+ break badly.
+
+config BUSYBOX_CONFIG_FEATURE_IPC_SYSLOG_BUFFER_SIZE
+ int "Circular buffer size in Kbytes (minimum 4KB)"
+ default 16
+ range 4 2147483647
+ depends on BUSYBOX_CONFIG_FEATURE_IPC_SYSLOG
+ help
+ This option sets the size of the circular buffer
+ used to record system log messages.
+
+config BUSYBOX_CONFIG_LOGREAD
+ bool "logread"
+ default y
+ depends on BUSYBOX_CONFIG_FEATURE_IPC_SYSLOG && !PROCD_INIT
+ help
+ If you enabled Circular Buffer support, you almost
+ certainly want to enable this feature as well. This
+ utility will allow you to read the messages that are
+ stored in the syslogd circular buffer.
+
+config BUSYBOX_CONFIG_FEATURE_LOGREAD_REDUCED_LOCKING
+ bool "Double buffering"
+ default n
+ depends on BUSYBOX_CONFIG_LOGREAD
+ help
+ 'logread' ouput to slow serial terminals can have
+ side effects on syslog because of the semaphore.
+ This option make logread to double buffer copy
+ from circular buffer, minimizing semaphore
+ contention at some minor memory expense.
+
+config BUSYBOX_CONFIG_KLOGD
+ bool "klogd"
+ default y
+ help
+ klogd is a utility which intercepts and logs all
+ messages from the Linux kernel and sends the messages
+ out to the 'syslogd' utility so they can be logged. If
+ you wish to record the messages produced by the kernel,
+ you should enable this option.
+
+config BUSYBOX_CONFIG_FEATURE_KLOGD_KLOGCTL
+ bool "Use the klogctl() interface"
+ default y
+ depends on BUSYBOX_CONFIG_KLOGD
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ The klogd applet supports two interfaces for reading
+ kernel messages. Linux provides the klogctl() interface
+ which allows reading messages from the kernel ring buffer
+ independently from the file system.
+
+ If you answer 'N' here, klogd will use the more portable
+ approach of reading them from /proc or a device node.
+ However, this method requires the file to be available.
+
+ If in doubt, say 'Y'.
+
+config BUSYBOX_CONFIG_LOGGER
+ bool "logger"
+ default y
+ select BUSYBOX_CONFIG_FEATURE_SYSLOG
+ help
+ The logger utility allows you to send arbitrary text
+ messages to the system log (i.e. the 'syslogd' utility) so
+ they can be logged. This is generally used to help locate
+ problems that occur within programs and scripts.
+
+endmenu
diff --git a/package/busybox/config/util-linux/.svn/entries b/package/busybox/config/util-linux/.svn/entries
new file mode 100644
index 0000000..7175d39
--- /dev/null
+++ b/package/busybox/config/util-linux/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/busybox/config/util-linux
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-06T16:21:29.224933Z
+35025
+hauke
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+Config.in
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+acf5b7d2683c66580b0b4ba8b5c67349
+2013-01-06T16:21:29.224933Z
+35025
+hauke
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+29555
+
diff --git a/package/busybox/config/util-linux/.svn/prop-base/Config.in.svn-base b/package/busybox/config/util-linux/.svn/prop-base/Config.in.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/busybox/config/util-linux/.svn/prop-base/Config.in.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/busybox/config/util-linux/.svn/text-base/Config.in.svn-base b/package/busybox/config/util-linux/.svn/text-base/Config.in.svn-base
new file mode 100644
index 0000000..d60b139
--- /dev/null
+++ b/package/busybox/config/util-linux/.svn/text-base/Config.in.svn-base
@@ -0,0 +1,985 @@
+# DO NOT EDIT. This file is generated from Config.src
+#
+# For a description of the syntax of this configuration file,
+# see scripts/kbuild/config-language.txt.
+#
+
+menu "Linux System Utilities"
+
+config BUSYBOX_CONFIG_BLOCKDEV
+ bool "blockdev"
+ default n
+ help
+ Performs some ioctls with block devices.
+config BUSYBOX_CONFIG_REV
+ bool "rev"
+ default n
+ help
+ Reverse lines of a file or files.
+
+config BUSYBOX_CONFIG_ACPID
+ bool "acpid"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ acpid listens to ACPI events coming either in textual form from
+ /proc/acpi/event (though it is marked deprecated it is still widely
+ used and _is_ a standard) or in binary form from specified evdevs
+ (just use /dev/input/event*).
+
+ It parses the event to retrieve ACTION and a possible PARAMETER.
+ It then spawns /etc/acpi/<ACTION>[/<PARAMETER>] either via run-parts
+ (if the resulting path is a directory) or directly as an executable.
+
+ N.B. acpid relies on run-parts so have the latter installed.
+
+config BUSYBOX_CONFIG_FEATURE_ACPID_COMPAT
+ bool "Accept and ignore redundant options"
+ default n
+ depends on BUSYBOX_CONFIG_ACPID
+ help
+ Accept and ignore compatibility options -g -m -s -S -v.
+
+config BUSYBOX_CONFIG_BLKID
+ bool "blkid"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ select BUSYBOX_CONFIG_VOLUMEID
+ help
+ Lists labels and UUIDs of all filesystems.
+ WARNING:
+ With all submodules selected, it will add ~8k to busybox.
+
+config BUSYBOX_CONFIG_FEATURE_BLKID_TYPE
+ bool "Print filesystem type"
+ default n
+ depends on BUSYBOX_CONFIG_BLKID
+ help
+ Show TYPE="filesystem type"
+
+config BUSYBOX_CONFIG_DMESG
+ bool "dmesg"
+ default y
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ dmesg is used to examine or control the kernel ring buffer. When the
+ Linux kernel prints messages to the system log, they are stored in
+ the kernel ring buffer. You can use dmesg to print the kernel's ring
+ buffer, clear the kernel ring buffer, change the size of the kernel
+ ring buffer, and change the priority level at which kernel messages
+ are also logged to the system console. Enable this option if you
+ wish to enable the 'dmesg' utility.
+
+config BUSYBOX_CONFIG_FEATURE_DMESG_PRETTY
+ bool "Pretty dmesg output"
+ default y
+ depends on BUSYBOX_CONFIG_DMESG
+ help
+ If you wish to scrub the syslog level from the output, say 'Y' here.
+ The syslog level is a string prefixed to every line with the form
+ "<#>".
+
+ With this option you will see:
+ # dmesg
+ Linux version 2.6.17.4 .....
+ BIOS-provided physical RAM map:
+ BIOS-e820: 0000000000000000 - 000000000009f000 (usable)
+
+ Without this option you will see:
+ # dmesg
+ <5>Linux version 2.6.17.4 .....
+ <6>BIOS-provided physical RAM map:
+ <6> BIOS-e820: 0000000000000000 - 000000000009f000 (usable)
+
+config BUSYBOX_CONFIG_FBSET
+ bool "fbset"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ fbset is used to show or change the settings of a Linux frame buffer
+ device. The frame buffer device provides a simple and unique
+ interface to access a graphics display. Enable this option
+ if you wish to enable the 'fbset' utility.
+
+config BUSYBOX_CONFIG_FEATURE_FBSET_FANCY
+ bool "Turn on extra fbset options"
+ default n
+ depends on BUSYBOX_CONFIG_FBSET
+ help
+ This option enables extended fbset options, allowing one to set the
+ framebuffer size, color depth, etc. interface to access a graphics
+ display. Enable this option if you wish to enable extended fbset
+ options.
+
+config BUSYBOX_CONFIG_FEATURE_FBSET_READMODE
+ bool "Turn on fbset readmode support"
+ default n
+ depends on BUSYBOX_CONFIG_FBSET
+ help
+ This option allows fbset to read the video mode database stored by
+ default n /etc/fb.modes, which can be used to set frame buffer
+ device to pre-defined video modes.
+
+config BUSYBOX_CONFIG_FDFLUSH
+ bool "fdflush"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ fdflush is only needed when changing media on slightly-broken
+ removable media drives. It is used to make Linux believe that a
+ hardware disk-change switch has been actuated, which causes Linux to
+ forget anything it has cached from the previous media. If you have
+ such a slightly-broken drive, you will need to run fdflush every time
+ you change a disk. Most people have working hardware and can safely
+ leave this disabled.
+
+config BUSYBOX_CONFIG_FDFORMAT
+ bool "fdformat"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ fdformat is used to low-level format a floppy disk.
+
+config BUSYBOX_CONFIG_FDISK
+ bool "fdisk"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ The fdisk utility is used to divide hard disks into one or more
+ logical disks, which are generally called partitions. This utility
+ can be used to list and edit the set of partitions or BSD style
+ 'disk slices' that are defined on a hard drive.
+
+config BUSYBOX_CONFIG_FDISK_SUPPORT_LARGE_DISKS
+ bool "Support over 4GB disks"
+ default y
+ depends on BUSYBOX_CONFIG_FDISK
+ depends on !BUSYBOX_CONFIG_LFS # with LFS no special code is needed
+ help
+ Enable this option to support large disks > 4GB.
+
+config BUSYBOX_CONFIG_FEATURE_FDISK_WRITABLE
+ bool "Write support"
+ default n
+ depends on BUSYBOX_CONFIG_FDISK
+ help
+ Enabling this option allows you to create or change a partition table
+ and write those changes out to disk. If you leave this option
+ disabled, you will only be able to view the partition table.
+
+config BUSYBOX_CONFIG_FEATURE_AIX_LABEL
+ bool "Support AIX disklabels"
+ default n
+ depends on BUSYBOX_CONFIG_FDISK && BUSYBOX_CONFIG_FEATURE_FDISK_WRITABLE
+ help
+ Enabling this option allows you to create or change AIX disklabels.
+ Most people can safely leave this option disabled.
+
+config BUSYBOX_CONFIG_FEATURE_SGI_LABEL
+ bool "Support SGI disklabels"
+ default n
+ depends on BUSYBOX_CONFIG_FDISK && BUSYBOX_CONFIG_FEATURE_FDISK_WRITABLE
+ help
+ Enabling this option allows you to create or change SGI disklabels.
+ Most people can safely leave this option disabled.
+
+config BUSYBOX_CONFIG_FEATURE_SUN_LABEL
+ bool "Support SUN disklabels"
+ default n
+ depends on BUSYBOX_CONFIG_FDISK && BUSYBOX_CONFIG_FEATURE_FDISK_WRITABLE
+ help
+ Enabling this option allows you to create or change SUN disklabels.
+ Most people can safely leave this option disabled.
+
+config BUSYBOX_CONFIG_FEATURE_OSF_LABEL
+ bool "Support BSD disklabels"
+ default n
+ depends on BUSYBOX_CONFIG_FDISK && BUSYBOX_CONFIG_FEATURE_FDISK_WRITABLE
+ help
+ Enabling this option allows you to create or change BSD disklabels
+ and define and edit BSD disk slices.
+
+config BUSYBOX_CONFIG_FEATURE_GPT_LABEL
+ bool "Support GPT disklabels"
+ default n
+ depends on BUSYBOX_CONFIG_FDISK && BUSYBOX_CONFIG_FEATURE_FDISK_WRITABLE
+ help
+ Enabling this option allows you to view GUID Partition Table
+ disklabels.
+
+config BUSYBOX_CONFIG_FEATURE_FDISK_ADVANCED
+ bool "Support expert mode"
+ default n
+ depends on BUSYBOX_CONFIG_FDISK && BUSYBOX_CONFIG_FEATURE_FDISK_WRITABLE
+ help
+ Enabling this option allows you to do terribly unsafe things like
+ define arbitrary drive geometry, move the beginning of data in a
+ partition, and similarly evil things. Unless you have a very good
+ reason you would be wise to leave this disabled.
+
+config BUSYBOX_CONFIG_FINDFS
+ bool "findfs"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ select BUSYBOX_CONFIG_VOLUMEID
+ help
+ Prints the name of a filesystem with given label or UUID.
+ WARNING:
+ With all submodules selected, it will add ~8k to busybox.
+
+config BUSYBOX_CONFIG_FLOCK
+ bool "flock"
+ default n
+ help
+ Manage locks from shell scripts
+
+config BUSYBOX_CONFIG_FREERAMDISK
+ bool "freeramdisk"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Linux allows you to create ramdisks. This utility allows you to
+ delete them and completely free all memory that was used for the
+ ramdisk. For example, if you boot Linux into a ramdisk and later
+ pivot_root, you may want to free the memory that is allocated to the
+ ramdisk. If you have no use for freeing memory from a ramdisk, leave
+ this disabled.
+
+config BUSYBOX_CONFIG_FSCK_MINIX
+ bool "fsck_minix"
+ default n
+ help
+ The minix filesystem is a nice, small, compact, read-write filesystem
+ with little overhead. It is not a journaling filesystem however and
+ can experience corruption if it is not properly unmounted or if the
+ power goes off in the middle of a write. This utility allows you to
+ check for and attempt to repair any corruption that occurs to a minix
+ filesystem.
+
+config BUSYBOX_CONFIG_MKFS_EXT2
+ bool "mkfs_ext2"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Utility to create EXT2 filesystems.
+
+config BUSYBOX_CONFIG_MKFS_MINIX
+ bool "mkfs_minix"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ The minix filesystem is a nice, small, compact, read-write filesystem
+ with little overhead. If you wish to be able to create minix
+ filesystems this utility will do the job for you.
+
+config BUSYBOX_CONFIG_FEATURE_MINIX2
+ bool "Support Minix fs v2 (fsck_minix/mkfs_minix)"
+ default n
+ depends on BUSYBOX_CONFIG_FSCK_MINIX || BUSYBOX_CONFIG_MKFS_MINIX
+ help
+ If you wish to be able to create version 2 minix filesystems, enable
+ this. If you enabled 'mkfs_minix' then you almost certainly want to
+ be using the version 2 filesystem support.
+
+config BUSYBOX_CONFIG_MKFS_REISER
+ bool "mkfs_reiser"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Utility to create ReiserFS filesystems.
+ Note: this applet needs a lot of testing and polishing.
+
+config BUSYBOX_CONFIG_MKFS_VFAT
+ bool "mkfs_vfat"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Utility to create FAT32 filesystems.
+
+config BUSYBOX_CONFIG_GETOPT
+ bool "getopt"
+ default n
+ help
+ The getopt utility is used to break up (parse) options in command
+ lines to make it easy to write complex shell scripts that also check
+ for legal (and illegal) options. If you want to write horribly
+ complex shell scripts, or use some horribly complex shell script
+ written by others, this utility may be for you. Most people will
+ wisely leave this disabled.
+
+config BUSYBOX_CONFIG_FEATURE_GETOPT_LONG
+ bool "Support option -l"
+ default n if BUSYBOX_CONFIG_LONG_OPTS
+ depends on BUSYBOX_CONFIG_GETOPT
+ help
+ Enable support for long options (option -l).
+
+config BUSYBOX_CONFIG_HEXDUMP
+ bool "hexdump"
+ default y
+ help
+ The hexdump utility is used to display binary data in a readable
+ way that is comparable to the output from most hex editors.
+
+config BUSYBOX_CONFIG_FEATURE_HEXDUMP_REVERSE
+ bool "Support -R, reverse of 'hexdump -Cv'"
+ default n
+ depends on BUSYBOX_CONFIG_HEXDUMP
+ help
+ The hexdump utility is used to display binary data in an ascii
+ readable way. This option creates binary data from an ascii input.
+ NB: this option is non-standard. It's unwise to use it in scripts
+ aimed to be portable.
+
+config BUSYBOX_CONFIG_HD
+ bool "hd"
+ default n
+ depends on BUSYBOX_CONFIG_HEXDUMP
+ help
+ hd is an alias to hexdump -C.
+
+config BUSYBOX_CONFIG_HWCLOCK
+ bool "hwclock"
+ default y
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ The hwclock utility is used to read and set the hardware clock
+ on a system. This is primarily used to set the current time on
+ shutdown in the hardware clock, so the hardware will keep the
+ correct time when Linux is _not_ running.
+
+config BUSYBOX_CONFIG_FEATURE_HWCLOCK_LONG_OPTIONS
+ bool "Support long options (--hctosys,...)"
+ default n
+ depends on BUSYBOX_CONFIG_HWCLOCK && BUSYBOX_CONFIG_LONG_OPTS
+ help
+ By default, the hwclock utility only uses short options. If you
+ are overly fond of its long options, such as --hctosys, --utc, etc)
+ then enable this option.
+
+config BUSYBOX_CONFIG_FEATURE_HWCLOCK_ADJTIME_FHS
+ bool "Use FHS /var/lib/hwclock/adjtime"
+ default n # util-linux-ng in Fedora 13 still uses /etc/adjtime
+ depends on BUSYBOX_CONFIG_HWCLOCK
+ help
+ Starting with FHS 2.3, the adjtime state file is supposed to exist
+ at /var/lib/hwclock/adjtime instead of /etc/adjtime. If you wish
+ to use the FHS behavior, answer Y here, otherwise answer N for the
+ classic /etc/adjtime path.
+
+ pathname.com/fhs/pub/fhs-2.3.html#VARLIBHWCLOCKSTATEDIRECTORYFORHWCLO
+
+config BUSYBOX_CONFIG_IPCRM
+ bool "ipcrm"
+ default n
+ help
+ The ipcrm utility allows the removal of System V interprocess
+ communication (IPC) objects and the associated data structures
+ from the system.
+
+config BUSYBOX_CONFIG_IPCS
+ bool "ipcs"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ The ipcs utility is used to provide information on the currently
+ allocated System V interprocess (IPC) objects in the system.
+
+config BUSYBOX_CONFIG_LOSETUP
+ bool "losetup"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ losetup is used to associate or detach a loop device with a regular
+ file or block device, and to query the status of a loop device. This
+ version does not currently support enabling data encryption.
+
+config BUSYBOX_CONFIG_LSPCI
+ bool "lspci"
+ default n
+ #select PLATFORM_LINUX
+ help
+ lspci is a utility for displaying information about PCI buses in the
+ system and devices connected to them.
+
+ This version uses sysfs (/sys/bus/pci/devices) only.
+
+config BUSYBOX_CONFIG_LSUSB
+ bool "lsusb"
+ default n
+ #select PLATFORM_LINUX
+ help
+ lsusb is a utility for displaying information about USB buses in the
+ system and devices connected to them.
+
+ This version uses sysfs (/sys/bus/usb/devices) only.
+
+config BUSYBOX_CONFIG_MDEV
+ bool "mdev"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ mdev is a mini-udev implementation for dynamically creating device
+ nodes in the /dev directory.
+
+ For more information, please see docs/mdev.txt
+
+config BUSYBOX_CONFIG_FEATURE_MDEV_CONF
+ bool "Support /etc/mdev.conf"
+ default n
+ depends on BUSYBOX_CONFIG_MDEV
+ help
+ Add support for the mdev config file to control ownership and
+ permissions of the device nodes.
+
+ For more information, please see docs/mdev.txt
+
+config BUSYBOX_CONFIG_FEATURE_MDEV_RENAME
+ bool "Support subdirs/symlinks"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_MDEV_CONF
+ help
+ Add support for renaming devices and creating symlinks.
+
+ For more information, please see docs/mdev.txt
+
+config BUSYBOX_CONFIG_FEATURE_MDEV_RENAME_REGEXP
+ bool "Support regular expressions substitutions when renaming device"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_MDEV_RENAME
+ help
+ Add support for regular expressions substitutions when renaming
+ device.
+
+config BUSYBOX_CONFIG_FEATURE_MDEV_EXEC
+ bool "Support command execution at device addition/removal"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_MDEV_CONF
+ help
+ This adds support for an optional field to /etc/mdev.conf for
+ executing commands when devices are created/removed.
+
+ For more information, please see docs/mdev.txt
+
+config BUSYBOX_CONFIG_FEATURE_MDEV_LOAD_FIRMWARE
+ bool "Support loading of firmwares"
+ default n
+ depends on BUSYBOX_CONFIG_MDEV
+ help
+ Some devices need to load firmware before they can be usable.
+
+ These devices will request userspace look up the files in
+ /lib/firmware/ and if it exists, send it to the kernel for
+ loading into the hardware.
+
+config BUSYBOX_CONFIG_MKSWAP
+ bool "mkswap"
+ default y
+ help
+ The mkswap utility is used to configure a file or disk partition as
+ Linux swap space. This allows Linux to use the entire file or
+ partition as if it were additional RAM, which can greatly increase
+ the capability of low-memory machines. This additional memory is
+ much slower than real RAM, but can be very helpful at preventing your
+ applications being killed by the Linux out of memory (OOM) killer.
+ Once you have created swap space using 'mkswap' you need to enable
+ the swap space using the 'swapon' utility.
+
+config BUSYBOX_CONFIG_FEATURE_MKSWAP_UUID
+ bool "UUID support"
+ default n
+ depends on BUSYBOX_CONFIG_MKSWAP
+ help
+ Generate swap spaces with universally unique identifiers.
+
+config BUSYBOX_CONFIG_MORE
+ bool "more"
+ default n
+ help
+ more is a simple utility which allows you to read text one screen
+ sized page at a time. If you want to read text that is larger than
+ the screen, and you are using anything faster than a 300 baud modem,
+ you will probably find this utility very helpful. If you don't have
+ any need to reading text files, you can leave this disabled.
+
+config BUSYBOX_CONFIG_MOUNT
+ bool "mount"
+ default y
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ All files and filesystems in Unix are arranged into one big directory
+ tree. The 'mount' utility is used to graft a filesystem onto a
+ particular part of the tree. A filesystem can either live on a block
+ device, or it can be accessible over the network, as is the case with
+ NFS filesystems. Most people using BusyBox will also want to enable
+ the 'mount' utility.
+
+config BUSYBOX_CONFIG_FEATURE_MOUNT_FAKE
+ bool "Support option -f"
+ default n
+ depends on BUSYBOX_CONFIG_MOUNT
+ help
+ Enable support for faking a file system mount.
+
+config BUSYBOX_CONFIG_FEATURE_MOUNT_VERBOSE
+ bool "Support option -v"
+ default n
+ depends on BUSYBOX_CONFIG_MOUNT
+ help
+ Enable multi-level -v[vv...] verbose messages. Useful if you
+ debug mount problems and want to see what is exactly passed
+ to the kernel.
+
+config BUSYBOX_CONFIG_FEATURE_MOUNT_HELPERS
+ bool "Support mount helpers"
+ default y
+ depends on BUSYBOX_CONFIG_MOUNT
+ help
+ Enable mounting of virtual file systems via external helpers.
+ E.g. "mount obexfs#-b00.11.22.33.44.55 /mnt" will in effect call
+ "obexfs -b00.11.22.33.44.55 /mnt"
+ Also "mount -t sometype [-o opts] fs /mnt" will try
+ "sometype [-o opts] fs /mnt" if simple mount syscall fails.
+ The idea is to use such virtual filesystems in /etc/fstab.
+
+config BUSYBOX_CONFIG_FEATURE_MOUNT_LABEL
+ bool "Support specifying devices by label or UUID"
+ default n
+ depends on BUSYBOX_CONFIG_MOUNT
+ select BUSYBOX_CONFIG_VOLUMEID
+ help
+ This allows for specifying a device by label or uuid, rather than by
+ name. This feature utilizes the same functionality as blkid/findfs.
+ This also enables label or uuid support for swapon.
+
+config BUSYBOX_CONFIG_FEATURE_MOUNT_NFS
+ bool "Support mounting NFS file systems"
+ default n
+ depends on BUSYBOX_CONFIG_MOUNT
+ select BUSYBOX_CONFIG_FEATURE_HAVE_RPC
+ select BUSYBOX_CONFIG_FEATURE_SYSLOG
+ help
+ Enable mounting of NFS file systems.
+
+config BUSYBOX_CONFIG_FEATURE_MOUNT_CIFS
+ bool "Support mounting CIFS/SMB file systems"
+ default y
+ depends on BUSYBOX_CONFIG_MOUNT
+ help
+ Enable support for samba mounts.
+
+config BUSYBOX_CONFIG_FEATURE_MOUNT_FLAGS
+ depends on BUSYBOX_CONFIG_MOUNT
+ bool "Support lots of -o flags in mount"
+ default y
+ help
+ Without this, mount only supports ro/rw/remount. With this, it
+ supports nosuid, suid, dev, nodev, exec, noexec, sync, async, atime,
+ noatime, diratime, nodiratime, loud, bind, move, shared, slave,
+ private, unbindable, rshared, rslave, rprivate, and runbindable.
+
+config BUSYBOX_CONFIG_FEATURE_MOUNT_FSTAB
+ depends on BUSYBOX_CONFIG_MOUNT
+ bool "Support /etc/fstab and -a"
+ default y
+ help
+ Support mount all and looking for files in /etc/fstab.
+
+config BUSYBOX_CONFIG_PIVOT_ROOT
+ bool "pivot_root"
+ default y
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ The pivot_root utility swaps the mount points for the root filesystem
+ with some other mounted filesystem. This allows you to do all sorts
+ of wild and crazy things with your Linux system and is far more
+ powerful than 'chroot'.
+
+ Note: This is for initrd in linux 2.4. Under initramfs (introduced
+ in linux 2.6) use switch_root instead.
+
+config BUSYBOX_CONFIG_RDATE
+ bool "rdate"
+ default n
+ help
+ The rdate utility allows you to synchronize the date and time of your
+ system clock with the date and time of a remote networked system using
+ the RFC868 protocol, which is built into the inetd daemon on most
+ systems.
+
+config BUSYBOX_CONFIG_RDEV
+ bool "rdev"
+ default n
+ help
+ Print the device node associated with the filesystem mounted at '/'.
+
+config BUSYBOX_CONFIG_READPROFILE
+ bool "readprofile"
+ default n
+ #select PLATFORM_LINUX
+ help
+ This allows you to parse /proc/profile for basic profiling.
+
+config BUSYBOX_CONFIG_RTCWAKE
+ bool "rtcwake"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Enter a system sleep state until specified wakeup time.
+
+config BUSYBOX_CONFIG_SCRIPT
+ bool "script"
+ default n
+ help
+ The script makes typescript of terminal session.
+
+config BUSYBOX_CONFIG_SCRIPTREPLAY
+ bool "scriptreplay"
+ default n
+ help
+ This program replays a typescript, using timing information
+ given by script -t.
+
+config BUSYBOX_CONFIG_SETARCH
+ bool "setarch"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ The linux32 utility is used to create a 32bit environment for the
+ specified program (usually a shell). It only makes sense to have
+ this util on a system that supports both 64bit and 32bit userland
+ (like amd64/x86, ppc64/ppc, sparc64/sparc, etc...).
+
+config BUSYBOX_CONFIG_SWAPONOFF
+ bool "swaponoff"
+ default y
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ This option enables both the 'swapon' and the 'swapoff' utilities.
+ Once you have created some swap space using 'mkswap', you also need
+ to enable your swap space with the 'swapon' utility. The 'swapoff'
+ utility is used, typically at system shutdown, to disable any swap
+ space. If you are not using any swap space, you can leave this
+ option disabled.
+
+config BUSYBOX_CONFIG_FEATURE_SWAPON_PRI
+ bool "Support priority option -p"
+ default n
+ depends on BUSYBOX_CONFIG_SWAPONOFF
+ help
+ Enable support for setting swap device priority in swapon.
+
+config BUSYBOX_CONFIG_SWITCH_ROOT
+ bool "switch_root"
+ default y
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ The switch_root utility is used from initramfs to select a new
+ root device. Under initramfs, you have to use this instead of
+ pivot_root. (Stop reading here if you don't care why.)
+
+ Booting with initramfs extracts a gzipped cpio archive into rootfs
+ (which is a variant of ramfs/tmpfs). Because rootfs can't be moved
+ or unmounted*, pivot_root will not work from initramfs. Instead,
+ switch_root deletes everything out of rootfs (including itself),
+ does a mount --move that overmounts rootfs with the new root, and
+ then execs the specified init program.
+
+ * Because the Linux kernel uses rootfs internally as the starting
+ and ending point for searching through the kernel's doubly linked
+ list of active mount points. That's why.
+
+config BUSYBOX_CONFIG_UMOUNT
+ bool "umount"
+ default y
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ When you want to remove a mounted filesystem from its current mount
+ point, for example when you are shutting down the system, the
+ 'umount' utility is the tool to use. If you enabled the 'mount'
+ utility, you almost certainly also want to enable 'umount'.
+
+config BUSYBOX_CONFIG_FEATURE_UMOUNT_ALL
+ bool "Support option -a"
+ default y
+ depends on BUSYBOX_CONFIG_UMOUNT
+ help
+ Support -a option to unmount all currently mounted filesystems.
+
+comment "Common options for mount/umount"
+ depends on BUSYBOX_CONFIG_MOUNT || BUSYBOX_CONFIG_UMOUNT
+
+config BUSYBOX_CONFIG_FEATURE_MOUNT_LOOP
+ bool "Support loopback mounts"
+ default y
+ depends on BUSYBOX_CONFIG_MOUNT || BUSYBOX_CONFIG_UMOUNT
+ help
+ Enabling this feature allows automatic mounting of files (containing
+ filesystem images) via the linux kernel's loopback devices.
+ The mount command will detect you are trying to mount a file instead
+ of a block device, and transparently associate the file with a
+ loopback device. The umount command will also free that loopback
+ device.
+
+ You can still use the 'losetup' utility (to manually associate files
+ with loop devices) if you need to do something advanced, such as
+ specify an offset or cryptographic options to the loopback device.
+ (If you don't want umount to free the loop device, use "umount -D".)
+
+config BUSYBOX_CONFIG_FEATURE_MOUNT_LOOP_CREATE
+ bool "Create new loopback devices if needed"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_MOUNT_LOOP
+ help
+ Linux kernels >= 2.6.24 support unlimited loopback devices. They are
+ allocated for use when trying to use a loop device. The loop device
+ must however exist.
+
+ This feature lets mount to try to create next /dev/loopN device
+ if it does not find a free one.
+
+config BUSYBOX_CONFIG_FEATURE_MTAB_SUPPORT
+ bool "Support for the old /etc/mtab file"
+ default n
+ depends on BUSYBOX_CONFIG_MOUNT || BUSYBOX_CONFIG_UMOUNT
+ select BUSYBOX_CONFIG_FEATURE_MOUNT_FAKE
+ help
+ Historically, Unix systems kept track of the currently mounted
+ partitions in the file "/etc/mtab". These days, the kernel exports
+ the list of currently mounted partitions in "/proc/mounts", rendering
+ the old mtab file obsolete. (In modern systems, /etc/mtab should be
+ a symlink to /proc/mounts.)
+
+ The only reason to have mount maintain an /etc/mtab file itself is if
+ your stripped-down embedded system does not have a /proc directory.
+ If you must use this, keep in mind it's inherently brittle (for
+ example a mount under chroot won't update it), can't handle modern
+ features like separate per-process filesystem namespaces, requires
+ that your /etc directory be writable, tends to get easily confused
+ by --bind or --move mounts, won't update if you rename a directory
+ that contains a mount point, and so on. (In brief: avoid.)
+
+ About the only reason to use this is if you've removed /proc from
+ your kernel.
+
+config BUSYBOX_CONFIG_VOLUMEID
+ bool #No description makes it a hidden option
+ default n
+
+menu "Filesystem/Volume identification"
+ depends on BUSYBOX_CONFIG_VOLUMEID
+
+config BUSYBOX_CONFIG_FEATURE_VOLUMEID_EXT
+ bool "Ext filesystem"
+ default n
+ depends on BUSYBOX_CONFIG_VOLUMEID
+ help
+ TODO
+
+config BUSYBOX_CONFIG_FEATURE_VOLUMEID_BTRFS
+ bool "btrfs filesystem"
+ default n
+ depends on BUSYBOX_CONFIG_VOLUMEID
+ help
+ TODO
+
+config BUSYBOX_CONFIG_FEATURE_VOLUMEID_REISERFS
+ bool "Reiser filesystem"
+ default n
+ depends on BUSYBOX_CONFIG_VOLUMEID
+ help
+ TODO
+
+config BUSYBOX_CONFIG_FEATURE_VOLUMEID_FAT
+ bool "fat filesystem"
+ default n
+ depends on BUSYBOX_CONFIG_VOLUMEID
+ help
+ TODO
+
+config BUSYBOX_CONFIG_FEATURE_VOLUMEID_HFS
+ bool "hfs filesystem"
+ default n
+ depends on BUSYBOX_CONFIG_VOLUMEID
+ help
+ TODO
+
+config BUSYBOX_CONFIG_FEATURE_VOLUMEID_JFS
+ bool "jfs filesystem"
+ default n
+ depends on BUSYBOX_CONFIG_VOLUMEID
+ help
+ TODO
+
+### config FEATURE_VOLUMEID_UFS
+### bool "ufs filesystem"
+### default y
+### depends on VOLUMEID
+### help
+### TODO
+
+config BUSYBOX_CONFIG_FEATURE_VOLUMEID_XFS
+ bool "xfs filesystem"
+ default n
+ depends on BUSYBOX_CONFIG_VOLUMEID
+ help
+ TODO
+
+config BUSYBOX_CONFIG_FEATURE_VOLUMEID_NTFS
+ bool "ntfs filesystem"
+ default n
+ depends on BUSYBOX_CONFIG_VOLUMEID
+ help
+ TODO
+
+config BUSYBOX_CONFIG_FEATURE_VOLUMEID_ISO9660
+ bool "iso9660 filesystem"
+ default n
+ depends on BUSYBOX_CONFIG_VOLUMEID
+ help
+ TODO
+
+config BUSYBOX_CONFIG_FEATURE_VOLUMEID_UDF
+ bool "udf filesystem"
+ default n
+ depends on BUSYBOX_CONFIG_VOLUMEID
+ help
+ TODO
+
+config BUSYBOX_CONFIG_FEATURE_VOLUMEID_LUKS
+ bool "luks filesystem"
+ default n
+ depends on BUSYBOX_CONFIG_VOLUMEID
+ help
+ TODO
+
+config BUSYBOX_CONFIG_FEATURE_VOLUMEID_LINUXSWAP
+ bool "linux swap filesystem"
+ default n
+ depends on BUSYBOX_CONFIG_VOLUMEID
+ help
+ TODO
+
+### config FEATURE_VOLUMEID_LVM
+### bool "lvm"
+### default y
+### depends on VOLUMEID
+### help
+### TODO
+
+config BUSYBOX_CONFIG_FEATURE_VOLUMEID_CRAMFS
+ bool "cramfs filesystem"
+ default n
+ depends on BUSYBOX_CONFIG_VOLUMEID
+ help
+ TODO
+
+### config FEATURE_VOLUMEID_HPFS
+### bool "hpfs filesystem"
+### default y
+### depends on VOLUMEID
+### help
+### TODO
+
+config BUSYBOX_CONFIG_FEATURE_VOLUMEID_ROMFS
+ bool "romfs filesystem"
+ default n
+ depends on BUSYBOX_CONFIG_VOLUMEID
+ help
+ TODO
+
+config BUSYBOX_CONFIG_FEATURE_VOLUMEID_SYSV
+ bool "sysv filesystem"
+ default n
+ depends on BUSYBOX_CONFIG_VOLUMEID
+ help
+ TODO
+
+### config FEATURE_VOLUMEID_MINIX
+### bool "minix filesystem"
+### default y
+### depends on VOLUMEID
+### help
+### TODO
+
+### These only detect partition tables - not used (yet?)
+### config FEATURE_VOLUMEID_MAC
+### bool "mac filesystem"
+### default y
+### depends on VOLUMEID
+### help
+### TODO
+###
+### config FEATURE_VOLUMEID_MSDOS
+### bool "msdos filesystem"
+### default y
+### depends on VOLUMEID
+### help
+### TODO
+
+config BUSYBOX_CONFIG_FEATURE_VOLUMEID_OCFS2
+ bool "ocfs2 filesystem"
+ default n
+ depends on BUSYBOX_CONFIG_VOLUMEID
+ help
+ TODO
+
+### config FEATURE_VOLUMEID_HIGHPOINTRAID
+### bool "highpoint raid"
+### default y
+### depends on VOLUMEID
+### help
+### TODO
+
+### config FEATURE_VOLUMEID_ISWRAID
+### bool "intel raid"
+### default y
+### depends on VOLUMEID
+### help
+### TODO
+
+### config FEATURE_VOLUMEID_LSIRAID
+### bool "lsi raid"
+### default y
+### depends on VOLUMEID
+### help
+### TODO
+
+### config FEATURE_VOLUMEID_VIARAID
+### bool "via raid"
+### default y
+### depends on VOLUMEID
+### help
+### TODO
+
+### config FEATURE_VOLUMEID_SILICONRAID
+### bool "silicon raid"
+### default y
+### depends on VOLUMEID
+### help
+### TODO
+
+### config FEATURE_VOLUMEID_NVIDIARAID
+### bool "nvidia raid"
+### default y
+### depends on VOLUMEID
+### help
+### TODO
+
+### config FEATURE_VOLUMEID_PROMISERAID
+### bool "promise raid"
+### default y
+### depends on VOLUMEID
+### help
+### TODO
+
+config BUSYBOX_CONFIG_FEATURE_VOLUMEID_LINUXRAID
+ bool "linuxraid"
+ default n
+ depends on BUSYBOX_CONFIG_VOLUMEID
+ help
+ TODO
+
+endmenu
+
+endmenu
diff --git a/package/busybox/config/util-linux/Config.in b/package/busybox/config/util-linux/Config.in
new file mode 100644
index 0000000..d60b139
--- /dev/null
+++ b/package/busybox/config/util-linux/Config.in
@@ -0,0 +1,985 @@
+# DO NOT EDIT. This file is generated from Config.src
+#
+# For a description of the syntax of this configuration file,
+# see scripts/kbuild/config-language.txt.
+#
+
+menu "Linux System Utilities"
+
+config BUSYBOX_CONFIG_BLOCKDEV
+ bool "blockdev"
+ default n
+ help
+ Performs some ioctls with block devices.
+config BUSYBOX_CONFIG_REV
+ bool "rev"
+ default n
+ help
+ Reverse lines of a file or files.
+
+config BUSYBOX_CONFIG_ACPID
+ bool "acpid"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ acpid listens to ACPI events coming either in textual form from
+ /proc/acpi/event (though it is marked deprecated it is still widely
+ used and _is_ a standard) or in binary form from specified evdevs
+ (just use /dev/input/event*).
+
+ It parses the event to retrieve ACTION and a possible PARAMETER.
+ It then spawns /etc/acpi/<ACTION>[/<PARAMETER>] either via run-parts
+ (if the resulting path is a directory) or directly as an executable.
+
+ N.B. acpid relies on run-parts so have the latter installed.
+
+config BUSYBOX_CONFIG_FEATURE_ACPID_COMPAT
+ bool "Accept and ignore redundant options"
+ default n
+ depends on BUSYBOX_CONFIG_ACPID
+ help
+ Accept and ignore compatibility options -g -m -s -S -v.
+
+config BUSYBOX_CONFIG_BLKID
+ bool "blkid"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ select BUSYBOX_CONFIG_VOLUMEID
+ help
+ Lists labels and UUIDs of all filesystems.
+ WARNING:
+ With all submodules selected, it will add ~8k to busybox.
+
+config BUSYBOX_CONFIG_FEATURE_BLKID_TYPE
+ bool "Print filesystem type"
+ default n
+ depends on BUSYBOX_CONFIG_BLKID
+ help
+ Show TYPE="filesystem type"
+
+config BUSYBOX_CONFIG_DMESG
+ bool "dmesg"
+ default y
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ dmesg is used to examine or control the kernel ring buffer. When the
+ Linux kernel prints messages to the system log, they are stored in
+ the kernel ring buffer. You can use dmesg to print the kernel's ring
+ buffer, clear the kernel ring buffer, change the size of the kernel
+ ring buffer, and change the priority level at which kernel messages
+ are also logged to the system console. Enable this option if you
+ wish to enable the 'dmesg' utility.
+
+config BUSYBOX_CONFIG_FEATURE_DMESG_PRETTY
+ bool "Pretty dmesg output"
+ default y
+ depends on BUSYBOX_CONFIG_DMESG
+ help
+ If you wish to scrub the syslog level from the output, say 'Y' here.
+ The syslog level is a string prefixed to every line with the form
+ "<#>".
+
+ With this option you will see:
+ # dmesg
+ Linux version 2.6.17.4 .....
+ BIOS-provided physical RAM map:
+ BIOS-e820: 0000000000000000 - 000000000009f000 (usable)
+
+ Without this option you will see:
+ # dmesg
+ <5>Linux version 2.6.17.4 .....
+ <6>BIOS-provided physical RAM map:
+ <6> BIOS-e820: 0000000000000000 - 000000000009f000 (usable)
+
+config BUSYBOX_CONFIG_FBSET
+ bool "fbset"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ fbset is used to show or change the settings of a Linux frame buffer
+ device. The frame buffer device provides a simple and unique
+ interface to access a graphics display. Enable this option
+ if you wish to enable the 'fbset' utility.
+
+config BUSYBOX_CONFIG_FEATURE_FBSET_FANCY
+ bool "Turn on extra fbset options"
+ default n
+ depends on BUSYBOX_CONFIG_FBSET
+ help
+ This option enables extended fbset options, allowing one to set the
+ framebuffer size, color depth, etc. interface to access a graphics
+ display. Enable this option if you wish to enable extended fbset
+ options.
+
+config BUSYBOX_CONFIG_FEATURE_FBSET_READMODE
+ bool "Turn on fbset readmode support"
+ default n
+ depends on BUSYBOX_CONFIG_FBSET
+ help
+ This option allows fbset to read the video mode database stored by
+ default n /etc/fb.modes, which can be used to set frame buffer
+ device to pre-defined video modes.
+
+config BUSYBOX_CONFIG_FDFLUSH
+ bool "fdflush"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ fdflush is only needed when changing media on slightly-broken
+ removable media drives. It is used to make Linux believe that a
+ hardware disk-change switch has been actuated, which causes Linux to
+ forget anything it has cached from the previous media. If you have
+ such a slightly-broken drive, you will need to run fdflush every time
+ you change a disk. Most people have working hardware and can safely
+ leave this disabled.
+
+config BUSYBOX_CONFIG_FDFORMAT
+ bool "fdformat"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ fdformat is used to low-level format a floppy disk.
+
+config BUSYBOX_CONFIG_FDISK
+ bool "fdisk"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ The fdisk utility is used to divide hard disks into one or more
+ logical disks, which are generally called partitions. This utility
+ can be used to list and edit the set of partitions or BSD style
+ 'disk slices' that are defined on a hard drive.
+
+config BUSYBOX_CONFIG_FDISK_SUPPORT_LARGE_DISKS
+ bool "Support over 4GB disks"
+ default y
+ depends on BUSYBOX_CONFIG_FDISK
+ depends on !BUSYBOX_CONFIG_LFS # with LFS no special code is needed
+ help
+ Enable this option to support large disks > 4GB.
+
+config BUSYBOX_CONFIG_FEATURE_FDISK_WRITABLE
+ bool "Write support"
+ default n
+ depends on BUSYBOX_CONFIG_FDISK
+ help
+ Enabling this option allows you to create or change a partition table
+ and write those changes out to disk. If you leave this option
+ disabled, you will only be able to view the partition table.
+
+config BUSYBOX_CONFIG_FEATURE_AIX_LABEL
+ bool "Support AIX disklabels"
+ default n
+ depends on BUSYBOX_CONFIG_FDISK && BUSYBOX_CONFIG_FEATURE_FDISK_WRITABLE
+ help
+ Enabling this option allows you to create or change AIX disklabels.
+ Most people can safely leave this option disabled.
+
+config BUSYBOX_CONFIG_FEATURE_SGI_LABEL
+ bool "Support SGI disklabels"
+ default n
+ depends on BUSYBOX_CONFIG_FDISK && BUSYBOX_CONFIG_FEATURE_FDISK_WRITABLE
+ help
+ Enabling this option allows you to create or change SGI disklabels.
+ Most people can safely leave this option disabled.
+
+config BUSYBOX_CONFIG_FEATURE_SUN_LABEL
+ bool "Support SUN disklabels"
+ default n
+ depends on BUSYBOX_CONFIG_FDISK && BUSYBOX_CONFIG_FEATURE_FDISK_WRITABLE
+ help
+ Enabling this option allows you to create or change SUN disklabels.
+ Most people can safely leave this option disabled.
+
+config BUSYBOX_CONFIG_FEATURE_OSF_LABEL
+ bool "Support BSD disklabels"
+ default n
+ depends on BUSYBOX_CONFIG_FDISK && BUSYBOX_CONFIG_FEATURE_FDISK_WRITABLE
+ help
+ Enabling this option allows you to create or change BSD disklabels
+ and define and edit BSD disk slices.
+
+config BUSYBOX_CONFIG_FEATURE_GPT_LABEL
+ bool "Support GPT disklabels"
+ default n
+ depends on BUSYBOX_CONFIG_FDISK && BUSYBOX_CONFIG_FEATURE_FDISK_WRITABLE
+ help
+ Enabling this option allows you to view GUID Partition Table
+ disklabels.
+
+config BUSYBOX_CONFIG_FEATURE_FDISK_ADVANCED
+ bool "Support expert mode"
+ default n
+ depends on BUSYBOX_CONFIG_FDISK && BUSYBOX_CONFIG_FEATURE_FDISK_WRITABLE
+ help
+ Enabling this option allows you to do terribly unsafe things like
+ define arbitrary drive geometry, move the beginning of data in a
+ partition, and similarly evil things. Unless you have a very good
+ reason you would be wise to leave this disabled.
+
+config BUSYBOX_CONFIG_FINDFS
+ bool "findfs"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ select BUSYBOX_CONFIG_VOLUMEID
+ help
+ Prints the name of a filesystem with given label or UUID.
+ WARNING:
+ With all submodules selected, it will add ~8k to busybox.
+
+config BUSYBOX_CONFIG_FLOCK
+ bool "flock"
+ default n
+ help
+ Manage locks from shell scripts
+
+config BUSYBOX_CONFIG_FREERAMDISK
+ bool "freeramdisk"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Linux allows you to create ramdisks. This utility allows you to
+ delete them and completely free all memory that was used for the
+ ramdisk. For example, if you boot Linux into a ramdisk and later
+ pivot_root, you may want to free the memory that is allocated to the
+ ramdisk. If you have no use for freeing memory from a ramdisk, leave
+ this disabled.
+
+config BUSYBOX_CONFIG_FSCK_MINIX
+ bool "fsck_minix"
+ default n
+ help
+ The minix filesystem is a nice, small, compact, read-write filesystem
+ with little overhead. It is not a journaling filesystem however and
+ can experience corruption if it is not properly unmounted or if the
+ power goes off in the middle of a write. This utility allows you to
+ check for and attempt to repair any corruption that occurs to a minix
+ filesystem.
+
+config BUSYBOX_CONFIG_MKFS_EXT2
+ bool "mkfs_ext2"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Utility to create EXT2 filesystems.
+
+config BUSYBOX_CONFIG_MKFS_MINIX
+ bool "mkfs_minix"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ The minix filesystem is a nice, small, compact, read-write filesystem
+ with little overhead. If you wish to be able to create minix
+ filesystems this utility will do the job for you.
+
+config BUSYBOX_CONFIG_FEATURE_MINIX2
+ bool "Support Minix fs v2 (fsck_minix/mkfs_minix)"
+ default n
+ depends on BUSYBOX_CONFIG_FSCK_MINIX || BUSYBOX_CONFIG_MKFS_MINIX
+ help
+ If you wish to be able to create version 2 minix filesystems, enable
+ this. If you enabled 'mkfs_minix' then you almost certainly want to
+ be using the version 2 filesystem support.
+
+config BUSYBOX_CONFIG_MKFS_REISER
+ bool "mkfs_reiser"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Utility to create ReiserFS filesystems.
+ Note: this applet needs a lot of testing and polishing.
+
+config BUSYBOX_CONFIG_MKFS_VFAT
+ bool "mkfs_vfat"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Utility to create FAT32 filesystems.
+
+config BUSYBOX_CONFIG_GETOPT
+ bool "getopt"
+ default n
+ help
+ The getopt utility is used to break up (parse) options in command
+ lines to make it easy to write complex shell scripts that also check
+ for legal (and illegal) options. If you want to write horribly
+ complex shell scripts, or use some horribly complex shell script
+ written by others, this utility may be for you. Most people will
+ wisely leave this disabled.
+
+config BUSYBOX_CONFIG_FEATURE_GETOPT_LONG
+ bool "Support option -l"
+ default n if BUSYBOX_CONFIG_LONG_OPTS
+ depends on BUSYBOX_CONFIG_GETOPT
+ help
+ Enable support for long options (option -l).
+
+config BUSYBOX_CONFIG_HEXDUMP
+ bool "hexdump"
+ default y
+ help
+ The hexdump utility is used to display binary data in a readable
+ way that is comparable to the output from most hex editors.
+
+config BUSYBOX_CONFIG_FEATURE_HEXDUMP_REVERSE
+ bool "Support -R, reverse of 'hexdump -Cv'"
+ default n
+ depends on BUSYBOX_CONFIG_HEXDUMP
+ help
+ The hexdump utility is used to display binary data in an ascii
+ readable way. This option creates binary data from an ascii input.
+ NB: this option is non-standard. It's unwise to use it in scripts
+ aimed to be portable.
+
+config BUSYBOX_CONFIG_HD
+ bool "hd"
+ default n
+ depends on BUSYBOX_CONFIG_HEXDUMP
+ help
+ hd is an alias to hexdump -C.
+
+config BUSYBOX_CONFIG_HWCLOCK
+ bool "hwclock"
+ default y
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ The hwclock utility is used to read and set the hardware clock
+ on a system. This is primarily used to set the current time on
+ shutdown in the hardware clock, so the hardware will keep the
+ correct time when Linux is _not_ running.
+
+config BUSYBOX_CONFIG_FEATURE_HWCLOCK_LONG_OPTIONS
+ bool "Support long options (--hctosys,...)"
+ default n
+ depends on BUSYBOX_CONFIG_HWCLOCK && BUSYBOX_CONFIG_LONG_OPTS
+ help
+ By default, the hwclock utility only uses short options. If you
+ are overly fond of its long options, such as --hctosys, --utc, etc)
+ then enable this option.
+
+config BUSYBOX_CONFIG_FEATURE_HWCLOCK_ADJTIME_FHS
+ bool "Use FHS /var/lib/hwclock/adjtime"
+ default n # util-linux-ng in Fedora 13 still uses /etc/adjtime
+ depends on BUSYBOX_CONFIG_HWCLOCK
+ help
+ Starting with FHS 2.3, the adjtime state file is supposed to exist
+ at /var/lib/hwclock/adjtime instead of /etc/adjtime. If you wish
+ to use the FHS behavior, answer Y here, otherwise answer N for the
+ classic /etc/adjtime path.
+
+ pathname.com/fhs/pub/fhs-2.3.html#VARLIBHWCLOCKSTATEDIRECTORYFORHWCLO
+
+config BUSYBOX_CONFIG_IPCRM
+ bool "ipcrm"
+ default n
+ help
+ The ipcrm utility allows the removal of System V interprocess
+ communication (IPC) objects and the associated data structures
+ from the system.
+
+config BUSYBOX_CONFIG_IPCS
+ bool "ipcs"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ The ipcs utility is used to provide information on the currently
+ allocated System V interprocess (IPC) objects in the system.
+
+config BUSYBOX_CONFIG_LOSETUP
+ bool "losetup"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ losetup is used to associate or detach a loop device with a regular
+ file or block device, and to query the status of a loop device. This
+ version does not currently support enabling data encryption.
+
+config BUSYBOX_CONFIG_LSPCI
+ bool "lspci"
+ default n
+ #select PLATFORM_LINUX
+ help
+ lspci is a utility for displaying information about PCI buses in the
+ system and devices connected to them.
+
+ This version uses sysfs (/sys/bus/pci/devices) only.
+
+config BUSYBOX_CONFIG_LSUSB
+ bool "lsusb"
+ default n
+ #select PLATFORM_LINUX
+ help
+ lsusb is a utility for displaying information about USB buses in the
+ system and devices connected to them.
+
+ This version uses sysfs (/sys/bus/usb/devices) only.
+
+config BUSYBOX_CONFIG_MDEV
+ bool "mdev"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ mdev is a mini-udev implementation for dynamically creating device
+ nodes in the /dev directory.
+
+ For more information, please see docs/mdev.txt
+
+config BUSYBOX_CONFIG_FEATURE_MDEV_CONF
+ bool "Support /etc/mdev.conf"
+ default n
+ depends on BUSYBOX_CONFIG_MDEV
+ help
+ Add support for the mdev config file to control ownership and
+ permissions of the device nodes.
+
+ For more information, please see docs/mdev.txt
+
+config BUSYBOX_CONFIG_FEATURE_MDEV_RENAME
+ bool "Support subdirs/symlinks"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_MDEV_CONF
+ help
+ Add support for renaming devices and creating symlinks.
+
+ For more information, please see docs/mdev.txt
+
+config BUSYBOX_CONFIG_FEATURE_MDEV_RENAME_REGEXP
+ bool "Support regular expressions substitutions when renaming device"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_MDEV_RENAME
+ help
+ Add support for regular expressions substitutions when renaming
+ device.
+
+config BUSYBOX_CONFIG_FEATURE_MDEV_EXEC
+ bool "Support command execution at device addition/removal"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_MDEV_CONF
+ help
+ This adds support for an optional field to /etc/mdev.conf for
+ executing commands when devices are created/removed.
+
+ For more information, please see docs/mdev.txt
+
+config BUSYBOX_CONFIG_FEATURE_MDEV_LOAD_FIRMWARE
+ bool "Support loading of firmwares"
+ default n
+ depends on BUSYBOX_CONFIG_MDEV
+ help
+ Some devices need to load firmware before they can be usable.
+
+ These devices will request userspace look up the files in
+ /lib/firmware/ and if it exists, send it to the kernel for
+ loading into the hardware.
+
+config BUSYBOX_CONFIG_MKSWAP
+ bool "mkswap"
+ default y
+ help
+ The mkswap utility is used to configure a file or disk partition as
+ Linux swap space. This allows Linux to use the entire file or
+ partition as if it were additional RAM, which can greatly increase
+ the capability of low-memory machines. This additional memory is
+ much slower than real RAM, but can be very helpful at preventing your
+ applications being killed by the Linux out of memory (OOM) killer.
+ Once you have created swap space using 'mkswap' you need to enable
+ the swap space using the 'swapon' utility.
+
+config BUSYBOX_CONFIG_FEATURE_MKSWAP_UUID
+ bool "UUID support"
+ default n
+ depends on BUSYBOX_CONFIG_MKSWAP
+ help
+ Generate swap spaces with universally unique identifiers.
+
+config BUSYBOX_CONFIG_MORE
+ bool "more"
+ default n
+ help
+ more is a simple utility which allows you to read text one screen
+ sized page at a time. If you want to read text that is larger than
+ the screen, and you are using anything faster than a 300 baud modem,
+ you will probably find this utility very helpful. If you don't have
+ any need to reading text files, you can leave this disabled.
+
+config BUSYBOX_CONFIG_MOUNT
+ bool "mount"
+ default y
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ All files and filesystems in Unix are arranged into one big directory
+ tree. The 'mount' utility is used to graft a filesystem onto a
+ particular part of the tree. A filesystem can either live on a block
+ device, or it can be accessible over the network, as is the case with
+ NFS filesystems. Most people using BusyBox will also want to enable
+ the 'mount' utility.
+
+config BUSYBOX_CONFIG_FEATURE_MOUNT_FAKE
+ bool "Support option -f"
+ default n
+ depends on BUSYBOX_CONFIG_MOUNT
+ help
+ Enable support for faking a file system mount.
+
+config BUSYBOX_CONFIG_FEATURE_MOUNT_VERBOSE
+ bool "Support option -v"
+ default n
+ depends on BUSYBOX_CONFIG_MOUNT
+ help
+ Enable multi-level -v[vv...] verbose messages. Useful if you
+ debug mount problems and want to see what is exactly passed
+ to the kernel.
+
+config BUSYBOX_CONFIG_FEATURE_MOUNT_HELPERS
+ bool "Support mount helpers"
+ default y
+ depends on BUSYBOX_CONFIG_MOUNT
+ help
+ Enable mounting of virtual file systems via external helpers.
+ E.g. "mount obexfs#-b00.11.22.33.44.55 /mnt" will in effect call
+ "obexfs -b00.11.22.33.44.55 /mnt"
+ Also "mount -t sometype [-o opts] fs /mnt" will try
+ "sometype [-o opts] fs /mnt" if simple mount syscall fails.
+ The idea is to use such virtual filesystems in /etc/fstab.
+
+config BUSYBOX_CONFIG_FEATURE_MOUNT_LABEL
+ bool "Support specifying devices by label or UUID"
+ default n
+ depends on BUSYBOX_CONFIG_MOUNT
+ select BUSYBOX_CONFIG_VOLUMEID
+ help
+ This allows for specifying a device by label or uuid, rather than by
+ name. This feature utilizes the same functionality as blkid/findfs.
+ This also enables label or uuid support for swapon.
+
+config BUSYBOX_CONFIG_FEATURE_MOUNT_NFS
+ bool "Support mounting NFS file systems"
+ default n
+ depends on BUSYBOX_CONFIG_MOUNT
+ select BUSYBOX_CONFIG_FEATURE_HAVE_RPC
+ select BUSYBOX_CONFIG_FEATURE_SYSLOG
+ help
+ Enable mounting of NFS file systems.
+
+config BUSYBOX_CONFIG_FEATURE_MOUNT_CIFS
+ bool "Support mounting CIFS/SMB file systems"
+ default y
+ depends on BUSYBOX_CONFIG_MOUNT
+ help
+ Enable support for samba mounts.
+
+config BUSYBOX_CONFIG_FEATURE_MOUNT_FLAGS
+ depends on BUSYBOX_CONFIG_MOUNT
+ bool "Support lots of -o flags in mount"
+ default y
+ help
+ Without this, mount only supports ro/rw/remount. With this, it
+ supports nosuid, suid, dev, nodev, exec, noexec, sync, async, atime,
+ noatime, diratime, nodiratime, loud, bind, move, shared, slave,
+ private, unbindable, rshared, rslave, rprivate, and runbindable.
+
+config BUSYBOX_CONFIG_FEATURE_MOUNT_FSTAB
+ depends on BUSYBOX_CONFIG_MOUNT
+ bool "Support /etc/fstab and -a"
+ default y
+ help
+ Support mount all and looking for files in /etc/fstab.
+
+config BUSYBOX_CONFIG_PIVOT_ROOT
+ bool "pivot_root"
+ default y
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ The pivot_root utility swaps the mount points for the root filesystem
+ with some other mounted filesystem. This allows you to do all sorts
+ of wild and crazy things with your Linux system and is far more
+ powerful than 'chroot'.
+
+ Note: This is for initrd in linux 2.4. Under initramfs (introduced
+ in linux 2.6) use switch_root instead.
+
+config BUSYBOX_CONFIG_RDATE
+ bool "rdate"
+ default n
+ help
+ The rdate utility allows you to synchronize the date and time of your
+ system clock with the date and time of a remote networked system using
+ the RFC868 protocol, which is built into the inetd daemon on most
+ systems.
+
+config BUSYBOX_CONFIG_RDEV
+ bool "rdev"
+ default n
+ help
+ Print the device node associated with the filesystem mounted at '/'.
+
+config BUSYBOX_CONFIG_READPROFILE
+ bool "readprofile"
+ default n
+ #select PLATFORM_LINUX
+ help
+ This allows you to parse /proc/profile for basic profiling.
+
+config BUSYBOX_CONFIG_RTCWAKE
+ bool "rtcwake"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ Enter a system sleep state until specified wakeup time.
+
+config BUSYBOX_CONFIG_SCRIPT
+ bool "script"
+ default n
+ help
+ The script makes typescript of terminal session.
+
+config BUSYBOX_CONFIG_SCRIPTREPLAY
+ bool "scriptreplay"
+ default n
+ help
+ This program replays a typescript, using timing information
+ given by script -t.
+
+config BUSYBOX_CONFIG_SETARCH
+ bool "setarch"
+ default n
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ The linux32 utility is used to create a 32bit environment for the
+ specified program (usually a shell). It only makes sense to have
+ this util on a system that supports both 64bit and 32bit userland
+ (like amd64/x86, ppc64/ppc, sparc64/sparc, etc...).
+
+config BUSYBOX_CONFIG_SWAPONOFF
+ bool "swaponoff"
+ default y
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ This option enables both the 'swapon' and the 'swapoff' utilities.
+ Once you have created some swap space using 'mkswap', you also need
+ to enable your swap space with the 'swapon' utility. The 'swapoff'
+ utility is used, typically at system shutdown, to disable any swap
+ space. If you are not using any swap space, you can leave this
+ option disabled.
+
+config BUSYBOX_CONFIG_FEATURE_SWAPON_PRI
+ bool "Support priority option -p"
+ default n
+ depends on BUSYBOX_CONFIG_SWAPONOFF
+ help
+ Enable support for setting swap device priority in swapon.
+
+config BUSYBOX_CONFIG_SWITCH_ROOT
+ bool "switch_root"
+ default y
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ The switch_root utility is used from initramfs to select a new
+ root device. Under initramfs, you have to use this instead of
+ pivot_root. (Stop reading here if you don't care why.)
+
+ Booting with initramfs extracts a gzipped cpio archive into rootfs
+ (which is a variant of ramfs/tmpfs). Because rootfs can't be moved
+ or unmounted*, pivot_root will not work from initramfs. Instead,
+ switch_root deletes everything out of rootfs (including itself),
+ does a mount --move that overmounts rootfs with the new root, and
+ then execs the specified init program.
+
+ * Because the Linux kernel uses rootfs internally as the starting
+ and ending point for searching through the kernel's doubly linked
+ list of active mount points. That's why.
+
+config BUSYBOX_CONFIG_UMOUNT
+ bool "umount"
+ default y
+ select BUSYBOX_CONFIG_PLATFORM_LINUX
+ help
+ When you want to remove a mounted filesystem from its current mount
+ point, for example when you are shutting down the system, the
+ 'umount' utility is the tool to use. If you enabled the 'mount'
+ utility, you almost certainly also want to enable 'umount'.
+
+config BUSYBOX_CONFIG_FEATURE_UMOUNT_ALL
+ bool "Support option -a"
+ default y
+ depends on BUSYBOX_CONFIG_UMOUNT
+ help
+ Support -a option to unmount all currently mounted filesystems.
+
+comment "Common options for mount/umount"
+ depends on BUSYBOX_CONFIG_MOUNT || BUSYBOX_CONFIG_UMOUNT
+
+config BUSYBOX_CONFIG_FEATURE_MOUNT_LOOP
+ bool "Support loopback mounts"
+ default y
+ depends on BUSYBOX_CONFIG_MOUNT || BUSYBOX_CONFIG_UMOUNT
+ help
+ Enabling this feature allows automatic mounting of files (containing
+ filesystem images) via the linux kernel's loopback devices.
+ The mount command will detect you are trying to mount a file instead
+ of a block device, and transparently associate the file with a
+ loopback device. The umount command will also free that loopback
+ device.
+
+ You can still use the 'losetup' utility (to manually associate files
+ with loop devices) if you need to do something advanced, such as
+ specify an offset or cryptographic options to the loopback device.
+ (If you don't want umount to free the loop device, use "umount -D".)
+
+config BUSYBOX_CONFIG_FEATURE_MOUNT_LOOP_CREATE
+ bool "Create new loopback devices if needed"
+ default n
+ depends on BUSYBOX_CONFIG_FEATURE_MOUNT_LOOP
+ help
+ Linux kernels >= 2.6.24 support unlimited loopback devices. They are
+ allocated for use when trying to use a loop device. The loop device
+ must however exist.
+
+ This feature lets mount to try to create next /dev/loopN device
+ if it does not find a free one.
+
+config BUSYBOX_CONFIG_FEATURE_MTAB_SUPPORT
+ bool "Support for the old /etc/mtab file"
+ default n
+ depends on BUSYBOX_CONFIG_MOUNT || BUSYBOX_CONFIG_UMOUNT
+ select BUSYBOX_CONFIG_FEATURE_MOUNT_FAKE
+ help
+ Historically, Unix systems kept track of the currently mounted
+ partitions in the file "/etc/mtab". These days, the kernel exports
+ the list of currently mounted partitions in "/proc/mounts", rendering
+ the old mtab file obsolete. (In modern systems, /etc/mtab should be
+ a symlink to /proc/mounts.)
+
+ The only reason to have mount maintain an /etc/mtab file itself is if
+ your stripped-down embedded system does not have a /proc directory.
+ If you must use this, keep in mind it's inherently brittle (for
+ example a mount under chroot won't update it), can't handle modern
+ features like separate per-process filesystem namespaces, requires
+ that your /etc directory be writable, tends to get easily confused
+ by --bind or --move mounts, won't update if you rename a directory
+ that contains a mount point, and so on. (In brief: avoid.)
+
+ About the only reason to use this is if you've removed /proc from
+ your kernel.
+
+config BUSYBOX_CONFIG_VOLUMEID
+ bool #No description makes it a hidden option
+ default n
+
+menu "Filesystem/Volume identification"
+ depends on BUSYBOX_CONFIG_VOLUMEID
+
+config BUSYBOX_CONFIG_FEATURE_VOLUMEID_EXT
+ bool "Ext filesystem"
+ default n
+ depends on BUSYBOX_CONFIG_VOLUMEID
+ help
+ TODO
+
+config BUSYBOX_CONFIG_FEATURE_VOLUMEID_BTRFS
+ bool "btrfs filesystem"
+ default n
+ depends on BUSYBOX_CONFIG_VOLUMEID
+ help
+ TODO
+
+config BUSYBOX_CONFIG_FEATURE_VOLUMEID_REISERFS
+ bool "Reiser filesystem"
+ default n
+ depends on BUSYBOX_CONFIG_VOLUMEID
+ help
+ TODO
+
+config BUSYBOX_CONFIG_FEATURE_VOLUMEID_FAT
+ bool "fat filesystem"
+ default n
+ depends on BUSYBOX_CONFIG_VOLUMEID
+ help
+ TODO
+
+config BUSYBOX_CONFIG_FEATURE_VOLUMEID_HFS
+ bool "hfs filesystem"
+ default n
+ depends on BUSYBOX_CONFIG_VOLUMEID
+ help
+ TODO
+
+config BUSYBOX_CONFIG_FEATURE_VOLUMEID_JFS
+ bool "jfs filesystem"
+ default n
+ depends on BUSYBOX_CONFIG_VOLUMEID
+ help
+ TODO
+
+### config FEATURE_VOLUMEID_UFS
+### bool "ufs filesystem"
+### default y
+### depends on VOLUMEID
+### help
+### TODO
+
+config BUSYBOX_CONFIG_FEATURE_VOLUMEID_XFS
+ bool "xfs filesystem"
+ default n
+ depends on BUSYBOX_CONFIG_VOLUMEID
+ help
+ TODO
+
+config BUSYBOX_CONFIG_FEATURE_VOLUMEID_NTFS
+ bool "ntfs filesystem"
+ default n
+ depends on BUSYBOX_CONFIG_VOLUMEID
+ help
+ TODO
+
+config BUSYBOX_CONFIG_FEATURE_VOLUMEID_ISO9660
+ bool "iso9660 filesystem"
+ default n
+ depends on BUSYBOX_CONFIG_VOLUMEID
+ help
+ TODO
+
+config BUSYBOX_CONFIG_FEATURE_VOLUMEID_UDF
+ bool "udf filesystem"
+ default n
+ depends on BUSYBOX_CONFIG_VOLUMEID
+ help
+ TODO
+
+config BUSYBOX_CONFIG_FEATURE_VOLUMEID_LUKS
+ bool "luks filesystem"
+ default n
+ depends on BUSYBOX_CONFIG_VOLUMEID
+ help
+ TODO
+
+config BUSYBOX_CONFIG_FEATURE_VOLUMEID_LINUXSWAP
+ bool "linux swap filesystem"
+ default n
+ depends on BUSYBOX_CONFIG_VOLUMEID
+ help
+ TODO
+
+### config FEATURE_VOLUMEID_LVM
+### bool "lvm"
+### default y
+### depends on VOLUMEID
+### help
+### TODO
+
+config BUSYBOX_CONFIG_FEATURE_VOLUMEID_CRAMFS
+ bool "cramfs filesystem"
+ default n
+ depends on BUSYBOX_CONFIG_VOLUMEID
+ help
+ TODO
+
+### config FEATURE_VOLUMEID_HPFS
+### bool "hpfs filesystem"
+### default y
+### depends on VOLUMEID
+### help
+### TODO
+
+config BUSYBOX_CONFIG_FEATURE_VOLUMEID_ROMFS
+ bool "romfs filesystem"
+ default n
+ depends on BUSYBOX_CONFIG_VOLUMEID
+ help
+ TODO
+
+config BUSYBOX_CONFIG_FEATURE_VOLUMEID_SYSV
+ bool "sysv filesystem"
+ default n
+ depends on BUSYBOX_CONFIG_VOLUMEID
+ help
+ TODO
+
+### config FEATURE_VOLUMEID_MINIX
+### bool "minix filesystem"
+### default y
+### depends on VOLUMEID
+### help
+### TODO
+
+### These only detect partition tables - not used (yet?)
+### config FEATURE_VOLUMEID_MAC
+### bool "mac filesystem"
+### default y
+### depends on VOLUMEID
+### help
+### TODO
+###
+### config FEATURE_VOLUMEID_MSDOS
+### bool "msdos filesystem"
+### default y
+### depends on VOLUMEID
+### help
+### TODO
+
+config BUSYBOX_CONFIG_FEATURE_VOLUMEID_OCFS2
+ bool "ocfs2 filesystem"
+ default n
+ depends on BUSYBOX_CONFIG_VOLUMEID
+ help
+ TODO
+
+### config FEATURE_VOLUMEID_HIGHPOINTRAID
+### bool "highpoint raid"
+### default y
+### depends on VOLUMEID
+### help
+### TODO
+
+### config FEATURE_VOLUMEID_ISWRAID
+### bool "intel raid"
+### default y
+### depends on VOLUMEID
+### help
+### TODO
+
+### config FEATURE_VOLUMEID_LSIRAID
+### bool "lsi raid"
+### default y
+### depends on VOLUMEID
+### help
+### TODO
+
+### config FEATURE_VOLUMEID_VIARAID
+### bool "via raid"
+### default y
+### depends on VOLUMEID
+### help
+### TODO
+
+### config FEATURE_VOLUMEID_SILICONRAID
+### bool "silicon raid"
+### default y
+### depends on VOLUMEID
+### help
+### TODO
+
+### config FEATURE_VOLUMEID_NVIDIARAID
+### bool "nvidia raid"
+### default y
+### depends on VOLUMEID
+### help
+### TODO
+
+### config FEATURE_VOLUMEID_PROMISERAID
+### bool "promise raid"
+### default y
+### depends on VOLUMEID
+### help
+### TODO
+
+config BUSYBOX_CONFIG_FEATURE_VOLUMEID_LINUXRAID
+ bool "linuxraid"
+ default n
+ depends on BUSYBOX_CONFIG_VOLUMEID
+ help
+ TODO
+
+endmenu
+
+endmenu
diff --git a/package/busybox/convert_menuconfig.pl b/package/busybox/convert_menuconfig.pl
new file mode 100755
index 0000000..0128bf7
--- /dev/null
+++ b/package/busybox/convert_menuconfig.pl
@@ -0,0 +1,78 @@
+#!/usr/bin/perl
+#
+# Copyright (C) 2006 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+use strict;
+my $PATH = $ARGV[0];
+($PATH and -d $PATH) or die 'invalid path';
+my $DEFCONFIG = $ARGV[1];
+($DEFCONFIG and -f $DEFCONFIG) or die 'invalid config file';
+
+my %config;
+
+open CONFIG, $DEFCONFIG or die 'cannot open config file';
+while (<CONFIG>) {
+ /^CONFIG_([\w_]+)=([ym])/ and $config{$1} = $2;
+ /^CONFIG_([\w_]+)=(\d+)/ and $config{$1} = $2;
+ /^CONFIG_([\w_]+)=(".+")/ and $config{$1} = $2;
+}
+close CONFIG;
+
+open FIND, "find \"$PATH\" -name Config.in |";
+while (<FIND>) {
+ chomp;
+ my $input = $_;
+ s/^$PATH\///g;
+ s/sysdeps\/linux\///g;
+ my $output = $_;
+ print STDERR "$input => $output\n";
+ $output =~ /^(.+)\/[^\/]+$/ and system("mkdir -p $1");
+
+ open INPUT, $input;
+ open OUTPUT, ">$output";
+ my ($cur, $default_set, $line);
+ while ($line = <INPUT>) {
+ next if $line =~ /^\s*mainmenu/;
+
+ # FIXME: make this dynamic
+ $line =~ s/default FEATURE_BUFFERS_USE_MALLOC/default FEATURE_BUFFERS_GO_ON_STACK/;
+ $line =~ s/default FEATURE_SH_IS_NONE/default FEATURE_SH_IS_ASH/;
+
+ if ($line =~ /^\s*config\s*([\w_]+)/) {
+ $cur = $1;
+ undef $default_set;
+ }
+ if ($line =~ /^\s*(menu|choice|end|source)/) {
+ undef $cur;
+ undef $default_set;
+ }
+ $line =~ s/^(\s*source\s+)/$1package\/busybox\/config\//;
+
+ $line =~ s/^(\s*(prompt "[^"]+" if|config|depends|depends on|select|default|default \w if)\s+\!?)([A-Z_])/$1BUSYBOX_CONFIG_$3/g;
+ $line =~ s/(( \|\| | \&\& | \( )!?)([A-Z_])/$1BUSYBOX_CONFIG_$3/g;
+ $line =~ s/(\( ?!?)([A-Z_]+ (\|\||&&))/$1BUSYBOX_CONFIG_$2/g;
+
+ if ($cur) {
+ ($cur eq 'LFS') and do {
+ $line =~ s/^(\s*(bool|tristate|string))\s*".+"$/$1/;
+ };
+ if ($line =~ /^\s*default/) {
+ my $c;
+ $default_set = 1;
+ $c = $config{$cur} or $c = 'n';
+
+ $line =~ s/^(\s*default\s*)(\w+|"[^"]*")(.*)/$1$c$3/;
+ }
+ }
+
+ print OUTPUT $line;
+ }
+ close OUTPUT;
+ close INPUT;
+
+}
+close FIND;
diff --git a/package/busybox/files/.svn/entries b/package/busybox/files/.svn/entries
new file mode 100644
index 0000000..d815495
--- /dev/null
+++ b/package/busybox/files/.svn/entries
@@ -0,0 +1,96 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/busybox/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2011-11-16T13:17:35.851342Z
+29183
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+cron
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+75e57cfa999797ca726eb3c2604bd712
+2011-11-07T22:58:39.735051Z
+28836
+nico
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+385
+
+telnet
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+78d40e5aaec0f57d9de5a3e7b51c9e4e
+2011-11-16T13:17:35.851342Z
+29183
+jow
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+878
+
diff --git a/package/busybox/files/.svn/prop-base/cron.svn-base b/package/busybox/files/.svn/prop-base/cron.svn-base
new file mode 100644
index 0000000..03b5bfa
--- /dev/null
+++ b/package/busybox/files/.svn/prop-base/cron.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:eol-style
+V 6
+native
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/busybox/files/.svn/prop-base/telnet.svn-base b/package/busybox/files/.svn/prop-base/telnet.svn-base
new file mode 100644
index 0000000..03b5bfa
--- /dev/null
+++ b/package/busybox/files/.svn/prop-base/telnet.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:eol-style
+V 6
+native
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/busybox/files/.svn/text-base/cron.svn-base b/package/busybox/files/.svn/text-base/cron.svn-base
new file mode 100644
index 0000000..465b1ab
--- /dev/null
+++ b/package/busybox/files/.svn/text-base/cron.svn-base
@@ -0,0 +1,18 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2006-2011 OpenWrt.org
+
+START=50
+
+SERVICE_USE_PID=1
+
+start () {
+ loglevel=$(uci_get "system.@system[0].cronloglevel")
+ [ -z "$(ls /etc/crontabs/)" ] && exit 1
+ mkdir -p /var/spool/cron
+ ln -s /etc/crontabs /var/spool/cron/ 2>/dev/null
+ service_start /usr/sbin/crond -c /etc/crontabs -l ${loglevel:-5}
+}
+
+stop() {
+ service_stop /usr/sbin/crond
+}
diff --git a/package/busybox/files/.svn/text-base/telnet.svn-base b/package/busybox/files/.svn/text-base/telnet.svn-base
new file mode 100644
index 0000000..994e713
--- /dev/null
+++ b/package/busybox/files/.svn/text-base/telnet.svn-base
@@ -0,0 +1,37 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2006-2011 OpenWrt.org
+
+START=50
+
+has_root_pwd() {
+ local pwd=$([ -f "$1" ] && cat "$1")
+ pwd="${pwd#*root:}"
+ pwd="${pwd%%:*}"
+
+ test -n "${pwd#[\!x]}"
+}
+
+get_root_home() {
+ local homedir=$([ -f "$1" ] && cat "$1")
+ homedir="${homedir#*:*:0:0:*:}"
+
+ echo "${homedir%%:*}"
+}
+
+has_ssh_pubkey() {
+ ( /etc/init.d/dropbear enabled 2> /dev/null && grep -qs "^ssh-" /etc/dropbear/authorized_keys ) || \
+ ( /etc/init.d/sshd enabled 2> /dev/null && grep -qs "^ssh-" "$(get_root_home /etc/passwd)"/.ssh/authorized_keys )
+}
+
+start() {
+ if ( ! has_ssh_pubkey && \
+ ! has_root_pwd /etc/passwd && ! has_root_pwd /etc/shadow ) || \
+ ( ! /etc/init.d/dropbear enabled 2> /dev/null && ! /etc/init.d/sshd enabled 2> /dev/null );
+ then
+ service_start /usr/sbin/telnetd -l /bin/login.sh
+ fi
+}
+
+stop() {
+ service_stop /usr/sbin/telnetd
+}
diff --git a/package/busybox/files/cron b/package/busybox/files/cron
new file mode 100755
index 0000000..465b1ab
--- /dev/null
+++ b/package/busybox/files/cron
@@ -0,0 +1,18 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2006-2011 OpenWrt.org
+
+START=50
+
+SERVICE_USE_PID=1
+
+start () {
+ loglevel=$(uci_get "system.@system[0].cronloglevel")
+ [ -z "$(ls /etc/crontabs/)" ] && exit 1
+ mkdir -p /var/spool/cron
+ ln -s /etc/crontabs /var/spool/cron/ 2>/dev/null
+ service_start /usr/sbin/crond -c /etc/crontabs -l ${loglevel:-5}
+}
+
+stop() {
+ service_stop /usr/sbin/crond
+}
diff --git a/package/busybox/files/telnet b/package/busybox/files/telnet
new file mode 100755
index 0000000..994e713
--- /dev/null
+++ b/package/busybox/files/telnet
@@ -0,0 +1,37 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2006-2011 OpenWrt.org
+
+START=50
+
+has_root_pwd() {
+ local pwd=$([ -f "$1" ] && cat "$1")
+ pwd="${pwd#*root:}"
+ pwd="${pwd%%:*}"
+
+ test -n "${pwd#[\!x]}"
+}
+
+get_root_home() {
+ local homedir=$([ -f "$1" ] && cat "$1")
+ homedir="${homedir#*:*:0:0:*:}"
+
+ echo "${homedir%%:*}"
+}
+
+has_ssh_pubkey() {
+ ( /etc/init.d/dropbear enabled 2> /dev/null && grep -qs "^ssh-" /etc/dropbear/authorized_keys ) || \
+ ( /etc/init.d/sshd enabled 2> /dev/null && grep -qs "^ssh-" "$(get_root_home /etc/passwd)"/.ssh/authorized_keys )
+}
+
+start() {
+ if ( ! has_ssh_pubkey && \
+ ! has_root_pwd /etc/passwd && ! has_root_pwd /etc/shadow ) || \
+ ( ! /etc/init.d/dropbear enabled 2> /dev/null && ! /etc/init.d/sshd enabled 2> /dev/null );
+ then
+ service_start /usr/sbin/telnetd -l /bin/login.sh
+ fi
+}
+
+stop() {
+ service_stop /usr/sbin/telnetd
+}
diff --git a/package/busybox/patches/.svn/entries b/package/busybox/patches/.svn/entries
new file mode 100644
index 0000000..c8a1785
--- /dev/null
+++ b/package/busybox/patches/.svn/entries
@@ -0,0 +1,1422 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/busybox/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-02-21T11:45:10.056568Z
+35710
+jogo
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+310-passwd_access.patch
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+5f003b98651ed24d2d07bde9f2c47cab
+2013-02-21T11:45:10.056568Z
+35710
+jogo
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1227
+
+007-upstream_mkfs_ext2_fixes.patch
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+a201c948c6cd2480925dab11631e15a8
+2013-02-21T11:45:10.056568Z
+35710
+jogo
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+49728
+
+911-date-k-flag.patch
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+57df31a5c2cf124e0026ec28de69241b
+2013-01-19T10:11:34.677010Z
+35239
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2620
+
+999-musl-fixes.patch
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+19af1f7b62cfd17710655424324c40b1
+2013-01-19T10:11:34.677010Z
+35239
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+406
+
+510-awk_include.patch
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+7d598691f7c99b5c8d914491e880c7a9
+2011-10-21T23:08:45.031764Z
+28513
+nico
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4896
+
+150-no_static_libgcc.patch
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+cdb235825ffbb72d3db149979b0d4234
+2011-03-01T05:40:57.493737Z
+25802
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+585
+
+001-init_avoid_loop_opening_tty.patch
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+01f181b060c2eea4d8b3f4208210d35d
+2011-10-21T23:08:45.031764Z
+28513
+nico
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+346
+
+490-mount_disable_check.patch
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+6285eb49d3cc6a1bca3c20277ef827b7
+2011-10-21T23:08:45.031764Z
+28513
+nico
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+447
+
+004-upstream-percent_decode_in_place.patch
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+7d10ac51944ce8de6060396edb57503a
+2013-02-21T11:45:10.056568Z
+35710
+jogo
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+6886
+
+241-udhcpc-oversized_packets.patch
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+937eab43e37e0ac54fb0e34a444bc436
+2011-10-21T23:08:45.031764Z
+28513
+nico
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3495
+
+110-wget_getopt_fix.patch
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+121ddbeecd91b58ade7511c8dcd61473
+2012-03-18T19:46:52.688247Z
+30985
+jow
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+446
+
+300-netmsg.patch
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+4966a4acb3734dd0ac085a593f4986ee
+2011-10-21T23:08:45.031764Z
+28513
+nico
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2597
+
+802-brctl_linux24.patch
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+11e915db54580b98059b91ebe638bd8a
+2011-10-21T23:08:45.031764Z
+28513
+nico
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2123
+
+251-ash_fix-redir-substitution.patch
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+5c127da4c4cea9c7c2a13b822b550148
+2012-06-10T13:19:45.010100Z
+32162
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+460
+
+611-upstream_ntpd_version_fix.patch
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+38602c53c467862e53fb83af3a968e73
+2013-01-19T10:11:34.677010Z
+35239
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1190
+
+910-insmod-q-flag.patch
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+8363897ba1177f261ae977d7a06a01e3
+2011-10-21T23:08:45.031764Z
+28513
+nico
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+896
+
+240-udhcpc_retries.patch
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+7b98924affa08734b1b0ed854afd698d
+2012-10-08T12:31:27.948633Z
+33661
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+705
+
+141-gen_build_files_bash.patch
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+2a67bd0fedbcf21c21aa7e180fb46101
+2011-11-08T00:33:10.514693Z
+28849
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+209
+
+003-brctl_show_fix.patch
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+380a6a19f0ba622a45b5db4a905fb2ed
+2011-10-21T23:08:45.031764Z
+28513
+nico
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1100
+
+006-upstream_CVE-2011-2716_fixes.patch
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+26d71e5176a77d5f7221f692f8dc068a
+2013-01-19T10:11:34.677010Z
+35239
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+6648
+
+524-udhcpc_renew.patch
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+5997f3faf2e04654abf1d91a3ef5657e
+2012-10-08T12:31:27.948633Z
+33661
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+327
+
+260-vconfig_proc.patch
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+12b509947ca468e9a20855d5997a8ff0
+2013-02-21T11:45:10.056568Z
+35710
+jogo
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+625
+
+470-insmod_search.patch
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+44e70282532d9d83d297b8d911641994
+2011-10-21T23:08:45.031764Z
+28513
+nico
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3544
+
+998-arping_missing_includes.patch
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+b0f4c24424173654ba76a816747927aa
+2013-01-19T10:11:34.677010Z
+35239
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+234
+
+244-udhcpc_add_6rd_option.patch
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+e4fd263333b037cb55767582f820a825
+2013-02-21T11:45:10.056568Z
+35710
+jogo
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5208
+
+340-lock_util.patch
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+f9b934d13b1dc4d36b5477d593c0f6e4
+2013-02-21T11:45:10.056568Z
+35710
+jogo
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3733
+
+140-trylink_bash.patch
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+dba1f389b9cd0f08439137b3fde931e6
+2008-08-20T14:00:34.479660Z
+12348
+kaloz
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+109
+
+243-udhcpc_changed_ifindex.patch
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+ffce669c1b381c3b88c80e89c14fe39c
+2012-10-08T12:31:27.948633Z
+33661
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+680
+
+610-ntpd_delayed_resolve.patch
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+1e6d60ec76cc94ef0e71532c071f9bf6
+2011-11-07T01:45:04.201966Z
+28794
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1459
+
+440-httpd_chdir.patch
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+2da361b9214f7b9e0018025fa5c44b19
+2011-11-23T19:41:36.301696Z
+29299
+nico
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+312
+
+410-httpd_cgi_headers.patch
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+53c478810cc354d3ca13058c9de01b5b
+2011-11-23T19:41:36.301696Z
+29299
+nico
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+684
+
+005-resource_h_include.patch
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+2523ed8757b66e27c9685ff95aa78922
+2012-09-13T15:57:59.508598Z
+33395
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+230
+
+902-telnetd_intr.patch
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+3194111fb981fa26151066752c7f321c
+2011-10-21T23:08:45.031764Z
+28513
+nico
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+244
+
+242-udhcpc_msgs.patch
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+5da871ef242168e8dd89464e9064091a
+2012-10-08T12:31:27.948633Z
+33661
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+564
+
+200-etc_crontabs.patch
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+e2a26f4b67fde73ab9a1549b3aded48c
+2011-10-21T23:08:45.031764Z
+28513
+nico
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+549
+
+950-partial-checksum.patch
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+a04b47381f5f7bad2088c9218aa6cad7
+2012-10-08T12:31:27.948633Z
+33661
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2455
+
+002-passwd_use_md5_hash_by_default_like_it_used_to_be.patch
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+dd6b204adca559fe947fc6c0c86e3779
+2011-11-09T17:32:23.264841Z
+28885
+nico
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+574
+
+920-portability.patch
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+5198ed6f32007b582f61292c84e0099b
+2011-10-25T13:03:18.363450Z
+28578
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+217
+
+250-ash_export-n.patch
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+36fda96ca7ee186bda44052c1650b808
+2011-10-21T23:08:45.031764Z
+28513
+nico
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+766
+
+350-httpd_redir.patch
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+0a28a335f6497305d42e78192a85f3bc
+2011-11-23T19:41:36.301696Z
+29299
+nico
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3276
+
+700-hexdump_segfault_fix.patch
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+d7377181b42a758cf958843a11ce9345
+2011-11-15T17:38:55.401635Z
+29156
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+309
+
diff --git a/package/busybox/patches/.svn/prop-base/110-wget_getopt_fix.patch.svn-base b/package/busybox/patches/.svn/prop-base/110-wget_getopt_fix.patch.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/busybox/patches/.svn/prop-base/110-wget_getopt_fix.patch.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/busybox/patches/.svn/prop-base/140-trylink_bash.patch.svn-base b/package/busybox/patches/.svn/prop-base/140-trylink_bash.patch.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/busybox/patches/.svn/prop-base/140-trylink_bash.patch.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/busybox/patches/.svn/prop-base/200-etc_crontabs.patch.svn-base b/package/busybox/patches/.svn/prop-base/200-etc_crontabs.patch.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/busybox/patches/.svn/prop-base/200-etc_crontabs.patch.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/busybox/patches/.svn/prop-base/240-udhcpc_retries.patch.svn-base b/package/busybox/patches/.svn/prop-base/240-udhcpc_retries.patch.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/busybox/patches/.svn/prop-base/240-udhcpc_retries.patch.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/busybox/patches/.svn/prop-base/241-udhcpc-oversized_packets.patch.svn-base b/package/busybox/patches/.svn/prop-base/241-udhcpc-oversized_packets.patch.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/busybox/patches/.svn/prop-base/241-udhcpc-oversized_packets.patch.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/busybox/patches/.svn/prop-base/250-ash_export-n.patch.svn-base b/package/busybox/patches/.svn/prop-base/250-ash_export-n.patch.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/busybox/patches/.svn/prop-base/250-ash_export-n.patch.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/busybox/patches/.svn/prop-base/300-netmsg.patch.svn-base b/package/busybox/patches/.svn/prop-base/300-netmsg.patch.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/busybox/patches/.svn/prop-base/300-netmsg.patch.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/busybox/patches/.svn/prop-base/340-lock_util.patch.svn-base b/package/busybox/patches/.svn/prop-base/340-lock_util.patch.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/busybox/patches/.svn/prop-base/340-lock_util.patch.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/busybox/patches/.svn/prop-base/410-httpd_cgi_headers.patch.svn-base b/package/busybox/patches/.svn/prop-base/410-httpd_cgi_headers.patch.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/busybox/patches/.svn/prop-base/410-httpd_cgi_headers.patch.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/busybox/patches/.svn/prop-base/440-httpd_chdir.patch.svn-base b/package/busybox/patches/.svn/prop-base/440-httpd_chdir.patch.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/busybox/patches/.svn/prop-base/440-httpd_chdir.patch.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/busybox/patches/.svn/text-base/001-init_avoid_loop_opening_tty.patch.svn-base b/package/busybox/patches/.svn/text-base/001-init_avoid_loop_opening_tty.patch.svn-base
new file mode 100644
index 0000000..4db64c3
--- /dev/null
+++ b/package/busybox/patches/.svn/text-base/001-init_avoid_loop_opening_tty.patch.svn-base
@@ -0,0 +1,15 @@
+--- a/init/init.c
++++ b/init/init.c
+@@ -573,8 +573,11 @@ static void run_actions(int action_type)
+ /* Only run stuff with pid == 0. If pid != 0,
+ * it is already running
+ */
+- if (a->pid == 0)
++ if (a->pid == 0) {
++ if (a->terminal[0] && access(a->terminal, R_OK | W_OK))
++ continue;
+ a->pid = run(a);
++ }
+ }
+ }
+ }
diff --git a/package/busybox/patches/.svn/text-base/002-passwd_use_md5_hash_by_default_like_it_used_to_be.patch.svn-base b/package/busybox/patches/.svn/text-base/002-passwd_use_md5_hash_by_default_like_it_used_to_be.patch.svn-base
new file mode 100644
index 0000000..ff79f3e
--- /dev/null
+++ b/package/busybox/patches/.svn/text-base/002-passwd_use_md5_hash_by_default_like_it_used_to_be.patch.svn-base
@@ -0,0 +1,20 @@
+From eb80c2a5315ed08bd329448217695375d89732c9 Mon Sep 17 00:00:00 2001
+From: Nicolas Thill <nico@openwrt.org>
+Date: Wed, 9 Nov 2011 18:17:20 +0100
+Subject: [PATCH] passwd: use MD5 hash by default (like it used to be)
+
+---
+ loginutils/passwd.c | 2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+--- a/loginutils/passwd.c
++++ b/loginutils/passwd.c
+@@ -94,7 +94,7 @@ int passwd_main(int argc UNUSED_PARAM, c
+ };
+ unsigned opt;
+ int rc;
+- const char *opt_a = "d"; /* des */
++ const char *opt_a = "m"; /* md5 */
+ const char *filename;
+ char *myname;
+ char *name;
diff --git a/package/busybox/patches/.svn/text-base/003-brctl_show_fix.patch.svn-base b/package/busybox/patches/.svn/text-base/003-brctl_show_fix.patch.svn-base
new file mode 100644
index 0000000..8177fb0
--- /dev/null
+++ b/package/busybox/patches/.svn/text-base/003-brctl_show_fix.patch.svn-base
@@ -0,0 +1,37 @@
+--- a/networking/brctl.c
++++ b/networking/brctl.c
+@@ -129,7 +129,7 @@ int brctl_main(int argc UNUSED_PARAM, ch
+ "setageing\0" "setfd\0" "sethello\0" "setmaxage\0"
+ "setpathcost\0" "setportprio\0" "setbridgeprio\0"
+ )
+- IF_FEATURE_BRCTL_SHOW("showmacs\0" "show\0");
++ IF_FEATURE_BRCTL_SHOW("show\0");
+
+ enum { ARG_addbr = 0, ARG_delbr, ARG_addif, ARG_delif
+ IF_FEATURE_BRCTL_FANCY(,
+@@ -137,7 +137,7 @@ int brctl_main(int argc UNUSED_PARAM, ch
+ ARG_setageing, ARG_setfd, ARG_sethello, ARG_setmaxage,
+ ARG_setpathcost, ARG_setportprio, ARG_setbridgeprio
+ )
+- IF_FEATURE_BRCTL_SHOW(, ARG_showmacs, ARG_show)
++ IF_FEATURE_BRCTL_SHOW(, ARG_show)
+ };
+
+ int fd;
+--- a/networking/Config.src
++++ b/networking/Config.src
+@@ -82,12 +82,12 @@ config FEATURE_BRCTL_FANCY
+ This adds about 600 bytes.
+
+ config FEATURE_BRCTL_SHOW
+- bool "Support show, showmac and showstp"
++ bool "Support show"
+ default y
+ depends on BRCTL && FEATURE_BRCTL_FANCY
+ help
+ Add support for option which prints the current config:
+- showmacs, showstp, show
++ show
+
+ config DNSD
+ bool "dnsd"
diff --git a/package/busybox/patches/.svn/text-base/004-upstream-percent_decode_in_place.patch.svn-base b/package/busybox/patches/.svn/text-base/004-upstream-percent_decode_in_place.patch.svn-base
new file mode 100644
index 0000000..d94ee47
--- /dev/null
+++ b/package/busybox/patches/.svn/text-base/004-upstream-percent_decode_in_place.patch.svn-base
@@ -0,0 +1,237 @@
+http://git.busybox.net/busybox/commit/?id=dd1061b6a79b0161597799e825bfefc27993ace5
+
+From dd1061b6a79b0161597799e825bfefc27993ace5 Mon Sep 17 00:00:00 2001
+From: Denys Vlasenko <vda.linux@googlemail.com>
+Date: Sun, 11 Sep 2011 21:04:02 +0200
+Subject: [PATCH] wget: URL-decode user:password before base64-encoding it into auth hdr. Closes 3625.
+
+function old new delta
+percent_decode_in_place - 152 +152
+parse_url 304 317 +13
+handle_incoming_and_exit 2795 2798 +3
+httpd_main 763 760 -3
+decodeString 152 - -152
+------------------------------------------------------------------------------
+(add/remove: 2/1 grow/shrink: 2/1 up/down: 168/-155) Total: 13 bytes
+
+Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
+
+--- a/include/libbb.h
++++ b/include/libbb.h
+@@ -1570,6 +1570,15 @@ int starts_with_cpu(const char *str) FAS
+ unsigned get_cpu_count(void) FAST_FUNC;
+
+
++/* Use strict=1 if you process input from untrusted source:
++ * it will return NULL on invalid %xx (bad hex chars)
++ * and str + 1 if decoded char is / or NUL.
++ * In non-strict mode, it always succeeds (returns str),
++ * and also it additionally decoded '+' to space.
++ */
++char *percent_decode_in_place(char *str, int strict) FAST_FUNC;
++
++
+ extern const char bb_uuenc_tbl_base64[];
+ extern const char bb_uuenc_tbl_std[];
+ void bb_uuencode(char *store, const void *s, int length, const char *tbl) FAST_FUNC;
+--- /dev/null
++++ b/libbb/percent_decode.c
+@@ -0,0 +1,69 @@
++/* vi: set sw=4 ts=4: */
++/*
++ * Licensed under GPLv2 or later, see file LICENSE in this source tree.
++ */
++
++//kbuild:lib-y += percent_decode.o
++
++#include "libbb.h"
++
++static unsigned hex_to_bin(unsigned char c)
++{
++ unsigned v;
++
++ v = c - '0';
++ if (v <= 9)
++ return v;
++ /* c | 0x20: letters to lower case, non-letters
++ * to (potentially different) non-letters */
++ v = (unsigned)(c | 0x20) - 'a';
++ if (v <= 5)
++ return v + 10;
++ return ~0;
++/* For testing:
++void t(char c) { printf("'%c'(%u) %u\n", c, c, hex_to_bin(c)); }
++int main() { t(0x10); t(0x20); t('0'); t('9'); t('A'); t('F'); t('a'); t('f');
++t('0'-1); t('9'+1); t('A'-1); t('F'+1); t('a'-1); t('f'+1); return 0; }
++*/
++}
++
++char* FAST_FUNC percent_decode_in_place(char *str, int strict)
++{
++ /* note that decoded string is always shorter than original */
++ char *src = str;
++ char *dst = str;
++ char c;
++
++ while ((c = *src++) != '\0') {
++ unsigned v;
++
++ if (!strict && c == '+') {
++ *dst++ = ' ';
++ continue;
++ }
++ if (c != '%') {
++ *dst++ = c;
++ continue;
++ }
++ v = hex_to_bin(src[0]);
++ if (v > 15) {
++ bad_hex:
++ if (strict)
++ return NULL;
++ *dst++ = '%';
++ continue;
++ }
++ v = (v * 16) | hex_to_bin(src[1]);
++ if (v > 255)
++ goto bad_hex;
++ if (strict && (v == '/' || v == '\0')) {
++ /* caller takes it as indication of invalid
++ * (dangerous wrt exploits) chars */
++ return str + 1;
++ }
++ *dst++ = v;
++ src += 2;
++ }
++ *dst = '\0';
++ return str;
++}
+--- a/networking/httpd.c
++++ b/networking/httpd.c
+@@ -820,78 +820,6 @@ static char *encodeString(const char *st
+ }
+ #endif
+
+-/*
+- * Given a URL encoded string, convert it to plain ascii.
+- * Since decoding always makes strings smaller, the decode is done in-place.
+- * Thus, callers should xstrdup() the argument if they do not want the
+- * argument modified. The return is the original pointer, allowing this
+- * function to be easily used as arguments to other functions.
+- *
+- * string The first string to decode.
+- * option_d 1 if called for httpd -d
+- *
+- * Returns a pointer to the decoded string (same as input).
+- */
+-static unsigned hex_to_bin(unsigned char c)
+-{
+- unsigned v;
+-
+- v = c - '0';
+- if (v <= 9)
+- return v;
+- /* c | 0x20: letters to lower case, non-letters
+- * to (potentially different) non-letters */
+- v = (unsigned)(c | 0x20) - 'a';
+- if (v <= 5)
+- return v + 10;
+- return ~0;
+-/* For testing:
+-void t(char c) { printf("'%c'(%u) %u\n", c, c, hex_to_bin(c)); }
+-int main() { t(0x10); t(0x20); t('0'); t('9'); t('A'); t('F'); t('a'); t('f');
+-t('0'-1); t('9'+1); t('A'-1); t('F'+1); t('a'-1); t('f'+1); return 0; }
+-*/
+-}
+-static char *decodeString(char *orig, int option_d)
+-{
+- /* note that decoded string is always shorter than original */
+- char *string = orig;
+- char *ptr = string;
+- char c;
+-
+- while ((c = *ptr++) != '\0') {
+- unsigned v;
+-
+- if (option_d && c == '+') {
+- *string++ = ' ';
+- continue;
+- }
+- if (c != '%') {
+- *string++ = c;
+- continue;
+- }
+- v = hex_to_bin(ptr[0]);
+- if (v > 15) {
+- bad_hex:
+- if (!option_d)
+- return NULL;
+- *string++ = '%';
+- continue;
+- }
+- v = (v * 16) | hex_to_bin(ptr[1]);
+- if (v > 255)
+- goto bad_hex;
+- if (!option_d && (v == '/' || v == '\0')) {
+- /* caller takes it as indication of invalid
+- * (dangerous wrt exploits) chars */
+- return orig + 1;
+- }
+- *string++ = v;
+- ptr += 2;
+- }
+- *string = '\0';
+- return orig;
+-}
+-
+ #if ENABLE_FEATURE_HTTPD_BASIC_AUTH
+ /*
+ * Decode a base64 data stream as per rfc1521.
+@@ -1949,7 +1877,7 @@ static void handle_incoming_and_exit(con
+ }
+
+ /* Decode URL escape sequences */
+- tptr = decodeString(urlcopy, 0);
++ tptr = percent_decode_in_place(urlcopy, /*strict:*/ 1);
+ if (tptr == NULL)
+ send_headers_and_exit(HTTP_BAD_REQUEST);
+ if (tptr == urlcopy + 1) {
+@@ -2408,7 +2336,7 @@ int httpd_main(int argc UNUSED_PARAM, ch
+ , &verbose
+ );
+ if (opt & OPT_DECODE_URL) {
+- fputs(decodeString(url_for_decode, 1), stdout);
++ fputs(percent_decode_in_place(url_for_decode, /*strict:*/ 0), stdout);
+ return 0;
+ }
+ #if ENABLE_FEATURE_HTTPD_ENCODE_URL_STR
+--- a/networking/wget.c
++++ b/networking/wget.c
+@@ -298,8 +298,13 @@ static void parse_url(const char *src_ur
+
+ sp = strrchr(h->host, '@');
+ if (sp != NULL) {
+- h->user = h->host;
++ // URL-decode "user:password" string before base64-encoding:
++ // wget http://test:my%20pass@example.com should send
++ // Authorization: Basic dGVzdDpteSBwYXNz
++ // which decodes to "test:my pass".
++ // Standard wget and curl do this too.
+ *sp = '\0';
++ h->user = percent_decode_in_place(h->host, /*strict:*/ 0);
+ h->host = sp + 1;
+ }
+
+@@ -661,12 +666,6 @@ static void download_one_url(const char
+
+ #if ENABLE_FEATURE_WGET_AUTHENTICATION
+ if (target.user) {
+-//TODO: URL-decode "user:password" string before base64-encoding:
+-//wget http://test:my%20pass@example.com should send
+-// Authorization: Basic dGVzdDpteSBwYXNz
+-//which decodes to "test:my pass", instead of what we send now:
+-// Authorization: Basic dGVzdDpteSUyMHBhc3M=
+-//Can reuse decodeString() from httpd.c
+ fprintf(sfp, "Proxy-Authorization: Basic %s\r\n"+6,
+ base64enc(target.user));
+ }
diff --git a/package/busybox/patches/.svn/text-base/005-resource_h_include.patch.svn-base b/package/busybox/patches/.svn/text-base/005-resource_h_include.patch.svn-base
new file mode 100644
index 0000000..d66d66d
--- /dev/null
+++ b/package/busybox/patches/.svn/text-base/005-resource_h_include.patch.svn-base
@@ -0,0 +1,10 @@
+--- a/include/libbb.h
++++ b/include/libbb.h
+@@ -35,6 +35,7 @@
+ #include <sys/poll.h>
+ #include <sys/ioctl.h>
+ #include <sys/mman.h>
++#include <sys/resource.h>
+ #include <sys/socket.h>
+ #include <sys/stat.h>
+ #include <sys/time.h>
diff --git a/package/busybox/patches/.svn/text-base/006-upstream_CVE-2011-2716_fixes.patch.svn-base b/package/busybox/patches/.svn/text-base/006-upstream_CVE-2011-2716_fixes.patch.svn-base
new file mode 100644
index 0000000..532fcee
--- /dev/null
+++ b/package/busybox/patches/.svn/text-base/006-upstream_CVE-2011-2716_fixes.patch.svn-base
@@ -0,0 +1,164 @@
+--- a/networking/udhcp/common.c
++++ b/networking/udhcp/common.c
+@@ -29,16 +29,16 @@ const struct dhcp_optflag dhcp_optflags[
+ // { OPTION_IP | OPTION_LIST , 0x07 }, /* DHCP_LOG_SERVER */
+ // { OPTION_IP | OPTION_LIST , 0x08 }, /* DHCP_COOKIE_SERVER */
+ { OPTION_IP | OPTION_LIST , 0x09 }, /* DHCP_LPR_SERVER */
+- { OPTION_STRING | OPTION_REQ, 0x0c }, /* DHCP_HOST_NAME */
++ { OPTION_STRING_HOST | OPTION_REQ, 0x0c }, /* DHCP_HOST_NAME */
+ { OPTION_U16 , 0x0d }, /* DHCP_BOOT_SIZE */
+- { OPTION_STRING | OPTION_REQ, 0x0f }, /* DHCP_DOMAIN_NAME */
++ { OPTION_STRING_HOST | OPTION_REQ, 0x0f }, /* DHCP_DOMAIN_NAME */
+ { OPTION_IP , 0x10 }, /* DHCP_SWAP_SERVER */
+ { OPTION_STRING , 0x11 }, /* DHCP_ROOT_PATH */
+ { OPTION_U8 , 0x17 }, /* DHCP_IP_TTL */
+ { OPTION_U16 , 0x1a }, /* DHCP_MTU */
+ { OPTION_IP | OPTION_REQ, 0x1c }, /* DHCP_BROADCAST */
+ { OPTION_IP_PAIR | OPTION_LIST , 0x21 }, /* DHCP_ROUTES */
+- { OPTION_STRING , 0x28 }, /* DHCP_NIS_DOMAIN */
++ { OPTION_STRING_HOST , 0x28 }, /* DHCP_NIS_DOMAIN */
+ { OPTION_IP | OPTION_LIST , 0x29 }, /* DHCP_NIS_SERVER */
+ { OPTION_IP | OPTION_LIST | OPTION_REQ, 0x2a }, /* DHCP_NTP_SERVER */
+ { OPTION_IP | OPTION_LIST , 0x2c }, /* DHCP_WINS_SERVER */
+@@ -46,7 +46,7 @@ const struct dhcp_optflag dhcp_optflags[
+ { OPTION_IP , 0x36 }, /* DHCP_SERVER_ID */
+ { OPTION_STRING , 0x38 }, /* DHCP_ERR_MESSAGE */
+ //TODO: must be combined with 'sname' and 'file' handling:
+- { OPTION_STRING , 0x42 }, /* DHCP_TFTP_SERVER_NAME */
++ { OPTION_STRING_HOST , 0x42 }, /* DHCP_TFTP_SERVER_NAME */
+ { OPTION_STRING , 0x43 }, /* DHCP_BOOT_FILE */
+ //TODO: not a string, but a set of LASCII strings:
+ // { OPTION_STRING , 0x4D }, /* DHCP_USER_CLASS */
+@@ -143,6 +143,7 @@ const uint8_t dhcp_option_lengths[] ALIG
+ [OPTION_IP_PAIR] = 8,
+ // [OPTION_BOOLEAN] = 1,
+ [OPTION_STRING] = 1, /* ignored by udhcp_str2optset */
++ [OPTION_STRING_HOST] = 1, /* ignored by udhcp_str2optset */
+ #if ENABLE_FEATURE_UDHCP_RFC3397
+ [OPTION_DNS_STRING] = 1, /* ignored by both udhcp_str2optset and xmalloc_optname_optval */
+ [OPTION_SIP_SERVERS] = 1,
+@@ -411,7 +412,9 @@ static NOINLINE void attach_option(
+ /* actually 255 is ok too, but adding a space can overlow it */
+
+ existing->data = xrealloc(existing->data, OPT_DATA + 1 + old_len + length);
+- if ((optflag->flags & OPTION_TYPE_MASK) == OPTION_STRING) {
++ if ((optflag->flags & OPTION_TYPE_MASK) == OPTION_STRING
++ || (optflag->flags & OPTION_TYPE_MASK) == OPTION_STRING_HOST
++ ) {
+ /* add space separator between STRING options in a list */
+ existing->data[OPT_DATA + old_len] = ' ';
+ old_len++;
+@@ -475,6 +478,7 @@ int FAST_FUNC udhcp_str2optset(const cha
+ retval = udhcp_str2nip(val, buffer + 4);
+ break;
+ case OPTION_STRING:
++ case OPTION_STRING_HOST:
+ #if ENABLE_FEATURE_UDHCP_RFC3397
+ case OPTION_DNS_STRING:
+ #endif
+--- a/networking/udhcp/common.h
++++ b/networking/udhcp/common.h
+@@ -80,6 +80,9 @@ enum {
+ OPTION_IP = 1,
+ OPTION_IP_PAIR,
+ OPTION_STRING,
++ /* Opts of STRING_HOST type will be sanitized before they are passed
++ * to udhcpc script's environment: */
++ OPTION_STRING_HOST,
+ // OPTION_BOOLEAN,
+ OPTION_U8,
+ OPTION_U16,
+--- a/networking/udhcp/dhcpc.c
++++ b/networking/udhcp/dhcpc.c
+@@ -101,6 +101,7 @@ static const uint8_t len_of_option_as_st
+ [OPTION_IP_PAIR ] = sizeof("255.255.255.255 ") * 2,
+ [OPTION_STATIC_ROUTES ] = sizeof("255.255.255.255/32 255.255.255.255 "),
+ [OPTION_STRING ] = 1,
++ [OPTION_STRING_HOST ] = 1,
+ #if ENABLE_FEATURE_UDHCP_RFC3397
+ [OPTION_DNS_STRING ] = 1, /* unused */
+ /* Hmmm, this severely overestimates size if SIP_SERVERS option
+@@ -135,6 +136,63 @@ static int mton(uint32_t mask)
+ return i;
+ }
+
++/* Check if a given label represents a valid DNS label
++ * Return pointer to the first character after the label upon success,
++ * NULL otherwise.
++ * See RFC1035, 2.3.1
++ */
++/* We don't need to be particularly anal. For example, allowing _, hyphen
++ * at the end, or leading and trailing dots would be ok, since it
++ * can't be used for attacks. (Leading hyphen can be, if someone uses
++ * cmd "$hostname"
++ * in the script: then hostname may be treated as an option)
++ */
++static const char *valid_domain_label(const char *label)
++{
++ unsigned char ch;
++ unsigned pos = 0;
++
++ for (;;) {
++ ch = *label;
++ if ((ch|0x20) < 'a' || (ch|0x20) > 'z') {
++ if (pos == 0) {
++ /* label must begin with letter */
++ return NULL;
++ }
++ if (ch < '0' || ch > '9') {
++ if (ch == '\0' || ch == '.')
++ return label;
++ /* DNS allows only '-', but we are more permissive */
++ if (ch != '-' && ch != '_')
++ return NULL;
++ }
++ }
++ label++;
++ pos++;
++ //Do we want this?
++ //if (pos > 63) /* NS_MAXLABEL; labels must be 63 chars or less */
++ // return NULL;
++ }
++}
++
++/* Check if a given name represents a valid DNS name */
++/* See RFC1035, 2.3.1 */
++static int good_hostname(const char *name)
++{
++ //const char *start = name;
++
++ for (;;) {
++ name = valid_domain_label(name);
++ if (!name)
++ return 0;
++ if (!name[0])
++ return 1;
++ //Do we want this?
++ //return ((name - start) < 1025); /* NS_MAXDNAME */
++ name++;
++ }
++}
++
+ /* Create "opt_name=opt_value" string */
+ static NOINLINE char *xmalloc_optname_optval(uint8_t *option, const struct dhcp_optflag *optflag, const char *opt_name)
+ {
+@@ -185,8 +243,11 @@ static NOINLINE char *xmalloc_optname_op
+ break;
+ }
+ case OPTION_STRING:
++ case OPTION_STRING_HOST:
+ memcpy(dest, option, len);
+ dest[len] = '\0';
++ if (type == OPTION_STRING_HOST && !good_hostname(dest))
++ safe_strncpy(dest, "bad", len);
+ return ret; /* Short circuit this case */
+ case OPTION_STATIC_ROUTES: {
+ /* Option binary format:
+@@ -314,6 +375,7 @@ static char **fill_envp(struct dhcp_pack
+ /* +1 element for each option, +2 for subnet option: */
+ if (packet) {
+ /* note: do not search for "pad" (0) and "end" (255) options */
++//TODO: change logic to scan packet _once_
+ for (i = 1; i < 255; i++) {
+ temp = udhcp_get_option(packet, i);
+ if (temp) {
diff --git a/package/busybox/patches/.svn/text-base/007-upstream_mkfs_ext2_fixes.patch.svn-base b/package/busybox/patches/.svn/text-base/007-upstream_mkfs_ext2_fixes.patch.svn-base
new file mode 100644
index 0000000..8528ee8
--- /dev/null
+++ b/package/busybox/patches/.svn/text-base/007-upstream_mkfs_ext2_fixes.patch.svn-base
@@ -0,0 +1,1441 @@
+--- a/e2fsprogs/e2fs_defs.h
++++ /dev/null
+@@ -1,561 +0,0 @@
+-/* vi: set sw=4 ts=4: */
+-/*
+- * linux/include/linux/ext2_fs.h
+- *
+- * Copyright (C) 1992, 1993, 1994, 1995
+- * Remy Card (card@masi.ibp.fr)
+- * Laboratoire MASI - Institut Blaise Pascal
+- * Universite Pierre et Marie Curie (Paris VI)
+- *
+- * Copyright (C) 1991, 1992 Linus Torvalds
+- */
+-
+-#ifndef LINUX_EXT2_FS_H
+-#define LINUX_EXT2_FS_H 1
+-
+-/*
+- * Special inode numbers
+- */
+-#define EXT2_BAD_INO 1 /* Bad blocks inode */
+-#define EXT2_ROOT_INO 2 /* Root inode */
+-#define EXT2_ACL_IDX_INO 3 /* ACL inode */
+-#define EXT2_ACL_DATA_INO 4 /* ACL inode */
+-#define EXT2_BOOT_LOADER_INO 5 /* Boot loader inode */
+-#define EXT2_UNDEL_DIR_INO 6 /* Undelete directory inode */
+-#define EXT2_RESIZE_INO 7 /* Reserved group descriptors inode */
+-#define EXT2_JOURNAL_INO 8 /* Journal inode */
+-
+-/* First non-reserved inode for old ext2 filesystems */
+-#define EXT2_GOOD_OLD_FIRST_INO 11
+-
+-/*
+- * The second extended file system magic number
+- */
+-#define EXT2_SUPER_MAGIC 0xEF53
+-
+-/* Assume that user mode programs are passing in an ext2fs superblock, not
+- * a kernel struct super_block. This will allow us to call the feature-test
+- * macros from user land. */
+-#define EXT2_SB(sb) (sb)
+-
+-/*
+- * Maximal count of links to a file
+- */
+-#define EXT2_LINK_MAX 32000
+-
+-/*
+- * Macro-instructions used to manage several block sizes
+- */
+-#define EXT2_MIN_BLOCK_LOG_SIZE 10 /* 1024 */
+-#define EXT2_MAX_BLOCK_LOG_SIZE 16 /* 65536 */
+-#define EXT2_MIN_BLOCK_SIZE (1 << EXT2_MIN_BLOCK_LOG_SIZE)
+-#define EXT2_MAX_BLOCK_SIZE (1 << EXT2_MAX_BLOCK_LOG_SIZE)
+-#define EXT2_BLOCK_SIZE(s) (EXT2_MIN_BLOCK_SIZE << (s)->s_log_block_size)
+-#define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10)
+-#define EXT2_INODE_SIZE(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \
+- EXT2_GOOD_OLD_INODE_SIZE : (s)->s_inode_size)
+-#define EXT2_FIRST_INO(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \
+- EXT2_GOOD_OLD_FIRST_INO : (s)->s_first_ino)
+-#define EXT2_ADDR_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof(uint32_t))
+-
+-/*
+- * Macro-instructions used to manage fragments
+- */
+-#define EXT2_MIN_FRAG_SIZE EXT2_MIN_BLOCK_SIZE
+-#define EXT2_MAX_FRAG_SIZE EXT2_MAX_BLOCK_SIZE
+-#define EXT2_MIN_FRAG_LOG_SIZE EXT2_MIN_BLOCK_LOG_SIZE
+-#define EXT2_FRAG_SIZE(s) (EXT2_MIN_FRAG_SIZE << (s)->s_log_frag_size)
+-#define EXT2_FRAGS_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / EXT2_FRAG_SIZE(s))
+-
+-/*
+- * ACL structures
+- */
+-struct ext2_acl_header { /* Header of Access Control Lists */
+- uint32_t aclh_size;
+- uint32_t aclh_file_count;
+- uint32_t aclh_acle_count;
+- uint32_t aclh_first_acle;
+-};
+-
+-struct ext2_acl_entry { /* Access Control List Entry */
+- uint32_t acle_size;
+- uint16_t acle_perms; /* Access permissions */
+- uint16_t acle_type; /* Type of entry */
+- uint16_t acle_tag; /* User or group identity */
+- uint16_t acle_pad1;
+- uint32_t acle_next; /* Pointer on next entry for the */
+- /* same inode or on next free entry */
+-};
+-
+-/*
+- * Structure of a blocks group descriptor
+- */
+-struct ext2_group_desc {
+- uint32_t bg_block_bitmap; /* Blocks bitmap block */
+- uint32_t bg_inode_bitmap; /* Inodes bitmap block */
+- uint32_t bg_inode_table; /* Inodes table block */
+- uint16_t bg_free_blocks_count; /* Free blocks count */
+- uint16_t bg_free_inodes_count; /* Free inodes count */
+- uint16_t bg_used_dirs_count; /* Directories count */
+- uint16_t bg_pad;
+- uint32_t bg_reserved[3];
+-};
+-
+-/*
+- * Data structures used by the directory indexing feature
+- *
+- * Note: all of the multibyte integer fields are little endian.
+- */
+-
+-/*
+- * Note: dx_root_info is laid out so that if it should somehow get
+- * overlaid by a dirent the two low bits of the hash version will be
+- * zero. Therefore, the hash version mod 4 should never be 0.
+- * Sincerely, the paranoia department.
+- */
+-struct ext2_dx_root_info {
+- uint32_t reserved_zero;
+- uint8_t hash_version; /* 0 now, 1 at release */
+- uint8_t info_length; /* 8 */
+- uint8_t indirect_levels;
+- uint8_t unused_flags;
+-};
+-
+-#define EXT2_HASH_LEGACY 0
+-#define EXT2_HASH_HALF_MD4 1
+-#define EXT2_HASH_TEA 2
+-
+-#define EXT2_HASH_FLAG_INCOMPAT 0x1
+-
+-struct ext2_dx_entry {
+- uint32_t hash;
+- uint32_t block;
+-};
+-
+-struct ext2_dx_countlimit {
+- uint16_t limit;
+- uint16_t count;
+-};
+-
+-
+-/*
+- * Macro-instructions used to manage group descriptors
+- */
+-#define EXT2_BLOCKS_PER_GROUP(s) (EXT2_SB(s)->s_blocks_per_group)
+-#define EXT2_INODES_PER_GROUP(s) (EXT2_SB(s)->s_inodes_per_group)
+-#define EXT2_INODES_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s)/EXT2_INODE_SIZE(s))
+-/* limits imposed by 16-bit value gd_free_{blocks,inode}_count */
+-#define EXT2_MAX_BLOCKS_PER_GROUP(s) ((1 << 16) - 8)
+-#define EXT2_MAX_INODES_PER_GROUP(s) ((1 << 16) - EXT2_INODES_PER_BLOCK(s))
+-#define EXT2_DESC_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_group_desc))
+-
+-/*
+- * Constants relative to the data blocks
+- */
+-#define EXT2_NDIR_BLOCKS 12
+-#define EXT2_IND_BLOCK EXT2_NDIR_BLOCKS
+-#define EXT2_DIND_BLOCK (EXT2_IND_BLOCK + 1)
+-#define EXT2_TIND_BLOCK (EXT2_DIND_BLOCK + 1)
+-#define EXT2_N_BLOCKS (EXT2_TIND_BLOCK + 1)
+-
+-/*
+- * Inode flags
+- */
+-#define EXT2_SECRM_FL 0x00000001 /* Secure deletion */
+-#define EXT2_UNRM_FL 0x00000002 /* Undelete */
+-#define EXT2_COMPR_FL 0x00000004 /* Compress file */
+-#define EXT2_SYNC_FL 0x00000008 /* Synchronous updates */
+-#define EXT2_IMMUTABLE_FL 0x00000010 /* Immutable file */
+-#define EXT2_APPEND_FL 0x00000020 /* writes to file may only append */
+-#define EXT2_NODUMP_FL 0x00000040 /* do not dump file */
+-#define EXT2_NOATIME_FL 0x00000080 /* do not update atime */
+-/* Reserved for compression usage... */
+-#define EXT2_DIRTY_FL 0x00000100
+-#define EXT2_COMPRBLK_FL 0x00000200 /* One or more compressed clusters */
+-#define EXT2_NOCOMPR_FL 0x00000400 /* Access raw compressed data */
+-#define EXT2_ECOMPR_FL 0x00000800 /* Compression error */
+-/* End compression flags --- maybe not all used */
+-#define EXT2_BTREE_FL 0x00001000 /* btree format dir */
+-#define EXT2_INDEX_FL 0x00001000 /* hash-indexed directory */
+-#define EXT2_IMAGIC_FL 0x00002000
+-#define EXT3_JOURNAL_DATA_FL 0x00004000 /* file data should be journaled */
+-#define EXT2_NOTAIL_FL 0x00008000 /* file tail should not be merged */
+-#define EXT2_DIRSYNC_FL 0x00010000 /* Synchronous directory modifications */
+-#define EXT2_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
+-#define EXT3_EXTENTS_FL 0x00080000 /* Inode uses extents */
+-#define EXT2_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
+-
+-#define EXT2_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
+-#define EXT2_FL_USER_MODIFIABLE 0x000080FF /* User modifiable flags */
+-
+-/*
+- * ioctl commands
+- */
+-#define EXT2_IOC_GETFLAGS _IOR('f', 1, long)
+-#define EXT2_IOC_SETFLAGS _IOW('f', 2, long)
+-#define EXT2_IOC_GETVERSION _IOR('v', 1, long)
+-#define EXT2_IOC_SETVERSION _IOW('v', 2, long)
+-
+-/*
+- * Structure of an inode on the disk
+- */
+-struct ext2_inode {
+- uint16_t i_mode; /* File mode */
+- uint16_t i_uid; /* Low 16 bits of Owner Uid */
+- uint32_t i_size; /* Size in bytes */
+- uint32_t i_atime; /* Access time */
+- uint32_t i_ctime; /* Creation time */
+- uint32_t i_mtime; /* Modification time */
+- uint32_t i_dtime; /* Deletion Time */
+- uint16_t i_gid; /* Low 16 bits of Group Id */
+- uint16_t i_links_count; /* Links count */
+- uint32_t i_blocks; /* Blocks count */
+- uint32_t i_flags; /* File flags */
+- union {
+- struct {
+- uint32_t l_i_reserved1;
+- } linux1;
+- struct {
+- uint32_t h_i_translator;
+- } hurd1;
+- struct {
+- uint32_t m_i_reserved1;
+- } masix1;
+- } osd1; /* OS dependent 1 */
+- uint32_t i_block[EXT2_N_BLOCKS];/* Pointers to blocks */
+- uint32_t i_generation; /* File version (for NFS) */
+- uint32_t i_file_acl; /* File ACL */
+- uint32_t i_dir_acl; /* Directory ACL */
+- uint32_t i_faddr; /* Fragment address */
+- union {
+- struct {
+- uint8_t l_i_frag; /* Fragment number */
+- uint8_t l_i_fsize; /* Fragment size */
+- uint16_t i_pad1;
+- uint16_t l_i_uid_high; /* these 2 fields */
+- uint16_t l_i_gid_high; /* were reserved2[0] */
+- uint32_t l_i_reserved2;
+- } linux2;
+- struct {
+- uint8_t h_i_frag; /* Fragment number */
+- uint8_t h_i_fsize; /* Fragment size */
+- uint16_t h_i_mode_high;
+- uint16_t h_i_uid_high;
+- uint16_t h_i_gid_high;
+- uint32_t h_i_author;
+- } hurd2;
+- struct {
+- uint8_t m_i_frag; /* Fragment number */
+- uint8_t m_i_fsize; /* Fragment size */
+- uint16_t m_pad1;
+- uint32_t m_i_reserved2[2];
+- } masix2;
+- } osd2; /* OS dependent 2 */
+-};
+-
+-/*
+- * Permanent part of an large inode on the disk
+- */
+-struct ext2_inode_large {
+- uint16_t i_mode; /* File mode */
+- uint16_t i_uid; /* Low 16 bits of Owner Uid */
+- uint32_t i_size; /* Size in bytes */
+- uint32_t i_atime; /* Access time */
+- uint32_t i_ctime; /* Creation time */
+- uint32_t i_mtime; /* Modification time */
+- uint32_t i_dtime; /* Deletion Time */
+- uint16_t i_gid; /* Low 16 bits of Group Id */
+- uint16_t i_links_count; /* Links count */
+- uint32_t i_blocks; /* Blocks count */
+- uint32_t i_flags; /* File flags */
+- union {
+- struct {
+- uint32_t l_i_reserved1;
+- } linux1;
+- struct {
+- uint32_t h_i_translator;
+- } hurd1;
+- struct {
+- uint32_t m_i_reserved1;
+- } masix1;
+- } osd1; /* OS dependent 1 */
+- uint32_t i_block[EXT2_N_BLOCKS];/* Pointers to blocks */
+- uint32_t i_generation; /* File version (for NFS) */
+- uint32_t i_file_acl; /* File ACL */
+- uint32_t i_dir_acl; /* Directory ACL */
+- uint32_t i_faddr; /* Fragment address */
+- union {
+- struct {
+- uint8_t l_i_frag; /* Fragment number */
+- uint8_t l_i_fsize; /* Fragment size */
+- uint16_t i_pad1;
+- uint16_t l_i_uid_high; /* these 2 fields */
+- uint16_t l_i_gid_high; /* were reserved2[0] */
+- uint32_t l_i_reserved2;
+- } linux2;
+- struct {
+- uint8_t h_i_frag; /* Fragment number */
+- uint8_t h_i_fsize; /* Fragment size */
+- uint16_t h_i_mode_high;
+- uint16_t h_i_uid_high;
+- uint16_t h_i_gid_high;
+- uint32_t h_i_author;
+- } hurd2;
+- struct {
+- uint8_t m_i_frag; /* Fragment number */
+- uint8_t m_i_fsize; /* Fragment size */
+- uint16_t m_pad1;
+- uint32_t m_i_reserved2[2];
+- } masix2;
+- } osd2; /* OS dependent 2 */
+- uint16_t i_extra_isize;
+- uint16_t i_pad1;
+-};
+-
+-#define i_size_high i_dir_acl
+-
+-/*
+- * File system states
+- */
+-#define EXT2_VALID_FS 0x0001 /* Unmounted cleanly */
+-#define EXT2_ERROR_FS 0x0002 /* Errors detected */
+-
+-/*
+- * Mount flags
+- */
+-#define EXT2_MOUNT_CHECK 0x0001 /* Do mount-time checks */
+-#define EXT2_MOUNT_GRPID 0x0004 /* Create files with directory's group */
+-#define EXT2_MOUNT_DEBUG 0x0008 /* Some debugging messages */
+-#define EXT2_MOUNT_ERRORS_CONT 0x0010 /* Continue on errors */
+-#define EXT2_MOUNT_ERRORS_RO 0x0020 /* Remount fs ro on errors */
+-#define EXT2_MOUNT_ERRORS_PANIC 0x0040 /* Panic on errors */
+-#define EXT2_MOUNT_MINIX_DF 0x0080 /* Mimics the Minix statfs */
+-#define EXT2_MOUNT_NO_UID32 0x0200 /* Disable 32-bit UIDs */
+-
+-#define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
+-#define set_opt(o, opt) o |= EXT2_MOUNT_##opt
+-#define test_opt(sb, opt) (EXT2_SB(sb)->s_mount_opt & \
+- EXT2_MOUNT_##opt)
+-/*
+- * Maximal mount counts between two filesystem checks
+- */
+-#define EXT2_DFL_MAX_MNT_COUNT 20 /* Allow 20 mounts */
+-#define EXT2_DFL_CHECKINTERVAL 0 /* Don't use interval check */
+-
+-/*
+- * Behaviour when detecting errors
+- */
+-#define EXT2_ERRORS_CONTINUE 1 /* Continue execution */
+-#define EXT2_ERRORS_RO 2 /* Remount fs read-only */
+-#define EXT2_ERRORS_PANIC 3 /* Panic */
+-#define EXT2_ERRORS_DEFAULT EXT2_ERRORS_CONTINUE
+-
+-/*
+- * Structure of the super block
+- */
+-struct ext2_super_block {
+- uint32_t s_inodes_count; /* Inodes count */
+- uint32_t s_blocks_count; /* Blocks count */
+- uint32_t s_r_blocks_count; /* Reserved blocks count */
+- uint32_t s_free_blocks_count; /* Free blocks count */
+- uint32_t s_free_inodes_count; /* Free inodes count */
+- uint32_t s_first_data_block; /* First Data Block */
+- uint32_t s_log_block_size; /* Block size */
+- int32_t s_log_frag_size; /* Fragment size */
+- uint32_t s_blocks_per_group; /* # Blocks per group */
+- uint32_t s_frags_per_group; /* # Fragments per group */
+- uint32_t s_inodes_per_group; /* # Inodes per group */
+- uint32_t s_mtime; /* Mount time */
+- uint32_t s_wtime; /* Write time */
+- uint16_t s_mnt_count; /* Mount count */
+- int16_t s_max_mnt_count; /* Maximal mount count */
+- uint16_t s_magic; /* Magic signature */
+- uint16_t s_state; /* File system state */
+- uint16_t s_errors; /* Behaviour when detecting errors */
+- uint16_t s_minor_rev_level; /* minor revision level */
+- uint32_t s_lastcheck; /* time of last check */
+- uint32_t s_checkinterval; /* max. time between checks */
+- uint32_t s_creator_os; /* OS */
+- uint32_t s_rev_level; /* Revision level */
+- uint16_t s_def_resuid; /* Default uid for reserved blocks */
+- uint16_t s_def_resgid; /* Default gid for reserved blocks */
+- /*
+- * These fields are for EXT2_DYNAMIC_REV superblocks only.
+- *
+- * Note: the difference between the compatible feature set and
+- * the incompatible feature set is that if there is a bit set
+- * in the incompatible feature set that the kernel doesn't
+- * know about, it should refuse to mount the filesystem.
+- *
+- * e2fsck's requirements are more strict; if it doesn't know
+- * about a feature in either the compatible or incompatible
+- * feature set, it must abort and not try to meddle with
+- * things it doesn't understand...
+- */
+- uint32_t s_first_ino; /* First non-reserved inode */
+- uint16_t s_inode_size; /* size of inode structure */
+- uint16_t s_block_group_nr; /* block group # of this superblock */
+- uint32_t s_feature_compat; /* compatible feature set */
+- uint32_t s_feature_incompat; /* incompatible feature set */
+- uint32_t s_feature_ro_compat; /* readonly-compatible feature set */
+- uint8_t s_uuid[16]; /* 128-bit uuid for volume */
+- char s_volume_name[16]; /* volume name */
+- char s_last_mounted[64]; /* directory where last mounted */
+- uint32_t s_algorithm_usage_bitmap; /* For compression */
+- /*
+- * Performance hints. Directory preallocation should only
+- * happen if the EXT2_FEATURE_COMPAT_DIR_PREALLOC flag is on.
+- */
+- uint8_t s_prealloc_blocks; /* Nr of blocks to try to preallocate*/
+- uint8_t s_prealloc_dir_blocks; /* Nr to preallocate for dirs */
+- uint16_t s_reserved_gdt_blocks; /* Per group table for online growth */
+- /*
+- * Journaling support valid if EXT2_FEATURE_COMPAT_HAS_JOURNAL set.
+- */
+- uint8_t s_journal_uuid[16]; /* uuid of journal superblock */
+- uint32_t s_journal_inum; /* inode number of journal file */
+- uint32_t s_journal_dev; /* device number of journal file */
+- uint32_t s_last_orphan; /* start of list of inodes to delete */
+- uint32_t s_hash_seed[4]; /* HTREE hash seed */
+- uint8_t s_def_hash_version; /* Default hash version to use */
+- uint8_t s_jnl_backup_type; /* Default type of journal backup */
+- uint16_t s_reserved_word_pad;
+- uint32_t s_default_mount_opts;
+- uint32_t s_first_meta_bg; /* First metablock group */
+- uint32_t s_mkfs_time; /* When the filesystem was created */
+- uint32_t s_jnl_blocks[17]; /* Backup of the journal inode */
+- uint32_t s_reserved[172]; /* Padding to the end of the block */
+-};
+-
+-/*
+- * Codes for operating systems
+- */
+-#define EXT2_OS_LINUX 0
+-#define EXT2_OS_HURD 1
+-#define EXT2_OS_MASIX 2
+-#define EXT2_OS_FREEBSD 3
+-#define EXT2_OS_LITES 4
+-
+-/*
+- * Revision levels
+- */
+-#define EXT2_GOOD_OLD_REV 0 /* The good old (original) format */
+-#define EXT2_DYNAMIC_REV 1 /* V2 format w/ dynamic inode sizes */
+-
+-#define EXT2_CURRENT_REV EXT2_GOOD_OLD_REV
+-#define EXT2_MAX_SUPP_REV EXT2_DYNAMIC_REV
+-
+-#define EXT2_GOOD_OLD_INODE_SIZE 128
+-
+-/*
+- * Journal inode backup types
+- */
+-#define EXT3_JNL_BACKUP_BLOCKS 1
+-
+-/*
+- * Feature set definitions
+- */
+-
+-#define EXT2_HAS_COMPAT_FEATURE(sb,mask) \
+- ( EXT2_SB(sb)->s_feature_compat & (mask) )
+-#define EXT2_HAS_RO_COMPAT_FEATURE(sb,mask) \
+- ( EXT2_SB(sb)->s_feature_ro_compat & (mask) )
+-#define EXT2_HAS_INCOMPAT_FEATURE(sb,mask) \
+- ( EXT2_SB(sb)->s_feature_incompat & (mask) )
+-
+-#define EXT2_FEATURE_COMPAT_DIR_PREALLOC 0x0001
+-#define EXT2_FEATURE_COMPAT_IMAGIC_INODES 0x0002
+-#define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x0004
+-#define EXT2_FEATURE_COMPAT_EXT_ATTR 0x0008
+-#define EXT2_FEATURE_COMPAT_RESIZE_INODE 0x0010
+-#define EXT2_FEATURE_COMPAT_DIR_INDEX 0x0020
+-
+-#define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001
+-#define EXT2_FEATURE_RO_COMPAT_LARGE_FILE 0x0002
+-/* #define EXT2_FEATURE_RO_COMPAT_BTREE_DIR 0x0004 not used */
+-
+-#define EXT2_FEATURE_INCOMPAT_COMPRESSION 0x0001
+-#define EXT2_FEATURE_INCOMPAT_FILETYPE 0x0002
+-#define EXT3_FEATURE_INCOMPAT_RECOVER 0x0004 /* Needs recovery */
+-#define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008 /* Journal device */
+-#define EXT2_FEATURE_INCOMPAT_META_BG 0x0010
+-#define EXT3_FEATURE_INCOMPAT_EXTENTS 0x0040
+-
+-
+-#define EXT2_FEATURE_COMPAT_SUPP 0
+-#define EXT2_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE)
+-#define EXT2_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \
+- EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \
+- EXT2_FEATURE_RO_COMPAT_BTREE_DIR)
+-
+-/*
+- * Default values for user and/or group using reserved blocks
+- */
+-#define EXT2_DEF_RESUID 0
+-#define EXT2_DEF_RESGID 0
+-
+-/*
+- * Default mount options
+- */
+-#define EXT2_DEFM_DEBUG 0x0001
+-#define EXT2_DEFM_BSDGROUPS 0x0002
+-#define EXT2_DEFM_XATTR_USER 0x0004
+-#define EXT2_DEFM_ACL 0x0008
+-#define EXT2_DEFM_UID16 0x0010
+-#define EXT3_DEFM_JMODE 0x0060
+-#define EXT3_DEFM_JMODE_DATA 0x0020
+-#define EXT3_DEFM_JMODE_ORDERED 0x0040
+-#define EXT3_DEFM_JMODE_WBACK 0x0060
+-
+-/*
+- * Structure of a directory entry
+- */
+-#define EXT2_NAME_LEN 255
+-
+-struct ext2_dir_entry {
+- uint32_t inode; /* Inode number */
+- uint16_t rec_len; /* Directory entry length */
+- uint16_t name_len; /* Name length */
+- char name[EXT2_NAME_LEN]; /* File name */
+-};
+-
+-/*
+- * The new version of the directory entry. Since EXT2 structures are
+- * stored in intel byte order, and the name_len field could never be
+- * bigger than 255 chars, it's safe to reclaim the extra byte for the
+- * file_type field.
+- */
+-struct ext2_dir_entry_2 {
+- uint32_t inode; /* Inode number */
+- uint16_t rec_len; /* Directory entry length */
+- uint8_t name_len; /* Name length */
+- uint8_t file_type;
+- char name[EXT2_NAME_LEN]; /* File name */
+-};
+-
+-/*
+- * Ext2 directory file types. Only the low 3 bits are used. The
+- * other bits are reserved for now.
+- */
+-#define EXT2_FT_UNKNOWN 0
+-#define EXT2_FT_REG_FILE 1
+-#define EXT2_FT_DIR 2
+-#define EXT2_FT_CHRDEV 3
+-#define EXT2_FT_BLKDEV 4
+-#define EXT2_FT_FIFO 5
+-#define EXT2_FT_SOCK 6
+-#define EXT2_FT_SYMLINK 7
+-
+-#define EXT2_FT_MAX 8
+-
+-/*
+- * EXT2_DIR_PAD defines the directory entries boundaries
+- *
+- * NOTE: It must be a multiple of 4
+- */
+-#define EXT2_DIR_PAD 4
+-#define EXT2_DIR_ROUND (EXT2_DIR_PAD - 1)
+-#define EXT2_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT2_DIR_ROUND) & \
+- ~EXT2_DIR_ROUND)
+-
+-#endif
+--- a/e2fsprogs/e2fs_lib.h
++++ b/e2fsprogs/e2fs_lib.h
+@@ -7,7 +7,7 @@
+ */
+
+ /* Constants and structures */
+-#include "e2fs_defs.h"
++#include "bb_e2fs_defs.h"
+
+ PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN
+
+--- a/e2fsprogs/old_e2fsprogs/e2fsck.c
++++ b/e2fsprogs/old_e2fsprogs/e2fsck.c
+@@ -11577,7 +11577,7 @@ static void check_resize_inode(e2fsck_t
+ * s_reserved_gdt_blocks must be zero.
+ */
+ if (!(fs->super->s_feature_compat &
+- EXT2_FEATURE_COMPAT_RESIZE_INODE)) {
++ EXT2_FEATURE_COMPAT_RESIZE_INO)) {
+ if (fs->super->s_reserved_gdt_blocks) {
+ pctx.num = fs->super->s_reserved_gdt_blocks;
+ if (fix_problem(ctx, PR_0_NONZERO_RESERVED_GDT_BLOCKS,
+@@ -11593,7 +11593,7 @@ static void check_resize_inode(e2fsck_t
+ retval = ext2fs_read_inode(fs, EXT2_RESIZE_INO, &inode);
+ if (retval) {
+ if (fs->super->s_feature_compat &
+- EXT2_FEATURE_COMPAT_RESIZE_INODE)
++ EXT2_FEATURE_COMPAT_RESIZE_INO)
+ ctx->flags |= E2F_FLAG_RESIZE_INODE;
+ return;
+ }
+@@ -11603,7 +11603,7 @@ static void check_resize_inode(e2fsck_t
+ * the resize inode is cleared; then we're done.
+ */
+ if (!(fs->super->s_feature_compat &
+- EXT2_FEATURE_COMPAT_RESIZE_INODE)) {
++ EXT2_FEATURE_COMPAT_RESIZE_INO)) {
+ for (i=0; i < EXT2_N_BLOCKS; i++) {
+ if (inode.i_block[i])
+ break;
+--- a/e2fsprogs/old_e2fsprogs/e2p/feature.c
++++ b/e2fsprogs/old_e2fsprogs/e2p/feature.c
+@@ -34,7 +34,7 @@ static const struct feature feature_list
+ "ext_attr" },
+ { E2P_FEATURE_COMPAT, EXT2_FEATURE_COMPAT_DIR_INDEX,
+ "dir_index" },
+- { E2P_FEATURE_COMPAT, EXT2_FEATURE_COMPAT_RESIZE_INODE,
++ { E2P_FEATURE_COMPAT, EXT2_FEATURE_COMPAT_RESIZE_INO,
+ "resize_inode" },
+ { E2P_FEATURE_RO_INCOMPAT, EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER,
+ "sparse_super" },
+--- a/e2fsprogs/old_e2fsprogs/ext2fs/ext2_fs.h
++++ b/e2fsprogs/old_e2fsprogs/ext2fs/ext2_fs.h
+@@ -475,7 +475,7 @@ struct ext2_super_block {
+ #define EXT2_FEATURE_COMPAT_IMAGIC_INODES 0x0002
+ #define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x0004
+ #define EXT2_FEATURE_COMPAT_EXT_ATTR 0x0008
+-#define EXT2_FEATURE_COMPAT_RESIZE_INODE 0x0010
++#define EXT2_FEATURE_COMPAT_RESIZE_INO 0x0010
+ #define EXT2_FEATURE_COMPAT_DIR_INDEX 0x0020
+
+ #define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001
+--- a/e2fsprogs/old_e2fsprogs/ext2fs/ext2fs.h
++++ b/e2fsprogs/old_e2fsprogs/ext2fs/ext2fs.h
+@@ -383,7 +383,7 @@ typedef struct ext2_icount *ext2_icount_
+ #define EXT2_LIB_FEATURE_COMPAT_SUPP (EXT2_FEATURE_COMPAT_DIR_PREALLOC|\
+ EXT2_FEATURE_COMPAT_IMAGIC_INODES|\
+ EXT3_FEATURE_COMPAT_HAS_JOURNAL|\
+- EXT2_FEATURE_COMPAT_RESIZE_INODE|\
++ EXT2_FEATURE_COMPAT_RESIZE_INO|\
+ EXT2_FEATURE_COMPAT_DIR_INDEX|\
+ EXT2_FEATURE_COMPAT_EXT_ATTR)
+
+--- a/e2fsprogs/old_e2fsprogs/ext2fs/initialize.c
++++ b/e2fsprogs/old_e2fsprogs/ext2fs/initialize.c
+@@ -284,7 +284,7 @@ retry:
+ /*
+ * check the number of reserved group descriptor table blocks
+ */
+- if (super->s_feature_compat & EXT2_FEATURE_COMPAT_RESIZE_INODE)
++ if (super->s_feature_compat & EXT2_FEATURE_COMPAT_RESIZE_INO)
+ rsv_gdt = calc_reserved_gdt_blocks(fs);
+ else
+ rsv_gdt = 0;
+--- a/e2fsprogs/old_e2fsprogs/mke2fs.c
++++ b/e2fsprogs/old_e2fsprogs/mke2fs.c
+@@ -757,7 +757,7 @@ static void parse_extended_opts(struct e
+
+ if (rsv_gdb > 0) {
+ sb_param->s_feature_compat |=
+- EXT2_FEATURE_COMPAT_RESIZE_INODE;
++ EXT2_FEATURE_COMPAT_RESIZE_INO;
+
+ sb_param->s_reserved_gdt_blocks = rsv_gdb;
+ }
+@@ -778,7 +778,7 @@ static void parse_extended_opts(struct e
+
+ static __u32 ok_features[3] = {
+ EXT3_FEATURE_COMPAT_HAS_JOURNAL |
+- EXT2_FEATURE_COMPAT_RESIZE_INODE |
++ EXT2_FEATURE_COMPAT_RESIZE_INO |
+ EXT2_FEATURE_COMPAT_DIR_INDEX, /* Compat */
+ EXT2_FEATURE_INCOMPAT_FILETYPE| /* Incompat */
+ EXT3_FEATURE_INCOMPAT_JOURNAL_DEV|
+@@ -1123,7 +1123,7 @@ static int PRS(int argc, char **argv)
+ /* Since sparse_super is the default, we would only have a problem
+ * here if it was explicitly disabled.
+ */
+- if ((param.s_feature_compat & EXT2_FEATURE_COMPAT_RESIZE_INODE) &&
++ if ((param.s_feature_compat & EXT2_FEATURE_COMPAT_RESIZE_INO) &&
+ !(param.s_feature_ro_compat&EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER)) {
+ bb_error_msg_and_die("reserved online resize blocks not supported "
+ "on non-sparse filesystem");
+@@ -1312,7 +1312,7 @@ int mke2fs_main (int argc, char **argv)
+ reserve_inodes(fs);
+ create_bad_block_inode(fs, bb_list);
+ if (fs->super->s_feature_compat &
+- EXT2_FEATURE_COMPAT_RESIZE_INODE) {
++ EXT2_FEATURE_COMPAT_RESIZE_INO) {
+ retval = ext2fs_create_resize_inode(fs);
+ mke2fs_error_msg_and_die(retval, "reserve blocks for online resize");
+ }
+--- a/e2fsprogs/tune2fs.c
++++ b/e2fsprogs/tune2fs.c
+@@ -8,7 +8,7 @@
+ */
+ #include "libbb.h"
+ #include <linux/fs.h>
+-#include <linux/ext2_fs.h>
++#include "bb_e2fs_defs.h"
+
+ // storage helpers
+ char BUG_wrong_field_size(void);
+--- /dev/null
++++ b/include/bb_e2fs_defs.h
+@@ -0,0 +1,602 @@
++/* vi: set sw=4 ts=4: */
++/*
++ * linux/include/linux/ext2_fs.h
++ *
++ * Copyright (C) 1992, 1993, 1994, 1995
++ * Remy Card (card@masi.ibp.fr)
++ * Laboratoire MASI - Institut Blaise Pascal
++ * Universite Pierre et Marie Curie (Paris VI)
++ *
++ * Copyright (C) 1991, 1992 Linus Torvalds
++ */
++
++#ifndef LINUX_EXT2_FS_H
++#define LINUX_EXT2_FS_H 1
++
++/*
++ * Special inode numbers
++ */
++#define EXT2_BAD_INO 1 /* Bad blocks inode */
++#define EXT2_ROOT_INO 2 /* Root inode */
++#define EXT2_ACL_IDX_INO 3 /* ACL inode */
++#define EXT2_ACL_DATA_INO 4 /* ACL inode */
++#define EXT2_BOOT_LOADER_INO 5 /* Boot loader inode */
++#define EXT2_UNDEL_DIR_INO 6 /* Undelete directory inode */
++#define EXT2_RESIZE_INO 7 /* Reserved group descriptors inode */
++#define EXT2_JOURNAL_INO 8 /* Journal inode */
++
++/* First non-reserved inode for old ext2 filesystems */
++#define EXT2_GOOD_OLD_FIRST_INO 11
++
++/*
++ * The second extended file system magic number
++ */
++#define EXT2_SUPER_MAGIC 0xEF53
++
++/* Assume that user mode programs are passing in an ext2fs superblock, not
++ * a kernel struct super_block. This will allow us to call the feature-test
++ * macros from user land. */
++#define EXT2_SB(sb) (sb)
++
++/*
++ * Maximal count of links to a file
++ */
++#define EXT2_LINK_MAX 32000
++
++/*
++ * Macro-instructions used to manage several block sizes
++ */
++#define EXT2_MIN_BLOCK_LOG_SIZE 10 /* 1024 */
++#define EXT2_MAX_BLOCK_LOG_SIZE 16 /* 65536 */
++#define EXT2_MIN_BLOCK_SIZE (1 << EXT2_MIN_BLOCK_LOG_SIZE)
++#define EXT2_MAX_BLOCK_SIZE (1 << EXT2_MAX_BLOCK_LOG_SIZE)
++#define EXT2_BLOCK_SIZE(s) (EXT2_MIN_BLOCK_SIZE << (s)->s_log_block_size)
++#define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10)
++#define EXT2_INODE_SIZE(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \
++ EXT2_GOOD_OLD_INODE_SIZE : (s)->s_inode_size)
++#define EXT2_FIRST_INO(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \
++ EXT2_GOOD_OLD_FIRST_INO : (s)->s_first_ino)
++#define EXT2_ADDR_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof(uint32_t))
++
++/*
++ * Macro-instructions used to manage fragments
++ */
++#define EXT2_MIN_FRAG_SIZE EXT2_MIN_BLOCK_SIZE
++#define EXT2_MAX_FRAG_SIZE EXT2_MAX_BLOCK_SIZE
++#define EXT2_MIN_FRAG_LOG_SIZE EXT2_MIN_BLOCK_LOG_SIZE
++#define EXT2_FRAG_SIZE(s) (EXT2_MIN_FRAG_SIZE << (s)->s_log_frag_size)
++#define EXT2_FRAGS_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / EXT2_FRAG_SIZE(s))
++
++/*
++ * ACL structures
++ */
++struct ext2_acl_header { /* Header of Access Control Lists */
++ uint32_t aclh_size;
++ uint32_t aclh_file_count;
++ uint32_t aclh_acle_count;
++ uint32_t aclh_first_acle;
++};
++
++struct ext2_acl_entry { /* Access Control List Entry */
++ uint32_t acle_size;
++ uint16_t acle_perms; /* Access permissions */
++ uint16_t acle_type; /* Type of entry */
++ uint16_t acle_tag; /* User or group identity */
++ uint16_t acle_pad1;
++ uint32_t acle_next; /* Pointer on next entry for the */
++ /* same inode or on next free entry */
++};
++
++/*
++ * Structure of a blocks group descriptor
++ */
++struct ext2_group_desc {
++ uint32_t bg_block_bitmap; /* Blocks bitmap block */
++ uint32_t bg_inode_bitmap; /* Inodes bitmap block */
++ uint32_t bg_inode_table; /* Inodes table block */
++ uint16_t bg_free_blocks_count; /* Free blocks count */
++ uint16_t bg_free_inodes_count; /* Free inodes count */
++ uint16_t bg_used_dirs_count; /* Directories count */
++ uint16_t bg_pad;
++ uint32_t bg_reserved[3];
++};
++
++/*
++ * Data structures used by the directory indexing feature
++ *
++ * Note: all of the multibyte integer fields are little endian.
++ */
++
++/*
++ * Note: dx_root_info is laid out so that if it should somehow get
++ * overlaid by a dirent the two low bits of the hash version will be
++ * zero. Therefore, the hash version mod 4 should never be 0.
++ * Sincerely, the paranoia department.
++ */
++struct ext2_dx_root_info {
++ uint32_t reserved_zero;
++ uint8_t hash_version; /* 0 now, 1 at release */
++ uint8_t info_length; /* 8 */
++ uint8_t indirect_levels;
++ uint8_t unused_flags;
++};
++
++#define EXT2_HASH_LEGACY 0
++#define EXT2_HASH_HALF_MD4 1
++#define EXT2_HASH_TEA 2
++
++#define EXT2_HASH_FLAG_INCOMPAT 0x1
++
++struct ext2_dx_entry {
++ uint32_t hash;
++ uint32_t block;
++};
++
++struct ext2_dx_countlimit {
++ uint16_t limit;
++ uint16_t count;
++};
++
++
++/*
++ * Macro-instructions used to manage group descriptors
++ */
++#define EXT2_BLOCKS_PER_GROUP(s) (EXT2_SB(s)->s_blocks_per_group)
++#define EXT2_INODES_PER_GROUP(s) (EXT2_SB(s)->s_inodes_per_group)
++#define EXT2_INODES_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s)/EXT2_INODE_SIZE(s))
++/* limits imposed by 16-bit value gd_free_{blocks,inode}_count */
++#define EXT2_MAX_BLOCKS_PER_GROUP(s) ((1 << 16) - 8)
++#define EXT2_MAX_INODES_PER_GROUP(s) ((1 << 16) - EXT2_INODES_PER_BLOCK(s))
++#define EXT2_DESC_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_group_desc))
++
++/*
++ * Constants relative to the data blocks
++ */
++#define EXT2_NDIR_BLOCKS 12
++#define EXT2_IND_BLOCK EXT2_NDIR_BLOCKS
++#define EXT2_DIND_BLOCK (EXT2_IND_BLOCK + 1)
++#define EXT2_TIND_BLOCK (EXT2_DIND_BLOCK + 1)
++#define EXT2_N_BLOCKS (EXT2_TIND_BLOCK + 1)
++
++/*
++ * Inode flags
++ */
++#define EXT2_SECRM_FL 0x00000001 /* Secure deletion */
++#define EXT2_UNRM_FL 0x00000002 /* Undelete */
++#define EXT2_COMPR_FL 0x00000004 /* Compress file */
++#define EXT2_SYNC_FL 0x00000008 /* Synchronous updates */
++#define EXT2_IMMUTABLE_FL 0x00000010 /* Immutable file */
++#define EXT2_APPEND_FL 0x00000020 /* writes to file may only append */
++#define EXT2_NODUMP_FL 0x00000040 /* do not dump file */
++#define EXT2_NOATIME_FL 0x00000080 /* do not update atime */
++/* Reserved for compression usage... */
++#define EXT2_DIRTY_FL 0x00000100
++#define EXT2_COMPRBLK_FL 0x00000200 /* One or more compressed clusters */
++#define EXT2_NOCOMPR_FL 0x00000400 /* Access raw compressed data */
++#define EXT2_ECOMPR_FL 0x00000800 /* Compression error */
++/* End compression flags --- maybe not all used */
++#define EXT2_BTREE_FL 0x00001000 /* btree format dir */
++#define EXT2_INDEX_FL 0x00001000 /* hash-indexed directory */
++#define EXT2_IMAGIC_FL 0x00002000
++#define EXT3_JOURNAL_DATA_FL 0x00004000 /* file data should be journaled */
++#define EXT2_NOTAIL_FL 0x00008000 /* file tail should not be merged */
++#define EXT2_DIRSYNC_FL 0x00010000 /* Synchronous directory modifications */
++#define EXT2_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
++#define EXT3_EXTENTS_FL 0x00080000 /* Inode uses extents */
++#define EXT2_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
++
++#define EXT2_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
++#define EXT2_FL_USER_MODIFIABLE 0x000080FF /* User modifiable flags */
++
++/*
++ * ioctl commands
++ */
++#define EXT2_IOC_GETFLAGS _IOR('f', 1, long)
++#define EXT2_IOC_SETFLAGS _IOW('f', 2, long)
++#define EXT2_IOC_GETVERSION _IOR('v', 1, long)
++#define EXT2_IOC_SETVERSION _IOW('v', 2, long)
++
++/*
++ * Structure of an inode on the disk
++ */
++struct ext2_inode {
++ uint16_t i_mode; /* File mode */
++ uint16_t i_uid; /* Low 16 bits of Owner Uid */
++ uint32_t i_size; /* Size in bytes */
++ uint32_t i_atime; /* Access time */
++ uint32_t i_ctime; /* Creation time */
++ uint32_t i_mtime; /* Modification time */
++ uint32_t i_dtime; /* Deletion Time */
++ uint16_t i_gid; /* Low 16 bits of Group Id */
++ uint16_t i_links_count; /* Links count */
++ uint32_t i_blocks; /* Blocks count */
++ uint32_t i_flags; /* File flags */
++ union {
++ struct {
++ uint32_t l_i_reserved1;
++ } linux1;
++ struct {
++ uint32_t h_i_translator;
++ } hurd1;
++ struct {
++ uint32_t m_i_reserved1;
++ } masix1;
++ } osd1; /* OS dependent 1 */
++ uint32_t i_block[EXT2_N_BLOCKS];/* Pointers to blocks */
++ uint32_t i_generation; /* File version (for NFS) */
++ uint32_t i_file_acl; /* File ACL */
++ uint32_t i_dir_acl; /* Directory ACL */
++ uint32_t i_faddr; /* Fragment address */
++ union {
++ struct {
++ uint8_t l_i_frag; /* Fragment number */
++ uint8_t l_i_fsize; /* Fragment size */
++ uint16_t i_pad1;
++ uint16_t l_i_uid_high; /* these 2 fields */
++ uint16_t l_i_gid_high; /* were reserved2[0] */
++ uint32_t l_i_reserved2;
++ } linux2;
++ struct {
++ uint8_t h_i_frag; /* Fragment number */
++ uint8_t h_i_fsize; /* Fragment size */
++ uint16_t h_i_mode_high;
++ uint16_t h_i_uid_high;
++ uint16_t h_i_gid_high;
++ uint32_t h_i_author;
++ } hurd2;
++ struct {
++ uint8_t m_i_frag; /* Fragment number */
++ uint8_t m_i_fsize; /* Fragment size */
++ uint16_t m_pad1;
++ uint32_t m_i_reserved2[2];
++ } masix2;
++ } osd2; /* OS dependent 2 */
++};
++
++/*
++ * Permanent part of an large inode on the disk
++ */
++struct ext2_inode_large {
++ uint16_t i_mode; /* File mode */
++ uint16_t i_uid; /* Low 16 bits of Owner Uid */
++ uint32_t i_size; /* Size in bytes */
++ uint32_t i_atime; /* Access time */
++ uint32_t i_ctime; /* Creation time */
++ uint32_t i_mtime; /* Modification time */
++ uint32_t i_dtime; /* Deletion Time */
++ uint16_t i_gid; /* Low 16 bits of Group Id */
++ uint16_t i_links_count; /* Links count */
++ uint32_t i_blocks; /* Blocks count */
++ uint32_t i_flags; /* File flags */
++ union {
++ struct {
++ uint32_t l_i_reserved1;
++ } linux1;
++ struct {
++ uint32_t h_i_translator;
++ } hurd1;
++ struct {
++ uint32_t m_i_reserved1;
++ } masix1;
++ } osd1; /* OS dependent 1 */
++ uint32_t i_block[EXT2_N_BLOCKS];/* Pointers to blocks */
++ uint32_t i_generation; /* File version (for NFS) */
++ uint32_t i_file_acl; /* File ACL */
++ uint32_t i_dir_acl; /* Directory ACL */
++ uint32_t i_faddr; /* Fragment address */
++ union {
++ struct {
++ uint8_t l_i_frag; /* Fragment number */
++ uint8_t l_i_fsize; /* Fragment size */
++ uint16_t i_pad1;
++ uint16_t l_i_uid_high; /* these 2 fields */
++ uint16_t l_i_gid_high; /* were reserved2[0] */
++ uint32_t l_i_reserved2;
++ } linux2;
++ struct {
++ uint8_t h_i_frag; /* Fragment number */
++ uint8_t h_i_fsize; /* Fragment size */
++ uint16_t h_i_mode_high;
++ uint16_t h_i_uid_high;
++ uint16_t h_i_gid_high;
++ uint32_t h_i_author;
++ } hurd2;
++ struct {
++ uint8_t m_i_frag; /* Fragment number */
++ uint8_t m_i_fsize; /* Fragment size */
++ uint16_t m_pad1;
++ uint32_t m_i_reserved2[2];
++ } masix2;
++ } osd2; /* OS dependent 2 */
++ uint16_t i_extra_isize;
++ uint16_t i_pad1;
++};
++
++#define i_size_high i_dir_acl
++
++/*
++ * File system states
++ */
++#define EXT2_VALID_FS 0x0001 /* Unmounted cleanly */
++#define EXT2_ERROR_FS 0x0002 /* Errors detected */
++
++/*
++ * Mount flags
++ */
++#define EXT2_MOUNT_CHECK 0x0001 /* Do mount-time checks */
++#define EXT2_MOUNT_GRPID 0x0004 /* Create files with directory's group */
++#define EXT2_MOUNT_DEBUG 0x0008 /* Some debugging messages */
++#define EXT2_MOUNT_ERRORS_CONT 0x0010 /* Continue on errors */
++#define EXT2_MOUNT_ERRORS_RO 0x0020 /* Remount fs ro on errors */
++#define EXT2_MOUNT_ERRORS_PANIC 0x0040 /* Panic on errors */
++#define EXT2_MOUNT_MINIX_DF 0x0080 /* Mimics the Minix statfs */
++#define EXT2_MOUNT_NO_UID32 0x0200 /* Disable 32-bit UIDs */
++
++#define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
++#define set_opt(o, opt) o |= EXT2_MOUNT_##opt
++#define test_opt(sb, opt) (EXT2_SB(sb)->s_mount_opt & \
++ EXT2_MOUNT_##opt)
++/*
++ * Maximal mount counts between two filesystem checks
++ */
++#define EXT2_DFL_MAX_MNT_COUNT 20 /* Allow 20 mounts */
++#define EXT2_DFL_CHECKINTERVAL 0 /* Don't use interval check */
++
++/*
++ * Behaviour when detecting errors
++ */
++#define EXT2_ERRORS_CONTINUE 1 /* Continue execution */
++#define EXT2_ERRORS_RO 2 /* Remount fs read-only */
++#define EXT2_ERRORS_PANIC 3 /* Panic */
++#define EXT2_ERRORS_DEFAULT EXT2_ERRORS_CONTINUE
++
++/*
++ * Structure of the super block
++ */
++struct ext2_super_block {
++ uint32_t s_inodes_count; /* Inodes count */
++ uint32_t s_blocks_count; /* Blocks count */
++ uint32_t s_r_blocks_count; /* Reserved blocks count */
++ uint32_t s_free_blocks_count; /* Free blocks count */
++ uint32_t s_free_inodes_count; /* Free inodes count */
++ uint32_t s_first_data_block; /* First Data Block */
++ uint32_t s_log_block_size; /* Block size */
++ int32_t s_log_frag_size; /* Fragment size */
++ uint32_t s_blocks_per_group; /* # Blocks per group */
++ uint32_t s_frags_per_group; /* # Fragments per group */
++ uint32_t s_inodes_per_group; /* # Inodes per group */
++ uint32_t s_mtime; /* Mount time */
++ uint32_t s_wtime; /* Write time */
++ uint16_t s_mnt_count; /* Mount count */
++ int16_t s_max_mnt_count; /* Maximal mount count */
++ uint16_t s_magic; /* Magic signature */
++ uint16_t s_state; /* File system state */
++ uint16_t s_errors; /* Behaviour when detecting errors */
++ uint16_t s_minor_rev_level; /* minor revision level */
++ uint32_t s_lastcheck; /* time of last check */
++ uint32_t s_checkinterval; /* max. time between checks */
++ uint32_t s_creator_os; /* OS */
++ uint32_t s_rev_level; /* Revision level */
++ uint16_t s_def_resuid; /* Default uid for reserved blocks */
++ uint16_t s_def_resgid; /* Default gid for reserved blocks */
++ /*
++ * These fields are for EXT2_DYNAMIC_REV superblocks only.
++ *
++ * Note: the difference between the compatible feature set and
++ * the incompatible feature set is that if there is a bit set
++ * in the incompatible feature set that the kernel doesn't
++ * know about, it should refuse to mount the filesystem.
++ *
++ * e2fsck's requirements are more strict; if it doesn't know
++ * about a feature in either the compatible or incompatible
++ * feature set, it must abort and not try to meddle with
++ * things it doesn't understand...
++ */
++ uint32_t s_first_ino; /* First non-reserved inode */
++ uint16_t s_inode_size; /* size of inode structure */
++ uint16_t s_block_group_nr; /* block group # of this superblock */
++ uint32_t s_feature_compat; /* compatible feature set */
++ uint32_t s_feature_incompat; /* incompatible feature set */
++ uint32_t s_feature_ro_compat; /* readonly-compatible feature set */
++ uint8_t s_uuid[16]; /* 128-bit uuid for volume */
++ char s_volume_name[16]; /* volume name */
++ char s_last_mounted[64]; /* directory where last mounted */
++ uint32_t s_algorithm_usage_bitmap; /* For compression */
++ /*
++ * Performance hints. Directory preallocation should only
++ * happen if the EXT2_FEATURE_COMPAT_DIR_PREALLOC flag is on.
++ */
++ uint8_t s_prealloc_blocks; /* Nr of blocks to try to preallocate*/
++ uint8_t s_prealloc_dir_blocks; /* Nr to preallocate for dirs */
++ uint16_t s_reserved_gdt_blocks; /* Per group table for online growth */
++ /*
++ * Journaling support valid if EXT2_FEATURE_COMPAT_HAS_JOURNAL set.
++ */
++/*D0*/ uint8_t s_journal_uuid[16]; /* uuid of journal superblock */
++/*E0*/ uint32_t s_journal_inum; /* inode number of journal file */
++ uint32_t s_journal_dev; /* device number of journal file */
++ uint32_t s_last_orphan; /* start of list of inodes to delete */
++ uint32_t s_hash_seed[4]; /* HTREE hash seed */
++ uint8_t s_def_hash_version; /* Default hash version to use */
++ uint8_t s_jnl_backup_type; /* Default type of journal backup */
++ uint16_t s_reserved_word_pad;
++/*100*/ uint32_t s_default_mount_opts;
++ uint32_t s_first_meta_bg; /* First metablock group */
++ /* ext3 additions */
++ uint32_t s_mkfs_time; /* When the filesystem was created */
++ uint32_t s_jnl_blocks[17]; /* Backup of the journal inode */
++ /* 64bit support valid if EXT4_FEATURE_COMPAT_64BIT */
++/*150*/ uint32_t s_blocks_count_hi; /* Blocks count */
++ uint32_t s_r_blocks_count_hi; /* Reserved blocks count */
++ uint32_t s_free_blocks_count_hi; /* Free blocks count */
++ uint16_t s_min_extra_isize; /* All inodes have at least # bytes */
++ uint16_t s_want_extra_isize; /* New inodes should reserve # bytes */
++ uint32_t s_flags; /* Miscellaneous flags */
++ uint16_t s_raid_stride; /* RAID stride */
++ uint16_t s_mmp_interval; /* # seconds to wait in MMP checking */
++ uint64_t s_mmp_block; /* Block for multi-mount protection */
++ uint32_t s_raid_stripe_width; /* blocks on all data disks (N*stride)*/
++ uint8_t s_log_groups_per_flex; /* FLEX_BG group size */
++ uint8_t s_reserved_char_pad2;
++ uint16_t s_reserved_pad;
++ uint32_t s_reserved[162]; /* Padding to the end of the block */
++};
++struct BUG_ext2_super_block {
++ char bug[sizeof(struct ext2_super_block) == 1024 ? 1 : -1];
++};
++
++/*
++ * Codes for operating systems
++ */
++#define EXT2_OS_LINUX 0
++#define EXT2_OS_HURD 1
++#define EXT2_OS_MASIX 2
++#define EXT2_OS_FREEBSD 3
++#define EXT2_OS_LITES 4
++
++/*
++ * Revision levels
++ */
++#define EXT2_GOOD_OLD_REV 0 /* The good old (original) format */
++#define EXT2_DYNAMIC_REV 1 /* V2 format w/ dynamic inode sizes */
++
++#define EXT2_CURRENT_REV EXT2_GOOD_OLD_REV
++#define EXT2_MAX_SUPP_REV EXT2_DYNAMIC_REV
++
++#define EXT2_GOOD_OLD_INODE_SIZE 128
++
++/*
++ * Journal inode backup types
++ */
++#define EXT3_JNL_BACKUP_BLOCKS 1
++
++/*
++ * Feature set definitions
++ */
++
++#define EXT2_HAS_COMPAT_FEATURE(sb,mask) \
++ ( EXT2_SB(sb)->s_feature_compat & (mask) )
++#define EXT2_HAS_RO_COMPAT_FEATURE(sb,mask) \
++ ( EXT2_SB(sb)->s_feature_ro_compat & (mask) )
++#define EXT2_HAS_INCOMPAT_FEATURE(sb,mask) \
++ ( EXT2_SB(sb)->s_feature_incompat & (mask) )
++
++/* for s_feature_compat */
++#define EXT2_FEATURE_COMPAT_DIR_PREALLOC 0x0001
++#define EXT2_FEATURE_COMPAT_IMAGIC_INODES 0x0002
++#define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x0004
++#define EXT2_FEATURE_COMPAT_EXT_ATTR 0x0008
++#define EXT2_FEATURE_COMPAT_RESIZE_INO 0x0010
++#define EXT2_FEATURE_COMPAT_DIR_INDEX 0x0020
++
++/* for s_feature_ro_compat */
++#define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001
++#define EXT2_FEATURE_RO_COMPAT_LARGE_FILE 0x0002
++#define EXT2_FEATURE_RO_COMPAT_BTREE_DIR 0x0004 /* not used */
++#define EXT4_FEATURE_RO_COMPAT_HUGE_FILE 0x0008
++#define EXT4_FEATURE_RO_COMPAT_GDT_CSUM 0x0010
++#define EXT4_FEATURE_RO_COMPAT_DIR_NLINK 0x0020
++#define EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE 0x0040
++
++/* for s_feature_incompat */
++#define EXT2_FEATURE_INCOMPAT_COMPRESSION 0x0001
++#define EXT2_FEATURE_INCOMPAT_FILETYPE 0x0002
++#define EXT3_FEATURE_INCOMPAT_RECOVER 0x0004
++#define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008
++#define EXT2_FEATURE_INCOMPAT_META_BG 0x0010
++#define EXT4_FEATURE_INCOMPAT_EXTENTS 0x0040
++#define EXT4_FEATURE_INCOMPAT_64BIT 0x0080
++#define EXT4_FEATURE_INCOMPAT_MMP 0x0100
++#define EXT4_FEATURE_INCOMPAT_FLEX_BG 0x0200
++
++
++#define EXT2_FEATURE_COMPAT_SUPP 0
++#define EXT2_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \
++ EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \
++ EXT2_FEATURE_RO_COMPAT_BTREE_DIR)
++#define EXT2_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE| \
++ EXT2_FEATURE_INCOMPAT_META_BG)
++#define EXT2_FEATURE_INCOMPAT_UNSUPPORTED (~EXT2_FEATURE_INCOMPAT_SUPP)
++#define EXT2_FEATURE_RO_COMPAT_UNSUPPORTED (~EXT2_FEATURE_RO_COMPAT_SUPP)
++
++#define EXT3_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \
++ EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \
++ EXT2_FEATURE_RO_COMPAT_BTREE_DIR)
++#define EXT3_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE| \
++ EXT3_FEATURE_INCOMPAT_RECOVER| \
++ EXT2_FEATURE_INCOMPAT_META_BG)
++#define EXT3_FEATURE_INCOMPAT_UNSUPPORTED (~EXT3_FEATURE_INCOMPAT_SUPP)
++#define EXT3_FEATURE_RO_COMPAT_UNSUPPORTED (~EXT3_FEATURE_RO_COMPAT_SUPP)
++
++
++/*
++ * Default values for user and/or group using reserved blocks
++ */
++#define EXT2_DEF_RESUID 0
++#define EXT2_DEF_RESGID 0
++
++/*
++ * Default mount options
++ */
++#define EXT2_DEFM_DEBUG 0x0001
++#define EXT2_DEFM_BSDGROUPS 0x0002
++#define EXT2_DEFM_XATTR_USER 0x0004
++#define EXT2_DEFM_ACL 0x0008
++#define EXT2_DEFM_UID16 0x0010
++#define EXT3_DEFM_JMODE 0x0060
++#define EXT3_DEFM_JMODE_DATA 0x0020
++#define EXT3_DEFM_JMODE_ORDERED 0x0040
++#define EXT3_DEFM_JMODE_WBACK 0x0060
++
++/*
++ * Structure of a directory entry
++ */
++#define EXT2_NAME_LEN 255
++
++struct ext2_dir_entry {
++ uint32_t inode; /* Inode number */
++ uint16_t rec_len; /* Directory entry length */
++ uint16_t name_len; /* Name length */
++ char name[EXT2_NAME_LEN]; /* File name */
++};
++
++/*
++ * The new version of the directory entry. Since EXT2 structures are
++ * stored in intel byte order, and the name_len field could never be
++ * bigger than 255 chars, it's safe to reclaim the extra byte for the
++ * file_type field.
++ */
++struct ext2_dir_entry_2 {
++ uint32_t inode; /* Inode number */
++ uint16_t rec_len; /* Directory entry length */
++ uint8_t name_len; /* Name length */
++ uint8_t file_type;
++ char name[EXT2_NAME_LEN]; /* File name */
++};
++
++/*
++ * Ext2 directory file types. Only the low 3 bits are used. The
++ * other bits are reserved for now.
++ */
++#define EXT2_FT_UNKNOWN 0
++#define EXT2_FT_REG_FILE 1
++#define EXT2_FT_DIR 2
++#define EXT2_FT_CHRDEV 3
++#define EXT2_FT_BLKDEV 4
++#define EXT2_FT_FIFO 5
++#define EXT2_FT_SOCK 6
++#define EXT2_FT_SYMLINK 7
++
++#define EXT2_FT_MAX 8
++
++/*
++ * EXT2_DIR_PAD defines the directory entries boundaries
++ *
++ * NOTE: It must be a multiple of 4
++ */
++#define EXT2_DIR_PAD 4
++#define EXT2_DIR_ROUND (EXT2_DIR_PAD - 1)
++#define EXT2_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT2_DIR_ROUND) & \
++ ~EXT2_DIR_ROUND)
++
++#endif
+--- a/testsuite/mount.tests
++++ b/testsuite/mount.tests
+@@ -36,7 +36,8 @@ testing "mount -o remount,mand" \
+ "mount -o loop mount.image1m $testdir "\
+ "&& grep -Fc $testdir </proc/mounts "\
+ "&& mount -o remount,mand $testdir "\
+-"&& grep -F $testdir </proc/mounts | grep -c '[, ]mand[, ]'" \
++"&& grep -F $testdir </proc/mounts | grep -c '[, ]mand[, ]'"\
++"|| grep -F $testdir </proc/mounts" \
+ "1\n""1\n" \
+ "" ""
+
+@@ -83,4 +84,28 @@ b
+ "" ""
+ SKIP=
+
++
++testing "mount RO loop" "\
++exec 2>&1
++umount -d mount.dir 2>/dev/null
++rmdir mount.dir 2>/dev/null
++mkdir -p mount.dir
++(
++cd mount.dir || { echo 'cd error'; exit 1; }
++mkdir z1 z2 || { echo 'mkdir error'; exit 1; }
++mount -t tmpfs tmpfs z1 || { echo 'mount tmpfs error'; exit 1; }
++dd if=/dev/zero of=z1/e2img count=10 bs=1M 2>/dev/null || { echo 'dd error'; exit 1; }
++mke2fs -F z1/e2img 2>/dev/null >&2 || { echo 'mke2fs error'; exit 1; }
++mount -r -o loop -t ext2 z1/e2img z2 || { echo 'mount -r -o loop error'; exit 1; }
++mount -o remount,ro z1 || { echo 'mount -o remount,ro error'; exit 1; }
++)
++umount -d mount.dir/z2
++##losetup -d /dev/loop*
++umount -d mount.dir/z1
++rm -rf mount.dir
++echo DONE
++" \
++"DONE\n" "" ""
++
++
+ exit $FAILCOUNT
+--- a/util-linux/mkfs_ext2.c
++++ b/util-linux/mkfs_ext2.c
+@@ -48,16 +48,11 @@
+
+ #include "libbb.h"
+ #include <linux/fs.h>
+-#include <linux/ext2_fs.h>
++#include "bb_e2fs_defs.h"
+
+ #define ENABLE_FEATURE_MKFS_EXT2_RESERVED_GDT 0
+ #define ENABLE_FEATURE_MKFS_EXT2_DIR_INDEX 1
+
+-// from e2fsprogs
+-#define s_reserved_gdt_blocks s_padding1
+-#define s_mkfs_time s_reserved[0]
+-#define s_flags s_reserved[22]
+-
+ #define EXT2_HASH_HALF_MD4 1
+ #define EXT2_FLAGS_SIGNED_HASH 0x0001
+ #define EXT2_FLAGS_UNSIGNED_HASH 0x0002
+@@ -482,8 +477,10 @@ int mkfs_ext2_main(int argc UNUSED_PARAM
+ STORE_LE(sb->s_magic, EXT2_SUPER_MAGIC);
+ STORE_LE(sb->s_inode_size, inodesize);
+ // set "Required extra isize" and "Desired extra isize" fields to 28
+- if (inodesize != sizeof(*inode))
+- STORE_LE(sb->s_reserved[21], 0x001C001C);
++ if (inodesize != sizeof(*inode)) {
++ STORE_LE(sb->s_min_extra_isize, 0x001c);
++ STORE_LE(sb->s_want_extra_isize, 0x001c);
++ }
+ STORE_LE(sb->s_first_ino, EXT2_GOOD_OLD_FIRST_INO);
+ STORE_LE(sb->s_log_block_size, blocksize_log2 - EXT2_MIN_BLOCK_LOG_SIZE);
+ STORE_LE(sb->s_log_frag_size, blocksize_log2 - EXT2_MIN_BLOCK_LOG_SIZE);
+--- a/util-linux/volume_id/ext.c
++++ b/util-linux/volume_id/ext.c
+@@ -19,28 +19,8 @@
+ */
+
+ #include "volume_id_internal.h"
++#include "bb_e2fs_defs.h"
+
+-struct ext2_super_block {
+- uint32_t inodes_count;
+- uint32_t blocks_count;
+- uint32_t r_blocks_count;
+- uint32_t free_blocks_count;
+- uint32_t free_inodes_count;
+- uint32_t first_data_block;
+- uint32_t log_block_size;
+- uint32_t dummy3[7];
+- uint8_t magic[2];
+- uint16_t state;
+- uint32_t dummy5[8];
+- uint32_t feature_compat;
+- uint32_t feature_incompat;
+- uint32_t feature_ro_compat;
+- uint8_t uuid[16];
+- uint8_t volume_name[16];
+-} PACKED;
+-
+-#define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x00000004
+-#define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x00000008
+ #define EXT_SUPERBLOCK_OFFSET 0x400
+
+ int FAST_FUNC volume_id_probe_ext(struct volume_id *id /*,uint64_t off*/)
+@@ -54,23 +34,27 @@ int FAST_FUNC volume_id_probe_ext(struct
+ if (es == NULL)
+ return -1;
+
+- if (es->magic[0] != 0123 || es->magic[1] != 0357) {
++ if (es->s_magic != cpu_to_le16(EXT2_SUPER_MAGIC)) {
+ dbg("ext: no magic found");
+ return -1;
+ }
+
+ // volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
+ // volume_id_set_label_raw(id, es->volume_name, 16);
+- volume_id_set_label_string(id, es->volume_name, 16);
+- volume_id_set_uuid(id, es->uuid, UUID_DCE);
++ volume_id_set_label_string(id, (void*)es->s_volume_name, 16);
++ volume_id_set_uuid(id, es->s_uuid, UUID_DCE);
+ dbg("ext: label '%s' uuid '%s'", id->label, id->uuid);
+
+ #if ENABLE_FEATURE_BLKID_TYPE
+- if ((le32_to_cpu(es->feature_compat) & EXT3_FEATURE_COMPAT_HAS_JOURNAL) != 0)
++ if ((es->s_feature_ro_compat & cpu_to_le32(EXT4_FEATURE_RO_COMPAT_HUGE_FILE | EXT4_FEATURE_RO_COMPAT_DIR_NLINK))
++ || (es->s_feature_incompat & cpu_to_le32(EXT4_FEATURE_INCOMPAT_EXTENTS | EXT4_FEATURE_INCOMPAT_64BIT))
++ ) {
++ id->type = "ext4";
++ }
++ else if (es->s_feature_compat & cpu_to_le32(EXT3_FEATURE_COMPAT_HAS_JOURNAL))
+ id->type = "ext3";
+ else
+ id->type = "ext2";
+ #endif
+-
+ return 0;
+ }
diff --git a/package/busybox/patches/.svn/text-base/110-wget_getopt_fix.patch.svn-base b/package/busybox/patches/.svn/text-base/110-wget_getopt_fix.patch.svn-base
new file mode 100644
index 0000000..1003231
--- /dev/null
+++ b/package/busybox/patches/.svn/text-base/110-wget_getopt_fix.patch.svn-base
@@ -0,0 +1,11 @@
+--- a/networking/wget.c
++++ b/networking/wget.c
+@@ -873,7 +873,7 @@ int wget_main(int argc UNUSED_PARAM, cha
+ /* Ignored: */
+ // "tries\0" Required_argument "t"
+ /* Ignored (we always use PASV): */
+- "passive-ftp\0" No_argument "\xff"
++ "passive-ftp\0" No_argument "\xfd"
+ "header\0" Required_argument "\xfe"
+ "post-data\0" Required_argument "\xfd"
+ /* Ignored (we don't do ssl) */
diff --git a/package/busybox/patches/.svn/text-base/140-trylink_bash.patch.svn-base b/package/busybox/patches/.svn/text-base/140-trylink_bash.patch.svn-base
new file mode 100644
index 0000000..f9571fc
--- /dev/null
+++ b/package/busybox/patches/.svn/text-base/140-trylink_bash.patch.svn-base
@@ -0,0 +1,8 @@
+--- a/scripts/trylink
++++ b/scripts/trylink
+@@ -1,4 +1,4 @@
+-#!/bin/sh
++#!/usr/bin/env bash
+
+ debug=false
+
diff --git a/package/busybox/patches/.svn/text-base/141-gen_build_files_bash.patch.svn-base b/package/busybox/patches/.svn/text-base/141-gen_build_files_bash.patch.svn-base
new file mode 100644
index 0000000..d258fb8
--- /dev/null
+++ b/package/busybox/patches/.svn/text-base/141-gen_build_files_bash.patch.svn-base
@@ -0,0 +1,8 @@
+--- a/scripts/gen_build_files.sh
++++ b/scripts/gen_build_files.sh
+@@ -1,4 +1,4 @@
+-#!/bin/sh
++#!/usr/bin/env bash
+
+ # Note: was using sed OPTS CMD -- FILES
+ # but users complain that many sed implementations
diff --git a/package/busybox/patches/.svn/text-base/150-no_static_libgcc.patch.svn-base b/package/busybox/patches/.svn/text-base/150-no_static_libgcc.patch.svn-base
new file mode 100644
index 0000000..fde6fbb
--- /dev/null
+++ b/package/busybox/patches/.svn/text-base/150-no_static_libgcc.patch.svn-base
@@ -0,0 +1,11 @@
+--- a/Makefile.flags
++++ b/Makefile.flags
+@@ -50,7 +50,7 @@ CFLAGS += $(call cc-option,-fno-builtin-
+ # -fno-guess-branch-probability: prohibit pseudo-random guessing
+ # of branch probabilities (hopefully makes bloatcheck more stable):
+ CFLAGS += $(call cc-option,-fno-guess-branch-probability,)
+-CFLAGS += $(call cc-option,-funsigned-char -static-libgcc,)
++CFLAGS += $(call cc-option,-funsigned-char,)
+ CFLAGS += $(call cc-option,-falign-functions=1 -falign-jumps=1 -falign-labels=1 -falign-loops=1,)
+
+ # FIXME: These warnings are at least partially to be concerned about and should
diff --git a/package/busybox/patches/.svn/text-base/200-etc_crontabs.patch.svn-base b/package/busybox/patches/.svn/text-base/200-etc_crontabs.patch.svn-base
new file mode 100644
index 0000000..ebf2990
--- /dev/null
+++ b/package/busybox/patches/.svn/text-base/200-etc_crontabs.patch.svn-base
@@ -0,0 +1,22 @@
+--- a/miscutils/crond.c
++++ b/miscutils/crond.c
+@@ -37,7 +37,7 @@
+
+
+ #define TMPDIR CONFIG_FEATURE_CROND_DIR
+-#define CRONTABS CONFIG_FEATURE_CROND_DIR "/crontabs"
++#define CRONTABS "/etc/crontabs"
+ #ifndef SENDMAIL
+ # define SENDMAIL "sendmail"
+ #endif
+--- a/miscutils/crontab.c
++++ b/miscutils/crontab.c
+@@ -22,7 +22,7 @@
+
+ #include "libbb.h"
+
+-#define CRONTABS CONFIG_FEATURE_CROND_DIR "/crontabs"
++#define CRONTABS "/etc/crontabs"
+ #ifndef CRONUPDATE
+ #define CRONUPDATE "cron.update"
+ #endif
diff --git a/package/busybox/patches/.svn/text-base/240-udhcpc_retries.patch.svn-base b/package/busybox/patches/.svn/text-base/240-udhcpc_retries.patch.svn-base
new file mode 100644
index 0000000..0e26864
--- /dev/null
+++ b/package/busybox/patches/.svn/text-base/240-udhcpc_retries.patch.svn-base
@@ -0,0 +1,20 @@
+--- a/networking/udhcp/dhcpc.c
++++ b/networking/udhcp/dhcpc.c
+@@ -1319,7 +1319,7 @@ int udhcpc_main(int argc UNUSED_PARAM, c
+
+ switch (state) {
+ case INIT_SELECTING:
+- if (packet_num < discover_retries) {
++ if (!discover_retries || packet_num < discover_retries) {
+ if (packet_num == 0)
+ xid = random_xid();
+ /* broadcast */
+@@ -1348,7 +1348,7 @@ int udhcpc_main(int argc UNUSED_PARAM, c
+ packet_num = 0;
+ continue;
+ case REQUESTING:
+- if (packet_num < discover_retries) {
++ if (!discover_retries || packet_num < discover_retries) {
+ /* send broadcast select packet */
+ send_select(xid, server_addr, requested_ip);
+ timeout = discover_timeout;
diff --git a/package/busybox/patches/.svn/text-base/241-udhcpc-oversized_packets.patch.svn-base b/package/busybox/patches/.svn/text-base/241-udhcpc-oversized_packets.patch.svn-base
new file mode 100644
index 0000000..471d704
--- /dev/null
+++ b/package/busybox/patches/.svn/text-base/241-udhcpc-oversized_packets.patch.svn-base
@@ -0,0 +1,99 @@
+--- a/networking/udhcp/packet.c
++++ b/networking/udhcp/packet.c
+@@ -158,6 +158,11 @@ uint16_t FAST_FUNC udhcp_checksum(void *
+ return ~sum;
+ }
+
++int udhcp_get_payload_len(struct dhcp_packet *dhcp_pkt)
++{
++ return sizeof(struct dhcp_packet) - DHCP_OPTIONS_BUFSIZE + udhcp_end_option(dhcp_pkt->options) + sizeof(dhcp_pkt->options[0]);
++}
++
+ /* Construct a ip/udp header for a packet, send packet */
+ int FAST_FUNC udhcp_send_raw_packet(struct dhcp_packet *dhcp_pkt,
+ uint32_t source_nip, int source_port,
+@@ -166,10 +171,10 @@ int FAST_FUNC udhcp_send_raw_packet(stru
+ {
+ struct sockaddr_ll dest_sll;
+ struct ip_udp_dhcp_packet packet;
+- unsigned padding;
+ int fd;
+ int result = -1;
+ const char *msg;
++ int p_len = udhcp_get_payload_len(dhcp_pkt);
+
+ fd = socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IP));
+ if (fd < 0) {
+@@ -178,8 +183,8 @@ int FAST_FUNC udhcp_send_raw_packet(stru
+ }
+
+ memset(&dest_sll, 0, sizeof(dest_sll));
+- memset(&packet, 0, offsetof(struct ip_udp_dhcp_packet, data));
+- packet.data = *dhcp_pkt; /* struct copy */
++ memset(&packet, 0, sizeof(packet));
++ memcpy(&(packet.data), dhcp_pkt, p_len);
+
+ dest_sll.sll_family = AF_PACKET;
+ dest_sll.sll_protocol = htons(ETH_P_IP);
+@@ -192,36 +197,24 @@ int FAST_FUNC udhcp_send_raw_packet(stru
+ goto ret_close;
+ }
+
+- /* We were sending full-sized DHCP packets (zero padded),
+- * but some badly configured servers were seen dropping them.
+- * Apparently they drop all DHCP packets >576 *ethernet* octets big,
+- * whereas they may only drop packets >576 *IP* octets big
+- * (which for typical Ethernet II means 590 octets: 6+6+2 + 576).
+- *
+- * In order to work with those buggy servers,
+- * we truncate packets after end option byte.
+- */
+- padding = DHCP_OPTIONS_BUFSIZE - 1 - udhcp_end_option(packet.data.options);
+-
+ packet.ip.protocol = IPPROTO_UDP;
+ packet.ip.saddr = source_nip;
+ packet.ip.daddr = dest_nip;
+ packet.udp.source = htons(source_port);
+ packet.udp.dest = htons(dest_port);
+- /* size, excluding IP header: */
+- packet.udp.len = htons(UDP_DHCP_SIZE - padding);
+- /* for UDP checksumming, ip.len is set to UDP packet len */
++ p_len += sizeof(packet.udp);
++ packet.udp.len = htons(p_len);
+ packet.ip.tot_len = packet.udp.len;
+- packet.udp.check = udhcp_checksum(&packet, IP_UDP_DHCP_SIZE - padding);
+- /* but for sending, it is set to IP packet len */
+- packet.ip.tot_len = htons(IP_UDP_DHCP_SIZE - padding);
++ p_len += sizeof(packet.ip);
++ packet.udp.check = udhcp_checksum(&packet, p_len);
++ packet.ip.tot_len = htons(p_len);
+ packet.ip.ihl = sizeof(packet.ip) >> 2;
+ packet.ip.version = IPVERSION;
+ packet.ip.ttl = IPDEFTTL;
+ packet.ip.check = udhcp_checksum(&packet.ip, sizeof(packet.ip));
+
+ udhcp_dump_packet(dhcp_pkt);
+- result = sendto(fd, &packet, IP_UDP_DHCP_SIZE - padding, /*flags:*/ 0,
++ result = sendto(fd, &packet, p_len, /*flags:*/ 0,
+ (struct sockaddr *) &dest_sll, sizeof(dest_sll));
+ msg = "sendto";
+ ret_close:
+@@ -239,7 +232,6 @@ int FAST_FUNC udhcp_send_kernel_packet(s
+ uint32_t dest_nip, int dest_port)
+ {
+ struct sockaddr_in client;
+- unsigned padding;
+ int fd;
+ int result = -1;
+ const char *msg;
+@@ -270,9 +262,7 @@ int FAST_FUNC udhcp_send_kernel_packet(s
+ }
+
+ udhcp_dump_packet(dhcp_pkt);
+-
+- padding = DHCP_OPTIONS_BUFSIZE - 1 - udhcp_end_option(dhcp_pkt->options);
+- result = safe_write(fd, dhcp_pkt, DHCP_SIZE - padding);
++ result = safe_write(fd, dhcp_pkt, udhcp_get_payload_len(dhcp_pkt));
+ msg = "write";
+ ret_close:
+ close(fd);
diff --git a/package/busybox/patches/.svn/text-base/242-udhcpc_msgs.patch.svn-base b/package/busybox/patches/.svn/text-base/242-udhcpc_msgs.patch.svn-base
new file mode 100644
index 0000000..c1c6096
--- /dev/null
+++ b/package/busybox/patches/.svn/text-base/242-udhcpc_msgs.patch.svn-base
@@ -0,0 +1,18 @@
+--- a/networking/udhcp/dhcpc.c
++++ b/networking/udhcp/dhcpc.c
+@@ -602,6 +602,7 @@ static int raw_bcast_from_client_config_
+ static NOINLINE int send_discover(uint32_t xid, uint32_t requested)
+ {
+ struct dhcp_packet packet;
++ static int msgs = 0;
+
+ /* Fill in: op, htype, hlen, cookie, chaddr fields,
+ * random xid field (we override it below),
+@@ -619,6 +620,7 @@ static NOINLINE int send_discover(uint32
+ */
+ add_client_options(&packet);
+
++ if (msgs++ < 3)
+ bb_info_msg("Sending discover...");
+ return raw_bcast_from_client_config_ifindex(&packet);
+ }
diff --git a/package/busybox/patches/.svn/text-base/243-udhcpc_changed_ifindex.patch.svn-base b/package/busybox/patches/.svn/text-base/243-udhcpc_changed_ifindex.patch.svn-base
new file mode 100644
index 0000000..cb0df22
--- /dev/null
+++ b/package/busybox/patches/.svn/text-base/243-udhcpc_changed_ifindex.patch.svn-base
@@ -0,0 +1,15 @@
+--- a/networking/udhcp/dhcpc.c
++++ b/networking/udhcp/dhcpc.c
+@@ -1267,6 +1267,12 @@ int udhcpc_main(int argc UNUSED_PARAM, c
+ /* silence "uninitialized!" warning */
+ unsigned timestamp_before_wait = timestamp_before_wait;
+
++ /* When running on a bridge, the ifindex may have changed (e.g. if
++ * member interfaces were added/removed or if the status of the
++ * bridge changed).
++ * Workaround: refresh it here before processing the next packet */
++ udhcp_read_interface(client_config.interface, &client_config.ifindex, NULL, client_config.client_mac);
++
+ //bb_error_msg("sockfd:%d, listen_mode:%d", sockfd, listen_mode);
+
+ /* Was opening raw or udp socket here
diff --git a/package/busybox/patches/.svn/text-base/244-udhcpc_add_6rd_option.patch.svn-base b/package/busybox/patches/.svn/text-base/244-udhcpc_add_6rd_option.patch.svn-base
new file mode 100644
index 0000000..2f0eadb
--- /dev/null
+++ b/package/busybox/patches/.svn/text-base/244-udhcpc_add_6rd_option.patch.svn-base
@@ -0,0 +1,143 @@
+--- a/networking/udhcp/common.c
++++ b/networking/udhcp/common.c
+@@ -60,6 +60,8 @@ const struct dhcp_optflag dhcp_optflags[
+ { OPTION_U8 , 0x85 }, /* DHCP_VLAN_PRIORITY */
+ #endif
+ { OPTION_STATIC_ROUTES , 0xf9 }, /* DHCP_MS_STATIC_ROUTES */
++ { OPTION_6RD , 0xd4 }, /* DHCP_6RD (RFC) */
++ { OPTION_6RD , 0x96 }, /* DHCP_6RD (Comcast) */
+ { OPTION_STRING , 0xfc }, /* DHCP_WPAD */
+
+ /* Options below have no match in dhcp_option_strings[],
+@@ -127,6 +129,8 @@ const char dhcp_option_strings[] ALIGN1
+ "vlanpriority" "\0"/* DHCP_VLAN_PRIORITY */
+ #endif
+ "msstaticroutes""\0"/* DHCP_MS_STATIC_ROUTES */
++ "ip6rd" "\0" /* DHCP_6RD (RFC) */
++ "ip6rd" "\0" /* DHCP_6RD (Comcast) */
+ "wpad" "\0" /* DHCP_WPAD */
+ ;
+
+@@ -155,6 +159,7 @@ const uint8_t dhcp_option_lengths[] ALIG
+ [OPTION_S32] = 4,
+ /* Just like OPTION_STRING, we use minimum length here */
+ [OPTION_STATIC_ROUTES] = 5,
++ [OPTION_6RD] = 22,
+ };
+
+
+--- a/networking/udhcp/common.h
++++ b/networking/udhcp/common.h
+@@ -91,6 +91,7 @@ enum {
+ OPTION_S32,
+ OPTION_BIN,
+ OPTION_STATIC_ROUTES,
++ OPTION_6RD,
+ #if ENABLE_FEATURE_UDHCP_RFC3397
+ OPTION_DNS_STRING, /* RFC1035 compressed domain name list */
+ OPTION_SIP_SERVERS,
+--- a/networking/udhcp/dhcpc.c
++++ b/networking/udhcp/dhcpc.c
+@@ -100,6 +100,7 @@ static const uint8_t len_of_option_as_st
+ [OPTION_IP ] = sizeof("255.255.255.255 "),
+ [OPTION_IP_PAIR ] = sizeof("255.255.255.255 ") * 2,
+ [OPTION_STATIC_ROUTES ] = sizeof("255.255.255.255/32 255.255.255.255 "),
++ [OPTION_6RD ] = sizeof("32 128 FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF 255.255.255.255 "),
+ [OPTION_STRING ] = 1,
+ [OPTION_STRING_HOST ] = 1,
+ #if ENABLE_FEATURE_UDHCP_RFC3397
+@@ -124,6 +125,23 @@ static int sprint_nip(char *dest, const
+ return sprintf(dest, "%s%u.%u.%u.%u", pre, ip[0], ip[1], ip[2], ip[3]);
+ }
+
++static int sprint_nip6(char *dest, const char *pre, const uint8_t *ip)
++{
++ int len = 0;
++ int off;
++ uint16_t word;
++
++ len += sprintf(dest, "%s", pre);
++
++ for (off = 0; off < 16; off += 2)
++ {
++ move_from_unaligned16(word, &ip[off]);
++ len += sprintf(dest+len, "%s%04X", off ? ":" : "", htons(word));
++ }
++
++ return len;
++}
++
+ /* really simple implementation, just count the bits */
+ static int mton(uint32_t mask)
+ {
+@@ -292,6 +310,70 @@ static NOINLINE char *xmalloc_optname_op
+ }
+
+ return ret;
++ }
++ case OPTION_6RD: {
++ /* Option binary format:
++ * 0 1 2 3
++ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
++ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
++ * | OPTION_6RD | option-length | IPv4MaskLen | 6rdPrefixLen |
++ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
++ * | |
++ * | 6rdPrefix |
++ * | (16 octets) |
++ * | |
++ * | |
++ * | |
++ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
++ * | 6rdBRIPv4Address(es) |
++ * . .
++ * . .
++ * . .
++ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
++ *
++ * We convert it to a string "IPv4MaskLen 6rdPrefixLen 6rdPrefix 6rdBRIPv4Address"
++ */
++
++ /* Sanity check: ensure that our length is at least 22 bytes, that
++ * IPv4MaskLen is <= 32, 6rdPrefixLen <= 128 and that the sum of
++ * (32 - IPv4MaskLen) + 6rdPrefixLen is less than or equal to 128.
++ * If any of these requirements is not fulfilled, return with empty
++ * value.
++ */
++ if ((len >= 22) && (*option <= 32) && (*(option+1) <= 128) &&
++ (((32 - *option) + *(option+1)) <= 128))
++ {
++ /* IPv4MaskLen */
++ dest += sprintf(dest, "%u ", *option++);
++ len--;
++
++ /* 6rdPrefixLen */
++ dest += sprintf(dest, "%u ", *option++);
++ len--;
++
++ /* 6rdPrefix */
++ dest += sprint_nip6(dest, "", option);
++ option += 16;
++ len -= 16;
++
++ /* 6rdBRIPv4Addresses */
++ while (len >= 4)
++ {
++ dest += sprint_nip(dest, " ", option);
++ option += 4;
++ len -= 4;
++
++ /* the code to determine the option size fails to work with
++ * lengths that are not a multiple of the minimum length,
++ * adding all advertised 6rdBRIPv4Addresses here would
++ * overflow the destination buffer, therefore skip the rest
++ * for now
++ */
++ break;
++ }
++ }
++
++ return ret;
+ }
+ #if ENABLE_FEATURE_UDHCP_RFC3397
+ case OPTION_DNS_STRING:
diff --git a/package/busybox/patches/.svn/text-base/250-ash_export-n.patch.svn-base b/package/busybox/patches/.svn/text-base/250-ash_export-n.patch.svn-base
new file mode 100644
index 0000000..048c236
--- /dev/null
+++ b/package/busybox/patches/.svn/text-base/250-ash_export-n.patch.svn-base
@@ -0,0 +1,34 @@
+--- a/shell/ash.c
++++ b/shell/ash.c
+@@ -12611,8 +12611,17 @@ exportcmd(int argc UNUSED_PARAM, char **
+ const char *p;
+ char **aptr;
+ int flag = argv[0][0] == 'r' ? VREADONLY : VEXPORT;
++ int mask = ~0;
++ int nopt;
++ while ((nopt = nextopt("np"))) {
++ if (nopt == 'n') {
++ mask = ~flag;
++ } else { /* p */
++ break;
++ }
++ }
+
+- if (nextopt("p") != 'p') {
++ if (nopt != 'p') {
+ aptr = argptr;
+ name = *aptr;
+ if (name) {
+@@ -12624,10 +12633,12 @@ exportcmd(int argc UNUSED_PARAM, char **
+ vp = *findvar(hashvar(name), name);
+ if (vp) {
+ vp->flags |= flag;
++ vp->flags &= mask;
+ continue;
+ }
+ }
+ setvar(name, p, flag);
++ setvar(name, p, flag & mask);
+ } while ((name = *++aptr) != NULL);
+ return 0;
+ }
diff --git a/package/busybox/patches/.svn/text-base/251-ash_fix-redir-substitution.patch.svn-base b/package/busybox/patches/.svn/text-base/251-ash_fix-redir-substitution.patch.svn-base
new file mode 100644
index 0000000..cb2ae94
--- /dev/null
+++ b/package/busybox/patches/.svn/text-base/251-ash_fix-redir-substitution.patch.svn-base
@@ -0,0 +1,12 @@
+--- a/shell/ash.c
++++ b/shell/ash.c
+@@ -6846,8 +6846,7 @@ evalvar(char *p, int flags, struct strli
+ patloc = expdest - (char *)stackblock();
+ if (NULL == subevalvar(p, /* varname: */ NULL, patloc, subtype,
+ startloc, varflags,
+-//TODO: | EXP_REDIR too? All other such places do it too
+- /* quotes: */ flags & (EXP_FULL | EXP_CASE),
++ /* quotes: */ flags & (EXP_FULL | EXP_CASE | EXP_REDIR),
+ var_str_list)
+ ) {
+ int amount = expdest - (
diff --git a/package/busybox/patches/.svn/text-base/260-vconfig_proc.patch.svn-base b/package/busybox/patches/.svn/text-base/260-vconfig_proc.patch.svn-base
new file mode 100644
index 0000000..7ac52ab
--- /dev/null
+++ b/package/busybox/patches/.svn/text-base/260-vconfig_proc.patch.svn-base
@@ -0,0 +1,22 @@
+--- a/networking/vconfig.c
++++ b/networking/vconfig.c
+@@ -116,8 +116,6 @@ static const char name_types[] ALIGN1 =
+ '_', 'N', 'O', '_', 'P', 'A', 'D', 0,
+ };
+
+-static const char conf_file_name[] ALIGN1 = "/proc/net/vlan/config";
+-
+ int vconfig_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
+ int vconfig_main(int argc, char **argv)
+ {
+@@ -129,10 +127,6 @@ int vconfig_main(int argc, char **argv)
+ bb_show_usage();
+ }
+
+- /* Don't bother closing the filedes. It will be closed on cleanup. */
+- /* Will die if 802.1q is not present */
+- xopen(conf_file_name, O_RDONLY);
+-
+ memset(&ifr, 0, sizeof(ifr));
+
+ ++argv;
diff --git a/package/busybox/patches/.svn/text-base/300-netmsg.patch.svn-base b/package/busybox/patches/.svn/text-base/300-netmsg.patch.svn-base
new file mode 100644
index 0000000..e8b2513
--- /dev/null
+++ b/package/busybox/patches/.svn/text-base/300-netmsg.patch.svn-base
@@ -0,0 +1,103 @@
+--- a/include/applets.src.h
++++ b/include/applets.src.h
+@@ -266,6 +266,7 @@ IF_MT(APPLET(mt, BB_DIR_BIN, BB_SUID_DRO
+ IF_MV(APPLET(mv, BB_DIR_BIN, BB_SUID_DROP))
+ IF_NAMEIF(APPLET(nameif, BB_DIR_SBIN, BB_SUID_DROP))
+ IF_NC(APPLET(nc, BB_DIR_USR_BIN, BB_SUID_DROP))
++IF_NETMSG(APPLET(netmsg, BB_DIR_BIN, BB_SUID_REQUIRE))
+ IF_NETSTAT(APPLET(netstat, BB_DIR_BIN, BB_SUID_DROP))
+ IF_NICE(APPLET(nice, BB_DIR_BIN, BB_SUID_DROP))
+ IF_NOHUP(APPLET(nohup, BB_DIR_USR_BIN, BB_SUID_DROP))
+--- a/networking/Config.src
++++ b/networking/Config.src
+@@ -612,6 +612,12 @@ config FEATURE_IPCALC_LONG_OPTIONS
+ help
+ Support long options for the ipcalc applet.
+
++config NETMSG
++ bool "netmsg"
++ default n
++ help
++ simple program for sending udp broadcast messages
++
+ config NETSTAT
+ bool "netstat"
+ default y
+--- a/networking/Kbuild.src
++++ b/networking/Kbuild.src
+@@ -27,6 +27,7 @@ lib-$(CONFIG_IP) += ip.o
+ lib-$(CONFIG_IPCALC) += ipcalc.o
+ lib-$(CONFIG_NAMEIF) += nameif.o
+ lib-$(CONFIG_NC) += nc.o
++lib-$(CONFIG_NETMSG) += netmsg.o
+ lib-$(CONFIG_NETSTAT) += netstat.o
+ lib-$(CONFIG_NSLOOKUP) += nslookup.o
+ lib-$(CONFIG_NTPD) += ntpd.o
+--- /dev/null
++++ b/networking/netmsg.c
+@@ -0,0 +1,65 @@
++/*
++ * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
++ *
++ * This is free software, licensed under the GNU General Public License v2.
++ */
++#include <sys/types.h>
++#include <sys/socket.h>
++#include <netinet/in.h>
++#include <netdb.h>
++#include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
++#include "busybox.h"
++
++//usage:#define netmsg_trivial_usage NOUSAGE_STR
++//usage:#define netmsg_full_usage ""
++
++#ifndef CONFIG_NETMSG
++int main(int argc, char **argv)
++#else
++int netmsg_main(int argc, char **argv)
++#endif
++{
++ int s;
++ struct sockaddr_in addr;
++ int optval = 1;
++ unsigned char buf[1001];
++
++ if (argc != 3) {
++ fprintf(stderr, "usage: %s <ip> \"<message>\"\n", argv[0]);
++ exit(1);
++ }
++
++ if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
++ perror("Opening socket");
++ exit(1);
++ }
++
++ memset(&addr, 0, sizeof(addr));
++ addr.sin_family = AF_INET;
++ addr.sin_addr.s_addr = inet_addr(argv[1]);
++ addr.sin_port = htons(0x1337);
++
++ memset(buf, 0, 1001);
++ buf[0] = 0xde;
++ buf[1] = 0xad;
++
++ strncpy(buf + 2, argv[2], 998);
++
++ if (setsockopt (s, SOL_SOCKET, SO_BROADCAST, (caddr_t) &optval, sizeof (optval)) < 0) {
++ perror("setsockopt()");
++ goto fail;
++ }
++
++ if (sendto(s, buf, 1001, 0, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
++ perror("sendto()");
++ goto fail;
++ }
++
++ return 0;
++
++fail:
++ close(s);
++ exit(1);
++}
diff --git a/package/busybox/patches/.svn/text-base/310-passwd_access.patch.svn-base b/package/busybox/patches/.svn/text-base/310-passwd_access.patch.svn-base
new file mode 100644
index 0000000..daa1b99
--- /dev/null
+++ b/package/busybox/patches/.svn/text-base/310-passwd_access.patch.svn-base
@@ -0,0 +1,41 @@
+
+ Copyright (C) 2006 OpenWrt.org
+
+--- a/networking/httpd.c
++++ b/networking/httpd.c
+@@ -1700,21 +1700,32 @@ static int check_user_passwd(const char
+
+ if (ENABLE_FEATURE_HTTPD_AUTH_MD5) {
+ char *md5_passwd;
++ int user_len_p1;
+
+ md5_passwd = strchr(cur->after_colon, ':');
+- if (md5_passwd && md5_passwd[1] == '$' && md5_passwd[2] == '1'
++ user_len_p1 = md5_passwd + 1 - cur->after_colon;
++ if (md5_passwd && !strncmp(md5_passwd + 1, "$p$", 3)) {
++ struct passwd *pwd = NULL;
++
++ pwd = getpwnam(&md5_passwd[4]);
++ if(!pwd->pw_passwd || !pwd->pw_passwd[0] || pwd->pw_passwd[0] == '!')
++ return 1;
++
++ md5_passwd = pwd->pw_passwd;
++ goto check_md5_pw;
++ } else if (md5_passwd && md5_passwd[1] == '$' && md5_passwd[2] == '1'
+ && md5_passwd[3] == '$' && md5_passwd[4]
+ ) {
+ char *encrypted;
+- int r, user_len_p1;
++ int r;
+
+ md5_passwd++;
+- user_len_p1 = md5_passwd - cur->after_colon;
+ /* comparing "user:" */
+ if (strncmp(cur->after_colon, user_and_passwd, user_len_p1) != 0) {
+ continue;
+ }
+
++check_md5_pw:
+ encrypted = pw_encrypt(
+ user_and_passwd + user_len_p1 /* cleartext pwd from user */,
+ md5_passwd /*salt */, 1 /* cleanup */);
diff --git a/package/busybox/patches/.svn/text-base/340-lock_util.patch.svn-base b/package/busybox/patches/.svn/text-base/340-lock_util.patch.svn-base
new file mode 100644
index 0000000..eb34642
--- /dev/null
+++ b/package/busybox/patches/.svn/text-base/340-lock_util.patch.svn-base
@@ -0,0 +1,172 @@
+--- a/include/applets.src.h
++++ b/include/applets.src.h
+@@ -218,6 +218,7 @@ IF_LN(APPLET_NOEXEC(ln, ln, BB_DIR_BIN,
+ IF_LOAD_POLICY(APPLET(load_policy, BB_DIR_USR_SBIN, BB_SUID_DROP))
+ IF_LOADFONT(APPLET(loadfont, BB_DIR_USR_SBIN, BB_SUID_DROP))
+ IF_LOADKMAP(APPLET(loadkmap, BB_DIR_SBIN, BB_SUID_DROP))
++IF_LOCK(APPLET(lock, BB_DIR_BIN, BB_SUID_DROP))
+ IF_LOGGER(APPLET(logger, BB_DIR_USR_BIN, BB_SUID_DROP))
+ /* Needs to be run by root or be suid root - needs to change uid and gid: */
+ IF_LOGIN(APPLET(login, BB_DIR_BIN, BB_SUID_REQUIRE))
+--- a/miscutils/Config.src
++++ b/miscutils/Config.src
+@@ -419,6 +419,11 @@ config FEATURE_HDPARM_HDIO_GETSET_DMA
+ help
+ Enables the 'hdparm -d' option to get/set using_dma flag.
+
++config LOCK
++ bool "lock"
++ help
++ Small utility for using locks in scripts
++
+ config MAKEDEVS
+ bool "makedevs"
+ default y
+--- a/miscutils/Kbuild.src
++++ b/miscutils/Kbuild.src
+@@ -29,6 +29,7 @@ lib-$(CONFIG_INOTIFYD) += inotifyd.o
+ lib-$(CONFIG_FEATURE_LAST_SMALL)+= last.o
+ lib-$(CONFIG_FEATURE_LAST_FANCY)+= last_fancy.o
+ lib-$(CONFIG_LESS) += less.o
++lib-$(CONFIG_LOCK) += lock.o
+ lib-$(CONFIG_MAKEDEVS) += makedevs.o
+ lib-$(CONFIG_MAN) += man.o
+ lib-$(CONFIG_MICROCOM) += microcom.o
+--- /dev/null
++++ b/miscutils/lock.c
+@@ -0,0 +1,135 @@
++/*
++ * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
++ *
++ * This is free software, licensed under the GNU General Public License v2.
++ */
++#include <sys/types.h>
++#include <sys/file.h>
++#include <sys/stat.h>
++#include <signal.h>
++#include <fcntl.h>
++#include <unistd.h>
++#include <stdio.h>
++#include "busybox.h"
++
++//usage:#define lock_trivial_usage NOUSAGE_STR
++//usage:#define lock_full_usage ""
++
++static int unlock = 0;
++static int shared = 0;
++static int waitonly = 0;
++static int fd;
++static char *file;
++
++static void usage(char *name)
++{
++ fprintf(stderr, "Usage: %s [-suw] <filename>\n"
++ " -s Use shared locking\n"
++ " -u Unlock\n"
++ " -w Wait for the lock to become free, don't acquire lock\n"
++ "\n", name);
++ exit(1);
++}
++
++static void exit_unlock(int sig)
++{
++ flock(fd, LOCK_UN);
++ exit(0);
++}
++
++static int do_unlock(void)
++{
++ FILE *f;
++ int i;
++
++ if ((f = fopen(file, "r")) == NULL)
++ return 0;
++
++ fscanf(f, "%d", &i);
++ if (i > 0)
++ kill(i, SIGTERM);
++
++ fclose(f);
++
++ return 0;
++}
++
++static int do_lock(void)
++{
++ int pid;
++ char pidstr[8];
++
++ if ((fd = open(file, O_RDWR | O_CREAT | O_EXCL, 0700)) < 0) {
++ if ((fd = open(file, O_RDWR)) < 0) {
++ fprintf(stderr, "Can't open %s\n", file);
++ return 1;
++ }
++ }
++
++ if (flock(fd, (shared ? LOCK_SH : LOCK_EX)) < 0) {
++ fprintf(stderr, "Can't lock %s\n", file);
++ return 1;
++ }
++
++ pid = fork();
++
++ if (pid < 0)
++ return -1;
++
++ if (pid == 0) {
++ signal(SIGKILL, exit_unlock);
++ signal(SIGTERM, exit_unlock);
++ signal(SIGINT, exit_unlock);
++ if (waitonly)
++ exit_unlock(0);
++ else
++ while (1)
++ sleep(1);
++ } else {
++ if (!waitonly) {
++ lseek(fd, 0, SEEK_SET);
++ ftruncate(fd, 0);
++ sprintf(pidstr, "%d\n", pid);
++ write(fd, pidstr, strlen(pidstr));
++ close(fd);
++ }
++
++ return 0;
++ }
++ return 0;
++}
++
++int lock_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
++int lock_main(int argc, char **argv)
++{
++ char **args = &argv[1];
++ int c = argc - 1;
++
++ while ((*args != NULL) && (*args)[0] == '-') {
++ char *ch = *args;
++ while (*(++ch) > 0) {
++ switch(*ch) {
++ case 'w':
++ waitonly = 1;
++ break;
++ case 's':
++ shared = 1;
++ break;
++ case 'u':
++ unlock = 1;
++ break;
++ }
++ }
++ c--;
++ args++;
++ }
++
++ if (c != 1)
++ usage(argv[0]);
++
++ file = *args;
++ if (unlock)
++ return do_unlock();
++ else
++ return do_lock();
++}
diff --git a/package/busybox/patches/.svn/text-base/350-httpd_redir.patch.svn-base b/package/busybox/patches/.svn/text-base/350-httpd_redir.patch.svn-base
new file mode 100644
index 0000000..11125e7
--- /dev/null
+++ b/package/busybox/patches/.svn/text-base/350-httpd_redir.patch.svn-base
@@ -0,0 +1,90 @@
+--- a/networking/httpd.c
++++ b/networking/httpd.c
+@@ -105,6 +105,7 @@
+ //usage: IF_FEATURE_HTTPD_BASIC_AUTH(" [-r REALM]")
+ //usage: " [-h HOME]\n"
+ //usage: "or httpd -d/-e" IF_FEATURE_HTTPD_AUTH_MD5("/-m") " STRING"
++//usage: " [-R <path> [-H <host>]]"
+ //usage:#define httpd_full_usage "\n\n"
+ //usage: "Listen for incoming HTTP requests\n"
+ //usage: "\n -i Inetd mode"
+@@ -121,6 +122,8 @@
+ //usage: "\n -m STRING MD5 crypt STRING")
+ //usage: "\n -e STRING HTML encode STRING"
+ //usage: "\n -d STRING URL decode STRING"
++//usage: "\n -R PATH Redirect target path"
++//usage: "\n -H HOST Redirect target host"
+
+ #include "libbb.h"
+ #if ENABLE_FEATURE_HTTPD_USE_SENDFILE
+@@ -272,6 +275,8 @@ struct globals {
+
+ const char *found_mime_type;
+ const char *found_moved_temporarily;
++ const char *redirect_path;
++ const char *redirect_host;
+ Htaccess_IP *ip_a_d; /* config allow/deny lines */
+
+ IF_FEATURE_HTTPD_BASIC_AUTH(const char *g_realm;)
+@@ -322,6 +327,8 @@ struct globals {
+ #define index_page (G.index_page )
+ #define found_mime_type (G.found_mime_type )
+ #define found_moved_temporarily (G.found_moved_temporarily)
++#define redirect_path (G.redirect_path )
++#define redirect_host (G.redirect_host )
+ #define last_mod (G.last_mod )
+ #define ip_a_d (G.ip_a_d )
+ #define g_realm (G.g_realm )
+@@ -956,8 +963,11 @@ static void send_headers(int responseNum
+ }
+ #endif
+ if (responseNum == HTTP_MOVED_TEMPORARILY) {
+- len += sprintf(iobuf + len, "Location: %s/%s%s\r\n",
++ len += sprintf(iobuf + len, "Location: %s%s%s%s%s%s\r\n",
++ (redirect_host ? "http://" : ""),
++ (redirect_host ? redirect_host : ""),
+ found_moved_temporarily,
++ (redirect_host ? "" : "/"),
+ (g_query ? "?" : ""),
+ (g_query ? g_query : ""));
+ }
+@@ -1925,8 +1935,12 @@ static void handle_incoming_and_exit(con
+ } while (*++tptr);
+ *++urlp = '\0'; /* terminate after last character */
+
++ /* redirect active */
++ if (redirect_path && (strncmp(urlcopy, redirect_path, strlen(redirect_path)) != 0))
++ found_moved_temporarily = redirect_path;
++
+ /* If URL is a directory, add '/' */
+- if (urlp[-1] != '/') {
++ if (!redirect_path && (urlp[-1] != '/')) {
+ if (is_directory(urlcopy + 1, 1, NULL)) {
+ found_moved_temporarily = urlcopy;
+ }
+@@ -2283,7 +2297,9 @@ static void sighup_handler(int sig UNUSE
+ }
+
+ enum {
+- c_opt_config_file = 0,
++ R_opt_redirect_path = 0,
++ H_opt_redirect_host,
++ c_opt_config_file,
+ d_opt_decode_url,
+ h_opt_home_httpd,
+ IF_FEATURE_HTTPD_ENCODE_URL_STR(e_opt_encode_url,)
+@@ -2332,12 +2348,13 @@ int httpd_main(int argc UNUSED_PARAM, ch
+ /* We do not "absolutize" path given by -h (home) opt.
+ * If user gives relative path in -h,
+ * $SCRIPT_FILENAME will not be set. */
+- opt = getopt32(argv, "c:d:h:"
++ opt = getopt32(argv, "R:H:c:d:h:"
+ IF_FEATURE_HTTPD_ENCODE_URL_STR("e:")
+ IF_FEATURE_HTTPD_BASIC_AUTH("r:")
+ IF_FEATURE_HTTPD_AUTH_MD5("m:")
+ IF_FEATURE_HTTPD_SETUID("u:")
+ "p:ifv",
++ &redirect_path, &redirect_host,
+ &opt_c_configFile, &url_for_decode, &home_httpd
+ IF_FEATURE_HTTPD_ENCODE_URL_STR(, &url_for_encode)
+ IF_FEATURE_HTTPD_BASIC_AUTH(, &g_realm)
diff --git a/package/busybox/patches/.svn/text-base/410-httpd_cgi_headers.patch.svn-base b/package/busybox/patches/.svn/text-base/410-httpd_cgi_headers.patch.svn-base
new file mode 100644
index 0000000..b02a5b9
--- /dev/null
+++ b/package/busybox/patches/.svn/text-base/410-httpd_cgi_headers.patch.svn-base
@@ -0,0 +1,16 @@
+--- a/networking/httpd.c
++++ b/networking/httpd.c
+@@ -1222,10 +1222,10 @@ static NOINLINE void cgi_io_loop_and_exi
+ if (full_write(STDOUT_FILENO, HTTP_200, sizeof(HTTP_200)-1) != sizeof(HTTP_200)-1)
+ break;
+ }
+- /* Commented out:
+- if (!strstr(rbuf, "ontent-")) {
+- full_write(s, "Content-type: text/plain\r\n\r\n", 28);
++ if (!strstr(rbuf, "ontent-") && !strstr(rbuf, "ocation:")) {
++ full_write(1, "Content-type: text/plain\r\n\r\n", 28);
+ }
++ /* Previously commented out:
+ * Counter-example of valid CGI without Content-type:
+ * echo -en "HTTP/1.0 302 Found\r\n"
+ * echo -en "Location: http://www.busybox.net\r\n"
diff --git a/package/busybox/patches/.svn/text-base/440-httpd_chdir.patch.svn-base b/package/busybox/patches/.svn/text-base/440-httpd_chdir.patch.svn-base
new file mode 100644
index 0000000..401c6eb
--- /dev/null
+++ b/package/busybox/patches/.svn/text-base/440-httpd_chdir.patch.svn-base
@@ -0,0 +1,10 @@
+--- a/networking/httpd.c
++++ b/networking/httpd.c
+@@ -1814,6 +1814,7 @@ static void handle_incoming_and_exit(con
+ char *header_ptr = header_ptr;
+ Htaccess_Proxy *proxy_entry;
+ #endif
++ xchdir(home_httpd);
+
+ /* Allocation of iobuf is postponed until now
+ * (IOW, server process doesn't need to waste 8k) */
diff --git a/package/busybox/patches/.svn/text-base/470-insmod_search.patch.svn-base b/package/busybox/patches/.svn/text-base/470-insmod_search.patch.svn-base
new file mode 100644
index 0000000..7f0188f
--- /dev/null
+++ b/package/busybox/patches/.svn/text-base/470-insmod_search.patch.svn-base
@@ -0,0 +1,137 @@
+--- a/modutils/Config.src
++++ b/modutils/Config.src
+@@ -247,7 +247,7 @@ config FEATURE_MODUTILS_SYMBOLS
+ config DEFAULT_MODULES_DIR
+ string "Default directory containing modules"
+ default "/lib/modules"
+- depends on DEPMOD || MODPROBE || MODPROBE_SMALL || MODINFO
++ depends on DEPMOD || INSMOD || MODPROBE || MODPROBE_SMALL || MODINFO
+ help
+ Directory that contains kernel modules.
+ Defaults to "/lib/modules"
+--- a/modutils/insmod.c
++++ b/modutils/insmod.c
+@@ -11,6 +11,106 @@
+
+ #include "libbb.h"
+ #include "modutils.h"
++#include <sys/utsname.h>
++#ifndef CONFIG_FEATURE_2_4_MODULES
++#include <sys/mman.h>
++#include <asm/unistd.h>
++#include <sys/syscall.h>
++#endif
++
++static char *g_filename = NULL;
++
++static int FAST_FUNC check_module_name_match(const char *filename, struct stat *statbuf,
++ void *userdata, int depth)
++{
++ char *fullname = (char *) userdata;
++ char *tmp;
++
++ if (fullname[0] == '\0')
++ return FALSE;
++
++ tmp = bb_get_last_path_component_nostrip(filename);
++ if (strcmp(tmp, fullname) == 0) {
++ /* Stop searching if we find a match */
++ g_filename = xstrdup(filename);
++ return FALSE;
++ }
++
++ return TRUE;
++}
++
++static int find_module(char *filename)
++{
++ char *module_dir, real_module_dir[FILENAME_MAX];
++ int len, slen, ret = ENOENT, k_version;
++ struct utsname myuname;
++ const char *suffix = ".ko";
++ struct stat st;
++
++ /* check the kernel version */
++ if (uname(&myuname) != 0)
++ return EINVAL;
++
++ k_version = myuname.release[0] - '0';
++
++ if (k_version < 2 || k_version > 9)
++ return EINVAL;
++
++ if (k_version == 2) {
++ int k_patchlevel = myuname.release[2] - '0';
++ if (k_patchlevel <= 4)
++#if ENABLE_FEATURE_2_4_MODULES
++ suffix = ".o";
++#else
++ return EINVAL;
++#endif
++ }
++
++ len = strlen(filename);
++ slen = strlen(suffix);
++
++ /* check for suffix and absolute path first */
++ if ((len < slen + 2) || (strcmp(filename + len - slen, suffix) != 0)) {
++ filename = xasprintf("%s%s", filename, suffix);
++ } else {
++ filename = strdup(filename);
++ if ((stat(filename, &st) == 0) && S_ISREG(st.st_mode)) {
++ g_filename = filename;
++ return 0;
++ }
++ free(filename);
++ return ENOENT;
++ }
++
++ /* next: scan /lib/modules/<release> */
++ /* Jump through hoops in case /lib/modules/`uname -r`
++ * is a symlink. We do not want recursive_action to
++ * follow symlinks, but we do want to follow the
++ * /lib/modules/`uname -r` dir, So resolve it ourselves
++ * if it is a link... */
++ module_dir = concat_path_file(CONFIG_DEFAULT_MODULES_DIR, myuname.release);
++ if (realpath(module_dir, real_module_dir) != NULL) {
++ free(module_dir);
++ module_dir = real_module_dir;
++ }
++
++ recursive_action(module_dir, ACTION_RECURSE,
++ check_module_name_match, 0, filename, 0);
++
++ /* Check if we have a complete path */
++ if (g_filename == NULL)
++ goto done;
++
++ if ((stat(g_filename, &st) == 0) && S_ISREG(st.st_mode))
++ ret = 0;
++ else
++ free(g_filename);
++
++done:
++ free(filename);
++
++ return ret;
++}
+
+ /* 2.6 style insmod has no options and required filename
+ * (not module name - .ko can't be omitted) */
+@@ -58,9 +158,15 @@ int insmod_main(int argc UNUSED_PARAM, c
+ if (!filename)
+ bb_show_usage();
+
+- rc = bb_init_module(filename, parse_cmdline_module_options(argv, /*quote_spaces:*/ 0));
++ rc = find_module(filename);
++ if (rc || (g_filename == NULL))
++ goto done;
++
++ rc = bb_init_module(g_filename, parse_cmdline_module_options(argv, /*quote_spaces:*/ 0));
+ if (rc)
+ bb_error_msg("can't insert '%s': %s", filename, moderror(rc));
++ free (g_filename);
+
++done:
+ return rc;
+ }
diff --git a/package/busybox/patches/.svn/text-base/490-mount_disable_check.patch.svn-base b/package/busybox/patches/.svn/text-base/490-mount_disable_check.patch.svn-base
new file mode 100644
index 0000000..2fcb7f7
--- /dev/null
+++ b/package/busybox/patches/.svn/text-base/490-mount_disable_check.patch.svn-base
@@ -0,0 +1,12 @@
+--- a/util-linux/mount.c
++++ b/util-linux/mount.c
+@@ -128,9 +128,6 @@
+ #if ENABLE_FEATURE_MOUNT_NFS
+ /* This is just a warning of a common mistake. Possibly this should be a
+ * uclibc faq entry rather than in busybox... */
+-# if defined(__UCLIBC__) && ! defined(__UCLIBC_HAS_RPC__)
+-# error "You need to build uClibc with UCLIBC_HAS_RPC for NFS support"
+-# endif
+ # include <rpc/rpc.h>
+ # include <rpc/pmap_prot.h>
+ # include <rpc/pmap_clnt.h>
diff --git a/package/busybox/patches/.svn/text-base/510-awk_include.patch.svn-base b/package/busybox/patches/.svn/text-base/510-awk_include.patch.svn-base
new file mode 100644
index 0000000..9f525ac
--- /dev/null
+++ b/package/busybox/patches/.svn/text-base/510-awk_include.patch.svn-base
@@ -0,0 +1,217 @@
+--- a/editors/awk.c
++++ b/editors/awk.c
+@@ -1,3 +1,4 @@
++
+ /* vi: set sw=4 ts=4: */
+ /*
+ * awk implementation for busybox
+@@ -81,9 +82,14 @@ typedef struct chain_s {
+ } chain;
+
+ /* Function */
++typedef var *(*awk_cfunc)(var *res, var *args, int nargs);
+ typedef struct func_s {
+ unsigned nargs;
++ enum { AWKFUNC, CFUNC } type;
++ union {
++ awk_cfunc cfunc;
+ struct chain_s body;
++ } x;
+ } func;
+
+ /* I/O stream */
+@@ -1473,7 +1479,8 @@ static void parse_program(char *p)
+ next_token(TC_FUNCTION);
+ g_pos++;
+ f = newfunc(t_string);
+- f->body.first = NULL;
++ f->type = AWKFUNC;
++ f->x.body.first = NULL;
+ f->nargs = 0;
+ while (next_token(TC_VARIABLE | TC_SEQTERM) & TC_VARIABLE) {
+ v = findvar(ahash, t_string);
+@@ -1482,7 +1489,7 @@ static void parse_program(char *p)
+ if (next_token(TC_COMMA | TC_SEQTERM) & TC_SEQTERM)
+ break;
+ }
+- seq = &f->body;
++ seq = &f->x.body;
+ chain_group();
+ clear_array(ahash);
+
+@@ -2580,7 +2587,8 @@ static var *evaluate(node *op, var *res)
+ var *vbeg, *v;
+ const char *sv_progname;
+
+- if (!op->r.f->body.first)
++ if ((op->r.f->type == AWKFUNC) &&
++ !op->r.f->x.body.first)
+ syntax_error(EMSG_UNDEF_FUNC);
+
+ vbeg = v = nvalloc(op->r.f->nargs + 1);
+@@ -2597,7 +2605,10 @@ static var *evaluate(node *op, var *res)
+ fnargs = vbeg;
+ sv_progname = g_progname;
+
+- res = evaluate(op->r.f->body.first, res);
++ if (op->r.f->type == AWKFUNC)
++ res = evaluate(op->r.f->x.body.first, res);
++ else if (op->r.f->type == CFUNC)
++ res = op->r.f->x.cfunc(res, fnargs, op->r.f->nargs);
+
+ g_progname = sv_progname;
+ nvfree(fnargs);
+@@ -2991,6 +3002,143 @@ static rstream *next_input_file(void)
+ #undef files_happen
+ }
+
++/* read the contents of an entire file */
++static char *get_file(const char *fname)
++{
++ FILE *F;
++ char *s = NULL;
++ int i, j, flen;
++
++ F = fopen(fname, "r");
++ if (!F) {
++ return NULL;
++ }
++
++ if (fseek(F, 0, SEEK_END) == 0) {
++ flen = ftell(F);
++ s = (char *)xmalloc(flen+4);
++ fseek(F, 0, SEEK_SET);
++ i = 1 + fread(s+1, 1, flen, F);
++ } else {
++ for (i=j=1; j>0; i+=j) {
++ s = (char *)xrealloc(s, i+4096);
++ j = fread(s+i, 1, 4094, F);
++ }
++ }
++
++ s[i] = '\0';
++ fclose(F);
++ return s;
++}
++
++
++/* parse_include():
++ *
++ * taken from parse_program from awk.c
++ * END{} is not parsed here, and BEGIN{} is executed immediately
++ */
++static void parse_include(char *p)
++{
++ uint32_t tclass;
++ chain *initseq = NULL;
++ chain tmp;
++ func *f;
++ var *v, *tv;
++
++ tv = nvalloc(1);
++ memset(&tmp, 0, sizeof(tmp));
++ g_pos = p;
++ t_lineno = 1;
++ while ((tclass = next_token(TC_EOF | TC_OPSEQ |
++ TC_OPTERM | TC_BEGIN | TC_FUNCDECL)) != TC_EOF) {
++ if (tclass & TC_OPTERM)
++ continue;
++
++ seq = &tmp;
++ if (tclass & TC_BEGIN) {
++ initseq = xzalloc(sizeof(chain));
++ seq = initseq;
++ chain_group();
++ } else if (tclass & TC_FUNCDECL) {
++ next_token(TC_FUNCTION);
++ g_pos++;
++ f = newfunc(t_string);
++ f->type = AWKFUNC;
++ f->x.body.first = NULL;
++ f->nargs = 0;
++ while (next_token(TC_VARIABLE | TC_SEQTERM) & TC_VARIABLE) {
++ v = findvar(ahash, t_string);
++ v->x.aidx = (f->nargs)++;
++
++ if (next_token(TC_COMMA | TC_SEQTERM) & TC_SEQTERM)
++ break;
++ }
++ seq = &(f->x.body);
++ chain_group();
++ clear_array(ahash);
++ }
++ }
++ if (initseq && initseq->first)
++ tv = evaluate(initseq->first, tv);
++ nvfree(tv);
++}
++
++
++/* include an awk file and run its BEGIN{} section */
++static xhash *includes = NULL;
++static void include_file(const char *filename)
++{
++ char *s;
++ var *v;
++ int oldlnr = g_lineno;
++ const char *oldprg = g_progname;
++
++ if (!includes)
++ includes = hash_init();
++
++ /* find out if the file has been included already */
++ v = findvar(includes, filename);
++ if (istrue(v))
++ return;
++ setvar_s(v, "1");
++
++ /* read include file */
++ s = get_file(filename);
++ if (!s) {
++ fprintf(stderr, "Could not open file.\n");
++ return;
++ }
++ g_lineno = 1;
++ g_progname = xstrdup(filename);
++ parse_include(s+1);
++ free(s);
++ g_lineno = oldlnr;
++ g_progname = oldprg;
++}
++
++static var *include(var *res, var *args, int nargs)
++{
++ const char *s;
++
++ nargs = nargs; /* shut up, gcc */
++ s = getvar_s(args);
++ if (s && (strlen(s) > 0))
++ include_file(s);
++
++ return res;
++}
++
++/* registers a global c function for the awk interpreter */
++static void register_cfunc(const char *name, awk_cfunc cfunc, int nargs)
++{
++ func *f;
++
++ f = newfunc(name);
++ f->type = CFUNC;
++ f->x.cfunc = cfunc;
++ f->nargs = nargs;
++}
++
+ int awk_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
+ int awk_main(int argc, char **argv)
+ {
+@@ -3056,6 +3204,9 @@ int awk_main(int argc, char **argv)
+ *s1 = '=';
+ }
+ }
++
++ register_cfunc("include", include, 1);
++
+ opt_complementary = "v::f::"; /* -v and -f can occur multiple times */
+ opt = getopt32(argv, "F:v:f:W:", &opt_F, &list_v, &list_f, &opt_W);
+ argv += optind;
diff --git a/package/busybox/patches/.svn/text-base/524-udhcpc_renew.patch.svn-base b/package/busybox/patches/.svn/text-base/524-udhcpc_renew.patch.svn-base
new file mode 100644
index 0000000..c22fa52
--- /dev/null
+++ b/package/busybox/patches/.svn/text-base/524-udhcpc_renew.patch.svn-base
@@ -0,0 +1,10 @@
+--- a/networking/udhcp/dhcpc.c
++++ b/networking/udhcp/dhcpc.c
+@@ -1045,7 +1045,6 @@ static void perform_renew(void)
+ state = RENEW_REQUESTED;
+ break;
+ case RENEW_REQUESTED: /* impatient are we? fine, square 1 */
+- udhcp_run_script(NULL, "deconfig");
+ case REQUESTING:
+ case RELEASED:
+ change_listen_mode(LISTEN_RAW);
diff --git a/package/busybox/patches/.svn/text-base/610-ntpd_delayed_resolve.patch.svn-base b/package/busybox/patches/.svn/text-base/610-ntpd_delayed_resolve.patch.svn-base
new file mode 100644
index 0000000..5e17ae1
--- /dev/null
+++ b/package/busybox/patches/.svn/text-base/610-ntpd_delayed_resolve.patch.svn-base
@@ -0,0 +1,48 @@
+--- a/networking/ntpd.c
++++ b/networking/ntpd.c
+@@ -216,6 +216,7 @@ typedef struct {
+ typedef struct {
+ len_and_sockaddr *p_lsa;
+ char *p_dotted;
++ char *p_hostname;
+ /* when to send new query (if p_fd == -1)
+ * or when receive times out (if p_fd >= 0): */
+ int p_fd;
+@@ -646,8 +647,9 @@ add_peers(char *s)
+ peer_t *p;
+
+ p = xzalloc(sizeof(*p));
+- p->p_lsa = xhost2sockaddr(s, 123);
+- p->p_dotted = xmalloc_sockaddr2dotted_noport(&p->p_lsa->u.sa);
++ p->p_hostname = s;
++ p->p_lsa = NULL;
++ p->p_dotted = NULL;
+ p->p_fd = -1;
+ p->p_xmt_msg.m_status = MODE_CLIENT | (NTP_VERSION << 3);
+ p->next_action_time = G.cur_time; /* = set_next(p, 0); */
+@@ -696,6 +698,25 @@ send_query_to_peer(peer_t *p)
+ *
+ * Uncomment this and use strace to see it in action:
+ */
++
++ /* See if the peer hostname already resolved yet, if not, retry to resolv and return on failure */
++ if (!p->p_lsa)
++ {
++ p->p_lsa = host2sockaddr(p->p_hostname, 123);
++
++ if (p->p_lsa)
++ {
++ p->p_dotted = xmalloc_sockaddr2dotted_noport(&p->p_lsa->u.sa);
++ VERB1 bb_error_msg("resolved peer %s to %s", p->p_hostname, p->p_dotted);
++ }
++ else
++ {
++ set_next(p, RETRY_INTERVAL);
++ VERB1 bb_error_msg("could not resolve peer %s, skipping", p->p_hostname);
++ return;
++ }
++ }
++
+ #define PROBE_LOCAL_ADDR /* { len_and_sockaddr lsa; lsa.len = LSA_SIZEOF_SA; getsockname(p->query.fd, &lsa.u.sa, &lsa.len); } */
+
+ if (p->p_fd == -1) {
diff --git a/package/busybox/patches/.svn/text-base/611-upstream_ntpd_version_fix.patch.svn-base b/package/busybox/patches/.svn/text-base/611-upstream_ntpd_version_fix.patch.svn-base
new file mode 100644
index 0000000..7bcb847
--- /dev/null
+++ b/package/busybox/patches/.svn/text-base/611-upstream_ntpd_version_fix.patch.svn-base
@@ -0,0 +1,29 @@
+From b7841cf7b919b16d1bd4619154bf7cb4c22b4ccd Mon Sep 17 00:00:00 2001
+From: Paul Marks <paul@pmarks.net>
+Date: Mon, 14 Jan 2013 01:39:10 +0000
+Subject: ntpd: fix incorrect m_status field in outgoing packets. Closes 5120
+
+When using busybox ntpd with an NTPv3 client and NTPv4 server (or vice
+versa), the version numbers can be incorrectly ORed together, yielding
+the bogus value of "NTPv7". This makes ntpd unusable with clients
+such as Chrony and Windows "Internet Time".
+
+This patch avoids the version mangling, by copying only the Leap
+Indicator bits from the server's status field.
+
+Signed-off-by: Paul Marks <paul@pmarks.net>
+Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
+---
+(limited to 'networking/ntpd.c')
+
+--- a/networking/ntpd.c
++++ b/networking/ntpd.c
+@@ -1794,7 +1794,7 @@ recv_and_process_client_pkt(void /*int f
+
+ /* Build a reply packet */
+ memset(&msg, 0, sizeof(msg));
+- msg.m_status = G.stratum < MAXSTRAT ? G.ntp_status : LI_ALARM;
++ msg.m_status = G.stratum < MAXSTRAT ? (G.ntp_status & LI_MASK) : LI_ALARM;
+ msg.m_status |= (query_status & VERSION_MASK);
+ msg.m_status |= ((query_status & MODE_MASK) == MODE_CLIENT) ?
+ MODE_SERVER : MODE_SYM_PAS;
diff --git a/package/busybox/patches/.svn/text-base/700-hexdump_segfault_fix.patch.svn-base b/package/busybox/patches/.svn/text-base/700-hexdump_segfault_fix.patch.svn-base
new file mode 100644
index 0000000..ab09fb3
--- /dev/null
+++ b/package/busybox/patches/.svn/text-base/700-hexdump_segfault_fix.patch.svn-base
@@ -0,0 +1,11 @@
+--- a/libbb/dump.c
++++ b/libbb/dump.c
+@@ -301,7 +301,7 @@ static NOINLINE void rewrite(priv_dumper
+ ) {
+ fu->reps += (dumper->blocksize - fs->bcnt) / fu->bcnt;
+ }
+- if (fu->reps > 1) {
++ if (fu->reps > 1 && fu->nextpr) {
+ for (pr = fu->nextpr;; pr = pr->nextpr)
+ if (!pr->nextpr)
+ break;
diff --git a/package/busybox/patches/.svn/text-base/802-brctl_linux24.patch.svn-base b/package/busybox/patches/.svn/text-base/802-brctl_linux24.patch.svn-base
new file mode 100644
index 0000000..8cc1977
--- /dev/null
+++ b/package/busybox/patches/.svn/text-base/802-brctl_linux24.patch.svn-base
@@ -0,0 +1,74 @@
+--- a/networking/brctl.c
++++ b/networking/brctl.c
+@@ -56,7 +56,7 @@
+
+ /* Maximum number of ports supported per bridge interface. */
+ #ifndef MAX_PORTS
+-# define MAX_PORTS 32
++# define MAX_PORTS 1024
+ #endif
+
+ /* Use internal number parsing and not the "exact" conversion. */
+@@ -193,6 +193,7 @@ int brctl_main(int argc UNUSED_PARAM, ch
+ printf(bi.stp_enabled ? "\tyes" : "\tno");
+
+ /* print interface list */
++ memset(ifidx, 0, sizeof ifidx);
+ arm_ioctl(args, BRCTL_GET_PORT_LIST,
+ (unsigned long) ifidx, MAX_PORTS);
+ xioctl(fd, SIOCDEVPRIVATE, &ifr);
+@@ -221,9 +222,19 @@ int brctl_main(int argc UNUSED_PARAM, ch
+ br = *argv++;
+
+ if (key == ARG_addbr || key == ARG_delbr) { /* addbr or delbr */
+- ioctl_or_perror_and_die(fd,
+- key == ARG_addbr ? SIOCBRADDBR : SIOCBRDELBR,
+- br, "bridge %s", br);
++ int ret;
++ ret = ioctl(fd,
++ key == ARG_addbr ? SIOCBRADDBR : SIOCBRDELBR,
++ br);
++ if (ret < 0) {
++ arm_ioctl(args,
++ key == ARG_addbr ? BRCTL_ADD_BRIDGE : BRCTL_DEL_BRIDGE,
++ (unsigned long) br, 0);
++ ret = ioctl(fd, SIOCSIFBR, args);
++ }
++ if (ret < 0) {
++ bb_perror_msg_and_die("bridge %s", br);
++ }
+ goto done;
+ }
+
+@@ -232,14 +243,27 @@ int brctl_main(int argc UNUSED_PARAM, ch
+
+ strncpy_IFNAMSIZ(ifr.ifr_name, br);
+ if (key == ARG_addif || key == ARG_delif) { /* addif or delif */
++ int ret;
++ int if_index;
+ brif = *argv;
+- ifr.ifr_ifindex = if_nametoindex(brif);
+- if (!ifr.ifr_ifindex) {
++ if_index = if_nametoindex(brif);
++ if (!if_index) {
+ bb_perror_msg_and_die("iface %s", brif);
+ }
+- ioctl_or_perror_and_die(fd,
++ ifr.ifr_ifindex = if_index;
++ ret = ioctl(fd,
+ key == ARG_addif ? SIOCBRADDIF : SIOCBRDELIF,
+- &ifr, "bridge %s", br);
++ &ifr);
++ if (ret < 0) {
++ arm_ioctl(args,
++ key == ARG_addif ? BRCTL_ADD_IF : BRCTL_DEL_IF,
++ if_index, 0);
++ ifr.ifr_data = (char *) &args;
++ ret = ioctl(fd, SIOCDEVPRIVATE, &ifr);
++ }
++ if (ret < 0) {
++ bb_perror_msg_and_die("bridge %s", br);
++ }
+ goto done_next_argv;
+ }
+ #if ENABLE_FEATURE_BRCTL_FANCY
diff --git a/package/busybox/patches/.svn/text-base/902-telnetd_intr.patch.svn-base b/package/busybox/patches/.svn/text-base/902-telnetd_intr.patch.svn-base
new file mode 100644
index 0000000..862ece0
--- /dev/null
+++ b/package/busybox/patches/.svn/text-base/902-telnetd_intr.patch.svn-base
@@ -0,0 +1,10 @@
+--- a/networking/telnetd.c
++++ b/networking/telnetd.c
+@@ -330,6 +330,7 @@ make_new_session(
+
+ /* Restore default signal handling ASAP */
+ bb_signals((1 << SIGCHLD) + (1 << SIGPIPE), SIG_DFL);
++ signal(SIGINT, SIG_DFL);
+
+ pid = getpid();
+
diff --git a/package/busybox/patches/.svn/text-base/910-insmod-q-flag.patch.svn-base b/package/busybox/patches/.svn/text-base/910-insmod-q-flag.patch.svn-base
new file mode 100644
index 0000000..6002f20
--- /dev/null
+++ b/package/busybox/patches/.svn/text-base/910-insmod-q-flag.patch.svn-base
@@ -0,0 +1,33 @@
+--- a/modutils/insmod.c
++++ b/modutils/insmod.c
+@@ -139,7 +139,7 @@ int insmod_main(int argc, char **argv) M
+ int insmod_main(int argc UNUSED_PARAM, char **argv)
+ {
+ char *filename;
+- int rc;
++ int rc, opt;
+
+ /* Compat note:
+ * 2.6 style insmod has no options and required filename
+@@ -149,10 +149,8 @@ int insmod_main(int argc UNUSED_PARAM, c
+ * or in $MODPATH.
+ */
+
+- IF_FEATURE_2_4_MODULES(
+- getopt32(argv, INSMOD_OPTS INSMOD_ARGS);
+- argv += optind - 1;
+- );
++ opt = getopt32(argv, INSMOD_OPTS, NULL, NULL);
++ argv += optind - 1;
+
+ filename = *++argv;
+ if (!filename)
+@@ -163,7 +161,7 @@ int insmod_main(int argc UNUSED_PARAM, c
+ goto done;
+
+ rc = bb_init_module(g_filename, parse_cmdline_module_options(argv, /*quote_spaces:*/ 0));
+- if (rc)
++ if (rc && !(opt & INSMOD_OPT_SILENT))
+ bb_error_msg("can't insert '%s': %s", filename, moderror(rc));
+ free (g_filename);
+
diff --git a/package/busybox/patches/.svn/text-base/911-date-k-flag.patch.svn-base b/package/busybox/patches/.svn/text-base/911-date-k-flag.patch.svn-base
new file mode 100644
index 0000000..c55ee23
--- /dev/null
+++ b/package/busybox/patches/.svn/text-base/911-date-k-flag.patch.svn-base
@@ -0,0 +1,87 @@
+--- a/coreutils/date.c
++++ b/coreutils/date.c
+@@ -123,6 +123,7 @@
+ //usage: IF_FEATURE_DATE_ISOFMT(
+ //usage: "\n -D FMT Use FMT for -d TIME conversion"
+ //usage: )
++//usage: "\n -k Set Kernel timezone from localtime and exit"
+ //usage: "\n"
+ //usage: "\nRecognized TIME formats:"
+ //usage: "\n hh:mm[:ss]"
+@@ -135,6 +136,7 @@
+ //usage: "Wed Apr 12 18:52:41 MDT 2000\n"
+
+ #include "libbb.h"
++#include <sys/time.h>
+ #if ENABLE_FEATURE_DATE_NANO
+ # include <sys/syscall.h>
+ #endif
+@@ -145,8 +147,9 @@ enum {
+ OPT_UTC = (1 << 2), /* u */
+ OPT_DATE = (1 << 3), /* d */
+ OPT_REFERENCE = (1 << 4), /* r */
+- OPT_TIMESPEC = (1 << 5) * ENABLE_FEATURE_DATE_ISOFMT, /* I */
+- OPT_HINT = (1 << 6) * ENABLE_FEATURE_DATE_ISOFMT, /* D */
++ OPT_KERNELTZ = (1 << 5), /* k */
++ OPT_TIMESPEC = (1 << 6) * ENABLE_FEATURE_DATE_ISOFMT, /* I */
++ OPT_HINT = (1 << 7) * ENABLE_FEATURE_DATE_ISOFMT, /* D */
+ };
+
+ static void maybe_set_utc(int opt)
+@@ -164,12 +167,15 @@ static const char date_longopts[] ALIGN1
+ /* "universal\0" No_argument "u" */
+ "date\0" Required_argument "d"
+ "reference\0" Required_argument "r"
++ "set-kernel-tz\0" No_argument "k"
+ ;
+ #endif
+
+ int date_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
+ int date_main(int argc UNUSED_PARAM, char **argv)
+ {
++ time_t tt;
++ struct timezone tz;
+ struct timespec ts;
+ struct tm tm_time;
+ char buf_fmt_dt2str[64];
+@@ -184,7 +190,7 @@ int date_main(int argc UNUSED_PARAM, cha
+ opt_complementary = "d--s:s--d"
+ IF_FEATURE_DATE_ISOFMT(":R--I:I--R");
+ IF_LONG_OPTS(applet_long_options = date_longopts;)
+- opt = getopt32(argv, "Rs:ud:r:"
++ opt = getopt32(argv, "Rs:ud:r:k"
+ IF_FEATURE_DATE_ISOFMT("I::D:"),
+ &date_str, &date_str, &filename
+ IF_FEATURE_DATE_ISOFMT(, &isofmt_arg, &fmt_str2dt));
+@@ -241,6 +247,31 @@ int date_main(int argc UNUSED_PARAM, cha
+ if (*argv)
+ bb_show_usage();
+
++ /* Setting of kernel timezone was requested */
++ if (opt & OPT_KERNELTZ) {
++ tt = time(NULL);
++ localtime_r(&tt, &tm_time);
++
++ /* workaround warp_clock() on first invocation */
++ memset(&tz, 0, sizeof(tz));
++ settimeofday(NULL, &tz);
++
++ memset(&tz, 0, sizeof(tz));
++#ifdef __USE_BSD
++ tz.tz_minuteswest = -(tm_time.tm_gmtoff / 60);
++#else
++ tz.tz_minuteswest = -(tm_time.__tm_gmtoff / 60);
++#endif
++
++ if (settimeofday(NULL, &tz))
++ {
++ bb_perror_msg("can't set kernel time zone");
++ return EXIT_FAILURE;
++ }
++
++ return EXIT_SUCCESS;
++ }
++
+ /* Now we have parsed all the information except the date format
+ * which depends on whether the clock is being set or read */
+
diff --git a/package/busybox/patches/.svn/text-base/920-portability.patch.svn-base b/package/busybox/patches/.svn/text-base/920-portability.patch.svn-base
new file mode 100644
index 0000000..4e5b9a0
--- /dev/null
+++ b/package/busybox/patches/.svn/text-base/920-portability.patch.svn-base
@@ -0,0 +1,13 @@
+--- a/scripts/kconfig/mconf.c
++++ b/scripts/kconfig/mconf.c
+@@ -25,6 +25,10 @@
+ #include <unistd.h>
+ #include <locale.h>
+
++#ifndef SIGWINCH
++#define SIGWINCH 28
++#endif
++
+ #define LKC_DIRECT_LINK
+ #include "lkc.h"
+
diff --git a/package/busybox/patches/.svn/text-base/950-partial-checksum.patch.svn-base b/package/busybox/patches/.svn/text-base/950-partial-checksum.patch.svn-base
new file mode 100644
index 0000000..6e8a69e
--- /dev/null
+++ b/package/busybox/patches/.svn/text-base/950-partial-checksum.patch.svn-base
@@ -0,0 +1,86 @@
+--- a/networking/udhcp/dhcpc.c
++++ b/networking/udhcp/dhcpc.c
+@@ -26,8 +26,8 @@
+ #include "dhcpc.h"
+
+ #include <netinet/if_ether.h>
+-#include <netpacket/packet.h>
+ #include <linux/filter.h>
++#include <linux/if_packet.h>
+
+ /* struct client_config_t client_config is in bb_common_bufsiz1 */
+
+@@ -846,17 +846,41 @@ static int send_release(uint32_t server,
+ static NOINLINE int udhcp_recv_raw_packet(struct dhcp_packet *dhcp_pkt, int fd)
+ {
+ int bytes;
++ int nocsum = 0;
+ struct ip_udp_dhcp_packet packet;
+ uint16_t check;
++ unsigned char cmsgbuf[CMSG_LEN(sizeof(struct tpacket_auxdata))];
++ struct iovec iov = {
++ .iov_base = &packet,
++ .iov_len = sizeof(packet),
++ };
++ struct msghdr msg = {
++ .msg_iov = &iov,
++ .msg_iovlen = 1,
++ .msg_control = cmsgbuf,
++ .msg_controllen = sizeof(cmsgbuf),
++ };
++ struct cmsghdr *cmsg;
+
+ memset(&packet, 0, sizeof(packet));
+- bytes = safe_read(fd, &packet, sizeof(packet));
++ do {
++ bytes = recvmsg(fd, &msg, 0);
++ } while (bytes < 0 && errno == EINTR);
++
+ if (bytes < 0) {
+ log1("Packet read error, ignoring");
+ /* NB: possible down interface, etc. Caller should pause. */
+ return bytes; /* returns -1 */
+ }
+
++ for (cmsg = CMSG_FIRSTHDR(&msg); cmsg; cmsg = CMSG_NXTHDR(&msg, cmsg)) {
++ if (cmsg->cmsg_level == SOL_PACKET &&
++ cmsg->cmsg_type == PACKET_AUXDATA) {
++ struct tpacket_auxdata *aux = (void *)CMSG_DATA(cmsg);
++ nocsum = aux->tp_status & TP_STATUS_CSUMNOTREADY;
++ }
++ }
++
+ if (bytes < (int) (sizeof(packet.ip) + sizeof(packet.udp))) {
+ log1("Packet is too short, ignoring");
+ return -2;
+@@ -896,7 +920,7 @@ static NOINLINE int udhcp_recv_raw_packe
+ packet.ip.tot_len = packet.udp.len; /* yes, this is needed */
+ check = packet.udp.check;
+ packet.udp.check = 0;
+- if (check && check != udhcp_checksum(&packet, bytes)) {
++ if (!nocsum && check && check != udhcp_checksum(&packet, bytes)) {
+ log1("Packet with bad UDP checksum received, ignoring");
+ return -2;
+ }
+@@ -942,6 +966,7 @@ static int udhcp_raw_socket(int ifindex)
+ {
+ int fd;
+ struct sockaddr_ll sock;
++ int val;
+
+ /*
+ * Comment:
+@@ -1008,6 +1033,13 @@ static int udhcp_raw_socket(int ifindex)
+ log1("Attached filter to raw socket fd %d", fd); // log?
+ }
+
++ val = 1;
++ if (setsockopt(fd, SOL_PACKET, PACKET_AUXDATA, &val,
++ sizeof(val)) < 0) {
++ if (errno != ENOPROTOOPT)
++ log1("Failed to set auxiliary packet data for socket fd %d", fd);
++ }
++
+ log1("Created raw socket");
+
+ return fd;
diff --git a/package/busybox/patches/.svn/text-base/998-arping_missing_includes.patch.svn-base b/package/busybox/patches/.svn/text-base/998-arping_missing_includes.patch.svn-base
new file mode 100644
index 0000000..a9d4a62
--- /dev/null
+++ b/package/busybox/patches/.svn/text-base/998-arping_missing_includes.patch.svn-base
@@ -0,0 +1,11 @@
+--- a/networking/arping.c
++++ b/networking/arping.c
+@@ -24,6 +24,8 @@
+
+ #include <arpa/inet.h>
+ #include <net/if.h>
++#include <net/if_arp.h>
++#include <netinet/if_ether.h>
+ #include <netinet/ether.h>
+ #include <netpacket/packet.h>
+
diff --git a/package/busybox/patches/.svn/text-base/999-musl-fixes.patch.svn-base b/package/busybox/patches/.svn/text-base/999-musl-fixes.patch.svn-base
new file mode 100644
index 0000000..b528b3e
--- /dev/null
+++ b/package/busybox/patches/.svn/text-base/999-musl-fixes.patch.svn-base
@@ -0,0 +1,16 @@
+--- a/include/platform.h
++++ b/include/platform.h
+@@ -443,6 +443,13 @@ typedef unsigned smalluint;
+ # undef HAVE_NET_ETHERNET_H
+ #endif
+
++#if defined(__musl__)
++# undef HAVE_SETBIT
++# include <stddef.h>
++# include <termios.h>
++# include <sys/ioctl.h>
++#endif
++
+ /*
+ * Now, define prototypes for all the functions defined in platform.c
+ * These must come after all the HAVE_* macros are defined (or not)
diff --git a/package/busybox/patches/001-init_avoid_loop_opening_tty.patch b/package/busybox/patches/001-init_avoid_loop_opening_tty.patch
new file mode 100644
index 0000000..4db64c3
--- /dev/null
+++ b/package/busybox/patches/001-init_avoid_loop_opening_tty.patch
@@ -0,0 +1,15 @@
+--- a/init/init.c
++++ b/init/init.c
+@@ -573,8 +573,11 @@ static void run_actions(int action_type)
+ /* Only run stuff with pid == 0. If pid != 0,
+ * it is already running
+ */
+- if (a->pid == 0)
++ if (a->pid == 0) {
++ if (a->terminal[0] && access(a->terminal, R_OK | W_OK))
++ continue;
+ a->pid = run(a);
++ }
+ }
+ }
+ }
diff --git a/package/busybox/patches/002-passwd_use_md5_hash_by_default_like_it_used_to_be.patch b/package/busybox/patches/002-passwd_use_md5_hash_by_default_like_it_used_to_be.patch
new file mode 100644
index 0000000..ff79f3e
--- /dev/null
+++ b/package/busybox/patches/002-passwd_use_md5_hash_by_default_like_it_used_to_be.patch
@@ -0,0 +1,20 @@
+From eb80c2a5315ed08bd329448217695375d89732c9 Mon Sep 17 00:00:00 2001
+From: Nicolas Thill <nico@openwrt.org>
+Date: Wed, 9 Nov 2011 18:17:20 +0100
+Subject: [PATCH] passwd: use MD5 hash by default (like it used to be)
+
+---
+ loginutils/passwd.c | 2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+--- a/loginutils/passwd.c
++++ b/loginutils/passwd.c
+@@ -94,7 +94,7 @@ int passwd_main(int argc UNUSED_PARAM, c
+ };
+ unsigned opt;
+ int rc;
+- const char *opt_a = "d"; /* des */
++ const char *opt_a = "m"; /* md5 */
+ const char *filename;
+ char *myname;
+ char *name;
diff --git a/package/busybox/patches/003-brctl_show_fix.patch b/package/busybox/patches/003-brctl_show_fix.patch
new file mode 100644
index 0000000..8177fb0
--- /dev/null
+++ b/package/busybox/patches/003-brctl_show_fix.patch
@@ -0,0 +1,37 @@
+--- a/networking/brctl.c
++++ b/networking/brctl.c
+@@ -129,7 +129,7 @@ int brctl_main(int argc UNUSED_PARAM, ch
+ "setageing\0" "setfd\0" "sethello\0" "setmaxage\0"
+ "setpathcost\0" "setportprio\0" "setbridgeprio\0"
+ )
+- IF_FEATURE_BRCTL_SHOW("showmacs\0" "show\0");
++ IF_FEATURE_BRCTL_SHOW("show\0");
+
+ enum { ARG_addbr = 0, ARG_delbr, ARG_addif, ARG_delif
+ IF_FEATURE_BRCTL_FANCY(,
+@@ -137,7 +137,7 @@ int brctl_main(int argc UNUSED_PARAM, ch
+ ARG_setageing, ARG_setfd, ARG_sethello, ARG_setmaxage,
+ ARG_setpathcost, ARG_setportprio, ARG_setbridgeprio
+ )
+- IF_FEATURE_BRCTL_SHOW(, ARG_showmacs, ARG_show)
++ IF_FEATURE_BRCTL_SHOW(, ARG_show)
+ };
+
+ int fd;
+--- a/networking/Config.src
++++ b/networking/Config.src
+@@ -82,12 +82,12 @@ config FEATURE_BRCTL_FANCY
+ This adds about 600 bytes.
+
+ config FEATURE_BRCTL_SHOW
+- bool "Support show, showmac and showstp"
++ bool "Support show"
+ default y
+ depends on BRCTL && FEATURE_BRCTL_FANCY
+ help
+ Add support for option which prints the current config:
+- showmacs, showstp, show
++ show
+
+ config DNSD
+ bool "dnsd"
diff --git a/package/busybox/patches/004-upstream-percent_decode_in_place.patch b/package/busybox/patches/004-upstream-percent_decode_in_place.patch
new file mode 100644
index 0000000..d94ee47
--- /dev/null
+++ b/package/busybox/patches/004-upstream-percent_decode_in_place.patch
@@ -0,0 +1,237 @@
+http://git.busybox.net/busybox/commit/?id=dd1061b6a79b0161597799e825bfefc27993ace5
+
+From dd1061b6a79b0161597799e825bfefc27993ace5 Mon Sep 17 00:00:00 2001
+From: Denys Vlasenko <vda.linux@googlemail.com>
+Date: Sun, 11 Sep 2011 21:04:02 +0200
+Subject: [PATCH] wget: URL-decode user:password before base64-encoding it into auth hdr. Closes 3625.
+
+function old new delta
+percent_decode_in_place - 152 +152
+parse_url 304 317 +13
+handle_incoming_and_exit 2795 2798 +3
+httpd_main 763 760 -3
+decodeString 152 - -152
+------------------------------------------------------------------------------
+(add/remove: 2/1 grow/shrink: 2/1 up/down: 168/-155) Total: 13 bytes
+
+Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
+
+--- a/include/libbb.h
++++ b/include/libbb.h
+@@ -1570,6 +1570,15 @@ int starts_with_cpu(const char *str) FAS
+ unsigned get_cpu_count(void) FAST_FUNC;
+
+
++/* Use strict=1 if you process input from untrusted source:
++ * it will return NULL on invalid %xx (bad hex chars)
++ * and str + 1 if decoded char is / or NUL.
++ * In non-strict mode, it always succeeds (returns str),
++ * and also it additionally decoded '+' to space.
++ */
++char *percent_decode_in_place(char *str, int strict) FAST_FUNC;
++
++
+ extern const char bb_uuenc_tbl_base64[];
+ extern const char bb_uuenc_tbl_std[];
+ void bb_uuencode(char *store, const void *s, int length, const char *tbl) FAST_FUNC;
+--- /dev/null
++++ b/libbb/percent_decode.c
+@@ -0,0 +1,69 @@
++/* vi: set sw=4 ts=4: */
++/*
++ * Licensed under GPLv2 or later, see file LICENSE in this source tree.
++ */
++
++//kbuild:lib-y += percent_decode.o
++
++#include "libbb.h"
++
++static unsigned hex_to_bin(unsigned char c)
++{
++ unsigned v;
++
++ v = c - '0';
++ if (v <= 9)
++ return v;
++ /* c | 0x20: letters to lower case, non-letters
++ * to (potentially different) non-letters */
++ v = (unsigned)(c | 0x20) - 'a';
++ if (v <= 5)
++ return v + 10;
++ return ~0;
++/* For testing:
++void t(char c) { printf("'%c'(%u) %u\n", c, c, hex_to_bin(c)); }
++int main() { t(0x10); t(0x20); t('0'); t('9'); t('A'); t('F'); t('a'); t('f');
++t('0'-1); t('9'+1); t('A'-1); t('F'+1); t('a'-1); t('f'+1); return 0; }
++*/
++}
++
++char* FAST_FUNC percent_decode_in_place(char *str, int strict)
++{
++ /* note that decoded string is always shorter than original */
++ char *src = str;
++ char *dst = str;
++ char c;
++
++ while ((c = *src++) != '\0') {
++ unsigned v;
++
++ if (!strict && c == '+') {
++ *dst++ = ' ';
++ continue;
++ }
++ if (c != '%') {
++ *dst++ = c;
++ continue;
++ }
++ v = hex_to_bin(src[0]);
++ if (v > 15) {
++ bad_hex:
++ if (strict)
++ return NULL;
++ *dst++ = '%';
++ continue;
++ }
++ v = (v * 16) | hex_to_bin(src[1]);
++ if (v > 255)
++ goto bad_hex;
++ if (strict && (v == '/' || v == '\0')) {
++ /* caller takes it as indication of invalid
++ * (dangerous wrt exploits) chars */
++ return str + 1;
++ }
++ *dst++ = v;
++ src += 2;
++ }
++ *dst = '\0';
++ return str;
++}
+--- a/networking/httpd.c
++++ b/networking/httpd.c
+@@ -820,78 +820,6 @@ static char *encodeString(const char *st
+ }
+ #endif
+
+-/*
+- * Given a URL encoded string, convert it to plain ascii.
+- * Since decoding always makes strings smaller, the decode is done in-place.
+- * Thus, callers should xstrdup() the argument if they do not want the
+- * argument modified. The return is the original pointer, allowing this
+- * function to be easily used as arguments to other functions.
+- *
+- * string The first string to decode.
+- * option_d 1 if called for httpd -d
+- *
+- * Returns a pointer to the decoded string (same as input).
+- */
+-static unsigned hex_to_bin(unsigned char c)
+-{
+- unsigned v;
+-
+- v = c - '0';
+- if (v <= 9)
+- return v;
+- /* c | 0x20: letters to lower case, non-letters
+- * to (potentially different) non-letters */
+- v = (unsigned)(c | 0x20) - 'a';
+- if (v <= 5)
+- return v + 10;
+- return ~0;
+-/* For testing:
+-void t(char c) { printf("'%c'(%u) %u\n", c, c, hex_to_bin(c)); }
+-int main() { t(0x10); t(0x20); t('0'); t('9'); t('A'); t('F'); t('a'); t('f');
+-t('0'-1); t('9'+1); t('A'-1); t('F'+1); t('a'-1); t('f'+1); return 0; }
+-*/
+-}
+-static char *decodeString(char *orig, int option_d)
+-{
+- /* note that decoded string is always shorter than original */
+- char *string = orig;
+- char *ptr = string;
+- char c;
+-
+- while ((c = *ptr++) != '\0') {
+- unsigned v;
+-
+- if (option_d && c == '+') {
+- *string++ = ' ';
+- continue;
+- }
+- if (c != '%') {
+- *string++ = c;
+- continue;
+- }
+- v = hex_to_bin(ptr[0]);
+- if (v > 15) {
+- bad_hex:
+- if (!option_d)
+- return NULL;
+- *string++ = '%';
+- continue;
+- }
+- v = (v * 16) | hex_to_bin(ptr[1]);
+- if (v > 255)
+- goto bad_hex;
+- if (!option_d && (v == '/' || v == '\0')) {
+- /* caller takes it as indication of invalid
+- * (dangerous wrt exploits) chars */
+- return orig + 1;
+- }
+- *string++ = v;
+- ptr += 2;
+- }
+- *string = '\0';
+- return orig;
+-}
+-
+ #if ENABLE_FEATURE_HTTPD_BASIC_AUTH
+ /*
+ * Decode a base64 data stream as per rfc1521.
+@@ -1949,7 +1877,7 @@ static void handle_incoming_and_exit(con
+ }
+
+ /* Decode URL escape sequences */
+- tptr = decodeString(urlcopy, 0);
++ tptr = percent_decode_in_place(urlcopy, /*strict:*/ 1);
+ if (tptr == NULL)
+ send_headers_and_exit(HTTP_BAD_REQUEST);
+ if (tptr == urlcopy + 1) {
+@@ -2408,7 +2336,7 @@ int httpd_main(int argc UNUSED_PARAM, ch
+ , &verbose
+ );
+ if (opt & OPT_DECODE_URL) {
+- fputs(decodeString(url_for_decode, 1), stdout);
++ fputs(percent_decode_in_place(url_for_decode, /*strict:*/ 0), stdout);
+ return 0;
+ }
+ #if ENABLE_FEATURE_HTTPD_ENCODE_URL_STR
+--- a/networking/wget.c
++++ b/networking/wget.c
+@@ -298,8 +298,13 @@ static void parse_url(const char *src_ur
+
+ sp = strrchr(h->host, '@');
+ if (sp != NULL) {
+- h->user = h->host;
++ // URL-decode "user:password" string before base64-encoding:
++ // wget http://test:my%20pass@example.com should send
++ // Authorization: Basic dGVzdDpteSBwYXNz
++ // which decodes to "test:my pass".
++ // Standard wget and curl do this too.
+ *sp = '\0';
++ h->user = percent_decode_in_place(h->host, /*strict:*/ 0);
+ h->host = sp + 1;
+ }
+
+@@ -661,12 +666,6 @@ static void download_one_url(const char
+
+ #if ENABLE_FEATURE_WGET_AUTHENTICATION
+ if (target.user) {
+-//TODO: URL-decode "user:password" string before base64-encoding:
+-//wget http://test:my%20pass@example.com should send
+-// Authorization: Basic dGVzdDpteSBwYXNz
+-//which decodes to "test:my pass", instead of what we send now:
+-// Authorization: Basic dGVzdDpteSUyMHBhc3M=
+-//Can reuse decodeString() from httpd.c
+ fprintf(sfp, "Proxy-Authorization: Basic %s\r\n"+6,
+ base64enc(target.user));
+ }
diff --git a/package/busybox/patches/005-resource_h_include.patch b/package/busybox/patches/005-resource_h_include.patch
new file mode 100644
index 0000000..d66d66d
--- /dev/null
+++ b/package/busybox/patches/005-resource_h_include.patch
@@ -0,0 +1,10 @@
+--- a/include/libbb.h
++++ b/include/libbb.h
+@@ -35,6 +35,7 @@
+ #include <sys/poll.h>
+ #include <sys/ioctl.h>
+ #include <sys/mman.h>
++#include <sys/resource.h>
+ #include <sys/socket.h>
+ #include <sys/stat.h>
+ #include <sys/time.h>
diff --git a/package/busybox/patches/006-upstream_CVE-2011-2716_fixes.patch b/package/busybox/patches/006-upstream_CVE-2011-2716_fixes.patch
new file mode 100644
index 0000000..532fcee
--- /dev/null
+++ b/package/busybox/patches/006-upstream_CVE-2011-2716_fixes.patch
@@ -0,0 +1,164 @@
+--- a/networking/udhcp/common.c
++++ b/networking/udhcp/common.c
+@@ -29,16 +29,16 @@ const struct dhcp_optflag dhcp_optflags[
+ // { OPTION_IP | OPTION_LIST , 0x07 }, /* DHCP_LOG_SERVER */
+ // { OPTION_IP | OPTION_LIST , 0x08 }, /* DHCP_COOKIE_SERVER */
+ { OPTION_IP | OPTION_LIST , 0x09 }, /* DHCP_LPR_SERVER */
+- { OPTION_STRING | OPTION_REQ, 0x0c }, /* DHCP_HOST_NAME */
++ { OPTION_STRING_HOST | OPTION_REQ, 0x0c }, /* DHCP_HOST_NAME */
+ { OPTION_U16 , 0x0d }, /* DHCP_BOOT_SIZE */
+- { OPTION_STRING | OPTION_REQ, 0x0f }, /* DHCP_DOMAIN_NAME */
++ { OPTION_STRING_HOST | OPTION_REQ, 0x0f }, /* DHCP_DOMAIN_NAME */
+ { OPTION_IP , 0x10 }, /* DHCP_SWAP_SERVER */
+ { OPTION_STRING , 0x11 }, /* DHCP_ROOT_PATH */
+ { OPTION_U8 , 0x17 }, /* DHCP_IP_TTL */
+ { OPTION_U16 , 0x1a }, /* DHCP_MTU */
+ { OPTION_IP | OPTION_REQ, 0x1c }, /* DHCP_BROADCAST */
+ { OPTION_IP_PAIR | OPTION_LIST , 0x21 }, /* DHCP_ROUTES */
+- { OPTION_STRING , 0x28 }, /* DHCP_NIS_DOMAIN */
++ { OPTION_STRING_HOST , 0x28 }, /* DHCP_NIS_DOMAIN */
+ { OPTION_IP | OPTION_LIST , 0x29 }, /* DHCP_NIS_SERVER */
+ { OPTION_IP | OPTION_LIST | OPTION_REQ, 0x2a }, /* DHCP_NTP_SERVER */
+ { OPTION_IP | OPTION_LIST , 0x2c }, /* DHCP_WINS_SERVER */
+@@ -46,7 +46,7 @@ const struct dhcp_optflag dhcp_optflags[
+ { OPTION_IP , 0x36 }, /* DHCP_SERVER_ID */
+ { OPTION_STRING , 0x38 }, /* DHCP_ERR_MESSAGE */
+ //TODO: must be combined with 'sname' and 'file' handling:
+- { OPTION_STRING , 0x42 }, /* DHCP_TFTP_SERVER_NAME */
++ { OPTION_STRING_HOST , 0x42 }, /* DHCP_TFTP_SERVER_NAME */
+ { OPTION_STRING , 0x43 }, /* DHCP_BOOT_FILE */
+ //TODO: not a string, but a set of LASCII strings:
+ // { OPTION_STRING , 0x4D }, /* DHCP_USER_CLASS */
+@@ -143,6 +143,7 @@ const uint8_t dhcp_option_lengths[] ALIG
+ [OPTION_IP_PAIR] = 8,
+ // [OPTION_BOOLEAN] = 1,
+ [OPTION_STRING] = 1, /* ignored by udhcp_str2optset */
++ [OPTION_STRING_HOST] = 1, /* ignored by udhcp_str2optset */
+ #if ENABLE_FEATURE_UDHCP_RFC3397
+ [OPTION_DNS_STRING] = 1, /* ignored by both udhcp_str2optset and xmalloc_optname_optval */
+ [OPTION_SIP_SERVERS] = 1,
+@@ -411,7 +412,9 @@ static NOINLINE void attach_option(
+ /* actually 255 is ok too, but adding a space can overlow it */
+
+ existing->data = xrealloc(existing->data, OPT_DATA + 1 + old_len + length);
+- if ((optflag->flags & OPTION_TYPE_MASK) == OPTION_STRING) {
++ if ((optflag->flags & OPTION_TYPE_MASK) == OPTION_STRING
++ || (optflag->flags & OPTION_TYPE_MASK) == OPTION_STRING_HOST
++ ) {
+ /* add space separator between STRING options in a list */
+ existing->data[OPT_DATA + old_len] = ' ';
+ old_len++;
+@@ -475,6 +478,7 @@ int FAST_FUNC udhcp_str2optset(const cha
+ retval = udhcp_str2nip(val, buffer + 4);
+ break;
+ case OPTION_STRING:
++ case OPTION_STRING_HOST:
+ #if ENABLE_FEATURE_UDHCP_RFC3397
+ case OPTION_DNS_STRING:
+ #endif
+--- a/networking/udhcp/common.h
++++ b/networking/udhcp/common.h
+@@ -80,6 +80,9 @@ enum {
+ OPTION_IP = 1,
+ OPTION_IP_PAIR,
+ OPTION_STRING,
++ /* Opts of STRING_HOST type will be sanitized before they are passed
++ * to udhcpc script's environment: */
++ OPTION_STRING_HOST,
+ // OPTION_BOOLEAN,
+ OPTION_U8,
+ OPTION_U16,
+--- a/networking/udhcp/dhcpc.c
++++ b/networking/udhcp/dhcpc.c
+@@ -101,6 +101,7 @@ static const uint8_t len_of_option_as_st
+ [OPTION_IP_PAIR ] = sizeof("255.255.255.255 ") * 2,
+ [OPTION_STATIC_ROUTES ] = sizeof("255.255.255.255/32 255.255.255.255 "),
+ [OPTION_STRING ] = 1,
++ [OPTION_STRING_HOST ] = 1,
+ #if ENABLE_FEATURE_UDHCP_RFC3397
+ [OPTION_DNS_STRING ] = 1, /* unused */
+ /* Hmmm, this severely overestimates size if SIP_SERVERS option
+@@ -135,6 +136,63 @@ static int mton(uint32_t mask)
+ return i;
+ }
+
++/* Check if a given label represents a valid DNS label
++ * Return pointer to the first character after the label upon success,
++ * NULL otherwise.
++ * See RFC1035, 2.3.1
++ */
++/* We don't need to be particularly anal. For example, allowing _, hyphen
++ * at the end, or leading and trailing dots would be ok, since it
++ * can't be used for attacks. (Leading hyphen can be, if someone uses
++ * cmd "$hostname"
++ * in the script: then hostname may be treated as an option)
++ */
++static const char *valid_domain_label(const char *label)
++{
++ unsigned char ch;
++ unsigned pos = 0;
++
++ for (;;) {
++ ch = *label;
++ if ((ch|0x20) < 'a' || (ch|0x20) > 'z') {
++ if (pos == 0) {
++ /* label must begin with letter */
++ return NULL;
++ }
++ if (ch < '0' || ch > '9') {
++ if (ch == '\0' || ch == '.')
++ return label;
++ /* DNS allows only '-', but we are more permissive */
++ if (ch != '-' && ch != '_')
++ return NULL;
++ }
++ }
++ label++;
++ pos++;
++ //Do we want this?
++ //if (pos > 63) /* NS_MAXLABEL; labels must be 63 chars or less */
++ // return NULL;
++ }
++}
++
++/* Check if a given name represents a valid DNS name */
++/* See RFC1035, 2.3.1 */
++static int good_hostname(const char *name)
++{
++ //const char *start = name;
++
++ for (;;) {
++ name = valid_domain_label(name);
++ if (!name)
++ return 0;
++ if (!name[0])
++ return 1;
++ //Do we want this?
++ //return ((name - start) < 1025); /* NS_MAXDNAME */
++ name++;
++ }
++}
++
+ /* Create "opt_name=opt_value" string */
+ static NOINLINE char *xmalloc_optname_optval(uint8_t *option, const struct dhcp_optflag *optflag, const char *opt_name)
+ {
+@@ -185,8 +243,11 @@ static NOINLINE char *xmalloc_optname_op
+ break;
+ }
+ case OPTION_STRING:
++ case OPTION_STRING_HOST:
+ memcpy(dest, option, len);
+ dest[len] = '\0';
++ if (type == OPTION_STRING_HOST && !good_hostname(dest))
++ safe_strncpy(dest, "bad", len);
+ return ret; /* Short circuit this case */
+ case OPTION_STATIC_ROUTES: {
+ /* Option binary format:
+@@ -314,6 +375,7 @@ static char **fill_envp(struct dhcp_pack
+ /* +1 element for each option, +2 for subnet option: */
+ if (packet) {
+ /* note: do not search for "pad" (0) and "end" (255) options */
++//TODO: change logic to scan packet _once_
+ for (i = 1; i < 255; i++) {
+ temp = udhcp_get_option(packet, i);
+ if (temp) {
diff --git a/package/busybox/patches/007-upstream_mkfs_ext2_fixes.patch b/package/busybox/patches/007-upstream_mkfs_ext2_fixes.patch
new file mode 100644
index 0000000..8528ee8
--- /dev/null
+++ b/package/busybox/patches/007-upstream_mkfs_ext2_fixes.patch
@@ -0,0 +1,1441 @@
+--- a/e2fsprogs/e2fs_defs.h
++++ /dev/null
+@@ -1,561 +0,0 @@
+-/* vi: set sw=4 ts=4: */
+-/*
+- * linux/include/linux/ext2_fs.h
+- *
+- * Copyright (C) 1992, 1993, 1994, 1995
+- * Remy Card (card@masi.ibp.fr)
+- * Laboratoire MASI - Institut Blaise Pascal
+- * Universite Pierre et Marie Curie (Paris VI)
+- *
+- * Copyright (C) 1991, 1992 Linus Torvalds
+- */
+-
+-#ifndef LINUX_EXT2_FS_H
+-#define LINUX_EXT2_FS_H 1
+-
+-/*
+- * Special inode numbers
+- */
+-#define EXT2_BAD_INO 1 /* Bad blocks inode */
+-#define EXT2_ROOT_INO 2 /* Root inode */
+-#define EXT2_ACL_IDX_INO 3 /* ACL inode */
+-#define EXT2_ACL_DATA_INO 4 /* ACL inode */
+-#define EXT2_BOOT_LOADER_INO 5 /* Boot loader inode */
+-#define EXT2_UNDEL_DIR_INO 6 /* Undelete directory inode */
+-#define EXT2_RESIZE_INO 7 /* Reserved group descriptors inode */
+-#define EXT2_JOURNAL_INO 8 /* Journal inode */
+-
+-/* First non-reserved inode for old ext2 filesystems */
+-#define EXT2_GOOD_OLD_FIRST_INO 11
+-
+-/*
+- * The second extended file system magic number
+- */
+-#define EXT2_SUPER_MAGIC 0xEF53
+-
+-/* Assume that user mode programs are passing in an ext2fs superblock, not
+- * a kernel struct super_block. This will allow us to call the feature-test
+- * macros from user land. */
+-#define EXT2_SB(sb) (sb)
+-
+-/*
+- * Maximal count of links to a file
+- */
+-#define EXT2_LINK_MAX 32000
+-
+-/*
+- * Macro-instructions used to manage several block sizes
+- */
+-#define EXT2_MIN_BLOCK_LOG_SIZE 10 /* 1024 */
+-#define EXT2_MAX_BLOCK_LOG_SIZE 16 /* 65536 */
+-#define EXT2_MIN_BLOCK_SIZE (1 << EXT2_MIN_BLOCK_LOG_SIZE)
+-#define EXT2_MAX_BLOCK_SIZE (1 << EXT2_MAX_BLOCK_LOG_SIZE)
+-#define EXT2_BLOCK_SIZE(s) (EXT2_MIN_BLOCK_SIZE << (s)->s_log_block_size)
+-#define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10)
+-#define EXT2_INODE_SIZE(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \
+- EXT2_GOOD_OLD_INODE_SIZE : (s)->s_inode_size)
+-#define EXT2_FIRST_INO(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \
+- EXT2_GOOD_OLD_FIRST_INO : (s)->s_first_ino)
+-#define EXT2_ADDR_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof(uint32_t))
+-
+-/*
+- * Macro-instructions used to manage fragments
+- */
+-#define EXT2_MIN_FRAG_SIZE EXT2_MIN_BLOCK_SIZE
+-#define EXT2_MAX_FRAG_SIZE EXT2_MAX_BLOCK_SIZE
+-#define EXT2_MIN_FRAG_LOG_SIZE EXT2_MIN_BLOCK_LOG_SIZE
+-#define EXT2_FRAG_SIZE(s) (EXT2_MIN_FRAG_SIZE << (s)->s_log_frag_size)
+-#define EXT2_FRAGS_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / EXT2_FRAG_SIZE(s))
+-
+-/*
+- * ACL structures
+- */
+-struct ext2_acl_header { /* Header of Access Control Lists */
+- uint32_t aclh_size;
+- uint32_t aclh_file_count;
+- uint32_t aclh_acle_count;
+- uint32_t aclh_first_acle;
+-};
+-
+-struct ext2_acl_entry { /* Access Control List Entry */
+- uint32_t acle_size;
+- uint16_t acle_perms; /* Access permissions */
+- uint16_t acle_type; /* Type of entry */
+- uint16_t acle_tag; /* User or group identity */
+- uint16_t acle_pad1;
+- uint32_t acle_next; /* Pointer on next entry for the */
+- /* same inode or on next free entry */
+-};
+-
+-/*
+- * Structure of a blocks group descriptor
+- */
+-struct ext2_group_desc {
+- uint32_t bg_block_bitmap; /* Blocks bitmap block */
+- uint32_t bg_inode_bitmap; /* Inodes bitmap block */
+- uint32_t bg_inode_table; /* Inodes table block */
+- uint16_t bg_free_blocks_count; /* Free blocks count */
+- uint16_t bg_free_inodes_count; /* Free inodes count */
+- uint16_t bg_used_dirs_count; /* Directories count */
+- uint16_t bg_pad;
+- uint32_t bg_reserved[3];
+-};
+-
+-/*
+- * Data structures used by the directory indexing feature
+- *
+- * Note: all of the multibyte integer fields are little endian.
+- */
+-
+-/*
+- * Note: dx_root_info is laid out so that if it should somehow get
+- * overlaid by a dirent the two low bits of the hash version will be
+- * zero. Therefore, the hash version mod 4 should never be 0.
+- * Sincerely, the paranoia department.
+- */
+-struct ext2_dx_root_info {
+- uint32_t reserved_zero;
+- uint8_t hash_version; /* 0 now, 1 at release */
+- uint8_t info_length; /* 8 */
+- uint8_t indirect_levels;
+- uint8_t unused_flags;
+-};
+-
+-#define EXT2_HASH_LEGACY 0
+-#define EXT2_HASH_HALF_MD4 1
+-#define EXT2_HASH_TEA 2
+-
+-#define EXT2_HASH_FLAG_INCOMPAT 0x1
+-
+-struct ext2_dx_entry {
+- uint32_t hash;
+- uint32_t block;
+-};
+-
+-struct ext2_dx_countlimit {
+- uint16_t limit;
+- uint16_t count;
+-};
+-
+-
+-/*
+- * Macro-instructions used to manage group descriptors
+- */
+-#define EXT2_BLOCKS_PER_GROUP(s) (EXT2_SB(s)->s_blocks_per_group)
+-#define EXT2_INODES_PER_GROUP(s) (EXT2_SB(s)->s_inodes_per_group)
+-#define EXT2_INODES_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s)/EXT2_INODE_SIZE(s))
+-/* limits imposed by 16-bit value gd_free_{blocks,inode}_count */
+-#define EXT2_MAX_BLOCKS_PER_GROUP(s) ((1 << 16) - 8)
+-#define EXT2_MAX_INODES_PER_GROUP(s) ((1 << 16) - EXT2_INODES_PER_BLOCK(s))
+-#define EXT2_DESC_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_group_desc))
+-
+-/*
+- * Constants relative to the data blocks
+- */
+-#define EXT2_NDIR_BLOCKS 12
+-#define EXT2_IND_BLOCK EXT2_NDIR_BLOCKS
+-#define EXT2_DIND_BLOCK (EXT2_IND_BLOCK + 1)
+-#define EXT2_TIND_BLOCK (EXT2_DIND_BLOCK + 1)
+-#define EXT2_N_BLOCKS (EXT2_TIND_BLOCK + 1)
+-
+-/*
+- * Inode flags
+- */
+-#define EXT2_SECRM_FL 0x00000001 /* Secure deletion */
+-#define EXT2_UNRM_FL 0x00000002 /* Undelete */
+-#define EXT2_COMPR_FL 0x00000004 /* Compress file */
+-#define EXT2_SYNC_FL 0x00000008 /* Synchronous updates */
+-#define EXT2_IMMUTABLE_FL 0x00000010 /* Immutable file */
+-#define EXT2_APPEND_FL 0x00000020 /* writes to file may only append */
+-#define EXT2_NODUMP_FL 0x00000040 /* do not dump file */
+-#define EXT2_NOATIME_FL 0x00000080 /* do not update atime */
+-/* Reserved for compression usage... */
+-#define EXT2_DIRTY_FL 0x00000100
+-#define EXT2_COMPRBLK_FL 0x00000200 /* One or more compressed clusters */
+-#define EXT2_NOCOMPR_FL 0x00000400 /* Access raw compressed data */
+-#define EXT2_ECOMPR_FL 0x00000800 /* Compression error */
+-/* End compression flags --- maybe not all used */
+-#define EXT2_BTREE_FL 0x00001000 /* btree format dir */
+-#define EXT2_INDEX_FL 0x00001000 /* hash-indexed directory */
+-#define EXT2_IMAGIC_FL 0x00002000
+-#define EXT3_JOURNAL_DATA_FL 0x00004000 /* file data should be journaled */
+-#define EXT2_NOTAIL_FL 0x00008000 /* file tail should not be merged */
+-#define EXT2_DIRSYNC_FL 0x00010000 /* Synchronous directory modifications */
+-#define EXT2_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
+-#define EXT3_EXTENTS_FL 0x00080000 /* Inode uses extents */
+-#define EXT2_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
+-
+-#define EXT2_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
+-#define EXT2_FL_USER_MODIFIABLE 0x000080FF /* User modifiable flags */
+-
+-/*
+- * ioctl commands
+- */
+-#define EXT2_IOC_GETFLAGS _IOR('f', 1, long)
+-#define EXT2_IOC_SETFLAGS _IOW('f', 2, long)
+-#define EXT2_IOC_GETVERSION _IOR('v', 1, long)
+-#define EXT2_IOC_SETVERSION _IOW('v', 2, long)
+-
+-/*
+- * Structure of an inode on the disk
+- */
+-struct ext2_inode {
+- uint16_t i_mode; /* File mode */
+- uint16_t i_uid; /* Low 16 bits of Owner Uid */
+- uint32_t i_size; /* Size in bytes */
+- uint32_t i_atime; /* Access time */
+- uint32_t i_ctime; /* Creation time */
+- uint32_t i_mtime; /* Modification time */
+- uint32_t i_dtime; /* Deletion Time */
+- uint16_t i_gid; /* Low 16 bits of Group Id */
+- uint16_t i_links_count; /* Links count */
+- uint32_t i_blocks; /* Blocks count */
+- uint32_t i_flags; /* File flags */
+- union {
+- struct {
+- uint32_t l_i_reserved1;
+- } linux1;
+- struct {
+- uint32_t h_i_translator;
+- } hurd1;
+- struct {
+- uint32_t m_i_reserved1;
+- } masix1;
+- } osd1; /* OS dependent 1 */
+- uint32_t i_block[EXT2_N_BLOCKS];/* Pointers to blocks */
+- uint32_t i_generation; /* File version (for NFS) */
+- uint32_t i_file_acl; /* File ACL */
+- uint32_t i_dir_acl; /* Directory ACL */
+- uint32_t i_faddr; /* Fragment address */
+- union {
+- struct {
+- uint8_t l_i_frag; /* Fragment number */
+- uint8_t l_i_fsize; /* Fragment size */
+- uint16_t i_pad1;
+- uint16_t l_i_uid_high; /* these 2 fields */
+- uint16_t l_i_gid_high; /* were reserved2[0] */
+- uint32_t l_i_reserved2;
+- } linux2;
+- struct {
+- uint8_t h_i_frag; /* Fragment number */
+- uint8_t h_i_fsize; /* Fragment size */
+- uint16_t h_i_mode_high;
+- uint16_t h_i_uid_high;
+- uint16_t h_i_gid_high;
+- uint32_t h_i_author;
+- } hurd2;
+- struct {
+- uint8_t m_i_frag; /* Fragment number */
+- uint8_t m_i_fsize; /* Fragment size */
+- uint16_t m_pad1;
+- uint32_t m_i_reserved2[2];
+- } masix2;
+- } osd2; /* OS dependent 2 */
+-};
+-
+-/*
+- * Permanent part of an large inode on the disk
+- */
+-struct ext2_inode_large {
+- uint16_t i_mode; /* File mode */
+- uint16_t i_uid; /* Low 16 bits of Owner Uid */
+- uint32_t i_size; /* Size in bytes */
+- uint32_t i_atime; /* Access time */
+- uint32_t i_ctime; /* Creation time */
+- uint32_t i_mtime; /* Modification time */
+- uint32_t i_dtime; /* Deletion Time */
+- uint16_t i_gid; /* Low 16 bits of Group Id */
+- uint16_t i_links_count; /* Links count */
+- uint32_t i_blocks; /* Blocks count */
+- uint32_t i_flags; /* File flags */
+- union {
+- struct {
+- uint32_t l_i_reserved1;
+- } linux1;
+- struct {
+- uint32_t h_i_translator;
+- } hurd1;
+- struct {
+- uint32_t m_i_reserved1;
+- } masix1;
+- } osd1; /* OS dependent 1 */
+- uint32_t i_block[EXT2_N_BLOCKS];/* Pointers to blocks */
+- uint32_t i_generation; /* File version (for NFS) */
+- uint32_t i_file_acl; /* File ACL */
+- uint32_t i_dir_acl; /* Directory ACL */
+- uint32_t i_faddr; /* Fragment address */
+- union {
+- struct {
+- uint8_t l_i_frag; /* Fragment number */
+- uint8_t l_i_fsize; /* Fragment size */
+- uint16_t i_pad1;
+- uint16_t l_i_uid_high; /* these 2 fields */
+- uint16_t l_i_gid_high; /* were reserved2[0] */
+- uint32_t l_i_reserved2;
+- } linux2;
+- struct {
+- uint8_t h_i_frag; /* Fragment number */
+- uint8_t h_i_fsize; /* Fragment size */
+- uint16_t h_i_mode_high;
+- uint16_t h_i_uid_high;
+- uint16_t h_i_gid_high;
+- uint32_t h_i_author;
+- } hurd2;
+- struct {
+- uint8_t m_i_frag; /* Fragment number */
+- uint8_t m_i_fsize; /* Fragment size */
+- uint16_t m_pad1;
+- uint32_t m_i_reserved2[2];
+- } masix2;
+- } osd2; /* OS dependent 2 */
+- uint16_t i_extra_isize;
+- uint16_t i_pad1;
+-};
+-
+-#define i_size_high i_dir_acl
+-
+-/*
+- * File system states
+- */
+-#define EXT2_VALID_FS 0x0001 /* Unmounted cleanly */
+-#define EXT2_ERROR_FS 0x0002 /* Errors detected */
+-
+-/*
+- * Mount flags
+- */
+-#define EXT2_MOUNT_CHECK 0x0001 /* Do mount-time checks */
+-#define EXT2_MOUNT_GRPID 0x0004 /* Create files with directory's group */
+-#define EXT2_MOUNT_DEBUG 0x0008 /* Some debugging messages */
+-#define EXT2_MOUNT_ERRORS_CONT 0x0010 /* Continue on errors */
+-#define EXT2_MOUNT_ERRORS_RO 0x0020 /* Remount fs ro on errors */
+-#define EXT2_MOUNT_ERRORS_PANIC 0x0040 /* Panic on errors */
+-#define EXT2_MOUNT_MINIX_DF 0x0080 /* Mimics the Minix statfs */
+-#define EXT2_MOUNT_NO_UID32 0x0200 /* Disable 32-bit UIDs */
+-
+-#define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
+-#define set_opt(o, opt) o |= EXT2_MOUNT_##opt
+-#define test_opt(sb, opt) (EXT2_SB(sb)->s_mount_opt & \
+- EXT2_MOUNT_##opt)
+-/*
+- * Maximal mount counts between two filesystem checks
+- */
+-#define EXT2_DFL_MAX_MNT_COUNT 20 /* Allow 20 mounts */
+-#define EXT2_DFL_CHECKINTERVAL 0 /* Don't use interval check */
+-
+-/*
+- * Behaviour when detecting errors
+- */
+-#define EXT2_ERRORS_CONTINUE 1 /* Continue execution */
+-#define EXT2_ERRORS_RO 2 /* Remount fs read-only */
+-#define EXT2_ERRORS_PANIC 3 /* Panic */
+-#define EXT2_ERRORS_DEFAULT EXT2_ERRORS_CONTINUE
+-
+-/*
+- * Structure of the super block
+- */
+-struct ext2_super_block {
+- uint32_t s_inodes_count; /* Inodes count */
+- uint32_t s_blocks_count; /* Blocks count */
+- uint32_t s_r_blocks_count; /* Reserved blocks count */
+- uint32_t s_free_blocks_count; /* Free blocks count */
+- uint32_t s_free_inodes_count; /* Free inodes count */
+- uint32_t s_first_data_block; /* First Data Block */
+- uint32_t s_log_block_size; /* Block size */
+- int32_t s_log_frag_size; /* Fragment size */
+- uint32_t s_blocks_per_group; /* # Blocks per group */
+- uint32_t s_frags_per_group; /* # Fragments per group */
+- uint32_t s_inodes_per_group; /* # Inodes per group */
+- uint32_t s_mtime; /* Mount time */
+- uint32_t s_wtime; /* Write time */
+- uint16_t s_mnt_count; /* Mount count */
+- int16_t s_max_mnt_count; /* Maximal mount count */
+- uint16_t s_magic; /* Magic signature */
+- uint16_t s_state; /* File system state */
+- uint16_t s_errors; /* Behaviour when detecting errors */
+- uint16_t s_minor_rev_level; /* minor revision level */
+- uint32_t s_lastcheck; /* time of last check */
+- uint32_t s_checkinterval; /* max. time between checks */
+- uint32_t s_creator_os; /* OS */
+- uint32_t s_rev_level; /* Revision level */
+- uint16_t s_def_resuid; /* Default uid for reserved blocks */
+- uint16_t s_def_resgid; /* Default gid for reserved blocks */
+- /*
+- * These fields are for EXT2_DYNAMIC_REV superblocks only.
+- *
+- * Note: the difference between the compatible feature set and
+- * the incompatible feature set is that if there is a bit set
+- * in the incompatible feature set that the kernel doesn't
+- * know about, it should refuse to mount the filesystem.
+- *
+- * e2fsck's requirements are more strict; if it doesn't know
+- * about a feature in either the compatible or incompatible
+- * feature set, it must abort and not try to meddle with
+- * things it doesn't understand...
+- */
+- uint32_t s_first_ino; /* First non-reserved inode */
+- uint16_t s_inode_size; /* size of inode structure */
+- uint16_t s_block_group_nr; /* block group # of this superblock */
+- uint32_t s_feature_compat; /* compatible feature set */
+- uint32_t s_feature_incompat; /* incompatible feature set */
+- uint32_t s_feature_ro_compat; /* readonly-compatible feature set */
+- uint8_t s_uuid[16]; /* 128-bit uuid for volume */
+- char s_volume_name[16]; /* volume name */
+- char s_last_mounted[64]; /* directory where last mounted */
+- uint32_t s_algorithm_usage_bitmap; /* For compression */
+- /*
+- * Performance hints. Directory preallocation should only
+- * happen if the EXT2_FEATURE_COMPAT_DIR_PREALLOC flag is on.
+- */
+- uint8_t s_prealloc_blocks; /* Nr of blocks to try to preallocate*/
+- uint8_t s_prealloc_dir_blocks; /* Nr to preallocate for dirs */
+- uint16_t s_reserved_gdt_blocks; /* Per group table for online growth */
+- /*
+- * Journaling support valid if EXT2_FEATURE_COMPAT_HAS_JOURNAL set.
+- */
+- uint8_t s_journal_uuid[16]; /* uuid of journal superblock */
+- uint32_t s_journal_inum; /* inode number of journal file */
+- uint32_t s_journal_dev; /* device number of journal file */
+- uint32_t s_last_orphan; /* start of list of inodes to delete */
+- uint32_t s_hash_seed[4]; /* HTREE hash seed */
+- uint8_t s_def_hash_version; /* Default hash version to use */
+- uint8_t s_jnl_backup_type; /* Default type of journal backup */
+- uint16_t s_reserved_word_pad;
+- uint32_t s_default_mount_opts;
+- uint32_t s_first_meta_bg; /* First metablock group */
+- uint32_t s_mkfs_time; /* When the filesystem was created */
+- uint32_t s_jnl_blocks[17]; /* Backup of the journal inode */
+- uint32_t s_reserved[172]; /* Padding to the end of the block */
+-};
+-
+-/*
+- * Codes for operating systems
+- */
+-#define EXT2_OS_LINUX 0
+-#define EXT2_OS_HURD 1
+-#define EXT2_OS_MASIX 2
+-#define EXT2_OS_FREEBSD 3
+-#define EXT2_OS_LITES 4
+-
+-/*
+- * Revision levels
+- */
+-#define EXT2_GOOD_OLD_REV 0 /* The good old (original) format */
+-#define EXT2_DYNAMIC_REV 1 /* V2 format w/ dynamic inode sizes */
+-
+-#define EXT2_CURRENT_REV EXT2_GOOD_OLD_REV
+-#define EXT2_MAX_SUPP_REV EXT2_DYNAMIC_REV
+-
+-#define EXT2_GOOD_OLD_INODE_SIZE 128
+-
+-/*
+- * Journal inode backup types
+- */
+-#define EXT3_JNL_BACKUP_BLOCKS 1
+-
+-/*
+- * Feature set definitions
+- */
+-
+-#define EXT2_HAS_COMPAT_FEATURE(sb,mask) \
+- ( EXT2_SB(sb)->s_feature_compat & (mask) )
+-#define EXT2_HAS_RO_COMPAT_FEATURE(sb,mask) \
+- ( EXT2_SB(sb)->s_feature_ro_compat & (mask) )
+-#define EXT2_HAS_INCOMPAT_FEATURE(sb,mask) \
+- ( EXT2_SB(sb)->s_feature_incompat & (mask) )
+-
+-#define EXT2_FEATURE_COMPAT_DIR_PREALLOC 0x0001
+-#define EXT2_FEATURE_COMPAT_IMAGIC_INODES 0x0002
+-#define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x0004
+-#define EXT2_FEATURE_COMPAT_EXT_ATTR 0x0008
+-#define EXT2_FEATURE_COMPAT_RESIZE_INODE 0x0010
+-#define EXT2_FEATURE_COMPAT_DIR_INDEX 0x0020
+-
+-#define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001
+-#define EXT2_FEATURE_RO_COMPAT_LARGE_FILE 0x0002
+-/* #define EXT2_FEATURE_RO_COMPAT_BTREE_DIR 0x0004 not used */
+-
+-#define EXT2_FEATURE_INCOMPAT_COMPRESSION 0x0001
+-#define EXT2_FEATURE_INCOMPAT_FILETYPE 0x0002
+-#define EXT3_FEATURE_INCOMPAT_RECOVER 0x0004 /* Needs recovery */
+-#define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008 /* Journal device */
+-#define EXT2_FEATURE_INCOMPAT_META_BG 0x0010
+-#define EXT3_FEATURE_INCOMPAT_EXTENTS 0x0040
+-
+-
+-#define EXT2_FEATURE_COMPAT_SUPP 0
+-#define EXT2_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE)
+-#define EXT2_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \
+- EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \
+- EXT2_FEATURE_RO_COMPAT_BTREE_DIR)
+-
+-/*
+- * Default values for user and/or group using reserved blocks
+- */
+-#define EXT2_DEF_RESUID 0
+-#define EXT2_DEF_RESGID 0
+-
+-/*
+- * Default mount options
+- */
+-#define EXT2_DEFM_DEBUG 0x0001
+-#define EXT2_DEFM_BSDGROUPS 0x0002
+-#define EXT2_DEFM_XATTR_USER 0x0004
+-#define EXT2_DEFM_ACL 0x0008
+-#define EXT2_DEFM_UID16 0x0010
+-#define EXT3_DEFM_JMODE 0x0060
+-#define EXT3_DEFM_JMODE_DATA 0x0020
+-#define EXT3_DEFM_JMODE_ORDERED 0x0040
+-#define EXT3_DEFM_JMODE_WBACK 0x0060
+-
+-/*
+- * Structure of a directory entry
+- */
+-#define EXT2_NAME_LEN 255
+-
+-struct ext2_dir_entry {
+- uint32_t inode; /* Inode number */
+- uint16_t rec_len; /* Directory entry length */
+- uint16_t name_len; /* Name length */
+- char name[EXT2_NAME_LEN]; /* File name */
+-};
+-
+-/*
+- * The new version of the directory entry. Since EXT2 structures are
+- * stored in intel byte order, and the name_len field could never be
+- * bigger than 255 chars, it's safe to reclaim the extra byte for the
+- * file_type field.
+- */
+-struct ext2_dir_entry_2 {
+- uint32_t inode; /* Inode number */
+- uint16_t rec_len; /* Directory entry length */
+- uint8_t name_len; /* Name length */
+- uint8_t file_type;
+- char name[EXT2_NAME_LEN]; /* File name */
+-};
+-
+-/*
+- * Ext2 directory file types. Only the low 3 bits are used. The
+- * other bits are reserved for now.
+- */
+-#define EXT2_FT_UNKNOWN 0
+-#define EXT2_FT_REG_FILE 1
+-#define EXT2_FT_DIR 2
+-#define EXT2_FT_CHRDEV 3
+-#define EXT2_FT_BLKDEV 4
+-#define EXT2_FT_FIFO 5
+-#define EXT2_FT_SOCK 6
+-#define EXT2_FT_SYMLINK 7
+-
+-#define EXT2_FT_MAX 8
+-
+-/*
+- * EXT2_DIR_PAD defines the directory entries boundaries
+- *
+- * NOTE: It must be a multiple of 4
+- */
+-#define EXT2_DIR_PAD 4
+-#define EXT2_DIR_ROUND (EXT2_DIR_PAD - 1)
+-#define EXT2_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT2_DIR_ROUND) & \
+- ~EXT2_DIR_ROUND)
+-
+-#endif
+--- a/e2fsprogs/e2fs_lib.h
++++ b/e2fsprogs/e2fs_lib.h
+@@ -7,7 +7,7 @@
+ */
+
+ /* Constants and structures */
+-#include "e2fs_defs.h"
++#include "bb_e2fs_defs.h"
+
+ PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN
+
+--- a/e2fsprogs/old_e2fsprogs/e2fsck.c
++++ b/e2fsprogs/old_e2fsprogs/e2fsck.c
+@@ -11577,7 +11577,7 @@ static void check_resize_inode(e2fsck_t
+ * s_reserved_gdt_blocks must be zero.
+ */
+ if (!(fs->super->s_feature_compat &
+- EXT2_FEATURE_COMPAT_RESIZE_INODE)) {
++ EXT2_FEATURE_COMPAT_RESIZE_INO)) {
+ if (fs->super->s_reserved_gdt_blocks) {
+ pctx.num = fs->super->s_reserved_gdt_blocks;
+ if (fix_problem(ctx, PR_0_NONZERO_RESERVED_GDT_BLOCKS,
+@@ -11593,7 +11593,7 @@ static void check_resize_inode(e2fsck_t
+ retval = ext2fs_read_inode(fs, EXT2_RESIZE_INO, &inode);
+ if (retval) {
+ if (fs->super->s_feature_compat &
+- EXT2_FEATURE_COMPAT_RESIZE_INODE)
++ EXT2_FEATURE_COMPAT_RESIZE_INO)
+ ctx->flags |= E2F_FLAG_RESIZE_INODE;
+ return;
+ }
+@@ -11603,7 +11603,7 @@ static void check_resize_inode(e2fsck_t
+ * the resize inode is cleared; then we're done.
+ */
+ if (!(fs->super->s_feature_compat &
+- EXT2_FEATURE_COMPAT_RESIZE_INODE)) {
++ EXT2_FEATURE_COMPAT_RESIZE_INO)) {
+ for (i=0; i < EXT2_N_BLOCKS; i++) {
+ if (inode.i_block[i])
+ break;
+--- a/e2fsprogs/old_e2fsprogs/e2p/feature.c
++++ b/e2fsprogs/old_e2fsprogs/e2p/feature.c
+@@ -34,7 +34,7 @@ static const struct feature feature_list
+ "ext_attr" },
+ { E2P_FEATURE_COMPAT, EXT2_FEATURE_COMPAT_DIR_INDEX,
+ "dir_index" },
+- { E2P_FEATURE_COMPAT, EXT2_FEATURE_COMPAT_RESIZE_INODE,
++ { E2P_FEATURE_COMPAT, EXT2_FEATURE_COMPAT_RESIZE_INO,
+ "resize_inode" },
+ { E2P_FEATURE_RO_INCOMPAT, EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER,
+ "sparse_super" },
+--- a/e2fsprogs/old_e2fsprogs/ext2fs/ext2_fs.h
++++ b/e2fsprogs/old_e2fsprogs/ext2fs/ext2_fs.h
+@@ -475,7 +475,7 @@ struct ext2_super_block {
+ #define EXT2_FEATURE_COMPAT_IMAGIC_INODES 0x0002
+ #define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x0004
+ #define EXT2_FEATURE_COMPAT_EXT_ATTR 0x0008
+-#define EXT2_FEATURE_COMPAT_RESIZE_INODE 0x0010
++#define EXT2_FEATURE_COMPAT_RESIZE_INO 0x0010
+ #define EXT2_FEATURE_COMPAT_DIR_INDEX 0x0020
+
+ #define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001
+--- a/e2fsprogs/old_e2fsprogs/ext2fs/ext2fs.h
++++ b/e2fsprogs/old_e2fsprogs/ext2fs/ext2fs.h
+@@ -383,7 +383,7 @@ typedef struct ext2_icount *ext2_icount_
+ #define EXT2_LIB_FEATURE_COMPAT_SUPP (EXT2_FEATURE_COMPAT_DIR_PREALLOC|\
+ EXT2_FEATURE_COMPAT_IMAGIC_INODES|\
+ EXT3_FEATURE_COMPAT_HAS_JOURNAL|\
+- EXT2_FEATURE_COMPAT_RESIZE_INODE|\
++ EXT2_FEATURE_COMPAT_RESIZE_INO|\
+ EXT2_FEATURE_COMPAT_DIR_INDEX|\
+ EXT2_FEATURE_COMPAT_EXT_ATTR)
+
+--- a/e2fsprogs/old_e2fsprogs/ext2fs/initialize.c
++++ b/e2fsprogs/old_e2fsprogs/ext2fs/initialize.c
+@@ -284,7 +284,7 @@ retry:
+ /*
+ * check the number of reserved group descriptor table blocks
+ */
+- if (super->s_feature_compat & EXT2_FEATURE_COMPAT_RESIZE_INODE)
++ if (super->s_feature_compat & EXT2_FEATURE_COMPAT_RESIZE_INO)
+ rsv_gdt = calc_reserved_gdt_blocks(fs);
+ else
+ rsv_gdt = 0;
+--- a/e2fsprogs/old_e2fsprogs/mke2fs.c
++++ b/e2fsprogs/old_e2fsprogs/mke2fs.c
+@@ -757,7 +757,7 @@ static void parse_extended_opts(struct e
+
+ if (rsv_gdb > 0) {
+ sb_param->s_feature_compat |=
+- EXT2_FEATURE_COMPAT_RESIZE_INODE;
++ EXT2_FEATURE_COMPAT_RESIZE_INO;
+
+ sb_param->s_reserved_gdt_blocks = rsv_gdb;
+ }
+@@ -778,7 +778,7 @@ static void parse_extended_opts(struct e
+
+ static __u32 ok_features[3] = {
+ EXT3_FEATURE_COMPAT_HAS_JOURNAL |
+- EXT2_FEATURE_COMPAT_RESIZE_INODE |
++ EXT2_FEATURE_COMPAT_RESIZE_INO |
+ EXT2_FEATURE_COMPAT_DIR_INDEX, /* Compat */
+ EXT2_FEATURE_INCOMPAT_FILETYPE| /* Incompat */
+ EXT3_FEATURE_INCOMPAT_JOURNAL_DEV|
+@@ -1123,7 +1123,7 @@ static int PRS(int argc, char **argv)
+ /* Since sparse_super is the default, we would only have a problem
+ * here if it was explicitly disabled.
+ */
+- if ((param.s_feature_compat & EXT2_FEATURE_COMPAT_RESIZE_INODE) &&
++ if ((param.s_feature_compat & EXT2_FEATURE_COMPAT_RESIZE_INO) &&
+ !(param.s_feature_ro_compat&EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER)) {
+ bb_error_msg_and_die("reserved online resize blocks not supported "
+ "on non-sparse filesystem");
+@@ -1312,7 +1312,7 @@ int mke2fs_main (int argc, char **argv)
+ reserve_inodes(fs);
+ create_bad_block_inode(fs, bb_list);
+ if (fs->super->s_feature_compat &
+- EXT2_FEATURE_COMPAT_RESIZE_INODE) {
++ EXT2_FEATURE_COMPAT_RESIZE_INO) {
+ retval = ext2fs_create_resize_inode(fs);
+ mke2fs_error_msg_and_die(retval, "reserve blocks for online resize");
+ }
+--- a/e2fsprogs/tune2fs.c
++++ b/e2fsprogs/tune2fs.c
+@@ -8,7 +8,7 @@
+ */
+ #include "libbb.h"
+ #include <linux/fs.h>
+-#include <linux/ext2_fs.h>
++#include "bb_e2fs_defs.h"
+
+ // storage helpers
+ char BUG_wrong_field_size(void);
+--- /dev/null
++++ b/include/bb_e2fs_defs.h
+@@ -0,0 +1,602 @@
++/* vi: set sw=4 ts=4: */
++/*
++ * linux/include/linux/ext2_fs.h
++ *
++ * Copyright (C) 1992, 1993, 1994, 1995
++ * Remy Card (card@masi.ibp.fr)
++ * Laboratoire MASI - Institut Blaise Pascal
++ * Universite Pierre et Marie Curie (Paris VI)
++ *
++ * Copyright (C) 1991, 1992 Linus Torvalds
++ */
++
++#ifndef LINUX_EXT2_FS_H
++#define LINUX_EXT2_FS_H 1
++
++/*
++ * Special inode numbers
++ */
++#define EXT2_BAD_INO 1 /* Bad blocks inode */
++#define EXT2_ROOT_INO 2 /* Root inode */
++#define EXT2_ACL_IDX_INO 3 /* ACL inode */
++#define EXT2_ACL_DATA_INO 4 /* ACL inode */
++#define EXT2_BOOT_LOADER_INO 5 /* Boot loader inode */
++#define EXT2_UNDEL_DIR_INO 6 /* Undelete directory inode */
++#define EXT2_RESIZE_INO 7 /* Reserved group descriptors inode */
++#define EXT2_JOURNAL_INO 8 /* Journal inode */
++
++/* First non-reserved inode for old ext2 filesystems */
++#define EXT2_GOOD_OLD_FIRST_INO 11
++
++/*
++ * The second extended file system magic number
++ */
++#define EXT2_SUPER_MAGIC 0xEF53
++
++/* Assume that user mode programs are passing in an ext2fs superblock, not
++ * a kernel struct super_block. This will allow us to call the feature-test
++ * macros from user land. */
++#define EXT2_SB(sb) (sb)
++
++/*
++ * Maximal count of links to a file
++ */
++#define EXT2_LINK_MAX 32000
++
++/*
++ * Macro-instructions used to manage several block sizes
++ */
++#define EXT2_MIN_BLOCK_LOG_SIZE 10 /* 1024 */
++#define EXT2_MAX_BLOCK_LOG_SIZE 16 /* 65536 */
++#define EXT2_MIN_BLOCK_SIZE (1 << EXT2_MIN_BLOCK_LOG_SIZE)
++#define EXT2_MAX_BLOCK_SIZE (1 << EXT2_MAX_BLOCK_LOG_SIZE)
++#define EXT2_BLOCK_SIZE(s) (EXT2_MIN_BLOCK_SIZE << (s)->s_log_block_size)
++#define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10)
++#define EXT2_INODE_SIZE(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \
++ EXT2_GOOD_OLD_INODE_SIZE : (s)->s_inode_size)
++#define EXT2_FIRST_INO(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \
++ EXT2_GOOD_OLD_FIRST_INO : (s)->s_first_ino)
++#define EXT2_ADDR_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof(uint32_t))
++
++/*
++ * Macro-instructions used to manage fragments
++ */
++#define EXT2_MIN_FRAG_SIZE EXT2_MIN_BLOCK_SIZE
++#define EXT2_MAX_FRAG_SIZE EXT2_MAX_BLOCK_SIZE
++#define EXT2_MIN_FRAG_LOG_SIZE EXT2_MIN_BLOCK_LOG_SIZE
++#define EXT2_FRAG_SIZE(s) (EXT2_MIN_FRAG_SIZE << (s)->s_log_frag_size)
++#define EXT2_FRAGS_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / EXT2_FRAG_SIZE(s))
++
++/*
++ * ACL structures
++ */
++struct ext2_acl_header { /* Header of Access Control Lists */
++ uint32_t aclh_size;
++ uint32_t aclh_file_count;
++ uint32_t aclh_acle_count;
++ uint32_t aclh_first_acle;
++};
++
++struct ext2_acl_entry { /* Access Control List Entry */
++ uint32_t acle_size;
++ uint16_t acle_perms; /* Access permissions */
++ uint16_t acle_type; /* Type of entry */
++ uint16_t acle_tag; /* User or group identity */
++ uint16_t acle_pad1;
++ uint32_t acle_next; /* Pointer on next entry for the */
++ /* same inode or on next free entry */
++};
++
++/*
++ * Structure of a blocks group descriptor
++ */
++struct ext2_group_desc {
++ uint32_t bg_block_bitmap; /* Blocks bitmap block */
++ uint32_t bg_inode_bitmap; /* Inodes bitmap block */
++ uint32_t bg_inode_table; /* Inodes table block */
++ uint16_t bg_free_blocks_count; /* Free blocks count */
++ uint16_t bg_free_inodes_count; /* Free inodes count */
++ uint16_t bg_used_dirs_count; /* Directories count */
++ uint16_t bg_pad;
++ uint32_t bg_reserved[3];
++};
++
++/*
++ * Data structures used by the directory indexing feature
++ *
++ * Note: all of the multibyte integer fields are little endian.
++ */
++
++/*
++ * Note: dx_root_info is laid out so that if it should somehow get
++ * overlaid by a dirent the two low bits of the hash version will be
++ * zero. Therefore, the hash version mod 4 should never be 0.
++ * Sincerely, the paranoia department.
++ */
++struct ext2_dx_root_info {
++ uint32_t reserved_zero;
++ uint8_t hash_version; /* 0 now, 1 at release */
++ uint8_t info_length; /* 8 */
++ uint8_t indirect_levels;
++ uint8_t unused_flags;
++};
++
++#define EXT2_HASH_LEGACY 0
++#define EXT2_HASH_HALF_MD4 1
++#define EXT2_HASH_TEA 2
++
++#define EXT2_HASH_FLAG_INCOMPAT 0x1
++
++struct ext2_dx_entry {
++ uint32_t hash;
++ uint32_t block;
++};
++
++struct ext2_dx_countlimit {
++ uint16_t limit;
++ uint16_t count;
++};
++
++
++/*
++ * Macro-instructions used to manage group descriptors
++ */
++#define EXT2_BLOCKS_PER_GROUP(s) (EXT2_SB(s)->s_blocks_per_group)
++#define EXT2_INODES_PER_GROUP(s) (EXT2_SB(s)->s_inodes_per_group)
++#define EXT2_INODES_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s)/EXT2_INODE_SIZE(s))
++/* limits imposed by 16-bit value gd_free_{blocks,inode}_count */
++#define EXT2_MAX_BLOCKS_PER_GROUP(s) ((1 << 16) - 8)
++#define EXT2_MAX_INODES_PER_GROUP(s) ((1 << 16) - EXT2_INODES_PER_BLOCK(s))
++#define EXT2_DESC_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_group_desc))
++
++/*
++ * Constants relative to the data blocks
++ */
++#define EXT2_NDIR_BLOCKS 12
++#define EXT2_IND_BLOCK EXT2_NDIR_BLOCKS
++#define EXT2_DIND_BLOCK (EXT2_IND_BLOCK + 1)
++#define EXT2_TIND_BLOCK (EXT2_DIND_BLOCK + 1)
++#define EXT2_N_BLOCKS (EXT2_TIND_BLOCK + 1)
++
++/*
++ * Inode flags
++ */
++#define EXT2_SECRM_FL 0x00000001 /* Secure deletion */
++#define EXT2_UNRM_FL 0x00000002 /* Undelete */
++#define EXT2_COMPR_FL 0x00000004 /* Compress file */
++#define EXT2_SYNC_FL 0x00000008 /* Synchronous updates */
++#define EXT2_IMMUTABLE_FL 0x00000010 /* Immutable file */
++#define EXT2_APPEND_FL 0x00000020 /* writes to file may only append */
++#define EXT2_NODUMP_FL 0x00000040 /* do not dump file */
++#define EXT2_NOATIME_FL 0x00000080 /* do not update atime */
++/* Reserved for compression usage... */
++#define EXT2_DIRTY_FL 0x00000100
++#define EXT2_COMPRBLK_FL 0x00000200 /* One or more compressed clusters */
++#define EXT2_NOCOMPR_FL 0x00000400 /* Access raw compressed data */
++#define EXT2_ECOMPR_FL 0x00000800 /* Compression error */
++/* End compression flags --- maybe not all used */
++#define EXT2_BTREE_FL 0x00001000 /* btree format dir */
++#define EXT2_INDEX_FL 0x00001000 /* hash-indexed directory */
++#define EXT2_IMAGIC_FL 0x00002000
++#define EXT3_JOURNAL_DATA_FL 0x00004000 /* file data should be journaled */
++#define EXT2_NOTAIL_FL 0x00008000 /* file tail should not be merged */
++#define EXT2_DIRSYNC_FL 0x00010000 /* Synchronous directory modifications */
++#define EXT2_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
++#define EXT3_EXTENTS_FL 0x00080000 /* Inode uses extents */
++#define EXT2_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
++
++#define EXT2_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
++#define EXT2_FL_USER_MODIFIABLE 0x000080FF /* User modifiable flags */
++
++/*
++ * ioctl commands
++ */
++#define EXT2_IOC_GETFLAGS _IOR('f', 1, long)
++#define EXT2_IOC_SETFLAGS _IOW('f', 2, long)
++#define EXT2_IOC_GETVERSION _IOR('v', 1, long)
++#define EXT2_IOC_SETVERSION _IOW('v', 2, long)
++
++/*
++ * Structure of an inode on the disk
++ */
++struct ext2_inode {
++ uint16_t i_mode; /* File mode */
++ uint16_t i_uid; /* Low 16 bits of Owner Uid */
++ uint32_t i_size; /* Size in bytes */
++ uint32_t i_atime; /* Access time */
++ uint32_t i_ctime; /* Creation time */
++ uint32_t i_mtime; /* Modification time */
++ uint32_t i_dtime; /* Deletion Time */
++ uint16_t i_gid; /* Low 16 bits of Group Id */
++ uint16_t i_links_count; /* Links count */
++ uint32_t i_blocks; /* Blocks count */
++ uint32_t i_flags; /* File flags */
++ union {
++ struct {
++ uint32_t l_i_reserved1;
++ } linux1;
++ struct {
++ uint32_t h_i_translator;
++ } hurd1;
++ struct {
++ uint32_t m_i_reserved1;
++ } masix1;
++ } osd1; /* OS dependent 1 */
++ uint32_t i_block[EXT2_N_BLOCKS];/* Pointers to blocks */
++ uint32_t i_generation; /* File version (for NFS) */
++ uint32_t i_file_acl; /* File ACL */
++ uint32_t i_dir_acl; /* Directory ACL */
++ uint32_t i_faddr; /* Fragment address */
++ union {
++ struct {
++ uint8_t l_i_frag; /* Fragment number */
++ uint8_t l_i_fsize; /* Fragment size */
++ uint16_t i_pad1;
++ uint16_t l_i_uid_high; /* these 2 fields */
++ uint16_t l_i_gid_high; /* were reserved2[0] */
++ uint32_t l_i_reserved2;
++ } linux2;
++ struct {
++ uint8_t h_i_frag; /* Fragment number */
++ uint8_t h_i_fsize; /* Fragment size */
++ uint16_t h_i_mode_high;
++ uint16_t h_i_uid_high;
++ uint16_t h_i_gid_high;
++ uint32_t h_i_author;
++ } hurd2;
++ struct {
++ uint8_t m_i_frag; /* Fragment number */
++ uint8_t m_i_fsize; /* Fragment size */
++ uint16_t m_pad1;
++ uint32_t m_i_reserved2[2];
++ } masix2;
++ } osd2; /* OS dependent 2 */
++};
++
++/*
++ * Permanent part of an large inode on the disk
++ */
++struct ext2_inode_large {
++ uint16_t i_mode; /* File mode */
++ uint16_t i_uid; /* Low 16 bits of Owner Uid */
++ uint32_t i_size; /* Size in bytes */
++ uint32_t i_atime; /* Access time */
++ uint32_t i_ctime; /* Creation time */
++ uint32_t i_mtime; /* Modification time */
++ uint32_t i_dtime; /* Deletion Time */
++ uint16_t i_gid; /* Low 16 bits of Group Id */
++ uint16_t i_links_count; /* Links count */
++ uint32_t i_blocks; /* Blocks count */
++ uint32_t i_flags; /* File flags */
++ union {
++ struct {
++ uint32_t l_i_reserved1;
++ } linux1;
++ struct {
++ uint32_t h_i_translator;
++ } hurd1;
++ struct {
++ uint32_t m_i_reserved1;
++ } masix1;
++ } osd1; /* OS dependent 1 */
++ uint32_t i_block[EXT2_N_BLOCKS];/* Pointers to blocks */
++ uint32_t i_generation; /* File version (for NFS) */
++ uint32_t i_file_acl; /* File ACL */
++ uint32_t i_dir_acl; /* Directory ACL */
++ uint32_t i_faddr; /* Fragment address */
++ union {
++ struct {
++ uint8_t l_i_frag; /* Fragment number */
++ uint8_t l_i_fsize; /* Fragment size */
++ uint16_t i_pad1;
++ uint16_t l_i_uid_high; /* these 2 fields */
++ uint16_t l_i_gid_high; /* were reserved2[0] */
++ uint32_t l_i_reserved2;
++ } linux2;
++ struct {
++ uint8_t h_i_frag; /* Fragment number */
++ uint8_t h_i_fsize; /* Fragment size */
++ uint16_t h_i_mode_high;
++ uint16_t h_i_uid_high;
++ uint16_t h_i_gid_high;
++ uint32_t h_i_author;
++ } hurd2;
++ struct {
++ uint8_t m_i_frag; /* Fragment number */
++ uint8_t m_i_fsize; /* Fragment size */
++ uint16_t m_pad1;
++ uint32_t m_i_reserved2[2];
++ } masix2;
++ } osd2; /* OS dependent 2 */
++ uint16_t i_extra_isize;
++ uint16_t i_pad1;
++};
++
++#define i_size_high i_dir_acl
++
++/*
++ * File system states
++ */
++#define EXT2_VALID_FS 0x0001 /* Unmounted cleanly */
++#define EXT2_ERROR_FS 0x0002 /* Errors detected */
++
++/*
++ * Mount flags
++ */
++#define EXT2_MOUNT_CHECK 0x0001 /* Do mount-time checks */
++#define EXT2_MOUNT_GRPID 0x0004 /* Create files with directory's group */
++#define EXT2_MOUNT_DEBUG 0x0008 /* Some debugging messages */
++#define EXT2_MOUNT_ERRORS_CONT 0x0010 /* Continue on errors */
++#define EXT2_MOUNT_ERRORS_RO 0x0020 /* Remount fs ro on errors */
++#define EXT2_MOUNT_ERRORS_PANIC 0x0040 /* Panic on errors */
++#define EXT2_MOUNT_MINIX_DF 0x0080 /* Mimics the Minix statfs */
++#define EXT2_MOUNT_NO_UID32 0x0200 /* Disable 32-bit UIDs */
++
++#define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
++#define set_opt(o, opt) o |= EXT2_MOUNT_##opt
++#define test_opt(sb, opt) (EXT2_SB(sb)->s_mount_opt & \
++ EXT2_MOUNT_##opt)
++/*
++ * Maximal mount counts between two filesystem checks
++ */
++#define EXT2_DFL_MAX_MNT_COUNT 20 /* Allow 20 mounts */
++#define EXT2_DFL_CHECKINTERVAL 0 /* Don't use interval check */
++
++/*
++ * Behaviour when detecting errors
++ */
++#define EXT2_ERRORS_CONTINUE 1 /* Continue execution */
++#define EXT2_ERRORS_RO 2 /* Remount fs read-only */
++#define EXT2_ERRORS_PANIC 3 /* Panic */
++#define EXT2_ERRORS_DEFAULT EXT2_ERRORS_CONTINUE
++
++/*
++ * Structure of the super block
++ */
++struct ext2_super_block {
++ uint32_t s_inodes_count; /* Inodes count */
++ uint32_t s_blocks_count; /* Blocks count */
++ uint32_t s_r_blocks_count; /* Reserved blocks count */
++ uint32_t s_free_blocks_count; /* Free blocks count */
++ uint32_t s_free_inodes_count; /* Free inodes count */
++ uint32_t s_first_data_block; /* First Data Block */
++ uint32_t s_log_block_size; /* Block size */
++ int32_t s_log_frag_size; /* Fragment size */
++ uint32_t s_blocks_per_group; /* # Blocks per group */
++ uint32_t s_frags_per_group; /* # Fragments per group */
++ uint32_t s_inodes_per_group; /* # Inodes per group */
++ uint32_t s_mtime; /* Mount time */
++ uint32_t s_wtime; /* Write time */
++ uint16_t s_mnt_count; /* Mount count */
++ int16_t s_max_mnt_count; /* Maximal mount count */
++ uint16_t s_magic; /* Magic signature */
++ uint16_t s_state; /* File system state */
++ uint16_t s_errors; /* Behaviour when detecting errors */
++ uint16_t s_minor_rev_level; /* minor revision level */
++ uint32_t s_lastcheck; /* time of last check */
++ uint32_t s_checkinterval; /* max. time between checks */
++ uint32_t s_creator_os; /* OS */
++ uint32_t s_rev_level; /* Revision level */
++ uint16_t s_def_resuid; /* Default uid for reserved blocks */
++ uint16_t s_def_resgid; /* Default gid for reserved blocks */
++ /*
++ * These fields are for EXT2_DYNAMIC_REV superblocks only.
++ *
++ * Note: the difference between the compatible feature set and
++ * the incompatible feature set is that if there is a bit set
++ * in the incompatible feature set that the kernel doesn't
++ * know about, it should refuse to mount the filesystem.
++ *
++ * e2fsck's requirements are more strict; if it doesn't know
++ * about a feature in either the compatible or incompatible
++ * feature set, it must abort and not try to meddle with
++ * things it doesn't understand...
++ */
++ uint32_t s_first_ino; /* First non-reserved inode */
++ uint16_t s_inode_size; /* size of inode structure */
++ uint16_t s_block_group_nr; /* block group # of this superblock */
++ uint32_t s_feature_compat; /* compatible feature set */
++ uint32_t s_feature_incompat; /* incompatible feature set */
++ uint32_t s_feature_ro_compat; /* readonly-compatible feature set */
++ uint8_t s_uuid[16]; /* 128-bit uuid for volume */
++ char s_volume_name[16]; /* volume name */
++ char s_last_mounted[64]; /* directory where last mounted */
++ uint32_t s_algorithm_usage_bitmap; /* For compression */
++ /*
++ * Performance hints. Directory preallocation should only
++ * happen if the EXT2_FEATURE_COMPAT_DIR_PREALLOC flag is on.
++ */
++ uint8_t s_prealloc_blocks; /* Nr of blocks to try to preallocate*/
++ uint8_t s_prealloc_dir_blocks; /* Nr to preallocate for dirs */
++ uint16_t s_reserved_gdt_blocks; /* Per group table for online growth */
++ /*
++ * Journaling support valid if EXT2_FEATURE_COMPAT_HAS_JOURNAL set.
++ */
++/*D0*/ uint8_t s_journal_uuid[16]; /* uuid of journal superblock */
++/*E0*/ uint32_t s_journal_inum; /* inode number of journal file */
++ uint32_t s_journal_dev; /* device number of journal file */
++ uint32_t s_last_orphan; /* start of list of inodes to delete */
++ uint32_t s_hash_seed[4]; /* HTREE hash seed */
++ uint8_t s_def_hash_version; /* Default hash version to use */
++ uint8_t s_jnl_backup_type; /* Default type of journal backup */
++ uint16_t s_reserved_word_pad;
++/*100*/ uint32_t s_default_mount_opts;
++ uint32_t s_first_meta_bg; /* First metablock group */
++ /* ext3 additions */
++ uint32_t s_mkfs_time; /* When the filesystem was created */
++ uint32_t s_jnl_blocks[17]; /* Backup of the journal inode */
++ /* 64bit support valid if EXT4_FEATURE_COMPAT_64BIT */
++/*150*/ uint32_t s_blocks_count_hi; /* Blocks count */
++ uint32_t s_r_blocks_count_hi; /* Reserved blocks count */
++ uint32_t s_free_blocks_count_hi; /* Free blocks count */
++ uint16_t s_min_extra_isize; /* All inodes have at least # bytes */
++ uint16_t s_want_extra_isize; /* New inodes should reserve # bytes */
++ uint32_t s_flags; /* Miscellaneous flags */
++ uint16_t s_raid_stride; /* RAID stride */
++ uint16_t s_mmp_interval; /* # seconds to wait in MMP checking */
++ uint64_t s_mmp_block; /* Block for multi-mount protection */
++ uint32_t s_raid_stripe_width; /* blocks on all data disks (N*stride)*/
++ uint8_t s_log_groups_per_flex; /* FLEX_BG group size */
++ uint8_t s_reserved_char_pad2;
++ uint16_t s_reserved_pad;
++ uint32_t s_reserved[162]; /* Padding to the end of the block */
++};
++struct BUG_ext2_super_block {
++ char bug[sizeof(struct ext2_super_block) == 1024 ? 1 : -1];
++};
++
++/*
++ * Codes for operating systems
++ */
++#define EXT2_OS_LINUX 0
++#define EXT2_OS_HURD 1
++#define EXT2_OS_MASIX 2
++#define EXT2_OS_FREEBSD 3
++#define EXT2_OS_LITES 4
++
++/*
++ * Revision levels
++ */
++#define EXT2_GOOD_OLD_REV 0 /* The good old (original) format */
++#define EXT2_DYNAMIC_REV 1 /* V2 format w/ dynamic inode sizes */
++
++#define EXT2_CURRENT_REV EXT2_GOOD_OLD_REV
++#define EXT2_MAX_SUPP_REV EXT2_DYNAMIC_REV
++
++#define EXT2_GOOD_OLD_INODE_SIZE 128
++
++/*
++ * Journal inode backup types
++ */
++#define EXT3_JNL_BACKUP_BLOCKS 1
++
++/*
++ * Feature set definitions
++ */
++
++#define EXT2_HAS_COMPAT_FEATURE(sb,mask) \
++ ( EXT2_SB(sb)->s_feature_compat & (mask) )
++#define EXT2_HAS_RO_COMPAT_FEATURE(sb,mask) \
++ ( EXT2_SB(sb)->s_feature_ro_compat & (mask) )
++#define EXT2_HAS_INCOMPAT_FEATURE(sb,mask) \
++ ( EXT2_SB(sb)->s_feature_incompat & (mask) )
++
++/* for s_feature_compat */
++#define EXT2_FEATURE_COMPAT_DIR_PREALLOC 0x0001
++#define EXT2_FEATURE_COMPAT_IMAGIC_INODES 0x0002
++#define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x0004
++#define EXT2_FEATURE_COMPAT_EXT_ATTR 0x0008
++#define EXT2_FEATURE_COMPAT_RESIZE_INO 0x0010
++#define EXT2_FEATURE_COMPAT_DIR_INDEX 0x0020
++
++/* for s_feature_ro_compat */
++#define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001
++#define EXT2_FEATURE_RO_COMPAT_LARGE_FILE 0x0002
++#define EXT2_FEATURE_RO_COMPAT_BTREE_DIR 0x0004 /* not used */
++#define EXT4_FEATURE_RO_COMPAT_HUGE_FILE 0x0008
++#define EXT4_FEATURE_RO_COMPAT_GDT_CSUM 0x0010
++#define EXT4_FEATURE_RO_COMPAT_DIR_NLINK 0x0020
++#define EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE 0x0040
++
++/* for s_feature_incompat */
++#define EXT2_FEATURE_INCOMPAT_COMPRESSION 0x0001
++#define EXT2_FEATURE_INCOMPAT_FILETYPE 0x0002
++#define EXT3_FEATURE_INCOMPAT_RECOVER 0x0004
++#define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008
++#define EXT2_FEATURE_INCOMPAT_META_BG 0x0010
++#define EXT4_FEATURE_INCOMPAT_EXTENTS 0x0040
++#define EXT4_FEATURE_INCOMPAT_64BIT 0x0080
++#define EXT4_FEATURE_INCOMPAT_MMP 0x0100
++#define EXT4_FEATURE_INCOMPAT_FLEX_BG 0x0200
++
++
++#define EXT2_FEATURE_COMPAT_SUPP 0
++#define EXT2_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \
++ EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \
++ EXT2_FEATURE_RO_COMPAT_BTREE_DIR)
++#define EXT2_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE| \
++ EXT2_FEATURE_INCOMPAT_META_BG)
++#define EXT2_FEATURE_INCOMPAT_UNSUPPORTED (~EXT2_FEATURE_INCOMPAT_SUPP)
++#define EXT2_FEATURE_RO_COMPAT_UNSUPPORTED (~EXT2_FEATURE_RO_COMPAT_SUPP)
++
++#define EXT3_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \
++ EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \
++ EXT2_FEATURE_RO_COMPAT_BTREE_DIR)
++#define EXT3_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE| \
++ EXT3_FEATURE_INCOMPAT_RECOVER| \
++ EXT2_FEATURE_INCOMPAT_META_BG)
++#define EXT3_FEATURE_INCOMPAT_UNSUPPORTED (~EXT3_FEATURE_INCOMPAT_SUPP)
++#define EXT3_FEATURE_RO_COMPAT_UNSUPPORTED (~EXT3_FEATURE_RO_COMPAT_SUPP)
++
++
++/*
++ * Default values for user and/or group using reserved blocks
++ */
++#define EXT2_DEF_RESUID 0
++#define EXT2_DEF_RESGID 0
++
++/*
++ * Default mount options
++ */
++#define EXT2_DEFM_DEBUG 0x0001
++#define EXT2_DEFM_BSDGROUPS 0x0002
++#define EXT2_DEFM_XATTR_USER 0x0004
++#define EXT2_DEFM_ACL 0x0008
++#define EXT2_DEFM_UID16 0x0010
++#define EXT3_DEFM_JMODE 0x0060
++#define EXT3_DEFM_JMODE_DATA 0x0020
++#define EXT3_DEFM_JMODE_ORDERED 0x0040
++#define EXT3_DEFM_JMODE_WBACK 0x0060
++
++/*
++ * Structure of a directory entry
++ */
++#define EXT2_NAME_LEN 255
++
++struct ext2_dir_entry {
++ uint32_t inode; /* Inode number */
++ uint16_t rec_len; /* Directory entry length */
++ uint16_t name_len; /* Name length */
++ char name[EXT2_NAME_LEN]; /* File name */
++};
++
++/*
++ * The new version of the directory entry. Since EXT2 structures are
++ * stored in intel byte order, and the name_len field could never be
++ * bigger than 255 chars, it's safe to reclaim the extra byte for the
++ * file_type field.
++ */
++struct ext2_dir_entry_2 {
++ uint32_t inode; /* Inode number */
++ uint16_t rec_len; /* Directory entry length */
++ uint8_t name_len; /* Name length */
++ uint8_t file_type;
++ char name[EXT2_NAME_LEN]; /* File name */
++};
++
++/*
++ * Ext2 directory file types. Only the low 3 bits are used. The
++ * other bits are reserved for now.
++ */
++#define EXT2_FT_UNKNOWN 0
++#define EXT2_FT_REG_FILE 1
++#define EXT2_FT_DIR 2
++#define EXT2_FT_CHRDEV 3
++#define EXT2_FT_BLKDEV 4
++#define EXT2_FT_FIFO 5
++#define EXT2_FT_SOCK 6
++#define EXT2_FT_SYMLINK 7
++
++#define EXT2_FT_MAX 8
++
++/*
++ * EXT2_DIR_PAD defines the directory entries boundaries
++ *
++ * NOTE: It must be a multiple of 4
++ */
++#define EXT2_DIR_PAD 4
++#define EXT2_DIR_ROUND (EXT2_DIR_PAD - 1)
++#define EXT2_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT2_DIR_ROUND) & \
++ ~EXT2_DIR_ROUND)
++
++#endif
+--- a/testsuite/mount.tests
++++ b/testsuite/mount.tests
+@@ -36,7 +36,8 @@ testing "mount -o remount,mand" \
+ "mount -o loop mount.image1m $testdir "\
+ "&& grep -Fc $testdir </proc/mounts "\
+ "&& mount -o remount,mand $testdir "\
+-"&& grep -F $testdir </proc/mounts | grep -c '[, ]mand[, ]'" \
++"&& grep -F $testdir </proc/mounts | grep -c '[, ]mand[, ]'"\
++"|| grep -F $testdir </proc/mounts" \
+ "1\n""1\n" \
+ "" ""
+
+@@ -83,4 +84,28 @@ b
+ "" ""
+ SKIP=
+
++
++testing "mount RO loop" "\
++exec 2>&1
++umount -d mount.dir 2>/dev/null
++rmdir mount.dir 2>/dev/null
++mkdir -p mount.dir
++(
++cd mount.dir || { echo 'cd error'; exit 1; }
++mkdir z1 z2 || { echo 'mkdir error'; exit 1; }
++mount -t tmpfs tmpfs z1 || { echo 'mount tmpfs error'; exit 1; }
++dd if=/dev/zero of=z1/e2img count=10 bs=1M 2>/dev/null || { echo 'dd error'; exit 1; }
++mke2fs -F z1/e2img 2>/dev/null >&2 || { echo 'mke2fs error'; exit 1; }
++mount -r -o loop -t ext2 z1/e2img z2 || { echo 'mount -r -o loop error'; exit 1; }
++mount -o remount,ro z1 || { echo 'mount -o remount,ro error'; exit 1; }
++)
++umount -d mount.dir/z2
++##losetup -d /dev/loop*
++umount -d mount.dir/z1
++rm -rf mount.dir
++echo DONE
++" \
++"DONE\n" "" ""
++
++
+ exit $FAILCOUNT
+--- a/util-linux/mkfs_ext2.c
++++ b/util-linux/mkfs_ext2.c
+@@ -48,16 +48,11 @@
+
+ #include "libbb.h"
+ #include <linux/fs.h>
+-#include <linux/ext2_fs.h>
++#include "bb_e2fs_defs.h"
+
+ #define ENABLE_FEATURE_MKFS_EXT2_RESERVED_GDT 0
+ #define ENABLE_FEATURE_MKFS_EXT2_DIR_INDEX 1
+
+-// from e2fsprogs
+-#define s_reserved_gdt_blocks s_padding1
+-#define s_mkfs_time s_reserved[0]
+-#define s_flags s_reserved[22]
+-
+ #define EXT2_HASH_HALF_MD4 1
+ #define EXT2_FLAGS_SIGNED_HASH 0x0001
+ #define EXT2_FLAGS_UNSIGNED_HASH 0x0002
+@@ -482,8 +477,10 @@ int mkfs_ext2_main(int argc UNUSED_PARAM
+ STORE_LE(sb->s_magic, EXT2_SUPER_MAGIC);
+ STORE_LE(sb->s_inode_size, inodesize);
+ // set "Required extra isize" and "Desired extra isize" fields to 28
+- if (inodesize != sizeof(*inode))
+- STORE_LE(sb->s_reserved[21], 0x001C001C);
++ if (inodesize != sizeof(*inode)) {
++ STORE_LE(sb->s_min_extra_isize, 0x001c);
++ STORE_LE(sb->s_want_extra_isize, 0x001c);
++ }
+ STORE_LE(sb->s_first_ino, EXT2_GOOD_OLD_FIRST_INO);
+ STORE_LE(sb->s_log_block_size, blocksize_log2 - EXT2_MIN_BLOCK_LOG_SIZE);
+ STORE_LE(sb->s_log_frag_size, blocksize_log2 - EXT2_MIN_BLOCK_LOG_SIZE);
+--- a/util-linux/volume_id/ext.c
++++ b/util-linux/volume_id/ext.c
+@@ -19,28 +19,8 @@
+ */
+
+ #include "volume_id_internal.h"
++#include "bb_e2fs_defs.h"
+
+-struct ext2_super_block {
+- uint32_t inodes_count;
+- uint32_t blocks_count;
+- uint32_t r_blocks_count;
+- uint32_t free_blocks_count;
+- uint32_t free_inodes_count;
+- uint32_t first_data_block;
+- uint32_t log_block_size;
+- uint32_t dummy3[7];
+- uint8_t magic[2];
+- uint16_t state;
+- uint32_t dummy5[8];
+- uint32_t feature_compat;
+- uint32_t feature_incompat;
+- uint32_t feature_ro_compat;
+- uint8_t uuid[16];
+- uint8_t volume_name[16];
+-} PACKED;
+-
+-#define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x00000004
+-#define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x00000008
+ #define EXT_SUPERBLOCK_OFFSET 0x400
+
+ int FAST_FUNC volume_id_probe_ext(struct volume_id *id /*,uint64_t off*/)
+@@ -54,23 +34,27 @@ int FAST_FUNC volume_id_probe_ext(struct
+ if (es == NULL)
+ return -1;
+
+- if (es->magic[0] != 0123 || es->magic[1] != 0357) {
++ if (es->s_magic != cpu_to_le16(EXT2_SUPER_MAGIC)) {
+ dbg("ext: no magic found");
+ return -1;
+ }
+
+ // volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
+ // volume_id_set_label_raw(id, es->volume_name, 16);
+- volume_id_set_label_string(id, es->volume_name, 16);
+- volume_id_set_uuid(id, es->uuid, UUID_DCE);
++ volume_id_set_label_string(id, (void*)es->s_volume_name, 16);
++ volume_id_set_uuid(id, es->s_uuid, UUID_DCE);
+ dbg("ext: label '%s' uuid '%s'", id->label, id->uuid);
+
+ #if ENABLE_FEATURE_BLKID_TYPE
+- if ((le32_to_cpu(es->feature_compat) & EXT3_FEATURE_COMPAT_HAS_JOURNAL) != 0)
++ if ((es->s_feature_ro_compat & cpu_to_le32(EXT4_FEATURE_RO_COMPAT_HUGE_FILE | EXT4_FEATURE_RO_COMPAT_DIR_NLINK))
++ || (es->s_feature_incompat & cpu_to_le32(EXT4_FEATURE_INCOMPAT_EXTENTS | EXT4_FEATURE_INCOMPAT_64BIT))
++ ) {
++ id->type = "ext4";
++ }
++ else if (es->s_feature_compat & cpu_to_le32(EXT3_FEATURE_COMPAT_HAS_JOURNAL))
+ id->type = "ext3";
+ else
+ id->type = "ext2";
+ #endif
+-
+ return 0;
+ }
diff --git a/package/busybox/patches/110-wget_getopt_fix.patch b/package/busybox/patches/110-wget_getopt_fix.patch
new file mode 100644
index 0000000..1003231
--- /dev/null
+++ b/package/busybox/patches/110-wget_getopt_fix.patch
@@ -0,0 +1,11 @@
+--- a/networking/wget.c
++++ b/networking/wget.c
+@@ -873,7 +873,7 @@ int wget_main(int argc UNUSED_PARAM, cha
+ /* Ignored: */
+ // "tries\0" Required_argument "t"
+ /* Ignored (we always use PASV): */
+- "passive-ftp\0" No_argument "\xff"
++ "passive-ftp\0" No_argument "\xfd"
+ "header\0" Required_argument "\xfe"
+ "post-data\0" Required_argument "\xfd"
+ /* Ignored (we don't do ssl) */
diff --git a/package/busybox/patches/140-trylink_bash.patch b/package/busybox/patches/140-trylink_bash.patch
new file mode 100644
index 0000000..f9571fc
--- /dev/null
+++ b/package/busybox/patches/140-trylink_bash.patch
@@ -0,0 +1,8 @@
+--- a/scripts/trylink
++++ b/scripts/trylink
+@@ -1,4 +1,4 @@
+-#!/bin/sh
++#!/usr/bin/env bash
+
+ debug=false
+
diff --git a/package/busybox/patches/141-gen_build_files_bash.patch b/package/busybox/patches/141-gen_build_files_bash.patch
new file mode 100644
index 0000000..d258fb8
--- /dev/null
+++ b/package/busybox/patches/141-gen_build_files_bash.patch
@@ -0,0 +1,8 @@
+--- a/scripts/gen_build_files.sh
++++ b/scripts/gen_build_files.sh
+@@ -1,4 +1,4 @@
+-#!/bin/sh
++#!/usr/bin/env bash
+
+ # Note: was using sed OPTS CMD -- FILES
+ # but users complain that many sed implementations
diff --git a/package/busybox/patches/150-no_static_libgcc.patch b/package/busybox/patches/150-no_static_libgcc.patch
new file mode 100644
index 0000000..fde6fbb
--- /dev/null
+++ b/package/busybox/patches/150-no_static_libgcc.patch
@@ -0,0 +1,11 @@
+--- a/Makefile.flags
++++ b/Makefile.flags
+@@ -50,7 +50,7 @@ CFLAGS += $(call cc-option,-fno-builtin-
+ # -fno-guess-branch-probability: prohibit pseudo-random guessing
+ # of branch probabilities (hopefully makes bloatcheck more stable):
+ CFLAGS += $(call cc-option,-fno-guess-branch-probability,)
+-CFLAGS += $(call cc-option,-funsigned-char -static-libgcc,)
++CFLAGS += $(call cc-option,-funsigned-char,)
+ CFLAGS += $(call cc-option,-falign-functions=1 -falign-jumps=1 -falign-labels=1 -falign-loops=1,)
+
+ # FIXME: These warnings are at least partially to be concerned about and should
diff --git a/package/busybox/patches/200-etc_crontabs.patch b/package/busybox/patches/200-etc_crontabs.patch
new file mode 100644
index 0000000..ebf2990
--- /dev/null
+++ b/package/busybox/patches/200-etc_crontabs.patch
@@ -0,0 +1,22 @@
+--- a/miscutils/crond.c
++++ b/miscutils/crond.c
+@@ -37,7 +37,7 @@
+
+
+ #define TMPDIR CONFIG_FEATURE_CROND_DIR
+-#define CRONTABS CONFIG_FEATURE_CROND_DIR "/crontabs"
++#define CRONTABS "/etc/crontabs"
+ #ifndef SENDMAIL
+ # define SENDMAIL "sendmail"
+ #endif
+--- a/miscutils/crontab.c
++++ b/miscutils/crontab.c
+@@ -22,7 +22,7 @@
+
+ #include "libbb.h"
+
+-#define CRONTABS CONFIG_FEATURE_CROND_DIR "/crontabs"
++#define CRONTABS "/etc/crontabs"
+ #ifndef CRONUPDATE
+ #define CRONUPDATE "cron.update"
+ #endif
diff --git a/package/busybox/patches/240-udhcpc_retries.patch b/package/busybox/patches/240-udhcpc_retries.patch
new file mode 100644
index 0000000..0e26864
--- /dev/null
+++ b/package/busybox/patches/240-udhcpc_retries.patch
@@ -0,0 +1,20 @@
+--- a/networking/udhcp/dhcpc.c
++++ b/networking/udhcp/dhcpc.c
+@@ -1319,7 +1319,7 @@ int udhcpc_main(int argc UNUSED_PARAM, c
+
+ switch (state) {
+ case INIT_SELECTING:
+- if (packet_num < discover_retries) {
++ if (!discover_retries || packet_num < discover_retries) {
+ if (packet_num == 0)
+ xid = random_xid();
+ /* broadcast */
+@@ -1348,7 +1348,7 @@ int udhcpc_main(int argc UNUSED_PARAM, c
+ packet_num = 0;
+ continue;
+ case REQUESTING:
+- if (packet_num < discover_retries) {
++ if (!discover_retries || packet_num < discover_retries) {
+ /* send broadcast select packet */
+ send_select(xid, server_addr, requested_ip);
+ timeout = discover_timeout;
diff --git a/package/busybox/patches/241-udhcpc-oversized_packets.patch b/package/busybox/patches/241-udhcpc-oversized_packets.patch
new file mode 100644
index 0000000..471d704
--- /dev/null
+++ b/package/busybox/patches/241-udhcpc-oversized_packets.patch
@@ -0,0 +1,99 @@
+--- a/networking/udhcp/packet.c
++++ b/networking/udhcp/packet.c
+@@ -158,6 +158,11 @@ uint16_t FAST_FUNC udhcp_checksum(void *
+ return ~sum;
+ }
+
++int udhcp_get_payload_len(struct dhcp_packet *dhcp_pkt)
++{
++ return sizeof(struct dhcp_packet) - DHCP_OPTIONS_BUFSIZE + udhcp_end_option(dhcp_pkt->options) + sizeof(dhcp_pkt->options[0]);
++}
++
+ /* Construct a ip/udp header for a packet, send packet */
+ int FAST_FUNC udhcp_send_raw_packet(struct dhcp_packet *dhcp_pkt,
+ uint32_t source_nip, int source_port,
+@@ -166,10 +171,10 @@ int FAST_FUNC udhcp_send_raw_packet(stru
+ {
+ struct sockaddr_ll dest_sll;
+ struct ip_udp_dhcp_packet packet;
+- unsigned padding;
+ int fd;
+ int result = -1;
+ const char *msg;
++ int p_len = udhcp_get_payload_len(dhcp_pkt);
+
+ fd = socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IP));
+ if (fd < 0) {
+@@ -178,8 +183,8 @@ int FAST_FUNC udhcp_send_raw_packet(stru
+ }
+
+ memset(&dest_sll, 0, sizeof(dest_sll));
+- memset(&packet, 0, offsetof(struct ip_udp_dhcp_packet, data));
+- packet.data = *dhcp_pkt; /* struct copy */
++ memset(&packet, 0, sizeof(packet));
++ memcpy(&(packet.data), dhcp_pkt, p_len);
+
+ dest_sll.sll_family = AF_PACKET;
+ dest_sll.sll_protocol = htons(ETH_P_IP);
+@@ -192,36 +197,24 @@ int FAST_FUNC udhcp_send_raw_packet(stru
+ goto ret_close;
+ }
+
+- /* We were sending full-sized DHCP packets (zero padded),
+- * but some badly configured servers were seen dropping them.
+- * Apparently they drop all DHCP packets >576 *ethernet* octets big,
+- * whereas they may only drop packets >576 *IP* octets big
+- * (which for typical Ethernet II means 590 octets: 6+6+2 + 576).
+- *
+- * In order to work with those buggy servers,
+- * we truncate packets after end option byte.
+- */
+- padding = DHCP_OPTIONS_BUFSIZE - 1 - udhcp_end_option(packet.data.options);
+-
+ packet.ip.protocol = IPPROTO_UDP;
+ packet.ip.saddr = source_nip;
+ packet.ip.daddr = dest_nip;
+ packet.udp.source = htons(source_port);
+ packet.udp.dest = htons(dest_port);
+- /* size, excluding IP header: */
+- packet.udp.len = htons(UDP_DHCP_SIZE - padding);
+- /* for UDP checksumming, ip.len is set to UDP packet len */
++ p_len += sizeof(packet.udp);
++ packet.udp.len = htons(p_len);
+ packet.ip.tot_len = packet.udp.len;
+- packet.udp.check = udhcp_checksum(&packet, IP_UDP_DHCP_SIZE - padding);
+- /* but for sending, it is set to IP packet len */
+- packet.ip.tot_len = htons(IP_UDP_DHCP_SIZE - padding);
++ p_len += sizeof(packet.ip);
++ packet.udp.check = udhcp_checksum(&packet, p_len);
++ packet.ip.tot_len = htons(p_len);
+ packet.ip.ihl = sizeof(packet.ip) >> 2;
+ packet.ip.version = IPVERSION;
+ packet.ip.ttl = IPDEFTTL;
+ packet.ip.check = udhcp_checksum(&packet.ip, sizeof(packet.ip));
+
+ udhcp_dump_packet(dhcp_pkt);
+- result = sendto(fd, &packet, IP_UDP_DHCP_SIZE - padding, /*flags:*/ 0,
++ result = sendto(fd, &packet, p_len, /*flags:*/ 0,
+ (struct sockaddr *) &dest_sll, sizeof(dest_sll));
+ msg = "sendto";
+ ret_close:
+@@ -239,7 +232,6 @@ int FAST_FUNC udhcp_send_kernel_packet(s
+ uint32_t dest_nip, int dest_port)
+ {
+ struct sockaddr_in client;
+- unsigned padding;
+ int fd;
+ int result = -1;
+ const char *msg;
+@@ -270,9 +262,7 @@ int FAST_FUNC udhcp_send_kernel_packet(s
+ }
+
+ udhcp_dump_packet(dhcp_pkt);
+-
+- padding = DHCP_OPTIONS_BUFSIZE - 1 - udhcp_end_option(dhcp_pkt->options);
+- result = safe_write(fd, dhcp_pkt, DHCP_SIZE - padding);
++ result = safe_write(fd, dhcp_pkt, udhcp_get_payload_len(dhcp_pkt));
+ msg = "write";
+ ret_close:
+ close(fd);
diff --git a/package/busybox/patches/242-udhcpc_msgs.patch b/package/busybox/patches/242-udhcpc_msgs.patch
new file mode 100644
index 0000000..c1c6096
--- /dev/null
+++ b/package/busybox/patches/242-udhcpc_msgs.patch
@@ -0,0 +1,18 @@
+--- a/networking/udhcp/dhcpc.c
++++ b/networking/udhcp/dhcpc.c
+@@ -602,6 +602,7 @@ static int raw_bcast_from_client_config_
+ static NOINLINE int send_discover(uint32_t xid, uint32_t requested)
+ {
+ struct dhcp_packet packet;
++ static int msgs = 0;
+
+ /* Fill in: op, htype, hlen, cookie, chaddr fields,
+ * random xid field (we override it below),
+@@ -619,6 +620,7 @@ static NOINLINE int send_discover(uint32
+ */
+ add_client_options(&packet);
+
++ if (msgs++ < 3)
+ bb_info_msg("Sending discover...");
+ return raw_bcast_from_client_config_ifindex(&packet);
+ }
diff --git a/package/busybox/patches/243-udhcpc_changed_ifindex.patch b/package/busybox/patches/243-udhcpc_changed_ifindex.patch
new file mode 100644
index 0000000..cb0df22
--- /dev/null
+++ b/package/busybox/patches/243-udhcpc_changed_ifindex.patch
@@ -0,0 +1,15 @@
+--- a/networking/udhcp/dhcpc.c
++++ b/networking/udhcp/dhcpc.c
+@@ -1267,6 +1267,12 @@ int udhcpc_main(int argc UNUSED_PARAM, c
+ /* silence "uninitialized!" warning */
+ unsigned timestamp_before_wait = timestamp_before_wait;
+
++ /* When running on a bridge, the ifindex may have changed (e.g. if
++ * member interfaces were added/removed or if the status of the
++ * bridge changed).
++ * Workaround: refresh it here before processing the next packet */
++ udhcp_read_interface(client_config.interface, &client_config.ifindex, NULL, client_config.client_mac);
++
+ //bb_error_msg("sockfd:%d, listen_mode:%d", sockfd, listen_mode);
+
+ /* Was opening raw or udp socket here
diff --git a/package/busybox/patches/244-udhcpc_add_6rd_option.patch b/package/busybox/patches/244-udhcpc_add_6rd_option.patch
new file mode 100644
index 0000000..2f0eadb
--- /dev/null
+++ b/package/busybox/patches/244-udhcpc_add_6rd_option.patch
@@ -0,0 +1,143 @@
+--- a/networking/udhcp/common.c
++++ b/networking/udhcp/common.c
+@@ -60,6 +60,8 @@ const struct dhcp_optflag dhcp_optflags[
+ { OPTION_U8 , 0x85 }, /* DHCP_VLAN_PRIORITY */
+ #endif
+ { OPTION_STATIC_ROUTES , 0xf9 }, /* DHCP_MS_STATIC_ROUTES */
++ { OPTION_6RD , 0xd4 }, /* DHCP_6RD (RFC) */
++ { OPTION_6RD , 0x96 }, /* DHCP_6RD (Comcast) */
+ { OPTION_STRING , 0xfc }, /* DHCP_WPAD */
+
+ /* Options below have no match in dhcp_option_strings[],
+@@ -127,6 +129,8 @@ const char dhcp_option_strings[] ALIGN1
+ "vlanpriority" "\0"/* DHCP_VLAN_PRIORITY */
+ #endif
+ "msstaticroutes""\0"/* DHCP_MS_STATIC_ROUTES */
++ "ip6rd" "\0" /* DHCP_6RD (RFC) */
++ "ip6rd" "\0" /* DHCP_6RD (Comcast) */
+ "wpad" "\0" /* DHCP_WPAD */
+ ;
+
+@@ -155,6 +159,7 @@ const uint8_t dhcp_option_lengths[] ALIG
+ [OPTION_S32] = 4,
+ /* Just like OPTION_STRING, we use minimum length here */
+ [OPTION_STATIC_ROUTES] = 5,
++ [OPTION_6RD] = 22,
+ };
+
+
+--- a/networking/udhcp/common.h
++++ b/networking/udhcp/common.h
+@@ -91,6 +91,7 @@ enum {
+ OPTION_S32,
+ OPTION_BIN,
+ OPTION_STATIC_ROUTES,
++ OPTION_6RD,
+ #if ENABLE_FEATURE_UDHCP_RFC3397
+ OPTION_DNS_STRING, /* RFC1035 compressed domain name list */
+ OPTION_SIP_SERVERS,
+--- a/networking/udhcp/dhcpc.c
++++ b/networking/udhcp/dhcpc.c
+@@ -100,6 +100,7 @@ static const uint8_t len_of_option_as_st
+ [OPTION_IP ] = sizeof("255.255.255.255 "),
+ [OPTION_IP_PAIR ] = sizeof("255.255.255.255 ") * 2,
+ [OPTION_STATIC_ROUTES ] = sizeof("255.255.255.255/32 255.255.255.255 "),
++ [OPTION_6RD ] = sizeof("32 128 FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF 255.255.255.255 "),
+ [OPTION_STRING ] = 1,
+ [OPTION_STRING_HOST ] = 1,
+ #if ENABLE_FEATURE_UDHCP_RFC3397
+@@ -124,6 +125,23 @@ static int sprint_nip(char *dest, const
+ return sprintf(dest, "%s%u.%u.%u.%u", pre, ip[0], ip[1], ip[2], ip[3]);
+ }
+
++static int sprint_nip6(char *dest, const char *pre, const uint8_t *ip)
++{
++ int len = 0;
++ int off;
++ uint16_t word;
++
++ len += sprintf(dest, "%s", pre);
++
++ for (off = 0; off < 16; off += 2)
++ {
++ move_from_unaligned16(word, &ip[off]);
++ len += sprintf(dest+len, "%s%04X", off ? ":" : "", htons(word));
++ }
++
++ return len;
++}
++
+ /* really simple implementation, just count the bits */
+ static int mton(uint32_t mask)
+ {
+@@ -292,6 +310,70 @@ static NOINLINE char *xmalloc_optname_op
+ }
+
+ return ret;
++ }
++ case OPTION_6RD: {
++ /* Option binary format:
++ * 0 1 2 3
++ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
++ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
++ * | OPTION_6RD | option-length | IPv4MaskLen | 6rdPrefixLen |
++ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
++ * | |
++ * | 6rdPrefix |
++ * | (16 octets) |
++ * | |
++ * | |
++ * | |
++ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
++ * | 6rdBRIPv4Address(es) |
++ * . .
++ * . .
++ * . .
++ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
++ *
++ * We convert it to a string "IPv4MaskLen 6rdPrefixLen 6rdPrefix 6rdBRIPv4Address"
++ */
++
++ /* Sanity check: ensure that our length is at least 22 bytes, that
++ * IPv4MaskLen is <= 32, 6rdPrefixLen <= 128 and that the sum of
++ * (32 - IPv4MaskLen) + 6rdPrefixLen is less than or equal to 128.
++ * If any of these requirements is not fulfilled, return with empty
++ * value.
++ */
++ if ((len >= 22) && (*option <= 32) && (*(option+1) <= 128) &&
++ (((32 - *option) + *(option+1)) <= 128))
++ {
++ /* IPv4MaskLen */
++ dest += sprintf(dest, "%u ", *option++);
++ len--;
++
++ /* 6rdPrefixLen */
++ dest += sprintf(dest, "%u ", *option++);
++ len--;
++
++ /* 6rdPrefix */
++ dest += sprint_nip6(dest, "", option);
++ option += 16;
++ len -= 16;
++
++ /* 6rdBRIPv4Addresses */
++ while (len >= 4)
++ {
++ dest += sprint_nip(dest, " ", option);
++ option += 4;
++ len -= 4;
++
++ /* the code to determine the option size fails to work with
++ * lengths that are not a multiple of the minimum length,
++ * adding all advertised 6rdBRIPv4Addresses here would
++ * overflow the destination buffer, therefore skip the rest
++ * for now
++ */
++ break;
++ }
++ }
++
++ return ret;
+ }
+ #if ENABLE_FEATURE_UDHCP_RFC3397
+ case OPTION_DNS_STRING:
diff --git a/package/busybox/patches/250-ash_export-n.patch b/package/busybox/patches/250-ash_export-n.patch
new file mode 100644
index 0000000..048c236
--- /dev/null
+++ b/package/busybox/patches/250-ash_export-n.patch
@@ -0,0 +1,34 @@
+--- a/shell/ash.c
++++ b/shell/ash.c
+@@ -12611,8 +12611,17 @@ exportcmd(int argc UNUSED_PARAM, char **
+ const char *p;
+ char **aptr;
+ int flag = argv[0][0] == 'r' ? VREADONLY : VEXPORT;
++ int mask = ~0;
++ int nopt;
++ while ((nopt = nextopt("np"))) {
++ if (nopt == 'n') {
++ mask = ~flag;
++ } else { /* p */
++ break;
++ }
++ }
+
+- if (nextopt("p") != 'p') {
++ if (nopt != 'p') {
+ aptr = argptr;
+ name = *aptr;
+ if (name) {
+@@ -12624,10 +12633,12 @@ exportcmd(int argc UNUSED_PARAM, char **
+ vp = *findvar(hashvar(name), name);
+ if (vp) {
+ vp->flags |= flag;
++ vp->flags &= mask;
+ continue;
+ }
+ }
+ setvar(name, p, flag);
++ setvar(name, p, flag & mask);
+ } while ((name = *++aptr) != NULL);
+ return 0;
+ }
diff --git a/package/busybox/patches/251-ash_fix-redir-substitution.patch b/package/busybox/patches/251-ash_fix-redir-substitution.patch
new file mode 100644
index 0000000..cb2ae94
--- /dev/null
+++ b/package/busybox/patches/251-ash_fix-redir-substitution.patch
@@ -0,0 +1,12 @@
+--- a/shell/ash.c
++++ b/shell/ash.c
+@@ -6846,8 +6846,7 @@ evalvar(char *p, int flags, struct strli
+ patloc = expdest - (char *)stackblock();
+ if (NULL == subevalvar(p, /* varname: */ NULL, patloc, subtype,
+ startloc, varflags,
+-//TODO: | EXP_REDIR too? All other such places do it too
+- /* quotes: */ flags & (EXP_FULL | EXP_CASE),
++ /* quotes: */ flags & (EXP_FULL | EXP_CASE | EXP_REDIR),
+ var_str_list)
+ ) {
+ int amount = expdest - (
diff --git a/package/busybox/patches/260-vconfig_proc.patch b/package/busybox/patches/260-vconfig_proc.patch
new file mode 100644
index 0000000..7ac52ab
--- /dev/null
+++ b/package/busybox/patches/260-vconfig_proc.patch
@@ -0,0 +1,22 @@
+--- a/networking/vconfig.c
++++ b/networking/vconfig.c
+@@ -116,8 +116,6 @@ static const char name_types[] ALIGN1 =
+ '_', 'N', 'O', '_', 'P', 'A', 'D', 0,
+ };
+
+-static const char conf_file_name[] ALIGN1 = "/proc/net/vlan/config";
+-
+ int vconfig_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
+ int vconfig_main(int argc, char **argv)
+ {
+@@ -129,10 +127,6 @@ int vconfig_main(int argc, char **argv)
+ bb_show_usage();
+ }
+
+- /* Don't bother closing the filedes. It will be closed on cleanup. */
+- /* Will die if 802.1q is not present */
+- xopen(conf_file_name, O_RDONLY);
+-
+ memset(&ifr, 0, sizeof(ifr));
+
+ ++argv;
diff --git a/package/busybox/patches/300-netmsg.patch b/package/busybox/patches/300-netmsg.patch
new file mode 100644
index 0000000..e8b2513
--- /dev/null
+++ b/package/busybox/patches/300-netmsg.patch
@@ -0,0 +1,103 @@
+--- a/include/applets.src.h
++++ b/include/applets.src.h
+@@ -266,6 +266,7 @@ IF_MT(APPLET(mt, BB_DIR_BIN, BB_SUID_DRO
+ IF_MV(APPLET(mv, BB_DIR_BIN, BB_SUID_DROP))
+ IF_NAMEIF(APPLET(nameif, BB_DIR_SBIN, BB_SUID_DROP))
+ IF_NC(APPLET(nc, BB_DIR_USR_BIN, BB_SUID_DROP))
++IF_NETMSG(APPLET(netmsg, BB_DIR_BIN, BB_SUID_REQUIRE))
+ IF_NETSTAT(APPLET(netstat, BB_DIR_BIN, BB_SUID_DROP))
+ IF_NICE(APPLET(nice, BB_DIR_BIN, BB_SUID_DROP))
+ IF_NOHUP(APPLET(nohup, BB_DIR_USR_BIN, BB_SUID_DROP))
+--- a/networking/Config.src
++++ b/networking/Config.src
+@@ -612,6 +612,12 @@ config FEATURE_IPCALC_LONG_OPTIONS
+ help
+ Support long options for the ipcalc applet.
+
++config NETMSG
++ bool "netmsg"
++ default n
++ help
++ simple program for sending udp broadcast messages
++
+ config NETSTAT
+ bool "netstat"
+ default y
+--- a/networking/Kbuild.src
++++ b/networking/Kbuild.src
+@@ -27,6 +27,7 @@ lib-$(CONFIG_IP) += ip.o
+ lib-$(CONFIG_IPCALC) += ipcalc.o
+ lib-$(CONFIG_NAMEIF) += nameif.o
+ lib-$(CONFIG_NC) += nc.o
++lib-$(CONFIG_NETMSG) += netmsg.o
+ lib-$(CONFIG_NETSTAT) += netstat.o
+ lib-$(CONFIG_NSLOOKUP) += nslookup.o
+ lib-$(CONFIG_NTPD) += ntpd.o
+--- /dev/null
++++ b/networking/netmsg.c
+@@ -0,0 +1,65 @@
++/*
++ * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
++ *
++ * This is free software, licensed under the GNU General Public License v2.
++ */
++#include <sys/types.h>
++#include <sys/socket.h>
++#include <netinet/in.h>
++#include <netdb.h>
++#include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
++#include "busybox.h"
++
++//usage:#define netmsg_trivial_usage NOUSAGE_STR
++//usage:#define netmsg_full_usage ""
++
++#ifndef CONFIG_NETMSG
++int main(int argc, char **argv)
++#else
++int netmsg_main(int argc, char **argv)
++#endif
++{
++ int s;
++ struct sockaddr_in addr;
++ int optval = 1;
++ unsigned char buf[1001];
++
++ if (argc != 3) {
++ fprintf(stderr, "usage: %s <ip> \"<message>\"\n", argv[0]);
++ exit(1);
++ }
++
++ if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
++ perror("Opening socket");
++ exit(1);
++ }
++
++ memset(&addr, 0, sizeof(addr));
++ addr.sin_family = AF_INET;
++ addr.sin_addr.s_addr = inet_addr(argv[1]);
++ addr.sin_port = htons(0x1337);
++
++ memset(buf, 0, 1001);
++ buf[0] = 0xde;
++ buf[1] = 0xad;
++
++ strncpy(buf + 2, argv[2], 998);
++
++ if (setsockopt (s, SOL_SOCKET, SO_BROADCAST, (caddr_t) &optval, sizeof (optval)) < 0) {
++ perror("setsockopt()");
++ goto fail;
++ }
++
++ if (sendto(s, buf, 1001, 0, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
++ perror("sendto()");
++ goto fail;
++ }
++
++ return 0;
++
++fail:
++ close(s);
++ exit(1);
++}
diff --git a/package/busybox/patches/310-passwd_access.patch b/package/busybox/patches/310-passwd_access.patch
new file mode 100644
index 0000000..daa1b99
--- /dev/null
+++ b/package/busybox/patches/310-passwd_access.patch
@@ -0,0 +1,41 @@
+
+ Copyright (C) 2006 OpenWrt.org
+
+--- a/networking/httpd.c
++++ b/networking/httpd.c
+@@ -1700,21 +1700,32 @@ static int check_user_passwd(const char
+
+ if (ENABLE_FEATURE_HTTPD_AUTH_MD5) {
+ char *md5_passwd;
++ int user_len_p1;
+
+ md5_passwd = strchr(cur->after_colon, ':');
+- if (md5_passwd && md5_passwd[1] == '$' && md5_passwd[2] == '1'
++ user_len_p1 = md5_passwd + 1 - cur->after_colon;
++ if (md5_passwd && !strncmp(md5_passwd + 1, "$p$", 3)) {
++ struct passwd *pwd = NULL;
++
++ pwd = getpwnam(&md5_passwd[4]);
++ if(!pwd->pw_passwd || !pwd->pw_passwd[0] || pwd->pw_passwd[0] == '!')
++ return 1;
++
++ md5_passwd = pwd->pw_passwd;
++ goto check_md5_pw;
++ } else if (md5_passwd && md5_passwd[1] == '$' && md5_passwd[2] == '1'
+ && md5_passwd[3] == '$' && md5_passwd[4]
+ ) {
+ char *encrypted;
+- int r, user_len_p1;
++ int r;
+
+ md5_passwd++;
+- user_len_p1 = md5_passwd - cur->after_colon;
+ /* comparing "user:" */
+ if (strncmp(cur->after_colon, user_and_passwd, user_len_p1) != 0) {
+ continue;
+ }
+
++check_md5_pw:
+ encrypted = pw_encrypt(
+ user_and_passwd + user_len_p1 /* cleartext pwd from user */,
+ md5_passwd /*salt */, 1 /* cleanup */);
diff --git a/package/busybox/patches/340-lock_util.patch b/package/busybox/patches/340-lock_util.patch
new file mode 100644
index 0000000..eb34642
--- /dev/null
+++ b/package/busybox/patches/340-lock_util.patch
@@ -0,0 +1,172 @@
+--- a/include/applets.src.h
++++ b/include/applets.src.h
+@@ -218,6 +218,7 @@ IF_LN(APPLET_NOEXEC(ln, ln, BB_DIR_BIN,
+ IF_LOAD_POLICY(APPLET(load_policy, BB_DIR_USR_SBIN, BB_SUID_DROP))
+ IF_LOADFONT(APPLET(loadfont, BB_DIR_USR_SBIN, BB_SUID_DROP))
+ IF_LOADKMAP(APPLET(loadkmap, BB_DIR_SBIN, BB_SUID_DROP))
++IF_LOCK(APPLET(lock, BB_DIR_BIN, BB_SUID_DROP))
+ IF_LOGGER(APPLET(logger, BB_DIR_USR_BIN, BB_SUID_DROP))
+ /* Needs to be run by root or be suid root - needs to change uid and gid: */
+ IF_LOGIN(APPLET(login, BB_DIR_BIN, BB_SUID_REQUIRE))
+--- a/miscutils/Config.src
++++ b/miscutils/Config.src
+@@ -419,6 +419,11 @@ config FEATURE_HDPARM_HDIO_GETSET_DMA
+ help
+ Enables the 'hdparm -d' option to get/set using_dma flag.
+
++config LOCK
++ bool "lock"
++ help
++ Small utility for using locks in scripts
++
+ config MAKEDEVS
+ bool "makedevs"
+ default y
+--- a/miscutils/Kbuild.src
++++ b/miscutils/Kbuild.src
+@@ -29,6 +29,7 @@ lib-$(CONFIG_INOTIFYD) += inotifyd.o
+ lib-$(CONFIG_FEATURE_LAST_SMALL)+= last.o
+ lib-$(CONFIG_FEATURE_LAST_FANCY)+= last_fancy.o
+ lib-$(CONFIG_LESS) += less.o
++lib-$(CONFIG_LOCK) += lock.o
+ lib-$(CONFIG_MAKEDEVS) += makedevs.o
+ lib-$(CONFIG_MAN) += man.o
+ lib-$(CONFIG_MICROCOM) += microcom.o
+--- /dev/null
++++ b/miscutils/lock.c
+@@ -0,0 +1,135 @@
++/*
++ * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
++ *
++ * This is free software, licensed under the GNU General Public License v2.
++ */
++#include <sys/types.h>
++#include <sys/file.h>
++#include <sys/stat.h>
++#include <signal.h>
++#include <fcntl.h>
++#include <unistd.h>
++#include <stdio.h>
++#include "busybox.h"
++
++//usage:#define lock_trivial_usage NOUSAGE_STR
++//usage:#define lock_full_usage ""
++
++static int unlock = 0;
++static int shared = 0;
++static int waitonly = 0;
++static int fd;
++static char *file;
++
++static void usage(char *name)
++{
++ fprintf(stderr, "Usage: %s [-suw] <filename>\n"
++ " -s Use shared locking\n"
++ " -u Unlock\n"
++ " -w Wait for the lock to become free, don't acquire lock\n"
++ "\n", name);
++ exit(1);
++}
++
++static void exit_unlock(int sig)
++{
++ flock(fd, LOCK_UN);
++ exit(0);
++}
++
++static int do_unlock(void)
++{
++ FILE *f;
++ int i;
++
++ if ((f = fopen(file, "r")) == NULL)
++ return 0;
++
++ fscanf(f, "%d", &i);
++ if (i > 0)
++ kill(i, SIGTERM);
++
++ fclose(f);
++
++ return 0;
++}
++
++static int do_lock(void)
++{
++ int pid;
++ char pidstr[8];
++
++ if ((fd = open(file, O_RDWR | O_CREAT | O_EXCL, 0700)) < 0) {
++ if ((fd = open(file, O_RDWR)) < 0) {
++ fprintf(stderr, "Can't open %s\n", file);
++ return 1;
++ }
++ }
++
++ if (flock(fd, (shared ? LOCK_SH : LOCK_EX)) < 0) {
++ fprintf(stderr, "Can't lock %s\n", file);
++ return 1;
++ }
++
++ pid = fork();
++
++ if (pid < 0)
++ return -1;
++
++ if (pid == 0) {
++ signal(SIGKILL, exit_unlock);
++ signal(SIGTERM, exit_unlock);
++ signal(SIGINT, exit_unlock);
++ if (waitonly)
++ exit_unlock(0);
++ else
++ while (1)
++ sleep(1);
++ } else {
++ if (!waitonly) {
++ lseek(fd, 0, SEEK_SET);
++ ftruncate(fd, 0);
++ sprintf(pidstr, "%d\n", pid);
++ write(fd, pidstr, strlen(pidstr));
++ close(fd);
++ }
++
++ return 0;
++ }
++ return 0;
++}
++
++int lock_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
++int lock_main(int argc, char **argv)
++{
++ char **args = &argv[1];
++ int c = argc - 1;
++
++ while ((*args != NULL) && (*args)[0] == '-') {
++ char *ch = *args;
++ while (*(++ch) > 0) {
++ switch(*ch) {
++ case 'w':
++ waitonly = 1;
++ break;
++ case 's':
++ shared = 1;
++ break;
++ case 'u':
++ unlock = 1;
++ break;
++ }
++ }
++ c--;
++ args++;
++ }
++
++ if (c != 1)
++ usage(argv[0]);
++
++ file = *args;
++ if (unlock)
++ return do_unlock();
++ else
++ return do_lock();
++}
diff --git a/package/busybox/patches/350-httpd_redir.patch b/package/busybox/patches/350-httpd_redir.patch
new file mode 100644
index 0000000..11125e7
--- /dev/null
+++ b/package/busybox/patches/350-httpd_redir.patch
@@ -0,0 +1,90 @@
+--- a/networking/httpd.c
++++ b/networking/httpd.c
+@@ -105,6 +105,7 @@
+ //usage: IF_FEATURE_HTTPD_BASIC_AUTH(" [-r REALM]")
+ //usage: " [-h HOME]\n"
+ //usage: "or httpd -d/-e" IF_FEATURE_HTTPD_AUTH_MD5("/-m") " STRING"
++//usage: " [-R <path> [-H <host>]]"
+ //usage:#define httpd_full_usage "\n\n"
+ //usage: "Listen for incoming HTTP requests\n"
+ //usage: "\n -i Inetd mode"
+@@ -121,6 +122,8 @@
+ //usage: "\n -m STRING MD5 crypt STRING")
+ //usage: "\n -e STRING HTML encode STRING"
+ //usage: "\n -d STRING URL decode STRING"
++//usage: "\n -R PATH Redirect target path"
++//usage: "\n -H HOST Redirect target host"
+
+ #include "libbb.h"
+ #if ENABLE_FEATURE_HTTPD_USE_SENDFILE
+@@ -272,6 +275,8 @@ struct globals {
+
+ const char *found_mime_type;
+ const char *found_moved_temporarily;
++ const char *redirect_path;
++ const char *redirect_host;
+ Htaccess_IP *ip_a_d; /* config allow/deny lines */
+
+ IF_FEATURE_HTTPD_BASIC_AUTH(const char *g_realm;)
+@@ -322,6 +327,8 @@ struct globals {
+ #define index_page (G.index_page )
+ #define found_mime_type (G.found_mime_type )
+ #define found_moved_temporarily (G.found_moved_temporarily)
++#define redirect_path (G.redirect_path )
++#define redirect_host (G.redirect_host )
+ #define last_mod (G.last_mod )
+ #define ip_a_d (G.ip_a_d )
+ #define g_realm (G.g_realm )
+@@ -956,8 +963,11 @@ static void send_headers(int responseNum
+ }
+ #endif
+ if (responseNum == HTTP_MOVED_TEMPORARILY) {
+- len += sprintf(iobuf + len, "Location: %s/%s%s\r\n",
++ len += sprintf(iobuf + len, "Location: %s%s%s%s%s%s\r\n",
++ (redirect_host ? "http://" : ""),
++ (redirect_host ? redirect_host : ""),
+ found_moved_temporarily,
++ (redirect_host ? "" : "/"),
+ (g_query ? "?" : ""),
+ (g_query ? g_query : ""));
+ }
+@@ -1925,8 +1935,12 @@ static void handle_incoming_and_exit(con
+ } while (*++tptr);
+ *++urlp = '\0'; /* terminate after last character */
+
++ /* redirect active */
++ if (redirect_path && (strncmp(urlcopy, redirect_path, strlen(redirect_path)) != 0))
++ found_moved_temporarily = redirect_path;
++
+ /* If URL is a directory, add '/' */
+- if (urlp[-1] != '/') {
++ if (!redirect_path && (urlp[-1] != '/')) {
+ if (is_directory(urlcopy + 1, 1, NULL)) {
+ found_moved_temporarily = urlcopy;
+ }
+@@ -2283,7 +2297,9 @@ static void sighup_handler(int sig UNUSE
+ }
+
+ enum {
+- c_opt_config_file = 0,
++ R_opt_redirect_path = 0,
++ H_opt_redirect_host,
++ c_opt_config_file,
+ d_opt_decode_url,
+ h_opt_home_httpd,
+ IF_FEATURE_HTTPD_ENCODE_URL_STR(e_opt_encode_url,)
+@@ -2332,12 +2348,13 @@ int httpd_main(int argc UNUSED_PARAM, ch
+ /* We do not "absolutize" path given by -h (home) opt.
+ * If user gives relative path in -h,
+ * $SCRIPT_FILENAME will not be set. */
+- opt = getopt32(argv, "c:d:h:"
++ opt = getopt32(argv, "R:H:c:d:h:"
+ IF_FEATURE_HTTPD_ENCODE_URL_STR("e:")
+ IF_FEATURE_HTTPD_BASIC_AUTH("r:")
+ IF_FEATURE_HTTPD_AUTH_MD5("m:")
+ IF_FEATURE_HTTPD_SETUID("u:")
+ "p:ifv",
++ &redirect_path, &redirect_host,
+ &opt_c_configFile, &url_for_decode, &home_httpd
+ IF_FEATURE_HTTPD_ENCODE_URL_STR(, &url_for_encode)
+ IF_FEATURE_HTTPD_BASIC_AUTH(, &g_realm)
diff --git a/package/busybox/patches/410-httpd_cgi_headers.patch b/package/busybox/patches/410-httpd_cgi_headers.patch
new file mode 100644
index 0000000..b02a5b9
--- /dev/null
+++ b/package/busybox/patches/410-httpd_cgi_headers.patch
@@ -0,0 +1,16 @@
+--- a/networking/httpd.c
++++ b/networking/httpd.c
+@@ -1222,10 +1222,10 @@ static NOINLINE void cgi_io_loop_and_exi
+ if (full_write(STDOUT_FILENO, HTTP_200, sizeof(HTTP_200)-1) != sizeof(HTTP_200)-1)
+ break;
+ }
+- /* Commented out:
+- if (!strstr(rbuf, "ontent-")) {
+- full_write(s, "Content-type: text/plain\r\n\r\n", 28);
++ if (!strstr(rbuf, "ontent-") && !strstr(rbuf, "ocation:")) {
++ full_write(1, "Content-type: text/plain\r\n\r\n", 28);
+ }
++ /* Previously commented out:
+ * Counter-example of valid CGI without Content-type:
+ * echo -en "HTTP/1.0 302 Found\r\n"
+ * echo -en "Location: http://www.busybox.net\r\n"
diff --git a/package/busybox/patches/440-httpd_chdir.patch b/package/busybox/patches/440-httpd_chdir.patch
new file mode 100644
index 0000000..401c6eb
--- /dev/null
+++ b/package/busybox/patches/440-httpd_chdir.patch
@@ -0,0 +1,10 @@
+--- a/networking/httpd.c
++++ b/networking/httpd.c
+@@ -1814,6 +1814,7 @@ static void handle_incoming_and_exit(con
+ char *header_ptr = header_ptr;
+ Htaccess_Proxy *proxy_entry;
+ #endif
++ xchdir(home_httpd);
+
+ /* Allocation of iobuf is postponed until now
+ * (IOW, server process doesn't need to waste 8k) */
diff --git a/package/busybox/patches/470-insmod_search.patch b/package/busybox/patches/470-insmod_search.patch
new file mode 100644
index 0000000..7f0188f
--- /dev/null
+++ b/package/busybox/patches/470-insmod_search.patch
@@ -0,0 +1,137 @@
+--- a/modutils/Config.src
++++ b/modutils/Config.src
+@@ -247,7 +247,7 @@ config FEATURE_MODUTILS_SYMBOLS
+ config DEFAULT_MODULES_DIR
+ string "Default directory containing modules"
+ default "/lib/modules"
+- depends on DEPMOD || MODPROBE || MODPROBE_SMALL || MODINFO
++ depends on DEPMOD || INSMOD || MODPROBE || MODPROBE_SMALL || MODINFO
+ help
+ Directory that contains kernel modules.
+ Defaults to "/lib/modules"
+--- a/modutils/insmod.c
++++ b/modutils/insmod.c
+@@ -11,6 +11,106 @@
+
+ #include "libbb.h"
+ #include "modutils.h"
++#include <sys/utsname.h>
++#ifndef CONFIG_FEATURE_2_4_MODULES
++#include <sys/mman.h>
++#include <asm/unistd.h>
++#include <sys/syscall.h>
++#endif
++
++static char *g_filename = NULL;
++
++static int FAST_FUNC check_module_name_match(const char *filename, struct stat *statbuf,
++ void *userdata, int depth)
++{
++ char *fullname = (char *) userdata;
++ char *tmp;
++
++ if (fullname[0] == '\0')
++ return FALSE;
++
++ tmp = bb_get_last_path_component_nostrip(filename);
++ if (strcmp(tmp, fullname) == 0) {
++ /* Stop searching if we find a match */
++ g_filename = xstrdup(filename);
++ return FALSE;
++ }
++
++ return TRUE;
++}
++
++static int find_module(char *filename)
++{
++ char *module_dir, real_module_dir[FILENAME_MAX];
++ int len, slen, ret = ENOENT, k_version;
++ struct utsname myuname;
++ const char *suffix = ".ko";
++ struct stat st;
++
++ /* check the kernel version */
++ if (uname(&myuname) != 0)
++ return EINVAL;
++
++ k_version = myuname.release[0] - '0';
++
++ if (k_version < 2 || k_version > 9)
++ return EINVAL;
++
++ if (k_version == 2) {
++ int k_patchlevel = myuname.release[2] - '0';
++ if (k_patchlevel <= 4)
++#if ENABLE_FEATURE_2_4_MODULES
++ suffix = ".o";
++#else
++ return EINVAL;
++#endif
++ }
++
++ len = strlen(filename);
++ slen = strlen(suffix);
++
++ /* check for suffix and absolute path first */
++ if ((len < slen + 2) || (strcmp(filename + len - slen, suffix) != 0)) {
++ filename = xasprintf("%s%s", filename, suffix);
++ } else {
++ filename = strdup(filename);
++ if ((stat(filename, &st) == 0) && S_ISREG(st.st_mode)) {
++ g_filename = filename;
++ return 0;
++ }
++ free(filename);
++ return ENOENT;
++ }
++
++ /* next: scan /lib/modules/<release> */
++ /* Jump through hoops in case /lib/modules/`uname -r`
++ * is a symlink. We do not want recursive_action to
++ * follow symlinks, but we do want to follow the
++ * /lib/modules/`uname -r` dir, So resolve it ourselves
++ * if it is a link... */
++ module_dir = concat_path_file(CONFIG_DEFAULT_MODULES_DIR, myuname.release);
++ if (realpath(module_dir, real_module_dir) != NULL) {
++ free(module_dir);
++ module_dir = real_module_dir;
++ }
++
++ recursive_action(module_dir, ACTION_RECURSE,
++ check_module_name_match, 0, filename, 0);
++
++ /* Check if we have a complete path */
++ if (g_filename == NULL)
++ goto done;
++
++ if ((stat(g_filename, &st) == 0) && S_ISREG(st.st_mode))
++ ret = 0;
++ else
++ free(g_filename);
++
++done:
++ free(filename);
++
++ return ret;
++}
+
+ /* 2.6 style insmod has no options and required filename
+ * (not module name - .ko can't be omitted) */
+@@ -58,9 +158,15 @@ int insmod_main(int argc UNUSED_PARAM, c
+ if (!filename)
+ bb_show_usage();
+
+- rc = bb_init_module(filename, parse_cmdline_module_options(argv, /*quote_spaces:*/ 0));
++ rc = find_module(filename);
++ if (rc || (g_filename == NULL))
++ goto done;
++
++ rc = bb_init_module(g_filename, parse_cmdline_module_options(argv, /*quote_spaces:*/ 0));
+ if (rc)
+ bb_error_msg("can't insert '%s': %s", filename, moderror(rc));
++ free (g_filename);
+
++done:
+ return rc;
+ }
diff --git a/package/busybox/patches/490-mount_disable_check.patch b/package/busybox/patches/490-mount_disable_check.patch
new file mode 100644
index 0000000..2fcb7f7
--- /dev/null
+++ b/package/busybox/patches/490-mount_disable_check.patch
@@ -0,0 +1,12 @@
+--- a/util-linux/mount.c
++++ b/util-linux/mount.c
+@@ -128,9 +128,6 @@
+ #if ENABLE_FEATURE_MOUNT_NFS
+ /* This is just a warning of a common mistake. Possibly this should be a
+ * uclibc faq entry rather than in busybox... */
+-# if defined(__UCLIBC__) && ! defined(__UCLIBC_HAS_RPC__)
+-# error "You need to build uClibc with UCLIBC_HAS_RPC for NFS support"
+-# endif
+ # include <rpc/rpc.h>
+ # include <rpc/pmap_prot.h>
+ # include <rpc/pmap_clnt.h>
diff --git a/package/busybox/patches/510-awk_include.patch b/package/busybox/patches/510-awk_include.patch
new file mode 100644
index 0000000..9f525ac
--- /dev/null
+++ b/package/busybox/patches/510-awk_include.patch
@@ -0,0 +1,217 @@
+--- a/editors/awk.c
++++ b/editors/awk.c
+@@ -1,3 +1,4 @@
++
+ /* vi: set sw=4 ts=4: */
+ /*
+ * awk implementation for busybox
+@@ -81,9 +82,14 @@ typedef struct chain_s {
+ } chain;
+
+ /* Function */
++typedef var *(*awk_cfunc)(var *res, var *args, int nargs);
+ typedef struct func_s {
+ unsigned nargs;
++ enum { AWKFUNC, CFUNC } type;
++ union {
++ awk_cfunc cfunc;
+ struct chain_s body;
++ } x;
+ } func;
+
+ /* I/O stream */
+@@ -1473,7 +1479,8 @@ static void parse_program(char *p)
+ next_token(TC_FUNCTION);
+ g_pos++;
+ f = newfunc(t_string);
+- f->body.first = NULL;
++ f->type = AWKFUNC;
++ f->x.body.first = NULL;
+ f->nargs = 0;
+ while (next_token(TC_VARIABLE | TC_SEQTERM) & TC_VARIABLE) {
+ v = findvar(ahash, t_string);
+@@ -1482,7 +1489,7 @@ static void parse_program(char *p)
+ if (next_token(TC_COMMA | TC_SEQTERM) & TC_SEQTERM)
+ break;
+ }
+- seq = &f->body;
++ seq = &f->x.body;
+ chain_group();
+ clear_array(ahash);
+
+@@ -2580,7 +2587,8 @@ static var *evaluate(node *op, var *res)
+ var *vbeg, *v;
+ const char *sv_progname;
+
+- if (!op->r.f->body.first)
++ if ((op->r.f->type == AWKFUNC) &&
++ !op->r.f->x.body.first)
+ syntax_error(EMSG_UNDEF_FUNC);
+
+ vbeg = v = nvalloc(op->r.f->nargs + 1);
+@@ -2597,7 +2605,10 @@ static var *evaluate(node *op, var *res)
+ fnargs = vbeg;
+ sv_progname = g_progname;
+
+- res = evaluate(op->r.f->body.first, res);
++ if (op->r.f->type == AWKFUNC)
++ res = evaluate(op->r.f->x.body.first, res);
++ else if (op->r.f->type == CFUNC)
++ res = op->r.f->x.cfunc(res, fnargs, op->r.f->nargs);
+
+ g_progname = sv_progname;
+ nvfree(fnargs);
+@@ -2991,6 +3002,143 @@ static rstream *next_input_file(void)
+ #undef files_happen
+ }
+
++/* read the contents of an entire file */
++static char *get_file(const char *fname)
++{
++ FILE *F;
++ char *s = NULL;
++ int i, j, flen;
++
++ F = fopen(fname, "r");
++ if (!F) {
++ return NULL;
++ }
++
++ if (fseek(F, 0, SEEK_END) == 0) {
++ flen = ftell(F);
++ s = (char *)xmalloc(flen+4);
++ fseek(F, 0, SEEK_SET);
++ i = 1 + fread(s+1, 1, flen, F);
++ } else {
++ for (i=j=1; j>0; i+=j) {
++ s = (char *)xrealloc(s, i+4096);
++ j = fread(s+i, 1, 4094, F);
++ }
++ }
++
++ s[i] = '\0';
++ fclose(F);
++ return s;
++}
++
++
++/* parse_include():
++ *
++ * taken from parse_program from awk.c
++ * END{} is not parsed here, and BEGIN{} is executed immediately
++ */
++static void parse_include(char *p)
++{
++ uint32_t tclass;
++ chain *initseq = NULL;
++ chain tmp;
++ func *f;
++ var *v, *tv;
++
++ tv = nvalloc(1);
++ memset(&tmp, 0, sizeof(tmp));
++ g_pos = p;
++ t_lineno = 1;
++ while ((tclass = next_token(TC_EOF | TC_OPSEQ |
++ TC_OPTERM | TC_BEGIN | TC_FUNCDECL)) != TC_EOF) {
++ if (tclass & TC_OPTERM)
++ continue;
++
++ seq = &tmp;
++ if (tclass & TC_BEGIN) {
++ initseq = xzalloc(sizeof(chain));
++ seq = initseq;
++ chain_group();
++ } else if (tclass & TC_FUNCDECL) {
++ next_token(TC_FUNCTION);
++ g_pos++;
++ f = newfunc(t_string);
++ f->type = AWKFUNC;
++ f->x.body.first = NULL;
++ f->nargs = 0;
++ while (next_token(TC_VARIABLE | TC_SEQTERM) & TC_VARIABLE) {
++ v = findvar(ahash, t_string);
++ v->x.aidx = (f->nargs)++;
++
++ if (next_token(TC_COMMA | TC_SEQTERM) & TC_SEQTERM)
++ break;
++ }
++ seq = &(f->x.body);
++ chain_group();
++ clear_array(ahash);
++ }
++ }
++ if (initseq && initseq->first)
++ tv = evaluate(initseq->first, tv);
++ nvfree(tv);
++}
++
++
++/* include an awk file and run its BEGIN{} section */
++static xhash *includes = NULL;
++static void include_file(const char *filename)
++{
++ char *s;
++ var *v;
++ int oldlnr = g_lineno;
++ const char *oldprg = g_progname;
++
++ if (!includes)
++ includes = hash_init();
++
++ /* find out if the file has been included already */
++ v = findvar(includes, filename);
++ if (istrue(v))
++ return;
++ setvar_s(v, "1");
++
++ /* read include file */
++ s = get_file(filename);
++ if (!s) {
++ fprintf(stderr, "Could not open file.\n");
++ return;
++ }
++ g_lineno = 1;
++ g_progname = xstrdup(filename);
++ parse_include(s+1);
++ free(s);
++ g_lineno = oldlnr;
++ g_progname = oldprg;
++}
++
++static var *include(var *res, var *args, int nargs)
++{
++ const char *s;
++
++ nargs = nargs; /* shut up, gcc */
++ s = getvar_s(args);
++ if (s && (strlen(s) > 0))
++ include_file(s);
++
++ return res;
++}
++
++/* registers a global c function for the awk interpreter */
++static void register_cfunc(const char *name, awk_cfunc cfunc, int nargs)
++{
++ func *f;
++
++ f = newfunc(name);
++ f->type = CFUNC;
++ f->x.cfunc = cfunc;
++ f->nargs = nargs;
++}
++
+ int awk_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
+ int awk_main(int argc, char **argv)
+ {
+@@ -3056,6 +3204,9 @@ int awk_main(int argc, char **argv)
+ *s1 = '=';
+ }
+ }
++
++ register_cfunc("include", include, 1);
++
+ opt_complementary = "v::f::"; /* -v and -f can occur multiple times */
+ opt = getopt32(argv, "F:v:f:W:", &opt_F, &list_v, &list_f, &opt_W);
+ argv += optind;
diff --git a/package/busybox/patches/524-udhcpc_renew.patch b/package/busybox/patches/524-udhcpc_renew.patch
new file mode 100644
index 0000000..c22fa52
--- /dev/null
+++ b/package/busybox/patches/524-udhcpc_renew.patch
@@ -0,0 +1,10 @@
+--- a/networking/udhcp/dhcpc.c
++++ b/networking/udhcp/dhcpc.c
+@@ -1045,7 +1045,6 @@ static void perform_renew(void)
+ state = RENEW_REQUESTED;
+ break;
+ case RENEW_REQUESTED: /* impatient are we? fine, square 1 */
+- udhcp_run_script(NULL, "deconfig");
+ case REQUESTING:
+ case RELEASED:
+ change_listen_mode(LISTEN_RAW);
diff --git a/package/busybox/patches/610-ntpd_delayed_resolve.patch b/package/busybox/patches/610-ntpd_delayed_resolve.patch
new file mode 100644
index 0000000..5e17ae1
--- /dev/null
+++ b/package/busybox/patches/610-ntpd_delayed_resolve.patch
@@ -0,0 +1,48 @@
+--- a/networking/ntpd.c
++++ b/networking/ntpd.c
+@@ -216,6 +216,7 @@ typedef struct {
+ typedef struct {
+ len_and_sockaddr *p_lsa;
+ char *p_dotted;
++ char *p_hostname;
+ /* when to send new query (if p_fd == -1)
+ * or when receive times out (if p_fd >= 0): */
+ int p_fd;
+@@ -646,8 +647,9 @@ add_peers(char *s)
+ peer_t *p;
+
+ p = xzalloc(sizeof(*p));
+- p->p_lsa = xhost2sockaddr(s, 123);
+- p->p_dotted = xmalloc_sockaddr2dotted_noport(&p->p_lsa->u.sa);
++ p->p_hostname = s;
++ p->p_lsa = NULL;
++ p->p_dotted = NULL;
+ p->p_fd = -1;
+ p->p_xmt_msg.m_status = MODE_CLIENT | (NTP_VERSION << 3);
+ p->next_action_time = G.cur_time; /* = set_next(p, 0); */
+@@ -696,6 +698,25 @@ send_query_to_peer(peer_t *p)
+ *
+ * Uncomment this and use strace to see it in action:
+ */
++
++ /* See if the peer hostname already resolved yet, if not, retry to resolv and return on failure */
++ if (!p->p_lsa)
++ {
++ p->p_lsa = host2sockaddr(p->p_hostname, 123);
++
++ if (p->p_lsa)
++ {
++ p->p_dotted = xmalloc_sockaddr2dotted_noport(&p->p_lsa->u.sa);
++ VERB1 bb_error_msg("resolved peer %s to %s", p->p_hostname, p->p_dotted);
++ }
++ else
++ {
++ set_next(p, RETRY_INTERVAL);
++ VERB1 bb_error_msg("could not resolve peer %s, skipping", p->p_hostname);
++ return;
++ }
++ }
++
+ #define PROBE_LOCAL_ADDR /* { len_and_sockaddr lsa; lsa.len = LSA_SIZEOF_SA; getsockname(p->query.fd, &lsa.u.sa, &lsa.len); } */
+
+ if (p->p_fd == -1) {
diff --git a/package/busybox/patches/611-upstream_ntpd_version_fix.patch b/package/busybox/patches/611-upstream_ntpd_version_fix.patch
new file mode 100644
index 0000000..7bcb847
--- /dev/null
+++ b/package/busybox/patches/611-upstream_ntpd_version_fix.patch
@@ -0,0 +1,29 @@
+From b7841cf7b919b16d1bd4619154bf7cb4c22b4ccd Mon Sep 17 00:00:00 2001
+From: Paul Marks <paul@pmarks.net>
+Date: Mon, 14 Jan 2013 01:39:10 +0000
+Subject: ntpd: fix incorrect m_status field in outgoing packets. Closes 5120
+
+When using busybox ntpd with an NTPv3 client and NTPv4 server (or vice
+versa), the version numbers can be incorrectly ORed together, yielding
+the bogus value of "NTPv7". This makes ntpd unusable with clients
+such as Chrony and Windows "Internet Time".
+
+This patch avoids the version mangling, by copying only the Leap
+Indicator bits from the server's status field.
+
+Signed-off-by: Paul Marks <paul@pmarks.net>
+Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
+---
+(limited to 'networking/ntpd.c')
+
+--- a/networking/ntpd.c
++++ b/networking/ntpd.c
+@@ -1794,7 +1794,7 @@ recv_and_process_client_pkt(void /*int f
+
+ /* Build a reply packet */
+ memset(&msg, 0, sizeof(msg));
+- msg.m_status = G.stratum < MAXSTRAT ? G.ntp_status : LI_ALARM;
++ msg.m_status = G.stratum < MAXSTRAT ? (G.ntp_status & LI_MASK) : LI_ALARM;
+ msg.m_status |= (query_status & VERSION_MASK);
+ msg.m_status |= ((query_status & MODE_MASK) == MODE_CLIENT) ?
+ MODE_SERVER : MODE_SYM_PAS;
diff --git a/package/busybox/patches/700-hexdump_segfault_fix.patch b/package/busybox/patches/700-hexdump_segfault_fix.patch
new file mode 100644
index 0000000..ab09fb3
--- /dev/null
+++ b/package/busybox/patches/700-hexdump_segfault_fix.patch
@@ -0,0 +1,11 @@
+--- a/libbb/dump.c
++++ b/libbb/dump.c
+@@ -301,7 +301,7 @@ static NOINLINE void rewrite(priv_dumper
+ ) {
+ fu->reps += (dumper->blocksize - fs->bcnt) / fu->bcnt;
+ }
+- if (fu->reps > 1) {
++ if (fu->reps > 1 && fu->nextpr) {
+ for (pr = fu->nextpr;; pr = pr->nextpr)
+ if (!pr->nextpr)
+ break;
diff --git a/package/busybox/patches/802-brctl_linux24.patch b/package/busybox/patches/802-brctl_linux24.patch
new file mode 100644
index 0000000..8cc1977
--- /dev/null
+++ b/package/busybox/patches/802-brctl_linux24.patch
@@ -0,0 +1,74 @@
+--- a/networking/brctl.c
++++ b/networking/brctl.c
+@@ -56,7 +56,7 @@
+
+ /* Maximum number of ports supported per bridge interface. */
+ #ifndef MAX_PORTS
+-# define MAX_PORTS 32
++# define MAX_PORTS 1024
+ #endif
+
+ /* Use internal number parsing and not the "exact" conversion. */
+@@ -193,6 +193,7 @@ int brctl_main(int argc UNUSED_PARAM, ch
+ printf(bi.stp_enabled ? "\tyes" : "\tno");
+
+ /* print interface list */
++ memset(ifidx, 0, sizeof ifidx);
+ arm_ioctl(args, BRCTL_GET_PORT_LIST,
+ (unsigned long) ifidx, MAX_PORTS);
+ xioctl(fd, SIOCDEVPRIVATE, &ifr);
+@@ -221,9 +222,19 @@ int brctl_main(int argc UNUSED_PARAM, ch
+ br = *argv++;
+
+ if (key == ARG_addbr || key == ARG_delbr) { /* addbr or delbr */
+- ioctl_or_perror_and_die(fd,
+- key == ARG_addbr ? SIOCBRADDBR : SIOCBRDELBR,
+- br, "bridge %s", br);
++ int ret;
++ ret = ioctl(fd,
++ key == ARG_addbr ? SIOCBRADDBR : SIOCBRDELBR,
++ br);
++ if (ret < 0) {
++ arm_ioctl(args,
++ key == ARG_addbr ? BRCTL_ADD_BRIDGE : BRCTL_DEL_BRIDGE,
++ (unsigned long) br, 0);
++ ret = ioctl(fd, SIOCSIFBR, args);
++ }
++ if (ret < 0) {
++ bb_perror_msg_and_die("bridge %s", br);
++ }
+ goto done;
+ }
+
+@@ -232,14 +243,27 @@ int brctl_main(int argc UNUSED_PARAM, ch
+
+ strncpy_IFNAMSIZ(ifr.ifr_name, br);
+ if (key == ARG_addif || key == ARG_delif) { /* addif or delif */
++ int ret;
++ int if_index;
+ brif = *argv;
+- ifr.ifr_ifindex = if_nametoindex(brif);
+- if (!ifr.ifr_ifindex) {
++ if_index = if_nametoindex(brif);
++ if (!if_index) {
+ bb_perror_msg_and_die("iface %s", brif);
+ }
+- ioctl_or_perror_and_die(fd,
++ ifr.ifr_ifindex = if_index;
++ ret = ioctl(fd,
+ key == ARG_addif ? SIOCBRADDIF : SIOCBRDELIF,
+- &ifr, "bridge %s", br);
++ &ifr);
++ if (ret < 0) {
++ arm_ioctl(args,
++ key == ARG_addif ? BRCTL_ADD_IF : BRCTL_DEL_IF,
++ if_index, 0);
++ ifr.ifr_data = (char *) &args;
++ ret = ioctl(fd, SIOCDEVPRIVATE, &ifr);
++ }
++ if (ret < 0) {
++ bb_perror_msg_and_die("bridge %s", br);
++ }
+ goto done_next_argv;
+ }
+ #if ENABLE_FEATURE_BRCTL_FANCY
diff --git a/package/busybox/patches/902-telnetd_intr.patch b/package/busybox/patches/902-telnetd_intr.patch
new file mode 100644
index 0000000..862ece0
--- /dev/null
+++ b/package/busybox/patches/902-telnetd_intr.patch
@@ -0,0 +1,10 @@
+--- a/networking/telnetd.c
++++ b/networking/telnetd.c
+@@ -330,6 +330,7 @@ make_new_session(
+
+ /* Restore default signal handling ASAP */
+ bb_signals((1 << SIGCHLD) + (1 << SIGPIPE), SIG_DFL);
++ signal(SIGINT, SIG_DFL);
+
+ pid = getpid();
+
diff --git a/package/busybox/patches/910-insmod-q-flag.patch b/package/busybox/patches/910-insmod-q-flag.patch
new file mode 100644
index 0000000..6002f20
--- /dev/null
+++ b/package/busybox/patches/910-insmod-q-flag.patch
@@ -0,0 +1,33 @@
+--- a/modutils/insmod.c
++++ b/modutils/insmod.c
+@@ -139,7 +139,7 @@ int insmod_main(int argc, char **argv) M
+ int insmod_main(int argc UNUSED_PARAM, char **argv)
+ {
+ char *filename;
+- int rc;
++ int rc, opt;
+
+ /* Compat note:
+ * 2.6 style insmod has no options and required filename
+@@ -149,10 +149,8 @@ int insmod_main(int argc UNUSED_PARAM, c
+ * or in $MODPATH.
+ */
+
+- IF_FEATURE_2_4_MODULES(
+- getopt32(argv, INSMOD_OPTS INSMOD_ARGS);
+- argv += optind - 1;
+- );
++ opt = getopt32(argv, INSMOD_OPTS, NULL, NULL);
++ argv += optind - 1;
+
+ filename = *++argv;
+ if (!filename)
+@@ -163,7 +161,7 @@ int insmod_main(int argc UNUSED_PARAM, c
+ goto done;
+
+ rc = bb_init_module(g_filename, parse_cmdline_module_options(argv, /*quote_spaces:*/ 0));
+- if (rc)
++ if (rc && !(opt & INSMOD_OPT_SILENT))
+ bb_error_msg("can't insert '%s': %s", filename, moderror(rc));
+ free (g_filename);
+
diff --git a/package/busybox/patches/911-date-k-flag.patch b/package/busybox/patches/911-date-k-flag.patch
new file mode 100644
index 0000000..c55ee23
--- /dev/null
+++ b/package/busybox/patches/911-date-k-flag.patch
@@ -0,0 +1,87 @@
+--- a/coreutils/date.c
++++ b/coreutils/date.c
+@@ -123,6 +123,7 @@
+ //usage: IF_FEATURE_DATE_ISOFMT(
+ //usage: "\n -D FMT Use FMT for -d TIME conversion"
+ //usage: )
++//usage: "\n -k Set Kernel timezone from localtime and exit"
+ //usage: "\n"
+ //usage: "\nRecognized TIME formats:"
+ //usage: "\n hh:mm[:ss]"
+@@ -135,6 +136,7 @@
+ //usage: "Wed Apr 12 18:52:41 MDT 2000\n"
+
+ #include "libbb.h"
++#include <sys/time.h>
+ #if ENABLE_FEATURE_DATE_NANO
+ # include <sys/syscall.h>
+ #endif
+@@ -145,8 +147,9 @@ enum {
+ OPT_UTC = (1 << 2), /* u */
+ OPT_DATE = (1 << 3), /* d */
+ OPT_REFERENCE = (1 << 4), /* r */
+- OPT_TIMESPEC = (1 << 5) * ENABLE_FEATURE_DATE_ISOFMT, /* I */
+- OPT_HINT = (1 << 6) * ENABLE_FEATURE_DATE_ISOFMT, /* D */
++ OPT_KERNELTZ = (1 << 5), /* k */
++ OPT_TIMESPEC = (1 << 6) * ENABLE_FEATURE_DATE_ISOFMT, /* I */
++ OPT_HINT = (1 << 7) * ENABLE_FEATURE_DATE_ISOFMT, /* D */
+ };
+
+ static void maybe_set_utc(int opt)
+@@ -164,12 +167,15 @@ static const char date_longopts[] ALIGN1
+ /* "universal\0" No_argument "u" */
+ "date\0" Required_argument "d"
+ "reference\0" Required_argument "r"
++ "set-kernel-tz\0" No_argument "k"
+ ;
+ #endif
+
+ int date_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
+ int date_main(int argc UNUSED_PARAM, char **argv)
+ {
++ time_t tt;
++ struct timezone tz;
+ struct timespec ts;
+ struct tm tm_time;
+ char buf_fmt_dt2str[64];
+@@ -184,7 +190,7 @@ int date_main(int argc UNUSED_PARAM, cha
+ opt_complementary = "d--s:s--d"
+ IF_FEATURE_DATE_ISOFMT(":R--I:I--R");
+ IF_LONG_OPTS(applet_long_options = date_longopts;)
+- opt = getopt32(argv, "Rs:ud:r:"
++ opt = getopt32(argv, "Rs:ud:r:k"
+ IF_FEATURE_DATE_ISOFMT("I::D:"),
+ &date_str, &date_str, &filename
+ IF_FEATURE_DATE_ISOFMT(, &isofmt_arg, &fmt_str2dt));
+@@ -241,6 +247,31 @@ int date_main(int argc UNUSED_PARAM, cha
+ if (*argv)
+ bb_show_usage();
+
++ /* Setting of kernel timezone was requested */
++ if (opt & OPT_KERNELTZ) {
++ tt = time(NULL);
++ localtime_r(&tt, &tm_time);
++
++ /* workaround warp_clock() on first invocation */
++ memset(&tz, 0, sizeof(tz));
++ settimeofday(NULL, &tz);
++
++ memset(&tz, 0, sizeof(tz));
++#ifdef __USE_BSD
++ tz.tz_minuteswest = -(tm_time.tm_gmtoff / 60);
++#else
++ tz.tz_minuteswest = -(tm_time.__tm_gmtoff / 60);
++#endif
++
++ if (settimeofday(NULL, &tz))
++ {
++ bb_perror_msg("can't set kernel time zone");
++ return EXIT_FAILURE;
++ }
++
++ return EXIT_SUCCESS;
++ }
++
+ /* Now we have parsed all the information except the date format
+ * which depends on whether the clock is being set or read */
+
diff --git a/package/busybox/patches/920-portability.patch b/package/busybox/patches/920-portability.patch
new file mode 100644
index 0000000..4e5b9a0
--- /dev/null
+++ b/package/busybox/patches/920-portability.patch
@@ -0,0 +1,13 @@
+--- a/scripts/kconfig/mconf.c
++++ b/scripts/kconfig/mconf.c
+@@ -25,6 +25,10 @@
+ #include <unistd.h>
+ #include <locale.h>
+
++#ifndef SIGWINCH
++#define SIGWINCH 28
++#endif
++
+ #define LKC_DIRECT_LINK
+ #include "lkc.h"
+
diff --git a/package/busybox/patches/950-partial-checksum.patch b/package/busybox/patches/950-partial-checksum.patch
new file mode 100644
index 0000000..6e8a69e
--- /dev/null
+++ b/package/busybox/patches/950-partial-checksum.patch
@@ -0,0 +1,86 @@
+--- a/networking/udhcp/dhcpc.c
++++ b/networking/udhcp/dhcpc.c
+@@ -26,8 +26,8 @@
+ #include "dhcpc.h"
+
+ #include <netinet/if_ether.h>
+-#include <netpacket/packet.h>
+ #include <linux/filter.h>
++#include <linux/if_packet.h>
+
+ /* struct client_config_t client_config is in bb_common_bufsiz1 */
+
+@@ -846,17 +846,41 @@ static int send_release(uint32_t server,
+ static NOINLINE int udhcp_recv_raw_packet(struct dhcp_packet *dhcp_pkt, int fd)
+ {
+ int bytes;
++ int nocsum = 0;
+ struct ip_udp_dhcp_packet packet;
+ uint16_t check;
++ unsigned char cmsgbuf[CMSG_LEN(sizeof(struct tpacket_auxdata))];
++ struct iovec iov = {
++ .iov_base = &packet,
++ .iov_len = sizeof(packet),
++ };
++ struct msghdr msg = {
++ .msg_iov = &iov,
++ .msg_iovlen = 1,
++ .msg_control = cmsgbuf,
++ .msg_controllen = sizeof(cmsgbuf),
++ };
++ struct cmsghdr *cmsg;
+
+ memset(&packet, 0, sizeof(packet));
+- bytes = safe_read(fd, &packet, sizeof(packet));
++ do {
++ bytes = recvmsg(fd, &msg, 0);
++ } while (bytes < 0 && errno == EINTR);
++
+ if (bytes < 0) {
+ log1("Packet read error, ignoring");
+ /* NB: possible down interface, etc. Caller should pause. */
+ return bytes; /* returns -1 */
+ }
+
++ for (cmsg = CMSG_FIRSTHDR(&msg); cmsg; cmsg = CMSG_NXTHDR(&msg, cmsg)) {
++ if (cmsg->cmsg_level == SOL_PACKET &&
++ cmsg->cmsg_type == PACKET_AUXDATA) {
++ struct tpacket_auxdata *aux = (void *)CMSG_DATA(cmsg);
++ nocsum = aux->tp_status & TP_STATUS_CSUMNOTREADY;
++ }
++ }
++
+ if (bytes < (int) (sizeof(packet.ip) + sizeof(packet.udp))) {
+ log1("Packet is too short, ignoring");
+ return -2;
+@@ -896,7 +920,7 @@ static NOINLINE int udhcp_recv_raw_packe
+ packet.ip.tot_len = packet.udp.len; /* yes, this is needed */
+ check = packet.udp.check;
+ packet.udp.check = 0;
+- if (check && check != udhcp_checksum(&packet, bytes)) {
++ if (!nocsum && check && check != udhcp_checksum(&packet, bytes)) {
+ log1("Packet with bad UDP checksum received, ignoring");
+ return -2;
+ }
+@@ -942,6 +966,7 @@ static int udhcp_raw_socket(int ifindex)
+ {
+ int fd;
+ struct sockaddr_ll sock;
++ int val;
+
+ /*
+ * Comment:
+@@ -1008,6 +1033,13 @@ static int udhcp_raw_socket(int ifindex)
+ log1("Attached filter to raw socket fd %d", fd); // log?
+ }
+
++ val = 1;
++ if (setsockopt(fd, SOL_PACKET, PACKET_AUXDATA, &val,
++ sizeof(val)) < 0) {
++ if (errno != ENOPROTOOPT)
++ log1("Failed to set auxiliary packet data for socket fd %d", fd);
++ }
++
+ log1("Created raw socket");
+
+ return fd;
diff --git a/package/busybox/patches/998-arping_missing_includes.patch b/package/busybox/patches/998-arping_missing_includes.patch
new file mode 100644
index 0000000..a9d4a62
--- /dev/null
+++ b/package/busybox/patches/998-arping_missing_includes.patch
@@ -0,0 +1,11 @@
+--- a/networking/arping.c
++++ b/networking/arping.c
+@@ -24,6 +24,8 @@
+
+ #include <arpa/inet.h>
+ #include <net/if.h>
++#include <net/if_arp.h>
++#include <netinet/if_ether.h>
+ #include <netinet/ether.h>
+ #include <netpacket/packet.h>
+
diff --git a/package/busybox/patches/999-musl-fixes.patch b/package/busybox/patches/999-musl-fixes.patch
new file mode 100644
index 0000000..b528b3e
--- /dev/null
+++ b/package/busybox/patches/999-musl-fixes.patch
@@ -0,0 +1,16 @@
+--- a/include/platform.h
++++ b/include/platform.h
+@@ -443,6 +443,13 @@ typedef unsigned smalluint;
+ # undef HAVE_NET_ETHERNET_H
+ #endif
+
++#if defined(__musl__)
++# undef HAVE_SETBIT
++# include <stddef.h>
++# include <termios.h>
++# include <sys/ioctl.h>
++#endif
++
+ /*
+ * Now, define prototypes for all the functions defined in platform.c
+ * These must come after all the HAVE_* macros are defined (or not)
diff --git a/package/devel/.svn/entries b/package/devel/.svn/entries
new file mode 100644
index 0000000..7e19dda
--- /dev/null
+++ b/package/devel/.svn/entries
@@ -0,0 +1,43 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/devel
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-02-26T16:39:59.198966Z
+35809
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+oprofile
+dir
+
+trace-cmd
+dir
+
+valgrind
+dir
+
+binutils
+dir
+
+gdb
+dir
+
diff --git a/package/devel/binutils/.svn/entries b/package/devel/binutils/.svn/entries
new file mode 100644
index 0000000..e9ab2ca
--- /dev/null
+++ b/package/devel/binutils/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/devel/binutils
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-10T13:26:27.622493Z
+33705
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+e845b2262528bd7203a09deaf9c4d27a
+2012-10-10T13:26:27.622493Z
+33705
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2754
+
diff --git a/package/devel/binutils/.svn/text-base/Makefile.svn-base b/package/devel/binutils/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..09710d4
--- /dev/null
+++ b/package/devel/binutils/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,115 @@
+#
+# Copyright (C) 2006-2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=binutils
+PKG_VERSION:=$(strip $(subst ",, $(CONFIG_BINUTILS_VERSION)))
+#"))
+PKG_RELEASE:=5
+
+PKG_SOURCE_URL:=@GNU/binutils
+PKG_SOURCE:=binutils-$(PKG_VERSION).tar.bz2
+PKG_MD5SUM:=
+
+PATCH_DIR:=$(TOPDIR)/toolchain/binutils/patches/$(PKG_VERSION)
+
+PKG_FIXUP:=autoreconf
+PKG_LIBTOOL_PATHS:=. gas bfd opcodes gprof binutils ld libiberty gold intl
+PKG_REMOVE_FILES:=libtool.m4
+PKG_INSTALL:=1
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+
+PKG_BUILD_PARALLEL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/binutils
+ SECTION:=devel
+ CATEGORY:=Development
+ TITLE:=binutils
+ DEPENDS:=+objdump
+endef
+
+define Package/objdump
+ SECTION:=devel
+ CATEGORY:=Development
+ TITLE:=objdump
+ DEPENDS:=+zlib
+endef
+
+define Package/binutils/description
+ The Binutils package contains a linker, an assembler, and other tools for handling object files
+endef
+
+CONFIGURE_ARGS = \
+ --target=$(REAL_GNU_TARGET_NAME) \
+ --host=$(REAL_GNU_TARGET_NAME) \
+ --build=$(GNU_HOST_NAME) \
+ --prefix=/usr \
+ --disable-multilib \
+ --disable-werror \
+ --disable-nls \
+ --enable-shared \
+ $(SOFT_FLOAT_CONFIG_OPTION) \
+ $(call qstrip,$(CONFIG_EXTRA_BINUTILS_CONFIG_OPTIONS))
+
+TARGET_CFLAGS += $(FPIC)
+TARGET_LDFLAGS := -L$(PKG_BUILD_DIR)/libiberty $(TARGET_LDFLAGS)
+
+define Build/Configure
+ $(call Build/Configure/Default)
+ $(call Build/Compile/Default, \
+ configure-bfd \
+ configure-binutils \
+ configure-etc \
+ configure-gas \
+ configure-gprof \
+ configure-intl \
+ configure-ld \
+ configure-libiberty \
+ configure-opcodes \
+ )
+ $(MAKE) CFLAGS="$(TARGET_CFLAGS)" -C $(PKG_BUILD_DIR)/bfd/po Makefile
+endef
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/{lib,include}
+ $(CP) \
+ $(PKG_INSTALL_DIR)/usr/lib/* \
+ $(1)/usr/lib/
+ $(CP) \
+ $(PKG_BUILD_DIR)/include/*.h \
+ $(1)/usr/include/
+ $(CP) \
+ $(PKG_INSTALL_DIR)/usr/include/* \
+ $(1)/usr/include/
+ rm -f $(1)/usr/include/gdbm.h
+endef
+
+define Build/Compile
+ +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR)/bfd/doc/ CFLAGS="-I$(PKG_BUILD_DIR)/include" chew
+ $(call Build/Compile/Default)
+endef
+
+define Package/objdump/install
+ $(INSTALL_DIR) $(1)/usr/bin $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/bin/objdump $(1)/usr/bin/
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libopcodes*.so $(1)/usr/lib/
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libbfd*.so $(1)/usr/lib/
+endef
+
+define Package/binutils/install
+ $(INSTALL_DIR) $(1)/usr $(1)/bin
+ $(CP) $(PKG_INSTALL_DIR)/usr/bin/ $(1)/usr/
+ mv $(1)/usr/bin/strings $(1)/bin/strings
+ rm -f $(1)/usr/bin/objdump
+endef
+
+$(eval $(call BuildPackage,binutils))
+$(eval $(call BuildPackage,objdump))
diff --git a/package/devel/binutils/Makefile b/package/devel/binutils/Makefile
new file mode 100644
index 0000000..09710d4
--- /dev/null
+++ b/package/devel/binutils/Makefile
@@ -0,0 +1,115 @@
+#
+# Copyright (C) 2006-2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=binutils
+PKG_VERSION:=$(strip $(subst ",, $(CONFIG_BINUTILS_VERSION)))
+#"))
+PKG_RELEASE:=5
+
+PKG_SOURCE_URL:=@GNU/binutils
+PKG_SOURCE:=binutils-$(PKG_VERSION).tar.bz2
+PKG_MD5SUM:=
+
+PATCH_DIR:=$(TOPDIR)/toolchain/binutils/patches/$(PKG_VERSION)
+
+PKG_FIXUP:=autoreconf
+PKG_LIBTOOL_PATHS:=. gas bfd opcodes gprof binutils ld libiberty gold intl
+PKG_REMOVE_FILES:=libtool.m4
+PKG_INSTALL:=1
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+
+PKG_BUILD_PARALLEL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/binutils
+ SECTION:=devel
+ CATEGORY:=Development
+ TITLE:=binutils
+ DEPENDS:=+objdump
+endef
+
+define Package/objdump
+ SECTION:=devel
+ CATEGORY:=Development
+ TITLE:=objdump
+ DEPENDS:=+zlib
+endef
+
+define Package/binutils/description
+ The Binutils package contains a linker, an assembler, and other tools for handling object files
+endef
+
+CONFIGURE_ARGS = \
+ --target=$(REAL_GNU_TARGET_NAME) \
+ --host=$(REAL_GNU_TARGET_NAME) \
+ --build=$(GNU_HOST_NAME) \
+ --prefix=/usr \
+ --disable-multilib \
+ --disable-werror \
+ --disable-nls \
+ --enable-shared \
+ $(SOFT_FLOAT_CONFIG_OPTION) \
+ $(call qstrip,$(CONFIG_EXTRA_BINUTILS_CONFIG_OPTIONS))
+
+TARGET_CFLAGS += $(FPIC)
+TARGET_LDFLAGS := -L$(PKG_BUILD_DIR)/libiberty $(TARGET_LDFLAGS)
+
+define Build/Configure
+ $(call Build/Configure/Default)
+ $(call Build/Compile/Default, \
+ configure-bfd \
+ configure-binutils \
+ configure-etc \
+ configure-gas \
+ configure-gprof \
+ configure-intl \
+ configure-ld \
+ configure-libiberty \
+ configure-opcodes \
+ )
+ $(MAKE) CFLAGS="$(TARGET_CFLAGS)" -C $(PKG_BUILD_DIR)/bfd/po Makefile
+endef
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/{lib,include}
+ $(CP) \
+ $(PKG_INSTALL_DIR)/usr/lib/* \
+ $(1)/usr/lib/
+ $(CP) \
+ $(PKG_BUILD_DIR)/include/*.h \
+ $(1)/usr/include/
+ $(CP) \
+ $(PKG_INSTALL_DIR)/usr/include/* \
+ $(1)/usr/include/
+ rm -f $(1)/usr/include/gdbm.h
+endef
+
+define Build/Compile
+ +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR)/bfd/doc/ CFLAGS="-I$(PKG_BUILD_DIR)/include" chew
+ $(call Build/Compile/Default)
+endef
+
+define Package/objdump/install
+ $(INSTALL_DIR) $(1)/usr/bin $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/bin/objdump $(1)/usr/bin/
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libopcodes*.so $(1)/usr/lib/
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libbfd*.so $(1)/usr/lib/
+endef
+
+define Package/binutils/install
+ $(INSTALL_DIR) $(1)/usr $(1)/bin
+ $(CP) $(PKG_INSTALL_DIR)/usr/bin/ $(1)/usr/
+ mv $(1)/usr/bin/strings $(1)/bin/strings
+ rm -f $(1)/usr/bin/objdump
+endef
+
+$(eval $(call BuildPackage,binutils))
+$(eval $(call BuildPackage,objdump))
diff --git a/package/devel/gdb/.svn/entries b/package/devel/gdb/.svn/entries
new file mode 100644
index 0000000..a3dd0b7
--- /dev/null
+++ b/package/devel/gdb/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/devel/gdb
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-02-26T16:39:59.198966Z
+35809
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+f251df7aa2f1079de8f215fddfc997f1
+2013-02-26T16:39:59.198966Z
+35809
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2056
+
diff --git a/package/devel/gdb/.svn/text-base/Makefile.svn-base b/package/devel/gdb/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..7663188
--- /dev/null
+++ b/package/devel/gdb/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,86 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=gdb
+PKG_VERSION:=7.5
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=@GNU/gdb
+PKG_MD5SUM:=24a6779a9fe0260667710de1b082ef61
+
+PKG_BUILD_PARALLEL:=1
+PKG_INSTALL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/gdb/Default
+ SECTION:=devel
+ CATEGORY:=Development
+ DEPENDS:=@!(avr32||cris) +!USE_MUSL:libthread-db +PACKAGE_zlib:zlib
+ URL:=http://www.gnu.org/software/gdb/
+endef
+
+define Package/gdb
+$(call Package/gdb/Default)
+ TITLE:=GNU Debugger
+ DEPENDS+=+libreadline +libncurses +zlib
+endef
+
+define Package/gdb/description
+GDB, the GNU Project debugger, allows you to see what is going on `inside'
+another program while it executes -- or what another program was doing at the
+moment it crashed.
+endef
+
+define Package/gdbserver
+$(call Package/gdb/Default)
+ TITLE:=Remote server for GNU Debugger
+endef
+
+define Package/gdbserver/description
+GDBSERVER is a program that allows you to run GDB on a different machine than the
+one which is running the program being debugged.
+endef
+
+# XXX: add --disable-werror to prevent build failure with arm
+CONFIGURE_ARGS+= \
+ --with-system-readline \
+ --without-expat \
+ --disable-werror
+
+CONFIGURE_VARS+= \
+ ac_cv_search_tgetent="$(TARGET_LDFLAGS) -lncurses -lreadline"
+
+define Build/Compile
+ +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
+ DESTDIR="$(PKG_INSTALL_DIR)" \
+ CPPFLAGS="$(TARGET_CPPFLAGS)" \
+ all
+endef
+
+define Build/Install
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ DESTDIR="$(PKG_INSTALL_DIR)" \
+ CPPFLAGS="$(TARGET_CPPFLAGS)" \
+ install-gdb
+endef
+
+define Package/gdb/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/gdb $(1)/usr/bin/
+endef
+
+define Package/gdbserver/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/gdbserver $(1)/usr/bin/
+endef
+
+$(eval $(call BuildPackage,gdb))
+$(eval $(call BuildPackage,gdbserver))
diff --git a/package/devel/gdb/Makefile b/package/devel/gdb/Makefile
new file mode 100644
index 0000000..7663188
--- /dev/null
+++ b/package/devel/gdb/Makefile
@@ -0,0 +1,86 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=gdb
+PKG_VERSION:=7.5
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=@GNU/gdb
+PKG_MD5SUM:=24a6779a9fe0260667710de1b082ef61
+
+PKG_BUILD_PARALLEL:=1
+PKG_INSTALL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/gdb/Default
+ SECTION:=devel
+ CATEGORY:=Development
+ DEPENDS:=@!(avr32||cris) +!USE_MUSL:libthread-db +PACKAGE_zlib:zlib
+ URL:=http://www.gnu.org/software/gdb/
+endef
+
+define Package/gdb
+$(call Package/gdb/Default)
+ TITLE:=GNU Debugger
+ DEPENDS+=+libreadline +libncurses +zlib
+endef
+
+define Package/gdb/description
+GDB, the GNU Project debugger, allows you to see what is going on `inside'
+another program while it executes -- or what another program was doing at the
+moment it crashed.
+endef
+
+define Package/gdbserver
+$(call Package/gdb/Default)
+ TITLE:=Remote server for GNU Debugger
+endef
+
+define Package/gdbserver/description
+GDBSERVER is a program that allows you to run GDB on a different machine than the
+one which is running the program being debugged.
+endef
+
+# XXX: add --disable-werror to prevent build failure with arm
+CONFIGURE_ARGS+= \
+ --with-system-readline \
+ --without-expat \
+ --disable-werror
+
+CONFIGURE_VARS+= \
+ ac_cv_search_tgetent="$(TARGET_LDFLAGS) -lncurses -lreadline"
+
+define Build/Compile
+ +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
+ DESTDIR="$(PKG_INSTALL_DIR)" \
+ CPPFLAGS="$(TARGET_CPPFLAGS)" \
+ all
+endef
+
+define Build/Install
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ DESTDIR="$(PKG_INSTALL_DIR)" \
+ CPPFLAGS="$(TARGET_CPPFLAGS)" \
+ install-gdb
+endef
+
+define Package/gdb/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/gdb $(1)/usr/bin/
+endef
+
+define Package/gdbserver/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/gdbserver $(1)/usr/bin/
+endef
+
+$(eval $(call BuildPackage,gdb))
+$(eval $(call BuildPackage,gdbserver))
diff --git a/package/devel/gdb/patches/.svn/entries b/package/devel/gdb/patches/.svn/entries
new file mode 100644
index 0000000..3f5f74f
--- /dev/null
+++ b/package/devel/gdb/patches/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/devel/gdb/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-11-19T14:38:02.668461Z
+34258
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+001-gdb-pr14523-mips-signal-number.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+c8b0cbf4a2313746496f1c3bb96ac156
+2012-11-19T14:38:02.668461Z
+34258
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+696
+
diff --git a/package/devel/gdb/patches/.svn/text-base/001-gdb-pr14523-mips-signal-number.patch.svn-base b/package/devel/gdb/patches/.svn/text-base/001-gdb-pr14523-mips-signal-number.patch.svn-base
new file mode 100644
index 0000000..c462399
--- /dev/null
+++ b/package/devel/gdb/patches/.svn/text-base/001-gdb-pr14523-mips-signal-number.patch.svn-base
@@ -0,0 +1,16 @@
+See http://sourceware.org/bugzilla/show_bug.cgi?id=14523
+---
+--- gdb-7.5.org/gdb/common/signals.c 2012-05-24 18:51:37.000000000 +0200
++++ gdb-7.5.org/gdb/common/signals.c 2012-08-29 22:32:07.000000000 +0200
+@@ -346,6 +346,11 @@
+ else if (64 <= hostsig && hostsig <= 127)
+ return (enum gdb_signal)
+ (hostsig - 64 + (int) GDB_SIGNAL_REALTIME_64);
++ else if (hostsig == 128)
++ /* Some platforms, such as Linux MIPS, have NSIG == 128, in which case
++ signal 128 is the highest realtime signal. There is no constant for
++ that though. */
++ return GDB_SIGNAL_UNKNOWN;
+ else
+ error (_("GDB bug: target.c (gdb_signal_from_host): "
+ "unrecognized real-time signal"));
diff --git a/package/devel/gdb/patches/001-gdb-pr14523-mips-signal-number.patch b/package/devel/gdb/patches/001-gdb-pr14523-mips-signal-number.patch
new file mode 100644
index 0000000..c462399
--- /dev/null
+++ b/package/devel/gdb/patches/001-gdb-pr14523-mips-signal-number.patch
@@ -0,0 +1,16 @@
+See http://sourceware.org/bugzilla/show_bug.cgi?id=14523
+---
+--- gdb-7.5.org/gdb/common/signals.c 2012-05-24 18:51:37.000000000 +0200
++++ gdb-7.5.org/gdb/common/signals.c 2012-08-29 22:32:07.000000000 +0200
+@@ -346,6 +346,11 @@
+ else if (64 <= hostsig && hostsig <= 127)
+ return (enum gdb_signal)
+ (hostsig - 64 + (int) GDB_SIGNAL_REALTIME_64);
++ else if (hostsig == 128)
++ /* Some platforms, such as Linux MIPS, have NSIG == 128, in which case
++ signal 128 is the highest realtime signal. There is no constant for
++ that though. */
++ return GDB_SIGNAL_UNKNOWN;
+ else
+ error (_("GDB bug: target.c (gdb_signal_from_host): "
+ "unrecognized real-time signal"));
diff --git a/package/devel/oprofile/.svn/entries b/package/devel/oprofile/.svn/entries
new file mode 100644
index 0000000..2879d68
--- /dev/null
+++ b/package/devel/oprofile/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/devel/oprofile
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-10T13:26:27.622493Z
+33705
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+fc4643f6dfc0641b4f04e42a3a96030d
+2012-10-10T13:26:27.622493Z
+33705
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2109
+
diff --git a/package/devel/oprofile/.svn/text-base/Makefile.svn-base b/package/devel/oprofile/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..884c54b
--- /dev/null
+++ b/package/devel/oprofile/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,91 @@
+#
+# Copyright (C) 2009-2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=oprofile
+PKG_VERSION:=0.9.7
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=@SF/oprofile/
+PKG_MD5SUM:=8b5d1d9b65f84420bcc3234777ad3be3
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+
+PKG_BUILD_DEPENDS:=binutils
+PKG_FIXUP:=autoreconf
+PKG_INSTALL:=1
+PKG_BUILD_PARALLEL:=1
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+define Package/oprofile
+ SECTION:=devel
+ CATEGORY:=Development
+ TITLE:=OProfile System Profiler
+ URL:=http://oprofile.sourceforge.net
+ DEPENDS:=+libpopt +kmod-oprofile +libstdcpp +objdump
+endef
+
+define Package/oprofile/description
+ A transparent low-overhead system-wide profiler.
+endef
+
+define Package/oprofile-utils
+ SECTION:=devel
+ CATEGORY:=Development
+ TITLE:=OProfile System Profiler (extra utilities)
+ URL:=http://oprofile.sourceforge.net
+ DEPENDS:=oprofile
+endef
+
+define Build/Configure
+ $(call Build/Configure/Default, \
+ --with-kernel-support \
+ --without-x \
+ )
+endef
+
+TARGET_CXXFLAGS += -fpermissive
+TARGET_LDFLAGS := -L$(STAGING_DIR)/usr/lib $(TARGET_LDFLAGS)
+
+define Package/oprofile-utils/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) \
+ $(PKG_INSTALL_DIR)/usr/bin/opannotate \
+ $(PKG_INSTALL_DIR)/usr/bin/oparchive \
+ $(PKG_INSTALL_DIR)/usr/bin/opgprof \
+ $(1)/usr/bin
+endef
+
+define Package/oprofile/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) \
+ $(PKG_INSTALL_DIR)/usr/bin/* \
+ $(1)/usr/bin
+
+ rm -f \
+ $(1)/usr/bin/opannotate \
+ $(1)/usr/bin/oparchive \
+ $(1)/usr/bin/opgprof
+
+ $(INSTALL_DIR) $(1)/usr/lib/oprofile
+ $(CP) \
+ $(PKG_INSTALL_DIR)/usr/lib/oprofile/*.so* \
+ $(1)/usr/lib/oprofile/
+
+ $(INSTALL_DIR) $(1)/usr/share/oprofile
+ $(CP) \
+ $(PKG_INSTALL_DIR)/usr/share/oprofile/stl.pat \
+ $(PKG_INSTALL_DIR)/usr/share/oprofile/$(patsubst x86,i386,$(LINUX_KARCH)) \
+ $(1)/usr/share/oprofile/
+endef
+
+$(eval $(call BuildPackage,oprofile))
+$(eval $(call BuildPackage,oprofile-utils))
diff --git a/package/devel/oprofile/Makefile b/package/devel/oprofile/Makefile
new file mode 100644
index 0000000..884c54b
--- /dev/null
+++ b/package/devel/oprofile/Makefile
@@ -0,0 +1,91 @@
+#
+# Copyright (C) 2009-2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=oprofile
+PKG_VERSION:=0.9.7
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=@SF/oprofile/
+PKG_MD5SUM:=8b5d1d9b65f84420bcc3234777ad3be3
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+
+PKG_BUILD_DEPENDS:=binutils
+PKG_FIXUP:=autoreconf
+PKG_INSTALL:=1
+PKG_BUILD_PARALLEL:=1
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+define Package/oprofile
+ SECTION:=devel
+ CATEGORY:=Development
+ TITLE:=OProfile System Profiler
+ URL:=http://oprofile.sourceforge.net
+ DEPENDS:=+libpopt +kmod-oprofile +libstdcpp +objdump
+endef
+
+define Package/oprofile/description
+ A transparent low-overhead system-wide profiler.
+endef
+
+define Package/oprofile-utils
+ SECTION:=devel
+ CATEGORY:=Development
+ TITLE:=OProfile System Profiler (extra utilities)
+ URL:=http://oprofile.sourceforge.net
+ DEPENDS:=oprofile
+endef
+
+define Build/Configure
+ $(call Build/Configure/Default, \
+ --with-kernel-support \
+ --without-x \
+ )
+endef
+
+TARGET_CXXFLAGS += -fpermissive
+TARGET_LDFLAGS := -L$(STAGING_DIR)/usr/lib $(TARGET_LDFLAGS)
+
+define Package/oprofile-utils/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) \
+ $(PKG_INSTALL_DIR)/usr/bin/opannotate \
+ $(PKG_INSTALL_DIR)/usr/bin/oparchive \
+ $(PKG_INSTALL_DIR)/usr/bin/opgprof \
+ $(1)/usr/bin
+endef
+
+define Package/oprofile/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) \
+ $(PKG_INSTALL_DIR)/usr/bin/* \
+ $(1)/usr/bin
+
+ rm -f \
+ $(1)/usr/bin/opannotate \
+ $(1)/usr/bin/oparchive \
+ $(1)/usr/bin/opgprof
+
+ $(INSTALL_DIR) $(1)/usr/lib/oprofile
+ $(CP) \
+ $(PKG_INSTALL_DIR)/usr/lib/oprofile/*.so* \
+ $(1)/usr/lib/oprofile/
+
+ $(INSTALL_DIR) $(1)/usr/share/oprofile
+ $(CP) \
+ $(PKG_INSTALL_DIR)/usr/share/oprofile/stl.pat \
+ $(PKG_INSTALL_DIR)/usr/share/oprofile/$(patsubst x86,i386,$(LINUX_KARCH)) \
+ $(1)/usr/share/oprofile/
+endef
+
+$(eval $(call BuildPackage,oprofile))
+$(eval $(call BuildPackage,oprofile-utils))
diff --git a/package/devel/oprofile/patches/.svn/entries b/package/devel/oprofile/patches/.svn/entries
new file mode 100644
index 0000000..7b591ca
--- /dev/null
+++ b/package/devel/oprofile/patches/.svn/entries
@@ -0,0 +1,96 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/devel/oprofile/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-03-20T01:00:43.264887Z
+31039
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+100-use_insmod_instead_of_modprobe.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+6a72010f0d238329f0b90f33e612f488
+2012-03-20T01:00:43.264887Z
+31039
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+483
+
+101-remove_24_support.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+6367480bbf7e1aa7a1aa8b2f7844f1e9
+2012-03-20T01:00:43.264887Z
+31039
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1978
+
diff --git a/package/devel/oprofile/patches/.svn/text-base/100-use_insmod_instead_of_modprobe.patch.svn-base b/package/devel/oprofile/patches/.svn/text-base/100-use_insmod_instead_of_modprobe.patch.svn-base
new file mode 100644
index 0000000..1010798
--- /dev/null
+++ b/package/devel/oprofile/patches/.svn/text-base/100-use_insmod_instead_of_modprobe.patch.svn-base
@@ -0,0 +1,20 @@
+--- a/utils/opcontrol
++++ b/utils/opcontrol
+@@ -248,7 +248,7 @@ load_module_26()
+ {
+ grep oprofilefs /proc/filesystems >/dev/null
+ if test "$?" -ne 0; then
+- modprobe oprofile
++ insmod oprofile
+ if test "$?" != "0"; then
+ # couldn't load the module
+ return
+@@ -278,7 +278,7 @@ load_module_24()
+ {
+ grep oprof /proc/devices >/dev/null
+ if test "$?" -ne 0; then
+- modprobe oprofile
++ insmod oprofile
+ if test "$?" != "0"; then
+ # couldn't load a module
+ return
diff --git a/package/devel/oprofile/patches/.svn/text-base/101-remove_24_support.patch.svn-base b/package/devel/oprofile/patches/.svn/text-base/101-remove_24_support.patch.svn-base
new file mode 100644
index 0000000..99eb928
--- /dev/null
+++ b/package/devel/oprofile/patches/.svn/text-base/101-remove_24_support.patch.svn-base
@@ -0,0 +1,64 @@
+--- a/daemon/Makefile.am
++++ b/daemon/Makefile.am
+@@ -1,4 +1,4 @@
+-SUBDIRS = liblegacy .
++SUBDIRS = .
+
+ oprofiled_SOURCES = \
+ init.c \
+@@ -49,7 +49,6 @@ AM_CFLAGS = @OP_CFLAGS@ -fno-omit-frame-
+ bin_PROGRAMS = oprofiled
+
+ oprofiled_LDADD = \
+- liblegacy/liblegacy.a \
+ ../libabi/libabi.a \
+ ../libdb/libodb.a \
+ ../libop/libop.a \
+--- a/daemon/Makefile.in
++++ b/daemon/Makefile.in
+@@ -70,7 +70,7 @@ am_oprofiled_OBJECTS = init.$(OBJEXT) op
+ opd_extended.$(OBJEXT) opd_ibs.$(OBJEXT) \
+ opd_ibs_trans.$(OBJEXT)
+ oprofiled_OBJECTS = $(am_oprofiled_OBJECTS)
+-oprofiled_DEPENDENCIES = liblegacy/liblegacy.a ../libabi/libabi.a \
++oprofiled_DEPENDENCIES = ../libabi/libabi.a \
+ ../libdb/libodb.a ../libop/libop.a ../libutil/libutil.a
+ DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+ depcomp = $(SHELL) $(top_srcdir)/depcomp
+@@ -285,7 +285,7 @@ top_build_prefix = @top_build_prefix@
+ top_builddir = @top_builddir@
+ top_srcdir = @top_srcdir@
+ topdir = @topdir@
+-SUBDIRS = liblegacy .
++SUBDIRS = .
+ oprofiled_SOURCES = \
+ init.c \
+ oprofiled.c \
+@@ -331,7 +331,6 @@ AM_CPPFLAGS = \
+ # -fno-omit-frame-pointer needed for daemon build: see ChangeLog-2004 02-23
+ AM_CFLAGS = @OP_CFLAGS@ -fno-omit-frame-pointer
+ oprofiled_LDADD = \
+- liblegacy/liblegacy.a \
+ ../libabi/libabi.a \
+ ../libdb/libodb.a \
+ ../libop/libop.a \
+--- a/daemon/oprofiled.c
++++ b/daemon/oprofiled.c
+@@ -77,7 +77,6 @@ static char * events;
+ static char * ext_feature;
+ static int showvers;
+ static struct oprofiled_ops * opd_ops;
+-extern struct oprofiled_ops opd_24_ops;
+ extern struct oprofiled_ops opd_26_ops;
+
+ #define OPD_IMAGE_FILTER_HASH_SIZE 32
+@@ -477,9 +476,6 @@ static void opd_options(int argc, char c
+ static struct oprofiled_ops * get_ops(void)
+ {
+ switch (op_get_interface()) {
+- case OP_INTERFACE_24:
+- printf("Using 2.4 OProfile kernel interface.\n");
+- return &opd_24_ops;
+ case OP_INTERFACE_26:
+ printf("Using 2.6+ OProfile kernel interface.\n");
+ return &opd_26_ops;
diff --git a/package/devel/oprofile/patches/100-use_insmod_instead_of_modprobe.patch b/package/devel/oprofile/patches/100-use_insmod_instead_of_modprobe.patch
new file mode 100644
index 0000000..1010798
--- /dev/null
+++ b/package/devel/oprofile/patches/100-use_insmod_instead_of_modprobe.patch
@@ -0,0 +1,20 @@
+--- a/utils/opcontrol
++++ b/utils/opcontrol
+@@ -248,7 +248,7 @@ load_module_26()
+ {
+ grep oprofilefs /proc/filesystems >/dev/null
+ if test "$?" -ne 0; then
+- modprobe oprofile
++ insmod oprofile
+ if test "$?" != "0"; then
+ # couldn't load the module
+ return
+@@ -278,7 +278,7 @@ load_module_24()
+ {
+ grep oprof /proc/devices >/dev/null
+ if test "$?" -ne 0; then
+- modprobe oprofile
++ insmod oprofile
+ if test "$?" != "0"; then
+ # couldn't load a module
+ return
diff --git a/package/devel/oprofile/patches/101-remove_24_support.patch b/package/devel/oprofile/patches/101-remove_24_support.patch
new file mode 100644
index 0000000..99eb928
--- /dev/null
+++ b/package/devel/oprofile/patches/101-remove_24_support.patch
@@ -0,0 +1,64 @@
+--- a/daemon/Makefile.am
++++ b/daemon/Makefile.am
+@@ -1,4 +1,4 @@
+-SUBDIRS = liblegacy .
++SUBDIRS = .
+
+ oprofiled_SOURCES = \
+ init.c \
+@@ -49,7 +49,6 @@ AM_CFLAGS = @OP_CFLAGS@ -fno-omit-frame-
+ bin_PROGRAMS = oprofiled
+
+ oprofiled_LDADD = \
+- liblegacy/liblegacy.a \
+ ../libabi/libabi.a \
+ ../libdb/libodb.a \
+ ../libop/libop.a \
+--- a/daemon/Makefile.in
++++ b/daemon/Makefile.in
+@@ -70,7 +70,7 @@ am_oprofiled_OBJECTS = init.$(OBJEXT) op
+ opd_extended.$(OBJEXT) opd_ibs.$(OBJEXT) \
+ opd_ibs_trans.$(OBJEXT)
+ oprofiled_OBJECTS = $(am_oprofiled_OBJECTS)
+-oprofiled_DEPENDENCIES = liblegacy/liblegacy.a ../libabi/libabi.a \
++oprofiled_DEPENDENCIES = ../libabi/libabi.a \
+ ../libdb/libodb.a ../libop/libop.a ../libutil/libutil.a
+ DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+ depcomp = $(SHELL) $(top_srcdir)/depcomp
+@@ -285,7 +285,7 @@ top_build_prefix = @top_build_prefix@
+ top_builddir = @top_builddir@
+ top_srcdir = @top_srcdir@
+ topdir = @topdir@
+-SUBDIRS = liblegacy .
++SUBDIRS = .
+ oprofiled_SOURCES = \
+ init.c \
+ oprofiled.c \
+@@ -331,7 +331,6 @@ AM_CPPFLAGS = \
+ # -fno-omit-frame-pointer needed for daemon build: see ChangeLog-2004 02-23
+ AM_CFLAGS = @OP_CFLAGS@ -fno-omit-frame-pointer
+ oprofiled_LDADD = \
+- liblegacy/liblegacy.a \
+ ../libabi/libabi.a \
+ ../libdb/libodb.a \
+ ../libop/libop.a \
+--- a/daemon/oprofiled.c
++++ b/daemon/oprofiled.c
+@@ -77,7 +77,6 @@ static char * events;
+ static char * ext_feature;
+ static int showvers;
+ static struct oprofiled_ops * opd_ops;
+-extern struct oprofiled_ops opd_24_ops;
+ extern struct oprofiled_ops opd_26_ops;
+
+ #define OPD_IMAGE_FILTER_HASH_SIZE 32
+@@ -477,9 +476,6 @@ static void opd_options(int argc, char c
+ static struct oprofiled_ops * get_ops(void)
+ {
+ switch (op_get_interface()) {
+- case OP_INTERFACE_24:
+- printf("Using 2.4 OProfile kernel interface.\n");
+- return &opd_24_ops;
+ case OP_INTERFACE_26:
+ printf("Using 2.6+ OProfile kernel interface.\n");
+ return &opd_26_ops;
diff --git a/package/devel/trace-cmd/.svn/entries b/package/devel/trace-cmd/.svn/entries
new file mode 100644
index 0000000..c543b16
--- /dev/null
+++ b/package/devel/trace-cmd/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/devel/trace-cmd
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-11-27T18:08:42.110454Z
+34390
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+71856f00391d8b28e513844f4e1a28a1
+2012-11-27T18:08:42.110454Z
+34390
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1585
+
diff --git a/package/devel/trace-cmd/.svn/text-base/Makefile.svn-base b/package/devel/trace-cmd/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..1d555db
--- /dev/null
+++ b/package/devel/trace-cmd/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,61 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=trace-cmd
+PKG_VERSION:=v2.0.1
+PKG_RELEASE=1
+
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL:=git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.git
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE_VERSION:=1776cf9a24f95b2623fe7ee380d708bb8c6d8a73
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+# PKG_MIRROR_MD5SUM:=6a08dfa2519a969d184e7bb5bb390620
+PKG_INSTALL:=1
+
+PKG_BUILD_PARALLEL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/trace-cmd
+ SECTION:=devel
+ CATEGORY:=Development
+ TITLE:=Linux trace command line utility
+ DEPENDS:=
+endef
+
+define Package/trace-cmd-extra
+ SECTION:=devel
+ CATEGORY:=Development
+ TITLE:=Extra plugins for trace-cmd
+ DEPENDS:=
+endef
+
+MAKE_FLAGS += \
+ NO_PYTHON=1 \
+ prefix=/usr
+
+PLUGINS_DIR := $(PKG_INSTALL_DIR)/usr/lib/trace-cmd/plugins
+PLUGINS_MAIN := function hrtimer mac80211 sched_switch
+
+TARGET_CFLAGS += --std=gnu99
+
+define Package/trace-cmd/install
+ $(INSTALL_DIR) $(1)/usr/bin $(1)/usr/lib/trace-cmd/plugins
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/trace-cmd $(1)/usr/bin/
+ $(CP) \
+ $(patsubst %,$(PLUGINS_DIR)/plugin_%.so,$(PLUGINS_MAIN)) \
+ $(1)/usr/lib/trace-cmd/plugins
+endef
+
+define Package/trace-cmd-extra/install
+ $(INSTALL_DIR) $(1)/usr/lib/trace-cmd/plugins
+ $(CP) \
+ $$(patsubst %,$(PLUGINS_DIR)/plugin_%.so, \
+ $$(filter-out $(PLUGINS_MAIN), \
+ $$(patsubst $(PLUGINS_DIR)/plugin_%.so,%, \
+ $$(wildcard $(PLUGINS_DIR)/plugin_*.so)))) \
+ $(1)/usr/lib/trace-cmd/plugins
+endef
+
+$(eval $(call BuildPackage,trace-cmd))
+$(eval $(call BuildPackage,trace-cmd-extra))
diff --git a/package/devel/trace-cmd/Makefile b/package/devel/trace-cmd/Makefile
new file mode 100644
index 0000000..1d555db
--- /dev/null
+++ b/package/devel/trace-cmd/Makefile
@@ -0,0 +1,61 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=trace-cmd
+PKG_VERSION:=v2.0.1
+PKG_RELEASE=1
+
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL:=git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.git
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE_VERSION:=1776cf9a24f95b2623fe7ee380d708bb8c6d8a73
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+# PKG_MIRROR_MD5SUM:=6a08dfa2519a969d184e7bb5bb390620
+PKG_INSTALL:=1
+
+PKG_BUILD_PARALLEL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/trace-cmd
+ SECTION:=devel
+ CATEGORY:=Development
+ TITLE:=Linux trace command line utility
+ DEPENDS:=
+endef
+
+define Package/trace-cmd-extra
+ SECTION:=devel
+ CATEGORY:=Development
+ TITLE:=Extra plugins for trace-cmd
+ DEPENDS:=
+endef
+
+MAKE_FLAGS += \
+ NO_PYTHON=1 \
+ prefix=/usr
+
+PLUGINS_DIR := $(PKG_INSTALL_DIR)/usr/lib/trace-cmd/plugins
+PLUGINS_MAIN := function hrtimer mac80211 sched_switch
+
+TARGET_CFLAGS += --std=gnu99
+
+define Package/trace-cmd/install
+ $(INSTALL_DIR) $(1)/usr/bin $(1)/usr/lib/trace-cmd/plugins
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/trace-cmd $(1)/usr/bin/
+ $(CP) \
+ $(patsubst %,$(PLUGINS_DIR)/plugin_%.so,$(PLUGINS_MAIN)) \
+ $(1)/usr/lib/trace-cmd/plugins
+endef
+
+define Package/trace-cmd-extra/install
+ $(INSTALL_DIR) $(1)/usr/lib/trace-cmd/plugins
+ $(CP) \
+ $$(patsubst %,$(PLUGINS_DIR)/plugin_%.so, \
+ $$(filter-out $(PLUGINS_MAIN), \
+ $$(patsubst $(PLUGINS_DIR)/plugin_%.so,%, \
+ $$(wildcard $(PLUGINS_DIR)/plugin_*.so)))) \
+ $(1)/usr/lib/trace-cmd/plugins
+endef
+
+$(eval $(call BuildPackage,trace-cmd))
+$(eval $(call BuildPackage,trace-cmd-extra))
diff --git a/package/devel/trace-cmd/patches/.svn/entries b/package/devel/trace-cmd/patches/.svn/entries
new file mode 100644
index 0000000..784671a
--- /dev/null
+++ b/package/devel/trace-cmd/patches/.svn/entries
@@ -0,0 +1,96 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/devel/trace-cmd/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-29T19:25:43.127587Z
+34002
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+100-compile_fix.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+281431187e241123c6221e9911262a8a
+2012-10-29T19:25:43.127587Z
+34002
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+652
+
+110-fix_sscanf_alloc.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+0c5ea93585cdaf423ace452f713af757
+2012-10-29T19:25:43.127587Z
+34002
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+671
+
diff --git a/package/devel/trace-cmd/patches/.svn/text-base/100-compile_fix.patch.svn-base b/package/devel/trace-cmd/patches/.svn/text-base/100-compile_fix.patch.svn-base
new file mode 100644
index 0000000..151c123
--- /dev/null
+++ b/package/devel/trace-cmd/patches/.svn/text-base/100-compile_fix.patch.svn-base
@@ -0,0 +1,30 @@
+--- a/event-utils.h
++++ b/event-utils.h
+@@ -22,6 +22,7 @@
+
+ #include <string.h>
+ #include <ctype.h>
++#include <stdarg.h>
+
+ /* Can be overridden */
+ void die(const char *fmt, ...);
+--- a/trace-listen.c
++++ b/trace-listen.c
+@@ -17,6 +17,7 @@
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
++#define _GNU_SOURCE
+ #define _LARGEFILE64_SOURCE
+ #include <dirent.h>
+ #include <stdio.h>
+--- a/trace-record.c
++++ b/trace-record.c
+@@ -17,6 +17,7 @@
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
++#define _GNU_SOURCE
+ #include <dirent.h>
+ #include <stdio.h>
+ #include <stdlib.h>
diff --git a/package/devel/trace-cmd/patches/.svn/text-base/110-fix_sscanf_alloc.patch.svn-base b/package/devel/trace-cmd/patches/.svn/text-base/110-fix_sscanf_alloc.patch.svn-base
new file mode 100644
index 0000000..c0af0c6
--- /dev/null
+++ b/package/devel/trace-cmd/patches/.svn/text-base/110-fix_sscanf_alloc.patch.svn-base
@@ -0,0 +1,20 @@
+--- a/trace-util.c
++++ b/trace-util.c
+@@ -110,7 +110,7 @@ void parse_cmdlines(struct pevent *peven
+
+ line = strtok_r(file, "\n", &next);
+ while (line) {
+- sscanf(line, "%d %as", &pid,
++ sscanf(line, "%d %ms", &pid,
+ (float *)(void *)&comm); /* workaround gcc warning */
+ pevent_register_comm(pevent, comm, pid);
+ free(comm);
+@@ -133,7 +133,7 @@ void parse_proc_kallsyms(struct pevent *
+ line = strtok_r(file, "\n", &next);
+ while (line) {
+ mod = NULL;
+- ret = sscanf(line, "%as %c %as\t[%as",
++ ret = sscanf(line, "%ms %c %ms\t[%ms",
+ (float *)(void *)&addr_str, /* workaround gcc warning */
+ &ch,
+ (float *)(void *)&func,
diff --git a/package/devel/trace-cmd/patches/100-compile_fix.patch b/package/devel/trace-cmd/patches/100-compile_fix.patch
new file mode 100644
index 0000000..151c123
--- /dev/null
+++ b/package/devel/trace-cmd/patches/100-compile_fix.patch
@@ -0,0 +1,30 @@
+--- a/event-utils.h
++++ b/event-utils.h
+@@ -22,6 +22,7 @@
+
+ #include <string.h>
+ #include <ctype.h>
++#include <stdarg.h>
+
+ /* Can be overridden */
+ void die(const char *fmt, ...);
+--- a/trace-listen.c
++++ b/trace-listen.c
+@@ -17,6 +17,7 @@
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
++#define _GNU_SOURCE
+ #define _LARGEFILE64_SOURCE
+ #include <dirent.h>
+ #include <stdio.h>
+--- a/trace-record.c
++++ b/trace-record.c
+@@ -17,6 +17,7 @@
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
++#define _GNU_SOURCE
+ #include <dirent.h>
+ #include <stdio.h>
+ #include <stdlib.h>
diff --git a/package/devel/trace-cmd/patches/110-fix_sscanf_alloc.patch b/package/devel/trace-cmd/patches/110-fix_sscanf_alloc.patch
new file mode 100644
index 0000000..c0af0c6
--- /dev/null
+++ b/package/devel/trace-cmd/patches/110-fix_sscanf_alloc.patch
@@ -0,0 +1,20 @@
+--- a/trace-util.c
++++ b/trace-util.c
+@@ -110,7 +110,7 @@ void parse_cmdlines(struct pevent *peven
+
+ line = strtok_r(file, "\n", &next);
+ while (line) {
+- sscanf(line, "%d %as", &pid,
++ sscanf(line, "%d %ms", &pid,
+ (float *)(void *)&comm); /* workaround gcc warning */
+ pevent_register_comm(pevent, comm, pid);
+ free(comm);
+@@ -133,7 +133,7 @@ void parse_proc_kallsyms(struct pevent *
+ line = strtok_r(file, "\n", &next);
+ while (line) {
+ mod = NULL;
+- ret = sscanf(line, "%as %c %as\t[%as",
++ ret = sscanf(line, "%ms %c %ms\t[%ms",
+ (float *)(void *)&addr_str, /* workaround gcc warning */
+ &ch,
+ (float *)(void *)&func,
diff --git a/package/devel/valgrind/.svn/entries b/package/devel/valgrind/.svn/entries
new file mode 100644
index 0000000..e0cfea7
--- /dev/null
+++ b/package/devel/valgrind/.svn/entries
@@ -0,0 +1,71 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/devel/valgrind
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-11-21T20:26:58.502174Z
+34293
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+files
+dir
+
+patches
+dir
+
+src
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+3f6c04f5b9338447d7a4dde3ae03e744
+2012-11-21T20:26:58.502174Z
+34293
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4514
+
diff --git a/package/devel/valgrind/.svn/text-base/Makefile.svn-base b/package/devel/valgrind/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..dfefa09
--- /dev/null
+++ b/package/devel/valgrind/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,164 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=valgrind
+PKG_VERSION:=3.8.0
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=http://valgrind.org/downloads/
+PKG_MD5SUM:=ec04dfd1256307432b2a7b520398c526
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+
+PKG_FIXUP = autoreconf
+PKG_INSTALL := 1
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+define Package/valgrind
+ SECTION:=devel
+ CATEGORY:=Development
+ DEPENDS:=@mips||mipsel||i386||powerpc||TARGET_omap4 +libpthread +librt
+ TITLE:=debugging and profiling tools for Linux
+ URL:=http://www.valgrind.org
+endef
+
+define Package/valgrind/default
+ $(Package/valgrind)
+ DEPENDS := valgrind
+endef
+
+define Package/valgrind-cachegrind
+ $(Package/valgrind/default)
+ TITLE += (cache profiling)
+endef
+
+define Package/valgrind-callgrind
+ $(Package/valgrind/default)
+ TITLE += (callgraph profiling)
+endef
+
+define Package/valgrind-drd
+ $(Package/valgrind/default)
+ TITLE += (thread error detection)
+endef
+
+define Package/valgrind-massif
+ $(Package/valgrind/default)
+ TITLE += (heap profiling)
+endef
+
+define Package/valgrind-helgrind
+ $(Package/valgrind/default)
+ TITLE += (thread debugging)
+endef
+
+define Package/valgrind-vgdb
+ $(Package/valgrind/default)
+ TITLE += (GDB interface)
+endef
+
+define Package/valgrind/description
+ Valgrind is an award-winning suite of tools for debugging and
+ profiling Linux programs. With the tools that come with Valgrind,
+ you can automatically detect many memory management and threading
+ bugs, avoiding hours of frustrating bug-hunting, making your
+ programs more stable. You can also perform detailed profiling,
+ to speed up and reduce memory use of your programs.
+endef
+
+CPU := $(patsubst x86,i386,$(LINUX_KARCH))
+
+CONFIGURE_VARS += \
+ UNAME_R=$(LINUX_VERSION)
+
+CONFIGURE_ARGS += \
+ --enable-only32bit \
+ --enable-tls \
+ --without-x \
+ --without-uiout \
+ --disable-valgrindmi \
+ --disable-tui \
+ --disable-valgrindtk \
+ --without-included-gettext
+
+define Package/valgrind/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/valgrind* $(1)/usr/bin/
+ $(INSTALL_DIR) $(1)/usr/lib/valgrind
+ $(CP) \
+ ./files/default.supp \
+ $(PKG_INSTALL_DIR)/usr/lib/valgrind/none-* \
+ $(PKG_INSTALL_DIR)/usr/lib/valgrind/vgpreload_core*.so \
+ $(PKG_INSTALL_DIR)/usr/lib/valgrind/$(CPU)-*.xml \
+ $(PKG_INSTALL_DIR)/usr/lib/valgrind/32bit-core*.xml \
+ $(PKG_INSTALL_DIR)/usr/lib/valgrind/32bit-linux*.xml \
+ $(PKG_INSTALL_DIR)/usr/lib/valgrind/memcheck-* \
+ $(PKG_INSTALL_DIR)/usr/lib/valgrind/vgpreload_memcheck*.so \
+ $(1)/usr/lib/valgrind/
+endef
+
+define Package/valgrind-cachegrind/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/cg_* $(1)/usr/bin/
+ $(INSTALL_DIR) $(1)/usr/lib/valgrind
+ $(CP) \
+ $(PKG_INSTALL_DIR)/usr/lib/valgrind/cachegrind-* \
+ $(1)/usr/lib/valgrind/
+endef
+
+define Package/valgrind-callgrind/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/callgrind* $(1)/usr/bin/
+ $(INSTALL_DIR) $(1)/usr/lib/valgrind
+ $(CP) \
+ $(PKG_INSTALL_DIR)/usr/lib/valgrind/callgrind-* \
+ $(1)/usr/lib/valgrind/
+endef
+
+define Package/valgrind-drd/install
+ $(INSTALL_DIR) $(1)/usr/lib/valgrind
+ $(CP) \
+ $(PKG_INSTALL_DIR)/usr/lib/valgrind/drd-* \
+ $(PKG_INSTALL_DIR)/usr/lib/valgrind/vgpreload_drd*.so \
+ $(1)/usr/lib/valgrind/
+endef
+
+define Package/valgrind-massif/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/ms_print $(1)/usr/bin/
+ $(INSTALL_DIR) $(1)/usr/lib/valgrind
+ $(CP) \
+ $(PKG_INSTALL_DIR)/usr/lib/valgrind/massif-* \
+ $(PKG_INSTALL_DIR)/usr/lib/valgrind/vgpreload_massif*.so \
+ $(1)/usr/lib/valgrind/
+endef
+
+define Package/valgrind-helgrind/install
+ $(INSTALL_DIR) $(1)/usr/lib/valgrind
+ $(CP) \
+ $(PKG_INSTALL_DIR)/usr/lib/valgrind/helgrind-* \
+ $(PKG_INSTALL_DIR)/usr/lib/valgrind/vgpreload_helgrind*.so \
+ $(1)/usr/lib/valgrind/
+endef
+
+define Package/valgrind-vgdb/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/vgdb $(1)/usr/bin/
+endef
+
+$(eval $(call BuildPackage,valgrind))
+$(eval $(call BuildPackage,valgrind-cachegrind))
+$(eval $(call BuildPackage,valgrind-callgrind))
+$(eval $(call BuildPackage,valgrind-drd))
+$(eval $(call BuildPackage,valgrind-massif))
+$(eval $(call BuildPackage,valgrind-helgrind))
+$(eval $(call BuildPackage,valgrind-vgdb))
diff --git a/package/devel/valgrind/Makefile b/package/devel/valgrind/Makefile
new file mode 100644
index 0000000..dfefa09
--- /dev/null
+++ b/package/devel/valgrind/Makefile
@@ -0,0 +1,164 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=valgrind
+PKG_VERSION:=3.8.0
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=http://valgrind.org/downloads/
+PKG_MD5SUM:=ec04dfd1256307432b2a7b520398c526
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+
+PKG_FIXUP = autoreconf
+PKG_INSTALL := 1
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+define Package/valgrind
+ SECTION:=devel
+ CATEGORY:=Development
+ DEPENDS:=@mips||mipsel||i386||powerpc||TARGET_omap4 +libpthread +librt
+ TITLE:=debugging and profiling tools for Linux
+ URL:=http://www.valgrind.org
+endef
+
+define Package/valgrind/default
+ $(Package/valgrind)
+ DEPENDS := valgrind
+endef
+
+define Package/valgrind-cachegrind
+ $(Package/valgrind/default)
+ TITLE += (cache profiling)
+endef
+
+define Package/valgrind-callgrind
+ $(Package/valgrind/default)
+ TITLE += (callgraph profiling)
+endef
+
+define Package/valgrind-drd
+ $(Package/valgrind/default)
+ TITLE += (thread error detection)
+endef
+
+define Package/valgrind-massif
+ $(Package/valgrind/default)
+ TITLE += (heap profiling)
+endef
+
+define Package/valgrind-helgrind
+ $(Package/valgrind/default)
+ TITLE += (thread debugging)
+endef
+
+define Package/valgrind-vgdb
+ $(Package/valgrind/default)
+ TITLE += (GDB interface)
+endef
+
+define Package/valgrind/description
+ Valgrind is an award-winning suite of tools for debugging and
+ profiling Linux programs. With the tools that come with Valgrind,
+ you can automatically detect many memory management and threading
+ bugs, avoiding hours of frustrating bug-hunting, making your
+ programs more stable. You can also perform detailed profiling,
+ to speed up and reduce memory use of your programs.
+endef
+
+CPU := $(patsubst x86,i386,$(LINUX_KARCH))
+
+CONFIGURE_VARS += \
+ UNAME_R=$(LINUX_VERSION)
+
+CONFIGURE_ARGS += \
+ --enable-only32bit \
+ --enable-tls \
+ --without-x \
+ --without-uiout \
+ --disable-valgrindmi \
+ --disable-tui \
+ --disable-valgrindtk \
+ --without-included-gettext
+
+define Package/valgrind/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/valgrind* $(1)/usr/bin/
+ $(INSTALL_DIR) $(1)/usr/lib/valgrind
+ $(CP) \
+ ./files/default.supp \
+ $(PKG_INSTALL_DIR)/usr/lib/valgrind/none-* \
+ $(PKG_INSTALL_DIR)/usr/lib/valgrind/vgpreload_core*.so \
+ $(PKG_INSTALL_DIR)/usr/lib/valgrind/$(CPU)-*.xml \
+ $(PKG_INSTALL_DIR)/usr/lib/valgrind/32bit-core*.xml \
+ $(PKG_INSTALL_DIR)/usr/lib/valgrind/32bit-linux*.xml \
+ $(PKG_INSTALL_DIR)/usr/lib/valgrind/memcheck-* \
+ $(PKG_INSTALL_DIR)/usr/lib/valgrind/vgpreload_memcheck*.so \
+ $(1)/usr/lib/valgrind/
+endef
+
+define Package/valgrind-cachegrind/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/cg_* $(1)/usr/bin/
+ $(INSTALL_DIR) $(1)/usr/lib/valgrind
+ $(CP) \
+ $(PKG_INSTALL_DIR)/usr/lib/valgrind/cachegrind-* \
+ $(1)/usr/lib/valgrind/
+endef
+
+define Package/valgrind-callgrind/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/callgrind* $(1)/usr/bin/
+ $(INSTALL_DIR) $(1)/usr/lib/valgrind
+ $(CP) \
+ $(PKG_INSTALL_DIR)/usr/lib/valgrind/callgrind-* \
+ $(1)/usr/lib/valgrind/
+endef
+
+define Package/valgrind-drd/install
+ $(INSTALL_DIR) $(1)/usr/lib/valgrind
+ $(CP) \
+ $(PKG_INSTALL_DIR)/usr/lib/valgrind/drd-* \
+ $(PKG_INSTALL_DIR)/usr/lib/valgrind/vgpreload_drd*.so \
+ $(1)/usr/lib/valgrind/
+endef
+
+define Package/valgrind-massif/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/ms_print $(1)/usr/bin/
+ $(INSTALL_DIR) $(1)/usr/lib/valgrind
+ $(CP) \
+ $(PKG_INSTALL_DIR)/usr/lib/valgrind/massif-* \
+ $(PKG_INSTALL_DIR)/usr/lib/valgrind/vgpreload_massif*.so \
+ $(1)/usr/lib/valgrind/
+endef
+
+define Package/valgrind-helgrind/install
+ $(INSTALL_DIR) $(1)/usr/lib/valgrind
+ $(CP) \
+ $(PKG_INSTALL_DIR)/usr/lib/valgrind/helgrind-* \
+ $(PKG_INSTALL_DIR)/usr/lib/valgrind/vgpreload_helgrind*.so \
+ $(1)/usr/lib/valgrind/
+endef
+
+define Package/valgrind-vgdb/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/vgdb $(1)/usr/bin/
+endef
+
+$(eval $(call BuildPackage,valgrind))
+$(eval $(call BuildPackage,valgrind-cachegrind))
+$(eval $(call BuildPackage,valgrind-callgrind))
+$(eval $(call BuildPackage,valgrind-drd))
+$(eval $(call BuildPackage,valgrind-massif))
+$(eval $(call BuildPackage,valgrind-helgrind))
+$(eval $(call BuildPackage,valgrind-vgdb))
diff --git a/package/devel/valgrind/files/.svn/entries b/package/devel/valgrind/files/.svn/entries
new file mode 100644
index 0000000..41017f1
--- /dev/null
+++ b/package/devel/valgrind/files/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/devel/valgrind/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-06-30T15:20:20.707095Z
+32552
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+default.supp
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+8046867dd2a44b871469e3d76b471d63
+2012-06-30T15:20:20.707095Z
+32552
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+398
+
diff --git a/package/devel/valgrind/files/.svn/text-base/default.supp.svn-base b/package/devel/valgrind/files/.svn/text-base/default.supp.svn-base
new file mode 100644
index 0000000..beff559
--- /dev/null
+++ b/package/devel/valgrind/files/.svn/text-base/default.supp.svn-base
@@ -0,0 +1,42 @@
+{
+ ld(Addr1)
+ Memcheck:Addr1
+ fun:*
+ obj:/lib/ld-*
+}
+{
+ ld(Addr2)
+ Memcheck:Addr2
+ fun:*
+ obj:/lib/ld-*
+}
+{
+ ld(Addr4)
+ Memcheck:Addr4
+ fun:*
+ obj:/lib/ld-*
+}
+{
+ ld(Cond)
+ Memcheck:Cond
+ fun:*
+ obj:/lib/ld-*
+}
+{
+ strlen(Cond)
+ Memcheck:Cond
+ fun:strlen
+ fun:*
+}
+{
+ strnlen(Cond)
+ Memcheck:Cond
+ fun:strnlen
+ fun:*
+}
+{
+ index(Cond)
+ Memcheck:Cond
+ fun:index
+ fun:*
+}
diff --git a/package/devel/valgrind/files/default.supp b/package/devel/valgrind/files/default.supp
new file mode 100644
index 0000000..beff559
--- /dev/null
+++ b/package/devel/valgrind/files/default.supp
@@ -0,0 +1,42 @@
+{
+ ld(Addr1)
+ Memcheck:Addr1
+ fun:*
+ obj:/lib/ld-*
+}
+{
+ ld(Addr2)
+ Memcheck:Addr2
+ fun:*
+ obj:/lib/ld-*
+}
+{
+ ld(Addr4)
+ Memcheck:Addr4
+ fun:*
+ obj:/lib/ld-*
+}
+{
+ ld(Cond)
+ Memcheck:Cond
+ fun:*
+ obj:/lib/ld-*
+}
+{
+ strlen(Cond)
+ Memcheck:Cond
+ fun:strlen
+ fun:*
+}
+{
+ strnlen(Cond)
+ Memcheck:Cond
+ fun:strnlen
+ fun:*
+}
+{
+ index(Cond)
+ Memcheck:Cond
+ fun:index
+ fun:*
+}
diff --git a/package/devel/valgrind/patches/.svn/entries b/package/devel/valgrind/patches/.svn/entries
new file mode 100644
index 0000000..eea1716
--- /dev/null
+++ b/package/devel/valgrind/patches/.svn/entries
@@ -0,0 +1,96 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/devel/valgrind/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-06-29T19:17:51.709805Z
+32532
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+100-fix_configure_check.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+cd07444d60fdc2efe6d05c9efb58e475
+2012-06-29T19:17:51.709805Z
+32532
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+310
+
+110-add_a_out_h.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+b1de24eba7f28c9dc4e922ae39017934
+2012-06-29T19:17:51.709805Z
+32532
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4913
+
diff --git a/package/devel/valgrind/patches/.svn/text-base/100-fix_configure_check.patch.svn-base b/package/devel/valgrind/patches/.svn/text-base/100-fix_configure_check.patch.svn-base
new file mode 100644
index 0000000..b06cc3b
--- /dev/null
+++ b/package/devel/valgrind/patches/.svn/text-base/100-fix_configure_check.patch.svn-base
@@ -0,0 +1,11 @@
+--- a/configure.in
++++ b/configure.in
+@@ -260,7 +260,7 @@ case "${host_os}" in
+ # Ok, this is linux. Check the kernel version
+ AC_MSG_CHECKING([for the kernel version])
+
+- kernel=`uname -r`
++ kernel=${UNAME_R:-`uname -r`}
+
+ case "${kernel}" in
+ 2.6.*|3.*)
diff --git a/package/devel/valgrind/patches/.svn/text-base/110-add_a_out_h.patch.svn-base b/package/devel/valgrind/patches/.svn/text-base/110-add_a_out_h.patch.svn-base
new file mode 100644
index 0000000..7d95fb3
--- /dev/null
+++ b/package/devel/valgrind/patches/.svn/text-base/110-add_a_out_h.patch.svn-base
@@ -0,0 +1,157 @@
+--- /dev/null
++++ b/include/a.out.h
+@@ -0,0 +1,138 @@
++#ifndef __A_OUT_GNU_H__
++#define __A_OUT_GNU_H__
++
++#include <bits/a.out.h>
++
++#define __GNU_EXEC_MACROS__
++
++struct exec
++{
++ unsigned long a_info; /* Use macros N_MAGIC, etc for access. */
++ unsigned int a_text; /* Length of text, in bytes. */
++ unsigned int a_data; /* Length of data, in bytes. */
++ unsigned int a_bss; /* Length of uninitialized data area for file, in bytes. */
++ unsigned int a_syms; /* Length of symbol table data in file, in bytes. */
++ unsigned int a_entry; /* Start address. */
++ unsigned int a_trsize;/* Length of relocation info for text, in bytes. */
++ unsigned int a_drsize;/* Length of relocation info for data, in bytes. */
++};
++
++enum machine_type
++{
++ M_OLDSUN2 = 0,
++ M_68010 = 1,
++ M_68020 = 2,
++ M_SPARC = 3,
++ M_386 = 100,
++ M_MIPS1 = 151,
++ M_MIPS2 = 152
++};
++
++#define N_MAGIC(exec) ((exec).a_info & 0xffff)
++#define N_MACHTYPE(exec) ((enum machine_type)(((exec).a_info >> 16) & 0xff))
++#define N_FLAGS(exec) (((exec).a_info >> 24) & 0xff)
++#define N_SET_INFO(exec, magic, type, flags) \
++ ((exec).a_info = ((magic) & 0xffff) \
++ | (((int)(type) & 0xff) << 16) \
++ | (((flags) & 0xff) << 24))
++#define N_SET_MAGIC(exec, magic) \
++ ((exec).a_info = ((exec).a_info & 0xffff0000) | ((magic) & 0xffff))
++#define N_SET_MACHTYPE(exec, machtype) \
++ ((exec).a_info = \
++ ((exec).a_info&0xff00ffff) | ((((int)(machtype))&0xff) << 16))
++#define N_SET_FLAGS(exec, flags) \
++ ((exec).a_info = \
++ ((exec).a_info&0x00ffffff) | (((flags) & 0xff) << 24))
++
++/* Code indicating object file or impure executable. */
++#define OMAGIC 0407
++/* Code indicating pure executable. */
++#define NMAGIC 0410
++/* Code indicating demand-paged executable. */
++#define ZMAGIC 0413
++/* This indicates a demand-paged executable with the header in the text.
++ The first page is unmapped to help trap NULL pointer references. */
++#define QMAGIC 0314
++/* Code indicating core file. */
++#define CMAGIC 0421
++
++#define N_TRSIZE(a) ((a).a_trsize)
++#define N_DRSIZE(a) ((a).a_drsize)
++#define N_SYMSIZE(a) ((a).a_syms)
++#define N_BADMAG(x) \
++ (N_MAGIC(x) != OMAGIC && N_MAGIC(x) != NMAGIC \
++ && N_MAGIC(x) != ZMAGIC && N_MAGIC(x) != QMAGIC)
++#define _N_HDROFF(x) (1024 - sizeof (struct exec))
++#define N_TXTOFF(x) \
++ (N_MAGIC(x) == ZMAGIC ? _N_HDROFF((x)) + sizeof (struct exec) : \
++ (N_MAGIC(x) == QMAGIC ? 0 : sizeof (struct exec)))
++#define N_DATOFF(x) (N_TXTOFF(x) + (x).a_text)
++#define N_TRELOFF(x) (N_DATOFF(x) + (x).a_data)
++#define N_DRELOFF(x) (N_TRELOFF(x) + N_TRSIZE(x))
++#define N_SYMOFF(x) (N_DRELOFF(x) + N_DRSIZE(x))
++#define N_STROFF(x) (N_SYMOFF(x) + N_SYMSIZE(x))
++
++/* Address of text segment in memory after it is loaded. */
++#define N_TXTADDR(x) (N_MAGIC(x) == QMAGIC ? 4096 : 0)
++
++/* Address of data segment in memory after it is loaded. */
++#define SEGMENT_SIZE 1024
++
++#define _N_SEGMENT_ROUND(x) (((x) + SEGMENT_SIZE - 1) & ~(SEGMENT_SIZE - 1))
++#define _N_TXTENDADDR(x) (N_TXTADDR(x)+(x).a_text)
++
++#define N_DATADDR(x) \
++ (N_MAGIC(x)==OMAGIC? (_N_TXTENDADDR(x)) \
++ : (_N_SEGMENT_ROUND (_N_TXTENDADDR(x))))
++#define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data)
++
++#if !defined (N_NLIST_DECLARED)
++struct nlist
++{
++ union
++ {
++ char *n_name;
++ struct nlist *n_next;
++ long n_strx;
++ } n_un;
++ unsigned char n_type;
++ char n_other;
++ short n_desc;
++ unsigned long n_value;
++};
++#endif /* no N_NLIST_DECLARED. */
++
++#define N_UNDF 0
++#define N_ABS 2
++#define N_TEXT 4
++#define N_DATA 6
++#define N_BSS 8
++#define N_FN 15
++#define N_EXT 1
++#define N_TYPE 036
++#define N_STAB 0340
++#define N_INDR 0xa
++#define N_SETA 0x14 /* Absolute set element symbol. */
++#define N_SETT 0x16 /* Text set element symbol. */
++#define N_SETD 0x18 /* Data set element symbol. */
++#define N_SETB 0x1A /* Bss set element symbol. */
++#define N_SETV 0x1C /* Pointer to set vector in data area. */
++
++#if !defined (N_RELOCATION_INFO_DECLARED)
++/* This structure describes a single relocation to be performed.
++ The text-relocation section of the file is a vector of these structures,
++ all of which apply to the text section.
++ Likewise, the data-relocation section applies to the data section. */
++
++struct relocation_info
++{
++ int r_address;
++ unsigned int r_symbolnum:24;
++ unsigned int r_pcrel:1;
++ unsigned int r_length:2;
++ unsigned int r_extern:1;
++ unsigned int r_pad:4;
++};
++#endif /* no N_RELOCATION_INFO_DECLARED. */
++
++#endif /* __A_OUT_GNU_H__ */
+--- /dev/null
++++ b/include/bits/a.out.h
+@@ -0,0 +1,13 @@
++#ifndef __A_OUT_GNU_H__
++# error "Never use <bits/a.out.h> directly; include <a.out.h> instead."
++#endif
++
++#include <bits/wordsize.h>
++
++#if __WORDSIZE == 64
++
++/* Signal to users of this header that this architecture really doesn't
++ support a.out binary format. */
++#define __NO_A_OUT_SUPPORT 1
++
++#endif
diff --git a/package/devel/valgrind/patches/100-fix_configure_check.patch b/package/devel/valgrind/patches/100-fix_configure_check.patch
new file mode 100644
index 0000000..b06cc3b
--- /dev/null
+++ b/package/devel/valgrind/patches/100-fix_configure_check.patch
@@ -0,0 +1,11 @@
+--- a/configure.in
++++ b/configure.in
+@@ -260,7 +260,7 @@ case "${host_os}" in
+ # Ok, this is linux. Check the kernel version
+ AC_MSG_CHECKING([for the kernel version])
+
+- kernel=`uname -r`
++ kernel=${UNAME_R:-`uname -r`}
+
+ case "${kernel}" in
+ 2.6.*|3.*)
diff --git a/package/devel/valgrind/patches/110-add_a_out_h.patch b/package/devel/valgrind/patches/110-add_a_out_h.patch
new file mode 100644
index 0000000..7d95fb3
--- /dev/null
+++ b/package/devel/valgrind/patches/110-add_a_out_h.patch
@@ -0,0 +1,157 @@
+--- /dev/null
++++ b/include/a.out.h
+@@ -0,0 +1,138 @@
++#ifndef __A_OUT_GNU_H__
++#define __A_OUT_GNU_H__
++
++#include <bits/a.out.h>
++
++#define __GNU_EXEC_MACROS__
++
++struct exec
++{
++ unsigned long a_info; /* Use macros N_MAGIC, etc for access. */
++ unsigned int a_text; /* Length of text, in bytes. */
++ unsigned int a_data; /* Length of data, in bytes. */
++ unsigned int a_bss; /* Length of uninitialized data area for file, in bytes. */
++ unsigned int a_syms; /* Length of symbol table data in file, in bytes. */
++ unsigned int a_entry; /* Start address. */
++ unsigned int a_trsize;/* Length of relocation info for text, in bytes. */
++ unsigned int a_drsize;/* Length of relocation info for data, in bytes. */
++};
++
++enum machine_type
++{
++ M_OLDSUN2 = 0,
++ M_68010 = 1,
++ M_68020 = 2,
++ M_SPARC = 3,
++ M_386 = 100,
++ M_MIPS1 = 151,
++ M_MIPS2 = 152
++};
++
++#define N_MAGIC(exec) ((exec).a_info & 0xffff)
++#define N_MACHTYPE(exec) ((enum machine_type)(((exec).a_info >> 16) & 0xff))
++#define N_FLAGS(exec) (((exec).a_info >> 24) & 0xff)
++#define N_SET_INFO(exec, magic, type, flags) \
++ ((exec).a_info = ((magic) & 0xffff) \
++ | (((int)(type) & 0xff) << 16) \
++ | (((flags) & 0xff) << 24))
++#define N_SET_MAGIC(exec, magic) \
++ ((exec).a_info = ((exec).a_info & 0xffff0000) | ((magic) & 0xffff))
++#define N_SET_MACHTYPE(exec, machtype) \
++ ((exec).a_info = \
++ ((exec).a_info&0xff00ffff) | ((((int)(machtype))&0xff) << 16))
++#define N_SET_FLAGS(exec, flags) \
++ ((exec).a_info = \
++ ((exec).a_info&0x00ffffff) | (((flags) & 0xff) << 24))
++
++/* Code indicating object file or impure executable. */
++#define OMAGIC 0407
++/* Code indicating pure executable. */
++#define NMAGIC 0410
++/* Code indicating demand-paged executable. */
++#define ZMAGIC 0413
++/* This indicates a demand-paged executable with the header in the text.
++ The first page is unmapped to help trap NULL pointer references. */
++#define QMAGIC 0314
++/* Code indicating core file. */
++#define CMAGIC 0421
++
++#define N_TRSIZE(a) ((a).a_trsize)
++#define N_DRSIZE(a) ((a).a_drsize)
++#define N_SYMSIZE(a) ((a).a_syms)
++#define N_BADMAG(x) \
++ (N_MAGIC(x) != OMAGIC && N_MAGIC(x) != NMAGIC \
++ && N_MAGIC(x) != ZMAGIC && N_MAGIC(x) != QMAGIC)
++#define _N_HDROFF(x) (1024 - sizeof (struct exec))
++#define N_TXTOFF(x) \
++ (N_MAGIC(x) == ZMAGIC ? _N_HDROFF((x)) + sizeof (struct exec) : \
++ (N_MAGIC(x) == QMAGIC ? 0 : sizeof (struct exec)))
++#define N_DATOFF(x) (N_TXTOFF(x) + (x).a_text)
++#define N_TRELOFF(x) (N_DATOFF(x) + (x).a_data)
++#define N_DRELOFF(x) (N_TRELOFF(x) + N_TRSIZE(x))
++#define N_SYMOFF(x) (N_DRELOFF(x) + N_DRSIZE(x))
++#define N_STROFF(x) (N_SYMOFF(x) + N_SYMSIZE(x))
++
++/* Address of text segment in memory after it is loaded. */
++#define N_TXTADDR(x) (N_MAGIC(x) == QMAGIC ? 4096 : 0)
++
++/* Address of data segment in memory after it is loaded. */
++#define SEGMENT_SIZE 1024
++
++#define _N_SEGMENT_ROUND(x) (((x) + SEGMENT_SIZE - 1) & ~(SEGMENT_SIZE - 1))
++#define _N_TXTENDADDR(x) (N_TXTADDR(x)+(x).a_text)
++
++#define N_DATADDR(x) \
++ (N_MAGIC(x)==OMAGIC? (_N_TXTENDADDR(x)) \
++ : (_N_SEGMENT_ROUND (_N_TXTENDADDR(x))))
++#define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data)
++
++#if !defined (N_NLIST_DECLARED)
++struct nlist
++{
++ union
++ {
++ char *n_name;
++ struct nlist *n_next;
++ long n_strx;
++ } n_un;
++ unsigned char n_type;
++ char n_other;
++ short n_desc;
++ unsigned long n_value;
++};
++#endif /* no N_NLIST_DECLARED. */
++
++#define N_UNDF 0
++#define N_ABS 2
++#define N_TEXT 4
++#define N_DATA 6
++#define N_BSS 8
++#define N_FN 15
++#define N_EXT 1
++#define N_TYPE 036
++#define N_STAB 0340
++#define N_INDR 0xa
++#define N_SETA 0x14 /* Absolute set element symbol. */
++#define N_SETT 0x16 /* Text set element symbol. */
++#define N_SETD 0x18 /* Data set element symbol. */
++#define N_SETB 0x1A /* Bss set element symbol. */
++#define N_SETV 0x1C /* Pointer to set vector in data area. */
++
++#if !defined (N_RELOCATION_INFO_DECLARED)
++/* This structure describes a single relocation to be performed.
++ The text-relocation section of the file is a vector of these structures,
++ all of which apply to the text section.
++ Likewise, the data-relocation section applies to the data section. */
++
++struct relocation_info
++{
++ int r_address;
++ unsigned int r_symbolnum:24;
++ unsigned int r_pcrel:1;
++ unsigned int r_length:2;
++ unsigned int r_extern:1;
++ unsigned int r_pad:4;
++};
++#endif /* no N_RELOCATION_INFO_DECLARED. */
++
++#endif /* __A_OUT_GNU_H__ */
+--- /dev/null
++++ b/include/bits/a.out.h
+@@ -0,0 +1,13 @@
++#ifndef __A_OUT_GNU_H__
++# error "Never use <bits/a.out.h> directly; include <a.out.h> instead."
++#endif
++
++#include <bits/wordsize.h>
++
++#if __WORDSIZE == 64
++
++/* Signal to users of this header that this architecture really doesn't
++ support a.out binary format. */
++#define __NO_A_OUT_SUPPORT 1
++
++#endif
diff --git a/package/devel/valgrind/src/.svn/entries b/package/devel/valgrind/src/.svn/entries
new file mode 100644
index 0000000..8779458
--- /dev/null
+++ b/package/devel/valgrind/src/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/devel/valgrind/src
+svn://svn.openwrt.org/openwrt
+
+
+
+2008-08-17T11:49:31.796133Z
+12330
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+abort.c
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+f7556e9fbc6aa866ae8b1c139a80afa7
+2008-08-17T11:49:31.796133Z
+12330
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+21
+
diff --git a/package/devel/valgrind/src/.svn/text-base/abort.c.svn-base b/package/devel/valgrind/src/.svn/text-base/abort.c.svn-base
new file mode 100644
index 0000000..0b4ad98
--- /dev/null
+++ b/package/devel/valgrind/src/.svn/text-base/abort.c.svn-base
@@ -0,0 +1,3 @@
+void abort(void)
+{
+}
diff --git a/package/devel/valgrind/src/abort.c b/package/devel/valgrind/src/abort.c
new file mode 100644
index 0000000..0b4ad98
--- /dev/null
+++ b/package/devel/valgrind/src/abort.c
@@ -0,0 +1,3 @@
+void abort(void)
+{
+}
diff --git a/package/fuse/.svn/entries b/package/fuse/.svn/entries
new file mode 100644
index 0000000..8ca5ff6
--- /dev/null
+++ b/package/fuse/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/fuse
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-19T15:34:28.915431Z
+33861
+hcg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+2407d65b47c261c55d8f8d2cdb9ed670
+2012-10-19T15:34:28.915431Z
+33861
+hcg
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2749
+
diff --git a/package/fuse/.svn/prop-base/Makefile.svn-base b/package/fuse/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..8e522ae
--- /dev/null
+++ b/package/fuse/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:copyright
+V 30
+Copyright (C) 2006 OpenWrt.org
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/fuse/.svn/text-base/Makefile.svn-base b/package/fuse/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..0620b6c
--- /dev/null
+++ b/package/fuse/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,111 @@
+#
+# Copyright (C) 2006-2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=fuse
+PKG_VERSION:=2.9.0
+PKG_RELEASE:=2
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=@SF/$(PKG_NAME)
+PKG_MD5SUM:=894ee11674f89a915ae87524aed55bc4
+
+PKG_LICENSE:=LGPLv2.1 GPLv2
+PKG_LICENSE_FILES:=COPYING.LIB COPYING
+
+PKG_INSTALL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/fuse/Default
+ TITLE:=FUSE
+ URL:=http://fuse.sourceforge.net/
+endef
+
+define Package/fuse/Default/description
+ FUSE (Filesystem in UserSpacE)
+endef
+
+define Package/fuse-utils
+$(call Package/fuse/Default)
+ SECTION:=utils
+ CATEGORY:=Utilities
+ DEPENDS:=+libfuse
+ TITLE+= (utilities)
+ SUBMENU:=Filesystem
+endef
+
+define Package/fuse-utils/description
+$(call Package/fuse/Default/description)
+ This package contains the FUSE utilities.
+ - fusermount
+ - ulockmgr_server
+endef
+
+define Package/libfuse
+$(call Package/fuse/Default)
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE+= (library)
+ DEPENDS:=+kmod-fuse +libpthread
+ SUBMENU:=Filesystem
+endef
+
+define Package/libfuse/description
+$(call Package/fuse/Default/description)
+ This package contains the FUSE shared libraries, needed by other programs.
+ - libfuse
+ - libulockmgr
+endef
+
+# generic args
+CONFIGURE_ARGS += \
+ --enable-shared \
+ --enable-static \
+ --disable-rpath \
+ --disable-example \
+ --disable-mtab
+
+# generic package uses lib & utils
+CONFIGURE_ARGS += --enable-lib --enable-util
+
+define Build/InstallDev
+ @echo "--> Build/InstallDev enter"
+ mkdir -p $(1)/usr/include
+ $(CP) $(PKG_INSTALL_DIR)/usr/include/{fuse,*.h} $(1)/usr/include/
+ mkdir -p $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/*.{a,so*} $(1)/usr/lib/
+ mkdir -p $(1)/usr/lib/pkgconfig
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/fuse.pc $(1)/usr/lib/pkgconfig/
+ $(SED) 's,-I$$$${includedir}/fuse,,g' $(1)/usr/lib/pkgconfig/fuse.pc
+ $(SED) 's,-L$$$${libdir},,g' $(1)/usr/lib/pkgconfig/fuse.pc
+ @echo "--> Build/InstallDev leave"
+endef
+
+define Package/fuse-utils/install
+ @echo "--> Package/fuse-utils/install enter"
+ $(INSTALL_DIR) $(1)/usr/bin
+ # use cp and keep fusermount sticky bit
+ $(FIND) $(PKG_INSTALL_DIR)/usr/bin/ -type f -exec $(CP) -a {} $(1)/usr/bin/ \;
+ @echo "--> Package/fuse-utils/install leave"
+endef
+
+define Package/libfuse/install
+ @echo "--> Package/libfuse/install enter"
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/*.so.* $(1)/usr/lib/
+ @echo "--> Package/libfuse/install leave"
+endef
+
+define Package/kmod-fuse/install
+ @echo "--> Package/kmod-fuse/install enter/leave"
+endef
+
+$(eval $(call BuildPackage,fuse-utils))
+$(eval $(call BuildPackage,libfuse))
diff --git a/package/fuse/Makefile b/package/fuse/Makefile
new file mode 100644
index 0000000..0620b6c
--- /dev/null
+++ b/package/fuse/Makefile
@@ -0,0 +1,111 @@
+#
+# Copyright (C) 2006-2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=fuse
+PKG_VERSION:=2.9.0
+PKG_RELEASE:=2
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=@SF/$(PKG_NAME)
+PKG_MD5SUM:=894ee11674f89a915ae87524aed55bc4
+
+PKG_LICENSE:=LGPLv2.1 GPLv2
+PKG_LICENSE_FILES:=COPYING.LIB COPYING
+
+PKG_INSTALL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/fuse/Default
+ TITLE:=FUSE
+ URL:=http://fuse.sourceforge.net/
+endef
+
+define Package/fuse/Default/description
+ FUSE (Filesystem in UserSpacE)
+endef
+
+define Package/fuse-utils
+$(call Package/fuse/Default)
+ SECTION:=utils
+ CATEGORY:=Utilities
+ DEPENDS:=+libfuse
+ TITLE+= (utilities)
+ SUBMENU:=Filesystem
+endef
+
+define Package/fuse-utils/description
+$(call Package/fuse/Default/description)
+ This package contains the FUSE utilities.
+ - fusermount
+ - ulockmgr_server
+endef
+
+define Package/libfuse
+$(call Package/fuse/Default)
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE+= (library)
+ DEPENDS:=+kmod-fuse +libpthread
+ SUBMENU:=Filesystem
+endef
+
+define Package/libfuse/description
+$(call Package/fuse/Default/description)
+ This package contains the FUSE shared libraries, needed by other programs.
+ - libfuse
+ - libulockmgr
+endef
+
+# generic args
+CONFIGURE_ARGS += \
+ --enable-shared \
+ --enable-static \
+ --disable-rpath \
+ --disable-example \
+ --disable-mtab
+
+# generic package uses lib & utils
+CONFIGURE_ARGS += --enable-lib --enable-util
+
+define Build/InstallDev
+ @echo "--> Build/InstallDev enter"
+ mkdir -p $(1)/usr/include
+ $(CP) $(PKG_INSTALL_DIR)/usr/include/{fuse,*.h} $(1)/usr/include/
+ mkdir -p $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/*.{a,so*} $(1)/usr/lib/
+ mkdir -p $(1)/usr/lib/pkgconfig
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/fuse.pc $(1)/usr/lib/pkgconfig/
+ $(SED) 's,-I$$$${includedir}/fuse,,g' $(1)/usr/lib/pkgconfig/fuse.pc
+ $(SED) 's,-L$$$${libdir},,g' $(1)/usr/lib/pkgconfig/fuse.pc
+ @echo "--> Build/InstallDev leave"
+endef
+
+define Package/fuse-utils/install
+ @echo "--> Package/fuse-utils/install enter"
+ $(INSTALL_DIR) $(1)/usr/bin
+ # use cp and keep fusermount sticky bit
+ $(FIND) $(PKG_INSTALL_DIR)/usr/bin/ -type f -exec $(CP) -a {} $(1)/usr/bin/ \;
+ @echo "--> Package/fuse-utils/install leave"
+endef
+
+define Package/libfuse/install
+ @echo "--> Package/libfuse/install enter"
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/*.so.* $(1)/usr/lib/
+ @echo "--> Package/libfuse/install leave"
+endef
+
+define Package/kmod-fuse/install
+ @echo "--> Package/kmod-fuse/install enter/leave"
+endef
+
+$(eval $(call BuildPackage,fuse-utils))
+$(eval $(call BuildPackage,libfuse))
diff --git a/package/fuse/patches/.svn/entries b/package/fuse/patches/.svn/entries
new file mode 100644
index 0000000..5a7290e
--- /dev/null
+++ b/package/fuse/patches/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/fuse/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-06-16T21:06:37.183617Z
+32396
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+112-no_break_on_mknod.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+6feab9779fe8ec4b7dec2c30d8cd3c57
+2012-06-16T21:06:37.183617Z
+32396
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+415
+
diff --git a/package/fuse/patches/.svn/prop-base/112-no_break_on_mknod.patch.svn-base b/package/fuse/patches/.svn/prop-base/112-no_break_on_mknod.patch.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/fuse/patches/.svn/prop-base/112-no_break_on_mknod.patch.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/fuse/patches/.svn/text-base/112-no_break_on_mknod.patch.svn-base b/package/fuse/patches/.svn/text-base/112-no_break_on_mknod.patch.svn-base
new file mode 100644
index 0000000..5f913df
--- /dev/null
+++ b/package/fuse/patches/.svn/text-base/112-no_break_on_mknod.patch.svn-base
@@ -0,0 +1,11 @@
+--- a/util/Makefile.in
++++ b/util/Makefile.in
+@@ -641,7 +641,7 @@ mount_util.c: $(top_srcdir)/lib/mount_ut
+
+ install-exec-hook:
+ -chmod u+s $(DESTDIR)$(bindir)/fusermount
+- @if test ! -e $(DESTDIR)/dev/fuse; then \
++ -@if test ! -e $(DESTDIR)/dev/fuse; then \
+ $(mkdir_p) $(DESTDIR)/dev; \
+ echo "mknod $(DESTDIR)/dev/fuse -m 0666 c 10 229 || true"; \
+ mknod $(DESTDIR)/dev/fuse -m 0666 c 10 229 || true; \
diff --git a/package/fuse/patches/112-no_break_on_mknod.patch b/package/fuse/patches/112-no_break_on_mknod.patch
new file mode 100644
index 0000000..5f913df
--- /dev/null
+++ b/package/fuse/patches/112-no_break_on_mknod.patch
@@ -0,0 +1,11 @@
+--- a/util/Makefile.in
++++ b/util/Makefile.in
+@@ -641,7 +641,7 @@ mount_util.c: $(top_srcdir)/lib/mount_ut
+
+ install-exec-hook:
+ -chmod u+s $(DESTDIR)$(bindir)/fusermount
+- @if test ! -e $(DESTDIR)/dev/fuse; then \
++ -@if test ! -e $(DESTDIR)/dev/fuse; then \
+ $(mkdir_p) $(DESTDIR)/dev; \
+ echo "mknod $(DESTDIR)/dev/fuse -m 0666 c 10 229 || true"; \
+ mknod $(DESTDIR)/dev/fuse -m 0666 c 10 229 || true; \
diff --git a/package/hotplug2/.svn/entries b/package/hotplug2/.svn/entries
new file mode 100644
index 0000000..e0cdc1c
--- /dev/null
+++ b/package/hotplug2/.svn/entries
@@ -0,0 +1,71 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/hotplug2
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-03T17:05:05.482112Z
+35863
+juhosg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+files
+dir
+
+patches
+dir
+
+src
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+3b5e657fc9ebb18d93f606144c257d8e
+2013-02-15T13:25:18.509639Z
+35608
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1768
+
diff --git a/package/hotplug2/.svn/text-base/Makefile.svn-base b/package/hotplug2/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..6b86c65
--- /dev/null
+++ b/package/hotplug2/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,66 @@
+#
+# Copyright (C) 2006-2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=hotplug2
+PKG_REV:=201
+PKG_VERSION:=$(PKG_REV)
+PKG_RELEASE:=4
+
+PKG_SOURCE_PROTO:=svn
+PKG_SOURCE_VERSION:=$(PKG_REV)
+PKG_SOURCE_SUBDIR:=hotplug2-$(PKG_VERSION)
+PKG_SOURCE_URL:=http://svn.nomi.cz/svn/isteve/hotplug2
+PKG_SOURCE:=$(PKG_SOURCE_SUBDIR).tar.gz
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+#PKG_SOURCE_URL:=http://isteve.bofh.cz/~isteve/hotplug2
+#PKG_MD5SUM:=ea2c01d027b4002e4e6b0ff266f51a51
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/hotplug2
+ SECTION:=base
+ CATEGORY:=Base system
+ VERSION:=1.0-beta-$(PKG_RELEASE)
+ TITLE:=Version 1.0 Dynamic device management subsystem for embedded systems
+ URL:=http://isteve.bofh.cz/~isteve/hotplug2/
+ DEPENDS:=+USE_EGLIBC:libbsd
+endef
+
+define Package/hotplug2/description
+ Hotplug2 is a trivial replacement of some of the UDev functionality
+ in a tiny pack, intended for Linux early userspace: Init RAM FS and InitRD.
+ This is an implementation of Hotplug2-1.0-beta
+endef
+
+define Package/hotplug2/conffiles
+/etc/hotplug2.rules
+endef
+
+MAKE_FLAGS += \
+ COPTS="$(TARGET_CFLAGS)" \
+ STATIC_WORKER="fork"
+
+ifneq ($(CONFIG_USE_EGLIBC),)
+ TARGET_LDFLAGS += -lbsd
+endif
+
+define Build/Compile
+ $(call Build/Compile/Default)
+ $(TARGET_CC) $(TARGET_CFLAGS) $(TARGET_LDFLAGS) -o $(PKG_BUILD_DIR)/udevtrigger src/udevtrigger.c
+endef
+
+define Package/hotplug2/install
+ $(INSTALL_DIR) $(1)/etc
+ $(INSTALL_DATA) ./files/hotplug2.rules $(1)/etc/
+ $(INSTALL_DIR) $(1)/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/udevtrigger $(1)/sbin/
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/hotplug2 $(1)/sbin/
+endef
+
+$(eval $(call BuildPackage,hotplug2))
diff --git a/package/hotplug2/Makefile b/package/hotplug2/Makefile
new file mode 100644
index 0000000..6b86c65
--- /dev/null
+++ b/package/hotplug2/Makefile
@@ -0,0 +1,66 @@
+#
+# Copyright (C) 2006-2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=hotplug2
+PKG_REV:=201
+PKG_VERSION:=$(PKG_REV)
+PKG_RELEASE:=4
+
+PKG_SOURCE_PROTO:=svn
+PKG_SOURCE_VERSION:=$(PKG_REV)
+PKG_SOURCE_SUBDIR:=hotplug2-$(PKG_VERSION)
+PKG_SOURCE_URL:=http://svn.nomi.cz/svn/isteve/hotplug2
+PKG_SOURCE:=$(PKG_SOURCE_SUBDIR).tar.gz
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+#PKG_SOURCE_URL:=http://isteve.bofh.cz/~isteve/hotplug2
+#PKG_MD5SUM:=ea2c01d027b4002e4e6b0ff266f51a51
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/hotplug2
+ SECTION:=base
+ CATEGORY:=Base system
+ VERSION:=1.0-beta-$(PKG_RELEASE)
+ TITLE:=Version 1.0 Dynamic device management subsystem for embedded systems
+ URL:=http://isteve.bofh.cz/~isteve/hotplug2/
+ DEPENDS:=+USE_EGLIBC:libbsd
+endef
+
+define Package/hotplug2/description
+ Hotplug2 is a trivial replacement of some of the UDev functionality
+ in a tiny pack, intended for Linux early userspace: Init RAM FS and InitRD.
+ This is an implementation of Hotplug2-1.0-beta
+endef
+
+define Package/hotplug2/conffiles
+/etc/hotplug2.rules
+endef
+
+MAKE_FLAGS += \
+ COPTS="$(TARGET_CFLAGS)" \
+ STATIC_WORKER="fork"
+
+ifneq ($(CONFIG_USE_EGLIBC),)
+ TARGET_LDFLAGS += -lbsd
+endif
+
+define Build/Compile
+ $(call Build/Compile/Default)
+ $(TARGET_CC) $(TARGET_CFLAGS) $(TARGET_LDFLAGS) -o $(PKG_BUILD_DIR)/udevtrigger src/udevtrigger.c
+endef
+
+define Package/hotplug2/install
+ $(INSTALL_DIR) $(1)/etc
+ $(INSTALL_DATA) ./files/hotplug2.rules $(1)/etc/
+ $(INSTALL_DIR) $(1)/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/udevtrigger $(1)/sbin/
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/hotplug2 $(1)/sbin/
+endef
+
+$(eval $(call BuildPackage,hotplug2))
diff --git a/package/hotplug2/files/.svn/entries b/package/hotplug2/files/.svn/entries
new file mode 100644
index 0000000..2d6ae73
--- /dev/null
+++ b/package/hotplug2/files/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/hotplug2/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2011-11-05T17:16:01.653535Z
+28768
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+hotplug2.rules
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+d4975ba71cf50d3d3c286b0de0f0929a
+2011-11-05T17:16:01.653535Z
+28768
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+242
+
diff --git a/package/hotplug2/files/.svn/text-base/hotplug2.rules.svn-base b/package/hotplug2/files/.svn/text-base/hotplug2.rules.svn-base
new file mode 100644
index 0000000..246cc3a
--- /dev/null
+++ b/package/hotplug2/files/.svn/text-base/hotplug2.rules.svn-base
@@ -0,0 +1,10 @@
+$include /etc/hotplug2-common.rules
+
+SUBSYSTEM ~~ (^net$|^input$|^button$|^usb$|^ieee1394$|^block$|^atm$|^zaptel$|^tty$) {
+ exec /sbin/hotplug-call %SUBSYSTEM%
+}
+
+DEVICENAME == watchdog {
+ exec /sbin/watchdog -t 5 /dev/watchdog
+ next-event
+}
diff --git a/package/hotplug2/files/hotplug2.rules b/package/hotplug2/files/hotplug2.rules
new file mode 100644
index 0000000..246cc3a
--- /dev/null
+++ b/package/hotplug2/files/hotplug2.rules
@@ -0,0 +1,10 @@
+$include /etc/hotplug2-common.rules
+
+SUBSYSTEM ~~ (^net$|^input$|^button$|^usb$|^ieee1394$|^block$|^atm$|^zaptel$|^tty$) {
+ exec /sbin/hotplug-call %SUBSYSTEM%
+}
+
+DEVICENAME == watchdog {
+ exec /sbin/watchdog -t 5 /dev/watchdog
+ next-event
+}
diff --git a/package/hotplug2/patches/.svn/entries b/package/hotplug2/patches/.svn/entries
new file mode 100644
index 0000000..7c324f1
--- /dev/null
+++ b/package/hotplug2/patches/.svn/entries
@@ -0,0 +1,232 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/hotplug2/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-03T17:05:05.482112Z
+35863
+juhosg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+100-env_memleak.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+143e755de44bf28ae52666f277a5decb
+2010-03-26T14:28:25.844871Z
+20462
+juhosg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1469
+
+140-worker_fork_fix.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+53077ddc1a80a0a05b3c10c615e61dbf
+2013-03-03T13:56:36.282605Z
+35857
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+6479
+
+130-cancel_download_fix.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+d9f895e49237290879e3a19cee3bea59
+2010-04-03T18:29:37.614307Z
+20685
+acinonyx
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+465
+
+120-sysfs_path_fix.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+83bb9f76c4c4de8dc9f41055f2e4e34f
+2010-04-03T18:29:37.614307Z
+20685
+acinonyx
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+591
+
+170-non_fatal_include.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+85a0e5eb0c9066c31736c6d7ee205de0
+2013-03-03T17:05:05.482112Z
+35863
+juhosg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+576
+
+110-static_worker.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+e79c2340ba22792a2cf04df44fe9329a
+2010-03-26T14:28:25.844871Z
+20462
+juhosg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+309
+
diff --git a/package/hotplug2/patches/.svn/text-base/100-env_memleak.patch.svn-base b/package/hotplug2/patches/.svn/text-base/100-env_memleak.patch.svn-base
new file mode 100644
index 0000000..28a3e25
--- /dev/null
+++ b/package/hotplug2/patches/.svn/text-base/100-env_memleak.patch.svn-base
@@ -0,0 +1,63 @@
+--- a/action.c
++++ b/action.c
+@@ -31,6 +31,30 @@ static void action_dumb(const struct set
+ }
+
+ /**
++ * Creates a "key=value" string from the given key and value
++ *
++ * @1 Key
++ * @2 Value
++ *
++ * Returns: Newly allocated string in "key=value" form
++ *
++ */
++static char* alloc_env(const char *key, const char *value) {
++ size_t keylen, vallen;
++ char *combined;
++
++ keylen = strlen(key);
++ vallen = strlen(value) + 1;
++
++ combined = xmalloc(keylen + vallen + 1);
++ memcpy(combined, key, keylen);
++ combined[keylen] = '=';
++ memcpy(&combined[keylen + 1], value, vallen);
++
++ return combined;
++}
++
++/**
+ * Choose what action should be taken according to passed settings.
+ *
+ * @1 Hotplug settings
+@@ -41,16 +65,25 @@ static void action_dumb(const struct set
+ */
+ void action_perform(struct settings_t *settings, struct uevent_t *event) {
+ int i;
++ char **env;
++
++ env = xmalloc(sizeof(char *) * event->env_vars_c);
++
++ for (i = 0; i < event->env_vars_c; i++) {
++ env[i] = alloc_env(event->env_vars[i].key, event->env_vars[i].value);
++ putenv(env[i]);
++ }
+
+- for (i = 0; i < event->env_vars_c; i++)
+- setenv(event->env_vars[i].key, event->env_vars[i].value, 1);
+-
+ if (settings->dumb == 0) {
+ ruleset_execute(&settings->rules, event, settings);
+ } else {
+ action_dumb(settings, event);
+ }
+
+- for (i = 0; i < event->env_vars_c; i++)
++ for (i = 0; i < event->env_vars_c; i++) {
+ unsetenv(event->env_vars[i].key);
++ free(env[i]);
++ }
++
++ free(env);
+ }
diff --git a/package/hotplug2/patches/.svn/text-base/110-static_worker.patch.svn-base b/package/hotplug2/patches/.svn/text-base/110-static_worker.patch.svn-base
new file mode 100644
index 0000000..3a5181f
--- /dev/null
+++ b/package/hotplug2/patches/.svn/text-base/110-static_worker.patch.svn-base
@@ -0,0 +1,20 @@
+--- a/common.mak
++++ b/common.mak
+@@ -1,7 +1,7 @@
+ # vim:set sw=8 nosta:
+
+ COPTS=-Os -Wall -g
+-LDFLAGS=-g -ldl
++LDFLAGS=-g
+
+ CFLAGS=$(COPTS)
+ FPIC=-fPIC
+--- a/Makefile
++++ b/Makefile
+@@ -40,5 +40,6 @@ ifdef STATIC_WORKER
+ CFLAGS += -DSTATIC_WORKER=1
+ else
+ CFLAGS += $(FPIC)
++ LDFLAGS += -ldl
+ endif
+
diff --git a/package/hotplug2/patches/.svn/text-base/120-sysfs_path_fix.patch.svn-base b/package/hotplug2/patches/.svn/text-base/120-sysfs_path_fix.patch.svn-base
new file mode 100644
index 0000000..0903057
--- /dev/null
+++ b/package/hotplug2/patches/.svn/text-base/120-sysfs_path_fix.patch.svn-base
@@ -0,0 +1,14 @@
+--- a/rules/command.c
++++ b/rules/command.c
+@@ -374,9 +374,9 @@ RULES_COMMAND_F(cmd_firmware) {
+ if (firmware == NULL)
+ return -1;
+
+- if (snprintf(sysfs_path_loading, PATH_MAX, "/sysfs%s/loading", devpath) >= PATH_MAX)
++ if (snprintf(sysfs_path_loading, PATH_MAX, "/sys%s/loading", devpath) >= PATH_MAX)
+ return -1;
+- if (snprintf(sysfs_path_data, PATH_MAX, "/sysfs%s/data", devpath) >= PATH_MAX)
++ if (snprintf(sysfs_path_data, PATH_MAX, "/sys%s/data", devpath) >= PATH_MAX)
+ return -1;
+ if (snprintf(firmware_path, PATH_MAX, "%s/%s", argv[0], firmware) >= PATH_MAX)
+ return -1;
diff --git a/package/hotplug2/patches/.svn/text-base/130-cancel_download_fix.patch.svn-base b/package/hotplug2/patches/.svn/text-base/130-cancel_download_fix.patch.svn-base
new file mode 100644
index 0000000..c94000d
--- /dev/null
+++ b/package/hotplug2/patches/.svn/text-base/130-cancel_download_fix.patch.svn-base
@@ -0,0 +1,18 @@
+--- a/rules/command.c
++++ b/rules/command.c
+@@ -385,13 +385,13 @@ RULES_COMMAND_F(cmd_firmware) {
+
+ infp = fopen(firmware_path, "r");
+ if (infp == NULL) {
+- echo_to_file(sysfs_path_loading, "0\n", 2);
++ echo_to_file(sysfs_path_loading, "-1\n", 2);
+ return -1;
+ }
+ outfp = fopen(sysfs_path_data, "w");
+ if (outfp == NULL) {
+ fclose(infp);
+- echo_to_file(sysfs_path_loading, "0\n", 2);
++ echo_to_file(sysfs_path_loading, "-1\n", 2);
+ return -1;
+ }
+
diff --git a/package/hotplug2/patches/.svn/text-base/140-worker_fork_fix.patch.svn-base b/package/hotplug2/patches/.svn/text-base/140-worker_fork_fix.patch.svn-base
new file mode 100644
index 0000000..5e288ae
--- /dev/null
+++ b/package/hotplug2/patches/.svn/text-base/140-worker_fork_fix.patch.svn-base
@@ -0,0 +1,237 @@
+--- a/action.c
++++ b/action.c
+@@ -39,7 +39,7 @@ static void action_dumb(const struct set
+ * Returns: Newly allocated string in "key=value" form
+ *
+ */
+-static char* alloc_env(const char *key, const char *value) {
++char* alloc_env(const char *key, const char *value) {
+ size_t keylen, vallen;
+ char *combined;
+
+--- a/action.h
++++ b/action.h
+@@ -12,5 +12,6 @@
+ #include "settings.h"
+
+ void action_perform(struct settings_t *, struct uevent_t *);
++char* alloc_env(const char *, const char *);
+ #endif /* ifndef ACTION_H */
+
+--- a/workers/worker_fork.c
++++ b/workers/worker_fork.c
+@@ -1,6 +1,69 @@
+ #include "worker_fork.h"
+
+ static struct worker_fork_ctx_t *global_ctx;
++static struct worker_fork_uevent_t *uevent_list;
++
++static void worker_fork_uevent_free(struct worker_fork_uevent_t *node) {
++ uevent_free(node->uevent);
++ free(node);
++}
++
++static void worker_fork_uevent_add(void *in_ctx, struct uevent_t *uevent) {
++ char **env;
++ int i;
++ struct worker_fork_ctx_t *ctx = in_ctx;
++ struct worker_fork_uevent_t *node, *walker;
++
++ node = malloc(sizeof (struct worker_fork_uevent_t));
++ node->uevent = uevent_dup(uevent);
++ node->next = NULL;
++
++ if (!uevent_list) uevent_list = node;
++ else {
++ /*
++ * Put events that need to fork first and in reverse order
++ */
++ env = xmalloc(sizeof(char *) * node->uevent->env_vars_c);
++ for (i = 0; i < node->uevent->env_vars_c; i++) {
++ env[i] = alloc_env(node->uevent->env_vars[i].key, node->uevent->env_vars[i].value);
++ putenv(env[i]);
++ }
++ if (ruleset_flags(&ctx->settings->rules, uevent) & FLAG_SLOW) {
++ node->next = uevent_list;
++ uevent_list = node;
++ }
++ else {
++ for (walker = uevent_list; walker->next; walker = walker->next);
++ walker->next = node;
++ }
++ for (i = 0; i < node->uevent->env_vars_c; i++) {
++ unsetenv(node->uevent->env_vars[i].key);
++ free(env[i]);
++ }
++ free(env);
++ }
++}
++
++static void worker_fork_uevent_del(struct worker_fork_uevent_t *node) {
++ struct worker_fork_uevent_t *walker;
++
++ if (node == uevent_list) {
++ uevent_list = node->next;
++ }
++ else {
++ for (walker = uevent_list; walker->next; walker = walker->next)
++ if (walker->next == node) walker->next = node->next;
++ }
++ worker_fork_uevent_free(node);
++}
++
++static void worker_fork_uevent_empty(void) {
++ struct worker_fork_uevent_t *walker;
++
++ if (!uevent_list) return;
++ for (walker = uevent_list; walker->next; walker = walker->next) worker_fork_uevent_free(walker);
++ uevent_list = NULL;
++}
+
+ /**
+ * Destroys data structures related to the given child ID (not PID).
+@@ -315,6 +378,8 @@ static void *worker_fork_init(struct set
+ struct worker_fork_ctx_t *ctx;
+ PRINTFUNC();
+
++ uevent_list = NULL;
++
+ ctx = malloc(sizeof(struct worker_fork_ctx_t));
+ ctx->children = NULL;
+ ctx->children_count = 0;
+@@ -376,26 +441,39 @@ static void worker_fork_deinit(void *in_
+ free(ctx->children);
+ free(ctx);
+ global_ctx = NULL;
++ worker_fork_uevent_empty();
+ }
+
+
+ static int worker_fork_process(void *in_ctx, struct uevent_t *uevent) {
++ char **env;
+ int i;
+ struct worker_fork_child_t *child;
+ struct worker_fork_ctx_t *ctx = in_ctx;
++ struct worker_fork_uevent_t *node, *walker;
++ event_seqnum_t seqnum;
++
++ worker_fork_uevent_add(ctx, uevent);
++ walker = uevent_list;
+
+ /*
+- * A big loop, because if we fail to process the event,
++ * A big loop, because if we fail to process the events,
+ * we don't want to give up.
+ *
+ * TODO: Decide if we want to limit the number of attempts
+ * or set a time limit before reporting terminal failure.
+ */
+ do {
++ /*
++ * If more events are waiting, return to receive them
++ */
++ if (!seqnum_get(&seqnum) && seqnum > uevent->seqnum) break;
++
++ node = walker;
+ worker_fork_update_children(ctx);
+
+ child = NULL;
+- for (i = 0; i < ctx->children_count; i++) {
++ for (i = 0; i < ctx->children_count && i < ctx->max_children; i++) {
+ if (ctx->children[i]->busy == 0) {
+ child = ctx->children[i];
+ break;
+@@ -406,21 +484,40 @@ static int worker_fork_process(void *in_
+ * No child process is currently available.
+ */
+ if (child == NULL) {
++ bool is_slow;
++
++ env = xmalloc(sizeof(char *) * node->uevent->env_vars_c);
++ for (i = 0; i < node->uevent->env_vars_c; i++) {
++ env[i] = alloc_env(node->uevent->env_vars[i].key, node->uevent->env_vars[i].value);
++ putenv(env[i]);
++ }
++
++ is_slow = !!(ruleset_flags(&ctx->settings->rules, node->uevent) & FLAG_MASK_SLOW);
++
++ for (i = 0; i < node->uevent->env_vars_c; i++) {
++ unsetenv(node->uevent->env_vars[i].key);
++ free(env[i]);
++ }
++ free(env);
++
+ /*
+ * Are the matching rules trivial enough that we
+ * can execute them in the main process?
+ */
+- if (ctx->always_fork == 0 && ctx->settings->dumb == 0 &&
+- (ruleset_flags(&ctx->settings->rules, uevent) & FLAG_MASK_SLOW) == 0) {
+- action_perform(ctx->settings, uevent);
++ if (ctx->always_fork == 0 && ctx->settings->dumb == 0 && !is_slow) {
++ action_perform(ctx->settings, node->uevent);
++ walker = walker->next;
++ worker_fork_uevent_del(node);
++ if (walker) continue;
+ break;
+ }
+-
++
+ /*
+ * We have to fork off a new child.
+ */
+ if (ctx->children_count < ctx->max_children)
+ child = worker_fork_spawn(ctx);
++
+ }
+
+ /*
+@@ -428,9 +525,14 @@ static int worker_fork_process(void *in_
+ */
+ if (child != NULL) {
+ child->busy = 1;
+- if (!worker_fork_relay_event(child->event_fd, uevent));
+- break;
+- child->busy = 0;
++ if (worker_fork_relay_event(child->event_fd, node->uevent)) {
++ child->busy = 0;
++ continue;
++ }
++ walker = walker->next;
++ worker_fork_uevent_del(node);
++ if (walker) continue;
++ break;
+ }
+
+ /*
+--- a/uevent.c
++++ b/uevent.c
+@@ -132,6 +132,8 @@ struct uevent_t *uevent_dup(const struct
+
+ dest = xmalloc(sizeof(struct uevent_t));
+ dest->action = src->action;
++ dest->seqnum = src->seqnum;
++ dest->action_str = strdup(src->action_str);
+ dest->env_vars_c = src->env_vars_c;
+ dest->env_vars = xmalloc(sizeof(struct env_var_t) * dest->env_vars_c);
+ dest->plain_s = src->plain_s;
+--- a/workers/worker_fork.h
++++ b/workers/worker_fork.h
+@@ -5,6 +5,7 @@
+ #include <sys/types.h>
+ #include <sys/select.h>
+ #include <unistd.h>
++#include <stdbool.h>
+
+ #include "../rules/execution.h"
+
+@@ -35,4 +36,9 @@ struct worker_fork_ctx_t {
+ struct settings_t *settings;
+ };
+
++struct worker_fork_uevent_t {
++ struct uevent_t *uevent;
++ struct worker_fork_uevent_t *next;
++};
++
+ #endif
diff --git a/package/hotplug2/patches/.svn/text-base/170-non_fatal_include.patch.svn-base b/package/hotplug2/patches/.svn/text-base/170-non_fatal_include.patch.svn-base
new file mode 100644
index 0000000..0b8e852
--- /dev/null
+++ b/package/hotplug2/patches/.svn/text-base/170-non_fatal_include.patch.svn-base
@@ -0,0 +1,21 @@
+Index: hotplug2-201/parser/parser.c
+===================================================================
+--- hotplug2-201.orig/parser/parser.c 2009-12-09 19:44:13.000000000 +0100
++++ hotplug2-201/parser/parser.c 2011-02-08 18:06:44.681213713 +0100
+@@ -1,5 +1,7 @@
+ #include "parser.h"
+
++#include <errno.h>
++
+ /*
+ * Grammar:
+ * input => directive // TOKEN_ROOTKW
+@@ -578,7 +580,7 @@
+ ctx.lexer.fp = fopen(filename, "r");
+ if (ctx.lexer.fp == NULL) {
+ parser_clear(&ctx);
+- return -1;
++ return (errno == ENOENT) ? 0 : -1;
+ }
+ ctx.lexer.filename = strdup(filename);
+
diff --git a/package/hotplug2/patches/100-env_memleak.patch b/package/hotplug2/patches/100-env_memleak.patch
new file mode 100644
index 0000000..28a3e25
--- /dev/null
+++ b/package/hotplug2/patches/100-env_memleak.patch
@@ -0,0 +1,63 @@
+--- a/action.c
++++ b/action.c
+@@ -31,6 +31,30 @@ static void action_dumb(const struct set
+ }
+
+ /**
++ * Creates a "key=value" string from the given key and value
++ *
++ * @1 Key
++ * @2 Value
++ *
++ * Returns: Newly allocated string in "key=value" form
++ *
++ */
++static char* alloc_env(const char *key, const char *value) {
++ size_t keylen, vallen;
++ char *combined;
++
++ keylen = strlen(key);
++ vallen = strlen(value) + 1;
++
++ combined = xmalloc(keylen + vallen + 1);
++ memcpy(combined, key, keylen);
++ combined[keylen] = '=';
++ memcpy(&combined[keylen + 1], value, vallen);
++
++ return combined;
++}
++
++/**
+ * Choose what action should be taken according to passed settings.
+ *
+ * @1 Hotplug settings
+@@ -41,16 +65,25 @@ static void action_dumb(const struct set
+ */
+ void action_perform(struct settings_t *settings, struct uevent_t *event) {
+ int i;
++ char **env;
++
++ env = xmalloc(sizeof(char *) * event->env_vars_c);
++
++ for (i = 0; i < event->env_vars_c; i++) {
++ env[i] = alloc_env(event->env_vars[i].key, event->env_vars[i].value);
++ putenv(env[i]);
++ }
+
+- for (i = 0; i < event->env_vars_c; i++)
+- setenv(event->env_vars[i].key, event->env_vars[i].value, 1);
+-
+ if (settings->dumb == 0) {
+ ruleset_execute(&settings->rules, event, settings);
+ } else {
+ action_dumb(settings, event);
+ }
+
+- for (i = 0; i < event->env_vars_c; i++)
++ for (i = 0; i < event->env_vars_c; i++) {
+ unsetenv(event->env_vars[i].key);
++ free(env[i]);
++ }
++
++ free(env);
+ }
diff --git a/package/hotplug2/patches/110-static_worker.patch b/package/hotplug2/patches/110-static_worker.patch
new file mode 100644
index 0000000..3a5181f
--- /dev/null
+++ b/package/hotplug2/patches/110-static_worker.patch
@@ -0,0 +1,20 @@
+--- a/common.mak
++++ b/common.mak
+@@ -1,7 +1,7 @@
+ # vim:set sw=8 nosta:
+
+ COPTS=-Os -Wall -g
+-LDFLAGS=-g -ldl
++LDFLAGS=-g
+
+ CFLAGS=$(COPTS)
+ FPIC=-fPIC
+--- a/Makefile
++++ b/Makefile
+@@ -40,5 +40,6 @@ ifdef STATIC_WORKER
+ CFLAGS += -DSTATIC_WORKER=1
+ else
+ CFLAGS += $(FPIC)
++ LDFLAGS += -ldl
+ endif
+
diff --git a/package/hotplug2/patches/120-sysfs_path_fix.patch b/package/hotplug2/patches/120-sysfs_path_fix.patch
new file mode 100644
index 0000000..0903057
--- /dev/null
+++ b/package/hotplug2/patches/120-sysfs_path_fix.patch
@@ -0,0 +1,14 @@
+--- a/rules/command.c
++++ b/rules/command.c
+@@ -374,9 +374,9 @@ RULES_COMMAND_F(cmd_firmware) {
+ if (firmware == NULL)
+ return -1;
+
+- if (snprintf(sysfs_path_loading, PATH_MAX, "/sysfs%s/loading", devpath) >= PATH_MAX)
++ if (snprintf(sysfs_path_loading, PATH_MAX, "/sys%s/loading", devpath) >= PATH_MAX)
+ return -1;
+- if (snprintf(sysfs_path_data, PATH_MAX, "/sysfs%s/data", devpath) >= PATH_MAX)
++ if (snprintf(sysfs_path_data, PATH_MAX, "/sys%s/data", devpath) >= PATH_MAX)
+ return -1;
+ if (snprintf(firmware_path, PATH_MAX, "%s/%s", argv[0], firmware) >= PATH_MAX)
+ return -1;
diff --git a/package/hotplug2/patches/130-cancel_download_fix.patch b/package/hotplug2/patches/130-cancel_download_fix.patch
new file mode 100644
index 0000000..c94000d
--- /dev/null
+++ b/package/hotplug2/patches/130-cancel_download_fix.patch
@@ -0,0 +1,18 @@
+--- a/rules/command.c
++++ b/rules/command.c
+@@ -385,13 +385,13 @@ RULES_COMMAND_F(cmd_firmware) {
+
+ infp = fopen(firmware_path, "r");
+ if (infp == NULL) {
+- echo_to_file(sysfs_path_loading, "0\n", 2);
++ echo_to_file(sysfs_path_loading, "-1\n", 2);
+ return -1;
+ }
+ outfp = fopen(sysfs_path_data, "w");
+ if (outfp == NULL) {
+ fclose(infp);
+- echo_to_file(sysfs_path_loading, "0\n", 2);
++ echo_to_file(sysfs_path_loading, "-1\n", 2);
+ return -1;
+ }
+
diff --git a/package/hotplug2/patches/140-worker_fork_fix.patch b/package/hotplug2/patches/140-worker_fork_fix.patch
new file mode 100644
index 0000000..5e288ae
--- /dev/null
+++ b/package/hotplug2/patches/140-worker_fork_fix.patch
@@ -0,0 +1,237 @@
+--- a/action.c
++++ b/action.c
+@@ -39,7 +39,7 @@ static void action_dumb(const struct set
+ * Returns: Newly allocated string in "key=value" form
+ *
+ */
+-static char* alloc_env(const char *key, const char *value) {
++char* alloc_env(const char *key, const char *value) {
+ size_t keylen, vallen;
+ char *combined;
+
+--- a/action.h
++++ b/action.h
+@@ -12,5 +12,6 @@
+ #include "settings.h"
+
+ void action_perform(struct settings_t *, struct uevent_t *);
++char* alloc_env(const char *, const char *);
+ #endif /* ifndef ACTION_H */
+
+--- a/workers/worker_fork.c
++++ b/workers/worker_fork.c
+@@ -1,6 +1,69 @@
+ #include "worker_fork.h"
+
+ static struct worker_fork_ctx_t *global_ctx;
++static struct worker_fork_uevent_t *uevent_list;
++
++static void worker_fork_uevent_free(struct worker_fork_uevent_t *node) {
++ uevent_free(node->uevent);
++ free(node);
++}
++
++static void worker_fork_uevent_add(void *in_ctx, struct uevent_t *uevent) {
++ char **env;
++ int i;
++ struct worker_fork_ctx_t *ctx = in_ctx;
++ struct worker_fork_uevent_t *node, *walker;
++
++ node = malloc(sizeof (struct worker_fork_uevent_t));
++ node->uevent = uevent_dup(uevent);
++ node->next = NULL;
++
++ if (!uevent_list) uevent_list = node;
++ else {
++ /*
++ * Put events that need to fork first and in reverse order
++ */
++ env = xmalloc(sizeof(char *) * node->uevent->env_vars_c);
++ for (i = 0; i < node->uevent->env_vars_c; i++) {
++ env[i] = alloc_env(node->uevent->env_vars[i].key, node->uevent->env_vars[i].value);
++ putenv(env[i]);
++ }
++ if (ruleset_flags(&ctx->settings->rules, uevent) & FLAG_SLOW) {
++ node->next = uevent_list;
++ uevent_list = node;
++ }
++ else {
++ for (walker = uevent_list; walker->next; walker = walker->next);
++ walker->next = node;
++ }
++ for (i = 0; i < node->uevent->env_vars_c; i++) {
++ unsetenv(node->uevent->env_vars[i].key);
++ free(env[i]);
++ }
++ free(env);
++ }
++}
++
++static void worker_fork_uevent_del(struct worker_fork_uevent_t *node) {
++ struct worker_fork_uevent_t *walker;
++
++ if (node == uevent_list) {
++ uevent_list = node->next;
++ }
++ else {
++ for (walker = uevent_list; walker->next; walker = walker->next)
++ if (walker->next == node) walker->next = node->next;
++ }
++ worker_fork_uevent_free(node);
++}
++
++static void worker_fork_uevent_empty(void) {
++ struct worker_fork_uevent_t *walker;
++
++ if (!uevent_list) return;
++ for (walker = uevent_list; walker->next; walker = walker->next) worker_fork_uevent_free(walker);
++ uevent_list = NULL;
++}
+
+ /**
+ * Destroys data structures related to the given child ID (not PID).
+@@ -315,6 +378,8 @@ static void *worker_fork_init(struct set
+ struct worker_fork_ctx_t *ctx;
+ PRINTFUNC();
+
++ uevent_list = NULL;
++
+ ctx = malloc(sizeof(struct worker_fork_ctx_t));
+ ctx->children = NULL;
+ ctx->children_count = 0;
+@@ -376,26 +441,39 @@ static void worker_fork_deinit(void *in_
+ free(ctx->children);
+ free(ctx);
+ global_ctx = NULL;
++ worker_fork_uevent_empty();
+ }
+
+
+ static int worker_fork_process(void *in_ctx, struct uevent_t *uevent) {
++ char **env;
+ int i;
+ struct worker_fork_child_t *child;
+ struct worker_fork_ctx_t *ctx = in_ctx;
++ struct worker_fork_uevent_t *node, *walker;
++ event_seqnum_t seqnum;
++
++ worker_fork_uevent_add(ctx, uevent);
++ walker = uevent_list;
+
+ /*
+- * A big loop, because if we fail to process the event,
++ * A big loop, because if we fail to process the events,
+ * we don't want to give up.
+ *
+ * TODO: Decide if we want to limit the number of attempts
+ * or set a time limit before reporting terminal failure.
+ */
+ do {
++ /*
++ * If more events are waiting, return to receive them
++ */
++ if (!seqnum_get(&seqnum) && seqnum > uevent->seqnum) break;
++
++ node = walker;
+ worker_fork_update_children(ctx);
+
+ child = NULL;
+- for (i = 0; i < ctx->children_count; i++) {
++ for (i = 0; i < ctx->children_count && i < ctx->max_children; i++) {
+ if (ctx->children[i]->busy == 0) {
+ child = ctx->children[i];
+ break;
+@@ -406,21 +484,40 @@ static int worker_fork_process(void *in_
+ * No child process is currently available.
+ */
+ if (child == NULL) {
++ bool is_slow;
++
++ env = xmalloc(sizeof(char *) * node->uevent->env_vars_c);
++ for (i = 0; i < node->uevent->env_vars_c; i++) {
++ env[i] = alloc_env(node->uevent->env_vars[i].key, node->uevent->env_vars[i].value);
++ putenv(env[i]);
++ }
++
++ is_slow = !!(ruleset_flags(&ctx->settings->rules, node->uevent) & FLAG_MASK_SLOW);
++
++ for (i = 0; i < node->uevent->env_vars_c; i++) {
++ unsetenv(node->uevent->env_vars[i].key);
++ free(env[i]);
++ }
++ free(env);
++
+ /*
+ * Are the matching rules trivial enough that we
+ * can execute them in the main process?
+ */
+- if (ctx->always_fork == 0 && ctx->settings->dumb == 0 &&
+- (ruleset_flags(&ctx->settings->rules, uevent) & FLAG_MASK_SLOW) == 0) {
+- action_perform(ctx->settings, uevent);
++ if (ctx->always_fork == 0 && ctx->settings->dumb == 0 && !is_slow) {
++ action_perform(ctx->settings, node->uevent);
++ walker = walker->next;
++ worker_fork_uevent_del(node);
++ if (walker) continue;
+ break;
+ }
+-
++
+ /*
+ * We have to fork off a new child.
+ */
+ if (ctx->children_count < ctx->max_children)
+ child = worker_fork_spawn(ctx);
++
+ }
+
+ /*
+@@ -428,9 +525,14 @@ static int worker_fork_process(void *in_
+ */
+ if (child != NULL) {
+ child->busy = 1;
+- if (!worker_fork_relay_event(child->event_fd, uevent));
+- break;
+- child->busy = 0;
++ if (worker_fork_relay_event(child->event_fd, node->uevent)) {
++ child->busy = 0;
++ continue;
++ }
++ walker = walker->next;
++ worker_fork_uevent_del(node);
++ if (walker) continue;
++ break;
+ }
+
+ /*
+--- a/uevent.c
++++ b/uevent.c
+@@ -132,6 +132,8 @@ struct uevent_t *uevent_dup(const struct
+
+ dest = xmalloc(sizeof(struct uevent_t));
+ dest->action = src->action;
++ dest->seqnum = src->seqnum;
++ dest->action_str = strdup(src->action_str);
+ dest->env_vars_c = src->env_vars_c;
+ dest->env_vars = xmalloc(sizeof(struct env_var_t) * dest->env_vars_c);
+ dest->plain_s = src->plain_s;
+--- a/workers/worker_fork.h
++++ b/workers/worker_fork.h
+@@ -5,6 +5,7 @@
+ #include <sys/types.h>
+ #include <sys/select.h>
+ #include <unistd.h>
++#include <stdbool.h>
+
+ #include "../rules/execution.h"
+
+@@ -35,4 +36,9 @@ struct worker_fork_ctx_t {
+ struct settings_t *settings;
+ };
+
++struct worker_fork_uevent_t {
++ struct uevent_t *uevent;
++ struct worker_fork_uevent_t *next;
++};
++
+ #endif
diff --git a/package/hotplug2/patches/170-non_fatal_include.patch b/package/hotplug2/patches/170-non_fatal_include.patch
new file mode 100644
index 0000000..0b8e852
--- /dev/null
+++ b/package/hotplug2/patches/170-non_fatal_include.patch
@@ -0,0 +1,21 @@
+Index: hotplug2-201/parser/parser.c
+===================================================================
+--- hotplug2-201.orig/parser/parser.c 2009-12-09 19:44:13.000000000 +0100
++++ hotplug2-201/parser/parser.c 2011-02-08 18:06:44.681213713 +0100
+@@ -1,5 +1,7 @@
+ #include "parser.h"
+
++#include <errno.h>
++
+ /*
+ * Grammar:
+ * input => directive // TOKEN_ROOTKW
+@@ -578,7 +580,7 @@
+ ctx.lexer.fp = fopen(filename, "r");
+ if (ctx.lexer.fp == NULL) {
+ parser_clear(&ctx);
+- return -1;
++ return (errno == ENOENT) ? 0 : -1;
+ }
+ ctx.lexer.filename = strdup(filename);
+
diff --git a/package/hotplug2/src/.svn/entries b/package/hotplug2/src/.svn/entries
new file mode 100644
index 0000000..a400687
--- /dev/null
+++ b/package/hotplug2/src/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/hotplug2/src
+svn://svn.openwrt.org/openwrt
+
+
+
+2011-03-07T02:49:24.650283Z
+25920
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+udevtrigger.c
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+5a897d252eb7bc27af45a64f236acf6a
+2011-03-07T02:49:24.650283Z
+25920
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+8111
+
diff --git a/package/hotplug2/src/.svn/text-base/udevtrigger.c.svn-base b/package/hotplug2/src/.svn/text-base/udevtrigger.c.svn-base
new file mode 100644
index 0000000..297e64c
--- /dev/null
+++ b/package/hotplug2/src/.svn/text-base/udevtrigger.c.svn-base
@@ -0,0 +1,345 @@
+/*
+ * Copyright (C) 2004-2006 Kay Sievers <kay@vrfy.org>
+ * Copyright (C) 2006 Hannes Reinecke <hare@suse.de>
+ *
+ * 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 version 2 of the License.
+ *
+ * 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; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include <stdlib.h>
+#include <stddef.h>
+#include <stdarg.h>
+#include <string.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <getopt.h>
+#include <errno.h>
+#include <dirent.h>
+#include <fcntl.h>
+#include <syslog.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+
+#define PATH_SIZE 512
+
+static int verbose;
+static int dry_run;
+
+void log_message(int priority, const char *format, ...)
+{
+ va_list args;
+
+ va_start(args, format);
+ vsyslog(priority, format, args);
+ va_end(args);
+}
+
+#undef err
+#define err(format, arg...) \
+ do { \
+ log_message(LOG_ERR ,"%s: " format ,__FUNCTION__ ,## arg); \
+ } while (0)
+
+#undef info
+#define info(format, arg...) \
+ do { \
+ log_message(LOG_INFO ,"%s: " format ,__FUNCTION__ ,## arg); \
+ } while (0)
+
+#ifdef DEBUG
+#undef dbg
+#define dbg(format, arg...) \
+ do { \
+ log_message(LOG_DEBUG ,"%s: " format ,__FUNCTION__ ,## arg); \
+ } while (0)
+#else
+#define dbg(...) do {} while(0)
+#endif
+
+
+static void trigger_uevent(const char *devpath)
+{
+ char filename[PATH_SIZE];
+ int fd;
+
+ strlcpy(filename, "/sys", sizeof(filename));
+ strlcat(filename, devpath, sizeof(filename));
+ strlcat(filename, "/uevent", sizeof(filename));
+
+ if (verbose)
+ printf("%s\n", devpath);
+
+ if (dry_run)
+ return;
+
+ fd = open(filename, O_WRONLY);
+ if (fd < 0) {
+ dbg("error on opening %s: %s\n", filename, strerror(errno));
+ return;
+ }
+
+ if (write(fd, "add", 3) < 0)
+ info("error on triggering %s: %s\n", filename, strerror(errno));
+
+ close(fd);
+}
+
+static int sysfs_resolve_link(char *devpath, size_t size)
+{
+ char link_path[PATH_SIZE];
+ char link_target[PATH_SIZE];
+ int len;
+ int i;
+ int back;
+
+ strlcpy(link_path, "/sys", sizeof(link_path));
+ strlcat(link_path, devpath, sizeof(link_path));
+ len = readlink(link_path, link_target, sizeof(link_target));
+ if (len <= 0)
+ return -1;
+ link_target[len] = '\0';
+ dbg("path link '%s' points to '%s'", devpath, link_target);
+
+ for (back = 0; strncmp(&link_target[back * 3], "../", 3) == 0; back++)
+ ;
+ dbg("base '%s', tail '%s', back %i", devpath, &link_target[back * 3], back);
+ for (i = 0; i <= back; i++) {
+ char *pos = strrchr(devpath, '/');
+
+ if (pos == NULL)
+ return -1;
+ pos[0] = '\0';
+ }
+ dbg("after moving back '%s'", devpath);
+ strlcat(devpath, "/", size);
+ strlcat(devpath, &link_target[back * 3], size);
+ return 0;
+}
+
+
+static int device_list_insert(const char *path)
+{
+ char filename[PATH_SIZE];
+ char devpath[PATH_SIZE];
+ struct stat statbuf;
+
+ dbg("add '%s'" , path);
+
+ /* we only have a device, if we have an uevent file */
+ strlcpy(filename, path, sizeof(filename));
+ strlcat(filename, "/uevent", sizeof(filename));
+ if (stat(filename, &statbuf) < 0)
+ return -1;
+ if (!(statbuf.st_mode & S_IWUSR))
+ return -1;
+
+ strlcpy(devpath, &path[4], sizeof(devpath));
+
+ /* resolve possible link to real target */
+ if (lstat(path, &statbuf) < 0)
+ return -1;
+ if (S_ISLNK(statbuf.st_mode))
+ if (sysfs_resolve_link(devpath, sizeof(devpath)) != 0)
+ return -1;
+
+ trigger_uevent(devpath);
+ return 0;
+}
+
+
+static void scan_subsystem(const char *subsys)
+{
+ char base[PATH_SIZE];
+ DIR *dir;
+ struct dirent *dent;
+
+ strlcpy(base, "/sys/", sizeof(base));
+ strlcat(base, subsys, sizeof(base));
+
+ dir = opendir(base);
+ if (dir != NULL) {
+ for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) {
+ char dirname[PATH_SIZE];
+ DIR *dir2;
+ struct dirent *dent2;
+
+ if (dent->d_name[0] == '.')
+ continue;
+
+ strlcpy(dirname, base, sizeof(dirname));
+ strlcat(dirname, "/", sizeof(dirname));
+ strlcat(dirname, dent->d_name, sizeof(dirname));
+ strlcat(dirname, "/devices", sizeof(dirname));
+
+ /* look for devices */
+ dir2 = opendir(dirname);
+ if (dir2 != NULL) {
+ for (dent2 = readdir(dir2); dent2 != NULL; dent2 = readdir(dir2)) {
+ char dirname2[PATH_SIZE];
+
+ if (dent2->d_name[0] == '.')
+ continue;
+
+ strlcpy(dirname2, dirname, sizeof(dirname2));
+ strlcat(dirname2, "/", sizeof(dirname2));
+ strlcat(dirname2, dent2->d_name, sizeof(dirname2));
+ device_list_insert(dirname2);
+ }
+ closedir(dir2);
+ }
+ }
+ closedir(dir);
+ }
+}
+
+static void scan_block(void)
+{
+ char base[PATH_SIZE];
+ DIR *dir;
+ struct dirent *dent;
+
+ strlcpy(base, "/sys/block", sizeof(base));
+
+ dir = opendir(base);
+ if (dir != NULL) {
+ for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) {
+ char dirname[PATH_SIZE];
+ DIR *dir2;
+ struct dirent *dent2;
+
+ if (dent->d_name[0] == '.')
+ continue;
+
+ strlcpy(dirname, base, sizeof(dirname));
+ strlcat(dirname, "/", sizeof(dirname));
+ strlcat(dirname, dent->d_name, sizeof(dirname));
+ if (device_list_insert(dirname) != 0)
+ continue;
+
+ /* look for partitions */
+ dir2 = opendir(dirname);
+ if (dir2 != NULL) {
+ for (dent2 = readdir(dir2); dent2 != NULL; dent2 = readdir(dir2)) {
+ char dirname2[PATH_SIZE];
+
+ if (dent2->d_name[0] == '.')
+ continue;
+
+ if (!strcmp(dent2->d_name,"device"))
+ continue;
+
+ strlcpy(dirname2, dirname, sizeof(dirname2));
+ strlcat(dirname2, "/", sizeof(dirname2));
+ strlcat(dirname2, dent2->d_name, sizeof(dirname2));
+ device_list_insert(dirname2);
+ }
+ closedir(dir2);
+ }
+ }
+ closedir(dir);
+ }
+}
+
+static void scan_class(void)
+{
+ char base[PATH_SIZE];
+ DIR *dir;
+ struct dirent *dent;
+
+ strlcpy(base, "/sys/class", sizeof(base));
+
+ dir = opendir(base);
+ if (dir != NULL) {
+ for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) {
+ char dirname[PATH_SIZE];
+ DIR *dir2;
+ struct dirent *dent2;
+
+ if (dent->d_name[0] == '.')
+ continue;
+
+ strlcpy(dirname, base, sizeof(dirname));
+ strlcat(dirname, "/", sizeof(dirname));
+ strlcat(dirname, dent->d_name, sizeof(dirname));
+ dir2 = opendir(dirname);
+ if (dir2 != NULL) {
+ for (dent2 = readdir(dir2); dent2 != NULL; dent2 = readdir(dir2)) {
+ char dirname2[PATH_SIZE];
+
+ if (dent2->d_name[0] == '.')
+ continue;
+
+ if (!strcmp(dent2->d_name, "device"))
+ continue;
+
+ strlcpy(dirname2, dirname, sizeof(dirname2));
+ strlcat(dirname2, "/", sizeof(dirname2));
+ strlcat(dirname2, dent2->d_name, sizeof(dirname2));
+ device_list_insert(dirname2);
+ }
+ closedir(dir2);
+ }
+ }
+ closedir(dir);
+ }
+}
+
+int main(int argc, char *argv[], char *envp[])
+{
+ char base[PATH_SIZE];
+ struct stat statbuf;
+ int failed = 0;
+ int option;
+
+ openlog("udevtrigger", LOG_PID | LOG_CONS, LOG_DAEMON);
+
+ while (1) {
+ option = getopt(argc, argv, "vnh");
+ if (option == -1)
+ break;
+
+ switch (option) {
+ case 'v':
+ verbose = 1;
+ break;
+ case 'n':
+ dry_run = 1;
+ break;
+ case 'h':
+ printf("Usage: udevtrigger OPTIONS\n"
+ " -v print the list of devices while running\n"
+ " -n do not actually trigger the events\n"
+ " -h print this text\n"
+ "\n");
+ goto exit;
+ default:
+ goto exit;
+ }
+ }
+
+
+ /* if we have /sys/subsystem, forget all the old stuff */
+ scan_subsystem("bus");
+ scan_class();
+
+ /* scan "block" if it isn't a "class" */
+ strlcpy(base, "/sys/class/block", sizeof(base));
+ if (stat(base, &statbuf) != 0)
+ scan_block();
+
+exit:
+
+ closelog();
+ return 0;
+}
diff --git a/package/hotplug2/src/udevtrigger.c b/package/hotplug2/src/udevtrigger.c
new file mode 100644
index 0000000..297e64c
--- /dev/null
+++ b/package/hotplug2/src/udevtrigger.c
@@ -0,0 +1,345 @@
+/*
+ * Copyright (C) 2004-2006 Kay Sievers <kay@vrfy.org>
+ * Copyright (C) 2006 Hannes Reinecke <hare@suse.de>
+ *
+ * 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 version 2 of the License.
+ *
+ * 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; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include <stdlib.h>
+#include <stddef.h>
+#include <stdarg.h>
+#include <string.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <getopt.h>
+#include <errno.h>
+#include <dirent.h>
+#include <fcntl.h>
+#include <syslog.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+
+#define PATH_SIZE 512
+
+static int verbose;
+static int dry_run;
+
+void log_message(int priority, const char *format, ...)
+{
+ va_list args;
+
+ va_start(args, format);
+ vsyslog(priority, format, args);
+ va_end(args);
+}
+
+#undef err
+#define err(format, arg...) \
+ do { \
+ log_message(LOG_ERR ,"%s: " format ,__FUNCTION__ ,## arg); \
+ } while (0)
+
+#undef info
+#define info(format, arg...) \
+ do { \
+ log_message(LOG_INFO ,"%s: " format ,__FUNCTION__ ,## arg); \
+ } while (0)
+
+#ifdef DEBUG
+#undef dbg
+#define dbg(format, arg...) \
+ do { \
+ log_message(LOG_DEBUG ,"%s: " format ,__FUNCTION__ ,## arg); \
+ } while (0)
+#else
+#define dbg(...) do {} while(0)
+#endif
+
+
+static void trigger_uevent(const char *devpath)
+{
+ char filename[PATH_SIZE];
+ int fd;
+
+ strlcpy(filename, "/sys", sizeof(filename));
+ strlcat(filename, devpath, sizeof(filename));
+ strlcat(filename, "/uevent", sizeof(filename));
+
+ if (verbose)
+ printf("%s\n", devpath);
+
+ if (dry_run)
+ return;
+
+ fd = open(filename, O_WRONLY);
+ if (fd < 0) {
+ dbg("error on opening %s: %s\n", filename, strerror(errno));
+ return;
+ }
+
+ if (write(fd, "add", 3) < 0)
+ info("error on triggering %s: %s\n", filename, strerror(errno));
+
+ close(fd);
+}
+
+static int sysfs_resolve_link(char *devpath, size_t size)
+{
+ char link_path[PATH_SIZE];
+ char link_target[PATH_SIZE];
+ int len;
+ int i;
+ int back;
+
+ strlcpy(link_path, "/sys", sizeof(link_path));
+ strlcat(link_path, devpath, sizeof(link_path));
+ len = readlink(link_path, link_target, sizeof(link_target));
+ if (len <= 0)
+ return -1;
+ link_target[len] = '\0';
+ dbg("path link '%s' points to '%s'", devpath, link_target);
+
+ for (back = 0; strncmp(&link_target[back * 3], "../", 3) == 0; back++)
+ ;
+ dbg("base '%s', tail '%s', back %i", devpath, &link_target[back * 3], back);
+ for (i = 0; i <= back; i++) {
+ char *pos = strrchr(devpath, '/');
+
+ if (pos == NULL)
+ return -1;
+ pos[0] = '\0';
+ }
+ dbg("after moving back '%s'", devpath);
+ strlcat(devpath, "/", size);
+ strlcat(devpath, &link_target[back * 3], size);
+ return 0;
+}
+
+
+static int device_list_insert(const char *path)
+{
+ char filename[PATH_SIZE];
+ char devpath[PATH_SIZE];
+ struct stat statbuf;
+
+ dbg("add '%s'" , path);
+
+ /* we only have a device, if we have an uevent file */
+ strlcpy(filename, path, sizeof(filename));
+ strlcat(filename, "/uevent", sizeof(filename));
+ if (stat(filename, &statbuf) < 0)
+ return -1;
+ if (!(statbuf.st_mode & S_IWUSR))
+ return -1;
+
+ strlcpy(devpath, &path[4], sizeof(devpath));
+
+ /* resolve possible link to real target */
+ if (lstat(path, &statbuf) < 0)
+ return -1;
+ if (S_ISLNK(statbuf.st_mode))
+ if (sysfs_resolve_link(devpath, sizeof(devpath)) != 0)
+ return -1;
+
+ trigger_uevent(devpath);
+ return 0;
+}
+
+
+static void scan_subsystem(const char *subsys)
+{
+ char base[PATH_SIZE];
+ DIR *dir;
+ struct dirent *dent;
+
+ strlcpy(base, "/sys/", sizeof(base));
+ strlcat(base, subsys, sizeof(base));
+
+ dir = opendir(base);
+ if (dir != NULL) {
+ for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) {
+ char dirname[PATH_SIZE];
+ DIR *dir2;
+ struct dirent *dent2;
+
+ if (dent->d_name[0] == '.')
+ continue;
+
+ strlcpy(dirname, base, sizeof(dirname));
+ strlcat(dirname, "/", sizeof(dirname));
+ strlcat(dirname, dent->d_name, sizeof(dirname));
+ strlcat(dirname, "/devices", sizeof(dirname));
+
+ /* look for devices */
+ dir2 = opendir(dirname);
+ if (dir2 != NULL) {
+ for (dent2 = readdir(dir2); dent2 != NULL; dent2 = readdir(dir2)) {
+ char dirname2[PATH_SIZE];
+
+ if (dent2->d_name[0] == '.')
+ continue;
+
+ strlcpy(dirname2, dirname, sizeof(dirname2));
+ strlcat(dirname2, "/", sizeof(dirname2));
+ strlcat(dirname2, dent2->d_name, sizeof(dirname2));
+ device_list_insert(dirname2);
+ }
+ closedir(dir2);
+ }
+ }
+ closedir(dir);
+ }
+}
+
+static void scan_block(void)
+{
+ char base[PATH_SIZE];
+ DIR *dir;
+ struct dirent *dent;
+
+ strlcpy(base, "/sys/block", sizeof(base));
+
+ dir = opendir(base);
+ if (dir != NULL) {
+ for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) {
+ char dirname[PATH_SIZE];
+ DIR *dir2;
+ struct dirent *dent2;
+
+ if (dent->d_name[0] == '.')
+ continue;
+
+ strlcpy(dirname, base, sizeof(dirname));
+ strlcat(dirname, "/", sizeof(dirname));
+ strlcat(dirname, dent->d_name, sizeof(dirname));
+ if (device_list_insert(dirname) != 0)
+ continue;
+
+ /* look for partitions */
+ dir2 = opendir(dirname);
+ if (dir2 != NULL) {
+ for (dent2 = readdir(dir2); dent2 != NULL; dent2 = readdir(dir2)) {
+ char dirname2[PATH_SIZE];
+
+ if (dent2->d_name[0] == '.')
+ continue;
+
+ if (!strcmp(dent2->d_name,"device"))
+ continue;
+
+ strlcpy(dirname2, dirname, sizeof(dirname2));
+ strlcat(dirname2, "/", sizeof(dirname2));
+ strlcat(dirname2, dent2->d_name, sizeof(dirname2));
+ device_list_insert(dirname2);
+ }
+ closedir(dir2);
+ }
+ }
+ closedir(dir);
+ }
+}
+
+static void scan_class(void)
+{
+ char base[PATH_SIZE];
+ DIR *dir;
+ struct dirent *dent;
+
+ strlcpy(base, "/sys/class", sizeof(base));
+
+ dir = opendir(base);
+ if (dir != NULL) {
+ for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) {
+ char dirname[PATH_SIZE];
+ DIR *dir2;
+ struct dirent *dent2;
+
+ if (dent->d_name[0] == '.')
+ continue;
+
+ strlcpy(dirname, base, sizeof(dirname));
+ strlcat(dirname, "/", sizeof(dirname));
+ strlcat(dirname, dent->d_name, sizeof(dirname));
+ dir2 = opendir(dirname);
+ if (dir2 != NULL) {
+ for (dent2 = readdir(dir2); dent2 != NULL; dent2 = readdir(dir2)) {
+ char dirname2[PATH_SIZE];
+
+ if (dent2->d_name[0] == '.')
+ continue;
+
+ if (!strcmp(dent2->d_name, "device"))
+ continue;
+
+ strlcpy(dirname2, dirname, sizeof(dirname2));
+ strlcat(dirname2, "/", sizeof(dirname2));
+ strlcat(dirname2, dent2->d_name, sizeof(dirname2));
+ device_list_insert(dirname2);
+ }
+ closedir(dir2);
+ }
+ }
+ closedir(dir);
+ }
+}
+
+int main(int argc, char *argv[], char *envp[])
+{
+ char base[PATH_SIZE];
+ struct stat statbuf;
+ int failed = 0;
+ int option;
+
+ openlog("udevtrigger", LOG_PID | LOG_CONS, LOG_DAEMON);
+
+ while (1) {
+ option = getopt(argc, argv, "vnh");
+ if (option == -1)
+ break;
+
+ switch (option) {
+ case 'v':
+ verbose = 1;
+ break;
+ case 'n':
+ dry_run = 1;
+ break;
+ case 'h':
+ printf("Usage: udevtrigger OPTIONS\n"
+ " -v print the list of devices while running\n"
+ " -n do not actually trigger the events\n"
+ " -h print this text\n"
+ "\n");
+ goto exit;
+ default:
+ goto exit;
+ }
+ }
+
+
+ /* if we have /sys/subsystem, forget all the old stuff */
+ scan_subsystem("bus");
+ scan_class();
+
+ /* scan "block" if it isn't a "class" */
+ strlcpy(base, "/sys/class/block", sizeof(base));
+ if (stat(base, &statbuf) != 0)
+ scan_block();
+
+exit:
+
+ closelog();
+ return 0;
+}
diff --git a/package/kernel/.svn/entries b/package/kernel/.svn/entries
new file mode 100644
index 0000000..6152d53
--- /dev/null
+++ b/package/kernel/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/kernel
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-02-23T11:30:30.640791Z
+35755
+jogo
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+modules
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+621997f6ea9391b8648fe44d8672447f
+2012-10-19T15:34:28.915431Z
+33861
+hcg
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1019
+
diff --git a/package/kernel/.svn/prop-base/Makefile.svn-base b/package/kernel/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..8e522ae
--- /dev/null
+++ b/package/kernel/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:copyright
+V 30
+Copyright (C) 2006 OpenWrt.org
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/kernel/.svn/text-base/Makefile.svn-base b/package/kernel/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..d44b5a7
--- /dev/null
+++ b/package/kernel/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,52 @@
+#
+# Copyright (C) 2006-2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=kernel
+PKG_FLAGS:=hold
+
+PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/packages
+SCAN_DEPS=modules/*.mk $(TOPDIR)/target/linux/*/modules.mk
+
+PKG_LICENSE:=GPLv2
+PKG_LICENSE_FILES:=
+
+include $(INCLUDE_DIR)/package.mk
+ifeq ($(DUMP),)
+ -include $(LINUX_DIR)/.config
+endif
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+endef
+
+CONFIG_PACKAGE_kernel=y
+define Package/kernel
+ SECTION:=sys
+ CATEGORY:=Kernel
+ DEFAULT:=y
+ TITLE:=Virtual kernel package
+ VERSION:=$(LINUX_VERSION)-$(LINUX_RELEASE)-$(LINUX_VERMAGIC)
+ URL:=http://www.kernel.org/
+endef
+
+define Package/kernel/install
+ # nothing to do
+endef
+
+$(eval $(if $(DUMP),,$(call BuildPackage,kernel)))
+
+include $(sort $(wildcard ./modules/*.mk))
+-include $(TOPDIR)/target/linux/*/modules.mk
diff --git a/package/kernel/Makefile b/package/kernel/Makefile
new file mode 100644
index 0000000..d44b5a7
--- /dev/null
+++ b/package/kernel/Makefile
@@ -0,0 +1,52 @@
+#
+# Copyright (C) 2006-2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=kernel
+PKG_FLAGS:=hold
+
+PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/packages
+SCAN_DEPS=modules/*.mk $(TOPDIR)/target/linux/*/modules.mk
+
+PKG_LICENSE:=GPLv2
+PKG_LICENSE_FILES:=
+
+include $(INCLUDE_DIR)/package.mk
+ifeq ($(DUMP),)
+ -include $(LINUX_DIR)/.config
+endif
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+endef
+
+CONFIG_PACKAGE_kernel=y
+define Package/kernel
+ SECTION:=sys
+ CATEGORY:=Kernel
+ DEFAULT:=y
+ TITLE:=Virtual kernel package
+ VERSION:=$(LINUX_VERSION)-$(LINUX_RELEASE)-$(LINUX_VERMAGIC)
+ URL:=http://www.kernel.org/
+endef
+
+define Package/kernel/install
+ # nothing to do
+endef
+
+$(eval $(if $(DUMP),,$(call BuildPackage,kernel)))
+
+include $(sort $(wildcard ./modules/*.mk))
+-include $(TOPDIR)/target/linux/*/modules.mk
diff --git a/package/kernel/modules/.svn/entries b/package/kernel/modules/.svn/entries
new file mode 100644
index 0000000..3bf4cb0
--- /dev/null
+++ b/package/kernel/modules/.svn/entries
@@ -0,0 +1,810 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/kernel/modules
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-02-23T11:30:30.640791Z
+35755
+jogo
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+firewire.mk
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+db11e55ca920746799ad21ea8e96371e
+2012-05-06T20:43:17.377831Z
+31634
+hauke
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1952
+
+i2c.mk
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+6307627c292b6bc204330e2a1de7c83c
+2013-02-23T11:30:30.640791Z
+35755
+jogo
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+7504
+
+crypto.mk
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+3337465cb888b0c817561bad1d2eedf9
+2013-01-14T17:09:16.184768Z
+35158
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+13516
+
+001-depends.mk
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+5ff6e3b6ea28676d34f4ac3e2538241b
+2012-10-17T22:46:16.612413Z
+33831
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+795
+
+other.mk
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+c677cd9aa78de52684a2cd21ce6af08b
+2013-02-20T19:14:20.463046Z
+35706
+juhosg
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+16364
+
+netsupport.mk
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+fd2556ecda87933be9fc714451bc8837
+2013-01-08T22:18:23.302624Z
+35054
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+21856
+
+virtual.mk
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+53bf80d18aae4f4b616de904003364d7
+2013-02-20T09:41:48.768946Z
+35691
+juhosg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4348
+
+leds.mk
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+d1691d151d9f7b337029768810a707cd
+2013-01-12T13:21:08.822540Z
+35120
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4559
+
+w1.mk
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+0817d575ba97b88b1d579cfe6ee7af94
+2013-02-20T09:41:48.768946Z
+35691
+juhosg
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3996
+
+hwmon.mk
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+aca0f7adf892dc54b063146a76bfa1b3
+2012-05-09T10:48:36.178287Z
+31657
+juhosg
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4975
+
+sound.mk
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+540e4dc7399a42c9fec1ee7a6197e3c3
+2013-02-20T09:41:48.768946Z
+35691
+juhosg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5369
+
+netdevices.mk
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+7c4951ff66994e52279c5f8fa3709d4b
+2013-02-20T19:14:15.938813Z
+35705
+juhosg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+19955
+
+usb.mk
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+8c35ff4c17c8574b563e04f07d19aca7
+2013-02-16T17:13:40.917053Z
+35627
+juhosg
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+26193
+
+block.mk
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+20ea29da9630d45702f13f78db326a65
+2013-02-20T09:41:48.768946Z
+35691
+juhosg
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+14587
+
+spi.mk
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+01554fc720926ccc2ee31088ecf40abb
+2012-07-25T15:50:04.902570Z
+32853
+florian
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2349
+
+nls.mk
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+4ce9fd7d0044eae948023ae84ad4907e
+2011-10-29T15:03:56.306902Z
+28668
+nico
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5703
+
+pcmcia.mk
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+6ec6b9af8789e5651d17ab17e3664f53
+2012-05-27T15:22:13.218690Z
+31907
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2030
+
+netfilter.mk
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+01d4f728dcab02e26b6a750b24d1cae7
+2013-02-20T09:41:48.768946Z
+35691
+juhosg
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+14604
+
+wireless.mk
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+18aaceaf83427cbea3b67d16769f078a
+2011-07-04T03:16:53.974639Z
+27436
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3119
+
+input.mk
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+d1b6b0178800cdb4ca6ba19ec257c39b
+2013-01-27T21:23:33.921493Z
+35338
+hauke
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5029
+
+lib.mk
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+469f5ad16b0d3d394c16915cbf277ec8
+2012-10-27T13:47:23.606015Z
+33967
+kaloz
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3668
+
+video.mk
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+47800d30a1d3f84bb93ecac29969cb91
+2013-01-02T11:28:11.029037Z
+34968
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+20427
+
+fs.mk
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+d8608ee4c5ee4048aea8048ee5af1d6d
+2013-02-20T09:41:48.768946Z
+35691
+juhosg
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+8299
+
diff --git a/package/kernel/modules/.svn/prop-base/block.mk.svn-base b/package/kernel/modules/.svn/prop-base/block.mk.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/kernel/modules/.svn/prop-base/block.mk.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/kernel/modules/.svn/prop-base/crypto.mk.svn-base b/package/kernel/modules/.svn/prop-base/crypto.mk.svn-base
new file mode 100644
index 0000000..f07be99
--- /dev/null
+++ b/package/kernel/modules/.svn/prop-base/crypto.mk.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:copyright
+V 30
+Copyright (C) 2007 OpenWrt.org
+END
diff --git a/package/kernel/modules/.svn/prop-base/fs.mk.svn-base b/package/kernel/modules/.svn/prop-base/fs.mk.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/kernel/modules/.svn/prop-base/fs.mk.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/kernel/modules/.svn/prop-base/hwmon.mk.svn-base b/package/kernel/modules/.svn/prop-base/hwmon.mk.svn-base
new file mode 100644
index 0000000..f07be99
--- /dev/null
+++ b/package/kernel/modules/.svn/prop-base/hwmon.mk.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:copyright
+V 30
+Copyright (C) 2007 OpenWrt.org
+END
diff --git a/package/kernel/modules/.svn/prop-base/i2c.mk.svn-base b/package/kernel/modules/.svn/prop-base/i2c.mk.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/kernel/modules/.svn/prop-base/i2c.mk.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/kernel/modules/.svn/prop-base/netfilter.mk.svn-base b/package/kernel/modules/.svn/prop-base/netfilter.mk.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/kernel/modules/.svn/prop-base/netfilter.mk.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/kernel/modules/.svn/prop-base/nls.mk.svn-base b/package/kernel/modules/.svn/prop-base/nls.mk.svn-base
new file mode 100644
index 0000000..0bac43c
--- /dev/null
+++ b/package/kernel/modules/.svn/prop-base/nls.mk.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:eol-style
+V 6
+native
+K 13
+svn:mergeinfo
+V 0
+
+END
diff --git a/package/kernel/modules/.svn/prop-base/other.mk.svn-base b/package/kernel/modules/.svn/prop-base/other.mk.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/kernel/modules/.svn/prop-base/other.mk.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/kernel/modules/.svn/prop-base/pcmcia.mk.svn-base b/package/kernel/modules/.svn/prop-base/pcmcia.mk.svn-base
new file mode 100644
index 0000000..0bac43c
--- /dev/null
+++ b/package/kernel/modules/.svn/prop-base/pcmcia.mk.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:eol-style
+V 6
+native
+K 13
+svn:mergeinfo
+V 0
+
+END
diff --git a/package/kernel/modules/.svn/prop-base/spi.mk.svn-base b/package/kernel/modules/.svn/prop-base/spi.mk.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/kernel/modules/.svn/prop-base/spi.mk.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/kernel/modules/.svn/prop-base/usb.mk.svn-base b/package/kernel/modules/.svn/prop-base/usb.mk.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/kernel/modules/.svn/prop-base/usb.mk.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/kernel/modules/.svn/prop-base/w1.mk.svn-base b/package/kernel/modules/.svn/prop-base/w1.mk.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/kernel/modules/.svn/prop-base/w1.mk.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/kernel/modules/.svn/prop-base/wireless.mk.svn-base b/package/kernel/modules/.svn/prop-base/wireless.mk.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/kernel/modules/.svn/prop-base/wireless.mk.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/kernel/modules/.svn/text-base/001-depends.mk.svn-base b/package/kernel/modules/.svn/text-base/001-depends.mk.svn-base
new file mode 100644
index 0000000..e0af735
--- /dev/null
+++ b/package/kernel/modules/.svn/text-base/001-depends.mk.svn-base
@@ -0,0 +1,37 @@
+#
+# Copyright (C) 2010-2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+define AddDepends/crc16
+ DEPENDS+= +kmod-lib-crc16 $(1)
+endef
+
+define AddDepends/hid
+ DEPENDS+= +kmod-hid $(1)
+endef
+
+define AddDepends/input
+ DEPENDS+= +kmod-input-core $(1)
+endef
+
+
+define AddDepends/nls
+ DEPENDS+= +kmod-nls-base $(foreach cp,$(1),+kmod-nls-$(cp))
+endef
+
+
+define SetDepends/rfkill
+ DEPENDS:= @(TARGET_ar71xx||TARGET_brcm47xx||TARGET_s3c24xx||TARGET_x86||TARGET_gemini||TARGET_cns3xxx||TARGET_ixp4xx)
+endef
+
+define AddDepends/rfkill
+ DEPENDS+= +(TARGET_ar71xx||TARGET_brcm47xx||TARGET_s3c24xx||TARGET_x86||TARGET_cns3xxx||TARGET_ixp4xx):kmod-rfkill $(1)
+endef
+
+
+define AddDepends/rtc
+ DEPENDS+= @RTC_SUPPORT
+endef
diff --git a/package/kernel/modules/.svn/text-base/block.mk.svn-base b/package/kernel/modules/.svn/text-base/block.mk.svn-base
new file mode 100644
index 0000000..1aa47de
--- /dev/null
+++ b/package/kernel/modules/.svn/text-base/block.mk.svn-base
@@ -0,0 +1,606 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+BLOCK_MENU:=Block Devices
+
+define KernelPackage/aoe
+ SUBMENU:=$(BLOCK_MENU)
+ TITLE:=ATA over Ethernet support
+ KCONFIG:=CONFIG_ATA_OVER_ETH
+ FILES:=$(LINUX_DIR)/drivers/block/aoe/aoe.ko
+ AUTOLOAD:=$(call AutoLoad,30,aoe)
+endef
+
+define KernelPackage/aoe/description
+ Kernel support for ATA over Ethernet
+endef
+
+$(eval $(call KernelPackage,aoe))
+
+
+define KernelPackage/ata-core
+ SUBMENU:=$(BLOCK_MENU)
+ TITLE:=Serial and Parallel ATA support
+ DEPENDS:=@PCI_SUPPORT +kmod-scsi-core
+ KCONFIG:=CONFIG_ATA
+ FILES:=$(LINUX_DIR)/drivers/ata/libata.ko
+ AUTOLOAD:=$(call AutoLoad,21,libata,1)
+endef
+
+$(eval $(call KernelPackage,ata-core))
+
+
+define AddDepends/ata
+ SUBMENU:=$(BLOCK_MENU)
+ DEPENDS+=kmod-ata-core $(1)
+endef
+
+
+define KernelPackage/ata-ahci
+ TITLE:=AHCI Serial ATA support
+ KCONFIG:=CONFIG_SATA_AHCI
+ FILES:= \
+ $(LINUX_DIR)/drivers/ata/ahci.ko \
+ $(LINUX_DIR)/drivers/ata/libahci.ko
+ AUTOLOAD:=$(call AutoLoad,41,libahci ahci,1)
+ $(call AddDepends/ata)
+endef
+
+define KernelPackage/ata-ahci/description
+ Support for AHCI Serial ATA controllers.
+endef
+
+$(eval $(call KernelPackage,ata-ahci))
+
+
+define KernelPackage/ata-artop
+ TITLE:=ARTOP 6210/6260 PATA support
+ KCONFIG:=CONFIG_PATA_ARTOP
+ FILES:=$(LINUX_DIR)/drivers/ata/pata_artop.ko
+ AUTOLOAD:=$(call AutoLoad,41,pata_artop,1)
+ $(call AddDepends/ata)
+endef
+
+define KernelPackage/ata-artop/description
+ PATA support for ARTOP 6210/6260 host controllers.
+endef
+
+$(eval $(call KernelPackage,ata-artop))
+
+
+define KernelPackage/ata-marvell-sata
+ TITLE:=Marvell Serial ATA support
+ KCONFIG:=CONFIG_SATA_MV
+ FILES:=$(LINUX_DIR)/drivers/ata/sata_mv.ko
+ AUTOLOAD:=$(call AutoLoad,41,sata_mv,1)
+ $(call AddDepends/ata)
+endef
+
+define KernelPackage/ata-marvell-sata/description
+ SATA support for marvell chipsets
+endef
+
+$(eval $(call KernelPackage,ata-marvell-sata))
+
+
+define KernelPackage/ata-nvidia-sata
+ TITLE:=Nvidia Serial ATA support
+ KCONFIG:=CONFIG_SATA_NV
+ FILES:=$(LINUX_DIR)/drivers/ata/sata_nv.ko
+ AUTOLOAD:=$(call AutoLoad,41,sata_nv,1)
+ $(call AddDepends/ata)
+endef
+
+$(eval $(call KernelPackage,ata-nvidia-sata))
+
+
+define KernelPackage/ata-pdc202xx-old
+ SUBMENU:=$(BLOCK_MENU)
+ TITLE:=Older Promise PATA controller support
+ DEPENDS:=kmod-ata-core
+ KCONFIG:= \
+ CONFIG_ATA_SFF=y \
+ CONFIG_PATA_PDC_OLD
+ FILES:=$(LINUX_DIR)/drivers/ata/pata_pdc202xx_old.ko
+ AUTOLOAD:=$(call AutoLoad,41,pata_pdc202xx_old,1)
+endef
+
+define KernelPackage/ata-pdc202xx-old/description
+ This option enables support for the Promise 20246, 20262, 20263,
+ 20265 and 20267 adapters.
+endef
+
+$(eval $(call KernelPackage,ata-pdc202xx-old))
+
+
+define KernelPackage/ata-piix
+ TITLE:=Intel PIIX PATA/SATA support
+ KCONFIG:=CONFIG_ATA_PIIX
+ FILES:=$(LINUX_DIR)/drivers/ata/ata_piix.ko
+ AUTOLOAD:=$(call AutoLoad,41,ata_piix,1)
+ $(call AddDepends/ata)
+endef
+
+define KernelPackage/ata-piix/description
+ SATA support for Intel ICH5/6/7/8 series host controllers and
+ PATA support for Intel ESB/ICH/PIIX3/PIIX4 series host controllers.
+endef
+
+$(eval $(call KernelPackage,ata-piix))
+
+
+define KernelPackage/ata-sil
+ TITLE:=Silicon Image SATA support
+ KCONFIG:=CONFIG_SATA_SIL
+ FILES:=$(LINUX_DIR)/drivers/ata/sata_sil.ko
+ AUTOLOAD:=$(call AutoLoad,41,sata_sil,1)
+ $(call AddDepends/ata)
+endef
+
+define KernelPackage/ata-sil/description
+ Support for Silicon Image Serial ATA controllers.
+endef
+
+$(eval $(call KernelPackage,ata-sil))
+
+
+define KernelPackage/ata-sil24
+ TITLE:=Silicon Image 3124/3132 SATA support
+ KCONFIG:=CONFIG_SATA_SIL24
+ FILES:=$(LINUX_DIR)/drivers/ata/sata_sil24.ko
+ AUTOLOAD:=$(call AutoLoad,41,sata_sil24,1)
+ $(call AddDepends/ata)
+endef
+
+define KernelPackage/ata-sil24/description
+ Support for Silicon Image 3124/3132 Serial ATA controllers.
+endef
+
+$(eval $(call KernelPackage,ata-sil24))
+
+
+define KernelPackage/ata-sis
+ TITLE:=SIS SATA support
+ KCONFIG:=CONFIG_SATA_SIS
+ FILES:=$(LINUX_DIR)/drivers/ata/sata_sis.ko
+ AUTOLOAD:=$(call AutoLoad,41,sata_sis,1)
+ $(call AddDepends/ata)
+endef
+
+define KernelPackage/ata-sis/description
+ Support for SIS Serial ATA controllers.
+endef
+
+$(eval $(call KernelPackage,ata-sis))
+
+
+define KernelPackage/ata-via-sata
+ TITLE:=VIA SATA support
+ KCONFIG:=CONFIG_SATA_VIA
+ FILES:=$(LINUX_DIR)/drivers/ata/sata_via.ko
+ AUTOLOAD:=$(call AutoLoad,41,sata_via,1)
+ $(call AddDepends/ata)
+endef
+
+define KernelPackage/ata-via-sata/description
+ This option enables support for VIA Serial ATA.
+endef
+
+$(eval $(call KernelPackage,ata-via-sata))
+
+
+define KernelPackage/block2mtd
+ SUBMENU:=$(BLOCK_MENU)
+ TITLE:=Block device MTD emulation
+ KCONFIG:=CONFIG_MTD_BLOCK2MTD
+ FILES:=$(LINUX_DIR)/drivers/mtd/devices/block2mtd.ko
+endef
+
+$(eval $(call KernelPackage,block2mtd))
+
+
+define KernelPackage/dm
+ SUBMENU:=$(BLOCK_MENU)
+ TITLE:=Device Mapper
+ # All the "=n" are unnecessary, they're only there
+ # to stop the config from asking the question.
+ # MIRROR is M because I've needed it for pvmove.
+ KCONFIG:= \
+ CONFIG_BLK_DEV_MD=n \
+ CONFIG_DM_DEBUG=n \
+ CONFIG_DM_UEVENT=n \
+ CONFIG_DM_DELAY=n \
+ CONFIG_DM_MULTIPATH=n \
+ CONFIG_DM_ZERO=n \
+ CONFIG_DM_SNAPSHOT=n \
+ CONFIG_DM_LOG_USERSPACE=n \
+ CONFIG_MD=y \
+ CONFIG_BLK_DEV_DM \
+ CONFIG_DM_CRYPT \
+ CONFIG_DM_MIRROR
+ FILES:=$(LINUX_DIR)/drivers/md/dm-*.ko
+ AUTOLOAD:=$(call AutoLoad,30,dm-mod dm-log dm-region-hash dm-mirror dm-crypt)
+endef
+
+define KernelPackage/dm/description
+ Kernel module necessary for LVM2 support
+endef
+
+$(eval $(call KernelPackage,dm))
+
+
+define KernelPackage/md-mod
+ SUBMENU:=$(BLOCK_MENU)
+ TITLE:=MD RAID
+ KCONFIG:= \
+ CONFIG_MD=y \
+ CONFIG_BLK_DEV_MD=m \
+ CONFIG_MD_AUTODETECT=y \
+ CONFIG_MD_FAULTY=n
+ FILES:=$(LINUX_DIR)/drivers/md/md-mod.ko
+ AUTOLOAD:=$(call AutoLoad,27,md-mod)
+endef
+
+define KernelPackage/md-mod/description
+ Kernel RAID md module (md-mod.ko).
+ You will need to select at least one RAID level module below.
+endef
+
+$(eval $(call KernelPackage,md-mod))
+
+
+define KernelPackage/md/Depends
+ SUBMENU:=$(BLOCK_MENU)
+ DEPENDS:=kmod-md-mod $(1)
+endef
+
+
+define KernelPackage/md-linear
+$(call KernelPackage/md/Depends,)
+ TITLE:=RAID Linear Module
+ KCONFIG:=CONFIG_MD_LINEAR
+ FILES:=$(LINUX_DIR)/drivers/md/linear.ko
+ AUTOLOAD:=$(call AutoLoad,28,linear)
+endef
+
+define KernelPackage/md-linear/description
+ RAID "Linear" or "Append" driver module (linear.ko)
+endef
+
+$(eval $(call KernelPackage,md-linear))
+
+
+define KernelPackage/md-raid0
+$(call KernelPackage/md/Depends,)
+ TITLE:=RAID0 Module
+ KCONFIG:=CONFIG_MD_RAID0
+ FILES:=$(LINUX_DIR)/drivers/md/raid0.ko
+ AUTOLOAD:=$(call AutoLoad,28,raid0)
+endef
+
+define KernelPackage/md-raid0/description
+ RAID Level 0 (Striping) driver module (raid0.ko)
+endef
+
+$(eval $(call KernelPackage,md-raid0))
+
+
+define KernelPackage/md-raid1
+$(call KernelPackage/md/Depends,)
+ TITLE:=RAID1 Module
+ KCONFIG:=CONFIG_MD_RAID1
+ FILES:=$(LINUX_DIR)/drivers/md/raid1.ko
+ AUTOLOAD:=$(call AutoLoad,28,raid1)
+endef
+
+define KernelPackage/md-raid1/description
+ RAID Level 1 (Mirroring) driver (raid1.ko)
+endef
+
+$(eval $(call KernelPackage,md-raid1))
+
+
+define KernelPackage/md-raid10
+$(call KernelPackage/md/Depends,)
+ TITLE:=RAID10 Module
+ KCONFIG:=CONFIG_MD_RAID10
+ FILES:=$(LINUX_DIR)/drivers/md/raid10.ko
+ AUTOLOAD:=$(call AutoLoad,28,raid10)
+endef
+
+define KernelPackage/md-raid10/description
+ RAID Level 10 (Mirroring+Striping) driver module (raid10.ko)
+endef
+
+$(eval $(call KernelPackage,md-raid10))
+
+
+define KernelPackage/md-raid456
+$(call KernelPackage/md/Depends,)
+ TITLE:=RAID Level 456 Driver
+ KCONFIG:= \
+ CONFIG_XOR_BLOCKS \
+ CONFIG_ASYNC_CORE \
+ CONFIG_ASYNC_MEMCPY \
+ CONFIG_ASYNC_XOR \
+ CONFIG_ASYNC_PQ \
+ CONFIG_ASYNC_RAID6_RECOV \
+ CONFIG_ASYNC_RAID6_TEST=n \
+ CONFIG_MD_RAID6_PQ \
+ CONFIG_MD_RAID456 \
+ CONFIG_MULTICORE_RAID456=n
+ FILES:= \
+ $(LINUX_DIR)/crypto/xor.ko \
+ $(LINUX_DIR)/crypto/async_tx/async_tx.ko \
+ $(LINUX_DIR)/crypto/async_tx/async_memcpy.ko \
+ $(LINUX_DIR)/crypto/async_tx/async_xor.ko \
+ $(LINUX_DIR)/crypto/async_tx/async_pq.ko \
+ $(LINUX_DIR)/crypto/async_tx/async_raid6_recov.ko \
+ $(LINUX_DIR)/drivers/md/raid456.ko \
+ $(LINUX_DIR)/lib/raid6/raid6_pq.ko
+ AUTOLOAD:=$(call AutoLoad,28, xor async_tx async_memcpy async_xor raid6_pq async_pq async_raid6_recov raid456)
+endef
+
+define KernelPackage/md-raid456/description
+ RAID Level 4,5,6 kernel module (raid456.ko)
+
+ Includes the following modules required by
+ raid456.ko:
+ xor.ko
+ async_tx.ko
+ async_xor.ko
+ async_memcpy.ko
+ async_pq.ko
+ async_raid5_recov.ko
+ raid6_pq.ko
+endef
+
+$(eval $(call KernelPackage,md-raid456))
+
+
+define KernelPackage/md-multipath
+$(call KernelPackage/md/Depends,)
+ TITLE:=MD Multipath Module
+ KCONFIG:=CONFIG_MD_MULTIPATH
+ FILES:=$(LINUX_DIR)/drivers/md/multipath.ko
+ AUTOLOAD:=$(call AutoLoad,29,multipath)
+endef
+
+define KernelPackage/md-multipath/description
+ Multipath driver module (multipath.ko)
+endef
+
+$(eval $(call KernelPackage,md-multipath))
+
+
+define KernelPackage/ide-core
+ SUBMENU:=$(BLOCK_MENU)
+ TITLE:=IDE (ATA/ATAPI) device support
+ DEPENDS:=@PCI_SUPPORT
+ KCONFIG:= \
+ CONFIG_IDE \
+ CONFIG_BLK_DEV_IDE \
+ CONFIG_BLK_DEV_IDEDISK \
+ CONFIG_IDE_GD \
+ CONFIG_IDE_GD_ATA=y \
+ CONFIG_IDE_GD_ATAPI=n \
+ CONFIG_IDEPCI_PCIBUS_ORDER=y \
+ CONFIG_BLK_DEV_IDEDMA_PCI=y \
+ CONFIG_BLK_DEV_IDEPCI=y
+ FILES:= \
+ $(LINUX_DIR)/drivers/ide/ide-core.ko \
+ $(LINUX_DIR)/drivers/ide/ide-gd_mod.ko
+ AUTOLOAD:= \
+ $(call AutoLoad,20,ide-core,1) \
+ $(call AutoLoad,40,ide-gd_mod,1)
+endef
+
+define KernelPackage/ide-core/description
+ Kernel support for IDE, useful for usb mass storage devices (e.g. on WL-HDD)
+ Includes:
+ - ide-core
+ - ide-gd_mod
+endef
+
+$(eval $(call KernelPackage,ide-core))
+
+
+define AddDepends/ide
+ SUBMENU:=$(BLOCK_MENU)
+ DEPENDS+=kmod-ide-core $(1)
+endef
+
+
+define KernelPackage/ide-generic
+ SUBMENU:=$(BLOCK_MENU)
+ DEPENDS:=@PCI_SUPPORT
+ TITLE:=Kernel support for generic PCI IDE chipsets
+ KCONFIG:=CONFIG_BLK_DEV_GENERIC
+ FILES:=$(LINUX_DIR)/drivers/ide/ide-pci-generic.ko
+ AUTOLOAD:=$(call AutoLoad,30,ide-pci-generic,1)
+ $(call AddDepends/ide)
+endef
+
+$(eval $(call KernelPackage,ide-generic))
+
+
+define KernelPackage/ide-generic-old
+ SUBMENU:=$(BLOCK_MENU)
+ TITLE:=Kernel support for generic (legacy) IDE chipsets
+ KCONFIG:=CONFIG_IDE_GENERIC
+ FILES:=$(LINUX_DIR)/drivers/ide/ide-generic.ko
+ AUTOLOAD:=$(call AutoLoad,30,ide-generic,1)
+ $(call AddDepends/ide)
+endef
+
+$(eval $(call KernelPackage,ide-generic-old))
+
+
+define KernelPackage/ide-aec62xx
+ TITLE:=Acard AEC62xx IDE driver
+ DEPENDS:=@PCI_SUPPORT
+ KCONFIG:=CONFIG_BLK_DEV_AEC62XX
+ FILES:=$(LINUX_DIR)/drivers/ide/aec62xx.ko
+ AUTOLOAD:=$(call AutoLoad,30,aec62xx,1)
+ $(call AddDepends/ide)
+endef
+
+define KernelPackage/ide-aec62xx/description
+ Support for Acard AEC62xx (Artop ATP8xx) IDE controllers.
+endef
+
+$(eval $(call KernelPackage,ide-aec62xx,1))
+
+
+define KernelPackage/ide-pdc202xx
+ TITLE:=Promise PDC202xx IDE driver
+ DEPENDS:=@PCI_SUPPORT
+ KCONFIG:=CONFIG_BLK_DEV_PDC202XX_OLD
+ FILES:=$(LINUX_DIR)/drivers/ide/pdc202xx_old.ko
+ AUTOLOAD:=$(call AutoLoad,30,pdc202xx_old,1)
+ $(call AddDepends/ide)
+endef
+
+define KernelPackage/ide-pdc202xx/description
+ Support for the Promise Ultra 33/66/100 (PDC202{46|62|65|67|68}) IDE
+ controllers.
+endef
+
+$(eval $(call KernelPackage,ide-pdc202xx))
+
+
+define KernelPackage/ide-it821x
+ TITLE:=ITE IT821x IDE driver
+ DEPENDS:=@PCI_SUPPORT
+ KCONFIG:=CONFIG_BLK_DEV_IT821X
+ FILES=$(LINUX_DIR)/drivers/ide/it821x.ko
+ AUTOLOAD:=$(call AutoLoad,30,it821x,1)
+ $(call AddDepends/ide)
+endef
+
+define KernelPackage/ide-it821x/description
+ Kernel module for the ITE IDE821x IDE controllers.
+endef
+
+$(eval $(call KernelPackage,ide-it821x))
+
+
+define KernelPackage/libsas
+ SUBMENU:=$(BLOCK_MENU)
+ TITLE:=SAS Domain Transport Attributes
+ KCONFIG:=CONFIG_SCSI_SAS_LIBSAS \
+ CONFIG_SCSI_SAS_ATTRS \
+ CONFIG_SCSI_SAS_ATA=y \
+ CONFIG_SCSI_SAS_HOST_SMP=y \
+ CONFIG_SCSI_SAS_LIBSAS_DEBUG=y
+ FILES:= \
+ $(LINUX_DIR)/drivers/scsi/scsi_transport_sas.ko \
+ $(LINUX_DIR)/drivers/scsi/libsas/libsas.ko
+ AUTOLOAD:=$(call AutoLoad,29,scsi_transport_sas libsas,1)
+endef
+
+define KernelPackage/libsas/description
+ SAS Domain Transport Attributes support.
+endef
+
+$(eval $(call KernelPackage,libsas,1))
+
+
+define KernelPackage/loop
+ SUBMENU:=$(BLOCK_MENU)
+ TITLE:=Loopback device support
+ KCONFIG:= \
+ CONFIG_BLK_DEV_LOOP \
+ CONFIG_BLK_DEV_CRYPTOLOOP=n
+ FILES:=$(LINUX_DIR)/drivers/block/loop.ko
+ AUTOLOAD:=$(call AutoLoad,30,loop)
+endef
+
+define KernelPackage/loop/description
+ Kernel module for loopback device support
+endef
+
+$(eval $(call KernelPackage,loop))
+
+
+define KernelPackage/mvsas
+ SUBMENU:=$(BLOCK_MENU)
+ TITLE:=Marvell 88SE6440 SAS/SATA driver
+ DEPENDS:=@TARGET_x86 +kmod-libsas
+ KCONFIG:= \
+ CONFIG_SCSI_MVSAS \
+ CONFIG_SCSI_MVSAS_TASKLET=n
+ FILES:=$(LINUX_DIR)/drivers/scsi/mvsas/mvsas.ko
+ AUTOLOAD:=$(call AutoLoad,40,mvsas,1)
+endef
+
+define KernelPackage/mvsas/description
+ Kernel support for the Marvell SAS SCSI adapters
+endef
+
+$(eval $(call KernelPackage,mvsas))
+
+
+define KernelPackage/nbd
+ SUBMENU:=$(BLOCK_MENU)
+ TITLE:=Network block device support
+ KCONFIG:=CONFIG_BLK_DEV_NBD
+ FILES:=$(LINUX_DIR)/drivers/block/nbd.ko
+ AUTOLOAD:=$(call AutoLoad,30,nbd)
+endef
+
+define KernelPackage/nbd/description
+ Kernel module for network block device support
+endef
+
+$(eval $(call KernelPackage,nbd))
+
+
+define KernelPackage/scsi-core
+ SUBMENU:=$(BLOCK_MENU)
+ TITLE:=SCSI device support
+ KCONFIG:= \
+ CONFIG_SCSI \
+ CONFIG_BLK_DEV_SD
+ FILES:= \
+ $(if $(findstring y,$(CONFIG_SCSI)),,$(LINUX_DIR)/drivers/scsi/scsi_mod.ko) \
+ $(LINUX_DIR)/drivers/scsi/sd_mod.ko
+ AUTOLOAD:=$(call AutoLoad,20,scsi_mod,1) $(call AutoLoad,40,sd_mod,1)
+endef
+
+$(eval $(call KernelPackage,scsi-core))
+
+
+define KernelPackage/scsi-generic
+ SUBMENU:=$(BLOCK_MENU)
+ TITLE:=Kernel support for SCSI generic
+ DEPENDS:=+kmod-scsi-core
+ KCONFIG:= \
+ CONFIG_CHR_DEV_SG
+ FILES:= \
+ $(LINUX_DIR)/drivers/scsi/sg.ko
+ AUTOLOAD:=$(call AutoLoad,65,sg)
+endef
+
+$(eval $(call KernelPackage,scsi-generic))
+
+
+define KernelPackage/scsi-cdrom
+ SUBMENU:=$(BLOCK_MENU)
+ TITLE:=Kernel support for CD / DVD drives
+ DEPENDS:=+kmod-scsi-core
+ KCONFIG:= \
+ CONFIG_BLK_DEV_SR \
+ CONFIG_BLK_DEV_SR_VENDOR=n
+ FILES:= \
+ $(LINUX_DIR)/drivers/cdrom/cdrom.ko \
+ $(LINUX_DIR)/drivers/scsi/sr_mod.ko
+ AUTOLOAD:=$(call AutoLoad,30,cdrom) $(call AutoLoad,45,sr_mod)
+endef
+
+$(eval $(call KernelPackage,scsi-cdrom))
+
diff --git a/package/kernel/modules/.svn/text-base/crypto.mk.svn-base b/package/kernel/modules/.svn/text-base/crypto.mk.svn-base
new file mode 100644
index 0000000..6a3b5a6
--- /dev/null
+++ b/package/kernel/modules/.svn/text-base/crypto.mk.svn-base
@@ -0,0 +1,496 @@
+#
+# Copyright (C) 2006-2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+CRYPTO_MENU:=Cryptographic API modules
+
+CRYPTO_MODULES = ALGAPI2=crypto_algapi
+
+CRYPTOMGR_MODULES = \
+ AEAD2=aead \
+ MANAGER2=cryptomgr \
+ BLKCIPHER2=crypto_blkcipher
+
+crypto_confvar=CONFIG_CRYPTO_$(word 1,$(subst =,$(space),$(1)))
+crypto_file=$(LINUX_DIR)/crypto/$(word 2,$(subst =,$(space),$(1))).ko
+crypto_name=$(if $(findstring y,$($(call crypto_confvar,$(1)))),,$(word 2,$(subst =,$(space),$(1))))
+
+define KernelPackage/crypto-core
+ SUBMENU:=$(CRYPTO_MENU)
+ TITLE:=Core CryptoAPI modules
+ KCONFIG:= \
+ CONFIG_CRYPTO=y \
+ CONFIG_CRYPTO_HW=y \
+ CONFIG_CRYPTO_ALGAPI \
+ $(foreach mod,$(CRYPTO_MODULES),$(call crypto_confvar,$(mod)))
+ FILES:=$(foreach mod,$(CRYPTO_MODULES),$(call crypto_file,$(mod)))
+ AUTOLOAD:=$(call AutoLoad,01,$(foreach mod,$(CRYPTO_MODULES),$(call crypto_name,$(mod))),1)
+endef
+$(eval $(call KernelPackage,crypto-core))
+
+
+define AddDepends/crypto
+ SUBMENU:=$(CRYPTO_MENU)
+ DEPENDS+=+kmod-crypto-core $(1)
+endef
+
+define KernelPackage/crypto-hash
+ TITLE:=CryptoAPI hash support
+ KCONFIG:=CONFIG_CRYPTO_HASH2
+ FILES:=$(LINUX_DIR)/crypto/crypto_hash.ko
+ AUTOLOAD:=$(call AutoLoad,02,crypto_hash,1)
+ $(call AddDepends/crypto)
+endef
+$(eval $(call KernelPackage,crypto-hash))
+
+define KernelPackage/crypto-manager
+ TITLE:=CryptoAPI algorithm manager
+ DEPENDS:=+kmod-crypto-hash
+ KCONFIG:= \
+ CONFIG_CRYPTO_AEAD \
+ CONFIG_CRYPTO_BLKCIPHER \
+ CONFIG_CRYPTO_MANAGER \
+ $(foreach mod,$(CRYPTOMGR_MODULES),$(call crypto_confvar,$(mod)))
+ FILES:=$(foreach mod,$(CRYPTOMGR_MODULES),$(call crypto_file,$(mod)))
+ AUTOLOAD:=$(call AutoLoad,03,$(foreach mod,$(CRYPTOMGR_MODULES),$(call crypto_name,$(mod))))
+ $(call AddDepends/crypto)
+endef
+$(eval $(call KernelPackage,crypto-manager))
+
+define KernelPackage/crypto-pcompress
+ TITLE:=CryptoAPI Partial (de)compression operations
+ KCONFIG:= \
+ CONFIG_CRYPTO_PCOMP=y \
+ CONFIG_CRYPTO_PCOMP2
+ FILES:=$(LINUX_DIR)/crypto/pcompress.ko
+ AUTOLOAD:=$(call AutoLoad,09,pcompress)
+ $(call AddDepends/crypto)
+endef
+$(eval $(call KernelPackage,crypto-pcompress))
+
+define KernelPackage/crypto-user
+ TITLE:=CryptoAPI userspace interface
+ DEPENDS:=+kmod-crypto-hash +kmod-crypto-manager
+ KCONFIG:= \
+ CONFIG_CRYPTO_USER_API \
+ CONFIG_CRYPTO_USER_API_HASH \
+ CONFIG_CRYPTO_USER_API_SKCIPHER
+ FILES:= \
+ $(LINUX_DIR)/crypto/af_alg.ko \
+ $(LINUX_DIR)/crypto/algif_hash.ko \
+ $(LINUX_DIR)/crypto/algif_skcipher.ko
+ AUTOLOAD:=$(call AutoLoad,09,af_alg algif_hash algif_skcipher)
+ $(call AddDepends/crypto)
+endef
+$(eval $(call KernelPackage,crypto-user))
+
+define KernelPackage/crypto-wq
+ TITLE:=CryptoAPI work queue handling
+ KCONFIG:=CONFIG_CRYPTO_WORKQUEUE
+ FILES:=$(LINUX_DIR)/crypto/crypto_wq.ko
+ AUTOLOAD:=$(call AutoLoad,09,crypto_wq)
+ $(call AddDepends/crypto)
+endef
+$(eval $(call KernelPackage,crypto-wq))
+
+define KernelPackage/crypto-rng
+ TITLE:=CryptoAPI random number generation
+ KCONFIG:=CONFIG_CRYPTO_RNG2
+ FILES:= \
+ $(LINUX_DIR)/crypto/rng.ko \
+ $(LINUX_DIR)/crypto/krng.ko
+ AUTOLOAD:=$(call AutoLoad,09,rng krng)
+ $(call AddDepends/crypto)
+endef
+$(eval $(call KernelPackage,crypto-rng))
+
+define KernelPackage/crypto-iv
+ TITLE:=CryptoAPI initialization vectors
+ DEPENDS:=+kmod-crypto-manager +kmod-crypto-rng +kmod-crypto-wq
+ KCONFIG:= CONFIG_CRYPTO_BLKCIPHER2
+ FILES:= \
+ $(LINUX_DIR)/crypto/eseqiv.ko \
+ $(LINUX_DIR)/crypto/chainiv.ko
+ AUTOLOAD:=$(call AutoLoad,10,eseqiv chainiv)
+ $(call AddDepends/crypto)
+endef
+$(eval $(call KernelPackage,crypto-iv))
+
+define KernelPackage/crypto-hw-padlock
+ TITLE:=VIA PadLock ACE with AES/SHA hw crypto module
+ DEPENDS:=+kmod-crypto-aes
+ KCONFIG:= \
+ CONFIG_CRYPTO_DEV_PADLOCK \
+ CONFIG_CRYPTO_DEV_PADLOCK_AES \
+ CONFIG_CRYPTO_DEV_PADLOCK_SHA
+ FILES:= \
+ $(LINUX_DIR)/drivers/crypto/padlock-aes.ko \
+ $(LINUX_DIR)/drivers/crypto/padlock-sha.ko
+ AUTOLOAD:=$(call AutoLoad,09,padlock-aes padlock-sha)
+ $(call AddDepends/crypto)
+endef
+
+$(eval $(call KernelPackage,crypto-hw-padlock))
+
+
+define KernelPackage/crypto-hw-geode
+ TITLE:=AMD Geode hardware crypto module
+ KCONFIG:= \
+ CONFIG_CRYPTO_DEV_GEODE
+ FILES:=$(LINUX_DIR)/drivers/crypto/geode-aes.ko
+ AUTOLOAD:=$(call AutoLoad,09,geode-aes)
+ $(call AddDepends/crypto)
+endef
+
+$(eval $(call KernelPackage,crypto-hw-geode))
+
+
+define KernelPackage/crypto-hw-hifn-795x
+ TITLE:=HIFN 795x crypto accelerator
+ KCONFIG:= \
+ CONFIG_HW_RANDOM=y \
+ CONFIG_CRYPTO_DEV_HIFN_795X \
+ CONFIG_CRYPTO_DEV_HIFN_795X_RNG=y
+ FILES:=$(LINUX_DIR)/drivers/crypto/hifn_795x.ko
+ AUTOLOAD:=$(call AutoLoad,09,hifn_795x)
+ $(call AddDepends/crypto,+kmod-crypto-des)
+endef
+
+$(eval $(call KernelPackage,crypto-hw-hifn-795x))
+
+
+define KernelPackage/crypto-hw-ppc4xx
+ TITLE:=AMCC PPC4xx hardware crypto module
+ DEPENDS:=@TARGET_ppc40x||TARGET_ppc44x
+ KCONFIG:= \
+ CONFIG_CRYPTO_DEV_PPC4XX
+ FILES:=$(LINUX_DIR)/drivers/crypto/amcc/crypto4xx.ko
+ AUTOLOAD:=$(call AutoLoad,90,crypto4xx)
+ $(call AddDepends/crypto)
+endef
+
+define KernelPackage/crypto-hw-ppc4xx/description
+ Kernel support for the AMCC PPC4xx HW crypto engine.
+endef
+
+$(eval $(call KernelPackage,crypto-hw-ppc4xx))
+
+
+define KernelPackage/crypto-aes
+ TITLE:=AES cipher CryptoAPI module
+ KCONFIG:=CONFIG_CRYPTO_AES CONFIG_CRYPTO_AES_586
+ FILES:=$(LINUX_DIR)/crypto/aes_generic.ko
+ AUTOLOAD:=$(call AutoLoad,09,aes_generic)
+ $(call AddDepends/crypto)
+endef
+
+define KernelPackage/crypto-aes/x86
+ FILES+=$(LINUX_DIR)/arch/x86/crypto/aes-i586.ko
+ AUTOLOAD:=$(call AutoLoad,09,aes_generic aes-i586)
+endef
+
+$(eval $(call KernelPackage,crypto-aes))
+
+
+define KernelPackage/crypto-arc4
+ TITLE:=ARC4 (RC4) cipher CryptoAPI module
+ KCONFIG:=CONFIG_CRYPTO_ARC4
+ FILES:=$(LINUX_DIR)/crypto/arc4.ko
+ AUTOLOAD:=$(call AutoLoad,09,arc4)
+ $(call AddDepends/crypto,+!LINUX_3_3:kmod-crypto-manager)
+endef
+
+$(eval $(call KernelPackage,crypto-arc4))
+
+
+define KernelPackage/crypto-authenc
+ TITLE:=Combined mode wrapper for IPsec
+ DEPENDS:=+kmod-crypto-manager
+ KCONFIG:=CONFIG_CRYPTO_AUTHENC
+ FILES:=$(LINUX_DIR)/crypto/authenc.ko
+ AUTOLOAD:=$(call AutoLoad,09,authenc)
+ $(call AddDepends/crypto)
+endef
+
+$(eval $(call KernelPackage,crypto-authenc))
+
+define KernelPackage/crypto-cbc
+ TITLE:=Cipher Block Chaining CryptoAPI module
+ DEPENDS:=+kmod-crypto-manager
+ KCONFIG:=CONFIG_CRYPTO_CBC
+ FILES:=$(LINUX_DIR)/crypto/cbc.ko
+ AUTOLOAD:=$(call AutoLoad,09,cbc)
+ $(call AddDepends/crypto)
+endef
+
+$(eval $(call KernelPackage,crypto-cbc))
+
+define KernelPackage/crypto-crc32c
+ TITLE:=CRC32c CRC module
+ DEPENDS:=+kmod-crypto-hash
+ KCONFIG:=CONFIG_CRYPTO_CRC32C
+ FILES:=$(LINUX_DIR)/crypto/crc32c.ko
+ AUTOLOAD:=$(call AutoLoad,04,crc32c,1)
+ $(call AddDepends/crypto)
+endef
+
+$(eval $(call KernelPackage,crypto-crc32c))
+
+define KernelPackage/crypto-des
+ TITLE:=DES/3DES cipher CryptoAPI module
+ KCONFIG:=CONFIG_CRYPTO_DES
+ FILES:=$(LINUX_DIR)/crypto/des_generic.ko
+ AUTOLOAD:=$(call AutoLoad,09,des_generic)
+ $(call AddDepends/crypto)
+endef
+
+$(eval $(call KernelPackage,crypto-des))
+
+define KernelPackage/crypto-deflate
+ TITLE:=Deflate compression CryptoAPI module
+ DEPENDS:=+kmod-lib-zlib
+ KCONFIG:=CONFIG_CRYPTO_DEFLATE
+ FILES:=$(LINUX_DIR)/crypto/deflate.ko
+ AUTOLOAD:=$(call AutoLoad,09,deflate)
+ $(call AddDepends/crypto)
+endef
+
+$(eval $(call KernelPackage,crypto-deflate))
+
+define KernelPackage/crypto-ecb
+ TITLE:=Electronic CodeBook CryptoAPI module
+ DEPENDS:=+kmod-crypto-manager
+ KCONFIG:=CONFIG_CRYPTO_ECB
+ FILES:=$(LINUX_DIR)/crypto/ecb.ko
+ AUTOLOAD:=$(call AutoLoad,09,ecb)
+ $(call AddDepends/crypto)
+endef
+
+$(eval $(call KernelPackage,crypto-ecb))
+
+
+define KernelPackage/crypto-hmac
+ TITLE:=HMAC digest CryptoAPI module
+ DEPENDS:=+kmod-crypto-hash
+ KCONFIG:=CONFIG_CRYPTO_HMAC
+ FILES:=$(LINUX_DIR)/crypto/hmac.ko
+ DEPENDS:=+kmod-crypto-manager
+ AUTOLOAD:=$(call AutoLoad,09,hmac)
+ $(call AddDepends/crypto)
+endef
+
+$(eval $(call KernelPackage,crypto-hmac))
+
+
+define KernelPackage/crypto-md4
+ TITLE:=MD4 digest CryptoAPI module
+ DEPENDS:=+kmod-crypto-hash
+ KCONFIG:=CONFIG_CRYPTO_MD4
+ FILES:=$(LINUX_DIR)/crypto/md4.ko
+ AUTOLOAD:=$(call AutoLoad,09,md4)
+ $(call AddDepends/crypto)
+endef
+
+$(eval $(call KernelPackage,crypto-md4))
+
+
+define KernelPackage/crypto-md5
+ TITLE:=MD5 digest CryptoAPI module
+ DEPENDS:=+kmod-crypto-hash
+ KCONFIG:=CONFIG_CRYPTO_MD5
+ FILES:=$(LINUX_DIR)/crypto/md5.ko
+ AUTOLOAD:=$(call AutoLoad,09,md5)
+ $(call AddDepends/crypto)
+endef
+
+$(eval $(call KernelPackage,crypto-md5))
+
+
+define KernelPackage/crypto-michael-mic
+ TITLE:=Michael MIC keyed digest CryptoAPI module
+ DEPENDS:=+kmod-crypto-hash
+ KCONFIG:=CONFIG_CRYPTO_MICHAEL_MIC
+ FILES:=$(LINUX_DIR)/crypto/michael_mic.ko
+ AUTOLOAD:=$(call AutoLoad,09,michael_mic)
+ $(call AddDepends/crypto)
+endef
+
+$(eval $(call KernelPackage,crypto-michael-mic))
+
+
+define KernelPackage/crypto-sha1
+ TITLE:=SHA1 digest CryptoAPI module
+ DEPENDS:=+kmod-crypto-hash
+ KCONFIG:=CONFIG_CRYPTO_SHA1
+ FILES:=$(LINUX_DIR)/crypto/sha1_generic.ko
+ AUTOLOAD:=$(call AutoLoad,09,sha1_generic)
+ $(call AddDepends/crypto)
+endef
+
+$(eval $(call KernelPackage,crypto-sha1))
+
+define KernelPackage/crypto-sha256
+ TITLE:=SHA224 SHA256 digest CryptoAPI module
+ DEPENDS:=+kmod-crypto-hash
+ KCONFIG:=CONFIG_CRYPTO_SHA256
+ FILES:=$(LINUX_DIR)/crypto/sha256_generic.ko
+ AUTOLOAD:=$(call AutoLoad,09,sha256_generic)
+ $(call AddDepends/crypto)
+endef
+
+$(eval $(call KernelPackage,crypto-sha256))
+
+ifeq ($(strip $(call CompareKernelPatchVer,$(KERNEL_PATCHVER),ge,3.6.0)),1)
+camellia_mod_suffix=_generic
+endif
+ifeq ($(strip $(call CompareKernelPatchVer,$(KERNEL_PATCHVER),ge,3.7.0)),1)
+cast56_mod_suffix=_generic
+endif
+
+define KernelPackage/crypto-misc
+ TITLE:=Other CryptoAPI modules
+ DEPENDS:=+kmod-crypto-manager
+ KCONFIG:= \
+ CONFIG_CRYPTO_ANUBIS \
+ CONFIG_CRYPTO_BLOWFISH \
+ CONFIG_CRYPTO_CAMELLIA \
+ CONFIG_CRYPTO_CAST5 \
+ CONFIG_CRYPTO_CAST6 \
+ CONFIG_CRYPTO_FCRYPT \
+ CONFIG_CRYPTO_KHAZAD \
+ CONFIG_CRYPTO_SERPENT \
+ CONFIG_CRYPTO_SHA512 \
+ CONFIG_CRYPTO_TEA \
+ CONFIG_CRYPTO_TGR192 \
+ CONFIG_CRYPTO_TWOFISH \
+ CONFIG_CRYPTO_TWOFISH_COMMON \
+ CONFIG_CRYPTO_TWOFISH_586 \
+ CONFIG_CRYPTO_WP512
+ FILES:= \
+ $(LINUX_DIR)/crypto/anubis.ko \
+ $(LINUX_DIR)/crypto/camellia$(camellia_mod_suffix).ko \
+ $(LINUX_DIR)/crypto/cast5$(cast56_mod_suffix).ko \
+ $(LINUX_DIR)/crypto/cast6$(cast56_mod_suffix).ko \
+ $(LINUX_DIR)/crypto/fcrypt.ko \
+ $(LINUX_DIR)/crypto/khazad.ko \
+ $(LINUX_DIR)/crypto/sha512_generic.ko \
+ $(LINUX_DIR)/crypto/tea.ko \
+ $(LINUX_DIR)/crypto/tgr192.ko \
+ $(LINUX_DIR)/crypto/twofish_common.ko \
+ $(LINUX_DIR)/crypto/wp512.ko \
+ $(LINUX_DIR)/crypto/twofish_generic.ko
+ FILES += \
+ $(LINUX_DIR)/crypto/blowfish_common.ko \
+ $(LINUX_DIR)/crypto/blowfish_generic.ko \
+ $(LINUX_DIR)/crypto/serpent_generic.ko
+ $(call AddDepends/crypto)
+endef
+
+
+define KernelPackage/crypto-misc/x86
+ FILES+=$(LINUX_DIR)/arch/x86/crypto/twofish-i586.ko
+endef
+
+$(eval $(call KernelPackage,crypto-misc))
+
+
+define KernelPackage/crypto-ocf
+ TITLE:=OCF modules
+ DEPENDS:=+@OPENSSL_ENGINE_CRYPTO @!TARGET_uml +kmod-crypto-manager
+ KCONFIG:= \
+ CONFIG_OCF_OCF \
+ CONFIG_OCF_CRYPTODEV \
+ CONFIG_OCF_CRYPTOSOFT \
+ CONFIG_OCF_FIPS=y \
+ CONFIG_OCF_RANDOMHARVEST=y
+ FILES:= \
+ $(LINUX_DIR)/crypto/ocf/ocf.ko \
+ $(LINUX_DIR)/crypto/ocf/cryptodev.ko \
+ $(LINUX_DIR)/crypto/ocf/cryptosoft.ko
+ AUTOLOAD:=$(call AutoLoad,09, \
+ ocf \
+ cryptodev \
+ cryptosoft \
+ )
+ $(call AddDepends/crypto)
+endef
+
+$(eval $(call KernelPackage,crypto-ocf))
+
+
+define KernelPackage/crypto-ocf-hifn7751
+ TITLE:=OCF support for Hifn 6500/7751/7811/795x, Invertex AEON and NetSec 7751 devices
+ DEPENDS:=+@OPENSSL_ENGINE_CRYPTO @PCI_SUPPORT @!TARGET_uml kmod-crypto-ocf
+ KCONFIG:=CONFIG_OCF_HIFN
+ FILES:=$(LINUX_DIR)/crypto/ocf/hifn/hifn7751.ko
+ AUTOLOAD:=$(call AutoLoad,10,hifn7751)
+ $(call AddDepends/crypto)
+endef
+
+$(eval $(call KernelPackage,crypto-ocf-hifn7751))
+
+
+define KernelPackage/crypto-ocf-hifnhipp
+ TITLE:=OCF support for Hifn 7855/8155 devices
+ DEPENDS:=+@OPENSSL_ENGINE_CRYPTO @PCI_SUPPORT @!TARGET_uml kmod-crypto-ocf
+ KCONFIG:=CONFIG_OCF_HIFNHIPP
+ FILES:=$(LINUX_DIR)/crypto/ocf/hifn/hifnHIPP.ko
+ AUTOLOAD:=$(call AutoLoad,10,hifnHIPP)
+ $(call AddDepends/crypto)
+endef
+
+$(eval $(call KernelPackage,crypto-ocf-hifnhipp))
+
+
+define KernelPackage/crypto-null
+ TITLE:=Null CryptoAPI module
+ KCONFIG:=CONFIG_CRYPTO_NULL
+ FILES:=$(LINUX_DIR)/crypto/crypto_null.ko
+ AUTOLOAD:=$(call AutoLoad,09,crypto_null)
+ $(call AddDepends/crypto)
+endef
+
+$(eval $(call KernelPackage,crypto-null))
+
+
+define KernelPackage/crypto-test
+ TITLE:=Test CryptoAPI module
+ KCONFIG:=CONFIG_CRYPTO_TEST
+ FILES:=$(LINUX_DIR)/crypto/tcrypt.ko
+ $(call AddDepends/crypto)
+endef
+
+$(eval $(call KernelPackage,crypto-test))
+
+
+define KernelPackage/crypto-xts
+ TITLE:=XTS cipher CryptoAPI module
+ DEPENDS:=+kmod-crypto-manager
+ KCONFIG:= \
+ CONFIG_CRYPTO_GF128MUL \
+ CONFIG_CRYPTO_XTS
+ FILES:= \
+ $(LINUX_DIR)/crypto/xts.ko \
+ $(LINUX_DIR)/crypto/gf128mul.ko
+ AUTOLOAD:=$(call AutoLoad,09, \
+ gf128mul \
+ xts \
+ )
+ $(call AddDepends/crypto)
+endef
+
+$(eval $(call KernelPackage,crypto-xts))
+
+define KernelPackage/crypto-mv-cesa
+ TITLE:=Marvell crypto engine
+ DEPENDS:=+kmod-crypto-manager +kmod-crypto-aes @TARGET_kirkwood||TARGET_orion||TARGET_mvebu
+ KCONFIG:=CONFIG_CRYPTO_DEV_MV_CESA
+ FILES:=$(LINUX_DIR)/drivers/crypto/mv_cesa.ko
+ AUTOLOAD:=$(call AutoLoad,09,mv_cesa)
+ $(call AddDepends/crypto)
+endef
+
+$(eval $(call KernelPackage,crypto-mv-cesa))
diff --git a/package/kernel/modules/.svn/text-base/firewire.mk.svn-base b/package/kernel/modules/.svn/text-base/firewire.mk.svn-base
new file mode 100644
index 0000000..34edf0c
--- /dev/null
+++ b/package/kernel/modules/.svn/text-base/firewire.mk.svn-base
@@ -0,0 +1,77 @@
+#
+# Copyright (C) 2008-2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+FIREWIRE_MENU:=FireWire support
+
+
+define KernelPackage/firewire
+ SUBMENU:=$(FIREWIRE_MENU)
+ TITLE:=Support for FireWire (new stack)
+ DEPENDS:=@PCI_SUPPORT +kmod-lib-crc-itu-t
+ KCONFIG:=CONFIG_FIREWIRE
+ FILES:=$(LINUX_DIR)/drivers/firewire/firewire-core.ko
+ AUTOLOAD:=$(call AutoLoad,20,firewire-core)
+endef
+
+define KernelPackage/firewire/description
+ Kernel support for FireWire (new stack)
+endef
+
+$(eval $(call KernelPackage,firewire))
+
+
+define KernelPackage/firewire-ohci
+ SUBMENU:=$(FIREWIRE_MENU)
+ TITLE:=Support for OHCI-1394 controllers
+ DEPENDS:=kmod-firewire
+ KCONFIG:= \
+ CONFIG_FIREWIRE_OHCI \
+ CONFIG_FIREWIRE_OHCI_DEBUG=n \
+ CONFIG_FIREWIRE_OHCI_REMOTE_DMA=n
+ FILES:=$(LINUX_DIR)/drivers/firewire/firewire-ohci.ko
+ AUTOLOAD:=$(call AutoLoad,50,firewire-ohci)
+endef
+
+
+define KernelPackage/firewire-ohci/description
+ Kernel support for FireWire OHCI-1394 controllers
+endef
+
+$(eval $(call KernelPackage,firewire-ohci))
+
+
+define KernelPackage/firewire-sbp2
+ SUBMENU:=$(FIREWIRE_MENU)
+ TITLE:=Support for SBP-2 devices over FireWire
+ DEPENDS:=kmod-firewire +kmod-scsi-core
+ KCONFIG:=CONFIG_FIREWIRE_SBP2
+ FILES:=$(LINUX_DIR)/drivers/firewire/firewire-sbp2.ko
+ AUTOLOAD:=$(call AutoLoad,50,firewire-sbp2)
+endef
+
+define KernelPackage/firewire-sbp2/description
+ Kernel support for SBP-2 devices over FireWire
+endef
+
+$(eval $(call KernelPackage,firewire-sbp2))
+
+
+define KernelPackage/firewire-net
+ SUBMENU:=$(FIREWIRE_MENU)
+ TITLE:=Support for IP networking over FireWire
+ DEPENDS:=kmod-firewire
+ KCONFIG:=CONFIG_FIREWIRE_NET
+ FILES:=$(LINUX_DIR)/drivers/firewire/firewire-net.ko
+ AUTOLOAD:=$(call AutoLoad,50,firewire-net)
+endef
+
+define KernelPackage/firewire-net/description
+ Kernel support for IPv4 over FireWire
+endef
+
+$(eval $(call KernelPackage,firewire-net))
+
diff --git a/package/kernel/modules/.svn/text-base/fs.mk.svn-base b/package/kernel/modules/.svn/text-base/fs.mk.svn-base
new file mode 100644
index 0000000..1b1fdd4
--- /dev/null
+++ b/package/kernel/modules/.svn/text-base/fs.mk.svn-base
@@ -0,0 +1,371 @@
+#
+# Copyright (C) 2006-2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+FS_MENU:=Filesystems
+
+define KernelPackage/fs-autofs4
+ SUBMENU:=$(FS_MENU)
+ TITLE:=AUTOFS4 filesystem support
+ KCONFIG:=CONFIG_AUTOFS4_FS
+ FILES:=$(LINUX_DIR)/fs/autofs4/autofs4.ko
+ AUTOLOAD:=$(call AutoLoad,30,autofs4)
+endef
+
+define KernelPackage/fs-autofs4/description
+ Kernel module for AutoFS4 support
+endef
+
+$(eval $(call KernelPackage,fs-autofs4))
+
+
+define KernelPackage/fs-btrfs
+ SUBMENU:=$(FS_MENU)
+ TITLE:=BTRFS filesystem support
+ DEPENDS:=+kmod-lib-crc32c +kmod-lib-lzo +kmod-lib-zlib
+ KCONFIG:=\
+ CONFIG_BTRFS_FS \
+ CONFIG_BTRFS_FS_POSIX_ACL=n \
+ CONFIG_BTRFS_FS_CHECK_INTEGRITY=n
+ FILES:=\
+ $(LINUX_DIR)/fs/btrfs/btrfs.ko
+ AUTOLOAD:=$(call AutoLoad,30,btrfs,1)
+endef
+
+define KernelPackage/fs-btrfs/description
+ Kernel module for BTRFS support
+endef
+
+$(eval $(call KernelPackage,fs-btrfs))
+
+
+define KernelPackage/fs-cifs
+ SUBMENU:=$(FS_MENU)
+ TITLE:=CIFS support
+ KCONFIG:= \
+ CONFIG_CIFS \
+ CONFIG_CIFS_DFS_UPCALL=n \
+ CONFIG_CIFS_UPCALL=n
+ FILES:=$(LINUX_DIR)/fs/cifs/cifs.ko
+ AUTOLOAD:=$(call AutoLoad,30,cifs)
+ $(call AddDepends/nls)
+ DEPENDS+= \
+ +kmod-crypto-arc4 \
+ +kmod-crypto-hmac \
+ +kmod-crypto-md5 \
+ +kmod-crypto-md4 \
+ +kmod-crypto-des \
+ +kmod-crypto-ecb \
+ +!LINUX_3_3&&!LINUX_3_6:kmod-crypto-sha256
+endef
+
+define KernelPackage/fs-cifs/description
+ Kernel module for CIFS support
+endef
+
+$(eval $(call KernelPackage,fs-cifs))
+
+
+define KernelPackage/fs-configfs
+ SUBMENU:=$(FS_MENU)
+ TITLE:=Configuration filesystem support
+ KCONFIG:= \
+ CONFIG_CONFIGFS_FS
+ FILES:=$(LINUX_DIR)/fs/configfs/configfs.ko
+ AUTOLOAD:=$(call AutoLoad,30,configfs)
+endef
+
+define KernelPackage/fs-configfs/description
+ Kernel module for configfs support
+endef
+
+$(eval $(call KernelPackage,fs-configfs))
+
+
+define KernelPackage/fs-exportfs
+ SUBMENU:=$(FS_MENU)
+ TITLE:=exportfs kernel server support
+ KCONFIG:=CONFIG_EXPORTFS
+ FILES=$(LINUX_DIR)/fs/exportfs/exportfs.ko
+ AUTOLOAD:=$(call AutoLoad,20,exportfs)
+endef
+
+define KernelPackage/fs-exportfs/description
+ Kernel module for exportfs. Needed for some other modules.
+endef
+
+$(eval $(call KernelPackage,fs-exportfs))
+
+
+define KernelPackage/fs-ext4
+ SUBMENU:=$(FS_MENU)
+ TITLE:=EXT4 filesystem support
+ KCONFIG:= \
+ CONFIG_EXT4_FS \
+ CONFIG_JBD2
+ FILES:= \
+ $(LINUX_DIR)/fs/ext4/ext4.ko \
+ $(LINUX_DIR)/fs/jbd2/jbd2.ko \
+ $(LINUX_DIR)/fs/mbcache.ko
+ AUTOLOAD:=$(call AutoLoad,30,mbcache jbd2 ext4,1)
+ $(call AddDepends/crc16, +!LINUX_3_3:kmod-crypto-hash)
+endef
+
+define KernelPackage/fs-ext4/description
+ Kernel module for EXT4 filesystem support
+endef
+
+$(eval $(call KernelPackage,fs-ext4))
+
+
+define KernelPackage/fuse
+ SUBMENU:=$(FS_MENU)
+ TITLE:=FUSE (Filesystem in Userspace) support
+ KCONFIG:= CONFIG_FUSE_FS
+ FILES:=$(LINUX_DIR)/fs/fuse/fuse.ko
+ AUTOLOAD:=$(call AutoLoad,80,fuse)
+endef
+
+define KernelPackage/fuse/description
+ Kernel module for userspace filesystem support
+endef
+
+$(eval $(call KernelPackage,fuse))
+
+
+define KernelPackage/fs-hfs
+ SUBMENU:=$(FS_MENU)
+ TITLE:=HFS filesystem support
+ KCONFIG:=CONFIG_HFS_FS
+ FILES:=$(LINUX_DIR)/fs/hfs/hfs.ko
+ AUTOLOAD:=$(call AutoLoad,30,hfs)
+ $(call AddDepends/nls)
+endef
+
+define KernelPackage/fs-hfs/description
+ Kernel module for HFS filesystem support
+endef
+
+$(eval $(call KernelPackage,fs-hfs))
+
+
+define KernelPackage/fs-hfsplus
+ SUBMENU:=$(FS_MENU)
+ TITLE:=HFS+ filesystem support
+ KCONFIG:=CONFIG_HFSPLUS_FS
+ FILES:=$(LINUX_DIR)/fs/hfsplus/hfsplus.ko
+ AUTOLOAD:=$(call AutoLoad,30,hfsplus)
+ $(call AddDepends/nls,utf8)
+endef
+
+define KernelPackage/fs-hfsplus/description
+ Kernel module for HFS+ filesystem support
+endef
+
+$(eval $(call KernelPackage,fs-hfsplus))
+
+
+define KernelPackage/fs-isofs
+ SUBMENU:=$(FS_MENU)
+ TITLE:=ISO9660 filesystem support
+ KCONFIG:=CONFIG_ISO9660_FS CONFIG_JOLIET=y CONFIG_ZISOFS=n
+ FILES:=$(LINUX_DIR)/fs/isofs/isofs.ko
+ AUTOLOAD:=$(call AutoLoad,30,isofs)
+ $(call AddDepends/nls)
+endef
+
+define KernelPackage/fs-isofs/description
+ Kernel module for ISO9660 filesystem support
+endef
+
+$(eval $(call KernelPackage,fs-isofs))
+
+
+define KernelPackage/fs-minix
+ SUBMENU:=$(FS_MENU)
+ TITLE:=Minix filesystem support
+ KCONFIG:=CONFIG_MINIX_FS
+ FILES:=$(LINUX_DIR)/fs/minix/minix.ko
+ AUTOLOAD:=$(call AutoLoad,30,minix)
+endef
+
+define KernelPackage/fs-minix/description
+ Kernel module for Minix filesystem support
+endef
+
+$(eval $(call KernelPackage,fs-minix))
+
+
+define KernelPackage/fs-msdos
+ SUBMENU:=$(FS_MENU)
+ TITLE:=MSDOS filesystem support
+ KCONFIG:=CONFIG_MSDOS_FS
+ FILES:=$(LINUX_DIR)/fs/fat/msdos.ko
+ AUTOLOAD:=$(call AutoLoad,40,msdos)
+ $(call AddDepends/nls)
+endef
+
+define KernelPackage/fs-msdos/description
+ Kernel module for MSDOS filesystem support
+endef
+
+$(eval $(call KernelPackage,fs-msdos))
+
+
+define KernelPackage/fs-nfs
+ SUBMENU:=$(FS_MENU)
+ TITLE:=NFS filesystem support
+ DEPENDS:=+kmod-fs-nfs-common
+ KCONFIG:= \
+ CONFIG_NFS_FS \
+ CONFIG_NFS_USE_LEGACY_DNS=n \
+ CONFIG_NFS_USE_NEW_IDMAPPER=n
+ FILES:= \
+ $(LINUX_DIR)/fs/nfs/nfs.ko
+ AUTOLOAD:=$(call AutoLoad,40,nfs)
+endef
+
+define KernelPackage/fs-nfs/description
+ Kernel module for NFS support
+endef
+
+$(eval $(call KernelPackage,fs-nfs))
+
+
+define KernelPackage/fs-nfs-common
+ SUBMENU:=$(FS_MENU)
+ TITLE:=Common NFS filesystem modules
+ KCONFIG:= \
+ CONFIG_LOCKD \
+ CONFIG_SUNRPC
+ FILES:= \
+ $(LINUX_DIR)/fs/lockd/lockd.ko \
+ $(LINUX_DIR)/net/sunrpc/sunrpc.ko
+ AUTOLOAD:=$(call AutoLoad,30,sunrpc lockd)
+endef
+
+$(eval $(call KernelPackage,fs-nfs-common))
+
+
+define KernelPackage/fs-nfs-common-v4
+ SUBMENU:=$(FS_MENU)
+ TITLE:=Common NFS V4 filesystem modules
+ KCONFIG+=\
+ CONFIG_SUNRPC_GSS\
+ CONFIG_NFS_V4=y\
+ CONFIG_NFSD_V4=y
+ DEPENDS:= @BROKEN
+ FILES+=$(LINUX_DIR)/net/sunrpc/auth_gss/auth_rpcgss.ko
+ AUTOLOAD=$(call AutoLoad,30,auth_rpcgss)
+endef
+
+define KernelPackage/fs-nfs-common-v4/description
+ Kernel modules for NFS V4 & NFSD V4 kernel support
+endef
+
+$(eval $(call KernelPackage,fs-nfs-common-v4))
+
+
+define KernelPackage/fs-nfsd
+ SUBMENU:=$(FS_MENU)
+ TITLE:=NFS kernel server support
+ DEPENDS:=+kmod-fs-nfs-common +kmod-fs-exportfs
+ KCONFIG:= \
+ CONFIG_NFSD \
+ CONFIG_NFSD_FAULT_INJECTION=n
+ FILES:=$(LINUX_DIR)/fs/nfsd/nfsd.ko
+ AUTOLOAD:=$(call AutoLoad,40,nfsd)
+endef
+
+define KernelPackage/fs-nfsd/description
+ Kernel module for NFS kernel server support
+endef
+
+$(eval $(call KernelPackage,fs-nfsd))
+
+
+define KernelPackage/fs-ntfs
+ SUBMENU:=$(FS_MENU)
+ TITLE:=NTFS filesystem support
+ KCONFIG:=CONFIG_NTFS_FS
+ FILES:=$(LINUX_DIR)/fs/ntfs/ntfs.ko
+ AUTOLOAD:=$(call AutoLoad,30,ntfs)
+ $(call AddDepends/nls)
+endef
+
+define KernelPackage/fs-ntfs/description
+ Kernel module for NTFS filesystem support
+endef
+
+$(eval $(call KernelPackage,fs-ntfs))
+
+
+define KernelPackage/fs-reiserfs
+ SUBMENU:=$(FS_MENU)
+ TITLE:=ReiserFS filesystem support
+ KCONFIG:=CONFIG_REISERFS_FS
+ FILES:=$(LINUX_DIR)/fs/reiserfs/reiserfs.ko
+ AUTOLOAD:=$(call AutoLoad,30,reiserfs,1)
+endef
+
+define KernelPackage/fs-reiserfs/description
+ Kernel module for ReiserFS support
+endef
+
+$(eval $(call KernelPackage,fs-reiserfs))
+
+
+define KernelPackage/fs-udf
+ SUBMENU:=$(FS_MENU)
+ TITLE:=UDF filesystem support
+ KCONFIG:=CONFIG_UDF_FS
+ FILES:=$(LINUX_DIR)/fs/udf/udf.ko
+ AUTOLOAD:=$(call AutoLoad,30,udf)
+ DEPENDS:=+kmod-lib-crc-itu-t
+ $(call AddDepends/nls)
+endef
+
+define KernelPackage/fs-udf/description
+ Kernel module for UDF filesystem support
+endef
+
+$(eval $(call KernelPackage,fs-udf))
+
+
+define KernelPackage/fs-vfat
+ SUBMENU:=$(FS_MENU)
+ TITLE:=VFAT filesystem support
+ KCONFIG:= \
+ CONFIG_FAT_FS \
+ CONFIG_VFAT_FS
+ FILES:= \
+ $(LINUX_DIR)/fs/fat/fat.ko \
+ $(LINUX_DIR)/fs/fat/vfat.ko
+ AUTOLOAD:=$(call AutoLoad,30,fat vfat)
+ $(call AddDepends/nls)
+endef
+
+define KernelPackage/fs-vfat/description
+ Kernel module for VFAT filesystem support
+endef
+
+$(eval $(call KernelPackage,fs-vfat))
+
+
+define KernelPackage/fs-xfs
+ SUBMENU:=$(FS_MENU)
+ TITLE:=XFS filesystem support
+ KCONFIG:=CONFIG_XFS_FS
+ DEPENDS:= +kmod-fs-exportfs @!avr32
+ FILES:=$(LINUX_DIR)/fs/xfs/xfs.ko
+ AUTOLOAD:=$(call AutoLoad,30,xfs,1)
+endef
+
+define KernelPackage/fs-xfs/description
+ Kernel module for XFS support
+endef
+
+$(eval $(call KernelPackage,fs-xfs))
diff --git a/package/kernel/modules/.svn/text-base/hwmon.mk.svn-base b/package/kernel/modules/.svn/text-base/hwmon.mk.svn-base
new file mode 100644
index 0000000..d549336
--- /dev/null
+++ b/package/kernel/modules/.svn/text-base/hwmon.mk.svn-base
@@ -0,0 +1,192 @@
+#
+# Copyright (C) 2006-2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+HWMON_MENU:=Hardware Monitoring Support
+
+define KernelPackage/hwmon-core
+ SUBMENU:=$(HWMON_MENU)
+ TITLE:=Hardware monitoring support
+ KCONFIG:= \
+ CONFIG_HWMON \
+ CONFIG_HWMON_DEBUG_CHIP=n
+ FILES:= \
+ $(LINUX_DIR)/drivers/hwmon/hwmon.ko
+ AUTOLOAD:=$(call AutoLoad,40,hwmon)
+endef
+
+define KernelPackage/hwmon-core/description
+ Kernel modules for hardware monitoring
+endef
+
+$(eval $(call KernelPackage,hwmon-core))
+
+
+define AddDepends/hwmon
+ SUBMENU:=$(HWMON_MENU)
+ DEPENDS:=kmod-hwmon-core $(1)
+endef
+
+define KernelPackage/hwmon-vid
+ TITLE:=VID/VRM/VRD voltage conversion module.
+ KCONFIG:=CONFIG_HWMON_VID
+ FILES:=$(LINUX_DIR)/drivers/hwmon/hwmon-vid.ko
+ AUTOLOAD:=$(call AutoLoad,41,hwmon-vid)
+ $(call AddDepends/hwmon,)
+endef
+
+define KernelPackage/hwmon-vid/description
+ VID/VRM/VRD voltage conversion module for hardware monitoring.
+endef
+
+$(eval $(call KernelPackage,hwmon-vid))
+
+
+define KernelPackage/hwmon-adt7475
+ TITLE:=ADT7473/7475/7476/7490 monitoring support
+ KCONFIG:=CONFIG_SENSORS_ADT7475
+ FILES:=$(LINUX_DIR)/drivers/hwmon/adt7475.ko
+ AUTOLOAD:=$(call AutoLoad,60,adt7475)
+ $(call AddDepends/hwmon,+kmod-i2c-core +kmod-hwmon-vid)
+endef
+
+define KernelPackage/hwmon-adt7475/description
+ Kernel module for ADT7473/7475/7476/7490 thermal monitor chip.
+endef
+
+$(eval $(call KernelPackage,hwmon-adt7475))
+
+
+define KernelPackage/hwmon-lm63
+ TITLE:=LM63/64 monitoring support
+ KCONFIG:=CONFIG_SENSORS_LM63
+ FILES:=$(LINUX_DIR)/drivers/hwmon/lm63.ko
+ AUTOLOAD:=$(call AutoLoad,60,lm63)
+ $(call AddDepends/hwmon,+kmod-i2c-core)
+endef
+
+define KernelPackage/hwmon-lm63/description
+ Kernel module for lm63 and lm64 thermal monitor chip
+endef
+
+$(eval $(call KernelPackage,hwmon-lm63))
+
+
+define KernelPackage/hwmon-lm75
+ TITLE:=LM75 monitoring support
+ KCONFIG:=CONFIG_SENSORS_LM75
+ FILES:=$(LINUX_DIR)/drivers/hwmon/lm75.ko
+ AUTOLOAD:=$(call AutoLoad,60,lm75)
+ $(call AddDepends/hwmon,+kmod-i2c-core)
+endef
+
+define KernelPackage/hwmon-lm75/description
+ Kernel module for lm75 thermal monitor chip
+endef
+
+$(eval $(call KernelPackage,hwmon-lm75))
+
+
+define KernelPackage/hwmon-lm77
+ TITLE:=LM77 monitoring support
+ KCONFIG:=CONFIG_SENSORS_LM77
+ FILES:=$(LINUX_DIR)/drivers/hwmon/lm77.ko
+ AUTOLOAD:=$(call AutoLoad,60,lm77)
+ $(call AddDepends/hwmon,+kmod-i2c-core)
+endef
+
+define KernelPackage/hwmon-lm77/description
+ Kernel module for LM77 thermal monitor chip
+endef
+
+$(eval $(call KernelPackage,hwmon-lm77))
+
+
+define KernelPackage/hwmon-lm85
+ TITLE:=LM85 monitoring support
+ KCONFIG:=CONFIG_SENSORS_LM85
+ FILES:=$(LINUX_DIR)/drivers/hwmon/lm85.ko
+ AUTOLOAD:=$(call AutoLoad,60,lm85)
+ $(call AddDepends/hwmon,+kmod-i2c-core +kmod-hwmon-vid)
+endef
+
+define KernelPackage/hwmon-lm85/description
+ Kernel module for LM85 thermal monitor chip
+endef
+
+$(eval $(call KernelPackage,hwmon-lm85))
+
+
+define KernelPackage/hwmon-lm90
+ TITLE:=LM90 monitoring support
+ KCONFIG:=CONFIG_SENSORS_LM90
+ FILES:=$(LINUX_DIR)/drivers/hwmon/lm90.ko
+ AUTOLOAD:=$(call AutoLoad,60,lm90)
+ $(call AddDepends/hwmon,+kmod-i2c-core)
+endef
+
+define KernelPackage/hwmon-lm90/description
+ Kernel module for LM90 thermal monitor chip
+endef
+
+$(eval $(call KernelPackage,hwmon-lm90))
+
+define KernelPackage/hwmon-lm95241
+ TITLE:=LM95241 monitoring support
+ KCONFIG:=CONFIG_SENSORS_LM95241
+ FILES:=$(LINUX_DIR)/drivers/hwmon/lm95241.ko
+ AUTOLOAD:=$(call AutoLoad,60,lm95241)
+ $(call AddDepends/hwmon,+kmod-i2c-core)
+endef
+
+define KernelPackage/hwmon-lm95241/description
+ Kernel module for LM95241 thermal monitor chip
+endef
+
+$(eval $(call KernelPackage,hwmon-lm95241))
+
+define KernelPackage/hwmon-sht21
+ TITLE:=Sensiron SHT21 and compat. monitoring support
+ KCONFIG:=CONFIG_SENSORS_SHT21
+ FILES:=$(LINUX_DIR)/drivers/hwmon/sht21.ko
+ AUTOLOAD:=$(call AutoLoad,60,sht21)
+ $(call AddDepends/hwmon,+kmod-i2c-core)
+endef
+
+define KernelPackage/hwmon-sht21/description
+ Kernel module for Sensirion SHT21 and SHT25 temperature and humidity sensors chip
+endef
+
+$(eval $(call KernelPackage,hwmon-sht21))
+
+define KernelPackage/hwmon-pc87360
+ TITLE:=PC87360 monitoring support
+ KCONFIG:=CONFIG_SENSORS_PC87360
+ FILES:=$(LINUX_DIR)/drivers/hwmon/pc87360.ko
+ AUTOLOAD:=$(call AutoLoad,50,pc87360)
+ $(call AddDepends/hwmon,@TARGET_x86 +kmod-hwmon-vid)
+endef
+
+define KernelPackage/hwmon-pc87360/description
+ Kernel modules for PC87360 chips
+endef
+
+$(eval $(call KernelPackage,hwmon-pc87360))
+
+
+define KernelPackage/hwmon-w83627hf
+ TITLE:=Winbond W83627HF monitoring support
+ KCONFIG:=CONFIG_SENSORS_W83627HF
+ FILES:=$(LINUX_DIR)/drivers/hwmon/w83627hf.ko
+ AUTOLOAD:=$(call AutoLoad,50,w83627hf)
+$(call AddDepends/hwmon,@TARGET_rdc||TARGET_x86 +kmod-hwmon-vid)
+endef
+
+define KernelPacakge/hwmon-w83627hf/description
+ Kernel module for the Winbond W83627HF chips.
+endef
+
+$(eval $(call KernelPackage,hwmon-w83627hf))
diff --git a/package/kernel/modules/.svn/text-base/i2c.mk.svn-base b/package/kernel/modules/.svn/text-base/i2c.mk.svn-base
new file mode 100644
index 0000000..e01f937
--- /dev/null
+++ b/package/kernel/modules/.svn/text-base/i2c.mk.svn-base
@@ -0,0 +1,283 @@
+#
+# Copyright (C) 2006-2009 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+I2C_MENU:=I2C support
+
+ModuleConfVar=$(word 1,$(subst :,$(space),$(1)))
+ModuleFullPath=$(LINUX_DIR)/$(word 2,$(subst :,$(space),$(1))).ko
+ModuleKconfig=$(foreach mod,$(1),$(call ModuleConfVar,$(mod)))
+ModuleFiles=$(foreach mod,$(1),$(call ModuleFullPath,$(mod)))
+ModuleAuto=$(call AutoLoad,$(1),$(foreach mod,$(2),$(basename $(notdir $(call ModuleFullPath,$(mod))))),$(3))
+
+define i2c_defaults
+ SUBMENU:=$(I2C_MENU)
+ KCONFIG:=$(call ModuleKconfig,$(1))
+ FILES:=$(call ModuleFiles,$(1))
+ AUTOLOAD:=$(call ModuleAuto,$(2),$(1),$(3))
+endef
+
+I2C_CORE_MODULES:= \
+ CONFIG_I2C:drivers/i2c/i2c-core \
+ CONFIG_I2C_CHARDEV:drivers/i2c/i2c-dev
+
+define KernelPackage/i2c-core
+ $(call i2c_defaults,$(I2C_CORE_MODULES),51)
+ TITLE:=I2C support
+endef
+
+define KernelPackage/i2c-core/description
+ Kernel modules for I2C support
+endef
+
+$(eval $(call KernelPackage,i2c-core))
+
+
+I2C_ALGOBIT_MODULES:= \
+ CONFIG_I2C_ALGOBIT:drivers/i2c/algos/i2c-algo-bit
+
+define KernelPackage/i2c-algo-bit
+ $(call i2c_defaults,$(I2C_ALGOBIT_MODULES),55)
+ TITLE:=I2C bit-banging interfaces
+ DEPENDS:=kmod-i2c-core
+endef
+
+define KernelPackage/i2c-algo-bit/description
+ Kernel modules for I2C bit-banging interfaces.
+endef
+
+$(eval $(call KernelPackage,i2c-algo-bit))
+
+
+I2C_ALGOPCA_MODULES:= \
+ CONFIG_I2C_ALGOPCA:drivers/i2c/algos/i2c-algo-pca
+
+define KernelPackage/i2c-algo-pca
+ $(call i2c_defaults,$(I2C_ALGOPCA_MODULES),55)
+ TITLE:=I2C PCA 9564 interfaces
+ DEPENDS:=kmod-i2c-core
+endef
+
+define KernelPackage/i2c-algo-pca/description
+ Kernel modules for I2C PCA 9564 interfaces.
+endef
+
+$(eval $(call KernelPackage,i2c-algo-pca))
+
+
+I2C_ALGOPCF_MODULES:= \
+ CONFIG_I2C_ALGOPCF:drivers/i2c/algos/i2c-algo-pcf
+
+define KernelPackage/i2c-algo-pcf
+ $(call i2c_defaults,$(I2C_ALGOPCF_MODULES),55)
+ TITLE:=I2C PCF 8584 interfaces
+ DEPENDS:=kmod-i2c-core
+endef
+
+define KernelPackage/i2c-algo-pcf/description
+ Kernel modules for I2C PCF 8584 interfaces
+endef
+
+$(eval $(call KernelPackage,i2c-algo-pcf))
+
+
+I2C_GPIO_MODULES:= \
+ CONFIG_I2C_GPIO:drivers/i2c/busses/i2c-gpio
+
+define KernelPackage/i2c-gpio
+ $(call i2c_defaults,$(I2C_GPIO_MODULES),59)
+ TITLE:=GPIO-based bitbanging I2C
+ DEPENDS:=@GPIO_SUPPORT +kmod-i2c-algo-bit
+endef
+
+define KernelPackage/i2c-gpio/description
+ Kernel modules for a very simple bitbanging I2C driver utilizing the
+ arch-neutral GPIO API to control the SCL and SDA lines.
+endef
+
+$(eval $(call KernelPackage,i2c-gpio))
+
+
+OF_I2C_MODULES:=\
+ CONFIG_OF_I2C:drivers/of/of_i2c
+
+define KernelPackage/of-i2c
+ $(call i2c_defaults,$(OF_I2C_MODULES),58)
+ TITLE:=OpenFirmware I2C accessors
+ DEPENDS:=@TARGET_ppc40x||TARGET_ppc4xx||TARGET_mpc52xx||TARGET_mpc83xx||TARGET_mpc85xx||TARGET_mvebu \
+ kmod-i2c-core
+endef
+
+define KernelPackage/of-i2c/description
+ Kernel module for OpenFirmware I2C accessors.
+endef
+
+$(eval $(call KernelPackage,of-i2c))
+
+I2C_MPC_MODULES:=\
+ CONFIG_I2C_MPC:drivers/i2c/busses/i2c-mpc
+
+define KernelPackage/i2c-mpc
+ $(call i2c_defaults,$(I2C_MPC_MODULES),59)
+ TITLE:=MPC I2C accessors
+ DEPENDS:=@TARGET_mpc52xx||TARGET_mpc83xx||TARGET_mpc85xx \
+ +kmod-i2c-core +kmod-of-i2c
+endef
+
+define KernelPackage/i2c-mpc/description
+ Kernel module for Freescale MPC52xx MPC83xx MPC85xx I2C accessors.
+endef
+
+$(eval $(call KernelPackage,i2c-mpc))
+
+I2C_IBM_IIC_MODULES:=\
+ CONFIG_I2C_IBM_IIC:drivers/i2c/busses/i2c-ibm_iic
+
+define KernelPackage/i2c-ibm-iic
+ $(call i2c_defaults,$(OF_I2C_MODULES),59)
+ TITLE:=IBM PPC 4xx on-chip I2C interface support
+ DEPENDS:=@TARGET_ppc40x||TARGET_ppc4xx +kmod-i2c-core +kmod-of-i2c
+endef
+
+define KernelPackage/i2c-ibm-iic/description
+ Kernel module for IIC peripheral found on embedded IBM PPC4xx based systems.
+endef
+
+$(eval $(call KernelPackage,i2c-ibm-iic))
+
+I2C_MV64XXX_MODULES:=\
+ CONFIG_I2C_MV64XXX:drivers/i2c/busses/i2c-mv64xxx
+
+define KernelPackage/i2c-mv64xxx
+ $(call i2c_defaults,$(I2C_MV64XXX_MODULES),59)
+ TITLE:=Orion Platform I2C interface support
+ DEPENDS:=@TARGET_kirkwood||TARGET_orion||TARGET_mvebu (TARGET_kirkwood||TARGET_orion):kmod-i2c-core \
+ TARGET_mvebu:kmod-of-i2c
+endef
+
+define KernelPackage/i2c-mv64xxx/description
+ Kernel module for I2C interface on the Kirkwood, Orion and Armada XP/370
+ family processors.
+endef
+
+$(eval $(call KernelPackage,i2c-mv64xxx))
+
+
+I2C_TINY_USB_MODULES:= \
+ CONFIG_I2C_TINY_USB:drivers/i2c/busses/i2c-tiny-usb
+
+define KernelPackage/i2c-tiny-usb
+ $(call i2c_defaults,$(I2C_TINY_USB_MODULES),59)
+ TITLE:=I2C Tiny USB adaptor
+ DEPENDS:=@USB_SUPPORT kmod-i2c-core
+endef
+
+define KernelPackage/i2c-tiny-usb/description
+ Kernel module for the I2C Tiny USB adaptor developed
+ by Till Harbaum (http://www.harbaum.org/till/i2c_tiny_usb).
+endef
+
+$(eval $(call KernelPackage,i2c-tiny-usb))
+
+I2C_MUX_MODULES:= \
+ CONFIG_I2C_MUX:drivers/i2c/i2c-mux
+
+define KernelPackage/i2c-mux
+ $(call i2c_defaults,$(I2C_MUX_MODULES),51)
+ TITLE:=I2C bus multiplexing support
+ DEPENDS:=kmod-i2c-core
+endef
+
+define KernelPackage/i2c-mux/description
+ Kernel modules for I2C bus multiplexing support.
+endef
+
+$(eval $(call KernelPackage,i2c-mux))
+
+ifeq ($(strip $(call CompareKernelPatchVer,$(KERNEL_PATCHVER),ge,3.6.0)),1)
+I2C_MUX_GPIO_MODULES:= \
+ CONFIG_I2C_MUX_GPIO:drivers/i2c/muxes/i2c-mux-gpio
+else
+I2C_MUX_GPIO_MODULES:= \
+ CONFIG_I2C_MUX_GPIO:drivers/i2c/muxes/gpio-i2cmux
+endif
+
+define KernelPackage/i2c-mux-gpio
+ $(call i2c_defaults,$(I2C_MUX_GPIO_MODULES),51)
+ TITLE:=GPIO-based I2C mux/switches
+ DEPENDS:=kmod-i2c-mux
+endef
+
+define KernelPackage/i2c-mux-gpio/description
+ Kernel modules for GENERIC_GPIO I2C bus mux/switching devices.
+endef
+
+$(eval $(call KernelPackage,i2c-mux-gpio))
+
+ifeq ($(strip $(call CompareKernelPatchVer,$(KERNEL_PATCHVER),ge,3.6.0)),1)
+I2C_MUX_PREFIX:=i2c-mux-
+endif
+
+I2C_MUX_PCA954x_MODULES:= \
+ CONFIG_I2C_MUX_PCA954x:drivers/i2c/muxes/$(I2C_MUX_PREFIX)pca954x
+
+define KernelPackage/i2c-mux-pca954x
+ $(call i2c_defaults,$(I2C_MUX_PCA954x_MODULES),51)
+ TITLE:=Philips PCA954x I2C mux/switches
+ DEPENDS:=kmod-i2c-mux
+endef
+
+define KernelPackage/i2c-mux-pca954x/description
+ Kernel modules for PCA954x I2C bus mux/switching devices.
+endef
+
+$(eval $(call KernelPackage,i2c-mux-pca954x))
+## Support for pca954x seems to be in kernel since 2.6.36
+
+I2C_MUX_PCA9541_MODULES:= \
+ CONFIG_I2C_MUX_PCA9541:drivers/i2c/muxes/$(I2C_MUX_PREFIX)pca9541
+
+define KernelPackage/i2c-mux-pca9541
+ $(call i2c_defaults,$(I2C_MUX_PCA9541_MODULES),51)
+ TITLE:=Philips PCA9541 I2C mux/switches
+ DEPENDS:=kmod-i2c-mux
+endef
+
+define KernelPackage/i2c-mux-pca9541/description
+ Kernel modules for PCA9541 I2C bus mux/switching devices.
+endef
+
+$(eval $(call KernelPackage,i2c-mux-pca9541))
+
+GPIO_PCA953X_MODULES:= \
+ CONFIG_GPIO_PCA953X:drivers/gpio/gpio-pca953x
+
+define KernelPackage/pca953x
+ $(call i2c_defaults,$(GPIO_PCA953X_MODULES),51)
+ TITLE:=Philips PCA953x I2C GPIO extenders
+ DEPENDS:=kmod-i2c-core
+endef
+
+define KernelPackage/pca953x/description
+ Kernel modules for PCA953x I2C GPIO extenders.
+endef
+
+$(eval $(call KernelPackage,pca953x))
+
+GPIO_PCF857X_MODULES:= \
+ CONFIG_GPIO_PCF857X:drivers/gpio/gpio-pcf857x
+
+define KernelPackage/pcf857x
+ $(call i2c_defaults,$(GPIO_PCF857X_MODULES),51)
+ TITLE:=Philips PCF857x I2C GPIO extenders
+ DEPENDS:=kmod-i2c-core
+endef
+
+define KernelPackage/pcf857x/description
+ Kernel modules for PCF857x I2C GPIO extenders.
+endef
+
+$(eval $(call KernelPackage,pcf857x))
diff --git a/package/kernel/modules/.svn/text-base/input.mk.svn-base b/package/kernel/modules/.svn/text-base/input.mk.svn-base
new file mode 100644
index 0000000..d3c1b34
--- /dev/null
+++ b/package/kernel/modules/.svn/text-base/input.mk.svn-base
@@ -0,0 +1,192 @@
+#
+# Copyright (C) 2006-2013 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+INPUT_MODULES_MENU:=Input modules
+
+define KernelPackage/hid
+ SUBMENU:=$(INPUT_MODULES_MENU)
+ TITLE:=HID Devices
+ KCONFIG:=CONFIG_HID
+ FILES:=$(LINUX_DIR)/drivers/hid/hid.ko
+ AUTOLOAD:=$(call AutoLoad,61,hid)
+ $(call AddDepends/input,+kmod-input-evdev)
+endef
+
+define KernelPackage/hid/description
+ Kernel modules for HID devices
+endef
+
+$(eval $(call KernelPackage,hid))
+
+
+define KernelPackage/input-core
+ SUBMENU:=$(INPUT_MODULES_MENU)
+ TITLE:=Input device core
+ KCONFIG:=CONFIG_INPUT
+ FILES:=$(LINUX_DIR)/drivers/input/input-core.ko
+ AUTOLOAD:=$(call AutoLoad,19,input-core)
+endef
+
+define KernelPackage/input-core/description
+ Kernel modules for support of input device
+endef
+
+$(eval $(call KernelPackage,input-core))
+
+
+define KernelPackage/input-evdev
+ SUBMENU:=$(INPUT_MODULES_MENU)
+ TITLE:=Input event device
+ KCONFIG:=CONFIG_INPUT_EVDEV
+ FILES:=$(LINUX_DIR)/drivers/input/evdev.ko
+ AUTOLOAD:=$(call AutoLoad,60,evdev)
+ $(call AddDepends/input)
+endef
+
+define KernelPackage/input-evdev/description
+ Kernel modules for support of input device events
+endef
+
+$(eval $(call KernelPackage,input-evdev))
+
+
+define KernelPackage/input-gpio-buttons
+ SUBMENU:=$(INPUT_MODULES_MENU)
+ TITLE:=Polled GPIO buttons input device
+ DEPENDS:=@GPIO_SUPPORT +kmod-input-polldev
+ KCONFIG:= \
+ CONFIG_INPUT_GPIO_BUTTONS \
+ CONFIG_INPUT_MISC=y
+ FILES:=$(LINUX_DIR)/drivers/input/misc/gpio_buttons.ko
+ AUTOLOAD:=$(call AutoLoad,62,gpio_buttons)
+endef
+
+define KernelPackage/input-gpio-buttons/description
+ Kernel module for support polled GPIO buttons input device
+endef
+
+$(eval $(call KernelPackage,input-gpio-buttons))
+
+
+define KernelPackage/input-gpio-keys
+ SUBMENU:=$(INPUT_MODULES_MENU)
+ TITLE:=GPIO key support
+ DEPENDS:= @GPIO_SUPPORT
+ KCONFIG:= \
+ CONFIG_KEYBOARD_GPIO \
+ CONFIG_INPUT_KEYBOARD=y
+ FILES:=$(LINUX_DIR)/drivers/input/keyboard/gpio_keys.ko
+ AUTOLOAD:=$(call AutoLoad,60,gpio_keys)
+ $(call AddDepends/input)
+endef
+
+define KernelPackage/input-gpio-keys/description
+ This driver implements support for buttons connected
+ to GPIO pins of various CPUs (and some other chips).
+endef
+
+$(eval $(call KernelPackage,input-gpio-keys))
+
+
+define KernelPackage/input-gpio-keys-polled
+ SUBMENU:=$(INPUT_MODULES_MENU)
+ TITLE:=Polled GPIO key support
+ DEPENDS:=@GPIO_SUPPORT +kmod-input-polldev
+ KCONFIG:= \
+ CONFIG_KEYBOARD_GPIO_POLLED \
+ CONFIG_INPUT_KEYBOARD=y
+ FILES:=$(LINUX_DIR)/drivers/input/keyboard/gpio_keys_polled.ko
+ AUTOLOAD:=$(call AutoLoad,62,gpio_keys_polled)
+ $(call AddDepends/input)
+endef
+
+define KernelPackage/input-gpio-keys-polled/description
+ Kernel module for support polled GPIO keys input device
+endef
+
+$(eval $(call KernelPackage,input-gpio-keys-polled))
+
+
+define KernelPackage/input-gpio-encoder
+ SUBMENU:=$(INPUT_MODULES_MENU)
+ TITLE:=GPIO rotay encoder
+ KCONFIG:=CONFIG_INPUT_GPIO_ROTARY_ENCODER
+ FILES:=$(LINUX_DIR)/drivers/input/misc/rotary_encoder.ko
+ AUTOLOAD:=$(call AutoLoad,62,rotary_encoder)
+ $(call AddDepends/input,@GPIO_SUPPORT)
+endef
+
+define KernelPackage/gpio-encoder/description
+ Kernel module to use rotary encoders connected to GPIO pins
+endef
+
+$(eval $(call KernelPackage,input-gpio-encoder))
+
+
+define KernelPackage/input-joydev
+ SUBMENU:=$(INPUT_MODULES_MENU)
+ TITLE:=Joystick device support
+ KCONFIG:=CONFIG_INPUT_JOYDEV
+ FILES:=$(LINUX_DIR)/drivers/input/joydev.ko
+ AUTOLOAD:=$(call AutoLoad,62,joydev)
+ $(call AddDepends/input)
+endef
+
+define KernelPackage/input-joydev/description
+ Kernel module for joystick support
+endef
+
+$(eval $(call KernelPackage,input-joydev))
+
+
+define KernelPackage/input-polldev
+ SUBMENU:=$(INPUT_MODULES_MENU)
+ TITLE:=Polled Input device support
+ KCONFIG:=CONFIG_INPUT_POLLDEV
+ FILES:=$(LINUX_DIR)/drivers/input/input-polldev.ko
+ AUTOLOAD:=$(call AutoLoad,20,input-polldev)
+ $(call AddDepends/input)
+endef
+
+define KernelPackage/input-polldev/description
+ Kernel module for support of polled input devices
+endef
+
+$(eval $(call KernelPackage,input-polldev))
+
+
+define KernelPackage/input-matrixkmap
+ SUBMENU:=$(INPUT_MODULES_MENU)
+ TITLE:=Input matrix devices support
+ KCONFIG:=CONFIG_INPUT_MATRIXKMAP
+ DEPENDS:=@!LINUX_3_3
+ FILES:=$(LINUX_DIR)/drivers/input/matrix-keymap.ko
+ AUTOLOAD:=$(call AutoLoad,20,matrix-keymap)
+ $(call AddDepends/input)
+endef
+
+define KernelPackage/input-matrix/description
+ Kernel module support for input matrix devices
+endef
+
+$(eval $(call KernelPackage,input-matrixkmap))
+
+
+define KernelPackage/acpi-button
+ SUBMENU:=$(INPUT_MODULES_MENU)
+ TITLE:=ACPI Button Support
+ DEPENDS:=@(TARGET_x86_generic||TARGET_x86_kvm_guest||TARGET_x86_xen_domu) +kmod-input-evdev
+ KCONFIG:=CONFIG_ACPI_BUTTON
+ FILES:=$(LINUX_DIR)/drivers/acpi/button.ko
+ AUTOLOAD:=$(call AutoLoad,06,button)
+endef
+
+define KernelPackage/acpi-button/description
+ Kernel module for ACPI Button support
+endef
+
+$(eval $(call KernelPackage,acpi-button))
diff --git a/package/kernel/modules/.svn/text-base/leds.mk.svn-base b/package/kernel/modules/.svn/text-base/leds.mk.svn-base
new file mode 100644
index 0000000..b2402c9
--- /dev/null
+++ b/package/kernel/modules/.svn/text-base/leds.mk.svn-base
@@ -0,0 +1,169 @@
+#
+# Copyright (C) 2006-2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+LEDS_MENU:=LED modules
+
+
+define KernelPackage/leds-gpio
+ SUBMENU:=$(LEDS_MENU)
+ TITLE:=GPIO LED support
+ DEPENDS:= @GPIO_SUPPORT
+ KCONFIG:=CONFIG_LEDS_GPIO
+ FILES:=$(LINUX_DIR)/drivers/leds/leds-gpio.ko
+ AUTOLOAD:=$(call AutoLoad,60,leds-gpio)
+endef
+
+define KernelPackage/leds-gpio/description
+ Kernel module for LEDs on GPIO lines
+endef
+
+$(eval $(call KernelPackage,leds-gpio))
+
+
+define KernelPackage/ledtrig-heartbeat
+ SUBMENU:=$(LEDS_MENU)
+ TITLE:=LED Heartbeat Trigger
+ KCONFIG:=CONFIG_LEDS_TRIGGER_HEARTBEAT
+ FILES:=$(LINUX_DIR)/drivers/leds/ledtrig-heartbeat.ko
+ AUTOLOAD:=$(call AutoLoad,50,ledtrig-heartbeat)
+endef
+
+define KernelPackage/ledtrig-gpio/description
+ Kernel module that allows LEDs to blink like heart beat
+endef
+
+$(eval $(call KernelPackage,ledtrig-heartbeat))
+
+
+define KernelPackage/ledtrig-gpio
+ SUBMENU:=$(LEDS_MENU)
+ TITLE:=LED GPIO Trigger
+ KCONFIG:=CONFIG_LEDS_TRIGGER_GPIO
+ FILES:=$(LINUX_DIR)/drivers/leds/ledtrig-gpio.ko
+ AUTOLOAD:=$(call AutoLoad,50,ledtrig-gpio)
+endef
+
+define KernelPackage/ledtrig-gpio/description
+ Kernel module that allows LEDs to be controlled by gpio events.
+endef
+
+$(eval $(call KernelPackage,ledtrig-gpio))
+
+
+define KernelPackage/ledtrig-morse
+ SUBMENU:=$(LEDS_MENU)
+ TITLE:=LED Morse Trigger
+ KCONFIG:=CONFIG_LEDS_TRIGGER_MORSE
+ FILES:=$(LINUX_DIR)/drivers/leds/ledtrig-morse.ko
+ AUTOLOAD:=$(call AutoLoad,50,ledtrig-morse)
+endef
+
+define KernelPackage/ledtrig-morse/description
+ Kernel module to show morse coded messages on LEDs.
+endef
+
+$(eval $(call KernelPackage,ledtrig-morse))
+
+
+define KernelPackage/ledtrig-netdev
+ SUBMENU:=$(LEDS_MENU)
+ TITLE:=LED NETDEV Trigger
+ KCONFIG:=CONFIG_LEDS_TRIGGER_NETDEV
+ FILES:=$(LINUX_DIR)/drivers/leds/ledtrig-netdev.ko
+ AUTOLOAD:=$(call AutoLoad,50,ledtrig-netdev)
+endef
+
+define KernelPackage/ledtrig-netdev/description
+ Kernel module to drive LEDs based on network activity.
+endef
+
+$(eval $(call KernelPackage,ledtrig-netdev))
+
+
+define KernelPackage/ledtrig-netfilter
+ SUBMENU:=$(LEDS_MENU)
+ TITLE:=LED NetFilter Trigger
+ DEPENDS:=kmod-ipt-core
+ KCONFIG:=CONFIG_NETFILTER_XT_TARGET_LED
+ FILES:=$(LINUX_DIR)/net/netfilter/xt_LED.ko
+ AUTOLOAD:=$(call AutoLoad,50,xt_LED)
+endef
+
+define KernelPackage/ledtrig-netfilter/description
+ Kernel module to flash LED when a particular packets passing through your machine.
+
+ For example to create an LED trigger for incoming SSH traffic:
+ iptables -A INPUT -p tcp --dport 22 -j LED --led-trigger-id ssh --led-delay 1000
+ Then attach the new trigger to an LED on your system:
+ echo netfilter-ssh > /sys/class/leds/<ledname>/trigger
+endef
+
+$(eval $(call KernelPackage,ledtrig-netfilter))
+
+
+define KernelPackage/ledtrig-usbdev
+ SUBMENU:=$(LEDS_MENU)
+ TITLE:=LED USB device Trigger
+ DEPENDS:=@USB_SUPPORT kmod-usb-core
+ KCONFIG:=CONFIG_LEDS_TRIGGER_USBDEV
+ FILES:=$(LINUX_DIR)/drivers/leds/ledtrig-usbdev.ko
+ AUTOLOAD:=$(call AutoLoad,50,ledtrig-usbdev)
+endef
+
+define KernelPackage/ledtrig-usbdev/description
+ Kernel module to drive LEDs based on USB device presence/activity.
+endef
+
+$(eval $(call KernelPackage,ledtrig-usbdev))
+
+
+define KernelPackage/ledtrig-default-on
+ SUBMENU:=$(LEDS_MENU)
+ TITLE:=LED Default ON Trigger
+ KCONFIG:=CONFIG_LEDS_TRIGGER_DEFAULT_ON
+ FILES:=$(LINUX_DIR)/drivers/leds/ledtrig-default-on.ko
+ AUTOLOAD:=$(call AutoLoad,50,ledtrig-default-on)
+endef
+
+define KernelPackage/ledtrig-default-on/description
+ Kernel module that allows LEDs to be initialised in the ON state.
+endef
+
+$(eval $(call KernelPackage,ledtrig-default-on))
+
+
+define KernelPackage/ledtrig-timer
+ SUBMENU:=$(LEDS_MENU)
+ TITLE:=LED Timer Trigger
+ KCONFIG:=CONFIG_LEDS_TRIGGER_TIMER
+ FILES:=$(LINUX_DIR)/drivers/leds/ledtrig-timer.ko
+ AUTOLOAD:=$(call AutoLoad,50,ledtrig-timer)
+endef
+
+define KernelPackage/ledtrig-timer/description
+ Kernel module that allows LEDs to be controlled by a programmable timer
+ via sysfs.
+endef
+
+$(eval $(call KernelPackage,ledtrig-timer))
+
+
+define KernelPackage/ledtrig-oneshot
+ SUBMENU:=$(LEDS_MENU)
+ TITLE:=LED One-Shot Trigger
+ DEPENDS:=@!LINUX_3_3
+ KCONFIG:=CONFIG_LEDS_TRIGGER_ONESHOT
+ FILES:=$(LINUX_DIR)/drivers/leds/ledtrig-oneshot.ko
+ AUTOLOAD:=$(call AutoLoad,50,ledtrig-oneshot)
+endef
+
+define KernelPackage/ledtrig-oneshot/description
+ Kernel module that allows LEDs to be triggered by sporadic events in
+ one-shot pulses.
+endef
+
+$(eval $(call KernelPackage,ledtrig-oneshot))
diff --git a/package/kernel/modules/.svn/text-base/lib.mk.svn-base b/package/kernel/modules/.svn/text-base/lib.mk.svn-base
new file mode 100644
index 0000000..0411e93
--- /dev/null
+++ b/package/kernel/modules/.svn/text-base/lib.mk.svn-base
@@ -0,0 +1,165 @@
+#
+# Copyright (C) 2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+LIB_MENU:=Libraries
+
+define KernelPackage/lib-crc-ccitt
+ SUBMENU:=$(LIB_MENU)
+ TITLE:=CRC-CCITT support
+ KCONFIG:=CONFIG_CRC_CCITT
+ FILES:=$(LINUX_DIR)/lib/crc-ccitt.ko
+ AUTOLOAD:=$(call AutoLoad,20,crc-ccitt)
+endef
+
+define KernelPackage/lib-crc-ccitt/description
+ Kernel module for CRC-CCITT support
+endef
+
+$(eval $(call KernelPackage,lib-crc-ccitt))
+
+
+define KernelPackage/lib-crc-itu-t
+ SUBMENU:=$(LIB_MENU)
+ TITLE:=CRC ITU-T V.41 support
+ KCONFIG:=CONFIG_CRC_ITU_T
+ FILES:=$(LINUX_DIR)/lib/crc-itu-t.ko
+ AUTOLOAD:=$(call AutoLoad,20,crc-itu-t)
+endef
+
+define KernelPackage/lib-crc-itu-t/description
+ Kernel module for CRC ITU-T V.41 support
+endef
+
+$(eval $(call KernelPackage,lib-crc-itu-t))
+
+
+define KernelPackage/lib-crc7
+ SUBMENU:=$(LIB_MENU)
+ TITLE:=CRC7 support
+ KCONFIG:=CONFIG_CRC7
+ FILES:=$(LINUX_DIR)/lib/crc7.ko
+ AUTOLOAD:=$(call AutoLoad,20,crc7)
+endef
+
+define KernelPackage/lib-crc7/description
+ Kernel module for CRC7 support
+endef
+
+$(eval $(call KernelPackage,lib-crc7))
+
+
+define KernelPackage/lib-crc8
+ SUBMENU:=$(LIB_MENU)
+ TITLE:=CRC8 support
+ KCONFIG:=CONFIG_CRC8
+ FILES:=$(LINUX_DIR)/lib/crc8.ko
+ AUTOLOAD:=$(call AutoLoad,20,crc8)
+endef
+
+define KernelPackage/lib-crc8/description
+ Kernel module for CRC8 support
+endef
+
+$(eval $(call KernelPackage,lib-crc8))
+
+
+define KernelPackage/lib-crc16
+ SUBMENU:=$(LIB_MENU)
+ TITLE:=CRC16 support
+ KCONFIG:=CONFIG_CRC16
+ FILES:=$(LINUX_DIR)/lib/crc16.ko
+ AUTOLOAD:=$(call AutoLoad,20,crc16,1)
+endef
+
+define KernelPackage/lib-crc16/description
+ Kernel module for CRC16 support
+endef
+
+$(eval $(call KernelPackage,lib-crc16))
+
+
+define KernelPackage/lib-crc32c
+ SUBMENU:=$(LIB_MENU)
+ TITLE:=CRC32 support
+ KCONFIG:=CONFIG_LIBCRC32C
+ DEPENDS:=+kmod-crypto-crc32c
+ FILES:=$(LINUX_DIR)/lib/libcrc32c.ko
+ AUTOLOAD:=$(call AutoLoad,20,libcrc32c,1)
+endef
+
+define KernelPackage/lib-crc32c/description
+ Kernel module for CRC32 support
+endef
+
+$(eval $(call KernelPackage,lib-crc32c))
+
+
+define KernelPackage/lib-lzo
+ SUBMENU:=$(LIB_MENU)
+ TITLE:=LZO support
+ KCONFIG:= \
+ CONFIG_LZO_COMPRESS \
+ CONFIG_LZO_DECOMPRESS
+ FILES:= \
+ $(LINUX_DIR)/lib/lzo/lzo_compress.ko \
+ $(LINUX_DIR)/lib/lzo/lzo_decompress.ko
+ AUTOLOAD:=$(call AutoLoad,20, lzo_compress lzo_decompress,1)
+endef
+
+define KernelPackage/lib-lzo/description
+ Kernel module for LZO compression/decompression support
+endef
+
+$(eval $(call KernelPackage,lib-lzo))
+
+
+define KernelPackage/lib-textsearch
+SUBMENU:=$(LIB_MENU)
+ TITLE:=Textsearch support
+ KCONFIG:= \
+ CONFIG_TEXTSEARCH=y \
+ CONFIG_TEXTSEARCH_KMP \
+ CONFIG_TEXTSEARCH_BM \
+ CONFIG_TEXTSEARCH_FSM
+ FILES:= \
+ $(LINUX_DIR)/lib/ts_kmp.ko \
+ $(LINUX_DIR)/lib/ts_bm.ko \
+ $(LINUX_DIR)/lib/ts_fsm.ko
+ AUTOLOAD:=$(call AutoLoad,20,ts_kmp ts_bm ts_fsm)
+endef
+
+$(eval $(call KernelPackage,lib-textsearch))
+
+
+define KernelPackage/lib-zlib
+ SUBMENU:=$(LIB_MENU)
+ TITLE:=Zlib support
+ KCONFIG:= \
+ CONFIG_ZLIB_DEFLATE \
+ CONFIG_ZLIB_INFLATE
+ FILES:= \
+ $(LINUX_DIR)/lib/zlib_deflate/zlib_deflate.ko \
+ $(LINUX_DIR)/lib/zlib_inflate/zlib_inflate.ko
+ AUTOLOAD:=$(call AutoLoad,08,zlib_deflate zlib_inflate,1)
+endef
+
+$(eval $(call KernelPackage,lib-zlib))
+
+
+define KernelPackage/lib-cordic
+ SUBMENU:=$(LIB_MENU)
+ TITLE:=Cordic function support
+ KCONFIG:=CONFIG_CORDIC
+ FILES:=$(LINUX_DIR)/lib/cordic.ko
+ AUTOLOAD:=$(call AutoLoad,20,cordic)
+endef
+
+define KernelPackage/lib-cordic/description
+ Kernel module for Cordic function support
+endef
+
+$(eval $(call KernelPackage,lib-cordic))
diff --git a/package/kernel/modules/.svn/text-base/netdevices.mk.svn-base b/package/kernel/modules/.svn/text-base/netdevices.mk.svn-base
new file mode 100644
index 0000000..07508ff
--- /dev/null
+++ b/package/kernel/modules/.svn/text-base/netdevices.mk.svn-base
@@ -0,0 +1,726 @@
+#
+# Copyright (C) 2006-2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+NETWORK_DEVICES_MENU:=Network Devices
+
+define KernelPackage/sis190
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=SiS 190 Fast/Gigabit Ethernet support
+ DEPENDS:=@PCI_SUPPORT
+ KCONFIG:=CONFIG_SIS190
+ FILES:=$(LINUX_DIR)/drivers/net/ethernet/sis/sis190.ko
+ AUTOLOAD:=$(call AutoLoad,50,sis190)
+endef
+
+$(eval $(call KernelPackage,sis190))
+
+define KernelPackage/skge
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=SysKonnect Yukon support
+ DEPENDS:=@PCI_SUPPORT
+ KCONFIG:=CONFIG_SKGE \
+ CONFIG_SKGE_DEBUG=n \
+ CONFIG_SKGE_GENESIS=n
+ FILES:=$(LINUX_DIR)/drivers/net/ethernet/marvell/skge.ko
+ AUTOLOAD:=$(call AutoLoad,50,skge)
+endef
+
+$(eval $(call KernelPackage,skge))
+
+define KernelPackage/atl2
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=Atheros L2 Fast Ethernet support
+ DEPENDS:=@PCI_SUPPORT
+ KCONFIG:=CONFIG_ATL2
+ FILES:=$(LINUX_DIR)/drivers/net/ethernet/atheros/atlx/atl2.ko
+ AUTOLOAD:=$(call AutoLoad,50,atl2)
+endef
+
+$(eval $(call KernelPackage,atl2))
+
+define KernelPackage/atl1
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=Atheros L1 Gigabit Ethernet support
+ DEPENDS:=@PCI_SUPPORT
+ KCONFIG:=CONFIG_ATL1
+ FILES:=$(LINUX_DIR)/drivers/net/ethernet/atheros/atlx/atl1.ko
+ AUTOLOAD:=$(call AutoLoad,50,atl1)
+endef
+
+$(eval $(call KernelPackage,atl1))
+
+define KernelPackage/atl1c
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=Atheros L1C
+ DEPENDS:=@PCI_SUPPORT
+ KCONFIG:=CONFIG_ATL1C
+ FILES:=$(LINUX_DIR)/drivers/net/ethernet/atheros/atl1c/atl1c.ko
+ AUTOLOAD:=$(call AutoLoad,50,atl1c)
+endef
+
+$(eval $(call KernelPackage,atl1c))
+
+define KernelPackage/atl1e
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=Atheros L1E
+ DEPENDS:=@PCI_SUPPORT
+ KCONFIG:=CONFIG_ATL1E
+ FILES:=$(LINUX_DIR)/drivers/net/ethernet/atheros/atl1e/atl1e.ko
+ AUTOLOAD:=$(call AutoLoad,50,atl1e)
+endef
+
+$(eval $(call KernelPackage,atl1e))
+
+define KernelPackage/libphy
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=PHY library
+ KCONFIG:=CONFIG_PHYLIB
+ FILES:=$(LINUX_DIR)/drivers/net/phy/libphy.ko
+ AUTOLOAD:=$(call AutoLoad,40,libphy)
+endef
+
+define KernelPackage/libphy/description
+ PHY library
+endef
+
+$(eval $(call KernelPackage,libphy))
+
+define KernelPackage/et131x
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=Agere ET131x Gigabit Ethernet driver
+ URL:=http://sourceforge.net/projects/et131x
+ FILES:=$(LINUX_DIR)/drivers/staging/et131x/et131x.$(LINUX_KMOD_SUFFIX)
+ KCONFIG:= \
+ CONFIG_ET131X \
+ CONFIG_ET131X_DEBUG=n
+ DEPENDS:=@PCI_SUPPORT
+ AUTOLOAD:=$(call AutoLoad,70,et131x)
+endef
+
+define KernelPackage/et131x/description
+ This package contains the et131x kernel module.
+endef
+
+$(eval $(call KernelPackage,et131x))
+
+define KernelPackage/swconfig
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=switch configuration API
+ DEPENDS:=+kmod-libphy
+ KCONFIG:=CONFIG_SWCONFIG
+ FILES:=$(LINUX_DIR)/drivers/net/phy/swconfig.ko
+ AUTOLOAD:=$(call AutoLoad,41,swconfig)
+endef
+
+define KernelPackage/swconfig/description
+ Switch configuration API module
+endef
+
+$(eval $(call KernelPackage,swconfig))
+
+define KernelPackage/switch-ip17xx
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=IC+ IP17XX switch support
+ DEPENDS:=+kmod-swconfig
+ KCONFIG:=CONFIG_IP17XX_PHY
+ FILES:=$(LINUX_DIR)/drivers/net/phy/ip17xx.ko
+ AUTOLOAD:=$(call AutoLoad,42,ip17xx)
+endef
+
+define KernelPackage/switch-ip17xx/description
+ IC+ IP175C/IP178C switch support
+endef
+
+$(eval $(call KernelPackage,switch-ip17xx))
+
+define KernelPackage/switch-rtl8366-smi
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=Realtek RTL8366 SMI switch interface support
+ DEPENDS:=@GPIO_SUPPORT +kmod-swconfig
+ KCONFIG:=CONFIG_RTL8366_SMI
+ FILES:=$(LINUX_DIR)/drivers/net/phy/rtl8366_smi.ko
+ AUTOLOAD:=$(call AutoLoad,42,rtl8366_smi)
+endef
+
+define KernelPackage/switch-rtl8366_smi/description
+ Realtek RTL8366 series SMI switch interface support
+endef
+
+$(eval $(call KernelPackage,switch-rtl8366-smi))
+
+define KernelPackage/switch-rtl8366rb
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=Realtek RTL8366RB switch support
+ DEPENDS:=+kmod-switch-rtl8366-smi
+ KCONFIG:=CONFIG_RTL8366RB_PHY
+ FILES:=$(LINUX_DIR)/drivers/net/phy/rtl8366rb.ko
+ AUTOLOAD:=$(call AutoLoad,43,rtl8366rb)
+endef
+
+define KernelPackage/switch-rtl8366rb/description
+ Realtek RTL8366RB switch support
+endef
+
+$(eval $(call KernelPackage,switch-rtl8366rb))
+
+define KernelPackage/switch-rtl8366s
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=Realtek RTL8366S switch support
+ DEPENDS:=+kmod-switch-rtl8366-smi
+ KCONFIG:=CONFIG_RTL8366S_PHY
+ FILES:=$(LINUX_DIR)/drivers/net/phy/rtl8366s.ko
+ AUTOLOAD:=$(call AutoLoad,43,rtl8366s)
+endef
+
+define KernelPackage/switch-rtl8366s/description
+ Realtek RTL8366S switch support
+endef
+
+$(eval $(call KernelPackage,switch-rtl8366s))
+
+define KernelPackage/natsemi
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=National Semiconductor DP8381x series
+ DEPENDS:=@PCI_SUPPORT
+ KCONFIG:=CONFIG_NATSEMI
+ FILES:=$(LINUX_DIR)/drivers/net/ethernet/natsemi/natsemi.ko
+ AUTOLOAD:=$(call AutoLoad,20,natsemi)
+endef
+
+define KernelPackage/natsemi/description
+ Kernel modules for National Semiconductor DP8381x series PCI Ethernet
+ adapters.
+endef
+
+$(eval $(call KernelPackage,natsemi))
+
+
+define KernelPackage/r6040
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=RDC Fast-Ethernet support
+ DEPENDS:=@PCI_SUPPORT +kmod-libphy
+ KCONFIG:=CONFIG_R6040 \
+ CONFIG_R6040_NAPI=y
+ FILES:=$(LINUX_DIR)/drivers/net/ethernet/rdc/r6040.ko
+ AUTOLOAD:=$(call AutoLoad,99,r6040)
+endef
+
+define KernelPackage/r6040/description
+ Kernel modules for RDC Fast-Ethernet adapters.
+endef
+
+$(eval $(call KernelPackage,r6040))
+
+
+define KernelPackage/sis900
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=SiS 900 Ethernet support
+ DEPENDS:=@PCI_SUPPORT
+ KCONFIG:=CONFIG_SIS900
+ FILES:=$(LINUX_DIR)/drivers/net/ethernet/sis/sis900.ko
+ AUTOLOAD:=$(call AutoLoad,50,sis900)
+endef
+
+define KernelPackage/sis900/description
+ Kernel modules for Sis 900 Ethernet adapters.
+endef
+
+$(eval $(call KernelPackage,sis900))
+
+
+define KernelPackage/sky2
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=SysKonnect Yukon2 support
+ DEPENDS:=@PCI_SUPPORT
+ KCONFIG:=CONFIG_SKY2
+ FILES:=$(LINUX_DIR)/drivers/net/ethernet/marvell/sky2.ko
+ AUTOLOAD:=$(call AutoLoad,50,sky2)
+endef
+
+define KernelPackage/sky2/description
+ This driver supports Gigabit Ethernet adapters based on the
+ Marvell Yukon 2 chipset:
+ Marvell 88E8021/88E8022/88E8035/88E8036/88E8038/88E8050/88E8052/
+ 88E8053/88E8055/88E8061/88E8062, SysKonnect SK-9E21D/SK-9S21
+
+ There is companion driver for the older Marvell Yukon and
+ Genesis based adapters: skge.
+endef
+
+$(eval $(call KernelPackage,sky2))
+
+
+define KernelPackage/via-rhine
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=Via Rhine ethernet support
+ DEPENDS:=@PCI_SUPPORT
+ KCONFIG:=CONFIG_VIA_RHINE \
+ CONFIG_VIA_RHINE_MMIO=y
+ FILES:=$(LINUX_DIR)/drivers/net/ethernet/via/via-rhine.ko
+ AUTOLOAD:=$(call AutoLoad,50,via-rhine)
+endef
+
+define KernelPackage/via-rhine/description
+ Kernel modules for Via Rhine Ethernet chipsets.
+endef
+
+$(eval $(call KernelPackage,via-rhine))
+
+
+define KernelPackage/via-velocity
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=VIA Velocity Gigabit Ethernet Adapter kernel support
+ DEPENDS:=@TARGET_ixp4xx||TARGET_mpc83xx||PCI_SUPPORT +kmod-lib-crc-ccitt
+ KCONFIG:=CONFIG_VIA_VELOCITY
+ FILES:=$(LINUX_DIR)/drivers/net/ethernet/via/via-velocity.ko
+ AUTOLOAD:=$(call AutoLoad,50,via-velocity)
+endef
+
+define KernelPackage/via-velocity/description
+ Kernel modules for VIA Velocity Gigabit Ethernet chipsets.
+endef
+
+$(eval $(call KernelPackage,via-velocity))
+
+
+define KernelPackage/8139too
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=RealTek RTL-8139 PCI Fast Ethernet Adapter kernel support
+ DEPENDS:=@PCI_SUPPORT
+ KCONFIG:=CONFIG_8139TOO \
+ CONFIG_8139TOO_PIO=y \
+ CONFIG_8139TOO_TUNE_TWISTER=n \
+ CONFIG_8139TOO_8129=n \
+ CONFIG_8139_OLD_RX_RESET=n
+ FILES:=$(LINUX_DIR)/drivers/net/ethernet/realtek/8139too.ko
+ AUTOLOAD:=$(call AutoLoad,50,8139too)
+endef
+
+define KernelPackage/8139too/description
+ Kernel modules for RealTek RTL-8139 PCI Fast Ethernet adapters.
+endef
+
+$(eval $(call KernelPackage,8139too))
+
+
+define KernelPackage/8139cp
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=RealTek RTL-8139C+ PCI Fast Ethernet Adapter kernel support
+ DEPENDS:=@PCI_SUPPORT
+ KCONFIG:=CONFIG_8139CP
+ FILES:=$(LINUX_DIR)/drivers/net/ethernet/realtek/8139cp.ko
+ AUTOLOAD:=$(call AutoLoad,50,8139cp)
+endef
+
+define KernelPackage/8139cp/description
+ Kernel module for RealTek RTL-8139C+ PCI Fast Ethernet adapters.
+endef
+
+$(eval $(call KernelPackage,8139cp))
+
+
+define KernelPackage/r8169
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=RealTek RTL-8169 PCI Gigabit Ethernet Adapter kernel support
+ DEPENDS:=@PCI_SUPPORT
+ KCONFIG:=CONFIG_R8169 \
+ CONFIG_R8169_NAPI=y \
+ CONFIG_R8169_VLAN=n
+ FILES:=$(LINUX_DIR)/drivers/net/ethernet/realtek/r8169.ko
+ AUTOLOAD:=$(call AutoLoad,50,r8169)
+endef
+
+define KernelPackage/r8169/description
+ Kernel modules for RealTek RTL-8169 PCI Gigabit Ethernet adapters.
+endef
+
+$(eval $(call KernelPackage,r8169))
+
+
+define KernelPackage/ne2k-pci
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=ne2k-pci Ethernet Adapter kernel support
+ DEPENDS:=@PCI_SUPPORT
+ KCONFIG:=CONFIG_NE2K_PCI
+ FILES:= \
+ $(LINUX_DIR)/drivers/net/ethernet/8390/ne2k-pci.ko \
+ $(LINUX_DIR)/drivers/net/ethernet/8390/8390.ko
+ AUTOLOAD:=$(call AutoLoad,50,8390 ne2k-pci)
+endef
+
+define KernelPackage/ne2k-pci/description
+ Kernel modules for NE2000 PCI Ethernet Adapter kernel.
+endef
+
+$(eval $(call KernelPackage,ne2k-pci))
+
+
+define KernelPackage/e100
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=Intel(R) PRO/100+ cards kernel support
+ DEPENDS:=@PCI_SUPPORT
+ KCONFIG:=CONFIG_E100
+ FILES:=$(LINUX_DIR)/drivers/net/ethernet/intel/e100.ko
+ AUTOLOAD:=$(call AutoLoad,50,e100)
+endef
+
+define KernelPackage/e100/description
+ Kernel modules for Intel(R) PRO/100+ Ethernet adapters.
+endef
+
+define KernelPackage/e100/install
+ $(INSTALL_DIR) $(1)/lib/firmware/e100
+ $(foreach file,d101m_ucode.bin d101s_ucode.bin d102e_ucode.bin, \
+ $(TARGET_CROSS)objcopy -Iihex -Obinary $(LINUX_DIR)/firmware/e100/$(file).ihex $(1)/lib/firmware/e100/$(file); \
+ )
+endef
+
+$(eval $(call KernelPackage,e100))
+
+
+define KernelPackage/e1000
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=Intel(R) PRO/1000 PCI cards kernel support
+ DEPENDS:=@PCI_SUPPORT
+ KCONFIG:=CONFIG_E1000 \
+ CONFIG_E1000_DISABLE_PACKET_SPLIT=n \
+ CONFIG_E1000_NAPI=y
+ FILES:=$(LINUX_DIR)/drivers/net/ethernet/intel/e1000/e1000.ko
+ AUTOLOAD:=$(call AutoLoad,35,e1000)
+endef
+
+define KernelPackage/e1000/description
+ Kernel modules for Intel(R) PRO/1000 PCI Ethernet adapters.
+endef
+
+$(eval $(call KernelPackage,e1000))
+
+
+define KernelPackage/e1000e
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=Intel(R) PRO/1000 PCIe cards kernel support
+ DEPENDS:=@PCIE_SUPPORT
+ KCONFIG:=CONFIG_E1000E
+ FILES:=$(LINUX_DIR)/drivers/net/ethernet/intel/e1000e/e1000e.ko
+ AUTOLOAD:=$(call AutoLoad,50,e1000e)
+endef
+
+define KernelPackage/e1000e/description
+ Kernel modules for Intel(R) PRO/1000 PCIe Ethernet adapters.
+endef
+
+$(eval $(call KernelPackage,e1000e))
+
+
+define KernelPackage/b44
+ TITLE:=Broadcom 44xx driver
+ KCONFIG:=CONFIG_B44
+ DEPENDS:=@PCI_SUPPORT +!TARGET_brcm47xx:kmod-ssb
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ FILES:=$(LINUX_DIR)/drivers/net/ethernet/broadcom/b44.ko
+ AUTOLOAD:=$(call AutoLoad,50,b44)
+endef
+
+define KernelPackage/b44/description
+ Kernel modules for Broadcom 44xx Ethernet adapters.
+endef
+
+$(eval $(call KernelPackage,b44))
+
+
+define KernelPackage/3c59x
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=3Com 3c590/3c900 series (592/595/597) Vortex/Boomerang
+ DEPENDS:=@PCI_SUPPORT
+ KCONFIG:=CONFIG_VORTEX
+ FILES:=$(LINUX_DIR)/drivers/net/ethernet/3com/3c59x.ko
+ AUTOLOAD:=$(call AutoLoad,50,3c59x)
+endef
+
+define KernelPackage/3c59x/description
+ This option enables driver support for a large number of 10mbps and
+ 10/100mbps EISA, PCI and PCMCIA 3Com Ethernet adapters:
+ - "Vortex" (Fast EtherLink 3c590/3c592/3c595/3c597) EISA and PCI
+ - "Boomerang" (EtherLink XL 3c900 or 3c905) PCI
+ - "Cyclone" (3c540/3c900/3c905/3c980/3c575/3c656) PCI and Cardbus
+ - "Tornado" (3c905) PCI
+ - "Hurricane" (3c555/3cSOHO) PCI
+endef
+
+$(eval $(call KernelPackage,3c59x))
+
+
+define KernelPackage/pcnet32
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=AMD PCnet32 PCI support
+ DEPENDS:=@(PCI_SUPPORT||TARGET_malta)
+ KCONFIG:=CONFIG_PCNET32
+ FILES:=$(LINUX_DIR)/drivers/net/ethernet/amd/pcnet32.ko
+ AUTOLOAD:=$(call AutoLoad,50,pcnet32)
+endef
+
+define KernelPackage/pcnet32/description
+ Kernel modules for AMD PCnet32 Ethernet adapters.
+endef
+
+$(eval $(call KernelPackage,pcnet32))
+
+
+define KernelPackage/tg3
+ TITLE:=Broadcom Tigon3 Gigabit Ethernet
+ KCONFIG:=CONFIG_TIGON3
+ DEPENDS:=+!TARGET_brcm47xx:kmod-libphy +!LINUX_3_3:kmod-hwmon-core +LINUX_3_8:kmod-ptp
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ FILES:=$(LINUX_DIR)/drivers/net/ethernet/broadcom/tg3.ko
+ AUTOLOAD:=$(call AutoLoad,50,tg3)
+endef
+
+define KernelPackage/tg3/description
+ Kernel modules for Broadcom Tigon3 Gigabit Ethernet adapters.
+endef
+
+$(eval $(call KernelPackage,tg3))
+
+
+define KernelPackage/hfcpci
+ TITLE:=HFC PCI cards (single port) support for mISDN
+ KCONFIG:=CONFIG_MISDN_HFCPCI
+ DEPENDS:=+kmod-misdn
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ FILES:=$(LINUX_DIR)/drivers/isdn/hardware/mISDN/hfcpci.ko
+ AUTOLOAD:=$(call AutoLoad,31,hfcpci)
+endef
+
+define KernelPackage/hfcpci/description
+ Kernel modules for Cologne AG's HFC pci cards (single port)
+ using the mISDN V2 stack.
+endef
+
+$(eval $(call KernelPackage,hfcpci))
+
+
+define KernelPackage/hfcmulti
+ TITLE:=HFC multiport cards (HFC-4S/8S/E1) support for mISDN
+ KCONFIG:=CONFIG_MISDN_HFCMULTI
+ DEPENDS:=+kmod-misdn
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ FILES:=$(LINUX_DIR)/drivers/isdn/hardware/mISDN/hfcmulti.ko
+ AUTOLOAD:=$(call AutoLoad,31,hfcmulti)
+endef
+
+define KernelPackage/hfcmulti/description
+ Kernel modules for Cologne AG's HFC multiport cards (HFC-4S/8S/E1)
+ using the mISDN V2 stack.
+endef
+
+$(eval $(call KernelPackage,hfcmulti))
+
+
+define KernelPackage/gigaset
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=Siemens Gigaset support for isdn4linux
+ DEPENDS:=@USB_SUPPORT +kmod-isdn4linux +kmod-lib-crc-ccitt +kmod-usb-core
+ URL:=http://gigaset307x.sourceforge.net/
+ KCONFIG:= \
+ CONFIG_ISDN_DRV_GIGASET \
+ CONFIG_GIGASET_BASE \
+ CONFIG_GIGASET_M101 \
+ CONFIG_GIGASET_M105 \
+ CONFIG_GIGASET_UNDOCREQ=y \
+ CONFIG_GIGASET_I4L=y
+ FILES:= \
+ $(LINUX_DIR)/drivers/isdn/gigaset/gigaset.ko \
+ $(LINUX_DIR)/drivers/isdn/gigaset/bas_gigaset.ko \
+ $(LINUX_DIR)/drivers/isdn/gigaset/ser_gigaset.ko \
+ $(LINUX_DIR)/drivers/isdn/gigaset/usb_gigaset.ko
+ AUTOLOAD:=$(call AutoLoad,50,gigaset bas_gigaset ser_gigaset usb_gigaset)
+endef
+
+define KernelPackage/gigaset/description
+ This driver supports the Siemens Gigaset SX205/255 family of
+ ISDN DECT bases, including the predecessors Gigaset 3070/3075
+ and 4170/4175 and their T-Com versions Sinus 45isdn and Sinus
+ 721X.
+endef
+
+$(eval $(call KernelPackage,gigaset))
+
+
+define KernelPackage/macvlan
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=MAC-VLAN support
+ KCONFIG:=CONFIG_MACVLAN
+ FILES:=$(LINUX_DIR)/drivers/net/macvlan.ko
+ AUTOLOAD:=$(call AutoLoad,50,macvlan)
+endef
+
+define KernelPackage/macvlan/description
+ A kernel module which allows one to create virtual interfaces that
+ map packets to or from specific MAC addresses to a particular interface.
+endef
+
+$(eval $(call KernelPackage,macvlan))
+
+define KernelPackage/tulip
+ TITLE:=Tulip family network device support
+ DEPENDS:=@PCI_SUPPORT
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ KCONFIG:= \
+ CONFIG_NET_TULIP=y \
+ CONFIG_DE2104X \
+ CONFIG_DE2104X_DSL=0 \
+ CONFIG_TULIP \
+ CONFIG_TULIP_MWI=y \
+ CONFIG_TULIP_MMIO=y \
+ CONFIG_TULIP_NAPI=y \
+ CONFIG_TULIP_NAPI_HW_MITIGATION=y \
+ CONFIG_DE4X5 \
+ CONFIG_WINBOND_840 \
+ CONFIG_DM9102 \
+ CONFIG_ULI526X
+ FILES:= \
+ $(LINUX_DIR)/drivers/net/ethernet/dec/tulip/tulip.ko \
+ $(LINUX_DIR)/drivers/net/ethernet/dec/tulip/de2104x.ko \
+ $(LINUX_DIR)/drivers/net/ethernet/dec/tulip/de4x5.ko \
+ $(LINUX_DIR)/drivers/net/ethernet/dec/tulip/dmfe.ko \
+ $(LINUX_DIR)/drivers/net/ethernet/dec/tulip/uli526x.ko \
+ $(LINUX_DIR)/drivers/net/ethernet/dec/tulip/winbond-840.ko
+ AUTOLOAD:=$(call AutoLoad,50,tulip)
+endef
+
+define KernelPackage/tulip/description
+ Kernel modules for the Tulip family of network cards,
+ including DECchip Tulip, DIGITAL EtherWORKS, Winbond W89c840,
+ Davicom DM910x/DM980x and ULi M526x controller support.
+endef
+
+$(eval $(call KernelPackage,tulip))
+
+
+define KernelPackage/solos-pci
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=Solos ADSL2+ multiport modem
+ DEPENDS:=@PCI_SUPPORT +kmod-atm
+ KCONFIG:=CONFIG_ATM_SOLOS
+ FILES:=$(LINUX_DIR)/drivers/atm/solos-pci.ko
+ AUTOLOAD:=$(call AutoLoad,50,solos-pci)
+endef
+
+define KernelPackage/solos-pci/description
+ Kernel module for Traverse Technologies' Solos PCI cards
+ and Geos ADSL2+ x86 motherboard.
+endef
+
+$(eval $(call KernelPackage,solos-pci))
+
+define KernelPackage/dummy
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=Dummy network device
+ KCONFIG:=CONFIG_DUMMY
+ FILES:=$(LINUX_DIR)/drivers/net/dummy.ko
+ AUTOLOAD:=$(call AutoLoad,34,dummy)
+endef
+
+define KernelPackage/dummy/description
+ The dummy network device
+endef
+
+$(eval $(call KernelPackage,dummy))
+
+define KernelPackage/ifb
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=Intermediate Functional Block support
+ KCONFIG:= \
+ CONFIG_IFB \
+ CONFIG_NET_CLS=y
+ FILES:=$(LINUX_DIR)/drivers/net/ifb.ko
+ AUTOLOAD:=$(call AutoLoad,34,ifb)
+endef
+
+define KernelPackage/ifb/description
+ The Intermediate Functional Block
+endef
+
+$(eval $(call KernelPackage,ifb))
+
+define KernelPackage/dm9000
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=Davicom 9000 Ethernet support
+ DEPENDS:=@PCI_SUPPORT
+ KCONFIG:=CONFIG_DM9000 \
+ CONFIG_DM9000_DEBUGLEVEL=4 \
+ CONFIG_DM9000_FORCE_SIMPLE_PHY_POLL=y
+ FILES:=$(LINUX_DIR)/drivers/net/ethernet/davicom/dm9000.ko
+ AUTOLOAD:=$(call AutoLoad,34,dm9000)
+endef
+
+define KernelPackage/dm9000/description
+ Kernel driver for Davicom 9000 Ethernet adapters.
+endef
+
+$(eval $(call KernelPackage,dm9000))
+
+define KernelPackage/forcedeth
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=nForce Ethernet support
+ DEPENDS:=@PCI_SUPPORT
+ KCONFIG:=CONFIG_FORCEDETH
+ FILES:=$(LINUX_DIR)/drivers/net/ethernet/nvidia/forcedeth.ko
+ AUTOLOAD:=$(call AutoLoad,50,forcedeth)
+endef
+
+define KernelPackage/forcedeth/description
+ Kernel driver for Nvidia Ethernet support
+endef
+
+$(eval $(call KernelPackage,forcedeth))
+
+define KernelPackage/of-mdio
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=OpenFirmware MDIO support
+ DEPENDS:=+kmod-libphy
+ KCONFIG:=CONFIG_OF_MDIO
+ FILES:=$(LINUX_DIR)/drivers/of/of_mdio.ko
+ AUTOLOAD:=$(call AutoLoad,41,of_mdio)
+endef
+
+define KernelPackage/of-mdio/description
+ Kernel driver for OpenFirmware MDIO support
+endef
+
+$(eval $(call KernelPackage,of-mdio))
+
+define KernelPackage/fsl-pq-mdio
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=Freescale PQ MDIO bus support
+ DEPENDS:=@TARGET_mpc85xx +kmod-of-mdio
+ KCONFIG:=CONFIG_FSL_PQ_MDIO
+ FILES:=$(LINUX_DIR)/drivers/net/ethernet/freescale/fsl_pq_mdio.ko
+ AUTOLOAD:=$(call AutoLoad,42,fsl_pq_mdio)
+endef
+
+define KernelPackage/fsl-pq-mdio/description
+ Kernel driver for the Freescale PQ MDIO bus
+endef
+
+$(eval $(call KernelPackage,fsl-pq-mdio))
+
+
+define KernelPackage/gianfar
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=Gianfar Ethernet support
+ DEPENDS:=@TARGET_mpc85xx +kmod-fsl-pq-mdio
+ KCONFIG:=CONFIG_GIANFAR
+ FILES:=$(LINUX_DIR)/drivers/net/ethernet/freescale/gianfar_driver.ko
+ AUTOLOAD:=$(call AutoLoad,50,gianfar_driver)
+endef
+
+define KernelPackage/gianfar/description
+ Kernel driver for Freescale Gianfar Ethernet support
+endef
+
+$(eval $(call KernelPackage,gianfar))
diff --git a/package/kernel/modules/.svn/text-base/netfilter.mk.svn-base b/package/kernel/modules/.svn/text-base/netfilter.mk.svn-base
new file mode 100644
index 0000000..50180a5
--- /dev/null
+++ b/package/kernel/modules/.svn/text-base/netfilter.mk.svn-base
@@ -0,0 +1,575 @@
+
+#
+# Copyright (C) 2006-2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+NF_MENU:=Netfilter Extensions
+NF_KMOD:=1
+include $(INCLUDE_DIR)/netfilter.mk
+
+define KernelPackage/ipt-core
+ SUBMENU:=$(NF_MENU)
+ TITLE:=Netfilter core
+ KCONFIG:= \
+ CONFIG_NETFILTER=y \
+ CONFIG_NETFILTER_ADVANCED=y \
+ $(KCONFIG_IPT_CORE)
+ FILES:=$(foreach mod,$(IPT_CORE-m),$(LINUX_DIR)/net/$(mod).ko)
+ AUTOLOAD:=$(call AutoLoad,40,$(notdir $(IPT_CORE-m)))
+endef
+
+define KernelPackage/ipt-core/description
+ Netfilter core kernel modules
+ Includes:
+ - comment
+ - limit
+ - LOG
+ - mac
+ - multiport
+ - REJECT
+ - TCPMSS
+endef
+
+$(eval $(call KernelPackage,ipt-core))
+
+
+define AddDepends/ipt
+ SUBMENU:=$(NF_MENU)
+ DEPENDS+= kmod-ipt-core $(1)
+endef
+
+
+define KernelPackage/ipt-conntrack
+ TITLE:=Basic connection tracking modules
+ KCONFIG:=$(KCONFIG_IPT_CONNTRACK)
+ FILES:=$(foreach mod,$(IPT_CONNTRACK-m),$(LINUX_DIR)/net/$(mod).ko)
+ AUTOLOAD:=$(call AutoLoad,41,$(notdir $(IPT_CONNTRACK-m)))
+ $(call AddDepends/ipt)
+endef
+
+define KernelPackage/ipt-conntrack/description
+ Netfilter (IPv4) kernel modules for connection tracking
+ Includes:
+ - conntrack
+ - defrag
+ - iptables_raw
+ - NOTRACK
+ - state
+endef
+
+$(eval $(call KernelPackage,ipt-conntrack))
+
+
+define KernelPackage/ipt-conntrack-extra
+ TITLE:=Extra connection tracking modules
+ KCONFIG:=$(KCONFIG_IPT_CONNTRACK_EXTRA)
+ FILES:=$(foreach mod,$(IPT_CONNTRACK_EXTRA-m),$(LINUX_DIR)/net/$(mod).ko)
+ AUTOLOAD:=$(call AutoLoad,42,$(notdir $(IPT_CONNTRACK_EXTRA-m)))
+ $(call AddDepends/ipt,+kmod-ipt-conntrack)
+endef
+
+define KernelPackage/ipt-conntrack-extra/description
+ Netfilter (IPv4) extra kernel modules for connection tracking
+ Includes:
+ - connbytes
+ - connmark/CONNMARK
+ - conntrack
+ - helper
+ - recent
+endef
+
+$(eval $(call KernelPackage,ipt-conntrack-extra))
+
+
+define KernelPackage/ipt-filter
+ TITLE:=Modules for packet content inspection
+ KCONFIG:=$(KCONFIG_IPT_FILTER)
+ FILES:=$(foreach mod,$(IPT_FILTER-m),$(LINUX_DIR)/net/$(mod).ko)
+ AUTOLOAD:=$(call AutoLoad,45,$(notdir $(IPT_FILTER-m)))
+ $(call AddDepends/ipt,+kmod-lib-textsearch)
+endef
+
+define KernelPackage/ipt-filter/description
+ Netfilter (IPv4) kernel modules for packet content inspection
+ Includes:
+ - layer7
+ - string
+endef
+
+$(eval $(call KernelPackage,ipt-filter))
+
+
+define KernelPackage/ipt-ipopt
+ TITLE:=Modules for matching/changing IP packet options
+ KCONFIG:=$(KCONFIG_IPT_IPOPT)
+ FILES:=$(foreach mod,$(IPT_IPOPT-m),$(LINUX_DIR)/net/$(mod).ko)
+ AUTOLOAD:=$(call AutoLoad,45,$(notdir $(IPT_IPOPT-m)))
+ $(call AddDepends/ipt)
+endef
+
+define KernelPackage/ipt-ipopt/description
+ Netfilter (IPv4) modules for matching/changing IP packet options
+ Includes:
+ - CLASSIFY
+ - dscp/DSCP
+ - ecn/ECN
+ - hl/HL
+ - length
+ - mark/MARK
+ - statistic
+ - tcpmss
+ - time
+ - ttl/TTL
+ - unclean
+endef
+
+$(eval $(call KernelPackage,ipt-ipopt))
+
+
+define KernelPackage/ipt-ipsec
+ TITLE:=Modules for matching IPSec packets
+ KCONFIG:=$(KCONFIG_IPT_IPSEC)
+ FILES:=$(foreach mod,$(IPT_IPSEC-m),$(LINUX_DIR)/net/$(mod).ko)
+ AUTOLOAD:=$(call AutoLoad,45,$(notdir $(IPT_IPSEC-m)))
+ $(call AddDepends/ipt)
+endef
+
+define KernelPackage/ipt-ipsec/description
+ Netfilter (IPv4) modules for matching IPSec packets
+ Includes:
+ - ah
+ - esp
+ - policy
+endef
+
+$(eval $(call KernelPackage,ipt-ipsec))
+
+
+define KernelPackage/ipt-nat
+ TITLE:=Basic NAT targets
+ KCONFIG:=$(KCONFIG_IPT_NAT)
+ FILES:=$(foreach mod,$(IPT_NAT-m),$(LINUX_DIR)/net/$(mod).ko)
+ AUTOLOAD:=$(call AutoLoad,42,$(notdir $(IPT_NAT-m)))
+ $(call AddDepends/ipt,+kmod-ipt-conntrack)
+endef
+
+define KernelPackage/ipt-nat/description
+ Netfilter (IPv4) kernel modules for basic NAT targets
+ Includes:
+ - MASQUERADE
+endef
+
+$(eval $(call KernelPackage,ipt-nat))
+
+
+define KernelPackage/ipt-nat-extra
+ TITLE:=Extra NAT targets
+ KCONFIG:=$(KCONFIG_IPT_NAT_EXTRA)
+ FILES:=$(foreach mod,$(IPT_NAT_EXTRA-m),$(LINUX_DIR)/net/$(mod).ko)
+ AUTOLOAD:=$(call AutoLoad,43,$(notdir $(IPT_NAT_EXTRA-m)))
+ $(call AddDepends/ipt,+kmod-ipt-nat)
+endef
+
+define KernelPackage/ipt-nat-extra/description
+ Netfilter (IPv4) kernel modules for extra NAT targets
+ Includes:
+ - NETMAP
+ - REDIRECT
+endef
+
+$(eval $(call KernelPackage,ipt-nat-extra))
+
+
+define KernelPackage/ipt-nathelper
+ TITLE:=Basic Conntrack and NAT helpers
+ KCONFIG:=$(KCONFIG_IPT_NATHELPER)
+ FILES:=$(foreach mod,$(IPT_NATHELPER-m),$(LINUX_DIR)/net/$(mod).ko)
+ AUTOLOAD:=$(call AutoLoad,45,$(notdir $(IPT_NATHELPER-m)))
+ $(call AddDepends/ipt,+kmod-ipt-nat)
+endef
+
+define KernelPackage/ipt-nathelper/description
+ Default Netfilter (IPv4) Conntrack and NAT helpers
+ Includes:
+ - ftp
+ - irc
+ - tftp
+endef
+
+$(eval $(call KernelPackage,ipt-nathelper))
+
+
+define KernelPackage/ipt-nathelper-extra
+ TITLE:=Extra Conntrack and NAT helpers
+ KCONFIG:=$(KCONFIG_IPT_NATHELPER_EXTRA)
+ FILES:=$(foreach mod,$(IPT_NATHELPER_EXTRA-m),$(LINUX_DIR)/net/$(mod).ko)
+ AUTOLOAD:=$(call AutoLoad,45,$(notdir $(IPT_NATHELPER_EXTRA-m)))
+ $(call AddDepends/ipt,+kmod-ipt-nat +kmod-lib-textsearch)
+endef
+
+define KernelPackage/ipt-nathelper-extra/description
+ Extra Netfilter (IPv4) Conntrack and NAT helpers
+ Includes:
+ - amanda
+ - h323
+ - mms
+ - pptp
+ - proto_gre
+ - sip
+ - snmp_basic
+ - broadcast
+endef
+
+$(eval $(call KernelPackage,ipt-nathelper-extra))
+
+
+define KernelPackage/ipt-queue
+ TITLE:=Module for user-space packet queueing
+ KCONFIG:=$(KCONFIG_IPT_QUEUE)
+ DEPENDS:=@!LINUX_3_6
+ FILES:=$(foreach mod,$(IPT_QUEUE-m),$(LINUX_DIR)/net/$(mod).ko)
+ AUTOLOAD:=$(call AutoLoad,45,$(notdir $(IPT_QUEUE-m)))
+ $(call AddDepends/ipt)
+endef
+
+define KernelPackage/ipt-queue/description
+ Netfilter (IPv4) module for user-space packet queueing
+ Includes:
+ - QUEUE
+endef
+
+$(eval $(call KernelPackage,ipt-queue))
+
+
+define KernelPackage/ipt-ulog
+ TITLE:=Module for user-space packet logging
+ KCONFIG:=$(KCONFIG_IPT_ULOG)
+ FILES:=$(foreach mod,$(IPT_ULOG-m),$(LINUX_DIR)/net/$(mod).ko)
+ AUTOLOAD:=$(call AutoLoad,45,$(notdir $(IPT_ULOG-m)))
+ $(call AddDepends/ipt)
+endef
+
+define KernelPackage/ipt-ulog/description
+ Netfilter (IPv4) module for user-space packet logging
+ Includes:
+ - ULOG
+endef
+
+$(eval $(call KernelPackage,ipt-ulog))
+
+
+define KernelPackage/ipt-debug
+ TITLE:=Module for debugging/development
+ KCONFIG:=$(KCONFIG_IPT_DEBUG)
+ DEFAULT:=n
+ FILES:=$(foreach mod,$(IPT_DEBUG-m),$(LINUX_DIR)/net/$(mod).ko)
+ AUTOLOAD:=$(call AutoLoad,45,$(notdir $(IPT_DEBUG-m)))
+ $(call AddDepends/ipt)
+endef
+
+define KernelPackage/ipt-debug/description
+ Netfilter modules for debugging/development of the firewall
+ Includes:
+ - TRACE
+endef
+
+$(eval $(call KernelPackage,ipt-debug))
+
+
+define KernelPackage/ipt-led
+ TITLE:=Module to trigger a LED with a Netfilter rule
+ KCONFIG:=$(KCONFIG_IPT_LED)
+ FILES:=$(foreach mod,$(IPT_LED-m),$(LINUX_DIR)/net/$(mod).ko)
+ AUTOLOAD:=$(call AutoLoad,61,$(notdir $(IPT_LED-m)))
+ $(call AddDepends/ipt)
+endef
+
+define KernelPackage/ipt-led/description
+ Netfilter target to trigger a LED when a network packet is matched.
+endef
+
+$(eval $(call KernelPackage,ipt-led))
+
+define KernelPackage/ipt-tproxy
+ TITLE:=Transparent proxying support
+ DEPENDS+=+IPV6:kmod-ipv6
+ KCONFIG:= \
+ CONFIG_NETFILTER_TPROXY \
+ CONFIG_NETFILTER_XT_MATCH_SOCKET \
+ CONFIG_NETFILTER_XT_TARGET_TPROXY
+ FILES:= \
+ $(LINUX_DIR)/net/netfilter/nf_tproxy_core.ko \
+ $(foreach mod,$(IPT_TPROXY-m),$(LINUX_DIR)/net/$(mod).ko)
+ AUTOLOAD:=$(call AutoLoad,50,$(notdir nf_tproxy_core $(IPT_TPROXY-m)))
+ $(call AddDepends/ipt)
+endef
+
+define KernelPackage/ipt-tproxy/description
+ Kernel modules for Transparent Proxying
+endef
+
+$(eval $(call KernelPackage,ipt-tproxy))
+
+define KernelPackage/ipt-tee
+ TITLE:=TEE support
+ KCONFIG:= \
+ CONFIG_NETFILTER_XT_TARGET_TEE
+ FILES:= \
+ $(LINUX_DIR)/net/netfilter/xt_TEE.ko \
+ $(foreach mod,$(IPT_TEE-m),$(LINUX_DIR)/net/$(mod).ko)
+ AUTOLOAD:=$(call AutoLoad,45,$(notdir nf_tee $(IPT_TEE-m)))
+ $(call AddDepends/ipt)
+endef
+
+define KernelPackage/ipt-tee/description
+ Kernel modules for TEE
+endef
+
+$(eval $(call KernelPackage,ipt-tee))
+
+
+define KernelPackage/ipt-u32
+ TITLE:=U32 support
+ KCONFIG:= \
+ CONFIG_NETFILTER_XT_MATCH_U32
+ FILES:= \
+ $(LINUX_DIR)/net/netfilter/xt_u32.ko \
+ $(foreach mod,$(IPT_U32-m),$(LINUX_DIR)/net/$(mod).ko)
+ AUTOLOAD:=$(call AutoLoad,45,$(notdir nf_tee $(IPT_U32-m)))
+ $(call AddDepends/ipt)
+endef
+
+define KernelPackage/ipt-u32/description
+ Kernel modules for U32
+endef
+
+$(eval $(call KernelPackage,ipt-u32))
+
+
+define KernelPackage/ipt-iprange
+ TITLE:=Module for matching ip ranges
+ KCONFIG:=$(KCONFIG_IPT_IPRANGE)
+ FILES:=$(foreach mod,$(IPT_IPRANGE-m),$(LINUX_DIR)/net/$(mod).ko)
+ AUTOLOAD:=$(call AutoLoad,45,$(notdir $(IPT_IPRANGE-m)))
+ $(call AddDepends/ipt)
+endef
+
+define KernelPackage/ipt-iprange/description
+ Netfilter (IPv4) module for matching ip ranges
+ Includes:
+ - iprange
+endef
+
+$(eval $(call KernelPackage,ipt-iprange))
+
+
+define KernelPackage/ipt-extra
+ TITLE:=Extra modules
+ KCONFIG:=$(KCONFIG_IPT_EXTRA)
+ FILES:=$(foreach mod,$(IPT_EXTRA-m),$(LINUX_DIR)/net/$(mod).ko)
+ AUTOLOAD:=$(call AutoLoad,45,$(notdir $(IPT_EXTRA-m)))
+ $(call AddDepends/ipt)
+endef
+
+define KernelPackage/ipt-extra/description
+ Other Netfilter (IPv4) kernel modules
+ Includes:
+ - addrtype
+ - owner
+ - physdev (if bridge support was enabled in kernel)
+ - pkttype
+ - quota
+endef
+
+$(eval $(call KernelPackage,ipt-extra))
+
+
+define KernelPackage/ip6tables
+ SUBMENU:=$(NF_MENU)
+ TITLE:=IPv6 modules
+ DEPENDS:=+kmod-ipv6
+ KCONFIG:=$(KCONFIG_IPT_IPV6)
+ FILES:=$(foreach mod,$(IPT_IPV6-m),$(LINUX_DIR)/net/$(mod).ko)
+ AUTOLOAD:=$(call AutoLoad,49,$(notdir $(IPT_IPV6-m)))
+endef
+
+define KernelPackage/ip6tables/description
+ Netfilter IPv6 firewalling support
+endef
+
+$(eval $(call KernelPackage,ip6tables))
+
+
+define KernelPackage/arptables
+ SUBMENU:=$(NF_MENU)
+ TITLE:=ARP firewalling modules
+ FILES:=$(LINUX_DIR)/net/ipv4/netfilter/arp*.ko
+ KCONFIG:=CONFIG_IP_NF_ARPTABLES \
+ CONFIG_IP_NF_ARPFILTER \
+ CONFIG_IP_NF_ARP_MANGLE
+ AUTOLOAD:=$(call AutoLoad,49,$(notdir $(patsubst %.ko,%,$(wildcard $(LINUX_DIR)/net/ipv4/netfilter/arp*.ko))))
+endef
+
+define KernelPackage/arptables/description
+ Kernel modules for ARP firewalling
+endef
+
+$(eval $(call KernelPackage,arptables))
+
+
+define KernelPackage/ebtables
+ SUBMENU:=$(NF_MENU)
+ TITLE:=Bridge firewalling modules
+ FILES:=$(foreach mod,$(EBTABLES-m),$(LINUX_DIR)/net/$(mod).ko)
+ KCONFIG:=CONFIG_BRIDGE_NETFILTER=y \
+ $(KCONFIG_EBTABLES)
+ AUTOLOAD:=$(call AutoLoad,49,$(notdir $(EBTABLES-m)))
+endef
+
+define KernelPackage/ebtables/description
+ ebtables is a general, extensible frame/packet identification
+ framework. It provides you to do Ethernet
+ filtering/NAT/brouting on the Ethernet bridge.
+endef
+
+$(eval $(call KernelPackage,ebtables))
+
+
+define AddDepends/ebtables
+ SUBMENU:=$(NF_MENU)
+ DEPENDS+=kmod-ebtables $(1)
+endef
+
+
+define KernelPackage/ebtables-ipv4
+ TITLE:=ebtables: IPv4 support
+ FILES:=$(foreach mod,$(EBTABLES_IP4-m),$(LINUX_DIR)/net/$(mod).ko)
+ KCONFIG:=$(KCONFIG_EBTABLES_IP4)
+ AUTOLOAD:=$(call AutoLoad,49,$(notdir $(EBTABLES_IP4-m)))
+ $(call AddDepends/ebtables)
+endef
+
+define KernelPackage/ebtables-ipv4/description
+ This option adds the IPv4 support to ebtables, which allows basic
+ IPv4 header field filtering, ARP filtering as well as SNAT, DNAT targets.
+endef
+
+$(eval $(call KernelPackage,ebtables-ipv4))
+
+
+define KernelPackage/ebtables-ipv6
+ TITLE:=ebtables: IPv6 support
+ FILES:=$(foreach mod,$(EBTABLES_IP6-m),$(LINUX_DIR)/net/$(mod).ko)
+ KCONFIG:=$(KCONFIG_EBTABLES_IP6)
+ AUTOLOAD:=$(call AutoLoad,49,$(notdir $(EBTABLES_IP6-m)))
+ $(call AddDepends/ebtables)
+endef
+
+define KernelPackage/ebtables-ipv6/description
+ This option adds the IPv6 support to ebtables, which allows basic
+ IPv6 header field filtering and target support.
+endef
+
+$(eval $(call KernelPackage,ebtables-ipv6))
+
+
+define KernelPackage/ebtables-watchers
+ TITLE:=ebtables: watchers support
+ FILES:=$(foreach mod,$(EBTABLES_WATCHERS-m),$(LINUX_DIR)/net/$(mod).ko)
+ KCONFIG:=$(KCONFIG_EBTABLES_WATCHERS)
+ AUTOLOAD:=$(call AutoLoad,49,$(notdir $(EBTABLES_WATCHERS-m)))
+ $(call AddDepends/ebtables)
+endef
+
+define KernelPackage/ebtables-watchers/description
+ This option adds the log watchers, that you can use in any rule
+ in any ebtables table.
+endef
+
+$(eval $(call KernelPackage,ebtables-watchers))
+
+
+define KernelPackage/nfnetlink
+ SUBMENU:=$(NF_MENU)
+ TITLE:=Netlink-based userspace interface
+ DEPENDS:=+kmod-ipt-core
+ FILES:=$(LINUX_DIR)/net/netfilter/nfnetlink.ko
+ KCONFIG:=CONFIG_NETFILTER_NETLINK
+ AUTOLOAD:=$(call AutoLoad,48,nfnetlink)
+endef
+
+define KernelPackage/nfnetlink/description
+ Kernel modules support for a netlink-based userspace interface
+endef
+
+$(eval $(call KernelPackage,nfnetlink))
+
+
+define AddDepends/nfnetlink
+ SUBMENU:=$(NF_MENU)
+ DEPENDS+=+kmod-nfnetlink $(1)
+endef
+
+
+define KernelPackage/nfnetlink-log
+ TITLE:=Netfilter LOG over NFNETLINK interface
+ FILES:=$(LINUX_DIR)/net/netfilter/nfnetlink_log.ko
+ KCONFIG:=CONFIG_NETFILTER_NETLINK_LOG
+ AUTOLOAD:=$(call AutoLoad,48,nfnetlink_log)
+ $(call AddDepends/nfnetlink)
+endef
+
+define KernelPackage/nfnetlink-log/description
+ Kernel modules support for logging packets via NFNETLINK
+endef
+
+$(eval $(call KernelPackage,nfnetlink-log))
+
+
+define KernelPackage/nfnetlink-queue
+ TITLE:=Netfilter QUEUE over NFNETLINK interface
+ FILES:=$(LINUX_DIR)/net/netfilter/nfnetlink_queue.ko
+ KCONFIG:=CONFIG_NETFILTER_NETLINK_QUEUE
+ AUTOLOAD:=$(call AutoLoad,48,nfnetlink_queue)
+ $(call AddDepends/nfnetlink)
+endef
+
+define KernelPackage/nfnetlink-queue/description
+ Kernel modules support for queueing packets via NFNETLINK
+endef
+
+$(eval $(call KernelPackage,nfnetlink-queue))
+
+
+define KernelPackage/nf-conntrack-netlink
+ TITLE:=Connection tracking netlink interface
+ FILES:=$(LINUX_DIR)/net/netfilter/nf_conntrack_netlink.ko
+ KCONFIG:=CONFIG_NF_CT_NETLINK
+ AUTOLOAD:=$(call AutoLoad,49,nf_conntrack_netlink)
+ $(call AddDepends/nfnetlink,+kmod-ipt-conntrack)
+endef
+
+define KernelPackage/nf-conntrack-netlink/description
+ Kernel modules support for a netlink-based connection tracking
+ userspace interface
+endef
+
+$(eval $(call KernelPackage,nf-conntrack-netlink))
+
+define KernelPackage/ipt-hashlimit
+ SUBMENU:=$(NF_MENU)
+ TITLE:=Netfilter hashlimit match
+ KCONFIG:=$(KCONFIG_IPT_HASHLIMIT)
+ FILES:=$(LINUX_DIR)/net/netfilter/xt_hashlimit.ko
+ AUTOLOAD:=$(call AutoLoad,50,xt_hashlimit)
+ $(call KernelPackage/ipt)
+endef
+
+define KernelPackage/ipt-hashlimit/description
+ Kernel modules support for the hashlimit bucket match module
+endef
+
+$(eval $(call KernelPackage,ipt-hashlimit))
diff --git a/package/kernel/modules/.svn/text-base/netsupport.mk.svn-base b/package/kernel/modules/.svn/text-base/netsupport.mk.svn-base
new file mode 100644
index 0000000..d893c1a
--- /dev/null
+++ b/package/kernel/modules/.svn/text-base/netsupport.mk.svn-base
@@ -0,0 +1,891 @@
+#
+# Copyright (C) 2006-2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+NETWORK_SUPPORT_MENU:=Network Support
+
+define KernelPackage/atm
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=ATM support
+ KCONFIG:= \
+ CONFIG_ATM \
+ CONFIG_ATM_BR2684
+ FILES:= \
+ $(LINUX_DIR)/net/atm/atm.ko \
+ $(LINUX_DIR)/net/atm/br2684.ko
+ AUTOLOAD:=$(call AutoLoad,30,atm br2684)
+endef
+
+define KernelPackage/atm/description
+ Kernel modules for ATM support
+endef
+
+$(eval $(call KernelPackage,atm))
+
+
+define KernelPackage/atmtcp
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=ATM over TCP
+ DEPENDS:=kmod-atm
+ KCONFIG:=CONFIG_ATM_TCP CONFIG_ATM_DRIVERS=y
+ FILES:=$(LINUX_DIR)/drivers/atm/atmtcp.ko
+ AUTOLOAD:=$(call AutoLoad,40,atmtcp)
+endef
+
+define KernelPackage/atmtcp/description
+ Kernel module for ATM over TCP support
+endef
+
+$(eval $(call KernelPackage,atmtcp))
+
+
+define KernelPackage/appletalk
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=Appletalk protocol support
+ KCONFIG:= \
+ CONFIG_ATALK \
+ CONFIG_DEV_APPLETALK \
+ CONFIG_IPDDP \
+ CONFIG_IPDDP_ENCAP=y \
+ CONFIG_IPDDP_DECAP=y
+ FILES:= \
+ $(LINUX_DIR)/net/appletalk/appletalk.ko \
+ $(LINUX_DIR)/drivers/net/appletalk/ipddp.ko
+ AUTOLOAD:=$(call AutoLoad,40,appletalk ipddp)
+endef
+
+define KernelPackage/appletalk/description
+ Kernel module for AppleTalk protocol.
+endef
+
+$(eval $(call KernelPackage,appletalk))
+
+
+define KernelPackage/bonding
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=Ethernet bonding driver
+ KCONFIG:=CONFIG_BONDING
+ FILES:=$(LINUX_DIR)/drivers/net/bonding/bonding.ko
+ AUTOLOAD:=$(call AutoLoad,40,bonding)
+endef
+
+define KernelPackage/bonding/description
+ Kernel module for NIC bonding.
+endef
+
+$(eval $(call KernelPackage,bonding))
+
+
+define KernelPackage/bridge
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=Ethernet bridging support
+ DEPENDS:=+kmod-stp
+ KCONFIG:= \
+ CONFIG_BRIDGE \
+ CONFIG_BRIDGE_IGMP_SNOOPING=y
+ FILES:=$(LINUX_DIR)/net/bridge/bridge.ko
+ AUTOLOAD:=$(call AutoLoad,11,bridge)
+endef
+
+define KernelPackage/bridge/description
+ Kernel module for Ethernet bridging.
+endef
+
+$(eval $(call KernelPackage,bridge))
+
+define KernelPackage/llc
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=ANSI/IEEE 802.2 LLC support
+ KCONFIG:=CONFIG_LLC
+ FILES:=$(LINUX_DIR)/net/llc/llc.ko
+ AUTOLOAD:=$(call AutoLoad,09,llc)
+endef
+
+define KernelPackage/llc/description
+ Kernel module for ANSI/IEEE 802.2 LLC support.
+endef
+
+$(eval $(call KernelPackage,llc))
+
+define KernelPackage/stp
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=Ethernet Spanning Tree Protocol support
+ DEPENDS:=+kmod-llc
+ KCONFIG:=CONFIG_STP
+ FILES:=$(LINUX_DIR)/net/802/stp.ko
+ AUTOLOAD:=$(call AutoLoad,10,stp)
+endef
+
+define KernelPackage/stp/description
+ Kernel module for Ethernet Spanning Tree Protocol support.
+endef
+
+$(eval $(call KernelPackage,stp))
+
+define KernelPackage/8021q
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=802.1Q VLAN support
+ KCONFIG:=CONFIG_VLAN_8021Q \
+ CONFIG_VLAN_8021Q_GVRP=n
+ FILES:=$(LINUX_DIR)/net/8021q/8021q.ko
+ AUTOLOAD:=$(call AutoLoad,12,8021q)
+endef
+
+define KernelPackage/8021q/description
+ Kernel module for 802.1Q VLAN support
+endef
+
+$(eval $(call KernelPackage,8021q))
+
+
+define KernelPackage/capi
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=CAPI (ISDN) Support
+ KCONFIG:= \
+ CONFIG_ISDN_CAPI \
+ CONFIG_ISDN_CAPI_CAPI20 \
+ CONFIG_ISDN_CAPIFS \
+ CONFIG_ISDN_CAPI_CAPIFS
+ FILES:= \
+ $(LINUX_DIR)/drivers/isdn/capi/kernelcapi.ko \
+ $(LINUX_DIR)/drivers/isdn/capi/capi.ko
+ AUTOLOAD:=$(call AutoLoad,30,kernelcapi capi)
+endef
+
+define KernelPackage/capi/description
+ Kernel module for basic CAPI (ISDN) support
+endef
+
+$(eval $(call KernelPackage,capi))
+
+define KernelPackage/misdn
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=mISDN (ISDN) Support
+ KCONFIG:= \
+ CONFIG_ISDN=y \
+ CONFIG_MISDN \
+ CONFIG_MISDN_DSP \
+ CONFIG_MISDN_L1OIP
+ FILES:= \
+ $(LINUX_DIR)/drivers/isdn/mISDN/mISDN_core.ko \
+ $(LINUX_DIR)/drivers/isdn/mISDN/mISDN_dsp.ko \
+ $(LINUX_DIR)/drivers/isdn/mISDN/l1oip.ko
+ AUTOLOAD:=$(call AutoLoad,30,mISDN_core mISDN_dsp l1oip)
+endef
+
+define KernelPackage/misdn/description
+ Modular ISDN driver support
+endef
+
+$(eval $(call KernelPackage,misdn))
+
+
+define KernelPackage/isdn4linux
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=Old ISDN4Linux (deprecated)
+ KCONFIG:= \
+ CONFIG_ISDN=y \
+ CONFIG_ISDN_I4L \
+ CONFIG_ISDN_PPP=y \
+ CONFIG_ISDN_PPP_VJ=y \
+ CONFIG_ISDN_MPP=y \
+ CONFIG_IPPP_FILTER=y \
+ CONFIG_ISDN_PPP_BSDCOMP \
+ CONFIG_ISDN_CAPI_MIDDLEWARE=y \
+ CONFIG_ISDN_CAPI_CAPIFS_BOOL=y \
+ CONFIG_ISDN_AUDIO=y \
+ CONFIG_ISDN_TTY_FAX=y \
+ CONFIG_ISDN_X25=y \
+ CONFIG_ISDN_DIVERSION
+ FILES:= \
+ $(LINUX_DIR)/drivers/isdn/divert/dss1_divert.ko \
+ $(LINUX_DIR)/drivers/isdn/i4l/isdn.ko \
+ $(LINUX_DIR)/drivers/isdn/i4l/isdn_bsdcomp.ko
+ AUTOLOAD:=$(call AutoLoad,40,isdn isdn_bsdcomp dss1_divert)
+endef
+
+define KernelPackage/isdn4linux/description
+ This driver allows you to use an ISDN adapter for networking
+endef
+
+$(eval $(call KernelPackage,isdn4linux))
+
+
+define KernelPackage/ipip
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=IP-in-IP encapsulation
+ DEPENDS:=+kmod-iptunnel4
+ KCONFIG:=CONFIG_NET_IPIP
+ FILES:=$(LINUX_DIR)/net/ipv4/ipip.ko
+ AUTOLOAD:=$(call AutoLoad,32,ipip)
+endef
+
+define KernelPackage/ipip/description
+ Kernel modules for IP-in-IP encapsulation
+endef
+
+$(eval $(call KernelPackage,ipip))
+
+
+IPSEC-m:= \
+ $(if $(CONFIG_LINUX_3_3),,xfrm/xfrm_algo) \
+ xfrm/xfrm_ipcomp \
+ xfrm/xfrm_user \
+ key/af_key \
+
+define KernelPackage/ipsec
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=IPsec related modules (IPv4 and IPv6)
+ DEPENDS:=+kmod-crypto-authenc +kmod-crypto-iv +kmod-crypto-des +kmod-crypto-hmac +kmod-crypto-md5 +kmod-crypto-sha1 +kmod-crypto-deflate +kmod-crypto-cbc
+ KCONFIG:= \
+ CONFIG_NET_KEY \
+ CONFIG_XFRM_USER \
+ CONFIG_INET_IPCOMP \
+ CONFIG_XFRM_IPCOMP
+ FILES:=$(foreach mod,$(IPSEC-m),$(LINUX_DIR)/net/$(mod).ko)
+ AUTOLOAD:=$(call AutoLoad,30,$(notdir $(IPSEC-m)))
+endef
+
+define KernelPackage/ipsec/description
+ Kernel modules for IPsec support in both IPv4 and IPv6.
+ Includes:
+ - af_key
+ - xfrm_ipcomp
+ - xfrm_user
+endef
+
+$(eval $(call KernelPackage,ipsec))
+
+
+IPSEC4-m:= \
+ ipv4/ah4 \
+ ipv4/esp4 \
+ ipv4/xfrm4_mode_beet \
+ ipv4/xfrm4_mode_transport \
+ ipv4/xfrm4_mode_tunnel \
+ ipv4/xfrm4_tunnel \
+ ipv4/ipcomp \
+
+define KernelPackage/ipsec4
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=IPsec related modules (IPv4)
+ DEPENDS:=kmod-ipsec +kmod-iptunnel4
+ KCONFIG:= \
+ CONFIG_INET_AH \
+ CONFIG_INET_ESP \
+ CONFIG_INET_IPCOMP \
+ CONFIG_INET_XFRM_MODE_BEET \
+ CONFIG_INET_XFRM_MODE_TRANSPORT \
+ CONFIG_INET_XFRM_MODE_TUNNEL \
+ CONFIG_INET_XFRM_TUNNEL
+ FILES:=$(foreach mod,$(IPSEC4-m),$(LINUX_DIR)/net/$(mod).ko)
+ AUTOLOAD:=$(call AutoLoad,32,$(notdir $(IPSEC4-m)))
+endef
+
+define KernelPackage/ipsec4/description
+ Kernel modules for IPsec support in IPv4.
+ Includes:
+ - ah4
+ - esp4
+ - ipcomp4
+ - xfrm4_mode_beet
+ - xfrm4_mode_transport
+ - xfrm4_mode_tunnel
+ - xfrm4_tunnel
+endef
+
+$(eval $(call KernelPackage,ipsec4))
+
+
+IPSEC6-m:= \
+ ipv6/ah6 \
+ ipv6/esp6 \
+ ipv6/xfrm6_mode_beet \
+ ipv6/xfrm6_mode_transport \
+ ipv6/xfrm6_mode_tunnel \
+ ipv6/xfrm6_tunnel \
+ ipv6/ipcomp6 \
+
+define KernelPackage/ipsec6
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=IPsec related modules (IPv6)
+ DEPENDS:=kmod-ipsec +kmod-iptunnel6
+ KCONFIG:= \
+ CONFIG_INET6_AH \
+ CONFIG_INET6_ESP \
+ CONFIG_INET6_IPCOMP \
+ CONFIG_INET6_XFRM_MODE_BEET \
+ CONFIG_INET6_XFRM_MODE_TRANSPORT \
+ CONFIG_INET6_XFRM_MODE_TUNNEL \
+ CONFIG_INET6_XFRM_TUNNEL
+ FILES:=$(foreach mod,$(IPSEC6-m),$(LINUX_DIR)/net/$(mod).ko)
+ AUTOLOAD:=$(call AutoLoad,32,$(notdir $(IPSEC6-m)))
+endef
+
+define KernelPackage/ipsec6/description
+ Kernel modules for IPsec support in IPv6.
+ Includes:
+ - ah6
+ - esp6
+ - ipcomp6
+ - xfrm6_mode_beet
+ - xfrm6_mode_transport
+ - xfrm6_mode_tunnel
+ - xfrm6_tunnel
+endef
+
+$(eval $(call KernelPackage,ipsec6))
+
+
+# NOTE: tunnel4 is not selectable by itself, so enable ipip for that
+define KernelPackage/iptunnel4
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=IPv4 tunneling
+ KCONFIG:= \
+ CONFIG_NET_IPIP \
+ CONFIG_INET_TUNNEL
+ FILES:=$(LINUX_DIR)/net/ipv4/tunnel4.ko
+ AUTOLOAD:=$(call AutoLoad,31,tunnel4)
+endef
+
+define KernelPackage/iptunnel4/description
+ Kernel modules for IPv4 tunneling
+endef
+
+$(eval $(call KernelPackage,iptunnel4))
+
+
+define KernelPackage/iptunnel6
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=IPv6 tunneling
+ DEPENDS:= +kmod-ipv6
+ KCONFIG:= \
+ CONFIG_INET6_TUNNEL
+ FILES:=$(LINUX_DIR)/net/ipv6/tunnel6.ko
+ AUTOLOAD:=$(call AutoLoad,31,tunnel6)
+endef
+
+define KernelPackage/iptunnel6/description
+ Kernel modules for IPv6 tunneling
+endef
+
+$(eval $(call KernelPackage,iptunnel6))
+
+
+define KernelPackage/ipv6
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=IPv6 support
+ KCONFIG:= \
+ CONFIG_IPV6 \
+ CONFIG_IPV6_PRIVACY=y \
+ CONFIG_IPV6_MULTIPLE_TABLES=y \
+ CONFIG_IPV6_MROUTE=y \
+ CONFIG_IPV6_PIMSM_V2=n \
+ CONFIG_IPV6_SUBTREES=y
+ FILES:=$(LINUX_DIR)/net/ipv6/ipv6.ko
+ AUTOLOAD:=$(call AutoLoad,20,ipv6)
+endef
+
+define KernelPackage/ipv6/description
+ Kernel modules for IPv6 support
+endef
+
+$(eval $(call KernelPackage,ipv6))
+
+
+define KernelPackage/sit
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ DEPENDS:=+kmod-ipv6 +kmod-iptunnel4
+ TITLE:=IPv6-in-IPv4 tunnel
+ KCONFIG:=CONFIG_IPV6_SIT \
+ CONFIG_IPV6_SIT_6RD=y
+ FILES:=$(LINUX_DIR)/net/ipv6/sit.ko
+ AUTOLOAD:=$(call AutoLoad,32,sit)
+endef
+
+define KernelPackage/sit/description
+ Kernel modules for IPv6-in-IPv4 tunnelling
+endef
+
+$(eval $(call KernelPackage,sit))
+
+
+define KernelPackage/ip6-tunnel
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=IP-in-IPv6 tunnelling
+ DEPENDS:= +kmod-ipv6 +kmod-iptunnel6
+ KCONFIG:= CONFIG_IPV6_TUNNEL
+ FILES:=$(LINUX_DIR)/net/ipv6/ip6_tunnel.ko
+ AUTOLOAD:=$(call AutoLoad,32,ip6_tunnel)
+endef
+
+define KernelPackage/ip6-tunnel/description
+ Kernel modules for IPv6-in-IPv6 and IPv4-in-IPv6 tunnelling
+endef
+
+$(eval $(call KernelPackage,ip6-tunnel))
+
+
+define KernelPackage/gre
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=GRE support
+ DEPENDS:=+PACKAGE_kmod-ipv6:kmod-ipv6
+ KCONFIG:=CONFIG_NET_IPGRE CONFIG_NET_IPGRE_DEMUX
+ FILES:=$(LINUX_DIR)/net/ipv4/ip_gre.ko $(LINUX_DIR)/net/ipv4/gre.ko
+ AUTOLOAD:=$(call AutoLoad,39,gre ip_gre)
+endef
+
+define KernelPackage/gre/description
+ Generic Routing Encapsulation support
+endef
+
+$(eval $(call KernelPackage,gre))
+
+
+define KernelPackage/gre6
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=GRE support over IPV6
+ DEPENDS:=+kmod-ipv6 +kmod-ip6-tunnel @!LINUX_3_3 @!LINUX_3_6
+ KCONFIG:=CONFIG_IPV6_GRE
+ FILES:=$(LINUX_DIR)/net/ipv6/ip6_gre.ko
+ AUTOLOAD:=$(call AutoLoad,39,ip6_gre)
+endef
+
+define KernelPackage/gre6/description
+ Generic Routing Encapsulation support over IPv6
+endef
+
+$(eval $(call KernelPackage,gre6))
+
+
+define KernelPackage/tun
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=Universal TUN/TAP driver
+ KCONFIG:=CONFIG_TUN
+ FILES:=$(LINUX_DIR)/drivers/net/tun.ko
+ AUTOLOAD:=$(call AutoLoad,30,tun)
+endef
+
+define KernelPackage/tun/description
+ Kernel support for the TUN/TAP tunneling device
+endef
+
+$(eval $(call KernelPackage,tun))
+
+
+define KernelPackage/ppp
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=PPP modules
+ DEPENDS:=+kmod-lib-crc-ccitt
+ KCONFIG:= \
+ CONFIG_PPP \
+ CONFIG_PPP_ASYNC \
+ CONFIG_SLHC
+ FILES:= \
+ $(LINUX_DIR)/drivers/net/ppp/ppp_async.ko \
+ $(LINUX_DIR)/drivers/net/ppp/ppp_generic.ko \
+ $(LINUX_DIR)/drivers/net/slip/slhc.ko
+ AUTOLOAD:=$(call AutoLoad,30,slhc ppp_generic ppp_async)
+endef
+
+define KernelPackage/ppp/description
+ Kernel modules for PPP support
+endef
+
+$(eval $(call KernelPackage,ppp))
+
+
+define KernelPackage/ppp-synctty
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=PPP sync tty support
+ DEPENDS:=kmod-ppp
+ KCONFIG:=CONFIG_PPP_SYNC_TTY
+ FILES:=$(LINUX_DIR)/drivers/net/ppp/ppp_synctty.ko
+ AUTOLOAD:=$(call AutoLoad,40,ppp_synctty)
+endef
+
+define KernelPackage/ppp-synctty/description
+ Kernel modules for PPP sync tty support
+endef
+
+$(eval $(call KernelPackage,ppp-synctty))
+
+
+define KernelPackage/pppox
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=PPPoX helper
+ DEPENDS:=kmod-ppp
+ KCONFIG:=CONFIG_PPPOE
+ FILES:=$(LINUX_DIR)/drivers/net/ppp/pppox.ko
+ AUTOLOAD:=$(call AutoLoad,40,pppox)
+endef
+
+define KernelPackage/pppox/description
+ Kernel helper module for PPPoE and PPTP support
+endef
+
+$(eval $(call KernelPackage,pppox))
+
+
+define KernelPackage/pppoe
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=PPPoE support
+ DEPENDS:=kmod-ppp +kmod-pppox
+ KCONFIG:=CONFIG_PPPOE
+ FILES:=$(LINUX_DIR)/drivers/net/ppp/pppoe.ko
+ AUTOLOAD:=$(call AutoLoad,41,pppoe)
+endef
+
+define KernelPackage/pppoe/description
+ Kernel module for PPPoE (PPP over Ethernet) support
+endef
+
+$(eval $(call KernelPackage,pppoe))
+
+
+define KernelPackage/pppoa
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=PPPoA support
+ DEPENDS:=kmod-ppp +kmod-atm
+ KCONFIG:=CONFIG_PPPOATM CONFIG_ATM_DRIVERS=y
+ FILES:=$(LINUX_DIR)/net/atm/pppoatm.ko
+ AUTOLOAD:=$(call AutoLoad,40,pppoatm)
+endef
+
+define KernelPackage/pppoa/description
+ Kernel modules for PPPoA (PPP over ATM) support
+endef
+
+$(eval $(call KernelPackage,pppoa))
+
+
+define KernelPackage/pptp
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=PPtP support
+ DEPENDS:=kmod-ppp +kmod-gre +kmod-pppox
+ KCONFIG:=CONFIG_PPTP
+ FILES:=$(LINUX_DIR)/drivers/net/ppp/pptp.ko
+ AUTOLOAD:=$(call AutoLoad,41,pptp)
+endef
+
+$(eval $(call KernelPackage,pptp))
+
+
+define KernelPackage/pppol2tp
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=PPPoL2TP support
+ DEPENDS:=kmod-ppp +kmod-pppox +kmod-l2tp
+ KCONFIG:=CONFIG_PPPOL2TP
+ FILES:=$(LINUX_DIR)/net/l2tp/l2tp_ppp.ko
+ AUTOLOAD:=$(call AutoLoad,41,l2tp_ppp)
+endef
+
+define KernelPackage/pppol2tp/description
+ Kernel modules for PPPoL2TP (PPP over L2TP) support
+endef
+
+$(eval $(call KernelPackage,pppol2tp))
+
+
+define KernelPackage/ipoa
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=IPoA support
+ DEPENDS:=kmod-atm
+ KCONFIG:=CONFIG_ATM_CLIP
+ FILES:=$(LINUX_DIR)/net/atm/clip.ko
+ AUTOLOAD:=$(call AutoLoad,40,clip)
+endef
+
+define KernelPackage/ipoa/description
+ Kernel modules for IPoA (IP over ATM) support
+endef
+
+$(eval $(call KernelPackage,ipoa))
+
+
+define KernelPackage/mppe
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=Microsoft PPP compression/encryption
+ DEPENDS:=kmod-ppp +kmod-crypto-core +kmod-crypto-arc4 +kmod-crypto-sha1 +kmod-crypto-ecb
+ KCONFIG:= \
+ CONFIG_PPP_MPPE_MPPC \
+ CONFIG_PPP_MPPE
+ FILES:=$(LINUX_DIR)/drivers/net/ppp/ppp_mppe.ko
+ AUTOLOAD:=$(call AutoLoad,31,ppp_mppe)
+endef
+
+define KernelPackage/mppe/description
+ Kernel modules for Microsoft PPP compression/encryption
+endef
+
+$(eval $(call KernelPackage,mppe))
+
+
+SCHED_MODULES = $(patsubst $(LINUX_DIR)/net/sched/%.ko,%,$(wildcard $(LINUX_DIR)/net/sched/*.ko))
+SCHED_MODULES_CORE = sch_ingress sch_codel sch_fq_codel sch_hfsc cls_fw cls_route cls_flow cls_tcindex cls_u32 em_u32 act_mirred act_skbedit
+SCHED_MODULES_FILTER = $(SCHED_MODULES_CORE) act_connmark sch_esfq
+SCHED_MODULES_EXTRA = $(filter-out $(SCHED_MODULES_FILTER),$(SCHED_MODULES))
+SCHED_FILES = $(patsubst %,$(LINUX_DIR)/net/sched/%.ko,$(filter $(SCHED_MODULES_CORE),$(SCHED_MODULES)))
+SCHED_FILES_EXTRA = $(patsubst %,$(LINUX_DIR)/net/sched/%.ko,$(SCHED_MODULES_EXTRA))
+
+define KernelPackage/sched-core
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=Traffic schedulers
+ KCONFIG:= \
+ CONFIG_NET_SCHED=y \
+ CONFIG_NET_SCH_HFSC \
+ CONFIG_NET_SCH_INGRESS \
+ CONFIG_NET_SCH_CODEL \
+ CONFIG_NET_SCH_FQ_CODEL \
+ CONFIG_NET_CLS=y \
+ CONFIG_NET_CLS_ACT=y \
+ CONFIG_NET_CLS_FLOW \
+ CONFIG_NET_CLS_FW \
+ CONFIG_NET_CLS_ROUTE4 \
+ CONFIG_NET_CLS_TCINDEX \
+ CONFIG_NET_CLS_U32 \
+ CONFIG_NET_ACT_MIRRED \
+ CONFIG_NET_ACT_SKBEDIT \
+ CONFIG_NET_EMATCH=y \
+ CONFIG_NET_EMATCH_U32
+ FILES:=$(SCHED_FILES)
+ AUTOLOAD:=$(call AutoLoad,70, $(SCHED_MODULES_CORE))
+endef
+
+define KernelPackage/sched-core/description
+ Core kernel scheduler support for IP traffic
+endef
+
+$(eval $(call KernelPackage,sched-core))
+
+
+define KernelPackage/sched-connmark
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=Traffic shaper conntrack mark support
+ DEPENDS:=+kmod-sched-core +kmod-ipt-core +kmod-ipt-conntrack-extra
+ KCONFIG:=CONFIG_NET_ACT_CONNMARK
+ FILES:=$(LINUX_DIR)/net/sched/act_connmark.ko
+ AUTOLOAD:=$(call AutoLoad,71, act_connmark)
+endef
+$(eval $(call KernelPackage,sched-connmark))
+
+define KernelPackage/sched-esfq
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=Traffic shaper ESFQ support
+ DEPENDS:=+kmod-sched-core +kmod-ipt-core
+ KCONFIG:= \
+ CONFIG_NET_SCH_ESFQ \
+ CONFIG_NET_SCH_ESFQ_NFCT=y
+ FILES:=$(LINUX_DIR)/net/sched/sch_esfq.ko
+ AUTOLOAD:=$(call AutoLoad,72, sch_esfq)
+endef
+$(eval $(call KernelPackage,sched-esfq))
+
+define KernelPackage/sched
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=Extra traffic schedulers
+ DEPENDS:=+kmod-sched-core
+ KCONFIG:= \
+ CONFIG_NET_SCH_DSMARK \
+ CONFIG_NET_SCH_HTB \
+ CONFIG_NET_SCH_FIFO \
+ CONFIG_NET_SCH_GRED \
+ CONFIG_NET_SCH_PRIO \
+ CONFIG_NET_SCH_RED \
+ CONFIG_NET_SCH_TBF \
+ CONFIG_NET_SCH_SFQ \
+ CONFIG_NET_SCH_TEQL \
+ CONFIG_NET_CLS_BASIC \
+ CONFIG_NET_ACT_POLICE \
+ CONFIG_NET_ACT_IPT \
+ CONFIG_NET_EMATCH_CMP \
+ CONFIG_NET_EMATCH_NBYTE \
+ CONFIG_NET_EMATCH_META \
+ CONFIG_NET_EMATCH_TEXT
+ FILES:=$(SCHED_FILES_EXTRA)
+ AUTOLOAD:=$(call AutoLoad,73, $(SCHED_MODULES_EXTRA))
+endef
+
+define KernelPackage/sched/description
+ Extra kernel schedulers modules for IP traffic
+endef
+
+$(eval $(call KernelPackage,sched))
+
+
+define KernelPackage/ax25
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=AX25 support
+ KCONFIG:= \
+ CONFIG_AX25 \
+ CONFIG_MKISS
+ FILES:= \
+ $(LINUX_DIR)/net/ax25/ax25.ko \
+ $(LINUX_DIR)/drivers/net/hamradio/mkiss.ko
+ AUTOLOAD:=$(call AutoLoad,80,ax25 mkiss)
+ $(call AddDepends/crc16)
+endef
+
+define KernelPackage/ax25/description
+ Kernel modules for AX25 support
+endef
+
+$(eval $(call KernelPackage,ax25))
+
+
+define KernelPackage/mp-alg
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=ECMP caching algorithms
+ KCONFIG:= \
+ CONFIG_IP_ROUTE_MULTIPATH_RR \
+ CONFIG_IP_ROUTE_MULTIPATH_RANDOM \
+ CONFIG_IP_ROUTE_MULTIPATH_WRANDOM \
+ CONFIG_IP_ROUTE_MULTIPATH_DRR
+ FILES:= \
+ $(LINUX_DIR)/net/ipv4/multipath_rr.ko \
+ $(LINUX_DIR)/net/ipv4/multipath_random.ko \
+ $(LINUX_DIR)/net/ipv4/multipath_wrandom.ko \
+ $(LINUX_DIR)/net/ipv4/multipath_drr.ko
+ AUTOLOAD:=$(call AutoLoad,35,multipath_rr multipath_random multipath_wrandom multipath_drr)
+endef
+
+define KernelPackage/mp-alg/description
+ Kernel modules that provide several different algorithms for multipath
+ route selection from the route cache. The iproute "mpath" argument allows
+ specifying which algorithm to use for routes.
+ quagga (at least <=0.99.6) requires a multipath patch to support this
+ cached mp route feature.
+endef
+
+$(eval $(call KernelPackage,mp-alg))
+
+
+define KernelPackage/pktgen
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ DEPENDS:=@!TARGET_uml
+ TITLE:=Network packet generator
+ KCONFIG:=CONFIG_NET_PKTGEN
+ FILES:=$(LINUX_DIR)/net/core/pktgen.ko
+ AUTOLOAD:=$(call AutoLoad,99,pktgen)
+endef
+
+define KernelPackage/pktgen/description
+ Kernel modules for the Network Packet Generator
+endef
+
+$(eval $(call KernelPackage,pktgen))
+
+define KernelPackage/l2tp
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=Layer Two Tunneling Protocol (L2TP)
+ KCONFIG:=CONFIG_L2TP \
+ CONFIG_L2TP_V3=y \
+ CONFIG_L2TP_DEBUGFS=n
+ FILES:=$(LINUX_DIR)/net/l2tp/l2tp_core.ko \
+ $(LINUX_DIR)/net/l2tp/l2tp_netlink.ko
+ AUTOLOAD:=$(call AutoLoad,32,l2tp_core l2tp_netlink)
+endef
+
+define KernelPackage/l2tp/description
+ Kernel modules for L2TP V3 Support
+endef
+
+$(eval $(call KernelPackage,l2tp))
+
+
+define KernelPackage/l2tp-eth
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=L2TP ethernet pseudowire support for L2TPv3
+ DEPENDS:=+kmod-l2tp
+ KCONFIG:=CONFIG_L2TP_ETH
+ FILES:=$(LINUX_DIR)/net/l2tp/l2tp_eth.ko
+ AUTOLOAD:=$(call AutoLoad,33,l2tp_eth)
+endef
+
+define KernelPackage/l2tp-eth/description
+ Kernel modules for L2TP ethernet pseudowire support for L2TPv3
+endef
+
+$(eval $(call KernelPackage,l2tp-eth))
+
+define KernelPackage/l2tp-ip
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=L2TP IP encapsulation for L2TPv3
+ DEPENDS:=+kmod-l2tp
+ KCONFIG:=CONFIG_L2TP_IP
+ FILES:=$(LINUX_DIR)/net/l2tp/l2tp_ip.ko
+ AUTOLOAD:=$(call AutoLoad,33,l2tp_ip)
+endef
+
+define KernelPackage/l2tp-ip/description
+ Kernel modules for L2TP IP encapsulation for L2TPv3
+endef
+
+$(eval $(call KernelPackage,l2tp-ip))
+
+
+define KernelPackage/sctp
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=SCTP protocol kernel support
+ KCONFIG:=\
+ CONFIG_IP_SCTP \
+ CONFIG_SCTP_DBG_MSG=n \
+ CONFIG_SCTP_DBG_OBJCNT=n \
+ CONFIG_SCTP_HMAC_NONE=n \
+ CONFIG_SCTP_HMAC_SHA1=n \
+ CONFIG_SCTP_HMAC_MD5=y \
+ CONFIG_SCTP_COOKIE_HMAC_SHA1=n \
+ CONFIG_SCTP_COOKIE_HMAC_MD5=y \
+ CONFIG_SCTP_DEFAULT_COOKIE_HMAC_NONE=n \
+ CONFIG_SCTP_DEFAULT_COOKIE_HMAC_SHA1=n \
+ CONFIG_SCTP_DEFAULT_COOKIE_HMAC_MD5=y
+ FILES:= $(LINUX_DIR)/net/sctp/sctp.ko
+ AUTOLOAD:= $(call AutoLoad,32,sctp)
+ DEPENDS:=+kmod-lib-crc32c +kmod-crypto-md5 +kmod-crypto-hmac
+endef
+
+define KernelPackage/sctp/description
+ Kernel modules for SCTP protocol support
+endef
+
+$(eval $(call KernelPackage,sctp))
+
+
+define KernelPackage/netem
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=Network emulation functionality
+ DEPENDS:=+kmod-sched
+ KCONFIG:=CONFIG_NET_SCH_NETEM
+ FILES:=$(LINUX_DIR)/net/sched/sch_netem.ko
+ AUTOLOAD:=$(call AutoLoad,99,netem)
+endef
+
+define KernelPackage/netem/description
+ Kernel modules for emulating the properties of wide area networks
+endef
+
+$(eval $(call KernelPackage,netem))
+
+define KernelPackage/slip
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=SLIP modules
+ KCONFIG:= \
+ CONFIG_SLIP \
+ CONFIG_SLIP_COMPRESSED=y \
+ CONFIG_SLIP_SMART=y \
+ CONFIG_SLIP_MODE_SLIP6=y
+
+ FILES:= \
+ $(LINUX_DIR)/drivers/net/slip/slip.ko
+ AUTOLOAD:=$(call AutoLoad,30,slip)
+endef
+
+define KernelPackage/slip/description
+ Kernel modules for SLIP support
+endef
+
+$(eval $(call KernelPackage,slip))
+
diff --git a/package/kernel/modules/.svn/text-base/nls.mk.svn-base b/package/kernel/modules/.svn/text-base/nls.mk.svn-base
new file mode 100644
index 0000000..28791b6
--- /dev/null
+++ b/package/kernel/modules/.svn/text-base/nls.mk.svn-base
@@ -0,0 +1,228 @@
+#
+# Copyright (C) 2006-2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+define KernelPackage/nls-base
+ SUBMENU:=Native Language Support
+ TITLE:=Native Language Support
+ KCONFIG:=CONFIG_NLS
+ FILES:=$(LINUX_DIR)/fs/nls/nls_base.ko
+ AUTOLOAD:=$(call AutoLoad,20,nls_base,1)
+endef
+
+define KernelPackage/nls-base/description
+ Kernel module for NLS (Native Language Support)
+endef
+
+$(eval $(call KernelPackage,nls-base))
+
+
+define KernelPackage/nls-cp437
+ SUBMENU:=Native Language Support
+ TITLE:=Codepage 437 (United States, Canada)
+ KCONFIG:=CONFIG_NLS_CODEPAGE_437
+ FILES:=$(LINUX_DIR)/fs/nls/nls_cp437.ko
+ AUTOLOAD:=$(call AutoLoad,25,nls_cp437)
+ $(call AddDepends/nls)
+endef
+
+define KernelPackage/nls-cp437/description
+ Kernel module for NLS Codepage 437 (United States, Canada)
+endef
+
+$(eval $(call KernelPackage,nls-cp437))
+
+
+define KernelPackage/nls-cp775
+ SUBMENU:=Native Language Support
+ TITLE:=Codepage 775 (Baltic Rim)
+ KCONFIG:=CONFIG_NLS_CODEPAGE_775
+ FILES:=$(LINUX_DIR)/fs/nls/nls_cp775.ko
+ AUTOLOAD:=$(call AutoLoad,25,nls_cp775)
+ $(call AddDepends/nls)
+endef
+
+define KernelPackage/nls-cp775/description
+ Kernel module for NLS Codepage 775 (Baltic Rim)
+endef
+
+$(eval $(call KernelPackage,nls-cp775))
+
+
+define KernelPackage/nls-cp850
+ SUBMENU:=Native Language Support
+ TITLE:=Codepage 850 (Europe)
+ KCONFIG:=CONFIG_NLS_CODEPAGE_850
+ FILES:=$(LINUX_DIR)/fs/nls/nls_cp850.ko
+ AUTOLOAD:=$(call AutoLoad,25,nls_cp850)
+ $(call AddDepends/nls)
+endef
+
+define KernelPackage/nls-cp850/description
+ Kernel module for NLS Codepage 850 (Europe)
+endef
+
+$(eval $(call KernelPackage,nls-cp850))
+
+
+define KernelPackage/nls-cp852
+ SUBMENU:=Native Language Support
+ TITLE:=Codepage 852 (Europe)
+ KCONFIG:=CONFIG_NLS_CODEPAGE_852
+ FILES:=$(LINUX_DIR)/fs/nls/nls_cp852.ko
+ AUTOLOAD:=$(call AutoLoad,25,nls_cp852)
+ $(call AddDepends/nls)
+endef
+
+define KernelPackage/nls-cp852/description
+ Kernel module for NLS Codepage 852 (Europe)
+endef
+
+$(eval $(call KernelPackage,nls-cp852))
+
+
+define KernelPackage/nls-cp866
+ SUBMENU:=Native Language Support
+ TITLE:=Codepage 866 (Cyrillic)
+ KCONFIG:=CONFIG_NLS_CODEPAGE_866
+ FILES:=$(LINUX_DIR)/fs/nls/nls_cp866.ko
+ AUTOLOAD:=$(call AutoLoad,25,nls_cp866)
+ $(call AddDepends/nls)
+endef
+
+define KernelPackage/nls-cp866/description
+ Kernel module for NLS Codepage 866 (Cyrillic)
+endef
+
+$(eval $(call KernelPackage,nls-cp866))
+
+
+define KernelPackage/nls-cp1250
+ SUBMENU:=Native Language Support
+ TITLE:=Codepage 1250 (Eastern Europe)
+ KCONFIG:=CONFIG_NLS_CODEPAGE_1250
+ FILES:=$(LINUX_DIR)/fs/nls/nls_cp1250.ko
+ AUTOLOAD:=$(call AutoLoad,25,nls_cp1250)
+ $(call AddDepends/nls)
+endef
+
+define KernelPackage/nls-cp1250/description
+ Kernel module for NLS Codepage 1250 (Eastern Europe)
+endef
+
+$(eval $(call KernelPackage,nls-cp1250))
+
+
+define KernelPackage/nls-cp1251
+ SUBMENU:=Native Language Support
+ TITLE:=Codepage 1251 (Russian)
+ KCONFIG:=CONFIG_NLS_CODEPAGE_1251
+ FILES:=$(LINUX_DIR)/fs/nls/nls_cp1251.ko
+ AUTOLOAD:=$(call AutoLoad,25,nls_cp1251)
+ $(call AddDepends/nls)
+endef
+
+define KernelPackage/nls-cp1251/description
+ Kernel module for NLS Codepage 1251 (Russian)
+endef
+
+$(eval $(call KernelPackage,nls-cp1251))
+
+
+define KernelPackage/nls-iso8859-1
+ SUBMENU:=Native Language Support
+ TITLE:=ISO 8859-1 (Latin 1; Western European Languages)
+ KCONFIG:=CONFIG_NLS_ISO8859_1
+ FILES:=$(LINUX_DIR)/fs/nls/nls_iso8859-1.ko
+ AUTOLOAD:=$(call AutoLoad,25,nls_iso8859-1)
+ $(call AddDepends/nls)
+endef
+
+define KernelPackage/nls-iso8859-1/description
+ Kernel module for NLS ISO 8859-1 (Latin 1)
+endef
+
+$(eval $(call KernelPackage,nls-iso8859-1))
+
+
+define KernelPackage/nls-iso8859-2
+ SUBMENU:=Native Language Support
+ TITLE:=ISO 8859-2 (Latin 2; Central European Languages)
+ KCONFIG:=CONFIG_NLS_ISO8859_2
+ FILES:=$(LINUX_DIR)/fs/nls/nls_iso8859-2.ko
+ AUTOLOAD:=$(call AutoLoad,25,nls_iso8859-2)
+ $(call AddDepends/nls)
+endef
+
+define KernelPackage/nls-iso8859-2/description
+ Kernel module for NLS ISO 8859-2 (Latin 2)
+endef
+
+$(eval $(call KernelPackage,nls-iso8859-2))
+
+
+define KernelPackage/nls-iso8859-13
+ SUBMENU:=Native Language Support
+ TITLE:=ISO 8859-13 (Latin 7; Baltic)
+ KCONFIG:=CONFIG_NLS_ISO8859_13
+ FILES:=$(LINUX_DIR)/fs/nls/nls_iso8859-13.ko
+ AUTOLOAD:=$(call AutoLoad,25,nls_iso8859-13)
+ $(call AddDepends/nls)
+endef
+
+define KernelPackage/nls-iso8859-13/description
+ Kernel module for NLS ISO 8859-13 (Latin 7; Baltic)
+endef
+
+$(eval $(call KernelPackage,nls-iso8859-13))
+
+
+define KernelPackage/nls-iso8859-15
+ SUBMENU:=Native Language Support
+ TITLE:=ISO 8859-15 (Latin 9; Western, with Euro symbol)
+ KCONFIG:=CONFIG_NLS_ISO8859_15
+ FILES:=$(LINUX_DIR)/fs/nls/nls_iso8859-15.ko
+ AUTOLOAD:=$(call AutoLoad,25,nls_iso8859-15)
+ $(call AddDepends/nls)
+endef
+
+define KernelPackage/nls-iso8859-15/description
+ Kernel module for NLS ISO 8859-15 (Latin 9)
+endef
+
+$(eval $(call KernelPackage,nls-iso8859-15))
+
+
+define KernelPackage/nls-koi8r
+ SUBMENU:=Native Language Support
+ TITLE:=KOI8-R (Russian)
+ KCONFIG:=CONFIG_NLS_KOI8_R
+ FILES:=$(LINUX_DIR)/fs/nls/nls_koi8-r.ko
+ AUTOLOAD:=$(call AutoLoad,25,nls_koi8-r)
+ $(call AddDepends/nls)
+endef
+
+define KernelPackage/nls-koi8r/description
+ Kernel module for NLS KOI8-R (Russian)
+endef
+
+$(eval $(call KernelPackage,nls-koi8r))
+
+
+define KernelPackage/nls-utf8
+ SUBMENU:=Native Language Support
+ TITLE:=UTF-8
+ KCONFIG:=CONFIG_NLS_UTF8
+ FILES:=$(LINUX_DIR)/fs/nls/nls_utf8.ko
+ AUTOLOAD:=$(call AutoLoad,25,nls_utf8)
+ $(call AddDepends/nls)
+endef
+
+define KernelPackage/nls-utf8/description
+ Kernel module for NLS UTF-8
+endef
+
+$(eval $(call KernelPackage,nls-utf8))
diff --git a/package/kernel/modules/.svn/text-base/other.mk.svn-base b/package/kernel/modules/.svn/text-base/other.mk.svn-base
new file mode 100644
index 0000000..13a0ec4
--- /dev/null
+++ b/package/kernel/modules/.svn/text-base/other.mk.svn-base
@@ -0,0 +1,655 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+OTHER_MENU:=Other modules
+
+WATCHDOG_DIR:=watchdog
+
+
+define KernelPackage/bluetooth
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=Bluetooth support
+ DEPENDS:=@USB_SUPPORT +kmod-usb-core
+ KCONFIG:= \
+ CONFIG_BLUEZ \
+ CONFIG_BLUEZ_L2CAP \
+ CONFIG_BLUEZ_SCO \
+ CONFIG_BLUEZ_RFCOMM \
+ CONFIG_BLUEZ_BNEP \
+ CONFIG_BLUEZ_HCIUART \
+ CONFIG_BLUEZ_HCIUSB \
+ CONFIG_BLUEZ_HIDP \
+ CONFIG_BT \
+ CONFIG_BT_L2CAP=y \
+ CONFIG_BT_SCO=y \
+ CONFIG_BT_RFCOMM \
+ CONFIG_BT_BNEP \
+ CONFIG_BT_HCIBTUSB \
+ CONFIG_BT_HCIUSB \
+ CONFIG_BT_HCIUART \
+ CONFIG_BT_HCIUART_H4 \
+ CONFIG_BT_HIDP \
+ CONFIG_HID_SUPPORT=y
+ $(call AddDepends/crc16)
+ $(call AddDepends/hid)
+ $(call AddDepends/rfkill)
+ FILES:= \
+ $(LINUX_DIR)/net/bluetooth/bluetooth.ko \
+ $(LINUX_DIR)/net/bluetooth/rfcomm/rfcomm.ko \
+ $(LINUX_DIR)/net/bluetooth/bnep/bnep.ko \
+ $(LINUX_DIR)/net/bluetooth/hidp/hidp.ko \
+ $(LINUX_DIR)/drivers/bluetooth/hci_uart.ko \
+ $(LINUX_DIR)/drivers/bluetooth/btusb.ko
+ AUTOLOAD:=$(call AutoLoad,90,bluetooth rfcomm bnep hidp hci_uart btusb)
+endef
+
+define KernelPackage/bluetooth/description
+ Kernel support for Bluetooth devices
+endef
+
+$(eval $(call KernelPackage,bluetooth))
+
+
+define KernelPackage/bluetooth-hci-h4p
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=HCI driver with H4 Nokia extensions
+ DEPENDS:=@TARGET_omap24xx +kmod-bluetooth
+ KCONFIG:=CONFIG_BT_HCIH4P
+ FILES:=$(LINUX_DIR)/drivers/bluetooth/hci_h4p/hci_h4p.ko
+ AUTOLOAD:=$(call AutoLoad,91,hci_h4p)
+endef
+
+define KernelPackage/bluetooth-hci-h4p/description
+ HCI driver with H4 Nokia extensions
+endef
+
+$(eval $(call KernelPackage,bluetooth-hci-h4p))
+
+
+define KernelPackage/eeprom-93cx6
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=EEPROM 93CX6 support
+ KCONFIG:=CONFIG_EEPROM_93CX6
+ FILES:=$(LINUX_DIR)/drivers/misc/eeprom/eeprom_93cx6.ko
+ AUTOLOAD:=$(call AutoLoad,20,eeprom_93cx6)
+endef
+
+define KernelPackage/eeprom-93cx6/description
+ Kernel module for EEPROM 93CX6 support
+endef
+
+$(eval $(call KernelPackage,eeprom-93cx6))
+
+
+define KernelPackage/eeprom-at24
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=EEPROM AT24 support
+ KCONFIG:=CONFIG_EEPROM_AT24
+ DEPENDS:=+kmod-i2c-core
+ FILES:=$(LINUX_DIR)/drivers/misc/eeprom/at24.ko
+ AUTOLOAD:=$(call AutoLoad,60,at24)
+endef
+
+define KernelPackage/eeprom-at24/description
+ Kernel module for most I2C EEPROMs
+endef
+
+$(eval $(call KernelPackage,eeprom-at24))
+
+
+define KernelPackage/eeprom-at25
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=EEPROM AT25 support
+ KCONFIG:=CONFIG_EEPROM_AT25
+ FILES:=$(LINUX_DIR)/drivers/misc/eeprom/at25.ko
+ AUTOLOAD:=$(call AutoLoad,61,at25)
+endef
+
+define KernelPackage/eeprom-at25/description
+ Kernel module for most SPI EEPROMs
+endef
+
+$(eval $(call KernelPackage,eeprom-at25))
+
+
+define KernelPackage/gpio-dev
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=Generic GPIO char device support
+ DEPENDS:=@GPIO_SUPPORT
+ KCONFIG:=CONFIG_GPIO_DEVICE
+ FILES:=$(LINUX_DIR)/drivers/char/gpio_dev.ko
+ AUTOLOAD:=$(call AutoLoad,40,gpio_dev)
+endef
+
+define KernelPackage/gpio-dev/description
+ Kernel module to allows control of GPIO pins using a character device.
+endef
+
+$(eval $(call KernelPackage,gpio-dev))
+
+
+define KernelPackage/gpio-nxp-74hc164
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=NXP 74HC164 GPIO expander support
+ KCONFIG:=CONFIG_GPIO_NXP_74HC164
+ FILES:=$(LINUX_DIR)/drivers/gpio/nxp_74hc164.ko
+ AUTOLOAD:=$(call AutoLoad,99,nxp_74hc164)
+endef
+
+define KernelPackage/gpio-nxp-74hc164/description
+ Kernel module for NXP 74HC164 GPIO expander
+endef
+
+$(eval $(call KernelPackage,gpio-nxp-74hc164))
+
+define KernelPackage/lp
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=Parallel port and line printer support
+ DEPENDS:=@BROKEN
+ KCONFIG:= \
+ CONFIG_PARPORT \
+ CONFIG_PRINTER \
+ CONFIG_PPDEV
+ FILES:= \
+ $(LINUX_DIR)/drivers/parport/parport.ko \
+ $(LINUX_DIR)/drivers/char/lp.ko \
+ $(LINUX_DIR)/drivers/char/ppdev.ko
+ AUTOLOAD:=$(call AutoLoad,50,parport lp)
+endef
+
+$(eval $(call KernelPackage,lp))
+
+
+define KernelPackage/mmc
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=MMC/SD Card Support
+ KCONFIG:= \
+ CONFIG_MMC \
+ CONFIG_MMC_BLOCK \
+ CONFIG_MMC_DEBUG=n \
+ CONFIG_MMC_UNSAFE_RESUME=n \
+ CONFIG_MMC_BLOCK_BOUNCE=y \
+ CONFIG_MMC_SDHCI=n \
+ CONFIG_MMC_TIFM_SD=n \
+ CONFIG_MMC_WBSD=n \
+ CONFIG_SDIO_UART=n
+ FILES:= \
+ $(LINUX_DIR)/drivers/mmc/core/mmc_core.ko \
+ $(LINUX_DIR)/drivers/mmc/card/mmc_block.ko
+ AUTOLOAD:=$(call AutoLoad,90,mmc_core mmc_block,1)
+endef
+
+define KernelPackage/mmc/description
+ Kernel support for MMC/SD cards
+endef
+
+$(eval $(call KernelPackage,mmc))
+
+
+define KernelPackage/oprofile
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=OProfile profiling support
+ KCONFIG:=CONFIG_OPROFILE
+ FILES:=$(LINUX_DIR)/arch/$(LINUX_KARCH)/oprofile/oprofile.ko
+ DEPENDS:=@KERNEL_PROFILING
+endef
+
+define KernelPackage/oprofile/description
+ Kernel module for support for oprofile system profiling.
+endef
+
+$(eval $(call KernelPackage,oprofile))
+
+
+define KernelPackage/rfkill
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=RF switch subsystem support
+ KCONFIG:= \
+ CONFIG_RFKILL \
+ CONFIG_RFKILL_INPUT=y \
+ CONFIG_RFKILL_LEDS=y \
+ CONFIG_RFKILL_GPIO=y
+ FILES:= \
+ $(LINUX_DIR)/net/rfkill/rfkill.ko
+ AUTOLOAD:=$(call AutoLoad,20,rfkill)
+ $(call SetDepends/rfkill)
+endef
+
+define KernelPackage/rfkill/description
+ Say Y here if you want to have control over RF switches
+ found on many WiFi and Bluetooth cards.
+endef
+
+$(eval $(call KernelPackage,rfkill))
+
+
+define KernelPackage/softdog
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=Software watchdog driver
+ KCONFIG:=CONFIG_SOFT_WATCHDOG
+ FILES:=$(LINUX_DIR)/drivers/$(WATCHDOG_DIR)/softdog.ko
+ AUTOLOAD:=$(call AutoLoad,50,softdog)
+endef
+
+define KernelPackage/softdog/description
+ Software watchdog driver
+endef
+
+$(eval $(call KernelPackage,softdog))
+
+
+define KernelPackage/ssb
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=Silicon Sonics Backplane glue code
+ DEPENDS:=@PCI_SUPPORT @!TARGET_brcm47xx @!TARGET_brcm63xx
+ KCONFIG:=\
+ CONFIG_SSB \
+ CONFIG_SSB_B43_PCI_BRIDGE=y \
+ CONFIG_SSB_DRIVER_MIPS=n \
+ CONFIG_SSB_DRIVER_PCICORE=y \
+ CONFIG_SSB_DRIVER_PCICORE_POSSIBLE=y \
+ CONFIG_SSB_PCIHOST=y \
+ CONFIG_SSB_PCIHOST_POSSIBLE=y \
+ CONFIG_SSB_POSSIBLE=y \
+ CONFIG_SSB_SPROM=y \
+ CONFIG_SSB_SILENT=y
+ FILES:=$(LINUX_DIR)/drivers/ssb/ssb.ko
+ AUTOLOAD:=$(call AutoLoad,29,ssb)
+endef
+
+define KernelPackage/ssb/description
+ Silicon Sonics Backplane glue code.
+endef
+
+$(eval $(call KernelPackage,ssb))
+
+
+define KernelPackage/bcma
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=BCMA support
+ DEPENDS:=@PCI_SUPPORT @!TARGET_brcm47xx
+ KCONFIG:=\
+ CONFIG_BCMA \
+ CONFIG_BCMA_POSSIBLE=y \
+ CONFIG_BCMA_BLOCKIO=y \
+ CONFIG_BCMA_HOST_PCI_POSSIBLE=y \
+ CONFIG_BCMA_HOST_PCI=y \
+ CONFIG_BCMA_DRIVER_MIPS=n \
+ CONFIG_BCMA_DRIVER_PCI_HOSTMODE=n \
+ CONFIG_BCMA_DRIVER_GMAC_CMN=n \
+ CONFIG_BCMA_DEBUG=n
+ FILES:=$(LINUX_DIR)/drivers/bcma/bcma.ko
+ AUTOLOAD:=$(call AutoLoad,29,bcma)
+endef
+
+define KernelPackage/bcma/description
+ Bus driver for Broadcom specific Advanced Microcontroller Bus Architecture.
+endef
+
+$(eval $(call KernelPackage,bcma))
+
+
+define KernelPackage/wdt-omap
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=OMAP Watchdog timer
+ DEPENDS:=@(TARGET_omap24xx||TARGET_omap35xx)
+ KCONFIG:=CONFIG_OMAP_WATCHDOG
+ FILES:=$(LINUX_DIR)/drivers/$(WATCHDOG_DIR)/omap_wdt.ko
+ AUTOLOAD:=$(call AutoLoad,50,omap_wdt.ko)
+endef
+
+define KernelPackage/wdt-omap/description
+ Kernel module for TI omap watchdog timer.
+endef
+
+$(eval $(call KernelPackage,wdt-omap))
+
+
+define KernelPackage/wdt-orion
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=Marvell Orion Watchdog timer
+ DEPENDS:=@TARGET_orion||TARGET_kirkwood||TARGET_mvebu
+ KCONFIG:=CONFIG_ORION_WATCHDOG
+ FILES:=$(LINUX_DIR)/drivers/$(WATCHDOG_DIR)/orion_wdt.ko
+ AUTOLOAD:=$(call AutoLoad,50,orion_wdt)
+endef
+
+define KernelPackage/wdt-orion/description
+ Kernel module for Marvell Orion, Kirkwood and Armada XP/370 watchdog timer.
+endef
+
+$(eval $(call KernelPackage,wdt-orion))
+
+
+define KernelPackage/booke-wdt
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=PowerPC Book-E Watchdog Timer
+ DEPENDS:=@(TARGET_mpc85xx||TARGET_ppc40x||TARGET_ppc44x)
+ KCONFIG:=CONFIG_BOOKE_WDT
+ FILES:=$(LINUX_DIR)/drivers/$(WATCHDOG_DIR)/booke_wdt.ko
+ AUTOLOAD:=$(call AutoLoad,50,booke_wdt)
+endef
+
+define KernelPackage/booke-wdt/description
+ Kernel module for PowerPC Book-E Watchdog Timer.
+endef
+
+$(eval $(call KernelPackage,booke-wdt))
+
+
+define KernelPackage/pwm
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=PWM generic API
+ KCONFIG:=CONFIG_GENERIC_PWM
+ FILES:=$(LINUX_DIR)/drivers/pwm/pwm.ko
+ AUTOLOAD:=$(call AutoLoad,50,pwm)
+endef
+
+define KernelPackage/pwm/description
+ Kernel module that implement a generic PWM API
+endef
+
+$(eval $(call KernelPackage,pwm))
+
+
+define KernelPackage/pwm-gpio
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=PWM over GPIO
+ DEPENDS:=+kmod-pwm
+ KCONFIG:=CONFIG_GPIO_PWM
+ FILES:=$(LINUX_DIR)/drivers/pwm/gpio-pwm.ko
+ AUTOLOAD:=$(call AutoLoad,51,gpio-pwm)
+endef
+
+define KernelPackage/pwm-gpio/description
+ Kernel module to models a single-channel PWM device using a timer and a GPIO pin
+endef
+
+$(eval $(call KernelPackage,pwm-gpio))
+
+
+define KernelPackage/rtc-isl1208
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=Intersil ISL1208 RTC support
+ $(call AddDepends/rtc)
+ DEPENDS+=+kmod-i2c-core
+ KCONFIG:=CONFIG_RTC_DRV_ISL1208
+ FILES:=$(LINUX_DIR)/drivers/rtc/rtc-isl1208.ko
+ AUTOLOAD:=$(call AutoLoad,60,rtc-isl1208)
+endef
+
+define KernelPackage/rtc-isl1208/description
+ Kernel module for Intersil ISL1208 RTC.
+endef
+
+$(eval $(call KernelPackage,rtc-isl1208))
+
+
+define KernelPackage/rtc-marvell
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=Marvell SoC built-in RTC support
+ $(call AddDepends/rtc)
+ DEPENDS+=@TARGET_kirkwood||TARGET_orion||TARGET_mvebu
+ KCONFIG:=CONFIG_RTC_DRV_MV
+ FILES:=$(LINUX_DIR)/drivers/rtc/rtc-mv.ko
+ AUTOLOAD:=$(call AutoLoad,60,rtc-mv)
+endef
+
+define KernelPackage/rtc-marvell/description
+ Kernel module for Marvell SoC built-in RTC.
+endef
+
+$(eval $(call KernelPackage,rtc-marvell))
+
+define KernelPackage/rtc-pcf8563
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=Philips PCF8563/Epson RTC8564 RTC support
+ $(call AddDepends/rtc)
+ KCONFIG:=CONFIG_RTC_DRV_PCF8563
+ FILES:=$(LINUX_DIR)/drivers/rtc/rtc-pcf8563.ko
+ AUTOLOAD:=$(call AutoLoad,60,rtc-pcf8563)
+endef
+
+define KernelPackage/rtc-pcf8563/description
+ Kernel module for Philips PCF8563 RTC chip.
+ The Epson RTC8564 should work as well.
+endef
+
+$(eval $(call KernelPackage,rtc-pcf8563))
+
+
+define KernelPackage/rtc-pcf2123
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=Philips PCF2123 RTC support
+ $(call AddDepends/rtc)
+ KCONFIG:=CONFIG_RTC_DRV_PCF2123
+ FILES:=$(LINUX_DIR)/drivers/rtc/rtc-pcf2123.ko
+ AUTOLOAD:=$(call AutoLoad,60,rtc-pcf2123)
+endef
+
+define KernelPackage/rtc-pcf2123/description
+ Kernel module for Philips PCF2123 RTC chip.
+endef
+
+$(eval $(call KernelPackage,rtc-pcf2123))
+
+define KernelPackage/rtc-pt7c4338
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=Pericom PT7C4338 RTC support
+ $(call AddDepends/rtc,+kmod-i2c-core)
+ KCONFIG:=CONFIG_RTC_DRV_PT7C4338
+ FILES:=$(LINUX_DIR)/drivers/rtc/rtc-pt7c4338.ko
+ AUTOLOAD:=$(call AutoLoad,60,rtc-pt7c4338)
+endef
+
+define KernelPackage/rtc-pt7c4338/description
+ Kernel module for Pericom PT7C4338 i2c RTC chip.
+endef
+
+$(eval $(call KernelPackage,rtc-pt7c4338))
+
+
+define KernelPackage/mtdtests
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=MTD subsystem tests
+ KCONFIG:=CONFIG_MTD_TESTS
+ FILES:=\
+ $(LINUX_DIR)/drivers/mtd/tests/mtd_nandecctest.ko \
+ $(LINUX_DIR)/drivers/mtd/tests/mtd_oobtest.ko \
+ $(LINUX_DIR)/drivers/mtd/tests/mtd_pagetest.ko \
+ $(LINUX_DIR)/drivers/mtd/tests/mtd_readtest.ko \
+ $(LINUX_DIR)/drivers/mtd/tests/mtd_speedtest.ko \
+ $(LINUX_DIR)/drivers/mtd/tests/mtd_stresstest.ko \
+ $(LINUX_DIR)/drivers/mtd/tests/mtd_subpagetest.ko \
+ $(LINUX_DIR)/drivers/mtd/tests/mtd_torturetest.ko
+endef
+
+define KernelPackage/mtdtests/description
+ Kernel modules for MTD subsystem/driver testing.
+endef
+
+$(eval $(call KernelPackage,mtdtests))
+
+
+define KernelPackage/nand
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=NAND flash support
+ KCONFIG:=CONFIG_MTD_NAND \
+ CONFIG_MTD_NAND_IDS \
+ CONFIG_MTD_NAND_ECC
+ FILES:= \
+ $(LINUX_DIR)/drivers/mtd/nand/nand_ids.ko \
+ $(LINUX_DIR)/drivers/mtd/nand/nand_ecc.ko \
+ $(LINUX_DIR)/drivers/mtd/nand/nand.ko
+ AUTOLOAD:=$(call AutoLoad,20,nand_ids nand_ecc nand)
+endef
+
+define KernelPackage/nand/description
+ Kernel module for NAND support.
+endef
+
+$(eval $(call KernelPackage,nand))
+
+
+define KernelPackage/nandsim
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=NAND simulator
+ DEPENDS:=+kmod-nand
+ KCONFIG:=CONFIG_MTD_NAND_NANDSIM
+ FILES:=$(LINUX_DIR)/drivers/mtd/nand/nandsim.ko
+endef
+
+define KernelPackage/nandsim/description
+ Kernel module for NAND flash simulation.
+endef
+
+$(eval $(call KernelPackage,nandsim))
+
+define KernelPackage/serial-8250
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=8250 UARTs
+ KCONFIG:= CONFIG_SERIAL_8250 \
+ CONFIG_SERIAL_8250_NR_UARTS=16 \
+ CONFIG_SERIAL_8250_RUNTIME_UARTS=16 \
+ CONFIG_SERIAL_8250_EXTENDED=y \
+ CONFIG_SERIAL_8250_MANY_PORTS=y \
+ CONFIG_SERIAL_8250_SHARE_IRQ=y \
+ CONFIG_SERIAL_8250_DETECT_IRQ=n \
+ CONFIG_SERIAL_8250_RSA=n
+ FILES:=$(LINUX_DIR)/drivers/tty/serial/8250/8250$(if $(call kernel_patchver_ge,3.7),_core).ko
+endef
+
+define KernelPackage/serial-8250/description
+ Kernel module for 8250 UART based serial ports.
+endef
+
+$(eval $(call KernelPackage,serial-8250))
+
+
+define KernelPackage/regmap
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=Generic register map support
+ DEPENDS:=+kmod-lib-lzo +kmod-i2c-core
+ KCONFIG:=CONFIG_REGMAP \
+ CONFIG_REGMAP_SPI \
+ CONFIG_REGMAP_I2C \
+ CONFIG_SPI=y
+ FILES:= \
+ $(LINUX_DIR)/drivers/base/regmap/regmap-core.ko \
+ $(LINUX_DIR)/drivers/base/regmap/regmap-i2c.ko \
+ $(LINUX_DIR)/drivers/base/regmap/regmap-spi.ko
+ AUTOLOAD:=$(call AutoLoad,10,regmap-core regmap-i2c regmap-spi)
+endef
+
+define KernelPackage/regmap/description
+ Generic register map support
+endef
+
+$(eval $(call KernelPackage,regmap))
+
+define KernelPackage/ikconfig
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=Kernel configuration via /proc/config.gz
+ KCONFIG:=CONFIG_IKCONFIG \
+ CONFIG_IKCONFIG_PROC=y
+ FILES:=$(LINUX_DIR)/kernel/configs.ko
+ AUTOLOAD:=$(call AutoLoad,70,configs)
+endef
+
+define KernelPackage/ikconfig/description
+ Kernel configuration via /proc/config.gz
+endef
+
+$(eval $(call KernelPackage,ikconfig))
+
+
+define KernelPackage/zram
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=ZRAM
+ DEPENDS:=@!LINUX_3_3 +kmod-lib-lzo
+ KCONFIG:= \
+ CONFIG_ZSMALLOC \
+ CONFIG_ZRAM \
+ CONFIG_ZRAM_DEBUG=n
+ FILES:= \
+ $(LINUX_DIR)/drivers/staging/zsmalloc/zsmalloc.ko \
+ $(LINUX_DIR)/drivers/staging/zram/zram.ko
+ AUTOLOAD:=$(call AutoLoad,20,zsmalloc zram)
+endef
+
+define KernelPackage/zram/description
+ Compressed RAM block device support
+endef
+
+$(eval $(call KernelPackage,zram))
+
+
+define KernelPackage/mvsdio
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=Marvell SDIO support
+ DEPENDS:=@TARGET_orion||TARGET_kirkwood||TARGET_mvebu +kmod-mmc
+ KCONFIG:=CONFIG_MMC_MVSDIO
+ FILES:=$(LINUX_DIR)/drivers/mmc/host/mvsdio.ko
+ AUTOLOAD:=$(call AutoLoad,91,mvsdio)
+endef
+
+define KernelPacakge/mvsdio/description
+ Kernel support for the Marvell SDIO controller
+endef
+
+$(eval $(call KernelPackage,mvsdio))
+
+
+define KernelPackage/pps
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=PPS support
+ KCONFIG:=CONFIG_PPS
+ FILES:=$(LINUX_DIR)/drivers/pps/pps_core.ko
+ AUTOLOAD:=$(call AutoLoad,20,pps_core)
+endef
+
+define KernelPacakge/pps/description
+ PPS (Pulse Per Second) is a special pulse provided by some GPS
+ antennae. Userland can use it to get a high-precision time
+ reference.
+endef
+
+$(eval $(call KernelPackage,pps))
+
+
+define KernelPackage/ptp
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=PTP clock support
+ DEPENDS:=+kmod-pps
+ KCONFIG:=CONFIG_PTP_1588_CLOCK
+ FILES:=$(LINUX_DIR)/drivers/ptp/ptp.ko
+ AUTOLOAD:=$(call AutoLoad,25,ptp)
+endef
+
+define KernelPacakge/ptp/description
+ The IEEE 1588 standard defines a method to precisely
+ synchronize distributed clocks over Ethernet networks.
+endef
+
+$(eval $(call KernelPackage,ptp))
+
+
+define KernelPackage/ptp-gianfar
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=Freescale Gianfar PTP support
+ DEPENDS:=@TARGET_mpc85xx +kmod-gianfar +kmod-ptp
+ KCONFIG:=CONFIG_PTP_1588_CLOCK_GIANFAR
+ FILES:=$(LINUX_DIR)/drivers/net/ethernet/freescale/gianfar_ptp.ko
+ AUTOLOAD:=$(call AutoLoad,51,gianfar_ptp)
+endef
+
+define KernelPacakge/ptp-gianfar/description
+ Kernel module for IEEE 1588 support for Freescale
+ Gianfar Ethernet drivers.
+endef
+
+$(eval $(call KernelPackage,ptp-gianfar))
diff --git a/package/kernel/modules/.svn/text-base/pcmcia.mk.svn-base b/package/kernel/modules/.svn/text-base/pcmcia.mk.svn-base
new file mode 100644
index 0000000..cac7277
--- /dev/null
+++ b/package/kernel/modules/.svn/text-base/pcmcia.mk.svn-base
@@ -0,0 +1,80 @@
+#
+# Copyright (C) 2006-2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+PCMCIA_MENU:=PCMCIA support
+
+define KernelPackage/pcmcia-core
+ SUBMENU:=$(PCMCIA_MENU)
+ TITLE:=PCMCIA/CardBus support
+ DEPENDS:=@PCMCIA_SUPPORT
+ KCONFIG:= \
+ CONFIG_PCMCIA \
+ CONFIG_CARDBUS \
+ CONFIG_PCCARD \
+ PCMCIA_DEBUG=n
+ FILES:= \
+ $(LINUX_DIR)/drivers/pcmcia/pcmcia_core.ko \
+ $(LINUX_DIR)/drivers/pcmcia/pcmcia.ko
+ AUTOLOAD:=$(call AutoLoad,25,pcmcia_core pcmcia)
+endef
+
+define KernelPackage/pcmcia-core/description
+ Kernel support for PCMCIA/CardBus controllers
+endef
+
+$(eval $(call KernelPackage,pcmcia-core))
+
+define KernelPackage/pcmcia-rsrc
+ SUBMENU:=$(PCMCIA_MENU)
+ TITLE:=PCMCIA resource support
+ DEPENDS:=kmod-pcmcia-core
+ KCONFIG:=CONFIG_PCCARD_NONSTATIC=y
+# For Linux 2.6.35+
+ifneq ($(wildcard $(LINUX_DIR)/drivers/pcmcia/pcmcia_rsrc.ko),)
+ FILES:=$(LINUX_DIR)/drivers/pcmcia/pcmcia_rsrc.ko
+ AUTOLOAD:=$(call AutoLoad,26,pcmcia_rsrc)
+else
+ FILES:=$(LINUX_DIR)/drivers/pcmcia/rsrc_nonstatic.ko
+ AUTOLOAD:=$(call AutoLoad,26,rsrc_nonstatic)
+endif
+endef
+
+define KernelPackage/pcmcia-rsrc/description
+ Kernel support for PCMCIA resource allocation
+endef
+
+$(eval $(call KernelPackage,pcmcia-rsrc))
+
+
+define KernelPackage/pcmcia-yenta
+ SUBMENU:=$(PCMCIA_MENU)
+ TITLE:=yenta socket driver
+ DEPENDS:=kmod-pcmcia-rsrc
+ KCONFIG:=CONFIG_YENTA
+ FILES:=$(LINUX_DIR)/drivers/pcmcia/yenta_socket.ko
+ AUTOLOAD:=$(call AutoLoad,41,pcmcia_rsrc yenta_socket)
+endef
+
+$(eval $(call KernelPackage,pcmcia-yenta))
+
+
+define KernelPackage/pcmcia-serial
+ SUBMENU:=$(PCMCIA_MENU)
+ TITLE:=Serial devices support
+ DEPENDS:=kmod-pcmcia-core
+ KCONFIG:= \
+ CONFIG_PCMCIA_SERIAL_CS \
+ CONFIG_SERIAL_8250_CS
+ FILES:=$(LINUX_DIR)/drivers/tty/serial/8250/serial_cs.ko
+ AUTOLOAD:=$(call AutoLoad,45,serial_cs)
+endef
+
+define KernelPackage/pcmcia-serial/description
+ Kernel support for PCMCIA/CardBus serial devices
+endef
+
+$(eval $(call KernelPackage,pcmcia-serial))
diff --git a/package/kernel/modules/.svn/text-base/sound.mk.svn-base b/package/kernel/modules/.svn/text-base/sound.mk.svn-base
new file mode 100644
index 0000000..877d31b
--- /dev/null
+++ b/package/kernel/modules/.svn/text-base/sound.mk.svn-base
@@ -0,0 +1,211 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+SOUND_MENU:=Sound Support
+
+# allow targets to override the soundcore stuff
+SOUNDCORE_LOAD ?= \
+ soundcore \
+ snd \
+ snd-page-alloc \
+ snd-hwdep \
+ snd-seq-device \
+ snd-rawmidi \
+ snd-timer \
+ snd-pcm \
+ snd-mixer-oss \
+ snd-pcm-oss
+
+SOUNDCORE_FILES ?= \
+ $(LINUX_DIR)/sound/soundcore.ko \
+ $(LINUX_DIR)/sound/core/snd.ko \
+ $(LINUX_DIR)/sound/core/snd-page-alloc.ko \
+ $(LINUX_DIR)/sound/core/snd-hwdep.ko \
+ $(LINUX_DIR)/sound/core/seq/snd-seq-device.ko \
+ $(LINUX_DIR)/sound/core/snd-rawmidi.ko \
+ $(LINUX_DIR)/sound/core/snd-timer.ko \
+ $(LINUX_DIR)/sound/core/snd-pcm.ko \
+ $(LINUX_DIR)/sound/core/oss/snd-mixer-oss.ko \
+ $(LINUX_DIR)/sound/core/oss/snd-pcm-oss.ko
+
+define KernelPackage/sound-core
+ SUBMENU:=$(SOUND_MENU)
+ TITLE:=Sound support
+ DEPENDS:=@AUDIO_SUPPORT
+ KCONFIG:= \
+ CONFIG_SOUND \
+ CONFIG_SND \
+ CONFIG_SND_HWDEP \
+ CONFIG_SND_RAWMIDI \
+ CONFIG_SND_TIMER \
+ CONFIG_SND_PCM \
+ CONFIG_SND_SEQUENCER \
+ CONFIG_SND_VIRMIDI \
+ CONFIG_SND_SEQ_DUMMY \
+ CONFIG_SND_SEQUENCER_OSS=y \
+ CONFIG_HOSTAUDIO \
+ CONFIG_SND_PCM_OSS \
+ CONFIG_SND_MIXER_OSS \
+ CONFIG_SOUND_OSS_CORE_PRECLAIM=y
+ FILES:=$(SOUNDCORE_FILES)
+ AUTOLOAD:=$(call AutoLoad,30,$(SOUNDCORE_LOAD))
+ $(call AddDepends/input)
+endef
+
+define KernelPackage/sound-core/uml
+ FILES:= \
+ $(LINUX_DIR)/sound/soundcore.ko \
+ $(LINUX_DIR)/arch/um/drivers/hostaudio.ko
+ AUTOLOAD:=$(call AutoLoad,30,soundcore hostaudio)
+endef
+
+define KernelPackage/sound-core/description
+ Kernel modules for sound support
+endef
+
+$(eval $(call KernelPackage,sound-core))
+
+
+define AddDepends/sound
+ SUBMENU:=$(SOUND_MENU)
+ DEPENDS+=kmod-sound-core $(1) @!TARGET_uml
+endef
+
+
+define KernelPackage/ac97
+ TITLE:=ac97 controller
+ KCONFIG:=CONFIG_SND_AC97_CODEC
+ FILES:= \
+ $(LINUX_DIR)/sound/ac97_bus.ko \
+ $(LINUX_DIR)/sound/pci/ac97/snd-ac97-codec.ko
+ AUTOLOAD:=$(call AutoLoad,35,ac97_bus snd-ac97-codec)
+ $(call AddDepends/sound)
+endef
+
+define KernelPackage/ac97/description
+ The ac97 controller
+endef
+
+$(eval $(call KernelPackage,ac97))
+
+
+define KernelPackage/sound-seq
+ TITLE:=Sequencer support
+ FILES:= \
+ $(LINUX_DIR)/sound/core/seq/snd-seq.ko \
+ $(LINUX_DIR)/sound/core/seq/snd-seq-midi-event.ko \
+ $(LINUX_DIR)/sound/core/seq/snd-seq-midi.ko
+ AUTOLOAD:=$(call AutoLoad,35,snd-seq snd-seq-midi-event snd-seq-midi)
+ $(call AddDepends/sound)
+endef
+
+define KernelPackage/sound-seq/description
+ Kernel modules for sequencer support
+endef
+
+$(eval $(call KernelPackage,sound-seq))
+
+
+define KernelPackage/sound-i8x0
+ TITLE:=Intel/SiS/nVidia/AMD/ALi AC97 Controller
+ DEPENDS:=+kmod-ac97
+ KCONFIG:=CONFIG_SND_INTEL8X0
+ FILES:=$(LINUX_DIR)/sound/pci/snd-intel8x0.ko
+ AUTOLOAD:=$(call AutoLoad,36,snd-intel8x0)
+ $(call AddDepends/sound)
+endef
+
+define KernelPackage/sound-i8x0/description
+ support for the integrated AC97 sound device on motherboards
+ with Intel/SiS/nVidia/AMD chipsets, or ALi chipsets using
+ the M5455 Audio Controller.
+endef
+
+$(eval $(call KernelPackage,sound-i8x0))
+
+
+define KernelPackage/sound-cs5535audio
+ TITLE:=CS5535 PCI Controller
+ DEPENDS:=+kmod-ac97
+ KCONFIG:=CONFIG_SND_CS5535AUDIO
+ FILES:=$(LINUX_DIR)/sound/pci/cs5535audio/snd-cs5535audio.ko
+ AUTOLOAD:=$(call AutoLoad,36,snd-cs5535audio)
+ $(call AddDepends/sound)
+endef
+
+define KernelPackage/sound-cs5535audio/description
+ support for the integrated AC97 sound device on olpc
+endef
+
+$(eval $(call KernelPackage,sound-cs5535audio))
+
+
+define KernelPackage/sound-soc-core
+ TITLE:=SoC sound support
+ DEPENDS:=+kmod-regmap
+ KCONFIG:= \
+ CONFIG_SND_SOC \
+ CONFIG_SND_SOC_DMAENGINE_PCM=y \
+ CONFIG_SND_SOC_ALL_CODECS=n
+ FILES:=$(LINUX_DIR)/sound/soc/snd-soc-core.ko
+ AUTOLOAD:=$(call AutoLoad,55, snd-soc-core)
+ $(call AddDepends/sound)
+endef
+
+$(eval $(call KernelPackage,sound-soc-core))
+
+
+define KernelPackage/sound-soc-ac97
+ TITLE:=AC97 Codec support
+ KCONFIG:=CONFIG_SND_SOC_AC97_CODEC
+ FILES:=$(LINUX_DIR)/sound/soc/codecs/snd-soc-ac97.ko
+ AUTOLOAD:=$(call AutoLoad,57,snd-soc-ac97)
+ DEPENDS:=+kmod-ac97 +kmod-sound-soc-core
+ $(call AddDepends/sound)
+endef
+
+$(eval $(call KernelPackage,sound-soc-ac97))
+
+
+define KernelPackage/sound-soc-gw_avila
+ TITLE:=Gateworks Avila SoC sound support
+ KCONFIG:= \
+ CONFIG_SND_GW_AVILA_SOC \
+ CONFIG_SND_GW_AVILA_SOC_PCM \
+ CONFIG_SND_GW_AVILA_SOC_HSS
+ FILES:= \
+ $(LINUX_DIR)/sound/soc/codecs/snd-soc-tlv320aic3x.ko \
+ $(LINUX_DIR)/sound/soc/gw-avila/snd-soc-gw-avila.ko \
+ $(LINUX_DIR)/sound/soc/gw-avila/snd-soc-gw-avila-pcm.ko \
+ $(LINUX_DIR)/sound/soc/gw-avila/snd-soc-gw-avila-hss.ko
+ AUTOLOAD:=$(call AutoLoad,65,snd-soc-tlv320aic3x snd-soc-gw-avila snd-soc-gw-avila-pcm snd-soc-gw-avila-hss)
+ DEPENDS:=@TARGET_ixp4xx +kmod-sound-soc-core
+ $(call AddDepends/sound)
+endef
+
+$(eval $(call KernelPackage,sound-soc-gw_avila))
+
+
+define KernelPackage/pcspkr
+ DEPENDS:=@!TARGET_x86
+ TITLE:=PC speaker support
+ KCONFIG:= \
+ CONFIG_INPUT_PCSPKR \
+ CONFIG_SND_PCSP
+ FILES:= \
+ $(LINUX_DIR)/drivers/input/misc/pcspkr.ko \
+ $(LINUX_DIR)/sound/drivers/pcsp/snd-pcsp.ko
+ AUTOLOAD:=$(call AutoLoad,50,pcspkr snd-pcsp)
+ $(call AddDepends/input)
+ $(call AddDepends/sound)
+endef
+
+define KernelPackage/pcspkr/description
+ This enables sounds (tones) through the pc speaker
+endef
+
+$(eval $(call KernelPackage,pcspkr))
diff --git a/package/kernel/modules/.svn/text-base/spi.mk.svn-base b/package/kernel/modules/.svn/text-base/spi.mk.svn-base
new file mode 100644
index 0000000..4162098
--- /dev/null
+++ b/package/kernel/modules/.svn/text-base/spi.mk.svn-base
@@ -0,0 +1,90 @@
+#
+# Copyright (C) 2006-2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+SPI_MENU:=SPI Support
+
+define KernelPackage/mmc-spi
+ SUBMENU:=$(SPI_MENU)
+ TITLE:=MMC/SD over SPI Support
+ DEPENDS:=+kmod-mmc +kmod-lib-crc-itu-t +kmod-lib-crc7
+ KCONFIG:=CONFIG_MMC_SPI \
+ CONFIG_SPI=y \
+ CONFIG_SPI_MASTER=y
+ FILES:=$(LINUX_DIR)/drivers/mmc/host/mmc_spi.ko
+ AUTOLOAD:=$(call AutoLoad,90,mmc_spi)
+endef
+
+define KernelPackage/mmc-spi/description
+ Kernel support for MMC/SD over SPI
+endef
+
+$(eval $(call KernelPackage,mmc-spi))
+
+
+define KernelPackage/spi-bitbang
+ SUBMENU:=$(SPI_MENU)
+ TITLE:=Serial Peripheral Interface bitbanging library
+ KCONFIG:=CONFIG_SPI_BITBANG \
+ CONFIG_SPI=y \
+ CONFIG_SPI_MASTER=y
+ FILES:=$(LINUX_DIR)/drivers/spi/spi-bitbang.ko
+ AUTOLOAD:=$(call AutoLoad,91,spi-bitbang)
+endef
+
+define KernelPackage/spi-bitbang/description
+ This package contains the SPI bitbanging library
+endef
+
+$(eval $(call KernelPackage,spi-bitbang))
+
+
+define KernelPackage/spi-gpio-old
+ SUBMENU:=$(SPI_MENU)
+ TITLE:=Old GPIO based bitbanging SPI controller (DEPRECATED)
+ DEPENDS:=@GPIO_SUPPORT +kmod-spi-bitbang
+ KCONFIG:=CONFIG_SPI_GPIO_OLD
+ FILES:=$(LINUX_DIR)/drivers/spi/spi_gpio_old.ko
+ AUTOLOAD:=$(call AutoLoad,92,spi_gpio_old)
+endef
+
+define KernelPackage/spi-gpio-old/description
+ This package contains the GPIO based bitbanging SPI controller driver
+endef
+
+$(eval $(call KernelPackage,spi-gpio-old))
+
+define KernelPackage/spi-gpio
+ SUBMENU:=$(SPI_MENU)
+ TITLE:=GPIO-based bitbanging SPI Master
+ DEPENDS:=@GPIO_SUPPORT +kmod-spi-bitbang
+ KCONFIG:=CONFIG_SPI_GPIO
+ FILES:=$(LINUX_DIR)/drivers/spi/spi-gpio.ko
+ AUTOLOAD:=$(call AutoLoad,92,spi-gpio)
+endef
+
+define KernelPackage/spi-gpio/description
+ This package contains the GPIO-based bitbanging SPI Master
+endef
+
+$(eval $(call KernelPackage,spi-gpio))
+
+define KernelPackage/spi-dev
+ SUBMENU:=$(SPI_MENU)
+ TITLE:=User mode SPI device driver
+ KCONFIG:=CONFIG_SPI_SPIDEV \
+ CONFIG_SPI=y \
+ CONFIG_SPI_MASTER=y
+ FILES:=$(LINUX_DIR)/drivers/spi/spidev.ko
+ AUTOLOAD:=$(call AutoLoad,93,spidev)
+endef
+
+define KernelPackage/spi-dev/description
+ This package contains the user mode SPI device driver
+endef
+
+$(eval $(call KernelPackage,spi-dev))
+
diff --git a/package/kernel/modules/.svn/text-base/usb.mk.svn-base b/package/kernel/modules/.svn/text-base/usb.mk.svn-base
new file mode 100644
index 0000000..fa6763c
--- /dev/null
+++ b/package/kernel/modules/.svn/text-base/usb.mk.svn-base
@@ -0,0 +1,985 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+USB_MENU:=USB Support
+
+USBNET_DIR:=net/usb
+USBHID_DIR?=hid/usbhid
+USBINPUT_DIR?=input/misc
+
+define KernelPackage/usb-core
+ SUBMENU:=$(USB_MENU)
+ TITLE:=Support for USB
+ DEPENDS:=@USB_SUPPORT
+ KCONFIG:=CONFIG_USB CONFIG_XPS_USB_HCD_XILINX=n CONFIG_USB_FHCI_HCD=n
+ FILES:= \
+ $(LINUX_DIR)/drivers/usb/core/usbcore.ko \
+ $(LINUX_DIR)/drivers/usb/usb-common.ko
+ AUTOLOAD:=$(call AutoLoad,20,usb-common usbcore,1)
+ $(call AddDepends/nls)
+endef
+
+define KernelPackage/usb-core/description
+ Kernel support for USB
+endef
+
+$(eval $(call KernelPackage,usb-core))
+
+
+define AddDepends/usb
+ SUBMENU:=$(USB_MENU)
+ DEPENDS+=+kmod-usb-core $(1)
+endef
+
+
+define KernelPackage/usb-gadget
+ TITLE:=USB Gadget support
+ KCONFIG:=CONFIG_USB_GADGET
+ FILES:=
+ AUTOLOAD:=
+ DEPENDS:=@USB_GADGET_SUPPORT
+ $(call AddDepends/usb)
+endef
+
+define KernelPackage/usb-gadget/description
+ Kernel support for USB Gadget mode.
+endef
+
+$(eval $(call KernelPackage,usb-gadget))
+
+
+define KernelPackage/usb-eth-gadget
+ TITLE:=USB Ethernet Gadget support
+ KCONFIG:= \
+ CONFIG_USB_ETH \
+ CONFIG_USB_ETH_RNDIS=y \
+ CONFIG_USB_ETH_EEM=y
+ DEPENDS:=+kmod-usb-gadget
+ FILES:=$(LINUX_DIR)/drivers/usb/gadget/g_ether.ko
+ AUTOLOAD:=$(call AutoLoad,52,g_ether)
+ $(call AddDepends/usb)
+endef
+
+define KernelPackage/usb-eth-gadget/description
+ Kernel support for USB Ethernet Gadget.
+endef
+
+$(eval $(call KernelPackage,usb-eth-gadget))
+
+
+define KernelPackage/usb-uhci
+ TITLE:=Support for UHCI controllers
+ KCONFIG:= \
+ CONFIG_USB_UHCI_ALT \
+ CONFIG_USB_UHCI_HCD
+ FILES:=$(LINUX_DIR)/drivers/usb/host/uhci-hcd.ko
+ AUTOLOAD:=$(call AutoLoad,50,uhci-hcd,1)
+ $(call AddDepends/usb)
+endef
+
+define KernelPackage/usb-uhci/description
+ Kernel support for USB UHCI controllers
+endef
+
+$(eval $(call KernelPackage,usb-uhci,1))
+
+
+define KernelPackage/usb-ohci
+ TITLE:=Support for OHCI controllers
+ DEPENDS:=+TARGET_brcm47xx:kmod-usb-brcm47xx
+ KCONFIG:= \
+ CONFIG_USB_OHCI \
+ CONFIG_USB_OHCI_HCD \
+ CONFIG_USB_OHCI_ATH79=y \
+ CONFIG_USB_OHCI_BCM63XX=y \
+ CONFIG_USB_OCTEON_OHCI=y \
+ CONFIG_USB_OHCI_HCD_PLATFORM=y
+ FILES:=$(LINUX_DIR)/drivers/usb/host/ohci-hcd.ko
+ AUTOLOAD:=$(call AutoLoad,50,ohci-hcd,1)
+ $(call AddDepends/usb)
+endef
+
+define KernelPackage/usb-ohci/description
+ Kernel support for USB OHCI controllers
+endef
+
+$(eval $(call KernelPackage,usb-ohci,1))
+
+
+define KernelPackage/usb2-fsl
+ TITLE:=Support for Freescale USB2 controllers
+ DEPENDS:=TARGET_mpc85xx
+ KCONFIG:=\
+ CONFIG_USB_FSL_MPH_DR_OF \
+ CONFIG_USB_EHCI_FSL=y
+ FILES:=$(LINUX_DIR)/drivers/usb/host/fsl-mph-dr-of.ko
+ AUTOLOAD:=$(call AutoLoad,39,fsl-mph-dr-of,1)
+ $(call AddDepends/usb)
+endef
+
+define KernelPackage/usb2-fsl/description
+ Kernel support for Freescale USB2 (EHCI) controllers
+endef
+
+$(eval $(call KernelPackage,usb2-fsl))
+
+
+define KernelPackage/usb2
+ TITLE:=Support for USB2 controllers
+ DEPENDS:=+TARGET_brcm47xx:kmod-usb-brcm47xx +TARGET_mpc85xx:kmod-usb2-fsl
+ KCONFIG:=CONFIG_USB_EHCI_HCD \
+ CONFIG_USB_EHCI_ATH79=y \
+ CONFIG_USB_EHCI_BCM63XX=y \
+ CONFIG_USB_OCTEON_EHCI=y \
+ CONFIG_USB_EHCI_HCD_PLATFORM=y
+ifeq ($(strip $(call CompareKernelPatchVer,$(KERNEL_PATCHVER),ge,3.8.0)),1)
+ FILES:= \
+ $(LINUX_DIR)/drivers/usb/host/ehci-hcd.ko \
+ $(LINUX_DIR)/drivers/usb/host/ehci-platform.ko
+ AUTOLOAD:=$(call AutoLoad,40,ehci-hcd ehci-platform,1)
+else
+ FILES:=$(LINUX_DIR)/drivers/usb/host/ehci-hcd.ko
+ AUTOLOAD:=$(call AutoLoad,40,ehci-hcd,1)
+endif
+ $(call AddDepends/usb)
+endef
+
+define KernelPackage/usb2/description
+ Kernel support for USB2 (EHCI) controllers
+endef
+
+$(eval $(call KernelPackage,usb2))
+
+
+define KernelPackage/usb2-pci
+ TITLE:=Support for PCI USB2 controllers
+ DEPENDS:=@PCI_SUPPORT @LINUX_3_8 +kmod-usb2
+ KCONFIG:=CONFIG_USB_EHCI_PCI
+ FILES:=$(LINUX_DIR)/drivers/usb/host/ehci-pci.ko
+ AUTOLOAD:=$(call AutoLoad,42,ehci-pci,1)
+ $(call AddDepends/usb)
+endef
+
+define KernelPackage/usb2-pci/description
+ Kernel support for PCI USB2 (EHCI) controllers
+endef
+
+$(eval $(call KernelPackage,usb2-pci))
+
+
+define KernelPackage/usb-acm
+ TITLE:=Support for modems/isdn controllers
+ KCONFIG:=CONFIG_USB_ACM
+ FILES:=$(LINUX_DIR)/drivers/usb/class/cdc-acm.ko
+ AUTOLOAD:=$(call AutoLoad,60,cdc-acm)
+$(call AddDepends/usb)
+endef
+
+define KernelPackage/usb-acm/description
+ Kernel support for USB ACM devices (modems/isdn controllers)
+endef
+
+$(eval $(call KernelPackage,usb-acm))
+
+
+define KernelPackage/usb-wdm
+ TITLE:=USB Wireless Device Management
+ KCONFIG:=CONFIG_USB_WDM
+ FILES:=$(LINUX_DIR)/drivers/usb/class/cdc-wdm.ko
+ AUTOLOAD:=$(call AutoLoad,60,cdc-wdm)
+$(call AddDepends/usb)
+$(call AddDepends/usb-net)
+endef
+
+define KernelPackage/usb-wdm/description
+ USB Wireless Device Management support
+endef
+
+$(eval $(call KernelPackage,usb-wdm))
+
+
+define KernelPackage/usb-audio
+ TITLE:=Support for USB audio devices
+ KCONFIG:= \
+ CONFIG_USB_AUDIO \
+ CONFIG_SND_USB_AUDIO
+ $(call AddDepends/usb)
+ $(call AddDepends/sound)
+# For Linux 2.6.35+
+ifneq ($(wildcard $(LINUX_DIR)/sound/usb/snd-usbmidi-lib.ko),)
+ FILES:= \
+ $(LINUX_DIR)/sound/usb/snd-usbmidi-lib.ko \
+ $(LINUX_DIR)/sound/usb/snd-usb-audio.ko
+ AUTOLOAD:=$(call AutoLoad,60,snd-usbmidi-lib snd-usb-audio)
+else
+ FILES:= \
+ $(LINUX_DIR)/sound/usb/snd-usb-lib.ko \
+ $(LINUX_DIR)/sound/usb/snd-usb-audio.ko
+ AUTOLOAD:=$(call AutoLoad,60,snd-usb-lib snd-usb-audio)
+endif
+endef
+
+define KernelPackage/usb-audio/description
+ Kernel support for USB audio devices
+endef
+
+$(eval $(call KernelPackage,usb-audio))
+
+
+define KernelPackage/usb-printer
+ TITLE:=Support for printers
+ KCONFIG:=CONFIG_USB_PRINTER
+ FILES:=$(LINUX_DIR)/drivers/usb/class/usblp.ko
+ AUTOLOAD:=$(call AutoLoad,60,usblp)
+ $(call AddDepends/usb)
+endef
+
+define KernelPackage/usb-printer/description
+ Kernel support for USB printers
+endef
+
+$(eval $(call KernelPackage,usb-printer))
+
+
+define KernelPackage/usb-serial
+ TITLE:=Support for USB-to-Serial converters
+ KCONFIG:=CONFIG_USB_SERIAL
+ FILES:=$(LINUX_DIR)/drivers/usb/serial/usbserial.ko
+ AUTOLOAD:=$(call AutoLoad,60,usbserial)
+ $(call AddDepends/usb)
+endef
+
+define KernelPackage/usb-serial/description
+ Kernel support for USB-to-Serial converters
+endef
+
+$(eval $(call KernelPackage,usb-serial))
+
+
+define AddDepends/usb-serial
+ SUBMENU:=$(USB_MENU)
+ DEPENDS+=kmod-usb-serial $(1)
+endef
+
+
+define KernelPackage/usb-serial-belkin
+ TITLE:=Support for Belkin devices
+ KCONFIG:=CONFIG_USB_SERIAL_BELKIN
+ FILES:=$(LINUX_DIR)/drivers/usb/serial/belkin_sa.ko
+ AUTOLOAD:=$(call AutoLoad,65,belkin_sa)
+ $(call AddDepends/usb-serial)
+endef
+
+define KernelPackage/usb-serial-belkin/description
+ Kernel support for Belkin USB-to-Serial converters
+endef
+
+$(eval $(call KernelPackage,usb-serial-belkin))
+
+
+define KernelPackage/usb-serial-ch341
+ TITLE:=Support for CH341 devices
+ KCONFIG:=CONFIG_USB_SERIAL_CH341
+ FILES:=$(LINUX_DIR)/drivers/usb/serial/ch341.ko
+ AUTOLOAD:=$(call AutoLoad,65,ch341)
+ $(call AddDepends/usb-serial)
+endef
+
+define KernelPackage/usb-serial-ch341/description
+ Kernel support for Winchiphead CH341 USB-to-Serial converters
+endef
+
+$(eval $(call KernelPackage,usb-serial-ch341))
+
+
+define KernelPackage/usb-serial-ftdi
+ TITLE:=Support for FTDI devices
+ KCONFIG:=CONFIG_USB_SERIAL_FTDI_SIO
+ FILES:=$(LINUX_DIR)/drivers/usb/serial/ftdi_sio.ko
+ AUTOLOAD:=$(call AutoLoad,65,ftdi_sio)
+ $(call AddDepends/usb-serial)
+endef
+
+define KernelPackage/usb-serial-ftdi/description
+ Kernel support for FTDI USB-to-Serial converters
+endef
+
+$(eval $(call KernelPackage,usb-serial-ftdi))
+
+
+define KernelPackage/usb-serial-ti-usb
+ TITLE:=Support for TI USB 3410/5052
+ KCONFIG:=CONFIG_USB_SERIAL_TI
+ FILES:=$(LINUX_DIR)/drivers/usb/serial/ti_usb_3410_5052.ko
+ AUTOLOAD:=$(call AutoLoad,65,ti_usb_3410_5052)
+ $(call AddDepends/usb-serial)
+endef
+
+define KernelPackage/usb-serial-ti-usb/description
+ Kernel support for TI USB 3410/5052 devices
+endef
+
+$(eval $(call KernelPackage,usb-serial-ti-usb))
+
+
+define KernelPackage/usb-serial-ipw
+ TITLE:=Support for IPWireless 3G devices
+ KCONFIG:=CONFIG_USB_SERIAL_IPW
+ FILES:=$(LINUX_DIR)/drivers/usb/serial/ipw.ko
+ AUTOLOAD:=$(call AutoLoad,65,ipw)
+ $(call AddDepends/usb-serial)
+endef
+
+$(eval $(call KernelPackage,usb-serial-ipw))
+
+
+define KernelPackage/usb-serial-mct
+ TITLE:=Support for Magic Control Tech. devices
+ KCONFIG:=CONFIG_USB_SERIAL_MCT_U232
+ FILES:=$(LINUX_DIR)/drivers/usb/serial/mct_u232.ko
+ AUTOLOAD:=$(call AutoLoad,65,mct_u232)
+ $(call AddDepends/usb-serial)
+endef
+
+define KernelPackage/usb-serial-mct/description
+ Kernel support for Magic Control Technology USB-to-Serial converters
+endef
+
+$(eval $(call KernelPackage,usb-serial-mct))
+
+
+define KernelPackage/usb-serial-mos7720
+ TITLE:=Support for Moschip MOS7720 devices
+ KCONFIG:=CONFIG_USB_SERIAL_MOS7720
+ FILES:=$(LINUX_DIR)/drivers/usb/serial/mos7720.ko
+ AUTOLOAD:=$(call AutoLoad,65,mos7720)
+ $(call AddDepends/usb-serial)
+endef
+
+define KernelPackage/usb-serial-mos7720/description
+ Kernel support for Moschip MOS7720 USB-to-Serial converters
+endef
+
+$(eval $(call KernelPackage,usb-serial-mos7720))
+
+
+define KernelPackage/usb-serial-pl2303
+ TITLE:=Support for Prolific PL2303 devices
+ KCONFIG:=CONFIG_USB_SERIAL_PL2303
+ FILES:=$(LINUX_DIR)/drivers/usb/serial/pl2303.ko
+ AUTOLOAD:=$(call AutoLoad,65,pl2303)
+ $(call AddDepends/usb-serial)
+endef
+
+define KernelPackage/usb-serial-pl2303/description
+ Kernel support for Prolific PL2303 USB-to-Serial converters
+endef
+
+$(eval $(call KernelPackage,usb-serial-pl2303))
+
+
+define KernelPackage/usb-serial-cp210x
+ TITLE:=Support for Silicon Labs cp210x devices
+ KCONFIG:=CONFIG_USB_SERIAL_CP210X
+ FILES:=$(LINUX_DIR)/drivers/usb/serial/cp210x.ko
+ AUTOLOAD:=$(call AutoLoad,65,cp210x)
+ $(call AddDepends/usb-serial)
+endef
+
+define KernelPackage/usb-serial-cp210x/description
+ Kernel support for Silicon Labs cp210x USB-to-Serial converters
+endef
+
+$(eval $(call KernelPackage,usb-serial-cp210x))
+
+
+define KernelPackage/usb-serial-ark3116
+ TITLE:=Support for ArkMicroChips ARK3116 devices
+ KCONFIG:=CONFIG_USB_SERIAL_ARK3116
+ FILES:=$(LINUX_DIR)/drivers/usb/serial/ark3116.ko
+ AUTOLOAD:=$(call AutoLoad,65,ark3116)
+ $(call AddDepends/usb-serial)
+endef
+
+define KernelPackage/usb-serial-ark3116/description
+ Kernel support for ArkMicroChips ARK3116 USB-to-Serial converters
+endef
+
+$(eval $(call KernelPackage,usb-serial-ark3116))
+
+
+define KernelPackage/usb-serial-oti6858
+ TITLE:=Support for Ours Technology OTI6858 devices
+ KCONFIG:=CONFIG_USB_SERIAL_OTI6858
+ FILES:=$(LINUX_DIR)/drivers/usb/serial/oti6858.ko
+ AUTOLOAD:=$(call AutoLoad,65,oti6858)
+ $(call AddDepends/usb-serial)
+endef
+
+define KernelPackage/usb-serial-oti6858/description
+ Kernel support for Ours Technology OTI6858 USB-to-Serial converters
+endef
+
+$(eval $(call KernelPackage,usb-serial-oti6858))
+
+
+define KernelPackage/usb-serial-sierrawireless
+ TITLE:=Support for Sierra Wireless devices
+ KCONFIG:=CONFIG_USB_SERIAL_SIERRAWIRELESS
+ FILES:=$(LINUX_DIR)/drivers/usb/serial/sierra.ko
+ AUTOLOAD:=$(call AutoLoad,65,sierra)
+ $(call AddDepends/usb-serial)
+endef
+
+define KernelPackage/usb-serial-sierrawireless/description
+ Kernel support for Sierra Wireless devices
+endef
+
+$(eval $(call KernelPackage,usb-serial-sierrawireless))
+
+
+define KernelPackage/usb-serial-motorola-phone
+ TITLE:=Support for Motorola usb phone
+ KCONFIG:=CONFIG_USB_SERIAL_MOTOROLA
+ FILES:=$(LINUX_DIR)/drivers/usb/serial/moto_modem.ko
+ AUTOLOAD:=$(call AutoLoad,65,moto_modem)
+ $(call AddDepends/usb-serial)
+endef
+
+define KernelPackage/usb-serial-motorola-phone/description
+ Kernel support for Motorola usb phone
+endef
+
+$(eval $(call KernelPackage,usb-serial-motorola-phone))
+
+
+define KernelPackage/usb-serial-visor
+ TITLE:=Support for Handspring Visor devices
+ KCONFIG:=CONFIG_USB_SERIAL_VISOR
+ FILES:=$(LINUX_DIR)/drivers/usb/serial/visor.ko
+ AUTOLOAD:=$(call AutoLoad,65,visor)
+ $(call AddDepends/usb-serial)
+endef
+
+define KernelPackage/usb-serial-visor/description
+ Kernel support for Handspring Visor PDAs
+endef
+
+$(eval $(call KernelPackage,usb-serial-visor))
+
+
+define KernelPackage/usb-serial-cypress-m8
+ TITLE:=Support for CypressM8 USB-Serial
+ KCONFIG:=CONFIG_USB_SERIAL_CYPRESS_M8
+ FILES:=$(LINUX_DIR)/drivers/usb/serial/cypress_m8.ko
+ AUTOLOAD:=$(call AutoLoad,65,cypress_m8)
+ $(call AddDepends/usb-serial)
+endef
+
+define KernelPackage/usb-serial-cypress-m8/description
+ Kernel support for devices with Cypress M8 USB to Serial chip
+ (for example, the Delorme Earthmate LT-20 GPS)
+ Supported microcontrollers in the CY4601 family are:
+ CY7C63741 CY7C63742 CY7C63743 CY7C64013
+endef
+
+$(eval $(call KernelPackage,usb-serial-cypress-m8))
+
+
+define KernelPackage/usb-serial-keyspan
+ TITLE:=Support for Keyspan USB-to-Serial devices
+ KCONFIG:= \
+ CONFIG_USB_SERIAL_KEYSPAN \
+ CONFIG_USB_SERIAL_KEYSPAN_USA28 \
+ CONFIG_USB_SERIAL_KEYSPAN_USA28X \
+ CONFIG_USB_SERIAL_KEYSPAN_USA28XA \
+ CONFIG_USB_SERIAL_KEYSPAN_USA28XB \
+ CONFIG_USB_SERIAL_KEYSPAN_USA19 \
+ CONFIG_USB_SERIAL_KEYSPAN_USA18X \
+ CONFIG_USB_SERIAL_KEYSPAN_USA19W \
+ CONFIG_USB_SERIAL_KEYSPAN_USA19QW \
+ CONFIG_USB_SERIAL_KEYSPAN_USA19QI \
+ CONFIG_USB_SERIAL_KEYSPAN_MPR \
+ CONFIG_USB_SERIAL_KEYSPAN_USA49W \
+ CONFIG_USB_SERIAL_KEYSPAN_USA49WLC
+ FILES:=$(LINUX_DIR)/drivers/usb/serial/keyspan.ko
+ AUTOLOAD:=$(call AutoLoad,65,keyspan)
+ $(call AddDepends/usb-serial)
+endef
+
+define KernelPackage/usb-serial-keyspan/description
+ Kernel support for Keyspan USB-to-Serial devices
+endef
+
+$(eval $(call KernelPackage,usb-serial-keyspan))
+
+
+define KernelPackage/usb-serial-wwan
+ TITLE:=Support for GSM and CDMA modems
+ KCONFIG:=CONFIG_USB_SERIAL_WWAN
+ FILES:=$(LINUX_DIR)/drivers/usb/serial/usb_wwan.ko
+ AUTOLOAD:=$(call AutoLoad,61,usb_wwan)
+ $(call AddDepends/usb-serial)
+endef
+
+define KernelPackage/usb-serial-wwan/description
+ Kernel support for USB GSM and CDMA modems
+endef
+
+$(eval $(call KernelPackage,usb-serial-wwan))
+
+
+define KernelPackage/usb-serial-option
+ TITLE:=Support for Option HSDPA modems
+ DEPENDS:=+kmod-usb-serial-wwan
+ KCONFIG:=CONFIG_USB_SERIAL_OPTION
+ FILES:=$(LINUX_DIR)/drivers/usb/serial/option.ko
+ AUTOLOAD:=$(call AutoLoad,65,option)
+ $(call AddDepends/usb-serial)
+endef
+
+define KernelPackage/usb-serial-option/description
+ Kernel support for Option HSDPA modems
+endef
+
+$(eval $(call KernelPackage,usb-serial-option))
+
+
+define KernelPackage/usb-serial-qualcomm
+ TITLE:=Support for Qualcomm USB serial
+ KCONFIG:=CONFIG_USB_SERIAL_QUALCOMM
+ FILES:=$(LINUX_DIR)/drivers/usb/serial/qcserial.ko
+ AUTOLOAD:=$(call AutoLoad,65,qcserial)
+ $(call AddDepends/usb-serial)
+endef
+
+define KernelPackage/usb-serial-qualcomm/description
+ Kernel support for Qualcomm USB Serial devices (Gobi)
+endef
+
+$(eval $(call KernelPackage,usb-serial-qualcomm))
+
+
+define KernelPackage/usb-storage
+ TITLE:=USB Storage support
+ DEPENDS:= +kmod-scsi-core
+ KCONFIG:=CONFIG_USB_STORAGE
+ FILES:=$(LINUX_DIR)/drivers/usb/storage/usb-storage.ko
+ AUTOLOAD:=$(call AutoLoad,60,usb-storage,1)
+ $(call AddDepends/usb)
+endef
+
+define KernelPackage/usb-storage/description
+ Kernel support for USB Mass Storage devices
+endef
+
+$(eval $(call KernelPackage,usb-storage))
+
+
+define KernelPackage/usb-storage-extras
+ SUBMENU:=$(USB_MENU)
+ TITLE:=Extra drivers for usb-storage
+ DEPENDS:=+kmod-usb-storage
+ KCONFIG:= \
+ CONFIG_USB_STORAGE_ALAUDA \
+ CONFIG_USB_STORAGE_CYPRESS_ATACB \
+ CONFIG_USB_STORAGE_DATAFAB \
+ CONFIG_USB_STORAGE_FREECOM \
+ CONFIG_USB_STORAGE_ISD200 \
+ CONFIG_USB_STORAGE_JUMPSHOT \
+ CONFIG_USB_STORAGE_KARMA \
+ CONFIG_USB_STORAGE_SDDR09 \
+ CONFIG_USB_STORAGE_SDDR55 \
+ CONFIG_USB_STORAGE_USBAT
+ FILES:= \
+ $(LINUX_DIR)/drivers/usb/storage/ums-alauda.ko \
+ $(LINUX_DIR)/drivers/usb/storage/ums-cypress.ko \
+ $(LINUX_DIR)/drivers/usb/storage/ums-datafab.ko \
+ $(LINUX_DIR)/drivers/usb/storage/ums-freecom.ko \
+ $(LINUX_DIR)/drivers/usb/storage/ums-isd200.ko \
+ $(LINUX_DIR)/drivers/usb/storage/ums-jumpshot.ko \
+ $(LINUX_DIR)/drivers/usb/storage/ums-karma.ko \
+ $(LINUX_DIR)/drivers/usb/storage/ums-sddr09.ko \
+ $(LINUX_DIR)/drivers/usb/storage/ums-sddr55.ko \
+ $(LINUX_DIR)/drivers/usb/storage/ums-usbat.ko
+ AUTOLOAD:=$(call AutoLoad,60,ums-alauda ums-cypress ums-datafab \
+ ums-freecom ums-isd200 ums-jumpshot \
+ ums-karma ums-sddr09 ums-sddr55 ums-usbat)
+endef
+
+define KernelPackage/usb-storage-extras/description
+ Say Y here if you want to have some more drivers,
+ such as for SmartMedia card readers.
+endef
+
+$(eval $(call KernelPackage,usb-storage-extras))
+
+
+define KernelPackage/usb-atm
+ TITLE:=Support for ATM on USB bus
+ DEPENDS:=+kmod-atm
+ KCONFIG:=CONFIG_USB_ATM
+ FILES:=$(LINUX_DIR)/drivers/usb/atm/usbatm.ko
+ AUTOLOAD:=$(call AutoLoad,60,usbatm)
+ $(call AddDepends/usb)
+endef
+
+define KernelPackage/usb-atm/description
+ Kernel support for USB DSL modems
+endef
+
+$(eval $(call KernelPackage,usb-atm))
+
+
+define AddDepends/usb-atm
+ SUBMENU:=$(USB_MENU)
+ DEPENDS+=kmod-usb-atm $(1)
+endef
+
+
+define KernelPackage/usb-atm-speedtouch
+ TITLE:=SpeedTouch USB ADSL modems support
+ KCONFIG:=CONFIG_USB_SPEEDTOUCH
+ FILES:=$(LINUX_DIR)/drivers/usb/atm/speedtch.ko
+ AUTOLOAD:=$(call AutoLoad,70,speedtch)
+ $(call AddDepends/usb-atm)
+endef
+
+define KernelPackage/usb-atm-speedtouch/description
+ Kernel support for SpeedTouch USB ADSL modems
+endef
+
+$(eval $(call KernelPackage,usb-atm-speedtouch))
+
+
+define KernelPackage/usb-atm-ueagle
+ TITLE:=Eagle 8051 based USB ADSL modems support
+ FILES:=$(LINUX_DIR)/drivers/usb/atm/ueagle-atm.ko
+ KCONFIG:=CONFIG_USB_UEAGLEATM
+ AUTOLOAD:=$(call AutoLoad,70,ueagle-atm)
+ $(call AddDepends/usb-atm)
+endef
+
+define KernelPackage/usb-atm-ueagle/description
+ Kernel support for Eagle 8051 based USB ADSL modems
+endef
+
+$(eval $(call KernelPackage,usb-atm-ueagle))
+
+
+define KernelPackage/usb-atm-cxacru
+ TITLE:=cxacru
+ FILES:=$(LINUX_DIR)/drivers/usb/atm/cxacru.ko
+ KCONFIG:=CONFIG_USB_CXACRU
+ AUTOLOAD:=$(call AutoLoad,70,cxacru)
+ $(call AddDepends/usb-atm)
+endef
+
+define KernelPackage/usb-atm-cxacru/description
+ Kernel support for cxacru based USB ADSL modems
+endef
+
+$(eval $(call KernelPackage,usb-atm-cxacru))
+
+
+define KernelPackage/usb-net
+ TITLE:=Kernel modules for USB-to-Ethernet convertors
+ KCONFIG:=CONFIG_USB_USBNET CONFIG_MII=y
+ AUTOLOAD:=$(call AutoLoad,60,usbnet)
+ FILES:=$(LINUX_DIR)/drivers/$(USBNET_DIR)/usbnet.ko
+ $(call AddDepends/usb)
+endef
+
+define KernelPackage/usb-net/description
+ Kernel modules for USB-to-Ethernet convertors
+endef
+
+$(eval $(call KernelPackage,usb-net))
+
+
+define AddDepends/usb-net
+ SUBMENU:=$(USB_MENU)
+ DEPENDS+=kmod-usb-net $(1)
+endef
+
+
+define KernelPackage/usb-net-asix
+ TITLE:=Kernel module for USB-to-Ethernet Asix convertors
+ KCONFIG:=CONFIG_USB_NET_AX8817X
+ FILES:=$(LINUX_DIR)/drivers/$(USBNET_DIR)/asix.ko
+ AUTOLOAD:=$(call AutoLoad,61,asix)
+ $(call AddDepends/usb-net)
+endef
+
+define KernelPackage/usb-net-asix/description
+ Kernel module for USB-to-Ethernet Asix convertors
+endef
+
+$(eval $(call KernelPackage,usb-net-asix))
+
+
+define KernelPackage/usb-net-hso
+ TITLE:=Kernel module for Option USB High Speed Mobile Devices
+ KCONFIG:=CONFIG_USB_HSO
+ FILES:= \
+ $(LINUX_DIR)/drivers/$(USBNET_DIR)/hso.ko
+ AUTOLOAD:=$(call AutoLoad,61,hso)
+ $(call AddDepends/usb-net)
+ $(call AddDepends/rfkill)
+endef
+
+define KernelPackage/usb-net-hso/description
+ Kernel module for Option USB High Speed Mobile Devices
+endef
+
+$(eval $(call KernelPackage,usb-net-hso))
+
+
+define KernelPackage/usb-net-kaweth
+ TITLE:=Kernel module for USB-to-Ethernet Kaweth convertors
+ KCONFIG:=CONFIG_USB_KAWETH
+ FILES:=$(LINUX_DIR)/drivers/$(USBNET_DIR)/kaweth.ko
+ AUTOLOAD:=$(call AutoLoad,61,kaweth)
+ $(call AddDepends/usb-net)
+endef
+
+define KernelPackage/usb-net-kaweth/description
+ Kernel module for USB-to-Ethernet Kaweth convertors
+endef
+
+$(eval $(call KernelPackage,usb-net-kaweth))
+
+
+define KernelPackage/usb-net-pegasus
+ TITLE:=Kernel module for USB-to-Ethernet Pegasus convertors
+ KCONFIG:=CONFIG_USB_PEGASUS
+ FILES:=$(LINUX_DIR)/drivers/$(USBNET_DIR)/pegasus.ko
+ AUTOLOAD:=$(call AutoLoad,61,pegasus)
+ $(call AddDepends/usb-net)
+endef
+
+define KernelPackage/usb-net-pegasus/description
+ Kernel module for USB-to-Ethernet Pegasus convertors
+endef
+
+$(eval $(call KernelPackage,usb-net-pegasus))
+
+
+define KernelPackage/usb-net-mcs7830
+ TITLE:=Kernel module for USB-to-Ethernet MCS7830 convertors
+ KCONFIG:=CONFIG_USB_NET_MCS7830
+ FILES:=$(LINUX_DIR)/drivers/$(USBNET_DIR)/mcs7830.ko
+ AUTOLOAD:=$(call AutoLoad,61,mcs7830)
+ $(call AddDepends/usb-net)
+endef
+
+define KernelPackage/usb-net-mcs7830/description
+ Kernel module for USB-to-Ethernet MCS7830 convertors
+endef
+
+$(eval $(call KernelPackage,usb-net-mcs7830))
+
+
+define KernelPackage/usb-net-dm9601-ether
+ TITLE:=Support for DM9601 ethernet connections
+ KCONFIG:=CONFIG_USB_NET_DM9601
+ FILES:=$(LINUX_DIR)/drivers/$(USBNET_DIR)/dm9601.ko
+ AUTOLOAD:=$(call AutoLoad,61,dm9601)
+ $(call AddDepends/usb-net)
+endef
+
+define KernelPackage/usb-net-dm9601-ether/description
+ Kernel support for USB DM9601 devices
+endef
+
+$(eval $(call KernelPackage,usb-net-dm9601-ether))
+
+define KernelPackage/usb-net-cdc-ether
+ TITLE:=Support for cdc ethernet connections
+ KCONFIG:=CONFIG_USB_NET_CDCETHER
+ FILES:=$(LINUX_DIR)/drivers/$(USBNET_DIR)/cdc_ether.ko
+ AUTOLOAD:=$(call AutoLoad,61,cdc_ether)
+ $(call AddDepends/usb-net)
+endef
+
+define KernelPackage/usb-net-cdc-ether/description
+ Kernel support for USB CDC Ethernet devices
+endef
+
+$(eval $(call KernelPackage,usb-net-cdc-ether))
+
+
+define KernelPackage/usb-net-qmi-wwan
+ TITLE:=QMI WWAN driver
+ KCONFIG:=CONFIG_USB_NET_QMI_WWAN
+ FILES:= $(LINUX_DIR)/drivers/$(USBNET_DIR)/qmi_wwan.ko
+ AUTOLOAD:=$(call AutoLoad,61,qmi_wwan)
+ $(call AddDepends/usb-net,+kmod-usb-wdm)
+endef
+
+define KernelPackage/usb-net-qmi-wwan/description
+ QMI WWAN driver for Qualcomm MSM based 3G and LTE modems
+endef
+
+$(eval $(call KernelPackage,usb-net-qmi-wwan))
+
+
+define KernelPackage/usb-net-rndis
+ TITLE:=Support for RNDIS connections
+ KCONFIG:=CONFIG_USB_NET_RNDIS_HOST
+ FILES:= $(LINUX_DIR)/drivers/$(USBNET_DIR)/rndis_host.ko
+ AUTOLOAD:=$(call AutoLoad,62,rndis_host)
+ $(call AddDepends/usb-net,+kmod-usb-net-cdc-ether)
+endef
+
+define KernelPackage/usb-net-rndis/description
+ Kernel support for RNDIS connections
+endef
+
+$(eval $(call KernelPackage,usb-net-rndis))
+
+define KernelPackage/usb-net-cdc-ncm
+ TITLE:=Support for CDC NCM connections
+ KCONFIG:=CONFIG_USB_NET_CDC_NCM
+ FILES:= $(LINUX_DIR)/drivers/$(USBNET_DIR)/cdc_ncm.ko
+ AUTOLOAD:=$(call AutoLoad,61,cdc_ncm)
+ $(call AddDepends/usb-net)
+endef
+
+define KernelPackage/usb-net-cdc-ncm/description
+ Kernel support for CDC NCM connections
+endef
+
+$(eval $(call KernelPackage,usb-net-cdc-ncm))
+
+
+define KernelPackage/usb-net-sierrawireless
+ TITLE:=Support for Sierra Wireless devices
+ KCONFIG:=CONFIG_USB_SIERRA_NET
+ FILES:=$(LINUX_DIR)/drivers/net/usb/sierra_net.ko
+ AUTOLOAD:=$(call AutoLoad,65,sierra_net)
+ $(call AddDepends/usb-net)
+endef
+
+define KernelPackage/usb-net-sierrawireless/description
+ Kernel support for Sierra Wireless devices
+endef
+
+$(eval $(call KernelPackage,usb-net-sierrawireless))
+
+
+define KernelPackage/usb-net-ipheth
+ TITLE:=Apple iPhone USB Ethernet driver
+ KCONFIG:=CONFIG_USB_IPHETH
+ FILES:=$(LINUX_DIR)/drivers/net/usb/ipheth.ko
+ AUTOLOAD:=$(call AutoLoad,64,ipheth)
+ $(call AddDepends/usb-net)
+endef
+
+define KernelPackage/usb-net-ipheth/description
+ Kernel support for Apple iPhone USB Ethernet driver
+endef
+
+$(eval $(call KernelPackage,usb-net-ipheth))
+
+
+define KernelPackage/usb-hid
+ TITLE:=Support for USB Human Input Devices
+ KCONFIG:=CONFIG_HID_SUPPORT=y CONFIG_USB_HID CONFIG_USB_HIDDEV=y
+ FILES:=$(LINUX_DIR)/drivers/$(USBHID_DIR)/usbhid.ko
+ AUTOLOAD:=$(call AutoLoad,70,usbhid)
+ $(call AddDepends/usb)
+ $(call AddDepends/hid)
+ $(call AddDepends/input,+kmod-input-evdev)
+endef
+
+
+define KernelPackage/usb-hid/description
+ Kernel support for USB HID devices such as keyboards and mice
+endef
+
+$(eval $(call KernelPackage,usb-hid))
+
+
+define KernelPackage/usb-yealink
+ TITLE:=USB Yealink VOIP phone
+ KCONFIG:=CONFIG_USB_YEALINK CONFIG_INPUT_YEALINK CONFIG_INPUT=m CONFIG_INPUT_MISC=y
+ FILES:=$(LINUX_DIR)/drivers/$(USBINPUT_DIR)/yealink.ko
+ AUTOLOAD:=$(call AutoLoad,70,yealink)
+ $(call AddDepends/usb)
+ $(call AddDepends/input,+kmod-input-evdev)
+endef
+
+define KernelPackage/usb-yealink/description
+ Kernel support for Yealink VOIP phone
+endef
+
+$(eval $(call KernelPackage,usb-yealink))
+
+
+define KernelPackage/usb-cm109
+ TITLE:=Support for CM109 device
+ KCONFIG:=CONFIG_USB_CM109 CONFIG_INPUT_CM109 CONFIG_INPUT=m CONFIG_INPUT_MISC=y
+ FILES:=$(LINUX_DIR)/drivers/$(USBINPUT_DIR)/cm109.ko
+ AUTOLOAD:=$(call AutoLoad,70,cm109)
+ $(call AddDepends/usb)
+ $(call AddDepends/input,+kmod-input-evdev)
+endef
+
+define KernelPackage/usb-cm109/description
+ Kernel support for CM109 VOIP phone
+endef
+
+$(eval $(call KernelPackage,usb-cm109))
+
+
+define KernelPackage/usb-test
+ TITLE:=USB Testing Driver
+ DEPENDS:=@DEVEL
+ KCONFIG:=CONFIG_USB_TEST
+ FILES:=$(LINUX_DIR)/drivers/usb/misc/usbtest.ko
+ $(call AddDepends/usb)
+endef
+
+define KernelPackage/usb-test/description
+ Kernel support for testing USB Host Controller software.
+endef
+
+$(eval $(call KernelPackage,usb-test))
+
+
+define KernelPackage/usbip
+ TITLE := USB-over-IP kernel support
+ KCONFIG:= \
+ CONFIG_USBIP_CORE \
+ CONFIG_USBIP_DEBUG=n
+ FILES:=$(LINUX_DIR)/drivers/staging/usbip/usbip-core.ko
+ AUTOLOAD:=$(call AutoLoad,90,usbip-core)
+ $(call AddDepends/usb)
+endef
+$(eval $(call KernelPackage,usbip))
+
+define KernelPackage/usbip-client
+ TITLE := USB-over-IP client driver
+ DEPENDS := +kmod-usbip
+ KCONFIG := CONFIG_USBIP_VHCI_HCD
+ FILES := $(LINUX_DIR)/drivers/staging/usbip/vhci-hcd.$(LINUX_KMOD_SUFFIX)
+ AUTOLOAD := $(call AutoLoad,95,vhci-hcd)
+ $(call AddDepends/usb)
+endef
+$(eval $(call KernelPackage,usbip-client))
+
+define KernelPackage/usbip-server
+$(call KernelPackage/usbip/Default)
+ TITLE := USB-over-IP host driver
+ DEPENDS := +kmod-usbip
+ KCONFIG := CONFIG_USBIP_HOST
+ FILES := $(LINUX_DIR)/drivers/staging/usbip/usbip-host.ko
+ AUTOLOAD := $(call AutoLoad,95,usbip-host)
+ $(call AddDepends/usb)
+endef
+$(eval $(call KernelPackage,usbip-server))
diff --git a/package/kernel/modules/.svn/text-base/video.mk.svn-base b/package/kernel/modules/.svn/text-base/video.mk.svn-base
new file mode 100644
index 0000000..e652e8a
--- /dev/null
+++ b/package/kernel/modules/.svn/text-base/video.mk.svn-base
@@ -0,0 +1,730 @@
+#
+# Copyright (C) 2009 David Cooper <dave@kupesoft.com>
+# Copyright (C) 2006-2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+VIDEO_MENU:=Video Support
+
+ifeq ($(strip $(call CompareKernelPatchVer,$(KERNEL_PATCHVER),ge,3.7.0)),1)
+V4L2_DIR=v4l2-core
+V4L2_USB_DIR=usb
+else
+V4L2_DIR=video
+V4L2_USB_DIR=video
+endif
+
+
+define KernelPackage/fb
+ SUBMENU:=$(VIDEO_MENU)
+ TITLE:=Framebuffer support
+ DEPENDS:=@DISPLAY_SUPPORT
+ KCONFIG:=CONFIG_FB
+ FILES:=$(LINUX_DIR)/drivers/video/fb.ko
+ AUTOLOAD:=$(call AutoLoad,06,fb)
+endef
+
+define KernelPackage/fb/description
+ Kernel support for framebuffers
+endef
+
+$(eval $(call KernelPackage,fb))
+
+define KernelPackage/fb-cfb-fillrect
+ SUBMENU:=$(VIDEO_MENU)
+ TITLE:=Framebuffer software rectangle filling support
+ DEPENDS:=+kmod-fb
+ KCONFIG:=CONFIG_FB_CFB_FILLRECT
+ FILES:=$(LINUX_DIR)/drivers/video/cfbfillrect.ko
+ AUTOLOAD:=$(call AutoLoad,07,cfbfillrect)
+endef
+
+define KernelPackage/fb-cfb-fillrect/description
+ Kernel support for software rectangle filling
+endef
+
+$(eval $(call KernelPackage,fb-cfb-fillrect))
+
+
+define KernelPackage/fb-cfb-copyarea
+ SUBMENU:=$(VIDEO_MENU)
+ TITLE:=Framebuffer software copy area support
+ DEPENDS:=+kmod-fb
+ KCONFIG:=CONFIG_FB_CFB_COPYAREA
+ FILES:=$(LINUX_DIR)/drivers/video/cfbcopyarea.ko
+ AUTOLOAD:=$(call AutoLoad,07,cfbcopyarea)
+endef
+
+define KernelPackage/fb-cfb-copyarea/description
+ Kernel support for software copy area
+endef
+
+$(eval $(call KernelPackage,fb-cfb-copyarea))
+
+define KernelPackage/fb-cfb-imgblt
+ SUBMENU:=$(VIDEO_MENU)
+ TITLE:=Framebuffer software image blit support
+ DEPENDS:=+kmod-fb
+ KCONFIG:=CONFIG_FB_CFB_IMAGEBLIT
+ FILES:=$(LINUX_DIR)/drivers/video/cfbimgblt.ko
+ AUTOLOAD:=$(call AutoLoad,07,cfbimgblt)
+endef
+
+define KernelPackage/fb-cfb-imgblt/description
+ Kernel support for software image blitting
+endef
+
+$(eval $(call KernelPackage,fb-cfb-imgblt))
+
+
+define KernelPackage/video-core
+ SUBMENU:=$(VIDEO_MENU)
+ TITLE=Video4Linux support
+ DEPENDS:=@PCI_SUPPORT||USB_SUPPORT
+ KCONFIG:= \
+ CONFIG_MEDIA_SUPPORT=m \
+ CONFIG_MEDIA_CAMERA_SUPPORT=y \
+ CONFIG_VIDEO_DEV \
+ CONFIG_VIDEO_V4L1=y \
+ CONFIG_VIDEO_ALLOW_V4L1=y \
+ CONFIG_VIDEO_CAPTURE_DRIVERS=y \
+ CONFIG_V4L_USB_DRIVERS=y \
+ CONFIG_V4L_PCI_DRIVERS=y \
+ CONFIG_V4L_PLATFORM_DRIVERS=y \
+ CONFIG_V4L_ISA_PARPORT_DRIVERS=y
+ FILES:= \
+ $(LINUX_DIR)/drivers/media/$(V4L2_DIR)/v4l2-common.ko \
+ $(LINUX_DIR)/drivers/media/$(V4L2_DIR)/videodev.ko
+ AUTOLOAD:=$(call AutoLoad,60, videodev v4l2-common)
+endef
+
+define KernelPackage/video-core/description
+ Kernel modules for Video4Linux support
+endef
+
+$(eval $(call KernelPackage,video-core))
+
+
+define AddDepends/video
+ SUBMENU:=$(VIDEO_MENU)
+ DEPENDS+=kmod-video-core $(1)
+endef
+
+define AddDepends/camera
+ SUBMENU:=$(VIDEO_MENU)
+ KCONFIG+=CONFIG_MEDIA_USB_SUPPORT=y \
+ CONFIG_MEDIA_CAMERA_SUPPORT=y
+ DEPENDS+=kmod-video-core $(1)
+endef
+
+
+define KernelPackage/video-videobuf2
+ TITLE:=videobuf2 lib
+ KCONFIG:= \
+ CONFIG_VIDEOBUF2_CORE \
+ CONFIG_VIDEOBUF2_MEMOPS \
+ CONFIG_VIDEOBUF2_VMALLOC
+ FILES:= \
+ $(LINUX_DIR)/drivers/media/$(V4L2_DIR)/videobuf2-core.ko \
+ $(LINUX_DIR)/drivers/media/$(V4L2_DIR)/videobuf2-memops.ko \
+ $(LINUX_DIR)/drivers/media/$(V4L2_DIR)/videobuf2-vmalloc.ko
+ AUTOLOAD:=$(call AutoLoad,65,videobuf2-core videobuf2-memops videobuf2-vmalloc)
+ $(call AddDepends/video)
+endef
+
+define KernelPackage/video-videobuf2/description
+ Kernel modules that implements three basic types of media buffers.
+endef
+
+$(eval $(call KernelPackage,video-videobuf2))
+
+
+define KernelPackage/video-cpia2
+ TITLE:=CPIA2 video driver
+ DEPENDS:=@USB_SUPPORT +kmod-usb-core
+ KCONFIG:=CONFIG_VIDEO_CPIA2
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/cpia2/cpia2.ko
+ AUTOLOAD:=$(call AutoLoad,70,cpia2)
+ $(call AddDepends/camera)
+endef
+
+define KernelPackage/video-cpia2/description
+ Kernel modules for supporting CPIA2 USB based cameras.
+endef
+
+$(eval $(call KernelPackage,video-cpia2))
+
+
+define KernelPackage/video-sn9c102
+ TITLE:=SN9C102 Camera Chip support
+ DEPENDS:=@USB_SUPPORT +kmod-usb-core
+ KCONFIG:=CONFIG_USB_SN9C102
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/sn9c102/sn9c102.ko
+ AUTOLOAD:=$(call AutoLoad,70,gspca_sn9c20x)
+ $(call AddDepends/camera)
+endef
+
+
+define KernelPackage/video-sn9c102/description
+ Kernel modules for supporting SN9C102
+ camera chips.
+endef
+
+$(eval $(call KernelPackage,video-sn9c102))
+
+
+define KernelPackage/video-pwc
+ TITLE:=Philips USB webcam support
+ DEPENDS:=@USB_SUPPORT +kmod-usb-core +kmod-video-videobuf2
+ KCONFIG:= \
+ CONFIG_USB_PWC \
+ CONFIG_USB_PWC_DEBUG=n
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/pwc/pwc.ko
+ AUTOLOAD:=$(call AutoLoad,70,pwc)
+ $(call AddDepends/camera)
+endef
+
+
+define KernelPackage/video-pwc/description
+ Kernel modules for supporting Philips USB based cameras.
+endef
+
+$(eval $(call KernelPackage,video-pwc))
+
+define KernelPackage/video-uvc
+ TITLE:=USB Video Class (UVC) support
+ DEPENDS:=@USB_SUPPORT +kmod-usb-core +kmod-video-videobuf2
+ KCONFIG:= CONFIG_USB_VIDEO_CLASS
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/uvc/uvcvideo.ko
+ AUTOLOAD:=$(call AutoLoad,90,uvcvideo)
+ $(call AddDepends/camera)
+ $(call AddDepends/input)
+endef
+
+
+define KernelPackage/video-uvc/description
+ Kernel modules for supporting USB Video Class (UVC) devices.
+endef
+
+$(eval $(call KernelPackage,video-uvc))
+
+
+define KernelPackage/video-gspca-core
+ MENU:=1
+ TITLE:=GSPCA webcam core support framework
+ DEPENDS:=@USB_SUPPORT +kmod-usb-core +kmod-input-core
+ KCONFIG:=CONFIG_USB_GSPCA
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_main.ko
+ AUTOLOAD:=$(call AutoLoad,70,gspca_main)
+ $(call AddDepends/camera)
+endef
+
+define KernelPackage/video-gspca-core/description
+ Kernel modules for supporting GSPCA based webcam devices. Note this is just
+ the core of the driver, please select a submodule that supports your webcam.
+endef
+
+$(eval $(call KernelPackage,video-gspca-core))
+
+
+define AddDepends/camera-gspca
+ SUBMENU:=$(VIDEO_MENU)
+ DEPENDS+=kmod-video-gspca-core $(1)
+endef
+
+
+define KernelPackage/video-gspca-conex
+ TITLE:=conex webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_CONEX
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_conex.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_conex)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-conex/description
+ The Conexant Camera Driver (conex) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-conex))
+
+
+define KernelPackage/video-gspca-etoms
+ TITLE:=etoms webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_ETOMS
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_etoms.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_etoms)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-etoms/description
+ The Etoms USB Camera Driver (etoms) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-etoms))
+
+
+define KernelPackage/video-gspca-finepix
+ TITLE:=finepix webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_FINEPIX
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_finepix.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_finepix)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-finepix/description
+ The Fujifilm FinePix USB V4L2 driver (finepix) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-finepix))
+
+
+define KernelPackage/video-gspca-mars
+ TITLE:=mars webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_MARS
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_mars.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_mars)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-mars/description
+ The Mars USB Camera Driver (mars) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-mars))
+
+
+define KernelPackage/video-gspca-mr97310a
+ TITLE:=mr97310a webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_MR97310A
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_mr97310a.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_mr97310a)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-mr97310a/description
+ The Mars-Semi MR97310A USB Camera Driver (mr97310a) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-mr97310a))
+
+
+define KernelPackage/video-gspca-ov519
+ TITLE:=ov519 webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_OV519
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_ov519.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_ov519)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-ov519/description
+ The OV519 USB Camera Driver (ov519) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-ov519))
+
+
+define KernelPackage/video-gspca-ov534
+ TITLE:=ov534 webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_OV534
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_ov534.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_ov534)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-ov534/description
+ The OV534 USB Camera Driver (ov534) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-ov534))
+
+
+define KernelPackage/video-gspca-ov534-9
+ TITLE:=ov534-9 webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_OV534_9
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_ov534_9.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_ov534_9)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-ov534-9/description
+ The OV534-9 USB Camera Driver (ov534_9) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-ov534-9))
+
+
+define KernelPackage/video-gspca-pac207
+ TITLE:=pac207 webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_PAC207
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_pac207.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_pac207)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-pac207/description
+ The Pixart PAC207 USB Camera Driver (pac207) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-pac207))
+
+
+define KernelPackage/video-gspca-pac7311
+ TITLE:=pac7311 webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_PAC7311
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_pac7311.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_pac7311)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-pac7311/description
+ The Pixart PAC7311 USB Camera Driver (pac7311) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-pac7311))
+
+
+define KernelPackage/video-gspca-se401
+ TITLE:=se401 webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_SE401
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_se401.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_se401)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-se401/description
+ The SE401 USB Camera Driver kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-se401))
+
+
+define KernelPackage/video-gspca-sn9c20x
+ TITLE:=sn9c20x webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_SN9C20X
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_sn9c20x.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_sn9c20x)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-sn9c20x/description
+ The SN9C20X USB Camera Driver (sn9c20x) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-sn9c20x))
+
+
+define KernelPackage/video-gspca-sonixb
+ TITLE:=sonixb webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_SONIXB
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_sonixb.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_sonixb)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-sonixb/description
+ The SONIX Bayer USB Camera Driver (sonixb) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-sonixb))
+
+
+define KernelPackage/video-gspca-sonixj
+ TITLE:=sonixj webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_SONIXJ
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_sonixj.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_sonixj)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-sonixj/description
+ The SONIX JPEG USB Camera Driver (sonixj) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-sonixj))
+
+
+define KernelPackage/video-gspca-spca500
+ TITLE:=spca500 webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_SPCA500
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_spca500.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_spca500)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-spca500/description
+ The SPCA500 USB Camera Driver (spca500) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-spca500))
+
+
+define KernelPackage/video-gspca-spca501
+ TITLE:=spca501 webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_SPCA501
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_spca501.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_spca501)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-spca501/description
+ The SPCA501 USB Camera Driver (spca501) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-spca501))
+
+
+define KernelPackage/video-gspca-spca505
+ TITLE:=spca505 webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_SPCA505
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_spca505.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_spca505)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-spca505/description
+ The SPCA505 USB Camera Driver (spca505) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-spca505))
+
+
+define KernelPackage/video-gspca-spca506
+ TITLE:=spca506 webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_SPCA506
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_spca506.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_spca506)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-spca506/description
+ The SPCA506 USB Camera Driver (spca506) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-spca506))
+
+
+define KernelPackage/video-gspca-spca508
+ TITLE:=spca508 webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_SPCA508
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_spca508.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_spca508)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-spca508/description
+ The SPCA508 USB Camera Driver (spca508) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-spca508))
+
+
+define KernelPackage/video-gspca-spca561
+ TITLE:=spca561 webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_SPCA561
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_spca561.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_spca561)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-spca561/description
+ The SPCA561 USB Camera Driver (spca561) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-spca561))
+
+
+define KernelPackage/video-gspca-sq905
+ TITLE:=sq905 webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_SQ905
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_sq905.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_sq905)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-sq905/description
+ The SQ Technologies SQ905 based USB Camera Driver (sq905) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-sq905))
+
+
+define KernelPackage/video-gspca-sq905c
+ TITLE:=sq905c webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_SQ905C
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_sq905c.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_sq905c)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-sq905c/description
+ The SQ Technologies SQ905C based USB Camera Driver (sq905c) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-sq905c))
+
+
+define KernelPackage/video-gspca-stk014
+ TITLE:=stk014 webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_STK014
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_stk014.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_stk014)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-stk014/description
+ The Syntek DV4000 (STK014) USB Camera Driver (stk014) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-stk014))
+
+
+define KernelPackage/video-gspca-sunplus
+ TITLE:=sunplus webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_SUNPLUS
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_sunplus.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_sunplus)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-sunplus/description
+ The SUNPLUS USB Camera Driver (sunplus) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-sunplus))
+
+
+define KernelPackage/video-gspca-t613
+ TITLE:=t613 webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_T613
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_t613.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_t613)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-t613/description
+ The T613 (JPEG Compliance) USB Camera Driver (t613) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-t613))
+
+
+define KernelPackage/video-gspca-tv8532
+ TITLE:=tv8532 webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_TV8532
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_tv8532.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_tv8532)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-tv8532/description
+ The TV8532 USB Camera Driver (tv8532) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-tv8532))
+
+
+define KernelPackage/video-gspca-vc032x
+ TITLE:=vc032x webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_VC032X
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_vc032x.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_vc032x)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-vc032x/description
+ The VC032X USB Camera Driver (vc032x) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-vc032x))
+
+
+define KernelPackage/video-gspca-zc3xx
+ TITLE:=zc3xx webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_ZC3XX
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_zc3xx.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_zc3xx)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-zc3xx/description
+ The ZC3XX USB Camera Driver (zc3xx) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-zc3xx))
+
+
+define KernelPackage/video-gspca-m5602
+ TITLE:=m5602 webcam support
+ KCONFIG:=CONFIG_USB_M5602
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/m5602/gspca_m5602.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_m5602)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-m5602/description
+ The ALi USB m5602 Camera Driver (m5602) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-m5602))
+
+
+define KernelPackage/video-gspca-stv06xx
+ TITLE:=stv06xx webcam support
+ KCONFIG:=CONFIG_USB_STV06XX
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/stv06xx/gspca_stv06xx.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_stv06xx)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-stv06xx/description
+ The STV06XX USB Camera Driver (stv06xx) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-stv06xx))
+
+
+define KernelPackage/video-gspca-gl860
+ TITLE:=gl860 webcam support
+ KCONFIG:=CONFIG_USB_GL860
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gl860/gspca_gl860.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_gl860)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-gl800/description
+ The GL860 USB Camera Driver (gl860) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-gl860))
+
+
+define KernelPackage/video-gspca-jeilinj
+ TITLE:=jeilinj webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_JEILINJ
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_jeilinj.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_jeilinj)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-jeilinj/description
+ The JEILINJ USB Camera Driver (jeilinj) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-jeilinj))
+
+
+define KernelPackage/video-gspca-konica
+ TITLE:=konica webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_KONICA
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_konica.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_konica)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-konica/description
+ The Konica USB Camera Driver (konica) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-konica))
diff --git a/package/kernel/modules/.svn/text-base/virtual.mk.svn-base b/package/kernel/modules/.svn/text-base/virtual.mk.svn-base
new file mode 100644
index 0000000..5f8428b
--- /dev/null
+++ b/package/kernel/modules/.svn/text-base/virtual.mk.svn-base
@@ -0,0 +1,171 @@
+#
+# Copyright (C) 2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+VIRTUAL_MENU:=Virtualization Support
+
+
+define KernelPackage/virtio-balloon
+ SUBMENU:=$(VIRTUAL_MENU)
+ TITLE:=VirtIO balloon driver
+ DEPENDS:=@TARGET_x86_kvm_guest
+ KCONFIG:=CONFIG_VIRTIO_BALLOON
+ FILES:=$(LINUX_DIR)/drivers/virtio/virtio_balloon.ko
+ AUTOLOAD:=$(call AutoLoad,06,virtio-balloon)
+endef
+
+define KernelPackage/virtio-balloon/description
+ Kernel module for VirtIO memory ballooning support
+endef
+
+$(eval $(call KernelPackage,virtio-balloon))
+
+
+define KernelPackage/virtio-net
+ SUBMENU:=$(VIRTUAL_MENU)
+ TITLE:=VirtIO network driver
+ DEPENDS:=@TARGET_x86_kvm_guest
+ KCONFIG:=CONFIG_VIRTIO_NET
+ FILES:=$(LINUX_DIR)/drivers/net/virtio_net.ko
+ AUTOLOAD:=$(call AutoLoad,50,virtio_net)
+endef
+
+define KernelPackage/virtio-net/description
+ Kernel module for the VirtIO paravirtualized network device
+endef
+
+$(eval $(call KernelPackage,virtio-net))
+
+
+define KernelPackage/virtio-random
+ SUBMENU:=$(VIRTUAL_MENU)
+ TITLE:=VirtIO Random Number Generator support
+ DEPENDS:=@TARGET_x86_kvm_guest
+ KCONFIG:=CONFIG_HW_RANDOM_VIRTIO
+ FILES:=$(LINUX_DIR)/drivers/char/hw_random/virtio-rng.ko
+ AUTOLOAD:=$(call AutoLoad,09,virtio-rng)
+endef
+
+define KernelPackage/virtio-random/description
+ Kernel module for the VirtIO Random Number Generator
+endef
+
+$(eval $(call KernelPackage,virtio-random))
+
+define KernelPackage/xen-fs
+ SUBMENU:=$(VIRTUAL_MENU)
+ TITLE:=Xen filesystem
+ DEPENDS:=@TARGET_x86_xen_domu
+ KCONFIG:= \
+ CONFIG_XENFS \
+ CONFIG_XEN_COMPAT_XENFS=y
+ FILES:=$(LINUX_DIR)/drivers/xen/xenfs/xenfs.ko
+ AUTOLOAD:=$(call AutoLoad,05,xenfs)
+endef
+
+define KernelPackage/xen-fs/description
+ Kernel module for the Xen filesystem
+endef
+
+$(eval $(call KernelPackage,xen-fs))
+
+
+define KernelPackage/xen-evtchn
+ SUBMENU:=$(VIRTUAL_MENU)
+ TITLE:=Xen event channels
+ DEPENDS:=@TARGET_x86_xen_domu
+ KCONFIG:=CONFIG_XEN_DEV_EVTCHN
+ FILES:=$(LINUX_DIR)/drivers/xen/xen-evtchn.ko
+ AUTOLOAD:=$(call AutoLoad,06,xen-evtchn)
+endef
+
+define KernelPackage/xen-evtchn/description
+ Kernel module for the /dev/xen/evtchn device
+endef
+
+$(eval $(call KernelPackage,xen-evtchn))
+
+define KernelPackage/xen-fbdev
+ SUBMENU:=$(VIRTUAL_MENU)
+ TITLE:=Xen virtual frame buffer
+ DEPENDS:=@TARGET_x86_xen_domu +kmod-fb
+ KCONFIG:= \
+ CONFIG_XEN_FBDEV_FRONTEND \
+ CONFIG_FB_DEFERRED_IO=y \
+ CONFIG_FB_SYS_COPYAREA \
+ CONFIG_FB_SYS_FILLRECT \
+ CONFIG_FB_SYS_FOPS \
+ CONFIG_FB_SYS_IMAGEBLIT \
+ CONFIG_FIRMWARE_EDID=n
+ FILES:= \
+ $(LINUX_DIR)/drivers/video/xen-fbfront.ko \
+ $(LINUX_DIR)/drivers/video/syscopyarea.ko \
+ $(LINUX_DIR)/drivers/video/sysfillrect.ko \
+ $(LINUX_DIR)/drivers/video/fb_sys_fops.ko \
+ $(LINUX_DIR)/drivers/video/sysimgblt.ko
+ AUTOLOAD:=$(call AutoLoad,07, \
+ fb \
+ syscopyarea \
+ sysfillrect \
+ fb_sys_fops \
+ sysimgblt \
+ xen-fbfront \
+ )
+endef
+
+define KernelPackage/xen-fbdev/description
+ Kernel module for the Xen virtual frame buffer
+endef
+
+$(eval $(call KernelPackage,xen-fbdev))
+
+
+define KernelPackage/xen-kbddev
+ SUBMENU:=$(VIRTUAL_MENU)
+ TITLE:=Xen virtual keyboard and mouse
+ DEPENDS:=@TARGET_x86_xen_domu
+ KCONFIG:=CONFIG_XEN_KBDDEV_FRONTEND
+ FILES:=$(LINUX_DIR)/drivers/input/xen-kbdfront.ko
+ AUTOLOAD:=$(call AutoLoad,08,xen-kbdfront)
+endef
+
+define KernelPackage/xen-kbddev/description
+ Kernel module for the Xen virtual keyboard and mouse
+endef
+
+$(eval $(call KernelPackage,xen-kbddev))
+
+
+define KernelPackage/xen-netdev
+ SUBMENU:=$(VIRTUAL_MENU)
+ TITLE:=Xen network device frontend
+ DEPENDS:=@TARGET_x86_xen_domu
+ KCONFIG:=CONFIG_XEN_NETDEV_FRONTEND
+ FILES:=$(LINUX_DIR)/drivers/net/xen-netfront.ko
+ AUTOLOAD:=$(call AutoLoad,09,xen-netfront)
+endef
+
+define KernelPackage/xen-netdev/description
+ Kernel module for the Xen network device frontend
+endef
+
+$(eval $(call KernelPackage,xen-netdev))
+
+
+define KernelPackage/xen-pcidev
+ SUBMENU:=$(VIRTUAL_MENU)
+ TITLE:=Xen PCI device frontend
+ DEPENDS:=@TARGET_x86_xen_domu
+ KCONFIG:=CONFIG_XEN_PCIDEV_FRONTEND
+ FILES:=$(LINUX_DIR)/drivers/pci/xen-pcifront.ko
+ AUTOLOAD:=$(call AutoLoad,10,xen-pcifront)
+endef
+
+define KernelPackage/xen-pcidev/description
+ Kernel module for the Xen network device frontend
+endef
+
+$(eval $(call KernelPackage,xen-pcidev))
diff --git a/package/kernel/modules/.svn/text-base/w1.mk.svn-base b/package/kernel/modules/.svn/text-base/w1.mk.svn-base
new file mode 100644
index 0000000..9093216
--- /dev/null
+++ b/package/kernel/modules/.svn/text-base/w1.mk.svn-base
@@ -0,0 +1,160 @@
+#
+# Copyright (C) 2008-2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+W1_MENU:=W1 support
+W1_MASTERS_DIR:=$(LINUX_DIR)/drivers/w1/masters
+W1_SLAVES_DIR:=$(LINUX_DIR)/drivers/w1/slaves
+
+define KernelPackage/w1
+ SUBMENU:=$(W1_MENU)
+ TITLE:=Dallas's 1-wire support
+ KCONFIG:=CONFIG_W1
+ FILES:=$(LINUX_DIR)/drivers/w1/wire.ko
+ AUTOLOAD:=$(call AutoLoad,50,wire)
+endef
+
+define KernelPackage/w1/description
+ Kernel module for Dallas's 1-wire support
+endef
+
+$(eval $(call KernelPackage,w1))
+
+
+define AddDepends/w1
+ SUBMENU:=$(W1_MENU)
+ DEPENDS+=kmod-w1 $(1)
+endef
+
+
+#
+# 1-wire masters
+#
+define KernelPackage/w1-master-gpio
+ TITLE:=GPIO 1-wire bus master driver
+ DEPENDS:=@GPIO_SUPPORT
+ KCONFIG:=CONFIG_W1_MASTER_GPIO
+ FILES:=$(W1_MASTERS_DIR)/w1-gpio.ko
+ AUTOLOAD:=$(call AutoLoad,60,w1-gpio)
+ $(call AddDepends/w1)
+endef
+
+define KernelPackage/w1-master-gpio/description
+ Kernel module for the GPIO 1-wire bus master driver
+endef
+
+$(eval $(call KernelPackage,w1-master-gpio))
+
+define KernelPackage/w1-master-ds2482
+ TITLE:=DS2482 1-wire i2c bus master driver
+ KCONFIG:=CONFIG_W1_MASTER_DS2482
+ FILES:=$(W1_MASTERS_DIR)/ds2482.ko
+ AUTOLOAD:=$(call AutoLoad,60,ds2482)
+ $(call AddDepends/w1,+kmod-i2c-core)
+endef
+
+define KernelPackage/w1-master-ds2482/description
+ Kernel module for the DS2482 i2c 1-wire bus master driver
+ NOTE: Init with: echo ds2482 0x18 > /sys/bus/i2c/devices/i2c-0/new_device
+ or use owfs
+endef
+
+$(eval $(call KernelPackage,w1-master-ds2482))
+
+
+define KernelPackage/w1-master-ds2490
+ TITLE:=DS2490 1-wire usb bus master driver
+ DEPENDS:=@USB_SUPPORT +kmod-usb-core
+ KCONFIG:=CONFIG_W1_MASTER_DS2490
+ FILES:=$(W1_MASTERS_DIR)/ds2490.ko
+ AUTOLOAD:=$(call AutoLoad,60,ds2490)
+ $(call AddDepends/w1)
+endef
+
+define KernelPackage/w1-master-ds2490/description
+ Kernel module for the DS2490 usb 1-wire bus master driver
+endef
+
+$(eval $(call KernelPackage,w1-master-ds2490))
+
+#
+# 1-wire slaves
+#
+define KernelPackage/w1-slave-therm
+ TITLE:=Thermal family implementation
+ KCONFIG:=CONFIG_W1_SLAVE_THERM
+ FILES:=$(W1_SLAVES_DIR)/w1_therm.ko
+ AUTOLOAD:=$(call AutoLoad,70,w1_therm)
+ $(call AddDepends/w1)
+endef
+
+define KernelPackage/w1-slave-therm/description
+ Kernel module for 1-wire thermal sensors
+endef
+
+$(eval $(call KernelPackage,w1-slave-therm))
+
+
+define KernelPackage/w1-slave-smem
+ TITLE:=Simple 64bit memory family implementation
+ KCONFIG:=CONFIG_W1_SLAVE_SMEM
+ FILES:=$(W1_SLAVES_DIR)/w1_smem.ko
+ AUTOLOAD:=$(call AutoLoad,70,w1_smem)
+ $(call AddDepends/w1)
+endef
+
+define KernelPackage/w1-slave-smem/description
+ Kernel module for 1-wire simple 64bit memory rom(ds2401/ds2411/ds1990*)
+endef
+
+$(eval $(call KernelPackage,w1-slave-smem))
+
+define KernelPackage/w1-slave-ds2431
+ TITLE:=DS2431 1kb EEPROM driver
+ KCONFIG:= CONFIG_W1_SLAVE_DS2431
+ FILES:=$(W1_SLAVES_DIR)/w1_ds2431.ko
+ AUTOLOAD:=$(call AutoLoad,70,w1_ds2431)
+ $(call AddDepends/w1)
+endef
+
+define KernelPackage/w1-slave-ds2431/description
+ Kernel module for 1-wire 1kb EEPROM (DS2431)
+endef
+
+$(eval $(call KernelPackage,w1-slave-ds2431))
+
+define KernelPackage/w1-slave-ds2433
+ TITLE:=DS2433 4kb EEPROM driver
+ KCONFIG:= \
+ CONFIG_W1_SLAVE_DS2433 \
+ CONFIG_W1_SLAVE_DS2433_CRC=n
+ FILES:=$(W1_SLAVES_DIR)/w1_ds2433.ko
+ AUTOLOAD:=$(call AutoLoad,70,w1_ds2433)
+ $(call AddDepends/w1)
+endef
+
+define KernelPackage/w1-slave-ds2433/description
+ Kernel module for 1-wire 4kb EEPROM (DS2433)
+endef
+
+$(eval $(call KernelPackage,w1-slave-ds2433))
+
+
+define KernelPackage/w1-slave-ds2760
+ TITLE:=Dallas 2760 battery monitor chip (HP iPAQ & others)
+ KCONFIG:= \
+ CONFIG_W1_SLAVE_DS2760 \
+ CONFIG_W1_SLAVE_DS2433_CRC=n
+ FILES:=$(W1_SLAVES_DIR)/w1_ds2760.ko
+ AUTOLOAD:=$(call AutoLoad,70,w1_ds2760)
+ $(call AddDepends/w1)
+endef
+
+define KernelPackage/w1-slave-ds2760/description
+ Kernel module for 1-wire DS2760 battery monitor chip support
+endef
+
+$(eval $(call KernelPackage,w1-slave-ds2760))
diff --git a/package/kernel/modules/.svn/text-base/wireless.mk.svn-base b/package/kernel/modules/.svn/text-base/wireless.mk.svn-base
new file mode 100644
index 0000000..ee0f965
--- /dev/null
+++ b/package/kernel/modules/.svn/text-base/wireless.mk.svn-base
@@ -0,0 +1,109 @@
+#
+# Copyright (C) 2006-2008 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+WIRELESS_MENU:=Wireless Drivers
+
+define KernelPackage/net-airo
+ SUBMENU:=$(WIRELESS_MENU)
+ TITLE:=Cisco Aironet driver
+ DEPENDS:=@PCI_SUPPORT +@DRIVER_WEXT_SUPPORT
+ KCONFIG:=CONFIG_AIRO
+ FILES:=$(LINUX_DIR)/drivers/net/wireless/airo.ko
+ AUTOLOAD:=$(call AutoLoad,50,airo)
+endef
+
+define KernelPackage/net-airo/description
+ Kernel support for Cisco Aironet cards
+endef
+
+$(eval $(call KernelPackage,net-airo))
+
+
+define KernelPackage/net-zd1201
+ SUBMENU:=$(WIRELESS_MENU)
+ TITLE:=Zydas ZD1201 support
+ DEPENDS:=@USB_SUPPORT +@DRIVER_WEXT_SUPPORT
+ KCONFIG:=CONFIG_USB_ZD1201
+ FILES:=$(LINUX_DIR)/drivers/net/wireless/zd1201.ko
+ AUTOLOAD:=$(call AutoLoad,60,zd1201)
+endef
+
+define KernelPackage/net-zd1201/description
+ Kernel modules for Zydas ZD1201 support
+ Devices using this chip:
+ * Sweex LC100020
+ * Zyxel ZyAir B-220
+ * Peabird USB
+ * Gigafast WF741-UIC
+ * E-Tech Wireless USB Adapter
+ * DSE 802.11b USB wireless LAN adapter
+ * CC and C WLAN USB Adapter (WL 1202)
+ * Edimax EW-7117U
+ * X-Micro WLAN 11b USB Adapter
+ * Belkin F5D6051
+ * Topcom SKYR@CER WIRELESS USB STICK 11
+ * Surecom EP-9001
+ * JAHT WN-1011U
+ * BeWAN Wi-Fi USB 11
+ * NorthQ NQ9000
+ * MSI UB11B
+ * Origo WLL-1610
+ * Longshine LCS-8131R
+ * Gigabyte GN-WLBZ201
+endef
+
+ZD1201FW_NAME:=zd1201
+ZD1201FW_VERSION:=0.14
+ZD1201FW_DIR:=$(ZD1201FW_NAME)-$(ZD1201FW_VERSION)-fw
+ZD1201FW_FILE:=$(ZD1201FW_DIR).tar.gz
+
+define Download/net-zd1201
+ FILE:=$(ZD1201FW_FILE)
+ #http://downloads.sourceforge.net/project/linux-lc100020/%28NEW%29%20zd1201%20driver/zd1201.%20Version%200.14/zd1201-0.14-fw.tar.gz
+ URL:=@SF/linux-lc100020/\(NEW\)\ $(ZD1201FW_NAME)\ driver/$(ZD1201FW_NAME).\ Version\ $(ZD1201FW_VERSION)/
+ MD5SUM:=07a4febc365121f975e2c5e59791d55d
+endef
+
+define KernelPackage/net-zd1201/install
+ $(INSTALL_DIR) $(1)/lib/firmware
+ $(TAR) -C $(1)/lib/firmware -zxf $(DL_DIR)/$(ZD1201FW_FILE) --strip-components=1 $(ZD1201FW_DIR)/$(ZD1201FW_NAME).fw $(ZD1201FW_DIR)/$(ZD1201FW_NAME)-ap.fw
+endef
+
+$(eval $(call Download,net-zd1201))
+$(eval $(call KernelPackage,net-zd1201))
+
+
+define KernelPackage/net-prism54
+ SUBMENU:=$(WIRELESS_MENU)
+ TITLE:=Intersil Prism54 support
+ DEPENDS:=@PCI_SUPPORT +@DRIVER_WEXT_SUPPORT
+ KCONFIG:=CONFIG_PRISM54
+ FILES:=$(LINUX_DIR)/drivers/net/wireless/prism54/prism54.ko
+ AUTOLOAD:=$(call AutoLoad,60,prism54)
+endef
+
+define KernelPackage/net-prism54/description
+ Kernel modules for Intersil Prism54 support
+endef
+
+# Prism54 FullMAC firmware (jbnore.free.fr seems to be rather slow, so we use daemonizer.de)
+PRISM54_FW:=1.0.4.3.arm
+
+define Download/net-prism54
+ FILE:=$(PRISM54_FW)
+ URL:=http://daemonizer.de/prism54/prism54-fw/fw-fullmac/
+ MD5SUM:=8bd4310971772a486b9784c77f8a6df9
+endef
+
+define KernelPackage/net-prism54/install
+ $(INSTALL_DIR) $(1)/lib/firmware
+ $(INSTALL_DATA) $(DL_DIR)/$(PRISM54_FW) $(1)/lib/firmware/isl3890
+endef
+
+$(eval $(call Download,net-prism54))
+$(eval $(call KernelPackage,net-prism54))
+
diff --git a/package/kernel/modules/001-depends.mk b/package/kernel/modules/001-depends.mk
new file mode 100644
index 0000000..e0af735
--- /dev/null
+++ b/package/kernel/modules/001-depends.mk
@@ -0,0 +1,37 @@
+#
+# Copyright (C) 2010-2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+define AddDepends/crc16
+ DEPENDS+= +kmod-lib-crc16 $(1)
+endef
+
+define AddDepends/hid
+ DEPENDS+= +kmod-hid $(1)
+endef
+
+define AddDepends/input
+ DEPENDS+= +kmod-input-core $(1)
+endef
+
+
+define AddDepends/nls
+ DEPENDS+= +kmod-nls-base $(foreach cp,$(1),+kmod-nls-$(cp))
+endef
+
+
+define SetDepends/rfkill
+ DEPENDS:= @(TARGET_ar71xx||TARGET_brcm47xx||TARGET_s3c24xx||TARGET_x86||TARGET_gemini||TARGET_cns3xxx||TARGET_ixp4xx)
+endef
+
+define AddDepends/rfkill
+ DEPENDS+= +(TARGET_ar71xx||TARGET_brcm47xx||TARGET_s3c24xx||TARGET_x86||TARGET_cns3xxx||TARGET_ixp4xx):kmod-rfkill $(1)
+endef
+
+
+define AddDepends/rtc
+ DEPENDS+= @RTC_SUPPORT
+endef
diff --git a/package/kernel/modules/block.mk b/package/kernel/modules/block.mk
new file mode 100644
index 0000000..1aa47de
--- /dev/null
+++ b/package/kernel/modules/block.mk
@@ -0,0 +1,606 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+BLOCK_MENU:=Block Devices
+
+define KernelPackage/aoe
+ SUBMENU:=$(BLOCK_MENU)
+ TITLE:=ATA over Ethernet support
+ KCONFIG:=CONFIG_ATA_OVER_ETH
+ FILES:=$(LINUX_DIR)/drivers/block/aoe/aoe.ko
+ AUTOLOAD:=$(call AutoLoad,30,aoe)
+endef
+
+define KernelPackage/aoe/description
+ Kernel support for ATA over Ethernet
+endef
+
+$(eval $(call KernelPackage,aoe))
+
+
+define KernelPackage/ata-core
+ SUBMENU:=$(BLOCK_MENU)
+ TITLE:=Serial and Parallel ATA support
+ DEPENDS:=@PCI_SUPPORT +kmod-scsi-core
+ KCONFIG:=CONFIG_ATA
+ FILES:=$(LINUX_DIR)/drivers/ata/libata.ko
+ AUTOLOAD:=$(call AutoLoad,21,libata,1)
+endef
+
+$(eval $(call KernelPackage,ata-core))
+
+
+define AddDepends/ata
+ SUBMENU:=$(BLOCK_MENU)
+ DEPENDS+=kmod-ata-core $(1)
+endef
+
+
+define KernelPackage/ata-ahci
+ TITLE:=AHCI Serial ATA support
+ KCONFIG:=CONFIG_SATA_AHCI
+ FILES:= \
+ $(LINUX_DIR)/drivers/ata/ahci.ko \
+ $(LINUX_DIR)/drivers/ata/libahci.ko
+ AUTOLOAD:=$(call AutoLoad,41,libahci ahci,1)
+ $(call AddDepends/ata)
+endef
+
+define KernelPackage/ata-ahci/description
+ Support for AHCI Serial ATA controllers.
+endef
+
+$(eval $(call KernelPackage,ata-ahci))
+
+
+define KernelPackage/ata-artop
+ TITLE:=ARTOP 6210/6260 PATA support
+ KCONFIG:=CONFIG_PATA_ARTOP
+ FILES:=$(LINUX_DIR)/drivers/ata/pata_artop.ko
+ AUTOLOAD:=$(call AutoLoad,41,pata_artop,1)
+ $(call AddDepends/ata)
+endef
+
+define KernelPackage/ata-artop/description
+ PATA support for ARTOP 6210/6260 host controllers.
+endef
+
+$(eval $(call KernelPackage,ata-artop))
+
+
+define KernelPackage/ata-marvell-sata
+ TITLE:=Marvell Serial ATA support
+ KCONFIG:=CONFIG_SATA_MV
+ FILES:=$(LINUX_DIR)/drivers/ata/sata_mv.ko
+ AUTOLOAD:=$(call AutoLoad,41,sata_mv,1)
+ $(call AddDepends/ata)
+endef
+
+define KernelPackage/ata-marvell-sata/description
+ SATA support for marvell chipsets
+endef
+
+$(eval $(call KernelPackage,ata-marvell-sata))
+
+
+define KernelPackage/ata-nvidia-sata
+ TITLE:=Nvidia Serial ATA support
+ KCONFIG:=CONFIG_SATA_NV
+ FILES:=$(LINUX_DIR)/drivers/ata/sata_nv.ko
+ AUTOLOAD:=$(call AutoLoad,41,sata_nv,1)
+ $(call AddDepends/ata)
+endef
+
+$(eval $(call KernelPackage,ata-nvidia-sata))
+
+
+define KernelPackage/ata-pdc202xx-old
+ SUBMENU:=$(BLOCK_MENU)
+ TITLE:=Older Promise PATA controller support
+ DEPENDS:=kmod-ata-core
+ KCONFIG:= \
+ CONFIG_ATA_SFF=y \
+ CONFIG_PATA_PDC_OLD
+ FILES:=$(LINUX_DIR)/drivers/ata/pata_pdc202xx_old.ko
+ AUTOLOAD:=$(call AutoLoad,41,pata_pdc202xx_old,1)
+endef
+
+define KernelPackage/ata-pdc202xx-old/description
+ This option enables support for the Promise 20246, 20262, 20263,
+ 20265 and 20267 adapters.
+endef
+
+$(eval $(call KernelPackage,ata-pdc202xx-old))
+
+
+define KernelPackage/ata-piix
+ TITLE:=Intel PIIX PATA/SATA support
+ KCONFIG:=CONFIG_ATA_PIIX
+ FILES:=$(LINUX_DIR)/drivers/ata/ata_piix.ko
+ AUTOLOAD:=$(call AutoLoad,41,ata_piix,1)
+ $(call AddDepends/ata)
+endef
+
+define KernelPackage/ata-piix/description
+ SATA support for Intel ICH5/6/7/8 series host controllers and
+ PATA support for Intel ESB/ICH/PIIX3/PIIX4 series host controllers.
+endef
+
+$(eval $(call KernelPackage,ata-piix))
+
+
+define KernelPackage/ata-sil
+ TITLE:=Silicon Image SATA support
+ KCONFIG:=CONFIG_SATA_SIL
+ FILES:=$(LINUX_DIR)/drivers/ata/sata_sil.ko
+ AUTOLOAD:=$(call AutoLoad,41,sata_sil,1)
+ $(call AddDepends/ata)
+endef
+
+define KernelPackage/ata-sil/description
+ Support for Silicon Image Serial ATA controllers.
+endef
+
+$(eval $(call KernelPackage,ata-sil))
+
+
+define KernelPackage/ata-sil24
+ TITLE:=Silicon Image 3124/3132 SATA support
+ KCONFIG:=CONFIG_SATA_SIL24
+ FILES:=$(LINUX_DIR)/drivers/ata/sata_sil24.ko
+ AUTOLOAD:=$(call AutoLoad,41,sata_sil24,1)
+ $(call AddDepends/ata)
+endef
+
+define KernelPackage/ata-sil24/description
+ Support for Silicon Image 3124/3132 Serial ATA controllers.
+endef
+
+$(eval $(call KernelPackage,ata-sil24))
+
+
+define KernelPackage/ata-sis
+ TITLE:=SIS SATA support
+ KCONFIG:=CONFIG_SATA_SIS
+ FILES:=$(LINUX_DIR)/drivers/ata/sata_sis.ko
+ AUTOLOAD:=$(call AutoLoad,41,sata_sis,1)
+ $(call AddDepends/ata)
+endef
+
+define KernelPackage/ata-sis/description
+ Support for SIS Serial ATA controllers.
+endef
+
+$(eval $(call KernelPackage,ata-sis))
+
+
+define KernelPackage/ata-via-sata
+ TITLE:=VIA SATA support
+ KCONFIG:=CONFIG_SATA_VIA
+ FILES:=$(LINUX_DIR)/drivers/ata/sata_via.ko
+ AUTOLOAD:=$(call AutoLoad,41,sata_via,1)
+ $(call AddDepends/ata)
+endef
+
+define KernelPackage/ata-via-sata/description
+ This option enables support for VIA Serial ATA.
+endef
+
+$(eval $(call KernelPackage,ata-via-sata))
+
+
+define KernelPackage/block2mtd
+ SUBMENU:=$(BLOCK_MENU)
+ TITLE:=Block device MTD emulation
+ KCONFIG:=CONFIG_MTD_BLOCK2MTD
+ FILES:=$(LINUX_DIR)/drivers/mtd/devices/block2mtd.ko
+endef
+
+$(eval $(call KernelPackage,block2mtd))
+
+
+define KernelPackage/dm
+ SUBMENU:=$(BLOCK_MENU)
+ TITLE:=Device Mapper
+ # All the "=n" are unnecessary, they're only there
+ # to stop the config from asking the question.
+ # MIRROR is M because I've needed it for pvmove.
+ KCONFIG:= \
+ CONFIG_BLK_DEV_MD=n \
+ CONFIG_DM_DEBUG=n \
+ CONFIG_DM_UEVENT=n \
+ CONFIG_DM_DELAY=n \
+ CONFIG_DM_MULTIPATH=n \
+ CONFIG_DM_ZERO=n \
+ CONFIG_DM_SNAPSHOT=n \
+ CONFIG_DM_LOG_USERSPACE=n \
+ CONFIG_MD=y \
+ CONFIG_BLK_DEV_DM \
+ CONFIG_DM_CRYPT \
+ CONFIG_DM_MIRROR
+ FILES:=$(LINUX_DIR)/drivers/md/dm-*.ko
+ AUTOLOAD:=$(call AutoLoad,30,dm-mod dm-log dm-region-hash dm-mirror dm-crypt)
+endef
+
+define KernelPackage/dm/description
+ Kernel module necessary for LVM2 support
+endef
+
+$(eval $(call KernelPackage,dm))
+
+
+define KernelPackage/md-mod
+ SUBMENU:=$(BLOCK_MENU)
+ TITLE:=MD RAID
+ KCONFIG:= \
+ CONFIG_MD=y \
+ CONFIG_BLK_DEV_MD=m \
+ CONFIG_MD_AUTODETECT=y \
+ CONFIG_MD_FAULTY=n
+ FILES:=$(LINUX_DIR)/drivers/md/md-mod.ko
+ AUTOLOAD:=$(call AutoLoad,27,md-mod)
+endef
+
+define KernelPackage/md-mod/description
+ Kernel RAID md module (md-mod.ko).
+ You will need to select at least one RAID level module below.
+endef
+
+$(eval $(call KernelPackage,md-mod))
+
+
+define KernelPackage/md/Depends
+ SUBMENU:=$(BLOCK_MENU)
+ DEPENDS:=kmod-md-mod $(1)
+endef
+
+
+define KernelPackage/md-linear
+$(call KernelPackage/md/Depends,)
+ TITLE:=RAID Linear Module
+ KCONFIG:=CONFIG_MD_LINEAR
+ FILES:=$(LINUX_DIR)/drivers/md/linear.ko
+ AUTOLOAD:=$(call AutoLoad,28,linear)
+endef
+
+define KernelPackage/md-linear/description
+ RAID "Linear" or "Append" driver module (linear.ko)
+endef
+
+$(eval $(call KernelPackage,md-linear))
+
+
+define KernelPackage/md-raid0
+$(call KernelPackage/md/Depends,)
+ TITLE:=RAID0 Module
+ KCONFIG:=CONFIG_MD_RAID0
+ FILES:=$(LINUX_DIR)/drivers/md/raid0.ko
+ AUTOLOAD:=$(call AutoLoad,28,raid0)
+endef
+
+define KernelPackage/md-raid0/description
+ RAID Level 0 (Striping) driver module (raid0.ko)
+endef
+
+$(eval $(call KernelPackage,md-raid0))
+
+
+define KernelPackage/md-raid1
+$(call KernelPackage/md/Depends,)
+ TITLE:=RAID1 Module
+ KCONFIG:=CONFIG_MD_RAID1
+ FILES:=$(LINUX_DIR)/drivers/md/raid1.ko
+ AUTOLOAD:=$(call AutoLoad,28,raid1)
+endef
+
+define KernelPackage/md-raid1/description
+ RAID Level 1 (Mirroring) driver (raid1.ko)
+endef
+
+$(eval $(call KernelPackage,md-raid1))
+
+
+define KernelPackage/md-raid10
+$(call KernelPackage/md/Depends,)
+ TITLE:=RAID10 Module
+ KCONFIG:=CONFIG_MD_RAID10
+ FILES:=$(LINUX_DIR)/drivers/md/raid10.ko
+ AUTOLOAD:=$(call AutoLoad,28,raid10)
+endef
+
+define KernelPackage/md-raid10/description
+ RAID Level 10 (Mirroring+Striping) driver module (raid10.ko)
+endef
+
+$(eval $(call KernelPackage,md-raid10))
+
+
+define KernelPackage/md-raid456
+$(call KernelPackage/md/Depends,)
+ TITLE:=RAID Level 456 Driver
+ KCONFIG:= \
+ CONFIG_XOR_BLOCKS \
+ CONFIG_ASYNC_CORE \
+ CONFIG_ASYNC_MEMCPY \
+ CONFIG_ASYNC_XOR \
+ CONFIG_ASYNC_PQ \
+ CONFIG_ASYNC_RAID6_RECOV \
+ CONFIG_ASYNC_RAID6_TEST=n \
+ CONFIG_MD_RAID6_PQ \
+ CONFIG_MD_RAID456 \
+ CONFIG_MULTICORE_RAID456=n
+ FILES:= \
+ $(LINUX_DIR)/crypto/xor.ko \
+ $(LINUX_DIR)/crypto/async_tx/async_tx.ko \
+ $(LINUX_DIR)/crypto/async_tx/async_memcpy.ko \
+ $(LINUX_DIR)/crypto/async_tx/async_xor.ko \
+ $(LINUX_DIR)/crypto/async_tx/async_pq.ko \
+ $(LINUX_DIR)/crypto/async_tx/async_raid6_recov.ko \
+ $(LINUX_DIR)/drivers/md/raid456.ko \
+ $(LINUX_DIR)/lib/raid6/raid6_pq.ko
+ AUTOLOAD:=$(call AutoLoad,28, xor async_tx async_memcpy async_xor raid6_pq async_pq async_raid6_recov raid456)
+endef
+
+define KernelPackage/md-raid456/description
+ RAID Level 4,5,6 kernel module (raid456.ko)
+
+ Includes the following modules required by
+ raid456.ko:
+ xor.ko
+ async_tx.ko
+ async_xor.ko
+ async_memcpy.ko
+ async_pq.ko
+ async_raid5_recov.ko
+ raid6_pq.ko
+endef
+
+$(eval $(call KernelPackage,md-raid456))
+
+
+define KernelPackage/md-multipath
+$(call KernelPackage/md/Depends,)
+ TITLE:=MD Multipath Module
+ KCONFIG:=CONFIG_MD_MULTIPATH
+ FILES:=$(LINUX_DIR)/drivers/md/multipath.ko
+ AUTOLOAD:=$(call AutoLoad,29,multipath)
+endef
+
+define KernelPackage/md-multipath/description
+ Multipath driver module (multipath.ko)
+endef
+
+$(eval $(call KernelPackage,md-multipath))
+
+
+define KernelPackage/ide-core
+ SUBMENU:=$(BLOCK_MENU)
+ TITLE:=IDE (ATA/ATAPI) device support
+ DEPENDS:=@PCI_SUPPORT
+ KCONFIG:= \
+ CONFIG_IDE \
+ CONFIG_BLK_DEV_IDE \
+ CONFIG_BLK_DEV_IDEDISK \
+ CONFIG_IDE_GD \
+ CONFIG_IDE_GD_ATA=y \
+ CONFIG_IDE_GD_ATAPI=n \
+ CONFIG_IDEPCI_PCIBUS_ORDER=y \
+ CONFIG_BLK_DEV_IDEDMA_PCI=y \
+ CONFIG_BLK_DEV_IDEPCI=y
+ FILES:= \
+ $(LINUX_DIR)/drivers/ide/ide-core.ko \
+ $(LINUX_DIR)/drivers/ide/ide-gd_mod.ko
+ AUTOLOAD:= \
+ $(call AutoLoad,20,ide-core,1) \
+ $(call AutoLoad,40,ide-gd_mod,1)
+endef
+
+define KernelPackage/ide-core/description
+ Kernel support for IDE, useful for usb mass storage devices (e.g. on WL-HDD)
+ Includes:
+ - ide-core
+ - ide-gd_mod
+endef
+
+$(eval $(call KernelPackage,ide-core))
+
+
+define AddDepends/ide
+ SUBMENU:=$(BLOCK_MENU)
+ DEPENDS+=kmod-ide-core $(1)
+endef
+
+
+define KernelPackage/ide-generic
+ SUBMENU:=$(BLOCK_MENU)
+ DEPENDS:=@PCI_SUPPORT
+ TITLE:=Kernel support for generic PCI IDE chipsets
+ KCONFIG:=CONFIG_BLK_DEV_GENERIC
+ FILES:=$(LINUX_DIR)/drivers/ide/ide-pci-generic.ko
+ AUTOLOAD:=$(call AutoLoad,30,ide-pci-generic,1)
+ $(call AddDepends/ide)
+endef
+
+$(eval $(call KernelPackage,ide-generic))
+
+
+define KernelPackage/ide-generic-old
+ SUBMENU:=$(BLOCK_MENU)
+ TITLE:=Kernel support for generic (legacy) IDE chipsets
+ KCONFIG:=CONFIG_IDE_GENERIC
+ FILES:=$(LINUX_DIR)/drivers/ide/ide-generic.ko
+ AUTOLOAD:=$(call AutoLoad,30,ide-generic,1)
+ $(call AddDepends/ide)
+endef
+
+$(eval $(call KernelPackage,ide-generic-old))
+
+
+define KernelPackage/ide-aec62xx
+ TITLE:=Acard AEC62xx IDE driver
+ DEPENDS:=@PCI_SUPPORT
+ KCONFIG:=CONFIG_BLK_DEV_AEC62XX
+ FILES:=$(LINUX_DIR)/drivers/ide/aec62xx.ko
+ AUTOLOAD:=$(call AutoLoad,30,aec62xx,1)
+ $(call AddDepends/ide)
+endef
+
+define KernelPackage/ide-aec62xx/description
+ Support for Acard AEC62xx (Artop ATP8xx) IDE controllers.
+endef
+
+$(eval $(call KernelPackage,ide-aec62xx,1))
+
+
+define KernelPackage/ide-pdc202xx
+ TITLE:=Promise PDC202xx IDE driver
+ DEPENDS:=@PCI_SUPPORT
+ KCONFIG:=CONFIG_BLK_DEV_PDC202XX_OLD
+ FILES:=$(LINUX_DIR)/drivers/ide/pdc202xx_old.ko
+ AUTOLOAD:=$(call AutoLoad,30,pdc202xx_old,1)
+ $(call AddDepends/ide)
+endef
+
+define KernelPackage/ide-pdc202xx/description
+ Support for the Promise Ultra 33/66/100 (PDC202{46|62|65|67|68}) IDE
+ controllers.
+endef
+
+$(eval $(call KernelPackage,ide-pdc202xx))
+
+
+define KernelPackage/ide-it821x
+ TITLE:=ITE IT821x IDE driver
+ DEPENDS:=@PCI_SUPPORT
+ KCONFIG:=CONFIG_BLK_DEV_IT821X
+ FILES=$(LINUX_DIR)/drivers/ide/it821x.ko
+ AUTOLOAD:=$(call AutoLoad,30,it821x,1)
+ $(call AddDepends/ide)
+endef
+
+define KernelPackage/ide-it821x/description
+ Kernel module for the ITE IDE821x IDE controllers.
+endef
+
+$(eval $(call KernelPackage,ide-it821x))
+
+
+define KernelPackage/libsas
+ SUBMENU:=$(BLOCK_MENU)
+ TITLE:=SAS Domain Transport Attributes
+ KCONFIG:=CONFIG_SCSI_SAS_LIBSAS \
+ CONFIG_SCSI_SAS_ATTRS \
+ CONFIG_SCSI_SAS_ATA=y \
+ CONFIG_SCSI_SAS_HOST_SMP=y \
+ CONFIG_SCSI_SAS_LIBSAS_DEBUG=y
+ FILES:= \
+ $(LINUX_DIR)/drivers/scsi/scsi_transport_sas.ko \
+ $(LINUX_DIR)/drivers/scsi/libsas/libsas.ko
+ AUTOLOAD:=$(call AutoLoad,29,scsi_transport_sas libsas,1)
+endef
+
+define KernelPackage/libsas/description
+ SAS Domain Transport Attributes support.
+endef
+
+$(eval $(call KernelPackage,libsas,1))
+
+
+define KernelPackage/loop
+ SUBMENU:=$(BLOCK_MENU)
+ TITLE:=Loopback device support
+ KCONFIG:= \
+ CONFIG_BLK_DEV_LOOP \
+ CONFIG_BLK_DEV_CRYPTOLOOP=n
+ FILES:=$(LINUX_DIR)/drivers/block/loop.ko
+ AUTOLOAD:=$(call AutoLoad,30,loop)
+endef
+
+define KernelPackage/loop/description
+ Kernel module for loopback device support
+endef
+
+$(eval $(call KernelPackage,loop))
+
+
+define KernelPackage/mvsas
+ SUBMENU:=$(BLOCK_MENU)
+ TITLE:=Marvell 88SE6440 SAS/SATA driver
+ DEPENDS:=@TARGET_x86 +kmod-libsas
+ KCONFIG:= \
+ CONFIG_SCSI_MVSAS \
+ CONFIG_SCSI_MVSAS_TASKLET=n
+ FILES:=$(LINUX_DIR)/drivers/scsi/mvsas/mvsas.ko
+ AUTOLOAD:=$(call AutoLoad,40,mvsas,1)
+endef
+
+define KernelPackage/mvsas/description
+ Kernel support for the Marvell SAS SCSI adapters
+endef
+
+$(eval $(call KernelPackage,mvsas))
+
+
+define KernelPackage/nbd
+ SUBMENU:=$(BLOCK_MENU)
+ TITLE:=Network block device support
+ KCONFIG:=CONFIG_BLK_DEV_NBD
+ FILES:=$(LINUX_DIR)/drivers/block/nbd.ko
+ AUTOLOAD:=$(call AutoLoad,30,nbd)
+endef
+
+define KernelPackage/nbd/description
+ Kernel module for network block device support
+endef
+
+$(eval $(call KernelPackage,nbd))
+
+
+define KernelPackage/scsi-core
+ SUBMENU:=$(BLOCK_MENU)
+ TITLE:=SCSI device support
+ KCONFIG:= \
+ CONFIG_SCSI \
+ CONFIG_BLK_DEV_SD
+ FILES:= \
+ $(if $(findstring y,$(CONFIG_SCSI)),,$(LINUX_DIR)/drivers/scsi/scsi_mod.ko) \
+ $(LINUX_DIR)/drivers/scsi/sd_mod.ko
+ AUTOLOAD:=$(call AutoLoad,20,scsi_mod,1) $(call AutoLoad,40,sd_mod,1)
+endef
+
+$(eval $(call KernelPackage,scsi-core))
+
+
+define KernelPackage/scsi-generic
+ SUBMENU:=$(BLOCK_MENU)
+ TITLE:=Kernel support for SCSI generic
+ DEPENDS:=+kmod-scsi-core
+ KCONFIG:= \
+ CONFIG_CHR_DEV_SG
+ FILES:= \
+ $(LINUX_DIR)/drivers/scsi/sg.ko
+ AUTOLOAD:=$(call AutoLoad,65,sg)
+endef
+
+$(eval $(call KernelPackage,scsi-generic))
+
+
+define KernelPackage/scsi-cdrom
+ SUBMENU:=$(BLOCK_MENU)
+ TITLE:=Kernel support for CD / DVD drives
+ DEPENDS:=+kmod-scsi-core
+ KCONFIG:= \
+ CONFIG_BLK_DEV_SR \
+ CONFIG_BLK_DEV_SR_VENDOR=n
+ FILES:= \
+ $(LINUX_DIR)/drivers/cdrom/cdrom.ko \
+ $(LINUX_DIR)/drivers/scsi/sr_mod.ko
+ AUTOLOAD:=$(call AutoLoad,30,cdrom) $(call AutoLoad,45,sr_mod)
+endef
+
+$(eval $(call KernelPackage,scsi-cdrom))
+
diff --git a/package/kernel/modules/crypto.mk b/package/kernel/modules/crypto.mk
new file mode 100644
index 0000000..6a3b5a6
--- /dev/null
+++ b/package/kernel/modules/crypto.mk
@@ -0,0 +1,496 @@
+#
+# Copyright (C) 2006-2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+CRYPTO_MENU:=Cryptographic API modules
+
+CRYPTO_MODULES = ALGAPI2=crypto_algapi
+
+CRYPTOMGR_MODULES = \
+ AEAD2=aead \
+ MANAGER2=cryptomgr \
+ BLKCIPHER2=crypto_blkcipher
+
+crypto_confvar=CONFIG_CRYPTO_$(word 1,$(subst =,$(space),$(1)))
+crypto_file=$(LINUX_DIR)/crypto/$(word 2,$(subst =,$(space),$(1))).ko
+crypto_name=$(if $(findstring y,$($(call crypto_confvar,$(1)))),,$(word 2,$(subst =,$(space),$(1))))
+
+define KernelPackage/crypto-core
+ SUBMENU:=$(CRYPTO_MENU)
+ TITLE:=Core CryptoAPI modules
+ KCONFIG:= \
+ CONFIG_CRYPTO=y \
+ CONFIG_CRYPTO_HW=y \
+ CONFIG_CRYPTO_ALGAPI \
+ $(foreach mod,$(CRYPTO_MODULES),$(call crypto_confvar,$(mod)))
+ FILES:=$(foreach mod,$(CRYPTO_MODULES),$(call crypto_file,$(mod)))
+ AUTOLOAD:=$(call AutoLoad,01,$(foreach mod,$(CRYPTO_MODULES),$(call crypto_name,$(mod))),1)
+endef
+$(eval $(call KernelPackage,crypto-core))
+
+
+define AddDepends/crypto
+ SUBMENU:=$(CRYPTO_MENU)
+ DEPENDS+=+kmod-crypto-core $(1)
+endef
+
+define KernelPackage/crypto-hash
+ TITLE:=CryptoAPI hash support
+ KCONFIG:=CONFIG_CRYPTO_HASH2
+ FILES:=$(LINUX_DIR)/crypto/crypto_hash.ko
+ AUTOLOAD:=$(call AutoLoad,02,crypto_hash,1)
+ $(call AddDepends/crypto)
+endef
+$(eval $(call KernelPackage,crypto-hash))
+
+define KernelPackage/crypto-manager
+ TITLE:=CryptoAPI algorithm manager
+ DEPENDS:=+kmod-crypto-hash
+ KCONFIG:= \
+ CONFIG_CRYPTO_AEAD \
+ CONFIG_CRYPTO_BLKCIPHER \
+ CONFIG_CRYPTO_MANAGER \
+ $(foreach mod,$(CRYPTOMGR_MODULES),$(call crypto_confvar,$(mod)))
+ FILES:=$(foreach mod,$(CRYPTOMGR_MODULES),$(call crypto_file,$(mod)))
+ AUTOLOAD:=$(call AutoLoad,03,$(foreach mod,$(CRYPTOMGR_MODULES),$(call crypto_name,$(mod))))
+ $(call AddDepends/crypto)
+endef
+$(eval $(call KernelPackage,crypto-manager))
+
+define KernelPackage/crypto-pcompress
+ TITLE:=CryptoAPI Partial (de)compression operations
+ KCONFIG:= \
+ CONFIG_CRYPTO_PCOMP=y \
+ CONFIG_CRYPTO_PCOMP2
+ FILES:=$(LINUX_DIR)/crypto/pcompress.ko
+ AUTOLOAD:=$(call AutoLoad,09,pcompress)
+ $(call AddDepends/crypto)
+endef
+$(eval $(call KernelPackage,crypto-pcompress))
+
+define KernelPackage/crypto-user
+ TITLE:=CryptoAPI userspace interface
+ DEPENDS:=+kmod-crypto-hash +kmod-crypto-manager
+ KCONFIG:= \
+ CONFIG_CRYPTO_USER_API \
+ CONFIG_CRYPTO_USER_API_HASH \
+ CONFIG_CRYPTO_USER_API_SKCIPHER
+ FILES:= \
+ $(LINUX_DIR)/crypto/af_alg.ko \
+ $(LINUX_DIR)/crypto/algif_hash.ko \
+ $(LINUX_DIR)/crypto/algif_skcipher.ko
+ AUTOLOAD:=$(call AutoLoad,09,af_alg algif_hash algif_skcipher)
+ $(call AddDepends/crypto)
+endef
+$(eval $(call KernelPackage,crypto-user))
+
+define KernelPackage/crypto-wq
+ TITLE:=CryptoAPI work queue handling
+ KCONFIG:=CONFIG_CRYPTO_WORKQUEUE
+ FILES:=$(LINUX_DIR)/crypto/crypto_wq.ko
+ AUTOLOAD:=$(call AutoLoad,09,crypto_wq)
+ $(call AddDepends/crypto)
+endef
+$(eval $(call KernelPackage,crypto-wq))
+
+define KernelPackage/crypto-rng
+ TITLE:=CryptoAPI random number generation
+ KCONFIG:=CONFIG_CRYPTO_RNG2
+ FILES:= \
+ $(LINUX_DIR)/crypto/rng.ko \
+ $(LINUX_DIR)/crypto/krng.ko
+ AUTOLOAD:=$(call AutoLoad,09,rng krng)
+ $(call AddDepends/crypto)
+endef
+$(eval $(call KernelPackage,crypto-rng))
+
+define KernelPackage/crypto-iv
+ TITLE:=CryptoAPI initialization vectors
+ DEPENDS:=+kmod-crypto-manager +kmod-crypto-rng +kmod-crypto-wq
+ KCONFIG:= CONFIG_CRYPTO_BLKCIPHER2
+ FILES:= \
+ $(LINUX_DIR)/crypto/eseqiv.ko \
+ $(LINUX_DIR)/crypto/chainiv.ko
+ AUTOLOAD:=$(call AutoLoad,10,eseqiv chainiv)
+ $(call AddDepends/crypto)
+endef
+$(eval $(call KernelPackage,crypto-iv))
+
+define KernelPackage/crypto-hw-padlock
+ TITLE:=VIA PadLock ACE with AES/SHA hw crypto module
+ DEPENDS:=+kmod-crypto-aes
+ KCONFIG:= \
+ CONFIG_CRYPTO_DEV_PADLOCK \
+ CONFIG_CRYPTO_DEV_PADLOCK_AES \
+ CONFIG_CRYPTO_DEV_PADLOCK_SHA
+ FILES:= \
+ $(LINUX_DIR)/drivers/crypto/padlock-aes.ko \
+ $(LINUX_DIR)/drivers/crypto/padlock-sha.ko
+ AUTOLOAD:=$(call AutoLoad,09,padlock-aes padlock-sha)
+ $(call AddDepends/crypto)
+endef
+
+$(eval $(call KernelPackage,crypto-hw-padlock))
+
+
+define KernelPackage/crypto-hw-geode
+ TITLE:=AMD Geode hardware crypto module
+ KCONFIG:= \
+ CONFIG_CRYPTO_DEV_GEODE
+ FILES:=$(LINUX_DIR)/drivers/crypto/geode-aes.ko
+ AUTOLOAD:=$(call AutoLoad,09,geode-aes)
+ $(call AddDepends/crypto)
+endef
+
+$(eval $(call KernelPackage,crypto-hw-geode))
+
+
+define KernelPackage/crypto-hw-hifn-795x
+ TITLE:=HIFN 795x crypto accelerator
+ KCONFIG:= \
+ CONFIG_HW_RANDOM=y \
+ CONFIG_CRYPTO_DEV_HIFN_795X \
+ CONFIG_CRYPTO_DEV_HIFN_795X_RNG=y
+ FILES:=$(LINUX_DIR)/drivers/crypto/hifn_795x.ko
+ AUTOLOAD:=$(call AutoLoad,09,hifn_795x)
+ $(call AddDepends/crypto,+kmod-crypto-des)
+endef
+
+$(eval $(call KernelPackage,crypto-hw-hifn-795x))
+
+
+define KernelPackage/crypto-hw-ppc4xx
+ TITLE:=AMCC PPC4xx hardware crypto module
+ DEPENDS:=@TARGET_ppc40x||TARGET_ppc44x
+ KCONFIG:= \
+ CONFIG_CRYPTO_DEV_PPC4XX
+ FILES:=$(LINUX_DIR)/drivers/crypto/amcc/crypto4xx.ko
+ AUTOLOAD:=$(call AutoLoad,90,crypto4xx)
+ $(call AddDepends/crypto)
+endef
+
+define KernelPackage/crypto-hw-ppc4xx/description
+ Kernel support for the AMCC PPC4xx HW crypto engine.
+endef
+
+$(eval $(call KernelPackage,crypto-hw-ppc4xx))
+
+
+define KernelPackage/crypto-aes
+ TITLE:=AES cipher CryptoAPI module
+ KCONFIG:=CONFIG_CRYPTO_AES CONFIG_CRYPTO_AES_586
+ FILES:=$(LINUX_DIR)/crypto/aes_generic.ko
+ AUTOLOAD:=$(call AutoLoad,09,aes_generic)
+ $(call AddDepends/crypto)
+endef
+
+define KernelPackage/crypto-aes/x86
+ FILES+=$(LINUX_DIR)/arch/x86/crypto/aes-i586.ko
+ AUTOLOAD:=$(call AutoLoad,09,aes_generic aes-i586)
+endef
+
+$(eval $(call KernelPackage,crypto-aes))
+
+
+define KernelPackage/crypto-arc4
+ TITLE:=ARC4 (RC4) cipher CryptoAPI module
+ KCONFIG:=CONFIG_CRYPTO_ARC4
+ FILES:=$(LINUX_DIR)/crypto/arc4.ko
+ AUTOLOAD:=$(call AutoLoad,09,arc4)
+ $(call AddDepends/crypto,+!LINUX_3_3:kmod-crypto-manager)
+endef
+
+$(eval $(call KernelPackage,crypto-arc4))
+
+
+define KernelPackage/crypto-authenc
+ TITLE:=Combined mode wrapper for IPsec
+ DEPENDS:=+kmod-crypto-manager
+ KCONFIG:=CONFIG_CRYPTO_AUTHENC
+ FILES:=$(LINUX_DIR)/crypto/authenc.ko
+ AUTOLOAD:=$(call AutoLoad,09,authenc)
+ $(call AddDepends/crypto)
+endef
+
+$(eval $(call KernelPackage,crypto-authenc))
+
+define KernelPackage/crypto-cbc
+ TITLE:=Cipher Block Chaining CryptoAPI module
+ DEPENDS:=+kmod-crypto-manager
+ KCONFIG:=CONFIG_CRYPTO_CBC
+ FILES:=$(LINUX_DIR)/crypto/cbc.ko
+ AUTOLOAD:=$(call AutoLoad,09,cbc)
+ $(call AddDepends/crypto)
+endef
+
+$(eval $(call KernelPackage,crypto-cbc))
+
+define KernelPackage/crypto-crc32c
+ TITLE:=CRC32c CRC module
+ DEPENDS:=+kmod-crypto-hash
+ KCONFIG:=CONFIG_CRYPTO_CRC32C
+ FILES:=$(LINUX_DIR)/crypto/crc32c.ko
+ AUTOLOAD:=$(call AutoLoad,04,crc32c,1)
+ $(call AddDepends/crypto)
+endef
+
+$(eval $(call KernelPackage,crypto-crc32c))
+
+define KernelPackage/crypto-des
+ TITLE:=DES/3DES cipher CryptoAPI module
+ KCONFIG:=CONFIG_CRYPTO_DES
+ FILES:=$(LINUX_DIR)/crypto/des_generic.ko
+ AUTOLOAD:=$(call AutoLoad,09,des_generic)
+ $(call AddDepends/crypto)
+endef
+
+$(eval $(call KernelPackage,crypto-des))
+
+define KernelPackage/crypto-deflate
+ TITLE:=Deflate compression CryptoAPI module
+ DEPENDS:=+kmod-lib-zlib
+ KCONFIG:=CONFIG_CRYPTO_DEFLATE
+ FILES:=$(LINUX_DIR)/crypto/deflate.ko
+ AUTOLOAD:=$(call AutoLoad,09,deflate)
+ $(call AddDepends/crypto)
+endef
+
+$(eval $(call KernelPackage,crypto-deflate))
+
+define KernelPackage/crypto-ecb
+ TITLE:=Electronic CodeBook CryptoAPI module
+ DEPENDS:=+kmod-crypto-manager
+ KCONFIG:=CONFIG_CRYPTO_ECB
+ FILES:=$(LINUX_DIR)/crypto/ecb.ko
+ AUTOLOAD:=$(call AutoLoad,09,ecb)
+ $(call AddDepends/crypto)
+endef
+
+$(eval $(call KernelPackage,crypto-ecb))
+
+
+define KernelPackage/crypto-hmac
+ TITLE:=HMAC digest CryptoAPI module
+ DEPENDS:=+kmod-crypto-hash
+ KCONFIG:=CONFIG_CRYPTO_HMAC
+ FILES:=$(LINUX_DIR)/crypto/hmac.ko
+ DEPENDS:=+kmod-crypto-manager
+ AUTOLOAD:=$(call AutoLoad,09,hmac)
+ $(call AddDepends/crypto)
+endef
+
+$(eval $(call KernelPackage,crypto-hmac))
+
+
+define KernelPackage/crypto-md4
+ TITLE:=MD4 digest CryptoAPI module
+ DEPENDS:=+kmod-crypto-hash
+ KCONFIG:=CONFIG_CRYPTO_MD4
+ FILES:=$(LINUX_DIR)/crypto/md4.ko
+ AUTOLOAD:=$(call AutoLoad,09,md4)
+ $(call AddDepends/crypto)
+endef
+
+$(eval $(call KernelPackage,crypto-md4))
+
+
+define KernelPackage/crypto-md5
+ TITLE:=MD5 digest CryptoAPI module
+ DEPENDS:=+kmod-crypto-hash
+ KCONFIG:=CONFIG_CRYPTO_MD5
+ FILES:=$(LINUX_DIR)/crypto/md5.ko
+ AUTOLOAD:=$(call AutoLoad,09,md5)
+ $(call AddDepends/crypto)
+endef
+
+$(eval $(call KernelPackage,crypto-md5))
+
+
+define KernelPackage/crypto-michael-mic
+ TITLE:=Michael MIC keyed digest CryptoAPI module
+ DEPENDS:=+kmod-crypto-hash
+ KCONFIG:=CONFIG_CRYPTO_MICHAEL_MIC
+ FILES:=$(LINUX_DIR)/crypto/michael_mic.ko
+ AUTOLOAD:=$(call AutoLoad,09,michael_mic)
+ $(call AddDepends/crypto)
+endef
+
+$(eval $(call KernelPackage,crypto-michael-mic))
+
+
+define KernelPackage/crypto-sha1
+ TITLE:=SHA1 digest CryptoAPI module
+ DEPENDS:=+kmod-crypto-hash
+ KCONFIG:=CONFIG_CRYPTO_SHA1
+ FILES:=$(LINUX_DIR)/crypto/sha1_generic.ko
+ AUTOLOAD:=$(call AutoLoad,09,sha1_generic)
+ $(call AddDepends/crypto)
+endef
+
+$(eval $(call KernelPackage,crypto-sha1))
+
+define KernelPackage/crypto-sha256
+ TITLE:=SHA224 SHA256 digest CryptoAPI module
+ DEPENDS:=+kmod-crypto-hash
+ KCONFIG:=CONFIG_CRYPTO_SHA256
+ FILES:=$(LINUX_DIR)/crypto/sha256_generic.ko
+ AUTOLOAD:=$(call AutoLoad,09,sha256_generic)
+ $(call AddDepends/crypto)
+endef
+
+$(eval $(call KernelPackage,crypto-sha256))
+
+ifeq ($(strip $(call CompareKernelPatchVer,$(KERNEL_PATCHVER),ge,3.6.0)),1)
+camellia_mod_suffix=_generic
+endif
+ifeq ($(strip $(call CompareKernelPatchVer,$(KERNEL_PATCHVER),ge,3.7.0)),1)
+cast56_mod_suffix=_generic
+endif
+
+define KernelPackage/crypto-misc
+ TITLE:=Other CryptoAPI modules
+ DEPENDS:=+kmod-crypto-manager
+ KCONFIG:= \
+ CONFIG_CRYPTO_ANUBIS \
+ CONFIG_CRYPTO_BLOWFISH \
+ CONFIG_CRYPTO_CAMELLIA \
+ CONFIG_CRYPTO_CAST5 \
+ CONFIG_CRYPTO_CAST6 \
+ CONFIG_CRYPTO_FCRYPT \
+ CONFIG_CRYPTO_KHAZAD \
+ CONFIG_CRYPTO_SERPENT \
+ CONFIG_CRYPTO_SHA512 \
+ CONFIG_CRYPTO_TEA \
+ CONFIG_CRYPTO_TGR192 \
+ CONFIG_CRYPTO_TWOFISH \
+ CONFIG_CRYPTO_TWOFISH_COMMON \
+ CONFIG_CRYPTO_TWOFISH_586 \
+ CONFIG_CRYPTO_WP512
+ FILES:= \
+ $(LINUX_DIR)/crypto/anubis.ko \
+ $(LINUX_DIR)/crypto/camellia$(camellia_mod_suffix).ko \
+ $(LINUX_DIR)/crypto/cast5$(cast56_mod_suffix).ko \
+ $(LINUX_DIR)/crypto/cast6$(cast56_mod_suffix).ko \
+ $(LINUX_DIR)/crypto/fcrypt.ko \
+ $(LINUX_DIR)/crypto/khazad.ko \
+ $(LINUX_DIR)/crypto/sha512_generic.ko \
+ $(LINUX_DIR)/crypto/tea.ko \
+ $(LINUX_DIR)/crypto/tgr192.ko \
+ $(LINUX_DIR)/crypto/twofish_common.ko \
+ $(LINUX_DIR)/crypto/wp512.ko \
+ $(LINUX_DIR)/crypto/twofish_generic.ko
+ FILES += \
+ $(LINUX_DIR)/crypto/blowfish_common.ko \
+ $(LINUX_DIR)/crypto/blowfish_generic.ko \
+ $(LINUX_DIR)/crypto/serpent_generic.ko
+ $(call AddDepends/crypto)
+endef
+
+
+define KernelPackage/crypto-misc/x86
+ FILES+=$(LINUX_DIR)/arch/x86/crypto/twofish-i586.ko
+endef
+
+$(eval $(call KernelPackage,crypto-misc))
+
+
+define KernelPackage/crypto-ocf
+ TITLE:=OCF modules
+ DEPENDS:=+@OPENSSL_ENGINE_CRYPTO @!TARGET_uml +kmod-crypto-manager
+ KCONFIG:= \
+ CONFIG_OCF_OCF \
+ CONFIG_OCF_CRYPTODEV \
+ CONFIG_OCF_CRYPTOSOFT \
+ CONFIG_OCF_FIPS=y \
+ CONFIG_OCF_RANDOMHARVEST=y
+ FILES:= \
+ $(LINUX_DIR)/crypto/ocf/ocf.ko \
+ $(LINUX_DIR)/crypto/ocf/cryptodev.ko \
+ $(LINUX_DIR)/crypto/ocf/cryptosoft.ko
+ AUTOLOAD:=$(call AutoLoad,09, \
+ ocf \
+ cryptodev \
+ cryptosoft \
+ )
+ $(call AddDepends/crypto)
+endef
+
+$(eval $(call KernelPackage,crypto-ocf))
+
+
+define KernelPackage/crypto-ocf-hifn7751
+ TITLE:=OCF support for Hifn 6500/7751/7811/795x, Invertex AEON and NetSec 7751 devices
+ DEPENDS:=+@OPENSSL_ENGINE_CRYPTO @PCI_SUPPORT @!TARGET_uml kmod-crypto-ocf
+ KCONFIG:=CONFIG_OCF_HIFN
+ FILES:=$(LINUX_DIR)/crypto/ocf/hifn/hifn7751.ko
+ AUTOLOAD:=$(call AutoLoad,10,hifn7751)
+ $(call AddDepends/crypto)
+endef
+
+$(eval $(call KernelPackage,crypto-ocf-hifn7751))
+
+
+define KernelPackage/crypto-ocf-hifnhipp
+ TITLE:=OCF support for Hifn 7855/8155 devices
+ DEPENDS:=+@OPENSSL_ENGINE_CRYPTO @PCI_SUPPORT @!TARGET_uml kmod-crypto-ocf
+ KCONFIG:=CONFIG_OCF_HIFNHIPP
+ FILES:=$(LINUX_DIR)/crypto/ocf/hifn/hifnHIPP.ko
+ AUTOLOAD:=$(call AutoLoad,10,hifnHIPP)
+ $(call AddDepends/crypto)
+endef
+
+$(eval $(call KernelPackage,crypto-ocf-hifnhipp))
+
+
+define KernelPackage/crypto-null
+ TITLE:=Null CryptoAPI module
+ KCONFIG:=CONFIG_CRYPTO_NULL
+ FILES:=$(LINUX_DIR)/crypto/crypto_null.ko
+ AUTOLOAD:=$(call AutoLoad,09,crypto_null)
+ $(call AddDepends/crypto)
+endef
+
+$(eval $(call KernelPackage,crypto-null))
+
+
+define KernelPackage/crypto-test
+ TITLE:=Test CryptoAPI module
+ KCONFIG:=CONFIG_CRYPTO_TEST
+ FILES:=$(LINUX_DIR)/crypto/tcrypt.ko
+ $(call AddDepends/crypto)
+endef
+
+$(eval $(call KernelPackage,crypto-test))
+
+
+define KernelPackage/crypto-xts
+ TITLE:=XTS cipher CryptoAPI module
+ DEPENDS:=+kmod-crypto-manager
+ KCONFIG:= \
+ CONFIG_CRYPTO_GF128MUL \
+ CONFIG_CRYPTO_XTS
+ FILES:= \
+ $(LINUX_DIR)/crypto/xts.ko \
+ $(LINUX_DIR)/crypto/gf128mul.ko
+ AUTOLOAD:=$(call AutoLoad,09, \
+ gf128mul \
+ xts \
+ )
+ $(call AddDepends/crypto)
+endef
+
+$(eval $(call KernelPackage,crypto-xts))
+
+define KernelPackage/crypto-mv-cesa
+ TITLE:=Marvell crypto engine
+ DEPENDS:=+kmod-crypto-manager +kmod-crypto-aes @TARGET_kirkwood||TARGET_orion||TARGET_mvebu
+ KCONFIG:=CONFIG_CRYPTO_DEV_MV_CESA
+ FILES:=$(LINUX_DIR)/drivers/crypto/mv_cesa.ko
+ AUTOLOAD:=$(call AutoLoad,09,mv_cesa)
+ $(call AddDepends/crypto)
+endef
+
+$(eval $(call KernelPackage,crypto-mv-cesa))
diff --git a/package/kernel/modules/firewire.mk b/package/kernel/modules/firewire.mk
new file mode 100644
index 0000000..34edf0c
--- /dev/null
+++ b/package/kernel/modules/firewire.mk
@@ -0,0 +1,77 @@
+#
+# Copyright (C) 2008-2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+FIREWIRE_MENU:=FireWire support
+
+
+define KernelPackage/firewire
+ SUBMENU:=$(FIREWIRE_MENU)
+ TITLE:=Support for FireWire (new stack)
+ DEPENDS:=@PCI_SUPPORT +kmod-lib-crc-itu-t
+ KCONFIG:=CONFIG_FIREWIRE
+ FILES:=$(LINUX_DIR)/drivers/firewire/firewire-core.ko
+ AUTOLOAD:=$(call AutoLoad,20,firewire-core)
+endef
+
+define KernelPackage/firewire/description
+ Kernel support for FireWire (new stack)
+endef
+
+$(eval $(call KernelPackage,firewire))
+
+
+define KernelPackage/firewire-ohci
+ SUBMENU:=$(FIREWIRE_MENU)
+ TITLE:=Support for OHCI-1394 controllers
+ DEPENDS:=kmod-firewire
+ KCONFIG:= \
+ CONFIG_FIREWIRE_OHCI \
+ CONFIG_FIREWIRE_OHCI_DEBUG=n \
+ CONFIG_FIREWIRE_OHCI_REMOTE_DMA=n
+ FILES:=$(LINUX_DIR)/drivers/firewire/firewire-ohci.ko
+ AUTOLOAD:=$(call AutoLoad,50,firewire-ohci)
+endef
+
+
+define KernelPackage/firewire-ohci/description
+ Kernel support for FireWire OHCI-1394 controllers
+endef
+
+$(eval $(call KernelPackage,firewire-ohci))
+
+
+define KernelPackage/firewire-sbp2
+ SUBMENU:=$(FIREWIRE_MENU)
+ TITLE:=Support for SBP-2 devices over FireWire
+ DEPENDS:=kmod-firewire +kmod-scsi-core
+ KCONFIG:=CONFIG_FIREWIRE_SBP2
+ FILES:=$(LINUX_DIR)/drivers/firewire/firewire-sbp2.ko
+ AUTOLOAD:=$(call AutoLoad,50,firewire-sbp2)
+endef
+
+define KernelPackage/firewire-sbp2/description
+ Kernel support for SBP-2 devices over FireWire
+endef
+
+$(eval $(call KernelPackage,firewire-sbp2))
+
+
+define KernelPackage/firewire-net
+ SUBMENU:=$(FIREWIRE_MENU)
+ TITLE:=Support for IP networking over FireWire
+ DEPENDS:=kmod-firewire
+ KCONFIG:=CONFIG_FIREWIRE_NET
+ FILES:=$(LINUX_DIR)/drivers/firewire/firewire-net.ko
+ AUTOLOAD:=$(call AutoLoad,50,firewire-net)
+endef
+
+define KernelPackage/firewire-net/description
+ Kernel support for IPv4 over FireWire
+endef
+
+$(eval $(call KernelPackage,firewire-net))
+
diff --git a/package/kernel/modules/fs.mk b/package/kernel/modules/fs.mk
new file mode 100644
index 0000000..1b1fdd4
--- /dev/null
+++ b/package/kernel/modules/fs.mk
@@ -0,0 +1,371 @@
+#
+# Copyright (C) 2006-2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+FS_MENU:=Filesystems
+
+define KernelPackage/fs-autofs4
+ SUBMENU:=$(FS_MENU)
+ TITLE:=AUTOFS4 filesystem support
+ KCONFIG:=CONFIG_AUTOFS4_FS
+ FILES:=$(LINUX_DIR)/fs/autofs4/autofs4.ko
+ AUTOLOAD:=$(call AutoLoad,30,autofs4)
+endef
+
+define KernelPackage/fs-autofs4/description
+ Kernel module for AutoFS4 support
+endef
+
+$(eval $(call KernelPackage,fs-autofs4))
+
+
+define KernelPackage/fs-btrfs
+ SUBMENU:=$(FS_MENU)
+ TITLE:=BTRFS filesystem support
+ DEPENDS:=+kmod-lib-crc32c +kmod-lib-lzo +kmod-lib-zlib
+ KCONFIG:=\
+ CONFIG_BTRFS_FS \
+ CONFIG_BTRFS_FS_POSIX_ACL=n \
+ CONFIG_BTRFS_FS_CHECK_INTEGRITY=n
+ FILES:=\
+ $(LINUX_DIR)/fs/btrfs/btrfs.ko
+ AUTOLOAD:=$(call AutoLoad,30,btrfs,1)
+endef
+
+define KernelPackage/fs-btrfs/description
+ Kernel module for BTRFS support
+endef
+
+$(eval $(call KernelPackage,fs-btrfs))
+
+
+define KernelPackage/fs-cifs
+ SUBMENU:=$(FS_MENU)
+ TITLE:=CIFS support
+ KCONFIG:= \
+ CONFIG_CIFS \
+ CONFIG_CIFS_DFS_UPCALL=n \
+ CONFIG_CIFS_UPCALL=n
+ FILES:=$(LINUX_DIR)/fs/cifs/cifs.ko
+ AUTOLOAD:=$(call AutoLoad,30,cifs)
+ $(call AddDepends/nls)
+ DEPENDS+= \
+ +kmod-crypto-arc4 \
+ +kmod-crypto-hmac \
+ +kmod-crypto-md5 \
+ +kmod-crypto-md4 \
+ +kmod-crypto-des \
+ +kmod-crypto-ecb \
+ +!LINUX_3_3&&!LINUX_3_6:kmod-crypto-sha256
+endef
+
+define KernelPackage/fs-cifs/description
+ Kernel module for CIFS support
+endef
+
+$(eval $(call KernelPackage,fs-cifs))
+
+
+define KernelPackage/fs-configfs
+ SUBMENU:=$(FS_MENU)
+ TITLE:=Configuration filesystem support
+ KCONFIG:= \
+ CONFIG_CONFIGFS_FS
+ FILES:=$(LINUX_DIR)/fs/configfs/configfs.ko
+ AUTOLOAD:=$(call AutoLoad,30,configfs)
+endef
+
+define KernelPackage/fs-configfs/description
+ Kernel module for configfs support
+endef
+
+$(eval $(call KernelPackage,fs-configfs))
+
+
+define KernelPackage/fs-exportfs
+ SUBMENU:=$(FS_MENU)
+ TITLE:=exportfs kernel server support
+ KCONFIG:=CONFIG_EXPORTFS
+ FILES=$(LINUX_DIR)/fs/exportfs/exportfs.ko
+ AUTOLOAD:=$(call AutoLoad,20,exportfs)
+endef
+
+define KernelPackage/fs-exportfs/description
+ Kernel module for exportfs. Needed for some other modules.
+endef
+
+$(eval $(call KernelPackage,fs-exportfs))
+
+
+define KernelPackage/fs-ext4
+ SUBMENU:=$(FS_MENU)
+ TITLE:=EXT4 filesystem support
+ KCONFIG:= \
+ CONFIG_EXT4_FS \
+ CONFIG_JBD2
+ FILES:= \
+ $(LINUX_DIR)/fs/ext4/ext4.ko \
+ $(LINUX_DIR)/fs/jbd2/jbd2.ko \
+ $(LINUX_DIR)/fs/mbcache.ko
+ AUTOLOAD:=$(call AutoLoad,30,mbcache jbd2 ext4,1)
+ $(call AddDepends/crc16, +!LINUX_3_3:kmod-crypto-hash)
+endef
+
+define KernelPackage/fs-ext4/description
+ Kernel module for EXT4 filesystem support
+endef
+
+$(eval $(call KernelPackage,fs-ext4))
+
+
+define KernelPackage/fuse
+ SUBMENU:=$(FS_MENU)
+ TITLE:=FUSE (Filesystem in Userspace) support
+ KCONFIG:= CONFIG_FUSE_FS
+ FILES:=$(LINUX_DIR)/fs/fuse/fuse.ko
+ AUTOLOAD:=$(call AutoLoad,80,fuse)
+endef
+
+define KernelPackage/fuse/description
+ Kernel module for userspace filesystem support
+endef
+
+$(eval $(call KernelPackage,fuse))
+
+
+define KernelPackage/fs-hfs
+ SUBMENU:=$(FS_MENU)
+ TITLE:=HFS filesystem support
+ KCONFIG:=CONFIG_HFS_FS
+ FILES:=$(LINUX_DIR)/fs/hfs/hfs.ko
+ AUTOLOAD:=$(call AutoLoad,30,hfs)
+ $(call AddDepends/nls)
+endef
+
+define KernelPackage/fs-hfs/description
+ Kernel module for HFS filesystem support
+endef
+
+$(eval $(call KernelPackage,fs-hfs))
+
+
+define KernelPackage/fs-hfsplus
+ SUBMENU:=$(FS_MENU)
+ TITLE:=HFS+ filesystem support
+ KCONFIG:=CONFIG_HFSPLUS_FS
+ FILES:=$(LINUX_DIR)/fs/hfsplus/hfsplus.ko
+ AUTOLOAD:=$(call AutoLoad,30,hfsplus)
+ $(call AddDepends/nls,utf8)
+endef
+
+define KernelPackage/fs-hfsplus/description
+ Kernel module for HFS+ filesystem support
+endef
+
+$(eval $(call KernelPackage,fs-hfsplus))
+
+
+define KernelPackage/fs-isofs
+ SUBMENU:=$(FS_MENU)
+ TITLE:=ISO9660 filesystem support
+ KCONFIG:=CONFIG_ISO9660_FS CONFIG_JOLIET=y CONFIG_ZISOFS=n
+ FILES:=$(LINUX_DIR)/fs/isofs/isofs.ko
+ AUTOLOAD:=$(call AutoLoad,30,isofs)
+ $(call AddDepends/nls)
+endef
+
+define KernelPackage/fs-isofs/description
+ Kernel module for ISO9660 filesystem support
+endef
+
+$(eval $(call KernelPackage,fs-isofs))
+
+
+define KernelPackage/fs-minix
+ SUBMENU:=$(FS_MENU)
+ TITLE:=Minix filesystem support
+ KCONFIG:=CONFIG_MINIX_FS
+ FILES:=$(LINUX_DIR)/fs/minix/minix.ko
+ AUTOLOAD:=$(call AutoLoad,30,minix)
+endef
+
+define KernelPackage/fs-minix/description
+ Kernel module for Minix filesystem support
+endef
+
+$(eval $(call KernelPackage,fs-minix))
+
+
+define KernelPackage/fs-msdos
+ SUBMENU:=$(FS_MENU)
+ TITLE:=MSDOS filesystem support
+ KCONFIG:=CONFIG_MSDOS_FS
+ FILES:=$(LINUX_DIR)/fs/fat/msdos.ko
+ AUTOLOAD:=$(call AutoLoad,40,msdos)
+ $(call AddDepends/nls)
+endef
+
+define KernelPackage/fs-msdos/description
+ Kernel module for MSDOS filesystem support
+endef
+
+$(eval $(call KernelPackage,fs-msdos))
+
+
+define KernelPackage/fs-nfs
+ SUBMENU:=$(FS_MENU)
+ TITLE:=NFS filesystem support
+ DEPENDS:=+kmod-fs-nfs-common
+ KCONFIG:= \
+ CONFIG_NFS_FS \
+ CONFIG_NFS_USE_LEGACY_DNS=n \
+ CONFIG_NFS_USE_NEW_IDMAPPER=n
+ FILES:= \
+ $(LINUX_DIR)/fs/nfs/nfs.ko
+ AUTOLOAD:=$(call AutoLoad,40,nfs)
+endef
+
+define KernelPackage/fs-nfs/description
+ Kernel module for NFS support
+endef
+
+$(eval $(call KernelPackage,fs-nfs))
+
+
+define KernelPackage/fs-nfs-common
+ SUBMENU:=$(FS_MENU)
+ TITLE:=Common NFS filesystem modules
+ KCONFIG:= \
+ CONFIG_LOCKD \
+ CONFIG_SUNRPC
+ FILES:= \
+ $(LINUX_DIR)/fs/lockd/lockd.ko \
+ $(LINUX_DIR)/net/sunrpc/sunrpc.ko
+ AUTOLOAD:=$(call AutoLoad,30,sunrpc lockd)
+endef
+
+$(eval $(call KernelPackage,fs-nfs-common))
+
+
+define KernelPackage/fs-nfs-common-v4
+ SUBMENU:=$(FS_MENU)
+ TITLE:=Common NFS V4 filesystem modules
+ KCONFIG+=\
+ CONFIG_SUNRPC_GSS\
+ CONFIG_NFS_V4=y\
+ CONFIG_NFSD_V4=y
+ DEPENDS:= @BROKEN
+ FILES+=$(LINUX_DIR)/net/sunrpc/auth_gss/auth_rpcgss.ko
+ AUTOLOAD=$(call AutoLoad,30,auth_rpcgss)
+endef
+
+define KernelPackage/fs-nfs-common-v4/description
+ Kernel modules for NFS V4 & NFSD V4 kernel support
+endef
+
+$(eval $(call KernelPackage,fs-nfs-common-v4))
+
+
+define KernelPackage/fs-nfsd
+ SUBMENU:=$(FS_MENU)
+ TITLE:=NFS kernel server support
+ DEPENDS:=+kmod-fs-nfs-common +kmod-fs-exportfs
+ KCONFIG:= \
+ CONFIG_NFSD \
+ CONFIG_NFSD_FAULT_INJECTION=n
+ FILES:=$(LINUX_DIR)/fs/nfsd/nfsd.ko
+ AUTOLOAD:=$(call AutoLoad,40,nfsd)
+endef
+
+define KernelPackage/fs-nfsd/description
+ Kernel module for NFS kernel server support
+endef
+
+$(eval $(call KernelPackage,fs-nfsd))
+
+
+define KernelPackage/fs-ntfs
+ SUBMENU:=$(FS_MENU)
+ TITLE:=NTFS filesystem support
+ KCONFIG:=CONFIG_NTFS_FS
+ FILES:=$(LINUX_DIR)/fs/ntfs/ntfs.ko
+ AUTOLOAD:=$(call AutoLoad,30,ntfs)
+ $(call AddDepends/nls)
+endef
+
+define KernelPackage/fs-ntfs/description
+ Kernel module for NTFS filesystem support
+endef
+
+$(eval $(call KernelPackage,fs-ntfs))
+
+
+define KernelPackage/fs-reiserfs
+ SUBMENU:=$(FS_MENU)
+ TITLE:=ReiserFS filesystem support
+ KCONFIG:=CONFIG_REISERFS_FS
+ FILES:=$(LINUX_DIR)/fs/reiserfs/reiserfs.ko
+ AUTOLOAD:=$(call AutoLoad,30,reiserfs,1)
+endef
+
+define KernelPackage/fs-reiserfs/description
+ Kernel module for ReiserFS support
+endef
+
+$(eval $(call KernelPackage,fs-reiserfs))
+
+
+define KernelPackage/fs-udf
+ SUBMENU:=$(FS_MENU)
+ TITLE:=UDF filesystem support
+ KCONFIG:=CONFIG_UDF_FS
+ FILES:=$(LINUX_DIR)/fs/udf/udf.ko
+ AUTOLOAD:=$(call AutoLoad,30,udf)
+ DEPENDS:=+kmod-lib-crc-itu-t
+ $(call AddDepends/nls)
+endef
+
+define KernelPackage/fs-udf/description
+ Kernel module for UDF filesystem support
+endef
+
+$(eval $(call KernelPackage,fs-udf))
+
+
+define KernelPackage/fs-vfat
+ SUBMENU:=$(FS_MENU)
+ TITLE:=VFAT filesystem support
+ KCONFIG:= \
+ CONFIG_FAT_FS \
+ CONFIG_VFAT_FS
+ FILES:= \
+ $(LINUX_DIR)/fs/fat/fat.ko \
+ $(LINUX_DIR)/fs/fat/vfat.ko
+ AUTOLOAD:=$(call AutoLoad,30,fat vfat)
+ $(call AddDepends/nls)
+endef
+
+define KernelPackage/fs-vfat/description
+ Kernel module for VFAT filesystem support
+endef
+
+$(eval $(call KernelPackage,fs-vfat))
+
+
+define KernelPackage/fs-xfs
+ SUBMENU:=$(FS_MENU)
+ TITLE:=XFS filesystem support
+ KCONFIG:=CONFIG_XFS_FS
+ DEPENDS:= +kmod-fs-exportfs @!avr32
+ FILES:=$(LINUX_DIR)/fs/xfs/xfs.ko
+ AUTOLOAD:=$(call AutoLoad,30,xfs,1)
+endef
+
+define KernelPackage/fs-xfs/description
+ Kernel module for XFS support
+endef
+
+$(eval $(call KernelPackage,fs-xfs))
diff --git a/package/kernel/modules/hwmon.mk b/package/kernel/modules/hwmon.mk
new file mode 100644
index 0000000..d549336
--- /dev/null
+++ b/package/kernel/modules/hwmon.mk
@@ -0,0 +1,192 @@
+#
+# Copyright (C) 2006-2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+HWMON_MENU:=Hardware Monitoring Support
+
+define KernelPackage/hwmon-core
+ SUBMENU:=$(HWMON_MENU)
+ TITLE:=Hardware monitoring support
+ KCONFIG:= \
+ CONFIG_HWMON \
+ CONFIG_HWMON_DEBUG_CHIP=n
+ FILES:= \
+ $(LINUX_DIR)/drivers/hwmon/hwmon.ko
+ AUTOLOAD:=$(call AutoLoad,40,hwmon)
+endef
+
+define KernelPackage/hwmon-core/description
+ Kernel modules for hardware monitoring
+endef
+
+$(eval $(call KernelPackage,hwmon-core))
+
+
+define AddDepends/hwmon
+ SUBMENU:=$(HWMON_MENU)
+ DEPENDS:=kmod-hwmon-core $(1)
+endef
+
+define KernelPackage/hwmon-vid
+ TITLE:=VID/VRM/VRD voltage conversion module.
+ KCONFIG:=CONFIG_HWMON_VID
+ FILES:=$(LINUX_DIR)/drivers/hwmon/hwmon-vid.ko
+ AUTOLOAD:=$(call AutoLoad,41,hwmon-vid)
+ $(call AddDepends/hwmon,)
+endef
+
+define KernelPackage/hwmon-vid/description
+ VID/VRM/VRD voltage conversion module for hardware monitoring.
+endef
+
+$(eval $(call KernelPackage,hwmon-vid))
+
+
+define KernelPackage/hwmon-adt7475
+ TITLE:=ADT7473/7475/7476/7490 monitoring support
+ KCONFIG:=CONFIG_SENSORS_ADT7475
+ FILES:=$(LINUX_DIR)/drivers/hwmon/adt7475.ko
+ AUTOLOAD:=$(call AutoLoad,60,adt7475)
+ $(call AddDepends/hwmon,+kmod-i2c-core +kmod-hwmon-vid)
+endef
+
+define KernelPackage/hwmon-adt7475/description
+ Kernel module for ADT7473/7475/7476/7490 thermal monitor chip.
+endef
+
+$(eval $(call KernelPackage,hwmon-adt7475))
+
+
+define KernelPackage/hwmon-lm63
+ TITLE:=LM63/64 monitoring support
+ KCONFIG:=CONFIG_SENSORS_LM63
+ FILES:=$(LINUX_DIR)/drivers/hwmon/lm63.ko
+ AUTOLOAD:=$(call AutoLoad,60,lm63)
+ $(call AddDepends/hwmon,+kmod-i2c-core)
+endef
+
+define KernelPackage/hwmon-lm63/description
+ Kernel module for lm63 and lm64 thermal monitor chip
+endef
+
+$(eval $(call KernelPackage,hwmon-lm63))
+
+
+define KernelPackage/hwmon-lm75
+ TITLE:=LM75 monitoring support
+ KCONFIG:=CONFIG_SENSORS_LM75
+ FILES:=$(LINUX_DIR)/drivers/hwmon/lm75.ko
+ AUTOLOAD:=$(call AutoLoad,60,lm75)
+ $(call AddDepends/hwmon,+kmod-i2c-core)
+endef
+
+define KernelPackage/hwmon-lm75/description
+ Kernel module for lm75 thermal monitor chip
+endef
+
+$(eval $(call KernelPackage,hwmon-lm75))
+
+
+define KernelPackage/hwmon-lm77
+ TITLE:=LM77 monitoring support
+ KCONFIG:=CONFIG_SENSORS_LM77
+ FILES:=$(LINUX_DIR)/drivers/hwmon/lm77.ko
+ AUTOLOAD:=$(call AutoLoad,60,lm77)
+ $(call AddDepends/hwmon,+kmod-i2c-core)
+endef
+
+define KernelPackage/hwmon-lm77/description
+ Kernel module for LM77 thermal monitor chip
+endef
+
+$(eval $(call KernelPackage,hwmon-lm77))
+
+
+define KernelPackage/hwmon-lm85
+ TITLE:=LM85 monitoring support
+ KCONFIG:=CONFIG_SENSORS_LM85
+ FILES:=$(LINUX_DIR)/drivers/hwmon/lm85.ko
+ AUTOLOAD:=$(call AutoLoad,60,lm85)
+ $(call AddDepends/hwmon,+kmod-i2c-core +kmod-hwmon-vid)
+endef
+
+define KernelPackage/hwmon-lm85/description
+ Kernel module for LM85 thermal monitor chip
+endef
+
+$(eval $(call KernelPackage,hwmon-lm85))
+
+
+define KernelPackage/hwmon-lm90
+ TITLE:=LM90 monitoring support
+ KCONFIG:=CONFIG_SENSORS_LM90
+ FILES:=$(LINUX_DIR)/drivers/hwmon/lm90.ko
+ AUTOLOAD:=$(call AutoLoad,60,lm90)
+ $(call AddDepends/hwmon,+kmod-i2c-core)
+endef
+
+define KernelPackage/hwmon-lm90/description
+ Kernel module for LM90 thermal monitor chip
+endef
+
+$(eval $(call KernelPackage,hwmon-lm90))
+
+define KernelPackage/hwmon-lm95241
+ TITLE:=LM95241 monitoring support
+ KCONFIG:=CONFIG_SENSORS_LM95241
+ FILES:=$(LINUX_DIR)/drivers/hwmon/lm95241.ko
+ AUTOLOAD:=$(call AutoLoad,60,lm95241)
+ $(call AddDepends/hwmon,+kmod-i2c-core)
+endef
+
+define KernelPackage/hwmon-lm95241/description
+ Kernel module for LM95241 thermal monitor chip
+endef
+
+$(eval $(call KernelPackage,hwmon-lm95241))
+
+define KernelPackage/hwmon-sht21
+ TITLE:=Sensiron SHT21 and compat. monitoring support
+ KCONFIG:=CONFIG_SENSORS_SHT21
+ FILES:=$(LINUX_DIR)/drivers/hwmon/sht21.ko
+ AUTOLOAD:=$(call AutoLoad,60,sht21)
+ $(call AddDepends/hwmon,+kmod-i2c-core)
+endef
+
+define KernelPackage/hwmon-sht21/description
+ Kernel module for Sensirion SHT21 and SHT25 temperature and humidity sensors chip
+endef
+
+$(eval $(call KernelPackage,hwmon-sht21))
+
+define KernelPackage/hwmon-pc87360
+ TITLE:=PC87360 monitoring support
+ KCONFIG:=CONFIG_SENSORS_PC87360
+ FILES:=$(LINUX_DIR)/drivers/hwmon/pc87360.ko
+ AUTOLOAD:=$(call AutoLoad,50,pc87360)
+ $(call AddDepends/hwmon,@TARGET_x86 +kmod-hwmon-vid)
+endef
+
+define KernelPackage/hwmon-pc87360/description
+ Kernel modules for PC87360 chips
+endef
+
+$(eval $(call KernelPackage,hwmon-pc87360))
+
+
+define KernelPackage/hwmon-w83627hf
+ TITLE:=Winbond W83627HF monitoring support
+ KCONFIG:=CONFIG_SENSORS_W83627HF
+ FILES:=$(LINUX_DIR)/drivers/hwmon/w83627hf.ko
+ AUTOLOAD:=$(call AutoLoad,50,w83627hf)
+$(call AddDepends/hwmon,@TARGET_rdc||TARGET_x86 +kmod-hwmon-vid)
+endef
+
+define KernelPacakge/hwmon-w83627hf/description
+ Kernel module for the Winbond W83627HF chips.
+endef
+
+$(eval $(call KernelPackage,hwmon-w83627hf))
diff --git a/package/kernel/modules/i2c.mk b/package/kernel/modules/i2c.mk
new file mode 100644
index 0000000..e01f937
--- /dev/null
+++ b/package/kernel/modules/i2c.mk
@@ -0,0 +1,283 @@
+#
+# Copyright (C) 2006-2009 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+I2C_MENU:=I2C support
+
+ModuleConfVar=$(word 1,$(subst :,$(space),$(1)))
+ModuleFullPath=$(LINUX_DIR)/$(word 2,$(subst :,$(space),$(1))).ko
+ModuleKconfig=$(foreach mod,$(1),$(call ModuleConfVar,$(mod)))
+ModuleFiles=$(foreach mod,$(1),$(call ModuleFullPath,$(mod)))
+ModuleAuto=$(call AutoLoad,$(1),$(foreach mod,$(2),$(basename $(notdir $(call ModuleFullPath,$(mod))))),$(3))
+
+define i2c_defaults
+ SUBMENU:=$(I2C_MENU)
+ KCONFIG:=$(call ModuleKconfig,$(1))
+ FILES:=$(call ModuleFiles,$(1))
+ AUTOLOAD:=$(call ModuleAuto,$(2),$(1),$(3))
+endef
+
+I2C_CORE_MODULES:= \
+ CONFIG_I2C:drivers/i2c/i2c-core \
+ CONFIG_I2C_CHARDEV:drivers/i2c/i2c-dev
+
+define KernelPackage/i2c-core
+ $(call i2c_defaults,$(I2C_CORE_MODULES),51)
+ TITLE:=I2C support
+endef
+
+define KernelPackage/i2c-core/description
+ Kernel modules for I2C support
+endef
+
+$(eval $(call KernelPackage,i2c-core))
+
+
+I2C_ALGOBIT_MODULES:= \
+ CONFIG_I2C_ALGOBIT:drivers/i2c/algos/i2c-algo-bit
+
+define KernelPackage/i2c-algo-bit
+ $(call i2c_defaults,$(I2C_ALGOBIT_MODULES),55)
+ TITLE:=I2C bit-banging interfaces
+ DEPENDS:=kmod-i2c-core
+endef
+
+define KernelPackage/i2c-algo-bit/description
+ Kernel modules for I2C bit-banging interfaces.
+endef
+
+$(eval $(call KernelPackage,i2c-algo-bit))
+
+
+I2C_ALGOPCA_MODULES:= \
+ CONFIG_I2C_ALGOPCA:drivers/i2c/algos/i2c-algo-pca
+
+define KernelPackage/i2c-algo-pca
+ $(call i2c_defaults,$(I2C_ALGOPCA_MODULES),55)
+ TITLE:=I2C PCA 9564 interfaces
+ DEPENDS:=kmod-i2c-core
+endef
+
+define KernelPackage/i2c-algo-pca/description
+ Kernel modules for I2C PCA 9564 interfaces.
+endef
+
+$(eval $(call KernelPackage,i2c-algo-pca))
+
+
+I2C_ALGOPCF_MODULES:= \
+ CONFIG_I2C_ALGOPCF:drivers/i2c/algos/i2c-algo-pcf
+
+define KernelPackage/i2c-algo-pcf
+ $(call i2c_defaults,$(I2C_ALGOPCF_MODULES),55)
+ TITLE:=I2C PCF 8584 interfaces
+ DEPENDS:=kmod-i2c-core
+endef
+
+define KernelPackage/i2c-algo-pcf/description
+ Kernel modules for I2C PCF 8584 interfaces
+endef
+
+$(eval $(call KernelPackage,i2c-algo-pcf))
+
+
+I2C_GPIO_MODULES:= \
+ CONFIG_I2C_GPIO:drivers/i2c/busses/i2c-gpio
+
+define KernelPackage/i2c-gpio
+ $(call i2c_defaults,$(I2C_GPIO_MODULES),59)
+ TITLE:=GPIO-based bitbanging I2C
+ DEPENDS:=@GPIO_SUPPORT +kmod-i2c-algo-bit
+endef
+
+define KernelPackage/i2c-gpio/description
+ Kernel modules for a very simple bitbanging I2C driver utilizing the
+ arch-neutral GPIO API to control the SCL and SDA lines.
+endef
+
+$(eval $(call KernelPackage,i2c-gpio))
+
+
+OF_I2C_MODULES:=\
+ CONFIG_OF_I2C:drivers/of/of_i2c
+
+define KernelPackage/of-i2c
+ $(call i2c_defaults,$(OF_I2C_MODULES),58)
+ TITLE:=OpenFirmware I2C accessors
+ DEPENDS:=@TARGET_ppc40x||TARGET_ppc4xx||TARGET_mpc52xx||TARGET_mpc83xx||TARGET_mpc85xx||TARGET_mvebu \
+ kmod-i2c-core
+endef
+
+define KernelPackage/of-i2c/description
+ Kernel module for OpenFirmware I2C accessors.
+endef
+
+$(eval $(call KernelPackage,of-i2c))
+
+I2C_MPC_MODULES:=\
+ CONFIG_I2C_MPC:drivers/i2c/busses/i2c-mpc
+
+define KernelPackage/i2c-mpc
+ $(call i2c_defaults,$(I2C_MPC_MODULES),59)
+ TITLE:=MPC I2C accessors
+ DEPENDS:=@TARGET_mpc52xx||TARGET_mpc83xx||TARGET_mpc85xx \
+ +kmod-i2c-core +kmod-of-i2c
+endef
+
+define KernelPackage/i2c-mpc/description
+ Kernel module for Freescale MPC52xx MPC83xx MPC85xx I2C accessors.
+endef
+
+$(eval $(call KernelPackage,i2c-mpc))
+
+I2C_IBM_IIC_MODULES:=\
+ CONFIG_I2C_IBM_IIC:drivers/i2c/busses/i2c-ibm_iic
+
+define KernelPackage/i2c-ibm-iic
+ $(call i2c_defaults,$(OF_I2C_MODULES),59)
+ TITLE:=IBM PPC 4xx on-chip I2C interface support
+ DEPENDS:=@TARGET_ppc40x||TARGET_ppc4xx +kmod-i2c-core +kmod-of-i2c
+endef
+
+define KernelPackage/i2c-ibm-iic/description
+ Kernel module for IIC peripheral found on embedded IBM PPC4xx based systems.
+endef
+
+$(eval $(call KernelPackage,i2c-ibm-iic))
+
+I2C_MV64XXX_MODULES:=\
+ CONFIG_I2C_MV64XXX:drivers/i2c/busses/i2c-mv64xxx
+
+define KernelPackage/i2c-mv64xxx
+ $(call i2c_defaults,$(I2C_MV64XXX_MODULES),59)
+ TITLE:=Orion Platform I2C interface support
+ DEPENDS:=@TARGET_kirkwood||TARGET_orion||TARGET_mvebu (TARGET_kirkwood||TARGET_orion):kmod-i2c-core \
+ TARGET_mvebu:kmod-of-i2c
+endef
+
+define KernelPackage/i2c-mv64xxx/description
+ Kernel module for I2C interface on the Kirkwood, Orion and Armada XP/370
+ family processors.
+endef
+
+$(eval $(call KernelPackage,i2c-mv64xxx))
+
+
+I2C_TINY_USB_MODULES:= \
+ CONFIG_I2C_TINY_USB:drivers/i2c/busses/i2c-tiny-usb
+
+define KernelPackage/i2c-tiny-usb
+ $(call i2c_defaults,$(I2C_TINY_USB_MODULES),59)
+ TITLE:=I2C Tiny USB adaptor
+ DEPENDS:=@USB_SUPPORT kmod-i2c-core
+endef
+
+define KernelPackage/i2c-tiny-usb/description
+ Kernel module for the I2C Tiny USB adaptor developed
+ by Till Harbaum (http://www.harbaum.org/till/i2c_tiny_usb).
+endef
+
+$(eval $(call KernelPackage,i2c-tiny-usb))
+
+I2C_MUX_MODULES:= \
+ CONFIG_I2C_MUX:drivers/i2c/i2c-mux
+
+define KernelPackage/i2c-mux
+ $(call i2c_defaults,$(I2C_MUX_MODULES),51)
+ TITLE:=I2C bus multiplexing support
+ DEPENDS:=kmod-i2c-core
+endef
+
+define KernelPackage/i2c-mux/description
+ Kernel modules for I2C bus multiplexing support.
+endef
+
+$(eval $(call KernelPackage,i2c-mux))
+
+ifeq ($(strip $(call CompareKernelPatchVer,$(KERNEL_PATCHVER),ge,3.6.0)),1)
+I2C_MUX_GPIO_MODULES:= \
+ CONFIG_I2C_MUX_GPIO:drivers/i2c/muxes/i2c-mux-gpio
+else
+I2C_MUX_GPIO_MODULES:= \
+ CONFIG_I2C_MUX_GPIO:drivers/i2c/muxes/gpio-i2cmux
+endif
+
+define KernelPackage/i2c-mux-gpio
+ $(call i2c_defaults,$(I2C_MUX_GPIO_MODULES),51)
+ TITLE:=GPIO-based I2C mux/switches
+ DEPENDS:=kmod-i2c-mux
+endef
+
+define KernelPackage/i2c-mux-gpio/description
+ Kernel modules for GENERIC_GPIO I2C bus mux/switching devices.
+endef
+
+$(eval $(call KernelPackage,i2c-mux-gpio))
+
+ifeq ($(strip $(call CompareKernelPatchVer,$(KERNEL_PATCHVER),ge,3.6.0)),1)
+I2C_MUX_PREFIX:=i2c-mux-
+endif
+
+I2C_MUX_PCA954x_MODULES:= \
+ CONFIG_I2C_MUX_PCA954x:drivers/i2c/muxes/$(I2C_MUX_PREFIX)pca954x
+
+define KernelPackage/i2c-mux-pca954x
+ $(call i2c_defaults,$(I2C_MUX_PCA954x_MODULES),51)
+ TITLE:=Philips PCA954x I2C mux/switches
+ DEPENDS:=kmod-i2c-mux
+endef
+
+define KernelPackage/i2c-mux-pca954x/description
+ Kernel modules for PCA954x I2C bus mux/switching devices.
+endef
+
+$(eval $(call KernelPackage,i2c-mux-pca954x))
+## Support for pca954x seems to be in kernel since 2.6.36
+
+I2C_MUX_PCA9541_MODULES:= \
+ CONFIG_I2C_MUX_PCA9541:drivers/i2c/muxes/$(I2C_MUX_PREFIX)pca9541
+
+define KernelPackage/i2c-mux-pca9541
+ $(call i2c_defaults,$(I2C_MUX_PCA9541_MODULES),51)
+ TITLE:=Philips PCA9541 I2C mux/switches
+ DEPENDS:=kmod-i2c-mux
+endef
+
+define KernelPackage/i2c-mux-pca9541/description
+ Kernel modules for PCA9541 I2C bus mux/switching devices.
+endef
+
+$(eval $(call KernelPackage,i2c-mux-pca9541))
+
+GPIO_PCA953X_MODULES:= \
+ CONFIG_GPIO_PCA953X:drivers/gpio/gpio-pca953x
+
+define KernelPackage/pca953x
+ $(call i2c_defaults,$(GPIO_PCA953X_MODULES),51)
+ TITLE:=Philips PCA953x I2C GPIO extenders
+ DEPENDS:=kmod-i2c-core
+endef
+
+define KernelPackage/pca953x/description
+ Kernel modules for PCA953x I2C GPIO extenders.
+endef
+
+$(eval $(call KernelPackage,pca953x))
+
+GPIO_PCF857X_MODULES:= \
+ CONFIG_GPIO_PCF857X:drivers/gpio/gpio-pcf857x
+
+define KernelPackage/pcf857x
+ $(call i2c_defaults,$(GPIO_PCF857X_MODULES),51)
+ TITLE:=Philips PCF857x I2C GPIO extenders
+ DEPENDS:=kmod-i2c-core
+endef
+
+define KernelPackage/pcf857x/description
+ Kernel modules for PCF857x I2C GPIO extenders.
+endef
+
+$(eval $(call KernelPackage,pcf857x))
diff --git a/package/kernel/modules/input.mk b/package/kernel/modules/input.mk
new file mode 100644
index 0000000..d3c1b34
--- /dev/null
+++ b/package/kernel/modules/input.mk
@@ -0,0 +1,192 @@
+#
+# Copyright (C) 2006-2013 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+INPUT_MODULES_MENU:=Input modules
+
+define KernelPackage/hid
+ SUBMENU:=$(INPUT_MODULES_MENU)
+ TITLE:=HID Devices
+ KCONFIG:=CONFIG_HID
+ FILES:=$(LINUX_DIR)/drivers/hid/hid.ko
+ AUTOLOAD:=$(call AutoLoad,61,hid)
+ $(call AddDepends/input,+kmod-input-evdev)
+endef
+
+define KernelPackage/hid/description
+ Kernel modules for HID devices
+endef
+
+$(eval $(call KernelPackage,hid))
+
+
+define KernelPackage/input-core
+ SUBMENU:=$(INPUT_MODULES_MENU)
+ TITLE:=Input device core
+ KCONFIG:=CONFIG_INPUT
+ FILES:=$(LINUX_DIR)/drivers/input/input-core.ko
+ AUTOLOAD:=$(call AutoLoad,19,input-core)
+endef
+
+define KernelPackage/input-core/description
+ Kernel modules for support of input device
+endef
+
+$(eval $(call KernelPackage,input-core))
+
+
+define KernelPackage/input-evdev
+ SUBMENU:=$(INPUT_MODULES_MENU)
+ TITLE:=Input event device
+ KCONFIG:=CONFIG_INPUT_EVDEV
+ FILES:=$(LINUX_DIR)/drivers/input/evdev.ko
+ AUTOLOAD:=$(call AutoLoad,60,evdev)
+ $(call AddDepends/input)
+endef
+
+define KernelPackage/input-evdev/description
+ Kernel modules for support of input device events
+endef
+
+$(eval $(call KernelPackage,input-evdev))
+
+
+define KernelPackage/input-gpio-buttons
+ SUBMENU:=$(INPUT_MODULES_MENU)
+ TITLE:=Polled GPIO buttons input device
+ DEPENDS:=@GPIO_SUPPORT +kmod-input-polldev
+ KCONFIG:= \
+ CONFIG_INPUT_GPIO_BUTTONS \
+ CONFIG_INPUT_MISC=y
+ FILES:=$(LINUX_DIR)/drivers/input/misc/gpio_buttons.ko
+ AUTOLOAD:=$(call AutoLoad,62,gpio_buttons)
+endef
+
+define KernelPackage/input-gpio-buttons/description
+ Kernel module for support polled GPIO buttons input device
+endef
+
+$(eval $(call KernelPackage,input-gpio-buttons))
+
+
+define KernelPackage/input-gpio-keys
+ SUBMENU:=$(INPUT_MODULES_MENU)
+ TITLE:=GPIO key support
+ DEPENDS:= @GPIO_SUPPORT
+ KCONFIG:= \
+ CONFIG_KEYBOARD_GPIO \
+ CONFIG_INPUT_KEYBOARD=y
+ FILES:=$(LINUX_DIR)/drivers/input/keyboard/gpio_keys.ko
+ AUTOLOAD:=$(call AutoLoad,60,gpio_keys)
+ $(call AddDepends/input)
+endef
+
+define KernelPackage/input-gpio-keys/description
+ This driver implements support for buttons connected
+ to GPIO pins of various CPUs (and some other chips).
+endef
+
+$(eval $(call KernelPackage,input-gpio-keys))
+
+
+define KernelPackage/input-gpio-keys-polled
+ SUBMENU:=$(INPUT_MODULES_MENU)
+ TITLE:=Polled GPIO key support
+ DEPENDS:=@GPIO_SUPPORT +kmod-input-polldev
+ KCONFIG:= \
+ CONFIG_KEYBOARD_GPIO_POLLED \
+ CONFIG_INPUT_KEYBOARD=y
+ FILES:=$(LINUX_DIR)/drivers/input/keyboard/gpio_keys_polled.ko
+ AUTOLOAD:=$(call AutoLoad,62,gpio_keys_polled)
+ $(call AddDepends/input)
+endef
+
+define KernelPackage/input-gpio-keys-polled/description
+ Kernel module for support polled GPIO keys input device
+endef
+
+$(eval $(call KernelPackage,input-gpio-keys-polled))
+
+
+define KernelPackage/input-gpio-encoder
+ SUBMENU:=$(INPUT_MODULES_MENU)
+ TITLE:=GPIO rotay encoder
+ KCONFIG:=CONFIG_INPUT_GPIO_ROTARY_ENCODER
+ FILES:=$(LINUX_DIR)/drivers/input/misc/rotary_encoder.ko
+ AUTOLOAD:=$(call AutoLoad,62,rotary_encoder)
+ $(call AddDepends/input,@GPIO_SUPPORT)
+endef
+
+define KernelPackage/gpio-encoder/description
+ Kernel module to use rotary encoders connected to GPIO pins
+endef
+
+$(eval $(call KernelPackage,input-gpio-encoder))
+
+
+define KernelPackage/input-joydev
+ SUBMENU:=$(INPUT_MODULES_MENU)
+ TITLE:=Joystick device support
+ KCONFIG:=CONFIG_INPUT_JOYDEV
+ FILES:=$(LINUX_DIR)/drivers/input/joydev.ko
+ AUTOLOAD:=$(call AutoLoad,62,joydev)
+ $(call AddDepends/input)
+endef
+
+define KernelPackage/input-joydev/description
+ Kernel module for joystick support
+endef
+
+$(eval $(call KernelPackage,input-joydev))
+
+
+define KernelPackage/input-polldev
+ SUBMENU:=$(INPUT_MODULES_MENU)
+ TITLE:=Polled Input device support
+ KCONFIG:=CONFIG_INPUT_POLLDEV
+ FILES:=$(LINUX_DIR)/drivers/input/input-polldev.ko
+ AUTOLOAD:=$(call AutoLoad,20,input-polldev)
+ $(call AddDepends/input)
+endef
+
+define KernelPackage/input-polldev/description
+ Kernel module for support of polled input devices
+endef
+
+$(eval $(call KernelPackage,input-polldev))
+
+
+define KernelPackage/input-matrixkmap
+ SUBMENU:=$(INPUT_MODULES_MENU)
+ TITLE:=Input matrix devices support
+ KCONFIG:=CONFIG_INPUT_MATRIXKMAP
+ DEPENDS:=@!LINUX_3_3
+ FILES:=$(LINUX_DIR)/drivers/input/matrix-keymap.ko
+ AUTOLOAD:=$(call AutoLoad,20,matrix-keymap)
+ $(call AddDepends/input)
+endef
+
+define KernelPackage/input-matrix/description
+ Kernel module support for input matrix devices
+endef
+
+$(eval $(call KernelPackage,input-matrixkmap))
+
+
+define KernelPackage/acpi-button
+ SUBMENU:=$(INPUT_MODULES_MENU)
+ TITLE:=ACPI Button Support
+ DEPENDS:=@(TARGET_x86_generic||TARGET_x86_kvm_guest||TARGET_x86_xen_domu) +kmod-input-evdev
+ KCONFIG:=CONFIG_ACPI_BUTTON
+ FILES:=$(LINUX_DIR)/drivers/acpi/button.ko
+ AUTOLOAD:=$(call AutoLoad,06,button)
+endef
+
+define KernelPackage/acpi-button/description
+ Kernel module for ACPI Button support
+endef
+
+$(eval $(call KernelPackage,acpi-button))
diff --git a/package/kernel/modules/leds.mk b/package/kernel/modules/leds.mk
new file mode 100644
index 0000000..b2402c9
--- /dev/null
+++ b/package/kernel/modules/leds.mk
@@ -0,0 +1,169 @@
+#
+# Copyright (C) 2006-2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+LEDS_MENU:=LED modules
+
+
+define KernelPackage/leds-gpio
+ SUBMENU:=$(LEDS_MENU)
+ TITLE:=GPIO LED support
+ DEPENDS:= @GPIO_SUPPORT
+ KCONFIG:=CONFIG_LEDS_GPIO
+ FILES:=$(LINUX_DIR)/drivers/leds/leds-gpio.ko
+ AUTOLOAD:=$(call AutoLoad,60,leds-gpio)
+endef
+
+define KernelPackage/leds-gpio/description
+ Kernel module for LEDs on GPIO lines
+endef
+
+$(eval $(call KernelPackage,leds-gpio))
+
+
+define KernelPackage/ledtrig-heartbeat
+ SUBMENU:=$(LEDS_MENU)
+ TITLE:=LED Heartbeat Trigger
+ KCONFIG:=CONFIG_LEDS_TRIGGER_HEARTBEAT
+ FILES:=$(LINUX_DIR)/drivers/leds/ledtrig-heartbeat.ko
+ AUTOLOAD:=$(call AutoLoad,50,ledtrig-heartbeat)
+endef
+
+define KernelPackage/ledtrig-gpio/description
+ Kernel module that allows LEDs to blink like heart beat
+endef
+
+$(eval $(call KernelPackage,ledtrig-heartbeat))
+
+
+define KernelPackage/ledtrig-gpio
+ SUBMENU:=$(LEDS_MENU)
+ TITLE:=LED GPIO Trigger
+ KCONFIG:=CONFIG_LEDS_TRIGGER_GPIO
+ FILES:=$(LINUX_DIR)/drivers/leds/ledtrig-gpio.ko
+ AUTOLOAD:=$(call AutoLoad,50,ledtrig-gpio)
+endef
+
+define KernelPackage/ledtrig-gpio/description
+ Kernel module that allows LEDs to be controlled by gpio events.
+endef
+
+$(eval $(call KernelPackage,ledtrig-gpio))
+
+
+define KernelPackage/ledtrig-morse
+ SUBMENU:=$(LEDS_MENU)
+ TITLE:=LED Morse Trigger
+ KCONFIG:=CONFIG_LEDS_TRIGGER_MORSE
+ FILES:=$(LINUX_DIR)/drivers/leds/ledtrig-morse.ko
+ AUTOLOAD:=$(call AutoLoad,50,ledtrig-morse)
+endef
+
+define KernelPackage/ledtrig-morse/description
+ Kernel module to show morse coded messages on LEDs.
+endef
+
+$(eval $(call KernelPackage,ledtrig-morse))
+
+
+define KernelPackage/ledtrig-netdev
+ SUBMENU:=$(LEDS_MENU)
+ TITLE:=LED NETDEV Trigger
+ KCONFIG:=CONFIG_LEDS_TRIGGER_NETDEV
+ FILES:=$(LINUX_DIR)/drivers/leds/ledtrig-netdev.ko
+ AUTOLOAD:=$(call AutoLoad,50,ledtrig-netdev)
+endef
+
+define KernelPackage/ledtrig-netdev/description
+ Kernel module to drive LEDs based on network activity.
+endef
+
+$(eval $(call KernelPackage,ledtrig-netdev))
+
+
+define KernelPackage/ledtrig-netfilter
+ SUBMENU:=$(LEDS_MENU)
+ TITLE:=LED NetFilter Trigger
+ DEPENDS:=kmod-ipt-core
+ KCONFIG:=CONFIG_NETFILTER_XT_TARGET_LED
+ FILES:=$(LINUX_DIR)/net/netfilter/xt_LED.ko
+ AUTOLOAD:=$(call AutoLoad,50,xt_LED)
+endef
+
+define KernelPackage/ledtrig-netfilter/description
+ Kernel module to flash LED when a particular packets passing through your machine.
+
+ For example to create an LED trigger for incoming SSH traffic:
+ iptables -A INPUT -p tcp --dport 22 -j LED --led-trigger-id ssh --led-delay 1000
+ Then attach the new trigger to an LED on your system:
+ echo netfilter-ssh > /sys/class/leds/<ledname>/trigger
+endef
+
+$(eval $(call KernelPackage,ledtrig-netfilter))
+
+
+define KernelPackage/ledtrig-usbdev
+ SUBMENU:=$(LEDS_MENU)
+ TITLE:=LED USB device Trigger
+ DEPENDS:=@USB_SUPPORT kmod-usb-core
+ KCONFIG:=CONFIG_LEDS_TRIGGER_USBDEV
+ FILES:=$(LINUX_DIR)/drivers/leds/ledtrig-usbdev.ko
+ AUTOLOAD:=$(call AutoLoad,50,ledtrig-usbdev)
+endef
+
+define KernelPackage/ledtrig-usbdev/description
+ Kernel module to drive LEDs based on USB device presence/activity.
+endef
+
+$(eval $(call KernelPackage,ledtrig-usbdev))
+
+
+define KernelPackage/ledtrig-default-on
+ SUBMENU:=$(LEDS_MENU)
+ TITLE:=LED Default ON Trigger
+ KCONFIG:=CONFIG_LEDS_TRIGGER_DEFAULT_ON
+ FILES:=$(LINUX_DIR)/drivers/leds/ledtrig-default-on.ko
+ AUTOLOAD:=$(call AutoLoad,50,ledtrig-default-on)
+endef
+
+define KernelPackage/ledtrig-default-on/description
+ Kernel module that allows LEDs to be initialised in the ON state.
+endef
+
+$(eval $(call KernelPackage,ledtrig-default-on))
+
+
+define KernelPackage/ledtrig-timer
+ SUBMENU:=$(LEDS_MENU)
+ TITLE:=LED Timer Trigger
+ KCONFIG:=CONFIG_LEDS_TRIGGER_TIMER
+ FILES:=$(LINUX_DIR)/drivers/leds/ledtrig-timer.ko
+ AUTOLOAD:=$(call AutoLoad,50,ledtrig-timer)
+endef
+
+define KernelPackage/ledtrig-timer/description
+ Kernel module that allows LEDs to be controlled by a programmable timer
+ via sysfs.
+endef
+
+$(eval $(call KernelPackage,ledtrig-timer))
+
+
+define KernelPackage/ledtrig-oneshot
+ SUBMENU:=$(LEDS_MENU)
+ TITLE:=LED One-Shot Trigger
+ DEPENDS:=@!LINUX_3_3
+ KCONFIG:=CONFIG_LEDS_TRIGGER_ONESHOT
+ FILES:=$(LINUX_DIR)/drivers/leds/ledtrig-oneshot.ko
+ AUTOLOAD:=$(call AutoLoad,50,ledtrig-oneshot)
+endef
+
+define KernelPackage/ledtrig-oneshot/description
+ Kernel module that allows LEDs to be triggered by sporadic events in
+ one-shot pulses.
+endef
+
+$(eval $(call KernelPackage,ledtrig-oneshot))
diff --git a/package/kernel/modules/lib.mk b/package/kernel/modules/lib.mk
new file mode 100644
index 0000000..0411e93
--- /dev/null
+++ b/package/kernel/modules/lib.mk
@@ -0,0 +1,165 @@
+#
+# Copyright (C) 2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+LIB_MENU:=Libraries
+
+define KernelPackage/lib-crc-ccitt
+ SUBMENU:=$(LIB_MENU)
+ TITLE:=CRC-CCITT support
+ KCONFIG:=CONFIG_CRC_CCITT
+ FILES:=$(LINUX_DIR)/lib/crc-ccitt.ko
+ AUTOLOAD:=$(call AutoLoad,20,crc-ccitt)
+endef
+
+define KernelPackage/lib-crc-ccitt/description
+ Kernel module for CRC-CCITT support
+endef
+
+$(eval $(call KernelPackage,lib-crc-ccitt))
+
+
+define KernelPackage/lib-crc-itu-t
+ SUBMENU:=$(LIB_MENU)
+ TITLE:=CRC ITU-T V.41 support
+ KCONFIG:=CONFIG_CRC_ITU_T
+ FILES:=$(LINUX_DIR)/lib/crc-itu-t.ko
+ AUTOLOAD:=$(call AutoLoad,20,crc-itu-t)
+endef
+
+define KernelPackage/lib-crc-itu-t/description
+ Kernel module for CRC ITU-T V.41 support
+endef
+
+$(eval $(call KernelPackage,lib-crc-itu-t))
+
+
+define KernelPackage/lib-crc7
+ SUBMENU:=$(LIB_MENU)
+ TITLE:=CRC7 support
+ KCONFIG:=CONFIG_CRC7
+ FILES:=$(LINUX_DIR)/lib/crc7.ko
+ AUTOLOAD:=$(call AutoLoad,20,crc7)
+endef
+
+define KernelPackage/lib-crc7/description
+ Kernel module for CRC7 support
+endef
+
+$(eval $(call KernelPackage,lib-crc7))
+
+
+define KernelPackage/lib-crc8
+ SUBMENU:=$(LIB_MENU)
+ TITLE:=CRC8 support
+ KCONFIG:=CONFIG_CRC8
+ FILES:=$(LINUX_DIR)/lib/crc8.ko
+ AUTOLOAD:=$(call AutoLoad,20,crc8)
+endef
+
+define KernelPackage/lib-crc8/description
+ Kernel module for CRC8 support
+endef
+
+$(eval $(call KernelPackage,lib-crc8))
+
+
+define KernelPackage/lib-crc16
+ SUBMENU:=$(LIB_MENU)
+ TITLE:=CRC16 support
+ KCONFIG:=CONFIG_CRC16
+ FILES:=$(LINUX_DIR)/lib/crc16.ko
+ AUTOLOAD:=$(call AutoLoad,20,crc16,1)
+endef
+
+define KernelPackage/lib-crc16/description
+ Kernel module for CRC16 support
+endef
+
+$(eval $(call KernelPackage,lib-crc16))
+
+
+define KernelPackage/lib-crc32c
+ SUBMENU:=$(LIB_MENU)
+ TITLE:=CRC32 support
+ KCONFIG:=CONFIG_LIBCRC32C
+ DEPENDS:=+kmod-crypto-crc32c
+ FILES:=$(LINUX_DIR)/lib/libcrc32c.ko
+ AUTOLOAD:=$(call AutoLoad,20,libcrc32c,1)
+endef
+
+define KernelPackage/lib-crc32c/description
+ Kernel module for CRC32 support
+endef
+
+$(eval $(call KernelPackage,lib-crc32c))
+
+
+define KernelPackage/lib-lzo
+ SUBMENU:=$(LIB_MENU)
+ TITLE:=LZO support
+ KCONFIG:= \
+ CONFIG_LZO_COMPRESS \
+ CONFIG_LZO_DECOMPRESS
+ FILES:= \
+ $(LINUX_DIR)/lib/lzo/lzo_compress.ko \
+ $(LINUX_DIR)/lib/lzo/lzo_decompress.ko
+ AUTOLOAD:=$(call AutoLoad,20, lzo_compress lzo_decompress,1)
+endef
+
+define KernelPackage/lib-lzo/description
+ Kernel module for LZO compression/decompression support
+endef
+
+$(eval $(call KernelPackage,lib-lzo))
+
+
+define KernelPackage/lib-textsearch
+SUBMENU:=$(LIB_MENU)
+ TITLE:=Textsearch support
+ KCONFIG:= \
+ CONFIG_TEXTSEARCH=y \
+ CONFIG_TEXTSEARCH_KMP \
+ CONFIG_TEXTSEARCH_BM \
+ CONFIG_TEXTSEARCH_FSM
+ FILES:= \
+ $(LINUX_DIR)/lib/ts_kmp.ko \
+ $(LINUX_DIR)/lib/ts_bm.ko \
+ $(LINUX_DIR)/lib/ts_fsm.ko
+ AUTOLOAD:=$(call AutoLoad,20,ts_kmp ts_bm ts_fsm)
+endef
+
+$(eval $(call KernelPackage,lib-textsearch))
+
+
+define KernelPackage/lib-zlib
+ SUBMENU:=$(LIB_MENU)
+ TITLE:=Zlib support
+ KCONFIG:= \
+ CONFIG_ZLIB_DEFLATE \
+ CONFIG_ZLIB_INFLATE
+ FILES:= \
+ $(LINUX_DIR)/lib/zlib_deflate/zlib_deflate.ko \
+ $(LINUX_DIR)/lib/zlib_inflate/zlib_inflate.ko
+ AUTOLOAD:=$(call AutoLoad,08,zlib_deflate zlib_inflate,1)
+endef
+
+$(eval $(call KernelPackage,lib-zlib))
+
+
+define KernelPackage/lib-cordic
+ SUBMENU:=$(LIB_MENU)
+ TITLE:=Cordic function support
+ KCONFIG:=CONFIG_CORDIC
+ FILES:=$(LINUX_DIR)/lib/cordic.ko
+ AUTOLOAD:=$(call AutoLoad,20,cordic)
+endef
+
+define KernelPackage/lib-cordic/description
+ Kernel module for Cordic function support
+endef
+
+$(eval $(call KernelPackage,lib-cordic))
diff --git a/package/kernel/modules/netdevices.mk b/package/kernel/modules/netdevices.mk
new file mode 100644
index 0000000..07508ff
--- /dev/null
+++ b/package/kernel/modules/netdevices.mk
@@ -0,0 +1,726 @@
+#
+# Copyright (C) 2006-2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+NETWORK_DEVICES_MENU:=Network Devices
+
+define KernelPackage/sis190
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=SiS 190 Fast/Gigabit Ethernet support
+ DEPENDS:=@PCI_SUPPORT
+ KCONFIG:=CONFIG_SIS190
+ FILES:=$(LINUX_DIR)/drivers/net/ethernet/sis/sis190.ko
+ AUTOLOAD:=$(call AutoLoad,50,sis190)
+endef
+
+$(eval $(call KernelPackage,sis190))
+
+define KernelPackage/skge
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=SysKonnect Yukon support
+ DEPENDS:=@PCI_SUPPORT
+ KCONFIG:=CONFIG_SKGE \
+ CONFIG_SKGE_DEBUG=n \
+ CONFIG_SKGE_GENESIS=n
+ FILES:=$(LINUX_DIR)/drivers/net/ethernet/marvell/skge.ko
+ AUTOLOAD:=$(call AutoLoad,50,skge)
+endef
+
+$(eval $(call KernelPackage,skge))
+
+define KernelPackage/atl2
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=Atheros L2 Fast Ethernet support
+ DEPENDS:=@PCI_SUPPORT
+ KCONFIG:=CONFIG_ATL2
+ FILES:=$(LINUX_DIR)/drivers/net/ethernet/atheros/atlx/atl2.ko
+ AUTOLOAD:=$(call AutoLoad,50,atl2)
+endef
+
+$(eval $(call KernelPackage,atl2))
+
+define KernelPackage/atl1
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=Atheros L1 Gigabit Ethernet support
+ DEPENDS:=@PCI_SUPPORT
+ KCONFIG:=CONFIG_ATL1
+ FILES:=$(LINUX_DIR)/drivers/net/ethernet/atheros/atlx/atl1.ko
+ AUTOLOAD:=$(call AutoLoad,50,atl1)
+endef
+
+$(eval $(call KernelPackage,atl1))
+
+define KernelPackage/atl1c
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=Atheros L1C
+ DEPENDS:=@PCI_SUPPORT
+ KCONFIG:=CONFIG_ATL1C
+ FILES:=$(LINUX_DIR)/drivers/net/ethernet/atheros/atl1c/atl1c.ko
+ AUTOLOAD:=$(call AutoLoad,50,atl1c)
+endef
+
+$(eval $(call KernelPackage,atl1c))
+
+define KernelPackage/atl1e
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=Atheros L1E
+ DEPENDS:=@PCI_SUPPORT
+ KCONFIG:=CONFIG_ATL1E
+ FILES:=$(LINUX_DIR)/drivers/net/ethernet/atheros/atl1e/atl1e.ko
+ AUTOLOAD:=$(call AutoLoad,50,atl1e)
+endef
+
+$(eval $(call KernelPackage,atl1e))
+
+define KernelPackage/libphy
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=PHY library
+ KCONFIG:=CONFIG_PHYLIB
+ FILES:=$(LINUX_DIR)/drivers/net/phy/libphy.ko
+ AUTOLOAD:=$(call AutoLoad,40,libphy)
+endef
+
+define KernelPackage/libphy/description
+ PHY library
+endef
+
+$(eval $(call KernelPackage,libphy))
+
+define KernelPackage/et131x
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=Agere ET131x Gigabit Ethernet driver
+ URL:=http://sourceforge.net/projects/et131x
+ FILES:=$(LINUX_DIR)/drivers/staging/et131x/et131x.$(LINUX_KMOD_SUFFIX)
+ KCONFIG:= \
+ CONFIG_ET131X \
+ CONFIG_ET131X_DEBUG=n
+ DEPENDS:=@PCI_SUPPORT
+ AUTOLOAD:=$(call AutoLoad,70,et131x)
+endef
+
+define KernelPackage/et131x/description
+ This package contains the et131x kernel module.
+endef
+
+$(eval $(call KernelPackage,et131x))
+
+define KernelPackage/swconfig
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=switch configuration API
+ DEPENDS:=+kmod-libphy
+ KCONFIG:=CONFIG_SWCONFIG
+ FILES:=$(LINUX_DIR)/drivers/net/phy/swconfig.ko
+ AUTOLOAD:=$(call AutoLoad,41,swconfig)
+endef
+
+define KernelPackage/swconfig/description
+ Switch configuration API module
+endef
+
+$(eval $(call KernelPackage,swconfig))
+
+define KernelPackage/switch-ip17xx
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=IC+ IP17XX switch support
+ DEPENDS:=+kmod-swconfig
+ KCONFIG:=CONFIG_IP17XX_PHY
+ FILES:=$(LINUX_DIR)/drivers/net/phy/ip17xx.ko
+ AUTOLOAD:=$(call AutoLoad,42,ip17xx)
+endef
+
+define KernelPackage/switch-ip17xx/description
+ IC+ IP175C/IP178C switch support
+endef
+
+$(eval $(call KernelPackage,switch-ip17xx))
+
+define KernelPackage/switch-rtl8366-smi
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=Realtek RTL8366 SMI switch interface support
+ DEPENDS:=@GPIO_SUPPORT +kmod-swconfig
+ KCONFIG:=CONFIG_RTL8366_SMI
+ FILES:=$(LINUX_DIR)/drivers/net/phy/rtl8366_smi.ko
+ AUTOLOAD:=$(call AutoLoad,42,rtl8366_smi)
+endef
+
+define KernelPackage/switch-rtl8366_smi/description
+ Realtek RTL8366 series SMI switch interface support
+endef
+
+$(eval $(call KernelPackage,switch-rtl8366-smi))
+
+define KernelPackage/switch-rtl8366rb
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=Realtek RTL8366RB switch support
+ DEPENDS:=+kmod-switch-rtl8366-smi
+ KCONFIG:=CONFIG_RTL8366RB_PHY
+ FILES:=$(LINUX_DIR)/drivers/net/phy/rtl8366rb.ko
+ AUTOLOAD:=$(call AutoLoad,43,rtl8366rb)
+endef
+
+define KernelPackage/switch-rtl8366rb/description
+ Realtek RTL8366RB switch support
+endef
+
+$(eval $(call KernelPackage,switch-rtl8366rb))
+
+define KernelPackage/switch-rtl8366s
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=Realtek RTL8366S switch support
+ DEPENDS:=+kmod-switch-rtl8366-smi
+ KCONFIG:=CONFIG_RTL8366S_PHY
+ FILES:=$(LINUX_DIR)/drivers/net/phy/rtl8366s.ko
+ AUTOLOAD:=$(call AutoLoad,43,rtl8366s)
+endef
+
+define KernelPackage/switch-rtl8366s/description
+ Realtek RTL8366S switch support
+endef
+
+$(eval $(call KernelPackage,switch-rtl8366s))
+
+define KernelPackage/natsemi
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=National Semiconductor DP8381x series
+ DEPENDS:=@PCI_SUPPORT
+ KCONFIG:=CONFIG_NATSEMI
+ FILES:=$(LINUX_DIR)/drivers/net/ethernet/natsemi/natsemi.ko
+ AUTOLOAD:=$(call AutoLoad,20,natsemi)
+endef
+
+define KernelPackage/natsemi/description
+ Kernel modules for National Semiconductor DP8381x series PCI Ethernet
+ adapters.
+endef
+
+$(eval $(call KernelPackage,natsemi))
+
+
+define KernelPackage/r6040
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=RDC Fast-Ethernet support
+ DEPENDS:=@PCI_SUPPORT +kmod-libphy
+ KCONFIG:=CONFIG_R6040 \
+ CONFIG_R6040_NAPI=y
+ FILES:=$(LINUX_DIR)/drivers/net/ethernet/rdc/r6040.ko
+ AUTOLOAD:=$(call AutoLoad,99,r6040)
+endef
+
+define KernelPackage/r6040/description
+ Kernel modules for RDC Fast-Ethernet adapters.
+endef
+
+$(eval $(call KernelPackage,r6040))
+
+
+define KernelPackage/sis900
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=SiS 900 Ethernet support
+ DEPENDS:=@PCI_SUPPORT
+ KCONFIG:=CONFIG_SIS900
+ FILES:=$(LINUX_DIR)/drivers/net/ethernet/sis/sis900.ko
+ AUTOLOAD:=$(call AutoLoad,50,sis900)
+endef
+
+define KernelPackage/sis900/description
+ Kernel modules for Sis 900 Ethernet adapters.
+endef
+
+$(eval $(call KernelPackage,sis900))
+
+
+define KernelPackage/sky2
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=SysKonnect Yukon2 support
+ DEPENDS:=@PCI_SUPPORT
+ KCONFIG:=CONFIG_SKY2
+ FILES:=$(LINUX_DIR)/drivers/net/ethernet/marvell/sky2.ko
+ AUTOLOAD:=$(call AutoLoad,50,sky2)
+endef
+
+define KernelPackage/sky2/description
+ This driver supports Gigabit Ethernet adapters based on the
+ Marvell Yukon 2 chipset:
+ Marvell 88E8021/88E8022/88E8035/88E8036/88E8038/88E8050/88E8052/
+ 88E8053/88E8055/88E8061/88E8062, SysKonnect SK-9E21D/SK-9S21
+
+ There is companion driver for the older Marvell Yukon and
+ Genesis based adapters: skge.
+endef
+
+$(eval $(call KernelPackage,sky2))
+
+
+define KernelPackage/via-rhine
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=Via Rhine ethernet support
+ DEPENDS:=@PCI_SUPPORT
+ KCONFIG:=CONFIG_VIA_RHINE \
+ CONFIG_VIA_RHINE_MMIO=y
+ FILES:=$(LINUX_DIR)/drivers/net/ethernet/via/via-rhine.ko
+ AUTOLOAD:=$(call AutoLoad,50,via-rhine)
+endef
+
+define KernelPackage/via-rhine/description
+ Kernel modules for Via Rhine Ethernet chipsets.
+endef
+
+$(eval $(call KernelPackage,via-rhine))
+
+
+define KernelPackage/via-velocity
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=VIA Velocity Gigabit Ethernet Adapter kernel support
+ DEPENDS:=@TARGET_ixp4xx||TARGET_mpc83xx||PCI_SUPPORT +kmod-lib-crc-ccitt
+ KCONFIG:=CONFIG_VIA_VELOCITY
+ FILES:=$(LINUX_DIR)/drivers/net/ethernet/via/via-velocity.ko
+ AUTOLOAD:=$(call AutoLoad,50,via-velocity)
+endef
+
+define KernelPackage/via-velocity/description
+ Kernel modules for VIA Velocity Gigabit Ethernet chipsets.
+endef
+
+$(eval $(call KernelPackage,via-velocity))
+
+
+define KernelPackage/8139too
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=RealTek RTL-8139 PCI Fast Ethernet Adapter kernel support
+ DEPENDS:=@PCI_SUPPORT
+ KCONFIG:=CONFIG_8139TOO \
+ CONFIG_8139TOO_PIO=y \
+ CONFIG_8139TOO_TUNE_TWISTER=n \
+ CONFIG_8139TOO_8129=n \
+ CONFIG_8139_OLD_RX_RESET=n
+ FILES:=$(LINUX_DIR)/drivers/net/ethernet/realtek/8139too.ko
+ AUTOLOAD:=$(call AutoLoad,50,8139too)
+endef
+
+define KernelPackage/8139too/description
+ Kernel modules for RealTek RTL-8139 PCI Fast Ethernet adapters.
+endef
+
+$(eval $(call KernelPackage,8139too))
+
+
+define KernelPackage/8139cp
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=RealTek RTL-8139C+ PCI Fast Ethernet Adapter kernel support
+ DEPENDS:=@PCI_SUPPORT
+ KCONFIG:=CONFIG_8139CP
+ FILES:=$(LINUX_DIR)/drivers/net/ethernet/realtek/8139cp.ko
+ AUTOLOAD:=$(call AutoLoad,50,8139cp)
+endef
+
+define KernelPackage/8139cp/description
+ Kernel module for RealTek RTL-8139C+ PCI Fast Ethernet adapters.
+endef
+
+$(eval $(call KernelPackage,8139cp))
+
+
+define KernelPackage/r8169
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=RealTek RTL-8169 PCI Gigabit Ethernet Adapter kernel support
+ DEPENDS:=@PCI_SUPPORT
+ KCONFIG:=CONFIG_R8169 \
+ CONFIG_R8169_NAPI=y \
+ CONFIG_R8169_VLAN=n
+ FILES:=$(LINUX_DIR)/drivers/net/ethernet/realtek/r8169.ko
+ AUTOLOAD:=$(call AutoLoad,50,r8169)
+endef
+
+define KernelPackage/r8169/description
+ Kernel modules for RealTek RTL-8169 PCI Gigabit Ethernet adapters.
+endef
+
+$(eval $(call KernelPackage,r8169))
+
+
+define KernelPackage/ne2k-pci
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=ne2k-pci Ethernet Adapter kernel support
+ DEPENDS:=@PCI_SUPPORT
+ KCONFIG:=CONFIG_NE2K_PCI
+ FILES:= \
+ $(LINUX_DIR)/drivers/net/ethernet/8390/ne2k-pci.ko \
+ $(LINUX_DIR)/drivers/net/ethernet/8390/8390.ko
+ AUTOLOAD:=$(call AutoLoad,50,8390 ne2k-pci)
+endef
+
+define KernelPackage/ne2k-pci/description
+ Kernel modules for NE2000 PCI Ethernet Adapter kernel.
+endef
+
+$(eval $(call KernelPackage,ne2k-pci))
+
+
+define KernelPackage/e100
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=Intel(R) PRO/100+ cards kernel support
+ DEPENDS:=@PCI_SUPPORT
+ KCONFIG:=CONFIG_E100
+ FILES:=$(LINUX_DIR)/drivers/net/ethernet/intel/e100.ko
+ AUTOLOAD:=$(call AutoLoad,50,e100)
+endef
+
+define KernelPackage/e100/description
+ Kernel modules for Intel(R) PRO/100+ Ethernet adapters.
+endef
+
+define KernelPackage/e100/install
+ $(INSTALL_DIR) $(1)/lib/firmware/e100
+ $(foreach file,d101m_ucode.bin d101s_ucode.bin d102e_ucode.bin, \
+ $(TARGET_CROSS)objcopy -Iihex -Obinary $(LINUX_DIR)/firmware/e100/$(file).ihex $(1)/lib/firmware/e100/$(file); \
+ )
+endef
+
+$(eval $(call KernelPackage,e100))
+
+
+define KernelPackage/e1000
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=Intel(R) PRO/1000 PCI cards kernel support
+ DEPENDS:=@PCI_SUPPORT
+ KCONFIG:=CONFIG_E1000 \
+ CONFIG_E1000_DISABLE_PACKET_SPLIT=n \
+ CONFIG_E1000_NAPI=y
+ FILES:=$(LINUX_DIR)/drivers/net/ethernet/intel/e1000/e1000.ko
+ AUTOLOAD:=$(call AutoLoad,35,e1000)
+endef
+
+define KernelPackage/e1000/description
+ Kernel modules for Intel(R) PRO/1000 PCI Ethernet adapters.
+endef
+
+$(eval $(call KernelPackage,e1000))
+
+
+define KernelPackage/e1000e
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=Intel(R) PRO/1000 PCIe cards kernel support
+ DEPENDS:=@PCIE_SUPPORT
+ KCONFIG:=CONFIG_E1000E
+ FILES:=$(LINUX_DIR)/drivers/net/ethernet/intel/e1000e/e1000e.ko
+ AUTOLOAD:=$(call AutoLoad,50,e1000e)
+endef
+
+define KernelPackage/e1000e/description
+ Kernel modules for Intel(R) PRO/1000 PCIe Ethernet adapters.
+endef
+
+$(eval $(call KernelPackage,e1000e))
+
+
+define KernelPackage/b44
+ TITLE:=Broadcom 44xx driver
+ KCONFIG:=CONFIG_B44
+ DEPENDS:=@PCI_SUPPORT +!TARGET_brcm47xx:kmod-ssb
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ FILES:=$(LINUX_DIR)/drivers/net/ethernet/broadcom/b44.ko
+ AUTOLOAD:=$(call AutoLoad,50,b44)
+endef
+
+define KernelPackage/b44/description
+ Kernel modules for Broadcom 44xx Ethernet adapters.
+endef
+
+$(eval $(call KernelPackage,b44))
+
+
+define KernelPackage/3c59x
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=3Com 3c590/3c900 series (592/595/597) Vortex/Boomerang
+ DEPENDS:=@PCI_SUPPORT
+ KCONFIG:=CONFIG_VORTEX
+ FILES:=$(LINUX_DIR)/drivers/net/ethernet/3com/3c59x.ko
+ AUTOLOAD:=$(call AutoLoad,50,3c59x)
+endef
+
+define KernelPackage/3c59x/description
+ This option enables driver support for a large number of 10mbps and
+ 10/100mbps EISA, PCI and PCMCIA 3Com Ethernet adapters:
+ - "Vortex" (Fast EtherLink 3c590/3c592/3c595/3c597) EISA and PCI
+ - "Boomerang" (EtherLink XL 3c900 or 3c905) PCI
+ - "Cyclone" (3c540/3c900/3c905/3c980/3c575/3c656) PCI and Cardbus
+ - "Tornado" (3c905) PCI
+ - "Hurricane" (3c555/3cSOHO) PCI
+endef
+
+$(eval $(call KernelPackage,3c59x))
+
+
+define KernelPackage/pcnet32
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=AMD PCnet32 PCI support
+ DEPENDS:=@(PCI_SUPPORT||TARGET_malta)
+ KCONFIG:=CONFIG_PCNET32
+ FILES:=$(LINUX_DIR)/drivers/net/ethernet/amd/pcnet32.ko
+ AUTOLOAD:=$(call AutoLoad,50,pcnet32)
+endef
+
+define KernelPackage/pcnet32/description
+ Kernel modules for AMD PCnet32 Ethernet adapters.
+endef
+
+$(eval $(call KernelPackage,pcnet32))
+
+
+define KernelPackage/tg3
+ TITLE:=Broadcom Tigon3 Gigabit Ethernet
+ KCONFIG:=CONFIG_TIGON3
+ DEPENDS:=+!TARGET_brcm47xx:kmod-libphy +!LINUX_3_3:kmod-hwmon-core +LINUX_3_8:kmod-ptp
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ FILES:=$(LINUX_DIR)/drivers/net/ethernet/broadcom/tg3.ko
+ AUTOLOAD:=$(call AutoLoad,50,tg3)
+endef
+
+define KernelPackage/tg3/description
+ Kernel modules for Broadcom Tigon3 Gigabit Ethernet adapters.
+endef
+
+$(eval $(call KernelPackage,tg3))
+
+
+define KernelPackage/hfcpci
+ TITLE:=HFC PCI cards (single port) support for mISDN
+ KCONFIG:=CONFIG_MISDN_HFCPCI
+ DEPENDS:=+kmod-misdn
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ FILES:=$(LINUX_DIR)/drivers/isdn/hardware/mISDN/hfcpci.ko
+ AUTOLOAD:=$(call AutoLoad,31,hfcpci)
+endef
+
+define KernelPackage/hfcpci/description
+ Kernel modules for Cologne AG's HFC pci cards (single port)
+ using the mISDN V2 stack.
+endef
+
+$(eval $(call KernelPackage,hfcpci))
+
+
+define KernelPackage/hfcmulti
+ TITLE:=HFC multiport cards (HFC-4S/8S/E1) support for mISDN
+ KCONFIG:=CONFIG_MISDN_HFCMULTI
+ DEPENDS:=+kmod-misdn
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ FILES:=$(LINUX_DIR)/drivers/isdn/hardware/mISDN/hfcmulti.ko
+ AUTOLOAD:=$(call AutoLoad,31,hfcmulti)
+endef
+
+define KernelPackage/hfcmulti/description
+ Kernel modules for Cologne AG's HFC multiport cards (HFC-4S/8S/E1)
+ using the mISDN V2 stack.
+endef
+
+$(eval $(call KernelPackage,hfcmulti))
+
+
+define KernelPackage/gigaset
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=Siemens Gigaset support for isdn4linux
+ DEPENDS:=@USB_SUPPORT +kmod-isdn4linux +kmod-lib-crc-ccitt +kmod-usb-core
+ URL:=http://gigaset307x.sourceforge.net/
+ KCONFIG:= \
+ CONFIG_ISDN_DRV_GIGASET \
+ CONFIG_GIGASET_BASE \
+ CONFIG_GIGASET_M101 \
+ CONFIG_GIGASET_M105 \
+ CONFIG_GIGASET_UNDOCREQ=y \
+ CONFIG_GIGASET_I4L=y
+ FILES:= \
+ $(LINUX_DIR)/drivers/isdn/gigaset/gigaset.ko \
+ $(LINUX_DIR)/drivers/isdn/gigaset/bas_gigaset.ko \
+ $(LINUX_DIR)/drivers/isdn/gigaset/ser_gigaset.ko \
+ $(LINUX_DIR)/drivers/isdn/gigaset/usb_gigaset.ko
+ AUTOLOAD:=$(call AutoLoad,50,gigaset bas_gigaset ser_gigaset usb_gigaset)
+endef
+
+define KernelPackage/gigaset/description
+ This driver supports the Siemens Gigaset SX205/255 family of
+ ISDN DECT bases, including the predecessors Gigaset 3070/3075
+ and 4170/4175 and their T-Com versions Sinus 45isdn and Sinus
+ 721X.
+endef
+
+$(eval $(call KernelPackage,gigaset))
+
+
+define KernelPackage/macvlan
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=MAC-VLAN support
+ KCONFIG:=CONFIG_MACVLAN
+ FILES:=$(LINUX_DIR)/drivers/net/macvlan.ko
+ AUTOLOAD:=$(call AutoLoad,50,macvlan)
+endef
+
+define KernelPackage/macvlan/description
+ A kernel module which allows one to create virtual interfaces that
+ map packets to or from specific MAC addresses to a particular interface.
+endef
+
+$(eval $(call KernelPackage,macvlan))
+
+define KernelPackage/tulip
+ TITLE:=Tulip family network device support
+ DEPENDS:=@PCI_SUPPORT
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ KCONFIG:= \
+ CONFIG_NET_TULIP=y \
+ CONFIG_DE2104X \
+ CONFIG_DE2104X_DSL=0 \
+ CONFIG_TULIP \
+ CONFIG_TULIP_MWI=y \
+ CONFIG_TULIP_MMIO=y \
+ CONFIG_TULIP_NAPI=y \
+ CONFIG_TULIP_NAPI_HW_MITIGATION=y \
+ CONFIG_DE4X5 \
+ CONFIG_WINBOND_840 \
+ CONFIG_DM9102 \
+ CONFIG_ULI526X
+ FILES:= \
+ $(LINUX_DIR)/drivers/net/ethernet/dec/tulip/tulip.ko \
+ $(LINUX_DIR)/drivers/net/ethernet/dec/tulip/de2104x.ko \
+ $(LINUX_DIR)/drivers/net/ethernet/dec/tulip/de4x5.ko \
+ $(LINUX_DIR)/drivers/net/ethernet/dec/tulip/dmfe.ko \
+ $(LINUX_DIR)/drivers/net/ethernet/dec/tulip/uli526x.ko \
+ $(LINUX_DIR)/drivers/net/ethernet/dec/tulip/winbond-840.ko
+ AUTOLOAD:=$(call AutoLoad,50,tulip)
+endef
+
+define KernelPackage/tulip/description
+ Kernel modules for the Tulip family of network cards,
+ including DECchip Tulip, DIGITAL EtherWORKS, Winbond W89c840,
+ Davicom DM910x/DM980x and ULi M526x controller support.
+endef
+
+$(eval $(call KernelPackage,tulip))
+
+
+define KernelPackage/solos-pci
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=Solos ADSL2+ multiport modem
+ DEPENDS:=@PCI_SUPPORT +kmod-atm
+ KCONFIG:=CONFIG_ATM_SOLOS
+ FILES:=$(LINUX_DIR)/drivers/atm/solos-pci.ko
+ AUTOLOAD:=$(call AutoLoad,50,solos-pci)
+endef
+
+define KernelPackage/solos-pci/description
+ Kernel module for Traverse Technologies' Solos PCI cards
+ and Geos ADSL2+ x86 motherboard.
+endef
+
+$(eval $(call KernelPackage,solos-pci))
+
+define KernelPackage/dummy
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=Dummy network device
+ KCONFIG:=CONFIG_DUMMY
+ FILES:=$(LINUX_DIR)/drivers/net/dummy.ko
+ AUTOLOAD:=$(call AutoLoad,34,dummy)
+endef
+
+define KernelPackage/dummy/description
+ The dummy network device
+endef
+
+$(eval $(call KernelPackage,dummy))
+
+define KernelPackage/ifb
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=Intermediate Functional Block support
+ KCONFIG:= \
+ CONFIG_IFB \
+ CONFIG_NET_CLS=y
+ FILES:=$(LINUX_DIR)/drivers/net/ifb.ko
+ AUTOLOAD:=$(call AutoLoad,34,ifb)
+endef
+
+define KernelPackage/ifb/description
+ The Intermediate Functional Block
+endef
+
+$(eval $(call KernelPackage,ifb))
+
+define KernelPackage/dm9000
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=Davicom 9000 Ethernet support
+ DEPENDS:=@PCI_SUPPORT
+ KCONFIG:=CONFIG_DM9000 \
+ CONFIG_DM9000_DEBUGLEVEL=4 \
+ CONFIG_DM9000_FORCE_SIMPLE_PHY_POLL=y
+ FILES:=$(LINUX_DIR)/drivers/net/ethernet/davicom/dm9000.ko
+ AUTOLOAD:=$(call AutoLoad,34,dm9000)
+endef
+
+define KernelPackage/dm9000/description
+ Kernel driver for Davicom 9000 Ethernet adapters.
+endef
+
+$(eval $(call KernelPackage,dm9000))
+
+define KernelPackage/forcedeth
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=nForce Ethernet support
+ DEPENDS:=@PCI_SUPPORT
+ KCONFIG:=CONFIG_FORCEDETH
+ FILES:=$(LINUX_DIR)/drivers/net/ethernet/nvidia/forcedeth.ko
+ AUTOLOAD:=$(call AutoLoad,50,forcedeth)
+endef
+
+define KernelPackage/forcedeth/description
+ Kernel driver for Nvidia Ethernet support
+endef
+
+$(eval $(call KernelPackage,forcedeth))
+
+define KernelPackage/of-mdio
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=OpenFirmware MDIO support
+ DEPENDS:=+kmod-libphy
+ KCONFIG:=CONFIG_OF_MDIO
+ FILES:=$(LINUX_DIR)/drivers/of/of_mdio.ko
+ AUTOLOAD:=$(call AutoLoad,41,of_mdio)
+endef
+
+define KernelPackage/of-mdio/description
+ Kernel driver for OpenFirmware MDIO support
+endef
+
+$(eval $(call KernelPackage,of-mdio))
+
+define KernelPackage/fsl-pq-mdio
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=Freescale PQ MDIO bus support
+ DEPENDS:=@TARGET_mpc85xx +kmod-of-mdio
+ KCONFIG:=CONFIG_FSL_PQ_MDIO
+ FILES:=$(LINUX_DIR)/drivers/net/ethernet/freescale/fsl_pq_mdio.ko
+ AUTOLOAD:=$(call AutoLoad,42,fsl_pq_mdio)
+endef
+
+define KernelPackage/fsl-pq-mdio/description
+ Kernel driver for the Freescale PQ MDIO bus
+endef
+
+$(eval $(call KernelPackage,fsl-pq-mdio))
+
+
+define KernelPackage/gianfar
+ SUBMENU:=$(NETWORK_DEVICES_MENU)
+ TITLE:=Gianfar Ethernet support
+ DEPENDS:=@TARGET_mpc85xx +kmod-fsl-pq-mdio
+ KCONFIG:=CONFIG_GIANFAR
+ FILES:=$(LINUX_DIR)/drivers/net/ethernet/freescale/gianfar_driver.ko
+ AUTOLOAD:=$(call AutoLoad,50,gianfar_driver)
+endef
+
+define KernelPackage/gianfar/description
+ Kernel driver for Freescale Gianfar Ethernet support
+endef
+
+$(eval $(call KernelPackage,gianfar))
diff --git a/package/kernel/modules/netfilter.mk b/package/kernel/modules/netfilter.mk
new file mode 100644
index 0000000..50180a5
--- /dev/null
+++ b/package/kernel/modules/netfilter.mk
@@ -0,0 +1,575 @@
+
+#
+# Copyright (C) 2006-2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+NF_MENU:=Netfilter Extensions
+NF_KMOD:=1
+include $(INCLUDE_DIR)/netfilter.mk
+
+define KernelPackage/ipt-core
+ SUBMENU:=$(NF_MENU)
+ TITLE:=Netfilter core
+ KCONFIG:= \
+ CONFIG_NETFILTER=y \
+ CONFIG_NETFILTER_ADVANCED=y \
+ $(KCONFIG_IPT_CORE)
+ FILES:=$(foreach mod,$(IPT_CORE-m),$(LINUX_DIR)/net/$(mod).ko)
+ AUTOLOAD:=$(call AutoLoad,40,$(notdir $(IPT_CORE-m)))
+endef
+
+define KernelPackage/ipt-core/description
+ Netfilter core kernel modules
+ Includes:
+ - comment
+ - limit
+ - LOG
+ - mac
+ - multiport
+ - REJECT
+ - TCPMSS
+endef
+
+$(eval $(call KernelPackage,ipt-core))
+
+
+define AddDepends/ipt
+ SUBMENU:=$(NF_MENU)
+ DEPENDS+= kmod-ipt-core $(1)
+endef
+
+
+define KernelPackage/ipt-conntrack
+ TITLE:=Basic connection tracking modules
+ KCONFIG:=$(KCONFIG_IPT_CONNTRACK)
+ FILES:=$(foreach mod,$(IPT_CONNTRACK-m),$(LINUX_DIR)/net/$(mod).ko)
+ AUTOLOAD:=$(call AutoLoad,41,$(notdir $(IPT_CONNTRACK-m)))
+ $(call AddDepends/ipt)
+endef
+
+define KernelPackage/ipt-conntrack/description
+ Netfilter (IPv4) kernel modules for connection tracking
+ Includes:
+ - conntrack
+ - defrag
+ - iptables_raw
+ - NOTRACK
+ - state
+endef
+
+$(eval $(call KernelPackage,ipt-conntrack))
+
+
+define KernelPackage/ipt-conntrack-extra
+ TITLE:=Extra connection tracking modules
+ KCONFIG:=$(KCONFIG_IPT_CONNTRACK_EXTRA)
+ FILES:=$(foreach mod,$(IPT_CONNTRACK_EXTRA-m),$(LINUX_DIR)/net/$(mod).ko)
+ AUTOLOAD:=$(call AutoLoad,42,$(notdir $(IPT_CONNTRACK_EXTRA-m)))
+ $(call AddDepends/ipt,+kmod-ipt-conntrack)
+endef
+
+define KernelPackage/ipt-conntrack-extra/description
+ Netfilter (IPv4) extra kernel modules for connection tracking
+ Includes:
+ - connbytes
+ - connmark/CONNMARK
+ - conntrack
+ - helper
+ - recent
+endef
+
+$(eval $(call KernelPackage,ipt-conntrack-extra))
+
+
+define KernelPackage/ipt-filter
+ TITLE:=Modules for packet content inspection
+ KCONFIG:=$(KCONFIG_IPT_FILTER)
+ FILES:=$(foreach mod,$(IPT_FILTER-m),$(LINUX_DIR)/net/$(mod).ko)
+ AUTOLOAD:=$(call AutoLoad,45,$(notdir $(IPT_FILTER-m)))
+ $(call AddDepends/ipt,+kmod-lib-textsearch)
+endef
+
+define KernelPackage/ipt-filter/description
+ Netfilter (IPv4) kernel modules for packet content inspection
+ Includes:
+ - layer7
+ - string
+endef
+
+$(eval $(call KernelPackage,ipt-filter))
+
+
+define KernelPackage/ipt-ipopt
+ TITLE:=Modules for matching/changing IP packet options
+ KCONFIG:=$(KCONFIG_IPT_IPOPT)
+ FILES:=$(foreach mod,$(IPT_IPOPT-m),$(LINUX_DIR)/net/$(mod).ko)
+ AUTOLOAD:=$(call AutoLoad,45,$(notdir $(IPT_IPOPT-m)))
+ $(call AddDepends/ipt)
+endef
+
+define KernelPackage/ipt-ipopt/description
+ Netfilter (IPv4) modules for matching/changing IP packet options
+ Includes:
+ - CLASSIFY
+ - dscp/DSCP
+ - ecn/ECN
+ - hl/HL
+ - length
+ - mark/MARK
+ - statistic
+ - tcpmss
+ - time
+ - ttl/TTL
+ - unclean
+endef
+
+$(eval $(call KernelPackage,ipt-ipopt))
+
+
+define KernelPackage/ipt-ipsec
+ TITLE:=Modules for matching IPSec packets
+ KCONFIG:=$(KCONFIG_IPT_IPSEC)
+ FILES:=$(foreach mod,$(IPT_IPSEC-m),$(LINUX_DIR)/net/$(mod).ko)
+ AUTOLOAD:=$(call AutoLoad,45,$(notdir $(IPT_IPSEC-m)))
+ $(call AddDepends/ipt)
+endef
+
+define KernelPackage/ipt-ipsec/description
+ Netfilter (IPv4) modules for matching IPSec packets
+ Includes:
+ - ah
+ - esp
+ - policy
+endef
+
+$(eval $(call KernelPackage,ipt-ipsec))
+
+
+define KernelPackage/ipt-nat
+ TITLE:=Basic NAT targets
+ KCONFIG:=$(KCONFIG_IPT_NAT)
+ FILES:=$(foreach mod,$(IPT_NAT-m),$(LINUX_DIR)/net/$(mod).ko)
+ AUTOLOAD:=$(call AutoLoad,42,$(notdir $(IPT_NAT-m)))
+ $(call AddDepends/ipt,+kmod-ipt-conntrack)
+endef
+
+define KernelPackage/ipt-nat/description
+ Netfilter (IPv4) kernel modules for basic NAT targets
+ Includes:
+ - MASQUERADE
+endef
+
+$(eval $(call KernelPackage,ipt-nat))
+
+
+define KernelPackage/ipt-nat-extra
+ TITLE:=Extra NAT targets
+ KCONFIG:=$(KCONFIG_IPT_NAT_EXTRA)
+ FILES:=$(foreach mod,$(IPT_NAT_EXTRA-m),$(LINUX_DIR)/net/$(mod).ko)
+ AUTOLOAD:=$(call AutoLoad,43,$(notdir $(IPT_NAT_EXTRA-m)))
+ $(call AddDepends/ipt,+kmod-ipt-nat)
+endef
+
+define KernelPackage/ipt-nat-extra/description
+ Netfilter (IPv4) kernel modules for extra NAT targets
+ Includes:
+ - NETMAP
+ - REDIRECT
+endef
+
+$(eval $(call KernelPackage,ipt-nat-extra))
+
+
+define KernelPackage/ipt-nathelper
+ TITLE:=Basic Conntrack and NAT helpers
+ KCONFIG:=$(KCONFIG_IPT_NATHELPER)
+ FILES:=$(foreach mod,$(IPT_NATHELPER-m),$(LINUX_DIR)/net/$(mod).ko)
+ AUTOLOAD:=$(call AutoLoad,45,$(notdir $(IPT_NATHELPER-m)))
+ $(call AddDepends/ipt,+kmod-ipt-nat)
+endef
+
+define KernelPackage/ipt-nathelper/description
+ Default Netfilter (IPv4) Conntrack and NAT helpers
+ Includes:
+ - ftp
+ - irc
+ - tftp
+endef
+
+$(eval $(call KernelPackage,ipt-nathelper))
+
+
+define KernelPackage/ipt-nathelper-extra
+ TITLE:=Extra Conntrack and NAT helpers
+ KCONFIG:=$(KCONFIG_IPT_NATHELPER_EXTRA)
+ FILES:=$(foreach mod,$(IPT_NATHELPER_EXTRA-m),$(LINUX_DIR)/net/$(mod).ko)
+ AUTOLOAD:=$(call AutoLoad,45,$(notdir $(IPT_NATHELPER_EXTRA-m)))
+ $(call AddDepends/ipt,+kmod-ipt-nat +kmod-lib-textsearch)
+endef
+
+define KernelPackage/ipt-nathelper-extra/description
+ Extra Netfilter (IPv4) Conntrack and NAT helpers
+ Includes:
+ - amanda
+ - h323
+ - mms
+ - pptp
+ - proto_gre
+ - sip
+ - snmp_basic
+ - broadcast
+endef
+
+$(eval $(call KernelPackage,ipt-nathelper-extra))
+
+
+define KernelPackage/ipt-queue
+ TITLE:=Module for user-space packet queueing
+ KCONFIG:=$(KCONFIG_IPT_QUEUE)
+ DEPENDS:=@!LINUX_3_6
+ FILES:=$(foreach mod,$(IPT_QUEUE-m),$(LINUX_DIR)/net/$(mod).ko)
+ AUTOLOAD:=$(call AutoLoad,45,$(notdir $(IPT_QUEUE-m)))
+ $(call AddDepends/ipt)
+endef
+
+define KernelPackage/ipt-queue/description
+ Netfilter (IPv4) module for user-space packet queueing
+ Includes:
+ - QUEUE
+endef
+
+$(eval $(call KernelPackage,ipt-queue))
+
+
+define KernelPackage/ipt-ulog
+ TITLE:=Module for user-space packet logging
+ KCONFIG:=$(KCONFIG_IPT_ULOG)
+ FILES:=$(foreach mod,$(IPT_ULOG-m),$(LINUX_DIR)/net/$(mod).ko)
+ AUTOLOAD:=$(call AutoLoad,45,$(notdir $(IPT_ULOG-m)))
+ $(call AddDepends/ipt)
+endef
+
+define KernelPackage/ipt-ulog/description
+ Netfilter (IPv4) module for user-space packet logging
+ Includes:
+ - ULOG
+endef
+
+$(eval $(call KernelPackage,ipt-ulog))
+
+
+define KernelPackage/ipt-debug
+ TITLE:=Module for debugging/development
+ KCONFIG:=$(KCONFIG_IPT_DEBUG)
+ DEFAULT:=n
+ FILES:=$(foreach mod,$(IPT_DEBUG-m),$(LINUX_DIR)/net/$(mod).ko)
+ AUTOLOAD:=$(call AutoLoad,45,$(notdir $(IPT_DEBUG-m)))
+ $(call AddDepends/ipt)
+endef
+
+define KernelPackage/ipt-debug/description
+ Netfilter modules for debugging/development of the firewall
+ Includes:
+ - TRACE
+endef
+
+$(eval $(call KernelPackage,ipt-debug))
+
+
+define KernelPackage/ipt-led
+ TITLE:=Module to trigger a LED with a Netfilter rule
+ KCONFIG:=$(KCONFIG_IPT_LED)
+ FILES:=$(foreach mod,$(IPT_LED-m),$(LINUX_DIR)/net/$(mod).ko)
+ AUTOLOAD:=$(call AutoLoad,61,$(notdir $(IPT_LED-m)))
+ $(call AddDepends/ipt)
+endef
+
+define KernelPackage/ipt-led/description
+ Netfilter target to trigger a LED when a network packet is matched.
+endef
+
+$(eval $(call KernelPackage,ipt-led))
+
+define KernelPackage/ipt-tproxy
+ TITLE:=Transparent proxying support
+ DEPENDS+=+IPV6:kmod-ipv6
+ KCONFIG:= \
+ CONFIG_NETFILTER_TPROXY \
+ CONFIG_NETFILTER_XT_MATCH_SOCKET \
+ CONFIG_NETFILTER_XT_TARGET_TPROXY
+ FILES:= \
+ $(LINUX_DIR)/net/netfilter/nf_tproxy_core.ko \
+ $(foreach mod,$(IPT_TPROXY-m),$(LINUX_DIR)/net/$(mod).ko)
+ AUTOLOAD:=$(call AutoLoad,50,$(notdir nf_tproxy_core $(IPT_TPROXY-m)))
+ $(call AddDepends/ipt)
+endef
+
+define KernelPackage/ipt-tproxy/description
+ Kernel modules for Transparent Proxying
+endef
+
+$(eval $(call KernelPackage,ipt-tproxy))
+
+define KernelPackage/ipt-tee
+ TITLE:=TEE support
+ KCONFIG:= \
+ CONFIG_NETFILTER_XT_TARGET_TEE
+ FILES:= \
+ $(LINUX_DIR)/net/netfilter/xt_TEE.ko \
+ $(foreach mod,$(IPT_TEE-m),$(LINUX_DIR)/net/$(mod).ko)
+ AUTOLOAD:=$(call AutoLoad,45,$(notdir nf_tee $(IPT_TEE-m)))
+ $(call AddDepends/ipt)
+endef
+
+define KernelPackage/ipt-tee/description
+ Kernel modules for TEE
+endef
+
+$(eval $(call KernelPackage,ipt-tee))
+
+
+define KernelPackage/ipt-u32
+ TITLE:=U32 support
+ KCONFIG:= \
+ CONFIG_NETFILTER_XT_MATCH_U32
+ FILES:= \
+ $(LINUX_DIR)/net/netfilter/xt_u32.ko \
+ $(foreach mod,$(IPT_U32-m),$(LINUX_DIR)/net/$(mod).ko)
+ AUTOLOAD:=$(call AutoLoad,45,$(notdir nf_tee $(IPT_U32-m)))
+ $(call AddDepends/ipt)
+endef
+
+define KernelPackage/ipt-u32/description
+ Kernel modules for U32
+endef
+
+$(eval $(call KernelPackage,ipt-u32))
+
+
+define KernelPackage/ipt-iprange
+ TITLE:=Module for matching ip ranges
+ KCONFIG:=$(KCONFIG_IPT_IPRANGE)
+ FILES:=$(foreach mod,$(IPT_IPRANGE-m),$(LINUX_DIR)/net/$(mod).ko)
+ AUTOLOAD:=$(call AutoLoad,45,$(notdir $(IPT_IPRANGE-m)))
+ $(call AddDepends/ipt)
+endef
+
+define KernelPackage/ipt-iprange/description
+ Netfilter (IPv4) module for matching ip ranges
+ Includes:
+ - iprange
+endef
+
+$(eval $(call KernelPackage,ipt-iprange))
+
+
+define KernelPackage/ipt-extra
+ TITLE:=Extra modules
+ KCONFIG:=$(KCONFIG_IPT_EXTRA)
+ FILES:=$(foreach mod,$(IPT_EXTRA-m),$(LINUX_DIR)/net/$(mod).ko)
+ AUTOLOAD:=$(call AutoLoad,45,$(notdir $(IPT_EXTRA-m)))
+ $(call AddDepends/ipt)
+endef
+
+define KernelPackage/ipt-extra/description
+ Other Netfilter (IPv4) kernel modules
+ Includes:
+ - addrtype
+ - owner
+ - physdev (if bridge support was enabled in kernel)
+ - pkttype
+ - quota
+endef
+
+$(eval $(call KernelPackage,ipt-extra))
+
+
+define KernelPackage/ip6tables
+ SUBMENU:=$(NF_MENU)
+ TITLE:=IPv6 modules
+ DEPENDS:=+kmod-ipv6
+ KCONFIG:=$(KCONFIG_IPT_IPV6)
+ FILES:=$(foreach mod,$(IPT_IPV6-m),$(LINUX_DIR)/net/$(mod).ko)
+ AUTOLOAD:=$(call AutoLoad,49,$(notdir $(IPT_IPV6-m)))
+endef
+
+define KernelPackage/ip6tables/description
+ Netfilter IPv6 firewalling support
+endef
+
+$(eval $(call KernelPackage,ip6tables))
+
+
+define KernelPackage/arptables
+ SUBMENU:=$(NF_MENU)
+ TITLE:=ARP firewalling modules
+ FILES:=$(LINUX_DIR)/net/ipv4/netfilter/arp*.ko
+ KCONFIG:=CONFIG_IP_NF_ARPTABLES \
+ CONFIG_IP_NF_ARPFILTER \
+ CONFIG_IP_NF_ARP_MANGLE
+ AUTOLOAD:=$(call AutoLoad,49,$(notdir $(patsubst %.ko,%,$(wildcard $(LINUX_DIR)/net/ipv4/netfilter/arp*.ko))))
+endef
+
+define KernelPackage/arptables/description
+ Kernel modules for ARP firewalling
+endef
+
+$(eval $(call KernelPackage,arptables))
+
+
+define KernelPackage/ebtables
+ SUBMENU:=$(NF_MENU)
+ TITLE:=Bridge firewalling modules
+ FILES:=$(foreach mod,$(EBTABLES-m),$(LINUX_DIR)/net/$(mod).ko)
+ KCONFIG:=CONFIG_BRIDGE_NETFILTER=y \
+ $(KCONFIG_EBTABLES)
+ AUTOLOAD:=$(call AutoLoad,49,$(notdir $(EBTABLES-m)))
+endef
+
+define KernelPackage/ebtables/description
+ ebtables is a general, extensible frame/packet identification
+ framework. It provides you to do Ethernet
+ filtering/NAT/brouting on the Ethernet bridge.
+endef
+
+$(eval $(call KernelPackage,ebtables))
+
+
+define AddDepends/ebtables
+ SUBMENU:=$(NF_MENU)
+ DEPENDS+=kmod-ebtables $(1)
+endef
+
+
+define KernelPackage/ebtables-ipv4
+ TITLE:=ebtables: IPv4 support
+ FILES:=$(foreach mod,$(EBTABLES_IP4-m),$(LINUX_DIR)/net/$(mod).ko)
+ KCONFIG:=$(KCONFIG_EBTABLES_IP4)
+ AUTOLOAD:=$(call AutoLoad,49,$(notdir $(EBTABLES_IP4-m)))
+ $(call AddDepends/ebtables)
+endef
+
+define KernelPackage/ebtables-ipv4/description
+ This option adds the IPv4 support to ebtables, which allows basic
+ IPv4 header field filtering, ARP filtering as well as SNAT, DNAT targets.
+endef
+
+$(eval $(call KernelPackage,ebtables-ipv4))
+
+
+define KernelPackage/ebtables-ipv6
+ TITLE:=ebtables: IPv6 support
+ FILES:=$(foreach mod,$(EBTABLES_IP6-m),$(LINUX_DIR)/net/$(mod).ko)
+ KCONFIG:=$(KCONFIG_EBTABLES_IP6)
+ AUTOLOAD:=$(call AutoLoad,49,$(notdir $(EBTABLES_IP6-m)))
+ $(call AddDepends/ebtables)
+endef
+
+define KernelPackage/ebtables-ipv6/description
+ This option adds the IPv6 support to ebtables, which allows basic
+ IPv6 header field filtering and target support.
+endef
+
+$(eval $(call KernelPackage,ebtables-ipv6))
+
+
+define KernelPackage/ebtables-watchers
+ TITLE:=ebtables: watchers support
+ FILES:=$(foreach mod,$(EBTABLES_WATCHERS-m),$(LINUX_DIR)/net/$(mod).ko)
+ KCONFIG:=$(KCONFIG_EBTABLES_WATCHERS)
+ AUTOLOAD:=$(call AutoLoad,49,$(notdir $(EBTABLES_WATCHERS-m)))
+ $(call AddDepends/ebtables)
+endef
+
+define KernelPackage/ebtables-watchers/description
+ This option adds the log watchers, that you can use in any rule
+ in any ebtables table.
+endef
+
+$(eval $(call KernelPackage,ebtables-watchers))
+
+
+define KernelPackage/nfnetlink
+ SUBMENU:=$(NF_MENU)
+ TITLE:=Netlink-based userspace interface
+ DEPENDS:=+kmod-ipt-core
+ FILES:=$(LINUX_DIR)/net/netfilter/nfnetlink.ko
+ KCONFIG:=CONFIG_NETFILTER_NETLINK
+ AUTOLOAD:=$(call AutoLoad,48,nfnetlink)
+endef
+
+define KernelPackage/nfnetlink/description
+ Kernel modules support for a netlink-based userspace interface
+endef
+
+$(eval $(call KernelPackage,nfnetlink))
+
+
+define AddDepends/nfnetlink
+ SUBMENU:=$(NF_MENU)
+ DEPENDS+=+kmod-nfnetlink $(1)
+endef
+
+
+define KernelPackage/nfnetlink-log
+ TITLE:=Netfilter LOG over NFNETLINK interface
+ FILES:=$(LINUX_DIR)/net/netfilter/nfnetlink_log.ko
+ KCONFIG:=CONFIG_NETFILTER_NETLINK_LOG
+ AUTOLOAD:=$(call AutoLoad,48,nfnetlink_log)
+ $(call AddDepends/nfnetlink)
+endef
+
+define KernelPackage/nfnetlink-log/description
+ Kernel modules support for logging packets via NFNETLINK
+endef
+
+$(eval $(call KernelPackage,nfnetlink-log))
+
+
+define KernelPackage/nfnetlink-queue
+ TITLE:=Netfilter QUEUE over NFNETLINK interface
+ FILES:=$(LINUX_DIR)/net/netfilter/nfnetlink_queue.ko
+ KCONFIG:=CONFIG_NETFILTER_NETLINK_QUEUE
+ AUTOLOAD:=$(call AutoLoad,48,nfnetlink_queue)
+ $(call AddDepends/nfnetlink)
+endef
+
+define KernelPackage/nfnetlink-queue/description
+ Kernel modules support for queueing packets via NFNETLINK
+endef
+
+$(eval $(call KernelPackage,nfnetlink-queue))
+
+
+define KernelPackage/nf-conntrack-netlink
+ TITLE:=Connection tracking netlink interface
+ FILES:=$(LINUX_DIR)/net/netfilter/nf_conntrack_netlink.ko
+ KCONFIG:=CONFIG_NF_CT_NETLINK
+ AUTOLOAD:=$(call AutoLoad,49,nf_conntrack_netlink)
+ $(call AddDepends/nfnetlink,+kmod-ipt-conntrack)
+endef
+
+define KernelPackage/nf-conntrack-netlink/description
+ Kernel modules support for a netlink-based connection tracking
+ userspace interface
+endef
+
+$(eval $(call KernelPackage,nf-conntrack-netlink))
+
+define KernelPackage/ipt-hashlimit
+ SUBMENU:=$(NF_MENU)
+ TITLE:=Netfilter hashlimit match
+ KCONFIG:=$(KCONFIG_IPT_HASHLIMIT)
+ FILES:=$(LINUX_DIR)/net/netfilter/xt_hashlimit.ko
+ AUTOLOAD:=$(call AutoLoad,50,xt_hashlimit)
+ $(call KernelPackage/ipt)
+endef
+
+define KernelPackage/ipt-hashlimit/description
+ Kernel modules support for the hashlimit bucket match module
+endef
+
+$(eval $(call KernelPackage,ipt-hashlimit))
diff --git a/package/kernel/modules/netsupport.mk b/package/kernel/modules/netsupport.mk
new file mode 100644
index 0000000..d893c1a
--- /dev/null
+++ b/package/kernel/modules/netsupport.mk
@@ -0,0 +1,891 @@
+#
+# Copyright (C) 2006-2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+NETWORK_SUPPORT_MENU:=Network Support
+
+define KernelPackage/atm
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=ATM support
+ KCONFIG:= \
+ CONFIG_ATM \
+ CONFIG_ATM_BR2684
+ FILES:= \
+ $(LINUX_DIR)/net/atm/atm.ko \
+ $(LINUX_DIR)/net/atm/br2684.ko
+ AUTOLOAD:=$(call AutoLoad,30,atm br2684)
+endef
+
+define KernelPackage/atm/description
+ Kernel modules for ATM support
+endef
+
+$(eval $(call KernelPackage,atm))
+
+
+define KernelPackage/atmtcp
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=ATM over TCP
+ DEPENDS:=kmod-atm
+ KCONFIG:=CONFIG_ATM_TCP CONFIG_ATM_DRIVERS=y
+ FILES:=$(LINUX_DIR)/drivers/atm/atmtcp.ko
+ AUTOLOAD:=$(call AutoLoad,40,atmtcp)
+endef
+
+define KernelPackage/atmtcp/description
+ Kernel module for ATM over TCP support
+endef
+
+$(eval $(call KernelPackage,atmtcp))
+
+
+define KernelPackage/appletalk
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=Appletalk protocol support
+ KCONFIG:= \
+ CONFIG_ATALK \
+ CONFIG_DEV_APPLETALK \
+ CONFIG_IPDDP \
+ CONFIG_IPDDP_ENCAP=y \
+ CONFIG_IPDDP_DECAP=y
+ FILES:= \
+ $(LINUX_DIR)/net/appletalk/appletalk.ko \
+ $(LINUX_DIR)/drivers/net/appletalk/ipddp.ko
+ AUTOLOAD:=$(call AutoLoad,40,appletalk ipddp)
+endef
+
+define KernelPackage/appletalk/description
+ Kernel module for AppleTalk protocol.
+endef
+
+$(eval $(call KernelPackage,appletalk))
+
+
+define KernelPackage/bonding
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=Ethernet bonding driver
+ KCONFIG:=CONFIG_BONDING
+ FILES:=$(LINUX_DIR)/drivers/net/bonding/bonding.ko
+ AUTOLOAD:=$(call AutoLoad,40,bonding)
+endef
+
+define KernelPackage/bonding/description
+ Kernel module for NIC bonding.
+endef
+
+$(eval $(call KernelPackage,bonding))
+
+
+define KernelPackage/bridge
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=Ethernet bridging support
+ DEPENDS:=+kmod-stp
+ KCONFIG:= \
+ CONFIG_BRIDGE \
+ CONFIG_BRIDGE_IGMP_SNOOPING=y
+ FILES:=$(LINUX_DIR)/net/bridge/bridge.ko
+ AUTOLOAD:=$(call AutoLoad,11,bridge)
+endef
+
+define KernelPackage/bridge/description
+ Kernel module for Ethernet bridging.
+endef
+
+$(eval $(call KernelPackage,bridge))
+
+define KernelPackage/llc
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=ANSI/IEEE 802.2 LLC support
+ KCONFIG:=CONFIG_LLC
+ FILES:=$(LINUX_DIR)/net/llc/llc.ko
+ AUTOLOAD:=$(call AutoLoad,09,llc)
+endef
+
+define KernelPackage/llc/description
+ Kernel module for ANSI/IEEE 802.2 LLC support.
+endef
+
+$(eval $(call KernelPackage,llc))
+
+define KernelPackage/stp
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=Ethernet Spanning Tree Protocol support
+ DEPENDS:=+kmod-llc
+ KCONFIG:=CONFIG_STP
+ FILES:=$(LINUX_DIR)/net/802/stp.ko
+ AUTOLOAD:=$(call AutoLoad,10,stp)
+endef
+
+define KernelPackage/stp/description
+ Kernel module for Ethernet Spanning Tree Protocol support.
+endef
+
+$(eval $(call KernelPackage,stp))
+
+define KernelPackage/8021q
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=802.1Q VLAN support
+ KCONFIG:=CONFIG_VLAN_8021Q \
+ CONFIG_VLAN_8021Q_GVRP=n
+ FILES:=$(LINUX_DIR)/net/8021q/8021q.ko
+ AUTOLOAD:=$(call AutoLoad,12,8021q)
+endef
+
+define KernelPackage/8021q/description
+ Kernel module for 802.1Q VLAN support
+endef
+
+$(eval $(call KernelPackage,8021q))
+
+
+define KernelPackage/capi
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=CAPI (ISDN) Support
+ KCONFIG:= \
+ CONFIG_ISDN_CAPI \
+ CONFIG_ISDN_CAPI_CAPI20 \
+ CONFIG_ISDN_CAPIFS \
+ CONFIG_ISDN_CAPI_CAPIFS
+ FILES:= \
+ $(LINUX_DIR)/drivers/isdn/capi/kernelcapi.ko \
+ $(LINUX_DIR)/drivers/isdn/capi/capi.ko
+ AUTOLOAD:=$(call AutoLoad,30,kernelcapi capi)
+endef
+
+define KernelPackage/capi/description
+ Kernel module for basic CAPI (ISDN) support
+endef
+
+$(eval $(call KernelPackage,capi))
+
+define KernelPackage/misdn
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=mISDN (ISDN) Support
+ KCONFIG:= \
+ CONFIG_ISDN=y \
+ CONFIG_MISDN \
+ CONFIG_MISDN_DSP \
+ CONFIG_MISDN_L1OIP
+ FILES:= \
+ $(LINUX_DIR)/drivers/isdn/mISDN/mISDN_core.ko \
+ $(LINUX_DIR)/drivers/isdn/mISDN/mISDN_dsp.ko \
+ $(LINUX_DIR)/drivers/isdn/mISDN/l1oip.ko
+ AUTOLOAD:=$(call AutoLoad,30,mISDN_core mISDN_dsp l1oip)
+endef
+
+define KernelPackage/misdn/description
+ Modular ISDN driver support
+endef
+
+$(eval $(call KernelPackage,misdn))
+
+
+define KernelPackage/isdn4linux
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=Old ISDN4Linux (deprecated)
+ KCONFIG:= \
+ CONFIG_ISDN=y \
+ CONFIG_ISDN_I4L \
+ CONFIG_ISDN_PPP=y \
+ CONFIG_ISDN_PPP_VJ=y \
+ CONFIG_ISDN_MPP=y \
+ CONFIG_IPPP_FILTER=y \
+ CONFIG_ISDN_PPP_BSDCOMP \
+ CONFIG_ISDN_CAPI_MIDDLEWARE=y \
+ CONFIG_ISDN_CAPI_CAPIFS_BOOL=y \
+ CONFIG_ISDN_AUDIO=y \
+ CONFIG_ISDN_TTY_FAX=y \
+ CONFIG_ISDN_X25=y \
+ CONFIG_ISDN_DIVERSION
+ FILES:= \
+ $(LINUX_DIR)/drivers/isdn/divert/dss1_divert.ko \
+ $(LINUX_DIR)/drivers/isdn/i4l/isdn.ko \
+ $(LINUX_DIR)/drivers/isdn/i4l/isdn_bsdcomp.ko
+ AUTOLOAD:=$(call AutoLoad,40,isdn isdn_bsdcomp dss1_divert)
+endef
+
+define KernelPackage/isdn4linux/description
+ This driver allows you to use an ISDN adapter for networking
+endef
+
+$(eval $(call KernelPackage,isdn4linux))
+
+
+define KernelPackage/ipip
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=IP-in-IP encapsulation
+ DEPENDS:=+kmod-iptunnel4
+ KCONFIG:=CONFIG_NET_IPIP
+ FILES:=$(LINUX_DIR)/net/ipv4/ipip.ko
+ AUTOLOAD:=$(call AutoLoad,32,ipip)
+endef
+
+define KernelPackage/ipip/description
+ Kernel modules for IP-in-IP encapsulation
+endef
+
+$(eval $(call KernelPackage,ipip))
+
+
+IPSEC-m:= \
+ $(if $(CONFIG_LINUX_3_3),,xfrm/xfrm_algo) \
+ xfrm/xfrm_ipcomp \
+ xfrm/xfrm_user \
+ key/af_key \
+
+define KernelPackage/ipsec
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=IPsec related modules (IPv4 and IPv6)
+ DEPENDS:=+kmod-crypto-authenc +kmod-crypto-iv +kmod-crypto-des +kmod-crypto-hmac +kmod-crypto-md5 +kmod-crypto-sha1 +kmod-crypto-deflate +kmod-crypto-cbc
+ KCONFIG:= \
+ CONFIG_NET_KEY \
+ CONFIG_XFRM_USER \
+ CONFIG_INET_IPCOMP \
+ CONFIG_XFRM_IPCOMP
+ FILES:=$(foreach mod,$(IPSEC-m),$(LINUX_DIR)/net/$(mod).ko)
+ AUTOLOAD:=$(call AutoLoad,30,$(notdir $(IPSEC-m)))
+endef
+
+define KernelPackage/ipsec/description
+ Kernel modules for IPsec support in both IPv4 and IPv6.
+ Includes:
+ - af_key
+ - xfrm_ipcomp
+ - xfrm_user
+endef
+
+$(eval $(call KernelPackage,ipsec))
+
+
+IPSEC4-m:= \
+ ipv4/ah4 \
+ ipv4/esp4 \
+ ipv4/xfrm4_mode_beet \
+ ipv4/xfrm4_mode_transport \
+ ipv4/xfrm4_mode_tunnel \
+ ipv4/xfrm4_tunnel \
+ ipv4/ipcomp \
+
+define KernelPackage/ipsec4
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=IPsec related modules (IPv4)
+ DEPENDS:=kmod-ipsec +kmod-iptunnel4
+ KCONFIG:= \
+ CONFIG_INET_AH \
+ CONFIG_INET_ESP \
+ CONFIG_INET_IPCOMP \
+ CONFIG_INET_XFRM_MODE_BEET \
+ CONFIG_INET_XFRM_MODE_TRANSPORT \
+ CONFIG_INET_XFRM_MODE_TUNNEL \
+ CONFIG_INET_XFRM_TUNNEL
+ FILES:=$(foreach mod,$(IPSEC4-m),$(LINUX_DIR)/net/$(mod).ko)
+ AUTOLOAD:=$(call AutoLoad,32,$(notdir $(IPSEC4-m)))
+endef
+
+define KernelPackage/ipsec4/description
+ Kernel modules for IPsec support in IPv4.
+ Includes:
+ - ah4
+ - esp4
+ - ipcomp4
+ - xfrm4_mode_beet
+ - xfrm4_mode_transport
+ - xfrm4_mode_tunnel
+ - xfrm4_tunnel
+endef
+
+$(eval $(call KernelPackage,ipsec4))
+
+
+IPSEC6-m:= \
+ ipv6/ah6 \
+ ipv6/esp6 \
+ ipv6/xfrm6_mode_beet \
+ ipv6/xfrm6_mode_transport \
+ ipv6/xfrm6_mode_tunnel \
+ ipv6/xfrm6_tunnel \
+ ipv6/ipcomp6 \
+
+define KernelPackage/ipsec6
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=IPsec related modules (IPv6)
+ DEPENDS:=kmod-ipsec +kmod-iptunnel6
+ KCONFIG:= \
+ CONFIG_INET6_AH \
+ CONFIG_INET6_ESP \
+ CONFIG_INET6_IPCOMP \
+ CONFIG_INET6_XFRM_MODE_BEET \
+ CONFIG_INET6_XFRM_MODE_TRANSPORT \
+ CONFIG_INET6_XFRM_MODE_TUNNEL \
+ CONFIG_INET6_XFRM_TUNNEL
+ FILES:=$(foreach mod,$(IPSEC6-m),$(LINUX_DIR)/net/$(mod).ko)
+ AUTOLOAD:=$(call AutoLoad,32,$(notdir $(IPSEC6-m)))
+endef
+
+define KernelPackage/ipsec6/description
+ Kernel modules for IPsec support in IPv6.
+ Includes:
+ - ah6
+ - esp6
+ - ipcomp6
+ - xfrm6_mode_beet
+ - xfrm6_mode_transport
+ - xfrm6_mode_tunnel
+ - xfrm6_tunnel
+endef
+
+$(eval $(call KernelPackage,ipsec6))
+
+
+# NOTE: tunnel4 is not selectable by itself, so enable ipip for that
+define KernelPackage/iptunnel4
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=IPv4 tunneling
+ KCONFIG:= \
+ CONFIG_NET_IPIP \
+ CONFIG_INET_TUNNEL
+ FILES:=$(LINUX_DIR)/net/ipv4/tunnel4.ko
+ AUTOLOAD:=$(call AutoLoad,31,tunnel4)
+endef
+
+define KernelPackage/iptunnel4/description
+ Kernel modules for IPv4 tunneling
+endef
+
+$(eval $(call KernelPackage,iptunnel4))
+
+
+define KernelPackage/iptunnel6
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=IPv6 tunneling
+ DEPENDS:= +kmod-ipv6
+ KCONFIG:= \
+ CONFIG_INET6_TUNNEL
+ FILES:=$(LINUX_DIR)/net/ipv6/tunnel6.ko
+ AUTOLOAD:=$(call AutoLoad,31,tunnel6)
+endef
+
+define KernelPackage/iptunnel6/description
+ Kernel modules for IPv6 tunneling
+endef
+
+$(eval $(call KernelPackage,iptunnel6))
+
+
+define KernelPackage/ipv6
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=IPv6 support
+ KCONFIG:= \
+ CONFIG_IPV6 \
+ CONFIG_IPV6_PRIVACY=y \
+ CONFIG_IPV6_MULTIPLE_TABLES=y \
+ CONFIG_IPV6_MROUTE=y \
+ CONFIG_IPV6_PIMSM_V2=n \
+ CONFIG_IPV6_SUBTREES=y
+ FILES:=$(LINUX_DIR)/net/ipv6/ipv6.ko
+ AUTOLOAD:=$(call AutoLoad,20,ipv6)
+endef
+
+define KernelPackage/ipv6/description
+ Kernel modules for IPv6 support
+endef
+
+$(eval $(call KernelPackage,ipv6))
+
+
+define KernelPackage/sit
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ DEPENDS:=+kmod-ipv6 +kmod-iptunnel4
+ TITLE:=IPv6-in-IPv4 tunnel
+ KCONFIG:=CONFIG_IPV6_SIT \
+ CONFIG_IPV6_SIT_6RD=y
+ FILES:=$(LINUX_DIR)/net/ipv6/sit.ko
+ AUTOLOAD:=$(call AutoLoad,32,sit)
+endef
+
+define KernelPackage/sit/description
+ Kernel modules for IPv6-in-IPv4 tunnelling
+endef
+
+$(eval $(call KernelPackage,sit))
+
+
+define KernelPackage/ip6-tunnel
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=IP-in-IPv6 tunnelling
+ DEPENDS:= +kmod-ipv6 +kmod-iptunnel6
+ KCONFIG:= CONFIG_IPV6_TUNNEL
+ FILES:=$(LINUX_DIR)/net/ipv6/ip6_tunnel.ko
+ AUTOLOAD:=$(call AutoLoad,32,ip6_tunnel)
+endef
+
+define KernelPackage/ip6-tunnel/description
+ Kernel modules for IPv6-in-IPv6 and IPv4-in-IPv6 tunnelling
+endef
+
+$(eval $(call KernelPackage,ip6-tunnel))
+
+
+define KernelPackage/gre
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=GRE support
+ DEPENDS:=+PACKAGE_kmod-ipv6:kmod-ipv6
+ KCONFIG:=CONFIG_NET_IPGRE CONFIG_NET_IPGRE_DEMUX
+ FILES:=$(LINUX_DIR)/net/ipv4/ip_gre.ko $(LINUX_DIR)/net/ipv4/gre.ko
+ AUTOLOAD:=$(call AutoLoad,39,gre ip_gre)
+endef
+
+define KernelPackage/gre/description
+ Generic Routing Encapsulation support
+endef
+
+$(eval $(call KernelPackage,gre))
+
+
+define KernelPackage/gre6
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=GRE support over IPV6
+ DEPENDS:=+kmod-ipv6 +kmod-ip6-tunnel @!LINUX_3_3 @!LINUX_3_6
+ KCONFIG:=CONFIG_IPV6_GRE
+ FILES:=$(LINUX_DIR)/net/ipv6/ip6_gre.ko
+ AUTOLOAD:=$(call AutoLoad,39,ip6_gre)
+endef
+
+define KernelPackage/gre6/description
+ Generic Routing Encapsulation support over IPv6
+endef
+
+$(eval $(call KernelPackage,gre6))
+
+
+define KernelPackage/tun
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=Universal TUN/TAP driver
+ KCONFIG:=CONFIG_TUN
+ FILES:=$(LINUX_DIR)/drivers/net/tun.ko
+ AUTOLOAD:=$(call AutoLoad,30,tun)
+endef
+
+define KernelPackage/tun/description
+ Kernel support for the TUN/TAP tunneling device
+endef
+
+$(eval $(call KernelPackage,tun))
+
+
+define KernelPackage/ppp
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=PPP modules
+ DEPENDS:=+kmod-lib-crc-ccitt
+ KCONFIG:= \
+ CONFIG_PPP \
+ CONFIG_PPP_ASYNC \
+ CONFIG_SLHC
+ FILES:= \
+ $(LINUX_DIR)/drivers/net/ppp/ppp_async.ko \
+ $(LINUX_DIR)/drivers/net/ppp/ppp_generic.ko \
+ $(LINUX_DIR)/drivers/net/slip/slhc.ko
+ AUTOLOAD:=$(call AutoLoad,30,slhc ppp_generic ppp_async)
+endef
+
+define KernelPackage/ppp/description
+ Kernel modules for PPP support
+endef
+
+$(eval $(call KernelPackage,ppp))
+
+
+define KernelPackage/ppp-synctty
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=PPP sync tty support
+ DEPENDS:=kmod-ppp
+ KCONFIG:=CONFIG_PPP_SYNC_TTY
+ FILES:=$(LINUX_DIR)/drivers/net/ppp/ppp_synctty.ko
+ AUTOLOAD:=$(call AutoLoad,40,ppp_synctty)
+endef
+
+define KernelPackage/ppp-synctty/description
+ Kernel modules for PPP sync tty support
+endef
+
+$(eval $(call KernelPackage,ppp-synctty))
+
+
+define KernelPackage/pppox
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=PPPoX helper
+ DEPENDS:=kmod-ppp
+ KCONFIG:=CONFIG_PPPOE
+ FILES:=$(LINUX_DIR)/drivers/net/ppp/pppox.ko
+ AUTOLOAD:=$(call AutoLoad,40,pppox)
+endef
+
+define KernelPackage/pppox/description
+ Kernel helper module for PPPoE and PPTP support
+endef
+
+$(eval $(call KernelPackage,pppox))
+
+
+define KernelPackage/pppoe
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=PPPoE support
+ DEPENDS:=kmod-ppp +kmod-pppox
+ KCONFIG:=CONFIG_PPPOE
+ FILES:=$(LINUX_DIR)/drivers/net/ppp/pppoe.ko
+ AUTOLOAD:=$(call AutoLoad,41,pppoe)
+endef
+
+define KernelPackage/pppoe/description
+ Kernel module for PPPoE (PPP over Ethernet) support
+endef
+
+$(eval $(call KernelPackage,pppoe))
+
+
+define KernelPackage/pppoa
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=PPPoA support
+ DEPENDS:=kmod-ppp +kmod-atm
+ KCONFIG:=CONFIG_PPPOATM CONFIG_ATM_DRIVERS=y
+ FILES:=$(LINUX_DIR)/net/atm/pppoatm.ko
+ AUTOLOAD:=$(call AutoLoad,40,pppoatm)
+endef
+
+define KernelPackage/pppoa/description
+ Kernel modules for PPPoA (PPP over ATM) support
+endef
+
+$(eval $(call KernelPackage,pppoa))
+
+
+define KernelPackage/pptp
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=PPtP support
+ DEPENDS:=kmod-ppp +kmod-gre +kmod-pppox
+ KCONFIG:=CONFIG_PPTP
+ FILES:=$(LINUX_DIR)/drivers/net/ppp/pptp.ko
+ AUTOLOAD:=$(call AutoLoad,41,pptp)
+endef
+
+$(eval $(call KernelPackage,pptp))
+
+
+define KernelPackage/pppol2tp
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=PPPoL2TP support
+ DEPENDS:=kmod-ppp +kmod-pppox +kmod-l2tp
+ KCONFIG:=CONFIG_PPPOL2TP
+ FILES:=$(LINUX_DIR)/net/l2tp/l2tp_ppp.ko
+ AUTOLOAD:=$(call AutoLoad,41,l2tp_ppp)
+endef
+
+define KernelPackage/pppol2tp/description
+ Kernel modules for PPPoL2TP (PPP over L2TP) support
+endef
+
+$(eval $(call KernelPackage,pppol2tp))
+
+
+define KernelPackage/ipoa
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=IPoA support
+ DEPENDS:=kmod-atm
+ KCONFIG:=CONFIG_ATM_CLIP
+ FILES:=$(LINUX_DIR)/net/atm/clip.ko
+ AUTOLOAD:=$(call AutoLoad,40,clip)
+endef
+
+define KernelPackage/ipoa/description
+ Kernel modules for IPoA (IP over ATM) support
+endef
+
+$(eval $(call KernelPackage,ipoa))
+
+
+define KernelPackage/mppe
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=Microsoft PPP compression/encryption
+ DEPENDS:=kmod-ppp +kmod-crypto-core +kmod-crypto-arc4 +kmod-crypto-sha1 +kmod-crypto-ecb
+ KCONFIG:= \
+ CONFIG_PPP_MPPE_MPPC \
+ CONFIG_PPP_MPPE
+ FILES:=$(LINUX_DIR)/drivers/net/ppp/ppp_mppe.ko
+ AUTOLOAD:=$(call AutoLoad,31,ppp_mppe)
+endef
+
+define KernelPackage/mppe/description
+ Kernel modules for Microsoft PPP compression/encryption
+endef
+
+$(eval $(call KernelPackage,mppe))
+
+
+SCHED_MODULES = $(patsubst $(LINUX_DIR)/net/sched/%.ko,%,$(wildcard $(LINUX_DIR)/net/sched/*.ko))
+SCHED_MODULES_CORE = sch_ingress sch_codel sch_fq_codel sch_hfsc cls_fw cls_route cls_flow cls_tcindex cls_u32 em_u32 act_mirred act_skbedit
+SCHED_MODULES_FILTER = $(SCHED_MODULES_CORE) act_connmark sch_esfq
+SCHED_MODULES_EXTRA = $(filter-out $(SCHED_MODULES_FILTER),$(SCHED_MODULES))
+SCHED_FILES = $(patsubst %,$(LINUX_DIR)/net/sched/%.ko,$(filter $(SCHED_MODULES_CORE),$(SCHED_MODULES)))
+SCHED_FILES_EXTRA = $(patsubst %,$(LINUX_DIR)/net/sched/%.ko,$(SCHED_MODULES_EXTRA))
+
+define KernelPackage/sched-core
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=Traffic schedulers
+ KCONFIG:= \
+ CONFIG_NET_SCHED=y \
+ CONFIG_NET_SCH_HFSC \
+ CONFIG_NET_SCH_INGRESS \
+ CONFIG_NET_SCH_CODEL \
+ CONFIG_NET_SCH_FQ_CODEL \
+ CONFIG_NET_CLS=y \
+ CONFIG_NET_CLS_ACT=y \
+ CONFIG_NET_CLS_FLOW \
+ CONFIG_NET_CLS_FW \
+ CONFIG_NET_CLS_ROUTE4 \
+ CONFIG_NET_CLS_TCINDEX \
+ CONFIG_NET_CLS_U32 \
+ CONFIG_NET_ACT_MIRRED \
+ CONFIG_NET_ACT_SKBEDIT \
+ CONFIG_NET_EMATCH=y \
+ CONFIG_NET_EMATCH_U32
+ FILES:=$(SCHED_FILES)
+ AUTOLOAD:=$(call AutoLoad,70, $(SCHED_MODULES_CORE))
+endef
+
+define KernelPackage/sched-core/description
+ Core kernel scheduler support for IP traffic
+endef
+
+$(eval $(call KernelPackage,sched-core))
+
+
+define KernelPackage/sched-connmark
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=Traffic shaper conntrack mark support
+ DEPENDS:=+kmod-sched-core +kmod-ipt-core +kmod-ipt-conntrack-extra
+ KCONFIG:=CONFIG_NET_ACT_CONNMARK
+ FILES:=$(LINUX_DIR)/net/sched/act_connmark.ko
+ AUTOLOAD:=$(call AutoLoad,71, act_connmark)
+endef
+$(eval $(call KernelPackage,sched-connmark))
+
+define KernelPackage/sched-esfq
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=Traffic shaper ESFQ support
+ DEPENDS:=+kmod-sched-core +kmod-ipt-core
+ KCONFIG:= \
+ CONFIG_NET_SCH_ESFQ \
+ CONFIG_NET_SCH_ESFQ_NFCT=y
+ FILES:=$(LINUX_DIR)/net/sched/sch_esfq.ko
+ AUTOLOAD:=$(call AutoLoad,72, sch_esfq)
+endef
+$(eval $(call KernelPackage,sched-esfq))
+
+define KernelPackage/sched
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=Extra traffic schedulers
+ DEPENDS:=+kmod-sched-core
+ KCONFIG:= \
+ CONFIG_NET_SCH_DSMARK \
+ CONFIG_NET_SCH_HTB \
+ CONFIG_NET_SCH_FIFO \
+ CONFIG_NET_SCH_GRED \
+ CONFIG_NET_SCH_PRIO \
+ CONFIG_NET_SCH_RED \
+ CONFIG_NET_SCH_TBF \
+ CONFIG_NET_SCH_SFQ \
+ CONFIG_NET_SCH_TEQL \
+ CONFIG_NET_CLS_BASIC \
+ CONFIG_NET_ACT_POLICE \
+ CONFIG_NET_ACT_IPT \
+ CONFIG_NET_EMATCH_CMP \
+ CONFIG_NET_EMATCH_NBYTE \
+ CONFIG_NET_EMATCH_META \
+ CONFIG_NET_EMATCH_TEXT
+ FILES:=$(SCHED_FILES_EXTRA)
+ AUTOLOAD:=$(call AutoLoad,73, $(SCHED_MODULES_EXTRA))
+endef
+
+define KernelPackage/sched/description
+ Extra kernel schedulers modules for IP traffic
+endef
+
+$(eval $(call KernelPackage,sched))
+
+
+define KernelPackage/ax25
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=AX25 support
+ KCONFIG:= \
+ CONFIG_AX25 \
+ CONFIG_MKISS
+ FILES:= \
+ $(LINUX_DIR)/net/ax25/ax25.ko \
+ $(LINUX_DIR)/drivers/net/hamradio/mkiss.ko
+ AUTOLOAD:=$(call AutoLoad,80,ax25 mkiss)
+ $(call AddDepends/crc16)
+endef
+
+define KernelPackage/ax25/description
+ Kernel modules for AX25 support
+endef
+
+$(eval $(call KernelPackage,ax25))
+
+
+define KernelPackage/mp-alg
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=ECMP caching algorithms
+ KCONFIG:= \
+ CONFIG_IP_ROUTE_MULTIPATH_RR \
+ CONFIG_IP_ROUTE_MULTIPATH_RANDOM \
+ CONFIG_IP_ROUTE_MULTIPATH_WRANDOM \
+ CONFIG_IP_ROUTE_MULTIPATH_DRR
+ FILES:= \
+ $(LINUX_DIR)/net/ipv4/multipath_rr.ko \
+ $(LINUX_DIR)/net/ipv4/multipath_random.ko \
+ $(LINUX_DIR)/net/ipv4/multipath_wrandom.ko \
+ $(LINUX_DIR)/net/ipv4/multipath_drr.ko
+ AUTOLOAD:=$(call AutoLoad,35,multipath_rr multipath_random multipath_wrandom multipath_drr)
+endef
+
+define KernelPackage/mp-alg/description
+ Kernel modules that provide several different algorithms for multipath
+ route selection from the route cache. The iproute "mpath" argument allows
+ specifying which algorithm to use for routes.
+ quagga (at least <=0.99.6) requires a multipath patch to support this
+ cached mp route feature.
+endef
+
+$(eval $(call KernelPackage,mp-alg))
+
+
+define KernelPackage/pktgen
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ DEPENDS:=@!TARGET_uml
+ TITLE:=Network packet generator
+ KCONFIG:=CONFIG_NET_PKTGEN
+ FILES:=$(LINUX_DIR)/net/core/pktgen.ko
+ AUTOLOAD:=$(call AutoLoad,99,pktgen)
+endef
+
+define KernelPackage/pktgen/description
+ Kernel modules for the Network Packet Generator
+endef
+
+$(eval $(call KernelPackage,pktgen))
+
+define KernelPackage/l2tp
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=Layer Two Tunneling Protocol (L2TP)
+ KCONFIG:=CONFIG_L2TP \
+ CONFIG_L2TP_V3=y \
+ CONFIG_L2TP_DEBUGFS=n
+ FILES:=$(LINUX_DIR)/net/l2tp/l2tp_core.ko \
+ $(LINUX_DIR)/net/l2tp/l2tp_netlink.ko
+ AUTOLOAD:=$(call AutoLoad,32,l2tp_core l2tp_netlink)
+endef
+
+define KernelPackage/l2tp/description
+ Kernel modules for L2TP V3 Support
+endef
+
+$(eval $(call KernelPackage,l2tp))
+
+
+define KernelPackage/l2tp-eth
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=L2TP ethernet pseudowire support for L2TPv3
+ DEPENDS:=+kmod-l2tp
+ KCONFIG:=CONFIG_L2TP_ETH
+ FILES:=$(LINUX_DIR)/net/l2tp/l2tp_eth.ko
+ AUTOLOAD:=$(call AutoLoad,33,l2tp_eth)
+endef
+
+define KernelPackage/l2tp-eth/description
+ Kernel modules for L2TP ethernet pseudowire support for L2TPv3
+endef
+
+$(eval $(call KernelPackage,l2tp-eth))
+
+define KernelPackage/l2tp-ip
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=L2TP IP encapsulation for L2TPv3
+ DEPENDS:=+kmod-l2tp
+ KCONFIG:=CONFIG_L2TP_IP
+ FILES:=$(LINUX_DIR)/net/l2tp/l2tp_ip.ko
+ AUTOLOAD:=$(call AutoLoad,33,l2tp_ip)
+endef
+
+define KernelPackage/l2tp-ip/description
+ Kernel modules for L2TP IP encapsulation for L2TPv3
+endef
+
+$(eval $(call KernelPackage,l2tp-ip))
+
+
+define KernelPackage/sctp
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=SCTP protocol kernel support
+ KCONFIG:=\
+ CONFIG_IP_SCTP \
+ CONFIG_SCTP_DBG_MSG=n \
+ CONFIG_SCTP_DBG_OBJCNT=n \
+ CONFIG_SCTP_HMAC_NONE=n \
+ CONFIG_SCTP_HMAC_SHA1=n \
+ CONFIG_SCTP_HMAC_MD5=y \
+ CONFIG_SCTP_COOKIE_HMAC_SHA1=n \
+ CONFIG_SCTP_COOKIE_HMAC_MD5=y \
+ CONFIG_SCTP_DEFAULT_COOKIE_HMAC_NONE=n \
+ CONFIG_SCTP_DEFAULT_COOKIE_HMAC_SHA1=n \
+ CONFIG_SCTP_DEFAULT_COOKIE_HMAC_MD5=y
+ FILES:= $(LINUX_DIR)/net/sctp/sctp.ko
+ AUTOLOAD:= $(call AutoLoad,32,sctp)
+ DEPENDS:=+kmod-lib-crc32c +kmod-crypto-md5 +kmod-crypto-hmac
+endef
+
+define KernelPackage/sctp/description
+ Kernel modules for SCTP protocol support
+endef
+
+$(eval $(call KernelPackage,sctp))
+
+
+define KernelPackage/netem
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=Network emulation functionality
+ DEPENDS:=+kmod-sched
+ KCONFIG:=CONFIG_NET_SCH_NETEM
+ FILES:=$(LINUX_DIR)/net/sched/sch_netem.ko
+ AUTOLOAD:=$(call AutoLoad,99,netem)
+endef
+
+define KernelPackage/netem/description
+ Kernel modules for emulating the properties of wide area networks
+endef
+
+$(eval $(call KernelPackage,netem))
+
+define KernelPackage/slip
+ SUBMENU:=$(NETWORK_SUPPORT_MENU)
+ TITLE:=SLIP modules
+ KCONFIG:= \
+ CONFIG_SLIP \
+ CONFIG_SLIP_COMPRESSED=y \
+ CONFIG_SLIP_SMART=y \
+ CONFIG_SLIP_MODE_SLIP6=y
+
+ FILES:= \
+ $(LINUX_DIR)/drivers/net/slip/slip.ko
+ AUTOLOAD:=$(call AutoLoad,30,slip)
+endef
+
+define KernelPackage/slip/description
+ Kernel modules for SLIP support
+endef
+
+$(eval $(call KernelPackage,slip))
+
diff --git a/package/kernel/modules/nls.mk b/package/kernel/modules/nls.mk
new file mode 100644
index 0000000..28791b6
--- /dev/null
+++ b/package/kernel/modules/nls.mk
@@ -0,0 +1,228 @@
+#
+# Copyright (C) 2006-2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+define KernelPackage/nls-base
+ SUBMENU:=Native Language Support
+ TITLE:=Native Language Support
+ KCONFIG:=CONFIG_NLS
+ FILES:=$(LINUX_DIR)/fs/nls/nls_base.ko
+ AUTOLOAD:=$(call AutoLoad,20,nls_base,1)
+endef
+
+define KernelPackage/nls-base/description
+ Kernel module for NLS (Native Language Support)
+endef
+
+$(eval $(call KernelPackage,nls-base))
+
+
+define KernelPackage/nls-cp437
+ SUBMENU:=Native Language Support
+ TITLE:=Codepage 437 (United States, Canada)
+ KCONFIG:=CONFIG_NLS_CODEPAGE_437
+ FILES:=$(LINUX_DIR)/fs/nls/nls_cp437.ko
+ AUTOLOAD:=$(call AutoLoad,25,nls_cp437)
+ $(call AddDepends/nls)
+endef
+
+define KernelPackage/nls-cp437/description
+ Kernel module for NLS Codepage 437 (United States, Canada)
+endef
+
+$(eval $(call KernelPackage,nls-cp437))
+
+
+define KernelPackage/nls-cp775
+ SUBMENU:=Native Language Support
+ TITLE:=Codepage 775 (Baltic Rim)
+ KCONFIG:=CONFIG_NLS_CODEPAGE_775
+ FILES:=$(LINUX_DIR)/fs/nls/nls_cp775.ko
+ AUTOLOAD:=$(call AutoLoad,25,nls_cp775)
+ $(call AddDepends/nls)
+endef
+
+define KernelPackage/nls-cp775/description
+ Kernel module for NLS Codepage 775 (Baltic Rim)
+endef
+
+$(eval $(call KernelPackage,nls-cp775))
+
+
+define KernelPackage/nls-cp850
+ SUBMENU:=Native Language Support
+ TITLE:=Codepage 850 (Europe)
+ KCONFIG:=CONFIG_NLS_CODEPAGE_850
+ FILES:=$(LINUX_DIR)/fs/nls/nls_cp850.ko
+ AUTOLOAD:=$(call AutoLoad,25,nls_cp850)
+ $(call AddDepends/nls)
+endef
+
+define KernelPackage/nls-cp850/description
+ Kernel module for NLS Codepage 850 (Europe)
+endef
+
+$(eval $(call KernelPackage,nls-cp850))
+
+
+define KernelPackage/nls-cp852
+ SUBMENU:=Native Language Support
+ TITLE:=Codepage 852 (Europe)
+ KCONFIG:=CONFIG_NLS_CODEPAGE_852
+ FILES:=$(LINUX_DIR)/fs/nls/nls_cp852.ko
+ AUTOLOAD:=$(call AutoLoad,25,nls_cp852)
+ $(call AddDepends/nls)
+endef
+
+define KernelPackage/nls-cp852/description
+ Kernel module for NLS Codepage 852 (Europe)
+endef
+
+$(eval $(call KernelPackage,nls-cp852))
+
+
+define KernelPackage/nls-cp866
+ SUBMENU:=Native Language Support
+ TITLE:=Codepage 866 (Cyrillic)
+ KCONFIG:=CONFIG_NLS_CODEPAGE_866
+ FILES:=$(LINUX_DIR)/fs/nls/nls_cp866.ko
+ AUTOLOAD:=$(call AutoLoad,25,nls_cp866)
+ $(call AddDepends/nls)
+endef
+
+define KernelPackage/nls-cp866/description
+ Kernel module for NLS Codepage 866 (Cyrillic)
+endef
+
+$(eval $(call KernelPackage,nls-cp866))
+
+
+define KernelPackage/nls-cp1250
+ SUBMENU:=Native Language Support
+ TITLE:=Codepage 1250 (Eastern Europe)
+ KCONFIG:=CONFIG_NLS_CODEPAGE_1250
+ FILES:=$(LINUX_DIR)/fs/nls/nls_cp1250.ko
+ AUTOLOAD:=$(call AutoLoad,25,nls_cp1250)
+ $(call AddDepends/nls)
+endef
+
+define KernelPackage/nls-cp1250/description
+ Kernel module for NLS Codepage 1250 (Eastern Europe)
+endef
+
+$(eval $(call KernelPackage,nls-cp1250))
+
+
+define KernelPackage/nls-cp1251
+ SUBMENU:=Native Language Support
+ TITLE:=Codepage 1251 (Russian)
+ KCONFIG:=CONFIG_NLS_CODEPAGE_1251
+ FILES:=$(LINUX_DIR)/fs/nls/nls_cp1251.ko
+ AUTOLOAD:=$(call AutoLoad,25,nls_cp1251)
+ $(call AddDepends/nls)
+endef
+
+define KernelPackage/nls-cp1251/description
+ Kernel module for NLS Codepage 1251 (Russian)
+endef
+
+$(eval $(call KernelPackage,nls-cp1251))
+
+
+define KernelPackage/nls-iso8859-1
+ SUBMENU:=Native Language Support
+ TITLE:=ISO 8859-1 (Latin 1; Western European Languages)
+ KCONFIG:=CONFIG_NLS_ISO8859_1
+ FILES:=$(LINUX_DIR)/fs/nls/nls_iso8859-1.ko
+ AUTOLOAD:=$(call AutoLoad,25,nls_iso8859-1)
+ $(call AddDepends/nls)
+endef
+
+define KernelPackage/nls-iso8859-1/description
+ Kernel module for NLS ISO 8859-1 (Latin 1)
+endef
+
+$(eval $(call KernelPackage,nls-iso8859-1))
+
+
+define KernelPackage/nls-iso8859-2
+ SUBMENU:=Native Language Support
+ TITLE:=ISO 8859-2 (Latin 2; Central European Languages)
+ KCONFIG:=CONFIG_NLS_ISO8859_2
+ FILES:=$(LINUX_DIR)/fs/nls/nls_iso8859-2.ko
+ AUTOLOAD:=$(call AutoLoad,25,nls_iso8859-2)
+ $(call AddDepends/nls)
+endef
+
+define KernelPackage/nls-iso8859-2/description
+ Kernel module for NLS ISO 8859-2 (Latin 2)
+endef
+
+$(eval $(call KernelPackage,nls-iso8859-2))
+
+
+define KernelPackage/nls-iso8859-13
+ SUBMENU:=Native Language Support
+ TITLE:=ISO 8859-13 (Latin 7; Baltic)
+ KCONFIG:=CONFIG_NLS_ISO8859_13
+ FILES:=$(LINUX_DIR)/fs/nls/nls_iso8859-13.ko
+ AUTOLOAD:=$(call AutoLoad,25,nls_iso8859-13)
+ $(call AddDepends/nls)
+endef
+
+define KernelPackage/nls-iso8859-13/description
+ Kernel module for NLS ISO 8859-13 (Latin 7; Baltic)
+endef
+
+$(eval $(call KernelPackage,nls-iso8859-13))
+
+
+define KernelPackage/nls-iso8859-15
+ SUBMENU:=Native Language Support
+ TITLE:=ISO 8859-15 (Latin 9; Western, with Euro symbol)
+ KCONFIG:=CONFIG_NLS_ISO8859_15
+ FILES:=$(LINUX_DIR)/fs/nls/nls_iso8859-15.ko
+ AUTOLOAD:=$(call AutoLoad,25,nls_iso8859-15)
+ $(call AddDepends/nls)
+endef
+
+define KernelPackage/nls-iso8859-15/description
+ Kernel module for NLS ISO 8859-15 (Latin 9)
+endef
+
+$(eval $(call KernelPackage,nls-iso8859-15))
+
+
+define KernelPackage/nls-koi8r
+ SUBMENU:=Native Language Support
+ TITLE:=KOI8-R (Russian)
+ KCONFIG:=CONFIG_NLS_KOI8_R
+ FILES:=$(LINUX_DIR)/fs/nls/nls_koi8-r.ko
+ AUTOLOAD:=$(call AutoLoad,25,nls_koi8-r)
+ $(call AddDepends/nls)
+endef
+
+define KernelPackage/nls-koi8r/description
+ Kernel module for NLS KOI8-R (Russian)
+endef
+
+$(eval $(call KernelPackage,nls-koi8r))
+
+
+define KernelPackage/nls-utf8
+ SUBMENU:=Native Language Support
+ TITLE:=UTF-8
+ KCONFIG:=CONFIG_NLS_UTF8
+ FILES:=$(LINUX_DIR)/fs/nls/nls_utf8.ko
+ AUTOLOAD:=$(call AutoLoad,25,nls_utf8)
+ $(call AddDepends/nls)
+endef
+
+define KernelPackage/nls-utf8/description
+ Kernel module for NLS UTF-8
+endef
+
+$(eval $(call KernelPackage,nls-utf8))
diff --git a/package/kernel/modules/other.mk b/package/kernel/modules/other.mk
new file mode 100644
index 0000000..13a0ec4
--- /dev/null
+++ b/package/kernel/modules/other.mk
@@ -0,0 +1,655 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+OTHER_MENU:=Other modules
+
+WATCHDOG_DIR:=watchdog
+
+
+define KernelPackage/bluetooth
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=Bluetooth support
+ DEPENDS:=@USB_SUPPORT +kmod-usb-core
+ KCONFIG:= \
+ CONFIG_BLUEZ \
+ CONFIG_BLUEZ_L2CAP \
+ CONFIG_BLUEZ_SCO \
+ CONFIG_BLUEZ_RFCOMM \
+ CONFIG_BLUEZ_BNEP \
+ CONFIG_BLUEZ_HCIUART \
+ CONFIG_BLUEZ_HCIUSB \
+ CONFIG_BLUEZ_HIDP \
+ CONFIG_BT \
+ CONFIG_BT_L2CAP=y \
+ CONFIG_BT_SCO=y \
+ CONFIG_BT_RFCOMM \
+ CONFIG_BT_BNEP \
+ CONFIG_BT_HCIBTUSB \
+ CONFIG_BT_HCIUSB \
+ CONFIG_BT_HCIUART \
+ CONFIG_BT_HCIUART_H4 \
+ CONFIG_BT_HIDP \
+ CONFIG_HID_SUPPORT=y
+ $(call AddDepends/crc16)
+ $(call AddDepends/hid)
+ $(call AddDepends/rfkill)
+ FILES:= \
+ $(LINUX_DIR)/net/bluetooth/bluetooth.ko \
+ $(LINUX_DIR)/net/bluetooth/rfcomm/rfcomm.ko \
+ $(LINUX_DIR)/net/bluetooth/bnep/bnep.ko \
+ $(LINUX_DIR)/net/bluetooth/hidp/hidp.ko \
+ $(LINUX_DIR)/drivers/bluetooth/hci_uart.ko \
+ $(LINUX_DIR)/drivers/bluetooth/btusb.ko
+ AUTOLOAD:=$(call AutoLoad,90,bluetooth rfcomm bnep hidp hci_uart btusb)
+endef
+
+define KernelPackage/bluetooth/description
+ Kernel support for Bluetooth devices
+endef
+
+$(eval $(call KernelPackage,bluetooth))
+
+
+define KernelPackage/bluetooth-hci-h4p
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=HCI driver with H4 Nokia extensions
+ DEPENDS:=@TARGET_omap24xx +kmod-bluetooth
+ KCONFIG:=CONFIG_BT_HCIH4P
+ FILES:=$(LINUX_DIR)/drivers/bluetooth/hci_h4p/hci_h4p.ko
+ AUTOLOAD:=$(call AutoLoad,91,hci_h4p)
+endef
+
+define KernelPackage/bluetooth-hci-h4p/description
+ HCI driver with H4 Nokia extensions
+endef
+
+$(eval $(call KernelPackage,bluetooth-hci-h4p))
+
+
+define KernelPackage/eeprom-93cx6
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=EEPROM 93CX6 support
+ KCONFIG:=CONFIG_EEPROM_93CX6
+ FILES:=$(LINUX_DIR)/drivers/misc/eeprom/eeprom_93cx6.ko
+ AUTOLOAD:=$(call AutoLoad,20,eeprom_93cx6)
+endef
+
+define KernelPackage/eeprom-93cx6/description
+ Kernel module for EEPROM 93CX6 support
+endef
+
+$(eval $(call KernelPackage,eeprom-93cx6))
+
+
+define KernelPackage/eeprom-at24
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=EEPROM AT24 support
+ KCONFIG:=CONFIG_EEPROM_AT24
+ DEPENDS:=+kmod-i2c-core
+ FILES:=$(LINUX_DIR)/drivers/misc/eeprom/at24.ko
+ AUTOLOAD:=$(call AutoLoad,60,at24)
+endef
+
+define KernelPackage/eeprom-at24/description
+ Kernel module for most I2C EEPROMs
+endef
+
+$(eval $(call KernelPackage,eeprom-at24))
+
+
+define KernelPackage/eeprom-at25
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=EEPROM AT25 support
+ KCONFIG:=CONFIG_EEPROM_AT25
+ FILES:=$(LINUX_DIR)/drivers/misc/eeprom/at25.ko
+ AUTOLOAD:=$(call AutoLoad,61,at25)
+endef
+
+define KernelPackage/eeprom-at25/description
+ Kernel module for most SPI EEPROMs
+endef
+
+$(eval $(call KernelPackage,eeprom-at25))
+
+
+define KernelPackage/gpio-dev
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=Generic GPIO char device support
+ DEPENDS:=@GPIO_SUPPORT
+ KCONFIG:=CONFIG_GPIO_DEVICE
+ FILES:=$(LINUX_DIR)/drivers/char/gpio_dev.ko
+ AUTOLOAD:=$(call AutoLoad,40,gpio_dev)
+endef
+
+define KernelPackage/gpio-dev/description
+ Kernel module to allows control of GPIO pins using a character device.
+endef
+
+$(eval $(call KernelPackage,gpio-dev))
+
+
+define KernelPackage/gpio-nxp-74hc164
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=NXP 74HC164 GPIO expander support
+ KCONFIG:=CONFIG_GPIO_NXP_74HC164
+ FILES:=$(LINUX_DIR)/drivers/gpio/nxp_74hc164.ko
+ AUTOLOAD:=$(call AutoLoad,99,nxp_74hc164)
+endef
+
+define KernelPackage/gpio-nxp-74hc164/description
+ Kernel module for NXP 74HC164 GPIO expander
+endef
+
+$(eval $(call KernelPackage,gpio-nxp-74hc164))
+
+define KernelPackage/lp
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=Parallel port and line printer support
+ DEPENDS:=@BROKEN
+ KCONFIG:= \
+ CONFIG_PARPORT \
+ CONFIG_PRINTER \
+ CONFIG_PPDEV
+ FILES:= \
+ $(LINUX_DIR)/drivers/parport/parport.ko \
+ $(LINUX_DIR)/drivers/char/lp.ko \
+ $(LINUX_DIR)/drivers/char/ppdev.ko
+ AUTOLOAD:=$(call AutoLoad,50,parport lp)
+endef
+
+$(eval $(call KernelPackage,lp))
+
+
+define KernelPackage/mmc
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=MMC/SD Card Support
+ KCONFIG:= \
+ CONFIG_MMC \
+ CONFIG_MMC_BLOCK \
+ CONFIG_MMC_DEBUG=n \
+ CONFIG_MMC_UNSAFE_RESUME=n \
+ CONFIG_MMC_BLOCK_BOUNCE=y \
+ CONFIG_MMC_SDHCI=n \
+ CONFIG_MMC_TIFM_SD=n \
+ CONFIG_MMC_WBSD=n \
+ CONFIG_SDIO_UART=n
+ FILES:= \
+ $(LINUX_DIR)/drivers/mmc/core/mmc_core.ko \
+ $(LINUX_DIR)/drivers/mmc/card/mmc_block.ko
+ AUTOLOAD:=$(call AutoLoad,90,mmc_core mmc_block,1)
+endef
+
+define KernelPackage/mmc/description
+ Kernel support for MMC/SD cards
+endef
+
+$(eval $(call KernelPackage,mmc))
+
+
+define KernelPackage/oprofile
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=OProfile profiling support
+ KCONFIG:=CONFIG_OPROFILE
+ FILES:=$(LINUX_DIR)/arch/$(LINUX_KARCH)/oprofile/oprofile.ko
+ DEPENDS:=@KERNEL_PROFILING
+endef
+
+define KernelPackage/oprofile/description
+ Kernel module for support for oprofile system profiling.
+endef
+
+$(eval $(call KernelPackage,oprofile))
+
+
+define KernelPackage/rfkill
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=RF switch subsystem support
+ KCONFIG:= \
+ CONFIG_RFKILL \
+ CONFIG_RFKILL_INPUT=y \
+ CONFIG_RFKILL_LEDS=y \
+ CONFIG_RFKILL_GPIO=y
+ FILES:= \
+ $(LINUX_DIR)/net/rfkill/rfkill.ko
+ AUTOLOAD:=$(call AutoLoad,20,rfkill)
+ $(call SetDepends/rfkill)
+endef
+
+define KernelPackage/rfkill/description
+ Say Y here if you want to have control over RF switches
+ found on many WiFi and Bluetooth cards.
+endef
+
+$(eval $(call KernelPackage,rfkill))
+
+
+define KernelPackage/softdog
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=Software watchdog driver
+ KCONFIG:=CONFIG_SOFT_WATCHDOG
+ FILES:=$(LINUX_DIR)/drivers/$(WATCHDOG_DIR)/softdog.ko
+ AUTOLOAD:=$(call AutoLoad,50,softdog)
+endef
+
+define KernelPackage/softdog/description
+ Software watchdog driver
+endef
+
+$(eval $(call KernelPackage,softdog))
+
+
+define KernelPackage/ssb
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=Silicon Sonics Backplane glue code
+ DEPENDS:=@PCI_SUPPORT @!TARGET_brcm47xx @!TARGET_brcm63xx
+ KCONFIG:=\
+ CONFIG_SSB \
+ CONFIG_SSB_B43_PCI_BRIDGE=y \
+ CONFIG_SSB_DRIVER_MIPS=n \
+ CONFIG_SSB_DRIVER_PCICORE=y \
+ CONFIG_SSB_DRIVER_PCICORE_POSSIBLE=y \
+ CONFIG_SSB_PCIHOST=y \
+ CONFIG_SSB_PCIHOST_POSSIBLE=y \
+ CONFIG_SSB_POSSIBLE=y \
+ CONFIG_SSB_SPROM=y \
+ CONFIG_SSB_SILENT=y
+ FILES:=$(LINUX_DIR)/drivers/ssb/ssb.ko
+ AUTOLOAD:=$(call AutoLoad,29,ssb)
+endef
+
+define KernelPackage/ssb/description
+ Silicon Sonics Backplane glue code.
+endef
+
+$(eval $(call KernelPackage,ssb))
+
+
+define KernelPackage/bcma
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=BCMA support
+ DEPENDS:=@PCI_SUPPORT @!TARGET_brcm47xx
+ KCONFIG:=\
+ CONFIG_BCMA \
+ CONFIG_BCMA_POSSIBLE=y \
+ CONFIG_BCMA_BLOCKIO=y \
+ CONFIG_BCMA_HOST_PCI_POSSIBLE=y \
+ CONFIG_BCMA_HOST_PCI=y \
+ CONFIG_BCMA_DRIVER_MIPS=n \
+ CONFIG_BCMA_DRIVER_PCI_HOSTMODE=n \
+ CONFIG_BCMA_DRIVER_GMAC_CMN=n \
+ CONFIG_BCMA_DEBUG=n
+ FILES:=$(LINUX_DIR)/drivers/bcma/bcma.ko
+ AUTOLOAD:=$(call AutoLoad,29,bcma)
+endef
+
+define KernelPackage/bcma/description
+ Bus driver for Broadcom specific Advanced Microcontroller Bus Architecture.
+endef
+
+$(eval $(call KernelPackage,bcma))
+
+
+define KernelPackage/wdt-omap
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=OMAP Watchdog timer
+ DEPENDS:=@(TARGET_omap24xx||TARGET_omap35xx)
+ KCONFIG:=CONFIG_OMAP_WATCHDOG
+ FILES:=$(LINUX_DIR)/drivers/$(WATCHDOG_DIR)/omap_wdt.ko
+ AUTOLOAD:=$(call AutoLoad,50,omap_wdt.ko)
+endef
+
+define KernelPackage/wdt-omap/description
+ Kernel module for TI omap watchdog timer.
+endef
+
+$(eval $(call KernelPackage,wdt-omap))
+
+
+define KernelPackage/wdt-orion
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=Marvell Orion Watchdog timer
+ DEPENDS:=@TARGET_orion||TARGET_kirkwood||TARGET_mvebu
+ KCONFIG:=CONFIG_ORION_WATCHDOG
+ FILES:=$(LINUX_DIR)/drivers/$(WATCHDOG_DIR)/orion_wdt.ko
+ AUTOLOAD:=$(call AutoLoad,50,orion_wdt)
+endef
+
+define KernelPackage/wdt-orion/description
+ Kernel module for Marvell Orion, Kirkwood and Armada XP/370 watchdog timer.
+endef
+
+$(eval $(call KernelPackage,wdt-orion))
+
+
+define KernelPackage/booke-wdt
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=PowerPC Book-E Watchdog Timer
+ DEPENDS:=@(TARGET_mpc85xx||TARGET_ppc40x||TARGET_ppc44x)
+ KCONFIG:=CONFIG_BOOKE_WDT
+ FILES:=$(LINUX_DIR)/drivers/$(WATCHDOG_DIR)/booke_wdt.ko
+ AUTOLOAD:=$(call AutoLoad,50,booke_wdt)
+endef
+
+define KernelPackage/booke-wdt/description
+ Kernel module for PowerPC Book-E Watchdog Timer.
+endef
+
+$(eval $(call KernelPackage,booke-wdt))
+
+
+define KernelPackage/pwm
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=PWM generic API
+ KCONFIG:=CONFIG_GENERIC_PWM
+ FILES:=$(LINUX_DIR)/drivers/pwm/pwm.ko
+ AUTOLOAD:=$(call AutoLoad,50,pwm)
+endef
+
+define KernelPackage/pwm/description
+ Kernel module that implement a generic PWM API
+endef
+
+$(eval $(call KernelPackage,pwm))
+
+
+define KernelPackage/pwm-gpio
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=PWM over GPIO
+ DEPENDS:=+kmod-pwm
+ KCONFIG:=CONFIG_GPIO_PWM
+ FILES:=$(LINUX_DIR)/drivers/pwm/gpio-pwm.ko
+ AUTOLOAD:=$(call AutoLoad,51,gpio-pwm)
+endef
+
+define KernelPackage/pwm-gpio/description
+ Kernel module to models a single-channel PWM device using a timer and a GPIO pin
+endef
+
+$(eval $(call KernelPackage,pwm-gpio))
+
+
+define KernelPackage/rtc-isl1208
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=Intersil ISL1208 RTC support
+ $(call AddDepends/rtc)
+ DEPENDS+=+kmod-i2c-core
+ KCONFIG:=CONFIG_RTC_DRV_ISL1208
+ FILES:=$(LINUX_DIR)/drivers/rtc/rtc-isl1208.ko
+ AUTOLOAD:=$(call AutoLoad,60,rtc-isl1208)
+endef
+
+define KernelPackage/rtc-isl1208/description
+ Kernel module for Intersil ISL1208 RTC.
+endef
+
+$(eval $(call KernelPackage,rtc-isl1208))
+
+
+define KernelPackage/rtc-marvell
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=Marvell SoC built-in RTC support
+ $(call AddDepends/rtc)
+ DEPENDS+=@TARGET_kirkwood||TARGET_orion||TARGET_mvebu
+ KCONFIG:=CONFIG_RTC_DRV_MV
+ FILES:=$(LINUX_DIR)/drivers/rtc/rtc-mv.ko
+ AUTOLOAD:=$(call AutoLoad,60,rtc-mv)
+endef
+
+define KernelPackage/rtc-marvell/description
+ Kernel module for Marvell SoC built-in RTC.
+endef
+
+$(eval $(call KernelPackage,rtc-marvell))
+
+define KernelPackage/rtc-pcf8563
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=Philips PCF8563/Epson RTC8564 RTC support
+ $(call AddDepends/rtc)
+ KCONFIG:=CONFIG_RTC_DRV_PCF8563
+ FILES:=$(LINUX_DIR)/drivers/rtc/rtc-pcf8563.ko
+ AUTOLOAD:=$(call AutoLoad,60,rtc-pcf8563)
+endef
+
+define KernelPackage/rtc-pcf8563/description
+ Kernel module for Philips PCF8563 RTC chip.
+ The Epson RTC8564 should work as well.
+endef
+
+$(eval $(call KernelPackage,rtc-pcf8563))
+
+
+define KernelPackage/rtc-pcf2123
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=Philips PCF2123 RTC support
+ $(call AddDepends/rtc)
+ KCONFIG:=CONFIG_RTC_DRV_PCF2123
+ FILES:=$(LINUX_DIR)/drivers/rtc/rtc-pcf2123.ko
+ AUTOLOAD:=$(call AutoLoad,60,rtc-pcf2123)
+endef
+
+define KernelPackage/rtc-pcf2123/description
+ Kernel module for Philips PCF2123 RTC chip.
+endef
+
+$(eval $(call KernelPackage,rtc-pcf2123))
+
+define KernelPackage/rtc-pt7c4338
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=Pericom PT7C4338 RTC support
+ $(call AddDepends/rtc,+kmod-i2c-core)
+ KCONFIG:=CONFIG_RTC_DRV_PT7C4338
+ FILES:=$(LINUX_DIR)/drivers/rtc/rtc-pt7c4338.ko
+ AUTOLOAD:=$(call AutoLoad,60,rtc-pt7c4338)
+endef
+
+define KernelPackage/rtc-pt7c4338/description
+ Kernel module for Pericom PT7C4338 i2c RTC chip.
+endef
+
+$(eval $(call KernelPackage,rtc-pt7c4338))
+
+
+define KernelPackage/mtdtests
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=MTD subsystem tests
+ KCONFIG:=CONFIG_MTD_TESTS
+ FILES:=\
+ $(LINUX_DIR)/drivers/mtd/tests/mtd_nandecctest.ko \
+ $(LINUX_DIR)/drivers/mtd/tests/mtd_oobtest.ko \
+ $(LINUX_DIR)/drivers/mtd/tests/mtd_pagetest.ko \
+ $(LINUX_DIR)/drivers/mtd/tests/mtd_readtest.ko \
+ $(LINUX_DIR)/drivers/mtd/tests/mtd_speedtest.ko \
+ $(LINUX_DIR)/drivers/mtd/tests/mtd_stresstest.ko \
+ $(LINUX_DIR)/drivers/mtd/tests/mtd_subpagetest.ko \
+ $(LINUX_DIR)/drivers/mtd/tests/mtd_torturetest.ko
+endef
+
+define KernelPackage/mtdtests/description
+ Kernel modules for MTD subsystem/driver testing.
+endef
+
+$(eval $(call KernelPackage,mtdtests))
+
+
+define KernelPackage/nand
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=NAND flash support
+ KCONFIG:=CONFIG_MTD_NAND \
+ CONFIG_MTD_NAND_IDS \
+ CONFIG_MTD_NAND_ECC
+ FILES:= \
+ $(LINUX_DIR)/drivers/mtd/nand/nand_ids.ko \
+ $(LINUX_DIR)/drivers/mtd/nand/nand_ecc.ko \
+ $(LINUX_DIR)/drivers/mtd/nand/nand.ko
+ AUTOLOAD:=$(call AutoLoad,20,nand_ids nand_ecc nand)
+endef
+
+define KernelPackage/nand/description
+ Kernel module for NAND support.
+endef
+
+$(eval $(call KernelPackage,nand))
+
+
+define KernelPackage/nandsim
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=NAND simulator
+ DEPENDS:=+kmod-nand
+ KCONFIG:=CONFIG_MTD_NAND_NANDSIM
+ FILES:=$(LINUX_DIR)/drivers/mtd/nand/nandsim.ko
+endef
+
+define KernelPackage/nandsim/description
+ Kernel module for NAND flash simulation.
+endef
+
+$(eval $(call KernelPackage,nandsim))
+
+define KernelPackage/serial-8250
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=8250 UARTs
+ KCONFIG:= CONFIG_SERIAL_8250 \
+ CONFIG_SERIAL_8250_NR_UARTS=16 \
+ CONFIG_SERIAL_8250_RUNTIME_UARTS=16 \
+ CONFIG_SERIAL_8250_EXTENDED=y \
+ CONFIG_SERIAL_8250_MANY_PORTS=y \
+ CONFIG_SERIAL_8250_SHARE_IRQ=y \
+ CONFIG_SERIAL_8250_DETECT_IRQ=n \
+ CONFIG_SERIAL_8250_RSA=n
+ FILES:=$(LINUX_DIR)/drivers/tty/serial/8250/8250$(if $(call kernel_patchver_ge,3.7),_core).ko
+endef
+
+define KernelPackage/serial-8250/description
+ Kernel module for 8250 UART based serial ports.
+endef
+
+$(eval $(call KernelPackage,serial-8250))
+
+
+define KernelPackage/regmap
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=Generic register map support
+ DEPENDS:=+kmod-lib-lzo +kmod-i2c-core
+ KCONFIG:=CONFIG_REGMAP \
+ CONFIG_REGMAP_SPI \
+ CONFIG_REGMAP_I2C \
+ CONFIG_SPI=y
+ FILES:= \
+ $(LINUX_DIR)/drivers/base/regmap/regmap-core.ko \
+ $(LINUX_DIR)/drivers/base/regmap/regmap-i2c.ko \
+ $(LINUX_DIR)/drivers/base/regmap/regmap-spi.ko
+ AUTOLOAD:=$(call AutoLoad,10,regmap-core regmap-i2c regmap-spi)
+endef
+
+define KernelPackage/regmap/description
+ Generic register map support
+endef
+
+$(eval $(call KernelPackage,regmap))
+
+define KernelPackage/ikconfig
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=Kernel configuration via /proc/config.gz
+ KCONFIG:=CONFIG_IKCONFIG \
+ CONFIG_IKCONFIG_PROC=y
+ FILES:=$(LINUX_DIR)/kernel/configs.ko
+ AUTOLOAD:=$(call AutoLoad,70,configs)
+endef
+
+define KernelPackage/ikconfig/description
+ Kernel configuration via /proc/config.gz
+endef
+
+$(eval $(call KernelPackage,ikconfig))
+
+
+define KernelPackage/zram
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=ZRAM
+ DEPENDS:=@!LINUX_3_3 +kmod-lib-lzo
+ KCONFIG:= \
+ CONFIG_ZSMALLOC \
+ CONFIG_ZRAM \
+ CONFIG_ZRAM_DEBUG=n
+ FILES:= \
+ $(LINUX_DIR)/drivers/staging/zsmalloc/zsmalloc.ko \
+ $(LINUX_DIR)/drivers/staging/zram/zram.ko
+ AUTOLOAD:=$(call AutoLoad,20,zsmalloc zram)
+endef
+
+define KernelPackage/zram/description
+ Compressed RAM block device support
+endef
+
+$(eval $(call KernelPackage,zram))
+
+
+define KernelPackage/mvsdio
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=Marvell SDIO support
+ DEPENDS:=@TARGET_orion||TARGET_kirkwood||TARGET_mvebu +kmod-mmc
+ KCONFIG:=CONFIG_MMC_MVSDIO
+ FILES:=$(LINUX_DIR)/drivers/mmc/host/mvsdio.ko
+ AUTOLOAD:=$(call AutoLoad,91,mvsdio)
+endef
+
+define KernelPacakge/mvsdio/description
+ Kernel support for the Marvell SDIO controller
+endef
+
+$(eval $(call KernelPackage,mvsdio))
+
+
+define KernelPackage/pps
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=PPS support
+ KCONFIG:=CONFIG_PPS
+ FILES:=$(LINUX_DIR)/drivers/pps/pps_core.ko
+ AUTOLOAD:=$(call AutoLoad,20,pps_core)
+endef
+
+define KernelPacakge/pps/description
+ PPS (Pulse Per Second) is a special pulse provided by some GPS
+ antennae. Userland can use it to get a high-precision time
+ reference.
+endef
+
+$(eval $(call KernelPackage,pps))
+
+
+define KernelPackage/ptp
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=PTP clock support
+ DEPENDS:=+kmod-pps
+ KCONFIG:=CONFIG_PTP_1588_CLOCK
+ FILES:=$(LINUX_DIR)/drivers/ptp/ptp.ko
+ AUTOLOAD:=$(call AutoLoad,25,ptp)
+endef
+
+define KernelPacakge/ptp/description
+ The IEEE 1588 standard defines a method to precisely
+ synchronize distributed clocks over Ethernet networks.
+endef
+
+$(eval $(call KernelPackage,ptp))
+
+
+define KernelPackage/ptp-gianfar
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=Freescale Gianfar PTP support
+ DEPENDS:=@TARGET_mpc85xx +kmod-gianfar +kmod-ptp
+ KCONFIG:=CONFIG_PTP_1588_CLOCK_GIANFAR
+ FILES:=$(LINUX_DIR)/drivers/net/ethernet/freescale/gianfar_ptp.ko
+ AUTOLOAD:=$(call AutoLoad,51,gianfar_ptp)
+endef
+
+define KernelPacakge/ptp-gianfar/description
+ Kernel module for IEEE 1588 support for Freescale
+ Gianfar Ethernet drivers.
+endef
+
+$(eval $(call KernelPackage,ptp-gianfar))
diff --git a/package/kernel/modules/pcmcia.mk b/package/kernel/modules/pcmcia.mk
new file mode 100644
index 0000000..cac7277
--- /dev/null
+++ b/package/kernel/modules/pcmcia.mk
@@ -0,0 +1,80 @@
+#
+# Copyright (C) 2006-2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+PCMCIA_MENU:=PCMCIA support
+
+define KernelPackage/pcmcia-core
+ SUBMENU:=$(PCMCIA_MENU)
+ TITLE:=PCMCIA/CardBus support
+ DEPENDS:=@PCMCIA_SUPPORT
+ KCONFIG:= \
+ CONFIG_PCMCIA \
+ CONFIG_CARDBUS \
+ CONFIG_PCCARD \
+ PCMCIA_DEBUG=n
+ FILES:= \
+ $(LINUX_DIR)/drivers/pcmcia/pcmcia_core.ko \
+ $(LINUX_DIR)/drivers/pcmcia/pcmcia.ko
+ AUTOLOAD:=$(call AutoLoad,25,pcmcia_core pcmcia)
+endef
+
+define KernelPackage/pcmcia-core/description
+ Kernel support for PCMCIA/CardBus controllers
+endef
+
+$(eval $(call KernelPackage,pcmcia-core))
+
+define KernelPackage/pcmcia-rsrc
+ SUBMENU:=$(PCMCIA_MENU)
+ TITLE:=PCMCIA resource support
+ DEPENDS:=kmod-pcmcia-core
+ KCONFIG:=CONFIG_PCCARD_NONSTATIC=y
+# For Linux 2.6.35+
+ifneq ($(wildcard $(LINUX_DIR)/drivers/pcmcia/pcmcia_rsrc.ko),)
+ FILES:=$(LINUX_DIR)/drivers/pcmcia/pcmcia_rsrc.ko
+ AUTOLOAD:=$(call AutoLoad,26,pcmcia_rsrc)
+else
+ FILES:=$(LINUX_DIR)/drivers/pcmcia/rsrc_nonstatic.ko
+ AUTOLOAD:=$(call AutoLoad,26,rsrc_nonstatic)
+endif
+endef
+
+define KernelPackage/pcmcia-rsrc/description
+ Kernel support for PCMCIA resource allocation
+endef
+
+$(eval $(call KernelPackage,pcmcia-rsrc))
+
+
+define KernelPackage/pcmcia-yenta
+ SUBMENU:=$(PCMCIA_MENU)
+ TITLE:=yenta socket driver
+ DEPENDS:=kmod-pcmcia-rsrc
+ KCONFIG:=CONFIG_YENTA
+ FILES:=$(LINUX_DIR)/drivers/pcmcia/yenta_socket.ko
+ AUTOLOAD:=$(call AutoLoad,41,pcmcia_rsrc yenta_socket)
+endef
+
+$(eval $(call KernelPackage,pcmcia-yenta))
+
+
+define KernelPackage/pcmcia-serial
+ SUBMENU:=$(PCMCIA_MENU)
+ TITLE:=Serial devices support
+ DEPENDS:=kmod-pcmcia-core
+ KCONFIG:= \
+ CONFIG_PCMCIA_SERIAL_CS \
+ CONFIG_SERIAL_8250_CS
+ FILES:=$(LINUX_DIR)/drivers/tty/serial/8250/serial_cs.ko
+ AUTOLOAD:=$(call AutoLoad,45,serial_cs)
+endef
+
+define KernelPackage/pcmcia-serial/description
+ Kernel support for PCMCIA/CardBus serial devices
+endef
+
+$(eval $(call KernelPackage,pcmcia-serial))
diff --git a/package/kernel/modules/sound.mk b/package/kernel/modules/sound.mk
new file mode 100644
index 0000000..877d31b
--- /dev/null
+++ b/package/kernel/modules/sound.mk
@@ -0,0 +1,211 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+SOUND_MENU:=Sound Support
+
+# allow targets to override the soundcore stuff
+SOUNDCORE_LOAD ?= \
+ soundcore \
+ snd \
+ snd-page-alloc \
+ snd-hwdep \
+ snd-seq-device \
+ snd-rawmidi \
+ snd-timer \
+ snd-pcm \
+ snd-mixer-oss \
+ snd-pcm-oss
+
+SOUNDCORE_FILES ?= \
+ $(LINUX_DIR)/sound/soundcore.ko \
+ $(LINUX_DIR)/sound/core/snd.ko \
+ $(LINUX_DIR)/sound/core/snd-page-alloc.ko \
+ $(LINUX_DIR)/sound/core/snd-hwdep.ko \
+ $(LINUX_DIR)/sound/core/seq/snd-seq-device.ko \
+ $(LINUX_DIR)/sound/core/snd-rawmidi.ko \
+ $(LINUX_DIR)/sound/core/snd-timer.ko \
+ $(LINUX_DIR)/sound/core/snd-pcm.ko \
+ $(LINUX_DIR)/sound/core/oss/snd-mixer-oss.ko \
+ $(LINUX_DIR)/sound/core/oss/snd-pcm-oss.ko
+
+define KernelPackage/sound-core
+ SUBMENU:=$(SOUND_MENU)
+ TITLE:=Sound support
+ DEPENDS:=@AUDIO_SUPPORT
+ KCONFIG:= \
+ CONFIG_SOUND \
+ CONFIG_SND \
+ CONFIG_SND_HWDEP \
+ CONFIG_SND_RAWMIDI \
+ CONFIG_SND_TIMER \
+ CONFIG_SND_PCM \
+ CONFIG_SND_SEQUENCER \
+ CONFIG_SND_VIRMIDI \
+ CONFIG_SND_SEQ_DUMMY \
+ CONFIG_SND_SEQUENCER_OSS=y \
+ CONFIG_HOSTAUDIO \
+ CONFIG_SND_PCM_OSS \
+ CONFIG_SND_MIXER_OSS \
+ CONFIG_SOUND_OSS_CORE_PRECLAIM=y
+ FILES:=$(SOUNDCORE_FILES)
+ AUTOLOAD:=$(call AutoLoad,30,$(SOUNDCORE_LOAD))
+ $(call AddDepends/input)
+endef
+
+define KernelPackage/sound-core/uml
+ FILES:= \
+ $(LINUX_DIR)/sound/soundcore.ko \
+ $(LINUX_DIR)/arch/um/drivers/hostaudio.ko
+ AUTOLOAD:=$(call AutoLoad,30,soundcore hostaudio)
+endef
+
+define KernelPackage/sound-core/description
+ Kernel modules for sound support
+endef
+
+$(eval $(call KernelPackage,sound-core))
+
+
+define AddDepends/sound
+ SUBMENU:=$(SOUND_MENU)
+ DEPENDS+=kmod-sound-core $(1) @!TARGET_uml
+endef
+
+
+define KernelPackage/ac97
+ TITLE:=ac97 controller
+ KCONFIG:=CONFIG_SND_AC97_CODEC
+ FILES:= \
+ $(LINUX_DIR)/sound/ac97_bus.ko \
+ $(LINUX_DIR)/sound/pci/ac97/snd-ac97-codec.ko
+ AUTOLOAD:=$(call AutoLoad,35,ac97_bus snd-ac97-codec)
+ $(call AddDepends/sound)
+endef
+
+define KernelPackage/ac97/description
+ The ac97 controller
+endef
+
+$(eval $(call KernelPackage,ac97))
+
+
+define KernelPackage/sound-seq
+ TITLE:=Sequencer support
+ FILES:= \
+ $(LINUX_DIR)/sound/core/seq/snd-seq.ko \
+ $(LINUX_DIR)/sound/core/seq/snd-seq-midi-event.ko \
+ $(LINUX_DIR)/sound/core/seq/snd-seq-midi.ko
+ AUTOLOAD:=$(call AutoLoad,35,snd-seq snd-seq-midi-event snd-seq-midi)
+ $(call AddDepends/sound)
+endef
+
+define KernelPackage/sound-seq/description
+ Kernel modules for sequencer support
+endef
+
+$(eval $(call KernelPackage,sound-seq))
+
+
+define KernelPackage/sound-i8x0
+ TITLE:=Intel/SiS/nVidia/AMD/ALi AC97 Controller
+ DEPENDS:=+kmod-ac97
+ KCONFIG:=CONFIG_SND_INTEL8X0
+ FILES:=$(LINUX_DIR)/sound/pci/snd-intel8x0.ko
+ AUTOLOAD:=$(call AutoLoad,36,snd-intel8x0)
+ $(call AddDepends/sound)
+endef
+
+define KernelPackage/sound-i8x0/description
+ support for the integrated AC97 sound device on motherboards
+ with Intel/SiS/nVidia/AMD chipsets, or ALi chipsets using
+ the M5455 Audio Controller.
+endef
+
+$(eval $(call KernelPackage,sound-i8x0))
+
+
+define KernelPackage/sound-cs5535audio
+ TITLE:=CS5535 PCI Controller
+ DEPENDS:=+kmod-ac97
+ KCONFIG:=CONFIG_SND_CS5535AUDIO
+ FILES:=$(LINUX_DIR)/sound/pci/cs5535audio/snd-cs5535audio.ko
+ AUTOLOAD:=$(call AutoLoad,36,snd-cs5535audio)
+ $(call AddDepends/sound)
+endef
+
+define KernelPackage/sound-cs5535audio/description
+ support for the integrated AC97 sound device on olpc
+endef
+
+$(eval $(call KernelPackage,sound-cs5535audio))
+
+
+define KernelPackage/sound-soc-core
+ TITLE:=SoC sound support
+ DEPENDS:=+kmod-regmap
+ KCONFIG:= \
+ CONFIG_SND_SOC \
+ CONFIG_SND_SOC_DMAENGINE_PCM=y \
+ CONFIG_SND_SOC_ALL_CODECS=n
+ FILES:=$(LINUX_DIR)/sound/soc/snd-soc-core.ko
+ AUTOLOAD:=$(call AutoLoad,55, snd-soc-core)
+ $(call AddDepends/sound)
+endef
+
+$(eval $(call KernelPackage,sound-soc-core))
+
+
+define KernelPackage/sound-soc-ac97
+ TITLE:=AC97 Codec support
+ KCONFIG:=CONFIG_SND_SOC_AC97_CODEC
+ FILES:=$(LINUX_DIR)/sound/soc/codecs/snd-soc-ac97.ko
+ AUTOLOAD:=$(call AutoLoad,57,snd-soc-ac97)
+ DEPENDS:=+kmod-ac97 +kmod-sound-soc-core
+ $(call AddDepends/sound)
+endef
+
+$(eval $(call KernelPackage,sound-soc-ac97))
+
+
+define KernelPackage/sound-soc-gw_avila
+ TITLE:=Gateworks Avila SoC sound support
+ KCONFIG:= \
+ CONFIG_SND_GW_AVILA_SOC \
+ CONFIG_SND_GW_AVILA_SOC_PCM \
+ CONFIG_SND_GW_AVILA_SOC_HSS
+ FILES:= \
+ $(LINUX_DIR)/sound/soc/codecs/snd-soc-tlv320aic3x.ko \
+ $(LINUX_DIR)/sound/soc/gw-avila/snd-soc-gw-avila.ko \
+ $(LINUX_DIR)/sound/soc/gw-avila/snd-soc-gw-avila-pcm.ko \
+ $(LINUX_DIR)/sound/soc/gw-avila/snd-soc-gw-avila-hss.ko
+ AUTOLOAD:=$(call AutoLoad,65,snd-soc-tlv320aic3x snd-soc-gw-avila snd-soc-gw-avila-pcm snd-soc-gw-avila-hss)
+ DEPENDS:=@TARGET_ixp4xx +kmod-sound-soc-core
+ $(call AddDepends/sound)
+endef
+
+$(eval $(call KernelPackage,sound-soc-gw_avila))
+
+
+define KernelPackage/pcspkr
+ DEPENDS:=@!TARGET_x86
+ TITLE:=PC speaker support
+ KCONFIG:= \
+ CONFIG_INPUT_PCSPKR \
+ CONFIG_SND_PCSP
+ FILES:= \
+ $(LINUX_DIR)/drivers/input/misc/pcspkr.ko \
+ $(LINUX_DIR)/sound/drivers/pcsp/snd-pcsp.ko
+ AUTOLOAD:=$(call AutoLoad,50,pcspkr snd-pcsp)
+ $(call AddDepends/input)
+ $(call AddDepends/sound)
+endef
+
+define KernelPackage/pcspkr/description
+ This enables sounds (tones) through the pc speaker
+endef
+
+$(eval $(call KernelPackage,pcspkr))
diff --git a/package/kernel/modules/spi.mk b/package/kernel/modules/spi.mk
new file mode 100644
index 0000000..4162098
--- /dev/null
+++ b/package/kernel/modules/spi.mk
@@ -0,0 +1,90 @@
+#
+# Copyright (C) 2006-2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+SPI_MENU:=SPI Support
+
+define KernelPackage/mmc-spi
+ SUBMENU:=$(SPI_MENU)
+ TITLE:=MMC/SD over SPI Support
+ DEPENDS:=+kmod-mmc +kmod-lib-crc-itu-t +kmod-lib-crc7
+ KCONFIG:=CONFIG_MMC_SPI \
+ CONFIG_SPI=y \
+ CONFIG_SPI_MASTER=y
+ FILES:=$(LINUX_DIR)/drivers/mmc/host/mmc_spi.ko
+ AUTOLOAD:=$(call AutoLoad,90,mmc_spi)
+endef
+
+define KernelPackage/mmc-spi/description
+ Kernel support for MMC/SD over SPI
+endef
+
+$(eval $(call KernelPackage,mmc-spi))
+
+
+define KernelPackage/spi-bitbang
+ SUBMENU:=$(SPI_MENU)
+ TITLE:=Serial Peripheral Interface bitbanging library
+ KCONFIG:=CONFIG_SPI_BITBANG \
+ CONFIG_SPI=y \
+ CONFIG_SPI_MASTER=y
+ FILES:=$(LINUX_DIR)/drivers/spi/spi-bitbang.ko
+ AUTOLOAD:=$(call AutoLoad,91,spi-bitbang)
+endef
+
+define KernelPackage/spi-bitbang/description
+ This package contains the SPI bitbanging library
+endef
+
+$(eval $(call KernelPackage,spi-bitbang))
+
+
+define KernelPackage/spi-gpio-old
+ SUBMENU:=$(SPI_MENU)
+ TITLE:=Old GPIO based bitbanging SPI controller (DEPRECATED)
+ DEPENDS:=@GPIO_SUPPORT +kmod-spi-bitbang
+ KCONFIG:=CONFIG_SPI_GPIO_OLD
+ FILES:=$(LINUX_DIR)/drivers/spi/spi_gpio_old.ko
+ AUTOLOAD:=$(call AutoLoad,92,spi_gpio_old)
+endef
+
+define KernelPackage/spi-gpio-old/description
+ This package contains the GPIO based bitbanging SPI controller driver
+endef
+
+$(eval $(call KernelPackage,spi-gpio-old))
+
+define KernelPackage/spi-gpio
+ SUBMENU:=$(SPI_MENU)
+ TITLE:=GPIO-based bitbanging SPI Master
+ DEPENDS:=@GPIO_SUPPORT +kmod-spi-bitbang
+ KCONFIG:=CONFIG_SPI_GPIO
+ FILES:=$(LINUX_DIR)/drivers/spi/spi-gpio.ko
+ AUTOLOAD:=$(call AutoLoad,92,spi-gpio)
+endef
+
+define KernelPackage/spi-gpio/description
+ This package contains the GPIO-based bitbanging SPI Master
+endef
+
+$(eval $(call KernelPackage,spi-gpio))
+
+define KernelPackage/spi-dev
+ SUBMENU:=$(SPI_MENU)
+ TITLE:=User mode SPI device driver
+ KCONFIG:=CONFIG_SPI_SPIDEV \
+ CONFIG_SPI=y \
+ CONFIG_SPI_MASTER=y
+ FILES:=$(LINUX_DIR)/drivers/spi/spidev.ko
+ AUTOLOAD:=$(call AutoLoad,93,spidev)
+endef
+
+define KernelPackage/spi-dev/description
+ This package contains the user mode SPI device driver
+endef
+
+$(eval $(call KernelPackage,spi-dev))
+
diff --git a/package/kernel/modules/usb.mk b/package/kernel/modules/usb.mk
new file mode 100644
index 0000000..fa6763c
--- /dev/null
+++ b/package/kernel/modules/usb.mk
@@ -0,0 +1,985 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+USB_MENU:=USB Support
+
+USBNET_DIR:=net/usb
+USBHID_DIR?=hid/usbhid
+USBINPUT_DIR?=input/misc
+
+define KernelPackage/usb-core
+ SUBMENU:=$(USB_MENU)
+ TITLE:=Support for USB
+ DEPENDS:=@USB_SUPPORT
+ KCONFIG:=CONFIG_USB CONFIG_XPS_USB_HCD_XILINX=n CONFIG_USB_FHCI_HCD=n
+ FILES:= \
+ $(LINUX_DIR)/drivers/usb/core/usbcore.ko \
+ $(LINUX_DIR)/drivers/usb/usb-common.ko
+ AUTOLOAD:=$(call AutoLoad,20,usb-common usbcore,1)
+ $(call AddDepends/nls)
+endef
+
+define KernelPackage/usb-core/description
+ Kernel support for USB
+endef
+
+$(eval $(call KernelPackage,usb-core))
+
+
+define AddDepends/usb
+ SUBMENU:=$(USB_MENU)
+ DEPENDS+=+kmod-usb-core $(1)
+endef
+
+
+define KernelPackage/usb-gadget
+ TITLE:=USB Gadget support
+ KCONFIG:=CONFIG_USB_GADGET
+ FILES:=
+ AUTOLOAD:=
+ DEPENDS:=@USB_GADGET_SUPPORT
+ $(call AddDepends/usb)
+endef
+
+define KernelPackage/usb-gadget/description
+ Kernel support for USB Gadget mode.
+endef
+
+$(eval $(call KernelPackage,usb-gadget))
+
+
+define KernelPackage/usb-eth-gadget
+ TITLE:=USB Ethernet Gadget support
+ KCONFIG:= \
+ CONFIG_USB_ETH \
+ CONFIG_USB_ETH_RNDIS=y \
+ CONFIG_USB_ETH_EEM=y
+ DEPENDS:=+kmod-usb-gadget
+ FILES:=$(LINUX_DIR)/drivers/usb/gadget/g_ether.ko
+ AUTOLOAD:=$(call AutoLoad,52,g_ether)
+ $(call AddDepends/usb)
+endef
+
+define KernelPackage/usb-eth-gadget/description
+ Kernel support for USB Ethernet Gadget.
+endef
+
+$(eval $(call KernelPackage,usb-eth-gadget))
+
+
+define KernelPackage/usb-uhci
+ TITLE:=Support for UHCI controllers
+ KCONFIG:= \
+ CONFIG_USB_UHCI_ALT \
+ CONFIG_USB_UHCI_HCD
+ FILES:=$(LINUX_DIR)/drivers/usb/host/uhci-hcd.ko
+ AUTOLOAD:=$(call AutoLoad,50,uhci-hcd,1)
+ $(call AddDepends/usb)
+endef
+
+define KernelPackage/usb-uhci/description
+ Kernel support for USB UHCI controllers
+endef
+
+$(eval $(call KernelPackage,usb-uhci,1))
+
+
+define KernelPackage/usb-ohci
+ TITLE:=Support for OHCI controllers
+ DEPENDS:=+TARGET_brcm47xx:kmod-usb-brcm47xx
+ KCONFIG:= \
+ CONFIG_USB_OHCI \
+ CONFIG_USB_OHCI_HCD \
+ CONFIG_USB_OHCI_ATH79=y \
+ CONFIG_USB_OHCI_BCM63XX=y \
+ CONFIG_USB_OCTEON_OHCI=y \
+ CONFIG_USB_OHCI_HCD_PLATFORM=y
+ FILES:=$(LINUX_DIR)/drivers/usb/host/ohci-hcd.ko
+ AUTOLOAD:=$(call AutoLoad,50,ohci-hcd,1)
+ $(call AddDepends/usb)
+endef
+
+define KernelPackage/usb-ohci/description
+ Kernel support for USB OHCI controllers
+endef
+
+$(eval $(call KernelPackage,usb-ohci,1))
+
+
+define KernelPackage/usb2-fsl
+ TITLE:=Support for Freescale USB2 controllers
+ DEPENDS:=TARGET_mpc85xx
+ KCONFIG:=\
+ CONFIG_USB_FSL_MPH_DR_OF \
+ CONFIG_USB_EHCI_FSL=y
+ FILES:=$(LINUX_DIR)/drivers/usb/host/fsl-mph-dr-of.ko
+ AUTOLOAD:=$(call AutoLoad,39,fsl-mph-dr-of,1)
+ $(call AddDepends/usb)
+endef
+
+define KernelPackage/usb2-fsl/description
+ Kernel support for Freescale USB2 (EHCI) controllers
+endef
+
+$(eval $(call KernelPackage,usb2-fsl))
+
+
+define KernelPackage/usb2
+ TITLE:=Support for USB2 controllers
+ DEPENDS:=+TARGET_brcm47xx:kmod-usb-brcm47xx +TARGET_mpc85xx:kmod-usb2-fsl
+ KCONFIG:=CONFIG_USB_EHCI_HCD \
+ CONFIG_USB_EHCI_ATH79=y \
+ CONFIG_USB_EHCI_BCM63XX=y \
+ CONFIG_USB_OCTEON_EHCI=y \
+ CONFIG_USB_EHCI_HCD_PLATFORM=y
+ifeq ($(strip $(call CompareKernelPatchVer,$(KERNEL_PATCHVER),ge,3.8.0)),1)
+ FILES:= \
+ $(LINUX_DIR)/drivers/usb/host/ehci-hcd.ko \
+ $(LINUX_DIR)/drivers/usb/host/ehci-platform.ko
+ AUTOLOAD:=$(call AutoLoad,40,ehci-hcd ehci-platform,1)
+else
+ FILES:=$(LINUX_DIR)/drivers/usb/host/ehci-hcd.ko
+ AUTOLOAD:=$(call AutoLoad,40,ehci-hcd,1)
+endif
+ $(call AddDepends/usb)
+endef
+
+define KernelPackage/usb2/description
+ Kernel support for USB2 (EHCI) controllers
+endef
+
+$(eval $(call KernelPackage,usb2))
+
+
+define KernelPackage/usb2-pci
+ TITLE:=Support for PCI USB2 controllers
+ DEPENDS:=@PCI_SUPPORT @LINUX_3_8 +kmod-usb2
+ KCONFIG:=CONFIG_USB_EHCI_PCI
+ FILES:=$(LINUX_DIR)/drivers/usb/host/ehci-pci.ko
+ AUTOLOAD:=$(call AutoLoad,42,ehci-pci,1)
+ $(call AddDepends/usb)
+endef
+
+define KernelPackage/usb2-pci/description
+ Kernel support for PCI USB2 (EHCI) controllers
+endef
+
+$(eval $(call KernelPackage,usb2-pci))
+
+
+define KernelPackage/usb-acm
+ TITLE:=Support for modems/isdn controllers
+ KCONFIG:=CONFIG_USB_ACM
+ FILES:=$(LINUX_DIR)/drivers/usb/class/cdc-acm.ko
+ AUTOLOAD:=$(call AutoLoad,60,cdc-acm)
+$(call AddDepends/usb)
+endef
+
+define KernelPackage/usb-acm/description
+ Kernel support for USB ACM devices (modems/isdn controllers)
+endef
+
+$(eval $(call KernelPackage,usb-acm))
+
+
+define KernelPackage/usb-wdm
+ TITLE:=USB Wireless Device Management
+ KCONFIG:=CONFIG_USB_WDM
+ FILES:=$(LINUX_DIR)/drivers/usb/class/cdc-wdm.ko
+ AUTOLOAD:=$(call AutoLoad,60,cdc-wdm)
+$(call AddDepends/usb)
+$(call AddDepends/usb-net)
+endef
+
+define KernelPackage/usb-wdm/description
+ USB Wireless Device Management support
+endef
+
+$(eval $(call KernelPackage,usb-wdm))
+
+
+define KernelPackage/usb-audio
+ TITLE:=Support for USB audio devices
+ KCONFIG:= \
+ CONFIG_USB_AUDIO \
+ CONFIG_SND_USB_AUDIO
+ $(call AddDepends/usb)
+ $(call AddDepends/sound)
+# For Linux 2.6.35+
+ifneq ($(wildcard $(LINUX_DIR)/sound/usb/snd-usbmidi-lib.ko),)
+ FILES:= \
+ $(LINUX_DIR)/sound/usb/snd-usbmidi-lib.ko \
+ $(LINUX_DIR)/sound/usb/snd-usb-audio.ko
+ AUTOLOAD:=$(call AutoLoad,60,snd-usbmidi-lib snd-usb-audio)
+else
+ FILES:= \
+ $(LINUX_DIR)/sound/usb/snd-usb-lib.ko \
+ $(LINUX_DIR)/sound/usb/snd-usb-audio.ko
+ AUTOLOAD:=$(call AutoLoad,60,snd-usb-lib snd-usb-audio)
+endif
+endef
+
+define KernelPackage/usb-audio/description
+ Kernel support for USB audio devices
+endef
+
+$(eval $(call KernelPackage,usb-audio))
+
+
+define KernelPackage/usb-printer
+ TITLE:=Support for printers
+ KCONFIG:=CONFIG_USB_PRINTER
+ FILES:=$(LINUX_DIR)/drivers/usb/class/usblp.ko
+ AUTOLOAD:=$(call AutoLoad,60,usblp)
+ $(call AddDepends/usb)
+endef
+
+define KernelPackage/usb-printer/description
+ Kernel support for USB printers
+endef
+
+$(eval $(call KernelPackage,usb-printer))
+
+
+define KernelPackage/usb-serial
+ TITLE:=Support for USB-to-Serial converters
+ KCONFIG:=CONFIG_USB_SERIAL
+ FILES:=$(LINUX_DIR)/drivers/usb/serial/usbserial.ko
+ AUTOLOAD:=$(call AutoLoad,60,usbserial)
+ $(call AddDepends/usb)
+endef
+
+define KernelPackage/usb-serial/description
+ Kernel support for USB-to-Serial converters
+endef
+
+$(eval $(call KernelPackage,usb-serial))
+
+
+define AddDepends/usb-serial
+ SUBMENU:=$(USB_MENU)
+ DEPENDS+=kmod-usb-serial $(1)
+endef
+
+
+define KernelPackage/usb-serial-belkin
+ TITLE:=Support for Belkin devices
+ KCONFIG:=CONFIG_USB_SERIAL_BELKIN
+ FILES:=$(LINUX_DIR)/drivers/usb/serial/belkin_sa.ko
+ AUTOLOAD:=$(call AutoLoad,65,belkin_sa)
+ $(call AddDepends/usb-serial)
+endef
+
+define KernelPackage/usb-serial-belkin/description
+ Kernel support for Belkin USB-to-Serial converters
+endef
+
+$(eval $(call KernelPackage,usb-serial-belkin))
+
+
+define KernelPackage/usb-serial-ch341
+ TITLE:=Support for CH341 devices
+ KCONFIG:=CONFIG_USB_SERIAL_CH341
+ FILES:=$(LINUX_DIR)/drivers/usb/serial/ch341.ko
+ AUTOLOAD:=$(call AutoLoad,65,ch341)
+ $(call AddDepends/usb-serial)
+endef
+
+define KernelPackage/usb-serial-ch341/description
+ Kernel support for Winchiphead CH341 USB-to-Serial converters
+endef
+
+$(eval $(call KernelPackage,usb-serial-ch341))
+
+
+define KernelPackage/usb-serial-ftdi
+ TITLE:=Support for FTDI devices
+ KCONFIG:=CONFIG_USB_SERIAL_FTDI_SIO
+ FILES:=$(LINUX_DIR)/drivers/usb/serial/ftdi_sio.ko
+ AUTOLOAD:=$(call AutoLoad,65,ftdi_sio)
+ $(call AddDepends/usb-serial)
+endef
+
+define KernelPackage/usb-serial-ftdi/description
+ Kernel support for FTDI USB-to-Serial converters
+endef
+
+$(eval $(call KernelPackage,usb-serial-ftdi))
+
+
+define KernelPackage/usb-serial-ti-usb
+ TITLE:=Support for TI USB 3410/5052
+ KCONFIG:=CONFIG_USB_SERIAL_TI
+ FILES:=$(LINUX_DIR)/drivers/usb/serial/ti_usb_3410_5052.ko
+ AUTOLOAD:=$(call AutoLoad,65,ti_usb_3410_5052)
+ $(call AddDepends/usb-serial)
+endef
+
+define KernelPackage/usb-serial-ti-usb/description
+ Kernel support for TI USB 3410/5052 devices
+endef
+
+$(eval $(call KernelPackage,usb-serial-ti-usb))
+
+
+define KernelPackage/usb-serial-ipw
+ TITLE:=Support for IPWireless 3G devices
+ KCONFIG:=CONFIG_USB_SERIAL_IPW
+ FILES:=$(LINUX_DIR)/drivers/usb/serial/ipw.ko
+ AUTOLOAD:=$(call AutoLoad,65,ipw)
+ $(call AddDepends/usb-serial)
+endef
+
+$(eval $(call KernelPackage,usb-serial-ipw))
+
+
+define KernelPackage/usb-serial-mct
+ TITLE:=Support for Magic Control Tech. devices
+ KCONFIG:=CONFIG_USB_SERIAL_MCT_U232
+ FILES:=$(LINUX_DIR)/drivers/usb/serial/mct_u232.ko
+ AUTOLOAD:=$(call AutoLoad,65,mct_u232)
+ $(call AddDepends/usb-serial)
+endef
+
+define KernelPackage/usb-serial-mct/description
+ Kernel support for Magic Control Technology USB-to-Serial converters
+endef
+
+$(eval $(call KernelPackage,usb-serial-mct))
+
+
+define KernelPackage/usb-serial-mos7720
+ TITLE:=Support for Moschip MOS7720 devices
+ KCONFIG:=CONFIG_USB_SERIAL_MOS7720
+ FILES:=$(LINUX_DIR)/drivers/usb/serial/mos7720.ko
+ AUTOLOAD:=$(call AutoLoad,65,mos7720)
+ $(call AddDepends/usb-serial)
+endef
+
+define KernelPackage/usb-serial-mos7720/description
+ Kernel support for Moschip MOS7720 USB-to-Serial converters
+endef
+
+$(eval $(call KernelPackage,usb-serial-mos7720))
+
+
+define KernelPackage/usb-serial-pl2303
+ TITLE:=Support for Prolific PL2303 devices
+ KCONFIG:=CONFIG_USB_SERIAL_PL2303
+ FILES:=$(LINUX_DIR)/drivers/usb/serial/pl2303.ko
+ AUTOLOAD:=$(call AutoLoad,65,pl2303)
+ $(call AddDepends/usb-serial)
+endef
+
+define KernelPackage/usb-serial-pl2303/description
+ Kernel support for Prolific PL2303 USB-to-Serial converters
+endef
+
+$(eval $(call KernelPackage,usb-serial-pl2303))
+
+
+define KernelPackage/usb-serial-cp210x
+ TITLE:=Support for Silicon Labs cp210x devices
+ KCONFIG:=CONFIG_USB_SERIAL_CP210X
+ FILES:=$(LINUX_DIR)/drivers/usb/serial/cp210x.ko
+ AUTOLOAD:=$(call AutoLoad,65,cp210x)
+ $(call AddDepends/usb-serial)
+endef
+
+define KernelPackage/usb-serial-cp210x/description
+ Kernel support for Silicon Labs cp210x USB-to-Serial converters
+endef
+
+$(eval $(call KernelPackage,usb-serial-cp210x))
+
+
+define KernelPackage/usb-serial-ark3116
+ TITLE:=Support for ArkMicroChips ARK3116 devices
+ KCONFIG:=CONFIG_USB_SERIAL_ARK3116
+ FILES:=$(LINUX_DIR)/drivers/usb/serial/ark3116.ko
+ AUTOLOAD:=$(call AutoLoad,65,ark3116)
+ $(call AddDepends/usb-serial)
+endef
+
+define KernelPackage/usb-serial-ark3116/description
+ Kernel support for ArkMicroChips ARK3116 USB-to-Serial converters
+endef
+
+$(eval $(call KernelPackage,usb-serial-ark3116))
+
+
+define KernelPackage/usb-serial-oti6858
+ TITLE:=Support for Ours Technology OTI6858 devices
+ KCONFIG:=CONFIG_USB_SERIAL_OTI6858
+ FILES:=$(LINUX_DIR)/drivers/usb/serial/oti6858.ko
+ AUTOLOAD:=$(call AutoLoad,65,oti6858)
+ $(call AddDepends/usb-serial)
+endef
+
+define KernelPackage/usb-serial-oti6858/description
+ Kernel support for Ours Technology OTI6858 USB-to-Serial converters
+endef
+
+$(eval $(call KernelPackage,usb-serial-oti6858))
+
+
+define KernelPackage/usb-serial-sierrawireless
+ TITLE:=Support for Sierra Wireless devices
+ KCONFIG:=CONFIG_USB_SERIAL_SIERRAWIRELESS
+ FILES:=$(LINUX_DIR)/drivers/usb/serial/sierra.ko
+ AUTOLOAD:=$(call AutoLoad,65,sierra)
+ $(call AddDepends/usb-serial)
+endef
+
+define KernelPackage/usb-serial-sierrawireless/description
+ Kernel support for Sierra Wireless devices
+endef
+
+$(eval $(call KernelPackage,usb-serial-sierrawireless))
+
+
+define KernelPackage/usb-serial-motorola-phone
+ TITLE:=Support for Motorola usb phone
+ KCONFIG:=CONFIG_USB_SERIAL_MOTOROLA
+ FILES:=$(LINUX_DIR)/drivers/usb/serial/moto_modem.ko
+ AUTOLOAD:=$(call AutoLoad,65,moto_modem)
+ $(call AddDepends/usb-serial)
+endef
+
+define KernelPackage/usb-serial-motorola-phone/description
+ Kernel support for Motorola usb phone
+endef
+
+$(eval $(call KernelPackage,usb-serial-motorola-phone))
+
+
+define KernelPackage/usb-serial-visor
+ TITLE:=Support for Handspring Visor devices
+ KCONFIG:=CONFIG_USB_SERIAL_VISOR
+ FILES:=$(LINUX_DIR)/drivers/usb/serial/visor.ko
+ AUTOLOAD:=$(call AutoLoad,65,visor)
+ $(call AddDepends/usb-serial)
+endef
+
+define KernelPackage/usb-serial-visor/description
+ Kernel support for Handspring Visor PDAs
+endef
+
+$(eval $(call KernelPackage,usb-serial-visor))
+
+
+define KernelPackage/usb-serial-cypress-m8
+ TITLE:=Support for CypressM8 USB-Serial
+ KCONFIG:=CONFIG_USB_SERIAL_CYPRESS_M8
+ FILES:=$(LINUX_DIR)/drivers/usb/serial/cypress_m8.ko
+ AUTOLOAD:=$(call AutoLoad,65,cypress_m8)
+ $(call AddDepends/usb-serial)
+endef
+
+define KernelPackage/usb-serial-cypress-m8/description
+ Kernel support for devices with Cypress M8 USB to Serial chip
+ (for example, the Delorme Earthmate LT-20 GPS)
+ Supported microcontrollers in the CY4601 family are:
+ CY7C63741 CY7C63742 CY7C63743 CY7C64013
+endef
+
+$(eval $(call KernelPackage,usb-serial-cypress-m8))
+
+
+define KernelPackage/usb-serial-keyspan
+ TITLE:=Support for Keyspan USB-to-Serial devices
+ KCONFIG:= \
+ CONFIG_USB_SERIAL_KEYSPAN \
+ CONFIG_USB_SERIAL_KEYSPAN_USA28 \
+ CONFIG_USB_SERIAL_KEYSPAN_USA28X \
+ CONFIG_USB_SERIAL_KEYSPAN_USA28XA \
+ CONFIG_USB_SERIAL_KEYSPAN_USA28XB \
+ CONFIG_USB_SERIAL_KEYSPAN_USA19 \
+ CONFIG_USB_SERIAL_KEYSPAN_USA18X \
+ CONFIG_USB_SERIAL_KEYSPAN_USA19W \
+ CONFIG_USB_SERIAL_KEYSPAN_USA19QW \
+ CONFIG_USB_SERIAL_KEYSPAN_USA19QI \
+ CONFIG_USB_SERIAL_KEYSPAN_MPR \
+ CONFIG_USB_SERIAL_KEYSPAN_USA49W \
+ CONFIG_USB_SERIAL_KEYSPAN_USA49WLC
+ FILES:=$(LINUX_DIR)/drivers/usb/serial/keyspan.ko
+ AUTOLOAD:=$(call AutoLoad,65,keyspan)
+ $(call AddDepends/usb-serial)
+endef
+
+define KernelPackage/usb-serial-keyspan/description
+ Kernel support for Keyspan USB-to-Serial devices
+endef
+
+$(eval $(call KernelPackage,usb-serial-keyspan))
+
+
+define KernelPackage/usb-serial-wwan
+ TITLE:=Support for GSM and CDMA modems
+ KCONFIG:=CONFIG_USB_SERIAL_WWAN
+ FILES:=$(LINUX_DIR)/drivers/usb/serial/usb_wwan.ko
+ AUTOLOAD:=$(call AutoLoad,61,usb_wwan)
+ $(call AddDepends/usb-serial)
+endef
+
+define KernelPackage/usb-serial-wwan/description
+ Kernel support for USB GSM and CDMA modems
+endef
+
+$(eval $(call KernelPackage,usb-serial-wwan))
+
+
+define KernelPackage/usb-serial-option
+ TITLE:=Support for Option HSDPA modems
+ DEPENDS:=+kmod-usb-serial-wwan
+ KCONFIG:=CONFIG_USB_SERIAL_OPTION
+ FILES:=$(LINUX_DIR)/drivers/usb/serial/option.ko
+ AUTOLOAD:=$(call AutoLoad,65,option)
+ $(call AddDepends/usb-serial)
+endef
+
+define KernelPackage/usb-serial-option/description
+ Kernel support for Option HSDPA modems
+endef
+
+$(eval $(call KernelPackage,usb-serial-option))
+
+
+define KernelPackage/usb-serial-qualcomm
+ TITLE:=Support for Qualcomm USB serial
+ KCONFIG:=CONFIG_USB_SERIAL_QUALCOMM
+ FILES:=$(LINUX_DIR)/drivers/usb/serial/qcserial.ko
+ AUTOLOAD:=$(call AutoLoad,65,qcserial)
+ $(call AddDepends/usb-serial)
+endef
+
+define KernelPackage/usb-serial-qualcomm/description
+ Kernel support for Qualcomm USB Serial devices (Gobi)
+endef
+
+$(eval $(call KernelPackage,usb-serial-qualcomm))
+
+
+define KernelPackage/usb-storage
+ TITLE:=USB Storage support
+ DEPENDS:= +kmod-scsi-core
+ KCONFIG:=CONFIG_USB_STORAGE
+ FILES:=$(LINUX_DIR)/drivers/usb/storage/usb-storage.ko
+ AUTOLOAD:=$(call AutoLoad,60,usb-storage,1)
+ $(call AddDepends/usb)
+endef
+
+define KernelPackage/usb-storage/description
+ Kernel support for USB Mass Storage devices
+endef
+
+$(eval $(call KernelPackage,usb-storage))
+
+
+define KernelPackage/usb-storage-extras
+ SUBMENU:=$(USB_MENU)
+ TITLE:=Extra drivers for usb-storage
+ DEPENDS:=+kmod-usb-storage
+ KCONFIG:= \
+ CONFIG_USB_STORAGE_ALAUDA \
+ CONFIG_USB_STORAGE_CYPRESS_ATACB \
+ CONFIG_USB_STORAGE_DATAFAB \
+ CONFIG_USB_STORAGE_FREECOM \
+ CONFIG_USB_STORAGE_ISD200 \
+ CONFIG_USB_STORAGE_JUMPSHOT \
+ CONFIG_USB_STORAGE_KARMA \
+ CONFIG_USB_STORAGE_SDDR09 \
+ CONFIG_USB_STORAGE_SDDR55 \
+ CONFIG_USB_STORAGE_USBAT
+ FILES:= \
+ $(LINUX_DIR)/drivers/usb/storage/ums-alauda.ko \
+ $(LINUX_DIR)/drivers/usb/storage/ums-cypress.ko \
+ $(LINUX_DIR)/drivers/usb/storage/ums-datafab.ko \
+ $(LINUX_DIR)/drivers/usb/storage/ums-freecom.ko \
+ $(LINUX_DIR)/drivers/usb/storage/ums-isd200.ko \
+ $(LINUX_DIR)/drivers/usb/storage/ums-jumpshot.ko \
+ $(LINUX_DIR)/drivers/usb/storage/ums-karma.ko \
+ $(LINUX_DIR)/drivers/usb/storage/ums-sddr09.ko \
+ $(LINUX_DIR)/drivers/usb/storage/ums-sddr55.ko \
+ $(LINUX_DIR)/drivers/usb/storage/ums-usbat.ko
+ AUTOLOAD:=$(call AutoLoad,60,ums-alauda ums-cypress ums-datafab \
+ ums-freecom ums-isd200 ums-jumpshot \
+ ums-karma ums-sddr09 ums-sddr55 ums-usbat)
+endef
+
+define KernelPackage/usb-storage-extras/description
+ Say Y here if you want to have some more drivers,
+ such as for SmartMedia card readers.
+endef
+
+$(eval $(call KernelPackage,usb-storage-extras))
+
+
+define KernelPackage/usb-atm
+ TITLE:=Support for ATM on USB bus
+ DEPENDS:=+kmod-atm
+ KCONFIG:=CONFIG_USB_ATM
+ FILES:=$(LINUX_DIR)/drivers/usb/atm/usbatm.ko
+ AUTOLOAD:=$(call AutoLoad,60,usbatm)
+ $(call AddDepends/usb)
+endef
+
+define KernelPackage/usb-atm/description
+ Kernel support for USB DSL modems
+endef
+
+$(eval $(call KernelPackage,usb-atm))
+
+
+define AddDepends/usb-atm
+ SUBMENU:=$(USB_MENU)
+ DEPENDS+=kmod-usb-atm $(1)
+endef
+
+
+define KernelPackage/usb-atm-speedtouch
+ TITLE:=SpeedTouch USB ADSL modems support
+ KCONFIG:=CONFIG_USB_SPEEDTOUCH
+ FILES:=$(LINUX_DIR)/drivers/usb/atm/speedtch.ko
+ AUTOLOAD:=$(call AutoLoad,70,speedtch)
+ $(call AddDepends/usb-atm)
+endef
+
+define KernelPackage/usb-atm-speedtouch/description
+ Kernel support for SpeedTouch USB ADSL modems
+endef
+
+$(eval $(call KernelPackage,usb-atm-speedtouch))
+
+
+define KernelPackage/usb-atm-ueagle
+ TITLE:=Eagle 8051 based USB ADSL modems support
+ FILES:=$(LINUX_DIR)/drivers/usb/atm/ueagle-atm.ko
+ KCONFIG:=CONFIG_USB_UEAGLEATM
+ AUTOLOAD:=$(call AutoLoad,70,ueagle-atm)
+ $(call AddDepends/usb-atm)
+endef
+
+define KernelPackage/usb-atm-ueagle/description
+ Kernel support for Eagle 8051 based USB ADSL modems
+endef
+
+$(eval $(call KernelPackage,usb-atm-ueagle))
+
+
+define KernelPackage/usb-atm-cxacru
+ TITLE:=cxacru
+ FILES:=$(LINUX_DIR)/drivers/usb/atm/cxacru.ko
+ KCONFIG:=CONFIG_USB_CXACRU
+ AUTOLOAD:=$(call AutoLoad,70,cxacru)
+ $(call AddDepends/usb-atm)
+endef
+
+define KernelPackage/usb-atm-cxacru/description
+ Kernel support for cxacru based USB ADSL modems
+endef
+
+$(eval $(call KernelPackage,usb-atm-cxacru))
+
+
+define KernelPackage/usb-net
+ TITLE:=Kernel modules for USB-to-Ethernet convertors
+ KCONFIG:=CONFIG_USB_USBNET CONFIG_MII=y
+ AUTOLOAD:=$(call AutoLoad,60,usbnet)
+ FILES:=$(LINUX_DIR)/drivers/$(USBNET_DIR)/usbnet.ko
+ $(call AddDepends/usb)
+endef
+
+define KernelPackage/usb-net/description
+ Kernel modules for USB-to-Ethernet convertors
+endef
+
+$(eval $(call KernelPackage,usb-net))
+
+
+define AddDepends/usb-net
+ SUBMENU:=$(USB_MENU)
+ DEPENDS+=kmod-usb-net $(1)
+endef
+
+
+define KernelPackage/usb-net-asix
+ TITLE:=Kernel module for USB-to-Ethernet Asix convertors
+ KCONFIG:=CONFIG_USB_NET_AX8817X
+ FILES:=$(LINUX_DIR)/drivers/$(USBNET_DIR)/asix.ko
+ AUTOLOAD:=$(call AutoLoad,61,asix)
+ $(call AddDepends/usb-net)
+endef
+
+define KernelPackage/usb-net-asix/description
+ Kernel module for USB-to-Ethernet Asix convertors
+endef
+
+$(eval $(call KernelPackage,usb-net-asix))
+
+
+define KernelPackage/usb-net-hso
+ TITLE:=Kernel module for Option USB High Speed Mobile Devices
+ KCONFIG:=CONFIG_USB_HSO
+ FILES:= \
+ $(LINUX_DIR)/drivers/$(USBNET_DIR)/hso.ko
+ AUTOLOAD:=$(call AutoLoad,61,hso)
+ $(call AddDepends/usb-net)
+ $(call AddDepends/rfkill)
+endef
+
+define KernelPackage/usb-net-hso/description
+ Kernel module for Option USB High Speed Mobile Devices
+endef
+
+$(eval $(call KernelPackage,usb-net-hso))
+
+
+define KernelPackage/usb-net-kaweth
+ TITLE:=Kernel module for USB-to-Ethernet Kaweth convertors
+ KCONFIG:=CONFIG_USB_KAWETH
+ FILES:=$(LINUX_DIR)/drivers/$(USBNET_DIR)/kaweth.ko
+ AUTOLOAD:=$(call AutoLoad,61,kaweth)
+ $(call AddDepends/usb-net)
+endef
+
+define KernelPackage/usb-net-kaweth/description
+ Kernel module for USB-to-Ethernet Kaweth convertors
+endef
+
+$(eval $(call KernelPackage,usb-net-kaweth))
+
+
+define KernelPackage/usb-net-pegasus
+ TITLE:=Kernel module for USB-to-Ethernet Pegasus convertors
+ KCONFIG:=CONFIG_USB_PEGASUS
+ FILES:=$(LINUX_DIR)/drivers/$(USBNET_DIR)/pegasus.ko
+ AUTOLOAD:=$(call AutoLoad,61,pegasus)
+ $(call AddDepends/usb-net)
+endef
+
+define KernelPackage/usb-net-pegasus/description
+ Kernel module for USB-to-Ethernet Pegasus convertors
+endef
+
+$(eval $(call KernelPackage,usb-net-pegasus))
+
+
+define KernelPackage/usb-net-mcs7830
+ TITLE:=Kernel module for USB-to-Ethernet MCS7830 convertors
+ KCONFIG:=CONFIG_USB_NET_MCS7830
+ FILES:=$(LINUX_DIR)/drivers/$(USBNET_DIR)/mcs7830.ko
+ AUTOLOAD:=$(call AutoLoad,61,mcs7830)
+ $(call AddDepends/usb-net)
+endef
+
+define KernelPackage/usb-net-mcs7830/description
+ Kernel module for USB-to-Ethernet MCS7830 convertors
+endef
+
+$(eval $(call KernelPackage,usb-net-mcs7830))
+
+
+define KernelPackage/usb-net-dm9601-ether
+ TITLE:=Support for DM9601 ethernet connections
+ KCONFIG:=CONFIG_USB_NET_DM9601
+ FILES:=$(LINUX_DIR)/drivers/$(USBNET_DIR)/dm9601.ko
+ AUTOLOAD:=$(call AutoLoad,61,dm9601)
+ $(call AddDepends/usb-net)
+endef
+
+define KernelPackage/usb-net-dm9601-ether/description
+ Kernel support for USB DM9601 devices
+endef
+
+$(eval $(call KernelPackage,usb-net-dm9601-ether))
+
+define KernelPackage/usb-net-cdc-ether
+ TITLE:=Support for cdc ethernet connections
+ KCONFIG:=CONFIG_USB_NET_CDCETHER
+ FILES:=$(LINUX_DIR)/drivers/$(USBNET_DIR)/cdc_ether.ko
+ AUTOLOAD:=$(call AutoLoad,61,cdc_ether)
+ $(call AddDepends/usb-net)
+endef
+
+define KernelPackage/usb-net-cdc-ether/description
+ Kernel support for USB CDC Ethernet devices
+endef
+
+$(eval $(call KernelPackage,usb-net-cdc-ether))
+
+
+define KernelPackage/usb-net-qmi-wwan
+ TITLE:=QMI WWAN driver
+ KCONFIG:=CONFIG_USB_NET_QMI_WWAN
+ FILES:= $(LINUX_DIR)/drivers/$(USBNET_DIR)/qmi_wwan.ko
+ AUTOLOAD:=$(call AutoLoad,61,qmi_wwan)
+ $(call AddDepends/usb-net,+kmod-usb-wdm)
+endef
+
+define KernelPackage/usb-net-qmi-wwan/description
+ QMI WWAN driver for Qualcomm MSM based 3G and LTE modems
+endef
+
+$(eval $(call KernelPackage,usb-net-qmi-wwan))
+
+
+define KernelPackage/usb-net-rndis
+ TITLE:=Support for RNDIS connections
+ KCONFIG:=CONFIG_USB_NET_RNDIS_HOST
+ FILES:= $(LINUX_DIR)/drivers/$(USBNET_DIR)/rndis_host.ko
+ AUTOLOAD:=$(call AutoLoad,62,rndis_host)
+ $(call AddDepends/usb-net,+kmod-usb-net-cdc-ether)
+endef
+
+define KernelPackage/usb-net-rndis/description
+ Kernel support for RNDIS connections
+endef
+
+$(eval $(call KernelPackage,usb-net-rndis))
+
+define KernelPackage/usb-net-cdc-ncm
+ TITLE:=Support for CDC NCM connections
+ KCONFIG:=CONFIG_USB_NET_CDC_NCM
+ FILES:= $(LINUX_DIR)/drivers/$(USBNET_DIR)/cdc_ncm.ko
+ AUTOLOAD:=$(call AutoLoad,61,cdc_ncm)
+ $(call AddDepends/usb-net)
+endef
+
+define KernelPackage/usb-net-cdc-ncm/description
+ Kernel support for CDC NCM connections
+endef
+
+$(eval $(call KernelPackage,usb-net-cdc-ncm))
+
+
+define KernelPackage/usb-net-sierrawireless
+ TITLE:=Support for Sierra Wireless devices
+ KCONFIG:=CONFIG_USB_SIERRA_NET
+ FILES:=$(LINUX_DIR)/drivers/net/usb/sierra_net.ko
+ AUTOLOAD:=$(call AutoLoad,65,sierra_net)
+ $(call AddDepends/usb-net)
+endef
+
+define KernelPackage/usb-net-sierrawireless/description
+ Kernel support for Sierra Wireless devices
+endef
+
+$(eval $(call KernelPackage,usb-net-sierrawireless))
+
+
+define KernelPackage/usb-net-ipheth
+ TITLE:=Apple iPhone USB Ethernet driver
+ KCONFIG:=CONFIG_USB_IPHETH
+ FILES:=$(LINUX_DIR)/drivers/net/usb/ipheth.ko
+ AUTOLOAD:=$(call AutoLoad,64,ipheth)
+ $(call AddDepends/usb-net)
+endef
+
+define KernelPackage/usb-net-ipheth/description
+ Kernel support for Apple iPhone USB Ethernet driver
+endef
+
+$(eval $(call KernelPackage,usb-net-ipheth))
+
+
+define KernelPackage/usb-hid
+ TITLE:=Support for USB Human Input Devices
+ KCONFIG:=CONFIG_HID_SUPPORT=y CONFIG_USB_HID CONFIG_USB_HIDDEV=y
+ FILES:=$(LINUX_DIR)/drivers/$(USBHID_DIR)/usbhid.ko
+ AUTOLOAD:=$(call AutoLoad,70,usbhid)
+ $(call AddDepends/usb)
+ $(call AddDepends/hid)
+ $(call AddDepends/input,+kmod-input-evdev)
+endef
+
+
+define KernelPackage/usb-hid/description
+ Kernel support for USB HID devices such as keyboards and mice
+endef
+
+$(eval $(call KernelPackage,usb-hid))
+
+
+define KernelPackage/usb-yealink
+ TITLE:=USB Yealink VOIP phone
+ KCONFIG:=CONFIG_USB_YEALINK CONFIG_INPUT_YEALINK CONFIG_INPUT=m CONFIG_INPUT_MISC=y
+ FILES:=$(LINUX_DIR)/drivers/$(USBINPUT_DIR)/yealink.ko
+ AUTOLOAD:=$(call AutoLoad,70,yealink)
+ $(call AddDepends/usb)
+ $(call AddDepends/input,+kmod-input-evdev)
+endef
+
+define KernelPackage/usb-yealink/description
+ Kernel support for Yealink VOIP phone
+endef
+
+$(eval $(call KernelPackage,usb-yealink))
+
+
+define KernelPackage/usb-cm109
+ TITLE:=Support for CM109 device
+ KCONFIG:=CONFIG_USB_CM109 CONFIG_INPUT_CM109 CONFIG_INPUT=m CONFIG_INPUT_MISC=y
+ FILES:=$(LINUX_DIR)/drivers/$(USBINPUT_DIR)/cm109.ko
+ AUTOLOAD:=$(call AutoLoad,70,cm109)
+ $(call AddDepends/usb)
+ $(call AddDepends/input,+kmod-input-evdev)
+endef
+
+define KernelPackage/usb-cm109/description
+ Kernel support for CM109 VOIP phone
+endef
+
+$(eval $(call KernelPackage,usb-cm109))
+
+
+define KernelPackage/usb-test
+ TITLE:=USB Testing Driver
+ DEPENDS:=@DEVEL
+ KCONFIG:=CONFIG_USB_TEST
+ FILES:=$(LINUX_DIR)/drivers/usb/misc/usbtest.ko
+ $(call AddDepends/usb)
+endef
+
+define KernelPackage/usb-test/description
+ Kernel support for testing USB Host Controller software.
+endef
+
+$(eval $(call KernelPackage,usb-test))
+
+
+define KernelPackage/usbip
+ TITLE := USB-over-IP kernel support
+ KCONFIG:= \
+ CONFIG_USBIP_CORE \
+ CONFIG_USBIP_DEBUG=n
+ FILES:=$(LINUX_DIR)/drivers/staging/usbip/usbip-core.ko
+ AUTOLOAD:=$(call AutoLoad,90,usbip-core)
+ $(call AddDepends/usb)
+endef
+$(eval $(call KernelPackage,usbip))
+
+define KernelPackage/usbip-client
+ TITLE := USB-over-IP client driver
+ DEPENDS := +kmod-usbip
+ KCONFIG := CONFIG_USBIP_VHCI_HCD
+ FILES := $(LINUX_DIR)/drivers/staging/usbip/vhci-hcd.$(LINUX_KMOD_SUFFIX)
+ AUTOLOAD := $(call AutoLoad,95,vhci-hcd)
+ $(call AddDepends/usb)
+endef
+$(eval $(call KernelPackage,usbip-client))
+
+define KernelPackage/usbip-server
+$(call KernelPackage/usbip/Default)
+ TITLE := USB-over-IP host driver
+ DEPENDS := +kmod-usbip
+ KCONFIG := CONFIG_USBIP_HOST
+ FILES := $(LINUX_DIR)/drivers/staging/usbip/usbip-host.ko
+ AUTOLOAD := $(call AutoLoad,95,usbip-host)
+ $(call AddDepends/usb)
+endef
+$(eval $(call KernelPackage,usbip-server))
diff --git a/package/kernel/modules/video.mk b/package/kernel/modules/video.mk
new file mode 100644
index 0000000..e652e8a
--- /dev/null
+++ b/package/kernel/modules/video.mk
@@ -0,0 +1,730 @@
+#
+# Copyright (C) 2009 David Cooper <dave@kupesoft.com>
+# Copyright (C) 2006-2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+VIDEO_MENU:=Video Support
+
+ifeq ($(strip $(call CompareKernelPatchVer,$(KERNEL_PATCHVER),ge,3.7.0)),1)
+V4L2_DIR=v4l2-core
+V4L2_USB_DIR=usb
+else
+V4L2_DIR=video
+V4L2_USB_DIR=video
+endif
+
+
+define KernelPackage/fb
+ SUBMENU:=$(VIDEO_MENU)
+ TITLE:=Framebuffer support
+ DEPENDS:=@DISPLAY_SUPPORT
+ KCONFIG:=CONFIG_FB
+ FILES:=$(LINUX_DIR)/drivers/video/fb.ko
+ AUTOLOAD:=$(call AutoLoad,06,fb)
+endef
+
+define KernelPackage/fb/description
+ Kernel support for framebuffers
+endef
+
+$(eval $(call KernelPackage,fb))
+
+define KernelPackage/fb-cfb-fillrect
+ SUBMENU:=$(VIDEO_MENU)
+ TITLE:=Framebuffer software rectangle filling support
+ DEPENDS:=+kmod-fb
+ KCONFIG:=CONFIG_FB_CFB_FILLRECT
+ FILES:=$(LINUX_DIR)/drivers/video/cfbfillrect.ko
+ AUTOLOAD:=$(call AutoLoad,07,cfbfillrect)
+endef
+
+define KernelPackage/fb-cfb-fillrect/description
+ Kernel support for software rectangle filling
+endef
+
+$(eval $(call KernelPackage,fb-cfb-fillrect))
+
+
+define KernelPackage/fb-cfb-copyarea
+ SUBMENU:=$(VIDEO_MENU)
+ TITLE:=Framebuffer software copy area support
+ DEPENDS:=+kmod-fb
+ KCONFIG:=CONFIG_FB_CFB_COPYAREA
+ FILES:=$(LINUX_DIR)/drivers/video/cfbcopyarea.ko
+ AUTOLOAD:=$(call AutoLoad,07,cfbcopyarea)
+endef
+
+define KernelPackage/fb-cfb-copyarea/description
+ Kernel support for software copy area
+endef
+
+$(eval $(call KernelPackage,fb-cfb-copyarea))
+
+define KernelPackage/fb-cfb-imgblt
+ SUBMENU:=$(VIDEO_MENU)
+ TITLE:=Framebuffer software image blit support
+ DEPENDS:=+kmod-fb
+ KCONFIG:=CONFIG_FB_CFB_IMAGEBLIT
+ FILES:=$(LINUX_DIR)/drivers/video/cfbimgblt.ko
+ AUTOLOAD:=$(call AutoLoad,07,cfbimgblt)
+endef
+
+define KernelPackage/fb-cfb-imgblt/description
+ Kernel support for software image blitting
+endef
+
+$(eval $(call KernelPackage,fb-cfb-imgblt))
+
+
+define KernelPackage/video-core
+ SUBMENU:=$(VIDEO_MENU)
+ TITLE=Video4Linux support
+ DEPENDS:=@PCI_SUPPORT||USB_SUPPORT
+ KCONFIG:= \
+ CONFIG_MEDIA_SUPPORT=m \
+ CONFIG_MEDIA_CAMERA_SUPPORT=y \
+ CONFIG_VIDEO_DEV \
+ CONFIG_VIDEO_V4L1=y \
+ CONFIG_VIDEO_ALLOW_V4L1=y \
+ CONFIG_VIDEO_CAPTURE_DRIVERS=y \
+ CONFIG_V4L_USB_DRIVERS=y \
+ CONFIG_V4L_PCI_DRIVERS=y \
+ CONFIG_V4L_PLATFORM_DRIVERS=y \
+ CONFIG_V4L_ISA_PARPORT_DRIVERS=y
+ FILES:= \
+ $(LINUX_DIR)/drivers/media/$(V4L2_DIR)/v4l2-common.ko \
+ $(LINUX_DIR)/drivers/media/$(V4L2_DIR)/videodev.ko
+ AUTOLOAD:=$(call AutoLoad,60, videodev v4l2-common)
+endef
+
+define KernelPackage/video-core/description
+ Kernel modules for Video4Linux support
+endef
+
+$(eval $(call KernelPackage,video-core))
+
+
+define AddDepends/video
+ SUBMENU:=$(VIDEO_MENU)
+ DEPENDS+=kmod-video-core $(1)
+endef
+
+define AddDepends/camera
+ SUBMENU:=$(VIDEO_MENU)
+ KCONFIG+=CONFIG_MEDIA_USB_SUPPORT=y \
+ CONFIG_MEDIA_CAMERA_SUPPORT=y
+ DEPENDS+=kmod-video-core $(1)
+endef
+
+
+define KernelPackage/video-videobuf2
+ TITLE:=videobuf2 lib
+ KCONFIG:= \
+ CONFIG_VIDEOBUF2_CORE \
+ CONFIG_VIDEOBUF2_MEMOPS \
+ CONFIG_VIDEOBUF2_VMALLOC
+ FILES:= \
+ $(LINUX_DIR)/drivers/media/$(V4L2_DIR)/videobuf2-core.ko \
+ $(LINUX_DIR)/drivers/media/$(V4L2_DIR)/videobuf2-memops.ko \
+ $(LINUX_DIR)/drivers/media/$(V4L2_DIR)/videobuf2-vmalloc.ko
+ AUTOLOAD:=$(call AutoLoad,65,videobuf2-core videobuf2-memops videobuf2-vmalloc)
+ $(call AddDepends/video)
+endef
+
+define KernelPackage/video-videobuf2/description
+ Kernel modules that implements three basic types of media buffers.
+endef
+
+$(eval $(call KernelPackage,video-videobuf2))
+
+
+define KernelPackage/video-cpia2
+ TITLE:=CPIA2 video driver
+ DEPENDS:=@USB_SUPPORT +kmod-usb-core
+ KCONFIG:=CONFIG_VIDEO_CPIA2
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/cpia2/cpia2.ko
+ AUTOLOAD:=$(call AutoLoad,70,cpia2)
+ $(call AddDepends/camera)
+endef
+
+define KernelPackage/video-cpia2/description
+ Kernel modules for supporting CPIA2 USB based cameras.
+endef
+
+$(eval $(call KernelPackage,video-cpia2))
+
+
+define KernelPackage/video-sn9c102
+ TITLE:=SN9C102 Camera Chip support
+ DEPENDS:=@USB_SUPPORT +kmod-usb-core
+ KCONFIG:=CONFIG_USB_SN9C102
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/sn9c102/sn9c102.ko
+ AUTOLOAD:=$(call AutoLoad,70,gspca_sn9c20x)
+ $(call AddDepends/camera)
+endef
+
+
+define KernelPackage/video-sn9c102/description
+ Kernel modules for supporting SN9C102
+ camera chips.
+endef
+
+$(eval $(call KernelPackage,video-sn9c102))
+
+
+define KernelPackage/video-pwc
+ TITLE:=Philips USB webcam support
+ DEPENDS:=@USB_SUPPORT +kmod-usb-core +kmod-video-videobuf2
+ KCONFIG:= \
+ CONFIG_USB_PWC \
+ CONFIG_USB_PWC_DEBUG=n
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/pwc/pwc.ko
+ AUTOLOAD:=$(call AutoLoad,70,pwc)
+ $(call AddDepends/camera)
+endef
+
+
+define KernelPackage/video-pwc/description
+ Kernel modules for supporting Philips USB based cameras.
+endef
+
+$(eval $(call KernelPackage,video-pwc))
+
+define KernelPackage/video-uvc
+ TITLE:=USB Video Class (UVC) support
+ DEPENDS:=@USB_SUPPORT +kmod-usb-core +kmod-video-videobuf2
+ KCONFIG:= CONFIG_USB_VIDEO_CLASS
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/uvc/uvcvideo.ko
+ AUTOLOAD:=$(call AutoLoad,90,uvcvideo)
+ $(call AddDepends/camera)
+ $(call AddDepends/input)
+endef
+
+
+define KernelPackage/video-uvc/description
+ Kernel modules for supporting USB Video Class (UVC) devices.
+endef
+
+$(eval $(call KernelPackage,video-uvc))
+
+
+define KernelPackage/video-gspca-core
+ MENU:=1
+ TITLE:=GSPCA webcam core support framework
+ DEPENDS:=@USB_SUPPORT +kmod-usb-core +kmod-input-core
+ KCONFIG:=CONFIG_USB_GSPCA
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_main.ko
+ AUTOLOAD:=$(call AutoLoad,70,gspca_main)
+ $(call AddDepends/camera)
+endef
+
+define KernelPackage/video-gspca-core/description
+ Kernel modules for supporting GSPCA based webcam devices. Note this is just
+ the core of the driver, please select a submodule that supports your webcam.
+endef
+
+$(eval $(call KernelPackage,video-gspca-core))
+
+
+define AddDepends/camera-gspca
+ SUBMENU:=$(VIDEO_MENU)
+ DEPENDS+=kmod-video-gspca-core $(1)
+endef
+
+
+define KernelPackage/video-gspca-conex
+ TITLE:=conex webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_CONEX
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_conex.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_conex)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-conex/description
+ The Conexant Camera Driver (conex) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-conex))
+
+
+define KernelPackage/video-gspca-etoms
+ TITLE:=etoms webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_ETOMS
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_etoms.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_etoms)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-etoms/description
+ The Etoms USB Camera Driver (etoms) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-etoms))
+
+
+define KernelPackage/video-gspca-finepix
+ TITLE:=finepix webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_FINEPIX
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_finepix.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_finepix)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-finepix/description
+ The Fujifilm FinePix USB V4L2 driver (finepix) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-finepix))
+
+
+define KernelPackage/video-gspca-mars
+ TITLE:=mars webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_MARS
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_mars.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_mars)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-mars/description
+ The Mars USB Camera Driver (mars) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-mars))
+
+
+define KernelPackage/video-gspca-mr97310a
+ TITLE:=mr97310a webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_MR97310A
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_mr97310a.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_mr97310a)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-mr97310a/description
+ The Mars-Semi MR97310A USB Camera Driver (mr97310a) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-mr97310a))
+
+
+define KernelPackage/video-gspca-ov519
+ TITLE:=ov519 webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_OV519
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_ov519.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_ov519)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-ov519/description
+ The OV519 USB Camera Driver (ov519) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-ov519))
+
+
+define KernelPackage/video-gspca-ov534
+ TITLE:=ov534 webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_OV534
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_ov534.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_ov534)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-ov534/description
+ The OV534 USB Camera Driver (ov534) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-ov534))
+
+
+define KernelPackage/video-gspca-ov534-9
+ TITLE:=ov534-9 webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_OV534_9
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_ov534_9.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_ov534_9)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-ov534-9/description
+ The OV534-9 USB Camera Driver (ov534_9) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-ov534-9))
+
+
+define KernelPackage/video-gspca-pac207
+ TITLE:=pac207 webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_PAC207
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_pac207.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_pac207)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-pac207/description
+ The Pixart PAC207 USB Camera Driver (pac207) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-pac207))
+
+
+define KernelPackage/video-gspca-pac7311
+ TITLE:=pac7311 webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_PAC7311
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_pac7311.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_pac7311)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-pac7311/description
+ The Pixart PAC7311 USB Camera Driver (pac7311) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-pac7311))
+
+
+define KernelPackage/video-gspca-se401
+ TITLE:=se401 webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_SE401
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_se401.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_se401)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-se401/description
+ The SE401 USB Camera Driver kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-se401))
+
+
+define KernelPackage/video-gspca-sn9c20x
+ TITLE:=sn9c20x webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_SN9C20X
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_sn9c20x.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_sn9c20x)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-sn9c20x/description
+ The SN9C20X USB Camera Driver (sn9c20x) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-sn9c20x))
+
+
+define KernelPackage/video-gspca-sonixb
+ TITLE:=sonixb webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_SONIXB
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_sonixb.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_sonixb)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-sonixb/description
+ The SONIX Bayer USB Camera Driver (sonixb) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-sonixb))
+
+
+define KernelPackage/video-gspca-sonixj
+ TITLE:=sonixj webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_SONIXJ
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_sonixj.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_sonixj)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-sonixj/description
+ The SONIX JPEG USB Camera Driver (sonixj) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-sonixj))
+
+
+define KernelPackage/video-gspca-spca500
+ TITLE:=spca500 webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_SPCA500
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_spca500.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_spca500)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-spca500/description
+ The SPCA500 USB Camera Driver (spca500) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-spca500))
+
+
+define KernelPackage/video-gspca-spca501
+ TITLE:=spca501 webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_SPCA501
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_spca501.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_spca501)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-spca501/description
+ The SPCA501 USB Camera Driver (spca501) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-spca501))
+
+
+define KernelPackage/video-gspca-spca505
+ TITLE:=spca505 webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_SPCA505
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_spca505.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_spca505)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-spca505/description
+ The SPCA505 USB Camera Driver (spca505) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-spca505))
+
+
+define KernelPackage/video-gspca-spca506
+ TITLE:=spca506 webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_SPCA506
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_spca506.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_spca506)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-spca506/description
+ The SPCA506 USB Camera Driver (spca506) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-spca506))
+
+
+define KernelPackage/video-gspca-spca508
+ TITLE:=spca508 webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_SPCA508
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_spca508.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_spca508)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-spca508/description
+ The SPCA508 USB Camera Driver (spca508) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-spca508))
+
+
+define KernelPackage/video-gspca-spca561
+ TITLE:=spca561 webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_SPCA561
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_spca561.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_spca561)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-spca561/description
+ The SPCA561 USB Camera Driver (spca561) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-spca561))
+
+
+define KernelPackage/video-gspca-sq905
+ TITLE:=sq905 webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_SQ905
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_sq905.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_sq905)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-sq905/description
+ The SQ Technologies SQ905 based USB Camera Driver (sq905) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-sq905))
+
+
+define KernelPackage/video-gspca-sq905c
+ TITLE:=sq905c webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_SQ905C
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_sq905c.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_sq905c)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-sq905c/description
+ The SQ Technologies SQ905C based USB Camera Driver (sq905c) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-sq905c))
+
+
+define KernelPackage/video-gspca-stk014
+ TITLE:=stk014 webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_STK014
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_stk014.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_stk014)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-stk014/description
+ The Syntek DV4000 (STK014) USB Camera Driver (stk014) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-stk014))
+
+
+define KernelPackage/video-gspca-sunplus
+ TITLE:=sunplus webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_SUNPLUS
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_sunplus.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_sunplus)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-sunplus/description
+ The SUNPLUS USB Camera Driver (sunplus) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-sunplus))
+
+
+define KernelPackage/video-gspca-t613
+ TITLE:=t613 webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_T613
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_t613.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_t613)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-t613/description
+ The T613 (JPEG Compliance) USB Camera Driver (t613) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-t613))
+
+
+define KernelPackage/video-gspca-tv8532
+ TITLE:=tv8532 webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_TV8532
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_tv8532.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_tv8532)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-tv8532/description
+ The TV8532 USB Camera Driver (tv8532) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-tv8532))
+
+
+define KernelPackage/video-gspca-vc032x
+ TITLE:=vc032x webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_VC032X
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_vc032x.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_vc032x)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-vc032x/description
+ The VC032X USB Camera Driver (vc032x) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-vc032x))
+
+
+define KernelPackage/video-gspca-zc3xx
+ TITLE:=zc3xx webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_ZC3XX
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_zc3xx.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_zc3xx)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-zc3xx/description
+ The ZC3XX USB Camera Driver (zc3xx) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-zc3xx))
+
+
+define KernelPackage/video-gspca-m5602
+ TITLE:=m5602 webcam support
+ KCONFIG:=CONFIG_USB_M5602
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/m5602/gspca_m5602.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_m5602)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-m5602/description
+ The ALi USB m5602 Camera Driver (m5602) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-m5602))
+
+
+define KernelPackage/video-gspca-stv06xx
+ TITLE:=stv06xx webcam support
+ KCONFIG:=CONFIG_USB_STV06XX
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/stv06xx/gspca_stv06xx.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_stv06xx)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-stv06xx/description
+ The STV06XX USB Camera Driver (stv06xx) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-stv06xx))
+
+
+define KernelPackage/video-gspca-gl860
+ TITLE:=gl860 webcam support
+ KCONFIG:=CONFIG_USB_GL860
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gl860/gspca_gl860.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_gl860)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-gl800/description
+ The GL860 USB Camera Driver (gl860) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-gl860))
+
+
+define KernelPackage/video-gspca-jeilinj
+ TITLE:=jeilinj webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_JEILINJ
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_jeilinj.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_jeilinj)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-jeilinj/description
+ The JEILINJ USB Camera Driver (jeilinj) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-jeilinj))
+
+
+define KernelPackage/video-gspca-konica
+ TITLE:=konica webcam support
+ KCONFIG:=CONFIG_USB_GSPCA_KONICA
+ FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/gspca/gspca_konica.ko
+ AUTOLOAD:=$(call AutoLoad,75,gspca_konica)
+ $(call AddDepends/camera-gspca)
+endef
+
+define KernelPackage/video-gspca-konica/description
+ The Konica USB Camera Driver (konica) kernel module.
+endef
+
+$(eval $(call KernelPackage,video-gspca-konica))
diff --git a/package/kernel/modules/virtual.mk b/package/kernel/modules/virtual.mk
new file mode 100644
index 0000000..5f8428b
--- /dev/null
+++ b/package/kernel/modules/virtual.mk
@@ -0,0 +1,171 @@
+#
+# Copyright (C) 2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+VIRTUAL_MENU:=Virtualization Support
+
+
+define KernelPackage/virtio-balloon
+ SUBMENU:=$(VIRTUAL_MENU)
+ TITLE:=VirtIO balloon driver
+ DEPENDS:=@TARGET_x86_kvm_guest
+ KCONFIG:=CONFIG_VIRTIO_BALLOON
+ FILES:=$(LINUX_DIR)/drivers/virtio/virtio_balloon.ko
+ AUTOLOAD:=$(call AutoLoad,06,virtio-balloon)
+endef
+
+define KernelPackage/virtio-balloon/description
+ Kernel module for VirtIO memory ballooning support
+endef
+
+$(eval $(call KernelPackage,virtio-balloon))
+
+
+define KernelPackage/virtio-net
+ SUBMENU:=$(VIRTUAL_MENU)
+ TITLE:=VirtIO network driver
+ DEPENDS:=@TARGET_x86_kvm_guest
+ KCONFIG:=CONFIG_VIRTIO_NET
+ FILES:=$(LINUX_DIR)/drivers/net/virtio_net.ko
+ AUTOLOAD:=$(call AutoLoad,50,virtio_net)
+endef
+
+define KernelPackage/virtio-net/description
+ Kernel module for the VirtIO paravirtualized network device
+endef
+
+$(eval $(call KernelPackage,virtio-net))
+
+
+define KernelPackage/virtio-random
+ SUBMENU:=$(VIRTUAL_MENU)
+ TITLE:=VirtIO Random Number Generator support
+ DEPENDS:=@TARGET_x86_kvm_guest
+ KCONFIG:=CONFIG_HW_RANDOM_VIRTIO
+ FILES:=$(LINUX_DIR)/drivers/char/hw_random/virtio-rng.ko
+ AUTOLOAD:=$(call AutoLoad,09,virtio-rng)
+endef
+
+define KernelPackage/virtio-random/description
+ Kernel module for the VirtIO Random Number Generator
+endef
+
+$(eval $(call KernelPackage,virtio-random))
+
+define KernelPackage/xen-fs
+ SUBMENU:=$(VIRTUAL_MENU)
+ TITLE:=Xen filesystem
+ DEPENDS:=@TARGET_x86_xen_domu
+ KCONFIG:= \
+ CONFIG_XENFS \
+ CONFIG_XEN_COMPAT_XENFS=y
+ FILES:=$(LINUX_DIR)/drivers/xen/xenfs/xenfs.ko
+ AUTOLOAD:=$(call AutoLoad,05,xenfs)
+endef
+
+define KernelPackage/xen-fs/description
+ Kernel module for the Xen filesystem
+endef
+
+$(eval $(call KernelPackage,xen-fs))
+
+
+define KernelPackage/xen-evtchn
+ SUBMENU:=$(VIRTUAL_MENU)
+ TITLE:=Xen event channels
+ DEPENDS:=@TARGET_x86_xen_domu
+ KCONFIG:=CONFIG_XEN_DEV_EVTCHN
+ FILES:=$(LINUX_DIR)/drivers/xen/xen-evtchn.ko
+ AUTOLOAD:=$(call AutoLoad,06,xen-evtchn)
+endef
+
+define KernelPackage/xen-evtchn/description
+ Kernel module for the /dev/xen/evtchn device
+endef
+
+$(eval $(call KernelPackage,xen-evtchn))
+
+define KernelPackage/xen-fbdev
+ SUBMENU:=$(VIRTUAL_MENU)
+ TITLE:=Xen virtual frame buffer
+ DEPENDS:=@TARGET_x86_xen_domu +kmod-fb
+ KCONFIG:= \
+ CONFIG_XEN_FBDEV_FRONTEND \
+ CONFIG_FB_DEFERRED_IO=y \
+ CONFIG_FB_SYS_COPYAREA \
+ CONFIG_FB_SYS_FILLRECT \
+ CONFIG_FB_SYS_FOPS \
+ CONFIG_FB_SYS_IMAGEBLIT \
+ CONFIG_FIRMWARE_EDID=n
+ FILES:= \
+ $(LINUX_DIR)/drivers/video/xen-fbfront.ko \
+ $(LINUX_DIR)/drivers/video/syscopyarea.ko \
+ $(LINUX_DIR)/drivers/video/sysfillrect.ko \
+ $(LINUX_DIR)/drivers/video/fb_sys_fops.ko \
+ $(LINUX_DIR)/drivers/video/sysimgblt.ko
+ AUTOLOAD:=$(call AutoLoad,07, \
+ fb \
+ syscopyarea \
+ sysfillrect \
+ fb_sys_fops \
+ sysimgblt \
+ xen-fbfront \
+ )
+endef
+
+define KernelPackage/xen-fbdev/description
+ Kernel module for the Xen virtual frame buffer
+endef
+
+$(eval $(call KernelPackage,xen-fbdev))
+
+
+define KernelPackage/xen-kbddev
+ SUBMENU:=$(VIRTUAL_MENU)
+ TITLE:=Xen virtual keyboard and mouse
+ DEPENDS:=@TARGET_x86_xen_domu
+ KCONFIG:=CONFIG_XEN_KBDDEV_FRONTEND
+ FILES:=$(LINUX_DIR)/drivers/input/xen-kbdfront.ko
+ AUTOLOAD:=$(call AutoLoad,08,xen-kbdfront)
+endef
+
+define KernelPackage/xen-kbddev/description
+ Kernel module for the Xen virtual keyboard and mouse
+endef
+
+$(eval $(call KernelPackage,xen-kbddev))
+
+
+define KernelPackage/xen-netdev
+ SUBMENU:=$(VIRTUAL_MENU)
+ TITLE:=Xen network device frontend
+ DEPENDS:=@TARGET_x86_xen_domu
+ KCONFIG:=CONFIG_XEN_NETDEV_FRONTEND
+ FILES:=$(LINUX_DIR)/drivers/net/xen-netfront.ko
+ AUTOLOAD:=$(call AutoLoad,09,xen-netfront)
+endef
+
+define KernelPackage/xen-netdev/description
+ Kernel module for the Xen network device frontend
+endef
+
+$(eval $(call KernelPackage,xen-netdev))
+
+
+define KernelPackage/xen-pcidev
+ SUBMENU:=$(VIRTUAL_MENU)
+ TITLE:=Xen PCI device frontend
+ DEPENDS:=@TARGET_x86_xen_domu
+ KCONFIG:=CONFIG_XEN_PCIDEV_FRONTEND
+ FILES:=$(LINUX_DIR)/drivers/pci/xen-pcifront.ko
+ AUTOLOAD:=$(call AutoLoad,10,xen-pcifront)
+endef
+
+define KernelPackage/xen-pcidev/description
+ Kernel module for the Xen network device frontend
+endef
+
+$(eval $(call KernelPackage,xen-pcidev))
diff --git a/package/kernel/modules/w1.mk b/package/kernel/modules/w1.mk
new file mode 100644
index 0000000..9093216
--- /dev/null
+++ b/package/kernel/modules/w1.mk
@@ -0,0 +1,160 @@
+#
+# Copyright (C) 2008-2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+W1_MENU:=W1 support
+W1_MASTERS_DIR:=$(LINUX_DIR)/drivers/w1/masters
+W1_SLAVES_DIR:=$(LINUX_DIR)/drivers/w1/slaves
+
+define KernelPackage/w1
+ SUBMENU:=$(W1_MENU)
+ TITLE:=Dallas's 1-wire support
+ KCONFIG:=CONFIG_W1
+ FILES:=$(LINUX_DIR)/drivers/w1/wire.ko
+ AUTOLOAD:=$(call AutoLoad,50,wire)
+endef
+
+define KernelPackage/w1/description
+ Kernel module for Dallas's 1-wire support
+endef
+
+$(eval $(call KernelPackage,w1))
+
+
+define AddDepends/w1
+ SUBMENU:=$(W1_MENU)
+ DEPENDS+=kmod-w1 $(1)
+endef
+
+
+#
+# 1-wire masters
+#
+define KernelPackage/w1-master-gpio
+ TITLE:=GPIO 1-wire bus master driver
+ DEPENDS:=@GPIO_SUPPORT
+ KCONFIG:=CONFIG_W1_MASTER_GPIO
+ FILES:=$(W1_MASTERS_DIR)/w1-gpio.ko
+ AUTOLOAD:=$(call AutoLoad,60,w1-gpio)
+ $(call AddDepends/w1)
+endef
+
+define KernelPackage/w1-master-gpio/description
+ Kernel module for the GPIO 1-wire bus master driver
+endef
+
+$(eval $(call KernelPackage,w1-master-gpio))
+
+define KernelPackage/w1-master-ds2482
+ TITLE:=DS2482 1-wire i2c bus master driver
+ KCONFIG:=CONFIG_W1_MASTER_DS2482
+ FILES:=$(W1_MASTERS_DIR)/ds2482.ko
+ AUTOLOAD:=$(call AutoLoad,60,ds2482)
+ $(call AddDepends/w1,+kmod-i2c-core)
+endef
+
+define KernelPackage/w1-master-ds2482/description
+ Kernel module for the DS2482 i2c 1-wire bus master driver
+ NOTE: Init with: echo ds2482 0x18 > /sys/bus/i2c/devices/i2c-0/new_device
+ or use owfs
+endef
+
+$(eval $(call KernelPackage,w1-master-ds2482))
+
+
+define KernelPackage/w1-master-ds2490
+ TITLE:=DS2490 1-wire usb bus master driver
+ DEPENDS:=@USB_SUPPORT +kmod-usb-core
+ KCONFIG:=CONFIG_W1_MASTER_DS2490
+ FILES:=$(W1_MASTERS_DIR)/ds2490.ko
+ AUTOLOAD:=$(call AutoLoad,60,ds2490)
+ $(call AddDepends/w1)
+endef
+
+define KernelPackage/w1-master-ds2490/description
+ Kernel module for the DS2490 usb 1-wire bus master driver
+endef
+
+$(eval $(call KernelPackage,w1-master-ds2490))
+
+#
+# 1-wire slaves
+#
+define KernelPackage/w1-slave-therm
+ TITLE:=Thermal family implementation
+ KCONFIG:=CONFIG_W1_SLAVE_THERM
+ FILES:=$(W1_SLAVES_DIR)/w1_therm.ko
+ AUTOLOAD:=$(call AutoLoad,70,w1_therm)
+ $(call AddDepends/w1)
+endef
+
+define KernelPackage/w1-slave-therm/description
+ Kernel module for 1-wire thermal sensors
+endef
+
+$(eval $(call KernelPackage,w1-slave-therm))
+
+
+define KernelPackage/w1-slave-smem
+ TITLE:=Simple 64bit memory family implementation
+ KCONFIG:=CONFIG_W1_SLAVE_SMEM
+ FILES:=$(W1_SLAVES_DIR)/w1_smem.ko
+ AUTOLOAD:=$(call AutoLoad,70,w1_smem)
+ $(call AddDepends/w1)
+endef
+
+define KernelPackage/w1-slave-smem/description
+ Kernel module for 1-wire simple 64bit memory rom(ds2401/ds2411/ds1990*)
+endef
+
+$(eval $(call KernelPackage,w1-slave-smem))
+
+define KernelPackage/w1-slave-ds2431
+ TITLE:=DS2431 1kb EEPROM driver
+ KCONFIG:= CONFIG_W1_SLAVE_DS2431
+ FILES:=$(W1_SLAVES_DIR)/w1_ds2431.ko
+ AUTOLOAD:=$(call AutoLoad,70,w1_ds2431)
+ $(call AddDepends/w1)
+endef
+
+define KernelPackage/w1-slave-ds2431/description
+ Kernel module for 1-wire 1kb EEPROM (DS2431)
+endef
+
+$(eval $(call KernelPackage,w1-slave-ds2431))
+
+define KernelPackage/w1-slave-ds2433
+ TITLE:=DS2433 4kb EEPROM driver
+ KCONFIG:= \
+ CONFIG_W1_SLAVE_DS2433 \
+ CONFIG_W1_SLAVE_DS2433_CRC=n
+ FILES:=$(W1_SLAVES_DIR)/w1_ds2433.ko
+ AUTOLOAD:=$(call AutoLoad,70,w1_ds2433)
+ $(call AddDepends/w1)
+endef
+
+define KernelPackage/w1-slave-ds2433/description
+ Kernel module for 1-wire 4kb EEPROM (DS2433)
+endef
+
+$(eval $(call KernelPackage,w1-slave-ds2433))
+
+
+define KernelPackage/w1-slave-ds2760
+ TITLE:=Dallas 2760 battery monitor chip (HP iPAQ & others)
+ KCONFIG:= \
+ CONFIG_W1_SLAVE_DS2760 \
+ CONFIG_W1_SLAVE_DS2433_CRC=n
+ FILES:=$(W1_SLAVES_DIR)/w1_ds2760.ko
+ AUTOLOAD:=$(call AutoLoad,70,w1_ds2760)
+ $(call AddDepends/w1)
+endef
+
+define KernelPackage/w1-slave-ds2760/description
+ Kernel module for 1-wire DS2760 battery monitor chip support
+endef
+
+$(eval $(call KernelPackage,w1-slave-ds2760))
diff --git a/package/kernel/modules/wireless.mk b/package/kernel/modules/wireless.mk
new file mode 100644
index 0000000..ee0f965
--- /dev/null
+++ b/package/kernel/modules/wireless.mk
@@ -0,0 +1,109 @@
+#
+# Copyright (C) 2006-2008 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+WIRELESS_MENU:=Wireless Drivers
+
+define KernelPackage/net-airo
+ SUBMENU:=$(WIRELESS_MENU)
+ TITLE:=Cisco Aironet driver
+ DEPENDS:=@PCI_SUPPORT +@DRIVER_WEXT_SUPPORT
+ KCONFIG:=CONFIG_AIRO
+ FILES:=$(LINUX_DIR)/drivers/net/wireless/airo.ko
+ AUTOLOAD:=$(call AutoLoad,50,airo)
+endef
+
+define KernelPackage/net-airo/description
+ Kernel support for Cisco Aironet cards
+endef
+
+$(eval $(call KernelPackage,net-airo))
+
+
+define KernelPackage/net-zd1201
+ SUBMENU:=$(WIRELESS_MENU)
+ TITLE:=Zydas ZD1201 support
+ DEPENDS:=@USB_SUPPORT +@DRIVER_WEXT_SUPPORT
+ KCONFIG:=CONFIG_USB_ZD1201
+ FILES:=$(LINUX_DIR)/drivers/net/wireless/zd1201.ko
+ AUTOLOAD:=$(call AutoLoad,60,zd1201)
+endef
+
+define KernelPackage/net-zd1201/description
+ Kernel modules for Zydas ZD1201 support
+ Devices using this chip:
+ * Sweex LC100020
+ * Zyxel ZyAir B-220
+ * Peabird USB
+ * Gigafast WF741-UIC
+ * E-Tech Wireless USB Adapter
+ * DSE 802.11b USB wireless LAN adapter
+ * CC and C WLAN USB Adapter (WL 1202)
+ * Edimax EW-7117U
+ * X-Micro WLAN 11b USB Adapter
+ * Belkin F5D6051
+ * Topcom SKYR@CER WIRELESS USB STICK 11
+ * Surecom EP-9001
+ * JAHT WN-1011U
+ * BeWAN Wi-Fi USB 11
+ * NorthQ NQ9000
+ * MSI UB11B
+ * Origo WLL-1610
+ * Longshine LCS-8131R
+ * Gigabyte GN-WLBZ201
+endef
+
+ZD1201FW_NAME:=zd1201
+ZD1201FW_VERSION:=0.14
+ZD1201FW_DIR:=$(ZD1201FW_NAME)-$(ZD1201FW_VERSION)-fw
+ZD1201FW_FILE:=$(ZD1201FW_DIR).tar.gz
+
+define Download/net-zd1201
+ FILE:=$(ZD1201FW_FILE)
+ #http://downloads.sourceforge.net/project/linux-lc100020/%28NEW%29%20zd1201%20driver/zd1201.%20Version%200.14/zd1201-0.14-fw.tar.gz
+ URL:=@SF/linux-lc100020/\(NEW\)\ $(ZD1201FW_NAME)\ driver/$(ZD1201FW_NAME).\ Version\ $(ZD1201FW_VERSION)/
+ MD5SUM:=07a4febc365121f975e2c5e59791d55d
+endef
+
+define KernelPackage/net-zd1201/install
+ $(INSTALL_DIR) $(1)/lib/firmware
+ $(TAR) -C $(1)/lib/firmware -zxf $(DL_DIR)/$(ZD1201FW_FILE) --strip-components=1 $(ZD1201FW_DIR)/$(ZD1201FW_NAME).fw $(ZD1201FW_DIR)/$(ZD1201FW_NAME)-ap.fw
+endef
+
+$(eval $(call Download,net-zd1201))
+$(eval $(call KernelPackage,net-zd1201))
+
+
+define KernelPackage/net-prism54
+ SUBMENU:=$(WIRELESS_MENU)
+ TITLE:=Intersil Prism54 support
+ DEPENDS:=@PCI_SUPPORT +@DRIVER_WEXT_SUPPORT
+ KCONFIG:=CONFIG_PRISM54
+ FILES:=$(LINUX_DIR)/drivers/net/wireless/prism54/prism54.ko
+ AUTOLOAD:=$(call AutoLoad,60,prism54)
+endef
+
+define KernelPackage/net-prism54/description
+ Kernel modules for Intersil Prism54 support
+endef
+
+# Prism54 FullMAC firmware (jbnore.free.fr seems to be rather slow, so we use daemonizer.de)
+PRISM54_FW:=1.0.4.3.arm
+
+define Download/net-prism54
+ FILE:=$(PRISM54_FW)
+ URL:=http://daemonizer.de/prism54/prism54-fw/fw-fullmac/
+ MD5SUM:=8bd4310971772a486b9784c77f8a6df9
+endef
+
+define KernelPackage/net-prism54/install
+ $(INSTALL_DIR) $(1)/lib/firmware
+ $(INSTALL_DATA) $(DL_DIR)/$(PRISM54_FW) $(1)/lib/firmware/isl3890
+endef
+
+$(eval $(call Download,net-prism54))
+$(eval $(call KernelPackage,net-prism54))
+
diff --git a/package/libs/.svn/entries b/package/libs/.svn/entries
new file mode 100644
index 0000000..84e9af9
--- /dev/null
+++ b/package/libs/.svn/entries
@@ -0,0 +1,118 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-13T15:44:08.492023Z
+35996
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+ustream-ssl
+dir
+
+libnfnetlink
+dir
+
+libusb
+dir
+
+libjson-c
+dir
+
+libnl-tiny
+dir
+
+ncurses
+dir
+
+popt
+dir
+
+openssl
+dir
+
+gettext-full
+dir
+
+gettext
+dir
+
+uclibc++
+dir
+
+sysfsutils
+dir
+
+libevent2
+dir
+
+ocf-crypto-headers
+dir
+
+cyassl
+dir
+
+polarssl
+dir
+
+libbsd
+dir
+
+zlib
+dir
+
+libnl
+dir
+
+libusb-compat
+dir
+
+libnetfilter-conntrack
+dir
+
+libtool
+dir
+
+libubox
+dir
+
+lzo
+dir
+
+libiconv-full
+dir
+
+libiconv
+dir
+
+libpcap
+dir
+
+libreadline
+dir
+
+librpc
+dir
+
+libmnl
+dir
+
diff --git a/package/libs/cyassl/.svn/entries b/package/libs/cyassl/.svn/entries
new file mode 100644
index 0000000..9ba2e15
--- /dev/null
+++ b/package/libs/cyassl/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs/cyassl
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-09T16:41:36.278401Z
+33675
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:06.000000Z
+98972ee67cc12252dfc30892d770b8c9
+2012-10-09T16:41:36.278401Z
+33675
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1214
+
diff --git a/package/libs/cyassl/.svn/text-base/Makefile.svn-base b/package/libs/cyassl/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..063e572
--- /dev/null
+++ b/package/libs/cyassl/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,56 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=cyassl
+PKG_VERSION:=1.6.5
+PKG_RELEASE:=2
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).zip
+PKG_SOURCE_URL:=http://www.yassl.com/
+PKG_MD5SUM:=98c2c6350acf1d089756a1de9ccb9903
+
+PKG_FIXUP:=patch-libtool
+PKG_INSTALL:=1
+PKG_BUILD_PARALLEL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/libcyassl
+ SECTION:=libs
+ SUBMENU:=SSL
+ CATEGORY:=Libraries
+ TITLE:=CyaSSL library
+ URL:=http://www.yassl.com/
+endef
+
+define Package/libcyassl/description
+CyaSSL is an SSL library optimized for small footprint, both on disk and for
+memory use.
+endef
+
+TARGET_CFLAGS += $(FPIC)
+
+CONFIGURE_ARGS += \
+ --without-zlib \
+ --enable-singleThreaded
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include
+ $(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/
+
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libcyassl.{a,so*,la} $(1)/usr/lib/
+endef
+
+define Package/libcyassl/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libcyassl.so* $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,libcyassl))
diff --git a/package/libs/cyassl/Makefile b/package/libs/cyassl/Makefile
new file mode 100644
index 0000000..063e572
--- /dev/null
+++ b/package/libs/cyassl/Makefile
@@ -0,0 +1,56 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=cyassl
+PKG_VERSION:=1.6.5
+PKG_RELEASE:=2
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).zip
+PKG_SOURCE_URL:=http://www.yassl.com/
+PKG_MD5SUM:=98c2c6350acf1d089756a1de9ccb9903
+
+PKG_FIXUP:=patch-libtool
+PKG_INSTALL:=1
+PKG_BUILD_PARALLEL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/libcyassl
+ SECTION:=libs
+ SUBMENU:=SSL
+ CATEGORY:=Libraries
+ TITLE:=CyaSSL library
+ URL:=http://www.yassl.com/
+endef
+
+define Package/libcyassl/description
+CyaSSL is an SSL library optimized for small footprint, both on disk and for
+memory use.
+endef
+
+TARGET_CFLAGS += $(FPIC)
+
+CONFIGURE_ARGS += \
+ --without-zlib \
+ --enable-singleThreaded
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include
+ $(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/
+
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libcyassl.{a,so*,la} $(1)/usr/lib/
+endef
+
+define Package/libcyassl/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libcyassl.so* $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,libcyassl))
diff --git a/package/libs/cyassl/patches/.svn/entries b/package/libs/cyassl/patches/.svn/entries
new file mode 100644
index 0000000..c3361eb
--- /dev/null
+++ b/package/libs/cyassl/patches/.svn/entries
@@ -0,0 +1,164 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs/cyassl/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-09T16:41:36.278401Z
+33675
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+130-configure_disable_pthreads_tests.patch
+file
+
+
+
+
+2013-03-17T12:13:06.000000Z
+06eecc233564015fdeb2f80f99121c96
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+14328
+
+120-makefile_destdir.patch
+file
+
+
+
+
+2013-03-17T12:13:06.000000Z
+fbc05464f99a0be2afa79d17d72c2b9d
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3422
+
+110-makefile_disable_examples_tests.patch
+file
+
+
+
+
+2013-03-17T12:13:06.000000Z
+254e7a4c860bd80adb2efc8b03ec0cc8
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1658
+
+200-SSL_accept-handle-hello-garbage.patch
+file
+
+
+
+
+2013-03-17T12:13:06.000000Z
+ee96c44abf5b8004f28265fdc637a9b6
+2012-10-09T16:41:36.278401Z
+33675
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+545
+
diff --git a/package/libs/cyassl/patches/.svn/text-base/110-makefile_disable_examples_tests.patch.svn-base b/package/libs/cyassl/patches/.svn/text-base/110-makefile_disable_examples_tests.patch.svn-base
new file mode 100644
index 0000000..c66ab8c
--- /dev/null
+++ b/package/libs/cyassl/patches/.svn/text-base/110-makefile_disable_examples_tests.patch.svn-base
@@ -0,0 +1,46 @@
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -1,4 +1,4 @@
+-SUBDIRS = src ctaocrypt examples testsuite sslSniffer
++SUBDIRS = src ctaocrypt
+ EXTRA_DIST = cyassl.dsp cyassl.dsw certs/*.pem certs/*.der certs/*.txt \
+ lib/dummy cyassl.sln cyassl.vcproj cyassl-iphone.xcodeproj/project.pbxproj \
+ doc/*.pdf swig/README swig/*.i swig/cyassl_adds.c swig/*.sh swig/runme.* \
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -193,7 +193,7 @@ target_os = @target_os@
+ target_vendor = @target_vendor@
+ top_builddir = @top_builddir@
+ top_srcdir = @top_srcdir@
+-SUBDIRS = src ctaocrypt examples testsuite sslSniffer
++SUBDIRS = src ctaocrypt
+ EXTRA_DIST = cyassl.dsp cyassl.dsw certs/*.pem certs/*.der certs/*.txt \
+ lib/dummy cyassl.sln cyassl.vcproj cyassl-iphone.xcodeproj/project.pbxproj \
+ doc/*.pdf swig/README swig/*.i swig/cyassl_adds.c swig/*.sh swig/runme.* \
+@@ -643,7 +643,7 @@ uninstall-am:
+
+ # !!!! first line of rule has to start with a hard (real) tab, not spaces
+ basic:
+- cd src; $(MAKE); cd ../testsuite; $(MAKE); cd ../
++ cd src; $(MAKE); cd ../
+
+ openssl-links:
+ cd lib; ln -s ../src/.libs/libcyassl.a libcrypto.a; \
+--- a/ctaocrypt/Makefile.am
++++ b/ctaocrypt/Makefile.am
+@@ -1,3 +1,3 @@
+-SUBDIRS = src test benchmark
++SUBDIRS = src
+ EXTRA_DIST = ctaocrypt.dsw ctaocrypt.dsp ctaocrypt.sln ctaocrypt.vcproj
+
+--- a/ctaocrypt/Makefile.in
++++ b/ctaocrypt/Makefile.in
+@@ -177,7 +177,7 @@ target_os = @target_os@
+ target_vendor = @target_vendor@
+ top_builddir = @top_builddir@
+ top_srcdir = @top_srcdir@
+-SUBDIRS = src test benchmark
++SUBDIRS = src
+ EXTRA_DIST = ctaocrypt.dsw ctaocrypt.dsp ctaocrypt.sln ctaocrypt.vcproj
+ all: all-recursive
+
diff --git a/package/libs/cyassl/patches/.svn/text-base/120-makefile_destdir.patch.svn-base b/package/libs/cyassl/patches/.svn/text-base/120-makefile_destdir.patch.svn-base
new file mode 100644
index 0000000..bf20274
--- /dev/null
+++ b/package/libs/cyassl/patches/.svn/text-base/120-makefile_destdir.patch.svn-base
@@ -0,0 +1,71 @@
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -10,19 +10,19 @@ basic:
+
+ openssl-links:
+ cd lib; ln -s ../src/.libs/libcyassl.a libcrypto.a; \
+- ln -s ../src/.libs/libcyassl.a libssl.a; \
+- ln -s ../src/.libs/libcyassl.a libcyassl.a; cd ../
++ ln -s ../src/.libs/libcyassl.a libssl.a; \
++ ln -s ../src/.libs/libcyassl.a libcyassl.a; cd ../
+
+ # !!! test -e with a .name like .libs then a * like *dylib fails so just
+ # look for the .dylib on OS X, and .so otherwise but copy all parts
+ install:
+- $(mkinstalldirs) $(DESTDIR)$(includedir) $(DESTDIR)$(libdir); \
+- cp -fpR include/* $(DESTDIR)$(includedir); \
+- cp -fpR ctaocrypt/include/* $(DESTDIR)$(includedir); \
+- cp -fpR src/libcyassl.la $(DESTDIR)$(libdir); \
+- if test -e src/.libs/libcyassl.a; then \
+- cp -fp src/.libs/libcyassl.a $(DESTDIR)$(libdir); fi; \
+- if test -e src/.libs/libcyassl.so; then \
+- cp -fpR src/.libs/libcyassl.so* $(DESTDIR)$(libdir); fi; \
+- if test -e src/.libs/libcyassl.dylib; then \
+- cp -fpR src/.libs/libcyassl.*dylib $(DESTDIR)$(libdir); fi;
++ $(mkinstalldirs) $(DESTDIR)$(includedir)/cyassl $(DESTDIR)$(libdir); \
++ cp -fpR include/* $(DESTDIR)$(includedir)/cyassl; \
++ cp -fpR ctaocrypt/include/* $(DESTDIR)$(includedir)/cyassl; \
++ cp -fpR src/libcyassl.la $(DESTDIR)$(libdir); \
++ if test -e src/.libs/libcyassl.a; then \
++ cp -fp src/.libs/libcyassl.a $(DESTDIR)$(libdir); fi; \
++ if test -e src/.libs/libcyassl.so; then \
++ cp -fpR src/.libs/libcyassl.so* $(DESTDIR)$(libdir); fi; \
++ if test -e src/.libs/libcyassl.dylib; then \
++ cp -fpR src/.libs/libcyassl.*dylib $(DESTDIR)$(libdir); fi;
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -647,22 +647,22 @@ basic:
+
+ openssl-links:
+ cd lib; ln -s ../src/.libs/libcyassl.a libcrypto.a; \
+- ln -s ../src/.libs/libcyassl.a libssl.a; \
+- ln -s ../src/.libs/libcyassl.a libcyassl.a; cd ../
++ ln -s ../src/.libs/libcyassl.a libssl.a; \
++ ln -s ../src/.libs/libcyassl.a libcyassl.a; cd ../
+
+ # !!! test -e with a .name like .libs then a * like *dylib fails so just
+ # look for the .dylib on OS X, and .so otherwise but copy all parts
+ install:
+- $(mkinstalldirs) $(DESTDIR)$(includedir) $(DESTDIR)$(libdir); \
+- cp -fpR include/* $(DESTDIR)$(includedir); \
+- cp -fpR ctaocrypt/include/* $(DESTDIR)$(includedir); \
+- cp -fpR src/libcyassl.la $(DESTDIR)$(libdir); \
+- if test -e src/.libs/libcyassl.a; then \
+- cp -fp src/.libs/libcyassl.a $(DESTDIR)$(libdir); fi; \
+- if test -e src/.libs/libcyassl.so; then \
+- cp -fpR src/.libs/libcyassl.so* $(DESTDIR)$(libdir); fi; \
+- if test -e src/.libs/libcyassl.dylib; then \
+- cp -fpR src/.libs/libcyassl.*dylib $(DESTDIR)$(libdir); fi;
++ $(mkinstalldirs) $(DESTDIR)$(includedir)/cyassl $(DESTDIR)$(libdir); \
++ cp -fpR include/* $(DESTDIR)$(includedir)/cyassl; \
++ cp -fpR ctaocrypt/include/* $(DESTDIR)$(includedir)/cyassl; \
++ cp -fpR src/libcyassl.la $(DESTDIR)$(libdir); \
++ if test -e src/.libs/libcyassl.a; then \
++ cp -fp src/.libs/libcyassl.a $(DESTDIR)$(libdir); fi; \
++ if test -e src/.libs/libcyassl.so; then \
++ cp -fpR src/.libs/libcyassl.so* $(DESTDIR)$(libdir); fi; \
++ if test -e src/.libs/libcyassl.dylib; then \
++ cp -fpR src/.libs/libcyassl.*dylib $(DESTDIR)$(libdir); fi;
+ # Tell versions [3.59,3.63) of GNU make to not export all variables.
+ # Otherwise a system limit (for SysV at least) may be exceeded.
+ .NOEXPORT:
diff --git a/package/libs/cyassl/patches/.svn/text-base/130-configure_disable_pthreads_tests.patch.svn-base b/package/libs/cyassl/patches/.svn/text-base/130-configure_disable_pthreads_tests.patch.svn-base
new file mode 100644
index 0000000..44fdf6c
--- /dev/null
+++ b/package/libs/cyassl/patches/.svn/text-base/130-configure_disable_pthreads_tests.patch.svn-base
@@ -0,0 +1,444 @@
+--- a/configure
++++ b/configure
+@@ -888,10 +888,6 @@ BUILD_RIPEMD_TRUE
+ BUILD_RIPEMD_FALSE
+ BUILD_SHA512_TRUE
+ BUILD_SHA512_FALSE
+-acx_pthread_config
+-PTHREAD_CC
+-PTHREAD_LIBS
+-PTHREAD_CFLAGS
+ LIBOBJS
+ LTLIBOBJS'
+ ac_subst_files=''
+@@ -22251,430 +22247,6 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS con
+ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+-acx_pthread_ok=no
+-
+-# We used to check for pthread.h first, but this fails if pthread.h
+-# requires special compiler flags (e.g. on True64 or Sequent).
+-# It gets checked for in the link test anyway.
+-
+-# First of all, check if the user has set any of the PTHREAD_LIBS,
+-# etcetera environment variables, and if threads linking works using
+-# them:
+-if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
+- save_CFLAGS="$CFLAGS"
+- CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+- save_LIBS="$LIBS"
+- LIBS="$PTHREAD_LIBS $LIBS"
+- { echo "$as_me:$LINENO: checking for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS" >&5
+-echo $ECHO_N "checking for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS... $ECHO_C" >&6; }
+- cat >conftest.$ac_ext <<_ACEOF
+-/* confdefs.h. */
+-_ACEOF
+-cat confdefs.h >>conftest.$ac_ext
+-cat >>conftest.$ac_ext <<_ACEOF
+-/* end confdefs.h. */
+-
+-/* Override any GCC internal prototype to avoid an error.
+- Use char because int might match the return type of a GCC
+- builtin and then its argument prototype would still apply. */
+-#ifdef __cplusplus
+-extern "C"
+-#endif
+-char pthread_join ();
+-int
+-main ()
+-{
+-return pthread_join ();
+- ;
+- return 0;
+-}
+-_ACEOF
+-rm -f conftest.$ac_objext conftest$ac_exeext
+-if { (ac_try="$ac_link"
+-case "(($ac_try" in
+- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+- *) ac_try_echo=$ac_try;;
+-esac
+-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+- (eval "$ac_link") 2>conftest.er1
+- ac_status=$?
+- grep -v '^ *+' conftest.er1 >conftest.err
+- rm -f conftest.er1
+- cat conftest.err >&5
+- echo "$as_me:$LINENO: \$? = $ac_status" >&5
+- (exit $ac_status); } && {
+- test -z "$ac_c_werror_flag" ||
+- test ! -s conftest.err
+- } && test -s conftest$ac_exeext &&
+- $as_test_x conftest$ac_exeext; then
+- acx_pthread_ok=yes
+-else
+- echo "$as_me: failed program was:" >&5
+-sed 's/^/| /' conftest.$ac_ext >&5
+-
+-
+-fi
+-
+-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+- conftest$ac_exeext conftest.$ac_ext
+- { echo "$as_me:$LINENO: result: $acx_pthread_ok" >&5
+-echo "${ECHO_T}$acx_pthread_ok" >&6; }
+- if test x"$acx_pthread_ok" = xno; then
+- PTHREAD_LIBS=""
+- PTHREAD_CFLAGS=""
+- fi
+- LIBS="$save_LIBS"
+- CFLAGS="$save_CFLAGS"
+-fi
+-
+-# We must check for the threads library under a number of different
+-# names; the ordering is very important because some systems
+-# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
+-# libraries is broken (non-POSIX).
+-
+-# Create a list of thread flags to try. Items starting with a "-" are
+-# C compiler flags, and other items are library names, except for "none"
+-# which indicates that we try without any flags at all, and "pthread-config"
+-# which is a program returning the flags for the Pth emulation library.
+-
+-acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
+-
+-# The ordering *is* (sometimes) important. Some notes on the
+-# individual items follow:
+-
+-# pthreads: AIX (must check this before -lpthread)
+-# none: in case threads are in libc; should be tried before -Kthread and
+-# other compiler flags to prevent continual compiler warnings
+-# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
+-# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
+-# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
+-# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
+-# -pthreads: Solaris/gcc
+-# -mthreads: Mingw32/gcc, Lynx/gcc
+-# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
+-# doesn't hurt to check since this sometimes defines pthreads too;
+-# also defines -D_REENTRANT)
+-# ... -mt is also the pthreads flag for HP/aCC
+-# pthread: Linux, etcetera
+-# --thread-safe: KAI C++
+-# pthread-config: use pthread-config program (for GNU Pth library)
+-
+-case "${host_cpu}-${host_os}" in
+- *solaris*)
+-
+- # On Solaris (at least, for some versions), libc contains stubbed
+- # (non-functional) versions of the pthreads routines, so link-based
+- # tests will erroneously succeed. (We need to link with -pthreads/-mt/
+- # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
+- # a function called by this macro, so we could check for that, but
+- # who knows whether they'll stub that too in a future libc.) So,
+- # we'll just look for -pthreads and -lpthread first:
+-
+- acx_pthread_flags="-pthreads pthread -mt -pthread $acx_pthread_flags"
+- ;;
+-esac
+-
+-if test x"$acx_pthread_ok" = xno; then
+-for flag in $acx_pthread_flags; do
+-
+- case $flag in
+- none)
+- { echo "$as_me:$LINENO: checking whether pthreads work without any flags" >&5
+-echo $ECHO_N "checking whether pthreads work without any flags... $ECHO_C" >&6; }
+- ;;
+-
+- -*)
+- { echo "$as_me:$LINENO: checking whether pthreads work with $flag" >&5
+-echo $ECHO_N "checking whether pthreads work with $flag... $ECHO_C" >&6; }
+- PTHREAD_CFLAGS="$flag"
+- ;;
+-
+- pthread-config)
+- # Extract the first word of "pthread-config", so it can be a program name with args.
+-set dummy pthread-config; ac_word=$2
+-{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+-if test "${ac_cv_prog_acx_pthread_config+set}" = set; then
+- echo $ECHO_N "(cached) $ECHO_C" >&6
+-else
+- if test -n "$acx_pthread_config"; then
+- ac_cv_prog_acx_pthread_config="$acx_pthread_config" # Let the user override the test.
+-else
+-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+-for as_dir in $PATH
+-do
+- IFS=$as_save_IFS
+- test -z "$as_dir" && as_dir=.
+- for ac_exec_ext in '' $ac_executable_extensions; do
+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+- ac_cv_prog_acx_pthread_config="yes"
+- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+- break 2
+- fi
+-done
+-done
+-IFS=$as_save_IFS
+-
+- test -z "$ac_cv_prog_acx_pthread_config" && ac_cv_prog_acx_pthread_config="no"
+-fi
+-fi
+-acx_pthread_config=$ac_cv_prog_acx_pthread_config
+-if test -n "$acx_pthread_config"; then
+- { echo "$as_me:$LINENO: result: $acx_pthread_config" >&5
+-echo "${ECHO_T}$acx_pthread_config" >&6; }
+-else
+- { echo "$as_me:$LINENO: result: no" >&5
+-echo "${ECHO_T}no" >&6; }
+-fi
+-
+-
+- if test x"$acx_pthread_config" = xno; then continue; fi
+- PTHREAD_CFLAGS="`pthread-config --cflags`"
+- PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
+- ;;
+-
+- *)
+- { echo "$as_me:$LINENO: checking for the pthreads library -l$flag" >&5
+-echo $ECHO_N "checking for the pthreads library -l$flag... $ECHO_C" >&6; }
+- PTHREAD_LIBS="-l$flag"
+- ;;
+- esac
+-
+- save_LIBS="$LIBS"
+- save_CFLAGS="$CFLAGS"
+- LIBS="$PTHREAD_LIBS $LIBS"
+- CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+-
+- # Check for various functions. We must include pthread.h,
+- # since some functions may be macros. (On the Sequent, we
+- # need a special flag -Kthread to make this header compile.)
+- # We check for pthread_join because it is in -lpthread on IRIX
+- # while pthread_create is in libc. We check for pthread_attr_init
+- # due to DEC craziness with -lpthreads. We check for
+- # pthread_cleanup_push because it is one of the few pthread
+- # functions on Solaris that doesn't have a non-functional libc stub.
+- # We try pthread_create on general principles.
+- cat >conftest.$ac_ext <<_ACEOF
+-/* confdefs.h. */
+-_ACEOF
+-cat confdefs.h >>conftest.$ac_ext
+-cat >>conftest.$ac_ext <<_ACEOF
+-/* end confdefs.h. */
+-#include <pthread.h>
+-int
+-main ()
+-{
+-pthread_t th; pthread_join(th, 0);
+- pthread_attr_init(0); pthread_cleanup_push(0, 0);
+- pthread_create(0,0,0,0); pthread_cleanup_pop(0);
+- ;
+- return 0;
+-}
+-_ACEOF
+-rm -f conftest.$ac_objext conftest$ac_exeext
+-if { (ac_try="$ac_link"
+-case "(($ac_try" in
+- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+- *) ac_try_echo=$ac_try;;
+-esac
+-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+- (eval "$ac_link") 2>conftest.er1
+- ac_status=$?
+- grep -v '^ *+' conftest.er1 >conftest.err
+- rm -f conftest.er1
+- cat conftest.err >&5
+- echo "$as_me:$LINENO: \$? = $ac_status" >&5
+- (exit $ac_status); } && {
+- test -z "$ac_c_werror_flag" ||
+- test ! -s conftest.err
+- } && test -s conftest$ac_exeext &&
+- $as_test_x conftest$ac_exeext; then
+- acx_pthread_ok=yes
+-else
+- echo "$as_me: failed program was:" >&5
+-sed 's/^/| /' conftest.$ac_ext >&5
+-
+-
+-fi
+-
+-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+- conftest$ac_exeext conftest.$ac_ext
+-
+- LIBS="$save_LIBS"
+- CFLAGS="$save_CFLAGS"
+-
+- { echo "$as_me:$LINENO: result: $acx_pthread_ok" >&5
+-echo "${ECHO_T}$acx_pthread_ok" >&6; }
+- if test "x$acx_pthread_ok" = xyes; then
+- break;
+- fi
+-
+- PTHREAD_LIBS=""
+- PTHREAD_CFLAGS=""
+-done
+-fi
+-
+-# Various other checks:
+-if test "x$acx_pthread_ok" = xyes; then
+- save_LIBS="$LIBS"
+- LIBS="$PTHREAD_LIBS $LIBS"
+- save_CFLAGS="$CFLAGS"
+- CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+-
+- # Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
+- { echo "$as_me:$LINENO: checking for joinable pthread attribute" >&5
+-echo $ECHO_N "checking for joinable pthread attribute... $ECHO_C" >&6; }
+- attr_name=unknown
+- for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
+- cat >conftest.$ac_ext <<_ACEOF
+-/* confdefs.h. */
+-_ACEOF
+-cat confdefs.h >>conftest.$ac_ext
+-cat >>conftest.$ac_ext <<_ACEOF
+-/* end confdefs.h. */
+-#include <pthread.h>
+-int
+-main ()
+-{
+-int attr=$attr; return attr;
+- ;
+- return 0;
+-}
+-_ACEOF
+-rm -f conftest.$ac_objext conftest$ac_exeext
+-if { (ac_try="$ac_link"
+-case "(($ac_try" in
+- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+- *) ac_try_echo=$ac_try;;
+-esac
+-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+- (eval "$ac_link") 2>conftest.er1
+- ac_status=$?
+- grep -v '^ *+' conftest.er1 >conftest.err
+- rm -f conftest.er1
+- cat conftest.err >&5
+- echo "$as_me:$LINENO: \$? = $ac_status" >&5
+- (exit $ac_status); } && {
+- test -z "$ac_c_werror_flag" ||
+- test ! -s conftest.err
+- } && test -s conftest$ac_exeext &&
+- $as_test_x conftest$ac_exeext; then
+- attr_name=$attr; break
+-else
+- echo "$as_me: failed program was:" >&5
+-sed 's/^/| /' conftest.$ac_ext >&5
+-
+-
+-fi
+-
+-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+- conftest$ac_exeext conftest.$ac_ext
+- done
+- { echo "$as_me:$LINENO: result: $attr_name" >&5
+-echo "${ECHO_T}$attr_name" >&6; }
+- if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
+-
+-cat >>confdefs.h <<_ACEOF
+-#define PTHREAD_CREATE_JOINABLE $attr_name
+-_ACEOF
+-
+- fi
+-
+- { echo "$as_me:$LINENO: checking if more special flags are required for pthreads" >&5
+-echo $ECHO_N "checking if more special flags are required for pthreads... $ECHO_C" >&6; }
+- flag=no
+- case "${host_cpu}-${host_os}" in
+- *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";;
+- *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";;
+- esac
+- { echo "$as_me:$LINENO: result: ${flag}" >&5
+-echo "${ECHO_T}${flag}" >&6; }
+- if test "x$flag" != xno; then
+- PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
+- fi
+-
+- LIBS="$save_LIBS"
+- CFLAGS="$save_CFLAGS"
+-
+- # More AIX lossage: must compile with xlc_r or cc_r
+- if test x"$GCC" != xyes; then
+- for ac_prog in xlc_r cc_r
+-do
+- # Extract the first word of "$ac_prog", so it can be a program name with args.
+-set dummy $ac_prog; ac_word=$2
+-{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+-if test "${ac_cv_prog_PTHREAD_CC+set}" = set; then
+- echo $ECHO_N "(cached) $ECHO_C" >&6
+-else
+- if test -n "$PTHREAD_CC"; then
+- ac_cv_prog_PTHREAD_CC="$PTHREAD_CC" # Let the user override the test.
+-else
+-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+-for as_dir in $PATH
+-do
+- IFS=$as_save_IFS
+- test -z "$as_dir" && as_dir=.
+- for ac_exec_ext in '' $ac_executable_extensions; do
+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+- ac_cv_prog_PTHREAD_CC="$ac_prog"
+- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+- break 2
+- fi
+-done
+-done
+-IFS=$as_save_IFS
+-
+-fi
+-fi
+-PTHREAD_CC=$ac_cv_prog_PTHREAD_CC
+-if test -n "$PTHREAD_CC"; then
+- { echo "$as_me:$LINENO: result: $PTHREAD_CC" >&5
+-echo "${ECHO_T}$PTHREAD_CC" >&6; }
+-else
+- { echo "$as_me:$LINENO: result: no" >&5
+-echo "${ECHO_T}no" >&6; }
+-fi
+-
+-
+- test -n "$PTHREAD_CC" && break
+-done
+-test -n "$PTHREAD_CC" || PTHREAD_CC="${CC}"
+-
+- else
+- PTHREAD_CC=$CC
+- fi
+-else
+- PTHREAD_CC="$CC"
+-fi
+-
+-
+-
+-
+-
+-# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
+-if test x"$acx_pthread_ok" = xyes; then
+-
+-cat >>confdefs.h <<\_ACEOF
+-#define HAVE_PTHREAD 1
+-_ACEOF
+-
+- :
+-else
+- acx_pthread_ok=no
+-
+-fi
+-ac_ext=c
+-ac_cpp='$CPP $CPPFLAGS'
+-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+-ac_compiler_gnu=$ac_cv_c_compiler_gnu
+-
+-
+-
+-LIBS="$PTHREAD_LIBS $LIBS"
+-CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+-
+
+ { echo "$as_me:$LINENO: checking for library containing gethostbyname" >&5
+ echo $ECHO_N "checking for library containing gethostbyname... $ECHO_C" >&6; }
diff --git a/package/libs/cyassl/patches/.svn/text-base/200-SSL_accept-handle-hello-garbage.patch.svn-base b/package/libs/cyassl/patches/.svn/text-base/200-SSL_accept-handle-hello-garbage.patch.svn-base
new file mode 100644
index 0000000..4a6b8da
--- /dev/null
+++ b/package/libs/cyassl/patches/.svn/text-base/200-SSL_accept-handle-hello-garbage.patch.svn-base
@@ -0,0 +1,13 @@
+--- a/src/cyassl_int.c
++++ b/src/cyassl_int.c
+@@ -1588,6 +1588,10 @@
+ b1 =
+ ssl->buffers.inputBuffer.buffer[ssl->buffers.inputBuffer.idx++];
+ ssl->curSize = ((b0 & 0x7f) << 8) | b1;
++
++ /* does not appear to a be a SSLv2 client hello */
++ if ( ssl->buffers.inputBuffer.buffer[ssl->buffers.inputBuffer.idx] != 1 )
++ return UNKNOWN_HANDSHAKE_TYPE;
+ }
+ else {
+ ssl->options.processReply = getRecordLayerHeader;
diff --git a/package/libs/cyassl/patches/110-makefile_disable_examples_tests.patch b/package/libs/cyassl/patches/110-makefile_disable_examples_tests.patch
new file mode 100644
index 0000000..c66ab8c
--- /dev/null
+++ b/package/libs/cyassl/patches/110-makefile_disable_examples_tests.patch
@@ -0,0 +1,46 @@
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -1,4 +1,4 @@
+-SUBDIRS = src ctaocrypt examples testsuite sslSniffer
++SUBDIRS = src ctaocrypt
+ EXTRA_DIST = cyassl.dsp cyassl.dsw certs/*.pem certs/*.der certs/*.txt \
+ lib/dummy cyassl.sln cyassl.vcproj cyassl-iphone.xcodeproj/project.pbxproj \
+ doc/*.pdf swig/README swig/*.i swig/cyassl_adds.c swig/*.sh swig/runme.* \
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -193,7 +193,7 @@ target_os = @target_os@
+ target_vendor = @target_vendor@
+ top_builddir = @top_builddir@
+ top_srcdir = @top_srcdir@
+-SUBDIRS = src ctaocrypt examples testsuite sslSniffer
++SUBDIRS = src ctaocrypt
+ EXTRA_DIST = cyassl.dsp cyassl.dsw certs/*.pem certs/*.der certs/*.txt \
+ lib/dummy cyassl.sln cyassl.vcproj cyassl-iphone.xcodeproj/project.pbxproj \
+ doc/*.pdf swig/README swig/*.i swig/cyassl_adds.c swig/*.sh swig/runme.* \
+@@ -643,7 +643,7 @@ uninstall-am:
+
+ # !!!! first line of rule has to start with a hard (real) tab, not spaces
+ basic:
+- cd src; $(MAKE); cd ../testsuite; $(MAKE); cd ../
++ cd src; $(MAKE); cd ../
+
+ openssl-links:
+ cd lib; ln -s ../src/.libs/libcyassl.a libcrypto.a; \
+--- a/ctaocrypt/Makefile.am
++++ b/ctaocrypt/Makefile.am
+@@ -1,3 +1,3 @@
+-SUBDIRS = src test benchmark
++SUBDIRS = src
+ EXTRA_DIST = ctaocrypt.dsw ctaocrypt.dsp ctaocrypt.sln ctaocrypt.vcproj
+
+--- a/ctaocrypt/Makefile.in
++++ b/ctaocrypt/Makefile.in
+@@ -177,7 +177,7 @@ target_os = @target_os@
+ target_vendor = @target_vendor@
+ top_builddir = @top_builddir@
+ top_srcdir = @top_srcdir@
+-SUBDIRS = src test benchmark
++SUBDIRS = src
+ EXTRA_DIST = ctaocrypt.dsw ctaocrypt.dsp ctaocrypt.sln ctaocrypt.vcproj
+ all: all-recursive
+
diff --git a/package/libs/cyassl/patches/120-makefile_destdir.patch b/package/libs/cyassl/patches/120-makefile_destdir.patch
new file mode 100644
index 0000000..bf20274
--- /dev/null
+++ b/package/libs/cyassl/patches/120-makefile_destdir.patch
@@ -0,0 +1,71 @@
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -10,19 +10,19 @@ basic:
+
+ openssl-links:
+ cd lib; ln -s ../src/.libs/libcyassl.a libcrypto.a; \
+- ln -s ../src/.libs/libcyassl.a libssl.a; \
+- ln -s ../src/.libs/libcyassl.a libcyassl.a; cd ../
++ ln -s ../src/.libs/libcyassl.a libssl.a; \
++ ln -s ../src/.libs/libcyassl.a libcyassl.a; cd ../
+
+ # !!! test -e with a .name like .libs then a * like *dylib fails so just
+ # look for the .dylib on OS X, and .so otherwise but copy all parts
+ install:
+- $(mkinstalldirs) $(DESTDIR)$(includedir) $(DESTDIR)$(libdir); \
+- cp -fpR include/* $(DESTDIR)$(includedir); \
+- cp -fpR ctaocrypt/include/* $(DESTDIR)$(includedir); \
+- cp -fpR src/libcyassl.la $(DESTDIR)$(libdir); \
+- if test -e src/.libs/libcyassl.a; then \
+- cp -fp src/.libs/libcyassl.a $(DESTDIR)$(libdir); fi; \
+- if test -e src/.libs/libcyassl.so; then \
+- cp -fpR src/.libs/libcyassl.so* $(DESTDIR)$(libdir); fi; \
+- if test -e src/.libs/libcyassl.dylib; then \
+- cp -fpR src/.libs/libcyassl.*dylib $(DESTDIR)$(libdir); fi;
++ $(mkinstalldirs) $(DESTDIR)$(includedir)/cyassl $(DESTDIR)$(libdir); \
++ cp -fpR include/* $(DESTDIR)$(includedir)/cyassl; \
++ cp -fpR ctaocrypt/include/* $(DESTDIR)$(includedir)/cyassl; \
++ cp -fpR src/libcyassl.la $(DESTDIR)$(libdir); \
++ if test -e src/.libs/libcyassl.a; then \
++ cp -fp src/.libs/libcyassl.a $(DESTDIR)$(libdir); fi; \
++ if test -e src/.libs/libcyassl.so; then \
++ cp -fpR src/.libs/libcyassl.so* $(DESTDIR)$(libdir); fi; \
++ if test -e src/.libs/libcyassl.dylib; then \
++ cp -fpR src/.libs/libcyassl.*dylib $(DESTDIR)$(libdir); fi;
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -647,22 +647,22 @@ basic:
+
+ openssl-links:
+ cd lib; ln -s ../src/.libs/libcyassl.a libcrypto.a; \
+- ln -s ../src/.libs/libcyassl.a libssl.a; \
+- ln -s ../src/.libs/libcyassl.a libcyassl.a; cd ../
++ ln -s ../src/.libs/libcyassl.a libssl.a; \
++ ln -s ../src/.libs/libcyassl.a libcyassl.a; cd ../
+
+ # !!! test -e with a .name like .libs then a * like *dylib fails so just
+ # look for the .dylib on OS X, and .so otherwise but copy all parts
+ install:
+- $(mkinstalldirs) $(DESTDIR)$(includedir) $(DESTDIR)$(libdir); \
+- cp -fpR include/* $(DESTDIR)$(includedir); \
+- cp -fpR ctaocrypt/include/* $(DESTDIR)$(includedir); \
+- cp -fpR src/libcyassl.la $(DESTDIR)$(libdir); \
+- if test -e src/.libs/libcyassl.a; then \
+- cp -fp src/.libs/libcyassl.a $(DESTDIR)$(libdir); fi; \
+- if test -e src/.libs/libcyassl.so; then \
+- cp -fpR src/.libs/libcyassl.so* $(DESTDIR)$(libdir); fi; \
+- if test -e src/.libs/libcyassl.dylib; then \
+- cp -fpR src/.libs/libcyassl.*dylib $(DESTDIR)$(libdir); fi;
++ $(mkinstalldirs) $(DESTDIR)$(includedir)/cyassl $(DESTDIR)$(libdir); \
++ cp -fpR include/* $(DESTDIR)$(includedir)/cyassl; \
++ cp -fpR ctaocrypt/include/* $(DESTDIR)$(includedir)/cyassl; \
++ cp -fpR src/libcyassl.la $(DESTDIR)$(libdir); \
++ if test -e src/.libs/libcyassl.a; then \
++ cp -fp src/.libs/libcyassl.a $(DESTDIR)$(libdir); fi; \
++ if test -e src/.libs/libcyassl.so; then \
++ cp -fpR src/.libs/libcyassl.so* $(DESTDIR)$(libdir); fi; \
++ if test -e src/.libs/libcyassl.dylib; then \
++ cp -fpR src/.libs/libcyassl.*dylib $(DESTDIR)$(libdir); fi;
+ # Tell versions [3.59,3.63) of GNU make to not export all variables.
+ # Otherwise a system limit (for SysV at least) may be exceeded.
+ .NOEXPORT:
diff --git a/package/libs/cyassl/patches/130-configure_disable_pthreads_tests.patch b/package/libs/cyassl/patches/130-configure_disable_pthreads_tests.patch
new file mode 100644
index 0000000..44fdf6c
--- /dev/null
+++ b/package/libs/cyassl/patches/130-configure_disable_pthreads_tests.patch
@@ -0,0 +1,444 @@
+--- a/configure
++++ b/configure
+@@ -888,10 +888,6 @@ BUILD_RIPEMD_TRUE
+ BUILD_RIPEMD_FALSE
+ BUILD_SHA512_TRUE
+ BUILD_SHA512_FALSE
+-acx_pthread_config
+-PTHREAD_CC
+-PTHREAD_LIBS
+-PTHREAD_CFLAGS
+ LIBOBJS
+ LTLIBOBJS'
+ ac_subst_files=''
+@@ -22251,430 +22247,6 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS con
+ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+-acx_pthread_ok=no
+-
+-# We used to check for pthread.h first, but this fails if pthread.h
+-# requires special compiler flags (e.g. on True64 or Sequent).
+-# It gets checked for in the link test anyway.
+-
+-# First of all, check if the user has set any of the PTHREAD_LIBS,
+-# etcetera environment variables, and if threads linking works using
+-# them:
+-if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
+- save_CFLAGS="$CFLAGS"
+- CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+- save_LIBS="$LIBS"
+- LIBS="$PTHREAD_LIBS $LIBS"
+- { echo "$as_me:$LINENO: checking for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS" >&5
+-echo $ECHO_N "checking for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS... $ECHO_C" >&6; }
+- cat >conftest.$ac_ext <<_ACEOF
+-/* confdefs.h. */
+-_ACEOF
+-cat confdefs.h >>conftest.$ac_ext
+-cat >>conftest.$ac_ext <<_ACEOF
+-/* end confdefs.h. */
+-
+-/* Override any GCC internal prototype to avoid an error.
+- Use char because int might match the return type of a GCC
+- builtin and then its argument prototype would still apply. */
+-#ifdef __cplusplus
+-extern "C"
+-#endif
+-char pthread_join ();
+-int
+-main ()
+-{
+-return pthread_join ();
+- ;
+- return 0;
+-}
+-_ACEOF
+-rm -f conftest.$ac_objext conftest$ac_exeext
+-if { (ac_try="$ac_link"
+-case "(($ac_try" in
+- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+- *) ac_try_echo=$ac_try;;
+-esac
+-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+- (eval "$ac_link") 2>conftest.er1
+- ac_status=$?
+- grep -v '^ *+' conftest.er1 >conftest.err
+- rm -f conftest.er1
+- cat conftest.err >&5
+- echo "$as_me:$LINENO: \$? = $ac_status" >&5
+- (exit $ac_status); } && {
+- test -z "$ac_c_werror_flag" ||
+- test ! -s conftest.err
+- } && test -s conftest$ac_exeext &&
+- $as_test_x conftest$ac_exeext; then
+- acx_pthread_ok=yes
+-else
+- echo "$as_me: failed program was:" >&5
+-sed 's/^/| /' conftest.$ac_ext >&5
+-
+-
+-fi
+-
+-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+- conftest$ac_exeext conftest.$ac_ext
+- { echo "$as_me:$LINENO: result: $acx_pthread_ok" >&5
+-echo "${ECHO_T}$acx_pthread_ok" >&6; }
+- if test x"$acx_pthread_ok" = xno; then
+- PTHREAD_LIBS=""
+- PTHREAD_CFLAGS=""
+- fi
+- LIBS="$save_LIBS"
+- CFLAGS="$save_CFLAGS"
+-fi
+-
+-# We must check for the threads library under a number of different
+-# names; the ordering is very important because some systems
+-# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
+-# libraries is broken (non-POSIX).
+-
+-# Create a list of thread flags to try. Items starting with a "-" are
+-# C compiler flags, and other items are library names, except for "none"
+-# which indicates that we try without any flags at all, and "pthread-config"
+-# which is a program returning the flags for the Pth emulation library.
+-
+-acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
+-
+-# The ordering *is* (sometimes) important. Some notes on the
+-# individual items follow:
+-
+-# pthreads: AIX (must check this before -lpthread)
+-# none: in case threads are in libc; should be tried before -Kthread and
+-# other compiler flags to prevent continual compiler warnings
+-# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
+-# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
+-# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
+-# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
+-# -pthreads: Solaris/gcc
+-# -mthreads: Mingw32/gcc, Lynx/gcc
+-# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
+-# doesn't hurt to check since this sometimes defines pthreads too;
+-# also defines -D_REENTRANT)
+-# ... -mt is also the pthreads flag for HP/aCC
+-# pthread: Linux, etcetera
+-# --thread-safe: KAI C++
+-# pthread-config: use pthread-config program (for GNU Pth library)
+-
+-case "${host_cpu}-${host_os}" in
+- *solaris*)
+-
+- # On Solaris (at least, for some versions), libc contains stubbed
+- # (non-functional) versions of the pthreads routines, so link-based
+- # tests will erroneously succeed. (We need to link with -pthreads/-mt/
+- # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
+- # a function called by this macro, so we could check for that, but
+- # who knows whether they'll stub that too in a future libc.) So,
+- # we'll just look for -pthreads and -lpthread first:
+-
+- acx_pthread_flags="-pthreads pthread -mt -pthread $acx_pthread_flags"
+- ;;
+-esac
+-
+-if test x"$acx_pthread_ok" = xno; then
+-for flag in $acx_pthread_flags; do
+-
+- case $flag in
+- none)
+- { echo "$as_me:$LINENO: checking whether pthreads work without any flags" >&5
+-echo $ECHO_N "checking whether pthreads work without any flags... $ECHO_C" >&6; }
+- ;;
+-
+- -*)
+- { echo "$as_me:$LINENO: checking whether pthreads work with $flag" >&5
+-echo $ECHO_N "checking whether pthreads work with $flag... $ECHO_C" >&6; }
+- PTHREAD_CFLAGS="$flag"
+- ;;
+-
+- pthread-config)
+- # Extract the first word of "pthread-config", so it can be a program name with args.
+-set dummy pthread-config; ac_word=$2
+-{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+-if test "${ac_cv_prog_acx_pthread_config+set}" = set; then
+- echo $ECHO_N "(cached) $ECHO_C" >&6
+-else
+- if test -n "$acx_pthread_config"; then
+- ac_cv_prog_acx_pthread_config="$acx_pthread_config" # Let the user override the test.
+-else
+-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+-for as_dir in $PATH
+-do
+- IFS=$as_save_IFS
+- test -z "$as_dir" && as_dir=.
+- for ac_exec_ext in '' $ac_executable_extensions; do
+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+- ac_cv_prog_acx_pthread_config="yes"
+- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+- break 2
+- fi
+-done
+-done
+-IFS=$as_save_IFS
+-
+- test -z "$ac_cv_prog_acx_pthread_config" && ac_cv_prog_acx_pthread_config="no"
+-fi
+-fi
+-acx_pthread_config=$ac_cv_prog_acx_pthread_config
+-if test -n "$acx_pthread_config"; then
+- { echo "$as_me:$LINENO: result: $acx_pthread_config" >&5
+-echo "${ECHO_T}$acx_pthread_config" >&6; }
+-else
+- { echo "$as_me:$LINENO: result: no" >&5
+-echo "${ECHO_T}no" >&6; }
+-fi
+-
+-
+- if test x"$acx_pthread_config" = xno; then continue; fi
+- PTHREAD_CFLAGS="`pthread-config --cflags`"
+- PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
+- ;;
+-
+- *)
+- { echo "$as_me:$LINENO: checking for the pthreads library -l$flag" >&5
+-echo $ECHO_N "checking for the pthreads library -l$flag... $ECHO_C" >&6; }
+- PTHREAD_LIBS="-l$flag"
+- ;;
+- esac
+-
+- save_LIBS="$LIBS"
+- save_CFLAGS="$CFLAGS"
+- LIBS="$PTHREAD_LIBS $LIBS"
+- CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+-
+- # Check for various functions. We must include pthread.h,
+- # since some functions may be macros. (On the Sequent, we
+- # need a special flag -Kthread to make this header compile.)
+- # We check for pthread_join because it is in -lpthread on IRIX
+- # while pthread_create is in libc. We check for pthread_attr_init
+- # due to DEC craziness with -lpthreads. We check for
+- # pthread_cleanup_push because it is one of the few pthread
+- # functions on Solaris that doesn't have a non-functional libc stub.
+- # We try pthread_create on general principles.
+- cat >conftest.$ac_ext <<_ACEOF
+-/* confdefs.h. */
+-_ACEOF
+-cat confdefs.h >>conftest.$ac_ext
+-cat >>conftest.$ac_ext <<_ACEOF
+-/* end confdefs.h. */
+-#include <pthread.h>
+-int
+-main ()
+-{
+-pthread_t th; pthread_join(th, 0);
+- pthread_attr_init(0); pthread_cleanup_push(0, 0);
+- pthread_create(0,0,0,0); pthread_cleanup_pop(0);
+- ;
+- return 0;
+-}
+-_ACEOF
+-rm -f conftest.$ac_objext conftest$ac_exeext
+-if { (ac_try="$ac_link"
+-case "(($ac_try" in
+- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+- *) ac_try_echo=$ac_try;;
+-esac
+-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+- (eval "$ac_link") 2>conftest.er1
+- ac_status=$?
+- grep -v '^ *+' conftest.er1 >conftest.err
+- rm -f conftest.er1
+- cat conftest.err >&5
+- echo "$as_me:$LINENO: \$? = $ac_status" >&5
+- (exit $ac_status); } && {
+- test -z "$ac_c_werror_flag" ||
+- test ! -s conftest.err
+- } && test -s conftest$ac_exeext &&
+- $as_test_x conftest$ac_exeext; then
+- acx_pthread_ok=yes
+-else
+- echo "$as_me: failed program was:" >&5
+-sed 's/^/| /' conftest.$ac_ext >&5
+-
+-
+-fi
+-
+-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+- conftest$ac_exeext conftest.$ac_ext
+-
+- LIBS="$save_LIBS"
+- CFLAGS="$save_CFLAGS"
+-
+- { echo "$as_me:$LINENO: result: $acx_pthread_ok" >&5
+-echo "${ECHO_T}$acx_pthread_ok" >&6; }
+- if test "x$acx_pthread_ok" = xyes; then
+- break;
+- fi
+-
+- PTHREAD_LIBS=""
+- PTHREAD_CFLAGS=""
+-done
+-fi
+-
+-# Various other checks:
+-if test "x$acx_pthread_ok" = xyes; then
+- save_LIBS="$LIBS"
+- LIBS="$PTHREAD_LIBS $LIBS"
+- save_CFLAGS="$CFLAGS"
+- CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+-
+- # Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
+- { echo "$as_me:$LINENO: checking for joinable pthread attribute" >&5
+-echo $ECHO_N "checking for joinable pthread attribute... $ECHO_C" >&6; }
+- attr_name=unknown
+- for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
+- cat >conftest.$ac_ext <<_ACEOF
+-/* confdefs.h. */
+-_ACEOF
+-cat confdefs.h >>conftest.$ac_ext
+-cat >>conftest.$ac_ext <<_ACEOF
+-/* end confdefs.h. */
+-#include <pthread.h>
+-int
+-main ()
+-{
+-int attr=$attr; return attr;
+- ;
+- return 0;
+-}
+-_ACEOF
+-rm -f conftest.$ac_objext conftest$ac_exeext
+-if { (ac_try="$ac_link"
+-case "(($ac_try" in
+- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+- *) ac_try_echo=$ac_try;;
+-esac
+-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+- (eval "$ac_link") 2>conftest.er1
+- ac_status=$?
+- grep -v '^ *+' conftest.er1 >conftest.err
+- rm -f conftest.er1
+- cat conftest.err >&5
+- echo "$as_me:$LINENO: \$? = $ac_status" >&5
+- (exit $ac_status); } && {
+- test -z "$ac_c_werror_flag" ||
+- test ! -s conftest.err
+- } && test -s conftest$ac_exeext &&
+- $as_test_x conftest$ac_exeext; then
+- attr_name=$attr; break
+-else
+- echo "$as_me: failed program was:" >&5
+-sed 's/^/| /' conftest.$ac_ext >&5
+-
+-
+-fi
+-
+-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+- conftest$ac_exeext conftest.$ac_ext
+- done
+- { echo "$as_me:$LINENO: result: $attr_name" >&5
+-echo "${ECHO_T}$attr_name" >&6; }
+- if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
+-
+-cat >>confdefs.h <<_ACEOF
+-#define PTHREAD_CREATE_JOINABLE $attr_name
+-_ACEOF
+-
+- fi
+-
+- { echo "$as_me:$LINENO: checking if more special flags are required for pthreads" >&5
+-echo $ECHO_N "checking if more special flags are required for pthreads... $ECHO_C" >&6; }
+- flag=no
+- case "${host_cpu}-${host_os}" in
+- *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";;
+- *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";;
+- esac
+- { echo "$as_me:$LINENO: result: ${flag}" >&5
+-echo "${ECHO_T}${flag}" >&6; }
+- if test "x$flag" != xno; then
+- PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
+- fi
+-
+- LIBS="$save_LIBS"
+- CFLAGS="$save_CFLAGS"
+-
+- # More AIX lossage: must compile with xlc_r or cc_r
+- if test x"$GCC" != xyes; then
+- for ac_prog in xlc_r cc_r
+-do
+- # Extract the first word of "$ac_prog", so it can be a program name with args.
+-set dummy $ac_prog; ac_word=$2
+-{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+-if test "${ac_cv_prog_PTHREAD_CC+set}" = set; then
+- echo $ECHO_N "(cached) $ECHO_C" >&6
+-else
+- if test -n "$PTHREAD_CC"; then
+- ac_cv_prog_PTHREAD_CC="$PTHREAD_CC" # Let the user override the test.
+-else
+-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+-for as_dir in $PATH
+-do
+- IFS=$as_save_IFS
+- test -z "$as_dir" && as_dir=.
+- for ac_exec_ext in '' $ac_executable_extensions; do
+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+- ac_cv_prog_PTHREAD_CC="$ac_prog"
+- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+- break 2
+- fi
+-done
+-done
+-IFS=$as_save_IFS
+-
+-fi
+-fi
+-PTHREAD_CC=$ac_cv_prog_PTHREAD_CC
+-if test -n "$PTHREAD_CC"; then
+- { echo "$as_me:$LINENO: result: $PTHREAD_CC" >&5
+-echo "${ECHO_T}$PTHREAD_CC" >&6; }
+-else
+- { echo "$as_me:$LINENO: result: no" >&5
+-echo "${ECHO_T}no" >&6; }
+-fi
+-
+-
+- test -n "$PTHREAD_CC" && break
+-done
+-test -n "$PTHREAD_CC" || PTHREAD_CC="${CC}"
+-
+- else
+- PTHREAD_CC=$CC
+- fi
+-else
+- PTHREAD_CC="$CC"
+-fi
+-
+-
+-
+-
+-
+-# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
+-if test x"$acx_pthread_ok" = xyes; then
+-
+-cat >>confdefs.h <<\_ACEOF
+-#define HAVE_PTHREAD 1
+-_ACEOF
+-
+- :
+-else
+- acx_pthread_ok=no
+-
+-fi
+-ac_ext=c
+-ac_cpp='$CPP $CPPFLAGS'
+-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+-ac_compiler_gnu=$ac_cv_c_compiler_gnu
+-
+-
+-
+-LIBS="$PTHREAD_LIBS $LIBS"
+-CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+-
+
+ { echo "$as_me:$LINENO: checking for library containing gethostbyname" >&5
+ echo $ECHO_N "checking for library containing gethostbyname... $ECHO_C" >&6; }
diff --git a/package/libs/cyassl/patches/200-SSL_accept-handle-hello-garbage.patch b/package/libs/cyassl/patches/200-SSL_accept-handle-hello-garbage.patch
new file mode 100644
index 0000000..4a6b8da
--- /dev/null
+++ b/package/libs/cyassl/patches/200-SSL_accept-handle-hello-garbage.patch
@@ -0,0 +1,13 @@
+--- a/src/cyassl_int.c
++++ b/src/cyassl_int.c
+@@ -1588,6 +1588,10 @@
+ b1 =
+ ssl->buffers.inputBuffer.buffer[ssl->buffers.inputBuffer.idx++];
+ ssl->curSize = ((b0 & 0x7f) << 8) | b1;
++
++ /* does not appear to a be a SSLv2 client hello */
++ if ( ssl->buffers.inputBuffer.buffer[ssl->buffers.inputBuffer.idx] != 1 )
++ return UNKNOWN_HANDSHAKE_TYPE;
+ }
+ else {
+ ssl->options.processReply = getRecordLayerHeader;
diff --git a/package/libs/gettext-full/.svn/entries b/package/libs/gettext-full/.svn/entries
new file mode 100644
index 0000000..ccb1f17
--- /dev/null
+++ b/package/libs/gettext-full/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs/gettext-full
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-11-28T21:02:53.817637Z
+34400
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+fea14a0df199dbbbc07d3eef65ae2145
+2012-11-28T21:02:53.817637Z
+34400
+jow
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1796
+
diff --git a/package/libs/gettext-full/.svn/prop-base/Makefile.svn-base b/package/libs/gettext-full/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..4179626
--- /dev/null
+++ b/package/libs/gettext-full/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,9 @@
+K 9
+copyright
+V 30
+Copyright (C) 2006 OpenWrt.org
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/libs/gettext-full/.svn/text-base/Makefile.svn-base b/package/libs/gettext-full/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..3444e6b
--- /dev/null
+++ b/package/libs/gettext-full/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,72 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=gettext-full
+PKG_VERSION:=0.18.1.1
+PKG_RELEASE:=2
+
+PKG_SOURCE:=gettext-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=@GNU/gettext
+PKG_MD5SUM:=3dd55b952826d2b32f51308f2f91aa89
+PKG_BUILD_DIR:=$(BUILD_DIR)/gettext-$(PKG_VERSION)
+HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/gettext-$(PKG_VERSION)
+
+PKG_MAINTAINER:=Jo-Philipp Wich <jow@openwrt.org>
+
+PKG_FIXUP:=autoreconf
+PKG_INSTALL:=1
+PKG_BUILD_PARALLEL:=0
+PKG_BUILD_DEPENDS:=gettext-full/host
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/host-build.mk
+
+define Package/libintl-full
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=GNU Internationalization library
+ URL:=http://www.gnu.org/software/gettext/
+endef
+
+TARGET_CFLAGS += $(FPIC)
+
+CONFIGURE_ARGS += \
+ --enable-shared \
+ --enable-static \
+ --disable-rpath \
+ --enable-nls \
+ --disable-java \
+ --disable-native-java \
+ --disable-openmp \
+ --with-included-gettext \
+ --without-libintl-prefix \
+ --without-libexpat-prefix \
+ --without-emacs
+
+HOST_CONFIGURE_ARGS += \
+ --with-included-libxml
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/lib/libintl-full/include
+ $(CP) $(PKG_INSTALL_DIR)/usr/include/libintl.h $(1)/usr/lib/libintl-full/include/
+
+ $(INSTALL_DIR) $(1)/usr/lib/libintl-full/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libintl.{a,so*} $(1)/usr/lib/libintl-full/lib/
+
+ $(INSTALL_DIR) $(1)/usr/share/aclocal
+ $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/share/aclocal/* $(1)/usr/share/aclocal/
+endef
+
+define Package/libintl-full/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libintl.so* $(1)/usr/lib/
+endef
+
+$(eval $(call HostBuild))
+$(eval $(call BuildPackage,libintl-full))
diff --git a/package/libs/gettext-full/Makefile b/package/libs/gettext-full/Makefile
new file mode 100644
index 0000000..3444e6b
--- /dev/null
+++ b/package/libs/gettext-full/Makefile
@@ -0,0 +1,72 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=gettext-full
+PKG_VERSION:=0.18.1.1
+PKG_RELEASE:=2
+
+PKG_SOURCE:=gettext-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=@GNU/gettext
+PKG_MD5SUM:=3dd55b952826d2b32f51308f2f91aa89
+PKG_BUILD_DIR:=$(BUILD_DIR)/gettext-$(PKG_VERSION)
+HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/gettext-$(PKG_VERSION)
+
+PKG_MAINTAINER:=Jo-Philipp Wich <jow@openwrt.org>
+
+PKG_FIXUP:=autoreconf
+PKG_INSTALL:=1
+PKG_BUILD_PARALLEL:=0
+PKG_BUILD_DEPENDS:=gettext-full/host
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/host-build.mk
+
+define Package/libintl-full
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=GNU Internationalization library
+ URL:=http://www.gnu.org/software/gettext/
+endef
+
+TARGET_CFLAGS += $(FPIC)
+
+CONFIGURE_ARGS += \
+ --enable-shared \
+ --enable-static \
+ --disable-rpath \
+ --enable-nls \
+ --disable-java \
+ --disable-native-java \
+ --disable-openmp \
+ --with-included-gettext \
+ --without-libintl-prefix \
+ --without-libexpat-prefix \
+ --without-emacs
+
+HOST_CONFIGURE_ARGS += \
+ --with-included-libxml
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/lib/libintl-full/include
+ $(CP) $(PKG_INSTALL_DIR)/usr/include/libintl.h $(1)/usr/lib/libintl-full/include/
+
+ $(INSTALL_DIR) $(1)/usr/lib/libintl-full/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libintl.{a,so*} $(1)/usr/lib/libintl-full/lib/
+
+ $(INSTALL_DIR) $(1)/usr/share/aclocal
+ $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/share/aclocal/* $(1)/usr/share/aclocal/
+endef
+
+define Package/libintl-full/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libintl.so* $(1)/usr/lib/
+endef
+
+$(eval $(call HostBuild))
+$(eval $(call BuildPackage,libintl-full))
diff --git a/package/libs/gettext-full/patches/.svn/entries b/package/libs/gettext-full/patches/.svn/entries
new file mode 100644
index 0000000..0e1cac9
--- /dev/null
+++ b/package/libs/gettext-full/patches/.svn/entries
@@ -0,0 +1,334 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs/gettext-full/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-09-13T14:42:54.965653Z
+33394
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+001-autotools.patch
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+3c8ef5a257d791052aa9de161636cd67
+2010-12-15T19:04:55.456377Z
+24608
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1211
+
+005-uclibc-0.9.30-compat.patch
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+d636049813a3da444e7b12958b18f504
+2011-02-06T16:47:41.129507Z
+25389
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+994
+
+120-uclibc-nolocale.patch
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+24cf77136f25b09f4e40138207ae2d8a
+2010-12-06T22:18:30.534861Z
+24290
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+650
+
+150-disable_libxml_iconv.patch
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+f71f2fd611eea71fae9fc0e5b9f6f390
+2010-12-06T22:18:30.534861Z
+24290
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+526
+
+160-eglibc_stdio.patch
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+89a7c020799e8bc861555b8bb6ac46eb
+2012-09-13T14:42:54.965653Z
+33394
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1301
+
+001-no_examples_and_tests.patch
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+88a92d3539a9a7939d641716e68c9480
+2010-12-06T22:18:30.534861Z
+24290
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+956
+
+003-gettext-error_print_progname.patch
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+ae8b373eb1d58292791a58067d37f1b0
+2010-12-06T22:48:51.742782Z
+24291
+acoul
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+540
+
+100-error_progname.patch
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+5f460d977790e72682acef9814440b9f
+2010-12-06T22:48:51.742782Z
+24291
+acoul
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+300
+
+004-gnulib-uclibc-sched_param-def.patch
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+d5ad070d919fe7e8f866dff08de8a251
+2010-12-06T22:48:51.742782Z
+24291
+acoul
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+575
+
diff --git a/package/libs/gettext-full/patches/.svn/text-base/001-autotools.patch.svn-base b/package/libs/gettext-full/patches/.svn/text-base/001-autotools.patch.svn-base
new file mode 100644
index 0000000..bf44fcb
--- /dev/null
+++ b/package/libs/gettext-full/patches/.svn/text-base/001-autotools.patch.svn-base
@@ -0,0 +1,35 @@
+--- a/gettext-runtime/man/Makefile.am
++++ b/gettext-runtime/man/Makefile.am
+@@ -159,8 +159,7 @@ bind_textdomain_codeset.3.html: bind_tex
+ $(MAN2HTML) $(srcdir)/bind_textdomain_codeset.3.in | sed -e '/CreationDate:/d' > t-$@
+ mv t-$@ $@
+
+-install-html-local:
+- $(mkdir_p) $(DESTDIR)$(htmldir)
++install-html: installdirs-html
+ for file in $(man_HTML); do \
+ if test -f $$file; then dir=.; else dir=$(srcdir); fi; \
+ $(INSTALL_DATA) $$dir/$$file $(DESTDIR)$(htmldir)/$$file; \
+--- a/gettext-tools/man/Makefile.am
++++ b/gettext-tools/man/Makefile.am
+@@ -186,8 +186,7 @@ autopoint.1.html: autopoint.1
+ $(MAN2HTML) `if test -f autopoint.1; then echo .; else echo $(srcdir); fi`/autopoint.1 | sed -e '/CreationDate:/d' > t-$@
+ mv t-$@ $@
+
+-install-html-local:
+- $(mkdir_p) $(DESTDIR)$(htmldir)
++install-html: installdirs-html
+ for file in $(man_HTML); do \
+ if test -f $$file; then dir=.; else dir=$(srcdir); fi; \
+ $(INSTALL_DATA) $$dir/$$file $(DESTDIR)$(htmldir)/$$file; \
+--- a/gettext-runtime/intl/Makefile.in
++++ b/gettext-runtime/intl/Makefile.in
+@@ -19,7 +19,7 @@
+ PACKAGE = @PACKAGE@
+ VERSION = @VERSION@
+
+-SHELL = /bin/sh
++SHELL = @SHELL@
+
+ srcdir = @srcdir@
+ top_srcdir = @top_srcdir@
diff --git a/package/libs/gettext-full/patches/.svn/text-base/001-no_examples_and_tests.patch.svn-base b/package/libs/gettext-full/patches/.svn/text-base/001-no_examples_and_tests.patch.svn-base
new file mode 100644
index 0000000..7cdb389
--- /dev/null
+++ b/package/libs/gettext-full/patches/.svn/text-base/001-no_examples_and_tests.patch.svn-base
@@ -0,0 +1,22 @@
+--- a/gettext-runtime/Makefile.in
++++ b/gettext-runtime/Makefile.in
+@@ -208,7 +208,7 @@ AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGE
+ ETAGS = etags
+ CTAGS = ctags
+ DIST_SUBDIRS = doc intl intl-java intl-csharp gnulib-lib libasprintf \
+- src po man m4 tests
++ src po man m4
+ DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ distdir = $(PACKAGE)-$(VERSION)
+ top_distdir = $(distdir)
+--- a/gettext-tools/Makefile.in
++++ b/gettext-tools/Makefile.in
+@@ -1248,7 +1248,7 @@ top_builddir = @top_builddir@
+ top_srcdir = @top_srcdir@
+ AUTOMAKE_OPTIONS = 1.5 gnu no-dependencies
+ ACLOCAL_AMFLAGS = -I m4 -I ../gettext-runtime/m4 -I ../m4 -I gnulib-m4 -I libgrep/gnulib-m4 -I libgettextpo/gnulib-m4
+-SUBDIRS = doc intl gnulib-lib libgrep src libgettextpo po projects styles misc man m4 tests gnulib-tests examples
++SUBDIRS = doc intl gnulib-lib libgrep src libgettextpo po projects styles misc man m4
+
+ # Allow users to use "gnulib-tool --update".
+
diff --git a/package/libs/gettext-full/patches/.svn/text-base/003-gettext-error_print_progname.patch.svn-base b/package/libs/gettext-full/patches/.svn/text-base/003-gettext-error_print_progname.patch.svn-base
new file mode 100644
index 0000000..9e84551
--- /dev/null
+++ b/package/libs/gettext-full/patches/.svn/text-base/003-gettext-error_print_progname.patch.svn-base
@@ -0,0 +1,11 @@
+--- a/gettext-tools/libgettextpo/error.h
++++ b/gettext-tools/libgettextpo/error.h
+@@ -49,7 +49,7 @@ extern void error_at_line (int __status,
+ /* If NULL, error will flush stdout, then print on stderr the program
+ name, a colon and a space. Otherwise, error will call this
+ function without parameters instead. */
+-extern DLL_VARIABLE void (*error_print_progname) (void);
++void (*error_print_progname) (void);
+
+ /* This variable is incremented each time `error' is called. */
+ extern DLL_VARIABLE unsigned int error_message_count;
diff --git a/package/libs/gettext-full/patches/.svn/text-base/004-gnulib-uclibc-sched_param-def.patch.svn-base b/package/libs/gettext-full/patches/.svn/text-base/004-gnulib-uclibc-sched_param-def.patch.svn-base
new file mode 100644
index 0000000..051c374
--- /dev/null
+++ b/package/libs/gettext-full/patches/.svn/text-base/004-gnulib-uclibc-sched_param-def.patch.svn-base
@@ -0,0 +1,17 @@
+uclibc defines __GLIBC__ but it does not expose struct shed_param as much as glibc
+and is not needed too per standard. gnulib attempts to use it but we have to account
+for it because in this case uclibc does not behave like glibc.
+
+-Khem
+
+--- a/gettext-tools/gnulib-lib/spawn.in.h
++++ b/gettext-tools/gnulib-lib/spawn.in.h
+@@ -31,7 +31,7 @@
+
+ /* Get definitions of 'struct sched_param' and 'sigset_t'.
+ But avoid namespace pollution on glibc systems. */
+-#ifndef __GLIBC__
++#if !defined __GLIBC__ || defined __UCLIBC__
+ # include <sched.h>
+ # include <signal.h>
+ #endif
diff --git a/package/libs/gettext-full/patches/.svn/text-base/005-uclibc-0.9.30-compat.patch.svn-base b/package/libs/gettext-full/patches/.svn/text-base/005-uclibc-0.9.30-compat.patch.svn-base
new file mode 100644
index 0000000..dafa79c
--- /dev/null
+++ b/package/libs/gettext-full/patches/.svn/text-base/005-uclibc-0.9.30-compat.patch.svn-base
@@ -0,0 +1,22 @@
+--- a/gettext-runtime/intl/localename.c
++++ b/gettext-runtime/intl/localename.c
+@@ -2607,7 +2607,7 @@ gl_locale_name_thread_unsafe (int catego
+ locale_t thread_locale = uselocale (NULL);
+ if (thread_locale != LC_GLOBAL_LOCALE)
+ {
+-# if __GLIBC__ >= 2
++# if __GLIBC__ >= 2 && !defined __UCLIBC__
+ /* Work around an incorrect definition of the _NL_LOCALE_NAME macro in
+ glibc < 2.12.
+ See <http://sourceware.org/bugzilla/show_bug.cgi?id=10968>. */
+--- a/gettext-tools/gnulib-lib/localename.c
++++ b/gettext-tools/gnulib-lib/localename.c
+@@ -2607,7 +2607,7 @@ gl_locale_name_thread_unsafe (int catego
+ locale_t thread_locale = uselocale (NULL);
+ if (thread_locale != LC_GLOBAL_LOCALE)
+ {
+-# if __GLIBC__ >= 2
++# if __GLIBC__ >= 2 && !defined __UCLIBC__
+ /* Work around an incorrect definition of the _NL_LOCALE_NAME macro in
+ glibc < 2.12.
+ See <http://sourceware.org/bugzilla/show_bug.cgi?id=10968>. */
diff --git a/package/libs/gettext-full/patches/.svn/text-base/100-error_progname.patch.svn-base b/package/libs/gettext-full/patches/.svn/text-base/100-error_progname.patch.svn-base
new file mode 100644
index 0000000..f414703
--- /dev/null
+++ b/package/libs/gettext-full/patches/.svn/text-base/100-error_progname.patch.svn-base
@@ -0,0 +1,10 @@
+--- a/gettext-runtime/intl/intl-compat.c
++++ b/gettext-runtime/intl/intl-compat.c
+@@ -131,3 +131,7 @@ bind_textdomain_codeset (const char *dom
+ {
+ return libintl_bind_textdomain_codeset (domainname, codeset);
+ }
++
++#ifdef __UCLIBC__
++DLL_EXPORTED void (*error_print_progname)(void) = NULL;
++#endif
diff --git a/package/libs/gettext-full/patches/.svn/text-base/120-uclibc-nolocale.patch.svn-base b/package/libs/gettext-full/patches/.svn/text-base/120-uclibc-nolocale.patch.svn-base
new file mode 100644
index 0000000..3e409eb
--- /dev/null
+++ b/package/libs/gettext-full/patches/.svn/text-base/120-uclibc-nolocale.patch.svn-base
@@ -0,0 +1,11 @@
+--- a/gettext-runtime/intl/localename.c
++++ b/gettext-runtime/intl/localename.c
+@@ -2780,7 +2780,7 @@ gl_locale_name_posix (int category, cons
+ {
+ /* Use the POSIX methods of looking to 'LC_ALL', 'LC_xxx', and 'LANG'.
+ On some systems this can be done by the 'setlocale' function itself. */
+-#if defined HAVE_SETLOCALE && defined HAVE_LC_MESSAGES && defined HAVE_LOCALE_NULL
++#if defined HAVE_SETLOCALE && defined HAVE_LC_MESSAGES && defined HAVE_LOCALE_NULL && (!defined __UCLIBC__ || defined __UCLIBC_HAS_LOCALE__)
+ return setlocale (category, NULL);
+ #else
+ /* On other systems we ignore what setlocale reports and instead look at the
diff --git a/package/libs/gettext-full/patches/.svn/text-base/150-disable_libxml_iconv.patch.svn-base b/package/libs/gettext-full/patches/.svn/text-base/150-disable_libxml_iconv.patch.svn-base
new file mode 100644
index 0000000..a8f5a5c
--- /dev/null
+++ b/package/libs/gettext-full/patches/.svn/text-base/150-disable_libxml_iconv.patch.svn-base
@@ -0,0 +1,22 @@
+--- a/gettext-tools/gnulib-lib/libxml/xmlversion.in.h
++++ b/gettext-tools/gnulib-lib/libxml/xmlversion.in.h
+@@ -263,7 +263,7 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(i
+ *
+ * Whether iconv support is available
+ */
+-#if 1
++#if 0
+ #define LIBXML_ICONV_ENABLED
+ #endif
+
+--- a/gnulib-local/lib/libxml/xmlversion.in.h
++++ b/gnulib-local/lib/libxml/xmlversion.in.h
+@@ -263,7 +263,7 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(i
+ *
+ * Whether iconv support is available
+ */
+-#if 1
++#if 0
+ #define LIBXML_ICONV_ENABLED
+ #endif
+
diff --git a/package/libs/gettext-full/patches/.svn/text-base/160-eglibc_stdio.patch.svn-base b/package/libs/gettext-full/patches/.svn/text-base/160-eglibc_stdio.patch.svn-base
new file mode 100644
index 0000000..a4c4f92
--- /dev/null
+++ b/package/libs/gettext-full/patches/.svn/text-base/160-eglibc_stdio.patch.svn-base
@@ -0,0 +1,36 @@
+--- a/gettext-runtime/gnulib-lib/stdio.in.h
++++ b/gettext-runtime/gnulib-lib/stdio.in.h
+@@ -141,7 +141,9 @@ _GL_WARN_ON_USE (fflush, "fflush is not
+ so any use of gets warrants an unconditional warning. Assume it is
+ always declared, since it is required by C89. */
+ #undef gets
++#if HAVE_RAW_DECL_GETS
+ _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
++#endif
+
+ #if @GNULIB_FOPEN@
+ # if @REPLACE_FOPEN@
+--- a/gettext-tools/gnulib-lib/stdio.in.h
++++ b/gettext-tools/gnulib-lib/stdio.in.h
+@@ -141,7 +141,9 @@ _GL_WARN_ON_USE (fflush, "fflush is not
+ so any use of gets warrants an unconditional warning. Assume it is
+ always declared, since it is required by C89. */
+ #undef gets
++#if HAVE_RAW_DECL_GETS
+ _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
++#endif
+
+ #if @GNULIB_FOPEN@
+ # if @REPLACE_FOPEN@
+--- a/gettext-tools/libgettextpo/stdio.in.h
++++ b/gettext-tools/libgettextpo/stdio.in.h
+@@ -141,7 +141,9 @@ _GL_WARN_ON_USE (fflush, "fflush is not
+ so any use of gets warrants an unconditional warning. Assume it is
+ always declared, since it is required by C89. */
+ #undef gets
++#if HAVE_RAW_DECL_GETS
+ _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
++#endif
+
+ #if @GNULIB_FOPEN@
+ # if @REPLACE_FOPEN@
diff --git a/package/libs/gettext-full/patches/001-autotools.patch b/package/libs/gettext-full/patches/001-autotools.patch
new file mode 100644
index 0000000..bf44fcb
--- /dev/null
+++ b/package/libs/gettext-full/patches/001-autotools.patch
@@ -0,0 +1,35 @@
+--- a/gettext-runtime/man/Makefile.am
++++ b/gettext-runtime/man/Makefile.am
+@@ -159,8 +159,7 @@ bind_textdomain_codeset.3.html: bind_tex
+ $(MAN2HTML) $(srcdir)/bind_textdomain_codeset.3.in | sed -e '/CreationDate:/d' > t-$@
+ mv t-$@ $@
+
+-install-html-local:
+- $(mkdir_p) $(DESTDIR)$(htmldir)
++install-html: installdirs-html
+ for file in $(man_HTML); do \
+ if test -f $$file; then dir=.; else dir=$(srcdir); fi; \
+ $(INSTALL_DATA) $$dir/$$file $(DESTDIR)$(htmldir)/$$file; \
+--- a/gettext-tools/man/Makefile.am
++++ b/gettext-tools/man/Makefile.am
+@@ -186,8 +186,7 @@ autopoint.1.html: autopoint.1
+ $(MAN2HTML) `if test -f autopoint.1; then echo .; else echo $(srcdir); fi`/autopoint.1 | sed -e '/CreationDate:/d' > t-$@
+ mv t-$@ $@
+
+-install-html-local:
+- $(mkdir_p) $(DESTDIR)$(htmldir)
++install-html: installdirs-html
+ for file in $(man_HTML); do \
+ if test -f $$file; then dir=.; else dir=$(srcdir); fi; \
+ $(INSTALL_DATA) $$dir/$$file $(DESTDIR)$(htmldir)/$$file; \
+--- a/gettext-runtime/intl/Makefile.in
++++ b/gettext-runtime/intl/Makefile.in
+@@ -19,7 +19,7 @@
+ PACKAGE = @PACKAGE@
+ VERSION = @VERSION@
+
+-SHELL = /bin/sh
++SHELL = @SHELL@
+
+ srcdir = @srcdir@
+ top_srcdir = @top_srcdir@
diff --git a/package/libs/gettext-full/patches/001-no_examples_and_tests.patch b/package/libs/gettext-full/patches/001-no_examples_and_tests.patch
new file mode 100644
index 0000000..7cdb389
--- /dev/null
+++ b/package/libs/gettext-full/patches/001-no_examples_and_tests.patch
@@ -0,0 +1,22 @@
+--- a/gettext-runtime/Makefile.in
++++ b/gettext-runtime/Makefile.in
+@@ -208,7 +208,7 @@ AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGE
+ ETAGS = etags
+ CTAGS = ctags
+ DIST_SUBDIRS = doc intl intl-java intl-csharp gnulib-lib libasprintf \
+- src po man m4 tests
++ src po man m4
+ DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ distdir = $(PACKAGE)-$(VERSION)
+ top_distdir = $(distdir)
+--- a/gettext-tools/Makefile.in
++++ b/gettext-tools/Makefile.in
+@@ -1248,7 +1248,7 @@ top_builddir = @top_builddir@
+ top_srcdir = @top_srcdir@
+ AUTOMAKE_OPTIONS = 1.5 gnu no-dependencies
+ ACLOCAL_AMFLAGS = -I m4 -I ../gettext-runtime/m4 -I ../m4 -I gnulib-m4 -I libgrep/gnulib-m4 -I libgettextpo/gnulib-m4
+-SUBDIRS = doc intl gnulib-lib libgrep src libgettextpo po projects styles misc man m4 tests gnulib-tests examples
++SUBDIRS = doc intl gnulib-lib libgrep src libgettextpo po projects styles misc man m4
+
+ # Allow users to use "gnulib-tool --update".
+
diff --git a/package/libs/gettext-full/patches/003-gettext-error_print_progname.patch b/package/libs/gettext-full/patches/003-gettext-error_print_progname.patch
new file mode 100644
index 0000000..9e84551
--- /dev/null
+++ b/package/libs/gettext-full/patches/003-gettext-error_print_progname.patch
@@ -0,0 +1,11 @@
+--- a/gettext-tools/libgettextpo/error.h
++++ b/gettext-tools/libgettextpo/error.h
+@@ -49,7 +49,7 @@ extern void error_at_line (int __status,
+ /* If NULL, error will flush stdout, then print on stderr the program
+ name, a colon and a space. Otherwise, error will call this
+ function without parameters instead. */
+-extern DLL_VARIABLE void (*error_print_progname) (void);
++void (*error_print_progname) (void);
+
+ /* This variable is incremented each time `error' is called. */
+ extern DLL_VARIABLE unsigned int error_message_count;
diff --git a/package/libs/gettext-full/patches/004-gnulib-uclibc-sched_param-def.patch b/package/libs/gettext-full/patches/004-gnulib-uclibc-sched_param-def.patch
new file mode 100644
index 0000000..051c374
--- /dev/null
+++ b/package/libs/gettext-full/patches/004-gnulib-uclibc-sched_param-def.patch
@@ -0,0 +1,17 @@
+uclibc defines __GLIBC__ but it does not expose struct shed_param as much as glibc
+and is not needed too per standard. gnulib attempts to use it but we have to account
+for it because in this case uclibc does not behave like glibc.
+
+-Khem
+
+--- a/gettext-tools/gnulib-lib/spawn.in.h
++++ b/gettext-tools/gnulib-lib/spawn.in.h
+@@ -31,7 +31,7 @@
+
+ /* Get definitions of 'struct sched_param' and 'sigset_t'.
+ But avoid namespace pollution on glibc systems. */
+-#ifndef __GLIBC__
++#if !defined __GLIBC__ || defined __UCLIBC__
+ # include <sched.h>
+ # include <signal.h>
+ #endif
diff --git a/package/libs/gettext-full/patches/005-uclibc-0.9.30-compat.patch b/package/libs/gettext-full/patches/005-uclibc-0.9.30-compat.patch
new file mode 100644
index 0000000..dafa79c
--- /dev/null
+++ b/package/libs/gettext-full/patches/005-uclibc-0.9.30-compat.patch
@@ -0,0 +1,22 @@
+--- a/gettext-runtime/intl/localename.c
++++ b/gettext-runtime/intl/localename.c
+@@ -2607,7 +2607,7 @@ gl_locale_name_thread_unsafe (int catego
+ locale_t thread_locale = uselocale (NULL);
+ if (thread_locale != LC_GLOBAL_LOCALE)
+ {
+-# if __GLIBC__ >= 2
++# if __GLIBC__ >= 2 && !defined __UCLIBC__
+ /* Work around an incorrect definition of the _NL_LOCALE_NAME macro in
+ glibc < 2.12.
+ See <http://sourceware.org/bugzilla/show_bug.cgi?id=10968>. */
+--- a/gettext-tools/gnulib-lib/localename.c
++++ b/gettext-tools/gnulib-lib/localename.c
+@@ -2607,7 +2607,7 @@ gl_locale_name_thread_unsafe (int catego
+ locale_t thread_locale = uselocale (NULL);
+ if (thread_locale != LC_GLOBAL_LOCALE)
+ {
+-# if __GLIBC__ >= 2
++# if __GLIBC__ >= 2 && !defined __UCLIBC__
+ /* Work around an incorrect definition of the _NL_LOCALE_NAME macro in
+ glibc < 2.12.
+ See <http://sourceware.org/bugzilla/show_bug.cgi?id=10968>. */
diff --git a/package/libs/gettext-full/patches/100-error_progname.patch b/package/libs/gettext-full/patches/100-error_progname.patch
new file mode 100644
index 0000000..f414703
--- /dev/null
+++ b/package/libs/gettext-full/patches/100-error_progname.patch
@@ -0,0 +1,10 @@
+--- a/gettext-runtime/intl/intl-compat.c
++++ b/gettext-runtime/intl/intl-compat.c
+@@ -131,3 +131,7 @@ bind_textdomain_codeset (const char *dom
+ {
+ return libintl_bind_textdomain_codeset (domainname, codeset);
+ }
++
++#ifdef __UCLIBC__
++DLL_EXPORTED void (*error_print_progname)(void) = NULL;
++#endif
diff --git a/package/libs/gettext-full/patches/120-uclibc-nolocale.patch b/package/libs/gettext-full/patches/120-uclibc-nolocale.patch
new file mode 100644
index 0000000..3e409eb
--- /dev/null
+++ b/package/libs/gettext-full/patches/120-uclibc-nolocale.patch
@@ -0,0 +1,11 @@
+--- a/gettext-runtime/intl/localename.c
++++ b/gettext-runtime/intl/localename.c
+@@ -2780,7 +2780,7 @@ gl_locale_name_posix (int category, cons
+ {
+ /* Use the POSIX methods of looking to 'LC_ALL', 'LC_xxx', and 'LANG'.
+ On some systems this can be done by the 'setlocale' function itself. */
+-#if defined HAVE_SETLOCALE && defined HAVE_LC_MESSAGES && defined HAVE_LOCALE_NULL
++#if defined HAVE_SETLOCALE && defined HAVE_LC_MESSAGES && defined HAVE_LOCALE_NULL && (!defined __UCLIBC__ || defined __UCLIBC_HAS_LOCALE__)
+ return setlocale (category, NULL);
+ #else
+ /* On other systems we ignore what setlocale reports and instead look at the
diff --git a/package/libs/gettext-full/patches/150-disable_libxml_iconv.patch b/package/libs/gettext-full/patches/150-disable_libxml_iconv.patch
new file mode 100644
index 0000000..a8f5a5c
--- /dev/null
+++ b/package/libs/gettext-full/patches/150-disable_libxml_iconv.patch
@@ -0,0 +1,22 @@
+--- a/gettext-tools/gnulib-lib/libxml/xmlversion.in.h
++++ b/gettext-tools/gnulib-lib/libxml/xmlversion.in.h
+@@ -263,7 +263,7 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(i
+ *
+ * Whether iconv support is available
+ */
+-#if 1
++#if 0
+ #define LIBXML_ICONV_ENABLED
+ #endif
+
+--- a/gnulib-local/lib/libxml/xmlversion.in.h
++++ b/gnulib-local/lib/libxml/xmlversion.in.h
+@@ -263,7 +263,7 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(i
+ *
+ * Whether iconv support is available
+ */
+-#if 1
++#if 0
+ #define LIBXML_ICONV_ENABLED
+ #endif
+
diff --git a/package/libs/gettext-full/patches/160-eglibc_stdio.patch b/package/libs/gettext-full/patches/160-eglibc_stdio.patch
new file mode 100644
index 0000000..a4c4f92
--- /dev/null
+++ b/package/libs/gettext-full/patches/160-eglibc_stdio.patch
@@ -0,0 +1,36 @@
+--- a/gettext-runtime/gnulib-lib/stdio.in.h
++++ b/gettext-runtime/gnulib-lib/stdio.in.h
+@@ -141,7 +141,9 @@ _GL_WARN_ON_USE (fflush, "fflush is not
+ so any use of gets warrants an unconditional warning. Assume it is
+ always declared, since it is required by C89. */
+ #undef gets
++#if HAVE_RAW_DECL_GETS
+ _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
++#endif
+
+ #if @GNULIB_FOPEN@
+ # if @REPLACE_FOPEN@
+--- a/gettext-tools/gnulib-lib/stdio.in.h
++++ b/gettext-tools/gnulib-lib/stdio.in.h
+@@ -141,7 +141,9 @@ _GL_WARN_ON_USE (fflush, "fflush is not
+ so any use of gets warrants an unconditional warning. Assume it is
+ always declared, since it is required by C89. */
+ #undef gets
++#if HAVE_RAW_DECL_GETS
+ _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
++#endif
+
+ #if @GNULIB_FOPEN@
+ # if @REPLACE_FOPEN@
+--- a/gettext-tools/libgettextpo/stdio.in.h
++++ b/gettext-tools/libgettextpo/stdio.in.h
+@@ -141,7 +141,9 @@ _GL_WARN_ON_USE (fflush, "fflush is not
+ so any use of gets warrants an unconditional warning. Assume it is
+ always declared, since it is required by C89. */
+ #undef gets
++#if HAVE_RAW_DECL_GETS
+ _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
++#endif
+
+ #if @GNULIB_FOPEN@
+ # if @REPLACE_FOPEN@
diff --git a/package/libs/gettext/.svn/entries b/package/libs/gettext/.svn/entries
new file mode 100644
index 0000000..826fde5
--- /dev/null
+++ b/package/libs/gettext/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs/gettext
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-19T15:34:28.915431Z
+33861
+hcg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+src
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+c179045cb993c4da94255665c1aa9f07
+2012-10-19T15:34:28.915431Z
+33861
+hcg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1443
+
diff --git a/package/libs/gettext/.svn/text-base/Makefile.svn-base b/package/libs/gettext/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..1ee785e
--- /dev/null
+++ b/package/libs/gettext/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,68 @@
+#
+# Copyright (C) 2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=gettext
+PKG_RELEASE:=2
+
+PKG_LICENSE:=FREE
+PKG_LICENSE_FILES:=LICENSE
+
+PKG_MAINTAINER:=Jo-Philipp Wich <jow@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/host-build.mk
+
+define Package/libintl
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=Stub header for the GNU Internationalization library
+endef
+
+define Build/Prepare
+ $(INSTALL_DIR) $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+endef
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/lib/libintl-stub/include
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/include/libintl.h $(1)/usr/lib/libintl-stub/include/
+
+ $(INSTALL_DIR) $(1)/usr/share/aclocal
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/m4/* $(1)/usr/share/aclocal/
+endef
+
+define Host/Prepare
+ mkdir -p $(HOST_BUILD_DIR)
+endef
+
+define Host/Compile
+
+endef
+
+define Host/Install
+ $(INSTALL_DIR) $(STAGING_DIR_HOST)/include
+ $(INSTALL_DATA) ./src/include/libintl.h $(STAGING_DIR_HOST)/include/
+
+ $(INSTALL_DIR) $(STAGING_DIR_HOST)/share/aclocal
+ $(INSTALL_DATA) ./src/m4/* $(STAGING_DIR_HOST)/share/aclocal/
+endef
+
+define Package/libintl/install
+ $(INSTALL_DIR) $(1)/tmp
+ touch $(1)/tmp/.libintl-placeholder
+endef
+
+$(eval $(call HostBuild))
+$(eval $(call BuildPackage,libintl))
diff --git a/package/libs/gettext/Makefile b/package/libs/gettext/Makefile
new file mode 100644
index 0000000..1ee785e
--- /dev/null
+++ b/package/libs/gettext/Makefile
@@ -0,0 +1,68 @@
+#
+# Copyright (C) 2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=gettext
+PKG_RELEASE:=2
+
+PKG_LICENSE:=FREE
+PKG_LICENSE_FILES:=LICENSE
+
+PKG_MAINTAINER:=Jo-Philipp Wich <jow@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/host-build.mk
+
+define Package/libintl
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=Stub header for the GNU Internationalization library
+endef
+
+define Build/Prepare
+ $(INSTALL_DIR) $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+endef
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/lib/libintl-stub/include
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/include/libintl.h $(1)/usr/lib/libintl-stub/include/
+
+ $(INSTALL_DIR) $(1)/usr/share/aclocal
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/m4/* $(1)/usr/share/aclocal/
+endef
+
+define Host/Prepare
+ mkdir -p $(HOST_BUILD_DIR)
+endef
+
+define Host/Compile
+
+endef
+
+define Host/Install
+ $(INSTALL_DIR) $(STAGING_DIR_HOST)/include
+ $(INSTALL_DATA) ./src/include/libintl.h $(STAGING_DIR_HOST)/include/
+
+ $(INSTALL_DIR) $(STAGING_DIR_HOST)/share/aclocal
+ $(INSTALL_DATA) ./src/m4/* $(STAGING_DIR_HOST)/share/aclocal/
+endef
+
+define Package/libintl/install
+ $(INSTALL_DIR) $(1)/tmp
+ touch $(1)/tmp/.libintl-placeholder
+endef
+
+$(eval $(call HostBuild))
+$(eval $(call BuildPackage,libintl))
diff --git a/package/libs/gettext/src/.svn/entries b/package/libs/gettext/src/.svn/entries
new file mode 100644
index 0000000..3db9b9b
--- /dev/null
+++ b/package/libs/gettext/src/.svn/entries
@@ -0,0 +1,68 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs/gettext/src
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-19T15:34:28.915431Z
+33861
+hcg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+m4
+dir
+
+LICENSE
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+c17dc539663b7049f8ffa4c33d8e5661
+2012-10-19T15:34:28.915431Z
+33861
+hcg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+288
+
+include
+dir
+
diff --git a/package/libs/gettext/src/.svn/text-base/LICENSE.svn-base b/package/libs/gettext/src/.svn/text-base/LICENSE.svn-base
new file mode 100644
index 0000000..d1a59b0
--- /dev/null
+++ b/package/libs/gettext/src/.svn/text-base/LICENSE.svn-base
@@ -0,0 +1,7 @@
+Each source file contains the following message:
+
+Copyright (C) 1995-2010 Free Software Foundation, Inc.
+This file is free software; the Free Software Foundation
+gives unlimited permission to copy and/or distribute it,
+with or without modifications, as long as this notice is preserved.
+
diff --git a/package/libs/gettext/src/LICENSE b/package/libs/gettext/src/LICENSE
new file mode 100644
index 0000000..d1a59b0
--- /dev/null
+++ b/package/libs/gettext/src/LICENSE
@@ -0,0 +1,7 @@
+Each source file contains the following message:
+
+Copyright (C) 1995-2010 Free Software Foundation, Inc.
+This file is free software; the Free Software Foundation
+gives unlimited permission to copy and/or distribute it,
+with or without modifications, as long as this notice is preserved.
+
diff --git a/package/libs/gettext/src/include/.svn/entries b/package/libs/gettext/src/include/.svn/entries
new file mode 100644
index 0000000..a1cfeb1
--- /dev/null
+++ b/package/libs/gettext/src/include/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs/gettext/src/include
+svn://svn.openwrt.org/openwrt
+
+
+
+2011-02-20T03:26:44.292354Z
+25599
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+libintl.h
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+9419e91221529dfca791558ef7ff8499
+2011-02-20T03:26:44.292354Z
+25599
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1365
+
diff --git a/package/libs/gettext/src/include/.svn/text-base/libintl.h.svn-base b/package/libs/gettext/src/include/.svn/text-base/libintl.h.svn-base
new file mode 100644
index 0000000..a1157a4
--- /dev/null
+++ b/package/libs/gettext/src/include/.svn/text-base/libintl.h.svn-base
@@ -0,0 +1,53 @@
+/*
+ * This code is lifted from http://permalink.gmane.org/gmane.linux.gentoo.embedded/3218
+ */
+
+#ifndef _LIBINTL_H
+#define _LIBINTL_H 1
+
+#include <locale.h>
+
+/* Undef gettext macros, if any... */
+#undef gettext
+#undef dgettext
+#undef dcgettext
+#undef ngettext
+#undef dngettext
+#undef dcngettext
+#undef textdomain
+#undef bindtextdomain
+#undef bind_textdomain_codeset
+
+/* part of locale.h */
+/* #undef setlocale */
+
+#undef _
+#undef N_
+
+/* Define gettext stubs that map back to the original strings */
+#define gettext(String) (String)
+#define dgettext(Domain, String) (String)
+#define dcgettext(Domain, String, Type) (String)
+
+#define ngettext(Singular, Plural, Count) \
+ ((Count) == 1 ? (const char *) (Singular) : (const char *) (Plural))
+
+#define dngettext(Domain, Singular, Plural, Count) \
+ ((Count) == 1 ? (const char *) (Singular) : (const char *) (Plural))
+
+#define dcngettext(Domain, Singular, Plural, Count, Category) \
+ ((Count) == 1 ? (const char *) (Singular) : (const char *) (Plural))
+
+#define _(String) (String)
+#define N_(String) String
+
+#ifndef _LOCALE_H
+/* #define setlocale(Category, Locale) ((char *)NULL) */
+#endif
+
+/* No-ops for textdomain operations */
+#define bindtextdomain(Domain, Directory) (Domain)
+#define bind_textdomain_codeset(Domain, Codeset) (Codeset)
+#define textdomain(String) (String) ?: "messages"
+
+#endif /* _LIBINTL_H */
diff --git a/package/libs/gettext/src/include/libintl.h b/package/libs/gettext/src/include/libintl.h
new file mode 100644
index 0000000..a1157a4
--- /dev/null
+++ b/package/libs/gettext/src/include/libintl.h
@@ -0,0 +1,53 @@
+/*
+ * This code is lifted from http://permalink.gmane.org/gmane.linux.gentoo.embedded/3218
+ */
+
+#ifndef _LIBINTL_H
+#define _LIBINTL_H 1
+
+#include <locale.h>
+
+/* Undef gettext macros, if any... */
+#undef gettext
+#undef dgettext
+#undef dcgettext
+#undef ngettext
+#undef dngettext
+#undef dcngettext
+#undef textdomain
+#undef bindtextdomain
+#undef bind_textdomain_codeset
+
+/* part of locale.h */
+/* #undef setlocale */
+
+#undef _
+#undef N_
+
+/* Define gettext stubs that map back to the original strings */
+#define gettext(String) (String)
+#define dgettext(Domain, String) (String)
+#define dcgettext(Domain, String, Type) (String)
+
+#define ngettext(Singular, Plural, Count) \
+ ((Count) == 1 ? (const char *) (Singular) : (const char *) (Plural))
+
+#define dngettext(Domain, Singular, Plural, Count) \
+ ((Count) == 1 ? (const char *) (Singular) : (const char *) (Plural))
+
+#define dcngettext(Domain, Singular, Plural, Count, Category) \
+ ((Count) == 1 ? (const char *) (Singular) : (const char *) (Plural))
+
+#define _(String) (String)
+#define N_(String) String
+
+#ifndef _LOCALE_H
+/* #define setlocale(Category, Locale) ((char *)NULL) */
+#endif
+
+/* No-ops for textdomain operations */
+#define bindtextdomain(Domain, Directory) (Domain)
+#define bind_textdomain_codeset(Domain, Codeset) (Codeset)
+#define textdomain(String) (String) ?: "messages"
+
+#endif /* _LIBINTL_H */
diff --git a/package/libs/gettext/src/m4/.svn/entries b/package/libs/gettext/src/m4/.svn/entries
new file mode 100644
index 0000000..4f4947c
--- /dev/null
+++ b/package/libs/gettext/src/m4/.svn/entries
@@ -0,0 +1,300 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs/gettext/src/m4
+svn://svn.openwrt.org/openwrt
+
+
+
+2010-12-19T04:39:07.093458Z
+24706
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+intlmacosx.m4
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+0c975c99d2ec007b59adbe369635a393
+2010-12-19T02:36:00.945741Z
+24699
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2429
+
+lcmessage.m4
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+71b021f276bcf4d25f2067c1ffd54601
+2010-12-19T02:36:00.945741Z
+24699
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1307
+
+gettext.m4
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+39a07a87982bd635431ea8e0af8273e3
+2010-12-19T02:36:00.945741Z
+24699
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+14938
+
+intldir.m4
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+e2d656509555803723825c6e45a0b2dd
+2010-12-19T02:36:00.945741Z
+24699
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+923
+
+codeset.m4
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+d37c7d67a170111ea65fdb3db8150ec0
+2010-12-19T02:36:00.945741Z
+24699
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+779
+
+intl.m4
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+5998e60de7f227d0716d1fdb24ccf8e4
+2010-12-19T02:36:00.945741Z
+24699
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+11823
+
+nls.m4
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+d0e1d2def079958d312c9a6843364c95
+2010-12-19T02:36:00.945741Z
+24699
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1229
+
+po.m4
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+7799327f0a516d6f7a62d69d902ec8fb
+2010-12-19T02:36:00.945741Z
+24699
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+18830
+
diff --git a/package/libs/gettext/src/m4/.svn/text-base/codeset.m4.svn-base b/package/libs/gettext/src/m4/.svn/text-base/codeset.m4.svn-base
new file mode 100644
index 0000000..a53c042
--- /dev/null
+++ b/package/libs/gettext/src/m4/.svn/text-base/codeset.m4.svn-base
@@ -0,0 +1,21 @@
+# codeset.m4 serial 4 (gettext-0.18)
+dnl Copyright (C) 2000-2002, 2006, 2008-2010 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Bruno Haible.
+
+AC_DEFUN([AM_LANGINFO_CODESET],
+[
+ AC_CACHE_CHECK([for nl_langinfo and CODESET], [am_cv_langinfo_codeset],
+ [AC_TRY_LINK([#include <langinfo.h>],
+ [char* cs = nl_langinfo(CODESET); return !cs;],
+ [am_cv_langinfo_codeset=yes],
+ [am_cv_langinfo_codeset=no])
+ ])
+ if test $am_cv_langinfo_codeset = yes; then
+ AC_DEFINE([HAVE_LANGINFO_CODESET], [1],
+ [Define if you have <langinfo.h> and nl_langinfo(CODESET).])
+ fi
+])
diff --git a/package/libs/gettext/src/m4/.svn/text-base/gettext.m4.svn-base b/package/libs/gettext/src/m4/.svn/text-base/gettext.m4.svn-base
new file mode 100644
index 0000000..f84e6a5
--- /dev/null
+++ b/package/libs/gettext/src/m4/.svn/text-base/gettext.m4.svn-base
@@ -0,0 +1,383 @@
+# gettext.m4 serial 63 (gettext-0.18)
+dnl Copyright (C) 1995-2010 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+dnl
+dnl This file can can be used in projects which are not available under
+dnl the GNU General Public License or the GNU Library General Public
+dnl License but which still want to provide support for the GNU gettext
+dnl functionality.
+dnl Please note that the actual code of the GNU gettext library is covered
+dnl by the GNU Library General Public License, and the rest of the GNU
+dnl gettext package package is covered by the GNU General Public License.
+dnl They are *not* in the public domain.
+
+dnl Authors:
+dnl Ulrich Drepper <drepper@cygnus.com>, 1995-2000.
+dnl Bruno Haible <haible@clisp.cons.org>, 2000-2006, 2008-2010.
+
+dnl Macro to add for using GNU gettext.
+
+dnl Usage: AM_GNU_GETTEXT([INTLSYMBOL], [NEEDSYMBOL], [INTLDIR]).
+dnl INTLSYMBOL can be one of 'external', 'no-libtool', 'use-libtool'. The
+dnl default (if it is not specified or empty) is 'no-libtool'.
+dnl INTLSYMBOL should be 'external' for packages with no intl directory,
+dnl and 'no-libtool' or 'use-libtool' for packages with an intl directory.
+dnl If INTLSYMBOL is 'use-libtool', then a libtool library
+dnl $(top_builddir)/intl/libintl.la will be created (shared and/or static,
+dnl depending on --{enable,disable}-{shared,static} and on the presence of
+dnl AM-DISABLE-SHARED). If INTLSYMBOL is 'no-libtool', a static library
+dnl $(top_builddir)/intl/libintl.a will be created.
+dnl If NEEDSYMBOL is specified and is 'need-ngettext', then GNU gettext
+dnl implementations (in libc or libintl) without the ngettext() function
+dnl will be ignored. If NEEDSYMBOL is specified and is
+dnl 'need-formatstring-macros', then GNU gettext implementations that don't
+dnl support the ISO C 99 <inttypes.h> formatstring macros will be ignored.
+dnl INTLDIR is used to find the intl libraries. If empty,
+dnl the value `$(top_builddir)/intl/' is used.
+dnl
+dnl The result of the configuration is one of three cases:
+dnl 1) GNU gettext, as included in the intl subdirectory, will be compiled
+dnl and used.
+dnl Catalog format: GNU --> install in $(datadir)
+dnl Catalog extension: .mo after installation, .gmo in source tree
+dnl 2) GNU gettext has been found in the system's C library.
+dnl Catalog format: GNU --> install in $(datadir)
+dnl Catalog extension: .mo after installation, .gmo in source tree
+dnl 3) No internationalization, always use English msgid.
+dnl Catalog format: none
+dnl Catalog extension: none
+dnl If INTLSYMBOL is 'external', only cases 2 and 3 can occur.
+dnl The use of .gmo is historical (it was needed to avoid overwriting the
+dnl GNU format catalogs when building on a platform with an X/Open gettext),
+dnl but we keep it in order not to force irrelevant filename changes on the
+dnl maintainers.
+dnl
+AC_DEFUN([AM_GNU_GETTEXT],
+[
+ dnl Argument checking.
+ ifelse([$1], [], , [ifelse([$1], [external], , [ifelse([$1], [no-libtool], , [ifelse([$1], [use-libtool], ,
+ [errprint([ERROR: invalid first argument to AM_GNU_GETTEXT
+])])])])])
+ ifelse(ifelse([$1], [], [old])[]ifelse([$1], [no-libtool], [old]), [old],
+ [AC_DIAGNOSE([obsolete], [Use of AM_GNU_GETTEXT without [external] argument is deprecated.])])
+ ifelse([$2], [], , [ifelse([$2], [need-ngettext], , [ifelse([$2], [need-formatstring-macros], ,
+ [errprint([ERROR: invalid second argument to AM_GNU_GETTEXT
+])])])])
+ define([gt_included_intl],
+ ifelse([$1], [external],
+ ifdef([AM_GNU_GETTEXT_][INTL_SUBDIR], [yes], [no]),
+ [yes]))
+ define([gt_libtool_suffix_prefix], ifelse([$1], [use-libtool], [l], []))
+ gt_NEEDS_INIT
+ AM_GNU_GETTEXT_NEED([$2])
+
+ AC_REQUIRE([AM_PO_SUBDIRS])dnl
+ ifelse(gt_included_intl, yes, [
+ AC_REQUIRE([AM_INTL_SUBDIR])dnl
+ ])
+
+ dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
+ AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
+ AC_REQUIRE([AC_LIB_RPATH])
+
+ dnl Sometimes libintl requires libiconv, so first search for libiconv.
+ dnl Ideally we would do this search only after the
+ dnl if test "$USE_NLS" = "yes"; then
+ dnl if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" != "yes"; }; then
+ dnl tests. But if configure.in invokes AM_ICONV after AM_GNU_GETTEXT
+ dnl the configure script would need to contain the same shell code
+ dnl again, outside any 'if'. There are two solutions:
+ dnl - Invoke AM_ICONV_LINKFLAGS_BODY here, outside any 'if'.
+ dnl - Control the expansions in more detail using AC_PROVIDE_IFELSE.
+ dnl Since AC_PROVIDE_IFELSE is only in autoconf >= 2.52 and not
+ dnl documented, we avoid it.
+ ifelse(gt_included_intl, yes, , [
+ AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY])
+ ])
+
+ dnl Sometimes, on MacOS X, libintl requires linking with CoreFoundation.
+ gt_INTL_MACOSX
+
+ dnl Set USE_NLS.
+ AC_REQUIRE([AM_NLS])
+
+ ifelse(gt_included_intl, yes, [
+ BUILD_INCLUDED_LIBINTL=no
+ USE_INCLUDED_LIBINTL=no
+ ])
+ LIBINTL=
+ LTLIBINTL=
+ POSUB=
+
+ dnl Add a version number to the cache macros.
+ case " $gt_needs " in
+ *" need-formatstring-macros "*) gt_api_version=3 ;;
+ *" need-ngettext "*) gt_api_version=2 ;;
+ *) gt_api_version=1 ;;
+ esac
+ gt_func_gnugettext_libc="gt_cv_func_gnugettext${gt_api_version}_libc"
+ gt_func_gnugettext_libintl="gt_cv_func_gnugettext${gt_api_version}_libintl"
+
+ dnl If we use NLS figure out what method
+ if test "$USE_NLS" = "yes"; then
+ gt_use_preinstalled_gnugettext=no
+ ifelse(gt_included_intl, yes, [
+ AC_MSG_CHECKING([whether included gettext is requested])
+ AC_ARG_WITH([included-gettext],
+ [ --with-included-gettext use the GNU gettext library included here],
+ nls_cv_force_use_gnu_gettext=$withval,
+ nls_cv_force_use_gnu_gettext=no)
+ AC_MSG_RESULT([$nls_cv_force_use_gnu_gettext])
+
+ nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
+ if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
+ ])
+ dnl User does not insist on using GNU NLS library. Figure out what
+ dnl to use. If GNU gettext is available we use this. Else we have
+ dnl to fall back to GNU NLS library.
+
+ if test $gt_api_version -ge 3; then
+ gt_revision_test_code='
+#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
+#define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1)
+#endif
+changequote(,)dnl
+typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1];
+changequote([,])dnl
+'
+ else
+ gt_revision_test_code=
+ fi
+ if test $gt_api_version -ge 2; then
+ gt_expression_test_code=' + * ngettext ("", "", 0)'
+ else
+ gt_expression_test_code=
+ fi
+
+ AC_CACHE_CHECK([for GNU gettext in libc], [$gt_func_gnugettext_libc],
+ [AC_TRY_LINK([#include <libintl.h>
+$gt_revision_test_code
+extern int _nl_msg_cat_cntr;
+extern int *_nl_domain_bindings;],
+ [bindtextdomain ("", "");
+return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_domain_bindings],
+ [eval "$gt_func_gnugettext_libc=yes"],
+ [eval "$gt_func_gnugettext_libc=no"])])
+
+ if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" != "yes"; }; then
+ dnl Sometimes libintl requires libiconv, so first search for libiconv.
+ ifelse(gt_included_intl, yes, , [
+ AM_ICONV_LINK
+ ])
+ dnl Search for libintl and define LIBINTL, LTLIBINTL and INCINTL
+ dnl accordingly. Don't use AC_LIB_LINKFLAGS_BODY([intl],[iconv])
+ dnl because that would add "-liconv" to LIBINTL and LTLIBINTL
+ dnl even if libiconv doesn't exist.
+ AC_LIB_LINKFLAGS_BODY([intl])
+ AC_CACHE_CHECK([for GNU gettext in libintl],
+ [$gt_func_gnugettext_libintl],
+ [gt_save_CPPFLAGS="$CPPFLAGS"
+ CPPFLAGS="$CPPFLAGS $INCINTL"
+ gt_save_LIBS="$LIBS"
+ LIBS="$LIBS $LIBINTL"
+ dnl Now see whether libintl exists and does not depend on libiconv.
+ AC_TRY_LINK([#include <libintl.h>
+$gt_revision_test_code
+extern int _nl_msg_cat_cntr;
+extern
+#ifdef __cplusplus
+"C"
+#endif
+const char *_nl_expand_alias (const char *);],
+ [bindtextdomain ("", "");
+return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_alias ("")],
+ [eval "$gt_func_gnugettext_libintl=yes"],
+ [eval "$gt_func_gnugettext_libintl=no"])
+ dnl Now see whether libintl exists and depends on libiconv.
+ if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" != yes; } && test -n "$LIBICONV"; then
+ LIBS="$LIBS $LIBICONV"
+ AC_TRY_LINK([#include <libintl.h>
+$gt_revision_test_code
+extern int _nl_msg_cat_cntr;
+extern
+#ifdef __cplusplus
+"C"
+#endif
+const char *_nl_expand_alias (const char *);],
+ [bindtextdomain ("", "");
+return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_alias ("")],
+ [LIBINTL="$LIBINTL $LIBICONV"
+ LTLIBINTL="$LTLIBINTL $LTLIBICONV"
+ eval "$gt_func_gnugettext_libintl=yes"
+ ])
+ fi
+ CPPFLAGS="$gt_save_CPPFLAGS"
+ LIBS="$gt_save_LIBS"])
+ fi
+
+ dnl If an already present or preinstalled GNU gettext() is found,
+ dnl use it. But if this macro is used in GNU gettext, and GNU
+ dnl gettext is already preinstalled in libintl, we update this
+ dnl libintl. (Cf. the install rule in intl/Makefile.in.)
+ if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" = "yes"; } \
+ || { { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; } \
+ && test "$PACKAGE" != gettext-runtime \
+ && test "$PACKAGE" != gettext-tools; }; then
+ gt_use_preinstalled_gnugettext=yes
+ else
+ dnl Reset the values set by searching for libintl.
+ LIBINTL=
+ LTLIBINTL=
+ INCINTL=
+ fi
+
+ ifelse(gt_included_intl, yes, [
+ if test "$gt_use_preinstalled_gnugettext" != "yes"; then
+ dnl GNU gettext is not found in the C library.
+ dnl Fall back on included GNU gettext library.
+ nls_cv_use_gnu_gettext=yes
+ fi
+ fi
+
+ if test "$nls_cv_use_gnu_gettext" = "yes"; then
+ dnl Mark actions used to generate GNU NLS library.
+ BUILD_INCLUDED_LIBINTL=yes
+ USE_INCLUDED_LIBINTL=yes
+ LIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LIBICONV $LIBTHREAD"
+ LTLIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LTLIBICONV $LTLIBTHREAD"
+ LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'`
+ fi
+
+ CATOBJEXT=
+ if test "$gt_use_preinstalled_gnugettext" = "yes" \
+ || test "$nls_cv_use_gnu_gettext" = "yes"; then
+ dnl Mark actions to use GNU gettext tools.
+ CATOBJEXT=.gmo
+ fi
+ ])
+
+ if test -n "$INTL_MACOSX_LIBS"; then
+ if test "$gt_use_preinstalled_gnugettext" = "yes" \
+ || test "$nls_cv_use_gnu_gettext" = "yes"; then
+ dnl Some extra flags are needed during linking.
+ LIBINTL="$LIBINTL $INTL_MACOSX_LIBS"
+ LTLIBINTL="$LTLIBINTL $INTL_MACOSX_LIBS"
+ fi
+ fi
+
+ if test "$gt_use_preinstalled_gnugettext" = "yes" \
+ || test "$nls_cv_use_gnu_gettext" = "yes"; then
+ AC_DEFINE([ENABLE_NLS], [1],
+ [Define to 1 if translation of program messages to the user's native language
+ is requested.])
+ else
+ USE_NLS=no
+ fi
+ fi
+
+ AC_MSG_CHECKING([whether to use NLS])
+ AC_MSG_RESULT([$USE_NLS])
+ if test "$USE_NLS" = "yes"; then
+ AC_MSG_CHECKING([where the gettext function comes from])
+ if test "$gt_use_preinstalled_gnugettext" = "yes"; then
+ if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then
+ gt_source="external libintl"
+ else
+ gt_source="libc"
+ fi
+ else
+ gt_source="included intl directory"
+ fi
+ AC_MSG_RESULT([$gt_source])
+ fi
+
+ if test "$USE_NLS" = "yes"; then
+
+ if test "$gt_use_preinstalled_gnugettext" = "yes"; then
+ if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then
+ AC_MSG_CHECKING([how to link with libintl])
+ AC_MSG_RESULT([$LIBINTL])
+ AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCINTL])
+ fi
+
+ dnl For backward compatibility. Some packages may be using this.
+ AC_DEFINE([HAVE_GETTEXT], [1],
+ [Define if the GNU gettext() function is already present or preinstalled.])
+ AC_DEFINE([HAVE_DCGETTEXT], [1],
+ [Define if the GNU dcgettext() function is already present or preinstalled.])
+ fi
+
+ dnl We need to process the po/ directory.
+ POSUB=po
+ fi
+
+ ifelse(gt_included_intl, yes, [
+ dnl If this is used in GNU gettext we have to set BUILD_INCLUDED_LIBINTL
+ dnl to 'yes' because some of the testsuite requires it.
+ if test "$PACKAGE" = gettext-runtime || test "$PACKAGE" = gettext-tools; then
+ BUILD_INCLUDED_LIBINTL=yes
+ fi
+
+ dnl Make all variables we use known to autoconf.
+ AC_SUBST([BUILD_INCLUDED_LIBINTL])
+ AC_SUBST([USE_INCLUDED_LIBINTL])
+ AC_SUBST([CATOBJEXT])
+
+ dnl For backward compatibility. Some configure.ins may be using this.
+ nls_cv_header_intl=
+ nls_cv_header_libgt=
+
+ dnl For backward compatibility. Some Makefiles may be using this.
+ DATADIRNAME=share
+ AC_SUBST([DATADIRNAME])
+
+ dnl For backward compatibility. Some Makefiles may be using this.
+ INSTOBJEXT=.mo
+ AC_SUBST([INSTOBJEXT])
+
+ dnl For backward compatibility. Some Makefiles may be using this.
+ GENCAT=gencat
+ AC_SUBST([GENCAT])
+
+ dnl For backward compatibility. Some Makefiles may be using this.
+ INTLOBJS=
+ if test "$USE_INCLUDED_LIBINTL" = yes; then
+ INTLOBJS="\$(GETTOBJS)"
+ fi
+ AC_SUBST([INTLOBJS])
+
+ dnl Enable libtool support if the surrounding package wishes it.
+ INTL_LIBTOOL_SUFFIX_PREFIX=gt_libtool_suffix_prefix
+ AC_SUBST([INTL_LIBTOOL_SUFFIX_PREFIX])
+ ])
+
+ dnl For backward compatibility. Some Makefiles may be using this.
+ INTLLIBS="$LIBINTL"
+ AC_SUBST([INTLLIBS])
+
+ dnl Make all documented variables known to autoconf.
+ AC_SUBST([LIBINTL])
+ AC_SUBST([LTLIBINTL])
+ AC_SUBST([POSUB])
+])
+
+
+dnl gt_NEEDS_INIT ensures that the gt_needs variable is initialized.
+m4_define([gt_NEEDS_INIT],
+[
+ m4_divert_text([DEFAULTS], [gt_needs=])
+ m4_define([gt_NEEDS_INIT], [])
+])
+
+
+dnl Usage: AM_GNU_GETTEXT_NEED([NEEDSYMBOL])
+AC_DEFUN([AM_GNU_GETTEXT_NEED],
+[
+ m4_divert_text([INIT_PREPARE], [gt_needs="$gt_needs $1"])
+])
+
+
+dnl Usage: AM_GNU_GETTEXT_VERSION([gettext-version])
+AC_DEFUN([AM_GNU_GETTEXT_VERSION], [])
diff --git a/package/libs/gettext/src/m4/.svn/text-base/intl.m4.svn-base b/package/libs/gettext/src/m4/.svn/text-base/intl.m4.svn-base
new file mode 100644
index 0000000..335b23c
--- /dev/null
+++ b/package/libs/gettext/src/m4/.svn/text-base/intl.m4.svn-base
@@ -0,0 +1,294 @@
+# intl.m4 serial 17 (gettext-0.18)
+dnl Copyright (C) 1995-2009 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+dnl
+dnl This file can can be used in projects which are not available under
+dnl the GNU General Public License or the GNU Library General Public
+dnl License but which still want to provide support for the GNU gettext
+dnl functionality.
+dnl Please note that the actual code of the GNU gettext library is covered
+dnl by the GNU Library General Public License, and the rest of the GNU
+dnl gettext package package is covered by the GNU General Public License.
+dnl They are *not* in the public domain.
+
+dnl Authors:
+dnl Ulrich Drepper <drepper@cygnus.com>, 1995-2000.
+dnl Bruno Haible <haible@clisp.cons.org>, 2000-2009.
+
+AC_PREREQ([2.52])
+
+dnl Checks for all prerequisites of the intl subdirectory,
+dnl except for INTL_LIBTOOL_SUFFIX_PREFIX (and possibly LIBTOOL), INTLOBJS,
+dnl USE_INCLUDED_LIBINTL, BUILD_INCLUDED_LIBINTL.
+AC_DEFUN([AM_INTL_SUBDIR],
+[
+ AC_REQUIRE([AC_PROG_INSTALL])dnl
+ AC_REQUIRE([AM_PROG_MKDIR_P])dnl defined by automake
+ AC_REQUIRE([AC_PROG_CC])dnl
+ AC_REQUIRE([AC_CANONICAL_HOST])dnl
+ AC_REQUIRE([gt_GLIBC2])dnl
+ AC_REQUIRE([AC_PROG_RANLIB])dnl
+ AC_REQUIRE([gl_VISIBILITY])dnl
+ AC_REQUIRE([gt_INTL_SUBDIR_CORE])dnl
+ AC_REQUIRE([AC_TYPE_LONG_LONG_INT])dnl
+ AC_REQUIRE([gt_TYPE_WCHAR_T])dnl
+ AC_REQUIRE([gt_TYPE_WINT_T])dnl
+ AC_REQUIRE([gl_AC_HEADER_INTTYPES_H])
+ AC_REQUIRE([gt_TYPE_INTMAX_T])
+ AC_REQUIRE([gt_PRINTF_POSIX])
+ AC_REQUIRE([gl_GLIBC21])dnl
+ AC_REQUIRE([gl_XSIZE])dnl
+ AC_REQUIRE([gl_FCNTL_O_FLAGS])dnl
+ AC_REQUIRE([gt_INTL_MACOSX])dnl
+
+ dnl Support for automake's --enable-silent-rules.
+ case "$enable_silent_rules" in
+ yes) INTL_DEFAULT_VERBOSITY=0;;
+ no) INTL_DEFAULT_VERBOSITY=1;;
+ *) INTL_DEFAULT_VERBOSITY=1;;
+ esac
+ AC_SUBST([INTL_DEFAULT_VERBOSITY])
+
+ AC_CHECK_TYPE([ptrdiff_t], ,
+ [AC_DEFINE([ptrdiff_t], [long],
+ [Define as the type of the result of subtracting two pointers, if the system doesn't define it.])
+ ])
+ AC_CHECK_HEADERS([stddef.h stdlib.h string.h])
+ AC_CHECK_FUNCS([asprintf fwprintf newlocale putenv setenv setlocale \
+ snprintf strnlen wcslen wcsnlen mbrtowc wcrtomb])
+
+ dnl Use the _snprintf function only if it is declared (because on NetBSD it
+ dnl is defined as a weak alias of snprintf; we prefer to use the latter).
+ gt_CHECK_DECL(_snprintf, [#include <stdio.h>])
+ gt_CHECK_DECL(_snwprintf, [#include <stdio.h>])
+
+ dnl Use the *_unlocked functions only if they are declared.
+ dnl (because some of them were defined without being declared in Solaris
+ dnl 2.5.1 but were removed in Solaris 2.6, whereas we want binaries built
+ dnl on Solaris 2.5.1 to run on Solaris 2.6).
+ dnl Don't use AC_CHECK_DECLS because it isn't supported in autoconf-2.13.
+ gt_CHECK_DECL(getc_unlocked, [#include <stdio.h>])
+
+ case $gt_cv_func_printf_posix in
+ *yes) HAVE_POSIX_PRINTF=1 ;;
+ *) HAVE_POSIX_PRINTF=0 ;;
+ esac
+ AC_SUBST([HAVE_POSIX_PRINTF])
+ if test "$ac_cv_func_asprintf" = yes; then
+ HAVE_ASPRINTF=1
+ else
+ HAVE_ASPRINTF=0
+ fi
+ AC_SUBST([HAVE_ASPRINTF])
+ if test "$ac_cv_func_snprintf" = yes; then
+ HAVE_SNPRINTF=1
+ else
+ HAVE_SNPRINTF=0
+ fi
+ AC_SUBST([HAVE_SNPRINTF])
+ if test "$ac_cv_func_newlocale" = yes; then
+ HAVE_NEWLOCALE=1
+ else
+ HAVE_NEWLOCALE=0
+ fi
+ AC_SUBST([HAVE_NEWLOCALE])
+ if test "$ac_cv_func_wprintf" = yes; then
+ HAVE_WPRINTF=1
+ else
+ HAVE_WPRINTF=0
+ fi
+ AC_SUBST([HAVE_WPRINTF])
+
+ AM_LANGINFO_CODESET
+ gt_LC_MESSAGES
+
+ dnl Compilation on mingw and Cygwin needs special Makefile rules, because
+ dnl 1. when we install a shared library, we must arrange to export
+ dnl auxiliary pointer variables for every exported variable,
+ dnl 2. when we install a shared library and a static library simultaneously,
+ dnl the include file specifies __declspec(dllimport) and therefore we
+ dnl must arrange to define the auxiliary pointer variables for the
+ dnl exported variables _also_ in the static library.
+ if test "$enable_shared" = yes; then
+ case "$host_os" in
+ mingw* | cygwin*) is_woe32dll=yes ;;
+ *) is_woe32dll=no ;;
+ esac
+ else
+ is_woe32dll=no
+ fi
+ WOE32DLL=$is_woe32dll
+ AC_SUBST([WOE32DLL])
+
+ dnl On mingw and Cygwin, we can activate special Makefile rules which add
+ dnl version information to the shared libraries and executables.
+ case "$host_os" in
+ mingw* | cygwin*) is_woe32=yes ;;
+ *) is_woe32=no ;;
+ esac
+ WOE32=$is_woe32
+ AC_SUBST([WOE32])
+ if test $WOE32 = yes; then
+ dnl Check for a program that compiles Windows resource files.
+ AC_CHECK_TOOL([WINDRES], [windres])
+ fi
+
+ dnl Determine whether when creating a library, "-lc" should be passed to
+ dnl libtool or not. On many platforms, it is required for the libtool option
+ dnl -no-undefined to work. On HP-UX, however, the -lc - stored by libtool
+ dnl in the *.la files - makes it impossible to create multithreaded programs,
+ dnl because libtool also reorders the -lc to come before the -pthread, and
+ dnl this disables pthread_create() <http://docs.hp.com/en/1896/pthreads.html>.
+ case "$host_os" in
+ hpux*) LTLIBC="" ;;
+ *) LTLIBC="-lc" ;;
+ esac
+ AC_SUBST([LTLIBC])
+
+ dnl Rename some macros and functions used for locking.
+ AH_BOTTOM([
+#define __libc_lock_t gl_lock_t
+#define __libc_lock_define gl_lock_define
+#define __libc_lock_define_initialized gl_lock_define_initialized
+#define __libc_lock_init gl_lock_init
+#define __libc_lock_lock gl_lock_lock
+#define __libc_lock_unlock gl_lock_unlock
+#define __libc_lock_recursive_t gl_recursive_lock_t
+#define __libc_lock_define_recursive gl_recursive_lock_define
+#define __libc_lock_define_initialized_recursive gl_recursive_lock_define_initialized
+#define __libc_lock_init_recursive gl_recursive_lock_init
+#define __libc_lock_lock_recursive gl_recursive_lock_lock
+#define __libc_lock_unlock_recursive gl_recursive_lock_unlock
+#define glthread_in_use libintl_thread_in_use
+#define glthread_lock_init_func libintl_lock_init_func
+#define glthread_lock_lock_func libintl_lock_lock_func
+#define glthread_lock_unlock_func libintl_lock_unlock_func
+#define glthread_lock_destroy_func libintl_lock_destroy_func
+#define glthread_rwlock_init_multithreaded libintl_rwlock_init_multithreaded
+#define glthread_rwlock_init_func libintl_rwlock_init_func
+#define glthread_rwlock_rdlock_multithreaded libintl_rwlock_rdlock_multithreaded
+#define glthread_rwlock_rdlock_func libintl_rwlock_rdlock_func
+#define glthread_rwlock_wrlock_multithreaded libintl_rwlock_wrlock_multithreaded
+#define glthread_rwlock_wrlock_func libintl_rwlock_wrlock_func
+#define glthread_rwlock_unlock_multithreaded libintl_rwlock_unlock_multithreaded
+#define glthread_rwlock_unlock_func libintl_rwlock_unlock_func
+#define glthread_rwlock_destroy_multithreaded libintl_rwlock_destroy_multithreaded
+#define glthread_rwlock_destroy_func libintl_rwlock_destroy_func
+#define glthread_recursive_lock_init_multithreaded libintl_recursive_lock_init_multithreaded
+#define glthread_recursive_lock_init_func libintl_recursive_lock_init_func
+#define glthread_recursive_lock_lock_multithreaded libintl_recursive_lock_lock_multithreaded
+#define glthread_recursive_lock_lock_func libintl_recursive_lock_lock_func
+#define glthread_recursive_lock_unlock_multithreaded libintl_recursive_lock_unlock_multithreaded
+#define glthread_recursive_lock_unlock_func libintl_recursive_lock_unlock_func
+#define glthread_recursive_lock_destroy_multithreaded libintl_recursive_lock_destroy_multithreaded
+#define glthread_recursive_lock_destroy_func libintl_recursive_lock_destroy_func
+#define glthread_once_func libintl_once_func
+#define glthread_once_singlethreaded libintl_once_singlethreaded
+#define glthread_once_multithreaded libintl_once_multithreaded
+])
+])
+
+
+dnl Checks for the core files of the intl subdirectory:
+dnl dcigettext.c
+dnl eval-plural.h
+dnl explodename.c
+dnl finddomain.c
+dnl gettextP.h
+dnl gmo.h
+dnl hash-string.h hash-string.c
+dnl l10nflist.c
+dnl libgnuintl.h.in (except the *printf stuff)
+dnl loadinfo.h
+dnl loadmsgcat.c
+dnl localealias.c
+dnl log.c
+dnl plural-exp.h plural-exp.c
+dnl plural.y
+dnl Used by libglocale.
+AC_DEFUN([gt_INTL_SUBDIR_CORE],
+[
+ AC_REQUIRE([AC_C_INLINE])dnl
+ AC_REQUIRE([AC_TYPE_SIZE_T])dnl
+ AC_REQUIRE([gl_AC_HEADER_STDINT_H])
+ AC_REQUIRE([AC_FUNC_ALLOCA])dnl
+ AC_REQUIRE([AC_FUNC_MMAP])dnl
+ AC_REQUIRE([gt_INTDIV0])dnl
+ AC_REQUIRE([gl_AC_TYPE_UINTMAX_T])dnl
+ AC_REQUIRE([gt_INTTYPES_PRI])dnl
+ AC_REQUIRE([gl_LOCK])dnl
+
+ AC_TRY_LINK(
+ [int foo (int a) { a = __builtin_expect (a, 10); return a == 10 ? 0 : 1; }],
+ [],
+ [AC_DEFINE([HAVE_BUILTIN_EXPECT], [1],
+ [Define to 1 if the compiler understands __builtin_expect.])])
+
+ AC_CHECK_HEADERS([argz.h inttypes.h limits.h unistd.h sys/param.h])
+ AC_CHECK_FUNCS([getcwd getegid geteuid getgid getuid mempcpy munmap \
+ stpcpy strcasecmp strdup strtoul tsearch uselocale argz_count \
+ argz_stringify argz_next __fsetlocking])
+
+ dnl Use the *_unlocked functions only if they are declared.
+ dnl (because some of them were defined without being declared in Solaris
+ dnl 2.5.1 but were removed in Solaris 2.6, whereas we want binaries built
+ dnl on Solaris 2.5.1 to run on Solaris 2.6).
+ dnl Don't use AC_CHECK_DECLS because it isn't supported in autoconf-2.13.
+ gt_CHECK_DECL([feof_unlocked], [#include <stdio.h>])
+ gt_CHECK_DECL([fgets_unlocked], [#include <stdio.h>])
+
+ AM_ICONV
+
+ dnl intl/plural.c is generated from intl/plural.y. It requires bison,
+ dnl because plural.y uses bison specific features. It requires at least
+ dnl bison-1.26 because earlier versions generate a plural.c that doesn't
+ dnl compile.
+ dnl bison is only needed for the maintainer (who touches plural.y). But in
+ dnl order to avoid separate Makefiles or --enable-maintainer-mode, we put
+ dnl the rule in general Makefile. Now, some people carelessly touch the
+ dnl files or have a broken "make" program, hence the plural.c rule will
+ dnl sometimes fire. To avoid an error, defines BISON to ":" if it is not
+ dnl present or too old.
+ AC_CHECK_PROGS([INTLBISON], [bison])
+ if test -z "$INTLBISON"; then
+ ac_verc_fail=yes
+ else
+ dnl Found it, now check the version.
+ AC_MSG_CHECKING([version of bison])
+changequote(<<,>>)dnl
+ ac_prog_version=`$INTLBISON --version 2>&1 | sed -n 's/^.*GNU Bison.* \([0-9]*\.[0-9.]*\).*$/\1/p'`
+ case $ac_prog_version in
+ '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
+ 1.2[6-9]* | 1.[3-9][0-9]* | [2-9].*)
+changequote([,])dnl
+ ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
+ *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
+ esac
+ AC_MSG_RESULT([$ac_prog_version])
+ fi
+ if test $ac_verc_fail = yes; then
+ INTLBISON=:
+ fi
+])
+
+
+dnl gt_CHECK_DECL(FUNC, INCLUDES)
+dnl Check whether a function is declared.
+AC_DEFUN([gt_CHECK_DECL],
+[
+ AC_CACHE_CHECK([whether $1 is declared], [ac_cv_have_decl_$1],
+ [AC_TRY_COMPILE([$2], [
+#ifndef $1
+ char *p = (char *) $1;
+#endif
+], ac_cv_have_decl_$1=yes, ac_cv_have_decl_$1=no)])
+ if test $ac_cv_have_decl_$1 = yes; then
+ gt_value=1
+ else
+ gt_value=0
+ fi
+ AC_DEFINE_UNQUOTED([HAVE_DECL_]translit($1, [a-z], [A-Z]), [$gt_value],
+ [Define to 1 if you have the declaration of `$1', and to 0 if you don't.])
+])
diff --git a/package/libs/gettext/src/m4/.svn/text-base/intldir.m4.svn-base b/package/libs/gettext/src/m4/.svn/text-base/intldir.m4.svn-base
new file mode 100644
index 0000000..ebae76d
--- /dev/null
+++ b/package/libs/gettext/src/m4/.svn/text-base/intldir.m4.svn-base
@@ -0,0 +1,19 @@
+# intldir.m4 serial 2 (gettext-0.18)
+dnl Copyright (C) 2006, 2009-2010 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+dnl
+dnl This file can can be used in projects which are not available under
+dnl the GNU General Public License or the GNU Library General Public
+dnl License but which still want to provide support for the GNU gettext
+dnl functionality.
+dnl Please note that the actual code of the GNU gettext library is covered
+dnl by the GNU Library General Public License, and the rest of the GNU
+dnl gettext package package is covered by the GNU General Public License.
+dnl They are *not* in the public domain.
+
+AC_PREREQ([2.52])
+
+dnl Tells the AM_GNU_GETTEXT macro to consider an intl/ directory.
+AC_DEFUN([AM_GNU_GETTEXT_INTL_SUBDIR], [])
diff --git a/package/libs/gettext/src/m4/.svn/text-base/intlmacosx.m4.svn-base b/package/libs/gettext/src/m4/.svn/text-base/intlmacosx.m4.svn-base
new file mode 100644
index 0000000..dd91025
--- /dev/null
+++ b/package/libs/gettext/src/m4/.svn/text-base/intlmacosx.m4.svn-base
@@ -0,0 +1,51 @@
+# intlmacosx.m4 serial 3 (gettext-0.18)
+dnl Copyright (C) 2004-2010 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+dnl
+dnl This file can can be used in projects which are not available under
+dnl the GNU General Public License or the GNU Library General Public
+dnl License but which still want to provide support for the GNU gettext
+dnl functionality.
+dnl Please note that the actual code of the GNU gettext library is covered
+dnl by the GNU Library General Public License, and the rest of the GNU
+dnl gettext package package is covered by the GNU General Public License.
+dnl They are *not* in the public domain.
+
+dnl Checks for special options needed on MacOS X.
+dnl Defines INTL_MACOSX_LIBS.
+AC_DEFUN([gt_INTL_MACOSX],
+[
+ dnl Check for API introduced in MacOS X 10.2.
+ AC_CACHE_CHECK([for CFPreferencesCopyAppValue],
+ [gt_cv_func_CFPreferencesCopyAppValue],
+ [gt_save_LIBS="$LIBS"
+ LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation"
+ AC_TRY_LINK([#include <CoreFoundation/CFPreferences.h>],
+ [CFPreferencesCopyAppValue(NULL, NULL)],
+ [gt_cv_func_CFPreferencesCopyAppValue=yes],
+ [gt_cv_func_CFPreferencesCopyAppValue=no])
+ LIBS="$gt_save_LIBS"])
+ if test $gt_cv_func_CFPreferencesCopyAppValue = yes; then
+ AC_DEFINE([HAVE_CFPREFERENCESCOPYAPPVALUE], [1],
+ [Define to 1 if you have the MacOS X function CFPreferencesCopyAppValue in the CoreFoundation framework.])
+ fi
+ dnl Check for API introduced in MacOS X 10.3.
+ AC_CACHE_CHECK([for CFLocaleCopyCurrent], [gt_cv_func_CFLocaleCopyCurrent],
+ [gt_save_LIBS="$LIBS"
+ LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation"
+ AC_TRY_LINK([#include <CoreFoundation/CFLocale.h>], [CFLocaleCopyCurrent();],
+ [gt_cv_func_CFLocaleCopyCurrent=yes],
+ [gt_cv_func_CFLocaleCopyCurrent=no])
+ LIBS="$gt_save_LIBS"])
+ if test $gt_cv_func_CFLocaleCopyCurrent = yes; then
+ AC_DEFINE([HAVE_CFLOCALECOPYCURRENT], [1],
+ [Define to 1 if you have the MacOS X function CFLocaleCopyCurrent in the CoreFoundation framework.])
+ fi
+ INTL_MACOSX_LIBS=
+ if test $gt_cv_func_CFPreferencesCopyAppValue = yes || test $gt_cv_func_CFLocaleCopyCurrent = yes; then
+ INTL_MACOSX_LIBS="-Wl,-framework -Wl,CoreFoundation"
+ fi
+ AC_SUBST([INTL_MACOSX_LIBS])
+])
diff --git a/package/libs/gettext/src/m4/.svn/text-base/lcmessage.m4.svn-base b/package/libs/gettext/src/m4/.svn/text-base/lcmessage.m4.svn-base
new file mode 100644
index 0000000..1a70543
--- /dev/null
+++ b/package/libs/gettext/src/m4/.svn/text-base/lcmessage.m4.svn-base
@@ -0,0 +1,31 @@
+# lcmessage.m4 serial 6 (gettext-0.18)
+dnl Copyright (C) 1995-2002, 2004-2005, 2008-2010 Free Software Foundation,
+dnl Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+dnl
+dnl This file can can be used in projects which are not available under
+dnl the GNU General Public License or the GNU Library General Public
+dnl License but which still want to provide support for the GNU gettext
+dnl functionality.
+dnl Please note that the actual code of the GNU gettext library is covered
+dnl by the GNU Library General Public License, and the rest of the GNU
+dnl gettext package package is covered by the GNU General Public License.
+dnl They are *not* in the public domain.
+
+dnl Authors:
+dnl Ulrich Drepper <drepper@cygnus.com>, 1995.
+
+# Check whether LC_MESSAGES is available in <locale.h>.
+
+AC_DEFUN([gt_LC_MESSAGES],
+[
+ AC_CACHE_CHECK([for LC_MESSAGES], [gt_cv_val_LC_MESSAGES],
+ [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
+ [gt_cv_val_LC_MESSAGES=yes], [gt_cv_val_LC_MESSAGES=no])])
+ if test $gt_cv_val_LC_MESSAGES = yes; then
+ AC_DEFINE([HAVE_LC_MESSAGES], [1],
+ [Define if your <locale.h> file defines LC_MESSAGES.])
+ fi
+])
diff --git a/package/libs/gettext/src/m4/.svn/text-base/nls.m4.svn-base b/package/libs/gettext/src/m4/.svn/text-base/nls.m4.svn-base
new file mode 100644
index 0000000..003704c
--- /dev/null
+++ b/package/libs/gettext/src/m4/.svn/text-base/nls.m4.svn-base
@@ -0,0 +1,32 @@
+# nls.m4 serial 5 (gettext-0.18)
+dnl Copyright (C) 1995-2003, 2005-2006, 2008-2010 Free Software Foundation,
+dnl Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+dnl
+dnl This file can can be used in projects which are not available under
+dnl the GNU General Public License or the GNU Library General Public
+dnl License but which still want to provide support for the GNU gettext
+dnl functionality.
+dnl Please note that the actual code of the GNU gettext library is covered
+dnl by the GNU Library General Public License, and the rest of the GNU
+dnl gettext package package is covered by the GNU General Public License.
+dnl They are *not* in the public domain.
+
+dnl Authors:
+dnl Ulrich Drepper <drepper@cygnus.com>, 1995-2000.
+dnl Bruno Haible <haible@clisp.cons.org>, 2000-2003.
+
+AC_PREREQ([2.50])
+
+AC_DEFUN([AM_NLS],
+[
+ AC_MSG_CHECKING([whether NLS is requested])
+ dnl Default is enabled NLS
+ AC_ARG_ENABLE([nls],
+ [ --disable-nls do not use Native Language Support],
+ USE_NLS=$enableval, USE_NLS=yes)
+ AC_MSG_RESULT([$USE_NLS])
+ AC_SUBST([USE_NLS])
+])
diff --git a/package/libs/gettext/src/m4/.svn/text-base/po.m4.svn-base b/package/libs/gettext/src/m4/.svn/text-base/po.m4.svn-base
new file mode 100644
index 0000000..47f36a4
--- /dev/null
+++ b/package/libs/gettext/src/m4/.svn/text-base/po.m4.svn-base
@@ -0,0 +1,449 @@
+# po.m4 serial 17 (gettext-0.18)
+dnl Copyright (C) 1995-2010 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+dnl
+dnl This file can can be used in projects which are not available under
+dnl the GNU General Public License or the GNU Library General Public
+dnl License but which still want to provide support for the GNU gettext
+dnl functionality.
+dnl Please note that the actual code of the GNU gettext library is covered
+dnl by the GNU Library General Public License, and the rest of the GNU
+dnl gettext package package is covered by the GNU General Public License.
+dnl They are *not* in the public domain.
+
+dnl Authors:
+dnl Ulrich Drepper <drepper@cygnus.com>, 1995-2000.
+dnl Bruno Haible <haible@clisp.cons.org>, 2000-2003.
+
+AC_PREREQ([2.50])
+
+dnl Checks for all prerequisites of the po subdirectory.
+AC_DEFUN([AM_PO_SUBDIRS],
+[
+ AC_REQUIRE([AC_PROG_MAKE_SET])dnl
+ AC_REQUIRE([AC_PROG_INSTALL])dnl
+ AC_REQUIRE([AM_PROG_MKDIR_P])dnl defined by automake
+ AC_REQUIRE([AM_NLS])dnl
+
+ dnl Release version of the gettext macros. This is used to ensure that
+ dnl the gettext macros and po/Makefile.in.in are in sync.
+ AC_SUBST([GETTEXT_MACRO_VERSION], [0.18])
+
+ dnl Perform the following tests also if --disable-nls has been given,
+ dnl because they are needed for "make dist" to work.
+
+ dnl Search for GNU msgfmt in the PATH.
+ dnl The first test excludes Solaris msgfmt and early GNU msgfmt versions.
+ dnl The second test excludes FreeBSD msgfmt.
+ AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
+ [$ac_dir/$ac_word --statistics /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1 &&
+ (if $ac_dir/$ac_word --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)],
+ :)
+ AC_PATH_PROG([GMSGFMT], [gmsgfmt], [$MSGFMT])
+
+ dnl Test whether it is GNU msgfmt >= 0.15.
+changequote(,)dnl
+ case `$MSGFMT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in
+ '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) MSGFMT_015=: ;;
+ *) MSGFMT_015=$MSGFMT ;;
+ esac
+changequote([,])dnl
+ AC_SUBST([MSGFMT_015])
+changequote(,)dnl
+ case `$GMSGFMT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in
+ '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) GMSGFMT_015=: ;;
+ *) GMSGFMT_015=$GMSGFMT ;;
+ esac
+changequote([,])dnl
+ AC_SUBST([GMSGFMT_015])
+
+ dnl Search for GNU xgettext 0.12 or newer in the PATH.
+ dnl The first test excludes Solaris xgettext and early GNU xgettext versions.
+ dnl The second test excludes FreeBSD xgettext.
+ AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
+ [$ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1 &&
+ (if $ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)],
+ :)
+ dnl Remove leftover from FreeBSD xgettext call.
+ rm -f messages.po
+
+ dnl Test whether it is GNU xgettext >= 0.15.
+changequote(,)dnl
+ case `$XGETTEXT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in
+ '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) XGETTEXT_015=: ;;
+ *) XGETTEXT_015=$XGETTEXT ;;
+ esac
+changequote([,])dnl
+ AC_SUBST([XGETTEXT_015])
+
+ dnl Search for GNU msgmerge 0.11 or newer in the PATH.
+ AM_PATH_PROG_WITH_TEST(MSGMERGE, msgmerge,
+ [$ac_dir/$ac_word --update -q /dev/null /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1], :)
+
+ dnl Installation directories.
+ dnl Autoconf >= 2.60 defines localedir. For older versions of autoconf, we
+ dnl have to define it here, so that it can be used in po/Makefile.
+ test -n "$localedir" || localedir='${datadir}/locale'
+ AC_SUBST([localedir])
+
+ dnl Support for AM_XGETTEXT_OPTION.
+ test -n "${XGETTEXT_EXTRA_OPTIONS+set}" || XGETTEXT_EXTRA_OPTIONS=
+ AC_SUBST([XGETTEXT_EXTRA_OPTIONS])
+
+ AC_CONFIG_COMMANDS([po-directories], [[
+ for ac_file in $CONFIG_FILES; do
+ # Support "outfile[:infile[:infile...]]"
+ case "$ac_file" in
+ *:*) ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
+ esac
+ # PO directories have a Makefile.in generated from Makefile.in.in.
+ case "$ac_file" in */Makefile.in)
+ # Adjust a relative srcdir.
+ ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'`
+ ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`"
+ ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'`
+ # In autoconf-2.13 it is called $ac_given_srcdir.
+ # In autoconf-2.50 it is called $srcdir.
+ test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir"
+ case "$ac_given_srcdir" in
+ .) top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;;
+ /*) top_srcdir="$ac_given_srcdir" ;;
+ *) top_srcdir="$ac_dots$ac_given_srcdir" ;;
+ esac
+ # Treat a directory as a PO directory if and only if it has a
+ # POTFILES.in file. This allows packages to have multiple PO
+ # directories under different names or in different locations.
+ if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then
+ rm -f "$ac_dir/POTFILES"
+ test -n "$as_me" && echo "$as_me: creating $ac_dir/POTFILES" || echo "creating $ac_dir/POTFILES"
+ cat "$ac_given_srcdir/$ac_dir/POTFILES.in" | sed -e "/^#/d" -e "/^[ ]*\$/d" -e "s,.*, $top_srcdir/& \\\\," | sed -e "\$s/\(.*\) \\\\/\1/" > "$ac_dir/POTFILES"
+ POMAKEFILEDEPS="POTFILES.in"
+ # ALL_LINGUAS, POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES depend
+ # on $ac_dir but don't depend on user-specified configuration
+ # parameters.
+ if test -f "$ac_given_srcdir/$ac_dir/LINGUAS"; then
+ # The LINGUAS file contains the set of available languages.
+ if test -n "$OBSOLETE_ALL_LINGUAS"; then
+ test -n "$as_me" && echo "$as_me: setting ALL_LINGUAS in configure.in is obsolete" || echo "setting ALL_LINGUAS in configure.in is obsolete"
+ fi
+ ALL_LINGUAS_=`sed -e "/^#/d" -e "s/#.*//" "$ac_given_srcdir/$ac_dir/LINGUAS"`
+ # Hide the ALL_LINGUAS assigment from automake < 1.5.
+ eval 'ALL_LINGUAS''=$ALL_LINGUAS_'
+ POMAKEFILEDEPS="$POMAKEFILEDEPS LINGUAS"
+ else
+ # The set of available languages was given in configure.in.
+ # Hide the ALL_LINGUAS assigment from automake < 1.5.
+ eval 'ALL_LINGUAS''=$OBSOLETE_ALL_LINGUAS'
+ fi
+ # Compute POFILES
+ # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).po)
+ # Compute UPDATEPOFILES
+ # as $(foreach lang, $(ALL_LINGUAS), $(lang).po-update)
+ # Compute DUMMYPOFILES
+ # as $(foreach lang, $(ALL_LINGUAS), $(lang).nop)
+ # Compute GMOFILES
+ # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).gmo)
+ case "$ac_given_srcdir" in
+ .) srcdirpre= ;;
+ *) srcdirpre='$(srcdir)/' ;;
+ esac
+ POFILES=
+ UPDATEPOFILES=
+ DUMMYPOFILES=
+ GMOFILES=
+ for lang in $ALL_LINGUAS; do
+ POFILES="$POFILES $srcdirpre$lang.po"
+ UPDATEPOFILES="$UPDATEPOFILES $lang.po-update"
+ DUMMYPOFILES="$DUMMYPOFILES $lang.nop"
+ GMOFILES="$GMOFILES $srcdirpre$lang.gmo"
+ done
+ # CATALOGS depends on both $ac_dir and the user's LINGUAS
+ # environment variable.
+ INST_LINGUAS=
+ if test -n "$ALL_LINGUAS"; then
+ for presentlang in $ALL_LINGUAS; do
+ useit=no
+ if test "%UNSET%" != "$LINGUAS"; then
+ desiredlanguages="$LINGUAS"
+ else
+ desiredlanguages="$ALL_LINGUAS"
+ fi
+ for desiredlang in $desiredlanguages; do
+ # Use the presentlang catalog if desiredlang is
+ # a. equal to presentlang, or
+ # b. a variant of presentlang (because in this case,
+ # presentlang can be used as a fallback for messages
+ # which are not translated in the desiredlang catalog).
+ case "$desiredlang" in
+ "$presentlang"*) useit=yes;;
+ esac
+ done
+ if test $useit = yes; then
+ INST_LINGUAS="$INST_LINGUAS $presentlang"
+ fi
+ done
+ fi
+ CATALOGS=
+ if test -n "$INST_LINGUAS"; then
+ for lang in $INST_LINGUAS; do
+ CATALOGS="$CATALOGS $lang.gmo"
+ done
+ fi
+ test -n "$as_me" && echo "$as_me: creating $ac_dir/Makefile" || echo "creating $ac_dir/Makefile"
+ sed -e "/^POTFILES =/r $ac_dir/POTFILES" -e "/^# Makevars/r $ac_given_srcdir/$ac_dir/Makevars" -e "s|@POFILES@|$POFILES|g" -e "s|@UPDATEPOFILES@|$UPDATEPOFILES|g" -e "s|@DUMMYPOFILES@|$DUMMYPOFILES|g" -e "s|@GMOFILES@|$GMOFILES|g" -e "s|@CATALOGS@|$CATALOGS|g" -e "s|@POMAKEFILEDEPS@|$POMAKEFILEDEPS|g" "$ac_dir/Makefile.in" > "$ac_dir/Makefile"
+ for f in "$ac_given_srcdir/$ac_dir"/Rules-*; do
+ if test -f "$f"; then
+ case "$f" in
+ *.orig | *.bak | *~) ;;
+ *) cat "$f" >> "$ac_dir/Makefile" ;;
+ esac
+ fi
+ done
+ fi
+ ;;
+ esac
+ done]],
+ [# Capture the value of obsolete ALL_LINGUAS because we need it to compute
+ # POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES, CATALOGS. But hide it
+ # from automake < 1.5.
+ eval 'OBSOLETE_ALL_LINGUAS''="$ALL_LINGUAS"'
+ # Capture the value of LINGUAS because we need it to compute CATALOGS.
+ LINGUAS="${LINGUAS-%UNSET%}"
+ ])
+])
+
+dnl Postprocesses a Makefile in a directory containing PO files.
+AC_DEFUN([AM_POSTPROCESS_PO_MAKEFILE],
+[
+ # When this code is run, in config.status, two variables have already been
+ # set:
+ # - OBSOLETE_ALL_LINGUAS is the value of LINGUAS set in configure.in,
+ # - LINGUAS is the value of the environment variable LINGUAS at configure
+ # time.
+
+changequote(,)dnl
+ # Adjust a relative srcdir.
+ ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'`
+ ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`"
+ ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'`
+ # In autoconf-2.13 it is called $ac_given_srcdir.
+ # In autoconf-2.50 it is called $srcdir.
+ test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir"
+ case "$ac_given_srcdir" in
+ .) top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;;
+ /*) top_srcdir="$ac_given_srcdir" ;;
+ *) top_srcdir="$ac_dots$ac_given_srcdir" ;;
+ esac
+
+ # Find a way to echo strings without interpreting backslash.
+ if test "X`(echo '\t') 2>/dev/null`" = 'X\t'; then
+ gt_echo='echo'
+ else
+ if test "X`(printf '%s\n' '\t') 2>/dev/null`" = 'X\t'; then
+ gt_echo='printf %s\n'
+ else
+ echo_func () {
+ cat <<EOT
+$*
+EOT
+ }
+ gt_echo='echo_func'
+ fi
+ fi
+
+ # A sed script that extracts the value of VARIABLE from a Makefile.
+ sed_x_variable='
+# Test if the hold space is empty.
+x
+s/P/P/
+x
+ta
+# Yes it was empty. Look if we have the expected variable definition.
+/^[ ]*VARIABLE[ ]*=/{
+ # Seen the first line of the variable definition.
+ s/^[ ]*VARIABLE[ ]*=//
+ ba
+}
+bd
+:a
+# Here we are processing a line from the variable definition.
+# Remove comment, more precisely replace it with a space.
+s/#.*$/ /
+# See if the line ends in a backslash.
+tb
+:b
+s/\\$//
+# Print the line, without the trailing backslash.
+p
+tc
+# There was no trailing backslash. The end of the variable definition is
+# reached. Clear the hold space.
+s/^.*$//
+x
+bd
+:c
+# A trailing backslash means that the variable definition continues in the
+# next line. Put a nonempty string into the hold space to indicate this.
+s/^.*$/P/
+x
+:d
+'
+changequote([,])dnl
+
+ # Set POTFILES to the value of the Makefile variable POTFILES.
+ sed_x_POTFILES=`$gt_echo "$sed_x_variable" | sed -e '/^ *#/d' -e 's/VARIABLE/POTFILES/g'`
+ POTFILES=`sed -n -e "$sed_x_POTFILES" < "$ac_file"`
+ # Compute POTFILES_DEPS as
+ # $(foreach file, $(POTFILES), $(top_srcdir)/$(file))
+ POTFILES_DEPS=
+ for file in $POTFILES; do
+ POTFILES_DEPS="$POTFILES_DEPS "'$(top_srcdir)/'"$file"
+ done
+ POMAKEFILEDEPS=""
+
+ if test -n "$OBSOLETE_ALL_LINGUAS"; then
+ test -n "$as_me" && echo "$as_me: setting ALL_LINGUAS in configure.in is obsolete" || echo "setting ALL_LINGUAS in configure.in is obsolete"
+ fi
+ if test -f "$ac_given_srcdir/$ac_dir/LINGUAS"; then
+ # The LINGUAS file contains the set of available languages.
+ ALL_LINGUAS_=`sed -e "/^#/d" -e "s/#.*//" "$ac_given_srcdir/$ac_dir/LINGUAS"`
+ POMAKEFILEDEPS="$POMAKEFILEDEPS LINGUAS"
+ else
+ # Set ALL_LINGUAS to the value of the Makefile variable LINGUAS.
+ sed_x_LINGUAS=`$gt_echo "$sed_x_variable" | sed -e '/^ *#/d' -e 's/VARIABLE/LINGUAS/g'`
+ ALL_LINGUAS_=`sed -n -e "$sed_x_LINGUAS" < "$ac_file"`
+ fi
+ # Hide the ALL_LINGUAS assigment from automake < 1.5.
+ eval 'ALL_LINGUAS''=$ALL_LINGUAS_'
+ # Compute POFILES
+ # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).po)
+ # Compute UPDATEPOFILES
+ # as $(foreach lang, $(ALL_LINGUAS), $(lang).po-update)
+ # Compute DUMMYPOFILES
+ # as $(foreach lang, $(ALL_LINGUAS), $(lang).nop)
+ # Compute GMOFILES
+ # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).gmo)
+ # Compute PROPERTIESFILES
+ # as $(foreach lang, $(ALL_LINGUAS), $(top_srcdir)/$(DOMAIN)_$(lang).properties)
+ # Compute CLASSFILES
+ # as $(foreach lang, $(ALL_LINGUAS), $(top_srcdir)/$(DOMAIN)_$(lang).class)
+ # Compute QMFILES
+ # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).qm)
+ # Compute MSGFILES
+ # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(frob $(lang)).msg)
+ # Compute RESOURCESDLLFILES
+ # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(frob $(lang))/$(DOMAIN).resources.dll)
+ case "$ac_given_srcdir" in
+ .) srcdirpre= ;;
+ *) srcdirpre='$(srcdir)/' ;;
+ esac
+ POFILES=
+ UPDATEPOFILES=
+ DUMMYPOFILES=
+ GMOFILES=
+ PROPERTIESFILES=
+ CLASSFILES=
+ QMFILES=
+ MSGFILES=
+ RESOURCESDLLFILES=
+ for lang in $ALL_LINGUAS; do
+ POFILES="$POFILES $srcdirpre$lang.po"
+ UPDATEPOFILES="$UPDATEPOFILES $lang.po-update"
+ DUMMYPOFILES="$DUMMYPOFILES $lang.nop"
+ GMOFILES="$GMOFILES $srcdirpre$lang.gmo"
+ PROPERTIESFILES="$PROPERTIESFILES \$(top_srcdir)/\$(DOMAIN)_$lang.properties"
+ CLASSFILES="$CLASSFILES \$(top_srcdir)/\$(DOMAIN)_$lang.class"
+ QMFILES="$QMFILES $srcdirpre$lang.qm"
+ frobbedlang=`echo $lang | sed -e 's/\..*$//' -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
+ MSGFILES="$MSGFILES $srcdirpre$frobbedlang.msg"
+ frobbedlang=`echo $lang | sed -e 's/_/-/g' -e 's/^sr-CS/sr-SP/' -e 's/@latin$/-Latn/' -e 's/@cyrillic$/-Cyrl/' -e 's/^sr-SP$/sr-SP-Latn/' -e 's/^uz-UZ$/uz-UZ-Latn/'`
+ RESOURCESDLLFILES="$RESOURCESDLLFILES $srcdirpre$frobbedlang/\$(DOMAIN).resources.dll"
+ done
+ # CATALOGS depends on both $ac_dir and the user's LINGUAS
+ # environment variable.
+ INST_LINGUAS=
+ if test -n "$ALL_LINGUAS"; then
+ for presentlang in $ALL_LINGUAS; do
+ useit=no
+ if test "%UNSET%" != "$LINGUAS"; then
+ desiredlanguages="$LINGUAS"
+ else
+ desiredlanguages="$ALL_LINGUAS"
+ fi
+ for desiredlang in $desiredlanguages; do
+ # Use the presentlang catalog if desiredlang is
+ # a. equal to presentlang, or
+ # b. a variant of presentlang (because in this case,
+ # presentlang can be used as a fallback for messages
+ # which are not translated in the desiredlang catalog).
+ case "$desiredlang" in
+ "$presentlang"*) useit=yes;;
+ esac
+ done
+ if test $useit = yes; then
+ INST_LINGUAS="$INST_LINGUAS $presentlang"
+ fi
+ done
+ fi
+ CATALOGS=
+ JAVACATALOGS=
+ QTCATALOGS=
+ TCLCATALOGS=
+ CSHARPCATALOGS=
+ if test -n "$INST_LINGUAS"; then
+ for lang in $INST_LINGUAS; do
+ CATALOGS="$CATALOGS $lang.gmo"
+ JAVACATALOGS="$JAVACATALOGS \$(DOMAIN)_$lang.properties"
+ QTCATALOGS="$QTCATALOGS $lang.qm"
+ frobbedlang=`echo $lang | sed -e 's/\..*$//' -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
+ TCLCATALOGS="$TCLCATALOGS $frobbedlang.msg"
+ frobbedlang=`echo $lang | sed -e 's/_/-/g' -e 's/^sr-CS/sr-SP/' -e 's/@latin$/-Latn/' -e 's/@cyrillic$/-Cyrl/' -e 's/^sr-SP$/sr-SP-Latn/' -e 's/^uz-UZ$/uz-UZ-Latn/'`
+ CSHARPCATALOGS="$CSHARPCATALOGS $frobbedlang/\$(DOMAIN).resources.dll"
+ done
+ fi
+
+ sed -e "s|@POTFILES_DEPS@|$POTFILES_DEPS|g" -e "s|@POFILES@|$POFILES|g" -e "s|@UPDATEPOFILES@|$UPDATEPOFILES|g" -e "s|@DUMMYPOFILES@|$DUMMYPOFILES|g" -e "s|@GMOFILES@|$GMOFILES|g" -e "s|@PROPERTIESFILES@|$PROPERTIESFILES|g" -e "s|@CLASSFILES@|$CLASSFILES|g" -e "s|@QMFILES@|$QMFILES|g" -e "s|@MSGFILES@|$MSGFILES|g" -e "s|@RESOURCESDLLFILES@|$RESOURCESDLLFILES|g" -e "s|@CATALOGS@|$CATALOGS|g" -e "s|@JAVACATALOGS@|$JAVACATALOGS|g" -e "s|@QTCATALOGS@|$QTCATALOGS|g" -e "s|@TCLCATALOGS@|$TCLCATALOGS|g" -e "s|@CSHARPCATALOGS@|$CSHARPCATALOGS|g" -e 's,^#distdir:,distdir:,' < "$ac_file" > "$ac_file.tmp"
+ if grep -l '@TCLCATALOGS@' "$ac_file" > /dev/null; then
+ # Add dependencies that cannot be formulated as a simple suffix rule.
+ for lang in $ALL_LINGUAS; do
+ frobbedlang=`echo $lang | sed -e 's/\..*$//' -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
+ cat >> "$ac_file.tmp" <<EOF
+$frobbedlang.msg: $lang.po
+ @echo "\$(MSGFMT) -c --tcl -d \$(srcdir) -l $lang $srcdirpre$lang.po"; \
+ \$(MSGFMT) -c --tcl -d "\$(srcdir)" -l $lang $srcdirpre$lang.po || { rm -f "\$(srcdir)/$frobbedlang.msg"; exit 1; }
+EOF
+ done
+ fi
+ if grep -l '@CSHARPCATALOGS@' "$ac_file" > /dev/null; then
+ # Add dependencies that cannot be formulated as a simple suffix rule.
+ for lang in $ALL_LINGUAS; do
+ frobbedlang=`echo $lang | sed -e 's/_/-/g' -e 's/^sr-CS/sr-SP/' -e 's/@latin$/-Latn/' -e 's/@cyrillic$/-Cyrl/' -e 's/^sr-SP$/sr-SP-Latn/' -e 's/^uz-UZ$/uz-UZ-Latn/'`
+ cat >> "$ac_file.tmp" <<EOF
+$frobbedlang/\$(DOMAIN).resources.dll: $lang.po
+ @echo "\$(MSGFMT) -c --csharp -d \$(srcdir) -l $lang $srcdirpre$lang.po -r \$(DOMAIN)"; \
+ \$(MSGFMT) -c --csharp -d "\$(srcdir)" -l $lang $srcdirpre$lang.po -r "\$(DOMAIN)" || { rm -f "\$(srcdir)/$frobbedlang.msg"; exit 1; }
+EOF
+ done
+ fi
+ if test -n "$POMAKEFILEDEPS"; then
+ cat >> "$ac_file.tmp" <<EOF
+Makefile: $POMAKEFILEDEPS
+EOF
+ fi
+ mv "$ac_file.tmp" "$ac_file"
+])
+
+dnl Initializes the accumulator used by AM_XGETTEXT_OPTION.
+AC_DEFUN([AM_XGETTEXT_OPTION_INIT],
+[
+ XGETTEXT_EXTRA_OPTIONS=
+])
+
+dnl Registers an option to be passed to xgettext in the po subdirectory.
+AC_DEFUN([AM_XGETTEXT_OPTION],
+[
+ AC_REQUIRE([AM_XGETTEXT_OPTION_INIT])
+ XGETTEXT_EXTRA_OPTIONS="$XGETTEXT_EXTRA_OPTIONS $1"
+])
diff --git a/package/libs/gettext/src/m4/codeset.m4 b/package/libs/gettext/src/m4/codeset.m4
new file mode 100644
index 0000000..a53c042
--- /dev/null
+++ b/package/libs/gettext/src/m4/codeset.m4
@@ -0,0 +1,21 @@
+# codeset.m4 serial 4 (gettext-0.18)
+dnl Copyright (C) 2000-2002, 2006, 2008-2010 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Bruno Haible.
+
+AC_DEFUN([AM_LANGINFO_CODESET],
+[
+ AC_CACHE_CHECK([for nl_langinfo and CODESET], [am_cv_langinfo_codeset],
+ [AC_TRY_LINK([#include <langinfo.h>],
+ [char* cs = nl_langinfo(CODESET); return !cs;],
+ [am_cv_langinfo_codeset=yes],
+ [am_cv_langinfo_codeset=no])
+ ])
+ if test $am_cv_langinfo_codeset = yes; then
+ AC_DEFINE([HAVE_LANGINFO_CODESET], [1],
+ [Define if you have <langinfo.h> and nl_langinfo(CODESET).])
+ fi
+])
diff --git a/package/libs/gettext/src/m4/gettext.m4 b/package/libs/gettext/src/m4/gettext.m4
new file mode 100644
index 0000000..f84e6a5
--- /dev/null
+++ b/package/libs/gettext/src/m4/gettext.m4
@@ -0,0 +1,383 @@
+# gettext.m4 serial 63 (gettext-0.18)
+dnl Copyright (C) 1995-2010 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+dnl
+dnl This file can can be used in projects which are not available under
+dnl the GNU General Public License or the GNU Library General Public
+dnl License but which still want to provide support for the GNU gettext
+dnl functionality.
+dnl Please note that the actual code of the GNU gettext library is covered
+dnl by the GNU Library General Public License, and the rest of the GNU
+dnl gettext package package is covered by the GNU General Public License.
+dnl They are *not* in the public domain.
+
+dnl Authors:
+dnl Ulrich Drepper <drepper@cygnus.com>, 1995-2000.
+dnl Bruno Haible <haible@clisp.cons.org>, 2000-2006, 2008-2010.
+
+dnl Macro to add for using GNU gettext.
+
+dnl Usage: AM_GNU_GETTEXT([INTLSYMBOL], [NEEDSYMBOL], [INTLDIR]).
+dnl INTLSYMBOL can be one of 'external', 'no-libtool', 'use-libtool'. The
+dnl default (if it is not specified or empty) is 'no-libtool'.
+dnl INTLSYMBOL should be 'external' for packages with no intl directory,
+dnl and 'no-libtool' or 'use-libtool' for packages with an intl directory.
+dnl If INTLSYMBOL is 'use-libtool', then a libtool library
+dnl $(top_builddir)/intl/libintl.la will be created (shared and/or static,
+dnl depending on --{enable,disable}-{shared,static} and on the presence of
+dnl AM-DISABLE-SHARED). If INTLSYMBOL is 'no-libtool', a static library
+dnl $(top_builddir)/intl/libintl.a will be created.
+dnl If NEEDSYMBOL is specified and is 'need-ngettext', then GNU gettext
+dnl implementations (in libc or libintl) without the ngettext() function
+dnl will be ignored. If NEEDSYMBOL is specified and is
+dnl 'need-formatstring-macros', then GNU gettext implementations that don't
+dnl support the ISO C 99 <inttypes.h> formatstring macros will be ignored.
+dnl INTLDIR is used to find the intl libraries. If empty,
+dnl the value `$(top_builddir)/intl/' is used.
+dnl
+dnl The result of the configuration is one of three cases:
+dnl 1) GNU gettext, as included in the intl subdirectory, will be compiled
+dnl and used.
+dnl Catalog format: GNU --> install in $(datadir)
+dnl Catalog extension: .mo after installation, .gmo in source tree
+dnl 2) GNU gettext has been found in the system's C library.
+dnl Catalog format: GNU --> install in $(datadir)
+dnl Catalog extension: .mo after installation, .gmo in source tree
+dnl 3) No internationalization, always use English msgid.
+dnl Catalog format: none
+dnl Catalog extension: none
+dnl If INTLSYMBOL is 'external', only cases 2 and 3 can occur.
+dnl The use of .gmo is historical (it was needed to avoid overwriting the
+dnl GNU format catalogs when building on a platform with an X/Open gettext),
+dnl but we keep it in order not to force irrelevant filename changes on the
+dnl maintainers.
+dnl
+AC_DEFUN([AM_GNU_GETTEXT],
+[
+ dnl Argument checking.
+ ifelse([$1], [], , [ifelse([$1], [external], , [ifelse([$1], [no-libtool], , [ifelse([$1], [use-libtool], ,
+ [errprint([ERROR: invalid first argument to AM_GNU_GETTEXT
+])])])])])
+ ifelse(ifelse([$1], [], [old])[]ifelse([$1], [no-libtool], [old]), [old],
+ [AC_DIAGNOSE([obsolete], [Use of AM_GNU_GETTEXT without [external] argument is deprecated.])])
+ ifelse([$2], [], , [ifelse([$2], [need-ngettext], , [ifelse([$2], [need-formatstring-macros], ,
+ [errprint([ERROR: invalid second argument to AM_GNU_GETTEXT
+])])])])
+ define([gt_included_intl],
+ ifelse([$1], [external],
+ ifdef([AM_GNU_GETTEXT_][INTL_SUBDIR], [yes], [no]),
+ [yes]))
+ define([gt_libtool_suffix_prefix], ifelse([$1], [use-libtool], [l], []))
+ gt_NEEDS_INIT
+ AM_GNU_GETTEXT_NEED([$2])
+
+ AC_REQUIRE([AM_PO_SUBDIRS])dnl
+ ifelse(gt_included_intl, yes, [
+ AC_REQUIRE([AM_INTL_SUBDIR])dnl
+ ])
+
+ dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
+ AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
+ AC_REQUIRE([AC_LIB_RPATH])
+
+ dnl Sometimes libintl requires libiconv, so first search for libiconv.
+ dnl Ideally we would do this search only after the
+ dnl if test "$USE_NLS" = "yes"; then
+ dnl if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" != "yes"; }; then
+ dnl tests. But if configure.in invokes AM_ICONV after AM_GNU_GETTEXT
+ dnl the configure script would need to contain the same shell code
+ dnl again, outside any 'if'. There are two solutions:
+ dnl - Invoke AM_ICONV_LINKFLAGS_BODY here, outside any 'if'.
+ dnl - Control the expansions in more detail using AC_PROVIDE_IFELSE.
+ dnl Since AC_PROVIDE_IFELSE is only in autoconf >= 2.52 and not
+ dnl documented, we avoid it.
+ ifelse(gt_included_intl, yes, , [
+ AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY])
+ ])
+
+ dnl Sometimes, on MacOS X, libintl requires linking with CoreFoundation.
+ gt_INTL_MACOSX
+
+ dnl Set USE_NLS.
+ AC_REQUIRE([AM_NLS])
+
+ ifelse(gt_included_intl, yes, [
+ BUILD_INCLUDED_LIBINTL=no
+ USE_INCLUDED_LIBINTL=no
+ ])
+ LIBINTL=
+ LTLIBINTL=
+ POSUB=
+
+ dnl Add a version number to the cache macros.
+ case " $gt_needs " in
+ *" need-formatstring-macros "*) gt_api_version=3 ;;
+ *" need-ngettext "*) gt_api_version=2 ;;
+ *) gt_api_version=1 ;;
+ esac
+ gt_func_gnugettext_libc="gt_cv_func_gnugettext${gt_api_version}_libc"
+ gt_func_gnugettext_libintl="gt_cv_func_gnugettext${gt_api_version}_libintl"
+
+ dnl If we use NLS figure out what method
+ if test "$USE_NLS" = "yes"; then
+ gt_use_preinstalled_gnugettext=no
+ ifelse(gt_included_intl, yes, [
+ AC_MSG_CHECKING([whether included gettext is requested])
+ AC_ARG_WITH([included-gettext],
+ [ --with-included-gettext use the GNU gettext library included here],
+ nls_cv_force_use_gnu_gettext=$withval,
+ nls_cv_force_use_gnu_gettext=no)
+ AC_MSG_RESULT([$nls_cv_force_use_gnu_gettext])
+
+ nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
+ if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
+ ])
+ dnl User does not insist on using GNU NLS library. Figure out what
+ dnl to use. If GNU gettext is available we use this. Else we have
+ dnl to fall back to GNU NLS library.
+
+ if test $gt_api_version -ge 3; then
+ gt_revision_test_code='
+#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
+#define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1)
+#endif
+changequote(,)dnl
+typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1];
+changequote([,])dnl
+'
+ else
+ gt_revision_test_code=
+ fi
+ if test $gt_api_version -ge 2; then
+ gt_expression_test_code=' + * ngettext ("", "", 0)'
+ else
+ gt_expression_test_code=
+ fi
+
+ AC_CACHE_CHECK([for GNU gettext in libc], [$gt_func_gnugettext_libc],
+ [AC_TRY_LINK([#include <libintl.h>
+$gt_revision_test_code
+extern int _nl_msg_cat_cntr;
+extern int *_nl_domain_bindings;],
+ [bindtextdomain ("", "");
+return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_domain_bindings],
+ [eval "$gt_func_gnugettext_libc=yes"],
+ [eval "$gt_func_gnugettext_libc=no"])])
+
+ if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" != "yes"; }; then
+ dnl Sometimes libintl requires libiconv, so first search for libiconv.
+ ifelse(gt_included_intl, yes, , [
+ AM_ICONV_LINK
+ ])
+ dnl Search for libintl and define LIBINTL, LTLIBINTL and INCINTL
+ dnl accordingly. Don't use AC_LIB_LINKFLAGS_BODY([intl],[iconv])
+ dnl because that would add "-liconv" to LIBINTL and LTLIBINTL
+ dnl even if libiconv doesn't exist.
+ AC_LIB_LINKFLAGS_BODY([intl])
+ AC_CACHE_CHECK([for GNU gettext in libintl],
+ [$gt_func_gnugettext_libintl],
+ [gt_save_CPPFLAGS="$CPPFLAGS"
+ CPPFLAGS="$CPPFLAGS $INCINTL"
+ gt_save_LIBS="$LIBS"
+ LIBS="$LIBS $LIBINTL"
+ dnl Now see whether libintl exists and does not depend on libiconv.
+ AC_TRY_LINK([#include <libintl.h>
+$gt_revision_test_code
+extern int _nl_msg_cat_cntr;
+extern
+#ifdef __cplusplus
+"C"
+#endif
+const char *_nl_expand_alias (const char *);],
+ [bindtextdomain ("", "");
+return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_alias ("")],
+ [eval "$gt_func_gnugettext_libintl=yes"],
+ [eval "$gt_func_gnugettext_libintl=no"])
+ dnl Now see whether libintl exists and depends on libiconv.
+ if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" != yes; } && test -n "$LIBICONV"; then
+ LIBS="$LIBS $LIBICONV"
+ AC_TRY_LINK([#include <libintl.h>
+$gt_revision_test_code
+extern int _nl_msg_cat_cntr;
+extern
+#ifdef __cplusplus
+"C"
+#endif
+const char *_nl_expand_alias (const char *);],
+ [bindtextdomain ("", "");
+return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_alias ("")],
+ [LIBINTL="$LIBINTL $LIBICONV"
+ LTLIBINTL="$LTLIBINTL $LTLIBICONV"
+ eval "$gt_func_gnugettext_libintl=yes"
+ ])
+ fi
+ CPPFLAGS="$gt_save_CPPFLAGS"
+ LIBS="$gt_save_LIBS"])
+ fi
+
+ dnl If an already present or preinstalled GNU gettext() is found,
+ dnl use it. But if this macro is used in GNU gettext, and GNU
+ dnl gettext is already preinstalled in libintl, we update this
+ dnl libintl. (Cf. the install rule in intl/Makefile.in.)
+ if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" = "yes"; } \
+ || { { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; } \
+ && test "$PACKAGE" != gettext-runtime \
+ && test "$PACKAGE" != gettext-tools; }; then
+ gt_use_preinstalled_gnugettext=yes
+ else
+ dnl Reset the values set by searching for libintl.
+ LIBINTL=
+ LTLIBINTL=
+ INCINTL=
+ fi
+
+ ifelse(gt_included_intl, yes, [
+ if test "$gt_use_preinstalled_gnugettext" != "yes"; then
+ dnl GNU gettext is not found in the C library.
+ dnl Fall back on included GNU gettext library.
+ nls_cv_use_gnu_gettext=yes
+ fi
+ fi
+
+ if test "$nls_cv_use_gnu_gettext" = "yes"; then
+ dnl Mark actions used to generate GNU NLS library.
+ BUILD_INCLUDED_LIBINTL=yes
+ USE_INCLUDED_LIBINTL=yes
+ LIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LIBICONV $LIBTHREAD"
+ LTLIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LTLIBICONV $LTLIBTHREAD"
+ LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'`
+ fi
+
+ CATOBJEXT=
+ if test "$gt_use_preinstalled_gnugettext" = "yes" \
+ || test "$nls_cv_use_gnu_gettext" = "yes"; then
+ dnl Mark actions to use GNU gettext tools.
+ CATOBJEXT=.gmo
+ fi
+ ])
+
+ if test -n "$INTL_MACOSX_LIBS"; then
+ if test "$gt_use_preinstalled_gnugettext" = "yes" \
+ || test "$nls_cv_use_gnu_gettext" = "yes"; then
+ dnl Some extra flags are needed during linking.
+ LIBINTL="$LIBINTL $INTL_MACOSX_LIBS"
+ LTLIBINTL="$LTLIBINTL $INTL_MACOSX_LIBS"
+ fi
+ fi
+
+ if test "$gt_use_preinstalled_gnugettext" = "yes" \
+ || test "$nls_cv_use_gnu_gettext" = "yes"; then
+ AC_DEFINE([ENABLE_NLS], [1],
+ [Define to 1 if translation of program messages to the user's native language
+ is requested.])
+ else
+ USE_NLS=no
+ fi
+ fi
+
+ AC_MSG_CHECKING([whether to use NLS])
+ AC_MSG_RESULT([$USE_NLS])
+ if test "$USE_NLS" = "yes"; then
+ AC_MSG_CHECKING([where the gettext function comes from])
+ if test "$gt_use_preinstalled_gnugettext" = "yes"; then
+ if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then
+ gt_source="external libintl"
+ else
+ gt_source="libc"
+ fi
+ else
+ gt_source="included intl directory"
+ fi
+ AC_MSG_RESULT([$gt_source])
+ fi
+
+ if test "$USE_NLS" = "yes"; then
+
+ if test "$gt_use_preinstalled_gnugettext" = "yes"; then
+ if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then
+ AC_MSG_CHECKING([how to link with libintl])
+ AC_MSG_RESULT([$LIBINTL])
+ AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCINTL])
+ fi
+
+ dnl For backward compatibility. Some packages may be using this.
+ AC_DEFINE([HAVE_GETTEXT], [1],
+ [Define if the GNU gettext() function is already present or preinstalled.])
+ AC_DEFINE([HAVE_DCGETTEXT], [1],
+ [Define if the GNU dcgettext() function is already present or preinstalled.])
+ fi
+
+ dnl We need to process the po/ directory.
+ POSUB=po
+ fi
+
+ ifelse(gt_included_intl, yes, [
+ dnl If this is used in GNU gettext we have to set BUILD_INCLUDED_LIBINTL
+ dnl to 'yes' because some of the testsuite requires it.
+ if test "$PACKAGE" = gettext-runtime || test "$PACKAGE" = gettext-tools; then
+ BUILD_INCLUDED_LIBINTL=yes
+ fi
+
+ dnl Make all variables we use known to autoconf.
+ AC_SUBST([BUILD_INCLUDED_LIBINTL])
+ AC_SUBST([USE_INCLUDED_LIBINTL])
+ AC_SUBST([CATOBJEXT])
+
+ dnl For backward compatibility. Some configure.ins may be using this.
+ nls_cv_header_intl=
+ nls_cv_header_libgt=
+
+ dnl For backward compatibility. Some Makefiles may be using this.
+ DATADIRNAME=share
+ AC_SUBST([DATADIRNAME])
+
+ dnl For backward compatibility. Some Makefiles may be using this.
+ INSTOBJEXT=.mo
+ AC_SUBST([INSTOBJEXT])
+
+ dnl For backward compatibility. Some Makefiles may be using this.
+ GENCAT=gencat
+ AC_SUBST([GENCAT])
+
+ dnl For backward compatibility. Some Makefiles may be using this.
+ INTLOBJS=
+ if test "$USE_INCLUDED_LIBINTL" = yes; then
+ INTLOBJS="\$(GETTOBJS)"
+ fi
+ AC_SUBST([INTLOBJS])
+
+ dnl Enable libtool support if the surrounding package wishes it.
+ INTL_LIBTOOL_SUFFIX_PREFIX=gt_libtool_suffix_prefix
+ AC_SUBST([INTL_LIBTOOL_SUFFIX_PREFIX])
+ ])
+
+ dnl For backward compatibility. Some Makefiles may be using this.
+ INTLLIBS="$LIBINTL"
+ AC_SUBST([INTLLIBS])
+
+ dnl Make all documented variables known to autoconf.
+ AC_SUBST([LIBINTL])
+ AC_SUBST([LTLIBINTL])
+ AC_SUBST([POSUB])
+])
+
+
+dnl gt_NEEDS_INIT ensures that the gt_needs variable is initialized.
+m4_define([gt_NEEDS_INIT],
+[
+ m4_divert_text([DEFAULTS], [gt_needs=])
+ m4_define([gt_NEEDS_INIT], [])
+])
+
+
+dnl Usage: AM_GNU_GETTEXT_NEED([NEEDSYMBOL])
+AC_DEFUN([AM_GNU_GETTEXT_NEED],
+[
+ m4_divert_text([INIT_PREPARE], [gt_needs="$gt_needs $1"])
+])
+
+
+dnl Usage: AM_GNU_GETTEXT_VERSION([gettext-version])
+AC_DEFUN([AM_GNU_GETTEXT_VERSION], [])
diff --git a/package/libs/gettext/src/m4/intl.m4 b/package/libs/gettext/src/m4/intl.m4
new file mode 100644
index 0000000..335b23c
--- /dev/null
+++ b/package/libs/gettext/src/m4/intl.m4
@@ -0,0 +1,294 @@
+# intl.m4 serial 17 (gettext-0.18)
+dnl Copyright (C) 1995-2009 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+dnl
+dnl This file can can be used in projects which are not available under
+dnl the GNU General Public License or the GNU Library General Public
+dnl License but which still want to provide support for the GNU gettext
+dnl functionality.
+dnl Please note that the actual code of the GNU gettext library is covered
+dnl by the GNU Library General Public License, and the rest of the GNU
+dnl gettext package package is covered by the GNU General Public License.
+dnl They are *not* in the public domain.
+
+dnl Authors:
+dnl Ulrich Drepper <drepper@cygnus.com>, 1995-2000.
+dnl Bruno Haible <haible@clisp.cons.org>, 2000-2009.
+
+AC_PREREQ([2.52])
+
+dnl Checks for all prerequisites of the intl subdirectory,
+dnl except for INTL_LIBTOOL_SUFFIX_PREFIX (and possibly LIBTOOL), INTLOBJS,
+dnl USE_INCLUDED_LIBINTL, BUILD_INCLUDED_LIBINTL.
+AC_DEFUN([AM_INTL_SUBDIR],
+[
+ AC_REQUIRE([AC_PROG_INSTALL])dnl
+ AC_REQUIRE([AM_PROG_MKDIR_P])dnl defined by automake
+ AC_REQUIRE([AC_PROG_CC])dnl
+ AC_REQUIRE([AC_CANONICAL_HOST])dnl
+ AC_REQUIRE([gt_GLIBC2])dnl
+ AC_REQUIRE([AC_PROG_RANLIB])dnl
+ AC_REQUIRE([gl_VISIBILITY])dnl
+ AC_REQUIRE([gt_INTL_SUBDIR_CORE])dnl
+ AC_REQUIRE([AC_TYPE_LONG_LONG_INT])dnl
+ AC_REQUIRE([gt_TYPE_WCHAR_T])dnl
+ AC_REQUIRE([gt_TYPE_WINT_T])dnl
+ AC_REQUIRE([gl_AC_HEADER_INTTYPES_H])
+ AC_REQUIRE([gt_TYPE_INTMAX_T])
+ AC_REQUIRE([gt_PRINTF_POSIX])
+ AC_REQUIRE([gl_GLIBC21])dnl
+ AC_REQUIRE([gl_XSIZE])dnl
+ AC_REQUIRE([gl_FCNTL_O_FLAGS])dnl
+ AC_REQUIRE([gt_INTL_MACOSX])dnl
+
+ dnl Support for automake's --enable-silent-rules.
+ case "$enable_silent_rules" in
+ yes) INTL_DEFAULT_VERBOSITY=0;;
+ no) INTL_DEFAULT_VERBOSITY=1;;
+ *) INTL_DEFAULT_VERBOSITY=1;;
+ esac
+ AC_SUBST([INTL_DEFAULT_VERBOSITY])
+
+ AC_CHECK_TYPE([ptrdiff_t], ,
+ [AC_DEFINE([ptrdiff_t], [long],
+ [Define as the type of the result of subtracting two pointers, if the system doesn't define it.])
+ ])
+ AC_CHECK_HEADERS([stddef.h stdlib.h string.h])
+ AC_CHECK_FUNCS([asprintf fwprintf newlocale putenv setenv setlocale \
+ snprintf strnlen wcslen wcsnlen mbrtowc wcrtomb])
+
+ dnl Use the _snprintf function only if it is declared (because on NetBSD it
+ dnl is defined as a weak alias of snprintf; we prefer to use the latter).
+ gt_CHECK_DECL(_snprintf, [#include <stdio.h>])
+ gt_CHECK_DECL(_snwprintf, [#include <stdio.h>])
+
+ dnl Use the *_unlocked functions only if they are declared.
+ dnl (because some of them were defined without being declared in Solaris
+ dnl 2.5.1 but were removed in Solaris 2.6, whereas we want binaries built
+ dnl on Solaris 2.5.1 to run on Solaris 2.6).
+ dnl Don't use AC_CHECK_DECLS because it isn't supported in autoconf-2.13.
+ gt_CHECK_DECL(getc_unlocked, [#include <stdio.h>])
+
+ case $gt_cv_func_printf_posix in
+ *yes) HAVE_POSIX_PRINTF=1 ;;
+ *) HAVE_POSIX_PRINTF=0 ;;
+ esac
+ AC_SUBST([HAVE_POSIX_PRINTF])
+ if test "$ac_cv_func_asprintf" = yes; then
+ HAVE_ASPRINTF=1
+ else
+ HAVE_ASPRINTF=0
+ fi
+ AC_SUBST([HAVE_ASPRINTF])
+ if test "$ac_cv_func_snprintf" = yes; then
+ HAVE_SNPRINTF=1
+ else
+ HAVE_SNPRINTF=0
+ fi
+ AC_SUBST([HAVE_SNPRINTF])
+ if test "$ac_cv_func_newlocale" = yes; then
+ HAVE_NEWLOCALE=1
+ else
+ HAVE_NEWLOCALE=0
+ fi
+ AC_SUBST([HAVE_NEWLOCALE])
+ if test "$ac_cv_func_wprintf" = yes; then
+ HAVE_WPRINTF=1
+ else
+ HAVE_WPRINTF=0
+ fi
+ AC_SUBST([HAVE_WPRINTF])
+
+ AM_LANGINFO_CODESET
+ gt_LC_MESSAGES
+
+ dnl Compilation on mingw and Cygwin needs special Makefile rules, because
+ dnl 1. when we install a shared library, we must arrange to export
+ dnl auxiliary pointer variables for every exported variable,
+ dnl 2. when we install a shared library and a static library simultaneously,
+ dnl the include file specifies __declspec(dllimport) and therefore we
+ dnl must arrange to define the auxiliary pointer variables for the
+ dnl exported variables _also_ in the static library.
+ if test "$enable_shared" = yes; then
+ case "$host_os" in
+ mingw* | cygwin*) is_woe32dll=yes ;;
+ *) is_woe32dll=no ;;
+ esac
+ else
+ is_woe32dll=no
+ fi
+ WOE32DLL=$is_woe32dll
+ AC_SUBST([WOE32DLL])
+
+ dnl On mingw and Cygwin, we can activate special Makefile rules which add
+ dnl version information to the shared libraries and executables.
+ case "$host_os" in
+ mingw* | cygwin*) is_woe32=yes ;;
+ *) is_woe32=no ;;
+ esac
+ WOE32=$is_woe32
+ AC_SUBST([WOE32])
+ if test $WOE32 = yes; then
+ dnl Check for a program that compiles Windows resource files.
+ AC_CHECK_TOOL([WINDRES], [windres])
+ fi
+
+ dnl Determine whether when creating a library, "-lc" should be passed to
+ dnl libtool or not. On many platforms, it is required for the libtool option
+ dnl -no-undefined to work. On HP-UX, however, the -lc - stored by libtool
+ dnl in the *.la files - makes it impossible to create multithreaded programs,
+ dnl because libtool also reorders the -lc to come before the -pthread, and
+ dnl this disables pthread_create() <http://docs.hp.com/en/1896/pthreads.html>.
+ case "$host_os" in
+ hpux*) LTLIBC="" ;;
+ *) LTLIBC="-lc" ;;
+ esac
+ AC_SUBST([LTLIBC])
+
+ dnl Rename some macros and functions used for locking.
+ AH_BOTTOM([
+#define __libc_lock_t gl_lock_t
+#define __libc_lock_define gl_lock_define
+#define __libc_lock_define_initialized gl_lock_define_initialized
+#define __libc_lock_init gl_lock_init
+#define __libc_lock_lock gl_lock_lock
+#define __libc_lock_unlock gl_lock_unlock
+#define __libc_lock_recursive_t gl_recursive_lock_t
+#define __libc_lock_define_recursive gl_recursive_lock_define
+#define __libc_lock_define_initialized_recursive gl_recursive_lock_define_initialized
+#define __libc_lock_init_recursive gl_recursive_lock_init
+#define __libc_lock_lock_recursive gl_recursive_lock_lock
+#define __libc_lock_unlock_recursive gl_recursive_lock_unlock
+#define glthread_in_use libintl_thread_in_use
+#define glthread_lock_init_func libintl_lock_init_func
+#define glthread_lock_lock_func libintl_lock_lock_func
+#define glthread_lock_unlock_func libintl_lock_unlock_func
+#define glthread_lock_destroy_func libintl_lock_destroy_func
+#define glthread_rwlock_init_multithreaded libintl_rwlock_init_multithreaded
+#define glthread_rwlock_init_func libintl_rwlock_init_func
+#define glthread_rwlock_rdlock_multithreaded libintl_rwlock_rdlock_multithreaded
+#define glthread_rwlock_rdlock_func libintl_rwlock_rdlock_func
+#define glthread_rwlock_wrlock_multithreaded libintl_rwlock_wrlock_multithreaded
+#define glthread_rwlock_wrlock_func libintl_rwlock_wrlock_func
+#define glthread_rwlock_unlock_multithreaded libintl_rwlock_unlock_multithreaded
+#define glthread_rwlock_unlock_func libintl_rwlock_unlock_func
+#define glthread_rwlock_destroy_multithreaded libintl_rwlock_destroy_multithreaded
+#define glthread_rwlock_destroy_func libintl_rwlock_destroy_func
+#define glthread_recursive_lock_init_multithreaded libintl_recursive_lock_init_multithreaded
+#define glthread_recursive_lock_init_func libintl_recursive_lock_init_func
+#define glthread_recursive_lock_lock_multithreaded libintl_recursive_lock_lock_multithreaded
+#define glthread_recursive_lock_lock_func libintl_recursive_lock_lock_func
+#define glthread_recursive_lock_unlock_multithreaded libintl_recursive_lock_unlock_multithreaded
+#define glthread_recursive_lock_unlock_func libintl_recursive_lock_unlock_func
+#define glthread_recursive_lock_destroy_multithreaded libintl_recursive_lock_destroy_multithreaded
+#define glthread_recursive_lock_destroy_func libintl_recursive_lock_destroy_func
+#define glthread_once_func libintl_once_func
+#define glthread_once_singlethreaded libintl_once_singlethreaded
+#define glthread_once_multithreaded libintl_once_multithreaded
+])
+])
+
+
+dnl Checks for the core files of the intl subdirectory:
+dnl dcigettext.c
+dnl eval-plural.h
+dnl explodename.c
+dnl finddomain.c
+dnl gettextP.h
+dnl gmo.h
+dnl hash-string.h hash-string.c
+dnl l10nflist.c
+dnl libgnuintl.h.in (except the *printf stuff)
+dnl loadinfo.h
+dnl loadmsgcat.c
+dnl localealias.c
+dnl log.c
+dnl plural-exp.h plural-exp.c
+dnl plural.y
+dnl Used by libglocale.
+AC_DEFUN([gt_INTL_SUBDIR_CORE],
+[
+ AC_REQUIRE([AC_C_INLINE])dnl
+ AC_REQUIRE([AC_TYPE_SIZE_T])dnl
+ AC_REQUIRE([gl_AC_HEADER_STDINT_H])
+ AC_REQUIRE([AC_FUNC_ALLOCA])dnl
+ AC_REQUIRE([AC_FUNC_MMAP])dnl
+ AC_REQUIRE([gt_INTDIV0])dnl
+ AC_REQUIRE([gl_AC_TYPE_UINTMAX_T])dnl
+ AC_REQUIRE([gt_INTTYPES_PRI])dnl
+ AC_REQUIRE([gl_LOCK])dnl
+
+ AC_TRY_LINK(
+ [int foo (int a) { a = __builtin_expect (a, 10); return a == 10 ? 0 : 1; }],
+ [],
+ [AC_DEFINE([HAVE_BUILTIN_EXPECT], [1],
+ [Define to 1 if the compiler understands __builtin_expect.])])
+
+ AC_CHECK_HEADERS([argz.h inttypes.h limits.h unistd.h sys/param.h])
+ AC_CHECK_FUNCS([getcwd getegid geteuid getgid getuid mempcpy munmap \
+ stpcpy strcasecmp strdup strtoul tsearch uselocale argz_count \
+ argz_stringify argz_next __fsetlocking])
+
+ dnl Use the *_unlocked functions only if they are declared.
+ dnl (because some of them were defined without being declared in Solaris
+ dnl 2.5.1 but were removed in Solaris 2.6, whereas we want binaries built
+ dnl on Solaris 2.5.1 to run on Solaris 2.6).
+ dnl Don't use AC_CHECK_DECLS because it isn't supported in autoconf-2.13.
+ gt_CHECK_DECL([feof_unlocked], [#include <stdio.h>])
+ gt_CHECK_DECL([fgets_unlocked], [#include <stdio.h>])
+
+ AM_ICONV
+
+ dnl intl/plural.c is generated from intl/plural.y. It requires bison,
+ dnl because plural.y uses bison specific features. It requires at least
+ dnl bison-1.26 because earlier versions generate a plural.c that doesn't
+ dnl compile.
+ dnl bison is only needed for the maintainer (who touches plural.y). But in
+ dnl order to avoid separate Makefiles or --enable-maintainer-mode, we put
+ dnl the rule in general Makefile. Now, some people carelessly touch the
+ dnl files or have a broken "make" program, hence the plural.c rule will
+ dnl sometimes fire. To avoid an error, defines BISON to ":" if it is not
+ dnl present or too old.
+ AC_CHECK_PROGS([INTLBISON], [bison])
+ if test -z "$INTLBISON"; then
+ ac_verc_fail=yes
+ else
+ dnl Found it, now check the version.
+ AC_MSG_CHECKING([version of bison])
+changequote(<<,>>)dnl
+ ac_prog_version=`$INTLBISON --version 2>&1 | sed -n 's/^.*GNU Bison.* \([0-9]*\.[0-9.]*\).*$/\1/p'`
+ case $ac_prog_version in
+ '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
+ 1.2[6-9]* | 1.[3-9][0-9]* | [2-9].*)
+changequote([,])dnl
+ ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
+ *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
+ esac
+ AC_MSG_RESULT([$ac_prog_version])
+ fi
+ if test $ac_verc_fail = yes; then
+ INTLBISON=:
+ fi
+])
+
+
+dnl gt_CHECK_DECL(FUNC, INCLUDES)
+dnl Check whether a function is declared.
+AC_DEFUN([gt_CHECK_DECL],
+[
+ AC_CACHE_CHECK([whether $1 is declared], [ac_cv_have_decl_$1],
+ [AC_TRY_COMPILE([$2], [
+#ifndef $1
+ char *p = (char *) $1;
+#endif
+], ac_cv_have_decl_$1=yes, ac_cv_have_decl_$1=no)])
+ if test $ac_cv_have_decl_$1 = yes; then
+ gt_value=1
+ else
+ gt_value=0
+ fi
+ AC_DEFINE_UNQUOTED([HAVE_DECL_]translit($1, [a-z], [A-Z]), [$gt_value],
+ [Define to 1 if you have the declaration of `$1', and to 0 if you don't.])
+])
diff --git a/package/libs/gettext/src/m4/intldir.m4 b/package/libs/gettext/src/m4/intldir.m4
new file mode 100644
index 0000000..ebae76d
--- /dev/null
+++ b/package/libs/gettext/src/m4/intldir.m4
@@ -0,0 +1,19 @@
+# intldir.m4 serial 2 (gettext-0.18)
+dnl Copyright (C) 2006, 2009-2010 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+dnl
+dnl This file can can be used in projects which are not available under
+dnl the GNU General Public License or the GNU Library General Public
+dnl License but which still want to provide support for the GNU gettext
+dnl functionality.
+dnl Please note that the actual code of the GNU gettext library is covered
+dnl by the GNU Library General Public License, and the rest of the GNU
+dnl gettext package package is covered by the GNU General Public License.
+dnl They are *not* in the public domain.
+
+AC_PREREQ([2.52])
+
+dnl Tells the AM_GNU_GETTEXT macro to consider an intl/ directory.
+AC_DEFUN([AM_GNU_GETTEXT_INTL_SUBDIR], [])
diff --git a/package/libs/gettext/src/m4/intlmacosx.m4 b/package/libs/gettext/src/m4/intlmacosx.m4
new file mode 100644
index 0000000..dd91025
--- /dev/null
+++ b/package/libs/gettext/src/m4/intlmacosx.m4
@@ -0,0 +1,51 @@
+# intlmacosx.m4 serial 3 (gettext-0.18)
+dnl Copyright (C) 2004-2010 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+dnl
+dnl This file can can be used in projects which are not available under
+dnl the GNU General Public License or the GNU Library General Public
+dnl License but which still want to provide support for the GNU gettext
+dnl functionality.
+dnl Please note that the actual code of the GNU gettext library is covered
+dnl by the GNU Library General Public License, and the rest of the GNU
+dnl gettext package package is covered by the GNU General Public License.
+dnl They are *not* in the public domain.
+
+dnl Checks for special options needed on MacOS X.
+dnl Defines INTL_MACOSX_LIBS.
+AC_DEFUN([gt_INTL_MACOSX],
+[
+ dnl Check for API introduced in MacOS X 10.2.
+ AC_CACHE_CHECK([for CFPreferencesCopyAppValue],
+ [gt_cv_func_CFPreferencesCopyAppValue],
+ [gt_save_LIBS="$LIBS"
+ LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation"
+ AC_TRY_LINK([#include <CoreFoundation/CFPreferences.h>],
+ [CFPreferencesCopyAppValue(NULL, NULL)],
+ [gt_cv_func_CFPreferencesCopyAppValue=yes],
+ [gt_cv_func_CFPreferencesCopyAppValue=no])
+ LIBS="$gt_save_LIBS"])
+ if test $gt_cv_func_CFPreferencesCopyAppValue = yes; then
+ AC_DEFINE([HAVE_CFPREFERENCESCOPYAPPVALUE], [1],
+ [Define to 1 if you have the MacOS X function CFPreferencesCopyAppValue in the CoreFoundation framework.])
+ fi
+ dnl Check for API introduced in MacOS X 10.3.
+ AC_CACHE_CHECK([for CFLocaleCopyCurrent], [gt_cv_func_CFLocaleCopyCurrent],
+ [gt_save_LIBS="$LIBS"
+ LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation"
+ AC_TRY_LINK([#include <CoreFoundation/CFLocale.h>], [CFLocaleCopyCurrent();],
+ [gt_cv_func_CFLocaleCopyCurrent=yes],
+ [gt_cv_func_CFLocaleCopyCurrent=no])
+ LIBS="$gt_save_LIBS"])
+ if test $gt_cv_func_CFLocaleCopyCurrent = yes; then
+ AC_DEFINE([HAVE_CFLOCALECOPYCURRENT], [1],
+ [Define to 1 if you have the MacOS X function CFLocaleCopyCurrent in the CoreFoundation framework.])
+ fi
+ INTL_MACOSX_LIBS=
+ if test $gt_cv_func_CFPreferencesCopyAppValue = yes || test $gt_cv_func_CFLocaleCopyCurrent = yes; then
+ INTL_MACOSX_LIBS="-Wl,-framework -Wl,CoreFoundation"
+ fi
+ AC_SUBST([INTL_MACOSX_LIBS])
+])
diff --git a/package/libs/gettext/src/m4/lcmessage.m4 b/package/libs/gettext/src/m4/lcmessage.m4
new file mode 100644
index 0000000..1a70543
--- /dev/null
+++ b/package/libs/gettext/src/m4/lcmessage.m4
@@ -0,0 +1,31 @@
+# lcmessage.m4 serial 6 (gettext-0.18)
+dnl Copyright (C) 1995-2002, 2004-2005, 2008-2010 Free Software Foundation,
+dnl Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+dnl
+dnl This file can can be used in projects which are not available under
+dnl the GNU General Public License or the GNU Library General Public
+dnl License but which still want to provide support for the GNU gettext
+dnl functionality.
+dnl Please note that the actual code of the GNU gettext library is covered
+dnl by the GNU Library General Public License, and the rest of the GNU
+dnl gettext package package is covered by the GNU General Public License.
+dnl They are *not* in the public domain.
+
+dnl Authors:
+dnl Ulrich Drepper <drepper@cygnus.com>, 1995.
+
+# Check whether LC_MESSAGES is available in <locale.h>.
+
+AC_DEFUN([gt_LC_MESSAGES],
+[
+ AC_CACHE_CHECK([for LC_MESSAGES], [gt_cv_val_LC_MESSAGES],
+ [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
+ [gt_cv_val_LC_MESSAGES=yes], [gt_cv_val_LC_MESSAGES=no])])
+ if test $gt_cv_val_LC_MESSAGES = yes; then
+ AC_DEFINE([HAVE_LC_MESSAGES], [1],
+ [Define if your <locale.h> file defines LC_MESSAGES.])
+ fi
+])
diff --git a/package/libs/gettext/src/m4/nls.m4 b/package/libs/gettext/src/m4/nls.m4
new file mode 100644
index 0000000..003704c
--- /dev/null
+++ b/package/libs/gettext/src/m4/nls.m4
@@ -0,0 +1,32 @@
+# nls.m4 serial 5 (gettext-0.18)
+dnl Copyright (C) 1995-2003, 2005-2006, 2008-2010 Free Software Foundation,
+dnl Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+dnl
+dnl This file can can be used in projects which are not available under
+dnl the GNU General Public License or the GNU Library General Public
+dnl License but which still want to provide support for the GNU gettext
+dnl functionality.
+dnl Please note that the actual code of the GNU gettext library is covered
+dnl by the GNU Library General Public License, and the rest of the GNU
+dnl gettext package package is covered by the GNU General Public License.
+dnl They are *not* in the public domain.
+
+dnl Authors:
+dnl Ulrich Drepper <drepper@cygnus.com>, 1995-2000.
+dnl Bruno Haible <haible@clisp.cons.org>, 2000-2003.
+
+AC_PREREQ([2.50])
+
+AC_DEFUN([AM_NLS],
+[
+ AC_MSG_CHECKING([whether NLS is requested])
+ dnl Default is enabled NLS
+ AC_ARG_ENABLE([nls],
+ [ --disable-nls do not use Native Language Support],
+ USE_NLS=$enableval, USE_NLS=yes)
+ AC_MSG_RESULT([$USE_NLS])
+ AC_SUBST([USE_NLS])
+])
diff --git a/package/libs/gettext/src/m4/po.m4 b/package/libs/gettext/src/m4/po.m4
new file mode 100644
index 0000000..47f36a4
--- /dev/null
+++ b/package/libs/gettext/src/m4/po.m4
@@ -0,0 +1,449 @@
+# po.m4 serial 17 (gettext-0.18)
+dnl Copyright (C) 1995-2010 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+dnl
+dnl This file can can be used in projects which are not available under
+dnl the GNU General Public License or the GNU Library General Public
+dnl License but which still want to provide support for the GNU gettext
+dnl functionality.
+dnl Please note that the actual code of the GNU gettext library is covered
+dnl by the GNU Library General Public License, and the rest of the GNU
+dnl gettext package package is covered by the GNU General Public License.
+dnl They are *not* in the public domain.
+
+dnl Authors:
+dnl Ulrich Drepper <drepper@cygnus.com>, 1995-2000.
+dnl Bruno Haible <haible@clisp.cons.org>, 2000-2003.
+
+AC_PREREQ([2.50])
+
+dnl Checks for all prerequisites of the po subdirectory.
+AC_DEFUN([AM_PO_SUBDIRS],
+[
+ AC_REQUIRE([AC_PROG_MAKE_SET])dnl
+ AC_REQUIRE([AC_PROG_INSTALL])dnl
+ AC_REQUIRE([AM_PROG_MKDIR_P])dnl defined by automake
+ AC_REQUIRE([AM_NLS])dnl
+
+ dnl Release version of the gettext macros. This is used to ensure that
+ dnl the gettext macros and po/Makefile.in.in are in sync.
+ AC_SUBST([GETTEXT_MACRO_VERSION], [0.18])
+
+ dnl Perform the following tests also if --disable-nls has been given,
+ dnl because they are needed for "make dist" to work.
+
+ dnl Search for GNU msgfmt in the PATH.
+ dnl The first test excludes Solaris msgfmt and early GNU msgfmt versions.
+ dnl The second test excludes FreeBSD msgfmt.
+ AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
+ [$ac_dir/$ac_word --statistics /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1 &&
+ (if $ac_dir/$ac_word --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)],
+ :)
+ AC_PATH_PROG([GMSGFMT], [gmsgfmt], [$MSGFMT])
+
+ dnl Test whether it is GNU msgfmt >= 0.15.
+changequote(,)dnl
+ case `$MSGFMT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in
+ '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) MSGFMT_015=: ;;
+ *) MSGFMT_015=$MSGFMT ;;
+ esac
+changequote([,])dnl
+ AC_SUBST([MSGFMT_015])
+changequote(,)dnl
+ case `$GMSGFMT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in
+ '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) GMSGFMT_015=: ;;
+ *) GMSGFMT_015=$GMSGFMT ;;
+ esac
+changequote([,])dnl
+ AC_SUBST([GMSGFMT_015])
+
+ dnl Search for GNU xgettext 0.12 or newer in the PATH.
+ dnl The first test excludes Solaris xgettext and early GNU xgettext versions.
+ dnl The second test excludes FreeBSD xgettext.
+ AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
+ [$ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1 &&
+ (if $ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)],
+ :)
+ dnl Remove leftover from FreeBSD xgettext call.
+ rm -f messages.po
+
+ dnl Test whether it is GNU xgettext >= 0.15.
+changequote(,)dnl
+ case `$XGETTEXT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in
+ '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) XGETTEXT_015=: ;;
+ *) XGETTEXT_015=$XGETTEXT ;;
+ esac
+changequote([,])dnl
+ AC_SUBST([XGETTEXT_015])
+
+ dnl Search for GNU msgmerge 0.11 or newer in the PATH.
+ AM_PATH_PROG_WITH_TEST(MSGMERGE, msgmerge,
+ [$ac_dir/$ac_word --update -q /dev/null /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1], :)
+
+ dnl Installation directories.
+ dnl Autoconf >= 2.60 defines localedir. For older versions of autoconf, we
+ dnl have to define it here, so that it can be used in po/Makefile.
+ test -n "$localedir" || localedir='${datadir}/locale'
+ AC_SUBST([localedir])
+
+ dnl Support for AM_XGETTEXT_OPTION.
+ test -n "${XGETTEXT_EXTRA_OPTIONS+set}" || XGETTEXT_EXTRA_OPTIONS=
+ AC_SUBST([XGETTEXT_EXTRA_OPTIONS])
+
+ AC_CONFIG_COMMANDS([po-directories], [[
+ for ac_file in $CONFIG_FILES; do
+ # Support "outfile[:infile[:infile...]]"
+ case "$ac_file" in
+ *:*) ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
+ esac
+ # PO directories have a Makefile.in generated from Makefile.in.in.
+ case "$ac_file" in */Makefile.in)
+ # Adjust a relative srcdir.
+ ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'`
+ ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`"
+ ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'`
+ # In autoconf-2.13 it is called $ac_given_srcdir.
+ # In autoconf-2.50 it is called $srcdir.
+ test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir"
+ case "$ac_given_srcdir" in
+ .) top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;;
+ /*) top_srcdir="$ac_given_srcdir" ;;
+ *) top_srcdir="$ac_dots$ac_given_srcdir" ;;
+ esac
+ # Treat a directory as a PO directory if and only if it has a
+ # POTFILES.in file. This allows packages to have multiple PO
+ # directories under different names or in different locations.
+ if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then
+ rm -f "$ac_dir/POTFILES"
+ test -n "$as_me" && echo "$as_me: creating $ac_dir/POTFILES" || echo "creating $ac_dir/POTFILES"
+ cat "$ac_given_srcdir/$ac_dir/POTFILES.in" | sed -e "/^#/d" -e "/^[ ]*\$/d" -e "s,.*, $top_srcdir/& \\\\," | sed -e "\$s/\(.*\) \\\\/\1/" > "$ac_dir/POTFILES"
+ POMAKEFILEDEPS="POTFILES.in"
+ # ALL_LINGUAS, POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES depend
+ # on $ac_dir but don't depend on user-specified configuration
+ # parameters.
+ if test -f "$ac_given_srcdir/$ac_dir/LINGUAS"; then
+ # The LINGUAS file contains the set of available languages.
+ if test -n "$OBSOLETE_ALL_LINGUAS"; then
+ test -n "$as_me" && echo "$as_me: setting ALL_LINGUAS in configure.in is obsolete" || echo "setting ALL_LINGUAS in configure.in is obsolete"
+ fi
+ ALL_LINGUAS_=`sed -e "/^#/d" -e "s/#.*//" "$ac_given_srcdir/$ac_dir/LINGUAS"`
+ # Hide the ALL_LINGUAS assigment from automake < 1.5.
+ eval 'ALL_LINGUAS''=$ALL_LINGUAS_'
+ POMAKEFILEDEPS="$POMAKEFILEDEPS LINGUAS"
+ else
+ # The set of available languages was given in configure.in.
+ # Hide the ALL_LINGUAS assigment from automake < 1.5.
+ eval 'ALL_LINGUAS''=$OBSOLETE_ALL_LINGUAS'
+ fi
+ # Compute POFILES
+ # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).po)
+ # Compute UPDATEPOFILES
+ # as $(foreach lang, $(ALL_LINGUAS), $(lang).po-update)
+ # Compute DUMMYPOFILES
+ # as $(foreach lang, $(ALL_LINGUAS), $(lang).nop)
+ # Compute GMOFILES
+ # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).gmo)
+ case "$ac_given_srcdir" in
+ .) srcdirpre= ;;
+ *) srcdirpre='$(srcdir)/' ;;
+ esac
+ POFILES=
+ UPDATEPOFILES=
+ DUMMYPOFILES=
+ GMOFILES=
+ for lang in $ALL_LINGUAS; do
+ POFILES="$POFILES $srcdirpre$lang.po"
+ UPDATEPOFILES="$UPDATEPOFILES $lang.po-update"
+ DUMMYPOFILES="$DUMMYPOFILES $lang.nop"
+ GMOFILES="$GMOFILES $srcdirpre$lang.gmo"
+ done
+ # CATALOGS depends on both $ac_dir and the user's LINGUAS
+ # environment variable.
+ INST_LINGUAS=
+ if test -n "$ALL_LINGUAS"; then
+ for presentlang in $ALL_LINGUAS; do
+ useit=no
+ if test "%UNSET%" != "$LINGUAS"; then
+ desiredlanguages="$LINGUAS"
+ else
+ desiredlanguages="$ALL_LINGUAS"
+ fi
+ for desiredlang in $desiredlanguages; do
+ # Use the presentlang catalog if desiredlang is
+ # a. equal to presentlang, or
+ # b. a variant of presentlang (because in this case,
+ # presentlang can be used as a fallback for messages
+ # which are not translated in the desiredlang catalog).
+ case "$desiredlang" in
+ "$presentlang"*) useit=yes;;
+ esac
+ done
+ if test $useit = yes; then
+ INST_LINGUAS="$INST_LINGUAS $presentlang"
+ fi
+ done
+ fi
+ CATALOGS=
+ if test -n "$INST_LINGUAS"; then
+ for lang in $INST_LINGUAS; do
+ CATALOGS="$CATALOGS $lang.gmo"
+ done
+ fi
+ test -n "$as_me" && echo "$as_me: creating $ac_dir/Makefile" || echo "creating $ac_dir/Makefile"
+ sed -e "/^POTFILES =/r $ac_dir/POTFILES" -e "/^# Makevars/r $ac_given_srcdir/$ac_dir/Makevars" -e "s|@POFILES@|$POFILES|g" -e "s|@UPDATEPOFILES@|$UPDATEPOFILES|g" -e "s|@DUMMYPOFILES@|$DUMMYPOFILES|g" -e "s|@GMOFILES@|$GMOFILES|g" -e "s|@CATALOGS@|$CATALOGS|g" -e "s|@POMAKEFILEDEPS@|$POMAKEFILEDEPS|g" "$ac_dir/Makefile.in" > "$ac_dir/Makefile"
+ for f in "$ac_given_srcdir/$ac_dir"/Rules-*; do
+ if test -f "$f"; then
+ case "$f" in
+ *.orig | *.bak | *~) ;;
+ *) cat "$f" >> "$ac_dir/Makefile" ;;
+ esac
+ fi
+ done
+ fi
+ ;;
+ esac
+ done]],
+ [# Capture the value of obsolete ALL_LINGUAS because we need it to compute
+ # POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES, CATALOGS. But hide it
+ # from automake < 1.5.
+ eval 'OBSOLETE_ALL_LINGUAS''="$ALL_LINGUAS"'
+ # Capture the value of LINGUAS because we need it to compute CATALOGS.
+ LINGUAS="${LINGUAS-%UNSET%}"
+ ])
+])
+
+dnl Postprocesses a Makefile in a directory containing PO files.
+AC_DEFUN([AM_POSTPROCESS_PO_MAKEFILE],
+[
+ # When this code is run, in config.status, two variables have already been
+ # set:
+ # - OBSOLETE_ALL_LINGUAS is the value of LINGUAS set in configure.in,
+ # - LINGUAS is the value of the environment variable LINGUAS at configure
+ # time.
+
+changequote(,)dnl
+ # Adjust a relative srcdir.
+ ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'`
+ ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`"
+ ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'`
+ # In autoconf-2.13 it is called $ac_given_srcdir.
+ # In autoconf-2.50 it is called $srcdir.
+ test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir"
+ case "$ac_given_srcdir" in
+ .) top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;;
+ /*) top_srcdir="$ac_given_srcdir" ;;
+ *) top_srcdir="$ac_dots$ac_given_srcdir" ;;
+ esac
+
+ # Find a way to echo strings without interpreting backslash.
+ if test "X`(echo '\t') 2>/dev/null`" = 'X\t'; then
+ gt_echo='echo'
+ else
+ if test "X`(printf '%s\n' '\t') 2>/dev/null`" = 'X\t'; then
+ gt_echo='printf %s\n'
+ else
+ echo_func () {
+ cat <<EOT
+$*
+EOT
+ }
+ gt_echo='echo_func'
+ fi
+ fi
+
+ # A sed script that extracts the value of VARIABLE from a Makefile.
+ sed_x_variable='
+# Test if the hold space is empty.
+x
+s/P/P/
+x
+ta
+# Yes it was empty. Look if we have the expected variable definition.
+/^[ ]*VARIABLE[ ]*=/{
+ # Seen the first line of the variable definition.
+ s/^[ ]*VARIABLE[ ]*=//
+ ba
+}
+bd
+:a
+# Here we are processing a line from the variable definition.
+# Remove comment, more precisely replace it with a space.
+s/#.*$/ /
+# See if the line ends in a backslash.
+tb
+:b
+s/\\$//
+# Print the line, without the trailing backslash.
+p
+tc
+# There was no trailing backslash. The end of the variable definition is
+# reached. Clear the hold space.
+s/^.*$//
+x
+bd
+:c
+# A trailing backslash means that the variable definition continues in the
+# next line. Put a nonempty string into the hold space to indicate this.
+s/^.*$/P/
+x
+:d
+'
+changequote([,])dnl
+
+ # Set POTFILES to the value of the Makefile variable POTFILES.
+ sed_x_POTFILES=`$gt_echo "$sed_x_variable" | sed -e '/^ *#/d' -e 's/VARIABLE/POTFILES/g'`
+ POTFILES=`sed -n -e "$sed_x_POTFILES" < "$ac_file"`
+ # Compute POTFILES_DEPS as
+ # $(foreach file, $(POTFILES), $(top_srcdir)/$(file))
+ POTFILES_DEPS=
+ for file in $POTFILES; do
+ POTFILES_DEPS="$POTFILES_DEPS "'$(top_srcdir)/'"$file"
+ done
+ POMAKEFILEDEPS=""
+
+ if test -n "$OBSOLETE_ALL_LINGUAS"; then
+ test -n "$as_me" && echo "$as_me: setting ALL_LINGUAS in configure.in is obsolete" || echo "setting ALL_LINGUAS in configure.in is obsolete"
+ fi
+ if test -f "$ac_given_srcdir/$ac_dir/LINGUAS"; then
+ # The LINGUAS file contains the set of available languages.
+ ALL_LINGUAS_=`sed -e "/^#/d" -e "s/#.*//" "$ac_given_srcdir/$ac_dir/LINGUAS"`
+ POMAKEFILEDEPS="$POMAKEFILEDEPS LINGUAS"
+ else
+ # Set ALL_LINGUAS to the value of the Makefile variable LINGUAS.
+ sed_x_LINGUAS=`$gt_echo "$sed_x_variable" | sed -e '/^ *#/d' -e 's/VARIABLE/LINGUAS/g'`
+ ALL_LINGUAS_=`sed -n -e "$sed_x_LINGUAS" < "$ac_file"`
+ fi
+ # Hide the ALL_LINGUAS assigment from automake < 1.5.
+ eval 'ALL_LINGUAS''=$ALL_LINGUAS_'
+ # Compute POFILES
+ # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).po)
+ # Compute UPDATEPOFILES
+ # as $(foreach lang, $(ALL_LINGUAS), $(lang).po-update)
+ # Compute DUMMYPOFILES
+ # as $(foreach lang, $(ALL_LINGUAS), $(lang).nop)
+ # Compute GMOFILES
+ # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).gmo)
+ # Compute PROPERTIESFILES
+ # as $(foreach lang, $(ALL_LINGUAS), $(top_srcdir)/$(DOMAIN)_$(lang).properties)
+ # Compute CLASSFILES
+ # as $(foreach lang, $(ALL_LINGUAS), $(top_srcdir)/$(DOMAIN)_$(lang).class)
+ # Compute QMFILES
+ # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).qm)
+ # Compute MSGFILES
+ # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(frob $(lang)).msg)
+ # Compute RESOURCESDLLFILES
+ # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(frob $(lang))/$(DOMAIN).resources.dll)
+ case "$ac_given_srcdir" in
+ .) srcdirpre= ;;
+ *) srcdirpre='$(srcdir)/' ;;
+ esac
+ POFILES=
+ UPDATEPOFILES=
+ DUMMYPOFILES=
+ GMOFILES=
+ PROPERTIESFILES=
+ CLASSFILES=
+ QMFILES=
+ MSGFILES=
+ RESOURCESDLLFILES=
+ for lang in $ALL_LINGUAS; do
+ POFILES="$POFILES $srcdirpre$lang.po"
+ UPDATEPOFILES="$UPDATEPOFILES $lang.po-update"
+ DUMMYPOFILES="$DUMMYPOFILES $lang.nop"
+ GMOFILES="$GMOFILES $srcdirpre$lang.gmo"
+ PROPERTIESFILES="$PROPERTIESFILES \$(top_srcdir)/\$(DOMAIN)_$lang.properties"
+ CLASSFILES="$CLASSFILES \$(top_srcdir)/\$(DOMAIN)_$lang.class"
+ QMFILES="$QMFILES $srcdirpre$lang.qm"
+ frobbedlang=`echo $lang | sed -e 's/\..*$//' -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
+ MSGFILES="$MSGFILES $srcdirpre$frobbedlang.msg"
+ frobbedlang=`echo $lang | sed -e 's/_/-/g' -e 's/^sr-CS/sr-SP/' -e 's/@latin$/-Latn/' -e 's/@cyrillic$/-Cyrl/' -e 's/^sr-SP$/sr-SP-Latn/' -e 's/^uz-UZ$/uz-UZ-Latn/'`
+ RESOURCESDLLFILES="$RESOURCESDLLFILES $srcdirpre$frobbedlang/\$(DOMAIN).resources.dll"
+ done
+ # CATALOGS depends on both $ac_dir and the user's LINGUAS
+ # environment variable.
+ INST_LINGUAS=
+ if test -n "$ALL_LINGUAS"; then
+ for presentlang in $ALL_LINGUAS; do
+ useit=no
+ if test "%UNSET%" != "$LINGUAS"; then
+ desiredlanguages="$LINGUAS"
+ else
+ desiredlanguages="$ALL_LINGUAS"
+ fi
+ for desiredlang in $desiredlanguages; do
+ # Use the presentlang catalog if desiredlang is
+ # a. equal to presentlang, or
+ # b. a variant of presentlang (because in this case,
+ # presentlang can be used as a fallback for messages
+ # which are not translated in the desiredlang catalog).
+ case "$desiredlang" in
+ "$presentlang"*) useit=yes;;
+ esac
+ done
+ if test $useit = yes; then
+ INST_LINGUAS="$INST_LINGUAS $presentlang"
+ fi
+ done
+ fi
+ CATALOGS=
+ JAVACATALOGS=
+ QTCATALOGS=
+ TCLCATALOGS=
+ CSHARPCATALOGS=
+ if test -n "$INST_LINGUAS"; then
+ for lang in $INST_LINGUAS; do
+ CATALOGS="$CATALOGS $lang.gmo"
+ JAVACATALOGS="$JAVACATALOGS \$(DOMAIN)_$lang.properties"
+ QTCATALOGS="$QTCATALOGS $lang.qm"
+ frobbedlang=`echo $lang | sed -e 's/\..*$//' -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
+ TCLCATALOGS="$TCLCATALOGS $frobbedlang.msg"
+ frobbedlang=`echo $lang | sed -e 's/_/-/g' -e 's/^sr-CS/sr-SP/' -e 's/@latin$/-Latn/' -e 's/@cyrillic$/-Cyrl/' -e 's/^sr-SP$/sr-SP-Latn/' -e 's/^uz-UZ$/uz-UZ-Latn/'`
+ CSHARPCATALOGS="$CSHARPCATALOGS $frobbedlang/\$(DOMAIN).resources.dll"
+ done
+ fi
+
+ sed -e "s|@POTFILES_DEPS@|$POTFILES_DEPS|g" -e "s|@POFILES@|$POFILES|g" -e "s|@UPDATEPOFILES@|$UPDATEPOFILES|g" -e "s|@DUMMYPOFILES@|$DUMMYPOFILES|g" -e "s|@GMOFILES@|$GMOFILES|g" -e "s|@PROPERTIESFILES@|$PROPERTIESFILES|g" -e "s|@CLASSFILES@|$CLASSFILES|g" -e "s|@QMFILES@|$QMFILES|g" -e "s|@MSGFILES@|$MSGFILES|g" -e "s|@RESOURCESDLLFILES@|$RESOURCESDLLFILES|g" -e "s|@CATALOGS@|$CATALOGS|g" -e "s|@JAVACATALOGS@|$JAVACATALOGS|g" -e "s|@QTCATALOGS@|$QTCATALOGS|g" -e "s|@TCLCATALOGS@|$TCLCATALOGS|g" -e "s|@CSHARPCATALOGS@|$CSHARPCATALOGS|g" -e 's,^#distdir:,distdir:,' < "$ac_file" > "$ac_file.tmp"
+ if grep -l '@TCLCATALOGS@' "$ac_file" > /dev/null; then
+ # Add dependencies that cannot be formulated as a simple suffix rule.
+ for lang in $ALL_LINGUAS; do
+ frobbedlang=`echo $lang | sed -e 's/\..*$//' -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
+ cat >> "$ac_file.tmp" <<EOF
+$frobbedlang.msg: $lang.po
+ @echo "\$(MSGFMT) -c --tcl -d \$(srcdir) -l $lang $srcdirpre$lang.po"; \
+ \$(MSGFMT) -c --tcl -d "\$(srcdir)" -l $lang $srcdirpre$lang.po || { rm -f "\$(srcdir)/$frobbedlang.msg"; exit 1; }
+EOF
+ done
+ fi
+ if grep -l '@CSHARPCATALOGS@' "$ac_file" > /dev/null; then
+ # Add dependencies that cannot be formulated as a simple suffix rule.
+ for lang in $ALL_LINGUAS; do
+ frobbedlang=`echo $lang | sed -e 's/_/-/g' -e 's/^sr-CS/sr-SP/' -e 's/@latin$/-Latn/' -e 's/@cyrillic$/-Cyrl/' -e 's/^sr-SP$/sr-SP-Latn/' -e 's/^uz-UZ$/uz-UZ-Latn/'`
+ cat >> "$ac_file.tmp" <<EOF
+$frobbedlang/\$(DOMAIN).resources.dll: $lang.po
+ @echo "\$(MSGFMT) -c --csharp -d \$(srcdir) -l $lang $srcdirpre$lang.po -r \$(DOMAIN)"; \
+ \$(MSGFMT) -c --csharp -d "\$(srcdir)" -l $lang $srcdirpre$lang.po -r "\$(DOMAIN)" || { rm -f "\$(srcdir)/$frobbedlang.msg"; exit 1; }
+EOF
+ done
+ fi
+ if test -n "$POMAKEFILEDEPS"; then
+ cat >> "$ac_file.tmp" <<EOF
+Makefile: $POMAKEFILEDEPS
+EOF
+ fi
+ mv "$ac_file.tmp" "$ac_file"
+])
+
+dnl Initializes the accumulator used by AM_XGETTEXT_OPTION.
+AC_DEFUN([AM_XGETTEXT_OPTION_INIT],
+[
+ XGETTEXT_EXTRA_OPTIONS=
+])
+
+dnl Registers an option to be passed to xgettext in the po subdirectory.
+AC_DEFUN([AM_XGETTEXT_OPTION],
+[
+ AC_REQUIRE([AM_XGETTEXT_OPTION_INIT])
+ XGETTEXT_EXTRA_OPTIONS="$XGETTEXT_EXTRA_OPTIONS $1"
+])
diff --git a/package/libs/libbsd/.svn/entries b/package/libs/libbsd/.svn/entries
new file mode 100644
index 0000000..aeb9d9f
--- /dev/null
+++ b/package/libs/libbsd/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs/libbsd
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-02-15T13:25:12.000491Z
+35606
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:07.000000Z
+7a4d21bd77a389736433698f98ffd548
+2013-02-15T13:25:12.000491Z
+35606
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1230
+
diff --git a/package/libs/libbsd/.svn/text-base/Makefile.svn-base b/package/libs/libbsd/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..7db1fc7
--- /dev/null
+++ b/package/libs/libbsd/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,57 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=libbsd
+PKG_VERSION:=0.3.0
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://libbsd.freedesktop.org/releases
+#PKG_MD5SUM:=d0870f2de55d59c1c8419f36e8fac150
+
+PKG_LICENSE:=BSD-4c
+PKG_LICENSE_FILES:=COPYING
+
+include $(INCLUDE_DIR)/package.mk
+
+PKG_INSTALL:=1
+
+define Package/libbsd
+ SECTION:=libs
+ CATEGORY:=Libraries
+ DEPENDS:=@USE_EGLIBC
+ TITLE:=common BSD library
+endef
+
+define Package/libbsd/description
+ This library provides useful functions commonly found on BSD systems, and lacking on others like GNU systems, thus making it easier to port projects with strong BSD origins, without needing to embed the same code over and over again on each project.
+endef
+
+define Build/InstallDev
+ $(INSTALL_DIR) \
+ $(1)/lib \
+ $(1)/usr/include
+
+ $(CP) \
+ $(PKG_INSTALL_DIR)/lib/libbsd.so* \
+ $(1)/lib/
+
+ $(CP) \
+ $(PKG_INSTALL_DIR)/usr/include/* \
+ $(1)/usr/include/
+
+ ( cd $(1)/lib ; ln -s libbsd.so.$(PKG_VERSION) libbsd.so )
+endef
+
+define Package/libbsd/install
+ $(INSTALL_DIR) \
+ $(1)/lib
+
+ $(CP) \
+ $(PKG_INSTALL_DIR)/lib/libbsd.so* \
+ $(1)/lib/
+
+ ( cd $(1)/lib ; ln -s libbsd.so.$(PKG_VERSION) libbsd.so )
+endef
+
+$(eval $(call BuildPackage,libbsd))
+
diff --git a/package/libs/libbsd/Makefile b/package/libs/libbsd/Makefile
new file mode 100644
index 0000000..7db1fc7
--- /dev/null
+++ b/package/libs/libbsd/Makefile
@@ -0,0 +1,57 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=libbsd
+PKG_VERSION:=0.3.0
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://libbsd.freedesktop.org/releases
+#PKG_MD5SUM:=d0870f2de55d59c1c8419f36e8fac150
+
+PKG_LICENSE:=BSD-4c
+PKG_LICENSE_FILES:=COPYING
+
+include $(INCLUDE_DIR)/package.mk
+
+PKG_INSTALL:=1
+
+define Package/libbsd
+ SECTION:=libs
+ CATEGORY:=Libraries
+ DEPENDS:=@USE_EGLIBC
+ TITLE:=common BSD library
+endef
+
+define Package/libbsd/description
+ This library provides useful functions commonly found on BSD systems, and lacking on others like GNU systems, thus making it easier to port projects with strong BSD origins, without needing to embed the same code over and over again on each project.
+endef
+
+define Build/InstallDev
+ $(INSTALL_DIR) \
+ $(1)/lib \
+ $(1)/usr/include
+
+ $(CP) \
+ $(PKG_INSTALL_DIR)/lib/libbsd.so* \
+ $(1)/lib/
+
+ $(CP) \
+ $(PKG_INSTALL_DIR)/usr/include/* \
+ $(1)/usr/include/
+
+ ( cd $(1)/lib ; ln -s libbsd.so.$(PKG_VERSION) libbsd.so )
+endef
+
+define Package/libbsd/install
+ $(INSTALL_DIR) \
+ $(1)/lib
+
+ $(CP) \
+ $(PKG_INSTALL_DIR)/lib/libbsd.so* \
+ $(1)/lib/
+
+ ( cd $(1)/lib ; ln -s libbsd.so.$(PKG_VERSION) libbsd.so )
+endef
+
+$(eval $(call BuildPackage,libbsd))
+
diff --git a/package/libs/libevent2/.svn/entries b/package/libs/libevent2/.svn/entries
new file mode 100644
index 0000000..564ba54
--- /dev/null
+++ b/package/libs/libevent2/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs/libevent2
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-02-15T13:25:15.547746Z
+35607
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:06.000000Z
+795c0e9d64c912a1fcd4ad4c334c0672
+2013-02-15T13:25:15.547746Z
+35607
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4337
+
diff --git a/package/libs/libevent2/.svn/text-base/Makefile.svn-base b/package/libs/libevent2/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..ea69782
--- /dev/null
+++ b/package/libs/libevent2/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,156 @@
+#
+# Copyright (C) 2011-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=libevent2
+PKG_VERSION:=2.0.19
+PKG_RELEASE:=1
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/libevent-$(PKG_VERSION)-stable
+PKG_SOURCE:=libevent-$(PKG_VERSION)-stable.tar.gz
+PKG_SOURCE_URL:=http://www.monkey.org/~provos/ \
+ @SF/levent
+PKG_MD5SUM:=91111579769f46055b0a438f5cc59572
+PKG_MAINTAINER:=Jo-Philipp Wich <jow@openwrt.org>
+
+PKG_FIXUP:=autoreconf
+PKG_INSTALL:=1
+PKG_BUILD_PARALLEL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/libevent2/Default
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=Event notification
+ URL:=http://www.monkey.org/~provos/libevent/
+endef
+
+define Package/libevent2/Default/description
+ The libevent API provides a mechanism to execute a callback function
+ when a specific event occurs on a file descriptor or after a timeout
+ has been reached. Furthermore, libevent also support callbacks due
+ to signals or regular timeouts.
+
+ libevent is meant to replace the event loop found in event driven
+ network servers. An application just needs to call event_dispatch()
+ and then add or remove events dynamically without having to change
+ the event loop.
+endef
+
+define Package/libevent2
+ $(call Package/libevent2/Default)
+ TITLE+= library (version 2.0)
+endef
+
+define Package/libevent2/description
+ $(call Package/libevent2/Default/description)
+
+ This package contains the libevent shared library historically
+ containing both the core & extra libraries.
+endef
+
+define Package/libevent2-core
+ $(call Package/libevent2/Default)
+ TITLE+= core library (version 2.0)
+endef
+
+define Package/libevent2-core/description
+ $(call Package/libevent2/Default/description)
+
+ This package contains the libevent core shared library for the event,
+ buffer & utility functions.
+endef
+
+define Package/libevent2-extra
+ $(call Package/libevent2/Default)
+ TITLE+= extra library (version 2.0)
+endef
+
+define Package/libevent2-extra/description
+ $(call Package/libevent2/Default/description)
+
+ This package contains the libevent extra shared library for specific
+ protocols including HTTP, DNS & RPC.
+endef
+
+define Package/libevent2-openssl
+ $(call Package/libevent2/Default)
+ TITLE+= OpenSSL library (version 2.0)
+ DEPENDS+=+libopenssl
+endef
+
+define Package/libevent2-openssl/description
+ $(call Package/libevent2/Default/description)
+
+ This package contains the libevent OpenSSL shared library for encrypted
+ bufferevents.
+endef
+
+define Package/libevent2-pthreads
+ $(call Package/libevent2/Default)
+ TITLE+= Pthreads library (version 2.0)
+ DEPENDS+=+libpthread
+endef
+
+define Package/libevent2-pthreads/description
+ $(call Package/libevent2/Default/description)
+
+ This package contains the libevent Pthreads shared library for
+ threading & locking.
+endef
+
+TARGET_CFLAGS += $(FPIC)
+
+CONFIGURE_ARGS += \
+ --enable-shared \
+ --enable-static
+
+MAKE_FLAGS += \
+ CFLAGS="$(TARGET_CFLAGS)"
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include
+ $(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libevent*.{la,a,so} $(1)/usr/lib/
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libevent*-2.0.so* $(1)/usr/lib/
+ $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libevent*.pc $(1)/usr/lib/pkgconfig/
+endef
+
+define Package/libevent2/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libevent-2.0.so.* $(1)/usr/lib/
+endef
+
+define Package/libevent2-core/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libevent_core-2.0.so.* $(1)/usr/lib/
+endef
+
+define Package/libevent2-extra/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libevent_extra-2.0.so.* $(1)/usr/lib/
+endef
+
+define Package/libevent2-openssl/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libevent_openssl-2.0.so.* $(1)/usr/lib/
+endef
+
+define Package/libevent2-pthreads/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libevent_pthreads-2.0.so.* $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,libevent2))
+$(eval $(call BuildPackage,libevent2-core))
+$(eval $(call BuildPackage,libevent2-extra))
+$(eval $(call BuildPackage,libevent2-openssl))
+$(eval $(call BuildPackage,libevent2-pthreads))
diff --git a/package/libs/libevent2/Makefile b/package/libs/libevent2/Makefile
new file mode 100644
index 0000000..ea69782
--- /dev/null
+++ b/package/libs/libevent2/Makefile
@@ -0,0 +1,156 @@
+#
+# Copyright (C) 2011-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=libevent2
+PKG_VERSION:=2.0.19
+PKG_RELEASE:=1
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/libevent-$(PKG_VERSION)-stable
+PKG_SOURCE:=libevent-$(PKG_VERSION)-stable.tar.gz
+PKG_SOURCE_URL:=http://www.monkey.org/~provos/ \
+ @SF/levent
+PKG_MD5SUM:=91111579769f46055b0a438f5cc59572
+PKG_MAINTAINER:=Jo-Philipp Wich <jow@openwrt.org>
+
+PKG_FIXUP:=autoreconf
+PKG_INSTALL:=1
+PKG_BUILD_PARALLEL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/libevent2/Default
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=Event notification
+ URL:=http://www.monkey.org/~provos/libevent/
+endef
+
+define Package/libevent2/Default/description
+ The libevent API provides a mechanism to execute a callback function
+ when a specific event occurs on a file descriptor or after a timeout
+ has been reached. Furthermore, libevent also support callbacks due
+ to signals or regular timeouts.
+
+ libevent is meant to replace the event loop found in event driven
+ network servers. An application just needs to call event_dispatch()
+ and then add or remove events dynamically without having to change
+ the event loop.
+endef
+
+define Package/libevent2
+ $(call Package/libevent2/Default)
+ TITLE+= library (version 2.0)
+endef
+
+define Package/libevent2/description
+ $(call Package/libevent2/Default/description)
+
+ This package contains the libevent shared library historically
+ containing both the core & extra libraries.
+endef
+
+define Package/libevent2-core
+ $(call Package/libevent2/Default)
+ TITLE+= core library (version 2.0)
+endef
+
+define Package/libevent2-core/description
+ $(call Package/libevent2/Default/description)
+
+ This package contains the libevent core shared library for the event,
+ buffer & utility functions.
+endef
+
+define Package/libevent2-extra
+ $(call Package/libevent2/Default)
+ TITLE+= extra library (version 2.0)
+endef
+
+define Package/libevent2-extra/description
+ $(call Package/libevent2/Default/description)
+
+ This package contains the libevent extra shared library for specific
+ protocols including HTTP, DNS & RPC.
+endef
+
+define Package/libevent2-openssl
+ $(call Package/libevent2/Default)
+ TITLE+= OpenSSL library (version 2.0)
+ DEPENDS+=+libopenssl
+endef
+
+define Package/libevent2-openssl/description
+ $(call Package/libevent2/Default/description)
+
+ This package contains the libevent OpenSSL shared library for encrypted
+ bufferevents.
+endef
+
+define Package/libevent2-pthreads
+ $(call Package/libevent2/Default)
+ TITLE+= Pthreads library (version 2.0)
+ DEPENDS+=+libpthread
+endef
+
+define Package/libevent2-pthreads/description
+ $(call Package/libevent2/Default/description)
+
+ This package contains the libevent Pthreads shared library for
+ threading & locking.
+endef
+
+TARGET_CFLAGS += $(FPIC)
+
+CONFIGURE_ARGS += \
+ --enable-shared \
+ --enable-static
+
+MAKE_FLAGS += \
+ CFLAGS="$(TARGET_CFLAGS)"
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include
+ $(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libevent*.{la,a,so} $(1)/usr/lib/
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libevent*-2.0.so* $(1)/usr/lib/
+ $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libevent*.pc $(1)/usr/lib/pkgconfig/
+endef
+
+define Package/libevent2/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libevent-2.0.so.* $(1)/usr/lib/
+endef
+
+define Package/libevent2-core/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libevent_core-2.0.so.* $(1)/usr/lib/
+endef
+
+define Package/libevent2-extra/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libevent_extra-2.0.so.* $(1)/usr/lib/
+endef
+
+define Package/libevent2-openssl/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libevent_openssl-2.0.so.* $(1)/usr/lib/
+endef
+
+define Package/libevent2-pthreads/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libevent_pthreads-2.0.so.* $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,libevent2))
+$(eval $(call BuildPackage,libevent2-core))
+$(eval $(call BuildPackage,libevent2-extra))
+$(eval $(call BuildPackage,libevent2-openssl))
+$(eval $(call BuildPackage,libevent2-pthreads))
diff --git a/package/libs/libiconv-full/.svn/entries b/package/libs/libiconv-full/.svn/entries
new file mode 100644
index 0000000..5895f45
--- /dev/null
+++ b/package/libs/libiconv-full/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs/libiconv-full
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-12-05T18:05:04.293667Z
+34530
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+1dcffc348d0ae2d98697b9787b5a160b
+2012-12-05T18:05:04.293667Z
+34530
+florian
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2219
+
diff --git a/package/libs/libiconv-full/.svn/prop-base/Makefile.svn-base b/package/libs/libiconv-full/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..f899379
--- /dev/null
+++ b/package/libs/libiconv-full/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,13 @@
+K 9
+copyright
+V 30
+Copyright (C) 2006 OpenWrt.org
+K 7
+licence
+V 5
+GPLv2
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/libs/libiconv-full/.svn/text-base/Makefile.svn-base b/package/libs/libiconv-full/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..75bca83
--- /dev/null
+++ b/package/libs/libiconv-full/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,93 @@
+#
+# Copyright (C) 2006-2009 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=libiconv-full
+PKG_VERSION:=1.11.1
+PKG_RELEASE:=1
+
+PKG_MAINTAINER:=Jo-Philipp Wich <jow@openwrt.org>
+
+PKG_SOURCE:=libiconv-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=@GNU/libiconv
+PKG_MD5SUM:=d42b97f6ef5dd0ba4469d520ed732fed
+PKG_BUILD_DIR:=$(BUILD_DIR)/libiconv-$(PKG_VERSION)
+
+PKG_FIXUP:=patch-libtool
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/libiconv-full/Default
+ URL:=http://www.gnu.org/software/libiconv/
+ TITLE:=Character set conversion
+endef
+
+define Package/libiconv-full
+ $(call Package/libiconv-full/Default)
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE+= library
+endef
+
+define Package/libcharset
+ $(call Package/libiconv-full/Default)
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE+= library
+endef
+
+define Package/iconv
+ $(call Package/libiconv-full/Default)
+ DEPENDS:=+libiconv-full +libcharset
+ SECTION:=utils
+ CATEGORY:=Utilities
+ TITLE+= utility
+endef
+
+TARGET_CFLAGS += $(FPIC) -DUSE_DOS
+
+CONFIGURE_ARGS += \
+ --enable-shared \
+ --enable-static \
+ --disable-rpath \
+ --enable-relocatable
+
+define Build/Compile
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ CC="$(TARGET_CC)" \
+ DESTDIR="$(PKG_INSTALL_DIR)" \
+ install
+endef
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/lib/libiconv-full/include
+ $(CP) $(PKG_INSTALL_DIR)/usr/include/iconv.h $(1)/usr/lib/libiconv-full/include/
+
+ $(INSTALL_DIR) $(1)/usr/lib/libiconv-full/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libcharset.{a,so*} $(1)/usr/lib/libiconv-full/lib/
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libiconv.{a,so*} $(1)/usr/lib/libiconv-full/lib/
+endef
+
+define Package/libcharset/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libcharset.so* $(1)/usr/lib/
+endef
+
+define Package/libiconv-full/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libiconv.so* $(1)/usr/lib/
+endef
+
+define Package/iconv/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(CP) $(PKG_INSTALL_DIR)/usr/bin/iconv $(1)/usr/bin/
+endef
+
+$(eval $(call BuildPackage,libcharset))
+$(eval $(call BuildPackage,libiconv-full))
+$(eval $(call BuildPackage,iconv))
diff --git a/package/libs/libiconv-full/Makefile b/package/libs/libiconv-full/Makefile
new file mode 100644
index 0000000..75bca83
--- /dev/null
+++ b/package/libs/libiconv-full/Makefile
@@ -0,0 +1,93 @@
+#
+# Copyright (C) 2006-2009 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=libiconv-full
+PKG_VERSION:=1.11.1
+PKG_RELEASE:=1
+
+PKG_MAINTAINER:=Jo-Philipp Wich <jow@openwrt.org>
+
+PKG_SOURCE:=libiconv-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=@GNU/libiconv
+PKG_MD5SUM:=d42b97f6ef5dd0ba4469d520ed732fed
+PKG_BUILD_DIR:=$(BUILD_DIR)/libiconv-$(PKG_VERSION)
+
+PKG_FIXUP:=patch-libtool
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/libiconv-full/Default
+ URL:=http://www.gnu.org/software/libiconv/
+ TITLE:=Character set conversion
+endef
+
+define Package/libiconv-full
+ $(call Package/libiconv-full/Default)
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE+= library
+endef
+
+define Package/libcharset
+ $(call Package/libiconv-full/Default)
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE+= library
+endef
+
+define Package/iconv
+ $(call Package/libiconv-full/Default)
+ DEPENDS:=+libiconv-full +libcharset
+ SECTION:=utils
+ CATEGORY:=Utilities
+ TITLE+= utility
+endef
+
+TARGET_CFLAGS += $(FPIC) -DUSE_DOS
+
+CONFIGURE_ARGS += \
+ --enable-shared \
+ --enable-static \
+ --disable-rpath \
+ --enable-relocatable
+
+define Build/Compile
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ CC="$(TARGET_CC)" \
+ DESTDIR="$(PKG_INSTALL_DIR)" \
+ install
+endef
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/lib/libiconv-full/include
+ $(CP) $(PKG_INSTALL_DIR)/usr/include/iconv.h $(1)/usr/lib/libiconv-full/include/
+
+ $(INSTALL_DIR) $(1)/usr/lib/libiconv-full/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libcharset.{a,so*} $(1)/usr/lib/libiconv-full/lib/
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libiconv.{a,so*} $(1)/usr/lib/libiconv-full/lib/
+endef
+
+define Package/libcharset/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libcharset.so* $(1)/usr/lib/
+endef
+
+define Package/libiconv-full/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libiconv.so* $(1)/usr/lib/
+endef
+
+define Package/iconv/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(CP) $(PKG_INSTALL_DIR)/usr/bin/iconv $(1)/usr/bin/
+endef
+
+$(eval $(call BuildPackage,libcharset))
+$(eval $(call BuildPackage,libiconv-full))
+$(eval $(call BuildPackage,iconv))
diff --git a/package/libs/libiconv-full/patches/.svn/entries b/package/libs/libiconv-full/patches/.svn/entries
new file mode 100644
index 0000000..c42e7cc
--- /dev/null
+++ b/package/libs/libiconv-full/patches/.svn/entries
@@ -0,0 +1,164 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs/libiconv-full/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2010-12-03T11:56:56.100710Z
+24226
+mirko
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+101-autotools.patch
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+17f097990b86890ba12f1716db869060
+2010-12-03T08:02:58.343463Z
+24221
+acoul
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+996045
+
+100-strip_charsets.patch
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+06c353ddabcd98eb7a2bbd16de3c06bd
+2010-12-03T08:02:58.343463Z
+24221
+acoul
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+135016
+
+103-configure_ac_fix.patch
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+1ace6fee3fa772e9d286509876bd689b
+2010-12-03T08:02:58.343463Z
+24221
+acoul
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+631
+
+200-work-with-libtool2.patch
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+6f795fc977f158db3c6c11d44564c098
+2010-12-03T11:56:56.100710Z
+24226
+mirko
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1273
+
diff --git a/package/libs/libiconv-full/patches/.svn/prop-base/100-strip_charsets.patch.svn-base b/package/libs/libiconv-full/patches/.svn/prop-base/100-strip_charsets.patch.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/libs/libiconv-full/patches/.svn/prop-base/100-strip_charsets.patch.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/libs/libiconv-full/patches/.svn/text-base/100-strip_charsets.patch.svn-base b/package/libs/libiconv-full/patches/.svn/text-base/100-strip_charsets.patch.svn-base
new file mode 100644
index 0000000..e4f49ae
--- /dev/null
+++ b/package/libs/libiconv-full/patches/.svn/text-base/100-strip_charsets.patch.svn-base
@@ -0,0 +1,3438 @@
+--- a/lib/aliases_dos.h
++++ b/lib/aliases_dos.h
+@@ -2,47 +2,3 @@
+ S(dos_1, "IBM437", ei_cp437 )
+ S(dos_2, "437", ei_cp437 )
+ S(dos_3, "CSPC8CODEPAGE437", ei_cp437 )
+- S(dos_4, "CP737", ei_cp737 )
+- S(dos_5, "CP775", ei_cp775 )
+- S(dos_6, "IBM775", ei_cp775 )
+- S(dos_7, "CSPC775BALTIC", ei_cp775 )
+- S(dos_8, "CP852", ei_cp852 )
+- S(dos_9, "IBM852", ei_cp852 )
+- S(dos_10, "852", ei_cp852 )
+- S(dos_11, "CSPCP852", ei_cp852 )
+- S(dos_12, "CP853", ei_cp853 )
+- S(dos_13, "CP855", ei_cp855 )
+- S(dos_14, "IBM855", ei_cp855 )
+- S(dos_15, "855", ei_cp855 )
+- S(dos_16, "CSIBM855", ei_cp855 )
+- S(dos_17, "CP857", ei_cp857 )
+- S(dos_18, "IBM857", ei_cp857 )
+- S(dos_19, "857", ei_cp857 )
+- S(dos_20, "CSIBM857", ei_cp857 )
+- S(dos_21, "CP858", ei_cp858 )
+- S(dos_22, "CP860", ei_cp860 )
+- S(dos_23, "IBM860", ei_cp860 )
+- S(dos_24, "860", ei_cp860 )
+- S(dos_25, "CSIBM860", ei_cp860 )
+- S(dos_26, "CP861", ei_cp861 )
+- S(dos_27, "IBM861", ei_cp861 )
+- S(dos_28, "861", ei_cp861 )
+- S(dos_29, "CP-IS", ei_cp861 )
+- S(dos_30, "CSIBM861", ei_cp861 )
+- S(dos_31, "CP863", ei_cp863 )
+- S(dos_32, "IBM863", ei_cp863 )
+- S(dos_33, "863", ei_cp863 )
+- S(dos_34, "CSIBM863", ei_cp863 )
+- S(dos_35, "CP864", ei_cp864 )
+- S(dos_36, "IBM864", ei_cp864 )
+- S(dos_37, "CSIBM864", ei_cp864 )
+- S(dos_38, "CP865", ei_cp865 )
+- S(dos_39, "IBM865", ei_cp865 )
+- S(dos_40, "865", ei_cp865 )
+- S(dos_41, "CSIBM865", ei_cp865 )
+- S(dos_42, "CP869", ei_cp869 )
+- S(dos_43, "IBM869", ei_cp869 )
+- S(dos_44, "869", ei_cp869 )
+- S(dos_45, "CP-GR", ei_cp869 )
+- S(dos_46, "CSIBM869", ei_cp869 )
+- S(dos_47, "CP1125", ei_cp1125 )
+--- a/lib/aliases.gperf
++++ b/lib/aliases.gperf
+@@ -48,8 +48,6 @@ UCS-2-INTERNAL, ei_ucs2internal
+ UCS-2-SWAPPED, ei_ucs2swapped
+ UCS-4-INTERNAL, ei_ucs4internal
+ UCS-4-SWAPPED, ei_ucs4swapped
+-C99, ei_c99
+-JAVA, ei_java
+ ISO-8859-1, ei_iso8859_1
+ ISO_8859-1, ei_iso8859_1
+ ISO_8859-1:1987, ei_iso8859_1
+@@ -68,285 +66,16 @@ LATIN2, ei_iso8859_2
+ L2, ei_iso8859_2
+ CSISOLATIN2, ei_iso8859_2
+ ISO8859-2, ei_iso8859_2
+-ISO-8859-3, ei_iso8859_3
+-ISO_8859-3, ei_iso8859_3
+-ISO_8859-3:1988, ei_iso8859_3
+-ISO-IR-109, ei_iso8859_3
+-LATIN3, ei_iso8859_3
+-L3, ei_iso8859_3
+-CSISOLATIN3, ei_iso8859_3
+-ISO8859-3, ei_iso8859_3
+-ISO-8859-4, ei_iso8859_4
+-ISO_8859-4, ei_iso8859_4
+-ISO_8859-4:1988, ei_iso8859_4
+-ISO-IR-110, ei_iso8859_4
+-LATIN4, ei_iso8859_4
+-L4, ei_iso8859_4
+-CSISOLATIN4, ei_iso8859_4
+-ISO8859-4, ei_iso8859_4
+-ISO-8859-5, ei_iso8859_5
+-ISO_8859-5, ei_iso8859_5
+-ISO_8859-5:1988, ei_iso8859_5
+-ISO-IR-144, ei_iso8859_5
+-CYRILLIC, ei_iso8859_5
+-CSISOLATINCYRILLIC, ei_iso8859_5
+-ISO8859-5, ei_iso8859_5
+-ISO-8859-6, ei_iso8859_6
+-ISO_8859-6, ei_iso8859_6
+-ISO_8859-6:1987, ei_iso8859_6
+-ISO-IR-127, ei_iso8859_6
+-ECMA-114, ei_iso8859_6
+-ASMO-708, ei_iso8859_6
+-ARABIC, ei_iso8859_6
+-CSISOLATINARABIC, ei_iso8859_6
+-ISO8859-6, ei_iso8859_6
+-ISO-8859-7, ei_iso8859_7
+-ISO_8859-7, ei_iso8859_7
+-ISO_8859-7:1987, ei_iso8859_7
+-ISO_8859-7:2003, ei_iso8859_7
+-ISO-IR-126, ei_iso8859_7
+-ECMA-118, ei_iso8859_7
+-ELOT_928, ei_iso8859_7
+-GREEK8, ei_iso8859_7
+-GREEK, ei_iso8859_7
+-CSISOLATINGREEK, ei_iso8859_7
+-ISO8859-7, ei_iso8859_7
+-ISO-8859-8, ei_iso8859_8
+-ISO_8859-8, ei_iso8859_8
+-ISO_8859-8:1988, ei_iso8859_8
+-ISO-IR-138, ei_iso8859_8
+-HEBREW, ei_iso8859_8
+-CSISOLATINHEBREW, ei_iso8859_8
+-ISO8859-8, ei_iso8859_8
+-ISO-8859-9, ei_iso8859_9
+-ISO_8859-9, ei_iso8859_9
+-ISO_8859-9:1989, ei_iso8859_9
+-ISO-IR-148, ei_iso8859_9
+-LATIN5, ei_iso8859_9
+-L5, ei_iso8859_9
+-CSISOLATIN5, ei_iso8859_9
+-ISO8859-9, ei_iso8859_9
+-ISO-8859-10, ei_iso8859_10
+-ISO_8859-10, ei_iso8859_10
+-ISO_8859-10:1992, ei_iso8859_10
+-ISO-IR-157, ei_iso8859_10
+-LATIN6, ei_iso8859_10
+-L6, ei_iso8859_10
+-CSISOLATIN6, ei_iso8859_10
+-ISO8859-10, ei_iso8859_10
+-ISO-8859-11, ei_iso8859_11
+-ISO_8859-11, ei_iso8859_11
+-ISO8859-11, ei_iso8859_11
+-ISO-8859-13, ei_iso8859_13
+-ISO_8859-13, ei_iso8859_13
+-ISO-IR-179, ei_iso8859_13
+-LATIN7, ei_iso8859_13
+-L7, ei_iso8859_13
+-ISO8859-13, ei_iso8859_13
+-ISO-8859-14, ei_iso8859_14
+-ISO_8859-14, ei_iso8859_14
+-ISO_8859-14:1998, ei_iso8859_14
+-ISO-IR-199, ei_iso8859_14
+-LATIN8, ei_iso8859_14
+-L8, ei_iso8859_14
+-ISO-CELTIC, ei_iso8859_14
+-ISO8859-14, ei_iso8859_14
+ ISO-8859-15, ei_iso8859_15
+ ISO_8859-15, ei_iso8859_15
+ ISO_8859-15:1998, ei_iso8859_15
+ ISO-IR-203, ei_iso8859_15
+ LATIN-9, ei_iso8859_15
+ ISO8859-15, ei_iso8859_15
+-ISO-8859-16, ei_iso8859_16
+-ISO_8859-16, ei_iso8859_16
+-ISO_8859-16:2001, ei_iso8859_16
+-ISO-IR-226, ei_iso8859_16
+-LATIN10, ei_iso8859_16
+-L10, ei_iso8859_16
+-ISO8859-16, ei_iso8859_16
+ KOI8-R, ei_koi8_r
+ CSKOI8R, ei_koi8_r
+-KOI8-U, ei_koi8_u
+-KOI8-RU, ei_koi8_ru
+ CP1250, ei_cp1250
+ WINDOWS-1250, ei_cp1250
+ MS-EE, ei_cp1250
+-CP1251, ei_cp1251
+-WINDOWS-1251, ei_cp1251
+-MS-CYRL, ei_cp1251
+-CP1252, ei_cp1252
+-WINDOWS-1252, ei_cp1252
+-MS-ANSI, ei_cp1252
+-CP1253, ei_cp1253
+-WINDOWS-1253, ei_cp1253
+-MS-GREEK, ei_cp1253
+-CP1254, ei_cp1254
+-WINDOWS-1254, ei_cp1254
+-MS-TURK, ei_cp1254
+-CP1255, ei_cp1255
+-WINDOWS-1255, ei_cp1255
+-MS-HEBR, ei_cp1255
+-CP1256, ei_cp1256
+-WINDOWS-1256, ei_cp1256
+-MS-ARAB, ei_cp1256
+-CP1257, ei_cp1257
+-WINDOWS-1257, ei_cp1257
+-WINBALTRIM, ei_cp1257
+-CP1258, ei_cp1258
+-WINDOWS-1258, ei_cp1258
+-CP850, ei_cp850
+-IBM850, ei_cp850
+-850, ei_cp850
+-CSPC850MULTILINGUAL, ei_cp850
+-CP862, ei_cp862
+-IBM862, ei_cp862
+-862, ei_cp862
+-CSPC862LATINHEBREW, ei_cp862
+-CP866, ei_cp866
+-IBM866, ei_cp866
+-866, ei_cp866
+-CSIBM866, ei_cp866
+-MACROMAN, ei_mac_roman
+-MACINTOSH, ei_mac_roman
+-MAC, ei_mac_roman
+-CSMACINTOSH, ei_mac_roman
+-MACCENTRALEUROPE, ei_mac_centraleurope
+-MACICELAND, ei_mac_iceland
+-MACCROATIAN, ei_mac_croatian
+-MACROMANIA, ei_mac_romania
+-MACCYRILLIC, ei_mac_cyrillic
+-MACUKRAINE, ei_mac_ukraine
+-MACGREEK, ei_mac_greek
+-MACTURKISH, ei_mac_turkish
+-MACHEBREW, ei_mac_hebrew
+-MACARABIC, ei_mac_arabic
+-MACTHAI, ei_mac_thai
+-HP-ROMAN8, ei_hp_roman8
+-ROMAN8, ei_hp_roman8
+-R8, ei_hp_roman8
+-CSHPROMAN8, ei_hp_roman8
+-NEXTSTEP, ei_nextstep
+-ARMSCII-8, ei_armscii_8
+-GEORGIAN-ACADEMY, ei_georgian_academy
+-GEORGIAN-PS, ei_georgian_ps
+-KOI8-T, ei_koi8_t
+-PT154, ei_pt154
+-PTCP154, ei_pt154
+-CP154, ei_pt154
+-CYRILLIC-ASIAN, ei_pt154
+-CSPTCP154, ei_pt154
+-MULELAO-1, ei_mulelao
+-CP1133, ei_cp1133
+-IBM-CP1133, ei_cp1133
+-TIS-620, ei_tis620
+-TIS620, ei_tis620
+-TIS620-0, ei_tis620
+-TIS620.2529-1, ei_tis620
+-TIS620.2533-0, ei_tis620
+-TIS620.2533-1, ei_tis620
+-ISO-IR-166, ei_tis620
+-CP874, ei_cp874
+-WINDOWS-874, ei_cp874
+-VISCII, ei_viscii
+-VISCII1.1-1, ei_viscii
+-CSVISCII, ei_viscii
+-TCVN, ei_tcvn
+-TCVN-5712, ei_tcvn
+-TCVN5712-1, ei_tcvn
+-TCVN5712-1:1993, ei_tcvn
+-JIS_C6220-1969-RO, ei_iso646_jp
+-ISO646-JP, ei_iso646_jp
+-ISO-IR-14, ei_iso646_jp
+-JP, ei_iso646_jp
+-CSISO14JISC6220RO, ei_iso646_jp
+-JIS_X0201, ei_jisx0201
+-JISX0201-1976, ei_jisx0201
+-X0201, ei_jisx0201
+-CSHALFWIDTHKATAKANA, ei_jisx0201
+-JIS_X0208, ei_jisx0208
+-JIS_X0208-1983, ei_jisx0208
+-JIS_X0208-1990, ei_jisx0208
+-JIS0208, ei_jisx0208
+-X0208, ei_jisx0208
+-ISO-IR-87, ei_jisx0208
+-JIS_C6226-1983, ei_jisx0208
+-CSISO87JISX0208, ei_jisx0208
+-JIS_X0212, ei_jisx0212
+-JIS_X0212.1990-0, ei_jisx0212
+-JIS_X0212-1990, ei_jisx0212
+-X0212, ei_jisx0212
+-ISO-IR-159, ei_jisx0212
+-CSISO159JISX02121990, ei_jisx0212
+-GB_1988-80, ei_iso646_cn
+-ISO646-CN, ei_iso646_cn
+-ISO-IR-57, ei_iso646_cn
+-CN, ei_iso646_cn
+-CSISO57GB1988, ei_iso646_cn
+-GB_2312-80, ei_gb2312
+-ISO-IR-58, ei_gb2312
+-CSISO58GB231280, ei_gb2312
+-CHINESE, ei_gb2312
+-ISO-IR-165, ei_isoir165
+-CN-GB-ISOIR165, ei_isoir165
+-KSC_5601, ei_ksc5601
+-KS_C_5601-1987, ei_ksc5601
+-KS_C_5601-1989, ei_ksc5601
+-ISO-IR-149, ei_ksc5601
+-CSKSC56011987, ei_ksc5601
+-KOREAN, ei_ksc5601
+-EUC-JP, ei_euc_jp
+-EUCJP, ei_euc_jp
+-EXTENDED_UNIX_CODE_PACKED_FORMAT_FOR_JAPANESE, ei_euc_jp
+-CSEUCPKDFMTJAPANESE, ei_euc_jp
+-SHIFT_JIS, ei_sjis
+-SHIFT-JIS, ei_sjis
+-SJIS, ei_sjis
+-MS_KANJI, ei_sjis
+-CSSHIFTJIS, ei_sjis
+-CP932, ei_cp932
+-ISO-2022-JP, ei_iso2022_jp
+-CSISO2022JP, ei_iso2022_jp
+-ISO-2022-JP-1, ei_iso2022_jp1
+-ISO-2022-JP-2, ei_iso2022_jp2
+-CSISO2022JP2, ei_iso2022_jp2
+-EUC-CN, ei_euc_cn
+-EUCCN, ei_euc_cn
+-GB2312, ei_euc_cn
+-CN-GB, ei_euc_cn
+-CSGB2312, ei_euc_cn
+-GBK, ei_ces_gbk
+-CP936, ei_cp936
+-MS936, ei_cp936
+-WINDOWS-936, ei_cp936
+-GB18030, ei_gb18030
+-ISO-2022-CN, ei_iso2022_cn
+-CSISO2022CN, ei_iso2022_cn
+-ISO-2022-CN-EXT, ei_iso2022_cn_ext
+-HZ, ei_hz
+-HZ-GB-2312, ei_hz
+-EUC-TW, ei_euc_tw
+-EUCTW, ei_euc_tw
+-CSEUCTW, ei_euc_tw
+-BIG5, ei_ces_big5
+-BIG-5, ei_ces_big5
+-BIG-FIVE, ei_ces_big5
+-BIGFIVE, ei_ces_big5
+-CN-BIG5, ei_ces_big5
+-CSBIG5, ei_ces_big5
+-CP950, ei_cp950
+-BIG5-HKSCS:1999, ei_big5hkscs1999
+-BIG5-HKSCS:2001, ei_big5hkscs2001
+-BIG5-HKSCS, ei_big5hkscs2004
+-BIG5HKSCS, ei_big5hkscs2004
+-BIG5-HKSCS:2004, ei_big5hkscs2004
+-EUC-KR, ei_euc_kr
+-EUCKR, ei_euc_kr
+-CSEUCKR, ei_euc_kr
+-CP949, ei_cp949
+-UHC, ei_cp949
+-JOHAB, ei_johab
+-CP1361, ei_johab
+-ISO-2022-KR, ei_iso2022_kr
+-CSISO2022KR, ei_iso2022_kr
+ CHAR, ei_local_char
+ WCHAR_T, ei_local_wchar_t
+--- a/lib/aliases.h
++++ b/lib/aliases.h
+@@ -1,6 +1,6 @@
+ /* ANSI-C code produced by gperf version 3.0.2 */
+ /* Command-line: gperf -m 10 lib/aliases.gperf */
+-/* Computed positions: -k'1,3-11,$' */
++/* Computed positions: -k'4-7,10,$' */
+
+ #if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
+ && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
+@@ -32,12 +32,12 @@
+ #line 1 "lib/aliases.gperf"
+ struct alias { int name; unsigned int encoding_index; };
+
+-#define TOTAL_KEYWORDS 341
++#define TOTAL_KEYWORDS 70
+ #define MIN_WORD_LENGTH 2
+-#define MAX_WORD_LENGTH 45
+-#define MIN_HASH_VALUE 13
+-#define MAX_HASH_VALUE 997
+-/* maximum key range = 985, duplicates = 0 */
++#define MAX_WORD_LENGTH 17
++#define MIN_HASH_VALUE 4
++#define MAX_HASH_VALUE 98
++/* maximum key range = 95, duplicates = 0 */
+
+ #ifdef __GNUC__
+ __inline
+@@ -49,38 +49,31 @@ inline
+ static unsigned int
+ aliases_hash (register const char *str, register unsigned int len)
+ {
+- static const unsigned short asso_values[] =
++ static const unsigned char asso_values[] =
+ {
+- 998, 998, 998, 998, 998, 998, 998, 998, 998, 998,
+- 998, 998, 998, 998, 998, 998, 998, 998, 998, 998,
+- 998, 998, 998, 998, 998, 998, 998, 998, 998, 998,
+- 998, 998, 998, 998, 998, 998, 998, 998, 998, 998,
+- 998, 998, 998, 998, 998, 4, 199, 998, 79, 6,
+- 29, 65, 13, 15, 4, 88, 20, 22, 386, 998,
+- 998, 998, 998, 998, 998, 47, 188, 110, 6, 26,
+- 63, 19, 12, 5, 281, 202, 7, 166, 11, 5,
+- 64, 998, 4, 11, 20, 185, 110, 152, 163, 4,
+- 4, 998, 998, 998, 998, 5, 998, 998, 998, 998,
+- 998, 998, 998, 998, 998, 998, 998, 998, 998, 998,
+- 998, 998, 998, 998, 998, 998, 998, 998, 998, 998,
+- 998, 998, 998, 998, 998, 998, 998, 998
++ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99,
++ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99,
++ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99,
++ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99,
++ 99, 99, 99, 99, 99, 6, 99, 99, 22, 3,
++ 2, 2, 17, 3, 2, 7, 3, 2, 99, 99,
++ 99, 99, 99, 99, 99, 4, 53, 2, 21, 2,
++ 99, 7, 99, 15, 99, 99, 19, 99, 33, 2,
++ 4, 99, 11, 26, 17, 99, 99, 3, 26, 99,
++ 99, 99, 99, 99, 99, 10, 99, 99, 99, 99,
++ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99,
++ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99,
++ 99, 99, 99, 99, 99, 99, 99, 99
+ };
+ register int hval = len;
+
+ switch (hval)
+ {
+ default:
+- hval += asso_values[(unsigned char)str[10]];
+- /*FALLTHROUGH*/
+- case 10:
+ hval += asso_values[(unsigned char)str[9]];
+ /*FALLTHROUGH*/
+ case 9:
+- hval += asso_values[(unsigned char)str[8]];
+- /*FALLTHROUGH*/
+ case 8:
+- hval += asso_values[(unsigned char)str[7]];
+- /*FALLTHROUGH*/
+ case 7:
+ hval += asso_values[(unsigned char)str[6]];
+ /*FALLTHROUGH*/
+@@ -94,11 +87,7 @@ aliases_hash (register const char *str,
+ hval += asso_values[(unsigned char)str[3]];
+ /*FALLTHROUGH*/
+ case 3:
+- hval += asso_values[(unsigned char)str[2]];
+- /*FALLTHROUGH*/
+ case 2:
+- case 1:
+- hval += asso_values[(unsigned char)str[0]];
+ break;
+ }
+ return hval + asso_values[(unsigned char)str[len - 1]];
+@@ -106,1576 +95,306 @@ aliases_hash (register const char *str,
+
+ struct stringpool_t
+ {
+- char stringpool_str13[sizeof("L6")];
+- char stringpool_str15[sizeof("L1")];
+- char stringpool_str18[sizeof("HZ")];
+- char stringpool_str22[sizeof("L4")];
+- char stringpool_str24[sizeof("L5")];
+- char stringpool_str26[sizeof("R8")];
+- char stringpool_str29[sizeof("L8")];
+- char stringpool_str31[sizeof("866")];
+- char stringpool_str38[sizeof("L2")];
+- char stringpool_str42[sizeof("SJIS")];
+- char stringpool_str43[sizeof("ISO-IR-6")];
+- char stringpool_str55[sizeof("ISO-IR-166")];
+- char stringpool_str57[sizeof("LATIN6")];
+- char stringpool_str61[sizeof("LATIN1")];
+- char stringpool_str68[sizeof("ISO-IR-14")];
+- char stringpool_str74[sizeof("L3")];
+- char stringpool_str75[sizeof("LATIN4")];
+- char stringpool_str77[sizeof("ISO-IR-165")];
+- char stringpool_str79[sizeof("LATIN5")];
+- char stringpool_str80[sizeof("ISO-IR-126")];
+- char stringpool_str81[sizeof("862")];
+- char stringpool_str82[sizeof("ISO-IR-144")];
+- char stringpool_str89[sizeof("LATIN8")];
+- char stringpool_str91[sizeof("ISO-IR-58")];
+- char stringpool_str96[sizeof("ISO-IR-148")];
+- char stringpool_str97[sizeof("L7")];
+- char stringpool_str98[sizeof("LATIN-9")];
+- char stringpool_str100[sizeof("ISO-IR-149")];
+- char stringpool_str102[sizeof("ISO-IR-159")];
+- char stringpool_str103[sizeof("ISO-IR-226")];
+- char stringpool_str107[sizeof("LATIN2")];
+- char stringpool_str108[sizeof("ISO8859-6")];
+- char stringpool_str109[sizeof("ISO-IR-199")];
+- char stringpool_str112[sizeof("ISO8859-1")];
+- char stringpool_str113[sizeof("ISO-8859-6")];
+- char stringpool_str114[sizeof("ISO_8859-6")];
+- char stringpool_str115[sizeof("ISO8859-16")];
+- char stringpool_str116[sizeof("PT154")];
+- char stringpool_str117[sizeof("ISO-8859-1")];
+- char stringpool_str118[sizeof("ISO_8859-1")];
+- char stringpool_str119[sizeof("ISO8859-11")];
+- char stringpool_str120[sizeof("ISO-8859-16")];
+- char stringpool_str121[sizeof("ISO_8859-16")];
+- char stringpool_str123[sizeof("CN")];
+- char stringpool_str124[sizeof("ISO-8859-11")];
+- char stringpool_str125[sizeof("ISO_8859-11")];
+- char stringpool_str126[sizeof("ISO8859-4")];
+- char stringpool_str128[sizeof("ISO_8859-16:2001")];
+- char stringpool_str130[sizeof("ISO8859-5")];
+- char stringpool_str131[sizeof("ISO-8859-4")];
+- char stringpool_str132[sizeof("ISO_8859-4")];
+- char stringpool_str133[sizeof("ISO8859-14")];
+- char stringpool_str134[sizeof("ISO-IR-101")];
+- char stringpool_str135[sizeof("ISO-8859-5")];
+- char stringpool_str136[sizeof("ISO_8859-5")];
+- char stringpool_str137[sizeof("ISO8859-15")];
+- char stringpool_str138[sizeof("ISO-8859-14")];
+- char stringpool_str139[sizeof("ISO_8859-14")];
+- char stringpool_str140[sizeof("ISO8859-8")];
+- char stringpool_str142[sizeof("ISO-8859-15")];
+- char stringpool_str143[sizeof("ISO_8859-15")];
+- char stringpool_str144[sizeof("ISO8859-9")];
+- char stringpool_str145[sizeof("ISO-8859-8")];
+- char stringpool_str146[sizeof("ISO_8859-8")];
+- char stringpool_str147[sizeof("CP866")];
+- char stringpool_str148[sizeof("ISO-IR-138")];
+- char stringpool_str149[sizeof("ISO-8859-9")];
+- char stringpool_str150[sizeof("ISO_8859-9")];
+- char stringpool_str151[sizeof("ISO_8859-14:1998")];
+- char stringpool_str153[sizeof("ISO_8859-15:1998")];
+- char stringpool_str155[sizeof("ELOT_928")];
+- char stringpool_str156[sizeof("TCVN")];
+- char stringpool_str157[sizeof("C99")];
+- char stringpool_str158[sizeof("ISO8859-2")];
+- char stringpool_str162[sizeof("CP154")];
+- char stringpool_str163[sizeof("ISO-8859-2")];
+- char stringpool_str164[sizeof("ISO_8859-2")];
+- char stringpool_str166[sizeof("ISO-IR-109")];
+- char stringpool_str168[sizeof("L10")];
+- char stringpool_str169[sizeof("CHAR")];
+- char stringpool_str174[sizeof("CP1256")];
+- char stringpool_str175[sizeof("ISO-IR-179")];
+- char stringpool_str176[sizeof("ISO646-CN")];
+- char stringpool_str177[sizeof("ASCII")];
+- char stringpool_str178[sizeof("CP1251")];
+- char stringpool_str179[sizeof("LATIN3")];
+- char stringpool_str181[sizeof("850")];
+- char stringpool_str183[sizeof("GB2312")];
+- char stringpool_str185[sizeof("CP819")];
+- char stringpool_str192[sizeof("CP1254")];
+- char stringpool_str194[sizeof("CP949")];
+- char stringpool_str196[sizeof("CP1255")];
+- char stringpool_str197[sizeof("CP862")];
+- char stringpool_str198[sizeof("US")];
+- char stringpool_str203[sizeof("CP1361")];
+- char stringpool_str206[sizeof("CP1258")];
+- char stringpool_str207[sizeof("ISO-IR-110")];
+- char stringpool_str209[sizeof("IBM866")];
+- char stringpool_str210[sizeof("CP936")];
+- char stringpool_str211[sizeof("GEORGIAN-PS")];
+- char stringpool_str214[sizeof("LATIN10")];
+- char stringpool_str222[sizeof("CHINESE")];
+- char stringpool_str224[sizeof("CP1252")];
+- char stringpool_str225[sizeof("LATIN7")];
+- char stringpool_str226[sizeof("ISO_8859-10:1992")];
+- char stringpool_str227[sizeof("ISO-IR-57")];
+- char stringpool_str228[sizeof("TIS620")];
+- char stringpool_str230[sizeof("ISO8859-3")];
+- char stringpool_str231[sizeof("UCS-4")];
+- char stringpool_str232[sizeof("ISO-IR-87")];
+- char stringpool_str233[sizeof("TIS-620")];
+- char stringpool_str234[sizeof("ISO-IR-157")];
+- char stringpool_str235[sizeof("ISO-8859-3")];
+- char stringpool_str236[sizeof("ISO_8859-3")];
+- char stringpool_str237[sizeof("ISO8859-13")];
+- char stringpool_str240[sizeof("CSISOLATIN6")];
+- char stringpool_str241[sizeof("BIG5")];
+- char stringpool_str242[sizeof("ISO-8859-13")];
+- char stringpool_str243[sizeof("ISO_8859-13")];
+- char stringpool_str244[sizeof("CSISOLATIN1")];
+- char stringpool_str245[sizeof("KOI8-R")];
+- char stringpool_str246[sizeof("BIG-5")];
+- char stringpool_str247[sizeof("IBM819")];
+- char stringpool_str248[sizeof("ISO-IR-127")];
+- char stringpool_str249[sizeof("CP874")];
+- char stringpool_str251[sizeof("ISO646-US")];
+- char stringpool_str252[sizeof("VISCII")];
+- char stringpool_str253[sizeof("MS-EE")];
+- char stringpool_str256[sizeof("MS-ANSI")];
+- char stringpool_str258[sizeof("CSISOLATIN4")];
+- char stringpool_str259[sizeof("IBM862")];
+- char stringpool_str260[sizeof("CP932")];
+- char stringpool_str261[sizeof("X0212")];
+- char stringpool_str262[sizeof("CSISOLATIN5")];
+- char stringpool_str263[sizeof("UCS-2")];
+- char stringpool_str265[sizeof("ISO8859-10")];
+- char stringpool_str266[sizeof("MS936")];
+- char stringpool_str267[sizeof("WCHAR_T")];
+- char stringpool_str270[sizeof("ISO-8859-10")];
+- char stringpool_str271[sizeof("ISO_8859-10")];
+- char stringpool_str272[sizeof("UTF-16")];
+- char stringpool_str273[sizeof("EUCCN")];
+- char stringpool_str274[sizeof("ROMAN8")];
+- char stringpool_str275[sizeof("ISO-IR-203")];
+- char stringpool_str276[sizeof("ISO8859-7")];
+- char stringpool_str277[sizeof("KOI8-T")];
+- char stringpool_str278[sizeof("EUC-CN")];
+- char stringpool_str279[sizeof("UCS-4LE")];
+- char stringpool_str280[sizeof("ISO-IR-100")];
+- char stringpool_str281[sizeof("ISO-8859-7")];
+- char stringpool_str282[sizeof("ISO_8859-7")];
+- char stringpool_str283[sizeof("MULELAO-1")];
+- char stringpool_str284[sizeof("GB_1988-80")];
+- char stringpool_str288[sizeof("X0201")];
+- char stringpool_str289[sizeof("ECMA-114")];
+- char stringpool_str290[sizeof("CSISOLATIN2")];
+- char stringpool_str291[sizeof("GEORGIAN-ACADEMY")];
+- char stringpool_str292[sizeof("PTCP154")];
+- char stringpool_str295[sizeof("UCS-2LE")];
+- char stringpool_str296[sizeof("CP1253")];
+- char stringpool_str297[sizeof("UTF-8")];
+- char stringpool_str298[sizeof("HP-ROMAN8")];
+- char stringpool_str300[sizeof("CSASCII")];
+- char stringpool_str303[sizeof("ECMA-118")];
+- char stringpool_str304[sizeof("UCS-4-INTERNAL")];
+- char stringpool_str305[sizeof("TCVN5712-1")];
+- char stringpool_str307[sizeof("KOREAN")];
+- char stringpool_str308[sizeof("CP850")];
+- char stringpool_str309[sizeof("MS-CYRL")];
+- char stringpool_str310[sizeof("CP950")];
+- char stringpool_str313[sizeof("TIS620-0")];
+- char stringpool_str316[sizeof("X0208")];
+- char stringpool_str319[sizeof("GREEK8")];
+- char stringpool_str320[sizeof("UCS-2-INTERNAL")];
+- char stringpool_str321[sizeof("TCVN-5712")];
+- char stringpool_str323[sizeof("CP1133")];
+- char stringpool_str324[sizeof("CP1250")];
+- char stringpool_str327[sizeof("ISO-2022-CN")];
+- char stringpool_str329[sizeof("UTF-16LE")];
+- char stringpool_str335[sizeof("CYRILLIC-ASIAN")];
+- char stringpool_str337[sizeof("ISO-10646-UCS-4")];
+- char stringpool_str340[sizeof("ISO-2022-CN-EXT")];
+- char stringpool_str342[sizeof("CP1257")];
+- char stringpool_str345[sizeof("GB_2312-80")];
+- char stringpool_str347[sizeof("JP")];
+- char stringpool_str351[sizeof("EUCKR")];
+- char stringpool_str353[sizeof("ISO-10646-UCS-2")];
+- char stringpool_str354[sizeof("GB18030")];
+- char stringpool_str356[sizeof("EUC-KR")];
+- char stringpool_str357[sizeof("CSKOI8R")];
+- char stringpool_str358[sizeof("CSBIG5")];
+- char stringpool_str360[sizeof("CP367")];
+- char stringpool_str361[sizeof("MACINTOSH")];
+- char stringpool_str362[sizeof("CSISOLATIN3")];
+- char stringpool_str363[sizeof("CN-BIG5")];
+- char stringpool_str366[sizeof("CYRILLIC")];
+- char stringpool_str369[sizeof("CSVISCII")];
+- char stringpool_str370[sizeof("IBM850")];
+- char stringpool_str372[sizeof("MACTHAI")];
+- char stringpool_str374[sizeof("UNICODE-1-1")];
+- char stringpool_str376[sizeof("ISO_646.IRV:1991")];
+- char stringpool_str380[sizeof("US-ASCII")];
+- char stringpool_str381[sizeof("UTF-32")];
+- char stringpool_str384[sizeof("CN-GB-ISOIR165")];
+- char stringpool_str387[sizeof("NEXTSTEP")];
+- char stringpool_str389[sizeof("MAC")];
+- char stringpool_str393[sizeof("EXTENDED_UNIX_CODE_PACKED_FORMAT_FOR_JAPANESE")];
+- char stringpool_str394[sizeof("CSISOLATINARABIC")];
+- char stringpool_str395[sizeof("HZ-GB-2312")];
+- char stringpool_str397[sizeof("ARMSCII-8")];
+- char stringpool_str401[sizeof("CSISOLATINHEBREW")];
+- char stringpool_str405[sizeof("ISO-2022-KR")];
+- char stringpool_str407[sizeof("WINDOWS-1256")];
+- char stringpool_str408[sizeof("UHC")];
+- char stringpool_str409[sizeof("WINDOWS-1251")];
+- char stringpool_str411[sizeof("MS-HEBR")];
+- char stringpool_str412[sizeof("ISO-CELTIC")];
+- char stringpool_str413[sizeof("UTF-32LE")];
+- char stringpool_str416[sizeof("WINDOWS-1254")];
+- char stringpool_str418[sizeof("WINDOWS-1255")];
+- char stringpool_str420[sizeof("SHIFT-JIS")];
+- char stringpool_str421[sizeof("SHIFT_JIS")];
+- char stringpool_str422[sizeof("IBM367")];
+- char stringpool_str423[sizeof("WINDOWS-1258")];
+- char stringpool_str424[sizeof("CSPTCP154")];
+- char stringpool_str426[sizeof("GBK")];
+- char stringpool_str428[sizeof("UNICODELITTLE")];
+- char stringpool_str432[sizeof("WINDOWS-1252")];
+- char stringpool_str433[sizeof("UTF-7")];
+- char stringpool_str435[sizeof("KSC_5601")];
+- char stringpool_str437[sizeof("ASMO-708")];
+- char stringpool_str440[sizeof("CSISO2022CN")];
+- char stringpool_str444[sizeof("BIGFIVE")];
+- char stringpool_str447[sizeof("WINDOWS-936")];
+- char stringpool_str448[sizeof("CSUCS4")];
+- char stringpool_str449[sizeof("BIG-FIVE")];
+- char stringpool_str453[sizeof("ISO646-JP")];
+- char stringpool_str456[sizeof("TIS620.2529-1")];
+- char stringpool_str457[sizeof("CSISOLATINGREEK")];
+- char stringpool_str459[sizeof("CSISOLATINCYRILLIC")];
+- char stringpool_str460[sizeof("UCS-4BE")];
+- char stringpool_str462[sizeof("UNICODE-1-1-UTF-7")];
+- char stringpool_str465[sizeof("EUCTW")];
+- char stringpool_str468[sizeof("WINDOWS-1253")];
+- char stringpool_str469[sizeof("CSHPROMAN8")];
+- char stringpool_str470[sizeof("EUC-TW")];
+- char stringpool_str472[sizeof("KS_C_5601-1989")];
+- char stringpool_str476[sizeof("UCS-2BE")];
+- char stringpool_str479[sizeof("VISCII1.1-1")];
+- char stringpool_str480[sizeof("GREEK")];
+- char stringpool_str482[sizeof("WINDOWS-1250")];
+- char stringpool_str483[sizeof("CSGB2312")];
+- char stringpool_str486[sizeof("WINDOWS-874")];
+- char stringpool_str487[sizeof("CSUNICODE11")];
+- char stringpool_str489[sizeof("JAVA")];
+- char stringpool_str491[sizeof("WINDOWS-1257")];
+- char stringpool_str493[sizeof("CSUNICODE")];
+- char stringpool_str500[sizeof("CSHALFWIDTHKATAKANA")];
+- char stringpool_str502[sizeof("CSISO57GB1988")];
+- char stringpool_str504[sizeof("MACICELAND")];
+- char stringpool_str509[sizeof("CSIBM866")];
+- char stringpool_str510[sizeof("UTF-16BE")];
+- char stringpool_str513[sizeof("ARABIC")];
+- char stringpool_str514[sizeof("CN-GB")];
+- char stringpool_str518[sizeof("CSISO2022KR")];
+- char stringpool_str520[sizeof("CSMACINTOSH")];
+- char stringpool_str526[sizeof("JIS0208")];
+- char stringpool_str528[sizeof("MACROMAN")];
+- char stringpool_str530[sizeof("ISO_8859-4:1988")];
+- char stringpool_str532[sizeof("ISO_8859-5:1988")];
+- char stringpool_str535[sizeof("TIS620.2533-1")];
+- char stringpool_str536[sizeof("ANSI_X3.4-1986")];
+- char stringpool_str537[sizeof("ISO_8859-8:1988")];
+- char stringpool_str538[sizeof("KS_C_5601-1987")];
+- char stringpool_str539[sizeof("CSSHIFTJIS")];
+- char stringpool_str540[sizeof("HEBREW")];
+- char stringpool_str541[sizeof("ISO_8859-9:1989")];
+- char stringpool_str547[sizeof("MACCROATIAN")];
+- char stringpool_str548[sizeof("ISO-2022-JP-1")];
+- char stringpool_str550[sizeof("EUCJP")];
+- char stringpool_str552[sizeof("ANSI_X3.4-1968")];
+- char stringpool_str555[sizeof("EUC-JP")];
+- char stringpool_str561[sizeof("CSISO58GB231280")];
+- char stringpool_str562[sizeof("JIS_C6226-1983")];
+- char stringpool_str566[sizeof("IBM-CP1133")];
+- char stringpool_str569[sizeof("MACCENTRALEUROPE")];
+- char stringpool_str570[sizeof("CSISO159JISX02121990")];
+- char stringpool_str571[sizeof("ISO-2022-JP-2")];
+- char stringpool_str573[sizeof("CSUNICODE11UTF7")];
+- char stringpool_str574[sizeof("UCS-4-SWAPPED")];
+- char stringpool_str578[sizeof("UNICODEBIG")];
+- char stringpool_str579[sizeof("CSISO14JISC6220RO")];
+- char stringpool_str580[sizeof("JIS_C6220-1969-RO")];
+- char stringpool_str582[sizeof("ISO_8859-3:1988")];
+- char stringpool_str586[sizeof("CSPC862LATINHEBREW")];
+- char stringpool_str588[sizeof("BIG5HKSCS")];
+- char stringpool_str589[sizeof("ISO_8859-6:1987")];
+- char stringpool_str590[sizeof("UCS-2-SWAPPED")];
+- char stringpool_str591[sizeof("ISO_8859-1:1987")];
+- char stringpool_str593[sizeof("BIG5-HKSCS")];
+- char stringpool_str594[sizeof("UTF-32BE")];
+- char stringpool_str604[sizeof("ISO-2022-JP")];
+- char stringpool_str607[sizeof("KOI8-U")];
+- char stringpool_str608[sizeof("TIS620.2533-0")];
+- char stringpool_str612[sizeof("KOI8-RU")];
+- char stringpool_str614[sizeof("ISO_8859-2:1987")];
+- char stringpool_str618[sizeof("MACROMANIA")];
+- char stringpool_str641[sizeof("JIS_X0212")];
+- char stringpool_str648[sizeof("CSEUCKR")];
+- char stringpool_str649[sizeof("MACCYRILLIC")];
+- char stringpool_str650[sizeof("ISO_8859-7:2003")];
+- char stringpool_str651[sizeof("MS-ARAB")];
+- char stringpool_str657[sizeof("MS-GREEK")];
+- char stringpool_str666[sizeof("CSKSC56011987")];
+- char stringpool_str668[sizeof("JIS_X0201")];
+- char stringpool_str673[sizeof("ISO_8859-7:1987")];
+- char stringpool_str683[sizeof("CSISO2022JP2")];
+- char stringpool_str696[sizeof("JIS_X0208")];
+- char stringpool_str697[sizeof("JISX0201-1976")];
+- char stringpool_str706[sizeof("JIS_X0212-1990")];
+- char stringpool_str717[sizeof("CSISO2022JP")];
+- char stringpool_str721[sizeof("JOHAB")];
+- char stringpool_str730[sizeof("MS_KANJI")];
+- char stringpool_str734[sizeof("CSISO87JISX0208")];
+- char stringpool_str737[sizeof("MACTURKISH")];
+- char stringpool_str755[sizeof("TCVN5712-1:1993")];
+- char stringpool_str756[sizeof("JIS_X0208-1983")];
+- char stringpool_str762[sizeof("CSEUCTW")];
+- char stringpool_str763[sizeof("MACGREEK")];
+- char stringpool_str770[sizeof("JIS_X0208-1990")];
+- char stringpool_str776[sizeof("WINBALTRIM")];
+- char stringpool_str790[sizeof("MS-TURK")];
+- char stringpool_str792[sizeof("MACUKRAINE")];
+- char stringpool_str796[sizeof("MACARABIC")];
+- char stringpool_str802[sizeof("CSPC850MULTILINGUAL")];
+- char stringpool_str845[sizeof("MACHEBREW")];
+- char stringpool_str903[sizeof("JIS_X0212.1990-0")];
+- char stringpool_str979[sizeof("BIG5-HKSCS:2001")];
+- char stringpool_str986[sizeof("BIG5-HKSCS:2004")];
+- char stringpool_str995[sizeof("BIG5-HKSCS:1999")];
+- char stringpool_str997[sizeof("CSEUCPKDFMTJAPANESE")];
++ char stringpool_str4[sizeof("L2")];
++ char stringpool_str5[sizeof("L1")];
++ char stringpool_str11[sizeof("MS-EE")];
++ char stringpool_str12[sizeof("CP819")];
++ char stringpool_str15[sizeof("UCS-2")];
++ char stringpool_str16[sizeof("IBM819")];
++ char stringpool_str17[sizeof("UTF-8")];
++ char stringpool_str18[sizeof("UTF-32")];
++ char stringpool_str19[sizeof("UTF-16")];
++ char stringpool_str21[sizeof("CP367")];
++ char stringpool_str22[sizeof("ISO8859-2")];
++ char stringpool_str23[sizeof("ISO8859-1")];
++ char stringpool_str24[sizeof("IBM367")];
++ char stringpool_str25[sizeof("UTF-7")];
++ char stringpool_str26[sizeof("CHAR")];
++ char stringpool_str27[sizeof("ISO8859-15")];
++ char stringpool_str28[sizeof("US")];
++ char stringpool_str29[sizeof("ISO-8859-2")];
++ char stringpool_str31[sizeof("ISO-8859-1")];
++ char stringpool_str32[sizeof("ISO-8859-15")];
++ char stringpool_str33[sizeof("ISO_8859-2")];
++ char stringpool_str35[sizeof("ISO_8859-1")];
++ char stringpool_str36[sizeof("ISO_8859-15")];
++ char stringpool_str37[sizeof("KOI8-R")];
++ char stringpool_str38[sizeof("UCS-2LE")];
++ char stringpool_str39[sizeof("UTF-32LE")];
++ char stringpool_str40[sizeof("UTF-16LE")];
++ char stringpool_str41[sizeof("ISO_8859-15:1998")];
++ char stringpool_str43[sizeof("ISO_8859-2:1987")];
++ char stringpool_str44[sizeof("ISO_8859-1:1987")];
++ char stringpool_str45[sizeof("UCS-4")];
++ char stringpool_str47[sizeof("UNICODE-1-1")];
++ char stringpool_str48[sizeof("ISO-IR-6")];
++ char stringpool_str49[sizeof("CSKOI8R")];
++ char stringpool_str50[sizeof("ASCII")];
++ char stringpool_str51[sizeof("UNICODEBIG")];
++ char stringpool_str52[sizeof("ISO-IR-203")];
++ char stringpool_str53[sizeof("UCS-4LE")];
++ char stringpool_str54[sizeof("ISO-IR-101")];
++ char stringpool_str55[sizeof("CP1250")];
++ char stringpool_str56[sizeof("ISO-10646-UCS-2")];
++ char stringpool_str57[sizeof("UNICODE-1-1-UTF-7")];
++ char stringpool_str58[sizeof("LATIN2")];
++ char stringpool_str59[sizeof("UNICODELITTLE")];
++ char stringpool_str60[sizeof("LATIN1")];
++ char stringpool_str61[sizeof("ISO_646.IRV:1991")];
++ char stringpool_str62[sizeof("ISO646-US")];
++ char stringpool_str63[sizeof("CSUNICODE")];
++ char stringpool_str64[sizeof("UCS-2-INTERNAL")];
++ char stringpool_str65[sizeof("LATIN-9")];
++ char stringpool_str66[sizeof("WCHAR_T")];
++ char stringpool_str68[sizeof("CSUCS4")];
++ char stringpool_str69[sizeof("CSUNICODE11")];
++ char stringpool_str70[sizeof("US-ASCII")];
++ char stringpool_str71[sizeof("ISO-10646-UCS-4")];
++ char stringpool_str72[sizeof("UCS-2BE")];
++ char stringpool_str73[sizeof("UTF-32BE")];
++ char stringpool_str74[sizeof("UTF-16BE")];
++ char stringpool_str75[sizeof("ANSI_X3.4-1986")];
++ char stringpool_str76[sizeof("ANSI_X3.4-1968")];
++ char stringpool_str77[sizeof("CSUNICODE11UTF7")];
++ char stringpool_str78[sizeof("UCS-2-SWAPPED")];
++ char stringpool_str79[sizeof("UCS-4-INTERNAL")];
++ char stringpool_str80[sizeof("CSASCII")];
++ char stringpool_str87[sizeof("UCS-4BE")];
++ char stringpool_str88[sizeof("WINDOWS-1250")];
++ char stringpool_str92[sizeof("ISO-IR-100")];
++ char stringpool_str93[sizeof("UCS-4-SWAPPED")];
++ char stringpool_str97[sizeof("CSISOLATIN2")];
++ char stringpool_str98[sizeof("CSISOLATIN1")];
+ };
+ static const struct stringpool_t stringpool_contents =
+ {
+- "L6",
+- "L1",
+- "HZ",
+- "L4",
+- "L5",
+- "R8",
+- "L8",
+- "866",
+ "L2",
+- "SJIS",
+- "ISO-IR-6",
+- "ISO-IR-166",
+- "LATIN6",
+- "LATIN1",
+- "ISO-IR-14",
+- "L3",
+- "LATIN4",
+- "ISO-IR-165",
+- "LATIN5",
+- "ISO-IR-126",
+- "862",
+- "ISO-IR-144",
+- "LATIN8",
+- "ISO-IR-58",
+- "ISO-IR-148",
+- "L7",
+- "LATIN-9",
+- "ISO-IR-149",
+- "ISO-IR-159",
+- "ISO-IR-226",
+- "LATIN2",
+- "ISO8859-6",
+- "ISO-IR-199",
++ "L1",
++ "MS-EE",
++ "CP819",
++ "UCS-2",
++ "IBM819",
++ "UTF-8",
++ "UTF-32",
++ "UTF-16",
++ "CP367",
++ "ISO8859-2",
+ "ISO8859-1",
+- "ISO-8859-6",
+- "ISO_8859-6",
+- "ISO8859-16",
+- "PT154",
+- "ISO-8859-1",
+- "ISO_8859-1",
+- "ISO8859-11",
+- "ISO-8859-16",
+- "ISO_8859-16",
+- "CN",
+- "ISO-8859-11",
+- "ISO_8859-11",
+- "ISO8859-4",
+- "ISO_8859-16:2001",
+- "ISO8859-5",
+- "ISO-8859-4",
+- "ISO_8859-4",
+- "ISO8859-14",
+- "ISO-IR-101",
+- "ISO-8859-5",
+- "ISO_8859-5",
++ "IBM367",
++ "UTF-7",
++ "CHAR",
+ "ISO8859-15",
+- "ISO-8859-14",
+- "ISO_8859-14",
+- "ISO8859-8",
++ "US",
++ "ISO-8859-2",
++ "ISO-8859-1",
+ "ISO-8859-15",
++ "ISO_8859-2",
++ "ISO_8859-1",
+ "ISO_8859-15",
+- "ISO8859-9",
+- "ISO-8859-8",
+- "ISO_8859-8",
+- "CP866",
+- "ISO-IR-138",
+- "ISO-8859-9",
+- "ISO_8859-9",
+- "ISO_8859-14:1998",
++ "KOI8-R",
++ "UCS-2LE",
++ "UTF-32LE",
++ "UTF-16LE",
+ "ISO_8859-15:1998",
+- "ELOT_928",
+- "TCVN",
+- "C99",
+- "ISO8859-2",
+- "CP154",
+- "ISO-8859-2",
+- "ISO_8859-2",
+- "ISO-IR-109",
+- "L10",
+- "CHAR",
+- "CP1256",
+- "ISO-IR-179",
+- "ISO646-CN",
+- "ASCII",
+- "CP1251",
+- "LATIN3",
+- "850",
+- "GB2312",
+- "CP819",
+- "CP1254",
+- "CP949",
+- "CP1255",
+- "CP862",
+- "US",
+- "CP1361",
+- "CP1258",
+- "ISO-IR-110",
+- "IBM866",
+- "CP936",
+- "GEORGIAN-PS",
+- "LATIN10",
+- "CHINESE",
+- "CP1252",
+- "LATIN7",
+- "ISO_8859-10:1992",
+- "ISO-IR-57",
+- "TIS620",
+- "ISO8859-3",
++ "ISO_8859-2:1987",
++ "ISO_8859-1:1987",
+ "UCS-4",
+- "ISO-IR-87",
+- "TIS-620",
+- "ISO-IR-157",
+- "ISO-8859-3",
+- "ISO_8859-3",
+- "ISO8859-13",
+- "CSISOLATIN6",
+- "BIG5",
+- "ISO-8859-13",
+- "ISO_8859-13",
+- "CSISOLATIN1",
+- "KOI8-R",
+- "BIG-5",
+- "IBM819",
+- "ISO-IR-127",
+- "CP874",
+- "ISO646-US",
+- "VISCII",
+- "MS-EE",
+- "MS-ANSI",
+- "CSISOLATIN4",
+- "IBM862",
+- "CP932",
+- "X0212",
+- "CSISOLATIN5",
+- "UCS-2",
+- "ISO8859-10",
+- "MS936",
+- "WCHAR_T",
+- "ISO-8859-10",
+- "ISO_8859-10",
+- "UTF-16",
+- "EUCCN",
+- "ROMAN8",
++ "UNICODE-1-1",
++ "ISO-IR-6",
++ "CSKOI8R",
++ "ASCII",
++ "UNICODEBIG",
+ "ISO-IR-203",
+- "ISO8859-7",
+- "KOI8-T",
+- "EUC-CN",
+ "UCS-4LE",
+- "ISO-IR-100",
+- "ISO-8859-7",
+- "ISO_8859-7",
+- "MULELAO-1",
+- "GB_1988-80",
+- "X0201",
+- "ECMA-114",
+- "CSISOLATIN2",
+- "GEORGIAN-ACADEMY",
+- "PTCP154",
+- "UCS-2LE",
+- "CP1253",
+- "UTF-8",
+- "HP-ROMAN8",
+- "CSASCII",
+- "ECMA-118",
+- "UCS-4-INTERNAL",
+- "TCVN5712-1",
+- "KOREAN",
+- "CP850",
+- "MS-CYRL",
+- "CP950",
+- "TIS620-0",
+- "X0208",
+- "GREEK8",
+- "UCS-2-INTERNAL",
+- "TCVN-5712",
+- "CP1133",
++ "ISO-IR-101",
+ "CP1250",
+- "ISO-2022-CN",
+- "UTF-16LE",
+- "CYRILLIC-ASIAN",
+- "ISO-10646-UCS-4",
+- "ISO-2022-CN-EXT",
+- "CP1257",
+- "GB_2312-80",
+- "JP",
+- "EUCKR",
+ "ISO-10646-UCS-2",
+- "GB18030",
+- "EUC-KR",
+- "CSKOI8R",
+- "CSBIG5",
+- "CP367",
+- "MACINTOSH",
+- "CSISOLATIN3",
+- "CN-BIG5",
+- "CYRILLIC",
+- "CSVISCII",
+- "IBM850",
+- "MACTHAI",
+- "UNICODE-1-1",
+- "ISO_646.IRV:1991",
+- "US-ASCII",
+- "UTF-32",
+- "CN-GB-ISOIR165",
+- "NEXTSTEP",
+- "MAC",
+- "EXTENDED_UNIX_CODE_PACKED_FORMAT_FOR_JAPANESE",
+- "CSISOLATINARABIC",
+- "HZ-GB-2312",
+- "ARMSCII-8",
+- "CSISOLATINHEBREW",
+- "ISO-2022-KR",
+- "WINDOWS-1256",
+- "UHC",
+- "WINDOWS-1251",
+- "MS-HEBR",
+- "ISO-CELTIC",
+- "UTF-32LE",
+- "WINDOWS-1254",
+- "WINDOWS-1255",
+- "SHIFT-JIS",
+- "SHIFT_JIS",
+- "IBM367",
+- "WINDOWS-1258",
+- "CSPTCP154",
+- "GBK",
++ "UNICODE-1-1-UTF-7",
++ "LATIN2",
+ "UNICODELITTLE",
+- "WINDOWS-1252",
+- "UTF-7",
+- "KSC_5601",
+- "ASMO-708",
+- "CSISO2022CN",
+- "BIGFIVE",
+- "WINDOWS-936",
++ "LATIN1",
++ "ISO_646.IRV:1991",
++ "ISO646-US",
++ "CSUNICODE",
++ "UCS-2-INTERNAL",
++ "LATIN-9",
++ "WCHAR_T",
+ "CSUCS4",
+- "BIG-FIVE",
+- "ISO646-JP",
+- "TIS620.2529-1",
+- "CSISOLATINGREEK",
+- "CSISOLATINCYRILLIC",
+- "UCS-4BE",
+- "UNICODE-1-1-UTF-7",
+- "EUCTW",
+- "WINDOWS-1253",
+- "CSHPROMAN8",
+- "EUC-TW",
+- "KS_C_5601-1989",
+- "UCS-2BE",
+- "VISCII1.1-1",
+- "GREEK",
+- "WINDOWS-1250",
+- "CSGB2312",
+- "WINDOWS-874",
+ "CSUNICODE11",
+- "JAVA",
+- "WINDOWS-1257",
+- "CSUNICODE",
+- "CSHALFWIDTHKATAKANA",
+- "CSISO57GB1988",
+- "MACICELAND",
+- "CSIBM866",
++ "US-ASCII",
++ "ISO-10646-UCS-4",
++ "UCS-2BE",
++ "UTF-32BE",
+ "UTF-16BE",
+- "ARABIC",
+- "CN-GB",
+- "CSISO2022KR",
+- "CSMACINTOSH",
+- "JIS0208",
+- "MACROMAN",
+- "ISO_8859-4:1988",
+- "ISO_8859-5:1988",
+- "TIS620.2533-1",
+ "ANSI_X3.4-1986",
+- "ISO_8859-8:1988",
+- "KS_C_5601-1987",
+- "CSSHIFTJIS",
+- "HEBREW",
+- "ISO_8859-9:1989",
+- "MACCROATIAN",
+- "ISO-2022-JP-1",
+- "EUCJP",
+ "ANSI_X3.4-1968",
+- "EUC-JP",
+- "CSISO58GB231280",
+- "JIS_C6226-1983",
+- "IBM-CP1133",
+- "MACCENTRALEUROPE",
+- "CSISO159JISX02121990",
+- "ISO-2022-JP-2",
+ "CSUNICODE11UTF7",
+- "UCS-4-SWAPPED",
+- "UNICODEBIG",
+- "CSISO14JISC6220RO",
+- "JIS_C6220-1969-RO",
+- "ISO_8859-3:1988",
+- "CSPC862LATINHEBREW",
+- "BIG5HKSCS",
+- "ISO_8859-6:1987",
+ "UCS-2-SWAPPED",
+- "ISO_8859-1:1987",
+- "BIG5-HKSCS",
+- "UTF-32BE",
+- "ISO-2022-JP",
+- "KOI8-U",
+- "TIS620.2533-0",
+- "KOI8-RU",
+- "ISO_8859-2:1987",
+- "MACROMANIA",
+- "JIS_X0212",
+- "CSEUCKR",
+- "MACCYRILLIC",
+- "ISO_8859-7:2003",
+- "MS-ARAB",
+- "MS-GREEK",
+- "CSKSC56011987",
+- "JIS_X0201",
+- "ISO_8859-7:1987",
+- "CSISO2022JP2",
+- "JIS_X0208",
+- "JISX0201-1976",
+- "JIS_X0212-1990",
+- "CSISO2022JP",
+- "JOHAB",
+- "MS_KANJI",
+- "CSISO87JISX0208",
+- "MACTURKISH",
+- "TCVN5712-1:1993",
+- "JIS_X0208-1983",
+- "CSEUCTW",
+- "MACGREEK",
+- "JIS_X0208-1990",
+- "WINBALTRIM",
+- "MS-TURK",
+- "MACUKRAINE",
+- "MACARABIC",
+- "CSPC850MULTILINGUAL",
+- "MACHEBREW",
+- "JIS_X0212.1990-0",
+- "BIG5-HKSCS:2001",
+- "BIG5-HKSCS:2004",
+- "BIG5-HKSCS:1999",
+- "CSEUCPKDFMTJAPANESE"
++ "UCS-4-INTERNAL",
++ "CSASCII",
++ "UCS-4BE",
++ "WINDOWS-1250",
++ "ISO-IR-100",
++ "UCS-4-SWAPPED",
++ "CSISOLATIN2",
++ "CSISOLATIN1"
+ };
+ #define stringpool ((const char *) &stringpool_contents)
+
+ static const struct alias aliases[] =
+ {
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1},
+-#line 134 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str13, ei_iso8859_10},
+- {-1},
+-#line 60 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str15, ei_iso8859_1},
+- {-1}, {-1},
+-#line 325 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str18, ei_hz},
+- {-1}, {-1}, {-1},
+-#line 84 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str22, ei_iso8859_4},
+- {-1},
+-#line 126 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str24, ei_iso8859_9},
+- {-1},
+-#line 226 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str26, ei_hp_roman8},
+- {-1}, {-1},
+-#line 151 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str29, ei_iso8859_14},
+- {-1},
+-#line 207 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str31, ei_cp866},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+-#line 68 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str38, ei_iso8859_2},
+- {-1}, {-1}, {-1},
+-#line 303 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str42, ei_sjis},
+-#line 16 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str43, ei_ascii},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+- {-1}, {-1},
+-#line 247 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str55, ei_tis620},
+- {-1},
+-#line 133 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str57, ei_iso8859_10},
+- {-1}, {-1}, {-1},
+-#line 59 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str61, ei_iso8859_1},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+-#line 259 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str68, ei_iso646_jp},
++#line 66 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str4, ei_iso8859_2},
++#line 58 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str5, ei_iso8859_1},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+-#line 76 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str74, ei_iso8859_3},
+-#line 83 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str75, ei_iso8859_4},
+- {-1},
+-#line 289 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str77, ei_isoir165},
+- {-1},
+-#line 125 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str79, ei_iso8859_9},
+-#line 107 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str80, ei_iso8859_7},
+-#line 203 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str81, ei_cp862},
+-#line 90 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str82, ei_iso8859_5},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+-#line 150 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str89, ei_iso8859_14},
+- {-1},
+-#line 286 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str91, ei_gb2312},
+- {-1}, {-1}, {-1}, {-1},
+-#line 124 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str96, ei_iso8859_9},
+-#line 144 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str97, ei_iso8859_13},
+-#line 158 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str98, ei_iso8859_15},
+- {-1},
+-#line 294 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str100, ei_ksc5601},
+- {-1},
+-#line 278 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str102, ei_jisx0212},
+-#line 163 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str103, ei_iso8859_16},
+- {-1}, {-1}, {-1},
+-#line 67 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str107, ei_iso8859_2},
+-#line 102 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str108, ei_iso8859_6},
+-#line 149 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str109, ei_iso8859_14},
++#line 79 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str11, ei_cp1250},
++#line 55 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str12, ei_iso8859_1},
+ {-1}, {-1},
+-#line 62 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str112, ei_iso8859_1},
+-#line 94 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str113, ei_iso8859_6},
+-#line 95 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str114, ei_iso8859_6},
+-#line 166 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str115, ei_iso8859_16},
+-#line 233 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str116, ei_pt154},
+-#line 53 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str117, ei_iso8859_1},
+-#line 54 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str118, ei_iso8859_1},
+-#line 139 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str119, ei_iso8859_11},
+-#line 160 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str120, ei_iso8859_16},
+-#line 161 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str121, ei_iso8859_16},
+- {-1},
+-#line 283 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str123, ei_iso646_cn},
+-#line 137 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str124, ei_iso8859_11},
+-#line 138 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str125, ei_iso8859_11},
+-#line 86 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str126, ei_iso8859_4},
+- {-1},
+-#line 162 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str128, ei_iso8859_16},
++#line 24 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str15, ei_ucs2},
++#line 56 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str16, ei_iso8859_1},
++#line 23 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str17, ei_utf8},
++#line 41 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str18, ei_utf32},
++#line 38 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str19, ei_utf16},
+ {-1},
+-#line 93 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str130, ei_iso8859_5},
+-#line 79 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str131, ei_iso8859_4},
++#line 19 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str21, ei_ascii},
++#line 68 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str22, ei_iso8859_2},
++#line 60 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str23, ei_iso8859_1},
++#line 20 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str24, ei_ascii},
++#line 44 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str25, ei_utf7},
+ #line 80 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str132, ei_iso8859_4},
+-#line 153 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str133, ei_iso8859_14},
+-#line 66 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str134, ei_iso8859_2},
+-#line 87 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str135, ei_iso8859_5},
+-#line 88 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str136, ei_iso8859_5},
+-#line 159 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str137, ei_iso8859_15},
+-#line 146 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str138, ei_iso8859_14},
+-#line 147 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str139, ei_iso8859_14},
+-#line 120 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str140, ei_iso8859_8},
+- {-1},
+-#line 154 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str142, ei_iso8859_15},
+-#line 155 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str143, ei_iso8859_15},
+-#line 128 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str144, ei_iso8859_9},
+-#line 114 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str145, ei_iso8859_8},
+-#line 115 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str146, ei_iso8859_8},
+-#line 205 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str147, ei_cp866},
+-#line 117 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str148, ei_iso8859_8},
+-#line 121 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str149, ei_iso8859_9},
+-#line 122 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str150, ei_iso8859_9},
+-#line 148 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str151, ei_iso8859_14},
+- {-1},
+-#line 156 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str153, ei_iso8859_15},
+- {-1},
+-#line 109 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str155, ei_iso8859_7},
+-#line 253 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str156, ei_tcvn},
+-#line 51 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str157, ei_c99},
+-#line 70 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str158, ei_iso8859_2},
+- {-1}, {-1}, {-1},
+-#line 235 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str162, ei_pt154},
+-#line 63 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str163, ei_iso8859_2},
+-#line 64 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str164, ei_iso8859_2},
+- {-1},
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str26, ei_local_char},
+ #line 74 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str166, ei_iso8859_3},
+- {-1},
+-#line 165 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str168, ei_iso8859_16},
+-#line 351 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str169, ei_local_char},
+- {-1}, {-1}, {-1}, {-1},
+-#line 189 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str174, ei_cp1256},
+-#line 142 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str175, ei_iso8859_13},
+-#line 281 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str176, ei_iso646_cn},
+-#line 13 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str177, ei_ascii},
+-#line 174 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str178, ei_cp1251},
+-#line 75 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str179, ei_iso8859_3},
+- {-1},
+-#line 199 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str181, ei_cp850},
+- {-1},
+-#line 314 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str183, ei_euc_cn},
+- {-1},
+-#line 57 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str185, ei_iso8859_1},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+-#line 183 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str192, ei_cp1254},
+- {-1},
+-#line 345 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str194, ei_cp949},
+- {-1},
+-#line 186 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str196, ei_cp1255},
+-#line 201 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str197, ei_cp862},
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str27, ei_iso8859_15},
+ #line 21 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str198, ei_ascii},
+- {-1}, {-1}, {-1}, {-1},
+-#line 348 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str203, ei_johab},
+- {-1}, {-1},
+-#line 195 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str206, ei_cp1258},
+-#line 82 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str207, ei_iso8859_4},
+- {-1},
+-#line 206 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str209, ei_cp866},
+-#line 318 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str210, ei_cp936},
+-#line 231 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str211, ei_georgian_ps},
+- {-1}, {-1},
+-#line 164 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str214, ei_iso8859_16},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+-#line 288 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str222, ei_gb2312},
+- {-1},
+-#line 177 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str224, ei_cp1252},
+-#line 143 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str225, ei_iso8859_13},
+-#line 131 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str226, ei_iso8859_10},
+-#line 282 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str227, ei_iso646_cn},
+-#line 242 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str228, ei_tis620},
+- {-1},
+-#line 78 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str230, ei_iso8859_3},
+-#line 33 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str231, ei_ucs4},
+-#line 271 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str232, ei_jisx0208},
+-#line 241 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str233, ei_tis620},
+-#line 132 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str234, ei_iso8859_10},
+-#line 71 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str235, ei_iso8859_3},
+-#line 72 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str236, ei_iso8859_3},
+-#line 145 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str237, ei_iso8859_13},
+- {-1}, {-1},
+-#line 135 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str240, ei_iso8859_10},
+-#line 330 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str241, ei_ces_big5},
+-#line 140 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str242, ei_iso8859_13},
+-#line 141 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str243, ei_iso8859_13},
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str28, ei_ascii},
+ #line 61 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str244, ei_iso8859_1},
+-#line 167 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str245, ei_koi8_r},
+-#line 331 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str246, ei_ces_big5},
+-#line 58 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str247, ei_iso8859_1},
+-#line 97 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str248, ei_iso8859_6},
+-#line 248 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str249, ei_cp874},
+- {-1},
+-#line 14 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str251, ei_ascii},
+-#line 250 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str252, ei_viscii},
+-#line 173 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str253, ei_cp1250},
+- {-1}, {-1},
+-#line 179 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str256, ei_cp1252},
+- {-1},
+-#line 85 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str258, ei_iso8859_4},
+-#line 202 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str259, ei_cp862},
+-#line 306 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str260, ei_cp932},
+-#line 277 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str261, ei_jisx0212},
+-#line 127 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str262, ei_iso8859_9},
+-#line 24 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str263, ei_ucs2},
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str29, ei_iso8859_2},
+ {-1},
+-#line 136 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str265, ei_iso8859_10},
+-#line 319 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str266, ei_cp936},
+-#line 352 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str267, ei_local_wchar_t},
+- {-1}, {-1},
+-#line 129 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str270, ei_iso8859_10},
+-#line 130 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str271, ei_iso8859_10},
+-#line 38 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str272, ei_utf16},
+-#line 313 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str273, ei_euc_cn},
+-#line 225 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str274, ei_hp_roman8},
+-#line 157 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str275, ei_iso8859_15},
+-#line 113 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str276, ei_iso8859_7},
+-#line 232 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str277, ei_koi8_t},
+-#line 312 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str278, ei_euc_cn},
+-#line 37 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str279, ei_ucs4le},
+-#line 56 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str280, ei_iso8859_1},
+-#line 103 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str281, ei_iso8859_7},
+-#line 104 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str282, ei_iso8859_7},
+-#line 238 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str283, ei_mulelao},
+-#line 280 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str284, ei_iso646_cn},
+- {-1}, {-1}, {-1},
+-#line 264 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str288, ei_jisx0201},
+-#line 98 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str289, ei_iso8859_6},
++#line 51 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str31, ei_iso8859_1},
+ #line 69 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str290, ei_iso8859_2},
+-#line 230 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str291, ei_georgian_academy},
+-#line 234 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str292, ei_pt154},
+- {-1}, {-1},
+-#line 31 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str295, ei_ucs2le},
+-#line 180 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str296, ei_cp1253},
+-#line 23 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str297, ei_utf8},
+-#line 224 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str298, ei_hp_roman8},
+- {-1},
+-#line 22 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str300, ei_ascii},
+- {-1}, {-1},
+-#line 108 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str303, ei_iso8859_7},
+-#line 49 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str304, ei_ucs4internal},
+-#line 255 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str305, ei_tcvn},
+- {-1},
+-#line 296 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str307, ei_ksc5601},
+-#line 197 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str308, ei_cp850},
+-#line 176 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str309, ei_cp1251},
+-#line 336 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str310, ei_cp950},
+- {-1}, {-1},
+-#line 243 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str313, ei_tis620},
+- {-1}, {-1},
+-#line 270 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str316, ei_jisx0208},
+- {-1}, {-1},
+-#line 110 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str319, ei_iso8859_7},
+-#line 47 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str320, ei_ucs2internal},
+-#line 254 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str321, ei_tcvn},
+- {-1},
+-#line 239 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str323, ei_cp1133},
+-#line 171 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str324, ei_cp1250},
+- {-1}, {-1},
+-#line 322 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str327, ei_iso2022_cn},
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str32, ei_iso8859_15},
++#line 62 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str33, ei_iso8859_2},
+ {-1},
++#line 52 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str35, ei_iso8859_1},
++#line 70 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str36, ei_iso8859_15},
++#line 75 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str37, ei_koi8_r},
++#line 31 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str38, ei_ucs2le},
++#line 43 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str39, ei_utf32le},
+ #line 40 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str329, ei_utf16le},
+- {-1}, {-1}, {-1}, {-1}, {-1},
+-#line 236 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str335, ei_pt154},
+- {-1},
+-#line 34 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str337, ei_ucs4},
+- {-1}, {-1},
+-#line 324 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str340, ei_iso2022_cn_ext},
+- {-1},
+-#line 192 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str342, ei_cp1257},
+- {-1}, {-1},
+-#line 285 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str345, ei_gb2312},
+- {-1},
+-#line 260 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str347, ei_iso646_jp},
+- {-1}, {-1}, {-1},
+-#line 343 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str351, ei_euc_kr},
+- {-1},
+-#line 25 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str353, ei_ucs2},
+-#line 321 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str354, ei_gb18030},
+- {-1},
+-#line 342 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str356, ei_euc_kr},
+-#line 168 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str357, ei_koi8_r},
+-#line 335 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str358, ei_ces_big5},
+- {-1},
+-#line 19 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str360, ei_ascii},
+-#line 210 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str361, ei_mac_roman},
+-#line 77 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str362, ei_iso8859_3},
+-#line 334 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str363, ei_ces_big5},
+- {-1}, {-1},
+-#line 91 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str366, ei_iso8859_5},
+- {-1}, {-1},
+-#line 252 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str369, ei_viscii},
+-#line 198 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str370, ei_cp850},
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str40, ei_utf16le},
++#line 71 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str41, ei_iso8859_15},
+ {-1},
+-#line 223 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str372, ei_mac_thai},
++#line 63 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str43, ei_iso8859_2},
++#line 53 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str44, ei_iso8859_1},
++#line 33 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str45, ei_ucs4},
+ {-1},
+ #line 29 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str374, ei_ucs2be},
+- {-1},
+-#line 15 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str376, ei_ascii},
+- {-1}, {-1}, {-1},
+-#line 12 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str380, ei_ascii},
+-#line 41 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str381, ei_utf32},
+- {-1}, {-1},
+-#line 290 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str384, ei_isoir165},
+- {-1}, {-1},
+-#line 228 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str387, ei_nextstep},
+- {-1},
+-#line 211 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str389, ei_mac_roman},
+- {-1}, {-1}, {-1},
+-#line 299 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str393, ei_euc_jp},
+-#line 101 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str394, ei_iso8859_6},
+-#line 326 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str395, ei_hz},
+- {-1},
+-#line 229 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str397, ei_armscii_8},
+- {-1}, {-1}, {-1},
+-#line 119 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str401, ei_iso8859_8},
+- {-1}, {-1}, {-1},
+-#line 349 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str405, ei_iso2022_kr},
+- {-1},
+-#line 190 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str407, ei_cp1256},
+-#line 346 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str408, ei_cp949},
+-#line 175 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str409, ei_cp1251},
+- {-1},
+-#line 188 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str411, ei_cp1255},
+-#line 152 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str412, ei_iso8859_14},
+-#line 43 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str413, ei_utf32le},
+- {-1}, {-1},
+-#line 184 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str416, ei_cp1254},
+- {-1},
+-#line 187 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str418, ei_cp1255},
+- {-1},
+-#line 302 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str420, ei_sjis},
+-#line 301 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str421, ei_sjis},
+-#line 20 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str422, ei_ascii},
+-#line 196 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str423, ei_cp1258},
+-#line 237 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str424, ei_pt154},
+- {-1},
+-#line 317 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str426, ei_ces_gbk},
+- {-1},
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str47, ei_ucs2be},
++#line 16 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str48, ei_ascii},
++#line 76 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str49, ei_koi8_r},
++#line 13 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str50, ei_ascii},
++#line 28 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str51, ei_ucs2be},
++#line 72 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str52, ei_iso8859_15},
++#line 37 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str53, ei_ucs4le},
++#line 64 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str54, ei_iso8859_2},
++#line 77 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str55, ei_cp1250},
++#line 25 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str56, ei_ucs2},
++#line 45 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str57, ei_utf7},
++#line 65 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str58, ei_iso8859_2},
+ #line 32 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str428, ei_ucs2le},
+- {-1}, {-1}, {-1},
+-#line 178 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str432, ei_cp1252},
+-#line 44 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str433, ei_utf7},
+- {-1},
+-#line 291 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str435, ei_ksc5601},
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str59, ei_ucs2le},
++#line 57 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str60, ei_iso8859_1},
++#line 15 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str61, ei_ascii},
++#line 14 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str62, ei_ascii},
++#line 26 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str63, ei_ucs2},
++#line 47 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str64, ei_ucs2internal},
++#line 73 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str65, ei_iso8859_15},
++#line 81 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str66, ei_local_wchar_t},
+ {-1},
+-#line 99 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str437, ei_iso8859_6},
+- {-1}, {-1},
+-#line 323 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str440, ei_iso2022_cn},
+- {-1}, {-1}, {-1},
+-#line 333 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str444, ei_ces_big5},
+- {-1}, {-1},
+-#line 320 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str447, ei_cp936},
+ #line 35 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str448, ei_ucs4},
+-#line 332 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str449, ei_ces_big5},
+- {-1}, {-1}, {-1},
+-#line 258 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str453, ei_iso646_jp},
+- {-1}, {-1},
+-#line 244 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str456, ei_tis620},
+-#line 112 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str457, ei_iso8859_7},
+- {-1},
+-#line 92 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str459, ei_iso8859_5},
+-#line 36 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str460, ei_ucs4be},
+- {-1},
+-#line 45 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str462, ei_utf7},
+- {-1}, {-1},
+-#line 328 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str465, ei_euc_tw},
+- {-1}, {-1},
+-#line 181 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str468, ei_cp1253},
+-#line 227 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str469, ei_hp_roman8},
+-#line 327 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str470, ei_euc_tw},
+- {-1},
+-#line 293 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str472, ei_ksc5601},
+- {-1}, {-1}, {-1},
+-#line 27 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str476, ei_ucs2be},
+- {-1}, {-1},
+-#line 251 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str479, ei_viscii},
+-#line 111 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str480, ei_iso8859_7},
+- {-1},
+-#line 172 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str482, ei_cp1250},
+-#line 316 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str483, ei_euc_cn},
+- {-1}, {-1},
+-#line 249 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str486, ei_cp874},
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str68, ei_ucs4},
+ #line 30 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str487, ei_ucs2be},
+- {-1},
+-#line 52 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str489, ei_java},
+- {-1},
+-#line 193 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str491, ei_cp1257},
+- {-1},
+-#line 26 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str493, ei_ucs2},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+-#line 265 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str500, ei_jisx0201},
+- {-1},
+-#line 284 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str502, ei_iso646_cn},
+- {-1},
+-#line 214 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str504, ei_mac_iceland},
+- {-1}, {-1}, {-1}, {-1},
+-#line 208 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str509, ei_cp866},
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str69, ei_ucs2be},
++#line 12 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str70, ei_ascii},
++#line 34 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str71, ei_ucs4},
++#line 27 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str72, ei_ucs2be},
++#line 42 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str73, ei_utf32be},
+ #line 39 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str510, ei_utf16be},
+- {-1}, {-1},
+-#line 100 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str513, ei_iso8859_6},
+-#line 315 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str514, ei_euc_cn},
+- {-1}, {-1}, {-1},
+-#line 350 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str518, ei_iso2022_kr},
+- {-1},
+-#line 212 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str520, ei_mac_roman},
+- {-1}, {-1}, {-1}, {-1}, {-1},
+-#line 269 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str526, ei_jisx0208},
+- {-1},
+-#line 209 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str528, ei_mac_roman},
+- {-1},
+-#line 81 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str530, ei_iso8859_4},
+- {-1},
+-#line 89 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str532, ei_iso8859_5},
+- {-1}, {-1},
+-#line 246 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str535, ei_tis620},
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str74, ei_utf16be},
+ #line 18 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str536, ei_ascii},
+-#line 116 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str537, ei_iso8859_8},
+-#line 292 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str538, ei_ksc5601},
+-#line 305 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str539, ei_sjis},
+-#line 118 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str540, ei_iso8859_8},
+-#line 123 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str541, ei_iso8859_9},
+- {-1}, {-1}, {-1}, {-1}, {-1},
+-#line 215 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str547, ei_mac_croatian},
+-#line 309 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str548, ei_iso2022_jp1},
+- {-1},
+-#line 298 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str550, ei_euc_jp},
+- {-1},
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str75, ei_ascii},
+ #line 17 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str552, ei_ascii},
+- {-1}, {-1},
+-#line 297 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str555, ei_euc_jp},
+- {-1}, {-1}, {-1}, {-1}, {-1},
+-#line 287 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str561, ei_gb2312},
+-#line 272 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str562, ei_jisx0208},
+- {-1}, {-1}, {-1},
+-#line 240 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str566, ei_cp1133},
+- {-1}, {-1},
+-#line 213 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str569, ei_mac_centraleurope},
+-#line 279 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str570, ei_jisx0212},
+-#line 310 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str571, ei_iso2022_jp2},
+- {-1},
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str76, ei_ascii},
+ #line 46 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str573, ei_utf7},
+-#line 50 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str574, ei_ucs4swapped},
+- {-1}, {-1}, {-1},
+-#line 28 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str578, ei_ucs2be},
+-#line 261 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str579, ei_iso646_jp},
+-#line 257 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str580, ei_iso646_jp},
+- {-1},
+-#line 73 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str582, ei_iso8859_3},
+- {-1}, {-1}, {-1},
+-#line 204 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str586, ei_cp862},
+- {-1},
+-#line 340 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str588, ei_big5hkscs2004},
+-#line 96 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str589, ei_iso8859_6},
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str77, ei_utf7},
+ #line 48 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str590, ei_ucs2swapped},
+-#line 55 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str591, ei_iso8859_1},
+- {-1},
+-#line 339 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str593, ei_big5hkscs2004},
+-#line 42 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str594, ei_utf32be},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+-#line 307 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str604, ei_iso2022_jp},
+- {-1}, {-1},
+-#line 169 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str607, ei_koi8_u},
+-#line 245 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str608, ei_tis620},
+- {-1}, {-1}, {-1},
+-#line 170 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str612, ei_koi8_ru},
+- {-1},
+-#line 65 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str614, ei_iso8859_2},
+- {-1}, {-1}, {-1},
+-#line 216 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str618, ei_mac_romania},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+- {-1}, {-1}, {-1}, {-1},
+-#line 274 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str641, ei_jisx0212},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+-#line 344 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str648, ei_euc_kr},
+-#line 217 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str649, ei_mac_cyrillic},
+-#line 106 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str650, ei_iso8859_7},
+-#line 191 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str651, ei_cp1256},
+- {-1}, {-1}, {-1}, {-1}, {-1},
+-#line 182 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str657, ei_cp1253},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+-#line 295 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str666, ei_ksc5601},
+- {-1},
+-#line 262 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str668, ei_jisx0201},
+- {-1}, {-1}, {-1}, {-1},
+-#line 105 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str673, ei_iso8859_7},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+-#line 311 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str683, ei_iso2022_jp2},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+- {-1}, {-1}, {-1},
+-#line 266 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str696, ei_jisx0208},
+-#line 263 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str697, ei_jisx0201},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+-#line 276 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str706, ei_jisx0212},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+- {-1},
+-#line 308 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str717, ei_iso2022_jp},
+- {-1}, {-1}, {-1},
+-#line 347 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str721, ei_johab},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+-#line 304 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str730, ei_sjis},
+- {-1}, {-1}, {-1},
+-#line 273 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str734, ei_jisx0208},
+- {-1}, {-1},
+-#line 220 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str737, ei_mac_turkish},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+-#line 256 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str755, ei_tcvn},
+-#line 267 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str756, ei_jisx0208},
+- {-1}, {-1}, {-1}, {-1}, {-1},
+-#line 329 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str762, ei_euc_tw},
+-#line 219 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str763, ei_mac_greek},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+-#line 268 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str770, ei_jisx0208},
+- {-1}, {-1}, {-1}, {-1}, {-1},
+-#line 194 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str776, ei_cp1257},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+- {-1}, {-1}, {-1}, {-1},
+-#line 185 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str790, ei_cp1254},
+- {-1},
+-#line 218 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str792, ei_mac_ukraine},
+- {-1}, {-1}, {-1},
+-#line 222 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str796, ei_mac_arabic},
+- {-1}, {-1}, {-1}, {-1}, {-1},
+-#line 200 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str802, ei_cp850},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str78, ei_ucs2swapped},
++#line 49 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str79, ei_ucs4internal},
++#line 22 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str80, ei_ascii},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+-#line 221 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str845, ei_mac_hebrew},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
++#line 36 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str87, ei_ucs4be},
++#line 78 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str88, ei_cp1250},
+ {-1}, {-1}, {-1},
+-#line 275 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str903, ei_jisx0212},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
++#line 54 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str92, ei_iso8859_1},
++#line 50 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str93, ei_ucs4swapped},
+ {-1}, {-1}, {-1},
+-#line 338 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str979, ei_big5hkscs2001},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+-#line 341 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str986, ei_big5hkscs2004},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+-#line 337 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str995, ei_big5hkscs1999},
+- {-1},
+-#line 300 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str997, ei_euc_jp}
++#line 67 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str97, ei_iso8859_2},
++#line 59 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str98, ei_iso8859_1}
+ };
+
+ #ifdef __GNUC__
+--- a/lib/canonical_dos.h
++++ b/lib/canonical_dos.h
+@@ -1,15 +1 @@
+ (int)(long)&((struct stringpool2_t *)0)->stringpool_dos_0,
+- (int)(long)&((struct stringpool2_t *)0)->stringpool_dos_4,
+- (int)(long)&((struct stringpool2_t *)0)->stringpool_dos_5,
+- (int)(long)&((struct stringpool2_t *)0)->stringpool_dos_8,
+- (int)(long)&((struct stringpool2_t *)0)->stringpool_dos_12,
+- (int)(long)&((struct stringpool2_t *)0)->stringpool_dos_13,
+- (int)(long)&((struct stringpool2_t *)0)->stringpool_dos_17,
+- (int)(long)&((struct stringpool2_t *)0)->stringpool_dos_21,
+- (int)(long)&((struct stringpool2_t *)0)->stringpool_dos_22,
+- (int)(long)&((struct stringpool2_t *)0)->stringpool_dos_26,
+- (int)(long)&((struct stringpool2_t *)0)->stringpool_dos_31,
+- (int)(long)&((struct stringpool2_t *)0)->stringpool_dos_35,
+- (int)(long)&((struct stringpool2_t *)0)->stringpool_dos_38,
+- (int)(long)&((struct stringpool2_t *)0)->stringpool_dos_42,
+- (int)(long)&((struct stringpool2_t *)0)->stringpool_dos_47,
+--- a/lib/canonical.h
++++ b/lib/canonical.h
+@@ -1,107 +1 @@
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str380,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str297,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str263,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str476,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str295,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str231,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str460,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str279,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str272,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str510,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str329,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str381,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str594,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str413,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str433,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str320,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str590,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str304,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str574,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str157,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str489,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str117,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str163,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str235,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str131,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str135,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str113,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str281,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str145,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str149,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str270,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str124,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str242,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str138,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str142,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str120,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str245,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str607,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str612,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str324,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str178,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str224,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str296,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str192,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str196,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str174,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str342,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str206,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str308,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str197,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str147,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str528,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str569,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str504,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str547,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str618,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str649,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str792,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str763,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str737,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str845,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str796,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str372,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str298,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str387,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str397,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str291,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str211,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str277,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str116,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str283,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str323,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str233,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str249,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str252,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str156,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str580,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str668,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str696,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str641,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str284,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str345,
+ (int)(long)&((struct stringpool_t *)0)->stringpool_str77,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str435,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str555,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str421,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str260,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str604,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str548,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str571,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str278,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str426,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str210,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str354,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str327,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str340,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str18,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str470,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str241,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str310,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str995,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str979,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str593,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str356,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str194,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str721,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str405,
+--- a/lib/canonical_local.h
++++ b/lib/canonical_local.h
+@@ -1,2 +1 @@
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str169,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str267,
++
+--- a/lib/converters.h
++++ b/lib/converters.h
+@@ -129,161 +129,15 @@ struct conv_struct {
+ #include "ucs2swapped.h"
+ #include "ucs4internal.h"
+ #include "ucs4swapped.h"
+-#include "c99.h"
+-#include "java.h"
+
+ /* 8-bit encodings */
+ #include "iso8859_1.h"
+ #include "iso8859_2.h"
+-#include "iso8859_3.h"
+-#include "iso8859_4.h"
+-#include "iso8859_5.h"
+-#include "iso8859_6.h"
+-#include "iso8859_7.h"
+-#include "iso8859_8.h"
+-#include "iso8859_9.h"
+-#include "iso8859_10.h"
+-#include "iso8859_11.h"
+-#include "iso8859_13.h"
+-#include "iso8859_14.h"
+ #include "iso8859_15.h"
+-#include "iso8859_16.h"
+ #include "koi8_r.h"
+-#include "koi8_u.h"
+-#include "koi8_ru.h"
+ #include "cp1250.h"
+-#include "cp1251.h"
+-#include "cp1252.h"
+-#include "cp1253.h"
+-#include "cp1254.h"
+-#include "cp1255.h"
+-#include "cp1256.h"
+-#include "cp1257.h"
+-#include "cp1258.h"
+ #include "cp850.h"
+-#include "cp862.h"
+-#include "cp866.h"
+-#include "mac_roman.h"
+-#include "mac_centraleurope.h"
+-#include "mac_iceland.h"
+-#include "mac_croatian.h"
+-#include "mac_romania.h"
+-#include "mac_cyrillic.h"
+-#include "mac_ukraine.h"
+-#include "mac_greek.h"
+-#include "mac_turkish.h"
+-#include "mac_hebrew.h"
+-#include "mac_arabic.h"
+-#include "mac_thai.h"
+-#include "hp_roman8.h"
+-#include "nextstep.h"
+-#include "armscii_8.h"
+-#include "georgian_academy.h"
+-#include "georgian_ps.h"
+-#include "koi8_t.h"
+-#include "pt154.h"
+-#include "mulelao.h"
+-#include "cp1133.h"
+-#include "tis620.h"
+-#include "cp874.h"
+-#include "viscii.h"
+-#include "tcvn.h"
+-
+-/* CJK character sets [CCS = coded character set] [CJKV.INF chapter 3] */
+-
+-typedef struct {
+- unsigned short indx; /* index into big table */
+- unsigned short used; /* bitmask of used entries */
+-} Summary16;
+-
+-#include "iso646_jp.h"
+-#include "jisx0201.h"
+-#include "jisx0208.h"
+-#include "jisx0212.h"
+-
+-#include "iso646_cn.h"
+-#include "gb2312.h"
+-#include "isoir165.h"
+-/*#include "gb12345.h"*/
+-#include "gbk.h"
+-#include "cns11643.h"
+-#include "big5.h"
+-
+-#include "ksc5601.h"
+-#include "johab_hangul.h"
+-
+-/* CJK encodings [CES = character encoding scheme] [CJKV.INF chapter 4] */
+-
+-#include "euc_jp.h"
+-#include "sjis.h"
+-#include "cp932.h"
+-#include "iso2022_jp.h"
+-#include "iso2022_jp1.h"
+-#include "iso2022_jp2.h"
+-
+-#include "euc_cn.h"
+-#include "ces_gbk.h"
+-#include "cp936.h"
+-#include "gb18030.h"
+-#include "iso2022_cn.h"
+-#include "iso2022_cnext.h"
+-#include "hz.h"
+-#include "euc_tw.h"
+-#include "ces_big5.h"
+-#include "cp950.h"
+-#include "big5hkscs1999.h"
+-#include "big5hkscs2001.h"
+-#include "big5hkscs2004.h"
+-
+-#include "euc_kr.h"
+-#include "cp949.h"
+-#include "johab.h"
+-#include "iso2022_kr.h"
+-
+-/* Encodings used by system dependent locales. */
+-
+-#ifdef USE_AIX
+-#include "cp856.h"
+-#include "cp922.h"
+-#include "cp943.h"
+-#include "cp1046.h"
+-#include "cp1124.h"
+-#include "cp1129.h"
+-#include "cp1161.h"
+-#include "cp1162.h"
+-#include "cp1163.h"
+-#endif
+-
+-#ifdef USE_OSF1
+-#include "dec_kanji.h"
+-#include "dec_hanyu.h"
+-#endif
+
+ #ifdef USE_DOS
+ #include "cp437.h"
+-#include "cp737.h"
+-#include "cp775.h"
+-#include "cp852.h"
+-#include "cp853.h"
+-#include "cp855.h"
+-#include "cp857.h"
+-#include "cp858.h"
+-#include "cp860.h"
+-#include "cp861.h"
+-#include "cp863.h"
+-#include "cp864.h"
+-#include "cp865.h"
+-#include "cp869.h"
+-#include "cp1125.h"
+-#endif
+-
+-#ifdef USE_EXTRA
+-#include "euc_jisx0213.h"
+-#include "shift_jisx0213.h"
+-#include "iso2022_jp3.h"
+-#include "big5_2003.h"
+-#include "tds565.h"
+-#include "atarist.h"
+-#include "riscos1.h"
+ #endif
+-
+--- a/lib/encodings.def
++++ b/lib/encodings.def
+@@ -161,16 +161,6 @@ DEFENCODING(( "UCS-4-SWAPPED",
+ ucs4swapped,
+ { ucs4swapped_mbtowc, NULL }, { ucs4swapped_wctomb, NULL })
+
+-DEFENCODING(( "C99",
+- ),
+- c99,
+- { c99_mbtowc, NULL }, { c99_wctomb, NULL })
+-
+-DEFENCODING(( "JAVA",
+- ),
+- java,
+- { java_mbtowc, NULL }, { java_wctomb, NULL })
+-
+ /* Standard 8-bit encodings */
+
+ DEFENCODING(( "ISO-8859-1", /* IANA */
+@@ -203,148 +193,6 @@ DEFENCODING(( "ISO-8859-2",
+ iso8859_2,
+ { iso8859_2_mbtowc, NULL }, { iso8859_2_wctomb, NULL })
+
+-DEFENCODING(( "ISO-8859-3", /* IANA */
+- "ISO_8859-3", /* IANA */
+- "ISO_8859-3:1988", /* IANA */
+- "ISO-IR-109", /* IANA */
+- "LATIN3", /* IANA */
+- "L3", /* IANA */
+- "csISOLatin3", /* IANA */
+- "ISO8859-3", /* X11R6.4, glibc, FreeBSD */
+- /*"ISO8859_3", JDK 1.1 */
+- /*"CP28593", Windows */
+- ),
+- iso8859_3,
+- { iso8859_3_mbtowc, NULL }, { iso8859_3_wctomb, NULL })
+-
+-DEFENCODING(( "ISO-8859-4", /* IANA */
+- "ISO_8859-4", /* IANA */
+- "ISO_8859-4:1988", /* IANA */
+- "ISO-IR-110", /* IANA */
+- "LATIN4", /* IANA */
+- "L4", /* IANA */
+- "csISOLatin4", /* IANA */
+- "ISO8859-4", /* X11R6.4, glibc, FreeBSD */
+- /*"ISO8859_4", JDK 1.1 */
+- /*"CP28594", Windows */
+- ),
+- iso8859_4,
+- { iso8859_4_mbtowc, NULL }, { iso8859_4_wctomb, NULL })
+-
+-DEFENCODING(( "ISO-8859-5", /* IANA */
+- "ISO_8859-5", /* IANA */
+- "ISO_8859-5:1988", /* IANA */
+- "ISO-IR-144", /* IANA */
+- "CYRILLIC", /* IANA */
+- "csISOLatinCyrillic", /* IANA */
+- "ISO8859-5", /* X11R6.4, glibc, FreeBSD */
+- /*"ISO8859_5", JDK 1.1 */
+- /*"CP28595", Windows */
+- ),
+- iso8859_5,
+- { iso8859_5_mbtowc, NULL }, { iso8859_5_wctomb, NULL })
+-
+-DEFENCODING(( "ISO-8859-6", /* IANA */
+- "ISO_8859-6", /* IANA */
+- "ISO_8859-6:1987", /* IANA */
+- "ISO-IR-127", /* IANA */
+- "ECMA-114", /* IANA */
+- "ASMO-708", /* IANA */
+- "ARABIC", /* IANA */
+- "csISOLatinArabic", /* IANA */
+- "ISO8859-6", /* X11R6.4, glibc, FreeBSD */
+- /*"ISO8859_6", JDK 1.1 */
+- /*"CP28596", Windows */
+- ),
+- iso8859_6,
+- { iso8859_6_mbtowc, NULL }, { iso8859_6_wctomb, NULL })
+-
+-DEFENCODING(( "ISO-8859-7", /* IANA, RFC 1947 */
+- "ISO_8859-7", /* IANA */
+- "ISO_8859-7:1987", /* IANA */
+- "ISO_8859-7:2003",
+- "ISO-IR-126", /* IANA */
+- "ECMA-118", /* IANA */
+- "ELOT_928", /* IANA */
+- "GREEK8", /* IANA */
+- "GREEK", /* IANA */
+- "csISOLatinGreek", /* IANA */
+- "ISO8859-7", /* X11R6.4, glibc, FreeBSD */
+- /*"ISO8859_7", JDK 1.1 */
+- /*"CP28597", Windows */
+- ),
+- iso8859_7,
+- { iso8859_7_mbtowc, NULL }, { iso8859_7_wctomb, NULL })
+-
+-DEFENCODING(( "ISO-8859-8", /* IANA */
+- "ISO_8859-8", /* IANA */
+- "ISO_8859-8:1988", /* IANA */
+- "ISO-IR-138", /* IANA */
+- "HEBREW", /* IANA */
+- "csISOLatinHebrew", /* IANA */
+- "ISO8859-8", /* X11R6.4, glibc, FreeBSD */
+- /*"ISO8859_8", JDK 1.1 */
+- /*"CP28598", Windows */
+- /*"CP38598", Windows */
+- ),
+- iso8859_8,
+- { iso8859_8_mbtowc, NULL }, { iso8859_8_wctomb, NULL })
+-
+-DEFENCODING(( "ISO-8859-9", /* IANA */
+- "ISO_8859-9", /* IANA */
+- "ISO_8859-9:1989", /* IANA */
+- "ISO-IR-148", /* IANA */
+- "LATIN5", /* IANA */
+- "L5", /* IANA */
+- "csISOLatin5", /* IANA */
+- "ISO8859-9", /* X11R6.4, glibc, FreeBSD */
+- /*"ISO8859_9", JDK 1.1 */
+- /*"CP28599", Windows */
+- ),
+- iso8859_9,
+- { iso8859_9_mbtowc, NULL }, { iso8859_9_wctomb, NULL })
+-
+-DEFENCODING(( "ISO-8859-10", /* IANA */
+- "ISO_8859-10",
+- "ISO_8859-10:1992", /* IANA */
+- "ISO-IR-157", /* IANA */
+- "LATIN6", /* IANA */
+- "L6", /* IANA */
+- "csISOLatin6", /* IANA */
+- "ISO8859-10", /* X11R6.4, glibc, FreeBSD */
+- ),
+- iso8859_10,
+- { iso8859_10_mbtowc, NULL }, { iso8859_10_wctomb, NULL })
+-
+-DEFENCODING(( "ISO-8859-11", /* glibc */
+- "ISO_8859-11",
+- "ISO8859-11", /* X11R6.7, glibc */
+- ),
+- iso8859_11,
+- { iso8859_11_mbtowc, NULL }, { iso8859_11_wctomb, NULL })
+-
+-DEFENCODING(( "ISO-8859-13", /* IANA, glibc */
+- "ISO_8859-13",
+- "ISO-IR-179", /* glibc */
+- "LATIN7", /* glibc */
+- "L7", /* glibc */
+- "ISO8859-13", /* glibc, FreeBSD */
+- ),
+- iso8859_13,
+- { iso8859_13_mbtowc, NULL }, { iso8859_13_wctomb, NULL })
+-
+-DEFENCODING(( "ISO-8859-14", /* IANA, glibc */
+- "ISO_8859-14", /* IANA */
+- "ISO_8859-14:1998", /* IANA, glibc */
+- "ISO-IR-199", /* IANA */
+- "LATIN8", /* IANA, glibc */
+- "L8", /* IANA, glibc */
+- "ISO-CELTIC", /* IANA */
+- "ISO8859-14", /* glibc, FreeBSD */
+- ),
+- iso8859_14,
+- { iso8859_14_mbtowc, NULL }, { iso8859_14_wctomb, NULL })
+-
+ DEFENCODING(( "ISO-8859-15", /* IANA, glibc */
+ "ISO_8859-15", /* IANA */
+ "ISO_8859-15:1998", /* glibc */
+@@ -356,17 +204,6 @@ DEFENCODING(( "ISO-8859-15",
+ iso8859_15,
+ { iso8859_15_mbtowc, NULL }, { iso8859_15_wctomb, NULL })
+
+-DEFENCODING(( "ISO-8859-16", /* IANA */
+- "ISO_8859-16", /* IANA */
+- "ISO_8859-16:2001", /* IANA */
+- "ISO-IR-226", /* IANA */
+- "LATIN10", /* IANA */
+- "L10", /* IANA */
+- "ISO8859-16", /* glibc, FreeBSD */
+- ),
+- iso8859_16,
+- { iso8859_16_mbtowc, NULL }, { iso8859_16_wctomb, NULL })
+-
+ DEFENCODING(( "KOI8-R", /* IANA, RFC 1489, X11R6.4, JDK 1.1 */
+ "csKOI8R", /* IANA */
+ /*"CP20866", Windows */
+@@ -374,16 +211,6 @@ DEFENCODING(( "KOI8-R",
+ koi8_r,
+ { koi8_r_mbtowc, NULL }, { koi8_r_wctomb, NULL })
+
+-DEFENCODING(( "KOI8-U", /* IANA, RFC 2319 */
+- ),
+- koi8_u,
+- { koi8_u_mbtowc, NULL }, { koi8_u_wctomb, NULL })
+-
+-DEFENCODING(( "KOI8-RU",
+- ),
+- koi8_ru,
+- { koi8_ru_mbtowc, NULL }, { koi8_ru_wctomb, NULL })
+-
+ /* Windows 8-bit encodings */
+
+ DEFENCODING(( "CP1250", /* JDK 1.1 */
+@@ -393,61 +220,6 @@ DEFENCODING(( "CP1250",
+ cp1250,
+ { cp1250_mbtowc, NULL }, { cp1250_wctomb, NULL })
+
+-DEFENCODING(( "CP1251", /* JDK 1.1 */
+- "WINDOWS-1251", /* IANA */
+- "MS-CYRL",
+- ),
+- cp1251,
+- { cp1251_mbtowc, NULL }, { cp1251_wctomb, NULL })
+-
+-DEFENCODING(( "CP1252", /* JDK 1.1 */
+- "WINDOWS-1252", /* IANA */
+- "MS-ANSI",
+- ),
+- cp1252,
+- { cp1252_mbtowc, NULL }, { cp1252_wctomb, NULL })
+-
+-DEFENCODING(( "CP1253", /* JDK 1.1 */
+- "WINDOWS-1253", /* IANA */
+- "MS-GREEK",
+- ),
+- cp1253,
+- { cp1253_mbtowc, NULL }, { cp1253_wctomb, NULL })
+-
+-DEFENCODING(( "CP1254", /* JDK 1.1 */
+- "WINDOWS-1254", /* IANA */
+- "MS-TURK",
+- ),
+- cp1254,
+- { cp1254_mbtowc, NULL }, { cp1254_wctomb, NULL })
+-
+-DEFENCODING(( "CP1255", /* JDK 1.1 */
+- "WINDOWS-1255", /* IANA */
+- "MS-HEBR",
+- ),
+- cp1255,
+- { cp1255_mbtowc, cp1255_flushwc }, { cp1255_wctomb, NULL })
+-
+-DEFENCODING(( "CP1256", /* JDK 1.1 */
+- "WINDOWS-1256", /* IANA */
+- "MS-ARAB",
+- ),
+- cp1256,
+- { cp1256_mbtowc, NULL }, { cp1256_wctomb, NULL })
+-
+-DEFENCODING(( "CP1257", /* JDK 1.1 */
+- "WINDOWS-1257", /* IANA */
+- "WINBALTRIM",
+- ),
+- cp1257,
+- { cp1257_mbtowc, NULL }, { cp1257_wctomb, NULL })
+-
+-DEFENCODING(( "CP1258", /* JDK 1.1 */
+- "WINDOWS-1258", /* IANA */
+- ),
+- cp1258,
+- { cp1258_mbtowc, cp1258_flushwc }, { cp1258_wctomb, NULL })
+-
+ /* DOS 8-bit encodings */
+
+ DEFENCODING(( "CP850", /* IANA, JDK 1.1 */
+@@ -458,431 +230,3 @@ DEFENCODING(( "CP850",
+ cp850,
+ { cp850_mbtowc, NULL }, { cp850_wctomb, NULL })
+
+-DEFENCODING(( "CP862", /* IANA, JDK 1.1 */
+- "IBM862", /* IANA */
+- "862", /* IANA */
+- "csPC862LatinHebrew", /* IANA */
+- ),
+- cp862,
+- { cp862_mbtowc, NULL }, { cp862_wctomb, NULL })
+-
+-DEFENCODING(( "CP866", /* IANA, JDK 1.1 */
+- "IBM866", /* IANA */
+- "866", /* IANA */
+- "csIBM866", /* IANA */
+- ),
+- cp866,
+- { cp866_mbtowc, NULL }, { cp866_wctomb, NULL })
+-
+-/* Macintosh 8-bit encodings */
+-
+-DEFENCODING(( "MacRoman", /* JDK 1.1 */
+- /* This is the best table for MACINTOSH. The ones */
+- /* in glibc and FreeBSD-iconv are bad quality. */
+- "MACINTOSH", /* IANA */
+- "MAC", /* IANA */
+- "csMacintosh", /* IANA */
+- /*"CP10000", Windows */
+- ),
+- mac_roman,
+- { mac_roman_mbtowc, NULL }, { mac_roman_wctomb, NULL })
+-
+-DEFENCODING(( "MacCentralEurope", /* JDK 1.1 */
+- /*"CP10029", Windows */
+- ),
+- mac_centraleurope,
+- { mac_centraleurope_mbtowc, NULL }, { mac_centraleurope_wctomb, NULL })
+-
+-DEFENCODING(( "MacIceland", /* JDK 1.1 */
+- /*"CP10079", Windows */
+- ),
+- mac_iceland,
+- { mac_iceland_mbtowc, NULL }, { mac_iceland_wctomb, NULL })
+-
+-DEFENCODING(( "MacCroatian", /* JDK 1.1 */
+- /*"CP10082", Windows */
+- ),
+- mac_croatian,
+- { mac_croatian_mbtowc, NULL }, { mac_croatian_wctomb, NULL })
+-
+-DEFENCODING(( "MacRomania", /* JDK 1.1 */
+- /*"CP10010", Windows */
+- ),
+- mac_romania,
+- { mac_romania_mbtowc, NULL }, { mac_romania_wctomb, NULL })
+-
+-DEFENCODING(( "MacCyrillic", /* JDK 1.1 */
+- /*"CP10007", Windows */
+- ),
+- mac_cyrillic,
+- { mac_cyrillic_mbtowc, NULL }, { mac_cyrillic_wctomb, NULL })
+-
+-DEFENCODING(( "MacUkraine", /* JDK 1.1 */
+- /*"CP10017", Windows */
+- ),
+- mac_ukraine,
+- { mac_ukraine_mbtowc, NULL }, { mac_ukraine_wctomb, NULL })
+-
+-DEFENCODING(( "MacGreek", /* JDK 1.1 */
+- /*"CP10006", Windows */
+- ),
+- mac_greek,
+- { mac_greek_mbtowc, NULL }, { mac_greek_wctomb, NULL })
+-
+-DEFENCODING(( "MacTurkish", /* JDK 1.1 */
+- /*"CP10081", Windows */
+- ),
+- mac_turkish,
+- { mac_turkish_mbtowc, NULL }, { mac_turkish_wctomb, NULL })
+-
+-DEFENCODING(( "MacHebrew", /* JDK 1.1 */
+- /*"CP10005", Windows */
+- ),
+- mac_hebrew,
+- { mac_hebrew_mbtowc, NULL }, { mac_hebrew_wctomb, NULL })
+-
+-DEFENCODING(( "MacArabic", /* JDK 1.1 */
+- /*"CP10004", Windows */
+- ),
+- mac_arabic,
+- { mac_arabic_mbtowc, NULL }, { mac_arabic_wctomb, NULL })
+-
+-DEFENCODING(( "MacThai", /* JDK 1.1 */
+- /*"CP10021", Windows */
+- ),
+- mac_thai,
+- { mac_thai_mbtowc, NULL }, { mac_thai_wctomb, NULL })
+-
+-/* Other platform specific 8-bit encodings */
+-
+-DEFENCODING(( "HP-ROMAN8", /* IANA, X11R6.4 */
+- "ROMAN8", /* IANA */
+- "R8", /* IANA */
+- "csHPRoman8", /* IANA */
+- ),
+- hp_roman8,
+- { hp_roman8_mbtowc, NULL }, { hp_roman8_wctomb, NULL })
+-
+-DEFENCODING(( "NEXTSTEP",
+- ),
+- nextstep,
+- { nextstep_mbtowc, NULL }, { nextstep_wctomb, NULL })
+-
+-/* Regional 8-bit encodings used for a single language */
+-
+-DEFENCODING(( "ARMSCII-8",
+- ),
+- armscii_8,
+- { armscii_8_mbtowc, NULL }, { armscii_8_wctomb, NULL })
+-
+-DEFENCODING(( "GEORGIAN-ACADEMY",
+- ),
+- georgian_academy,
+- { georgian_academy_mbtowc, NULL }, { georgian_academy_wctomb, NULL })
+-
+-DEFENCODING(( "GEORGIAN-PS",
+- ),
+- georgian_ps,
+- { georgian_ps_mbtowc, NULL }, { georgian_ps_wctomb, NULL })
+-
+-DEFENCODING(( "KOI8-T",
+- ),
+- koi8_t,
+- { koi8_t_mbtowc, NULL }, { koi8_t_wctomb, NULL })
+-
+-DEFENCODING(( "PT154", /* IANA, glibc */
+- "PTCP154", /* IANA */
+- "CP154", /* IANA */
+- "CYRILLIC-ASIAN", /* IANA */
+- "csPTCP154", /* IANA */
+- ),
+- pt154,
+- { pt154_mbtowc, NULL }, { pt154_wctomb, NULL })
+-
+-DEFENCODING(( "MULELAO-1",
+- ),
+- mulelao,
+- { mulelao_mbtowc, NULL }, { mulelao_wctomb, NULL })
+-
+-DEFENCODING(( "CP1133",
+- "IBM-CP1133",
+- ),
+- cp1133,
+- { cp1133_mbtowc, NULL }, { cp1133_wctomb, NULL })
+-
+-DEFENCODING(( "TIS-620", /* IANA */
+- "TIS620", /* glibc */
+- "TIS620-0", /* glibc */
+- "TIS620.2529-1", /* glibc */
+- "TIS620.2533-0", /* glibc */
+- "TIS620.2533-1",
+- "ISO-IR-166", /* glibc */
+- ),
+- tis620,
+- { tis620_mbtowc, NULL }, { tis620_wctomb, NULL })
+-
+-DEFENCODING(( "CP874", /* JDK 1.1 */
+- "WINDOWS-874",
+- ),
+- cp874,
+- { cp874_mbtowc, NULL }, { cp874_wctomb, NULL })
+-
+-DEFENCODING(( "VISCII", /* IANA, RFC 1456 */
+- "VISCII1.1-1",
+- "csVISCII", /* IANA */
+- ),
+- viscii,
+- { viscii_mbtowc, NULL }, { viscii_wctomb, NULL })
+-
+-DEFENCODING(( "TCVN",
+- "TCVN-5712",
+- "TCVN5712-1",
+- "TCVN5712-1:1993",
+- ),
+- tcvn,
+- { tcvn_mbtowc, tcvn_flushwc }, { tcvn_wctomb, NULL })
+-
+-/* CJK character sets (not documented) */
+-
+-DEFENCODING(( "JIS_C6220-1969-RO", /* IANA */
+- "ISO646-JP", /* IANA */
+- "ISO-IR-14", /* IANA */
+- "JP", /* IANA */
+- "csISO14JISC6220ro", /* IANA */
+- ),
+- iso646_jp,
+- { iso646_jp_mbtowc, NULL }, { iso646_jp_wctomb, NULL })
+-
+-DEFENCODING(( "JIS_X0201", /* IANA */
+- "JISX0201-1976",
+- "X0201", /* IANA */
+- "csHalfWidthKatakana", /* IANA */
+- /*"JISX0201.1976-0", X11R6.4 */
+- /*"JIS0201", JDK 1.1 */
+- ),
+- jisx0201,
+- { jisx0201_mbtowc, NULL }, { jisx0201_wctomb, NULL })
+-
+-DEFENCODING(( "JIS_X0208",
+- "JIS_X0208-1983", /* IANA */
+- "JIS_X0208-1990",
+- "JIS0208",
+- "X0208", /* IANA */
+- "ISO-IR-87", /* IANA */
+- "JIS_C6226-1983", /* IANA */
+- "csISO87JISX0208", /* IANA */
+- /*"JISX0208.1983-0", X11R6.4 */
+- /*"JISX0208.1990-0", X11R6.4 */
+- /*"JIS0208", JDK 1.1 */
+- ),
+- jisx0208,
+- { jisx0208_mbtowc, NULL }, { jisx0208_wctomb, NULL })
+-
+-DEFENCODING(( "JIS_X0212",
+- "JIS_X0212.1990-0",
+- "JIS_X0212-1990", /* IANA */
+- "X0212", /* IANA */
+- "ISO-IR-159", /* IANA */
+- "csISO159JISX02121990", /* IANA */
+- /*"JISX0212.1990-0", X11R6.4 */
+- /*"JIS0212", JDK 1.1 */
+- ),
+- jisx0212,
+- { jisx0212_mbtowc, NULL }, { jisx0212_wctomb, NULL })
+-
+-DEFENCODING(( "GB_1988-80", /* IANA */
+- "ISO646-CN", /* IANA */
+- "ISO-IR-57", /* IANA */
+- "CN", /* IANA */
+- "csISO57GB1988", /* IANA */
+- ),
+- iso646_cn,
+- { iso646_cn_mbtowc, NULL }, { iso646_cn_wctomb, NULL })
+-
+-DEFENCODING(( "GB_2312-80", /* IANA */
+- "ISO-IR-58", /* IANA */
+- "csISO58GB231280", /* IANA */
+- "CHINESE", /* IANA */
+- /*"GB2312.1980-0", X11R6.4 */
+- ),
+- gb2312,
+- { gb2312_mbtowc, NULL }, { gb2312_wctomb, NULL })
+-
+-DEFENCODING(( "ISO-IR-165",
+- "CN-GB-ISOIR165", /* RFC 1922 */
+- ),
+- isoir165,
+- { isoir165_mbtowc, NULL }, { isoir165_wctomb, NULL })
+-
+-DEFENCODING(( "KSC_5601", /* IANA */
+- "KS_C_5601-1987", /* IANA */
+- "KS_C_5601-1989", /* IANA */
+- "ISO-IR-149", /* IANA */
+- "csKSC56011987", /* IANA */
+- "KOREAN", /* IANA */
+- /*"KSC5601.1987-0", X11R6.4 */
+- /*"KSX1001:1992", Ken Lunde */
+- ),
+- ksc5601,
+- { ksc5601_mbtowc, NULL }, { ksc5601_wctomb, NULL })
+-
+-/* CJK encodings */
+-
+-DEFENCODING(( "EUC-JP", /* IANA */
+- "EUCJP", /* glibc */
+- "Extended_UNIX_Code_Packed_Format_for_Japanese", /* IANA */
+- "csEUCPkdFmtJapanese", /* IANA */
+- /*"EUC_JP", JDK 1.1 */
+- /*"CP51932", Windows */
+- ),
+- euc_jp,
+- { euc_jp_mbtowc, NULL }, { euc_jp_wctomb, NULL })
+-
+-DEFENCODING(( "SHIFT_JIS", /* IANA */
+- "SHIFT-JIS", /* glibc */
+- "SJIS", /* JDK 1.1 */
+- "MS_KANJI", /* IANA */
+- "csShiftJIS", /* IANA */
+- ),
+- sjis,
+- { sjis_mbtowc, NULL }, { sjis_wctomb, NULL })
+-
+-DEFENCODING(( "CP932", /* glibc */
+- ),
+- cp932,
+- { cp932_mbtowc, NULL }, { cp932_wctomb, NULL })
+-
+-DEFENCODING(( "ISO-2022-JP", /* IANA, RFC 1468 */
+- "csISO2022JP", /* IANA */
+- /*"ISO2022JP", JDK 1.1 */
+- ),
+- iso2022_jp,
+- { iso2022_jp_mbtowc, NULL }, { iso2022_jp_wctomb, iso2022_jp_reset })
+-
+-DEFENCODING(( "ISO-2022-JP-1", /* RFC 2237 */
+- ),
+- iso2022_jp1,
+- { iso2022_jp1_mbtowc, NULL }, { iso2022_jp1_wctomb, iso2022_jp1_reset })
+-
+-DEFENCODING(( "ISO-2022-JP-2", /* IANA, RFC 1554 */
+- "csISO2022JP2", /* IANA */
+- ),
+- iso2022_jp2,
+- { iso2022_jp2_mbtowc, NULL }, { iso2022_jp2_wctomb, iso2022_jp2_reset })
+-
+-DEFENCODING(( "EUC-CN", /* glibc */
+- "EUCCN", /* glibc */
+- "GB2312", /* IANA */
+- "CN-GB", /* RFC 1922 */
+- "csGB2312", /* IANA */
+- /*"EUC_CN", JDK 1.1 */
+- /*"CP51936", Windows */
+- ),
+- euc_cn,
+- { euc_cn_mbtowc, NULL }, { euc_cn_wctomb, NULL })
+-
+-DEFENCODING(( "GBK", /* IANA, JDK 1.1 */
+- ),
+- ces_gbk,
+- { ces_gbk_mbtowc, NULL }, { ces_gbk_wctomb, NULL })
+-
+-DEFENCODING(( "CP936", /* IANA */
+- "MS936", /* IANA */
+- "WINDOWS-936", /* IANA */
+- ),
+- cp936,
+- { cp936_mbtowc, NULL }, { cp936_wctomb, NULL })
+-
+-DEFENCODING(( "GB18030", /* IANA, glibc */
+- /*"CP54936", Windows */
+- ),
+- gb18030,
+- { gb18030_mbtowc, NULL }, { gb18030_wctomb, NULL })
+-
+-DEFENCODING(( "ISO-2022-CN", /* IANA, RFC 1922 */
+- "csISO2022CN",
+- /*"ISO2022CN", JDK 1.1 */
+- ),
+- iso2022_cn,
+- { iso2022_cn_mbtowc, NULL }, { iso2022_cn_wctomb, iso2022_cn_reset })
+-
+-DEFENCODING(( "ISO-2022-CN-EXT", /* IANA, RFC 1922 */
+- ),
+- iso2022_cn_ext,
+- { iso2022_cn_ext_mbtowc, NULL }, { iso2022_cn_ext_wctomb, iso2022_cn_ext_reset })
+-
+-DEFENCODING(( "HZ", /* RFC 1843 */
+- "HZ-GB-2312", /* IANA, RFC 1842 */
+- ),
+- hz,
+- { hz_mbtowc, NULL }, { hz_wctomb, hz_reset })
+-
+-DEFENCODING(( "EUC-TW", /* glibc */
+- "EUCTW", /* glibc */
+- "csEUCTW",
+- /*"EUC_TW", JDK 1.1 */
+- /*"CP51950", Windows */
+- ),
+- euc_tw,
+- { euc_tw_mbtowc, NULL }, { euc_tw_wctomb, NULL })
+-
+-DEFENCODING(( "BIG5", /* IANA, JDK 1.1 */
+- "BIG-5", /* glibc */
+- "BIG-FIVE", /* glibc */
+- "BIGFIVE", /* glibc */
+- "CN-BIG5", /* RFC 1922 */
+- "csBig5", /* IANA */
+- ),
+- ces_big5,
+- { ces_big5_mbtowc, NULL }, { ces_big5_wctomb, NULL })
+-
+-DEFENCODING(( "CP950", /* JDK 1.1 */
+- ),
+- cp950,
+- { cp950_mbtowc, NULL }, { cp950_wctomb, NULL })
+-
+-DEFENCODING(( "BIG5-HKSCS:1999",
+- ),
+- big5hkscs1999,
+- { big5hkscs1999_mbtowc, big5hkscs1999_flushwc }, { big5hkscs1999_wctomb, big5hkscs1999_reset })
+-
+-DEFENCODING(( "BIG5-HKSCS:2001",
+- ),
+- big5hkscs2001,
+- { big5hkscs2001_mbtowc, big5hkscs2001_flushwc }, { big5hkscs2001_wctomb, big5hkscs2001_reset })
+-
+-DEFENCODING(( "BIG5-HKSCS", /* IANA */
+- "BIG5HKSCS", /* glibc */
+- "BIG5-HKSCS:2004",
+- ),
+- big5hkscs2004,
+- { big5hkscs2004_mbtowc, big5hkscs2004_flushwc }, { big5hkscs2004_wctomb, big5hkscs2004_reset })
+-
+-DEFENCODING(( "EUC-KR", /* IANA, RFC 1557 */
+- "EUCKR", /* glibc */
+- "csEUCKR", /* IANA */
+- /*"EUC_KR", JDK 1.1 */
+- /*"CP51949", Windows */
+- ),
+- euc_kr,
+- { euc_kr_mbtowc, NULL }, { euc_kr_wctomb, NULL })
+-
+-DEFENCODING(( "CP949", /* JDK 1.1 */
+- "UHC", /* glibc */
+- ),
+- cp949,
+- { cp949_mbtowc, NULL }, { cp949_wctomb, NULL })
+-
+-DEFENCODING(( "JOHAB", /* glibc */
+- "CP1361", /* glibc */
+- ),
+- johab,
+- { johab_mbtowc, NULL }, { johab_wctomb, NULL })
+-
+-DEFENCODING(( "ISO-2022-KR", /* IANA, RFC 1557 */
+- "csISO2022KR", /* IANA */
+- /*"ISO2022KR", JDK 1.1 */
+- ),
+- iso2022_kr,
+- { iso2022_kr_mbtowc, NULL }, { iso2022_kr_wctomb, iso2022_kr_reset })
+-
+--- a/lib/encodings_dos.def
++++ b/lib/encodings_dos.def
+@@ -26,102 +26,3 @@ DEFENCODING(( "CP437",
+ cp437,
+ { cp437_mbtowc, NULL }, { cp437_wctomb, NULL })
+
+-DEFENCODING(( "CP737", /* JDK 1.1 */
+- ),
+- cp737,
+- { cp737_mbtowc, NULL }, { cp737_wctomb, NULL })
+-
+-DEFENCODING(( "CP775", /* IANA, JDK 1.1 */
+- "IBM775", /* IANA */
+- "csPC775Baltic", /* IANA */
+- ),
+- cp775,
+- { cp775_mbtowc, NULL }, { cp775_wctomb, NULL })
+-
+-DEFENCODING(( "CP852", /* IANA, JDK 1.1 */
+- "IBM852", /* IANA */
+- "852", /* IANA */
+- "csPCp852", /* IANA */
+- ),
+- cp852,
+- { cp852_mbtowc, NULL }, { cp852_wctomb, NULL })
+-
+-DEFENCODING(( "CP853",
+- ),
+- cp853,
+- { cp853_mbtowc, NULL }, { cp853_wctomb, NULL })
+-
+-DEFENCODING(( "CP855", /* IANA, JDK 1.1 */
+- "IBM855", /* IANA */
+- "855", /* IANA */
+- "csIBM855", /* IANA */
+- ),
+- cp855,
+- { cp855_mbtowc, NULL }, { cp855_wctomb, NULL })
+-
+-DEFENCODING(( "CP857", /* IANA, JDK 1.1 */
+- "IBM857", /* IANA */
+- "857", /* IANA */
+- "csIBM857", /* IANA */
+- ),
+- cp857,
+- { cp857_mbtowc, NULL }, { cp857_wctomb, NULL })
+-
+-DEFENCODING(( "CP858", /* JDK 1.1.7 */
+- ),
+- cp858,
+- { cp858_mbtowc, NULL }, { cp858_wctomb, NULL })
+-
+-DEFENCODING(( "CP860", /* IANA, JDK 1.1 */
+- "IBM860", /* IANA */
+- "860", /* IANA */
+- "csIBM860", /* IANA */
+- ),
+- cp860,
+- { cp860_mbtowc, NULL }, { cp860_wctomb, NULL })
+-
+-DEFENCODING(( "CP861", /* IANA, JDK 1.1 */
+- "IBM861", /* IANA */
+- "861", /* IANA */
+- "CP-IS", /* IANA */
+- "csIBM861", /* IANA */
+- ),
+- cp861,
+- { cp861_mbtowc, NULL }, { cp861_wctomb, NULL })
+-
+-DEFENCODING(( "CP863", /* IANA, JDK 1.1 */
+- "IBM863", /* IANA */
+- "863", /* IANA */
+- "csIBM863", /* IANA */
+- ),
+- cp863,
+- { cp863_mbtowc, NULL }, { cp863_wctomb, NULL })
+-
+-DEFENCODING(( "CP864", /* IANA, JDK 1.1 */
+- "IBM864", /* IANA */
+- "csIBM864", /* IANA */
+- ),
+- cp864,
+- { cp864_mbtowc, NULL }, { cp864_wctomb, NULL })
+-
+-DEFENCODING(( "CP865", /* IANA, JDK 1.1 */
+- "IBM865", /* IANA */
+- "865", /* IANA */
+- "csIBM865", /* IANA */
+- ),
+- cp865,
+- { cp865_mbtowc, NULL }, { cp865_wctomb, NULL })
+-
+-DEFENCODING(( "CP869", /* IANA, JDK 1.1 */
+- "IBM869", /* IANA */
+- "869", /* IANA */
+- "CP-GR", /* IANA */
+- "csIBM869", /* IANA */
+- ),
+- cp869,
+- { cp869_mbtowc, NULL }, { cp869_wctomb, NULL })
+-
+-DEFENCODING(( "CP1125", /* ICU */
+- ),
+- cp1125,
+- { cp1125_mbtowc, NULL }, { cp1125_wctomb, NULL })
+--- a/lib/loop_unicode.h
++++ b/lib/loop_unicode.h
+@@ -24,14 +24,15 @@
+ static int unicode_transliterate (conv_t cd, ucs4_t wc,
+ unsigned char* outptr, size_t outleft)
+ {
++/*
+ if (cd->oflags & HAVE_HANGUL_JAMO) {
+- /* Decompose Hangul into Jamo. Use double-width Jamo (contained
++ /-* Decompose Hangul into Jamo. Use double-width Jamo (contained
+ in all Korean encodings and ISO-2022-JP-2), not half-width Jamo
+- (contained in Unicode only). */
++ (contained in Unicode only). *-/
+ ucs4_t buf[3];
+ int ret = johab_hangul_decompose(cd,buf,wc);
+ if (ret != RET_ILUNI) {
+- /* we know 1 <= ret <= 3 */
++ /-* we know 1 <= ret <= 3 *-/
+ state_t backup_state = cd->ostate;
+ unsigned char* backup_outptr = outptr;
+ size_t backup_outleft = outleft;
+@@ -57,9 +58,9 @@ static int unicode_transliterate (conv_t
+ }
+ }
+ {
+- /* Try to use a variant, but postfix it with
++ /-* Try to use a variant, but postfix it with
+ U+303E IDEOGRAPHIC VARIATION INDICATOR
+- (cf. Ken Lunde's "CJKV information processing", p. 188). */
++ (cf. Ken Lunde's "CJKV information processing", p. 188). *-/
+ int indx = -1;
+ if (wc == 0x3006)
+ indx = 0;
+@@ -105,20 +106,20 @@ static int unicode_transliterate (conv_t
+ }
+ }
+ if (wc >= 0x2018 && wc <= 0x201a) {
+- /* Special case for quotation marks 0x2018, 0x2019, 0x201a */
++ /-* Special case for quotation marks 0x2018, 0x2019, 0x201a *-/
+ ucs4_t substitute =
+ (cd->oflags & HAVE_QUOTATION_MARKS
+ ? (wc == 0x201a ? 0x2018 : wc)
+ : (cd->oflags & HAVE_ACCENTS
+- ? (wc==0x2019 ? 0x00b4 : 0x0060) /* use accents */
+- : 0x0027 /* use apostrophe */
++ ? (wc==0x2019 ? 0x00b4 : 0x0060) /-* use accents *-/
++ : 0x0027 /-* use apostrophe *-/
+ ) );
+ int outcount = cd->ofuncs.xxx_wctomb(cd,outptr,substitute,outleft);
+ if (outcount != RET_ILUNI)
+ return outcount;
+ }
+ {
+- /* Use the transliteration table. */
++ /-* Use the transliteration table. *-/
+ int indx = translit_index(wc);
+ if (indx >= 0) {
+ const unsigned int * cp = &translit_data[indx];
+@@ -135,7 +136,7 @@ static int unicode_transliterate (conv_t
+ }
+ sub_outcount = cd->ofuncs.xxx_wctomb(cd,outptr,cp[i],outleft);
+ if (sub_outcount == RET_ILUNI)
+- /* Recursive transliteration. */
++ /-* Recursive transliteration. *-/
+ sub_outcount = unicode_transliterate(cd,cp[i],outptr,outleft);
+ if (sub_outcount <= RET_ILUNI)
+ goto translit_failed;
+@@ -151,6 +152,7 @@ static int unicode_transliterate (conv_t
+ return RET_TOOSMALL;
+ }
+ }
++*/
+ return RET_ILUNI;
+ }
+
diff --git a/package/libs/libiconv-full/patches/.svn/text-base/101-autotools.patch.svn-base b/package/libs/libiconv-full/patches/.svn/text-base/101-autotools.patch.svn-base
new file mode 100644
index 0000000..f8fdce5
--- /dev/null
+++ b/package/libs/libiconv-full/patches/.svn/text-base/101-autotools.patch.svn-base
@@ -0,0 +1,26014 @@
+--- a/libcharset/configure.ac
++++ b/libcharset/configure.ac
+@@ -16,17 +16,17 @@ dnl along with the GNU CHARSET Library;
+ dnl write to the Free Software Foundation, Inc., 51 Franklin Street,
+ dnl Fifth Floor, Boston, MA 02110-1301, USA.
+
+-AC_PREREQ(2.13)
++AC_PREREQ(2.61)
++AC_INIT([libcharset],[1.4] )
++AC_CONFIG_SRCDIR([lib/localcharset.c])
+
+-PACKAGE=libcharset
+-VERSION=1.4
+-
+-AC_INIT(lib/localcharset.c)
+ AC_CONFIG_AUX_DIR(build-aux)
+ AC_CONFIG_HEADER(config.h)
+ AC_PROG_MAKE_SET
+-AC_SUBST(PACKAGE)
+-AC_SUBST(VERSION)
++dnl AC_SUBST(PACKAGE)
++dnl AC_SUBST(VERSION)
++
++AC_CONFIG_MACRO_DIR([m4])
+
+ dnl checks for basic programs
+
+--- a/configure.ac
++++ b/configure.ac
+@@ -24,6 +24,8 @@ AM_INIT_AUTOMAKE(libiconv, 1.11)
+ AC_CONFIG_HEADERS(config.h lib/config.h)
+ AC_PROG_MAKE_SET
+
++AC_CONFIG_MACRO_DIR([m4])
++
+ dnl checks for basic programs
+
+ AC_PROG_CC
+--- a/libcharset/m4/libtool.m4
++++ b/libcharset/m4/libtool.m4
+@@ -1,107 +1,186 @@
+ # libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-
+-## Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006
+-## Free Software Foundation, Inc.
+-## Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
+-##
+-## This file is free software; the Free Software Foundation gives
+-## unlimited permission to copy and/or distribute it, with or without
+-## modifications, as long as this notice is preserved.
+-
+-# serial 48 AC_PROG_LIBTOOL
+-
+-
+-# AC_PROVIDE_IFELSE(MACRO-NAME, IF-PROVIDED, IF-NOT-PROVIDED)
+-# -----------------------------------------------------------
+-# If this macro is not defined by Autoconf, define it here.
+-m4_ifdef([AC_PROVIDE_IFELSE],
+- [],
+- [m4_define([AC_PROVIDE_IFELSE],
+- [m4_ifdef([AC_PROVIDE_$1],
+- [$2], [$3])])])
++#
++# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
++# 2006, 2007, 2008 Free Software Foundation, Inc.
++# Written by Gordon Matzigkeit, 1996
++#
++# This file is free software; the Free Software Foundation gives
++# unlimited permission to copy and/or distribute it, with or without
++# modifications, as long as this notice is preserved.
++
++m4_define([_LT_COPYING], [dnl
++# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
++# 2006, 2007, 2008 Free Software Foundation, Inc.
++# Written by Gordon Matzigkeit, 1996
++#
++# This file is part of GNU Libtool.
++#
++# GNU Libtool 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.
++#
++# As a special exception to the GNU General Public License,
++# if you distribute this file as part of a program or library that
++# is built using GNU Libtool, you may include this file under the
++# same distribution terms that you use for the rest of that program.
++#
++# GNU Libtool 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 GNU Libtool; see the file COPYING. If not, a copy
++# can be downloaded from http://www.gnu.org/licenses/gpl.html, or
++# obtained by writing to the Free Software Foundation, Inc.,
++# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
++])
+
++# serial 56 LT_INIT
+
+-# AC_PROG_LIBTOOL
+-# ---------------
+-AC_DEFUN([AC_PROG_LIBTOOL],
+-[AC_REQUIRE([_AC_PROG_LIBTOOL])dnl
+-dnl If AC_PROG_CXX has already been expanded, run AC_LIBTOOL_CXX
+-dnl immediately, otherwise, hook it in at the end of AC_PROG_CXX.
+- AC_PROVIDE_IFELSE([AC_PROG_CXX],
+- [AC_LIBTOOL_CXX],
+- [define([AC_PROG_CXX], defn([AC_PROG_CXX])[AC_LIBTOOL_CXX
+- ])])
+-dnl And a similar setup for Fortran 77 support
+- AC_PROVIDE_IFELSE([AC_PROG_F77],
+- [AC_LIBTOOL_F77],
+- [define([AC_PROG_F77], defn([AC_PROG_F77])[AC_LIBTOOL_F77
+-])])
+-
+-dnl Quote A][M_PROG_GCJ so that aclocal doesn't bring it in needlessly.
+-dnl If either AC_PROG_GCJ or A][M_PROG_GCJ have already been expanded, run
+-dnl AC_LIBTOOL_GCJ immediately, otherwise, hook it in at the end of both.
+- AC_PROVIDE_IFELSE([AC_PROG_GCJ],
+- [AC_LIBTOOL_GCJ],
+- [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],
+- [AC_LIBTOOL_GCJ],
+- [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ],
+- [AC_LIBTOOL_GCJ],
+- [ifdef([AC_PROG_GCJ],
+- [define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[AC_LIBTOOL_GCJ])])
+- ifdef([A][M_PROG_GCJ],
+- [define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[AC_LIBTOOL_GCJ])])
+- ifdef([LT_AC_PROG_GCJ],
+- [define([LT_AC_PROG_GCJ],
+- defn([LT_AC_PROG_GCJ])[AC_LIBTOOL_GCJ])])])])
+-])])# AC_PROG_LIBTOOL
+
++# LT_PREREQ(VERSION)
++# ------------------
++# Complain and exit if this libtool version is less that VERSION.
++m4_defun([LT_PREREQ],
++[m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1,
++ [m4_default([$3],
++ [m4_fatal([Libtool version $1 or higher is required],
++ 63)])],
++ [$2])])
+
+-# _AC_PROG_LIBTOOL
+-# ----------------
+-AC_DEFUN([_AC_PROG_LIBTOOL],
+-[AC_REQUIRE([AC_LIBTOOL_SETUP])dnl
+-AC_BEFORE([$0],[AC_LIBTOOL_CXX])dnl
+-AC_BEFORE([$0],[AC_LIBTOOL_F77])dnl
+-AC_BEFORE([$0],[AC_LIBTOOL_GCJ])dnl
++
++# _LT_CHECK_BUILDDIR
++# ------------------
++# Complain if the absolute build directory name contains unusual characters
++m4_defun([_LT_CHECK_BUILDDIR],
++[case `pwd` in
++ *\ * | *\ *)
++ AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;;
++esac
++])
++
++
++# LT_INIT([OPTIONS])
++# ------------------
++AC_DEFUN([LT_INIT],
++[AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT
++AC_BEFORE([$0], [LT_LANG])dnl
++AC_BEFORE([$0], [LT_OUTPUT])dnl
++AC_BEFORE([$0], [LTDL_INIT])dnl
++m4_require([_LT_CHECK_BUILDDIR])dnl
++
++dnl Autoconf doesn't catch unexpanded LT_ macros by default:
++m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl
++m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl
++dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4
++dnl unless we require an AC_DEFUNed macro:
++AC_REQUIRE([LTOPTIONS_VERSION])dnl
++AC_REQUIRE([LTSUGAR_VERSION])dnl
++AC_REQUIRE([LTVERSION_VERSION])dnl
++AC_REQUIRE([LTOBSOLETE_VERSION])dnl
++m4_require([_LT_PROG_LTMAIN])dnl
++
++dnl Parse OPTIONS
++_LT_SET_OPTIONS([$0], [$1])
+
+ # This can be used to rebuild libtool when needed
+-LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh"
++LIBTOOL_DEPS="$ltmain"
+
+ # Always use our own libtool.
+-LIBTOOL='$(SHELL) $(top_builddir)/libtool'
++LIBTOOL='$(SHELL) $(top_builddir)'
++LIBTOOL="$LIBTOOL/$host_alias-libtool"
+ AC_SUBST(LIBTOOL)dnl
+
+-# Prevent multiple expansion
+-define([AC_PROG_LIBTOOL], [])
+-])# _AC_PROG_LIBTOOL
++_LT_SETUP
+
++# Only expand once:
++m4_define([LT_INIT])
++])# LT_INIT
++
++# Old names:
++AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT])
++AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT])
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([AC_PROG_LIBTOOL], [])
++dnl AC_DEFUN([AM_PROG_LIBTOOL], [])
+
+-# AC_LIBTOOL_SETUP
+-# ----------------
+-AC_DEFUN([AC_LIBTOOL_SETUP],
+-[AC_PREREQ(2.50)dnl
+-AC_REQUIRE([AC_ENABLE_SHARED])dnl
+-AC_REQUIRE([AC_ENABLE_STATIC])dnl
+-AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl
+-AC_REQUIRE([AC_CANONICAL_HOST])dnl
++
++# _LT_CC_BASENAME(CC)
++# -------------------
++# Calculate cc_basename. Skip known compiler wrappers and cross-prefix.
++m4_defun([_LT_CC_BASENAME],
++[for cc_temp in $1""; do
++ case $cc_temp in
++ compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;;
++ distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;;
++ \-*) ;;
++ *) break;;
++ esac
++done
++cc_basename=`$ECHO "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
++])
++
++
++# _LT_FILEUTILS_DEFAULTS
++# ----------------------
++# It is okay to use these file commands and assume they have been set
++# sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'.
++m4_defun([_LT_FILEUTILS_DEFAULTS],
++[: ${CP="cp -f"}
++: ${MV="mv -f"}
++: ${RM="rm -f"}
++])# _LT_FILEUTILS_DEFAULTS
++
++
++# _LT_SETUP
++# ---------
++m4_defun([_LT_SETUP],
++[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+ AC_REQUIRE([AC_CANONICAL_BUILD])dnl
++_LT_DECL([], [host_alias], [0], [The host system])dnl
++_LT_DECL([], [host], [0])dnl
++_LT_DECL([], [host_os], [0])dnl
++dnl
++_LT_DECL([], [build_alias], [0], [The build system])dnl
++_LT_DECL([], [build], [0])dnl
++_LT_DECL([], [build_os], [0])dnl
++dnl
+ AC_REQUIRE([AC_PROG_CC])dnl
+-AC_REQUIRE([AC_PROG_LD])dnl
+-AC_REQUIRE([AC_PROG_LD_RELOAD_FLAG])dnl
+-AC_REQUIRE([AC_PROG_NM])dnl
+-
++AC_REQUIRE([LT_PATH_LD])dnl
++AC_REQUIRE([LT_PATH_NM])dnl
++dnl
+ AC_REQUIRE([AC_PROG_LN_S])dnl
+-AC_REQUIRE([AC_DEPLIBS_CHECK_METHOD])dnl
+-# Autoconf 2.13's AC_OBJEXT and AC_EXEEXT macros only works for C compilers!
+-AC_REQUIRE([AC_OBJEXT])dnl
+-AC_REQUIRE([AC_EXEEXT])dnl
++test -z "$LN_S" && LN_S="ln -s"
++_LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl
+ dnl
++AC_REQUIRE([LT_CMD_MAX_LEN])dnl
++_LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl
++_LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl
++dnl
++m4_require([_LT_FILEUTILS_DEFAULTS])dnl
++m4_require([_LT_CHECK_SHELL_FEATURES])dnl
++m4_require([_LT_CMD_RELOAD])dnl
++m4_require([_LT_CHECK_MAGIC_METHOD])dnl
++m4_require([_LT_CMD_OLD_ARCHIVE])dnl
++m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl
++
++_LT_CONFIG_LIBTOOL_INIT([
++# See if we are running on zsh, and set the options which allow our
++# commands through without removal of \ escapes INIT.
++if test -n "\${ZSH_VERSION+set}" ; then
++ setopt NO_GLOB_SUBST
++fi
++])
++if test -n "${ZSH_VERSION+set}" ; then
++ setopt NO_GLOB_SUBST
++fi
+
+-AC_LIBTOOL_SYS_MAX_CMD_LEN
+-AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE
+-AC_LIBTOOL_OBJDIR
++_LT_CHECK_OBJDIR
+
+-AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl
+-_LT_AC_PROG_ECHO_BACKSLASH
++m4_require([_LT_TAG_COMPILER])dnl
++_LT_PROG_ECHO_BACKSLASH
+
+ case $host_os in
+ aix3*)
+@@ -117,6307 +196,6803 @@ esac
+
+ # Sed substitution that helps us do robust quoting. It backslashifies
+ # metacharacters that are still active within double-quoted strings.
+-Xsed='sed -e 1s/^X//'
+-[sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g']
++sed_quote_subst='s/\([["`$\\]]\)/\\\1/g'
+
+ # Same as above, but do not quote variable references.
+-[double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g']
++double_quote_subst='s/\([["`\\]]\)/\\\1/g'
+
+ # Sed substitution to delay expansion of an escaped shell variable in a
+ # double_quote_subst'ed string.
+ delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
+
++# Sed substitution to delay expansion of an escaped single quote.
++delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g'
++
+ # Sed substitution to avoid accidental globbing in evaled expressions
+ no_glob_subst='s/\*/\\\*/g'
+
+-# Constants:
+-rm="rm -f"
+-
+ # Global variables:
+-default_ofile=libtool
++ofile=${host_alias}-libtool
+ can_build_shared=yes
+
+ # All known linkers require a `.a' archive for static linking (except MSVC,
+ # which needs '.lib').
+ libext=a
+-ltmain="$ac_aux_dir/ltmain.sh"
+-ofile="$default_ofile"
+-with_gnu_ld="$lt_cv_prog_gnu_ld"
+
+-AC_CHECK_TOOL(AR, ar, false)
+-AC_CHECK_TOOL(RANLIB, ranlib, :)
+-AC_CHECK_TOOL(STRIP, strip, :)
++with_gnu_ld="$lt_cv_prog_gnu_ld"
+
+ old_CC="$CC"
+ old_CFLAGS="$CFLAGS"
+
+ # Set sane defaults for various variables
+-test -z "$AR" && AR=ar
+-test -z "$AR_FLAGS" && AR_FLAGS=cru
+-test -z "$AS" && AS=as
+ test -z "$CC" && CC=cc
+ test -z "$LTCC" && LTCC=$CC
+ test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
+-test -z "$DLLTOOL" && DLLTOOL=dlltool
+ test -z "$LD" && LD=ld
+-test -z "$LN_S" && LN_S="ln -s"
+-test -z "$MAGIC_CMD" && MAGIC_CMD=file
+-test -z "$NM" && NM=nm
+-test -z "$SED" && SED=sed
+-test -z "$OBJDUMP" && OBJDUMP=objdump
+-test -z "$RANLIB" && RANLIB=:
+-test -z "$STRIP" && STRIP=:
+ test -z "$ac_objext" && ac_objext=o
+
+-# Determine commands to create old-style static archives.
+-old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs'
+-old_postinstall_cmds='chmod 644 $oldlib'
+-old_postuninstall_cmds=
+-
+-if test -n "$RANLIB"; then
+- case $host_os in
+- openbsd*)
+- old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib"
+- ;;
+- *)
+- old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib"
+- ;;
+- esac
+- old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
+-fi
+-
+ _LT_CC_BASENAME([$compiler])
+
+ # Only perform the check for file, if the check method requires it
++test -z "$MAGIC_CMD" && MAGIC_CMD=file
+ case $deplibs_check_method in
+ file_magic*)
+ if test "$file_magic_cmd" = '$MAGIC_CMD'; then
+- AC_PATH_MAGIC
++ _LT_PATH_MAGIC
+ fi
+ ;;
+ esac
+
+-AC_PROVIDE_IFELSE([AC_LIBTOOL_DLOPEN], enable_dlopen=yes, enable_dlopen=no)
+-AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL],
+-enable_win32_dll=yes, enable_win32_dll=no)
+-
+-AC_ARG_ENABLE([libtool-lock],
+- [AC_HELP_STRING([--disable-libtool-lock],
+- [avoid locking (might break parallel builds)])])
+-test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
++# Use C for the default configuration in the libtool script
++LT_SUPPORTED_TAG([CC])
++_LT_LANG_C_CONFIG
++_LT_LANG_DEFAULT_CONFIG
++_LT_CONFIG_COMMANDS
++])# _LT_SETUP
+
+-AC_ARG_WITH([pic],
+- [AC_HELP_STRING([--with-pic],
+- [try to use only PIC/non-PIC objects @<:@default=use both@:>@])],
+- [pic_mode="$withval"],
+- [pic_mode=default])
+-test -z "$pic_mode" && pic_mode=default
+
+-# Use C for the default configuration in the libtool script
+-tagname=
+-AC_LIBTOOL_LANG_C_CONFIG
+-_LT_AC_TAGCONFIG
+-])# AC_LIBTOOL_SETUP
++# _LT_PROG_LTMAIN
++# ---------------
++# Note that this code is called both from `configure', and `config.status'
++# now that we use AC_CONFIG_COMMANDS to generate libtool. Notably,
++# `config.status' has no value for ac_aux_dir unless we are using Automake,
++# so we pass a copy along to make sure it has a sensible value anyway.
++m4_defun([_LT_PROG_LTMAIN],
++[m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl
++_LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir'])
++ltmain="$ac_aux_dir/ltmain.sh"
++])# _LT_PROG_LTMAIN
+
+
+-# _LT_AC_SYS_COMPILER
+-# -------------------
+-AC_DEFUN([_LT_AC_SYS_COMPILER],
+-[AC_REQUIRE([AC_PROG_CC])dnl
++## ------------------------------------- ##
++## Accumulate code for creating libtool. ##
++## ------------------------------------- ##
++
++# So that we can recreate a full libtool script including additional
++# tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS
++# in macros and then make a single call at the end using the `libtool'
++# label.
++
++
++# _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS])
++# ----------------------------------------
++# Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later.
++m4_define([_LT_CONFIG_LIBTOOL_INIT],
++[m4_ifval([$1],
++ [m4_append([_LT_OUTPUT_LIBTOOL_INIT],
++ [$1
++])])])
++
++# Initialize.
++m4_define([_LT_OUTPUT_LIBTOOL_INIT])
++
++
++# _LT_CONFIG_LIBTOOL([COMMANDS])
++# ------------------------------
++# Register COMMANDS to be passed to AC_CONFIG_COMMANDS later.
++m4_define([_LT_CONFIG_LIBTOOL],
++[m4_ifval([$1],
++ [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS],
++ [$1
++])])])
++
++# Initialize.
++m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS])
++
++
++# _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS])
++# -----------------------------------------------------
++m4_defun([_LT_CONFIG_SAVE_COMMANDS],
++[_LT_CONFIG_LIBTOOL([$1])
++_LT_CONFIG_LIBTOOL_INIT([$2])
++])
+
+-# If no C compiler was specified, use CC.
+-LTCC=${LTCC-"$CC"}
+
+-# If no C compiler flags were specified, use CFLAGS.
+-LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
++# _LT_FORMAT_COMMENT([COMMENT])
++# -----------------------------
++# Add leading comment marks to the start of each line, and a trailing
++# full-stop to the whole comment if one is not present already.
++m4_define([_LT_FORMAT_COMMENT],
++[m4_ifval([$1], [
++m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])],
++ [['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.])
++)])
+
+-# Allow CC to be a program name with arguments.
+-compiler=$CC
+-])# _LT_AC_SYS_COMPILER
+
+
+-# _LT_CC_BASENAME(CC)
+-# -------------------
+-# Calculate cc_basename. Skip known compiler wrappers and cross-prefix.
+-AC_DEFUN([_LT_CC_BASENAME],
+-[for cc_temp in $1""; do
+- case $cc_temp in
+- compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;;
+- distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;;
+- \-*) ;;
+- *) break;;
+- esac
+-done
+-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
++## ------------------------ ##
++## FIXME: Eliminate VARNAME ##
++## ------------------------ ##
++
++
++# _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?])
++# -------------------------------------------------------------------
++# CONFIGNAME is the name given to the value in the libtool script.
++# VARNAME is the (base) name used in the configure script.
++# VALUE may be 0, 1 or 2 for a computed quote escaped value based on
++# VARNAME. Any other value will be used directly.
++m4_define([_LT_DECL],
++[lt_if_append_uniq([lt_decl_varnames], [$2], [, ],
++ [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name],
++ [m4_ifval([$1], [$1], [$2])])
++ lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3])
++ m4_ifval([$4],
++ [lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])])
++ lt_dict_add_subkey([lt_decl_dict], [$2],
++ [tagged?], [m4_ifval([$5], [yes], [no])])])
+ ])
+
+
+-# _LT_COMPILER_BOILERPLATE
+-# ------------------------
+-# Check for compiler boilerplate output or warnings with
+-# the simple compiler test code.
+-AC_DEFUN([_LT_COMPILER_BOILERPLATE],
+-[ac_outfile=conftest.$ac_objext
+-printf "$lt_simple_compile_test_code" >conftest.$ac_ext
+-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+-_lt_compiler_boilerplate=`cat conftest.err`
+-$rm conftest*
+-])# _LT_COMPILER_BOILERPLATE
+-
++# _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION])
++# --------------------------------------------------------
++m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])])
++
++
++# lt_decl_tag_varnames([SEPARATOR], [VARNAME1...])
++# ------------------------------------------------
++m4_define([lt_decl_tag_varnames],
++[_lt_decl_filter([tagged?], [yes], $@)])
++
++
++# _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..])
++# ---------------------------------------------------------
++m4_define([_lt_decl_filter],
++[m4_case([$#],
++ [0], [m4_fatal([$0: too few arguments: $#])],
++ [1], [m4_fatal([$0: too few arguments: $#: $1])],
++ [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)],
++ [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)],
++ [lt_dict_filter([lt_decl_dict], $@)])[]dnl
++])
+
+-# _LT_LINKER_BOILERPLATE
+-# ----------------------
+-# Check for linker boilerplate output or warnings with
+-# the simple link test code.
+-AC_DEFUN([_LT_LINKER_BOILERPLATE],
+-[ac_outfile=conftest.$ac_objext
+-printf "$lt_simple_link_test_code" >conftest.$ac_ext
+-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+-_lt_linker_boilerplate=`cat conftest.err`
+-$rm conftest*
+-])# _LT_LINKER_BOILERPLATE
+
++# lt_decl_quote_varnames([SEPARATOR], [VARNAME1...])
++# --------------------------------------------------
++m4_define([lt_decl_quote_varnames],
++[_lt_decl_filter([value], [1], $@)])
++
++
++# lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...])
++# ---------------------------------------------------
++m4_define([lt_decl_dquote_varnames],
++[_lt_decl_filter([value], [2], $@)])
++
++
++# lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...])
++# ---------------------------------------------------
++m4_define([lt_decl_varnames_tagged],
++[_$0(m4_quote(m4_default([$1], [[, ]])),
++ m4_quote(m4_if([$2], [],
++ m4_quote(lt_decl_tag_varnames),
++ m4_quote(m4_shift($@)))),
++ m4_split(m4_normalize(m4_quote(_LT_TAGS))))])
++m4_define([_lt_decl_varnames_tagged], [lt_combine([$1], [$2], [_], $3)])
++
++
++# lt_decl_all_varnames([SEPARATOR], [VARNAME1...])
++# ------------------------------------------------
++m4_define([lt_decl_all_varnames],
++[_$0(m4_quote(m4_default([$1], [[, ]])),
++ m4_if([$2], [],
++ m4_quote(lt_decl_varnames),
++ m4_quote(m4_shift($@))))[]dnl
++])
++m4_define([_lt_decl_all_varnames],
++[lt_join($@, lt_decl_varnames_tagged([$1],
++ lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl
++])
+
+-# _LT_AC_SYS_LIBPATH_AIX
+-# ----------------------
+-# Links a minimal program and checks the executable
+-# for the system default hardcoded library path. In most cases,
+-# this is /usr/lib:/lib, but when the MPI compilers are used
+-# the location of the communication and MPI libs are included too.
+-# If we don't find anything, use the default library path according
+-# to the aix ld manual.
+-AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX],
+-[AC_LINK_IFELSE(AC_LANG_PROGRAM,[
+-aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
+-}'`
+-# Check for a 64-bit object if we didn't find anything.
+-if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
+-}'`; fi],[])
+-if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+-])# _LT_AC_SYS_LIBPATH_AIX
+
++# _LT_CONFIG_STATUS_DECLARE([VARNAME])
++# ------------------------------------
++# Quote a variable value, and forward it to `config.status' so that its
++# declaration there will have the same value as in `configure'. VARNAME
++# must have a single quote delimited value for this to work.
++m4_define([_LT_CONFIG_STATUS_DECLARE],
++[$1='`$ECHO "X$][$1" | $Xsed -e "$delay_single_quote_subst"`'])
+
+-# _LT_AC_SHELL_INIT(ARG)
+-# ----------------------
+-AC_DEFUN([_LT_AC_SHELL_INIT],
+-[ifdef([AC_DIVERSION_NOTICE],
+- [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)],
+- [AC_DIVERT_PUSH(NOTICE)])
+-$1
+-AC_DIVERT_POP
+-])# _LT_AC_SHELL_INIT
+
++# _LT_CONFIG_STATUS_DECLARATIONS
++# ------------------------------
++# We delimit libtool config variables with single quotes, so when
++# we write them to config.status, we have to be sure to quote all
++# embedded single quotes properly. In configure, this macro expands
++# each variable declared with _LT_DECL (and _LT_TAGDECL) into:
++#
++# <var>='`$ECHO "X$<var>" | $Xsed -e "$delay_single_quote_subst"`'
++m4_defun([_LT_CONFIG_STATUS_DECLARATIONS],
++[m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames),
++ [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])])
+
+-# _LT_AC_PROG_ECHO_BACKSLASH
+-# --------------------------
+-# Add some code to the start of the generated configure script which
+-# will find an echo command which doesn't interpret backslashes.
+-AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH],
+-[_LT_AC_SHELL_INIT([
+-# Check that we are running under the correct shell.
+-SHELL=${CONFIG_SHELL-/bin/sh}
+
+-case X$ECHO in
+-X*--fallback-echo)
+- # Remove one level of quotation (which was required for Make).
+- ECHO=`echo "$ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','`
+- ;;
+-esac
++# _LT_LIBTOOL_TAGS
++# ----------------
++# Output comment and list of tags supported by the script
++m4_defun([_LT_LIBTOOL_TAGS],
++[_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl
++available_tags="_LT_TAGS"dnl
++])
+
+-echo=${ECHO-echo}
+-if test "X[$]1" = X--no-reexec; then
+- # Discard the --no-reexec flag, and continue.
+- shift
+-elif test "X[$]1" = X--fallback-echo; then
+- # Avoid inline document here, it may be left over
+- :
+-elif test "X`($echo '\t') 2>/dev/null`" = 'X\t' ; then
+- # Yippee, $echo works!
+- :
+-else
+- # Restart under the correct shell.
+- exec $SHELL "[$]0" --no-reexec ${1+"[$]@"}
+-fi
+
+-if test "X[$]1" = X--fallback-echo; then
+- # used as fallback echo
+- shift
+- cat <<EOF
+-[$]*
+-EOF
+- exit 0
+-fi
++# _LT_LIBTOOL_DECLARE(VARNAME, [TAG])
++# -----------------------------------
++# Extract the dictionary values for VARNAME (optionally with TAG) and
++# expand to a commented shell variable setting:
++#
++# # Some comment about what VAR is for.
++# visible_name=$lt_internal_name
++m4_define([_LT_LIBTOOL_DECLARE],
++[_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1],
++ [description])))[]dnl
++m4_pushdef([_libtool_name],
++ m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl
++m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])),
++ [0], [_libtool_name=[$]$1],
++ [1], [_libtool_name=$lt_[]$1],
++ [2], [_libtool_name=$lt_[]$1],
++ [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl
++m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl
++])
+
+-# The HP-UX ksh and POSIX shell print the target directory to stdout
+-# if CDPATH is set.
+-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+-if test -z "$ECHO"; then
+-if test "X${echo_test_string+set}" != Xset; then
+-# find a string as large as possible, as long as the shell can cope with it
+- for cmd in 'sed 50q "[$]0"' 'sed 20q "[$]0"' 'sed 10q "[$]0"' 'sed 2q "[$]0"' 'echo test'; do
+- # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ...
+- if (echo_test_string=`eval $cmd`) 2>/dev/null &&
+- echo_test_string=`eval $cmd` &&
+- (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null
+- then
+- break
+- fi
+- done
+-fi
++# _LT_LIBTOOL_CONFIG_VARS
++# -----------------------
++# Produce commented declarations of non-tagged libtool config variables
++# suitable for insertion in the LIBTOOL CONFIG section of the `libtool'
++# script. Tagged libtool config variables (even for the LIBTOOL CONFIG
++# section) are produced by _LT_LIBTOOL_TAG_VARS.
++m4_defun([_LT_LIBTOOL_CONFIG_VARS],
++[m4_foreach([_lt_var],
++ m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)),
++ [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])])
+
+-if test "X`($echo '\t') 2>/dev/null`" = 'X\t' &&
+- echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` &&
+- test "X$echo_testing_string" = "X$echo_test_string"; then
+- :
+-else
+- # The Solaris, AIX, and Digital Unix default echo programs unquote
+- # backslashes. This makes it impossible to quote backslashes using
+- # echo "$something" | sed 's/\\/\\\\/g'
+- #
+- # So, first we look for a working echo in the user's PATH.
+
+- lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+- for dir in $PATH /usr/ucb; do
+- IFS="$lt_save_ifs"
+- if (test -f $dir/echo || test -f $dir/echo$ac_exeext) &&
+- test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' &&
+- echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` &&
+- test "X$echo_testing_string" = "X$echo_test_string"; then
+- echo="$dir/echo"
+- break
+- fi
+- done
+- IFS="$lt_save_ifs"
++# _LT_LIBTOOL_TAG_VARS(TAG)
++# -------------------------
++m4_define([_LT_LIBTOOL_TAG_VARS],
++[m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames),
++ [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])])
+
+- if test "X$echo" = Xecho; then
+- # We didn't find a better echo, so look for alternatives.
+- if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' &&
+- echo_testing_string=`(print -r "$echo_test_string") 2>/dev/null` &&
+- test "X$echo_testing_string" = "X$echo_test_string"; then
+- # This shell has a builtin print -r that does the trick.
+- echo='print -r'
+- elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) &&
+- test "X$CONFIG_SHELL" != X/bin/ksh; then
+- # If we have ksh, try running configure again with it.
+- ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
+- export ORIGINAL_CONFIG_SHELL
+- CONFIG_SHELL=/bin/ksh
+- export CONFIG_SHELL
+- exec $CONFIG_SHELL "[$]0" --no-reexec ${1+"[$]@"}
+- else
+- # Try using printf.
+- echo='printf %s\n'
+- if test "X`($echo '\t') 2>/dev/null`" = 'X\t' &&
+- echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` &&
+- test "X$echo_testing_string" = "X$echo_test_string"; then
+- # Cool, printf works
+- :
+- elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` &&
+- test "X$echo_testing_string" = 'X\t' &&
+- echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
+- test "X$echo_testing_string" = "X$echo_test_string"; then
+- CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL
+- export CONFIG_SHELL
+- SHELL="$CONFIG_SHELL"
+- export SHELL
+- echo="$CONFIG_SHELL [$]0 --fallback-echo"
+- elif echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` &&
+- test "X$echo_testing_string" = 'X\t' &&
+- echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
+- test "X$echo_testing_string" = "X$echo_test_string"; then
+- echo="$CONFIG_SHELL [$]0 --fallback-echo"
+- else
+- # maybe with a smaller string...
+- prev=:
+
+- for cmd in 'echo test' 'sed 2q "[$]0"' 'sed 10q "[$]0"' 'sed 20q "[$]0"' 'sed 50q "[$]0"'; do
+- if (test "X$echo_test_string" = "X`eval $cmd`") 2>/dev/null
+- then
+- break
+- fi
+- prev="$cmd"
+- done
++# _LT_TAGVAR(VARNAME, [TAGNAME])
++# ------------------------------
++m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])])
+
+- if test "$prev" != 'sed 50q "[$]0"'; then
+- echo_test_string=`eval $prev`
+- export echo_test_string
+- exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "[$]0" ${1+"[$]@"}
+- else
+- # Oops. We lost completely, so just stick with echo.
+- echo=echo
+- fi
+- fi
+- fi
+- fi
+-fi
+-fi
+
+-# Copy echo and quote the copy suitably for passing to libtool from
+-# the Makefile, instead of quoting the original, which is used later.
+-ECHO=$echo
+-if test "X$ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then
+- ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo"
+-fi
++# _LT_CONFIG_COMMANDS
++# -------------------
++# Send accumulated output to $CONFIG_STATUS. Thanks to the lists of
++# variables for single and double quote escaping we saved from calls
++# to _LT_DECL, we can put quote escaped variables declarations
++# into `config.status', and then the shell code to quote escape them in
++# for loops in `config.status'. Finally, any additional code accumulated
++# from calls to _LT_CONFIG_LIBTOOL_INIT is expanded.
++m4_defun([_LT_CONFIG_COMMANDS],
++[AC_PROVIDE_IFELSE([LT_OUTPUT],
++ dnl If the libtool generation code has been placed in $CONFIG_LT,
++ dnl instead of duplicating it all over again into config.status,
++ dnl then we will have config.status run $CONFIG_LT later, so it
++ dnl needs to know what name is stored there:
++ [AC_CONFIG_COMMANDS([libtool],
++ [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])],
++ dnl If the libtool generation code is destined for config.status,
++ dnl expand the accumulated commands and init code now:
++ [AC_CONFIG_COMMANDS([libtool],
++ [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])])
++])#_LT_CONFIG_COMMANDS
+
+-AC_SUBST(ECHO)
+-])])# _LT_AC_PROG_ECHO_BACKSLASH
+
++# Initialize.
++m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT],
++[
+
+-# _LT_AC_LOCK
+-# -----------
+-AC_DEFUN([_LT_AC_LOCK],
+-[AC_ARG_ENABLE([libtool-lock],
+- [AC_HELP_STRING([--disable-libtool-lock],
+- [avoid locking (might break parallel builds)])])
+-test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
++# The HP-UX ksh and POSIX shell print the target directory to stdout
++# if CDPATH is set.
++(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+-# Some flags need to be propagated to the compiler or linker for good
+-# libtool support.
+-case $host in
+-ia64-*-hpux*)
+- # Find out which ABI we are using.
+- echo 'int i;' > conftest.$ac_ext
+- if AC_TRY_EVAL(ac_compile); then
+- case `/usr/bin/file conftest.$ac_objext` in
+- *ELF-32*)
+- HPUX_IA64_MODE="32"
+- ;;
+- *ELF-64*)
+- HPUX_IA64_MODE="64"
+- ;;
+- esac
+- fi
+- rm -rf conftest*
+- ;;
+-*-*-irix6*)
+- # Find out which ABI we are using.
+- echo '[#]line __oline__ "configure"' > conftest.$ac_ext
+- if AC_TRY_EVAL(ac_compile); then
+- if test "$lt_cv_prog_gnu_ld" = yes; then
+- case `/usr/bin/file conftest.$ac_objext` in
+- *32-bit*)
+- LD="${LD-ld} -melf32bsmip"
+- ;;
+- *N32*)
+- LD="${LD-ld} -melf32bmipn32"
++sed_quote_subst='$sed_quote_subst'
++double_quote_subst='$double_quote_subst'
++delay_variable_subst='$delay_variable_subst'
++_LT_CONFIG_STATUS_DECLARATIONS
++LTCC='$LTCC'
++LTCFLAGS='$LTCFLAGS'
++compiler='$compiler_DEFAULT'
++
++# Quote evaled strings.
++for var in lt_decl_all_varnames([[ \
++]], lt_decl_quote_varnames); do
++ case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in
++ *[[\\\\\\\`\\"\\\$]]*)
++ eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$sed_quote_subst\\"\\\`\\\\\\""
+ ;;
+- *64-bit*)
+- LD="${LD-ld} -melf64bmip"
++ *)
++ eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
+ ;;
+ esac
+- else
+- case `/usr/bin/file conftest.$ac_objext` in
+- *32-bit*)
+- LD="${LD-ld} -32"
+- ;;
+- *N32*)
+- LD="${LD-ld} -n32"
++done
++
++# Double-quote double-evaled strings.
++for var in lt_decl_all_varnames([[ \
++]], lt_decl_dquote_varnames); do
++ case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in
++ *[[\\\\\\\`\\"\\\$]]*)
++ eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\""
+ ;;
+- *64-bit*)
+- LD="${LD-ld} -64"
++ *)
++ eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
+ ;;
+ esac
+- fi
+- fi
+- rm -rf conftest*
++done
++
++# Fix-up fallback echo if it was mangled by the above quoting rules.
++case \$lt_ECHO in
++*'\\\[$]0 --fallback-echo"')dnl "
++ lt_ECHO=\`\$ECHO "X\$lt_ECHO" | \$Xsed -e 's/\\\\\\\\\\\\\\\[$]0 --fallback-echo"\[$]/\[$]0 --fallback-echo"/'\`
+ ;;
++esac
+
+-x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*|s390*-*linux*|sparc*-*linux*)
+- # Find out which ABI we are using.
+- echo 'int i;' > conftest.$ac_ext
+- if AC_TRY_EVAL(ac_compile); then
+- case `/usr/bin/file conftest.o` in
+- *32-bit*)
+- case $host in
+- x86_64-*linux*)
+- LD="${LD-ld} -m elf_i386"
+- ;;
+- ppc64-*linux*|powerpc64-*linux*)
+- LD="${LD-ld} -m elf32ppclinux"
+- ;;
+- s390x-*linux*)
+- LD="${LD-ld} -m elf_s390"
+- ;;
+- sparc64-*linux*)
+- LD="${LD-ld} -m elf32_sparc"
+- ;;
+- esac
+- ;;
+- *64-bit*)
+- case $host in
+- x86_64-*linux*)
+- LD="${LD-ld} -m elf_x86_64"
+- ;;
+- ppc*-*linux*|powerpc*-*linux*)
+- LD="${LD-ld} -m elf64ppc"
+- ;;
+- s390*-*linux*)
+- LD="${LD-ld} -m elf64_s390"
+- ;;
+- sparc*-*linux*)
+- LD="${LD-ld} -m elf64_sparc"
+- ;;
+- esac
+- ;;
+- esac
+- fi
+- rm -rf conftest*
+- ;;
++_LT_OUTPUT_LIBTOOL_INIT
++])
+
+-*-*-sco3.2v5*)
+- # On SCO OpenServer 5, we need -belf to get full-featured binaries.
+- SAVE_CFLAGS="$CFLAGS"
+- CFLAGS="$CFLAGS -belf"
+- AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
+- [AC_LANG_PUSH(C)
+- AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])
+- AC_LANG_POP])
+- if test x"$lt_cv_cc_needs_belf" != x"yes"; then
+- # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
+- CFLAGS="$SAVE_CFLAGS"
+- fi
+- ;;
+-sparc*-*solaris*)
+- # Find out which ABI we are using.
+- echo 'int i;' > conftest.$ac_ext
+- if AC_TRY_EVAL(ac_compile); then
+- case `/usr/bin/file conftest.o` in
+- *64-bit*)
+- case $lt_cv_prog_gnu_ld in
+- yes*) LD="${LD-ld} -m elf64_sparc" ;;
+- *) LD="${LD-ld} -64" ;;
+- esac
+- ;;
+- esac
+- fi
+- rm -rf conftest*
+- ;;
+
+-AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL],
+-[*-*-cygwin* | *-*-mingw* | *-*-pw32*)
+- AC_CHECK_TOOL(DLLTOOL, dlltool, false)
+- AC_CHECK_TOOL(AS, as, false)
+- AC_CHECK_TOOL(OBJDUMP, objdump, false)
+- ;;
+- ])
+-esac
++# LT_OUTPUT
++# ---------
++# This macro allows early generation of the libtool script (before
++# AC_OUTPUT is called), incase it is used in configure for compilation
++# tests.
++AC_DEFUN([LT_OUTPUT],
++[: ${CONFIG_LT=./config.lt}
++AC_MSG_NOTICE([creating $CONFIG_LT])
++cat >"$CONFIG_LT" <<_LTEOF
++#! $SHELL
++# Generated by $as_me.
++# Run this file to recreate a libtool stub with the current configuration.
++
++lt_cl_silent=false
++SHELL=\${CONFIG_SHELL-$SHELL}
++_LTEOF
++
++cat >>"$CONFIG_LT" <<\_LTEOF
++AS_SHELL_SANITIZE
++_AS_PREPARE
+
+-need_locks="$enable_libtool_lock"
++exec AS_MESSAGE_FD>&1
++exec AS_MESSAGE_LOG_FD>>config.log
++{
++ echo
++ AS_BOX([Running $as_me.])
++} >&AS_MESSAGE_LOG_FD
++
++lt_cl_help="\
++\`$as_me' creates a local libtool stub from the current configuration,
++for use in further configure time tests before the real libtool is
++generated.
++
++Usage: $[0] [[OPTIONS]]
++
++ -h, --help print this help, then exit
++ -V, --version print version number, then exit
++ -q, --quiet do not print progress messages
++ -d, --debug don't remove temporary files
++
++Report bugs to <bug-libtool@gnu.org>."
++
++lt_cl_version="\
++m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl
++m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION])
++configured by $[0], generated by m4_PACKAGE_STRING.
++
++Copyright (C) 2008 Free Software Foundation, Inc.
++This config.lt script is free software; the Free Software Foundation
++gives unlimited permision to copy, distribute and modify it."
+
+-])# _LT_AC_LOCK
++while test $[#] != 0
++do
++ case $[1] in
++ --version | --v* | -V )
++ echo "$lt_cl_version"; exit 0 ;;
++ --help | --h* | -h )
++ echo "$lt_cl_help"; exit 0 ;;
++ --debug | --d* | -d )
++ debug=: ;;
++ --quiet | --q* | --silent | --s* | -q )
++ lt_cl_silent=: ;;
+
++ -*) AC_MSG_ERROR([unrecognized option: $[1]
++Try \`$[0] --help' for more information.]) ;;
+
+-# AC_LIBTOOL_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
+-# [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE])
+-# ----------------------------------------------------------------
+-# Check whether the given compiler option works
+-AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION],
+-[AC_REQUIRE([LT_AC_PROG_SED])
+-AC_CACHE_CHECK([$1], [$2],
+- [$2=no
+- ifelse([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4])
+- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+- lt_compiler_flag="$3"
+- # Insert the option either (1) after the last *FLAGS variable, or
+- # (2) before a word containing "conftest.", or (3) at the end.
+- # Note that $ac_compile itself does not contain backslashes and begins
+- # with a dollar sign (not a hyphen), so the echo should work correctly.
+- # The option is referenced via a variable to avoid confusing sed.
+- lt_compile=`echo "$ac_compile" | $SED \
+- -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+- -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
+- -e 's:$: $lt_compiler_flag:'`
+- (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
+- (eval "$lt_compile" 2>conftest.err)
+- ac_status=$?
+- cat conftest.err >&AS_MESSAGE_LOG_FD
+- echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
+- if (exit $ac_status) && test -s "$ac_outfile"; then
+- # The compiler can only warn and ignore the option if not recognized
+- # So say no if there are warnings other than the usual output.
+- $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
+- $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+- if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+- $2=yes
+- fi
+- fi
+- $rm conftest*
+-])
++ *) AC_MSG_ERROR([unrecognized argument: $[1]
++Try \`$[0] --help' for more information.]) ;;
++ esac
++ shift
++done
+
+-if test x"[$]$2" = xyes; then
+- ifelse([$5], , :, [$5])
+-else
+- ifelse([$6], , :, [$6])
++if $lt_cl_silent; then
++ exec AS_MESSAGE_FD>/dev/null
+ fi
+-])# AC_LIBTOOL_COMPILER_OPTION
+-
+-
+-# AC_LIBTOOL_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
+-# [ACTION-SUCCESS], [ACTION-FAILURE])
+-# ------------------------------------------------------------
+-# Check whether the given compiler option works
+-AC_DEFUN([AC_LIBTOOL_LINKER_OPTION],
+-[AC_CACHE_CHECK([$1], [$2],
+- [$2=no
+- save_LDFLAGS="$LDFLAGS"
+- LDFLAGS="$LDFLAGS $3"
+- printf "$lt_simple_link_test_code" > conftest.$ac_ext
+- if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
+- # The linker can only warn and ignore the option if not recognized
+- # So say no if there are warnings
+- if test -s conftest.err; then
+- # Append any errors to the config.log.
+- cat conftest.err 1>&AS_MESSAGE_LOG_FD
+- $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
+- $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+- if diff conftest.exp conftest.er2 >/dev/null; then
+- $2=yes
+- fi
+- else
+- $2=yes
+- fi
+- fi
+- $rm conftest*
+- LDFLAGS="$save_LDFLAGS"
+-])
++_LTEOF
+
+-if test x"[$]$2" = xyes; then
+- ifelse([$4], , :, [$4])
+-else
+- ifelse([$5], , :, [$5])
++cat >>"$CONFIG_LT" <<_LTEOF
++_LT_OUTPUT_LIBTOOL_COMMANDS_INIT
++_LTEOF
++
++cat >>"$CONFIG_LT" <<\_LTEOF
++AC_MSG_NOTICE([creating $ofile])
++_LT_OUTPUT_LIBTOOL_COMMANDS
++AS_EXIT(0)
++_LTEOF
++chmod +x "$CONFIG_LT"
++
++# configure is writing to config.log, but config.lt does its own redirection,
++# appending to config.log, which fails on DOS, as config.log is still kept
++# open by configure. Here we exec the FD to /dev/null, effectively closing
++# config.log, so it can be properly (re)opened and appended to by config.lt.
++if test "$no_create" != yes; then
++ lt_cl_success=:
++ test "$silent" = yes &&
++ lt_config_lt_args="$lt_config_lt_args --quiet"
++ exec AS_MESSAGE_LOG_FD>/dev/null
++ $SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false
++ exec AS_MESSAGE_LOG_FD>>config.log
++ $lt_cl_success || AS_EXIT(1)
+ fi
+-])# AC_LIBTOOL_LINKER_OPTION
+-
++])# LT_OUTPUT
+
+-# AC_LIBTOOL_SYS_MAX_CMD_LEN
+-# --------------------------
+-AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN],
+-[# find the maximum length of command line arguments
+-AC_MSG_CHECKING([the maximum length of command line arguments])
+-AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
+- i=0
+- teststring="ABCD"
+
+- case $build_os in
+- msdosdjgpp*)
+- # On DJGPP, this test can blow up pretty badly due to problems in libc
+- # (any single argument exceeding 2000 bytes causes a buffer overrun
+- # during glob expansion). Even if it were fixed, the result of this
+- # check would be larger than it should be.
+- lt_cv_sys_max_cmd_len=12288; # 12K is about right
+- ;;
++# _LT_CONFIG(TAG)
++# ---------------
++# If TAG is the built-in tag, create an initial libtool script with a
++# default configuration from the untagged config vars. Otherwise add code
++# to config.status for appending the configuration named by TAG from the
++# matching tagged config vars.
++m4_defun([_LT_CONFIG],
++[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
++_LT_CONFIG_SAVE_COMMANDS([
++ m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl
++ m4_if(_LT_TAG, [C], [
++ # See if we are running on zsh, and set the options which allow our
++ # commands through without removal of \ escapes.
++ if test -n "${ZSH_VERSION+set}" ; then
++ setopt NO_GLOB_SUBST
++ fi
+
+- gnu*)
+- # Under GNU Hurd, this test is not required because there is
+- # no limit to the length of command line arguments.
+- # Libtool will interpret -1 as no limit whatsoever
+- lt_cv_sys_max_cmd_len=-1;
+- ;;
++ cfgfile="${ofile}T"
++ trap "$RM \"$cfgfile\"; exit 1" 1 2 15
++ $RM "$cfgfile"
+
+- cygwin* | mingw*)
+- # On Win9x/ME, this test blows up -- it succeeds, but takes
+- # about 5 minutes as the teststring grows exponentially.
+- # Worse, since 9x/ME are not pre-emptively multitasking,
+- # you end up with a "frozen" computer, even though with patience
+- # the test eventually succeeds (with a max line length of 256k).
+- # Instead, let's just punt: use the minimum linelength reported by
+- # all of the supported platforms: 8192 (on NT/2K/XP).
+- lt_cv_sys_max_cmd_len=8192;
+- ;;
++ cat <<_LT_EOF >> "$cfgfile"
++#! $SHELL
+
+- amigaos*)
+- # On AmigaOS with pdksh, this test takes hours, literally.
+- # So we just punt and use a minimum line length of 8192.
+- lt_cv_sys_max_cmd_len=8192;
+- ;;
++# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
++# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION
++# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
++# NOTE: Changes made to this file will be lost: look at ltmain.sh.
++#
++_LT_COPYING
++_LT_LIBTOOL_TAGS
+
+- netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
+- # This has been around since 386BSD, at least. Likely further.
+- if test -x /sbin/sysctl; then
+- lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
+- elif test -x /usr/sbin/sysctl; then
+- lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
+- else
+- lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs
+- fi
+- # And add a safety zone
+- lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
+- lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+- ;;
++# ### BEGIN LIBTOOL CONFIG
++_LT_LIBTOOL_CONFIG_VARS
++_LT_LIBTOOL_TAG_VARS
++# ### END LIBTOOL CONFIG
+
+- interix*)
+- # We know the value 262144 and hardcode it with a safety zone (like BSD)
+- lt_cv_sys_max_cmd_len=196608
+- ;;
++_LT_EOF
+
+- osf*)
+- # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
+- # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
+- # nice to cause kernel panics so lets avoid the loop below.
+- # First set a reasonable default.
+- lt_cv_sys_max_cmd_len=16384
+- #
+- if test -x /sbin/sysconfig; then
+- case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
+- *1*) lt_cv_sys_max_cmd_len=-1 ;;
+- esac
+- fi
+- ;;
+- sco3.2v5*)
+- lt_cv_sys_max_cmd_len=102400
+- ;;
+- sysv5* | sco5v6* | sysv4.2uw2*)
+- kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
+- if test -n "$kargmax"; then
+- lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'`
+- else
+- lt_cv_sys_max_cmd_len=32768
+- fi
+- ;;
+- *)
+- # If test is not a shell built-in, we'll probably end up computing a
+- # maximum length that is only half of the actual maximum length, but
+- # we can't tell.
+- SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
+- while (test "X"`$SHELL [$]0 --fallback-echo "X$teststring" 2>/dev/null` \
+- = "XX$teststring") >/dev/null 2>&1 &&
+- new_result=`expr "X$teststring" : ".*" 2>&1` &&
+- lt_cv_sys_max_cmd_len=$new_result &&
+- test $i != 17 # 1/2 MB should be enough
+- do
+- i=`expr $i + 1`
+- teststring=$teststring$teststring
+- done
+- teststring=
+- # Add a significant safety factor because C++ compilers can tack on massive
+- # amounts of additional arguments before passing them to the linker.
+- # It appears as though 1/2 is a usable value.
+- lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
++ case $host_os in
++ aix3*)
++ cat <<\_LT_EOF >> "$cfgfile"
++# AIX sometimes has problems with the GCC collect2 program. For some
++# reason, if we set the COLLECT_NAMES environment variable, the problems
++# vanish in a puff of smoke.
++if test "X${COLLECT_NAMES+set}" != Xset; then
++ COLLECT_NAMES=
++ export COLLECT_NAMES
++fi
++_LT_EOF
+ ;;
+ esac
+-])
+-if test -n $lt_cv_sys_max_cmd_len ; then
+- AC_MSG_RESULT($lt_cv_sys_max_cmd_len)
+-else
+- AC_MSG_RESULT(none)
+-fi
+-])# AC_LIBTOOL_SYS_MAX_CMD_LEN
+
++ _LT_PROG_LTMAIN
+
+-# _LT_AC_CHECK_DLFCN
+-# ------------------
+-AC_DEFUN([_LT_AC_CHECK_DLFCN],
+-[AC_CHECK_HEADERS(dlfcn.h)dnl
+-])# _LT_AC_CHECK_DLFCN
++ # We use sed instead of cat because bash on DJGPP gets confused if
++ # if finds mixed CR/LF and LF-only lines. Since sed operates in
++ # text mode, it properly converts lines to CR/LF. This bash problem
++ # is reportedly fixed, but why not run on old versions too?
++ sed '/^# Generated shell functions inserted here/q' "$ltmain" >> "$cfgfile" \
++ || (rm -f "$cfgfile"; exit 1)
+
++ _LT_PROG_XSI_SHELLFNS
+
+-# _LT_AC_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE,
+-# ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING)
+-# ---------------------------------------------------------------------
+-AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF],
+-[AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl
+-if test "$cross_compiling" = yes; then :
+- [$4]
+-else
+- lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+- lt_status=$lt_dlunknown
+- cat > conftest.$ac_ext <<EOF
+-[#line __oline__ "configure"
+-#include "confdefs.h"
++ sed -n '/^# Generated shell functions inserted here/,$p' "$ltmain" >> "$cfgfile" \
++ || (rm -f "$cfgfile"; exit 1)
+
+-#if HAVE_DLFCN_H
+-#include <dlfcn.h>
+-#endif
++ mv -f "$cfgfile" "$ofile" ||
++ (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
++ chmod +x "$ofile"
++],
++[cat <<_LT_EOF >> "$ofile"
+
+-#include <stdio.h>
++dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded
++dnl in a comment (ie after a #).
++# ### BEGIN LIBTOOL TAG CONFIG: $1
++_LT_LIBTOOL_TAG_VARS(_LT_TAG)
++# ### END LIBTOOL TAG CONFIG: $1
++_LT_EOF
++])dnl /m4_if
++],
++[m4_if([$1], [], [
++ PACKAGE='$PACKAGE'
++ VERSION='$VERSION'
++ TIMESTAMP='$TIMESTAMP'
++ RM='$RM'
++ ofile='$ofile'], [])
++])dnl /_LT_CONFIG_SAVE_COMMANDS
++])# _LT_CONFIG
++
++
++# LT_SUPPORTED_TAG(TAG)
++# ---------------------
++# Trace this macro to discover what tags are supported by the libtool
++# --tag option, using:
++# autoconf --trace 'LT_SUPPORTED_TAG:$1'
++AC_DEFUN([LT_SUPPORTED_TAG], [])
++
++
++# C support is built-in for now
++m4_define([_LT_LANG_C_enabled], [])
++m4_define([_LT_TAGS], [])
+
+-#ifdef RTLD_GLOBAL
+-# define LT_DLGLOBAL RTLD_GLOBAL
+-#else
+-# ifdef DL_GLOBAL
+-# define LT_DLGLOBAL DL_GLOBAL
+-# else
+-# define LT_DLGLOBAL 0
+-# endif
+-#endif
+
+-/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+- find out it does not work in some platform. */
+-#ifndef LT_DLLAZY_OR_NOW
+-# ifdef RTLD_LAZY
+-# define LT_DLLAZY_OR_NOW RTLD_LAZY
+-# else
+-# ifdef DL_LAZY
+-# define LT_DLLAZY_OR_NOW DL_LAZY
+-# else
+-# ifdef RTLD_NOW
+-# define LT_DLLAZY_OR_NOW RTLD_NOW
+-# else
+-# ifdef DL_NOW
+-# define LT_DLLAZY_OR_NOW DL_NOW
+-# else
+-# define LT_DLLAZY_OR_NOW 0
+-# endif
+-# endif
+-# endif
+-# endif
+-#endif
++# LT_LANG(LANG)
++# -------------
++# Enable libtool support for the given language if not already enabled.
++AC_DEFUN([LT_LANG],
++[AC_BEFORE([$0], [LT_OUTPUT])dnl
++m4_case([$1],
++ [C], [_LT_LANG(C)],
++ [C++], [_LT_LANG(CXX)],
++ [Java], [_LT_LANG(GCJ)],
++ [Fortran 77], [_LT_LANG(F77)],
++ [Fortran], [_LT_LANG(FC)],
++ [Windows Resource], [_LT_LANG(RC)],
++ [m4_ifdef([_LT_LANG_]$1[_CONFIG],
++ [_LT_LANG($1)],
++ [m4_fatal([$0: unsupported language: "$1"])])])dnl
++])# LT_LANG
+
+-#ifdef __cplusplus
+-extern "C" void exit (int);
+-#endif
+
+-void fnord() { int i=42;}
+-int main ()
+-{
+- void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+- int status = $lt_dlunknown;
+-
+- if (self)
+- {
+- if (dlsym (self,"fnord")) status = $lt_dlno_uscore;
+- else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
+- /* dlclose (self); */
+- }
+- else
+- puts (dlerror ());
++# _LT_LANG(LANGNAME)
++# ------------------
++m4_defun([_LT_LANG],
++[m4_ifdef([_LT_LANG_]$1[_enabled], [],
++ [LT_SUPPORTED_TAG([$1])dnl
++ m4_append([_LT_TAGS], [$1 ])dnl
++ m4_define([_LT_LANG_]$1[_enabled], [])dnl
++ _LT_LANG_$1_CONFIG($1)])dnl
++])# _LT_LANG
+
+- exit (status);
+-}]
+-EOF
+- if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then
+- (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null
+- lt_status=$?
+- case x$lt_status in
+- x$lt_dlno_uscore) $1 ;;
+- x$lt_dlneed_uscore) $2 ;;
+- x$lt_dlunknown|x*) $3 ;;
+- esac
+- else :
+- # compilation failed
+- $3
+- fi
+-fi
+-rm -fr conftest*
+-])# _LT_AC_TRY_DLOPEN_SELF
+
++# _LT_LANG_DEFAULT_CONFIG
++# -----------------------
++m4_defun([_LT_LANG_DEFAULT_CONFIG],
++[AC_PROVIDE_IFELSE([AC_PROG_CXX],
++ [LT_LANG(CXX)],
++ [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])])
++
++AC_PROVIDE_IFELSE([AC_PROG_F77],
++ [LT_LANG(F77)],
++ [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])])
++
++AC_PROVIDE_IFELSE([AC_PROG_FC],
++ [LT_LANG(FC)],
++ [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])])
++
++dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal
++dnl pulling things in needlessly.
++AC_PROVIDE_IFELSE([AC_PROG_GCJ],
++ [LT_LANG(GCJ)],
++ [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],
++ [LT_LANG(GCJ)],
++ [AC_PROVIDE_IFELSE([LT_PROG_GCJ],
++ [LT_LANG(GCJ)],
++ [m4_ifdef([AC_PROG_GCJ],
++ [m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])])
++ m4_ifdef([A][M_PROG_GCJ],
++ [m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])])
++ m4_ifdef([LT_PROG_GCJ],
++ [m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])])
++
++AC_PROVIDE_IFELSE([LT_PROG_RC],
++ [LT_LANG(RC)],
++ [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])])
++])# _LT_LANG_DEFAULT_CONFIG
++
++# Obsolete macros:
++AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)])
++AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)])
++AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)])
++AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)])
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([AC_LIBTOOL_CXX], [])
++dnl AC_DEFUN([AC_LIBTOOL_F77], [])
++dnl AC_DEFUN([AC_LIBTOOL_FC], [])
++dnl AC_DEFUN([AC_LIBTOOL_GCJ], [])
+
+-# AC_LIBTOOL_DLOPEN_SELF
+-# ----------------------
+-AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF],
+-[AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl
+-if test "x$enable_dlopen" != xyes; then
+- enable_dlopen=unknown
+- enable_dlopen_self=unknown
+- enable_dlopen_self_static=unknown
+-else
+- lt_cv_dlopen=no
+- lt_cv_dlopen_libs=
+
+- case $host_os in
+- beos*)
+- lt_cv_dlopen="load_add_on"
+- lt_cv_dlopen_libs=
+- lt_cv_dlopen_self=yes
+- ;;
++# _LT_TAG_COMPILER
++# ----------------
++m4_defun([_LT_TAG_COMPILER],
++[AC_REQUIRE([AC_PROG_CC])dnl
+
+- mingw* | pw32*)
+- lt_cv_dlopen="LoadLibrary"
+- lt_cv_dlopen_libs=
+- ;;
++_LT_DECL([LTCC], [CC], [1], [A C compiler])dnl
++_LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl
++_LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl
++_LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl
+
+- cygwin*)
+- lt_cv_dlopen="dlopen"
+- lt_cv_dlopen_libs=
+- ;;
++# If no C compiler was specified, use CC.
++LTCC=${LTCC-"$CC"}
+
+- darwin*)
+- # if libdl is installed we need to link against it
+- AC_CHECK_LIB([dl], [dlopen],
+- [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[
+- lt_cv_dlopen="dyld"
+- lt_cv_dlopen_libs=
+- lt_cv_dlopen_self=yes
+- ])
+- ;;
++# If no C compiler flags were specified, use CFLAGS.
++LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
+
+- *)
+- AC_CHECK_FUNC([shl_load],
+- [lt_cv_dlopen="shl_load"],
+- [AC_CHECK_LIB([dld], [shl_load],
+- [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld"],
+- [AC_CHECK_FUNC([dlopen],
+- [lt_cv_dlopen="dlopen"],
+- [AC_CHECK_LIB([dl], [dlopen],
+- [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],
+- [AC_CHECK_LIB([svld], [dlopen],
+- [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"],
+- [AC_CHECK_LIB([dld], [dld_link],
+- [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld"])
+- ])
+- ])
+- ])
+- ])
+- ])
+- ;;
+- esac
++# Allow CC to be a program name with arguments.
++compiler=$CC
++])# _LT_TAG_COMPILER
+
+- if test "x$lt_cv_dlopen" != xno; then
+- enable_dlopen=yes
+- else
+- enable_dlopen=no
+- fi
+
+- case $lt_cv_dlopen in
+- dlopen)
+- save_CPPFLAGS="$CPPFLAGS"
+- test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
++# _LT_COMPILER_BOILERPLATE
++# ------------------------
++# Check for compiler boilerplate output or warnings with
++# the simple compiler test code.
++m4_defun([_LT_COMPILER_BOILERPLATE],
++[m4_require([_LT_DECL_SED])dnl
++ac_outfile=conftest.$ac_objext
++echo "$lt_simple_compile_test_code" >conftest.$ac_ext
++eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
++_lt_compiler_boilerplate=`cat conftest.err`
++$RM conftest*
++])# _LT_COMPILER_BOILERPLATE
+
+- save_LDFLAGS="$LDFLAGS"
+- wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
+
+- save_LIBS="$LIBS"
+- LIBS="$lt_cv_dlopen_libs $LIBS"
++# _LT_LINKER_BOILERPLATE
++# ----------------------
++# Check for linker boilerplate output or warnings with
++# the simple link test code.
++m4_defun([_LT_LINKER_BOILERPLATE],
++[m4_require([_LT_DECL_SED])dnl
++ac_outfile=conftest.$ac_objext
++echo "$lt_simple_link_test_code" >conftest.$ac_ext
++eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
++_lt_linker_boilerplate=`cat conftest.err`
++$RM -r conftest*
++])# _LT_LINKER_BOILERPLATE
+
+- AC_CACHE_CHECK([whether a program can dlopen itself],
+- lt_cv_dlopen_self, [dnl
+- _LT_AC_TRY_DLOPEN_SELF(
+- lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes,
+- lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross)
++# _LT_REQUIRED_DARWIN_CHECKS
++# -------------------------
++m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[
++ case $host_os in
++ rhapsody* | darwin*)
++ AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:])
++ AC_CHECK_TOOL([NMEDIT], [nmedit], [:])
++ AC_CHECK_TOOL([LIPO], [lipo], [:])
++ AC_CHECK_TOOL([OTOOL], [otool], [:])
++ AC_CHECK_TOOL([OTOOL64], [otool64], [:])
++ _LT_DECL([], [DSYMUTIL], [1],
++ [Tool to manipulate archived DWARF debug symbol files on Mac OS X])
++ _LT_DECL([], [NMEDIT], [1],
++ [Tool to change global to local symbols on Mac OS X])
++ _LT_DECL([], [LIPO], [1],
++ [Tool to manipulate fat objects and archives on Mac OS X])
++ _LT_DECL([], [OTOOL], [1],
++ [ldd/readelf like tool for Mach-O binaries on Mac OS X])
++ _LT_DECL([], [OTOOL64], [1],
++ [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4])
++
++ AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod],
++ [lt_cv_apple_cc_single_mod=no
++ if test -z "${LT_MULTI_MODULE}"; then
++ # By default we will add the -single_module flag. You can override
++ # by either setting the environment variable LT_MULTI_MODULE
++ # non-empty at configure time, or by adding -multi_module to the
++ # link flags.
++ rm -rf libconftest.dylib*
++ echo "int foo(void){return 1;}" > conftest.c
++ echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
++-dynamiclib -Wl,-single_module conftest.c" >&AS_MESSAGE_LOG_FD
++ $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
++ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err
++ _lt_result=$?
++ if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then
++ lt_cv_apple_cc_single_mod=yes
++ else
++ cat conftest.err >&AS_MESSAGE_LOG_FD
++ fi
++ rm -rf libconftest.dylib*
++ rm -f conftest.*
++ fi])
++ AC_CACHE_CHECK([for -exported_symbols_list linker flag],
++ [lt_cv_ld_exported_symbols_list],
++ [lt_cv_ld_exported_symbols_list=no
++ save_LDFLAGS=$LDFLAGS
++ echo "_main" > conftest.sym
++ LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym"
++ AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
++ [lt_cv_ld_exported_symbols_list=yes],
++ [lt_cv_ld_exported_symbols_list=no])
++ LDFLAGS="$save_LDFLAGS"
+ ])
+-
+- if test "x$lt_cv_dlopen_self" = xyes; then
+- wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
+- AC_CACHE_CHECK([whether a statically linked program can dlopen itself],
+- lt_cv_dlopen_self_static, [dnl
+- _LT_AC_TRY_DLOPEN_SELF(
+- lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes,
+- lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross)
+- ])
++ case $host_os in
++ rhapsody* | darwin1.[[012]])
++ _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
++ darwin1.*)
++ _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
++ darwin*) # darwin 5.x on
++ # if running on 10.5 or later, the deployment target defaults
++ # to the OS version, if on x86, and 10.4, the deployment
++ # target defaults to 10.4. Don't you love it?
++ case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
++ 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*)
++ _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
++ 10.[[012]]*)
++ _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
++ 10.*)
++ _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
++ esac
++ ;;
++ esac
++ if test "$lt_cv_apple_cc_single_mod" = "yes"; then
++ _lt_dar_single_mod='$single_module'
++ fi
++ if test "$lt_cv_ld_exported_symbols_list" = "yes"; then
++ _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym'
++ else
++ _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}'
++ fi
++ if test "$DSYMUTIL" != ":"; then
++ _lt_dsymutil='~$DSYMUTIL $lib || :'
++ else
++ _lt_dsymutil=
+ fi
+-
+- CPPFLAGS="$save_CPPFLAGS"
+- LDFLAGS="$save_LDFLAGS"
+- LIBS="$save_LIBS"
+ ;;
+ esac
++])
+
+- case $lt_cv_dlopen_self in
+- yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
+- *) enable_dlopen_self=unknown ;;
+- esac
+
+- case $lt_cv_dlopen_self_static in
+- yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
+- *) enable_dlopen_self_static=unknown ;;
+- esac
+-fi
+-])# AC_LIBTOOL_DLOPEN_SELF
++# _LT_DARWIN_LINKER_FEATURES
++# --------------------------
++# Checks for linker and compiler features on darwin
++m4_defun([_LT_DARWIN_LINKER_FEATURES],
++[
++ m4_require([_LT_REQUIRED_DARWIN_CHECKS])
++ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
++ _LT_TAGVAR(hardcode_direct, $1)=no
++ _LT_TAGVAR(hardcode_automatic, $1)=yes
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
++ _LT_TAGVAR(whole_archive_flag_spec, $1)=''
++ _LT_TAGVAR(link_all_deplibs, $1)=yes
++ _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined"
++ if test "$GCC" = "yes"; then
++ output_verbose_link_cmd=echo
++ _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
++ _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
++ _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
++ _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
++ m4_if([$1], [CXX],
++[ if test "$lt_cv_apple_cc_single_mod" != "yes"; then
++ _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
++ _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}"
++ fi
++],[])
++ else
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ fi
++])
+
++# _LT_SYS_MODULE_PATH_AIX
++# -----------------------
++# Links a minimal program and checks the executable
++# for the system default hardcoded library path. In most cases,
++# this is /usr/lib:/lib, but when the MPI compilers are used
++# the location of the communication and MPI libs are included too.
++# If we don't find anything, use the default library path according
++# to the aix ld manual.
++m4_defun([_LT_SYS_MODULE_PATH_AIX],
++[m4_require([_LT_DECL_SED])dnl
++AC_LINK_IFELSE(AC_LANG_PROGRAM,[
++lt_aix_libpath_sed='
++ /Import File Strings/,/^$/ {
++ /^0/ {
++ s/^0 *\(.*\)$/\1/
++ p
++ }
++ }'
++aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
++# Check for a 64-bit object if we didn't find anything.
++if test -z "$aix_libpath"; then
++ aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
++fi],[])
++if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
++])# _LT_SYS_MODULE_PATH_AIX
+
+-# AC_LIBTOOL_PROG_CC_C_O([TAGNAME])
+-# ---------------------------------
+-# Check to see if options -c and -o are simultaneously supported by compiler
+-AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O],
+-[AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl
+-AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext],
+- [_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)],
+- [_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no
+- $rm -r conftest 2>/dev/null
+- mkdir conftest
+- cd conftest
+- mkdir out
+- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+- lt_compiler_flag="-o out/conftest2.$ac_objext"
+- # Insert the option either (1) after the last *FLAGS variable, or
+- # (2) before a word containing "conftest.", or (3) at the end.
+- # Note that $ac_compile itself does not contain backslashes and begins
+- # with a dollar sign (not a hyphen), so the echo should work correctly.
+- lt_compile=`echo "$ac_compile" | $SED \
+- -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+- -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
+- -e 's:$: $lt_compiler_flag:'`
+- (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
+- (eval "$lt_compile" 2>out/conftest.err)
+- ac_status=$?
+- cat out/conftest.err >&AS_MESSAGE_LOG_FD
+- echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
+- if (exit $ac_status) && test -s out/conftest2.$ac_objext
+- then
+- # The compiler can only warn and ignore the option if not recognized
+- # So say no if there are warnings
+- $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
+- $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+- if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+- _LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
+- fi
+- fi
+- chmod u+w . 2>&AS_MESSAGE_LOG_FD
+- $rm conftest*
+- # SGI C++ compiler will create directory out/ii_files/ for
+- # template instantiation
+- test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files
+- $rm out/* && rmdir out
+- cd ..
+- rmdir conftest
+- $rm conftest*
+-])
+-])# AC_LIBTOOL_PROG_CC_C_O
++# _LT_SHELL_INIT(ARG)
++# -------------------
++m4_define([_LT_SHELL_INIT],
++[ifdef([AC_DIVERSION_NOTICE],
++ [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)],
++ [AC_DIVERT_PUSH(NOTICE)])
++$1
++AC_DIVERT_POP
++])# _LT_SHELL_INIT
+
+
+-# AC_LIBTOOL_SYS_HARD_LINK_LOCKS([TAGNAME])
+-# -----------------------------------------
+-# Check to see if we can do hard links to lock some files if needed
+-AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS],
+-[AC_REQUIRE([_LT_AC_LOCK])dnl
++# _LT_PROG_ECHO_BACKSLASH
++# -----------------------
++# Add some code to the start of the generated configure script which
++# will find an echo command which doesn't interpret backslashes.
++m4_defun([_LT_PROG_ECHO_BACKSLASH],
++[_LT_SHELL_INIT([
++# Check that we are running under the correct shell.
++SHELL=${CONFIG_SHELL-/bin/sh}
+
+-hard_links="nottested"
+-if test "$_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then
+- # do not overwrite the value of need_locks provided by the user
+- AC_MSG_CHECKING([if we can lock with hard links])
+- hard_links=yes
+- $rm conftest*
+- ln conftest.a conftest.b 2>/dev/null && hard_links=no
+- touch conftest.a
+- ln conftest.a conftest.b 2>&5 || hard_links=no
+- ln conftest.a conftest.b 2>/dev/null && hard_links=no
+- AC_MSG_RESULT([$hard_links])
+- if test "$hard_links" = no; then
+- AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe])
+- need_locks=warn
+- fi
++case X$lt_ECHO in
++X*--fallback-echo)
++ # Remove one level of quotation (which was required for Make).
++ ECHO=`echo "$lt_ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','`
++ ;;
++esac
++
++ECHO=${lt_ECHO-echo}
++if test "X[$]1" = X--no-reexec; then
++ # Discard the --no-reexec flag, and continue.
++ shift
++elif test "X[$]1" = X--fallback-echo; then
++ # Avoid inline document here, it may be left over
++ :
++elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' ; then
++ # Yippee, $ECHO works!
++ :
+ else
+- need_locks=no
++ # Restart under the correct shell.
++ exec $SHELL "[$]0" --no-reexec ${1+"[$]@"}
+ fi
+-])# AC_LIBTOOL_SYS_HARD_LINK_LOCKS
+
+-
+-# AC_LIBTOOL_OBJDIR
+-# -----------------
+-AC_DEFUN([AC_LIBTOOL_OBJDIR],
+-[AC_CACHE_CHECK([for objdir], [lt_cv_objdir],
+-[rm -f .libs 2>/dev/null
+-mkdir .libs 2>/dev/null
+-if test -d .libs; then
+- lt_cv_objdir=.libs
+-else
+- # MS-DOS does not allow filenames that begin with a dot.
+- lt_cv_objdir=_libs
++if test "X[$]1" = X--fallback-echo; then
++ # used as fallback echo
++ shift
++ cat <<_LT_EOF
++[$]*
++_LT_EOF
++ exit 0
+ fi
+-rmdir .libs 2>/dev/null])
+-objdir=$lt_cv_objdir
+-])# AC_LIBTOOL_OBJDIR
+
++# The HP-UX ksh and POSIX shell print the target directory to stdout
++# if CDPATH is set.
++(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+-# AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH([TAGNAME])
+-# ----------------------------------------------
+-# Check hardcoding attributes.
+-AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH],
+-[AC_MSG_CHECKING([how to hardcode library paths into programs])
+-_LT_AC_TAGVAR(hardcode_action, $1)=
+-if test -n "$_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)" || \
+- test -n "$_LT_AC_TAGVAR(runpath_var, $1)" || \
+- test "X$_LT_AC_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then
+-
+- # We can hardcode non-existant directories.
+- if test "$_LT_AC_TAGVAR(hardcode_direct, $1)" != no &&
+- # If the only mechanism to avoid hardcoding is shlibpath_var, we
+- # have to relink, otherwise we might link with an installed library
+- # when we should be linking with a yet-to-be-installed one
+- ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)" != no &&
+- test "$_LT_AC_TAGVAR(hardcode_minus_L, $1)" != no; then
+- # Linking always hardcodes the temporary library directory.
+- _LT_AC_TAGVAR(hardcode_action, $1)=relink
+- else
+- # We can link without hardcoding, and we can hardcode nonexisting dirs.
+- _LT_AC_TAGVAR(hardcode_action, $1)=immediate
++if test -z "$lt_ECHO"; then
++ if test "X${echo_test_string+set}" != Xset; then
++ # find a string as large as possible, as long as the shell can cope with it
++ for cmd in 'sed 50q "[$]0"' 'sed 20q "[$]0"' 'sed 10q "[$]0"' 'sed 2q "[$]0"' 'echo test'; do
++ # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ...
++ if { echo_test_string=`eval $cmd`; } 2>/dev/null &&
++ { test "X$echo_test_string" = "X$echo_test_string"; } 2>/dev/null
++ then
++ break
++ fi
++ done
+ fi
+-else
+- # We cannot hardcode anything, or else we can only hardcode existing
+- # directories.
+- _LT_AC_TAGVAR(hardcode_action, $1)=unsupported
+-fi
+-AC_MSG_RESULT([$_LT_AC_TAGVAR(hardcode_action, $1)])
+
+-if test "$_LT_AC_TAGVAR(hardcode_action, $1)" = relink; then
+- # Fast installation is not supported
+- enable_fast_install=no
+-elif test "$shlibpath_overrides_runpath" = yes ||
+- test "$enable_shared" = no; then
+- # Fast installation is not necessary
+- enable_fast_install=needless
+-fi
+-])# AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH
++ if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' &&
++ echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` &&
++ test "X$echo_testing_string" = "X$echo_test_string"; then
++ :
++ else
++ # The Solaris, AIX, and Digital Unix default echo programs unquote
++ # backslashes. This makes it impossible to quote backslashes using
++ # echo "$something" | sed 's/\\/\\\\/g'
++ #
++ # So, first we look for a working echo in the user's PATH.
+
++ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
++ for dir in $PATH /usr/ucb; do
++ IFS="$lt_save_ifs"
++ if (test -f $dir/echo || test -f $dir/echo$ac_exeext) &&
++ test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' &&
++ echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` &&
++ test "X$echo_testing_string" = "X$echo_test_string"; then
++ ECHO="$dir/echo"
++ break
++ fi
++ done
++ IFS="$lt_save_ifs"
+
+-# AC_LIBTOOL_SYS_LIB_STRIP
+-# ------------------------
+-AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP],
+-[striplib=
+-old_striplib=
+-AC_MSG_CHECKING([whether stripping libraries is possible])
+-if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then
+- test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
+- test -z "$striplib" && striplib="$STRIP --strip-unneeded"
+- AC_MSG_RESULT([yes])
+-else
+-# FIXME - insert some real tests, host_os isn't really good enough
+- case $host_os in
+- darwin*)
+- if test -n "$STRIP" ; then
+- striplib="$STRIP -x"
+- AC_MSG_RESULT([yes])
+- else
+- AC_MSG_RESULT([no])
+-fi
+- ;;
+- *)
+- AC_MSG_RESULT([no])
+- ;;
+- esac
+-fi
+-])# AC_LIBTOOL_SYS_LIB_STRIP
++ if test "X$ECHO" = Xecho; then
++ # We didn't find a better echo, so look for alternatives.
++ if test "X`{ print -r '\t'; } 2>/dev/null`" = 'X\t' &&
++ echo_testing_string=`{ print -r "$echo_test_string"; } 2>/dev/null` &&
++ test "X$echo_testing_string" = "X$echo_test_string"; then
++ # This shell has a builtin print -r that does the trick.
++ ECHO='print -r'
++ elif { test -f /bin/ksh || test -f /bin/ksh$ac_exeext; } &&
++ test "X$CONFIG_SHELL" != X/bin/ksh; then
++ # If we have ksh, try running configure again with it.
++ ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
++ export ORIGINAL_CONFIG_SHELL
++ CONFIG_SHELL=/bin/ksh
++ export CONFIG_SHELL
++ exec $CONFIG_SHELL "[$]0" --no-reexec ${1+"[$]@"}
++ else
++ # Try using printf.
++ ECHO='printf %s\n'
++ if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' &&
++ echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` &&
++ test "X$echo_testing_string" = "X$echo_test_string"; then
++ # Cool, printf works
++ :
++ elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` &&
++ test "X$echo_testing_string" = 'X\t' &&
++ echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
++ test "X$echo_testing_string" = "X$echo_test_string"; then
++ CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL
++ export CONFIG_SHELL
++ SHELL="$CONFIG_SHELL"
++ export SHELL
++ ECHO="$CONFIG_SHELL [$]0 --fallback-echo"
++ elif echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` &&
++ test "X$echo_testing_string" = 'X\t' &&
++ echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
++ test "X$echo_testing_string" = "X$echo_test_string"; then
++ ECHO="$CONFIG_SHELL [$]0 --fallback-echo"
++ else
++ # maybe with a smaller string...
++ prev=:
+
++ for cmd in 'echo test' 'sed 2q "[$]0"' 'sed 10q "[$]0"' 'sed 20q "[$]0"' 'sed 50q "[$]0"'; do
++ if { test "X$echo_test_string" = "X`eval $cmd`"; } 2>/dev/null
++ then
++ break
++ fi
++ prev="$cmd"
++ done
+
+-# AC_LIBTOOL_SYS_DYNAMIC_LINKER
+-# -----------------------------
+-# PORTME Fill in your ld.so characteristics
+-AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER],
+-[AC_MSG_CHECKING([dynamic linker characteristics])
+-library_names_spec=
+-libname_spec='lib$name'
+-soname_spec=
+-shrext_cmds=".so"
+-postinstall_cmds=
+-postuninstall_cmds=
+-finish_cmds=
+-finish_eval=
+-shlibpath_var=
+-shlibpath_overrides_runpath=unknown
+-version_type=none
+-dynamic_linker="$host_os ld.so"
+-sys_lib_dlsearch_path_spec="/lib /usr/lib"
+-if test "$GCC" = yes; then
+- sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+- if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then
+- # if the path contains ";" then we assume it to be the separator
+- # otherwise default to the standard path separator (i.e. ":") - it is
+- # assumed that no part of a normal pathname contains ";" but that should
+- # okay in the real world where ";" in dirpaths is itself problematic.
+- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+- else
+- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
++ if test "$prev" != 'sed 50q "[$]0"'; then
++ echo_test_string=`eval $prev`
++ export echo_test_string
++ exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "[$]0" ${1+"[$]@"}
++ else
++ # Oops. We lost completely, so just stick with echo.
++ ECHO=echo
++ fi
++ fi
++ fi
++ fi
+ fi
+-else
+- sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+ fi
+-need_lib_prefix=unknown
+-hardcode_into_libs=no
+
+-# when you set need_version to no, make sure it does not cause -set_version
+-# flags to be left without arguments
+-need_version=unknown
++# Copy echo and quote the copy suitably for passing to libtool from
++# the Makefile, instead of quoting the original, which is used later.
++lt_ECHO=$ECHO
++if test "X$lt_ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then
++ lt_ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo"
++fi
+
+-case $host_os in
+-aix3*)
+- version_type=linux
+- library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+- shlibpath_var=LIBPATH
++AC_SUBST(lt_ECHO)
++])
++_LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts])
++_LT_DECL([], [ECHO], [1],
++ [An echo program that does not interpret backslashes])
++])# _LT_PROG_ECHO_BACKSLASH
+
+- # AIX 3 has no versioning support, so we append a major version to the name.
+- soname_spec='${libname}${release}${shared_ext}$major'
+- ;;
+
+-aix4* | aix5*)
+- version_type=linux
+- need_lib_prefix=no
+- need_version=no
+- hardcode_into_libs=yes
+- if test "$host_cpu" = ia64; then
+- # AIX 5 supports IA64
+- library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+- shlibpath_var=LD_LIBRARY_PATH
+- else
+- # With GCC up to 2.95.x, collect2 would create an import file
+- # for dependence libraries. The import file would start with
+- # the line `#! .'. This would cause the generated library to
+- # depend on `.', always an invalid library. This was fixed in
+- # development snapshots of GCC prior to 3.0.
+- case $host_os in
+- aix4 | aix4.[[01]] | aix4.[[01]].*)
+- if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
+- echo ' yes '
+- echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then
+- :
+- else
+- can_build_shared=no
+- fi
+- ;;
++# _LT_ENABLE_LOCK
++# ---------------
++m4_defun([_LT_ENABLE_LOCK],
++[AC_ARG_ENABLE([libtool-lock],
++ [AS_HELP_STRING([--disable-libtool-lock],
++ [avoid locking (might break parallel builds)])])
++test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
++
++# Some flags need to be propagated to the compiler or linker for good
++# libtool support.
++case $host in
++ia64-*-hpux*)
++ # Find out which ABI we are using.
++ echo 'int i;' > conftest.$ac_ext
++ if AC_TRY_EVAL(ac_compile); then
++ case `/usr/bin/file conftest.$ac_objext` in
++ *ELF-32*)
++ HPUX_IA64_MODE="32"
++ ;;
++ *ELF-64*)
++ HPUX_IA64_MODE="64"
++ ;;
+ esac
+- # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+- # soname into executable. Probably we can add versioning support to
+- # collect2, so additional links can be useful in future.
+- if test "$aix_use_runtimelinking" = yes; then
+- # If using run time linking (on AIX 4.2 or later) use lib<name>.so
+- # instead of lib<name>.a to let people know that these are not
+- # typical AIX shared libraries.
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
++ fi
++ rm -rf conftest*
++ ;;
++*-*-irix6*)
++ # Find out which ABI we are using.
++ echo '[#]line __oline__ "configure"' > conftest.$ac_ext
++ if AC_TRY_EVAL(ac_compile); then
++ if test "$lt_cv_prog_gnu_ld" = yes; then
++ case `/usr/bin/file conftest.$ac_objext` in
++ *32-bit*)
++ LD="${LD-ld} -melf32bsmip"
++ ;;
++ *N32*)
++ LD="${LD-ld} -melf32bmipn32"
++ ;;
++ *64-bit*)
++ LD="${LD-ld} -melf64bmip"
++ ;;
++ esac
+ else
+- # We preserve .a as extension for shared libraries through AIX4.2
+- # and later when we are not doing run time linking.
+- library_names_spec='${libname}${release}.a $libname.a'
+- soname_spec='${libname}${release}${shared_ext}$major'
++ case `/usr/bin/file conftest.$ac_objext` in
++ *32-bit*)
++ LD="${LD-ld} -32"
++ ;;
++ *N32*)
++ LD="${LD-ld} -n32"
++ ;;
++ *64-bit*)
++ LD="${LD-ld} -64"
++ ;;
++ esac
+ fi
+- shlibpath_var=LIBPATH
+ fi
++ rm -rf conftest*
+ ;;
+
+-amigaos*)
+- library_names_spec='$libname.ixlibrary $libname.a'
+- # Create ${libname}_ixlibrary.a entries in /sys/libs.
+- finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
++x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
++s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
++ # Find out which ABI we are using.
++ echo 'int i;' > conftest.$ac_ext
++ if AC_TRY_EVAL(ac_compile); then
++ case `/usr/bin/file conftest.o` in
++ *32-bit*)
++ case $host in
++ x86_64-*kfreebsd*-gnu)
++ LD="${LD-ld} -m elf_i386_fbsd"
++ ;;
++ x86_64-*linux*)
++ LD="${LD-ld} -m elf_i386"
++ ;;
++ ppc64-*linux*|powerpc64-*linux*)
++ LD="${LD-ld} -m elf32ppclinux"
++ ;;
++ s390x-*linux*)
++ LD="${LD-ld} -m elf_s390"
++ ;;
++ sparc64-*linux*)
++ LD="${LD-ld} -m elf32_sparc"
++ ;;
++ esac
++ ;;
++ *64-bit*)
++ case $host in
++ x86_64-*kfreebsd*-gnu)
++ LD="${LD-ld} -m elf_x86_64_fbsd"
++ ;;
++ x86_64-*linux*)
++ LD="${LD-ld} -m elf_x86_64"
++ ;;
++ ppc*-*linux*|powerpc*-*linux*)
++ LD="${LD-ld} -m elf64ppc"
++ ;;
++ s390*-*linux*|s390*-*tpf*)
++ LD="${LD-ld} -m elf64_s390"
++ ;;
++ sparc*-*linux*)
++ LD="${LD-ld} -m elf64_sparc"
++ ;;
++ esac
++ ;;
++ esac
++ fi
++ rm -rf conftest*
+ ;;
+
+-beos*)
+- library_names_spec='${libname}${shared_ext}'
+- dynamic_linker="$host_os ld.so"
+- shlibpath_var=LIBRARY_PATH
++*-*-sco3.2v5*)
++ # On SCO OpenServer 5, we need -belf to get full-featured binaries.
++ SAVE_CFLAGS="$CFLAGS"
++ CFLAGS="$CFLAGS -belf"
++ AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
++ [AC_LANG_PUSH(C)
++ AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])
++ AC_LANG_POP])
++ if test x"$lt_cv_cc_needs_belf" != x"yes"; then
++ # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
++ CFLAGS="$SAVE_CFLAGS"
++ fi
+ ;;
+-
+-bsdi[[45]]*)
+- version_type=linux
+- need_version=no
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
+- shlibpath_var=LD_LIBRARY_PATH
+- sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
+- sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
+- # the default ld.so.conf also contains /usr/contrib/lib and
+- # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
+- # libtool to hard-code these into programs
++sparc*-*solaris*)
++ # Find out which ABI we are using.
++ echo 'int i;' > conftest.$ac_ext
++ if AC_TRY_EVAL(ac_compile); then
++ case `/usr/bin/file conftest.o` in
++ *64-bit*)
++ case $lt_cv_prog_gnu_ld in
++ yes*) LD="${LD-ld} -m elf64_sparc" ;;
++ *)
++ if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then
++ LD="${LD-ld} -64"
++ fi
++ ;;
++ esac
++ ;;
++ esac
++ fi
++ rm -rf conftest*
+ ;;
++esac
+
+-cygwin* | mingw* | pw32*)
+- version_type=windows
+- shrext_cmds=".dll"
+- need_version=no
+- need_lib_prefix=no
++need_locks="$enable_libtool_lock"
++])# _LT_ENABLE_LOCK
+
+- case $GCC,$host_os in
+- yes,cygwin* | yes,mingw* | yes,pw32*)
+- library_names_spec='$libname.dll.a'
+- # DLL is installed to $(libdir)/../bin by postinstall_cmds
+- postinstall_cmds='base_file=`basename \${file}`~
+- dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
+- dldir=$destdir/`dirname \$dlpath`~
+- test -d \$dldir || mkdir -p \$dldir~
+- $install_prog $dir/$dlname \$dldir/$dlname~
+- chmod a+x \$dldir/$dlname'
+- postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+- dlpath=$dir/\$dldll~
+- $rm \$dlpath'
+- shlibpath_overrides_runpath=yes
+
+- case $host_os in
+- cygwin*)
+- # Cygwin DLLs use 'cyg' prefix rather than 'lib'
+- soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+- sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
+- ;;
+- mingw*)
+- # MinGW DLLs use traditional 'lib' prefix
+- soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+- sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+- if echo "$sys_lib_search_path_spec" | [grep ';[c-zC-Z]:/' >/dev/null]; then
+- # It is most probably a Windows format PATH printed by
+- # mingw gcc, but we are running on Cygwin. Gcc prints its search
+- # path with ; separators, and with drive letters. We can handle the
+- # drive letters (cygwin fileutils understands them), so leave them,
+- # especially as we might pass files found there to a mingw objdump,
+- # which wouldn't understand a cygwinified path. Ahh.
+- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+- else
+- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
+- fi
+- ;;
+- pw32*)
+- # pw32 DLLs use 'pw' prefix rather than 'lib'
+- library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+- ;;
+- esac
+- ;;
++# _LT_CMD_OLD_ARCHIVE
++# -------------------
++m4_defun([_LT_CMD_OLD_ARCHIVE],
++[AC_CHECK_TOOL(AR, ar, false)
++test -z "$AR" && AR=ar
++test -z "$AR_FLAGS" && AR_FLAGS=cru
++_LT_DECL([], [AR], [1], [The archiver])
++_LT_DECL([], [AR_FLAGS], [1])
++
++AC_CHECK_TOOL(STRIP, strip, :)
++test -z "$STRIP" && STRIP=:
++_LT_DECL([], [STRIP], [1], [A symbol stripping program])
++
++AC_CHECK_TOOL(RANLIB, ranlib, :)
++test -z "$RANLIB" && RANLIB=:
++_LT_DECL([], [RANLIB], [1],
++ [Commands used to install an old-style archive])
++
++# Determine commands to create old-style static archives.
++old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs'
++old_postinstall_cmds='chmod 644 $oldlib'
++old_postuninstall_cmds=
+
++if test -n "$RANLIB"; then
++ case $host_os in
++ openbsd*)
++ old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib"
++ ;;
+ *)
+- library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib'
++ old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib"
+ ;;
+ esac
+- dynamic_linker='Win32 ld.exe'
+- # FIXME: first we should search . and the directory the executable is in
+- shlibpath_var=PATH
+- ;;
++ old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
++fi
++_LT_DECL([], [old_postinstall_cmds], [2])
++_LT_DECL([], [old_postuninstall_cmds], [2])
++_LT_TAGDECL([], [old_archive_cmds], [2],
++ [Commands used to build an old-style archive])
++])# _LT_CMD_OLD_ARCHIVE
+
+-darwin* | rhapsody*)
+- dynamic_linker="$host_os dyld"
+- version_type=darwin
+- need_lib_prefix=no
+- need_version=no
+- library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext'
+- soname_spec='${libname}${release}${major}$shared_ext'
+- shlibpath_overrides_runpath=yes
+- shlibpath_var=DYLD_LIBRARY_PATH
+- shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
+- # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same.
+- if test "$GCC" = yes; then
+- sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"`
+- else
+- sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib'
+- fi
+- sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
+- ;;
+
+-dgux*)
+- version_type=linux
+- need_lib_prefix=no
+- need_version=no
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- shlibpath_var=LD_LIBRARY_PATH
+- ;;
++# _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
++# [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE])
++# ----------------------------------------------------------------
++# Check whether the given compiler option works
++AC_DEFUN([_LT_COMPILER_OPTION],
++[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
++m4_require([_LT_DECL_SED])dnl
++AC_CACHE_CHECK([$1], [$2],
++ [$2=no
++ m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4])
++ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
++ lt_compiler_flag="$3"
++ # Insert the option either (1) after the last *FLAGS variable, or
++ # (2) before a word containing "conftest.", or (3) at the end.
++ # Note that $ac_compile itself does not contain backslashes and begins
++ # with a dollar sign (not a hyphen), so the echo should work correctly.
++ # The option is referenced via a variable to avoid confusing sed.
++ lt_compile=`echo "$ac_compile" | $SED \
++ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
++ -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
++ -e 's:$: $lt_compiler_flag:'`
++ (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
++ (eval "$lt_compile" 2>conftest.err)
++ ac_status=$?
++ cat conftest.err >&AS_MESSAGE_LOG_FD
++ echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
++ if (exit $ac_status) && test -s "$ac_outfile"; then
++ # The compiler can only warn and ignore the option if not recognized
++ # So say no if there are warnings other than the usual output.
++ $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
++ $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
++ if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
++ $2=yes
++ fi
++ fi
++ $RM conftest*
++])
+
+-freebsd1*)
+- dynamic_linker=no
+- ;;
++if test x"[$]$2" = xyes; then
++ m4_if([$5], , :, [$5])
++else
++ m4_if([$6], , :, [$6])
++fi
++])# _LT_COMPILER_OPTION
+
+-kfreebsd*-gnu)
+- version_type=linux
+- need_lib_prefix=no
+- need_version=no
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- shlibpath_var=LD_LIBRARY_PATH
+- shlibpath_overrides_runpath=no
+- hardcode_into_libs=yes
+- dynamic_linker='GNU ld.so'
+- ;;
++# Old name:
++AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION])
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], [])
+
+-freebsd* | dragonfly*)
+- # DragonFly does not have aout. When/if they implement a new
+- # versioning mechanism, adjust this.
+- if test -x /usr/bin/objformat; then
+- objformat=`/usr/bin/objformat`
+- else
+- case $host_os in
+- freebsd[[123]]*) objformat=aout ;;
+- *) objformat=elf ;;
+- esac
+- fi
+- version_type=freebsd-$objformat
+- case $version_type in
+- freebsd-elf*)
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+- need_version=no
+- need_lib_prefix=no
+- ;;
+- freebsd-*)
+- library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+- need_version=yes
+- ;;
+- esac
+- shlibpath_var=LD_LIBRARY_PATH
+- case $host_os in
+- freebsd2*)
+- shlibpath_overrides_runpath=yes
+- ;;
+- freebsd3.[[01]]* | freebsdelf3.[[01]]*)
+- shlibpath_overrides_runpath=yes
+- hardcode_into_libs=yes
++
++# _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
++# [ACTION-SUCCESS], [ACTION-FAILURE])
++# ----------------------------------------------------
++# Check whether the given linker option works
++AC_DEFUN([_LT_LINKER_OPTION],
++[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
++m4_require([_LT_DECL_SED])dnl
++AC_CACHE_CHECK([$1], [$2],
++ [$2=no
++ save_LDFLAGS="$LDFLAGS"
++ LDFLAGS="$LDFLAGS $3"
++ echo "$lt_simple_link_test_code" > conftest.$ac_ext
++ if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
++ # The linker can only warn and ignore the option if not recognized
++ # So say no if there are warnings
++ if test -s conftest.err; then
++ # Append any errors to the config.log.
++ cat conftest.err 1>&AS_MESSAGE_LOG_FD
++ $ECHO "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
++ $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
++ if diff conftest.exp conftest.er2 >/dev/null; then
++ $2=yes
++ fi
++ else
++ $2=yes
++ fi
++ fi
++ $RM -r conftest*
++ LDFLAGS="$save_LDFLAGS"
++])
++
++if test x"[$]$2" = xyes; then
++ m4_if([$4], , :, [$4])
++else
++ m4_if([$5], , :, [$5])
++fi
++])# _LT_LINKER_OPTION
++
++# Old name:
++AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION])
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], [])
++
++
++# LT_CMD_MAX_LEN
++#---------------
++AC_DEFUN([LT_CMD_MAX_LEN],
++[AC_REQUIRE([AC_CANONICAL_HOST])dnl
++# find the maximum length of command line arguments
++AC_MSG_CHECKING([the maximum length of command line arguments])
++AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
++ i=0
++ teststring="ABCD"
++
++ case $build_os in
++ msdosdjgpp*)
++ # On DJGPP, this test can blow up pretty badly due to problems in libc
++ # (any single argument exceeding 2000 bytes causes a buffer overrun
++ # during glob expansion). Even if it were fixed, the result of this
++ # check would be larger than it should be.
++ lt_cv_sys_max_cmd_len=12288; # 12K is about right
+ ;;
+- freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \
+- freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1)
+- shlibpath_overrides_runpath=no
+- hardcode_into_libs=yes
++
++ gnu*)
++ # Under GNU Hurd, this test is not required because there is
++ # no limit to the length of command line arguments.
++ # Libtool will interpret -1 as no limit whatsoever
++ lt_cv_sys_max_cmd_len=-1;
+ ;;
+- freebsd*) # from 4.6 on
+- shlibpath_overrides_runpath=yes
+- hardcode_into_libs=yes
++
++ cygwin* | mingw*)
++ # On Win9x/ME, this test blows up -- it succeeds, but takes
++ # about 5 minutes as the teststring grows exponentially.
++ # Worse, since 9x/ME are not pre-emptively multitasking,
++ # you end up with a "frozen" computer, even though with patience
++ # the test eventually succeeds (with a max line length of 256k).
++ # Instead, let's just punt: use the minimum linelength reported by
++ # all of the supported platforms: 8192 (on NT/2K/XP).
++ lt_cv_sys_max_cmd_len=8192;
+ ;;
+- esac
+- ;;
+
+-gnu*)
+- version_type=linux
+- need_lib_prefix=no
+- need_version=no
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- shlibpath_var=LD_LIBRARY_PATH
+- hardcode_into_libs=yes
+- ;;
++ amigaos*)
++ # On AmigaOS with pdksh, this test takes hours, literally.
++ # So we just punt and use a minimum line length of 8192.
++ lt_cv_sys_max_cmd_len=8192;
++ ;;
+
+-hpux9* | hpux10* | hpux11*)
+- # Give a soname corresponding to the major version so that dld.sl refuses to
+- # link against other versions.
+- version_type=sunos
+- need_lib_prefix=no
+- need_version=no
+- case $host_cpu in
+- ia64*)
+- shrext_cmds='.so'
+- hardcode_into_libs=yes
+- dynamic_linker="$host_os dld.so"
+- shlibpath_var=LD_LIBRARY_PATH
+- shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- if test "X$HPUX_IA64_MODE" = X32; then
+- sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
++ netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
++ # This has been around since 386BSD, at least. Likely further.
++ if test -x /sbin/sysctl; then
++ lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
++ elif test -x /usr/sbin/sysctl; then
++ lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
+ else
+- sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
++ lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs
+ fi
+- sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+- ;;
+- hppa*64*)
+- shrext_cmds='.sl'
+- hardcode_into_libs=yes
+- dynamic_linker="$host_os dld.sl"
+- shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
+- shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
+- sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+- ;;
+- *)
+- shrext_cmds='.sl'
+- dynamic_linker="$host_os dld.sl"
+- shlibpath_var=SHLIB_PATH
+- shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
++ # And add a safety zone
++ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
++ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+ ;;
+- esac
+- # HP-UX runs *really* slowly unless shared libraries are mode 555.
+- postinstall_cmds='chmod 555 $lib'
+- ;;
+
+-interix3*)
+- version_type=linux
+- need_lib_prefix=no
+- need_version=no
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
+- shlibpath_var=LD_LIBRARY_PATH
+- shlibpath_overrides_runpath=no
+- hardcode_into_libs=yes
+- ;;
++ interix*)
++ # We know the value 262144 and hardcode it with a safety zone (like BSD)
++ lt_cv_sys_max_cmd_len=196608
++ ;;
+
+-irix5* | irix6* | nonstopux*)
+- case $host_os in
+- nonstopux*) version_type=nonstopux ;;
+- *)
+- if test "$lt_cv_prog_gnu_ld" = yes; then
+- version_type=linux
+- else
+- version_type=irix
+- fi ;;
+- esac
+- need_lib_prefix=no
+- need_version=no
+- soname_spec='${libname}${release}${shared_ext}$major'
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+- case $host_os in
+- irix5* | nonstopux*)
+- libsuff= shlibsuff=
++ osf*)
++ # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
++ # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
++ # nice to cause kernel panics so lets avoid the loop below.
++ # First set a reasonable default.
++ lt_cv_sys_max_cmd_len=16384
++ #
++ if test -x /sbin/sysconfig; then
++ case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
++ *1*) lt_cv_sys_max_cmd_len=-1 ;;
++ esac
++ fi
++ ;;
++ sco3.2v5*)
++ lt_cv_sys_max_cmd_len=102400
++ ;;
++ sysv5* | sco5v6* | sysv4.2uw2*)
++ kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
++ if test -n "$kargmax"; then
++ lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'`
++ else
++ lt_cv_sys_max_cmd_len=32768
++ fi
+ ;;
+ *)
+- case $LD in # libtool.m4 will add one of these switches to LD
+- *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
+- libsuff= shlibsuff= libmagic=32-bit;;
+- *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
+- libsuff=32 shlibsuff=N32 libmagic=N32;;
+- *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
+- libsuff=64 shlibsuff=64 libmagic=64-bit;;
+- *) libsuff= shlibsuff= libmagic=never-match;;
+- esac
++ lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`
++ if test -n "$lt_cv_sys_max_cmd_len"; then
++ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
++ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
++ else
++ # Make teststring a little bigger before we do anything with it.
++ # a 1K string should be a reasonable start.
++ for i in 1 2 3 4 5 6 7 8 ; do
++ teststring=$teststring$teststring
++ done
++ SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
++ # If test is not a shell built-in, we'll probably end up computing a
++ # maximum length that is only half of the actual maximum length, but
++ # we can't tell.
++ while { test "X"`$SHELL [$]0 --fallback-echo "X$teststring$teststring" 2>/dev/null` \
++ = "XX$teststring$teststring"; } >/dev/null 2>&1 &&
++ test $i != 17 # 1/2 MB should be enough
++ do
++ i=`expr $i + 1`
++ teststring=$teststring$teststring
++ done
++ # Only check the string length outside the loop.
++ lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1`
++ teststring=
++ # Add a significant safety factor because C++ compilers can tack on
++ # massive amounts of additional arguments before passing them to the
++ # linker. It appears as though 1/2 is a usable value.
++ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
++ fi
+ ;;
+ esac
+- shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
+- shlibpath_overrides_runpath=no
+- sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
+- sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+- hardcode_into_libs=yes
+- ;;
++])
++if test -n $lt_cv_sys_max_cmd_len ; then
++ AC_MSG_RESULT($lt_cv_sys_max_cmd_len)
++else
++ AC_MSG_RESULT(none)
++fi
++max_cmd_len=$lt_cv_sys_max_cmd_len
++_LT_DECL([], [max_cmd_len], [0],
++ [What is the maximum length of a command?])
++])# LT_CMD_MAX_LEN
+
+-# No shared lib support for Linux oldld, aout, or coff.
+-linux*oldld* | linux*aout* | linux*coff*)
+- dynamic_linker=no
+- ;;
++# Old name:
++AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN])
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], [])
+
+-# This must be Linux ELF.
+-linux*)
+- version_type=linux
+- need_lib_prefix=no
+- need_version=no
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
+- shlibpath_var=LD_LIBRARY_PATH
+- shlibpath_overrides_runpath=no
+- # This implies no fast_install, which is unacceptable.
+- # Some rework will be needed to allow for fast_install
+- # before this can be enabled.
+- hardcode_into_libs=yes
+
+- # Append ld.so.conf contents to the search path
+- if test -f /etc/ld.so.conf; then
+- lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
+- sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+- fi
++# _LT_HEADER_DLFCN
++# ----------------
++m4_defun([_LT_HEADER_DLFCN],
++[AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl
++])# _LT_HEADER_DLFCN
+
+- # We used to test for /lib/ld.so.1 and disable shared libraries on
+- # powerpc, because MkLinux only supported shared libraries with the
+- # GNU dynamic linker. Since this was broken with cross compilers,
+- # most powerpc-linux boxes support dynamic linking these days and
+- # people can always --disable-shared, the test was removed, and we
+- # assume the GNU/Linux dynamic linker is in use.
+- dynamic_linker='GNU/Linux ld.so'
+- ;;
+
+-knetbsd*-gnu)
+- version_type=linux
+- need_lib_prefix=no
+- need_version=no
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- shlibpath_var=LD_LIBRARY_PATH
+- shlibpath_overrides_runpath=no
+- hardcode_into_libs=yes
+- dynamic_linker='GNU ld.so'
+- ;;
++# _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE,
++# ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING)
++# ----------------------------------------------------------------
++m4_defun([_LT_TRY_DLOPEN_SELF],
++[m4_require([_LT_HEADER_DLFCN])dnl
++if test "$cross_compiling" = yes; then :
++ [$4]
++else
++ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
++ lt_status=$lt_dlunknown
++ cat > conftest.$ac_ext <<_LT_EOF
++[#line __oline__ "configure"
++#include "confdefs.h"
+
+-netbsd*)
+- version_type=sunos
+- need_lib_prefix=no
+- need_version=no
+- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+- finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+- dynamic_linker='NetBSD (a.out) ld.so'
+- else
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- dynamic_linker='NetBSD ld.elf_so'
+- fi
+- shlibpath_var=LD_LIBRARY_PATH
+- shlibpath_overrides_runpath=yes
+- hardcode_into_libs=yes
+- ;;
++#if HAVE_DLFCN_H
++#include <dlfcn.h>
++#endif
+
+-newsos6)
+- version_type=linux
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+- shlibpath_var=LD_LIBRARY_PATH
+- shlibpath_overrides_runpath=yes
+- ;;
++#include <stdio.h>
+
+-nto-qnx*)
+- version_type=linux
+- need_lib_prefix=no
+- need_version=no
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- shlibpath_var=LD_LIBRARY_PATH
+- shlibpath_overrides_runpath=yes
+- ;;
++#ifdef RTLD_GLOBAL
++# define LT_DLGLOBAL RTLD_GLOBAL
++#else
++# ifdef DL_GLOBAL
++# define LT_DLGLOBAL DL_GLOBAL
++# else
++# define LT_DLGLOBAL 0
++# endif
++#endif
+
+-openbsd*)
+- version_type=sunos
+- sys_lib_dlsearch_path_spec="/usr/lib"
+- need_lib_prefix=no
+- # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
+- case $host_os in
+- openbsd3.3 | openbsd3.3.*) need_version=yes ;;
+- *) need_version=no ;;
+- esac
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+- finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+- shlibpath_var=LD_LIBRARY_PATH
+- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+- case $host_os in
+- openbsd2.[[89]] | openbsd2.[[89]].*)
+- shlibpath_overrides_runpath=no
+- ;;
+- *)
+- shlibpath_overrides_runpath=yes
+- ;;
+- esac
++/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
++ find out it does not work in some platform. */
++#ifndef LT_DLLAZY_OR_NOW
++# ifdef RTLD_LAZY
++# define LT_DLLAZY_OR_NOW RTLD_LAZY
++# else
++# ifdef DL_LAZY
++# define LT_DLLAZY_OR_NOW DL_LAZY
++# else
++# ifdef RTLD_NOW
++# define LT_DLLAZY_OR_NOW RTLD_NOW
++# else
++# ifdef DL_NOW
++# define LT_DLLAZY_OR_NOW DL_NOW
++# else
++# define LT_DLLAZY_OR_NOW 0
++# endif
++# endif
++# endif
++# endif
++#endif
++
++#ifdef __cplusplus
++extern "C" void exit (int);
++#endif
++
++void fnord() { int i=42;}
++int main ()
++{
++ void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
++ int status = $lt_dlunknown;
++
++ if (self)
++ {
++ if (dlsym (self,"fnord")) status = $lt_dlno_uscore;
++ else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
++ /* dlclose (self); */
++ }
+ else
+- shlibpath_overrides_runpath=yes
++ puts (dlerror ());
++
++ exit (status);
++}]
++_LT_EOF
++ if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then
++ (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null
++ lt_status=$?
++ case x$lt_status in
++ x$lt_dlno_uscore) $1 ;;
++ x$lt_dlneed_uscore) $2 ;;
++ x$lt_dlunknown|x*) $3 ;;
++ esac
++ else :
++ # compilation failed
++ $3
+ fi
+- ;;
++fi
++rm -fr conftest*
++])# _LT_TRY_DLOPEN_SELF
+
+-os2*)
+- libname_spec='$name'
+- shrext_cmds=".dll"
+- need_lib_prefix=no
+- library_names_spec='$libname${shared_ext} $libname.a'
+- dynamic_linker='OS/2 ld.exe'
+- shlibpath_var=LIBPATH
+- ;;
+
+-osf3* | osf4* | osf5*)
+- version_type=osf
+- need_lib_prefix=no
+- need_version=no
+- soname_spec='${libname}${release}${shared_ext}$major'
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+- shlibpath_var=LD_LIBRARY_PATH
+- sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
+- sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+- ;;
++# LT_SYS_DLOPEN_SELF
++# ------------------
++AC_DEFUN([LT_SYS_DLOPEN_SELF],
++[m4_require([_LT_HEADER_DLFCN])dnl
++if test "x$enable_dlopen" != xyes; then
++ enable_dlopen=unknown
++ enable_dlopen_self=unknown
++ enable_dlopen_self_static=unknown
++else
++ lt_cv_dlopen=no
++ lt_cv_dlopen_libs=
+
+-solaris*)
+- version_type=linux
+- need_lib_prefix=no
+- need_version=no
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- shlibpath_var=LD_LIBRARY_PATH
+- shlibpath_overrides_runpath=yes
+- hardcode_into_libs=yes
+- # ldd complains unless libraries are executable
+- postinstall_cmds='chmod +x $lib'
+- ;;
++ case $host_os in
++ beos*)
++ lt_cv_dlopen="load_add_on"
++ lt_cv_dlopen_libs=
++ lt_cv_dlopen_self=yes
++ ;;
+
+-sunos4*)
+- version_type=sunos
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+- finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
+- shlibpath_var=LD_LIBRARY_PATH
+- shlibpath_overrides_runpath=yes
+- if test "$with_gnu_ld" = yes; then
+- need_lib_prefix=no
+- fi
+- need_version=yes
+- ;;
++ mingw* | pw32*)
++ lt_cv_dlopen="LoadLibrary"
++ lt_cv_dlopen_libs=
++ ;;
+
+-sysv4 | sysv4.3*)
+- version_type=linux
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- shlibpath_var=LD_LIBRARY_PATH
+- case $host_vendor in
+- sni)
+- shlibpath_overrides_runpath=no
+- need_lib_prefix=no
+- export_dynamic_flag_spec='${wl}-Blargedynsym'
+- runpath_var=LD_RUN_PATH
+- ;;
+- siemens)
+- need_lib_prefix=no
+- ;;
+- motorola)
+- need_lib_prefix=no
+- need_version=no
+- shlibpath_overrides_runpath=no
+- sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
+- ;;
+- esac
+- ;;
++ cygwin*)
++ lt_cv_dlopen="dlopen"
++ lt_cv_dlopen_libs=
++ ;;
+
+-sysv4*MP*)
+- if test -d /usr/nec ;then
+- version_type=linux
+- library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
+- soname_spec='$libname${shared_ext}.$major'
+- shlibpath_var=LD_LIBRARY_PATH
+- fi
+- ;;
++ darwin*)
++ # if libdl is installed we need to link against it
++ AC_CHECK_LIB([dl], [dlopen],
++ [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[
++ lt_cv_dlopen="dyld"
++ lt_cv_dlopen_libs=
++ lt_cv_dlopen_self=yes
++ ])
++ ;;
+
+-sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+- version_type=freebsd-elf
+- need_lib_prefix=no
+- need_version=no
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- shlibpath_var=LD_LIBRARY_PATH
+- hardcode_into_libs=yes
+- if test "$with_gnu_ld" = yes; then
+- sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
+- shlibpath_overrides_runpath=no
++ *)
++ AC_CHECK_FUNC([shl_load],
++ [lt_cv_dlopen="shl_load"],
++ [AC_CHECK_LIB([dld], [shl_load],
++ [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"],
++ [AC_CHECK_FUNC([dlopen],
++ [lt_cv_dlopen="dlopen"],
++ [AC_CHECK_LIB([dl], [dlopen],
++ [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],
++ [AC_CHECK_LIB([svld], [dlopen],
++ [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"],
++ [AC_CHECK_LIB([dld], [dld_link],
++ [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"])
++ ])
++ ])
++ ])
++ ])
++ ])
++ ;;
++ esac
++
++ if test "x$lt_cv_dlopen" != xno; then
++ enable_dlopen=yes
+ else
+- sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
+- shlibpath_overrides_runpath=yes
+- case $host_os in
+- sco3.2v5*)
+- sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
+- ;;
+- esac
++ enable_dlopen=no
+ fi
+- sys_lib_dlsearch_path_spec='/usr/lib'
+- ;;
+-
+-uts4*)
+- version_type=linux
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- shlibpath_var=LD_LIBRARY_PATH
+- ;;
+-
+-*)
+- dynamic_linker=no
+- ;;
+-esac
+-AC_MSG_RESULT([$dynamic_linker])
+-test "$dynamic_linker" = no && can_build_shared=no
+-
+-variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
+-if test "$GCC" = yes; then
+- variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
+-fi
+-])# AC_LIBTOOL_SYS_DYNAMIC_LINKER
+-
+
+-# _LT_AC_TAGCONFIG
+-# ----------------
+-AC_DEFUN([_LT_AC_TAGCONFIG],
+-[AC_ARG_WITH([tags],
+- [AC_HELP_STRING([--with-tags@<:@=TAGS@:>@],
+- [include additional configurations @<:@automatic@:>@])],
+- [tagnames="$withval"])
+-
+-if test -f "$ltmain" && test -n "$tagnames"; then
+- if test ! -f "${ofile}"; then
+- AC_MSG_WARN([output file `$ofile' does not exist])
+- fi
++ case $lt_cv_dlopen in
++ dlopen)
++ save_CPPFLAGS="$CPPFLAGS"
++ test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
+
+- if test -z "$LTCC"; then
+- eval "`$SHELL ${ofile} --config | grep '^LTCC='`"
+- if test -z "$LTCC"; then
+- AC_MSG_WARN([output file `$ofile' does not look like a libtool script])
+- else
+- AC_MSG_WARN([using `LTCC=$LTCC', extracted from `$ofile'])
+- fi
+- fi
+- if test -z "$LTCFLAGS"; then
+- eval "`$SHELL ${ofile} --config | grep '^LTCFLAGS='`"
+- fi
++ save_LDFLAGS="$LDFLAGS"
++ wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
+
+- # Extract list of available tagged configurations in $ofile.
+- # Note that this assumes the entire list is on one line.
+- available_tags=`grep "^available_tags=" "${ofile}" | $SED -e 's/available_tags=\(.*$\)/\1/' -e 's/\"//g'`
++ save_LIBS="$LIBS"
++ LIBS="$lt_cv_dlopen_libs $LIBS"
+
+- lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+- for tagname in $tagnames; do
+- IFS="$lt_save_ifs"
+- # Check whether tagname contains only valid characters
+- case `$echo "X$tagname" | $Xsed -e 's:[[-_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890,/]]::g'` in
+- "") ;;
+- *) AC_MSG_ERROR([invalid tag name: $tagname])
+- ;;
+- esac
++ AC_CACHE_CHECK([whether a program can dlopen itself],
++ lt_cv_dlopen_self, [dnl
++ _LT_TRY_DLOPEN_SELF(
++ lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes,
++ lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross)
++ ])
+
+- if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "${ofile}" > /dev/null
+- then
+- AC_MSG_ERROR([tag name \"$tagname\" already exists])
++ if test "x$lt_cv_dlopen_self" = xyes; then
++ wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
++ AC_CACHE_CHECK([whether a statically linked program can dlopen itself],
++ lt_cv_dlopen_self_static, [dnl
++ _LT_TRY_DLOPEN_SELF(
++ lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes,
++ lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross)
++ ])
+ fi
+
+- # Update the list of available tags.
+- if test -n "$tagname"; then
+- echo appending configuration tag \"$tagname\" to $ofile
+-
+- case $tagname in
+- CXX)
+- if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
+- ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
+- (test "X$CXX" != "Xg++"))) ; then
+- AC_LIBTOOL_LANG_CXX_CONFIG
+- else
+- tagname=""
+- fi
+- ;;
+-
+- F77)
+- if test -n "$F77" && test "X$F77" != "Xno"; then
+- AC_LIBTOOL_LANG_F77_CONFIG
+- else
+- tagname=""
+- fi
+- ;;
+-
+- GCJ)
+- if test -n "$GCJ" && test "X$GCJ" != "Xno"; then
+- AC_LIBTOOL_LANG_GCJ_CONFIG
+- else
+- tagname=""
+- fi
+- ;;
+-
+- RC)
+- AC_LIBTOOL_LANG_RC_CONFIG
+- ;;
+-
+- *)
+- AC_MSG_ERROR([Unsupported tag name: $tagname])
+- ;;
+- esac
++ CPPFLAGS="$save_CPPFLAGS"
++ LDFLAGS="$save_LDFLAGS"
++ LIBS="$save_LIBS"
++ ;;
++ esac
+
+- # Append the new tag name to the list of available tags.
+- if test -n "$tagname" ; then
+- available_tags="$available_tags $tagname"
+- fi
+- fi
+- done
+- IFS="$lt_save_ifs"
++ case $lt_cv_dlopen_self in
++ yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
++ *) enable_dlopen_self=unknown ;;
++ esac
+
+- # Now substitute the updated list of available tags.
+- if eval "sed -e 's/^available_tags=.*\$/available_tags=\"$available_tags\"/' \"$ofile\" > \"${ofile}T\""; then
+- mv "${ofile}T" "$ofile"
+- chmod +x "$ofile"
+- else
+- rm -f "${ofile}T"
+- AC_MSG_ERROR([unable to update list of available tagged configurations.])
+- fi
++ case $lt_cv_dlopen_self_static in
++ yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
++ *) enable_dlopen_self_static=unknown ;;
++ esac
+ fi
+-])# _LT_AC_TAGCONFIG
++_LT_DECL([dlopen_support], [enable_dlopen], [0],
++ [Whether dlopen is supported])
++_LT_DECL([dlopen_self], [enable_dlopen_self], [0],
++ [Whether dlopen of programs is supported])
++_LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0],
++ [Whether dlopen of statically linked programs is supported])
++])# LT_SYS_DLOPEN_SELF
++
++# Old name:
++AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF])
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], [])
+
+
+-# AC_LIBTOOL_DLOPEN
+-# -----------------
+-# enable checks for dlopen support
+-AC_DEFUN([AC_LIBTOOL_DLOPEN],
+- [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])
+-])# AC_LIBTOOL_DLOPEN
++# _LT_COMPILER_C_O([TAGNAME])
++# ---------------------------
++# Check to see if options -c and -o are simultaneously supported by compiler.
++# This macro does not hard code the compiler like AC_PROG_CC_C_O.
++m4_defun([_LT_COMPILER_C_O],
++[m4_require([_LT_DECL_SED])dnl
++m4_require([_LT_FILEUTILS_DEFAULTS])dnl
++m4_require([_LT_TAG_COMPILER])dnl
++AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext],
++ [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)],
++ [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no
++ $RM -r conftest 2>/dev/null
++ mkdir conftest
++ cd conftest
++ mkdir out
++ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
++ lt_compiler_flag="-o out/conftest2.$ac_objext"
++ # Insert the option either (1) after the last *FLAGS variable, or
++ # (2) before a word containing "conftest.", or (3) at the end.
++ # Note that $ac_compile itself does not contain backslashes and begins
++ # with a dollar sign (not a hyphen), so the echo should work correctly.
++ lt_compile=`echo "$ac_compile" | $SED \
++ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
++ -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
++ -e 's:$: $lt_compiler_flag:'`
++ (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
++ (eval "$lt_compile" 2>out/conftest.err)
++ ac_status=$?
++ cat out/conftest.err >&AS_MESSAGE_LOG_FD
++ echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
++ if (exit $ac_status) && test -s out/conftest2.$ac_objext
++ then
++ # The compiler can only warn and ignore the option if not recognized
++ # So say no if there are warnings
++ $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
++ $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
++ if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
++ _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
++ fi
++ fi
++ chmod u+w . 2>&AS_MESSAGE_LOG_FD
++ $RM conftest*
++ # SGI C++ compiler will create directory out/ii_files/ for
++ # template instantiation
++ test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
++ $RM out/* && rmdir out
++ cd ..
++ $RM -r conftest
++ $RM conftest*
++])
++_LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1],
++ [Does compiler simultaneously support -c and -o options?])
++])# _LT_COMPILER_C_O
+
+-# AC_LIBTOOL_WIN32_DLL
+-# --------------------
+-# declare package support for building win32 DLLs
+-AC_DEFUN([AC_LIBTOOL_WIN32_DLL],
+-[AC_BEFORE([$0], [AC_LIBTOOL_SETUP])
+-])# AC_LIBTOOL_WIN32_DLL
+
++# _LT_COMPILER_FILE_LOCKS([TAGNAME])
++# ----------------------------------
++# Check to see if we can do hard links to lock some files if needed
++m4_defun([_LT_COMPILER_FILE_LOCKS],
++[m4_require([_LT_ENABLE_LOCK])dnl
++m4_require([_LT_FILEUTILS_DEFAULTS])dnl
++_LT_COMPILER_C_O([$1])
+
+-# AC_ENABLE_SHARED([DEFAULT])
+-# ---------------------------
+-# implement the --enable-shared flag
+-# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
+-AC_DEFUN([AC_ENABLE_SHARED],
+-[define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl
+-AC_ARG_ENABLE([shared],
+- [AC_HELP_STRING([--enable-shared@<:@=PKGS@:>@],
+- [build shared libraries @<:@default=]AC_ENABLE_SHARED_DEFAULT[@:>@])],
+- [p=${PACKAGE-default}
+- case $enableval in
+- yes) enable_shared=yes ;;
+- no) enable_shared=no ;;
+- *)
+- enable_shared=no
+- # Look at the argument we got. We use all the common list separators.
+- lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+- for pkg in $enableval; do
+- IFS="$lt_save_ifs"
+- if test "X$pkg" = "X$p"; then
+- enable_shared=yes
+- fi
+- done
+- IFS="$lt_save_ifs"
+- ;;
+- esac],
+- [enable_shared=]AC_ENABLE_SHARED_DEFAULT)
+-])# AC_ENABLE_SHARED
+-
+-
+-# AC_DISABLE_SHARED
+-# -----------------
+-# set the default shared flag to --disable-shared
+-AC_DEFUN([AC_DISABLE_SHARED],
+-[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+-AC_ENABLE_SHARED(no)
+-])# AC_DISABLE_SHARED
+-
+-
+-# AC_ENABLE_STATIC([DEFAULT])
+-# ---------------------------
+-# implement the --enable-static flag
+-# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
+-AC_DEFUN([AC_ENABLE_STATIC],
+-[define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl
+-AC_ARG_ENABLE([static],
+- [AC_HELP_STRING([--enable-static@<:@=PKGS@:>@],
+- [build static libraries @<:@default=]AC_ENABLE_STATIC_DEFAULT[@:>@])],
+- [p=${PACKAGE-default}
+- case $enableval in
+- yes) enable_static=yes ;;
+- no) enable_static=no ;;
+- *)
+- enable_static=no
+- # Look at the argument we got. We use all the common list separators.
+- lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+- for pkg in $enableval; do
+- IFS="$lt_save_ifs"
+- if test "X$pkg" = "X$p"; then
+- enable_static=yes
+- fi
+- done
+- IFS="$lt_save_ifs"
+- ;;
+- esac],
+- [enable_static=]AC_ENABLE_STATIC_DEFAULT)
+-])# AC_ENABLE_STATIC
+-
+-
+-# AC_DISABLE_STATIC
+-# -----------------
+-# set the default static flag to --disable-static
+-AC_DEFUN([AC_DISABLE_STATIC],
+-[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+-AC_ENABLE_STATIC(no)
+-])# AC_DISABLE_STATIC
+-
+-
+-# AC_ENABLE_FAST_INSTALL([DEFAULT])
+-# ---------------------------------
+-# implement the --enable-fast-install flag
+-# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
+-AC_DEFUN([AC_ENABLE_FAST_INSTALL],
+-[define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl
+-AC_ARG_ENABLE([fast-install],
+- [AC_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@],
+- [optimize for fast installation @<:@default=]AC_ENABLE_FAST_INSTALL_DEFAULT[@:>@])],
+- [p=${PACKAGE-default}
+- case $enableval in
+- yes) enable_fast_install=yes ;;
+- no) enable_fast_install=no ;;
+- *)
+- enable_fast_install=no
+- # Look at the argument we got. We use all the common list separators.
+- lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+- for pkg in $enableval; do
+- IFS="$lt_save_ifs"
+- if test "X$pkg" = "X$p"; then
+- enable_fast_install=yes
+- fi
+- done
+- IFS="$lt_save_ifs"
+- ;;
+- esac],
+- [enable_fast_install=]AC_ENABLE_FAST_INSTALL_DEFAULT)
+-])# AC_ENABLE_FAST_INSTALL
+-
+-
+-# AC_DISABLE_FAST_INSTALL
+-# -----------------------
+-# set the default to --disable-fast-install
+-AC_DEFUN([AC_DISABLE_FAST_INSTALL],
+-[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+-AC_ENABLE_FAST_INSTALL(no)
+-])# AC_DISABLE_FAST_INSTALL
+-
+-
+-# AC_LIBTOOL_PICMODE([MODE])
+-# --------------------------
+-# implement the --with-pic flag
+-# MODE is either `yes' or `no'. If omitted, it defaults to `both'.
+-AC_DEFUN([AC_LIBTOOL_PICMODE],
+-[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+-pic_mode=ifelse($#,1,$1,default)
+-])# AC_LIBTOOL_PICMODE
+-
+-
+-# AC_PROG_EGREP
+-# -------------
+-# This is predefined starting with Autoconf 2.54, so this conditional
+-# definition can be removed once we require Autoconf 2.54 or later.
+-m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP],
+-[AC_CACHE_CHECK([for egrep], [ac_cv_prog_egrep],
+- [if echo a | (grep -E '(a|b)') >/dev/null 2>&1
+- then ac_cv_prog_egrep='grep -E'
+- else ac_cv_prog_egrep='egrep'
+- fi])
+- EGREP=$ac_cv_prog_egrep
+- AC_SUBST([EGREP])
+-])])
+-
+-
+-# AC_PATH_TOOL_PREFIX
+-# -------------------
+-# find a file program which can recognise shared library
+-AC_DEFUN([AC_PATH_TOOL_PREFIX],
+-[AC_REQUIRE([AC_PROG_EGREP])dnl
+-AC_MSG_CHECKING([for $1])
+-AC_CACHE_VAL(lt_cv_path_MAGIC_CMD,
+-[case $MAGIC_CMD in
+-[[\\/*] | ?:[\\/]*])
+- lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+- ;;
+-*)
+- lt_save_MAGIC_CMD="$MAGIC_CMD"
+- lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+-dnl $ac_dummy forces splitting on constant user-supplied paths.
+-dnl POSIX.2 word splitting is done only on the output of word expansions,
+-dnl not every word. This closes a longstanding sh security hole.
+- ac_dummy="ifelse([$2], , $PATH, [$2])"
+- for ac_dir in $ac_dummy; do
+- IFS="$lt_save_ifs"
+- test -z "$ac_dir" && ac_dir=.
+- if test -f $ac_dir/$1; then
+- lt_cv_path_MAGIC_CMD="$ac_dir/$1"
+- if test -n "$file_magic_test_file"; then
+- case $deplibs_check_method in
+- "file_magic "*)
+- file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
+- MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+- if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
+- $EGREP "$file_magic_regex" > /dev/null; then
+- :
+- else
+- cat <<EOF 1>&2
++hard_links="nottested"
++if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then
++ # do not overwrite the value of need_locks provided by the user
++ AC_MSG_CHECKING([if we can lock with hard links])
++ hard_links=yes
++ $RM conftest*
++ ln conftest.a conftest.b 2>/dev/null && hard_links=no
++ touch conftest.a
++ ln conftest.a conftest.b 2>&5 || hard_links=no
++ ln conftest.a conftest.b 2>/dev/null && hard_links=no
++ AC_MSG_RESULT([$hard_links])
++ if test "$hard_links" = no; then
++ AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe])
++ need_locks=warn
++ fi
++else
++ need_locks=no
++fi
++_LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?])
++])# _LT_COMPILER_FILE_LOCKS
+
+-*** Warning: the command libtool uses to detect shared libraries,
+-*** $file_magic_cmd, produces output that libtool cannot recognize.
+-*** The result is that libtool may fail to recognize shared libraries
+-*** as such. This will affect the creation of libtool libraries that
+-*** depend on shared libraries, but programs linked with such libtool
+-*** libraries will work regardless of this problem. Nevertheless, you
+-*** may want to report the problem to your system manager and/or to
+-*** bug-libtool@gnu.org
+
+-EOF
+- fi ;;
+- esac
+- fi
+- break
+- fi
+- done
+- IFS="$lt_save_ifs"
+- MAGIC_CMD="$lt_save_MAGIC_CMD"
+- ;;
+-esac])
+-MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+-if test -n "$MAGIC_CMD"; then
+- AC_MSG_RESULT($MAGIC_CMD)
++# _LT_CHECK_OBJDIR
++# ----------------
++m4_defun([_LT_CHECK_OBJDIR],
++[AC_CACHE_CHECK([for objdir], [lt_cv_objdir],
++[rm -f .libs 2>/dev/null
++mkdir .libs 2>/dev/null
++if test -d .libs; then
++ lt_cv_objdir=.libs
+ else
+- AC_MSG_RESULT(no)
++ # MS-DOS does not allow filenames that begin with a dot.
++ lt_cv_objdir=_libs
+ fi
+-])# AC_PATH_TOOL_PREFIX
++rmdir .libs 2>/dev/null])
++objdir=$lt_cv_objdir
++_LT_DECL([], [objdir], [0],
++ [The name of the directory that contains temporary libtool files])dnl
++m4_pattern_allow([LT_OBJDIR])dnl
++AC_DEFINE_UNQUOTED(LT_OBJDIR, "$lt_cv_objdir/",
++ [Define to the sub-directory in which libtool stores uninstalled libraries.])
++])# _LT_CHECK_OBJDIR
+
+
+-# AC_PATH_MAGIC
+-# -------------
+-# find a file program which can recognise a shared library
+-AC_DEFUN([AC_PATH_MAGIC],
+-[AC_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH)
+-if test -z "$lt_cv_path_MAGIC_CMD"; then
+- if test -n "$ac_tool_prefix"; then
+- AC_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH)
++# _LT_LINKER_HARDCODE_LIBPATH([TAGNAME])
++# --------------------------------------
++# Check hardcoding attributes.
++m4_defun([_LT_LINKER_HARDCODE_LIBPATH],
++[AC_MSG_CHECKING([how to hardcode library paths into programs])
++_LT_TAGVAR(hardcode_action, $1)=
++if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" ||
++ test -n "$_LT_TAGVAR(runpath_var, $1)" ||
++ test "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then
++
++ # We can hardcode non-existent directories.
++ if test "$_LT_TAGVAR(hardcode_direct, $1)" != no &&
++ # If the only mechanism to avoid hardcoding is shlibpath_var, we
++ # have to relink, otherwise we might link with an installed library
++ # when we should be linking with a yet-to-be-installed one
++ ## test "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" != no &&
++ test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; then
++ # Linking always hardcodes the temporary library directory.
++ _LT_TAGVAR(hardcode_action, $1)=relink
+ else
+- MAGIC_CMD=:
++ # We can link without hardcoding, and we can hardcode nonexisting dirs.
++ _LT_TAGVAR(hardcode_action, $1)=immediate
+ fi
++else
++ # We cannot hardcode anything, or else we can only hardcode existing
++ # directories.
++ _LT_TAGVAR(hardcode_action, $1)=unsupported
++fi
++AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)])
++
++if test "$_LT_TAGVAR(hardcode_action, $1)" = relink ||
++ test "$_LT_TAGVAR(inherit_rpath, $1)" = yes; then
++ # Fast installation is not supported
++ enable_fast_install=no
++elif test "$shlibpath_overrides_runpath" = yes ||
++ test "$enable_shared" = no; then
++ # Fast installation is not necessary
++ enable_fast_install=needless
+ fi
+-])# AC_PATH_MAGIC
++_LT_TAGDECL([], [hardcode_action], [0],
++ [How to hardcode a shared library path into an executable])
++])# _LT_LINKER_HARDCODE_LIBPATH
+
+
+-# AC_PROG_LD
+-# ----------
+-# find the pathname to the GNU or non-GNU linker
+-AC_DEFUN([AC_PROG_LD],
+-[AC_ARG_WITH([gnu-ld],
+- [AC_HELP_STRING([--with-gnu-ld],
+- [assume the C compiler uses GNU ld @<:@default=no@:>@])],
+- [test "$withval" = no || with_gnu_ld=yes],
+- [with_gnu_ld=no])
+-AC_REQUIRE([LT_AC_PROG_SED])dnl
+-AC_REQUIRE([AC_PROG_CC])dnl
+-AC_REQUIRE([AC_CANONICAL_HOST])dnl
+-AC_REQUIRE([AC_CANONICAL_BUILD])dnl
+-ac_prog=ld
+-if test "$GCC" = yes; then
+- # Check if gcc -print-prog-name=ld gives a path.
+- AC_MSG_CHECKING([for ld used by $CC])
+- case $host in
+- *-*-mingw*)
+- # gcc leaves a trailing carriage return which upsets mingw
+- ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
+- *)
+- ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
+- esac
+- case $ac_prog in
+- # Accept absolute paths.
+- [[\\/]]* | ?:[[\\/]]*)
+- re_direlt='/[[^/]][[^/]]*/\.\./'
+- # Canonicalize the pathname of ld
+- ac_prog=`echo $ac_prog| $SED 's%\\\\%/%g'`
+- while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
+- ac_prog=`echo $ac_prog| $SED "s%$re_direlt%/%"`
+- done
+- test -z "$LD" && LD="$ac_prog"
+- ;;
+- "")
+- # If it fails, then pretend we aren't using GCC.
+- ac_prog=ld
++# _LT_CMD_STRIPLIB
++# ----------------
++m4_defun([_LT_CMD_STRIPLIB],
++[m4_require([_LT_DECL_EGREP])
++striplib=
++old_striplib=
++AC_MSG_CHECKING([whether stripping libraries is possible])
++if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then
++ test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
++ test -z "$striplib" && striplib="$STRIP --strip-unneeded"
++ AC_MSG_RESULT([yes])
++else
++# FIXME - insert some real tests, host_os isn't really good enough
++ case $host_os in
++ darwin*)
++ if test -n "$STRIP" ; then
++ striplib="$STRIP -x"
++ old_striplib="$STRIP -S"
++ AC_MSG_RESULT([yes])
++ else
++ AC_MSG_RESULT([no])
++ fi
+ ;;
+ *)
+- # If it is relative, then search for the first ld in PATH.
+- with_gnu_ld=unknown
++ AC_MSG_RESULT([no])
+ ;;
+ esac
+-elif test "$with_gnu_ld" = yes; then
+- AC_MSG_CHECKING([for GNU ld])
+-else
+- AC_MSG_CHECKING([for non-GNU ld])
+ fi
+-AC_CACHE_VAL(lt_cv_path_LD,
+-[if test -z "$LD"; then
+- lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+- for ac_dir in $PATH; do
+- IFS="$lt_save_ifs"
+- test -z "$ac_dir" && ac_dir=.
+- if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+- lt_cv_path_LD="$ac_dir/$ac_prog"
+- # Check to see if the program is GNU ld. I'd rather use --version,
+- # but apparently some variants of GNU ld only accept -v.
+- # Break only if it was the GNU/non-GNU ld that we prefer.
+- case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
+- *GNU* | *'with BFD'*)
+- test "$with_gnu_ld" != no && break
+- ;;
+- *)
+- test "$with_gnu_ld" != yes && break
+- ;;
+- esac
++_LT_DECL([], [old_striplib], [1], [Commands to strip libraries])
++_LT_DECL([], [striplib], [1])
++])# _LT_CMD_STRIPLIB
++
++
++# _LT_SYS_DYNAMIC_LINKER([TAG])
++# -----------------------------
++# PORTME Fill in your ld.so characteristics
++m4_defun([_LT_SYS_DYNAMIC_LINKER],
++[AC_REQUIRE([AC_CANONICAL_HOST])dnl
++m4_require([_LT_DECL_EGREP])dnl
++m4_require([_LT_FILEUTILS_DEFAULTS])dnl
++m4_require([_LT_DECL_SED])dnl
++AC_MSG_CHECKING([dynamic linker characteristics])
++m4_if([$1],
++ [], [
++if test "$GCC" = yes; then
++ case $host_os in
++ darwin*) lt_awk_arg="/^libraries:/,/LR/" ;;
++ *) lt_awk_arg="/^libraries:/" ;;
++ esac
++ lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e "s,=/,/,g"`
++ if $ECHO "$lt_search_path_spec" | $GREP ';' >/dev/null ; then
++ # if the path contains ";" then we assume it to be the separator
++ # otherwise default to the standard path separator (i.e. ":") - it is
++ # assumed that no part of a normal pathname contains ";" but that should
++ # okay in the real world where ";" in dirpaths is itself problematic.
++ lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e 's/;/ /g'`
++ else
++ lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
++ fi
++ # Ok, now we have the path, separated by spaces, we can step through it
++ # and add multilib dir if necessary.
++ lt_tmp_lt_search_path_spec=
++ lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
++ for lt_sys_path in $lt_search_path_spec; do
++ if test -d "$lt_sys_path/$lt_multi_os_dir"; then
++ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir"
++ else
++ test -d "$lt_sys_path" && \
++ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path"
+ fi
+ done
+- IFS="$lt_save_ifs"
++ lt_search_path_spec=`$ECHO $lt_tmp_lt_search_path_spec | awk '
++BEGIN {RS=" "; FS="/|\n";} {
++ lt_foo="";
++ lt_count=0;
++ for (lt_i = NF; lt_i > 0; lt_i--) {
++ if ($lt_i != "" && $lt_i != ".") {
++ if ($lt_i == "..") {
++ lt_count++;
++ } else {
++ if (lt_count == 0) {
++ lt_foo="/" $lt_i lt_foo;
++ } else {
++ lt_count--;
++ }
++ }
++ }
++ }
++ if (lt_foo != "") { lt_freq[[lt_foo]]++; }
++ if (lt_freq[[lt_foo]] == 1) { print lt_foo; }
++}'`
++ sys_lib_search_path_spec=`$ECHO $lt_search_path_spec`
+ else
+- lt_cv_path_LD="$LD" # Let the user override the test with a path.
++ sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+ fi])
+-LD="$lt_cv_path_LD"
+-if test -n "$LD"; then
+- AC_MSG_RESULT($LD)
+-else
+- AC_MSG_RESULT(no)
+-fi
+-test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
+-AC_PROG_LD_GNU
+-])# AC_PROG_LD
++library_names_spec=
++libname_spec='lib$name'
++soname_spec=
++shrext_cmds=".so"
++postinstall_cmds=
++postuninstall_cmds=
++finish_cmds=
++finish_eval=
++shlibpath_var=
++shlibpath_overrides_runpath=unknown
++version_type=none
++dynamic_linker="$host_os ld.so"
++sys_lib_dlsearch_path_spec="/lib /usr/lib"
++need_lib_prefix=unknown
++hardcode_into_libs=no
++
++# when you set need_version to no, make sure it does not cause -set_version
++# flags to be left without arguments
++need_version=unknown
+
++case $host_os in
++aix3*)
++ version_type=linux
++ library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
++ shlibpath_var=LIBPATH
+
+-# AC_PROG_LD_GNU
+-# --------------
+-AC_DEFUN([AC_PROG_LD_GNU],
+-[AC_REQUIRE([AC_PROG_EGREP])dnl
+-AC_CACHE_CHECK([if the linker ($LD) is GNU ld], lt_cv_prog_gnu_ld,
+-[# I'd rather use --version here, but apparently some GNU lds only accept -v.
+-case `$LD -v 2>&1 </dev/null` in
+-*GNU* | *'with BFD'*)
+- lt_cv_prog_gnu_ld=yes
++ # AIX 3 has no versioning support, so we append a major version to the name.
++ soname_spec='${libname}${release}${shared_ext}$major'
+ ;;
+-*)
+- lt_cv_prog_gnu_ld=no
+- ;;
+-esac])
+-with_gnu_ld=$lt_cv_prog_gnu_ld
+-])# AC_PROG_LD_GNU
+-
+
+-# AC_PROG_LD_RELOAD_FLAG
+-# ----------------------
+-# find reload flag for linker
+-# -- PORTME Some linkers may need a different reload flag.
+-AC_DEFUN([AC_PROG_LD_RELOAD_FLAG],
+-[AC_CACHE_CHECK([for $LD option to reload object files],
+- lt_cv_ld_reload_flag,
+- [lt_cv_ld_reload_flag='-r'])
+-reload_flag=$lt_cv_ld_reload_flag
+-case $reload_flag in
+-"" | " "*) ;;
+-*) reload_flag=" $reload_flag" ;;
+-esac
+-reload_cmds='$LD$reload_flag -o $output$reload_objs'
+-case $host_os in
+- darwin*)
+- if test "$GCC" = yes; then
+- reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
++aix[[4-9]]*)
++ version_type=linux
++ need_lib_prefix=no
++ need_version=no
++ hardcode_into_libs=yes
++ if test "$host_cpu" = ia64; then
++ # AIX 5 supports IA64
++ library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
++ shlibpath_var=LD_LIBRARY_PATH
++ else
++ # With GCC up to 2.95.x, collect2 would create an import file
++ # for dependence libraries. The import file would start with
++ # the line `#! .'. This would cause the generated library to
++ # depend on `.', always an invalid library. This was fixed in
++ # development snapshots of GCC prior to 3.0.
++ case $host_os in
++ aix4 | aix4.[[01]] | aix4.[[01]].*)
++ if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
++ echo ' yes '
++ echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
++ :
++ else
++ can_build_shared=no
++ fi
++ ;;
++ esac
++ # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
++ # soname into executable. Probably we can add versioning support to
++ # collect2, so additional links can be useful in future.
++ if test "$aix_use_runtimelinking" = yes; then
++ # If using run time linking (on AIX 4.2 or later) use lib<name>.so
++ # instead of lib<name>.a to let people know that these are not
++ # typical AIX shared libraries.
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ else
+- reload_cmds='$LD$reload_flag -o $output$reload_objs'
++ # We preserve .a as extension for shared libraries through AIX4.2
++ # and later when we are not doing run time linking.
++ library_names_spec='${libname}${release}.a $libname.a'
++ soname_spec='${libname}${release}${shared_ext}$major'
+ fi
+- ;;
+-esac
+-])# AC_PROG_LD_RELOAD_FLAG
+-
+-
+-# AC_DEPLIBS_CHECK_METHOD
+-# -----------------------
+-# how to check for library dependencies
+-# -- PORTME fill in with the dynamic library characteristics
+-AC_DEFUN([AC_DEPLIBS_CHECK_METHOD],
+-[AC_CACHE_CHECK([how to recognise dependent libraries],
+-lt_cv_deplibs_check_method,
+-[lt_cv_file_magic_cmd='$MAGIC_CMD'
+-lt_cv_file_magic_test_file=
+-lt_cv_deplibs_check_method='unknown'
+-# Need to set the preceding variable on all platforms that support
+-# interlibrary dependencies.
+-# 'none' -- dependencies not supported.
+-# `unknown' -- same as none, but documents that we really don't know.
+-# 'pass_all' -- all dependencies passed with no checks.
+-# 'test_compile' -- check by making test program.
+-# 'file_magic [[regex]]' -- check by looking for files in library path
+-# which responds to the $file_magic_cmd with a given extended regex.
+-# If you have `file' or equivalent on your system and you're not sure
+-# whether `pass_all' will *always* work, you probably want this one.
++ shlibpath_var=LIBPATH
++ fi
++ ;;
+
+-case $host_os in
+-aix4* | aix5*)
+- lt_cv_deplibs_check_method=pass_all
++amigaos*)
++ case $host_cpu in
++ powerpc)
++ # Since July 2007 AmigaOS4 officially supports .so libraries.
++ # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
++ ;;
++ m68k)
++ library_names_spec='$libname.ixlibrary $libname.a'
++ # Create ${libname}_ixlibrary.a entries in /sys/libs.
++ finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$ECHO "X$lib" | $Xsed -e '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
++ ;;
++ esac
+ ;;
+
+ beos*)
+- lt_cv_deplibs_check_method=pass_all
++ library_names_spec='${libname}${shared_ext}'
++ dynamic_linker="$host_os ld.so"
++ shlibpath_var=LIBRARY_PATH
+ ;;
+
+ bsdi[[45]]*)
+- lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib)'
+- lt_cv_file_magic_cmd='/usr/bin/file -L'
+- lt_cv_file_magic_test_file=/shlib/libc.so
+- ;;
+-
+-cygwin*)
+- # func_win32_libid is a shell function defined in ltmain.sh
+- lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+- lt_cv_file_magic_cmd='func_win32_libid'
++ version_type=linux
++ need_version=no
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
++ soname_spec='${libname}${release}${shared_ext}$major'
++ finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
++ shlibpath_var=LD_LIBRARY_PATH
++ sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
++ sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
++ # the default ld.so.conf also contains /usr/contrib/lib and
++ # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
++ # libtool to hard-code these into programs
+ ;;
+
+-mingw* | pw32*)
+- # Base MSYS/MinGW do not provide the 'file' command needed by
+- # func_win32_libid shell function, so use a weaker test based on 'objdump'.
+- lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?'
+- lt_cv_file_magic_cmd='$OBJDUMP -f'
+- ;;
++cygwin* | mingw* | pw32*)
++ version_type=windows
++ shrext_cmds=".dll"
++ need_version=no
++ need_lib_prefix=no
+
+-darwin* | rhapsody*)
+- lt_cv_deplibs_check_method=pass_all
+- ;;
++ case $GCC,$host_os in
++ yes,cygwin* | yes,mingw* | yes,pw32*)
++ library_names_spec='$libname.dll.a'
++ # DLL is installed to $(libdir)/../bin by postinstall_cmds
++ postinstall_cmds='base_file=`basename \${file}`~
++ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
++ dldir=$destdir/`dirname \$dlpath`~
++ test -d \$dldir || mkdir -p \$dldir~
++ $install_prog $dir/$dlname \$dldir/$dlname~
++ chmod a+x \$dldir/$dlname~
++ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
++ eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
++ fi'
++ postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
++ dlpath=$dir/\$dldll~
++ $RM \$dlpath'
++ shlibpath_overrides_runpath=yes
+
+-freebsd* | kfreebsd*-gnu | dragonfly*)
+- if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+- case $host_cpu in
+- i*86 )
+- # Not sure whether the presence of OpenBSD here was a mistake.
+- # Let's accept both of them until this is cleared up.
+- lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library'
+- lt_cv_file_magic_cmd=/usr/bin/file
+- lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
++ case $host_os in
++ cygwin*)
++ # Cygwin DLLs use 'cyg' prefix rather than 'lib'
++ soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
++ sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
++ ;;
++ mingw*)
++ # MinGW DLLs use traditional 'lib' prefix
++ soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
++ sys_lib_search_path_spec=`$CC -print-search-dirs | $GREP "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
++ if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then
++ # It is most probably a Windows format PATH printed by
++ # mingw gcc, but we are running on Cygwin. Gcc prints its search
++ # path with ; separators, and with drive letters. We can handle the
++ # drive letters (cygwin fileutils understands them), so leave them,
++ # especially as we might pass files found there to a mingw objdump,
++ # which wouldn't understand a cygwinified path. Ahh.
++ sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
++ else
++ sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
++ fi
++ ;;
++ pw32*)
++ # pw32 DLLs use 'pw' prefix rather than 'lib'
++ library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+ ;;
+ esac
+- else
+- lt_cv_deplibs_check_method=pass_all
+- fi
+- ;;
+-
+-gnu*)
+- lt_cv_deplibs_check_method=pass_all
+- ;;
+-
+-hpux10.20* | hpux11*)
+- lt_cv_file_magic_cmd=/usr/bin/file
+- case $host_cpu in
+- ia64*)
+- lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64'
+- lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
+- ;;
+- hppa*64*)
+- [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]']
+- lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
+ ;;
++
+ *)
+- lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]].[[0-9]]) shared library'
+- lt_cv_file_magic_test_file=/usr/lib/libc.sl
++ library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib'
+ ;;
+ esac
++ dynamic_linker='Win32 ld.exe'
++ # FIXME: first we should search . and the directory the executable is in
++ shlibpath_var=PATH
+ ;;
+
+-interix3*)
+- # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
+- lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$'
+- ;;
+-
+-irix5* | irix6* | nonstopux*)
+- case $LD in
+- *-32|*"-32 ") libmagic=32-bit;;
+- *-n32|*"-n32 ") libmagic=N32;;
+- *-64|*"-64 ") libmagic=64-bit;;
+- *) libmagic=never-match;;
+- esac
+- lt_cv_deplibs_check_method=pass_all
+- ;;
+-
+-# This must be Linux ELF.
+-linux*)
+- lt_cv_deplibs_check_method=pass_all
+- ;;
+-
+-netbsd*)
+- if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+- lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
+- else
+- lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$'
+- fi
++darwin* | rhapsody*)
++ dynamic_linker="$host_os dyld"
++ version_type=darwin
++ need_lib_prefix=no
++ need_version=no
++ library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
++ soname_spec='${libname}${release}${major}$shared_ext'
++ shlibpath_overrides_runpath=yes
++ shlibpath_var=DYLD_LIBRARY_PATH
++ shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
++m4_if([$1], [],[
++ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"])
++ sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
+ ;;
+
+-newos6*)
+- lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)'
+- lt_cv_file_magic_cmd=/usr/bin/file
+- lt_cv_file_magic_test_file=/usr/lib/libnls.so
++dgux*)
++ version_type=linux
++ need_lib_prefix=no
++ need_version=no
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
++ soname_spec='${libname}${release}${shared_ext}$major'
++ shlibpath_var=LD_LIBRARY_PATH
+ ;;
+
+-nto-qnx*)
+- lt_cv_deplibs_check_method=unknown
++freebsd1*)
++ dynamic_linker=no
+ ;;
+
+-openbsd*)
+- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+- lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$'
++freebsd* | dragonfly*)
++ # DragonFly does not have aout. When/if they implement a new
++ # versioning mechanism, adjust this.
++ if test -x /usr/bin/objformat; then
++ objformat=`/usr/bin/objformat`
+ else
+- lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
++ case $host_os in
++ freebsd[[123]]*) objformat=aout ;;
++ *) objformat=elf ;;
++ esac
+ fi
+- ;;
+-
+-osf3* | osf4* | osf5*)
+- lt_cv_deplibs_check_method=pass_all
+- ;;
+-
+-solaris*)
+- lt_cv_deplibs_check_method=pass_all
+- ;;
+-
+-sysv4 | sysv4.3*)
+- case $host_vendor in
+- motorola)
+- lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]'
+- lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
+- ;;
+- ncr)
+- lt_cv_deplibs_check_method=pass_all
+- ;;
+- sequent)
+- lt_cv_file_magic_cmd='/bin/file'
+- lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )'
++ version_type=freebsd-$objformat
++ case $version_type in
++ freebsd-elf*)
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
++ need_version=no
++ need_lib_prefix=no
++ ;;
++ freebsd-*)
++ library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
++ need_version=yes
++ ;;
++ esac
++ shlibpath_var=LD_LIBRARY_PATH
++ case $host_os in
++ freebsd2*)
++ shlibpath_overrides_runpath=yes
+ ;;
+- sni)
+- lt_cv_file_magic_cmd='/bin/file'
+- lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib"
+- lt_cv_file_magic_test_file=/lib/libc.so
++ freebsd3.[[01]]* | freebsdelf3.[[01]]*)
++ shlibpath_overrides_runpath=yes
++ hardcode_into_libs=yes
+ ;;
+- siemens)
+- lt_cv_deplibs_check_method=pass_all
++ freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \
++ freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1)
++ shlibpath_overrides_runpath=no
++ hardcode_into_libs=yes
+ ;;
+- pc)
+- lt_cv_deplibs_check_method=pass_all
++ *) # from 4.6 on, and DragonFly
++ shlibpath_overrides_runpath=yes
++ hardcode_into_libs=yes
+ ;;
+ esac
+ ;;
+
+-sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+- lt_cv_deplibs_check_method=pass_all
++gnu*)
++ version_type=linux
++ need_lib_prefix=no
++ need_version=no
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
++ soname_spec='${libname}${release}${shared_ext}$major'
++ shlibpath_var=LD_LIBRARY_PATH
++ hardcode_into_libs=yes
+ ;;
+-esac
+-])
+-file_magic_cmd=$lt_cv_file_magic_cmd
+-deplibs_check_method=$lt_cv_deplibs_check_method
+-test -z "$deplibs_check_method" && deplibs_check_method=unknown
+-])# AC_DEPLIBS_CHECK_METHOD
+
+-
+-# AC_PROG_NM
+-# ----------
+-# find the pathname to a BSD-compatible name lister
+-AC_DEFUN([AC_PROG_NM],
+-[AC_CACHE_CHECK([for BSD-compatible nm], lt_cv_path_NM,
+-[if test -n "$NM"; then
+- # Let the user override the test.
+- lt_cv_path_NM="$NM"
+-else
+- lt_nm_to_check="${ac_tool_prefix}nm"
+- if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
+- lt_nm_to_check="$lt_nm_to_check nm"
+- fi
+- for lt_tmp_nm in $lt_nm_to_check; do
+- lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+- for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
+- IFS="$lt_save_ifs"
+- test -z "$ac_dir" && ac_dir=.
+- tmp_nm="$ac_dir/$lt_tmp_nm"
+- if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
+- # Check to see if the nm accepts a BSD-compat flag.
+- # Adding the `sed 1q' prevents false positives on HP-UX, which says:
+- # nm: unknown option "B" ignored
+- # Tru64's nm complains that /dev/null is an invalid object file
+- case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
+- */dev/null* | *'Invalid file or object type'*)
+- lt_cv_path_NM="$tmp_nm -B"
+- break
+- ;;
+- *)
+- case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
+- */dev/null*)
+- lt_cv_path_NM="$tmp_nm -p"
+- break
+- ;;
+- *)
+- lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
+- continue # so that we can try to find one that supports BSD flags
+- ;;
+- esac
+- ;;
+- esac
+- fi
+- done
+- IFS="$lt_save_ifs"
+- done
+- test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm
+-fi])
+-NM="$lt_cv_path_NM"
+-])# AC_PROG_NM
+-
+-
+-# AC_CHECK_LIBM
+-# -------------
+-# check for math library
+-AC_DEFUN([AC_CHECK_LIBM],
+-[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+-LIBM=
+-case $host in
+-*-*-beos* | *-*-cygwin* | *-*-pw32* | *-*-darwin*)
+- # These system don't have libm, or don't need it
+- ;;
+-*-ncr-sysv4.3*)
+- AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
+- AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm")
+- ;;
+-*)
+- AC_CHECK_LIB(m, cos, LIBM="-lm")
++hpux9* | hpux10* | hpux11*)
++ # Give a soname corresponding to the major version so that dld.sl refuses to
++ # link against other versions.
++ version_type=sunos
++ need_lib_prefix=no
++ need_version=no
++ case $host_cpu in
++ ia64*)
++ shrext_cmds='.so'
++ hardcode_into_libs=yes
++ dynamic_linker="$host_os dld.so"
++ shlibpath_var=LD_LIBRARY_PATH
++ shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
++ soname_spec='${libname}${release}${shared_ext}$major'
++ if test "X$HPUX_IA64_MODE" = X32; then
++ sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
++ else
++ sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
++ fi
++ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
++ ;;
++ hppa*64*)
++ shrext_cmds='.sl'
++ hardcode_into_libs=yes
++ dynamic_linker="$host_os dld.sl"
++ shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
++ shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
++ soname_spec='${libname}${release}${shared_ext}$major'
++ sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
++ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
++ ;;
++ *)
++ shrext_cmds='.sl'
++ dynamic_linker="$host_os dld.sl"
++ shlibpath_var=SHLIB_PATH
++ shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
++ soname_spec='${libname}${release}${shared_ext}$major'
++ ;;
++ esac
++ # HP-UX runs *really* slowly unless shared libraries are mode 555.
++ postinstall_cmds='chmod 555 $lib'
+ ;;
+-esac
+-])# AC_CHECK_LIBM
+
++interix[[3-9]]*)
++ version_type=linux
++ need_lib_prefix=no
++ need_version=no
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
++ soname_spec='${libname}${release}${shared_ext}$major'
++ dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
++ shlibpath_var=LD_LIBRARY_PATH
++ shlibpath_overrides_runpath=no
++ hardcode_into_libs=yes
++ ;;
+
+-# AC_LIBLTDL_CONVENIENCE([DIRECTORY])
+-# -----------------------------------
+-# sets LIBLTDL to the link flags for the libltdl convenience library and
+-# LTDLINCL to the include flags for the libltdl header and adds
+-# --enable-ltdl-convenience to the configure arguments. Note that
+-# AC_CONFIG_SUBDIRS is not called here. If DIRECTORY is not provided,
+-# it is assumed to be `libltdl'. LIBLTDL will be prefixed with
+-# '${top_builddir}/' and LTDLINCL will be prefixed with '${top_srcdir}/'
+-# (note the single quotes!). If your package is not flat and you're not
+-# using automake, define top_builddir and top_srcdir appropriately in
+-# the Makefiles.
+-AC_DEFUN([AC_LIBLTDL_CONVENIENCE],
+-[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+- case $enable_ltdl_convenience in
+- no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;;
+- "") enable_ltdl_convenience=yes
+- ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;;
++irix5* | irix6* | nonstopux*)
++ case $host_os in
++ nonstopux*) version_type=nonstopux ;;
++ *)
++ if test "$lt_cv_prog_gnu_ld" = yes; then
++ version_type=linux
++ else
++ version_type=irix
++ fi ;;
+ esac
+- LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdlc.la
+- LTDLINCL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl'])
+- # For backwards non-gettext consistent compatibility...
+- INCLTDL="$LTDLINCL"
+-])# AC_LIBLTDL_CONVENIENCE
+-
+-
+-# AC_LIBLTDL_INSTALLABLE([DIRECTORY])
+-# -----------------------------------
+-# sets LIBLTDL to the link flags for the libltdl installable library and
+-# LTDLINCL to the include flags for the libltdl header and adds
+-# --enable-ltdl-install to the configure arguments. Note that
+-# AC_CONFIG_SUBDIRS is not called here. If DIRECTORY is not provided,
+-# and an installed libltdl is not found, it is assumed to be `libltdl'.
+-# LIBLTDL will be prefixed with '${top_builddir}/'# and LTDLINCL with
+-# '${top_srcdir}/' (note the single quotes!). If your package is not
+-# flat and you're not using automake, define top_builddir and top_srcdir
+-# appropriately in the Makefiles.
+-# In the future, this macro may have to be called after AC_PROG_LIBTOOL.
+-AC_DEFUN([AC_LIBLTDL_INSTALLABLE],
+-[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+- AC_CHECK_LIB(ltdl, lt_dlinit,
+- [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no],
+- [if test x"$enable_ltdl_install" = xno; then
+- AC_MSG_WARN([libltdl not installed, but installation disabled])
+- else
+- enable_ltdl_install=yes
+- fi
+- ])
+- if test x"$enable_ltdl_install" = x"yes"; then
+- ac_configure_args="$ac_configure_args --enable-ltdl-install"
+- LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdl.la
+- LTDLINCL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl'])
+- else
+- ac_configure_args="$ac_configure_args --enable-ltdl-install=no"
+- LIBLTDL="-lltdl"
+- LTDLINCL=
+- fi
+- # For backwards non-gettext consistent compatibility...
+- INCLTDL="$LTDLINCL"
+-])# AC_LIBLTDL_INSTALLABLE
++ need_lib_prefix=no
++ need_version=no
++ soname_spec='${libname}${release}${shared_ext}$major'
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
++ case $host_os in
++ irix5* | nonstopux*)
++ libsuff= shlibsuff=
++ ;;
++ *)
++ case $LD in # libtool.m4 will add one of these switches to LD
++ *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
++ libsuff= shlibsuff= libmagic=32-bit;;
++ *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
++ libsuff=32 shlibsuff=N32 libmagic=N32;;
++ *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
++ libsuff=64 shlibsuff=64 libmagic=64-bit;;
++ *) libsuff= shlibsuff= libmagic=never-match;;
++ esac
++ ;;
++ esac
++ shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
++ shlibpath_overrides_runpath=no
++ sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
++ sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
++ hardcode_into_libs=yes
++ ;;
+
++# No shared lib support for Linux oldld, aout, or coff.
++linux*oldld* | linux*aout* | linux*coff*)
++ dynamic_linker=no
++ ;;
+
+-# AC_LIBTOOL_CXX
+-# --------------
+-# enable support for C++ libraries
+-AC_DEFUN([AC_LIBTOOL_CXX],
+-[AC_REQUIRE([_LT_AC_LANG_CXX])
+-])# AC_LIBTOOL_CXX
++# This must be Linux ELF.
++linux* | k*bsd*-gnu)
++ version_type=linux
++ need_lib_prefix=no
++ need_version=no
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
++ soname_spec='${libname}${release}${shared_ext}$major'
++ finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
++ shlibpath_var=LD_LIBRARY_PATH
++ shlibpath_overrides_runpath=no
++ # Some binutils ld are patched to set DT_RUNPATH
++ save_LDFLAGS=$LDFLAGS
++ save_libdir=$libdir
++ eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \
++ LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\""
++ AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
++ [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null],
++ [shlibpath_overrides_runpath=yes])])
++ LDFLAGS=$save_LDFLAGS
++ libdir=$save_libdir
+
++ # This implies no fast_install, which is unacceptable.
++ # Some rework will be needed to allow for fast_install
++ # before this can be enabled.
++ hardcode_into_libs=yes
+
+-# _LT_AC_LANG_CXX
+-# ---------------
+-AC_DEFUN([_LT_AC_LANG_CXX],
+-[AC_REQUIRE([AC_PROG_CXX])
+-AC_REQUIRE([_LT_AC_PROG_CXXCPP])
+-_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}CXX])
+-])# _LT_AC_LANG_CXX
++ # Append ld.so.conf contents to the search path
++ if test -f /etc/ld.so.conf; then
++ lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
++ sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
++ fi
+
+-# _LT_AC_PROG_CXXCPP
+-# ------------------
+-AC_DEFUN([_LT_AC_PROG_CXXCPP],
+-[
+-AC_REQUIRE([AC_PROG_CXX])
+-if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
+- ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
+- (test "X$CXX" != "Xg++"))) ; then
+- AC_PROG_CXXCPP
+-fi
+-])# _LT_AC_PROG_CXXCPP
+-
+-# AC_LIBTOOL_F77
+-# --------------
+-# enable support for Fortran 77 libraries
+-AC_DEFUN([AC_LIBTOOL_F77],
+-[AC_REQUIRE([_LT_AC_LANG_F77])
+-])# AC_LIBTOOL_F77
+-
+-
+-# _LT_AC_LANG_F77
+-# ---------------
+-AC_DEFUN([_LT_AC_LANG_F77],
+-[AC_REQUIRE([AC_PROG_F77])
+-_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}F77])
+-])# _LT_AC_LANG_F77
+-
+-
+-# AC_LIBTOOL_GCJ
+-# --------------
+-# enable support for GCJ libraries
+-AC_DEFUN([AC_LIBTOOL_GCJ],
+-[AC_REQUIRE([_LT_AC_LANG_GCJ])
+-])# AC_LIBTOOL_GCJ
+-
+-
+-# _LT_AC_LANG_GCJ
+-# ---------------
+-AC_DEFUN([_LT_AC_LANG_GCJ],
+-[AC_PROVIDE_IFELSE([AC_PROG_GCJ],[],
+- [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],[],
+- [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ],[],
+- [ifdef([AC_PROG_GCJ],[AC_REQUIRE([AC_PROG_GCJ])],
+- [ifdef([A][M_PROG_GCJ],[AC_REQUIRE([A][M_PROG_GCJ])],
+- [AC_REQUIRE([A][C_PROG_GCJ_OR_A][M_PROG_GCJ])])])])])])
+-_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}GCJ])
+-])# _LT_AC_LANG_GCJ
+-
+-
+-# AC_LIBTOOL_RC
+-# -------------
+-# enable support for Windows resource files
+-AC_DEFUN([AC_LIBTOOL_RC],
+-[AC_REQUIRE([LT_AC_PROG_RC])
+-_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}RC])
+-])# AC_LIBTOOL_RC
++ # We used to test for /lib/ld.so.1 and disable shared libraries on
++ # powerpc, because MkLinux only supported shared libraries with the
++ # GNU dynamic linker. Since this was broken with cross compilers,
++ # most powerpc-linux boxes support dynamic linking these days and
++ # people can always --disable-shared, the test was removed, and we
++ # assume the GNU/Linux dynamic linker is in use.
++ dynamic_linker='GNU/Linux ld.so'
++ ;;
+
++netbsd*)
++ version_type=sunos
++ need_lib_prefix=no
++ need_version=no
++ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
++ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
++ dynamic_linker='NetBSD (a.out) ld.so'
++ else
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
++ soname_spec='${libname}${release}${shared_ext}$major'
++ dynamic_linker='NetBSD ld.elf_so'
++ fi
++ shlibpath_var=LD_LIBRARY_PATH
++ shlibpath_overrides_runpath=yes
++ hardcode_into_libs=yes
++ ;;
+
+-# AC_LIBTOOL_LANG_C_CONFIG
+-# ------------------------
+-# Ensure that the configuration vars for the C compiler are
+-# suitably defined. Those variables are subsequently used by
+-# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
+-AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG], [_LT_AC_LANG_C_CONFIG])
+-AC_DEFUN([_LT_AC_LANG_C_CONFIG],
+-[lt_save_CC="$CC"
+-AC_LANG_PUSH(C)
++newsos6)
++ version_type=linux
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
++ shlibpath_var=LD_LIBRARY_PATH
++ shlibpath_overrides_runpath=yes
++ ;;
+
+-# Source file extension for C test sources.
+-ac_ext=c
++*nto* | *qnx*)
++ version_type=qnx
++ need_lib_prefix=no
++ need_version=no
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
++ soname_spec='${libname}${release}${shared_ext}$major'
++ shlibpath_var=LD_LIBRARY_PATH
++ shlibpath_overrides_runpath=no
++ hardcode_into_libs=yes
++ dynamic_linker='ldqnx.so'
++ ;;
+
+-# Object file extension for compiled C test sources.
+-objext=o
+-_LT_AC_TAGVAR(objext, $1)=$objext
++openbsd*)
++ version_type=sunos
++ sys_lib_dlsearch_path_spec="/usr/lib"
++ need_lib_prefix=no
++ # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
++ case $host_os in
++ openbsd3.3 | openbsd3.3.*) need_version=yes ;;
++ *) need_version=no ;;
++ esac
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
++ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
++ shlibpath_var=LD_LIBRARY_PATH
++ if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
++ case $host_os in
++ openbsd2.[[89]] | openbsd2.[[89]].*)
++ shlibpath_overrides_runpath=no
++ ;;
++ *)
++ shlibpath_overrides_runpath=yes
++ ;;
++ esac
++ else
++ shlibpath_overrides_runpath=yes
++ fi
++ ;;
+
+-# Code to be used in simple compile tests
+-lt_simple_compile_test_code="int some_variable = 0;\n"
++os2*)
++ libname_spec='$name'
++ shrext_cmds=".dll"
++ need_lib_prefix=no
++ library_names_spec='$libname${shared_ext} $libname.a'
++ dynamic_linker='OS/2 ld.exe'
++ shlibpath_var=LIBPATH
++ ;;
+
+-# Code to be used in simple link tests
+-lt_simple_link_test_code='int main(){return(0);}\n'
++osf3* | osf4* | osf5*)
++ version_type=osf
++ need_lib_prefix=no
++ need_version=no
++ soname_spec='${libname}${release}${shared_ext}$major'
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
++ shlibpath_var=LD_LIBRARY_PATH
++ sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
++ sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
++ ;;
+
+-_LT_AC_SYS_COMPILER
++rdos*)
++ dynamic_linker=no
++ ;;
+
+-# save warnings/boilerplate of simple test code
+-_LT_COMPILER_BOILERPLATE
+-_LT_LINKER_BOILERPLATE
++solaris*)
++ version_type=linux
++ need_lib_prefix=no
++ need_version=no
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
++ soname_spec='${libname}${release}${shared_ext}$major'
++ shlibpath_var=LD_LIBRARY_PATH
++ shlibpath_overrides_runpath=yes
++ hardcode_into_libs=yes
++ # ldd complains unless libraries are executable
++ postinstall_cmds='chmod +x $lib'
++ ;;
+
+-## CAVEAT EMPTOR:
+-## There is no encapsulation within the following macros, do not change
+-## the running order or otherwise move them around unless you know exactly
+-## what you are doing...
+-AC_LIBTOOL_PROG_COMPILER_NO_RTTI($1)
+-AC_LIBTOOL_PROG_COMPILER_PIC($1)
+-AC_LIBTOOL_PROG_CC_C_O($1)
+-AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
+-AC_LIBTOOL_PROG_LD_SHLIBS($1)
+-AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
+-AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
+-AC_LIBTOOL_SYS_LIB_STRIP
+-AC_LIBTOOL_DLOPEN_SELF
+-
+-# Report which library types will actually be built
+-AC_MSG_CHECKING([if libtool supports shared libraries])
+-AC_MSG_RESULT([$can_build_shared])
++sunos4*)
++ version_type=sunos
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
++ finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
++ shlibpath_var=LD_LIBRARY_PATH
++ shlibpath_overrides_runpath=yes
++ if test "$with_gnu_ld" = yes; then
++ need_lib_prefix=no
++ fi
++ need_version=yes
++ ;;
+
+-AC_MSG_CHECKING([whether to build shared libraries])
+-test "$can_build_shared" = "no" && enable_shared=no
++sysv4 | sysv4.3*)
++ version_type=linux
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
++ soname_spec='${libname}${release}${shared_ext}$major'
++ shlibpath_var=LD_LIBRARY_PATH
++ case $host_vendor in
++ sni)
++ shlibpath_overrides_runpath=no
++ need_lib_prefix=no
++ runpath_var=LD_RUN_PATH
++ ;;
++ siemens)
++ need_lib_prefix=no
++ ;;
++ motorola)
++ need_lib_prefix=no
++ need_version=no
++ shlibpath_overrides_runpath=no
++ sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
++ ;;
++ esac
++ ;;
+
+-# On AIX, shared libraries and static libraries use the same namespace, and
+-# are all built from PIC.
+-case $host_os in
+-aix3*)
+- test "$enable_shared" = yes && enable_static=no
+- if test -n "$RANLIB"; then
+- archive_cmds="$archive_cmds~\$RANLIB \$lib"
+- postinstall_cmds='$RANLIB $lib'
++sysv4*MP*)
++ if test -d /usr/nec ;then
++ version_type=linux
++ library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
++ soname_spec='$libname${shared_ext}.$major'
++ shlibpath_var=LD_LIBRARY_PATH
+ fi
+ ;;
+
+-aix4* | aix5*)
+- if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+- test "$enable_shared" = yes && enable_static=no
++sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
++ version_type=freebsd-elf
++ need_lib_prefix=no
++ need_version=no
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
++ soname_spec='${libname}${release}${shared_ext}$major'
++ shlibpath_var=LD_LIBRARY_PATH
++ shlibpath_overrides_runpath=yes
++ hardcode_into_libs=yes
++ if test "$with_gnu_ld" = yes; then
++ sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
++ else
++ sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
++ case $host_os in
++ sco3.2v5*)
++ sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
++ ;;
++ esac
+ fi
+- ;;
+-esac
+-AC_MSG_RESULT([$enable_shared])
+-
+-AC_MSG_CHECKING([whether to build static libraries])
+-# Make sure either enable_shared or enable_static is yes.
+-test "$enable_shared" = yes || enable_static=yes
+-AC_MSG_RESULT([$enable_static])
+-
+-AC_LIBTOOL_CONFIG($1)
+-
+-AC_LANG_POP
+-CC="$lt_save_CC"
+-])# AC_LIBTOOL_LANG_C_CONFIG
+-
+-
+-# AC_LIBTOOL_LANG_CXX_CONFIG
+-# --------------------------
+-# Ensure that the configuration vars for the C compiler are
+-# suitably defined. Those variables are subsequently used by
+-# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
+-AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG], [_LT_AC_LANG_CXX_CONFIG(CXX)])
+-AC_DEFUN([_LT_AC_LANG_CXX_CONFIG],
+-[AC_LANG_PUSH(C++)
+-AC_REQUIRE([AC_PROG_CXX])
+-AC_REQUIRE([_LT_AC_PROG_CXXCPP])
+-
+-_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+-_LT_AC_TAGVAR(allow_undefined_flag, $1)=
+-_LT_AC_TAGVAR(always_export_symbols, $1)=no
+-_LT_AC_TAGVAR(archive_expsym_cmds, $1)=
+-_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=
+-_LT_AC_TAGVAR(hardcode_direct, $1)=no
+-_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
+-_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
+-_LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
+-_LT_AC_TAGVAR(hardcode_minus_L, $1)=no
+-_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+-_LT_AC_TAGVAR(hardcode_automatic, $1)=no
+-_LT_AC_TAGVAR(module_cmds, $1)=
+-_LT_AC_TAGVAR(module_expsym_cmds, $1)=
+-_LT_AC_TAGVAR(link_all_deplibs, $1)=unknown
+-_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+-_LT_AC_TAGVAR(no_undefined_flag, $1)=
+-_LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+-_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+-
+-# Dependencies to place before and after the object being linked:
+-_LT_AC_TAGVAR(predep_objects, $1)=
+-_LT_AC_TAGVAR(postdep_objects, $1)=
+-_LT_AC_TAGVAR(predeps, $1)=
+-_LT_AC_TAGVAR(postdeps, $1)=
+-_LT_AC_TAGVAR(compiler_lib_search_path, $1)=
+-
+-# Source file extension for C++ test sources.
+-ac_ext=cpp
+-
+-# Object file extension for compiled C++ test sources.
+-objext=o
+-_LT_AC_TAGVAR(objext, $1)=$objext
+-
+-# Code to be used in simple compile tests
+-lt_simple_compile_test_code="int some_variable = 0;\n"
++ sys_lib_dlsearch_path_spec='/usr/lib'
++ ;;
+
+-# Code to be used in simple link tests
+-lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }\n'
++tpf*)
++ # TPF is a cross-target only. Preferred cross-host = GNU/Linux.
++ version_type=linux
++ need_lib_prefix=no
++ need_version=no
++ library_name_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
++ shlibpath_var=LD_LIBRARY_PATH
++ shlibpath_overrides_runpath=no
++ hardcode_into_libs=yes
++ ;;
+
+-# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+-_LT_AC_SYS_COMPILER
++uts4*)
++ version_type=linux
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
++ soname_spec='${libname}${release}${shared_ext}$major'
++ shlibpath_var=LD_LIBRARY_PATH
++ ;;
+
+-# save warnings/boilerplate of simple test code
+-_LT_COMPILER_BOILERPLATE
+-_LT_LINKER_BOILERPLATE
++*)
++ dynamic_linker=no
++ ;;
++esac
++AC_MSG_RESULT([$dynamic_linker])
++test "$dynamic_linker" = no && can_build_shared=no
+
+-# Allow CC to be a program name with arguments.
+-lt_save_CC=$CC
+-lt_save_LD=$LD
+-lt_save_GCC=$GCC
+-GCC=$GXX
+-lt_save_with_gnu_ld=$with_gnu_ld
+-lt_save_path_LD=$lt_cv_path_LD
+-if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then
+- lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx
+-else
+- $as_unset lt_cv_prog_gnu_ld
++variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
++if test "$GCC" = yes; then
++ variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
+ fi
+-if test -n "${lt_cv_path_LDCXX+set}"; then
+- lt_cv_path_LD=$lt_cv_path_LDCXX
+-else
+- $as_unset lt_cv_path_LD
++
++if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
++ sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+ fi
+-test -z "${LDCXX+set}" || LD=$LDCXX
+-CC=${CXX-"c++"}
+-compiler=$CC
+-_LT_AC_TAGVAR(compiler, $1)=$CC
+-_LT_CC_BASENAME([$compiler])
+-
+-# We don't want -fno-exception wen compiling C++ code, so set the
+-# no_builtin_flag separately
+-if test "$GXX" = yes; then
+- _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
+-else
+- _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
++if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
++ sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+ fi
+
+-if test "$GXX" = yes; then
+- # Set up default GNU C++ configuration
+-
+- AC_PROG_LD
+-
+- # Check if GNU C++ uses GNU ld as the underlying linker, since the
+- # archiving commands below assume that GNU ld is being used.
+- if test "$with_gnu_ld" = yes; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+-
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+-
+- # If archive_cmds runs LD, not CC, wlarc should be empty
+- # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
+- # investigate it a little bit more. (MM)
+- wlarc='${wl}'
+-
+- # ancient GNU ld didn't support --whole-archive et. al.
+- if eval "`$CC -print-prog-name=ld` --help 2>&1" | \
+- grep 'no-whole-archive' > /dev/null; then
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+- else
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+- fi
+- else
+- with_gnu_ld=no
+- wlarc=
+-
+- # A generic and very simple default shared library creation
+- # command for GNU C++ for the case where it uses the native
+- # linker, instead of GNU ld. If possible, this setting should
+- # overridden to take advantage of the native linker features on
+- # the platform it is being used on.
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+- fi
+-
+- # Commands to make compiler produce verbose output that lists
+- # what "hidden" libraries, object files and flags are used when
+- # linking a shared library.
+- output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"'
+-
+-else
+- GXX=no
+- with_gnu_ld=no
+- wlarc=
+-fi
++_LT_DECL([], [variables_saved_for_relink], [1],
++ [Variables whose values should be saved in libtool wrapper scripts and
++ restored at link time])
++_LT_DECL([], [need_lib_prefix], [0],
++ [Do we need the "lib" prefix for modules?])
++_LT_DECL([], [need_version], [0], [Do we need a version for libraries?])
++_LT_DECL([], [version_type], [0], [Library versioning type])
++_LT_DECL([], [runpath_var], [0], [Shared library runtime path variable])
++_LT_DECL([], [shlibpath_var], [0],[Shared library path variable])
++_LT_DECL([], [shlibpath_overrides_runpath], [0],
++ [Is shlibpath searched before the hard-coded library search path?])
++_LT_DECL([], [libname_spec], [1], [Format of library name prefix])
++_LT_DECL([], [library_names_spec], [1],
++ [[List of archive names. First name is the real one, the rest are links.
++ The last name is the one that the linker finds with -lNAME]])
++_LT_DECL([], [soname_spec], [1],
++ [[The coded name of the library, if different from the real name]])
++_LT_DECL([], [postinstall_cmds], [2],
++ [Command to use after installation of a shared archive])
++_LT_DECL([], [postuninstall_cmds], [2],
++ [Command to use after uninstallation of a shared archive])
++_LT_DECL([], [finish_cmds], [2],
++ [Commands used to finish a libtool library installation in a directory])
++_LT_DECL([], [finish_eval], [1],
++ [[As "finish_cmds", except a single script fragment to be evaled but
++ not shown]])
++_LT_DECL([], [hardcode_into_libs], [0],
++ [Whether we should hardcode library paths into libraries])
++_LT_DECL([], [sys_lib_search_path_spec], [2],
++ [Compile-time system search path for libraries])
++_LT_DECL([], [sys_lib_dlsearch_path_spec], [2],
++ [Run-time system search path for libraries])
++])# _LT_SYS_DYNAMIC_LINKER
+
+-# PORTME: fill in a description of your system's C++ link characteristics
+-AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
+-_LT_AC_TAGVAR(ld_shlibs, $1)=yes
+-case $host_os in
+- aix3*)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- aix4* | aix5*)
+- if test "$host_cpu" = ia64; then
+- # On IA64, the linker does run time linking by default, so we don't
+- # have to do anything special.
+- aix_use_runtimelinking=no
+- exp_sym_flag='-Bexport'
+- no_entry_flag=""
+- else
+- aix_use_runtimelinking=no
+
+- # Test if we are trying to use run time linking or normal
+- # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+- # need to do runtime linking.
+- case $host_os in aix4.[[23]]|aix4.[[23]].*|aix5*)
+- for ld_flag in $LDFLAGS; do
+- case $ld_flag in
+- *-brtl*)
+- aix_use_runtimelinking=yes
+- break
+- ;;
+- esac
+- done
+- ;;
+- esac
+-
+- exp_sym_flag='-bexport'
+- no_entry_flag='-bnoentry'
+- fi
++# _LT_PATH_TOOL_PREFIX(TOOL)
++# --------------------------
++# find a file program which can recognize shared library
++AC_DEFUN([_LT_PATH_TOOL_PREFIX],
++[m4_require([_LT_DECL_EGREP])dnl
++AC_MSG_CHECKING([for $1])
++AC_CACHE_VAL(lt_cv_path_MAGIC_CMD,
++[case $MAGIC_CMD in
++[[\\/*] | ?:[\\/]*])
++ lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
++ ;;
++*)
++ lt_save_MAGIC_CMD="$MAGIC_CMD"
++ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
++dnl $ac_dummy forces splitting on constant user-supplied paths.
++dnl POSIX.2 word splitting is done only on the output of word expansions,
++dnl not every word. This closes a longstanding sh security hole.
++ ac_dummy="m4_if([$2], , $PATH, [$2])"
++ for ac_dir in $ac_dummy; do
++ IFS="$lt_save_ifs"
++ test -z "$ac_dir" && ac_dir=.
++ if test -f $ac_dir/$1; then
++ lt_cv_path_MAGIC_CMD="$ac_dir/$1"
++ if test -n "$file_magic_test_file"; then
++ case $deplibs_check_method in
++ "file_magic "*)
++ file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
++ MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
++ if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
++ $EGREP "$file_magic_regex" > /dev/null; then
++ :
++ else
++ cat <<_LT_EOF 1>&2
+
+- # When large executables or shared objects are built, AIX ld can
+- # have problems creating the table of contents. If linking a library
+- # or program results in "error TOC overflow" add -mminimal-toc to
+- # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
+- # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+-
+- _LT_AC_TAGVAR(archive_cmds, $1)=''
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':'
+- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
++*** Warning: the command libtool uses to detect shared libraries,
++*** $file_magic_cmd, produces output that libtool cannot recognize.
++*** The result is that libtool may fail to recognize shared libraries
++*** as such. This will affect the creation of libtool libraries that
++*** depend on shared libraries, but programs linked with such libtool
++*** libraries will work regardless of this problem. Nevertheless, you
++*** may want to report the problem to your system manager and/or to
++*** bug-libtool@gnu.org
+
+- if test "$GXX" = yes; then
+- case $host_os in aix4.[[012]]|aix4.[[012]].*)
+- # We only want to do this on AIX 4.2 and lower, the check
+- # below for broken collect2 doesn't work under 4.3+
+- collect2name=`${CC} -print-prog-name=collect2`
+- if test -f "$collect2name" && \
+- strings "$collect2name" | grep resolve_lib_name >/dev/null
+- then
+- # We have reworked collect2
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- else
+- # We have old collect2
+- _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported
+- # It fails to find uninstalled libraries when the uninstalled
+- # path is not listed in the libpath. Setting hardcode_minus_L
+- # to unsupported forces relinking
+- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
+- fi
+- ;;
+- esac
+- shared_flag='-shared'
+- if test "$aix_use_runtimelinking" = yes; then
+- shared_flag="$shared_flag "'${wl}-G'
+- fi
+- else
+- # not using gcc
+- if test "$host_cpu" = ia64; then
+- # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+- # chokes on -Wl,-G. The following line is correct:
+- shared_flag='-G'
+- else
+- if test "$aix_use_runtimelinking" = yes; then
+- shared_flag='${wl}-G'
+- else
+- shared_flag='${wl}-bM:SRE'
+- fi
++_LT_EOF
++ fi ;;
++ esac
+ fi
++ break
+ fi
++ done
++ IFS="$lt_save_ifs"
++ MAGIC_CMD="$lt_save_MAGIC_CMD"
++ ;;
++esac])
++MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
++if test -n "$MAGIC_CMD"; then
++ AC_MSG_RESULT($MAGIC_CMD)
++else
++ AC_MSG_RESULT(no)
++fi
++_LT_DECL([], [MAGIC_CMD], [0],
++ [Used to examine libraries when file_magic_cmd begins with "file"])dnl
++])# _LT_PATH_TOOL_PREFIX
+
+- # It seems that -bexpall does not export symbols beginning with
+- # underscore (_), so it is better to generate a list of symbols to export.
+- _LT_AC_TAGVAR(always_export_symbols, $1)=yes
+- if test "$aix_use_runtimelinking" = yes; then
+- # Warning - without using the other runtime loading flags (-brtl),
+- # -berok will link without error, but may produce a broken library.
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)='-berok'
+- # Determine the default libpath from the value encoded in an empty executable.
+- _LT_AC_SYS_LIBPATH_AIX
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
++# Old name:
++AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX])
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], [])
+
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+- else
+- if test "$host_cpu" = ia64; then
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+- else
+- # Determine the default libpath from the value encoded in an empty executable.
+- _LT_AC_SYS_LIBPATH_AIX
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+- # Warning - without using the other run time loading flags,
+- # -berok will link without error, but may produce a broken library.
+- _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
+- # Exported symbols can be pulled into shared objects from archives
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
+- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
+- # This is similar to how AIX traditionally builds its shared libraries.
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+- fi
+- fi
+- ;;
+
+- beos*)
+- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+- # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
+- # support --undefined. This deserves some investigation. FIXME
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+- else
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- fi
+- ;;
++# _LT_PATH_MAGIC
++# --------------
++# find a file program which can recognize a shared library
++m4_defun([_LT_PATH_MAGIC],
++[_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH)
++if test -z "$lt_cv_path_MAGIC_CMD"; then
++ if test -n "$ac_tool_prefix"; then
++ _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH)
++ else
++ MAGIC_CMD=:
++ fi
++fi
++])# _LT_PATH_MAGIC
+
+- chorus*)
+- case $cc_basename in
+- *)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- esac
+- ;;
+
+- cygwin* | mingw* | pw32*)
+- # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
+- # as there is no search path for DLLs.
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+- _LT_AC_TAGVAR(always_export_symbols, $1)=no
+- _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+-
+- if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+- # If the export-symbols file already is a .def file (1st line
+- # is EXPORTS), use it as is; otherwise, prepend...
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+- cp $export_symbols $output_objdir/$soname.def;
+- else
+- echo EXPORTS > $output_objdir/$soname.def;
+- cat $export_symbols >> $output_objdir/$soname.def;
+- fi~
+- $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+- else
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- fi
+- ;;
+- darwin* | rhapsody*)
+- case $host_os in
+- rhapsody* | darwin1.[[012]])
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}suppress'
+- ;;
+- *) # Darwin 1.3 on
+- if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+- else
+- case ${MACOSX_DEPLOYMENT_TARGET} in
+- 10.[[012]])
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+- ;;
+- 10.*)
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}dynamic_lookup'
+- ;;
+- esac
+- fi
+- ;;
+- esac
+- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+- _LT_AC_TAGVAR(hardcode_direct, $1)=no
+- _LT_AC_TAGVAR(hardcode_automatic, $1)=yes
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=''
+- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+-
+- if test "$GXX" = yes ; then
+- lt_int_apple_cc_single_mod=no
+- output_verbose_link_cmd='echo'
+- if $CC -dumpspecs 2>&1 | $EGREP 'single_module' >/dev/null ; then
+- lt_int_apple_cc_single_mod=yes
+- fi
+- if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+- else
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+- fi
+- _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+- # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
+- if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+- else
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+- fi
+- _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+- else
+- case $cc_basename in
+- xlc*)
+- output_verbose_link_cmd='echo'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
+- _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+- # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+- _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+- ;;
+- *)
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- esac
+- fi
+- ;;
++# LT_PATH_LD
++# ----------
++# find the pathname to the GNU or non-GNU linker
++AC_DEFUN([LT_PATH_LD],
++[AC_REQUIRE([AC_PROG_CC])dnl
++AC_REQUIRE([AC_CANONICAL_HOST])dnl
++AC_REQUIRE([AC_CANONICAL_BUILD])dnl
++m4_require([_LT_DECL_SED])dnl
++m4_require([_LT_DECL_EGREP])dnl
+
+- dgux*)
+- case $cc_basename in
+- ec++*)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- ghcx*)
+- # Green Hills C++ Compiler
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- *)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- esac
+- ;;
+- freebsd[[12]]*)
+- # C++ shared libraries reported to be fairly broken before switch to ELF
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- freebsd-elf*)
+- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+- ;;
+- freebsd* | kfreebsd*-gnu | dragonfly*)
+- # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
+- # conventions
+- _LT_AC_TAGVAR(ld_shlibs, $1)=yes
+- ;;
+- gnu*)
+- ;;
+- hpux9*)
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
+- # but as the default
+- # location of the library.
+-
+- case $cc_basename in
+- CC*)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- aCC*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+- # Commands to make compiler produce verbose output that lists
+- # what "hidden" libraries, object files and flags are used when
+- # linking a shared library.
+- #
+- # There doesn't appear to be a way to prevent this compiler from
+- # explicitly linking system object files so we need to strip them
+- # from the output so that they don't get included in the library
+- # dependencies.
+- output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "[[-]]L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+- ;;
+- *)
+- if test "$GXX" = yes; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+- else
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- fi
+- ;;
+- esac
+- ;;
+- hpux10*|hpux11*)
+- if test $with_gnu_ld = no; then
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
++AC_ARG_WITH([gnu-ld],
++ [AS_HELP_STRING([--with-gnu-ld],
++ [assume the C compiler uses GNU ld @<:@default=no@:>@])],
++ [test "$withval" = no || with_gnu_ld=yes],
++ [with_gnu_ld=no])dnl
+
+- case $host_cpu in
+- hppa*64*|ia64*)
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir'
+- ;;
+- *)
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+- ;;
+- esac
+- fi
+- case $host_cpu in
+- hppa*64*|ia64*)
+- _LT_AC_TAGVAR(hardcode_direct, $1)=no
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- ;;
+- *)
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
+- # but as the default
+- # location of the library.
++ac_prog=ld
++if test "$GCC" = yes; then
++ # Check if gcc -print-prog-name=ld gives a path.
++ AC_MSG_CHECKING([for ld used by $CC])
++ case $host in
++ *-*-mingw*)
++ # gcc leaves a trailing carriage return which upsets mingw
++ ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
++ *)
++ ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
++ esac
++ case $ac_prog in
++ # Accept absolute paths.
++ [[\\/]]* | ?:[[\\/]]*)
++ re_direlt='/[[^/]][[^/]]*/\.\./'
++ # Canonicalize the pathname of ld
++ ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'`
++ while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
++ ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
++ done
++ test -z "$LD" && LD="$ac_prog"
+ ;;
+- esac
+-
+- case $cc_basename in
+- CC*)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- aCC*)
+- case $host_cpu in
+- hppa*64*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+- ;;
+- ia64*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+- ;;
+- *)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+- ;;
+- esac
+- # Commands to make compiler produce verbose output that lists
+- # what "hidden" libraries, object files and flags are used when
+- # linking a shared library.
+- #
+- # There doesn't appear to be a way to prevent this compiler from
+- # explicitly linking system object files so we need to strip them
+- # from the output so that they don't get included in the library
+- # dependencies.
+- output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+- ;;
+- *)
+- if test "$GXX" = yes; then
+- if test $with_gnu_ld = no; then
+- case $host_cpu in
+- hppa*64*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+- ;;
+- ia64*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+- ;;
+- *)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+- ;;
+- esac
+- fi
+- else
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- fi
+- ;;
+- esac
+- ;;
+- interix3*)
+- _LT_AC_TAGVAR(hardcode_direct, $1)=no
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+- # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+- # Instead, shared libraries are loaded at an image base (0x10000000 by
+- # default) and relocated if they conflict, which is a slow very memory
+- # consuming and fragmenting process. To avoid this, we pick a random,
+- # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+- # time. Moving up from 0x10000000 also allows more sbrk(2) space.
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+- ;;
+- irix5* | irix6*)
+- case $cc_basename in
+- CC*)
+- # SGI C++
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+-
+- # Archives containing C++ object files must be created using
+- # "CC -ar", where "CC" is the IRIX C++ compiler. This is
+- # necessary to make sure instantiated templates are included
+- # in the archive.
+- _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs'
+- ;;
+- *)
+- if test "$GXX" = yes; then
+- if test "$with_gnu_ld" = no; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+- else
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` -o $lib'
+- fi
+- fi
+- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+- ;;
+- esac
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
++ "")
++ # If it fails, then pretend we aren't using GCC.
++ ac_prog=ld
+ ;;
+- linux*)
+- case $cc_basename in
+- KCC*)
+- # Kuck and Associates, Inc. (KAI) C++ Compiler
+-
+- # KCC will only create a shared library if the output file
+- # ends with ".so" (or ".sl" for HP-UX), so rename the library
+- # to its proper name (with version) after linking.
+- _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib'
+- # Commands to make compiler produce verbose output that lists
+- # what "hidden" libraries, object files and flags are used when
+- # linking a shared library.
+- #
+- # There doesn't appear to be a way to prevent this compiler from
+- # explicitly linking system object files so we need to strip them
+- # from the output so that they don't get included in the library
+- # dependencies.
+- output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | grep "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+-
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath,$libdir'
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+-
+- # Archives containing C++ object files must be created using
+- # "CC -Bstatic", where "CC" is the KAI C++ compiler.
+- _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs'
+- ;;
+- icpc*)
+- # Intel C++
+- with_gnu_ld=yes
+- # version 8.0 and above of icpc choke on multiply defined symbols
+- # if we add $predep_objects and $postdep_objects, however 7.1 and
+- # earlier do not add the objects themselves.
+- case `$CC -V 2>&1` in
+- *"Version 7."*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+- ;;
+- *) # Version 8.0 or newer
+- tmp_idyn=
+- case $host_cpu in
+- ia64*) tmp_idyn=' -i_dynamic';;
+- esac
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+- ;;
+- esac
+- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+- ;;
+- pgCC*)
+- # Portland Group C++ compiler
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+-
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+- ;;
+- cxx*)
+- # Compaq C++
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
+-
+- runpath_var=LD_RUN_PATH
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+-
+- # Commands to make compiler produce verbose output that lists
+- # what "hidden" libraries, object files and flags are used when
+- # linking a shared library.
+- #
+- # There doesn't appear to be a way to prevent this compiler from
+- # explicitly linking system object files so we need to strip them
+- # from the output so that they don't get included in the library
+- # dependencies.
+- output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+- ;;
+- *)
+- case `$CC -V 2>&1 | sed 5q` in
+- *Sun\ C*)
+- # Sun C++ 5.9
+- _LT_AC_TAGVAR(no_undefined_flag, $1)=' -zdefs'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols'
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+-
+- # Not sure whether something based on
+- # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1
+- # would be better.
+- output_verbose_link_cmd='echo'
+-
+- # Archives containing C++ object files must be created using
+- # "CC -xar", where "CC" is the Sun C++ compiler. This is
+- # necessary to make sure instantiated templates are included
+- # in the archive.
+- _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
+- ;;
+- esac
+- ;;
+- esac
++ *)
++ # If it is relative, then search for the first ld in PATH.
++ with_gnu_ld=unknown
+ ;;
+- lynxos*)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- m88k*)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- mvs*)
+- case $cc_basename in
+- cxx*)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
++ esac
++elif test "$with_gnu_ld" = yes; then
++ AC_MSG_CHECKING([for GNU ld])
++else
++ AC_MSG_CHECKING([for non-GNU ld])
++fi
++AC_CACHE_VAL(lt_cv_path_LD,
++[if test -z "$LD"; then
++ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
++ for ac_dir in $PATH; do
++ IFS="$lt_save_ifs"
++ test -z "$ac_dir" && ac_dir=.
++ if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
++ lt_cv_path_LD="$ac_dir/$ac_prog"
++ # Check to see if the program is GNU ld. I'd rather use --version,
++ # but apparently some variants of GNU ld only accept -v.
++ # Break only if it was the GNU/non-GNU ld that we prefer.
++ case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
++ *GNU* | *'with BFD'*)
++ test "$with_gnu_ld" != no && break
+ ;;
+ *)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
++ test "$with_gnu_ld" != yes && break
+ ;;
+- esac
+- ;;
+- netbsd*)
+- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags'
+- wlarc=
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- fi
+- # Workaround some broken pre-1.5 toolchains
+- output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"'
+- ;;
+- openbsd2*)
+- # C++ shared libraries are fairly broken
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- openbsd*)
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
++ esac
+ fi
+- output_verbose_link_cmd='echo'
+- ;;
+- osf3*)
+- case $cc_basename in
+- KCC*)
+- # Kuck and Associates, Inc. (KAI) C++ Compiler
+-
+- # KCC will only create a shared library if the output file
+- # ends with ".so" (or ".sl" for HP-UX), so rename the library
+- # to its proper name (with version) after linking.
+- _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+-
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+-
+- # Archives containing C++ object files must be created using
+- # "CC -Bstatic", where "CC" is the KAI C++ compiler.
+- _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs'
+-
+- ;;
+- RCC*)
+- # Rational C++ 2.4.1
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- cxx*)
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && echo ${wl}-set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+-
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+-
+- # Commands to make compiler produce verbose output that lists
+- # what "hidden" libraries, object files and flags are used when
+- # linking a shared library.
+- #
+- # There doesn't appear to be a way to prevent this compiler from
+- # explicitly linking system object files so we need to strip them
+- # from the output so that they don't get included in the library
+- # dependencies.
+- output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+- ;;
+- *)
+- if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+-
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+-
+- # Commands to make compiler produce verbose output that lists
+- # what "hidden" libraries, object files and flags are used when
+- # linking a shared library.
+- output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"'
++ done
++ IFS="$lt_save_ifs"
++else
++ lt_cv_path_LD="$LD" # Let the user override the test with a path.
++fi])
++LD="$lt_cv_path_LD"
++if test -n "$LD"; then
++ AC_MSG_RESULT($LD)
++else
++ AC_MSG_RESULT(no)
++fi
++test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
++_LT_PATH_LD_GNU
++AC_SUBST([LD])
+
+- else
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- fi
+- ;;
+- esac
+- ;;
+- osf4* | osf5*)
+- case $cc_basename in
+- KCC*)
+- # Kuck and Associates, Inc. (KAI) C++ Compiler
+-
+- # KCC will only create a shared library if the output file
+- # ends with ".so" (or ".sl" for HP-UX), so rename the library
+- # to its proper name (with version) after linking.
+- _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+-
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+-
+- # Archives containing C++ object files must be created using
+- # the KAI C++ compiler.
+- _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs'
+- ;;
+- RCC*)
+- # Rational C++ 2.4.1
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- cxx*)
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
+- echo "-hidden">> $lib.exp~
+- $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname -Wl,-input -Wl,$lib.exp `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~
+- $rm $lib.exp'
+-
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+-
+- # Commands to make compiler produce verbose output that lists
+- # what "hidden" libraries, object files and flags are used when
+- # linking a shared library.
+- #
+- # There doesn't appear to be a way to prevent this compiler from
+- # explicitly linking system object files so we need to strip them
+- # from the output so that they don't get included in the library
+- # dependencies.
+- output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+- ;;
+- *)
+- if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+-
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+-
+- # Commands to make compiler produce verbose output that lists
+- # what "hidden" libraries, object files and flags are used when
+- # linking a shared library.
+- output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"'
++_LT_TAGDECL([], [LD], [1], [The linker used to build libraries])
++])# LT_PATH_LD
+
+- else
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- fi
+- ;;
+- esac
+- ;;
+- psos*)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- sunos4*)
+- case $cc_basename in
+- CC*)
+- # Sun C++ 4.x
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- lcc*)
+- # Lucid
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- *)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- esac
++# Old names:
++AU_ALIAS([AM_PROG_LD], [LT_PATH_LD])
++AU_ALIAS([AC_PROG_LD], [LT_PATH_LD])
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([AM_PROG_LD], [])
++dnl AC_DEFUN([AC_PROG_LD], [])
++
++
++# _LT_PATH_LD_GNU
++#- --------------
++m4_defun([_LT_PATH_LD_GNU],
++[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], lt_cv_prog_gnu_ld,
++[# I'd rather use --version here, but apparently some GNU lds only accept -v.
++case `$LD -v 2>&1 </dev/null` in
++*GNU* | *'with BFD'*)
++ lt_cv_prog_gnu_ld=yes
++ ;;
++*)
++ lt_cv_prog_gnu_ld=no
++ ;;
++esac])
++with_gnu_ld=$lt_cv_prog_gnu_ld
++])# _LT_PATH_LD_GNU
++
++
++# _LT_CMD_RELOAD
++# --------------
++# find reload flag for linker
++# -- PORTME Some linkers may need a different reload flag.
++m4_defun([_LT_CMD_RELOAD],
++[AC_CACHE_CHECK([for $LD option to reload object files],
++ lt_cv_ld_reload_flag,
++ [lt_cv_ld_reload_flag='-r'])
++reload_flag=$lt_cv_ld_reload_flag
++case $reload_flag in
++"" | " "*) ;;
++*) reload_flag=" $reload_flag" ;;
++esac
++reload_cmds='$LD$reload_flag -o $output$reload_objs'
++case $host_os in
++ darwin*)
++ if test "$GCC" = yes; then
++ reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
++ else
++ reload_cmds='$LD$reload_flag -o $output$reload_objs'
++ fi
+ ;;
+- solaris*)
+- case $cc_basename in
+- CC*)
+- # Sun C++ 4.2, 5.x and Centerline C++
+- _LT_AC_TAGVAR(archive_cmds_need_lc,$1)=yes
+- _LT_AC_TAGVAR(no_undefined_flag, $1)=' -zdefs'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+- $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
+-
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- case $host_os in
+- solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
+- *)
+- # The C++ compiler is used as linker so we must use $wl
+- # flag to pass the commands to the underlying system
+- # linker. We must also pass each convience library through
+- # to the system linker between allextract/defaultextract.
+- # The C++ compiler will combine linker options so we
+- # cannot just pass the convience library names through
+- # without $wl.
+- # Supported since Solaris 2.6 (maybe 2.5.1?)
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract'
+- ;;
+- esac
+- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
++esac
++_LT_DECL([], [reload_flag], [1], [How to create reloadable object files])dnl
++_LT_DECL([], [reload_cmds], [2])dnl
++])# _LT_CMD_RELOAD
+
+- output_verbose_link_cmd='echo'
+
+- # Archives containing C++ object files must be created using
+- # "CC -xar", where "CC" is the Sun C++ compiler. This is
+- # necessary to make sure instantiated templates are included
+- # in the archive.
+- _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
+- ;;
+- gcx*)
+- # Green Hills C++ Compiler
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
++# _LT_CHECK_MAGIC_METHOD
++# ----------------------
++# how to check for library dependencies
++# -- PORTME fill in with the dynamic library characteristics
++m4_defun([_LT_CHECK_MAGIC_METHOD],
++[m4_require([_LT_DECL_EGREP])
++AC_CACHE_CHECK([how to recognize dependent libraries],
++lt_cv_deplibs_check_method,
++[lt_cv_file_magic_cmd='$MAGIC_CMD'
++lt_cv_file_magic_test_file=
++lt_cv_deplibs_check_method='unknown'
++# Need to set the preceding variable on all platforms that support
++# interlibrary dependencies.
++# 'none' -- dependencies not supported.
++# `unknown' -- same as none, but documents that we really don't know.
++# 'pass_all' -- all dependencies passed with no checks.
++# 'test_compile' -- check by making test program.
++# 'file_magic [[regex]]' -- check by looking for files in library path
++# which responds to the $file_magic_cmd with a given extended regex.
++# If you have `file' or equivalent on your system and you're not sure
++# whether `pass_all' will *always* work, you probably want this one.
+
+- # The C++ compiler must be used to create the archive.
+- _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
+- ;;
+- *)
+- # GNU C++ compiler with Solaris linker
+- if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+- _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs'
+- if $CC --version | grep -v '^2\.7' > /dev/null; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+- $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
++case $host_os in
++aix[[4-9]]*)
++ lt_cv_deplibs_check_method=pass_all
++ ;;
+
+- # Commands to make compiler produce verbose output that lists
+- # what "hidden" libraries, object files and flags are used when
+- # linking a shared library.
+- output_verbose_link_cmd="$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\""
+- else
+- # g++ 2.7 appears to require `-G' NOT `-shared' on this
+- # platform.
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+- $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
++beos*)
++ lt_cv_deplibs_check_method=pass_all
++ ;;
+
+- # Commands to make compiler produce verbose output that lists
+- # what "hidden" libraries, object files and flags are used when
+- # linking a shared library.
+- output_verbose_link_cmd="$CC -G $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\""
+- fi
++bsdi[[45]]*)
++ lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib)'
++ lt_cv_file_magic_cmd='/usr/bin/file -L'
++ lt_cv_file_magic_test_file=/shlib/libc.so
++ ;;
+
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir'
+- fi
+- ;;
+- esac
+- ;;
+- sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
+- _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- runpath_var='LD_RUN_PATH'
+-
+- case $cc_basename in
+- CC*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+- ;;
+- *)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+- ;;
+- esac
+- ;;
+- sysv5* | sco3.2v5* | sco5v6*)
+- # Note: We can NOT use -z defs as we might desire, because we do not
+- # link with -lc, and that would cause any symbols used from libc to
+- # always be unresolved, which means just about no library would
+- # ever link correctly. If we're not using GNU ld we use -z text
+- # though, which does catch some bad symbols but isn't as heavy-handed
+- # as -z defs.
+- # For security reasons, it is highly recommended that you always
+- # use absolute paths for naming shared libraries, and exclude the
+- # DT_RUNPATH tag from executables and libraries. But doing so
+- # requires that you compile everything twice, which is a pain.
+- # So that behaviour is only enabled if SCOABSPATH is set to a
+- # non-empty value in the environment. Most likely only useful for
+- # creating official distributions of packages.
+- # This is a hack until libtool officially supports absolute path
+- # names for shared libraries.
+- _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
+- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':'
+- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
+- runpath_var='LD_RUN_PATH'
+-
+- case $cc_basename in
+- CC*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+- ;;
+- *)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+- ;;
+- esac
+- ;;
+- tandem*)
+- case $cc_basename in
+- NCC*)
+- # NonStop-UX NCC 3.20
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- *)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
++cygwin*)
++ # func_win32_libid is a shell function defined in ltmain.sh
++ lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
++ lt_cv_file_magic_cmd='func_win32_libid'
++ ;;
++
++mingw* | pw32*)
++ # Base MSYS/MinGW do not provide the 'file' command needed by
++ # func_win32_libid shell function, so use a weaker test based on 'objdump',
++ # unless we find 'file', for example because we are cross-compiling.
++ if ( file / ) >/dev/null 2>&1; then
++ lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
++ lt_cv_file_magic_cmd='func_win32_libid'
++ else
++ lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?'
++ lt_cv_file_magic_cmd='$OBJDUMP -f'
++ fi
++ ;;
++
++darwin* | rhapsody*)
++ lt_cv_deplibs_check_method=pass_all
++ ;;
++
++freebsd* | dragonfly*)
++ if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
++ case $host_cpu in
++ i*86 )
++ # Not sure whether the presence of OpenBSD here was a mistake.
++ # Let's accept both of them until this is cleared up.
++ lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library'
++ lt_cv_file_magic_cmd=/usr/bin/file
++ lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
++ ;;
+ esac
++ else
++ lt_cv_deplibs_check_method=pass_all
++ fi
++ ;;
++
++gnu*)
++ lt_cv_deplibs_check_method=pass_all
++ ;;
++
++hpux10.20* | hpux11*)
++ lt_cv_file_magic_cmd=/usr/bin/file
++ case $host_cpu in
++ ia64*)
++ lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64'
++ lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
+ ;;
+- vxworks*)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
++ hppa*64*)
++ [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]']
++ lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
+ ;;
+ *)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
++ lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]].[[0-9]]) shared library'
++ lt_cv_file_magic_test_file=/usr/lib/libc.sl
+ ;;
+-esac
+-AC_MSG_RESULT([$_LT_AC_TAGVAR(ld_shlibs, $1)])
+-test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
++ esac
++ ;;
+
+-_LT_AC_TAGVAR(GCC, $1)="$GXX"
+-_LT_AC_TAGVAR(LD, $1)="$LD"
++interix[[3-9]]*)
++ # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
++ lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$'
++ ;;
+
+-## CAVEAT EMPTOR:
+-## There is no encapsulation within the following macros, do not change
+-## the running order or otherwise move them around unless you know exactly
+-## what you are doing...
+-AC_LIBTOOL_POSTDEP_PREDEP($1)
+-AC_LIBTOOL_PROG_COMPILER_PIC($1)
+-AC_LIBTOOL_PROG_CC_C_O($1)
+-AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
+-AC_LIBTOOL_PROG_LD_SHLIBS($1)
+-AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
+-AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
++irix5* | irix6* | nonstopux*)
++ case $LD in
++ *-32|*"-32 ") libmagic=32-bit;;
++ *-n32|*"-n32 ") libmagic=N32;;
++ *-64|*"-64 ") libmagic=64-bit;;
++ *) libmagic=never-match;;
++ esac
++ lt_cv_deplibs_check_method=pass_all
++ ;;
+
+-AC_LIBTOOL_CONFIG($1)
++# This must be Linux ELF.
++linux* | k*bsd*-gnu)
++ lt_cv_deplibs_check_method=pass_all
++ ;;
+
+-AC_LANG_POP
+-CC=$lt_save_CC
+-LDCXX=$LD
+-LD=$lt_save_LD
+-GCC=$lt_save_GCC
+-with_gnu_ldcxx=$with_gnu_ld
+-with_gnu_ld=$lt_save_with_gnu_ld
+-lt_cv_path_LDCXX=$lt_cv_path_LD
+-lt_cv_path_LD=$lt_save_path_LD
+-lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
+-lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
+-])# AC_LIBTOOL_LANG_CXX_CONFIG
++netbsd*)
++ if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
++ lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
++ else
++ lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$'
++ fi
++ ;;
+
+-# AC_LIBTOOL_POSTDEP_PREDEP([TAGNAME])
+-# ------------------------------------
+-# Figure out "hidden" library dependencies from verbose
+-# compiler output when linking a shared library.
+-# Parse the compiler output and extract the necessary
+-# objects, libraries and library flags.
+-AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP],[
+-dnl we can't use the lt_simple_compile_test_code here,
+-dnl because it contains code intended for an executable,
+-dnl not a library. It's possible we should let each
+-dnl tag define a new lt_????_link_test_code variable,
+-dnl but it's only used here...
+-ifelse([$1],[],[cat > conftest.$ac_ext <<EOF
+-int a;
+-void foo (void) { a = 0; }
+-EOF
+-],[$1],[CXX],[cat > conftest.$ac_ext <<EOF
+-class Foo
+-{
+-public:
+- Foo (void) { a = 0; }
+-private:
+- int a;
+-};
+-EOF
+-],[$1],[F77],[cat > conftest.$ac_ext <<EOF
+- subroutine foo
+- implicit none
+- integer*4 a
+- a=0
+- return
+- end
+-EOF
+-],[$1],[GCJ],[cat > conftest.$ac_ext <<EOF
+-public class foo {
+- private int a;
+- public void bar (void) {
+- a = 0;
+- }
+-};
+-EOF
+-])
+-dnl Parse the compiler output and extract the necessary
+-dnl objects, libraries and library flags.
+-if AC_TRY_EVAL(ac_compile); then
+- # Parse the compiler output and extract the necessary
+- # objects, libraries and library flags.
++newos6*)
++ lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)'
++ lt_cv_file_magic_cmd=/usr/bin/file
++ lt_cv_file_magic_test_file=/usr/lib/libnls.so
++ ;;
+
+- # Sentinel used to keep track of whether or not we are before
+- # the conftest object file.
+- pre_test_object_deps_done=no
++*nto* | *qnx*)
++ lt_cv_deplibs_check_method=pass_all
++ ;;
+
+- # The `*' in the case matches for architectures that use `case' in
+- # $output_verbose_cmd can trigger glob expansion during the loop
+- # eval without this substitution.
+- output_verbose_link_cmd=`$echo "X$output_verbose_link_cmd" | $Xsed -e "$no_glob_subst"`
++openbsd*)
++ if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
++ lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$'
++ else
++ lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
++ fi
++ ;;
+
+- for p in `eval $output_verbose_link_cmd`; do
+- case $p in
++osf3* | osf4* | osf5*)
++ lt_cv_deplibs_check_method=pass_all
++ ;;
+
+- -L* | -R* | -l*)
+- # Some compilers place space between "-{L,R}" and the path.
+- # Remove the space.
+- if test $p = "-L" \
+- || test $p = "-R"; then
+- prev=$p
+- continue
+- else
+- prev=
+- fi
++rdos*)
++ lt_cv_deplibs_check_method=pass_all
++ ;;
++
++solaris*)
++ lt_cv_deplibs_check_method=pass_all
++ ;;
++
++sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
++ lt_cv_deplibs_check_method=pass_all
++ ;;
++
++sysv4 | sysv4.3*)
++ case $host_vendor in
++ motorola)
++ lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]'
++ lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
++ ;;
++ ncr)
++ lt_cv_deplibs_check_method=pass_all
++ ;;
++ sequent)
++ lt_cv_file_magic_cmd='/bin/file'
++ lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )'
++ ;;
++ sni)
++ lt_cv_file_magic_cmd='/bin/file'
++ lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib"
++ lt_cv_file_magic_test_file=/lib/libc.so
++ ;;
++ siemens)
++ lt_cv_deplibs_check_method=pass_all
++ ;;
++ pc)
++ lt_cv_deplibs_check_method=pass_all
++ ;;
++ esac
++ ;;
++
++tpf*)
++ lt_cv_deplibs_check_method=pass_all
++ ;;
++esac
++])
++file_magic_cmd=$lt_cv_file_magic_cmd
++deplibs_check_method=$lt_cv_deplibs_check_method
++test -z "$deplibs_check_method" && deplibs_check_method=unknown
++
++_LT_DECL([], [deplibs_check_method], [1],
++ [Method to check whether dependent libraries are shared objects])
++_LT_DECL([], [file_magic_cmd], [1],
++ [Command to use when deplibs_check_method == "file_magic"])
++])# _LT_CHECK_MAGIC_METHOD
++
++
++# LT_PATH_NM
++# ----------
++# find the pathname to a BSD- or MS-compatible name lister
++AC_DEFUN([LT_PATH_NM],
++[AC_REQUIRE([AC_PROG_CC])dnl
++AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM,
++[if test -n "$NM"; then
++ # Let the user override the test.
++ lt_cv_path_NM="$NM"
++else
++ lt_nm_to_check="${ac_tool_prefix}nm"
++ if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
++ lt_nm_to_check="$lt_nm_to_check nm"
++ fi
++ for lt_tmp_nm in $lt_nm_to_check; do
++ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
++ for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
++ IFS="$lt_save_ifs"
++ test -z "$ac_dir" && ac_dir=.
++ tmp_nm="$ac_dir/$lt_tmp_nm"
++ if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
++ # Check to see if the nm accepts a BSD-compat flag.
++ # Adding the `sed 1q' prevents false positives on HP-UX, which says:
++ # nm: unknown option "B" ignored
++ # Tru64's nm complains that /dev/null is an invalid object file
++ case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
++ */dev/null* | *'Invalid file or object type'*)
++ lt_cv_path_NM="$tmp_nm -B"
++ break
++ ;;
++ *)
++ case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
++ */dev/null*)
++ lt_cv_path_NM="$tmp_nm -p"
++ break
++ ;;
++ *)
++ lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
++ continue # so that we can try to find one that supports BSD flags
++ ;;
++ esac
++ ;;
++ esac
++ fi
++ done
++ IFS="$lt_save_ifs"
++ done
++ : ${lt_cv_path_NM=no}
++fi])
++if test "$lt_cv_path_NM" != "no"; then
++ NM="$lt_cv_path_NM"
++else
++ # Didn't find any BSD compatible name lister, look for dumpbin.
++ AC_CHECK_TOOLS(DUMPBIN, ["dumpbin -symbols" "link -dump -symbols"], :)
++ AC_SUBST([DUMPBIN])
++ if test "$DUMPBIN" != ":"; then
++ NM="$DUMPBIN"
++ fi
++fi
++test -z "$NM" && NM=nm
++AC_SUBST([NM])
++_LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl
++
++AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface],
++ [lt_cv_nm_interface="BSD nm"
++ echo "int some_variable = 0;" > conftest.$ac_ext
++ (eval echo "\"\$as_me:__oline__: $ac_compile\"" >&AS_MESSAGE_LOG_FD)
++ (eval "$ac_compile" 2>conftest.err)
++ cat conftest.err >&AS_MESSAGE_LOG_FD
++ (eval echo "\"\$as_me:__oline__: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD)
++ (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
++ cat conftest.err >&AS_MESSAGE_LOG_FD
++ (eval echo "\"\$as_me:__oline__: output\"" >&AS_MESSAGE_LOG_FD)
++ cat conftest.out >&AS_MESSAGE_LOG_FD
++ if $GREP 'External.*some_variable' conftest.out > /dev/null; then
++ lt_cv_nm_interface="MS dumpbin"
++ fi
++ rm -f conftest*])
++])# LT_PATH_NM
++
++# Old names:
++AU_ALIAS([AM_PROG_NM], [LT_PATH_NM])
++AU_ALIAS([AC_PROG_NM], [LT_PATH_NM])
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([AM_PROG_NM], [])
++dnl AC_DEFUN([AC_PROG_NM], [])
++
++
++# LT_LIB_M
++# --------
++# check for math library
++AC_DEFUN([LT_LIB_M],
++[AC_REQUIRE([AC_CANONICAL_HOST])dnl
++LIBM=
++case $host in
++*-*-beos* | *-*-cygwin* | *-*-pw32* | *-*-darwin*)
++ # These system don't have libm, or don't need it
++ ;;
++*-ncr-sysv4.3*)
++ AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
++ AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm")
++ ;;
++*)
++ AC_CHECK_LIB(m, cos, LIBM="-lm")
++ ;;
++esac
++AC_SUBST([LIBM])
++])# LT_LIB_M
++
++# Old name:
++AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M])
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([AC_CHECK_LIBM], [])
++
++
++# _LT_COMPILER_NO_RTTI([TAGNAME])
++# -------------------------------
++m4_defun([_LT_COMPILER_NO_RTTI],
++[m4_require([_LT_TAG_COMPILER])dnl
++
++_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
++
++if test "$GCC" = yes; then
++ _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
++
++ _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions],
++ lt_cv_prog_compiler_rtti_exceptions,
++ [-fno-rtti -fno-exceptions], [],
++ [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"])
++fi
++_LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1],
++ [Compiler flag to turn off builtin functions])
++])# _LT_COMPILER_NO_RTTI
++
++
++# _LT_CMD_GLOBAL_SYMBOLS
++# ----------------------
++m4_defun([_LT_CMD_GLOBAL_SYMBOLS],
++[AC_REQUIRE([AC_CANONICAL_HOST])dnl
++AC_REQUIRE([AC_PROG_CC])dnl
++AC_REQUIRE([LT_PATH_NM])dnl
++AC_REQUIRE([LT_PATH_LD])dnl
++m4_require([_LT_DECL_SED])dnl
++m4_require([_LT_DECL_EGREP])dnl
++m4_require([_LT_TAG_COMPILER])dnl
++
++# Check for command to grab the raw symbol name followed by C symbol from nm.
++AC_MSG_CHECKING([command to parse $NM output from $compiler object])
++AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe],
++[
++# These are sane defaults that work on at least a few old systems.
++# [They come from Ultrix. What could be older than Ultrix?!! ;)]
++
++# Character class describing NM global symbol codes.
++symcode='[[BCDEGRST]]'
++
++# Regexp to match symbols that can be accessed directly from C.
++sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)'
++
++# Define system-specific variables.
++case $host_os in
++aix*)
++ symcode='[[BCDT]]'
++ ;;
++cygwin* | mingw* | pw32*)
++ symcode='[[ABCDGISTW]]'
++ ;;
++hpux*)
++ if test "$host_cpu" = ia64; then
++ symcode='[[ABCDEGRST]]'
++ fi
++ ;;
++irix* | nonstopux*)
++ symcode='[[BCDEGRST]]'
++ ;;
++osf*)
++ symcode='[[BCDEGQRST]]'
++ ;;
++solaris*)
++ symcode='[[BDRT]]'
++ ;;
++sco3.2v5*)
++ symcode='[[DT]]'
++ ;;
++sysv4.2uw2*)
++ symcode='[[DT]]'
++ ;;
++sysv5* | sco5v6* | unixware* | OpenUNIX*)
++ symcode='[[ABDT]]'
++ ;;
++sysv4)
++ symcode='[[DFNSTU]]'
++ ;;
++esac
++
++# If we're using GNU nm, then use its standard symbol codes.
++case `$NM -V 2>&1` in
++*GNU* | *'with BFD'*)
++ symcode='[[ABCDGIRSTW]]' ;;
++esac
++
++# Transform an extracted symbol line into a proper C declaration.
++# Some systems (esp. on ia64) link data and code symbols differently,
++# so use this general approach.
++lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
++
++# Transform an extracted symbol line into symbol name and symbol address
++lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p'"
++lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"lib\2\", (void *) \&\2},/p'"
++
++# Handle CRLF in mingw tool chain
++opt_cr=
++case $build_os in
++mingw*)
++ opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp
++ ;;
++esac
++
++# Try without a prefix underscore, then with it.
++for ac_symprfx in "" "_"; do
++
++ # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
++ symxfrm="\\1 $ac_symprfx\\2 \\2"
++
++ # Write the raw and C identifiers.
++ if test "$lt_cv_nm_interface" = "MS dumpbin"; then
++ # Fake it for dumpbin and say T for any non-static function
++ # and D for any global variable.
++ # Also find C++ and __fastcall symbols from MSVC++,
++ # which start with @ or ?.
++ lt_cv_sys_global_symbol_pipe="$AWK ['"\
++" {last_section=section; section=\$ 3};"\
++" /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\
++" \$ 0!~/External *\|/{next};"\
++" / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\
++" {if(hide[section]) next};"\
++" {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\
++" {split(\$ 0, a, /\||\r/); split(a[2], s)};"\
++" s[1]~/^[@?]/{print s[1], s[1]; next};"\
++" s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\
++" ' prfx=^$ac_symprfx]"
++ else
++ lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
++ fi
++
++ # Check to see that the pipe works correctly.
++ pipe_works=no
++
++ rm -f conftest*
++ cat > conftest.$ac_ext <<_LT_EOF
++#ifdef __cplusplus
++extern "C" {
++#endif
++char nm_test_var;
++void nm_test_func(void);
++void nm_test_func(void){}
++#ifdef __cplusplus
++}
++#endif
++int main(){nm_test_var='a';nm_test_func();return(0);}
++_LT_EOF
++
++ if AC_TRY_EVAL(ac_compile); then
++ # Now try to grab the symbols.
++ nlist=conftest.nm
++ if AC_TRY_EVAL(NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) && test -s "$nlist"; then
++ # Try sorting and uniquifying the output.
++ if sort "$nlist" | uniq > "$nlist"T; then
++ mv -f "$nlist"T "$nlist"
++ else
++ rm -f "$nlist"T
++ fi
++
++ # Make sure that we snagged all the symbols we need.
++ if $GREP ' nm_test_var$' "$nlist" >/dev/null; then
++ if $GREP ' nm_test_func$' "$nlist" >/dev/null; then
++ cat <<_LT_EOF > conftest.$ac_ext
++#ifdef __cplusplus
++extern "C" {
++#endif
++
++_LT_EOF
++ # Now generate the symbol file.
++ eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext'
++
++ cat <<_LT_EOF >> conftest.$ac_ext
++
++/* The mapping between symbol names and symbols. */
++const struct {
++ const char *name;
++ void *address;
++}
++lt__PROGRAM__LTX_preloaded_symbols[[]] =
++{
++ { "@PROGRAM@", (void *) 0 },
++_LT_EOF
++ $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
++ cat <<\_LT_EOF >> conftest.$ac_ext
++ {0, (void *) 0}
++};
++
++/* This works around a problem in FreeBSD linker */
++#ifdef FREEBSD_WORKAROUND
++static const void *lt_preloaded_setup() {
++ return lt__PROGRAM__LTX_preloaded_symbols;
++}
++#endif
++
++#ifdef __cplusplus
++}
++#endif
++_LT_EOF
++ # Now try linking the two files.
++ mv conftest.$ac_objext conftstm.$ac_objext
++ lt_save_LIBS="$LIBS"
++ lt_save_CFLAGS="$CFLAGS"
++ LIBS="conftstm.$ac_objext"
++ CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)"
++ if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then
++ pipe_works=yes
++ fi
++ LIBS="$lt_save_LIBS"
++ CFLAGS="$lt_save_CFLAGS"
++ else
++ echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD
++ fi
++ else
++ echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD
++ fi
++ else
++ echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD
++ fi
++ else
++ echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD
++ cat conftest.$ac_ext >&5
++ fi
++ rm -rf conftest* conftst*
+
+- if test "$pre_test_object_deps_done" = no; then
+- case $p in
+- -L* | -R*)
+- # Internal compiler library paths should come after those
+- # provided the user. The postdeps already come after the
+- # user supplied libs so there is no need to process them.
+- if test -z "$_LT_AC_TAGVAR(compiler_lib_search_path, $1)"; then
+- _LT_AC_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}"
+- else
+- _LT_AC_TAGVAR(compiler_lib_search_path, $1)="${_LT_AC_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}"
+- fi
+- ;;
+- # The "-l" case would never come before the object being
+- # linked, so don't bother handling this case.
+- esac
+- else
+- if test -z "$_LT_AC_TAGVAR(postdeps, $1)"; then
+- _LT_AC_TAGVAR(postdeps, $1)="${prev}${p}"
+- else
+- _LT_AC_TAGVAR(postdeps, $1)="${_LT_AC_TAGVAR(postdeps, $1)} ${prev}${p}"
+- fi
+- fi
+- ;;
++ # Do not use the global_symbol_pipe unless it works.
++ if test "$pipe_works" = yes; then
++ break
++ else
++ lt_cv_sys_global_symbol_pipe=
++ fi
++done
++])
++if test -z "$lt_cv_sys_global_symbol_pipe"; then
++ lt_cv_sys_global_symbol_to_cdecl=
++fi
++if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
++ AC_MSG_RESULT(failed)
++else
++ AC_MSG_RESULT(ok)
++fi
+
+- *.$objext)
+- # This assumes that the test object file only shows up
+- # once in the compiler output.
+- if test "$p" = "conftest.$objext"; then
+- pre_test_object_deps_done=yes
+- continue
+- fi
++_LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1],
++ [Take the output of nm and produce a listing of raw symbols and C names])
++_LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1],
++ [Transform the output of nm in a proper C declaration])
++_LT_DECL([global_symbol_to_c_name_address],
++ [lt_cv_sys_global_symbol_to_c_name_address], [1],
++ [Transform the output of nm in a C name address pair])
++_LT_DECL([global_symbol_to_c_name_address_lib_prefix],
++ [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1],
++ [Transform the output of nm in a C name address pair when lib prefix is needed])
++]) # _LT_CMD_GLOBAL_SYMBOLS
+
+- if test "$pre_test_object_deps_done" = no; then
+- if test -z "$_LT_AC_TAGVAR(predep_objects, $1)"; then
+- _LT_AC_TAGVAR(predep_objects, $1)="$p"
+- else
+- _LT_AC_TAGVAR(predep_objects, $1)="$_LT_AC_TAGVAR(predep_objects, $1) $p"
+- fi
+- else
+- if test -z "$_LT_AC_TAGVAR(postdep_objects, $1)"; then
+- _LT_AC_TAGVAR(postdep_objects, $1)="$p"
+- else
+- _LT_AC_TAGVAR(postdep_objects, $1)="$_LT_AC_TAGVAR(postdep_objects, $1) $p"
+- fi
+- fi
+- ;;
+
+- *) ;; # Ignore the rest.
++# _LT_COMPILER_PIC([TAGNAME])
++# ---------------------------
++m4_defun([_LT_COMPILER_PIC],
++[m4_require([_LT_TAG_COMPILER])dnl
++_LT_TAGVAR(lt_prog_compiler_wl, $1)=
++_LT_TAGVAR(lt_prog_compiler_pic, $1)=
++_LT_TAGVAR(lt_prog_compiler_static, $1)=
++
++AC_MSG_CHECKING([for $compiler option to produce PIC])
++m4_if([$1], [CXX], [
++ # C++ specific cases for pic, static, wl, etc.
++ if test "$GXX" = yes; then
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+
++ case $host_os in
++ aix*)
++ # All AIX code is PIC.
++ if test "$host_cpu" = ia64; then
++ # AIX 5 now supports IA64 processor
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ fi
++ ;;
++
++ amigaos*)
++ case $host_cpu in
++ powerpc)
++ # see comment about AmigaOS4 .so support
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
++ ;;
++ m68k)
++ # FIXME: we need at least 68020 code to build shared libraries, but
++ # adding the `-m68020' flag to GCC prevents building anything better,
++ # like `-m68040'.
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
++ ;;
++ esac
++ ;;
++
++ beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
++ # PIC is the default for these OSes.
++ ;;
++ mingw* | cygwin* | os2* | pw32*)
++ # This hack is so that the source file can tell whether it is being
++ # built for inclusion in a dll (and should export symbols for example).
++ # Although the cygwin gcc ignores -fPIC, still need this for old-style
++ # (--disable-auto-import) libraries
++ m4_if([$1], [GCJ], [],
++ [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
++ ;;
++ darwin* | rhapsody*)
++ # PIC is the default on this platform
++ # Common symbols not allowed in MH_DYLIB files
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
++ ;;
++ *djgpp*)
++ # DJGPP does not support shared libraries at all
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)=
++ ;;
++ interix[[3-9]]*)
++ # Interix 3.x gcc -fpic/-fPIC options generate broken code.
++ # Instead, we relocate shared libraries at runtime.
++ ;;
++ sysv4*MP*)
++ if test -d /usr/nec; then
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
++ fi
++ ;;
++ hpux*)
++ # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
++ # not for PA HP-UX.
++ case $host_cpu in
++ hppa*64*|ia64*)
++ ;;
++ *)
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
++ ;;
++ esac
++ ;;
++ *qnx* | *nto*)
++ # QNX uses GNU C++, but need to define -shared option too, otherwise
++ # it will coredump.
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
++ ;;
++ *)
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
++ ;;
++ esac
++ else
++ case $host_os in
++ aix[[4-9]]*)
++ # All AIX code is PIC.
++ if test "$host_cpu" = ia64; then
++ # AIX 5 now supports IA64 processor
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ else
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
++ fi
++ ;;
++ chorus*)
++ case $cc_basename in
++ cxch68*)
++ # Green Hills C++ Compiler
++ # _LT_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a"
++ ;;
++ esac
++ ;;
++ dgux*)
++ case $cc_basename in
++ ec++*)
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ ;;
++ ghcx*)
++ # Green Hills C++ Compiler
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
++ ;;
++ *)
++ ;;
++ esac
++ ;;
++ freebsd* | dragonfly*)
++ # FreeBSD uses GNU C++
++ ;;
++ hpux9* | hpux10* | hpux11*)
++ case $cc_basename in
++ CC*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
++ if test "$host_cpu" != ia64; then
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
++ fi
++ ;;
++ aCC*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
++ case $host_cpu in
++ hppa*64*|ia64*)
++ # +Z the default
++ ;;
++ *)
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
++ ;;
++ esac
++ ;;
++ *)
++ ;;
++ esac
++ ;;
++ interix*)
++ # This is c89, which is MS Visual C++ (no shared libs)
++ # Anyone wants to do a port?
++ ;;
++ irix5* | irix6* | nonstopux*)
++ case $cc_basename in
++ CC*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
++ # CC pic flag -KPIC is the default.
++ ;;
++ *)
++ ;;
++ esac
++ ;;
++ linux* | k*bsd*-gnu)
++ case $cc_basename in
++ KCC*)
++ # KAI C++ Compiler
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
++ ;;
++ icpc* | ecpc* )
++ # Intel C++
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
++ ;;
++ pgCC* | pgcpp*)
++ # Portland Group C++ compiler
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ ;;
++ cxx*)
++ # Compaq C++
++ # Make sure the PIC flag is empty. It appears that all Alpha
++ # Linux and Compaq Tru64 Unix objects are PIC.
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)=
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
++ ;;
++ xlc* | xlC*)
++ # IBM XL 8.0 on PPC
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink'
++ ;;
++ *)
++ case `$CC -V 2>&1 | sed 5q` in
++ *Sun\ C*)
++ # Sun C++ 5.9
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
++ ;;
++ esac
++ ;;
++ esac
++ ;;
++ lynxos*)
++ ;;
++ m88k*)
++ ;;
++ mvs*)
++ case $cc_basename in
++ cxx*)
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall'
++ ;;
++ *)
++ ;;
++ esac
++ ;;
++ netbsd*)
++ ;;
++ *qnx* | *nto*)
++ # QNX uses GNU C++, but need to define -shared option too, otherwise
++ # it will coredump.
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
++ ;;
++ osf3* | osf4* | osf5*)
++ case $cc_basename in
++ KCC*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
++ ;;
++ RCC*)
++ # Rational C++ 2.4.1
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
++ ;;
++ cxx*)
++ # Digital/Compaq C++
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ # Make sure the PIC flag is empty. It appears that all Alpha
++ # Linux and Compaq Tru64 Unix objects are PIC.
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)=
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
++ ;;
++ *)
++ ;;
++ esac
++ ;;
++ psos*)
++ ;;
++ solaris*)
++ case $cc_basename in
++ CC*)
++ # Sun C++ 4.2, 5.x and Centerline C++
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
++ ;;
++ gcx*)
++ # Green Hills C++ Compiler
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
++ ;;
++ *)
++ ;;
++ esac
++ ;;
++ sunos4*)
++ case $cc_basename in
++ CC*)
++ # Sun C++ 4.x
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ ;;
++ lcc*)
++ # Lucid
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
++ ;;
++ *)
++ ;;
++ esac
++ ;;
++ sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
++ case $cc_basename in
++ CC*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ ;;
++ esac
++ ;;
++ tandem*)
++ case $cc_basename in
++ NCC*)
++ # NonStop-UX NCC 3.20
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ ;;
++ *)
++ ;;
++ esac
++ ;;
++ vxworks*)
++ ;;
++ *)
++ _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
++ ;;
+ esac
+- done
+-
+- # Clean up.
+- rm -f a.out a.exe
+-else
+- echo "libtool.m4: error: problem compiling $1 test program"
+-fi
+-
+-$rm -f confest.$objext
+-
+-# PORTME: override above test on systems where it is broken
+-ifelse([$1],[CXX],
+-[case $host_os in
+-interix3*)
+- # Interix 3.5 installs completely hosed .la files for C++, so rather than
+- # hack all around it, let's just trust "g++" to DTRT.
+- _LT_AC_TAGVAR(predep_objects,$1)=
+- _LT_AC_TAGVAR(postdep_objects,$1)=
+- _LT_AC_TAGVAR(postdeps,$1)=
+- ;;
+-
+-linux*)
+- case `$CC -V 2>&1 | sed 5q` in
+- *Sun\ C*)
+- # Sun C++ 5.9
+- _LT_AC_TAGVAR(postdeps,$1)='-lCstd -lCrun'
+- ;;
+- esac
+- ;;
+-
+-solaris*)
+- case $cc_basename in
+- CC*)
+- # Adding this requires a known-good setup of shared libraries for
+- # Sun compiler versions before 5.6, else PIC objects from an old
+- # archive will be linked into the output, leading to subtle bugs.
+- _LT_AC_TAGVAR(postdeps,$1)='-lCstd -lCrun'
+- ;;
+- esac
+- ;;
+-esac
+-])
+-
+-case " $_LT_AC_TAGVAR(postdeps, $1) " in
+-*" -lc "*) _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no ;;
+-esac
+-])# AC_LIBTOOL_POSTDEP_PREDEP
+-
+-# AC_LIBTOOL_LANG_F77_CONFIG
+-# --------------------------
+-# Ensure that the configuration vars for the C compiler are
+-# suitably defined. Those variables are subsequently used by
+-# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
+-AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG], [_LT_AC_LANG_F77_CONFIG(F77)])
+-AC_DEFUN([_LT_AC_LANG_F77_CONFIG],
+-[AC_REQUIRE([AC_PROG_F77])
+-AC_LANG_PUSH(Fortran 77)
+-
+-_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+-_LT_AC_TAGVAR(allow_undefined_flag, $1)=
+-_LT_AC_TAGVAR(always_export_symbols, $1)=no
+-_LT_AC_TAGVAR(archive_expsym_cmds, $1)=
+-_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=
+-_LT_AC_TAGVAR(hardcode_direct, $1)=no
+-_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
+-_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
+-_LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
+-_LT_AC_TAGVAR(hardcode_minus_L, $1)=no
+-_LT_AC_TAGVAR(hardcode_automatic, $1)=no
+-_LT_AC_TAGVAR(module_cmds, $1)=
+-_LT_AC_TAGVAR(module_expsym_cmds, $1)=
+-_LT_AC_TAGVAR(link_all_deplibs, $1)=unknown
+-_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+-_LT_AC_TAGVAR(no_undefined_flag, $1)=
+-_LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+-_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+-
+-# Source file extension for f77 test sources.
+-ac_ext=f
+-
+-# Object file extension for compiled f77 test sources.
+-objext=o
+-_LT_AC_TAGVAR(objext, $1)=$objext
+-
+-# Code to be used in simple compile tests
+-lt_simple_compile_test_code=" subroutine t\n return\n end\n"
+-
+-# Code to be used in simple link tests
+-lt_simple_link_test_code=" program t\n end\n"
+-
+-# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+-_LT_AC_SYS_COMPILER
+-
+-# save warnings/boilerplate of simple test code
+-_LT_COMPILER_BOILERPLATE
+-_LT_LINKER_BOILERPLATE
+-
+-# Allow CC to be a program name with arguments.
+-lt_save_CC="$CC"
+-CC=${F77-"f77"}
+-compiler=$CC
+-_LT_AC_TAGVAR(compiler, $1)=$CC
+-_LT_CC_BASENAME([$compiler])
+-
+-AC_MSG_CHECKING([if libtool supports shared libraries])
+-AC_MSG_RESULT([$can_build_shared])
+-
+-AC_MSG_CHECKING([whether to build shared libraries])
+-test "$can_build_shared" = "no" && enable_shared=no
+-
+-# On AIX, shared libraries and static libraries use the same namespace, and
+-# are all built from PIC.
+-case $host_os in
+-aix3*)
+- test "$enable_shared" = yes && enable_static=no
+- if test -n "$RANLIB"; then
+- archive_cmds="$archive_cmds~\$RANLIB \$lib"
+- postinstall_cmds='$RANLIB $lib'
+ fi
+- ;;
+-aix4* | aix5*)
+- if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+- test "$enable_shared" = yes && enable_static=no
+- fi
+- ;;
+-esac
+-AC_MSG_RESULT([$enable_shared])
+-
+-AC_MSG_CHECKING([whether to build static libraries])
+-# Make sure either enable_shared or enable_static is yes.
+-test "$enable_shared" = yes || enable_static=yes
+-AC_MSG_RESULT([$enable_static])
+-
+-_LT_AC_TAGVAR(GCC, $1)="$G77"
+-_LT_AC_TAGVAR(LD, $1)="$LD"
+-
+-AC_LIBTOOL_PROG_COMPILER_PIC($1)
+-AC_LIBTOOL_PROG_CC_C_O($1)
+-AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
+-AC_LIBTOOL_PROG_LD_SHLIBS($1)
+-AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
+-AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
+-
+-AC_LIBTOOL_CONFIG($1)
+-
+-AC_LANG_POP
+-CC="$lt_save_CC"
+-])# AC_LIBTOOL_LANG_F77_CONFIG
+-
+-
+-# AC_LIBTOOL_LANG_GCJ_CONFIG
+-# --------------------------
+-# Ensure that the configuration vars for the C compiler are
+-# suitably defined. Those variables are subsequently used by
+-# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
+-AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG], [_LT_AC_LANG_GCJ_CONFIG(GCJ)])
+-AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG],
+-[AC_LANG_SAVE
+-
+-# Source file extension for Java test sources.
+-ac_ext=java
++],
++[
++ if test "$GCC" = yes; then
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+
+-# Object file extension for compiled Java test sources.
+-objext=o
+-_LT_AC_TAGVAR(objext, $1)=$objext
++ case $host_os in
++ aix*)
++ # All AIX code is PIC.
++ if test "$host_cpu" = ia64; then
++ # AIX 5 now supports IA64 processor
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ fi
++ ;;
+
+-# Code to be used in simple compile tests
+-lt_simple_compile_test_code="class foo {}\n"
++ amigaos*)
++ case $host_cpu in
++ powerpc)
++ # see comment about AmigaOS4 .so support
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
++ ;;
++ m68k)
++ # FIXME: we need at least 68020 code to build shared libraries, but
++ # adding the `-m68020' flag to GCC prevents building anything better,
++ # like `-m68040'.
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
++ ;;
++ esac
++ ;;
+
+-# Code to be used in simple link tests
+-lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }\n'
++ beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
++ # PIC is the default for these OSes.
++ ;;
+
+-# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+-_LT_AC_SYS_COMPILER
++ mingw* | cygwin* | pw32* | os2*)
++ # This hack is so that the source file can tell whether it is being
++ # built for inclusion in a dll (and should export symbols for example).
++ # Although the cygwin gcc ignores -fPIC, still need this for old-style
++ # (--disable-auto-import) libraries
++ m4_if([$1], [GCJ], [],
++ [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
++ ;;
+
+-# save warnings/boilerplate of simple test code
+-_LT_COMPILER_BOILERPLATE
+-_LT_LINKER_BOILERPLATE
++ darwin* | rhapsody*)
++ # PIC is the default on this platform
++ # Common symbols not allowed in MH_DYLIB files
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
++ ;;
+
+-# Allow CC to be a program name with arguments.
+-lt_save_CC="$CC"
+-CC=${GCJ-"gcj"}
+-compiler=$CC
+-_LT_AC_TAGVAR(compiler, $1)=$CC
+-_LT_CC_BASENAME([$compiler])
++ hpux*)
++ # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
++ # not for PA HP-UX.
++ case $host_cpu in
++ hppa*64*|ia64*)
++ # +Z the default
++ ;;
++ *)
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
++ ;;
++ esac
++ ;;
+
+-# GCJ did not exist at the time GCC didn't implicitly link libc in.
+-_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
++ interix[[3-9]]*)
++ # Interix 3.x gcc -fpic/-fPIC options generate broken code.
++ # Instead, we relocate shared libraries at runtime.
++ ;;
+
+-_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
++ msdosdjgpp*)
++ # Just because we use GCC doesn't mean we suddenly get shared libraries
++ # on systems that don't support them.
++ _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
++ enable_shared=no
++ ;;
+
+-## CAVEAT EMPTOR:
+-## There is no encapsulation within the following macros, do not change
+-## the running order or otherwise move them around unless you know exactly
+-## what you are doing...
+-AC_LIBTOOL_PROG_COMPILER_NO_RTTI($1)
+-AC_LIBTOOL_PROG_COMPILER_PIC($1)
+-AC_LIBTOOL_PROG_CC_C_O($1)
+-AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
+-AC_LIBTOOL_PROG_LD_SHLIBS($1)
+-AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
+-AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
++ *nto* | *qnx*)
++ # QNX uses GNU C++, but need to define -shared option too, otherwise
++ # it will coredump.
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
++ ;;
+
+-AC_LIBTOOL_CONFIG($1)
++ sysv4*MP*)
++ if test -d /usr/nec; then
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
++ fi
++ ;;
+
+-AC_LANG_RESTORE
+-CC="$lt_save_CC"
+-])# AC_LIBTOOL_LANG_GCJ_CONFIG
++ *)
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
++ ;;
++ esac
++ else
++ # PORTME Check for flag to pass linker flags through the system compiler.
++ case $host_os in
++ aix*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ if test "$host_cpu" = ia64; then
++ # AIX 5 now supports IA64 processor
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ else
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
++ fi
++ ;;
+
++ mingw* | cygwin* | pw32* | os2*)
++ # This hack is so that the source file can tell whether it is being
++ # built for inclusion in a dll (and should export symbols for example).
++ m4_if([$1], [GCJ], [],
++ [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
++ ;;
+
+-# AC_LIBTOOL_LANG_RC_CONFIG
+-# -------------------------
+-# Ensure that the configuration vars for the Windows resource compiler are
+-# suitably defined. Those variables are subsequently used by
+-# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
+-AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG], [_LT_AC_LANG_RC_CONFIG(RC)])
+-AC_DEFUN([_LT_AC_LANG_RC_CONFIG],
+-[AC_LANG_SAVE
++ hpux9* | hpux10* | hpux11*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
++ # not for PA HP-UX.
++ case $host_cpu in
++ hppa*64*|ia64*)
++ # +Z the default
++ ;;
++ *)
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
++ ;;
++ esac
++ # Is there a better lt_prog_compiler_static that works with the bundled CC?
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
++ ;;
+
+-# Source file extension for RC test sources.
+-ac_ext=rc
++ irix5* | irix6* | nonstopux*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ # PIC (with -KPIC) is the default.
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
++ ;;
+
+-# Object file extension for compiled RC test sources.
+-objext=o
+-_LT_AC_TAGVAR(objext, $1)=$objext
++ linux* | k*bsd*-gnu)
++ case $cc_basename in
++ icc* | ecc* | ifort*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
++ ;;
++ pgcc* | pgf77* | pgf90* | pgf95*)
++ # Portland Group compilers (*not* the Pentium gcc compiler,
++ # which looks to be a dead project)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ ;;
++ ccc*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ # All Alpha code is PIC.
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
++ ;;
++ xl*)
++ # IBM XL C 8.0/Fortran 10.1 on PPC
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink'
++ ;;
++ *)
++ case `$CC -V 2>&1 | sed 5q` in
++ *Sun\ C*)
++ # Sun C 5.9
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ ;;
++ *Sun\ F*)
++ # Sun Fortran 8.3 passes all unrecognized flags to the linker
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)=''
++ ;;
++ esac
++ ;;
++ esac
++ ;;
+
+-# Code to be used in simple compile tests
+-lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }\n'
++ newsos6)
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ ;;
+
+-# Code to be used in simple link tests
+-lt_simple_link_test_code="$lt_simple_compile_test_code"
++ *nto* | *qnx*)
++ # QNX uses GNU C++, but need to define -shared option too, otherwise
++ # it will coredump.
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
++ ;;
+
+-# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+-_LT_AC_SYS_COMPILER
++ osf3* | osf4* | osf5*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ # All OSF/1 code is PIC.
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
++ ;;
+
+-# save warnings/boilerplate of simple test code
+-_LT_COMPILER_BOILERPLATE
+-_LT_LINKER_BOILERPLATE
++ rdos*)
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
++ ;;
+
+-# Allow CC to be a program name with arguments.
+-lt_save_CC="$CC"
+-CC=${RC-"windres"}
+-compiler=$CC
+-_LT_AC_TAGVAR(compiler, $1)=$CC
+-_LT_CC_BASENAME([$compiler])
+-_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
++ solaris*)
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ case $cc_basename in
++ f77* | f90* | f95*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';;
++ *)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';;
++ esac
++ ;;
+
+-AC_LIBTOOL_CONFIG($1)
++ sunos4*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ ;;
+
+-AC_LANG_RESTORE
+-CC="$lt_save_CC"
+-])# AC_LIBTOOL_LANG_RC_CONFIG
++ sysv4 | sysv4.2uw2* | sysv4.3*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ ;;
++
++ sysv4*MP*)
++ if test -d /usr/nec ;then
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ fi
++ ;;
+
++ sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ ;;
+
+-# AC_LIBTOOL_CONFIG([TAGNAME])
+-# ----------------------------
+-# If TAGNAME is not passed, then create an initial libtool script
+-# with a default configuration from the untagged config vars. Otherwise
+-# add code to config.status for appending the configuration named by
+-# TAGNAME from the matching tagged config vars.
+-AC_DEFUN([AC_LIBTOOL_CONFIG],
+-[# The else clause should only fire when bootstrapping the
+-# libtool distribution, otherwise you forgot to ship ltmain.sh
+-# with your package, and you will get complaints that there are
+-# no rules to generate ltmain.sh.
+-if test -f "$ltmain"; then
+- # See if we are running on zsh, and set the options which allow our commands through
+- # without removal of \ escapes.
+- if test -n "${ZSH_VERSION+set}" ; then
+- setopt NO_GLOB_SUBST
+- fi
+- # Now quote all the things that may contain metacharacters while being
+- # careful not to overquote the AC_SUBSTed values. We take copies of the
+- # variables and quote the copies for generation of the libtool script.
+- for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \
+- SED SHELL STRIP \
+- libname_spec library_names_spec soname_spec extract_expsyms_cmds \
+- old_striplib striplib file_magic_cmd finish_cmds finish_eval \
+- deplibs_check_method reload_flag reload_cmds need_locks \
+- lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \
+- lt_cv_sys_global_symbol_to_c_name_address \
+- sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
+- old_postinstall_cmds old_postuninstall_cmds \
+- _LT_AC_TAGVAR(compiler, $1) \
+- _LT_AC_TAGVAR(CC, $1) \
+- _LT_AC_TAGVAR(LD, $1) \
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1) \
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1) \
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1) \
+- _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) \
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1) \
+- _LT_AC_TAGVAR(thread_safe_flag_spec, $1) \
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1) \
+- _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1) \
+- _LT_AC_TAGVAR(old_archive_cmds, $1) \
+- _LT_AC_TAGVAR(old_archive_from_new_cmds, $1) \
+- _LT_AC_TAGVAR(predep_objects, $1) \
+- _LT_AC_TAGVAR(postdep_objects, $1) \
+- _LT_AC_TAGVAR(predeps, $1) \
+- _LT_AC_TAGVAR(postdeps, $1) \
+- _LT_AC_TAGVAR(compiler_lib_search_path, $1) \
+- _LT_AC_TAGVAR(archive_cmds, $1) \
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1) \
+- _LT_AC_TAGVAR(postinstall_cmds, $1) \
+- _LT_AC_TAGVAR(postuninstall_cmds, $1) \
+- _LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1) \
+- _LT_AC_TAGVAR(allow_undefined_flag, $1) \
+- _LT_AC_TAGVAR(no_undefined_flag, $1) \
+- _LT_AC_TAGVAR(export_symbols_cmds, $1) \
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) \
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1) \
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1) \
+- _LT_AC_TAGVAR(hardcode_automatic, $1) \
+- _LT_AC_TAGVAR(module_cmds, $1) \
+- _LT_AC_TAGVAR(module_expsym_cmds, $1) \
+- _LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1) \
+- _LT_AC_TAGVAR(exclude_expsyms, $1) \
+- _LT_AC_TAGVAR(include_expsyms, $1); do
+-
+- case $var in
+- _LT_AC_TAGVAR(old_archive_cmds, $1) | \
+- _LT_AC_TAGVAR(old_archive_from_new_cmds, $1) | \
+- _LT_AC_TAGVAR(archive_cmds, $1) | \
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1) | \
+- _LT_AC_TAGVAR(module_cmds, $1) | \
+- _LT_AC_TAGVAR(module_expsym_cmds, $1) | \
+- _LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1) | \
+- _LT_AC_TAGVAR(export_symbols_cmds, $1) | \
+- extract_expsyms_cmds | reload_cmds | finish_cmds | \
+- postinstall_cmds | postuninstall_cmds | \
+- old_postinstall_cmds | old_postuninstall_cmds | \
+- sys_lib_search_path_spec | sys_lib_dlsearch_path_spec)
+- # Double-quote double-evaled strings.
+- eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\""
++ unicos*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
++ ;;
++
++ uts4*)
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
++
+ *)
+- eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\""
++ _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+ ;;
+ esac
+- done
+-
+- case $lt_echo in
+- *'\[$]0 --fallback-echo"')
+- lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\[$]0 --fallback-echo"[$]/[$]0 --fallback-echo"/'`
++ fi
++])
++case $host_os in
++ # For platforms which do not support PIC, -DPIC is meaningless:
++ *djgpp*)
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)=
+ ;;
+- esac
+-
+-ifelse([$1], [],
+- [cfgfile="${ofile}T"
+- trap "$rm \"$cfgfile\"; exit 1" 1 2 15
+- $rm -f "$cfgfile"
+- AC_MSG_NOTICE([creating $ofile])],
+- [cfgfile="$ofile"])
+-
+- cat <<__EOF__ >> "$cfgfile"
+-ifelse([$1], [],
+-[#! $SHELL
++ *)
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])"
++ ;;
++esac
++AC_MSG_RESULT([$_LT_TAGVAR(lt_prog_compiler_pic, $1)])
++_LT_TAGDECL([wl], [lt_prog_compiler_wl], [1],
++ [How to pass a linker flag through the compiler])
+
+-# `$echo "$cfgfile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
+-# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP)
+-# NOTE: Changes made to this file will be lost: look at ltmain.sh.
+ #
+-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001
+-# Free Software Foundation, Inc.
+-#
+-# This file is part of GNU Libtool:
+-# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
+-#
+-# 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 of the License, or
+-# (at your option) any later version.
++# Check to make sure the PIC flag actually works.
+ #
+-# 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.
++if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then
++ _LT_COMPILER_OPTION([if $compiler PIC flag $_LT_TAGVAR(lt_prog_compiler_pic, $1) works],
++ [_LT_TAGVAR(lt_cv_prog_compiler_pic_works, $1)],
++ [$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [],
++ [case $_LT_TAGVAR(lt_prog_compiler_pic, $1) in
++ "" | " "*) ;;
++ *) _LT_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_TAGVAR(lt_prog_compiler_pic, $1)" ;;
++ esac],
++ [_LT_TAGVAR(lt_prog_compiler_pic, $1)=
++ _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no])
++fi
++_LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1],
++ [Additional compiler flags for building library objects])
++
+ #
+-# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
++# Check to make sure the static flag actually works.
+ #
+-# As a special exception to the GNU General Public License, if you
+-# distribute this file as part of a program that contains a
+-# configuration script generated by Autoconf, you may include it under
+-# the same distribution terms that you use for the rest of that program.
+-
+-# A sed program that does not truncate output.
+-SED=$lt_SED
+-
+-# Sed that helps us avoid accidentally triggering echo(1) options like -n.
+-Xsed="$SED -e 1s/^X//"
+-
+-# The HP-UX ksh and POSIX shell print the target directory to stdout
+-# if CDPATH is set.
+-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+-
+-# The names of the tagged configurations supported by this script.
+-available_tags=
+-
+-# ### BEGIN LIBTOOL CONFIG],
+-[# ### BEGIN LIBTOOL TAG CONFIG: $tagname])
+-
+-# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+-
+-# Shell to use when invoking shell scripts.
+-SHELL=$lt_SHELL
+-
+-# Whether or not to build shared libraries.
+-build_libtool_libs=$enable_shared
+-
+-# Whether or not to build static libraries.
+-build_old_libs=$enable_static
+-
+-# Whether or not to add -lc for building shared libraries.
+-build_libtool_need_lc=$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)
+-
+-# Whether or not to disallow shared libs when runtime libs are static
+-allow_libtool_libs_with_static_runtimes=$_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)
+-
+-# Whether or not to optimize for fast installation.
+-fast_install=$enable_fast_install
+-
+-# The host system.
+-host_alias=$host_alias
+-host=$host
+-host_os=$host_os
++wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_TAGVAR(lt_prog_compiler_static, $1)\"
++_LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works],
++ _LT_TAGVAR(lt_cv_prog_compiler_static_works, $1),
++ $lt_tmp_static_flag,
++ [],
++ [_LT_TAGVAR(lt_prog_compiler_static, $1)=])
++_LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1],
++ [Compiler flag to prevent dynamic linking])
++])# _LT_COMPILER_PIC
+
+-# The build system.
+-build_alias=$build_alias
+-build=$build
+-build_os=$build_os
+
+-# An echo program that does not interpret backslashes.
+-echo=$lt_echo
++# _LT_LINKER_SHLIBS([TAGNAME])
++# ----------------------------
++# See if the linker supports building shared libraries.
++m4_defun([_LT_LINKER_SHLIBS],
++[AC_REQUIRE([LT_PATH_LD])dnl
++AC_REQUIRE([LT_PATH_NM])dnl
++m4_require([_LT_FILEUTILS_DEFAULTS])dnl
++m4_require([_LT_DECL_EGREP])dnl
++m4_require([_LT_DECL_SED])dnl
++m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl
++m4_require([_LT_TAG_COMPILER])dnl
++AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
++m4_if([$1], [CXX], [
++ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
++ case $host_os in
++ aix[[4-9]]*)
++ # If we're using GNU nm, then we don't want the "-C" option.
++ # -C means demangle to AIX nm, but means don't demangle with GNU nm
++ if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
++ _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
++ else
++ _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
++ fi
++ ;;
++ pw32*)
++ _LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds"
++ ;;
++ cygwin* | mingw*)
++ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;/^.*[[ ]]__nm__/s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols'
++ ;;
++ *)
++ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
++ ;;
++ esac
++ _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']
++], [
++ runpath_var=
++ _LT_TAGVAR(allow_undefined_flag, $1)=
++ _LT_TAGVAR(always_export_symbols, $1)=no
++ _LT_TAGVAR(archive_cmds, $1)=
++ _LT_TAGVAR(archive_expsym_cmds, $1)=
++ _LT_TAGVAR(compiler_needs_object, $1)=no
++ _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)=
++ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
++ _LT_TAGVAR(hardcode_automatic, $1)=no
++ _LT_TAGVAR(hardcode_direct, $1)=no
++ _LT_TAGVAR(hardcode_direct_absolute, $1)=no
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
++ _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=
++ _LT_TAGVAR(hardcode_minus_L, $1)=no
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
++ _LT_TAGVAR(inherit_rpath, $1)=no
++ _LT_TAGVAR(link_all_deplibs, $1)=unknown
++ _LT_TAGVAR(module_cmds, $1)=
++ _LT_TAGVAR(module_expsym_cmds, $1)=
++ _LT_TAGVAR(old_archive_from_new_cmds, $1)=
++ _LT_TAGVAR(old_archive_from_expsyms_cmds, $1)=
++ _LT_TAGVAR(thread_safe_flag_spec, $1)=
++ _LT_TAGVAR(whole_archive_flag_spec, $1)=
++ # include_expsyms should be a list of space-separated symbols to be *always*
++ # included in the symbol list
++ _LT_TAGVAR(include_expsyms, $1)=
++ # exclude_expsyms can be an extended regexp of symbols to exclude
++ # it will be wrapped by ` (' and `)$', so one must not match beginning or
++ # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
++ # as well as any symbol that contains `d'.
++ _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']
++ # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
++ # platforms (ab)use it in PIC code, but their linkers get confused if
++ # the symbol is explicitly referenced. Since portable code cannot
++ # rely on this symbol name, it's probably fine to never include it in
++ # preloaded symbol tables.
++ # Exclude shared library initialization/finalization symbols.
++dnl Note also adjust exclude_expsyms for C++ above.
++ extract_expsyms_cmds=
+
+-# The archiver.
+-AR=$lt_AR
+-AR_FLAGS=$lt_AR_FLAGS
++ case $host_os in
++ cygwin* | mingw* | pw32*)
++ # FIXME: the MSVC++ port hasn't been tested in a loooong time
++ # When not using gcc, we currently assume that we are using
++ # Microsoft Visual C++.
++ if test "$GCC" != yes; then
++ with_gnu_ld=no
++ fi
++ ;;
++ interix*)
++ # we just hope/assume this is gcc and not c89 (= MSVC++)
++ with_gnu_ld=yes
++ ;;
++ openbsd*)
++ with_gnu_ld=no
++ ;;
++ esac
+
+-# A C compiler.
+-LTCC=$lt_LTCC
++ _LT_TAGVAR(ld_shlibs, $1)=yes
++ if test "$with_gnu_ld" = yes; then
++ # If archive_cmds runs LD, not CC, wlarc should be empty
++ wlarc='${wl}'
+
+-# LTCC compiler flags.
+-LTCFLAGS=$lt_LTCFLAGS
++ # Set some defaults for GNU ld with shared library support. These
++ # are reset later if shared libraries are not supported. Putting them
++ # here allows them to be overridden if necessary.
++ runpath_var=LD_RUN_PATH
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
++ # ancient GNU ld didn't support --whole-archive et. al.
++ if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then
++ _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
++ else
++ _LT_TAGVAR(whole_archive_flag_spec, $1)=
++ fi
++ supports_anon_versioning=no
++ case `$LD -v 2>&1` in
++ *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11
++ *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
++ *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
++ *\ 2.11.*) ;; # other 2.11 versions
++ *) supports_anon_versioning=yes ;;
++ esac
+
+-# A language-specific compiler.
+-CC=$lt_[]_LT_AC_TAGVAR(compiler, $1)
++ # See if GNU ld supports shared libraries.
++ case $host_os in
++ aix[[3-9]]*)
++ # On AIX/PPC, the GNU linker is very broken
++ if test "$host_cpu" != ia64; then
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ cat <<_LT_EOF 1>&2
+
+-# Is the compiler the GNU C compiler?
+-with_gcc=$_LT_AC_TAGVAR(GCC, $1)
++*** Warning: the GNU linker, at least up to release 2.9.1, is reported
++*** to be unable to reliably create shared libraries on AIX.
++*** Therefore, libtool is disabling shared libraries support. If you
++*** really care for shared libraries, you may want to modify your PATH
++*** so that a non-GNU linker is found, and then restart.
+
+-# An ERE matcher.
+-EGREP=$lt_EGREP
++_LT_EOF
++ fi
++ ;;
+
+-# The linker used to build libraries.
+-LD=$lt_[]_LT_AC_TAGVAR(LD, $1)
++ amigaos*)
++ case $host_cpu in
++ powerpc)
++ # see comment about AmigaOS4 .so support
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)=''
++ ;;
++ m68k)
++ _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
++ _LT_TAGVAR(hardcode_minus_L, $1)=yes
++ ;;
++ esac
++ ;;
+
+-# Whether we need hard or soft links.
+-LN_S=$lt_LN_S
++ beos*)
++ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
++ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
++ # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
++ # support --undefined. This deserves some investigation. FIXME
++ _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
++ else
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ fi
++ ;;
+
+-# A BSD-compatible nm program.
+-NM=$lt_NM
++ cygwin* | mingw* | pw32*)
++ # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
++ # as there is no search path for DLLs.
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
++ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
++ _LT_TAGVAR(always_export_symbols, $1)=no
++ _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
++ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols'
+
+-# A symbol stripping program
+-STRIP=$lt_STRIP
++ if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
++ # If the export-symbols file already is a .def file (1st line
++ # is EXPORTS), use it as is; otherwise, prepend...
++ _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
++ cp $export_symbols $output_objdir/$soname.def;
++ else
++ echo EXPORTS > $output_objdir/$soname.def;
++ cat $export_symbols >> $output_objdir/$soname.def;
++ fi~
++ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
++ else
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ fi
++ ;;
+
+-# Used to examine libraries when file_magic_cmd begins "file"
+-MAGIC_CMD=$MAGIC_CMD
++ interix[[3-9]]*)
++ _LT_TAGVAR(hardcode_direct, $1)=no
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
++ # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
++ # Instead, shared libraries are loaded at an image base (0x10000000 by
++ # default) and relocated if they conflict, which is a slow very memory
++ # consuming and fragmenting process. To avoid this, we pick a random,
++ # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
++ # time. Moving up from 0x10000000 also allows more sbrk(2) space.
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
++ ;;
+
+-# Used on cygwin: DLL creation program.
+-DLLTOOL="$DLLTOOL"
++ gnu* | linux* | tpf* | k*bsd*-gnu)
++ tmp_diet=no
++ if test "$host_os" = linux-dietlibc; then
++ case $cc_basename in
++ diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn)
++ esac
++ fi
++ if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \
++ && test "$tmp_diet" = no
++ then
++ tmp_addflag=
++ tmp_sharedflag='-shared'
++ case $cc_basename,$host_cpu in
++ pgcc*) # Portland Group C compiler
++ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
++ tmp_addflag=' $pic_flag'
++ ;;
++ pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers
++ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
++ tmp_addflag=' $pic_flag -Mnomain' ;;
++ ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64
++ tmp_addflag=' -i_dynamic' ;;
++ efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64
++ tmp_addflag=' -i_dynamic -nofor_main' ;;
++ ifc* | ifort*) # Intel Fortran compiler
++ tmp_addflag=' -nofor_main' ;;
++ xl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below)
++ tmp_sharedflag='-qmkshrobj'
++ tmp_addflag= ;;
++ esac
++ case `$CC -V 2>&1 | sed 5q` in
++ *Sun\ C*) # Sun C 5.9
++ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
++ _LT_TAGVAR(compiler_needs_object, $1)=yes
++ tmp_sharedflag='-G' ;;
++ *Sun\ F*) # Sun Fortran 8.3
++ tmp_sharedflag='-G' ;;
++ esac
++ _LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+
+-# Used on cygwin: object dumper.
+-OBJDUMP="$OBJDUMP"
++ if test "x$supports_anon_versioning" = xyes; then
++ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
++ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
++ echo "local: *; };" >> $output_objdir/$libname.ver~
++ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
++ fi
+
+-# Used on cygwin: assembler.
+-AS="$AS"
++ case $cc_basename in
++ xlf*)
++ # IBM XL Fortran 10.1 on PPC cannot create shared libs itself
++ _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
++ _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir'
++ _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $compiler_flags -soname $soname -o $lib'
++ if test "x$supports_anon_versioning" = xyes; then
++ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
++ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
++ echo "local: *; };" >> $output_objdir/$libname.ver~
++ $LD -shared $libobjs $deplibs $compiler_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
++ fi
++ ;;
++ esac
++ else
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ fi
++ ;;
+
+-# The name of the directory that contains temporary libtool files.
+-objdir=$objdir
++ netbsd*)
++ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
++ _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
++ wlarc=
++ else
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
++ fi
++ ;;
+
+-# How to create reloadable object files.
+-reload_flag=$lt_reload_flag
+-reload_cmds=$lt_reload_cmds
++ solaris*)
++ if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ cat <<_LT_EOF 1>&2
+
+-# How to pass a linker flag through the compiler.
+-wl=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)
++*** Warning: The releases 2.8.* of the GNU linker cannot reliably
++*** create shared libraries on Solaris systems. Therefore, libtool
++*** is disabling shared libraries support. We urge you to upgrade GNU
++*** binutils to release 2.9.1 or newer. Another option is to modify
++*** your PATH or compiler configuration so that the native linker is
++*** used, and then restart.
+
+-# Object file suffix (normally "o").
+-objext="$ac_objext"
++_LT_EOF
++ elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
++ else
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ fi
++ ;;
+
+-# Old archive suffix (normally "a").
+-libext="$libext"
++ sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
++ case `$LD -v 2>&1` in
++ *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*)
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ cat <<_LT_EOF 1>&2
+
+-# Shared library suffix (normally ".so").
+-shrext_cmds='$shrext_cmds'
++*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
++*** reliably create shared libraries on SCO systems. Therefore, libtool
++*** is disabling shared libraries support. We urge you to upgrade GNU
++*** binutils to release 2.16.91.0.3 or newer. Another option is to modify
++*** your PATH or compiler configuration so that the native linker is
++*** used, and then restart.
+
+-# Executable file suffix (normally "").
+-exeext="$exeext"
++_LT_EOF
++ ;;
++ *)
++ # For security reasons, it is highly recommended that you always
++ # use absolute paths for naming shared libraries, and exclude the
++ # DT_RUNPATH tag from executables and libraries. But doing so
++ # requires that you compile everything twice, which is a pain.
++ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
++ else
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ fi
++ ;;
++ esac
++ ;;
+
+-# Additional compiler flags for building library objects.
+-pic_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)
+-pic_mode=$pic_mode
++ sunos4*)
++ _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
++ wlarc=
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ ;;
+
+-# What is the maximum length of a command?
+-max_cmd_len=$lt_cv_sys_max_cmd_len
++ *)
++ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
++ else
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ fi
++ ;;
++ esac
+
+-# Does compiler simultaneously support -c and -o options?
+-compiler_c_o=$lt_[]_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)
++ if test "$_LT_TAGVAR(ld_shlibs, $1)" = no; then
++ runpath_var=
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)=
++ _LT_TAGVAR(whole_archive_flag_spec, $1)=
++ fi
++ else
++ # PORTME fill in a description of your system's linker (not GNU ld)
++ case $host_os in
++ aix3*)
++ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
++ _LT_TAGVAR(always_export_symbols, $1)=yes
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
++ # Note: this linker hardcodes the directories in LIBPATH if there
++ # are no directories specified by -L.
++ _LT_TAGVAR(hardcode_minus_L, $1)=yes
++ if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
++ # Neither direct hardcoding nor static linking is supported with a
++ # broken collect2.
++ _LT_TAGVAR(hardcode_direct, $1)=unsupported
++ fi
++ ;;
+
+-# Must we lock files when doing compilation?
+-need_locks=$lt_need_locks
++ aix[[4-9]]*)
++ if test "$host_cpu" = ia64; then
++ # On IA64, the linker does run time linking by default, so we don't
++ # have to do anything special.
++ aix_use_runtimelinking=no
++ exp_sym_flag='-Bexport'
++ no_entry_flag=""
++ else
++ # If we're using GNU nm, then we don't want the "-C" option.
++ # -C means demangle to AIX nm, but means don't demangle with GNU nm
++ if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
++ _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
++ else
++ _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
++ fi
++ aix_use_runtimelinking=no
+
+-# Do we need the lib prefix for modules?
+-need_lib_prefix=$need_lib_prefix
++ # Test if we are trying to use run time linking or normal
++ # AIX style linking. If -brtl is somewhere in LDFLAGS, we
++ # need to do runtime linking.
++ case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
++ for ld_flag in $LDFLAGS; do
++ if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
++ aix_use_runtimelinking=yes
++ break
++ fi
++ done
++ ;;
++ esac
+
+-# Do we need a version for libraries?
+-need_version=$need_version
++ exp_sym_flag='-bexport'
++ no_entry_flag='-bnoentry'
++ fi
+
+-# Whether dlopen is supported.
+-dlopen_support=$enable_dlopen
++ # When large executables or shared objects are built, AIX ld can
++ # have problems creating the table of contents. If linking a library
++ # or program results in "error TOC overflow" add -mminimal-toc to
++ # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
++ # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+-# Whether dlopen of programs is supported.
+-dlopen_self=$enable_dlopen_self
++ _LT_TAGVAR(archive_cmds, $1)=''
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
++ _LT_TAGVAR(link_all_deplibs, $1)=yes
++ _LT_TAGVAR(file_list_spec, $1)='${wl}-f,'
+
+-# Whether dlopen of statically linked programs is supported.
+-dlopen_self_static=$enable_dlopen_self_static
++ if test "$GCC" = yes; then
++ case $host_os in aix4.[[012]]|aix4.[[012]].*)
++ # We only want to do this on AIX 4.2 and lower, the check
++ # below for broken collect2 doesn't work under 4.3+
++ collect2name=`${CC} -print-prog-name=collect2`
++ if test -f "$collect2name" &&
++ strings "$collect2name" | $GREP resolve_lib_name >/dev/null
++ then
++ # We have reworked collect2
++ :
++ else
++ # We have old collect2
++ _LT_TAGVAR(hardcode_direct, $1)=unsupported
++ # It fails to find uninstalled libraries when the uninstalled
++ # path is not listed in the libpath. Setting hardcode_minus_L
++ # to unsupported forces relinking
++ _LT_TAGVAR(hardcode_minus_L, $1)=yes
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=
++ fi
++ ;;
++ esac
++ shared_flag='-shared'
++ if test "$aix_use_runtimelinking" = yes; then
++ shared_flag="$shared_flag "'${wl}-G'
++ fi
++ else
++ # not using gcc
++ if test "$host_cpu" = ia64; then
++ # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
++ # chokes on -Wl,-G. The following line is correct:
++ shared_flag='-G'
++ else
++ if test "$aix_use_runtimelinking" = yes; then
++ shared_flag='${wl}-G'
++ else
++ shared_flag='${wl}-bM:SRE'
++ fi
++ fi
++ fi
+
+-# Compiler flag to prevent dynamic linking.
+-link_static_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_static, $1)
++ # It seems that -bexpall does not export symbols beginning with
++ # underscore (_), so it is better to generate a list of symbols to export.
++ _LT_TAGVAR(always_export_symbols, $1)=yes
++ if test "$aix_use_runtimelinking" = yes; then
++ # Warning - without using the other runtime loading flags (-brtl),
++ # -berok will link without error, but may produce a broken library.
++ _LT_TAGVAR(allow_undefined_flag, $1)='-berok'
++ # Determine the default libpath from the value encoded in an
++ # empty executable.
++ _LT_SYS_MODULE_PATH_AIX
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
++ else
++ if test "$host_cpu" = ia64; then
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
++ _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
++ _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
++ else
++ # Determine the default libpath from the value encoded in an
++ # empty executable.
++ _LT_SYS_MODULE_PATH_AIX
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
++ # Warning - without using the other run time loading flags,
++ # -berok will link without error, but may produce a broken library.
++ _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
++ _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
++ # Exported symbols can be pulled into shared objects from archives
++ _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
++ _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
++ # This is similar to how AIX traditionally builds its shared libraries.
++ _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
++ fi
++ fi
++ ;;
+
+-# Compiler flag to turn off builtin functions.
+-no_builtin_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)
++ amigaos*)
++ case $host_cpu in
++ powerpc)
++ # see comment about AmigaOS4 .so support
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)=''
++ ;;
++ m68k)
++ _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
++ _LT_TAGVAR(hardcode_minus_L, $1)=yes
++ ;;
++ esac
++ ;;
+
+-# Compiler flag to allow reflexive dlopens.
+-export_dynamic_flag_spec=$lt_[]_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)
++ bsdi[[45]]*)
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic
++ ;;
+
+-# Compiler flag to generate shared objects directly from archives.
+-whole_archive_flag_spec=$lt_[]_LT_AC_TAGVAR(whole_archive_flag_spec, $1)
++ cygwin* | mingw* | pw32*)
++ # When not using gcc, we currently assume that we are using
++ # Microsoft Visual C++.
++ # hardcode_libdir_flag_spec is actually meaningless, as there is
++ # no search path for DLLs.
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' '
++ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
++ # Tell ltmain to make .lib files, not .a files.
++ libext=lib
++ # Tell ltmain to make .dll files, not .so files.
++ shrext_cmds=".dll"
++ # FIXME: Setting linknames here is a bad hack.
++ _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `$ECHO "X$deplibs" | $Xsed -e '\''s/ -lc$//'\''` -link -dll~linknames='
++ # The linker will automatically build a .lib file if we build a DLL.
++ _LT_TAGVAR(old_archive_from_new_cmds, $1)='true'
++ # FIXME: Should let the user specify the lib program.
++ _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs'
++ _LT_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`'
++ _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
++ ;;
+
+-# Compiler flag to generate thread-safe objects.
+-thread_safe_flag_spec=$lt_[]_LT_AC_TAGVAR(thread_safe_flag_spec, $1)
++ darwin* | rhapsody*)
++ _LT_DARWIN_LINKER_FEATURES($1)
++ ;;
+
+-# Library versioning type.
+-version_type=$version_type
++ dgux*)
++ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ ;;
+
+-# Format of library name prefix.
+-libname_spec=$lt_libname_spec
++ freebsd1*)
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
+
+-# List of archive names. First name is the real one, the rest are links.
+-# The last name is the one that the linker finds with -lNAME.
+-library_names_spec=$lt_library_names_spec
++ # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
++ # support. Future versions do this automatically, but an explicit c++rt0.o
++ # does not break anything, and helps significantly (at the cost of a little
++ # extra space).
++ freebsd2.2*)
++ _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ ;;
+
+-# The coded name of the library, if different from the real name.
+-soname_spec=$lt_soname_spec
++ # Unfortunately, older versions of FreeBSD 2 do not have this feature.
++ freebsd2*)
++ _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_minus_L, $1)=yes
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ ;;
+
+-# Commands used to build and install an old-style archive.
+-RANLIB=$lt_RANLIB
+-old_archive_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_cmds, $1)
+-old_postinstall_cmds=$lt_old_postinstall_cmds
+-old_postuninstall_cmds=$lt_old_postuninstall_cmds
++ # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
++ freebsd* | dragonfly*)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ ;;
+
+-# Create an old-style archive from a shared archive.
+-old_archive_from_new_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_from_new_cmds, $1)
++ hpux9*)
++ if test "$GCC" = yes; then
++ _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
++ else
++ _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
++ fi
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
++ _LT_TAGVAR(hardcode_direct, $1)=yes
+
+-# Create a temporary old-style archive to link instead of a shared archive.
+-old_archive_from_expsyms_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1)
++ # hardcode_minus_L: Not really in the search PATH,
++ # but as the default location of the library.
++ _LT_TAGVAR(hardcode_minus_L, $1)=yes
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
++ ;;
+
+-# Commands used to build and install a shared archive.
+-archive_cmds=$lt_[]_LT_AC_TAGVAR(archive_cmds, $1)
+-archive_expsym_cmds=$lt_[]_LT_AC_TAGVAR(archive_expsym_cmds, $1)
+-postinstall_cmds=$lt_postinstall_cmds
+-postuninstall_cmds=$lt_postuninstall_cmds
++ hpux10*)
++ if test "$GCC" = yes -a "$with_gnu_ld" = no; then
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
++ else
++ _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
++ fi
++ if test "$with_gnu_ld" = no; then
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
++ _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
++ # hardcode_minus_L: Not really in the search PATH,
++ # but as the default location of the library.
++ _LT_TAGVAR(hardcode_minus_L, $1)=yes
++ fi
++ ;;
+
+-# Commands used to build a loadable module (assumed same as above if empty)
+-module_cmds=$lt_[]_LT_AC_TAGVAR(module_cmds, $1)
+-module_expsym_cmds=$lt_[]_LT_AC_TAGVAR(module_expsym_cmds, $1)
++ hpux11*)
++ if test "$GCC" = yes -a "$with_gnu_ld" = no; then
++ case $host_cpu in
++ hppa*64*)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
++ ;;
++ ia64*)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
++ ;;
++ *)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
++ ;;
++ esac
++ else
++ case $host_cpu in
++ hppa*64*)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
++ ;;
++ ia64*)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
++ ;;
++ *)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
++ ;;
++ esac
++ fi
++ if test "$with_gnu_ld" = no; then
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+-# Commands to strip libraries.
+-old_striplib=$lt_old_striplib
+-striplib=$lt_striplib
++ case $host_cpu in
++ hppa*64*|ia64*)
++ _LT_TAGVAR(hardcode_direct, $1)=no
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ ;;
++ *)
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+
+-# Dependencies to place before the objects being linked to create a
+-# shared library.
+-predep_objects=$lt_[]_LT_AC_TAGVAR(predep_objects, $1)
++ # hardcode_minus_L: Not really in the search PATH,
++ # but as the default location of the library.
++ _LT_TAGVAR(hardcode_minus_L, $1)=yes
++ ;;
++ esac
++ fi
++ ;;
+
+-# Dependencies to place after the objects being linked to create a
+-# shared library.
+-postdep_objects=$lt_[]_LT_AC_TAGVAR(postdep_objects, $1)
++ irix5* | irix6* | nonstopux*)
++ if test "$GCC" = yes; then
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
++ # Try to use the -exported_symbol ld option, if it does not
++ # work, assume that -exports_file does not work either and
++ # implicitly export all symbols.
++ save_LDFLAGS="$LDFLAGS"
++ LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null"
++ AC_LINK_IFELSE(int foo(void) {},
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib'
++ )
++ LDFLAGS="$save_LDFLAGS"
++ else
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib'
++ fi
++ _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
++ _LT_TAGVAR(inherit_rpath, $1)=yes
++ _LT_TAGVAR(link_all_deplibs, $1)=yes
++ ;;
+
+-# Dependencies to place before the objects being linked to create a
+-# shared library.
+-predeps=$lt_[]_LT_AC_TAGVAR(predeps, $1)
++ netbsd*)
++ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
++ _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out
++ else
++ _LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF
++ fi
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ ;;
+
+-# Dependencies to place after the objects being linked to create a
+-# shared library.
+-postdeps=$lt_[]_LT_AC_TAGVAR(postdeps, $1)
++ newsos6)
++ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ ;;
+
+-# The library search path used internally by the compiler when linking
+-# a shared library.
+-compiler_lib_search_path=$lt_[]_LT_AC_TAGVAR(compiler_lib_search_path, $1)
++ *nto* | *qnx*)
++ ;;
+
+-# Method to check whether dependent libraries are shared objects.
+-deplibs_check_method=$lt_deplibs_check_method
++ openbsd*)
++ if test -f /usr/libexec/ld.so; then
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
++ if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
++ else
++ case $host_os in
++ openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*)
++ _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
++ ;;
++ *)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
++ ;;
++ esac
++ fi
++ else
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ fi
++ ;;
+
+-# Command to use when deplibs_check_method == file_magic.
+-file_magic_cmd=$lt_file_magic_cmd
++ os2*)
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
++ _LT_TAGVAR(hardcode_minus_L, $1)=yes
++ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
++ _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$ECHO DATA >> $output_objdir/$libname.def~$ECHO " SINGLE NONSHARED" >> $output_objdir/$libname.def~$ECHO EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
++ _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
++ ;;
+
+-# Flag that allows shared libraries with undefined symbols to be built.
+-allow_undefined_flag=$lt_[]_LT_AC_TAGVAR(allow_undefined_flag, $1)
++ osf3*)
++ if test "$GCC" = yes; then
++ _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
++ else
++ _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
++ fi
++ _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
++ ;;
+
+-# Flag that forces no undefined symbols.
+-no_undefined_flag=$lt_[]_LT_AC_TAGVAR(no_undefined_flag, $1)
++ osf4* | osf5*) # as osf3* with the addition of -msym flag
++ if test "$GCC" = yes; then
++ _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
++ else
++ _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~
++ $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp'
+
+-# Commands used to finish a libtool library installation in a directory.
+-finish_cmds=$lt_finish_cmds
++ # Both c and cxx compiler support -rpath directly
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
++ fi
++ _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
++ ;;
+
+-# Same as above, but a single script fragment to be evaled but not shown.
+-finish_eval=$lt_finish_eval
++ solaris*)
++ _LT_TAGVAR(no_undefined_flag, $1)=' -z defs'
++ if test "$GCC" = yes; then
++ wlarc='${wl}'
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
++ $CC -shared ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
++ else
++ case `$CC -V 2>&1` in
++ *"Compilers 5.0"*)
++ wlarc=''
++ _LT_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
++ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
++ ;;
++ *)
++ wlarc='${wl}'
++ _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
++ $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
++ ;;
++ esac
++ fi
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ case $host_os in
++ solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
++ *)
++ # The compiler driver will combine and reorder linker options,
++ # but understands `-z linker_flag'. GCC discards it without `$wl',
++ # but is careful enough not to reorder.
++ # Supported since Solaris 2.6 (maybe 2.5.1?)
++ if test "$GCC" = yes; then
++ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
++ else
++ _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
++ fi
++ ;;
++ esac
++ _LT_TAGVAR(link_all_deplibs, $1)=yes
++ ;;
+
+-# Take the output of nm and produce a listing of raw symbols and C names.
+-global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
++ sunos4*)
++ if test "x$host_vendor" = xsequent; then
++ # Use $CC to link under sequent, because it throws in some extra .o
++ # files that make .init and .fini sections work.
++ _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
++ else
++ _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
++ fi
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_minus_L, $1)=yes
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ ;;
+
+-# Transform the output of nm in a proper C declaration
+-global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
++ sysv4)
++ case $host_vendor in
++ sni)
++ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
++ _LT_TAGVAR(hardcode_direct, $1)=yes # is this really true???
++ ;;
++ siemens)
++ ## LD is ld it makes a PLAMLIB
++ ## CC just makes a GrossModule.
++ _LT_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags'
++ _LT_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs'
++ _LT_TAGVAR(hardcode_direct, $1)=no
++ ;;
++ motorola)
++ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
++ _LT_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie
++ ;;
++ esac
++ runpath_var='LD_RUN_PATH'
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ ;;
+
+-# Transform the output of nm in a C name address pair
+-global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
++ sysv4.3*)
++ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport'
++ ;;
+
+-# This is the shared library runtime path variable.
+-runpath_var=$runpath_var
++ sysv4*MP*)
++ if test -d /usr/nec; then
++ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ runpath_var=LD_RUN_PATH
++ hardcode_runpath_var=yes
++ _LT_TAGVAR(ld_shlibs, $1)=yes
++ fi
++ ;;
+
+-# This is the shared library path variable.
+-shlibpath_var=$shlibpath_var
++ sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
++ _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
++ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ runpath_var='LD_RUN_PATH'
+
+-# Is shlibpath searched before the hard-coded library search path?
+-shlibpath_overrides_runpath=$shlibpath_overrides_runpath
++ if test "$GCC" = yes; then
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ else
++ _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ fi
++ ;;
+
+-# How to hardcode a shared library path into an executable.
+-hardcode_action=$_LT_AC_TAGVAR(hardcode_action, $1)
++ sysv5* | sco3.2v5* | sco5v6*)
++ # Note: We can NOT use -z defs as we might desire, because we do not
++ # link with -lc, and that would cause any symbols used from libc to
++ # always be unresolved, which means just about no library would
++ # ever link correctly. If we're not using GNU ld we use -z text
++ # though, which does catch some bad symbols but isn't as heavy-handed
++ # as -z defs.
++ _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
++ _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
++ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
++ _LT_TAGVAR(link_all_deplibs, $1)=yes
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
++ runpath_var='LD_RUN_PATH'
+
+-# Whether we should hardcode library paths into libraries.
+-hardcode_into_libs=$hardcode_into_libs
++ if test "$GCC" = yes; then
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ else
++ _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ fi
++ ;;
+
+-# Flag to hardcode \$libdir into a binary during linking.
+-# This must work even if \$libdir does not exist.
+-hardcode_libdir_flag_spec=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)
++ uts4*)
++ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ ;;
+
+-# If ld is used when linking, flag to hardcode \$libdir into
+-# a binary during linking. This must work even if \$libdir does
+-# not exist.
+-hardcode_libdir_flag_spec_ld=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)
++ *)
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++ esac
+
+-# Whether we need a single -rpath flag with a separated argument.
+-hardcode_libdir_separator=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_separator, $1)
++ if test x$host_vendor = xsni; then
++ case $host in
++ sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Blargedynsym'
++ ;;
++ esac
++ fi
++ fi
++])
++AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
++test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
+
+-# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the
+-# resulting binary.
+-hardcode_direct=$_LT_AC_TAGVAR(hardcode_direct, $1)
++_LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld
+
+-# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
+-# resulting binary.
+-hardcode_minus_L=$_LT_AC_TAGVAR(hardcode_minus_L, $1)
++_LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl
++_LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl
++_LT_DECL([], [extract_expsyms_cmds], [2],
++ [The commands to extract the exported symbol list from a shared archive])
+
+-# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
+-# the resulting binary.
+-hardcode_shlibpath_var=$_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)
++#
++# Do we need to explicitly link libc?
++#
++case "x$_LT_TAGVAR(archive_cmds_need_lc, $1)" in
++x|xyes)
++ # Assume -lc should be added
++ _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
+
+-# Set to yes if building a shared library automatically hardcodes DIR into the library
+-# and all subsequent libraries and executables linked against it.
+-hardcode_automatic=$_LT_AC_TAGVAR(hardcode_automatic, $1)
++ if test "$enable_shared" = yes && test "$GCC" = yes; then
++ case $_LT_TAGVAR(archive_cmds, $1) in
++ *'~'*)
++ # FIXME: we may have to deal with multi-command sequences.
++ ;;
++ '$CC '*)
++ # Test whether the compiler implicitly links with -lc since on some
++ # systems, -lgcc has to come before -lc. If gcc already passes -lc
++ # to ld, don't add -lc before -lgcc.
++ AC_MSG_CHECKING([whether -lc should be explicitly linked in])
++ $RM conftest*
++ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+-# Variables whose values should be saved in libtool wrapper scripts and
+-# restored at relink time.
+-variables_saved_for_relink="$variables_saved_for_relink"
++ if AC_TRY_EVAL(ac_compile) 2>conftest.err; then
++ soname=conftest
++ lib=conftest
++ libobjs=conftest.$ac_objext
++ deplibs=
++ wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1)
++ pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1)
++ compiler_flags=-v
++ linker_flags=-v
++ verstring=
++ output_objdir=.
++ libname=conftest
++ lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1)
++ _LT_TAGVAR(allow_undefined_flag, $1)=
++ if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1)
++ then
++ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
++ else
++ _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
++ fi
++ _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag
++ else
++ cat conftest.err 1>&5
++ fi
++ $RM conftest*
++ AC_MSG_RESULT([$_LT_TAGVAR(archive_cmds_need_lc, $1)])
++ ;;
++ esac
++ fi
++ ;;
++esac
+
+-# Whether libtool must link a program against all its dependency libraries.
+-link_all_deplibs=$_LT_AC_TAGVAR(link_all_deplibs, $1)
++_LT_TAGDECL([build_libtool_need_lc], [archive_cmds_need_lc], [0],
++ [Whether or not to add -lc for building shared libraries])
++_LT_TAGDECL([allow_libtool_libs_with_static_runtimes],
++ [enable_shared_with_static_runtimes], [0],
++ [Whether or not to disallow shared libs when runtime libs are static])
++_LT_TAGDECL([], [export_dynamic_flag_spec], [1],
++ [Compiler flag to allow reflexive dlopens])
++_LT_TAGDECL([], [whole_archive_flag_spec], [1],
++ [Compiler flag to generate shared objects directly from archives])
++_LT_TAGDECL([], [compiler_needs_object], [1],
++ [Whether the compiler copes with passing no objects directly])
++_LT_TAGDECL([], [old_archive_from_new_cmds], [2],
++ [Create an old-style archive from a shared archive])
++_LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2],
++ [Create a temporary old-style archive to link instead of a shared archive])
++_LT_TAGDECL([], [archive_cmds], [2], [Commands used to build a shared archive])
++_LT_TAGDECL([], [archive_expsym_cmds], [2])
++_LT_TAGDECL([], [module_cmds], [2],
++ [Commands used to build a loadable module if different from building
++ a shared archive.])
++_LT_TAGDECL([], [module_expsym_cmds], [2])
++_LT_TAGDECL([], [with_gnu_ld], [1],
++ [Whether we are building with GNU ld or not])
++_LT_TAGDECL([], [allow_undefined_flag], [1],
++ [Flag that allows shared libraries with undefined symbols to be built])
++_LT_TAGDECL([], [no_undefined_flag], [1],
++ [Flag that enforces no undefined symbols])
++_LT_TAGDECL([], [hardcode_libdir_flag_spec], [1],
++ [Flag to hardcode $libdir into a binary during linking.
++ This must work even if $libdir does not exist])
++_LT_TAGDECL([], [hardcode_libdir_flag_spec_ld], [1],
++ [[If ld is used when linking, flag to hardcode $libdir into a binary
++ during linking. This must work even if $libdir does not exist]])
++_LT_TAGDECL([], [hardcode_libdir_separator], [1],
++ [Whether we need a single "-rpath" flag with a separated argument])
++_LT_TAGDECL([], [hardcode_direct], [0],
++ [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes
++ DIR into the resulting binary])
++_LT_TAGDECL([], [hardcode_direct_absolute], [0],
++ [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes
++ DIR into the resulting binary and the resulting library dependency is
++ "absolute", i.e impossible to change by setting ${shlibpath_var} if the
++ library is relocated])
++_LT_TAGDECL([], [hardcode_minus_L], [0],
++ [Set to "yes" if using the -LDIR flag during linking hardcodes DIR
++ into the resulting binary])
++_LT_TAGDECL([], [hardcode_shlibpath_var], [0],
++ [Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR
++ into the resulting binary])
++_LT_TAGDECL([], [hardcode_automatic], [0],
++ [Set to "yes" if building a shared library automatically hardcodes DIR
++ into the library and all subsequent libraries and executables linked
++ against it])
++_LT_TAGDECL([], [inherit_rpath], [0],
++ [Set to yes if linker adds runtime paths of dependent libraries
++ to runtime path list])
++_LT_TAGDECL([], [link_all_deplibs], [0],
++ [Whether libtool must link a program against all its dependency libraries])
++_LT_TAGDECL([], [fix_srcfile_path], [1],
++ [Fix the shell variable $srcfile for the compiler])
++_LT_TAGDECL([], [always_export_symbols], [0],
++ [Set to "yes" if exported symbols are required])
++_LT_TAGDECL([], [export_symbols_cmds], [2],
++ [The commands to list exported symbols])
++_LT_TAGDECL([], [exclude_expsyms], [1],
++ [Symbols that should not be listed in the preloaded symbols])
++_LT_TAGDECL([], [include_expsyms], [1],
++ [Symbols that must always be exported])
++_LT_TAGDECL([], [prelink_cmds], [2],
++ [Commands necessary for linking programs (against libraries) with templates])
++_LT_TAGDECL([], [file_list_spec], [1],
++ [Specify filename containing input files])
++dnl FIXME: Not yet implemented
++dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1],
++dnl [Compiler flag to generate thread safe objects])
++])# _LT_LINKER_SHLIBS
+
+-# Compile-time system search path for libraries
+-sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
+
+-# Run-time system search path for libraries
+-sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
++# _LT_LANG_C_CONFIG([TAG])
++# ------------------------
++# Ensure that the configuration variables for a C compiler are suitably
++# defined. These variables are subsequently used by _LT_CONFIG to write
++# the compiler configuration to `libtool'.
++m4_defun([_LT_LANG_C_CONFIG],
++[m4_require([_LT_DECL_EGREP])dnl
++lt_save_CC="$CC"
++AC_LANG_PUSH(C)
+
+-# Fix the shell variable \$srcfile for the compiler.
+-fix_srcfile_path="$_LT_AC_TAGVAR(fix_srcfile_path, $1)"
++# Source file extension for C test sources.
++ac_ext=c
+
+-# Set to yes if exported symbols are required.
+-always_export_symbols=$_LT_AC_TAGVAR(always_export_symbols, $1)
++# Object file extension for compiled C test sources.
++objext=o
++_LT_TAGVAR(objext, $1)=$objext
+
+-# The commands to list exported symbols.
+-export_symbols_cmds=$lt_[]_LT_AC_TAGVAR(export_symbols_cmds, $1)
++# Code to be used in simple compile tests
++lt_simple_compile_test_code="int some_variable = 0;"
+
+-# The commands to extract the exported symbol list from a shared archive.
+-extract_expsyms_cmds=$lt_extract_expsyms_cmds
++# Code to be used in simple link tests
++lt_simple_link_test_code='int main(){return(0);}'
+
+-# Symbols that should not be listed in the preloaded symbols.
+-exclude_expsyms=$lt_[]_LT_AC_TAGVAR(exclude_expsyms, $1)
++_LT_TAG_COMPILER
++# Save the default compiler, since it gets overwritten when the other
++# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP.
++compiler_DEFAULT=$CC
+
+-# Symbols that must always be exported.
+-include_expsyms=$lt_[]_LT_AC_TAGVAR(include_expsyms, $1)
++# save warnings/boilerplate of simple test code
++_LT_COMPILER_BOILERPLATE
++_LT_LINKER_BOILERPLATE
+
+-ifelse([$1],[],
+-[# ### END LIBTOOL CONFIG],
+-[# ### END LIBTOOL TAG CONFIG: $tagname])
++## CAVEAT EMPTOR:
++## There is no encapsulation within the following macros, do not change
++## the running order or otherwise move them around unless you know exactly
++## what you are doing...
++if test -n "$compiler"; then
++ _LT_COMPILER_NO_RTTI($1)
++ _LT_COMPILER_PIC($1)
++ _LT_COMPILER_C_O($1)
++ _LT_COMPILER_FILE_LOCKS($1)
++ _LT_LINKER_SHLIBS($1)
++ _LT_SYS_DYNAMIC_LINKER($1)
++ _LT_LINKER_HARDCODE_LIBPATH($1)
++ LT_SYS_DLOPEN_SELF
++ _LT_CMD_STRIPLIB
++
++ # Report which library types will actually be built
++ AC_MSG_CHECKING([if libtool supports shared libraries])
++ AC_MSG_RESULT([$can_build_shared])
+
+-__EOF__
++ AC_MSG_CHECKING([whether to build shared libraries])
++ test "$can_build_shared" = "no" && enable_shared=no
+
+-ifelse([$1],[], [
++ # On AIX, shared libraries and static libraries use the same namespace, and
++ # are all built from PIC.
+ case $host_os in
+ aix3*)
+- cat <<\EOF >> "$cfgfile"
++ test "$enable_shared" = yes && enable_static=no
++ if test -n "$RANLIB"; then
++ archive_cmds="$archive_cmds~\$RANLIB \$lib"
++ postinstall_cmds='$RANLIB $lib'
++ fi
++ ;;
+
+-# AIX sometimes has problems with the GCC collect2 program. For some
+-# reason, if we set the COLLECT_NAMES environment variable, the problems
+-# vanish in a puff of smoke.
+-if test "X${COLLECT_NAMES+set}" != Xset; then
+- COLLECT_NAMES=
+- export COLLECT_NAMES
+-fi
+-EOF
++ aix[[4-9]]*)
++ if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
++ test "$enable_shared" = yes && enable_static=no
++ fi
+ ;;
+ esac
++ AC_MSG_RESULT([$enable_shared])
+
+- # We use sed instead of cat because bash on DJGPP gets confused if
+- # if finds mixed CR/LF and LF-only lines. Since sed operates in
+- # text mode, it properly converts lines to CR/LF. This bash problem
+- # is reportedly fixed, but why not run on old versions too?
+- sed '$q' "$ltmain" >> "$cfgfile" || (rm -f "$cfgfile"; exit 1)
++ AC_MSG_CHECKING([whether to build static libraries])
++ # Make sure either enable_shared or enable_static is yes.
++ test "$enable_shared" = yes || enable_static=yes
++ AC_MSG_RESULT([$enable_static])
+
+- mv -f "$cfgfile" "$ofile" || \
+- (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
+- chmod +x "$ofile"
+-])
+-else
+- # If there is no Makefile yet, we rely on a make rule to execute
+- # `config.status --recheck' to rerun these tests and create the
+- # libtool script then.
+- ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'`
+- if test -f "$ltmain_in"; then
+- test -f Makefile && make "$ltmain"
+- fi
++ _LT_CONFIG($1)
+ fi
+-])# AC_LIBTOOL_CONFIG
+-
+-
+-# AC_LIBTOOL_PROG_COMPILER_NO_RTTI([TAGNAME])
+-# -------------------------------------------
+-AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI],
+-[AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl
+-
+-_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
++AC_LANG_POP
++CC="$lt_save_CC"
++])# _LT_LANG_C_CONFIG
+
+-if test "$GCC" = yes; then
+- _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
+
+- AC_LIBTOOL_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions],
+- lt_cv_prog_compiler_rtti_exceptions,
+- [-fno-rtti -fno-exceptions], [],
+- [_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"])
++# _LT_PROG_CXX
++# ------------
++# Since AC_PROG_CXX is broken, in that it returns g++ if there is no c++
++# compiler, we have our own version here.
++m4_defun([_LT_PROG_CXX],
++[
++pushdef([AC_MSG_ERROR], [_lt_caught_CXX_error=yes])
++AC_PROG_CXX
++if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
++ ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
++ (test "X$CXX" != "Xg++"))) ; then
++ AC_PROG_CXXCPP
++else
++ _lt_caught_CXX_error=yes
+ fi
+-])# AC_LIBTOOL_PROG_COMPILER_NO_RTTI
++popdef([AC_MSG_ERROR])
++])# _LT_PROG_CXX
+
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([_LT_PROG_CXX], [])
+
+-# AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE
+-# ---------------------------------
+-AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE],
+-[AC_REQUIRE([AC_CANONICAL_HOST])
+-AC_REQUIRE([AC_PROG_NM])
+-AC_REQUIRE([AC_OBJEXT])
+-# Check for command to grab the raw symbol name followed by C symbol from nm.
+-AC_MSG_CHECKING([command to parse $NM output from $compiler object])
+-AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe],
+-[
+-# These are sane defaults that work on at least a few old systems.
+-# [They come from Ultrix. What could be older than Ultrix?!! ;)]
+-
+-# Character class describing NM global symbol codes.
+-symcode='[[BCDEGRST]]'
+
+-# Regexp to match symbols that can be accessed directly from C.
+-sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)'
++# _LT_LANG_CXX_CONFIG([TAG])
++# --------------------------
++# Ensure that the configuration variables for a C++ compiler are suitably
++# defined. These variables are subsequently used by _LT_CONFIG to write
++# the compiler configuration to `libtool'.
++m4_defun([_LT_LANG_CXX_CONFIG],
++[AC_REQUIRE([_LT_PROG_CXX])dnl
++m4_require([_LT_FILEUTILS_DEFAULTS])dnl
++m4_require([_LT_DECL_EGREP])dnl
++
++AC_LANG_PUSH(C++)
++_LT_TAGVAR(archive_cmds_need_lc, $1)=no
++_LT_TAGVAR(allow_undefined_flag, $1)=
++_LT_TAGVAR(always_export_symbols, $1)=no
++_LT_TAGVAR(archive_expsym_cmds, $1)=
++_LT_TAGVAR(compiler_needs_object, $1)=no
++_LT_TAGVAR(export_dynamic_flag_spec, $1)=
++_LT_TAGVAR(hardcode_direct, $1)=no
++_LT_TAGVAR(hardcode_direct_absolute, $1)=no
++_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
++_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
++_LT_TAGVAR(hardcode_libdir_separator, $1)=
++_LT_TAGVAR(hardcode_minus_L, $1)=no
++_LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
++_LT_TAGVAR(hardcode_automatic, $1)=no
++_LT_TAGVAR(inherit_rpath, $1)=no
++_LT_TAGVAR(module_cmds, $1)=
++_LT_TAGVAR(module_expsym_cmds, $1)=
++_LT_TAGVAR(link_all_deplibs, $1)=unknown
++_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
++_LT_TAGVAR(no_undefined_flag, $1)=
++_LT_TAGVAR(whole_archive_flag_spec, $1)=
++_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+
+-# Transform an extracted symbol line into a proper C declaration
+-lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern int \1;/p'"
++# Source file extension for C++ test sources.
++ac_ext=cpp
+
+-# Transform an extracted symbol line into symbol name and symbol address
+-lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'"
++# Object file extension for compiled C++ test sources.
++objext=o
++_LT_TAGVAR(objext, $1)=$objext
+
+-# Define system-specific variables.
+-case $host_os in
+-aix*)
+- symcode='[[BCDT]]'
+- ;;
+-cygwin* | mingw* | pw32*)
+- symcode='[[ABCDGISTW]]'
+- ;;
+-hpux*) # Its linker distinguishes data from code symbols
+- if test "$host_cpu" = ia64; then
+- symcode='[[ABCDEGRST]]'
++# No sense in running all these tests if we already determined that
++# the CXX compiler isn't working. Some variables (like enable_shared)
++# are currently assumed to apply to all compilers on this platform,
++# and will be corrupted by setting them based on a non-working compiler.
++if test "$_lt_caught_CXX_error" != yes; then
++ # Code to be used in simple compile tests
++ lt_simple_compile_test_code="int some_variable = 0;"
++
++ # Code to be used in simple link tests
++ lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }'
++
++ # ltmain only uses $CC for tagged configurations so make sure $CC is set.
++ _LT_TAG_COMPILER
++
++ # save warnings/boilerplate of simple test code
++ _LT_COMPILER_BOILERPLATE
++ _LT_LINKER_BOILERPLATE
++
++ # Allow CC to be a program name with arguments.
++ lt_save_CC=$CC
++ lt_save_LD=$LD
++ lt_save_GCC=$GCC
++ GCC=$GXX
++ lt_save_with_gnu_ld=$with_gnu_ld
++ lt_save_path_LD=$lt_cv_path_LD
++ if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then
++ lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx
++ else
++ $as_unset lt_cv_prog_gnu_ld
+ fi
+- lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
+- lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'"
+- ;;
+-linux*)
+- if test "$host_cpu" = ia64; then
+- symcode='[[ABCDGIRSTW]]'
+- lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
+- lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'"
++ if test -n "${lt_cv_path_LDCXX+set}"; then
++ lt_cv_path_LD=$lt_cv_path_LDCXX
++ else
++ $as_unset lt_cv_path_LD
+ fi
+- ;;
+-irix* | nonstopux*)
+- symcode='[[BCDEGRST]]'
+- ;;
+-osf*)
+- symcode='[[BCDEGQRST]]'
+- ;;
+-solaris*)
+- symcode='[[BDRT]]'
+- ;;
+-sco3.2v5*)
+- symcode='[[DT]]'
+- ;;
+-sysv4.2uw2*)
+- symcode='[[DT]]'
+- ;;
+-sysv5* | sco5v6* | unixware* | OpenUNIX*)
+- symcode='[[ABDT]]'
+- ;;
+-sysv4)
+- symcode='[[DFNSTU]]'
+- ;;
+-esac
+-
+-# Handle CRLF in mingw tool chain
+-opt_cr=
+-case $build_os in
+-mingw*)
+- opt_cr=`echo 'x\{0,1\}' | tr x '\015'` # option cr in regexp
+- ;;
+-esac
+-
+-# If we're using GNU nm, then use its standard symbol codes.
+-case `$NM -V 2>&1` in
+-*GNU* | *'with BFD'*)
+- symcode='[[ABCDGIRSTW]]' ;;
+-esac
+-
+-# Try without a prefix undercore, then with it.
+-for ac_symprfx in "" "_"; do
+-
+- # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
+- symxfrm="\\1 $ac_symprfx\\2 \\2"
+-
+- # Write the raw and C identifiers.
+- lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
+-
+- # Check to see that the pipe works correctly.
+- pipe_works=no
+-
+- rm -f conftest*
+- cat > conftest.$ac_ext <<EOF
+-#ifdef __cplusplus
+-extern "C" {
+-#endif
+-char nm_test_var;
+-void nm_test_func(){}
+-#ifdef __cplusplus
+-}
+-#endif
+-int main(){nm_test_var='a';nm_test_func();return(0);}
+-EOF
+-
+- if AC_TRY_EVAL(ac_compile); then
+- # Now try to grab the symbols.
+- nlist=conftest.nm
+- if AC_TRY_EVAL(NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) && test -s "$nlist"; then
+- # Try sorting and uniquifying the output.
+- if sort "$nlist" | uniq > "$nlist"T; then
+- mv -f "$nlist"T "$nlist"
+- else
+- rm -f "$nlist"T
+- fi
+-
+- # Make sure that we snagged all the symbols we need.
+- if grep ' nm_test_var$' "$nlist" >/dev/null; then
+- if grep ' nm_test_func$' "$nlist" >/dev/null; then
+- cat <<EOF > conftest.$ac_ext
+-#ifdef __cplusplus
+-extern "C" {
+-#endif
+-
+-EOF
+- # Now generate the symbol file.
+- eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | grep -v main >> conftest.$ac_ext'
+-
+- cat <<EOF >> conftest.$ac_ext
+-#if defined (__STDC__) && __STDC__
+-# define lt_ptr_t void *
+-#else
+-# define lt_ptr_t char *
+-# define const
+-#endif
+-
+-/* The mapping between symbol names and symbols. */
+-const struct {
+- const char *name;
+- lt_ptr_t address;
+-}
+-lt_preloaded_symbols[[]] =
+-{
+-EOF
+- $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (lt_ptr_t) \&\2},/" < "$nlist" | grep -v main >> conftest.$ac_ext
+- cat <<\EOF >> conftest.$ac_ext
+- {0, (lt_ptr_t) 0}
+-};
++ test -z "${LDCXX+set}" || LD=$LDCXX
++ CC=${CXX-"c++"}
++ compiler=$CC
++ _LT_TAGVAR(compiler, $1)=$CC
++ _LT_CC_BASENAME([$compiler])
+
+-#ifdef __cplusplus
+-}
+-#endif
+-EOF
+- # Now try linking the two files.
+- mv conftest.$ac_objext conftstm.$ac_objext
+- lt_save_LIBS="$LIBS"
+- lt_save_CFLAGS="$CFLAGS"
+- LIBS="conftstm.$ac_objext"
+- CFLAGS="$CFLAGS$_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)"
+- if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then
+- pipe_works=yes
+- fi
+- LIBS="$lt_save_LIBS"
+- CFLAGS="$lt_save_CFLAGS"
+- else
+- echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD
+- fi
+- else
+- echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD
+- fi
++ if test -n "$compiler"; then
++ # We don't want -fno-exception when compiling C++ code, so set the
++ # no_builtin_flag separately
++ if test "$GXX" = yes; then
++ _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
+ else
+- echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD
++ _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
+ fi
+- else
+- echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD
+- cat conftest.$ac_ext >&5
+- fi
+- rm -f conftest* conftst*
+-
+- # Do not use the global_symbol_pipe unless it works.
+- if test "$pipe_works" = yes; then
+- break
+- else
+- lt_cv_sys_global_symbol_pipe=
+- fi
+-done
+-])
+-if test -z "$lt_cv_sys_global_symbol_pipe"; then
+- lt_cv_sys_global_symbol_to_cdecl=
+-fi
+-if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
+- AC_MSG_RESULT(failed)
+-else
+- AC_MSG_RESULT(ok)
+-fi
+-]) # AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE
+
++ if test "$GXX" = yes; then
++ # Set up default GNU C++ configuration
+
+-# AC_LIBTOOL_PROG_COMPILER_PIC([TAGNAME])
+-# ---------------------------------------
+-AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC],
+-[_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)=
+-_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
+-_LT_AC_TAGVAR(lt_prog_compiler_static, $1)=
++ LT_PATH_LD
+
+-AC_MSG_CHECKING([for $compiler option to produce PIC])
+- ifelse([$1],[CXX],[
+- # C++ specific cases for pic, static, wl, etc.
+- if test "$GXX" = yes; then
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
++ # Check if GNU C++ uses GNU ld as the underlying linker, since the
++ # archiving commands below assume that GNU ld is being used.
++ if test "$with_gnu_ld" = yes; then
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
++
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
++
++ # If archive_cmds runs LD, not CC, wlarc should be empty
++ # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
++ # investigate it a little bit more. (MM)
++ wlarc='${wl}'
++
++ # ancient GNU ld didn't support --whole-archive et. al.
++ if eval "`$CC -print-prog-name=ld` --help 2>&1" |
++ $GREP 'no-whole-archive' > /dev/null; then
++ _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
++ else
++ _LT_TAGVAR(whole_archive_flag_spec, $1)=
++ fi
++ else
++ with_gnu_ld=no
++ wlarc=
+
+- case $host_os in
+- aix*)
+- # All AIX code is PIC.
+- if test "$host_cpu" = ia64; then
+- # AIX 5 now supports IA64 processor
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- fi
+- ;;
+- amigaos*)
+- # FIXME: we need at least 68020 code to build shared libraries, but
+- # adding the `-m68020' flag to GCC prevents building anything better,
+- # like `-m68040'.
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
+- ;;
+- beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+- # PIC is the default for these OSes.
+- ;;
+- mingw* | cygwin* | os2* | pw32*)
+- # This hack is so that the source file can tell whether it is being
+- # built for inclusion in a dll (and should export symbols for example).
+- # Although the cygwin gcc ignores -fPIC, still need this for old-style
+- # (--disable-auto-import) libraries
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'
+- ;;
+- darwin* | rhapsody*)
+- # PIC is the default on this platform
+- # Common symbols not allowed in MH_DYLIB files
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
+- ;;
+- *djgpp*)
+- # DJGPP does not support shared libraries at all
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
+- ;;
+- interix3*)
+- # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+- # Instead, we relocate shared libraries at runtime.
+- ;;
+- sysv4*MP*)
+- if test -d /usr/nec; then
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
++ # A generic and very simple default shared library creation
++ # command for GNU C++ for the case where it uses the native
++ # linker, instead of GNU ld. If possible, this setting should
++ # overridden to take advantage of the native linker features on
++ # the platform it is being used on.
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+ fi
+- ;;
+- hpux*)
+- # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+- # not for PA HP-UX.
+- case $host_cpu in
+- hppa*64*|ia64*)
+- ;;
+- *)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+- ;;
+- esac
+- ;;
+- *)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+- ;;
+- esac
+- else
++
++ # Commands to make compiler produce verbose output that lists
++ # what "hidden" libraries, object files and flags are used when
++ # linking a shared library.
++ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
++
++ else
++ GXX=no
++ with_gnu_ld=no
++ wlarc=
++ fi
++
++ # PORTME: fill in a description of your system's C++ link characteristics
++ AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
++ _LT_TAGVAR(ld_shlibs, $1)=yes
+ case $host_os in
+- aix4* | aix5*)
+- # All AIX code is PIC.
+- if test "$host_cpu" = ia64; then
+- # AIX 5 now supports IA64 processor
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ aix3*)
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++ aix[[4-9]]*)
++ if test "$host_cpu" = ia64; then
++ # On IA64, the linker does run time linking by default, so we don't
++ # have to do anything special.
++ aix_use_runtimelinking=no
++ exp_sym_flag='-Bexport'
++ no_entry_flag=""
++ else
++ aix_use_runtimelinking=no
++
++ # Test if we are trying to use run time linking or normal
++ # AIX style linking. If -brtl is somewhere in LDFLAGS, we
++ # need to do runtime linking.
++ case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
++ for ld_flag in $LDFLAGS; do
++ case $ld_flag in
++ *-brtl*)
++ aix_use_runtimelinking=yes
++ break
++ ;;
++ esac
++ done
++ ;;
++ esac
++
++ exp_sym_flag='-bexport'
++ no_entry_flag='-bnoentry'
++ fi
++
++ # When large executables or shared objects are built, AIX ld can
++ # have problems creating the table of contents. If linking a library
++ # or program results in "error TOC overflow" add -mminimal-toc to
++ # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
++ # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
++
++ _LT_TAGVAR(archive_cmds, $1)=''
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
++ _LT_TAGVAR(link_all_deplibs, $1)=yes
++ _LT_TAGVAR(file_list_spec, $1)='${wl}-f,'
++
++ if test "$GXX" = yes; then
++ case $host_os in aix4.[[012]]|aix4.[[012]].*)
++ # We only want to do this on AIX 4.2 and lower, the check
++ # below for broken collect2 doesn't work under 4.3+
++ collect2name=`${CC} -print-prog-name=collect2`
++ if test -f "$collect2name" &&
++ strings "$collect2name" | $GREP resolve_lib_name >/dev/null
++ then
++ # We have reworked collect2
++ :
++ else
++ # We have old collect2
++ _LT_TAGVAR(hardcode_direct, $1)=unsupported
++ # It fails to find uninstalled libraries when the uninstalled
++ # path is not listed in the libpath. Setting hardcode_minus_L
++ # to unsupported forces relinking
++ _LT_TAGVAR(hardcode_minus_L, $1)=yes
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=
++ fi
++ esac
++ shared_flag='-shared'
++ if test "$aix_use_runtimelinking" = yes; then
++ shared_flag="$shared_flag "'${wl}-G'
++ fi
++ else
++ # not using gcc
++ if test "$host_cpu" = ia64; then
++ # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
++ # chokes on -Wl,-G. The following line is correct:
++ shared_flag='-G'
++ else
++ if test "$aix_use_runtimelinking" = yes; then
++ shared_flag='${wl}-G'
++ else
++ shared_flag='${wl}-bM:SRE'
++ fi
++ fi
++ fi
++
++ # It seems that -bexpall does not export symbols beginning with
++ # underscore (_), so it is better to generate a list of symbols to
++ # export.
++ _LT_TAGVAR(always_export_symbols, $1)=yes
++ if test "$aix_use_runtimelinking" = yes; then
++ # Warning - without using the other runtime loading flags (-brtl),
++ # -berok will link without error, but may produce a broken library.
++ _LT_TAGVAR(allow_undefined_flag, $1)='-berok'
++ # Determine the default libpath from the value encoded in an empty
++ # executable.
++ _LT_SYS_MODULE_PATH_AIX
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
++
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
++ else
++ if test "$host_cpu" = ia64; then
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
++ _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
++ _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
++ else
++ # Determine the default libpath from the value encoded in an
++ # empty executable.
++ _LT_SYS_MODULE_PATH_AIX
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
++ # Warning - without using the other run time loading flags,
++ # -berok will link without error, but may produce a broken library.
++ _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
++ _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
++ # Exported symbols can be pulled into shared objects from archives
++ _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
++ _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
++ # This is similar to how AIX traditionally builds its shared
++ # libraries.
++ _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
++ fi
++ fi
++ ;;
++
++ beos*)
++ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
++ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
++ # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
++ # support --undefined. This deserves some investigation. FIXME
++ _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ else
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
++ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
++
+ chorus*)
+- case $cc_basename in
+- cxch68*)
+- # Green Hills C++ Compiler
+- # _LT_AC_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a"
++ case $cc_basename in
++ *)
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+- esac
++ esac
++ ;;
++
++ cygwin* | mingw* | pw32*)
++ # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
++ # as there is no search path for DLLs.
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
++ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
++ _LT_TAGVAR(always_export_symbols, $1)=no
++ _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
++
++ if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
++ # If the export-symbols file already is a .def file (1st line
++ # is EXPORTS), use it as is; otherwise, prepend...
++ _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
++ cp $export_symbols $output_objdir/$soname.def;
++ else
++ echo EXPORTS > $output_objdir/$soname.def;
++ cat $export_symbols >> $output_objdir/$soname.def;
++ fi~
++ $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
++ else
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ fi
++ ;;
++ darwin* | rhapsody*)
++ _LT_DARWIN_LINKER_FEATURES($1)
+ ;;
+- darwin*)
+- # PIC is the default on this platform
+- # Common symbols not allowed in MH_DYLIB files
+- case $cc_basename in
+- xlc*)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-qnocommon'
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- ;;
+- esac
+- ;;
++
+ dgux*)
+- case $cc_basename in
+- ec++*)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ case $cc_basename in
++ ec++*)
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+- ghcx*)
++ ghcx*)
+ # Green Hills C++ Compiler
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+- *)
++ *)
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+- esac
+- ;;
+- freebsd* | kfreebsd*-gnu | dragonfly*)
+- # FreeBSD uses GNU C++
+- ;;
+- hpux9* | hpux10* | hpux11*)
+- case $cc_basename in
+- CC*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+- if test "$host_cpu" != ia64; then
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
+- fi
++ esac
++ ;;
++
++ freebsd[[12]]*)
++ # C++ shared libraries reported to be fairly broken before
++ # switch to ELF
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++
++ freebsd-elf*)
++ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
++ ;;
++
++ freebsd* | dragonfly*)
++ # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
++ # conventions
++ _LT_TAGVAR(ld_shlibs, $1)=yes
++ ;;
++
++ gnu*)
++ ;;
++
++ hpux9*)
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
++ # but as the default
++ # location of the library.
++
++ case $cc_basename in
++ CC*)
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++ aCC*)
++ _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
++ # Commands to make compiler produce verbose output that lists
++ # what "hidden" libraries, object files and flags are used when
++ # linking a shared library.
++ #
++ # There doesn't appear to be a way to prevent this compiler from
++ # explicitly linking system object files so we need to strip them
++ # from the output so that they don't get included in the library
++ # dependencies.
++ output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
++ ;;
++ *)
++ if test "$GXX" = yes; then
++ _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
++ else
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ fi
++ ;;
++ esac
++ ;;
++
++ hpux10*|hpux11*)
++ if test $with_gnu_ld = no; then
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
++
++ case $host_cpu in
++ hppa*64*|ia64*)
++ ;;
++ *)
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
++ ;;
++ esac
++ fi
++ case $host_cpu in
++ hppa*64*|ia64*)
++ _LT_TAGVAR(hardcode_direct, $1)=no
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ ;;
++ *)
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
++ _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
++ # but as the default
++ # location of the library.
++ ;;
++ esac
++
++ case $cc_basename in
++ CC*)
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+- aCC*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
++ aCC*)
+ case $host_cpu in
+- hppa*64*|ia64*)
+- # +Z the default
+- ;;
+- *)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
+- ;;
++ hppa*64*)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
++ ;;
++ ia64*)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
++ ;;
++ *)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
++ ;;
+ esac
++ # Commands to make compiler produce verbose output that lists
++ # what "hidden" libraries, object files and flags are used when
++ # linking a shared library.
++ #
++ # There doesn't appear to be a way to prevent this compiler from
++ # explicitly linking system object files so we need to strip them
++ # from the output so that they don't get included in the library
++ # dependencies.
++ output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
+ ;;
+- *)
++ *)
++ if test "$GXX" = yes; then
++ if test $with_gnu_ld = no; then
++ case $host_cpu in
++ hppa*64*)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
++ ;;
++ ia64*)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
++ ;;
++ *)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
++ ;;
++ esac
++ fi
++ else
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ fi
+ ;;
+- esac
+- ;;
+- interix*)
+- # This is c89, which is MS Visual C++ (no shared libs)
+- # Anyone wants to do a port?
+- ;;
+- irix5* | irix6* | nonstopux*)
+- case $cc_basename in
+- CC*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+- # CC pic flag -KPIC is the default.
++ esac
++ ;;
++
++ interix[[3-9]]*)
++ _LT_TAGVAR(hardcode_direct, $1)=no
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
++ # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
++ # Instead, shared libraries are loaded at an image base (0x10000000 by
++ # default) and relocated if they conflict, which is a slow very memory
++ # consuming and fragmenting process. To avoid this, we pick a random,
++ # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
++ # time. Moving up from 0x10000000 also allows more sbrk(2) space.
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
++ ;;
++ irix5* | irix6*)
++ case $cc_basename in
++ CC*)
++ # SGI C++
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
++
++ # Archives containing C++ object files must be created using
++ # "CC -ar", where "CC" is the IRIX C++ compiler. This is
++ # necessary to make sure instantiated templates are included
++ # in the archive.
++ _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs'
+ ;;
+- *)
++ *)
++ if test "$GXX" = yes; then
++ if test "$with_gnu_ld" = no; then
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
++ else
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` -o $lib'
++ fi
++ fi
++ _LT_TAGVAR(link_all_deplibs, $1)=yes
+ ;;
+- esac
+- ;;
+- linux*)
+- case $cc_basename in
+- KCC*)
+- # KAI C++ Compiler
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
++ esac
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
++ _LT_TAGVAR(inherit_rpath, $1)=yes
++ ;;
++
++ linux* | k*bsd*-gnu)
++ case $cc_basename in
++ KCC*)
++ # Kuck and Associates, Inc. (KAI) C++ Compiler
++
++ # KCC will only create a shared library if the output file
++ # ends with ".so" (or ".sl" for HP-UX), so rename the library
++ # to its proper name (with version) after linking.
++ _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib'
++ # Commands to make compiler produce verbose output that lists
++ # what "hidden" libraries, object files and flags are used when
++ # linking a shared library.
++ #
++ # There doesn't appear to be a way to prevent this compiler from
++ # explicitly linking system object files so we need to strip them
++ # from the output so that they don't get included in the library
++ # dependencies.
++ output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
++
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
++
++ # Archives containing C++ object files must be created using
++ # "CC -Bstatic", where "CC" is the KAI C++ compiler.
++ _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs'
+ ;;
+- icpc* | ecpc*)
++ icpc* | ecpc* )
+ # Intel C++
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
+- ;;
+- pgCC*)
+- # Portland Group C++ compiler.
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- ;;
+- cxx*)
+- # Compaq C++
+- # Make sure the PIC flag is empty. It appears that all Alpha
+- # Linux and Compaq Tru64 Unix objects are PIC.
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
++ with_gnu_ld=yes
++ # version 8.0 and above of icpc choke on multiply defined symbols
++ # if we add $predep_objects and $postdep_objects, however 7.1 and
++ # earlier do not add the objects themselves.
++ case `$CC -V 2>&1` in
++ *"Version 7."*)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
++ ;;
++ *) # Version 8.0 or newer
++ tmp_idyn=
++ case $host_cpu in
++ ia64*) tmp_idyn=' -i_dynamic';;
++ esac
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
++ ;;
++ esac
++ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
++ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+ ;;
+- *)
+- case `$CC -V 2>&1 | sed 5q` in
+- *Sun\ C*)
+- # Sun C++ 5.9
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
++ pgCC* | pgcpp*)
++ # Portland Group C++ compiler
++ case `$CC -V` in
++ *pgCC\ [[1-5]]* | *pgcpp\ [[1-5]]*)
++ _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~
++ rm -rf $tpldir~
++ $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~
++ compile_command="$compile_command `find $tpldir -name \*.o | $NL2SP`"'
++ _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~
++ rm -rf $tpldir~
++ $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~
++ $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | $NL2SP`~
++ $RANLIB $oldlib'
++ _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~
++ rm -rf $tpldir~
++ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
++ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~
++ rm -rf $tpldir~
++ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
++ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
++ ;;
++ *) # Version 6 will use weak symbols
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+ ;;
+ esac
+- ;;
+- esac
+- ;;
+- lynxos*)
+- ;;
+- m88k*)
+- ;;
+- mvs*)
+- case $cc_basename in
+- cxx*)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall'
+- ;;
+- *)
+- ;;
+- esac
+- ;;
+- netbsd*)
+- ;;
+- osf3* | osf4* | osf5*)
+- case $cc_basename in
+- KCC*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
+- ;;
+- RCC*)
+- # Rational C++ 2.4.1
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+- ;;
++
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
++ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
++ ;;
+ cxx*)
+- # Digital/Compaq C++
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- # Make sure the PIC flag is empty. It appears that all Alpha
+- # Linux and Compaq Tru64 Unix objects are PIC.
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+- ;;
+- *)
+- ;;
+- esac
+- ;;
+- psos*)
+- ;;
+- solaris*)
+- case $cc_basename in
+- CC*)
+- # Sun C++ 4.2, 5.x and Centerline C++
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
+- ;;
+- gcx*)
+- # Green Hills C++ Compiler
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
+- ;;
+- *)
+- ;;
+- esac
+- ;;
+- sunos4*)
+- case $cc_basename in
+- CC*)
+- # Sun C++ 4.x
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- ;;
+- lcc*)
+- # Lucid
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+- ;;
+- *)
++ # Compaq C++
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
++
++ runpath_var=LD_RUN_PATH
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
++
++ # Commands to make compiler produce verbose output that lists
++ # what "hidden" libraries, object files and flags are used when
++ # linking a shared library.
++ #
++ # There doesn't appear to be a way to prevent this compiler from
++ # explicitly linking system object files so we need to strip them
++ # from the output so that they don't get included in the library
++ # dependencies.
++ output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
+ ;;
+- esac
+- ;;
+- tandem*)
+- case $cc_basename in
+- NCC*)
+- # NonStop-UX NCC 3.20
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ xl*)
++ # IBM XL 8.0 on PPC, with GNU ld
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
++ _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
++ if test "x$supports_anon_versioning" = xyes; then
++ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
++ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
++ echo "local: *; };" >> $output_objdir/$libname.ver~
++ $CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
++ fi
+ ;;
+ *)
++ case `$CC -V 2>&1 | sed 5q` in
++ *Sun\ C*)
++ # Sun C++ 5.9
++ _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'
++ _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
++ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
++ _LT_TAGVAR(compiler_needs_object, $1)=yes
++
++ # Not sure whether something based on
++ # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1
++ # would be better.
++ output_verbose_link_cmd='echo'
++
++ # Archives containing C++ object files must be created using
++ # "CC -xar", where "CC" is the Sun C++ compiler. This is
++ # necessary to make sure instantiated templates are included
++ # in the archive.
++ _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
++ ;;
++ esac
+ ;;
+ esac
+ ;;
+- sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+- case $cc_basename in
+- CC*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++
++ lynxos*)
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++
++ m88k*)
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++
++ mvs*)
++ case $cc_basename in
++ cxx*)
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++ *)
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ esac
+ ;;
+- vxworks*)
++
++ netbsd*)
++ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
++ _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags'
++ wlarc=
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ fi
++ # Workaround some broken pre-1.5 toolchains
++ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"'
+ ;;
+- *)
+- _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
++
++ *nto* | *qnx*)
++ _LT_TAGVAR(ld_shlibs, $1)=yes
+ ;;
+- esac
+- fi
+-],
+-[
+- if test "$GCC" = yes; then
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
+
+- case $host_os in
+- aix*)
+- # All AIX code is PIC.
+- if test "$host_cpu" = ia64; then
+- # AIX 5 now supports IA64 processor
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- fi
+- ;;
++ openbsd2*)
++ # C++ shared libraries are fairly broken
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++
++ openbsd*)
++ if test -f /usr/libexec/ld.so; then
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
++ if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
++ _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
++ fi
++ output_verbose_link_cmd=echo
++ else
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ fi
++ ;;
+
+- amigaos*)
+- # FIXME: we need at least 68020 code to build shared libraries, but
+- # adding the `-m68020' flag to GCC prevents building anything better,
+- # like `-m68040'.
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
+- ;;
++ osf3* | osf4* | osf5*)
++ case $cc_basename in
++ KCC*)
++ # Kuck and Associates, Inc. (KAI) C++ Compiler
++
++ # KCC will only create a shared library if the output file
++ # ends with ".so" (or ".sl" for HP-UX), so rename the library
++ # to its proper name (with version) after linking.
++ _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
++
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
++
++ # Archives containing C++ object files must be created using
++ # the KAI C++ compiler.
++ case $host in
++ osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;;
++ *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;;
++ esac
++ ;;
++ RCC*)
++ # Rational C++ 2.4.1
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++ cxx*)
++ case $host in
++ osf3*)
++ _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && $ECHO "X${wl}-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
++ ;;
++ *)
++ _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
++ echo "-hidden">> $lib.exp~
++ $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~
++ $RM $lib.exp'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
++ ;;
++ esac
+
+- beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+- # PIC is the default for these OSes.
+- ;;
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+- mingw* | cygwin* | pw32* | os2*)
+- # This hack is so that the source file can tell whether it is being
+- # built for inclusion in a dll (and should export symbols for example).
+- # Although the cygwin gcc ignores -fPIC, still need this for old-style
+- # (--disable-auto-import) libraries
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'
+- ;;
++ # Commands to make compiler produce verbose output that lists
++ # what "hidden" libraries, object files and flags are used when
++ # linking a shared library.
++ #
++ # There doesn't appear to be a way to prevent this compiler from
++ # explicitly linking system object files so we need to strip them
++ # from the output so that they don't get included in the library
++ # dependencies.
++ output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
++ ;;
++ *)
++ if test "$GXX" = yes && test "$with_gnu_ld" = no; then
++ _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
++ case $host in
++ osf3*)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
++ ;;
++ *)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
++ ;;
++ esac
++
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
++
++ # Commands to make compiler produce verbose output that lists
++ # what "hidden" libraries, object files and flags are used when
++ # linking a shared library.
++ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
++
++ else
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ fi
++ ;;
++ esac
++ ;;
+
+- darwin* | rhapsody*)
+- # PIC is the default on this platform
+- # Common symbols not allowed in MH_DYLIB files
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
+- ;;
++ psos*)
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
+
+- interix3*)
+- # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+- # Instead, we relocate shared libraries at runtime.
+- ;;
++ sunos4*)
++ case $cc_basename in
++ CC*)
++ # Sun C++ 4.x
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++ lcc*)
++ # Lucid
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++ *)
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++ esac
++ ;;
+
+- msdosdjgpp*)
+- # Just because we use GCC doesn't mean we suddenly get shared libraries
+- # on systems that don't support them.
+- _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+- enable_shared=no
+- ;;
++ solaris*)
++ case $cc_basename in
++ CC*)
++ # Sun C++ 4.2, 5.x and Centerline C++
++ _LT_TAGVAR(archive_cmds_need_lc,$1)=yes
++ _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'
++ _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
++ $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
++
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ case $host_os in
++ solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
++ *)
++ # The compiler driver will combine and reorder linker options,
++ # but understands `-z linker_flag'.
++ # Supported since Solaris 2.6 (maybe 2.5.1?)
++ _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
++ ;;
++ esac
++ _LT_TAGVAR(link_all_deplibs, $1)=yes
+
+- sysv4*MP*)
+- if test -d /usr/nec; then
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
+- fi
+- ;;
++ output_verbose_link_cmd='echo'
+
+- hpux*)
+- # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+- # not for PA HP-UX.
+- case $host_cpu in
+- hppa*64*|ia64*)
+- # +Z the default
+- ;;
+- *)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+- ;;
+- esac
+- ;;
++ # Archives containing C++ object files must be created using
++ # "CC -xar", where "CC" is the Sun C++ compiler. This is
++ # necessary to make sure instantiated templates are included
++ # in the archive.
++ _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
++ ;;
++ gcx*)
++ # Green Hills C++ Compiler
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+
+- *)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+- ;;
+- esac
+- else
+- # PORTME Check for flag to pass linker flags through the system compiler.
+- case $host_os in
+- aix*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- if test "$host_cpu" = ia64; then
+- # AIX 5 now supports IA64 processor
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- else
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
+- fi
+- ;;
+- darwin*)
+- # PIC is the default on this platform
+- # Common symbols not allowed in MH_DYLIB files
+- case $cc_basename in
+- xlc*)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-qnocommon'
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- ;;
+- esac
+- ;;
++ # The C++ compiler must be used to create the archive.
++ _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
++ ;;
++ *)
++ # GNU C++ compiler with Solaris linker
++ if test "$GXX" = yes && test "$with_gnu_ld" = no; then
++ _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs'
++ if $CC --version | $GREP -v '^2\.7' > /dev/null; then
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
++ $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
++
++ # Commands to make compiler produce verbose output that lists
++ # what "hidden" libraries, object files and flags are used when
++ # linking a shared library.
++ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
++ else
++ # g++ 2.7 appears to require `-G' NOT `-shared' on this
++ # platform.
++ _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
++ $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
++
++ # Commands to make compiler produce verbose output that lists
++ # what "hidden" libraries, object files and flags are used when
++ # linking a shared library.
++ output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
++ fi
++
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir'
++ case $host_os in
++ solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
++ *)
++ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
++ ;;
++ esac
++ fi
++ ;;
++ esac
++ ;;
+
+- mingw* | cygwin* | pw32* | os2*)
+- # This hack is so that the source file can tell whether it is being
+- # built for inclusion in a dll (and should export symbols for example).
+- # Although the cygwin gcc ignores -fPIC, still need this for old-style
+- # (--disable-auto-import) libraries
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'
+- ;;
++ sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
++ _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
++ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ runpath_var='LD_RUN_PATH'
+
+- hpux9* | hpux10* | hpux11*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+- # not for PA HP-UX.
+- case $host_cpu in
+- hppa*64*|ia64*)
+- # +Z the default
+- ;;
+- *)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
+- ;;
++ case $cc_basename in
++ CC*)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ ;;
++ *)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ ;;
+ esac
+- # Is there a better lt_prog_compiler_static that works with the bundled CC?
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+ ;;
+
+- irix5* | irix6* | nonstopux*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- # PIC (with -KPIC) is the default.
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+- ;;
++ sysv5* | sco3.2v5* | sco5v6*)
++ # Note: We can NOT use -z defs as we might desire, because we do not
++ # link with -lc, and that would cause any symbols used from libc to
++ # always be unresolved, which means just about no library would
++ # ever link correctly. If we're not using GNU ld we use -z text
++ # though, which does catch some bad symbols but isn't as heavy-handed
++ # as -z defs.
++ _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
++ _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
++ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
++ _LT_TAGVAR(link_all_deplibs, $1)=yes
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
++ runpath_var='LD_RUN_PATH'
+
+- newsos6)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ case $cc_basename in
++ CC*)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ ;;
++ *)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ ;;
++ esac
+ ;;
+
+- linux*)
+- case $cc_basename in
+- icc* | ecc*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
+- ;;
+- pgcc* | pgf77* | pgf90* | pgf95*)
+- # Portland Group compilers (*not* the Pentium gcc compiler,
+- # which looks to be a dead project)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- ;;
+- ccc*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- # All Alpha code is PIC.
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
++ tandem*)
++ case $cc_basename in
++ NCC*)
++ # NonStop-UX NCC 3.20
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++ *)
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++ esac
+ ;;
+- como)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-lopt='
++
++ vxworks*)
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
++
+ *)
+- case `$CC -V 2>&1 | sed 5q` in
+- *Sun\ C*)
+- # Sun C 5.9
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- ;;
+- *Sun\ F*)
+- # Sun Fortran 8.3 passes all unrecognized flags to the linker
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)=''
+- ;;
+- esac
+- ;;
+- esac
+- ;;
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++ esac
+
+- osf3* | osf4* | osf5*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- # All OSF/1 code is PIC.
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+- ;;
++ AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
++ test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
+
+- solaris*)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- case $cc_basename in
+- f77* | f90* | f95*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';;
+- *)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';;
+- esac
+- ;;
++ _LT_TAGVAR(GCC, $1)="$GXX"
++ _LT_TAGVAR(LD, $1)="$LD"
++
++ ## CAVEAT EMPTOR:
++ ## There is no encapsulation within the following macros, do not change
++ ## the running order or otherwise move them around unless you know exactly
++ ## what you are doing...
++ _LT_SYS_HIDDEN_LIBDEPS($1)
++ _LT_COMPILER_PIC($1)
++ _LT_COMPILER_C_O($1)
++ _LT_COMPILER_FILE_LOCKS($1)
++ _LT_LINKER_SHLIBS($1)
++ _LT_SYS_DYNAMIC_LINKER($1)
++ _LT_LINKER_HARDCODE_LIBPATH($1)
++
++ _LT_CONFIG($1)
++ fi # test -n "$compiler"
++
++ CC=$lt_save_CC
++ LDCXX=$LD
++ LD=$lt_save_LD
++ GCC=$lt_save_GCC
++ with_gnu_ld=$lt_save_with_gnu_ld
++ lt_cv_path_LDCXX=$lt_cv_path_LD
++ lt_cv_path_LD=$lt_save_path_LD
++ lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
++ lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
++fi # test "$_lt_caught_CXX_error" != yes
++
++AC_LANG_POP
++])# _LT_LANG_CXX_CONFIG
++
++
++# _LT_SYS_HIDDEN_LIBDEPS([TAGNAME])
++# ---------------------------------
++# Figure out "hidden" library dependencies from verbose
++# compiler output when linking a shared library.
++# Parse the compiler output and extract the necessary
++# objects, libraries and library flags.
++m4_defun([_LT_SYS_HIDDEN_LIBDEPS],
++[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
++# Dependencies to place before and after the object being linked:
++_LT_TAGVAR(predep_objects, $1)=
++_LT_TAGVAR(postdep_objects, $1)=
++_LT_TAGVAR(predeps, $1)=
++_LT_TAGVAR(postdeps, $1)=
++_LT_TAGVAR(compiler_lib_search_path, $1)=
++
++dnl we can't use the lt_simple_compile_test_code here,
++dnl because it contains code intended for an executable,
++dnl not a library. It's possible we should let each
++dnl tag define a new lt_????_link_test_code variable,
++dnl but it's only used here...
++m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF
++int a;
++void foo (void) { a = 0; }
++_LT_EOF
++], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF
++class Foo
++{
++public:
++ Foo (void) { a = 0; }
++private:
++ int a;
++};
++_LT_EOF
++], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF
++ subroutine foo
++ implicit none
++ integer*4 a
++ a=0
++ return
++ end
++_LT_EOF
++], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF
++ subroutine foo
++ implicit none
++ integer a
++ a=0
++ return
++ end
++_LT_EOF
++], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF
++public class foo {
++ private int a;
++ public void bar (void) {
++ a = 0;
++ }
++};
++_LT_EOF
++])
++dnl Parse the compiler output and extract the necessary
++dnl objects, libraries and library flags.
++if AC_TRY_EVAL(ac_compile); then
++ # Parse the compiler output and extract the necessary
++ # objects, libraries and library flags.
++
++ # Sentinel used to keep track of whether or not we are before
++ # the conftest object file.
++ pre_test_object_deps_done=no
+
+- sunos4*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- ;;
++ for p in `eval "$output_verbose_link_cmd"`; do
++ case $p in
+
+- sysv4 | sysv4.2uw2* | sysv4.3*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- ;;
++ -L* | -R* | -l*)
++ # Some compilers place space between "-{L,R}" and the path.
++ # Remove the space.
++ if test $p = "-L" ||
++ test $p = "-R"; then
++ prev=$p
++ continue
++ else
++ prev=
++ fi
+
+- sysv4*MP*)
+- if test -d /usr/nec ;then
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- fi
+- ;;
++ if test "$pre_test_object_deps_done" = no; then
++ case $p in
++ -L* | -R*)
++ # Internal compiler library paths should come after those
++ # provided the user. The postdeps already come after the
++ # user supplied libs so there is no need to process them.
++ if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then
++ _LT_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}"
++ else
++ _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}"
++ fi
++ ;;
++ # The "-l" case would never come before the object being
++ # linked, so don't bother handling this case.
++ esac
++ else
++ if test -z "$_LT_TAGVAR(postdeps, $1)"; then
++ _LT_TAGVAR(postdeps, $1)="${prev}${p}"
++ else
++ _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}"
++ fi
++ fi
++ ;;
+
+- sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- ;;
++ *.$objext)
++ # This assumes that the test object file only shows up
++ # once in the compiler output.
++ if test "$p" = "conftest.$objext"; then
++ pre_test_object_deps_done=yes
++ continue
++ fi
+
+- unicos*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+- ;;
++ if test "$pre_test_object_deps_done" = no; then
++ if test -z "$_LT_TAGVAR(predep_objects, $1)"; then
++ _LT_TAGVAR(predep_objects, $1)="$p"
++ else
++ _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p"
++ fi
++ else
++ if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then
++ _LT_TAGVAR(postdep_objects, $1)="$p"
++ else
++ _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p"
++ fi
++ fi
++ ;;
+
+- uts4*)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- ;;
++ *) ;; # Ignore the rest.
+
+- *)
+- _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+- ;;
+ esac
+- fi
+-])
+-AC_MSG_RESULT([$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)])
++ done
+
+-#
+-# Check to make sure the PIC flag actually works.
+-#
+-if test -n "$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)"; then
+- AC_LIBTOOL_COMPILER_OPTION([if $compiler PIC flag $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) works],
+- _LT_AC_TAGVAR(lt_prog_compiler_pic_works, $1),
+- [$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)ifelse([$1],[],[ -DPIC],[ifelse([$1],[CXX],[ -DPIC],[])])], [],
+- [case $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) in
+- "" | " "*) ;;
+- *) _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)" ;;
+- esac],
+- [_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
+- _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no])
++ # Clean up.
++ rm -f a.out a.exe
++else
++ echo "libtool.m4: error: problem compiling $1 test program"
+ fi
+-case $host_os in
+- # For platforms which do not support PIC, -DPIC is meaningless:
+- *djgpp*)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
+- ;;
+- *)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)ifelse([$1],[],[ -DPIC],[ifelse([$1],[CXX],[ -DPIC],[])])"
+- ;;
+-esac
+-
+-#
+-# Check to make sure the static flag actually works.
+-#
+-wl=$_LT_AC_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_AC_TAGVAR(lt_prog_compiler_static, $1)\"
+-AC_LIBTOOL_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works],
+- _LT_AC_TAGVAR(lt_prog_compiler_static_works, $1),
+- $lt_tmp_static_flag,
+- [],
+- [_LT_AC_TAGVAR(lt_prog_compiler_static, $1)=])
+-])
+
++$RM -f confest.$objext
+
+-# AC_LIBTOOL_PROG_LD_SHLIBS([TAGNAME])
+-# ------------------------------------
+-# See if the linker supports building shared libraries.
+-AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS],
+-[AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
+-ifelse([$1],[CXX],[
+- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+- case $host_os in
+- aix4* | aix5*)
+- # If we're using GNU nm, then we don't want the "-C" option.
+- # -C means demangle to AIX nm, but means don't demangle with GNU nm
+- if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
+- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols'
+- else
+- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols'
+- fi
+- ;;
+- pw32*)
+- _LT_AC_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds"
+- ;;
+- cygwin* | mingw*)
+- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]] /s/.* \([[^ ]]*\)/\1 DATA/;/^.* __nm__/s/^.* __nm__\([[^ ]]*\) [[^ ]]*/\1 DATA/;/^I /d;/^[[AITW]] /s/.* //'\'' | sort | uniq > $export_symbols'
+- ;;
+- *)
+- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
++# PORTME: override above test on systems where it is broken
++m4_if([$1], [CXX],
++[case $host_os in
++interix[[3-9]]*)
++ # Interix 3.5 installs completely hosed .la files for C++, so rather than
++ # hack all around it, let's just trust "g++" to DTRT.
++ _LT_TAGVAR(predep_objects,$1)=
++ _LT_TAGVAR(postdep_objects,$1)=
++ _LT_TAGVAR(postdeps,$1)=
+ ;;
+- esac
+-],[
+- runpath_var=
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=
+- _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+- _LT_AC_TAGVAR(archive_cmds, $1)=
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)=
+- _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)=
+- _LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1)=
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+- _LT_AC_TAGVAR(thread_safe_flag_spec, $1)=
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
+- _LT_AC_TAGVAR(hardcode_direct, $1)=no
+- _LT_AC_TAGVAR(hardcode_minus_L, $1)=no
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+- _LT_AC_TAGVAR(link_all_deplibs, $1)=unknown
+- _LT_AC_TAGVAR(hardcode_automatic, $1)=no
+- _LT_AC_TAGVAR(module_cmds, $1)=
+- _LT_AC_TAGVAR(module_expsym_cmds, $1)=
+- _LT_AC_TAGVAR(always_export_symbols, $1)=no
+- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+- # include_expsyms should be a list of space-separated symbols to be *always*
+- # included in the symbol list
+- _LT_AC_TAGVAR(include_expsyms, $1)=
+- # exclude_expsyms can be an extended regexp of symbols to exclude
+- # it will be wrapped by ` (' and `)$', so one must not match beginning or
+- # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
+- # as well as any symbol that contains `d'.
+- _LT_AC_TAGVAR(exclude_expsyms, $1)="_GLOBAL_OFFSET_TABLE_"
+- # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
+- # platforms (ab)use it in PIC code, but their linkers get confused if
+- # the symbol is explicitly referenced. Since portable code cannot
+- # rely on this symbol name, it's probably fine to never include it in
+- # preloaded symbol tables.
+- extract_expsyms_cmds=
+- # Just being paranoid about ensuring that cc_basename is set.
+- _LT_CC_BASENAME([$compiler])
+- case $host_os in
+- cygwin* | mingw* | pw32*)
+- # FIXME: the MSVC++ port hasn't been tested in a loooong time
+- # When not using gcc, we currently assume that we are using
+- # Microsoft Visual C++.
+- if test "$GCC" != yes; then
+- with_gnu_ld=no
+- fi
+- ;;
+- interix*)
+- # we just hope/assume this is gcc and not c89 (= MSVC++)
+- with_gnu_ld=yes
+- ;;
+- openbsd*)
+- with_gnu_ld=no
+- ;;
+- esac
+-
+- _LT_AC_TAGVAR(ld_shlibs, $1)=yes
+- if test "$with_gnu_ld" = yes; then
+- # If archive_cmds runs LD, not CC, wlarc should be empty
+- wlarc='${wl}'
+-
+- # Set some defaults for GNU ld with shared library support. These
+- # are reset later if shared libraries are not supported. Putting them
+- # here allows them to be overridden if necessary.
+- runpath_var=LD_RUN_PATH
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+- # ancient GNU ld didn't support --whole-archive et. al.
+- if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+- else
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+- fi
+- supports_anon_versioning=no
+- case `$LD -v 2>/dev/null` in
+- *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11
+- *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
+- *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
+- *\ 2.11.*) ;; # other 2.11 versions
+- *) supports_anon_versioning=yes ;;
+- esac
+-
+- # See if GNU ld supports shared libraries.
+- case $host_os in
+- aix3* | aix4* | aix5*)
+- # On AIX/PPC, the GNU linker is very broken
+- if test "$host_cpu" != ia64; then
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- cat <<EOF 1>&2
+-
+-*** Warning: the GNU linker, at least up to release 2.9.1, is reported
+-*** to be unable to reliably create shared libraries on AIX.
+-*** Therefore, libtool is disabling shared libraries support. If you
+-*** really care for shared libraries, you may want to modify your PATH
+-*** so that a non-GNU linker is found, and then restart.
+-
+-EOF
+- fi
+- ;;
+
+- amigaos*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+-
+- # Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports
+- # that the semantics of dynamic libraries on AmigaOS, at least up
+- # to version 4, is to share data among multiple programs linked
+- # with the same dynamic library. Since this doesn't match the
+- # behavior of shared libraries on other platforms, we can't use
+- # them.
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
++linux*)
++ case `$CC -V 2>&1 | sed 5q` in
++ *Sun\ C*)
++ # Sun C++ 5.9
+
+- beos*)
+- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+- # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
+- # support --undefined. This deserves some investigation. FIXME
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+- else
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- fi
++ # The more standards-conforming stlport4 library is
++ # incompatible with the Cstd library. Avoid specifying
++ # it if it's in CXXFLAGS. Ignore libCrun as
++ # -library=stlport4 depends on it.
++ case " $CXX $CXXFLAGS " in
++ *" -library=stlport4 "*)
++ solaris_use_stlport4=yes
+ ;;
++ esac
+
+- cygwin* | mingw* | pw32*)
+- # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
+- # as there is no search path for DLLs.
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+- _LT_AC_TAGVAR(always_export_symbols, $1)=no
+- _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]] /s/.* \([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]] /s/.* //'\'' | sort | uniq > $export_symbols'
+-
+- if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+- # If the export-symbols file already is a .def file (1st line
+- # is EXPORTS), use it as is; otherwise, prepend...
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+- cp $export_symbols $output_objdir/$soname.def;
+- else
+- echo EXPORTS > $output_objdir/$soname.def;
+- cat $export_symbols >> $output_objdir/$soname.def;
+- fi~
+- $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+- else
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- fi
+- ;;
++ if test "$solaris_use_stlport4" != yes; then
++ _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
++ fi
++ ;;
++ esac
++ ;;
+
+- interix3*)
+- _LT_AC_TAGVAR(hardcode_direct, $1)=no
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+- # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+- # Instead, shared libraries are loaded at an image base (0x10000000 by
+- # default) and relocated if they conflict, which is a slow very memory
+- # consuming and fragmenting process. To avoid this, we pick a random,
+- # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+- # time. Moving up from 0x10000000 also allows more sbrk(2) space.
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
++solaris*)
++ case $cc_basename in
++ CC*)
++ # The more standards-conforming stlport4 library is
++ # incompatible with the Cstd library. Avoid specifying
++ # it if it's in CXXFLAGS. Ignore libCrun as
++ # -library=stlport4 depends on it.
++ case " $CXX $CXXFLAGS " in
++ *" -library=stlport4 "*)
++ solaris_use_stlport4=yes
+ ;;
++ esac
+
+- linux*)
+- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+- tmp_addflag=
+- case $cc_basename,$host_cpu in
+- pgcc*) # Portland Group C compiler
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+- tmp_addflag=' $pic_flag'
+- ;;
+- pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+- tmp_addflag=' $pic_flag -Mnomain' ;;
+- ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64
+- tmp_addflag=' -i_dynamic' ;;
+- efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64
+- tmp_addflag=' -i_dynamic -nofor_main' ;;
+- ifc* | ifort*) # Intel Fortran compiler
+- tmp_addflag=' -nofor_main' ;;
+- esac
+- case `$CC -V 2>&1 | sed 5q` in
+- *Sun\ C*) # Sun C 5.9
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive /dev/null'
+- tmp_sharedflag='-G' ;;
+- *Sun\ F*) # Sun Fortran 8.3
+- tmp_sharedflag='-G' ;;
+- *)
+- tmp_sharedflag='-shared' ;;
+- esac
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
++ # Adding this requires a known-good setup of shared libraries for
++ # Sun compiler versions before 5.6, else PIC objects from an old
++ # archive will be linked into the output, leading to subtle bugs.
++ if test "$solaris_use_stlport4" != yes; then
++ _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
++ fi
++ ;;
++ esac
++ ;;
++esac
++])
+
+- if test $supports_anon_versioning = yes; then
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $output_objdir/$libname.ver~
+- cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+- $echo "local: *; };" >> $output_objdir/$libname.ver~
+- $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+- fi
+- else
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- fi
+- ;;
++case " $_LT_TAGVAR(postdeps, $1) " in
++*" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;;
++esac
++ _LT_TAGVAR(compiler_lib_search_dirs, $1)=
++if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then
++ _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'`
++fi
++_LT_TAGDECL([], [compiler_lib_search_dirs], [1],
++ [The directories searched by this compiler when creating a shared library])
++_LT_TAGDECL([], [predep_objects], [1],
++ [Dependencies to place before and after the objects being linked to
++ create a shared library])
++_LT_TAGDECL([], [postdep_objects], [1])
++_LT_TAGDECL([], [predeps], [1])
++_LT_TAGDECL([], [postdeps], [1])
++_LT_TAGDECL([], [compiler_lib_search_path], [1],
++ [The library search path used internally by the compiler when linking
++ a shared library])
++])# _LT_SYS_HIDDEN_LIBDEPS
++
++
++# _LT_PROG_F77
++# ------------
++# Since AC_PROG_F77 is broken, in that it returns the empty string
++# if there is no fortran compiler, we have our own version here.
++m4_defun([_LT_PROG_F77],
++[
++pushdef([AC_MSG_ERROR], [_lt_disable_F77=yes])
++AC_PROG_F77
++if test -z "$F77" || test "X$F77" = "Xno"; then
++ _lt_disable_F77=yes
++fi
++popdef([AC_MSG_ERROR])
++])# _LT_PROG_F77
+
+- netbsd*)
+- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
+- wlarc=
+- else
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+- fi
+- ;;
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([_LT_PROG_F77], [])
+
+- solaris*)
+- if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- cat <<EOF 1>&2
+
+-*** Warning: The releases 2.8.* of the GNU linker cannot reliably
+-*** create shared libraries on Solaris systems. Therefore, libtool
+-*** is disabling shared libraries support. We urge you to upgrade GNU
+-*** binutils to release 2.9.1 or newer. Another option is to modify
+-*** your PATH or compiler configuration so that the native linker is
+-*** used, and then restart.
++# _LT_LANG_F77_CONFIG([TAG])
++# --------------------------
++# Ensure that the configuration variables for a Fortran 77 compiler are
++# suitably defined. These variables are subsequently used by _LT_CONFIG
++# to write the compiler configuration to `libtool'.
++m4_defun([_LT_LANG_F77_CONFIG],
++[AC_REQUIRE([_LT_PROG_F77])dnl
++AC_LANG_PUSH(Fortran 77)
+
+-EOF
+- elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+- else
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- fi
+- ;;
++_LT_TAGVAR(archive_cmds_need_lc, $1)=no
++_LT_TAGVAR(allow_undefined_flag, $1)=
++_LT_TAGVAR(always_export_symbols, $1)=no
++_LT_TAGVAR(archive_expsym_cmds, $1)=
++_LT_TAGVAR(export_dynamic_flag_spec, $1)=
++_LT_TAGVAR(hardcode_direct, $1)=no
++_LT_TAGVAR(hardcode_direct_absolute, $1)=no
++_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
++_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
++_LT_TAGVAR(hardcode_libdir_separator, $1)=
++_LT_TAGVAR(hardcode_minus_L, $1)=no
++_LT_TAGVAR(hardcode_automatic, $1)=no
++_LT_TAGVAR(inherit_rpath, $1)=no
++_LT_TAGVAR(module_cmds, $1)=
++_LT_TAGVAR(module_expsym_cmds, $1)=
++_LT_TAGVAR(link_all_deplibs, $1)=unknown
++_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
++_LT_TAGVAR(no_undefined_flag, $1)=
++_LT_TAGVAR(whole_archive_flag_spec, $1)=
++_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+
+- sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
+- case `$LD -v 2>&1` in
+- *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*)
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- cat <<_LT_EOF 1>&2
++# Source file extension for f77 test sources.
++ac_ext=f
+
+-*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
+-*** reliably create shared libraries on SCO systems. Therefore, libtool
+-*** is disabling shared libraries support. We urge you to upgrade GNU
+-*** binutils to release 2.16.91.0.3 or newer. Another option is to modify
+-*** your PATH or compiler configuration so that the native linker is
+-*** used, and then restart.
++# Object file extension for compiled f77 test sources.
++objext=o
++_LT_TAGVAR(objext, $1)=$objext
+
+-_LT_EOF
+- ;;
+- *)
+- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname,-retain-symbols-file,$export_symbols -o $lib'
+- else
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- fi
+- ;;
+- esac
+- ;;
++# No sense in running all these tests if we already determined that
++# the F77 compiler isn't working. Some variables (like enable_shared)
++# are currently assumed to apply to all compilers on this platform,
++# and will be corrupted by setting them based on a non-working compiler.
++if test "$_lt_disable_F77" != yes; then
++ # Code to be used in simple compile tests
++ lt_simple_compile_test_code="\
++ subroutine t
++ return
++ end
++"
+
+- sunos4*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+- wlarc=
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- ;;
++ # Code to be used in simple link tests
++ lt_simple_link_test_code="\
++ program t
++ end
++"
+
+- *)
+- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+- else
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- fi
+- ;;
+- esac
++ # ltmain only uses $CC for tagged configurations so make sure $CC is set.
++ _LT_TAG_COMPILER
+
+- if test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no; then
+- runpath_var=
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+- fi
+- else
+- # PORTME fill in a description of your system's linker (not GNU ld)
+- case $host_os in
+- aix3*)
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+- _LT_AC_TAGVAR(always_export_symbols, $1)=yes
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
+- # Note: this linker hardcodes the directories in LIBPATH if there
+- # are no directories specified by -L.
+- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+- if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
+- # Neither direct hardcoding nor static linking is supported with a
+- # broken collect2.
+- _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported
+- fi
+- ;;
++ # save warnings/boilerplate of simple test code
++ _LT_COMPILER_BOILERPLATE
++ _LT_LINKER_BOILERPLATE
++
++ # Allow CC to be a program name with arguments.
++ lt_save_CC="$CC"
++ lt_save_GCC=$GCC
++ CC=${F77-"f77"}
++ compiler=$CC
++ _LT_TAGVAR(compiler, $1)=$CC
++ _LT_CC_BASENAME([$compiler])
++ GCC=$G77
++ if test -n "$compiler"; then
++ AC_MSG_CHECKING([if libtool supports shared libraries])
++ AC_MSG_RESULT([$can_build_shared])
+
+- aix4* | aix5*)
+- if test "$host_cpu" = ia64; then
+- # On IA64, the linker does run time linking by default, so we don't
+- # have to do anything special.
+- aix_use_runtimelinking=no
+- exp_sym_flag='-Bexport'
+- no_entry_flag=""
+- else
+- # If we're using GNU nm, then we don't want the "-C" option.
+- # -C means demangle to AIX nm, but means don't demangle with GNU nm
+- if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
+- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols'
+- else
+- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols'
++ AC_MSG_CHECKING([whether to build shared libraries])
++ test "$can_build_shared" = "no" && enable_shared=no
++
++ # On AIX, shared libraries and static libraries use the same namespace, and
++ # are all built from PIC.
++ case $host_os in
++ aix3*)
++ test "$enable_shared" = yes && enable_static=no
++ if test -n "$RANLIB"; then
++ archive_cmds="$archive_cmds~\$RANLIB \$lib"
++ postinstall_cmds='$RANLIB $lib'
++ fi
++ ;;
++ aix[[4-9]]*)
++ if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
++ test "$enable_shared" = yes && enable_static=no
+ fi
+- aix_use_runtimelinking=no
++ ;;
++ esac
++ AC_MSG_RESULT([$enable_shared])
+
+- # Test if we are trying to use run time linking or normal
+- # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+- # need to do runtime linking.
+- case $host_os in aix4.[[23]]|aix4.[[23]].*|aix5*)
+- for ld_flag in $LDFLAGS; do
+- if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+- aix_use_runtimelinking=yes
+- break
+- fi
+- done
+- ;;
+- esac
++ AC_MSG_CHECKING([whether to build static libraries])
++ # Make sure either enable_shared or enable_static is yes.
++ test "$enable_shared" = yes || enable_static=yes
++ AC_MSG_RESULT([$enable_static])
++
++ _LT_TAGVAR(GCC, $1)="$G77"
++ _LT_TAGVAR(LD, $1)="$LD"
++
++ ## CAVEAT EMPTOR:
++ ## There is no encapsulation within the following macros, do not change
++ ## the running order or otherwise move them around unless you know exactly
++ ## what you are doing...
++ _LT_COMPILER_PIC($1)
++ _LT_COMPILER_C_O($1)
++ _LT_COMPILER_FILE_LOCKS($1)
++ _LT_LINKER_SHLIBS($1)
++ _LT_SYS_DYNAMIC_LINKER($1)
++ _LT_LINKER_HARDCODE_LIBPATH($1)
++
++ _LT_CONFIG($1)
++ fi # test -n "$compiler"
++
++ GCC=$lt_save_GCC
++ CC="$lt_save_CC"
++fi # test "$_lt_disable_F77" != yes
+
+- exp_sym_flag='-bexport'
+- no_entry_flag='-bnoentry'
+- fi
++AC_LANG_POP
++])# _LT_LANG_F77_CONFIG
+
+- # When large executables or shared objects are built, AIX ld can
+- # have problems creating the table of contents. If linking a library
+- # or program results in "error TOC overflow" add -mminimal-toc to
+- # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
+- # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+- _LT_AC_TAGVAR(archive_cmds, $1)=''
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':'
+- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
++# _LT_PROG_FC
++# -----------
++# Since AC_PROG_FC is broken, in that it returns the empty string
++# if there is no fortran compiler, we have our own version here.
++m4_defun([_LT_PROG_FC],
++[
++pushdef([AC_MSG_ERROR], [_lt_disable_FC=yes])
++AC_PROG_FC
++if test -z "$FC" || test "X$FC" = "Xno"; then
++ _lt_disable_FC=yes
++fi
++popdef([AC_MSG_ERROR])
++])# _LT_PROG_FC
+
+- if test "$GCC" = yes; then
+- case $host_os in aix4.[[012]]|aix4.[[012]].*)
+- # We only want to do this on AIX 4.2 and lower, the check
+- # below for broken collect2 doesn't work under 4.3+
+- collect2name=`${CC} -print-prog-name=collect2`
+- if test -f "$collect2name" && \
+- strings "$collect2name" | grep resolve_lib_name >/dev/null
+- then
+- # We have reworked collect2
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- else
+- # We have old collect2
+- _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported
+- # It fails to find uninstalled libraries when the uninstalled
+- # path is not listed in the libpath. Setting hardcode_minus_L
+- # to unsupported forces relinking
+- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
+- fi
+- ;;
+- esac
+- shared_flag='-shared'
+- if test "$aix_use_runtimelinking" = yes; then
+- shared_flag="$shared_flag "'${wl}-G'
+- fi
+- else
+- # not using gcc
+- if test "$host_cpu" = ia64; then
+- # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+- # chokes on -Wl,-G. The following line is correct:
+- shared_flag='-G'
+- else
+- if test "$aix_use_runtimelinking" = yes; then
+- shared_flag='${wl}-G'
+- else
+- shared_flag='${wl}-bM:SRE'
+- fi
+- fi
+- fi
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([_LT_PROG_FC], [])
+
+- # It seems that -bexpall does not export symbols beginning with
+- # underscore (_), so it is better to generate a list of symbols to export.
+- _LT_AC_TAGVAR(always_export_symbols, $1)=yes
+- if test "$aix_use_runtimelinking" = yes; then
+- # Warning - without using the other runtime loading flags (-brtl),
+- # -berok will link without error, but may produce a broken library.
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)='-berok'
+- # Determine the default libpath from the value encoded in an empty executable.
+- _LT_AC_SYS_LIBPATH_AIX
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+- else
+- if test "$host_cpu" = ia64; then
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+- else
+- # Determine the default libpath from the value encoded in an empty executable.
+- _LT_AC_SYS_LIBPATH_AIX
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+- # Warning - without using the other run time loading flags,
+- # -berok will link without error, but may produce a broken library.
+- _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
+- # Exported symbols can be pulled into shared objects from archives
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
+- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
+- # This is similar to how AIX traditionally builds its shared libraries.
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+- fi
+- fi
+- ;;
+
+- amigaos*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+- # see comment about different semantics on the GNU ld section
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
++# _LT_LANG_FC_CONFIG([TAG])
++# -------------------------
++# Ensure that the configuration variables for a Fortran compiler are
++# suitably defined. These variables are subsequently used by _LT_CONFIG
++# to write the compiler configuration to `libtool'.
++m4_defun([_LT_LANG_FC_CONFIG],
++[AC_REQUIRE([_LT_PROG_FC])dnl
++AC_LANG_PUSH(Fortran)
++
++_LT_TAGVAR(archive_cmds_need_lc, $1)=no
++_LT_TAGVAR(allow_undefined_flag, $1)=
++_LT_TAGVAR(always_export_symbols, $1)=no
++_LT_TAGVAR(archive_expsym_cmds, $1)=
++_LT_TAGVAR(export_dynamic_flag_spec, $1)=
++_LT_TAGVAR(hardcode_direct, $1)=no
++_LT_TAGVAR(hardcode_direct_absolute, $1)=no
++_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
++_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
++_LT_TAGVAR(hardcode_libdir_separator, $1)=
++_LT_TAGVAR(hardcode_minus_L, $1)=no
++_LT_TAGVAR(hardcode_automatic, $1)=no
++_LT_TAGVAR(inherit_rpath, $1)=no
++_LT_TAGVAR(module_cmds, $1)=
++_LT_TAGVAR(module_expsym_cmds, $1)=
++_LT_TAGVAR(link_all_deplibs, $1)=unknown
++_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
++_LT_TAGVAR(no_undefined_flag, $1)=
++_LT_TAGVAR(whole_archive_flag_spec, $1)=
++_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+
+- bsdi[[45]]*)
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic
+- ;;
++# Source file extension for fc test sources.
++ac_ext=${ac_fc_srcext-f}
+
+- cygwin* | mingw* | pw32*)
+- # When not using gcc, we currently assume that we are using
+- # Microsoft Visual C++.
+- # hardcode_libdir_flag_spec is actually meaningless, as there is
+- # no search path for DLLs.
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=' '
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+- # Tell ltmain to make .lib files, not .a files.
+- libext=lib
+- # Tell ltmain to make .dll files, not .so files.
+- shrext_cmds=".dll"
+- # FIXME: Setting linknames here is a bad hack.
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames='
+- # The linker will automatically build a .lib file if we build a DLL.
+- _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)='true'
+- # FIXME: Should let the user specify the lib program.
+- _LT_AC_TAGVAR(old_archive_cmds, $1)='lib /OUT:$oldlib$oldobjs$old_deplibs'
+- _LT_AC_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`'
+- _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+- ;;
++# Object file extension for compiled fc test sources.
++objext=o
++_LT_TAGVAR(objext, $1)=$objext
+
+- darwin* | rhapsody*)
+- case $host_os in
+- rhapsody* | darwin1.[[012]])
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}suppress'
+- ;;
+- *) # Darwin 1.3 on
+- if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+- else
+- case ${MACOSX_DEPLOYMENT_TARGET} in
+- 10.[[012]])
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+- ;;
+- 10.*)
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}dynamic_lookup'
+- ;;
+- esac
+- fi
+- ;;
+- esac
+- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+- _LT_AC_TAGVAR(hardcode_direct, $1)=no
+- _LT_AC_TAGVAR(hardcode_automatic, $1)=yes
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=''
+- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+- if test "$GCC" = yes ; then
+- output_verbose_link_cmd='echo'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+- _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+- # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+- _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+- else
+- case $cc_basename in
+- xlc*)
+- output_verbose_link_cmd='echo'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
+- _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+- # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+- _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+- ;;
+- *)
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- esac
+- fi
+- ;;
++# No sense in running all these tests if we already determined that
++# the FC compiler isn't working. Some variables (like enable_shared)
++# are currently assumed to apply to all compilers on this platform,
++# and will be corrupted by setting them based on a non-working compiler.
++if test "$_lt_disable_FC" != yes; then
++ # Code to be used in simple compile tests
++ lt_simple_compile_test_code="\
++ subroutine t
++ return
++ end
++"
+
+- dgux*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- ;;
++ # Code to be used in simple link tests
++ lt_simple_link_test_code="\
++ program t
++ end
++"
+
+- freebsd1*)
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
++ # ltmain only uses $CC for tagged configurations so make sure $CC is set.
++ _LT_TAG_COMPILER
+
+- # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
+- # support. Future versions do this automatically, but an explicit c++rt0.o
+- # does not break anything, and helps significantly (at the cost of a little
+- # extra space).
+- freebsd2.2*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- ;;
++ # save warnings/boilerplate of simple test code
++ _LT_COMPILER_BOILERPLATE
++ _LT_LINKER_BOILERPLATE
++
++ # Allow CC to be a program name with arguments.
++ lt_save_CC="$CC"
++ lt_save_GCC=$GCC
++ CC=${FC-"f95"}
++ compiler=$CC
++ GCC=$ac_cv_fc_compiler_gnu
+
+- # Unfortunately, older versions of FreeBSD 2 do not have this feature.
+- freebsd2*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- ;;
++ _LT_TAGVAR(compiler, $1)=$CC
++ _LT_CC_BASENAME([$compiler])
+
+- # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
+- freebsd* | kfreebsd*-gnu | dragonfly*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- ;;
++ if test -n "$compiler"; then
++ AC_MSG_CHECKING([if libtool supports shared libraries])
++ AC_MSG_RESULT([$can_build_shared])
+
+- hpux9*)
+- if test "$GCC" = yes; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+- else
+- _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+- fi
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
++ AC_MSG_CHECKING([whether to build shared libraries])
++ test "$can_build_shared" = "no" && enable_shared=no
+
+- # hardcode_minus_L: Not really in the search PATH,
+- # but as the default location of the library.
+- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+- ;;
++ # On AIX, shared libraries and static libraries use the same namespace, and
++ # are all built from PIC.
++ case $host_os in
++ aix3*)
++ test "$enable_shared" = yes && enable_static=no
++ if test -n "$RANLIB"; then
++ archive_cmds="$archive_cmds~\$RANLIB \$lib"
++ postinstall_cmds='$RANLIB $lib'
++ fi
++ ;;
++ aix[[4-9]]*)
++ if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
++ test "$enable_shared" = yes && enable_static=no
++ fi
++ ;;
++ esac
++ AC_MSG_RESULT([$enable_shared])
+
+- hpux10*)
+- if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+- else
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
+- fi
+- if test "$with_gnu_ld" = no; then
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
++ AC_MSG_CHECKING([whether to build static libraries])
++ # Make sure either enable_shared or enable_static is yes.
++ test "$enable_shared" = yes || enable_static=yes
++ AC_MSG_RESULT([$enable_static])
++
++ _LT_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu"
++ _LT_TAGVAR(LD, $1)="$LD"
++
++ ## CAVEAT EMPTOR:
++ ## There is no encapsulation within the following macros, do not change
++ ## the running order or otherwise move them around unless you know exactly
++ ## what you are doing...
++ _LT_SYS_HIDDEN_LIBDEPS($1)
++ _LT_COMPILER_PIC($1)
++ _LT_COMPILER_C_O($1)
++ _LT_COMPILER_FILE_LOCKS($1)
++ _LT_LINKER_SHLIBS($1)
++ _LT_SYS_DYNAMIC_LINKER($1)
++ _LT_LINKER_HARDCODE_LIBPATH($1)
++
++ _LT_CONFIG($1)
++ fi # test -n "$compiler"
++
++ GCC=$lt_save_GCC
++ CC="$lt_save_CC"
++fi # test "$_lt_disable_FC" != yes
+
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
++AC_LANG_POP
++])# _LT_LANG_FC_CONFIG
+
+- # hardcode_minus_L: Not really in the search PATH,
+- # but as the default location of the library.
+- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+- fi
+- ;;
+
+- hpux11*)
+- if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+- case $host_cpu in
+- hppa*64*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+- ;;
+- ia64*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+- ;;
+- *)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+- ;;
+- esac
+- else
+- case $host_cpu in
+- hppa*64*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+- ;;
+- ia64*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+- ;;
+- *)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+- ;;
+- esac
+- fi
+- if test "$with_gnu_ld" = no; then
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
++# _LT_LANG_GCJ_CONFIG([TAG])
++# --------------------------
++# Ensure that the configuration variables for the GNU Java Compiler compiler
++# are suitably defined. These variables are subsequently used by _LT_CONFIG
++# to write the compiler configuration to `libtool'.
++m4_defun([_LT_LANG_GCJ_CONFIG],
++[AC_REQUIRE([LT_PROG_GCJ])dnl
++AC_LANG_SAVE
+
+- case $host_cpu in
+- hppa*64*|ia64*)
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir'
+- _LT_AC_TAGVAR(hardcode_direct, $1)=no
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- ;;
+- *)
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
++# Source file extension for Java test sources.
++ac_ext=java
+
+- # hardcode_minus_L: Not really in the search PATH,
+- # but as the default location of the library.
+- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+- ;;
+- esac
+- fi
+- ;;
++# Object file extension for compiled Java test sources.
++objext=o
++_LT_TAGVAR(objext, $1)=$objext
+
+- irix5* | irix6* | nonstopux*)
+- if test "$GCC" = yes; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+- else
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir'
+- fi
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+- ;;
++# Code to be used in simple compile tests
++lt_simple_compile_test_code="class foo {}"
+
+- netbsd*)
+- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out
+- else
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF
+- fi
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- ;;
++# Code to be used in simple link tests
++lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }'
+
+- newsos6)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- ;;
++# ltmain only uses $CC for tagged configurations so make sure $CC is set.
++_LT_TAG_COMPILER
++
++# save warnings/boilerplate of simple test code
++_LT_COMPILER_BOILERPLATE
++_LT_LINKER_BOILERPLATE
++
++# Allow CC to be a program name with arguments.
++lt_save_CC="$CC"
++lt_save_GCC=$GCC
++GCC=yes
++CC=${GCJ-"gcj"}
++compiler=$CC
++_LT_TAGVAR(compiler, $1)=$CC
++_LT_TAGVAR(LD, $1)="$LD"
++_LT_CC_BASENAME([$compiler])
+
+- openbsd*)
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+- else
+- case $host_os in
+- openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+- ;;
+- *)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+- ;;
+- esac
+- fi
+- ;;
++# GCJ did not exist at the time GCC didn't implicitly link libc in.
++_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+
+- os2*)
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+- _LT_AC_TAGVAR(archive_cmds, $1)='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
+- _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
+- ;;
++_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+
+- osf3*)
+- if test "$GCC" = yes; then
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+- else
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+- fi
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+- ;;
++## CAVEAT EMPTOR:
++## There is no encapsulation within the following macros, do not change
++## the running order or otherwise move them around unless you know exactly
++## what you are doing...
++if test -n "$compiler"; then
++ _LT_COMPILER_NO_RTTI($1)
++ _LT_COMPILER_PIC($1)
++ _LT_COMPILER_C_O($1)
++ _LT_COMPILER_FILE_LOCKS($1)
++ _LT_LINKER_SHLIBS($1)
++ _LT_LINKER_HARDCODE_LIBPATH($1)
+
+- osf4* | osf5*) # as osf3* with the addition of -msym flag
+- if test "$GCC" = yes; then
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+- else
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~
+- $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp'
++ _LT_CONFIG($1)
++fi
+
+- # Both c and cxx compiler support -rpath directly
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
+- fi
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+- ;;
++AC_LANG_RESTORE
+
+- solaris*)
+- _LT_AC_TAGVAR(no_undefined_flag, $1)=' -z text'
+- if test "$GCC" = yes; then
+- wlarc='${wl}'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+- $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp'
+- else
+- wlarc=''
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+- $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
+- fi
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- case $host_os in
+- solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
+- *)
+- # The compiler driver will combine linker options so we
+- # cannot just pass the convience library names through
+- # without $wl, iff we do not link with $LD.
+- # Luckily, gcc supports the same syntax we need for Sun Studio.
+- # Supported since Solaris 2.6 (maybe 2.5.1?)
+- case $wlarc in
+- '')
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' ;;
+- *)
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;;
+- esac ;;
+- esac
+- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+- ;;
++GCC=$lt_save_GCC
++CC="$lt_save_CC"
++])# _LT_LANG_GCJ_CONFIG
+
+- sunos4*)
+- if test "x$host_vendor" = xsequent; then
+- # Use $CC to link under sequent, because it throws in some extra .o
+- # files that make .init and .fini sections work.
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+- else
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
+- fi
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- ;;
+
+- sysv4)
+- case $host_vendor in
+- sni)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes # is this really true???
+- ;;
+- siemens)
+- ## LD is ld it makes a PLAMLIB
+- ## CC just makes a GrossModule.
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+- _LT_AC_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs'
+- _LT_AC_TAGVAR(hardcode_direct, $1)=no
+- ;;
+- motorola)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+- _LT_AC_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie
+- ;;
+- esac
+- runpath_var='LD_RUN_PATH'
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- ;;
++# _LT_LANG_RC_CONFIG([TAG])
++# -------------------------
++# Ensure that the configuration variables for the Windows resource compiler
++# are suitably defined. These variables are subsequently used by _LT_CONFIG
++# to write the compiler configuration to `libtool'.
++m4_defun([_LT_LANG_RC_CONFIG],
++[AC_REQUIRE([LT_PROG_RC])dnl
++AC_LANG_SAVE
+
+- sysv4.3*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport'
+- ;;
++# Source file extension for RC test sources.
++ac_ext=rc
+
+- sysv4*MP*)
+- if test -d /usr/nec; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- runpath_var=LD_RUN_PATH
+- hardcode_runpath_var=yes
+- _LT_AC_TAGVAR(ld_shlibs, $1)=yes
+- fi
+- ;;
++# Object file extension for compiled RC test sources.
++objext=o
++_LT_TAGVAR(objext, $1)=$objext
+
+- sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7*)
+- _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- runpath_var='LD_RUN_PATH'
++# Code to be used in simple compile tests
++lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }'
+
+- if test "$GCC" = yes; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+- else
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+- fi
+- ;;
++# Code to be used in simple link tests
++lt_simple_link_test_code="$lt_simple_compile_test_code"
+
+- sysv5* | sco3.2v5* | sco5v6*)
+- # Note: We can NOT use -z defs as we might desire, because we do not
+- # link with -lc, and that would cause any symbols used from libc to
+- # always be unresolved, which means just about no library would
+- # ever link correctly. If we're not using GNU ld we use -z text
+- # though, which does catch some bad symbols but isn't as heavy-handed
+- # as -z defs.
+- _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
+- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':'
+- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
+- runpath_var='LD_RUN_PATH'
++# ltmain only uses $CC for tagged configurations so make sure $CC is set.
++_LT_TAG_COMPILER
+
+- if test "$GCC" = yes; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+- else
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+- fi
+- ;;
++# save warnings/boilerplate of simple test code
++_LT_COMPILER_BOILERPLATE
++_LT_LINKER_BOILERPLATE
+
+- uts4*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- ;;
++# Allow CC to be a program name with arguments.
++lt_save_CC="$CC"
++lt_save_GCC=$GCC
++GCC=
++CC=${RC-"windres"}
++compiler=$CC
++_LT_TAGVAR(compiler, $1)=$CC
++_LT_CC_BASENAME([$compiler])
++_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
+
+- *)
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- esac
+- fi
+-])
+-AC_MSG_RESULT([$_LT_AC_TAGVAR(ld_shlibs, $1)])
+-test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
++if test -n "$compiler"; then
++ :
++ _LT_CONFIG($1)
++fi
+
+-#
+-# Do we need to explicitly link libc?
+-#
+-case "x$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)" in
+-x|xyes)
+- # Assume -lc should be added
+- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
++GCC=$lt_save_GCC
++AC_LANG_RESTORE
++CC="$lt_save_CC"
++])# _LT_LANG_RC_CONFIG
+
+- if test "$enable_shared" = yes && test "$GCC" = yes; then
+- case $_LT_AC_TAGVAR(archive_cmds, $1) in
+- *'~'*)
+- # FIXME: we may have to deal with multi-command sequences.
+- ;;
+- '$CC '*)
+- # Test whether the compiler implicitly links with -lc since on some
+- # systems, -lgcc has to come before -lc. If gcc already passes -lc
+- # to ld, don't add -lc before -lgcc.
+- AC_MSG_CHECKING([whether -lc should be explicitly linked in])
+- $rm conftest*
+- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+- if AC_TRY_EVAL(ac_compile) 2>conftest.err; then
+- soname=conftest
+- lib=conftest
+- libobjs=conftest.$ac_objext
+- deplibs=
+- wl=$_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)
+- pic_flag=$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)
+- compiler_flags=-v
+- linker_flags=-v
+- verstring=
+- output_objdir=.
+- libname=conftest
+- lt_save_allow_undefined_flag=$_LT_AC_TAGVAR(allow_undefined_flag, $1)
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=
+- if AC_TRY_EVAL(_LT_AC_TAGVAR(archive_cmds, $1) 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1)
+- then
+- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+- else
+- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
+- fi
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag
+- else
+- cat conftest.err 1>&5
+- fi
+- $rm conftest*
+- AC_MSG_RESULT([$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)])
+- ;;
+- esac
+- fi
+- ;;
+-esac
+-])# AC_LIBTOOL_PROG_LD_SHLIBS
++# LT_PROG_GCJ
++# -----------
++AC_DEFUN([LT_PROG_GCJ],
++[m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ],
++ [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ],
++ [AC_CHECK_TOOL(GCJ, gcj,)
++ test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2"
++ AC_SUBST(GCJFLAGS)])])[]dnl
++])
+
++# Old name:
++AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ])
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([LT_AC_PROG_GCJ], [])
+
+-# _LT_AC_FILE_LTDLL_C
+-# -------------------
+-# Be careful that the start marker always follows a newline.
+-AC_DEFUN([_LT_AC_FILE_LTDLL_C], [
+-# /* ltdll.c starts here */
+-# #define WIN32_LEAN_AND_MEAN
+-# #include <windows.h>
+-# #undef WIN32_LEAN_AND_MEAN
+-# #include <stdio.h>
+-#
+-# #ifndef __CYGWIN__
+-# # ifdef __CYGWIN32__
+-# # define __CYGWIN__ __CYGWIN32__
+-# # endif
+-# #endif
+-#
+-# #ifdef __cplusplus
+-# extern "C" {
+-# #endif
+-# BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved);
+-# #ifdef __cplusplus
+-# }
+-# #endif
+-#
+-# #ifdef __CYGWIN__
+-# #include <cygwin/cygwin_dll.h>
+-# DECLARE_CYGWIN_DLL( DllMain );
+-# #endif
+-# HINSTANCE __hDllInstance_base;
+-#
+-# BOOL APIENTRY
+-# DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved)
+-# {
+-# __hDllInstance_base = hInst;
+-# return TRUE;
+-# }
+-# /* ltdll.c ends here */
+-])# _LT_AC_FILE_LTDLL_C
+
++# LT_PROG_RC
++# ----------
++AC_DEFUN([LT_PROG_RC],
++[AC_CHECK_TOOL(RC, windres,)
++])
+
+-# _LT_AC_TAGVAR(VARNAME, [TAGNAME])
+-# ---------------------------------
+-AC_DEFUN([_LT_AC_TAGVAR], [ifelse([$2], [], [$1], [$1_$2])])
++# Old name:
++AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC])
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([LT_AC_PROG_RC], [])
+
+
+-# old names
+-AC_DEFUN([AM_PROG_LIBTOOL], [AC_PROG_LIBTOOL])
+-AC_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)])
+-AC_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)])
+-AC_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)])
+-AC_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)])
+-AC_DEFUN([AM_PROG_LD], [AC_PROG_LD])
+-AC_DEFUN([AM_PROG_NM], [AC_PROG_NM])
+-
+-# This is just to silence aclocal about the macro not being used
+-ifelse([AC_DISABLE_FAST_INSTALL])
+-
+-AC_DEFUN([LT_AC_PROG_GCJ],
+-[AC_CHECK_TOOL(GCJ, gcj, no)
+- test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2"
+- AC_SUBST(GCJFLAGS)
++# _LT_DECL_EGREP
++# --------------
++# If we don't have a new enough Autoconf to choose the best grep
++# available, choose the one first in the user's PATH.
++m4_defun([_LT_DECL_EGREP],
++[AC_REQUIRE([AC_PROG_EGREP])dnl
++AC_REQUIRE([AC_PROG_FGREP])dnl
++test -z "$GREP" && GREP=grep
++_LT_DECL([], [GREP], [1], [A grep program that handles long lines])
++_LT_DECL([], [EGREP], [1], [An ERE matcher])
++_LT_DECL([], [FGREP], [1], [A literal string matcher])
++dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too
++AC_SUBST([GREP])
+ ])
+
+-AC_DEFUN([LT_AC_PROG_RC],
+-[AC_CHECK_TOOL(RC, windres, no)
+-])
+
++# _LT_DECL_SED
++# ------------
++# Check for a fully-functional sed program, that truncates
++# as few characters as possible. Prefer GNU sed if found.
++m4_defun([_LT_DECL_SED],
++[AC_PROG_SED
++test -z "$SED" && SED=sed
++Xsed="$SED -e 1s/^X//"
++_LT_DECL([], [SED], [1], [A sed program that does not truncate output])
++_LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"],
++ [Sed that helps us avoid accidentally triggering echo(1) options like -n])
++])# _LT_DECL_SED
++
++m4_ifndef([AC_PROG_SED], [
+ ############################################################
+ # NOTE: This macro has been submitted for inclusion into #
+ # GNU Autoconf as AC_PROG_SED. When it is available in #
+ # a released version of Autoconf we should remove this #
+ # macro and use it instead. #
+ ############################################################
+-# LT_AC_PROG_SED
+-# --------------
+-# Check for a fully-functional sed program, that truncates
+-# as few characters as possible. Prefer GNU sed if found.
+-AC_DEFUN([LT_AC_PROG_SED],
++
++m4_defun([AC_PROG_SED],
+ [AC_MSG_CHECKING([for a sed that does not truncate output])
+ AC_CACHE_VAL(lt_cv_path_SED,
+ [# Loop through the user's path and test for sed and gsed.
+@@ -6435,6 +7010,7 @@ do
+ done
+ done
+ done
++IFS=$as_save_IFS
+ lt_ac_max=0
+ lt_ac_count=0
+ # Add /usr/xpg4/bin/sed as it is typically found on Solaris
+@@ -6467,5 +7043,268 @@ for lt_ac_sed in $lt_ac_sed_list /usr/xp
+ done
+ ])
+ SED=$lt_cv_path_SED
++AC_SUBST([SED])
+ AC_MSG_RESULT([$SED])
++])#AC_PROG_SED
++])#m4_ifndef
++
++# Old name:
++AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED])
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([LT_AC_PROG_SED], [])
++
++
++# _LT_CHECK_SHELL_FEATURES
++# ------------------------
++# Find out whether the shell is Bourne or XSI compatible,
++# or has some other useful features.
++m4_defun([_LT_CHECK_SHELL_FEATURES],
++[AC_MSG_CHECKING([whether the shell understands some XSI constructs])
++# Try some XSI features
++xsi_shell=no
++( _lt_dummy="a/b/c"
++ test "${_lt_dummy##*/},${_lt_dummy%/*},"${_lt_dummy%"$_lt_dummy"}, \
++ = c,a/b,, \
++ && eval 'test $(( 1 + 1 )) -eq 2 \
++ && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \
++ && xsi_shell=yes
++AC_MSG_RESULT([$xsi_shell])
++_LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell'])
++
++AC_MSG_CHECKING([whether the shell understands "+="])
++lt_shell_append=no
++( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \
++ >/dev/null 2>&1 \
++ && lt_shell_append=yes
++AC_MSG_RESULT([$lt_shell_append])
++_LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append'])
++
++if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
++ lt_unset=unset
++else
++ lt_unset=false
++fi
++_LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl
++
++# test EBCDIC or ASCII
++case `echo X|tr X '\101'` in
++ A) # ASCII based system
++ # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
++ lt_SP2NL='tr \040 \012'
++ lt_NL2SP='tr \015\012 \040\040'
++ ;;
++ *) # EBCDIC based system
++ lt_SP2NL='tr \100 \n'
++ lt_NL2SP='tr \r\n \100\100'
++ ;;
++esac
++_LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl
++_LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl
++])# _LT_CHECK_SHELL_FEATURES
++
++
++# _LT_PROG_XSI_SHELLFNS
++# ---------------------
++# Bourne and XSI compatible variants of some useful shell functions.
++m4_defun([_LT_PROG_XSI_SHELLFNS],
++[case $xsi_shell in
++ yes)
++ cat << \_LT_EOF >> "$cfgfile"
++
++# func_dirname file append nondir_replacement
++# Compute the dirname of FILE. If nonempty, add APPEND to the result,
++# otherwise set result to NONDIR_REPLACEMENT.
++func_dirname ()
++{
++ case ${1} in
++ */*) func_dirname_result="${1%/*}${2}" ;;
++ * ) func_dirname_result="${3}" ;;
++ esac
++}
++
++# func_basename file
++func_basename ()
++{
++ func_basename_result="${1##*/}"
++}
++
++# func_dirname_and_basename file append nondir_replacement
++# perform func_basename and func_dirname in a single function
++# call:
++# dirname: Compute the dirname of FILE. If nonempty,
++# add APPEND to the result, otherwise set result
++# to NONDIR_REPLACEMENT.
++# value returned in "$func_dirname_result"
++# basename: Compute filename of FILE.
++# value retuned in "$func_basename_result"
++# Implementation must be kept synchronized with func_dirname
++# and func_basename. For efficiency, we do not delegate to
++# those functions but instead duplicate the functionality here.
++func_dirname_and_basename ()
++{
++ case ${1} in
++ */*) func_dirname_result="${1%/*}${2}" ;;
++ * ) func_dirname_result="${3}" ;;
++ esac
++ func_basename_result="${1##*/}"
++}
++
++# func_stripname prefix suffix name
++# strip PREFIX and SUFFIX off of NAME.
++# PREFIX and SUFFIX must not contain globbing or regex special
++# characters, hashes, percent signs, but SUFFIX may contain a leading
++# dot (in which case that matches only a dot).
++func_stripname ()
++{
++ # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
++ # positional parameters, so assign one to ordinary parameter first.
++ func_stripname_result=${3}
++ func_stripname_result=${func_stripname_result#"${1}"}
++ func_stripname_result=${func_stripname_result%"${2}"}
++}
++
++# func_opt_split
++func_opt_split ()
++{
++ func_opt_split_opt=${1%%=*}
++ func_opt_split_arg=${1#*=}
++}
++
++# func_lo2o object
++func_lo2o ()
++{
++ case ${1} in
++ *.lo) func_lo2o_result=${1%.lo}.${objext} ;;
++ *) func_lo2o_result=${1} ;;
++ esac
++}
++
++# func_xform libobj-or-source
++func_xform ()
++{
++ func_xform_result=${1%.*}.lo
++}
++
++# func_arith arithmetic-term...
++func_arith ()
++{
++ func_arith_result=$(( $[*] ))
++}
++
++# func_len string
++# STRING may not start with a hyphen.
++func_len ()
++{
++ func_len_result=${#1}
++}
++
++_LT_EOF
++ ;;
++ *) # Bourne compatible functions.
++ cat << \_LT_EOF >> "$cfgfile"
++
++# func_dirname file append nondir_replacement
++# Compute the dirname of FILE. If nonempty, add APPEND to the result,
++# otherwise set result to NONDIR_REPLACEMENT.
++func_dirname ()
++{
++ # Extract subdirectory from the argument.
++ func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"`
++ if test "X$func_dirname_result" = "X${1}"; then
++ func_dirname_result="${3}"
++ else
++ func_dirname_result="$func_dirname_result${2}"
++ fi
++}
++
++# func_basename file
++func_basename ()
++{
++ func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"`
++}
++
++dnl func_dirname_and_basename
++dnl A portable version of this function is already defined in general.m4sh
++dnl so there is no need for it here.
++
++# func_stripname prefix suffix name
++# strip PREFIX and SUFFIX off of NAME.
++# PREFIX and SUFFIX must not contain globbing or regex special
++# characters, hashes, percent signs, but SUFFIX may contain a leading
++# dot (in which case that matches only a dot).
++# func_strip_suffix prefix name
++func_stripname ()
++{
++ case ${2} in
++ .*) func_stripname_result=`$ECHO "X${3}" \
++ | $Xsed -e "s%^${1}%%" -e "s%\\\\${2}\$%%"`;;
++ *) func_stripname_result=`$ECHO "X${3}" \
++ | $Xsed -e "s%^${1}%%" -e "s%${2}\$%%"`;;
++ esac
++}
++
++# sed scripts:
++my_sed_long_opt='1s/^\(-[[^=]]*\)=.*/\1/;q'
++my_sed_long_arg='1s/^-[[^=]]*=//'
++
++# func_opt_split
++func_opt_split ()
++{
++ func_opt_split_opt=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_opt"`
++ func_opt_split_arg=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_arg"`
++}
++
++# func_lo2o object
++func_lo2o ()
++{
++ func_lo2o_result=`$ECHO "X${1}" | $Xsed -e "$lo2o"`
++}
++
++# func_xform libobj-or-source
++func_xform ()
++{
++ func_xform_result=`$ECHO "X${1}" | $Xsed -e 's/\.[[^.]]*$/.lo/'`
++}
++
++# func_arith arithmetic-term...
++func_arith ()
++{
++ func_arith_result=`expr "$[@]"`
++}
++
++# func_len string
++# STRING may not start with a hyphen.
++func_len ()
++{
++ func_len_result=`expr "$[1]" : ".*" 2>/dev/null || echo $max_cmd_len`
++}
++
++_LT_EOF
++esac
++
++case $lt_shell_append in
++ yes)
++ cat << \_LT_EOF >> "$cfgfile"
++
++# func_append var value
++# Append VALUE to the end of shell variable VAR.
++func_append ()
++{
++ eval "$[1]+=\$[2]"
++}
++_LT_EOF
++ ;;
++ *)
++ cat << \_LT_EOF >> "$cfgfile"
++
++# func_append var value
++# Append VALUE to the end of shell variable VAR.
++func_append ()
++{
++ eval "$[1]=\$$[1]\$[2]"
++}
++
++_LT_EOF
++ ;;
++ esac
+ ])
+--- a/m4/libtool.m4
++++ b/m4/libtool.m4
+@@ -1,107 +1,186 @@
+ # libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-
+-## Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006
+-## Free Software Foundation, Inc.
+-## Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
+-##
+-## This file is free software; the Free Software Foundation gives
+-## unlimited permission to copy and/or distribute it, with or without
+-## modifications, as long as this notice is preserved.
+-
+-# serial 48 AC_PROG_LIBTOOL
+-
+-
+-# AC_PROVIDE_IFELSE(MACRO-NAME, IF-PROVIDED, IF-NOT-PROVIDED)
+-# -----------------------------------------------------------
+-# If this macro is not defined by Autoconf, define it here.
+-m4_ifdef([AC_PROVIDE_IFELSE],
+- [],
+- [m4_define([AC_PROVIDE_IFELSE],
+- [m4_ifdef([AC_PROVIDE_$1],
+- [$2], [$3])])])
++#
++# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
++# 2006, 2007, 2008 Free Software Foundation, Inc.
++# Written by Gordon Matzigkeit, 1996
++#
++# This file is free software; the Free Software Foundation gives
++# unlimited permission to copy and/or distribute it, with or without
++# modifications, as long as this notice is preserved.
++
++m4_define([_LT_COPYING], [dnl
++# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
++# 2006, 2007, 2008 Free Software Foundation, Inc.
++# Written by Gordon Matzigkeit, 1996
++#
++# This file is part of GNU Libtool.
++#
++# GNU Libtool 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.
++#
++# As a special exception to the GNU General Public License,
++# if you distribute this file as part of a program or library that
++# is built using GNU Libtool, you may include this file under the
++# same distribution terms that you use for the rest of that program.
++#
++# GNU Libtool 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 GNU Libtool; see the file COPYING. If not, a copy
++# can be downloaded from http://www.gnu.org/licenses/gpl.html, or
++# obtained by writing to the Free Software Foundation, Inc.,
++# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
++])
+
++# serial 56 LT_INIT
+
+-# AC_PROG_LIBTOOL
+-# ---------------
+-AC_DEFUN([AC_PROG_LIBTOOL],
+-[AC_REQUIRE([_AC_PROG_LIBTOOL])dnl
+-dnl If AC_PROG_CXX has already been expanded, run AC_LIBTOOL_CXX
+-dnl immediately, otherwise, hook it in at the end of AC_PROG_CXX.
+- AC_PROVIDE_IFELSE([AC_PROG_CXX],
+- [AC_LIBTOOL_CXX],
+- [define([AC_PROG_CXX], defn([AC_PROG_CXX])[AC_LIBTOOL_CXX
+- ])])
+-dnl And a similar setup for Fortran 77 support
+- AC_PROVIDE_IFELSE([AC_PROG_F77],
+- [AC_LIBTOOL_F77],
+- [define([AC_PROG_F77], defn([AC_PROG_F77])[AC_LIBTOOL_F77
+-])])
+-
+-dnl Quote A][M_PROG_GCJ so that aclocal doesn't bring it in needlessly.
+-dnl If either AC_PROG_GCJ or A][M_PROG_GCJ have already been expanded, run
+-dnl AC_LIBTOOL_GCJ immediately, otherwise, hook it in at the end of both.
+- AC_PROVIDE_IFELSE([AC_PROG_GCJ],
+- [AC_LIBTOOL_GCJ],
+- [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],
+- [AC_LIBTOOL_GCJ],
+- [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ],
+- [AC_LIBTOOL_GCJ],
+- [ifdef([AC_PROG_GCJ],
+- [define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[AC_LIBTOOL_GCJ])])
+- ifdef([A][M_PROG_GCJ],
+- [define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[AC_LIBTOOL_GCJ])])
+- ifdef([LT_AC_PROG_GCJ],
+- [define([LT_AC_PROG_GCJ],
+- defn([LT_AC_PROG_GCJ])[AC_LIBTOOL_GCJ])])])])
+-])])# AC_PROG_LIBTOOL
+
++# LT_PREREQ(VERSION)
++# ------------------
++# Complain and exit if this libtool version is less that VERSION.
++m4_defun([LT_PREREQ],
++[m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1,
++ [m4_default([$3],
++ [m4_fatal([Libtool version $1 or higher is required],
++ 63)])],
++ [$2])])
+
+-# _AC_PROG_LIBTOOL
+-# ----------------
+-AC_DEFUN([_AC_PROG_LIBTOOL],
+-[AC_REQUIRE([AC_LIBTOOL_SETUP])dnl
+-AC_BEFORE([$0],[AC_LIBTOOL_CXX])dnl
+-AC_BEFORE([$0],[AC_LIBTOOL_F77])dnl
+-AC_BEFORE([$0],[AC_LIBTOOL_GCJ])dnl
++
++# _LT_CHECK_BUILDDIR
++# ------------------
++# Complain if the absolute build directory name contains unusual characters
++m4_defun([_LT_CHECK_BUILDDIR],
++[case `pwd` in
++ *\ * | *\ *)
++ AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;;
++esac
++])
++
++
++# LT_INIT([OPTIONS])
++# ------------------
++AC_DEFUN([LT_INIT],
++[AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT
++AC_BEFORE([$0], [LT_LANG])dnl
++AC_BEFORE([$0], [LT_OUTPUT])dnl
++AC_BEFORE([$0], [LTDL_INIT])dnl
++m4_require([_LT_CHECK_BUILDDIR])dnl
++
++dnl Autoconf doesn't catch unexpanded LT_ macros by default:
++m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl
++m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl
++dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4
++dnl unless we require an AC_DEFUNed macro:
++AC_REQUIRE([LTOPTIONS_VERSION])dnl
++AC_REQUIRE([LTSUGAR_VERSION])dnl
++AC_REQUIRE([LTVERSION_VERSION])dnl
++AC_REQUIRE([LTOBSOLETE_VERSION])dnl
++m4_require([_LT_PROG_LTMAIN])dnl
++
++dnl Parse OPTIONS
++_LT_SET_OPTIONS([$0], [$1])
+
+ # This can be used to rebuild libtool when needed
+-LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh"
++LIBTOOL_DEPS="$ltmain"
+
+ # Always use our own libtool.
+-LIBTOOL='$(SHELL) $(top_builddir)/libtool'
++LIBTOOL='$(SHELL) $(top_builddir)'
++LIBTOOL="$LIBTOOL/$host_alias-libtool"
+ AC_SUBST(LIBTOOL)dnl
+
+-# Prevent multiple expansion
+-define([AC_PROG_LIBTOOL], [])
+-])# _AC_PROG_LIBTOOL
++_LT_SETUP
+
++# Only expand once:
++m4_define([LT_INIT])
++])# LT_INIT
++
++# Old names:
++AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT])
++AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT])
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([AC_PROG_LIBTOOL], [])
++dnl AC_DEFUN([AM_PROG_LIBTOOL], [])
+
+-# AC_LIBTOOL_SETUP
+-# ----------------
+-AC_DEFUN([AC_LIBTOOL_SETUP],
+-[AC_PREREQ(2.50)dnl
+-AC_REQUIRE([AC_ENABLE_SHARED])dnl
+-AC_REQUIRE([AC_ENABLE_STATIC])dnl
+-AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl
+-AC_REQUIRE([AC_CANONICAL_HOST])dnl
++
++# _LT_CC_BASENAME(CC)
++# -------------------
++# Calculate cc_basename. Skip known compiler wrappers and cross-prefix.
++m4_defun([_LT_CC_BASENAME],
++[for cc_temp in $1""; do
++ case $cc_temp in
++ compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;;
++ distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;;
++ \-*) ;;
++ *) break;;
++ esac
++done
++cc_basename=`$ECHO "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
++])
++
++
++# _LT_FILEUTILS_DEFAULTS
++# ----------------------
++# It is okay to use these file commands and assume they have been set
++# sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'.
++m4_defun([_LT_FILEUTILS_DEFAULTS],
++[: ${CP="cp -f"}
++: ${MV="mv -f"}
++: ${RM="rm -f"}
++])# _LT_FILEUTILS_DEFAULTS
++
++
++# _LT_SETUP
++# ---------
++m4_defun([_LT_SETUP],
++[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+ AC_REQUIRE([AC_CANONICAL_BUILD])dnl
++_LT_DECL([], [host_alias], [0], [The host system])dnl
++_LT_DECL([], [host], [0])dnl
++_LT_DECL([], [host_os], [0])dnl
++dnl
++_LT_DECL([], [build_alias], [0], [The build system])dnl
++_LT_DECL([], [build], [0])dnl
++_LT_DECL([], [build_os], [0])dnl
++dnl
+ AC_REQUIRE([AC_PROG_CC])dnl
+-AC_REQUIRE([AC_PROG_LD])dnl
+-AC_REQUIRE([AC_PROG_LD_RELOAD_FLAG])dnl
+-AC_REQUIRE([AC_PROG_NM])dnl
+-
++AC_REQUIRE([LT_PATH_LD])dnl
++AC_REQUIRE([LT_PATH_NM])dnl
++dnl
+ AC_REQUIRE([AC_PROG_LN_S])dnl
+-AC_REQUIRE([AC_DEPLIBS_CHECK_METHOD])dnl
+-# Autoconf 2.13's AC_OBJEXT and AC_EXEEXT macros only works for C compilers!
+-AC_REQUIRE([AC_OBJEXT])dnl
+-AC_REQUIRE([AC_EXEEXT])dnl
++test -z "$LN_S" && LN_S="ln -s"
++_LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl
+ dnl
++AC_REQUIRE([LT_CMD_MAX_LEN])dnl
++_LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl
++_LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl
++dnl
++m4_require([_LT_FILEUTILS_DEFAULTS])dnl
++m4_require([_LT_CHECK_SHELL_FEATURES])dnl
++m4_require([_LT_CMD_RELOAD])dnl
++m4_require([_LT_CHECK_MAGIC_METHOD])dnl
++m4_require([_LT_CMD_OLD_ARCHIVE])dnl
++m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl
++
++_LT_CONFIG_LIBTOOL_INIT([
++# See if we are running on zsh, and set the options which allow our
++# commands through without removal of \ escapes INIT.
++if test -n "\${ZSH_VERSION+set}" ; then
++ setopt NO_GLOB_SUBST
++fi
++])
++if test -n "${ZSH_VERSION+set}" ; then
++ setopt NO_GLOB_SUBST
++fi
+
+-AC_LIBTOOL_SYS_MAX_CMD_LEN
+-AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE
+-AC_LIBTOOL_OBJDIR
++_LT_CHECK_OBJDIR
+
+-AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl
+-_LT_AC_PROG_ECHO_BACKSLASH
++m4_require([_LT_TAG_COMPILER])dnl
++_LT_PROG_ECHO_BACKSLASH
+
+ case $host_os in
+ aix3*)
+@@ -117,6307 +196,6803 @@ esac
+
+ # Sed substitution that helps us do robust quoting. It backslashifies
+ # metacharacters that are still active within double-quoted strings.
+-Xsed='sed -e 1s/^X//'
+-[sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g']
++sed_quote_subst='s/\([["`$\\]]\)/\\\1/g'
+
+ # Same as above, but do not quote variable references.
+-[double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g']
++double_quote_subst='s/\([["`\\]]\)/\\\1/g'
+
+ # Sed substitution to delay expansion of an escaped shell variable in a
+ # double_quote_subst'ed string.
+ delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
+
++# Sed substitution to delay expansion of an escaped single quote.
++delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g'
++
+ # Sed substitution to avoid accidental globbing in evaled expressions
+ no_glob_subst='s/\*/\\\*/g'
+
+-# Constants:
+-rm="rm -f"
+-
+ # Global variables:
+-default_ofile=libtool
++ofile=${host_alias}-libtool
+ can_build_shared=yes
+
+ # All known linkers require a `.a' archive for static linking (except MSVC,
+ # which needs '.lib').
+ libext=a
+-ltmain="$ac_aux_dir/ltmain.sh"
+-ofile="$default_ofile"
+-with_gnu_ld="$lt_cv_prog_gnu_ld"
+
+-AC_CHECK_TOOL(AR, ar, false)
+-AC_CHECK_TOOL(RANLIB, ranlib, :)
+-AC_CHECK_TOOL(STRIP, strip, :)
++with_gnu_ld="$lt_cv_prog_gnu_ld"
+
+ old_CC="$CC"
+ old_CFLAGS="$CFLAGS"
+
+ # Set sane defaults for various variables
+-test -z "$AR" && AR=ar
+-test -z "$AR_FLAGS" && AR_FLAGS=cru
+-test -z "$AS" && AS=as
+ test -z "$CC" && CC=cc
+ test -z "$LTCC" && LTCC=$CC
+ test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
+-test -z "$DLLTOOL" && DLLTOOL=dlltool
+ test -z "$LD" && LD=ld
+-test -z "$LN_S" && LN_S="ln -s"
+-test -z "$MAGIC_CMD" && MAGIC_CMD=file
+-test -z "$NM" && NM=nm
+-test -z "$SED" && SED=sed
+-test -z "$OBJDUMP" && OBJDUMP=objdump
+-test -z "$RANLIB" && RANLIB=:
+-test -z "$STRIP" && STRIP=:
+ test -z "$ac_objext" && ac_objext=o
+
+-# Determine commands to create old-style static archives.
+-old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs'
+-old_postinstall_cmds='chmod 644 $oldlib'
+-old_postuninstall_cmds=
+-
+-if test -n "$RANLIB"; then
+- case $host_os in
+- openbsd*)
+- old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib"
+- ;;
+- *)
+- old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib"
+- ;;
+- esac
+- old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
+-fi
+-
+ _LT_CC_BASENAME([$compiler])
+
+ # Only perform the check for file, if the check method requires it
++test -z "$MAGIC_CMD" && MAGIC_CMD=file
+ case $deplibs_check_method in
+ file_magic*)
+ if test "$file_magic_cmd" = '$MAGIC_CMD'; then
+- AC_PATH_MAGIC
++ _LT_PATH_MAGIC
+ fi
+ ;;
+ esac
+
+-AC_PROVIDE_IFELSE([AC_LIBTOOL_DLOPEN], enable_dlopen=yes, enable_dlopen=no)
+-AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL],
+-enable_win32_dll=yes, enable_win32_dll=no)
+-
+-AC_ARG_ENABLE([libtool-lock],
+- [AC_HELP_STRING([--disable-libtool-lock],
+- [avoid locking (might break parallel builds)])])
+-test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
++# Use C for the default configuration in the libtool script
++LT_SUPPORTED_TAG([CC])
++_LT_LANG_C_CONFIG
++_LT_LANG_DEFAULT_CONFIG
++_LT_CONFIG_COMMANDS
++])# _LT_SETUP
+
+-AC_ARG_WITH([pic],
+- [AC_HELP_STRING([--with-pic],
+- [try to use only PIC/non-PIC objects @<:@default=use both@:>@])],
+- [pic_mode="$withval"],
+- [pic_mode=default])
+-test -z "$pic_mode" && pic_mode=default
+
+-# Use C for the default configuration in the libtool script
+-tagname=
+-AC_LIBTOOL_LANG_C_CONFIG
+-_LT_AC_TAGCONFIG
+-])# AC_LIBTOOL_SETUP
++# _LT_PROG_LTMAIN
++# ---------------
++# Note that this code is called both from `configure', and `config.status'
++# now that we use AC_CONFIG_COMMANDS to generate libtool. Notably,
++# `config.status' has no value for ac_aux_dir unless we are using Automake,
++# so we pass a copy along to make sure it has a sensible value anyway.
++m4_defun([_LT_PROG_LTMAIN],
++[m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl
++_LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir'])
++ltmain="$ac_aux_dir/ltmain.sh"
++])# _LT_PROG_LTMAIN
+
+
+-# _LT_AC_SYS_COMPILER
+-# -------------------
+-AC_DEFUN([_LT_AC_SYS_COMPILER],
+-[AC_REQUIRE([AC_PROG_CC])dnl
++## ------------------------------------- ##
++## Accumulate code for creating libtool. ##
++## ------------------------------------- ##
++
++# So that we can recreate a full libtool script including additional
++# tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS
++# in macros and then make a single call at the end using the `libtool'
++# label.
++
++
++# _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS])
++# ----------------------------------------
++# Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later.
++m4_define([_LT_CONFIG_LIBTOOL_INIT],
++[m4_ifval([$1],
++ [m4_append([_LT_OUTPUT_LIBTOOL_INIT],
++ [$1
++])])])
++
++# Initialize.
++m4_define([_LT_OUTPUT_LIBTOOL_INIT])
++
++
++# _LT_CONFIG_LIBTOOL([COMMANDS])
++# ------------------------------
++# Register COMMANDS to be passed to AC_CONFIG_COMMANDS later.
++m4_define([_LT_CONFIG_LIBTOOL],
++[m4_ifval([$1],
++ [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS],
++ [$1
++])])])
++
++# Initialize.
++m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS])
++
++
++# _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS])
++# -----------------------------------------------------
++m4_defun([_LT_CONFIG_SAVE_COMMANDS],
++[_LT_CONFIG_LIBTOOL([$1])
++_LT_CONFIG_LIBTOOL_INIT([$2])
++])
+
+-# If no C compiler was specified, use CC.
+-LTCC=${LTCC-"$CC"}
+
+-# If no C compiler flags were specified, use CFLAGS.
+-LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
++# _LT_FORMAT_COMMENT([COMMENT])
++# -----------------------------
++# Add leading comment marks to the start of each line, and a trailing
++# full-stop to the whole comment if one is not present already.
++m4_define([_LT_FORMAT_COMMENT],
++[m4_ifval([$1], [
++m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])],
++ [['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.])
++)])
+
+-# Allow CC to be a program name with arguments.
+-compiler=$CC
+-])# _LT_AC_SYS_COMPILER
+
+
+-# _LT_CC_BASENAME(CC)
+-# -------------------
+-# Calculate cc_basename. Skip known compiler wrappers and cross-prefix.
+-AC_DEFUN([_LT_CC_BASENAME],
+-[for cc_temp in $1""; do
+- case $cc_temp in
+- compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;;
+- distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;;
+- \-*) ;;
+- *) break;;
+- esac
+-done
+-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
++## ------------------------ ##
++## FIXME: Eliminate VARNAME ##
++## ------------------------ ##
++
++
++# _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?])
++# -------------------------------------------------------------------
++# CONFIGNAME is the name given to the value in the libtool script.
++# VARNAME is the (base) name used in the configure script.
++# VALUE may be 0, 1 or 2 for a computed quote escaped value based on
++# VARNAME. Any other value will be used directly.
++m4_define([_LT_DECL],
++[lt_if_append_uniq([lt_decl_varnames], [$2], [, ],
++ [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name],
++ [m4_ifval([$1], [$1], [$2])])
++ lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3])
++ m4_ifval([$4],
++ [lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])])
++ lt_dict_add_subkey([lt_decl_dict], [$2],
++ [tagged?], [m4_ifval([$5], [yes], [no])])])
+ ])
+
+
+-# _LT_COMPILER_BOILERPLATE
+-# ------------------------
+-# Check for compiler boilerplate output or warnings with
+-# the simple compiler test code.
+-AC_DEFUN([_LT_COMPILER_BOILERPLATE],
+-[ac_outfile=conftest.$ac_objext
+-printf "$lt_simple_compile_test_code" >conftest.$ac_ext
+-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+-_lt_compiler_boilerplate=`cat conftest.err`
+-$rm conftest*
+-])# _LT_COMPILER_BOILERPLATE
+-
++# _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION])
++# --------------------------------------------------------
++m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])])
++
++
++# lt_decl_tag_varnames([SEPARATOR], [VARNAME1...])
++# ------------------------------------------------
++m4_define([lt_decl_tag_varnames],
++[_lt_decl_filter([tagged?], [yes], $@)])
++
++
++# _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..])
++# ---------------------------------------------------------
++m4_define([_lt_decl_filter],
++[m4_case([$#],
++ [0], [m4_fatal([$0: too few arguments: $#])],
++ [1], [m4_fatal([$0: too few arguments: $#: $1])],
++ [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)],
++ [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)],
++ [lt_dict_filter([lt_decl_dict], $@)])[]dnl
++])
+
+-# _LT_LINKER_BOILERPLATE
+-# ----------------------
+-# Check for linker boilerplate output or warnings with
+-# the simple link test code.
+-AC_DEFUN([_LT_LINKER_BOILERPLATE],
+-[ac_outfile=conftest.$ac_objext
+-printf "$lt_simple_link_test_code" >conftest.$ac_ext
+-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+-_lt_linker_boilerplate=`cat conftest.err`
+-$rm conftest*
+-])# _LT_LINKER_BOILERPLATE
+
++# lt_decl_quote_varnames([SEPARATOR], [VARNAME1...])
++# --------------------------------------------------
++m4_define([lt_decl_quote_varnames],
++[_lt_decl_filter([value], [1], $@)])
++
++
++# lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...])
++# ---------------------------------------------------
++m4_define([lt_decl_dquote_varnames],
++[_lt_decl_filter([value], [2], $@)])
++
++
++# lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...])
++# ---------------------------------------------------
++m4_define([lt_decl_varnames_tagged],
++[_$0(m4_quote(m4_default([$1], [[, ]])),
++ m4_quote(m4_if([$2], [],
++ m4_quote(lt_decl_tag_varnames),
++ m4_quote(m4_shift($@)))),
++ m4_split(m4_normalize(m4_quote(_LT_TAGS))))])
++m4_define([_lt_decl_varnames_tagged], [lt_combine([$1], [$2], [_], $3)])
++
++
++# lt_decl_all_varnames([SEPARATOR], [VARNAME1...])
++# ------------------------------------------------
++m4_define([lt_decl_all_varnames],
++[_$0(m4_quote(m4_default([$1], [[, ]])),
++ m4_if([$2], [],
++ m4_quote(lt_decl_varnames),
++ m4_quote(m4_shift($@))))[]dnl
++])
++m4_define([_lt_decl_all_varnames],
++[lt_join($@, lt_decl_varnames_tagged([$1],
++ lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl
++])
+
+-# _LT_AC_SYS_LIBPATH_AIX
+-# ----------------------
+-# Links a minimal program and checks the executable
+-# for the system default hardcoded library path. In most cases,
+-# this is /usr/lib:/lib, but when the MPI compilers are used
+-# the location of the communication and MPI libs are included too.
+-# If we don't find anything, use the default library path according
+-# to the aix ld manual.
+-AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX],
+-[AC_LINK_IFELSE(AC_LANG_PROGRAM,[
+-aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
+-}'`
+-# Check for a 64-bit object if we didn't find anything.
+-if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
+-}'`; fi],[])
+-if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+-])# _LT_AC_SYS_LIBPATH_AIX
+
++# _LT_CONFIG_STATUS_DECLARE([VARNAME])
++# ------------------------------------
++# Quote a variable value, and forward it to `config.status' so that its
++# declaration there will have the same value as in `configure'. VARNAME
++# must have a single quote delimited value for this to work.
++m4_define([_LT_CONFIG_STATUS_DECLARE],
++[$1='`$ECHO "X$][$1" | $Xsed -e "$delay_single_quote_subst"`'])
+
+-# _LT_AC_SHELL_INIT(ARG)
+-# ----------------------
+-AC_DEFUN([_LT_AC_SHELL_INIT],
+-[ifdef([AC_DIVERSION_NOTICE],
+- [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)],
+- [AC_DIVERT_PUSH(NOTICE)])
+-$1
+-AC_DIVERT_POP
+-])# _LT_AC_SHELL_INIT
+
++# _LT_CONFIG_STATUS_DECLARATIONS
++# ------------------------------
++# We delimit libtool config variables with single quotes, so when
++# we write them to config.status, we have to be sure to quote all
++# embedded single quotes properly. In configure, this macro expands
++# each variable declared with _LT_DECL (and _LT_TAGDECL) into:
++#
++# <var>='`$ECHO "X$<var>" | $Xsed -e "$delay_single_quote_subst"`'
++m4_defun([_LT_CONFIG_STATUS_DECLARATIONS],
++[m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames),
++ [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])])
+
+-# _LT_AC_PROG_ECHO_BACKSLASH
+-# --------------------------
+-# Add some code to the start of the generated configure script which
+-# will find an echo command which doesn't interpret backslashes.
+-AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH],
+-[_LT_AC_SHELL_INIT([
+-# Check that we are running under the correct shell.
+-SHELL=${CONFIG_SHELL-/bin/sh}
+
+-case X$ECHO in
+-X*--fallback-echo)
+- # Remove one level of quotation (which was required for Make).
+- ECHO=`echo "$ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','`
+- ;;
+-esac
++# _LT_LIBTOOL_TAGS
++# ----------------
++# Output comment and list of tags supported by the script
++m4_defun([_LT_LIBTOOL_TAGS],
++[_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl
++available_tags="_LT_TAGS"dnl
++])
+
+-echo=${ECHO-echo}
+-if test "X[$]1" = X--no-reexec; then
+- # Discard the --no-reexec flag, and continue.
+- shift
+-elif test "X[$]1" = X--fallback-echo; then
+- # Avoid inline document here, it may be left over
+- :
+-elif test "X`($echo '\t') 2>/dev/null`" = 'X\t' ; then
+- # Yippee, $echo works!
+- :
+-else
+- # Restart under the correct shell.
+- exec $SHELL "[$]0" --no-reexec ${1+"[$]@"}
+-fi
+
+-if test "X[$]1" = X--fallback-echo; then
+- # used as fallback echo
+- shift
+- cat <<EOF
+-[$]*
+-EOF
+- exit 0
+-fi
++# _LT_LIBTOOL_DECLARE(VARNAME, [TAG])
++# -----------------------------------
++# Extract the dictionary values for VARNAME (optionally with TAG) and
++# expand to a commented shell variable setting:
++#
++# # Some comment about what VAR is for.
++# visible_name=$lt_internal_name
++m4_define([_LT_LIBTOOL_DECLARE],
++[_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1],
++ [description])))[]dnl
++m4_pushdef([_libtool_name],
++ m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl
++m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])),
++ [0], [_libtool_name=[$]$1],
++ [1], [_libtool_name=$lt_[]$1],
++ [2], [_libtool_name=$lt_[]$1],
++ [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl
++m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl
++])
+
+-# The HP-UX ksh and POSIX shell print the target directory to stdout
+-# if CDPATH is set.
+-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+-if test -z "$ECHO"; then
+-if test "X${echo_test_string+set}" != Xset; then
+-# find a string as large as possible, as long as the shell can cope with it
+- for cmd in 'sed 50q "[$]0"' 'sed 20q "[$]0"' 'sed 10q "[$]0"' 'sed 2q "[$]0"' 'echo test'; do
+- # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ...
+- if (echo_test_string=`eval $cmd`) 2>/dev/null &&
+- echo_test_string=`eval $cmd` &&
+- (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null
+- then
+- break
+- fi
+- done
+-fi
++# _LT_LIBTOOL_CONFIG_VARS
++# -----------------------
++# Produce commented declarations of non-tagged libtool config variables
++# suitable for insertion in the LIBTOOL CONFIG section of the `libtool'
++# script. Tagged libtool config variables (even for the LIBTOOL CONFIG
++# section) are produced by _LT_LIBTOOL_TAG_VARS.
++m4_defun([_LT_LIBTOOL_CONFIG_VARS],
++[m4_foreach([_lt_var],
++ m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)),
++ [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])])
+
+-if test "X`($echo '\t') 2>/dev/null`" = 'X\t' &&
+- echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` &&
+- test "X$echo_testing_string" = "X$echo_test_string"; then
+- :
+-else
+- # The Solaris, AIX, and Digital Unix default echo programs unquote
+- # backslashes. This makes it impossible to quote backslashes using
+- # echo "$something" | sed 's/\\/\\\\/g'
+- #
+- # So, first we look for a working echo in the user's PATH.
+
+- lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+- for dir in $PATH /usr/ucb; do
+- IFS="$lt_save_ifs"
+- if (test -f $dir/echo || test -f $dir/echo$ac_exeext) &&
+- test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' &&
+- echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` &&
+- test "X$echo_testing_string" = "X$echo_test_string"; then
+- echo="$dir/echo"
+- break
+- fi
+- done
+- IFS="$lt_save_ifs"
++# _LT_LIBTOOL_TAG_VARS(TAG)
++# -------------------------
++m4_define([_LT_LIBTOOL_TAG_VARS],
++[m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames),
++ [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])])
+
+- if test "X$echo" = Xecho; then
+- # We didn't find a better echo, so look for alternatives.
+- if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' &&
+- echo_testing_string=`(print -r "$echo_test_string") 2>/dev/null` &&
+- test "X$echo_testing_string" = "X$echo_test_string"; then
+- # This shell has a builtin print -r that does the trick.
+- echo='print -r'
+- elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) &&
+- test "X$CONFIG_SHELL" != X/bin/ksh; then
+- # If we have ksh, try running configure again with it.
+- ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
+- export ORIGINAL_CONFIG_SHELL
+- CONFIG_SHELL=/bin/ksh
+- export CONFIG_SHELL
+- exec $CONFIG_SHELL "[$]0" --no-reexec ${1+"[$]@"}
+- else
+- # Try using printf.
+- echo='printf %s\n'
+- if test "X`($echo '\t') 2>/dev/null`" = 'X\t' &&
+- echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` &&
+- test "X$echo_testing_string" = "X$echo_test_string"; then
+- # Cool, printf works
+- :
+- elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` &&
+- test "X$echo_testing_string" = 'X\t' &&
+- echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
+- test "X$echo_testing_string" = "X$echo_test_string"; then
+- CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL
+- export CONFIG_SHELL
+- SHELL="$CONFIG_SHELL"
+- export SHELL
+- echo="$CONFIG_SHELL [$]0 --fallback-echo"
+- elif echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` &&
+- test "X$echo_testing_string" = 'X\t' &&
+- echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
+- test "X$echo_testing_string" = "X$echo_test_string"; then
+- echo="$CONFIG_SHELL [$]0 --fallback-echo"
+- else
+- # maybe with a smaller string...
+- prev=:
+
+- for cmd in 'echo test' 'sed 2q "[$]0"' 'sed 10q "[$]0"' 'sed 20q "[$]0"' 'sed 50q "[$]0"'; do
+- if (test "X$echo_test_string" = "X`eval $cmd`") 2>/dev/null
+- then
+- break
+- fi
+- prev="$cmd"
+- done
++# _LT_TAGVAR(VARNAME, [TAGNAME])
++# ------------------------------
++m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])])
+
+- if test "$prev" != 'sed 50q "[$]0"'; then
+- echo_test_string=`eval $prev`
+- export echo_test_string
+- exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "[$]0" ${1+"[$]@"}
+- else
+- # Oops. We lost completely, so just stick with echo.
+- echo=echo
+- fi
+- fi
+- fi
+- fi
+-fi
+-fi
+
+-# Copy echo and quote the copy suitably for passing to libtool from
+-# the Makefile, instead of quoting the original, which is used later.
+-ECHO=$echo
+-if test "X$ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then
+- ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo"
+-fi
++# _LT_CONFIG_COMMANDS
++# -------------------
++# Send accumulated output to $CONFIG_STATUS. Thanks to the lists of
++# variables for single and double quote escaping we saved from calls
++# to _LT_DECL, we can put quote escaped variables declarations
++# into `config.status', and then the shell code to quote escape them in
++# for loops in `config.status'. Finally, any additional code accumulated
++# from calls to _LT_CONFIG_LIBTOOL_INIT is expanded.
++m4_defun([_LT_CONFIG_COMMANDS],
++[AC_PROVIDE_IFELSE([LT_OUTPUT],
++ dnl If the libtool generation code has been placed in $CONFIG_LT,
++ dnl instead of duplicating it all over again into config.status,
++ dnl then we will have config.status run $CONFIG_LT later, so it
++ dnl needs to know what name is stored there:
++ [AC_CONFIG_COMMANDS([libtool],
++ [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])],
++ dnl If the libtool generation code is destined for config.status,
++ dnl expand the accumulated commands and init code now:
++ [AC_CONFIG_COMMANDS([libtool],
++ [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])])
++])#_LT_CONFIG_COMMANDS
+
+-AC_SUBST(ECHO)
+-])])# _LT_AC_PROG_ECHO_BACKSLASH
+
++# Initialize.
++m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT],
++[
+
+-# _LT_AC_LOCK
+-# -----------
+-AC_DEFUN([_LT_AC_LOCK],
+-[AC_ARG_ENABLE([libtool-lock],
+- [AC_HELP_STRING([--disable-libtool-lock],
+- [avoid locking (might break parallel builds)])])
+-test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
++# The HP-UX ksh and POSIX shell print the target directory to stdout
++# if CDPATH is set.
++(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+-# Some flags need to be propagated to the compiler or linker for good
+-# libtool support.
+-case $host in
+-ia64-*-hpux*)
+- # Find out which ABI we are using.
+- echo 'int i;' > conftest.$ac_ext
+- if AC_TRY_EVAL(ac_compile); then
+- case `/usr/bin/file conftest.$ac_objext` in
+- *ELF-32*)
+- HPUX_IA64_MODE="32"
+- ;;
+- *ELF-64*)
+- HPUX_IA64_MODE="64"
+- ;;
+- esac
+- fi
+- rm -rf conftest*
+- ;;
+-*-*-irix6*)
+- # Find out which ABI we are using.
+- echo '[#]line __oline__ "configure"' > conftest.$ac_ext
+- if AC_TRY_EVAL(ac_compile); then
+- if test "$lt_cv_prog_gnu_ld" = yes; then
+- case `/usr/bin/file conftest.$ac_objext` in
+- *32-bit*)
+- LD="${LD-ld} -melf32bsmip"
+- ;;
+- *N32*)
+- LD="${LD-ld} -melf32bmipn32"
++sed_quote_subst='$sed_quote_subst'
++double_quote_subst='$double_quote_subst'
++delay_variable_subst='$delay_variable_subst'
++_LT_CONFIG_STATUS_DECLARATIONS
++LTCC='$LTCC'
++LTCFLAGS='$LTCFLAGS'
++compiler='$compiler_DEFAULT'
++
++# Quote evaled strings.
++for var in lt_decl_all_varnames([[ \
++]], lt_decl_quote_varnames); do
++ case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in
++ *[[\\\\\\\`\\"\\\$]]*)
++ eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$sed_quote_subst\\"\\\`\\\\\\""
+ ;;
+- *64-bit*)
+- LD="${LD-ld} -melf64bmip"
++ *)
++ eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
+ ;;
+ esac
+- else
+- case `/usr/bin/file conftest.$ac_objext` in
+- *32-bit*)
+- LD="${LD-ld} -32"
+- ;;
+- *N32*)
+- LD="${LD-ld} -n32"
++done
++
++# Double-quote double-evaled strings.
++for var in lt_decl_all_varnames([[ \
++]], lt_decl_dquote_varnames); do
++ case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in
++ *[[\\\\\\\`\\"\\\$]]*)
++ eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\""
+ ;;
+- *64-bit*)
+- LD="${LD-ld} -64"
++ *)
++ eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
+ ;;
+ esac
+- fi
+- fi
+- rm -rf conftest*
++done
++
++# Fix-up fallback echo if it was mangled by the above quoting rules.
++case \$lt_ECHO in
++*'\\\[$]0 --fallback-echo"')dnl "
++ lt_ECHO=\`\$ECHO "X\$lt_ECHO" | \$Xsed -e 's/\\\\\\\\\\\\\\\[$]0 --fallback-echo"\[$]/\[$]0 --fallback-echo"/'\`
+ ;;
++esac
+
+-x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*|s390*-*linux*|sparc*-*linux*)
+- # Find out which ABI we are using.
+- echo 'int i;' > conftest.$ac_ext
+- if AC_TRY_EVAL(ac_compile); then
+- case `/usr/bin/file conftest.o` in
+- *32-bit*)
+- case $host in
+- x86_64-*linux*)
+- LD="${LD-ld} -m elf_i386"
+- ;;
+- ppc64-*linux*|powerpc64-*linux*)
+- LD="${LD-ld} -m elf32ppclinux"
+- ;;
+- s390x-*linux*)
+- LD="${LD-ld} -m elf_s390"
+- ;;
+- sparc64-*linux*)
+- LD="${LD-ld} -m elf32_sparc"
+- ;;
+- esac
+- ;;
+- *64-bit*)
+- case $host in
+- x86_64-*linux*)
+- LD="${LD-ld} -m elf_x86_64"
+- ;;
+- ppc*-*linux*|powerpc*-*linux*)
+- LD="${LD-ld} -m elf64ppc"
+- ;;
+- s390*-*linux*)
+- LD="${LD-ld} -m elf64_s390"
+- ;;
+- sparc*-*linux*)
+- LD="${LD-ld} -m elf64_sparc"
+- ;;
+- esac
+- ;;
+- esac
+- fi
+- rm -rf conftest*
+- ;;
++_LT_OUTPUT_LIBTOOL_INIT
++])
+
+-*-*-sco3.2v5*)
+- # On SCO OpenServer 5, we need -belf to get full-featured binaries.
+- SAVE_CFLAGS="$CFLAGS"
+- CFLAGS="$CFLAGS -belf"
+- AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
+- [AC_LANG_PUSH(C)
+- AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])
+- AC_LANG_POP])
+- if test x"$lt_cv_cc_needs_belf" != x"yes"; then
+- # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
+- CFLAGS="$SAVE_CFLAGS"
+- fi
+- ;;
+-sparc*-*solaris*)
+- # Find out which ABI we are using.
+- echo 'int i;' > conftest.$ac_ext
+- if AC_TRY_EVAL(ac_compile); then
+- case `/usr/bin/file conftest.o` in
+- *64-bit*)
+- case $lt_cv_prog_gnu_ld in
+- yes*) LD="${LD-ld} -m elf64_sparc" ;;
+- *) LD="${LD-ld} -64" ;;
+- esac
+- ;;
+- esac
+- fi
+- rm -rf conftest*
+- ;;
+
+-AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL],
+-[*-*-cygwin* | *-*-mingw* | *-*-pw32*)
+- AC_CHECK_TOOL(DLLTOOL, dlltool, false)
+- AC_CHECK_TOOL(AS, as, false)
+- AC_CHECK_TOOL(OBJDUMP, objdump, false)
+- ;;
+- ])
+-esac
++# LT_OUTPUT
++# ---------
++# This macro allows early generation of the libtool script (before
++# AC_OUTPUT is called), incase it is used in configure for compilation
++# tests.
++AC_DEFUN([LT_OUTPUT],
++[: ${CONFIG_LT=./config.lt}
++AC_MSG_NOTICE([creating $CONFIG_LT])
++cat >"$CONFIG_LT" <<_LTEOF
++#! $SHELL
++# Generated by $as_me.
++# Run this file to recreate a libtool stub with the current configuration.
++
++lt_cl_silent=false
++SHELL=\${CONFIG_SHELL-$SHELL}
++_LTEOF
++
++cat >>"$CONFIG_LT" <<\_LTEOF
++AS_SHELL_SANITIZE
++_AS_PREPARE
+
+-need_locks="$enable_libtool_lock"
++exec AS_MESSAGE_FD>&1
++exec AS_MESSAGE_LOG_FD>>config.log
++{
++ echo
++ AS_BOX([Running $as_me.])
++} >&AS_MESSAGE_LOG_FD
++
++lt_cl_help="\
++\`$as_me' creates a local libtool stub from the current configuration,
++for use in further configure time tests before the real libtool is
++generated.
++
++Usage: $[0] [[OPTIONS]]
++
++ -h, --help print this help, then exit
++ -V, --version print version number, then exit
++ -q, --quiet do not print progress messages
++ -d, --debug don't remove temporary files
++
++Report bugs to <bug-libtool@gnu.org>."
++
++lt_cl_version="\
++m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl
++m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION])
++configured by $[0], generated by m4_PACKAGE_STRING.
++
++Copyright (C) 2008 Free Software Foundation, Inc.
++This config.lt script is free software; the Free Software Foundation
++gives unlimited permision to copy, distribute and modify it."
+
+-])# _LT_AC_LOCK
++while test $[#] != 0
++do
++ case $[1] in
++ --version | --v* | -V )
++ echo "$lt_cl_version"; exit 0 ;;
++ --help | --h* | -h )
++ echo "$lt_cl_help"; exit 0 ;;
++ --debug | --d* | -d )
++ debug=: ;;
++ --quiet | --q* | --silent | --s* | -q )
++ lt_cl_silent=: ;;
+
++ -*) AC_MSG_ERROR([unrecognized option: $[1]
++Try \`$[0] --help' for more information.]) ;;
+
+-# AC_LIBTOOL_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
+-# [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE])
+-# ----------------------------------------------------------------
+-# Check whether the given compiler option works
+-AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION],
+-[AC_REQUIRE([LT_AC_PROG_SED])
+-AC_CACHE_CHECK([$1], [$2],
+- [$2=no
+- ifelse([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4])
+- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+- lt_compiler_flag="$3"
+- # Insert the option either (1) after the last *FLAGS variable, or
+- # (2) before a word containing "conftest.", or (3) at the end.
+- # Note that $ac_compile itself does not contain backslashes and begins
+- # with a dollar sign (not a hyphen), so the echo should work correctly.
+- # The option is referenced via a variable to avoid confusing sed.
+- lt_compile=`echo "$ac_compile" | $SED \
+- -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+- -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
+- -e 's:$: $lt_compiler_flag:'`
+- (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
+- (eval "$lt_compile" 2>conftest.err)
+- ac_status=$?
+- cat conftest.err >&AS_MESSAGE_LOG_FD
+- echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
+- if (exit $ac_status) && test -s "$ac_outfile"; then
+- # The compiler can only warn and ignore the option if not recognized
+- # So say no if there are warnings other than the usual output.
+- $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
+- $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+- if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+- $2=yes
+- fi
+- fi
+- $rm conftest*
+-])
++ *) AC_MSG_ERROR([unrecognized argument: $[1]
++Try \`$[0] --help' for more information.]) ;;
++ esac
++ shift
++done
+
+-if test x"[$]$2" = xyes; then
+- ifelse([$5], , :, [$5])
+-else
+- ifelse([$6], , :, [$6])
++if $lt_cl_silent; then
++ exec AS_MESSAGE_FD>/dev/null
+ fi
+-])# AC_LIBTOOL_COMPILER_OPTION
+-
+-
+-# AC_LIBTOOL_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
+-# [ACTION-SUCCESS], [ACTION-FAILURE])
+-# ------------------------------------------------------------
+-# Check whether the given compiler option works
+-AC_DEFUN([AC_LIBTOOL_LINKER_OPTION],
+-[AC_CACHE_CHECK([$1], [$2],
+- [$2=no
+- save_LDFLAGS="$LDFLAGS"
+- LDFLAGS="$LDFLAGS $3"
+- printf "$lt_simple_link_test_code" > conftest.$ac_ext
+- if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
+- # The linker can only warn and ignore the option if not recognized
+- # So say no if there are warnings
+- if test -s conftest.err; then
+- # Append any errors to the config.log.
+- cat conftest.err 1>&AS_MESSAGE_LOG_FD
+- $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
+- $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+- if diff conftest.exp conftest.er2 >/dev/null; then
+- $2=yes
+- fi
+- else
+- $2=yes
+- fi
+- fi
+- $rm conftest*
+- LDFLAGS="$save_LDFLAGS"
+-])
++_LTEOF
+
+-if test x"[$]$2" = xyes; then
+- ifelse([$4], , :, [$4])
+-else
+- ifelse([$5], , :, [$5])
++cat >>"$CONFIG_LT" <<_LTEOF
++_LT_OUTPUT_LIBTOOL_COMMANDS_INIT
++_LTEOF
++
++cat >>"$CONFIG_LT" <<\_LTEOF
++AC_MSG_NOTICE([creating $ofile])
++_LT_OUTPUT_LIBTOOL_COMMANDS
++AS_EXIT(0)
++_LTEOF
++chmod +x "$CONFIG_LT"
++
++# configure is writing to config.log, but config.lt does its own redirection,
++# appending to config.log, which fails on DOS, as config.log is still kept
++# open by configure. Here we exec the FD to /dev/null, effectively closing
++# config.log, so it can be properly (re)opened and appended to by config.lt.
++if test "$no_create" != yes; then
++ lt_cl_success=:
++ test "$silent" = yes &&
++ lt_config_lt_args="$lt_config_lt_args --quiet"
++ exec AS_MESSAGE_LOG_FD>/dev/null
++ $SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false
++ exec AS_MESSAGE_LOG_FD>>config.log
++ $lt_cl_success || AS_EXIT(1)
+ fi
+-])# AC_LIBTOOL_LINKER_OPTION
+-
++])# LT_OUTPUT
+
+-# AC_LIBTOOL_SYS_MAX_CMD_LEN
+-# --------------------------
+-AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN],
+-[# find the maximum length of command line arguments
+-AC_MSG_CHECKING([the maximum length of command line arguments])
+-AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
+- i=0
+- teststring="ABCD"
+
+- case $build_os in
+- msdosdjgpp*)
+- # On DJGPP, this test can blow up pretty badly due to problems in libc
+- # (any single argument exceeding 2000 bytes causes a buffer overrun
+- # during glob expansion). Even if it were fixed, the result of this
+- # check would be larger than it should be.
+- lt_cv_sys_max_cmd_len=12288; # 12K is about right
+- ;;
++# _LT_CONFIG(TAG)
++# ---------------
++# If TAG is the built-in tag, create an initial libtool script with a
++# default configuration from the untagged config vars. Otherwise add code
++# to config.status for appending the configuration named by TAG from the
++# matching tagged config vars.
++m4_defun([_LT_CONFIG],
++[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
++_LT_CONFIG_SAVE_COMMANDS([
++ m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl
++ m4_if(_LT_TAG, [C], [
++ # See if we are running on zsh, and set the options which allow our
++ # commands through without removal of \ escapes.
++ if test -n "${ZSH_VERSION+set}" ; then
++ setopt NO_GLOB_SUBST
++ fi
+
+- gnu*)
+- # Under GNU Hurd, this test is not required because there is
+- # no limit to the length of command line arguments.
+- # Libtool will interpret -1 as no limit whatsoever
+- lt_cv_sys_max_cmd_len=-1;
+- ;;
++ cfgfile="${ofile}T"
++ trap "$RM \"$cfgfile\"; exit 1" 1 2 15
++ $RM "$cfgfile"
+
+- cygwin* | mingw*)
+- # On Win9x/ME, this test blows up -- it succeeds, but takes
+- # about 5 minutes as the teststring grows exponentially.
+- # Worse, since 9x/ME are not pre-emptively multitasking,
+- # you end up with a "frozen" computer, even though with patience
+- # the test eventually succeeds (with a max line length of 256k).
+- # Instead, let's just punt: use the minimum linelength reported by
+- # all of the supported platforms: 8192 (on NT/2K/XP).
+- lt_cv_sys_max_cmd_len=8192;
+- ;;
++ cat <<_LT_EOF >> "$cfgfile"
++#! $SHELL
+
+- amigaos*)
+- # On AmigaOS with pdksh, this test takes hours, literally.
+- # So we just punt and use a minimum line length of 8192.
+- lt_cv_sys_max_cmd_len=8192;
+- ;;
++# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
++# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION
++# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
++# NOTE: Changes made to this file will be lost: look at ltmain.sh.
++#
++_LT_COPYING
++_LT_LIBTOOL_TAGS
+
+- netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
+- # This has been around since 386BSD, at least. Likely further.
+- if test -x /sbin/sysctl; then
+- lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
+- elif test -x /usr/sbin/sysctl; then
+- lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
+- else
+- lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs
+- fi
+- # And add a safety zone
+- lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
+- lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+- ;;
++# ### BEGIN LIBTOOL CONFIG
++_LT_LIBTOOL_CONFIG_VARS
++_LT_LIBTOOL_TAG_VARS
++# ### END LIBTOOL CONFIG
+
+- interix*)
+- # We know the value 262144 and hardcode it with a safety zone (like BSD)
+- lt_cv_sys_max_cmd_len=196608
+- ;;
++_LT_EOF
+
+- osf*)
+- # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
+- # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
+- # nice to cause kernel panics so lets avoid the loop below.
+- # First set a reasonable default.
+- lt_cv_sys_max_cmd_len=16384
+- #
+- if test -x /sbin/sysconfig; then
+- case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
+- *1*) lt_cv_sys_max_cmd_len=-1 ;;
+- esac
+- fi
+- ;;
+- sco3.2v5*)
+- lt_cv_sys_max_cmd_len=102400
+- ;;
+- sysv5* | sco5v6* | sysv4.2uw2*)
+- kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
+- if test -n "$kargmax"; then
+- lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'`
+- else
+- lt_cv_sys_max_cmd_len=32768
+- fi
+- ;;
+- *)
+- # If test is not a shell built-in, we'll probably end up computing a
+- # maximum length that is only half of the actual maximum length, but
+- # we can't tell.
+- SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
+- while (test "X"`$SHELL [$]0 --fallback-echo "X$teststring" 2>/dev/null` \
+- = "XX$teststring") >/dev/null 2>&1 &&
+- new_result=`expr "X$teststring" : ".*" 2>&1` &&
+- lt_cv_sys_max_cmd_len=$new_result &&
+- test $i != 17 # 1/2 MB should be enough
+- do
+- i=`expr $i + 1`
+- teststring=$teststring$teststring
+- done
+- teststring=
+- # Add a significant safety factor because C++ compilers can tack on massive
+- # amounts of additional arguments before passing them to the linker.
+- # It appears as though 1/2 is a usable value.
+- lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
++ case $host_os in
++ aix3*)
++ cat <<\_LT_EOF >> "$cfgfile"
++# AIX sometimes has problems with the GCC collect2 program. For some
++# reason, if we set the COLLECT_NAMES environment variable, the problems
++# vanish in a puff of smoke.
++if test "X${COLLECT_NAMES+set}" != Xset; then
++ COLLECT_NAMES=
++ export COLLECT_NAMES
++fi
++_LT_EOF
+ ;;
+ esac
+-])
+-if test -n $lt_cv_sys_max_cmd_len ; then
+- AC_MSG_RESULT($lt_cv_sys_max_cmd_len)
+-else
+- AC_MSG_RESULT(none)
+-fi
+-])# AC_LIBTOOL_SYS_MAX_CMD_LEN
+
++ _LT_PROG_LTMAIN
+
+-# _LT_AC_CHECK_DLFCN
+-# ------------------
+-AC_DEFUN([_LT_AC_CHECK_DLFCN],
+-[AC_CHECK_HEADERS(dlfcn.h)dnl
+-])# _LT_AC_CHECK_DLFCN
++ # We use sed instead of cat because bash on DJGPP gets confused if
++ # if finds mixed CR/LF and LF-only lines. Since sed operates in
++ # text mode, it properly converts lines to CR/LF. This bash problem
++ # is reportedly fixed, but why not run on old versions too?
++ sed '/^# Generated shell functions inserted here/q' "$ltmain" >> "$cfgfile" \
++ || (rm -f "$cfgfile"; exit 1)
+
++ _LT_PROG_XSI_SHELLFNS
+
+-# _LT_AC_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE,
+-# ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING)
+-# ---------------------------------------------------------------------
+-AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF],
+-[AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl
+-if test "$cross_compiling" = yes; then :
+- [$4]
+-else
+- lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+- lt_status=$lt_dlunknown
+- cat > conftest.$ac_ext <<EOF
+-[#line __oline__ "configure"
+-#include "confdefs.h"
++ sed -n '/^# Generated shell functions inserted here/,$p' "$ltmain" >> "$cfgfile" \
++ || (rm -f "$cfgfile"; exit 1)
+
+-#if HAVE_DLFCN_H
+-#include <dlfcn.h>
+-#endif
++ mv -f "$cfgfile" "$ofile" ||
++ (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
++ chmod +x "$ofile"
++],
++[cat <<_LT_EOF >> "$ofile"
+
+-#include <stdio.h>
++dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded
++dnl in a comment (ie after a #).
++# ### BEGIN LIBTOOL TAG CONFIG: $1
++_LT_LIBTOOL_TAG_VARS(_LT_TAG)
++# ### END LIBTOOL TAG CONFIG: $1
++_LT_EOF
++])dnl /m4_if
++],
++[m4_if([$1], [], [
++ PACKAGE='$PACKAGE'
++ VERSION='$VERSION'
++ TIMESTAMP='$TIMESTAMP'
++ RM='$RM'
++ ofile='$ofile'], [])
++])dnl /_LT_CONFIG_SAVE_COMMANDS
++])# _LT_CONFIG
++
++
++# LT_SUPPORTED_TAG(TAG)
++# ---------------------
++# Trace this macro to discover what tags are supported by the libtool
++# --tag option, using:
++# autoconf --trace 'LT_SUPPORTED_TAG:$1'
++AC_DEFUN([LT_SUPPORTED_TAG], [])
++
++
++# C support is built-in for now
++m4_define([_LT_LANG_C_enabled], [])
++m4_define([_LT_TAGS], [])
+
+-#ifdef RTLD_GLOBAL
+-# define LT_DLGLOBAL RTLD_GLOBAL
+-#else
+-# ifdef DL_GLOBAL
+-# define LT_DLGLOBAL DL_GLOBAL
+-# else
+-# define LT_DLGLOBAL 0
+-# endif
+-#endif
+
+-/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+- find out it does not work in some platform. */
+-#ifndef LT_DLLAZY_OR_NOW
+-# ifdef RTLD_LAZY
+-# define LT_DLLAZY_OR_NOW RTLD_LAZY
+-# else
+-# ifdef DL_LAZY
+-# define LT_DLLAZY_OR_NOW DL_LAZY
+-# else
+-# ifdef RTLD_NOW
+-# define LT_DLLAZY_OR_NOW RTLD_NOW
+-# else
+-# ifdef DL_NOW
+-# define LT_DLLAZY_OR_NOW DL_NOW
+-# else
+-# define LT_DLLAZY_OR_NOW 0
+-# endif
+-# endif
+-# endif
+-# endif
+-#endif
++# LT_LANG(LANG)
++# -------------
++# Enable libtool support for the given language if not already enabled.
++AC_DEFUN([LT_LANG],
++[AC_BEFORE([$0], [LT_OUTPUT])dnl
++m4_case([$1],
++ [C], [_LT_LANG(C)],
++ [C++], [_LT_LANG(CXX)],
++ [Java], [_LT_LANG(GCJ)],
++ [Fortran 77], [_LT_LANG(F77)],
++ [Fortran], [_LT_LANG(FC)],
++ [Windows Resource], [_LT_LANG(RC)],
++ [m4_ifdef([_LT_LANG_]$1[_CONFIG],
++ [_LT_LANG($1)],
++ [m4_fatal([$0: unsupported language: "$1"])])])dnl
++])# LT_LANG
+
+-#ifdef __cplusplus
+-extern "C" void exit (int);
+-#endif
+
+-void fnord() { int i=42;}
+-int main ()
+-{
+- void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+- int status = $lt_dlunknown;
+-
+- if (self)
+- {
+- if (dlsym (self,"fnord")) status = $lt_dlno_uscore;
+- else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
+- /* dlclose (self); */
+- }
+- else
+- puts (dlerror ());
++# _LT_LANG(LANGNAME)
++# ------------------
++m4_defun([_LT_LANG],
++[m4_ifdef([_LT_LANG_]$1[_enabled], [],
++ [LT_SUPPORTED_TAG([$1])dnl
++ m4_append([_LT_TAGS], [$1 ])dnl
++ m4_define([_LT_LANG_]$1[_enabled], [])dnl
++ _LT_LANG_$1_CONFIG($1)])dnl
++])# _LT_LANG
+
+- exit (status);
+-}]
+-EOF
+- if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then
+- (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null
+- lt_status=$?
+- case x$lt_status in
+- x$lt_dlno_uscore) $1 ;;
+- x$lt_dlneed_uscore) $2 ;;
+- x$lt_dlunknown|x*) $3 ;;
+- esac
+- else :
+- # compilation failed
+- $3
+- fi
+-fi
+-rm -fr conftest*
+-])# _LT_AC_TRY_DLOPEN_SELF
+
++# _LT_LANG_DEFAULT_CONFIG
++# -----------------------
++m4_defun([_LT_LANG_DEFAULT_CONFIG],
++[AC_PROVIDE_IFELSE([AC_PROG_CXX],
++ [LT_LANG(CXX)],
++ [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])])
++
++AC_PROVIDE_IFELSE([AC_PROG_F77],
++ [LT_LANG(F77)],
++ [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])])
++
++AC_PROVIDE_IFELSE([AC_PROG_FC],
++ [LT_LANG(FC)],
++ [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])])
++
++dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal
++dnl pulling things in needlessly.
++AC_PROVIDE_IFELSE([AC_PROG_GCJ],
++ [LT_LANG(GCJ)],
++ [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],
++ [LT_LANG(GCJ)],
++ [AC_PROVIDE_IFELSE([LT_PROG_GCJ],
++ [LT_LANG(GCJ)],
++ [m4_ifdef([AC_PROG_GCJ],
++ [m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])])
++ m4_ifdef([A][M_PROG_GCJ],
++ [m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])])
++ m4_ifdef([LT_PROG_GCJ],
++ [m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])])
++
++AC_PROVIDE_IFELSE([LT_PROG_RC],
++ [LT_LANG(RC)],
++ [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])])
++])# _LT_LANG_DEFAULT_CONFIG
++
++# Obsolete macros:
++AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)])
++AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)])
++AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)])
++AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)])
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([AC_LIBTOOL_CXX], [])
++dnl AC_DEFUN([AC_LIBTOOL_F77], [])
++dnl AC_DEFUN([AC_LIBTOOL_FC], [])
++dnl AC_DEFUN([AC_LIBTOOL_GCJ], [])
+
+-# AC_LIBTOOL_DLOPEN_SELF
+-# ----------------------
+-AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF],
+-[AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl
+-if test "x$enable_dlopen" != xyes; then
+- enable_dlopen=unknown
+- enable_dlopen_self=unknown
+- enable_dlopen_self_static=unknown
+-else
+- lt_cv_dlopen=no
+- lt_cv_dlopen_libs=
+
+- case $host_os in
+- beos*)
+- lt_cv_dlopen="load_add_on"
+- lt_cv_dlopen_libs=
+- lt_cv_dlopen_self=yes
+- ;;
++# _LT_TAG_COMPILER
++# ----------------
++m4_defun([_LT_TAG_COMPILER],
++[AC_REQUIRE([AC_PROG_CC])dnl
+
+- mingw* | pw32*)
+- lt_cv_dlopen="LoadLibrary"
+- lt_cv_dlopen_libs=
+- ;;
++_LT_DECL([LTCC], [CC], [1], [A C compiler])dnl
++_LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl
++_LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl
++_LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl
+
+- cygwin*)
+- lt_cv_dlopen="dlopen"
+- lt_cv_dlopen_libs=
+- ;;
++# If no C compiler was specified, use CC.
++LTCC=${LTCC-"$CC"}
+
+- darwin*)
+- # if libdl is installed we need to link against it
+- AC_CHECK_LIB([dl], [dlopen],
+- [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[
+- lt_cv_dlopen="dyld"
+- lt_cv_dlopen_libs=
+- lt_cv_dlopen_self=yes
+- ])
+- ;;
++# If no C compiler flags were specified, use CFLAGS.
++LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
+
+- *)
+- AC_CHECK_FUNC([shl_load],
+- [lt_cv_dlopen="shl_load"],
+- [AC_CHECK_LIB([dld], [shl_load],
+- [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld"],
+- [AC_CHECK_FUNC([dlopen],
+- [lt_cv_dlopen="dlopen"],
+- [AC_CHECK_LIB([dl], [dlopen],
+- [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],
+- [AC_CHECK_LIB([svld], [dlopen],
+- [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"],
+- [AC_CHECK_LIB([dld], [dld_link],
+- [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld"])
+- ])
+- ])
+- ])
+- ])
+- ])
+- ;;
+- esac
++# Allow CC to be a program name with arguments.
++compiler=$CC
++])# _LT_TAG_COMPILER
+
+- if test "x$lt_cv_dlopen" != xno; then
+- enable_dlopen=yes
+- else
+- enable_dlopen=no
+- fi
+
+- case $lt_cv_dlopen in
+- dlopen)
+- save_CPPFLAGS="$CPPFLAGS"
+- test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
++# _LT_COMPILER_BOILERPLATE
++# ------------------------
++# Check for compiler boilerplate output or warnings with
++# the simple compiler test code.
++m4_defun([_LT_COMPILER_BOILERPLATE],
++[m4_require([_LT_DECL_SED])dnl
++ac_outfile=conftest.$ac_objext
++echo "$lt_simple_compile_test_code" >conftest.$ac_ext
++eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
++_lt_compiler_boilerplate=`cat conftest.err`
++$RM conftest*
++])# _LT_COMPILER_BOILERPLATE
+
+- save_LDFLAGS="$LDFLAGS"
+- wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
+
+- save_LIBS="$LIBS"
+- LIBS="$lt_cv_dlopen_libs $LIBS"
++# _LT_LINKER_BOILERPLATE
++# ----------------------
++# Check for linker boilerplate output or warnings with
++# the simple link test code.
++m4_defun([_LT_LINKER_BOILERPLATE],
++[m4_require([_LT_DECL_SED])dnl
++ac_outfile=conftest.$ac_objext
++echo "$lt_simple_link_test_code" >conftest.$ac_ext
++eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
++_lt_linker_boilerplate=`cat conftest.err`
++$RM -r conftest*
++])# _LT_LINKER_BOILERPLATE
+
+- AC_CACHE_CHECK([whether a program can dlopen itself],
+- lt_cv_dlopen_self, [dnl
+- _LT_AC_TRY_DLOPEN_SELF(
+- lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes,
+- lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross)
++# _LT_REQUIRED_DARWIN_CHECKS
++# -------------------------
++m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[
++ case $host_os in
++ rhapsody* | darwin*)
++ AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:])
++ AC_CHECK_TOOL([NMEDIT], [nmedit], [:])
++ AC_CHECK_TOOL([LIPO], [lipo], [:])
++ AC_CHECK_TOOL([OTOOL], [otool], [:])
++ AC_CHECK_TOOL([OTOOL64], [otool64], [:])
++ _LT_DECL([], [DSYMUTIL], [1],
++ [Tool to manipulate archived DWARF debug symbol files on Mac OS X])
++ _LT_DECL([], [NMEDIT], [1],
++ [Tool to change global to local symbols on Mac OS X])
++ _LT_DECL([], [LIPO], [1],
++ [Tool to manipulate fat objects and archives on Mac OS X])
++ _LT_DECL([], [OTOOL], [1],
++ [ldd/readelf like tool for Mach-O binaries on Mac OS X])
++ _LT_DECL([], [OTOOL64], [1],
++ [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4])
++
++ AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod],
++ [lt_cv_apple_cc_single_mod=no
++ if test -z "${LT_MULTI_MODULE}"; then
++ # By default we will add the -single_module flag. You can override
++ # by either setting the environment variable LT_MULTI_MODULE
++ # non-empty at configure time, or by adding -multi_module to the
++ # link flags.
++ rm -rf libconftest.dylib*
++ echo "int foo(void){return 1;}" > conftest.c
++ echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
++-dynamiclib -Wl,-single_module conftest.c" >&AS_MESSAGE_LOG_FD
++ $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
++ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err
++ _lt_result=$?
++ if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then
++ lt_cv_apple_cc_single_mod=yes
++ else
++ cat conftest.err >&AS_MESSAGE_LOG_FD
++ fi
++ rm -rf libconftest.dylib*
++ rm -f conftest.*
++ fi])
++ AC_CACHE_CHECK([for -exported_symbols_list linker flag],
++ [lt_cv_ld_exported_symbols_list],
++ [lt_cv_ld_exported_symbols_list=no
++ save_LDFLAGS=$LDFLAGS
++ echo "_main" > conftest.sym
++ LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym"
++ AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
++ [lt_cv_ld_exported_symbols_list=yes],
++ [lt_cv_ld_exported_symbols_list=no])
++ LDFLAGS="$save_LDFLAGS"
+ ])
+-
+- if test "x$lt_cv_dlopen_self" = xyes; then
+- wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
+- AC_CACHE_CHECK([whether a statically linked program can dlopen itself],
+- lt_cv_dlopen_self_static, [dnl
+- _LT_AC_TRY_DLOPEN_SELF(
+- lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes,
+- lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross)
+- ])
++ case $host_os in
++ rhapsody* | darwin1.[[012]])
++ _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
++ darwin1.*)
++ _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
++ darwin*) # darwin 5.x on
++ # if running on 10.5 or later, the deployment target defaults
++ # to the OS version, if on x86, and 10.4, the deployment
++ # target defaults to 10.4. Don't you love it?
++ case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
++ 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*)
++ _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
++ 10.[[012]]*)
++ _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
++ 10.*)
++ _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
++ esac
++ ;;
++ esac
++ if test "$lt_cv_apple_cc_single_mod" = "yes"; then
++ _lt_dar_single_mod='$single_module'
++ fi
++ if test "$lt_cv_ld_exported_symbols_list" = "yes"; then
++ _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym'
++ else
++ _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}'
++ fi
++ if test "$DSYMUTIL" != ":"; then
++ _lt_dsymutil='~$DSYMUTIL $lib || :'
++ else
++ _lt_dsymutil=
+ fi
+-
+- CPPFLAGS="$save_CPPFLAGS"
+- LDFLAGS="$save_LDFLAGS"
+- LIBS="$save_LIBS"
+ ;;
+ esac
++])
+
+- case $lt_cv_dlopen_self in
+- yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
+- *) enable_dlopen_self=unknown ;;
+- esac
+
+- case $lt_cv_dlopen_self_static in
+- yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
+- *) enable_dlopen_self_static=unknown ;;
+- esac
+-fi
+-])# AC_LIBTOOL_DLOPEN_SELF
++# _LT_DARWIN_LINKER_FEATURES
++# --------------------------
++# Checks for linker and compiler features on darwin
++m4_defun([_LT_DARWIN_LINKER_FEATURES],
++[
++ m4_require([_LT_REQUIRED_DARWIN_CHECKS])
++ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
++ _LT_TAGVAR(hardcode_direct, $1)=no
++ _LT_TAGVAR(hardcode_automatic, $1)=yes
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
++ _LT_TAGVAR(whole_archive_flag_spec, $1)=''
++ _LT_TAGVAR(link_all_deplibs, $1)=yes
++ _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined"
++ if test "$GCC" = "yes"; then
++ output_verbose_link_cmd=echo
++ _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
++ _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
++ _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
++ _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
++ m4_if([$1], [CXX],
++[ if test "$lt_cv_apple_cc_single_mod" != "yes"; then
++ _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
++ _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}"
++ fi
++],[])
++ else
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ fi
++])
+
++# _LT_SYS_MODULE_PATH_AIX
++# -----------------------
++# Links a minimal program and checks the executable
++# for the system default hardcoded library path. In most cases,
++# this is /usr/lib:/lib, but when the MPI compilers are used
++# the location of the communication and MPI libs are included too.
++# If we don't find anything, use the default library path according
++# to the aix ld manual.
++m4_defun([_LT_SYS_MODULE_PATH_AIX],
++[m4_require([_LT_DECL_SED])dnl
++AC_LINK_IFELSE(AC_LANG_PROGRAM,[
++lt_aix_libpath_sed='
++ /Import File Strings/,/^$/ {
++ /^0/ {
++ s/^0 *\(.*\)$/\1/
++ p
++ }
++ }'
++aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
++# Check for a 64-bit object if we didn't find anything.
++if test -z "$aix_libpath"; then
++ aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
++fi],[])
++if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
++])# _LT_SYS_MODULE_PATH_AIX
+
+-# AC_LIBTOOL_PROG_CC_C_O([TAGNAME])
+-# ---------------------------------
+-# Check to see if options -c and -o are simultaneously supported by compiler
+-AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O],
+-[AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl
+-AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext],
+- [_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)],
+- [_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no
+- $rm -r conftest 2>/dev/null
+- mkdir conftest
+- cd conftest
+- mkdir out
+- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+- lt_compiler_flag="-o out/conftest2.$ac_objext"
+- # Insert the option either (1) after the last *FLAGS variable, or
+- # (2) before a word containing "conftest.", or (3) at the end.
+- # Note that $ac_compile itself does not contain backslashes and begins
+- # with a dollar sign (not a hyphen), so the echo should work correctly.
+- lt_compile=`echo "$ac_compile" | $SED \
+- -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+- -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
+- -e 's:$: $lt_compiler_flag:'`
+- (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
+- (eval "$lt_compile" 2>out/conftest.err)
+- ac_status=$?
+- cat out/conftest.err >&AS_MESSAGE_LOG_FD
+- echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
+- if (exit $ac_status) && test -s out/conftest2.$ac_objext
+- then
+- # The compiler can only warn and ignore the option if not recognized
+- # So say no if there are warnings
+- $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
+- $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+- if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+- _LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
+- fi
+- fi
+- chmod u+w . 2>&AS_MESSAGE_LOG_FD
+- $rm conftest*
+- # SGI C++ compiler will create directory out/ii_files/ for
+- # template instantiation
+- test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files
+- $rm out/* && rmdir out
+- cd ..
+- rmdir conftest
+- $rm conftest*
+-])
+-])# AC_LIBTOOL_PROG_CC_C_O
++# _LT_SHELL_INIT(ARG)
++# -------------------
++m4_define([_LT_SHELL_INIT],
++[ifdef([AC_DIVERSION_NOTICE],
++ [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)],
++ [AC_DIVERT_PUSH(NOTICE)])
++$1
++AC_DIVERT_POP
++])# _LT_SHELL_INIT
+
+
+-# AC_LIBTOOL_SYS_HARD_LINK_LOCKS([TAGNAME])
+-# -----------------------------------------
+-# Check to see if we can do hard links to lock some files if needed
+-AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS],
+-[AC_REQUIRE([_LT_AC_LOCK])dnl
++# _LT_PROG_ECHO_BACKSLASH
++# -----------------------
++# Add some code to the start of the generated configure script which
++# will find an echo command which doesn't interpret backslashes.
++m4_defun([_LT_PROG_ECHO_BACKSLASH],
++[_LT_SHELL_INIT([
++# Check that we are running under the correct shell.
++SHELL=${CONFIG_SHELL-/bin/sh}
+
+-hard_links="nottested"
+-if test "$_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then
+- # do not overwrite the value of need_locks provided by the user
+- AC_MSG_CHECKING([if we can lock with hard links])
+- hard_links=yes
+- $rm conftest*
+- ln conftest.a conftest.b 2>/dev/null && hard_links=no
+- touch conftest.a
+- ln conftest.a conftest.b 2>&5 || hard_links=no
+- ln conftest.a conftest.b 2>/dev/null && hard_links=no
+- AC_MSG_RESULT([$hard_links])
+- if test "$hard_links" = no; then
+- AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe])
+- need_locks=warn
+- fi
++case X$lt_ECHO in
++X*--fallback-echo)
++ # Remove one level of quotation (which was required for Make).
++ ECHO=`echo "$lt_ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','`
++ ;;
++esac
++
++ECHO=${lt_ECHO-echo}
++if test "X[$]1" = X--no-reexec; then
++ # Discard the --no-reexec flag, and continue.
++ shift
++elif test "X[$]1" = X--fallback-echo; then
++ # Avoid inline document here, it may be left over
++ :
++elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' ; then
++ # Yippee, $ECHO works!
++ :
+ else
+- need_locks=no
++ # Restart under the correct shell.
++ exec $SHELL "[$]0" --no-reexec ${1+"[$]@"}
+ fi
+-])# AC_LIBTOOL_SYS_HARD_LINK_LOCKS
+
+-
+-# AC_LIBTOOL_OBJDIR
+-# -----------------
+-AC_DEFUN([AC_LIBTOOL_OBJDIR],
+-[AC_CACHE_CHECK([for objdir], [lt_cv_objdir],
+-[rm -f .libs 2>/dev/null
+-mkdir .libs 2>/dev/null
+-if test -d .libs; then
+- lt_cv_objdir=.libs
+-else
+- # MS-DOS does not allow filenames that begin with a dot.
+- lt_cv_objdir=_libs
++if test "X[$]1" = X--fallback-echo; then
++ # used as fallback echo
++ shift
++ cat <<_LT_EOF
++[$]*
++_LT_EOF
++ exit 0
+ fi
+-rmdir .libs 2>/dev/null])
+-objdir=$lt_cv_objdir
+-])# AC_LIBTOOL_OBJDIR
+
++# The HP-UX ksh and POSIX shell print the target directory to stdout
++# if CDPATH is set.
++(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+-# AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH([TAGNAME])
+-# ----------------------------------------------
+-# Check hardcoding attributes.
+-AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH],
+-[AC_MSG_CHECKING([how to hardcode library paths into programs])
+-_LT_AC_TAGVAR(hardcode_action, $1)=
+-if test -n "$_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)" || \
+- test -n "$_LT_AC_TAGVAR(runpath_var, $1)" || \
+- test "X$_LT_AC_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then
+-
+- # We can hardcode non-existant directories.
+- if test "$_LT_AC_TAGVAR(hardcode_direct, $1)" != no &&
+- # If the only mechanism to avoid hardcoding is shlibpath_var, we
+- # have to relink, otherwise we might link with an installed library
+- # when we should be linking with a yet-to-be-installed one
+- ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)" != no &&
+- test "$_LT_AC_TAGVAR(hardcode_minus_L, $1)" != no; then
+- # Linking always hardcodes the temporary library directory.
+- _LT_AC_TAGVAR(hardcode_action, $1)=relink
+- else
+- # We can link without hardcoding, and we can hardcode nonexisting dirs.
+- _LT_AC_TAGVAR(hardcode_action, $1)=immediate
++if test -z "$lt_ECHO"; then
++ if test "X${echo_test_string+set}" != Xset; then
++ # find a string as large as possible, as long as the shell can cope with it
++ for cmd in 'sed 50q "[$]0"' 'sed 20q "[$]0"' 'sed 10q "[$]0"' 'sed 2q "[$]0"' 'echo test'; do
++ # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ...
++ if { echo_test_string=`eval $cmd`; } 2>/dev/null &&
++ { test "X$echo_test_string" = "X$echo_test_string"; } 2>/dev/null
++ then
++ break
++ fi
++ done
+ fi
+-else
+- # We cannot hardcode anything, or else we can only hardcode existing
+- # directories.
+- _LT_AC_TAGVAR(hardcode_action, $1)=unsupported
+-fi
+-AC_MSG_RESULT([$_LT_AC_TAGVAR(hardcode_action, $1)])
+
+-if test "$_LT_AC_TAGVAR(hardcode_action, $1)" = relink; then
+- # Fast installation is not supported
+- enable_fast_install=no
+-elif test "$shlibpath_overrides_runpath" = yes ||
+- test "$enable_shared" = no; then
+- # Fast installation is not necessary
+- enable_fast_install=needless
+-fi
+-])# AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH
++ if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' &&
++ echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` &&
++ test "X$echo_testing_string" = "X$echo_test_string"; then
++ :
++ else
++ # The Solaris, AIX, and Digital Unix default echo programs unquote
++ # backslashes. This makes it impossible to quote backslashes using
++ # echo "$something" | sed 's/\\/\\\\/g'
++ #
++ # So, first we look for a working echo in the user's PATH.
+
++ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
++ for dir in $PATH /usr/ucb; do
++ IFS="$lt_save_ifs"
++ if (test -f $dir/echo || test -f $dir/echo$ac_exeext) &&
++ test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' &&
++ echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` &&
++ test "X$echo_testing_string" = "X$echo_test_string"; then
++ ECHO="$dir/echo"
++ break
++ fi
++ done
++ IFS="$lt_save_ifs"
+
+-# AC_LIBTOOL_SYS_LIB_STRIP
+-# ------------------------
+-AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP],
+-[striplib=
+-old_striplib=
+-AC_MSG_CHECKING([whether stripping libraries is possible])
+-if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then
+- test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
+- test -z "$striplib" && striplib="$STRIP --strip-unneeded"
+- AC_MSG_RESULT([yes])
+-else
+-# FIXME - insert some real tests, host_os isn't really good enough
+- case $host_os in
+- darwin*)
+- if test -n "$STRIP" ; then
+- striplib="$STRIP -x"
+- AC_MSG_RESULT([yes])
+- else
+- AC_MSG_RESULT([no])
+-fi
+- ;;
+- *)
+- AC_MSG_RESULT([no])
+- ;;
+- esac
+-fi
+-])# AC_LIBTOOL_SYS_LIB_STRIP
++ if test "X$ECHO" = Xecho; then
++ # We didn't find a better echo, so look for alternatives.
++ if test "X`{ print -r '\t'; } 2>/dev/null`" = 'X\t' &&
++ echo_testing_string=`{ print -r "$echo_test_string"; } 2>/dev/null` &&
++ test "X$echo_testing_string" = "X$echo_test_string"; then
++ # This shell has a builtin print -r that does the trick.
++ ECHO='print -r'
++ elif { test -f /bin/ksh || test -f /bin/ksh$ac_exeext; } &&
++ test "X$CONFIG_SHELL" != X/bin/ksh; then
++ # If we have ksh, try running configure again with it.
++ ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
++ export ORIGINAL_CONFIG_SHELL
++ CONFIG_SHELL=/bin/ksh
++ export CONFIG_SHELL
++ exec $CONFIG_SHELL "[$]0" --no-reexec ${1+"[$]@"}
++ else
++ # Try using printf.
++ ECHO='printf %s\n'
++ if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' &&
++ echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` &&
++ test "X$echo_testing_string" = "X$echo_test_string"; then
++ # Cool, printf works
++ :
++ elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` &&
++ test "X$echo_testing_string" = 'X\t' &&
++ echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
++ test "X$echo_testing_string" = "X$echo_test_string"; then
++ CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL
++ export CONFIG_SHELL
++ SHELL="$CONFIG_SHELL"
++ export SHELL
++ ECHO="$CONFIG_SHELL [$]0 --fallback-echo"
++ elif echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` &&
++ test "X$echo_testing_string" = 'X\t' &&
++ echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
++ test "X$echo_testing_string" = "X$echo_test_string"; then
++ ECHO="$CONFIG_SHELL [$]0 --fallback-echo"
++ else
++ # maybe with a smaller string...
++ prev=:
+
++ for cmd in 'echo test' 'sed 2q "[$]0"' 'sed 10q "[$]0"' 'sed 20q "[$]0"' 'sed 50q "[$]0"'; do
++ if { test "X$echo_test_string" = "X`eval $cmd`"; } 2>/dev/null
++ then
++ break
++ fi
++ prev="$cmd"
++ done
+
+-# AC_LIBTOOL_SYS_DYNAMIC_LINKER
+-# -----------------------------
+-# PORTME Fill in your ld.so characteristics
+-AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER],
+-[AC_MSG_CHECKING([dynamic linker characteristics])
+-library_names_spec=
+-libname_spec='lib$name'
+-soname_spec=
+-shrext_cmds=".so"
+-postinstall_cmds=
+-postuninstall_cmds=
+-finish_cmds=
+-finish_eval=
+-shlibpath_var=
+-shlibpath_overrides_runpath=unknown
+-version_type=none
+-dynamic_linker="$host_os ld.so"
+-sys_lib_dlsearch_path_spec="/lib /usr/lib"
+-if test "$GCC" = yes; then
+- sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+- if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then
+- # if the path contains ";" then we assume it to be the separator
+- # otherwise default to the standard path separator (i.e. ":") - it is
+- # assumed that no part of a normal pathname contains ";" but that should
+- # okay in the real world where ";" in dirpaths is itself problematic.
+- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+- else
+- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
++ if test "$prev" != 'sed 50q "[$]0"'; then
++ echo_test_string=`eval $prev`
++ export echo_test_string
++ exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "[$]0" ${1+"[$]@"}
++ else
++ # Oops. We lost completely, so just stick with echo.
++ ECHO=echo
++ fi
++ fi
++ fi
++ fi
+ fi
+-else
+- sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+ fi
+-need_lib_prefix=unknown
+-hardcode_into_libs=no
+
+-# when you set need_version to no, make sure it does not cause -set_version
+-# flags to be left without arguments
+-need_version=unknown
++# Copy echo and quote the copy suitably for passing to libtool from
++# the Makefile, instead of quoting the original, which is used later.
++lt_ECHO=$ECHO
++if test "X$lt_ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then
++ lt_ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo"
++fi
+
+-case $host_os in
+-aix3*)
+- version_type=linux
+- library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+- shlibpath_var=LIBPATH
++AC_SUBST(lt_ECHO)
++])
++_LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts])
++_LT_DECL([], [ECHO], [1],
++ [An echo program that does not interpret backslashes])
++])# _LT_PROG_ECHO_BACKSLASH
+
+- # AIX 3 has no versioning support, so we append a major version to the name.
+- soname_spec='${libname}${release}${shared_ext}$major'
+- ;;
+
+-aix4* | aix5*)
+- version_type=linux
+- need_lib_prefix=no
+- need_version=no
+- hardcode_into_libs=yes
+- if test "$host_cpu" = ia64; then
+- # AIX 5 supports IA64
+- library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+- shlibpath_var=LD_LIBRARY_PATH
+- else
+- # With GCC up to 2.95.x, collect2 would create an import file
+- # for dependence libraries. The import file would start with
+- # the line `#! .'. This would cause the generated library to
+- # depend on `.', always an invalid library. This was fixed in
+- # development snapshots of GCC prior to 3.0.
+- case $host_os in
+- aix4 | aix4.[[01]] | aix4.[[01]].*)
+- if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
+- echo ' yes '
+- echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then
+- :
+- else
+- can_build_shared=no
+- fi
+- ;;
++# _LT_ENABLE_LOCK
++# ---------------
++m4_defun([_LT_ENABLE_LOCK],
++[AC_ARG_ENABLE([libtool-lock],
++ [AS_HELP_STRING([--disable-libtool-lock],
++ [avoid locking (might break parallel builds)])])
++test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
++
++# Some flags need to be propagated to the compiler or linker for good
++# libtool support.
++case $host in
++ia64-*-hpux*)
++ # Find out which ABI we are using.
++ echo 'int i;' > conftest.$ac_ext
++ if AC_TRY_EVAL(ac_compile); then
++ case `/usr/bin/file conftest.$ac_objext` in
++ *ELF-32*)
++ HPUX_IA64_MODE="32"
++ ;;
++ *ELF-64*)
++ HPUX_IA64_MODE="64"
++ ;;
+ esac
+- # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+- # soname into executable. Probably we can add versioning support to
+- # collect2, so additional links can be useful in future.
+- if test "$aix_use_runtimelinking" = yes; then
+- # If using run time linking (on AIX 4.2 or later) use lib<name>.so
+- # instead of lib<name>.a to let people know that these are not
+- # typical AIX shared libraries.
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
++ fi
++ rm -rf conftest*
++ ;;
++*-*-irix6*)
++ # Find out which ABI we are using.
++ echo '[#]line __oline__ "configure"' > conftest.$ac_ext
++ if AC_TRY_EVAL(ac_compile); then
++ if test "$lt_cv_prog_gnu_ld" = yes; then
++ case `/usr/bin/file conftest.$ac_objext` in
++ *32-bit*)
++ LD="${LD-ld} -melf32bsmip"
++ ;;
++ *N32*)
++ LD="${LD-ld} -melf32bmipn32"
++ ;;
++ *64-bit*)
++ LD="${LD-ld} -melf64bmip"
++ ;;
++ esac
+ else
+- # We preserve .a as extension for shared libraries through AIX4.2
+- # and later when we are not doing run time linking.
+- library_names_spec='${libname}${release}.a $libname.a'
+- soname_spec='${libname}${release}${shared_ext}$major'
++ case `/usr/bin/file conftest.$ac_objext` in
++ *32-bit*)
++ LD="${LD-ld} -32"
++ ;;
++ *N32*)
++ LD="${LD-ld} -n32"
++ ;;
++ *64-bit*)
++ LD="${LD-ld} -64"
++ ;;
++ esac
+ fi
+- shlibpath_var=LIBPATH
+ fi
++ rm -rf conftest*
+ ;;
+
+-amigaos*)
+- library_names_spec='$libname.ixlibrary $libname.a'
+- # Create ${libname}_ixlibrary.a entries in /sys/libs.
+- finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
++x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
++s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
++ # Find out which ABI we are using.
++ echo 'int i;' > conftest.$ac_ext
++ if AC_TRY_EVAL(ac_compile); then
++ case `/usr/bin/file conftest.o` in
++ *32-bit*)
++ case $host in
++ x86_64-*kfreebsd*-gnu)
++ LD="${LD-ld} -m elf_i386_fbsd"
++ ;;
++ x86_64-*linux*)
++ LD="${LD-ld} -m elf_i386"
++ ;;
++ ppc64-*linux*|powerpc64-*linux*)
++ LD="${LD-ld} -m elf32ppclinux"
++ ;;
++ s390x-*linux*)
++ LD="${LD-ld} -m elf_s390"
++ ;;
++ sparc64-*linux*)
++ LD="${LD-ld} -m elf32_sparc"
++ ;;
++ esac
++ ;;
++ *64-bit*)
++ case $host in
++ x86_64-*kfreebsd*-gnu)
++ LD="${LD-ld} -m elf_x86_64_fbsd"
++ ;;
++ x86_64-*linux*)
++ LD="${LD-ld} -m elf_x86_64"
++ ;;
++ ppc*-*linux*|powerpc*-*linux*)
++ LD="${LD-ld} -m elf64ppc"
++ ;;
++ s390*-*linux*|s390*-*tpf*)
++ LD="${LD-ld} -m elf64_s390"
++ ;;
++ sparc*-*linux*)
++ LD="${LD-ld} -m elf64_sparc"
++ ;;
++ esac
++ ;;
++ esac
++ fi
++ rm -rf conftest*
+ ;;
+
+-beos*)
+- library_names_spec='${libname}${shared_ext}'
+- dynamic_linker="$host_os ld.so"
+- shlibpath_var=LIBRARY_PATH
++*-*-sco3.2v5*)
++ # On SCO OpenServer 5, we need -belf to get full-featured binaries.
++ SAVE_CFLAGS="$CFLAGS"
++ CFLAGS="$CFLAGS -belf"
++ AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
++ [AC_LANG_PUSH(C)
++ AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])
++ AC_LANG_POP])
++ if test x"$lt_cv_cc_needs_belf" != x"yes"; then
++ # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
++ CFLAGS="$SAVE_CFLAGS"
++ fi
+ ;;
+-
+-bsdi[[45]]*)
+- version_type=linux
+- need_version=no
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
+- shlibpath_var=LD_LIBRARY_PATH
+- sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
+- sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
+- # the default ld.so.conf also contains /usr/contrib/lib and
+- # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
+- # libtool to hard-code these into programs
++sparc*-*solaris*)
++ # Find out which ABI we are using.
++ echo 'int i;' > conftest.$ac_ext
++ if AC_TRY_EVAL(ac_compile); then
++ case `/usr/bin/file conftest.o` in
++ *64-bit*)
++ case $lt_cv_prog_gnu_ld in
++ yes*) LD="${LD-ld} -m elf64_sparc" ;;
++ *)
++ if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then
++ LD="${LD-ld} -64"
++ fi
++ ;;
++ esac
++ ;;
++ esac
++ fi
++ rm -rf conftest*
+ ;;
++esac
+
+-cygwin* | mingw* | pw32*)
+- version_type=windows
+- shrext_cmds=".dll"
+- need_version=no
+- need_lib_prefix=no
++need_locks="$enable_libtool_lock"
++])# _LT_ENABLE_LOCK
+
+- case $GCC,$host_os in
+- yes,cygwin* | yes,mingw* | yes,pw32*)
+- library_names_spec='$libname.dll.a'
+- # DLL is installed to $(libdir)/../bin by postinstall_cmds
+- postinstall_cmds='base_file=`basename \${file}`~
+- dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
+- dldir=$destdir/`dirname \$dlpath`~
+- test -d \$dldir || mkdir -p \$dldir~
+- $install_prog $dir/$dlname \$dldir/$dlname~
+- chmod a+x \$dldir/$dlname'
+- postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+- dlpath=$dir/\$dldll~
+- $rm \$dlpath'
+- shlibpath_overrides_runpath=yes
+
+- case $host_os in
+- cygwin*)
+- # Cygwin DLLs use 'cyg' prefix rather than 'lib'
+- soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+- sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
+- ;;
+- mingw*)
+- # MinGW DLLs use traditional 'lib' prefix
+- soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+- sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+- if echo "$sys_lib_search_path_spec" | [grep ';[c-zC-Z]:/' >/dev/null]; then
+- # It is most probably a Windows format PATH printed by
+- # mingw gcc, but we are running on Cygwin. Gcc prints its search
+- # path with ; separators, and with drive letters. We can handle the
+- # drive letters (cygwin fileutils understands them), so leave them,
+- # especially as we might pass files found there to a mingw objdump,
+- # which wouldn't understand a cygwinified path. Ahh.
+- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+- else
+- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
+- fi
+- ;;
+- pw32*)
+- # pw32 DLLs use 'pw' prefix rather than 'lib'
+- library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+- ;;
+- esac
+- ;;
++# _LT_CMD_OLD_ARCHIVE
++# -------------------
++m4_defun([_LT_CMD_OLD_ARCHIVE],
++[AC_CHECK_TOOL(AR, ar, false)
++test -z "$AR" && AR=ar
++test -z "$AR_FLAGS" && AR_FLAGS=cru
++_LT_DECL([], [AR], [1], [The archiver])
++_LT_DECL([], [AR_FLAGS], [1])
++
++AC_CHECK_TOOL(STRIP, strip, :)
++test -z "$STRIP" && STRIP=:
++_LT_DECL([], [STRIP], [1], [A symbol stripping program])
++
++AC_CHECK_TOOL(RANLIB, ranlib, :)
++test -z "$RANLIB" && RANLIB=:
++_LT_DECL([], [RANLIB], [1],
++ [Commands used to install an old-style archive])
++
++# Determine commands to create old-style static archives.
++old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs'
++old_postinstall_cmds='chmod 644 $oldlib'
++old_postuninstall_cmds=
+
++if test -n "$RANLIB"; then
++ case $host_os in
++ openbsd*)
++ old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib"
++ ;;
+ *)
+- library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib'
++ old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib"
+ ;;
+ esac
+- dynamic_linker='Win32 ld.exe'
+- # FIXME: first we should search . and the directory the executable is in
+- shlibpath_var=PATH
+- ;;
++ old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
++fi
++_LT_DECL([], [old_postinstall_cmds], [2])
++_LT_DECL([], [old_postuninstall_cmds], [2])
++_LT_TAGDECL([], [old_archive_cmds], [2],
++ [Commands used to build an old-style archive])
++])# _LT_CMD_OLD_ARCHIVE
+
+-darwin* | rhapsody*)
+- dynamic_linker="$host_os dyld"
+- version_type=darwin
+- need_lib_prefix=no
+- need_version=no
+- library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext'
+- soname_spec='${libname}${release}${major}$shared_ext'
+- shlibpath_overrides_runpath=yes
+- shlibpath_var=DYLD_LIBRARY_PATH
+- shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
+- # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same.
+- if test "$GCC" = yes; then
+- sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"`
+- else
+- sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib'
+- fi
+- sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
+- ;;
+
+-dgux*)
+- version_type=linux
+- need_lib_prefix=no
+- need_version=no
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- shlibpath_var=LD_LIBRARY_PATH
+- ;;
++# _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
++# [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE])
++# ----------------------------------------------------------------
++# Check whether the given compiler option works
++AC_DEFUN([_LT_COMPILER_OPTION],
++[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
++m4_require([_LT_DECL_SED])dnl
++AC_CACHE_CHECK([$1], [$2],
++ [$2=no
++ m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4])
++ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
++ lt_compiler_flag="$3"
++ # Insert the option either (1) after the last *FLAGS variable, or
++ # (2) before a word containing "conftest.", or (3) at the end.
++ # Note that $ac_compile itself does not contain backslashes and begins
++ # with a dollar sign (not a hyphen), so the echo should work correctly.
++ # The option is referenced via a variable to avoid confusing sed.
++ lt_compile=`echo "$ac_compile" | $SED \
++ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
++ -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
++ -e 's:$: $lt_compiler_flag:'`
++ (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
++ (eval "$lt_compile" 2>conftest.err)
++ ac_status=$?
++ cat conftest.err >&AS_MESSAGE_LOG_FD
++ echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
++ if (exit $ac_status) && test -s "$ac_outfile"; then
++ # The compiler can only warn and ignore the option if not recognized
++ # So say no if there are warnings other than the usual output.
++ $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
++ $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
++ if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
++ $2=yes
++ fi
++ fi
++ $RM conftest*
++])
+
+-freebsd1*)
+- dynamic_linker=no
+- ;;
++if test x"[$]$2" = xyes; then
++ m4_if([$5], , :, [$5])
++else
++ m4_if([$6], , :, [$6])
++fi
++])# _LT_COMPILER_OPTION
+
+-kfreebsd*-gnu)
+- version_type=linux
+- need_lib_prefix=no
+- need_version=no
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- shlibpath_var=LD_LIBRARY_PATH
+- shlibpath_overrides_runpath=no
+- hardcode_into_libs=yes
+- dynamic_linker='GNU ld.so'
+- ;;
++# Old name:
++AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION])
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], [])
+
+-freebsd* | dragonfly*)
+- # DragonFly does not have aout. When/if they implement a new
+- # versioning mechanism, adjust this.
+- if test -x /usr/bin/objformat; then
+- objformat=`/usr/bin/objformat`
+- else
+- case $host_os in
+- freebsd[[123]]*) objformat=aout ;;
+- *) objformat=elf ;;
+- esac
+- fi
+- version_type=freebsd-$objformat
+- case $version_type in
+- freebsd-elf*)
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+- need_version=no
+- need_lib_prefix=no
+- ;;
+- freebsd-*)
+- library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+- need_version=yes
+- ;;
+- esac
+- shlibpath_var=LD_LIBRARY_PATH
+- case $host_os in
+- freebsd2*)
+- shlibpath_overrides_runpath=yes
+- ;;
+- freebsd3.[[01]]* | freebsdelf3.[[01]]*)
+- shlibpath_overrides_runpath=yes
+- hardcode_into_libs=yes
++
++# _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
++# [ACTION-SUCCESS], [ACTION-FAILURE])
++# ----------------------------------------------------
++# Check whether the given linker option works
++AC_DEFUN([_LT_LINKER_OPTION],
++[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
++m4_require([_LT_DECL_SED])dnl
++AC_CACHE_CHECK([$1], [$2],
++ [$2=no
++ save_LDFLAGS="$LDFLAGS"
++ LDFLAGS="$LDFLAGS $3"
++ echo "$lt_simple_link_test_code" > conftest.$ac_ext
++ if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
++ # The linker can only warn and ignore the option if not recognized
++ # So say no if there are warnings
++ if test -s conftest.err; then
++ # Append any errors to the config.log.
++ cat conftest.err 1>&AS_MESSAGE_LOG_FD
++ $ECHO "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
++ $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
++ if diff conftest.exp conftest.er2 >/dev/null; then
++ $2=yes
++ fi
++ else
++ $2=yes
++ fi
++ fi
++ $RM -r conftest*
++ LDFLAGS="$save_LDFLAGS"
++])
++
++if test x"[$]$2" = xyes; then
++ m4_if([$4], , :, [$4])
++else
++ m4_if([$5], , :, [$5])
++fi
++])# _LT_LINKER_OPTION
++
++# Old name:
++AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION])
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], [])
++
++
++# LT_CMD_MAX_LEN
++#---------------
++AC_DEFUN([LT_CMD_MAX_LEN],
++[AC_REQUIRE([AC_CANONICAL_HOST])dnl
++# find the maximum length of command line arguments
++AC_MSG_CHECKING([the maximum length of command line arguments])
++AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
++ i=0
++ teststring="ABCD"
++
++ case $build_os in
++ msdosdjgpp*)
++ # On DJGPP, this test can blow up pretty badly due to problems in libc
++ # (any single argument exceeding 2000 bytes causes a buffer overrun
++ # during glob expansion). Even if it were fixed, the result of this
++ # check would be larger than it should be.
++ lt_cv_sys_max_cmd_len=12288; # 12K is about right
+ ;;
+- freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \
+- freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1)
+- shlibpath_overrides_runpath=no
+- hardcode_into_libs=yes
++
++ gnu*)
++ # Under GNU Hurd, this test is not required because there is
++ # no limit to the length of command line arguments.
++ # Libtool will interpret -1 as no limit whatsoever
++ lt_cv_sys_max_cmd_len=-1;
+ ;;
+- freebsd*) # from 4.6 on
+- shlibpath_overrides_runpath=yes
+- hardcode_into_libs=yes
++
++ cygwin* | mingw*)
++ # On Win9x/ME, this test blows up -- it succeeds, but takes
++ # about 5 minutes as the teststring grows exponentially.
++ # Worse, since 9x/ME are not pre-emptively multitasking,
++ # you end up with a "frozen" computer, even though with patience
++ # the test eventually succeeds (with a max line length of 256k).
++ # Instead, let's just punt: use the minimum linelength reported by
++ # all of the supported platforms: 8192 (on NT/2K/XP).
++ lt_cv_sys_max_cmd_len=8192;
+ ;;
+- esac
+- ;;
+
+-gnu*)
+- version_type=linux
+- need_lib_prefix=no
+- need_version=no
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- shlibpath_var=LD_LIBRARY_PATH
+- hardcode_into_libs=yes
+- ;;
++ amigaos*)
++ # On AmigaOS with pdksh, this test takes hours, literally.
++ # So we just punt and use a minimum line length of 8192.
++ lt_cv_sys_max_cmd_len=8192;
++ ;;
+
+-hpux9* | hpux10* | hpux11*)
+- # Give a soname corresponding to the major version so that dld.sl refuses to
+- # link against other versions.
+- version_type=sunos
+- need_lib_prefix=no
+- need_version=no
+- case $host_cpu in
+- ia64*)
+- shrext_cmds='.so'
+- hardcode_into_libs=yes
+- dynamic_linker="$host_os dld.so"
+- shlibpath_var=LD_LIBRARY_PATH
+- shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- if test "X$HPUX_IA64_MODE" = X32; then
+- sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
++ netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
++ # This has been around since 386BSD, at least. Likely further.
++ if test -x /sbin/sysctl; then
++ lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
++ elif test -x /usr/sbin/sysctl; then
++ lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
+ else
+- sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
++ lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs
+ fi
+- sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+- ;;
+- hppa*64*)
+- shrext_cmds='.sl'
+- hardcode_into_libs=yes
+- dynamic_linker="$host_os dld.sl"
+- shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
+- shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
+- sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+- ;;
+- *)
+- shrext_cmds='.sl'
+- dynamic_linker="$host_os dld.sl"
+- shlibpath_var=SHLIB_PATH
+- shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
++ # And add a safety zone
++ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
++ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+ ;;
+- esac
+- # HP-UX runs *really* slowly unless shared libraries are mode 555.
+- postinstall_cmds='chmod 555 $lib'
+- ;;
+
+-interix3*)
+- version_type=linux
+- need_lib_prefix=no
+- need_version=no
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
+- shlibpath_var=LD_LIBRARY_PATH
+- shlibpath_overrides_runpath=no
+- hardcode_into_libs=yes
+- ;;
++ interix*)
++ # We know the value 262144 and hardcode it with a safety zone (like BSD)
++ lt_cv_sys_max_cmd_len=196608
++ ;;
+
+-irix5* | irix6* | nonstopux*)
+- case $host_os in
+- nonstopux*) version_type=nonstopux ;;
+- *)
+- if test "$lt_cv_prog_gnu_ld" = yes; then
+- version_type=linux
+- else
+- version_type=irix
+- fi ;;
+- esac
+- need_lib_prefix=no
+- need_version=no
+- soname_spec='${libname}${release}${shared_ext}$major'
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+- case $host_os in
+- irix5* | nonstopux*)
+- libsuff= shlibsuff=
++ osf*)
++ # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
++ # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
++ # nice to cause kernel panics so lets avoid the loop below.
++ # First set a reasonable default.
++ lt_cv_sys_max_cmd_len=16384
++ #
++ if test -x /sbin/sysconfig; then
++ case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
++ *1*) lt_cv_sys_max_cmd_len=-1 ;;
++ esac
++ fi
++ ;;
++ sco3.2v5*)
++ lt_cv_sys_max_cmd_len=102400
++ ;;
++ sysv5* | sco5v6* | sysv4.2uw2*)
++ kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
++ if test -n "$kargmax"; then
++ lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'`
++ else
++ lt_cv_sys_max_cmd_len=32768
++ fi
+ ;;
+ *)
+- case $LD in # libtool.m4 will add one of these switches to LD
+- *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
+- libsuff= shlibsuff= libmagic=32-bit;;
+- *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
+- libsuff=32 shlibsuff=N32 libmagic=N32;;
+- *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
+- libsuff=64 shlibsuff=64 libmagic=64-bit;;
+- *) libsuff= shlibsuff= libmagic=never-match;;
+- esac
++ lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`
++ if test -n "$lt_cv_sys_max_cmd_len"; then
++ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
++ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
++ else
++ # Make teststring a little bigger before we do anything with it.
++ # a 1K string should be a reasonable start.
++ for i in 1 2 3 4 5 6 7 8 ; do
++ teststring=$teststring$teststring
++ done
++ SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
++ # If test is not a shell built-in, we'll probably end up computing a
++ # maximum length that is only half of the actual maximum length, but
++ # we can't tell.
++ while { test "X"`$SHELL [$]0 --fallback-echo "X$teststring$teststring" 2>/dev/null` \
++ = "XX$teststring$teststring"; } >/dev/null 2>&1 &&
++ test $i != 17 # 1/2 MB should be enough
++ do
++ i=`expr $i + 1`
++ teststring=$teststring$teststring
++ done
++ # Only check the string length outside the loop.
++ lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1`
++ teststring=
++ # Add a significant safety factor because C++ compilers can tack on
++ # massive amounts of additional arguments before passing them to the
++ # linker. It appears as though 1/2 is a usable value.
++ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
++ fi
+ ;;
+ esac
+- shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
+- shlibpath_overrides_runpath=no
+- sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
+- sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+- hardcode_into_libs=yes
+- ;;
++])
++if test -n $lt_cv_sys_max_cmd_len ; then
++ AC_MSG_RESULT($lt_cv_sys_max_cmd_len)
++else
++ AC_MSG_RESULT(none)
++fi
++max_cmd_len=$lt_cv_sys_max_cmd_len
++_LT_DECL([], [max_cmd_len], [0],
++ [What is the maximum length of a command?])
++])# LT_CMD_MAX_LEN
+
+-# No shared lib support for Linux oldld, aout, or coff.
+-linux*oldld* | linux*aout* | linux*coff*)
+- dynamic_linker=no
+- ;;
++# Old name:
++AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN])
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], [])
+
+-# This must be Linux ELF.
+-linux*)
+- version_type=linux
+- need_lib_prefix=no
+- need_version=no
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
+- shlibpath_var=LD_LIBRARY_PATH
+- shlibpath_overrides_runpath=no
+- # This implies no fast_install, which is unacceptable.
+- # Some rework will be needed to allow for fast_install
+- # before this can be enabled.
+- hardcode_into_libs=yes
+
+- # Append ld.so.conf contents to the search path
+- if test -f /etc/ld.so.conf; then
+- lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
+- sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+- fi
++# _LT_HEADER_DLFCN
++# ----------------
++m4_defun([_LT_HEADER_DLFCN],
++[AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl
++])# _LT_HEADER_DLFCN
+
+- # We used to test for /lib/ld.so.1 and disable shared libraries on
+- # powerpc, because MkLinux only supported shared libraries with the
+- # GNU dynamic linker. Since this was broken with cross compilers,
+- # most powerpc-linux boxes support dynamic linking these days and
+- # people can always --disable-shared, the test was removed, and we
+- # assume the GNU/Linux dynamic linker is in use.
+- dynamic_linker='GNU/Linux ld.so'
+- ;;
+
+-knetbsd*-gnu)
+- version_type=linux
+- need_lib_prefix=no
+- need_version=no
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- shlibpath_var=LD_LIBRARY_PATH
+- shlibpath_overrides_runpath=no
+- hardcode_into_libs=yes
+- dynamic_linker='GNU ld.so'
+- ;;
++# _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE,
++# ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING)
++# ----------------------------------------------------------------
++m4_defun([_LT_TRY_DLOPEN_SELF],
++[m4_require([_LT_HEADER_DLFCN])dnl
++if test "$cross_compiling" = yes; then :
++ [$4]
++else
++ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
++ lt_status=$lt_dlunknown
++ cat > conftest.$ac_ext <<_LT_EOF
++[#line __oline__ "configure"
++#include "confdefs.h"
+
+-netbsd*)
+- version_type=sunos
+- need_lib_prefix=no
+- need_version=no
+- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+- finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+- dynamic_linker='NetBSD (a.out) ld.so'
+- else
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- dynamic_linker='NetBSD ld.elf_so'
+- fi
+- shlibpath_var=LD_LIBRARY_PATH
+- shlibpath_overrides_runpath=yes
+- hardcode_into_libs=yes
+- ;;
++#if HAVE_DLFCN_H
++#include <dlfcn.h>
++#endif
+
+-newsos6)
+- version_type=linux
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+- shlibpath_var=LD_LIBRARY_PATH
+- shlibpath_overrides_runpath=yes
+- ;;
++#include <stdio.h>
+
+-nto-qnx*)
+- version_type=linux
+- need_lib_prefix=no
+- need_version=no
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- shlibpath_var=LD_LIBRARY_PATH
+- shlibpath_overrides_runpath=yes
+- ;;
++#ifdef RTLD_GLOBAL
++# define LT_DLGLOBAL RTLD_GLOBAL
++#else
++# ifdef DL_GLOBAL
++# define LT_DLGLOBAL DL_GLOBAL
++# else
++# define LT_DLGLOBAL 0
++# endif
++#endif
+
+-openbsd*)
+- version_type=sunos
+- sys_lib_dlsearch_path_spec="/usr/lib"
+- need_lib_prefix=no
+- # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
+- case $host_os in
+- openbsd3.3 | openbsd3.3.*) need_version=yes ;;
+- *) need_version=no ;;
+- esac
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+- finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+- shlibpath_var=LD_LIBRARY_PATH
+- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+- case $host_os in
+- openbsd2.[[89]] | openbsd2.[[89]].*)
+- shlibpath_overrides_runpath=no
+- ;;
+- *)
+- shlibpath_overrides_runpath=yes
+- ;;
+- esac
++/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
++ find out it does not work in some platform. */
++#ifndef LT_DLLAZY_OR_NOW
++# ifdef RTLD_LAZY
++# define LT_DLLAZY_OR_NOW RTLD_LAZY
++# else
++# ifdef DL_LAZY
++# define LT_DLLAZY_OR_NOW DL_LAZY
++# else
++# ifdef RTLD_NOW
++# define LT_DLLAZY_OR_NOW RTLD_NOW
++# else
++# ifdef DL_NOW
++# define LT_DLLAZY_OR_NOW DL_NOW
++# else
++# define LT_DLLAZY_OR_NOW 0
++# endif
++# endif
++# endif
++# endif
++#endif
++
++#ifdef __cplusplus
++extern "C" void exit (int);
++#endif
++
++void fnord() { int i=42;}
++int main ()
++{
++ void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
++ int status = $lt_dlunknown;
++
++ if (self)
++ {
++ if (dlsym (self,"fnord")) status = $lt_dlno_uscore;
++ else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
++ /* dlclose (self); */
++ }
+ else
+- shlibpath_overrides_runpath=yes
++ puts (dlerror ());
++
++ exit (status);
++}]
++_LT_EOF
++ if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then
++ (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null
++ lt_status=$?
++ case x$lt_status in
++ x$lt_dlno_uscore) $1 ;;
++ x$lt_dlneed_uscore) $2 ;;
++ x$lt_dlunknown|x*) $3 ;;
++ esac
++ else :
++ # compilation failed
++ $3
+ fi
+- ;;
++fi
++rm -fr conftest*
++])# _LT_TRY_DLOPEN_SELF
+
+-os2*)
+- libname_spec='$name'
+- shrext_cmds=".dll"
+- need_lib_prefix=no
+- library_names_spec='$libname${shared_ext} $libname.a'
+- dynamic_linker='OS/2 ld.exe'
+- shlibpath_var=LIBPATH
+- ;;
+
+-osf3* | osf4* | osf5*)
+- version_type=osf
+- need_lib_prefix=no
+- need_version=no
+- soname_spec='${libname}${release}${shared_ext}$major'
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+- shlibpath_var=LD_LIBRARY_PATH
+- sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
+- sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+- ;;
++# LT_SYS_DLOPEN_SELF
++# ------------------
++AC_DEFUN([LT_SYS_DLOPEN_SELF],
++[m4_require([_LT_HEADER_DLFCN])dnl
++if test "x$enable_dlopen" != xyes; then
++ enable_dlopen=unknown
++ enable_dlopen_self=unknown
++ enable_dlopen_self_static=unknown
++else
++ lt_cv_dlopen=no
++ lt_cv_dlopen_libs=
+
+-solaris*)
+- version_type=linux
+- need_lib_prefix=no
+- need_version=no
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- shlibpath_var=LD_LIBRARY_PATH
+- shlibpath_overrides_runpath=yes
+- hardcode_into_libs=yes
+- # ldd complains unless libraries are executable
+- postinstall_cmds='chmod +x $lib'
+- ;;
++ case $host_os in
++ beos*)
++ lt_cv_dlopen="load_add_on"
++ lt_cv_dlopen_libs=
++ lt_cv_dlopen_self=yes
++ ;;
+
+-sunos4*)
+- version_type=sunos
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+- finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
+- shlibpath_var=LD_LIBRARY_PATH
+- shlibpath_overrides_runpath=yes
+- if test "$with_gnu_ld" = yes; then
+- need_lib_prefix=no
+- fi
+- need_version=yes
+- ;;
++ mingw* | pw32*)
++ lt_cv_dlopen="LoadLibrary"
++ lt_cv_dlopen_libs=
++ ;;
+
+-sysv4 | sysv4.3*)
+- version_type=linux
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- shlibpath_var=LD_LIBRARY_PATH
+- case $host_vendor in
+- sni)
+- shlibpath_overrides_runpath=no
+- need_lib_prefix=no
+- export_dynamic_flag_spec='${wl}-Blargedynsym'
+- runpath_var=LD_RUN_PATH
+- ;;
+- siemens)
+- need_lib_prefix=no
+- ;;
+- motorola)
+- need_lib_prefix=no
+- need_version=no
+- shlibpath_overrides_runpath=no
+- sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
+- ;;
+- esac
+- ;;
++ cygwin*)
++ lt_cv_dlopen="dlopen"
++ lt_cv_dlopen_libs=
++ ;;
+
+-sysv4*MP*)
+- if test -d /usr/nec ;then
+- version_type=linux
+- library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
+- soname_spec='$libname${shared_ext}.$major'
+- shlibpath_var=LD_LIBRARY_PATH
+- fi
+- ;;
++ darwin*)
++ # if libdl is installed we need to link against it
++ AC_CHECK_LIB([dl], [dlopen],
++ [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[
++ lt_cv_dlopen="dyld"
++ lt_cv_dlopen_libs=
++ lt_cv_dlopen_self=yes
++ ])
++ ;;
+
+-sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+- version_type=freebsd-elf
+- need_lib_prefix=no
+- need_version=no
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- shlibpath_var=LD_LIBRARY_PATH
+- hardcode_into_libs=yes
+- if test "$with_gnu_ld" = yes; then
+- sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
+- shlibpath_overrides_runpath=no
++ *)
++ AC_CHECK_FUNC([shl_load],
++ [lt_cv_dlopen="shl_load"],
++ [AC_CHECK_LIB([dld], [shl_load],
++ [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"],
++ [AC_CHECK_FUNC([dlopen],
++ [lt_cv_dlopen="dlopen"],
++ [AC_CHECK_LIB([dl], [dlopen],
++ [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],
++ [AC_CHECK_LIB([svld], [dlopen],
++ [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"],
++ [AC_CHECK_LIB([dld], [dld_link],
++ [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"])
++ ])
++ ])
++ ])
++ ])
++ ])
++ ;;
++ esac
++
++ if test "x$lt_cv_dlopen" != xno; then
++ enable_dlopen=yes
+ else
+- sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
+- shlibpath_overrides_runpath=yes
+- case $host_os in
+- sco3.2v5*)
+- sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
+- ;;
+- esac
++ enable_dlopen=no
+ fi
+- sys_lib_dlsearch_path_spec='/usr/lib'
+- ;;
+-
+-uts4*)
+- version_type=linux
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- shlibpath_var=LD_LIBRARY_PATH
+- ;;
+-
+-*)
+- dynamic_linker=no
+- ;;
+-esac
+-AC_MSG_RESULT([$dynamic_linker])
+-test "$dynamic_linker" = no && can_build_shared=no
+-
+-variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
+-if test "$GCC" = yes; then
+- variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
+-fi
+-])# AC_LIBTOOL_SYS_DYNAMIC_LINKER
+-
+
+-# _LT_AC_TAGCONFIG
+-# ----------------
+-AC_DEFUN([_LT_AC_TAGCONFIG],
+-[AC_ARG_WITH([tags],
+- [AC_HELP_STRING([--with-tags@<:@=TAGS@:>@],
+- [include additional configurations @<:@automatic@:>@])],
+- [tagnames="$withval"])
+-
+-if test -f "$ltmain" && test -n "$tagnames"; then
+- if test ! -f "${ofile}"; then
+- AC_MSG_WARN([output file `$ofile' does not exist])
+- fi
++ case $lt_cv_dlopen in
++ dlopen)
++ save_CPPFLAGS="$CPPFLAGS"
++ test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
+
+- if test -z "$LTCC"; then
+- eval "`$SHELL ${ofile} --config | grep '^LTCC='`"
+- if test -z "$LTCC"; then
+- AC_MSG_WARN([output file `$ofile' does not look like a libtool script])
+- else
+- AC_MSG_WARN([using `LTCC=$LTCC', extracted from `$ofile'])
+- fi
+- fi
+- if test -z "$LTCFLAGS"; then
+- eval "`$SHELL ${ofile} --config | grep '^LTCFLAGS='`"
+- fi
++ save_LDFLAGS="$LDFLAGS"
++ wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
+
+- # Extract list of available tagged configurations in $ofile.
+- # Note that this assumes the entire list is on one line.
+- available_tags=`grep "^available_tags=" "${ofile}" | $SED -e 's/available_tags=\(.*$\)/\1/' -e 's/\"//g'`
++ save_LIBS="$LIBS"
++ LIBS="$lt_cv_dlopen_libs $LIBS"
+
+- lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+- for tagname in $tagnames; do
+- IFS="$lt_save_ifs"
+- # Check whether tagname contains only valid characters
+- case `$echo "X$tagname" | $Xsed -e 's:[[-_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890,/]]::g'` in
+- "") ;;
+- *) AC_MSG_ERROR([invalid tag name: $tagname])
+- ;;
+- esac
++ AC_CACHE_CHECK([whether a program can dlopen itself],
++ lt_cv_dlopen_self, [dnl
++ _LT_TRY_DLOPEN_SELF(
++ lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes,
++ lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross)
++ ])
+
+- if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "${ofile}" > /dev/null
+- then
+- AC_MSG_ERROR([tag name \"$tagname\" already exists])
++ if test "x$lt_cv_dlopen_self" = xyes; then
++ wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
++ AC_CACHE_CHECK([whether a statically linked program can dlopen itself],
++ lt_cv_dlopen_self_static, [dnl
++ _LT_TRY_DLOPEN_SELF(
++ lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes,
++ lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross)
++ ])
+ fi
+
+- # Update the list of available tags.
+- if test -n "$tagname"; then
+- echo appending configuration tag \"$tagname\" to $ofile
+-
+- case $tagname in
+- CXX)
+- if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
+- ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
+- (test "X$CXX" != "Xg++"))) ; then
+- AC_LIBTOOL_LANG_CXX_CONFIG
+- else
+- tagname=""
+- fi
+- ;;
+-
+- F77)
+- if test -n "$F77" && test "X$F77" != "Xno"; then
+- AC_LIBTOOL_LANG_F77_CONFIG
+- else
+- tagname=""
+- fi
+- ;;
+-
+- GCJ)
+- if test -n "$GCJ" && test "X$GCJ" != "Xno"; then
+- AC_LIBTOOL_LANG_GCJ_CONFIG
+- else
+- tagname=""
+- fi
+- ;;
+-
+- RC)
+- AC_LIBTOOL_LANG_RC_CONFIG
+- ;;
+-
+- *)
+- AC_MSG_ERROR([Unsupported tag name: $tagname])
+- ;;
+- esac
++ CPPFLAGS="$save_CPPFLAGS"
++ LDFLAGS="$save_LDFLAGS"
++ LIBS="$save_LIBS"
++ ;;
++ esac
+
+- # Append the new tag name to the list of available tags.
+- if test -n "$tagname" ; then
+- available_tags="$available_tags $tagname"
+- fi
+- fi
+- done
+- IFS="$lt_save_ifs"
++ case $lt_cv_dlopen_self in
++ yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
++ *) enable_dlopen_self=unknown ;;
++ esac
+
+- # Now substitute the updated list of available tags.
+- if eval "sed -e 's/^available_tags=.*\$/available_tags=\"$available_tags\"/' \"$ofile\" > \"${ofile}T\""; then
+- mv "${ofile}T" "$ofile"
+- chmod +x "$ofile"
+- else
+- rm -f "${ofile}T"
+- AC_MSG_ERROR([unable to update list of available tagged configurations.])
+- fi
++ case $lt_cv_dlopen_self_static in
++ yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
++ *) enable_dlopen_self_static=unknown ;;
++ esac
+ fi
+-])# _LT_AC_TAGCONFIG
++_LT_DECL([dlopen_support], [enable_dlopen], [0],
++ [Whether dlopen is supported])
++_LT_DECL([dlopen_self], [enable_dlopen_self], [0],
++ [Whether dlopen of programs is supported])
++_LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0],
++ [Whether dlopen of statically linked programs is supported])
++])# LT_SYS_DLOPEN_SELF
++
++# Old name:
++AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF])
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], [])
+
+
+-# AC_LIBTOOL_DLOPEN
+-# -----------------
+-# enable checks for dlopen support
+-AC_DEFUN([AC_LIBTOOL_DLOPEN],
+- [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])
+-])# AC_LIBTOOL_DLOPEN
++# _LT_COMPILER_C_O([TAGNAME])
++# ---------------------------
++# Check to see if options -c and -o are simultaneously supported by compiler.
++# This macro does not hard code the compiler like AC_PROG_CC_C_O.
++m4_defun([_LT_COMPILER_C_O],
++[m4_require([_LT_DECL_SED])dnl
++m4_require([_LT_FILEUTILS_DEFAULTS])dnl
++m4_require([_LT_TAG_COMPILER])dnl
++AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext],
++ [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)],
++ [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no
++ $RM -r conftest 2>/dev/null
++ mkdir conftest
++ cd conftest
++ mkdir out
++ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
++ lt_compiler_flag="-o out/conftest2.$ac_objext"
++ # Insert the option either (1) after the last *FLAGS variable, or
++ # (2) before a word containing "conftest.", or (3) at the end.
++ # Note that $ac_compile itself does not contain backslashes and begins
++ # with a dollar sign (not a hyphen), so the echo should work correctly.
++ lt_compile=`echo "$ac_compile" | $SED \
++ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
++ -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
++ -e 's:$: $lt_compiler_flag:'`
++ (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
++ (eval "$lt_compile" 2>out/conftest.err)
++ ac_status=$?
++ cat out/conftest.err >&AS_MESSAGE_LOG_FD
++ echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
++ if (exit $ac_status) && test -s out/conftest2.$ac_objext
++ then
++ # The compiler can only warn and ignore the option if not recognized
++ # So say no if there are warnings
++ $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
++ $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
++ if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
++ _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
++ fi
++ fi
++ chmod u+w . 2>&AS_MESSAGE_LOG_FD
++ $RM conftest*
++ # SGI C++ compiler will create directory out/ii_files/ for
++ # template instantiation
++ test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
++ $RM out/* && rmdir out
++ cd ..
++ $RM -r conftest
++ $RM conftest*
++])
++_LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1],
++ [Does compiler simultaneously support -c and -o options?])
++])# _LT_COMPILER_C_O
+
+-# AC_LIBTOOL_WIN32_DLL
+-# --------------------
+-# declare package support for building win32 DLLs
+-AC_DEFUN([AC_LIBTOOL_WIN32_DLL],
+-[AC_BEFORE([$0], [AC_LIBTOOL_SETUP])
+-])# AC_LIBTOOL_WIN32_DLL
+
++# _LT_COMPILER_FILE_LOCKS([TAGNAME])
++# ----------------------------------
++# Check to see if we can do hard links to lock some files if needed
++m4_defun([_LT_COMPILER_FILE_LOCKS],
++[m4_require([_LT_ENABLE_LOCK])dnl
++m4_require([_LT_FILEUTILS_DEFAULTS])dnl
++_LT_COMPILER_C_O([$1])
+
+-# AC_ENABLE_SHARED([DEFAULT])
+-# ---------------------------
+-# implement the --enable-shared flag
+-# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
+-AC_DEFUN([AC_ENABLE_SHARED],
+-[define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl
+-AC_ARG_ENABLE([shared],
+- [AC_HELP_STRING([--enable-shared@<:@=PKGS@:>@],
+- [build shared libraries @<:@default=]AC_ENABLE_SHARED_DEFAULT[@:>@])],
+- [p=${PACKAGE-default}
+- case $enableval in
+- yes) enable_shared=yes ;;
+- no) enable_shared=no ;;
+- *)
+- enable_shared=no
+- # Look at the argument we got. We use all the common list separators.
+- lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+- for pkg in $enableval; do
+- IFS="$lt_save_ifs"
+- if test "X$pkg" = "X$p"; then
+- enable_shared=yes
+- fi
+- done
+- IFS="$lt_save_ifs"
+- ;;
+- esac],
+- [enable_shared=]AC_ENABLE_SHARED_DEFAULT)
+-])# AC_ENABLE_SHARED
+-
+-
+-# AC_DISABLE_SHARED
+-# -----------------
+-# set the default shared flag to --disable-shared
+-AC_DEFUN([AC_DISABLE_SHARED],
+-[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+-AC_ENABLE_SHARED(no)
+-])# AC_DISABLE_SHARED
+-
+-
+-# AC_ENABLE_STATIC([DEFAULT])
+-# ---------------------------
+-# implement the --enable-static flag
+-# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
+-AC_DEFUN([AC_ENABLE_STATIC],
+-[define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl
+-AC_ARG_ENABLE([static],
+- [AC_HELP_STRING([--enable-static@<:@=PKGS@:>@],
+- [build static libraries @<:@default=]AC_ENABLE_STATIC_DEFAULT[@:>@])],
+- [p=${PACKAGE-default}
+- case $enableval in
+- yes) enable_static=yes ;;
+- no) enable_static=no ;;
+- *)
+- enable_static=no
+- # Look at the argument we got. We use all the common list separators.
+- lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+- for pkg in $enableval; do
+- IFS="$lt_save_ifs"
+- if test "X$pkg" = "X$p"; then
+- enable_static=yes
+- fi
+- done
+- IFS="$lt_save_ifs"
+- ;;
+- esac],
+- [enable_static=]AC_ENABLE_STATIC_DEFAULT)
+-])# AC_ENABLE_STATIC
+-
+-
+-# AC_DISABLE_STATIC
+-# -----------------
+-# set the default static flag to --disable-static
+-AC_DEFUN([AC_DISABLE_STATIC],
+-[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+-AC_ENABLE_STATIC(no)
+-])# AC_DISABLE_STATIC
+-
+-
+-# AC_ENABLE_FAST_INSTALL([DEFAULT])
+-# ---------------------------------
+-# implement the --enable-fast-install flag
+-# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
+-AC_DEFUN([AC_ENABLE_FAST_INSTALL],
+-[define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl
+-AC_ARG_ENABLE([fast-install],
+- [AC_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@],
+- [optimize for fast installation @<:@default=]AC_ENABLE_FAST_INSTALL_DEFAULT[@:>@])],
+- [p=${PACKAGE-default}
+- case $enableval in
+- yes) enable_fast_install=yes ;;
+- no) enable_fast_install=no ;;
+- *)
+- enable_fast_install=no
+- # Look at the argument we got. We use all the common list separators.
+- lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+- for pkg in $enableval; do
+- IFS="$lt_save_ifs"
+- if test "X$pkg" = "X$p"; then
+- enable_fast_install=yes
+- fi
+- done
+- IFS="$lt_save_ifs"
+- ;;
+- esac],
+- [enable_fast_install=]AC_ENABLE_FAST_INSTALL_DEFAULT)
+-])# AC_ENABLE_FAST_INSTALL
+-
+-
+-# AC_DISABLE_FAST_INSTALL
+-# -----------------------
+-# set the default to --disable-fast-install
+-AC_DEFUN([AC_DISABLE_FAST_INSTALL],
+-[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+-AC_ENABLE_FAST_INSTALL(no)
+-])# AC_DISABLE_FAST_INSTALL
+-
+-
+-# AC_LIBTOOL_PICMODE([MODE])
+-# --------------------------
+-# implement the --with-pic flag
+-# MODE is either `yes' or `no'. If omitted, it defaults to `both'.
+-AC_DEFUN([AC_LIBTOOL_PICMODE],
+-[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+-pic_mode=ifelse($#,1,$1,default)
+-])# AC_LIBTOOL_PICMODE
+-
+-
+-# AC_PROG_EGREP
+-# -------------
+-# This is predefined starting with Autoconf 2.54, so this conditional
+-# definition can be removed once we require Autoconf 2.54 or later.
+-m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP],
+-[AC_CACHE_CHECK([for egrep], [ac_cv_prog_egrep],
+- [if echo a | (grep -E '(a|b)') >/dev/null 2>&1
+- then ac_cv_prog_egrep='grep -E'
+- else ac_cv_prog_egrep='egrep'
+- fi])
+- EGREP=$ac_cv_prog_egrep
+- AC_SUBST([EGREP])
+-])])
+-
+-
+-# AC_PATH_TOOL_PREFIX
+-# -------------------
+-# find a file program which can recognise shared library
+-AC_DEFUN([AC_PATH_TOOL_PREFIX],
+-[AC_REQUIRE([AC_PROG_EGREP])dnl
+-AC_MSG_CHECKING([for $1])
+-AC_CACHE_VAL(lt_cv_path_MAGIC_CMD,
+-[case $MAGIC_CMD in
+-[[\\/*] | ?:[\\/]*])
+- lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+- ;;
+-*)
+- lt_save_MAGIC_CMD="$MAGIC_CMD"
+- lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+-dnl $ac_dummy forces splitting on constant user-supplied paths.
+-dnl POSIX.2 word splitting is done only on the output of word expansions,
+-dnl not every word. This closes a longstanding sh security hole.
+- ac_dummy="ifelse([$2], , $PATH, [$2])"
+- for ac_dir in $ac_dummy; do
+- IFS="$lt_save_ifs"
+- test -z "$ac_dir" && ac_dir=.
+- if test -f $ac_dir/$1; then
+- lt_cv_path_MAGIC_CMD="$ac_dir/$1"
+- if test -n "$file_magic_test_file"; then
+- case $deplibs_check_method in
+- "file_magic "*)
+- file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
+- MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+- if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
+- $EGREP "$file_magic_regex" > /dev/null; then
+- :
+- else
+- cat <<EOF 1>&2
++hard_links="nottested"
++if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then
++ # do not overwrite the value of need_locks provided by the user
++ AC_MSG_CHECKING([if we can lock with hard links])
++ hard_links=yes
++ $RM conftest*
++ ln conftest.a conftest.b 2>/dev/null && hard_links=no
++ touch conftest.a
++ ln conftest.a conftest.b 2>&5 || hard_links=no
++ ln conftest.a conftest.b 2>/dev/null && hard_links=no
++ AC_MSG_RESULT([$hard_links])
++ if test "$hard_links" = no; then
++ AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe])
++ need_locks=warn
++ fi
++else
++ need_locks=no
++fi
++_LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?])
++])# _LT_COMPILER_FILE_LOCKS
+
+-*** Warning: the command libtool uses to detect shared libraries,
+-*** $file_magic_cmd, produces output that libtool cannot recognize.
+-*** The result is that libtool may fail to recognize shared libraries
+-*** as such. This will affect the creation of libtool libraries that
+-*** depend on shared libraries, but programs linked with such libtool
+-*** libraries will work regardless of this problem. Nevertheless, you
+-*** may want to report the problem to your system manager and/or to
+-*** bug-libtool@gnu.org
+
+-EOF
+- fi ;;
+- esac
+- fi
+- break
+- fi
+- done
+- IFS="$lt_save_ifs"
+- MAGIC_CMD="$lt_save_MAGIC_CMD"
+- ;;
+-esac])
+-MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+-if test -n "$MAGIC_CMD"; then
+- AC_MSG_RESULT($MAGIC_CMD)
++# _LT_CHECK_OBJDIR
++# ----------------
++m4_defun([_LT_CHECK_OBJDIR],
++[AC_CACHE_CHECK([for objdir], [lt_cv_objdir],
++[rm -f .libs 2>/dev/null
++mkdir .libs 2>/dev/null
++if test -d .libs; then
++ lt_cv_objdir=.libs
+ else
+- AC_MSG_RESULT(no)
++ # MS-DOS does not allow filenames that begin with a dot.
++ lt_cv_objdir=_libs
+ fi
+-])# AC_PATH_TOOL_PREFIX
++rmdir .libs 2>/dev/null])
++objdir=$lt_cv_objdir
++_LT_DECL([], [objdir], [0],
++ [The name of the directory that contains temporary libtool files])dnl
++m4_pattern_allow([LT_OBJDIR])dnl
++AC_DEFINE_UNQUOTED(LT_OBJDIR, "$lt_cv_objdir/",
++ [Define to the sub-directory in which libtool stores uninstalled libraries.])
++])# _LT_CHECK_OBJDIR
+
+
+-# AC_PATH_MAGIC
+-# -------------
+-# find a file program which can recognise a shared library
+-AC_DEFUN([AC_PATH_MAGIC],
+-[AC_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH)
+-if test -z "$lt_cv_path_MAGIC_CMD"; then
+- if test -n "$ac_tool_prefix"; then
+- AC_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH)
++# _LT_LINKER_HARDCODE_LIBPATH([TAGNAME])
++# --------------------------------------
++# Check hardcoding attributes.
++m4_defun([_LT_LINKER_HARDCODE_LIBPATH],
++[AC_MSG_CHECKING([how to hardcode library paths into programs])
++_LT_TAGVAR(hardcode_action, $1)=
++if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" ||
++ test -n "$_LT_TAGVAR(runpath_var, $1)" ||
++ test "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then
++
++ # We can hardcode non-existent directories.
++ if test "$_LT_TAGVAR(hardcode_direct, $1)" != no &&
++ # If the only mechanism to avoid hardcoding is shlibpath_var, we
++ # have to relink, otherwise we might link with an installed library
++ # when we should be linking with a yet-to-be-installed one
++ ## test "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" != no &&
++ test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; then
++ # Linking always hardcodes the temporary library directory.
++ _LT_TAGVAR(hardcode_action, $1)=relink
+ else
+- MAGIC_CMD=:
++ # We can link without hardcoding, and we can hardcode nonexisting dirs.
++ _LT_TAGVAR(hardcode_action, $1)=immediate
+ fi
++else
++ # We cannot hardcode anything, or else we can only hardcode existing
++ # directories.
++ _LT_TAGVAR(hardcode_action, $1)=unsupported
++fi
++AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)])
++
++if test "$_LT_TAGVAR(hardcode_action, $1)" = relink ||
++ test "$_LT_TAGVAR(inherit_rpath, $1)" = yes; then
++ # Fast installation is not supported
++ enable_fast_install=no
++elif test "$shlibpath_overrides_runpath" = yes ||
++ test "$enable_shared" = no; then
++ # Fast installation is not necessary
++ enable_fast_install=needless
+ fi
+-])# AC_PATH_MAGIC
++_LT_TAGDECL([], [hardcode_action], [0],
++ [How to hardcode a shared library path into an executable])
++])# _LT_LINKER_HARDCODE_LIBPATH
+
+
+-# AC_PROG_LD
+-# ----------
+-# find the pathname to the GNU or non-GNU linker
+-AC_DEFUN([AC_PROG_LD],
+-[AC_ARG_WITH([gnu-ld],
+- [AC_HELP_STRING([--with-gnu-ld],
+- [assume the C compiler uses GNU ld @<:@default=no@:>@])],
+- [test "$withval" = no || with_gnu_ld=yes],
+- [with_gnu_ld=no])
+-AC_REQUIRE([LT_AC_PROG_SED])dnl
+-AC_REQUIRE([AC_PROG_CC])dnl
+-AC_REQUIRE([AC_CANONICAL_HOST])dnl
+-AC_REQUIRE([AC_CANONICAL_BUILD])dnl
+-ac_prog=ld
+-if test "$GCC" = yes; then
+- # Check if gcc -print-prog-name=ld gives a path.
+- AC_MSG_CHECKING([for ld used by $CC])
+- case $host in
+- *-*-mingw*)
+- # gcc leaves a trailing carriage return which upsets mingw
+- ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
+- *)
+- ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
+- esac
+- case $ac_prog in
+- # Accept absolute paths.
+- [[\\/]]* | ?:[[\\/]]*)
+- re_direlt='/[[^/]][[^/]]*/\.\./'
+- # Canonicalize the pathname of ld
+- ac_prog=`echo $ac_prog| $SED 's%\\\\%/%g'`
+- while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
+- ac_prog=`echo $ac_prog| $SED "s%$re_direlt%/%"`
+- done
+- test -z "$LD" && LD="$ac_prog"
+- ;;
+- "")
+- # If it fails, then pretend we aren't using GCC.
+- ac_prog=ld
++# _LT_CMD_STRIPLIB
++# ----------------
++m4_defun([_LT_CMD_STRIPLIB],
++[m4_require([_LT_DECL_EGREP])
++striplib=
++old_striplib=
++AC_MSG_CHECKING([whether stripping libraries is possible])
++if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then
++ test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
++ test -z "$striplib" && striplib="$STRIP --strip-unneeded"
++ AC_MSG_RESULT([yes])
++else
++# FIXME - insert some real tests, host_os isn't really good enough
++ case $host_os in
++ darwin*)
++ if test -n "$STRIP" ; then
++ striplib="$STRIP -x"
++ old_striplib="$STRIP -S"
++ AC_MSG_RESULT([yes])
++ else
++ AC_MSG_RESULT([no])
++ fi
+ ;;
+ *)
+- # If it is relative, then search for the first ld in PATH.
+- with_gnu_ld=unknown
++ AC_MSG_RESULT([no])
+ ;;
+ esac
+-elif test "$with_gnu_ld" = yes; then
+- AC_MSG_CHECKING([for GNU ld])
+-else
+- AC_MSG_CHECKING([for non-GNU ld])
+ fi
+-AC_CACHE_VAL(lt_cv_path_LD,
+-[if test -z "$LD"; then
+- lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+- for ac_dir in $PATH; do
+- IFS="$lt_save_ifs"
+- test -z "$ac_dir" && ac_dir=.
+- if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+- lt_cv_path_LD="$ac_dir/$ac_prog"
+- # Check to see if the program is GNU ld. I'd rather use --version,
+- # but apparently some variants of GNU ld only accept -v.
+- # Break only if it was the GNU/non-GNU ld that we prefer.
+- case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
+- *GNU* | *'with BFD'*)
+- test "$with_gnu_ld" != no && break
+- ;;
+- *)
+- test "$with_gnu_ld" != yes && break
+- ;;
+- esac
++_LT_DECL([], [old_striplib], [1], [Commands to strip libraries])
++_LT_DECL([], [striplib], [1])
++])# _LT_CMD_STRIPLIB
++
++
++# _LT_SYS_DYNAMIC_LINKER([TAG])
++# -----------------------------
++# PORTME Fill in your ld.so characteristics
++m4_defun([_LT_SYS_DYNAMIC_LINKER],
++[AC_REQUIRE([AC_CANONICAL_HOST])dnl
++m4_require([_LT_DECL_EGREP])dnl
++m4_require([_LT_FILEUTILS_DEFAULTS])dnl
++m4_require([_LT_DECL_SED])dnl
++AC_MSG_CHECKING([dynamic linker characteristics])
++m4_if([$1],
++ [], [
++if test "$GCC" = yes; then
++ case $host_os in
++ darwin*) lt_awk_arg="/^libraries:/,/LR/" ;;
++ *) lt_awk_arg="/^libraries:/" ;;
++ esac
++ lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e "s,=/,/,g"`
++ if $ECHO "$lt_search_path_spec" | $GREP ';' >/dev/null ; then
++ # if the path contains ";" then we assume it to be the separator
++ # otherwise default to the standard path separator (i.e. ":") - it is
++ # assumed that no part of a normal pathname contains ";" but that should
++ # okay in the real world where ";" in dirpaths is itself problematic.
++ lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e 's/;/ /g'`
++ else
++ lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
++ fi
++ # Ok, now we have the path, separated by spaces, we can step through it
++ # and add multilib dir if necessary.
++ lt_tmp_lt_search_path_spec=
++ lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
++ for lt_sys_path in $lt_search_path_spec; do
++ if test -d "$lt_sys_path/$lt_multi_os_dir"; then
++ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir"
++ else
++ test -d "$lt_sys_path" && \
++ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path"
+ fi
+ done
+- IFS="$lt_save_ifs"
++ lt_search_path_spec=`$ECHO $lt_tmp_lt_search_path_spec | awk '
++BEGIN {RS=" "; FS="/|\n";} {
++ lt_foo="";
++ lt_count=0;
++ for (lt_i = NF; lt_i > 0; lt_i--) {
++ if ($lt_i != "" && $lt_i != ".") {
++ if ($lt_i == "..") {
++ lt_count++;
++ } else {
++ if (lt_count == 0) {
++ lt_foo="/" $lt_i lt_foo;
++ } else {
++ lt_count--;
++ }
++ }
++ }
++ }
++ if (lt_foo != "") { lt_freq[[lt_foo]]++; }
++ if (lt_freq[[lt_foo]] == 1) { print lt_foo; }
++}'`
++ sys_lib_search_path_spec=`$ECHO $lt_search_path_spec`
+ else
+- lt_cv_path_LD="$LD" # Let the user override the test with a path.
++ sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+ fi])
+-LD="$lt_cv_path_LD"
+-if test -n "$LD"; then
+- AC_MSG_RESULT($LD)
+-else
+- AC_MSG_RESULT(no)
+-fi
+-test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
+-AC_PROG_LD_GNU
+-])# AC_PROG_LD
++library_names_spec=
++libname_spec='lib$name'
++soname_spec=
++shrext_cmds=".so"
++postinstall_cmds=
++postuninstall_cmds=
++finish_cmds=
++finish_eval=
++shlibpath_var=
++shlibpath_overrides_runpath=unknown
++version_type=none
++dynamic_linker="$host_os ld.so"
++sys_lib_dlsearch_path_spec="/lib /usr/lib"
++need_lib_prefix=unknown
++hardcode_into_libs=no
++
++# when you set need_version to no, make sure it does not cause -set_version
++# flags to be left without arguments
++need_version=unknown
+
++case $host_os in
++aix3*)
++ version_type=linux
++ library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
++ shlibpath_var=LIBPATH
+
+-# AC_PROG_LD_GNU
+-# --------------
+-AC_DEFUN([AC_PROG_LD_GNU],
+-[AC_REQUIRE([AC_PROG_EGREP])dnl
+-AC_CACHE_CHECK([if the linker ($LD) is GNU ld], lt_cv_prog_gnu_ld,
+-[# I'd rather use --version here, but apparently some GNU lds only accept -v.
+-case `$LD -v 2>&1 </dev/null` in
+-*GNU* | *'with BFD'*)
+- lt_cv_prog_gnu_ld=yes
++ # AIX 3 has no versioning support, so we append a major version to the name.
++ soname_spec='${libname}${release}${shared_ext}$major'
+ ;;
+-*)
+- lt_cv_prog_gnu_ld=no
+- ;;
+-esac])
+-with_gnu_ld=$lt_cv_prog_gnu_ld
+-])# AC_PROG_LD_GNU
+-
+
+-# AC_PROG_LD_RELOAD_FLAG
+-# ----------------------
+-# find reload flag for linker
+-# -- PORTME Some linkers may need a different reload flag.
+-AC_DEFUN([AC_PROG_LD_RELOAD_FLAG],
+-[AC_CACHE_CHECK([for $LD option to reload object files],
+- lt_cv_ld_reload_flag,
+- [lt_cv_ld_reload_flag='-r'])
+-reload_flag=$lt_cv_ld_reload_flag
+-case $reload_flag in
+-"" | " "*) ;;
+-*) reload_flag=" $reload_flag" ;;
+-esac
+-reload_cmds='$LD$reload_flag -o $output$reload_objs'
+-case $host_os in
+- darwin*)
+- if test "$GCC" = yes; then
+- reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
++aix[[4-9]]*)
++ version_type=linux
++ need_lib_prefix=no
++ need_version=no
++ hardcode_into_libs=yes
++ if test "$host_cpu" = ia64; then
++ # AIX 5 supports IA64
++ library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
++ shlibpath_var=LD_LIBRARY_PATH
++ else
++ # With GCC up to 2.95.x, collect2 would create an import file
++ # for dependence libraries. The import file would start with
++ # the line `#! .'. This would cause the generated library to
++ # depend on `.', always an invalid library. This was fixed in
++ # development snapshots of GCC prior to 3.0.
++ case $host_os in
++ aix4 | aix4.[[01]] | aix4.[[01]].*)
++ if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
++ echo ' yes '
++ echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
++ :
++ else
++ can_build_shared=no
++ fi
++ ;;
++ esac
++ # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
++ # soname into executable. Probably we can add versioning support to
++ # collect2, so additional links can be useful in future.
++ if test "$aix_use_runtimelinking" = yes; then
++ # If using run time linking (on AIX 4.2 or later) use lib<name>.so
++ # instead of lib<name>.a to let people know that these are not
++ # typical AIX shared libraries.
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ else
+- reload_cmds='$LD$reload_flag -o $output$reload_objs'
++ # We preserve .a as extension for shared libraries through AIX4.2
++ # and later when we are not doing run time linking.
++ library_names_spec='${libname}${release}.a $libname.a'
++ soname_spec='${libname}${release}${shared_ext}$major'
+ fi
+- ;;
+-esac
+-])# AC_PROG_LD_RELOAD_FLAG
+-
+-
+-# AC_DEPLIBS_CHECK_METHOD
+-# -----------------------
+-# how to check for library dependencies
+-# -- PORTME fill in with the dynamic library characteristics
+-AC_DEFUN([AC_DEPLIBS_CHECK_METHOD],
+-[AC_CACHE_CHECK([how to recognise dependent libraries],
+-lt_cv_deplibs_check_method,
+-[lt_cv_file_magic_cmd='$MAGIC_CMD'
+-lt_cv_file_magic_test_file=
+-lt_cv_deplibs_check_method='unknown'
+-# Need to set the preceding variable on all platforms that support
+-# interlibrary dependencies.
+-# 'none' -- dependencies not supported.
+-# `unknown' -- same as none, but documents that we really don't know.
+-# 'pass_all' -- all dependencies passed with no checks.
+-# 'test_compile' -- check by making test program.
+-# 'file_magic [[regex]]' -- check by looking for files in library path
+-# which responds to the $file_magic_cmd with a given extended regex.
+-# If you have `file' or equivalent on your system and you're not sure
+-# whether `pass_all' will *always* work, you probably want this one.
++ shlibpath_var=LIBPATH
++ fi
++ ;;
+
+-case $host_os in
+-aix4* | aix5*)
+- lt_cv_deplibs_check_method=pass_all
++amigaos*)
++ case $host_cpu in
++ powerpc)
++ # Since July 2007 AmigaOS4 officially supports .so libraries.
++ # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
++ ;;
++ m68k)
++ library_names_spec='$libname.ixlibrary $libname.a'
++ # Create ${libname}_ixlibrary.a entries in /sys/libs.
++ finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$ECHO "X$lib" | $Xsed -e '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
++ ;;
++ esac
+ ;;
+
+ beos*)
+- lt_cv_deplibs_check_method=pass_all
++ library_names_spec='${libname}${shared_ext}'
++ dynamic_linker="$host_os ld.so"
++ shlibpath_var=LIBRARY_PATH
+ ;;
+
+ bsdi[[45]]*)
+- lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib)'
+- lt_cv_file_magic_cmd='/usr/bin/file -L'
+- lt_cv_file_magic_test_file=/shlib/libc.so
+- ;;
+-
+-cygwin*)
+- # func_win32_libid is a shell function defined in ltmain.sh
+- lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+- lt_cv_file_magic_cmd='func_win32_libid'
++ version_type=linux
++ need_version=no
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
++ soname_spec='${libname}${release}${shared_ext}$major'
++ finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
++ shlibpath_var=LD_LIBRARY_PATH
++ sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
++ sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
++ # the default ld.so.conf also contains /usr/contrib/lib and
++ # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
++ # libtool to hard-code these into programs
+ ;;
+
+-mingw* | pw32*)
+- # Base MSYS/MinGW do not provide the 'file' command needed by
+- # func_win32_libid shell function, so use a weaker test based on 'objdump'.
+- lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?'
+- lt_cv_file_magic_cmd='$OBJDUMP -f'
+- ;;
++cygwin* | mingw* | pw32*)
++ version_type=windows
++ shrext_cmds=".dll"
++ need_version=no
++ need_lib_prefix=no
+
+-darwin* | rhapsody*)
+- lt_cv_deplibs_check_method=pass_all
+- ;;
++ case $GCC,$host_os in
++ yes,cygwin* | yes,mingw* | yes,pw32*)
++ library_names_spec='$libname.dll.a'
++ # DLL is installed to $(libdir)/../bin by postinstall_cmds
++ postinstall_cmds='base_file=`basename \${file}`~
++ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
++ dldir=$destdir/`dirname \$dlpath`~
++ test -d \$dldir || mkdir -p \$dldir~
++ $install_prog $dir/$dlname \$dldir/$dlname~
++ chmod a+x \$dldir/$dlname~
++ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
++ eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
++ fi'
++ postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
++ dlpath=$dir/\$dldll~
++ $RM \$dlpath'
++ shlibpath_overrides_runpath=yes
+
+-freebsd* | kfreebsd*-gnu | dragonfly*)
+- if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+- case $host_cpu in
+- i*86 )
+- # Not sure whether the presence of OpenBSD here was a mistake.
+- # Let's accept both of them until this is cleared up.
+- lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library'
+- lt_cv_file_magic_cmd=/usr/bin/file
+- lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
++ case $host_os in
++ cygwin*)
++ # Cygwin DLLs use 'cyg' prefix rather than 'lib'
++ soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
++ sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
++ ;;
++ mingw*)
++ # MinGW DLLs use traditional 'lib' prefix
++ soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
++ sys_lib_search_path_spec=`$CC -print-search-dirs | $GREP "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
++ if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then
++ # It is most probably a Windows format PATH printed by
++ # mingw gcc, but we are running on Cygwin. Gcc prints its search
++ # path with ; separators, and with drive letters. We can handle the
++ # drive letters (cygwin fileutils understands them), so leave them,
++ # especially as we might pass files found there to a mingw objdump,
++ # which wouldn't understand a cygwinified path. Ahh.
++ sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
++ else
++ sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
++ fi
++ ;;
++ pw32*)
++ # pw32 DLLs use 'pw' prefix rather than 'lib'
++ library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+ ;;
+ esac
+- else
+- lt_cv_deplibs_check_method=pass_all
+- fi
+- ;;
+-
+-gnu*)
+- lt_cv_deplibs_check_method=pass_all
+- ;;
+-
+-hpux10.20* | hpux11*)
+- lt_cv_file_magic_cmd=/usr/bin/file
+- case $host_cpu in
+- ia64*)
+- lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64'
+- lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
+- ;;
+- hppa*64*)
+- [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]']
+- lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
+ ;;
++
+ *)
+- lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]].[[0-9]]) shared library'
+- lt_cv_file_magic_test_file=/usr/lib/libc.sl
++ library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib'
+ ;;
+ esac
++ dynamic_linker='Win32 ld.exe'
++ # FIXME: first we should search . and the directory the executable is in
++ shlibpath_var=PATH
+ ;;
+
+-interix3*)
+- # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
+- lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$'
+- ;;
+-
+-irix5* | irix6* | nonstopux*)
+- case $LD in
+- *-32|*"-32 ") libmagic=32-bit;;
+- *-n32|*"-n32 ") libmagic=N32;;
+- *-64|*"-64 ") libmagic=64-bit;;
+- *) libmagic=never-match;;
+- esac
+- lt_cv_deplibs_check_method=pass_all
+- ;;
+-
+-# This must be Linux ELF.
+-linux*)
+- lt_cv_deplibs_check_method=pass_all
+- ;;
+-
+-netbsd*)
+- if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+- lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
+- else
+- lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$'
+- fi
++darwin* | rhapsody*)
++ dynamic_linker="$host_os dyld"
++ version_type=darwin
++ need_lib_prefix=no
++ need_version=no
++ library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
++ soname_spec='${libname}${release}${major}$shared_ext'
++ shlibpath_overrides_runpath=yes
++ shlibpath_var=DYLD_LIBRARY_PATH
++ shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
++m4_if([$1], [],[
++ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"])
++ sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
+ ;;
+
+-newos6*)
+- lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)'
+- lt_cv_file_magic_cmd=/usr/bin/file
+- lt_cv_file_magic_test_file=/usr/lib/libnls.so
++dgux*)
++ version_type=linux
++ need_lib_prefix=no
++ need_version=no
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
++ soname_spec='${libname}${release}${shared_ext}$major'
++ shlibpath_var=LD_LIBRARY_PATH
+ ;;
+
+-nto-qnx*)
+- lt_cv_deplibs_check_method=unknown
++freebsd1*)
++ dynamic_linker=no
+ ;;
+
+-openbsd*)
+- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+- lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$'
++freebsd* | dragonfly*)
++ # DragonFly does not have aout. When/if they implement a new
++ # versioning mechanism, adjust this.
++ if test -x /usr/bin/objformat; then
++ objformat=`/usr/bin/objformat`
+ else
+- lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
++ case $host_os in
++ freebsd[[123]]*) objformat=aout ;;
++ *) objformat=elf ;;
++ esac
+ fi
+- ;;
+-
+-osf3* | osf4* | osf5*)
+- lt_cv_deplibs_check_method=pass_all
+- ;;
+-
+-solaris*)
+- lt_cv_deplibs_check_method=pass_all
+- ;;
+-
+-sysv4 | sysv4.3*)
+- case $host_vendor in
+- motorola)
+- lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]'
+- lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
+- ;;
+- ncr)
+- lt_cv_deplibs_check_method=pass_all
+- ;;
+- sequent)
+- lt_cv_file_magic_cmd='/bin/file'
+- lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )'
++ version_type=freebsd-$objformat
++ case $version_type in
++ freebsd-elf*)
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
++ need_version=no
++ need_lib_prefix=no
++ ;;
++ freebsd-*)
++ library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
++ need_version=yes
++ ;;
++ esac
++ shlibpath_var=LD_LIBRARY_PATH
++ case $host_os in
++ freebsd2*)
++ shlibpath_overrides_runpath=yes
+ ;;
+- sni)
+- lt_cv_file_magic_cmd='/bin/file'
+- lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib"
+- lt_cv_file_magic_test_file=/lib/libc.so
++ freebsd3.[[01]]* | freebsdelf3.[[01]]*)
++ shlibpath_overrides_runpath=yes
++ hardcode_into_libs=yes
+ ;;
+- siemens)
+- lt_cv_deplibs_check_method=pass_all
++ freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \
++ freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1)
++ shlibpath_overrides_runpath=no
++ hardcode_into_libs=yes
+ ;;
+- pc)
+- lt_cv_deplibs_check_method=pass_all
++ *) # from 4.6 on, and DragonFly
++ shlibpath_overrides_runpath=yes
++ hardcode_into_libs=yes
+ ;;
+ esac
+ ;;
+
+-sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+- lt_cv_deplibs_check_method=pass_all
++gnu*)
++ version_type=linux
++ need_lib_prefix=no
++ need_version=no
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
++ soname_spec='${libname}${release}${shared_ext}$major'
++ shlibpath_var=LD_LIBRARY_PATH
++ hardcode_into_libs=yes
+ ;;
+-esac
+-])
+-file_magic_cmd=$lt_cv_file_magic_cmd
+-deplibs_check_method=$lt_cv_deplibs_check_method
+-test -z "$deplibs_check_method" && deplibs_check_method=unknown
+-])# AC_DEPLIBS_CHECK_METHOD
+
+-
+-# AC_PROG_NM
+-# ----------
+-# find the pathname to a BSD-compatible name lister
+-AC_DEFUN([AC_PROG_NM],
+-[AC_CACHE_CHECK([for BSD-compatible nm], lt_cv_path_NM,
+-[if test -n "$NM"; then
+- # Let the user override the test.
+- lt_cv_path_NM="$NM"
+-else
+- lt_nm_to_check="${ac_tool_prefix}nm"
+- if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
+- lt_nm_to_check="$lt_nm_to_check nm"
+- fi
+- for lt_tmp_nm in $lt_nm_to_check; do
+- lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+- for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
+- IFS="$lt_save_ifs"
+- test -z "$ac_dir" && ac_dir=.
+- tmp_nm="$ac_dir/$lt_tmp_nm"
+- if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
+- # Check to see if the nm accepts a BSD-compat flag.
+- # Adding the `sed 1q' prevents false positives on HP-UX, which says:
+- # nm: unknown option "B" ignored
+- # Tru64's nm complains that /dev/null is an invalid object file
+- case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
+- */dev/null* | *'Invalid file or object type'*)
+- lt_cv_path_NM="$tmp_nm -B"
+- break
+- ;;
+- *)
+- case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
+- */dev/null*)
+- lt_cv_path_NM="$tmp_nm -p"
+- break
+- ;;
+- *)
+- lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
+- continue # so that we can try to find one that supports BSD flags
+- ;;
+- esac
+- ;;
+- esac
+- fi
+- done
+- IFS="$lt_save_ifs"
+- done
+- test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm
+-fi])
+-NM="$lt_cv_path_NM"
+-])# AC_PROG_NM
+-
+-
+-# AC_CHECK_LIBM
+-# -------------
+-# check for math library
+-AC_DEFUN([AC_CHECK_LIBM],
+-[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+-LIBM=
+-case $host in
+-*-*-beos* | *-*-cygwin* | *-*-pw32* | *-*-darwin*)
+- # These system don't have libm, or don't need it
+- ;;
+-*-ncr-sysv4.3*)
+- AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
+- AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm")
+- ;;
+-*)
+- AC_CHECK_LIB(m, cos, LIBM="-lm")
++hpux9* | hpux10* | hpux11*)
++ # Give a soname corresponding to the major version so that dld.sl refuses to
++ # link against other versions.
++ version_type=sunos
++ need_lib_prefix=no
++ need_version=no
++ case $host_cpu in
++ ia64*)
++ shrext_cmds='.so'
++ hardcode_into_libs=yes
++ dynamic_linker="$host_os dld.so"
++ shlibpath_var=LD_LIBRARY_PATH
++ shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
++ soname_spec='${libname}${release}${shared_ext}$major'
++ if test "X$HPUX_IA64_MODE" = X32; then
++ sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
++ else
++ sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
++ fi
++ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
++ ;;
++ hppa*64*)
++ shrext_cmds='.sl'
++ hardcode_into_libs=yes
++ dynamic_linker="$host_os dld.sl"
++ shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
++ shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
++ soname_spec='${libname}${release}${shared_ext}$major'
++ sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
++ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
++ ;;
++ *)
++ shrext_cmds='.sl'
++ dynamic_linker="$host_os dld.sl"
++ shlibpath_var=SHLIB_PATH
++ shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
++ soname_spec='${libname}${release}${shared_ext}$major'
++ ;;
++ esac
++ # HP-UX runs *really* slowly unless shared libraries are mode 555.
++ postinstall_cmds='chmod 555 $lib'
+ ;;
+-esac
+-])# AC_CHECK_LIBM
+
++interix[[3-9]]*)
++ version_type=linux
++ need_lib_prefix=no
++ need_version=no
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
++ soname_spec='${libname}${release}${shared_ext}$major'
++ dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
++ shlibpath_var=LD_LIBRARY_PATH
++ shlibpath_overrides_runpath=no
++ hardcode_into_libs=yes
++ ;;
+
+-# AC_LIBLTDL_CONVENIENCE([DIRECTORY])
+-# -----------------------------------
+-# sets LIBLTDL to the link flags for the libltdl convenience library and
+-# LTDLINCL to the include flags for the libltdl header and adds
+-# --enable-ltdl-convenience to the configure arguments. Note that
+-# AC_CONFIG_SUBDIRS is not called here. If DIRECTORY is not provided,
+-# it is assumed to be `libltdl'. LIBLTDL will be prefixed with
+-# '${top_builddir}/' and LTDLINCL will be prefixed with '${top_srcdir}/'
+-# (note the single quotes!). If your package is not flat and you're not
+-# using automake, define top_builddir and top_srcdir appropriately in
+-# the Makefiles.
+-AC_DEFUN([AC_LIBLTDL_CONVENIENCE],
+-[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+- case $enable_ltdl_convenience in
+- no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;;
+- "") enable_ltdl_convenience=yes
+- ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;;
++irix5* | irix6* | nonstopux*)
++ case $host_os in
++ nonstopux*) version_type=nonstopux ;;
++ *)
++ if test "$lt_cv_prog_gnu_ld" = yes; then
++ version_type=linux
++ else
++ version_type=irix
++ fi ;;
+ esac
+- LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdlc.la
+- LTDLINCL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl'])
+- # For backwards non-gettext consistent compatibility...
+- INCLTDL="$LTDLINCL"
+-])# AC_LIBLTDL_CONVENIENCE
+-
+-
+-# AC_LIBLTDL_INSTALLABLE([DIRECTORY])
+-# -----------------------------------
+-# sets LIBLTDL to the link flags for the libltdl installable library and
+-# LTDLINCL to the include flags for the libltdl header and adds
+-# --enable-ltdl-install to the configure arguments. Note that
+-# AC_CONFIG_SUBDIRS is not called here. If DIRECTORY is not provided,
+-# and an installed libltdl is not found, it is assumed to be `libltdl'.
+-# LIBLTDL will be prefixed with '${top_builddir}/'# and LTDLINCL with
+-# '${top_srcdir}/' (note the single quotes!). If your package is not
+-# flat and you're not using automake, define top_builddir and top_srcdir
+-# appropriately in the Makefiles.
+-# In the future, this macro may have to be called after AC_PROG_LIBTOOL.
+-AC_DEFUN([AC_LIBLTDL_INSTALLABLE],
+-[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+- AC_CHECK_LIB(ltdl, lt_dlinit,
+- [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no],
+- [if test x"$enable_ltdl_install" = xno; then
+- AC_MSG_WARN([libltdl not installed, but installation disabled])
+- else
+- enable_ltdl_install=yes
+- fi
+- ])
+- if test x"$enable_ltdl_install" = x"yes"; then
+- ac_configure_args="$ac_configure_args --enable-ltdl-install"
+- LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdl.la
+- LTDLINCL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl'])
+- else
+- ac_configure_args="$ac_configure_args --enable-ltdl-install=no"
+- LIBLTDL="-lltdl"
+- LTDLINCL=
+- fi
+- # For backwards non-gettext consistent compatibility...
+- INCLTDL="$LTDLINCL"
+-])# AC_LIBLTDL_INSTALLABLE
++ need_lib_prefix=no
++ need_version=no
++ soname_spec='${libname}${release}${shared_ext}$major'
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
++ case $host_os in
++ irix5* | nonstopux*)
++ libsuff= shlibsuff=
++ ;;
++ *)
++ case $LD in # libtool.m4 will add one of these switches to LD
++ *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
++ libsuff= shlibsuff= libmagic=32-bit;;
++ *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
++ libsuff=32 shlibsuff=N32 libmagic=N32;;
++ *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
++ libsuff=64 shlibsuff=64 libmagic=64-bit;;
++ *) libsuff= shlibsuff= libmagic=never-match;;
++ esac
++ ;;
++ esac
++ shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
++ shlibpath_overrides_runpath=no
++ sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
++ sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
++ hardcode_into_libs=yes
++ ;;
+
++# No shared lib support for Linux oldld, aout, or coff.
++linux*oldld* | linux*aout* | linux*coff*)
++ dynamic_linker=no
++ ;;
+
+-# AC_LIBTOOL_CXX
+-# --------------
+-# enable support for C++ libraries
+-AC_DEFUN([AC_LIBTOOL_CXX],
+-[AC_REQUIRE([_LT_AC_LANG_CXX])
+-])# AC_LIBTOOL_CXX
++# This must be Linux ELF.
++linux* | k*bsd*-gnu)
++ version_type=linux
++ need_lib_prefix=no
++ need_version=no
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
++ soname_spec='${libname}${release}${shared_ext}$major'
++ finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
++ shlibpath_var=LD_LIBRARY_PATH
++ shlibpath_overrides_runpath=no
++ # Some binutils ld are patched to set DT_RUNPATH
++ save_LDFLAGS=$LDFLAGS
++ save_libdir=$libdir
++ eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \
++ LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\""
++ AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
++ [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null],
++ [shlibpath_overrides_runpath=yes])])
++ LDFLAGS=$save_LDFLAGS
++ libdir=$save_libdir
+
++ # This implies no fast_install, which is unacceptable.
++ # Some rework will be needed to allow for fast_install
++ # before this can be enabled.
++ hardcode_into_libs=yes
+
+-# _LT_AC_LANG_CXX
+-# ---------------
+-AC_DEFUN([_LT_AC_LANG_CXX],
+-[AC_REQUIRE([AC_PROG_CXX])
+-AC_REQUIRE([_LT_AC_PROG_CXXCPP])
+-_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}CXX])
+-])# _LT_AC_LANG_CXX
++ # Append ld.so.conf contents to the search path
++ if test -f /etc/ld.so.conf; then
++ lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
++ sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
++ fi
+
+-# _LT_AC_PROG_CXXCPP
+-# ------------------
+-AC_DEFUN([_LT_AC_PROG_CXXCPP],
+-[
+-AC_REQUIRE([AC_PROG_CXX])
+-if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
+- ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
+- (test "X$CXX" != "Xg++"))) ; then
+- AC_PROG_CXXCPP
+-fi
+-])# _LT_AC_PROG_CXXCPP
+-
+-# AC_LIBTOOL_F77
+-# --------------
+-# enable support for Fortran 77 libraries
+-AC_DEFUN([AC_LIBTOOL_F77],
+-[AC_REQUIRE([_LT_AC_LANG_F77])
+-])# AC_LIBTOOL_F77
+-
+-
+-# _LT_AC_LANG_F77
+-# ---------------
+-AC_DEFUN([_LT_AC_LANG_F77],
+-[AC_REQUIRE([AC_PROG_F77])
+-_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}F77])
+-])# _LT_AC_LANG_F77
+-
+-
+-# AC_LIBTOOL_GCJ
+-# --------------
+-# enable support for GCJ libraries
+-AC_DEFUN([AC_LIBTOOL_GCJ],
+-[AC_REQUIRE([_LT_AC_LANG_GCJ])
+-])# AC_LIBTOOL_GCJ
+-
+-
+-# _LT_AC_LANG_GCJ
+-# ---------------
+-AC_DEFUN([_LT_AC_LANG_GCJ],
+-[AC_PROVIDE_IFELSE([AC_PROG_GCJ],[],
+- [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],[],
+- [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ],[],
+- [ifdef([AC_PROG_GCJ],[AC_REQUIRE([AC_PROG_GCJ])],
+- [ifdef([A][M_PROG_GCJ],[AC_REQUIRE([A][M_PROG_GCJ])],
+- [AC_REQUIRE([A][C_PROG_GCJ_OR_A][M_PROG_GCJ])])])])])])
+-_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}GCJ])
+-])# _LT_AC_LANG_GCJ
+-
+-
+-# AC_LIBTOOL_RC
+-# -------------
+-# enable support for Windows resource files
+-AC_DEFUN([AC_LIBTOOL_RC],
+-[AC_REQUIRE([LT_AC_PROG_RC])
+-_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}RC])
+-])# AC_LIBTOOL_RC
++ # We used to test for /lib/ld.so.1 and disable shared libraries on
++ # powerpc, because MkLinux only supported shared libraries with the
++ # GNU dynamic linker. Since this was broken with cross compilers,
++ # most powerpc-linux boxes support dynamic linking these days and
++ # people can always --disable-shared, the test was removed, and we
++ # assume the GNU/Linux dynamic linker is in use.
++ dynamic_linker='GNU/Linux ld.so'
++ ;;
+
++netbsd*)
++ version_type=sunos
++ need_lib_prefix=no
++ need_version=no
++ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
++ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
++ dynamic_linker='NetBSD (a.out) ld.so'
++ else
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
++ soname_spec='${libname}${release}${shared_ext}$major'
++ dynamic_linker='NetBSD ld.elf_so'
++ fi
++ shlibpath_var=LD_LIBRARY_PATH
++ shlibpath_overrides_runpath=yes
++ hardcode_into_libs=yes
++ ;;
+
+-# AC_LIBTOOL_LANG_C_CONFIG
+-# ------------------------
+-# Ensure that the configuration vars for the C compiler are
+-# suitably defined. Those variables are subsequently used by
+-# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
+-AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG], [_LT_AC_LANG_C_CONFIG])
+-AC_DEFUN([_LT_AC_LANG_C_CONFIG],
+-[lt_save_CC="$CC"
+-AC_LANG_PUSH(C)
++newsos6)
++ version_type=linux
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
++ shlibpath_var=LD_LIBRARY_PATH
++ shlibpath_overrides_runpath=yes
++ ;;
+
+-# Source file extension for C test sources.
+-ac_ext=c
++*nto* | *qnx*)
++ version_type=qnx
++ need_lib_prefix=no
++ need_version=no
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
++ soname_spec='${libname}${release}${shared_ext}$major'
++ shlibpath_var=LD_LIBRARY_PATH
++ shlibpath_overrides_runpath=no
++ hardcode_into_libs=yes
++ dynamic_linker='ldqnx.so'
++ ;;
+
+-# Object file extension for compiled C test sources.
+-objext=o
+-_LT_AC_TAGVAR(objext, $1)=$objext
++openbsd*)
++ version_type=sunos
++ sys_lib_dlsearch_path_spec="/usr/lib"
++ need_lib_prefix=no
++ # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
++ case $host_os in
++ openbsd3.3 | openbsd3.3.*) need_version=yes ;;
++ *) need_version=no ;;
++ esac
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
++ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
++ shlibpath_var=LD_LIBRARY_PATH
++ if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
++ case $host_os in
++ openbsd2.[[89]] | openbsd2.[[89]].*)
++ shlibpath_overrides_runpath=no
++ ;;
++ *)
++ shlibpath_overrides_runpath=yes
++ ;;
++ esac
++ else
++ shlibpath_overrides_runpath=yes
++ fi
++ ;;
+
+-# Code to be used in simple compile tests
+-lt_simple_compile_test_code="int some_variable = 0;\n"
++os2*)
++ libname_spec='$name'
++ shrext_cmds=".dll"
++ need_lib_prefix=no
++ library_names_spec='$libname${shared_ext} $libname.a'
++ dynamic_linker='OS/2 ld.exe'
++ shlibpath_var=LIBPATH
++ ;;
+
+-# Code to be used in simple link tests
+-lt_simple_link_test_code='int main(){return(0);}\n'
++osf3* | osf4* | osf5*)
++ version_type=osf
++ need_lib_prefix=no
++ need_version=no
++ soname_spec='${libname}${release}${shared_ext}$major'
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
++ shlibpath_var=LD_LIBRARY_PATH
++ sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
++ sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
++ ;;
+
+-_LT_AC_SYS_COMPILER
++rdos*)
++ dynamic_linker=no
++ ;;
+
+-# save warnings/boilerplate of simple test code
+-_LT_COMPILER_BOILERPLATE
+-_LT_LINKER_BOILERPLATE
++solaris*)
++ version_type=linux
++ need_lib_prefix=no
++ need_version=no
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
++ soname_spec='${libname}${release}${shared_ext}$major'
++ shlibpath_var=LD_LIBRARY_PATH
++ shlibpath_overrides_runpath=yes
++ hardcode_into_libs=yes
++ # ldd complains unless libraries are executable
++ postinstall_cmds='chmod +x $lib'
++ ;;
+
+-## CAVEAT EMPTOR:
+-## There is no encapsulation within the following macros, do not change
+-## the running order or otherwise move them around unless you know exactly
+-## what you are doing...
+-AC_LIBTOOL_PROG_COMPILER_NO_RTTI($1)
+-AC_LIBTOOL_PROG_COMPILER_PIC($1)
+-AC_LIBTOOL_PROG_CC_C_O($1)
+-AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
+-AC_LIBTOOL_PROG_LD_SHLIBS($1)
+-AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
+-AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
+-AC_LIBTOOL_SYS_LIB_STRIP
+-AC_LIBTOOL_DLOPEN_SELF
+-
+-# Report which library types will actually be built
+-AC_MSG_CHECKING([if libtool supports shared libraries])
+-AC_MSG_RESULT([$can_build_shared])
++sunos4*)
++ version_type=sunos
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
++ finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
++ shlibpath_var=LD_LIBRARY_PATH
++ shlibpath_overrides_runpath=yes
++ if test "$with_gnu_ld" = yes; then
++ need_lib_prefix=no
++ fi
++ need_version=yes
++ ;;
+
+-AC_MSG_CHECKING([whether to build shared libraries])
+-test "$can_build_shared" = "no" && enable_shared=no
++sysv4 | sysv4.3*)
++ version_type=linux
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
++ soname_spec='${libname}${release}${shared_ext}$major'
++ shlibpath_var=LD_LIBRARY_PATH
++ case $host_vendor in
++ sni)
++ shlibpath_overrides_runpath=no
++ need_lib_prefix=no
++ runpath_var=LD_RUN_PATH
++ ;;
++ siemens)
++ need_lib_prefix=no
++ ;;
++ motorola)
++ need_lib_prefix=no
++ need_version=no
++ shlibpath_overrides_runpath=no
++ sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
++ ;;
++ esac
++ ;;
+
+-# On AIX, shared libraries and static libraries use the same namespace, and
+-# are all built from PIC.
+-case $host_os in
+-aix3*)
+- test "$enable_shared" = yes && enable_static=no
+- if test -n "$RANLIB"; then
+- archive_cmds="$archive_cmds~\$RANLIB \$lib"
+- postinstall_cmds='$RANLIB $lib'
++sysv4*MP*)
++ if test -d /usr/nec ;then
++ version_type=linux
++ library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
++ soname_spec='$libname${shared_ext}.$major'
++ shlibpath_var=LD_LIBRARY_PATH
+ fi
+ ;;
+
+-aix4* | aix5*)
+- if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+- test "$enable_shared" = yes && enable_static=no
++sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
++ version_type=freebsd-elf
++ need_lib_prefix=no
++ need_version=no
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
++ soname_spec='${libname}${release}${shared_ext}$major'
++ shlibpath_var=LD_LIBRARY_PATH
++ shlibpath_overrides_runpath=yes
++ hardcode_into_libs=yes
++ if test "$with_gnu_ld" = yes; then
++ sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
++ else
++ sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
++ case $host_os in
++ sco3.2v5*)
++ sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
++ ;;
++ esac
+ fi
+- ;;
+-esac
+-AC_MSG_RESULT([$enable_shared])
+-
+-AC_MSG_CHECKING([whether to build static libraries])
+-# Make sure either enable_shared or enable_static is yes.
+-test "$enable_shared" = yes || enable_static=yes
+-AC_MSG_RESULT([$enable_static])
+-
+-AC_LIBTOOL_CONFIG($1)
+-
+-AC_LANG_POP
+-CC="$lt_save_CC"
+-])# AC_LIBTOOL_LANG_C_CONFIG
+-
+-
+-# AC_LIBTOOL_LANG_CXX_CONFIG
+-# --------------------------
+-# Ensure that the configuration vars for the C compiler are
+-# suitably defined. Those variables are subsequently used by
+-# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
+-AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG], [_LT_AC_LANG_CXX_CONFIG(CXX)])
+-AC_DEFUN([_LT_AC_LANG_CXX_CONFIG],
+-[AC_LANG_PUSH(C++)
+-AC_REQUIRE([AC_PROG_CXX])
+-AC_REQUIRE([_LT_AC_PROG_CXXCPP])
+-
+-_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+-_LT_AC_TAGVAR(allow_undefined_flag, $1)=
+-_LT_AC_TAGVAR(always_export_symbols, $1)=no
+-_LT_AC_TAGVAR(archive_expsym_cmds, $1)=
+-_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=
+-_LT_AC_TAGVAR(hardcode_direct, $1)=no
+-_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
+-_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
+-_LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
+-_LT_AC_TAGVAR(hardcode_minus_L, $1)=no
+-_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+-_LT_AC_TAGVAR(hardcode_automatic, $1)=no
+-_LT_AC_TAGVAR(module_cmds, $1)=
+-_LT_AC_TAGVAR(module_expsym_cmds, $1)=
+-_LT_AC_TAGVAR(link_all_deplibs, $1)=unknown
+-_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+-_LT_AC_TAGVAR(no_undefined_flag, $1)=
+-_LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+-_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+-
+-# Dependencies to place before and after the object being linked:
+-_LT_AC_TAGVAR(predep_objects, $1)=
+-_LT_AC_TAGVAR(postdep_objects, $1)=
+-_LT_AC_TAGVAR(predeps, $1)=
+-_LT_AC_TAGVAR(postdeps, $1)=
+-_LT_AC_TAGVAR(compiler_lib_search_path, $1)=
+-
+-# Source file extension for C++ test sources.
+-ac_ext=cpp
+-
+-# Object file extension for compiled C++ test sources.
+-objext=o
+-_LT_AC_TAGVAR(objext, $1)=$objext
+-
+-# Code to be used in simple compile tests
+-lt_simple_compile_test_code="int some_variable = 0;\n"
++ sys_lib_dlsearch_path_spec='/usr/lib'
++ ;;
+
+-# Code to be used in simple link tests
+-lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }\n'
++tpf*)
++ # TPF is a cross-target only. Preferred cross-host = GNU/Linux.
++ version_type=linux
++ need_lib_prefix=no
++ need_version=no
++ library_name_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
++ shlibpath_var=LD_LIBRARY_PATH
++ shlibpath_overrides_runpath=no
++ hardcode_into_libs=yes
++ ;;
+
+-# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+-_LT_AC_SYS_COMPILER
++uts4*)
++ version_type=linux
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
++ soname_spec='${libname}${release}${shared_ext}$major'
++ shlibpath_var=LD_LIBRARY_PATH
++ ;;
+
+-# save warnings/boilerplate of simple test code
+-_LT_COMPILER_BOILERPLATE
+-_LT_LINKER_BOILERPLATE
++*)
++ dynamic_linker=no
++ ;;
++esac
++AC_MSG_RESULT([$dynamic_linker])
++test "$dynamic_linker" = no && can_build_shared=no
+
+-# Allow CC to be a program name with arguments.
+-lt_save_CC=$CC
+-lt_save_LD=$LD
+-lt_save_GCC=$GCC
+-GCC=$GXX
+-lt_save_with_gnu_ld=$with_gnu_ld
+-lt_save_path_LD=$lt_cv_path_LD
+-if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then
+- lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx
+-else
+- $as_unset lt_cv_prog_gnu_ld
++variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
++if test "$GCC" = yes; then
++ variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
+ fi
+-if test -n "${lt_cv_path_LDCXX+set}"; then
+- lt_cv_path_LD=$lt_cv_path_LDCXX
+-else
+- $as_unset lt_cv_path_LD
++
++if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
++ sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+ fi
+-test -z "${LDCXX+set}" || LD=$LDCXX
+-CC=${CXX-"c++"}
+-compiler=$CC
+-_LT_AC_TAGVAR(compiler, $1)=$CC
+-_LT_CC_BASENAME([$compiler])
+-
+-# We don't want -fno-exception wen compiling C++ code, so set the
+-# no_builtin_flag separately
+-if test "$GXX" = yes; then
+- _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
+-else
+- _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
++if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
++ sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+ fi
+
+-if test "$GXX" = yes; then
+- # Set up default GNU C++ configuration
+-
+- AC_PROG_LD
+-
+- # Check if GNU C++ uses GNU ld as the underlying linker, since the
+- # archiving commands below assume that GNU ld is being used.
+- if test "$with_gnu_ld" = yes; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+-
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+-
+- # If archive_cmds runs LD, not CC, wlarc should be empty
+- # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
+- # investigate it a little bit more. (MM)
+- wlarc='${wl}'
+-
+- # ancient GNU ld didn't support --whole-archive et. al.
+- if eval "`$CC -print-prog-name=ld` --help 2>&1" | \
+- grep 'no-whole-archive' > /dev/null; then
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+- else
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+- fi
+- else
+- with_gnu_ld=no
+- wlarc=
+-
+- # A generic and very simple default shared library creation
+- # command for GNU C++ for the case where it uses the native
+- # linker, instead of GNU ld. If possible, this setting should
+- # overridden to take advantage of the native linker features on
+- # the platform it is being used on.
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+- fi
+-
+- # Commands to make compiler produce verbose output that lists
+- # what "hidden" libraries, object files and flags are used when
+- # linking a shared library.
+- output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"'
+-
+-else
+- GXX=no
+- with_gnu_ld=no
+- wlarc=
+-fi
++_LT_DECL([], [variables_saved_for_relink], [1],
++ [Variables whose values should be saved in libtool wrapper scripts and
++ restored at link time])
++_LT_DECL([], [need_lib_prefix], [0],
++ [Do we need the "lib" prefix for modules?])
++_LT_DECL([], [need_version], [0], [Do we need a version for libraries?])
++_LT_DECL([], [version_type], [0], [Library versioning type])
++_LT_DECL([], [runpath_var], [0], [Shared library runtime path variable])
++_LT_DECL([], [shlibpath_var], [0],[Shared library path variable])
++_LT_DECL([], [shlibpath_overrides_runpath], [0],
++ [Is shlibpath searched before the hard-coded library search path?])
++_LT_DECL([], [libname_spec], [1], [Format of library name prefix])
++_LT_DECL([], [library_names_spec], [1],
++ [[List of archive names. First name is the real one, the rest are links.
++ The last name is the one that the linker finds with -lNAME]])
++_LT_DECL([], [soname_spec], [1],
++ [[The coded name of the library, if different from the real name]])
++_LT_DECL([], [postinstall_cmds], [2],
++ [Command to use after installation of a shared archive])
++_LT_DECL([], [postuninstall_cmds], [2],
++ [Command to use after uninstallation of a shared archive])
++_LT_DECL([], [finish_cmds], [2],
++ [Commands used to finish a libtool library installation in a directory])
++_LT_DECL([], [finish_eval], [1],
++ [[As "finish_cmds", except a single script fragment to be evaled but
++ not shown]])
++_LT_DECL([], [hardcode_into_libs], [0],
++ [Whether we should hardcode library paths into libraries])
++_LT_DECL([], [sys_lib_search_path_spec], [2],
++ [Compile-time system search path for libraries])
++_LT_DECL([], [sys_lib_dlsearch_path_spec], [2],
++ [Run-time system search path for libraries])
++])# _LT_SYS_DYNAMIC_LINKER
+
+-# PORTME: fill in a description of your system's C++ link characteristics
+-AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
+-_LT_AC_TAGVAR(ld_shlibs, $1)=yes
+-case $host_os in
+- aix3*)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- aix4* | aix5*)
+- if test "$host_cpu" = ia64; then
+- # On IA64, the linker does run time linking by default, so we don't
+- # have to do anything special.
+- aix_use_runtimelinking=no
+- exp_sym_flag='-Bexport'
+- no_entry_flag=""
+- else
+- aix_use_runtimelinking=no
+
+- # Test if we are trying to use run time linking or normal
+- # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+- # need to do runtime linking.
+- case $host_os in aix4.[[23]]|aix4.[[23]].*|aix5*)
+- for ld_flag in $LDFLAGS; do
+- case $ld_flag in
+- *-brtl*)
+- aix_use_runtimelinking=yes
+- break
+- ;;
+- esac
+- done
+- ;;
+- esac
+-
+- exp_sym_flag='-bexport'
+- no_entry_flag='-bnoentry'
+- fi
++# _LT_PATH_TOOL_PREFIX(TOOL)
++# --------------------------
++# find a file program which can recognize shared library
++AC_DEFUN([_LT_PATH_TOOL_PREFIX],
++[m4_require([_LT_DECL_EGREP])dnl
++AC_MSG_CHECKING([for $1])
++AC_CACHE_VAL(lt_cv_path_MAGIC_CMD,
++[case $MAGIC_CMD in
++[[\\/*] | ?:[\\/]*])
++ lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
++ ;;
++*)
++ lt_save_MAGIC_CMD="$MAGIC_CMD"
++ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
++dnl $ac_dummy forces splitting on constant user-supplied paths.
++dnl POSIX.2 word splitting is done only on the output of word expansions,
++dnl not every word. This closes a longstanding sh security hole.
++ ac_dummy="m4_if([$2], , $PATH, [$2])"
++ for ac_dir in $ac_dummy; do
++ IFS="$lt_save_ifs"
++ test -z "$ac_dir" && ac_dir=.
++ if test -f $ac_dir/$1; then
++ lt_cv_path_MAGIC_CMD="$ac_dir/$1"
++ if test -n "$file_magic_test_file"; then
++ case $deplibs_check_method in
++ "file_magic "*)
++ file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
++ MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
++ if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
++ $EGREP "$file_magic_regex" > /dev/null; then
++ :
++ else
++ cat <<_LT_EOF 1>&2
+
+- # When large executables or shared objects are built, AIX ld can
+- # have problems creating the table of contents. If linking a library
+- # or program results in "error TOC overflow" add -mminimal-toc to
+- # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
+- # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+-
+- _LT_AC_TAGVAR(archive_cmds, $1)=''
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':'
+- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
++*** Warning: the command libtool uses to detect shared libraries,
++*** $file_magic_cmd, produces output that libtool cannot recognize.
++*** The result is that libtool may fail to recognize shared libraries
++*** as such. This will affect the creation of libtool libraries that
++*** depend on shared libraries, but programs linked with such libtool
++*** libraries will work regardless of this problem. Nevertheless, you
++*** may want to report the problem to your system manager and/or to
++*** bug-libtool@gnu.org
+
+- if test "$GXX" = yes; then
+- case $host_os in aix4.[[012]]|aix4.[[012]].*)
+- # We only want to do this on AIX 4.2 and lower, the check
+- # below for broken collect2 doesn't work under 4.3+
+- collect2name=`${CC} -print-prog-name=collect2`
+- if test -f "$collect2name" && \
+- strings "$collect2name" | grep resolve_lib_name >/dev/null
+- then
+- # We have reworked collect2
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- else
+- # We have old collect2
+- _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported
+- # It fails to find uninstalled libraries when the uninstalled
+- # path is not listed in the libpath. Setting hardcode_minus_L
+- # to unsupported forces relinking
+- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
+- fi
+- ;;
+- esac
+- shared_flag='-shared'
+- if test "$aix_use_runtimelinking" = yes; then
+- shared_flag="$shared_flag "'${wl}-G'
+- fi
+- else
+- # not using gcc
+- if test "$host_cpu" = ia64; then
+- # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+- # chokes on -Wl,-G. The following line is correct:
+- shared_flag='-G'
+- else
+- if test "$aix_use_runtimelinking" = yes; then
+- shared_flag='${wl}-G'
+- else
+- shared_flag='${wl}-bM:SRE'
+- fi
++_LT_EOF
++ fi ;;
++ esac
+ fi
++ break
+ fi
++ done
++ IFS="$lt_save_ifs"
++ MAGIC_CMD="$lt_save_MAGIC_CMD"
++ ;;
++esac])
++MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
++if test -n "$MAGIC_CMD"; then
++ AC_MSG_RESULT($MAGIC_CMD)
++else
++ AC_MSG_RESULT(no)
++fi
++_LT_DECL([], [MAGIC_CMD], [0],
++ [Used to examine libraries when file_magic_cmd begins with "file"])dnl
++])# _LT_PATH_TOOL_PREFIX
+
+- # It seems that -bexpall does not export symbols beginning with
+- # underscore (_), so it is better to generate a list of symbols to export.
+- _LT_AC_TAGVAR(always_export_symbols, $1)=yes
+- if test "$aix_use_runtimelinking" = yes; then
+- # Warning - without using the other runtime loading flags (-brtl),
+- # -berok will link without error, but may produce a broken library.
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)='-berok'
+- # Determine the default libpath from the value encoded in an empty executable.
+- _LT_AC_SYS_LIBPATH_AIX
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
++# Old name:
++AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX])
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], [])
+
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+- else
+- if test "$host_cpu" = ia64; then
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+- else
+- # Determine the default libpath from the value encoded in an empty executable.
+- _LT_AC_SYS_LIBPATH_AIX
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+- # Warning - without using the other run time loading flags,
+- # -berok will link without error, but may produce a broken library.
+- _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
+- # Exported symbols can be pulled into shared objects from archives
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
+- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
+- # This is similar to how AIX traditionally builds its shared libraries.
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+- fi
+- fi
+- ;;
+
+- beos*)
+- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+- # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
+- # support --undefined. This deserves some investigation. FIXME
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+- else
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- fi
+- ;;
++# _LT_PATH_MAGIC
++# --------------
++# find a file program which can recognize a shared library
++m4_defun([_LT_PATH_MAGIC],
++[_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH)
++if test -z "$lt_cv_path_MAGIC_CMD"; then
++ if test -n "$ac_tool_prefix"; then
++ _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH)
++ else
++ MAGIC_CMD=:
++ fi
++fi
++])# _LT_PATH_MAGIC
+
+- chorus*)
+- case $cc_basename in
+- *)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- esac
+- ;;
+
+- cygwin* | mingw* | pw32*)
+- # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
+- # as there is no search path for DLLs.
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+- _LT_AC_TAGVAR(always_export_symbols, $1)=no
+- _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+-
+- if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+- # If the export-symbols file already is a .def file (1st line
+- # is EXPORTS), use it as is; otherwise, prepend...
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+- cp $export_symbols $output_objdir/$soname.def;
+- else
+- echo EXPORTS > $output_objdir/$soname.def;
+- cat $export_symbols >> $output_objdir/$soname.def;
+- fi~
+- $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+- else
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- fi
+- ;;
+- darwin* | rhapsody*)
+- case $host_os in
+- rhapsody* | darwin1.[[012]])
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}suppress'
+- ;;
+- *) # Darwin 1.3 on
+- if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+- else
+- case ${MACOSX_DEPLOYMENT_TARGET} in
+- 10.[[012]])
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+- ;;
+- 10.*)
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}dynamic_lookup'
+- ;;
+- esac
+- fi
+- ;;
+- esac
+- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+- _LT_AC_TAGVAR(hardcode_direct, $1)=no
+- _LT_AC_TAGVAR(hardcode_automatic, $1)=yes
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=''
+- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+-
+- if test "$GXX" = yes ; then
+- lt_int_apple_cc_single_mod=no
+- output_verbose_link_cmd='echo'
+- if $CC -dumpspecs 2>&1 | $EGREP 'single_module' >/dev/null ; then
+- lt_int_apple_cc_single_mod=yes
+- fi
+- if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+- else
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+- fi
+- _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+- # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
+- if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+- else
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+- fi
+- _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+- else
+- case $cc_basename in
+- xlc*)
+- output_verbose_link_cmd='echo'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
+- _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+- # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+- _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+- ;;
+- *)
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- esac
+- fi
+- ;;
++# LT_PATH_LD
++# ----------
++# find the pathname to the GNU or non-GNU linker
++AC_DEFUN([LT_PATH_LD],
++[AC_REQUIRE([AC_PROG_CC])dnl
++AC_REQUIRE([AC_CANONICAL_HOST])dnl
++AC_REQUIRE([AC_CANONICAL_BUILD])dnl
++m4_require([_LT_DECL_SED])dnl
++m4_require([_LT_DECL_EGREP])dnl
+
+- dgux*)
+- case $cc_basename in
+- ec++*)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- ghcx*)
+- # Green Hills C++ Compiler
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- *)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- esac
+- ;;
+- freebsd[[12]]*)
+- # C++ shared libraries reported to be fairly broken before switch to ELF
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- freebsd-elf*)
+- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+- ;;
+- freebsd* | kfreebsd*-gnu | dragonfly*)
+- # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
+- # conventions
+- _LT_AC_TAGVAR(ld_shlibs, $1)=yes
+- ;;
+- gnu*)
+- ;;
+- hpux9*)
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
+- # but as the default
+- # location of the library.
+-
+- case $cc_basename in
+- CC*)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- aCC*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+- # Commands to make compiler produce verbose output that lists
+- # what "hidden" libraries, object files and flags are used when
+- # linking a shared library.
+- #
+- # There doesn't appear to be a way to prevent this compiler from
+- # explicitly linking system object files so we need to strip them
+- # from the output so that they don't get included in the library
+- # dependencies.
+- output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "[[-]]L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+- ;;
+- *)
+- if test "$GXX" = yes; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+- else
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- fi
+- ;;
+- esac
+- ;;
+- hpux10*|hpux11*)
+- if test $with_gnu_ld = no; then
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
++AC_ARG_WITH([gnu-ld],
++ [AS_HELP_STRING([--with-gnu-ld],
++ [assume the C compiler uses GNU ld @<:@default=no@:>@])],
++ [test "$withval" = no || with_gnu_ld=yes],
++ [with_gnu_ld=no])dnl
+
+- case $host_cpu in
+- hppa*64*|ia64*)
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir'
+- ;;
+- *)
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+- ;;
+- esac
+- fi
+- case $host_cpu in
+- hppa*64*|ia64*)
+- _LT_AC_TAGVAR(hardcode_direct, $1)=no
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- ;;
+- *)
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
+- # but as the default
+- # location of the library.
++ac_prog=ld
++if test "$GCC" = yes; then
++ # Check if gcc -print-prog-name=ld gives a path.
++ AC_MSG_CHECKING([for ld used by $CC])
++ case $host in
++ *-*-mingw*)
++ # gcc leaves a trailing carriage return which upsets mingw
++ ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
++ *)
++ ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
++ esac
++ case $ac_prog in
++ # Accept absolute paths.
++ [[\\/]]* | ?:[[\\/]]*)
++ re_direlt='/[[^/]][[^/]]*/\.\./'
++ # Canonicalize the pathname of ld
++ ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'`
++ while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
++ ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
++ done
++ test -z "$LD" && LD="$ac_prog"
+ ;;
+- esac
+-
+- case $cc_basename in
+- CC*)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- aCC*)
+- case $host_cpu in
+- hppa*64*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+- ;;
+- ia64*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+- ;;
+- *)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+- ;;
+- esac
+- # Commands to make compiler produce verbose output that lists
+- # what "hidden" libraries, object files and flags are used when
+- # linking a shared library.
+- #
+- # There doesn't appear to be a way to prevent this compiler from
+- # explicitly linking system object files so we need to strip them
+- # from the output so that they don't get included in the library
+- # dependencies.
+- output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+- ;;
+- *)
+- if test "$GXX" = yes; then
+- if test $with_gnu_ld = no; then
+- case $host_cpu in
+- hppa*64*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+- ;;
+- ia64*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+- ;;
+- *)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+- ;;
+- esac
+- fi
+- else
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- fi
+- ;;
+- esac
+- ;;
+- interix3*)
+- _LT_AC_TAGVAR(hardcode_direct, $1)=no
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+- # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+- # Instead, shared libraries are loaded at an image base (0x10000000 by
+- # default) and relocated if they conflict, which is a slow very memory
+- # consuming and fragmenting process. To avoid this, we pick a random,
+- # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+- # time. Moving up from 0x10000000 also allows more sbrk(2) space.
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+- ;;
+- irix5* | irix6*)
+- case $cc_basename in
+- CC*)
+- # SGI C++
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+-
+- # Archives containing C++ object files must be created using
+- # "CC -ar", where "CC" is the IRIX C++ compiler. This is
+- # necessary to make sure instantiated templates are included
+- # in the archive.
+- _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs'
+- ;;
+- *)
+- if test "$GXX" = yes; then
+- if test "$with_gnu_ld" = no; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+- else
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` -o $lib'
+- fi
+- fi
+- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+- ;;
+- esac
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
++ "")
++ # If it fails, then pretend we aren't using GCC.
++ ac_prog=ld
+ ;;
+- linux*)
+- case $cc_basename in
+- KCC*)
+- # Kuck and Associates, Inc. (KAI) C++ Compiler
+-
+- # KCC will only create a shared library if the output file
+- # ends with ".so" (or ".sl" for HP-UX), so rename the library
+- # to its proper name (with version) after linking.
+- _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib'
+- # Commands to make compiler produce verbose output that lists
+- # what "hidden" libraries, object files and flags are used when
+- # linking a shared library.
+- #
+- # There doesn't appear to be a way to prevent this compiler from
+- # explicitly linking system object files so we need to strip them
+- # from the output so that they don't get included in the library
+- # dependencies.
+- output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | grep "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+-
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath,$libdir'
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+-
+- # Archives containing C++ object files must be created using
+- # "CC -Bstatic", where "CC" is the KAI C++ compiler.
+- _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs'
+- ;;
+- icpc*)
+- # Intel C++
+- with_gnu_ld=yes
+- # version 8.0 and above of icpc choke on multiply defined symbols
+- # if we add $predep_objects and $postdep_objects, however 7.1 and
+- # earlier do not add the objects themselves.
+- case `$CC -V 2>&1` in
+- *"Version 7."*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+- ;;
+- *) # Version 8.0 or newer
+- tmp_idyn=
+- case $host_cpu in
+- ia64*) tmp_idyn=' -i_dynamic';;
+- esac
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+- ;;
+- esac
+- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+- ;;
+- pgCC*)
+- # Portland Group C++ compiler
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+-
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+- ;;
+- cxx*)
+- # Compaq C++
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
+-
+- runpath_var=LD_RUN_PATH
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+-
+- # Commands to make compiler produce verbose output that lists
+- # what "hidden" libraries, object files and flags are used when
+- # linking a shared library.
+- #
+- # There doesn't appear to be a way to prevent this compiler from
+- # explicitly linking system object files so we need to strip them
+- # from the output so that they don't get included in the library
+- # dependencies.
+- output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+- ;;
+- *)
+- case `$CC -V 2>&1 | sed 5q` in
+- *Sun\ C*)
+- # Sun C++ 5.9
+- _LT_AC_TAGVAR(no_undefined_flag, $1)=' -zdefs'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols'
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+-
+- # Not sure whether something based on
+- # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1
+- # would be better.
+- output_verbose_link_cmd='echo'
+-
+- # Archives containing C++ object files must be created using
+- # "CC -xar", where "CC" is the Sun C++ compiler. This is
+- # necessary to make sure instantiated templates are included
+- # in the archive.
+- _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
+- ;;
+- esac
+- ;;
+- esac
++ *)
++ # If it is relative, then search for the first ld in PATH.
++ with_gnu_ld=unknown
+ ;;
+- lynxos*)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- m88k*)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- mvs*)
+- case $cc_basename in
+- cxx*)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
++ esac
++elif test "$with_gnu_ld" = yes; then
++ AC_MSG_CHECKING([for GNU ld])
++else
++ AC_MSG_CHECKING([for non-GNU ld])
++fi
++AC_CACHE_VAL(lt_cv_path_LD,
++[if test -z "$LD"; then
++ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
++ for ac_dir in $PATH; do
++ IFS="$lt_save_ifs"
++ test -z "$ac_dir" && ac_dir=.
++ if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
++ lt_cv_path_LD="$ac_dir/$ac_prog"
++ # Check to see if the program is GNU ld. I'd rather use --version,
++ # but apparently some variants of GNU ld only accept -v.
++ # Break only if it was the GNU/non-GNU ld that we prefer.
++ case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
++ *GNU* | *'with BFD'*)
++ test "$with_gnu_ld" != no && break
+ ;;
+ *)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
++ test "$with_gnu_ld" != yes && break
+ ;;
+- esac
+- ;;
+- netbsd*)
+- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags'
+- wlarc=
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- fi
+- # Workaround some broken pre-1.5 toolchains
+- output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"'
+- ;;
+- openbsd2*)
+- # C++ shared libraries are fairly broken
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- openbsd*)
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
++ esac
+ fi
+- output_verbose_link_cmd='echo'
+- ;;
+- osf3*)
+- case $cc_basename in
+- KCC*)
+- # Kuck and Associates, Inc. (KAI) C++ Compiler
+-
+- # KCC will only create a shared library if the output file
+- # ends with ".so" (or ".sl" for HP-UX), so rename the library
+- # to its proper name (with version) after linking.
+- _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+-
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+-
+- # Archives containing C++ object files must be created using
+- # "CC -Bstatic", where "CC" is the KAI C++ compiler.
+- _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs'
+-
+- ;;
+- RCC*)
+- # Rational C++ 2.4.1
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- cxx*)
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && echo ${wl}-set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+-
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+-
+- # Commands to make compiler produce verbose output that lists
+- # what "hidden" libraries, object files and flags are used when
+- # linking a shared library.
+- #
+- # There doesn't appear to be a way to prevent this compiler from
+- # explicitly linking system object files so we need to strip them
+- # from the output so that they don't get included in the library
+- # dependencies.
+- output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+- ;;
+- *)
+- if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+-
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+-
+- # Commands to make compiler produce verbose output that lists
+- # what "hidden" libraries, object files and flags are used when
+- # linking a shared library.
+- output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"'
++ done
++ IFS="$lt_save_ifs"
++else
++ lt_cv_path_LD="$LD" # Let the user override the test with a path.
++fi])
++LD="$lt_cv_path_LD"
++if test -n "$LD"; then
++ AC_MSG_RESULT($LD)
++else
++ AC_MSG_RESULT(no)
++fi
++test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
++_LT_PATH_LD_GNU
++AC_SUBST([LD])
+
+- else
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- fi
+- ;;
+- esac
+- ;;
+- osf4* | osf5*)
+- case $cc_basename in
+- KCC*)
+- # Kuck and Associates, Inc. (KAI) C++ Compiler
+-
+- # KCC will only create a shared library if the output file
+- # ends with ".so" (or ".sl" for HP-UX), so rename the library
+- # to its proper name (with version) after linking.
+- _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+-
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+-
+- # Archives containing C++ object files must be created using
+- # the KAI C++ compiler.
+- _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs'
+- ;;
+- RCC*)
+- # Rational C++ 2.4.1
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- cxx*)
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
+- echo "-hidden">> $lib.exp~
+- $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname -Wl,-input -Wl,$lib.exp `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~
+- $rm $lib.exp'
+-
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+-
+- # Commands to make compiler produce verbose output that lists
+- # what "hidden" libraries, object files and flags are used when
+- # linking a shared library.
+- #
+- # There doesn't appear to be a way to prevent this compiler from
+- # explicitly linking system object files so we need to strip them
+- # from the output so that they don't get included in the library
+- # dependencies.
+- output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+- ;;
+- *)
+- if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+-
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+-
+- # Commands to make compiler produce verbose output that lists
+- # what "hidden" libraries, object files and flags are used when
+- # linking a shared library.
+- output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"'
++_LT_TAGDECL([], [LD], [1], [The linker used to build libraries])
++])# LT_PATH_LD
+
+- else
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- fi
+- ;;
+- esac
+- ;;
+- psos*)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- sunos4*)
+- case $cc_basename in
+- CC*)
+- # Sun C++ 4.x
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- lcc*)
+- # Lucid
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- *)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- esac
++# Old names:
++AU_ALIAS([AM_PROG_LD], [LT_PATH_LD])
++AU_ALIAS([AC_PROG_LD], [LT_PATH_LD])
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([AM_PROG_LD], [])
++dnl AC_DEFUN([AC_PROG_LD], [])
++
++
++# _LT_PATH_LD_GNU
++#- --------------
++m4_defun([_LT_PATH_LD_GNU],
++[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], lt_cv_prog_gnu_ld,
++[# I'd rather use --version here, but apparently some GNU lds only accept -v.
++case `$LD -v 2>&1 </dev/null` in
++*GNU* | *'with BFD'*)
++ lt_cv_prog_gnu_ld=yes
++ ;;
++*)
++ lt_cv_prog_gnu_ld=no
++ ;;
++esac])
++with_gnu_ld=$lt_cv_prog_gnu_ld
++])# _LT_PATH_LD_GNU
++
++
++# _LT_CMD_RELOAD
++# --------------
++# find reload flag for linker
++# -- PORTME Some linkers may need a different reload flag.
++m4_defun([_LT_CMD_RELOAD],
++[AC_CACHE_CHECK([for $LD option to reload object files],
++ lt_cv_ld_reload_flag,
++ [lt_cv_ld_reload_flag='-r'])
++reload_flag=$lt_cv_ld_reload_flag
++case $reload_flag in
++"" | " "*) ;;
++*) reload_flag=" $reload_flag" ;;
++esac
++reload_cmds='$LD$reload_flag -o $output$reload_objs'
++case $host_os in
++ darwin*)
++ if test "$GCC" = yes; then
++ reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
++ else
++ reload_cmds='$LD$reload_flag -o $output$reload_objs'
++ fi
+ ;;
+- solaris*)
+- case $cc_basename in
+- CC*)
+- # Sun C++ 4.2, 5.x and Centerline C++
+- _LT_AC_TAGVAR(archive_cmds_need_lc,$1)=yes
+- _LT_AC_TAGVAR(no_undefined_flag, $1)=' -zdefs'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+- $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
+-
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- case $host_os in
+- solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
+- *)
+- # The C++ compiler is used as linker so we must use $wl
+- # flag to pass the commands to the underlying system
+- # linker. We must also pass each convience library through
+- # to the system linker between allextract/defaultextract.
+- # The C++ compiler will combine linker options so we
+- # cannot just pass the convience library names through
+- # without $wl.
+- # Supported since Solaris 2.6 (maybe 2.5.1?)
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract'
+- ;;
+- esac
+- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
++esac
++_LT_DECL([], [reload_flag], [1], [How to create reloadable object files])dnl
++_LT_DECL([], [reload_cmds], [2])dnl
++])# _LT_CMD_RELOAD
+
+- output_verbose_link_cmd='echo'
+
+- # Archives containing C++ object files must be created using
+- # "CC -xar", where "CC" is the Sun C++ compiler. This is
+- # necessary to make sure instantiated templates are included
+- # in the archive.
+- _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
+- ;;
+- gcx*)
+- # Green Hills C++ Compiler
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
++# _LT_CHECK_MAGIC_METHOD
++# ----------------------
++# how to check for library dependencies
++# -- PORTME fill in with the dynamic library characteristics
++m4_defun([_LT_CHECK_MAGIC_METHOD],
++[m4_require([_LT_DECL_EGREP])
++AC_CACHE_CHECK([how to recognize dependent libraries],
++lt_cv_deplibs_check_method,
++[lt_cv_file_magic_cmd='$MAGIC_CMD'
++lt_cv_file_magic_test_file=
++lt_cv_deplibs_check_method='unknown'
++# Need to set the preceding variable on all platforms that support
++# interlibrary dependencies.
++# 'none' -- dependencies not supported.
++# `unknown' -- same as none, but documents that we really don't know.
++# 'pass_all' -- all dependencies passed with no checks.
++# 'test_compile' -- check by making test program.
++# 'file_magic [[regex]]' -- check by looking for files in library path
++# which responds to the $file_magic_cmd with a given extended regex.
++# If you have `file' or equivalent on your system and you're not sure
++# whether `pass_all' will *always* work, you probably want this one.
+
+- # The C++ compiler must be used to create the archive.
+- _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
+- ;;
+- *)
+- # GNU C++ compiler with Solaris linker
+- if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+- _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs'
+- if $CC --version | grep -v '^2\.7' > /dev/null; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+- $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
++case $host_os in
++aix[[4-9]]*)
++ lt_cv_deplibs_check_method=pass_all
++ ;;
+
+- # Commands to make compiler produce verbose output that lists
+- # what "hidden" libraries, object files and flags are used when
+- # linking a shared library.
+- output_verbose_link_cmd="$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\""
+- else
+- # g++ 2.7 appears to require `-G' NOT `-shared' on this
+- # platform.
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+- $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
++beos*)
++ lt_cv_deplibs_check_method=pass_all
++ ;;
+
+- # Commands to make compiler produce verbose output that lists
+- # what "hidden" libraries, object files and flags are used when
+- # linking a shared library.
+- output_verbose_link_cmd="$CC -G $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\""
+- fi
++bsdi[[45]]*)
++ lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib)'
++ lt_cv_file_magic_cmd='/usr/bin/file -L'
++ lt_cv_file_magic_test_file=/shlib/libc.so
++ ;;
+
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir'
+- fi
+- ;;
+- esac
+- ;;
+- sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
+- _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- runpath_var='LD_RUN_PATH'
+-
+- case $cc_basename in
+- CC*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+- ;;
+- *)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+- ;;
+- esac
+- ;;
+- sysv5* | sco3.2v5* | sco5v6*)
+- # Note: We can NOT use -z defs as we might desire, because we do not
+- # link with -lc, and that would cause any symbols used from libc to
+- # always be unresolved, which means just about no library would
+- # ever link correctly. If we're not using GNU ld we use -z text
+- # though, which does catch some bad symbols but isn't as heavy-handed
+- # as -z defs.
+- # For security reasons, it is highly recommended that you always
+- # use absolute paths for naming shared libraries, and exclude the
+- # DT_RUNPATH tag from executables and libraries. But doing so
+- # requires that you compile everything twice, which is a pain.
+- # So that behaviour is only enabled if SCOABSPATH is set to a
+- # non-empty value in the environment. Most likely only useful for
+- # creating official distributions of packages.
+- # This is a hack until libtool officially supports absolute path
+- # names for shared libraries.
+- _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
+- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':'
+- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
+- runpath_var='LD_RUN_PATH'
+-
+- case $cc_basename in
+- CC*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+- ;;
+- *)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+- ;;
+- esac
+- ;;
+- tandem*)
+- case $cc_basename in
+- NCC*)
+- # NonStop-UX NCC 3.20
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- *)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
++cygwin*)
++ # func_win32_libid is a shell function defined in ltmain.sh
++ lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
++ lt_cv_file_magic_cmd='func_win32_libid'
++ ;;
++
++mingw* | pw32*)
++ # Base MSYS/MinGW do not provide the 'file' command needed by
++ # func_win32_libid shell function, so use a weaker test based on 'objdump',
++ # unless we find 'file', for example because we are cross-compiling.
++ if ( file / ) >/dev/null 2>&1; then
++ lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
++ lt_cv_file_magic_cmd='func_win32_libid'
++ else
++ lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?'
++ lt_cv_file_magic_cmd='$OBJDUMP -f'
++ fi
++ ;;
++
++darwin* | rhapsody*)
++ lt_cv_deplibs_check_method=pass_all
++ ;;
++
++freebsd* | dragonfly*)
++ if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
++ case $host_cpu in
++ i*86 )
++ # Not sure whether the presence of OpenBSD here was a mistake.
++ # Let's accept both of them until this is cleared up.
++ lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library'
++ lt_cv_file_magic_cmd=/usr/bin/file
++ lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
++ ;;
+ esac
++ else
++ lt_cv_deplibs_check_method=pass_all
++ fi
++ ;;
++
++gnu*)
++ lt_cv_deplibs_check_method=pass_all
++ ;;
++
++hpux10.20* | hpux11*)
++ lt_cv_file_magic_cmd=/usr/bin/file
++ case $host_cpu in
++ ia64*)
++ lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64'
++ lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
+ ;;
+- vxworks*)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
++ hppa*64*)
++ [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]']
++ lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
+ ;;
+ *)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
++ lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]].[[0-9]]) shared library'
++ lt_cv_file_magic_test_file=/usr/lib/libc.sl
+ ;;
+-esac
+-AC_MSG_RESULT([$_LT_AC_TAGVAR(ld_shlibs, $1)])
+-test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
++ esac
++ ;;
+
+-_LT_AC_TAGVAR(GCC, $1)="$GXX"
+-_LT_AC_TAGVAR(LD, $1)="$LD"
++interix[[3-9]]*)
++ # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
++ lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$'
++ ;;
+
+-## CAVEAT EMPTOR:
+-## There is no encapsulation within the following macros, do not change
+-## the running order or otherwise move them around unless you know exactly
+-## what you are doing...
+-AC_LIBTOOL_POSTDEP_PREDEP($1)
+-AC_LIBTOOL_PROG_COMPILER_PIC($1)
+-AC_LIBTOOL_PROG_CC_C_O($1)
+-AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
+-AC_LIBTOOL_PROG_LD_SHLIBS($1)
+-AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
+-AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
++irix5* | irix6* | nonstopux*)
++ case $LD in
++ *-32|*"-32 ") libmagic=32-bit;;
++ *-n32|*"-n32 ") libmagic=N32;;
++ *-64|*"-64 ") libmagic=64-bit;;
++ *) libmagic=never-match;;
++ esac
++ lt_cv_deplibs_check_method=pass_all
++ ;;
+
+-AC_LIBTOOL_CONFIG($1)
++# This must be Linux ELF.
++linux* | k*bsd*-gnu)
++ lt_cv_deplibs_check_method=pass_all
++ ;;
+
+-AC_LANG_POP
+-CC=$lt_save_CC
+-LDCXX=$LD
+-LD=$lt_save_LD
+-GCC=$lt_save_GCC
+-with_gnu_ldcxx=$with_gnu_ld
+-with_gnu_ld=$lt_save_with_gnu_ld
+-lt_cv_path_LDCXX=$lt_cv_path_LD
+-lt_cv_path_LD=$lt_save_path_LD
+-lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
+-lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
+-])# AC_LIBTOOL_LANG_CXX_CONFIG
++netbsd*)
++ if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
++ lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
++ else
++ lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$'
++ fi
++ ;;
+
+-# AC_LIBTOOL_POSTDEP_PREDEP([TAGNAME])
+-# ------------------------------------
+-# Figure out "hidden" library dependencies from verbose
+-# compiler output when linking a shared library.
+-# Parse the compiler output and extract the necessary
+-# objects, libraries and library flags.
+-AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP],[
+-dnl we can't use the lt_simple_compile_test_code here,
+-dnl because it contains code intended for an executable,
+-dnl not a library. It's possible we should let each
+-dnl tag define a new lt_????_link_test_code variable,
+-dnl but it's only used here...
+-ifelse([$1],[],[cat > conftest.$ac_ext <<EOF
+-int a;
+-void foo (void) { a = 0; }
+-EOF
+-],[$1],[CXX],[cat > conftest.$ac_ext <<EOF
+-class Foo
+-{
+-public:
+- Foo (void) { a = 0; }
+-private:
+- int a;
+-};
+-EOF
+-],[$1],[F77],[cat > conftest.$ac_ext <<EOF
+- subroutine foo
+- implicit none
+- integer*4 a
+- a=0
+- return
+- end
+-EOF
+-],[$1],[GCJ],[cat > conftest.$ac_ext <<EOF
+-public class foo {
+- private int a;
+- public void bar (void) {
+- a = 0;
+- }
+-};
+-EOF
+-])
+-dnl Parse the compiler output and extract the necessary
+-dnl objects, libraries and library flags.
+-if AC_TRY_EVAL(ac_compile); then
+- # Parse the compiler output and extract the necessary
+- # objects, libraries and library flags.
++newos6*)
++ lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)'
++ lt_cv_file_magic_cmd=/usr/bin/file
++ lt_cv_file_magic_test_file=/usr/lib/libnls.so
++ ;;
+
+- # Sentinel used to keep track of whether or not we are before
+- # the conftest object file.
+- pre_test_object_deps_done=no
++*nto* | *qnx*)
++ lt_cv_deplibs_check_method=pass_all
++ ;;
+
+- # The `*' in the case matches for architectures that use `case' in
+- # $output_verbose_cmd can trigger glob expansion during the loop
+- # eval without this substitution.
+- output_verbose_link_cmd=`$echo "X$output_verbose_link_cmd" | $Xsed -e "$no_glob_subst"`
++openbsd*)
++ if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
++ lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$'
++ else
++ lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
++ fi
++ ;;
+
+- for p in `eval $output_verbose_link_cmd`; do
+- case $p in
++osf3* | osf4* | osf5*)
++ lt_cv_deplibs_check_method=pass_all
++ ;;
+
+- -L* | -R* | -l*)
+- # Some compilers place space between "-{L,R}" and the path.
+- # Remove the space.
+- if test $p = "-L" \
+- || test $p = "-R"; then
+- prev=$p
+- continue
+- else
+- prev=
+- fi
++rdos*)
++ lt_cv_deplibs_check_method=pass_all
++ ;;
++
++solaris*)
++ lt_cv_deplibs_check_method=pass_all
++ ;;
++
++sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
++ lt_cv_deplibs_check_method=pass_all
++ ;;
++
++sysv4 | sysv4.3*)
++ case $host_vendor in
++ motorola)
++ lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]'
++ lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
++ ;;
++ ncr)
++ lt_cv_deplibs_check_method=pass_all
++ ;;
++ sequent)
++ lt_cv_file_magic_cmd='/bin/file'
++ lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )'
++ ;;
++ sni)
++ lt_cv_file_magic_cmd='/bin/file'
++ lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib"
++ lt_cv_file_magic_test_file=/lib/libc.so
++ ;;
++ siemens)
++ lt_cv_deplibs_check_method=pass_all
++ ;;
++ pc)
++ lt_cv_deplibs_check_method=pass_all
++ ;;
++ esac
++ ;;
++
++tpf*)
++ lt_cv_deplibs_check_method=pass_all
++ ;;
++esac
++])
++file_magic_cmd=$lt_cv_file_magic_cmd
++deplibs_check_method=$lt_cv_deplibs_check_method
++test -z "$deplibs_check_method" && deplibs_check_method=unknown
++
++_LT_DECL([], [deplibs_check_method], [1],
++ [Method to check whether dependent libraries are shared objects])
++_LT_DECL([], [file_magic_cmd], [1],
++ [Command to use when deplibs_check_method == "file_magic"])
++])# _LT_CHECK_MAGIC_METHOD
++
++
++# LT_PATH_NM
++# ----------
++# find the pathname to a BSD- or MS-compatible name lister
++AC_DEFUN([LT_PATH_NM],
++[AC_REQUIRE([AC_PROG_CC])dnl
++AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM,
++[if test -n "$NM"; then
++ # Let the user override the test.
++ lt_cv_path_NM="$NM"
++else
++ lt_nm_to_check="${ac_tool_prefix}nm"
++ if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
++ lt_nm_to_check="$lt_nm_to_check nm"
++ fi
++ for lt_tmp_nm in $lt_nm_to_check; do
++ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
++ for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
++ IFS="$lt_save_ifs"
++ test -z "$ac_dir" && ac_dir=.
++ tmp_nm="$ac_dir/$lt_tmp_nm"
++ if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
++ # Check to see if the nm accepts a BSD-compat flag.
++ # Adding the `sed 1q' prevents false positives on HP-UX, which says:
++ # nm: unknown option "B" ignored
++ # Tru64's nm complains that /dev/null is an invalid object file
++ case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
++ */dev/null* | *'Invalid file or object type'*)
++ lt_cv_path_NM="$tmp_nm -B"
++ break
++ ;;
++ *)
++ case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
++ */dev/null*)
++ lt_cv_path_NM="$tmp_nm -p"
++ break
++ ;;
++ *)
++ lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
++ continue # so that we can try to find one that supports BSD flags
++ ;;
++ esac
++ ;;
++ esac
++ fi
++ done
++ IFS="$lt_save_ifs"
++ done
++ : ${lt_cv_path_NM=no}
++fi])
++if test "$lt_cv_path_NM" != "no"; then
++ NM="$lt_cv_path_NM"
++else
++ # Didn't find any BSD compatible name lister, look for dumpbin.
++ AC_CHECK_TOOLS(DUMPBIN, ["dumpbin -symbols" "link -dump -symbols"], :)
++ AC_SUBST([DUMPBIN])
++ if test "$DUMPBIN" != ":"; then
++ NM="$DUMPBIN"
++ fi
++fi
++test -z "$NM" && NM=nm
++AC_SUBST([NM])
++_LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl
++
++AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface],
++ [lt_cv_nm_interface="BSD nm"
++ echo "int some_variable = 0;" > conftest.$ac_ext
++ (eval echo "\"\$as_me:__oline__: $ac_compile\"" >&AS_MESSAGE_LOG_FD)
++ (eval "$ac_compile" 2>conftest.err)
++ cat conftest.err >&AS_MESSAGE_LOG_FD
++ (eval echo "\"\$as_me:__oline__: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD)
++ (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
++ cat conftest.err >&AS_MESSAGE_LOG_FD
++ (eval echo "\"\$as_me:__oline__: output\"" >&AS_MESSAGE_LOG_FD)
++ cat conftest.out >&AS_MESSAGE_LOG_FD
++ if $GREP 'External.*some_variable' conftest.out > /dev/null; then
++ lt_cv_nm_interface="MS dumpbin"
++ fi
++ rm -f conftest*])
++])# LT_PATH_NM
++
++# Old names:
++AU_ALIAS([AM_PROG_NM], [LT_PATH_NM])
++AU_ALIAS([AC_PROG_NM], [LT_PATH_NM])
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([AM_PROG_NM], [])
++dnl AC_DEFUN([AC_PROG_NM], [])
++
++
++# LT_LIB_M
++# --------
++# check for math library
++AC_DEFUN([LT_LIB_M],
++[AC_REQUIRE([AC_CANONICAL_HOST])dnl
++LIBM=
++case $host in
++*-*-beos* | *-*-cygwin* | *-*-pw32* | *-*-darwin*)
++ # These system don't have libm, or don't need it
++ ;;
++*-ncr-sysv4.3*)
++ AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
++ AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm")
++ ;;
++*)
++ AC_CHECK_LIB(m, cos, LIBM="-lm")
++ ;;
++esac
++AC_SUBST([LIBM])
++])# LT_LIB_M
++
++# Old name:
++AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M])
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([AC_CHECK_LIBM], [])
++
++
++# _LT_COMPILER_NO_RTTI([TAGNAME])
++# -------------------------------
++m4_defun([_LT_COMPILER_NO_RTTI],
++[m4_require([_LT_TAG_COMPILER])dnl
++
++_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
++
++if test "$GCC" = yes; then
++ _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
++
++ _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions],
++ lt_cv_prog_compiler_rtti_exceptions,
++ [-fno-rtti -fno-exceptions], [],
++ [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"])
++fi
++_LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1],
++ [Compiler flag to turn off builtin functions])
++])# _LT_COMPILER_NO_RTTI
++
++
++# _LT_CMD_GLOBAL_SYMBOLS
++# ----------------------
++m4_defun([_LT_CMD_GLOBAL_SYMBOLS],
++[AC_REQUIRE([AC_CANONICAL_HOST])dnl
++AC_REQUIRE([AC_PROG_CC])dnl
++AC_REQUIRE([LT_PATH_NM])dnl
++AC_REQUIRE([LT_PATH_LD])dnl
++m4_require([_LT_DECL_SED])dnl
++m4_require([_LT_DECL_EGREP])dnl
++m4_require([_LT_TAG_COMPILER])dnl
++
++# Check for command to grab the raw symbol name followed by C symbol from nm.
++AC_MSG_CHECKING([command to parse $NM output from $compiler object])
++AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe],
++[
++# These are sane defaults that work on at least a few old systems.
++# [They come from Ultrix. What could be older than Ultrix?!! ;)]
++
++# Character class describing NM global symbol codes.
++symcode='[[BCDEGRST]]'
++
++# Regexp to match symbols that can be accessed directly from C.
++sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)'
++
++# Define system-specific variables.
++case $host_os in
++aix*)
++ symcode='[[BCDT]]'
++ ;;
++cygwin* | mingw* | pw32*)
++ symcode='[[ABCDGISTW]]'
++ ;;
++hpux*)
++ if test "$host_cpu" = ia64; then
++ symcode='[[ABCDEGRST]]'
++ fi
++ ;;
++irix* | nonstopux*)
++ symcode='[[BCDEGRST]]'
++ ;;
++osf*)
++ symcode='[[BCDEGQRST]]'
++ ;;
++solaris*)
++ symcode='[[BDRT]]'
++ ;;
++sco3.2v5*)
++ symcode='[[DT]]'
++ ;;
++sysv4.2uw2*)
++ symcode='[[DT]]'
++ ;;
++sysv5* | sco5v6* | unixware* | OpenUNIX*)
++ symcode='[[ABDT]]'
++ ;;
++sysv4)
++ symcode='[[DFNSTU]]'
++ ;;
++esac
++
++# If we're using GNU nm, then use its standard symbol codes.
++case `$NM -V 2>&1` in
++*GNU* | *'with BFD'*)
++ symcode='[[ABCDGIRSTW]]' ;;
++esac
++
++# Transform an extracted symbol line into a proper C declaration.
++# Some systems (esp. on ia64) link data and code symbols differently,
++# so use this general approach.
++lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
++
++# Transform an extracted symbol line into symbol name and symbol address
++lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p'"
++lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"lib\2\", (void *) \&\2},/p'"
++
++# Handle CRLF in mingw tool chain
++opt_cr=
++case $build_os in
++mingw*)
++ opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp
++ ;;
++esac
++
++# Try without a prefix underscore, then with it.
++for ac_symprfx in "" "_"; do
++
++ # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
++ symxfrm="\\1 $ac_symprfx\\2 \\2"
++
++ # Write the raw and C identifiers.
++ if test "$lt_cv_nm_interface" = "MS dumpbin"; then
++ # Fake it for dumpbin and say T for any non-static function
++ # and D for any global variable.
++ # Also find C++ and __fastcall symbols from MSVC++,
++ # which start with @ or ?.
++ lt_cv_sys_global_symbol_pipe="$AWK ['"\
++" {last_section=section; section=\$ 3};"\
++" /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\
++" \$ 0!~/External *\|/{next};"\
++" / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\
++" {if(hide[section]) next};"\
++" {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\
++" {split(\$ 0, a, /\||\r/); split(a[2], s)};"\
++" s[1]~/^[@?]/{print s[1], s[1]; next};"\
++" s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\
++" ' prfx=^$ac_symprfx]"
++ else
++ lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
++ fi
++
++ # Check to see that the pipe works correctly.
++ pipe_works=no
++
++ rm -f conftest*
++ cat > conftest.$ac_ext <<_LT_EOF
++#ifdef __cplusplus
++extern "C" {
++#endif
++char nm_test_var;
++void nm_test_func(void);
++void nm_test_func(void){}
++#ifdef __cplusplus
++}
++#endif
++int main(){nm_test_var='a';nm_test_func();return(0);}
++_LT_EOF
++
++ if AC_TRY_EVAL(ac_compile); then
++ # Now try to grab the symbols.
++ nlist=conftest.nm
++ if AC_TRY_EVAL(NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) && test -s "$nlist"; then
++ # Try sorting and uniquifying the output.
++ if sort "$nlist" | uniq > "$nlist"T; then
++ mv -f "$nlist"T "$nlist"
++ else
++ rm -f "$nlist"T
++ fi
++
++ # Make sure that we snagged all the symbols we need.
++ if $GREP ' nm_test_var$' "$nlist" >/dev/null; then
++ if $GREP ' nm_test_func$' "$nlist" >/dev/null; then
++ cat <<_LT_EOF > conftest.$ac_ext
++#ifdef __cplusplus
++extern "C" {
++#endif
++
++_LT_EOF
++ # Now generate the symbol file.
++ eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext'
++
++ cat <<_LT_EOF >> conftest.$ac_ext
++
++/* The mapping between symbol names and symbols. */
++const struct {
++ const char *name;
++ void *address;
++}
++lt__PROGRAM__LTX_preloaded_symbols[[]] =
++{
++ { "@PROGRAM@", (void *) 0 },
++_LT_EOF
++ $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
++ cat <<\_LT_EOF >> conftest.$ac_ext
++ {0, (void *) 0}
++};
++
++/* This works around a problem in FreeBSD linker */
++#ifdef FREEBSD_WORKAROUND
++static const void *lt_preloaded_setup() {
++ return lt__PROGRAM__LTX_preloaded_symbols;
++}
++#endif
++
++#ifdef __cplusplus
++}
++#endif
++_LT_EOF
++ # Now try linking the two files.
++ mv conftest.$ac_objext conftstm.$ac_objext
++ lt_save_LIBS="$LIBS"
++ lt_save_CFLAGS="$CFLAGS"
++ LIBS="conftstm.$ac_objext"
++ CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)"
++ if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then
++ pipe_works=yes
++ fi
++ LIBS="$lt_save_LIBS"
++ CFLAGS="$lt_save_CFLAGS"
++ else
++ echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD
++ fi
++ else
++ echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD
++ fi
++ else
++ echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD
++ fi
++ else
++ echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD
++ cat conftest.$ac_ext >&5
++ fi
++ rm -rf conftest* conftst*
+
+- if test "$pre_test_object_deps_done" = no; then
+- case $p in
+- -L* | -R*)
+- # Internal compiler library paths should come after those
+- # provided the user. The postdeps already come after the
+- # user supplied libs so there is no need to process them.
+- if test -z "$_LT_AC_TAGVAR(compiler_lib_search_path, $1)"; then
+- _LT_AC_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}"
+- else
+- _LT_AC_TAGVAR(compiler_lib_search_path, $1)="${_LT_AC_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}"
+- fi
+- ;;
+- # The "-l" case would never come before the object being
+- # linked, so don't bother handling this case.
+- esac
+- else
+- if test -z "$_LT_AC_TAGVAR(postdeps, $1)"; then
+- _LT_AC_TAGVAR(postdeps, $1)="${prev}${p}"
+- else
+- _LT_AC_TAGVAR(postdeps, $1)="${_LT_AC_TAGVAR(postdeps, $1)} ${prev}${p}"
+- fi
+- fi
+- ;;
++ # Do not use the global_symbol_pipe unless it works.
++ if test "$pipe_works" = yes; then
++ break
++ else
++ lt_cv_sys_global_symbol_pipe=
++ fi
++done
++])
++if test -z "$lt_cv_sys_global_symbol_pipe"; then
++ lt_cv_sys_global_symbol_to_cdecl=
++fi
++if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
++ AC_MSG_RESULT(failed)
++else
++ AC_MSG_RESULT(ok)
++fi
+
+- *.$objext)
+- # This assumes that the test object file only shows up
+- # once in the compiler output.
+- if test "$p" = "conftest.$objext"; then
+- pre_test_object_deps_done=yes
+- continue
+- fi
++_LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1],
++ [Take the output of nm and produce a listing of raw symbols and C names])
++_LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1],
++ [Transform the output of nm in a proper C declaration])
++_LT_DECL([global_symbol_to_c_name_address],
++ [lt_cv_sys_global_symbol_to_c_name_address], [1],
++ [Transform the output of nm in a C name address pair])
++_LT_DECL([global_symbol_to_c_name_address_lib_prefix],
++ [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1],
++ [Transform the output of nm in a C name address pair when lib prefix is needed])
++]) # _LT_CMD_GLOBAL_SYMBOLS
+
+- if test "$pre_test_object_deps_done" = no; then
+- if test -z "$_LT_AC_TAGVAR(predep_objects, $1)"; then
+- _LT_AC_TAGVAR(predep_objects, $1)="$p"
+- else
+- _LT_AC_TAGVAR(predep_objects, $1)="$_LT_AC_TAGVAR(predep_objects, $1) $p"
+- fi
+- else
+- if test -z "$_LT_AC_TAGVAR(postdep_objects, $1)"; then
+- _LT_AC_TAGVAR(postdep_objects, $1)="$p"
+- else
+- _LT_AC_TAGVAR(postdep_objects, $1)="$_LT_AC_TAGVAR(postdep_objects, $1) $p"
+- fi
+- fi
+- ;;
+
+- *) ;; # Ignore the rest.
++# _LT_COMPILER_PIC([TAGNAME])
++# ---------------------------
++m4_defun([_LT_COMPILER_PIC],
++[m4_require([_LT_TAG_COMPILER])dnl
++_LT_TAGVAR(lt_prog_compiler_wl, $1)=
++_LT_TAGVAR(lt_prog_compiler_pic, $1)=
++_LT_TAGVAR(lt_prog_compiler_static, $1)=
++
++AC_MSG_CHECKING([for $compiler option to produce PIC])
++m4_if([$1], [CXX], [
++ # C++ specific cases for pic, static, wl, etc.
++ if test "$GXX" = yes; then
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+
++ case $host_os in
++ aix*)
++ # All AIX code is PIC.
++ if test "$host_cpu" = ia64; then
++ # AIX 5 now supports IA64 processor
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ fi
++ ;;
++
++ amigaos*)
++ case $host_cpu in
++ powerpc)
++ # see comment about AmigaOS4 .so support
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
++ ;;
++ m68k)
++ # FIXME: we need at least 68020 code to build shared libraries, but
++ # adding the `-m68020' flag to GCC prevents building anything better,
++ # like `-m68040'.
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
++ ;;
++ esac
++ ;;
++
++ beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
++ # PIC is the default for these OSes.
++ ;;
++ mingw* | cygwin* | os2* | pw32*)
++ # This hack is so that the source file can tell whether it is being
++ # built for inclusion in a dll (and should export symbols for example).
++ # Although the cygwin gcc ignores -fPIC, still need this for old-style
++ # (--disable-auto-import) libraries
++ m4_if([$1], [GCJ], [],
++ [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
++ ;;
++ darwin* | rhapsody*)
++ # PIC is the default on this platform
++ # Common symbols not allowed in MH_DYLIB files
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
++ ;;
++ *djgpp*)
++ # DJGPP does not support shared libraries at all
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)=
++ ;;
++ interix[[3-9]]*)
++ # Interix 3.x gcc -fpic/-fPIC options generate broken code.
++ # Instead, we relocate shared libraries at runtime.
++ ;;
++ sysv4*MP*)
++ if test -d /usr/nec; then
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
++ fi
++ ;;
++ hpux*)
++ # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
++ # not for PA HP-UX.
++ case $host_cpu in
++ hppa*64*|ia64*)
++ ;;
++ *)
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
++ ;;
++ esac
++ ;;
++ *qnx* | *nto*)
++ # QNX uses GNU C++, but need to define -shared option too, otherwise
++ # it will coredump.
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
++ ;;
++ *)
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
++ ;;
++ esac
++ else
++ case $host_os in
++ aix[[4-9]]*)
++ # All AIX code is PIC.
++ if test "$host_cpu" = ia64; then
++ # AIX 5 now supports IA64 processor
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ else
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
++ fi
++ ;;
++ chorus*)
++ case $cc_basename in
++ cxch68*)
++ # Green Hills C++ Compiler
++ # _LT_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a"
++ ;;
++ esac
++ ;;
++ dgux*)
++ case $cc_basename in
++ ec++*)
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ ;;
++ ghcx*)
++ # Green Hills C++ Compiler
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
++ ;;
++ *)
++ ;;
++ esac
++ ;;
++ freebsd* | dragonfly*)
++ # FreeBSD uses GNU C++
++ ;;
++ hpux9* | hpux10* | hpux11*)
++ case $cc_basename in
++ CC*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
++ if test "$host_cpu" != ia64; then
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
++ fi
++ ;;
++ aCC*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
++ case $host_cpu in
++ hppa*64*|ia64*)
++ # +Z the default
++ ;;
++ *)
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
++ ;;
++ esac
++ ;;
++ *)
++ ;;
++ esac
++ ;;
++ interix*)
++ # This is c89, which is MS Visual C++ (no shared libs)
++ # Anyone wants to do a port?
++ ;;
++ irix5* | irix6* | nonstopux*)
++ case $cc_basename in
++ CC*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
++ # CC pic flag -KPIC is the default.
++ ;;
++ *)
++ ;;
++ esac
++ ;;
++ linux* | k*bsd*-gnu)
++ case $cc_basename in
++ KCC*)
++ # KAI C++ Compiler
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
++ ;;
++ icpc* | ecpc* )
++ # Intel C++
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
++ ;;
++ pgCC* | pgcpp*)
++ # Portland Group C++ compiler
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ ;;
++ cxx*)
++ # Compaq C++
++ # Make sure the PIC flag is empty. It appears that all Alpha
++ # Linux and Compaq Tru64 Unix objects are PIC.
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)=
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
++ ;;
++ xlc* | xlC*)
++ # IBM XL 8.0 on PPC
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink'
++ ;;
++ *)
++ case `$CC -V 2>&1 | sed 5q` in
++ *Sun\ C*)
++ # Sun C++ 5.9
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
++ ;;
++ esac
++ ;;
++ esac
++ ;;
++ lynxos*)
++ ;;
++ m88k*)
++ ;;
++ mvs*)
++ case $cc_basename in
++ cxx*)
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall'
++ ;;
++ *)
++ ;;
++ esac
++ ;;
++ netbsd*)
++ ;;
++ *qnx* | *nto*)
++ # QNX uses GNU C++, but need to define -shared option too, otherwise
++ # it will coredump.
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
++ ;;
++ osf3* | osf4* | osf5*)
++ case $cc_basename in
++ KCC*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
++ ;;
++ RCC*)
++ # Rational C++ 2.4.1
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
++ ;;
++ cxx*)
++ # Digital/Compaq C++
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ # Make sure the PIC flag is empty. It appears that all Alpha
++ # Linux and Compaq Tru64 Unix objects are PIC.
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)=
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
++ ;;
++ *)
++ ;;
++ esac
++ ;;
++ psos*)
++ ;;
++ solaris*)
++ case $cc_basename in
++ CC*)
++ # Sun C++ 4.2, 5.x and Centerline C++
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
++ ;;
++ gcx*)
++ # Green Hills C++ Compiler
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
++ ;;
++ *)
++ ;;
++ esac
++ ;;
++ sunos4*)
++ case $cc_basename in
++ CC*)
++ # Sun C++ 4.x
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ ;;
++ lcc*)
++ # Lucid
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
++ ;;
++ *)
++ ;;
++ esac
++ ;;
++ sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
++ case $cc_basename in
++ CC*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ ;;
++ esac
++ ;;
++ tandem*)
++ case $cc_basename in
++ NCC*)
++ # NonStop-UX NCC 3.20
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ ;;
++ *)
++ ;;
++ esac
++ ;;
++ vxworks*)
++ ;;
++ *)
++ _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
++ ;;
+ esac
+- done
+-
+- # Clean up.
+- rm -f a.out a.exe
+-else
+- echo "libtool.m4: error: problem compiling $1 test program"
+-fi
+-
+-$rm -f confest.$objext
+-
+-# PORTME: override above test on systems where it is broken
+-ifelse([$1],[CXX],
+-[case $host_os in
+-interix3*)
+- # Interix 3.5 installs completely hosed .la files for C++, so rather than
+- # hack all around it, let's just trust "g++" to DTRT.
+- _LT_AC_TAGVAR(predep_objects,$1)=
+- _LT_AC_TAGVAR(postdep_objects,$1)=
+- _LT_AC_TAGVAR(postdeps,$1)=
+- ;;
+-
+-linux*)
+- case `$CC -V 2>&1 | sed 5q` in
+- *Sun\ C*)
+- # Sun C++ 5.9
+- _LT_AC_TAGVAR(postdeps,$1)='-lCstd -lCrun'
+- ;;
+- esac
+- ;;
+-
+-solaris*)
+- case $cc_basename in
+- CC*)
+- # Adding this requires a known-good setup of shared libraries for
+- # Sun compiler versions before 5.6, else PIC objects from an old
+- # archive will be linked into the output, leading to subtle bugs.
+- _LT_AC_TAGVAR(postdeps,$1)='-lCstd -lCrun'
+- ;;
+- esac
+- ;;
+-esac
+-])
+-
+-case " $_LT_AC_TAGVAR(postdeps, $1) " in
+-*" -lc "*) _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no ;;
+-esac
+-])# AC_LIBTOOL_POSTDEP_PREDEP
+-
+-# AC_LIBTOOL_LANG_F77_CONFIG
+-# --------------------------
+-# Ensure that the configuration vars for the C compiler are
+-# suitably defined. Those variables are subsequently used by
+-# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
+-AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG], [_LT_AC_LANG_F77_CONFIG(F77)])
+-AC_DEFUN([_LT_AC_LANG_F77_CONFIG],
+-[AC_REQUIRE([AC_PROG_F77])
+-AC_LANG_PUSH(Fortran 77)
+-
+-_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+-_LT_AC_TAGVAR(allow_undefined_flag, $1)=
+-_LT_AC_TAGVAR(always_export_symbols, $1)=no
+-_LT_AC_TAGVAR(archive_expsym_cmds, $1)=
+-_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=
+-_LT_AC_TAGVAR(hardcode_direct, $1)=no
+-_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
+-_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
+-_LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
+-_LT_AC_TAGVAR(hardcode_minus_L, $1)=no
+-_LT_AC_TAGVAR(hardcode_automatic, $1)=no
+-_LT_AC_TAGVAR(module_cmds, $1)=
+-_LT_AC_TAGVAR(module_expsym_cmds, $1)=
+-_LT_AC_TAGVAR(link_all_deplibs, $1)=unknown
+-_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+-_LT_AC_TAGVAR(no_undefined_flag, $1)=
+-_LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+-_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+-
+-# Source file extension for f77 test sources.
+-ac_ext=f
+-
+-# Object file extension for compiled f77 test sources.
+-objext=o
+-_LT_AC_TAGVAR(objext, $1)=$objext
+-
+-# Code to be used in simple compile tests
+-lt_simple_compile_test_code=" subroutine t\n return\n end\n"
+-
+-# Code to be used in simple link tests
+-lt_simple_link_test_code=" program t\n end\n"
+-
+-# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+-_LT_AC_SYS_COMPILER
+-
+-# save warnings/boilerplate of simple test code
+-_LT_COMPILER_BOILERPLATE
+-_LT_LINKER_BOILERPLATE
+-
+-# Allow CC to be a program name with arguments.
+-lt_save_CC="$CC"
+-CC=${F77-"f77"}
+-compiler=$CC
+-_LT_AC_TAGVAR(compiler, $1)=$CC
+-_LT_CC_BASENAME([$compiler])
+-
+-AC_MSG_CHECKING([if libtool supports shared libraries])
+-AC_MSG_RESULT([$can_build_shared])
+-
+-AC_MSG_CHECKING([whether to build shared libraries])
+-test "$can_build_shared" = "no" && enable_shared=no
+-
+-# On AIX, shared libraries and static libraries use the same namespace, and
+-# are all built from PIC.
+-case $host_os in
+-aix3*)
+- test "$enable_shared" = yes && enable_static=no
+- if test -n "$RANLIB"; then
+- archive_cmds="$archive_cmds~\$RANLIB \$lib"
+- postinstall_cmds='$RANLIB $lib'
+ fi
+- ;;
+-aix4* | aix5*)
+- if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+- test "$enable_shared" = yes && enable_static=no
+- fi
+- ;;
+-esac
+-AC_MSG_RESULT([$enable_shared])
+-
+-AC_MSG_CHECKING([whether to build static libraries])
+-# Make sure either enable_shared or enable_static is yes.
+-test "$enable_shared" = yes || enable_static=yes
+-AC_MSG_RESULT([$enable_static])
+-
+-_LT_AC_TAGVAR(GCC, $1)="$G77"
+-_LT_AC_TAGVAR(LD, $1)="$LD"
+-
+-AC_LIBTOOL_PROG_COMPILER_PIC($1)
+-AC_LIBTOOL_PROG_CC_C_O($1)
+-AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
+-AC_LIBTOOL_PROG_LD_SHLIBS($1)
+-AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
+-AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
+-
+-AC_LIBTOOL_CONFIG($1)
+-
+-AC_LANG_POP
+-CC="$lt_save_CC"
+-])# AC_LIBTOOL_LANG_F77_CONFIG
+-
+-
+-# AC_LIBTOOL_LANG_GCJ_CONFIG
+-# --------------------------
+-# Ensure that the configuration vars for the C compiler are
+-# suitably defined. Those variables are subsequently used by
+-# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
+-AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG], [_LT_AC_LANG_GCJ_CONFIG(GCJ)])
+-AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG],
+-[AC_LANG_SAVE
+-
+-# Source file extension for Java test sources.
+-ac_ext=java
++],
++[
++ if test "$GCC" = yes; then
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+
+-# Object file extension for compiled Java test sources.
+-objext=o
+-_LT_AC_TAGVAR(objext, $1)=$objext
++ case $host_os in
++ aix*)
++ # All AIX code is PIC.
++ if test "$host_cpu" = ia64; then
++ # AIX 5 now supports IA64 processor
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ fi
++ ;;
+
+-# Code to be used in simple compile tests
+-lt_simple_compile_test_code="class foo {}\n"
++ amigaos*)
++ case $host_cpu in
++ powerpc)
++ # see comment about AmigaOS4 .so support
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
++ ;;
++ m68k)
++ # FIXME: we need at least 68020 code to build shared libraries, but
++ # adding the `-m68020' flag to GCC prevents building anything better,
++ # like `-m68040'.
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
++ ;;
++ esac
++ ;;
+
+-# Code to be used in simple link tests
+-lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }\n'
++ beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
++ # PIC is the default for these OSes.
++ ;;
+
+-# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+-_LT_AC_SYS_COMPILER
++ mingw* | cygwin* | pw32* | os2*)
++ # This hack is so that the source file can tell whether it is being
++ # built for inclusion in a dll (and should export symbols for example).
++ # Although the cygwin gcc ignores -fPIC, still need this for old-style
++ # (--disable-auto-import) libraries
++ m4_if([$1], [GCJ], [],
++ [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
++ ;;
+
+-# save warnings/boilerplate of simple test code
+-_LT_COMPILER_BOILERPLATE
+-_LT_LINKER_BOILERPLATE
++ darwin* | rhapsody*)
++ # PIC is the default on this platform
++ # Common symbols not allowed in MH_DYLIB files
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
++ ;;
+
+-# Allow CC to be a program name with arguments.
+-lt_save_CC="$CC"
+-CC=${GCJ-"gcj"}
+-compiler=$CC
+-_LT_AC_TAGVAR(compiler, $1)=$CC
+-_LT_CC_BASENAME([$compiler])
++ hpux*)
++ # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
++ # not for PA HP-UX.
++ case $host_cpu in
++ hppa*64*|ia64*)
++ # +Z the default
++ ;;
++ *)
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
++ ;;
++ esac
++ ;;
+
+-# GCJ did not exist at the time GCC didn't implicitly link libc in.
+-_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
++ interix[[3-9]]*)
++ # Interix 3.x gcc -fpic/-fPIC options generate broken code.
++ # Instead, we relocate shared libraries at runtime.
++ ;;
+
+-_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
++ msdosdjgpp*)
++ # Just because we use GCC doesn't mean we suddenly get shared libraries
++ # on systems that don't support them.
++ _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
++ enable_shared=no
++ ;;
+
+-## CAVEAT EMPTOR:
+-## There is no encapsulation within the following macros, do not change
+-## the running order or otherwise move them around unless you know exactly
+-## what you are doing...
+-AC_LIBTOOL_PROG_COMPILER_NO_RTTI($1)
+-AC_LIBTOOL_PROG_COMPILER_PIC($1)
+-AC_LIBTOOL_PROG_CC_C_O($1)
+-AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
+-AC_LIBTOOL_PROG_LD_SHLIBS($1)
+-AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
+-AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
++ *nto* | *qnx*)
++ # QNX uses GNU C++, but need to define -shared option too, otherwise
++ # it will coredump.
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
++ ;;
+
+-AC_LIBTOOL_CONFIG($1)
++ sysv4*MP*)
++ if test -d /usr/nec; then
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
++ fi
++ ;;
+
+-AC_LANG_RESTORE
+-CC="$lt_save_CC"
+-])# AC_LIBTOOL_LANG_GCJ_CONFIG
++ *)
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
++ ;;
++ esac
++ else
++ # PORTME Check for flag to pass linker flags through the system compiler.
++ case $host_os in
++ aix*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ if test "$host_cpu" = ia64; then
++ # AIX 5 now supports IA64 processor
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ else
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
++ fi
++ ;;
+
++ mingw* | cygwin* | pw32* | os2*)
++ # This hack is so that the source file can tell whether it is being
++ # built for inclusion in a dll (and should export symbols for example).
++ m4_if([$1], [GCJ], [],
++ [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
++ ;;
+
+-# AC_LIBTOOL_LANG_RC_CONFIG
+-# -------------------------
+-# Ensure that the configuration vars for the Windows resource compiler are
+-# suitably defined. Those variables are subsequently used by
+-# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
+-AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG], [_LT_AC_LANG_RC_CONFIG(RC)])
+-AC_DEFUN([_LT_AC_LANG_RC_CONFIG],
+-[AC_LANG_SAVE
++ hpux9* | hpux10* | hpux11*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
++ # not for PA HP-UX.
++ case $host_cpu in
++ hppa*64*|ia64*)
++ # +Z the default
++ ;;
++ *)
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
++ ;;
++ esac
++ # Is there a better lt_prog_compiler_static that works with the bundled CC?
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
++ ;;
+
+-# Source file extension for RC test sources.
+-ac_ext=rc
++ irix5* | irix6* | nonstopux*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ # PIC (with -KPIC) is the default.
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
++ ;;
+
+-# Object file extension for compiled RC test sources.
+-objext=o
+-_LT_AC_TAGVAR(objext, $1)=$objext
++ linux* | k*bsd*-gnu)
++ case $cc_basename in
++ icc* | ecc* | ifort*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
++ ;;
++ pgcc* | pgf77* | pgf90* | pgf95*)
++ # Portland Group compilers (*not* the Pentium gcc compiler,
++ # which looks to be a dead project)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ ;;
++ ccc*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ # All Alpha code is PIC.
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
++ ;;
++ xl*)
++ # IBM XL C 8.0/Fortran 10.1 on PPC
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink'
++ ;;
++ *)
++ case `$CC -V 2>&1 | sed 5q` in
++ *Sun\ C*)
++ # Sun C 5.9
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ ;;
++ *Sun\ F*)
++ # Sun Fortran 8.3 passes all unrecognized flags to the linker
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)=''
++ ;;
++ esac
++ ;;
++ esac
++ ;;
+
+-# Code to be used in simple compile tests
+-lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }\n'
++ newsos6)
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ ;;
+
+-# Code to be used in simple link tests
+-lt_simple_link_test_code="$lt_simple_compile_test_code"
++ *nto* | *qnx*)
++ # QNX uses GNU C++, but need to define -shared option too, otherwise
++ # it will coredump.
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
++ ;;
+
+-# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+-_LT_AC_SYS_COMPILER
++ osf3* | osf4* | osf5*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ # All OSF/1 code is PIC.
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
++ ;;
+
+-# save warnings/boilerplate of simple test code
+-_LT_COMPILER_BOILERPLATE
+-_LT_LINKER_BOILERPLATE
++ rdos*)
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
++ ;;
+
+-# Allow CC to be a program name with arguments.
+-lt_save_CC="$CC"
+-CC=${RC-"windres"}
+-compiler=$CC
+-_LT_AC_TAGVAR(compiler, $1)=$CC
+-_LT_CC_BASENAME([$compiler])
+-_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
++ solaris*)
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ case $cc_basename in
++ f77* | f90* | f95*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';;
++ *)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';;
++ esac
++ ;;
+
+-AC_LIBTOOL_CONFIG($1)
++ sunos4*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ ;;
+
+-AC_LANG_RESTORE
+-CC="$lt_save_CC"
+-])# AC_LIBTOOL_LANG_RC_CONFIG
++ sysv4 | sysv4.2uw2* | sysv4.3*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ ;;
++
++ sysv4*MP*)
++ if test -d /usr/nec ;then
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ fi
++ ;;
+
++ sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ ;;
+
+-# AC_LIBTOOL_CONFIG([TAGNAME])
+-# ----------------------------
+-# If TAGNAME is not passed, then create an initial libtool script
+-# with a default configuration from the untagged config vars. Otherwise
+-# add code to config.status for appending the configuration named by
+-# TAGNAME from the matching tagged config vars.
+-AC_DEFUN([AC_LIBTOOL_CONFIG],
+-[# The else clause should only fire when bootstrapping the
+-# libtool distribution, otherwise you forgot to ship ltmain.sh
+-# with your package, and you will get complaints that there are
+-# no rules to generate ltmain.sh.
+-if test -f "$ltmain"; then
+- # See if we are running on zsh, and set the options which allow our commands through
+- # without removal of \ escapes.
+- if test -n "${ZSH_VERSION+set}" ; then
+- setopt NO_GLOB_SUBST
+- fi
+- # Now quote all the things that may contain metacharacters while being
+- # careful not to overquote the AC_SUBSTed values. We take copies of the
+- # variables and quote the copies for generation of the libtool script.
+- for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \
+- SED SHELL STRIP \
+- libname_spec library_names_spec soname_spec extract_expsyms_cmds \
+- old_striplib striplib file_magic_cmd finish_cmds finish_eval \
+- deplibs_check_method reload_flag reload_cmds need_locks \
+- lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \
+- lt_cv_sys_global_symbol_to_c_name_address \
+- sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
+- old_postinstall_cmds old_postuninstall_cmds \
+- _LT_AC_TAGVAR(compiler, $1) \
+- _LT_AC_TAGVAR(CC, $1) \
+- _LT_AC_TAGVAR(LD, $1) \
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1) \
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1) \
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1) \
+- _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) \
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1) \
+- _LT_AC_TAGVAR(thread_safe_flag_spec, $1) \
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1) \
+- _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1) \
+- _LT_AC_TAGVAR(old_archive_cmds, $1) \
+- _LT_AC_TAGVAR(old_archive_from_new_cmds, $1) \
+- _LT_AC_TAGVAR(predep_objects, $1) \
+- _LT_AC_TAGVAR(postdep_objects, $1) \
+- _LT_AC_TAGVAR(predeps, $1) \
+- _LT_AC_TAGVAR(postdeps, $1) \
+- _LT_AC_TAGVAR(compiler_lib_search_path, $1) \
+- _LT_AC_TAGVAR(archive_cmds, $1) \
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1) \
+- _LT_AC_TAGVAR(postinstall_cmds, $1) \
+- _LT_AC_TAGVAR(postuninstall_cmds, $1) \
+- _LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1) \
+- _LT_AC_TAGVAR(allow_undefined_flag, $1) \
+- _LT_AC_TAGVAR(no_undefined_flag, $1) \
+- _LT_AC_TAGVAR(export_symbols_cmds, $1) \
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) \
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1) \
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1) \
+- _LT_AC_TAGVAR(hardcode_automatic, $1) \
+- _LT_AC_TAGVAR(module_cmds, $1) \
+- _LT_AC_TAGVAR(module_expsym_cmds, $1) \
+- _LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1) \
+- _LT_AC_TAGVAR(exclude_expsyms, $1) \
+- _LT_AC_TAGVAR(include_expsyms, $1); do
+-
+- case $var in
+- _LT_AC_TAGVAR(old_archive_cmds, $1) | \
+- _LT_AC_TAGVAR(old_archive_from_new_cmds, $1) | \
+- _LT_AC_TAGVAR(archive_cmds, $1) | \
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1) | \
+- _LT_AC_TAGVAR(module_cmds, $1) | \
+- _LT_AC_TAGVAR(module_expsym_cmds, $1) | \
+- _LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1) | \
+- _LT_AC_TAGVAR(export_symbols_cmds, $1) | \
+- extract_expsyms_cmds | reload_cmds | finish_cmds | \
+- postinstall_cmds | postuninstall_cmds | \
+- old_postinstall_cmds | old_postuninstall_cmds | \
+- sys_lib_search_path_spec | sys_lib_dlsearch_path_spec)
+- # Double-quote double-evaled strings.
+- eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\""
++ unicos*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
++ ;;
++
++ uts4*)
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
++
+ *)
+- eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\""
++ _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+ ;;
+ esac
+- done
+-
+- case $lt_echo in
+- *'\[$]0 --fallback-echo"')
+- lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\[$]0 --fallback-echo"[$]/[$]0 --fallback-echo"/'`
++ fi
++])
++case $host_os in
++ # For platforms which do not support PIC, -DPIC is meaningless:
++ *djgpp*)
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)=
+ ;;
+- esac
+-
+-ifelse([$1], [],
+- [cfgfile="${ofile}T"
+- trap "$rm \"$cfgfile\"; exit 1" 1 2 15
+- $rm -f "$cfgfile"
+- AC_MSG_NOTICE([creating $ofile])],
+- [cfgfile="$ofile"])
+-
+- cat <<__EOF__ >> "$cfgfile"
+-ifelse([$1], [],
+-[#! $SHELL
++ *)
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])"
++ ;;
++esac
++AC_MSG_RESULT([$_LT_TAGVAR(lt_prog_compiler_pic, $1)])
++_LT_TAGDECL([wl], [lt_prog_compiler_wl], [1],
++ [How to pass a linker flag through the compiler])
+
+-# `$echo "$cfgfile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
+-# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP)
+-# NOTE: Changes made to this file will be lost: look at ltmain.sh.
+ #
+-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001
+-# Free Software Foundation, Inc.
+-#
+-# This file is part of GNU Libtool:
+-# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
+-#
+-# 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 of the License, or
+-# (at your option) any later version.
++# Check to make sure the PIC flag actually works.
+ #
+-# 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.
++if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then
++ _LT_COMPILER_OPTION([if $compiler PIC flag $_LT_TAGVAR(lt_prog_compiler_pic, $1) works],
++ [_LT_TAGVAR(lt_cv_prog_compiler_pic_works, $1)],
++ [$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [],
++ [case $_LT_TAGVAR(lt_prog_compiler_pic, $1) in
++ "" | " "*) ;;
++ *) _LT_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_TAGVAR(lt_prog_compiler_pic, $1)" ;;
++ esac],
++ [_LT_TAGVAR(lt_prog_compiler_pic, $1)=
++ _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no])
++fi
++_LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1],
++ [Additional compiler flags for building library objects])
++
+ #
+-# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
++# Check to make sure the static flag actually works.
+ #
+-# As a special exception to the GNU General Public License, if you
+-# distribute this file as part of a program that contains a
+-# configuration script generated by Autoconf, you may include it under
+-# the same distribution terms that you use for the rest of that program.
+-
+-# A sed program that does not truncate output.
+-SED=$lt_SED
+-
+-# Sed that helps us avoid accidentally triggering echo(1) options like -n.
+-Xsed="$SED -e 1s/^X//"
+-
+-# The HP-UX ksh and POSIX shell print the target directory to stdout
+-# if CDPATH is set.
+-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+-
+-# The names of the tagged configurations supported by this script.
+-available_tags=
+-
+-# ### BEGIN LIBTOOL CONFIG],
+-[# ### BEGIN LIBTOOL TAG CONFIG: $tagname])
+-
+-# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+-
+-# Shell to use when invoking shell scripts.
+-SHELL=$lt_SHELL
+-
+-# Whether or not to build shared libraries.
+-build_libtool_libs=$enable_shared
+-
+-# Whether or not to build static libraries.
+-build_old_libs=$enable_static
+-
+-# Whether or not to add -lc for building shared libraries.
+-build_libtool_need_lc=$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)
+-
+-# Whether or not to disallow shared libs when runtime libs are static
+-allow_libtool_libs_with_static_runtimes=$_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)
+-
+-# Whether or not to optimize for fast installation.
+-fast_install=$enable_fast_install
+-
+-# The host system.
+-host_alias=$host_alias
+-host=$host
+-host_os=$host_os
++wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_TAGVAR(lt_prog_compiler_static, $1)\"
++_LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works],
++ _LT_TAGVAR(lt_cv_prog_compiler_static_works, $1),
++ $lt_tmp_static_flag,
++ [],
++ [_LT_TAGVAR(lt_prog_compiler_static, $1)=])
++_LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1],
++ [Compiler flag to prevent dynamic linking])
++])# _LT_COMPILER_PIC
+
+-# The build system.
+-build_alias=$build_alias
+-build=$build
+-build_os=$build_os
+
+-# An echo program that does not interpret backslashes.
+-echo=$lt_echo
++# _LT_LINKER_SHLIBS([TAGNAME])
++# ----------------------------
++# See if the linker supports building shared libraries.
++m4_defun([_LT_LINKER_SHLIBS],
++[AC_REQUIRE([LT_PATH_LD])dnl
++AC_REQUIRE([LT_PATH_NM])dnl
++m4_require([_LT_FILEUTILS_DEFAULTS])dnl
++m4_require([_LT_DECL_EGREP])dnl
++m4_require([_LT_DECL_SED])dnl
++m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl
++m4_require([_LT_TAG_COMPILER])dnl
++AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
++m4_if([$1], [CXX], [
++ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
++ case $host_os in
++ aix[[4-9]]*)
++ # If we're using GNU nm, then we don't want the "-C" option.
++ # -C means demangle to AIX nm, but means don't demangle with GNU nm
++ if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
++ _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
++ else
++ _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
++ fi
++ ;;
++ pw32*)
++ _LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds"
++ ;;
++ cygwin* | mingw*)
++ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;/^.*[[ ]]__nm__/s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols'
++ ;;
++ *)
++ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
++ ;;
++ esac
++ _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']
++], [
++ runpath_var=
++ _LT_TAGVAR(allow_undefined_flag, $1)=
++ _LT_TAGVAR(always_export_symbols, $1)=no
++ _LT_TAGVAR(archive_cmds, $1)=
++ _LT_TAGVAR(archive_expsym_cmds, $1)=
++ _LT_TAGVAR(compiler_needs_object, $1)=no
++ _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)=
++ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
++ _LT_TAGVAR(hardcode_automatic, $1)=no
++ _LT_TAGVAR(hardcode_direct, $1)=no
++ _LT_TAGVAR(hardcode_direct_absolute, $1)=no
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
++ _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=
++ _LT_TAGVAR(hardcode_minus_L, $1)=no
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
++ _LT_TAGVAR(inherit_rpath, $1)=no
++ _LT_TAGVAR(link_all_deplibs, $1)=unknown
++ _LT_TAGVAR(module_cmds, $1)=
++ _LT_TAGVAR(module_expsym_cmds, $1)=
++ _LT_TAGVAR(old_archive_from_new_cmds, $1)=
++ _LT_TAGVAR(old_archive_from_expsyms_cmds, $1)=
++ _LT_TAGVAR(thread_safe_flag_spec, $1)=
++ _LT_TAGVAR(whole_archive_flag_spec, $1)=
++ # include_expsyms should be a list of space-separated symbols to be *always*
++ # included in the symbol list
++ _LT_TAGVAR(include_expsyms, $1)=
++ # exclude_expsyms can be an extended regexp of symbols to exclude
++ # it will be wrapped by ` (' and `)$', so one must not match beginning or
++ # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
++ # as well as any symbol that contains `d'.
++ _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']
++ # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
++ # platforms (ab)use it in PIC code, but their linkers get confused if
++ # the symbol is explicitly referenced. Since portable code cannot
++ # rely on this symbol name, it's probably fine to never include it in
++ # preloaded symbol tables.
++ # Exclude shared library initialization/finalization symbols.
++dnl Note also adjust exclude_expsyms for C++ above.
++ extract_expsyms_cmds=
+
+-# The archiver.
+-AR=$lt_AR
+-AR_FLAGS=$lt_AR_FLAGS
++ case $host_os in
++ cygwin* | mingw* | pw32*)
++ # FIXME: the MSVC++ port hasn't been tested in a loooong time
++ # When not using gcc, we currently assume that we are using
++ # Microsoft Visual C++.
++ if test "$GCC" != yes; then
++ with_gnu_ld=no
++ fi
++ ;;
++ interix*)
++ # we just hope/assume this is gcc and not c89 (= MSVC++)
++ with_gnu_ld=yes
++ ;;
++ openbsd*)
++ with_gnu_ld=no
++ ;;
++ esac
+
+-# A C compiler.
+-LTCC=$lt_LTCC
++ _LT_TAGVAR(ld_shlibs, $1)=yes
++ if test "$with_gnu_ld" = yes; then
++ # If archive_cmds runs LD, not CC, wlarc should be empty
++ wlarc='${wl}'
+
+-# LTCC compiler flags.
+-LTCFLAGS=$lt_LTCFLAGS
++ # Set some defaults for GNU ld with shared library support. These
++ # are reset later if shared libraries are not supported. Putting them
++ # here allows them to be overridden if necessary.
++ runpath_var=LD_RUN_PATH
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
++ # ancient GNU ld didn't support --whole-archive et. al.
++ if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then
++ _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
++ else
++ _LT_TAGVAR(whole_archive_flag_spec, $1)=
++ fi
++ supports_anon_versioning=no
++ case `$LD -v 2>&1` in
++ *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11
++ *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
++ *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
++ *\ 2.11.*) ;; # other 2.11 versions
++ *) supports_anon_versioning=yes ;;
++ esac
+
+-# A language-specific compiler.
+-CC=$lt_[]_LT_AC_TAGVAR(compiler, $1)
++ # See if GNU ld supports shared libraries.
++ case $host_os in
++ aix[[3-9]]*)
++ # On AIX/PPC, the GNU linker is very broken
++ if test "$host_cpu" != ia64; then
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ cat <<_LT_EOF 1>&2
+
+-# Is the compiler the GNU C compiler?
+-with_gcc=$_LT_AC_TAGVAR(GCC, $1)
++*** Warning: the GNU linker, at least up to release 2.9.1, is reported
++*** to be unable to reliably create shared libraries on AIX.
++*** Therefore, libtool is disabling shared libraries support. If you
++*** really care for shared libraries, you may want to modify your PATH
++*** so that a non-GNU linker is found, and then restart.
+
+-# An ERE matcher.
+-EGREP=$lt_EGREP
++_LT_EOF
++ fi
++ ;;
+
+-# The linker used to build libraries.
+-LD=$lt_[]_LT_AC_TAGVAR(LD, $1)
++ amigaos*)
++ case $host_cpu in
++ powerpc)
++ # see comment about AmigaOS4 .so support
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)=''
++ ;;
++ m68k)
++ _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
++ _LT_TAGVAR(hardcode_minus_L, $1)=yes
++ ;;
++ esac
++ ;;
+
+-# Whether we need hard or soft links.
+-LN_S=$lt_LN_S
++ beos*)
++ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
++ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
++ # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
++ # support --undefined. This deserves some investigation. FIXME
++ _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
++ else
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ fi
++ ;;
+
+-# A BSD-compatible nm program.
+-NM=$lt_NM
++ cygwin* | mingw* | pw32*)
++ # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
++ # as there is no search path for DLLs.
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
++ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
++ _LT_TAGVAR(always_export_symbols, $1)=no
++ _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
++ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols'
+
+-# A symbol stripping program
+-STRIP=$lt_STRIP
++ if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
++ # If the export-symbols file already is a .def file (1st line
++ # is EXPORTS), use it as is; otherwise, prepend...
++ _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
++ cp $export_symbols $output_objdir/$soname.def;
++ else
++ echo EXPORTS > $output_objdir/$soname.def;
++ cat $export_symbols >> $output_objdir/$soname.def;
++ fi~
++ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
++ else
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ fi
++ ;;
+
+-# Used to examine libraries when file_magic_cmd begins "file"
+-MAGIC_CMD=$MAGIC_CMD
++ interix[[3-9]]*)
++ _LT_TAGVAR(hardcode_direct, $1)=no
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
++ # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
++ # Instead, shared libraries are loaded at an image base (0x10000000 by
++ # default) and relocated if they conflict, which is a slow very memory
++ # consuming and fragmenting process. To avoid this, we pick a random,
++ # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
++ # time. Moving up from 0x10000000 also allows more sbrk(2) space.
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
++ ;;
+
+-# Used on cygwin: DLL creation program.
+-DLLTOOL="$DLLTOOL"
++ gnu* | linux* | tpf* | k*bsd*-gnu)
++ tmp_diet=no
++ if test "$host_os" = linux-dietlibc; then
++ case $cc_basename in
++ diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn)
++ esac
++ fi
++ if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \
++ && test "$tmp_diet" = no
++ then
++ tmp_addflag=
++ tmp_sharedflag='-shared'
++ case $cc_basename,$host_cpu in
++ pgcc*) # Portland Group C compiler
++ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
++ tmp_addflag=' $pic_flag'
++ ;;
++ pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers
++ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
++ tmp_addflag=' $pic_flag -Mnomain' ;;
++ ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64
++ tmp_addflag=' -i_dynamic' ;;
++ efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64
++ tmp_addflag=' -i_dynamic -nofor_main' ;;
++ ifc* | ifort*) # Intel Fortran compiler
++ tmp_addflag=' -nofor_main' ;;
++ xl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below)
++ tmp_sharedflag='-qmkshrobj'
++ tmp_addflag= ;;
++ esac
++ case `$CC -V 2>&1 | sed 5q` in
++ *Sun\ C*) # Sun C 5.9
++ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
++ _LT_TAGVAR(compiler_needs_object, $1)=yes
++ tmp_sharedflag='-G' ;;
++ *Sun\ F*) # Sun Fortran 8.3
++ tmp_sharedflag='-G' ;;
++ esac
++ _LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+
+-# Used on cygwin: object dumper.
+-OBJDUMP="$OBJDUMP"
++ if test "x$supports_anon_versioning" = xyes; then
++ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
++ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
++ echo "local: *; };" >> $output_objdir/$libname.ver~
++ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
++ fi
+
+-# Used on cygwin: assembler.
+-AS="$AS"
++ case $cc_basename in
++ xlf*)
++ # IBM XL Fortran 10.1 on PPC cannot create shared libs itself
++ _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
++ _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir'
++ _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $compiler_flags -soname $soname -o $lib'
++ if test "x$supports_anon_versioning" = xyes; then
++ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
++ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
++ echo "local: *; };" >> $output_objdir/$libname.ver~
++ $LD -shared $libobjs $deplibs $compiler_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
++ fi
++ ;;
++ esac
++ else
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ fi
++ ;;
+
+-# The name of the directory that contains temporary libtool files.
+-objdir=$objdir
++ netbsd*)
++ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
++ _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
++ wlarc=
++ else
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
++ fi
++ ;;
+
+-# How to create reloadable object files.
+-reload_flag=$lt_reload_flag
+-reload_cmds=$lt_reload_cmds
++ solaris*)
++ if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ cat <<_LT_EOF 1>&2
+
+-# How to pass a linker flag through the compiler.
+-wl=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)
++*** Warning: The releases 2.8.* of the GNU linker cannot reliably
++*** create shared libraries on Solaris systems. Therefore, libtool
++*** is disabling shared libraries support. We urge you to upgrade GNU
++*** binutils to release 2.9.1 or newer. Another option is to modify
++*** your PATH or compiler configuration so that the native linker is
++*** used, and then restart.
+
+-# Object file suffix (normally "o").
+-objext="$ac_objext"
++_LT_EOF
++ elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
++ else
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ fi
++ ;;
+
+-# Old archive suffix (normally "a").
+-libext="$libext"
++ sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
++ case `$LD -v 2>&1` in
++ *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*)
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ cat <<_LT_EOF 1>&2
+
+-# Shared library suffix (normally ".so").
+-shrext_cmds='$shrext_cmds'
++*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
++*** reliably create shared libraries on SCO systems. Therefore, libtool
++*** is disabling shared libraries support. We urge you to upgrade GNU
++*** binutils to release 2.16.91.0.3 or newer. Another option is to modify
++*** your PATH or compiler configuration so that the native linker is
++*** used, and then restart.
+
+-# Executable file suffix (normally "").
+-exeext="$exeext"
++_LT_EOF
++ ;;
++ *)
++ # For security reasons, it is highly recommended that you always
++ # use absolute paths for naming shared libraries, and exclude the
++ # DT_RUNPATH tag from executables and libraries. But doing so
++ # requires that you compile everything twice, which is a pain.
++ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
++ else
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ fi
++ ;;
++ esac
++ ;;
+
+-# Additional compiler flags for building library objects.
+-pic_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)
+-pic_mode=$pic_mode
++ sunos4*)
++ _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
++ wlarc=
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ ;;
+
+-# What is the maximum length of a command?
+-max_cmd_len=$lt_cv_sys_max_cmd_len
++ *)
++ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
++ else
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ fi
++ ;;
++ esac
+
+-# Does compiler simultaneously support -c and -o options?
+-compiler_c_o=$lt_[]_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)
++ if test "$_LT_TAGVAR(ld_shlibs, $1)" = no; then
++ runpath_var=
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)=
++ _LT_TAGVAR(whole_archive_flag_spec, $1)=
++ fi
++ else
++ # PORTME fill in a description of your system's linker (not GNU ld)
++ case $host_os in
++ aix3*)
++ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
++ _LT_TAGVAR(always_export_symbols, $1)=yes
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
++ # Note: this linker hardcodes the directories in LIBPATH if there
++ # are no directories specified by -L.
++ _LT_TAGVAR(hardcode_minus_L, $1)=yes
++ if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
++ # Neither direct hardcoding nor static linking is supported with a
++ # broken collect2.
++ _LT_TAGVAR(hardcode_direct, $1)=unsupported
++ fi
++ ;;
+
+-# Must we lock files when doing compilation?
+-need_locks=$lt_need_locks
++ aix[[4-9]]*)
++ if test "$host_cpu" = ia64; then
++ # On IA64, the linker does run time linking by default, so we don't
++ # have to do anything special.
++ aix_use_runtimelinking=no
++ exp_sym_flag='-Bexport'
++ no_entry_flag=""
++ else
++ # If we're using GNU nm, then we don't want the "-C" option.
++ # -C means demangle to AIX nm, but means don't demangle with GNU nm
++ if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
++ _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
++ else
++ _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
++ fi
++ aix_use_runtimelinking=no
+
+-# Do we need the lib prefix for modules?
+-need_lib_prefix=$need_lib_prefix
++ # Test if we are trying to use run time linking or normal
++ # AIX style linking. If -brtl is somewhere in LDFLAGS, we
++ # need to do runtime linking.
++ case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
++ for ld_flag in $LDFLAGS; do
++ if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
++ aix_use_runtimelinking=yes
++ break
++ fi
++ done
++ ;;
++ esac
+
+-# Do we need a version for libraries?
+-need_version=$need_version
++ exp_sym_flag='-bexport'
++ no_entry_flag='-bnoentry'
++ fi
+
+-# Whether dlopen is supported.
+-dlopen_support=$enable_dlopen
++ # When large executables or shared objects are built, AIX ld can
++ # have problems creating the table of contents. If linking a library
++ # or program results in "error TOC overflow" add -mminimal-toc to
++ # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
++ # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+-# Whether dlopen of programs is supported.
+-dlopen_self=$enable_dlopen_self
++ _LT_TAGVAR(archive_cmds, $1)=''
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
++ _LT_TAGVAR(link_all_deplibs, $1)=yes
++ _LT_TAGVAR(file_list_spec, $1)='${wl}-f,'
+
+-# Whether dlopen of statically linked programs is supported.
+-dlopen_self_static=$enable_dlopen_self_static
++ if test "$GCC" = yes; then
++ case $host_os in aix4.[[012]]|aix4.[[012]].*)
++ # We only want to do this on AIX 4.2 and lower, the check
++ # below for broken collect2 doesn't work under 4.3+
++ collect2name=`${CC} -print-prog-name=collect2`
++ if test -f "$collect2name" &&
++ strings "$collect2name" | $GREP resolve_lib_name >/dev/null
++ then
++ # We have reworked collect2
++ :
++ else
++ # We have old collect2
++ _LT_TAGVAR(hardcode_direct, $1)=unsupported
++ # It fails to find uninstalled libraries when the uninstalled
++ # path is not listed in the libpath. Setting hardcode_minus_L
++ # to unsupported forces relinking
++ _LT_TAGVAR(hardcode_minus_L, $1)=yes
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=
++ fi
++ ;;
++ esac
++ shared_flag='-shared'
++ if test "$aix_use_runtimelinking" = yes; then
++ shared_flag="$shared_flag "'${wl}-G'
++ fi
++ else
++ # not using gcc
++ if test "$host_cpu" = ia64; then
++ # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
++ # chokes on -Wl,-G. The following line is correct:
++ shared_flag='-G'
++ else
++ if test "$aix_use_runtimelinking" = yes; then
++ shared_flag='${wl}-G'
++ else
++ shared_flag='${wl}-bM:SRE'
++ fi
++ fi
++ fi
+
+-# Compiler flag to prevent dynamic linking.
+-link_static_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_static, $1)
++ # It seems that -bexpall does not export symbols beginning with
++ # underscore (_), so it is better to generate a list of symbols to export.
++ _LT_TAGVAR(always_export_symbols, $1)=yes
++ if test "$aix_use_runtimelinking" = yes; then
++ # Warning - without using the other runtime loading flags (-brtl),
++ # -berok will link without error, but may produce a broken library.
++ _LT_TAGVAR(allow_undefined_flag, $1)='-berok'
++ # Determine the default libpath from the value encoded in an
++ # empty executable.
++ _LT_SYS_MODULE_PATH_AIX
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
++ else
++ if test "$host_cpu" = ia64; then
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
++ _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
++ _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
++ else
++ # Determine the default libpath from the value encoded in an
++ # empty executable.
++ _LT_SYS_MODULE_PATH_AIX
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
++ # Warning - without using the other run time loading flags,
++ # -berok will link without error, but may produce a broken library.
++ _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
++ _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
++ # Exported symbols can be pulled into shared objects from archives
++ _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
++ _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
++ # This is similar to how AIX traditionally builds its shared libraries.
++ _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
++ fi
++ fi
++ ;;
+
+-# Compiler flag to turn off builtin functions.
+-no_builtin_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)
++ amigaos*)
++ case $host_cpu in
++ powerpc)
++ # see comment about AmigaOS4 .so support
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)=''
++ ;;
++ m68k)
++ _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
++ _LT_TAGVAR(hardcode_minus_L, $1)=yes
++ ;;
++ esac
++ ;;
+
+-# Compiler flag to allow reflexive dlopens.
+-export_dynamic_flag_spec=$lt_[]_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)
++ bsdi[[45]]*)
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic
++ ;;
+
+-# Compiler flag to generate shared objects directly from archives.
+-whole_archive_flag_spec=$lt_[]_LT_AC_TAGVAR(whole_archive_flag_spec, $1)
++ cygwin* | mingw* | pw32*)
++ # When not using gcc, we currently assume that we are using
++ # Microsoft Visual C++.
++ # hardcode_libdir_flag_spec is actually meaningless, as there is
++ # no search path for DLLs.
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' '
++ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
++ # Tell ltmain to make .lib files, not .a files.
++ libext=lib
++ # Tell ltmain to make .dll files, not .so files.
++ shrext_cmds=".dll"
++ # FIXME: Setting linknames here is a bad hack.
++ _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `$ECHO "X$deplibs" | $Xsed -e '\''s/ -lc$//'\''` -link -dll~linknames='
++ # The linker will automatically build a .lib file if we build a DLL.
++ _LT_TAGVAR(old_archive_from_new_cmds, $1)='true'
++ # FIXME: Should let the user specify the lib program.
++ _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs'
++ _LT_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`'
++ _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
++ ;;
+
+-# Compiler flag to generate thread-safe objects.
+-thread_safe_flag_spec=$lt_[]_LT_AC_TAGVAR(thread_safe_flag_spec, $1)
++ darwin* | rhapsody*)
++ _LT_DARWIN_LINKER_FEATURES($1)
++ ;;
+
+-# Library versioning type.
+-version_type=$version_type
++ dgux*)
++ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ ;;
+
+-# Format of library name prefix.
+-libname_spec=$lt_libname_spec
++ freebsd1*)
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
+
+-# List of archive names. First name is the real one, the rest are links.
+-# The last name is the one that the linker finds with -lNAME.
+-library_names_spec=$lt_library_names_spec
++ # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
++ # support. Future versions do this automatically, but an explicit c++rt0.o
++ # does not break anything, and helps significantly (at the cost of a little
++ # extra space).
++ freebsd2.2*)
++ _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ ;;
+
+-# The coded name of the library, if different from the real name.
+-soname_spec=$lt_soname_spec
++ # Unfortunately, older versions of FreeBSD 2 do not have this feature.
++ freebsd2*)
++ _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_minus_L, $1)=yes
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ ;;
+
+-# Commands used to build and install an old-style archive.
+-RANLIB=$lt_RANLIB
+-old_archive_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_cmds, $1)
+-old_postinstall_cmds=$lt_old_postinstall_cmds
+-old_postuninstall_cmds=$lt_old_postuninstall_cmds
++ # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
++ freebsd* | dragonfly*)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ ;;
+
+-# Create an old-style archive from a shared archive.
+-old_archive_from_new_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_from_new_cmds, $1)
++ hpux9*)
++ if test "$GCC" = yes; then
++ _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
++ else
++ _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
++ fi
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
++ _LT_TAGVAR(hardcode_direct, $1)=yes
+
+-# Create a temporary old-style archive to link instead of a shared archive.
+-old_archive_from_expsyms_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1)
++ # hardcode_minus_L: Not really in the search PATH,
++ # but as the default location of the library.
++ _LT_TAGVAR(hardcode_minus_L, $1)=yes
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
++ ;;
+
+-# Commands used to build and install a shared archive.
+-archive_cmds=$lt_[]_LT_AC_TAGVAR(archive_cmds, $1)
+-archive_expsym_cmds=$lt_[]_LT_AC_TAGVAR(archive_expsym_cmds, $1)
+-postinstall_cmds=$lt_postinstall_cmds
+-postuninstall_cmds=$lt_postuninstall_cmds
++ hpux10*)
++ if test "$GCC" = yes -a "$with_gnu_ld" = no; then
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
++ else
++ _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
++ fi
++ if test "$with_gnu_ld" = no; then
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
++ _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
++ # hardcode_minus_L: Not really in the search PATH,
++ # but as the default location of the library.
++ _LT_TAGVAR(hardcode_minus_L, $1)=yes
++ fi
++ ;;
+
+-# Commands used to build a loadable module (assumed same as above if empty)
+-module_cmds=$lt_[]_LT_AC_TAGVAR(module_cmds, $1)
+-module_expsym_cmds=$lt_[]_LT_AC_TAGVAR(module_expsym_cmds, $1)
++ hpux11*)
++ if test "$GCC" = yes -a "$with_gnu_ld" = no; then
++ case $host_cpu in
++ hppa*64*)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
++ ;;
++ ia64*)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
++ ;;
++ *)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
++ ;;
++ esac
++ else
++ case $host_cpu in
++ hppa*64*)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
++ ;;
++ ia64*)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
++ ;;
++ *)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
++ ;;
++ esac
++ fi
++ if test "$with_gnu_ld" = no; then
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+-# Commands to strip libraries.
+-old_striplib=$lt_old_striplib
+-striplib=$lt_striplib
++ case $host_cpu in
++ hppa*64*|ia64*)
++ _LT_TAGVAR(hardcode_direct, $1)=no
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ ;;
++ *)
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+
+-# Dependencies to place before the objects being linked to create a
+-# shared library.
+-predep_objects=$lt_[]_LT_AC_TAGVAR(predep_objects, $1)
++ # hardcode_minus_L: Not really in the search PATH,
++ # but as the default location of the library.
++ _LT_TAGVAR(hardcode_minus_L, $1)=yes
++ ;;
++ esac
++ fi
++ ;;
+
+-# Dependencies to place after the objects being linked to create a
+-# shared library.
+-postdep_objects=$lt_[]_LT_AC_TAGVAR(postdep_objects, $1)
++ irix5* | irix6* | nonstopux*)
++ if test "$GCC" = yes; then
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
++ # Try to use the -exported_symbol ld option, if it does not
++ # work, assume that -exports_file does not work either and
++ # implicitly export all symbols.
++ save_LDFLAGS="$LDFLAGS"
++ LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null"
++ AC_LINK_IFELSE(int foo(void) {},
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib'
++ )
++ LDFLAGS="$save_LDFLAGS"
++ else
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib'
++ fi
++ _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
++ _LT_TAGVAR(inherit_rpath, $1)=yes
++ _LT_TAGVAR(link_all_deplibs, $1)=yes
++ ;;
+
+-# Dependencies to place before the objects being linked to create a
+-# shared library.
+-predeps=$lt_[]_LT_AC_TAGVAR(predeps, $1)
++ netbsd*)
++ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
++ _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out
++ else
++ _LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF
++ fi
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ ;;
+
+-# Dependencies to place after the objects being linked to create a
+-# shared library.
+-postdeps=$lt_[]_LT_AC_TAGVAR(postdeps, $1)
++ newsos6)
++ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ ;;
+
+-# The library search path used internally by the compiler when linking
+-# a shared library.
+-compiler_lib_search_path=$lt_[]_LT_AC_TAGVAR(compiler_lib_search_path, $1)
++ *nto* | *qnx*)
++ ;;
+
+-# Method to check whether dependent libraries are shared objects.
+-deplibs_check_method=$lt_deplibs_check_method
++ openbsd*)
++ if test -f /usr/libexec/ld.so; then
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
++ if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
++ else
++ case $host_os in
++ openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*)
++ _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
++ ;;
++ *)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
++ ;;
++ esac
++ fi
++ else
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ fi
++ ;;
+
+-# Command to use when deplibs_check_method == file_magic.
+-file_magic_cmd=$lt_file_magic_cmd
++ os2*)
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
++ _LT_TAGVAR(hardcode_minus_L, $1)=yes
++ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
++ _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$ECHO DATA >> $output_objdir/$libname.def~$ECHO " SINGLE NONSHARED" >> $output_objdir/$libname.def~$ECHO EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
++ _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
++ ;;
+
+-# Flag that allows shared libraries with undefined symbols to be built.
+-allow_undefined_flag=$lt_[]_LT_AC_TAGVAR(allow_undefined_flag, $1)
++ osf3*)
++ if test "$GCC" = yes; then
++ _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
++ else
++ _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
++ fi
++ _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
++ ;;
+
+-# Flag that forces no undefined symbols.
+-no_undefined_flag=$lt_[]_LT_AC_TAGVAR(no_undefined_flag, $1)
++ osf4* | osf5*) # as osf3* with the addition of -msym flag
++ if test "$GCC" = yes; then
++ _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
++ else
++ _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~
++ $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp'
+
+-# Commands used to finish a libtool library installation in a directory.
+-finish_cmds=$lt_finish_cmds
++ # Both c and cxx compiler support -rpath directly
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
++ fi
++ _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
++ ;;
+
+-# Same as above, but a single script fragment to be evaled but not shown.
+-finish_eval=$lt_finish_eval
++ solaris*)
++ _LT_TAGVAR(no_undefined_flag, $1)=' -z defs'
++ if test "$GCC" = yes; then
++ wlarc='${wl}'
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
++ $CC -shared ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
++ else
++ case `$CC -V 2>&1` in
++ *"Compilers 5.0"*)
++ wlarc=''
++ _LT_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
++ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
++ ;;
++ *)
++ wlarc='${wl}'
++ _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
++ $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
++ ;;
++ esac
++ fi
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ case $host_os in
++ solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
++ *)
++ # The compiler driver will combine and reorder linker options,
++ # but understands `-z linker_flag'. GCC discards it without `$wl',
++ # but is careful enough not to reorder.
++ # Supported since Solaris 2.6 (maybe 2.5.1?)
++ if test "$GCC" = yes; then
++ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
++ else
++ _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
++ fi
++ ;;
++ esac
++ _LT_TAGVAR(link_all_deplibs, $1)=yes
++ ;;
+
+-# Take the output of nm and produce a listing of raw symbols and C names.
+-global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
++ sunos4*)
++ if test "x$host_vendor" = xsequent; then
++ # Use $CC to link under sequent, because it throws in some extra .o
++ # files that make .init and .fini sections work.
++ _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
++ else
++ _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
++ fi
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_minus_L, $1)=yes
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ ;;
+
+-# Transform the output of nm in a proper C declaration
+-global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
++ sysv4)
++ case $host_vendor in
++ sni)
++ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
++ _LT_TAGVAR(hardcode_direct, $1)=yes # is this really true???
++ ;;
++ siemens)
++ ## LD is ld it makes a PLAMLIB
++ ## CC just makes a GrossModule.
++ _LT_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags'
++ _LT_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs'
++ _LT_TAGVAR(hardcode_direct, $1)=no
++ ;;
++ motorola)
++ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
++ _LT_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie
++ ;;
++ esac
++ runpath_var='LD_RUN_PATH'
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ ;;
+
+-# Transform the output of nm in a C name address pair
+-global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
++ sysv4.3*)
++ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport'
++ ;;
+
+-# This is the shared library runtime path variable.
+-runpath_var=$runpath_var
++ sysv4*MP*)
++ if test -d /usr/nec; then
++ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ runpath_var=LD_RUN_PATH
++ hardcode_runpath_var=yes
++ _LT_TAGVAR(ld_shlibs, $1)=yes
++ fi
++ ;;
+
+-# This is the shared library path variable.
+-shlibpath_var=$shlibpath_var
++ sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
++ _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
++ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ runpath_var='LD_RUN_PATH'
+
+-# Is shlibpath searched before the hard-coded library search path?
+-shlibpath_overrides_runpath=$shlibpath_overrides_runpath
++ if test "$GCC" = yes; then
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ else
++ _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ fi
++ ;;
+
+-# How to hardcode a shared library path into an executable.
+-hardcode_action=$_LT_AC_TAGVAR(hardcode_action, $1)
++ sysv5* | sco3.2v5* | sco5v6*)
++ # Note: We can NOT use -z defs as we might desire, because we do not
++ # link with -lc, and that would cause any symbols used from libc to
++ # always be unresolved, which means just about no library would
++ # ever link correctly. If we're not using GNU ld we use -z text
++ # though, which does catch some bad symbols but isn't as heavy-handed
++ # as -z defs.
++ _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
++ _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
++ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
++ _LT_TAGVAR(link_all_deplibs, $1)=yes
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
++ runpath_var='LD_RUN_PATH'
+
+-# Whether we should hardcode library paths into libraries.
+-hardcode_into_libs=$hardcode_into_libs
++ if test "$GCC" = yes; then
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ else
++ _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ fi
++ ;;
+
+-# Flag to hardcode \$libdir into a binary during linking.
+-# This must work even if \$libdir does not exist.
+-hardcode_libdir_flag_spec=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)
++ uts4*)
++ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ ;;
+
+-# If ld is used when linking, flag to hardcode \$libdir into
+-# a binary during linking. This must work even if \$libdir does
+-# not exist.
+-hardcode_libdir_flag_spec_ld=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)
++ *)
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++ esac
+
+-# Whether we need a single -rpath flag with a separated argument.
+-hardcode_libdir_separator=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_separator, $1)
++ if test x$host_vendor = xsni; then
++ case $host in
++ sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Blargedynsym'
++ ;;
++ esac
++ fi
++ fi
++])
++AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
++test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
+
+-# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the
+-# resulting binary.
+-hardcode_direct=$_LT_AC_TAGVAR(hardcode_direct, $1)
++_LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld
+
+-# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
+-# resulting binary.
+-hardcode_minus_L=$_LT_AC_TAGVAR(hardcode_minus_L, $1)
++_LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl
++_LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl
++_LT_DECL([], [extract_expsyms_cmds], [2],
++ [The commands to extract the exported symbol list from a shared archive])
+
+-# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
+-# the resulting binary.
+-hardcode_shlibpath_var=$_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)
++#
++# Do we need to explicitly link libc?
++#
++case "x$_LT_TAGVAR(archive_cmds_need_lc, $1)" in
++x|xyes)
++ # Assume -lc should be added
++ _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
+
+-# Set to yes if building a shared library automatically hardcodes DIR into the library
+-# and all subsequent libraries and executables linked against it.
+-hardcode_automatic=$_LT_AC_TAGVAR(hardcode_automatic, $1)
++ if test "$enable_shared" = yes && test "$GCC" = yes; then
++ case $_LT_TAGVAR(archive_cmds, $1) in
++ *'~'*)
++ # FIXME: we may have to deal with multi-command sequences.
++ ;;
++ '$CC '*)
++ # Test whether the compiler implicitly links with -lc since on some
++ # systems, -lgcc has to come before -lc. If gcc already passes -lc
++ # to ld, don't add -lc before -lgcc.
++ AC_MSG_CHECKING([whether -lc should be explicitly linked in])
++ $RM conftest*
++ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+-# Variables whose values should be saved in libtool wrapper scripts and
+-# restored at relink time.
+-variables_saved_for_relink="$variables_saved_for_relink"
++ if AC_TRY_EVAL(ac_compile) 2>conftest.err; then
++ soname=conftest
++ lib=conftest
++ libobjs=conftest.$ac_objext
++ deplibs=
++ wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1)
++ pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1)
++ compiler_flags=-v
++ linker_flags=-v
++ verstring=
++ output_objdir=.
++ libname=conftest
++ lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1)
++ _LT_TAGVAR(allow_undefined_flag, $1)=
++ if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1)
++ then
++ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
++ else
++ _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
++ fi
++ _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag
++ else
++ cat conftest.err 1>&5
++ fi
++ $RM conftest*
++ AC_MSG_RESULT([$_LT_TAGVAR(archive_cmds_need_lc, $1)])
++ ;;
++ esac
++ fi
++ ;;
++esac
+
+-# Whether libtool must link a program against all its dependency libraries.
+-link_all_deplibs=$_LT_AC_TAGVAR(link_all_deplibs, $1)
++_LT_TAGDECL([build_libtool_need_lc], [archive_cmds_need_lc], [0],
++ [Whether or not to add -lc for building shared libraries])
++_LT_TAGDECL([allow_libtool_libs_with_static_runtimes],
++ [enable_shared_with_static_runtimes], [0],
++ [Whether or not to disallow shared libs when runtime libs are static])
++_LT_TAGDECL([], [export_dynamic_flag_spec], [1],
++ [Compiler flag to allow reflexive dlopens])
++_LT_TAGDECL([], [whole_archive_flag_spec], [1],
++ [Compiler flag to generate shared objects directly from archives])
++_LT_TAGDECL([], [compiler_needs_object], [1],
++ [Whether the compiler copes with passing no objects directly])
++_LT_TAGDECL([], [old_archive_from_new_cmds], [2],
++ [Create an old-style archive from a shared archive])
++_LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2],
++ [Create a temporary old-style archive to link instead of a shared archive])
++_LT_TAGDECL([], [archive_cmds], [2], [Commands used to build a shared archive])
++_LT_TAGDECL([], [archive_expsym_cmds], [2])
++_LT_TAGDECL([], [module_cmds], [2],
++ [Commands used to build a loadable module if different from building
++ a shared archive.])
++_LT_TAGDECL([], [module_expsym_cmds], [2])
++_LT_TAGDECL([], [with_gnu_ld], [1],
++ [Whether we are building with GNU ld or not])
++_LT_TAGDECL([], [allow_undefined_flag], [1],
++ [Flag that allows shared libraries with undefined symbols to be built])
++_LT_TAGDECL([], [no_undefined_flag], [1],
++ [Flag that enforces no undefined symbols])
++_LT_TAGDECL([], [hardcode_libdir_flag_spec], [1],
++ [Flag to hardcode $libdir into a binary during linking.
++ This must work even if $libdir does not exist])
++_LT_TAGDECL([], [hardcode_libdir_flag_spec_ld], [1],
++ [[If ld is used when linking, flag to hardcode $libdir into a binary
++ during linking. This must work even if $libdir does not exist]])
++_LT_TAGDECL([], [hardcode_libdir_separator], [1],
++ [Whether we need a single "-rpath" flag with a separated argument])
++_LT_TAGDECL([], [hardcode_direct], [0],
++ [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes
++ DIR into the resulting binary])
++_LT_TAGDECL([], [hardcode_direct_absolute], [0],
++ [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes
++ DIR into the resulting binary and the resulting library dependency is
++ "absolute", i.e impossible to change by setting ${shlibpath_var} if the
++ library is relocated])
++_LT_TAGDECL([], [hardcode_minus_L], [0],
++ [Set to "yes" if using the -LDIR flag during linking hardcodes DIR
++ into the resulting binary])
++_LT_TAGDECL([], [hardcode_shlibpath_var], [0],
++ [Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR
++ into the resulting binary])
++_LT_TAGDECL([], [hardcode_automatic], [0],
++ [Set to "yes" if building a shared library automatically hardcodes DIR
++ into the library and all subsequent libraries and executables linked
++ against it])
++_LT_TAGDECL([], [inherit_rpath], [0],
++ [Set to yes if linker adds runtime paths of dependent libraries
++ to runtime path list])
++_LT_TAGDECL([], [link_all_deplibs], [0],
++ [Whether libtool must link a program against all its dependency libraries])
++_LT_TAGDECL([], [fix_srcfile_path], [1],
++ [Fix the shell variable $srcfile for the compiler])
++_LT_TAGDECL([], [always_export_symbols], [0],
++ [Set to "yes" if exported symbols are required])
++_LT_TAGDECL([], [export_symbols_cmds], [2],
++ [The commands to list exported symbols])
++_LT_TAGDECL([], [exclude_expsyms], [1],
++ [Symbols that should not be listed in the preloaded symbols])
++_LT_TAGDECL([], [include_expsyms], [1],
++ [Symbols that must always be exported])
++_LT_TAGDECL([], [prelink_cmds], [2],
++ [Commands necessary for linking programs (against libraries) with templates])
++_LT_TAGDECL([], [file_list_spec], [1],
++ [Specify filename containing input files])
++dnl FIXME: Not yet implemented
++dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1],
++dnl [Compiler flag to generate thread safe objects])
++])# _LT_LINKER_SHLIBS
+
+-# Compile-time system search path for libraries
+-sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
+
+-# Run-time system search path for libraries
+-sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
++# _LT_LANG_C_CONFIG([TAG])
++# ------------------------
++# Ensure that the configuration variables for a C compiler are suitably
++# defined. These variables are subsequently used by _LT_CONFIG to write
++# the compiler configuration to `libtool'.
++m4_defun([_LT_LANG_C_CONFIG],
++[m4_require([_LT_DECL_EGREP])dnl
++lt_save_CC="$CC"
++AC_LANG_PUSH(C)
+
+-# Fix the shell variable \$srcfile for the compiler.
+-fix_srcfile_path="$_LT_AC_TAGVAR(fix_srcfile_path, $1)"
++# Source file extension for C test sources.
++ac_ext=c
+
+-# Set to yes if exported symbols are required.
+-always_export_symbols=$_LT_AC_TAGVAR(always_export_symbols, $1)
++# Object file extension for compiled C test sources.
++objext=o
++_LT_TAGVAR(objext, $1)=$objext
+
+-# The commands to list exported symbols.
+-export_symbols_cmds=$lt_[]_LT_AC_TAGVAR(export_symbols_cmds, $1)
++# Code to be used in simple compile tests
++lt_simple_compile_test_code="int some_variable = 0;"
+
+-# The commands to extract the exported symbol list from a shared archive.
+-extract_expsyms_cmds=$lt_extract_expsyms_cmds
++# Code to be used in simple link tests
++lt_simple_link_test_code='int main(){return(0);}'
+
+-# Symbols that should not be listed in the preloaded symbols.
+-exclude_expsyms=$lt_[]_LT_AC_TAGVAR(exclude_expsyms, $1)
++_LT_TAG_COMPILER
++# Save the default compiler, since it gets overwritten when the other
++# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP.
++compiler_DEFAULT=$CC
+
+-# Symbols that must always be exported.
+-include_expsyms=$lt_[]_LT_AC_TAGVAR(include_expsyms, $1)
++# save warnings/boilerplate of simple test code
++_LT_COMPILER_BOILERPLATE
++_LT_LINKER_BOILERPLATE
+
+-ifelse([$1],[],
+-[# ### END LIBTOOL CONFIG],
+-[# ### END LIBTOOL TAG CONFIG: $tagname])
++## CAVEAT EMPTOR:
++## There is no encapsulation within the following macros, do not change
++## the running order or otherwise move them around unless you know exactly
++## what you are doing...
++if test -n "$compiler"; then
++ _LT_COMPILER_NO_RTTI($1)
++ _LT_COMPILER_PIC($1)
++ _LT_COMPILER_C_O($1)
++ _LT_COMPILER_FILE_LOCKS($1)
++ _LT_LINKER_SHLIBS($1)
++ _LT_SYS_DYNAMIC_LINKER($1)
++ _LT_LINKER_HARDCODE_LIBPATH($1)
++ LT_SYS_DLOPEN_SELF
++ _LT_CMD_STRIPLIB
++
++ # Report which library types will actually be built
++ AC_MSG_CHECKING([if libtool supports shared libraries])
++ AC_MSG_RESULT([$can_build_shared])
+
+-__EOF__
++ AC_MSG_CHECKING([whether to build shared libraries])
++ test "$can_build_shared" = "no" && enable_shared=no
+
+-ifelse([$1],[], [
++ # On AIX, shared libraries and static libraries use the same namespace, and
++ # are all built from PIC.
+ case $host_os in
+ aix3*)
+- cat <<\EOF >> "$cfgfile"
++ test "$enable_shared" = yes && enable_static=no
++ if test -n "$RANLIB"; then
++ archive_cmds="$archive_cmds~\$RANLIB \$lib"
++ postinstall_cmds='$RANLIB $lib'
++ fi
++ ;;
+
+-# AIX sometimes has problems with the GCC collect2 program. For some
+-# reason, if we set the COLLECT_NAMES environment variable, the problems
+-# vanish in a puff of smoke.
+-if test "X${COLLECT_NAMES+set}" != Xset; then
+- COLLECT_NAMES=
+- export COLLECT_NAMES
+-fi
+-EOF
++ aix[[4-9]]*)
++ if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
++ test "$enable_shared" = yes && enable_static=no
++ fi
+ ;;
+ esac
++ AC_MSG_RESULT([$enable_shared])
+
+- # We use sed instead of cat because bash on DJGPP gets confused if
+- # if finds mixed CR/LF and LF-only lines. Since sed operates in
+- # text mode, it properly converts lines to CR/LF. This bash problem
+- # is reportedly fixed, but why not run on old versions too?
+- sed '$q' "$ltmain" >> "$cfgfile" || (rm -f "$cfgfile"; exit 1)
++ AC_MSG_CHECKING([whether to build static libraries])
++ # Make sure either enable_shared or enable_static is yes.
++ test "$enable_shared" = yes || enable_static=yes
++ AC_MSG_RESULT([$enable_static])
+
+- mv -f "$cfgfile" "$ofile" || \
+- (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
+- chmod +x "$ofile"
+-])
+-else
+- # If there is no Makefile yet, we rely on a make rule to execute
+- # `config.status --recheck' to rerun these tests and create the
+- # libtool script then.
+- ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'`
+- if test -f "$ltmain_in"; then
+- test -f Makefile && make "$ltmain"
+- fi
++ _LT_CONFIG($1)
+ fi
+-])# AC_LIBTOOL_CONFIG
+-
+-
+-# AC_LIBTOOL_PROG_COMPILER_NO_RTTI([TAGNAME])
+-# -------------------------------------------
+-AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI],
+-[AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl
+-
+-_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
++AC_LANG_POP
++CC="$lt_save_CC"
++])# _LT_LANG_C_CONFIG
+
+-if test "$GCC" = yes; then
+- _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
+
+- AC_LIBTOOL_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions],
+- lt_cv_prog_compiler_rtti_exceptions,
+- [-fno-rtti -fno-exceptions], [],
+- [_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"])
++# _LT_PROG_CXX
++# ------------
++# Since AC_PROG_CXX is broken, in that it returns g++ if there is no c++
++# compiler, we have our own version here.
++m4_defun([_LT_PROG_CXX],
++[
++pushdef([AC_MSG_ERROR], [_lt_caught_CXX_error=yes])
++AC_PROG_CXX
++if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
++ ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
++ (test "X$CXX" != "Xg++"))) ; then
++ AC_PROG_CXXCPP
++else
++ _lt_caught_CXX_error=yes
+ fi
+-])# AC_LIBTOOL_PROG_COMPILER_NO_RTTI
++popdef([AC_MSG_ERROR])
++])# _LT_PROG_CXX
+
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([_LT_PROG_CXX], [])
+
+-# AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE
+-# ---------------------------------
+-AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE],
+-[AC_REQUIRE([AC_CANONICAL_HOST])
+-AC_REQUIRE([AC_PROG_NM])
+-AC_REQUIRE([AC_OBJEXT])
+-# Check for command to grab the raw symbol name followed by C symbol from nm.
+-AC_MSG_CHECKING([command to parse $NM output from $compiler object])
+-AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe],
+-[
+-# These are sane defaults that work on at least a few old systems.
+-# [They come from Ultrix. What could be older than Ultrix?!! ;)]
+-
+-# Character class describing NM global symbol codes.
+-symcode='[[BCDEGRST]]'
+
+-# Regexp to match symbols that can be accessed directly from C.
+-sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)'
++# _LT_LANG_CXX_CONFIG([TAG])
++# --------------------------
++# Ensure that the configuration variables for a C++ compiler are suitably
++# defined. These variables are subsequently used by _LT_CONFIG to write
++# the compiler configuration to `libtool'.
++m4_defun([_LT_LANG_CXX_CONFIG],
++[AC_REQUIRE([_LT_PROG_CXX])dnl
++m4_require([_LT_FILEUTILS_DEFAULTS])dnl
++m4_require([_LT_DECL_EGREP])dnl
++
++AC_LANG_PUSH(C++)
++_LT_TAGVAR(archive_cmds_need_lc, $1)=no
++_LT_TAGVAR(allow_undefined_flag, $1)=
++_LT_TAGVAR(always_export_symbols, $1)=no
++_LT_TAGVAR(archive_expsym_cmds, $1)=
++_LT_TAGVAR(compiler_needs_object, $1)=no
++_LT_TAGVAR(export_dynamic_flag_spec, $1)=
++_LT_TAGVAR(hardcode_direct, $1)=no
++_LT_TAGVAR(hardcode_direct_absolute, $1)=no
++_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
++_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
++_LT_TAGVAR(hardcode_libdir_separator, $1)=
++_LT_TAGVAR(hardcode_minus_L, $1)=no
++_LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
++_LT_TAGVAR(hardcode_automatic, $1)=no
++_LT_TAGVAR(inherit_rpath, $1)=no
++_LT_TAGVAR(module_cmds, $1)=
++_LT_TAGVAR(module_expsym_cmds, $1)=
++_LT_TAGVAR(link_all_deplibs, $1)=unknown
++_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
++_LT_TAGVAR(no_undefined_flag, $1)=
++_LT_TAGVAR(whole_archive_flag_spec, $1)=
++_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+
+-# Transform an extracted symbol line into a proper C declaration
+-lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern int \1;/p'"
++# Source file extension for C++ test sources.
++ac_ext=cpp
+
+-# Transform an extracted symbol line into symbol name and symbol address
+-lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'"
++# Object file extension for compiled C++ test sources.
++objext=o
++_LT_TAGVAR(objext, $1)=$objext
+
+-# Define system-specific variables.
+-case $host_os in
+-aix*)
+- symcode='[[BCDT]]'
+- ;;
+-cygwin* | mingw* | pw32*)
+- symcode='[[ABCDGISTW]]'
+- ;;
+-hpux*) # Its linker distinguishes data from code symbols
+- if test "$host_cpu" = ia64; then
+- symcode='[[ABCDEGRST]]'
++# No sense in running all these tests if we already determined that
++# the CXX compiler isn't working. Some variables (like enable_shared)
++# are currently assumed to apply to all compilers on this platform,
++# and will be corrupted by setting them based on a non-working compiler.
++if test "$_lt_caught_CXX_error" != yes; then
++ # Code to be used in simple compile tests
++ lt_simple_compile_test_code="int some_variable = 0;"
++
++ # Code to be used in simple link tests
++ lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }'
++
++ # ltmain only uses $CC for tagged configurations so make sure $CC is set.
++ _LT_TAG_COMPILER
++
++ # save warnings/boilerplate of simple test code
++ _LT_COMPILER_BOILERPLATE
++ _LT_LINKER_BOILERPLATE
++
++ # Allow CC to be a program name with arguments.
++ lt_save_CC=$CC
++ lt_save_LD=$LD
++ lt_save_GCC=$GCC
++ GCC=$GXX
++ lt_save_with_gnu_ld=$with_gnu_ld
++ lt_save_path_LD=$lt_cv_path_LD
++ if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then
++ lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx
++ else
++ $as_unset lt_cv_prog_gnu_ld
+ fi
+- lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
+- lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'"
+- ;;
+-linux*)
+- if test "$host_cpu" = ia64; then
+- symcode='[[ABCDGIRSTW]]'
+- lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
+- lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'"
++ if test -n "${lt_cv_path_LDCXX+set}"; then
++ lt_cv_path_LD=$lt_cv_path_LDCXX
++ else
++ $as_unset lt_cv_path_LD
+ fi
+- ;;
+-irix* | nonstopux*)
+- symcode='[[BCDEGRST]]'
+- ;;
+-osf*)
+- symcode='[[BCDEGQRST]]'
+- ;;
+-solaris*)
+- symcode='[[BDRT]]'
+- ;;
+-sco3.2v5*)
+- symcode='[[DT]]'
+- ;;
+-sysv4.2uw2*)
+- symcode='[[DT]]'
+- ;;
+-sysv5* | sco5v6* | unixware* | OpenUNIX*)
+- symcode='[[ABDT]]'
+- ;;
+-sysv4)
+- symcode='[[DFNSTU]]'
+- ;;
+-esac
+-
+-# Handle CRLF in mingw tool chain
+-opt_cr=
+-case $build_os in
+-mingw*)
+- opt_cr=`echo 'x\{0,1\}' | tr x '\015'` # option cr in regexp
+- ;;
+-esac
+-
+-# If we're using GNU nm, then use its standard symbol codes.
+-case `$NM -V 2>&1` in
+-*GNU* | *'with BFD'*)
+- symcode='[[ABCDGIRSTW]]' ;;
+-esac
+-
+-# Try without a prefix undercore, then with it.
+-for ac_symprfx in "" "_"; do
+-
+- # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
+- symxfrm="\\1 $ac_symprfx\\2 \\2"
+-
+- # Write the raw and C identifiers.
+- lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
+-
+- # Check to see that the pipe works correctly.
+- pipe_works=no
+-
+- rm -f conftest*
+- cat > conftest.$ac_ext <<EOF
+-#ifdef __cplusplus
+-extern "C" {
+-#endif
+-char nm_test_var;
+-void nm_test_func(){}
+-#ifdef __cplusplus
+-}
+-#endif
+-int main(){nm_test_var='a';nm_test_func();return(0);}
+-EOF
+-
+- if AC_TRY_EVAL(ac_compile); then
+- # Now try to grab the symbols.
+- nlist=conftest.nm
+- if AC_TRY_EVAL(NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) && test -s "$nlist"; then
+- # Try sorting and uniquifying the output.
+- if sort "$nlist" | uniq > "$nlist"T; then
+- mv -f "$nlist"T "$nlist"
+- else
+- rm -f "$nlist"T
+- fi
+-
+- # Make sure that we snagged all the symbols we need.
+- if grep ' nm_test_var$' "$nlist" >/dev/null; then
+- if grep ' nm_test_func$' "$nlist" >/dev/null; then
+- cat <<EOF > conftest.$ac_ext
+-#ifdef __cplusplus
+-extern "C" {
+-#endif
+-
+-EOF
+- # Now generate the symbol file.
+- eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | grep -v main >> conftest.$ac_ext'
+-
+- cat <<EOF >> conftest.$ac_ext
+-#if defined (__STDC__) && __STDC__
+-# define lt_ptr_t void *
+-#else
+-# define lt_ptr_t char *
+-# define const
+-#endif
+-
+-/* The mapping between symbol names and symbols. */
+-const struct {
+- const char *name;
+- lt_ptr_t address;
+-}
+-lt_preloaded_symbols[[]] =
+-{
+-EOF
+- $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (lt_ptr_t) \&\2},/" < "$nlist" | grep -v main >> conftest.$ac_ext
+- cat <<\EOF >> conftest.$ac_ext
+- {0, (lt_ptr_t) 0}
+-};
++ test -z "${LDCXX+set}" || LD=$LDCXX
++ CC=${CXX-"c++"}
++ compiler=$CC
++ _LT_TAGVAR(compiler, $1)=$CC
++ _LT_CC_BASENAME([$compiler])
+
+-#ifdef __cplusplus
+-}
+-#endif
+-EOF
+- # Now try linking the two files.
+- mv conftest.$ac_objext conftstm.$ac_objext
+- lt_save_LIBS="$LIBS"
+- lt_save_CFLAGS="$CFLAGS"
+- LIBS="conftstm.$ac_objext"
+- CFLAGS="$CFLAGS$_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)"
+- if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then
+- pipe_works=yes
+- fi
+- LIBS="$lt_save_LIBS"
+- CFLAGS="$lt_save_CFLAGS"
+- else
+- echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD
+- fi
+- else
+- echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD
+- fi
++ if test -n "$compiler"; then
++ # We don't want -fno-exception when compiling C++ code, so set the
++ # no_builtin_flag separately
++ if test "$GXX" = yes; then
++ _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
+ else
+- echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD
++ _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
+ fi
+- else
+- echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD
+- cat conftest.$ac_ext >&5
+- fi
+- rm -f conftest* conftst*
+-
+- # Do not use the global_symbol_pipe unless it works.
+- if test "$pipe_works" = yes; then
+- break
+- else
+- lt_cv_sys_global_symbol_pipe=
+- fi
+-done
+-])
+-if test -z "$lt_cv_sys_global_symbol_pipe"; then
+- lt_cv_sys_global_symbol_to_cdecl=
+-fi
+-if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
+- AC_MSG_RESULT(failed)
+-else
+- AC_MSG_RESULT(ok)
+-fi
+-]) # AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE
+
++ if test "$GXX" = yes; then
++ # Set up default GNU C++ configuration
+
+-# AC_LIBTOOL_PROG_COMPILER_PIC([TAGNAME])
+-# ---------------------------------------
+-AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC],
+-[_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)=
+-_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
+-_LT_AC_TAGVAR(lt_prog_compiler_static, $1)=
++ LT_PATH_LD
+
+-AC_MSG_CHECKING([for $compiler option to produce PIC])
+- ifelse([$1],[CXX],[
+- # C++ specific cases for pic, static, wl, etc.
+- if test "$GXX" = yes; then
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
++ # Check if GNU C++ uses GNU ld as the underlying linker, since the
++ # archiving commands below assume that GNU ld is being used.
++ if test "$with_gnu_ld" = yes; then
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
++
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
++
++ # If archive_cmds runs LD, not CC, wlarc should be empty
++ # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
++ # investigate it a little bit more. (MM)
++ wlarc='${wl}'
++
++ # ancient GNU ld didn't support --whole-archive et. al.
++ if eval "`$CC -print-prog-name=ld` --help 2>&1" |
++ $GREP 'no-whole-archive' > /dev/null; then
++ _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
++ else
++ _LT_TAGVAR(whole_archive_flag_spec, $1)=
++ fi
++ else
++ with_gnu_ld=no
++ wlarc=
+
+- case $host_os in
+- aix*)
+- # All AIX code is PIC.
+- if test "$host_cpu" = ia64; then
+- # AIX 5 now supports IA64 processor
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- fi
+- ;;
+- amigaos*)
+- # FIXME: we need at least 68020 code to build shared libraries, but
+- # adding the `-m68020' flag to GCC prevents building anything better,
+- # like `-m68040'.
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
+- ;;
+- beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+- # PIC is the default for these OSes.
+- ;;
+- mingw* | cygwin* | os2* | pw32*)
+- # This hack is so that the source file can tell whether it is being
+- # built for inclusion in a dll (and should export symbols for example).
+- # Although the cygwin gcc ignores -fPIC, still need this for old-style
+- # (--disable-auto-import) libraries
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'
+- ;;
+- darwin* | rhapsody*)
+- # PIC is the default on this platform
+- # Common symbols not allowed in MH_DYLIB files
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
+- ;;
+- *djgpp*)
+- # DJGPP does not support shared libraries at all
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
+- ;;
+- interix3*)
+- # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+- # Instead, we relocate shared libraries at runtime.
+- ;;
+- sysv4*MP*)
+- if test -d /usr/nec; then
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
++ # A generic and very simple default shared library creation
++ # command for GNU C++ for the case where it uses the native
++ # linker, instead of GNU ld. If possible, this setting should
++ # overridden to take advantage of the native linker features on
++ # the platform it is being used on.
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+ fi
+- ;;
+- hpux*)
+- # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+- # not for PA HP-UX.
+- case $host_cpu in
+- hppa*64*|ia64*)
+- ;;
+- *)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+- ;;
+- esac
+- ;;
+- *)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+- ;;
+- esac
+- else
++
++ # Commands to make compiler produce verbose output that lists
++ # what "hidden" libraries, object files and flags are used when
++ # linking a shared library.
++ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
++
++ else
++ GXX=no
++ with_gnu_ld=no
++ wlarc=
++ fi
++
++ # PORTME: fill in a description of your system's C++ link characteristics
++ AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
++ _LT_TAGVAR(ld_shlibs, $1)=yes
+ case $host_os in
+- aix4* | aix5*)
+- # All AIX code is PIC.
+- if test "$host_cpu" = ia64; then
+- # AIX 5 now supports IA64 processor
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ aix3*)
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++ aix[[4-9]]*)
++ if test "$host_cpu" = ia64; then
++ # On IA64, the linker does run time linking by default, so we don't
++ # have to do anything special.
++ aix_use_runtimelinking=no
++ exp_sym_flag='-Bexport'
++ no_entry_flag=""
++ else
++ aix_use_runtimelinking=no
++
++ # Test if we are trying to use run time linking or normal
++ # AIX style linking. If -brtl is somewhere in LDFLAGS, we
++ # need to do runtime linking.
++ case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
++ for ld_flag in $LDFLAGS; do
++ case $ld_flag in
++ *-brtl*)
++ aix_use_runtimelinking=yes
++ break
++ ;;
++ esac
++ done
++ ;;
++ esac
++
++ exp_sym_flag='-bexport'
++ no_entry_flag='-bnoentry'
++ fi
++
++ # When large executables or shared objects are built, AIX ld can
++ # have problems creating the table of contents. If linking a library
++ # or program results in "error TOC overflow" add -mminimal-toc to
++ # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
++ # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
++
++ _LT_TAGVAR(archive_cmds, $1)=''
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
++ _LT_TAGVAR(link_all_deplibs, $1)=yes
++ _LT_TAGVAR(file_list_spec, $1)='${wl}-f,'
++
++ if test "$GXX" = yes; then
++ case $host_os in aix4.[[012]]|aix4.[[012]].*)
++ # We only want to do this on AIX 4.2 and lower, the check
++ # below for broken collect2 doesn't work under 4.3+
++ collect2name=`${CC} -print-prog-name=collect2`
++ if test -f "$collect2name" &&
++ strings "$collect2name" | $GREP resolve_lib_name >/dev/null
++ then
++ # We have reworked collect2
++ :
++ else
++ # We have old collect2
++ _LT_TAGVAR(hardcode_direct, $1)=unsupported
++ # It fails to find uninstalled libraries when the uninstalled
++ # path is not listed in the libpath. Setting hardcode_minus_L
++ # to unsupported forces relinking
++ _LT_TAGVAR(hardcode_minus_L, $1)=yes
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=
++ fi
++ esac
++ shared_flag='-shared'
++ if test "$aix_use_runtimelinking" = yes; then
++ shared_flag="$shared_flag "'${wl}-G'
++ fi
++ else
++ # not using gcc
++ if test "$host_cpu" = ia64; then
++ # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
++ # chokes on -Wl,-G. The following line is correct:
++ shared_flag='-G'
++ else
++ if test "$aix_use_runtimelinking" = yes; then
++ shared_flag='${wl}-G'
++ else
++ shared_flag='${wl}-bM:SRE'
++ fi
++ fi
++ fi
++
++ # It seems that -bexpall does not export symbols beginning with
++ # underscore (_), so it is better to generate a list of symbols to
++ # export.
++ _LT_TAGVAR(always_export_symbols, $1)=yes
++ if test "$aix_use_runtimelinking" = yes; then
++ # Warning - without using the other runtime loading flags (-brtl),
++ # -berok will link without error, but may produce a broken library.
++ _LT_TAGVAR(allow_undefined_flag, $1)='-berok'
++ # Determine the default libpath from the value encoded in an empty
++ # executable.
++ _LT_SYS_MODULE_PATH_AIX
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
++
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
++ else
++ if test "$host_cpu" = ia64; then
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
++ _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
++ _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
++ else
++ # Determine the default libpath from the value encoded in an
++ # empty executable.
++ _LT_SYS_MODULE_PATH_AIX
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
++ # Warning - without using the other run time loading flags,
++ # -berok will link without error, but may produce a broken library.
++ _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
++ _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
++ # Exported symbols can be pulled into shared objects from archives
++ _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
++ _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
++ # This is similar to how AIX traditionally builds its shared
++ # libraries.
++ _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
++ fi
++ fi
++ ;;
++
++ beos*)
++ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
++ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
++ # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
++ # support --undefined. This deserves some investigation. FIXME
++ _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ else
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
++ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
++
+ chorus*)
+- case $cc_basename in
+- cxch68*)
+- # Green Hills C++ Compiler
+- # _LT_AC_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a"
++ case $cc_basename in
++ *)
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+- esac
++ esac
++ ;;
++
++ cygwin* | mingw* | pw32*)
++ # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
++ # as there is no search path for DLLs.
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
++ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
++ _LT_TAGVAR(always_export_symbols, $1)=no
++ _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
++
++ if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
++ # If the export-symbols file already is a .def file (1st line
++ # is EXPORTS), use it as is; otherwise, prepend...
++ _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
++ cp $export_symbols $output_objdir/$soname.def;
++ else
++ echo EXPORTS > $output_objdir/$soname.def;
++ cat $export_symbols >> $output_objdir/$soname.def;
++ fi~
++ $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
++ else
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ fi
++ ;;
++ darwin* | rhapsody*)
++ _LT_DARWIN_LINKER_FEATURES($1)
+ ;;
+- darwin*)
+- # PIC is the default on this platform
+- # Common symbols not allowed in MH_DYLIB files
+- case $cc_basename in
+- xlc*)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-qnocommon'
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- ;;
+- esac
+- ;;
++
+ dgux*)
+- case $cc_basename in
+- ec++*)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ case $cc_basename in
++ ec++*)
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+- ghcx*)
++ ghcx*)
+ # Green Hills C++ Compiler
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+- *)
++ *)
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+- esac
+- ;;
+- freebsd* | kfreebsd*-gnu | dragonfly*)
+- # FreeBSD uses GNU C++
+- ;;
+- hpux9* | hpux10* | hpux11*)
+- case $cc_basename in
+- CC*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+- if test "$host_cpu" != ia64; then
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
+- fi
++ esac
++ ;;
++
++ freebsd[[12]]*)
++ # C++ shared libraries reported to be fairly broken before
++ # switch to ELF
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++
++ freebsd-elf*)
++ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
++ ;;
++
++ freebsd* | dragonfly*)
++ # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
++ # conventions
++ _LT_TAGVAR(ld_shlibs, $1)=yes
++ ;;
++
++ gnu*)
++ ;;
++
++ hpux9*)
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
++ # but as the default
++ # location of the library.
++
++ case $cc_basename in
++ CC*)
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++ aCC*)
++ _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
++ # Commands to make compiler produce verbose output that lists
++ # what "hidden" libraries, object files and flags are used when
++ # linking a shared library.
++ #
++ # There doesn't appear to be a way to prevent this compiler from
++ # explicitly linking system object files so we need to strip them
++ # from the output so that they don't get included in the library
++ # dependencies.
++ output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
++ ;;
++ *)
++ if test "$GXX" = yes; then
++ _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
++ else
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ fi
++ ;;
++ esac
++ ;;
++
++ hpux10*|hpux11*)
++ if test $with_gnu_ld = no; then
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
++
++ case $host_cpu in
++ hppa*64*|ia64*)
++ ;;
++ *)
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
++ ;;
++ esac
++ fi
++ case $host_cpu in
++ hppa*64*|ia64*)
++ _LT_TAGVAR(hardcode_direct, $1)=no
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ ;;
++ *)
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
++ _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
++ # but as the default
++ # location of the library.
++ ;;
++ esac
++
++ case $cc_basename in
++ CC*)
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+- aCC*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
++ aCC*)
+ case $host_cpu in
+- hppa*64*|ia64*)
+- # +Z the default
+- ;;
+- *)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
+- ;;
++ hppa*64*)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
++ ;;
++ ia64*)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
++ ;;
++ *)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
++ ;;
+ esac
++ # Commands to make compiler produce verbose output that lists
++ # what "hidden" libraries, object files and flags are used when
++ # linking a shared library.
++ #
++ # There doesn't appear to be a way to prevent this compiler from
++ # explicitly linking system object files so we need to strip them
++ # from the output so that they don't get included in the library
++ # dependencies.
++ output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
+ ;;
+- *)
++ *)
++ if test "$GXX" = yes; then
++ if test $with_gnu_ld = no; then
++ case $host_cpu in
++ hppa*64*)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
++ ;;
++ ia64*)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
++ ;;
++ *)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
++ ;;
++ esac
++ fi
++ else
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ fi
+ ;;
+- esac
+- ;;
+- interix*)
+- # This is c89, which is MS Visual C++ (no shared libs)
+- # Anyone wants to do a port?
+- ;;
+- irix5* | irix6* | nonstopux*)
+- case $cc_basename in
+- CC*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+- # CC pic flag -KPIC is the default.
++ esac
++ ;;
++
++ interix[[3-9]]*)
++ _LT_TAGVAR(hardcode_direct, $1)=no
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
++ # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
++ # Instead, shared libraries are loaded at an image base (0x10000000 by
++ # default) and relocated if they conflict, which is a slow very memory
++ # consuming and fragmenting process. To avoid this, we pick a random,
++ # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
++ # time. Moving up from 0x10000000 also allows more sbrk(2) space.
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
++ ;;
++ irix5* | irix6*)
++ case $cc_basename in
++ CC*)
++ # SGI C++
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
++
++ # Archives containing C++ object files must be created using
++ # "CC -ar", where "CC" is the IRIX C++ compiler. This is
++ # necessary to make sure instantiated templates are included
++ # in the archive.
++ _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs'
+ ;;
+- *)
++ *)
++ if test "$GXX" = yes; then
++ if test "$with_gnu_ld" = no; then
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
++ else
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` -o $lib'
++ fi
++ fi
++ _LT_TAGVAR(link_all_deplibs, $1)=yes
+ ;;
+- esac
+- ;;
+- linux*)
+- case $cc_basename in
+- KCC*)
+- # KAI C++ Compiler
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
++ esac
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
++ _LT_TAGVAR(inherit_rpath, $1)=yes
++ ;;
++
++ linux* | k*bsd*-gnu)
++ case $cc_basename in
++ KCC*)
++ # Kuck and Associates, Inc. (KAI) C++ Compiler
++
++ # KCC will only create a shared library if the output file
++ # ends with ".so" (or ".sl" for HP-UX), so rename the library
++ # to its proper name (with version) after linking.
++ _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib'
++ # Commands to make compiler produce verbose output that lists
++ # what "hidden" libraries, object files and flags are used when
++ # linking a shared library.
++ #
++ # There doesn't appear to be a way to prevent this compiler from
++ # explicitly linking system object files so we need to strip them
++ # from the output so that they don't get included in the library
++ # dependencies.
++ output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
++
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
++
++ # Archives containing C++ object files must be created using
++ # "CC -Bstatic", where "CC" is the KAI C++ compiler.
++ _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs'
+ ;;
+- icpc* | ecpc*)
++ icpc* | ecpc* )
+ # Intel C++
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
+- ;;
+- pgCC*)
+- # Portland Group C++ compiler.
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- ;;
+- cxx*)
+- # Compaq C++
+- # Make sure the PIC flag is empty. It appears that all Alpha
+- # Linux and Compaq Tru64 Unix objects are PIC.
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
++ with_gnu_ld=yes
++ # version 8.0 and above of icpc choke on multiply defined symbols
++ # if we add $predep_objects and $postdep_objects, however 7.1 and
++ # earlier do not add the objects themselves.
++ case `$CC -V 2>&1` in
++ *"Version 7."*)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
++ ;;
++ *) # Version 8.0 or newer
++ tmp_idyn=
++ case $host_cpu in
++ ia64*) tmp_idyn=' -i_dynamic';;
++ esac
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
++ ;;
++ esac
++ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
++ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+ ;;
+- *)
+- case `$CC -V 2>&1 | sed 5q` in
+- *Sun\ C*)
+- # Sun C++ 5.9
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
++ pgCC* | pgcpp*)
++ # Portland Group C++ compiler
++ case `$CC -V` in
++ *pgCC\ [[1-5]]* | *pgcpp\ [[1-5]]*)
++ _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~
++ rm -rf $tpldir~
++ $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~
++ compile_command="$compile_command `find $tpldir -name \*.o | $NL2SP`"'
++ _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~
++ rm -rf $tpldir~
++ $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~
++ $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | $NL2SP`~
++ $RANLIB $oldlib'
++ _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~
++ rm -rf $tpldir~
++ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
++ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~
++ rm -rf $tpldir~
++ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
++ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
++ ;;
++ *) # Version 6 will use weak symbols
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+ ;;
+ esac
+- ;;
+- esac
+- ;;
+- lynxos*)
+- ;;
+- m88k*)
+- ;;
+- mvs*)
+- case $cc_basename in
+- cxx*)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall'
+- ;;
+- *)
+- ;;
+- esac
+- ;;
+- netbsd*)
+- ;;
+- osf3* | osf4* | osf5*)
+- case $cc_basename in
+- KCC*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
+- ;;
+- RCC*)
+- # Rational C++ 2.4.1
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+- ;;
++
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
++ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
++ ;;
+ cxx*)
+- # Digital/Compaq C++
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- # Make sure the PIC flag is empty. It appears that all Alpha
+- # Linux and Compaq Tru64 Unix objects are PIC.
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+- ;;
+- *)
+- ;;
+- esac
+- ;;
+- psos*)
+- ;;
+- solaris*)
+- case $cc_basename in
+- CC*)
+- # Sun C++ 4.2, 5.x and Centerline C++
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
+- ;;
+- gcx*)
+- # Green Hills C++ Compiler
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
+- ;;
+- *)
+- ;;
+- esac
+- ;;
+- sunos4*)
+- case $cc_basename in
+- CC*)
+- # Sun C++ 4.x
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- ;;
+- lcc*)
+- # Lucid
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+- ;;
+- *)
++ # Compaq C++
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
++
++ runpath_var=LD_RUN_PATH
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
++
++ # Commands to make compiler produce verbose output that lists
++ # what "hidden" libraries, object files and flags are used when
++ # linking a shared library.
++ #
++ # There doesn't appear to be a way to prevent this compiler from
++ # explicitly linking system object files so we need to strip them
++ # from the output so that they don't get included in the library
++ # dependencies.
++ output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
+ ;;
+- esac
+- ;;
+- tandem*)
+- case $cc_basename in
+- NCC*)
+- # NonStop-UX NCC 3.20
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ xl*)
++ # IBM XL 8.0 on PPC, with GNU ld
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
++ _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
++ if test "x$supports_anon_versioning" = xyes; then
++ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
++ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
++ echo "local: *; };" >> $output_objdir/$libname.ver~
++ $CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
++ fi
+ ;;
+ *)
++ case `$CC -V 2>&1 | sed 5q` in
++ *Sun\ C*)
++ # Sun C++ 5.9
++ _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'
++ _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
++ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
++ _LT_TAGVAR(compiler_needs_object, $1)=yes
++
++ # Not sure whether something based on
++ # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1
++ # would be better.
++ output_verbose_link_cmd='echo'
++
++ # Archives containing C++ object files must be created using
++ # "CC -xar", where "CC" is the Sun C++ compiler. This is
++ # necessary to make sure instantiated templates are included
++ # in the archive.
++ _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
++ ;;
++ esac
+ ;;
+ esac
+ ;;
+- sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+- case $cc_basename in
+- CC*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++
++ lynxos*)
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++
++ m88k*)
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++
++ mvs*)
++ case $cc_basename in
++ cxx*)
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++ *)
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ esac
+ ;;
+- vxworks*)
++
++ netbsd*)
++ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
++ _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags'
++ wlarc=
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ fi
++ # Workaround some broken pre-1.5 toolchains
++ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"'
+ ;;
+- *)
+- _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
++
++ *nto* | *qnx*)
++ _LT_TAGVAR(ld_shlibs, $1)=yes
+ ;;
+- esac
+- fi
+-],
+-[
+- if test "$GCC" = yes; then
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
+
+- case $host_os in
+- aix*)
+- # All AIX code is PIC.
+- if test "$host_cpu" = ia64; then
+- # AIX 5 now supports IA64 processor
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- fi
+- ;;
++ openbsd2*)
++ # C++ shared libraries are fairly broken
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++
++ openbsd*)
++ if test -f /usr/libexec/ld.so; then
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
++ if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
++ _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
++ fi
++ output_verbose_link_cmd=echo
++ else
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ fi
++ ;;
+
+- amigaos*)
+- # FIXME: we need at least 68020 code to build shared libraries, but
+- # adding the `-m68020' flag to GCC prevents building anything better,
+- # like `-m68040'.
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
+- ;;
++ osf3* | osf4* | osf5*)
++ case $cc_basename in
++ KCC*)
++ # Kuck and Associates, Inc. (KAI) C++ Compiler
++
++ # KCC will only create a shared library if the output file
++ # ends with ".so" (or ".sl" for HP-UX), so rename the library
++ # to its proper name (with version) after linking.
++ _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
++
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
++
++ # Archives containing C++ object files must be created using
++ # the KAI C++ compiler.
++ case $host in
++ osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;;
++ *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;;
++ esac
++ ;;
++ RCC*)
++ # Rational C++ 2.4.1
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++ cxx*)
++ case $host in
++ osf3*)
++ _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && $ECHO "X${wl}-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
++ ;;
++ *)
++ _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
++ echo "-hidden">> $lib.exp~
++ $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~
++ $RM $lib.exp'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
++ ;;
++ esac
+
+- beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+- # PIC is the default for these OSes.
+- ;;
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+- mingw* | cygwin* | pw32* | os2*)
+- # This hack is so that the source file can tell whether it is being
+- # built for inclusion in a dll (and should export symbols for example).
+- # Although the cygwin gcc ignores -fPIC, still need this for old-style
+- # (--disable-auto-import) libraries
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'
+- ;;
++ # Commands to make compiler produce verbose output that lists
++ # what "hidden" libraries, object files and flags are used when
++ # linking a shared library.
++ #
++ # There doesn't appear to be a way to prevent this compiler from
++ # explicitly linking system object files so we need to strip them
++ # from the output so that they don't get included in the library
++ # dependencies.
++ output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
++ ;;
++ *)
++ if test "$GXX" = yes && test "$with_gnu_ld" = no; then
++ _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
++ case $host in
++ osf3*)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
++ ;;
++ *)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
++ ;;
++ esac
++
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
++
++ # Commands to make compiler produce verbose output that lists
++ # what "hidden" libraries, object files and flags are used when
++ # linking a shared library.
++ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
++
++ else
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ fi
++ ;;
++ esac
++ ;;
+
+- darwin* | rhapsody*)
+- # PIC is the default on this platform
+- # Common symbols not allowed in MH_DYLIB files
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
+- ;;
++ psos*)
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
+
+- interix3*)
+- # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+- # Instead, we relocate shared libraries at runtime.
+- ;;
++ sunos4*)
++ case $cc_basename in
++ CC*)
++ # Sun C++ 4.x
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++ lcc*)
++ # Lucid
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++ *)
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++ esac
++ ;;
+
+- msdosdjgpp*)
+- # Just because we use GCC doesn't mean we suddenly get shared libraries
+- # on systems that don't support them.
+- _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+- enable_shared=no
+- ;;
++ solaris*)
++ case $cc_basename in
++ CC*)
++ # Sun C++ 4.2, 5.x and Centerline C++
++ _LT_TAGVAR(archive_cmds_need_lc,$1)=yes
++ _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'
++ _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
++ $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
++
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ case $host_os in
++ solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
++ *)
++ # The compiler driver will combine and reorder linker options,
++ # but understands `-z linker_flag'.
++ # Supported since Solaris 2.6 (maybe 2.5.1?)
++ _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
++ ;;
++ esac
++ _LT_TAGVAR(link_all_deplibs, $1)=yes
+
+- sysv4*MP*)
+- if test -d /usr/nec; then
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
+- fi
+- ;;
++ output_verbose_link_cmd='echo'
+
+- hpux*)
+- # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+- # not for PA HP-UX.
+- case $host_cpu in
+- hppa*64*|ia64*)
+- # +Z the default
+- ;;
+- *)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+- ;;
+- esac
+- ;;
++ # Archives containing C++ object files must be created using
++ # "CC -xar", where "CC" is the Sun C++ compiler. This is
++ # necessary to make sure instantiated templates are included
++ # in the archive.
++ _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
++ ;;
++ gcx*)
++ # Green Hills C++ Compiler
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+
+- *)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+- ;;
+- esac
+- else
+- # PORTME Check for flag to pass linker flags through the system compiler.
+- case $host_os in
+- aix*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- if test "$host_cpu" = ia64; then
+- # AIX 5 now supports IA64 processor
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- else
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
+- fi
+- ;;
+- darwin*)
+- # PIC is the default on this platform
+- # Common symbols not allowed in MH_DYLIB files
+- case $cc_basename in
+- xlc*)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-qnocommon'
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- ;;
+- esac
+- ;;
++ # The C++ compiler must be used to create the archive.
++ _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
++ ;;
++ *)
++ # GNU C++ compiler with Solaris linker
++ if test "$GXX" = yes && test "$with_gnu_ld" = no; then
++ _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs'
++ if $CC --version | $GREP -v '^2\.7' > /dev/null; then
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
++ $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
++
++ # Commands to make compiler produce verbose output that lists
++ # what "hidden" libraries, object files and flags are used when
++ # linking a shared library.
++ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
++ else
++ # g++ 2.7 appears to require `-G' NOT `-shared' on this
++ # platform.
++ _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
++ $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
++
++ # Commands to make compiler produce verbose output that lists
++ # what "hidden" libraries, object files and flags are used when
++ # linking a shared library.
++ output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
++ fi
++
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir'
++ case $host_os in
++ solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
++ *)
++ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
++ ;;
++ esac
++ fi
++ ;;
++ esac
++ ;;
+
+- mingw* | cygwin* | pw32* | os2*)
+- # This hack is so that the source file can tell whether it is being
+- # built for inclusion in a dll (and should export symbols for example).
+- # Although the cygwin gcc ignores -fPIC, still need this for old-style
+- # (--disable-auto-import) libraries
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'
+- ;;
++ sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
++ _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
++ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ runpath_var='LD_RUN_PATH'
+
+- hpux9* | hpux10* | hpux11*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+- # not for PA HP-UX.
+- case $host_cpu in
+- hppa*64*|ia64*)
+- # +Z the default
+- ;;
+- *)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
+- ;;
++ case $cc_basename in
++ CC*)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ ;;
++ *)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ ;;
+ esac
+- # Is there a better lt_prog_compiler_static that works with the bundled CC?
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+ ;;
+
+- irix5* | irix6* | nonstopux*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- # PIC (with -KPIC) is the default.
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+- ;;
++ sysv5* | sco3.2v5* | sco5v6*)
++ # Note: We can NOT use -z defs as we might desire, because we do not
++ # link with -lc, and that would cause any symbols used from libc to
++ # always be unresolved, which means just about no library would
++ # ever link correctly. If we're not using GNU ld we use -z text
++ # though, which does catch some bad symbols but isn't as heavy-handed
++ # as -z defs.
++ _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
++ _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
++ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
++ _LT_TAGVAR(link_all_deplibs, $1)=yes
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
++ runpath_var='LD_RUN_PATH'
+
+- newsos6)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ case $cc_basename in
++ CC*)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ ;;
++ *)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ ;;
++ esac
+ ;;
+
+- linux*)
+- case $cc_basename in
+- icc* | ecc*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
+- ;;
+- pgcc* | pgf77* | pgf90* | pgf95*)
+- # Portland Group compilers (*not* the Pentium gcc compiler,
+- # which looks to be a dead project)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- ;;
+- ccc*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- # All Alpha code is PIC.
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
++ tandem*)
++ case $cc_basename in
++ NCC*)
++ # NonStop-UX NCC 3.20
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++ *)
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++ esac
+ ;;
+- como)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-lopt='
++
++ vxworks*)
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
++
+ *)
+- case `$CC -V 2>&1 | sed 5q` in
+- *Sun\ C*)
+- # Sun C 5.9
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- ;;
+- *Sun\ F*)
+- # Sun Fortran 8.3 passes all unrecognized flags to the linker
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)=''
+- ;;
+- esac
+- ;;
+- esac
+- ;;
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++ esac
+
+- osf3* | osf4* | osf5*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- # All OSF/1 code is PIC.
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+- ;;
++ AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
++ test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
+
+- solaris*)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- case $cc_basename in
+- f77* | f90* | f95*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';;
+- *)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';;
+- esac
+- ;;
++ _LT_TAGVAR(GCC, $1)="$GXX"
++ _LT_TAGVAR(LD, $1)="$LD"
++
++ ## CAVEAT EMPTOR:
++ ## There is no encapsulation within the following macros, do not change
++ ## the running order or otherwise move them around unless you know exactly
++ ## what you are doing...
++ _LT_SYS_HIDDEN_LIBDEPS($1)
++ _LT_COMPILER_PIC($1)
++ _LT_COMPILER_C_O($1)
++ _LT_COMPILER_FILE_LOCKS($1)
++ _LT_LINKER_SHLIBS($1)
++ _LT_SYS_DYNAMIC_LINKER($1)
++ _LT_LINKER_HARDCODE_LIBPATH($1)
++
++ _LT_CONFIG($1)
++ fi # test -n "$compiler"
++
++ CC=$lt_save_CC
++ LDCXX=$LD
++ LD=$lt_save_LD
++ GCC=$lt_save_GCC
++ with_gnu_ld=$lt_save_with_gnu_ld
++ lt_cv_path_LDCXX=$lt_cv_path_LD
++ lt_cv_path_LD=$lt_save_path_LD
++ lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
++ lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
++fi # test "$_lt_caught_CXX_error" != yes
++
++AC_LANG_POP
++])# _LT_LANG_CXX_CONFIG
++
++
++# _LT_SYS_HIDDEN_LIBDEPS([TAGNAME])
++# ---------------------------------
++# Figure out "hidden" library dependencies from verbose
++# compiler output when linking a shared library.
++# Parse the compiler output and extract the necessary
++# objects, libraries and library flags.
++m4_defun([_LT_SYS_HIDDEN_LIBDEPS],
++[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
++# Dependencies to place before and after the object being linked:
++_LT_TAGVAR(predep_objects, $1)=
++_LT_TAGVAR(postdep_objects, $1)=
++_LT_TAGVAR(predeps, $1)=
++_LT_TAGVAR(postdeps, $1)=
++_LT_TAGVAR(compiler_lib_search_path, $1)=
++
++dnl we can't use the lt_simple_compile_test_code here,
++dnl because it contains code intended for an executable,
++dnl not a library. It's possible we should let each
++dnl tag define a new lt_????_link_test_code variable,
++dnl but it's only used here...
++m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF
++int a;
++void foo (void) { a = 0; }
++_LT_EOF
++], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF
++class Foo
++{
++public:
++ Foo (void) { a = 0; }
++private:
++ int a;
++};
++_LT_EOF
++], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF
++ subroutine foo
++ implicit none
++ integer*4 a
++ a=0
++ return
++ end
++_LT_EOF
++], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF
++ subroutine foo
++ implicit none
++ integer a
++ a=0
++ return
++ end
++_LT_EOF
++], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF
++public class foo {
++ private int a;
++ public void bar (void) {
++ a = 0;
++ }
++};
++_LT_EOF
++])
++dnl Parse the compiler output and extract the necessary
++dnl objects, libraries and library flags.
++if AC_TRY_EVAL(ac_compile); then
++ # Parse the compiler output and extract the necessary
++ # objects, libraries and library flags.
++
++ # Sentinel used to keep track of whether or not we are before
++ # the conftest object file.
++ pre_test_object_deps_done=no
+
+- sunos4*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- ;;
++ for p in `eval "$output_verbose_link_cmd"`; do
++ case $p in
+
+- sysv4 | sysv4.2uw2* | sysv4.3*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- ;;
++ -L* | -R* | -l*)
++ # Some compilers place space between "-{L,R}" and the path.
++ # Remove the space.
++ if test $p = "-L" ||
++ test $p = "-R"; then
++ prev=$p
++ continue
++ else
++ prev=
++ fi
+
+- sysv4*MP*)
+- if test -d /usr/nec ;then
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- fi
+- ;;
++ if test "$pre_test_object_deps_done" = no; then
++ case $p in
++ -L* | -R*)
++ # Internal compiler library paths should come after those
++ # provided the user. The postdeps already come after the
++ # user supplied libs so there is no need to process them.
++ if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then
++ _LT_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}"
++ else
++ _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}"
++ fi
++ ;;
++ # The "-l" case would never come before the object being
++ # linked, so don't bother handling this case.
++ esac
++ else
++ if test -z "$_LT_TAGVAR(postdeps, $1)"; then
++ _LT_TAGVAR(postdeps, $1)="${prev}${p}"
++ else
++ _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}"
++ fi
++ fi
++ ;;
+
+- sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- ;;
++ *.$objext)
++ # This assumes that the test object file only shows up
++ # once in the compiler output.
++ if test "$p" = "conftest.$objext"; then
++ pre_test_object_deps_done=yes
++ continue
++ fi
+
+- unicos*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+- ;;
++ if test "$pre_test_object_deps_done" = no; then
++ if test -z "$_LT_TAGVAR(predep_objects, $1)"; then
++ _LT_TAGVAR(predep_objects, $1)="$p"
++ else
++ _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p"
++ fi
++ else
++ if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then
++ _LT_TAGVAR(postdep_objects, $1)="$p"
++ else
++ _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p"
++ fi
++ fi
++ ;;
+
+- uts4*)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- ;;
++ *) ;; # Ignore the rest.
+
+- *)
+- _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+- ;;
+ esac
+- fi
+-])
+-AC_MSG_RESULT([$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)])
++ done
+
+-#
+-# Check to make sure the PIC flag actually works.
+-#
+-if test -n "$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)"; then
+- AC_LIBTOOL_COMPILER_OPTION([if $compiler PIC flag $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) works],
+- _LT_AC_TAGVAR(lt_prog_compiler_pic_works, $1),
+- [$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)ifelse([$1],[],[ -DPIC],[ifelse([$1],[CXX],[ -DPIC],[])])], [],
+- [case $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) in
+- "" | " "*) ;;
+- *) _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)" ;;
+- esac],
+- [_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
+- _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no])
++ # Clean up.
++ rm -f a.out a.exe
++else
++ echo "libtool.m4: error: problem compiling $1 test program"
+ fi
+-case $host_os in
+- # For platforms which do not support PIC, -DPIC is meaningless:
+- *djgpp*)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
+- ;;
+- *)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)ifelse([$1],[],[ -DPIC],[ifelse([$1],[CXX],[ -DPIC],[])])"
+- ;;
+-esac
+-
+-#
+-# Check to make sure the static flag actually works.
+-#
+-wl=$_LT_AC_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_AC_TAGVAR(lt_prog_compiler_static, $1)\"
+-AC_LIBTOOL_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works],
+- _LT_AC_TAGVAR(lt_prog_compiler_static_works, $1),
+- $lt_tmp_static_flag,
+- [],
+- [_LT_AC_TAGVAR(lt_prog_compiler_static, $1)=])
+-])
+
++$RM -f confest.$objext
+
+-# AC_LIBTOOL_PROG_LD_SHLIBS([TAGNAME])
+-# ------------------------------------
+-# See if the linker supports building shared libraries.
+-AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS],
+-[AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
+-ifelse([$1],[CXX],[
+- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+- case $host_os in
+- aix4* | aix5*)
+- # If we're using GNU nm, then we don't want the "-C" option.
+- # -C means demangle to AIX nm, but means don't demangle with GNU nm
+- if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
+- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols'
+- else
+- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols'
+- fi
+- ;;
+- pw32*)
+- _LT_AC_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds"
+- ;;
+- cygwin* | mingw*)
+- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]] /s/.* \([[^ ]]*\)/\1 DATA/;/^.* __nm__/s/^.* __nm__\([[^ ]]*\) [[^ ]]*/\1 DATA/;/^I /d;/^[[AITW]] /s/.* //'\'' | sort | uniq > $export_symbols'
+- ;;
+- *)
+- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
++# PORTME: override above test on systems where it is broken
++m4_if([$1], [CXX],
++[case $host_os in
++interix[[3-9]]*)
++ # Interix 3.5 installs completely hosed .la files for C++, so rather than
++ # hack all around it, let's just trust "g++" to DTRT.
++ _LT_TAGVAR(predep_objects,$1)=
++ _LT_TAGVAR(postdep_objects,$1)=
++ _LT_TAGVAR(postdeps,$1)=
+ ;;
+- esac
+-],[
+- runpath_var=
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=
+- _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+- _LT_AC_TAGVAR(archive_cmds, $1)=
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)=
+- _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)=
+- _LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1)=
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+- _LT_AC_TAGVAR(thread_safe_flag_spec, $1)=
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
+- _LT_AC_TAGVAR(hardcode_direct, $1)=no
+- _LT_AC_TAGVAR(hardcode_minus_L, $1)=no
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+- _LT_AC_TAGVAR(link_all_deplibs, $1)=unknown
+- _LT_AC_TAGVAR(hardcode_automatic, $1)=no
+- _LT_AC_TAGVAR(module_cmds, $1)=
+- _LT_AC_TAGVAR(module_expsym_cmds, $1)=
+- _LT_AC_TAGVAR(always_export_symbols, $1)=no
+- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+- # include_expsyms should be a list of space-separated symbols to be *always*
+- # included in the symbol list
+- _LT_AC_TAGVAR(include_expsyms, $1)=
+- # exclude_expsyms can be an extended regexp of symbols to exclude
+- # it will be wrapped by ` (' and `)$', so one must not match beginning or
+- # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
+- # as well as any symbol that contains `d'.
+- _LT_AC_TAGVAR(exclude_expsyms, $1)="_GLOBAL_OFFSET_TABLE_"
+- # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
+- # platforms (ab)use it in PIC code, but their linkers get confused if
+- # the symbol is explicitly referenced. Since portable code cannot
+- # rely on this symbol name, it's probably fine to never include it in
+- # preloaded symbol tables.
+- extract_expsyms_cmds=
+- # Just being paranoid about ensuring that cc_basename is set.
+- _LT_CC_BASENAME([$compiler])
+- case $host_os in
+- cygwin* | mingw* | pw32*)
+- # FIXME: the MSVC++ port hasn't been tested in a loooong time
+- # When not using gcc, we currently assume that we are using
+- # Microsoft Visual C++.
+- if test "$GCC" != yes; then
+- with_gnu_ld=no
+- fi
+- ;;
+- interix*)
+- # we just hope/assume this is gcc and not c89 (= MSVC++)
+- with_gnu_ld=yes
+- ;;
+- openbsd*)
+- with_gnu_ld=no
+- ;;
+- esac
+-
+- _LT_AC_TAGVAR(ld_shlibs, $1)=yes
+- if test "$with_gnu_ld" = yes; then
+- # If archive_cmds runs LD, not CC, wlarc should be empty
+- wlarc='${wl}'
+-
+- # Set some defaults for GNU ld with shared library support. These
+- # are reset later if shared libraries are not supported. Putting them
+- # here allows them to be overridden if necessary.
+- runpath_var=LD_RUN_PATH
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+- # ancient GNU ld didn't support --whole-archive et. al.
+- if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+- else
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+- fi
+- supports_anon_versioning=no
+- case `$LD -v 2>/dev/null` in
+- *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11
+- *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
+- *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
+- *\ 2.11.*) ;; # other 2.11 versions
+- *) supports_anon_versioning=yes ;;
+- esac
+-
+- # See if GNU ld supports shared libraries.
+- case $host_os in
+- aix3* | aix4* | aix5*)
+- # On AIX/PPC, the GNU linker is very broken
+- if test "$host_cpu" != ia64; then
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- cat <<EOF 1>&2
+-
+-*** Warning: the GNU linker, at least up to release 2.9.1, is reported
+-*** to be unable to reliably create shared libraries on AIX.
+-*** Therefore, libtool is disabling shared libraries support. If you
+-*** really care for shared libraries, you may want to modify your PATH
+-*** so that a non-GNU linker is found, and then restart.
+-
+-EOF
+- fi
+- ;;
+
+- amigaos*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+-
+- # Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports
+- # that the semantics of dynamic libraries on AmigaOS, at least up
+- # to version 4, is to share data among multiple programs linked
+- # with the same dynamic library. Since this doesn't match the
+- # behavior of shared libraries on other platforms, we can't use
+- # them.
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
++linux*)
++ case `$CC -V 2>&1 | sed 5q` in
++ *Sun\ C*)
++ # Sun C++ 5.9
+
+- beos*)
+- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+- # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
+- # support --undefined. This deserves some investigation. FIXME
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+- else
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- fi
++ # The more standards-conforming stlport4 library is
++ # incompatible with the Cstd library. Avoid specifying
++ # it if it's in CXXFLAGS. Ignore libCrun as
++ # -library=stlport4 depends on it.
++ case " $CXX $CXXFLAGS " in
++ *" -library=stlport4 "*)
++ solaris_use_stlport4=yes
+ ;;
++ esac
+
+- cygwin* | mingw* | pw32*)
+- # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
+- # as there is no search path for DLLs.
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+- _LT_AC_TAGVAR(always_export_symbols, $1)=no
+- _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]] /s/.* \([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]] /s/.* //'\'' | sort | uniq > $export_symbols'
+-
+- if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+- # If the export-symbols file already is a .def file (1st line
+- # is EXPORTS), use it as is; otherwise, prepend...
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+- cp $export_symbols $output_objdir/$soname.def;
+- else
+- echo EXPORTS > $output_objdir/$soname.def;
+- cat $export_symbols >> $output_objdir/$soname.def;
+- fi~
+- $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+- else
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- fi
+- ;;
++ if test "$solaris_use_stlport4" != yes; then
++ _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
++ fi
++ ;;
++ esac
++ ;;
+
+- interix3*)
+- _LT_AC_TAGVAR(hardcode_direct, $1)=no
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+- # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+- # Instead, shared libraries are loaded at an image base (0x10000000 by
+- # default) and relocated if they conflict, which is a slow very memory
+- # consuming and fragmenting process. To avoid this, we pick a random,
+- # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+- # time. Moving up from 0x10000000 also allows more sbrk(2) space.
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
++solaris*)
++ case $cc_basename in
++ CC*)
++ # The more standards-conforming stlport4 library is
++ # incompatible with the Cstd library. Avoid specifying
++ # it if it's in CXXFLAGS. Ignore libCrun as
++ # -library=stlport4 depends on it.
++ case " $CXX $CXXFLAGS " in
++ *" -library=stlport4 "*)
++ solaris_use_stlport4=yes
+ ;;
++ esac
+
+- linux*)
+- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+- tmp_addflag=
+- case $cc_basename,$host_cpu in
+- pgcc*) # Portland Group C compiler
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+- tmp_addflag=' $pic_flag'
+- ;;
+- pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+- tmp_addflag=' $pic_flag -Mnomain' ;;
+- ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64
+- tmp_addflag=' -i_dynamic' ;;
+- efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64
+- tmp_addflag=' -i_dynamic -nofor_main' ;;
+- ifc* | ifort*) # Intel Fortran compiler
+- tmp_addflag=' -nofor_main' ;;
+- esac
+- case `$CC -V 2>&1 | sed 5q` in
+- *Sun\ C*) # Sun C 5.9
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive /dev/null'
+- tmp_sharedflag='-G' ;;
+- *Sun\ F*) # Sun Fortran 8.3
+- tmp_sharedflag='-G' ;;
+- *)
+- tmp_sharedflag='-shared' ;;
+- esac
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
++ # Adding this requires a known-good setup of shared libraries for
++ # Sun compiler versions before 5.6, else PIC objects from an old
++ # archive will be linked into the output, leading to subtle bugs.
++ if test "$solaris_use_stlport4" != yes; then
++ _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
++ fi
++ ;;
++ esac
++ ;;
++esac
++])
+
+- if test $supports_anon_versioning = yes; then
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $output_objdir/$libname.ver~
+- cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+- $echo "local: *; };" >> $output_objdir/$libname.ver~
+- $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+- fi
+- else
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- fi
+- ;;
++case " $_LT_TAGVAR(postdeps, $1) " in
++*" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;;
++esac
++ _LT_TAGVAR(compiler_lib_search_dirs, $1)=
++if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then
++ _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'`
++fi
++_LT_TAGDECL([], [compiler_lib_search_dirs], [1],
++ [The directories searched by this compiler when creating a shared library])
++_LT_TAGDECL([], [predep_objects], [1],
++ [Dependencies to place before and after the objects being linked to
++ create a shared library])
++_LT_TAGDECL([], [postdep_objects], [1])
++_LT_TAGDECL([], [predeps], [1])
++_LT_TAGDECL([], [postdeps], [1])
++_LT_TAGDECL([], [compiler_lib_search_path], [1],
++ [The library search path used internally by the compiler when linking
++ a shared library])
++])# _LT_SYS_HIDDEN_LIBDEPS
++
++
++# _LT_PROG_F77
++# ------------
++# Since AC_PROG_F77 is broken, in that it returns the empty string
++# if there is no fortran compiler, we have our own version here.
++m4_defun([_LT_PROG_F77],
++[
++pushdef([AC_MSG_ERROR], [_lt_disable_F77=yes])
++AC_PROG_F77
++if test -z "$F77" || test "X$F77" = "Xno"; then
++ _lt_disable_F77=yes
++fi
++popdef([AC_MSG_ERROR])
++])# _LT_PROG_F77
+
+- netbsd*)
+- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
+- wlarc=
+- else
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+- fi
+- ;;
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([_LT_PROG_F77], [])
+
+- solaris*)
+- if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- cat <<EOF 1>&2
+
+-*** Warning: The releases 2.8.* of the GNU linker cannot reliably
+-*** create shared libraries on Solaris systems. Therefore, libtool
+-*** is disabling shared libraries support. We urge you to upgrade GNU
+-*** binutils to release 2.9.1 or newer. Another option is to modify
+-*** your PATH or compiler configuration so that the native linker is
+-*** used, and then restart.
++# _LT_LANG_F77_CONFIG([TAG])
++# --------------------------
++# Ensure that the configuration variables for a Fortran 77 compiler are
++# suitably defined. These variables are subsequently used by _LT_CONFIG
++# to write the compiler configuration to `libtool'.
++m4_defun([_LT_LANG_F77_CONFIG],
++[AC_REQUIRE([_LT_PROG_F77])dnl
++AC_LANG_PUSH(Fortran 77)
+
+-EOF
+- elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+- else
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- fi
+- ;;
++_LT_TAGVAR(archive_cmds_need_lc, $1)=no
++_LT_TAGVAR(allow_undefined_flag, $1)=
++_LT_TAGVAR(always_export_symbols, $1)=no
++_LT_TAGVAR(archive_expsym_cmds, $1)=
++_LT_TAGVAR(export_dynamic_flag_spec, $1)=
++_LT_TAGVAR(hardcode_direct, $1)=no
++_LT_TAGVAR(hardcode_direct_absolute, $1)=no
++_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
++_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
++_LT_TAGVAR(hardcode_libdir_separator, $1)=
++_LT_TAGVAR(hardcode_minus_L, $1)=no
++_LT_TAGVAR(hardcode_automatic, $1)=no
++_LT_TAGVAR(inherit_rpath, $1)=no
++_LT_TAGVAR(module_cmds, $1)=
++_LT_TAGVAR(module_expsym_cmds, $1)=
++_LT_TAGVAR(link_all_deplibs, $1)=unknown
++_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
++_LT_TAGVAR(no_undefined_flag, $1)=
++_LT_TAGVAR(whole_archive_flag_spec, $1)=
++_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+
+- sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
+- case `$LD -v 2>&1` in
+- *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*)
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- cat <<_LT_EOF 1>&2
++# Source file extension for f77 test sources.
++ac_ext=f
+
+-*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
+-*** reliably create shared libraries on SCO systems. Therefore, libtool
+-*** is disabling shared libraries support. We urge you to upgrade GNU
+-*** binutils to release 2.16.91.0.3 or newer. Another option is to modify
+-*** your PATH or compiler configuration so that the native linker is
+-*** used, and then restart.
++# Object file extension for compiled f77 test sources.
++objext=o
++_LT_TAGVAR(objext, $1)=$objext
+
+-_LT_EOF
+- ;;
+- *)
+- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname,-retain-symbols-file,$export_symbols -o $lib'
+- else
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- fi
+- ;;
+- esac
+- ;;
++# No sense in running all these tests if we already determined that
++# the F77 compiler isn't working. Some variables (like enable_shared)
++# are currently assumed to apply to all compilers on this platform,
++# and will be corrupted by setting them based on a non-working compiler.
++if test "$_lt_disable_F77" != yes; then
++ # Code to be used in simple compile tests
++ lt_simple_compile_test_code="\
++ subroutine t
++ return
++ end
++"
+
+- sunos4*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+- wlarc=
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- ;;
++ # Code to be used in simple link tests
++ lt_simple_link_test_code="\
++ program t
++ end
++"
+
+- *)
+- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+- else
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- fi
+- ;;
+- esac
++ # ltmain only uses $CC for tagged configurations so make sure $CC is set.
++ _LT_TAG_COMPILER
+
+- if test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no; then
+- runpath_var=
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+- fi
+- else
+- # PORTME fill in a description of your system's linker (not GNU ld)
+- case $host_os in
+- aix3*)
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+- _LT_AC_TAGVAR(always_export_symbols, $1)=yes
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
+- # Note: this linker hardcodes the directories in LIBPATH if there
+- # are no directories specified by -L.
+- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+- if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
+- # Neither direct hardcoding nor static linking is supported with a
+- # broken collect2.
+- _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported
+- fi
+- ;;
++ # save warnings/boilerplate of simple test code
++ _LT_COMPILER_BOILERPLATE
++ _LT_LINKER_BOILERPLATE
++
++ # Allow CC to be a program name with arguments.
++ lt_save_CC="$CC"
++ lt_save_GCC=$GCC
++ CC=${F77-"f77"}
++ compiler=$CC
++ _LT_TAGVAR(compiler, $1)=$CC
++ _LT_CC_BASENAME([$compiler])
++ GCC=$G77
++ if test -n "$compiler"; then
++ AC_MSG_CHECKING([if libtool supports shared libraries])
++ AC_MSG_RESULT([$can_build_shared])
+
+- aix4* | aix5*)
+- if test "$host_cpu" = ia64; then
+- # On IA64, the linker does run time linking by default, so we don't
+- # have to do anything special.
+- aix_use_runtimelinking=no
+- exp_sym_flag='-Bexport'
+- no_entry_flag=""
+- else
+- # If we're using GNU nm, then we don't want the "-C" option.
+- # -C means demangle to AIX nm, but means don't demangle with GNU nm
+- if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
+- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols'
+- else
+- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols'
++ AC_MSG_CHECKING([whether to build shared libraries])
++ test "$can_build_shared" = "no" && enable_shared=no
++
++ # On AIX, shared libraries and static libraries use the same namespace, and
++ # are all built from PIC.
++ case $host_os in
++ aix3*)
++ test "$enable_shared" = yes && enable_static=no
++ if test -n "$RANLIB"; then
++ archive_cmds="$archive_cmds~\$RANLIB \$lib"
++ postinstall_cmds='$RANLIB $lib'
++ fi
++ ;;
++ aix[[4-9]]*)
++ if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
++ test "$enable_shared" = yes && enable_static=no
+ fi
+- aix_use_runtimelinking=no
++ ;;
++ esac
++ AC_MSG_RESULT([$enable_shared])
+
+- # Test if we are trying to use run time linking or normal
+- # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+- # need to do runtime linking.
+- case $host_os in aix4.[[23]]|aix4.[[23]].*|aix5*)
+- for ld_flag in $LDFLAGS; do
+- if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+- aix_use_runtimelinking=yes
+- break
+- fi
+- done
+- ;;
+- esac
++ AC_MSG_CHECKING([whether to build static libraries])
++ # Make sure either enable_shared or enable_static is yes.
++ test "$enable_shared" = yes || enable_static=yes
++ AC_MSG_RESULT([$enable_static])
++
++ _LT_TAGVAR(GCC, $1)="$G77"
++ _LT_TAGVAR(LD, $1)="$LD"
++
++ ## CAVEAT EMPTOR:
++ ## There is no encapsulation within the following macros, do not change
++ ## the running order or otherwise move them around unless you know exactly
++ ## what you are doing...
++ _LT_COMPILER_PIC($1)
++ _LT_COMPILER_C_O($1)
++ _LT_COMPILER_FILE_LOCKS($1)
++ _LT_LINKER_SHLIBS($1)
++ _LT_SYS_DYNAMIC_LINKER($1)
++ _LT_LINKER_HARDCODE_LIBPATH($1)
++
++ _LT_CONFIG($1)
++ fi # test -n "$compiler"
++
++ GCC=$lt_save_GCC
++ CC="$lt_save_CC"
++fi # test "$_lt_disable_F77" != yes
+
+- exp_sym_flag='-bexport'
+- no_entry_flag='-bnoentry'
+- fi
++AC_LANG_POP
++])# _LT_LANG_F77_CONFIG
+
+- # When large executables or shared objects are built, AIX ld can
+- # have problems creating the table of contents. If linking a library
+- # or program results in "error TOC overflow" add -mminimal-toc to
+- # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
+- # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+- _LT_AC_TAGVAR(archive_cmds, $1)=''
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':'
+- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
++# _LT_PROG_FC
++# -----------
++# Since AC_PROG_FC is broken, in that it returns the empty string
++# if there is no fortran compiler, we have our own version here.
++m4_defun([_LT_PROG_FC],
++[
++pushdef([AC_MSG_ERROR], [_lt_disable_FC=yes])
++AC_PROG_FC
++if test -z "$FC" || test "X$FC" = "Xno"; then
++ _lt_disable_FC=yes
++fi
++popdef([AC_MSG_ERROR])
++])# _LT_PROG_FC
+
+- if test "$GCC" = yes; then
+- case $host_os in aix4.[[012]]|aix4.[[012]].*)
+- # We only want to do this on AIX 4.2 and lower, the check
+- # below for broken collect2 doesn't work under 4.3+
+- collect2name=`${CC} -print-prog-name=collect2`
+- if test -f "$collect2name" && \
+- strings "$collect2name" | grep resolve_lib_name >/dev/null
+- then
+- # We have reworked collect2
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- else
+- # We have old collect2
+- _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported
+- # It fails to find uninstalled libraries when the uninstalled
+- # path is not listed in the libpath. Setting hardcode_minus_L
+- # to unsupported forces relinking
+- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
+- fi
+- ;;
+- esac
+- shared_flag='-shared'
+- if test "$aix_use_runtimelinking" = yes; then
+- shared_flag="$shared_flag "'${wl}-G'
+- fi
+- else
+- # not using gcc
+- if test "$host_cpu" = ia64; then
+- # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+- # chokes on -Wl,-G. The following line is correct:
+- shared_flag='-G'
+- else
+- if test "$aix_use_runtimelinking" = yes; then
+- shared_flag='${wl}-G'
+- else
+- shared_flag='${wl}-bM:SRE'
+- fi
+- fi
+- fi
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([_LT_PROG_FC], [])
+
+- # It seems that -bexpall does not export symbols beginning with
+- # underscore (_), so it is better to generate a list of symbols to export.
+- _LT_AC_TAGVAR(always_export_symbols, $1)=yes
+- if test "$aix_use_runtimelinking" = yes; then
+- # Warning - without using the other runtime loading flags (-brtl),
+- # -berok will link without error, but may produce a broken library.
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)='-berok'
+- # Determine the default libpath from the value encoded in an empty executable.
+- _LT_AC_SYS_LIBPATH_AIX
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+- else
+- if test "$host_cpu" = ia64; then
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+- else
+- # Determine the default libpath from the value encoded in an empty executable.
+- _LT_AC_SYS_LIBPATH_AIX
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+- # Warning - without using the other run time loading flags,
+- # -berok will link without error, but may produce a broken library.
+- _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
+- # Exported symbols can be pulled into shared objects from archives
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
+- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
+- # This is similar to how AIX traditionally builds its shared libraries.
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+- fi
+- fi
+- ;;
+
+- amigaos*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+- # see comment about different semantics on the GNU ld section
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
++# _LT_LANG_FC_CONFIG([TAG])
++# -------------------------
++# Ensure that the configuration variables for a Fortran compiler are
++# suitably defined. These variables are subsequently used by _LT_CONFIG
++# to write the compiler configuration to `libtool'.
++m4_defun([_LT_LANG_FC_CONFIG],
++[AC_REQUIRE([_LT_PROG_FC])dnl
++AC_LANG_PUSH(Fortran)
++
++_LT_TAGVAR(archive_cmds_need_lc, $1)=no
++_LT_TAGVAR(allow_undefined_flag, $1)=
++_LT_TAGVAR(always_export_symbols, $1)=no
++_LT_TAGVAR(archive_expsym_cmds, $1)=
++_LT_TAGVAR(export_dynamic_flag_spec, $1)=
++_LT_TAGVAR(hardcode_direct, $1)=no
++_LT_TAGVAR(hardcode_direct_absolute, $1)=no
++_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
++_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
++_LT_TAGVAR(hardcode_libdir_separator, $1)=
++_LT_TAGVAR(hardcode_minus_L, $1)=no
++_LT_TAGVAR(hardcode_automatic, $1)=no
++_LT_TAGVAR(inherit_rpath, $1)=no
++_LT_TAGVAR(module_cmds, $1)=
++_LT_TAGVAR(module_expsym_cmds, $1)=
++_LT_TAGVAR(link_all_deplibs, $1)=unknown
++_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
++_LT_TAGVAR(no_undefined_flag, $1)=
++_LT_TAGVAR(whole_archive_flag_spec, $1)=
++_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+
+- bsdi[[45]]*)
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic
+- ;;
++# Source file extension for fc test sources.
++ac_ext=${ac_fc_srcext-f}
+
+- cygwin* | mingw* | pw32*)
+- # When not using gcc, we currently assume that we are using
+- # Microsoft Visual C++.
+- # hardcode_libdir_flag_spec is actually meaningless, as there is
+- # no search path for DLLs.
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=' '
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+- # Tell ltmain to make .lib files, not .a files.
+- libext=lib
+- # Tell ltmain to make .dll files, not .so files.
+- shrext_cmds=".dll"
+- # FIXME: Setting linknames here is a bad hack.
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames='
+- # The linker will automatically build a .lib file if we build a DLL.
+- _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)='true'
+- # FIXME: Should let the user specify the lib program.
+- _LT_AC_TAGVAR(old_archive_cmds, $1)='lib /OUT:$oldlib$oldobjs$old_deplibs'
+- _LT_AC_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`'
+- _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+- ;;
++# Object file extension for compiled fc test sources.
++objext=o
++_LT_TAGVAR(objext, $1)=$objext
+
+- darwin* | rhapsody*)
+- case $host_os in
+- rhapsody* | darwin1.[[012]])
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}suppress'
+- ;;
+- *) # Darwin 1.3 on
+- if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+- else
+- case ${MACOSX_DEPLOYMENT_TARGET} in
+- 10.[[012]])
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+- ;;
+- 10.*)
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}dynamic_lookup'
+- ;;
+- esac
+- fi
+- ;;
+- esac
+- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+- _LT_AC_TAGVAR(hardcode_direct, $1)=no
+- _LT_AC_TAGVAR(hardcode_automatic, $1)=yes
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=''
+- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+- if test "$GCC" = yes ; then
+- output_verbose_link_cmd='echo'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+- _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+- # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+- _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+- else
+- case $cc_basename in
+- xlc*)
+- output_verbose_link_cmd='echo'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
+- _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+- # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+- _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+- ;;
+- *)
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- esac
+- fi
+- ;;
++# No sense in running all these tests if we already determined that
++# the FC compiler isn't working. Some variables (like enable_shared)
++# are currently assumed to apply to all compilers on this platform,
++# and will be corrupted by setting them based on a non-working compiler.
++if test "$_lt_disable_FC" != yes; then
++ # Code to be used in simple compile tests
++ lt_simple_compile_test_code="\
++ subroutine t
++ return
++ end
++"
+
+- dgux*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- ;;
++ # Code to be used in simple link tests
++ lt_simple_link_test_code="\
++ program t
++ end
++"
+
+- freebsd1*)
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
++ # ltmain only uses $CC for tagged configurations so make sure $CC is set.
++ _LT_TAG_COMPILER
+
+- # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
+- # support. Future versions do this automatically, but an explicit c++rt0.o
+- # does not break anything, and helps significantly (at the cost of a little
+- # extra space).
+- freebsd2.2*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- ;;
++ # save warnings/boilerplate of simple test code
++ _LT_COMPILER_BOILERPLATE
++ _LT_LINKER_BOILERPLATE
++
++ # Allow CC to be a program name with arguments.
++ lt_save_CC="$CC"
++ lt_save_GCC=$GCC
++ CC=${FC-"f95"}
++ compiler=$CC
++ GCC=$ac_cv_fc_compiler_gnu
+
+- # Unfortunately, older versions of FreeBSD 2 do not have this feature.
+- freebsd2*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- ;;
++ _LT_TAGVAR(compiler, $1)=$CC
++ _LT_CC_BASENAME([$compiler])
+
+- # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
+- freebsd* | kfreebsd*-gnu | dragonfly*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- ;;
++ if test -n "$compiler"; then
++ AC_MSG_CHECKING([if libtool supports shared libraries])
++ AC_MSG_RESULT([$can_build_shared])
+
+- hpux9*)
+- if test "$GCC" = yes; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+- else
+- _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+- fi
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
++ AC_MSG_CHECKING([whether to build shared libraries])
++ test "$can_build_shared" = "no" && enable_shared=no
+
+- # hardcode_minus_L: Not really in the search PATH,
+- # but as the default location of the library.
+- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+- ;;
++ # On AIX, shared libraries and static libraries use the same namespace, and
++ # are all built from PIC.
++ case $host_os in
++ aix3*)
++ test "$enable_shared" = yes && enable_static=no
++ if test -n "$RANLIB"; then
++ archive_cmds="$archive_cmds~\$RANLIB \$lib"
++ postinstall_cmds='$RANLIB $lib'
++ fi
++ ;;
++ aix[[4-9]]*)
++ if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
++ test "$enable_shared" = yes && enable_static=no
++ fi
++ ;;
++ esac
++ AC_MSG_RESULT([$enable_shared])
+
+- hpux10*)
+- if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+- else
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
+- fi
+- if test "$with_gnu_ld" = no; then
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
++ AC_MSG_CHECKING([whether to build static libraries])
++ # Make sure either enable_shared or enable_static is yes.
++ test "$enable_shared" = yes || enable_static=yes
++ AC_MSG_RESULT([$enable_static])
++
++ _LT_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu"
++ _LT_TAGVAR(LD, $1)="$LD"
++
++ ## CAVEAT EMPTOR:
++ ## There is no encapsulation within the following macros, do not change
++ ## the running order or otherwise move them around unless you know exactly
++ ## what you are doing...
++ _LT_SYS_HIDDEN_LIBDEPS($1)
++ _LT_COMPILER_PIC($1)
++ _LT_COMPILER_C_O($1)
++ _LT_COMPILER_FILE_LOCKS($1)
++ _LT_LINKER_SHLIBS($1)
++ _LT_SYS_DYNAMIC_LINKER($1)
++ _LT_LINKER_HARDCODE_LIBPATH($1)
++
++ _LT_CONFIG($1)
++ fi # test -n "$compiler"
++
++ GCC=$lt_save_GCC
++ CC="$lt_save_CC"
++fi # test "$_lt_disable_FC" != yes
+
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
++AC_LANG_POP
++])# _LT_LANG_FC_CONFIG
+
+- # hardcode_minus_L: Not really in the search PATH,
+- # but as the default location of the library.
+- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+- fi
+- ;;
+
+- hpux11*)
+- if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+- case $host_cpu in
+- hppa*64*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+- ;;
+- ia64*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+- ;;
+- *)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+- ;;
+- esac
+- else
+- case $host_cpu in
+- hppa*64*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+- ;;
+- ia64*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+- ;;
+- *)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+- ;;
+- esac
+- fi
+- if test "$with_gnu_ld" = no; then
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
++# _LT_LANG_GCJ_CONFIG([TAG])
++# --------------------------
++# Ensure that the configuration variables for the GNU Java Compiler compiler
++# are suitably defined. These variables are subsequently used by _LT_CONFIG
++# to write the compiler configuration to `libtool'.
++m4_defun([_LT_LANG_GCJ_CONFIG],
++[AC_REQUIRE([LT_PROG_GCJ])dnl
++AC_LANG_SAVE
+
+- case $host_cpu in
+- hppa*64*|ia64*)
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir'
+- _LT_AC_TAGVAR(hardcode_direct, $1)=no
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- ;;
+- *)
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
++# Source file extension for Java test sources.
++ac_ext=java
+
+- # hardcode_minus_L: Not really in the search PATH,
+- # but as the default location of the library.
+- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+- ;;
+- esac
+- fi
+- ;;
++# Object file extension for compiled Java test sources.
++objext=o
++_LT_TAGVAR(objext, $1)=$objext
+
+- irix5* | irix6* | nonstopux*)
+- if test "$GCC" = yes; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+- else
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir'
+- fi
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+- ;;
++# Code to be used in simple compile tests
++lt_simple_compile_test_code="class foo {}"
+
+- netbsd*)
+- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out
+- else
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF
+- fi
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- ;;
++# Code to be used in simple link tests
++lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }'
+
+- newsos6)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- ;;
++# ltmain only uses $CC for tagged configurations so make sure $CC is set.
++_LT_TAG_COMPILER
++
++# save warnings/boilerplate of simple test code
++_LT_COMPILER_BOILERPLATE
++_LT_LINKER_BOILERPLATE
++
++# Allow CC to be a program name with arguments.
++lt_save_CC="$CC"
++lt_save_GCC=$GCC
++GCC=yes
++CC=${GCJ-"gcj"}
++compiler=$CC
++_LT_TAGVAR(compiler, $1)=$CC
++_LT_TAGVAR(LD, $1)="$LD"
++_LT_CC_BASENAME([$compiler])
+
+- openbsd*)
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+- else
+- case $host_os in
+- openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+- ;;
+- *)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+- ;;
+- esac
+- fi
+- ;;
++# GCJ did not exist at the time GCC didn't implicitly link libc in.
++_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+
+- os2*)
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+- _LT_AC_TAGVAR(archive_cmds, $1)='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
+- _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
+- ;;
++_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+
+- osf3*)
+- if test "$GCC" = yes; then
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+- else
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+- fi
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+- ;;
++## CAVEAT EMPTOR:
++## There is no encapsulation within the following macros, do not change
++## the running order or otherwise move them around unless you know exactly
++## what you are doing...
++if test -n "$compiler"; then
++ _LT_COMPILER_NO_RTTI($1)
++ _LT_COMPILER_PIC($1)
++ _LT_COMPILER_C_O($1)
++ _LT_COMPILER_FILE_LOCKS($1)
++ _LT_LINKER_SHLIBS($1)
++ _LT_LINKER_HARDCODE_LIBPATH($1)
+
+- osf4* | osf5*) # as osf3* with the addition of -msym flag
+- if test "$GCC" = yes; then
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+- else
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~
+- $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp'
++ _LT_CONFIG($1)
++fi
+
+- # Both c and cxx compiler support -rpath directly
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
+- fi
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+- ;;
++AC_LANG_RESTORE
+
+- solaris*)
+- _LT_AC_TAGVAR(no_undefined_flag, $1)=' -z text'
+- if test "$GCC" = yes; then
+- wlarc='${wl}'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+- $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp'
+- else
+- wlarc=''
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+- $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
+- fi
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- case $host_os in
+- solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
+- *)
+- # The compiler driver will combine linker options so we
+- # cannot just pass the convience library names through
+- # without $wl, iff we do not link with $LD.
+- # Luckily, gcc supports the same syntax we need for Sun Studio.
+- # Supported since Solaris 2.6 (maybe 2.5.1?)
+- case $wlarc in
+- '')
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' ;;
+- *)
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;;
+- esac ;;
+- esac
+- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+- ;;
++GCC=$lt_save_GCC
++CC="$lt_save_CC"
++])# _LT_LANG_GCJ_CONFIG
+
+- sunos4*)
+- if test "x$host_vendor" = xsequent; then
+- # Use $CC to link under sequent, because it throws in some extra .o
+- # files that make .init and .fini sections work.
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+- else
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
+- fi
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- ;;
+
+- sysv4)
+- case $host_vendor in
+- sni)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes # is this really true???
+- ;;
+- siemens)
+- ## LD is ld it makes a PLAMLIB
+- ## CC just makes a GrossModule.
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+- _LT_AC_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs'
+- _LT_AC_TAGVAR(hardcode_direct, $1)=no
+- ;;
+- motorola)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+- _LT_AC_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie
+- ;;
+- esac
+- runpath_var='LD_RUN_PATH'
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- ;;
++# _LT_LANG_RC_CONFIG([TAG])
++# -------------------------
++# Ensure that the configuration variables for the Windows resource compiler
++# are suitably defined. These variables are subsequently used by _LT_CONFIG
++# to write the compiler configuration to `libtool'.
++m4_defun([_LT_LANG_RC_CONFIG],
++[AC_REQUIRE([LT_PROG_RC])dnl
++AC_LANG_SAVE
+
+- sysv4.3*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport'
+- ;;
++# Source file extension for RC test sources.
++ac_ext=rc
+
+- sysv4*MP*)
+- if test -d /usr/nec; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- runpath_var=LD_RUN_PATH
+- hardcode_runpath_var=yes
+- _LT_AC_TAGVAR(ld_shlibs, $1)=yes
+- fi
+- ;;
++# Object file extension for compiled RC test sources.
++objext=o
++_LT_TAGVAR(objext, $1)=$objext
+
+- sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7*)
+- _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- runpath_var='LD_RUN_PATH'
++# Code to be used in simple compile tests
++lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }'
+
+- if test "$GCC" = yes; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+- else
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+- fi
+- ;;
++# Code to be used in simple link tests
++lt_simple_link_test_code="$lt_simple_compile_test_code"
+
+- sysv5* | sco3.2v5* | sco5v6*)
+- # Note: We can NOT use -z defs as we might desire, because we do not
+- # link with -lc, and that would cause any symbols used from libc to
+- # always be unresolved, which means just about no library would
+- # ever link correctly. If we're not using GNU ld we use -z text
+- # though, which does catch some bad symbols but isn't as heavy-handed
+- # as -z defs.
+- _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
+- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':'
+- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
+- runpath_var='LD_RUN_PATH'
++# ltmain only uses $CC for tagged configurations so make sure $CC is set.
++_LT_TAG_COMPILER
+
+- if test "$GCC" = yes; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+- else
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+- fi
+- ;;
++# save warnings/boilerplate of simple test code
++_LT_COMPILER_BOILERPLATE
++_LT_LINKER_BOILERPLATE
+
+- uts4*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- ;;
++# Allow CC to be a program name with arguments.
++lt_save_CC="$CC"
++lt_save_GCC=$GCC
++GCC=
++CC=${RC-"windres"}
++compiler=$CC
++_LT_TAGVAR(compiler, $1)=$CC
++_LT_CC_BASENAME([$compiler])
++_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
+
+- *)
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- esac
+- fi
+-])
+-AC_MSG_RESULT([$_LT_AC_TAGVAR(ld_shlibs, $1)])
+-test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
++if test -n "$compiler"; then
++ :
++ _LT_CONFIG($1)
++fi
+
+-#
+-# Do we need to explicitly link libc?
+-#
+-case "x$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)" in
+-x|xyes)
+- # Assume -lc should be added
+- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
++GCC=$lt_save_GCC
++AC_LANG_RESTORE
++CC="$lt_save_CC"
++])# _LT_LANG_RC_CONFIG
+
+- if test "$enable_shared" = yes && test "$GCC" = yes; then
+- case $_LT_AC_TAGVAR(archive_cmds, $1) in
+- *'~'*)
+- # FIXME: we may have to deal with multi-command sequences.
+- ;;
+- '$CC '*)
+- # Test whether the compiler implicitly links with -lc since on some
+- # systems, -lgcc has to come before -lc. If gcc already passes -lc
+- # to ld, don't add -lc before -lgcc.
+- AC_MSG_CHECKING([whether -lc should be explicitly linked in])
+- $rm conftest*
+- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+- if AC_TRY_EVAL(ac_compile) 2>conftest.err; then
+- soname=conftest
+- lib=conftest
+- libobjs=conftest.$ac_objext
+- deplibs=
+- wl=$_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)
+- pic_flag=$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)
+- compiler_flags=-v
+- linker_flags=-v
+- verstring=
+- output_objdir=.
+- libname=conftest
+- lt_save_allow_undefined_flag=$_LT_AC_TAGVAR(allow_undefined_flag, $1)
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=
+- if AC_TRY_EVAL(_LT_AC_TAGVAR(archive_cmds, $1) 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1)
+- then
+- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+- else
+- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
+- fi
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag
+- else
+- cat conftest.err 1>&5
+- fi
+- $rm conftest*
+- AC_MSG_RESULT([$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)])
+- ;;
+- esac
+- fi
+- ;;
+-esac
+-])# AC_LIBTOOL_PROG_LD_SHLIBS
++# LT_PROG_GCJ
++# -----------
++AC_DEFUN([LT_PROG_GCJ],
++[m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ],
++ [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ],
++ [AC_CHECK_TOOL(GCJ, gcj,)
++ test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2"
++ AC_SUBST(GCJFLAGS)])])[]dnl
++])
+
++# Old name:
++AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ])
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([LT_AC_PROG_GCJ], [])
+
+-# _LT_AC_FILE_LTDLL_C
+-# -------------------
+-# Be careful that the start marker always follows a newline.
+-AC_DEFUN([_LT_AC_FILE_LTDLL_C], [
+-# /* ltdll.c starts here */
+-# #define WIN32_LEAN_AND_MEAN
+-# #include <windows.h>
+-# #undef WIN32_LEAN_AND_MEAN
+-# #include <stdio.h>
+-#
+-# #ifndef __CYGWIN__
+-# # ifdef __CYGWIN32__
+-# # define __CYGWIN__ __CYGWIN32__
+-# # endif
+-# #endif
+-#
+-# #ifdef __cplusplus
+-# extern "C" {
+-# #endif
+-# BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved);
+-# #ifdef __cplusplus
+-# }
+-# #endif
+-#
+-# #ifdef __CYGWIN__
+-# #include <cygwin/cygwin_dll.h>
+-# DECLARE_CYGWIN_DLL( DllMain );
+-# #endif
+-# HINSTANCE __hDllInstance_base;
+-#
+-# BOOL APIENTRY
+-# DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved)
+-# {
+-# __hDllInstance_base = hInst;
+-# return TRUE;
+-# }
+-# /* ltdll.c ends here */
+-])# _LT_AC_FILE_LTDLL_C
+
++# LT_PROG_RC
++# ----------
++AC_DEFUN([LT_PROG_RC],
++[AC_CHECK_TOOL(RC, windres,)
++])
+
+-# _LT_AC_TAGVAR(VARNAME, [TAGNAME])
+-# ---------------------------------
+-AC_DEFUN([_LT_AC_TAGVAR], [ifelse([$2], [], [$1], [$1_$2])])
++# Old name:
++AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC])
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([LT_AC_PROG_RC], [])
+
+
+-# old names
+-AC_DEFUN([AM_PROG_LIBTOOL], [AC_PROG_LIBTOOL])
+-AC_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)])
+-AC_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)])
+-AC_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)])
+-AC_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)])
+-AC_DEFUN([AM_PROG_LD], [AC_PROG_LD])
+-AC_DEFUN([AM_PROG_NM], [AC_PROG_NM])
+-
+-# This is just to silence aclocal about the macro not being used
+-ifelse([AC_DISABLE_FAST_INSTALL])
+-
+-AC_DEFUN([LT_AC_PROG_GCJ],
+-[AC_CHECK_TOOL(GCJ, gcj, no)
+- test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2"
+- AC_SUBST(GCJFLAGS)
++# _LT_DECL_EGREP
++# --------------
++# If we don't have a new enough Autoconf to choose the best grep
++# available, choose the one first in the user's PATH.
++m4_defun([_LT_DECL_EGREP],
++[AC_REQUIRE([AC_PROG_EGREP])dnl
++AC_REQUIRE([AC_PROG_FGREP])dnl
++test -z "$GREP" && GREP=grep
++_LT_DECL([], [GREP], [1], [A grep program that handles long lines])
++_LT_DECL([], [EGREP], [1], [An ERE matcher])
++_LT_DECL([], [FGREP], [1], [A literal string matcher])
++dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too
++AC_SUBST([GREP])
+ ])
+
+-AC_DEFUN([LT_AC_PROG_RC],
+-[AC_CHECK_TOOL(RC, windres, no)
+-])
+
++# _LT_DECL_SED
++# ------------
++# Check for a fully-functional sed program, that truncates
++# as few characters as possible. Prefer GNU sed if found.
++m4_defun([_LT_DECL_SED],
++[AC_PROG_SED
++test -z "$SED" && SED=sed
++Xsed="$SED -e 1s/^X//"
++_LT_DECL([], [SED], [1], [A sed program that does not truncate output])
++_LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"],
++ [Sed that helps us avoid accidentally triggering echo(1) options like -n])
++])# _LT_DECL_SED
++
++m4_ifndef([AC_PROG_SED], [
+ ############################################################
+ # NOTE: This macro has been submitted for inclusion into #
+ # GNU Autoconf as AC_PROG_SED. When it is available in #
+ # a released version of Autoconf we should remove this #
+ # macro and use it instead. #
+ ############################################################
+-# LT_AC_PROG_SED
+-# --------------
+-# Check for a fully-functional sed program, that truncates
+-# as few characters as possible. Prefer GNU sed if found.
+-AC_DEFUN([LT_AC_PROG_SED],
++
++m4_defun([AC_PROG_SED],
+ [AC_MSG_CHECKING([for a sed that does not truncate output])
+ AC_CACHE_VAL(lt_cv_path_SED,
+ [# Loop through the user's path and test for sed and gsed.
+@@ -6435,6 +7010,7 @@ do
+ done
+ done
+ done
++IFS=$as_save_IFS
+ lt_ac_max=0
+ lt_ac_count=0
+ # Add /usr/xpg4/bin/sed as it is typically found on Solaris
+@@ -6467,5 +7043,268 @@ for lt_ac_sed in $lt_ac_sed_list /usr/xp
+ done
+ ])
+ SED=$lt_cv_path_SED
++AC_SUBST([SED])
+ AC_MSG_RESULT([$SED])
++])#AC_PROG_SED
++])#m4_ifndef
++
++# Old name:
++AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED])
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([LT_AC_PROG_SED], [])
++
++
++# _LT_CHECK_SHELL_FEATURES
++# ------------------------
++# Find out whether the shell is Bourne or XSI compatible,
++# or has some other useful features.
++m4_defun([_LT_CHECK_SHELL_FEATURES],
++[AC_MSG_CHECKING([whether the shell understands some XSI constructs])
++# Try some XSI features
++xsi_shell=no
++( _lt_dummy="a/b/c"
++ test "${_lt_dummy##*/},${_lt_dummy%/*},"${_lt_dummy%"$_lt_dummy"}, \
++ = c,a/b,, \
++ && eval 'test $(( 1 + 1 )) -eq 2 \
++ && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \
++ && xsi_shell=yes
++AC_MSG_RESULT([$xsi_shell])
++_LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell'])
++
++AC_MSG_CHECKING([whether the shell understands "+="])
++lt_shell_append=no
++( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \
++ >/dev/null 2>&1 \
++ && lt_shell_append=yes
++AC_MSG_RESULT([$lt_shell_append])
++_LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append'])
++
++if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
++ lt_unset=unset
++else
++ lt_unset=false
++fi
++_LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl
++
++# test EBCDIC or ASCII
++case `echo X|tr X '\101'` in
++ A) # ASCII based system
++ # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
++ lt_SP2NL='tr \040 \012'
++ lt_NL2SP='tr \015\012 \040\040'
++ ;;
++ *) # EBCDIC based system
++ lt_SP2NL='tr \100 \n'
++ lt_NL2SP='tr \r\n \100\100'
++ ;;
++esac
++_LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl
++_LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl
++])# _LT_CHECK_SHELL_FEATURES
++
++
++# _LT_PROG_XSI_SHELLFNS
++# ---------------------
++# Bourne and XSI compatible variants of some useful shell functions.
++m4_defun([_LT_PROG_XSI_SHELLFNS],
++[case $xsi_shell in
++ yes)
++ cat << \_LT_EOF >> "$cfgfile"
++
++# func_dirname file append nondir_replacement
++# Compute the dirname of FILE. If nonempty, add APPEND to the result,
++# otherwise set result to NONDIR_REPLACEMENT.
++func_dirname ()
++{
++ case ${1} in
++ */*) func_dirname_result="${1%/*}${2}" ;;
++ * ) func_dirname_result="${3}" ;;
++ esac
++}
++
++# func_basename file
++func_basename ()
++{
++ func_basename_result="${1##*/}"
++}
++
++# func_dirname_and_basename file append nondir_replacement
++# perform func_basename and func_dirname in a single function
++# call:
++# dirname: Compute the dirname of FILE. If nonempty,
++# add APPEND to the result, otherwise set result
++# to NONDIR_REPLACEMENT.
++# value returned in "$func_dirname_result"
++# basename: Compute filename of FILE.
++# value retuned in "$func_basename_result"
++# Implementation must be kept synchronized with func_dirname
++# and func_basename. For efficiency, we do not delegate to
++# those functions but instead duplicate the functionality here.
++func_dirname_and_basename ()
++{
++ case ${1} in
++ */*) func_dirname_result="${1%/*}${2}" ;;
++ * ) func_dirname_result="${3}" ;;
++ esac
++ func_basename_result="${1##*/}"
++}
++
++# func_stripname prefix suffix name
++# strip PREFIX and SUFFIX off of NAME.
++# PREFIX and SUFFIX must not contain globbing or regex special
++# characters, hashes, percent signs, but SUFFIX may contain a leading
++# dot (in which case that matches only a dot).
++func_stripname ()
++{
++ # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
++ # positional parameters, so assign one to ordinary parameter first.
++ func_stripname_result=${3}
++ func_stripname_result=${func_stripname_result#"${1}"}
++ func_stripname_result=${func_stripname_result%"${2}"}
++}
++
++# func_opt_split
++func_opt_split ()
++{
++ func_opt_split_opt=${1%%=*}
++ func_opt_split_arg=${1#*=}
++}
++
++# func_lo2o object
++func_lo2o ()
++{
++ case ${1} in
++ *.lo) func_lo2o_result=${1%.lo}.${objext} ;;
++ *) func_lo2o_result=${1} ;;
++ esac
++}
++
++# func_xform libobj-or-source
++func_xform ()
++{
++ func_xform_result=${1%.*}.lo
++}
++
++# func_arith arithmetic-term...
++func_arith ()
++{
++ func_arith_result=$(( $[*] ))
++}
++
++# func_len string
++# STRING may not start with a hyphen.
++func_len ()
++{
++ func_len_result=${#1}
++}
++
++_LT_EOF
++ ;;
++ *) # Bourne compatible functions.
++ cat << \_LT_EOF >> "$cfgfile"
++
++# func_dirname file append nondir_replacement
++# Compute the dirname of FILE. If nonempty, add APPEND to the result,
++# otherwise set result to NONDIR_REPLACEMENT.
++func_dirname ()
++{
++ # Extract subdirectory from the argument.
++ func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"`
++ if test "X$func_dirname_result" = "X${1}"; then
++ func_dirname_result="${3}"
++ else
++ func_dirname_result="$func_dirname_result${2}"
++ fi
++}
++
++# func_basename file
++func_basename ()
++{
++ func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"`
++}
++
++dnl func_dirname_and_basename
++dnl A portable version of this function is already defined in general.m4sh
++dnl so there is no need for it here.
++
++# func_stripname prefix suffix name
++# strip PREFIX and SUFFIX off of NAME.
++# PREFIX and SUFFIX must not contain globbing or regex special
++# characters, hashes, percent signs, but SUFFIX may contain a leading
++# dot (in which case that matches only a dot).
++# func_strip_suffix prefix name
++func_stripname ()
++{
++ case ${2} in
++ .*) func_stripname_result=`$ECHO "X${3}" \
++ | $Xsed -e "s%^${1}%%" -e "s%\\\\${2}\$%%"`;;
++ *) func_stripname_result=`$ECHO "X${3}" \
++ | $Xsed -e "s%^${1}%%" -e "s%${2}\$%%"`;;
++ esac
++}
++
++# sed scripts:
++my_sed_long_opt='1s/^\(-[[^=]]*\)=.*/\1/;q'
++my_sed_long_arg='1s/^-[[^=]]*=//'
++
++# func_opt_split
++func_opt_split ()
++{
++ func_opt_split_opt=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_opt"`
++ func_opt_split_arg=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_arg"`
++}
++
++# func_lo2o object
++func_lo2o ()
++{
++ func_lo2o_result=`$ECHO "X${1}" | $Xsed -e "$lo2o"`
++}
++
++# func_xform libobj-or-source
++func_xform ()
++{
++ func_xform_result=`$ECHO "X${1}" | $Xsed -e 's/\.[[^.]]*$/.lo/'`
++}
++
++# func_arith arithmetic-term...
++func_arith ()
++{
++ func_arith_result=`expr "$[@]"`
++}
++
++# func_len string
++# STRING may not start with a hyphen.
++func_len ()
++{
++ func_len_result=`expr "$[1]" : ".*" 2>/dev/null || echo $max_cmd_len`
++}
++
++_LT_EOF
++esac
++
++case $lt_shell_append in
++ yes)
++ cat << \_LT_EOF >> "$cfgfile"
++
++# func_append var value
++# Append VALUE to the end of shell variable VAR.
++func_append ()
++{
++ eval "$[1]+=\$[2]"
++}
++_LT_EOF
++ ;;
++ *)
++ cat << \_LT_EOF >> "$cfgfile"
++
++# func_append var value
++# Append VALUE to the end of shell variable VAR.
++func_append ()
++{
++ eval "$[1]=\$$[1]\$[2]"
++}
++
++_LT_EOF
++ ;;
++ esac
+ ])
diff --git a/package/libs/libiconv-full/patches/.svn/text-base/103-configure_ac_fix.patch.svn-base b/package/libs/libiconv-full/patches/.svn/text-base/103-configure_ac_fix.patch.svn-base
new file mode 100644
index 0000000..d57ae84
--- /dev/null
+++ b/package/libs/libiconv-full/patches/.svn/text-base/103-configure_ac_fix.patch.svn-base
@@ -0,0 +1,31 @@
+--- /dev/null
++++ b/Makefile.am
+@@ -0,0 +1,2 @@
++ACLOCAL_AMFLAGS = -I m4
++SUBDIRS = .
+--- /dev/null
++++ b/libcharset/Makefile.am
+@@ -0,0 +1 @@
++ACLOCAL_AMFLAGS = -I m4
+--- a/configure.ac
++++ b/configure.ac
+@@ -54,7 +54,7 @@ AC_ISC_POSIX
+
+ dnl checks for installer options
+
+-AC_RELOCATABLE
++gl_RELOCATABLE
+
+ AC_ARG_ENABLE([extra-encodings],
+ [AC_HELP_STRING([--enable-extra-encodings],
+--- a/libcharset/configure.ac
++++ b/libcharset/configure.ac
+@@ -41,7 +41,7 @@ AC_CANONICAL_HOST
+
+ dnl checks for installer options
+
+-AC_RELOCATABLE_LIBRARY
++gl_RELOCATABLE_LIBRARY
+
+ dnl checks for programs
+
diff --git a/package/libs/libiconv-full/patches/.svn/text-base/200-work-with-libtool2.patch.svn-base b/package/libs/libiconv-full/patches/.svn/text-base/200-work-with-libtool2.patch.svn-base
new file mode 100644
index 0000000..6e31967
--- /dev/null
+++ b/package/libs/libiconv-full/patches/.svn/text-base/200-work-with-libtool2.patch.svn-base
@@ -0,0 +1,17 @@
+Make iconv 1.11.x link correctly with libtool2 - argument "-Xcompiler" ensures "-shared" is passed to $(CC) when used as linker. Otherwise $(CC) tries to create an executable and fails while looking for a main()-function
+
+diff -ruN libiconv-1.11.1/lib/Makefile.in libiconv-1.11.1.mod/lib/Makefile.in
+--- libiconv-1.11.1/lib/Makefile.in 2006-07-14 15:18:42.000000000 +0200
++++ libiconv-1.11.1.mod/lib/Makefile.in 2010-12-01 20:47:57.000000000 +0100
+@@ -70,9 +70,9 @@
+
+ preloadable_libiconv_linux.so : $(SOURCES)
+ if test -n "@GCC@"; then \
+- $(LIBTOOL_LINK) $(CC) $(LDFLAGS) $(INCLUDES) $(CFLAGS) $(CPPFLAGS) $(DEFS) -fPIC -DPIC -DLIBICONV_PLUG $(SOURCES) -shared -o preloadable_libiconv_linux.so; \
++ $(LIBTOOL_LINK) $(CC) $(LDFLAGS) $(INCLUDES) $(CFLAGS) $(CPPFLAGS) $(DEFS) -fPIC -DPIC -DLIBICONV_PLUG $(SOURCES) -Xcompiler -shared -o preloadable_libiconv_linux.so; \
+ else \
+- $(LIBTOOL_LINK) $(CC) $(LDFLAGS) $(INCLUDES) $(CFLAGS) $(CPPFLAGS) $(DEFS) -KPIC -DPIC -DLIBICONV_PLUG $(SOURCES) -shared -o preloadable_libiconv_linux.so; \
++ $(LIBTOOL_LINK) $(CC) $(LDFLAGS) $(INCLUDES) $(CFLAGS) $(CPPFLAGS) $(DEFS) -KPIC -DPIC -DLIBICONV_PLUG $(SOURCES) -Xcompiler -shared -o preloadable_libiconv_linux.so; \
+ fi
+
+ preloadable_libiconv_solaris.so : $(SOURCES)
diff --git a/package/libs/libiconv-full/patches/100-strip_charsets.patch b/package/libs/libiconv-full/patches/100-strip_charsets.patch
new file mode 100644
index 0000000..e4f49ae
--- /dev/null
+++ b/package/libs/libiconv-full/patches/100-strip_charsets.patch
@@ -0,0 +1,3438 @@
+--- a/lib/aliases_dos.h
++++ b/lib/aliases_dos.h
+@@ -2,47 +2,3 @@
+ S(dos_1, "IBM437", ei_cp437 )
+ S(dos_2, "437", ei_cp437 )
+ S(dos_3, "CSPC8CODEPAGE437", ei_cp437 )
+- S(dos_4, "CP737", ei_cp737 )
+- S(dos_5, "CP775", ei_cp775 )
+- S(dos_6, "IBM775", ei_cp775 )
+- S(dos_7, "CSPC775BALTIC", ei_cp775 )
+- S(dos_8, "CP852", ei_cp852 )
+- S(dos_9, "IBM852", ei_cp852 )
+- S(dos_10, "852", ei_cp852 )
+- S(dos_11, "CSPCP852", ei_cp852 )
+- S(dos_12, "CP853", ei_cp853 )
+- S(dos_13, "CP855", ei_cp855 )
+- S(dos_14, "IBM855", ei_cp855 )
+- S(dos_15, "855", ei_cp855 )
+- S(dos_16, "CSIBM855", ei_cp855 )
+- S(dos_17, "CP857", ei_cp857 )
+- S(dos_18, "IBM857", ei_cp857 )
+- S(dos_19, "857", ei_cp857 )
+- S(dos_20, "CSIBM857", ei_cp857 )
+- S(dos_21, "CP858", ei_cp858 )
+- S(dos_22, "CP860", ei_cp860 )
+- S(dos_23, "IBM860", ei_cp860 )
+- S(dos_24, "860", ei_cp860 )
+- S(dos_25, "CSIBM860", ei_cp860 )
+- S(dos_26, "CP861", ei_cp861 )
+- S(dos_27, "IBM861", ei_cp861 )
+- S(dos_28, "861", ei_cp861 )
+- S(dos_29, "CP-IS", ei_cp861 )
+- S(dos_30, "CSIBM861", ei_cp861 )
+- S(dos_31, "CP863", ei_cp863 )
+- S(dos_32, "IBM863", ei_cp863 )
+- S(dos_33, "863", ei_cp863 )
+- S(dos_34, "CSIBM863", ei_cp863 )
+- S(dos_35, "CP864", ei_cp864 )
+- S(dos_36, "IBM864", ei_cp864 )
+- S(dos_37, "CSIBM864", ei_cp864 )
+- S(dos_38, "CP865", ei_cp865 )
+- S(dos_39, "IBM865", ei_cp865 )
+- S(dos_40, "865", ei_cp865 )
+- S(dos_41, "CSIBM865", ei_cp865 )
+- S(dos_42, "CP869", ei_cp869 )
+- S(dos_43, "IBM869", ei_cp869 )
+- S(dos_44, "869", ei_cp869 )
+- S(dos_45, "CP-GR", ei_cp869 )
+- S(dos_46, "CSIBM869", ei_cp869 )
+- S(dos_47, "CP1125", ei_cp1125 )
+--- a/lib/aliases.gperf
++++ b/lib/aliases.gperf
+@@ -48,8 +48,6 @@ UCS-2-INTERNAL, ei_ucs2internal
+ UCS-2-SWAPPED, ei_ucs2swapped
+ UCS-4-INTERNAL, ei_ucs4internal
+ UCS-4-SWAPPED, ei_ucs4swapped
+-C99, ei_c99
+-JAVA, ei_java
+ ISO-8859-1, ei_iso8859_1
+ ISO_8859-1, ei_iso8859_1
+ ISO_8859-1:1987, ei_iso8859_1
+@@ -68,285 +66,16 @@ LATIN2, ei_iso8859_2
+ L2, ei_iso8859_2
+ CSISOLATIN2, ei_iso8859_2
+ ISO8859-2, ei_iso8859_2
+-ISO-8859-3, ei_iso8859_3
+-ISO_8859-3, ei_iso8859_3
+-ISO_8859-3:1988, ei_iso8859_3
+-ISO-IR-109, ei_iso8859_3
+-LATIN3, ei_iso8859_3
+-L3, ei_iso8859_3
+-CSISOLATIN3, ei_iso8859_3
+-ISO8859-3, ei_iso8859_3
+-ISO-8859-4, ei_iso8859_4
+-ISO_8859-4, ei_iso8859_4
+-ISO_8859-4:1988, ei_iso8859_4
+-ISO-IR-110, ei_iso8859_4
+-LATIN4, ei_iso8859_4
+-L4, ei_iso8859_4
+-CSISOLATIN4, ei_iso8859_4
+-ISO8859-4, ei_iso8859_4
+-ISO-8859-5, ei_iso8859_5
+-ISO_8859-5, ei_iso8859_5
+-ISO_8859-5:1988, ei_iso8859_5
+-ISO-IR-144, ei_iso8859_5
+-CYRILLIC, ei_iso8859_5
+-CSISOLATINCYRILLIC, ei_iso8859_5
+-ISO8859-5, ei_iso8859_5
+-ISO-8859-6, ei_iso8859_6
+-ISO_8859-6, ei_iso8859_6
+-ISO_8859-6:1987, ei_iso8859_6
+-ISO-IR-127, ei_iso8859_6
+-ECMA-114, ei_iso8859_6
+-ASMO-708, ei_iso8859_6
+-ARABIC, ei_iso8859_6
+-CSISOLATINARABIC, ei_iso8859_6
+-ISO8859-6, ei_iso8859_6
+-ISO-8859-7, ei_iso8859_7
+-ISO_8859-7, ei_iso8859_7
+-ISO_8859-7:1987, ei_iso8859_7
+-ISO_8859-7:2003, ei_iso8859_7
+-ISO-IR-126, ei_iso8859_7
+-ECMA-118, ei_iso8859_7
+-ELOT_928, ei_iso8859_7
+-GREEK8, ei_iso8859_7
+-GREEK, ei_iso8859_7
+-CSISOLATINGREEK, ei_iso8859_7
+-ISO8859-7, ei_iso8859_7
+-ISO-8859-8, ei_iso8859_8
+-ISO_8859-8, ei_iso8859_8
+-ISO_8859-8:1988, ei_iso8859_8
+-ISO-IR-138, ei_iso8859_8
+-HEBREW, ei_iso8859_8
+-CSISOLATINHEBREW, ei_iso8859_8
+-ISO8859-8, ei_iso8859_8
+-ISO-8859-9, ei_iso8859_9
+-ISO_8859-9, ei_iso8859_9
+-ISO_8859-9:1989, ei_iso8859_9
+-ISO-IR-148, ei_iso8859_9
+-LATIN5, ei_iso8859_9
+-L5, ei_iso8859_9
+-CSISOLATIN5, ei_iso8859_9
+-ISO8859-9, ei_iso8859_9
+-ISO-8859-10, ei_iso8859_10
+-ISO_8859-10, ei_iso8859_10
+-ISO_8859-10:1992, ei_iso8859_10
+-ISO-IR-157, ei_iso8859_10
+-LATIN6, ei_iso8859_10
+-L6, ei_iso8859_10
+-CSISOLATIN6, ei_iso8859_10
+-ISO8859-10, ei_iso8859_10
+-ISO-8859-11, ei_iso8859_11
+-ISO_8859-11, ei_iso8859_11
+-ISO8859-11, ei_iso8859_11
+-ISO-8859-13, ei_iso8859_13
+-ISO_8859-13, ei_iso8859_13
+-ISO-IR-179, ei_iso8859_13
+-LATIN7, ei_iso8859_13
+-L7, ei_iso8859_13
+-ISO8859-13, ei_iso8859_13
+-ISO-8859-14, ei_iso8859_14
+-ISO_8859-14, ei_iso8859_14
+-ISO_8859-14:1998, ei_iso8859_14
+-ISO-IR-199, ei_iso8859_14
+-LATIN8, ei_iso8859_14
+-L8, ei_iso8859_14
+-ISO-CELTIC, ei_iso8859_14
+-ISO8859-14, ei_iso8859_14
+ ISO-8859-15, ei_iso8859_15
+ ISO_8859-15, ei_iso8859_15
+ ISO_8859-15:1998, ei_iso8859_15
+ ISO-IR-203, ei_iso8859_15
+ LATIN-9, ei_iso8859_15
+ ISO8859-15, ei_iso8859_15
+-ISO-8859-16, ei_iso8859_16
+-ISO_8859-16, ei_iso8859_16
+-ISO_8859-16:2001, ei_iso8859_16
+-ISO-IR-226, ei_iso8859_16
+-LATIN10, ei_iso8859_16
+-L10, ei_iso8859_16
+-ISO8859-16, ei_iso8859_16
+ KOI8-R, ei_koi8_r
+ CSKOI8R, ei_koi8_r
+-KOI8-U, ei_koi8_u
+-KOI8-RU, ei_koi8_ru
+ CP1250, ei_cp1250
+ WINDOWS-1250, ei_cp1250
+ MS-EE, ei_cp1250
+-CP1251, ei_cp1251
+-WINDOWS-1251, ei_cp1251
+-MS-CYRL, ei_cp1251
+-CP1252, ei_cp1252
+-WINDOWS-1252, ei_cp1252
+-MS-ANSI, ei_cp1252
+-CP1253, ei_cp1253
+-WINDOWS-1253, ei_cp1253
+-MS-GREEK, ei_cp1253
+-CP1254, ei_cp1254
+-WINDOWS-1254, ei_cp1254
+-MS-TURK, ei_cp1254
+-CP1255, ei_cp1255
+-WINDOWS-1255, ei_cp1255
+-MS-HEBR, ei_cp1255
+-CP1256, ei_cp1256
+-WINDOWS-1256, ei_cp1256
+-MS-ARAB, ei_cp1256
+-CP1257, ei_cp1257
+-WINDOWS-1257, ei_cp1257
+-WINBALTRIM, ei_cp1257
+-CP1258, ei_cp1258
+-WINDOWS-1258, ei_cp1258
+-CP850, ei_cp850
+-IBM850, ei_cp850
+-850, ei_cp850
+-CSPC850MULTILINGUAL, ei_cp850
+-CP862, ei_cp862
+-IBM862, ei_cp862
+-862, ei_cp862
+-CSPC862LATINHEBREW, ei_cp862
+-CP866, ei_cp866
+-IBM866, ei_cp866
+-866, ei_cp866
+-CSIBM866, ei_cp866
+-MACROMAN, ei_mac_roman
+-MACINTOSH, ei_mac_roman
+-MAC, ei_mac_roman
+-CSMACINTOSH, ei_mac_roman
+-MACCENTRALEUROPE, ei_mac_centraleurope
+-MACICELAND, ei_mac_iceland
+-MACCROATIAN, ei_mac_croatian
+-MACROMANIA, ei_mac_romania
+-MACCYRILLIC, ei_mac_cyrillic
+-MACUKRAINE, ei_mac_ukraine
+-MACGREEK, ei_mac_greek
+-MACTURKISH, ei_mac_turkish
+-MACHEBREW, ei_mac_hebrew
+-MACARABIC, ei_mac_arabic
+-MACTHAI, ei_mac_thai
+-HP-ROMAN8, ei_hp_roman8
+-ROMAN8, ei_hp_roman8
+-R8, ei_hp_roman8
+-CSHPROMAN8, ei_hp_roman8
+-NEXTSTEP, ei_nextstep
+-ARMSCII-8, ei_armscii_8
+-GEORGIAN-ACADEMY, ei_georgian_academy
+-GEORGIAN-PS, ei_georgian_ps
+-KOI8-T, ei_koi8_t
+-PT154, ei_pt154
+-PTCP154, ei_pt154
+-CP154, ei_pt154
+-CYRILLIC-ASIAN, ei_pt154
+-CSPTCP154, ei_pt154
+-MULELAO-1, ei_mulelao
+-CP1133, ei_cp1133
+-IBM-CP1133, ei_cp1133
+-TIS-620, ei_tis620
+-TIS620, ei_tis620
+-TIS620-0, ei_tis620
+-TIS620.2529-1, ei_tis620
+-TIS620.2533-0, ei_tis620
+-TIS620.2533-1, ei_tis620
+-ISO-IR-166, ei_tis620
+-CP874, ei_cp874
+-WINDOWS-874, ei_cp874
+-VISCII, ei_viscii
+-VISCII1.1-1, ei_viscii
+-CSVISCII, ei_viscii
+-TCVN, ei_tcvn
+-TCVN-5712, ei_tcvn
+-TCVN5712-1, ei_tcvn
+-TCVN5712-1:1993, ei_tcvn
+-JIS_C6220-1969-RO, ei_iso646_jp
+-ISO646-JP, ei_iso646_jp
+-ISO-IR-14, ei_iso646_jp
+-JP, ei_iso646_jp
+-CSISO14JISC6220RO, ei_iso646_jp
+-JIS_X0201, ei_jisx0201
+-JISX0201-1976, ei_jisx0201
+-X0201, ei_jisx0201
+-CSHALFWIDTHKATAKANA, ei_jisx0201
+-JIS_X0208, ei_jisx0208
+-JIS_X0208-1983, ei_jisx0208
+-JIS_X0208-1990, ei_jisx0208
+-JIS0208, ei_jisx0208
+-X0208, ei_jisx0208
+-ISO-IR-87, ei_jisx0208
+-JIS_C6226-1983, ei_jisx0208
+-CSISO87JISX0208, ei_jisx0208
+-JIS_X0212, ei_jisx0212
+-JIS_X0212.1990-0, ei_jisx0212
+-JIS_X0212-1990, ei_jisx0212
+-X0212, ei_jisx0212
+-ISO-IR-159, ei_jisx0212
+-CSISO159JISX02121990, ei_jisx0212
+-GB_1988-80, ei_iso646_cn
+-ISO646-CN, ei_iso646_cn
+-ISO-IR-57, ei_iso646_cn
+-CN, ei_iso646_cn
+-CSISO57GB1988, ei_iso646_cn
+-GB_2312-80, ei_gb2312
+-ISO-IR-58, ei_gb2312
+-CSISO58GB231280, ei_gb2312
+-CHINESE, ei_gb2312
+-ISO-IR-165, ei_isoir165
+-CN-GB-ISOIR165, ei_isoir165
+-KSC_5601, ei_ksc5601
+-KS_C_5601-1987, ei_ksc5601
+-KS_C_5601-1989, ei_ksc5601
+-ISO-IR-149, ei_ksc5601
+-CSKSC56011987, ei_ksc5601
+-KOREAN, ei_ksc5601
+-EUC-JP, ei_euc_jp
+-EUCJP, ei_euc_jp
+-EXTENDED_UNIX_CODE_PACKED_FORMAT_FOR_JAPANESE, ei_euc_jp
+-CSEUCPKDFMTJAPANESE, ei_euc_jp
+-SHIFT_JIS, ei_sjis
+-SHIFT-JIS, ei_sjis
+-SJIS, ei_sjis
+-MS_KANJI, ei_sjis
+-CSSHIFTJIS, ei_sjis
+-CP932, ei_cp932
+-ISO-2022-JP, ei_iso2022_jp
+-CSISO2022JP, ei_iso2022_jp
+-ISO-2022-JP-1, ei_iso2022_jp1
+-ISO-2022-JP-2, ei_iso2022_jp2
+-CSISO2022JP2, ei_iso2022_jp2
+-EUC-CN, ei_euc_cn
+-EUCCN, ei_euc_cn
+-GB2312, ei_euc_cn
+-CN-GB, ei_euc_cn
+-CSGB2312, ei_euc_cn
+-GBK, ei_ces_gbk
+-CP936, ei_cp936
+-MS936, ei_cp936
+-WINDOWS-936, ei_cp936
+-GB18030, ei_gb18030
+-ISO-2022-CN, ei_iso2022_cn
+-CSISO2022CN, ei_iso2022_cn
+-ISO-2022-CN-EXT, ei_iso2022_cn_ext
+-HZ, ei_hz
+-HZ-GB-2312, ei_hz
+-EUC-TW, ei_euc_tw
+-EUCTW, ei_euc_tw
+-CSEUCTW, ei_euc_tw
+-BIG5, ei_ces_big5
+-BIG-5, ei_ces_big5
+-BIG-FIVE, ei_ces_big5
+-BIGFIVE, ei_ces_big5
+-CN-BIG5, ei_ces_big5
+-CSBIG5, ei_ces_big5
+-CP950, ei_cp950
+-BIG5-HKSCS:1999, ei_big5hkscs1999
+-BIG5-HKSCS:2001, ei_big5hkscs2001
+-BIG5-HKSCS, ei_big5hkscs2004
+-BIG5HKSCS, ei_big5hkscs2004
+-BIG5-HKSCS:2004, ei_big5hkscs2004
+-EUC-KR, ei_euc_kr
+-EUCKR, ei_euc_kr
+-CSEUCKR, ei_euc_kr
+-CP949, ei_cp949
+-UHC, ei_cp949
+-JOHAB, ei_johab
+-CP1361, ei_johab
+-ISO-2022-KR, ei_iso2022_kr
+-CSISO2022KR, ei_iso2022_kr
+ CHAR, ei_local_char
+ WCHAR_T, ei_local_wchar_t
+--- a/lib/aliases.h
++++ b/lib/aliases.h
+@@ -1,6 +1,6 @@
+ /* ANSI-C code produced by gperf version 3.0.2 */
+ /* Command-line: gperf -m 10 lib/aliases.gperf */
+-/* Computed positions: -k'1,3-11,$' */
++/* Computed positions: -k'4-7,10,$' */
+
+ #if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
+ && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
+@@ -32,12 +32,12 @@
+ #line 1 "lib/aliases.gperf"
+ struct alias { int name; unsigned int encoding_index; };
+
+-#define TOTAL_KEYWORDS 341
++#define TOTAL_KEYWORDS 70
+ #define MIN_WORD_LENGTH 2
+-#define MAX_WORD_LENGTH 45
+-#define MIN_HASH_VALUE 13
+-#define MAX_HASH_VALUE 997
+-/* maximum key range = 985, duplicates = 0 */
++#define MAX_WORD_LENGTH 17
++#define MIN_HASH_VALUE 4
++#define MAX_HASH_VALUE 98
++/* maximum key range = 95, duplicates = 0 */
+
+ #ifdef __GNUC__
+ __inline
+@@ -49,38 +49,31 @@ inline
+ static unsigned int
+ aliases_hash (register const char *str, register unsigned int len)
+ {
+- static const unsigned short asso_values[] =
++ static const unsigned char asso_values[] =
+ {
+- 998, 998, 998, 998, 998, 998, 998, 998, 998, 998,
+- 998, 998, 998, 998, 998, 998, 998, 998, 998, 998,
+- 998, 998, 998, 998, 998, 998, 998, 998, 998, 998,
+- 998, 998, 998, 998, 998, 998, 998, 998, 998, 998,
+- 998, 998, 998, 998, 998, 4, 199, 998, 79, 6,
+- 29, 65, 13, 15, 4, 88, 20, 22, 386, 998,
+- 998, 998, 998, 998, 998, 47, 188, 110, 6, 26,
+- 63, 19, 12, 5, 281, 202, 7, 166, 11, 5,
+- 64, 998, 4, 11, 20, 185, 110, 152, 163, 4,
+- 4, 998, 998, 998, 998, 5, 998, 998, 998, 998,
+- 998, 998, 998, 998, 998, 998, 998, 998, 998, 998,
+- 998, 998, 998, 998, 998, 998, 998, 998, 998, 998,
+- 998, 998, 998, 998, 998, 998, 998, 998
++ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99,
++ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99,
++ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99,
++ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99,
++ 99, 99, 99, 99, 99, 6, 99, 99, 22, 3,
++ 2, 2, 17, 3, 2, 7, 3, 2, 99, 99,
++ 99, 99, 99, 99, 99, 4, 53, 2, 21, 2,
++ 99, 7, 99, 15, 99, 99, 19, 99, 33, 2,
++ 4, 99, 11, 26, 17, 99, 99, 3, 26, 99,
++ 99, 99, 99, 99, 99, 10, 99, 99, 99, 99,
++ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99,
++ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99,
++ 99, 99, 99, 99, 99, 99, 99, 99
+ };
+ register int hval = len;
+
+ switch (hval)
+ {
+ default:
+- hval += asso_values[(unsigned char)str[10]];
+- /*FALLTHROUGH*/
+- case 10:
+ hval += asso_values[(unsigned char)str[9]];
+ /*FALLTHROUGH*/
+ case 9:
+- hval += asso_values[(unsigned char)str[8]];
+- /*FALLTHROUGH*/
+ case 8:
+- hval += asso_values[(unsigned char)str[7]];
+- /*FALLTHROUGH*/
+ case 7:
+ hval += asso_values[(unsigned char)str[6]];
+ /*FALLTHROUGH*/
+@@ -94,11 +87,7 @@ aliases_hash (register const char *str,
+ hval += asso_values[(unsigned char)str[3]];
+ /*FALLTHROUGH*/
+ case 3:
+- hval += asso_values[(unsigned char)str[2]];
+- /*FALLTHROUGH*/
+ case 2:
+- case 1:
+- hval += asso_values[(unsigned char)str[0]];
+ break;
+ }
+ return hval + asso_values[(unsigned char)str[len - 1]];
+@@ -106,1576 +95,306 @@ aliases_hash (register const char *str,
+
+ struct stringpool_t
+ {
+- char stringpool_str13[sizeof("L6")];
+- char stringpool_str15[sizeof("L1")];
+- char stringpool_str18[sizeof("HZ")];
+- char stringpool_str22[sizeof("L4")];
+- char stringpool_str24[sizeof("L5")];
+- char stringpool_str26[sizeof("R8")];
+- char stringpool_str29[sizeof("L8")];
+- char stringpool_str31[sizeof("866")];
+- char stringpool_str38[sizeof("L2")];
+- char stringpool_str42[sizeof("SJIS")];
+- char stringpool_str43[sizeof("ISO-IR-6")];
+- char stringpool_str55[sizeof("ISO-IR-166")];
+- char stringpool_str57[sizeof("LATIN6")];
+- char stringpool_str61[sizeof("LATIN1")];
+- char stringpool_str68[sizeof("ISO-IR-14")];
+- char stringpool_str74[sizeof("L3")];
+- char stringpool_str75[sizeof("LATIN4")];
+- char stringpool_str77[sizeof("ISO-IR-165")];
+- char stringpool_str79[sizeof("LATIN5")];
+- char stringpool_str80[sizeof("ISO-IR-126")];
+- char stringpool_str81[sizeof("862")];
+- char stringpool_str82[sizeof("ISO-IR-144")];
+- char stringpool_str89[sizeof("LATIN8")];
+- char stringpool_str91[sizeof("ISO-IR-58")];
+- char stringpool_str96[sizeof("ISO-IR-148")];
+- char stringpool_str97[sizeof("L7")];
+- char stringpool_str98[sizeof("LATIN-9")];
+- char stringpool_str100[sizeof("ISO-IR-149")];
+- char stringpool_str102[sizeof("ISO-IR-159")];
+- char stringpool_str103[sizeof("ISO-IR-226")];
+- char stringpool_str107[sizeof("LATIN2")];
+- char stringpool_str108[sizeof("ISO8859-6")];
+- char stringpool_str109[sizeof("ISO-IR-199")];
+- char stringpool_str112[sizeof("ISO8859-1")];
+- char stringpool_str113[sizeof("ISO-8859-6")];
+- char stringpool_str114[sizeof("ISO_8859-6")];
+- char stringpool_str115[sizeof("ISO8859-16")];
+- char stringpool_str116[sizeof("PT154")];
+- char stringpool_str117[sizeof("ISO-8859-1")];
+- char stringpool_str118[sizeof("ISO_8859-1")];
+- char stringpool_str119[sizeof("ISO8859-11")];
+- char stringpool_str120[sizeof("ISO-8859-16")];
+- char stringpool_str121[sizeof("ISO_8859-16")];
+- char stringpool_str123[sizeof("CN")];
+- char stringpool_str124[sizeof("ISO-8859-11")];
+- char stringpool_str125[sizeof("ISO_8859-11")];
+- char stringpool_str126[sizeof("ISO8859-4")];
+- char stringpool_str128[sizeof("ISO_8859-16:2001")];
+- char stringpool_str130[sizeof("ISO8859-5")];
+- char stringpool_str131[sizeof("ISO-8859-4")];
+- char stringpool_str132[sizeof("ISO_8859-4")];
+- char stringpool_str133[sizeof("ISO8859-14")];
+- char stringpool_str134[sizeof("ISO-IR-101")];
+- char stringpool_str135[sizeof("ISO-8859-5")];
+- char stringpool_str136[sizeof("ISO_8859-5")];
+- char stringpool_str137[sizeof("ISO8859-15")];
+- char stringpool_str138[sizeof("ISO-8859-14")];
+- char stringpool_str139[sizeof("ISO_8859-14")];
+- char stringpool_str140[sizeof("ISO8859-8")];
+- char stringpool_str142[sizeof("ISO-8859-15")];
+- char stringpool_str143[sizeof("ISO_8859-15")];
+- char stringpool_str144[sizeof("ISO8859-9")];
+- char stringpool_str145[sizeof("ISO-8859-8")];
+- char stringpool_str146[sizeof("ISO_8859-8")];
+- char stringpool_str147[sizeof("CP866")];
+- char stringpool_str148[sizeof("ISO-IR-138")];
+- char stringpool_str149[sizeof("ISO-8859-9")];
+- char stringpool_str150[sizeof("ISO_8859-9")];
+- char stringpool_str151[sizeof("ISO_8859-14:1998")];
+- char stringpool_str153[sizeof("ISO_8859-15:1998")];
+- char stringpool_str155[sizeof("ELOT_928")];
+- char stringpool_str156[sizeof("TCVN")];
+- char stringpool_str157[sizeof("C99")];
+- char stringpool_str158[sizeof("ISO8859-2")];
+- char stringpool_str162[sizeof("CP154")];
+- char stringpool_str163[sizeof("ISO-8859-2")];
+- char stringpool_str164[sizeof("ISO_8859-2")];
+- char stringpool_str166[sizeof("ISO-IR-109")];
+- char stringpool_str168[sizeof("L10")];
+- char stringpool_str169[sizeof("CHAR")];
+- char stringpool_str174[sizeof("CP1256")];
+- char stringpool_str175[sizeof("ISO-IR-179")];
+- char stringpool_str176[sizeof("ISO646-CN")];
+- char stringpool_str177[sizeof("ASCII")];
+- char stringpool_str178[sizeof("CP1251")];
+- char stringpool_str179[sizeof("LATIN3")];
+- char stringpool_str181[sizeof("850")];
+- char stringpool_str183[sizeof("GB2312")];
+- char stringpool_str185[sizeof("CP819")];
+- char stringpool_str192[sizeof("CP1254")];
+- char stringpool_str194[sizeof("CP949")];
+- char stringpool_str196[sizeof("CP1255")];
+- char stringpool_str197[sizeof("CP862")];
+- char stringpool_str198[sizeof("US")];
+- char stringpool_str203[sizeof("CP1361")];
+- char stringpool_str206[sizeof("CP1258")];
+- char stringpool_str207[sizeof("ISO-IR-110")];
+- char stringpool_str209[sizeof("IBM866")];
+- char stringpool_str210[sizeof("CP936")];
+- char stringpool_str211[sizeof("GEORGIAN-PS")];
+- char stringpool_str214[sizeof("LATIN10")];
+- char stringpool_str222[sizeof("CHINESE")];
+- char stringpool_str224[sizeof("CP1252")];
+- char stringpool_str225[sizeof("LATIN7")];
+- char stringpool_str226[sizeof("ISO_8859-10:1992")];
+- char stringpool_str227[sizeof("ISO-IR-57")];
+- char stringpool_str228[sizeof("TIS620")];
+- char stringpool_str230[sizeof("ISO8859-3")];
+- char stringpool_str231[sizeof("UCS-4")];
+- char stringpool_str232[sizeof("ISO-IR-87")];
+- char stringpool_str233[sizeof("TIS-620")];
+- char stringpool_str234[sizeof("ISO-IR-157")];
+- char stringpool_str235[sizeof("ISO-8859-3")];
+- char stringpool_str236[sizeof("ISO_8859-3")];
+- char stringpool_str237[sizeof("ISO8859-13")];
+- char stringpool_str240[sizeof("CSISOLATIN6")];
+- char stringpool_str241[sizeof("BIG5")];
+- char stringpool_str242[sizeof("ISO-8859-13")];
+- char stringpool_str243[sizeof("ISO_8859-13")];
+- char stringpool_str244[sizeof("CSISOLATIN1")];
+- char stringpool_str245[sizeof("KOI8-R")];
+- char stringpool_str246[sizeof("BIG-5")];
+- char stringpool_str247[sizeof("IBM819")];
+- char stringpool_str248[sizeof("ISO-IR-127")];
+- char stringpool_str249[sizeof("CP874")];
+- char stringpool_str251[sizeof("ISO646-US")];
+- char stringpool_str252[sizeof("VISCII")];
+- char stringpool_str253[sizeof("MS-EE")];
+- char stringpool_str256[sizeof("MS-ANSI")];
+- char stringpool_str258[sizeof("CSISOLATIN4")];
+- char stringpool_str259[sizeof("IBM862")];
+- char stringpool_str260[sizeof("CP932")];
+- char stringpool_str261[sizeof("X0212")];
+- char stringpool_str262[sizeof("CSISOLATIN5")];
+- char stringpool_str263[sizeof("UCS-2")];
+- char stringpool_str265[sizeof("ISO8859-10")];
+- char stringpool_str266[sizeof("MS936")];
+- char stringpool_str267[sizeof("WCHAR_T")];
+- char stringpool_str270[sizeof("ISO-8859-10")];
+- char stringpool_str271[sizeof("ISO_8859-10")];
+- char stringpool_str272[sizeof("UTF-16")];
+- char stringpool_str273[sizeof("EUCCN")];
+- char stringpool_str274[sizeof("ROMAN8")];
+- char stringpool_str275[sizeof("ISO-IR-203")];
+- char stringpool_str276[sizeof("ISO8859-7")];
+- char stringpool_str277[sizeof("KOI8-T")];
+- char stringpool_str278[sizeof("EUC-CN")];
+- char stringpool_str279[sizeof("UCS-4LE")];
+- char stringpool_str280[sizeof("ISO-IR-100")];
+- char stringpool_str281[sizeof("ISO-8859-7")];
+- char stringpool_str282[sizeof("ISO_8859-7")];
+- char stringpool_str283[sizeof("MULELAO-1")];
+- char stringpool_str284[sizeof("GB_1988-80")];
+- char stringpool_str288[sizeof("X0201")];
+- char stringpool_str289[sizeof("ECMA-114")];
+- char stringpool_str290[sizeof("CSISOLATIN2")];
+- char stringpool_str291[sizeof("GEORGIAN-ACADEMY")];
+- char stringpool_str292[sizeof("PTCP154")];
+- char stringpool_str295[sizeof("UCS-2LE")];
+- char stringpool_str296[sizeof("CP1253")];
+- char stringpool_str297[sizeof("UTF-8")];
+- char stringpool_str298[sizeof("HP-ROMAN8")];
+- char stringpool_str300[sizeof("CSASCII")];
+- char stringpool_str303[sizeof("ECMA-118")];
+- char stringpool_str304[sizeof("UCS-4-INTERNAL")];
+- char stringpool_str305[sizeof("TCVN5712-1")];
+- char stringpool_str307[sizeof("KOREAN")];
+- char stringpool_str308[sizeof("CP850")];
+- char stringpool_str309[sizeof("MS-CYRL")];
+- char stringpool_str310[sizeof("CP950")];
+- char stringpool_str313[sizeof("TIS620-0")];
+- char stringpool_str316[sizeof("X0208")];
+- char stringpool_str319[sizeof("GREEK8")];
+- char stringpool_str320[sizeof("UCS-2-INTERNAL")];
+- char stringpool_str321[sizeof("TCVN-5712")];
+- char stringpool_str323[sizeof("CP1133")];
+- char stringpool_str324[sizeof("CP1250")];
+- char stringpool_str327[sizeof("ISO-2022-CN")];
+- char stringpool_str329[sizeof("UTF-16LE")];
+- char stringpool_str335[sizeof("CYRILLIC-ASIAN")];
+- char stringpool_str337[sizeof("ISO-10646-UCS-4")];
+- char stringpool_str340[sizeof("ISO-2022-CN-EXT")];
+- char stringpool_str342[sizeof("CP1257")];
+- char stringpool_str345[sizeof("GB_2312-80")];
+- char stringpool_str347[sizeof("JP")];
+- char stringpool_str351[sizeof("EUCKR")];
+- char stringpool_str353[sizeof("ISO-10646-UCS-2")];
+- char stringpool_str354[sizeof("GB18030")];
+- char stringpool_str356[sizeof("EUC-KR")];
+- char stringpool_str357[sizeof("CSKOI8R")];
+- char stringpool_str358[sizeof("CSBIG5")];
+- char stringpool_str360[sizeof("CP367")];
+- char stringpool_str361[sizeof("MACINTOSH")];
+- char stringpool_str362[sizeof("CSISOLATIN3")];
+- char stringpool_str363[sizeof("CN-BIG5")];
+- char stringpool_str366[sizeof("CYRILLIC")];
+- char stringpool_str369[sizeof("CSVISCII")];
+- char stringpool_str370[sizeof("IBM850")];
+- char stringpool_str372[sizeof("MACTHAI")];
+- char stringpool_str374[sizeof("UNICODE-1-1")];
+- char stringpool_str376[sizeof("ISO_646.IRV:1991")];
+- char stringpool_str380[sizeof("US-ASCII")];
+- char stringpool_str381[sizeof("UTF-32")];
+- char stringpool_str384[sizeof("CN-GB-ISOIR165")];
+- char stringpool_str387[sizeof("NEXTSTEP")];
+- char stringpool_str389[sizeof("MAC")];
+- char stringpool_str393[sizeof("EXTENDED_UNIX_CODE_PACKED_FORMAT_FOR_JAPANESE")];
+- char stringpool_str394[sizeof("CSISOLATINARABIC")];
+- char stringpool_str395[sizeof("HZ-GB-2312")];
+- char stringpool_str397[sizeof("ARMSCII-8")];
+- char stringpool_str401[sizeof("CSISOLATINHEBREW")];
+- char stringpool_str405[sizeof("ISO-2022-KR")];
+- char stringpool_str407[sizeof("WINDOWS-1256")];
+- char stringpool_str408[sizeof("UHC")];
+- char stringpool_str409[sizeof("WINDOWS-1251")];
+- char stringpool_str411[sizeof("MS-HEBR")];
+- char stringpool_str412[sizeof("ISO-CELTIC")];
+- char stringpool_str413[sizeof("UTF-32LE")];
+- char stringpool_str416[sizeof("WINDOWS-1254")];
+- char stringpool_str418[sizeof("WINDOWS-1255")];
+- char stringpool_str420[sizeof("SHIFT-JIS")];
+- char stringpool_str421[sizeof("SHIFT_JIS")];
+- char stringpool_str422[sizeof("IBM367")];
+- char stringpool_str423[sizeof("WINDOWS-1258")];
+- char stringpool_str424[sizeof("CSPTCP154")];
+- char stringpool_str426[sizeof("GBK")];
+- char stringpool_str428[sizeof("UNICODELITTLE")];
+- char stringpool_str432[sizeof("WINDOWS-1252")];
+- char stringpool_str433[sizeof("UTF-7")];
+- char stringpool_str435[sizeof("KSC_5601")];
+- char stringpool_str437[sizeof("ASMO-708")];
+- char stringpool_str440[sizeof("CSISO2022CN")];
+- char stringpool_str444[sizeof("BIGFIVE")];
+- char stringpool_str447[sizeof("WINDOWS-936")];
+- char stringpool_str448[sizeof("CSUCS4")];
+- char stringpool_str449[sizeof("BIG-FIVE")];
+- char stringpool_str453[sizeof("ISO646-JP")];
+- char stringpool_str456[sizeof("TIS620.2529-1")];
+- char stringpool_str457[sizeof("CSISOLATINGREEK")];
+- char stringpool_str459[sizeof("CSISOLATINCYRILLIC")];
+- char stringpool_str460[sizeof("UCS-4BE")];
+- char stringpool_str462[sizeof("UNICODE-1-1-UTF-7")];
+- char stringpool_str465[sizeof("EUCTW")];
+- char stringpool_str468[sizeof("WINDOWS-1253")];
+- char stringpool_str469[sizeof("CSHPROMAN8")];
+- char stringpool_str470[sizeof("EUC-TW")];
+- char stringpool_str472[sizeof("KS_C_5601-1989")];
+- char stringpool_str476[sizeof("UCS-2BE")];
+- char stringpool_str479[sizeof("VISCII1.1-1")];
+- char stringpool_str480[sizeof("GREEK")];
+- char stringpool_str482[sizeof("WINDOWS-1250")];
+- char stringpool_str483[sizeof("CSGB2312")];
+- char stringpool_str486[sizeof("WINDOWS-874")];
+- char stringpool_str487[sizeof("CSUNICODE11")];
+- char stringpool_str489[sizeof("JAVA")];
+- char stringpool_str491[sizeof("WINDOWS-1257")];
+- char stringpool_str493[sizeof("CSUNICODE")];
+- char stringpool_str500[sizeof("CSHALFWIDTHKATAKANA")];
+- char stringpool_str502[sizeof("CSISO57GB1988")];
+- char stringpool_str504[sizeof("MACICELAND")];
+- char stringpool_str509[sizeof("CSIBM866")];
+- char stringpool_str510[sizeof("UTF-16BE")];
+- char stringpool_str513[sizeof("ARABIC")];
+- char stringpool_str514[sizeof("CN-GB")];
+- char stringpool_str518[sizeof("CSISO2022KR")];
+- char stringpool_str520[sizeof("CSMACINTOSH")];
+- char stringpool_str526[sizeof("JIS0208")];
+- char stringpool_str528[sizeof("MACROMAN")];
+- char stringpool_str530[sizeof("ISO_8859-4:1988")];
+- char stringpool_str532[sizeof("ISO_8859-5:1988")];
+- char stringpool_str535[sizeof("TIS620.2533-1")];
+- char stringpool_str536[sizeof("ANSI_X3.4-1986")];
+- char stringpool_str537[sizeof("ISO_8859-8:1988")];
+- char stringpool_str538[sizeof("KS_C_5601-1987")];
+- char stringpool_str539[sizeof("CSSHIFTJIS")];
+- char stringpool_str540[sizeof("HEBREW")];
+- char stringpool_str541[sizeof("ISO_8859-9:1989")];
+- char stringpool_str547[sizeof("MACCROATIAN")];
+- char stringpool_str548[sizeof("ISO-2022-JP-1")];
+- char stringpool_str550[sizeof("EUCJP")];
+- char stringpool_str552[sizeof("ANSI_X3.4-1968")];
+- char stringpool_str555[sizeof("EUC-JP")];
+- char stringpool_str561[sizeof("CSISO58GB231280")];
+- char stringpool_str562[sizeof("JIS_C6226-1983")];
+- char stringpool_str566[sizeof("IBM-CP1133")];
+- char stringpool_str569[sizeof("MACCENTRALEUROPE")];
+- char stringpool_str570[sizeof("CSISO159JISX02121990")];
+- char stringpool_str571[sizeof("ISO-2022-JP-2")];
+- char stringpool_str573[sizeof("CSUNICODE11UTF7")];
+- char stringpool_str574[sizeof("UCS-4-SWAPPED")];
+- char stringpool_str578[sizeof("UNICODEBIG")];
+- char stringpool_str579[sizeof("CSISO14JISC6220RO")];
+- char stringpool_str580[sizeof("JIS_C6220-1969-RO")];
+- char stringpool_str582[sizeof("ISO_8859-3:1988")];
+- char stringpool_str586[sizeof("CSPC862LATINHEBREW")];
+- char stringpool_str588[sizeof("BIG5HKSCS")];
+- char stringpool_str589[sizeof("ISO_8859-6:1987")];
+- char stringpool_str590[sizeof("UCS-2-SWAPPED")];
+- char stringpool_str591[sizeof("ISO_8859-1:1987")];
+- char stringpool_str593[sizeof("BIG5-HKSCS")];
+- char stringpool_str594[sizeof("UTF-32BE")];
+- char stringpool_str604[sizeof("ISO-2022-JP")];
+- char stringpool_str607[sizeof("KOI8-U")];
+- char stringpool_str608[sizeof("TIS620.2533-0")];
+- char stringpool_str612[sizeof("KOI8-RU")];
+- char stringpool_str614[sizeof("ISO_8859-2:1987")];
+- char stringpool_str618[sizeof("MACROMANIA")];
+- char stringpool_str641[sizeof("JIS_X0212")];
+- char stringpool_str648[sizeof("CSEUCKR")];
+- char stringpool_str649[sizeof("MACCYRILLIC")];
+- char stringpool_str650[sizeof("ISO_8859-7:2003")];
+- char stringpool_str651[sizeof("MS-ARAB")];
+- char stringpool_str657[sizeof("MS-GREEK")];
+- char stringpool_str666[sizeof("CSKSC56011987")];
+- char stringpool_str668[sizeof("JIS_X0201")];
+- char stringpool_str673[sizeof("ISO_8859-7:1987")];
+- char stringpool_str683[sizeof("CSISO2022JP2")];
+- char stringpool_str696[sizeof("JIS_X0208")];
+- char stringpool_str697[sizeof("JISX0201-1976")];
+- char stringpool_str706[sizeof("JIS_X0212-1990")];
+- char stringpool_str717[sizeof("CSISO2022JP")];
+- char stringpool_str721[sizeof("JOHAB")];
+- char stringpool_str730[sizeof("MS_KANJI")];
+- char stringpool_str734[sizeof("CSISO87JISX0208")];
+- char stringpool_str737[sizeof("MACTURKISH")];
+- char stringpool_str755[sizeof("TCVN5712-1:1993")];
+- char stringpool_str756[sizeof("JIS_X0208-1983")];
+- char stringpool_str762[sizeof("CSEUCTW")];
+- char stringpool_str763[sizeof("MACGREEK")];
+- char stringpool_str770[sizeof("JIS_X0208-1990")];
+- char stringpool_str776[sizeof("WINBALTRIM")];
+- char stringpool_str790[sizeof("MS-TURK")];
+- char stringpool_str792[sizeof("MACUKRAINE")];
+- char stringpool_str796[sizeof("MACARABIC")];
+- char stringpool_str802[sizeof("CSPC850MULTILINGUAL")];
+- char stringpool_str845[sizeof("MACHEBREW")];
+- char stringpool_str903[sizeof("JIS_X0212.1990-0")];
+- char stringpool_str979[sizeof("BIG5-HKSCS:2001")];
+- char stringpool_str986[sizeof("BIG5-HKSCS:2004")];
+- char stringpool_str995[sizeof("BIG5-HKSCS:1999")];
+- char stringpool_str997[sizeof("CSEUCPKDFMTJAPANESE")];
++ char stringpool_str4[sizeof("L2")];
++ char stringpool_str5[sizeof("L1")];
++ char stringpool_str11[sizeof("MS-EE")];
++ char stringpool_str12[sizeof("CP819")];
++ char stringpool_str15[sizeof("UCS-2")];
++ char stringpool_str16[sizeof("IBM819")];
++ char stringpool_str17[sizeof("UTF-8")];
++ char stringpool_str18[sizeof("UTF-32")];
++ char stringpool_str19[sizeof("UTF-16")];
++ char stringpool_str21[sizeof("CP367")];
++ char stringpool_str22[sizeof("ISO8859-2")];
++ char stringpool_str23[sizeof("ISO8859-1")];
++ char stringpool_str24[sizeof("IBM367")];
++ char stringpool_str25[sizeof("UTF-7")];
++ char stringpool_str26[sizeof("CHAR")];
++ char stringpool_str27[sizeof("ISO8859-15")];
++ char stringpool_str28[sizeof("US")];
++ char stringpool_str29[sizeof("ISO-8859-2")];
++ char stringpool_str31[sizeof("ISO-8859-1")];
++ char stringpool_str32[sizeof("ISO-8859-15")];
++ char stringpool_str33[sizeof("ISO_8859-2")];
++ char stringpool_str35[sizeof("ISO_8859-1")];
++ char stringpool_str36[sizeof("ISO_8859-15")];
++ char stringpool_str37[sizeof("KOI8-R")];
++ char stringpool_str38[sizeof("UCS-2LE")];
++ char stringpool_str39[sizeof("UTF-32LE")];
++ char stringpool_str40[sizeof("UTF-16LE")];
++ char stringpool_str41[sizeof("ISO_8859-15:1998")];
++ char stringpool_str43[sizeof("ISO_8859-2:1987")];
++ char stringpool_str44[sizeof("ISO_8859-1:1987")];
++ char stringpool_str45[sizeof("UCS-4")];
++ char stringpool_str47[sizeof("UNICODE-1-1")];
++ char stringpool_str48[sizeof("ISO-IR-6")];
++ char stringpool_str49[sizeof("CSKOI8R")];
++ char stringpool_str50[sizeof("ASCII")];
++ char stringpool_str51[sizeof("UNICODEBIG")];
++ char stringpool_str52[sizeof("ISO-IR-203")];
++ char stringpool_str53[sizeof("UCS-4LE")];
++ char stringpool_str54[sizeof("ISO-IR-101")];
++ char stringpool_str55[sizeof("CP1250")];
++ char stringpool_str56[sizeof("ISO-10646-UCS-2")];
++ char stringpool_str57[sizeof("UNICODE-1-1-UTF-7")];
++ char stringpool_str58[sizeof("LATIN2")];
++ char stringpool_str59[sizeof("UNICODELITTLE")];
++ char stringpool_str60[sizeof("LATIN1")];
++ char stringpool_str61[sizeof("ISO_646.IRV:1991")];
++ char stringpool_str62[sizeof("ISO646-US")];
++ char stringpool_str63[sizeof("CSUNICODE")];
++ char stringpool_str64[sizeof("UCS-2-INTERNAL")];
++ char stringpool_str65[sizeof("LATIN-9")];
++ char stringpool_str66[sizeof("WCHAR_T")];
++ char stringpool_str68[sizeof("CSUCS4")];
++ char stringpool_str69[sizeof("CSUNICODE11")];
++ char stringpool_str70[sizeof("US-ASCII")];
++ char stringpool_str71[sizeof("ISO-10646-UCS-4")];
++ char stringpool_str72[sizeof("UCS-2BE")];
++ char stringpool_str73[sizeof("UTF-32BE")];
++ char stringpool_str74[sizeof("UTF-16BE")];
++ char stringpool_str75[sizeof("ANSI_X3.4-1986")];
++ char stringpool_str76[sizeof("ANSI_X3.4-1968")];
++ char stringpool_str77[sizeof("CSUNICODE11UTF7")];
++ char stringpool_str78[sizeof("UCS-2-SWAPPED")];
++ char stringpool_str79[sizeof("UCS-4-INTERNAL")];
++ char stringpool_str80[sizeof("CSASCII")];
++ char stringpool_str87[sizeof("UCS-4BE")];
++ char stringpool_str88[sizeof("WINDOWS-1250")];
++ char stringpool_str92[sizeof("ISO-IR-100")];
++ char stringpool_str93[sizeof("UCS-4-SWAPPED")];
++ char stringpool_str97[sizeof("CSISOLATIN2")];
++ char stringpool_str98[sizeof("CSISOLATIN1")];
+ };
+ static const struct stringpool_t stringpool_contents =
+ {
+- "L6",
+- "L1",
+- "HZ",
+- "L4",
+- "L5",
+- "R8",
+- "L8",
+- "866",
+ "L2",
+- "SJIS",
+- "ISO-IR-6",
+- "ISO-IR-166",
+- "LATIN6",
+- "LATIN1",
+- "ISO-IR-14",
+- "L3",
+- "LATIN4",
+- "ISO-IR-165",
+- "LATIN5",
+- "ISO-IR-126",
+- "862",
+- "ISO-IR-144",
+- "LATIN8",
+- "ISO-IR-58",
+- "ISO-IR-148",
+- "L7",
+- "LATIN-9",
+- "ISO-IR-149",
+- "ISO-IR-159",
+- "ISO-IR-226",
+- "LATIN2",
+- "ISO8859-6",
+- "ISO-IR-199",
++ "L1",
++ "MS-EE",
++ "CP819",
++ "UCS-2",
++ "IBM819",
++ "UTF-8",
++ "UTF-32",
++ "UTF-16",
++ "CP367",
++ "ISO8859-2",
+ "ISO8859-1",
+- "ISO-8859-6",
+- "ISO_8859-6",
+- "ISO8859-16",
+- "PT154",
+- "ISO-8859-1",
+- "ISO_8859-1",
+- "ISO8859-11",
+- "ISO-8859-16",
+- "ISO_8859-16",
+- "CN",
+- "ISO-8859-11",
+- "ISO_8859-11",
+- "ISO8859-4",
+- "ISO_8859-16:2001",
+- "ISO8859-5",
+- "ISO-8859-4",
+- "ISO_8859-4",
+- "ISO8859-14",
+- "ISO-IR-101",
+- "ISO-8859-5",
+- "ISO_8859-5",
++ "IBM367",
++ "UTF-7",
++ "CHAR",
+ "ISO8859-15",
+- "ISO-8859-14",
+- "ISO_8859-14",
+- "ISO8859-8",
++ "US",
++ "ISO-8859-2",
++ "ISO-8859-1",
+ "ISO-8859-15",
++ "ISO_8859-2",
++ "ISO_8859-1",
+ "ISO_8859-15",
+- "ISO8859-9",
+- "ISO-8859-8",
+- "ISO_8859-8",
+- "CP866",
+- "ISO-IR-138",
+- "ISO-8859-9",
+- "ISO_8859-9",
+- "ISO_8859-14:1998",
++ "KOI8-R",
++ "UCS-2LE",
++ "UTF-32LE",
++ "UTF-16LE",
+ "ISO_8859-15:1998",
+- "ELOT_928",
+- "TCVN",
+- "C99",
+- "ISO8859-2",
+- "CP154",
+- "ISO-8859-2",
+- "ISO_8859-2",
+- "ISO-IR-109",
+- "L10",
+- "CHAR",
+- "CP1256",
+- "ISO-IR-179",
+- "ISO646-CN",
+- "ASCII",
+- "CP1251",
+- "LATIN3",
+- "850",
+- "GB2312",
+- "CP819",
+- "CP1254",
+- "CP949",
+- "CP1255",
+- "CP862",
+- "US",
+- "CP1361",
+- "CP1258",
+- "ISO-IR-110",
+- "IBM866",
+- "CP936",
+- "GEORGIAN-PS",
+- "LATIN10",
+- "CHINESE",
+- "CP1252",
+- "LATIN7",
+- "ISO_8859-10:1992",
+- "ISO-IR-57",
+- "TIS620",
+- "ISO8859-3",
++ "ISO_8859-2:1987",
++ "ISO_8859-1:1987",
+ "UCS-4",
+- "ISO-IR-87",
+- "TIS-620",
+- "ISO-IR-157",
+- "ISO-8859-3",
+- "ISO_8859-3",
+- "ISO8859-13",
+- "CSISOLATIN6",
+- "BIG5",
+- "ISO-8859-13",
+- "ISO_8859-13",
+- "CSISOLATIN1",
+- "KOI8-R",
+- "BIG-5",
+- "IBM819",
+- "ISO-IR-127",
+- "CP874",
+- "ISO646-US",
+- "VISCII",
+- "MS-EE",
+- "MS-ANSI",
+- "CSISOLATIN4",
+- "IBM862",
+- "CP932",
+- "X0212",
+- "CSISOLATIN5",
+- "UCS-2",
+- "ISO8859-10",
+- "MS936",
+- "WCHAR_T",
+- "ISO-8859-10",
+- "ISO_8859-10",
+- "UTF-16",
+- "EUCCN",
+- "ROMAN8",
++ "UNICODE-1-1",
++ "ISO-IR-6",
++ "CSKOI8R",
++ "ASCII",
++ "UNICODEBIG",
+ "ISO-IR-203",
+- "ISO8859-7",
+- "KOI8-T",
+- "EUC-CN",
+ "UCS-4LE",
+- "ISO-IR-100",
+- "ISO-8859-7",
+- "ISO_8859-7",
+- "MULELAO-1",
+- "GB_1988-80",
+- "X0201",
+- "ECMA-114",
+- "CSISOLATIN2",
+- "GEORGIAN-ACADEMY",
+- "PTCP154",
+- "UCS-2LE",
+- "CP1253",
+- "UTF-8",
+- "HP-ROMAN8",
+- "CSASCII",
+- "ECMA-118",
+- "UCS-4-INTERNAL",
+- "TCVN5712-1",
+- "KOREAN",
+- "CP850",
+- "MS-CYRL",
+- "CP950",
+- "TIS620-0",
+- "X0208",
+- "GREEK8",
+- "UCS-2-INTERNAL",
+- "TCVN-5712",
+- "CP1133",
++ "ISO-IR-101",
+ "CP1250",
+- "ISO-2022-CN",
+- "UTF-16LE",
+- "CYRILLIC-ASIAN",
+- "ISO-10646-UCS-4",
+- "ISO-2022-CN-EXT",
+- "CP1257",
+- "GB_2312-80",
+- "JP",
+- "EUCKR",
+ "ISO-10646-UCS-2",
+- "GB18030",
+- "EUC-KR",
+- "CSKOI8R",
+- "CSBIG5",
+- "CP367",
+- "MACINTOSH",
+- "CSISOLATIN3",
+- "CN-BIG5",
+- "CYRILLIC",
+- "CSVISCII",
+- "IBM850",
+- "MACTHAI",
+- "UNICODE-1-1",
+- "ISO_646.IRV:1991",
+- "US-ASCII",
+- "UTF-32",
+- "CN-GB-ISOIR165",
+- "NEXTSTEP",
+- "MAC",
+- "EXTENDED_UNIX_CODE_PACKED_FORMAT_FOR_JAPANESE",
+- "CSISOLATINARABIC",
+- "HZ-GB-2312",
+- "ARMSCII-8",
+- "CSISOLATINHEBREW",
+- "ISO-2022-KR",
+- "WINDOWS-1256",
+- "UHC",
+- "WINDOWS-1251",
+- "MS-HEBR",
+- "ISO-CELTIC",
+- "UTF-32LE",
+- "WINDOWS-1254",
+- "WINDOWS-1255",
+- "SHIFT-JIS",
+- "SHIFT_JIS",
+- "IBM367",
+- "WINDOWS-1258",
+- "CSPTCP154",
+- "GBK",
++ "UNICODE-1-1-UTF-7",
++ "LATIN2",
+ "UNICODELITTLE",
+- "WINDOWS-1252",
+- "UTF-7",
+- "KSC_5601",
+- "ASMO-708",
+- "CSISO2022CN",
+- "BIGFIVE",
+- "WINDOWS-936",
++ "LATIN1",
++ "ISO_646.IRV:1991",
++ "ISO646-US",
++ "CSUNICODE",
++ "UCS-2-INTERNAL",
++ "LATIN-9",
++ "WCHAR_T",
+ "CSUCS4",
+- "BIG-FIVE",
+- "ISO646-JP",
+- "TIS620.2529-1",
+- "CSISOLATINGREEK",
+- "CSISOLATINCYRILLIC",
+- "UCS-4BE",
+- "UNICODE-1-1-UTF-7",
+- "EUCTW",
+- "WINDOWS-1253",
+- "CSHPROMAN8",
+- "EUC-TW",
+- "KS_C_5601-1989",
+- "UCS-2BE",
+- "VISCII1.1-1",
+- "GREEK",
+- "WINDOWS-1250",
+- "CSGB2312",
+- "WINDOWS-874",
+ "CSUNICODE11",
+- "JAVA",
+- "WINDOWS-1257",
+- "CSUNICODE",
+- "CSHALFWIDTHKATAKANA",
+- "CSISO57GB1988",
+- "MACICELAND",
+- "CSIBM866",
++ "US-ASCII",
++ "ISO-10646-UCS-4",
++ "UCS-2BE",
++ "UTF-32BE",
+ "UTF-16BE",
+- "ARABIC",
+- "CN-GB",
+- "CSISO2022KR",
+- "CSMACINTOSH",
+- "JIS0208",
+- "MACROMAN",
+- "ISO_8859-4:1988",
+- "ISO_8859-5:1988",
+- "TIS620.2533-1",
+ "ANSI_X3.4-1986",
+- "ISO_8859-8:1988",
+- "KS_C_5601-1987",
+- "CSSHIFTJIS",
+- "HEBREW",
+- "ISO_8859-9:1989",
+- "MACCROATIAN",
+- "ISO-2022-JP-1",
+- "EUCJP",
+ "ANSI_X3.4-1968",
+- "EUC-JP",
+- "CSISO58GB231280",
+- "JIS_C6226-1983",
+- "IBM-CP1133",
+- "MACCENTRALEUROPE",
+- "CSISO159JISX02121990",
+- "ISO-2022-JP-2",
+ "CSUNICODE11UTF7",
+- "UCS-4-SWAPPED",
+- "UNICODEBIG",
+- "CSISO14JISC6220RO",
+- "JIS_C6220-1969-RO",
+- "ISO_8859-3:1988",
+- "CSPC862LATINHEBREW",
+- "BIG5HKSCS",
+- "ISO_8859-6:1987",
+ "UCS-2-SWAPPED",
+- "ISO_8859-1:1987",
+- "BIG5-HKSCS",
+- "UTF-32BE",
+- "ISO-2022-JP",
+- "KOI8-U",
+- "TIS620.2533-0",
+- "KOI8-RU",
+- "ISO_8859-2:1987",
+- "MACROMANIA",
+- "JIS_X0212",
+- "CSEUCKR",
+- "MACCYRILLIC",
+- "ISO_8859-7:2003",
+- "MS-ARAB",
+- "MS-GREEK",
+- "CSKSC56011987",
+- "JIS_X0201",
+- "ISO_8859-7:1987",
+- "CSISO2022JP2",
+- "JIS_X0208",
+- "JISX0201-1976",
+- "JIS_X0212-1990",
+- "CSISO2022JP",
+- "JOHAB",
+- "MS_KANJI",
+- "CSISO87JISX0208",
+- "MACTURKISH",
+- "TCVN5712-1:1993",
+- "JIS_X0208-1983",
+- "CSEUCTW",
+- "MACGREEK",
+- "JIS_X0208-1990",
+- "WINBALTRIM",
+- "MS-TURK",
+- "MACUKRAINE",
+- "MACARABIC",
+- "CSPC850MULTILINGUAL",
+- "MACHEBREW",
+- "JIS_X0212.1990-0",
+- "BIG5-HKSCS:2001",
+- "BIG5-HKSCS:2004",
+- "BIG5-HKSCS:1999",
+- "CSEUCPKDFMTJAPANESE"
++ "UCS-4-INTERNAL",
++ "CSASCII",
++ "UCS-4BE",
++ "WINDOWS-1250",
++ "ISO-IR-100",
++ "UCS-4-SWAPPED",
++ "CSISOLATIN2",
++ "CSISOLATIN1"
+ };
+ #define stringpool ((const char *) &stringpool_contents)
+
+ static const struct alias aliases[] =
+ {
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1},
+-#line 134 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str13, ei_iso8859_10},
+- {-1},
+-#line 60 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str15, ei_iso8859_1},
+- {-1}, {-1},
+-#line 325 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str18, ei_hz},
+- {-1}, {-1}, {-1},
+-#line 84 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str22, ei_iso8859_4},
+- {-1},
+-#line 126 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str24, ei_iso8859_9},
+- {-1},
+-#line 226 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str26, ei_hp_roman8},
+- {-1}, {-1},
+-#line 151 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str29, ei_iso8859_14},
+- {-1},
+-#line 207 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str31, ei_cp866},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+-#line 68 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str38, ei_iso8859_2},
+- {-1}, {-1}, {-1},
+-#line 303 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str42, ei_sjis},
+-#line 16 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str43, ei_ascii},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+- {-1}, {-1},
+-#line 247 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str55, ei_tis620},
+- {-1},
+-#line 133 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str57, ei_iso8859_10},
+- {-1}, {-1}, {-1},
+-#line 59 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str61, ei_iso8859_1},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+-#line 259 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str68, ei_iso646_jp},
++#line 66 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str4, ei_iso8859_2},
++#line 58 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str5, ei_iso8859_1},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+-#line 76 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str74, ei_iso8859_3},
+-#line 83 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str75, ei_iso8859_4},
+- {-1},
+-#line 289 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str77, ei_isoir165},
+- {-1},
+-#line 125 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str79, ei_iso8859_9},
+-#line 107 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str80, ei_iso8859_7},
+-#line 203 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str81, ei_cp862},
+-#line 90 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str82, ei_iso8859_5},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+-#line 150 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str89, ei_iso8859_14},
+- {-1},
+-#line 286 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str91, ei_gb2312},
+- {-1}, {-1}, {-1}, {-1},
+-#line 124 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str96, ei_iso8859_9},
+-#line 144 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str97, ei_iso8859_13},
+-#line 158 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str98, ei_iso8859_15},
+- {-1},
+-#line 294 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str100, ei_ksc5601},
+- {-1},
+-#line 278 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str102, ei_jisx0212},
+-#line 163 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str103, ei_iso8859_16},
+- {-1}, {-1}, {-1},
+-#line 67 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str107, ei_iso8859_2},
+-#line 102 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str108, ei_iso8859_6},
+-#line 149 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str109, ei_iso8859_14},
++#line 79 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str11, ei_cp1250},
++#line 55 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str12, ei_iso8859_1},
+ {-1}, {-1},
+-#line 62 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str112, ei_iso8859_1},
+-#line 94 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str113, ei_iso8859_6},
+-#line 95 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str114, ei_iso8859_6},
+-#line 166 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str115, ei_iso8859_16},
+-#line 233 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str116, ei_pt154},
+-#line 53 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str117, ei_iso8859_1},
+-#line 54 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str118, ei_iso8859_1},
+-#line 139 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str119, ei_iso8859_11},
+-#line 160 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str120, ei_iso8859_16},
+-#line 161 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str121, ei_iso8859_16},
+- {-1},
+-#line 283 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str123, ei_iso646_cn},
+-#line 137 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str124, ei_iso8859_11},
+-#line 138 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str125, ei_iso8859_11},
+-#line 86 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str126, ei_iso8859_4},
+- {-1},
+-#line 162 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str128, ei_iso8859_16},
++#line 24 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str15, ei_ucs2},
++#line 56 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str16, ei_iso8859_1},
++#line 23 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str17, ei_utf8},
++#line 41 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str18, ei_utf32},
++#line 38 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str19, ei_utf16},
+ {-1},
+-#line 93 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str130, ei_iso8859_5},
+-#line 79 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str131, ei_iso8859_4},
++#line 19 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str21, ei_ascii},
++#line 68 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str22, ei_iso8859_2},
++#line 60 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str23, ei_iso8859_1},
++#line 20 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str24, ei_ascii},
++#line 44 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str25, ei_utf7},
+ #line 80 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str132, ei_iso8859_4},
+-#line 153 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str133, ei_iso8859_14},
+-#line 66 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str134, ei_iso8859_2},
+-#line 87 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str135, ei_iso8859_5},
+-#line 88 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str136, ei_iso8859_5},
+-#line 159 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str137, ei_iso8859_15},
+-#line 146 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str138, ei_iso8859_14},
+-#line 147 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str139, ei_iso8859_14},
+-#line 120 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str140, ei_iso8859_8},
+- {-1},
+-#line 154 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str142, ei_iso8859_15},
+-#line 155 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str143, ei_iso8859_15},
+-#line 128 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str144, ei_iso8859_9},
+-#line 114 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str145, ei_iso8859_8},
+-#line 115 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str146, ei_iso8859_8},
+-#line 205 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str147, ei_cp866},
+-#line 117 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str148, ei_iso8859_8},
+-#line 121 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str149, ei_iso8859_9},
+-#line 122 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str150, ei_iso8859_9},
+-#line 148 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str151, ei_iso8859_14},
+- {-1},
+-#line 156 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str153, ei_iso8859_15},
+- {-1},
+-#line 109 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str155, ei_iso8859_7},
+-#line 253 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str156, ei_tcvn},
+-#line 51 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str157, ei_c99},
+-#line 70 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str158, ei_iso8859_2},
+- {-1}, {-1}, {-1},
+-#line 235 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str162, ei_pt154},
+-#line 63 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str163, ei_iso8859_2},
+-#line 64 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str164, ei_iso8859_2},
+- {-1},
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str26, ei_local_char},
+ #line 74 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str166, ei_iso8859_3},
+- {-1},
+-#line 165 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str168, ei_iso8859_16},
+-#line 351 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str169, ei_local_char},
+- {-1}, {-1}, {-1}, {-1},
+-#line 189 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str174, ei_cp1256},
+-#line 142 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str175, ei_iso8859_13},
+-#line 281 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str176, ei_iso646_cn},
+-#line 13 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str177, ei_ascii},
+-#line 174 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str178, ei_cp1251},
+-#line 75 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str179, ei_iso8859_3},
+- {-1},
+-#line 199 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str181, ei_cp850},
+- {-1},
+-#line 314 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str183, ei_euc_cn},
+- {-1},
+-#line 57 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str185, ei_iso8859_1},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+-#line 183 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str192, ei_cp1254},
+- {-1},
+-#line 345 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str194, ei_cp949},
+- {-1},
+-#line 186 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str196, ei_cp1255},
+-#line 201 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str197, ei_cp862},
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str27, ei_iso8859_15},
+ #line 21 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str198, ei_ascii},
+- {-1}, {-1}, {-1}, {-1},
+-#line 348 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str203, ei_johab},
+- {-1}, {-1},
+-#line 195 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str206, ei_cp1258},
+-#line 82 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str207, ei_iso8859_4},
+- {-1},
+-#line 206 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str209, ei_cp866},
+-#line 318 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str210, ei_cp936},
+-#line 231 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str211, ei_georgian_ps},
+- {-1}, {-1},
+-#line 164 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str214, ei_iso8859_16},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+-#line 288 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str222, ei_gb2312},
+- {-1},
+-#line 177 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str224, ei_cp1252},
+-#line 143 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str225, ei_iso8859_13},
+-#line 131 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str226, ei_iso8859_10},
+-#line 282 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str227, ei_iso646_cn},
+-#line 242 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str228, ei_tis620},
+- {-1},
+-#line 78 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str230, ei_iso8859_3},
+-#line 33 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str231, ei_ucs4},
+-#line 271 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str232, ei_jisx0208},
+-#line 241 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str233, ei_tis620},
+-#line 132 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str234, ei_iso8859_10},
+-#line 71 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str235, ei_iso8859_3},
+-#line 72 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str236, ei_iso8859_3},
+-#line 145 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str237, ei_iso8859_13},
+- {-1}, {-1},
+-#line 135 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str240, ei_iso8859_10},
+-#line 330 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str241, ei_ces_big5},
+-#line 140 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str242, ei_iso8859_13},
+-#line 141 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str243, ei_iso8859_13},
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str28, ei_ascii},
+ #line 61 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str244, ei_iso8859_1},
+-#line 167 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str245, ei_koi8_r},
+-#line 331 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str246, ei_ces_big5},
+-#line 58 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str247, ei_iso8859_1},
+-#line 97 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str248, ei_iso8859_6},
+-#line 248 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str249, ei_cp874},
+- {-1},
+-#line 14 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str251, ei_ascii},
+-#line 250 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str252, ei_viscii},
+-#line 173 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str253, ei_cp1250},
+- {-1}, {-1},
+-#line 179 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str256, ei_cp1252},
+- {-1},
+-#line 85 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str258, ei_iso8859_4},
+-#line 202 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str259, ei_cp862},
+-#line 306 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str260, ei_cp932},
+-#line 277 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str261, ei_jisx0212},
+-#line 127 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str262, ei_iso8859_9},
+-#line 24 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str263, ei_ucs2},
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str29, ei_iso8859_2},
+ {-1},
+-#line 136 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str265, ei_iso8859_10},
+-#line 319 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str266, ei_cp936},
+-#line 352 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str267, ei_local_wchar_t},
+- {-1}, {-1},
+-#line 129 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str270, ei_iso8859_10},
+-#line 130 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str271, ei_iso8859_10},
+-#line 38 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str272, ei_utf16},
+-#line 313 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str273, ei_euc_cn},
+-#line 225 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str274, ei_hp_roman8},
+-#line 157 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str275, ei_iso8859_15},
+-#line 113 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str276, ei_iso8859_7},
+-#line 232 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str277, ei_koi8_t},
+-#line 312 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str278, ei_euc_cn},
+-#line 37 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str279, ei_ucs4le},
+-#line 56 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str280, ei_iso8859_1},
+-#line 103 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str281, ei_iso8859_7},
+-#line 104 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str282, ei_iso8859_7},
+-#line 238 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str283, ei_mulelao},
+-#line 280 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str284, ei_iso646_cn},
+- {-1}, {-1}, {-1},
+-#line 264 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str288, ei_jisx0201},
+-#line 98 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str289, ei_iso8859_6},
++#line 51 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str31, ei_iso8859_1},
+ #line 69 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str290, ei_iso8859_2},
+-#line 230 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str291, ei_georgian_academy},
+-#line 234 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str292, ei_pt154},
+- {-1}, {-1},
+-#line 31 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str295, ei_ucs2le},
+-#line 180 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str296, ei_cp1253},
+-#line 23 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str297, ei_utf8},
+-#line 224 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str298, ei_hp_roman8},
+- {-1},
+-#line 22 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str300, ei_ascii},
+- {-1}, {-1},
+-#line 108 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str303, ei_iso8859_7},
+-#line 49 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str304, ei_ucs4internal},
+-#line 255 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str305, ei_tcvn},
+- {-1},
+-#line 296 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str307, ei_ksc5601},
+-#line 197 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str308, ei_cp850},
+-#line 176 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str309, ei_cp1251},
+-#line 336 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str310, ei_cp950},
+- {-1}, {-1},
+-#line 243 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str313, ei_tis620},
+- {-1}, {-1},
+-#line 270 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str316, ei_jisx0208},
+- {-1}, {-1},
+-#line 110 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str319, ei_iso8859_7},
+-#line 47 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str320, ei_ucs2internal},
+-#line 254 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str321, ei_tcvn},
+- {-1},
+-#line 239 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str323, ei_cp1133},
+-#line 171 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str324, ei_cp1250},
+- {-1}, {-1},
+-#line 322 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str327, ei_iso2022_cn},
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str32, ei_iso8859_15},
++#line 62 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str33, ei_iso8859_2},
+ {-1},
++#line 52 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str35, ei_iso8859_1},
++#line 70 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str36, ei_iso8859_15},
++#line 75 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str37, ei_koi8_r},
++#line 31 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str38, ei_ucs2le},
++#line 43 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str39, ei_utf32le},
+ #line 40 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str329, ei_utf16le},
+- {-1}, {-1}, {-1}, {-1}, {-1},
+-#line 236 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str335, ei_pt154},
+- {-1},
+-#line 34 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str337, ei_ucs4},
+- {-1}, {-1},
+-#line 324 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str340, ei_iso2022_cn_ext},
+- {-1},
+-#line 192 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str342, ei_cp1257},
+- {-1}, {-1},
+-#line 285 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str345, ei_gb2312},
+- {-1},
+-#line 260 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str347, ei_iso646_jp},
+- {-1}, {-1}, {-1},
+-#line 343 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str351, ei_euc_kr},
+- {-1},
+-#line 25 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str353, ei_ucs2},
+-#line 321 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str354, ei_gb18030},
+- {-1},
+-#line 342 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str356, ei_euc_kr},
+-#line 168 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str357, ei_koi8_r},
+-#line 335 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str358, ei_ces_big5},
+- {-1},
+-#line 19 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str360, ei_ascii},
+-#line 210 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str361, ei_mac_roman},
+-#line 77 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str362, ei_iso8859_3},
+-#line 334 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str363, ei_ces_big5},
+- {-1}, {-1},
+-#line 91 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str366, ei_iso8859_5},
+- {-1}, {-1},
+-#line 252 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str369, ei_viscii},
+-#line 198 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str370, ei_cp850},
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str40, ei_utf16le},
++#line 71 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str41, ei_iso8859_15},
+ {-1},
+-#line 223 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str372, ei_mac_thai},
++#line 63 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str43, ei_iso8859_2},
++#line 53 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str44, ei_iso8859_1},
++#line 33 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str45, ei_ucs4},
+ {-1},
+ #line 29 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str374, ei_ucs2be},
+- {-1},
+-#line 15 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str376, ei_ascii},
+- {-1}, {-1}, {-1},
+-#line 12 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str380, ei_ascii},
+-#line 41 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str381, ei_utf32},
+- {-1}, {-1},
+-#line 290 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str384, ei_isoir165},
+- {-1}, {-1},
+-#line 228 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str387, ei_nextstep},
+- {-1},
+-#line 211 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str389, ei_mac_roman},
+- {-1}, {-1}, {-1},
+-#line 299 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str393, ei_euc_jp},
+-#line 101 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str394, ei_iso8859_6},
+-#line 326 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str395, ei_hz},
+- {-1},
+-#line 229 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str397, ei_armscii_8},
+- {-1}, {-1}, {-1},
+-#line 119 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str401, ei_iso8859_8},
+- {-1}, {-1}, {-1},
+-#line 349 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str405, ei_iso2022_kr},
+- {-1},
+-#line 190 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str407, ei_cp1256},
+-#line 346 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str408, ei_cp949},
+-#line 175 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str409, ei_cp1251},
+- {-1},
+-#line 188 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str411, ei_cp1255},
+-#line 152 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str412, ei_iso8859_14},
+-#line 43 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str413, ei_utf32le},
+- {-1}, {-1},
+-#line 184 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str416, ei_cp1254},
+- {-1},
+-#line 187 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str418, ei_cp1255},
+- {-1},
+-#line 302 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str420, ei_sjis},
+-#line 301 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str421, ei_sjis},
+-#line 20 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str422, ei_ascii},
+-#line 196 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str423, ei_cp1258},
+-#line 237 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str424, ei_pt154},
+- {-1},
+-#line 317 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str426, ei_ces_gbk},
+- {-1},
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str47, ei_ucs2be},
++#line 16 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str48, ei_ascii},
++#line 76 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str49, ei_koi8_r},
++#line 13 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str50, ei_ascii},
++#line 28 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str51, ei_ucs2be},
++#line 72 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str52, ei_iso8859_15},
++#line 37 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str53, ei_ucs4le},
++#line 64 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str54, ei_iso8859_2},
++#line 77 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str55, ei_cp1250},
++#line 25 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str56, ei_ucs2},
++#line 45 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str57, ei_utf7},
++#line 65 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str58, ei_iso8859_2},
+ #line 32 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str428, ei_ucs2le},
+- {-1}, {-1}, {-1},
+-#line 178 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str432, ei_cp1252},
+-#line 44 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str433, ei_utf7},
+- {-1},
+-#line 291 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str435, ei_ksc5601},
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str59, ei_ucs2le},
++#line 57 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str60, ei_iso8859_1},
++#line 15 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str61, ei_ascii},
++#line 14 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str62, ei_ascii},
++#line 26 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str63, ei_ucs2},
++#line 47 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str64, ei_ucs2internal},
++#line 73 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str65, ei_iso8859_15},
++#line 81 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str66, ei_local_wchar_t},
+ {-1},
+-#line 99 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str437, ei_iso8859_6},
+- {-1}, {-1},
+-#line 323 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str440, ei_iso2022_cn},
+- {-1}, {-1}, {-1},
+-#line 333 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str444, ei_ces_big5},
+- {-1}, {-1},
+-#line 320 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str447, ei_cp936},
+ #line 35 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str448, ei_ucs4},
+-#line 332 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str449, ei_ces_big5},
+- {-1}, {-1}, {-1},
+-#line 258 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str453, ei_iso646_jp},
+- {-1}, {-1},
+-#line 244 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str456, ei_tis620},
+-#line 112 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str457, ei_iso8859_7},
+- {-1},
+-#line 92 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str459, ei_iso8859_5},
+-#line 36 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str460, ei_ucs4be},
+- {-1},
+-#line 45 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str462, ei_utf7},
+- {-1}, {-1},
+-#line 328 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str465, ei_euc_tw},
+- {-1}, {-1},
+-#line 181 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str468, ei_cp1253},
+-#line 227 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str469, ei_hp_roman8},
+-#line 327 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str470, ei_euc_tw},
+- {-1},
+-#line 293 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str472, ei_ksc5601},
+- {-1}, {-1}, {-1},
+-#line 27 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str476, ei_ucs2be},
+- {-1}, {-1},
+-#line 251 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str479, ei_viscii},
+-#line 111 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str480, ei_iso8859_7},
+- {-1},
+-#line 172 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str482, ei_cp1250},
+-#line 316 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str483, ei_euc_cn},
+- {-1}, {-1},
+-#line 249 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str486, ei_cp874},
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str68, ei_ucs4},
+ #line 30 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str487, ei_ucs2be},
+- {-1},
+-#line 52 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str489, ei_java},
+- {-1},
+-#line 193 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str491, ei_cp1257},
+- {-1},
+-#line 26 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str493, ei_ucs2},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+-#line 265 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str500, ei_jisx0201},
+- {-1},
+-#line 284 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str502, ei_iso646_cn},
+- {-1},
+-#line 214 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str504, ei_mac_iceland},
+- {-1}, {-1}, {-1}, {-1},
+-#line 208 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str509, ei_cp866},
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str69, ei_ucs2be},
++#line 12 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str70, ei_ascii},
++#line 34 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str71, ei_ucs4},
++#line 27 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str72, ei_ucs2be},
++#line 42 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str73, ei_utf32be},
+ #line 39 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str510, ei_utf16be},
+- {-1}, {-1},
+-#line 100 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str513, ei_iso8859_6},
+-#line 315 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str514, ei_euc_cn},
+- {-1}, {-1}, {-1},
+-#line 350 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str518, ei_iso2022_kr},
+- {-1},
+-#line 212 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str520, ei_mac_roman},
+- {-1}, {-1}, {-1}, {-1}, {-1},
+-#line 269 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str526, ei_jisx0208},
+- {-1},
+-#line 209 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str528, ei_mac_roman},
+- {-1},
+-#line 81 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str530, ei_iso8859_4},
+- {-1},
+-#line 89 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str532, ei_iso8859_5},
+- {-1}, {-1},
+-#line 246 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str535, ei_tis620},
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str74, ei_utf16be},
+ #line 18 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str536, ei_ascii},
+-#line 116 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str537, ei_iso8859_8},
+-#line 292 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str538, ei_ksc5601},
+-#line 305 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str539, ei_sjis},
+-#line 118 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str540, ei_iso8859_8},
+-#line 123 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str541, ei_iso8859_9},
+- {-1}, {-1}, {-1}, {-1}, {-1},
+-#line 215 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str547, ei_mac_croatian},
+-#line 309 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str548, ei_iso2022_jp1},
+- {-1},
+-#line 298 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str550, ei_euc_jp},
+- {-1},
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str75, ei_ascii},
+ #line 17 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str552, ei_ascii},
+- {-1}, {-1},
+-#line 297 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str555, ei_euc_jp},
+- {-1}, {-1}, {-1}, {-1}, {-1},
+-#line 287 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str561, ei_gb2312},
+-#line 272 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str562, ei_jisx0208},
+- {-1}, {-1}, {-1},
+-#line 240 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str566, ei_cp1133},
+- {-1}, {-1},
+-#line 213 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str569, ei_mac_centraleurope},
+-#line 279 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str570, ei_jisx0212},
+-#line 310 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str571, ei_iso2022_jp2},
+- {-1},
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str76, ei_ascii},
+ #line 46 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str573, ei_utf7},
+-#line 50 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str574, ei_ucs4swapped},
+- {-1}, {-1}, {-1},
+-#line 28 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str578, ei_ucs2be},
+-#line 261 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str579, ei_iso646_jp},
+-#line 257 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str580, ei_iso646_jp},
+- {-1},
+-#line 73 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str582, ei_iso8859_3},
+- {-1}, {-1}, {-1},
+-#line 204 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str586, ei_cp862},
+- {-1},
+-#line 340 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str588, ei_big5hkscs2004},
+-#line 96 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str589, ei_iso8859_6},
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str77, ei_utf7},
+ #line 48 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str590, ei_ucs2swapped},
+-#line 55 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str591, ei_iso8859_1},
+- {-1},
+-#line 339 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str593, ei_big5hkscs2004},
+-#line 42 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str594, ei_utf32be},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+-#line 307 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str604, ei_iso2022_jp},
+- {-1}, {-1},
+-#line 169 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str607, ei_koi8_u},
+-#line 245 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str608, ei_tis620},
+- {-1}, {-1}, {-1},
+-#line 170 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str612, ei_koi8_ru},
+- {-1},
+-#line 65 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str614, ei_iso8859_2},
+- {-1}, {-1}, {-1},
+-#line 216 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str618, ei_mac_romania},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+- {-1}, {-1}, {-1}, {-1},
+-#line 274 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str641, ei_jisx0212},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+-#line 344 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str648, ei_euc_kr},
+-#line 217 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str649, ei_mac_cyrillic},
+-#line 106 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str650, ei_iso8859_7},
+-#line 191 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str651, ei_cp1256},
+- {-1}, {-1}, {-1}, {-1}, {-1},
+-#line 182 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str657, ei_cp1253},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+-#line 295 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str666, ei_ksc5601},
+- {-1},
+-#line 262 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str668, ei_jisx0201},
+- {-1}, {-1}, {-1}, {-1},
+-#line 105 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str673, ei_iso8859_7},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+-#line 311 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str683, ei_iso2022_jp2},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+- {-1}, {-1}, {-1},
+-#line 266 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str696, ei_jisx0208},
+-#line 263 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str697, ei_jisx0201},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+-#line 276 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str706, ei_jisx0212},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+- {-1},
+-#line 308 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str717, ei_iso2022_jp},
+- {-1}, {-1}, {-1},
+-#line 347 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str721, ei_johab},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+-#line 304 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str730, ei_sjis},
+- {-1}, {-1}, {-1},
+-#line 273 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str734, ei_jisx0208},
+- {-1}, {-1},
+-#line 220 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str737, ei_mac_turkish},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+-#line 256 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str755, ei_tcvn},
+-#line 267 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str756, ei_jisx0208},
+- {-1}, {-1}, {-1}, {-1}, {-1},
+-#line 329 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str762, ei_euc_tw},
+-#line 219 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str763, ei_mac_greek},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+-#line 268 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str770, ei_jisx0208},
+- {-1}, {-1}, {-1}, {-1}, {-1},
+-#line 194 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str776, ei_cp1257},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+- {-1}, {-1}, {-1}, {-1},
+-#line 185 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str790, ei_cp1254},
+- {-1},
+-#line 218 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str792, ei_mac_ukraine},
+- {-1}, {-1}, {-1},
+-#line 222 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str796, ei_mac_arabic},
+- {-1}, {-1}, {-1}, {-1}, {-1},
+-#line 200 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str802, ei_cp850},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str78, ei_ucs2swapped},
++#line 49 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str79, ei_ucs4internal},
++#line 22 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str80, ei_ascii},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+-#line 221 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str845, ei_mac_hebrew},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
++#line 36 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str87, ei_ucs4be},
++#line 78 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str88, ei_cp1250},
+ {-1}, {-1}, {-1},
+-#line 275 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str903, ei_jisx0212},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
++#line 54 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str92, ei_iso8859_1},
++#line 50 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str93, ei_ucs4swapped},
+ {-1}, {-1}, {-1},
+-#line 338 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str979, ei_big5hkscs2001},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+-#line 341 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str986, ei_big5hkscs2004},
+- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+-#line 337 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str995, ei_big5hkscs1999},
+- {-1},
+-#line 300 "lib/aliases.gperf"
+- {(int)(long)&((struct stringpool_t *)0)->stringpool_str997, ei_euc_jp}
++#line 67 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str97, ei_iso8859_2},
++#line 59 "lib/aliases.gperf"
++ {(int)(long)&((struct stringpool_t *)0)->stringpool_str98, ei_iso8859_1}
+ };
+
+ #ifdef __GNUC__
+--- a/lib/canonical_dos.h
++++ b/lib/canonical_dos.h
+@@ -1,15 +1 @@
+ (int)(long)&((struct stringpool2_t *)0)->stringpool_dos_0,
+- (int)(long)&((struct stringpool2_t *)0)->stringpool_dos_4,
+- (int)(long)&((struct stringpool2_t *)0)->stringpool_dos_5,
+- (int)(long)&((struct stringpool2_t *)0)->stringpool_dos_8,
+- (int)(long)&((struct stringpool2_t *)0)->stringpool_dos_12,
+- (int)(long)&((struct stringpool2_t *)0)->stringpool_dos_13,
+- (int)(long)&((struct stringpool2_t *)0)->stringpool_dos_17,
+- (int)(long)&((struct stringpool2_t *)0)->stringpool_dos_21,
+- (int)(long)&((struct stringpool2_t *)0)->stringpool_dos_22,
+- (int)(long)&((struct stringpool2_t *)0)->stringpool_dos_26,
+- (int)(long)&((struct stringpool2_t *)0)->stringpool_dos_31,
+- (int)(long)&((struct stringpool2_t *)0)->stringpool_dos_35,
+- (int)(long)&((struct stringpool2_t *)0)->stringpool_dos_38,
+- (int)(long)&((struct stringpool2_t *)0)->stringpool_dos_42,
+- (int)(long)&((struct stringpool2_t *)0)->stringpool_dos_47,
+--- a/lib/canonical.h
++++ b/lib/canonical.h
+@@ -1,107 +1 @@
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str380,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str297,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str263,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str476,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str295,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str231,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str460,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str279,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str272,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str510,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str329,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str381,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str594,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str413,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str433,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str320,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str590,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str304,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str574,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str157,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str489,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str117,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str163,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str235,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str131,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str135,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str113,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str281,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str145,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str149,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str270,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str124,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str242,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str138,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str142,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str120,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str245,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str607,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str612,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str324,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str178,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str224,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str296,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str192,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str196,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str174,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str342,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str206,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str308,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str197,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str147,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str528,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str569,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str504,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str547,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str618,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str649,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str792,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str763,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str737,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str845,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str796,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str372,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str298,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str387,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str397,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str291,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str211,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str277,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str116,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str283,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str323,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str233,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str249,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str252,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str156,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str580,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str668,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str696,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str641,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str284,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str345,
+ (int)(long)&((struct stringpool_t *)0)->stringpool_str77,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str435,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str555,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str421,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str260,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str604,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str548,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str571,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str278,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str426,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str210,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str354,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str327,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str340,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str18,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str470,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str241,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str310,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str995,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str979,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str593,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str356,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str194,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str721,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str405,
+--- a/lib/canonical_local.h
++++ b/lib/canonical_local.h
+@@ -1,2 +1 @@
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str169,
+- (int)(long)&((struct stringpool_t *)0)->stringpool_str267,
++
+--- a/lib/converters.h
++++ b/lib/converters.h
+@@ -129,161 +129,15 @@ struct conv_struct {
+ #include "ucs2swapped.h"
+ #include "ucs4internal.h"
+ #include "ucs4swapped.h"
+-#include "c99.h"
+-#include "java.h"
+
+ /* 8-bit encodings */
+ #include "iso8859_1.h"
+ #include "iso8859_2.h"
+-#include "iso8859_3.h"
+-#include "iso8859_4.h"
+-#include "iso8859_5.h"
+-#include "iso8859_6.h"
+-#include "iso8859_7.h"
+-#include "iso8859_8.h"
+-#include "iso8859_9.h"
+-#include "iso8859_10.h"
+-#include "iso8859_11.h"
+-#include "iso8859_13.h"
+-#include "iso8859_14.h"
+ #include "iso8859_15.h"
+-#include "iso8859_16.h"
+ #include "koi8_r.h"
+-#include "koi8_u.h"
+-#include "koi8_ru.h"
+ #include "cp1250.h"
+-#include "cp1251.h"
+-#include "cp1252.h"
+-#include "cp1253.h"
+-#include "cp1254.h"
+-#include "cp1255.h"
+-#include "cp1256.h"
+-#include "cp1257.h"
+-#include "cp1258.h"
+ #include "cp850.h"
+-#include "cp862.h"
+-#include "cp866.h"
+-#include "mac_roman.h"
+-#include "mac_centraleurope.h"
+-#include "mac_iceland.h"
+-#include "mac_croatian.h"
+-#include "mac_romania.h"
+-#include "mac_cyrillic.h"
+-#include "mac_ukraine.h"
+-#include "mac_greek.h"
+-#include "mac_turkish.h"
+-#include "mac_hebrew.h"
+-#include "mac_arabic.h"
+-#include "mac_thai.h"
+-#include "hp_roman8.h"
+-#include "nextstep.h"
+-#include "armscii_8.h"
+-#include "georgian_academy.h"
+-#include "georgian_ps.h"
+-#include "koi8_t.h"
+-#include "pt154.h"
+-#include "mulelao.h"
+-#include "cp1133.h"
+-#include "tis620.h"
+-#include "cp874.h"
+-#include "viscii.h"
+-#include "tcvn.h"
+-
+-/* CJK character sets [CCS = coded character set] [CJKV.INF chapter 3] */
+-
+-typedef struct {
+- unsigned short indx; /* index into big table */
+- unsigned short used; /* bitmask of used entries */
+-} Summary16;
+-
+-#include "iso646_jp.h"
+-#include "jisx0201.h"
+-#include "jisx0208.h"
+-#include "jisx0212.h"
+-
+-#include "iso646_cn.h"
+-#include "gb2312.h"
+-#include "isoir165.h"
+-/*#include "gb12345.h"*/
+-#include "gbk.h"
+-#include "cns11643.h"
+-#include "big5.h"
+-
+-#include "ksc5601.h"
+-#include "johab_hangul.h"
+-
+-/* CJK encodings [CES = character encoding scheme] [CJKV.INF chapter 4] */
+-
+-#include "euc_jp.h"
+-#include "sjis.h"
+-#include "cp932.h"
+-#include "iso2022_jp.h"
+-#include "iso2022_jp1.h"
+-#include "iso2022_jp2.h"
+-
+-#include "euc_cn.h"
+-#include "ces_gbk.h"
+-#include "cp936.h"
+-#include "gb18030.h"
+-#include "iso2022_cn.h"
+-#include "iso2022_cnext.h"
+-#include "hz.h"
+-#include "euc_tw.h"
+-#include "ces_big5.h"
+-#include "cp950.h"
+-#include "big5hkscs1999.h"
+-#include "big5hkscs2001.h"
+-#include "big5hkscs2004.h"
+-
+-#include "euc_kr.h"
+-#include "cp949.h"
+-#include "johab.h"
+-#include "iso2022_kr.h"
+-
+-/* Encodings used by system dependent locales. */
+-
+-#ifdef USE_AIX
+-#include "cp856.h"
+-#include "cp922.h"
+-#include "cp943.h"
+-#include "cp1046.h"
+-#include "cp1124.h"
+-#include "cp1129.h"
+-#include "cp1161.h"
+-#include "cp1162.h"
+-#include "cp1163.h"
+-#endif
+-
+-#ifdef USE_OSF1
+-#include "dec_kanji.h"
+-#include "dec_hanyu.h"
+-#endif
+
+ #ifdef USE_DOS
+ #include "cp437.h"
+-#include "cp737.h"
+-#include "cp775.h"
+-#include "cp852.h"
+-#include "cp853.h"
+-#include "cp855.h"
+-#include "cp857.h"
+-#include "cp858.h"
+-#include "cp860.h"
+-#include "cp861.h"
+-#include "cp863.h"
+-#include "cp864.h"
+-#include "cp865.h"
+-#include "cp869.h"
+-#include "cp1125.h"
+-#endif
+-
+-#ifdef USE_EXTRA
+-#include "euc_jisx0213.h"
+-#include "shift_jisx0213.h"
+-#include "iso2022_jp3.h"
+-#include "big5_2003.h"
+-#include "tds565.h"
+-#include "atarist.h"
+-#include "riscos1.h"
+ #endif
+-
+--- a/lib/encodings.def
++++ b/lib/encodings.def
+@@ -161,16 +161,6 @@ DEFENCODING(( "UCS-4-SWAPPED",
+ ucs4swapped,
+ { ucs4swapped_mbtowc, NULL }, { ucs4swapped_wctomb, NULL })
+
+-DEFENCODING(( "C99",
+- ),
+- c99,
+- { c99_mbtowc, NULL }, { c99_wctomb, NULL })
+-
+-DEFENCODING(( "JAVA",
+- ),
+- java,
+- { java_mbtowc, NULL }, { java_wctomb, NULL })
+-
+ /* Standard 8-bit encodings */
+
+ DEFENCODING(( "ISO-8859-1", /* IANA */
+@@ -203,148 +193,6 @@ DEFENCODING(( "ISO-8859-2",
+ iso8859_2,
+ { iso8859_2_mbtowc, NULL }, { iso8859_2_wctomb, NULL })
+
+-DEFENCODING(( "ISO-8859-3", /* IANA */
+- "ISO_8859-3", /* IANA */
+- "ISO_8859-3:1988", /* IANA */
+- "ISO-IR-109", /* IANA */
+- "LATIN3", /* IANA */
+- "L3", /* IANA */
+- "csISOLatin3", /* IANA */
+- "ISO8859-3", /* X11R6.4, glibc, FreeBSD */
+- /*"ISO8859_3", JDK 1.1 */
+- /*"CP28593", Windows */
+- ),
+- iso8859_3,
+- { iso8859_3_mbtowc, NULL }, { iso8859_3_wctomb, NULL })
+-
+-DEFENCODING(( "ISO-8859-4", /* IANA */
+- "ISO_8859-4", /* IANA */
+- "ISO_8859-4:1988", /* IANA */
+- "ISO-IR-110", /* IANA */
+- "LATIN4", /* IANA */
+- "L4", /* IANA */
+- "csISOLatin4", /* IANA */
+- "ISO8859-4", /* X11R6.4, glibc, FreeBSD */
+- /*"ISO8859_4", JDK 1.1 */
+- /*"CP28594", Windows */
+- ),
+- iso8859_4,
+- { iso8859_4_mbtowc, NULL }, { iso8859_4_wctomb, NULL })
+-
+-DEFENCODING(( "ISO-8859-5", /* IANA */
+- "ISO_8859-5", /* IANA */
+- "ISO_8859-5:1988", /* IANA */
+- "ISO-IR-144", /* IANA */
+- "CYRILLIC", /* IANA */
+- "csISOLatinCyrillic", /* IANA */
+- "ISO8859-5", /* X11R6.4, glibc, FreeBSD */
+- /*"ISO8859_5", JDK 1.1 */
+- /*"CP28595", Windows */
+- ),
+- iso8859_5,
+- { iso8859_5_mbtowc, NULL }, { iso8859_5_wctomb, NULL })
+-
+-DEFENCODING(( "ISO-8859-6", /* IANA */
+- "ISO_8859-6", /* IANA */
+- "ISO_8859-6:1987", /* IANA */
+- "ISO-IR-127", /* IANA */
+- "ECMA-114", /* IANA */
+- "ASMO-708", /* IANA */
+- "ARABIC", /* IANA */
+- "csISOLatinArabic", /* IANA */
+- "ISO8859-6", /* X11R6.4, glibc, FreeBSD */
+- /*"ISO8859_6", JDK 1.1 */
+- /*"CP28596", Windows */
+- ),
+- iso8859_6,
+- { iso8859_6_mbtowc, NULL }, { iso8859_6_wctomb, NULL })
+-
+-DEFENCODING(( "ISO-8859-7", /* IANA, RFC 1947 */
+- "ISO_8859-7", /* IANA */
+- "ISO_8859-7:1987", /* IANA */
+- "ISO_8859-7:2003",
+- "ISO-IR-126", /* IANA */
+- "ECMA-118", /* IANA */
+- "ELOT_928", /* IANA */
+- "GREEK8", /* IANA */
+- "GREEK", /* IANA */
+- "csISOLatinGreek", /* IANA */
+- "ISO8859-7", /* X11R6.4, glibc, FreeBSD */
+- /*"ISO8859_7", JDK 1.1 */
+- /*"CP28597", Windows */
+- ),
+- iso8859_7,
+- { iso8859_7_mbtowc, NULL }, { iso8859_7_wctomb, NULL })
+-
+-DEFENCODING(( "ISO-8859-8", /* IANA */
+- "ISO_8859-8", /* IANA */
+- "ISO_8859-8:1988", /* IANA */
+- "ISO-IR-138", /* IANA */
+- "HEBREW", /* IANA */
+- "csISOLatinHebrew", /* IANA */
+- "ISO8859-8", /* X11R6.4, glibc, FreeBSD */
+- /*"ISO8859_8", JDK 1.1 */
+- /*"CP28598", Windows */
+- /*"CP38598", Windows */
+- ),
+- iso8859_8,
+- { iso8859_8_mbtowc, NULL }, { iso8859_8_wctomb, NULL })
+-
+-DEFENCODING(( "ISO-8859-9", /* IANA */
+- "ISO_8859-9", /* IANA */
+- "ISO_8859-9:1989", /* IANA */
+- "ISO-IR-148", /* IANA */
+- "LATIN5", /* IANA */
+- "L5", /* IANA */
+- "csISOLatin5", /* IANA */
+- "ISO8859-9", /* X11R6.4, glibc, FreeBSD */
+- /*"ISO8859_9", JDK 1.1 */
+- /*"CP28599", Windows */
+- ),
+- iso8859_9,
+- { iso8859_9_mbtowc, NULL }, { iso8859_9_wctomb, NULL })
+-
+-DEFENCODING(( "ISO-8859-10", /* IANA */
+- "ISO_8859-10",
+- "ISO_8859-10:1992", /* IANA */
+- "ISO-IR-157", /* IANA */
+- "LATIN6", /* IANA */
+- "L6", /* IANA */
+- "csISOLatin6", /* IANA */
+- "ISO8859-10", /* X11R6.4, glibc, FreeBSD */
+- ),
+- iso8859_10,
+- { iso8859_10_mbtowc, NULL }, { iso8859_10_wctomb, NULL })
+-
+-DEFENCODING(( "ISO-8859-11", /* glibc */
+- "ISO_8859-11",
+- "ISO8859-11", /* X11R6.7, glibc */
+- ),
+- iso8859_11,
+- { iso8859_11_mbtowc, NULL }, { iso8859_11_wctomb, NULL })
+-
+-DEFENCODING(( "ISO-8859-13", /* IANA, glibc */
+- "ISO_8859-13",
+- "ISO-IR-179", /* glibc */
+- "LATIN7", /* glibc */
+- "L7", /* glibc */
+- "ISO8859-13", /* glibc, FreeBSD */
+- ),
+- iso8859_13,
+- { iso8859_13_mbtowc, NULL }, { iso8859_13_wctomb, NULL })
+-
+-DEFENCODING(( "ISO-8859-14", /* IANA, glibc */
+- "ISO_8859-14", /* IANA */
+- "ISO_8859-14:1998", /* IANA, glibc */
+- "ISO-IR-199", /* IANA */
+- "LATIN8", /* IANA, glibc */
+- "L8", /* IANA, glibc */
+- "ISO-CELTIC", /* IANA */
+- "ISO8859-14", /* glibc, FreeBSD */
+- ),
+- iso8859_14,
+- { iso8859_14_mbtowc, NULL }, { iso8859_14_wctomb, NULL })
+-
+ DEFENCODING(( "ISO-8859-15", /* IANA, glibc */
+ "ISO_8859-15", /* IANA */
+ "ISO_8859-15:1998", /* glibc */
+@@ -356,17 +204,6 @@ DEFENCODING(( "ISO-8859-15",
+ iso8859_15,
+ { iso8859_15_mbtowc, NULL }, { iso8859_15_wctomb, NULL })
+
+-DEFENCODING(( "ISO-8859-16", /* IANA */
+- "ISO_8859-16", /* IANA */
+- "ISO_8859-16:2001", /* IANA */
+- "ISO-IR-226", /* IANA */
+- "LATIN10", /* IANA */
+- "L10", /* IANA */
+- "ISO8859-16", /* glibc, FreeBSD */
+- ),
+- iso8859_16,
+- { iso8859_16_mbtowc, NULL }, { iso8859_16_wctomb, NULL })
+-
+ DEFENCODING(( "KOI8-R", /* IANA, RFC 1489, X11R6.4, JDK 1.1 */
+ "csKOI8R", /* IANA */
+ /*"CP20866", Windows */
+@@ -374,16 +211,6 @@ DEFENCODING(( "KOI8-R",
+ koi8_r,
+ { koi8_r_mbtowc, NULL }, { koi8_r_wctomb, NULL })
+
+-DEFENCODING(( "KOI8-U", /* IANA, RFC 2319 */
+- ),
+- koi8_u,
+- { koi8_u_mbtowc, NULL }, { koi8_u_wctomb, NULL })
+-
+-DEFENCODING(( "KOI8-RU",
+- ),
+- koi8_ru,
+- { koi8_ru_mbtowc, NULL }, { koi8_ru_wctomb, NULL })
+-
+ /* Windows 8-bit encodings */
+
+ DEFENCODING(( "CP1250", /* JDK 1.1 */
+@@ -393,61 +220,6 @@ DEFENCODING(( "CP1250",
+ cp1250,
+ { cp1250_mbtowc, NULL }, { cp1250_wctomb, NULL })
+
+-DEFENCODING(( "CP1251", /* JDK 1.1 */
+- "WINDOWS-1251", /* IANA */
+- "MS-CYRL",
+- ),
+- cp1251,
+- { cp1251_mbtowc, NULL }, { cp1251_wctomb, NULL })
+-
+-DEFENCODING(( "CP1252", /* JDK 1.1 */
+- "WINDOWS-1252", /* IANA */
+- "MS-ANSI",
+- ),
+- cp1252,
+- { cp1252_mbtowc, NULL }, { cp1252_wctomb, NULL })
+-
+-DEFENCODING(( "CP1253", /* JDK 1.1 */
+- "WINDOWS-1253", /* IANA */
+- "MS-GREEK",
+- ),
+- cp1253,
+- { cp1253_mbtowc, NULL }, { cp1253_wctomb, NULL })
+-
+-DEFENCODING(( "CP1254", /* JDK 1.1 */
+- "WINDOWS-1254", /* IANA */
+- "MS-TURK",
+- ),
+- cp1254,
+- { cp1254_mbtowc, NULL }, { cp1254_wctomb, NULL })
+-
+-DEFENCODING(( "CP1255", /* JDK 1.1 */
+- "WINDOWS-1255", /* IANA */
+- "MS-HEBR",
+- ),
+- cp1255,
+- { cp1255_mbtowc, cp1255_flushwc }, { cp1255_wctomb, NULL })
+-
+-DEFENCODING(( "CP1256", /* JDK 1.1 */
+- "WINDOWS-1256", /* IANA */
+- "MS-ARAB",
+- ),
+- cp1256,
+- { cp1256_mbtowc, NULL }, { cp1256_wctomb, NULL })
+-
+-DEFENCODING(( "CP1257", /* JDK 1.1 */
+- "WINDOWS-1257", /* IANA */
+- "WINBALTRIM",
+- ),
+- cp1257,
+- { cp1257_mbtowc, NULL }, { cp1257_wctomb, NULL })
+-
+-DEFENCODING(( "CP1258", /* JDK 1.1 */
+- "WINDOWS-1258", /* IANA */
+- ),
+- cp1258,
+- { cp1258_mbtowc, cp1258_flushwc }, { cp1258_wctomb, NULL })
+-
+ /* DOS 8-bit encodings */
+
+ DEFENCODING(( "CP850", /* IANA, JDK 1.1 */
+@@ -458,431 +230,3 @@ DEFENCODING(( "CP850",
+ cp850,
+ { cp850_mbtowc, NULL }, { cp850_wctomb, NULL })
+
+-DEFENCODING(( "CP862", /* IANA, JDK 1.1 */
+- "IBM862", /* IANA */
+- "862", /* IANA */
+- "csPC862LatinHebrew", /* IANA */
+- ),
+- cp862,
+- { cp862_mbtowc, NULL }, { cp862_wctomb, NULL })
+-
+-DEFENCODING(( "CP866", /* IANA, JDK 1.1 */
+- "IBM866", /* IANA */
+- "866", /* IANA */
+- "csIBM866", /* IANA */
+- ),
+- cp866,
+- { cp866_mbtowc, NULL }, { cp866_wctomb, NULL })
+-
+-/* Macintosh 8-bit encodings */
+-
+-DEFENCODING(( "MacRoman", /* JDK 1.1 */
+- /* This is the best table for MACINTOSH. The ones */
+- /* in glibc and FreeBSD-iconv are bad quality. */
+- "MACINTOSH", /* IANA */
+- "MAC", /* IANA */
+- "csMacintosh", /* IANA */
+- /*"CP10000", Windows */
+- ),
+- mac_roman,
+- { mac_roman_mbtowc, NULL }, { mac_roman_wctomb, NULL })
+-
+-DEFENCODING(( "MacCentralEurope", /* JDK 1.1 */
+- /*"CP10029", Windows */
+- ),
+- mac_centraleurope,
+- { mac_centraleurope_mbtowc, NULL }, { mac_centraleurope_wctomb, NULL })
+-
+-DEFENCODING(( "MacIceland", /* JDK 1.1 */
+- /*"CP10079", Windows */
+- ),
+- mac_iceland,
+- { mac_iceland_mbtowc, NULL }, { mac_iceland_wctomb, NULL })
+-
+-DEFENCODING(( "MacCroatian", /* JDK 1.1 */
+- /*"CP10082", Windows */
+- ),
+- mac_croatian,
+- { mac_croatian_mbtowc, NULL }, { mac_croatian_wctomb, NULL })
+-
+-DEFENCODING(( "MacRomania", /* JDK 1.1 */
+- /*"CP10010", Windows */
+- ),
+- mac_romania,
+- { mac_romania_mbtowc, NULL }, { mac_romania_wctomb, NULL })
+-
+-DEFENCODING(( "MacCyrillic", /* JDK 1.1 */
+- /*"CP10007", Windows */
+- ),
+- mac_cyrillic,
+- { mac_cyrillic_mbtowc, NULL }, { mac_cyrillic_wctomb, NULL })
+-
+-DEFENCODING(( "MacUkraine", /* JDK 1.1 */
+- /*"CP10017", Windows */
+- ),
+- mac_ukraine,
+- { mac_ukraine_mbtowc, NULL }, { mac_ukraine_wctomb, NULL })
+-
+-DEFENCODING(( "MacGreek", /* JDK 1.1 */
+- /*"CP10006", Windows */
+- ),
+- mac_greek,
+- { mac_greek_mbtowc, NULL }, { mac_greek_wctomb, NULL })
+-
+-DEFENCODING(( "MacTurkish", /* JDK 1.1 */
+- /*"CP10081", Windows */
+- ),
+- mac_turkish,
+- { mac_turkish_mbtowc, NULL }, { mac_turkish_wctomb, NULL })
+-
+-DEFENCODING(( "MacHebrew", /* JDK 1.1 */
+- /*"CP10005", Windows */
+- ),
+- mac_hebrew,
+- { mac_hebrew_mbtowc, NULL }, { mac_hebrew_wctomb, NULL })
+-
+-DEFENCODING(( "MacArabic", /* JDK 1.1 */
+- /*"CP10004", Windows */
+- ),
+- mac_arabic,
+- { mac_arabic_mbtowc, NULL }, { mac_arabic_wctomb, NULL })
+-
+-DEFENCODING(( "MacThai", /* JDK 1.1 */
+- /*"CP10021", Windows */
+- ),
+- mac_thai,
+- { mac_thai_mbtowc, NULL }, { mac_thai_wctomb, NULL })
+-
+-/* Other platform specific 8-bit encodings */
+-
+-DEFENCODING(( "HP-ROMAN8", /* IANA, X11R6.4 */
+- "ROMAN8", /* IANA */
+- "R8", /* IANA */
+- "csHPRoman8", /* IANA */
+- ),
+- hp_roman8,
+- { hp_roman8_mbtowc, NULL }, { hp_roman8_wctomb, NULL })
+-
+-DEFENCODING(( "NEXTSTEP",
+- ),
+- nextstep,
+- { nextstep_mbtowc, NULL }, { nextstep_wctomb, NULL })
+-
+-/* Regional 8-bit encodings used for a single language */
+-
+-DEFENCODING(( "ARMSCII-8",
+- ),
+- armscii_8,
+- { armscii_8_mbtowc, NULL }, { armscii_8_wctomb, NULL })
+-
+-DEFENCODING(( "GEORGIAN-ACADEMY",
+- ),
+- georgian_academy,
+- { georgian_academy_mbtowc, NULL }, { georgian_academy_wctomb, NULL })
+-
+-DEFENCODING(( "GEORGIAN-PS",
+- ),
+- georgian_ps,
+- { georgian_ps_mbtowc, NULL }, { georgian_ps_wctomb, NULL })
+-
+-DEFENCODING(( "KOI8-T",
+- ),
+- koi8_t,
+- { koi8_t_mbtowc, NULL }, { koi8_t_wctomb, NULL })
+-
+-DEFENCODING(( "PT154", /* IANA, glibc */
+- "PTCP154", /* IANA */
+- "CP154", /* IANA */
+- "CYRILLIC-ASIAN", /* IANA */
+- "csPTCP154", /* IANA */
+- ),
+- pt154,
+- { pt154_mbtowc, NULL }, { pt154_wctomb, NULL })
+-
+-DEFENCODING(( "MULELAO-1",
+- ),
+- mulelao,
+- { mulelao_mbtowc, NULL }, { mulelao_wctomb, NULL })
+-
+-DEFENCODING(( "CP1133",
+- "IBM-CP1133",
+- ),
+- cp1133,
+- { cp1133_mbtowc, NULL }, { cp1133_wctomb, NULL })
+-
+-DEFENCODING(( "TIS-620", /* IANA */
+- "TIS620", /* glibc */
+- "TIS620-0", /* glibc */
+- "TIS620.2529-1", /* glibc */
+- "TIS620.2533-0", /* glibc */
+- "TIS620.2533-1",
+- "ISO-IR-166", /* glibc */
+- ),
+- tis620,
+- { tis620_mbtowc, NULL }, { tis620_wctomb, NULL })
+-
+-DEFENCODING(( "CP874", /* JDK 1.1 */
+- "WINDOWS-874",
+- ),
+- cp874,
+- { cp874_mbtowc, NULL }, { cp874_wctomb, NULL })
+-
+-DEFENCODING(( "VISCII", /* IANA, RFC 1456 */
+- "VISCII1.1-1",
+- "csVISCII", /* IANA */
+- ),
+- viscii,
+- { viscii_mbtowc, NULL }, { viscii_wctomb, NULL })
+-
+-DEFENCODING(( "TCVN",
+- "TCVN-5712",
+- "TCVN5712-1",
+- "TCVN5712-1:1993",
+- ),
+- tcvn,
+- { tcvn_mbtowc, tcvn_flushwc }, { tcvn_wctomb, NULL })
+-
+-/* CJK character sets (not documented) */
+-
+-DEFENCODING(( "JIS_C6220-1969-RO", /* IANA */
+- "ISO646-JP", /* IANA */
+- "ISO-IR-14", /* IANA */
+- "JP", /* IANA */
+- "csISO14JISC6220ro", /* IANA */
+- ),
+- iso646_jp,
+- { iso646_jp_mbtowc, NULL }, { iso646_jp_wctomb, NULL })
+-
+-DEFENCODING(( "JIS_X0201", /* IANA */
+- "JISX0201-1976",
+- "X0201", /* IANA */
+- "csHalfWidthKatakana", /* IANA */
+- /*"JISX0201.1976-0", X11R6.4 */
+- /*"JIS0201", JDK 1.1 */
+- ),
+- jisx0201,
+- { jisx0201_mbtowc, NULL }, { jisx0201_wctomb, NULL })
+-
+-DEFENCODING(( "JIS_X0208",
+- "JIS_X0208-1983", /* IANA */
+- "JIS_X0208-1990",
+- "JIS0208",
+- "X0208", /* IANA */
+- "ISO-IR-87", /* IANA */
+- "JIS_C6226-1983", /* IANA */
+- "csISO87JISX0208", /* IANA */
+- /*"JISX0208.1983-0", X11R6.4 */
+- /*"JISX0208.1990-0", X11R6.4 */
+- /*"JIS0208", JDK 1.1 */
+- ),
+- jisx0208,
+- { jisx0208_mbtowc, NULL }, { jisx0208_wctomb, NULL })
+-
+-DEFENCODING(( "JIS_X0212",
+- "JIS_X0212.1990-0",
+- "JIS_X0212-1990", /* IANA */
+- "X0212", /* IANA */
+- "ISO-IR-159", /* IANA */
+- "csISO159JISX02121990", /* IANA */
+- /*"JISX0212.1990-0", X11R6.4 */
+- /*"JIS0212", JDK 1.1 */
+- ),
+- jisx0212,
+- { jisx0212_mbtowc, NULL }, { jisx0212_wctomb, NULL })
+-
+-DEFENCODING(( "GB_1988-80", /* IANA */
+- "ISO646-CN", /* IANA */
+- "ISO-IR-57", /* IANA */
+- "CN", /* IANA */
+- "csISO57GB1988", /* IANA */
+- ),
+- iso646_cn,
+- { iso646_cn_mbtowc, NULL }, { iso646_cn_wctomb, NULL })
+-
+-DEFENCODING(( "GB_2312-80", /* IANA */
+- "ISO-IR-58", /* IANA */
+- "csISO58GB231280", /* IANA */
+- "CHINESE", /* IANA */
+- /*"GB2312.1980-0", X11R6.4 */
+- ),
+- gb2312,
+- { gb2312_mbtowc, NULL }, { gb2312_wctomb, NULL })
+-
+-DEFENCODING(( "ISO-IR-165",
+- "CN-GB-ISOIR165", /* RFC 1922 */
+- ),
+- isoir165,
+- { isoir165_mbtowc, NULL }, { isoir165_wctomb, NULL })
+-
+-DEFENCODING(( "KSC_5601", /* IANA */
+- "KS_C_5601-1987", /* IANA */
+- "KS_C_5601-1989", /* IANA */
+- "ISO-IR-149", /* IANA */
+- "csKSC56011987", /* IANA */
+- "KOREAN", /* IANA */
+- /*"KSC5601.1987-0", X11R6.4 */
+- /*"KSX1001:1992", Ken Lunde */
+- ),
+- ksc5601,
+- { ksc5601_mbtowc, NULL }, { ksc5601_wctomb, NULL })
+-
+-/* CJK encodings */
+-
+-DEFENCODING(( "EUC-JP", /* IANA */
+- "EUCJP", /* glibc */
+- "Extended_UNIX_Code_Packed_Format_for_Japanese", /* IANA */
+- "csEUCPkdFmtJapanese", /* IANA */
+- /*"EUC_JP", JDK 1.1 */
+- /*"CP51932", Windows */
+- ),
+- euc_jp,
+- { euc_jp_mbtowc, NULL }, { euc_jp_wctomb, NULL })
+-
+-DEFENCODING(( "SHIFT_JIS", /* IANA */
+- "SHIFT-JIS", /* glibc */
+- "SJIS", /* JDK 1.1 */
+- "MS_KANJI", /* IANA */
+- "csShiftJIS", /* IANA */
+- ),
+- sjis,
+- { sjis_mbtowc, NULL }, { sjis_wctomb, NULL })
+-
+-DEFENCODING(( "CP932", /* glibc */
+- ),
+- cp932,
+- { cp932_mbtowc, NULL }, { cp932_wctomb, NULL })
+-
+-DEFENCODING(( "ISO-2022-JP", /* IANA, RFC 1468 */
+- "csISO2022JP", /* IANA */
+- /*"ISO2022JP", JDK 1.1 */
+- ),
+- iso2022_jp,
+- { iso2022_jp_mbtowc, NULL }, { iso2022_jp_wctomb, iso2022_jp_reset })
+-
+-DEFENCODING(( "ISO-2022-JP-1", /* RFC 2237 */
+- ),
+- iso2022_jp1,
+- { iso2022_jp1_mbtowc, NULL }, { iso2022_jp1_wctomb, iso2022_jp1_reset })
+-
+-DEFENCODING(( "ISO-2022-JP-2", /* IANA, RFC 1554 */
+- "csISO2022JP2", /* IANA */
+- ),
+- iso2022_jp2,
+- { iso2022_jp2_mbtowc, NULL }, { iso2022_jp2_wctomb, iso2022_jp2_reset })
+-
+-DEFENCODING(( "EUC-CN", /* glibc */
+- "EUCCN", /* glibc */
+- "GB2312", /* IANA */
+- "CN-GB", /* RFC 1922 */
+- "csGB2312", /* IANA */
+- /*"EUC_CN", JDK 1.1 */
+- /*"CP51936", Windows */
+- ),
+- euc_cn,
+- { euc_cn_mbtowc, NULL }, { euc_cn_wctomb, NULL })
+-
+-DEFENCODING(( "GBK", /* IANA, JDK 1.1 */
+- ),
+- ces_gbk,
+- { ces_gbk_mbtowc, NULL }, { ces_gbk_wctomb, NULL })
+-
+-DEFENCODING(( "CP936", /* IANA */
+- "MS936", /* IANA */
+- "WINDOWS-936", /* IANA */
+- ),
+- cp936,
+- { cp936_mbtowc, NULL }, { cp936_wctomb, NULL })
+-
+-DEFENCODING(( "GB18030", /* IANA, glibc */
+- /*"CP54936", Windows */
+- ),
+- gb18030,
+- { gb18030_mbtowc, NULL }, { gb18030_wctomb, NULL })
+-
+-DEFENCODING(( "ISO-2022-CN", /* IANA, RFC 1922 */
+- "csISO2022CN",
+- /*"ISO2022CN", JDK 1.1 */
+- ),
+- iso2022_cn,
+- { iso2022_cn_mbtowc, NULL }, { iso2022_cn_wctomb, iso2022_cn_reset })
+-
+-DEFENCODING(( "ISO-2022-CN-EXT", /* IANA, RFC 1922 */
+- ),
+- iso2022_cn_ext,
+- { iso2022_cn_ext_mbtowc, NULL }, { iso2022_cn_ext_wctomb, iso2022_cn_ext_reset })
+-
+-DEFENCODING(( "HZ", /* RFC 1843 */
+- "HZ-GB-2312", /* IANA, RFC 1842 */
+- ),
+- hz,
+- { hz_mbtowc, NULL }, { hz_wctomb, hz_reset })
+-
+-DEFENCODING(( "EUC-TW", /* glibc */
+- "EUCTW", /* glibc */
+- "csEUCTW",
+- /*"EUC_TW", JDK 1.1 */
+- /*"CP51950", Windows */
+- ),
+- euc_tw,
+- { euc_tw_mbtowc, NULL }, { euc_tw_wctomb, NULL })
+-
+-DEFENCODING(( "BIG5", /* IANA, JDK 1.1 */
+- "BIG-5", /* glibc */
+- "BIG-FIVE", /* glibc */
+- "BIGFIVE", /* glibc */
+- "CN-BIG5", /* RFC 1922 */
+- "csBig5", /* IANA */
+- ),
+- ces_big5,
+- { ces_big5_mbtowc, NULL }, { ces_big5_wctomb, NULL })
+-
+-DEFENCODING(( "CP950", /* JDK 1.1 */
+- ),
+- cp950,
+- { cp950_mbtowc, NULL }, { cp950_wctomb, NULL })
+-
+-DEFENCODING(( "BIG5-HKSCS:1999",
+- ),
+- big5hkscs1999,
+- { big5hkscs1999_mbtowc, big5hkscs1999_flushwc }, { big5hkscs1999_wctomb, big5hkscs1999_reset })
+-
+-DEFENCODING(( "BIG5-HKSCS:2001",
+- ),
+- big5hkscs2001,
+- { big5hkscs2001_mbtowc, big5hkscs2001_flushwc }, { big5hkscs2001_wctomb, big5hkscs2001_reset })
+-
+-DEFENCODING(( "BIG5-HKSCS", /* IANA */
+- "BIG5HKSCS", /* glibc */
+- "BIG5-HKSCS:2004",
+- ),
+- big5hkscs2004,
+- { big5hkscs2004_mbtowc, big5hkscs2004_flushwc }, { big5hkscs2004_wctomb, big5hkscs2004_reset })
+-
+-DEFENCODING(( "EUC-KR", /* IANA, RFC 1557 */
+- "EUCKR", /* glibc */
+- "csEUCKR", /* IANA */
+- /*"EUC_KR", JDK 1.1 */
+- /*"CP51949", Windows */
+- ),
+- euc_kr,
+- { euc_kr_mbtowc, NULL }, { euc_kr_wctomb, NULL })
+-
+-DEFENCODING(( "CP949", /* JDK 1.1 */
+- "UHC", /* glibc */
+- ),
+- cp949,
+- { cp949_mbtowc, NULL }, { cp949_wctomb, NULL })
+-
+-DEFENCODING(( "JOHAB", /* glibc */
+- "CP1361", /* glibc */
+- ),
+- johab,
+- { johab_mbtowc, NULL }, { johab_wctomb, NULL })
+-
+-DEFENCODING(( "ISO-2022-KR", /* IANA, RFC 1557 */
+- "csISO2022KR", /* IANA */
+- /*"ISO2022KR", JDK 1.1 */
+- ),
+- iso2022_kr,
+- { iso2022_kr_mbtowc, NULL }, { iso2022_kr_wctomb, iso2022_kr_reset })
+-
+--- a/lib/encodings_dos.def
++++ b/lib/encodings_dos.def
+@@ -26,102 +26,3 @@ DEFENCODING(( "CP437",
+ cp437,
+ { cp437_mbtowc, NULL }, { cp437_wctomb, NULL })
+
+-DEFENCODING(( "CP737", /* JDK 1.1 */
+- ),
+- cp737,
+- { cp737_mbtowc, NULL }, { cp737_wctomb, NULL })
+-
+-DEFENCODING(( "CP775", /* IANA, JDK 1.1 */
+- "IBM775", /* IANA */
+- "csPC775Baltic", /* IANA */
+- ),
+- cp775,
+- { cp775_mbtowc, NULL }, { cp775_wctomb, NULL })
+-
+-DEFENCODING(( "CP852", /* IANA, JDK 1.1 */
+- "IBM852", /* IANA */
+- "852", /* IANA */
+- "csPCp852", /* IANA */
+- ),
+- cp852,
+- { cp852_mbtowc, NULL }, { cp852_wctomb, NULL })
+-
+-DEFENCODING(( "CP853",
+- ),
+- cp853,
+- { cp853_mbtowc, NULL }, { cp853_wctomb, NULL })
+-
+-DEFENCODING(( "CP855", /* IANA, JDK 1.1 */
+- "IBM855", /* IANA */
+- "855", /* IANA */
+- "csIBM855", /* IANA */
+- ),
+- cp855,
+- { cp855_mbtowc, NULL }, { cp855_wctomb, NULL })
+-
+-DEFENCODING(( "CP857", /* IANA, JDK 1.1 */
+- "IBM857", /* IANA */
+- "857", /* IANA */
+- "csIBM857", /* IANA */
+- ),
+- cp857,
+- { cp857_mbtowc, NULL }, { cp857_wctomb, NULL })
+-
+-DEFENCODING(( "CP858", /* JDK 1.1.7 */
+- ),
+- cp858,
+- { cp858_mbtowc, NULL }, { cp858_wctomb, NULL })
+-
+-DEFENCODING(( "CP860", /* IANA, JDK 1.1 */
+- "IBM860", /* IANA */
+- "860", /* IANA */
+- "csIBM860", /* IANA */
+- ),
+- cp860,
+- { cp860_mbtowc, NULL }, { cp860_wctomb, NULL })
+-
+-DEFENCODING(( "CP861", /* IANA, JDK 1.1 */
+- "IBM861", /* IANA */
+- "861", /* IANA */
+- "CP-IS", /* IANA */
+- "csIBM861", /* IANA */
+- ),
+- cp861,
+- { cp861_mbtowc, NULL }, { cp861_wctomb, NULL })
+-
+-DEFENCODING(( "CP863", /* IANA, JDK 1.1 */
+- "IBM863", /* IANA */
+- "863", /* IANA */
+- "csIBM863", /* IANA */
+- ),
+- cp863,
+- { cp863_mbtowc, NULL }, { cp863_wctomb, NULL })
+-
+-DEFENCODING(( "CP864", /* IANA, JDK 1.1 */
+- "IBM864", /* IANA */
+- "csIBM864", /* IANA */
+- ),
+- cp864,
+- { cp864_mbtowc, NULL }, { cp864_wctomb, NULL })
+-
+-DEFENCODING(( "CP865", /* IANA, JDK 1.1 */
+- "IBM865", /* IANA */
+- "865", /* IANA */
+- "csIBM865", /* IANA */
+- ),
+- cp865,
+- { cp865_mbtowc, NULL }, { cp865_wctomb, NULL })
+-
+-DEFENCODING(( "CP869", /* IANA, JDK 1.1 */
+- "IBM869", /* IANA */
+- "869", /* IANA */
+- "CP-GR", /* IANA */
+- "csIBM869", /* IANA */
+- ),
+- cp869,
+- { cp869_mbtowc, NULL }, { cp869_wctomb, NULL })
+-
+-DEFENCODING(( "CP1125", /* ICU */
+- ),
+- cp1125,
+- { cp1125_mbtowc, NULL }, { cp1125_wctomb, NULL })
+--- a/lib/loop_unicode.h
++++ b/lib/loop_unicode.h
+@@ -24,14 +24,15 @@
+ static int unicode_transliterate (conv_t cd, ucs4_t wc,
+ unsigned char* outptr, size_t outleft)
+ {
++/*
+ if (cd->oflags & HAVE_HANGUL_JAMO) {
+- /* Decompose Hangul into Jamo. Use double-width Jamo (contained
++ /-* Decompose Hangul into Jamo. Use double-width Jamo (contained
+ in all Korean encodings and ISO-2022-JP-2), not half-width Jamo
+- (contained in Unicode only). */
++ (contained in Unicode only). *-/
+ ucs4_t buf[3];
+ int ret = johab_hangul_decompose(cd,buf,wc);
+ if (ret != RET_ILUNI) {
+- /* we know 1 <= ret <= 3 */
++ /-* we know 1 <= ret <= 3 *-/
+ state_t backup_state = cd->ostate;
+ unsigned char* backup_outptr = outptr;
+ size_t backup_outleft = outleft;
+@@ -57,9 +58,9 @@ static int unicode_transliterate (conv_t
+ }
+ }
+ {
+- /* Try to use a variant, but postfix it with
++ /-* Try to use a variant, but postfix it with
+ U+303E IDEOGRAPHIC VARIATION INDICATOR
+- (cf. Ken Lunde's "CJKV information processing", p. 188). */
++ (cf. Ken Lunde's "CJKV information processing", p. 188). *-/
+ int indx = -1;
+ if (wc == 0x3006)
+ indx = 0;
+@@ -105,20 +106,20 @@ static int unicode_transliterate (conv_t
+ }
+ }
+ if (wc >= 0x2018 && wc <= 0x201a) {
+- /* Special case for quotation marks 0x2018, 0x2019, 0x201a */
++ /-* Special case for quotation marks 0x2018, 0x2019, 0x201a *-/
+ ucs4_t substitute =
+ (cd->oflags & HAVE_QUOTATION_MARKS
+ ? (wc == 0x201a ? 0x2018 : wc)
+ : (cd->oflags & HAVE_ACCENTS
+- ? (wc==0x2019 ? 0x00b4 : 0x0060) /* use accents */
+- : 0x0027 /* use apostrophe */
++ ? (wc==0x2019 ? 0x00b4 : 0x0060) /-* use accents *-/
++ : 0x0027 /-* use apostrophe *-/
+ ) );
+ int outcount = cd->ofuncs.xxx_wctomb(cd,outptr,substitute,outleft);
+ if (outcount != RET_ILUNI)
+ return outcount;
+ }
+ {
+- /* Use the transliteration table. */
++ /-* Use the transliteration table. *-/
+ int indx = translit_index(wc);
+ if (indx >= 0) {
+ const unsigned int * cp = &translit_data[indx];
+@@ -135,7 +136,7 @@ static int unicode_transliterate (conv_t
+ }
+ sub_outcount = cd->ofuncs.xxx_wctomb(cd,outptr,cp[i],outleft);
+ if (sub_outcount == RET_ILUNI)
+- /* Recursive transliteration. */
++ /-* Recursive transliteration. *-/
+ sub_outcount = unicode_transliterate(cd,cp[i],outptr,outleft);
+ if (sub_outcount <= RET_ILUNI)
+ goto translit_failed;
+@@ -151,6 +152,7 @@ static int unicode_transliterate (conv_t
+ return RET_TOOSMALL;
+ }
+ }
++*/
+ return RET_ILUNI;
+ }
+
diff --git a/package/libs/libiconv-full/patches/101-autotools.patch b/package/libs/libiconv-full/patches/101-autotools.patch
new file mode 100644
index 0000000..f8fdce5
--- /dev/null
+++ b/package/libs/libiconv-full/patches/101-autotools.patch
@@ -0,0 +1,26014 @@
+--- a/libcharset/configure.ac
++++ b/libcharset/configure.ac
+@@ -16,17 +16,17 @@ dnl along with the GNU CHARSET Library;
+ dnl write to the Free Software Foundation, Inc., 51 Franklin Street,
+ dnl Fifth Floor, Boston, MA 02110-1301, USA.
+
+-AC_PREREQ(2.13)
++AC_PREREQ(2.61)
++AC_INIT([libcharset],[1.4] )
++AC_CONFIG_SRCDIR([lib/localcharset.c])
+
+-PACKAGE=libcharset
+-VERSION=1.4
+-
+-AC_INIT(lib/localcharset.c)
+ AC_CONFIG_AUX_DIR(build-aux)
+ AC_CONFIG_HEADER(config.h)
+ AC_PROG_MAKE_SET
+-AC_SUBST(PACKAGE)
+-AC_SUBST(VERSION)
++dnl AC_SUBST(PACKAGE)
++dnl AC_SUBST(VERSION)
++
++AC_CONFIG_MACRO_DIR([m4])
+
+ dnl checks for basic programs
+
+--- a/configure.ac
++++ b/configure.ac
+@@ -24,6 +24,8 @@ AM_INIT_AUTOMAKE(libiconv, 1.11)
+ AC_CONFIG_HEADERS(config.h lib/config.h)
+ AC_PROG_MAKE_SET
+
++AC_CONFIG_MACRO_DIR([m4])
++
+ dnl checks for basic programs
+
+ AC_PROG_CC
+--- a/libcharset/m4/libtool.m4
++++ b/libcharset/m4/libtool.m4
+@@ -1,107 +1,186 @@
+ # libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-
+-## Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006
+-## Free Software Foundation, Inc.
+-## Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
+-##
+-## This file is free software; the Free Software Foundation gives
+-## unlimited permission to copy and/or distribute it, with or without
+-## modifications, as long as this notice is preserved.
+-
+-# serial 48 AC_PROG_LIBTOOL
+-
+-
+-# AC_PROVIDE_IFELSE(MACRO-NAME, IF-PROVIDED, IF-NOT-PROVIDED)
+-# -----------------------------------------------------------
+-# If this macro is not defined by Autoconf, define it here.
+-m4_ifdef([AC_PROVIDE_IFELSE],
+- [],
+- [m4_define([AC_PROVIDE_IFELSE],
+- [m4_ifdef([AC_PROVIDE_$1],
+- [$2], [$3])])])
++#
++# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
++# 2006, 2007, 2008 Free Software Foundation, Inc.
++# Written by Gordon Matzigkeit, 1996
++#
++# This file is free software; the Free Software Foundation gives
++# unlimited permission to copy and/or distribute it, with or without
++# modifications, as long as this notice is preserved.
++
++m4_define([_LT_COPYING], [dnl
++# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
++# 2006, 2007, 2008 Free Software Foundation, Inc.
++# Written by Gordon Matzigkeit, 1996
++#
++# This file is part of GNU Libtool.
++#
++# GNU Libtool 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.
++#
++# As a special exception to the GNU General Public License,
++# if you distribute this file as part of a program or library that
++# is built using GNU Libtool, you may include this file under the
++# same distribution terms that you use for the rest of that program.
++#
++# GNU Libtool 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 GNU Libtool; see the file COPYING. If not, a copy
++# can be downloaded from http://www.gnu.org/licenses/gpl.html, or
++# obtained by writing to the Free Software Foundation, Inc.,
++# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
++])
+
++# serial 56 LT_INIT
+
+-# AC_PROG_LIBTOOL
+-# ---------------
+-AC_DEFUN([AC_PROG_LIBTOOL],
+-[AC_REQUIRE([_AC_PROG_LIBTOOL])dnl
+-dnl If AC_PROG_CXX has already been expanded, run AC_LIBTOOL_CXX
+-dnl immediately, otherwise, hook it in at the end of AC_PROG_CXX.
+- AC_PROVIDE_IFELSE([AC_PROG_CXX],
+- [AC_LIBTOOL_CXX],
+- [define([AC_PROG_CXX], defn([AC_PROG_CXX])[AC_LIBTOOL_CXX
+- ])])
+-dnl And a similar setup for Fortran 77 support
+- AC_PROVIDE_IFELSE([AC_PROG_F77],
+- [AC_LIBTOOL_F77],
+- [define([AC_PROG_F77], defn([AC_PROG_F77])[AC_LIBTOOL_F77
+-])])
+-
+-dnl Quote A][M_PROG_GCJ so that aclocal doesn't bring it in needlessly.
+-dnl If either AC_PROG_GCJ or A][M_PROG_GCJ have already been expanded, run
+-dnl AC_LIBTOOL_GCJ immediately, otherwise, hook it in at the end of both.
+- AC_PROVIDE_IFELSE([AC_PROG_GCJ],
+- [AC_LIBTOOL_GCJ],
+- [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],
+- [AC_LIBTOOL_GCJ],
+- [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ],
+- [AC_LIBTOOL_GCJ],
+- [ifdef([AC_PROG_GCJ],
+- [define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[AC_LIBTOOL_GCJ])])
+- ifdef([A][M_PROG_GCJ],
+- [define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[AC_LIBTOOL_GCJ])])
+- ifdef([LT_AC_PROG_GCJ],
+- [define([LT_AC_PROG_GCJ],
+- defn([LT_AC_PROG_GCJ])[AC_LIBTOOL_GCJ])])])])
+-])])# AC_PROG_LIBTOOL
+
++# LT_PREREQ(VERSION)
++# ------------------
++# Complain and exit if this libtool version is less that VERSION.
++m4_defun([LT_PREREQ],
++[m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1,
++ [m4_default([$3],
++ [m4_fatal([Libtool version $1 or higher is required],
++ 63)])],
++ [$2])])
+
+-# _AC_PROG_LIBTOOL
+-# ----------------
+-AC_DEFUN([_AC_PROG_LIBTOOL],
+-[AC_REQUIRE([AC_LIBTOOL_SETUP])dnl
+-AC_BEFORE([$0],[AC_LIBTOOL_CXX])dnl
+-AC_BEFORE([$0],[AC_LIBTOOL_F77])dnl
+-AC_BEFORE([$0],[AC_LIBTOOL_GCJ])dnl
++
++# _LT_CHECK_BUILDDIR
++# ------------------
++# Complain if the absolute build directory name contains unusual characters
++m4_defun([_LT_CHECK_BUILDDIR],
++[case `pwd` in
++ *\ * | *\ *)
++ AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;;
++esac
++])
++
++
++# LT_INIT([OPTIONS])
++# ------------------
++AC_DEFUN([LT_INIT],
++[AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT
++AC_BEFORE([$0], [LT_LANG])dnl
++AC_BEFORE([$0], [LT_OUTPUT])dnl
++AC_BEFORE([$0], [LTDL_INIT])dnl
++m4_require([_LT_CHECK_BUILDDIR])dnl
++
++dnl Autoconf doesn't catch unexpanded LT_ macros by default:
++m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl
++m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl
++dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4
++dnl unless we require an AC_DEFUNed macro:
++AC_REQUIRE([LTOPTIONS_VERSION])dnl
++AC_REQUIRE([LTSUGAR_VERSION])dnl
++AC_REQUIRE([LTVERSION_VERSION])dnl
++AC_REQUIRE([LTOBSOLETE_VERSION])dnl
++m4_require([_LT_PROG_LTMAIN])dnl
++
++dnl Parse OPTIONS
++_LT_SET_OPTIONS([$0], [$1])
+
+ # This can be used to rebuild libtool when needed
+-LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh"
++LIBTOOL_DEPS="$ltmain"
+
+ # Always use our own libtool.
+-LIBTOOL='$(SHELL) $(top_builddir)/libtool'
++LIBTOOL='$(SHELL) $(top_builddir)'
++LIBTOOL="$LIBTOOL/$host_alias-libtool"
+ AC_SUBST(LIBTOOL)dnl
+
+-# Prevent multiple expansion
+-define([AC_PROG_LIBTOOL], [])
+-])# _AC_PROG_LIBTOOL
++_LT_SETUP
+
++# Only expand once:
++m4_define([LT_INIT])
++])# LT_INIT
++
++# Old names:
++AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT])
++AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT])
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([AC_PROG_LIBTOOL], [])
++dnl AC_DEFUN([AM_PROG_LIBTOOL], [])
+
+-# AC_LIBTOOL_SETUP
+-# ----------------
+-AC_DEFUN([AC_LIBTOOL_SETUP],
+-[AC_PREREQ(2.50)dnl
+-AC_REQUIRE([AC_ENABLE_SHARED])dnl
+-AC_REQUIRE([AC_ENABLE_STATIC])dnl
+-AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl
+-AC_REQUIRE([AC_CANONICAL_HOST])dnl
++
++# _LT_CC_BASENAME(CC)
++# -------------------
++# Calculate cc_basename. Skip known compiler wrappers and cross-prefix.
++m4_defun([_LT_CC_BASENAME],
++[for cc_temp in $1""; do
++ case $cc_temp in
++ compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;;
++ distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;;
++ \-*) ;;
++ *) break;;
++ esac
++done
++cc_basename=`$ECHO "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
++])
++
++
++# _LT_FILEUTILS_DEFAULTS
++# ----------------------
++# It is okay to use these file commands and assume they have been set
++# sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'.
++m4_defun([_LT_FILEUTILS_DEFAULTS],
++[: ${CP="cp -f"}
++: ${MV="mv -f"}
++: ${RM="rm -f"}
++])# _LT_FILEUTILS_DEFAULTS
++
++
++# _LT_SETUP
++# ---------
++m4_defun([_LT_SETUP],
++[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+ AC_REQUIRE([AC_CANONICAL_BUILD])dnl
++_LT_DECL([], [host_alias], [0], [The host system])dnl
++_LT_DECL([], [host], [0])dnl
++_LT_DECL([], [host_os], [0])dnl
++dnl
++_LT_DECL([], [build_alias], [0], [The build system])dnl
++_LT_DECL([], [build], [0])dnl
++_LT_DECL([], [build_os], [0])dnl
++dnl
+ AC_REQUIRE([AC_PROG_CC])dnl
+-AC_REQUIRE([AC_PROG_LD])dnl
+-AC_REQUIRE([AC_PROG_LD_RELOAD_FLAG])dnl
+-AC_REQUIRE([AC_PROG_NM])dnl
+-
++AC_REQUIRE([LT_PATH_LD])dnl
++AC_REQUIRE([LT_PATH_NM])dnl
++dnl
+ AC_REQUIRE([AC_PROG_LN_S])dnl
+-AC_REQUIRE([AC_DEPLIBS_CHECK_METHOD])dnl
+-# Autoconf 2.13's AC_OBJEXT and AC_EXEEXT macros only works for C compilers!
+-AC_REQUIRE([AC_OBJEXT])dnl
+-AC_REQUIRE([AC_EXEEXT])dnl
++test -z "$LN_S" && LN_S="ln -s"
++_LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl
+ dnl
++AC_REQUIRE([LT_CMD_MAX_LEN])dnl
++_LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl
++_LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl
++dnl
++m4_require([_LT_FILEUTILS_DEFAULTS])dnl
++m4_require([_LT_CHECK_SHELL_FEATURES])dnl
++m4_require([_LT_CMD_RELOAD])dnl
++m4_require([_LT_CHECK_MAGIC_METHOD])dnl
++m4_require([_LT_CMD_OLD_ARCHIVE])dnl
++m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl
++
++_LT_CONFIG_LIBTOOL_INIT([
++# See if we are running on zsh, and set the options which allow our
++# commands through without removal of \ escapes INIT.
++if test -n "\${ZSH_VERSION+set}" ; then
++ setopt NO_GLOB_SUBST
++fi
++])
++if test -n "${ZSH_VERSION+set}" ; then
++ setopt NO_GLOB_SUBST
++fi
+
+-AC_LIBTOOL_SYS_MAX_CMD_LEN
+-AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE
+-AC_LIBTOOL_OBJDIR
++_LT_CHECK_OBJDIR
+
+-AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl
+-_LT_AC_PROG_ECHO_BACKSLASH
++m4_require([_LT_TAG_COMPILER])dnl
++_LT_PROG_ECHO_BACKSLASH
+
+ case $host_os in
+ aix3*)
+@@ -117,6307 +196,6803 @@ esac
+
+ # Sed substitution that helps us do robust quoting. It backslashifies
+ # metacharacters that are still active within double-quoted strings.
+-Xsed='sed -e 1s/^X//'
+-[sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g']
++sed_quote_subst='s/\([["`$\\]]\)/\\\1/g'
+
+ # Same as above, but do not quote variable references.
+-[double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g']
++double_quote_subst='s/\([["`\\]]\)/\\\1/g'
+
+ # Sed substitution to delay expansion of an escaped shell variable in a
+ # double_quote_subst'ed string.
+ delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
+
++# Sed substitution to delay expansion of an escaped single quote.
++delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g'
++
+ # Sed substitution to avoid accidental globbing in evaled expressions
+ no_glob_subst='s/\*/\\\*/g'
+
+-# Constants:
+-rm="rm -f"
+-
+ # Global variables:
+-default_ofile=libtool
++ofile=${host_alias}-libtool
+ can_build_shared=yes
+
+ # All known linkers require a `.a' archive for static linking (except MSVC,
+ # which needs '.lib').
+ libext=a
+-ltmain="$ac_aux_dir/ltmain.sh"
+-ofile="$default_ofile"
+-with_gnu_ld="$lt_cv_prog_gnu_ld"
+
+-AC_CHECK_TOOL(AR, ar, false)
+-AC_CHECK_TOOL(RANLIB, ranlib, :)
+-AC_CHECK_TOOL(STRIP, strip, :)
++with_gnu_ld="$lt_cv_prog_gnu_ld"
+
+ old_CC="$CC"
+ old_CFLAGS="$CFLAGS"
+
+ # Set sane defaults for various variables
+-test -z "$AR" && AR=ar
+-test -z "$AR_FLAGS" && AR_FLAGS=cru
+-test -z "$AS" && AS=as
+ test -z "$CC" && CC=cc
+ test -z "$LTCC" && LTCC=$CC
+ test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
+-test -z "$DLLTOOL" && DLLTOOL=dlltool
+ test -z "$LD" && LD=ld
+-test -z "$LN_S" && LN_S="ln -s"
+-test -z "$MAGIC_CMD" && MAGIC_CMD=file
+-test -z "$NM" && NM=nm
+-test -z "$SED" && SED=sed
+-test -z "$OBJDUMP" && OBJDUMP=objdump
+-test -z "$RANLIB" && RANLIB=:
+-test -z "$STRIP" && STRIP=:
+ test -z "$ac_objext" && ac_objext=o
+
+-# Determine commands to create old-style static archives.
+-old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs'
+-old_postinstall_cmds='chmod 644 $oldlib'
+-old_postuninstall_cmds=
+-
+-if test -n "$RANLIB"; then
+- case $host_os in
+- openbsd*)
+- old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib"
+- ;;
+- *)
+- old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib"
+- ;;
+- esac
+- old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
+-fi
+-
+ _LT_CC_BASENAME([$compiler])
+
+ # Only perform the check for file, if the check method requires it
++test -z "$MAGIC_CMD" && MAGIC_CMD=file
+ case $deplibs_check_method in
+ file_magic*)
+ if test "$file_magic_cmd" = '$MAGIC_CMD'; then
+- AC_PATH_MAGIC
++ _LT_PATH_MAGIC
+ fi
+ ;;
+ esac
+
+-AC_PROVIDE_IFELSE([AC_LIBTOOL_DLOPEN], enable_dlopen=yes, enable_dlopen=no)
+-AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL],
+-enable_win32_dll=yes, enable_win32_dll=no)
+-
+-AC_ARG_ENABLE([libtool-lock],
+- [AC_HELP_STRING([--disable-libtool-lock],
+- [avoid locking (might break parallel builds)])])
+-test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
++# Use C for the default configuration in the libtool script
++LT_SUPPORTED_TAG([CC])
++_LT_LANG_C_CONFIG
++_LT_LANG_DEFAULT_CONFIG
++_LT_CONFIG_COMMANDS
++])# _LT_SETUP
+
+-AC_ARG_WITH([pic],
+- [AC_HELP_STRING([--with-pic],
+- [try to use only PIC/non-PIC objects @<:@default=use both@:>@])],
+- [pic_mode="$withval"],
+- [pic_mode=default])
+-test -z "$pic_mode" && pic_mode=default
+
+-# Use C for the default configuration in the libtool script
+-tagname=
+-AC_LIBTOOL_LANG_C_CONFIG
+-_LT_AC_TAGCONFIG
+-])# AC_LIBTOOL_SETUP
++# _LT_PROG_LTMAIN
++# ---------------
++# Note that this code is called both from `configure', and `config.status'
++# now that we use AC_CONFIG_COMMANDS to generate libtool. Notably,
++# `config.status' has no value for ac_aux_dir unless we are using Automake,
++# so we pass a copy along to make sure it has a sensible value anyway.
++m4_defun([_LT_PROG_LTMAIN],
++[m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl
++_LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir'])
++ltmain="$ac_aux_dir/ltmain.sh"
++])# _LT_PROG_LTMAIN
+
+
+-# _LT_AC_SYS_COMPILER
+-# -------------------
+-AC_DEFUN([_LT_AC_SYS_COMPILER],
+-[AC_REQUIRE([AC_PROG_CC])dnl
++## ------------------------------------- ##
++## Accumulate code for creating libtool. ##
++## ------------------------------------- ##
++
++# So that we can recreate a full libtool script including additional
++# tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS
++# in macros and then make a single call at the end using the `libtool'
++# label.
++
++
++# _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS])
++# ----------------------------------------
++# Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later.
++m4_define([_LT_CONFIG_LIBTOOL_INIT],
++[m4_ifval([$1],
++ [m4_append([_LT_OUTPUT_LIBTOOL_INIT],
++ [$1
++])])])
++
++# Initialize.
++m4_define([_LT_OUTPUT_LIBTOOL_INIT])
++
++
++# _LT_CONFIG_LIBTOOL([COMMANDS])
++# ------------------------------
++# Register COMMANDS to be passed to AC_CONFIG_COMMANDS later.
++m4_define([_LT_CONFIG_LIBTOOL],
++[m4_ifval([$1],
++ [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS],
++ [$1
++])])])
++
++# Initialize.
++m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS])
++
++
++# _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS])
++# -----------------------------------------------------
++m4_defun([_LT_CONFIG_SAVE_COMMANDS],
++[_LT_CONFIG_LIBTOOL([$1])
++_LT_CONFIG_LIBTOOL_INIT([$2])
++])
+
+-# If no C compiler was specified, use CC.
+-LTCC=${LTCC-"$CC"}
+
+-# If no C compiler flags were specified, use CFLAGS.
+-LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
++# _LT_FORMAT_COMMENT([COMMENT])
++# -----------------------------
++# Add leading comment marks to the start of each line, and a trailing
++# full-stop to the whole comment if one is not present already.
++m4_define([_LT_FORMAT_COMMENT],
++[m4_ifval([$1], [
++m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])],
++ [['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.])
++)])
+
+-# Allow CC to be a program name with arguments.
+-compiler=$CC
+-])# _LT_AC_SYS_COMPILER
+
+
+-# _LT_CC_BASENAME(CC)
+-# -------------------
+-# Calculate cc_basename. Skip known compiler wrappers and cross-prefix.
+-AC_DEFUN([_LT_CC_BASENAME],
+-[for cc_temp in $1""; do
+- case $cc_temp in
+- compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;;
+- distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;;
+- \-*) ;;
+- *) break;;
+- esac
+-done
+-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
++## ------------------------ ##
++## FIXME: Eliminate VARNAME ##
++## ------------------------ ##
++
++
++# _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?])
++# -------------------------------------------------------------------
++# CONFIGNAME is the name given to the value in the libtool script.
++# VARNAME is the (base) name used in the configure script.
++# VALUE may be 0, 1 or 2 for a computed quote escaped value based on
++# VARNAME. Any other value will be used directly.
++m4_define([_LT_DECL],
++[lt_if_append_uniq([lt_decl_varnames], [$2], [, ],
++ [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name],
++ [m4_ifval([$1], [$1], [$2])])
++ lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3])
++ m4_ifval([$4],
++ [lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])])
++ lt_dict_add_subkey([lt_decl_dict], [$2],
++ [tagged?], [m4_ifval([$5], [yes], [no])])])
+ ])
+
+
+-# _LT_COMPILER_BOILERPLATE
+-# ------------------------
+-# Check for compiler boilerplate output or warnings with
+-# the simple compiler test code.
+-AC_DEFUN([_LT_COMPILER_BOILERPLATE],
+-[ac_outfile=conftest.$ac_objext
+-printf "$lt_simple_compile_test_code" >conftest.$ac_ext
+-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+-_lt_compiler_boilerplate=`cat conftest.err`
+-$rm conftest*
+-])# _LT_COMPILER_BOILERPLATE
+-
++# _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION])
++# --------------------------------------------------------
++m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])])
++
++
++# lt_decl_tag_varnames([SEPARATOR], [VARNAME1...])
++# ------------------------------------------------
++m4_define([lt_decl_tag_varnames],
++[_lt_decl_filter([tagged?], [yes], $@)])
++
++
++# _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..])
++# ---------------------------------------------------------
++m4_define([_lt_decl_filter],
++[m4_case([$#],
++ [0], [m4_fatal([$0: too few arguments: $#])],
++ [1], [m4_fatal([$0: too few arguments: $#: $1])],
++ [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)],
++ [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)],
++ [lt_dict_filter([lt_decl_dict], $@)])[]dnl
++])
+
+-# _LT_LINKER_BOILERPLATE
+-# ----------------------
+-# Check for linker boilerplate output or warnings with
+-# the simple link test code.
+-AC_DEFUN([_LT_LINKER_BOILERPLATE],
+-[ac_outfile=conftest.$ac_objext
+-printf "$lt_simple_link_test_code" >conftest.$ac_ext
+-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+-_lt_linker_boilerplate=`cat conftest.err`
+-$rm conftest*
+-])# _LT_LINKER_BOILERPLATE
+
++# lt_decl_quote_varnames([SEPARATOR], [VARNAME1...])
++# --------------------------------------------------
++m4_define([lt_decl_quote_varnames],
++[_lt_decl_filter([value], [1], $@)])
++
++
++# lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...])
++# ---------------------------------------------------
++m4_define([lt_decl_dquote_varnames],
++[_lt_decl_filter([value], [2], $@)])
++
++
++# lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...])
++# ---------------------------------------------------
++m4_define([lt_decl_varnames_tagged],
++[_$0(m4_quote(m4_default([$1], [[, ]])),
++ m4_quote(m4_if([$2], [],
++ m4_quote(lt_decl_tag_varnames),
++ m4_quote(m4_shift($@)))),
++ m4_split(m4_normalize(m4_quote(_LT_TAGS))))])
++m4_define([_lt_decl_varnames_tagged], [lt_combine([$1], [$2], [_], $3)])
++
++
++# lt_decl_all_varnames([SEPARATOR], [VARNAME1...])
++# ------------------------------------------------
++m4_define([lt_decl_all_varnames],
++[_$0(m4_quote(m4_default([$1], [[, ]])),
++ m4_if([$2], [],
++ m4_quote(lt_decl_varnames),
++ m4_quote(m4_shift($@))))[]dnl
++])
++m4_define([_lt_decl_all_varnames],
++[lt_join($@, lt_decl_varnames_tagged([$1],
++ lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl
++])
+
+-# _LT_AC_SYS_LIBPATH_AIX
+-# ----------------------
+-# Links a minimal program and checks the executable
+-# for the system default hardcoded library path. In most cases,
+-# this is /usr/lib:/lib, but when the MPI compilers are used
+-# the location of the communication and MPI libs are included too.
+-# If we don't find anything, use the default library path according
+-# to the aix ld manual.
+-AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX],
+-[AC_LINK_IFELSE(AC_LANG_PROGRAM,[
+-aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
+-}'`
+-# Check for a 64-bit object if we didn't find anything.
+-if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
+-}'`; fi],[])
+-if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+-])# _LT_AC_SYS_LIBPATH_AIX
+
++# _LT_CONFIG_STATUS_DECLARE([VARNAME])
++# ------------------------------------
++# Quote a variable value, and forward it to `config.status' so that its
++# declaration there will have the same value as in `configure'. VARNAME
++# must have a single quote delimited value for this to work.
++m4_define([_LT_CONFIG_STATUS_DECLARE],
++[$1='`$ECHO "X$][$1" | $Xsed -e "$delay_single_quote_subst"`'])
+
+-# _LT_AC_SHELL_INIT(ARG)
+-# ----------------------
+-AC_DEFUN([_LT_AC_SHELL_INIT],
+-[ifdef([AC_DIVERSION_NOTICE],
+- [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)],
+- [AC_DIVERT_PUSH(NOTICE)])
+-$1
+-AC_DIVERT_POP
+-])# _LT_AC_SHELL_INIT
+
++# _LT_CONFIG_STATUS_DECLARATIONS
++# ------------------------------
++# We delimit libtool config variables with single quotes, so when
++# we write them to config.status, we have to be sure to quote all
++# embedded single quotes properly. In configure, this macro expands
++# each variable declared with _LT_DECL (and _LT_TAGDECL) into:
++#
++# <var>='`$ECHO "X$<var>" | $Xsed -e "$delay_single_quote_subst"`'
++m4_defun([_LT_CONFIG_STATUS_DECLARATIONS],
++[m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames),
++ [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])])
+
+-# _LT_AC_PROG_ECHO_BACKSLASH
+-# --------------------------
+-# Add some code to the start of the generated configure script which
+-# will find an echo command which doesn't interpret backslashes.
+-AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH],
+-[_LT_AC_SHELL_INIT([
+-# Check that we are running under the correct shell.
+-SHELL=${CONFIG_SHELL-/bin/sh}
+
+-case X$ECHO in
+-X*--fallback-echo)
+- # Remove one level of quotation (which was required for Make).
+- ECHO=`echo "$ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','`
+- ;;
+-esac
++# _LT_LIBTOOL_TAGS
++# ----------------
++# Output comment and list of tags supported by the script
++m4_defun([_LT_LIBTOOL_TAGS],
++[_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl
++available_tags="_LT_TAGS"dnl
++])
+
+-echo=${ECHO-echo}
+-if test "X[$]1" = X--no-reexec; then
+- # Discard the --no-reexec flag, and continue.
+- shift
+-elif test "X[$]1" = X--fallback-echo; then
+- # Avoid inline document here, it may be left over
+- :
+-elif test "X`($echo '\t') 2>/dev/null`" = 'X\t' ; then
+- # Yippee, $echo works!
+- :
+-else
+- # Restart under the correct shell.
+- exec $SHELL "[$]0" --no-reexec ${1+"[$]@"}
+-fi
+
+-if test "X[$]1" = X--fallback-echo; then
+- # used as fallback echo
+- shift
+- cat <<EOF
+-[$]*
+-EOF
+- exit 0
+-fi
++# _LT_LIBTOOL_DECLARE(VARNAME, [TAG])
++# -----------------------------------
++# Extract the dictionary values for VARNAME (optionally with TAG) and
++# expand to a commented shell variable setting:
++#
++# # Some comment about what VAR is for.
++# visible_name=$lt_internal_name
++m4_define([_LT_LIBTOOL_DECLARE],
++[_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1],
++ [description])))[]dnl
++m4_pushdef([_libtool_name],
++ m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl
++m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])),
++ [0], [_libtool_name=[$]$1],
++ [1], [_libtool_name=$lt_[]$1],
++ [2], [_libtool_name=$lt_[]$1],
++ [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl
++m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl
++])
+
+-# The HP-UX ksh and POSIX shell print the target directory to stdout
+-# if CDPATH is set.
+-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+-if test -z "$ECHO"; then
+-if test "X${echo_test_string+set}" != Xset; then
+-# find a string as large as possible, as long as the shell can cope with it
+- for cmd in 'sed 50q "[$]0"' 'sed 20q "[$]0"' 'sed 10q "[$]0"' 'sed 2q "[$]0"' 'echo test'; do
+- # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ...
+- if (echo_test_string=`eval $cmd`) 2>/dev/null &&
+- echo_test_string=`eval $cmd` &&
+- (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null
+- then
+- break
+- fi
+- done
+-fi
++# _LT_LIBTOOL_CONFIG_VARS
++# -----------------------
++# Produce commented declarations of non-tagged libtool config variables
++# suitable for insertion in the LIBTOOL CONFIG section of the `libtool'
++# script. Tagged libtool config variables (even for the LIBTOOL CONFIG
++# section) are produced by _LT_LIBTOOL_TAG_VARS.
++m4_defun([_LT_LIBTOOL_CONFIG_VARS],
++[m4_foreach([_lt_var],
++ m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)),
++ [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])])
+
+-if test "X`($echo '\t') 2>/dev/null`" = 'X\t' &&
+- echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` &&
+- test "X$echo_testing_string" = "X$echo_test_string"; then
+- :
+-else
+- # The Solaris, AIX, and Digital Unix default echo programs unquote
+- # backslashes. This makes it impossible to quote backslashes using
+- # echo "$something" | sed 's/\\/\\\\/g'
+- #
+- # So, first we look for a working echo in the user's PATH.
+
+- lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+- for dir in $PATH /usr/ucb; do
+- IFS="$lt_save_ifs"
+- if (test -f $dir/echo || test -f $dir/echo$ac_exeext) &&
+- test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' &&
+- echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` &&
+- test "X$echo_testing_string" = "X$echo_test_string"; then
+- echo="$dir/echo"
+- break
+- fi
+- done
+- IFS="$lt_save_ifs"
++# _LT_LIBTOOL_TAG_VARS(TAG)
++# -------------------------
++m4_define([_LT_LIBTOOL_TAG_VARS],
++[m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames),
++ [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])])
+
+- if test "X$echo" = Xecho; then
+- # We didn't find a better echo, so look for alternatives.
+- if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' &&
+- echo_testing_string=`(print -r "$echo_test_string") 2>/dev/null` &&
+- test "X$echo_testing_string" = "X$echo_test_string"; then
+- # This shell has a builtin print -r that does the trick.
+- echo='print -r'
+- elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) &&
+- test "X$CONFIG_SHELL" != X/bin/ksh; then
+- # If we have ksh, try running configure again with it.
+- ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
+- export ORIGINAL_CONFIG_SHELL
+- CONFIG_SHELL=/bin/ksh
+- export CONFIG_SHELL
+- exec $CONFIG_SHELL "[$]0" --no-reexec ${1+"[$]@"}
+- else
+- # Try using printf.
+- echo='printf %s\n'
+- if test "X`($echo '\t') 2>/dev/null`" = 'X\t' &&
+- echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` &&
+- test "X$echo_testing_string" = "X$echo_test_string"; then
+- # Cool, printf works
+- :
+- elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` &&
+- test "X$echo_testing_string" = 'X\t' &&
+- echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
+- test "X$echo_testing_string" = "X$echo_test_string"; then
+- CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL
+- export CONFIG_SHELL
+- SHELL="$CONFIG_SHELL"
+- export SHELL
+- echo="$CONFIG_SHELL [$]0 --fallback-echo"
+- elif echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` &&
+- test "X$echo_testing_string" = 'X\t' &&
+- echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
+- test "X$echo_testing_string" = "X$echo_test_string"; then
+- echo="$CONFIG_SHELL [$]0 --fallback-echo"
+- else
+- # maybe with a smaller string...
+- prev=:
+
+- for cmd in 'echo test' 'sed 2q "[$]0"' 'sed 10q "[$]0"' 'sed 20q "[$]0"' 'sed 50q "[$]0"'; do
+- if (test "X$echo_test_string" = "X`eval $cmd`") 2>/dev/null
+- then
+- break
+- fi
+- prev="$cmd"
+- done
++# _LT_TAGVAR(VARNAME, [TAGNAME])
++# ------------------------------
++m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])])
+
+- if test "$prev" != 'sed 50q "[$]0"'; then
+- echo_test_string=`eval $prev`
+- export echo_test_string
+- exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "[$]0" ${1+"[$]@"}
+- else
+- # Oops. We lost completely, so just stick with echo.
+- echo=echo
+- fi
+- fi
+- fi
+- fi
+-fi
+-fi
+
+-# Copy echo and quote the copy suitably for passing to libtool from
+-# the Makefile, instead of quoting the original, which is used later.
+-ECHO=$echo
+-if test "X$ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then
+- ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo"
+-fi
++# _LT_CONFIG_COMMANDS
++# -------------------
++# Send accumulated output to $CONFIG_STATUS. Thanks to the lists of
++# variables for single and double quote escaping we saved from calls
++# to _LT_DECL, we can put quote escaped variables declarations
++# into `config.status', and then the shell code to quote escape them in
++# for loops in `config.status'. Finally, any additional code accumulated
++# from calls to _LT_CONFIG_LIBTOOL_INIT is expanded.
++m4_defun([_LT_CONFIG_COMMANDS],
++[AC_PROVIDE_IFELSE([LT_OUTPUT],
++ dnl If the libtool generation code has been placed in $CONFIG_LT,
++ dnl instead of duplicating it all over again into config.status,
++ dnl then we will have config.status run $CONFIG_LT later, so it
++ dnl needs to know what name is stored there:
++ [AC_CONFIG_COMMANDS([libtool],
++ [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])],
++ dnl If the libtool generation code is destined for config.status,
++ dnl expand the accumulated commands and init code now:
++ [AC_CONFIG_COMMANDS([libtool],
++ [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])])
++])#_LT_CONFIG_COMMANDS
+
+-AC_SUBST(ECHO)
+-])])# _LT_AC_PROG_ECHO_BACKSLASH
+
++# Initialize.
++m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT],
++[
+
+-# _LT_AC_LOCK
+-# -----------
+-AC_DEFUN([_LT_AC_LOCK],
+-[AC_ARG_ENABLE([libtool-lock],
+- [AC_HELP_STRING([--disable-libtool-lock],
+- [avoid locking (might break parallel builds)])])
+-test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
++# The HP-UX ksh and POSIX shell print the target directory to stdout
++# if CDPATH is set.
++(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+-# Some flags need to be propagated to the compiler or linker for good
+-# libtool support.
+-case $host in
+-ia64-*-hpux*)
+- # Find out which ABI we are using.
+- echo 'int i;' > conftest.$ac_ext
+- if AC_TRY_EVAL(ac_compile); then
+- case `/usr/bin/file conftest.$ac_objext` in
+- *ELF-32*)
+- HPUX_IA64_MODE="32"
+- ;;
+- *ELF-64*)
+- HPUX_IA64_MODE="64"
+- ;;
+- esac
+- fi
+- rm -rf conftest*
+- ;;
+-*-*-irix6*)
+- # Find out which ABI we are using.
+- echo '[#]line __oline__ "configure"' > conftest.$ac_ext
+- if AC_TRY_EVAL(ac_compile); then
+- if test "$lt_cv_prog_gnu_ld" = yes; then
+- case `/usr/bin/file conftest.$ac_objext` in
+- *32-bit*)
+- LD="${LD-ld} -melf32bsmip"
+- ;;
+- *N32*)
+- LD="${LD-ld} -melf32bmipn32"
++sed_quote_subst='$sed_quote_subst'
++double_quote_subst='$double_quote_subst'
++delay_variable_subst='$delay_variable_subst'
++_LT_CONFIG_STATUS_DECLARATIONS
++LTCC='$LTCC'
++LTCFLAGS='$LTCFLAGS'
++compiler='$compiler_DEFAULT'
++
++# Quote evaled strings.
++for var in lt_decl_all_varnames([[ \
++]], lt_decl_quote_varnames); do
++ case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in
++ *[[\\\\\\\`\\"\\\$]]*)
++ eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$sed_quote_subst\\"\\\`\\\\\\""
+ ;;
+- *64-bit*)
+- LD="${LD-ld} -melf64bmip"
++ *)
++ eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
+ ;;
+ esac
+- else
+- case `/usr/bin/file conftest.$ac_objext` in
+- *32-bit*)
+- LD="${LD-ld} -32"
+- ;;
+- *N32*)
+- LD="${LD-ld} -n32"
++done
++
++# Double-quote double-evaled strings.
++for var in lt_decl_all_varnames([[ \
++]], lt_decl_dquote_varnames); do
++ case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in
++ *[[\\\\\\\`\\"\\\$]]*)
++ eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\""
+ ;;
+- *64-bit*)
+- LD="${LD-ld} -64"
++ *)
++ eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
+ ;;
+ esac
+- fi
+- fi
+- rm -rf conftest*
++done
++
++# Fix-up fallback echo if it was mangled by the above quoting rules.
++case \$lt_ECHO in
++*'\\\[$]0 --fallback-echo"')dnl "
++ lt_ECHO=\`\$ECHO "X\$lt_ECHO" | \$Xsed -e 's/\\\\\\\\\\\\\\\[$]0 --fallback-echo"\[$]/\[$]0 --fallback-echo"/'\`
+ ;;
++esac
+
+-x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*|s390*-*linux*|sparc*-*linux*)
+- # Find out which ABI we are using.
+- echo 'int i;' > conftest.$ac_ext
+- if AC_TRY_EVAL(ac_compile); then
+- case `/usr/bin/file conftest.o` in
+- *32-bit*)
+- case $host in
+- x86_64-*linux*)
+- LD="${LD-ld} -m elf_i386"
+- ;;
+- ppc64-*linux*|powerpc64-*linux*)
+- LD="${LD-ld} -m elf32ppclinux"
+- ;;
+- s390x-*linux*)
+- LD="${LD-ld} -m elf_s390"
+- ;;
+- sparc64-*linux*)
+- LD="${LD-ld} -m elf32_sparc"
+- ;;
+- esac
+- ;;
+- *64-bit*)
+- case $host in
+- x86_64-*linux*)
+- LD="${LD-ld} -m elf_x86_64"
+- ;;
+- ppc*-*linux*|powerpc*-*linux*)
+- LD="${LD-ld} -m elf64ppc"
+- ;;
+- s390*-*linux*)
+- LD="${LD-ld} -m elf64_s390"
+- ;;
+- sparc*-*linux*)
+- LD="${LD-ld} -m elf64_sparc"
+- ;;
+- esac
+- ;;
+- esac
+- fi
+- rm -rf conftest*
+- ;;
++_LT_OUTPUT_LIBTOOL_INIT
++])
+
+-*-*-sco3.2v5*)
+- # On SCO OpenServer 5, we need -belf to get full-featured binaries.
+- SAVE_CFLAGS="$CFLAGS"
+- CFLAGS="$CFLAGS -belf"
+- AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
+- [AC_LANG_PUSH(C)
+- AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])
+- AC_LANG_POP])
+- if test x"$lt_cv_cc_needs_belf" != x"yes"; then
+- # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
+- CFLAGS="$SAVE_CFLAGS"
+- fi
+- ;;
+-sparc*-*solaris*)
+- # Find out which ABI we are using.
+- echo 'int i;' > conftest.$ac_ext
+- if AC_TRY_EVAL(ac_compile); then
+- case `/usr/bin/file conftest.o` in
+- *64-bit*)
+- case $lt_cv_prog_gnu_ld in
+- yes*) LD="${LD-ld} -m elf64_sparc" ;;
+- *) LD="${LD-ld} -64" ;;
+- esac
+- ;;
+- esac
+- fi
+- rm -rf conftest*
+- ;;
+
+-AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL],
+-[*-*-cygwin* | *-*-mingw* | *-*-pw32*)
+- AC_CHECK_TOOL(DLLTOOL, dlltool, false)
+- AC_CHECK_TOOL(AS, as, false)
+- AC_CHECK_TOOL(OBJDUMP, objdump, false)
+- ;;
+- ])
+-esac
++# LT_OUTPUT
++# ---------
++# This macro allows early generation of the libtool script (before
++# AC_OUTPUT is called), incase it is used in configure for compilation
++# tests.
++AC_DEFUN([LT_OUTPUT],
++[: ${CONFIG_LT=./config.lt}
++AC_MSG_NOTICE([creating $CONFIG_LT])
++cat >"$CONFIG_LT" <<_LTEOF
++#! $SHELL
++# Generated by $as_me.
++# Run this file to recreate a libtool stub with the current configuration.
++
++lt_cl_silent=false
++SHELL=\${CONFIG_SHELL-$SHELL}
++_LTEOF
++
++cat >>"$CONFIG_LT" <<\_LTEOF
++AS_SHELL_SANITIZE
++_AS_PREPARE
+
+-need_locks="$enable_libtool_lock"
++exec AS_MESSAGE_FD>&1
++exec AS_MESSAGE_LOG_FD>>config.log
++{
++ echo
++ AS_BOX([Running $as_me.])
++} >&AS_MESSAGE_LOG_FD
++
++lt_cl_help="\
++\`$as_me' creates a local libtool stub from the current configuration,
++for use in further configure time tests before the real libtool is
++generated.
++
++Usage: $[0] [[OPTIONS]]
++
++ -h, --help print this help, then exit
++ -V, --version print version number, then exit
++ -q, --quiet do not print progress messages
++ -d, --debug don't remove temporary files
++
++Report bugs to <bug-libtool@gnu.org>."
++
++lt_cl_version="\
++m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl
++m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION])
++configured by $[0], generated by m4_PACKAGE_STRING.
++
++Copyright (C) 2008 Free Software Foundation, Inc.
++This config.lt script is free software; the Free Software Foundation
++gives unlimited permision to copy, distribute and modify it."
+
+-])# _LT_AC_LOCK
++while test $[#] != 0
++do
++ case $[1] in
++ --version | --v* | -V )
++ echo "$lt_cl_version"; exit 0 ;;
++ --help | --h* | -h )
++ echo "$lt_cl_help"; exit 0 ;;
++ --debug | --d* | -d )
++ debug=: ;;
++ --quiet | --q* | --silent | --s* | -q )
++ lt_cl_silent=: ;;
+
++ -*) AC_MSG_ERROR([unrecognized option: $[1]
++Try \`$[0] --help' for more information.]) ;;
+
+-# AC_LIBTOOL_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
+-# [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE])
+-# ----------------------------------------------------------------
+-# Check whether the given compiler option works
+-AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION],
+-[AC_REQUIRE([LT_AC_PROG_SED])
+-AC_CACHE_CHECK([$1], [$2],
+- [$2=no
+- ifelse([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4])
+- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+- lt_compiler_flag="$3"
+- # Insert the option either (1) after the last *FLAGS variable, or
+- # (2) before a word containing "conftest.", or (3) at the end.
+- # Note that $ac_compile itself does not contain backslashes and begins
+- # with a dollar sign (not a hyphen), so the echo should work correctly.
+- # The option is referenced via a variable to avoid confusing sed.
+- lt_compile=`echo "$ac_compile" | $SED \
+- -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+- -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
+- -e 's:$: $lt_compiler_flag:'`
+- (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
+- (eval "$lt_compile" 2>conftest.err)
+- ac_status=$?
+- cat conftest.err >&AS_MESSAGE_LOG_FD
+- echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
+- if (exit $ac_status) && test -s "$ac_outfile"; then
+- # The compiler can only warn and ignore the option if not recognized
+- # So say no if there are warnings other than the usual output.
+- $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
+- $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+- if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+- $2=yes
+- fi
+- fi
+- $rm conftest*
+-])
++ *) AC_MSG_ERROR([unrecognized argument: $[1]
++Try \`$[0] --help' for more information.]) ;;
++ esac
++ shift
++done
+
+-if test x"[$]$2" = xyes; then
+- ifelse([$5], , :, [$5])
+-else
+- ifelse([$6], , :, [$6])
++if $lt_cl_silent; then
++ exec AS_MESSAGE_FD>/dev/null
+ fi
+-])# AC_LIBTOOL_COMPILER_OPTION
+-
+-
+-# AC_LIBTOOL_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
+-# [ACTION-SUCCESS], [ACTION-FAILURE])
+-# ------------------------------------------------------------
+-# Check whether the given compiler option works
+-AC_DEFUN([AC_LIBTOOL_LINKER_OPTION],
+-[AC_CACHE_CHECK([$1], [$2],
+- [$2=no
+- save_LDFLAGS="$LDFLAGS"
+- LDFLAGS="$LDFLAGS $3"
+- printf "$lt_simple_link_test_code" > conftest.$ac_ext
+- if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
+- # The linker can only warn and ignore the option if not recognized
+- # So say no if there are warnings
+- if test -s conftest.err; then
+- # Append any errors to the config.log.
+- cat conftest.err 1>&AS_MESSAGE_LOG_FD
+- $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
+- $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+- if diff conftest.exp conftest.er2 >/dev/null; then
+- $2=yes
+- fi
+- else
+- $2=yes
+- fi
+- fi
+- $rm conftest*
+- LDFLAGS="$save_LDFLAGS"
+-])
++_LTEOF
+
+-if test x"[$]$2" = xyes; then
+- ifelse([$4], , :, [$4])
+-else
+- ifelse([$5], , :, [$5])
++cat >>"$CONFIG_LT" <<_LTEOF
++_LT_OUTPUT_LIBTOOL_COMMANDS_INIT
++_LTEOF
++
++cat >>"$CONFIG_LT" <<\_LTEOF
++AC_MSG_NOTICE([creating $ofile])
++_LT_OUTPUT_LIBTOOL_COMMANDS
++AS_EXIT(0)
++_LTEOF
++chmod +x "$CONFIG_LT"
++
++# configure is writing to config.log, but config.lt does its own redirection,
++# appending to config.log, which fails on DOS, as config.log is still kept
++# open by configure. Here we exec the FD to /dev/null, effectively closing
++# config.log, so it can be properly (re)opened and appended to by config.lt.
++if test "$no_create" != yes; then
++ lt_cl_success=:
++ test "$silent" = yes &&
++ lt_config_lt_args="$lt_config_lt_args --quiet"
++ exec AS_MESSAGE_LOG_FD>/dev/null
++ $SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false
++ exec AS_MESSAGE_LOG_FD>>config.log
++ $lt_cl_success || AS_EXIT(1)
+ fi
+-])# AC_LIBTOOL_LINKER_OPTION
+-
++])# LT_OUTPUT
+
+-# AC_LIBTOOL_SYS_MAX_CMD_LEN
+-# --------------------------
+-AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN],
+-[# find the maximum length of command line arguments
+-AC_MSG_CHECKING([the maximum length of command line arguments])
+-AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
+- i=0
+- teststring="ABCD"
+
+- case $build_os in
+- msdosdjgpp*)
+- # On DJGPP, this test can blow up pretty badly due to problems in libc
+- # (any single argument exceeding 2000 bytes causes a buffer overrun
+- # during glob expansion). Even if it were fixed, the result of this
+- # check would be larger than it should be.
+- lt_cv_sys_max_cmd_len=12288; # 12K is about right
+- ;;
++# _LT_CONFIG(TAG)
++# ---------------
++# If TAG is the built-in tag, create an initial libtool script with a
++# default configuration from the untagged config vars. Otherwise add code
++# to config.status for appending the configuration named by TAG from the
++# matching tagged config vars.
++m4_defun([_LT_CONFIG],
++[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
++_LT_CONFIG_SAVE_COMMANDS([
++ m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl
++ m4_if(_LT_TAG, [C], [
++ # See if we are running on zsh, and set the options which allow our
++ # commands through without removal of \ escapes.
++ if test -n "${ZSH_VERSION+set}" ; then
++ setopt NO_GLOB_SUBST
++ fi
+
+- gnu*)
+- # Under GNU Hurd, this test is not required because there is
+- # no limit to the length of command line arguments.
+- # Libtool will interpret -1 as no limit whatsoever
+- lt_cv_sys_max_cmd_len=-1;
+- ;;
++ cfgfile="${ofile}T"
++ trap "$RM \"$cfgfile\"; exit 1" 1 2 15
++ $RM "$cfgfile"
+
+- cygwin* | mingw*)
+- # On Win9x/ME, this test blows up -- it succeeds, but takes
+- # about 5 minutes as the teststring grows exponentially.
+- # Worse, since 9x/ME are not pre-emptively multitasking,
+- # you end up with a "frozen" computer, even though with patience
+- # the test eventually succeeds (with a max line length of 256k).
+- # Instead, let's just punt: use the minimum linelength reported by
+- # all of the supported platforms: 8192 (on NT/2K/XP).
+- lt_cv_sys_max_cmd_len=8192;
+- ;;
++ cat <<_LT_EOF >> "$cfgfile"
++#! $SHELL
+
+- amigaos*)
+- # On AmigaOS with pdksh, this test takes hours, literally.
+- # So we just punt and use a minimum line length of 8192.
+- lt_cv_sys_max_cmd_len=8192;
+- ;;
++# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
++# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION
++# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
++# NOTE: Changes made to this file will be lost: look at ltmain.sh.
++#
++_LT_COPYING
++_LT_LIBTOOL_TAGS
+
+- netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
+- # This has been around since 386BSD, at least. Likely further.
+- if test -x /sbin/sysctl; then
+- lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
+- elif test -x /usr/sbin/sysctl; then
+- lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
+- else
+- lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs
+- fi
+- # And add a safety zone
+- lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
+- lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+- ;;
++# ### BEGIN LIBTOOL CONFIG
++_LT_LIBTOOL_CONFIG_VARS
++_LT_LIBTOOL_TAG_VARS
++# ### END LIBTOOL CONFIG
+
+- interix*)
+- # We know the value 262144 and hardcode it with a safety zone (like BSD)
+- lt_cv_sys_max_cmd_len=196608
+- ;;
++_LT_EOF
+
+- osf*)
+- # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
+- # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
+- # nice to cause kernel panics so lets avoid the loop below.
+- # First set a reasonable default.
+- lt_cv_sys_max_cmd_len=16384
+- #
+- if test -x /sbin/sysconfig; then
+- case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
+- *1*) lt_cv_sys_max_cmd_len=-1 ;;
+- esac
+- fi
+- ;;
+- sco3.2v5*)
+- lt_cv_sys_max_cmd_len=102400
+- ;;
+- sysv5* | sco5v6* | sysv4.2uw2*)
+- kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
+- if test -n "$kargmax"; then
+- lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'`
+- else
+- lt_cv_sys_max_cmd_len=32768
+- fi
+- ;;
+- *)
+- # If test is not a shell built-in, we'll probably end up computing a
+- # maximum length that is only half of the actual maximum length, but
+- # we can't tell.
+- SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
+- while (test "X"`$SHELL [$]0 --fallback-echo "X$teststring" 2>/dev/null` \
+- = "XX$teststring") >/dev/null 2>&1 &&
+- new_result=`expr "X$teststring" : ".*" 2>&1` &&
+- lt_cv_sys_max_cmd_len=$new_result &&
+- test $i != 17 # 1/2 MB should be enough
+- do
+- i=`expr $i + 1`
+- teststring=$teststring$teststring
+- done
+- teststring=
+- # Add a significant safety factor because C++ compilers can tack on massive
+- # amounts of additional arguments before passing them to the linker.
+- # It appears as though 1/2 is a usable value.
+- lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
++ case $host_os in
++ aix3*)
++ cat <<\_LT_EOF >> "$cfgfile"
++# AIX sometimes has problems with the GCC collect2 program. For some
++# reason, if we set the COLLECT_NAMES environment variable, the problems
++# vanish in a puff of smoke.
++if test "X${COLLECT_NAMES+set}" != Xset; then
++ COLLECT_NAMES=
++ export COLLECT_NAMES
++fi
++_LT_EOF
+ ;;
+ esac
+-])
+-if test -n $lt_cv_sys_max_cmd_len ; then
+- AC_MSG_RESULT($lt_cv_sys_max_cmd_len)
+-else
+- AC_MSG_RESULT(none)
+-fi
+-])# AC_LIBTOOL_SYS_MAX_CMD_LEN
+
++ _LT_PROG_LTMAIN
+
+-# _LT_AC_CHECK_DLFCN
+-# ------------------
+-AC_DEFUN([_LT_AC_CHECK_DLFCN],
+-[AC_CHECK_HEADERS(dlfcn.h)dnl
+-])# _LT_AC_CHECK_DLFCN
++ # We use sed instead of cat because bash on DJGPP gets confused if
++ # if finds mixed CR/LF and LF-only lines. Since sed operates in
++ # text mode, it properly converts lines to CR/LF. This bash problem
++ # is reportedly fixed, but why not run on old versions too?
++ sed '/^# Generated shell functions inserted here/q' "$ltmain" >> "$cfgfile" \
++ || (rm -f "$cfgfile"; exit 1)
+
++ _LT_PROG_XSI_SHELLFNS
+
+-# _LT_AC_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE,
+-# ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING)
+-# ---------------------------------------------------------------------
+-AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF],
+-[AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl
+-if test "$cross_compiling" = yes; then :
+- [$4]
+-else
+- lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+- lt_status=$lt_dlunknown
+- cat > conftest.$ac_ext <<EOF
+-[#line __oline__ "configure"
+-#include "confdefs.h"
++ sed -n '/^# Generated shell functions inserted here/,$p' "$ltmain" >> "$cfgfile" \
++ || (rm -f "$cfgfile"; exit 1)
+
+-#if HAVE_DLFCN_H
+-#include <dlfcn.h>
+-#endif
++ mv -f "$cfgfile" "$ofile" ||
++ (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
++ chmod +x "$ofile"
++],
++[cat <<_LT_EOF >> "$ofile"
+
+-#include <stdio.h>
++dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded
++dnl in a comment (ie after a #).
++# ### BEGIN LIBTOOL TAG CONFIG: $1
++_LT_LIBTOOL_TAG_VARS(_LT_TAG)
++# ### END LIBTOOL TAG CONFIG: $1
++_LT_EOF
++])dnl /m4_if
++],
++[m4_if([$1], [], [
++ PACKAGE='$PACKAGE'
++ VERSION='$VERSION'
++ TIMESTAMP='$TIMESTAMP'
++ RM='$RM'
++ ofile='$ofile'], [])
++])dnl /_LT_CONFIG_SAVE_COMMANDS
++])# _LT_CONFIG
++
++
++# LT_SUPPORTED_TAG(TAG)
++# ---------------------
++# Trace this macro to discover what tags are supported by the libtool
++# --tag option, using:
++# autoconf --trace 'LT_SUPPORTED_TAG:$1'
++AC_DEFUN([LT_SUPPORTED_TAG], [])
++
++
++# C support is built-in for now
++m4_define([_LT_LANG_C_enabled], [])
++m4_define([_LT_TAGS], [])
+
+-#ifdef RTLD_GLOBAL
+-# define LT_DLGLOBAL RTLD_GLOBAL
+-#else
+-# ifdef DL_GLOBAL
+-# define LT_DLGLOBAL DL_GLOBAL
+-# else
+-# define LT_DLGLOBAL 0
+-# endif
+-#endif
+
+-/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+- find out it does not work in some platform. */
+-#ifndef LT_DLLAZY_OR_NOW
+-# ifdef RTLD_LAZY
+-# define LT_DLLAZY_OR_NOW RTLD_LAZY
+-# else
+-# ifdef DL_LAZY
+-# define LT_DLLAZY_OR_NOW DL_LAZY
+-# else
+-# ifdef RTLD_NOW
+-# define LT_DLLAZY_OR_NOW RTLD_NOW
+-# else
+-# ifdef DL_NOW
+-# define LT_DLLAZY_OR_NOW DL_NOW
+-# else
+-# define LT_DLLAZY_OR_NOW 0
+-# endif
+-# endif
+-# endif
+-# endif
+-#endif
++# LT_LANG(LANG)
++# -------------
++# Enable libtool support for the given language if not already enabled.
++AC_DEFUN([LT_LANG],
++[AC_BEFORE([$0], [LT_OUTPUT])dnl
++m4_case([$1],
++ [C], [_LT_LANG(C)],
++ [C++], [_LT_LANG(CXX)],
++ [Java], [_LT_LANG(GCJ)],
++ [Fortran 77], [_LT_LANG(F77)],
++ [Fortran], [_LT_LANG(FC)],
++ [Windows Resource], [_LT_LANG(RC)],
++ [m4_ifdef([_LT_LANG_]$1[_CONFIG],
++ [_LT_LANG($1)],
++ [m4_fatal([$0: unsupported language: "$1"])])])dnl
++])# LT_LANG
+
+-#ifdef __cplusplus
+-extern "C" void exit (int);
+-#endif
+
+-void fnord() { int i=42;}
+-int main ()
+-{
+- void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+- int status = $lt_dlunknown;
+-
+- if (self)
+- {
+- if (dlsym (self,"fnord")) status = $lt_dlno_uscore;
+- else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
+- /* dlclose (self); */
+- }
+- else
+- puts (dlerror ());
++# _LT_LANG(LANGNAME)
++# ------------------
++m4_defun([_LT_LANG],
++[m4_ifdef([_LT_LANG_]$1[_enabled], [],
++ [LT_SUPPORTED_TAG([$1])dnl
++ m4_append([_LT_TAGS], [$1 ])dnl
++ m4_define([_LT_LANG_]$1[_enabled], [])dnl
++ _LT_LANG_$1_CONFIG($1)])dnl
++])# _LT_LANG
+
+- exit (status);
+-}]
+-EOF
+- if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then
+- (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null
+- lt_status=$?
+- case x$lt_status in
+- x$lt_dlno_uscore) $1 ;;
+- x$lt_dlneed_uscore) $2 ;;
+- x$lt_dlunknown|x*) $3 ;;
+- esac
+- else :
+- # compilation failed
+- $3
+- fi
+-fi
+-rm -fr conftest*
+-])# _LT_AC_TRY_DLOPEN_SELF
+
++# _LT_LANG_DEFAULT_CONFIG
++# -----------------------
++m4_defun([_LT_LANG_DEFAULT_CONFIG],
++[AC_PROVIDE_IFELSE([AC_PROG_CXX],
++ [LT_LANG(CXX)],
++ [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])])
++
++AC_PROVIDE_IFELSE([AC_PROG_F77],
++ [LT_LANG(F77)],
++ [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])])
++
++AC_PROVIDE_IFELSE([AC_PROG_FC],
++ [LT_LANG(FC)],
++ [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])])
++
++dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal
++dnl pulling things in needlessly.
++AC_PROVIDE_IFELSE([AC_PROG_GCJ],
++ [LT_LANG(GCJ)],
++ [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],
++ [LT_LANG(GCJ)],
++ [AC_PROVIDE_IFELSE([LT_PROG_GCJ],
++ [LT_LANG(GCJ)],
++ [m4_ifdef([AC_PROG_GCJ],
++ [m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])])
++ m4_ifdef([A][M_PROG_GCJ],
++ [m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])])
++ m4_ifdef([LT_PROG_GCJ],
++ [m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])])
++
++AC_PROVIDE_IFELSE([LT_PROG_RC],
++ [LT_LANG(RC)],
++ [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])])
++])# _LT_LANG_DEFAULT_CONFIG
++
++# Obsolete macros:
++AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)])
++AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)])
++AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)])
++AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)])
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([AC_LIBTOOL_CXX], [])
++dnl AC_DEFUN([AC_LIBTOOL_F77], [])
++dnl AC_DEFUN([AC_LIBTOOL_FC], [])
++dnl AC_DEFUN([AC_LIBTOOL_GCJ], [])
+
+-# AC_LIBTOOL_DLOPEN_SELF
+-# ----------------------
+-AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF],
+-[AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl
+-if test "x$enable_dlopen" != xyes; then
+- enable_dlopen=unknown
+- enable_dlopen_self=unknown
+- enable_dlopen_self_static=unknown
+-else
+- lt_cv_dlopen=no
+- lt_cv_dlopen_libs=
+
+- case $host_os in
+- beos*)
+- lt_cv_dlopen="load_add_on"
+- lt_cv_dlopen_libs=
+- lt_cv_dlopen_self=yes
+- ;;
++# _LT_TAG_COMPILER
++# ----------------
++m4_defun([_LT_TAG_COMPILER],
++[AC_REQUIRE([AC_PROG_CC])dnl
+
+- mingw* | pw32*)
+- lt_cv_dlopen="LoadLibrary"
+- lt_cv_dlopen_libs=
+- ;;
++_LT_DECL([LTCC], [CC], [1], [A C compiler])dnl
++_LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl
++_LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl
++_LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl
+
+- cygwin*)
+- lt_cv_dlopen="dlopen"
+- lt_cv_dlopen_libs=
+- ;;
++# If no C compiler was specified, use CC.
++LTCC=${LTCC-"$CC"}
+
+- darwin*)
+- # if libdl is installed we need to link against it
+- AC_CHECK_LIB([dl], [dlopen],
+- [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[
+- lt_cv_dlopen="dyld"
+- lt_cv_dlopen_libs=
+- lt_cv_dlopen_self=yes
+- ])
+- ;;
++# If no C compiler flags were specified, use CFLAGS.
++LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
+
+- *)
+- AC_CHECK_FUNC([shl_load],
+- [lt_cv_dlopen="shl_load"],
+- [AC_CHECK_LIB([dld], [shl_load],
+- [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld"],
+- [AC_CHECK_FUNC([dlopen],
+- [lt_cv_dlopen="dlopen"],
+- [AC_CHECK_LIB([dl], [dlopen],
+- [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],
+- [AC_CHECK_LIB([svld], [dlopen],
+- [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"],
+- [AC_CHECK_LIB([dld], [dld_link],
+- [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld"])
+- ])
+- ])
+- ])
+- ])
+- ])
+- ;;
+- esac
++# Allow CC to be a program name with arguments.
++compiler=$CC
++])# _LT_TAG_COMPILER
+
+- if test "x$lt_cv_dlopen" != xno; then
+- enable_dlopen=yes
+- else
+- enable_dlopen=no
+- fi
+
+- case $lt_cv_dlopen in
+- dlopen)
+- save_CPPFLAGS="$CPPFLAGS"
+- test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
++# _LT_COMPILER_BOILERPLATE
++# ------------------------
++# Check for compiler boilerplate output or warnings with
++# the simple compiler test code.
++m4_defun([_LT_COMPILER_BOILERPLATE],
++[m4_require([_LT_DECL_SED])dnl
++ac_outfile=conftest.$ac_objext
++echo "$lt_simple_compile_test_code" >conftest.$ac_ext
++eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
++_lt_compiler_boilerplate=`cat conftest.err`
++$RM conftest*
++])# _LT_COMPILER_BOILERPLATE
+
+- save_LDFLAGS="$LDFLAGS"
+- wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
+
+- save_LIBS="$LIBS"
+- LIBS="$lt_cv_dlopen_libs $LIBS"
++# _LT_LINKER_BOILERPLATE
++# ----------------------
++# Check for linker boilerplate output or warnings with
++# the simple link test code.
++m4_defun([_LT_LINKER_BOILERPLATE],
++[m4_require([_LT_DECL_SED])dnl
++ac_outfile=conftest.$ac_objext
++echo "$lt_simple_link_test_code" >conftest.$ac_ext
++eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
++_lt_linker_boilerplate=`cat conftest.err`
++$RM -r conftest*
++])# _LT_LINKER_BOILERPLATE
+
+- AC_CACHE_CHECK([whether a program can dlopen itself],
+- lt_cv_dlopen_self, [dnl
+- _LT_AC_TRY_DLOPEN_SELF(
+- lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes,
+- lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross)
++# _LT_REQUIRED_DARWIN_CHECKS
++# -------------------------
++m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[
++ case $host_os in
++ rhapsody* | darwin*)
++ AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:])
++ AC_CHECK_TOOL([NMEDIT], [nmedit], [:])
++ AC_CHECK_TOOL([LIPO], [lipo], [:])
++ AC_CHECK_TOOL([OTOOL], [otool], [:])
++ AC_CHECK_TOOL([OTOOL64], [otool64], [:])
++ _LT_DECL([], [DSYMUTIL], [1],
++ [Tool to manipulate archived DWARF debug symbol files on Mac OS X])
++ _LT_DECL([], [NMEDIT], [1],
++ [Tool to change global to local symbols on Mac OS X])
++ _LT_DECL([], [LIPO], [1],
++ [Tool to manipulate fat objects and archives on Mac OS X])
++ _LT_DECL([], [OTOOL], [1],
++ [ldd/readelf like tool for Mach-O binaries on Mac OS X])
++ _LT_DECL([], [OTOOL64], [1],
++ [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4])
++
++ AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod],
++ [lt_cv_apple_cc_single_mod=no
++ if test -z "${LT_MULTI_MODULE}"; then
++ # By default we will add the -single_module flag. You can override
++ # by either setting the environment variable LT_MULTI_MODULE
++ # non-empty at configure time, or by adding -multi_module to the
++ # link flags.
++ rm -rf libconftest.dylib*
++ echo "int foo(void){return 1;}" > conftest.c
++ echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
++-dynamiclib -Wl,-single_module conftest.c" >&AS_MESSAGE_LOG_FD
++ $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
++ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err
++ _lt_result=$?
++ if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then
++ lt_cv_apple_cc_single_mod=yes
++ else
++ cat conftest.err >&AS_MESSAGE_LOG_FD
++ fi
++ rm -rf libconftest.dylib*
++ rm -f conftest.*
++ fi])
++ AC_CACHE_CHECK([for -exported_symbols_list linker flag],
++ [lt_cv_ld_exported_symbols_list],
++ [lt_cv_ld_exported_symbols_list=no
++ save_LDFLAGS=$LDFLAGS
++ echo "_main" > conftest.sym
++ LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym"
++ AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
++ [lt_cv_ld_exported_symbols_list=yes],
++ [lt_cv_ld_exported_symbols_list=no])
++ LDFLAGS="$save_LDFLAGS"
+ ])
+-
+- if test "x$lt_cv_dlopen_self" = xyes; then
+- wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
+- AC_CACHE_CHECK([whether a statically linked program can dlopen itself],
+- lt_cv_dlopen_self_static, [dnl
+- _LT_AC_TRY_DLOPEN_SELF(
+- lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes,
+- lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross)
+- ])
++ case $host_os in
++ rhapsody* | darwin1.[[012]])
++ _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
++ darwin1.*)
++ _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
++ darwin*) # darwin 5.x on
++ # if running on 10.5 or later, the deployment target defaults
++ # to the OS version, if on x86, and 10.4, the deployment
++ # target defaults to 10.4. Don't you love it?
++ case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
++ 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*)
++ _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
++ 10.[[012]]*)
++ _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
++ 10.*)
++ _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
++ esac
++ ;;
++ esac
++ if test "$lt_cv_apple_cc_single_mod" = "yes"; then
++ _lt_dar_single_mod='$single_module'
++ fi
++ if test "$lt_cv_ld_exported_symbols_list" = "yes"; then
++ _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym'
++ else
++ _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}'
++ fi
++ if test "$DSYMUTIL" != ":"; then
++ _lt_dsymutil='~$DSYMUTIL $lib || :'
++ else
++ _lt_dsymutil=
+ fi
+-
+- CPPFLAGS="$save_CPPFLAGS"
+- LDFLAGS="$save_LDFLAGS"
+- LIBS="$save_LIBS"
+ ;;
+ esac
++])
+
+- case $lt_cv_dlopen_self in
+- yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
+- *) enable_dlopen_self=unknown ;;
+- esac
+
+- case $lt_cv_dlopen_self_static in
+- yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
+- *) enable_dlopen_self_static=unknown ;;
+- esac
+-fi
+-])# AC_LIBTOOL_DLOPEN_SELF
++# _LT_DARWIN_LINKER_FEATURES
++# --------------------------
++# Checks for linker and compiler features on darwin
++m4_defun([_LT_DARWIN_LINKER_FEATURES],
++[
++ m4_require([_LT_REQUIRED_DARWIN_CHECKS])
++ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
++ _LT_TAGVAR(hardcode_direct, $1)=no
++ _LT_TAGVAR(hardcode_automatic, $1)=yes
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
++ _LT_TAGVAR(whole_archive_flag_spec, $1)=''
++ _LT_TAGVAR(link_all_deplibs, $1)=yes
++ _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined"
++ if test "$GCC" = "yes"; then
++ output_verbose_link_cmd=echo
++ _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
++ _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
++ _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
++ _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
++ m4_if([$1], [CXX],
++[ if test "$lt_cv_apple_cc_single_mod" != "yes"; then
++ _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
++ _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}"
++ fi
++],[])
++ else
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ fi
++])
+
++# _LT_SYS_MODULE_PATH_AIX
++# -----------------------
++# Links a minimal program and checks the executable
++# for the system default hardcoded library path. In most cases,
++# this is /usr/lib:/lib, but when the MPI compilers are used
++# the location of the communication and MPI libs are included too.
++# If we don't find anything, use the default library path according
++# to the aix ld manual.
++m4_defun([_LT_SYS_MODULE_PATH_AIX],
++[m4_require([_LT_DECL_SED])dnl
++AC_LINK_IFELSE(AC_LANG_PROGRAM,[
++lt_aix_libpath_sed='
++ /Import File Strings/,/^$/ {
++ /^0/ {
++ s/^0 *\(.*\)$/\1/
++ p
++ }
++ }'
++aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
++# Check for a 64-bit object if we didn't find anything.
++if test -z "$aix_libpath"; then
++ aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
++fi],[])
++if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
++])# _LT_SYS_MODULE_PATH_AIX
+
+-# AC_LIBTOOL_PROG_CC_C_O([TAGNAME])
+-# ---------------------------------
+-# Check to see if options -c and -o are simultaneously supported by compiler
+-AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O],
+-[AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl
+-AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext],
+- [_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)],
+- [_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no
+- $rm -r conftest 2>/dev/null
+- mkdir conftest
+- cd conftest
+- mkdir out
+- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+- lt_compiler_flag="-o out/conftest2.$ac_objext"
+- # Insert the option either (1) after the last *FLAGS variable, or
+- # (2) before a word containing "conftest.", or (3) at the end.
+- # Note that $ac_compile itself does not contain backslashes and begins
+- # with a dollar sign (not a hyphen), so the echo should work correctly.
+- lt_compile=`echo "$ac_compile" | $SED \
+- -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+- -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
+- -e 's:$: $lt_compiler_flag:'`
+- (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
+- (eval "$lt_compile" 2>out/conftest.err)
+- ac_status=$?
+- cat out/conftest.err >&AS_MESSAGE_LOG_FD
+- echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
+- if (exit $ac_status) && test -s out/conftest2.$ac_objext
+- then
+- # The compiler can only warn and ignore the option if not recognized
+- # So say no if there are warnings
+- $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
+- $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+- if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+- _LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
+- fi
+- fi
+- chmod u+w . 2>&AS_MESSAGE_LOG_FD
+- $rm conftest*
+- # SGI C++ compiler will create directory out/ii_files/ for
+- # template instantiation
+- test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files
+- $rm out/* && rmdir out
+- cd ..
+- rmdir conftest
+- $rm conftest*
+-])
+-])# AC_LIBTOOL_PROG_CC_C_O
++# _LT_SHELL_INIT(ARG)
++# -------------------
++m4_define([_LT_SHELL_INIT],
++[ifdef([AC_DIVERSION_NOTICE],
++ [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)],
++ [AC_DIVERT_PUSH(NOTICE)])
++$1
++AC_DIVERT_POP
++])# _LT_SHELL_INIT
+
+
+-# AC_LIBTOOL_SYS_HARD_LINK_LOCKS([TAGNAME])
+-# -----------------------------------------
+-# Check to see if we can do hard links to lock some files if needed
+-AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS],
+-[AC_REQUIRE([_LT_AC_LOCK])dnl
++# _LT_PROG_ECHO_BACKSLASH
++# -----------------------
++# Add some code to the start of the generated configure script which
++# will find an echo command which doesn't interpret backslashes.
++m4_defun([_LT_PROG_ECHO_BACKSLASH],
++[_LT_SHELL_INIT([
++# Check that we are running under the correct shell.
++SHELL=${CONFIG_SHELL-/bin/sh}
+
+-hard_links="nottested"
+-if test "$_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then
+- # do not overwrite the value of need_locks provided by the user
+- AC_MSG_CHECKING([if we can lock with hard links])
+- hard_links=yes
+- $rm conftest*
+- ln conftest.a conftest.b 2>/dev/null && hard_links=no
+- touch conftest.a
+- ln conftest.a conftest.b 2>&5 || hard_links=no
+- ln conftest.a conftest.b 2>/dev/null && hard_links=no
+- AC_MSG_RESULT([$hard_links])
+- if test "$hard_links" = no; then
+- AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe])
+- need_locks=warn
+- fi
++case X$lt_ECHO in
++X*--fallback-echo)
++ # Remove one level of quotation (which was required for Make).
++ ECHO=`echo "$lt_ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','`
++ ;;
++esac
++
++ECHO=${lt_ECHO-echo}
++if test "X[$]1" = X--no-reexec; then
++ # Discard the --no-reexec flag, and continue.
++ shift
++elif test "X[$]1" = X--fallback-echo; then
++ # Avoid inline document here, it may be left over
++ :
++elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' ; then
++ # Yippee, $ECHO works!
++ :
+ else
+- need_locks=no
++ # Restart under the correct shell.
++ exec $SHELL "[$]0" --no-reexec ${1+"[$]@"}
+ fi
+-])# AC_LIBTOOL_SYS_HARD_LINK_LOCKS
+
+-
+-# AC_LIBTOOL_OBJDIR
+-# -----------------
+-AC_DEFUN([AC_LIBTOOL_OBJDIR],
+-[AC_CACHE_CHECK([for objdir], [lt_cv_objdir],
+-[rm -f .libs 2>/dev/null
+-mkdir .libs 2>/dev/null
+-if test -d .libs; then
+- lt_cv_objdir=.libs
+-else
+- # MS-DOS does not allow filenames that begin with a dot.
+- lt_cv_objdir=_libs
++if test "X[$]1" = X--fallback-echo; then
++ # used as fallback echo
++ shift
++ cat <<_LT_EOF
++[$]*
++_LT_EOF
++ exit 0
+ fi
+-rmdir .libs 2>/dev/null])
+-objdir=$lt_cv_objdir
+-])# AC_LIBTOOL_OBJDIR
+
++# The HP-UX ksh and POSIX shell print the target directory to stdout
++# if CDPATH is set.
++(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+-# AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH([TAGNAME])
+-# ----------------------------------------------
+-# Check hardcoding attributes.
+-AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH],
+-[AC_MSG_CHECKING([how to hardcode library paths into programs])
+-_LT_AC_TAGVAR(hardcode_action, $1)=
+-if test -n "$_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)" || \
+- test -n "$_LT_AC_TAGVAR(runpath_var, $1)" || \
+- test "X$_LT_AC_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then
+-
+- # We can hardcode non-existant directories.
+- if test "$_LT_AC_TAGVAR(hardcode_direct, $1)" != no &&
+- # If the only mechanism to avoid hardcoding is shlibpath_var, we
+- # have to relink, otherwise we might link with an installed library
+- # when we should be linking with a yet-to-be-installed one
+- ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)" != no &&
+- test "$_LT_AC_TAGVAR(hardcode_minus_L, $1)" != no; then
+- # Linking always hardcodes the temporary library directory.
+- _LT_AC_TAGVAR(hardcode_action, $1)=relink
+- else
+- # We can link without hardcoding, and we can hardcode nonexisting dirs.
+- _LT_AC_TAGVAR(hardcode_action, $1)=immediate
++if test -z "$lt_ECHO"; then
++ if test "X${echo_test_string+set}" != Xset; then
++ # find a string as large as possible, as long as the shell can cope with it
++ for cmd in 'sed 50q "[$]0"' 'sed 20q "[$]0"' 'sed 10q "[$]0"' 'sed 2q "[$]0"' 'echo test'; do
++ # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ...
++ if { echo_test_string=`eval $cmd`; } 2>/dev/null &&
++ { test "X$echo_test_string" = "X$echo_test_string"; } 2>/dev/null
++ then
++ break
++ fi
++ done
+ fi
+-else
+- # We cannot hardcode anything, or else we can only hardcode existing
+- # directories.
+- _LT_AC_TAGVAR(hardcode_action, $1)=unsupported
+-fi
+-AC_MSG_RESULT([$_LT_AC_TAGVAR(hardcode_action, $1)])
+
+-if test "$_LT_AC_TAGVAR(hardcode_action, $1)" = relink; then
+- # Fast installation is not supported
+- enable_fast_install=no
+-elif test "$shlibpath_overrides_runpath" = yes ||
+- test "$enable_shared" = no; then
+- # Fast installation is not necessary
+- enable_fast_install=needless
+-fi
+-])# AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH
++ if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' &&
++ echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` &&
++ test "X$echo_testing_string" = "X$echo_test_string"; then
++ :
++ else
++ # The Solaris, AIX, and Digital Unix default echo programs unquote
++ # backslashes. This makes it impossible to quote backslashes using
++ # echo "$something" | sed 's/\\/\\\\/g'
++ #
++ # So, first we look for a working echo in the user's PATH.
+
++ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
++ for dir in $PATH /usr/ucb; do
++ IFS="$lt_save_ifs"
++ if (test -f $dir/echo || test -f $dir/echo$ac_exeext) &&
++ test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' &&
++ echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` &&
++ test "X$echo_testing_string" = "X$echo_test_string"; then
++ ECHO="$dir/echo"
++ break
++ fi
++ done
++ IFS="$lt_save_ifs"
+
+-# AC_LIBTOOL_SYS_LIB_STRIP
+-# ------------------------
+-AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP],
+-[striplib=
+-old_striplib=
+-AC_MSG_CHECKING([whether stripping libraries is possible])
+-if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then
+- test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
+- test -z "$striplib" && striplib="$STRIP --strip-unneeded"
+- AC_MSG_RESULT([yes])
+-else
+-# FIXME - insert some real tests, host_os isn't really good enough
+- case $host_os in
+- darwin*)
+- if test -n "$STRIP" ; then
+- striplib="$STRIP -x"
+- AC_MSG_RESULT([yes])
+- else
+- AC_MSG_RESULT([no])
+-fi
+- ;;
+- *)
+- AC_MSG_RESULT([no])
+- ;;
+- esac
+-fi
+-])# AC_LIBTOOL_SYS_LIB_STRIP
++ if test "X$ECHO" = Xecho; then
++ # We didn't find a better echo, so look for alternatives.
++ if test "X`{ print -r '\t'; } 2>/dev/null`" = 'X\t' &&
++ echo_testing_string=`{ print -r "$echo_test_string"; } 2>/dev/null` &&
++ test "X$echo_testing_string" = "X$echo_test_string"; then
++ # This shell has a builtin print -r that does the trick.
++ ECHO='print -r'
++ elif { test -f /bin/ksh || test -f /bin/ksh$ac_exeext; } &&
++ test "X$CONFIG_SHELL" != X/bin/ksh; then
++ # If we have ksh, try running configure again with it.
++ ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
++ export ORIGINAL_CONFIG_SHELL
++ CONFIG_SHELL=/bin/ksh
++ export CONFIG_SHELL
++ exec $CONFIG_SHELL "[$]0" --no-reexec ${1+"[$]@"}
++ else
++ # Try using printf.
++ ECHO='printf %s\n'
++ if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' &&
++ echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` &&
++ test "X$echo_testing_string" = "X$echo_test_string"; then
++ # Cool, printf works
++ :
++ elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` &&
++ test "X$echo_testing_string" = 'X\t' &&
++ echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
++ test "X$echo_testing_string" = "X$echo_test_string"; then
++ CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL
++ export CONFIG_SHELL
++ SHELL="$CONFIG_SHELL"
++ export SHELL
++ ECHO="$CONFIG_SHELL [$]0 --fallback-echo"
++ elif echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` &&
++ test "X$echo_testing_string" = 'X\t' &&
++ echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
++ test "X$echo_testing_string" = "X$echo_test_string"; then
++ ECHO="$CONFIG_SHELL [$]0 --fallback-echo"
++ else
++ # maybe with a smaller string...
++ prev=:
+
++ for cmd in 'echo test' 'sed 2q "[$]0"' 'sed 10q "[$]0"' 'sed 20q "[$]0"' 'sed 50q "[$]0"'; do
++ if { test "X$echo_test_string" = "X`eval $cmd`"; } 2>/dev/null
++ then
++ break
++ fi
++ prev="$cmd"
++ done
+
+-# AC_LIBTOOL_SYS_DYNAMIC_LINKER
+-# -----------------------------
+-# PORTME Fill in your ld.so characteristics
+-AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER],
+-[AC_MSG_CHECKING([dynamic linker characteristics])
+-library_names_spec=
+-libname_spec='lib$name'
+-soname_spec=
+-shrext_cmds=".so"
+-postinstall_cmds=
+-postuninstall_cmds=
+-finish_cmds=
+-finish_eval=
+-shlibpath_var=
+-shlibpath_overrides_runpath=unknown
+-version_type=none
+-dynamic_linker="$host_os ld.so"
+-sys_lib_dlsearch_path_spec="/lib /usr/lib"
+-if test "$GCC" = yes; then
+- sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+- if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then
+- # if the path contains ";" then we assume it to be the separator
+- # otherwise default to the standard path separator (i.e. ":") - it is
+- # assumed that no part of a normal pathname contains ";" but that should
+- # okay in the real world where ";" in dirpaths is itself problematic.
+- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+- else
+- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
++ if test "$prev" != 'sed 50q "[$]0"'; then
++ echo_test_string=`eval $prev`
++ export echo_test_string
++ exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "[$]0" ${1+"[$]@"}
++ else
++ # Oops. We lost completely, so just stick with echo.
++ ECHO=echo
++ fi
++ fi
++ fi
++ fi
+ fi
+-else
+- sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+ fi
+-need_lib_prefix=unknown
+-hardcode_into_libs=no
+
+-# when you set need_version to no, make sure it does not cause -set_version
+-# flags to be left without arguments
+-need_version=unknown
++# Copy echo and quote the copy suitably for passing to libtool from
++# the Makefile, instead of quoting the original, which is used later.
++lt_ECHO=$ECHO
++if test "X$lt_ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then
++ lt_ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo"
++fi
+
+-case $host_os in
+-aix3*)
+- version_type=linux
+- library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+- shlibpath_var=LIBPATH
++AC_SUBST(lt_ECHO)
++])
++_LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts])
++_LT_DECL([], [ECHO], [1],
++ [An echo program that does not interpret backslashes])
++])# _LT_PROG_ECHO_BACKSLASH
+
+- # AIX 3 has no versioning support, so we append a major version to the name.
+- soname_spec='${libname}${release}${shared_ext}$major'
+- ;;
+
+-aix4* | aix5*)
+- version_type=linux
+- need_lib_prefix=no
+- need_version=no
+- hardcode_into_libs=yes
+- if test "$host_cpu" = ia64; then
+- # AIX 5 supports IA64
+- library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+- shlibpath_var=LD_LIBRARY_PATH
+- else
+- # With GCC up to 2.95.x, collect2 would create an import file
+- # for dependence libraries. The import file would start with
+- # the line `#! .'. This would cause the generated library to
+- # depend on `.', always an invalid library. This was fixed in
+- # development snapshots of GCC prior to 3.0.
+- case $host_os in
+- aix4 | aix4.[[01]] | aix4.[[01]].*)
+- if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
+- echo ' yes '
+- echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then
+- :
+- else
+- can_build_shared=no
+- fi
+- ;;
++# _LT_ENABLE_LOCK
++# ---------------
++m4_defun([_LT_ENABLE_LOCK],
++[AC_ARG_ENABLE([libtool-lock],
++ [AS_HELP_STRING([--disable-libtool-lock],
++ [avoid locking (might break parallel builds)])])
++test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
++
++# Some flags need to be propagated to the compiler or linker for good
++# libtool support.
++case $host in
++ia64-*-hpux*)
++ # Find out which ABI we are using.
++ echo 'int i;' > conftest.$ac_ext
++ if AC_TRY_EVAL(ac_compile); then
++ case `/usr/bin/file conftest.$ac_objext` in
++ *ELF-32*)
++ HPUX_IA64_MODE="32"
++ ;;
++ *ELF-64*)
++ HPUX_IA64_MODE="64"
++ ;;
+ esac
+- # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+- # soname into executable. Probably we can add versioning support to
+- # collect2, so additional links can be useful in future.
+- if test "$aix_use_runtimelinking" = yes; then
+- # If using run time linking (on AIX 4.2 or later) use lib<name>.so
+- # instead of lib<name>.a to let people know that these are not
+- # typical AIX shared libraries.
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
++ fi
++ rm -rf conftest*
++ ;;
++*-*-irix6*)
++ # Find out which ABI we are using.
++ echo '[#]line __oline__ "configure"' > conftest.$ac_ext
++ if AC_TRY_EVAL(ac_compile); then
++ if test "$lt_cv_prog_gnu_ld" = yes; then
++ case `/usr/bin/file conftest.$ac_objext` in
++ *32-bit*)
++ LD="${LD-ld} -melf32bsmip"
++ ;;
++ *N32*)
++ LD="${LD-ld} -melf32bmipn32"
++ ;;
++ *64-bit*)
++ LD="${LD-ld} -melf64bmip"
++ ;;
++ esac
+ else
+- # We preserve .a as extension for shared libraries through AIX4.2
+- # and later when we are not doing run time linking.
+- library_names_spec='${libname}${release}.a $libname.a'
+- soname_spec='${libname}${release}${shared_ext}$major'
++ case `/usr/bin/file conftest.$ac_objext` in
++ *32-bit*)
++ LD="${LD-ld} -32"
++ ;;
++ *N32*)
++ LD="${LD-ld} -n32"
++ ;;
++ *64-bit*)
++ LD="${LD-ld} -64"
++ ;;
++ esac
+ fi
+- shlibpath_var=LIBPATH
+ fi
++ rm -rf conftest*
+ ;;
+
+-amigaos*)
+- library_names_spec='$libname.ixlibrary $libname.a'
+- # Create ${libname}_ixlibrary.a entries in /sys/libs.
+- finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
++x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
++s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
++ # Find out which ABI we are using.
++ echo 'int i;' > conftest.$ac_ext
++ if AC_TRY_EVAL(ac_compile); then
++ case `/usr/bin/file conftest.o` in
++ *32-bit*)
++ case $host in
++ x86_64-*kfreebsd*-gnu)
++ LD="${LD-ld} -m elf_i386_fbsd"
++ ;;
++ x86_64-*linux*)
++ LD="${LD-ld} -m elf_i386"
++ ;;
++ ppc64-*linux*|powerpc64-*linux*)
++ LD="${LD-ld} -m elf32ppclinux"
++ ;;
++ s390x-*linux*)
++ LD="${LD-ld} -m elf_s390"
++ ;;
++ sparc64-*linux*)
++ LD="${LD-ld} -m elf32_sparc"
++ ;;
++ esac
++ ;;
++ *64-bit*)
++ case $host in
++ x86_64-*kfreebsd*-gnu)
++ LD="${LD-ld} -m elf_x86_64_fbsd"
++ ;;
++ x86_64-*linux*)
++ LD="${LD-ld} -m elf_x86_64"
++ ;;
++ ppc*-*linux*|powerpc*-*linux*)
++ LD="${LD-ld} -m elf64ppc"
++ ;;
++ s390*-*linux*|s390*-*tpf*)
++ LD="${LD-ld} -m elf64_s390"
++ ;;
++ sparc*-*linux*)
++ LD="${LD-ld} -m elf64_sparc"
++ ;;
++ esac
++ ;;
++ esac
++ fi
++ rm -rf conftest*
+ ;;
+
+-beos*)
+- library_names_spec='${libname}${shared_ext}'
+- dynamic_linker="$host_os ld.so"
+- shlibpath_var=LIBRARY_PATH
++*-*-sco3.2v5*)
++ # On SCO OpenServer 5, we need -belf to get full-featured binaries.
++ SAVE_CFLAGS="$CFLAGS"
++ CFLAGS="$CFLAGS -belf"
++ AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
++ [AC_LANG_PUSH(C)
++ AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])
++ AC_LANG_POP])
++ if test x"$lt_cv_cc_needs_belf" != x"yes"; then
++ # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
++ CFLAGS="$SAVE_CFLAGS"
++ fi
+ ;;
+-
+-bsdi[[45]]*)
+- version_type=linux
+- need_version=no
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
+- shlibpath_var=LD_LIBRARY_PATH
+- sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
+- sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
+- # the default ld.so.conf also contains /usr/contrib/lib and
+- # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
+- # libtool to hard-code these into programs
++sparc*-*solaris*)
++ # Find out which ABI we are using.
++ echo 'int i;' > conftest.$ac_ext
++ if AC_TRY_EVAL(ac_compile); then
++ case `/usr/bin/file conftest.o` in
++ *64-bit*)
++ case $lt_cv_prog_gnu_ld in
++ yes*) LD="${LD-ld} -m elf64_sparc" ;;
++ *)
++ if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then
++ LD="${LD-ld} -64"
++ fi
++ ;;
++ esac
++ ;;
++ esac
++ fi
++ rm -rf conftest*
+ ;;
++esac
+
+-cygwin* | mingw* | pw32*)
+- version_type=windows
+- shrext_cmds=".dll"
+- need_version=no
+- need_lib_prefix=no
++need_locks="$enable_libtool_lock"
++])# _LT_ENABLE_LOCK
+
+- case $GCC,$host_os in
+- yes,cygwin* | yes,mingw* | yes,pw32*)
+- library_names_spec='$libname.dll.a'
+- # DLL is installed to $(libdir)/../bin by postinstall_cmds
+- postinstall_cmds='base_file=`basename \${file}`~
+- dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
+- dldir=$destdir/`dirname \$dlpath`~
+- test -d \$dldir || mkdir -p \$dldir~
+- $install_prog $dir/$dlname \$dldir/$dlname~
+- chmod a+x \$dldir/$dlname'
+- postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+- dlpath=$dir/\$dldll~
+- $rm \$dlpath'
+- shlibpath_overrides_runpath=yes
+
+- case $host_os in
+- cygwin*)
+- # Cygwin DLLs use 'cyg' prefix rather than 'lib'
+- soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+- sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
+- ;;
+- mingw*)
+- # MinGW DLLs use traditional 'lib' prefix
+- soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+- sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+- if echo "$sys_lib_search_path_spec" | [grep ';[c-zC-Z]:/' >/dev/null]; then
+- # It is most probably a Windows format PATH printed by
+- # mingw gcc, but we are running on Cygwin. Gcc prints its search
+- # path with ; separators, and with drive letters. We can handle the
+- # drive letters (cygwin fileutils understands them), so leave them,
+- # especially as we might pass files found there to a mingw objdump,
+- # which wouldn't understand a cygwinified path. Ahh.
+- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+- else
+- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
+- fi
+- ;;
+- pw32*)
+- # pw32 DLLs use 'pw' prefix rather than 'lib'
+- library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+- ;;
+- esac
+- ;;
++# _LT_CMD_OLD_ARCHIVE
++# -------------------
++m4_defun([_LT_CMD_OLD_ARCHIVE],
++[AC_CHECK_TOOL(AR, ar, false)
++test -z "$AR" && AR=ar
++test -z "$AR_FLAGS" && AR_FLAGS=cru
++_LT_DECL([], [AR], [1], [The archiver])
++_LT_DECL([], [AR_FLAGS], [1])
++
++AC_CHECK_TOOL(STRIP, strip, :)
++test -z "$STRIP" && STRIP=:
++_LT_DECL([], [STRIP], [1], [A symbol stripping program])
++
++AC_CHECK_TOOL(RANLIB, ranlib, :)
++test -z "$RANLIB" && RANLIB=:
++_LT_DECL([], [RANLIB], [1],
++ [Commands used to install an old-style archive])
++
++# Determine commands to create old-style static archives.
++old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs'
++old_postinstall_cmds='chmod 644 $oldlib'
++old_postuninstall_cmds=
+
++if test -n "$RANLIB"; then
++ case $host_os in
++ openbsd*)
++ old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib"
++ ;;
+ *)
+- library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib'
++ old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib"
+ ;;
+ esac
+- dynamic_linker='Win32 ld.exe'
+- # FIXME: first we should search . and the directory the executable is in
+- shlibpath_var=PATH
+- ;;
++ old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
++fi
++_LT_DECL([], [old_postinstall_cmds], [2])
++_LT_DECL([], [old_postuninstall_cmds], [2])
++_LT_TAGDECL([], [old_archive_cmds], [2],
++ [Commands used to build an old-style archive])
++])# _LT_CMD_OLD_ARCHIVE
+
+-darwin* | rhapsody*)
+- dynamic_linker="$host_os dyld"
+- version_type=darwin
+- need_lib_prefix=no
+- need_version=no
+- library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext'
+- soname_spec='${libname}${release}${major}$shared_ext'
+- shlibpath_overrides_runpath=yes
+- shlibpath_var=DYLD_LIBRARY_PATH
+- shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
+- # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same.
+- if test "$GCC" = yes; then
+- sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"`
+- else
+- sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib'
+- fi
+- sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
+- ;;
+
+-dgux*)
+- version_type=linux
+- need_lib_prefix=no
+- need_version=no
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- shlibpath_var=LD_LIBRARY_PATH
+- ;;
++# _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
++# [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE])
++# ----------------------------------------------------------------
++# Check whether the given compiler option works
++AC_DEFUN([_LT_COMPILER_OPTION],
++[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
++m4_require([_LT_DECL_SED])dnl
++AC_CACHE_CHECK([$1], [$2],
++ [$2=no
++ m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4])
++ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
++ lt_compiler_flag="$3"
++ # Insert the option either (1) after the last *FLAGS variable, or
++ # (2) before a word containing "conftest.", or (3) at the end.
++ # Note that $ac_compile itself does not contain backslashes and begins
++ # with a dollar sign (not a hyphen), so the echo should work correctly.
++ # The option is referenced via a variable to avoid confusing sed.
++ lt_compile=`echo "$ac_compile" | $SED \
++ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
++ -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
++ -e 's:$: $lt_compiler_flag:'`
++ (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
++ (eval "$lt_compile" 2>conftest.err)
++ ac_status=$?
++ cat conftest.err >&AS_MESSAGE_LOG_FD
++ echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
++ if (exit $ac_status) && test -s "$ac_outfile"; then
++ # The compiler can only warn and ignore the option if not recognized
++ # So say no if there are warnings other than the usual output.
++ $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
++ $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
++ if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
++ $2=yes
++ fi
++ fi
++ $RM conftest*
++])
+
+-freebsd1*)
+- dynamic_linker=no
+- ;;
++if test x"[$]$2" = xyes; then
++ m4_if([$5], , :, [$5])
++else
++ m4_if([$6], , :, [$6])
++fi
++])# _LT_COMPILER_OPTION
+
+-kfreebsd*-gnu)
+- version_type=linux
+- need_lib_prefix=no
+- need_version=no
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- shlibpath_var=LD_LIBRARY_PATH
+- shlibpath_overrides_runpath=no
+- hardcode_into_libs=yes
+- dynamic_linker='GNU ld.so'
+- ;;
++# Old name:
++AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION])
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], [])
+
+-freebsd* | dragonfly*)
+- # DragonFly does not have aout. When/if they implement a new
+- # versioning mechanism, adjust this.
+- if test -x /usr/bin/objformat; then
+- objformat=`/usr/bin/objformat`
+- else
+- case $host_os in
+- freebsd[[123]]*) objformat=aout ;;
+- *) objformat=elf ;;
+- esac
+- fi
+- version_type=freebsd-$objformat
+- case $version_type in
+- freebsd-elf*)
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+- need_version=no
+- need_lib_prefix=no
+- ;;
+- freebsd-*)
+- library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+- need_version=yes
+- ;;
+- esac
+- shlibpath_var=LD_LIBRARY_PATH
+- case $host_os in
+- freebsd2*)
+- shlibpath_overrides_runpath=yes
+- ;;
+- freebsd3.[[01]]* | freebsdelf3.[[01]]*)
+- shlibpath_overrides_runpath=yes
+- hardcode_into_libs=yes
++
++# _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
++# [ACTION-SUCCESS], [ACTION-FAILURE])
++# ----------------------------------------------------
++# Check whether the given linker option works
++AC_DEFUN([_LT_LINKER_OPTION],
++[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
++m4_require([_LT_DECL_SED])dnl
++AC_CACHE_CHECK([$1], [$2],
++ [$2=no
++ save_LDFLAGS="$LDFLAGS"
++ LDFLAGS="$LDFLAGS $3"
++ echo "$lt_simple_link_test_code" > conftest.$ac_ext
++ if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
++ # The linker can only warn and ignore the option if not recognized
++ # So say no if there are warnings
++ if test -s conftest.err; then
++ # Append any errors to the config.log.
++ cat conftest.err 1>&AS_MESSAGE_LOG_FD
++ $ECHO "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
++ $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
++ if diff conftest.exp conftest.er2 >/dev/null; then
++ $2=yes
++ fi
++ else
++ $2=yes
++ fi
++ fi
++ $RM -r conftest*
++ LDFLAGS="$save_LDFLAGS"
++])
++
++if test x"[$]$2" = xyes; then
++ m4_if([$4], , :, [$4])
++else
++ m4_if([$5], , :, [$5])
++fi
++])# _LT_LINKER_OPTION
++
++# Old name:
++AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION])
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], [])
++
++
++# LT_CMD_MAX_LEN
++#---------------
++AC_DEFUN([LT_CMD_MAX_LEN],
++[AC_REQUIRE([AC_CANONICAL_HOST])dnl
++# find the maximum length of command line arguments
++AC_MSG_CHECKING([the maximum length of command line arguments])
++AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
++ i=0
++ teststring="ABCD"
++
++ case $build_os in
++ msdosdjgpp*)
++ # On DJGPP, this test can blow up pretty badly due to problems in libc
++ # (any single argument exceeding 2000 bytes causes a buffer overrun
++ # during glob expansion). Even if it were fixed, the result of this
++ # check would be larger than it should be.
++ lt_cv_sys_max_cmd_len=12288; # 12K is about right
+ ;;
+- freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \
+- freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1)
+- shlibpath_overrides_runpath=no
+- hardcode_into_libs=yes
++
++ gnu*)
++ # Under GNU Hurd, this test is not required because there is
++ # no limit to the length of command line arguments.
++ # Libtool will interpret -1 as no limit whatsoever
++ lt_cv_sys_max_cmd_len=-1;
+ ;;
+- freebsd*) # from 4.6 on
+- shlibpath_overrides_runpath=yes
+- hardcode_into_libs=yes
++
++ cygwin* | mingw*)
++ # On Win9x/ME, this test blows up -- it succeeds, but takes
++ # about 5 minutes as the teststring grows exponentially.
++ # Worse, since 9x/ME are not pre-emptively multitasking,
++ # you end up with a "frozen" computer, even though with patience
++ # the test eventually succeeds (with a max line length of 256k).
++ # Instead, let's just punt: use the minimum linelength reported by
++ # all of the supported platforms: 8192 (on NT/2K/XP).
++ lt_cv_sys_max_cmd_len=8192;
+ ;;
+- esac
+- ;;
+
+-gnu*)
+- version_type=linux
+- need_lib_prefix=no
+- need_version=no
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- shlibpath_var=LD_LIBRARY_PATH
+- hardcode_into_libs=yes
+- ;;
++ amigaos*)
++ # On AmigaOS with pdksh, this test takes hours, literally.
++ # So we just punt and use a minimum line length of 8192.
++ lt_cv_sys_max_cmd_len=8192;
++ ;;
+
+-hpux9* | hpux10* | hpux11*)
+- # Give a soname corresponding to the major version so that dld.sl refuses to
+- # link against other versions.
+- version_type=sunos
+- need_lib_prefix=no
+- need_version=no
+- case $host_cpu in
+- ia64*)
+- shrext_cmds='.so'
+- hardcode_into_libs=yes
+- dynamic_linker="$host_os dld.so"
+- shlibpath_var=LD_LIBRARY_PATH
+- shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- if test "X$HPUX_IA64_MODE" = X32; then
+- sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
++ netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
++ # This has been around since 386BSD, at least. Likely further.
++ if test -x /sbin/sysctl; then
++ lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
++ elif test -x /usr/sbin/sysctl; then
++ lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
+ else
+- sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
++ lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs
+ fi
+- sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+- ;;
+- hppa*64*)
+- shrext_cmds='.sl'
+- hardcode_into_libs=yes
+- dynamic_linker="$host_os dld.sl"
+- shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
+- shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
+- sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+- ;;
+- *)
+- shrext_cmds='.sl'
+- dynamic_linker="$host_os dld.sl"
+- shlibpath_var=SHLIB_PATH
+- shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
++ # And add a safety zone
++ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
++ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+ ;;
+- esac
+- # HP-UX runs *really* slowly unless shared libraries are mode 555.
+- postinstall_cmds='chmod 555 $lib'
+- ;;
+
+-interix3*)
+- version_type=linux
+- need_lib_prefix=no
+- need_version=no
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
+- shlibpath_var=LD_LIBRARY_PATH
+- shlibpath_overrides_runpath=no
+- hardcode_into_libs=yes
+- ;;
++ interix*)
++ # We know the value 262144 and hardcode it with a safety zone (like BSD)
++ lt_cv_sys_max_cmd_len=196608
++ ;;
+
+-irix5* | irix6* | nonstopux*)
+- case $host_os in
+- nonstopux*) version_type=nonstopux ;;
+- *)
+- if test "$lt_cv_prog_gnu_ld" = yes; then
+- version_type=linux
+- else
+- version_type=irix
+- fi ;;
+- esac
+- need_lib_prefix=no
+- need_version=no
+- soname_spec='${libname}${release}${shared_ext}$major'
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+- case $host_os in
+- irix5* | nonstopux*)
+- libsuff= shlibsuff=
++ osf*)
++ # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
++ # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
++ # nice to cause kernel panics so lets avoid the loop below.
++ # First set a reasonable default.
++ lt_cv_sys_max_cmd_len=16384
++ #
++ if test -x /sbin/sysconfig; then
++ case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
++ *1*) lt_cv_sys_max_cmd_len=-1 ;;
++ esac
++ fi
++ ;;
++ sco3.2v5*)
++ lt_cv_sys_max_cmd_len=102400
++ ;;
++ sysv5* | sco5v6* | sysv4.2uw2*)
++ kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
++ if test -n "$kargmax"; then
++ lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'`
++ else
++ lt_cv_sys_max_cmd_len=32768
++ fi
+ ;;
+ *)
+- case $LD in # libtool.m4 will add one of these switches to LD
+- *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
+- libsuff= shlibsuff= libmagic=32-bit;;
+- *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
+- libsuff=32 shlibsuff=N32 libmagic=N32;;
+- *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
+- libsuff=64 shlibsuff=64 libmagic=64-bit;;
+- *) libsuff= shlibsuff= libmagic=never-match;;
+- esac
++ lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`
++ if test -n "$lt_cv_sys_max_cmd_len"; then
++ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
++ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
++ else
++ # Make teststring a little bigger before we do anything with it.
++ # a 1K string should be a reasonable start.
++ for i in 1 2 3 4 5 6 7 8 ; do
++ teststring=$teststring$teststring
++ done
++ SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
++ # If test is not a shell built-in, we'll probably end up computing a
++ # maximum length that is only half of the actual maximum length, but
++ # we can't tell.
++ while { test "X"`$SHELL [$]0 --fallback-echo "X$teststring$teststring" 2>/dev/null` \
++ = "XX$teststring$teststring"; } >/dev/null 2>&1 &&
++ test $i != 17 # 1/2 MB should be enough
++ do
++ i=`expr $i + 1`
++ teststring=$teststring$teststring
++ done
++ # Only check the string length outside the loop.
++ lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1`
++ teststring=
++ # Add a significant safety factor because C++ compilers can tack on
++ # massive amounts of additional arguments before passing them to the
++ # linker. It appears as though 1/2 is a usable value.
++ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
++ fi
+ ;;
+ esac
+- shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
+- shlibpath_overrides_runpath=no
+- sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
+- sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+- hardcode_into_libs=yes
+- ;;
++])
++if test -n $lt_cv_sys_max_cmd_len ; then
++ AC_MSG_RESULT($lt_cv_sys_max_cmd_len)
++else
++ AC_MSG_RESULT(none)
++fi
++max_cmd_len=$lt_cv_sys_max_cmd_len
++_LT_DECL([], [max_cmd_len], [0],
++ [What is the maximum length of a command?])
++])# LT_CMD_MAX_LEN
+
+-# No shared lib support for Linux oldld, aout, or coff.
+-linux*oldld* | linux*aout* | linux*coff*)
+- dynamic_linker=no
+- ;;
++# Old name:
++AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN])
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], [])
+
+-# This must be Linux ELF.
+-linux*)
+- version_type=linux
+- need_lib_prefix=no
+- need_version=no
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
+- shlibpath_var=LD_LIBRARY_PATH
+- shlibpath_overrides_runpath=no
+- # This implies no fast_install, which is unacceptable.
+- # Some rework will be needed to allow for fast_install
+- # before this can be enabled.
+- hardcode_into_libs=yes
+
+- # Append ld.so.conf contents to the search path
+- if test -f /etc/ld.so.conf; then
+- lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
+- sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+- fi
++# _LT_HEADER_DLFCN
++# ----------------
++m4_defun([_LT_HEADER_DLFCN],
++[AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl
++])# _LT_HEADER_DLFCN
+
+- # We used to test for /lib/ld.so.1 and disable shared libraries on
+- # powerpc, because MkLinux only supported shared libraries with the
+- # GNU dynamic linker. Since this was broken with cross compilers,
+- # most powerpc-linux boxes support dynamic linking these days and
+- # people can always --disable-shared, the test was removed, and we
+- # assume the GNU/Linux dynamic linker is in use.
+- dynamic_linker='GNU/Linux ld.so'
+- ;;
+
+-knetbsd*-gnu)
+- version_type=linux
+- need_lib_prefix=no
+- need_version=no
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- shlibpath_var=LD_LIBRARY_PATH
+- shlibpath_overrides_runpath=no
+- hardcode_into_libs=yes
+- dynamic_linker='GNU ld.so'
+- ;;
++# _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE,
++# ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING)
++# ----------------------------------------------------------------
++m4_defun([_LT_TRY_DLOPEN_SELF],
++[m4_require([_LT_HEADER_DLFCN])dnl
++if test "$cross_compiling" = yes; then :
++ [$4]
++else
++ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
++ lt_status=$lt_dlunknown
++ cat > conftest.$ac_ext <<_LT_EOF
++[#line __oline__ "configure"
++#include "confdefs.h"
+
+-netbsd*)
+- version_type=sunos
+- need_lib_prefix=no
+- need_version=no
+- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+- finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+- dynamic_linker='NetBSD (a.out) ld.so'
+- else
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- dynamic_linker='NetBSD ld.elf_so'
+- fi
+- shlibpath_var=LD_LIBRARY_PATH
+- shlibpath_overrides_runpath=yes
+- hardcode_into_libs=yes
+- ;;
++#if HAVE_DLFCN_H
++#include <dlfcn.h>
++#endif
+
+-newsos6)
+- version_type=linux
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+- shlibpath_var=LD_LIBRARY_PATH
+- shlibpath_overrides_runpath=yes
+- ;;
++#include <stdio.h>
+
+-nto-qnx*)
+- version_type=linux
+- need_lib_prefix=no
+- need_version=no
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- shlibpath_var=LD_LIBRARY_PATH
+- shlibpath_overrides_runpath=yes
+- ;;
++#ifdef RTLD_GLOBAL
++# define LT_DLGLOBAL RTLD_GLOBAL
++#else
++# ifdef DL_GLOBAL
++# define LT_DLGLOBAL DL_GLOBAL
++# else
++# define LT_DLGLOBAL 0
++# endif
++#endif
+
+-openbsd*)
+- version_type=sunos
+- sys_lib_dlsearch_path_spec="/usr/lib"
+- need_lib_prefix=no
+- # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
+- case $host_os in
+- openbsd3.3 | openbsd3.3.*) need_version=yes ;;
+- *) need_version=no ;;
+- esac
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+- finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+- shlibpath_var=LD_LIBRARY_PATH
+- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+- case $host_os in
+- openbsd2.[[89]] | openbsd2.[[89]].*)
+- shlibpath_overrides_runpath=no
+- ;;
+- *)
+- shlibpath_overrides_runpath=yes
+- ;;
+- esac
++/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
++ find out it does not work in some platform. */
++#ifndef LT_DLLAZY_OR_NOW
++# ifdef RTLD_LAZY
++# define LT_DLLAZY_OR_NOW RTLD_LAZY
++# else
++# ifdef DL_LAZY
++# define LT_DLLAZY_OR_NOW DL_LAZY
++# else
++# ifdef RTLD_NOW
++# define LT_DLLAZY_OR_NOW RTLD_NOW
++# else
++# ifdef DL_NOW
++# define LT_DLLAZY_OR_NOW DL_NOW
++# else
++# define LT_DLLAZY_OR_NOW 0
++# endif
++# endif
++# endif
++# endif
++#endif
++
++#ifdef __cplusplus
++extern "C" void exit (int);
++#endif
++
++void fnord() { int i=42;}
++int main ()
++{
++ void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
++ int status = $lt_dlunknown;
++
++ if (self)
++ {
++ if (dlsym (self,"fnord")) status = $lt_dlno_uscore;
++ else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
++ /* dlclose (self); */
++ }
+ else
+- shlibpath_overrides_runpath=yes
++ puts (dlerror ());
++
++ exit (status);
++}]
++_LT_EOF
++ if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then
++ (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null
++ lt_status=$?
++ case x$lt_status in
++ x$lt_dlno_uscore) $1 ;;
++ x$lt_dlneed_uscore) $2 ;;
++ x$lt_dlunknown|x*) $3 ;;
++ esac
++ else :
++ # compilation failed
++ $3
+ fi
+- ;;
++fi
++rm -fr conftest*
++])# _LT_TRY_DLOPEN_SELF
+
+-os2*)
+- libname_spec='$name'
+- shrext_cmds=".dll"
+- need_lib_prefix=no
+- library_names_spec='$libname${shared_ext} $libname.a'
+- dynamic_linker='OS/2 ld.exe'
+- shlibpath_var=LIBPATH
+- ;;
+
+-osf3* | osf4* | osf5*)
+- version_type=osf
+- need_lib_prefix=no
+- need_version=no
+- soname_spec='${libname}${release}${shared_ext}$major'
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+- shlibpath_var=LD_LIBRARY_PATH
+- sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
+- sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+- ;;
++# LT_SYS_DLOPEN_SELF
++# ------------------
++AC_DEFUN([LT_SYS_DLOPEN_SELF],
++[m4_require([_LT_HEADER_DLFCN])dnl
++if test "x$enable_dlopen" != xyes; then
++ enable_dlopen=unknown
++ enable_dlopen_self=unknown
++ enable_dlopen_self_static=unknown
++else
++ lt_cv_dlopen=no
++ lt_cv_dlopen_libs=
+
+-solaris*)
+- version_type=linux
+- need_lib_prefix=no
+- need_version=no
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- shlibpath_var=LD_LIBRARY_PATH
+- shlibpath_overrides_runpath=yes
+- hardcode_into_libs=yes
+- # ldd complains unless libraries are executable
+- postinstall_cmds='chmod +x $lib'
+- ;;
++ case $host_os in
++ beos*)
++ lt_cv_dlopen="load_add_on"
++ lt_cv_dlopen_libs=
++ lt_cv_dlopen_self=yes
++ ;;
+
+-sunos4*)
+- version_type=sunos
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+- finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
+- shlibpath_var=LD_LIBRARY_PATH
+- shlibpath_overrides_runpath=yes
+- if test "$with_gnu_ld" = yes; then
+- need_lib_prefix=no
+- fi
+- need_version=yes
+- ;;
++ mingw* | pw32*)
++ lt_cv_dlopen="LoadLibrary"
++ lt_cv_dlopen_libs=
++ ;;
+
+-sysv4 | sysv4.3*)
+- version_type=linux
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- shlibpath_var=LD_LIBRARY_PATH
+- case $host_vendor in
+- sni)
+- shlibpath_overrides_runpath=no
+- need_lib_prefix=no
+- export_dynamic_flag_spec='${wl}-Blargedynsym'
+- runpath_var=LD_RUN_PATH
+- ;;
+- siemens)
+- need_lib_prefix=no
+- ;;
+- motorola)
+- need_lib_prefix=no
+- need_version=no
+- shlibpath_overrides_runpath=no
+- sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
+- ;;
+- esac
+- ;;
++ cygwin*)
++ lt_cv_dlopen="dlopen"
++ lt_cv_dlopen_libs=
++ ;;
+
+-sysv4*MP*)
+- if test -d /usr/nec ;then
+- version_type=linux
+- library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
+- soname_spec='$libname${shared_ext}.$major'
+- shlibpath_var=LD_LIBRARY_PATH
+- fi
+- ;;
++ darwin*)
++ # if libdl is installed we need to link against it
++ AC_CHECK_LIB([dl], [dlopen],
++ [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[
++ lt_cv_dlopen="dyld"
++ lt_cv_dlopen_libs=
++ lt_cv_dlopen_self=yes
++ ])
++ ;;
+
+-sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+- version_type=freebsd-elf
+- need_lib_prefix=no
+- need_version=no
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- shlibpath_var=LD_LIBRARY_PATH
+- hardcode_into_libs=yes
+- if test "$with_gnu_ld" = yes; then
+- sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
+- shlibpath_overrides_runpath=no
++ *)
++ AC_CHECK_FUNC([shl_load],
++ [lt_cv_dlopen="shl_load"],
++ [AC_CHECK_LIB([dld], [shl_load],
++ [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"],
++ [AC_CHECK_FUNC([dlopen],
++ [lt_cv_dlopen="dlopen"],
++ [AC_CHECK_LIB([dl], [dlopen],
++ [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],
++ [AC_CHECK_LIB([svld], [dlopen],
++ [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"],
++ [AC_CHECK_LIB([dld], [dld_link],
++ [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"])
++ ])
++ ])
++ ])
++ ])
++ ])
++ ;;
++ esac
++
++ if test "x$lt_cv_dlopen" != xno; then
++ enable_dlopen=yes
+ else
+- sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
+- shlibpath_overrides_runpath=yes
+- case $host_os in
+- sco3.2v5*)
+- sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
+- ;;
+- esac
++ enable_dlopen=no
+ fi
+- sys_lib_dlsearch_path_spec='/usr/lib'
+- ;;
+-
+-uts4*)
+- version_type=linux
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- shlibpath_var=LD_LIBRARY_PATH
+- ;;
+-
+-*)
+- dynamic_linker=no
+- ;;
+-esac
+-AC_MSG_RESULT([$dynamic_linker])
+-test "$dynamic_linker" = no && can_build_shared=no
+-
+-variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
+-if test "$GCC" = yes; then
+- variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
+-fi
+-])# AC_LIBTOOL_SYS_DYNAMIC_LINKER
+-
+
+-# _LT_AC_TAGCONFIG
+-# ----------------
+-AC_DEFUN([_LT_AC_TAGCONFIG],
+-[AC_ARG_WITH([tags],
+- [AC_HELP_STRING([--with-tags@<:@=TAGS@:>@],
+- [include additional configurations @<:@automatic@:>@])],
+- [tagnames="$withval"])
+-
+-if test -f "$ltmain" && test -n "$tagnames"; then
+- if test ! -f "${ofile}"; then
+- AC_MSG_WARN([output file `$ofile' does not exist])
+- fi
++ case $lt_cv_dlopen in
++ dlopen)
++ save_CPPFLAGS="$CPPFLAGS"
++ test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
+
+- if test -z "$LTCC"; then
+- eval "`$SHELL ${ofile} --config | grep '^LTCC='`"
+- if test -z "$LTCC"; then
+- AC_MSG_WARN([output file `$ofile' does not look like a libtool script])
+- else
+- AC_MSG_WARN([using `LTCC=$LTCC', extracted from `$ofile'])
+- fi
+- fi
+- if test -z "$LTCFLAGS"; then
+- eval "`$SHELL ${ofile} --config | grep '^LTCFLAGS='`"
+- fi
++ save_LDFLAGS="$LDFLAGS"
++ wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
+
+- # Extract list of available tagged configurations in $ofile.
+- # Note that this assumes the entire list is on one line.
+- available_tags=`grep "^available_tags=" "${ofile}" | $SED -e 's/available_tags=\(.*$\)/\1/' -e 's/\"//g'`
++ save_LIBS="$LIBS"
++ LIBS="$lt_cv_dlopen_libs $LIBS"
+
+- lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+- for tagname in $tagnames; do
+- IFS="$lt_save_ifs"
+- # Check whether tagname contains only valid characters
+- case `$echo "X$tagname" | $Xsed -e 's:[[-_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890,/]]::g'` in
+- "") ;;
+- *) AC_MSG_ERROR([invalid tag name: $tagname])
+- ;;
+- esac
++ AC_CACHE_CHECK([whether a program can dlopen itself],
++ lt_cv_dlopen_self, [dnl
++ _LT_TRY_DLOPEN_SELF(
++ lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes,
++ lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross)
++ ])
+
+- if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "${ofile}" > /dev/null
+- then
+- AC_MSG_ERROR([tag name \"$tagname\" already exists])
++ if test "x$lt_cv_dlopen_self" = xyes; then
++ wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
++ AC_CACHE_CHECK([whether a statically linked program can dlopen itself],
++ lt_cv_dlopen_self_static, [dnl
++ _LT_TRY_DLOPEN_SELF(
++ lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes,
++ lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross)
++ ])
+ fi
+
+- # Update the list of available tags.
+- if test -n "$tagname"; then
+- echo appending configuration tag \"$tagname\" to $ofile
+-
+- case $tagname in
+- CXX)
+- if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
+- ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
+- (test "X$CXX" != "Xg++"))) ; then
+- AC_LIBTOOL_LANG_CXX_CONFIG
+- else
+- tagname=""
+- fi
+- ;;
+-
+- F77)
+- if test -n "$F77" && test "X$F77" != "Xno"; then
+- AC_LIBTOOL_LANG_F77_CONFIG
+- else
+- tagname=""
+- fi
+- ;;
+-
+- GCJ)
+- if test -n "$GCJ" && test "X$GCJ" != "Xno"; then
+- AC_LIBTOOL_LANG_GCJ_CONFIG
+- else
+- tagname=""
+- fi
+- ;;
+-
+- RC)
+- AC_LIBTOOL_LANG_RC_CONFIG
+- ;;
+-
+- *)
+- AC_MSG_ERROR([Unsupported tag name: $tagname])
+- ;;
+- esac
++ CPPFLAGS="$save_CPPFLAGS"
++ LDFLAGS="$save_LDFLAGS"
++ LIBS="$save_LIBS"
++ ;;
++ esac
+
+- # Append the new tag name to the list of available tags.
+- if test -n "$tagname" ; then
+- available_tags="$available_tags $tagname"
+- fi
+- fi
+- done
+- IFS="$lt_save_ifs"
++ case $lt_cv_dlopen_self in
++ yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
++ *) enable_dlopen_self=unknown ;;
++ esac
+
+- # Now substitute the updated list of available tags.
+- if eval "sed -e 's/^available_tags=.*\$/available_tags=\"$available_tags\"/' \"$ofile\" > \"${ofile}T\""; then
+- mv "${ofile}T" "$ofile"
+- chmod +x "$ofile"
+- else
+- rm -f "${ofile}T"
+- AC_MSG_ERROR([unable to update list of available tagged configurations.])
+- fi
++ case $lt_cv_dlopen_self_static in
++ yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
++ *) enable_dlopen_self_static=unknown ;;
++ esac
+ fi
+-])# _LT_AC_TAGCONFIG
++_LT_DECL([dlopen_support], [enable_dlopen], [0],
++ [Whether dlopen is supported])
++_LT_DECL([dlopen_self], [enable_dlopen_self], [0],
++ [Whether dlopen of programs is supported])
++_LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0],
++ [Whether dlopen of statically linked programs is supported])
++])# LT_SYS_DLOPEN_SELF
++
++# Old name:
++AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF])
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], [])
+
+
+-# AC_LIBTOOL_DLOPEN
+-# -----------------
+-# enable checks for dlopen support
+-AC_DEFUN([AC_LIBTOOL_DLOPEN],
+- [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])
+-])# AC_LIBTOOL_DLOPEN
++# _LT_COMPILER_C_O([TAGNAME])
++# ---------------------------
++# Check to see if options -c and -o are simultaneously supported by compiler.
++# This macro does not hard code the compiler like AC_PROG_CC_C_O.
++m4_defun([_LT_COMPILER_C_O],
++[m4_require([_LT_DECL_SED])dnl
++m4_require([_LT_FILEUTILS_DEFAULTS])dnl
++m4_require([_LT_TAG_COMPILER])dnl
++AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext],
++ [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)],
++ [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no
++ $RM -r conftest 2>/dev/null
++ mkdir conftest
++ cd conftest
++ mkdir out
++ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
++ lt_compiler_flag="-o out/conftest2.$ac_objext"
++ # Insert the option either (1) after the last *FLAGS variable, or
++ # (2) before a word containing "conftest.", or (3) at the end.
++ # Note that $ac_compile itself does not contain backslashes and begins
++ # with a dollar sign (not a hyphen), so the echo should work correctly.
++ lt_compile=`echo "$ac_compile" | $SED \
++ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
++ -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
++ -e 's:$: $lt_compiler_flag:'`
++ (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
++ (eval "$lt_compile" 2>out/conftest.err)
++ ac_status=$?
++ cat out/conftest.err >&AS_MESSAGE_LOG_FD
++ echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
++ if (exit $ac_status) && test -s out/conftest2.$ac_objext
++ then
++ # The compiler can only warn and ignore the option if not recognized
++ # So say no if there are warnings
++ $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
++ $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
++ if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
++ _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
++ fi
++ fi
++ chmod u+w . 2>&AS_MESSAGE_LOG_FD
++ $RM conftest*
++ # SGI C++ compiler will create directory out/ii_files/ for
++ # template instantiation
++ test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
++ $RM out/* && rmdir out
++ cd ..
++ $RM -r conftest
++ $RM conftest*
++])
++_LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1],
++ [Does compiler simultaneously support -c and -o options?])
++])# _LT_COMPILER_C_O
+
+-# AC_LIBTOOL_WIN32_DLL
+-# --------------------
+-# declare package support for building win32 DLLs
+-AC_DEFUN([AC_LIBTOOL_WIN32_DLL],
+-[AC_BEFORE([$0], [AC_LIBTOOL_SETUP])
+-])# AC_LIBTOOL_WIN32_DLL
+
++# _LT_COMPILER_FILE_LOCKS([TAGNAME])
++# ----------------------------------
++# Check to see if we can do hard links to lock some files if needed
++m4_defun([_LT_COMPILER_FILE_LOCKS],
++[m4_require([_LT_ENABLE_LOCK])dnl
++m4_require([_LT_FILEUTILS_DEFAULTS])dnl
++_LT_COMPILER_C_O([$1])
+
+-# AC_ENABLE_SHARED([DEFAULT])
+-# ---------------------------
+-# implement the --enable-shared flag
+-# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
+-AC_DEFUN([AC_ENABLE_SHARED],
+-[define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl
+-AC_ARG_ENABLE([shared],
+- [AC_HELP_STRING([--enable-shared@<:@=PKGS@:>@],
+- [build shared libraries @<:@default=]AC_ENABLE_SHARED_DEFAULT[@:>@])],
+- [p=${PACKAGE-default}
+- case $enableval in
+- yes) enable_shared=yes ;;
+- no) enable_shared=no ;;
+- *)
+- enable_shared=no
+- # Look at the argument we got. We use all the common list separators.
+- lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+- for pkg in $enableval; do
+- IFS="$lt_save_ifs"
+- if test "X$pkg" = "X$p"; then
+- enable_shared=yes
+- fi
+- done
+- IFS="$lt_save_ifs"
+- ;;
+- esac],
+- [enable_shared=]AC_ENABLE_SHARED_DEFAULT)
+-])# AC_ENABLE_SHARED
+-
+-
+-# AC_DISABLE_SHARED
+-# -----------------
+-# set the default shared flag to --disable-shared
+-AC_DEFUN([AC_DISABLE_SHARED],
+-[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+-AC_ENABLE_SHARED(no)
+-])# AC_DISABLE_SHARED
+-
+-
+-# AC_ENABLE_STATIC([DEFAULT])
+-# ---------------------------
+-# implement the --enable-static flag
+-# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
+-AC_DEFUN([AC_ENABLE_STATIC],
+-[define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl
+-AC_ARG_ENABLE([static],
+- [AC_HELP_STRING([--enable-static@<:@=PKGS@:>@],
+- [build static libraries @<:@default=]AC_ENABLE_STATIC_DEFAULT[@:>@])],
+- [p=${PACKAGE-default}
+- case $enableval in
+- yes) enable_static=yes ;;
+- no) enable_static=no ;;
+- *)
+- enable_static=no
+- # Look at the argument we got. We use all the common list separators.
+- lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+- for pkg in $enableval; do
+- IFS="$lt_save_ifs"
+- if test "X$pkg" = "X$p"; then
+- enable_static=yes
+- fi
+- done
+- IFS="$lt_save_ifs"
+- ;;
+- esac],
+- [enable_static=]AC_ENABLE_STATIC_DEFAULT)
+-])# AC_ENABLE_STATIC
+-
+-
+-# AC_DISABLE_STATIC
+-# -----------------
+-# set the default static flag to --disable-static
+-AC_DEFUN([AC_DISABLE_STATIC],
+-[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+-AC_ENABLE_STATIC(no)
+-])# AC_DISABLE_STATIC
+-
+-
+-# AC_ENABLE_FAST_INSTALL([DEFAULT])
+-# ---------------------------------
+-# implement the --enable-fast-install flag
+-# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
+-AC_DEFUN([AC_ENABLE_FAST_INSTALL],
+-[define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl
+-AC_ARG_ENABLE([fast-install],
+- [AC_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@],
+- [optimize for fast installation @<:@default=]AC_ENABLE_FAST_INSTALL_DEFAULT[@:>@])],
+- [p=${PACKAGE-default}
+- case $enableval in
+- yes) enable_fast_install=yes ;;
+- no) enable_fast_install=no ;;
+- *)
+- enable_fast_install=no
+- # Look at the argument we got. We use all the common list separators.
+- lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+- for pkg in $enableval; do
+- IFS="$lt_save_ifs"
+- if test "X$pkg" = "X$p"; then
+- enable_fast_install=yes
+- fi
+- done
+- IFS="$lt_save_ifs"
+- ;;
+- esac],
+- [enable_fast_install=]AC_ENABLE_FAST_INSTALL_DEFAULT)
+-])# AC_ENABLE_FAST_INSTALL
+-
+-
+-# AC_DISABLE_FAST_INSTALL
+-# -----------------------
+-# set the default to --disable-fast-install
+-AC_DEFUN([AC_DISABLE_FAST_INSTALL],
+-[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+-AC_ENABLE_FAST_INSTALL(no)
+-])# AC_DISABLE_FAST_INSTALL
+-
+-
+-# AC_LIBTOOL_PICMODE([MODE])
+-# --------------------------
+-# implement the --with-pic flag
+-# MODE is either `yes' or `no'. If omitted, it defaults to `both'.
+-AC_DEFUN([AC_LIBTOOL_PICMODE],
+-[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+-pic_mode=ifelse($#,1,$1,default)
+-])# AC_LIBTOOL_PICMODE
+-
+-
+-# AC_PROG_EGREP
+-# -------------
+-# This is predefined starting with Autoconf 2.54, so this conditional
+-# definition can be removed once we require Autoconf 2.54 or later.
+-m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP],
+-[AC_CACHE_CHECK([for egrep], [ac_cv_prog_egrep],
+- [if echo a | (grep -E '(a|b)') >/dev/null 2>&1
+- then ac_cv_prog_egrep='grep -E'
+- else ac_cv_prog_egrep='egrep'
+- fi])
+- EGREP=$ac_cv_prog_egrep
+- AC_SUBST([EGREP])
+-])])
+-
+-
+-# AC_PATH_TOOL_PREFIX
+-# -------------------
+-# find a file program which can recognise shared library
+-AC_DEFUN([AC_PATH_TOOL_PREFIX],
+-[AC_REQUIRE([AC_PROG_EGREP])dnl
+-AC_MSG_CHECKING([for $1])
+-AC_CACHE_VAL(lt_cv_path_MAGIC_CMD,
+-[case $MAGIC_CMD in
+-[[\\/*] | ?:[\\/]*])
+- lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+- ;;
+-*)
+- lt_save_MAGIC_CMD="$MAGIC_CMD"
+- lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+-dnl $ac_dummy forces splitting on constant user-supplied paths.
+-dnl POSIX.2 word splitting is done only on the output of word expansions,
+-dnl not every word. This closes a longstanding sh security hole.
+- ac_dummy="ifelse([$2], , $PATH, [$2])"
+- for ac_dir in $ac_dummy; do
+- IFS="$lt_save_ifs"
+- test -z "$ac_dir" && ac_dir=.
+- if test -f $ac_dir/$1; then
+- lt_cv_path_MAGIC_CMD="$ac_dir/$1"
+- if test -n "$file_magic_test_file"; then
+- case $deplibs_check_method in
+- "file_magic "*)
+- file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
+- MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+- if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
+- $EGREP "$file_magic_regex" > /dev/null; then
+- :
+- else
+- cat <<EOF 1>&2
++hard_links="nottested"
++if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then
++ # do not overwrite the value of need_locks provided by the user
++ AC_MSG_CHECKING([if we can lock with hard links])
++ hard_links=yes
++ $RM conftest*
++ ln conftest.a conftest.b 2>/dev/null && hard_links=no
++ touch conftest.a
++ ln conftest.a conftest.b 2>&5 || hard_links=no
++ ln conftest.a conftest.b 2>/dev/null && hard_links=no
++ AC_MSG_RESULT([$hard_links])
++ if test "$hard_links" = no; then
++ AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe])
++ need_locks=warn
++ fi
++else
++ need_locks=no
++fi
++_LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?])
++])# _LT_COMPILER_FILE_LOCKS
+
+-*** Warning: the command libtool uses to detect shared libraries,
+-*** $file_magic_cmd, produces output that libtool cannot recognize.
+-*** The result is that libtool may fail to recognize shared libraries
+-*** as such. This will affect the creation of libtool libraries that
+-*** depend on shared libraries, but programs linked with such libtool
+-*** libraries will work regardless of this problem. Nevertheless, you
+-*** may want to report the problem to your system manager and/or to
+-*** bug-libtool@gnu.org
+
+-EOF
+- fi ;;
+- esac
+- fi
+- break
+- fi
+- done
+- IFS="$lt_save_ifs"
+- MAGIC_CMD="$lt_save_MAGIC_CMD"
+- ;;
+-esac])
+-MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+-if test -n "$MAGIC_CMD"; then
+- AC_MSG_RESULT($MAGIC_CMD)
++# _LT_CHECK_OBJDIR
++# ----------------
++m4_defun([_LT_CHECK_OBJDIR],
++[AC_CACHE_CHECK([for objdir], [lt_cv_objdir],
++[rm -f .libs 2>/dev/null
++mkdir .libs 2>/dev/null
++if test -d .libs; then
++ lt_cv_objdir=.libs
+ else
+- AC_MSG_RESULT(no)
++ # MS-DOS does not allow filenames that begin with a dot.
++ lt_cv_objdir=_libs
+ fi
+-])# AC_PATH_TOOL_PREFIX
++rmdir .libs 2>/dev/null])
++objdir=$lt_cv_objdir
++_LT_DECL([], [objdir], [0],
++ [The name of the directory that contains temporary libtool files])dnl
++m4_pattern_allow([LT_OBJDIR])dnl
++AC_DEFINE_UNQUOTED(LT_OBJDIR, "$lt_cv_objdir/",
++ [Define to the sub-directory in which libtool stores uninstalled libraries.])
++])# _LT_CHECK_OBJDIR
+
+
+-# AC_PATH_MAGIC
+-# -------------
+-# find a file program which can recognise a shared library
+-AC_DEFUN([AC_PATH_MAGIC],
+-[AC_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH)
+-if test -z "$lt_cv_path_MAGIC_CMD"; then
+- if test -n "$ac_tool_prefix"; then
+- AC_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH)
++# _LT_LINKER_HARDCODE_LIBPATH([TAGNAME])
++# --------------------------------------
++# Check hardcoding attributes.
++m4_defun([_LT_LINKER_HARDCODE_LIBPATH],
++[AC_MSG_CHECKING([how to hardcode library paths into programs])
++_LT_TAGVAR(hardcode_action, $1)=
++if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" ||
++ test -n "$_LT_TAGVAR(runpath_var, $1)" ||
++ test "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then
++
++ # We can hardcode non-existent directories.
++ if test "$_LT_TAGVAR(hardcode_direct, $1)" != no &&
++ # If the only mechanism to avoid hardcoding is shlibpath_var, we
++ # have to relink, otherwise we might link with an installed library
++ # when we should be linking with a yet-to-be-installed one
++ ## test "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" != no &&
++ test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; then
++ # Linking always hardcodes the temporary library directory.
++ _LT_TAGVAR(hardcode_action, $1)=relink
+ else
+- MAGIC_CMD=:
++ # We can link without hardcoding, and we can hardcode nonexisting dirs.
++ _LT_TAGVAR(hardcode_action, $1)=immediate
+ fi
++else
++ # We cannot hardcode anything, or else we can only hardcode existing
++ # directories.
++ _LT_TAGVAR(hardcode_action, $1)=unsupported
++fi
++AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)])
++
++if test "$_LT_TAGVAR(hardcode_action, $1)" = relink ||
++ test "$_LT_TAGVAR(inherit_rpath, $1)" = yes; then
++ # Fast installation is not supported
++ enable_fast_install=no
++elif test "$shlibpath_overrides_runpath" = yes ||
++ test "$enable_shared" = no; then
++ # Fast installation is not necessary
++ enable_fast_install=needless
+ fi
+-])# AC_PATH_MAGIC
++_LT_TAGDECL([], [hardcode_action], [0],
++ [How to hardcode a shared library path into an executable])
++])# _LT_LINKER_HARDCODE_LIBPATH
+
+
+-# AC_PROG_LD
+-# ----------
+-# find the pathname to the GNU or non-GNU linker
+-AC_DEFUN([AC_PROG_LD],
+-[AC_ARG_WITH([gnu-ld],
+- [AC_HELP_STRING([--with-gnu-ld],
+- [assume the C compiler uses GNU ld @<:@default=no@:>@])],
+- [test "$withval" = no || with_gnu_ld=yes],
+- [with_gnu_ld=no])
+-AC_REQUIRE([LT_AC_PROG_SED])dnl
+-AC_REQUIRE([AC_PROG_CC])dnl
+-AC_REQUIRE([AC_CANONICAL_HOST])dnl
+-AC_REQUIRE([AC_CANONICAL_BUILD])dnl
+-ac_prog=ld
+-if test "$GCC" = yes; then
+- # Check if gcc -print-prog-name=ld gives a path.
+- AC_MSG_CHECKING([for ld used by $CC])
+- case $host in
+- *-*-mingw*)
+- # gcc leaves a trailing carriage return which upsets mingw
+- ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
+- *)
+- ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
+- esac
+- case $ac_prog in
+- # Accept absolute paths.
+- [[\\/]]* | ?:[[\\/]]*)
+- re_direlt='/[[^/]][[^/]]*/\.\./'
+- # Canonicalize the pathname of ld
+- ac_prog=`echo $ac_prog| $SED 's%\\\\%/%g'`
+- while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
+- ac_prog=`echo $ac_prog| $SED "s%$re_direlt%/%"`
+- done
+- test -z "$LD" && LD="$ac_prog"
+- ;;
+- "")
+- # If it fails, then pretend we aren't using GCC.
+- ac_prog=ld
++# _LT_CMD_STRIPLIB
++# ----------------
++m4_defun([_LT_CMD_STRIPLIB],
++[m4_require([_LT_DECL_EGREP])
++striplib=
++old_striplib=
++AC_MSG_CHECKING([whether stripping libraries is possible])
++if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then
++ test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
++ test -z "$striplib" && striplib="$STRIP --strip-unneeded"
++ AC_MSG_RESULT([yes])
++else
++# FIXME - insert some real tests, host_os isn't really good enough
++ case $host_os in
++ darwin*)
++ if test -n "$STRIP" ; then
++ striplib="$STRIP -x"
++ old_striplib="$STRIP -S"
++ AC_MSG_RESULT([yes])
++ else
++ AC_MSG_RESULT([no])
++ fi
+ ;;
+ *)
+- # If it is relative, then search for the first ld in PATH.
+- with_gnu_ld=unknown
++ AC_MSG_RESULT([no])
+ ;;
+ esac
+-elif test "$with_gnu_ld" = yes; then
+- AC_MSG_CHECKING([for GNU ld])
+-else
+- AC_MSG_CHECKING([for non-GNU ld])
+ fi
+-AC_CACHE_VAL(lt_cv_path_LD,
+-[if test -z "$LD"; then
+- lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+- for ac_dir in $PATH; do
+- IFS="$lt_save_ifs"
+- test -z "$ac_dir" && ac_dir=.
+- if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+- lt_cv_path_LD="$ac_dir/$ac_prog"
+- # Check to see if the program is GNU ld. I'd rather use --version,
+- # but apparently some variants of GNU ld only accept -v.
+- # Break only if it was the GNU/non-GNU ld that we prefer.
+- case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
+- *GNU* | *'with BFD'*)
+- test "$with_gnu_ld" != no && break
+- ;;
+- *)
+- test "$with_gnu_ld" != yes && break
+- ;;
+- esac
++_LT_DECL([], [old_striplib], [1], [Commands to strip libraries])
++_LT_DECL([], [striplib], [1])
++])# _LT_CMD_STRIPLIB
++
++
++# _LT_SYS_DYNAMIC_LINKER([TAG])
++# -----------------------------
++# PORTME Fill in your ld.so characteristics
++m4_defun([_LT_SYS_DYNAMIC_LINKER],
++[AC_REQUIRE([AC_CANONICAL_HOST])dnl
++m4_require([_LT_DECL_EGREP])dnl
++m4_require([_LT_FILEUTILS_DEFAULTS])dnl
++m4_require([_LT_DECL_SED])dnl
++AC_MSG_CHECKING([dynamic linker characteristics])
++m4_if([$1],
++ [], [
++if test "$GCC" = yes; then
++ case $host_os in
++ darwin*) lt_awk_arg="/^libraries:/,/LR/" ;;
++ *) lt_awk_arg="/^libraries:/" ;;
++ esac
++ lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e "s,=/,/,g"`
++ if $ECHO "$lt_search_path_spec" | $GREP ';' >/dev/null ; then
++ # if the path contains ";" then we assume it to be the separator
++ # otherwise default to the standard path separator (i.e. ":") - it is
++ # assumed that no part of a normal pathname contains ";" but that should
++ # okay in the real world where ";" in dirpaths is itself problematic.
++ lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e 's/;/ /g'`
++ else
++ lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
++ fi
++ # Ok, now we have the path, separated by spaces, we can step through it
++ # and add multilib dir if necessary.
++ lt_tmp_lt_search_path_spec=
++ lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
++ for lt_sys_path in $lt_search_path_spec; do
++ if test -d "$lt_sys_path/$lt_multi_os_dir"; then
++ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir"
++ else
++ test -d "$lt_sys_path" && \
++ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path"
+ fi
+ done
+- IFS="$lt_save_ifs"
++ lt_search_path_spec=`$ECHO $lt_tmp_lt_search_path_spec | awk '
++BEGIN {RS=" "; FS="/|\n";} {
++ lt_foo="";
++ lt_count=0;
++ for (lt_i = NF; lt_i > 0; lt_i--) {
++ if ($lt_i != "" && $lt_i != ".") {
++ if ($lt_i == "..") {
++ lt_count++;
++ } else {
++ if (lt_count == 0) {
++ lt_foo="/" $lt_i lt_foo;
++ } else {
++ lt_count--;
++ }
++ }
++ }
++ }
++ if (lt_foo != "") { lt_freq[[lt_foo]]++; }
++ if (lt_freq[[lt_foo]] == 1) { print lt_foo; }
++}'`
++ sys_lib_search_path_spec=`$ECHO $lt_search_path_spec`
+ else
+- lt_cv_path_LD="$LD" # Let the user override the test with a path.
++ sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+ fi])
+-LD="$lt_cv_path_LD"
+-if test -n "$LD"; then
+- AC_MSG_RESULT($LD)
+-else
+- AC_MSG_RESULT(no)
+-fi
+-test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
+-AC_PROG_LD_GNU
+-])# AC_PROG_LD
++library_names_spec=
++libname_spec='lib$name'
++soname_spec=
++shrext_cmds=".so"
++postinstall_cmds=
++postuninstall_cmds=
++finish_cmds=
++finish_eval=
++shlibpath_var=
++shlibpath_overrides_runpath=unknown
++version_type=none
++dynamic_linker="$host_os ld.so"
++sys_lib_dlsearch_path_spec="/lib /usr/lib"
++need_lib_prefix=unknown
++hardcode_into_libs=no
++
++# when you set need_version to no, make sure it does not cause -set_version
++# flags to be left without arguments
++need_version=unknown
+
++case $host_os in
++aix3*)
++ version_type=linux
++ library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
++ shlibpath_var=LIBPATH
+
+-# AC_PROG_LD_GNU
+-# --------------
+-AC_DEFUN([AC_PROG_LD_GNU],
+-[AC_REQUIRE([AC_PROG_EGREP])dnl
+-AC_CACHE_CHECK([if the linker ($LD) is GNU ld], lt_cv_prog_gnu_ld,
+-[# I'd rather use --version here, but apparently some GNU lds only accept -v.
+-case `$LD -v 2>&1 </dev/null` in
+-*GNU* | *'with BFD'*)
+- lt_cv_prog_gnu_ld=yes
++ # AIX 3 has no versioning support, so we append a major version to the name.
++ soname_spec='${libname}${release}${shared_ext}$major'
+ ;;
+-*)
+- lt_cv_prog_gnu_ld=no
+- ;;
+-esac])
+-with_gnu_ld=$lt_cv_prog_gnu_ld
+-])# AC_PROG_LD_GNU
+-
+
+-# AC_PROG_LD_RELOAD_FLAG
+-# ----------------------
+-# find reload flag for linker
+-# -- PORTME Some linkers may need a different reload flag.
+-AC_DEFUN([AC_PROG_LD_RELOAD_FLAG],
+-[AC_CACHE_CHECK([for $LD option to reload object files],
+- lt_cv_ld_reload_flag,
+- [lt_cv_ld_reload_flag='-r'])
+-reload_flag=$lt_cv_ld_reload_flag
+-case $reload_flag in
+-"" | " "*) ;;
+-*) reload_flag=" $reload_flag" ;;
+-esac
+-reload_cmds='$LD$reload_flag -o $output$reload_objs'
+-case $host_os in
+- darwin*)
+- if test "$GCC" = yes; then
+- reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
++aix[[4-9]]*)
++ version_type=linux
++ need_lib_prefix=no
++ need_version=no
++ hardcode_into_libs=yes
++ if test "$host_cpu" = ia64; then
++ # AIX 5 supports IA64
++ library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
++ shlibpath_var=LD_LIBRARY_PATH
++ else
++ # With GCC up to 2.95.x, collect2 would create an import file
++ # for dependence libraries. The import file would start with
++ # the line `#! .'. This would cause the generated library to
++ # depend on `.', always an invalid library. This was fixed in
++ # development snapshots of GCC prior to 3.0.
++ case $host_os in
++ aix4 | aix4.[[01]] | aix4.[[01]].*)
++ if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
++ echo ' yes '
++ echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
++ :
++ else
++ can_build_shared=no
++ fi
++ ;;
++ esac
++ # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
++ # soname into executable. Probably we can add versioning support to
++ # collect2, so additional links can be useful in future.
++ if test "$aix_use_runtimelinking" = yes; then
++ # If using run time linking (on AIX 4.2 or later) use lib<name>.so
++ # instead of lib<name>.a to let people know that these are not
++ # typical AIX shared libraries.
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ else
+- reload_cmds='$LD$reload_flag -o $output$reload_objs'
++ # We preserve .a as extension for shared libraries through AIX4.2
++ # and later when we are not doing run time linking.
++ library_names_spec='${libname}${release}.a $libname.a'
++ soname_spec='${libname}${release}${shared_ext}$major'
+ fi
+- ;;
+-esac
+-])# AC_PROG_LD_RELOAD_FLAG
+-
+-
+-# AC_DEPLIBS_CHECK_METHOD
+-# -----------------------
+-# how to check for library dependencies
+-# -- PORTME fill in with the dynamic library characteristics
+-AC_DEFUN([AC_DEPLIBS_CHECK_METHOD],
+-[AC_CACHE_CHECK([how to recognise dependent libraries],
+-lt_cv_deplibs_check_method,
+-[lt_cv_file_magic_cmd='$MAGIC_CMD'
+-lt_cv_file_magic_test_file=
+-lt_cv_deplibs_check_method='unknown'
+-# Need to set the preceding variable on all platforms that support
+-# interlibrary dependencies.
+-# 'none' -- dependencies not supported.
+-# `unknown' -- same as none, but documents that we really don't know.
+-# 'pass_all' -- all dependencies passed with no checks.
+-# 'test_compile' -- check by making test program.
+-# 'file_magic [[regex]]' -- check by looking for files in library path
+-# which responds to the $file_magic_cmd with a given extended regex.
+-# If you have `file' or equivalent on your system and you're not sure
+-# whether `pass_all' will *always* work, you probably want this one.
++ shlibpath_var=LIBPATH
++ fi
++ ;;
+
+-case $host_os in
+-aix4* | aix5*)
+- lt_cv_deplibs_check_method=pass_all
++amigaos*)
++ case $host_cpu in
++ powerpc)
++ # Since July 2007 AmigaOS4 officially supports .so libraries.
++ # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
++ ;;
++ m68k)
++ library_names_spec='$libname.ixlibrary $libname.a'
++ # Create ${libname}_ixlibrary.a entries in /sys/libs.
++ finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$ECHO "X$lib" | $Xsed -e '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
++ ;;
++ esac
+ ;;
+
+ beos*)
+- lt_cv_deplibs_check_method=pass_all
++ library_names_spec='${libname}${shared_ext}'
++ dynamic_linker="$host_os ld.so"
++ shlibpath_var=LIBRARY_PATH
+ ;;
+
+ bsdi[[45]]*)
+- lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib)'
+- lt_cv_file_magic_cmd='/usr/bin/file -L'
+- lt_cv_file_magic_test_file=/shlib/libc.so
+- ;;
+-
+-cygwin*)
+- # func_win32_libid is a shell function defined in ltmain.sh
+- lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+- lt_cv_file_magic_cmd='func_win32_libid'
++ version_type=linux
++ need_version=no
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
++ soname_spec='${libname}${release}${shared_ext}$major'
++ finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
++ shlibpath_var=LD_LIBRARY_PATH
++ sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
++ sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
++ # the default ld.so.conf also contains /usr/contrib/lib and
++ # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
++ # libtool to hard-code these into programs
+ ;;
+
+-mingw* | pw32*)
+- # Base MSYS/MinGW do not provide the 'file' command needed by
+- # func_win32_libid shell function, so use a weaker test based on 'objdump'.
+- lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?'
+- lt_cv_file_magic_cmd='$OBJDUMP -f'
+- ;;
++cygwin* | mingw* | pw32*)
++ version_type=windows
++ shrext_cmds=".dll"
++ need_version=no
++ need_lib_prefix=no
+
+-darwin* | rhapsody*)
+- lt_cv_deplibs_check_method=pass_all
+- ;;
++ case $GCC,$host_os in
++ yes,cygwin* | yes,mingw* | yes,pw32*)
++ library_names_spec='$libname.dll.a'
++ # DLL is installed to $(libdir)/../bin by postinstall_cmds
++ postinstall_cmds='base_file=`basename \${file}`~
++ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
++ dldir=$destdir/`dirname \$dlpath`~
++ test -d \$dldir || mkdir -p \$dldir~
++ $install_prog $dir/$dlname \$dldir/$dlname~
++ chmod a+x \$dldir/$dlname~
++ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
++ eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
++ fi'
++ postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
++ dlpath=$dir/\$dldll~
++ $RM \$dlpath'
++ shlibpath_overrides_runpath=yes
+
+-freebsd* | kfreebsd*-gnu | dragonfly*)
+- if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+- case $host_cpu in
+- i*86 )
+- # Not sure whether the presence of OpenBSD here was a mistake.
+- # Let's accept both of them until this is cleared up.
+- lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library'
+- lt_cv_file_magic_cmd=/usr/bin/file
+- lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
++ case $host_os in
++ cygwin*)
++ # Cygwin DLLs use 'cyg' prefix rather than 'lib'
++ soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
++ sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
++ ;;
++ mingw*)
++ # MinGW DLLs use traditional 'lib' prefix
++ soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
++ sys_lib_search_path_spec=`$CC -print-search-dirs | $GREP "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
++ if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then
++ # It is most probably a Windows format PATH printed by
++ # mingw gcc, but we are running on Cygwin. Gcc prints its search
++ # path with ; separators, and with drive letters. We can handle the
++ # drive letters (cygwin fileutils understands them), so leave them,
++ # especially as we might pass files found there to a mingw objdump,
++ # which wouldn't understand a cygwinified path. Ahh.
++ sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
++ else
++ sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
++ fi
++ ;;
++ pw32*)
++ # pw32 DLLs use 'pw' prefix rather than 'lib'
++ library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+ ;;
+ esac
+- else
+- lt_cv_deplibs_check_method=pass_all
+- fi
+- ;;
+-
+-gnu*)
+- lt_cv_deplibs_check_method=pass_all
+- ;;
+-
+-hpux10.20* | hpux11*)
+- lt_cv_file_magic_cmd=/usr/bin/file
+- case $host_cpu in
+- ia64*)
+- lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64'
+- lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
+- ;;
+- hppa*64*)
+- [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]']
+- lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
+ ;;
++
+ *)
+- lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]].[[0-9]]) shared library'
+- lt_cv_file_magic_test_file=/usr/lib/libc.sl
++ library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib'
+ ;;
+ esac
++ dynamic_linker='Win32 ld.exe'
++ # FIXME: first we should search . and the directory the executable is in
++ shlibpath_var=PATH
+ ;;
+
+-interix3*)
+- # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
+- lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$'
+- ;;
+-
+-irix5* | irix6* | nonstopux*)
+- case $LD in
+- *-32|*"-32 ") libmagic=32-bit;;
+- *-n32|*"-n32 ") libmagic=N32;;
+- *-64|*"-64 ") libmagic=64-bit;;
+- *) libmagic=never-match;;
+- esac
+- lt_cv_deplibs_check_method=pass_all
+- ;;
+-
+-# This must be Linux ELF.
+-linux*)
+- lt_cv_deplibs_check_method=pass_all
+- ;;
+-
+-netbsd*)
+- if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+- lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
+- else
+- lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$'
+- fi
++darwin* | rhapsody*)
++ dynamic_linker="$host_os dyld"
++ version_type=darwin
++ need_lib_prefix=no
++ need_version=no
++ library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
++ soname_spec='${libname}${release}${major}$shared_ext'
++ shlibpath_overrides_runpath=yes
++ shlibpath_var=DYLD_LIBRARY_PATH
++ shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
++m4_if([$1], [],[
++ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"])
++ sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
+ ;;
+
+-newos6*)
+- lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)'
+- lt_cv_file_magic_cmd=/usr/bin/file
+- lt_cv_file_magic_test_file=/usr/lib/libnls.so
++dgux*)
++ version_type=linux
++ need_lib_prefix=no
++ need_version=no
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
++ soname_spec='${libname}${release}${shared_ext}$major'
++ shlibpath_var=LD_LIBRARY_PATH
+ ;;
+
+-nto-qnx*)
+- lt_cv_deplibs_check_method=unknown
++freebsd1*)
++ dynamic_linker=no
+ ;;
+
+-openbsd*)
+- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+- lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$'
++freebsd* | dragonfly*)
++ # DragonFly does not have aout. When/if they implement a new
++ # versioning mechanism, adjust this.
++ if test -x /usr/bin/objformat; then
++ objformat=`/usr/bin/objformat`
+ else
+- lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
++ case $host_os in
++ freebsd[[123]]*) objformat=aout ;;
++ *) objformat=elf ;;
++ esac
+ fi
+- ;;
+-
+-osf3* | osf4* | osf5*)
+- lt_cv_deplibs_check_method=pass_all
+- ;;
+-
+-solaris*)
+- lt_cv_deplibs_check_method=pass_all
+- ;;
+-
+-sysv4 | sysv4.3*)
+- case $host_vendor in
+- motorola)
+- lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]'
+- lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
+- ;;
+- ncr)
+- lt_cv_deplibs_check_method=pass_all
+- ;;
+- sequent)
+- lt_cv_file_magic_cmd='/bin/file'
+- lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )'
++ version_type=freebsd-$objformat
++ case $version_type in
++ freebsd-elf*)
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
++ need_version=no
++ need_lib_prefix=no
++ ;;
++ freebsd-*)
++ library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
++ need_version=yes
++ ;;
++ esac
++ shlibpath_var=LD_LIBRARY_PATH
++ case $host_os in
++ freebsd2*)
++ shlibpath_overrides_runpath=yes
+ ;;
+- sni)
+- lt_cv_file_magic_cmd='/bin/file'
+- lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib"
+- lt_cv_file_magic_test_file=/lib/libc.so
++ freebsd3.[[01]]* | freebsdelf3.[[01]]*)
++ shlibpath_overrides_runpath=yes
++ hardcode_into_libs=yes
+ ;;
+- siemens)
+- lt_cv_deplibs_check_method=pass_all
++ freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \
++ freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1)
++ shlibpath_overrides_runpath=no
++ hardcode_into_libs=yes
+ ;;
+- pc)
+- lt_cv_deplibs_check_method=pass_all
++ *) # from 4.6 on, and DragonFly
++ shlibpath_overrides_runpath=yes
++ hardcode_into_libs=yes
+ ;;
+ esac
+ ;;
+
+-sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+- lt_cv_deplibs_check_method=pass_all
++gnu*)
++ version_type=linux
++ need_lib_prefix=no
++ need_version=no
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
++ soname_spec='${libname}${release}${shared_ext}$major'
++ shlibpath_var=LD_LIBRARY_PATH
++ hardcode_into_libs=yes
+ ;;
+-esac
+-])
+-file_magic_cmd=$lt_cv_file_magic_cmd
+-deplibs_check_method=$lt_cv_deplibs_check_method
+-test -z "$deplibs_check_method" && deplibs_check_method=unknown
+-])# AC_DEPLIBS_CHECK_METHOD
+
+-
+-# AC_PROG_NM
+-# ----------
+-# find the pathname to a BSD-compatible name lister
+-AC_DEFUN([AC_PROG_NM],
+-[AC_CACHE_CHECK([for BSD-compatible nm], lt_cv_path_NM,
+-[if test -n "$NM"; then
+- # Let the user override the test.
+- lt_cv_path_NM="$NM"
+-else
+- lt_nm_to_check="${ac_tool_prefix}nm"
+- if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
+- lt_nm_to_check="$lt_nm_to_check nm"
+- fi
+- for lt_tmp_nm in $lt_nm_to_check; do
+- lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+- for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
+- IFS="$lt_save_ifs"
+- test -z "$ac_dir" && ac_dir=.
+- tmp_nm="$ac_dir/$lt_tmp_nm"
+- if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
+- # Check to see if the nm accepts a BSD-compat flag.
+- # Adding the `sed 1q' prevents false positives on HP-UX, which says:
+- # nm: unknown option "B" ignored
+- # Tru64's nm complains that /dev/null is an invalid object file
+- case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
+- */dev/null* | *'Invalid file or object type'*)
+- lt_cv_path_NM="$tmp_nm -B"
+- break
+- ;;
+- *)
+- case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
+- */dev/null*)
+- lt_cv_path_NM="$tmp_nm -p"
+- break
+- ;;
+- *)
+- lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
+- continue # so that we can try to find one that supports BSD flags
+- ;;
+- esac
+- ;;
+- esac
+- fi
+- done
+- IFS="$lt_save_ifs"
+- done
+- test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm
+-fi])
+-NM="$lt_cv_path_NM"
+-])# AC_PROG_NM
+-
+-
+-# AC_CHECK_LIBM
+-# -------------
+-# check for math library
+-AC_DEFUN([AC_CHECK_LIBM],
+-[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+-LIBM=
+-case $host in
+-*-*-beos* | *-*-cygwin* | *-*-pw32* | *-*-darwin*)
+- # These system don't have libm, or don't need it
+- ;;
+-*-ncr-sysv4.3*)
+- AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
+- AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm")
+- ;;
+-*)
+- AC_CHECK_LIB(m, cos, LIBM="-lm")
++hpux9* | hpux10* | hpux11*)
++ # Give a soname corresponding to the major version so that dld.sl refuses to
++ # link against other versions.
++ version_type=sunos
++ need_lib_prefix=no
++ need_version=no
++ case $host_cpu in
++ ia64*)
++ shrext_cmds='.so'
++ hardcode_into_libs=yes
++ dynamic_linker="$host_os dld.so"
++ shlibpath_var=LD_LIBRARY_PATH
++ shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
++ soname_spec='${libname}${release}${shared_ext}$major'
++ if test "X$HPUX_IA64_MODE" = X32; then
++ sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
++ else
++ sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
++ fi
++ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
++ ;;
++ hppa*64*)
++ shrext_cmds='.sl'
++ hardcode_into_libs=yes
++ dynamic_linker="$host_os dld.sl"
++ shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
++ shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
++ soname_spec='${libname}${release}${shared_ext}$major'
++ sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
++ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
++ ;;
++ *)
++ shrext_cmds='.sl'
++ dynamic_linker="$host_os dld.sl"
++ shlibpath_var=SHLIB_PATH
++ shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
++ soname_spec='${libname}${release}${shared_ext}$major'
++ ;;
++ esac
++ # HP-UX runs *really* slowly unless shared libraries are mode 555.
++ postinstall_cmds='chmod 555 $lib'
+ ;;
+-esac
+-])# AC_CHECK_LIBM
+
++interix[[3-9]]*)
++ version_type=linux
++ need_lib_prefix=no
++ need_version=no
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
++ soname_spec='${libname}${release}${shared_ext}$major'
++ dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
++ shlibpath_var=LD_LIBRARY_PATH
++ shlibpath_overrides_runpath=no
++ hardcode_into_libs=yes
++ ;;
+
+-# AC_LIBLTDL_CONVENIENCE([DIRECTORY])
+-# -----------------------------------
+-# sets LIBLTDL to the link flags for the libltdl convenience library and
+-# LTDLINCL to the include flags for the libltdl header and adds
+-# --enable-ltdl-convenience to the configure arguments. Note that
+-# AC_CONFIG_SUBDIRS is not called here. If DIRECTORY is not provided,
+-# it is assumed to be `libltdl'. LIBLTDL will be prefixed with
+-# '${top_builddir}/' and LTDLINCL will be prefixed with '${top_srcdir}/'
+-# (note the single quotes!). If your package is not flat and you're not
+-# using automake, define top_builddir and top_srcdir appropriately in
+-# the Makefiles.
+-AC_DEFUN([AC_LIBLTDL_CONVENIENCE],
+-[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+- case $enable_ltdl_convenience in
+- no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;;
+- "") enable_ltdl_convenience=yes
+- ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;;
++irix5* | irix6* | nonstopux*)
++ case $host_os in
++ nonstopux*) version_type=nonstopux ;;
++ *)
++ if test "$lt_cv_prog_gnu_ld" = yes; then
++ version_type=linux
++ else
++ version_type=irix
++ fi ;;
+ esac
+- LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdlc.la
+- LTDLINCL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl'])
+- # For backwards non-gettext consistent compatibility...
+- INCLTDL="$LTDLINCL"
+-])# AC_LIBLTDL_CONVENIENCE
+-
+-
+-# AC_LIBLTDL_INSTALLABLE([DIRECTORY])
+-# -----------------------------------
+-# sets LIBLTDL to the link flags for the libltdl installable library and
+-# LTDLINCL to the include flags for the libltdl header and adds
+-# --enable-ltdl-install to the configure arguments. Note that
+-# AC_CONFIG_SUBDIRS is not called here. If DIRECTORY is not provided,
+-# and an installed libltdl is not found, it is assumed to be `libltdl'.
+-# LIBLTDL will be prefixed with '${top_builddir}/'# and LTDLINCL with
+-# '${top_srcdir}/' (note the single quotes!). If your package is not
+-# flat and you're not using automake, define top_builddir and top_srcdir
+-# appropriately in the Makefiles.
+-# In the future, this macro may have to be called after AC_PROG_LIBTOOL.
+-AC_DEFUN([AC_LIBLTDL_INSTALLABLE],
+-[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+- AC_CHECK_LIB(ltdl, lt_dlinit,
+- [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no],
+- [if test x"$enable_ltdl_install" = xno; then
+- AC_MSG_WARN([libltdl not installed, but installation disabled])
+- else
+- enable_ltdl_install=yes
+- fi
+- ])
+- if test x"$enable_ltdl_install" = x"yes"; then
+- ac_configure_args="$ac_configure_args --enable-ltdl-install"
+- LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdl.la
+- LTDLINCL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl'])
+- else
+- ac_configure_args="$ac_configure_args --enable-ltdl-install=no"
+- LIBLTDL="-lltdl"
+- LTDLINCL=
+- fi
+- # For backwards non-gettext consistent compatibility...
+- INCLTDL="$LTDLINCL"
+-])# AC_LIBLTDL_INSTALLABLE
++ need_lib_prefix=no
++ need_version=no
++ soname_spec='${libname}${release}${shared_ext}$major'
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
++ case $host_os in
++ irix5* | nonstopux*)
++ libsuff= shlibsuff=
++ ;;
++ *)
++ case $LD in # libtool.m4 will add one of these switches to LD
++ *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
++ libsuff= shlibsuff= libmagic=32-bit;;
++ *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
++ libsuff=32 shlibsuff=N32 libmagic=N32;;
++ *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
++ libsuff=64 shlibsuff=64 libmagic=64-bit;;
++ *) libsuff= shlibsuff= libmagic=never-match;;
++ esac
++ ;;
++ esac
++ shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
++ shlibpath_overrides_runpath=no
++ sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
++ sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
++ hardcode_into_libs=yes
++ ;;
+
++# No shared lib support for Linux oldld, aout, or coff.
++linux*oldld* | linux*aout* | linux*coff*)
++ dynamic_linker=no
++ ;;
+
+-# AC_LIBTOOL_CXX
+-# --------------
+-# enable support for C++ libraries
+-AC_DEFUN([AC_LIBTOOL_CXX],
+-[AC_REQUIRE([_LT_AC_LANG_CXX])
+-])# AC_LIBTOOL_CXX
++# This must be Linux ELF.
++linux* | k*bsd*-gnu)
++ version_type=linux
++ need_lib_prefix=no
++ need_version=no
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
++ soname_spec='${libname}${release}${shared_ext}$major'
++ finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
++ shlibpath_var=LD_LIBRARY_PATH
++ shlibpath_overrides_runpath=no
++ # Some binutils ld are patched to set DT_RUNPATH
++ save_LDFLAGS=$LDFLAGS
++ save_libdir=$libdir
++ eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \
++ LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\""
++ AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
++ [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null],
++ [shlibpath_overrides_runpath=yes])])
++ LDFLAGS=$save_LDFLAGS
++ libdir=$save_libdir
+
++ # This implies no fast_install, which is unacceptable.
++ # Some rework will be needed to allow for fast_install
++ # before this can be enabled.
++ hardcode_into_libs=yes
+
+-# _LT_AC_LANG_CXX
+-# ---------------
+-AC_DEFUN([_LT_AC_LANG_CXX],
+-[AC_REQUIRE([AC_PROG_CXX])
+-AC_REQUIRE([_LT_AC_PROG_CXXCPP])
+-_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}CXX])
+-])# _LT_AC_LANG_CXX
++ # Append ld.so.conf contents to the search path
++ if test -f /etc/ld.so.conf; then
++ lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
++ sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
++ fi
+
+-# _LT_AC_PROG_CXXCPP
+-# ------------------
+-AC_DEFUN([_LT_AC_PROG_CXXCPP],
+-[
+-AC_REQUIRE([AC_PROG_CXX])
+-if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
+- ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
+- (test "X$CXX" != "Xg++"))) ; then
+- AC_PROG_CXXCPP
+-fi
+-])# _LT_AC_PROG_CXXCPP
+-
+-# AC_LIBTOOL_F77
+-# --------------
+-# enable support for Fortran 77 libraries
+-AC_DEFUN([AC_LIBTOOL_F77],
+-[AC_REQUIRE([_LT_AC_LANG_F77])
+-])# AC_LIBTOOL_F77
+-
+-
+-# _LT_AC_LANG_F77
+-# ---------------
+-AC_DEFUN([_LT_AC_LANG_F77],
+-[AC_REQUIRE([AC_PROG_F77])
+-_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}F77])
+-])# _LT_AC_LANG_F77
+-
+-
+-# AC_LIBTOOL_GCJ
+-# --------------
+-# enable support for GCJ libraries
+-AC_DEFUN([AC_LIBTOOL_GCJ],
+-[AC_REQUIRE([_LT_AC_LANG_GCJ])
+-])# AC_LIBTOOL_GCJ
+-
+-
+-# _LT_AC_LANG_GCJ
+-# ---------------
+-AC_DEFUN([_LT_AC_LANG_GCJ],
+-[AC_PROVIDE_IFELSE([AC_PROG_GCJ],[],
+- [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],[],
+- [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ],[],
+- [ifdef([AC_PROG_GCJ],[AC_REQUIRE([AC_PROG_GCJ])],
+- [ifdef([A][M_PROG_GCJ],[AC_REQUIRE([A][M_PROG_GCJ])],
+- [AC_REQUIRE([A][C_PROG_GCJ_OR_A][M_PROG_GCJ])])])])])])
+-_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}GCJ])
+-])# _LT_AC_LANG_GCJ
+-
+-
+-# AC_LIBTOOL_RC
+-# -------------
+-# enable support for Windows resource files
+-AC_DEFUN([AC_LIBTOOL_RC],
+-[AC_REQUIRE([LT_AC_PROG_RC])
+-_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}RC])
+-])# AC_LIBTOOL_RC
++ # We used to test for /lib/ld.so.1 and disable shared libraries on
++ # powerpc, because MkLinux only supported shared libraries with the
++ # GNU dynamic linker. Since this was broken with cross compilers,
++ # most powerpc-linux boxes support dynamic linking these days and
++ # people can always --disable-shared, the test was removed, and we
++ # assume the GNU/Linux dynamic linker is in use.
++ dynamic_linker='GNU/Linux ld.so'
++ ;;
+
++netbsd*)
++ version_type=sunos
++ need_lib_prefix=no
++ need_version=no
++ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
++ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
++ dynamic_linker='NetBSD (a.out) ld.so'
++ else
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
++ soname_spec='${libname}${release}${shared_ext}$major'
++ dynamic_linker='NetBSD ld.elf_so'
++ fi
++ shlibpath_var=LD_LIBRARY_PATH
++ shlibpath_overrides_runpath=yes
++ hardcode_into_libs=yes
++ ;;
+
+-# AC_LIBTOOL_LANG_C_CONFIG
+-# ------------------------
+-# Ensure that the configuration vars for the C compiler are
+-# suitably defined. Those variables are subsequently used by
+-# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
+-AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG], [_LT_AC_LANG_C_CONFIG])
+-AC_DEFUN([_LT_AC_LANG_C_CONFIG],
+-[lt_save_CC="$CC"
+-AC_LANG_PUSH(C)
++newsos6)
++ version_type=linux
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
++ shlibpath_var=LD_LIBRARY_PATH
++ shlibpath_overrides_runpath=yes
++ ;;
+
+-# Source file extension for C test sources.
+-ac_ext=c
++*nto* | *qnx*)
++ version_type=qnx
++ need_lib_prefix=no
++ need_version=no
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
++ soname_spec='${libname}${release}${shared_ext}$major'
++ shlibpath_var=LD_LIBRARY_PATH
++ shlibpath_overrides_runpath=no
++ hardcode_into_libs=yes
++ dynamic_linker='ldqnx.so'
++ ;;
+
+-# Object file extension for compiled C test sources.
+-objext=o
+-_LT_AC_TAGVAR(objext, $1)=$objext
++openbsd*)
++ version_type=sunos
++ sys_lib_dlsearch_path_spec="/usr/lib"
++ need_lib_prefix=no
++ # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
++ case $host_os in
++ openbsd3.3 | openbsd3.3.*) need_version=yes ;;
++ *) need_version=no ;;
++ esac
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
++ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
++ shlibpath_var=LD_LIBRARY_PATH
++ if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
++ case $host_os in
++ openbsd2.[[89]] | openbsd2.[[89]].*)
++ shlibpath_overrides_runpath=no
++ ;;
++ *)
++ shlibpath_overrides_runpath=yes
++ ;;
++ esac
++ else
++ shlibpath_overrides_runpath=yes
++ fi
++ ;;
+
+-# Code to be used in simple compile tests
+-lt_simple_compile_test_code="int some_variable = 0;\n"
++os2*)
++ libname_spec='$name'
++ shrext_cmds=".dll"
++ need_lib_prefix=no
++ library_names_spec='$libname${shared_ext} $libname.a'
++ dynamic_linker='OS/2 ld.exe'
++ shlibpath_var=LIBPATH
++ ;;
+
+-# Code to be used in simple link tests
+-lt_simple_link_test_code='int main(){return(0);}\n'
++osf3* | osf4* | osf5*)
++ version_type=osf
++ need_lib_prefix=no
++ need_version=no
++ soname_spec='${libname}${release}${shared_ext}$major'
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
++ shlibpath_var=LD_LIBRARY_PATH
++ sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
++ sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
++ ;;
+
+-_LT_AC_SYS_COMPILER
++rdos*)
++ dynamic_linker=no
++ ;;
+
+-# save warnings/boilerplate of simple test code
+-_LT_COMPILER_BOILERPLATE
+-_LT_LINKER_BOILERPLATE
++solaris*)
++ version_type=linux
++ need_lib_prefix=no
++ need_version=no
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
++ soname_spec='${libname}${release}${shared_ext}$major'
++ shlibpath_var=LD_LIBRARY_PATH
++ shlibpath_overrides_runpath=yes
++ hardcode_into_libs=yes
++ # ldd complains unless libraries are executable
++ postinstall_cmds='chmod +x $lib'
++ ;;
+
+-## CAVEAT EMPTOR:
+-## There is no encapsulation within the following macros, do not change
+-## the running order or otherwise move them around unless you know exactly
+-## what you are doing...
+-AC_LIBTOOL_PROG_COMPILER_NO_RTTI($1)
+-AC_LIBTOOL_PROG_COMPILER_PIC($1)
+-AC_LIBTOOL_PROG_CC_C_O($1)
+-AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
+-AC_LIBTOOL_PROG_LD_SHLIBS($1)
+-AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
+-AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
+-AC_LIBTOOL_SYS_LIB_STRIP
+-AC_LIBTOOL_DLOPEN_SELF
+-
+-# Report which library types will actually be built
+-AC_MSG_CHECKING([if libtool supports shared libraries])
+-AC_MSG_RESULT([$can_build_shared])
++sunos4*)
++ version_type=sunos
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
++ finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
++ shlibpath_var=LD_LIBRARY_PATH
++ shlibpath_overrides_runpath=yes
++ if test "$with_gnu_ld" = yes; then
++ need_lib_prefix=no
++ fi
++ need_version=yes
++ ;;
+
+-AC_MSG_CHECKING([whether to build shared libraries])
+-test "$can_build_shared" = "no" && enable_shared=no
++sysv4 | sysv4.3*)
++ version_type=linux
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
++ soname_spec='${libname}${release}${shared_ext}$major'
++ shlibpath_var=LD_LIBRARY_PATH
++ case $host_vendor in
++ sni)
++ shlibpath_overrides_runpath=no
++ need_lib_prefix=no
++ runpath_var=LD_RUN_PATH
++ ;;
++ siemens)
++ need_lib_prefix=no
++ ;;
++ motorola)
++ need_lib_prefix=no
++ need_version=no
++ shlibpath_overrides_runpath=no
++ sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
++ ;;
++ esac
++ ;;
+
+-# On AIX, shared libraries and static libraries use the same namespace, and
+-# are all built from PIC.
+-case $host_os in
+-aix3*)
+- test "$enable_shared" = yes && enable_static=no
+- if test -n "$RANLIB"; then
+- archive_cmds="$archive_cmds~\$RANLIB \$lib"
+- postinstall_cmds='$RANLIB $lib'
++sysv4*MP*)
++ if test -d /usr/nec ;then
++ version_type=linux
++ library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
++ soname_spec='$libname${shared_ext}.$major'
++ shlibpath_var=LD_LIBRARY_PATH
+ fi
+ ;;
+
+-aix4* | aix5*)
+- if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+- test "$enable_shared" = yes && enable_static=no
++sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
++ version_type=freebsd-elf
++ need_lib_prefix=no
++ need_version=no
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
++ soname_spec='${libname}${release}${shared_ext}$major'
++ shlibpath_var=LD_LIBRARY_PATH
++ shlibpath_overrides_runpath=yes
++ hardcode_into_libs=yes
++ if test "$with_gnu_ld" = yes; then
++ sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
++ else
++ sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
++ case $host_os in
++ sco3.2v5*)
++ sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
++ ;;
++ esac
+ fi
+- ;;
+-esac
+-AC_MSG_RESULT([$enable_shared])
+-
+-AC_MSG_CHECKING([whether to build static libraries])
+-# Make sure either enable_shared or enable_static is yes.
+-test "$enable_shared" = yes || enable_static=yes
+-AC_MSG_RESULT([$enable_static])
+-
+-AC_LIBTOOL_CONFIG($1)
+-
+-AC_LANG_POP
+-CC="$lt_save_CC"
+-])# AC_LIBTOOL_LANG_C_CONFIG
+-
+-
+-# AC_LIBTOOL_LANG_CXX_CONFIG
+-# --------------------------
+-# Ensure that the configuration vars for the C compiler are
+-# suitably defined. Those variables are subsequently used by
+-# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
+-AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG], [_LT_AC_LANG_CXX_CONFIG(CXX)])
+-AC_DEFUN([_LT_AC_LANG_CXX_CONFIG],
+-[AC_LANG_PUSH(C++)
+-AC_REQUIRE([AC_PROG_CXX])
+-AC_REQUIRE([_LT_AC_PROG_CXXCPP])
+-
+-_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+-_LT_AC_TAGVAR(allow_undefined_flag, $1)=
+-_LT_AC_TAGVAR(always_export_symbols, $1)=no
+-_LT_AC_TAGVAR(archive_expsym_cmds, $1)=
+-_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=
+-_LT_AC_TAGVAR(hardcode_direct, $1)=no
+-_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
+-_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
+-_LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
+-_LT_AC_TAGVAR(hardcode_minus_L, $1)=no
+-_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+-_LT_AC_TAGVAR(hardcode_automatic, $1)=no
+-_LT_AC_TAGVAR(module_cmds, $1)=
+-_LT_AC_TAGVAR(module_expsym_cmds, $1)=
+-_LT_AC_TAGVAR(link_all_deplibs, $1)=unknown
+-_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+-_LT_AC_TAGVAR(no_undefined_flag, $1)=
+-_LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+-_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+-
+-# Dependencies to place before and after the object being linked:
+-_LT_AC_TAGVAR(predep_objects, $1)=
+-_LT_AC_TAGVAR(postdep_objects, $1)=
+-_LT_AC_TAGVAR(predeps, $1)=
+-_LT_AC_TAGVAR(postdeps, $1)=
+-_LT_AC_TAGVAR(compiler_lib_search_path, $1)=
+-
+-# Source file extension for C++ test sources.
+-ac_ext=cpp
+-
+-# Object file extension for compiled C++ test sources.
+-objext=o
+-_LT_AC_TAGVAR(objext, $1)=$objext
+-
+-# Code to be used in simple compile tests
+-lt_simple_compile_test_code="int some_variable = 0;\n"
++ sys_lib_dlsearch_path_spec='/usr/lib'
++ ;;
+
+-# Code to be used in simple link tests
+-lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }\n'
++tpf*)
++ # TPF is a cross-target only. Preferred cross-host = GNU/Linux.
++ version_type=linux
++ need_lib_prefix=no
++ need_version=no
++ library_name_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
++ shlibpath_var=LD_LIBRARY_PATH
++ shlibpath_overrides_runpath=no
++ hardcode_into_libs=yes
++ ;;
+
+-# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+-_LT_AC_SYS_COMPILER
++uts4*)
++ version_type=linux
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
++ soname_spec='${libname}${release}${shared_ext}$major'
++ shlibpath_var=LD_LIBRARY_PATH
++ ;;
+
+-# save warnings/boilerplate of simple test code
+-_LT_COMPILER_BOILERPLATE
+-_LT_LINKER_BOILERPLATE
++*)
++ dynamic_linker=no
++ ;;
++esac
++AC_MSG_RESULT([$dynamic_linker])
++test "$dynamic_linker" = no && can_build_shared=no
+
+-# Allow CC to be a program name with arguments.
+-lt_save_CC=$CC
+-lt_save_LD=$LD
+-lt_save_GCC=$GCC
+-GCC=$GXX
+-lt_save_with_gnu_ld=$with_gnu_ld
+-lt_save_path_LD=$lt_cv_path_LD
+-if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then
+- lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx
+-else
+- $as_unset lt_cv_prog_gnu_ld
++variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
++if test "$GCC" = yes; then
++ variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
+ fi
+-if test -n "${lt_cv_path_LDCXX+set}"; then
+- lt_cv_path_LD=$lt_cv_path_LDCXX
+-else
+- $as_unset lt_cv_path_LD
++
++if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
++ sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+ fi
+-test -z "${LDCXX+set}" || LD=$LDCXX
+-CC=${CXX-"c++"}
+-compiler=$CC
+-_LT_AC_TAGVAR(compiler, $1)=$CC
+-_LT_CC_BASENAME([$compiler])
+-
+-# We don't want -fno-exception wen compiling C++ code, so set the
+-# no_builtin_flag separately
+-if test "$GXX" = yes; then
+- _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
+-else
+- _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
++if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
++ sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+ fi
+
+-if test "$GXX" = yes; then
+- # Set up default GNU C++ configuration
+-
+- AC_PROG_LD
+-
+- # Check if GNU C++ uses GNU ld as the underlying linker, since the
+- # archiving commands below assume that GNU ld is being used.
+- if test "$with_gnu_ld" = yes; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+-
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+-
+- # If archive_cmds runs LD, not CC, wlarc should be empty
+- # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
+- # investigate it a little bit more. (MM)
+- wlarc='${wl}'
+-
+- # ancient GNU ld didn't support --whole-archive et. al.
+- if eval "`$CC -print-prog-name=ld` --help 2>&1" | \
+- grep 'no-whole-archive' > /dev/null; then
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+- else
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+- fi
+- else
+- with_gnu_ld=no
+- wlarc=
+-
+- # A generic and very simple default shared library creation
+- # command for GNU C++ for the case where it uses the native
+- # linker, instead of GNU ld. If possible, this setting should
+- # overridden to take advantage of the native linker features on
+- # the platform it is being used on.
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+- fi
+-
+- # Commands to make compiler produce verbose output that lists
+- # what "hidden" libraries, object files and flags are used when
+- # linking a shared library.
+- output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"'
+-
+-else
+- GXX=no
+- with_gnu_ld=no
+- wlarc=
+-fi
++_LT_DECL([], [variables_saved_for_relink], [1],
++ [Variables whose values should be saved in libtool wrapper scripts and
++ restored at link time])
++_LT_DECL([], [need_lib_prefix], [0],
++ [Do we need the "lib" prefix for modules?])
++_LT_DECL([], [need_version], [0], [Do we need a version for libraries?])
++_LT_DECL([], [version_type], [0], [Library versioning type])
++_LT_DECL([], [runpath_var], [0], [Shared library runtime path variable])
++_LT_DECL([], [shlibpath_var], [0],[Shared library path variable])
++_LT_DECL([], [shlibpath_overrides_runpath], [0],
++ [Is shlibpath searched before the hard-coded library search path?])
++_LT_DECL([], [libname_spec], [1], [Format of library name prefix])
++_LT_DECL([], [library_names_spec], [1],
++ [[List of archive names. First name is the real one, the rest are links.
++ The last name is the one that the linker finds with -lNAME]])
++_LT_DECL([], [soname_spec], [1],
++ [[The coded name of the library, if different from the real name]])
++_LT_DECL([], [postinstall_cmds], [2],
++ [Command to use after installation of a shared archive])
++_LT_DECL([], [postuninstall_cmds], [2],
++ [Command to use after uninstallation of a shared archive])
++_LT_DECL([], [finish_cmds], [2],
++ [Commands used to finish a libtool library installation in a directory])
++_LT_DECL([], [finish_eval], [1],
++ [[As "finish_cmds", except a single script fragment to be evaled but
++ not shown]])
++_LT_DECL([], [hardcode_into_libs], [0],
++ [Whether we should hardcode library paths into libraries])
++_LT_DECL([], [sys_lib_search_path_spec], [2],
++ [Compile-time system search path for libraries])
++_LT_DECL([], [sys_lib_dlsearch_path_spec], [2],
++ [Run-time system search path for libraries])
++])# _LT_SYS_DYNAMIC_LINKER
+
+-# PORTME: fill in a description of your system's C++ link characteristics
+-AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
+-_LT_AC_TAGVAR(ld_shlibs, $1)=yes
+-case $host_os in
+- aix3*)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- aix4* | aix5*)
+- if test "$host_cpu" = ia64; then
+- # On IA64, the linker does run time linking by default, so we don't
+- # have to do anything special.
+- aix_use_runtimelinking=no
+- exp_sym_flag='-Bexport'
+- no_entry_flag=""
+- else
+- aix_use_runtimelinking=no
+
+- # Test if we are trying to use run time linking or normal
+- # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+- # need to do runtime linking.
+- case $host_os in aix4.[[23]]|aix4.[[23]].*|aix5*)
+- for ld_flag in $LDFLAGS; do
+- case $ld_flag in
+- *-brtl*)
+- aix_use_runtimelinking=yes
+- break
+- ;;
+- esac
+- done
+- ;;
+- esac
+-
+- exp_sym_flag='-bexport'
+- no_entry_flag='-bnoentry'
+- fi
++# _LT_PATH_TOOL_PREFIX(TOOL)
++# --------------------------
++# find a file program which can recognize shared library
++AC_DEFUN([_LT_PATH_TOOL_PREFIX],
++[m4_require([_LT_DECL_EGREP])dnl
++AC_MSG_CHECKING([for $1])
++AC_CACHE_VAL(lt_cv_path_MAGIC_CMD,
++[case $MAGIC_CMD in
++[[\\/*] | ?:[\\/]*])
++ lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
++ ;;
++*)
++ lt_save_MAGIC_CMD="$MAGIC_CMD"
++ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
++dnl $ac_dummy forces splitting on constant user-supplied paths.
++dnl POSIX.2 word splitting is done only on the output of word expansions,
++dnl not every word. This closes a longstanding sh security hole.
++ ac_dummy="m4_if([$2], , $PATH, [$2])"
++ for ac_dir in $ac_dummy; do
++ IFS="$lt_save_ifs"
++ test -z "$ac_dir" && ac_dir=.
++ if test -f $ac_dir/$1; then
++ lt_cv_path_MAGIC_CMD="$ac_dir/$1"
++ if test -n "$file_magic_test_file"; then
++ case $deplibs_check_method in
++ "file_magic "*)
++ file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
++ MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
++ if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
++ $EGREP "$file_magic_regex" > /dev/null; then
++ :
++ else
++ cat <<_LT_EOF 1>&2
+
+- # When large executables or shared objects are built, AIX ld can
+- # have problems creating the table of contents. If linking a library
+- # or program results in "error TOC overflow" add -mminimal-toc to
+- # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
+- # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+-
+- _LT_AC_TAGVAR(archive_cmds, $1)=''
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':'
+- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
++*** Warning: the command libtool uses to detect shared libraries,
++*** $file_magic_cmd, produces output that libtool cannot recognize.
++*** The result is that libtool may fail to recognize shared libraries
++*** as such. This will affect the creation of libtool libraries that
++*** depend on shared libraries, but programs linked with such libtool
++*** libraries will work regardless of this problem. Nevertheless, you
++*** may want to report the problem to your system manager and/or to
++*** bug-libtool@gnu.org
+
+- if test "$GXX" = yes; then
+- case $host_os in aix4.[[012]]|aix4.[[012]].*)
+- # We only want to do this on AIX 4.2 and lower, the check
+- # below for broken collect2 doesn't work under 4.3+
+- collect2name=`${CC} -print-prog-name=collect2`
+- if test -f "$collect2name" && \
+- strings "$collect2name" | grep resolve_lib_name >/dev/null
+- then
+- # We have reworked collect2
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- else
+- # We have old collect2
+- _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported
+- # It fails to find uninstalled libraries when the uninstalled
+- # path is not listed in the libpath. Setting hardcode_minus_L
+- # to unsupported forces relinking
+- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
+- fi
+- ;;
+- esac
+- shared_flag='-shared'
+- if test "$aix_use_runtimelinking" = yes; then
+- shared_flag="$shared_flag "'${wl}-G'
+- fi
+- else
+- # not using gcc
+- if test "$host_cpu" = ia64; then
+- # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+- # chokes on -Wl,-G. The following line is correct:
+- shared_flag='-G'
+- else
+- if test "$aix_use_runtimelinking" = yes; then
+- shared_flag='${wl}-G'
+- else
+- shared_flag='${wl}-bM:SRE'
+- fi
++_LT_EOF
++ fi ;;
++ esac
+ fi
++ break
+ fi
++ done
++ IFS="$lt_save_ifs"
++ MAGIC_CMD="$lt_save_MAGIC_CMD"
++ ;;
++esac])
++MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
++if test -n "$MAGIC_CMD"; then
++ AC_MSG_RESULT($MAGIC_CMD)
++else
++ AC_MSG_RESULT(no)
++fi
++_LT_DECL([], [MAGIC_CMD], [0],
++ [Used to examine libraries when file_magic_cmd begins with "file"])dnl
++])# _LT_PATH_TOOL_PREFIX
+
+- # It seems that -bexpall does not export symbols beginning with
+- # underscore (_), so it is better to generate a list of symbols to export.
+- _LT_AC_TAGVAR(always_export_symbols, $1)=yes
+- if test "$aix_use_runtimelinking" = yes; then
+- # Warning - without using the other runtime loading flags (-brtl),
+- # -berok will link without error, but may produce a broken library.
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)='-berok'
+- # Determine the default libpath from the value encoded in an empty executable.
+- _LT_AC_SYS_LIBPATH_AIX
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
++# Old name:
++AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX])
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], [])
+
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+- else
+- if test "$host_cpu" = ia64; then
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+- else
+- # Determine the default libpath from the value encoded in an empty executable.
+- _LT_AC_SYS_LIBPATH_AIX
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+- # Warning - without using the other run time loading flags,
+- # -berok will link without error, but may produce a broken library.
+- _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
+- # Exported symbols can be pulled into shared objects from archives
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
+- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
+- # This is similar to how AIX traditionally builds its shared libraries.
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+- fi
+- fi
+- ;;
+
+- beos*)
+- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+- # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
+- # support --undefined. This deserves some investigation. FIXME
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+- else
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- fi
+- ;;
++# _LT_PATH_MAGIC
++# --------------
++# find a file program which can recognize a shared library
++m4_defun([_LT_PATH_MAGIC],
++[_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH)
++if test -z "$lt_cv_path_MAGIC_CMD"; then
++ if test -n "$ac_tool_prefix"; then
++ _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH)
++ else
++ MAGIC_CMD=:
++ fi
++fi
++])# _LT_PATH_MAGIC
+
+- chorus*)
+- case $cc_basename in
+- *)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- esac
+- ;;
+
+- cygwin* | mingw* | pw32*)
+- # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
+- # as there is no search path for DLLs.
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+- _LT_AC_TAGVAR(always_export_symbols, $1)=no
+- _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+-
+- if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+- # If the export-symbols file already is a .def file (1st line
+- # is EXPORTS), use it as is; otherwise, prepend...
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+- cp $export_symbols $output_objdir/$soname.def;
+- else
+- echo EXPORTS > $output_objdir/$soname.def;
+- cat $export_symbols >> $output_objdir/$soname.def;
+- fi~
+- $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+- else
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- fi
+- ;;
+- darwin* | rhapsody*)
+- case $host_os in
+- rhapsody* | darwin1.[[012]])
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}suppress'
+- ;;
+- *) # Darwin 1.3 on
+- if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+- else
+- case ${MACOSX_DEPLOYMENT_TARGET} in
+- 10.[[012]])
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+- ;;
+- 10.*)
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}dynamic_lookup'
+- ;;
+- esac
+- fi
+- ;;
+- esac
+- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+- _LT_AC_TAGVAR(hardcode_direct, $1)=no
+- _LT_AC_TAGVAR(hardcode_automatic, $1)=yes
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=''
+- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+-
+- if test "$GXX" = yes ; then
+- lt_int_apple_cc_single_mod=no
+- output_verbose_link_cmd='echo'
+- if $CC -dumpspecs 2>&1 | $EGREP 'single_module' >/dev/null ; then
+- lt_int_apple_cc_single_mod=yes
+- fi
+- if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+- else
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+- fi
+- _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+- # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
+- if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+- else
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+- fi
+- _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+- else
+- case $cc_basename in
+- xlc*)
+- output_verbose_link_cmd='echo'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
+- _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+- # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+- _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+- ;;
+- *)
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- esac
+- fi
+- ;;
++# LT_PATH_LD
++# ----------
++# find the pathname to the GNU or non-GNU linker
++AC_DEFUN([LT_PATH_LD],
++[AC_REQUIRE([AC_PROG_CC])dnl
++AC_REQUIRE([AC_CANONICAL_HOST])dnl
++AC_REQUIRE([AC_CANONICAL_BUILD])dnl
++m4_require([_LT_DECL_SED])dnl
++m4_require([_LT_DECL_EGREP])dnl
+
+- dgux*)
+- case $cc_basename in
+- ec++*)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- ghcx*)
+- # Green Hills C++ Compiler
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- *)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- esac
+- ;;
+- freebsd[[12]]*)
+- # C++ shared libraries reported to be fairly broken before switch to ELF
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- freebsd-elf*)
+- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+- ;;
+- freebsd* | kfreebsd*-gnu | dragonfly*)
+- # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
+- # conventions
+- _LT_AC_TAGVAR(ld_shlibs, $1)=yes
+- ;;
+- gnu*)
+- ;;
+- hpux9*)
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
+- # but as the default
+- # location of the library.
+-
+- case $cc_basename in
+- CC*)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- aCC*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+- # Commands to make compiler produce verbose output that lists
+- # what "hidden" libraries, object files and flags are used when
+- # linking a shared library.
+- #
+- # There doesn't appear to be a way to prevent this compiler from
+- # explicitly linking system object files so we need to strip them
+- # from the output so that they don't get included in the library
+- # dependencies.
+- output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "[[-]]L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+- ;;
+- *)
+- if test "$GXX" = yes; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+- else
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- fi
+- ;;
+- esac
+- ;;
+- hpux10*|hpux11*)
+- if test $with_gnu_ld = no; then
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
++AC_ARG_WITH([gnu-ld],
++ [AS_HELP_STRING([--with-gnu-ld],
++ [assume the C compiler uses GNU ld @<:@default=no@:>@])],
++ [test "$withval" = no || with_gnu_ld=yes],
++ [with_gnu_ld=no])dnl
+
+- case $host_cpu in
+- hppa*64*|ia64*)
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir'
+- ;;
+- *)
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+- ;;
+- esac
+- fi
+- case $host_cpu in
+- hppa*64*|ia64*)
+- _LT_AC_TAGVAR(hardcode_direct, $1)=no
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- ;;
+- *)
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
+- # but as the default
+- # location of the library.
++ac_prog=ld
++if test "$GCC" = yes; then
++ # Check if gcc -print-prog-name=ld gives a path.
++ AC_MSG_CHECKING([for ld used by $CC])
++ case $host in
++ *-*-mingw*)
++ # gcc leaves a trailing carriage return which upsets mingw
++ ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
++ *)
++ ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
++ esac
++ case $ac_prog in
++ # Accept absolute paths.
++ [[\\/]]* | ?:[[\\/]]*)
++ re_direlt='/[[^/]][[^/]]*/\.\./'
++ # Canonicalize the pathname of ld
++ ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'`
++ while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
++ ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
++ done
++ test -z "$LD" && LD="$ac_prog"
+ ;;
+- esac
+-
+- case $cc_basename in
+- CC*)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- aCC*)
+- case $host_cpu in
+- hppa*64*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+- ;;
+- ia64*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+- ;;
+- *)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+- ;;
+- esac
+- # Commands to make compiler produce verbose output that lists
+- # what "hidden" libraries, object files and flags are used when
+- # linking a shared library.
+- #
+- # There doesn't appear to be a way to prevent this compiler from
+- # explicitly linking system object files so we need to strip them
+- # from the output so that they don't get included in the library
+- # dependencies.
+- output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+- ;;
+- *)
+- if test "$GXX" = yes; then
+- if test $with_gnu_ld = no; then
+- case $host_cpu in
+- hppa*64*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+- ;;
+- ia64*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+- ;;
+- *)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+- ;;
+- esac
+- fi
+- else
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- fi
+- ;;
+- esac
+- ;;
+- interix3*)
+- _LT_AC_TAGVAR(hardcode_direct, $1)=no
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+- # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+- # Instead, shared libraries are loaded at an image base (0x10000000 by
+- # default) and relocated if they conflict, which is a slow very memory
+- # consuming and fragmenting process. To avoid this, we pick a random,
+- # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+- # time. Moving up from 0x10000000 also allows more sbrk(2) space.
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+- ;;
+- irix5* | irix6*)
+- case $cc_basename in
+- CC*)
+- # SGI C++
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+-
+- # Archives containing C++ object files must be created using
+- # "CC -ar", where "CC" is the IRIX C++ compiler. This is
+- # necessary to make sure instantiated templates are included
+- # in the archive.
+- _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs'
+- ;;
+- *)
+- if test "$GXX" = yes; then
+- if test "$with_gnu_ld" = no; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+- else
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` -o $lib'
+- fi
+- fi
+- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+- ;;
+- esac
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
++ "")
++ # If it fails, then pretend we aren't using GCC.
++ ac_prog=ld
+ ;;
+- linux*)
+- case $cc_basename in
+- KCC*)
+- # Kuck and Associates, Inc. (KAI) C++ Compiler
+-
+- # KCC will only create a shared library if the output file
+- # ends with ".so" (or ".sl" for HP-UX), so rename the library
+- # to its proper name (with version) after linking.
+- _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib'
+- # Commands to make compiler produce verbose output that lists
+- # what "hidden" libraries, object files and flags are used when
+- # linking a shared library.
+- #
+- # There doesn't appear to be a way to prevent this compiler from
+- # explicitly linking system object files so we need to strip them
+- # from the output so that they don't get included in the library
+- # dependencies.
+- output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | grep "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+-
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath,$libdir'
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+-
+- # Archives containing C++ object files must be created using
+- # "CC -Bstatic", where "CC" is the KAI C++ compiler.
+- _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs'
+- ;;
+- icpc*)
+- # Intel C++
+- with_gnu_ld=yes
+- # version 8.0 and above of icpc choke on multiply defined symbols
+- # if we add $predep_objects and $postdep_objects, however 7.1 and
+- # earlier do not add the objects themselves.
+- case `$CC -V 2>&1` in
+- *"Version 7."*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+- ;;
+- *) # Version 8.0 or newer
+- tmp_idyn=
+- case $host_cpu in
+- ia64*) tmp_idyn=' -i_dynamic';;
+- esac
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+- ;;
+- esac
+- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+- ;;
+- pgCC*)
+- # Portland Group C++ compiler
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+-
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+- ;;
+- cxx*)
+- # Compaq C++
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
+-
+- runpath_var=LD_RUN_PATH
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+-
+- # Commands to make compiler produce verbose output that lists
+- # what "hidden" libraries, object files and flags are used when
+- # linking a shared library.
+- #
+- # There doesn't appear to be a way to prevent this compiler from
+- # explicitly linking system object files so we need to strip them
+- # from the output so that they don't get included in the library
+- # dependencies.
+- output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+- ;;
+- *)
+- case `$CC -V 2>&1 | sed 5q` in
+- *Sun\ C*)
+- # Sun C++ 5.9
+- _LT_AC_TAGVAR(no_undefined_flag, $1)=' -zdefs'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols'
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+-
+- # Not sure whether something based on
+- # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1
+- # would be better.
+- output_verbose_link_cmd='echo'
+-
+- # Archives containing C++ object files must be created using
+- # "CC -xar", where "CC" is the Sun C++ compiler. This is
+- # necessary to make sure instantiated templates are included
+- # in the archive.
+- _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
+- ;;
+- esac
+- ;;
+- esac
++ *)
++ # If it is relative, then search for the first ld in PATH.
++ with_gnu_ld=unknown
+ ;;
+- lynxos*)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- m88k*)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- mvs*)
+- case $cc_basename in
+- cxx*)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
++ esac
++elif test "$with_gnu_ld" = yes; then
++ AC_MSG_CHECKING([for GNU ld])
++else
++ AC_MSG_CHECKING([for non-GNU ld])
++fi
++AC_CACHE_VAL(lt_cv_path_LD,
++[if test -z "$LD"; then
++ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
++ for ac_dir in $PATH; do
++ IFS="$lt_save_ifs"
++ test -z "$ac_dir" && ac_dir=.
++ if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
++ lt_cv_path_LD="$ac_dir/$ac_prog"
++ # Check to see if the program is GNU ld. I'd rather use --version,
++ # but apparently some variants of GNU ld only accept -v.
++ # Break only if it was the GNU/non-GNU ld that we prefer.
++ case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
++ *GNU* | *'with BFD'*)
++ test "$with_gnu_ld" != no && break
+ ;;
+ *)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
++ test "$with_gnu_ld" != yes && break
+ ;;
+- esac
+- ;;
+- netbsd*)
+- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags'
+- wlarc=
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- fi
+- # Workaround some broken pre-1.5 toolchains
+- output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"'
+- ;;
+- openbsd2*)
+- # C++ shared libraries are fairly broken
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- openbsd*)
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
++ esac
+ fi
+- output_verbose_link_cmd='echo'
+- ;;
+- osf3*)
+- case $cc_basename in
+- KCC*)
+- # Kuck and Associates, Inc. (KAI) C++ Compiler
+-
+- # KCC will only create a shared library if the output file
+- # ends with ".so" (or ".sl" for HP-UX), so rename the library
+- # to its proper name (with version) after linking.
+- _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+-
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+-
+- # Archives containing C++ object files must be created using
+- # "CC -Bstatic", where "CC" is the KAI C++ compiler.
+- _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs'
+-
+- ;;
+- RCC*)
+- # Rational C++ 2.4.1
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- cxx*)
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && echo ${wl}-set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+-
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+-
+- # Commands to make compiler produce verbose output that lists
+- # what "hidden" libraries, object files and flags are used when
+- # linking a shared library.
+- #
+- # There doesn't appear to be a way to prevent this compiler from
+- # explicitly linking system object files so we need to strip them
+- # from the output so that they don't get included in the library
+- # dependencies.
+- output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+- ;;
+- *)
+- if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+-
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+-
+- # Commands to make compiler produce verbose output that lists
+- # what "hidden" libraries, object files and flags are used when
+- # linking a shared library.
+- output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"'
++ done
++ IFS="$lt_save_ifs"
++else
++ lt_cv_path_LD="$LD" # Let the user override the test with a path.
++fi])
++LD="$lt_cv_path_LD"
++if test -n "$LD"; then
++ AC_MSG_RESULT($LD)
++else
++ AC_MSG_RESULT(no)
++fi
++test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
++_LT_PATH_LD_GNU
++AC_SUBST([LD])
+
+- else
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- fi
+- ;;
+- esac
+- ;;
+- osf4* | osf5*)
+- case $cc_basename in
+- KCC*)
+- # Kuck and Associates, Inc. (KAI) C++ Compiler
+-
+- # KCC will only create a shared library if the output file
+- # ends with ".so" (or ".sl" for HP-UX), so rename the library
+- # to its proper name (with version) after linking.
+- _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+-
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+-
+- # Archives containing C++ object files must be created using
+- # the KAI C++ compiler.
+- _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs'
+- ;;
+- RCC*)
+- # Rational C++ 2.4.1
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- cxx*)
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
+- echo "-hidden">> $lib.exp~
+- $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname -Wl,-input -Wl,$lib.exp `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~
+- $rm $lib.exp'
+-
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+-
+- # Commands to make compiler produce verbose output that lists
+- # what "hidden" libraries, object files and flags are used when
+- # linking a shared library.
+- #
+- # There doesn't appear to be a way to prevent this compiler from
+- # explicitly linking system object files so we need to strip them
+- # from the output so that they don't get included in the library
+- # dependencies.
+- output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+- ;;
+- *)
+- if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+-
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+-
+- # Commands to make compiler produce verbose output that lists
+- # what "hidden" libraries, object files and flags are used when
+- # linking a shared library.
+- output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"'
++_LT_TAGDECL([], [LD], [1], [The linker used to build libraries])
++])# LT_PATH_LD
+
+- else
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- fi
+- ;;
+- esac
+- ;;
+- psos*)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- sunos4*)
+- case $cc_basename in
+- CC*)
+- # Sun C++ 4.x
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- lcc*)
+- # Lucid
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- *)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- esac
++# Old names:
++AU_ALIAS([AM_PROG_LD], [LT_PATH_LD])
++AU_ALIAS([AC_PROG_LD], [LT_PATH_LD])
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([AM_PROG_LD], [])
++dnl AC_DEFUN([AC_PROG_LD], [])
++
++
++# _LT_PATH_LD_GNU
++#- --------------
++m4_defun([_LT_PATH_LD_GNU],
++[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], lt_cv_prog_gnu_ld,
++[# I'd rather use --version here, but apparently some GNU lds only accept -v.
++case `$LD -v 2>&1 </dev/null` in
++*GNU* | *'with BFD'*)
++ lt_cv_prog_gnu_ld=yes
++ ;;
++*)
++ lt_cv_prog_gnu_ld=no
++ ;;
++esac])
++with_gnu_ld=$lt_cv_prog_gnu_ld
++])# _LT_PATH_LD_GNU
++
++
++# _LT_CMD_RELOAD
++# --------------
++# find reload flag for linker
++# -- PORTME Some linkers may need a different reload flag.
++m4_defun([_LT_CMD_RELOAD],
++[AC_CACHE_CHECK([for $LD option to reload object files],
++ lt_cv_ld_reload_flag,
++ [lt_cv_ld_reload_flag='-r'])
++reload_flag=$lt_cv_ld_reload_flag
++case $reload_flag in
++"" | " "*) ;;
++*) reload_flag=" $reload_flag" ;;
++esac
++reload_cmds='$LD$reload_flag -o $output$reload_objs'
++case $host_os in
++ darwin*)
++ if test "$GCC" = yes; then
++ reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
++ else
++ reload_cmds='$LD$reload_flag -o $output$reload_objs'
++ fi
+ ;;
+- solaris*)
+- case $cc_basename in
+- CC*)
+- # Sun C++ 4.2, 5.x and Centerline C++
+- _LT_AC_TAGVAR(archive_cmds_need_lc,$1)=yes
+- _LT_AC_TAGVAR(no_undefined_flag, $1)=' -zdefs'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+- $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
+-
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- case $host_os in
+- solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
+- *)
+- # The C++ compiler is used as linker so we must use $wl
+- # flag to pass the commands to the underlying system
+- # linker. We must also pass each convience library through
+- # to the system linker between allextract/defaultextract.
+- # The C++ compiler will combine linker options so we
+- # cannot just pass the convience library names through
+- # without $wl.
+- # Supported since Solaris 2.6 (maybe 2.5.1?)
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract'
+- ;;
+- esac
+- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
++esac
++_LT_DECL([], [reload_flag], [1], [How to create reloadable object files])dnl
++_LT_DECL([], [reload_cmds], [2])dnl
++])# _LT_CMD_RELOAD
+
+- output_verbose_link_cmd='echo'
+
+- # Archives containing C++ object files must be created using
+- # "CC -xar", where "CC" is the Sun C++ compiler. This is
+- # necessary to make sure instantiated templates are included
+- # in the archive.
+- _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
+- ;;
+- gcx*)
+- # Green Hills C++ Compiler
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
++# _LT_CHECK_MAGIC_METHOD
++# ----------------------
++# how to check for library dependencies
++# -- PORTME fill in with the dynamic library characteristics
++m4_defun([_LT_CHECK_MAGIC_METHOD],
++[m4_require([_LT_DECL_EGREP])
++AC_CACHE_CHECK([how to recognize dependent libraries],
++lt_cv_deplibs_check_method,
++[lt_cv_file_magic_cmd='$MAGIC_CMD'
++lt_cv_file_magic_test_file=
++lt_cv_deplibs_check_method='unknown'
++# Need to set the preceding variable on all platforms that support
++# interlibrary dependencies.
++# 'none' -- dependencies not supported.
++# `unknown' -- same as none, but documents that we really don't know.
++# 'pass_all' -- all dependencies passed with no checks.
++# 'test_compile' -- check by making test program.
++# 'file_magic [[regex]]' -- check by looking for files in library path
++# which responds to the $file_magic_cmd with a given extended regex.
++# If you have `file' or equivalent on your system and you're not sure
++# whether `pass_all' will *always* work, you probably want this one.
+
+- # The C++ compiler must be used to create the archive.
+- _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
+- ;;
+- *)
+- # GNU C++ compiler with Solaris linker
+- if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+- _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs'
+- if $CC --version | grep -v '^2\.7' > /dev/null; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+- $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
++case $host_os in
++aix[[4-9]]*)
++ lt_cv_deplibs_check_method=pass_all
++ ;;
+
+- # Commands to make compiler produce verbose output that lists
+- # what "hidden" libraries, object files and flags are used when
+- # linking a shared library.
+- output_verbose_link_cmd="$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\""
+- else
+- # g++ 2.7 appears to require `-G' NOT `-shared' on this
+- # platform.
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+- $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
++beos*)
++ lt_cv_deplibs_check_method=pass_all
++ ;;
+
+- # Commands to make compiler produce verbose output that lists
+- # what "hidden" libraries, object files and flags are used when
+- # linking a shared library.
+- output_verbose_link_cmd="$CC -G $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\""
+- fi
++bsdi[[45]]*)
++ lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib)'
++ lt_cv_file_magic_cmd='/usr/bin/file -L'
++ lt_cv_file_magic_test_file=/shlib/libc.so
++ ;;
+
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir'
+- fi
+- ;;
+- esac
+- ;;
+- sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
+- _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- runpath_var='LD_RUN_PATH'
+-
+- case $cc_basename in
+- CC*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+- ;;
+- *)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+- ;;
+- esac
+- ;;
+- sysv5* | sco3.2v5* | sco5v6*)
+- # Note: We can NOT use -z defs as we might desire, because we do not
+- # link with -lc, and that would cause any symbols used from libc to
+- # always be unresolved, which means just about no library would
+- # ever link correctly. If we're not using GNU ld we use -z text
+- # though, which does catch some bad symbols but isn't as heavy-handed
+- # as -z defs.
+- # For security reasons, it is highly recommended that you always
+- # use absolute paths for naming shared libraries, and exclude the
+- # DT_RUNPATH tag from executables and libraries. But doing so
+- # requires that you compile everything twice, which is a pain.
+- # So that behaviour is only enabled if SCOABSPATH is set to a
+- # non-empty value in the environment. Most likely only useful for
+- # creating official distributions of packages.
+- # This is a hack until libtool officially supports absolute path
+- # names for shared libraries.
+- _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
+- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':'
+- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
+- runpath_var='LD_RUN_PATH'
+-
+- case $cc_basename in
+- CC*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+- ;;
+- *)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+- ;;
+- esac
+- ;;
+- tandem*)
+- case $cc_basename in
+- NCC*)
+- # NonStop-UX NCC 3.20
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- *)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
++cygwin*)
++ # func_win32_libid is a shell function defined in ltmain.sh
++ lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
++ lt_cv_file_magic_cmd='func_win32_libid'
++ ;;
++
++mingw* | pw32*)
++ # Base MSYS/MinGW do not provide the 'file' command needed by
++ # func_win32_libid shell function, so use a weaker test based on 'objdump',
++ # unless we find 'file', for example because we are cross-compiling.
++ if ( file / ) >/dev/null 2>&1; then
++ lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
++ lt_cv_file_magic_cmd='func_win32_libid'
++ else
++ lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?'
++ lt_cv_file_magic_cmd='$OBJDUMP -f'
++ fi
++ ;;
++
++darwin* | rhapsody*)
++ lt_cv_deplibs_check_method=pass_all
++ ;;
++
++freebsd* | dragonfly*)
++ if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
++ case $host_cpu in
++ i*86 )
++ # Not sure whether the presence of OpenBSD here was a mistake.
++ # Let's accept both of them until this is cleared up.
++ lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library'
++ lt_cv_file_magic_cmd=/usr/bin/file
++ lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
++ ;;
+ esac
++ else
++ lt_cv_deplibs_check_method=pass_all
++ fi
++ ;;
++
++gnu*)
++ lt_cv_deplibs_check_method=pass_all
++ ;;
++
++hpux10.20* | hpux11*)
++ lt_cv_file_magic_cmd=/usr/bin/file
++ case $host_cpu in
++ ia64*)
++ lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64'
++ lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
+ ;;
+- vxworks*)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
++ hppa*64*)
++ [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]']
++ lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
+ ;;
+ *)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
++ lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]].[[0-9]]) shared library'
++ lt_cv_file_magic_test_file=/usr/lib/libc.sl
+ ;;
+-esac
+-AC_MSG_RESULT([$_LT_AC_TAGVAR(ld_shlibs, $1)])
+-test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
++ esac
++ ;;
+
+-_LT_AC_TAGVAR(GCC, $1)="$GXX"
+-_LT_AC_TAGVAR(LD, $1)="$LD"
++interix[[3-9]]*)
++ # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
++ lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$'
++ ;;
+
+-## CAVEAT EMPTOR:
+-## There is no encapsulation within the following macros, do not change
+-## the running order or otherwise move them around unless you know exactly
+-## what you are doing...
+-AC_LIBTOOL_POSTDEP_PREDEP($1)
+-AC_LIBTOOL_PROG_COMPILER_PIC($1)
+-AC_LIBTOOL_PROG_CC_C_O($1)
+-AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
+-AC_LIBTOOL_PROG_LD_SHLIBS($1)
+-AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
+-AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
++irix5* | irix6* | nonstopux*)
++ case $LD in
++ *-32|*"-32 ") libmagic=32-bit;;
++ *-n32|*"-n32 ") libmagic=N32;;
++ *-64|*"-64 ") libmagic=64-bit;;
++ *) libmagic=never-match;;
++ esac
++ lt_cv_deplibs_check_method=pass_all
++ ;;
+
+-AC_LIBTOOL_CONFIG($1)
++# This must be Linux ELF.
++linux* | k*bsd*-gnu)
++ lt_cv_deplibs_check_method=pass_all
++ ;;
+
+-AC_LANG_POP
+-CC=$lt_save_CC
+-LDCXX=$LD
+-LD=$lt_save_LD
+-GCC=$lt_save_GCC
+-with_gnu_ldcxx=$with_gnu_ld
+-with_gnu_ld=$lt_save_with_gnu_ld
+-lt_cv_path_LDCXX=$lt_cv_path_LD
+-lt_cv_path_LD=$lt_save_path_LD
+-lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
+-lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
+-])# AC_LIBTOOL_LANG_CXX_CONFIG
++netbsd*)
++ if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
++ lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
++ else
++ lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$'
++ fi
++ ;;
+
+-# AC_LIBTOOL_POSTDEP_PREDEP([TAGNAME])
+-# ------------------------------------
+-# Figure out "hidden" library dependencies from verbose
+-# compiler output when linking a shared library.
+-# Parse the compiler output and extract the necessary
+-# objects, libraries and library flags.
+-AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP],[
+-dnl we can't use the lt_simple_compile_test_code here,
+-dnl because it contains code intended for an executable,
+-dnl not a library. It's possible we should let each
+-dnl tag define a new lt_????_link_test_code variable,
+-dnl but it's only used here...
+-ifelse([$1],[],[cat > conftest.$ac_ext <<EOF
+-int a;
+-void foo (void) { a = 0; }
+-EOF
+-],[$1],[CXX],[cat > conftest.$ac_ext <<EOF
+-class Foo
+-{
+-public:
+- Foo (void) { a = 0; }
+-private:
+- int a;
+-};
+-EOF
+-],[$1],[F77],[cat > conftest.$ac_ext <<EOF
+- subroutine foo
+- implicit none
+- integer*4 a
+- a=0
+- return
+- end
+-EOF
+-],[$1],[GCJ],[cat > conftest.$ac_ext <<EOF
+-public class foo {
+- private int a;
+- public void bar (void) {
+- a = 0;
+- }
+-};
+-EOF
+-])
+-dnl Parse the compiler output and extract the necessary
+-dnl objects, libraries and library flags.
+-if AC_TRY_EVAL(ac_compile); then
+- # Parse the compiler output and extract the necessary
+- # objects, libraries and library flags.
++newos6*)
++ lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)'
++ lt_cv_file_magic_cmd=/usr/bin/file
++ lt_cv_file_magic_test_file=/usr/lib/libnls.so
++ ;;
+
+- # Sentinel used to keep track of whether or not we are before
+- # the conftest object file.
+- pre_test_object_deps_done=no
++*nto* | *qnx*)
++ lt_cv_deplibs_check_method=pass_all
++ ;;
+
+- # The `*' in the case matches for architectures that use `case' in
+- # $output_verbose_cmd can trigger glob expansion during the loop
+- # eval without this substitution.
+- output_verbose_link_cmd=`$echo "X$output_verbose_link_cmd" | $Xsed -e "$no_glob_subst"`
++openbsd*)
++ if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
++ lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$'
++ else
++ lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
++ fi
++ ;;
+
+- for p in `eval $output_verbose_link_cmd`; do
+- case $p in
++osf3* | osf4* | osf5*)
++ lt_cv_deplibs_check_method=pass_all
++ ;;
+
+- -L* | -R* | -l*)
+- # Some compilers place space between "-{L,R}" and the path.
+- # Remove the space.
+- if test $p = "-L" \
+- || test $p = "-R"; then
+- prev=$p
+- continue
+- else
+- prev=
+- fi
++rdos*)
++ lt_cv_deplibs_check_method=pass_all
++ ;;
++
++solaris*)
++ lt_cv_deplibs_check_method=pass_all
++ ;;
++
++sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
++ lt_cv_deplibs_check_method=pass_all
++ ;;
++
++sysv4 | sysv4.3*)
++ case $host_vendor in
++ motorola)
++ lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]'
++ lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
++ ;;
++ ncr)
++ lt_cv_deplibs_check_method=pass_all
++ ;;
++ sequent)
++ lt_cv_file_magic_cmd='/bin/file'
++ lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )'
++ ;;
++ sni)
++ lt_cv_file_magic_cmd='/bin/file'
++ lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib"
++ lt_cv_file_magic_test_file=/lib/libc.so
++ ;;
++ siemens)
++ lt_cv_deplibs_check_method=pass_all
++ ;;
++ pc)
++ lt_cv_deplibs_check_method=pass_all
++ ;;
++ esac
++ ;;
++
++tpf*)
++ lt_cv_deplibs_check_method=pass_all
++ ;;
++esac
++])
++file_magic_cmd=$lt_cv_file_magic_cmd
++deplibs_check_method=$lt_cv_deplibs_check_method
++test -z "$deplibs_check_method" && deplibs_check_method=unknown
++
++_LT_DECL([], [deplibs_check_method], [1],
++ [Method to check whether dependent libraries are shared objects])
++_LT_DECL([], [file_magic_cmd], [1],
++ [Command to use when deplibs_check_method == "file_magic"])
++])# _LT_CHECK_MAGIC_METHOD
++
++
++# LT_PATH_NM
++# ----------
++# find the pathname to a BSD- or MS-compatible name lister
++AC_DEFUN([LT_PATH_NM],
++[AC_REQUIRE([AC_PROG_CC])dnl
++AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM,
++[if test -n "$NM"; then
++ # Let the user override the test.
++ lt_cv_path_NM="$NM"
++else
++ lt_nm_to_check="${ac_tool_prefix}nm"
++ if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
++ lt_nm_to_check="$lt_nm_to_check nm"
++ fi
++ for lt_tmp_nm in $lt_nm_to_check; do
++ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
++ for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
++ IFS="$lt_save_ifs"
++ test -z "$ac_dir" && ac_dir=.
++ tmp_nm="$ac_dir/$lt_tmp_nm"
++ if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
++ # Check to see if the nm accepts a BSD-compat flag.
++ # Adding the `sed 1q' prevents false positives on HP-UX, which says:
++ # nm: unknown option "B" ignored
++ # Tru64's nm complains that /dev/null is an invalid object file
++ case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
++ */dev/null* | *'Invalid file or object type'*)
++ lt_cv_path_NM="$tmp_nm -B"
++ break
++ ;;
++ *)
++ case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
++ */dev/null*)
++ lt_cv_path_NM="$tmp_nm -p"
++ break
++ ;;
++ *)
++ lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
++ continue # so that we can try to find one that supports BSD flags
++ ;;
++ esac
++ ;;
++ esac
++ fi
++ done
++ IFS="$lt_save_ifs"
++ done
++ : ${lt_cv_path_NM=no}
++fi])
++if test "$lt_cv_path_NM" != "no"; then
++ NM="$lt_cv_path_NM"
++else
++ # Didn't find any BSD compatible name lister, look for dumpbin.
++ AC_CHECK_TOOLS(DUMPBIN, ["dumpbin -symbols" "link -dump -symbols"], :)
++ AC_SUBST([DUMPBIN])
++ if test "$DUMPBIN" != ":"; then
++ NM="$DUMPBIN"
++ fi
++fi
++test -z "$NM" && NM=nm
++AC_SUBST([NM])
++_LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl
++
++AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface],
++ [lt_cv_nm_interface="BSD nm"
++ echo "int some_variable = 0;" > conftest.$ac_ext
++ (eval echo "\"\$as_me:__oline__: $ac_compile\"" >&AS_MESSAGE_LOG_FD)
++ (eval "$ac_compile" 2>conftest.err)
++ cat conftest.err >&AS_MESSAGE_LOG_FD
++ (eval echo "\"\$as_me:__oline__: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD)
++ (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
++ cat conftest.err >&AS_MESSAGE_LOG_FD
++ (eval echo "\"\$as_me:__oline__: output\"" >&AS_MESSAGE_LOG_FD)
++ cat conftest.out >&AS_MESSAGE_LOG_FD
++ if $GREP 'External.*some_variable' conftest.out > /dev/null; then
++ lt_cv_nm_interface="MS dumpbin"
++ fi
++ rm -f conftest*])
++])# LT_PATH_NM
++
++# Old names:
++AU_ALIAS([AM_PROG_NM], [LT_PATH_NM])
++AU_ALIAS([AC_PROG_NM], [LT_PATH_NM])
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([AM_PROG_NM], [])
++dnl AC_DEFUN([AC_PROG_NM], [])
++
++
++# LT_LIB_M
++# --------
++# check for math library
++AC_DEFUN([LT_LIB_M],
++[AC_REQUIRE([AC_CANONICAL_HOST])dnl
++LIBM=
++case $host in
++*-*-beos* | *-*-cygwin* | *-*-pw32* | *-*-darwin*)
++ # These system don't have libm, or don't need it
++ ;;
++*-ncr-sysv4.3*)
++ AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
++ AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm")
++ ;;
++*)
++ AC_CHECK_LIB(m, cos, LIBM="-lm")
++ ;;
++esac
++AC_SUBST([LIBM])
++])# LT_LIB_M
++
++# Old name:
++AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M])
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([AC_CHECK_LIBM], [])
++
++
++# _LT_COMPILER_NO_RTTI([TAGNAME])
++# -------------------------------
++m4_defun([_LT_COMPILER_NO_RTTI],
++[m4_require([_LT_TAG_COMPILER])dnl
++
++_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
++
++if test "$GCC" = yes; then
++ _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
++
++ _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions],
++ lt_cv_prog_compiler_rtti_exceptions,
++ [-fno-rtti -fno-exceptions], [],
++ [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"])
++fi
++_LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1],
++ [Compiler flag to turn off builtin functions])
++])# _LT_COMPILER_NO_RTTI
++
++
++# _LT_CMD_GLOBAL_SYMBOLS
++# ----------------------
++m4_defun([_LT_CMD_GLOBAL_SYMBOLS],
++[AC_REQUIRE([AC_CANONICAL_HOST])dnl
++AC_REQUIRE([AC_PROG_CC])dnl
++AC_REQUIRE([LT_PATH_NM])dnl
++AC_REQUIRE([LT_PATH_LD])dnl
++m4_require([_LT_DECL_SED])dnl
++m4_require([_LT_DECL_EGREP])dnl
++m4_require([_LT_TAG_COMPILER])dnl
++
++# Check for command to grab the raw symbol name followed by C symbol from nm.
++AC_MSG_CHECKING([command to parse $NM output from $compiler object])
++AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe],
++[
++# These are sane defaults that work on at least a few old systems.
++# [They come from Ultrix. What could be older than Ultrix?!! ;)]
++
++# Character class describing NM global symbol codes.
++symcode='[[BCDEGRST]]'
++
++# Regexp to match symbols that can be accessed directly from C.
++sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)'
++
++# Define system-specific variables.
++case $host_os in
++aix*)
++ symcode='[[BCDT]]'
++ ;;
++cygwin* | mingw* | pw32*)
++ symcode='[[ABCDGISTW]]'
++ ;;
++hpux*)
++ if test "$host_cpu" = ia64; then
++ symcode='[[ABCDEGRST]]'
++ fi
++ ;;
++irix* | nonstopux*)
++ symcode='[[BCDEGRST]]'
++ ;;
++osf*)
++ symcode='[[BCDEGQRST]]'
++ ;;
++solaris*)
++ symcode='[[BDRT]]'
++ ;;
++sco3.2v5*)
++ symcode='[[DT]]'
++ ;;
++sysv4.2uw2*)
++ symcode='[[DT]]'
++ ;;
++sysv5* | sco5v6* | unixware* | OpenUNIX*)
++ symcode='[[ABDT]]'
++ ;;
++sysv4)
++ symcode='[[DFNSTU]]'
++ ;;
++esac
++
++# If we're using GNU nm, then use its standard symbol codes.
++case `$NM -V 2>&1` in
++*GNU* | *'with BFD'*)
++ symcode='[[ABCDGIRSTW]]' ;;
++esac
++
++# Transform an extracted symbol line into a proper C declaration.
++# Some systems (esp. on ia64) link data and code symbols differently,
++# so use this general approach.
++lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
++
++# Transform an extracted symbol line into symbol name and symbol address
++lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p'"
++lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"lib\2\", (void *) \&\2},/p'"
++
++# Handle CRLF in mingw tool chain
++opt_cr=
++case $build_os in
++mingw*)
++ opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp
++ ;;
++esac
++
++# Try without a prefix underscore, then with it.
++for ac_symprfx in "" "_"; do
++
++ # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
++ symxfrm="\\1 $ac_symprfx\\2 \\2"
++
++ # Write the raw and C identifiers.
++ if test "$lt_cv_nm_interface" = "MS dumpbin"; then
++ # Fake it for dumpbin and say T for any non-static function
++ # and D for any global variable.
++ # Also find C++ and __fastcall symbols from MSVC++,
++ # which start with @ or ?.
++ lt_cv_sys_global_symbol_pipe="$AWK ['"\
++" {last_section=section; section=\$ 3};"\
++" /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\
++" \$ 0!~/External *\|/{next};"\
++" / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\
++" {if(hide[section]) next};"\
++" {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\
++" {split(\$ 0, a, /\||\r/); split(a[2], s)};"\
++" s[1]~/^[@?]/{print s[1], s[1]; next};"\
++" s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\
++" ' prfx=^$ac_symprfx]"
++ else
++ lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
++ fi
++
++ # Check to see that the pipe works correctly.
++ pipe_works=no
++
++ rm -f conftest*
++ cat > conftest.$ac_ext <<_LT_EOF
++#ifdef __cplusplus
++extern "C" {
++#endif
++char nm_test_var;
++void nm_test_func(void);
++void nm_test_func(void){}
++#ifdef __cplusplus
++}
++#endif
++int main(){nm_test_var='a';nm_test_func();return(0);}
++_LT_EOF
++
++ if AC_TRY_EVAL(ac_compile); then
++ # Now try to grab the symbols.
++ nlist=conftest.nm
++ if AC_TRY_EVAL(NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) && test -s "$nlist"; then
++ # Try sorting and uniquifying the output.
++ if sort "$nlist" | uniq > "$nlist"T; then
++ mv -f "$nlist"T "$nlist"
++ else
++ rm -f "$nlist"T
++ fi
++
++ # Make sure that we snagged all the symbols we need.
++ if $GREP ' nm_test_var$' "$nlist" >/dev/null; then
++ if $GREP ' nm_test_func$' "$nlist" >/dev/null; then
++ cat <<_LT_EOF > conftest.$ac_ext
++#ifdef __cplusplus
++extern "C" {
++#endif
++
++_LT_EOF
++ # Now generate the symbol file.
++ eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext'
++
++ cat <<_LT_EOF >> conftest.$ac_ext
++
++/* The mapping between symbol names and symbols. */
++const struct {
++ const char *name;
++ void *address;
++}
++lt__PROGRAM__LTX_preloaded_symbols[[]] =
++{
++ { "@PROGRAM@", (void *) 0 },
++_LT_EOF
++ $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
++ cat <<\_LT_EOF >> conftest.$ac_ext
++ {0, (void *) 0}
++};
++
++/* This works around a problem in FreeBSD linker */
++#ifdef FREEBSD_WORKAROUND
++static const void *lt_preloaded_setup() {
++ return lt__PROGRAM__LTX_preloaded_symbols;
++}
++#endif
++
++#ifdef __cplusplus
++}
++#endif
++_LT_EOF
++ # Now try linking the two files.
++ mv conftest.$ac_objext conftstm.$ac_objext
++ lt_save_LIBS="$LIBS"
++ lt_save_CFLAGS="$CFLAGS"
++ LIBS="conftstm.$ac_objext"
++ CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)"
++ if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then
++ pipe_works=yes
++ fi
++ LIBS="$lt_save_LIBS"
++ CFLAGS="$lt_save_CFLAGS"
++ else
++ echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD
++ fi
++ else
++ echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD
++ fi
++ else
++ echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD
++ fi
++ else
++ echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD
++ cat conftest.$ac_ext >&5
++ fi
++ rm -rf conftest* conftst*
+
+- if test "$pre_test_object_deps_done" = no; then
+- case $p in
+- -L* | -R*)
+- # Internal compiler library paths should come after those
+- # provided the user. The postdeps already come after the
+- # user supplied libs so there is no need to process them.
+- if test -z "$_LT_AC_TAGVAR(compiler_lib_search_path, $1)"; then
+- _LT_AC_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}"
+- else
+- _LT_AC_TAGVAR(compiler_lib_search_path, $1)="${_LT_AC_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}"
+- fi
+- ;;
+- # The "-l" case would never come before the object being
+- # linked, so don't bother handling this case.
+- esac
+- else
+- if test -z "$_LT_AC_TAGVAR(postdeps, $1)"; then
+- _LT_AC_TAGVAR(postdeps, $1)="${prev}${p}"
+- else
+- _LT_AC_TAGVAR(postdeps, $1)="${_LT_AC_TAGVAR(postdeps, $1)} ${prev}${p}"
+- fi
+- fi
+- ;;
++ # Do not use the global_symbol_pipe unless it works.
++ if test "$pipe_works" = yes; then
++ break
++ else
++ lt_cv_sys_global_symbol_pipe=
++ fi
++done
++])
++if test -z "$lt_cv_sys_global_symbol_pipe"; then
++ lt_cv_sys_global_symbol_to_cdecl=
++fi
++if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
++ AC_MSG_RESULT(failed)
++else
++ AC_MSG_RESULT(ok)
++fi
+
+- *.$objext)
+- # This assumes that the test object file only shows up
+- # once in the compiler output.
+- if test "$p" = "conftest.$objext"; then
+- pre_test_object_deps_done=yes
+- continue
+- fi
++_LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1],
++ [Take the output of nm and produce a listing of raw symbols and C names])
++_LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1],
++ [Transform the output of nm in a proper C declaration])
++_LT_DECL([global_symbol_to_c_name_address],
++ [lt_cv_sys_global_symbol_to_c_name_address], [1],
++ [Transform the output of nm in a C name address pair])
++_LT_DECL([global_symbol_to_c_name_address_lib_prefix],
++ [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1],
++ [Transform the output of nm in a C name address pair when lib prefix is needed])
++]) # _LT_CMD_GLOBAL_SYMBOLS
+
+- if test "$pre_test_object_deps_done" = no; then
+- if test -z "$_LT_AC_TAGVAR(predep_objects, $1)"; then
+- _LT_AC_TAGVAR(predep_objects, $1)="$p"
+- else
+- _LT_AC_TAGVAR(predep_objects, $1)="$_LT_AC_TAGVAR(predep_objects, $1) $p"
+- fi
+- else
+- if test -z "$_LT_AC_TAGVAR(postdep_objects, $1)"; then
+- _LT_AC_TAGVAR(postdep_objects, $1)="$p"
+- else
+- _LT_AC_TAGVAR(postdep_objects, $1)="$_LT_AC_TAGVAR(postdep_objects, $1) $p"
+- fi
+- fi
+- ;;
+
+- *) ;; # Ignore the rest.
++# _LT_COMPILER_PIC([TAGNAME])
++# ---------------------------
++m4_defun([_LT_COMPILER_PIC],
++[m4_require([_LT_TAG_COMPILER])dnl
++_LT_TAGVAR(lt_prog_compiler_wl, $1)=
++_LT_TAGVAR(lt_prog_compiler_pic, $1)=
++_LT_TAGVAR(lt_prog_compiler_static, $1)=
++
++AC_MSG_CHECKING([for $compiler option to produce PIC])
++m4_if([$1], [CXX], [
++ # C++ specific cases for pic, static, wl, etc.
++ if test "$GXX" = yes; then
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+
++ case $host_os in
++ aix*)
++ # All AIX code is PIC.
++ if test "$host_cpu" = ia64; then
++ # AIX 5 now supports IA64 processor
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ fi
++ ;;
++
++ amigaos*)
++ case $host_cpu in
++ powerpc)
++ # see comment about AmigaOS4 .so support
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
++ ;;
++ m68k)
++ # FIXME: we need at least 68020 code to build shared libraries, but
++ # adding the `-m68020' flag to GCC prevents building anything better,
++ # like `-m68040'.
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
++ ;;
++ esac
++ ;;
++
++ beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
++ # PIC is the default for these OSes.
++ ;;
++ mingw* | cygwin* | os2* | pw32*)
++ # This hack is so that the source file can tell whether it is being
++ # built for inclusion in a dll (and should export symbols for example).
++ # Although the cygwin gcc ignores -fPIC, still need this for old-style
++ # (--disable-auto-import) libraries
++ m4_if([$1], [GCJ], [],
++ [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
++ ;;
++ darwin* | rhapsody*)
++ # PIC is the default on this platform
++ # Common symbols not allowed in MH_DYLIB files
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
++ ;;
++ *djgpp*)
++ # DJGPP does not support shared libraries at all
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)=
++ ;;
++ interix[[3-9]]*)
++ # Interix 3.x gcc -fpic/-fPIC options generate broken code.
++ # Instead, we relocate shared libraries at runtime.
++ ;;
++ sysv4*MP*)
++ if test -d /usr/nec; then
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
++ fi
++ ;;
++ hpux*)
++ # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
++ # not for PA HP-UX.
++ case $host_cpu in
++ hppa*64*|ia64*)
++ ;;
++ *)
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
++ ;;
++ esac
++ ;;
++ *qnx* | *nto*)
++ # QNX uses GNU C++, but need to define -shared option too, otherwise
++ # it will coredump.
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
++ ;;
++ *)
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
++ ;;
++ esac
++ else
++ case $host_os in
++ aix[[4-9]]*)
++ # All AIX code is PIC.
++ if test "$host_cpu" = ia64; then
++ # AIX 5 now supports IA64 processor
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ else
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
++ fi
++ ;;
++ chorus*)
++ case $cc_basename in
++ cxch68*)
++ # Green Hills C++ Compiler
++ # _LT_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a"
++ ;;
++ esac
++ ;;
++ dgux*)
++ case $cc_basename in
++ ec++*)
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ ;;
++ ghcx*)
++ # Green Hills C++ Compiler
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
++ ;;
++ *)
++ ;;
++ esac
++ ;;
++ freebsd* | dragonfly*)
++ # FreeBSD uses GNU C++
++ ;;
++ hpux9* | hpux10* | hpux11*)
++ case $cc_basename in
++ CC*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
++ if test "$host_cpu" != ia64; then
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
++ fi
++ ;;
++ aCC*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
++ case $host_cpu in
++ hppa*64*|ia64*)
++ # +Z the default
++ ;;
++ *)
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
++ ;;
++ esac
++ ;;
++ *)
++ ;;
++ esac
++ ;;
++ interix*)
++ # This is c89, which is MS Visual C++ (no shared libs)
++ # Anyone wants to do a port?
++ ;;
++ irix5* | irix6* | nonstopux*)
++ case $cc_basename in
++ CC*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
++ # CC pic flag -KPIC is the default.
++ ;;
++ *)
++ ;;
++ esac
++ ;;
++ linux* | k*bsd*-gnu)
++ case $cc_basename in
++ KCC*)
++ # KAI C++ Compiler
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
++ ;;
++ icpc* | ecpc* )
++ # Intel C++
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
++ ;;
++ pgCC* | pgcpp*)
++ # Portland Group C++ compiler
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ ;;
++ cxx*)
++ # Compaq C++
++ # Make sure the PIC flag is empty. It appears that all Alpha
++ # Linux and Compaq Tru64 Unix objects are PIC.
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)=
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
++ ;;
++ xlc* | xlC*)
++ # IBM XL 8.0 on PPC
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink'
++ ;;
++ *)
++ case `$CC -V 2>&1 | sed 5q` in
++ *Sun\ C*)
++ # Sun C++ 5.9
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
++ ;;
++ esac
++ ;;
++ esac
++ ;;
++ lynxos*)
++ ;;
++ m88k*)
++ ;;
++ mvs*)
++ case $cc_basename in
++ cxx*)
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall'
++ ;;
++ *)
++ ;;
++ esac
++ ;;
++ netbsd*)
++ ;;
++ *qnx* | *nto*)
++ # QNX uses GNU C++, but need to define -shared option too, otherwise
++ # it will coredump.
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
++ ;;
++ osf3* | osf4* | osf5*)
++ case $cc_basename in
++ KCC*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
++ ;;
++ RCC*)
++ # Rational C++ 2.4.1
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
++ ;;
++ cxx*)
++ # Digital/Compaq C++
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ # Make sure the PIC flag is empty. It appears that all Alpha
++ # Linux and Compaq Tru64 Unix objects are PIC.
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)=
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
++ ;;
++ *)
++ ;;
++ esac
++ ;;
++ psos*)
++ ;;
++ solaris*)
++ case $cc_basename in
++ CC*)
++ # Sun C++ 4.2, 5.x and Centerline C++
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
++ ;;
++ gcx*)
++ # Green Hills C++ Compiler
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
++ ;;
++ *)
++ ;;
++ esac
++ ;;
++ sunos4*)
++ case $cc_basename in
++ CC*)
++ # Sun C++ 4.x
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ ;;
++ lcc*)
++ # Lucid
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
++ ;;
++ *)
++ ;;
++ esac
++ ;;
++ sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
++ case $cc_basename in
++ CC*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ ;;
++ esac
++ ;;
++ tandem*)
++ case $cc_basename in
++ NCC*)
++ # NonStop-UX NCC 3.20
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ ;;
++ *)
++ ;;
++ esac
++ ;;
++ vxworks*)
++ ;;
++ *)
++ _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
++ ;;
+ esac
+- done
+-
+- # Clean up.
+- rm -f a.out a.exe
+-else
+- echo "libtool.m4: error: problem compiling $1 test program"
+-fi
+-
+-$rm -f confest.$objext
+-
+-# PORTME: override above test on systems where it is broken
+-ifelse([$1],[CXX],
+-[case $host_os in
+-interix3*)
+- # Interix 3.5 installs completely hosed .la files for C++, so rather than
+- # hack all around it, let's just trust "g++" to DTRT.
+- _LT_AC_TAGVAR(predep_objects,$1)=
+- _LT_AC_TAGVAR(postdep_objects,$1)=
+- _LT_AC_TAGVAR(postdeps,$1)=
+- ;;
+-
+-linux*)
+- case `$CC -V 2>&1 | sed 5q` in
+- *Sun\ C*)
+- # Sun C++ 5.9
+- _LT_AC_TAGVAR(postdeps,$1)='-lCstd -lCrun'
+- ;;
+- esac
+- ;;
+-
+-solaris*)
+- case $cc_basename in
+- CC*)
+- # Adding this requires a known-good setup of shared libraries for
+- # Sun compiler versions before 5.6, else PIC objects from an old
+- # archive will be linked into the output, leading to subtle bugs.
+- _LT_AC_TAGVAR(postdeps,$1)='-lCstd -lCrun'
+- ;;
+- esac
+- ;;
+-esac
+-])
+-
+-case " $_LT_AC_TAGVAR(postdeps, $1) " in
+-*" -lc "*) _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no ;;
+-esac
+-])# AC_LIBTOOL_POSTDEP_PREDEP
+-
+-# AC_LIBTOOL_LANG_F77_CONFIG
+-# --------------------------
+-# Ensure that the configuration vars for the C compiler are
+-# suitably defined. Those variables are subsequently used by
+-# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
+-AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG], [_LT_AC_LANG_F77_CONFIG(F77)])
+-AC_DEFUN([_LT_AC_LANG_F77_CONFIG],
+-[AC_REQUIRE([AC_PROG_F77])
+-AC_LANG_PUSH(Fortran 77)
+-
+-_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+-_LT_AC_TAGVAR(allow_undefined_flag, $1)=
+-_LT_AC_TAGVAR(always_export_symbols, $1)=no
+-_LT_AC_TAGVAR(archive_expsym_cmds, $1)=
+-_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=
+-_LT_AC_TAGVAR(hardcode_direct, $1)=no
+-_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
+-_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
+-_LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
+-_LT_AC_TAGVAR(hardcode_minus_L, $1)=no
+-_LT_AC_TAGVAR(hardcode_automatic, $1)=no
+-_LT_AC_TAGVAR(module_cmds, $1)=
+-_LT_AC_TAGVAR(module_expsym_cmds, $1)=
+-_LT_AC_TAGVAR(link_all_deplibs, $1)=unknown
+-_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+-_LT_AC_TAGVAR(no_undefined_flag, $1)=
+-_LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+-_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+-
+-# Source file extension for f77 test sources.
+-ac_ext=f
+-
+-# Object file extension for compiled f77 test sources.
+-objext=o
+-_LT_AC_TAGVAR(objext, $1)=$objext
+-
+-# Code to be used in simple compile tests
+-lt_simple_compile_test_code=" subroutine t\n return\n end\n"
+-
+-# Code to be used in simple link tests
+-lt_simple_link_test_code=" program t\n end\n"
+-
+-# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+-_LT_AC_SYS_COMPILER
+-
+-# save warnings/boilerplate of simple test code
+-_LT_COMPILER_BOILERPLATE
+-_LT_LINKER_BOILERPLATE
+-
+-# Allow CC to be a program name with arguments.
+-lt_save_CC="$CC"
+-CC=${F77-"f77"}
+-compiler=$CC
+-_LT_AC_TAGVAR(compiler, $1)=$CC
+-_LT_CC_BASENAME([$compiler])
+-
+-AC_MSG_CHECKING([if libtool supports shared libraries])
+-AC_MSG_RESULT([$can_build_shared])
+-
+-AC_MSG_CHECKING([whether to build shared libraries])
+-test "$can_build_shared" = "no" && enable_shared=no
+-
+-# On AIX, shared libraries and static libraries use the same namespace, and
+-# are all built from PIC.
+-case $host_os in
+-aix3*)
+- test "$enable_shared" = yes && enable_static=no
+- if test -n "$RANLIB"; then
+- archive_cmds="$archive_cmds~\$RANLIB \$lib"
+- postinstall_cmds='$RANLIB $lib'
+ fi
+- ;;
+-aix4* | aix5*)
+- if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+- test "$enable_shared" = yes && enable_static=no
+- fi
+- ;;
+-esac
+-AC_MSG_RESULT([$enable_shared])
+-
+-AC_MSG_CHECKING([whether to build static libraries])
+-# Make sure either enable_shared or enable_static is yes.
+-test "$enable_shared" = yes || enable_static=yes
+-AC_MSG_RESULT([$enable_static])
+-
+-_LT_AC_TAGVAR(GCC, $1)="$G77"
+-_LT_AC_TAGVAR(LD, $1)="$LD"
+-
+-AC_LIBTOOL_PROG_COMPILER_PIC($1)
+-AC_LIBTOOL_PROG_CC_C_O($1)
+-AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
+-AC_LIBTOOL_PROG_LD_SHLIBS($1)
+-AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
+-AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
+-
+-AC_LIBTOOL_CONFIG($1)
+-
+-AC_LANG_POP
+-CC="$lt_save_CC"
+-])# AC_LIBTOOL_LANG_F77_CONFIG
+-
+-
+-# AC_LIBTOOL_LANG_GCJ_CONFIG
+-# --------------------------
+-# Ensure that the configuration vars for the C compiler are
+-# suitably defined. Those variables are subsequently used by
+-# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
+-AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG], [_LT_AC_LANG_GCJ_CONFIG(GCJ)])
+-AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG],
+-[AC_LANG_SAVE
+-
+-# Source file extension for Java test sources.
+-ac_ext=java
++],
++[
++ if test "$GCC" = yes; then
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+
+-# Object file extension for compiled Java test sources.
+-objext=o
+-_LT_AC_TAGVAR(objext, $1)=$objext
++ case $host_os in
++ aix*)
++ # All AIX code is PIC.
++ if test "$host_cpu" = ia64; then
++ # AIX 5 now supports IA64 processor
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ fi
++ ;;
+
+-# Code to be used in simple compile tests
+-lt_simple_compile_test_code="class foo {}\n"
++ amigaos*)
++ case $host_cpu in
++ powerpc)
++ # see comment about AmigaOS4 .so support
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
++ ;;
++ m68k)
++ # FIXME: we need at least 68020 code to build shared libraries, but
++ # adding the `-m68020' flag to GCC prevents building anything better,
++ # like `-m68040'.
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
++ ;;
++ esac
++ ;;
+
+-# Code to be used in simple link tests
+-lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }\n'
++ beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
++ # PIC is the default for these OSes.
++ ;;
+
+-# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+-_LT_AC_SYS_COMPILER
++ mingw* | cygwin* | pw32* | os2*)
++ # This hack is so that the source file can tell whether it is being
++ # built for inclusion in a dll (and should export symbols for example).
++ # Although the cygwin gcc ignores -fPIC, still need this for old-style
++ # (--disable-auto-import) libraries
++ m4_if([$1], [GCJ], [],
++ [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
++ ;;
+
+-# save warnings/boilerplate of simple test code
+-_LT_COMPILER_BOILERPLATE
+-_LT_LINKER_BOILERPLATE
++ darwin* | rhapsody*)
++ # PIC is the default on this platform
++ # Common symbols not allowed in MH_DYLIB files
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
++ ;;
+
+-# Allow CC to be a program name with arguments.
+-lt_save_CC="$CC"
+-CC=${GCJ-"gcj"}
+-compiler=$CC
+-_LT_AC_TAGVAR(compiler, $1)=$CC
+-_LT_CC_BASENAME([$compiler])
++ hpux*)
++ # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
++ # not for PA HP-UX.
++ case $host_cpu in
++ hppa*64*|ia64*)
++ # +Z the default
++ ;;
++ *)
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
++ ;;
++ esac
++ ;;
+
+-# GCJ did not exist at the time GCC didn't implicitly link libc in.
+-_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
++ interix[[3-9]]*)
++ # Interix 3.x gcc -fpic/-fPIC options generate broken code.
++ # Instead, we relocate shared libraries at runtime.
++ ;;
+
+-_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
++ msdosdjgpp*)
++ # Just because we use GCC doesn't mean we suddenly get shared libraries
++ # on systems that don't support them.
++ _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
++ enable_shared=no
++ ;;
+
+-## CAVEAT EMPTOR:
+-## There is no encapsulation within the following macros, do not change
+-## the running order or otherwise move them around unless you know exactly
+-## what you are doing...
+-AC_LIBTOOL_PROG_COMPILER_NO_RTTI($1)
+-AC_LIBTOOL_PROG_COMPILER_PIC($1)
+-AC_LIBTOOL_PROG_CC_C_O($1)
+-AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
+-AC_LIBTOOL_PROG_LD_SHLIBS($1)
+-AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
+-AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
++ *nto* | *qnx*)
++ # QNX uses GNU C++, but need to define -shared option too, otherwise
++ # it will coredump.
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
++ ;;
+
+-AC_LIBTOOL_CONFIG($1)
++ sysv4*MP*)
++ if test -d /usr/nec; then
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
++ fi
++ ;;
+
+-AC_LANG_RESTORE
+-CC="$lt_save_CC"
+-])# AC_LIBTOOL_LANG_GCJ_CONFIG
++ *)
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
++ ;;
++ esac
++ else
++ # PORTME Check for flag to pass linker flags through the system compiler.
++ case $host_os in
++ aix*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ if test "$host_cpu" = ia64; then
++ # AIX 5 now supports IA64 processor
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ else
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
++ fi
++ ;;
+
++ mingw* | cygwin* | pw32* | os2*)
++ # This hack is so that the source file can tell whether it is being
++ # built for inclusion in a dll (and should export symbols for example).
++ m4_if([$1], [GCJ], [],
++ [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
++ ;;
+
+-# AC_LIBTOOL_LANG_RC_CONFIG
+-# -------------------------
+-# Ensure that the configuration vars for the Windows resource compiler are
+-# suitably defined. Those variables are subsequently used by
+-# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
+-AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG], [_LT_AC_LANG_RC_CONFIG(RC)])
+-AC_DEFUN([_LT_AC_LANG_RC_CONFIG],
+-[AC_LANG_SAVE
++ hpux9* | hpux10* | hpux11*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
++ # not for PA HP-UX.
++ case $host_cpu in
++ hppa*64*|ia64*)
++ # +Z the default
++ ;;
++ *)
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
++ ;;
++ esac
++ # Is there a better lt_prog_compiler_static that works with the bundled CC?
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
++ ;;
+
+-# Source file extension for RC test sources.
+-ac_ext=rc
++ irix5* | irix6* | nonstopux*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ # PIC (with -KPIC) is the default.
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
++ ;;
+
+-# Object file extension for compiled RC test sources.
+-objext=o
+-_LT_AC_TAGVAR(objext, $1)=$objext
++ linux* | k*bsd*-gnu)
++ case $cc_basename in
++ icc* | ecc* | ifort*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
++ ;;
++ pgcc* | pgf77* | pgf90* | pgf95*)
++ # Portland Group compilers (*not* the Pentium gcc compiler,
++ # which looks to be a dead project)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ ;;
++ ccc*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ # All Alpha code is PIC.
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
++ ;;
++ xl*)
++ # IBM XL C 8.0/Fortran 10.1 on PPC
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink'
++ ;;
++ *)
++ case `$CC -V 2>&1 | sed 5q` in
++ *Sun\ C*)
++ # Sun C 5.9
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ ;;
++ *Sun\ F*)
++ # Sun Fortran 8.3 passes all unrecognized flags to the linker
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)=''
++ ;;
++ esac
++ ;;
++ esac
++ ;;
+
+-# Code to be used in simple compile tests
+-lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }\n'
++ newsos6)
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ ;;
+
+-# Code to be used in simple link tests
+-lt_simple_link_test_code="$lt_simple_compile_test_code"
++ *nto* | *qnx*)
++ # QNX uses GNU C++, but need to define -shared option too, otherwise
++ # it will coredump.
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
++ ;;
+
+-# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+-_LT_AC_SYS_COMPILER
++ osf3* | osf4* | osf5*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ # All OSF/1 code is PIC.
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
++ ;;
+
+-# save warnings/boilerplate of simple test code
+-_LT_COMPILER_BOILERPLATE
+-_LT_LINKER_BOILERPLATE
++ rdos*)
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
++ ;;
+
+-# Allow CC to be a program name with arguments.
+-lt_save_CC="$CC"
+-CC=${RC-"windres"}
+-compiler=$CC
+-_LT_AC_TAGVAR(compiler, $1)=$CC
+-_LT_CC_BASENAME([$compiler])
+-_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
++ solaris*)
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ case $cc_basename in
++ f77* | f90* | f95*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';;
++ *)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';;
++ esac
++ ;;
+
+-AC_LIBTOOL_CONFIG($1)
++ sunos4*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ ;;
+
+-AC_LANG_RESTORE
+-CC="$lt_save_CC"
+-])# AC_LIBTOOL_LANG_RC_CONFIG
++ sysv4 | sysv4.2uw2* | sysv4.3*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ ;;
++
++ sysv4*MP*)
++ if test -d /usr/nec ;then
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ fi
++ ;;
+
++ sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ ;;
+
+-# AC_LIBTOOL_CONFIG([TAGNAME])
+-# ----------------------------
+-# If TAGNAME is not passed, then create an initial libtool script
+-# with a default configuration from the untagged config vars. Otherwise
+-# add code to config.status for appending the configuration named by
+-# TAGNAME from the matching tagged config vars.
+-AC_DEFUN([AC_LIBTOOL_CONFIG],
+-[# The else clause should only fire when bootstrapping the
+-# libtool distribution, otherwise you forgot to ship ltmain.sh
+-# with your package, and you will get complaints that there are
+-# no rules to generate ltmain.sh.
+-if test -f "$ltmain"; then
+- # See if we are running on zsh, and set the options which allow our commands through
+- # without removal of \ escapes.
+- if test -n "${ZSH_VERSION+set}" ; then
+- setopt NO_GLOB_SUBST
+- fi
+- # Now quote all the things that may contain metacharacters while being
+- # careful not to overquote the AC_SUBSTed values. We take copies of the
+- # variables and quote the copies for generation of the libtool script.
+- for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \
+- SED SHELL STRIP \
+- libname_spec library_names_spec soname_spec extract_expsyms_cmds \
+- old_striplib striplib file_magic_cmd finish_cmds finish_eval \
+- deplibs_check_method reload_flag reload_cmds need_locks \
+- lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \
+- lt_cv_sys_global_symbol_to_c_name_address \
+- sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
+- old_postinstall_cmds old_postuninstall_cmds \
+- _LT_AC_TAGVAR(compiler, $1) \
+- _LT_AC_TAGVAR(CC, $1) \
+- _LT_AC_TAGVAR(LD, $1) \
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1) \
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1) \
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1) \
+- _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) \
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1) \
+- _LT_AC_TAGVAR(thread_safe_flag_spec, $1) \
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1) \
+- _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1) \
+- _LT_AC_TAGVAR(old_archive_cmds, $1) \
+- _LT_AC_TAGVAR(old_archive_from_new_cmds, $1) \
+- _LT_AC_TAGVAR(predep_objects, $1) \
+- _LT_AC_TAGVAR(postdep_objects, $1) \
+- _LT_AC_TAGVAR(predeps, $1) \
+- _LT_AC_TAGVAR(postdeps, $1) \
+- _LT_AC_TAGVAR(compiler_lib_search_path, $1) \
+- _LT_AC_TAGVAR(archive_cmds, $1) \
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1) \
+- _LT_AC_TAGVAR(postinstall_cmds, $1) \
+- _LT_AC_TAGVAR(postuninstall_cmds, $1) \
+- _LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1) \
+- _LT_AC_TAGVAR(allow_undefined_flag, $1) \
+- _LT_AC_TAGVAR(no_undefined_flag, $1) \
+- _LT_AC_TAGVAR(export_symbols_cmds, $1) \
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) \
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1) \
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1) \
+- _LT_AC_TAGVAR(hardcode_automatic, $1) \
+- _LT_AC_TAGVAR(module_cmds, $1) \
+- _LT_AC_TAGVAR(module_expsym_cmds, $1) \
+- _LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1) \
+- _LT_AC_TAGVAR(exclude_expsyms, $1) \
+- _LT_AC_TAGVAR(include_expsyms, $1); do
+-
+- case $var in
+- _LT_AC_TAGVAR(old_archive_cmds, $1) | \
+- _LT_AC_TAGVAR(old_archive_from_new_cmds, $1) | \
+- _LT_AC_TAGVAR(archive_cmds, $1) | \
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1) | \
+- _LT_AC_TAGVAR(module_cmds, $1) | \
+- _LT_AC_TAGVAR(module_expsym_cmds, $1) | \
+- _LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1) | \
+- _LT_AC_TAGVAR(export_symbols_cmds, $1) | \
+- extract_expsyms_cmds | reload_cmds | finish_cmds | \
+- postinstall_cmds | postuninstall_cmds | \
+- old_postinstall_cmds | old_postuninstall_cmds | \
+- sys_lib_search_path_spec | sys_lib_dlsearch_path_spec)
+- # Double-quote double-evaled strings.
+- eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\""
++ unicos*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
++ ;;
++
++ uts4*)
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
++
+ *)
+- eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\""
++ _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+ ;;
+ esac
+- done
+-
+- case $lt_echo in
+- *'\[$]0 --fallback-echo"')
+- lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\[$]0 --fallback-echo"[$]/[$]0 --fallback-echo"/'`
++ fi
++])
++case $host_os in
++ # For platforms which do not support PIC, -DPIC is meaningless:
++ *djgpp*)
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)=
+ ;;
+- esac
+-
+-ifelse([$1], [],
+- [cfgfile="${ofile}T"
+- trap "$rm \"$cfgfile\"; exit 1" 1 2 15
+- $rm -f "$cfgfile"
+- AC_MSG_NOTICE([creating $ofile])],
+- [cfgfile="$ofile"])
+-
+- cat <<__EOF__ >> "$cfgfile"
+-ifelse([$1], [],
+-[#! $SHELL
++ *)
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])"
++ ;;
++esac
++AC_MSG_RESULT([$_LT_TAGVAR(lt_prog_compiler_pic, $1)])
++_LT_TAGDECL([wl], [lt_prog_compiler_wl], [1],
++ [How to pass a linker flag through the compiler])
+
+-# `$echo "$cfgfile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
+-# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP)
+-# NOTE: Changes made to this file will be lost: look at ltmain.sh.
+ #
+-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001
+-# Free Software Foundation, Inc.
+-#
+-# This file is part of GNU Libtool:
+-# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
+-#
+-# 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 of the License, or
+-# (at your option) any later version.
++# Check to make sure the PIC flag actually works.
+ #
+-# 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.
++if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then
++ _LT_COMPILER_OPTION([if $compiler PIC flag $_LT_TAGVAR(lt_prog_compiler_pic, $1) works],
++ [_LT_TAGVAR(lt_cv_prog_compiler_pic_works, $1)],
++ [$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [],
++ [case $_LT_TAGVAR(lt_prog_compiler_pic, $1) in
++ "" | " "*) ;;
++ *) _LT_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_TAGVAR(lt_prog_compiler_pic, $1)" ;;
++ esac],
++ [_LT_TAGVAR(lt_prog_compiler_pic, $1)=
++ _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no])
++fi
++_LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1],
++ [Additional compiler flags for building library objects])
++
+ #
+-# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
++# Check to make sure the static flag actually works.
+ #
+-# As a special exception to the GNU General Public License, if you
+-# distribute this file as part of a program that contains a
+-# configuration script generated by Autoconf, you may include it under
+-# the same distribution terms that you use for the rest of that program.
+-
+-# A sed program that does not truncate output.
+-SED=$lt_SED
+-
+-# Sed that helps us avoid accidentally triggering echo(1) options like -n.
+-Xsed="$SED -e 1s/^X//"
+-
+-# The HP-UX ksh and POSIX shell print the target directory to stdout
+-# if CDPATH is set.
+-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+-
+-# The names of the tagged configurations supported by this script.
+-available_tags=
+-
+-# ### BEGIN LIBTOOL CONFIG],
+-[# ### BEGIN LIBTOOL TAG CONFIG: $tagname])
+-
+-# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+-
+-# Shell to use when invoking shell scripts.
+-SHELL=$lt_SHELL
+-
+-# Whether or not to build shared libraries.
+-build_libtool_libs=$enable_shared
+-
+-# Whether or not to build static libraries.
+-build_old_libs=$enable_static
+-
+-# Whether or not to add -lc for building shared libraries.
+-build_libtool_need_lc=$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)
+-
+-# Whether or not to disallow shared libs when runtime libs are static
+-allow_libtool_libs_with_static_runtimes=$_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)
+-
+-# Whether or not to optimize for fast installation.
+-fast_install=$enable_fast_install
+-
+-# The host system.
+-host_alias=$host_alias
+-host=$host
+-host_os=$host_os
++wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_TAGVAR(lt_prog_compiler_static, $1)\"
++_LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works],
++ _LT_TAGVAR(lt_cv_prog_compiler_static_works, $1),
++ $lt_tmp_static_flag,
++ [],
++ [_LT_TAGVAR(lt_prog_compiler_static, $1)=])
++_LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1],
++ [Compiler flag to prevent dynamic linking])
++])# _LT_COMPILER_PIC
+
+-# The build system.
+-build_alias=$build_alias
+-build=$build
+-build_os=$build_os
+
+-# An echo program that does not interpret backslashes.
+-echo=$lt_echo
++# _LT_LINKER_SHLIBS([TAGNAME])
++# ----------------------------
++# See if the linker supports building shared libraries.
++m4_defun([_LT_LINKER_SHLIBS],
++[AC_REQUIRE([LT_PATH_LD])dnl
++AC_REQUIRE([LT_PATH_NM])dnl
++m4_require([_LT_FILEUTILS_DEFAULTS])dnl
++m4_require([_LT_DECL_EGREP])dnl
++m4_require([_LT_DECL_SED])dnl
++m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl
++m4_require([_LT_TAG_COMPILER])dnl
++AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
++m4_if([$1], [CXX], [
++ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
++ case $host_os in
++ aix[[4-9]]*)
++ # If we're using GNU nm, then we don't want the "-C" option.
++ # -C means demangle to AIX nm, but means don't demangle with GNU nm
++ if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
++ _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
++ else
++ _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
++ fi
++ ;;
++ pw32*)
++ _LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds"
++ ;;
++ cygwin* | mingw*)
++ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;/^.*[[ ]]__nm__/s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols'
++ ;;
++ *)
++ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
++ ;;
++ esac
++ _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']
++], [
++ runpath_var=
++ _LT_TAGVAR(allow_undefined_flag, $1)=
++ _LT_TAGVAR(always_export_symbols, $1)=no
++ _LT_TAGVAR(archive_cmds, $1)=
++ _LT_TAGVAR(archive_expsym_cmds, $1)=
++ _LT_TAGVAR(compiler_needs_object, $1)=no
++ _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)=
++ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
++ _LT_TAGVAR(hardcode_automatic, $1)=no
++ _LT_TAGVAR(hardcode_direct, $1)=no
++ _LT_TAGVAR(hardcode_direct_absolute, $1)=no
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
++ _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=
++ _LT_TAGVAR(hardcode_minus_L, $1)=no
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
++ _LT_TAGVAR(inherit_rpath, $1)=no
++ _LT_TAGVAR(link_all_deplibs, $1)=unknown
++ _LT_TAGVAR(module_cmds, $1)=
++ _LT_TAGVAR(module_expsym_cmds, $1)=
++ _LT_TAGVAR(old_archive_from_new_cmds, $1)=
++ _LT_TAGVAR(old_archive_from_expsyms_cmds, $1)=
++ _LT_TAGVAR(thread_safe_flag_spec, $1)=
++ _LT_TAGVAR(whole_archive_flag_spec, $1)=
++ # include_expsyms should be a list of space-separated symbols to be *always*
++ # included in the symbol list
++ _LT_TAGVAR(include_expsyms, $1)=
++ # exclude_expsyms can be an extended regexp of symbols to exclude
++ # it will be wrapped by ` (' and `)$', so one must not match beginning or
++ # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
++ # as well as any symbol that contains `d'.
++ _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']
++ # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
++ # platforms (ab)use it in PIC code, but their linkers get confused if
++ # the symbol is explicitly referenced. Since portable code cannot
++ # rely on this symbol name, it's probably fine to never include it in
++ # preloaded symbol tables.
++ # Exclude shared library initialization/finalization symbols.
++dnl Note also adjust exclude_expsyms for C++ above.
++ extract_expsyms_cmds=
+
+-# The archiver.
+-AR=$lt_AR
+-AR_FLAGS=$lt_AR_FLAGS
++ case $host_os in
++ cygwin* | mingw* | pw32*)
++ # FIXME: the MSVC++ port hasn't been tested in a loooong time
++ # When not using gcc, we currently assume that we are using
++ # Microsoft Visual C++.
++ if test "$GCC" != yes; then
++ with_gnu_ld=no
++ fi
++ ;;
++ interix*)
++ # we just hope/assume this is gcc and not c89 (= MSVC++)
++ with_gnu_ld=yes
++ ;;
++ openbsd*)
++ with_gnu_ld=no
++ ;;
++ esac
+
+-# A C compiler.
+-LTCC=$lt_LTCC
++ _LT_TAGVAR(ld_shlibs, $1)=yes
++ if test "$with_gnu_ld" = yes; then
++ # If archive_cmds runs LD, not CC, wlarc should be empty
++ wlarc='${wl}'
+
+-# LTCC compiler flags.
+-LTCFLAGS=$lt_LTCFLAGS
++ # Set some defaults for GNU ld with shared library support. These
++ # are reset later if shared libraries are not supported. Putting them
++ # here allows them to be overridden if necessary.
++ runpath_var=LD_RUN_PATH
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
++ # ancient GNU ld didn't support --whole-archive et. al.
++ if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then
++ _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
++ else
++ _LT_TAGVAR(whole_archive_flag_spec, $1)=
++ fi
++ supports_anon_versioning=no
++ case `$LD -v 2>&1` in
++ *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11
++ *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
++ *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
++ *\ 2.11.*) ;; # other 2.11 versions
++ *) supports_anon_versioning=yes ;;
++ esac
+
+-# A language-specific compiler.
+-CC=$lt_[]_LT_AC_TAGVAR(compiler, $1)
++ # See if GNU ld supports shared libraries.
++ case $host_os in
++ aix[[3-9]]*)
++ # On AIX/PPC, the GNU linker is very broken
++ if test "$host_cpu" != ia64; then
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ cat <<_LT_EOF 1>&2
+
+-# Is the compiler the GNU C compiler?
+-with_gcc=$_LT_AC_TAGVAR(GCC, $1)
++*** Warning: the GNU linker, at least up to release 2.9.1, is reported
++*** to be unable to reliably create shared libraries on AIX.
++*** Therefore, libtool is disabling shared libraries support. If you
++*** really care for shared libraries, you may want to modify your PATH
++*** so that a non-GNU linker is found, and then restart.
+
+-# An ERE matcher.
+-EGREP=$lt_EGREP
++_LT_EOF
++ fi
++ ;;
+
+-# The linker used to build libraries.
+-LD=$lt_[]_LT_AC_TAGVAR(LD, $1)
++ amigaos*)
++ case $host_cpu in
++ powerpc)
++ # see comment about AmigaOS4 .so support
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)=''
++ ;;
++ m68k)
++ _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
++ _LT_TAGVAR(hardcode_minus_L, $1)=yes
++ ;;
++ esac
++ ;;
+
+-# Whether we need hard or soft links.
+-LN_S=$lt_LN_S
++ beos*)
++ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
++ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
++ # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
++ # support --undefined. This deserves some investigation. FIXME
++ _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
++ else
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ fi
++ ;;
+
+-# A BSD-compatible nm program.
+-NM=$lt_NM
++ cygwin* | mingw* | pw32*)
++ # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
++ # as there is no search path for DLLs.
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
++ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
++ _LT_TAGVAR(always_export_symbols, $1)=no
++ _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
++ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols'
+
+-# A symbol stripping program
+-STRIP=$lt_STRIP
++ if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
++ # If the export-symbols file already is a .def file (1st line
++ # is EXPORTS), use it as is; otherwise, prepend...
++ _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
++ cp $export_symbols $output_objdir/$soname.def;
++ else
++ echo EXPORTS > $output_objdir/$soname.def;
++ cat $export_symbols >> $output_objdir/$soname.def;
++ fi~
++ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
++ else
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ fi
++ ;;
+
+-# Used to examine libraries when file_magic_cmd begins "file"
+-MAGIC_CMD=$MAGIC_CMD
++ interix[[3-9]]*)
++ _LT_TAGVAR(hardcode_direct, $1)=no
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
++ # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
++ # Instead, shared libraries are loaded at an image base (0x10000000 by
++ # default) and relocated if they conflict, which is a slow very memory
++ # consuming and fragmenting process. To avoid this, we pick a random,
++ # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
++ # time. Moving up from 0x10000000 also allows more sbrk(2) space.
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
++ ;;
+
+-# Used on cygwin: DLL creation program.
+-DLLTOOL="$DLLTOOL"
++ gnu* | linux* | tpf* | k*bsd*-gnu)
++ tmp_diet=no
++ if test "$host_os" = linux-dietlibc; then
++ case $cc_basename in
++ diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn)
++ esac
++ fi
++ if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \
++ && test "$tmp_diet" = no
++ then
++ tmp_addflag=
++ tmp_sharedflag='-shared'
++ case $cc_basename,$host_cpu in
++ pgcc*) # Portland Group C compiler
++ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
++ tmp_addflag=' $pic_flag'
++ ;;
++ pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers
++ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
++ tmp_addflag=' $pic_flag -Mnomain' ;;
++ ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64
++ tmp_addflag=' -i_dynamic' ;;
++ efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64
++ tmp_addflag=' -i_dynamic -nofor_main' ;;
++ ifc* | ifort*) # Intel Fortran compiler
++ tmp_addflag=' -nofor_main' ;;
++ xl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below)
++ tmp_sharedflag='-qmkshrobj'
++ tmp_addflag= ;;
++ esac
++ case `$CC -V 2>&1 | sed 5q` in
++ *Sun\ C*) # Sun C 5.9
++ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
++ _LT_TAGVAR(compiler_needs_object, $1)=yes
++ tmp_sharedflag='-G' ;;
++ *Sun\ F*) # Sun Fortran 8.3
++ tmp_sharedflag='-G' ;;
++ esac
++ _LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+
+-# Used on cygwin: object dumper.
+-OBJDUMP="$OBJDUMP"
++ if test "x$supports_anon_versioning" = xyes; then
++ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
++ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
++ echo "local: *; };" >> $output_objdir/$libname.ver~
++ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
++ fi
+
+-# Used on cygwin: assembler.
+-AS="$AS"
++ case $cc_basename in
++ xlf*)
++ # IBM XL Fortran 10.1 on PPC cannot create shared libs itself
++ _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
++ _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir'
++ _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $compiler_flags -soname $soname -o $lib'
++ if test "x$supports_anon_versioning" = xyes; then
++ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
++ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
++ echo "local: *; };" >> $output_objdir/$libname.ver~
++ $LD -shared $libobjs $deplibs $compiler_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
++ fi
++ ;;
++ esac
++ else
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ fi
++ ;;
+
+-# The name of the directory that contains temporary libtool files.
+-objdir=$objdir
++ netbsd*)
++ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
++ _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
++ wlarc=
++ else
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
++ fi
++ ;;
+
+-# How to create reloadable object files.
+-reload_flag=$lt_reload_flag
+-reload_cmds=$lt_reload_cmds
++ solaris*)
++ if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ cat <<_LT_EOF 1>&2
+
+-# How to pass a linker flag through the compiler.
+-wl=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)
++*** Warning: The releases 2.8.* of the GNU linker cannot reliably
++*** create shared libraries on Solaris systems. Therefore, libtool
++*** is disabling shared libraries support. We urge you to upgrade GNU
++*** binutils to release 2.9.1 or newer. Another option is to modify
++*** your PATH or compiler configuration so that the native linker is
++*** used, and then restart.
+
+-# Object file suffix (normally "o").
+-objext="$ac_objext"
++_LT_EOF
++ elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
++ else
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ fi
++ ;;
+
+-# Old archive suffix (normally "a").
+-libext="$libext"
++ sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
++ case `$LD -v 2>&1` in
++ *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*)
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ cat <<_LT_EOF 1>&2
+
+-# Shared library suffix (normally ".so").
+-shrext_cmds='$shrext_cmds'
++*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
++*** reliably create shared libraries on SCO systems. Therefore, libtool
++*** is disabling shared libraries support. We urge you to upgrade GNU
++*** binutils to release 2.16.91.0.3 or newer. Another option is to modify
++*** your PATH or compiler configuration so that the native linker is
++*** used, and then restart.
+
+-# Executable file suffix (normally "").
+-exeext="$exeext"
++_LT_EOF
++ ;;
++ *)
++ # For security reasons, it is highly recommended that you always
++ # use absolute paths for naming shared libraries, and exclude the
++ # DT_RUNPATH tag from executables and libraries. But doing so
++ # requires that you compile everything twice, which is a pain.
++ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
++ else
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ fi
++ ;;
++ esac
++ ;;
+
+-# Additional compiler flags for building library objects.
+-pic_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)
+-pic_mode=$pic_mode
++ sunos4*)
++ _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
++ wlarc=
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ ;;
+
+-# What is the maximum length of a command?
+-max_cmd_len=$lt_cv_sys_max_cmd_len
++ *)
++ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
++ else
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ fi
++ ;;
++ esac
+
+-# Does compiler simultaneously support -c and -o options?
+-compiler_c_o=$lt_[]_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)
++ if test "$_LT_TAGVAR(ld_shlibs, $1)" = no; then
++ runpath_var=
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)=
++ _LT_TAGVAR(whole_archive_flag_spec, $1)=
++ fi
++ else
++ # PORTME fill in a description of your system's linker (not GNU ld)
++ case $host_os in
++ aix3*)
++ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
++ _LT_TAGVAR(always_export_symbols, $1)=yes
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
++ # Note: this linker hardcodes the directories in LIBPATH if there
++ # are no directories specified by -L.
++ _LT_TAGVAR(hardcode_minus_L, $1)=yes
++ if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
++ # Neither direct hardcoding nor static linking is supported with a
++ # broken collect2.
++ _LT_TAGVAR(hardcode_direct, $1)=unsupported
++ fi
++ ;;
+
+-# Must we lock files when doing compilation?
+-need_locks=$lt_need_locks
++ aix[[4-9]]*)
++ if test "$host_cpu" = ia64; then
++ # On IA64, the linker does run time linking by default, so we don't
++ # have to do anything special.
++ aix_use_runtimelinking=no
++ exp_sym_flag='-Bexport'
++ no_entry_flag=""
++ else
++ # If we're using GNU nm, then we don't want the "-C" option.
++ # -C means demangle to AIX nm, but means don't demangle with GNU nm
++ if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
++ _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
++ else
++ _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
++ fi
++ aix_use_runtimelinking=no
+
+-# Do we need the lib prefix for modules?
+-need_lib_prefix=$need_lib_prefix
++ # Test if we are trying to use run time linking or normal
++ # AIX style linking. If -brtl is somewhere in LDFLAGS, we
++ # need to do runtime linking.
++ case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
++ for ld_flag in $LDFLAGS; do
++ if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
++ aix_use_runtimelinking=yes
++ break
++ fi
++ done
++ ;;
++ esac
+
+-# Do we need a version for libraries?
+-need_version=$need_version
++ exp_sym_flag='-bexport'
++ no_entry_flag='-bnoentry'
++ fi
+
+-# Whether dlopen is supported.
+-dlopen_support=$enable_dlopen
++ # When large executables or shared objects are built, AIX ld can
++ # have problems creating the table of contents. If linking a library
++ # or program results in "error TOC overflow" add -mminimal-toc to
++ # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
++ # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+-# Whether dlopen of programs is supported.
+-dlopen_self=$enable_dlopen_self
++ _LT_TAGVAR(archive_cmds, $1)=''
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
++ _LT_TAGVAR(link_all_deplibs, $1)=yes
++ _LT_TAGVAR(file_list_spec, $1)='${wl}-f,'
+
+-# Whether dlopen of statically linked programs is supported.
+-dlopen_self_static=$enable_dlopen_self_static
++ if test "$GCC" = yes; then
++ case $host_os in aix4.[[012]]|aix4.[[012]].*)
++ # We only want to do this on AIX 4.2 and lower, the check
++ # below for broken collect2 doesn't work under 4.3+
++ collect2name=`${CC} -print-prog-name=collect2`
++ if test -f "$collect2name" &&
++ strings "$collect2name" | $GREP resolve_lib_name >/dev/null
++ then
++ # We have reworked collect2
++ :
++ else
++ # We have old collect2
++ _LT_TAGVAR(hardcode_direct, $1)=unsupported
++ # It fails to find uninstalled libraries when the uninstalled
++ # path is not listed in the libpath. Setting hardcode_minus_L
++ # to unsupported forces relinking
++ _LT_TAGVAR(hardcode_minus_L, $1)=yes
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=
++ fi
++ ;;
++ esac
++ shared_flag='-shared'
++ if test "$aix_use_runtimelinking" = yes; then
++ shared_flag="$shared_flag "'${wl}-G'
++ fi
++ else
++ # not using gcc
++ if test "$host_cpu" = ia64; then
++ # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
++ # chokes on -Wl,-G. The following line is correct:
++ shared_flag='-G'
++ else
++ if test "$aix_use_runtimelinking" = yes; then
++ shared_flag='${wl}-G'
++ else
++ shared_flag='${wl}-bM:SRE'
++ fi
++ fi
++ fi
+
+-# Compiler flag to prevent dynamic linking.
+-link_static_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_static, $1)
++ # It seems that -bexpall does not export symbols beginning with
++ # underscore (_), so it is better to generate a list of symbols to export.
++ _LT_TAGVAR(always_export_symbols, $1)=yes
++ if test "$aix_use_runtimelinking" = yes; then
++ # Warning - without using the other runtime loading flags (-brtl),
++ # -berok will link without error, but may produce a broken library.
++ _LT_TAGVAR(allow_undefined_flag, $1)='-berok'
++ # Determine the default libpath from the value encoded in an
++ # empty executable.
++ _LT_SYS_MODULE_PATH_AIX
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
++ else
++ if test "$host_cpu" = ia64; then
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
++ _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
++ _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
++ else
++ # Determine the default libpath from the value encoded in an
++ # empty executable.
++ _LT_SYS_MODULE_PATH_AIX
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
++ # Warning - without using the other run time loading flags,
++ # -berok will link without error, but may produce a broken library.
++ _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
++ _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
++ # Exported symbols can be pulled into shared objects from archives
++ _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
++ _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
++ # This is similar to how AIX traditionally builds its shared libraries.
++ _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
++ fi
++ fi
++ ;;
+
+-# Compiler flag to turn off builtin functions.
+-no_builtin_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)
++ amigaos*)
++ case $host_cpu in
++ powerpc)
++ # see comment about AmigaOS4 .so support
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)=''
++ ;;
++ m68k)
++ _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
++ _LT_TAGVAR(hardcode_minus_L, $1)=yes
++ ;;
++ esac
++ ;;
+
+-# Compiler flag to allow reflexive dlopens.
+-export_dynamic_flag_spec=$lt_[]_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)
++ bsdi[[45]]*)
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic
++ ;;
+
+-# Compiler flag to generate shared objects directly from archives.
+-whole_archive_flag_spec=$lt_[]_LT_AC_TAGVAR(whole_archive_flag_spec, $1)
++ cygwin* | mingw* | pw32*)
++ # When not using gcc, we currently assume that we are using
++ # Microsoft Visual C++.
++ # hardcode_libdir_flag_spec is actually meaningless, as there is
++ # no search path for DLLs.
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' '
++ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
++ # Tell ltmain to make .lib files, not .a files.
++ libext=lib
++ # Tell ltmain to make .dll files, not .so files.
++ shrext_cmds=".dll"
++ # FIXME: Setting linknames here is a bad hack.
++ _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `$ECHO "X$deplibs" | $Xsed -e '\''s/ -lc$//'\''` -link -dll~linknames='
++ # The linker will automatically build a .lib file if we build a DLL.
++ _LT_TAGVAR(old_archive_from_new_cmds, $1)='true'
++ # FIXME: Should let the user specify the lib program.
++ _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs'
++ _LT_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`'
++ _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
++ ;;
+
+-# Compiler flag to generate thread-safe objects.
+-thread_safe_flag_spec=$lt_[]_LT_AC_TAGVAR(thread_safe_flag_spec, $1)
++ darwin* | rhapsody*)
++ _LT_DARWIN_LINKER_FEATURES($1)
++ ;;
+
+-# Library versioning type.
+-version_type=$version_type
++ dgux*)
++ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ ;;
+
+-# Format of library name prefix.
+-libname_spec=$lt_libname_spec
++ freebsd1*)
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
+
+-# List of archive names. First name is the real one, the rest are links.
+-# The last name is the one that the linker finds with -lNAME.
+-library_names_spec=$lt_library_names_spec
++ # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
++ # support. Future versions do this automatically, but an explicit c++rt0.o
++ # does not break anything, and helps significantly (at the cost of a little
++ # extra space).
++ freebsd2.2*)
++ _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ ;;
+
+-# The coded name of the library, if different from the real name.
+-soname_spec=$lt_soname_spec
++ # Unfortunately, older versions of FreeBSD 2 do not have this feature.
++ freebsd2*)
++ _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_minus_L, $1)=yes
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ ;;
+
+-# Commands used to build and install an old-style archive.
+-RANLIB=$lt_RANLIB
+-old_archive_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_cmds, $1)
+-old_postinstall_cmds=$lt_old_postinstall_cmds
+-old_postuninstall_cmds=$lt_old_postuninstall_cmds
++ # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
++ freebsd* | dragonfly*)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ ;;
+
+-# Create an old-style archive from a shared archive.
+-old_archive_from_new_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_from_new_cmds, $1)
++ hpux9*)
++ if test "$GCC" = yes; then
++ _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
++ else
++ _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
++ fi
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
++ _LT_TAGVAR(hardcode_direct, $1)=yes
+
+-# Create a temporary old-style archive to link instead of a shared archive.
+-old_archive_from_expsyms_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1)
++ # hardcode_minus_L: Not really in the search PATH,
++ # but as the default location of the library.
++ _LT_TAGVAR(hardcode_minus_L, $1)=yes
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
++ ;;
+
+-# Commands used to build and install a shared archive.
+-archive_cmds=$lt_[]_LT_AC_TAGVAR(archive_cmds, $1)
+-archive_expsym_cmds=$lt_[]_LT_AC_TAGVAR(archive_expsym_cmds, $1)
+-postinstall_cmds=$lt_postinstall_cmds
+-postuninstall_cmds=$lt_postuninstall_cmds
++ hpux10*)
++ if test "$GCC" = yes -a "$with_gnu_ld" = no; then
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
++ else
++ _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
++ fi
++ if test "$with_gnu_ld" = no; then
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
++ _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
++ # hardcode_minus_L: Not really in the search PATH,
++ # but as the default location of the library.
++ _LT_TAGVAR(hardcode_minus_L, $1)=yes
++ fi
++ ;;
+
+-# Commands used to build a loadable module (assumed same as above if empty)
+-module_cmds=$lt_[]_LT_AC_TAGVAR(module_cmds, $1)
+-module_expsym_cmds=$lt_[]_LT_AC_TAGVAR(module_expsym_cmds, $1)
++ hpux11*)
++ if test "$GCC" = yes -a "$with_gnu_ld" = no; then
++ case $host_cpu in
++ hppa*64*)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
++ ;;
++ ia64*)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
++ ;;
++ *)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
++ ;;
++ esac
++ else
++ case $host_cpu in
++ hppa*64*)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
++ ;;
++ ia64*)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
++ ;;
++ *)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
++ ;;
++ esac
++ fi
++ if test "$with_gnu_ld" = no; then
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+-# Commands to strip libraries.
+-old_striplib=$lt_old_striplib
+-striplib=$lt_striplib
++ case $host_cpu in
++ hppa*64*|ia64*)
++ _LT_TAGVAR(hardcode_direct, $1)=no
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ ;;
++ *)
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+
+-# Dependencies to place before the objects being linked to create a
+-# shared library.
+-predep_objects=$lt_[]_LT_AC_TAGVAR(predep_objects, $1)
++ # hardcode_minus_L: Not really in the search PATH,
++ # but as the default location of the library.
++ _LT_TAGVAR(hardcode_minus_L, $1)=yes
++ ;;
++ esac
++ fi
++ ;;
+
+-# Dependencies to place after the objects being linked to create a
+-# shared library.
+-postdep_objects=$lt_[]_LT_AC_TAGVAR(postdep_objects, $1)
++ irix5* | irix6* | nonstopux*)
++ if test "$GCC" = yes; then
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
++ # Try to use the -exported_symbol ld option, if it does not
++ # work, assume that -exports_file does not work either and
++ # implicitly export all symbols.
++ save_LDFLAGS="$LDFLAGS"
++ LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null"
++ AC_LINK_IFELSE(int foo(void) {},
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib'
++ )
++ LDFLAGS="$save_LDFLAGS"
++ else
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib'
++ fi
++ _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
++ _LT_TAGVAR(inherit_rpath, $1)=yes
++ _LT_TAGVAR(link_all_deplibs, $1)=yes
++ ;;
+
+-# Dependencies to place before the objects being linked to create a
+-# shared library.
+-predeps=$lt_[]_LT_AC_TAGVAR(predeps, $1)
++ netbsd*)
++ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
++ _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out
++ else
++ _LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF
++ fi
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ ;;
+
+-# Dependencies to place after the objects being linked to create a
+-# shared library.
+-postdeps=$lt_[]_LT_AC_TAGVAR(postdeps, $1)
++ newsos6)
++ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ ;;
+
+-# The library search path used internally by the compiler when linking
+-# a shared library.
+-compiler_lib_search_path=$lt_[]_LT_AC_TAGVAR(compiler_lib_search_path, $1)
++ *nto* | *qnx*)
++ ;;
+
+-# Method to check whether dependent libraries are shared objects.
+-deplibs_check_method=$lt_deplibs_check_method
++ openbsd*)
++ if test -f /usr/libexec/ld.so; then
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
++ if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
++ else
++ case $host_os in
++ openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*)
++ _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
++ ;;
++ *)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
++ ;;
++ esac
++ fi
++ else
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ fi
++ ;;
+
+-# Command to use when deplibs_check_method == file_magic.
+-file_magic_cmd=$lt_file_magic_cmd
++ os2*)
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
++ _LT_TAGVAR(hardcode_minus_L, $1)=yes
++ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
++ _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$ECHO DATA >> $output_objdir/$libname.def~$ECHO " SINGLE NONSHARED" >> $output_objdir/$libname.def~$ECHO EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
++ _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
++ ;;
+
+-# Flag that allows shared libraries with undefined symbols to be built.
+-allow_undefined_flag=$lt_[]_LT_AC_TAGVAR(allow_undefined_flag, $1)
++ osf3*)
++ if test "$GCC" = yes; then
++ _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
++ else
++ _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
++ fi
++ _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
++ ;;
+
+-# Flag that forces no undefined symbols.
+-no_undefined_flag=$lt_[]_LT_AC_TAGVAR(no_undefined_flag, $1)
++ osf4* | osf5*) # as osf3* with the addition of -msym flag
++ if test "$GCC" = yes; then
++ _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
++ else
++ _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~
++ $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp'
+
+-# Commands used to finish a libtool library installation in a directory.
+-finish_cmds=$lt_finish_cmds
++ # Both c and cxx compiler support -rpath directly
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
++ fi
++ _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
++ ;;
+
+-# Same as above, but a single script fragment to be evaled but not shown.
+-finish_eval=$lt_finish_eval
++ solaris*)
++ _LT_TAGVAR(no_undefined_flag, $1)=' -z defs'
++ if test "$GCC" = yes; then
++ wlarc='${wl}'
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
++ $CC -shared ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
++ else
++ case `$CC -V 2>&1` in
++ *"Compilers 5.0"*)
++ wlarc=''
++ _LT_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
++ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
++ ;;
++ *)
++ wlarc='${wl}'
++ _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
++ $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
++ ;;
++ esac
++ fi
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ case $host_os in
++ solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
++ *)
++ # The compiler driver will combine and reorder linker options,
++ # but understands `-z linker_flag'. GCC discards it without `$wl',
++ # but is careful enough not to reorder.
++ # Supported since Solaris 2.6 (maybe 2.5.1?)
++ if test "$GCC" = yes; then
++ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
++ else
++ _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
++ fi
++ ;;
++ esac
++ _LT_TAGVAR(link_all_deplibs, $1)=yes
++ ;;
+
+-# Take the output of nm and produce a listing of raw symbols and C names.
+-global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
++ sunos4*)
++ if test "x$host_vendor" = xsequent; then
++ # Use $CC to link under sequent, because it throws in some extra .o
++ # files that make .init and .fini sections work.
++ _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
++ else
++ _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
++ fi
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_minus_L, $1)=yes
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ ;;
+
+-# Transform the output of nm in a proper C declaration
+-global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
++ sysv4)
++ case $host_vendor in
++ sni)
++ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
++ _LT_TAGVAR(hardcode_direct, $1)=yes # is this really true???
++ ;;
++ siemens)
++ ## LD is ld it makes a PLAMLIB
++ ## CC just makes a GrossModule.
++ _LT_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags'
++ _LT_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs'
++ _LT_TAGVAR(hardcode_direct, $1)=no
++ ;;
++ motorola)
++ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
++ _LT_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie
++ ;;
++ esac
++ runpath_var='LD_RUN_PATH'
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ ;;
+
+-# Transform the output of nm in a C name address pair
+-global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
++ sysv4.3*)
++ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport'
++ ;;
+
+-# This is the shared library runtime path variable.
+-runpath_var=$runpath_var
++ sysv4*MP*)
++ if test -d /usr/nec; then
++ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ runpath_var=LD_RUN_PATH
++ hardcode_runpath_var=yes
++ _LT_TAGVAR(ld_shlibs, $1)=yes
++ fi
++ ;;
+
+-# This is the shared library path variable.
+-shlibpath_var=$shlibpath_var
++ sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
++ _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
++ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ runpath_var='LD_RUN_PATH'
+
+-# Is shlibpath searched before the hard-coded library search path?
+-shlibpath_overrides_runpath=$shlibpath_overrides_runpath
++ if test "$GCC" = yes; then
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ else
++ _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ fi
++ ;;
+
+-# How to hardcode a shared library path into an executable.
+-hardcode_action=$_LT_AC_TAGVAR(hardcode_action, $1)
++ sysv5* | sco3.2v5* | sco5v6*)
++ # Note: We can NOT use -z defs as we might desire, because we do not
++ # link with -lc, and that would cause any symbols used from libc to
++ # always be unresolved, which means just about no library would
++ # ever link correctly. If we're not using GNU ld we use -z text
++ # though, which does catch some bad symbols but isn't as heavy-handed
++ # as -z defs.
++ _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
++ _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
++ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
++ _LT_TAGVAR(link_all_deplibs, $1)=yes
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
++ runpath_var='LD_RUN_PATH'
+
+-# Whether we should hardcode library paths into libraries.
+-hardcode_into_libs=$hardcode_into_libs
++ if test "$GCC" = yes; then
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ else
++ _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ fi
++ ;;
+
+-# Flag to hardcode \$libdir into a binary during linking.
+-# This must work even if \$libdir does not exist.
+-hardcode_libdir_flag_spec=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)
++ uts4*)
++ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ ;;
+
+-# If ld is used when linking, flag to hardcode \$libdir into
+-# a binary during linking. This must work even if \$libdir does
+-# not exist.
+-hardcode_libdir_flag_spec_ld=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)
++ *)
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++ esac
+
+-# Whether we need a single -rpath flag with a separated argument.
+-hardcode_libdir_separator=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_separator, $1)
++ if test x$host_vendor = xsni; then
++ case $host in
++ sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Blargedynsym'
++ ;;
++ esac
++ fi
++ fi
++])
++AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
++test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
+
+-# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the
+-# resulting binary.
+-hardcode_direct=$_LT_AC_TAGVAR(hardcode_direct, $1)
++_LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld
+
+-# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
+-# resulting binary.
+-hardcode_minus_L=$_LT_AC_TAGVAR(hardcode_minus_L, $1)
++_LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl
++_LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl
++_LT_DECL([], [extract_expsyms_cmds], [2],
++ [The commands to extract the exported symbol list from a shared archive])
+
+-# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
+-# the resulting binary.
+-hardcode_shlibpath_var=$_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)
++#
++# Do we need to explicitly link libc?
++#
++case "x$_LT_TAGVAR(archive_cmds_need_lc, $1)" in
++x|xyes)
++ # Assume -lc should be added
++ _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
+
+-# Set to yes if building a shared library automatically hardcodes DIR into the library
+-# and all subsequent libraries and executables linked against it.
+-hardcode_automatic=$_LT_AC_TAGVAR(hardcode_automatic, $1)
++ if test "$enable_shared" = yes && test "$GCC" = yes; then
++ case $_LT_TAGVAR(archive_cmds, $1) in
++ *'~'*)
++ # FIXME: we may have to deal with multi-command sequences.
++ ;;
++ '$CC '*)
++ # Test whether the compiler implicitly links with -lc since on some
++ # systems, -lgcc has to come before -lc. If gcc already passes -lc
++ # to ld, don't add -lc before -lgcc.
++ AC_MSG_CHECKING([whether -lc should be explicitly linked in])
++ $RM conftest*
++ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+-# Variables whose values should be saved in libtool wrapper scripts and
+-# restored at relink time.
+-variables_saved_for_relink="$variables_saved_for_relink"
++ if AC_TRY_EVAL(ac_compile) 2>conftest.err; then
++ soname=conftest
++ lib=conftest
++ libobjs=conftest.$ac_objext
++ deplibs=
++ wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1)
++ pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1)
++ compiler_flags=-v
++ linker_flags=-v
++ verstring=
++ output_objdir=.
++ libname=conftest
++ lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1)
++ _LT_TAGVAR(allow_undefined_flag, $1)=
++ if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1)
++ then
++ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
++ else
++ _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
++ fi
++ _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag
++ else
++ cat conftest.err 1>&5
++ fi
++ $RM conftest*
++ AC_MSG_RESULT([$_LT_TAGVAR(archive_cmds_need_lc, $1)])
++ ;;
++ esac
++ fi
++ ;;
++esac
+
+-# Whether libtool must link a program against all its dependency libraries.
+-link_all_deplibs=$_LT_AC_TAGVAR(link_all_deplibs, $1)
++_LT_TAGDECL([build_libtool_need_lc], [archive_cmds_need_lc], [0],
++ [Whether or not to add -lc for building shared libraries])
++_LT_TAGDECL([allow_libtool_libs_with_static_runtimes],
++ [enable_shared_with_static_runtimes], [0],
++ [Whether or not to disallow shared libs when runtime libs are static])
++_LT_TAGDECL([], [export_dynamic_flag_spec], [1],
++ [Compiler flag to allow reflexive dlopens])
++_LT_TAGDECL([], [whole_archive_flag_spec], [1],
++ [Compiler flag to generate shared objects directly from archives])
++_LT_TAGDECL([], [compiler_needs_object], [1],
++ [Whether the compiler copes with passing no objects directly])
++_LT_TAGDECL([], [old_archive_from_new_cmds], [2],
++ [Create an old-style archive from a shared archive])
++_LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2],
++ [Create a temporary old-style archive to link instead of a shared archive])
++_LT_TAGDECL([], [archive_cmds], [2], [Commands used to build a shared archive])
++_LT_TAGDECL([], [archive_expsym_cmds], [2])
++_LT_TAGDECL([], [module_cmds], [2],
++ [Commands used to build a loadable module if different from building
++ a shared archive.])
++_LT_TAGDECL([], [module_expsym_cmds], [2])
++_LT_TAGDECL([], [with_gnu_ld], [1],
++ [Whether we are building with GNU ld or not])
++_LT_TAGDECL([], [allow_undefined_flag], [1],
++ [Flag that allows shared libraries with undefined symbols to be built])
++_LT_TAGDECL([], [no_undefined_flag], [1],
++ [Flag that enforces no undefined symbols])
++_LT_TAGDECL([], [hardcode_libdir_flag_spec], [1],
++ [Flag to hardcode $libdir into a binary during linking.
++ This must work even if $libdir does not exist])
++_LT_TAGDECL([], [hardcode_libdir_flag_spec_ld], [1],
++ [[If ld is used when linking, flag to hardcode $libdir into a binary
++ during linking. This must work even if $libdir does not exist]])
++_LT_TAGDECL([], [hardcode_libdir_separator], [1],
++ [Whether we need a single "-rpath" flag with a separated argument])
++_LT_TAGDECL([], [hardcode_direct], [0],
++ [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes
++ DIR into the resulting binary])
++_LT_TAGDECL([], [hardcode_direct_absolute], [0],
++ [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes
++ DIR into the resulting binary and the resulting library dependency is
++ "absolute", i.e impossible to change by setting ${shlibpath_var} if the
++ library is relocated])
++_LT_TAGDECL([], [hardcode_minus_L], [0],
++ [Set to "yes" if using the -LDIR flag during linking hardcodes DIR
++ into the resulting binary])
++_LT_TAGDECL([], [hardcode_shlibpath_var], [0],
++ [Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR
++ into the resulting binary])
++_LT_TAGDECL([], [hardcode_automatic], [0],
++ [Set to "yes" if building a shared library automatically hardcodes DIR
++ into the library and all subsequent libraries and executables linked
++ against it])
++_LT_TAGDECL([], [inherit_rpath], [0],
++ [Set to yes if linker adds runtime paths of dependent libraries
++ to runtime path list])
++_LT_TAGDECL([], [link_all_deplibs], [0],
++ [Whether libtool must link a program against all its dependency libraries])
++_LT_TAGDECL([], [fix_srcfile_path], [1],
++ [Fix the shell variable $srcfile for the compiler])
++_LT_TAGDECL([], [always_export_symbols], [0],
++ [Set to "yes" if exported symbols are required])
++_LT_TAGDECL([], [export_symbols_cmds], [2],
++ [The commands to list exported symbols])
++_LT_TAGDECL([], [exclude_expsyms], [1],
++ [Symbols that should not be listed in the preloaded symbols])
++_LT_TAGDECL([], [include_expsyms], [1],
++ [Symbols that must always be exported])
++_LT_TAGDECL([], [prelink_cmds], [2],
++ [Commands necessary for linking programs (against libraries) with templates])
++_LT_TAGDECL([], [file_list_spec], [1],
++ [Specify filename containing input files])
++dnl FIXME: Not yet implemented
++dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1],
++dnl [Compiler flag to generate thread safe objects])
++])# _LT_LINKER_SHLIBS
+
+-# Compile-time system search path for libraries
+-sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
+
+-# Run-time system search path for libraries
+-sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
++# _LT_LANG_C_CONFIG([TAG])
++# ------------------------
++# Ensure that the configuration variables for a C compiler are suitably
++# defined. These variables are subsequently used by _LT_CONFIG to write
++# the compiler configuration to `libtool'.
++m4_defun([_LT_LANG_C_CONFIG],
++[m4_require([_LT_DECL_EGREP])dnl
++lt_save_CC="$CC"
++AC_LANG_PUSH(C)
+
+-# Fix the shell variable \$srcfile for the compiler.
+-fix_srcfile_path="$_LT_AC_TAGVAR(fix_srcfile_path, $1)"
++# Source file extension for C test sources.
++ac_ext=c
+
+-# Set to yes if exported symbols are required.
+-always_export_symbols=$_LT_AC_TAGVAR(always_export_symbols, $1)
++# Object file extension for compiled C test sources.
++objext=o
++_LT_TAGVAR(objext, $1)=$objext
+
+-# The commands to list exported symbols.
+-export_symbols_cmds=$lt_[]_LT_AC_TAGVAR(export_symbols_cmds, $1)
++# Code to be used in simple compile tests
++lt_simple_compile_test_code="int some_variable = 0;"
+
+-# The commands to extract the exported symbol list from a shared archive.
+-extract_expsyms_cmds=$lt_extract_expsyms_cmds
++# Code to be used in simple link tests
++lt_simple_link_test_code='int main(){return(0);}'
+
+-# Symbols that should not be listed in the preloaded symbols.
+-exclude_expsyms=$lt_[]_LT_AC_TAGVAR(exclude_expsyms, $1)
++_LT_TAG_COMPILER
++# Save the default compiler, since it gets overwritten when the other
++# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP.
++compiler_DEFAULT=$CC
+
+-# Symbols that must always be exported.
+-include_expsyms=$lt_[]_LT_AC_TAGVAR(include_expsyms, $1)
++# save warnings/boilerplate of simple test code
++_LT_COMPILER_BOILERPLATE
++_LT_LINKER_BOILERPLATE
+
+-ifelse([$1],[],
+-[# ### END LIBTOOL CONFIG],
+-[# ### END LIBTOOL TAG CONFIG: $tagname])
++## CAVEAT EMPTOR:
++## There is no encapsulation within the following macros, do not change
++## the running order or otherwise move them around unless you know exactly
++## what you are doing...
++if test -n "$compiler"; then
++ _LT_COMPILER_NO_RTTI($1)
++ _LT_COMPILER_PIC($1)
++ _LT_COMPILER_C_O($1)
++ _LT_COMPILER_FILE_LOCKS($1)
++ _LT_LINKER_SHLIBS($1)
++ _LT_SYS_DYNAMIC_LINKER($1)
++ _LT_LINKER_HARDCODE_LIBPATH($1)
++ LT_SYS_DLOPEN_SELF
++ _LT_CMD_STRIPLIB
++
++ # Report which library types will actually be built
++ AC_MSG_CHECKING([if libtool supports shared libraries])
++ AC_MSG_RESULT([$can_build_shared])
+
+-__EOF__
++ AC_MSG_CHECKING([whether to build shared libraries])
++ test "$can_build_shared" = "no" && enable_shared=no
+
+-ifelse([$1],[], [
++ # On AIX, shared libraries and static libraries use the same namespace, and
++ # are all built from PIC.
+ case $host_os in
+ aix3*)
+- cat <<\EOF >> "$cfgfile"
++ test "$enable_shared" = yes && enable_static=no
++ if test -n "$RANLIB"; then
++ archive_cmds="$archive_cmds~\$RANLIB \$lib"
++ postinstall_cmds='$RANLIB $lib'
++ fi
++ ;;
+
+-# AIX sometimes has problems with the GCC collect2 program. For some
+-# reason, if we set the COLLECT_NAMES environment variable, the problems
+-# vanish in a puff of smoke.
+-if test "X${COLLECT_NAMES+set}" != Xset; then
+- COLLECT_NAMES=
+- export COLLECT_NAMES
+-fi
+-EOF
++ aix[[4-9]]*)
++ if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
++ test "$enable_shared" = yes && enable_static=no
++ fi
+ ;;
+ esac
++ AC_MSG_RESULT([$enable_shared])
+
+- # We use sed instead of cat because bash on DJGPP gets confused if
+- # if finds mixed CR/LF and LF-only lines. Since sed operates in
+- # text mode, it properly converts lines to CR/LF. This bash problem
+- # is reportedly fixed, but why not run on old versions too?
+- sed '$q' "$ltmain" >> "$cfgfile" || (rm -f "$cfgfile"; exit 1)
++ AC_MSG_CHECKING([whether to build static libraries])
++ # Make sure either enable_shared or enable_static is yes.
++ test "$enable_shared" = yes || enable_static=yes
++ AC_MSG_RESULT([$enable_static])
+
+- mv -f "$cfgfile" "$ofile" || \
+- (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
+- chmod +x "$ofile"
+-])
+-else
+- # If there is no Makefile yet, we rely on a make rule to execute
+- # `config.status --recheck' to rerun these tests and create the
+- # libtool script then.
+- ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'`
+- if test -f "$ltmain_in"; then
+- test -f Makefile && make "$ltmain"
+- fi
++ _LT_CONFIG($1)
+ fi
+-])# AC_LIBTOOL_CONFIG
+-
+-
+-# AC_LIBTOOL_PROG_COMPILER_NO_RTTI([TAGNAME])
+-# -------------------------------------------
+-AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI],
+-[AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl
+-
+-_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
++AC_LANG_POP
++CC="$lt_save_CC"
++])# _LT_LANG_C_CONFIG
+
+-if test "$GCC" = yes; then
+- _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
+
+- AC_LIBTOOL_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions],
+- lt_cv_prog_compiler_rtti_exceptions,
+- [-fno-rtti -fno-exceptions], [],
+- [_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"])
++# _LT_PROG_CXX
++# ------------
++# Since AC_PROG_CXX is broken, in that it returns g++ if there is no c++
++# compiler, we have our own version here.
++m4_defun([_LT_PROG_CXX],
++[
++pushdef([AC_MSG_ERROR], [_lt_caught_CXX_error=yes])
++AC_PROG_CXX
++if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
++ ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
++ (test "X$CXX" != "Xg++"))) ; then
++ AC_PROG_CXXCPP
++else
++ _lt_caught_CXX_error=yes
+ fi
+-])# AC_LIBTOOL_PROG_COMPILER_NO_RTTI
++popdef([AC_MSG_ERROR])
++])# _LT_PROG_CXX
+
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([_LT_PROG_CXX], [])
+
+-# AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE
+-# ---------------------------------
+-AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE],
+-[AC_REQUIRE([AC_CANONICAL_HOST])
+-AC_REQUIRE([AC_PROG_NM])
+-AC_REQUIRE([AC_OBJEXT])
+-# Check for command to grab the raw symbol name followed by C symbol from nm.
+-AC_MSG_CHECKING([command to parse $NM output from $compiler object])
+-AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe],
+-[
+-# These are sane defaults that work on at least a few old systems.
+-# [They come from Ultrix. What could be older than Ultrix?!! ;)]
+-
+-# Character class describing NM global symbol codes.
+-symcode='[[BCDEGRST]]'
+
+-# Regexp to match symbols that can be accessed directly from C.
+-sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)'
++# _LT_LANG_CXX_CONFIG([TAG])
++# --------------------------
++# Ensure that the configuration variables for a C++ compiler are suitably
++# defined. These variables are subsequently used by _LT_CONFIG to write
++# the compiler configuration to `libtool'.
++m4_defun([_LT_LANG_CXX_CONFIG],
++[AC_REQUIRE([_LT_PROG_CXX])dnl
++m4_require([_LT_FILEUTILS_DEFAULTS])dnl
++m4_require([_LT_DECL_EGREP])dnl
++
++AC_LANG_PUSH(C++)
++_LT_TAGVAR(archive_cmds_need_lc, $1)=no
++_LT_TAGVAR(allow_undefined_flag, $1)=
++_LT_TAGVAR(always_export_symbols, $1)=no
++_LT_TAGVAR(archive_expsym_cmds, $1)=
++_LT_TAGVAR(compiler_needs_object, $1)=no
++_LT_TAGVAR(export_dynamic_flag_spec, $1)=
++_LT_TAGVAR(hardcode_direct, $1)=no
++_LT_TAGVAR(hardcode_direct_absolute, $1)=no
++_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
++_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
++_LT_TAGVAR(hardcode_libdir_separator, $1)=
++_LT_TAGVAR(hardcode_minus_L, $1)=no
++_LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
++_LT_TAGVAR(hardcode_automatic, $1)=no
++_LT_TAGVAR(inherit_rpath, $1)=no
++_LT_TAGVAR(module_cmds, $1)=
++_LT_TAGVAR(module_expsym_cmds, $1)=
++_LT_TAGVAR(link_all_deplibs, $1)=unknown
++_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
++_LT_TAGVAR(no_undefined_flag, $1)=
++_LT_TAGVAR(whole_archive_flag_spec, $1)=
++_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+
+-# Transform an extracted symbol line into a proper C declaration
+-lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern int \1;/p'"
++# Source file extension for C++ test sources.
++ac_ext=cpp
+
+-# Transform an extracted symbol line into symbol name and symbol address
+-lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'"
++# Object file extension for compiled C++ test sources.
++objext=o
++_LT_TAGVAR(objext, $1)=$objext
+
+-# Define system-specific variables.
+-case $host_os in
+-aix*)
+- symcode='[[BCDT]]'
+- ;;
+-cygwin* | mingw* | pw32*)
+- symcode='[[ABCDGISTW]]'
+- ;;
+-hpux*) # Its linker distinguishes data from code symbols
+- if test "$host_cpu" = ia64; then
+- symcode='[[ABCDEGRST]]'
++# No sense in running all these tests if we already determined that
++# the CXX compiler isn't working. Some variables (like enable_shared)
++# are currently assumed to apply to all compilers on this platform,
++# and will be corrupted by setting them based on a non-working compiler.
++if test "$_lt_caught_CXX_error" != yes; then
++ # Code to be used in simple compile tests
++ lt_simple_compile_test_code="int some_variable = 0;"
++
++ # Code to be used in simple link tests
++ lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }'
++
++ # ltmain only uses $CC for tagged configurations so make sure $CC is set.
++ _LT_TAG_COMPILER
++
++ # save warnings/boilerplate of simple test code
++ _LT_COMPILER_BOILERPLATE
++ _LT_LINKER_BOILERPLATE
++
++ # Allow CC to be a program name with arguments.
++ lt_save_CC=$CC
++ lt_save_LD=$LD
++ lt_save_GCC=$GCC
++ GCC=$GXX
++ lt_save_with_gnu_ld=$with_gnu_ld
++ lt_save_path_LD=$lt_cv_path_LD
++ if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then
++ lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx
++ else
++ $as_unset lt_cv_prog_gnu_ld
+ fi
+- lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
+- lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'"
+- ;;
+-linux*)
+- if test "$host_cpu" = ia64; then
+- symcode='[[ABCDGIRSTW]]'
+- lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
+- lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'"
++ if test -n "${lt_cv_path_LDCXX+set}"; then
++ lt_cv_path_LD=$lt_cv_path_LDCXX
++ else
++ $as_unset lt_cv_path_LD
+ fi
+- ;;
+-irix* | nonstopux*)
+- symcode='[[BCDEGRST]]'
+- ;;
+-osf*)
+- symcode='[[BCDEGQRST]]'
+- ;;
+-solaris*)
+- symcode='[[BDRT]]'
+- ;;
+-sco3.2v5*)
+- symcode='[[DT]]'
+- ;;
+-sysv4.2uw2*)
+- symcode='[[DT]]'
+- ;;
+-sysv5* | sco5v6* | unixware* | OpenUNIX*)
+- symcode='[[ABDT]]'
+- ;;
+-sysv4)
+- symcode='[[DFNSTU]]'
+- ;;
+-esac
+-
+-# Handle CRLF in mingw tool chain
+-opt_cr=
+-case $build_os in
+-mingw*)
+- opt_cr=`echo 'x\{0,1\}' | tr x '\015'` # option cr in regexp
+- ;;
+-esac
+-
+-# If we're using GNU nm, then use its standard symbol codes.
+-case `$NM -V 2>&1` in
+-*GNU* | *'with BFD'*)
+- symcode='[[ABCDGIRSTW]]' ;;
+-esac
+-
+-# Try without a prefix undercore, then with it.
+-for ac_symprfx in "" "_"; do
+-
+- # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
+- symxfrm="\\1 $ac_symprfx\\2 \\2"
+-
+- # Write the raw and C identifiers.
+- lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
+-
+- # Check to see that the pipe works correctly.
+- pipe_works=no
+-
+- rm -f conftest*
+- cat > conftest.$ac_ext <<EOF
+-#ifdef __cplusplus
+-extern "C" {
+-#endif
+-char nm_test_var;
+-void nm_test_func(){}
+-#ifdef __cplusplus
+-}
+-#endif
+-int main(){nm_test_var='a';nm_test_func();return(0);}
+-EOF
+-
+- if AC_TRY_EVAL(ac_compile); then
+- # Now try to grab the symbols.
+- nlist=conftest.nm
+- if AC_TRY_EVAL(NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) && test -s "$nlist"; then
+- # Try sorting and uniquifying the output.
+- if sort "$nlist" | uniq > "$nlist"T; then
+- mv -f "$nlist"T "$nlist"
+- else
+- rm -f "$nlist"T
+- fi
+-
+- # Make sure that we snagged all the symbols we need.
+- if grep ' nm_test_var$' "$nlist" >/dev/null; then
+- if grep ' nm_test_func$' "$nlist" >/dev/null; then
+- cat <<EOF > conftest.$ac_ext
+-#ifdef __cplusplus
+-extern "C" {
+-#endif
+-
+-EOF
+- # Now generate the symbol file.
+- eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | grep -v main >> conftest.$ac_ext'
+-
+- cat <<EOF >> conftest.$ac_ext
+-#if defined (__STDC__) && __STDC__
+-# define lt_ptr_t void *
+-#else
+-# define lt_ptr_t char *
+-# define const
+-#endif
+-
+-/* The mapping between symbol names and symbols. */
+-const struct {
+- const char *name;
+- lt_ptr_t address;
+-}
+-lt_preloaded_symbols[[]] =
+-{
+-EOF
+- $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (lt_ptr_t) \&\2},/" < "$nlist" | grep -v main >> conftest.$ac_ext
+- cat <<\EOF >> conftest.$ac_ext
+- {0, (lt_ptr_t) 0}
+-};
++ test -z "${LDCXX+set}" || LD=$LDCXX
++ CC=${CXX-"c++"}
++ compiler=$CC
++ _LT_TAGVAR(compiler, $1)=$CC
++ _LT_CC_BASENAME([$compiler])
+
+-#ifdef __cplusplus
+-}
+-#endif
+-EOF
+- # Now try linking the two files.
+- mv conftest.$ac_objext conftstm.$ac_objext
+- lt_save_LIBS="$LIBS"
+- lt_save_CFLAGS="$CFLAGS"
+- LIBS="conftstm.$ac_objext"
+- CFLAGS="$CFLAGS$_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)"
+- if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then
+- pipe_works=yes
+- fi
+- LIBS="$lt_save_LIBS"
+- CFLAGS="$lt_save_CFLAGS"
+- else
+- echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD
+- fi
+- else
+- echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD
+- fi
++ if test -n "$compiler"; then
++ # We don't want -fno-exception when compiling C++ code, so set the
++ # no_builtin_flag separately
++ if test "$GXX" = yes; then
++ _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
+ else
+- echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD
++ _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
+ fi
+- else
+- echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD
+- cat conftest.$ac_ext >&5
+- fi
+- rm -f conftest* conftst*
+-
+- # Do not use the global_symbol_pipe unless it works.
+- if test "$pipe_works" = yes; then
+- break
+- else
+- lt_cv_sys_global_symbol_pipe=
+- fi
+-done
+-])
+-if test -z "$lt_cv_sys_global_symbol_pipe"; then
+- lt_cv_sys_global_symbol_to_cdecl=
+-fi
+-if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
+- AC_MSG_RESULT(failed)
+-else
+- AC_MSG_RESULT(ok)
+-fi
+-]) # AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE
+
++ if test "$GXX" = yes; then
++ # Set up default GNU C++ configuration
+
+-# AC_LIBTOOL_PROG_COMPILER_PIC([TAGNAME])
+-# ---------------------------------------
+-AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC],
+-[_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)=
+-_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
+-_LT_AC_TAGVAR(lt_prog_compiler_static, $1)=
++ LT_PATH_LD
+
+-AC_MSG_CHECKING([for $compiler option to produce PIC])
+- ifelse([$1],[CXX],[
+- # C++ specific cases for pic, static, wl, etc.
+- if test "$GXX" = yes; then
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
++ # Check if GNU C++ uses GNU ld as the underlying linker, since the
++ # archiving commands below assume that GNU ld is being used.
++ if test "$with_gnu_ld" = yes; then
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
++
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
++
++ # If archive_cmds runs LD, not CC, wlarc should be empty
++ # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
++ # investigate it a little bit more. (MM)
++ wlarc='${wl}'
++
++ # ancient GNU ld didn't support --whole-archive et. al.
++ if eval "`$CC -print-prog-name=ld` --help 2>&1" |
++ $GREP 'no-whole-archive' > /dev/null; then
++ _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
++ else
++ _LT_TAGVAR(whole_archive_flag_spec, $1)=
++ fi
++ else
++ with_gnu_ld=no
++ wlarc=
+
+- case $host_os in
+- aix*)
+- # All AIX code is PIC.
+- if test "$host_cpu" = ia64; then
+- # AIX 5 now supports IA64 processor
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- fi
+- ;;
+- amigaos*)
+- # FIXME: we need at least 68020 code to build shared libraries, but
+- # adding the `-m68020' flag to GCC prevents building anything better,
+- # like `-m68040'.
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
+- ;;
+- beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+- # PIC is the default for these OSes.
+- ;;
+- mingw* | cygwin* | os2* | pw32*)
+- # This hack is so that the source file can tell whether it is being
+- # built for inclusion in a dll (and should export symbols for example).
+- # Although the cygwin gcc ignores -fPIC, still need this for old-style
+- # (--disable-auto-import) libraries
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'
+- ;;
+- darwin* | rhapsody*)
+- # PIC is the default on this platform
+- # Common symbols not allowed in MH_DYLIB files
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
+- ;;
+- *djgpp*)
+- # DJGPP does not support shared libraries at all
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
+- ;;
+- interix3*)
+- # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+- # Instead, we relocate shared libraries at runtime.
+- ;;
+- sysv4*MP*)
+- if test -d /usr/nec; then
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
++ # A generic and very simple default shared library creation
++ # command for GNU C++ for the case where it uses the native
++ # linker, instead of GNU ld. If possible, this setting should
++ # overridden to take advantage of the native linker features on
++ # the platform it is being used on.
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+ fi
+- ;;
+- hpux*)
+- # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+- # not for PA HP-UX.
+- case $host_cpu in
+- hppa*64*|ia64*)
+- ;;
+- *)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+- ;;
+- esac
+- ;;
+- *)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+- ;;
+- esac
+- else
++
++ # Commands to make compiler produce verbose output that lists
++ # what "hidden" libraries, object files and flags are used when
++ # linking a shared library.
++ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
++
++ else
++ GXX=no
++ with_gnu_ld=no
++ wlarc=
++ fi
++
++ # PORTME: fill in a description of your system's C++ link characteristics
++ AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
++ _LT_TAGVAR(ld_shlibs, $1)=yes
+ case $host_os in
+- aix4* | aix5*)
+- # All AIX code is PIC.
+- if test "$host_cpu" = ia64; then
+- # AIX 5 now supports IA64 processor
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ aix3*)
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++ aix[[4-9]]*)
++ if test "$host_cpu" = ia64; then
++ # On IA64, the linker does run time linking by default, so we don't
++ # have to do anything special.
++ aix_use_runtimelinking=no
++ exp_sym_flag='-Bexport'
++ no_entry_flag=""
++ else
++ aix_use_runtimelinking=no
++
++ # Test if we are trying to use run time linking or normal
++ # AIX style linking. If -brtl is somewhere in LDFLAGS, we
++ # need to do runtime linking.
++ case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
++ for ld_flag in $LDFLAGS; do
++ case $ld_flag in
++ *-brtl*)
++ aix_use_runtimelinking=yes
++ break
++ ;;
++ esac
++ done
++ ;;
++ esac
++
++ exp_sym_flag='-bexport'
++ no_entry_flag='-bnoentry'
++ fi
++
++ # When large executables or shared objects are built, AIX ld can
++ # have problems creating the table of contents. If linking a library
++ # or program results in "error TOC overflow" add -mminimal-toc to
++ # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
++ # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
++
++ _LT_TAGVAR(archive_cmds, $1)=''
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
++ _LT_TAGVAR(link_all_deplibs, $1)=yes
++ _LT_TAGVAR(file_list_spec, $1)='${wl}-f,'
++
++ if test "$GXX" = yes; then
++ case $host_os in aix4.[[012]]|aix4.[[012]].*)
++ # We only want to do this on AIX 4.2 and lower, the check
++ # below for broken collect2 doesn't work under 4.3+
++ collect2name=`${CC} -print-prog-name=collect2`
++ if test -f "$collect2name" &&
++ strings "$collect2name" | $GREP resolve_lib_name >/dev/null
++ then
++ # We have reworked collect2
++ :
++ else
++ # We have old collect2
++ _LT_TAGVAR(hardcode_direct, $1)=unsupported
++ # It fails to find uninstalled libraries when the uninstalled
++ # path is not listed in the libpath. Setting hardcode_minus_L
++ # to unsupported forces relinking
++ _LT_TAGVAR(hardcode_minus_L, $1)=yes
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=
++ fi
++ esac
++ shared_flag='-shared'
++ if test "$aix_use_runtimelinking" = yes; then
++ shared_flag="$shared_flag "'${wl}-G'
++ fi
++ else
++ # not using gcc
++ if test "$host_cpu" = ia64; then
++ # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
++ # chokes on -Wl,-G. The following line is correct:
++ shared_flag='-G'
++ else
++ if test "$aix_use_runtimelinking" = yes; then
++ shared_flag='${wl}-G'
++ else
++ shared_flag='${wl}-bM:SRE'
++ fi
++ fi
++ fi
++
++ # It seems that -bexpall does not export symbols beginning with
++ # underscore (_), so it is better to generate a list of symbols to
++ # export.
++ _LT_TAGVAR(always_export_symbols, $1)=yes
++ if test "$aix_use_runtimelinking" = yes; then
++ # Warning - without using the other runtime loading flags (-brtl),
++ # -berok will link without error, but may produce a broken library.
++ _LT_TAGVAR(allow_undefined_flag, $1)='-berok'
++ # Determine the default libpath from the value encoded in an empty
++ # executable.
++ _LT_SYS_MODULE_PATH_AIX
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
++
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
++ else
++ if test "$host_cpu" = ia64; then
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
++ _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
++ _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
++ else
++ # Determine the default libpath from the value encoded in an
++ # empty executable.
++ _LT_SYS_MODULE_PATH_AIX
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
++ # Warning - without using the other run time loading flags,
++ # -berok will link without error, but may produce a broken library.
++ _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
++ _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
++ # Exported symbols can be pulled into shared objects from archives
++ _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
++ _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
++ # This is similar to how AIX traditionally builds its shared
++ # libraries.
++ _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
++ fi
++ fi
++ ;;
++
++ beos*)
++ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
++ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
++ # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
++ # support --undefined. This deserves some investigation. FIXME
++ _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ else
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
++ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
++
+ chorus*)
+- case $cc_basename in
+- cxch68*)
+- # Green Hills C++ Compiler
+- # _LT_AC_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a"
++ case $cc_basename in
++ *)
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+- esac
++ esac
++ ;;
++
++ cygwin* | mingw* | pw32*)
++ # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
++ # as there is no search path for DLLs.
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
++ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
++ _LT_TAGVAR(always_export_symbols, $1)=no
++ _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
++
++ if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
++ # If the export-symbols file already is a .def file (1st line
++ # is EXPORTS), use it as is; otherwise, prepend...
++ _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
++ cp $export_symbols $output_objdir/$soname.def;
++ else
++ echo EXPORTS > $output_objdir/$soname.def;
++ cat $export_symbols >> $output_objdir/$soname.def;
++ fi~
++ $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
++ else
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ fi
++ ;;
++ darwin* | rhapsody*)
++ _LT_DARWIN_LINKER_FEATURES($1)
+ ;;
+- darwin*)
+- # PIC is the default on this platform
+- # Common symbols not allowed in MH_DYLIB files
+- case $cc_basename in
+- xlc*)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-qnocommon'
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- ;;
+- esac
+- ;;
++
+ dgux*)
+- case $cc_basename in
+- ec++*)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ case $cc_basename in
++ ec++*)
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+- ghcx*)
++ ghcx*)
+ # Green Hills C++ Compiler
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+- *)
++ *)
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+- esac
+- ;;
+- freebsd* | kfreebsd*-gnu | dragonfly*)
+- # FreeBSD uses GNU C++
+- ;;
+- hpux9* | hpux10* | hpux11*)
+- case $cc_basename in
+- CC*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+- if test "$host_cpu" != ia64; then
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
+- fi
++ esac
++ ;;
++
++ freebsd[[12]]*)
++ # C++ shared libraries reported to be fairly broken before
++ # switch to ELF
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++
++ freebsd-elf*)
++ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
++ ;;
++
++ freebsd* | dragonfly*)
++ # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
++ # conventions
++ _LT_TAGVAR(ld_shlibs, $1)=yes
++ ;;
++
++ gnu*)
++ ;;
++
++ hpux9*)
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
++ # but as the default
++ # location of the library.
++
++ case $cc_basename in
++ CC*)
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++ aCC*)
++ _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
++ # Commands to make compiler produce verbose output that lists
++ # what "hidden" libraries, object files and flags are used when
++ # linking a shared library.
++ #
++ # There doesn't appear to be a way to prevent this compiler from
++ # explicitly linking system object files so we need to strip them
++ # from the output so that they don't get included in the library
++ # dependencies.
++ output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
++ ;;
++ *)
++ if test "$GXX" = yes; then
++ _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
++ else
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ fi
++ ;;
++ esac
++ ;;
++
++ hpux10*|hpux11*)
++ if test $with_gnu_ld = no; then
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
++
++ case $host_cpu in
++ hppa*64*|ia64*)
++ ;;
++ *)
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
++ ;;
++ esac
++ fi
++ case $host_cpu in
++ hppa*64*|ia64*)
++ _LT_TAGVAR(hardcode_direct, $1)=no
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ ;;
++ *)
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
++ _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
++ # but as the default
++ # location of the library.
++ ;;
++ esac
++
++ case $cc_basename in
++ CC*)
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+- aCC*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
++ aCC*)
+ case $host_cpu in
+- hppa*64*|ia64*)
+- # +Z the default
+- ;;
+- *)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
+- ;;
++ hppa*64*)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
++ ;;
++ ia64*)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
++ ;;
++ *)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
++ ;;
+ esac
++ # Commands to make compiler produce verbose output that lists
++ # what "hidden" libraries, object files and flags are used when
++ # linking a shared library.
++ #
++ # There doesn't appear to be a way to prevent this compiler from
++ # explicitly linking system object files so we need to strip them
++ # from the output so that they don't get included in the library
++ # dependencies.
++ output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
+ ;;
+- *)
++ *)
++ if test "$GXX" = yes; then
++ if test $with_gnu_ld = no; then
++ case $host_cpu in
++ hppa*64*)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
++ ;;
++ ia64*)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
++ ;;
++ *)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
++ ;;
++ esac
++ fi
++ else
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ fi
+ ;;
+- esac
+- ;;
+- interix*)
+- # This is c89, which is MS Visual C++ (no shared libs)
+- # Anyone wants to do a port?
+- ;;
+- irix5* | irix6* | nonstopux*)
+- case $cc_basename in
+- CC*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+- # CC pic flag -KPIC is the default.
++ esac
++ ;;
++
++ interix[[3-9]]*)
++ _LT_TAGVAR(hardcode_direct, $1)=no
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
++ # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
++ # Instead, shared libraries are loaded at an image base (0x10000000 by
++ # default) and relocated if they conflict, which is a slow very memory
++ # consuming and fragmenting process. To avoid this, we pick a random,
++ # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
++ # time. Moving up from 0x10000000 also allows more sbrk(2) space.
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
++ ;;
++ irix5* | irix6*)
++ case $cc_basename in
++ CC*)
++ # SGI C++
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
++
++ # Archives containing C++ object files must be created using
++ # "CC -ar", where "CC" is the IRIX C++ compiler. This is
++ # necessary to make sure instantiated templates are included
++ # in the archive.
++ _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs'
+ ;;
+- *)
++ *)
++ if test "$GXX" = yes; then
++ if test "$with_gnu_ld" = no; then
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
++ else
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` -o $lib'
++ fi
++ fi
++ _LT_TAGVAR(link_all_deplibs, $1)=yes
+ ;;
+- esac
+- ;;
+- linux*)
+- case $cc_basename in
+- KCC*)
+- # KAI C++ Compiler
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
++ esac
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
++ _LT_TAGVAR(inherit_rpath, $1)=yes
++ ;;
++
++ linux* | k*bsd*-gnu)
++ case $cc_basename in
++ KCC*)
++ # Kuck and Associates, Inc. (KAI) C++ Compiler
++
++ # KCC will only create a shared library if the output file
++ # ends with ".so" (or ".sl" for HP-UX), so rename the library
++ # to its proper name (with version) after linking.
++ _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib'
++ # Commands to make compiler produce verbose output that lists
++ # what "hidden" libraries, object files and flags are used when
++ # linking a shared library.
++ #
++ # There doesn't appear to be a way to prevent this compiler from
++ # explicitly linking system object files so we need to strip them
++ # from the output so that they don't get included in the library
++ # dependencies.
++ output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
++
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
++
++ # Archives containing C++ object files must be created using
++ # "CC -Bstatic", where "CC" is the KAI C++ compiler.
++ _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs'
+ ;;
+- icpc* | ecpc*)
++ icpc* | ecpc* )
+ # Intel C++
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
+- ;;
+- pgCC*)
+- # Portland Group C++ compiler.
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- ;;
+- cxx*)
+- # Compaq C++
+- # Make sure the PIC flag is empty. It appears that all Alpha
+- # Linux and Compaq Tru64 Unix objects are PIC.
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
++ with_gnu_ld=yes
++ # version 8.0 and above of icpc choke on multiply defined symbols
++ # if we add $predep_objects and $postdep_objects, however 7.1 and
++ # earlier do not add the objects themselves.
++ case `$CC -V 2>&1` in
++ *"Version 7."*)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
++ ;;
++ *) # Version 8.0 or newer
++ tmp_idyn=
++ case $host_cpu in
++ ia64*) tmp_idyn=' -i_dynamic';;
++ esac
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
++ ;;
++ esac
++ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
++ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+ ;;
+- *)
+- case `$CC -V 2>&1 | sed 5q` in
+- *Sun\ C*)
+- # Sun C++ 5.9
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
++ pgCC* | pgcpp*)
++ # Portland Group C++ compiler
++ case `$CC -V` in
++ *pgCC\ [[1-5]]* | *pgcpp\ [[1-5]]*)
++ _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~
++ rm -rf $tpldir~
++ $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~
++ compile_command="$compile_command `find $tpldir -name \*.o | $NL2SP`"'
++ _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~
++ rm -rf $tpldir~
++ $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~
++ $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | $NL2SP`~
++ $RANLIB $oldlib'
++ _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~
++ rm -rf $tpldir~
++ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
++ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~
++ rm -rf $tpldir~
++ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
++ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
++ ;;
++ *) # Version 6 will use weak symbols
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+ ;;
+ esac
+- ;;
+- esac
+- ;;
+- lynxos*)
+- ;;
+- m88k*)
+- ;;
+- mvs*)
+- case $cc_basename in
+- cxx*)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall'
+- ;;
+- *)
+- ;;
+- esac
+- ;;
+- netbsd*)
+- ;;
+- osf3* | osf4* | osf5*)
+- case $cc_basename in
+- KCC*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
+- ;;
+- RCC*)
+- # Rational C++ 2.4.1
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+- ;;
++
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
++ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
++ ;;
+ cxx*)
+- # Digital/Compaq C++
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- # Make sure the PIC flag is empty. It appears that all Alpha
+- # Linux and Compaq Tru64 Unix objects are PIC.
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+- ;;
+- *)
+- ;;
+- esac
+- ;;
+- psos*)
+- ;;
+- solaris*)
+- case $cc_basename in
+- CC*)
+- # Sun C++ 4.2, 5.x and Centerline C++
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
+- ;;
+- gcx*)
+- # Green Hills C++ Compiler
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
+- ;;
+- *)
+- ;;
+- esac
+- ;;
+- sunos4*)
+- case $cc_basename in
+- CC*)
+- # Sun C++ 4.x
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- ;;
+- lcc*)
+- # Lucid
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+- ;;
+- *)
++ # Compaq C++
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
++
++ runpath_var=LD_RUN_PATH
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
++
++ # Commands to make compiler produce verbose output that lists
++ # what "hidden" libraries, object files and flags are used when
++ # linking a shared library.
++ #
++ # There doesn't appear to be a way to prevent this compiler from
++ # explicitly linking system object files so we need to strip them
++ # from the output so that they don't get included in the library
++ # dependencies.
++ output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
+ ;;
+- esac
+- ;;
+- tandem*)
+- case $cc_basename in
+- NCC*)
+- # NonStop-UX NCC 3.20
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ xl*)
++ # IBM XL 8.0 on PPC, with GNU ld
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
++ _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
++ if test "x$supports_anon_versioning" = xyes; then
++ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
++ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
++ echo "local: *; };" >> $output_objdir/$libname.ver~
++ $CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
++ fi
+ ;;
+ *)
++ case `$CC -V 2>&1 | sed 5q` in
++ *Sun\ C*)
++ # Sun C++ 5.9
++ _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'
++ _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
++ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
++ _LT_TAGVAR(compiler_needs_object, $1)=yes
++
++ # Not sure whether something based on
++ # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1
++ # would be better.
++ output_verbose_link_cmd='echo'
++
++ # Archives containing C++ object files must be created using
++ # "CC -xar", where "CC" is the Sun C++ compiler. This is
++ # necessary to make sure instantiated templates are included
++ # in the archive.
++ _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
++ ;;
++ esac
+ ;;
+ esac
+ ;;
+- sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+- case $cc_basename in
+- CC*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++
++ lynxos*)
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++
++ m88k*)
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++
++ mvs*)
++ case $cc_basename in
++ cxx*)
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++ *)
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ esac
+ ;;
+- vxworks*)
++
++ netbsd*)
++ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
++ _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags'
++ wlarc=
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ fi
++ # Workaround some broken pre-1.5 toolchains
++ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"'
+ ;;
+- *)
+- _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
++
++ *nto* | *qnx*)
++ _LT_TAGVAR(ld_shlibs, $1)=yes
+ ;;
+- esac
+- fi
+-],
+-[
+- if test "$GCC" = yes; then
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
+
+- case $host_os in
+- aix*)
+- # All AIX code is PIC.
+- if test "$host_cpu" = ia64; then
+- # AIX 5 now supports IA64 processor
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- fi
+- ;;
++ openbsd2*)
++ # C++ shared libraries are fairly broken
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++
++ openbsd*)
++ if test -f /usr/libexec/ld.so; then
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
++ if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
++ _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
++ fi
++ output_verbose_link_cmd=echo
++ else
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ fi
++ ;;
+
+- amigaos*)
+- # FIXME: we need at least 68020 code to build shared libraries, but
+- # adding the `-m68020' flag to GCC prevents building anything better,
+- # like `-m68040'.
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
+- ;;
++ osf3* | osf4* | osf5*)
++ case $cc_basename in
++ KCC*)
++ # Kuck and Associates, Inc. (KAI) C++ Compiler
++
++ # KCC will only create a shared library if the output file
++ # ends with ".so" (or ".sl" for HP-UX), so rename the library
++ # to its proper name (with version) after linking.
++ _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
++
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
++
++ # Archives containing C++ object files must be created using
++ # the KAI C++ compiler.
++ case $host in
++ osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;;
++ *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;;
++ esac
++ ;;
++ RCC*)
++ # Rational C++ 2.4.1
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++ cxx*)
++ case $host in
++ osf3*)
++ _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && $ECHO "X${wl}-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
++ ;;
++ *)
++ _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
++ echo "-hidden">> $lib.exp~
++ $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~
++ $RM $lib.exp'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
++ ;;
++ esac
+
+- beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+- # PIC is the default for these OSes.
+- ;;
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+- mingw* | cygwin* | pw32* | os2*)
+- # This hack is so that the source file can tell whether it is being
+- # built for inclusion in a dll (and should export symbols for example).
+- # Although the cygwin gcc ignores -fPIC, still need this for old-style
+- # (--disable-auto-import) libraries
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'
+- ;;
++ # Commands to make compiler produce verbose output that lists
++ # what "hidden" libraries, object files and flags are used when
++ # linking a shared library.
++ #
++ # There doesn't appear to be a way to prevent this compiler from
++ # explicitly linking system object files so we need to strip them
++ # from the output so that they don't get included in the library
++ # dependencies.
++ output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
++ ;;
++ *)
++ if test "$GXX" = yes && test "$with_gnu_ld" = no; then
++ _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
++ case $host in
++ osf3*)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
++ ;;
++ *)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
++ ;;
++ esac
++
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
++
++ # Commands to make compiler produce verbose output that lists
++ # what "hidden" libraries, object files and flags are used when
++ # linking a shared library.
++ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
++
++ else
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ fi
++ ;;
++ esac
++ ;;
+
+- darwin* | rhapsody*)
+- # PIC is the default on this platform
+- # Common symbols not allowed in MH_DYLIB files
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
+- ;;
++ psos*)
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
+
+- interix3*)
+- # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+- # Instead, we relocate shared libraries at runtime.
+- ;;
++ sunos4*)
++ case $cc_basename in
++ CC*)
++ # Sun C++ 4.x
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++ lcc*)
++ # Lucid
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++ *)
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++ esac
++ ;;
+
+- msdosdjgpp*)
+- # Just because we use GCC doesn't mean we suddenly get shared libraries
+- # on systems that don't support them.
+- _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+- enable_shared=no
+- ;;
++ solaris*)
++ case $cc_basename in
++ CC*)
++ # Sun C++ 4.2, 5.x and Centerline C++
++ _LT_TAGVAR(archive_cmds_need_lc,$1)=yes
++ _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'
++ _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
++ $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
++
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ case $host_os in
++ solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
++ *)
++ # The compiler driver will combine and reorder linker options,
++ # but understands `-z linker_flag'.
++ # Supported since Solaris 2.6 (maybe 2.5.1?)
++ _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
++ ;;
++ esac
++ _LT_TAGVAR(link_all_deplibs, $1)=yes
+
+- sysv4*MP*)
+- if test -d /usr/nec; then
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
+- fi
+- ;;
++ output_verbose_link_cmd='echo'
+
+- hpux*)
+- # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+- # not for PA HP-UX.
+- case $host_cpu in
+- hppa*64*|ia64*)
+- # +Z the default
+- ;;
+- *)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+- ;;
+- esac
+- ;;
++ # Archives containing C++ object files must be created using
++ # "CC -xar", where "CC" is the Sun C++ compiler. This is
++ # necessary to make sure instantiated templates are included
++ # in the archive.
++ _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
++ ;;
++ gcx*)
++ # Green Hills C++ Compiler
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+
+- *)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+- ;;
+- esac
+- else
+- # PORTME Check for flag to pass linker flags through the system compiler.
+- case $host_os in
+- aix*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- if test "$host_cpu" = ia64; then
+- # AIX 5 now supports IA64 processor
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- else
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
+- fi
+- ;;
+- darwin*)
+- # PIC is the default on this platform
+- # Common symbols not allowed in MH_DYLIB files
+- case $cc_basename in
+- xlc*)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-qnocommon'
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- ;;
+- esac
+- ;;
++ # The C++ compiler must be used to create the archive.
++ _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
++ ;;
++ *)
++ # GNU C++ compiler with Solaris linker
++ if test "$GXX" = yes && test "$with_gnu_ld" = no; then
++ _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs'
++ if $CC --version | $GREP -v '^2\.7' > /dev/null; then
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
++ $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
++
++ # Commands to make compiler produce verbose output that lists
++ # what "hidden" libraries, object files and flags are used when
++ # linking a shared library.
++ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
++ else
++ # g++ 2.7 appears to require `-G' NOT `-shared' on this
++ # platform.
++ _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
++ $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
++
++ # Commands to make compiler produce verbose output that lists
++ # what "hidden" libraries, object files and flags are used when
++ # linking a shared library.
++ output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
++ fi
++
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir'
++ case $host_os in
++ solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
++ *)
++ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
++ ;;
++ esac
++ fi
++ ;;
++ esac
++ ;;
+
+- mingw* | cygwin* | pw32* | os2*)
+- # This hack is so that the source file can tell whether it is being
+- # built for inclusion in a dll (and should export symbols for example).
+- # Although the cygwin gcc ignores -fPIC, still need this for old-style
+- # (--disable-auto-import) libraries
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'
+- ;;
++ sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
++ _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
++ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ runpath_var='LD_RUN_PATH'
+
+- hpux9* | hpux10* | hpux11*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+- # not for PA HP-UX.
+- case $host_cpu in
+- hppa*64*|ia64*)
+- # +Z the default
+- ;;
+- *)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
+- ;;
++ case $cc_basename in
++ CC*)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ ;;
++ *)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ ;;
+ esac
+- # Is there a better lt_prog_compiler_static that works with the bundled CC?
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+ ;;
+
+- irix5* | irix6* | nonstopux*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- # PIC (with -KPIC) is the default.
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+- ;;
++ sysv5* | sco3.2v5* | sco5v6*)
++ # Note: We can NOT use -z defs as we might desire, because we do not
++ # link with -lc, and that would cause any symbols used from libc to
++ # always be unresolved, which means just about no library would
++ # ever link correctly. If we're not using GNU ld we use -z text
++ # though, which does catch some bad symbols but isn't as heavy-handed
++ # as -z defs.
++ _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
++ _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
++ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
++ _LT_TAGVAR(link_all_deplibs, $1)=yes
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
++ runpath_var='LD_RUN_PATH'
+
+- newsos6)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ case $cc_basename in
++ CC*)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ ;;
++ *)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ ;;
++ esac
+ ;;
+
+- linux*)
+- case $cc_basename in
+- icc* | ecc*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
+- ;;
+- pgcc* | pgf77* | pgf90* | pgf95*)
+- # Portland Group compilers (*not* the Pentium gcc compiler,
+- # which looks to be a dead project)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- ;;
+- ccc*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- # All Alpha code is PIC.
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
++ tandem*)
++ case $cc_basename in
++ NCC*)
++ # NonStop-UX NCC 3.20
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++ *)
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++ esac
+ ;;
+- como)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-lopt='
++
++ vxworks*)
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
++
+ *)
+- case `$CC -V 2>&1 | sed 5q` in
+- *Sun\ C*)
+- # Sun C 5.9
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- ;;
+- *Sun\ F*)
+- # Sun Fortran 8.3 passes all unrecognized flags to the linker
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)=''
+- ;;
+- esac
+- ;;
+- esac
+- ;;
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++ esac
+
+- osf3* | osf4* | osf5*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- # All OSF/1 code is PIC.
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+- ;;
++ AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
++ test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
+
+- solaris*)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- case $cc_basename in
+- f77* | f90* | f95*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';;
+- *)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';;
+- esac
+- ;;
++ _LT_TAGVAR(GCC, $1)="$GXX"
++ _LT_TAGVAR(LD, $1)="$LD"
++
++ ## CAVEAT EMPTOR:
++ ## There is no encapsulation within the following macros, do not change
++ ## the running order or otherwise move them around unless you know exactly
++ ## what you are doing...
++ _LT_SYS_HIDDEN_LIBDEPS($1)
++ _LT_COMPILER_PIC($1)
++ _LT_COMPILER_C_O($1)
++ _LT_COMPILER_FILE_LOCKS($1)
++ _LT_LINKER_SHLIBS($1)
++ _LT_SYS_DYNAMIC_LINKER($1)
++ _LT_LINKER_HARDCODE_LIBPATH($1)
++
++ _LT_CONFIG($1)
++ fi # test -n "$compiler"
++
++ CC=$lt_save_CC
++ LDCXX=$LD
++ LD=$lt_save_LD
++ GCC=$lt_save_GCC
++ with_gnu_ld=$lt_save_with_gnu_ld
++ lt_cv_path_LDCXX=$lt_cv_path_LD
++ lt_cv_path_LD=$lt_save_path_LD
++ lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
++ lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
++fi # test "$_lt_caught_CXX_error" != yes
++
++AC_LANG_POP
++])# _LT_LANG_CXX_CONFIG
++
++
++# _LT_SYS_HIDDEN_LIBDEPS([TAGNAME])
++# ---------------------------------
++# Figure out "hidden" library dependencies from verbose
++# compiler output when linking a shared library.
++# Parse the compiler output and extract the necessary
++# objects, libraries and library flags.
++m4_defun([_LT_SYS_HIDDEN_LIBDEPS],
++[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
++# Dependencies to place before and after the object being linked:
++_LT_TAGVAR(predep_objects, $1)=
++_LT_TAGVAR(postdep_objects, $1)=
++_LT_TAGVAR(predeps, $1)=
++_LT_TAGVAR(postdeps, $1)=
++_LT_TAGVAR(compiler_lib_search_path, $1)=
++
++dnl we can't use the lt_simple_compile_test_code here,
++dnl because it contains code intended for an executable,
++dnl not a library. It's possible we should let each
++dnl tag define a new lt_????_link_test_code variable,
++dnl but it's only used here...
++m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF
++int a;
++void foo (void) { a = 0; }
++_LT_EOF
++], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF
++class Foo
++{
++public:
++ Foo (void) { a = 0; }
++private:
++ int a;
++};
++_LT_EOF
++], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF
++ subroutine foo
++ implicit none
++ integer*4 a
++ a=0
++ return
++ end
++_LT_EOF
++], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF
++ subroutine foo
++ implicit none
++ integer a
++ a=0
++ return
++ end
++_LT_EOF
++], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF
++public class foo {
++ private int a;
++ public void bar (void) {
++ a = 0;
++ }
++};
++_LT_EOF
++])
++dnl Parse the compiler output and extract the necessary
++dnl objects, libraries and library flags.
++if AC_TRY_EVAL(ac_compile); then
++ # Parse the compiler output and extract the necessary
++ # objects, libraries and library flags.
++
++ # Sentinel used to keep track of whether or not we are before
++ # the conftest object file.
++ pre_test_object_deps_done=no
+
+- sunos4*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- ;;
++ for p in `eval "$output_verbose_link_cmd"`; do
++ case $p in
+
+- sysv4 | sysv4.2uw2* | sysv4.3*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- ;;
++ -L* | -R* | -l*)
++ # Some compilers place space between "-{L,R}" and the path.
++ # Remove the space.
++ if test $p = "-L" ||
++ test $p = "-R"; then
++ prev=$p
++ continue
++ else
++ prev=
++ fi
+
+- sysv4*MP*)
+- if test -d /usr/nec ;then
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- fi
+- ;;
++ if test "$pre_test_object_deps_done" = no; then
++ case $p in
++ -L* | -R*)
++ # Internal compiler library paths should come after those
++ # provided the user. The postdeps already come after the
++ # user supplied libs so there is no need to process them.
++ if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then
++ _LT_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}"
++ else
++ _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}"
++ fi
++ ;;
++ # The "-l" case would never come before the object being
++ # linked, so don't bother handling this case.
++ esac
++ else
++ if test -z "$_LT_TAGVAR(postdeps, $1)"; then
++ _LT_TAGVAR(postdeps, $1)="${prev}${p}"
++ else
++ _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}"
++ fi
++ fi
++ ;;
+
+- sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- ;;
++ *.$objext)
++ # This assumes that the test object file only shows up
++ # once in the compiler output.
++ if test "$p" = "conftest.$objext"; then
++ pre_test_object_deps_done=yes
++ continue
++ fi
+
+- unicos*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+- ;;
++ if test "$pre_test_object_deps_done" = no; then
++ if test -z "$_LT_TAGVAR(predep_objects, $1)"; then
++ _LT_TAGVAR(predep_objects, $1)="$p"
++ else
++ _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p"
++ fi
++ else
++ if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then
++ _LT_TAGVAR(postdep_objects, $1)="$p"
++ else
++ _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p"
++ fi
++ fi
++ ;;
+
+- uts4*)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- ;;
++ *) ;; # Ignore the rest.
+
+- *)
+- _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+- ;;
+ esac
+- fi
+-])
+-AC_MSG_RESULT([$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)])
++ done
+
+-#
+-# Check to make sure the PIC flag actually works.
+-#
+-if test -n "$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)"; then
+- AC_LIBTOOL_COMPILER_OPTION([if $compiler PIC flag $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) works],
+- _LT_AC_TAGVAR(lt_prog_compiler_pic_works, $1),
+- [$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)ifelse([$1],[],[ -DPIC],[ifelse([$1],[CXX],[ -DPIC],[])])], [],
+- [case $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) in
+- "" | " "*) ;;
+- *) _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)" ;;
+- esac],
+- [_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
+- _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no])
++ # Clean up.
++ rm -f a.out a.exe
++else
++ echo "libtool.m4: error: problem compiling $1 test program"
+ fi
+-case $host_os in
+- # For platforms which do not support PIC, -DPIC is meaningless:
+- *djgpp*)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
+- ;;
+- *)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)ifelse([$1],[],[ -DPIC],[ifelse([$1],[CXX],[ -DPIC],[])])"
+- ;;
+-esac
+-
+-#
+-# Check to make sure the static flag actually works.
+-#
+-wl=$_LT_AC_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_AC_TAGVAR(lt_prog_compiler_static, $1)\"
+-AC_LIBTOOL_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works],
+- _LT_AC_TAGVAR(lt_prog_compiler_static_works, $1),
+- $lt_tmp_static_flag,
+- [],
+- [_LT_AC_TAGVAR(lt_prog_compiler_static, $1)=])
+-])
+
++$RM -f confest.$objext
+
+-# AC_LIBTOOL_PROG_LD_SHLIBS([TAGNAME])
+-# ------------------------------------
+-# See if the linker supports building shared libraries.
+-AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS],
+-[AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
+-ifelse([$1],[CXX],[
+- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+- case $host_os in
+- aix4* | aix5*)
+- # If we're using GNU nm, then we don't want the "-C" option.
+- # -C means demangle to AIX nm, but means don't demangle with GNU nm
+- if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
+- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols'
+- else
+- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols'
+- fi
+- ;;
+- pw32*)
+- _LT_AC_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds"
+- ;;
+- cygwin* | mingw*)
+- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]] /s/.* \([[^ ]]*\)/\1 DATA/;/^.* __nm__/s/^.* __nm__\([[^ ]]*\) [[^ ]]*/\1 DATA/;/^I /d;/^[[AITW]] /s/.* //'\'' | sort | uniq > $export_symbols'
+- ;;
+- *)
+- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
++# PORTME: override above test on systems where it is broken
++m4_if([$1], [CXX],
++[case $host_os in
++interix[[3-9]]*)
++ # Interix 3.5 installs completely hosed .la files for C++, so rather than
++ # hack all around it, let's just trust "g++" to DTRT.
++ _LT_TAGVAR(predep_objects,$1)=
++ _LT_TAGVAR(postdep_objects,$1)=
++ _LT_TAGVAR(postdeps,$1)=
+ ;;
+- esac
+-],[
+- runpath_var=
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=
+- _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+- _LT_AC_TAGVAR(archive_cmds, $1)=
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)=
+- _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)=
+- _LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1)=
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+- _LT_AC_TAGVAR(thread_safe_flag_spec, $1)=
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
+- _LT_AC_TAGVAR(hardcode_direct, $1)=no
+- _LT_AC_TAGVAR(hardcode_minus_L, $1)=no
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+- _LT_AC_TAGVAR(link_all_deplibs, $1)=unknown
+- _LT_AC_TAGVAR(hardcode_automatic, $1)=no
+- _LT_AC_TAGVAR(module_cmds, $1)=
+- _LT_AC_TAGVAR(module_expsym_cmds, $1)=
+- _LT_AC_TAGVAR(always_export_symbols, $1)=no
+- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+- # include_expsyms should be a list of space-separated symbols to be *always*
+- # included in the symbol list
+- _LT_AC_TAGVAR(include_expsyms, $1)=
+- # exclude_expsyms can be an extended regexp of symbols to exclude
+- # it will be wrapped by ` (' and `)$', so one must not match beginning or
+- # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
+- # as well as any symbol that contains `d'.
+- _LT_AC_TAGVAR(exclude_expsyms, $1)="_GLOBAL_OFFSET_TABLE_"
+- # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
+- # platforms (ab)use it in PIC code, but their linkers get confused if
+- # the symbol is explicitly referenced. Since portable code cannot
+- # rely on this symbol name, it's probably fine to never include it in
+- # preloaded symbol tables.
+- extract_expsyms_cmds=
+- # Just being paranoid about ensuring that cc_basename is set.
+- _LT_CC_BASENAME([$compiler])
+- case $host_os in
+- cygwin* | mingw* | pw32*)
+- # FIXME: the MSVC++ port hasn't been tested in a loooong time
+- # When not using gcc, we currently assume that we are using
+- # Microsoft Visual C++.
+- if test "$GCC" != yes; then
+- with_gnu_ld=no
+- fi
+- ;;
+- interix*)
+- # we just hope/assume this is gcc and not c89 (= MSVC++)
+- with_gnu_ld=yes
+- ;;
+- openbsd*)
+- with_gnu_ld=no
+- ;;
+- esac
+-
+- _LT_AC_TAGVAR(ld_shlibs, $1)=yes
+- if test "$with_gnu_ld" = yes; then
+- # If archive_cmds runs LD, not CC, wlarc should be empty
+- wlarc='${wl}'
+-
+- # Set some defaults for GNU ld with shared library support. These
+- # are reset later if shared libraries are not supported. Putting them
+- # here allows them to be overridden if necessary.
+- runpath_var=LD_RUN_PATH
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+- # ancient GNU ld didn't support --whole-archive et. al.
+- if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+- else
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+- fi
+- supports_anon_versioning=no
+- case `$LD -v 2>/dev/null` in
+- *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11
+- *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
+- *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
+- *\ 2.11.*) ;; # other 2.11 versions
+- *) supports_anon_versioning=yes ;;
+- esac
+-
+- # See if GNU ld supports shared libraries.
+- case $host_os in
+- aix3* | aix4* | aix5*)
+- # On AIX/PPC, the GNU linker is very broken
+- if test "$host_cpu" != ia64; then
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- cat <<EOF 1>&2
+-
+-*** Warning: the GNU linker, at least up to release 2.9.1, is reported
+-*** to be unable to reliably create shared libraries on AIX.
+-*** Therefore, libtool is disabling shared libraries support. If you
+-*** really care for shared libraries, you may want to modify your PATH
+-*** so that a non-GNU linker is found, and then restart.
+-
+-EOF
+- fi
+- ;;
+
+- amigaos*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+-
+- # Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports
+- # that the semantics of dynamic libraries on AmigaOS, at least up
+- # to version 4, is to share data among multiple programs linked
+- # with the same dynamic library. Since this doesn't match the
+- # behavior of shared libraries on other platforms, we can't use
+- # them.
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
++linux*)
++ case `$CC -V 2>&1 | sed 5q` in
++ *Sun\ C*)
++ # Sun C++ 5.9
+
+- beos*)
+- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+- # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
+- # support --undefined. This deserves some investigation. FIXME
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+- else
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- fi
++ # The more standards-conforming stlport4 library is
++ # incompatible with the Cstd library. Avoid specifying
++ # it if it's in CXXFLAGS. Ignore libCrun as
++ # -library=stlport4 depends on it.
++ case " $CXX $CXXFLAGS " in
++ *" -library=stlport4 "*)
++ solaris_use_stlport4=yes
+ ;;
++ esac
+
+- cygwin* | mingw* | pw32*)
+- # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
+- # as there is no search path for DLLs.
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+- _LT_AC_TAGVAR(always_export_symbols, $1)=no
+- _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]] /s/.* \([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]] /s/.* //'\'' | sort | uniq > $export_symbols'
+-
+- if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+- # If the export-symbols file already is a .def file (1st line
+- # is EXPORTS), use it as is; otherwise, prepend...
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+- cp $export_symbols $output_objdir/$soname.def;
+- else
+- echo EXPORTS > $output_objdir/$soname.def;
+- cat $export_symbols >> $output_objdir/$soname.def;
+- fi~
+- $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+- else
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- fi
+- ;;
++ if test "$solaris_use_stlport4" != yes; then
++ _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
++ fi
++ ;;
++ esac
++ ;;
+
+- interix3*)
+- _LT_AC_TAGVAR(hardcode_direct, $1)=no
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+- # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+- # Instead, shared libraries are loaded at an image base (0x10000000 by
+- # default) and relocated if they conflict, which is a slow very memory
+- # consuming and fragmenting process. To avoid this, we pick a random,
+- # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+- # time. Moving up from 0x10000000 also allows more sbrk(2) space.
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
++solaris*)
++ case $cc_basename in
++ CC*)
++ # The more standards-conforming stlport4 library is
++ # incompatible with the Cstd library. Avoid specifying
++ # it if it's in CXXFLAGS. Ignore libCrun as
++ # -library=stlport4 depends on it.
++ case " $CXX $CXXFLAGS " in
++ *" -library=stlport4 "*)
++ solaris_use_stlport4=yes
+ ;;
++ esac
+
+- linux*)
+- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+- tmp_addflag=
+- case $cc_basename,$host_cpu in
+- pgcc*) # Portland Group C compiler
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+- tmp_addflag=' $pic_flag'
+- ;;
+- pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+- tmp_addflag=' $pic_flag -Mnomain' ;;
+- ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64
+- tmp_addflag=' -i_dynamic' ;;
+- efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64
+- tmp_addflag=' -i_dynamic -nofor_main' ;;
+- ifc* | ifort*) # Intel Fortran compiler
+- tmp_addflag=' -nofor_main' ;;
+- esac
+- case `$CC -V 2>&1 | sed 5q` in
+- *Sun\ C*) # Sun C 5.9
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive /dev/null'
+- tmp_sharedflag='-G' ;;
+- *Sun\ F*) # Sun Fortran 8.3
+- tmp_sharedflag='-G' ;;
+- *)
+- tmp_sharedflag='-shared' ;;
+- esac
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
++ # Adding this requires a known-good setup of shared libraries for
++ # Sun compiler versions before 5.6, else PIC objects from an old
++ # archive will be linked into the output, leading to subtle bugs.
++ if test "$solaris_use_stlport4" != yes; then
++ _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
++ fi
++ ;;
++ esac
++ ;;
++esac
++])
+
+- if test $supports_anon_versioning = yes; then
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $output_objdir/$libname.ver~
+- cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+- $echo "local: *; };" >> $output_objdir/$libname.ver~
+- $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+- fi
+- else
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- fi
+- ;;
++case " $_LT_TAGVAR(postdeps, $1) " in
++*" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;;
++esac
++ _LT_TAGVAR(compiler_lib_search_dirs, $1)=
++if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then
++ _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'`
++fi
++_LT_TAGDECL([], [compiler_lib_search_dirs], [1],
++ [The directories searched by this compiler when creating a shared library])
++_LT_TAGDECL([], [predep_objects], [1],
++ [Dependencies to place before and after the objects being linked to
++ create a shared library])
++_LT_TAGDECL([], [postdep_objects], [1])
++_LT_TAGDECL([], [predeps], [1])
++_LT_TAGDECL([], [postdeps], [1])
++_LT_TAGDECL([], [compiler_lib_search_path], [1],
++ [The library search path used internally by the compiler when linking
++ a shared library])
++])# _LT_SYS_HIDDEN_LIBDEPS
++
++
++# _LT_PROG_F77
++# ------------
++# Since AC_PROG_F77 is broken, in that it returns the empty string
++# if there is no fortran compiler, we have our own version here.
++m4_defun([_LT_PROG_F77],
++[
++pushdef([AC_MSG_ERROR], [_lt_disable_F77=yes])
++AC_PROG_F77
++if test -z "$F77" || test "X$F77" = "Xno"; then
++ _lt_disable_F77=yes
++fi
++popdef([AC_MSG_ERROR])
++])# _LT_PROG_F77
+
+- netbsd*)
+- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
+- wlarc=
+- else
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+- fi
+- ;;
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([_LT_PROG_F77], [])
+
+- solaris*)
+- if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- cat <<EOF 1>&2
+
+-*** Warning: The releases 2.8.* of the GNU linker cannot reliably
+-*** create shared libraries on Solaris systems. Therefore, libtool
+-*** is disabling shared libraries support. We urge you to upgrade GNU
+-*** binutils to release 2.9.1 or newer. Another option is to modify
+-*** your PATH or compiler configuration so that the native linker is
+-*** used, and then restart.
++# _LT_LANG_F77_CONFIG([TAG])
++# --------------------------
++# Ensure that the configuration variables for a Fortran 77 compiler are
++# suitably defined. These variables are subsequently used by _LT_CONFIG
++# to write the compiler configuration to `libtool'.
++m4_defun([_LT_LANG_F77_CONFIG],
++[AC_REQUIRE([_LT_PROG_F77])dnl
++AC_LANG_PUSH(Fortran 77)
+
+-EOF
+- elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+- else
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- fi
+- ;;
++_LT_TAGVAR(archive_cmds_need_lc, $1)=no
++_LT_TAGVAR(allow_undefined_flag, $1)=
++_LT_TAGVAR(always_export_symbols, $1)=no
++_LT_TAGVAR(archive_expsym_cmds, $1)=
++_LT_TAGVAR(export_dynamic_flag_spec, $1)=
++_LT_TAGVAR(hardcode_direct, $1)=no
++_LT_TAGVAR(hardcode_direct_absolute, $1)=no
++_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
++_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
++_LT_TAGVAR(hardcode_libdir_separator, $1)=
++_LT_TAGVAR(hardcode_minus_L, $1)=no
++_LT_TAGVAR(hardcode_automatic, $1)=no
++_LT_TAGVAR(inherit_rpath, $1)=no
++_LT_TAGVAR(module_cmds, $1)=
++_LT_TAGVAR(module_expsym_cmds, $1)=
++_LT_TAGVAR(link_all_deplibs, $1)=unknown
++_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
++_LT_TAGVAR(no_undefined_flag, $1)=
++_LT_TAGVAR(whole_archive_flag_spec, $1)=
++_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+
+- sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
+- case `$LD -v 2>&1` in
+- *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*)
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- cat <<_LT_EOF 1>&2
++# Source file extension for f77 test sources.
++ac_ext=f
+
+-*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
+-*** reliably create shared libraries on SCO systems. Therefore, libtool
+-*** is disabling shared libraries support. We urge you to upgrade GNU
+-*** binutils to release 2.16.91.0.3 or newer. Another option is to modify
+-*** your PATH or compiler configuration so that the native linker is
+-*** used, and then restart.
++# Object file extension for compiled f77 test sources.
++objext=o
++_LT_TAGVAR(objext, $1)=$objext
+
+-_LT_EOF
+- ;;
+- *)
+- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname,-retain-symbols-file,$export_symbols -o $lib'
+- else
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- fi
+- ;;
+- esac
+- ;;
++# No sense in running all these tests if we already determined that
++# the F77 compiler isn't working. Some variables (like enable_shared)
++# are currently assumed to apply to all compilers on this platform,
++# and will be corrupted by setting them based on a non-working compiler.
++if test "$_lt_disable_F77" != yes; then
++ # Code to be used in simple compile tests
++ lt_simple_compile_test_code="\
++ subroutine t
++ return
++ end
++"
+
+- sunos4*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+- wlarc=
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- ;;
++ # Code to be used in simple link tests
++ lt_simple_link_test_code="\
++ program t
++ end
++"
+
+- *)
+- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+- else
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- fi
+- ;;
+- esac
++ # ltmain only uses $CC for tagged configurations so make sure $CC is set.
++ _LT_TAG_COMPILER
+
+- if test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no; then
+- runpath_var=
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+- fi
+- else
+- # PORTME fill in a description of your system's linker (not GNU ld)
+- case $host_os in
+- aix3*)
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+- _LT_AC_TAGVAR(always_export_symbols, $1)=yes
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
+- # Note: this linker hardcodes the directories in LIBPATH if there
+- # are no directories specified by -L.
+- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+- if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
+- # Neither direct hardcoding nor static linking is supported with a
+- # broken collect2.
+- _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported
+- fi
+- ;;
++ # save warnings/boilerplate of simple test code
++ _LT_COMPILER_BOILERPLATE
++ _LT_LINKER_BOILERPLATE
++
++ # Allow CC to be a program name with arguments.
++ lt_save_CC="$CC"
++ lt_save_GCC=$GCC
++ CC=${F77-"f77"}
++ compiler=$CC
++ _LT_TAGVAR(compiler, $1)=$CC
++ _LT_CC_BASENAME([$compiler])
++ GCC=$G77
++ if test -n "$compiler"; then
++ AC_MSG_CHECKING([if libtool supports shared libraries])
++ AC_MSG_RESULT([$can_build_shared])
+
+- aix4* | aix5*)
+- if test "$host_cpu" = ia64; then
+- # On IA64, the linker does run time linking by default, so we don't
+- # have to do anything special.
+- aix_use_runtimelinking=no
+- exp_sym_flag='-Bexport'
+- no_entry_flag=""
+- else
+- # If we're using GNU nm, then we don't want the "-C" option.
+- # -C means demangle to AIX nm, but means don't demangle with GNU nm
+- if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
+- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols'
+- else
+- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols'
++ AC_MSG_CHECKING([whether to build shared libraries])
++ test "$can_build_shared" = "no" && enable_shared=no
++
++ # On AIX, shared libraries and static libraries use the same namespace, and
++ # are all built from PIC.
++ case $host_os in
++ aix3*)
++ test "$enable_shared" = yes && enable_static=no
++ if test -n "$RANLIB"; then
++ archive_cmds="$archive_cmds~\$RANLIB \$lib"
++ postinstall_cmds='$RANLIB $lib'
++ fi
++ ;;
++ aix[[4-9]]*)
++ if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
++ test "$enable_shared" = yes && enable_static=no
+ fi
+- aix_use_runtimelinking=no
++ ;;
++ esac
++ AC_MSG_RESULT([$enable_shared])
+
+- # Test if we are trying to use run time linking or normal
+- # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+- # need to do runtime linking.
+- case $host_os in aix4.[[23]]|aix4.[[23]].*|aix5*)
+- for ld_flag in $LDFLAGS; do
+- if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+- aix_use_runtimelinking=yes
+- break
+- fi
+- done
+- ;;
+- esac
++ AC_MSG_CHECKING([whether to build static libraries])
++ # Make sure either enable_shared or enable_static is yes.
++ test "$enable_shared" = yes || enable_static=yes
++ AC_MSG_RESULT([$enable_static])
++
++ _LT_TAGVAR(GCC, $1)="$G77"
++ _LT_TAGVAR(LD, $1)="$LD"
++
++ ## CAVEAT EMPTOR:
++ ## There is no encapsulation within the following macros, do not change
++ ## the running order or otherwise move them around unless you know exactly
++ ## what you are doing...
++ _LT_COMPILER_PIC($1)
++ _LT_COMPILER_C_O($1)
++ _LT_COMPILER_FILE_LOCKS($1)
++ _LT_LINKER_SHLIBS($1)
++ _LT_SYS_DYNAMIC_LINKER($1)
++ _LT_LINKER_HARDCODE_LIBPATH($1)
++
++ _LT_CONFIG($1)
++ fi # test -n "$compiler"
++
++ GCC=$lt_save_GCC
++ CC="$lt_save_CC"
++fi # test "$_lt_disable_F77" != yes
+
+- exp_sym_flag='-bexport'
+- no_entry_flag='-bnoentry'
+- fi
++AC_LANG_POP
++])# _LT_LANG_F77_CONFIG
+
+- # When large executables or shared objects are built, AIX ld can
+- # have problems creating the table of contents. If linking a library
+- # or program results in "error TOC overflow" add -mminimal-toc to
+- # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
+- # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+- _LT_AC_TAGVAR(archive_cmds, $1)=''
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':'
+- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
++# _LT_PROG_FC
++# -----------
++# Since AC_PROG_FC is broken, in that it returns the empty string
++# if there is no fortran compiler, we have our own version here.
++m4_defun([_LT_PROG_FC],
++[
++pushdef([AC_MSG_ERROR], [_lt_disable_FC=yes])
++AC_PROG_FC
++if test -z "$FC" || test "X$FC" = "Xno"; then
++ _lt_disable_FC=yes
++fi
++popdef([AC_MSG_ERROR])
++])# _LT_PROG_FC
+
+- if test "$GCC" = yes; then
+- case $host_os in aix4.[[012]]|aix4.[[012]].*)
+- # We only want to do this on AIX 4.2 and lower, the check
+- # below for broken collect2 doesn't work under 4.3+
+- collect2name=`${CC} -print-prog-name=collect2`
+- if test -f "$collect2name" && \
+- strings "$collect2name" | grep resolve_lib_name >/dev/null
+- then
+- # We have reworked collect2
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- else
+- # We have old collect2
+- _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported
+- # It fails to find uninstalled libraries when the uninstalled
+- # path is not listed in the libpath. Setting hardcode_minus_L
+- # to unsupported forces relinking
+- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
+- fi
+- ;;
+- esac
+- shared_flag='-shared'
+- if test "$aix_use_runtimelinking" = yes; then
+- shared_flag="$shared_flag "'${wl}-G'
+- fi
+- else
+- # not using gcc
+- if test "$host_cpu" = ia64; then
+- # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+- # chokes on -Wl,-G. The following line is correct:
+- shared_flag='-G'
+- else
+- if test "$aix_use_runtimelinking" = yes; then
+- shared_flag='${wl}-G'
+- else
+- shared_flag='${wl}-bM:SRE'
+- fi
+- fi
+- fi
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([_LT_PROG_FC], [])
+
+- # It seems that -bexpall does not export symbols beginning with
+- # underscore (_), so it is better to generate a list of symbols to export.
+- _LT_AC_TAGVAR(always_export_symbols, $1)=yes
+- if test "$aix_use_runtimelinking" = yes; then
+- # Warning - without using the other runtime loading flags (-brtl),
+- # -berok will link without error, but may produce a broken library.
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)='-berok'
+- # Determine the default libpath from the value encoded in an empty executable.
+- _LT_AC_SYS_LIBPATH_AIX
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+- else
+- if test "$host_cpu" = ia64; then
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+- else
+- # Determine the default libpath from the value encoded in an empty executable.
+- _LT_AC_SYS_LIBPATH_AIX
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+- # Warning - without using the other run time loading flags,
+- # -berok will link without error, but may produce a broken library.
+- _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
+- # Exported symbols can be pulled into shared objects from archives
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
+- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
+- # This is similar to how AIX traditionally builds its shared libraries.
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+- fi
+- fi
+- ;;
+
+- amigaos*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+- # see comment about different semantics on the GNU ld section
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
++# _LT_LANG_FC_CONFIG([TAG])
++# -------------------------
++# Ensure that the configuration variables for a Fortran compiler are
++# suitably defined. These variables are subsequently used by _LT_CONFIG
++# to write the compiler configuration to `libtool'.
++m4_defun([_LT_LANG_FC_CONFIG],
++[AC_REQUIRE([_LT_PROG_FC])dnl
++AC_LANG_PUSH(Fortran)
++
++_LT_TAGVAR(archive_cmds_need_lc, $1)=no
++_LT_TAGVAR(allow_undefined_flag, $1)=
++_LT_TAGVAR(always_export_symbols, $1)=no
++_LT_TAGVAR(archive_expsym_cmds, $1)=
++_LT_TAGVAR(export_dynamic_flag_spec, $1)=
++_LT_TAGVAR(hardcode_direct, $1)=no
++_LT_TAGVAR(hardcode_direct_absolute, $1)=no
++_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
++_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
++_LT_TAGVAR(hardcode_libdir_separator, $1)=
++_LT_TAGVAR(hardcode_minus_L, $1)=no
++_LT_TAGVAR(hardcode_automatic, $1)=no
++_LT_TAGVAR(inherit_rpath, $1)=no
++_LT_TAGVAR(module_cmds, $1)=
++_LT_TAGVAR(module_expsym_cmds, $1)=
++_LT_TAGVAR(link_all_deplibs, $1)=unknown
++_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
++_LT_TAGVAR(no_undefined_flag, $1)=
++_LT_TAGVAR(whole_archive_flag_spec, $1)=
++_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+
+- bsdi[[45]]*)
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic
+- ;;
++# Source file extension for fc test sources.
++ac_ext=${ac_fc_srcext-f}
+
+- cygwin* | mingw* | pw32*)
+- # When not using gcc, we currently assume that we are using
+- # Microsoft Visual C++.
+- # hardcode_libdir_flag_spec is actually meaningless, as there is
+- # no search path for DLLs.
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=' '
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+- # Tell ltmain to make .lib files, not .a files.
+- libext=lib
+- # Tell ltmain to make .dll files, not .so files.
+- shrext_cmds=".dll"
+- # FIXME: Setting linknames here is a bad hack.
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames='
+- # The linker will automatically build a .lib file if we build a DLL.
+- _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)='true'
+- # FIXME: Should let the user specify the lib program.
+- _LT_AC_TAGVAR(old_archive_cmds, $1)='lib /OUT:$oldlib$oldobjs$old_deplibs'
+- _LT_AC_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`'
+- _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+- ;;
++# Object file extension for compiled fc test sources.
++objext=o
++_LT_TAGVAR(objext, $1)=$objext
+
+- darwin* | rhapsody*)
+- case $host_os in
+- rhapsody* | darwin1.[[012]])
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}suppress'
+- ;;
+- *) # Darwin 1.3 on
+- if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+- else
+- case ${MACOSX_DEPLOYMENT_TARGET} in
+- 10.[[012]])
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+- ;;
+- 10.*)
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}dynamic_lookup'
+- ;;
+- esac
+- fi
+- ;;
+- esac
+- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+- _LT_AC_TAGVAR(hardcode_direct, $1)=no
+- _LT_AC_TAGVAR(hardcode_automatic, $1)=yes
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=''
+- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+- if test "$GCC" = yes ; then
+- output_verbose_link_cmd='echo'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+- _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+- # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+- _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+- else
+- case $cc_basename in
+- xlc*)
+- output_verbose_link_cmd='echo'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
+- _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+- # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+- _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+- ;;
+- *)
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- esac
+- fi
+- ;;
++# No sense in running all these tests if we already determined that
++# the FC compiler isn't working. Some variables (like enable_shared)
++# are currently assumed to apply to all compilers on this platform,
++# and will be corrupted by setting them based on a non-working compiler.
++if test "$_lt_disable_FC" != yes; then
++ # Code to be used in simple compile tests
++ lt_simple_compile_test_code="\
++ subroutine t
++ return
++ end
++"
+
+- dgux*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- ;;
++ # Code to be used in simple link tests
++ lt_simple_link_test_code="\
++ program t
++ end
++"
+
+- freebsd1*)
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
++ # ltmain only uses $CC for tagged configurations so make sure $CC is set.
++ _LT_TAG_COMPILER
+
+- # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
+- # support. Future versions do this automatically, but an explicit c++rt0.o
+- # does not break anything, and helps significantly (at the cost of a little
+- # extra space).
+- freebsd2.2*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- ;;
++ # save warnings/boilerplate of simple test code
++ _LT_COMPILER_BOILERPLATE
++ _LT_LINKER_BOILERPLATE
++
++ # Allow CC to be a program name with arguments.
++ lt_save_CC="$CC"
++ lt_save_GCC=$GCC
++ CC=${FC-"f95"}
++ compiler=$CC
++ GCC=$ac_cv_fc_compiler_gnu
+
+- # Unfortunately, older versions of FreeBSD 2 do not have this feature.
+- freebsd2*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- ;;
++ _LT_TAGVAR(compiler, $1)=$CC
++ _LT_CC_BASENAME([$compiler])
+
+- # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
+- freebsd* | kfreebsd*-gnu | dragonfly*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- ;;
++ if test -n "$compiler"; then
++ AC_MSG_CHECKING([if libtool supports shared libraries])
++ AC_MSG_RESULT([$can_build_shared])
+
+- hpux9*)
+- if test "$GCC" = yes; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+- else
+- _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+- fi
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
++ AC_MSG_CHECKING([whether to build shared libraries])
++ test "$can_build_shared" = "no" && enable_shared=no
+
+- # hardcode_minus_L: Not really in the search PATH,
+- # but as the default location of the library.
+- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+- ;;
++ # On AIX, shared libraries and static libraries use the same namespace, and
++ # are all built from PIC.
++ case $host_os in
++ aix3*)
++ test "$enable_shared" = yes && enable_static=no
++ if test -n "$RANLIB"; then
++ archive_cmds="$archive_cmds~\$RANLIB \$lib"
++ postinstall_cmds='$RANLIB $lib'
++ fi
++ ;;
++ aix[[4-9]]*)
++ if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
++ test "$enable_shared" = yes && enable_static=no
++ fi
++ ;;
++ esac
++ AC_MSG_RESULT([$enable_shared])
+
+- hpux10*)
+- if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+- else
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
+- fi
+- if test "$with_gnu_ld" = no; then
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
++ AC_MSG_CHECKING([whether to build static libraries])
++ # Make sure either enable_shared or enable_static is yes.
++ test "$enable_shared" = yes || enable_static=yes
++ AC_MSG_RESULT([$enable_static])
++
++ _LT_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu"
++ _LT_TAGVAR(LD, $1)="$LD"
++
++ ## CAVEAT EMPTOR:
++ ## There is no encapsulation within the following macros, do not change
++ ## the running order or otherwise move them around unless you know exactly
++ ## what you are doing...
++ _LT_SYS_HIDDEN_LIBDEPS($1)
++ _LT_COMPILER_PIC($1)
++ _LT_COMPILER_C_O($1)
++ _LT_COMPILER_FILE_LOCKS($1)
++ _LT_LINKER_SHLIBS($1)
++ _LT_SYS_DYNAMIC_LINKER($1)
++ _LT_LINKER_HARDCODE_LIBPATH($1)
++
++ _LT_CONFIG($1)
++ fi # test -n "$compiler"
++
++ GCC=$lt_save_GCC
++ CC="$lt_save_CC"
++fi # test "$_lt_disable_FC" != yes
+
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
++AC_LANG_POP
++])# _LT_LANG_FC_CONFIG
+
+- # hardcode_minus_L: Not really in the search PATH,
+- # but as the default location of the library.
+- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+- fi
+- ;;
+
+- hpux11*)
+- if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+- case $host_cpu in
+- hppa*64*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+- ;;
+- ia64*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+- ;;
+- *)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+- ;;
+- esac
+- else
+- case $host_cpu in
+- hppa*64*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+- ;;
+- ia64*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+- ;;
+- *)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+- ;;
+- esac
+- fi
+- if test "$with_gnu_ld" = no; then
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
++# _LT_LANG_GCJ_CONFIG([TAG])
++# --------------------------
++# Ensure that the configuration variables for the GNU Java Compiler compiler
++# are suitably defined. These variables are subsequently used by _LT_CONFIG
++# to write the compiler configuration to `libtool'.
++m4_defun([_LT_LANG_GCJ_CONFIG],
++[AC_REQUIRE([LT_PROG_GCJ])dnl
++AC_LANG_SAVE
+
+- case $host_cpu in
+- hppa*64*|ia64*)
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir'
+- _LT_AC_TAGVAR(hardcode_direct, $1)=no
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- ;;
+- *)
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
++# Source file extension for Java test sources.
++ac_ext=java
+
+- # hardcode_minus_L: Not really in the search PATH,
+- # but as the default location of the library.
+- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+- ;;
+- esac
+- fi
+- ;;
++# Object file extension for compiled Java test sources.
++objext=o
++_LT_TAGVAR(objext, $1)=$objext
+
+- irix5* | irix6* | nonstopux*)
+- if test "$GCC" = yes; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+- else
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir'
+- fi
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+- ;;
++# Code to be used in simple compile tests
++lt_simple_compile_test_code="class foo {}"
+
+- netbsd*)
+- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out
+- else
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF
+- fi
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- ;;
++# Code to be used in simple link tests
++lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }'
+
+- newsos6)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- ;;
++# ltmain only uses $CC for tagged configurations so make sure $CC is set.
++_LT_TAG_COMPILER
++
++# save warnings/boilerplate of simple test code
++_LT_COMPILER_BOILERPLATE
++_LT_LINKER_BOILERPLATE
++
++# Allow CC to be a program name with arguments.
++lt_save_CC="$CC"
++lt_save_GCC=$GCC
++GCC=yes
++CC=${GCJ-"gcj"}
++compiler=$CC
++_LT_TAGVAR(compiler, $1)=$CC
++_LT_TAGVAR(LD, $1)="$LD"
++_LT_CC_BASENAME([$compiler])
+
+- openbsd*)
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+- else
+- case $host_os in
+- openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+- ;;
+- *)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+- ;;
+- esac
+- fi
+- ;;
++# GCJ did not exist at the time GCC didn't implicitly link libc in.
++_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+
+- os2*)
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+- _LT_AC_TAGVAR(archive_cmds, $1)='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
+- _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
+- ;;
++_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+
+- osf3*)
+- if test "$GCC" = yes; then
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+- else
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+- fi
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+- ;;
++## CAVEAT EMPTOR:
++## There is no encapsulation within the following macros, do not change
++## the running order or otherwise move them around unless you know exactly
++## what you are doing...
++if test -n "$compiler"; then
++ _LT_COMPILER_NO_RTTI($1)
++ _LT_COMPILER_PIC($1)
++ _LT_COMPILER_C_O($1)
++ _LT_COMPILER_FILE_LOCKS($1)
++ _LT_LINKER_SHLIBS($1)
++ _LT_LINKER_HARDCODE_LIBPATH($1)
+
+- osf4* | osf5*) # as osf3* with the addition of -msym flag
+- if test "$GCC" = yes; then
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+- else
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~
+- $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp'
++ _LT_CONFIG($1)
++fi
+
+- # Both c and cxx compiler support -rpath directly
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
+- fi
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+- ;;
++AC_LANG_RESTORE
+
+- solaris*)
+- _LT_AC_TAGVAR(no_undefined_flag, $1)=' -z text'
+- if test "$GCC" = yes; then
+- wlarc='${wl}'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+- $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp'
+- else
+- wlarc=''
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+- $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
+- fi
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- case $host_os in
+- solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
+- *)
+- # The compiler driver will combine linker options so we
+- # cannot just pass the convience library names through
+- # without $wl, iff we do not link with $LD.
+- # Luckily, gcc supports the same syntax we need for Sun Studio.
+- # Supported since Solaris 2.6 (maybe 2.5.1?)
+- case $wlarc in
+- '')
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' ;;
+- *)
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;;
+- esac ;;
+- esac
+- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+- ;;
++GCC=$lt_save_GCC
++CC="$lt_save_CC"
++])# _LT_LANG_GCJ_CONFIG
+
+- sunos4*)
+- if test "x$host_vendor" = xsequent; then
+- # Use $CC to link under sequent, because it throws in some extra .o
+- # files that make .init and .fini sections work.
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+- else
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
+- fi
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- ;;
+
+- sysv4)
+- case $host_vendor in
+- sni)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes # is this really true???
+- ;;
+- siemens)
+- ## LD is ld it makes a PLAMLIB
+- ## CC just makes a GrossModule.
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+- _LT_AC_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs'
+- _LT_AC_TAGVAR(hardcode_direct, $1)=no
+- ;;
+- motorola)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+- _LT_AC_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie
+- ;;
+- esac
+- runpath_var='LD_RUN_PATH'
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- ;;
++# _LT_LANG_RC_CONFIG([TAG])
++# -------------------------
++# Ensure that the configuration variables for the Windows resource compiler
++# are suitably defined. These variables are subsequently used by _LT_CONFIG
++# to write the compiler configuration to `libtool'.
++m4_defun([_LT_LANG_RC_CONFIG],
++[AC_REQUIRE([LT_PROG_RC])dnl
++AC_LANG_SAVE
+
+- sysv4.3*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport'
+- ;;
++# Source file extension for RC test sources.
++ac_ext=rc
+
+- sysv4*MP*)
+- if test -d /usr/nec; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- runpath_var=LD_RUN_PATH
+- hardcode_runpath_var=yes
+- _LT_AC_TAGVAR(ld_shlibs, $1)=yes
+- fi
+- ;;
++# Object file extension for compiled RC test sources.
++objext=o
++_LT_TAGVAR(objext, $1)=$objext
+
+- sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7*)
+- _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- runpath_var='LD_RUN_PATH'
++# Code to be used in simple compile tests
++lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }'
+
+- if test "$GCC" = yes; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+- else
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+- fi
+- ;;
++# Code to be used in simple link tests
++lt_simple_link_test_code="$lt_simple_compile_test_code"
+
+- sysv5* | sco3.2v5* | sco5v6*)
+- # Note: We can NOT use -z defs as we might desire, because we do not
+- # link with -lc, and that would cause any symbols used from libc to
+- # always be unresolved, which means just about no library would
+- # ever link correctly. If we're not using GNU ld we use -z text
+- # though, which does catch some bad symbols but isn't as heavy-handed
+- # as -z defs.
+- _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
+- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':'
+- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
+- runpath_var='LD_RUN_PATH'
++# ltmain only uses $CC for tagged configurations so make sure $CC is set.
++_LT_TAG_COMPILER
+
+- if test "$GCC" = yes; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+- else
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+- fi
+- ;;
++# save warnings/boilerplate of simple test code
++_LT_COMPILER_BOILERPLATE
++_LT_LINKER_BOILERPLATE
+
+- uts4*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- ;;
++# Allow CC to be a program name with arguments.
++lt_save_CC="$CC"
++lt_save_GCC=$GCC
++GCC=
++CC=${RC-"windres"}
++compiler=$CC
++_LT_TAGVAR(compiler, $1)=$CC
++_LT_CC_BASENAME([$compiler])
++_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
+
+- *)
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- esac
+- fi
+-])
+-AC_MSG_RESULT([$_LT_AC_TAGVAR(ld_shlibs, $1)])
+-test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
++if test -n "$compiler"; then
++ :
++ _LT_CONFIG($1)
++fi
+
+-#
+-# Do we need to explicitly link libc?
+-#
+-case "x$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)" in
+-x|xyes)
+- # Assume -lc should be added
+- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
++GCC=$lt_save_GCC
++AC_LANG_RESTORE
++CC="$lt_save_CC"
++])# _LT_LANG_RC_CONFIG
+
+- if test "$enable_shared" = yes && test "$GCC" = yes; then
+- case $_LT_AC_TAGVAR(archive_cmds, $1) in
+- *'~'*)
+- # FIXME: we may have to deal with multi-command sequences.
+- ;;
+- '$CC '*)
+- # Test whether the compiler implicitly links with -lc since on some
+- # systems, -lgcc has to come before -lc. If gcc already passes -lc
+- # to ld, don't add -lc before -lgcc.
+- AC_MSG_CHECKING([whether -lc should be explicitly linked in])
+- $rm conftest*
+- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+- if AC_TRY_EVAL(ac_compile) 2>conftest.err; then
+- soname=conftest
+- lib=conftest
+- libobjs=conftest.$ac_objext
+- deplibs=
+- wl=$_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)
+- pic_flag=$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)
+- compiler_flags=-v
+- linker_flags=-v
+- verstring=
+- output_objdir=.
+- libname=conftest
+- lt_save_allow_undefined_flag=$_LT_AC_TAGVAR(allow_undefined_flag, $1)
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=
+- if AC_TRY_EVAL(_LT_AC_TAGVAR(archive_cmds, $1) 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1)
+- then
+- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+- else
+- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
+- fi
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag
+- else
+- cat conftest.err 1>&5
+- fi
+- $rm conftest*
+- AC_MSG_RESULT([$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)])
+- ;;
+- esac
+- fi
+- ;;
+-esac
+-])# AC_LIBTOOL_PROG_LD_SHLIBS
++# LT_PROG_GCJ
++# -----------
++AC_DEFUN([LT_PROG_GCJ],
++[m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ],
++ [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ],
++ [AC_CHECK_TOOL(GCJ, gcj,)
++ test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2"
++ AC_SUBST(GCJFLAGS)])])[]dnl
++])
+
++# Old name:
++AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ])
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([LT_AC_PROG_GCJ], [])
+
+-# _LT_AC_FILE_LTDLL_C
+-# -------------------
+-# Be careful that the start marker always follows a newline.
+-AC_DEFUN([_LT_AC_FILE_LTDLL_C], [
+-# /* ltdll.c starts here */
+-# #define WIN32_LEAN_AND_MEAN
+-# #include <windows.h>
+-# #undef WIN32_LEAN_AND_MEAN
+-# #include <stdio.h>
+-#
+-# #ifndef __CYGWIN__
+-# # ifdef __CYGWIN32__
+-# # define __CYGWIN__ __CYGWIN32__
+-# # endif
+-# #endif
+-#
+-# #ifdef __cplusplus
+-# extern "C" {
+-# #endif
+-# BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved);
+-# #ifdef __cplusplus
+-# }
+-# #endif
+-#
+-# #ifdef __CYGWIN__
+-# #include <cygwin/cygwin_dll.h>
+-# DECLARE_CYGWIN_DLL( DllMain );
+-# #endif
+-# HINSTANCE __hDllInstance_base;
+-#
+-# BOOL APIENTRY
+-# DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved)
+-# {
+-# __hDllInstance_base = hInst;
+-# return TRUE;
+-# }
+-# /* ltdll.c ends here */
+-])# _LT_AC_FILE_LTDLL_C
+
++# LT_PROG_RC
++# ----------
++AC_DEFUN([LT_PROG_RC],
++[AC_CHECK_TOOL(RC, windres,)
++])
+
+-# _LT_AC_TAGVAR(VARNAME, [TAGNAME])
+-# ---------------------------------
+-AC_DEFUN([_LT_AC_TAGVAR], [ifelse([$2], [], [$1], [$1_$2])])
++# Old name:
++AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC])
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([LT_AC_PROG_RC], [])
+
+
+-# old names
+-AC_DEFUN([AM_PROG_LIBTOOL], [AC_PROG_LIBTOOL])
+-AC_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)])
+-AC_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)])
+-AC_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)])
+-AC_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)])
+-AC_DEFUN([AM_PROG_LD], [AC_PROG_LD])
+-AC_DEFUN([AM_PROG_NM], [AC_PROG_NM])
+-
+-# This is just to silence aclocal about the macro not being used
+-ifelse([AC_DISABLE_FAST_INSTALL])
+-
+-AC_DEFUN([LT_AC_PROG_GCJ],
+-[AC_CHECK_TOOL(GCJ, gcj, no)
+- test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2"
+- AC_SUBST(GCJFLAGS)
++# _LT_DECL_EGREP
++# --------------
++# If we don't have a new enough Autoconf to choose the best grep
++# available, choose the one first in the user's PATH.
++m4_defun([_LT_DECL_EGREP],
++[AC_REQUIRE([AC_PROG_EGREP])dnl
++AC_REQUIRE([AC_PROG_FGREP])dnl
++test -z "$GREP" && GREP=grep
++_LT_DECL([], [GREP], [1], [A grep program that handles long lines])
++_LT_DECL([], [EGREP], [1], [An ERE matcher])
++_LT_DECL([], [FGREP], [1], [A literal string matcher])
++dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too
++AC_SUBST([GREP])
+ ])
+
+-AC_DEFUN([LT_AC_PROG_RC],
+-[AC_CHECK_TOOL(RC, windres, no)
+-])
+
++# _LT_DECL_SED
++# ------------
++# Check for a fully-functional sed program, that truncates
++# as few characters as possible. Prefer GNU sed if found.
++m4_defun([_LT_DECL_SED],
++[AC_PROG_SED
++test -z "$SED" && SED=sed
++Xsed="$SED -e 1s/^X//"
++_LT_DECL([], [SED], [1], [A sed program that does not truncate output])
++_LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"],
++ [Sed that helps us avoid accidentally triggering echo(1) options like -n])
++])# _LT_DECL_SED
++
++m4_ifndef([AC_PROG_SED], [
+ ############################################################
+ # NOTE: This macro has been submitted for inclusion into #
+ # GNU Autoconf as AC_PROG_SED. When it is available in #
+ # a released version of Autoconf we should remove this #
+ # macro and use it instead. #
+ ############################################################
+-# LT_AC_PROG_SED
+-# --------------
+-# Check for a fully-functional sed program, that truncates
+-# as few characters as possible. Prefer GNU sed if found.
+-AC_DEFUN([LT_AC_PROG_SED],
++
++m4_defun([AC_PROG_SED],
+ [AC_MSG_CHECKING([for a sed that does not truncate output])
+ AC_CACHE_VAL(lt_cv_path_SED,
+ [# Loop through the user's path and test for sed and gsed.
+@@ -6435,6 +7010,7 @@ do
+ done
+ done
+ done
++IFS=$as_save_IFS
+ lt_ac_max=0
+ lt_ac_count=0
+ # Add /usr/xpg4/bin/sed as it is typically found on Solaris
+@@ -6467,5 +7043,268 @@ for lt_ac_sed in $lt_ac_sed_list /usr/xp
+ done
+ ])
+ SED=$lt_cv_path_SED
++AC_SUBST([SED])
+ AC_MSG_RESULT([$SED])
++])#AC_PROG_SED
++])#m4_ifndef
++
++# Old name:
++AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED])
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([LT_AC_PROG_SED], [])
++
++
++# _LT_CHECK_SHELL_FEATURES
++# ------------------------
++# Find out whether the shell is Bourne or XSI compatible,
++# or has some other useful features.
++m4_defun([_LT_CHECK_SHELL_FEATURES],
++[AC_MSG_CHECKING([whether the shell understands some XSI constructs])
++# Try some XSI features
++xsi_shell=no
++( _lt_dummy="a/b/c"
++ test "${_lt_dummy##*/},${_lt_dummy%/*},"${_lt_dummy%"$_lt_dummy"}, \
++ = c,a/b,, \
++ && eval 'test $(( 1 + 1 )) -eq 2 \
++ && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \
++ && xsi_shell=yes
++AC_MSG_RESULT([$xsi_shell])
++_LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell'])
++
++AC_MSG_CHECKING([whether the shell understands "+="])
++lt_shell_append=no
++( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \
++ >/dev/null 2>&1 \
++ && lt_shell_append=yes
++AC_MSG_RESULT([$lt_shell_append])
++_LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append'])
++
++if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
++ lt_unset=unset
++else
++ lt_unset=false
++fi
++_LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl
++
++# test EBCDIC or ASCII
++case `echo X|tr X '\101'` in
++ A) # ASCII based system
++ # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
++ lt_SP2NL='tr \040 \012'
++ lt_NL2SP='tr \015\012 \040\040'
++ ;;
++ *) # EBCDIC based system
++ lt_SP2NL='tr \100 \n'
++ lt_NL2SP='tr \r\n \100\100'
++ ;;
++esac
++_LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl
++_LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl
++])# _LT_CHECK_SHELL_FEATURES
++
++
++# _LT_PROG_XSI_SHELLFNS
++# ---------------------
++# Bourne and XSI compatible variants of some useful shell functions.
++m4_defun([_LT_PROG_XSI_SHELLFNS],
++[case $xsi_shell in
++ yes)
++ cat << \_LT_EOF >> "$cfgfile"
++
++# func_dirname file append nondir_replacement
++# Compute the dirname of FILE. If nonempty, add APPEND to the result,
++# otherwise set result to NONDIR_REPLACEMENT.
++func_dirname ()
++{
++ case ${1} in
++ */*) func_dirname_result="${1%/*}${2}" ;;
++ * ) func_dirname_result="${3}" ;;
++ esac
++}
++
++# func_basename file
++func_basename ()
++{
++ func_basename_result="${1##*/}"
++}
++
++# func_dirname_and_basename file append nondir_replacement
++# perform func_basename and func_dirname in a single function
++# call:
++# dirname: Compute the dirname of FILE. If nonempty,
++# add APPEND to the result, otherwise set result
++# to NONDIR_REPLACEMENT.
++# value returned in "$func_dirname_result"
++# basename: Compute filename of FILE.
++# value retuned in "$func_basename_result"
++# Implementation must be kept synchronized with func_dirname
++# and func_basename. For efficiency, we do not delegate to
++# those functions but instead duplicate the functionality here.
++func_dirname_and_basename ()
++{
++ case ${1} in
++ */*) func_dirname_result="${1%/*}${2}" ;;
++ * ) func_dirname_result="${3}" ;;
++ esac
++ func_basename_result="${1##*/}"
++}
++
++# func_stripname prefix suffix name
++# strip PREFIX and SUFFIX off of NAME.
++# PREFIX and SUFFIX must not contain globbing or regex special
++# characters, hashes, percent signs, but SUFFIX may contain a leading
++# dot (in which case that matches only a dot).
++func_stripname ()
++{
++ # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
++ # positional parameters, so assign one to ordinary parameter first.
++ func_stripname_result=${3}
++ func_stripname_result=${func_stripname_result#"${1}"}
++ func_stripname_result=${func_stripname_result%"${2}"}
++}
++
++# func_opt_split
++func_opt_split ()
++{
++ func_opt_split_opt=${1%%=*}
++ func_opt_split_arg=${1#*=}
++}
++
++# func_lo2o object
++func_lo2o ()
++{
++ case ${1} in
++ *.lo) func_lo2o_result=${1%.lo}.${objext} ;;
++ *) func_lo2o_result=${1} ;;
++ esac
++}
++
++# func_xform libobj-or-source
++func_xform ()
++{
++ func_xform_result=${1%.*}.lo
++}
++
++# func_arith arithmetic-term...
++func_arith ()
++{
++ func_arith_result=$(( $[*] ))
++}
++
++# func_len string
++# STRING may not start with a hyphen.
++func_len ()
++{
++ func_len_result=${#1}
++}
++
++_LT_EOF
++ ;;
++ *) # Bourne compatible functions.
++ cat << \_LT_EOF >> "$cfgfile"
++
++# func_dirname file append nondir_replacement
++# Compute the dirname of FILE. If nonempty, add APPEND to the result,
++# otherwise set result to NONDIR_REPLACEMENT.
++func_dirname ()
++{
++ # Extract subdirectory from the argument.
++ func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"`
++ if test "X$func_dirname_result" = "X${1}"; then
++ func_dirname_result="${3}"
++ else
++ func_dirname_result="$func_dirname_result${2}"
++ fi
++}
++
++# func_basename file
++func_basename ()
++{
++ func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"`
++}
++
++dnl func_dirname_and_basename
++dnl A portable version of this function is already defined in general.m4sh
++dnl so there is no need for it here.
++
++# func_stripname prefix suffix name
++# strip PREFIX and SUFFIX off of NAME.
++# PREFIX and SUFFIX must not contain globbing or regex special
++# characters, hashes, percent signs, but SUFFIX may contain a leading
++# dot (in which case that matches only a dot).
++# func_strip_suffix prefix name
++func_stripname ()
++{
++ case ${2} in
++ .*) func_stripname_result=`$ECHO "X${3}" \
++ | $Xsed -e "s%^${1}%%" -e "s%\\\\${2}\$%%"`;;
++ *) func_stripname_result=`$ECHO "X${3}" \
++ | $Xsed -e "s%^${1}%%" -e "s%${2}\$%%"`;;
++ esac
++}
++
++# sed scripts:
++my_sed_long_opt='1s/^\(-[[^=]]*\)=.*/\1/;q'
++my_sed_long_arg='1s/^-[[^=]]*=//'
++
++# func_opt_split
++func_opt_split ()
++{
++ func_opt_split_opt=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_opt"`
++ func_opt_split_arg=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_arg"`
++}
++
++# func_lo2o object
++func_lo2o ()
++{
++ func_lo2o_result=`$ECHO "X${1}" | $Xsed -e "$lo2o"`
++}
++
++# func_xform libobj-or-source
++func_xform ()
++{
++ func_xform_result=`$ECHO "X${1}" | $Xsed -e 's/\.[[^.]]*$/.lo/'`
++}
++
++# func_arith arithmetic-term...
++func_arith ()
++{
++ func_arith_result=`expr "$[@]"`
++}
++
++# func_len string
++# STRING may not start with a hyphen.
++func_len ()
++{
++ func_len_result=`expr "$[1]" : ".*" 2>/dev/null || echo $max_cmd_len`
++}
++
++_LT_EOF
++esac
++
++case $lt_shell_append in
++ yes)
++ cat << \_LT_EOF >> "$cfgfile"
++
++# func_append var value
++# Append VALUE to the end of shell variable VAR.
++func_append ()
++{
++ eval "$[1]+=\$[2]"
++}
++_LT_EOF
++ ;;
++ *)
++ cat << \_LT_EOF >> "$cfgfile"
++
++# func_append var value
++# Append VALUE to the end of shell variable VAR.
++func_append ()
++{
++ eval "$[1]=\$$[1]\$[2]"
++}
++
++_LT_EOF
++ ;;
++ esac
+ ])
+--- a/m4/libtool.m4
++++ b/m4/libtool.m4
+@@ -1,107 +1,186 @@
+ # libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-
+-## Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006
+-## Free Software Foundation, Inc.
+-## Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
+-##
+-## This file is free software; the Free Software Foundation gives
+-## unlimited permission to copy and/or distribute it, with or without
+-## modifications, as long as this notice is preserved.
+-
+-# serial 48 AC_PROG_LIBTOOL
+-
+-
+-# AC_PROVIDE_IFELSE(MACRO-NAME, IF-PROVIDED, IF-NOT-PROVIDED)
+-# -----------------------------------------------------------
+-# If this macro is not defined by Autoconf, define it here.
+-m4_ifdef([AC_PROVIDE_IFELSE],
+- [],
+- [m4_define([AC_PROVIDE_IFELSE],
+- [m4_ifdef([AC_PROVIDE_$1],
+- [$2], [$3])])])
++#
++# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
++# 2006, 2007, 2008 Free Software Foundation, Inc.
++# Written by Gordon Matzigkeit, 1996
++#
++# This file is free software; the Free Software Foundation gives
++# unlimited permission to copy and/or distribute it, with or without
++# modifications, as long as this notice is preserved.
++
++m4_define([_LT_COPYING], [dnl
++# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
++# 2006, 2007, 2008 Free Software Foundation, Inc.
++# Written by Gordon Matzigkeit, 1996
++#
++# This file is part of GNU Libtool.
++#
++# GNU Libtool 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.
++#
++# As a special exception to the GNU General Public License,
++# if you distribute this file as part of a program or library that
++# is built using GNU Libtool, you may include this file under the
++# same distribution terms that you use for the rest of that program.
++#
++# GNU Libtool 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 GNU Libtool; see the file COPYING. If not, a copy
++# can be downloaded from http://www.gnu.org/licenses/gpl.html, or
++# obtained by writing to the Free Software Foundation, Inc.,
++# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
++])
+
++# serial 56 LT_INIT
+
+-# AC_PROG_LIBTOOL
+-# ---------------
+-AC_DEFUN([AC_PROG_LIBTOOL],
+-[AC_REQUIRE([_AC_PROG_LIBTOOL])dnl
+-dnl If AC_PROG_CXX has already been expanded, run AC_LIBTOOL_CXX
+-dnl immediately, otherwise, hook it in at the end of AC_PROG_CXX.
+- AC_PROVIDE_IFELSE([AC_PROG_CXX],
+- [AC_LIBTOOL_CXX],
+- [define([AC_PROG_CXX], defn([AC_PROG_CXX])[AC_LIBTOOL_CXX
+- ])])
+-dnl And a similar setup for Fortran 77 support
+- AC_PROVIDE_IFELSE([AC_PROG_F77],
+- [AC_LIBTOOL_F77],
+- [define([AC_PROG_F77], defn([AC_PROG_F77])[AC_LIBTOOL_F77
+-])])
+-
+-dnl Quote A][M_PROG_GCJ so that aclocal doesn't bring it in needlessly.
+-dnl If either AC_PROG_GCJ or A][M_PROG_GCJ have already been expanded, run
+-dnl AC_LIBTOOL_GCJ immediately, otherwise, hook it in at the end of both.
+- AC_PROVIDE_IFELSE([AC_PROG_GCJ],
+- [AC_LIBTOOL_GCJ],
+- [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],
+- [AC_LIBTOOL_GCJ],
+- [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ],
+- [AC_LIBTOOL_GCJ],
+- [ifdef([AC_PROG_GCJ],
+- [define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[AC_LIBTOOL_GCJ])])
+- ifdef([A][M_PROG_GCJ],
+- [define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[AC_LIBTOOL_GCJ])])
+- ifdef([LT_AC_PROG_GCJ],
+- [define([LT_AC_PROG_GCJ],
+- defn([LT_AC_PROG_GCJ])[AC_LIBTOOL_GCJ])])])])
+-])])# AC_PROG_LIBTOOL
+
++# LT_PREREQ(VERSION)
++# ------------------
++# Complain and exit if this libtool version is less that VERSION.
++m4_defun([LT_PREREQ],
++[m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1,
++ [m4_default([$3],
++ [m4_fatal([Libtool version $1 or higher is required],
++ 63)])],
++ [$2])])
+
+-# _AC_PROG_LIBTOOL
+-# ----------------
+-AC_DEFUN([_AC_PROG_LIBTOOL],
+-[AC_REQUIRE([AC_LIBTOOL_SETUP])dnl
+-AC_BEFORE([$0],[AC_LIBTOOL_CXX])dnl
+-AC_BEFORE([$0],[AC_LIBTOOL_F77])dnl
+-AC_BEFORE([$0],[AC_LIBTOOL_GCJ])dnl
++
++# _LT_CHECK_BUILDDIR
++# ------------------
++# Complain if the absolute build directory name contains unusual characters
++m4_defun([_LT_CHECK_BUILDDIR],
++[case `pwd` in
++ *\ * | *\ *)
++ AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;;
++esac
++])
++
++
++# LT_INIT([OPTIONS])
++# ------------------
++AC_DEFUN([LT_INIT],
++[AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT
++AC_BEFORE([$0], [LT_LANG])dnl
++AC_BEFORE([$0], [LT_OUTPUT])dnl
++AC_BEFORE([$0], [LTDL_INIT])dnl
++m4_require([_LT_CHECK_BUILDDIR])dnl
++
++dnl Autoconf doesn't catch unexpanded LT_ macros by default:
++m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl
++m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl
++dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4
++dnl unless we require an AC_DEFUNed macro:
++AC_REQUIRE([LTOPTIONS_VERSION])dnl
++AC_REQUIRE([LTSUGAR_VERSION])dnl
++AC_REQUIRE([LTVERSION_VERSION])dnl
++AC_REQUIRE([LTOBSOLETE_VERSION])dnl
++m4_require([_LT_PROG_LTMAIN])dnl
++
++dnl Parse OPTIONS
++_LT_SET_OPTIONS([$0], [$1])
+
+ # This can be used to rebuild libtool when needed
+-LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh"
++LIBTOOL_DEPS="$ltmain"
+
+ # Always use our own libtool.
+-LIBTOOL='$(SHELL) $(top_builddir)/libtool'
++LIBTOOL='$(SHELL) $(top_builddir)'
++LIBTOOL="$LIBTOOL/$host_alias-libtool"
+ AC_SUBST(LIBTOOL)dnl
+
+-# Prevent multiple expansion
+-define([AC_PROG_LIBTOOL], [])
+-])# _AC_PROG_LIBTOOL
++_LT_SETUP
+
++# Only expand once:
++m4_define([LT_INIT])
++])# LT_INIT
++
++# Old names:
++AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT])
++AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT])
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([AC_PROG_LIBTOOL], [])
++dnl AC_DEFUN([AM_PROG_LIBTOOL], [])
+
+-# AC_LIBTOOL_SETUP
+-# ----------------
+-AC_DEFUN([AC_LIBTOOL_SETUP],
+-[AC_PREREQ(2.50)dnl
+-AC_REQUIRE([AC_ENABLE_SHARED])dnl
+-AC_REQUIRE([AC_ENABLE_STATIC])dnl
+-AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl
+-AC_REQUIRE([AC_CANONICAL_HOST])dnl
++
++# _LT_CC_BASENAME(CC)
++# -------------------
++# Calculate cc_basename. Skip known compiler wrappers and cross-prefix.
++m4_defun([_LT_CC_BASENAME],
++[for cc_temp in $1""; do
++ case $cc_temp in
++ compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;;
++ distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;;
++ \-*) ;;
++ *) break;;
++ esac
++done
++cc_basename=`$ECHO "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
++])
++
++
++# _LT_FILEUTILS_DEFAULTS
++# ----------------------
++# It is okay to use these file commands and assume they have been set
++# sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'.
++m4_defun([_LT_FILEUTILS_DEFAULTS],
++[: ${CP="cp -f"}
++: ${MV="mv -f"}
++: ${RM="rm -f"}
++])# _LT_FILEUTILS_DEFAULTS
++
++
++# _LT_SETUP
++# ---------
++m4_defun([_LT_SETUP],
++[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+ AC_REQUIRE([AC_CANONICAL_BUILD])dnl
++_LT_DECL([], [host_alias], [0], [The host system])dnl
++_LT_DECL([], [host], [0])dnl
++_LT_DECL([], [host_os], [0])dnl
++dnl
++_LT_DECL([], [build_alias], [0], [The build system])dnl
++_LT_DECL([], [build], [0])dnl
++_LT_DECL([], [build_os], [0])dnl
++dnl
+ AC_REQUIRE([AC_PROG_CC])dnl
+-AC_REQUIRE([AC_PROG_LD])dnl
+-AC_REQUIRE([AC_PROG_LD_RELOAD_FLAG])dnl
+-AC_REQUIRE([AC_PROG_NM])dnl
+-
++AC_REQUIRE([LT_PATH_LD])dnl
++AC_REQUIRE([LT_PATH_NM])dnl
++dnl
+ AC_REQUIRE([AC_PROG_LN_S])dnl
+-AC_REQUIRE([AC_DEPLIBS_CHECK_METHOD])dnl
+-# Autoconf 2.13's AC_OBJEXT and AC_EXEEXT macros only works for C compilers!
+-AC_REQUIRE([AC_OBJEXT])dnl
+-AC_REQUIRE([AC_EXEEXT])dnl
++test -z "$LN_S" && LN_S="ln -s"
++_LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl
+ dnl
++AC_REQUIRE([LT_CMD_MAX_LEN])dnl
++_LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl
++_LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl
++dnl
++m4_require([_LT_FILEUTILS_DEFAULTS])dnl
++m4_require([_LT_CHECK_SHELL_FEATURES])dnl
++m4_require([_LT_CMD_RELOAD])dnl
++m4_require([_LT_CHECK_MAGIC_METHOD])dnl
++m4_require([_LT_CMD_OLD_ARCHIVE])dnl
++m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl
++
++_LT_CONFIG_LIBTOOL_INIT([
++# See if we are running on zsh, and set the options which allow our
++# commands through without removal of \ escapes INIT.
++if test -n "\${ZSH_VERSION+set}" ; then
++ setopt NO_GLOB_SUBST
++fi
++])
++if test -n "${ZSH_VERSION+set}" ; then
++ setopt NO_GLOB_SUBST
++fi
+
+-AC_LIBTOOL_SYS_MAX_CMD_LEN
+-AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE
+-AC_LIBTOOL_OBJDIR
++_LT_CHECK_OBJDIR
+
+-AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl
+-_LT_AC_PROG_ECHO_BACKSLASH
++m4_require([_LT_TAG_COMPILER])dnl
++_LT_PROG_ECHO_BACKSLASH
+
+ case $host_os in
+ aix3*)
+@@ -117,6307 +196,6803 @@ esac
+
+ # Sed substitution that helps us do robust quoting. It backslashifies
+ # metacharacters that are still active within double-quoted strings.
+-Xsed='sed -e 1s/^X//'
+-[sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g']
++sed_quote_subst='s/\([["`$\\]]\)/\\\1/g'
+
+ # Same as above, but do not quote variable references.
+-[double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g']
++double_quote_subst='s/\([["`\\]]\)/\\\1/g'
+
+ # Sed substitution to delay expansion of an escaped shell variable in a
+ # double_quote_subst'ed string.
+ delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
+
++# Sed substitution to delay expansion of an escaped single quote.
++delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g'
++
+ # Sed substitution to avoid accidental globbing in evaled expressions
+ no_glob_subst='s/\*/\\\*/g'
+
+-# Constants:
+-rm="rm -f"
+-
+ # Global variables:
+-default_ofile=libtool
++ofile=${host_alias}-libtool
+ can_build_shared=yes
+
+ # All known linkers require a `.a' archive for static linking (except MSVC,
+ # which needs '.lib').
+ libext=a
+-ltmain="$ac_aux_dir/ltmain.sh"
+-ofile="$default_ofile"
+-with_gnu_ld="$lt_cv_prog_gnu_ld"
+
+-AC_CHECK_TOOL(AR, ar, false)
+-AC_CHECK_TOOL(RANLIB, ranlib, :)
+-AC_CHECK_TOOL(STRIP, strip, :)
++with_gnu_ld="$lt_cv_prog_gnu_ld"
+
+ old_CC="$CC"
+ old_CFLAGS="$CFLAGS"
+
+ # Set sane defaults for various variables
+-test -z "$AR" && AR=ar
+-test -z "$AR_FLAGS" && AR_FLAGS=cru
+-test -z "$AS" && AS=as
+ test -z "$CC" && CC=cc
+ test -z "$LTCC" && LTCC=$CC
+ test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
+-test -z "$DLLTOOL" && DLLTOOL=dlltool
+ test -z "$LD" && LD=ld
+-test -z "$LN_S" && LN_S="ln -s"
+-test -z "$MAGIC_CMD" && MAGIC_CMD=file
+-test -z "$NM" && NM=nm
+-test -z "$SED" && SED=sed
+-test -z "$OBJDUMP" && OBJDUMP=objdump
+-test -z "$RANLIB" && RANLIB=:
+-test -z "$STRIP" && STRIP=:
+ test -z "$ac_objext" && ac_objext=o
+
+-# Determine commands to create old-style static archives.
+-old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs'
+-old_postinstall_cmds='chmod 644 $oldlib'
+-old_postuninstall_cmds=
+-
+-if test -n "$RANLIB"; then
+- case $host_os in
+- openbsd*)
+- old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib"
+- ;;
+- *)
+- old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib"
+- ;;
+- esac
+- old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
+-fi
+-
+ _LT_CC_BASENAME([$compiler])
+
+ # Only perform the check for file, if the check method requires it
++test -z "$MAGIC_CMD" && MAGIC_CMD=file
+ case $deplibs_check_method in
+ file_magic*)
+ if test "$file_magic_cmd" = '$MAGIC_CMD'; then
+- AC_PATH_MAGIC
++ _LT_PATH_MAGIC
+ fi
+ ;;
+ esac
+
+-AC_PROVIDE_IFELSE([AC_LIBTOOL_DLOPEN], enable_dlopen=yes, enable_dlopen=no)
+-AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL],
+-enable_win32_dll=yes, enable_win32_dll=no)
+-
+-AC_ARG_ENABLE([libtool-lock],
+- [AC_HELP_STRING([--disable-libtool-lock],
+- [avoid locking (might break parallel builds)])])
+-test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
++# Use C for the default configuration in the libtool script
++LT_SUPPORTED_TAG([CC])
++_LT_LANG_C_CONFIG
++_LT_LANG_DEFAULT_CONFIG
++_LT_CONFIG_COMMANDS
++])# _LT_SETUP
+
+-AC_ARG_WITH([pic],
+- [AC_HELP_STRING([--with-pic],
+- [try to use only PIC/non-PIC objects @<:@default=use both@:>@])],
+- [pic_mode="$withval"],
+- [pic_mode=default])
+-test -z "$pic_mode" && pic_mode=default
+
+-# Use C for the default configuration in the libtool script
+-tagname=
+-AC_LIBTOOL_LANG_C_CONFIG
+-_LT_AC_TAGCONFIG
+-])# AC_LIBTOOL_SETUP
++# _LT_PROG_LTMAIN
++# ---------------
++# Note that this code is called both from `configure', and `config.status'
++# now that we use AC_CONFIG_COMMANDS to generate libtool. Notably,
++# `config.status' has no value for ac_aux_dir unless we are using Automake,
++# so we pass a copy along to make sure it has a sensible value anyway.
++m4_defun([_LT_PROG_LTMAIN],
++[m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl
++_LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir'])
++ltmain="$ac_aux_dir/ltmain.sh"
++])# _LT_PROG_LTMAIN
+
+
+-# _LT_AC_SYS_COMPILER
+-# -------------------
+-AC_DEFUN([_LT_AC_SYS_COMPILER],
+-[AC_REQUIRE([AC_PROG_CC])dnl
++## ------------------------------------- ##
++## Accumulate code for creating libtool. ##
++## ------------------------------------- ##
++
++# So that we can recreate a full libtool script including additional
++# tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS
++# in macros and then make a single call at the end using the `libtool'
++# label.
++
++
++# _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS])
++# ----------------------------------------
++# Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later.
++m4_define([_LT_CONFIG_LIBTOOL_INIT],
++[m4_ifval([$1],
++ [m4_append([_LT_OUTPUT_LIBTOOL_INIT],
++ [$1
++])])])
++
++# Initialize.
++m4_define([_LT_OUTPUT_LIBTOOL_INIT])
++
++
++# _LT_CONFIG_LIBTOOL([COMMANDS])
++# ------------------------------
++# Register COMMANDS to be passed to AC_CONFIG_COMMANDS later.
++m4_define([_LT_CONFIG_LIBTOOL],
++[m4_ifval([$1],
++ [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS],
++ [$1
++])])])
++
++# Initialize.
++m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS])
++
++
++# _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS])
++# -----------------------------------------------------
++m4_defun([_LT_CONFIG_SAVE_COMMANDS],
++[_LT_CONFIG_LIBTOOL([$1])
++_LT_CONFIG_LIBTOOL_INIT([$2])
++])
+
+-# If no C compiler was specified, use CC.
+-LTCC=${LTCC-"$CC"}
+
+-# If no C compiler flags were specified, use CFLAGS.
+-LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
++# _LT_FORMAT_COMMENT([COMMENT])
++# -----------------------------
++# Add leading comment marks to the start of each line, and a trailing
++# full-stop to the whole comment if one is not present already.
++m4_define([_LT_FORMAT_COMMENT],
++[m4_ifval([$1], [
++m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])],
++ [['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.])
++)])
+
+-# Allow CC to be a program name with arguments.
+-compiler=$CC
+-])# _LT_AC_SYS_COMPILER
+
+
+-# _LT_CC_BASENAME(CC)
+-# -------------------
+-# Calculate cc_basename. Skip known compiler wrappers and cross-prefix.
+-AC_DEFUN([_LT_CC_BASENAME],
+-[for cc_temp in $1""; do
+- case $cc_temp in
+- compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;;
+- distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;;
+- \-*) ;;
+- *) break;;
+- esac
+-done
+-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
++## ------------------------ ##
++## FIXME: Eliminate VARNAME ##
++## ------------------------ ##
++
++
++# _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?])
++# -------------------------------------------------------------------
++# CONFIGNAME is the name given to the value in the libtool script.
++# VARNAME is the (base) name used in the configure script.
++# VALUE may be 0, 1 or 2 for a computed quote escaped value based on
++# VARNAME. Any other value will be used directly.
++m4_define([_LT_DECL],
++[lt_if_append_uniq([lt_decl_varnames], [$2], [, ],
++ [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name],
++ [m4_ifval([$1], [$1], [$2])])
++ lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3])
++ m4_ifval([$4],
++ [lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])])
++ lt_dict_add_subkey([lt_decl_dict], [$2],
++ [tagged?], [m4_ifval([$5], [yes], [no])])])
+ ])
+
+
+-# _LT_COMPILER_BOILERPLATE
+-# ------------------------
+-# Check for compiler boilerplate output or warnings with
+-# the simple compiler test code.
+-AC_DEFUN([_LT_COMPILER_BOILERPLATE],
+-[ac_outfile=conftest.$ac_objext
+-printf "$lt_simple_compile_test_code" >conftest.$ac_ext
+-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+-_lt_compiler_boilerplate=`cat conftest.err`
+-$rm conftest*
+-])# _LT_COMPILER_BOILERPLATE
+-
++# _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION])
++# --------------------------------------------------------
++m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])])
++
++
++# lt_decl_tag_varnames([SEPARATOR], [VARNAME1...])
++# ------------------------------------------------
++m4_define([lt_decl_tag_varnames],
++[_lt_decl_filter([tagged?], [yes], $@)])
++
++
++# _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..])
++# ---------------------------------------------------------
++m4_define([_lt_decl_filter],
++[m4_case([$#],
++ [0], [m4_fatal([$0: too few arguments: $#])],
++ [1], [m4_fatal([$0: too few arguments: $#: $1])],
++ [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)],
++ [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)],
++ [lt_dict_filter([lt_decl_dict], $@)])[]dnl
++])
+
+-# _LT_LINKER_BOILERPLATE
+-# ----------------------
+-# Check for linker boilerplate output or warnings with
+-# the simple link test code.
+-AC_DEFUN([_LT_LINKER_BOILERPLATE],
+-[ac_outfile=conftest.$ac_objext
+-printf "$lt_simple_link_test_code" >conftest.$ac_ext
+-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+-_lt_linker_boilerplate=`cat conftest.err`
+-$rm conftest*
+-])# _LT_LINKER_BOILERPLATE
+
++# lt_decl_quote_varnames([SEPARATOR], [VARNAME1...])
++# --------------------------------------------------
++m4_define([lt_decl_quote_varnames],
++[_lt_decl_filter([value], [1], $@)])
++
++
++# lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...])
++# ---------------------------------------------------
++m4_define([lt_decl_dquote_varnames],
++[_lt_decl_filter([value], [2], $@)])
++
++
++# lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...])
++# ---------------------------------------------------
++m4_define([lt_decl_varnames_tagged],
++[_$0(m4_quote(m4_default([$1], [[, ]])),
++ m4_quote(m4_if([$2], [],
++ m4_quote(lt_decl_tag_varnames),
++ m4_quote(m4_shift($@)))),
++ m4_split(m4_normalize(m4_quote(_LT_TAGS))))])
++m4_define([_lt_decl_varnames_tagged], [lt_combine([$1], [$2], [_], $3)])
++
++
++# lt_decl_all_varnames([SEPARATOR], [VARNAME1...])
++# ------------------------------------------------
++m4_define([lt_decl_all_varnames],
++[_$0(m4_quote(m4_default([$1], [[, ]])),
++ m4_if([$2], [],
++ m4_quote(lt_decl_varnames),
++ m4_quote(m4_shift($@))))[]dnl
++])
++m4_define([_lt_decl_all_varnames],
++[lt_join($@, lt_decl_varnames_tagged([$1],
++ lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl
++])
+
+-# _LT_AC_SYS_LIBPATH_AIX
+-# ----------------------
+-# Links a minimal program and checks the executable
+-# for the system default hardcoded library path. In most cases,
+-# this is /usr/lib:/lib, but when the MPI compilers are used
+-# the location of the communication and MPI libs are included too.
+-# If we don't find anything, use the default library path according
+-# to the aix ld manual.
+-AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX],
+-[AC_LINK_IFELSE(AC_LANG_PROGRAM,[
+-aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
+-}'`
+-# Check for a 64-bit object if we didn't find anything.
+-if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
+-}'`; fi],[])
+-if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+-])# _LT_AC_SYS_LIBPATH_AIX
+
++# _LT_CONFIG_STATUS_DECLARE([VARNAME])
++# ------------------------------------
++# Quote a variable value, and forward it to `config.status' so that its
++# declaration there will have the same value as in `configure'. VARNAME
++# must have a single quote delimited value for this to work.
++m4_define([_LT_CONFIG_STATUS_DECLARE],
++[$1='`$ECHO "X$][$1" | $Xsed -e "$delay_single_quote_subst"`'])
+
+-# _LT_AC_SHELL_INIT(ARG)
+-# ----------------------
+-AC_DEFUN([_LT_AC_SHELL_INIT],
+-[ifdef([AC_DIVERSION_NOTICE],
+- [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)],
+- [AC_DIVERT_PUSH(NOTICE)])
+-$1
+-AC_DIVERT_POP
+-])# _LT_AC_SHELL_INIT
+
++# _LT_CONFIG_STATUS_DECLARATIONS
++# ------------------------------
++# We delimit libtool config variables with single quotes, so when
++# we write them to config.status, we have to be sure to quote all
++# embedded single quotes properly. In configure, this macro expands
++# each variable declared with _LT_DECL (and _LT_TAGDECL) into:
++#
++# <var>='`$ECHO "X$<var>" | $Xsed -e "$delay_single_quote_subst"`'
++m4_defun([_LT_CONFIG_STATUS_DECLARATIONS],
++[m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames),
++ [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])])
+
+-# _LT_AC_PROG_ECHO_BACKSLASH
+-# --------------------------
+-# Add some code to the start of the generated configure script which
+-# will find an echo command which doesn't interpret backslashes.
+-AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH],
+-[_LT_AC_SHELL_INIT([
+-# Check that we are running under the correct shell.
+-SHELL=${CONFIG_SHELL-/bin/sh}
+
+-case X$ECHO in
+-X*--fallback-echo)
+- # Remove one level of quotation (which was required for Make).
+- ECHO=`echo "$ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','`
+- ;;
+-esac
++# _LT_LIBTOOL_TAGS
++# ----------------
++# Output comment and list of tags supported by the script
++m4_defun([_LT_LIBTOOL_TAGS],
++[_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl
++available_tags="_LT_TAGS"dnl
++])
+
+-echo=${ECHO-echo}
+-if test "X[$]1" = X--no-reexec; then
+- # Discard the --no-reexec flag, and continue.
+- shift
+-elif test "X[$]1" = X--fallback-echo; then
+- # Avoid inline document here, it may be left over
+- :
+-elif test "X`($echo '\t') 2>/dev/null`" = 'X\t' ; then
+- # Yippee, $echo works!
+- :
+-else
+- # Restart under the correct shell.
+- exec $SHELL "[$]0" --no-reexec ${1+"[$]@"}
+-fi
+
+-if test "X[$]1" = X--fallback-echo; then
+- # used as fallback echo
+- shift
+- cat <<EOF
+-[$]*
+-EOF
+- exit 0
+-fi
++# _LT_LIBTOOL_DECLARE(VARNAME, [TAG])
++# -----------------------------------
++# Extract the dictionary values for VARNAME (optionally with TAG) and
++# expand to a commented shell variable setting:
++#
++# # Some comment about what VAR is for.
++# visible_name=$lt_internal_name
++m4_define([_LT_LIBTOOL_DECLARE],
++[_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1],
++ [description])))[]dnl
++m4_pushdef([_libtool_name],
++ m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl
++m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])),
++ [0], [_libtool_name=[$]$1],
++ [1], [_libtool_name=$lt_[]$1],
++ [2], [_libtool_name=$lt_[]$1],
++ [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl
++m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl
++])
+
+-# The HP-UX ksh and POSIX shell print the target directory to stdout
+-# if CDPATH is set.
+-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+-if test -z "$ECHO"; then
+-if test "X${echo_test_string+set}" != Xset; then
+-# find a string as large as possible, as long as the shell can cope with it
+- for cmd in 'sed 50q "[$]0"' 'sed 20q "[$]0"' 'sed 10q "[$]0"' 'sed 2q "[$]0"' 'echo test'; do
+- # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ...
+- if (echo_test_string=`eval $cmd`) 2>/dev/null &&
+- echo_test_string=`eval $cmd` &&
+- (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null
+- then
+- break
+- fi
+- done
+-fi
++# _LT_LIBTOOL_CONFIG_VARS
++# -----------------------
++# Produce commented declarations of non-tagged libtool config variables
++# suitable for insertion in the LIBTOOL CONFIG section of the `libtool'
++# script. Tagged libtool config variables (even for the LIBTOOL CONFIG
++# section) are produced by _LT_LIBTOOL_TAG_VARS.
++m4_defun([_LT_LIBTOOL_CONFIG_VARS],
++[m4_foreach([_lt_var],
++ m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)),
++ [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])])
+
+-if test "X`($echo '\t') 2>/dev/null`" = 'X\t' &&
+- echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` &&
+- test "X$echo_testing_string" = "X$echo_test_string"; then
+- :
+-else
+- # The Solaris, AIX, and Digital Unix default echo programs unquote
+- # backslashes. This makes it impossible to quote backslashes using
+- # echo "$something" | sed 's/\\/\\\\/g'
+- #
+- # So, first we look for a working echo in the user's PATH.
+
+- lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+- for dir in $PATH /usr/ucb; do
+- IFS="$lt_save_ifs"
+- if (test -f $dir/echo || test -f $dir/echo$ac_exeext) &&
+- test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' &&
+- echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` &&
+- test "X$echo_testing_string" = "X$echo_test_string"; then
+- echo="$dir/echo"
+- break
+- fi
+- done
+- IFS="$lt_save_ifs"
++# _LT_LIBTOOL_TAG_VARS(TAG)
++# -------------------------
++m4_define([_LT_LIBTOOL_TAG_VARS],
++[m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames),
++ [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])])
+
+- if test "X$echo" = Xecho; then
+- # We didn't find a better echo, so look for alternatives.
+- if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' &&
+- echo_testing_string=`(print -r "$echo_test_string") 2>/dev/null` &&
+- test "X$echo_testing_string" = "X$echo_test_string"; then
+- # This shell has a builtin print -r that does the trick.
+- echo='print -r'
+- elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) &&
+- test "X$CONFIG_SHELL" != X/bin/ksh; then
+- # If we have ksh, try running configure again with it.
+- ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
+- export ORIGINAL_CONFIG_SHELL
+- CONFIG_SHELL=/bin/ksh
+- export CONFIG_SHELL
+- exec $CONFIG_SHELL "[$]0" --no-reexec ${1+"[$]@"}
+- else
+- # Try using printf.
+- echo='printf %s\n'
+- if test "X`($echo '\t') 2>/dev/null`" = 'X\t' &&
+- echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` &&
+- test "X$echo_testing_string" = "X$echo_test_string"; then
+- # Cool, printf works
+- :
+- elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` &&
+- test "X$echo_testing_string" = 'X\t' &&
+- echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
+- test "X$echo_testing_string" = "X$echo_test_string"; then
+- CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL
+- export CONFIG_SHELL
+- SHELL="$CONFIG_SHELL"
+- export SHELL
+- echo="$CONFIG_SHELL [$]0 --fallback-echo"
+- elif echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` &&
+- test "X$echo_testing_string" = 'X\t' &&
+- echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
+- test "X$echo_testing_string" = "X$echo_test_string"; then
+- echo="$CONFIG_SHELL [$]0 --fallback-echo"
+- else
+- # maybe with a smaller string...
+- prev=:
+
+- for cmd in 'echo test' 'sed 2q "[$]0"' 'sed 10q "[$]0"' 'sed 20q "[$]0"' 'sed 50q "[$]0"'; do
+- if (test "X$echo_test_string" = "X`eval $cmd`") 2>/dev/null
+- then
+- break
+- fi
+- prev="$cmd"
+- done
++# _LT_TAGVAR(VARNAME, [TAGNAME])
++# ------------------------------
++m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])])
+
+- if test "$prev" != 'sed 50q "[$]0"'; then
+- echo_test_string=`eval $prev`
+- export echo_test_string
+- exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "[$]0" ${1+"[$]@"}
+- else
+- # Oops. We lost completely, so just stick with echo.
+- echo=echo
+- fi
+- fi
+- fi
+- fi
+-fi
+-fi
+
+-# Copy echo and quote the copy suitably for passing to libtool from
+-# the Makefile, instead of quoting the original, which is used later.
+-ECHO=$echo
+-if test "X$ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then
+- ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo"
+-fi
++# _LT_CONFIG_COMMANDS
++# -------------------
++# Send accumulated output to $CONFIG_STATUS. Thanks to the lists of
++# variables for single and double quote escaping we saved from calls
++# to _LT_DECL, we can put quote escaped variables declarations
++# into `config.status', and then the shell code to quote escape them in
++# for loops in `config.status'. Finally, any additional code accumulated
++# from calls to _LT_CONFIG_LIBTOOL_INIT is expanded.
++m4_defun([_LT_CONFIG_COMMANDS],
++[AC_PROVIDE_IFELSE([LT_OUTPUT],
++ dnl If the libtool generation code has been placed in $CONFIG_LT,
++ dnl instead of duplicating it all over again into config.status,
++ dnl then we will have config.status run $CONFIG_LT later, so it
++ dnl needs to know what name is stored there:
++ [AC_CONFIG_COMMANDS([libtool],
++ [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])],
++ dnl If the libtool generation code is destined for config.status,
++ dnl expand the accumulated commands and init code now:
++ [AC_CONFIG_COMMANDS([libtool],
++ [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])])
++])#_LT_CONFIG_COMMANDS
+
+-AC_SUBST(ECHO)
+-])])# _LT_AC_PROG_ECHO_BACKSLASH
+
++# Initialize.
++m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT],
++[
+
+-# _LT_AC_LOCK
+-# -----------
+-AC_DEFUN([_LT_AC_LOCK],
+-[AC_ARG_ENABLE([libtool-lock],
+- [AC_HELP_STRING([--disable-libtool-lock],
+- [avoid locking (might break parallel builds)])])
+-test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
++# The HP-UX ksh and POSIX shell print the target directory to stdout
++# if CDPATH is set.
++(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+-# Some flags need to be propagated to the compiler or linker for good
+-# libtool support.
+-case $host in
+-ia64-*-hpux*)
+- # Find out which ABI we are using.
+- echo 'int i;' > conftest.$ac_ext
+- if AC_TRY_EVAL(ac_compile); then
+- case `/usr/bin/file conftest.$ac_objext` in
+- *ELF-32*)
+- HPUX_IA64_MODE="32"
+- ;;
+- *ELF-64*)
+- HPUX_IA64_MODE="64"
+- ;;
+- esac
+- fi
+- rm -rf conftest*
+- ;;
+-*-*-irix6*)
+- # Find out which ABI we are using.
+- echo '[#]line __oline__ "configure"' > conftest.$ac_ext
+- if AC_TRY_EVAL(ac_compile); then
+- if test "$lt_cv_prog_gnu_ld" = yes; then
+- case `/usr/bin/file conftest.$ac_objext` in
+- *32-bit*)
+- LD="${LD-ld} -melf32bsmip"
+- ;;
+- *N32*)
+- LD="${LD-ld} -melf32bmipn32"
++sed_quote_subst='$sed_quote_subst'
++double_quote_subst='$double_quote_subst'
++delay_variable_subst='$delay_variable_subst'
++_LT_CONFIG_STATUS_DECLARATIONS
++LTCC='$LTCC'
++LTCFLAGS='$LTCFLAGS'
++compiler='$compiler_DEFAULT'
++
++# Quote evaled strings.
++for var in lt_decl_all_varnames([[ \
++]], lt_decl_quote_varnames); do
++ case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in
++ *[[\\\\\\\`\\"\\\$]]*)
++ eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$sed_quote_subst\\"\\\`\\\\\\""
+ ;;
+- *64-bit*)
+- LD="${LD-ld} -melf64bmip"
++ *)
++ eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
+ ;;
+ esac
+- else
+- case `/usr/bin/file conftest.$ac_objext` in
+- *32-bit*)
+- LD="${LD-ld} -32"
+- ;;
+- *N32*)
+- LD="${LD-ld} -n32"
++done
++
++# Double-quote double-evaled strings.
++for var in lt_decl_all_varnames([[ \
++]], lt_decl_dquote_varnames); do
++ case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in
++ *[[\\\\\\\`\\"\\\$]]*)
++ eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\""
+ ;;
+- *64-bit*)
+- LD="${LD-ld} -64"
++ *)
++ eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
+ ;;
+ esac
+- fi
+- fi
+- rm -rf conftest*
++done
++
++# Fix-up fallback echo if it was mangled by the above quoting rules.
++case \$lt_ECHO in
++*'\\\[$]0 --fallback-echo"')dnl "
++ lt_ECHO=\`\$ECHO "X\$lt_ECHO" | \$Xsed -e 's/\\\\\\\\\\\\\\\[$]0 --fallback-echo"\[$]/\[$]0 --fallback-echo"/'\`
+ ;;
++esac
+
+-x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*|s390*-*linux*|sparc*-*linux*)
+- # Find out which ABI we are using.
+- echo 'int i;' > conftest.$ac_ext
+- if AC_TRY_EVAL(ac_compile); then
+- case `/usr/bin/file conftest.o` in
+- *32-bit*)
+- case $host in
+- x86_64-*linux*)
+- LD="${LD-ld} -m elf_i386"
+- ;;
+- ppc64-*linux*|powerpc64-*linux*)
+- LD="${LD-ld} -m elf32ppclinux"
+- ;;
+- s390x-*linux*)
+- LD="${LD-ld} -m elf_s390"
+- ;;
+- sparc64-*linux*)
+- LD="${LD-ld} -m elf32_sparc"
+- ;;
+- esac
+- ;;
+- *64-bit*)
+- case $host in
+- x86_64-*linux*)
+- LD="${LD-ld} -m elf_x86_64"
+- ;;
+- ppc*-*linux*|powerpc*-*linux*)
+- LD="${LD-ld} -m elf64ppc"
+- ;;
+- s390*-*linux*)
+- LD="${LD-ld} -m elf64_s390"
+- ;;
+- sparc*-*linux*)
+- LD="${LD-ld} -m elf64_sparc"
+- ;;
+- esac
+- ;;
+- esac
+- fi
+- rm -rf conftest*
+- ;;
++_LT_OUTPUT_LIBTOOL_INIT
++])
+
+-*-*-sco3.2v5*)
+- # On SCO OpenServer 5, we need -belf to get full-featured binaries.
+- SAVE_CFLAGS="$CFLAGS"
+- CFLAGS="$CFLAGS -belf"
+- AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
+- [AC_LANG_PUSH(C)
+- AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])
+- AC_LANG_POP])
+- if test x"$lt_cv_cc_needs_belf" != x"yes"; then
+- # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
+- CFLAGS="$SAVE_CFLAGS"
+- fi
+- ;;
+-sparc*-*solaris*)
+- # Find out which ABI we are using.
+- echo 'int i;' > conftest.$ac_ext
+- if AC_TRY_EVAL(ac_compile); then
+- case `/usr/bin/file conftest.o` in
+- *64-bit*)
+- case $lt_cv_prog_gnu_ld in
+- yes*) LD="${LD-ld} -m elf64_sparc" ;;
+- *) LD="${LD-ld} -64" ;;
+- esac
+- ;;
+- esac
+- fi
+- rm -rf conftest*
+- ;;
+
+-AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL],
+-[*-*-cygwin* | *-*-mingw* | *-*-pw32*)
+- AC_CHECK_TOOL(DLLTOOL, dlltool, false)
+- AC_CHECK_TOOL(AS, as, false)
+- AC_CHECK_TOOL(OBJDUMP, objdump, false)
+- ;;
+- ])
+-esac
++# LT_OUTPUT
++# ---------
++# This macro allows early generation of the libtool script (before
++# AC_OUTPUT is called), incase it is used in configure for compilation
++# tests.
++AC_DEFUN([LT_OUTPUT],
++[: ${CONFIG_LT=./config.lt}
++AC_MSG_NOTICE([creating $CONFIG_LT])
++cat >"$CONFIG_LT" <<_LTEOF
++#! $SHELL
++# Generated by $as_me.
++# Run this file to recreate a libtool stub with the current configuration.
++
++lt_cl_silent=false
++SHELL=\${CONFIG_SHELL-$SHELL}
++_LTEOF
++
++cat >>"$CONFIG_LT" <<\_LTEOF
++AS_SHELL_SANITIZE
++_AS_PREPARE
+
+-need_locks="$enable_libtool_lock"
++exec AS_MESSAGE_FD>&1
++exec AS_MESSAGE_LOG_FD>>config.log
++{
++ echo
++ AS_BOX([Running $as_me.])
++} >&AS_MESSAGE_LOG_FD
++
++lt_cl_help="\
++\`$as_me' creates a local libtool stub from the current configuration,
++for use in further configure time tests before the real libtool is
++generated.
++
++Usage: $[0] [[OPTIONS]]
++
++ -h, --help print this help, then exit
++ -V, --version print version number, then exit
++ -q, --quiet do not print progress messages
++ -d, --debug don't remove temporary files
++
++Report bugs to <bug-libtool@gnu.org>."
++
++lt_cl_version="\
++m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl
++m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION])
++configured by $[0], generated by m4_PACKAGE_STRING.
++
++Copyright (C) 2008 Free Software Foundation, Inc.
++This config.lt script is free software; the Free Software Foundation
++gives unlimited permision to copy, distribute and modify it."
+
+-])# _LT_AC_LOCK
++while test $[#] != 0
++do
++ case $[1] in
++ --version | --v* | -V )
++ echo "$lt_cl_version"; exit 0 ;;
++ --help | --h* | -h )
++ echo "$lt_cl_help"; exit 0 ;;
++ --debug | --d* | -d )
++ debug=: ;;
++ --quiet | --q* | --silent | --s* | -q )
++ lt_cl_silent=: ;;
+
++ -*) AC_MSG_ERROR([unrecognized option: $[1]
++Try \`$[0] --help' for more information.]) ;;
+
+-# AC_LIBTOOL_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
+-# [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE])
+-# ----------------------------------------------------------------
+-# Check whether the given compiler option works
+-AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION],
+-[AC_REQUIRE([LT_AC_PROG_SED])
+-AC_CACHE_CHECK([$1], [$2],
+- [$2=no
+- ifelse([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4])
+- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+- lt_compiler_flag="$3"
+- # Insert the option either (1) after the last *FLAGS variable, or
+- # (2) before a word containing "conftest.", or (3) at the end.
+- # Note that $ac_compile itself does not contain backslashes and begins
+- # with a dollar sign (not a hyphen), so the echo should work correctly.
+- # The option is referenced via a variable to avoid confusing sed.
+- lt_compile=`echo "$ac_compile" | $SED \
+- -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+- -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
+- -e 's:$: $lt_compiler_flag:'`
+- (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
+- (eval "$lt_compile" 2>conftest.err)
+- ac_status=$?
+- cat conftest.err >&AS_MESSAGE_LOG_FD
+- echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
+- if (exit $ac_status) && test -s "$ac_outfile"; then
+- # The compiler can only warn and ignore the option if not recognized
+- # So say no if there are warnings other than the usual output.
+- $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
+- $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+- if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+- $2=yes
+- fi
+- fi
+- $rm conftest*
+-])
++ *) AC_MSG_ERROR([unrecognized argument: $[1]
++Try \`$[0] --help' for more information.]) ;;
++ esac
++ shift
++done
+
+-if test x"[$]$2" = xyes; then
+- ifelse([$5], , :, [$5])
+-else
+- ifelse([$6], , :, [$6])
++if $lt_cl_silent; then
++ exec AS_MESSAGE_FD>/dev/null
+ fi
+-])# AC_LIBTOOL_COMPILER_OPTION
+-
+-
+-# AC_LIBTOOL_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
+-# [ACTION-SUCCESS], [ACTION-FAILURE])
+-# ------------------------------------------------------------
+-# Check whether the given compiler option works
+-AC_DEFUN([AC_LIBTOOL_LINKER_OPTION],
+-[AC_CACHE_CHECK([$1], [$2],
+- [$2=no
+- save_LDFLAGS="$LDFLAGS"
+- LDFLAGS="$LDFLAGS $3"
+- printf "$lt_simple_link_test_code" > conftest.$ac_ext
+- if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
+- # The linker can only warn and ignore the option if not recognized
+- # So say no if there are warnings
+- if test -s conftest.err; then
+- # Append any errors to the config.log.
+- cat conftest.err 1>&AS_MESSAGE_LOG_FD
+- $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
+- $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+- if diff conftest.exp conftest.er2 >/dev/null; then
+- $2=yes
+- fi
+- else
+- $2=yes
+- fi
+- fi
+- $rm conftest*
+- LDFLAGS="$save_LDFLAGS"
+-])
++_LTEOF
+
+-if test x"[$]$2" = xyes; then
+- ifelse([$4], , :, [$4])
+-else
+- ifelse([$5], , :, [$5])
++cat >>"$CONFIG_LT" <<_LTEOF
++_LT_OUTPUT_LIBTOOL_COMMANDS_INIT
++_LTEOF
++
++cat >>"$CONFIG_LT" <<\_LTEOF
++AC_MSG_NOTICE([creating $ofile])
++_LT_OUTPUT_LIBTOOL_COMMANDS
++AS_EXIT(0)
++_LTEOF
++chmod +x "$CONFIG_LT"
++
++# configure is writing to config.log, but config.lt does its own redirection,
++# appending to config.log, which fails on DOS, as config.log is still kept
++# open by configure. Here we exec the FD to /dev/null, effectively closing
++# config.log, so it can be properly (re)opened and appended to by config.lt.
++if test "$no_create" != yes; then
++ lt_cl_success=:
++ test "$silent" = yes &&
++ lt_config_lt_args="$lt_config_lt_args --quiet"
++ exec AS_MESSAGE_LOG_FD>/dev/null
++ $SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false
++ exec AS_MESSAGE_LOG_FD>>config.log
++ $lt_cl_success || AS_EXIT(1)
+ fi
+-])# AC_LIBTOOL_LINKER_OPTION
+-
++])# LT_OUTPUT
+
+-# AC_LIBTOOL_SYS_MAX_CMD_LEN
+-# --------------------------
+-AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN],
+-[# find the maximum length of command line arguments
+-AC_MSG_CHECKING([the maximum length of command line arguments])
+-AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
+- i=0
+- teststring="ABCD"
+
+- case $build_os in
+- msdosdjgpp*)
+- # On DJGPP, this test can blow up pretty badly due to problems in libc
+- # (any single argument exceeding 2000 bytes causes a buffer overrun
+- # during glob expansion). Even if it were fixed, the result of this
+- # check would be larger than it should be.
+- lt_cv_sys_max_cmd_len=12288; # 12K is about right
+- ;;
++# _LT_CONFIG(TAG)
++# ---------------
++# If TAG is the built-in tag, create an initial libtool script with a
++# default configuration from the untagged config vars. Otherwise add code
++# to config.status for appending the configuration named by TAG from the
++# matching tagged config vars.
++m4_defun([_LT_CONFIG],
++[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
++_LT_CONFIG_SAVE_COMMANDS([
++ m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl
++ m4_if(_LT_TAG, [C], [
++ # See if we are running on zsh, and set the options which allow our
++ # commands through without removal of \ escapes.
++ if test -n "${ZSH_VERSION+set}" ; then
++ setopt NO_GLOB_SUBST
++ fi
+
+- gnu*)
+- # Under GNU Hurd, this test is not required because there is
+- # no limit to the length of command line arguments.
+- # Libtool will interpret -1 as no limit whatsoever
+- lt_cv_sys_max_cmd_len=-1;
+- ;;
++ cfgfile="${ofile}T"
++ trap "$RM \"$cfgfile\"; exit 1" 1 2 15
++ $RM "$cfgfile"
+
+- cygwin* | mingw*)
+- # On Win9x/ME, this test blows up -- it succeeds, but takes
+- # about 5 minutes as the teststring grows exponentially.
+- # Worse, since 9x/ME are not pre-emptively multitasking,
+- # you end up with a "frozen" computer, even though with patience
+- # the test eventually succeeds (with a max line length of 256k).
+- # Instead, let's just punt: use the minimum linelength reported by
+- # all of the supported platforms: 8192 (on NT/2K/XP).
+- lt_cv_sys_max_cmd_len=8192;
+- ;;
++ cat <<_LT_EOF >> "$cfgfile"
++#! $SHELL
+
+- amigaos*)
+- # On AmigaOS with pdksh, this test takes hours, literally.
+- # So we just punt and use a minimum line length of 8192.
+- lt_cv_sys_max_cmd_len=8192;
+- ;;
++# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
++# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION
++# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
++# NOTE: Changes made to this file will be lost: look at ltmain.sh.
++#
++_LT_COPYING
++_LT_LIBTOOL_TAGS
+
+- netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
+- # This has been around since 386BSD, at least. Likely further.
+- if test -x /sbin/sysctl; then
+- lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
+- elif test -x /usr/sbin/sysctl; then
+- lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
+- else
+- lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs
+- fi
+- # And add a safety zone
+- lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
+- lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+- ;;
++# ### BEGIN LIBTOOL CONFIG
++_LT_LIBTOOL_CONFIG_VARS
++_LT_LIBTOOL_TAG_VARS
++# ### END LIBTOOL CONFIG
+
+- interix*)
+- # We know the value 262144 and hardcode it with a safety zone (like BSD)
+- lt_cv_sys_max_cmd_len=196608
+- ;;
++_LT_EOF
+
+- osf*)
+- # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
+- # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
+- # nice to cause kernel panics so lets avoid the loop below.
+- # First set a reasonable default.
+- lt_cv_sys_max_cmd_len=16384
+- #
+- if test -x /sbin/sysconfig; then
+- case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
+- *1*) lt_cv_sys_max_cmd_len=-1 ;;
+- esac
+- fi
+- ;;
+- sco3.2v5*)
+- lt_cv_sys_max_cmd_len=102400
+- ;;
+- sysv5* | sco5v6* | sysv4.2uw2*)
+- kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
+- if test -n "$kargmax"; then
+- lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'`
+- else
+- lt_cv_sys_max_cmd_len=32768
+- fi
+- ;;
+- *)
+- # If test is not a shell built-in, we'll probably end up computing a
+- # maximum length that is only half of the actual maximum length, but
+- # we can't tell.
+- SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
+- while (test "X"`$SHELL [$]0 --fallback-echo "X$teststring" 2>/dev/null` \
+- = "XX$teststring") >/dev/null 2>&1 &&
+- new_result=`expr "X$teststring" : ".*" 2>&1` &&
+- lt_cv_sys_max_cmd_len=$new_result &&
+- test $i != 17 # 1/2 MB should be enough
+- do
+- i=`expr $i + 1`
+- teststring=$teststring$teststring
+- done
+- teststring=
+- # Add a significant safety factor because C++ compilers can tack on massive
+- # amounts of additional arguments before passing them to the linker.
+- # It appears as though 1/2 is a usable value.
+- lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
++ case $host_os in
++ aix3*)
++ cat <<\_LT_EOF >> "$cfgfile"
++# AIX sometimes has problems with the GCC collect2 program. For some
++# reason, if we set the COLLECT_NAMES environment variable, the problems
++# vanish in a puff of smoke.
++if test "X${COLLECT_NAMES+set}" != Xset; then
++ COLLECT_NAMES=
++ export COLLECT_NAMES
++fi
++_LT_EOF
+ ;;
+ esac
+-])
+-if test -n $lt_cv_sys_max_cmd_len ; then
+- AC_MSG_RESULT($lt_cv_sys_max_cmd_len)
+-else
+- AC_MSG_RESULT(none)
+-fi
+-])# AC_LIBTOOL_SYS_MAX_CMD_LEN
+
++ _LT_PROG_LTMAIN
+
+-# _LT_AC_CHECK_DLFCN
+-# ------------------
+-AC_DEFUN([_LT_AC_CHECK_DLFCN],
+-[AC_CHECK_HEADERS(dlfcn.h)dnl
+-])# _LT_AC_CHECK_DLFCN
++ # We use sed instead of cat because bash on DJGPP gets confused if
++ # if finds mixed CR/LF and LF-only lines. Since sed operates in
++ # text mode, it properly converts lines to CR/LF. This bash problem
++ # is reportedly fixed, but why not run on old versions too?
++ sed '/^# Generated shell functions inserted here/q' "$ltmain" >> "$cfgfile" \
++ || (rm -f "$cfgfile"; exit 1)
+
++ _LT_PROG_XSI_SHELLFNS
+
+-# _LT_AC_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE,
+-# ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING)
+-# ---------------------------------------------------------------------
+-AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF],
+-[AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl
+-if test "$cross_compiling" = yes; then :
+- [$4]
+-else
+- lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+- lt_status=$lt_dlunknown
+- cat > conftest.$ac_ext <<EOF
+-[#line __oline__ "configure"
+-#include "confdefs.h"
++ sed -n '/^# Generated shell functions inserted here/,$p' "$ltmain" >> "$cfgfile" \
++ || (rm -f "$cfgfile"; exit 1)
+
+-#if HAVE_DLFCN_H
+-#include <dlfcn.h>
+-#endif
++ mv -f "$cfgfile" "$ofile" ||
++ (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
++ chmod +x "$ofile"
++],
++[cat <<_LT_EOF >> "$ofile"
+
+-#include <stdio.h>
++dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded
++dnl in a comment (ie after a #).
++# ### BEGIN LIBTOOL TAG CONFIG: $1
++_LT_LIBTOOL_TAG_VARS(_LT_TAG)
++# ### END LIBTOOL TAG CONFIG: $1
++_LT_EOF
++])dnl /m4_if
++],
++[m4_if([$1], [], [
++ PACKAGE='$PACKAGE'
++ VERSION='$VERSION'
++ TIMESTAMP='$TIMESTAMP'
++ RM='$RM'
++ ofile='$ofile'], [])
++])dnl /_LT_CONFIG_SAVE_COMMANDS
++])# _LT_CONFIG
++
++
++# LT_SUPPORTED_TAG(TAG)
++# ---------------------
++# Trace this macro to discover what tags are supported by the libtool
++# --tag option, using:
++# autoconf --trace 'LT_SUPPORTED_TAG:$1'
++AC_DEFUN([LT_SUPPORTED_TAG], [])
++
++
++# C support is built-in for now
++m4_define([_LT_LANG_C_enabled], [])
++m4_define([_LT_TAGS], [])
+
+-#ifdef RTLD_GLOBAL
+-# define LT_DLGLOBAL RTLD_GLOBAL
+-#else
+-# ifdef DL_GLOBAL
+-# define LT_DLGLOBAL DL_GLOBAL
+-# else
+-# define LT_DLGLOBAL 0
+-# endif
+-#endif
+
+-/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+- find out it does not work in some platform. */
+-#ifndef LT_DLLAZY_OR_NOW
+-# ifdef RTLD_LAZY
+-# define LT_DLLAZY_OR_NOW RTLD_LAZY
+-# else
+-# ifdef DL_LAZY
+-# define LT_DLLAZY_OR_NOW DL_LAZY
+-# else
+-# ifdef RTLD_NOW
+-# define LT_DLLAZY_OR_NOW RTLD_NOW
+-# else
+-# ifdef DL_NOW
+-# define LT_DLLAZY_OR_NOW DL_NOW
+-# else
+-# define LT_DLLAZY_OR_NOW 0
+-# endif
+-# endif
+-# endif
+-# endif
+-#endif
++# LT_LANG(LANG)
++# -------------
++# Enable libtool support for the given language if not already enabled.
++AC_DEFUN([LT_LANG],
++[AC_BEFORE([$0], [LT_OUTPUT])dnl
++m4_case([$1],
++ [C], [_LT_LANG(C)],
++ [C++], [_LT_LANG(CXX)],
++ [Java], [_LT_LANG(GCJ)],
++ [Fortran 77], [_LT_LANG(F77)],
++ [Fortran], [_LT_LANG(FC)],
++ [Windows Resource], [_LT_LANG(RC)],
++ [m4_ifdef([_LT_LANG_]$1[_CONFIG],
++ [_LT_LANG($1)],
++ [m4_fatal([$0: unsupported language: "$1"])])])dnl
++])# LT_LANG
+
+-#ifdef __cplusplus
+-extern "C" void exit (int);
+-#endif
+
+-void fnord() { int i=42;}
+-int main ()
+-{
+- void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+- int status = $lt_dlunknown;
+-
+- if (self)
+- {
+- if (dlsym (self,"fnord")) status = $lt_dlno_uscore;
+- else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
+- /* dlclose (self); */
+- }
+- else
+- puts (dlerror ());
++# _LT_LANG(LANGNAME)
++# ------------------
++m4_defun([_LT_LANG],
++[m4_ifdef([_LT_LANG_]$1[_enabled], [],
++ [LT_SUPPORTED_TAG([$1])dnl
++ m4_append([_LT_TAGS], [$1 ])dnl
++ m4_define([_LT_LANG_]$1[_enabled], [])dnl
++ _LT_LANG_$1_CONFIG($1)])dnl
++])# _LT_LANG
+
+- exit (status);
+-}]
+-EOF
+- if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then
+- (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null
+- lt_status=$?
+- case x$lt_status in
+- x$lt_dlno_uscore) $1 ;;
+- x$lt_dlneed_uscore) $2 ;;
+- x$lt_dlunknown|x*) $3 ;;
+- esac
+- else :
+- # compilation failed
+- $3
+- fi
+-fi
+-rm -fr conftest*
+-])# _LT_AC_TRY_DLOPEN_SELF
+
++# _LT_LANG_DEFAULT_CONFIG
++# -----------------------
++m4_defun([_LT_LANG_DEFAULT_CONFIG],
++[AC_PROVIDE_IFELSE([AC_PROG_CXX],
++ [LT_LANG(CXX)],
++ [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])])
++
++AC_PROVIDE_IFELSE([AC_PROG_F77],
++ [LT_LANG(F77)],
++ [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])])
++
++AC_PROVIDE_IFELSE([AC_PROG_FC],
++ [LT_LANG(FC)],
++ [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])])
++
++dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal
++dnl pulling things in needlessly.
++AC_PROVIDE_IFELSE([AC_PROG_GCJ],
++ [LT_LANG(GCJ)],
++ [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],
++ [LT_LANG(GCJ)],
++ [AC_PROVIDE_IFELSE([LT_PROG_GCJ],
++ [LT_LANG(GCJ)],
++ [m4_ifdef([AC_PROG_GCJ],
++ [m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])])
++ m4_ifdef([A][M_PROG_GCJ],
++ [m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])])
++ m4_ifdef([LT_PROG_GCJ],
++ [m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])])
++
++AC_PROVIDE_IFELSE([LT_PROG_RC],
++ [LT_LANG(RC)],
++ [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])])
++])# _LT_LANG_DEFAULT_CONFIG
++
++# Obsolete macros:
++AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)])
++AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)])
++AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)])
++AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)])
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([AC_LIBTOOL_CXX], [])
++dnl AC_DEFUN([AC_LIBTOOL_F77], [])
++dnl AC_DEFUN([AC_LIBTOOL_FC], [])
++dnl AC_DEFUN([AC_LIBTOOL_GCJ], [])
+
+-# AC_LIBTOOL_DLOPEN_SELF
+-# ----------------------
+-AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF],
+-[AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl
+-if test "x$enable_dlopen" != xyes; then
+- enable_dlopen=unknown
+- enable_dlopen_self=unknown
+- enable_dlopen_self_static=unknown
+-else
+- lt_cv_dlopen=no
+- lt_cv_dlopen_libs=
+
+- case $host_os in
+- beos*)
+- lt_cv_dlopen="load_add_on"
+- lt_cv_dlopen_libs=
+- lt_cv_dlopen_self=yes
+- ;;
++# _LT_TAG_COMPILER
++# ----------------
++m4_defun([_LT_TAG_COMPILER],
++[AC_REQUIRE([AC_PROG_CC])dnl
+
+- mingw* | pw32*)
+- lt_cv_dlopen="LoadLibrary"
+- lt_cv_dlopen_libs=
+- ;;
++_LT_DECL([LTCC], [CC], [1], [A C compiler])dnl
++_LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl
++_LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl
++_LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl
+
+- cygwin*)
+- lt_cv_dlopen="dlopen"
+- lt_cv_dlopen_libs=
+- ;;
++# If no C compiler was specified, use CC.
++LTCC=${LTCC-"$CC"}
+
+- darwin*)
+- # if libdl is installed we need to link against it
+- AC_CHECK_LIB([dl], [dlopen],
+- [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[
+- lt_cv_dlopen="dyld"
+- lt_cv_dlopen_libs=
+- lt_cv_dlopen_self=yes
+- ])
+- ;;
++# If no C compiler flags were specified, use CFLAGS.
++LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
+
+- *)
+- AC_CHECK_FUNC([shl_load],
+- [lt_cv_dlopen="shl_load"],
+- [AC_CHECK_LIB([dld], [shl_load],
+- [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld"],
+- [AC_CHECK_FUNC([dlopen],
+- [lt_cv_dlopen="dlopen"],
+- [AC_CHECK_LIB([dl], [dlopen],
+- [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],
+- [AC_CHECK_LIB([svld], [dlopen],
+- [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"],
+- [AC_CHECK_LIB([dld], [dld_link],
+- [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld"])
+- ])
+- ])
+- ])
+- ])
+- ])
+- ;;
+- esac
++# Allow CC to be a program name with arguments.
++compiler=$CC
++])# _LT_TAG_COMPILER
+
+- if test "x$lt_cv_dlopen" != xno; then
+- enable_dlopen=yes
+- else
+- enable_dlopen=no
+- fi
+
+- case $lt_cv_dlopen in
+- dlopen)
+- save_CPPFLAGS="$CPPFLAGS"
+- test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
++# _LT_COMPILER_BOILERPLATE
++# ------------------------
++# Check for compiler boilerplate output or warnings with
++# the simple compiler test code.
++m4_defun([_LT_COMPILER_BOILERPLATE],
++[m4_require([_LT_DECL_SED])dnl
++ac_outfile=conftest.$ac_objext
++echo "$lt_simple_compile_test_code" >conftest.$ac_ext
++eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
++_lt_compiler_boilerplate=`cat conftest.err`
++$RM conftest*
++])# _LT_COMPILER_BOILERPLATE
+
+- save_LDFLAGS="$LDFLAGS"
+- wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
+
+- save_LIBS="$LIBS"
+- LIBS="$lt_cv_dlopen_libs $LIBS"
++# _LT_LINKER_BOILERPLATE
++# ----------------------
++# Check for linker boilerplate output or warnings with
++# the simple link test code.
++m4_defun([_LT_LINKER_BOILERPLATE],
++[m4_require([_LT_DECL_SED])dnl
++ac_outfile=conftest.$ac_objext
++echo "$lt_simple_link_test_code" >conftest.$ac_ext
++eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
++_lt_linker_boilerplate=`cat conftest.err`
++$RM -r conftest*
++])# _LT_LINKER_BOILERPLATE
+
+- AC_CACHE_CHECK([whether a program can dlopen itself],
+- lt_cv_dlopen_self, [dnl
+- _LT_AC_TRY_DLOPEN_SELF(
+- lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes,
+- lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross)
++# _LT_REQUIRED_DARWIN_CHECKS
++# -------------------------
++m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[
++ case $host_os in
++ rhapsody* | darwin*)
++ AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:])
++ AC_CHECK_TOOL([NMEDIT], [nmedit], [:])
++ AC_CHECK_TOOL([LIPO], [lipo], [:])
++ AC_CHECK_TOOL([OTOOL], [otool], [:])
++ AC_CHECK_TOOL([OTOOL64], [otool64], [:])
++ _LT_DECL([], [DSYMUTIL], [1],
++ [Tool to manipulate archived DWARF debug symbol files on Mac OS X])
++ _LT_DECL([], [NMEDIT], [1],
++ [Tool to change global to local symbols on Mac OS X])
++ _LT_DECL([], [LIPO], [1],
++ [Tool to manipulate fat objects and archives on Mac OS X])
++ _LT_DECL([], [OTOOL], [1],
++ [ldd/readelf like tool for Mach-O binaries on Mac OS X])
++ _LT_DECL([], [OTOOL64], [1],
++ [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4])
++
++ AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod],
++ [lt_cv_apple_cc_single_mod=no
++ if test -z "${LT_MULTI_MODULE}"; then
++ # By default we will add the -single_module flag. You can override
++ # by either setting the environment variable LT_MULTI_MODULE
++ # non-empty at configure time, or by adding -multi_module to the
++ # link flags.
++ rm -rf libconftest.dylib*
++ echo "int foo(void){return 1;}" > conftest.c
++ echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
++-dynamiclib -Wl,-single_module conftest.c" >&AS_MESSAGE_LOG_FD
++ $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
++ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err
++ _lt_result=$?
++ if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then
++ lt_cv_apple_cc_single_mod=yes
++ else
++ cat conftest.err >&AS_MESSAGE_LOG_FD
++ fi
++ rm -rf libconftest.dylib*
++ rm -f conftest.*
++ fi])
++ AC_CACHE_CHECK([for -exported_symbols_list linker flag],
++ [lt_cv_ld_exported_symbols_list],
++ [lt_cv_ld_exported_symbols_list=no
++ save_LDFLAGS=$LDFLAGS
++ echo "_main" > conftest.sym
++ LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym"
++ AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
++ [lt_cv_ld_exported_symbols_list=yes],
++ [lt_cv_ld_exported_symbols_list=no])
++ LDFLAGS="$save_LDFLAGS"
+ ])
+-
+- if test "x$lt_cv_dlopen_self" = xyes; then
+- wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
+- AC_CACHE_CHECK([whether a statically linked program can dlopen itself],
+- lt_cv_dlopen_self_static, [dnl
+- _LT_AC_TRY_DLOPEN_SELF(
+- lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes,
+- lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross)
+- ])
++ case $host_os in
++ rhapsody* | darwin1.[[012]])
++ _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
++ darwin1.*)
++ _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
++ darwin*) # darwin 5.x on
++ # if running on 10.5 or later, the deployment target defaults
++ # to the OS version, if on x86, and 10.4, the deployment
++ # target defaults to 10.4. Don't you love it?
++ case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
++ 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*)
++ _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
++ 10.[[012]]*)
++ _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
++ 10.*)
++ _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
++ esac
++ ;;
++ esac
++ if test "$lt_cv_apple_cc_single_mod" = "yes"; then
++ _lt_dar_single_mod='$single_module'
++ fi
++ if test "$lt_cv_ld_exported_symbols_list" = "yes"; then
++ _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym'
++ else
++ _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}'
++ fi
++ if test "$DSYMUTIL" != ":"; then
++ _lt_dsymutil='~$DSYMUTIL $lib || :'
++ else
++ _lt_dsymutil=
+ fi
+-
+- CPPFLAGS="$save_CPPFLAGS"
+- LDFLAGS="$save_LDFLAGS"
+- LIBS="$save_LIBS"
+ ;;
+ esac
++])
+
+- case $lt_cv_dlopen_self in
+- yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
+- *) enable_dlopen_self=unknown ;;
+- esac
+
+- case $lt_cv_dlopen_self_static in
+- yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
+- *) enable_dlopen_self_static=unknown ;;
+- esac
+-fi
+-])# AC_LIBTOOL_DLOPEN_SELF
++# _LT_DARWIN_LINKER_FEATURES
++# --------------------------
++# Checks for linker and compiler features on darwin
++m4_defun([_LT_DARWIN_LINKER_FEATURES],
++[
++ m4_require([_LT_REQUIRED_DARWIN_CHECKS])
++ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
++ _LT_TAGVAR(hardcode_direct, $1)=no
++ _LT_TAGVAR(hardcode_automatic, $1)=yes
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
++ _LT_TAGVAR(whole_archive_flag_spec, $1)=''
++ _LT_TAGVAR(link_all_deplibs, $1)=yes
++ _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined"
++ if test "$GCC" = "yes"; then
++ output_verbose_link_cmd=echo
++ _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
++ _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
++ _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
++ _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
++ m4_if([$1], [CXX],
++[ if test "$lt_cv_apple_cc_single_mod" != "yes"; then
++ _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
++ _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}"
++ fi
++],[])
++ else
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ fi
++])
+
++# _LT_SYS_MODULE_PATH_AIX
++# -----------------------
++# Links a minimal program and checks the executable
++# for the system default hardcoded library path. In most cases,
++# this is /usr/lib:/lib, but when the MPI compilers are used
++# the location of the communication and MPI libs are included too.
++# If we don't find anything, use the default library path according
++# to the aix ld manual.
++m4_defun([_LT_SYS_MODULE_PATH_AIX],
++[m4_require([_LT_DECL_SED])dnl
++AC_LINK_IFELSE(AC_LANG_PROGRAM,[
++lt_aix_libpath_sed='
++ /Import File Strings/,/^$/ {
++ /^0/ {
++ s/^0 *\(.*\)$/\1/
++ p
++ }
++ }'
++aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
++# Check for a 64-bit object if we didn't find anything.
++if test -z "$aix_libpath"; then
++ aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
++fi],[])
++if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
++])# _LT_SYS_MODULE_PATH_AIX
+
+-# AC_LIBTOOL_PROG_CC_C_O([TAGNAME])
+-# ---------------------------------
+-# Check to see if options -c and -o are simultaneously supported by compiler
+-AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O],
+-[AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl
+-AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext],
+- [_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)],
+- [_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no
+- $rm -r conftest 2>/dev/null
+- mkdir conftest
+- cd conftest
+- mkdir out
+- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+- lt_compiler_flag="-o out/conftest2.$ac_objext"
+- # Insert the option either (1) after the last *FLAGS variable, or
+- # (2) before a word containing "conftest.", or (3) at the end.
+- # Note that $ac_compile itself does not contain backslashes and begins
+- # with a dollar sign (not a hyphen), so the echo should work correctly.
+- lt_compile=`echo "$ac_compile" | $SED \
+- -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+- -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
+- -e 's:$: $lt_compiler_flag:'`
+- (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
+- (eval "$lt_compile" 2>out/conftest.err)
+- ac_status=$?
+- cat out/conftest.err >&AS_MESSAGE_LOG_FD
+- echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
+- if (exit $ac_status) && test -s out/conftest2.$ac_objext
+- then
+- # The compiler can only warn and ignore the option if not recognized
+- # So say no if there are warnings
+- $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
+- $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+- if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+- _LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
+- fi
+- fi
+- chmod u+w . 2>&AS_MESSAGE_LOG_FD
+- $rm conftest*
+- # SGI C++ compiler will create directory out/ii_files/ for
+- # template instantiation
+- test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files
+- $rm out/* && rmdir out
+- cd ..
+- rmdir conftest
+- $rm conftest*
+-])
+-])# AC_LIBTOOL_PROG_CC_C_O
++# _LT_SHELL_INIT(ARG)
++# -------------------
++m4_define([_LT_SHELL_INIT],
++[ifdef([AC_DIVERSION_NOTICE],
++ [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)],
++ [AC_DIVERT_PUSH(NOTICE)])
++$1
++AC_DIVERT_POP
++])# _LT_SHELL_INIT
+
+
+-# AC_LIBTOOL_SYS_HARD_LINK_LOCKS([TAGNAME])
+-# -----------------------------------------
+-# Check to see if we can do hard links to lock some files if needed
+-AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS],
+-[AC_REQUIRE([_LT_AC_LOCK])dnl
++# _LT_PROG_ECHO_BACKSLASH
++# -----------------------
++# Add some code to the start of the generated configure script which
++# will find an echo command which doesn't interpret backslashes.
++m4_defun([_LT_PROG_ECHO_BACKSLASH],
++[_LT_SHELL_INIT([
++# Check that we are running under the correct shell.
++SHELL=${CONFIG_SHELL-/bin/sh}
+
+-hard_links="nottested"
+-if test "$_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then
+- # do not overwrite the value of need_locks provided by the user
+- AC_MSG_CHECKING([if we can lock with hard links])
+- hard_links=yes
+- $rm conftest*
+- ln conftest.a conftest.b 2>/dev/null && hard_links=no
+- touch conftest.a
+- ln conftest.a conftest.b 2>&5 || hard_links=no
+- ln conftest.a conftest.b 2>/dev/null && hard_links=no
+- AC_MSG_RESULT([$hard_links])
+- if test "$hard_links" = no; then
+- AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe])
+- need_locks=warn
+- fi
++case X$lt_ECHO in
++X*--fallback-echo)
++ # Remove one level of quotation (which was required for Make).
++ ECHO=`echo "$lt_ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','`
++ ;;
++esac
++
++ECHO=${lt_ECHO-echo}
++if test "X[$]1" = X--no-reexec; then
++ # Discard the --no-reexec flag, and continue.
++ shift
++elif test "X[$]1" = X--fallback-echo; then
++ # Avoid inline document here, it may be left over
++ :
++elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' ; then
++ # Yippee, $ECHO works!
++ :
+ else
+- need_locks=no
++ # Restart under the correct shell.
++ exec $SHELL "[$]0" --no-reexec ${1+"[$]@"}
+ fi
+-])# AC_LIBTOOL_SYS_HARD_LINK_LOCKS
+
+-
+-# AC_LIBTOOL_OBJDIR
+-# -----------------
+-AC_DEFUN([AC_LIBTOOL_OBJDIR],
+-[AC_CACHE_CHECK([for objdir], [lt_cv_objdir],
+-[rm -f .libs 2>/dev/null
+-mkdir .libs 2>/dev/null
+-if test -d .libs; then
+- lt_cv_objdir=.libs
+-else
+- # MS-DOS does not allow filenames that begin with a dot.
+- lt_cv_objdir=_libs
++if test "X[$]1" = X--fallback-echo; then
++ # used as fallback echo
++ shift
++ cat <<_LT_EOF
++[$]*
++_LT_EOF
++ exit 0
+ fi
+-rmdir .libs 2>/dev/null])
+-objdir=$lt_cv_objdir
+-])# AC_LIBTOOL_OBJDIR
+
++# The HP-UX ksh and POSIX shell print the target directory to stdout
++# if CDPATH is set.
++(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+-# AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH([TAGNAME])
+-# ----------------------------------------------
+-# Check hardcoding attributes.
+-AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH],
+-[AC_MSG_CHECKING([how to hardcode library paths into programs])
+-_LT_AC_TAGVAR(hardcode_action, $1)=
+-if test -n "$_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)" || \
+- test -n "$_LT_AC_TAGVAR(runpath_var, $1)" || \
+- test "X$_LT_AC_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then
+-
+- # We can hardcode non-existant directories.
+- if test "$_LT_AC_TAGVAR(hardcode_direct, $1)" != no &&
+- # If the only mechanism to avoid hardcoding is shlibpath_var, we
+- # have to relink, otherwise we might link with an installed library
+- # when we should be linking with a yet-to-be-installed one
+- ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)" != no &&
+- test "$_LT_AC_TAGVAR(hardcode_minus_L, $1)" != no; then
+- # Linking always hardcodes the temporary library directory.
+- _LT_AC_TAGVAR(hardcode_action, $1)=relink
+- else
+- # We can link without hardcoding, and we can hardcode nonexisting dirs.
+- _LT_AC_TAGVAR(hardcode_action, $1)=immediate
++if test -z "$lt_ECHO"; then
++ if test "X${echo_test_string+set}" != Xset; then
++ # find a string as large as possible, as long as the shell can cope with it
++ for cmd in 'sed 50q "[$]0"' 'sed 20q "[$]0"' 'sed 10q "[$]0"' 'sed 2q "[$]0"' 'echo test'; do
++ # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ...
++ if { echo_test_string=`eval $cmd`; } 2>/dev/null &&
++ { test "X$echo_test_string" = "X$echo_test_string"; } 2>/dev/null
++ then
++ break
++ fi
++ done
+ fi
+-else
+- # We cannot hardcode anything, or else we can only hardcode existing
+- # directories.
+- _LT_AC_TAGVAR(hardcode_action, $1)=unsupported
+-fi
+-AC_MSG_RESULT([$_LT_AC_TAGVAR(hardcode_action, $1)])
+
+-if test "$_LT_AC_TAGVAR(hardcode_action, $1)" = relink; then
+- # Fast installation is not supported
+- enable_fast_install=no
+-elif test "$shlibpath_overrides_runpath" = yes ||
+- test "$enable_shared" = no; then
+- # Fast installation is not necessary
+- enable_fast_install=needless
+-fi
+-])# AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH
++ if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' &&
++ echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` &&
++ test "X$echo_testing_string" = "X$echo_test_string"; then
++ :
++ else
++ # The Solaris, AIX, and Digital Unix default echo programs unquote
++ # backslashes. This makes it impossible to quote backslashes using
++ # echo "$something" | sed 's/\\/\\\\/g'
++ #
++ # So, first we look for a working echo in the user's PATH.
+
++ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
++ for dir in $PATH /usr/ucb; do
++ IFS="$lt_save_ifs"
++ if (test -f $dir/echo || test -f $dir/echo$ac_exeext) &&
++ test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' &&
++ echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` &&
++ test "X$echo_testing_string" = "X$echo_test_string"; then
++ ECHO="$dir/echo"
++ break
++ fi
++ done
++ IFS="$lt_save_ifs"
+
+-# AC_LIBTOOL_SYS_LIB_STRIP
+-# ------------------------
+-AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP],
+-[striplib=
+-old_striplib=
+-AC_MSG_CHECKING([whether stripping libraries is possible])
+-if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then
+- test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
+- test -z "$striplib" && striplib="$STRIP --strip-unneeded"
+- AC_MSG_RESULT([yes])
+-else
+-# FIXME - insert some real tests, host_os isn't really good enough
+- case $host_os in
+- darwin*)
+- if test -n "$STRIP" ; then
+- striplib="$STRIP -x"
+- AC_MSG_RESULT([yes])
+- else
+- AC_MSG_RESULT([no])
+-fi
+- ;;
+- *)
+- AC_MSG_RESULT([no])
+- ;;
+- esac
+-fi
+-])# AC_LIBTOOL_SYS_LIB_STRIP
++ if test "X$ECHO" = Xecho; then
++ # We didn't find a better echo, so look for alternatives.
++ if test "X`{ print -r '\t'; } 2>/dev/null`" = 'X\t' &&
++ echo_testing_string=`{ print -r "$echo_test_string"; } 2>/dev/null` &&
++ test "X$echo_testing_string" = "X$echo_test_string"; then
++ # This shell has a builtin print -r that does the trick.
++ ECHO='print -r'
++ elif { test -f /bin/ksh || test -f /bin/ksh$ac_exeext; } &&
++ test "X$CONFIG_SHELL" != X/bin/ksh; then
++ # If we have ksh, try running configure again with it.
++ ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
++ export ORIGINAL_CONFIG_SHELL
++ CONFIG_SHELL=/bin/ksh
++ export CONFIG_SHELL
++ exec $CONFIG_SHELL "[$]0" --no-reexec ${1+"[$]@"}
++ else
++ # Try using printf.
++ ECHO='printf %s\n'
++ if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' &&
++ echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` &&
++ test "X$echo_testing_string" = "X$echo_test_string"; then
++ # Cool, printf works
++ :
++ elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` &&
++ test "X$echo_testing_string" = 'X\t' &&
++ echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
++ test "X$echo_testing_string" = "X$echo_test_string"; then
++ CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL
++ export CONFIG_SHELL
++ SHELL="$CONFIG_SHELL"
++ export SHELL
++ ECHO="$CONFIG_SHELL [$]0 --fallback-echo"
++ elif echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` &&
++ test "X$echo_testing_string" = 'X\t' &&
++ echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
++ test "X$echo_testing_string" = "X$echo_test_string"; then
++ ECHO="$CONFIG_SHELL [$]0 --fallback-echo"
++ else
++ # maybe with a smaller string...
++ prev=:
+
++ for cmd in 'echo test' 'sed 2q "[$]0"' 'sed 10q "[$]0"' 'sed 20q "[$]0"' 'sed 50q "[$]0"'; do
++ if { test "X$echo_test_string" = "X`eval $cmd`"; } 2>/dev/null
++ then
++ break
++ fi
++ prev="$cmd"
++ done
+
+-# AC_LIBTOOL_SYS_DYNAMIC_LINKER
+-# -----------------------------
+-# PORTME Fill in your ld.so characteristics
+-AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER],
+-[AC_MSG_CHECKING([dynamic linker characteristics])
+-library_names_spec=
+-libname_spec='lib$name'
+-soname_spec=
+-shrext_cmds=".so"
+-postinstall_cmds=
+-postuninstall_cmds=
+-finish_cmds=
+-finish_eval=
+-shlibpath_var=
+-shlibpath_overrides_runpath=unknown
+-version_type=none
+-dynamic_linker="$host_os ld.so"
+-sys_lib_dlsearch_path_spec="/lib /usr/lib"
+-if test "$GCC" = yes; then
+- sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+- if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then
+- # if the path contains ";" then we assume it to be the separator
+- # otherwise default to the standard path separator (i.e. ":") - it is
+- # assumed that no part of a normal pathname contains ";" but that should
+- # okay in the real world where ";" in dirpaths is itself problematic.
+- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+- else
+- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
++ if test "$prev" != 'sed 50q "[$]0"'; then
++ echo_test_string=`eval $prev`
++ export echo_test_string
++ exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "[$]0" ${1+"[$]@"}
++ else
++ # Oops. We lost completely, so just stick with echo.
++ ECHO=echo
++ fi
++ fi
++ fi
++ fi
+ fi
+-else
+- sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+ fi
+-need_lib_prefix=unknown
+-hardcode_into_libs=no
+
+-# when you set need_version to no, make sure it does not cause -set_version
+-# flags to be left without arguments
+-need_version=unknown
++# Copy echo and quote the copy suitably for passing to libtool from
++# the Makefile, instead of quoting the original, which is used later.
++lt_ECHO=$ECHO
++if test "X$lt_ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then
++ lt_ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo"
++fi
+
+-case $host_os in
+-aix3*)
+- version_type=linux
+- library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+- shlibpath_var=LIBPATH
++AC_SUBST(lt_ECHO)
++])
++_LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts])
++_LT_DECL([], [ECHO], [1],
++ [An echo program that does not interpret backslashes])
++])# _LT_PROG_ECHO_BACKSLASH
+
+- # AIX 3 has no versioning support, so we append a major version to the name.
+- soname_spec='${libname}${release}${shared_ext}$major'
+- ;;
+
+-aix4* | aix5*)
+- version_type=linux
+- need_lib_prefix=no
+- need_version=no
+- hardcode_into_libs=yes
+- if test "$host_cpu" = ia64; then
+- # AIX 5 supports IA64
+- library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+- shlibpath_var=LD_LIBRARY_PATH
+- else
+- # With GCC up to 2.95.x, collect2 would create an import file
+- # for dependence libraries. The import file would start with
+- # the line `#! .'. This would cause the generated library to
+- # depend on `.', always an invalid library. This was fixed in
+- # development snapshots of GCC prior to 3.0.
+- case $host_os in
+- aix4 | aix4.[[01]] | aix4.[[01]].*)
+- if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
+- echo ' yes '
+- echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then
+- :
+- else
+- can_build_shared=no
+- fi
+- ;;
++# _LT_ENABLE_LOCK
++# ---------------
++m4_defun([_LT_ENABLE_LOCK],
++[AC_ARG_ENABLE([libtool-lock],
++ [AS_HELP_STRING([--disable-libtool-lock],
++ [avoid locking (might break parallel builds)])])
++test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
++
++# Some flags need to be propagated to the compiler or linker for good
++# libtool support.
++case $host in
++ia64-*-hpux*)
++ # Find out which ABI we are using.
++ echo 'int i;' > conftest.$ac_ext
++ if AC_TRY_EVAL(ac_compile); then
++ case `/usr/bin/file conftest.$ac_objext` in
++ *ELF-32*)
++ HPUX_IA64_MODE="32"
++ ;;
++ *ELF-64*)
++ HPUX_IA64_MODE="64"
++ ;;
+ esac
+- # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+- # soname into executable. Probably we can add versioning support to
+- # collect2, so additional links can be useful in future.
+- if test "$aix_use_runtimelinking" = yes; then
+- # If using run time linking (on AIX 4.2 or later) use lib<name>.so
+- # instead of lib<name>.a to let people know that these are not
+- # typical AIX shared libraries.
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
++ fi
++ rm -rf conftest*
++ ;;
++*-*-irix6*)
++ # Find out which ABI we are using.
++ echo '[#]line __oline__ "configure"' > conftest.$ac_ext
++ if AC_TRY_EVAL(ac_compile); then
++ if test "$lt_cv_prog_gnu_ld" = yes; then
++ case `/usr/bin/file conftest.$ac_objext` in
++ *32-bit*)
++ LD="${LD-ld} -melf32bsmip"
++ ;;
++ *N32*)
++ LD="${LD-ld} -melf32bmipn32"
++ ;;
++ *64-bit*)
++ LD="${LD-ld} -melf64bmip"
++ ;;
++ esac
+ else
+- # We preserve .a as extension for shared libraries through AIX4.2
+- # and later when we are not doing run time linking.
+- library_names_spec='${libname}${release}.a $libname.a'
+- soname_spec='${libname}${release}${shared_ext}$major'
++ case `/usr/bin/file conftest.$ac_objext` in
++ *32-bit*)
++ LD="${LD-ld} -32"
++ ;;
++ *N32*)
++ LD="${LD-ld} -n32"
++ ;;
++ *64-bit*)
++ LD="${LD-ld} -64"
++ ;;
++ esac
+ fi
+- shlibpath_var=LIBPATH
+ fi
++ rm -rf conftest*
+ ;;
+
+-amigaos*)
+- library_names_spec='$libname.ixlibrary $libname.a'
+- # Create ${libname}_ixlibrary.a entries in /sys/libs.
+- finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
++x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
++s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
++ # Find out which ABI we are using.
++ echo 'int i;' > conftest.$ac_ext
++ if AC_TRY_EVAL(ac_compile); then
++ case `/usr/bin/file conftest.o` in
++ *32-bit*)
++ case $host in
++ x86_64-*kfreebsd*-gnu)
++ LD="${LD-ld} -m elf_i386_fbsd"
++ ;;
++ x86_64-*linux*)
++ LD="${LD-ld} -m elf_i386"
++ ;;
++ ppc64-*linux*|powerpc64-*linux*)
++ LD="${LD-ld} -m elf32ppclinux"
++ ;;
++ s390x-*linux*)
++ LD="${LD-ld} -m elf_s390"
++ ;;
++ sparc64-*linux*)
++ LD="${LD-ld} -m elf32_sparc"
++ ;;
++ esac
++ ;;
++ *64-bit*)
++ case $host in
++ x86_64-*kfreebsd*-gnu)
++ LD="${LD-ld} -m elf_x86_64_fbsd"
++ ;;
++ x86_64-*linux*)
++ LD="${LD-ld} -m elf_x86_64"
++ ;;
++ ppc*-*linux*|powerpc*-*linux*)
++ LD="${LD-ld} -m elf64ppc"
++ ;;
++ s390*-*linux*|s390*-*tpf*)
++ LD="${LD-ld} -m elf64_s390"
++ ;;
++ sparc*-*linux*)
++ LD="${LD-ld} -m elf64_sparc"
++ ;;
++ esac
++ ;;
++ esac
++ fi
++ rm -rf conftest*
+ ;;
+
+-beos*)
+- library_names_spec='${libname}${shared_ext}'
+- dynamic_linker="$host_os ld.so"
+- shlibpath_var=LIBRARY_PATH
++*-*-sco3.2v5*)
++ # On SCO OpenServer 5, we need -belf to get full-featured binaries.
++ SAVE_CFLAGS="$CFLAGS"
++ CFLAGS="$CFLAGS -belf"
++ AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
++ [AC_LANG_PUSH(C)
++ AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])
++ AC_LANG_POP])
++ if test x"$lt_cv_cc_needs_belf" != x"yes"; then
++ # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
++ CFLAGS="$SAVE_CFLAGS"
++ fi
+ ;;
+-
+-bsdi[[45]]*)
+- version_type=linux
+- need_version=no
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
+- shlibpath_var=LD_LIBRARY_PATH
+- sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
+- sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
+- # the default ld.so.conf also contains /usr/contrib/lib and
+- # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
+- # libtool to hard-code these into programs
++sparc*-*solaris*)
++ # Find out which ABI we are using.
++ echo 'int i;' > conftest.$ac_ext
++ if AC_TRY_EVAL(ac_compile); then
++ case `/usr/bin/file conftest.o` in
++ *64-bit*)
++ case $lt_cv_prog_gnu_ld in
++ yes*) LD="${LD-ld} -m elf64_sparc" ;;
++ *)
++ if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then
++ LD="${LD-ld} -64"
++ fi
++ ;;
++ esac
++ ;;
++ esac
++ fi
++ rm -rf conftest*
+ ;;
++esac
+
+-cygwin* | mingw* | pw32*)
+- version_type=windows
+- shrext_cmds=".dll"
+- need_version=no
+- need_lib_prefix=no
++need_locks="$enable_libtool_lock"
++])# _LT_ENABLE_LOCK
+
+- case $GCC,$host_os in
+- yes,cygwin* | yes,mingw* | yes,pw32*)
+- library_names_spec='$libname.dll.a'
+- # DLL is installed to $(libdir)/../bin by postinstall_cmds
+- postinstall_cmds='base_file=`basename \${file}`~
+- dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
+- dldir=$destdir/`dirname \$dlpath`~
+- test -d \$dldir || mkdir -p \$dldir~
+- $install_prog $dir/$dlname \$dldir/$dlname~
+- chmod a+x \$dldir/$dlname'
+- postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+- dlpath=$dir/\$dldll~
+- $rm \$dlpath'
+- shlibpath_overrides_runpath=yes
+
+- case $host_os in
+- cygwin*)
+- # Cygwin DLLs use 'cyg' prefix rather than 'lib'
+- soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+- sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
+- ;;
+- mingw*)
+- # MinGW DLLs use traditional 'lib' prefix
+- soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+- sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+- if echo "$sys_lib_search_path_spec" | [grep ';[c-zC-Z]:/' >/dev/null]; then
+- # It is most probably a Windows format PATH printed by
+- # mingw gcc, but we are running on Cygwin. Gcc prints its search
+- # path with ; separators, and with drive letters. We can handle the
+- # drive letters (cygwin fileutils understands them), so leave them,
+- # especially as we might pass files found there to a mingw objdump,
+- # which wouldn't understand a cygwinified path. Ahh.
+- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+- else
+- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
+- fi
+- ;;
+- pw32*)
+- # pw32 DLLs use 'pw' prefix rather than 'lib'
+- library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+- ;;
+- esac
+- ;;
++# _LT_CMD_OLD_ARCHIVE
++# -------------------
++m4_defun([_LT_CMD_OLD_ARCHIVE],
++[AC_CHECK_TOOL(AR, ar, false)
++test -z "$AR" && AR=ar
++test -z "$AR_FLAGS" && AR_FLAGS=cru
++_LT_DECL([], [AR], [1], [The archiver])
++_LT_DECL([], [AR_FLAGS], [1])
++
++AC_CHECK_TOOL(STRIP, strip, :)
++test -z "$STRIP" && STRIP=:
++_LT_DECL([], [STRIP], [1], [A symbol stripping program])
++
++AC_CHECK_TOOL(RANLIB, ranlib, :)
++test -z "$RANLIB" && RANLIB=:
++_LT_DECL([], [RANLIB], [1],
++ [Commands used to install an old-style archive])
++
++# Determine commands to create old-style static archives.
++old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs'
++old_postinstall_cmds='chmod 644 $oldlib'
++old_postuninstall_cmds=
+
++if test -n "$RANLIB"; then
++ case $host_os in
++ openbsd*)
++ old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib"
++ ;;
+ *)
+- library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib'
++ old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib"
+ ;;
+ esac
+- dynamic_linker='Win32 ld.exe'
+- # FIXME: first we should search . and the directory the executable is in
+- shlibpath_var=PATH
+- ;;
++ old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
++fi
++_LT_DECL([], [old_postinstall_cmds], [2])
++_LT_DECL([], [old_postuninstall_cmds], [2])
++_LT_TAGDECL([], [old_archive_cmds], [2],
++ [Commands used to build an old-style archive])
++])# _LT_CMD_OLD_ARCHIVE
+
+-darwin* | rhapsody*)
+- dynamic_linker="$host_os dyld"
+- version_type=darwin
+- need_lib_prefix=no
+- need_version=no
+- library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext'
+- soname_spec='${libname}${release}${major}$shared_ext'
+- shlibpath_overrides_runpath=yes
+- shlibpath_var=DYLD_LIBRARY_PATH
+- shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
+- # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same.
+- if test "$GCC" = yes; then
+- sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"`
+- else
+- sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib'
+- fi
+- sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
+- ;;
+
+-dgux*)
+- version_type=linux
+- need_lib_prefix=no
+- need_version=no
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- shlibpath_var=LD_LIBRARY_PATH
+- ;;
++# _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
++# [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE])
++# ----------------------------------------------------------------
++# Check whether the given compiler option works
++AC_DEFUN([_LT_COMPILER_OPTION],
++[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
++m4_require([_LT_DECL_SED])dnl
++AC_CACHE_CHECK([$1], [$2],
++ [$2=no
++ m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4])
++ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
++ lt_compiler_flag="$3"
++ # Insert the option either (1) after the last *FLAGS variable, or
++ # (2) before a word containing "conftest.", or (3) at the end.
++ # Note that $ac_compile itself does not contain backslashes and begins
++ # with a dollar sign (not a hyphen), so the echo should work correctly.
++ # The option is referenced via a variable to avoid confusing sed.
++ lt_compile=`echo "$ac_compile" | $SED \
++ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
++ -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
++ -e 's:$: $lt_compiler_flag:'`
++ (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
++ (eval "$lt_compile" 2>conftest.err)
++ ac_status=$?
++ cat conftest.err >&AS_MESSAGE_LOG_FD
++ echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
++ if (exit $ac_status) && test -s "$ac_outfile"; then
++ # The compiler can only warn and ignore the option if not recognized
++ # So say no if there are warnings other than the usual output.
++ $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
++ $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
++ if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
++ $2=yes
++ fi
++ fi
++ $RM conftest*
++])
+
+-freebsd1*)
+- dynamic_linker=no
+- ;;
++if test x"[$]$2" = xyes; then
++ m4_if([$5], , :, [$5])
++else
++ m4_if([$6], , :, [$6])
++fi
++])# _LT_COMPILER_OPTION
+
+-kfreebsd*-gnu)
+- version_type=linux
+- need_lib_prefix=no
+- need_version=no
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- shlibpath_var=LD_LIBRARY_PATH
+- shlibpath_overrides_runpath=no
+- hardcode_into_libs=yes
+- dynamic_linker='GNU ld.so'
+- ;;
++# Old name:
++AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION])
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], [])
+
+-freebsd* | dragonfly*)
+- # DragonFly does not have aout. When/if they implement a new
+- # versioning mechanism, adjust this.
+- if test -x /usr/bin/objformat; then
+- objformat=`/usr/bin/objformat`
+- else
+- case $host_os in
+- freebsd[[123]]*) objformat=aout ;;
+- *) objformat=elf ;;
+- esac
+- fi
+- version_type=freebsd-$objformat
+- case $version_type in
+- freebsd-elf*)
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+- need_version=no
+- need_lib_prefix=no
+- ;;
+- freebsd-*)
+- library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+- need_version=yes
+- ;;
+- esac
+- shlibpath_var=LD_LIBRARY_PATH
+- case $host_os in
+- freebsd2*)
+- shlibpath_overrides_runpath=yes
+- ;;
+- freebsd3.[[01]]* | freebsdelf3.[[01]]*)
+- shlibpath_overrides_runpath=yes
+- hardcode_into_libs=yes
++
++# _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
++# [ACTION-SUCCESS], [ACTION-FAILURE])
++# ----------------------------------------------------
++# Check whether the given linker option works
++AC_DEFUN([_LT_LINKER_OPTION],
++[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
++m4_require([_LT_DECL_SED])dnl
++AC_CACHE_CHECK([$1], [$2],
++ [$2=no
++ save_LDFLAGS="$LDFLAGS"
++ LDFLAGS="$LDFLAGS $3"
++ echo "$lt_simple_link_test_code" > conftest.$ac_ext
++ if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
++ # The linker can only warn and ignore the option if not recognized
++ # So say no if there are warnings
++ if test -s conftest.err; then
++ # Append any errors to the config.log.
++ cat conftest.err 1>&AS_MESSAGE_LOG_FD
++ $ECHO "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
++ $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
++ if diff conftest.exp conftest.er2 >/dev/null; then
++ $2=yes
++ fi
++ else
++ $2=yes
++ fi
++ fi
++ $RM -r conftest*
++ LDFLAGS="$save_LDFLAGS"
++])
++
++if test x"[$]$2" = xyes; then
++ m4_if([$4], , :, [$4])
++else
++ m4_if([$5], , :, [$5])
++fi
++])# _LT_LINKER_OPTION
++
++# Old name:
++AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION])
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], [])
++
++
++# LT_CMD_MAX_LEN
++#---------------
++AC_DEFUN([LT_CMD_MAX_LEN],
++[AC_REQUIRE([AC_CANONICAL_HOST])dnl
++# find the maximum length of command line arguments
++AC_MSG_CHECKING([the maximum length of command line arguments])
++AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
++ i=0
++ teststring="ABCD"
++
++ case $build_os in
++ msdosdjgpp*)
++ # On DJGPP, this test can blow up pretty badly due to problems in libc
++ # (any single argument exceeding 2000 bytes causes a buffer overrun
++ # during glob expansion). Even if it were fixed, the result of this
++ # check would be larger than it should be.
++ lt_cv_sys_max_cmd_len=12288; # 12K is about right
+ ;;
+- freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \
+- freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1)
+- shlibpath_overrides_runpath=no
+- hardcode_into_libs=yes
++
++ gnu*)
++ # Under GNU Hurd, this test is not required because there is
++ # no limit to the length of command line arguments.
++ # Libtool will interpret -1 as no limit whatsoever
++ lt_cv_sys_max_cmd_len=-1;
+ ;;
+- freebsd*) # from 4.6 on
+- shlibpath_overrides_runpath=yes
+- hardcode_into_libs=yes
++
++ cygwin* | mingw*)
++ # On Win9x/ME, this test blows up -- it succeeds, but takes
++ # about 5 minutes as the teststring grows exponentially.
++ # Worse, since 9x/ME are not pre-emptively multitasking,
++ # you end up with a "frozen" computer, even though with patience
++ # the test eventually succeeds (with a max line length of 256k).
++ # Instead, let's just punt: use the minimum linelength reported by
++ # all of the supported platforms: 8192 (on NT/2K/XP).
++ lt_cv_sys_max_cmd_len=8192;
+ ;;
+- esac
+- ;;
+
+-gnu*)
+- version_type=linux
+- need_lib_prefix=no
+- need_version=no
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- shlibpath_var=LD_LIBRARY_PATH
+- hardcode_into_libs=yes
+- ;;
++ amigaos*)
++ # On AmigaOS with pdksh, this test takes hours, literally.
++ # So we just punt and use a minimum line length of 8192.
++ lt_cv_sys_max_cmd_len=8192;
++ ;;
+
+-hpux9* | hpux10* | hpux11*)
+- # Give a soname corresponding to the major version so that dld.sl refuses to
+- # link against other versions.
+- version_type=sunos
+- need_lib_prefix=no
+- need_version=no
+- case $host_cpu in
+- ia64*)
+- shrext_cmds='.so'
+- hardcode_into_libs=yes
+- dynamic_linker="$host_os dld.so"
+- shlibpath_var=LD_LIBRARY_PATH
+- shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- if test "X$HPUX_IA64_MODE" = X32; then
+- sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
++ netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
++ # This has been around since 386BSD, at least. Likely further.
++ if test -x /sbin/sysctl; then
++ lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
++ elif test -x /usr/sbin/sysctl; then
++ lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
+ else
+- sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
++ lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs
+ fi
+- sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+- ;;
+- hppa*64*)
+- shrext_cmds='.sl'
+- hardcode_into_libs=yes
+- dynamic_linker="$host_os dld.sl"
+- shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
+- shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
+- sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+- ;;
+- *)
+- shrext_cmds='.sl'
+- dynamic_linker="$host_os dld.sl"
+- shlibpath_var=SHLIB_PATH
+- shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
++ # And add a safety zone
++ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
++ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+ ;;
+- esac
+- # HP-UX runs *really* slowly unless shared libraries are mode 555.
+- postinstall_cmds='chmod 555 $lib'
+- ;;
+
+-interix3*)
+- version_type=linux
+- need_lib_prefix=no
+- need_version=no
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
+- shlibpath_var=LD_LIBRARY_PATH
+- shlibpath_overrides_runpath=no
+- hardcode_into_libs=yes
+- ;;
++ interix*)
++ # We know the value 262144 and hardcode it with a safety zone (like BSD)
++ lt_cv_sys_max_cmd_len=196608
++ ;;
+
+-irix5* | irix6* | nonstopux*)
+- case $host_os in
+- nonstopux*) version_type=nonstopux ;;
+- *)
+- if test "$lt_cv_prog_gnu_ld" = yes; then
+- version_type=linux
+- else
+- version_type=irix
+- fi ;;
+- esac
+- need_lib_prefix=no
+- need_version=no
+- soname_spec='${libname}${release}${shared_ext}$major'
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+- case $host_os in
+- irix5* | nonstopux*)
+- libsuff= shlibsuff=
++ osf*)
++ # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
++ # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
++ # nice to cause kernel panics so lets avoid the loop below.
++ # First set a reasonable default.
++ lt_cv_sys_max_cmd_len=16384
++ #
++ if test -x /sbin/sysconfig; then
++ case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
++ *1*) lt_cv_sys_max_cmd_len=-1 ;;
++ esac
++ fi
++ ;;
++ sco3.2v5*)
++ lt_cv_sys_max_cmd_len=102400
++ ;;
++ sysv5* | sco5v6* | sysv4.2uw2*)
++ kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
++ if test -n "$kargmax"; then
++ lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'`
++ else
++ lt_cv_sys_max_cmd_len=32768
++ fi
+ ;;
+ *)
+- case $LD in # libtool.m4 will add one of these switches to LD
+- *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
+- libsuff= shlibsuff= libmagic=32-bit;;
+- *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
+- libsuff=32 shlibsuff=N32 libmagic=N32;;
+- *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
+- libsuff=64 shlibsuff=64 libmagic=64-bit;;
+- *) libsuff= shlibsuff= libmagic=never-match;;
+- esac
++ lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`
++ if test -n "$lt_cv_sys_max_cmd_len"; then
++ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
++ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
++ else
++ # Make teststring a little bigger before we do anything with it.
++ # a 1K string should be a reasonable start.
++ for i in 1 2 3 4 5 6 7 8 ; do
++ teststring=$teststring$teststring
++ done
++ SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
++ # If test is not a shell built-in, we'll probably end up computing a
++ # maximum length that is only half of the actual maximum length, but
++ # we can't tell.
++ while { test "X"`$SHELL [$]0 --fallback-echo "X$teststring$teststring" 2>/dev/null` \
++ = "XX$teststring$teststring"; } >/dev/null 2>&1 &&
++ test $i != 17 # 1/2 MB should be enough
++ do
++ i=`expr $i + 1`
++ teststring=$teststring$teststring
++ done
++ # Only check the string length outside the loop.
++ lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1`
++ teststring=
++ # Add a significant safety factor because C++ compilers can tack on
++ # massive amounts of additional arguments before passing them to the
++ # linker. It appears as though 1/2 is a usable value.
++ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
++ fi
+ ;;
+ esac
+- shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
+- shlibpath_overrides_runpath=no
+- sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
+- sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+- hardcode_into_libs=yes
+- ;;
++])
++if test -n $lt_cv_sys_max_cmd_len ; then
++ AC_MSG_RESULT($lt_cv_sys_max_cmd_len)
++else
++ AC_MSG_RESULT(none)
++fi
++max_cmd_len=$lt_cv_sys_max_cmd_len
++_LT_DECL([], [max_cmd_len], [0],
++ [What is the maximum length of a command?])
++])# LT_CMD_MAX_LEN
+
+-# No shared lib support for Linux oldld, aout, or coff.
+-linux*oldld* | linux*aout* | linux*coff*)
+- dynamic_linker=no
+- ;;
++# Old name:
++AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN])
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], [])
+
+-# This must be Linux ELF.
+-linux*)
+- version_type=linux
+- need_lib_prefix=no
+- need_version=no
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
+- shlibpath_var=LD_LIBRARY_PATH
+- shlibpath_overrides_runpath=no
+- # This implies no fast_install, which is unacceptable.
+- # Some rework will be needed to allow for fast_install
+- # before this can be enabled.
+- hardcode_into_libs=yes
+
+- # Append ld.so.conf contents to the search path
+- if test -f /etc/ld.so.conf; then
+- lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
+- sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+- fi
++# _LT_HEADER_DLFCN
++# ----------------
++m4_defun([_LT_HEADER_DLFCN],
++[AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl
++])# _LT_HEADER_DLFCN
+
+- # We used to test for /lib/ld.so.1 and disable shared libraries on
+- # powerpc, because MkLinux only supported shared libraries with the
+- # GNU dynamic linker. Since this was broken with cross compilers,
+- # most powerpc-linux boxes support dynamic linking these days and
+- # people can always --disable-shared, the test was removed, and we
+- # assume the GNU/Linux dynamic linker is in use.
+- dynamic_linker='GNU/Linux ld.so'
+- ;;
+
+-knetbsd*-gnu)
+- version_type=linux
+- need_lib_prefix=no
+- need_version=no
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- shlibpath_var=LD_LIBRARY_PATH
+- shlibpath_overrides_runpath=no
+- hardcode_into_libs=yes
+- dynamic_linker='GNU ld.so'
+- ;;
++# _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE,
++# ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING)
++# ----------------------------------------------------------------
++m4_defun([_LT_TRY_DLOPEN_SELF],
++[m4_require([_LT_HEADER_DLFCN])dnl
++if test "$cross_compiling" = yes; then :
++ [$4]
++else
++ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
++ lt_status=$lt_dlunknown
++ cat > conftest.$ac_ext <<_LT_EOF
++[#line __oline__ "configure"
++#include "confdefs.h"
+
+-netbsd*)
+- version_type=sunos
+- need_lib_prefix=no
+- need_version=no
+- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+- finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+- dynamic_linker='NetBSD (a.out) ld.so'
+- else
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- dynamic_linker='NetBSD ld.elf_so'
+- fi
+- shlibpath_var=LD_LIBRARY_PATH
+- shlibpath_overrides_runpath=yes
+- hardcode_into_libs=yes
+- ;;
++#if HAVE_DLFCN_H
++#include <dlfcn.h>
++#endif
+
+-newsos6)
+- version_type=linux
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+- shlibpath_var=LD_LIBRARY_PATH
+- shlibpath_overrides_runpath=yes
+- ;;
++#include <stdio.h>
+
+-nto-qnx*)
+- version_type=linux
+- need_lib_prefix=no
+- need_version=no
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- shlibpath_var=LD_LIBRARY_PATH
+- shlibpath_overrides_runpath=yes
+- ;;
++#ifdef RTLD_GLOBAL
++# define LT_DLGLOBAL RTLD_GLOBAL
++#else
++# ifdef DL_GLOBAL
++# define LT_DLGLOBAL DL_GLOBAL
++# else
++# define LT_DLGLOBAL 0
++# endif
++#endif
+
+-openbsd*)
+- version_type=sunos
+- sys_lib_dlsearch_path_spec="/usr/lib"
+- need_lib_prefix=no
+- # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
+- case $host_os in
+- openbsd3.3 | openbsd3.3.*) need_version=yes ;;
+- *) need_version=no ;;
+- esac
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+- finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+- shlibpath_var=LD_LIBRARY_PATH
+- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+- case $host_os in
+- openbsd2.[[89]] | openbsd2.[[89]].*)
+- shlibpath_overrides_runpath=no
+- ;;
+- *)
+- shlibpath_overrides_runpath=yes
+- ;;
+- esac
++/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
++ find out it does not work in some platform. */
++#ifndef LT_DLLAZY_OR_NOW
++# ifdef RTLD_LAZY
++# define LT_DLLAZY_OR_NOW RTLD_LAZY
++# else
++# ifdef DL_LAZY
++# define LT_DLLAZY_OR_NOW DL_LAZY
++# else
++# ifdef RTLD_NOW
++# define LT_DLLAZY_OR_NOW RTLD_NOW
++# else
++# ifdef DL_NOW
++# define LT_DLLAZY_OR_NOW DL_NOW
++# else
++# define LT_DLLAZY_OR_NOW 0
++# endif
++# endif
++# endif
++# endif
++#endif
++
++#ifdef __cplusplus
++extern "C" void exit (int);
++#endif
++
++void fnord() { int i=42;}
++int main ()
++{
++ void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
++ int status = $lt_dlunknown;
++
++ if (self)
++ {
++ if (dlsym (self,"fnord")) status = $lt_dlno_uscore;
++ else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
++ /* dlclose (self); */
++ }
+ else
+- shlibpath_overrides_runpath=yes
++ puts (dlerror ());
++
++ exit (status);
++}]
++_LT_EOF
++ if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then
++ (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null
++ lt_status=$?
++ case x$lt_status in
++ x$lt_dlno_uscore) $1 ;;
++ x$lt_dlneed_uscore) $2 ;;
++ x$lt_dlunknown|x*) $3 ;;
++ esac
++ else :
++ # compilation failed
++ $3
+ fi
+- ;;
++fi
++rm -fr conftest*
++])# _LT_TRY_DLOPEN_SELF
+
+-os2*)
+- libname_spec='$name'
+- shrext_cmds=".dll"
+- need_lib_prefix=no
+- library_names_spec='$libname${shared_ext} $libname.a'
+- dynamic_linker='OS/2 ld.exe'
+- shlibpath_var=LIBPATH
+- ;;
+
+-osf3* | osf4* | osf5*)
+- version_type=osf
+- need_lib_prefix=no
+- need_version=no
+- soname_spec='${libname}${release}${shared_ext}$major'
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+- shlibpath_var=LD_LIBRARY_PATH
+- sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
+- sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+- ;;
++# LT_SYS_DLOPEN_SELF
++# ------------------
++AC_DEFUN([LT_SYS_DLOPEN_SELF],
++[m4_require([_LT_HEADER_DLFCN])dnl
++if test "x$enable_dlopen" != xyes; then
++ enable_dlopen=unknown
++ enable_dlopen_self=unknown
++ enable_dlopen_self_static=unknown
++else
++ lt_cv_dlopen=no
++ lt_cv_dlopen_libs=
+
+-solaris*)
+- version_type=linux
+- need_lib_prefix=no
+- need_version=no
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- shlibpath_var=LD_LIBRARY_PATH
+- shlibpath_overrides_runpath=yes
+- hardcode_into_libs=yes
+- # ldd complains unless libraries are executable
+- postinstall_cmds='chmod +x $lib'
+- ;;
++ case $host_os in
++ beos*)
++ lt_cv_dlopen="load_add_on"
++ lt_cv_dlopen_libs=
++ lt_cv_dlopen_self=yes
++ ;;
+
+-sunos4*)
+- version_type=sunos
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+- finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
+- shlibpath_var=LD_LIBRARY_PATH
+- shlibpath_overrides_runpath=yes
+- if test "$with_gnu_ld" = yes; then
+- need_lib_prefix=no
+- fi
+- need_version=yes
+- ;;
++ mingw* | pw32*)
++ lt_cv_dlopen="LoadLibrary"
++ lt_cv_dlopen_libs=
++ ;;
+
+-sysv4 | sysv4.3*)
+- version_type=linux
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- shlibpath_var=LD_LIBRARY_PATH
+- case $host_vendor in
+- sni)
+- shlibpath_overrides_runpath=no
+- need_lib_prefix=no
+- export_dynamic_flag_spec='${wl}-Blargedynsym'
+- runpath_var=LD_RUN_PATH
+- ;;
+- siemens)
+- need_lib_prefix=no
+- ;;
+- motorola)
+- need_lib_prefix=no
+- need_version=no
+- shlibpath_overrides_runpath=no
+- sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
+- ;;
+- esac
+- ;;
++ cygwin*)
++ lt_cv_dlopen="dlopen"
++ lt_cv_dlopen_libs=
++ ;;
+
+-sysv4*MP*)
+- if test -d /usr/nec ;then
+- version_type=linux
+- library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
+- soname_spec='$libname${shared_ext}.$major'
+- shlibpath_var=LD_LIBRARY_PATH
+- fi
+- ;;
++ darwin*)
++ # if libdl is installed we need to link against it
++ AC_CHECK_LIB([dl], [dlopen],
++ [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[
++ lt_cv_dlopen="dyld"
++ lt_cv_dlopen_libs=
++ lt_cv_dlopen_self=yes
++ ])
++ ;;
+
+-sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+- version_type=freebsd-elf
+- need_lib_prefix=no
+- need_version=no
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- shlibpath_var=LD_LIBRARY_PATH
+- hardcode_into_libs=yes
+- if test "$with_gnu_ld" = yes; then
+- sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
+- shlibpath_overrides_runpath=no
++ *)
++ AC_CHECK_FUNC([shl_load],
++ [lt_cv_dlopen="shl_load"],
++ [AC_CHECK_LIB([dld], [shl_load],
++ [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"],
++ [AC_CHECK_FUNC([dlopen],
++ [lt_cv_dlopen="dlopen"],
++ [AC_CHECK_LIB([dl], [dlopen],
++ [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],
++ [AC_CHECK_LIB([svld], [dlopen],
++ [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"],
++ [AC_CHECK_LIB([dld], [dld_link],
++ [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"])
++ ])
++ ])
++ ])
++ ])
++ ])
++ ;;
++ esac
++
++ if test "x$lt_cv_dlopen" != xno; then
++ enable_dlopen=yes
+ else
+- sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
+- shlibpath_overrides_runpath=yes
+- case $host_os in
+- sco3.2v5*)
+- sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
+- ;;
+- esac
++ enable_dlopen=no
+ fi
+- sys_lib_dlsearch_path_spec='/usr/lib'
+- ;;
+-
+-uts4*)
+- version_type=linux
+- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+- soname_spec='${libname}${release}${shared_ext}$major'
+- shlibpath_var=LD_LIBRARY_PATH
+- ;;
+-
+-*)
+- dynamic_linker=no
+- ;;
+-esac
+-AC_MSG_RESULT([$dynamic_linker])
+-test "$dynamic_linker" = no && can_build_shared=no
+-
+-variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
+-if test "$GCC" = yes; then
+- variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
+-fi
+-])# AC_LIBTOOL_SYS_DYNAMIC_LINKER
+-
+
+-# _LT_AC_TAGCONFIG
+-# ----------------
+-AC_DEFUN([_LT_AC_TAGCONFIG],
+-[AC_ARG_WITH([tags],
+- [AC_HELP_STRING([--with-tags@<:@=TAGS@:>@],
+- [include additional configurations @<:@automatic@:>@])],
+- [tagnames="$withval"])
+-
+-if test -f "$ltmain" && test -n "$tagnames"; then
+- if test ! -f "${ofile}"; then
+- AC_MSG_WARN([output file `$ofile' does not exist])
+- fi
++ case $lt_cv_dlopen in
++ dlopen)
++ save_CPPFLAGS="$CPPFLAGS"
++ test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
+
+- if test -z "$LTCC"; then
+- eval "`$SHELL ${ofile} --config | grep '^LTCC='`"
+- if test -z "$LTCC"; then
+- AC_MSG_WARN([output file `$ofile' does not look like a libtool script])
+- else
+- AC_MSG_WARN([using `LTCC=$LTCC', extracted from `$ofile'])
+- fi
+- fi
+- if test -z "$LTCFLAGS"; then
+- eval "`$SHELL ${ofile} --config | grep '^LTCFLAGS='`"
+- fi
++ save_LDFLAGS="$LDFLAGS"
++ wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
+
+- # Extract list of available tagged configurations in $ofile.
+- # Note that this assumes the entire list is on one line.
+- available_tags=`grep "^available_tags=" "${ofile}" | $SED -e 's/available_tags=\(.*$\)/\1/' -e 's/\"//g'`
++ save_LIBS="$LIBS"
++ LIBS="$lt_cv_dlopen_libs $LIBS"
+
+- lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+- for tagname in $tagnames; do
+- IFS="$lt_save_ifs"
+- # Check whether tagname contains only valid characters
+- case `$echo "X$tagname" | $Xsed -e 's:[[-_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890,/]]::g'` in
+- "") ;;
+- *) AC_MSG_ERROR([invalid tag name: $tagname])
+- ;;
+- esac
++ AC_CACHE_CHECK([whether a program can dlopen itself],
++ lt_cv_dlopen_self, [dnl
++ _LT_TRY_DLOPEN_SELF(
++ lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes,
++ lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross)
++ ])
+
+- if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "${ofile}" > /dev/null
+- then
+- AC_MSG_ERROR([tag name \"$tagname\" already exists])
++ if test "x$lt_cv_dlopen_self" = xyes; then
++ wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
++ AC_CACHE_CHECK([whether a statically linked program can dlopen itself],
++ lt_cv_dlopen_self_static, [dnl
++ _LT_TRY_DLOPEN_SELF(
++ lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes,
++ lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross)
++ ])
+ fi
+
+- # Update the list of available tags.
+- if test -n "$tagname"; then
+- echo appending configuration tag \"$tagname\" to $ofile
+-
+- case $tagname in
+- CXX)
+- if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
+- ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
+- (test "X$CXX" != "Xg++"))) ; then
+- AC_LIBTOOL_LANG_CXX_CONFIG
+- else
+- tagname=""
+- fi
+- ;;
+-
+- F77)
+- if test -n "$F77" && test "X$F77" != "Xno"; then
+- AC_LIBTOOL_LANG_F77_CONFIG
+- else
+- tagname=""
+- fi
+- ;;
+-
+- GCJ)
+- if test -n "$GCJ" && test "X$GCJ" != "Xno"; then
+- AC_LIBTOOL_LANG_GCJ_CONFIG
+- else
+- tagname=""
+- fi
+- ;;
+-
+- RC)
+- AC_LIBTOOL_LANG_RC_CONFIG
+- ;;
+-
+- *)
+- AC_MSG_ERROR([Unsupported tag name: $tagname])
+- ;;
+- esac
++ CPPFLAGS="$save_CPPFLAGS"
++ LDFLAGS="$save_LDFLAGS"
++ LIBS="$save_LIBS"
++ ;;
++ esac
+
+- # Append the new tag name to the list of available tags.
+- if test -n "$tagname" ; then
+- available_tags="$available_tags $tagname"
+- fi
+- fi
+- done
+- IFS="$lt_save_ifs"
++ case $lt_cv_dlopen_self in
++ yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
++ *) enable_dlopen_self=unknown ;;
++ esac
+
+- # Now substitute the updated list of available tags.
+- if eval "sed -e 's/^available_tags=.*\$/available_tags=\"$available_tags\"/' \"$ofile\" > \"${ofile}T\""; then
+- mv "${ofile}T" "$ofile"
+- chmod +x "$ofile"
+- else
+- rm -f "${ofile}T"
+- AC_MSG_ERROR([unable to update list of available tagged configurations.])
+- fi
++ case $lt_cv_dlopen_self_static in
++ yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
++ *) enable_dlopen_self_static=unknown ;;
++ esac
+ fi
+-])# _LT_AC_TAGCONFIG
++_LT_DECL([dlopen_support], [enable_dlopen], [0],
++ [Whether dlopen is supported])
++_LT_DECL([dlopen_self], [enable_dlopen_self], [0],
++ [Whether dlopen of programs is supported])
++_LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0],
++ [Whether dlopen of statically linked programs is supported])
++])# LT_SYS_DLOPEN_SELF
++
++# Old name:
++AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF])
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], [])
+
+
+-# AC_LIBTOOL_DLOPEN
+-# -----------------
+-# enable checks for dlopen support
+-AC_DEFUN([AC_LIBTOOL_DLOPEN],
+- [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])
+-])# AC_LIBTOOL_DLOPEN
++# _LT_COMPILER_C_O([TAGNAME])
++# ---------------------------
++# Check to see if options -c and -o are simultaneously supported by compiler.
++# This macro does not hard code the compiler like AC_PROG_CC_C_O.
++m4_defun([_LT_COMPILER_C_O],
++[m4_require([_LT_DECL_SED])dnl
++m4_require([_LT_FILEUTILS_DEFAULTS])dnl
++m4_require([_LT_TAG_COMPILER])dnl
++AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext],
++ [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)],
++ [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no
++ $RM -r conftest 2>/dev/null
++ mkdir conftest
++ cd conftest
++ mkdir out
++ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
++ lt_compiler_flag="-o out/conftest2.$ac_objext"
++ # Insert the option either (1) after the last *FLAGS variable, or
++ # (2) before a word containing "conftest.", or (3) at the end.
++ # Note that $ac_compile itself does not contain backslashes and begins
++ # with a dollar sign (not a hyphen), so the echo should work correctly.
++ lt_compile=`echo "$ac_compile" | $SED \
++ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
++ -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
++ -e 's:$: $lt_compiler_flag:'`
++ (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
++ (eval "$lt_compile" 2>out/conftest.err)
++ ac_status=$?
++ cat out/conftest.err >&AS_MESSAGE_LOG_FD
++ echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
++ if (exit $ac_status) && test -s out/conftest2.$ac_objext
++ then
++ # The compiler can only warn and ignore the option if not recognized
++ # So say no if there are warnings
++ $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
++ $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
++ if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
++ _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
++ fi
++ fi
++ chmod u+w . 2>&AS_MESSAGE_LOG_FD
++ $RM conftest*
++ # SGI C++ compiler will create directory out/ii_files/ for
++ # template instantiation
++ test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
++ $RM out/* && rmdir out
++ cd ..
++ $RM -r conftest
++ $RM conftest*
++])
++_LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1],
++ [Does compiler simultaneously support -c and -o options?])
++])# _LT_COMPILER_C_O
+
+-# AC_LIBTOOL_WIN32_DLL
+-# --------------------
+-# declare package support for building win32 DLLs
+-AC_DEFUN([AC_LIBTOOL_WIN32_DLL],
+-[AC_BEFORE([$0], [AC_LIBTOOL_SETUP])
+-])# AC_LIBTOOL_WIN32_DLL
+
++# _LT_COMPILER_FILE_LOCKS([TAGNAME])
++# ----------------------------------
++# Check to see if we can do hard links to lock some files if needed
++m4_defun([_LT_COMPILER_FILE_LOCKS],
++[m4_require([_LT_ENABLE_LOCK])dnl
++m4_require([_LT_FILEUTILS_DEFAULTS])dnl
++_LT_COMPILER_C_O([$1])
+
+-# AC_ENABLE_SHARED([DEFAULT])
+-# ---------------------------
+-# implement the --enable-shared flag
+-# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
+-AC_DEFUN([AC_ENABLE_SHARED],
+-[define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl
+-AC_ARG_ENABLE([shared],
+- [AC_HELP_STRING([--enable-shared@<:@=PKGS@:>@],
+- [build shared libraries @<:@default=]AC_ENABLE_SHARED_DEFAULT[@:>@])],
+- [p=${PACKAGE-default}
+- case $enableval in
+- yes) enable_shared=yes ;;
+- no) enable_shared=no ;;
+- *)
+- enable_shared=no
+- # Look at the argument we got. We use all the common list separators.
+- lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+- for pkg in $enableval; do
+- IFS="$lt_save_ifs"
+- if test "X$pkg" = "X$p"; then
+- enable_shared=yes
+- fi
+- done
+- IFS="$lt_save_ifs"
+- ;;
+- esac],
+- [enable_shared=]AC_ENABLE_SHARED_DEFAULT)
+-])# AC_ENABLE_SHARED
+-
+-
+-# AC_DISABLE_SHARED
+-# -----------------
+-# set the default shared flag to --disable-shared
+-AC_DEFUN([AC_DISABLE_SHARED],
+-[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+-AC_ENABLE_SHARED(no)
+-])# AC_DISABLE_SHARED
+-
+-
+-# AC_ENABLE_STATIC([DEFAULT])
+-# ---------------------------
+-# implement the --enable-static flag
+-# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
+-AC_DEFUN([AC_ENABLE_STATIC],
+-[define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl
+-AC_ARG_ENABLE([static],
+- [AC_HELP_STRING([--enable-static@<:@=PKGS@:>@],
+- [build static libraries @<:@default=]AC_ENABLE_STATIC_DEFAULT[@:>@])],
+- [p=${PACKAGE-default}
+- case $enableval in
+- yes) enable_static=yes ;;
+- no) enable_static=no ;;
+- *)
+- enable_static=no
+- # Look at the argument we got. We use all the common list separators.
+- lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+- for pkg in $enableval; do
+- IFS="$lt_save_ifs"
+- if test "X$pkg" = "X$p"; then
+- enable_static=yes
+- fi
+- done
+- IFS="$lt_save_ifs"
+- ;;
+- esac],
+- [enable_static=]AC_ENABLE_STATIC_DEFAULT)
+-])# AC_ENABLE_STATIC
+-
+-
+-# AC_DISABLE_STATIC
+-# -----------------
+-# set the default static flag to --disable-static
+-AC_DEFUN([AC_DISABLE_STATIC],
+-[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+-AC_ENABLE_STATIC(no)
+-])# AC_DISABLE_STATIC
+-
+-
+-# AC_ENABLE_FAST_INSTALL([DEFAULT])
+-# ---------------------------------
+-# implement the --enable-fast-install flag
+-# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
+-AC_DEFUN([AC_ENABLE_FAST_INSTALL],
+-[define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl
+-AC_ARG_ENABLE([fast-install],
+- [AC_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@],
+- [optimize for fast installation @<:@default=]AC_ENABLE_FAST_INSTALL_DEFAULT[@:>@])],
+- [p=${PACKAGE-default}
+- case $enableval in
+- yes) enable_fast_install=yes ;;
+- no) enable_fast_install=no ;;
+- *)
+- enable_fast_install=no
+- # Look at the argument we got. We use all the common list separators.
+- lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+- for pkg in $enableval; do
+- IFS="$lt_save_ifs"
+- if test "X$pkg" = "X$p"; then
+- enable_fast_install=yes
+- fi
+- done
+- IFS="$lt_save_ifs"
+- ;;
+- esac],
+- [enable_fast_install=]AC_ENABLE_FAST_INSTALL_DEFAULT)
+-])# AC_ENABLE_FAST_INSTALL
+-
+-
+-# AC_DISABLE_FAST_INSTALL
+-# -----------------------
+-# set the default to --disable-fast-install
+-AC_DEFUN([AC_DISABLE_FAST_INSTALL],
+-[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+-AC_ENABLE_FAST_INSTALL(no)
+-])# AC_DISABLE_FAST_INSTALL
+-
+-
+-# AC_LIBTOOL_PICMODE([MODE])
+-# --------------------------
+-# implement the --with-pic flag
+-# MODE is either `yes' or `no'. If omitted, it defaults to `both'.
+-AC_DEFUN([AC_LIBTOOL_PICMODE],
+-[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+-pic_mode=ifelse($#,1,$1,default)
+-])# AC_LIBTOOL_PICMODE
+-
+-
+-# AC_PROG_EGREP
+-# -------------
+-# This is predefined starting with Autoconf 2.54, so this conditional
+-# definition can be removed once we require Autoconf 2.54 or later.
+-m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP],
+-[AC_CACHE_CHECK([for egrep], [ac_cv_prog_egrep],
+- [if echo a | (grep -E '(a|b)') >/dev/null 2>&1
+- then ac_cv_prog_egrep='grep -E'
+- else ac_cv_prog_egrep='egrep'
+- fi])
+- EGREP=$ac_cv_prog_egrep
+- AC_SUBST([EGREP])
+-])])
+-
+-
+-# AC_PATH_TOOL_PREFIX
+-# -------------------
+-# find a file program which can recognise shared library
+-AC_DEFUN([AC_PATH_TOOL_PREFIX],
+-[AC_REQUIRE([AC_PROG_EGREP])dnl
+-AC_MSG_CHECKING([for $1])
+-AC_CACHE_VAL(lt_cv_path_MAGIC_CMD,
+-[case $MAGIC_CMD in
+-[[\\/*] | ?:[\\/]*])
+- lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+- ;;
+-*)
+- lt_save_MAGIC_CMD="$MAGIC_CMD"
+- lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+-dnl $ac_dummy forces splitting on constant user-supplied paths.
+-dnl POSIX.2 word splitting is done only on the output of word expansions,
+-dnl not every word. This closes a longstanding sh security hole.
+- ac_dummy="ifelse([$2], , $PATH, [$2])"
+- for ac_dir in $ac_dummy; do
+- IFS="$lt_save_ifs"
+- test -z "$ac_dir" && ac_dir=.
+- if test -f $ac_dir/$1; then
+- lt_cv_path_MAGIC_CMD="$ac_dir/$1"
+- if test -n "$file_magic_test_file"; then
+- case $deplibs_check_method in
+- "file_magic "*)
+- file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
+- MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+- if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
+- $EGREP "$file_magic_regex" > /dev/null; then
+- :
+- else
+- cat <<EOF 1>&2
++hard_links="nottested"
++if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then
++ # do not overwrite the value of need_locks provided by the user
++ AC_MSG_CHECKING([if we can lock with hard links])
++ hard_links=yes
++ $RM conftest*
++ ln conftest.a conftest.b 2>/dev/null && hard_links=no
++ touch conftest.a
++ ln conftest.a conftest.b 2>&5 || hard_links=no
++ ln conftest.a conftest.b 2>/dev/null && hard_links=no
++ AC_MSG_RESULT([$hard_links])
++ if test "$hard_links" = no; then
++ AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe])
++ need_locks=warn
++ fi
++else
++ need_locks=no
++fi
++_LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?])
++])# _LT_COMPILER_FILE_LOCKS
+
+-*** Warning: the command libtool uses to detect shared libraries,
+-*** $file_magic_cmd, produces output that libtool cannot recognize.
+-*** The result is that libtool may fail to recognize shared libraries
+-*** as such. This will affect the creation of libtool libraries that
+-*** depend on shared libraries, but programs linked with such libtool
+-*** libraries will work regardless of this problem. Nevertheless, you
+-*** may want to report the problem to your system manager and/or to
+-*** bug-libtool@gnu.org
+
+-EOF
+- fi ;;
+- esac
+- fi
+- break
+- fi
+- done
+- IFS="$lt_save_ifs"
+- MAGIC_CMD="$lt_save_MAGIC_CMD"
+- ;;
+-esac])
+-MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+-if test -n "$MAGIC_CMD"; then
+- AC_MSG_RESULT($MAGIC_CMD)
++# _LT_CHECK_OBJDIR
++# ----------------
++m4_defun([_LT_CHECK_OBJDIR],
++[AC_CACHE_CHECK([for objdir], [lt_cv_objdir],
++[rm -f .libs 2>/dev/null
++mkdir .libs 2>/dev/null
++if test -d .libs; then
++ lt_cv_objdir=.libs
+ else
+- AC_MSG_RESULT(no)
++ # MS-DOS does not allow filenames that begin with a dot.
++ lt_cv_objdir=_libs
+ fi
+-])# AC_PATH_TOOL_PREFIX
++rmdir .libs 2>/dev/null])
++objdir=$lt_cv_objdir
++_LT_DECL([], [objdir], [0],
++ [The name of the directory that contains temporary libtool files])dnl
++m4_pattern_allow([LT_OBJDIR])dnl
++AC_DEFINE_UNQUOTED(LT_OBJDIR, "$lt_cv_objdir/",
++ [Define to the sub-directory in which libtool stores uninstalled libraries.])
++])# _LT_CHECK_OBJDIR
+
+
+-# AC_PATH_MAGIC
+-# -------------
+-# find a file program which can recognise a shared library
+-AC_DEFUN([AC_PATH_MAGIC],
+-[AC_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH)
+-if test -z "$lt_cv_path_MAGIC_CMD"; then
+- if test -n "$ac_tool_prefix"; then
+- AC_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH)
++# _LT_LINKER_HARDCODE_LIBPATH([TAGNAME])
++# --------------------------------------
++# Check hardcoding attributes.
++m4_defun([_LT_LINKER_HARDCODE_LIBPATH],
++[AC_MSG_CHECKING([how to hardcode library paths into programs])
++_LT_TAGVAR(hardcode_action, $1)=
++if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" ||
++ test -n "$_LT_TAGVAR(runpath_var, $1)" ||
++ test "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then
++
++ # We can hardcode non-existent directories.
++ if test "$_LT_TAGVAR(hardcode_direct, $1)" != no &&
++ # If the only mechanism to avoid hardcoding is shlibpath_var, we
++ # have to relink, otherwise we might link with an installed library
++ # when we should be linking with a yet-to-be-installed one
++ ## test "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" != no &&
++ test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; then
++ # Linking always hardcodes the temporary library directory.
++ _LT_TAGVAR(hardcode_action, $1)=relink
+ else
+- MAGIC_CMD=:
++ # We can link without hardcoding, and we can hardcode nonexisting dirs.
++ _LT_TAGVAR(hardcode_action, $1)=immediate
+ fi
++else
++ # We cannot hardcode anything, or else we can only hardcode existing
++ # directories.
++ _LT_TAGVAR(hardcode_action, $1)=unsupported
++fi
++AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)])
++
++if test "$_LT_TAGVAR(hardcode_action, $1)" = relink ||
++ test "$_LT_TAGVAR(inherit_rpath, $1)" = yes; then
++ # Fast installation is not supported
++ enable_fast_install=no
++elif test "$shlibpath_overrides_runpath" = yes ||
++ test "$enable_shared" = no; then
++ # Fast installation is not necessary
++ enable_fast_install=needless
+ fi
+-])# AC_PATH_MAGIC
++_LT_TAGDECL([], [hardcode_action], [0],
++ [How to hardcode a shared library path into an executable])
++])# _LT_LINKER_HARDCODE_LIBPATH
+
+
+-# AC_PROG_LD
+-# ----------
+-# find the pathname to the GNU or non-GNU linker
+-AC_DEFUN([AC_PROG_LD],
+-[AC_ARG_WITH([gnu-ld],
+- [AC_HELP_STRING([--with-gnu-ld],
+- [assume the C compiler uses GNU ld @<:@default=no@:>@])],
+- [test "$withval" = no || with_gnu_ld=yes],
+- [with_gnu_ld=no])
+-AC_REQUIRE([LT_AC_PROG_SED])dnl
+-AC_REQUIRE([AC_PROG_CC])dnl
+-AC_REQUIRE([AC_CANONICAL_HOST])dnl
+-AC_REQUIRE([AC_CANONICAL_BUILD])dnl
+-ac_prog=ld
+-if test "$GCC" = yes; then
+- # Check if gcc -print-prog-name=ld gives a path.
+- AC_MSG_CHECKING([for ld used by $CC])
+- case $host in
+- *-*-mingw*)
+- # gcc leaves a trailing carriage return which upsets mingw
+- ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
+- *)
+- ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
+- esac
+- case $ac_prog in
+- # Accept absolute paths.
+- [[\\/]]* | ?:[[\\/]]*)
+- re_direlt='/[[^/]][[^/]]*/\.\./'
+- # Canonicalize the pathname of ld
+- ac_prog=`echo $ac_prog| $SED 's%\\\\%/%g'`
+- while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
+- ac_prog=`echo $ac_prog| $SED "s%$re_direlt%/%"`
+- done
+- test -z "$LD" && LD="$ac_prog"
+- ;;
+- "")
+- # If it fails, then pretend we aren't using GCC.
+- ac_prog=ld
++# _LT_CMD_STRIPLIB
++# ----------------
++m4_defun([_LT_CMD_STRIPLIB],
++[m4_require([_LT_DECL_EGREP])
++striplib=
++old_striplib=
++AC_MSG_CHECKING([whether stripping libraries is possible])
++if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then
++ test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
++ test -z "$striplib" && striplib="$STRIP --strip-unneeded"
++ AC_MSG_RESULT([yes])
++else
++# FIXME - insert some real tests, host_os isn't really good enough
++ case $host_os in
++ darwin*)
++ if test -n "$STRIP" ; then
++ striplib="$STRIP -x"
++ old_striplib="$STRIP -S"
++ AC_MSG_RESULT([yes])
++ else
++ AC_MSG_RESULT([no])
++ fi
+ ;;
+ *)
+- # If it is relative, then search for the first ld in PATH.
+- with_gnu_ld=unknown
++ AC_MSG_RESULT([no])
+ ;;
+ esac
+-elif test "$with_gnu_ld" = yes; then
+- AC_MSG_CHECKING([for GNU ld])
+-else
+- AC_MSG_CHECKING([for non-GNU ld])
+ fi
+-AC_CACHE_VAL(lt_cv_path_LD,
+-[if test -z "$LD"; then
+- lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+- for ac_dir in $PATH; do
+- IFS="$lt_save_ifs"
+- test -z "$ac_dir" && ac_dir=.
+- if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+- lt_cv_path_LD="$ac_dir/$ac_prog"
+- # Check to see if the program is GNU ld. I'd rather use --version,
+- # but apparently some variants of GNU ld only accept -v.
+- # Break only if it was the GNU/non-GNU ld that we prefer.
+- case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
+- *GNU* | *'with BFD'*)
+- test "$with_gnu_ld" != no && break
+- ;;
+- *)
+- test "$with_gnu_ld" != yes && break
+- ;;
+- esac
++_LT_DECL([], [old_striplib], [1], [Commands to strip libraries])
++_LT_DECL([], [striplib], [1])
++])# _LT_CMD_STRIPLIB
++
++
++# _LT_SYS_DYNAMIC_LINKER([TAG])
++# -----------------------------
++# PORTME Fill in your ld.so characteristics
++m4_defun([_LT_SYS_DYNAMIC_LINKER],
++[AC_REQUIRE([AC_CANONICAL_HOST])dnl
++m4_require([_LT_DECL_EGREP])dnl
++m4_require([_LT_FILEUTILS_DEFAULTS])dnl
++m4_require([_LT_DECL_SED])dnl
++AC_MSG_CHECKING([dynamic linker characteristics])
++m4_if([$1],
++ [], [
++if test "$GCC" = yes; then
++ case $host_os in
++ darwin*) lt_awk_arg="/^libraries:/,/LR/" ;;
++ *) lt_awk_arg="/^libraries:/" ;;
++ esac
++ lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e "s,=/,/,g"`
++ if $ECHO "$lt_search_path_spec" | $GREP ';' >/dev/null ; then
++ # if the path contains ";" then we assume it to be the separator
++ # otherwise default to the standard path separator (i.e. ":") - it is
++ # assumed that no part of a normal pathname contains ";" but that should
++ # okay in the real world where ";" in dirpaths is itself problematic.
++ lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e 's/;/ /g'`
++ else
++ lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
++ fi
++ # Ok, now we have the path, separated by spaces, we can step through it
++ # and add multilib dir if necessary.
++ lt_tmp_lt_search_path_spec=
++ lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
++ for lt_sys_path in $lt_search_path_spec; do
++ if test -d "$lt_sys_path/$lt_multi_os_dir"; then
++ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir"
++ else
++ test -d "$lt_sys_path" && \
++ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path"
+ fi
+ done
+- IFS="$lt_save_ifs"
++ lt_search_path_spec=`$ECHO $lt_tmp_lt_search_path_spec | awk '
++BEGIN {RS=" "; FS="/|\n";} {
++ lt_foo="";
++ lt_count=0;
++ for (lt_i = NF; lt_i > 0; lt_i--) {
++ if ($lt_i != "" && $lt_i != ".") {
++ if ($lt_i == "..") {
++ lt_count++;
++ } else {
++ if (lt_count == 0) {
++ lt_foo="/" $lt_i lt_foo;
++ } else {
++ lt_count--;
++ }
++ }
++ }
++ }
++ if (lt_foo != "") { lt_freq[[lt_foo]]++; }
++ if (lt_freq[[lt_foo]] == 1) { print lt_foo; }
++}'`
++ sys_lib_search_path_spec=`$ECHO $lt_search_path_spec`
+ else
+- lt_cv_path_LD="$LD" # Let the user override the test with a path.
++ sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+ fi])
+-LD="$lt_cv_path_LD"
+-if test -n "$LD"; then
+- AC_MSG_RESULT($LD)
+-else
+- AC_MSG_RESULT(no)
+-fi
+-test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
+-AC_PROG_LD_GNU
+-])# AC_PROG_LD
++library_names_spec=
++libname_spec='lib$name'
++soname_spec=
++shrext_cmds=".so"
++postinstall_cmds=
++postuninstall_cmds=
++finish_cmds=
++finish_eval=
++shlibpath_var=
++shlibpath_overrides_runpath=unknown
++version_type=none
++dynamic_linker="$host_os ld.so"
++sys_lib_dlsearch_path_spec="/lib /usr/lib"
++need_lib_prefix=unknown
++hardcode_into_libs=no
++
++# when you set need_version to no, make sure it does not cause -set_version
++# flags to be left without arguments
++need_version=unknown
+
++case $host_os in
++aix3*)
++ version_type=linux
++ library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
++ shlibpath_var=LIBPATH
+
+-# AC_PROG_LD_GNU
+-# --------------
+-AC_DEFUN([AC_PROG_LD_GNU],
+-[AC_REQUIRE([AC_PROG_EGREP])dnl
+-AC_CACHE_CHECK([if the linker ($LD) is GNU ld], lt_cv_prog_gnu_ld,
+-[# I'd rather use --version here, but apparently some GNU lds only accept -v.
+-case `$LD -v 2>&1 </dev/null` in
+-*GNU* | *'with BFD'*)
+- lt_cv_prog_gnu_ld=yes
++ # AIX 3 has no versioning support, so we append a major version to the name.
++ soname_spec='${libname}${release}${shared_ext}$major'
+ ;;
+-*)
+- lt_cv_prog_gnu_ld=no
+- ;;
+-esac])
+-with_gnu_ld=$lt_cv_prog_gnu_ld
+-])# AC_PROG_LD_GNU
+-
+
+-# AC_PROG_LD_RELOAD_FLAG
+-# ----------------------
+-# find reload flag for linker
+-# -- PORTME Some linkers may need a different reload flag.
+-AC_DEFUN([AC_PROG_LD_RELOAD_FLAG],
+-[AC_CACHE_CHECK([for $LD option to reload object files],
+- lt_cv_ld_reload_flag,
+- [lt_cv_ld_reload_flag='-r'])
+-reload_flag=$lt_cv_ld_reload_flag
+-case $reload_flag in
+-"" | " "*) ;;
+-*) reload_flag=" $reload_flag" ;;
+-esac
+-reload_cmds='$LD$reload_flag -o $output$reload_objs'
+-case $host_os in
+- darwin*)
+- if test "$GCC" = yes; then
+- reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
++aix[[4-9]]*)
++ version_type=linux
++ need_lib_prefix=no
++ need_version=no
++ hardcode_into_libs=yes
++ if test "$host_cpu" = ia64; then
++ # AIX 5 supports IA64
++ library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
++ shlibpath_var=LD_LIBRARY_PATH
++ else
++ # With GCC up to 2.95.x, collect2 would create an import file
++ # for dependence libraries. The import file would start with
++ # the line `#! .'. This would cause the generated library to
++ # depend on `.', always an invalid library. This was fixed in
++ # development snapshots of GCC prior to 3.0.
++ case $host_os in
++ aix4 | aix4.[[01]] | aix4.[[01]].*)
++ if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
++ echo ' yes '
++ echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
++ :
++ else
++ can_build_shared=no
++ fi
++ ;;
++ esac
++ # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
++ # soname into executable. Probably we can add versioning support to
++ # collect2, so additional links can be useful in future.
++ if test "$aix_use_runtimelinking" = yes; then
++ # If using run time linking (on AIX 4.2 or later) use lib<name>.so
++ # instead of lib<name>.a to let people know that these are not
++ # typical AIX shared libraries.
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ else
+- reload_cmds='$LD$reload_flag -o $output$reload_objs'
++ # We preserve .a as extension for shared libraries through AIX4.2
++ # and later when we are not doing run time linking.
++ library_names_spec='${libname}${release}.a $libname.a'
++ soname_spec='${libname}${release}${shared_ext}$major'
+ fi
+- ;;
+-esac
+-])# AC_PROG_LD_RELOAD_FLAG
+-
+-
+-# AC_DEPLIBS_CHECK_METHOD
+-# -----------------------
+-# how to check for library dependencies
+-# -- PORTME fill in with the dynamic library characteristics
+-AC_DEFUN([AC_DEPLIBS_CHECK_METHOD],
+-[AC_CACHE_CHECK([how to recognise dependent libraries],
+-lt_cv_deplibs_check_method,
+-[lt_cv_file_magic_cmd='$MAGIC_CMD'
+-lt_cv_file_magic_test_file=
+-lt_cv_deplibs_check_method='unknown'
+-# Need to set the preceding variable on all platforms that support
+-# interlibrary dependencies.
+-# 'none' -- dependencies not supported.
+-# `unknown' -- same as none, but documents that we really don't know.
+-# 'pass_all' -- all dependencies passed with no checks.
+-# 'test_compile' -- check by making test program.
+-# 'file_magic [[regex]]' -- check by looking for files in library path
+-# which responds to the $file_magic_cmd with a given extended regex.
+-# If you have `file' or equivalent on your system and you're not sure
+-# whether `pass_all' will *always* work, you probably want this one.
++ shlibpath_var=LIBPATH
++ fi
++ ;;
+
+-case $host_os in
+-aix4* | aix5*)
+- lt_cv_deplibs_check_method=pass_all
++amigaos*)
++ case $host_cpu in
++ powerpc)
++ # Since July 2007 AmigaOS4 officially supports .so libraries.
++ # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
++ ;;
++ m68k)
++ library_names_spec='$libname.ixlibrary $libname.a'
++ # Create ${libname}_ixlibrary.a entries in /sys/libs.
++ finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$ECHO "X$lib" | $Xsed -e '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
++ ;;
++ esac
+ ;;
+
+ beos*)
+- lt_cv_deplibs_check_method=pass_all
++ library_names_spec='${libname}${shared_ext}'
++ dynamic_linker="$host_os ld.so"
++ shlibpath_var=LIBRARY_PATH
+ ;;
+
+ bsdi[[45]]*)
+- lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib)'
+- lt_cv_file_magic_cmd='/usr/bin/file -L'
+- lt_cv_file_magic_test_file=/shlib/libc.so
+- ;;
+-
+-cygwin*)
+- # func_win32_libid is a shell function defined in ltmain.sh
+- lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+- lt_cv_file_magic_cmd='func_win32_libid'
++ version_type=linux
++ need_version=no
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
++ soname_spec='${libname}${release}${shared_ext}$major'
++ finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
++ shlibpath_var=LD_LIBRARY_PATH
++ sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
++ sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
++ # the default ld.so.conf also contains /usr/contrib/lib and
++ # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
++ # libtool to hard-code these into programs
+ ;;
+
+-mingw* | pw32*)
+- # Base MSYS/MinGW do not provide the 'file' command needed by
+- # func_win32_libid shell function, so use a weaker test based on 'objdump'.
+- lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?'
+- lt_cv_file_magic_cmd='$OBJDUMP -f'
+- ;;
++cygwin* | mingw* | pw32*)
++ version_type=windows
++ shrext_cmds=".dll"
++ need_version=no
++ need_lib_prefix=no
+
+-darwin* | rhapsody*)
+- lt_cv_deplibs_check_method=pass_all
+- ;;
++ case $GCC,$host_os in
++ yes,cygwin* | yes,mingw* | yes,pw32*)
++ library_names_spec='$libname.dll.a'
++ # DLL is installed to $(libdir)/../bin by postinstall_cmds
++ postinstall_cmds='base_file=`basename \${file}`~
++ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
++ dldir=$destdir/`dirname \$dlpath`~
++ test -d \$dldir || mkdir -p \$dldir~
++ $install_prog $dir/$dlname \$dldir/$dlname~
++ chmod a+x \$dldir/$dlname~
++ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
++ eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
++ fi'
++ postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
++ dlpath=$dir/\$dldll~
++ $RM \$dlpath'
++ shlibpath_overrides_runpath=yes
+
+-freebsd* | kfreebsd*-gnu | dragonfly*)
+- if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+- case $host_cpu in
+- i*86 )
+- # Not sure whether the presence of OpenBSD here was a mistake.
+- # Let's accept both of them until this is cleared up.
+- lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library'
+- lt_cv_file_magic_cmd=/usr/bin/file
+- lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
++ case $host_os in
++ cygwin*)
++ # Cygwin DLLs use 'cyg' prefix rather than 'lib'
++ soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
++ sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
++ ;;
++ mingw*)
++ # MinGW DLLs use traditional 'lib' prefix
++ soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
++ sys_lib_search_path_spec=`$CC -print-search-dirs | $GREP "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
++ if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then
++ # It is most probably a Windows format PATH printed by
++ # mingw gcc, but we are running on Cygwin. Gcc prints its search
++ # path with ; separators, and with drive letters. We can handle the
++ # drive letters (cygwin fileutils understands them), so leave them,
++ # especially as we might pass files found there to a mingw objdump,
++ # which wouldn't understand a cygwinified path. Ahh.
++ sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
++ else
++ sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
++ fi
++ ;;
++ pw32*)
++ # pw32 DLLs use 'pw' prefix rather than 'lib'
++ library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+ ;;
+ esac
+- else
+- lt_cv_deplibs_check_method=pass_all
+- fi
+- ;;
+-
+-gnu*)
+- lt_cv_deplibs_check_method=pass_all
+- ;;
+-
+-hpux10.20* | hpux11*)
+- lt_cv_file_magic_cmd=/usr/bin/file
+- case $host_cpu in
+- ia64*)
+- lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64'
+- lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
+- ;;
+- hppa*64*)
+- [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]']
+- lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
+ ;;
++
+ *)
+- lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]].[[0-9]]) shared library'
+- lt_cv_file_magic_test_file=/usr/lib/libc.sl
++ library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib'
+ ;;
+ esac
++ dynamic_linker='Win32 ld.exe'
++ # FIXME: first we should search . and the directory the executable is in
++ shlibpath_var=PATH
+ ;;
+
+-interix3*)
+- # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
+- lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$'
+- ;;
+-
+-irix5* | irix6* | nonstopux*)
+- case $LD in
+- *-32|*"-32 ") libmagic=32-bit;;
+- *-n32|*"-n32 ") libmagic=N32;;
+- *-64|*"-64 ") libmagic=64-bit;;
+- *) libmagic=never-match;;
+- esac
+- lt_cv_deplibs_check_method=pass_all
+- ;;
+-
+-# This must be Linux ELF.
+-linux*)
+- lt_cv_deplibs_check_method=pass_all
+- ;;
+-
+-netbsd*)
+- if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+- lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
+- else
+- lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$'
+- fi
++darwin* | rhapsody*)
++ dynamic_linker="$host_os dyld"
++ version_type=darwin
++ need_lib_prefix=no
++ need_version=no
++ library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
++ soname_spec='${libname}${release}${major}$shared_ext'
++ shlibpath_overrides_runpath=yes
++ shlibpath_var=DYLD_LIBRARY_PATH
++ shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
++m4_if([$1], [],[
++ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"])
++ sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
+ ;;
+
+-newos6*)
+- lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)'
+- lt_cv_file_magic_cmd=/usr/bin/file
+- lt_cv_file_magic_test_file=/usr/lib/libnls.so
++dgux*)
++ version_type=linux
++ need_lib_prefix=no
++ need_version=no
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
++ soname_spec='${libname}${release}${shared_ext}$major'
++ shlibpath_var=LD_LIBRARY_PATH
+ ;;
+
+-nto-qnx*)
+- lt_cv_deplibs_check_method=unknown
++freebsd1*)
++ dynamic_linker=no
+ ;;
+
+-openbsd*)
+- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+- lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$'
++freebsd* | dragonfly*)
++ # DragonFly does not have aout. When/if they implement a new
++ # versioning mechanism, adjust this.
++ if test -x /usr/bin/objformat; then
++ objformat=`/usr/bin/objformat`
+ else
+- lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
++ case $host_os in
++ freebsd[[123]]*) objformat=aout ;;
++ *) objformat=elf ;;
++ esac
+ fi
+- ;;
+-
+-osf3* | osf4* | osf5*)
+- lt_cv_deplibs_check_method=pass_all
+- ;;
+-
+-solaris*)
+- lt_cv_deplibs_check_method=pass_all
+- ;;
+-
+-sysv4 | sysv4.3*)
+- case $host_vendor in
+- motorola)
+- lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]'
+- lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
+- ;;
+- ncr)
+- lt_cv_deplibs_check_method=pass_all
+- ;;
+- sequent)
+- lt_cv_file_magic_cmd='/bin/file'
+- lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )'
++ version_type=freebsd-$objformat
++ case $version_type in
++ freebsd-elf*)
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
++ need_version=no
++ need_lib_prefix=no
++ ;;
++ freebsd-*)
++ library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
++ need_version=yes
++ ;;
++ esac
++ shlibpath_var=LD_LIBRARY_PATH
++ case $host_os in
++ freebsd2*)
++ shlibpath_overrides_runpath=yes
+ ;;
+- sni)
+- lt_cv_file_magic_cmd='/bin/file'
+- lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib"
+- lt_cv_file_magic_test_file=/lib/libc.so
++ freebsd3.[[01]]* | freebsdelf3.[[01]]*)
++ shlibpath_overrides_runpath=yes
++ hardcode_into_libs=yes
+ ;;
+- siemens)
+- lt_cv_deplibs_check_method=pass_all
++ freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \
++ freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1)
++ shlibpath_overrides_runpath=no
++ hardcode_into_libs=yes
+ ;;
+- pc)
+- lt_cv_deplibs_check_method=pass_all
++ *) # from 4.6 on, and DragonFly
++ shlibpath_overrides_runpath=yes
++ hardcode_into_libs=yes
+ ;;
+ esac
+ ;;
+
+-sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+- lt_cv_deplibs_check_method=pass_all
++gnu*)
++ version_type=linux
++ need_lib_prefix=no
++ need_version=no
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
++ soname_spec='${libname}${release}${shared_ext}$major'
++ shlibpath_var=LD_LIBRARY_PATH
++ hardcode_into_libs=yes
+ ;;
+-esac
+-])
+-file_magic_cmd=$lt_cv_file_magic_cmd
+-deplibs_check_method=$lt_cv_deplibs_check_method
+-test -z "$deplibs_check_method" && deplibs_check_method=unknown
+-])# AC_DEPLIBS_CHECK_METHOD
+
+-
+-# AC_PROG_NM
+-# ----------
+-# find the pathname to a BSD-compatible name lister
+-AC_DEFUN([AC_PROG_NM],
+-[AC_CACHE_CHECK([for BSD-compatible nm], lt_cv_path_NM,
+-[if test -n "$NM"; then
+- # Let the user override the test.
+- lt_cv_path_NM="$NM"
+-else
+- lt_nm_to_check="${ac_tool_prefix}nm"
+- if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
+- lt_nm_to_check="$lt_nm_to_check nm"
+- fi
+- for lt_tmp_nm in $lt_nm_to_check; do
+- lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+- for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
+- IFS="$lt_save_ifs"
+- test -z "$ac_dir" && ac_dir=.
+- tmp_nm="$ac_dir/$lt_tmp_nm"
+- if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
+- # Check to see if the nm accepts a BSD-compat flag.
+- # Adding the `sed 1q' prevents false positives on HP-UX, which says:
+- # nm: unknown option "B" ignored
+- # Tru64's nm complains that /dev/null is an invalid object file
+- case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
+- */dev/null* | *'Invalid file or object type'*)
+- lt_cv_path_NM="$tmp_nm -B"
+- break
+- ;;
+- *)
+- case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
+- */dev/null*)
+- lt_cv_path_NM="$tmp_nm -p"
+- break
+- ;;
+- *)
+- lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
+- continue # so that we can try to find one that supports BSD flags
+- ;;
+- esac
+- ;;
+- esac
+- fi
+- done
+- IFS="$lt_save_ifs"
+- done
+- test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm
+-fi])
+-NM="$lt_cv_path_NM"
+-])# AC_PROG_NM
+-
+-
+-# AC_CHECK_LIBM
+-# -------------
+-# check for math library
+-AC_DEFUN([AC_CHECK_LIBM],
+-[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+-LIBM=
+-case $host in
+-*-*-beos* | *-*-cygwin* | *-*-pw32* | *-*-darwin*)
+- # These system don't have libm, or don't need it
+- ;;
+-*-ncr-sysv4.3*)
+- AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
+- AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm")
+- ;;
+-*)
+- AC_CHECK_LIB(m, cos, LIBM="-lm")
++hpux9* | hpux10* | hpux11*)
++ # Give a soname corresponding to the major version so that dld.sl refuses to
++ # link against other versions.
++ version_type=sunos
++ need_lib_prefix=no
++ need_version=no
++ case $host_cpu in
++ ia64*)
++ shrext_cmds='.so'
++ hardcode_into_libs=yes
++ dynamic_linker="$host_os dld.so"
++ shlibpath_var=LD_LIBRARY_PATH
++ shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
++ soname_spec='${libname}${release}${shared_ext}$major'
++ if test "X$HPUX_IA64_MODE" = X32; then
++ sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
++ else
++ sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
++ fi
++ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
++ ;;
++ hppa*64*)
++ shrext_cmds='.sl'
++ hardcode_into_libs=yes
++ dynamic_linker="$host_os dld.sl"
++ shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
++ shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
++ soname_spec='${libname}${release}${shared_ext}$major'
++ sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
++ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
++ ;;
++ *)
++ shrext_cmds='.sl'
++ dynamic_linker="$host_os dld.sl"
++ shlibpath_var=SHLIB_PATH
++ shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
++ soname_spec='${libname}${release}${shared_ext}$major'
++ ;;
++ esac
++ # HP-UX runs *really* slowly unless shared libraries are mode 555.
++ postinstall_cmds='chmod 555 $lib'
+ ;;
+-esac
+-])# AC_CHECK_LIBM
+
++interix[[3-9]]*)
++ version_type=linux
++ need_lib_prefix=no
++ need_version=no
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
++ soname_spec='${libname}${release}${shared_ext}$major'
++ dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
++ shlibpath_var=LD_LIBRARY_PATH
++ shlibpath_overrides_runpath=no
++ hardcode_into_libs=yes
++ ;;
+
+-# AC_LIBLTDL_CONVENIENCE([DIRECTORY])
+-# -----------------------------------
+-# sets LIBLTDL to the link flags for the libltdl convenience library and
+-# LTDLINCL to the include flags for the libltdl header and adds
+-# --enable-ltdl-convenience to the configure arguments. Note that
+-# AC_CONFIG_SUBDIRS is not called here. If DIRECTORY is not provided,
+-# it is assumed to be `libltdl'. LIBLTDL will be prefixed with
+-# '${top_builddir}/' and LTDLINCL will be prefixed with '${top_srcdir}/'
+-# (note the single quotes!). If your package is not flat and you're not
+-# using automake, define top_builddir and top_srcdir appropriately in
+-# the Makefiles.
+-AC_DEFUN([AC_LIBLTDL_CONVENIENCE],
+-[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+- case $enable_ltdl_convenience in
+- no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;;
+- "") enable_ltdl_convenience=yes
+- ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;;
++irix5* | irix6* | nonstopux*)
++ case $host_os in
++ nonstopux*) version_type=nonstopux ;;
++ *)
++ if test "$lt_cv_prog_gnu_ld" = yes; then
++ version_type=linux
++ else
++ version_type=irix
++ fi ;;
+ esac
+- LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdlc.la
+- LTDLINCL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl'])
+- # For backwards non-gettext consistent compatibility...
+- INCLTDL="$LTDLINCL"
+-])# AC_LIBLTDL_CONVENIENCE
+-
+-
+-# AC_LIBLTDL_INSTALLABLE([DIRECTORY])
+-# -----------------------------------
+-# sets LIBLTDL to the link flags for the libltdl installable library and
+-# LTDLINCL to the include flags for the libltdl header and adds
+-# --enable-ltdl-install to the configure arguments. Note that
+-# AC_CONFIG_SUBDIRS is not called here. If DIRECTORY is not provided,
+-# and an installed libltdl is not found, it is assumed to be `libltdl'.
+-# LIBLTDL will be prefixed with '${top_builddir}/'# and LTDLINCL with
+-# '${top_srcdir}/' (note the single quotes!). If your package is not
+-# flat and you're not using automake, define top_builddir and top_srcdir
+-# appropriately in the Makefiles.
+-# In the future, this macro may have to be called after AC_PROG_LIBTOOL.
+-AC_DEFUN([AC_LIBLTDL_INSTALLABLE],
+-[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+- AC_CHECK_LIB(ltdl, lt_dlinit,
+- [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no],
+- [if test x"$enable_ltdl_install" = xno; then
+- AC_MSG_WARN([libltdl not installed, but installation disabled])
+- else
+- enable_ltdl_install=yes
+- fi
+- ])
+- if test x"$enable_ltdl_install" = x"yes"; then
+- ac_configure_args="$ac_configure_args --enable-ltdl-install"
+- LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdl.la
+- LTDLINCL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl'])
+- else
+- ac_configure_args="$ac_configure_args --enable-ltdl-install=no"
+- LIBLTDL="-lltdl"
+- LTDLINCL=
+- fi
+- # For backwards non-gettext consistent compatibility...
+- INCLTDL="$LTDLINCL"
+-])# AC_LIBLTDL_INSTALLABLE
++ need_lib_prefix=no
++ need_version=no
++ soname_spec='${libname}${release}${shared_ext}$major'
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
++ case $host_os in
++ irix5* | nonstopux*)
++ libsuff= shlibsuff=
++ ;;
++ *)
++ case $LD in # libtool.m4 will add one of these switches to LD
++ *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
++ libsuff= shlibsuff= libmagic=32-bit;;
++ *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
++ libsuff=32 shlibsuff=N32 libmagic=N32;;
++ *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
++ libsuff=64 shlibsuff=64 libmagic=64-bit;;
++ *) libsuff= shlibsuff= libmagic=never-match;;
++ esac
++ ;;
++ esac
++ shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
++ shlibpath_overrides_runpath=no
++ sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
++ sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
++ hardcode_into_libs=yes
++ ;;
+
++# No shared lib support for Linux oldld, aout, or coff.
++linux*oldld* | linux*aout* | linux*coff*)
++ dynamic_linker=no
++ ;;
+
+-# AC_LIBTOOL_CXX
+-# --------------
+-# enable support for C++ libraries
+-AC_DEFUN([AC_LIBTOOL_CXX],
+-[AC_REQUIRE([_LT_AC_LANG_CXX])
+-])# AC_LIBTOOL_CXX
++# This must be Linux ELF.
++linux* | k*bsd*-gnu)
++ version_type=linux
++ need_lib_prefix=no
++ need_version=no
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
++ soname_spec='${libname}${release}${shared_ext}$major'
++ finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
++ shlibpath_var=LD_LIBRARY_PATH
++ shlibpath_overrides_runpath=no
++ # Some binutils ld are patched to set DT_RUNPATH
++ save_LDFLAGS=$LDFLAGS
++ save_libdir=$libdir
++ eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \
++ LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\""
++ AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
++ [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null],
++ [shlibpath_overrides_runpath=yes])])
++ LDFLAGS=$save_LDFLAGS
++ libdir=$save_libdir
+
++ # This implies no fast_install, which is unacceptable.
++ # Some rework will be needed to allow for fast_install
++ # before this can be enabled.
++ hardcode_into_libs=yes
+
+-# _LT_AC_LANG_CXX
+-# ---------------
+-AC_DEFUN([_LT_AC_LANG_CXX],
+-[AC_REQUIRE([AC_PROG_CXX])
+-AC_REQUIRE([_LT_AC_PROG_CXXCPP])
+-_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}CXX])
+-])# _LT_AC_LANG_CXX
++ # Append ld.so.conf contents to the search path
++ if test -f /etc/ld.so.conf; then
++ lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
++ sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
++ fi
+
+-# _LT_AC_PROG_CXXCPP
+-# ------------------
+-AC_DEFUN([_LT_AC_PROG_CXXCPP],
+-[
+-AC_REQUIRE([AC_PROG_CXX])
+-if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
+- ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
+- (test "X$CXX" != "Xg++"))) ; then
+- AC_PROG_CXXCPP
+-fi
+-])# _LT_AC_PROG_CXXCPP
+-
+-# AC_LIBTOOL_F77
+-# --------------
+-# enable support for Fortran 77 libraries
+-AC_DEFUN([AC_LIBTOOL_F77],
+-[AC_REQUIRE([_LT_AC_LANG_F77])
+-])# AC_LIBTOOL_F77
+-
+-
+-# _LT_AC_LANG_F77
+-# ---------------
+-AC_DEFUN([_LT_AC_LANG_F77],
+-[AC_REQUIRE([AC_PROG_F77])
+-_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}F77])
+-])# _LT_AC_LANG_F77
+-
+-
+-# AC_LIBTOOL_GCJ
+-# --------------
+-# enable support for GCJ libraries
+-AC_DEFUN([AC_LIBTOOL_GCJ],
+-[AC_REQUIRE([_LT_AC_LANG_GCJ])
+-])# AC_LIBTOOL_GCJ
+-
+-
+-# _LT_AC_LANG_GCJ
+-# ---------------
+-AC_DEFUN([_LT_AC_LANG_GCJ],
+-[AC_PROVIDE_IFELSE([AC_PROG_GCJ],[],
+- [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],[],
+- [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ],[],
+- [ifdef([AC_PROG_GCJ],[AC_REQUIRE([AC_PROG_GCJ])],
+- [ifdef([A][M_PROG_GCJ],[AC_REQUIRE([A][M_PROG_GCJ])],
+- [AC_REQUIRE([A][C_PROG_GCJ_OR_A][M_PROG_GCJ])])])])])])
+-_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}GCJ])
+-])# _LT_AC_LANG_GCJ
+-
+-
+-# AC_LIBTOOL_RC
+-# -------------
+-# enable support for Windows resource files
+-AC_DEFUN([AC_LIBTOOL_RC],
+-[AC_REQUIRE([LT_AC_PROG_RC])
+-_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}RC])
+-])# AC_LIBTOOL_RC
++ # We used to test for /lib/ld.so.1 and disable shared libraries on
++ # powerpc, because MkLinux only supported shared libraries with the
++ # GNU dynamic linker. Since this was broken with cross compilers,
++ # most powerpc-linux boxes support dynamic linking these days and
++ # people can always --disable-shared, the test was removed, and we
++ # assume the GNU/Linux dynamic linker is in use.
++ dynamic_linker='GNU/Linux ld.so'
++ ;;
+
++netbsd*)
++ version_type=sunos
++ need_lib_prefix=no
++ need_version=no
++ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
++ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
++ dynamic_linker='NetBSD (a.out) ld.so'
++ else
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
++ soname_spec='${libname}${release}${shared_ext}$major'
++ dynamic_linker='NetBSD ld.elf_so'
++ fi
++ shlibpath_var=LD_LIBRARY_PATH
++ shlibpath_overrides_runpath=yes
++ hardcode_into_libs=yes
++ ;;
+
+-# AC_LIBTOOL_LANG_C_CONFIG
+-# ------------------------
+-# Ensure that the configuration vars for the C compiler are
+-# suitably defined. Those variables are subsequently used by
+-# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
+-AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG], [_LT_AC_LANG_C_CONFIG])
+-AC_DEFUN([_LT_AC_LANG_C_CONFIG],
+-[lt_save_CC="$CC"
+-AC_LANG_PUSH(C)
++newsos6)
++ version_type=linux
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
++ shlibpath_var=LD_LIBRARY_PATH
++ shlibpath_overrides_runpath=yes
++ ;;
+
+-# Source file extension for C test sources.
+-ac_ext=c
++*nto* | *qnx*)
++ version_type=qnx
++ need_lib_prefix=no
++ need_version=no
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
++ soname_spec='${libname}${release}${shared_ext}$major'
++ shlibpath_var=LD_LIBRARY_PATH
++ shlibpath_overrides_runpath=no
++ hardcode_into_libs=yes
++ dynamic_linker='ldqnx.so'
++ ;;
+
+-# Object file extension for compiled C test sources.
+-objext=o
+-_LT_AC_TAGVAR(objext, $1)=$objext
++openbsd*)
++ version_type=sunos
++ sys_lib_dlsearch_path_spec="/usr/lib"
++ need_lib_prefix=no
++ # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
++ case $host_os in
++ openbsd3.3 | openbsd3.3.*) need_version=yes ;;
++ *) need_version=no ;;
++ esac
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
++ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
++ shlibpath_var=LD_LIBRARY_PATH
++ if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
++ case $host_os in
++ openbsd2.[[89]] | openbsd2.[[89]].*)
++ shlibpath_overrides_runpath=no
++ ;;
++ *)
++ shlibpath_overrides_runpath=yes
++ ;;
++ esac
++ else
++ shlibpath_overrides_runpath=yes
++ fi
++ ;;
+
+-# Code to be used in simple compile tests
+-lt_simple_compile_test_code="int some_variable = 0;\n"
++os2*)
++ libname_spec='$name'
++ shrext_cmds=".dll"
++ need_lib_prefix=no
++ library_names_spec='$libname${shared_ext} $libname.a'
++ dynamic_linker='OS/2 ld.exe'
++ shlibpath_var=LIBPATH
++ ;;
+
+-# Code to be used in simple link tests
+-lt_simple_link_test_code='int main(){return(0);}\n'
++osf3* | osf4* | osf5*)
++ version_type=osf
++ need_lib_prefix=no
++ need_version=no
++ soname_spec='${libname}${release}${shared_ext}$major'
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
++ shlibpath_var=LD_LIBRARY_PATH
++ sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
++ sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
++ ;;
+
+-_LT_AC_SYS_COMPILER
++rdos*)
++ dynamic_linker=no
++ ;;
+
+-# save warnings/boilerplate of simple test code
+-_LT_COMPILER_BOILERPLATE
+-_LT_LINKER_BOILERPLATE
++solaris*)
++ version_type=linux
++ need_lib_prefix=no
++ need_version=no
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
++ soname_spec='${libname}${release}${shared_ext}$major'
++ shlibpath_var=LD_LIBRARY_PATH
++ shlibpath_overrides_runpath=yes
++ hardcode_into_libs=yes
++ # ldd complains unless libraries are executable
++ postinstall_cmds='chmod +x $lib'
++ ;;
+
+-## CAVEAT EMPTOR:
+-## There is no encapsulation within the following macros, do not change
+-## the running order or otherwise move them around unless you know exactly
+-## what you are doing...
+-AC_LIBTOOL_PROG_COMPILER_NO_RTTI($1)
+-AC_LIBTOOL_PROG_COMPILER_PIC($1)
+-AC_LIBTOOL_PROG_CC_C_O($1)
+-AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
+-AC_LIBTOOL_PROG_LD_SHLIBS($1)
+-AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
+-AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
+-AC_LIBTOOL_SYS_LIB_STRIP
+-AC_LIBTOOL_DLOPEN_SELF
+-
+-# Report which library types will actually be built
+-AC_MSG_CHECKING([if libtool supports shared libraries])
+-AC_MSG_RESULT([$can_build_shared])
++sunos4*)
++ version_type=sunos
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
++ finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
++ shlibpath_var=LD_LIBRARY_PATH
++ shlibpath_overrides_runpath=yes
++ if test "$with_gnu_ld" = yes; then
++ need_lib_prefix=no
++ fi
++ need_version=yes
++ ;;
+
+-AC_MSG_CHECKING([whether to build shared libraries])
+-test "$can_build_shared" = "no" && enable_shared=no
++sysv4 | sysv4.3*)
++ version_type=linux
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
++ soname_spec='${libname}${release}${shared_ext}$major'
++ shlibpath_var=LD_LIBRARY_PATH
++ case $host_vendor in
++ sni)
++ shlibpath_overrides_runpath=no
++ need_lib_prefix=no
++ runpath_var=LD_RUN_PATH
++ ;;
++ siemens)
++ need_lib_prefix=no
++ ;;
++ motorola)
++ need_lib_prefix=no
++ need_version=no
++ shlibpath_overrides_runpath=no
++ sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
++ ;;
++ esac
++ ;;
+
+-# On AIX, shared libraries and static libraries use the same namespace, and
+-# are all built from PIC.
+-case $host_os in
+-aix3*)
+- test "$enable_shared" = yes && enable_static=no
+- if test -n "$RANLIB"; then
+- archive_cmds="$archive_cmds~\$RANLIB \$lib"
+- postinstall_cmds='$RANLIB $lib'
++sysv4*MP*)
++ if test -d /usr/nec ;then
++ version_type=linux
++ library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
++ soname_spec='$libname${shared_ext}.$major'
++ shlibpath_var=LD_LIBRARY_PATH
+ fi
+ ;;
+
+-aix4* | aix5*)
+- if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+- test "$enable_shared" = yes && enable_static=no
++sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
++ version_type=freebsd-elf
++ need_lib_prefix=no
++ need_version=no
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
++ soname_spec='${libname}${release}${shared_ext}$major'
++ shlibpath_var=LD_LIBRARY_PATH
++ shlibpath_overrides_runpath=yes
++ hardcode_into_libs=yes
++ if test "$with_gnu_ld" = yes; then
++ sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
++ else
++ sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
++ case $host_os in
++ sco3.2v5*)
++ sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
++ ;;
++ esac
+ fi
+- ;;
+-esac
+-AC_MSG_RESULT([$enable_shared])
+-
+-AC_MSG_CHECKING([whether to build static libraries])
+-# Make sure either enable_shared or enable_static is yes.
+-test "$enable_shared" = yes || enable_static=yes
+-AC_MSG_RESULT([$enable_static])
+-
+-AC_LIBTOOL_CONFIG($1)
+-
+-AC_LANG_POP
+-CC="$lt_save_CC"
+-])# AC_LIBTOOL_LANG_C_CONFIG
+-
+-
+-# AC_LIBTOOL_LANG_CXX_CONFIG
+-# --------------------------
+-# Ensure that the configuration vars for the C compiler are
+-# suitably defined. Those variables are subsequently used by
+-# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
+-AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG], [_LT_AC_LANG_CXX_CONFIG(CXX)])
+-AC_DEFUN([_LT_AC_LANG_CXX_CONFIG],
+-[AC_LANG_PUSH(C++)
+-AC_REQUIRE([AC_PROG_CXX])
+-AC_REQUIRE([_LT_AC_PROG_CXXCPP])
+-
+-_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+-_LT_AC_TAGVAR(allow_undefined_flag, $1)=
+-_LT_AC_TAGVAR(always_export_symbols, $1)=no
+-_LT_AC_TAGVAR(archive_expsym_cmds, $1)=
+-_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=
+-_LT_AC_TAGVAR(hardcode_direct, $1)=no
+-_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
+-_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
+-_LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
+-_LT_AC_TAGVAR(hardcode_minus_L, $1)=no
+-_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+-_LT_AC_TAGVAR(hardcode_automatic, $1)=no
+-_LT_AC_TAGVAR(module_cmds, $1)=
+-_LT_AC_TAGVAR(module_expsym_cmds, $1)=
+-_LT_AC_TAGVAR(link_all_deplibs, $1)=unknown
+-_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+-_LT_AC_TAGVAR(no_undefined_flag, $1)=
+-_LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+-_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+-
+-# Dependencies to place before and after the object being linked:
+-_LT_AC_TAGVAR(predep_objects, $1)=
+-_LT_AC_TAGVAR(postdep_objects, $1)=
+-_LT_AC_TAGVAR(predeps, $1)=
+-_LT_AC_TAGVAR(postdeps, $1)=
+-_LT_AC_TAGVAR(compiler_lib_search_path, $1)=
+-
+-# Source file extension for C++ test sources.
+-ac_ext=cpp
+-
+-# Object file extension for compiled C++ test sources.
+-objext=o
+-_LT_AC_TAGVAR(objext, $1)=$objext
+-
+-# Code to be used in simple compile tests
+-lt_simple_compile_test_code="int some_variable = 0;\n"
++ sys_lib_dlsearch_path_spec='/usr/lib'
++ ;;
+
+-# Code to be used in simple link tests
+-lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }\n'
++tpf*)
++ # TPF is a cross-target only. Preferred cross-host = GNU/Linux.
++ version_type=linux
++ need_lib_prefix=no
++ need_version=no
++ library_name_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
++ shlibpath_var=LD_LIBRARY_PATH
++ shlibpath_overrides_runpath=no
++ hardcode_into_libs=yes
++ ;;
+
+-# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+-_LT_AC_SYS_COMPILER
++uts4*)
++ version_type=linux
++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
++ soname_spec='${libname}${release}${shared_ext}$major'
++ shlibpath_var=LD_LIBRARY_PATH
++ ;;
+
+-# save warnings/boilerplate of simple test code
+-_LT_COMPILER_BOILERPLATE
+-_LT_LINKER_BOILERPLATE
++*)
++ dynamic_linker=no
++ ;;
++esac
++AC_MSG_RESULT([$dynamic_linker])
++test "$dynamic_linker" = no && can_build_shared=no
+
+-# Allow CC to be a program name with arguments.
+-lt_save_CC=$CC
+-lt_save_LD=$LD
+-lt_save_GCC=$GCC
+-GCC=$GXX
+-lt_save_with_gnu_ld=$with_gnu_ld
+-lt_save_path_LD=$lt_cv_path_LD
+-if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then
+- lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx
+-else
+- $as_unset lt_cv_prog_gnu_ld
++variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
++if test "$GCC" = yes; then
++ variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
+ fi
+-if test -n "${lt_cv_path_LDCXX+set}"; then
+- lt_cv_path_LD=$lt_cv_path_LDCXX
+-else
+- $as_unset lt_cv_path_LD
++
++if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
++ sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+ fi
+-test -z "${LDCXX+set}" || LD=$LDCXX
+-CC=${CXX-"c++"}
+-compiler=$CC
+-_LT_AC_TAGVAR(compiler, $1)=$CC
+-_LT_CC_BASENAME([$compiler])
+-
+-# We don't want -fno-exception wen compiling C++ code, so set the
+-# no_builtin_flag separately
+-if test "$GXX" = yes; then
+- _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
+-else
+- _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
++if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
++ sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+ fi
+
+-if test "$GXX" = yes; then
+- # Set up default GNU C++ configuration
+-
+- AC_PROG_LD
+-
+- # Check if GNU C++ uses GNU ld as the underlying linker, since the
+- # archiving commands below assume that GNU ld is being used.
+- if test "$with_gnu_ld" = yes; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+-
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+-
+- # If archive_cmds runs LD, not CC, wlarc should be empty
+- # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
+- # investigate it a little bit more. (MM)
+- wlarc='${wl}'
+-
+- # ancient GNU ld didn't support --whole-archive et. al.
+- if eval "`$CC -print-prog-name=ld` --help 2>&1" | \
+- grep 'no-whole-archive' > /dev/null; then
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+- else
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+- fi
+- else
+- with_gnu_ld=no
+- wlarc=
+-
+- # A generic and very simple default shared library creation
+- # command for GNU C++ for the case where it uses the native
+- # linker, instead of GNU ld. If possible, this setting should
+- # overridden to take advantage of the native linker features on
+- # the platform it is being used on.
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+- fi
+-
+- # Commands to make compiler produce verbose output that lists
+- # what "hidden" libraries, object files and flags are used when
+- # linking a shared library.
+- output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"'
+-
+-else
+- GXX=no
+- with_gnu_ld=no
+- wlarc=
+-fi
++_LT_DECL([], [variables_saved_for_relink], [1],
++ [Variables whose values should be saved in libtool wrapper scripts and
++ restored at link time])
++_LT_DECL([], [need_lib_prefix], [0],
++ [Do we need the "lib" prefix for modules?])
++_LT_DECL([], [need_version], [0], [Do we need a version for libraries?])
++_LT_DECL([], [version_type], [0], [Library versioning type])
++_LT_DECL([], [runpath_var], [0], [Shared library runtime path variable])
++_LT_DECL([], [shlibpath_var], [0],[Shared library path variable])
++_LT_DECL([], [shlibpath_overrides_runpath], [0],
++ [Is shlibpath searched before the hard-coded library search path?])
++_LT_DECL([], [libname_spec], [1], [Format of library name prefix])
++_LT_DECL([], [library_names_spec], [1],
++ [[List of archive names. First name is the real one, the rest are links.
++ The last name is the one that the linker finds with -lNAME]])
++_LT_DECL([], [soname_spec], [1],
++ [[The coded name of the library, if different from the real name]])
++_LT_DECL([], [postinstall_cmds], [2],
++ [Command to use after installation of a shared archive])
++_LT_DECL([], [postuninstall_cmds], [2],
++ [Command to use after uninstallation of a shared archive])
++_LT_DECL([], [finish_cmds], [2],
++ [Commands used to finish a libtool library installation in a directory])
++_LT_DECL([], [finish_eval], [1],
++ [[As "finish_cmds", except a single script fragment to be evaled but
++ not shown]])
++_LT_DECL([], [hardcode_into_libs], [0],
++ [Whether we should hardcode library paths into libraries])
++_LT_DECL([], [sys_lib_search_path_spec], [2],
++ [Compile-time system search path for libraries])
++_LT_DECL([], [sys_lib_dlsearch_path_spec], [2],
++ [Run-time system search path for libraries])
++])# _LT_SYS_DYNAMIC_LINKER
+
+-# PORTME: fill in a description of your system's C++ link characteristics
+-AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
+-_LT_AC_TAGVAR(ld_shlibs, $1)=yes
+-case $host_os in
+- aix3*)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- aix4* | aix5*)
+- if test "$host_cpu" = ia64; then
+- # On IA64, the linker does run time linking by default, so we don't
+- # have to do anything special.
+- aix_use_runtimelinking=no
+- exp_sym_flag='-Bexport'
+- no_entry_flag=""
+- else
+- aix_use_runtimelinking=no
+
+- # Test if we are trying to use run time linking or normal
+- # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+- # need to do runtime linking.
+- case $host_os in aix4.[[23]]|aix4.[[23]].*|aix5*)
+- for ld_flag in $LDFLAGS; do
+- case $ld_flag in
+- *-brtl*)
+- aix_use_runtimelinking=yes
+- break
+- ;;
+- esac
+- done
+- ;;
+- esac
+-
+- exp_sym_flag='-bexport'
+- no_entry_flag='-bnoentry'
+- fi
++# _LT_PATH_TOOL_PREFIX(TOOL)
++# --------------------------
++# find a file program which can recognize shared library
++AC_DEFUN([_LT_PATH_TOOL_PREFIX],
++[m4_require([_LT_DECL_EGREP])dnl
++AC_MSG_CHECKING([for $1])
++AC_CACHE_VAL(lt_cv_path_MAGIC_CMD,
++[case $MAGIC_CMD in
++[[\\/*] | ?:[\\/]*])
++ lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
++ ;;
++*)
++ lt_save_MAGIC_CMD="$MAGIC_CMD"
++ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
++dnl $ac_dummy forces splitting on constant user-supplied paths.
++dnl POSIX.2 word splitting is done only on the output of word expansions,
++dnl not every word. This closes a longstanding sh security hole.
++ ac_dummy="m4_if([$2], , $PATH, [$2])"
++ for ac_dir in $ac_dummy; do
++ IFS="$lt_save_ifs"
++ test -z "$ac_dir" && ac_dir=.
++ if test -f $ac_dir/$1; then
++ lt_cv_path_MAGIC_CMD="$ac_dir/$1"
++ if test -n "$file_magic_test_file"; then
++ case $deplibs_check_method in
++ "file_magic "*)
++ file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
++ MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
++ if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
++ $EGREP "$file_magic_regex" > /dev/null; then
++ :
++ else
++ cat <<_LT_EOF 1>&2
+
+- # When large executables or shared objects are built, AIX ld can
+- # have problems creating the table of contents. If linking a library
+- # or program results in "error TOC overflow" add -mminimal-toc to
+- # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
+- # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+-
+- _LT_AC_TAGVAR(archive_cmds, $1)=''
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':'
+- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
++*** Warning: the command libtool uses to detect shared libraries,
++*** $file_magic_cmd, produces output that libtool cannot recognize.
++*** The result is that libtool may fail to recognize shared libraries
++*** as such. This will affect the creation of libtool libraries that
++*** depend on shared libraries, but programs linked with such libtool
++*** libraries will work regardless of this problem. Nevertheless, you
++*** may want to report the problem to your system manager and/or to
++*** bug-libtool@gnu.org
+
+- if test "$GXX" = yes; then
+- case $host_os in aix4.[[012]]|aix4.[[012]].*)
+- # We only want to do this on AIX 4.2 and lower, the check
+- # below for broken collect2 doesn't work under 4.3+
+- collect2name=`${CC} -print-prog-name=collect2`
+- if test -f "$collect2name" && \
+- strings "$collect2name" | grep resolve_lib_name >/dev/null
+- then
+- # We have reworked collect2
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- else
+- # We have old collect2
+- _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported
+- # It fails to find uninstalled libraries when the uninstalled
+- # path is not listed in the libpath. Setting hardcode_minus_L
+- # to unsupported forces relinking
+- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
+- fi
+- ;;
+- esac
+- shared_flag='-shared'
+- if test "$aix_use_runtimelinking" = yes; then
+- shared_flag="$shared_flag "'${wl}-G'
+- fi
+- else
+- # not using gcc
+- if test "$host_cpu" = ia64; then
+- # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+- # chokes on -Wl,-G. The following line is correct:
+- shared_flag='-G'
+- else
+- if test "$aix_use_runtimelinking" = yes; then
+- shared_flag='${wl}-G'
+- else
+- shared_flag='${wl}-bM:SRE'
+- fi
++_LT_EOF
++ fi ;;
++ esac
+ fi
++ break
+ fi
++ done
++ IFS="$lt_save_ifs"
++ MAGIC_CMD="$lt_save_MAGIC_CMD"
++ ;;
++esac])
++MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
++if test -n "$MAGIC_CMD"; then
++ AC_MSG_RESULT($MAGIC_CMD)
++else
++ AC_MSG_RESULT(no)
++fi
++_LT_DECL([], [MAGIC_CMD], [0],
++ [Used to examine libraries when file_magic_cmd begins with "file"])dnl
++])# _LT_PATH_TOOL_PREFIX
+
+- # It seems that -bexpall does not export symbols beginning with
+- # underscore (_), so it is better to generate a list of symbols to export.
+- _LT_AC_TAGVAR(always_export_symbols, $1)=yes
+- if test "$aix_use_runtimelinking" = yes; then
+- # Warning - without using the other runtime loading flags (-brtl),
+- # -berok will link without error, but may produce a broken library.
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)='-berok'
+- # Determine the default libpath from the value encoded in an empty executable.
+- _LT_AC_SYS_LIBPATH_AIX
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
++# Old name:
++AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX])
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], [])
+
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+- else
+- if test "$host_cpu" = ia64; then
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+- else
+- # Determine the default libpath from the value encoded in an empty executable.
+- _LT_AC_SYS_LIBPATH_AIX
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+- # Warning - without using the other run time loading flags,
+- # -berok will link without error, but may produce a broken library.
+- _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
+- # Exported symbols can be pulled into shared objects from archives
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
+- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
+- # This is similar to how AIX traditionally builds its shared libraries.
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+- fi
+- fi
+- ;;
+
+- beos*)
+- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+- # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
+- # support --undefined. This deserves some investigation. FIXME
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+- else
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- fi
+- ;;
++# _LT_PATH_MAGIC
++# --------------
++# find a file program which can recognize a shared library
++m4_defun([_LT_PATH_MAGIC],
++[_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH)
++if test -z "$lt_cv_path_MAGIC_CMD"; then
++ if test -n "$ac_tool_prefix"; then
++ _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH)
++ else
++ MAGIC_CMD=:
++ fi
++fi
++])# _LT_PATH_MAGIC
+
+- chorus*)
+- case $cc_basename in
+- *)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- esac
+- ;;
+
+- cygwin* | mingw* | pw32*)
+- # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
+- # as there is no search path for DLLs.
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+- _LT_AC_TAGVAR(always_export_symbols, $1)=no
+- _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+-
+- if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+- # If the export-symbols file already is a .def file (1st line
+- # is EXPORTS), use it as is; otherwise, prepend...
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+- cp $export_symbols $output_objdir/$soname.def;
+- else
+- echo EXPORTS > $output_objdir/$soname.def;
+- cat $export_symbols >> $output_objdir/$soname.def;
+- fi~
+- $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+- else
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- fi
+- ;;
+- darwin* | rhapsody*)
+- case $host_os in
+- rhapsody* | darwin1.[[012]])
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}suppress'
+- ;;
+- *) # Darwin 1.3 on
+- if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+- else
+- case ${MACOSX_DEPLOYMENT_TARGET} in
+- 10.[[012]])
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+- ;;
+- 10.*)
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}dynamic_lookup'
+- ;;
+- esac
+- fi
+- ;;
+- esac
+- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+- _LT_AC_TAGVAR(hardcode_direct, $1)=no
+- _LT_AC_TAGVAR(hardcode_automatic, $1)=yes
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=''
+- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+-
+- if test "$GXX" = yes ; then
+- lt_int_apple_cc_single_mod=no
+- output_verbose_link_cmd='echo'
+- if $CC -dumpspecs 2>&1 | $EGREP 'single_module' >/dev/null ; then
+- lt_int_apple_cc_single_mod=yes
+- fi
+- if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+- else
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+- fi
+- _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+- # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
+- if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+- else
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+- fi
+- _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+- else
+- case $cc_basename in
+- xlc*)
+- output_verbose_link_cmd='echo'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
+- _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+- # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+- _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+- ;;
+- *)
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- esac
+- fi
+- ;;
++# LT_PATH_LD
++# ----------
++# find the pathname to the GNU or non-GNU linker
++AC_DEFUN([LT_PATH_LD],
++[AC_REQUIRE([AC_PROG_CC])dnl
++AC_REQUIRE([AC_CANONICAL_HOST])dnl
++AC_REQUIRE([AC_CANONICAL_BUILD])dnl
++m4_require([_LT_DECL_SED])dnl
++m4_require([_LT_DECL_EGREP])dnl
+
+- dgux*)
+- case $cc_basename in
+- ec++*)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- ghcx*)
+- # Green Hills C++ Compiler
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- *)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- esac
+- ;;
+- freebsd[[12]]*)
+- # C++ shared libraries reported to be fairly broken before switch to ELF
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- freebsd-elf*)
+- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+- ;;
+- freebsd* | kfreebsd*-gnu | dragonfly*)
+- # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
+- # conventions
+- _LT_AC_TAGVAR(ld_shlibs, $1)=yes
+- ;;
+- gnu*)
+- ;;
+- hpux9*)
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
+- # but as the default
+- # location of the library.
+-
+- case $cc_basename in
+- CC*)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- aCC*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+- # Commands to make compiler produce verbose output that lists
+- # what "hidden" libraries, object files and flags are used when
+- # linking a shared library.
+- #
+- # There doesn't appear to be a way to prevent this compiler from
+- # explicitly linking system object files so we need to strip them
+- # from the output so that they don't get included in the library
+- # dependencies.
+- output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "[[-]]L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+- ;;
+- *)
+- if test "$GXX" = yes; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+- else
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- fi
+- ;;
+- esac
+- ;;
+- hpux10*|hpux11*)
+- if test $with_gnu_ld = no; then
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
++AC_ARG_WITH([gnu-ld],
++ [AS_HELP_STRING([--with-gnu-ld],
++ [assume the C compiler uses GNU ld @<:@default=no@:>@])],
++ [test "$withval" = no || with_gnu_ld=yes],
++ [with_gnu_ld=no])dnl
+
+- case $host_cpu in
+- hppa*64*|ia64*)
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir'
+- ;;
+- *)
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+- ;;
+- esac
+- fi
+- case $host_cpu in
+- hppa*64*|ia64*)
+- _LT_AC_TAGVAR(hardcode_direct, $1)=no
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- ;;
+- *)
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
+- # but as the default
+- # location of the library.
++ac_prog=ld
++if test "$GCC" = yes; then
++ # Check if gcc -print-prog-name=ld gives a path.
++ AC_MSG_CHECKING([for ld used by $CC])
++ case $host in
++ *-*-mingw*)
++ # gcc leaves a trailing carriage return which upsets mingw
++ ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
++ *)
++ ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
++ esac
++ case $ac_prog in
++ # Accept absolute paths.
++ [[\\/]]* | ?:[[\\/]]*)
++ re_direlt='/[[^/]][[^/]]*/\.\./'
++ # Canonicalize the pathname of ld
++ ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'`
++ while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
++ ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
++ done
++ test -z "$LD" && LD="$ac_prog"
+ ;;
+- esac
+-
+- case $cc_basename in
+- CC*)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- aCC*)
+- case $host_cpu in
+- hppa*64*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+- ;;
+- ia64*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+- ;;
+- *)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+- ;;
+- esac
+- # Commands to make compiler produce verbose output that lists
+- # what "hidden" libraries, object files and flags are used when
+- # linking a shared library.
+- #
+- # There doesn't appear to be a way to prevent this compiler from
+- # explicitly linking system object files so we need to strip them
+- # from the output so that they don't get included in the library
+- # dependencies.
+- output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+- ;;
+- *)
+- if test "$GXX" = yes; then
+- if test $with_gnu_ld = no; then
+- case $host_cpu in
+- hppa*64*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+- ;;
+- ia64*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+- ;;
+- *)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+- ;;
+- esac
+- fi
+- else
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- fi
+- ;;
+- esac
+- ;;
+- interix3*)
+- _LT_AC_TAGVAR(hardcode_direct, $1)=no
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+- # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+- # Instead, shared libraries are loaded at an image base (0x10000000 by
+- # default) and relocated if they conflict, which is a slow very memory
+- # consuming and fragmenting process. To avoid this, we pick a random,
+- # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+- # time. Moving up from 0x10000000 also allows more sbrk(2) space.
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+- ;;
+- irix5* | irix6*)
+- case $cc_basename in
+- CC*)
+- # SGI C++
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+-
+- # Archives containing C++ object files must be created using
+- # "CC -ar", where "CC" is the IRIX C++ compiler. This is
+- # necessary to make sure instantiated templates are included
+- # in the archive.
+- _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs'
+- ;;
+- *)
+- if test "$GXX" = yes; then
+- if test "$with_gnu_ld" = no; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+- else
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` -o $lib'
+- fi
+- fi
+- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+- ;;
+- esac
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
++ "")
++ # If it fails, then pretend we aren't using GCC.
++ ac_prog=ld
+ ;;
+- linux*)
+- case $cc_basename in
+- KCC*)
+- # Kuck and Associates, Inc. (KAI) C++ Compiler
+-
+- # KCC will only create a shared library if the output file
+- # ends with ".so" (or ".sl" for HP-UX), so rename the library
+- # to its proper name (with version) after linking.
+- _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib'
+- # Commands to make compiler produce verbose output that lists
+- # what "hidden" libraries, object files and flags are used when
+- # linking a shared library.
+- #
+- # There doesn't appear to be a way to prevent this compiler from
+- # explicitly linking system object files so we need to strip them
+- # from the output so that they don't get included in the library
+- # dependencies.
+- output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | grep "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+-
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath,$libdir'
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+-
+- # Archives containing C++ object files must be created using
+- # "CC -Bstatic", where "CC" is the KAI C++ compiler.
+- _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs'
+- ;;
+- icpc*)
+- # Intel C++
+- with_gnu_ld=yes
+- # version 8.0 and above of icpc choke on multiply defined symbols
+- # if we add $predep_objects and $postdep_objects, however 7.1 and
+- # earlier do not add the objects themselves.
+- case `$CC -V 2>&1` in
+- *"Version 7."*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+- ;;
+- *) # Version 8.0 or newer
+- tmp_idyn=
+- case $host_cpu in
+- ia64*) tmp_idyn=' -i_dynamic';;
+- esac
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+- ;;
+- esac
+- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+- ;;
+- pgCC*)
+- # Portland Group C++ compiler
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+-
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+- ;;
+- cxx*)
+- # Compaq C++
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
+-
+- runpath_var=LD_RUN_PATH
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+-
+- # Commands to make compiler produce verbose output that lists
+- # what "hidden" libraries, object files and flags are used when
+- # linking a shared library.
+- #
+- # There doesn't appear to be a way to prevent this compiler from
+- # explicitly linking system object files so we need to strip them
+- # from the output so that they don't get included in the library
+- # dependencies.
+- output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+- ;;
+- *)
+- case `$CC -V 2>&1 | sed 5q` in
+- *Sun\ C*)
+- # Sun C++ 5.9
+- _LT_AC_TAGVAR(no_undefined_flag, $1)=' -zdefs'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols'
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+-
+- # Not sure whether something based on
+- # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1
+- # would be better.
+- output_verbose_link_cmd='echo'
+-
+- # Archives containing C++ object files must be created using
+- # "CC -xar", where "CC" is the Sun C++ compiler. This is
+- # necessary to make sure instantiated templates are included
+- # in the archive.
+- _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
+- ;;
+- esac
+- ;;
+- esac
++ *)
++ # If it is relative, then search for the first ld in PATH.
++ with_gnu_ld=unknown
+ ;;
+- lynxos*)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- m88k*)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- mvs*)
+- case $cc_basename in
+- cxx*)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
++ esac
++elif test "$with_gnu_ld" = yes; then
++ AC_MSG_CHECKING([for GNU ld])
++else
++ AC_MSG_CHECKING([for non-GNU ld])
++fi
++AC_CACHE_VAL(lt_cv_path_LD,
++[if test -z "$LD"; then
++ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
++ for ac_dir in $PATH; do
++ IFS="$lt_save_ifs"
++ test -z "$ac_dir" && ac_dir=.
++ if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
++ lt_cv_path_LD="$ac_dir/$ac_prog"
++ # Check to see if the program is GNU ld. I'd rather use --version,
++ # but apparently some variants of GNU ld only accept -v.
++ # Break only if it was the GNU/non-GNU ld that we prefer.
++ case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
++ *GNU* | *'with BFD'*)
++ test "$with_gnu_ld" != no && break
+ ;;
+ *)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
++ test "$with_gnu_ld" != yes && break
+ ;;
+- esac
+- ;;
+- netbsd*)
+- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags'
+- wlarc=
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- fi
+- # Workaround some broken pre-1.5 toolchains
+- output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"'
+- ;;
+- openbsd2*)
+- # C++ shared libraries are fairly broken
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- openbsd*)
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
++ esac
+ fi
+- output_verbose_link_cmd='echo'
+- ;;
+- osf3*)
+- case $cc_basename in
+- KCC*)
+- # Kuck and Associates, Inc. (KAI) C++ Compiler
+-
+- # KCC will only create a shared library if the output file
+- # ends with ".so" (or ".sl" for HP-UX), so rename the library
+- # to its proper name (with version) after linking.
+- _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+-
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+-
+- # Archives containing C++ object files must be created using
+- # "CC -Bstatic", where "CC" is the KAI C++ compiler.
+- _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs'
+-
+- ;;
+- RCC*)
+- # Rational C++ 2.4.1
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- cxx*)
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && echo ${wl}-set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+-
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+-
+- # Commands to make compiler produce verbose output that lists
+- # what "hidden" libraries, object files and flags are used when
+- # linking a shared library.
+- #
+- # There doesn't appear to be a way to prevent this compiler from
+- # explicitly linking system object files so we need to strip them
+- # from the output so that they don't get included in the library
+- # dependencies.
+- output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+- ;;
+- *)
+- if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+-
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+-
+- # Commands to make compiler produce verbose output that lists
+- # what "hidden" libraries, object files and flags are used when
+- # linking a shared library.
+- output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"'
++ done
++ IFS="$lt_save_ifs"
++else
++ lt_cv_path_LD="$LD" # Let the user override the test with a path.
++fi])
++LD="$lt_cv_path_LD"
++if test -n "$LD"; then
++ AC_MSG_RESULT($LD)
++else
++ AC_MSG_RESULT(no)
++fi
++test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
++_LT_PATH_LD_GNU
++AC_SUBST([LD])
+
+- else
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- fi
+- ;;
+- esac
+- ;;
+- osf4* | osf5*)
+- case $cc_basename in
+- KCC*)
+- # Kuck and Associates, Inc. (KAI) C++ Compiler
+-
+- # KCC will only create a shared library if the output file
+- # ends with ".so" (or ".sl" for HP-UX), so rename the library
+- # to its proper name (with version) after linking.
+- _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+-
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+-
+- # Archives containing C++ object files must be created using
+- # the KAI C++ compiler.
+- _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs'
+- ;;
+- RCC*)
+- # Rational C++ 2.4.1
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- cxx*)
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
+- echo "-hidden">> $lib.exp~
+- $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname -Wl,-input -Wl,$lib.exp `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~
+- $rm $lib.exp'
+-
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+-
+- # Commands to make compiler produce verbose output that lists
+- # what "hidden" libraries, object files and flags are used when
+- # linking a shared library.
+- #
+- # There doesn't appear to be a way to prevent this compiler from
+- # explicitly linking system object files so we need to strip them
+- # from the output so that they don't get included in the library
+- # dependencies.
+- output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+- ;;
+- *)
+- if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+-
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+-
+- # Commands to make compiler produce verbose output that lists
+- # what "hidden" libraries, object files and flags are used when
+- # linking a shared library.
+- output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"'
++_LT_TAGDECL([], [LD], [1], [The linker used to build libraries])
++])# LT_PATH_LD
+
+- else
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- fi
+- ;;
+- esac
+- ;;
+- psos*)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- sunos4*)
+- case $cc_basename in
+- CC*)
+- # Sun C++ 4.x
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- lcc*)
+- # Lucid
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- *)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- esac
++# Old names:
++AU_ALIAS([AM_PROG_LD], [LT_PATH_LD])
++AU_ALIAS([AC_PROG_LD], [LT_PATH_LD])
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([AM_PROG_LD], [])
++dnl AC_DEFUN([AC_PROG_LD], [])
++
++
++# _LT_PATH_LD_GNU
++#- --------------
++m4_defun([_LT_PATH_LD_GNU],
++[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], lt_cv_prog_gnu_ld,
++[# I'd rather use --version here, but apparently some GNU lds only accept -v.
++case `$LD -v 2>&1 </dev/null` in
++*GNU* | *'with BFD'*)
++ lt_cv_prog_gnu_ld=yes
++ ;;
++*)
++ lt_cv_prog_gnu_ld=no
++ ;;
++esac])
++with_gnu_ld=$lt_cv_prog_gnu_ld
++])# _LT_PATH_LD_GNU
++
++
++# _LT_CMD_RELOAD
++# --------------
++# find reload flag for linker
++# -- PORTME Some linkers may need a different reload flag.
++m4_defun([_LT_CMD_RELOAD],
++[AC_CACHE_CHECK([for $LD option to reload object files],
++ lt_cv_ld_reload_flag,
++ [lt_cv_ld_reload_flag='-r'])
++reload_flag=$lt_cv_ld_reload_flag
++case $reload_flag in
++"" | " "*) ;;
++*) reload_flag=" $reload_flag" ;;
++esac
++reload_cmds='$LD$reload_flag -o $output$reload_objs'
++case $host_os in
++ darwin*)
++ if test "$GCC" = yes; then
++ reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
++ else
++ reload_cmds='$LD$reload_flag -o $output$reload_objs'
++ fi
+ ;;
+- solaris*)
+- case $cc_basename in
+- CC*)
+- # Sun C++ 4.2, 5.x and Centerline C++
+- _LT_AC_TAGVAR(archive_cmds_need_lc,$1)=yes
+- _LT_AC_TAGVAR(no_undefined_flag, $1)=' -zdefs'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+- $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
+-
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- case $host_os in
+- solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
+- *)
+- # The C++ compiler is used as linker so we must use $wl
+- # flag to pass the commands to the underlying system
+- # linker. We must also pass each convience library through
+- # to the system linker between allextract/defaultextract.
+- # The C++ compiler will combine linker options so we
+- # cannot just pass the convience library names through
+- # without $wl.
+- # Supported since Solaris 2.6 (maybe 2.5.1?)
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract'
+- ;;
+- esac
+- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
++esac
++_LT_DECL([], [reload_flag], [1], [How to create reloadable object files])dnl
++_LT_DECL([], [reload_cmds], [2])dnl
++])# _LT_CMD_RELOAD
+
+- output_verbose_link_cmd='echo'
+
+- # Archives containing C++ object files must be created using
+- # "CC -xar", where "CC" is the Sun C++ compiler. This is
+- # necessary to make sure instantiated templates are included
+- # in the archive.
+- _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
+- ;;
+- gcx*)
+- # Green Hills C++ Compiler
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
++# _LT_CHECK_MAGIC_METHOD
++# ----------------------
++# how to check for library dependencies
++# -- PORTME fill in with the dynamic library characteristics
++m4_defun([_LT_CHECK_MAGIC_METHOD],
++[m4_require([_LT_DECL_EGREP])
++AC_CACHE_CHECK([how to recognize dependent libraries],
++lt_cv_deplibs_check_method,
++[lt_cv_file_magic_cmd='$MAGIC_CMD'
++lt_cv_file_magic_test_file=
++lt_cv_deplibs_check_method='unknown'
++# Need to set the preceding variable on all platforms that support
++# interlibrary dependencies.
++# 'none' -- dependencies not supported.
++# `unknown' -- same as none, but documents that we really don't know.
++# 'pass_all' -- all dependencies passed with no checks.
++# 'test_compile' -- check by making test program.
++# 'file_magic [[regex]]' -- check by looking for files in library path
++# which responds to the $file_magic_cmd with a given extended regex.
++# If you have `file' or equivalent on your system and you're not sure
++# whether `pass_all' will *always* work, you probably want this one.
+
+- # The C++ compiler must be used to create the archive.
+- _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
+- ;;
+- *)
+- # GNU C++ compiler with Solaris linker
+- if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+- _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs'
+- if $CC --version | grep -v '^2\.7' > /dev/null; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+- $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
++case $host_os in
++aix[[4-9]]*)
++ lt_cv_deplibs_check_method=pass_all
++ ;;
+
+- # Commands to make compiler produce verbose output that lists
+- # what "hidden" libraries, object files and flags are used when
+- # linking a shared library.
+- output_verbose_link_cmd="$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\""
+- else
+- # g++ 2.7 appears to require `-G' NOT `-shared' on this
+- # platform.
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+- $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
++beos*)
++ lt_cv_deplibs_check_method=pass_all
++ ;;
+
+- # Commands to make compiler produce verbose output that lists
+- # what "hidden" libraries, object files and flags are used when
+- # linking a shared library.
+- output_verbose_link_cmd="$CC -G $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\""
+- fi
++bsdi[[45]]*)
++ lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib)'
++ lt_cv_file_magic_cmd='/usr/bin/file -L'
++ lt_cv_file_magic_test_file=/shlib/libc.so
++ ;;
+
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir'
+- fi
+- ;;
+- esac
+- ;;
+- sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
+- _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- runpath_var='LD_RUN_PATH'
+-
+- case $cc_basename in
+- CC*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+- ;;
+- *)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+- ;;
+- esac
+- ;;
+- sysv5* | sco3.2v5* | sco5v6*)
+- # Note: We can NOT use -z defs as we might desire, because we do not
+- # link with -lc, and that would cause any symbols used from libc to
+- # always be unresolved, which means just about no library would
+- # ever link correctly. If we're not using GNU ld we use -z text
+- # though, which does catch some bad symbols but isn't as heavy-handed
+- # as -z defs.
+- # For security reasons, it is highly recommended that you always
+- # use absolute paths for naming shared libraries, and exclude the
+- # DT_RUNPATH tag from executables and libraries. But doing so
+- # requires that you compile everything twice, which is a pain.
+- # So that behaviour is only enabled if SCOABSPATH is set to a
+- # non-empty value in the environment. Most likely only useful for
+- # creating official distributions of packages.
+- # This is a hack until libtool officially supports absolute path
+- # names for shared libraries.
+- _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
+- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':'
+- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
+- runpath_var='LD_RUN_PATH'
+-
+- case $cc_basename in
+- CC*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+- ;;
+- *)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+- ;;
+- esac
+- ;;
+- tandem*)
+- case $cc_basename in
+- NCC*)
+- # NonStop-UX NCC 3.20
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- *)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
++cygwin*)
++ # func_win32_libid is a shell function defined in ltmain.sh
++ lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
++ lt_cv_file_magic_cmd='func_win32_libid'
++ ;;
++
++mingw* | pw32*)
++ # Base MSYS/MinGW do not provide the 'file' command needed by
++ # func_win32_libid shell function, so use a weaker test based on 'objdump',
++ # unless we find 'file', for example because we are cross-compiling.
++ if ( file / ) >/dev/null 2>&1; then
++ lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
++ lt_cv_file_magic_cmd='func_win32_libid'
++ else
++ lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?'
++ lt_cv_file_magic_cmd='$OBJDUMP -f'
++ fi
++ ;;
++
++darwin* | rhapsody*)
++ lt_cv_deplibs_check_method=pass_all
++ ;;
++
++freebsd* | dragonfly*)
++ if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
++ case $host_cpu in
++ i*86 )
++ # Not sure whether the presence of OpenBSD here was a mistake.
++ # Let's accept both of them until this is cleared up.
++ lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library'
++ lt_cv_file_magic_cmd=/usr/bin/file
++ lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
++ ;;
+ esac
++ else
++ lt_cv_deplibs_check_method=pass_all
++ fi
++ ;;
++
++gnu*)
++ lt_cv_deplibs_check_method=pass_all
++ ;;
++
++hpux10.20* | hpux11*)
++ lt_cv_file_magic_cmd=/usr/bin/file
++ case $host_cpu in
++ ia64*)
++ lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64'
++ lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
+ ;;
+- vxworks*)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
++ hppa*64*)
++ [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]']
++ lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
+ ;;
+ *)
+- # FIXME: insert proper C++ library support
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
++ lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]].[[0-9]]) shared library'
++ lt_cv_file_magic_test_file=/usr/lib/libc.sl
+ ;;
+-esac
+-AC_MSG_RESULT([$_LT_AC_TAGVAR(ld_shlibs, $1)])
+-test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
++ esac
++ ;;
+
+-_LT_AC_TAGVAR(GCC, $1)="$GXX"
+-_LT_AC_TAGVAR(LD, $1)="$LD"
++interix[[3-9]]*)
++ # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
++ lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$'
++ ;;
+
+-## CAVEAT EMPTOR:
+-## There is no encapsulation within the following macros, do not change
+-## the running order or otherwise move them around unless you know exactly
+-## what you are doing...
+-AC_LIBTOOL_POSTDEP_PREDEP($1)
+-AC_LIBTOOL_PROG_COMPILER_PIC($1)
+-AC_LIBTOOL_PROG_CC_C_O($1)
+-AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
+-AC_LIBTOOL_PROG_LD_SHLIBS($1)
+-AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
+-AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
++irix5* | irix6* | nonstopux*)
++ case $LD in
++ *-32|*"-32 ") libmagic=32-bit;;
++ *-n32|*"-n32 ") libmagic=N32;;
++ *-64|*"-64 ") libmagic=64-bit;;
++ *) libmagic=never-match;;
++ esac
++ lt_cv_deplibs_check_method=pass_all
++ ;;
+
+-AC_LIBTOOL_CONFIG($1)
++# This must be Linux ELF.
++linux* | k*bsd*-gnu)
++ lt_cv_deplibs_check_method=pass_all
++ ;;
+
+-AC_LANG_POP
+-CC=$lt_save_CC
+-LDCXX=$LD
+-LD=$lt_save_LD
+-GCC=$lt_save_GCC
+-with_gnu_ldcxx=$with_gnu_ld
+-with_gnu_ld=$lt_save_with_gnu_ld
+-lt_cv_path_LDCXX=$lt_cv_path_LD
+-lt_cv_path_LD=$lt_save_path_LD
+-lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
+-lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
+-])# AC_LIBTOOL_LANG_CXX_CONFIG
++netbsd*)
++ if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
++ lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
++ else
++ lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$'
++ fi
++ ;;
+
+-# AC_LIBTOOL_POSTDEP_PREDEP([TAGNAME])
+-# ------------------------------------
+-# Figure out "hidden" library dependencies from verbose
+-# compiler output when linking a shared library.
+-# Parse the compiler output and extract the necessary
+-# objects, libraries and library flags.
+-AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP],[
+-dnl we can't use the lt_simple_compile_test_code here,
+-dnl because it contains code intended for an executable,
+-dnl not a library. It's possible we should let each
+-dnl tag define a new lt_????_link_test_code variable,
+-dnl but it's only used here...
+-ifelse([$1],[],[cat > conftest.$ac_ext <<EOF
+-int a;
+-void foo (void) { a = 0; }
+-EOF
+-],[$1],[CXX],[cat > conftest.$ac_ext <<EOF
+-class Foo
+-{
+-public:
+- Foo (void) { a = 0; }
+-private:
+- int a;
+-};
+-EOF
+-],[$1],[F77],[cat > conftest.$ac_ext <<EOF
+- subroutine foo
+- implicit none
+- integer*4 a
+- a=0
+- return
+- end
+-EOF
+-],[$1],[GCJ],[cat > conftest.$ac_ext <<EOF
+-public class foo {
+- private int a;
+- public void bar (void) {
+- a = 0;
+- }
+-};
+-EOF
+-])
+-dnl Parse the compiler output and extract the necessary
+-dnl objects, libraries and library flags.
+-if AC_TRY_EVAL(ac_compile); then
+- # Parse the compiler output and extract the necessary
+- # objects, libraries and library flags.
++newos6*)
++ lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)'
++ lt_cv_file_magic_cmd=/usr/bin/file
++ lt_cv_file_magic_test_file=/usr/lib/libnls.so
++ ;;
+
+- # Sentinel used to keep track of whether or not we are before
+- # the conftest object file.
+- pre_test_object_deps_done=no
++*nto* | *qnx*)
++ lt_cv_deplibs_check_method=pass_all
++ ;;
+
+- # The `*' in the case matches for architectures that use `case' in
+- # $output_verbose_cmd can trigger glob expansion during the loop
+- # eval without this substitution.
+- output_verbose_link_cmd=`$echo "X$output_verbose_link_cmd" | $Xsed -e "$no_glob_subst"`
++openbsd*)
++ if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
++ lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$'
++ else
++ lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
++ fi
++ ;;
+
+- for p in `eval $output_verbose_link_cmd`; do
+- case $p in
++osf3* | osf4* | osf5*)
++ lt_cv_deplibs_check_method=pass_all
++ ;;
+
+- -L* | -R* | -l*)
+- # Some compilers place space between "-{L,R}" and the path.
+- # Remove the space.
+- if test $p = "-L" \
+- || test $p = "-R"; then
+- prev=$p
+- continue
+- else
+- prev=
+- fi
++rdos*)
++ lt_cv_deplibs_check_method=pass_all
++ ;;
++
++solaris*)
++ lt_cv_deplibs_check_method=pass_all
++ ;;
++
++sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
++ lt_cv_deplibs_check_method=pass_all
++ ;;
++
++sysv4 | sysv4.3*)
++ case $host_vendor in
++ motorola)
++ lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]'
++ lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
++ ;;
++ ncr)
++ lt_cv_deplibs_check_method=pass_all
++ ;;
++ sequent)
++ lt_cv_file_magic_cmd='/bin/file'
++ lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )'
++ ;;
++ sni)
++ lt_cv_file_magic_cmd='/bin/file'
++ lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib"
++ lt_cv_file_magic_test_file=/lib/libc.so
++ ;;
++ siemens)
++ lt_cv_deplibs_check_method=pass_all
++ ;;
++ pc)
++ lt_cv_deplibs_check_method=pass_all
++ ;;
++ esac
++ ;;
++
++tpf*)
++ lt_cv_deplibs_check_method=pass_all
++ ;;
++esac
++])
++file_magic_cmd=$lt_cv_file_magic_cmd
++deplibs_check_method=$lt_cv_deplibs_check_method
++test -z "$deplibs_check_method" && deplibs_check_method=unknown
++
++_LT_DECL([], [deplibs_check_method], [1],
++ [Method to check whether dependent libraries are shared objects])
++_LT_DECL([], [file_magic_cmd], [1],
++ [Command to use when deplibs_check_method == "file_magic"])
++])# _LT_CHECK_MAGIC_METHOD
++
++
++# LT_PATH_NM
++# ----------
++# find the pathname to a BSD- or MS-compatible name lister
++AC_DEFUN([LT_PATH_NM],
++[AC_REQUIRE([AC_PROG_CC])dnl
++AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM,
++[if test -n "$NM"; then
++ # Let the user override the test.
++ lt_cv_path_NM="$NM"
++else
++ lt_nm_to_check="${ac_tool_prefix}nm"
++ if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
++ lt_nm_to_check="$lt_nm_to_check nm"
++ fi
++ for lt_tmp_nm in $lt_nm_to_check; do
++ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
++ for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
++ IFS="$lt_save_ifs"
++ test -z "$ac_dir" && ac_dir=.
++ tmp_nm="$ac_dir/$lt_tmp_nm"
++ if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
++ # Check to see if the nm accepts a BSD-compat flag.
++ # Adding the `sed 1q' prevents false positives on HP-UX, which says:
++ # nm: unknown option "B" ignored
++ # Tru64's nm complains that /dev/null is an invalid object file
++ case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
++ */dev/null* | *'Invalid file or object type'*)
++ lt_cv_path_NM="$tmp_nm -B"
++ break
++ ;;
++ *)
++ case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
++ */dev/null*)
++ lt_cv_path_NM="$tmp_nm -p"
++ break
++ ;;
++ *)
++ lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
++ continue # so that we can try to find one that supports BSD flags
++ ;;
++ esac
++ ;;
++ esac
++ fi
++ done
++ IFS="$lt_save_ifs"
++ done
++ : ${lt_cv_path_NM=no}
++fi])
++if test "$lt_cv_path_NM" != "no"; then
++ NM="$lt_cv_path_NM"
++else
++ # Didn't find any BSD compatible name lister, look for dumpbin.
++ AC_CHECK_TOOLS(DUMPBIN, ["dumpbin -symbols" "link -dump -symbols"], :)
++ AC_SUBST([DUMPBIN])
++ if test "$DUMPBIN" != ":"; then
++ NM="$DUMPBIN"
++ fi
++fi
++test -z "$NM" && NM=nm
++AC_SUBST([NM])
++_LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl
++
++AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface],
++ [lt_cv_nm_interface="BSD nm"
++ echo "int some_variable = 0;" > conftest.$ac_ext
++ (eval echo "\"\$as_me:__oline__: $ac_compile\"" >&AS_MESSAGE_LOG_FD)
++ (eval "$ac_compile" 2>conftest.err)
++ cat conftest.err >&AS_MESSAGE_LOG_FD
++ (eval echo "\"\$as_me:__oline__: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD)
++ (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
++ cat conftest.err >&AS_MESSAGE_LOG_FD
++ (eval echo "\"\$as_me:__oline__: output\"" >&AS_MESSAGE_LOG_FD)
++ cat conftest.out >&AS_MESSAGE_LOG_FD
++ if $GREP 'External.*some_variable' conftest.out > /dev/null; then
++ lt_cv_nm_interface="MS dumpbin"
++ fi
++ rm -f conftest*])
++])# LT_PATH_NM
++
++# Old names:
++AU_ALIAS([AM_PROG_NM], [LT_PATH_NM])
++AU_ALIAS([AC_PROG_NM], [LT_PATH_NM])
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([AM_PROG_NM], [])
++dnl AC_DEFUN([AC_PROG_NM], [])
++
++
++# LT_LIB_M
++# --------
++# check for math library
++AC_DEFUN([LT_LIB_M],
++[AC_REQUIRE([AC_CANONICAL_HOST])dnl
++LIBM=
++case $host in
++*-*-beos* | *-*-cygwin* | *-*-pw32* | *-*-darwin*)
++ # These system don't have libm, or don't need it
++ ;;
++*-ncr-sysv4.3*)
++ AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
++ AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm")
++ ;;
++*)
++ AC_CHECK_LIB(m, cos, LIBM="-lm")
++ ;;
++esac
++AC_SUBST([LIBM])
++])# LT_LIB_M
++
++# Old name:
++AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M])
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([AC_CHECK_LIBM], [])
++
++
++# _LT_COMPILER_NO_RTTI([TAGNAME])
++# -------------------------------
++m4_defun([_LT_COMPILER_NO_RTTI],
++[m4_require([_LT_TAG_COMPILER])dnl
++
++_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
++
++if test "$GCC" = yes; then
++ _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
++
++ _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions],
++ lt_cv_prog_compiler_rtti_exceptions,
++ [-fno-rtti -fno-exceptions], [],
++ [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"])
++fi
++_LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1],
++ [Compiler flag to turn off builtin functions])
++])# _LT_COMPILER_NO_RTTI
++
++
++# _LT_CMD_GLOBAL_SYMBOLS
++# ----------------------
++m4_defun([_LT_CMD_GLOBAL_SYMBOLS],
++[AC_REQUIRE([AC_CANONICAL_HOST])dnl
++AC_REQUIRE([AC_PROG_CC])dnl
++AC_REQUIRE([LT_PATH_NM])dnl
++AC_REQUIRE([LT_PATH_LD])dnl
++m4_require([_LT_DECL_SED])dnl
++m4_require([_LT_DECL_EGREP])dnl
++m4_require([_LT_TAG_COMPILER])dnl
++
++# Check for command to grab the raw symbol name followed by C symbol from nm.
++AC_MSG_CHECKING([command to parse $NM output from $compiler object])
++AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe],
++[
++# These are sane defaults that work on at least a few old systems.
++# [They come from Ultrix. What could be older than Ultrix?!! ;)]
++
++# Character class describing NM global symbol codes.
++symcode='[[BCDEGRST]]'
++
++# Regexp to match symbols that can be accessed directly from C.
++sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)'
++
++# Define system-specific variables.
++case $host_os in
++aix*)
++ symcode='[[BCDT]]'
++ ;;
++cygwin* | mingw* | pw32*)
++ symcode='[[ABCDGISTW]]'
++ ;;
++hpux*)
++ if test "$host_cpu" = ia64; then
++ symcode='[[ABCDEGRST]]'
++ fi
++ ;;
++irix* | nonstopux*)
++ symcode='[[BCDEGRST]]'
++ ;;
++osf*)
++ symcode='[[BCDEGQRST]]'
++ ;;
++solaris*)
++ symcode='[[BDRT]]'
++ ;;
++sco3.2v5*)
++ symcode='[[DT]]'
++ ;;
++sysv4.2uw2*)
++ symcode='[[DT]]'
++ ;;
++sysv5* | sco5v6* | unixware* | OpenUNIX*)
++ symcode='[[ABDT]]'
++ ;;
++sysv4)
++ symcode='[[DFNSTU]]'
++ ;;
++esac
++
++# If we're using GNU nm, then use its standard symbol codes.
++case `$NM -V 2>&1` in
++*GNU* | *'with BFD'*)
++ symcode='[[ABCDGIRSTW]]' ;;
++esac
++
++# Transform an extracted symbol line into a proper C declaration.
++# Some systems (esp. on ia64) link data and code symbols differently,
++# so use this general approach.
++lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
++
++# Transform an extracted symbol line into symbol name and symbol address
++lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p'"
++lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"lib\2\", (void *) \&\2},/p'"
++
++# Handle CRLF in mingw tool chain
++opt_cr=
++case $build_os in
++mingw*)
++ opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp
++ ;;
++esac
++
++# Try without a prefix underscore, then with it.
++for ac_symprfx in "" "_"; do
++
++ # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
++ symxfrm="\\1 $ac_symprfx\\2 \\2"
++
++ # Write the raw and C identifiers.
++ if test "$lt_cv_nm_interface" = "MS dumpbin"; then
++ # Fake it for dumpbin and say T for any non-static function
++ # and D for any global variable.
++ # Also find C++ and __fastcall symbols from MSVC++,
++ # which start with @ or ?.
++ lt_cv_sys_global_symbol_pipe="$AWK ['"\
++" {last_section=section; section=\$ 3};"\
++" /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\
++" \$ 0!~/External *\|/{next};"\
++" / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\
++" {if(hide[section]) next};"\
++" {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\
++" {split(\$ 0, a, /\||\r/); split(a[2], s)};"\
++" s[1]~/^[@?]/{print s[1], s[1]; next};"\
++" s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\
++" ' prfx=^$ac_symprfx]"
++ else
++ lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
++ fi
++
++ # Check to see that the pipe works correctly.
++ pipe_works=no
++
++ rm -f conftest*
++ cat > conftest.$ac_ext <<_LT_EOF
++#ifdef __cplusplus
++extern "C" {
++#endif
++char nm_test_var;
++void nm_test_func(void);
++void nm_test_func(void){}
++#ifdef __cplusplus
++}
++#endif
++int main(){nm_test_var='a';nm_test_func();return(0);}
++_LT_EOF
++
++ if AC_TRY_EVAL(ac_compile); then
++ # Now try to grab the symbols.
++ nlist=conftest.nm
++ if AC_TRY_EVAL(NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) && test -s "$nlist"; then
++ # Try sorting and uniquifying the output.
++ if sort "$nlist" | uniq > "$nlist"T; then
++ mv -f "$nlist"T "$nlist"
++ else
++ rm -f "$nlist"T
++ fi
++
++ # Make sure that we snagged all the symbols we need.
++ if $GREP ' nm_test_var$' "$nlist" >/dev/null; then
++ if $GREP ' nm_test_func$' "$nlist" >/dev/null; then
++ cat <<_LT_EOF > conftest.$ac_ext
++#ifdef __cplusplus
++extern "C" {
++#endif
++
++_LT_EOF
++ # Now generate the symbol file.
++ eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext'
++
++ cat <<_LT_EOF >> conftest.$ac_ext
++
++/* The mapping between symbol names and symbols. */
++const struct {
++ const char *name;
++ void *address;
++}
++lt__PROGRAM__LTX_preloaded_symbols[[]] =
++{
++ { "@PROGRAM@", (void *) 0 },
++_LT_EOF
++ $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
++ cat <<\_LT_EOF >> conftest.$ac_ext
++ {0, (void *) 0}
++};
++
++/* This works around a problem in FreeBSD linker */
++#ifdef FREEBSD_WORKAROUND
++static const void *lt_preloaded_setup() {
++ return lt__PROGRAM__LTX_preloaded_symbols;
++}
++#endif
++
++#ifdef __cplusplus
++}
++#endif
++_LT_EOF
++ # Now try linking the two files.
++ mv conftest.$ac_objext conftstm.$ac_objext
++ lt_save_LIBS="$LIBS"
++ lt_save_CFLAGS="$CFLAGS"
++ LIBS="conftstm.$ac_objext"
++ CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)"
++ if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then
++ pipe_works=yes
++ fi
++ LIBS="$lt_save_LIBS"
++ CFLAGS="$lt_save_CFLAGS"
++ else
++ echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD
++ fi
++ else
++ echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD
++ fi
++ else
++ echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD
++ fi
++ else
++ echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD
++ cat conftest.$ac_ext >&5
++ fi
++ rm -rf conftest* conftst*
+
+- if test "$pre_test_object_deps_done" = no; then
+- case $p in
+- -L* | -R*)
+- # Internal compiler library paths should come after those
+- # provided the user. The postdeps already come after the
+- # user supplied libs so there is no need to process them.
+- if test -z "$_LT_AC_TAGVAR(compiler_lib_search_path, $1)"; then
+- _LT_AC_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}"
+- else
+- _LT_AC_TAGVAR(compiler_lib_search_path, $1)="${_LT_AC_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}"
+- fi
+- ;;
+- # The "-l" case would never come before the object being
+- # linked, so don't bother handling this case.
+- esac
+- else
+- if test -z "$_LT_AC_TAGVAR(postdeps, $1)"; then
+- _LT_AC_TAGVAR(postdeps, $1)="${prev}${p}"
+- else
+- _LT_AC_TAGVAR(postdeps, $1)="${_LT_AC_TAGVAR(postdeps, $1)} ${prev}${p}"
+- fi
+- fi
+- ;;
++ # Do not use the global_symbol_pipe unless it works.
++ if test "$pipe_works" = yes; then
++ break
++ else
++ lt_cv_sys_global_symbol_pipe=
++ fi
++done
++])
++if test -z "$lt_cv_sys_global_symbol_pipe"; then
++ lt_cv_sys_global_symbol_to_cdecl=
++fi
++if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
++ AC_MSG_RESULT(failed)
++else
++ AC_MSG_RESULT(ok)
++fi
+
+- *.$objext)
+- # This assumes that the test object file only shows up
+- # once in the compiler output.
+- if test "$p" = "conftest.$objext"; then
+- pre_test_object_deps_done=yes
+- continue
+- fi
++_LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1],
++ [Take the output of nm and produce a listing of raw symbols and C names])
++_LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1],
++ [Transform the output of nm in a proper C declaration])
++_LT_DECL([global_symbol_to_c_name_address],
++ [lt_cv_sys_global_symbol_to_c_name_address], [1],
++ [Transform the output of nm in a C name address pair])
++_LT_DECL([global_symbol_to_c_name_address_lib_prefix],
++ [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1],
++ [Transform the output of nm in a C name address pair when lib prefix is needed])
++]) # _LT_CMD_GLOBAL_SYMBOLS
+
+- if test "$pre_test_object_deps_done" = no; then
+- if test -z "$_LT_AC_TAGVAR(predep_objects, $1)"; then
+- _LT_AC_TAGVAR(predep_objects, $1)="$p"
+- else
+- _LT_AC_TAGVAR(predep_objects, $1)="$_LT_AC_TAGVAR(predep_objects, $1) $p"
+- fi
+- else
+- if test -z "$_LT_AC_TAGVAR(postdep_objects, $1)"; then
+- _LT_AC_TAGVAR(postdep_objects, $1)="$p"
+- else
+- _LT_AC_TAGVAR(postdep_objects, $1)="$_LT_AC_TAGVAR(postdep_objects, $1) $p"
+- fi
+- fi
+- ;;
+
+- *) ;; # Ignore the rest.
++# _LT_COMPILER_PIC([TAGNAME])
++# ---------------------------
++m4_defun([_LT_COMPILER_PIC],
++[m4_require([_LT_TAG_COMPILER])dnl
++_LT_TAGVAR(lt_prog_compiler_wl, $1)=
++_LT_TAGVAR(lt_prog_compiler_pic, $1)=
++_LT_TAGVAR(lt_prog_compiler_static, $1)=
++
++AC_MSG_CHECKING([for $compiler option to produce PIC])
++m4_if([$1], [CXX], [
++ # C++ specific cases for pic, static, wl, etc.
++ if test "$GXX" = yes; then
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+
++ case $host_os in
++ aix*)
++ # All AIX code is PIC.
++ if test "$host_cpu" = ia64; then
++ # AIX 5 now supports IA64 processor
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ fi
++ ;;
++
++ amigaos*)
++ case $host_cpu in
++ powerpc)
++ # see comment about AmigaOS4 .so support
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
++ ;;
++ m68k)
++ # FIXME: we need at least 68020 code to build shared libraries, but
++ # adding the `-m68020' flag to GCC prevents building anything better,
++ # like `-m68040'.
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
++ ;;
++ esac
++ ;;
++
++ beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
++ # PIC is the default for these OSes.
++ ;;
++ mingw* | cygwin* | os2* | pw32*)
++ # This hack is so that the source file can tell whether it is being
++ # built for inclusion in a dll (and should export symbols for example).
++ # Although the cygwin gcc ignores -fPIC, still need this for old-style
++ # (--disable-auto-import) libraries
++ m4_if([$1], [GCJ], [],
++ [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
++ ;;
++ darwin* | rhapsody*)
++ # PIC is the default on this platform
++ # Common symbols not allowed in MH_DYLIB files
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
++ ;;
++ *djgpp*)
++ # DJGPP does not support shared libraries at all
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)=
++ ;;
++ interix[[3-9]]*)
++ # Interix 3.x gcc -fpic/-fPIC options generate broken code.
++ # Instead, we relocate shared libraries at runtime.
++ ;;
++ sysv4*MP*)
++ if test -d /usr/nec; then
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
++ fi
++ ;;
++ hpux*)
++ # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
++ # not for PA HP-UX.
++ case $host_cpu in
++ hppa*64*|ia64*)
++ ;;
++ *)
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
++ ;;
++ esac
++ ;;
++ *qnx* | *nto*)
++ # QNX uses GNU C++, but need to define -shared option too, otherwise
++ # it will coredump.
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
++ ;;
++ *)
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
++ ;;
++ esac
++ else
++ case $host_os in
++ aix[[4-9]]*)
++ # All AIX code is PIC.
++ if test "$host_cpu" = ia64; then
++ # AIX 5 now supports IA64 processor
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ else
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
++ fi
++ ;;
++ chorus*)
++ case $cc_basename in
++ cxch68*)
++ # Green Hills C++ Compiler
++ # _LT_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a"
++ ;;
++ esac
++ ;;
++ dgux*)
++ case $cc_basename in
++ ec++*)
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ ;;
++ ghcx*)
++ # Green Hills C++ Compiler
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
++ ;;
++ *)
++ ;;
++ esac
++ ;;
++ freebsd* | dragonfly*)
++ # FreeBSD uses GNU C++
++ ;;
++ hpux9* | hpux10* | hpux11*)
++ case $cc_basename in
++ CC*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
++ if test "$host_cpu" != ia64; then
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
++ fi
++ ;;
++ aCC*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
++ case $host_cpu in
++ hppa*64*|ia64*)
++ # +Z the default
++ ;;
++ *)
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
++ ;;
++ esac
++ ;;
++ *)
++ ;;
++ esac
++ ;;
++ interix*)
++ # This is c89, which is MS Visual C++ (no shared libs)
++ # Anyone wants to do a port?
++ ;;
++ irix5* | irix6* | nonstopux*)
++ case $cc_basename in
++ CC*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
++ # CC pic flag -KPIC is the default.
++ ;;
++ *)
++ ;;
++ esac
++ ;;
++ linux* | k*bsd*-gnu)
++ case $cc_basename in
++ KCC*)
++ # KAI C++ Compiler
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
++ ;;
++ icpc* | ecpc* )
++ # Intel C++
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
++ ;;
++ pgCC* | pgcpp*)
++ # Portland Group C++ compiler
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ ;;
++ cxx*)
++ # Compaq C++
++ # Make sure the PIC flag is empty. It appears that all Alpha
++ # Linux and Compaq Tru64 Unix objects are PIC.
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)=
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
++ ;;
++ xlc* | xlC*)
++ # IBM XL 8.0 on PPC
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink'
++ ;;
++ *)
++ case `$CC -V 2>&1 | sed 5q` in
++ *Sun\ C*)
++ # Sun C++ 5.9
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
++ ;;
++ esac
++ ;;
++ esac
++ ;;
++ lynxos*)
++ ;;
++ m88k*)
++ ;;
++ mvs*)
++ case $cc_basename in
++ cxx*)
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall'
++ ;;
++ *)
++ ;;
++ esac
++ ;;
++ netbsd*)
++ ;;
++ *qnx* | *nto*)
++ # QNX uses GNU C++, but need to define -shared option too, otherwise
++ # it will coredump.
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
++ ;;
++ osf3* | osf4* | osf5*)
++ case $cc_basename in
++ KCC*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
++ ;;
++ RCC*)
++ # Rational C++ 2.4.1
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
++ ;;
++ cxx*)
++ # Digital/Compaq C++
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ # Make sure the PIC flag is empty. It appears that all Alpha
++ # Linux and Compaq Tru64 Unix objects are PIC.
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)=
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
++ ;;
++ *)
++ ;;
++ esac
++ ;;
++ psos*)
++ ;;
++ solaris*)
++ case $cc_basename in
++ CC*)
++ # Sun C++ 4.2, 5.x and Centerline C++
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
++ ;;
++ gcx*)
++ # Green Hills C++ Compiler
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
++ ;;
++ *)
++ ;;
++ esac
++ ;;
++ sunos4*)
++ case $cc_basename in
++ CC*)
++ # Sun C++ 4.x
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ ;;
++ lcc*)
++ # Lucid
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
++ ;;
++ *)
++ ;;
++ esac
++ ;;
++ sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
++ case $cc_basename in
++ CC*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ ;;
++ esac
++ ;;
++ tandem*)
++ case $cc_basename in
++ NCC*)
++ # NonStop-UX NCC 3.20
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ ;;
++ *)
++ ;;
++ esac
++ ;;
++ vxworks*)
++ ;;
++ *)
++ _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
++ ;;
+ esac
+- done
+-
+- # Clean up.
+- rm -f a.out a.exe
+-else
+- echo "libtool.m4: error: problem compiling $1 test program"
+-fi
+-
+-$rm -f confest.$objext
+-
+-# PORTME: override above test on systems where it is broken
+-ifelse([$1],[CXX],
+-[case $host_os in
+-interix3*)
+- # Interix 3.5 installs completely hosed .la files for C++, so rather than
+- # hack all around it, let's just trust "g++" to DTRT.
+- _LT_AC_TAGVAR(predep_objects,$1)=
+- _LT_AC_TAGVAR(postdep_objects,$1)=
+- _LT_AC_TAGVAR(postdeps,$1)=
+- ;;
+-
+-linux*)
+- case `$CC -V 2>&1 | sed 5q` in
+- *Sun\ C*)
+- # Sun C++ 5.9
+- _LT_AC_TAGVAR(postdeps,$1)='-lCstd -lCrun'
+- ;;
+- esac
+- ;;
+-
+-solaris*)
+- case $cc_basename in
+- CC*)
+- # Adding this requires a known-good setup of shared libraries for
+- # Sun compiler versions before 5.6, else PIC objects from an old
+- # archive will be linked into the output, leading to subtle bugs.
+- _LT_AC_TAGVAR(postdeps,$1)='-lCstd -lCrun'
+- ;;
+- esac
+- ;;
+-esac
+-])
+-
+-case " $_LT_AC_TAGVAR(postdeps, $1) " in
+-*" -lc "*) _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no ;;
+-esac
+-])# AC_LIBTOOL_POSTDEP_PREDEP
+-
+-# AC_LIBTOOL_LANG_F77_CONFIG
+-# --------------------------
+-# Ensure that the configuration vars for the C compiler are
+-# suitably defined. Those variables are subsequently used by
+-# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
+-AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG], [_LT_AC_LANG_F77_CONFIG(F77)])
+-AC_DEFUN([_LT_AC_LANG_F77_CONFIG],
+-[AC_REQUIRE([AC_PROG_F77])
+-AC_LANG_PUSH(Fortran 77)
+-
+-_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+-_LT_AC_TAGVAR(allow_undefined_flag, $1)=
+-_LT_AC_TAGVAR(always_export_symbols, $1)=no
+-_LT_AC_TAGVAR(archive_expsym_cmds, $1)=
+-_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=
+-_LT_AC_TAGVAR(hardcode_direct, $1)=no
+-_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
+-_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
+-_LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
+-_LT_AC_TAGVAR(hardcode_minus_L, $1)=no
+-_LT_AC_TAGVAR(hardcode_automatic, $1)=no
+-_LT_AC_TAGVAR(module_cmds, $1)=
+-_LT_AC_TAGVAR(module_expsym_cmds, $1)=
+-_LT_AC_TAGVAR(link_all_deplibs, $1)=unknown
+-_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+-_LT_AC_TAGVAR(no_undefined_flag, $1)=
+-_LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+-_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+-
+-# Source file extension for f77 test sources.
+-ac_ext=f
+-
+-# Object file extension for compiled f77 test sources.
+-objext=o
+-_LT_AC_TAGVAR(objext, $1)=$objext
+-
+-# Code to be used in simple compile tests
+-lt_simple_compile_test_code=" subroutine t\n return\n end\n"
+-
+-# Code to be used in simple link tests
+-lt_simple_link_test_code=" program t\n end\n"
+-
+-# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+-_LT_AC_SYS_COMPILER
+-
+-# save warnings/boilerplate of simple test code
+-_LT_COMPILER_BOILERPLATE
+-_LT_LINKER_BOILERPLATE
+-
+-# Allow CC to be a program name with arguments.
+-lt_save_CC="$CC"
+-CC=${F77-"f77"}
+-compiler=$CC
+-_LT_AC_TAGVAR(compiler, $1)=$CC
+-_LT_CC_BASENAME([$compiler])
+-
+-AC_MSG_CHECKING([if libtool supports shared libraries])
+-AC_MSG_RESULT([$can_build_shared])
+-
+-AC_MSG_CHECKING([whether to build shared libraries])
+-test "$can_build_shared" = "no" && enable_shared=no
+-
+-# On AIX, shared libraries and static libraries use the same namespace, and
+-# are all built from PIC.
+-case $host_os in
+-aix3*)
+- test "$enable_shared" = yes && enable_static=no
+- if test -n "$RANLIB"; then
+- archive_cmds="$archive_cmds~\$RANLIB \$lib"
+- postinstall_cmds='$RANLIB $lib'
+ fi
+- ;;
+-aix4* | aix5*)
+- if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+- test "$enable_shared" = yes && enable_static=no
+- fi
+- ;;
+-esac
+-AC_MSG_RESULT([$enable_shared])
+-
+-AC_MSG_CHECKING([whether to build static libraries])
+-# Make sure either enable_shared or enable_static is yes.
+-test "$enable_shared" = yes || enable_static=yes
+-AC_MSG_RESULT([$enable_static])
+-
+-_LT_AC_TAGVAR(GCC, $1)="$G77"
+-_LT_AC_TAGVAR(LD, $1)="$LD"
+-
+-AC_LIBTOOL_PROG_COMPILER_PIC($1)
+-AC_LIBTOOL_PROG_CC_C_O($1)
+-AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
+-AC_LIBTOOL_PROG_LD_SHLIBS($1)
+-AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
+-AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
+-
+-AC_LIBTOOL_CONFIG($1)
+-
+-AC_LANG_POP
+-CC="$lt_save_CC"
+-])# AC_LIBTOOL_LANG_F77_CONFIG
+-
+-
+-# AC_LIBTOOL_LANG_GCJ_CONFIG
+-# --------------------------
+-# Ensure that the configuration vars for the C compiler are
+-# suitably defined. Those variables are subsequently used by
+-# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
+-AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG], [_LT_AC_LANG_GCJ_CONFIG(GCJ)])
+-AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG],
+-[AC_LANG_SAVE
+-
+-# Source file extension for Java test sources.
+-ac_ext=java
++],
++[
++ if test "$GCC" = yes; then
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+
+-# Object file extension for compiled Java test sources.
+-objext=o
+-_LT_AC_TAGVAR(objext, $1)=$objext
++ case $host_os in
++ aix*)
++ # All AIX code is PIC.
++ if test "$host_cpu" = ia64; then
++ # AIX 5 now supports IA64 processor
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ fi
++ ;;
+
+-# Code to be used in simple compile tests
+-lt_simple_compile_test_code="class foo {}\n"
++ amigaos*)
++ case $host_cpu in
++ powerpc)
++ # see comment about AmigaOS4 .so support
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
++ ;;
++ m68k)
++ # FIXME: we need at least 68020 code to build shared libraries, but
++ # adding the `-m68020' flag to GCC prevents building anything better,
++ # like `-m68040'.
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
++ ;;
++ esac
++ ;;
+
+-# Code to be used in simple link tests
+-lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }\n'
++ beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
++ # PIC is the default for these OSes.
++ ;;
+
+-# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+-_LT_AC_SYS_COMPILER
++ mingw* | cygwin* | pw32* | os2*)
++ # This hack is so that the source file can tell whether it is being
++ # built for inclusion in a dll (and should export symbols for example).
++ # Although the cygwin gcc ignores -fPIC, still need this for old-style
++ # (--disable-auto-import) libraries
++ m4_if([$1], [GCJ], [],
++ [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
++ ;;
+
+-# save warnings/boilerplate of simple test code
+-_LT_COMPILER_BOILERPLATE
+-_LT_LINKER_BOILERPLATE
++ darwin* | rhapsody*)
++ # PIC is the default on this platform
++ # Common symbols not allowed in MH_DYLIB files
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
++ ;;
+
+-# Allow CC to be a program name with arguments.
+-lt_save_CC="$CC"
+-CC=${GCJ-"gcj"}
+-compiler=$CC
+-_LT_AC_TAGVAR(compiler, $1)=$CC
+-_LT_CC_BASENAME([$compiler])
++ hpux*)
++ # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
++ # not for PA HP-UX.
++ case $host_cpu in
++ hppa*64*|ia64*)
++ # +Z the default
++ ;;
++ *)
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
++ ;;
++ esac
++ ;;
+
+-# GCJ did not exist at the time GCC didn't implicitly link libc in.
+-_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
++ interix[[3-9]]*)
++ # Interix 3.x gcc -fpic/-fPIC options generate broken code.
++ # Instead, we relocate shared libraries at runtime.
++ ;;
+
+-_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
++ msdosdjgpp*)
++ # Just because we use GCC doesn't mean we suddenly get shared libraries
++ # on systems that don't support them.
++ _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
++ enable_shared=no
++ ;;
+
+-## CAVEAT EMPTOR:
+-## There is no encapsulation within the following macros, do not change
+-## the running order or otherwise move them around unless you know exactly
+-## what you are doing...
+-AC_LIBTOOL_PROG_COMPILER_NO_RTTI($1)
+-AC_LIBTOOL_PROG_COMPILER_PIC($1)
+-AC_LIBTOOL_PROG_CC_C_O($1)
+-AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
+-AC_LIBTOOL_PROG_LD_SHLIBS($1)
+-AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
+-AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
++ *nto* | *qnx*)
++ # QNX uses GNU C++, but need to define -shared option too, otherwise
++ # it will coredump.
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
++ ;;
+
+-AC_LIBTOOL_CONFIG($1)
++ sysv4*MP*)
++ if test -d /usr/nec; then
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
++ fi
++ ;;
+
+-AC_LANG_RESTORE
+-CC="$lt_save_CC"
+-])# AC_LIBTOOL_LANG_GCJ_CONFIG
++ *)
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
++ ;;
++ esac
++ else
++ # PORTME Check for flag to pass linker flags through the system compiler.
++ case $host_os in
++ aix*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ if test "$host_cpu" = ia64; then
++ # AIX 5 now supports IA64 processor
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ else
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
++ fi
++ ;;
+
++ mingw* | cygwin* | pw32* | os2*)
++ # This hack is so that the source file can tell whether it is being
++ # built for inclusion in a dll (and should export symbols for example).
++ m4_if([$1], [GCJ], [],
++ [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
++ ;;
+
+-# AC_LIBTOOL_LANG_RC_CONFIG
+-# -------------------------
+-# Ensure that the configuration vars for the Windows resource compiler are
+-# suitably defined. Those variables are subsequently used by
+-# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
+-AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG], [_LT_AC_LANG_RC_CONFIG(RC)])
+-AC_DEFUN([_LT_AC_LANG_RC_CONFIG],
+-[AC_LANG_SAVE
++ hpux9* | hpux10* | hpux11*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
++ # not for PA HP-UX.
++ case $host_cpu in
++ hppa*64*|ia64*)
++ # +Z the default
++ ;;
++ *)
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
++ ;;
++ esac
++ # Is there a better lt_prog_compiler_static that works with the bundled CC?
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
++ ;;
+
+-# Source file extension for RC test sources.
+-ac_ext=rc
++ irix5* | irix6* | nonstopux*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ # PIC (with -KPIC) is the default.
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
++ ;;
+
+-# Object file extension for compiled RC test sources.
+-objext=o
+-_LT_AC_TAGVAR(objext, $1)=$objext
++ linux* | k*bsd*-gnu)
++ case $cc_basename in
++ icc* | ecc* | ifort*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
++ ;;
++ pgcc* | pgf77* | pgf90* | pgf95*)
++ # Portland Group compilers (*not* the Pentium gcc compiler,
++ # which looks to be a dead project)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ ;;
++ ccc*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ # All Alpha code is PIC.
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
++ ;;
++ xl*)
++ # IBM XL C 8.0/Fortran 10.1 on PPC
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink'
++ ;;
++ *)
++ case `$CC -V 2>&1 | sed 5q` in
++ *Sun\ C*)
++ # Sun C 5.9
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ ;;
++ *Sun\ F*)
++ # Sun Fortran 8.3 passes all unrecognized flags to the linker
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)=''
++ ;;
++ esac
++ ;;
++ esac
++ ;;
+
+-# Code to be used in simple compile tests
+-lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }\n'
++ newsos6)
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ ;;
+
+-# Code to be used in simple link tests
+-lt_simple_link_test_code="$lt_simple_compile_test_code"
++ *nto* | *qnx*)
++ # QNX uses GNU C++, but need to define -shared option too, otherwise
++ # it will coredump.
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
++ ;;
+
+-# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+-_LT_AC_SYS_COMPILER
++ osf3* | osf4* | osf5*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ # All OSF/1 code is PIC.
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
++ ;;
+
+-# save warnings/boilerplate of simple test code
+-_LT_COMPILER_BOILERPLATE
+-_LT_LINKER_BOILERPLATE
++ rdos*)
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
++ ;;
+
+-# Allow CC to be a program name with arguments.
+-lt_save_CC="$CC"
+-CC=${RC-"windres"}
+-compiler=$CC
+-_LT_AC_TAGVAR(compiler, $1)=$CC
+-_LT_CC_BASENAME([$compiler])
+-_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
++ solaris*)
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ case $cc_basename in
++ f77* | f90* | f95*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';;
++ *)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';;
++ esac
++ ;;
+
+-AC_LIBTOOL_CONFIG($1)
++ sunos4*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ ;;
+
+-AC_LANG_RESTORE
+-CC="$lt_save_CC"
+-])# AC_LIBTOOL_LANG_RC_CONFIG
++ sysv4 | sysv4.2uw2* | sysv4.3*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ ;;
++
++ sysv4*MP*)
++ if test -d /usr/nec ;then
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ fi
++ ;;
+
++ sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ ;;
+
+-# AC_LIBTOOL_CONFIG([TAGNAME])
+-# ----------------------------
+-# If TAGNAME is not passed, then create an initial libtool script
+-# with a default configuration from the untagged config vars. Otherwise
+-# add code to config.status for appending the configuration named by
+-# TAGNAME from the matching tagged config vars.
+-AC_DEFUN([AC_LIBTOOL_CONFIG],
+-[# The else clause should only fire when bootstrapping the
+-# libtool distribution, otherwise you forgot to ship ltmain.sh
+-# with your package, and you will get complaints that there are
+-# no rules to generate ltmain.sh.
+-if test -f "$ltmain"; then
+- # See if we are running on zsh, and set the options which allow our commands through
+- # without removal of \ escapes.
+- if test -n "${ZSH_VERSION+set}" ; then
+- setopt NO_GLOB_SUBST
+- fi
+- # Now quote all the things that may contain metacharacters while being
+- # careful not to overquote the AC_SUBSTed values. We take copies of the
+- # variables and quote the copies for generation of the libtool script.
+- for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \
+- SED SHELL STRIP \
+- libname_spec library_names_spec soname_spec extract_expsyms_cmds \
+- old_striplib striplib file_magic_cmd finish_cmds finish_eval \
+- deplibs_check_method reload_flag reload_cmds need_locks \
+- lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \
+- lt_cv_sys_global_symbol_to_c_name_address \
+- sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
+- old_postinstall_cmds old_postuninstall_cmds \
+- _LT_AC_TAGVAR(compiler, $1) \
+- _LT_AC_TAGVAR(CC, $1) \
+- _LT_AC_TAGVAR(LD, $1) \
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1) \
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1) \
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1) \
+- _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) \
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1) \
+- _LT_AC_TAGVAR(thread_safe_flag_spec, $1) \
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1) \
+- _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1) \
+- _LT_AC_TAGVAR(old_archive_cmds, $1) \
+- _LT_AC_TAGVAR(old_archive_from_new_cmds, $1) \
+- _LT_AC_TAGVAR(predep_objects, $1) \
+- _LT_AC_TAGVAR(postdep_objects, $1) \
+- _LT_AC_TAGVAR(predeps, $1) \
+- _LT_AC_TAGVAR(postdeps, $1) \
+- _LT_AC_TAGVAR(compiler_lib_search_path, $1) \
+- _LT_AC_TAGVAR(archive_cmds, $1) \
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1) \
+- _LT_AC_TAGVAR(postinstall_cmds, $1) \
+- _LT_AC_TAGVAR(postuninstall_cmds, $1) \
+- _LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1) \
+- _LT_AC_TAGVAR(allow_undefined_flag, $1) \
+- _LT_AC_TAGVAR(no_undefined_flag, $1) \
+- _LT_AC_TAGVAR(export_symbols_cmds, $1) \
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) \
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1) \
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1) \
+- _LT_AC_TAGVAR(hardcode_automatic, $1) \
+- _LT_AC_TAGVAR(module_cmds, $1) \
+- _LT_AC_TAGVAR(module_expsym_cmds, $1) \
+- _LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1) \
+- _LT_AC_TAGVAR(exclude_expsyms, $1) \
+- _LT_AC_TAGVAR(include_expsyms, $1); do
+-
+- case $var in
+- _LT_AC_TAGVAR(old_archive_cmds, $1) | \
+- _LT_AC_TAGVAR(old_archive_from_new_cmds, $1) | \
+- _LT_AC_TAGVAR(archive_cmds, $1) | \
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1) | \
+- _LT_AC_TAGVAR(module_cmds, $1) | \
+- _LT_AC_TAGVAR(module_expsym_cmds, $1) | \
+- _LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1) | \
+- _LT_AC_TAGVAR(export_symbols_cmds, $1) | \
+- extract_expsyms_cmds | reload_cmds | finish_cmds | \
+- postinstall_cmds | postuninstall_cmds | \
+- old_postinstall_cmds | old_postuninstall_cmds | \
+- sys_lib_search_path_spec | sys_lib_dlsearch_path_spec)
+- # Double-quote double-evaled strings.
+- eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\""
++ unicos*)
++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
++ ;;
++
++ uts4*)
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
++
+ *)
+- eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\""
++ _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+ ;;
+ esac
+- done
+-
+- case $lt_echo in
+- *'\[$]0 --fallback-echo"')
+- lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\[$]0 --fallback-echo"[$]/[$]0 --fallback-echo"/'`
++ fi
++])
++case $host_os in
++ # For platforms which do not support PIC, -DPIC is meaningless:
++ *djgpp*)
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)=
+ ;;
+- esac
+-
+-ifelse([$1], [],
+- [cfgfile="${ofile}T"
+- trap "$rm \"$cfgfile\"; exit 1" 1 2 15
+- $rm -f "$cfgfile"
+- AC_MSG_NOTICE([creating $ofile])],
+- [cfgfile="$ofile"])
+-
+- cat <<__EOF__ >> "$cfgfile"
+-ifelse([$1], [],
+-[#! $SHELL
++ *)
++ _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])"
++ ;;
++esac
++AC_MSG_RESULT([$_LT_TAGVAR(lt_prog_compiler_pic, $1)])
++_LT_TAGDECL([wl], [lt_prog_compiler_wl], [1],
++ [How to pass a linker flag through the compiler])
+
+-# `$echo "$cfgfile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
+-# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP)
+-# NOTE: Changes made to this file will be lost: look at ltmain.sh.
+ #
+-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001
+-# Free Software Foundation, Inc.
+-#
+-# This file is part of GNU Libtool:
+-# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
+-#
+-# 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 of the License, or
+-# (at your option) any later version.
++# Check to make sure the PIC flag actually works.
+ #
+-# 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.
++if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then
++ _LT_COMPILER_OPTION([if $compiler PIC flag $_LT_TAGVAR(lt_prog_compiler_pic, $1) works],
++ [_LT_TAGVAR(lt_cv_prog_compiler_pic_works, $1)],
++ [$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [],
++ [case $_LT_TAGVAR(lt_prog_compiler_pic, $1) in
++ "" | " "*) ;;
++ *) _LT_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_TAGVAR(lt_prog_compiler_pic, $1)" ;;
++ esac],
++ [_LT_TAGVAR(lt_prog_compiler_pic, $1)=
++ _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no])
++fi
++_LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1],
++ [Additional compiler flags for building library objects])
++
+ #
+-# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
++# Check to make sure the static flag actually works.
+ #
+-# As a special exception to the GNU General Public License, if you
+-# distribute this file as part of a program that contains a
+-# configuration script generated by Autoconf, you may include it under
+-# the same distribution terms that you use for the rest of that program.
+-
+-# A sed program that does not truncate output.
+-SED=$lt_SED
+-
+-# Sed that helps us avoid accidentally triggering echo(1) options like -n.
+-Xsed="$SED -e 1s/^X//"
+-
+-# The HP-UX ksh and POSIX shell print the target directory to stdout
+-# if CDPATH is set.
+-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+-
+-# The names of the tagged configurations supported by this script.
+-available_tags=
+-
+-# ### BEGIN LIBTOOL CONFIG],
+-[# ### BEGIN LIBTOOL TAG CONFIG: $tagname])
+-
+-# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+-
+-# Shell to use when invoking shell scripts.
+-SHELL=$lt_SHELL
+-
+-# Whether or not to build shared libraries.
+-build_libtool_libs=$enable_shared
+-
+-# Whether or not to build static libraries.
+-build_old_libs=$enable_static
+-
+-# Whether or not to add -lc for building shared libraries.
+-build_libtool_need_lc=$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)
+-
+-# Whether or not to disallow shared libs when runtime libs are static
+-allow_libtool_libs_with_static_runtimes=$_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)
+-
+-# Whether or not to optimize for fast installation.
+-fast_install=$enable_fast_install
+-
+-# The host system.
+-host_alias=$host_alias
+-host=$host
+-host_os=$host_os
++wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_TAGVAR(lt_prog_compiler_static, $1)\"
++_LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works],
++ _LT_TAGVAR(lt_cv_prog_compiler_static_works, $1),
++ $lt_tmp_static_flag,
++ [],
++ [_LT_TAGVAR(lt_prog_compiler_static, $1)=])
++_LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1],
++ [Compiler flag to prevent dynamic linking])
++])# _LT_COMPILER_PIC
+
+-# The build system.
+-build_alias=$build_alias
+-build=$build
+-build_os=$build_os
+
+-# An echo program that does not interpret backslashes.
+-echo=$lt_echo
++# _LT_LINKER_SHLIBS([TAGNAME])
++# ----------------------------
++# See if the linker supports building shared libraries.
++m4_defun([_LT_LINKER_SHLIBS],
++[AC_REQUIRE([LT_PATH_LD])dnl
++AC_REQUIRE([LT_PATH_NM])dnl
++m4_require([_LT_FILEUTILS_DEFAULTS])dnl
++m4_require([_LT_DECL_EGREP])dnl
++m4_require([_LT_DECL_SED])dnl
++m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl
++m4_require([_LT_TAG_COMPILER])dnl
++AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
++m4_if([$1], [CXX], [
++ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
++ case $host_os in
++ aix[[4-9]]*)
++ # If we're using GNU nm, then we don't want the "-C" option.
++ # -C means demangle to AIX nm, but means don't demangle with GNU nm
++ if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
++ _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
++ else
++ _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
++ fi
++ ;;
++ pw32*)
++ _LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds"
++ ;;
++ cygwin* | mingw*)
++ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;/^.*[[ ]]__nm__/s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols'
++ ;;
++ *)
++ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
++ ;;
++ esac
++ _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']
++], [
++ runpath_var=
++ _LT_TAGVAR(allow_undefined_flag, $1)=
++ _LT_TAGVAR(always_export_symbols, $1)=no
++ _LT_TAGVAR(archive_cmds, $1)=
++ _LT_TAGVAR(archive_expsym_cmds, $1)=
++ _LT_TAGVAR(compiler_needs_object, $1)=no
++ _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)=
++ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
++ _LT_TAGVAR(hardcode_automatic, $1)=no
++ _LT_TAGVAR(hardcode_direct, $1)=no
++ _LT_TAGVAR(hardcode_direct_absolute, $1)=no
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
++ _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=
++ _LT_TAGVAR(hardcode_minus_L, $1)=no
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
++ _LT_TAGVAR(inherit_rpath, $1)=no
++ _LT_TAGVAR(link_all_deplibs, $1)=unknown
++ _LT_TAGVAR(module_cmds, $1)=
++ _LT_TAGVAR(module_expsym_cmds, $1)=
++ _LT_TAGVAR(old_archive_from_new_cmds, $1)=
++ _LT_TAGVAR(old_archive_from_expsyms_cmds, $1)=
++ _LT_TAGVAR(thread_safe_flag_spec, $1)=
++ _LT_TAGVAR(whole_archive_flag_spec, $1)=
++ # include_expsyms should be a list of space-separated symbols to be *always*
++ # included in the symbol list
++ _LT_TAGVAR(include_expsyms, $1)=
++ # exclude_expsyms can be an extended regexp of symbols to exclude
++ # it will be wrapped by ` (' and `)$', so one must not match beginning or
++ # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
++ # as well as any symbol that contains `d'.
++ _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']
++ # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
++ # platforms (ab)use it in PIC code, but their linkers get confused if
++ # the symbol is explicitly referenced. Since portable code cannot
++ # rely on this symbol name, it's probably fine to never include it in
++ # preloaded symbol tables.
++ # Exclude shared library initialization/finalization symbols.
++dnl Note also adjust exclude_expsyms for C++ above.
++ extract_expsyms_cmds=
+
+-# The archiver.
+-AR=$lt_AR
+-AR_FLAGS=$lt_AR_FLAGS
++ case $host_os in
++ cygwin* | mingw* | pw32*)
++ # FIXME: the MSVC++ port hasn't been tested in a loooong time
++ # When not using gcc, we currently assume that we are using
++ # Microsoft Visual C++.
++ if test "$GCC" != yes; then
++ with_gnu_ld=no
++ fi
++ ;;
++ interix*)
++ # we just hope/assume this is gcc and not c89 (= MSVC++)
++ with_gnu_ld=yes
++ ;;
++ openbsd*)
++ with_gnu_ld=no
++ ;;
++ esac
+
+-# A C compiler.
+-LTCC=$lt_LTCC
++ _LT_TAGVAR(ld_shlibs, $1)=yes
++ if test "$with_gnu_ld" = yes; then
++ # If archive_cmds runs LD, not CC, wlarc should be empty
++ wlarc='${wl}'
+
+-# LTCC compiler flags.
+-LTCFLAGS=$lt_LTCFLAGS
++ # Set some defaults for GNU ld with shared library support. These
++ # are reset later if shared libraries are not supported. Putting them
++ # here allows them to be overridden if necessary.
++ runpath_var=LD_RUN_PATH
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
++ # ancient GNU ld didn't support --whole-archive et. al.
++ if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then
++ _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
++ else
++ _LT_TAGVAR(whole_archive_flag_spec, $1)=
++ fi
++ supports_anon_versioning=no
++ case `$LD -v 2>&1` in
++ *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11
++ *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
++ *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
++ *\ 2.11.*) ;; # other 2.11 versions
++ *) supports_anon_versioning=yes ;;
++ esac
+
+-# A language-specific compiler.
+-CC=$lt_[]_LT_AC_TAGVAR(compiler, $1)
++ # See if GNU ld supports shared libraries.
++ case $host_os in
++ aix[[3-9]]*)
++ # On AIX/PPC, the GNU linker is very broken
++ if test "$host_cpu" != ia64; then
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ cat <<_LT_EOF 1>&2
+
+-# Is the compiler the GNU C compiler?
+-with_gcc=$_LT_AC_TAGVAR(GCC, $1)
++*** Warning: the GNU linker, at least up to release 2.9.1, is reported
++*** to be unable to reliably create shared libraries on AIX.
++*** Therefore, libtool is disabling shared libraries support. If you
++*** really care for shared libraries, you may want to modify your PATH
++*** so that a non-GNU linker is found, and then restart.
+
+-# An ERE matcher.
+-EGREP=$lt_EGREP
++_LT_EOF
++ fi
++ ;;
+
+-# The linker used to build libraries.
+-LD=$lt_[]_LT_AC_TAGVAR(LD, $1)
++ amigaos*)
++ case $host_cpu in
++ powerpc)
++ # see comment about AmigaOS4 .so support
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)=''
++ ;;
++ m68k)
++ _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
++ _LT_TAGVAR(hardcode_minus_L, $1)=yes
++ ;;
++ esac
++ ;;
+
+-# Whether we need hard or soft links.
+-LN_S=$lt_LN_S
++ beos*)
++ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
++ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
++ # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
++ # support --undefined. This deserves some investigation. FIXME
++ _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
++ else
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ fi
++ ;;
+
+-# A BSD-compatible nm program.
+-NM=$lt_NM
++ cygwin* | mingw* | pw32*)
++ # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
++ # as there is no search path for DLLs.
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
++ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
++ _LT_TAGVAR(always_export_symbols, $1)=no
++ _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
++ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols'
+
+-# A symbol stripping program
+-STRIP=$lt_STRIP
++ if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
++ # If the export-symbols file already is a .def file (1st line
++ # is EXPORTS), use it as is; otherwise, prepend...
++ _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
++ cp $export_symbols $output_objdir/$soname.def;
++ else
++ echo EXPORTS > $output_objdir/$soname.def;
++ cat $export_symbols >> $output_objdir/$soname.def;
++ fi~
++ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
++ else
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ fi
++ ;;
+
+-# Used to examine libraries when file_magic_cmd begins "file"
+-MAGIC_CMD=$MAGIC_CMD
++ interix[[3-9]]*)
++ _LT_TAGVAR(hardcode_direct, $1)=no
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
++ # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
++ # Instead, shared libraries are loaded at an image base (0x10000000 by
++ # default) and relocated if they conflict, which is a slow very memory
++ # consuming and fragmenting process. To avoid this, we pick a random,
++ # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
++ # time. Moving up from 0x10000000 also allows more sbrk(2) space.
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
++ ;;
+
+-# Used on cygwin: DLL creation program.
+-DLLTOOL="$DLLTOOL"
++ gnu* | linux* | tpf* | k*bsd*-gnu)
++ tmp_diet=no
++ if test "$host_os" = linux-dietlibc; then
++ case $cc_basename in
++ diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn)
++ esac
++ fi
++ if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \
++ && test "$tmp_diet" = no
++ then
++ tmp_addflag=
++ tmp_sharedflag='-shared'
++ case $cc_basename,$host_cpu in
++ pgcc*) # Portland Group C compiler
++ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
++ tmp_addflag=' $pic_flag'
++ ;;
++ pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers
++ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
++ tmp_addflag=' $pic_flag -Mnomain' ;;
++ ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64
++ tmp_addflag=' -i_dynamic' ;;
++ efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64
++ tmp_addflag=' -i_dynamic -nofor_main' ;;
++ ifc* | ifort*) # Intel Fortran compiler
++ tmp_addflag=' -nofor_main' ;;
++ xl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below)
++ tmp_sharedflag='-qmkshrobj'
++ tmp_addflag= ;;
++ esac
++ case `$CC -V 2>&1 | sed 5q` in
++ *Sun\ C*) # Sun C 5.9
++ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
++ _LT_TAGVAR(compiler_needs_object, $1)=yes
++ tmp_sharedflag='-G' ;;
++ *Sun\ F*) # Sun Fortran 8.3
++ tmp_sharedflag='-G' ;;
++ esac
++ _LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+
+-# Used on cygwin: object dumper.
+-OBJDUMP="$OBJDUMP"
++ if test "x$supports_anon_versioning" = xyes; then
++ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
++ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
++ echo "local: *; };" >> $output_objdir/$libname.ver~
++ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
++ fi
+
+-# Used on cygwin: assembler.
+-AS="$AS"
++ case $cc_basename in
++ xlf*)
++ # IBM XL Fortran 10.1 on PPC cannot create shared libs itself
++ _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
++ _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir'
++ _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $compiler_flags -soname $soname -o $lib'
++ if test "x$supports_anon_versioning" = xyes; then
++ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
++ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
++ echo "local: *; };" >> $output_objdir/$libname.ver~
++ $LD -shared $libobjs $deplibs $compiler_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
++ fi
++ ;;
++ esac
++ else
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ fi
++ ;;
+
+-# The name of the directory that contains temporary libtool files.
+-objdir=$objdir
++ netbsd*)
++ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
++ _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
++ wlarc=
++ else
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
++ fi
++ ;;
+
+-# How to create reloadable object files.
+-reload_flag=$lt_reload_flag
+-reload_cmds=$lt_reload_cmds
++ solaris*)
++ if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ cat <<_LT_EOF 1>&2
+
+-# How to pass a linker flag through the compiler.
+-wl=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)
++*** Warning: The releases 2.8.* of the GNU linker cannot reliably
++*** create shared libraries on Solaris systems. Therefore, libtool
++*** is disabling shared libraries support. We urge you to upgrade GNU
++*** binutils to release 2.9.1 or newer. Another option is to modify
++*** your PATH or compiler configuration so that the native linker is
++*** used, and then restart.
+
+-# Object file suffix (normally "o").
+-objext="$ac_objext"
++_LT_EOF
++ elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
++ else
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ fi
++ ;;
+
+-# Old archive suffix (normally "a").
+-libext="$libext"
++ sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
++ case `$LD -v 2>&1` in
++ *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*)
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ cat <<_LT_EOF 1>&2
+
+-# Shared library suffix (normally ".so").
+-shrext_cmds='$shrext_cmds'
++*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
++*** reliably create shared libraries on SCO systems. Therefore, libtool
++*** is disabling shared libraries support. We urge you to upgrade GNU
++*** binutils to release 2.16.91.0.3 or newer. Another option is to modify
++*** your PATH or compiler configuration so that the native linker is
++*** used, and then restart.
+
+-# Executable file suffix (normally "").
+-exeext="$exeext"
++_LT_EOF
++ ;;
++ *)
++ # For security reasons, it is highly recommended that you always
++ # use absolute paths for naming shared libraries, and exclude the
++ # DT_RUNPATH tag from executables and libraries. But doing so
++ # requires that you compile everything twice, which is a pain.
++ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
++ else
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ fi
++ ;;
++ esac
++ ;;
+
+-# Additional compiler flags for building library objects.
+-pic_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)
+-pic_mode=$pic_mode
++ sunos4*)
++ _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
++ wlarc=
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ ;;
+
+-# What is the maximum length of a command?
+-max_cmd_len=$lt_cv_sys_max_cmd_len
++ *)
++ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
++ else
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ fi
++ ;;
++ esac
+
+-# Does compiler simultaneously support -c and -o options?
+-compiler_c_o=$lt_[]_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)
++ if test "$_LT_TAGVAR(ld_shlibs, $1)" = no; then
++ runpath_var=
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)=
++ _LT_TAGVAR(whole_archive_flag_spec, $1)=
++ fi
++ else
++ # PORTME fill in a description of your system's linker (not GNU ld)
++ case $host_os in
++ aix3*)
++ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
++ _LT_TAGVAR(always_export_symbols, $1)=yes
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
++ # Note: this linker hardcodes the directories in LIBPATH if there
++ # are no directories specified by -L.
++ _LT_TAGVAR(hardcode_minus_L, $1)=yes
++ if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
++ # Neither direct hardcoding nor static linking is supported with a
++ # broken collect2.
++ _LT_TAGVAR(hardcode_direct, $1)=unsupported
++ fi
++ ;;
+
+-# Must we lock files when doing compilation?
+-need_locks=$lt_need_locks
++ aix[[4-9]]*)
++ if test "$host_cpu" = ia64; then
++ # On IA64, the linker does run time linking by default, so we don't
++ # have to do anything special.
++ aix_use_runtimelinking=no
++ exp_sym_flag='-Bexport'
++ no_entry_flag=""
++ else
++ # If we're using GNU nm, then we don't want the "-C" option.
++ # -C means demangle to AIX nm, but means don't demangle with GNU nm
++ if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
++ _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
++ else
++ _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
++ fi
++ aix_use_runtimelinking=no
+
+-# Do we need the lib prefix for modules?
+-need_lib_prefix=$need_lib_prefix
++ # Test if we are trying to use run time linking or normal
++ # AIX style linking. If -brtl is somewhere in LDFLAGS, we
++ # need to do runtime linking.
++ case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
++ for ld_flag in $LDFLAGS; do
++ if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
++ aix_use_runtimelinking=yes
++ break
++ fi
++ done
++ ;;
++ esac
+
+-# Do we need a version for libraries?
+-need_version=$need_version
++ exp_sym_flag='-bexport'
++ no_entry_flag='-bnoentry'
++ fi
+
+-# Whether dlopen is supported.
+-dlopen_support=$enable_dlopen
++ # When large executables or shared objects are built, AIX ld can
++ # have problems creating the table of contents. If linking a library
++ # or program results in "error TOC overflow" add -mminimal-toc to
++ # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
++ # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+-# Whether dlopen of programs is supported.
+-dlopen_self=$enable_dlopen_self
++ _LT_TAGVAR(archive_cmds, $1)=''
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
++ _LT_TAGVAR(link_all_deplibs, $1)=yes
++ _LT_TAGVAR(file_list_spec, $1)='${wl}-f,'
+
+-# Whether dlopen of statically linked programs is supported.
+-dlopen_self_static=$enable_dlopen_self_static
++ if test "$GCC" = yes; then
++ case $host_os in aix4.[[012]]|aix4.[[012]].*)
++ # We only want to do this on AIX 4.2 and lower, the check
++ # below for broken collect2 doesn't work under 4.3+
++ collect2name=`${CC} -print-prog-name=collect2`
++ if test -f "$collect2name" &&
++ strings "$collect2name" | $GREP resolve_lib_name >/dev/null
++ then
++ # We have reworked collect2
++ :
++ else
++ # We have old collect2
++ _LT_TAGVAR(hardcode_direct, $1)=unsupported
++ # It fails to find uninstalled libraries when the uninstalled
++ # path is not listed in the libpath. Setting hardcode_minus_L
++ # to unsupported forces relinking
++ _LT_TAGVAR(hardcode_minus_L, $1)=yes
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=
++ fi
++ ;;
++ esac
++ shared_flag='-shared'
++ if test "$aix_use_runtimelinking" = yes; then
++ shared_flag="$shared_flag "'${wl}-G'
++ fi
++ else
++ # not using gcc
++ if test "$host_cpu" = ia64; then
++ # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
++ # chokes on -Wl,-G. The following line is correct:
++ shared_flag='-G'
++ else
++ if test "$aix_use_runtimelinking" = yes; then
++ shared_flag='${wl}-G'
++ else
++ shared_flag='${wl}-bM:SRE'
++ fi
++ fi
++ fi
+
+-# Compiler flag to prevent dynamic linking.
+-link_static_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_static, $1)
++ # It seems that -bexpall does not export symbols beginning with
++ # underscore (_), so it is better to generate a list of symbols to export.
++ _LT_TAGVAR(always_export_symbols, $1)=yes
++ if test "$aix_use_runtimelinking" = yes; then
++ # Warning - without using the other runtime loading flags (-brtl),
++ # -berok will link without error, but may produce a broken library.
++ _LT_TAGVAR(allow_undefined_flag, $1)='-berok'
++ # Determine the default libpath from the value encoded in an
++ # empty executable.
++ _LT_SYS_MODULE_PATH_AIX
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
++ else
++ if test "$host_cpu" = ia64; then
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
++ _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
++ _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
++ else
++ # Determine the default libpath from the value encoded in an
++ # empty executable.
++ _LT_SYS_MODULE_PATH_AIX
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
++ # Warning - without using the other run time loading flags,
++ # -berok will link without error, but may produce a broken library.
++ _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
++ _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
++ # Exported symbols can be pulled into shared objects from archives
++ _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
++ _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
++ # This is similar to how AIX traditionally builds its shared libraries.
++ _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
++ fi
++ fi
++ ;;
+
+-# Compiler flag to turn off builtin functions.
+-no_builtin_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)
++ amigaos*)
++ case $host_cpu in
++ powerpc)
++ # see comment about AmigaOS4 .so support
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)=''
++ ;;
++ m68k)
++ _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
++ _LT_TAGVAR(hardcode_minus_L, $1)=yes
++ ;;
++ esac
++ ;;
+
+-# Compiler flag to allow reflexive dlopens.
+-export_dynamic_flag_spec=$lt_[]_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)
++ bsdi[[45]]*)
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic
++ ;;
+
+-# Compiler flag to generate shared objects directly from archives.
+-whole_archive_flag_spec=$lt_[]_LT_AC_TAGVAR(whole_archive_flag_spec, $1)
++ cygwin* | mingw* | pw32*)
++ # When not using gcc, we currently assume that we are using
++ # Microsoft Visual C++.
++ # hardcode_libdir_flag_spec is actually meaningless, as there is
++ # no search path for DLLs.
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' '
++ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
++ # Tell ltmain to make .lib files, not .a files.
++ libext=lib
++ # Tell ltmain to make .dll files, not .so files.
++ shrext_cmds=".dll"
++ # FIXME: Setting linknames here is a bad hack.
++ _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `$ECHO "X$deplibs" | $Xsed -e '\''s/ -lc$//'\''` -link -dll~linknames='
++ # The linker will automatically build a .lib file if we build a DLL.
++ _LT_TAGVAR(old_archive_from_new_cmds, $1)='true'
++ # FIXME: Should let the user specify the lib program.
++ _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs'
++ _LT_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`'
++ _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
++ ;;
+
+-# Compiler flag to generate thread-safe objects.
+-thread_safe_flag_spec=$lt_[]_LT_AC_TAGVAR(thread_safe_flag_spec, $1)
++ darwin* | rhapsody*)
++ _LT_DARWIN_LINKER_FEATURES($1)
++ ;;
+
+-# Library versioning type.
+-version_type=$version_type
++ dgux*)
++ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ ;;
+
+-# Format of library name prefix.
+-libname_spec=$lt_libname_spec
++ freebsd1*)
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
+
+-# List of archive names. First name is the real one, the rest are links.
+-# The last name is the one that the linker finds with -lNAME.
+-library_names_spec=$lt_library_names_spec
++ # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
++ # support. Future versions do this automatically, but an explicit c++rt0.o
++ # does not break anything, and helps significantly (at the cost of a little
++ # extra space).
++ freebsd2.2*)
++ _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ ;;
+
+-# The coded name of the library, if different from the real name.
+-soname_spec=$lt_soname_spec
++ # Unfortunately, older versions of FreeBSD 2 do not have this feature.
++ freebsd2*)
++ _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_minus_L, $1)=yes
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ ;;
+
+-# Commands used to build and install an old-style archive.
+-RANLIB=$lt_RANLIB
+-old_archive_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_cmds, $1)
+-old_postinstall_cmds=$lt_old_postinstall_cmds
+-old_postuninstall_cmds=$lt_old_postuninstall_cmds
++ # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
++ freebsd* | dragonfly*)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ ;;
+
+-# Create an old-style archive from a shared archive.
+-old_archive_from_new_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_from_new_cmds, $1)
++ hpux9*)
++ if test "$GCC" = yes; then
++ _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
++ else
++ _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
++ fi
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
++ _LT_TAGVAR(hardcode_direct, $1)=yes
+
+-# Create a temporary old-style archive to link instead of a shared archive.
+-old_archive_from_expsyms_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1)
++ # hardcode_minus_L: Not really in the search PATH,
++ # but as the default location of the library.
++ _LT_TAGVAR(hardcode_minus_L, $1)=yes
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
++ ;;
+
+-# Commands used to build and install a shared archive.
+-archive_cmds=$lt_[]_LT_AC_TAGVAR(archive_cmds, $1)
+-archive_expsym_cmds=$lt_[]_LT_AC_TAGVAR(archive_expsym_cmds, $1)
+-postinstall_cmds=$lt_postinstall_cmds
+-postuninstall_cmds=$lt_postuninstall_cmds
++ hpux10*)
++ if test "$GCC" = yes -a "$with_gnu_ld" = no; then
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
++ else
++ _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
++ fi
++ if test "$with_gnu_ld" = no; then
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
++ _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
++ # hardcode_minus_L: Not really in the search PATH,
++ # but as the default location of the library.
++ _LT_TAGVAR(hardcode_minus_L, $1)=yes
++ fi
++ ;;
+
+-# Commands used to build a loadable module (assumed same as above if empty)
+-module_cmds=$lt_[]_LT_AC_TAGVAR(module_cmds, $1)
+-module_expsym_cmds=$lt_[]_LT_AC_TAGVAR(module_expsym_cmds, $1)
++ hpux11*)
++ if test "$GCC" = yes -a "$with_gnu_ld" = no; then
++ case $host_cpu in
++ hppa*64*)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
++ ;;
++ ia64*)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
++ ;;
++ *)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
++ ;;
++ esac
++ else
++ case $host_cpu in
++ hppa*64*)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
++ ;;
++ ia64*)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
++ ;;
++ *)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
++ ;;
++ esac
++ fi
++ if test "$with_gnu_ld" = no; then
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+-# Commands to strip libraries.
+-old_striplib=$lt_old_striplib
+-striplib=$lt_striplib
++ case $host_cpu in
++ hppa*64*|ia64*)
++ _LT_TAGVAR(hardcode_direct, $1)=no
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ ;;
++ *)
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+
+-# Dependencies to place before the objects being linked to create a
+-# shared library.
+-predep_objects=$lt_[]_LT_AC_TAGVAR(predep_objects, $1)
++ # hardcode_minus_L: Not really in the search PATH,
++ # but as the default location of the library.
++ _LT_TAGVAR(hardcode_minus_L, $1)=yes
++ ;;
++ esac
++ fi
++ ;;
+
+-# Dependencies to place after the objects being linked to create a
+-# shared library.
+-postdep_objects=$lt_[]_LT_AC_TAGVAR(postdep_objects, $1)
++ irix5* | irix6* | nonstopux*)
++ if test "$GCC" = yes; then
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
++ # Try to use the -exported_symbol ld option, if it does not
++ # work, assume that -exports_file does not work either and
++ # implicitly export all symbols.
++ save_LDFLAGS="$LDFLAGS"
++ LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null"
++ AC_LINK_IFELSE(int foo(void) {},
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib'
++ )
++ LDFLAGS="$save_LDFLAGS"
++ else
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib'
++ fi
++ _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
++ _LT_TAGVAR(inherit_rpath, $1)=yes
++ _LT_TAGVAR(link_all_deplibs, $1)=yes
++ ;;
+
+-# Dependencies to place before the objects being linked to create a
+-# shared library.
+-predeps=$lt_[]_LT_AC_TAGVAR(predeps, $1)
++ netbsd*)
++ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
++ _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out
++ else
++ _LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF
++ fi
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ ;;
+
+-# Dependencies to place after the objects being linked to create a
+-# shared library.
+-postdeps=$lt_[]_LT_AC_TAGVAR(postdeps, $1)
++ newsos6)
++ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ ;;
+
+-# The library search path used internally by the compiler when linking
+-# a shared library.
+-compiler_lib_search_path=$lt_[]_LT_AC_TAGVAR(compiler_lib_search_path, $1)
++ *nto* | *qnx*)
++ ;;
+
+-# Method to check whether dependent libraries are shared objects.
+-deplibs_check_method=$lt_deplibs_check_method
++ openbsd*)
++ if test -f /usr/libexec/ld.so; then
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
++ if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
++ else
++ case $host_os in
++ openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*)
++ _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
++ ;;
++ *)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
++ ;;
++ esac
++ fi
++ else
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ fi
++ ;;
+
+-# Command to use when deplibs_check_method == file_magic.
+-file_magic_cmd=$lt_file_magic_cmd
++ os2*)
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
++ _LT_TAGVAR(hardcode_minus_L, $1)=yes
++ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
++ _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$ECHO DATA >> $output_objdir/$libname.def~$ECHO " SINGLE NONSHARED" >> $output_objdir/$libname.def~$ECHO EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
++ _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
++ ;;
+
+-# Flag that allows shared libraries with undefined symbols to be built.
+-allow_undefined_flag=$lt_[]_LT_AC_TAGVAR(allow_undefined_flag, $1)
++ osf3*)
++ if test "$GCC" = yes; then
++ _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
++ else
++ _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
++ fi
++ _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
++ ;;
+
+-# Flag that forces no undefined symbols.
+-no_undefined_flag=$lt_[]_LT_AC_TAGVAR(no_undefined_flag, $1)
++ osf4* | osf5*) # as osf3* with the addition of -msym flag
++ if test "$GCC" = yes; then
++ _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
++ else
++ _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~
++ $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp'
+
+-# Commands used to finish a libtool library installation in a directory.
+-finish_cmds=$lt_finish_cmds
++ # Both c and cxx compiler support -rpath directly
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
++ fi
++ _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
++ ;;
+
+-# Same as above, but a single script fragment to be evaled but not shown.
+-finish_eval=$lt_finish_eval
++ solaris*)
++ _LT_TAGVAR(no_undefined_flag, $1)=' -z defs'
++ if test "$GCC" = yes; then
++ wlarc='${wl}'
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
++ $CC -shared ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
++ else
++ case `$CC -V 2>&1` in
++ *"Compilers 5.0"*)
++ wlarc=''
++ _LT_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
++ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
++ ;;
++ *)
++ wlarc='${wl}'
++ _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
++ $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
++ ;;
++ esac
++ fi
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ case $host_os in
++ solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
++ *)
++ # The compiler driver will combine and reorder linker options,
++ # but understands `-z linker_flag'. GCC discards it without `$wl',
++ # but is careful enough not to reorder.
++ # Supported since Solaris 2.6 (maybe 2.5.1?)
++ if test "$GCC" = yes; then
++ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
++ else
++ _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
++ fi
++ ;;
++ esac
++ _LT_TAGVAR(link_all_deplibs, $1)=yes
++ ;;
+
+-# Take the output of nm and produce a listing of raw symbols and C names.
+-global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
++ sunos4*)
++ if test "x$host_vendor" = xsequent; then
++ # Use $CC to link under sequent, because it throws in some extra .o
++ # files that make .init and .fini sections work.
++ _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
++ else
++ _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
++ fi
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_minus_L, $1)=yes
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ ;;
+
+-# Transform the output of nm in a proper C declaration
+-global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
++ sysv4)
++ case $host_vendor in
++ sni)
++ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
++ _LT_TAGVAR(hardcode_direct, $1)=yes # is this really true???
++ ;;
++ siemens)
++ ## LD is ld it makes a PLAMLIB
++ ## CC just makes a GrossModule.
++ _LT_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags'
++ _LT_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs'
++ _LT_TAGVAR(hardcode_direct, $1)=no
++ ;;
++ motorola)
++ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
++ _LT_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie
++ ;;
++ esac
++ runpath_var='LD_RUN_PATH'
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ ;;
+
+-# Transform the output of nm in a C name address pair
+-global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
++ sysv4.3*)
++ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport'
++ ;;
+
+-# This is the shared library runtime path variable.
+-runpath_var=$runpath_var
++ sysv4*MP*)
++ if test -d /usr/nec; then
++ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ runpath_var=LD_RUN_PATH
++ hardcode_runpath_var=yes
++ _LT_TAGVAR(ld_shlibs, $1)=yes
++ fi
++ ;;
+
+-# This is the shared library path variable.
+-shlibpath_var=$shlibpath_var
++ sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
++ _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
++ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ runpath_var='LD_RUN_PATH'
+
+-# Is shlibpath searched before the hard-coded library search path?
+-shlibpath_overrides_runpath=$shlibpath_overrides_runpath
++ if test "$GCC" = yes; then
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ else
++ _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ fi
++ ;;
+
+-# How to hardcode a shared library path into an executable.
+-hardcode_action=$_LT_AC_TAGVAR(hardcode_action, $1)
++ sysv5* | sco3.2v5* | sco5v6*)
++ # Note: We can NOT use -z defs as we might desire, because we do not
++ # link with -lc, and that would cause any symbols used from libc to
++ # always be unresolved, which means just about no library would
++ # ever link correctly. If we're not using GNU ld we use -z text
++ # though, which does catch some bad symbols but isn't as heavy-handed
++ # as -z defs.
++ _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
++ _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
++ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
++ _LT_TAGVAR(link_all_deplibs, $1)=yes
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
++ runpath_var='LD_RUN_PATH'
+
+-# Whether we should hardcode library paths into libraries.
+-hardcode_into_libs=$hardcode_into_libs
++ if test "$GCC" = yes; then
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ else
++ _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ fi
++ ;;
+
+-# Flag to hardcode \$libdir into a binary during linking.
+-# This must work even if \$libdir does not exist.
+-hardcode_libdir_flag_spec=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)
++ uts4*)
++ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ ;;
+
+-# If ld is used when linking, flag to hardcode \$libdir into
+-# a binary during linking. This must work even if \$libdir does
+-# not exist.
+-hardcode_libdir_flag_spec_ld=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)
++ *)
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++ esac
+
+-# Whether we need a single -rpath flag with a separated argument.
+-hardcode_libdir_separator=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_separator, $1)
++ if test x$host_vendor = xsni; then
++ case $host in
++ sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Blargedynsym'
++ ;;
++ esac
++ fi
++ fi
++])
++AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
++test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
+
+-# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the
+-# resulting binary.
+-hardcode_direct=$_LT_AC_TAGVAR(hardcode_direct, $1)
++_LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld
+
+-# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
+-# resulting binary.
+-hardcode_minus_L=$_LT_AC_TAGVAR(hardcode_minus_L, $1)
++_LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl
++_LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl
++_LT_DECL([], [extract_expsyms_cmds], [2],
++ [The commands to extract the exported symbol list from a shared archive])
+
+-# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
+-# the resulting binary.
+-hardcode_shlibpath_var=$_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)
++#
++# Do we need to explicitly link libc?
++#
++case "x$_LT_TAGVAR(archive_cmds_need_lc, $1)" in
++x|xyes)
++ # Assume -lc should be added
++ _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
+
+-# Set to yes if building a shared library automatically hardcodes DIR into the library
+-# and all subsequent libraries and executables linked against it.
+-hardcode_automatic=$_LT_AC_TAGVAR(hardcode_automatic, $1)
++ if test "$enable_shared" = yes && test "$GCC" = yes; then
++ case $_LT_TAGVAR(archive_cmds, $1) in
++ *'~'*)
++ # FIXME: we may have to deal with multi-command sequences.
++ ;;
++ '$CC '*)
++ # Test whether the compiler implicitly links with -lc since on some
++ # systems, -lgcc has to come before -lc. If gcc already passes -lc
++ # to ld, don't add -lc before -lgcc.
++ AC_MSG_CHECKING([whether -lc should be explicitly linked in])
++ $RM conftest*
++ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+-# Variables whose values should be saved in libtool wrapper scripts and
+-# restored at relink time.
+-variables_saved_for_relink="$variables_saved_for_relink"
++ if AC_TRY_EVAL(ac_compile) 2>conftest.err; then
++ soname=conftest
++ lib=conftest
++ libobjs=conftest.$ac_objext
++ deplibs=
++ wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1)
++ pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1)
++ compiler_flags=-v
++ linker_flags=-v
++ verstring=
++ output_objdir=.
++ libname=conftest
++ lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1)
++ _LT_TAGVAR(allow_undefined_flag, $1)=
++ if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1)
++ then
++ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
++ else
++ _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
++ fi
++ _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag
++ else
++ cat conftest.err 1>&5
++ fi
++ $RM conftest*
++ AC_MSG_RESULT([$_LT_TAGVAR(archive_cmds_need_lc, $1)])
++ ;;
++ esac
++ fi
++ ;;
++esac
+
+-# Whether libtool must link a program against all its dependency libraries.
+-link_all_deplibs=$_LT_AC_TAGVAR(link_all_deplibs, $1)
++_LT_TAGDECL([build_libtool_need_lc], [archive_cmds_need_lc], [0],
++ [Whether or not to add -lc for building shared libraries])
++_LT_TAGDECL([allow_libtool_libs_with_static_runtimes],
++ [enable_shared_with_static_runtimes], [0],
++ [Whether or not to disallow shared libs when runtime libs are static])
++_LT_TAGDECL([], [export_dynamic_flag_spec], [1],
++ [Compiler flag to allow reflexive dlopens])
++_LT_TAGDECL([], [whole_archive_flag_spec], [1],
++ [Compiler flag to generate shared objects directly from archives])
++_LT_TAGDECL([], [compiler_needs_object], [1],
++ [Whether the compiler copes with passing no objects directly])
++_LT_TAGDECL([], [old_archive_from_new_cmds], [2],
++ [Create an old-style archive from a shared archive])
++_LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2],
++ [Create a temporary old-style archive to link instead of a shared archive])
++_LT_TAGDECL([], [archive_cmds], [2], [Commands used to build a shared archive])
++_LT_TAGDECL([], [archive_expsym_cmds], [2])
++_LT_TAGDECL([], [module_cmds], [2],
++ [Commands used to build a loadable module if different from building
++ a shared archive.])
++_LT_TAGDECL([], [module_expsym_cmds], [2])
++_LT_TAGDECL([], [with_gnu_ld], [1],
++ [Whether we are building with GNU ld or not])
++_LT_TAGDECL([], [allow_undefined_flag], [1],
++ [Flag that allows shared libraries with undefined symbols to be built])
++_LT_TAGDECL([], [no_undefined_flag], [1],
++ [Flag that enforces no undefined symbols])
++_LT_TAGDECL([], [hardcode_libdir_flag_spec], [1],
++ [Flag to hardcode $libdir into a binary during linking.
++ This must work even if $libdir does not exist])
++_LT_TAGDECL([], [hardcode_libdir_flag_spec_ld], [1],
++ [[If ld is used when linking, flag to hardcode $libdir into a binary
++ during linking. This must work even if $libdir does not exist]])
++_LT_TAGDECL([], [hardcode_libdir_separator], [1],
++ [Whether we need a single "-rpath" flag with a separated argument])
++_LT_TAGDECL([], [hardcode_direct], [0],
++ [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes
++ DIR into the resulting binary])
++_LT_TAGDECL([], [hardcode_direct_absolute], [0],
++ [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes
++ DIR into the resulting binary and the resulting library dependency is
++ "absolute", i.e impossible to change by setting ${shlibpath_var} if the
++ library is relocated])
++_LT_TAGDECL([], [hardcode_minus_L], [0],
++ [Set to "yes" if using the -LDIR flag during linking hardcodes DIR
++ into the resulting binary])
++_LT_TAGDECL([], [hardcode_shlibpath_var], [0],
++ [Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR
++ into the resulting binary])
++_LT_TAGDECL([], [hardcode_automatic], [0],
++ [Set to "yes" if building a shared library automatically hardcodes DIR
++ into the library and all subsequent libraries and executables linked
++ against it])
++_LT_TAGDECL([], [inherit_rpath], [0],
++ [Set to yes if linker adds runtime paths of dependent libraries
++ to runtime path list])
++_LT_TAGDECL([], [link_all_deplibs], [0],
++ [Whether libtool must link a program against all its dependency libraries])
++_LT_TAGDECL([], [fix_srcfile_path], [1],
++ [Fix the shell variable $srcfile for the compiler])
++_LT_TAGDECL([], [always_export_symbols], [0],
++ [Set to "yes" if exported symbols are required])
++_LT_TAGDECL([], [export_symbols_cmds], [2],
++ [The commands to list exported symbols])
++_LT_TAGDECL([], [exclude_expsyms], [1],
++ [Symbols that should not be listed in the preloaded symbols])
++_LT_TAGDECL([], [include_expsyms], [1],
++ [Symbols that must always be exported])
++_LT_TAGDECL([], [prelink_cmds], [2],
++ [Commands necessary for linking programs (against libraries) with templates])
++_LT_TAGDECL([], [file_list_spec], [1],
++ [Specify filename containing input files])
++dnl FIXME: Not yet implemented
++dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1],
++dnl [Compiler flag to generate thread safe objects])
++])# _LT_LINKER_SHLIBS
+
+-# Compile-time system search path for libraries
+-sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
+
+-# Run-time system search path for libraries
+-sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
++# _LT_LANG_C_CONFIG([TAG])
++# ------------------------
++# Ensure that the configuration variables for a C compiler are suitably
++# defined. These variables are subsequently used by _LT_CONFIG to write
++# the compiler configuration to `libtool'.
++m4_defun([_LT_LANG_C_CONFIG],
++[m4_require([_LT_DECL_EGREP])dnl
++lt_save_CC="$CC"
++AC_LANG_PUSH(C)
+
+-# Fix the shell variable \$srcfile for the compiler.
+-fix_srcfile_path="$_LT_AC_TAGVAR(fix_srcfile_path, $1)"
++# Source file extension for C test sources.
++ac_ext=c
+
+-# Set to yes if exported symbols are required.
+-always_export_symbols=$_LT_AC_TAGVAR(always_export_symbols, $1)
++# Object file extension for compiled C test sources.
++objext=o
++_LT_TAGVAR(objext, $1)=$objext
+
+-# The commands to list exported symbols.
+-export_symbols_cmds=$lt_[]_LT_AC_TAGVAR(export_symbols_cmds, $1)
++# Code to be used in simple compile tests
++lt_simple_compile_test_code="int some_variable = 0;"
+
+-# The commands to extract the exported symbol list from a shared archive.
+-extract_expsyms_cmds=$lt_extract_expsyms_cmds
++# Code to be used in simple link tests
++lt_simple_link_test_code='int main(){return(0);}'
+
+-# Symbols that should not be listed in the preloaded symbols.
+-exclude_expsyms=$lt_[]_LT_AC_TAGVAR(exclude_expsyms, $1)
++_LT_TAG_COMPILER
++# Save the default compiler, since it gets overwritten when the other
++# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP.
++compiler_DEFAULT=$CC
+
+-# Symbols that must always be exported.
+-include_expsyms=$lt_[]_LT_AC_TAGVAR(include_expsyms, $1)
++# save warnings/boilerplate of simple test code
++_LT_COMPILER_BOILERPLATE
++_LT_LINKER_BOILERPLATE
+
+-ifelse([$1],[],
+-[# ### END LIBTOOL CONFIG],
+-[# ### END LIBTOOL TAG CONFIG: $tagname])
++## CAVEAT EMPTOR:
++## There is no encapsulation within the following macros, do not change
++## the running order or otherwise move them around unless you know exactly
++## what you are doing...
++if test -n "$compiler"; then
++ _LT_COMPILER_NO_RTTI($1)
++ _LT_COMPILER_PIC($1)
++ _LT_COMPILER_C_O($1)
++ _LT_COMPILER_FILE_LOCKS($1)
++ _LT_LINKER_SHLIBS($1)
++ _LT_SYS_DYNAMIC_LINKER($1)
++ _LT_LINKER_HARDCODE_LIBPATH($1)
++ LT_SYS_DLOPEN_SELF
++ _LT_CMD_STRIPLIB
++
++ # Report which library types will actually be built
++ AC_MSG_CHECKING([if libtool supports shared libraries])
++ AC_MSG_RESULT([$can_build_shared])
+
+-__EOF__
++ AC_MSG_CHECKING([whether to build shared libraries])
++ test "$can_build_shared" = "no" && enable_shared=no
+
+-ifelse([$1],[], [
++ # On AIX, shared libraries and static libraries use the same namespace, and
++ # are all built from PIC.
+ case $host_os in
+ aix3*)
+- cat <<\EOF >> "$cfgfile"
++ test "$enable_shared" = yes && enable_static=no
++ if test -n "$RANLIB"; then
++ archive_cmds="$archive_cmds~\$RANLIB \$lib"
++ postinstall_cmds='$RANLIB $lib'
++ fi
++ ;;
+
+-# AIX sometimes has problems with the GCC collect2 program. For some
+-# reason, if we set the COLLECT_NAMES environment variable, the problems
+-# vanish in a puff of smoke.
+-if test "X${COLLECT_NAMES+set}" != Xset; then
+- COLLECT_NAMES=
+- export COLLECT_NAMES
+-fi
+-EOF
++ aix[[4-9]]*)
++ if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
++ test "$enable_shared" = yes && enable_static=no
++ fi
+ ;;
+ esac
++ AC_MSG_RESULT([$enable_shared])
+
+- # We use sed instead of cat because bash on DJGPP gets confused if
+- # if finds mixed CR/LF and LF-only lines. Since sed operates in
+- # text mode, it properly converts lines to CR/LF. This bash problem
+- # is reportedly fixed, but why not run on old versions too?
+- sed '$q' "$ltmain" >> "$cfgfile" || (rm -f "$cfgfile"; exit 1)
++ AC_MSG_CHECKING([whether to build static libraries])
++ # Make sure either enable_shared or enable_static is yes.
++ test "$enable_shared" = yes || enable_static=yes
++ AC_MSG_RESULT([$enable_static])
+
+- mv -f "$cfgfile" "$ofile" || \
+- (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
+- chmod +x "$ofile"
+-])
+-else
+- # If there is no Makefile yet, we rely on a make rule to execute
+- # `config.status --recheck' to rerun these tests and create the
+- # libtool script then.
+- ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'`
+- if test -f "$ltmain_in"; then
+- test -f Makefile && make "$ltmain"
+- fi
++ _LT_CONFIG($1)
+ fi
+-])# AC_LIBTOOL_CONFIG
+-
+-
+-# AC_LIBTOOL_PROG_COMPILER_NO_RTTI([TAGNAME])
+-# -------------------------------------------
+-AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI],
+-[AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl
+-
+-_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
++AC_LANG_POP
++CC="$lt_save_CC"
++])# _LT_LANG_C_CONFIG
+
+-if test "$GCC" = yes; then
+- _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
+
+- AC_LIBTOOL_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions],
+- lt_cv_prog_compiler_rtti_exceptions,
+- [-fno-rtti -fno-exceptions], [],
+- [_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"])
++# _LT_PROG_CXX
++# ------------
++# Since AC_PROG_CXX is broken, in that it returns g++ if there is no c++
++# compiler, we have our own version here.
++m4_defun([_LT_PROG_CXX],
++[
++pushdef([AC_MSG_ERROR], [_lt_caught_CXX_error=yes])
++AC_PROG_CXX
++if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
++ ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
++ (test "X$CXX" != "Xg++"))) ; then
++ AC_PROG_CXXCPP
++else
++ _lt_caught_CXX_error=yes
+ fi
+-])# AC_LIBTOOL_PROG_COMPILER_NO_RTTI
++popdef([AC_MSG_ERROR])
++])# _LT_PROG_CXX
+
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([_LT_PROG_CXX], [])
+
+-# AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE
+-# ---------------------------------
+-AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE],
+-[AC_REQUIRE([AC_CANONICAL_HOST])
+-AC_REQUIRE([AC_PROG_NM])
+-AC_REQUIRE([AC_OBJEXT])
+-# Check for command to grab the raw symbol name followed by C symbol from nm.
+-AC_MSG_CHECKING([command to parse $NM output from $compiler object])
+-AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe],
+-[
+-# These are sane defaults that work on at least a few old systems.
+-# [They come from Ultrix. What could be older than Ultrix?!! ;)]
+-
+-# Character class describing NM global symbol codes.
+-symcode='[[BCDEGRST]]'
+
+-# Regexp to match symbols that can be accessed directly from C.
+-sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)'
++# _LT_LANG_CXX_CONFIG([TAG])
++# --------------------------
++# Ensure that the configuration variables for a C++ compiler are suitably
++# defined. These variables are subsequently used by _LT_CONFIG to write
++# the compiler configuration to `libtool'.
++m4_defun([_LT_LANG_CXX_CONFIG],
++[AC_REQUIRE([_LT_PROG_CXX])dnl
++m4_require([_LT_FILEUTILS_DEFAULTS])dnl
++m4_require([_LT_DECL_EGREP])dnl
++
++AC_LANG_PUSH(C++)
++_LT_TAGVAR(archive_cmds_need_lc, $1)=no
++_LT_TAGVAR(allow_undefined_flag, $1)=
++_LT_TAGVAR(always_export_symbols, $1)=no
++_LT_TAGVAR(archive_expsym_cmds, $1)=
++_LT_TAGVAR(compiler_needs_object, $1)=no
++_LT_TAGVAR(export_dynamic_flag_spec, $1)=
++_LT_TAGVAR(hardcode_direct, $1)=no
++_LT_TAGVAR(hardcode_direct_absolute, $1)=no
++_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
++_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
++_LT_TAGVAR(hardcode_libdir_separator, $1)=
++_LT_TAGVAR(hardcode_minus_L, $1)=no
++_LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
++_LT_TAGVAR(hardcode_automatic, $1)=no
++_LT_TAGVAR(inherit_rpath, $1)=no
++_LT_TAGVAR(module_cmds, $1)=
++_LT_TAGVAR(module_expsym_cmds, $1)=
++_LT_TAGVAR(link_all_deplibs, $1)=unknown
++_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
++_LT_TAGVAR(no_undefined_flag, $1)=
++_LT_TAGVAR(whole_archive_flag_spec, $1)=
++_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+
+-# Transform an extracted symbol line into a proper C declaration
+-lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern int \1;/p'"
++# Source file extension for C++ test sources.
++ac_ext=cpp
+
+-# Transform an extracted symbol line into symbol name and symbol address
+-lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'"
++# Object file extension for compiled C++ test sources.
++objext=o
++_LT_TAGVAR(objext, $1)=$objext
+
+-# Define system-specific variables.
+-case $host_os in
+-aix*)
+- symcode='[[BCDT]]'
+- ;;
+-cygwin* | mingw* | pw32*)
+- symcode='[[ABCDGISTW]]'
+- ;;
+-hpux*) # Its linker distinguishes data from code symbols
+- if test "$host_cpu" = ia64; then
+- symcode='[[ABCDEGRST]]'
++# No sense in running all these tests if we already determined that
++# the CXX compiler isn't working. Some variables (like enable_shared)
++# are currently assumed to apply to all compilers on this platform,
++# and will be corrupted by setting them based on a non-working compiler.
++if test "$_lt_caught_CXX_error" != yes; then
++ # Code to be used in simple compile tests
++ lt_simple_compile_test_code="int some_variable = 0;"
++
++ # Code to be used in simple link tests
++ lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }'
++
++ # ltmain only uses $CC for tagged configurations so make sure $CC is set.
++ _LT_TAG_COMPILER
++
++ # save warnings/boilerplate of simple test code
++ _LT_COMPILER_BOILERPLATE
++ _LT_LINKER_BOILERPLATE
++
++ # Allow CC to be a program name with arguments.
++ lt_save_CC=$CC
++ lt_save_LD=$LD
++ lt_save_GCC=$GCC
++ GCC=$GXX
++ lt_save_with_gnu_ld=$with_gnu_ld
++ lt_save_path_LD=$lt_cv_path_LD
++ if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then
++ lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx
++ else
++ $as_unset lt_cv_prog_gnu_ld
+ fi
+- lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
+- lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'"
+- ;;
+-linux*)
+- if test "$host_cpu" = ia64; then
+- symcode='[[ABCDGIRSTW]]'
+- lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
+- lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'"
++ if test -n "${lt_cv_path_LDCXX+set}"; then
++ lt_cv_path_LD=$lt_cv_path_LDCXX
++ else
++ $as_unset lt_cv_path_LD
+ fi
+- ;;
+-irix* | nonstopux*)
+- symcode='[[BCDEGRST]]'
+- ;;
+-osf*)
+- symcode='[[BCDEGQRST]]'
+- ;;
+-solaris*)
+- symcode='[[BDRT]]'
+- ;;
+-sco3.2v5*)
+- symcode='[[DT]]'
+- ;;
+-sysv4.2uw2*)
+- symcode='[[DT]]'
+- ;;
+-sysv5* | sco5v6* | unixware* | OpenUNIX*)
+- symcode='[[ABDT]]'
+- ;;
+-sysv4)
+- symcode='[[DFNSTU]]'
+- ;;
+-esac
+-
+-# Handle CRLF in mingw tool chain
+-opt_cr=
+-case $build_os in
+-mingw*)
+- opt_cr=`echo 'x\{0,1\}' | tr x '\015'` # option cr in regexp
+- ;;
+-esac
+-
+-# If we're using GNU nm, then use its standard symbol codes.
+-case `$NM -V 2>&1` in
+-*GNU* | *'with BFD'*)
+- symcode='[[ABCDGIRSTW]]' ;;
+-esac
+-
+-# Try without a prefix undercore, then with it.
+-for ac_symprfx in "" "_"; do
+-
+- # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
+- symxfrm="\\1 $ac_symprfx\\2 \\2"
+-
+- # Write the raw and C identifiers.
+- lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
+-
+- # Check to see that the pipe works correctly.
+- pipe_works=no
+-
+- rm -f conftest*
+- cat > conftest.$ac_ext <<EOF
+-#ifdef __cplusplus
+-extern "C" {
+-#endif
+-char nm_test_var;
+-void nm_test_func(){}
+-#ifdef __cplusplus
+-}
+-#endif
+-int main(){nm_test_var='a';nm_test_func();return(0);}
+-EOF
+-
+- if AC_TRY_EVAL(ac_compile); then
+- # Now try to grab the symbols.
+- nlist=conftest.nm
+- if AC_TRY_EVAL(NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) && test -s "$nlist"; then
+- # Try sorting and uniquifying the output.
+- if sort "$nlist" | uniq > "$nlist"T; then
+- mv -f "$nlist"T "$nlist"
+- else
+- rm -f "$nlist"T
+- fi
+-
+- # Make sure that we snagged all the symbols we need.
+- if grep ' nm_test_var$' "$nlist" >/dev/null; then
+- if grep ' nm_test_func$' "$nlist" >/dev/null; then
+- cat <<EOF > conftest.$ac_ext
+-#ifdef __cplusplus
+-extern "C" {
+-#endif
+-
+-EOF
+- # Now generate the symbol file.
+- eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | grep -v main >> conftest.$ac_ext'
+-
+- cat <<EOF >> conftest.$ac_ext
+-#if defined (__STDC__) && __STDC__
+-# define lt_ptr_t void *
+-#else
+-# define lt_ptr_t char *
+-# define const
+-#endif
+-
+-/* The mapping between symbol names and symbols. */
+-const struct {
+- const char *name;
+- lt_ptr_t address;
+-}
+-lt_preloaded_symbols[[]] =
+-{
+-EOF
+- $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (lt_ptr_t) \&\2},/" < "$nlist" | grep -v main >> conftest.$ac_ext
+- cat <<\EOF >> conftest.$ac_ext
+- {0, (lt_ptr_t) 0}
+-};
++ test -z "${LDCXX+set}" || LD=$LDCXX
++ CC=${CXX-"c++"}
++ compiler=$CC
++ _LT_TAGVAR(compiler, $1)=$CC
++ _LT_CC_BASENAME([$compiler])
+
+-#ifdef __cplusplus
+-}
+-#endif
+-EOF
+- # Now try linking the two files.
+- mv conftest.$ac_objext conftstm.$ac_objext
+- lt_save_LIBS="$LIBS"
+- lt_save_CFLAGS="$CFLAGS"
+- LIBS="conftstm.$ac_objext"
+- CFLAGS="$CFLAGS$_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)"
+- if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then
+- pipe_works=yes
+- fi
+- LIBS="$lt_save_LIBS"
+- CFLAGS="$lt_save_CFLAGS"
+- else
+- echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD
+- fi
+- else
+- echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD
+- fi
++ if test -n "$compiler"; then
++ # We don't want -fno-exception when compiling C++ code, so set the
++ # no_builtin_flag separately
++ if test "$GXX" = yes; then
++ _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
+ else
+- echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD
++ _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
+ fi
+- else
+- echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD
+- cat conftest.$ac_ext >&5
+- fi
+- rm -f conftest* conftst*
+-
+- # Do not use the global_symbol_pipe unless it works.
+- if test "$pipe_works" = yes; then
+- break
+- else
+- lt_cv_sys_global_symbol_pipe=
+- fi
+-done
+-])
+-if test -z "$lt_cv_sys_global_symbol_pipe"; then
+- lt_cv_sys_global_symbol_to_cdecl=
+-fi
+-if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
+- AC_MSG_RESULT(failed)
+-else
+- AC_MSG_RESULT(ok)
+-fi
+-]) # AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE
+
++ if test "$GXX" = yes; then
++ # Set up default GNU C++ configuration
+
+-# AC_LIBTOOL_PROG_COMPILER_PIC([TAGNAME])
+-# ---------------------------------------
+-AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC],
+-[_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)=
+-_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
+-_LT_AC_TAGVAR(lt_prog_compiler_static, $1)=
++ LT_PATH_LD
+
+-AC_MSG_CHECKING([for $compiler option to produce PIC])
+- ifelse([$1],[CXX],[
+- # C++ specific cases for pic, static, wl, etc.
+- if test "$GXX" = yes; then
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
++ # Check if GNU C++ uses GNU ld as the underlying linker, since the
++ # archiving commands below assume that GNU ld is being used.
++ if test "$with_gnu_ld" = yes; then
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
++
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
++
++ # If archive_cmds runs LD, not CC, wlarc should be empty
++ # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
++ # investigate it a little bit more. (MM)
++ wlarc='${wl}'
++
++ # ancient GNU ld didn't support --whole-archive et. al.
++ if eval "`$CC -print-prog-name=ld` --help 2>&1" |
++ $GREP 'no-whole-archive' > /dev/null; then
++ _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
++ else
++ _LT_TAGVAR(whole_archive_flag_spec, $1)=
++ fi
++ else
++ with_gnu_ld=no
++ wlarc=
+
+- case $host_os in
+- aix*)
+- # All AIX code is PIC.
+- if test "$host_cpu" = ia64; then
+- # AIX 5 now supports IA64 processor
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- fi
+- ;;
+- amigaos*)
+- # FIXME: we need at least 68020 code to build shared libraries, but
+- # adding the `-m68020' flag to GCC prevents building anything better,
+- # like `-m68040'.
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
+- ;;
+- beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+- # PIC is the default for these OSes.
+- ;;
+- mingw* | cygwin* | os2* | pw32*)
+- # This hack is so that the source file can tell whether it is being
+- # built for inclusion in a dll (and should export symbols for example).
+- # Although the cygwin gcc ignores -fPIC, still need this for old-style
+- # (--disable-auto-import) libraries
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'
+- ;;
+- darwin* | rhapsody*)
+- # PIC is the default on this platform
+- # Common symbols not allowed in MH_DYLIB files
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
+- ;;
+- *djgpp*)
+- # DJGPP does not support shared libraries at all
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
+- ;;
+- interix3*)
+- # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+- # Instead, we relocate shared libraries at runtime.
+- ;;
+- sysv4*MP*)
+- if test -d /usr/nec; then
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
++ # A generic and very simple default shared library creation
++ # command for GNU C++ for the case where it uses the native
++ # linker, instead of GNU ld. If possible, this setting should
++ # overridden to take advantage of the native linker features on
++ # the platform it is being used on.
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+ fi
+- ;;
+- hpux*)
+- # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+- # not for PA HP-UX.
+- case $host_cpu in
+- hppa*64*|ia64*)
+- ;;
+- *)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+- ;;
+- esac
+- ;;
+- *)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+- ;;
+- esac
+- else
++
++ # Commands to make compiler produce verbose output that lists
++ # what "hidden" libraries, object files and flags are used when
++ # linking a shared library.
++ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
++
++ else
++ GXX=no
++ with_gnu_ld=no
++ wlarc=
++ fi
++
++ # PORTME: fill in a description of your system's C++ link characteristics
++ AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
++ _LT_TAGVAR(ld_shlibs, $1)=yes
+ case $host_os in
+- aix4* | aix5*)
+- # All AIX code is PIC.
+- if test "$host_cpu" = ia64; then
+- # AIX 5 now supports IA64 processor
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ aix3*)
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++ aix[[4-9]]*)
++ if test "$host_cpu" = ia64; then
++ # On IA64, the linker does run time linking by default, so we don't
++ # have to do anything special.
++ aix_use_runtimelinking=no
++ exp_sym_flag='-Bexport'
++ no_entry_flag=""
++ else
++ aix_use_runtimelinking=no
++
++ # Test if we are trying to use run time linking or normal
++ # AIX style linking. If -brtl is somewhere in LDFLAGS, we
++ # need to do runtime linking.
++ case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
++ for ld_flag in $LDFLAGS; do
++ case $ld_flag in
++ *-brtl*)
++ aix_use_runtimelinking=yes
++ break
++ ;;
++ esac
++ done
++ ;;
++ esac
++
++ exp_sym_flag='-bexport'
++ no_entry_flag='-bnoentry'
++ fi
++
++ # When large executables or shared objects are built, AIX ld can
++ # have problems creating the table of contents. If linking a library
++ # or program results in "error TOC overflow" add -mminimal-toc to
++ # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
++ # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
++
++ _LT_TAGVAR(archive_cmds, $1)=''
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
++ _LT_TAGVAR(link_all_deplibs, $1)=yes
++ _LT_TAGVAR(file_list_spec, $1)='${wl}-f,'
++
++ if test "$GXX" = yes; then
++ case $host_os in aix4.[[012]]|aix4.[[012]].*)
++ # We only want to do this on AIX 4.2 and lower, the check
++ # below for broken collect2 doesn't work under 4.3+
++ collect2name=`${CC} -print-prog-name=collect2`
++ if test -f "$collect2name" &&
++ strings "$collect2name" | $GREP resolve_lib_name >/dev/null
++ then
++ # We have reworked collect2
++ :
++ else
++ # We have old collect2
++ _LT_TAGVAR(hardcode_direct, $1)=unsupported
++ # It fails to find uninstalled libraries when the uninstalled
++ # path is not listed in the libpath. Setting hardcode_minus_L
++ # to unsupported forces relinking
++ _LT_TAGVAR(hardcode_minus_L, $1)=yes
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=
++ fi
++ esac
++ shared_flag='-shared'
++ if test "$aix_use_runtimelinking" = yes; then
++ shared_flag="$shared_flag "'${wl}-G'
++ fi
++ else
++ # not using gcc
++ if test "$host_cpu" = ia64; then
++ # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
++ # chokes on -Wl,-G. The following line is correct:
++ shared_flag='-G'
++ else
++ if test "$aix_use_runtimelinking" = yes; then
++ shared_flag='${wl}-G'
++ else
++ shared_flag='${wl}-bM:SRE'
++ fi
++ fi
++ fi
++
++ # It seems that -bexpall does not export symbols beginning with
++ # underscore (_), so it is better to generate a list of symbols to
++ # export.
++ _LT_TAGVAR(always_export_symbols, $1)=yes
++ if test "$aix_use_runtimelinking" = yes; then
++ # Warning - without using the other runtime loading flags (-brtl),
++ # -berok will link without error, but may produce a broken library.
++ _LT_TAGVAR(allow_undefined_flag, $1)='-berok'
++ # Determine the default libpath from the value encoded in an empty
++ # executable.
++ _LT_SYS_MODULE_PATH_AIX
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
++
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
++ else
++ if test "$host_cpu" = ia64; then
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
++ _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
++ _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
++ else
++ # Determine the default libpath from the value encoded in an
++ # empty executable.
++ _LT_SYS_MODULE_PATH_AIX
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
++ # Warning - without using the other run time loading flags,
++ # -berok will link without error, but may produce a broken library.
++ _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
++ _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
++ # Exported symbols can be pulled into shared objects from archives
++ _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
++ _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
++ # This is similar to how AIX traditionally builds its shared
++ # libraries.
++ _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
++ fi
++ fi
++ ;;
++
++ beos*)
++ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
++ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
++ # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
++ # support --undefined. This deserves some investigation. FIXME
++ _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ else
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
++ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
++
+ chorus*)
+- case $cc_basename in
+- cxch68*)
+- # Green Hills C++ Compiler
+- # _LT_AC_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a"
++ case $cc_basename in
++ *)
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+- esac
++ esac
++ ;;
++
++ cygwin* | mingw* | pw32*)
++ # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
++ # as there is no search path for DLLs.
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
++ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
++ _LT_TAGVAR(always_export_symbols, $1)=no
++ _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
++
++ if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
++ # If the export-symbols file already is a .def file (1st line
++ # is EXPORTS), use it as is; otherwise, prepend...
++ _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
++ cp $export_symbols $output_objdir/$soname.def;
++ else
++ echo EXPORTS > $output_objdir/$soname.def;
++ cat $export_symbols >> $output_objdir/$soname.def;
++ fi~
++ $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
++ else
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ fi
++ ;;
++ darwin* | rhapsody*)
++ _LT_DARWIN_LINKER_FEATURES($1)
+ ;;
+- darwin*)
+- # PIC is the default on this platform
+- # Common symbols not allowed in MH_DYLIB files
+- case $cc_basename in
+- xlc*)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-qnocommon'
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- ;;
+- esac
+- ;;
++
+ dgux*)
+- case $cc_basename in
+- ec++*)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ case $cc_basename in
++ ec++*)
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+- ghcx*)
++ ghcx*)
+ # Green Hills C++ Compiler
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+- *)
++ *)
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+- esac
+- ;;
+- freebsd* | kfreebsd*-gnu | dragonfly*)
+- # FreeBSD uses GNU C++
+- ;;
+- hpux9* | hpux10* | hpux11*)
+- case $cc_basename in
+- CC*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+- if test "$host_cpu" != ia64; then
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
+- fi
++ esac
++ ;;
++
++ freebsd[[12]]*)
++ # C++ shared libraries reported to be fairly broken before
++ # switch to ELF
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++
++ freebsd-elf*)
++ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
++ ;;
++
++ freebsd* | dragonfly*)
++ # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
++ # conventions
++ _LT_TAGVAR(ld_shlibs, $1)=yes
++ ;;
++
++ gnu*)
++ ;;
++
++ hpux9*)
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
++ # but as the default
++ # location of the library.
++
++ case $cc_basename in
++ CC*)
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++ aCC*)
++ _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
++ # Commands to make compiler produce verbose output that lists
++ # what "hidden" libraries, object files and flags are used when
++ # linking a shared library.
++ #
++ # There doesn't appear to be a way to prevent this compiler from
++ # explicitly linking system object files so we need to strip them
++ # from the output so that they don't get included in the library
++ # dependencies.
++ output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
++ ;;
++ *)
++ if test "$GXX" = yes; then
++ _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
++ else
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ fi
++ ;;
++ esac
++ ;;
++
++ hpux10*|hpux11*)
++ if test $with_gnu_ld = no; then
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
++
++ case $host_cpu in
++ hppa*64*|ia64*)
++ ;;
++ *)
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
++ ;;
++ esac
++ fi
++ case $host_cpu in
++ hppa*64*|ia64*)
++ _LT_TAGVAR(hardcode_direct, $1)=no
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ ;;
++ *)
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
++ _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
++ # but as the default
++ # location of the library.
++ ;;
++ esac
++
++ case $cc_basename in
++ CC*)
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+- aCC*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
++ aCC*)
+ case $host_cpu in
+- hppa*64*|ia64*)
+- # +Z the default
+- ;;
+- *)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
+- ;;
++ hppa*64*)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
++ ;;
++ ia64*)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
++ ;;
++ *)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
++ ;;
+ esac
++ # Commands to make compiler produce verbose output that lists
++ # what "hidden" libraries, object files and flags are used when
++ # linking a shared library.
++ #
++ # There doesn't appear to be a way to prevent this compiler from
++ # explicitly linking system object files so we need to strip them
++ # from the output so that they don't get included in the library
++ # dependencies.
++ output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
+ ;;
+- *)
++ *)
++ if test "$GXX" = yes; then
++ if test $with_gnu_ld = no; then
++ case $host_cpu in
++ hppa*64*)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
++ ;;
++ ia64*)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
++ ;;
++ *)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
++ ;;
++ esac
++ fi
++ else
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ fi
+ ;;
+- esac
+- ;;
+- interix*)
+- # This is c89, which is MS Visual C++ (no shared libs)
+- # Anyone wants to do a port?
+- ;;
+- irix5* | irix6* | nonstopux*)
+- case $cc_basename in
+- CC*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+- # CC pic flag -KPIC is the default.
++ esac
++ ;;
++
++ interix[[3-9]]*)
++ _LT_TAGVAR(hardcode_direct, $1)=no
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
++ # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
++ # Instead, shared libraries are loaded at an image base (0x10000000 by
++ # default) and relocated if they conflict, which is a slow very memory
++ # consuming and fragmenting process. To avoid this, we pick a random,
++ # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
++ # time. Moving up from 0x10000000 also allows more sbrk(2) space.
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
++ ;;
++ irix5* | irix6*)
++ case $cc_basename in
++ CC*)
++ # SGI C++
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
++
++ # Archives containing C++ object files must be created using
++ # "CC -ar", where "CC" is the IRIX C++ compiler. This is
++ # necessary to make sure instantiated templates are included
++ # in the archive.
++ _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs'
+ ;;
+- *)
++ *)
++ if test "$GXX" = yes; then
++ if test "$with_gnu_ld" = no; then
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
++ else
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` -o $lib'
++ fi
++ fi
++ _LT_TAGVAR(link_all_deplibs, $1)=yes
+ ;;
+- esac
+- ;;
+- linux*)
+- case $cc_basename in
+- KCC*)
+- # KAI C++ Compiler
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
++ esac
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
++ _LT_TAGVAR(inherit_rpath, $1)=yes
++ ;;
++
++ linux* | k*bsd*-gnu)
++ case $cc_basename in
++ KCC*)
++ # Kuck and Associates, Inc. (KAI) C++ Compiler
++
++ # KCC will only create a shared library if the output file
++ # ends with ".so" (or ".sl" for HP-UX), so rename the library
++ # to its proper name (with version) after linking.
++ _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib'
++ # Commands to make compiler produce verbose output that lists
++ # what "hidden" libraries, object files and flags are used when
++ # linking a shared library.
++ #
++ # There doesn't appear to be a way to prevent this compiler from
++ # explicitly linking system object files so we need to strip them
++ # from the output so that they don't get included in the library
++ # dependencies.
++ output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
++
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
++
++ # Archives containing C++ object files must be created using
++ # "CC -Bstatic", where "CC" is the KAI C++ compiler.
++ _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs'
+ ;;
+- icpc* | ecpc*)
++ icpc* | ecpc* )
+ # Intel C++
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
+- ;;
+- pgCC*)
+- # Portland Group C++ compiler.
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- ;;
+- cxx*)
+- # Compaq C++
+- # Make sure the PIC flag is empty. It appears that all Alpha
+- # Linux and Compaq Tru64 Unix objects are PIC.
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
++ with_gnu_ld=yes
++ # version 8.0 and above of icpc choke on multiply defined symbols
++ # if we add $predep_objects and $postdep_objects, however 7.1 and
++ # earlier do not add the objects themselves.
++ case `$CC -V 2>&1` in
++ *"Version 7."*)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
++ ;;
++ *) # Version 8.0 or newer
++ tmp_idyn=
++ case $host_cpu in
++ ia64*) tmp_idyn=' -i_dynamic';;
++ esac
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
++ ;;
++ esac
++ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
++ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+ ;;
+- *)
+- case `$CC -V 2>&1 | sed 5q` in
+- *Sun\ C*)
+- # Sun C++ 5.9
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
++ pgCC* | pgcpp*)
++ # Portland Group C++ compiler
++ case `$CC -V` in
++ *pgCC\ [[1-5]]* | *pgcpp\ [[1-5]]*)
++ _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~
++ rm -rf $tpldir~
++ $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~
++ compile_command="$compile_command `find $tpldir -name \*.o | $NL2SP`"'
++ _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~
++ rm -rf $tpldir~
++ $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~
++ $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | $NL2SP`~
++ $RANLIB $oldlib'
++ _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~
++ rm -rf $tpldir~
++ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
++ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~
++ rm -rf $tpldir~
++ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
++ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
++ ;;
++ *) # Version 6 will use weak symbols
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+ ;;
+ esac
+- ;;
+- esac
+- ;;
+- lynxos*)
+- ;;
+- m88k*)
+- ;;
+- mvs*)
+- case $cc_basename in
+- cxx*)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall'
+- ;;
+- *)
+- ;;
+- esac
+- ;;
+- netbsd*)
+- ;;
+- osf3* | osf4* | osf5*)
+- case $cc_basename in
+- KCC*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
+- ;;
+- RCC*)
+- # Rational C++ 2.4.1
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+- ;;
++
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
++ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
++ ;;
+ cxx*)
+- # Digital/Compaq C++
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- # Make sure the PIC flag is empty. It appears that all Alpha
+- # Linux and Compaq Tru64 Unix objects are PIC.
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+- ;;
+- *)
+- ;;
+- esac
+- ;;
+- psos*)
+- ;;
+- solaris*)
+- case $cc_basename in
+- CC*)
+- # Sun C++ 4.2, 5.x and Centerline C++
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
+- ;;
+- gcx*)
+- # Green Hills C++ Compiler
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
+- ;;
+- *)
+- ;;
+- esac
+- ;;
+- sunos4*)
+- case $cc_basename in
+- CC*)
+- # Sun C++ 4.x
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- ;;
+- lcc*)
+- # Lucid
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+- ;;
+- *)
++ # Compaq C++
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
++
++ runpath_var=LD_RUN_PATH
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
++
++ # Commands to make compiler produce verbose output that lists
++ # what "hidden" libraries, object files and flags are used when
++ # linking a shared library.
++ #
++ # There doesn't appear to be a way to prevent this compiler from
++ # explicitly linking system object files so we need to strip them
++ # from the output so that they don't get included in the library
++ # dependencies.
++ output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
+ ;;
+- esac
+- ;;
+- tandem*)
+- case $cc_basename in
+- NCC*)
+- # NonStop-UX NCC 3.20
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
++ xl*)
++ # IBM XL 8.0 on PPC, with GNU ld
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
++ _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
++ if test "x$supports_anon_versioning" = xyes; then
++ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
++ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
++ echo "local: *; };" >> $output_objdir/$libname.ver~
++ $CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
++ fi
+ ;;
+ *)
++ case `$CC -V 2>&1 | sed 5q` in
++ *Sun\ C*)
++ # Sun C++ 5.9
++ _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'
++ _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
++ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
++ _LT_TAGVAR(compiler_needs_object, $1)=yes
++
++ # Not sure whether something based on
++ # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1
++ # would be better.
++ output_verbose_link_cmd='echo'
++
++ # Archives containing C++ object files must be created using
++ # "CC -xar", where "CC" is the Sun C++ compiler. This is
++ # necessary to make sure instantiated templates are included
++ # in the archive.
++ _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
++ ;;
++ esac
+ ;;
+ esac
+ ;;
+- sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+- case $cc_basename in
+- CC*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++
++ lynxos*)
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++
++ m88k*)
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++
++ mvs*)
++ case $cc_basename in
++ cxx*)
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++ *)
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ esac
+ ;;
+- vxworks*)
++
++ netbsd*)
++ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
++ _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags'
++ wlarc=
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ fi
++ # Workaround some broken pre-1.5 toolchains
++ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"'
+ ;;
+- *)
+- _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
++
++ *nto* | *qnx*)
++ _LT_TAGVAR(ld_shlibs, $1)=yes
+ ;;
+- esac
+- fi
+-],
+-[
+- if test "$GCC" = yes; then
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
+
+- case $host_os in
+- aix*)
+- # All AIX code is PIC.
+- if test "$host_cpu" = ia64; then
+- # AIX 5 now supports IA64 processor
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- fi
+- ;;
++ openbsd2*)
++ # C++ shared libraries are fairly broken
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++
++ openbsd*)
++ if test -f /usr/libexec/ld.so; then
++ _LT_TAGVAR(hardcode_direct, $1)=yes
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
++ if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
++ _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
++ fi
++ output_verbose_link_cmd=echo
++ else
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ fi
++ ;;
+
+- amigaos*)
+- # FIXME: we need at least 68020 code to build shared libraries, but
+- # adding the `-m68020' flag to GCC prevents building anything better,
+- # like `-m68040'.
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
+- ;;
++ osf3* | osf4* | osf5*)
++ case $cc_basename in
++ KCC*)
++ # Kuck and Associates, Inc. (KAI) C++ Compiler
++
++ # KCC will only create a shared library if the output file
++ # ends with ".so" (or ".sl" for HP-UX), so rename the library
++ # to its proper name (with version) after linking.
++ _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
++
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
++
++ # Archives containing C++ object files must be created using
++ # the KAI C++ compiler.
++ case $host in
++ osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;;
++ *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;;
++ esac
++ ;;
++ RCC*)
++ # Rational C++ 2.4.1
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++ cxx*)
++ case $host in
++ osf3*)
++ _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && $ECHO "X${wl}-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
++ ;;
++ *)
++ _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
++ echo "-hidden">> $lib.exp~
++ $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~
++ $RM $lib.exp'
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
++ ;;
++ esac
+
+- beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+- # PIC is the default for these OSes.
+- ;;
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+- mingw* | cygwin* | pw32* | os2*)
+- # This hack is so that the source file can tell whether it is being
+- # built for inclusion in a dll (and should export symbols for example).
+- # Although the cygwin gcc ignores -fPIC, still need this for old-style
+- # (--disable-auto-import) libraries
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'
+- ;;
++ # Commands to make compiler produce verbose output that lists
++ # what "hidden" libraries, object files and flags are used when
++ # linking a shared library.
++ #
++ # There doesn't appear to be a way to prevent this compiler from
++ # explicitly linking system object files so we need to strip them
++ # from the output so that they don't get included in the library
++ # dependencies.
++ output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
++ ;;
++ *)
++ if test "$GXX" = yes && test "$with_gnu_ld" = no; then
++ _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
++ case $host in
++ osf3*)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
++ ;;
++ *)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
++ ;;
++ esac
++
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
++
++ # Commands to make compiler produce verbose output that lists
++ # what "hidden" libraries, object files and flags are used when
++ # linking a shared library.
++ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
++
++ else
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ fi
++ ;;
++ esac
++ ;;
+
+- darwin* | rhapsody*)
+- # PIC is the default on this platform
+- # Common symbols not allowed in MH_DYLIB files
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
+- ;;
++ psos*)
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
+
+- interix3*)
+- # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+- # Instead, we relocate shared libraries at runtime.
+- ;;
++ sunos4*)
++ case $cc_basename in
++ CC*)
++ # Sun C++ 4.x
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++ lcc*)
++ # Lucid
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++ *)
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++ esac
++ ;;
+
+- msdosdjgpp*)
+- # Just because we use GCC doesn't mean we suddenly get shared libraries
+- # on systems that don't support them.
+- _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+- enable_shared=no
+- ;;
++ solaris*)
++ case $cc_basename in
++ CC*)
++ # Sun C++ 4.2, 5.x and Centerline C++
++ _LT_TAGVAR(archive_cmds_need_lc,$1)=yes
++ _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'
++ _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
++ $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
++
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ case $host_os in
++ solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
++ *)
++ # The compiler driver will combine and reorder linker options,
++ # but understands `-z linker_flag'.
++ # Supported since Solaris 2.6 (maybe 2.5.1?)
++ _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
++ ;;
++ esac
++ _LT_TAGVAR(link_all_deplibs, $1)=yes
+
+- sysv4*MP*)
+- if test -d /usr/nec; then
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
+- fi
+- ;;
++ output_verbose_link_cmd='echo'
+
+- hpux*)
+- # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+- # not for PA HP-UX.
+- case $host_cpu in
+- hppa*64*|ia64*)
+- # +Z the default
+- ;;
+- *)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+- ;;
+- esac
+- ;;
++ # Archives containing C++ object files must be created using
++ # "CC -xar", where "CC" is the Sun C++ compiler. This is
++ # necessary to make sure instantiated templates are included
++ # in the archive.
++ _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
++ ;;
++ gcx*)
++ # Green Hills C++ Compiler
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+
+- *)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+- ;;
+- esac
+- else
+- # PORTME Check for flag to pass linker flags through the system compiler.
+- case $host_os in
+- aix*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- if test "$host_cpu" = ia64; then
+- # AIX 5 now supports IA64 processor
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- else
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
+- fi
+- ;;
+- darwin*)
+- # PIC is the default on this platform
+- # Common symbols not allowed in MH_DYLIB files
+- case $cc_basename in
+- xlc*)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-qnocommon'
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- ;;
+- esac
+- ;;
++ # The C++ compiler must be used to create the archive.
++ _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
++ ;;
++ *)
++ # GNU C++ compiler with Solaris linker
++ if test "$GXX" = yes && test "$with_gnu_ld" = no; then
++ _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs'
++ if $CC --version | $GREP -v '^2\.7' > /dev/null; then
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
++ $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
++
++ # Commands to make compiler produce verbose output that lists
++ # what "hidden" libraries, object files and flags are used when
++ # linking a shared library.
++ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
++ else
++ # g++ 2.7 appears to require `-G' NOT `-shared' on this
++ # platform.
++ _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
++ $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
++
++ # Commands to make compiler produce verbose output that lists
++ # what "hidden" libraries, object files and flags are used when
++ # linking a shared library.
++ output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
++ fi
++
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir'
++ case $host_os in
++ solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
++ *)
++ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
++ ;;
++ esac
++ fi
++ ;;
++ esac
++ ;;
+
+- mingw* | cygwin* | pw32* | os2*)
+- # This hack is so that the source file can tell whether it is being
+- # built for inclusion in a dll (and should export symbols for example).
+- # Although the cygwin gcc ignores -fPIC, still need this for old-style
+- # (--disable-auto-import) libraries
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'
+- ;;
++ sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
++ _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
++ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ runpath_var='LD_RUN_PATH'
+
+- hpux9* | hpux10* | hpux11*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+- # not for PA HP-UX.
+- case $host_cpu in
+- hppa*64*|ia64*)
+- # +Z the default
+- ;;
+- *)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
+- ;;
++ case $cc_basename in
++ CC*)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ ;;
++ *)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ ;;
+ esac
+- # Is there a better lt_prog_compiler_static that works with the bundled CC?
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+ ;;
+
+- irix5* | irix6* | nonstopux*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- # PIC (with -KPIC) is the default.
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+- ;;
++ sysv5* | sco3.2v5* | sco5v6*)
++ # Note: We can NOT use -z defs as we might desire, because we do not
++ # link with -lc, and that would cause any symbols used from libc to
++ # always be unresolved, which means just about no library would
++ # ever link correctly. If we're not using GNU ld we use -z text
++ # though, which does catch some bad symbols but isn't as heavy-handed
++ # as -z defs.
++ _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
++ _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
++ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
++ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
++ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir'
++ _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
++ _LT_TAGVAR(link_all_deplibs, $1)=yes
++ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
++ runpath_var='LD_RUN_PATH'
+
+- newsos6)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
++ case $cc_basename in
++ CC*)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ ;;
++ *)
++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
++ ;;
++ esac
+ ;;
+
+- linux*)
+- case $cc_basename in
+- icc* | ecc*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
+- ;;
+- pgcc* | pgf77* | pgf90* | pgf95*)
+- # Portland Group compilers (*not* the Pentium gcc compiler,
+- # which looks to be a dead project)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- ;;
+- ccc*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- # All Alpha code is PIC.
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
++ tandem*)
++ case $cc_basename in
++ NCC*)
++ # NonStop-UX NCC 3.20
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++ *)
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++ esac
+ ;;
+- como)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-lopt='
++
++ vxworks*)
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
++
+ *)
+- case `$CC -V 2>&1 | sed 5q` in
+- *Sun\ C*)
+- # Sun C 5.9
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- ;;
+- *Sun\ F*)
+- # Sun Fortran 8.3 passes all unrecognized flags to the linker
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)=''
+- ;;
+- esac
+- ;;
+- esac
+- ;;
++ # FIXME: insert proper C++ library support
++ _LT_TAGVAR(ld_shlibs, $1)=no
++ ;;
++ esac
+
+- osf3* | osf4* | osf5*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- # All OSF/1 code is PIC.
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+- ;;
++ AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
++ test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
+
+- solaris*)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- case $cc_basename in
+- f77* | f90* | f95*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';;
+- *)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';;
+- esac
+- ;;
++ _LT_TAGVAR(GCC, $1)="$GXX"
++ _LT_TAGVAR(LD, $1)="$LD"
++
++ ## CAVEAT EMPTOR:
++ ## There is no encapsulation within the following macros, do not change
++ ## the running order or otherwise move them around unless you know exactly
++ ## what you are doing...
++ _LT_SYS_HIDDEN_LIBDEPS($1)
++ _LT_COMPILER_PIC($1)
++ _LT_COMPILER_C_O($1)
++ _LT_COMPILER_FILE_LOCKS($1)
++ _LT_LINKER_SHLIBS($1)
++ _LT_SYS_DYNAMIC_LINKER($1)
++ _LT_LINKER_HARDCODE_LIBPATH($1)
++
++ _LT_CONFIG($1)
++ fi # test -n "$compiler"
++
++ CC=$lt_save_CC
++ LDCXX=$LD
++ LD=$lt_save_LD
++ GCC=$lt_save_GCC
++ with_gnu_ld=$lt_save_with_gnu_ld
++ lt_cv_path_LDCXX=$lt_cv_path_LD
++ lt_cv_path_LD=$lt_save_path_LD
++ lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
++ lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
++fi # test "$_lt_caught_CXX_error" != yes
++
++AC_LANG_POP
++])# _LT_LANG_CXX_CONFIG
++
++
++# _LT_SYS_HIDDEN_LIBDEPS([TAGNAME])
++# ---------------------------------
++# Figure out "hidden" library dependencies from verbose
++# compiler output when linking a shared library.
++# Parse the compiler output and extract the necessary
++# objects, libraries and library flags.
++m4_defun([_LT_SYS_HIDDEN_LIBDEPS],
++[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
++# Dependencies to place before and after the object being linked:
++_LT_TAGVAR(predep_objects, $1)=
++_LT_TAGVAR(postdep_objects, $1)=
++_LT_TAGVAR(predeps, $1)=
++_LT_TAGVAR(postdeps, $1)=
++_LT_TAGVAR(compiler_lib_search_path, $1)=
++
++dnl we can't use the lt_simple_compile_test_code here,
++dnl because it contains code intended for an executable,
++dnl not a library. It's possible we should let each
++dnl tag define a new lt_????_link_test_code variable,
++dnl but it's only used here...
++m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF
++int a;
++void foo (void) { a = 0; }
++_LT_EOF
++], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF
++class Foo
++{
++public:
++ Foo (void) { a = 0; }
++private:
++ int a;
++};
++_LT_EOF
++], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF
++ subroutine foo
++ implicit none
++ integer*4 a
++ a=0
++ return
++ end
++_LT_EOF
++], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF
++ subroutine foo
++ implicit none
++ integer a
++ a=0
++ return
++ end
++_LT_EOF
++], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF
++public class foo {
++ private int a;
++ public void bar (void) {
++ a = 0;
++ }
++};
++_LT_EOF
++])
++dnl Parse the compiler output and extract the necessary
++dnl objects, libraries and library flags.
++if AC_TRY_EVAL(ac_compile); then
++ # Parse the compiler output and extract the necessary
++ # objects, libraries and library flags.
++
++ # Sentinel used to keep track of whether or not we are before
++ # the conftest object file.
++ pre_test_object_deps_done=no
+
+- sunos4*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- ;;
++ for p in `eval "$output_verbose_link_cmd"`; do
++ case $p in
+
+- sysv4 | sysv4.2uw2* | sysv4.3*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- ;;
++ -L* | -R* | -l*)
++ # Some compilers place space between "-{L,R}" and the path.
++ # Remove the space.
++ if test $p = "-L" ||
++ test $p = "-R"; then
++ prev=$p
++ continue
++ else
++ prev=
++ fi
+
+- sysv4*MP*)
+- if test -d /usr/nec ;then
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- fi
+- ;;
++ if test "$pre_test_object_deps_done" = no; then
++ case $p in
++ -L* | -R*)
++ # Internal compiler library paths should come after those
++ # provided the user. The postdeps already come after the
++ # user supplied libs so there is no need to process them.
++ if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then
++ _LT_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}"
++ else
++ _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}"
++ fi
++ ;;
++ # The "-l" case would never come before the object being
++ # linked, so don't bother handling this case.
++ esac
++ else
++ if test -z "$_LT_TAGVAR(postdeps, $1)"; then
++ _LT_TAGVAR(postdeps, $1)="${prev}${p}"
++ else
++ _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}"
++ fi
++ fi
++ ;;
+
+- sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- ;;
++ *.$objext)
++ # This assumes that the test object file only shows up
++ # once in the compiler output.
++ if test "$p" = "conftest.$objext"; then
++ pre_test_object_deps_done=yes
++ continue
++ fi
+
+- unicos*)
+- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+- _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+- ;;
++ if test "$pre_test_object_deps_done" = no; then
++ if test -z "$_LT_TAGVAR(predep_objects, $1)"; then
++ _LT_TAGVAR(predep_objects, $1)="$p"
++ else
++ _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p"
++ fi
++ else
++ if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then
++ _LT_TAGVAR(postdep_objects, $1)="$p"
++ else
++ _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p"
++ fi
++ fi
++ ;;
+
+- uts4*)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+- ;;
++ *) ;; # Ignore the rest.
+
+- *)
+- _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+- ;;
+ esac
+- fi
+-])
+-AC_MSG_RESULT([$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)])
++ done
+
+-#
+-# Check to make sure the PIC flag actually works.
+-#
+-if test -n "$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)"; then
+- AC_LIBTOOL_COMPILER_OPTION([if $compiler PIC flag $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) works],
+- _LT_AC_TAGVAR(lt_prog_compiler_pic_works, $1),
+- [$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)ifelse([$1],[],[ -DPIC],[ifelse([$1],[CXX],[ -DPIC],[])])], [],
+- [case $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) in
+- "" | " "*) ;;
+- *) _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)" ;;
+- esac],
+- [_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
+- _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no])
++ # Clean up.
++ rm -f a.out a.exe
++else
++ echo "libtool.m4: error: problem compiling $1 test program"
+ fi
+-case $host_os in
+- # For platforms which do not support PIC, -DPIC is meaningless:
+- *djgpp*)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
+- ;;
+- *)
+- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)ifelse([$1],[],[ -DPIC],[ifelse([$1],[CXX],[ -DPIC],[])])"
+- ;;
+-esac
+-
+-#
+-# Check to make sure the static flag actually works.
+-#
+-wl=$_LT_AC_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_AC_TAGVAR(lt_prog_compiler_static, $1)\"
+-AC_LIBTOOL_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works],
+- _LT_AC_TAGVAR(lt_prog_compiler_static_works, $1),
+- $lt_tmp_static_flag,
+- [],
+- [_LT_AC_TAGVAR(lt_prog_compiler_static, $1)=])
+-])
+
++$RM -f confest.$objext
+
+-# AC_LIBTOOL_PROG_LD_SHLIBS([TAGNAME])
+-# ------------------------------------
+-# See if the linker supports building shared libraries.
+-AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS],
+-[AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
+-ifelse([$1],[CXX],[
+- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+- case $host_os in
+- aix4* | aix5*)
+- # If we're using GNU nm, then we don't want the "-C" option.
+- # -C means demangle to AIX nm, but means don't demangle with GNU nm
+- if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
+- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols'
+- else
+- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols'
+- fi
+- ;;
+- pw32*)
+- _LT_AC_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds"
+- ;;
+- cygwin* | mingw*)
+- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]] /s/.* \([[^ ]]*\)/\1 DATA/;/^.* __nm__/s/^.* __nm__\([[^ ]]*\) [[^ ]]*/\1 DATA/;/^I /d;/^[[AITW]] /s/.* //'\'' | sort | uniq > $export_symbols'
+- ;;
+- *)
+- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
++# PORTME: override above test on systems where it is broken
++m4_if([$1], [CXX],
++[case $host_os in
++interix[[3-9]]*)
++ # Interix 3.5 installs completely hosed .la files for C++, so rather than
++ # hack all around it, let's just trust "g++" to DTRT.
++ _LT_TAGVAR(predep_objects,$1)=
++ _LT_TAGVAR(postdep_objects,$1)=
++ _LT_TAGVAR(postdeps,$1)=
+ ;;
+- esac
+-],[
+- runpath_var=
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=
+- _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+- _LT_AC_TAGVAR(archive_cmds, $1)=
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)=
+- _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)=
+- _LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1)=
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+- _LT_AC_TAGVAR(thread_safe_flag_spec, $1)=
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
+- _LT_AC_TAGVAR(hardcode_direct, $1)=no
+- _LT_AC_TAGVAR(hardcode_minus_L, $1)=no
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+- _LT_AC_TAGVAR(link_all_deplibs, $1)=unknown
+- _LT_AC_TAGVAR(hardcode_automatic, $1)=no
+- _LT_AC_TAGVAR(module_cmds, $1)=
+- _LT_AC_TAGVAR(module_expsym_cmds, $1)=
+- _LT_AC_TAGVAR(always_export_symbols, $1)=no
+- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+- # include_expsyms should be a list of space-separated symbols to be *always*
+- # included in the symbol list
+- _LT_AC_TAGVAR(include_expsyms, $1)=
+- # exclude_expsyms can be an extended regexp of symbols to exclude
+- # it will be wrapped by ` (' and `)$', so one must not match beginning or
+- # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
+- # as well as any symbol that contains `d'.
+- _LT_AC_TAGVAR(exclude_expsyms, $1)="_GLOBAL_OFFSET_TABLE_"
+- # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
+- # platforms (ab)use it in PIC code, but their linkers get confused if
+- # the symbol is explicitly referenced. Since portable code cannot
+- # rely on this symbol name, it's probably fine to never include it in
+- # preloaded symbol tables.
+- extract_expsyms_cmds=
+- # Just being paranoid about ensuring that cc_basename is set.
+- _LT_CC_BASENAME([$compiler])
+- case $host_os in
+- cygwin* | mingw* | pw32*)
+- # FIXME: the MSVC++ port hasn't been tested in a loooong time
+- # When not using gcc, we currently assume that we are using
+- # Microsoft Visual C++.
+- if test "$GCC" != yes; then
+- with_gnu_ld=no
+- fi
+- ;;
+- interix*)
+- # we just hope/assume this is gcc and not c89 (= MSVC++)
+- with_gnu_ld=yes
+- ;;
+- openbsd*)
+- with_gnu_ld=no
+- ;;
+- esac
+-
+- _LT_AC_TAGVAR(ld_shlibs, $1)=yes
+- if test "$with_gnu_ld" = yes; then
+- # If archive_cmds runs LD, not CC, wlarc should be empty
+- wlarc='${wl}'
+-
+- # Set some defaults for GNU ld with shared library support. These
+- # are reset later if shared libraries are not supported. Putting them
+- # here allows them to be overridden if necessary.
+- runpath_var=LD_RUN_PATH
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+- # ancient GNU ld didn't support --whole-archive et. al.
+- if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+- else
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+- fi
+- supports_anon_versioning=no
+- case `$LD -v 2>/dev/null` in
+- *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11
+- *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
+- *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
+- *\ 2.11.*) ;; # other 2.11 versions
+- *) supports_anon_versioning=yes ;;
+- esac
+-
+- # See if GNU ld supports shared libraries.
+- case $host_os in
+- aix3* | aix4* | aix5*)
+- # On AIX/PPC, the GNU linker is very broken
+- if test "$host_cpu" != ia64; then
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- cat <<EOF 1>&2
+-
+-*** Warning: the GNU linker, at least up to release 2.9.1, is reported
+-*** to be unable to reliably create shared libraries on AIX.
+-*** Therefore, libtool is disabling shared libraries support. If you
+-*** really care for shared libraries, you may want to modify your PATH
+-*** so that a non-GNU linker is found, and then restart.
+-
+-EOF
+- fi
+- ;;
+
+- amigaos*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+-
+- # Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports
+- # that the semantics of dynamic libraries on AmigaOS, at least up
+- # to version 4, is to share data among multiple programs linked
+- # with the same dynamic library. Since this doesn't match the
+- # behavior of shared libraries on other platforms, we can't use
+- # them.
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
++linux*)
++ case `$CC -V 2>&1 | sed 5q` in
++ *Sun\ C*)
++ # Sun C++ 5.9
+
+- beos*)
+- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+- # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
+- # support --undefined. This deserves some investigation. FIXME
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+- else
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- fi
++ # The more standards-conforming stlport4 library is
++ # incompatible with the Cstd library. Avoid specifying
++ # it if it's in CXXFLAGS. Ignore libCrun as
++ # -library=stlport4 depends on it.
++ case " $CXX $CXXFLAGS " in
++ *" -library=stlport4 "*)
++ solaris_use_stlport4=yes
+ ;;
++ esac
+
+- cygwin* | mingw* | pw32*)
+- # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
+- # as there is no search path for DLLs.
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+- _LT_AC_TAGVAR(always_export_symbols, $1)=no
+- _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]] /s/.* \([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]] /s/.* //'\'' | sort | uniq > $export_symbols'
+-
+- if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+- # If the export-symbols file already is a .def file (1st line
+- # is EXPORTS), use it as is; otherwise, prepend...
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+- cp $export_symbols $output_objdir/$soname.def;
+- else
+- echo EXPORTS > $output_objdir/$soname.def;
+- cat $export_symbols >> $output_objdir/$soname.def;
+- fi~
+- $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+- else
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- fi
+- ;;
++ if test "$solaris_use_stlport4" != yes; then
++ _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
++ fi
++ ;;
++ esac
++ ;;
+
+- interix3*)
+- _LT_AC_TAGVAR(hardcode_direct, $1)=no
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+- # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+- # Instead, shared libraries are loaded at an image base (0x10000000 by
+- # default) and relocated if they conflict, which is a slow very memory
+- # consuming and fragmenting process. To avoid this, we pick a random,
+- # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+- # time. Moving up from 0x10000000 also allows more sbrk(2) space.
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
++solaris*)
++ case $cc_basename in
++ CC*)
++ # The more standards-conforming stlport4 library is
++ # incompatible with the Cstd library. Avoid specifying
++ # it if it's in CXXFLAGS. Ignore libCrun as
++ # -library=stlport4 depends on it.
++ case " $CXX $CXXFLAGS " in
++ *" -library=stlport4 "*)
++ solaris_use_stlport4=yes
+ ;;
++ esac
+
+- linux*)
+- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+- tmp_addflag=
+- case $cc_basename,$host_cpu in
+- pgcc*) # Portland Group C compiler
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+- tmp_addflag=' $pic_flag'
+- ;;
+- pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+- tmp_addflag=' $pic_flag -Mnomain' ;;
+- ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64
+- tmp_addflag=' -i_dynamic' ;;
+- efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64
+- tmp_addflag=' -i_dynamic -nofor_main' ;;
+- ifc* | ifort*) # Intel Fortran compiler
+- tmp_addflag=' -nofor_main' ;;
+- esac
+- case `$CC -V 2>&1 | sed 5q` in
+- *Sun\ C*) # Sun C 5.9
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive /dev/null'
+- tmp_sharedflag='-G' ;;
+- *Sun\ F*) # Sun Fortran 8.3
+- tmp_sharedflag='-G' ;;
+- *)
+- tmp_sharedflag='-shared' ;;
+- esac
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
++ # Adding this requires a known-good setup of shared libraries for
++ # Sun compiler versions before 5.6, else PIC objects from an old
++ # archive will be linked into the output, leading to subtle bugs.
++ if test "$solaris_use_stlport4" != yes; then
++ _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
++ fi
++ ;;
++ esac
++ ;;
++esac
++])
+
+- if test $supports_anon_versioning = yes; then
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $output_objdir/$libname.ver~
+- cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+- $echo "local: *; };" >> $output_objdir/$libname.ver~
+- $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+- fi
+- else
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- fi
+- ;;
++case " $_LT_TAGVAR(postdeps, $1) " in
++*" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;;
++esac
++ _LT_TAGVAR(compiler_lib_search_dirs, $1)=
++if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then
++ _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'`
++fi
++_LT_TAGDECL([], [compiler_lib_search_dirs], [1],
++ [The directories searched by this compiler when creating a shared library])
++_LT_TAGDECL([], [predep_objects], [1],
++ [Dependencies to place before and after the objects being linked to
++ create a shared library])
++_LT_TAGDECL([], [postdep_objects], [1])
++_LT_TAGDECL([], [predeps], [1])
++_LT_TAGDECL([], [postdeps], [1])
++_LT_TAGDECL([], [compiler_lib_search_path], [1],
++ [The library search path used internally by the compiler when linking
++ a shared library])
++])# _LT_SYS_HIDDEN_LIBDEPS
++
++
++# _LT_PROG_F77
++# ------------
++# Since AC_PROG_F77 is broken, in that it returns the empty string
++# if there is no fortran compiler, we have our own version here.
++m4_defun([_LT_PROG_F77],
++[
++pushdef([AC_MSG_ERROR], [_lt_disable_F77=yes])
++AC_PROG_F77
++if test -z "$F77" || test "X$F77" = "Xno"; then
++ _lt_disable_F77=yes
++fi
++popdef([AC_MSG_ERROR])
++])# _LT_PROG_F77
+
+- netbsd*)
+- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
+- wlarc=
+- else
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+- fi
+- ;;
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([_LT_PROG_F77], [])
+
+- solaris*)
+- if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- cat <<EOF 1>&2
+
+-*** Warning: The releases 2.8.* of the GNU linker cannot reliably
+-*** create shared libraries on Solaris systems. Therefore, libtool
+-*** is disabling shared libraries support. We urge you to upgrade GNU
+-*** binutils to release 2.9.1 or newer. Another option is to modify
+-*** your PATH or compiler configuration so that the native linker is
+-*** used, and then restart.
++# _LT_LANG_F77_CONFIG([TAG])
++# --------------------------
++# Ensure that the configuration variables for a Fortran 77 compiler are
++# suitably defined. These variables are subsequently used by _LT_CONFIG
++# to write the compiler configuration to `libtool'.
++m4_defun([_LT_LANG_F77_CONFIG],
++[AC_REQUIRE([_LT_PROG_F77])dnl
++AC_LANG_PUSH(Fortran 77)
+
+-EOF
+- elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+- else
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- fi
+- ;;
++_LT_TAGVAR(archive_cmds_need_lc, $1)=no
++_LT_TAGVAR(allow_undefined_flag, $1)=
++_LT_TAGVAR(always_export_symbols, $1)=no
++_LT_TAGVAR(archive_expsym_cmds, $1)=
++_LT_TAGVAR(export_dynamic_flag_spec, $1)=
++_LT_TAGVAR(hardcode_direct, $1)=no
++_LT_TAGVAR(hardcode_direct_absolute, $1)=no
++_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
++_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
++_LT_TAGVAR(hardcode_libdir_separator, $1)=
++_LT_TAGVAR(hardcode_minus_L, $1)=no
++_LT_TAGVAR(hardcode_automatic, $1)=no
++_LT_TAGVAR(inherit_rpath, $1)=no
++_LT_TAGVAR(module_cmds, $1)=
++_LT_TAGVAR(module_expsym_cmds, $1)=
++_LT_TAGVAR(link_all_deplibs, $1)=unknown
++_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
++_LT_TAGVAR(no_undefined_flag, $1)=
++_LT_TAGVAR(whole_archive_flag_spec, $1)=
++_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+
+- sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
+- case `$LD -v 2>&1` in
+- *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*)
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- cat <<_LT_EOF 1>&2
++# Source file extension for f77 test sources.
++ac_ext=f
+
+-*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
+-*** reliably create shared libraries on SCO systems. Therefore, libtool
+-*** is disabling shared libraries support. We urge you to upgrade GNU
+-*** binutils to release 2.16.91.0.3 or newer. Another option is to modify
+-*** your PATH or compiler configuration so that the native linker is
+-*** used, and then restart.
++# Object file extension for compiled f77 test sources.
++objext=o
++_LT_TAGVAR(objext, $1)=$objext
+
+-_LT_EOF
+- ;;
+- *)
+- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname,-retain-symbols-file,$export_symbols -o $lib'
+- else
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- fi
+- ;;
+- esac
+- ;;
++# No sense in running all these tests if we already determined that
++# the F77 compiler isn't working. Some variables (like enable_shared)
++# are currently assumed to apply to all compilers on this platform,
++# and will be corrupted by setting them based on a non-working compiler.
++if test "$_lt_disable_F77" != yes; then
++ # Code to be used in simple compile tests
++ lt_simple_compile_test_code="\
++ subroutine t
++ return
++ end
++"
+
+- sunos4*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+- wlarc=
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- ;;
++ # Code to be used in simple link tests
++ lt_simple_link_test_code="\
++ program t
++ end
++"
+
+- *)
+- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+- else
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- fi
+- ;;
+- esac
++ # ltmain only uses $CC for tagged configurations so make sure $CC is set.
++ _LT_TAG_COMPILER
+
+- if test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no; then
+- runpath_var=
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+- fi
+- else
+- # PORTME fill in a description of your system's linker (not GNU ld)
+- case $host_os in
+- aix3*)
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+- _LT_AC_TAGVAR(always_export_symbols, $1)=yes
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
+- # Note: this linker hardcodes the directories in LIBPATH if there
+- # are no directories specified by -L.
+- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+- if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
+- # Neither direct hardcoding nor static linking is supported with a
+- # broken collect2.
+- _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported
+- fi
+- ;;
++ # save warnings/boilerplate of simple test code
++ _LT_COMPILER_BOILERPLATE
++ _LT_LINKER_BOILERPLATE
++
++ # Allow CC to be a program name with arguments.
++ lt_save_CC="$CC"
++ lt_save_GCC=$GCC
++ CC=${F77-"f77"}
++ compiler=$CC
++ _LT_TAGVAR(compiler, $1)=$CC
++ _LT_CC_BASENAME([$compiler])
++ GCC=$G77
++ if test -n "$compiler"; then
++ AC_MSG_CHECKING([if libtool supports shared libraries])
++ AC_MSG_RESULT([$can_build_shared])
+
+- aix4* | aix5*)
+- if test "$host_cpu" = ia64; then
+- # On IA64, the linker does run time linking by default, so we don't
+- # have to do anything special.
+- aix_use_runtimelinking=no
+- exp_sym_flag='-Bexport'
+- no_entry_flag=""
+- else
+- # If we're using GNU nm, then we don't want the "-C" option.
+- # -C means demangle to AIX nm, but means don't demangle with GNU nm
+- if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
+- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols'
+- else
+- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols'
++ AC_MSG_CHECKING([whether to build shared libraries])
++ test "$can_build_shared" = "no" && enable_shared=no
++
++ # On AIX, shared libraries and static libraries use the same namespace, and
++ # are all built from PIC.
++ case $host_os in
++ aix3*)
++ test "$enable_shared" = yes && enable_static=no
++ if test -n "$RANLIB"; then
++ archive_cmds="$archive_cmds~\$RANLIB \$lib"
++ postinstall_cmds='$RANLIB $lib'
++ fi
++ ;;
++ aix[[4-9]]*)
++ if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
++ test "$enable_shared" = yes && enable_static=no
+ fi
+- aix_use_runtimelinking=no
++ ;;
++ esac
++ AC_MSG_RESULT([$enable_shared])
+
+- # Test if we are trying to use run time linking or normal
+- # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+- # need to do runtime linking.
+- case $host_os in aix4.[[23]]|aix4.[[23]].*|aix5*)
+- for ld_flag in $LDFLAGS; do
+- if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+- aix_use_runtimelinking=yes
+- break
+- fi
+- done
+- ;;
+- esac
++ AC_MSG_CHECKING([whether to build static libraries])
++ # Make sure either enable_shared or enable_static is yes.
++ test "$enable_shared" = yes || enable_static=yes
++ AC_MSG_RESULT([$enable_static])
++
++ _LT_TAGVAR(GCC, $1)="$G77"
++ _LT_TAGVAR(LD, $1)="$LD"
++
++ ## CAVEAT EMPTOR:
++ ## There is no encapsulation within the following macros, do not change
++ ## the running order or otherwise move them around unless you know exactly
++ ## what you are doing...
++ _LT_COMPILER_PIC($1)
++ _LT_COMPILER_C_O($1)
++ _LT_COMPILER_FILE_LOCKS($1)
++ _LT_LINKER_SHLIBS($1)
++ _LT_SYS_DYNAMIC_LINKER($1)
++ _LT_LINKER_HARDCODE_LIBPATH($1)
++
++ _LT_CONFIG($1)
++ fi # test -n "$compiler"
++
++ GCC=$lt_save_GCC
++ CC="$lt_save_CC"
++fi # test "$_lt_disable_F77" != yes
+
+- exp_sym_flag='-bexport'
+- no_entry_flag='-bnoentry'
+- fi
++AC_LANG_POP
++])# _LT_LANG_F77_CONFIG
+
+- # When large executables or shared objects are built, AIX ld can
+- # have problems creating the table of contents. If linking a library
+- # or program results in "error TOC overflow" add -mminimal-toc to
+- # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
+- # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+- _LT_AC_TAGVAR(archive_cmds, $1)=''
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':'
+- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
++# _LT_PROG_FC
++# -----------
++# Since AC_PROG_FC is broken, in that it returns the empty string
++# if there is no fortran compiler, we have our own version here.
++m4_defun([_LT_PROG_FC],
++[
++pushdef([AC_MSG_ERROR], [_lt_disable_FC=yes])
++AC_PROG_FC
++if test -z "$FC" || test "X$FC" = "Xno"; then
++ _lt_disable_FC=yes
++fi
++popdef([AC_MSG_ERROR])
++])# _LT_PROG_FC
+
+- if test "$GCC" = yes; then
+- case $host_os in aix4.[[012]]|aix4.[[012]].*)
+- # We only want to do this on AIX 4.2 and lower, the check
+- # below for broken collect2 doesn't work under 4.3+
+- collect2name=`${CC} -print-prog-name=collect2`
+- if test -f "$collect2name" && \
+- strings "$collect2name" | grep resolve_lib_name >/dev/null
+- then
+- # We have reworked collect2
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- else
+- # We have old collect2
+- _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported
+- # It fails to find uninstalled libraries when the uninstalled
+- # path is not listed in the libpath. Setting hardcode_minus_L
+- # to unsupported forces relinking
+- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
+- fi
+- ;;
+- esac
+- shared_flag='-shared'
+- if test "$aix_use_runtimelinking" = yes; then
+- shared_flag="$shared_flag "'${wl}-G'
+- fi
+- else
+- # not using gcc
+- if test "$host_cpu" = ia64; then
+- # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+- # chokes on -Wl,-G. The following line is correct:
+- shared_flag='-G'
+- else
+- if test "$aix_use_runtimelinking" = yes; then
+- shared_flag='${wl}-G'
+- else
+- shared_flag='${wl}-bM:SRE'
+- fi
+- fi
+- fi
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([_LT_PROG_FC], [])
+
+- # It seems that -bexpall does not export symbols beginning with
+- # underscore (_), so it is better to generate a list of symbols to export.
+- _LT_AC_TAGVAR(always_export_symbols, $1)=yes
+- if test "$aix_use_runtimelinking" = yes; then
+- # Warning - without using the other runtime loading flags (-brtl),
+- # -berok will link without error, but may produce a broken library.
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)='-berok'
+- # Determine the default libpath from the value encoded in an empty executable.
+- _LT_AC_SYS_LIBPATH_AIX
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+- else
+- if test "$host_cpu" = ia64; then
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+- else
+- # Determine the default libpath from the value encoded in an empty executable.
+- _LT_AC_SYS_LIBPATH_AIX
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+- # Warning - without using the other run time loading flags,
+- # -berok will link without error, but may produce a broken library.
+- _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
+- # Exported symbols can be pulled into shared objects from archives
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
+- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
+- # This is similar to how AIX traditionally builds its shared libraries.
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+- fi
+- fi
+- ;;
+
+- amigaos*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+- # see comment about different semantics on the GNU ld section
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
++# _LT_LANG_FC_CONFIG([TAG])
++# -------------------------
++# Ensure that the configuration variables for a Fortran compiler are
++# suitably defined. These variables are subsequently used by _LT_CONFIG
++# to write the compiler configuration to `libtool'.
++m4_defun([_LT_LANG_FC_CONFIG],
++[AC_REQUIRE([_LT_PROG_FC])dnl
++AC_LANG_PUSH(Fortran)
++
++_LT_TAGVAR(archive_cmds_need_lc, $1)=no
++_LT_TAGVAR(allow_undefined_flag, $1)=
++_LT_TAGVAR(always_export_symbols, $1)=no
++_LT_TAGVAR(archive_expsym_cmds, $1)=
++_LT_TAGVAR(export_dynamic_flag_spec, $1)=
++_LT_TAGVAR(hardcode_direct, $1)=no
++_LT_TAGVAR(hardcode_direct_absolute, $1)=no
++_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
++_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
++_LT_TAGVAR(hardcode_libdir_separator, $1)=
++_LT_TAGVAR(hardcode_minus_L, $1)=no
++_LT_TAGVAR(hardcode_automatic, $1)=no
++_LT_TAGVAR(inherit_rpath, $1)=no
++_LT_TAGVAR(module_cmds, $1)=
++_LT_TAGVAR(module_expsym_cmds, $1)=
++_LT_TAGVAR(link_all_deplibs, $1)=unknown
++_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
++_LT_TAGVAR(no_undefined_flag, $1)=
++_LT_TAGVAR(whole_archive_flag_spec, $1)=
++_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+
+- bsdi[[45]]*)
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic
+- ;;
++# Source file extension for fc test sources.
++ac_ext=${ac_fc_srcext-f}
+
+- cygwin* | mingw* | pw32*)
+- # When not using gcc, we currently assume that we are using
+- # Microsoft Visual C++.
+- # hardcode_libdir_flag_spec is actually meaningless, as there is
+- # no search path for DLLs.
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=' '
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+- # Tell ltmain to make .lib files, not .a files.
+- libext=lib
+- # Tell ltmain to make .dll files, not .so files.
+- shrext_cmds=".dll"
+- # FIXME: Setting linknames here is a bad hack.
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames='
+- # The linker will automatically build a .lib file if we build a DLL.
+- _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)='true'
+- # FIXME: Should let the user specify the lib program.
+- _LT_AC_TAGVAR(old_archive_cmds, $1)='lib /OUT:$oldlib$oldobjs$old_deplibs'
+- _LT_AC_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`'
+- _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+- ;;
++# Object file extension for compiled fc test sources.
++objext=o
++_LT_TAGVAR(objext, $1)=$objext
+
+- darwin* | rhapsody*)
+- case $host_os in
+- rhapsody* | darwin1.[[012]])
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}suppress'
+- ;;
+- *) # Darwin 1.3 on
+- if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+- else
+- case ${MACOSX_DEPLOYMENT_TARGET} in
+- 10.[[012]])
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+- ;;
+- 10.*)
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}dynamic_lookup'
+- ;;
+- esac
+- fi
+- ;;
+- esac
+- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+- _LT_AC_TAGVAR(hardcode_direct, $1)=no
+- _LT_AC_TAGVAR(hardcode_automatic, $1)=yes
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=''
+- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+- if test "$GCC" = yes ; then
+- output_verbose_link_cmd='echo'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+- _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+- # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+- _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+- else
+- case $cc_basename in
+- xlc*)
+- output_verbose_link_cmd='echo'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
+- _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+- # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+- _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+- ;;
+- *)
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- esac
+- fi
+- ;;
++# No sense in running all these tests if we already determined that
++# the FC compiler isn't working. Some variables (like enable_shared)
++# are currently assumed to apply to all compilers on this platform,
++# and will be corrupted by setting them based on a non-working compiler.
++if test "$_lt_disable_FC" != yes; then
++ # Code to be used in simple compile tests
++ lt_simple_compile_test_code="\
++ subroutine t
++ return
++ end
++"
+
+- dgux*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- ;;
++ # Code to be used in simple link tests
++ lt_simple_link_test_code="\
++ program t
++ end
++"
+
+- freebsd1*)
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
++ # ltmain only uses $CC for tagged configurations so make sure $CC is set.
++ _LT_TAG_COMPILER
+
+- # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
+- # support. Future versions do this automatically, but an explicit c++rt0.o
+- # does not break anything, and helps significantly (at the cost of a little
+- # extra space).
+- freebsd2.2*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- ;;
++ # save warnings/boilerplate of simple test code
++ _LT_COMPILER_BOILERPLATE
++ _LT_LINKER_BOILERPLATE
++
++ # Allow CC to be a program name with arguments.
++ lt_save_CC="$CC"
++ lt_save_GCC=$GCC
++ CC=${FC-"f95"}
++ compiler=$CC
++ GCC=$ac_cv_fc_compiler_gnu
+
+- # Unfortunately, older versions of FreeBSD 2 do not have this feature.
+- freebsd2*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- ;;
++ _LT_TAGVAR(compiler, $1)=$CC
++ _LT_CC_BASENAME([$compiler])
+
+- # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
+- freebsd* | kfreebsd*-gnu | dragonfly*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- ;;
++ if test -n "$compiler"; then
++ AC_MSG_CHECKING([if libtool supports shared libraries])
++ AC_MSG_RESULT([$can_build_shared])
+
+- hpux9*)
+- if test "$GCC" = yes; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+- else
+- _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+- fi
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
++ AC_MSG_CHECKING([whether to build shared libraries])
++ test "$can_build_shared" = "no" && enable_shared=no
+
+- # hardcode_minus_L: Not really in the search PATH,
+- # but as the default location of the library.
+- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+- ;;
++ # On AIX, shared libraries and static libraries use the same namespace, and
++ # are all built from PIC.
++ case $host_os in
++ aix3*)
++ test "$enable_shared" = yes && enable_static=no
++ if test -n "$RANLIB"; then
++ archive_cmds="$archive_cmds~\$RANLIB \$lib"
++ postinstall_cmds='$RANLIB $lib'
++ fi
++ ;;
++ aix[[4-9]]*)
++ if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
++ test "$enable_shared" = yes && enable_static=no
++ fi
++ ;;
++ esac
++ AC_MSG_RESULT([$enable_shared])
+
+- hpux10*)
+- if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+- else
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
+- fi
+- if test "$with_gnu_ld" = no; then
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
++ AC_MSG_CHECKING([whether to build static libraries])
++ # Make sure either enable_shared or enable_static is yes.
++ test "$enable_shared" = yes || enable_static=yes
++ AC_MSG_RESULT([$enable_static])
++
++ _LT_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu"
++ _LT_TAGVAR(LD, $1)="$LD"
++
++ ## CAVEAT EMPTOR:
++ ## There is no encapsulation within the following macros, do not change
++ ## the running order or otherwise move them around unless you know exactly
++ ## what you are doing...
++ _LT_SYS_HIDDEN_LIBDEPS($1)
++ _LT_COMPILER_PIC($1)
++ _LT_COMPILER_C_O($1)
++ _LT_COMPILER_FILE_LOCKS($1)
++ _LT_LINKER_SHLIBS($1)
++ _LT_SYS_DYNAMIC_LINKER($1)
++ _LT_LINKER_HARDCODE_LIBPATH($1)
++
++ _LT_CONFIG($1)
++ fi # test -n "$compiler"
++
++ GCC=$lt_save_GCC
++ CC="$lt_save_CC"
++fi # test "$_lt_disable_FC" != yes
+
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
++AC_LANG_POP
++])# _LT_LANG_FC_CONFIG
+
+- # hardcode_minus_L: Not really in the search PATH,
+- # but as the default location of the library.
+- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+- fi
+- ;;
+
+- hpux11*)
+- if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+- case $host_cpu in
+- hppa*64*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+- ;;
+- ia64*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+- ;;
+- *)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+- ;;
+- esac
+- else
+- case $host_cpu in
+- hppa*64*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+- ;;
+- ia64*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+- ;;
+- *)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+- ;;
+- esac
+- fi
+- if test "$with_gnu_ld" = no; then
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
++# _LT_LANG_GCJ_CONFIG([TAG])
++# --------------------------
++# Ensure that the configuration variables for the GNU Java Compiler compiler
++# are suitably defined. These variables are subsequently used by _LT_CONFIG
++# to write the compiler configuration to `libtool'.
++m4_defun([_LT_LANG_GCJ_CONFIG],
++[AC_REQUIRE([LT_PROG_GCJ])dnl
++AC_LANG_SAVE
+
+- case $host_cpu in
+- hppa*64*|ia64*)
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir'
+- _LT_AC_TAGVAR(hardcode_direct, $1)=no
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- ;;
+- *)
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
++# Source file extension for Java test sources.
++ac_ext=java
+
+- # hardcode_minus_L: Not really in the search PATH,
+- # but as the default location of the library.
+- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+- ;;
+- esac
+- fi
+- ;;
++# Object file extension for compiled Java test sources.
++objext=o
++_LT_TAGVAR(objext, $1)=$objext
+
+- irix5* | irix6* | nonstopux*)
+- if test "$GCC" = yes; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+- else
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir'
+- fi
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+- ;;
++# Code to be used in simple compile tests
++lt_simple_compile_test_code="class foo {}"
+
+- netbsd*)
+- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out
+- else
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF
+- fi
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- ;;
++# Code to be used in simple link tests
++lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }'
+
+- newsos6)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- ;;
++# ltmain only uses $CC for tagged configurations so make sure $CC is set.
++_LT_TAG_COMPILER
++
++# save warnings/boilerplate of simple test code
++_LT_COMPILER_BOILERPLATE
++_LT_LINKER_BOILERPLATE
++
++# Allow CC to be a program name with arguments.
++lt_save_CC="$CC"
++lt_save_GCC=$GCC
++GCC=yes
++CC=${GCJ-"gcj"}
++compiler=$CC
++_LT_TAGVAR(compiler, $1)=$CC
++_LT_TAGVAR(LD, $1)="$LD"
++_LT_CC_BASENAME([$compiler])
+
+- openbsd*)
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+- else
+- case $host_os in
+- openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+- ;;
+- *)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+- ;;
+- esac
+- fi
+- ;;
++# GCJ did not exist at the time GCC didn't implicitly link libc in.
++_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+
+- os2*)
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+- _LT_AC_TAGVAR(archive_cmds, $1)='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
+- _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
+- ;;
++_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+
+- osf3*)
+- if test "$GCC" = yes; then
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+- else
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+- fi
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+- ;;
++## CAVEAT EMPTOR:
++## There is no encapsulation within the following macros, do not change
++## the running order or otherwise move them around unless you know exactly
++## what you are doing...
++if test -n "$compiler"; then
++ _LT_COMPILER_NO_RTTI($1)
++ _LT_COMPILER_PIC($1)
++ _LT_COMPILER_C_O($1)
++ _LT_COMPILER_FILE_LOCKS($1)
++ _LT_LINKER_SHLIBS($1)
++ _LT_LINKER_HARDCODE_LIBPATH($1)
+
+- osf4* | osf5*) # as osf3* with the addition of -msym flag
+- if test "$GCC" = yes; then
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+- else
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~
+- $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp'
++ _LT_CONFIG($1)
++fi
+
+- # Both c and cxx compiler support -rpath directly
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
+- fi
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+- ;;
++AC_LANG_RESTORE
+
+- solaris*)
+- _LT_AC_TAGVAR(no_undefined_flag, $1)=' -z text'
+- if test "$GCC" = yes; then
+- wlarc='${wl}'
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+- $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp'
+- else
+- wlarc=''
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+- $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
+- fi
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- case $host_os in
+- solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
+- *)
+- # The compiler driver will combine linker options so we
+- # cannot just pass the convience library names through
+- # without $wl, iff we do not link with $LD.
+- # Luckily, gcc supports the same syntax we need for Sun Studio.
+- # Supported since Solaris 2.6 (maybe 2.5.1?)
+- case $wlarc in
+- '')
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' ;;
+- *)
+- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;;
+- esac ;;
+- esac
+- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+- ;;
++GCC=$lt_save_GCC
++CC="$lt_save_CC"
++])# _LT_LANG_GCJ_CONFIG
+
+- sunos4*)
+- if test "x$host_vendor" = xsequent; then
+- # Use $CC to link under sequent, because it throws in some extra .o
+- # files that make .init and .fini sections work.
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+- else
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
+- fi
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- ;;
+
+- sysv4)
+- case $host_vendor in
+- sni)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+- _LT_AC_TAGVAR(hardcode_direct, $1)=yes # is this really true???
+- ;;
+- siemens)
+- ## LD is ld it makes a PLAMLIB
+- ## CC just makes a GrossModule.
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+- _LT_AC_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs'
+- _LT_AC_TAGVAR(hardcode_direct, $1)=no
+- ;;
+- motorola)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+- _LT_AC_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie
+- ;;
+- esac
+- runpath_var='LD_RUN_PATH'
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- ;;
++# _LT_LANG_RC_CONFIG([TAG])
++# -------------------------
++# Ensure that the configuration variables for the Windows resource compiler
++# are suitably defined. These variables are subsequently used by _LT_CONFIG
++# to write the compiler configuration to `libtool'.
++m4_defun([_LT_LANG_RC_CONFIG],
++[AC_REQUIRE([LT_PROG_RC])dnl
++AC_LANG_SAVE
+
+- sysv4.3*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport'
+- ;;
++# Source file extension for RC test sources.
++ac_ext=rc
+
+- sysv4*MP*)
+- if test -d /usr/nec; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- runpath_var=LD_RUN_PATH
+- hardcode_runpath_var=yes
+- _LT_AC_TAGVAR(ld_shlibs, $1)=yes
+- fi
+- ;;
++# Object file extension for compiled RC test sources.
++objext=o
++_LT_TAGVAR(objext, $1)=$objext
+
+- sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7*)
+- _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- runpath_var='LD_RUN_PATH'
++# Code to be used in simple compile tests
++lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }'
+
+- if test "$GCC" = yes; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+- else
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+- fi
+- ;;
++# Code to be used in simple link tests
++lt_simple_link_test_code="$lt_simple_compile_test_code"
+
+- sysv5* | sco3.2v5* | sco5v6*)
+- # Note: We can NOT use -z defs as we might desire, because we do not
+- # link with -lc, and that would cause any symbols used from libc to
+- # always be unresolved, which means just about no library would
+- # ever link correctly. If we're not using GNU ld we use -z text
+- # though, which does catch some bad symbols but isn't as heavy-handed
+- # as -z defs.
+- _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
+- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
+- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':'
+- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
+- runpath_var='LD_RUN_PATH'
++# ltmain only uses $CC for tagged configurations so make sure $CC is set.
++_LT_TAG_COMPILER
+
+- if test "$GCC" = yes; then
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+- else
+- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+- fi
+- ;;
++# save warnings/boilerplate of simple test code
++_LT_COMPILER_BOILERPLATE
++_LT_LINKER_BOILERPLATE
+
+- uts4*)
+- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+- ;;
++# Allow CC to be a program name with arguments.
++lt_save_CC="$CC"
++lt_save_GCC=$GCC
++GCC=
++CC=${RC-"windres"}
++compiler=$CC
++_LT_TAGVAR(compiler, $1)=$CC
++_LT_CC_BASENAME([$compiler])
++_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
+
+- *)
+- _LT_AC_TAGVAR(ld_shlibs, $1)=no
+- ;;
+- esac
+- fi
+-])
+-AC_MSG_RESULT([$_LT_AC_TAGVAR(ld_shlibs, $1)])
+-test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
++if test -n "$compiler"; then
++ :
++ _LT_CONFIG($1)
++fi
+
+-#
+-# Do we need to explicitly link libc?
+-#
+-case "x$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)" in
+-x|xyes)
+- # Assume -lc should be added
+- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
++GCC=$lt_save_GCC
++AC_LANG_RESTORE
++CC="$lt_save_CC"
++])# _LT_LANG_RC_CONFIG
+
+- if test "$enable_shared" = yes && test "$GCC" = yes; then
+- case $_LT_AC_TAGVAR(archive_cmds, $1) in
+- *'~'*)
+- # FIXME: we may have to deal with multi-command sequences.
+- ;;
+- '$CC '*)
+- # Test whether the compiler implicitly links with -lc since on some
+- # systems, -lgcc has to come before -lc. If gcc already passes -lc
+- # to ld, don't add -lc before -lgcc.
+- AC_MSG_CHECKING([whether -lc should be explicitly linked in])
+- $rm conftest*
+- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+- if AC_TRY_EVAL(ac_compile) 2>conftest.err; then
+- soname=conftest
+- lib=conftest
+- libobjs=conftest.$ac_objext
+- deplibs=
+- wl=$_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)
+- pic_flag=$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)
+- compiler_flags=-v
+- linker_flags=-v
+- verstring=
+- output_objdir=.
+- libname=conftest
+- lt_save_allow_undefined_flag=$_LT_AC_TAGVAR(allow_undefined_flag, $1)
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=
+- if AC_TRY_EVAL(_LT_AC_TAGVAR(archive_cmds, $1) 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1)
+- then
+- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+- else
+- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
+- fi
+- _LT_AC_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag
+- else
+- cat conftest.err 1>&5
+- fi
+- $rm conftest*
+- AC_MSG_RESULT([$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)])
+- ;;
+- esac
+- fi
+- ;;
+-esac
+-])# AC_LIBTOOL_PROG_LD_SHLIBS
++# LT_PROG_GCJ
++# -----------
++AC_DEFUN([LT_PROG_GCJ],
++[m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ],
++ [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ],
++ [AC_CHECK_TOOL(GCJ, gcj,)
++ test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2"
++ AC_SUBST(GCJFLAGS)])])[]dnl
++])
+
++# Old name:
++AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ])
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([LT_AC_PROG_GCJ], [])
+
+-# _LT_AC_FILE_LTDLL_C
+-# -------------------
+-# Be careful that the start marker always follows a newline.
+-AC_DEFUN([_LT_AC_FILE_LTDLL_C], [
+-# /* ltdll.c starts here */
+-# #define WIN32_LEAN_AND_MEAN
+-# #include <windows.h>
+-# #undef WIN32_LEAN_AND_MEAN
+-# #include <stdio.h>
+-#
+-# #ifndef __CYGWIN__
+-# # ifdef __CYGWIN32__
+-# # define __CYGWIN__ __CYGWIN32__
+-# # endif
+-# #endif
+-#
+-# #ifdef __cplusplus
+-# extern "C" {
+-# #endif
+-# BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved);
+-# #ifdef __cplusplus
+-# }
+-# #endif
+-#
+-# #ifdef __CYGWIN__
+-# #include <cygwin/cygwin_dll.h>
+-# DECLARE_CYGWIN_DLL( DllMain );
+-# #endif
+-# HINSTANCE __hDllInstance_base;
+-#
+-# BOOL APIENTRY
+-# DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved)
+-# {
+-# __hDllInstance_base = hInst;
+-# return TRUE;
+-# }
+-# /* ltdll.c ends here */
+-])# _LT_AC_FILE_LTDLL_C
+
++# LT_PROG_RC
++# ----------
++AC_DEFUN([LT_PROG_RC],
++[AC_CHECK_TOOL(RC, windres,)
++])
+
+-# _LT_AC_TAGVAR(VARNAME, [TAGNAME])
+-# ---------------------------------
+-AC_DEFUN([_LT_AC_TAGVAR], [ifelse([$2], [], [$1], [$1_$2])])
++# Old name:
++AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC])
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([LT_AC_PROG_RC], [])
+
+
+-# old names
+-AC_DEFUN([AM_PROG_LIBTOOL], [AC_PROG_LIBTOOL])
+-AC_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)])
+-AC_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)])
+-AC_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)])
+-AC_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)])
+-AC_DEFUN([AM_PROG_LD], [AC_PROG_LD])
+-AC_DEFUN([AM_PROG_NM], [AC_PROG_NM])
+-
+-# This is just to silence aclocal about the macro not being used
+-ifelse([AC_DISABLE_FAST_INSTALL])
+-
+-AC_DEFUN([LT_AC_PROG_GCJ],
+-[AC_CHECK_TOOL(GCJ, gcj, no)
+- test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2"
+- AC_SUBST(GCJFLAGS)
++# _LT_DECL_EGREP
++# --------------
++# If we don't have a new enough Autoconf to choose the best grep
++# available, choose the one first in the user's PATH.
++m4_defun([_LT_DECL_EGREP],
++[AC_REQUIRE([AC_PROG_EGREP])dnl
++AC_REQUIRE([AC_PROG_FGREP])dnl
++test -z "$GREP" && GREP=grep
++_LT_DECL([], [GREP], [1], [A grep program that handles long lines])
++_LT_DECL([], [EGREP], [1], [An ERE matcher])
++_LT_DECL([], [FGREP], [1], [A literal string matcher])
++dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too
++AC_SUBST([GREP])
+ ])
+
+-AC_DEFUN([LT_AC_PROG_RC],
+-[AC_CHECK_TOOL(RC, windres, no)
+-])
+
++# _LT_DECL_SED
++# ------------
++# Check for a fully-functional sed program, that truncates
++# as few characters as possible. Prefer GNU sed if found.
++m4_defun([_LT_DECL_SED],
++[AC_PROG_SED
++test -z "$SED" && SED=sed
++Xsed="$SED -e 1s/^X//"
++_LT_DECL([], [SED], [1], [A sed program that does not truncate output])
++_LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"],
++ [Sed that helps us avoid accidentally triggering echo(1) options like -n])
++])# _LT_DECL_SED
++
++m4_ifndef([AC_PROG_SED], [
+ ############################################################
+ # NOTE: This macro has been submitted for inclusion into #
+ # GNU Autoconf as AC_PROG_SED. When it is available in #
+ # a released version of Autoconf we should remove this #
+ # macro and use it instead. #
+ ############################################################
+-# LT_AC_PROG_SED
+-# --------------
+-# Check for a fully-functional sed program, that truncates
+-# as few characters as possible. Prefer GNU sed if found.
+-AC_DEFUN([LT_AC_PROG_SED],
++
++m4_defun([AC_PROG_SED],
+ [AC_MSG_CHECKING([for a sed that does not truncate output])
+ AC_CACHE_VAL(lt_cv_path_SED,
+ [# Loop through the user's path and test for sed and gsed.
+@@ -6435,6 +7010,7 @@ do
+ done
+ done
+ done
++IFS=$as_save_IFS
+ lt_ac_max=0
+ lt_ac_count=0
+ # Add /usr/xpg4/bin/sed as it is typically found on Solaris
+@@ -6467,5 +7043,268 @@ for lt_ac_sed in $lt_ac_sed_list /usr/xp
+ done
+ ])
+ SED=$lt_cv_path_SED
++AC_SUBST([SED])
+ AC_MSG_RESULT([$SED])
++])#AC_PROG_SED
++])#m4_ifndef
++
++# Old name:
++AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED])
++dnl aclocal-1.4 backwards compatibility:
++dnl AC_DEFUN([LT_AC_PROG_SED], [])
++
++
++# _LT_CHECK_SHELL_FEATURES
++# ------------------------
++# Find out whether the shell is Bourne or XSI compatible,
++# or has some other useful features.
++m4_defun([_LT_CHECK_SHELL_FEATURES],
++[AC_MSG_CHECKING([whether the shell understands some XSI constructs])
++# Try some XSI features
++xsi_shell=no
++( _lt_dummy="a/b/c"
++ test "${_lt_dummy##*/},${_lt_dummy%/*},"${_lt_dummy%"$_lt_dummy"}, \
++ = c,a/b,, \
++ && eval 'test $(( 1 + 1 )) -eq 2 \
++ && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \
++ && xsi_shell=yes
++AC_MSG_RESULT([$xsi_shell])
++_LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell'])
++
++AC_MSG_CHECKING([whether the shell understands "+="])
++lt_shell_append=no
++( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \
++ >/dev/null 2>&1 \
++ && lt_shell_append=yes
++AC_MSG_RESULT([$lt_shell_append])
++_LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append'])
++
++if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
++ lt_unset=unset
++else
++ lt_unset=false
++fi
++_LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl
++
++# test EBCDIC or ASCII
++case `echo X|tr X '\101'` in
++ A) # ASCII based system
++ # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
++ lt_SP2NL='tr \040 \012'
++ lt_NL2SP='tr \015\012 \040\040'
++ ;;
++ *) # EBCDIC based system
++ lt_SP2NL='tr \100 \n'
++ lt_NL2SP='tr \r\n \100\100'
++ ;;
++esac
++_LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl
++_LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl
++])# _LT_CHECK_SHELL_FEATURES
++
++
++# _LT_PROG_XSI_SHELLFNS
++# ---------------------
++# Bourne and XSI compatible variants of some useful shell functions.
++m4_defun([_LT_PROG_XSI_SHELLFNS],
++[case $xsi_shell in
++ yes)
++ cat << \_LT_EOF >> "$cfgfile"
++
++# func_dirname file append nondir_replacement
++# Compute the dirname of FILE. If nonempty, add APPEND to the result,
++# otherwise set result to NONDIR_REPLACEMENT.
++func_dirname ()
++{
++ case ${1} in
++ */*) func_dirname_result="${1%/*}${2}" ;;
++ * ) func_dirname_result="${3}" ;;
++ esac
++}
++
++# func_basename file
++func_basename ()
++{
++ func_basename_result="${1##*/}"
++}
++
++# func_dirname_and_basename file append nondir_replacement
++# perform func_basename and func_dirname in a single function
++# call:
++# dirname: Compute the dirname of FILE. If nonempty,
++# add APPEND to the result, otherwise set result
++# to NONDIR_REPLACEMENT.
++# value returned in "$func_dirname_result"
++# basename: Compute filename of FILE.
++# value retuned in "$func_basename_result"
++# Implementation must be kept synchronized with func_dirname
++# and func_basename. For efficiency, we do not delegate to
++# those functions but instead duplicate the functionality here.
++func_dirname_and_basename ()
++{
++ case ${1} in
++ */*) func_dirname_result="${1%/*}${2}" ;;
++ * ) func_dirname_result="${3}" ;;
++ esac
++ func_basename_result="${1##*/}"
++}
++
++# func_stripname prefix suffix name
++# strip PREFIX and SUFFIX off of NAME.
++# PREFIX and SUFFIX must not contain globbing or regex special
++# characters, hashes, percent signs, but SUFFIX may contain a leading
++# dot (in which case that matches only a dot).
++func_stripname ()
++{
++ # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
++ # positional parameters, so assign one to ordinary parameter first.
++ func_stripname_result=${3}
++ func_stripname_result=${func_stripname_result#"${1}"}
++ func_stripname_result=${func_stripname_result%"${2}"}
++}
++
++# func_opt_split
++func_opt_split ()
++{
++ func_opt_split_opt=${1%%=*}
++ func_opt_split_arg=${1#*=}
++}
++
++# func_lo2o object
++func_lo2o ()
++{
++ case ${1} in
++ *.lo) func_lo2o_result=${1%.lo}.${objext} ;;
++ *) func_lo2o_result=${1} ;;
++ esac
++}
++
++# func_xform libobj-or-source
++func_xform ()
++{
++ func_xform_result=${1%.*}.lo
++}
++
++# func_arith arithmetic-term...
++func_arith ()
++{
++ func_arith_result=$(( $[*] ))
++}
++
++# func_len string
++# STRING may not start with a hyphen.
++func_len ()
++{
++ func_len_result=${#1}
++}
++
++_LT_EOF
++ ;;
++ *) # Bourne compatible functions.
++ cat << \_LT_EOF >> "$cfgfile"
++
++# func_dirname file append nondir_replacement
++# Compute the dirname of FILE. If nonempty, add APPEND to the result,
++# otherwise set result to NONDIR_REPLACEMENT.
++func_dirname ()
++{
++ # Extract subdirectory from the argument.
++ func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"`
++ if test "X$func_dirname_result" = "X${1}"; then
++ func_dirname_result="${3}"
++ else
++ func_dirname_result="$func_dirname_result${2}"
++ fi
++}
++
++# func_basename file
++func_basename ()
++{
++ func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"`
++}
++
++dnl func_dirname_and_basename
++dnl A portable version of this function is already defined in general.m4sh
++dnl so there is no need for it here.
++
++# func_stripname prefix suffix name
++# strip PREFIX and SUFFIX off of NAME.
++# PREFIX and SUFFIX must not contain globbing or regex special
++# characters, hashes, percent signs, but SUFFIX may contain a leading
++# dot (in which case that matches only a dot).
++# func_strip_suffix prefix name
++func_stripname ()
++{
++ case ${2} in
++ .*) func_stripname_result=`$ECHO "X${3}" \
++ | $Xsed -e "s%^${1}%%" -e "s%\\\\${2}\$%%"`;;
++ *) func_stripname_result=`$ECHO "X${3}" \
++ | $Xsed -e "s%^${1}%%" -e "s%${2}\$%%"`;;
++ esac
++}
++
++# sed scripts:
++my_sed_long_opt='1s/^\(-[[^=]]*\)=.*/\1/;q'
++my_sed_long_arg='1s/^-[[^=]]*=//'
++
++# func_opt_split
++func_opt_split ()
++{
++ func_opt_split_opt=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_opt"`
++ func_opt_split_arg=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_arg"`
++}
++
++# func_lo2o object
++func_lo2o ()
++{
++ func_lo2o_result=`$ECHO "X${1}" | $Xsed -e "$lo2o"`
++}
++
++# func_xform libobj-or-source
++func_xform ()
++{
++ func_xform_result=`$ECHO "X${1}" | $Xsed -e 's/\.[[^.]]*$/.lo/'`
++}
++
++# func_arith arithmetic-term...
++func_arith ()
++{
++ func_arith_result=`expr "$[@]"`
++}
++
++# func_len string
++# STRING may not start with a hyphen.
++func_len ()
++{
++ func_len_result=`expr "$[1]" : ".*" 2>/dev/null || echo $max_cmd_len`
++}
++
++_LT_EOF
++esac
++
++case $lt_shell_append in
++ yes)
++ cat << \_LT_EOF >> "$cfgfile"
++
++# func_append var value
++# Append VALUE to the end of shell variable VAR.
++func_append ()
++{
++ eval "$[1]+=\$[2]"
++}
++_LT_EOF
++ ;;
++ *)
++ cat << \_LT_EOF >> "$cfgfile"
++
++# func_append var value
++# Append VALUE to the end of shell variable VAR.
++func_append ()
++{
++ eval "$[1]=\$$[1]\$[2]"
++}
++
++_LT_EOF
++ ;;
++ esac
+ ])
diff --git a/package/libs/libiconv-full/patches/103-configure_ac_fix.patch b/package/libs/libiconv-full/patches/103-configure_ac_fix.patch
new file mode 100644
index 0000000..d57ae84
--- /dev/null
+++ b/package/libs/libiconv-full/patches/103-configure_ac_fix.patch
@@ -0,0 +1,31 @@
+--- /dev/null
++++ b/Makefile.am
+@@ -0,0 +1,2 @@
++ACLOCAL_AMFLAGS = -I m4
++SUBDIRS = .
+--- /dev/null
++++ b/libcharset/Makefile.am
+@@ -0,0 +1 @@
++ACLOCAL_AMFLAGS = -I m4
+--- a/configure.ac
++++ b/configure.ac
+@@ -54,7 +54,7 @@ AC_ISC_POSIX
+
+ dnl checks for installer options
+
+-AC_RELOCATABLE
++gl_RELOCATABLE
+
+ AC_ARG_ENABLE([extra-encodings],
+ [AC_HELP_STRING([--enable-extra-encodings],
+--- a/libcharset/configure.ac
++++ b/libcharset/configure.ac
+@@ -41,7 +41,7 @@ AC_CANONICAL_HOST
+
+ dnl checks for installer options
+
+-AC_RELOCATABLE_LIBRARY
++gl_RELOCATABLE_LIBRARY
+
+ dnl checks for programs
+
diff --git a/package/libs/libiconv-full/patches/200-work-with-libtool2.patch b/package/libs/libiconv-full/patches/200-work-with-libtool2.patch
new file mode 100644
index 0000000..6e31967
--- /dev/null
+++ b/package/libs/libiconv-full/patches/200-work-with-libtool2.patch
@@ -0,0 +1,17 @@
+Make iconv 1.11.x link correctly with libtool2 - argument "-Xcompiler" ensures "-shared" is passed to $(CC) when used as linker. Otherwise $(CC) tries to create an executable and fails while looking for a main()-function
+
+diff -ruN libiconv-1.11.1/lib/Makefile.in libiconv-1.11.1.mod/lib/Makefile.in
+--- libiconv-1.11.1/lib/Makefile.in 2006-07-14 15:18:42.000000000 +0200
++++ libiconv-1.11.1.mod/lib/Makefile.in 2010-12-01 20:47:57.000000000 +0100
+@@ -70,9 +70,9 @@
+
+ preloadable_libiconv_linux.so : $(SOURCES)
+ if test -n "@GCC@"; then \
+- $(LIBTOOL_LINK) $(CC) $(LDFLAGS) $(INCLUDES) $(CFLAGS) $(CPPFLAGS) $(DEFS) -fPIC -DPIC -DLIBICONV_PLUG $(SOURCES) -shared -o preloadable_libiconv_linux.so; \
++ $(LIBTOOL_LINK) $(CC) $(LDFLAGS) $(INCLUDES) $(CFLAGS) $(CPPFLAGS) $(DEFS) -fPIC -DPIC -DLIBICONV_PLUG $(SOURCES) -Xcompiler -shared -o preloadable_libiconv_linux.so; \
+ else \
+- $(LIBTOOL_LINK) $(CC) $(LDFLAGS) $(INCLUDES) $(CFLAGS) $(CPPFLAGS) $(DEFS) -KPIC -DPIC -DLIBICONV_PLUG $(SOURCES) -shared -o preloadable_libiconv_linux.so; \
++ $(LIBTOOL_LINK) $(CC) $(LDFLAGS) $(INCLUDES) $(CFLAGS) $(CPPFLAGS) $(DEFS) -KPIC -DPIC -DLIBICONV_PLUG $(SOURCES) -Xcompiler -shared -o preloadable_libiconv_linux.so; \
+ fi
+
+ preloadable_libiconv_solaris.so : $(SOURCES)
diff --git a/package/libs/libiconv/.svn/entries b/package/libs/libiconv/.svn/entries
new file mode 100644
index 0000000..0aae4f8
--- /dev/null
+++ b/package/libs/libiconv/.svn/entries
@@ -0,0 +1,133 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs/libiconv
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-02-19T17:22:46.939498Z
+35683
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+src
+dir
+
+COPYING
+file
+
+
+
+
+2013-03-17T12:13:07.000000Z
+dcf3c825659e82539645da41a7908589
+2011-01-01T23:11:48.338490Z
+24870
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+26428
+
+COPYRIGHT
+file
+
+
+
+
+2013-03-17T12:13:07.000000Z
+fd9c6e299f81ee247f1dc10b41506745
+2011-01-01T23:11:48.338490Z
+24870
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+995
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:07.000000Z
+4ac68b40c7be68647d9a6f893de21b4a
+2013-02-19T17:22:46.939498Z
+35683
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2213
+
diff --git a/package/libs/libiconv/.svn/text-base/COPYING.svn-base b/package/libs/libiconv/.svn/text-base/COPYING.svn-base
new file mode 100644
index 0000000..223ede7
--- /dev/null
+++ b/package/libs/libiconv/.svn/text-base/COPYING.svn-base
@@ -0,0 +1,504 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard. To achieve this, non-free programs must be
+allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library. It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the library's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+ <signature of Ty Coon>, 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
+
+
diff --git a/package/libs/libiconv/.svn/text-base/COPYRIGHT.svn-base b/package/libs/libiconv/.svn/text-base/COPYRIGHT.svn-base
new file mode 100644
index 0000000..d228af3
--- /dev/null
+++ b/package/libs/libiconv/.svn/text-base/COPYRIGHT.svn-base
@@ -0,0 +1,20 @@
+Copyright status on all included code:
+
+All files which have no copyright comments are original works
+Copyright (C) 2005-2006 Rich Felker. The decision to exclude such
+comments is intentional, as it should be possible to carry around the
+complete source code on tiny storage media. All public header files
+(include/*) should be treated as Public Domain as they intentionally
+contain no content which can be covered by copyright. Some source
+modules may fall in this category as well. If you believe that a file
+is so trivial that it should be in the Public Domain, please contact
+me and, if I agree, I will explicitly release it from copyright.
+
+Some code has been modified by the OpenWrt project, this includes
+the conversion from char map files to C arrays and the iconv.h header
+file in particular.
+
+The library as a whole is licensed under the GNU LGPL version 2.1.
+See the file COPYING for the text of this license.
+
+The original source can be accessed at svn://svn.mplayerhq.hu/libc/trunk
diff --git a/package/libs/libiconv/.svn/text-base/Makefile.svn-base b/package/libs/libiconv/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..d2f5b7e
--- /dev/null
+++ b/package/libs/libiconv/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,84 @@
+#
+# Copyright (C) 2010-2012 OpenWrt.org
+#
+# This Makefile and the code shipped in src/ is free software, licensed
+# under the GNU Lesser General Public License, version 2.1 and later.
+# See src/COPYING for more information.
+#
+# Refer to src/COPYRIGHT for copyright statements on the source files.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=libiconv
+PKG_RELEASE:=7
+
+PKG_LICENSE:=FREE
+PKG_LICENSE_FILES:=LICENSE
+
+PKG_MAINTAINER:=Jo-Philipp Wich <jow@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/host-build.mk
+
+define Package/libiconv
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=Tiny drop-in replacement for the GNU Character set conversion library
+endef
+
+define Build/Prepare
+ $(INSTALL_DIR) $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+ $(TARGET_CC) $(TARGET_CFLAGS) -c $(PKG_BUILD_DIR)/iconv.c -o $(PKG_BUILD_DIR)/iconv.o -I$(PKG_BUILD_DIR)/include $(FPIC)
+ $(TARGET_CROSS)ar rcs $(PKG_BUILD_DIR)/libiconv.a $(PKG_BUILD_DIR)/iconv.o
+endef
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/lib/libiconv-stub/lib
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/libiconv.a $(1)/usr/lib/libiconv-stub/lib/
+
+ $(INSTALL_DIR) $(1)/usr/lib/libiconv-stub/include
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/include/iconv.h $(1)/usr/lib/libiconv-stub/include/
+
+ $(INSTALL_DIR) $(1)/usr/share/aclocal
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/m4/* $(1)/usr/share/aclocal/
+endef
+
+define Package/libiconv/install
+ $(INSTALL_DIR) $(1)/tmp
+ touch $(1)/tmp/.libiconv-placeholder
+endef
+
+define Host/Prepare
+ mkdir -p $(HOST_BUILD_DIR)
+endef
+
+define Host/Configure
+
+endef
+
+define Host/Compile
+ $(HOSTCC) -c src/iconv.c -o $(HOST_BUILD_DIR)/iconv.o -Isrc/include -fPIC
+ ar rcs $(HOST_BUILD_DIR)/libiconv.a $(HOST_BUILD_DIR)/iconv.o
+endef
+
+define Host/Install
+ $(INSTALL_DIR) $(STAGING_DIR_HOST)/lib
+ $(INSTALL_DATA) $(HOST_BUILD_DIR)/libiconv.a $(STAGING_DIR_HOST)/lib/
+
+ $(INSTALL_DIR) $(STAGING_DIR_HOST)/include
+ $(INSTALL_DATA) ./src/include/iconv.h $(STAGING_DIR_HOST)/include/
+
+ $(INSTALL_DIR) $(STAGING_DIR_HOST)/share/aclocal
+ $(INSTALL_DATA) ./src/m4/* $(STAGING_DIR_HOST)/share/aclocal/
+endef
+
+$(eval $(call HostBuild))
+$(eval $(call BuildPackage,libiconv))
diff --git a/package/libs/libiconv/COPYING b/package/libs/libiconv/COPYING
new file mode 100644
index 0000000..223ede7
--- /dev/null
+++ b/package/libs/libiconv/COPYING
@@ -0,0 +1,504 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard. To achieve this, non-free programs must be
+allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library. It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the library's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+ <signature of Ty Coon>, 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
+
+
diff --git a/package/libs/libiconv/COPYRIGHT b/package/libs/libiconv/COPYRIGHT
new file mode 100644
index 0000000..d228af3
--- /dev/null
+++ b/package/libs/libiconv/COPYRIGHT
@@ -0,0 +1,20 @@
+Copyright status on all included code:
+
+All files which have no copyright comments are original works
+Copyright (C) 2005-2006 Rich Felker. The decision to exclude such
+comments is intentional, as it should be possible to carry around the
+complete source code on tiny storage media. All public header files
+(include/*) should be treated as Public Domain as they intentionally
+contain no content which can be covered by copyright. Some source
+modules may fall in this category as well. If you believe that a file
+is so trivial that it should be in the Public Domain, please contact
+me and, if I agree, I will explicitly release it from copyright.
+
+Some code has been modified by the OpenWrt project, this includes
+the conversion from char map files to C arrays and the iconv.h header
+file in particular.
+
+The library as a whole is licensed under the GNU LGPL version 2.1.
+See the file COPYING for the text of this license.
+
+The original source can be accessed at svn://svn.mplayerhq.hu/libc/trunk
diff --git a/package/libs/libiconv/Makefile b/package/libs/libiconv/Makefile
new file mode 100644
index 0000000..d2f5b7e
--- /dev/null
+++ b/package/libs/libiconv/Makefile
@@ -0,0 +1,84 @@
+#
+# Copyright (C) 2010-2012 OpenWrt.org
+#
+# This Makefile and the code shipped in src/ is free software, licensed
+# under the GNU Lesser General Public License, version 2.1 and later.
+# See src/COPYING for more information.
+#
+# Refer to src/COPYRIGHT for copyright statements on the source files.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=libiconv
+PKG_RELEASE:=7
+
+PKG_LICENSE:=FREE
+PKG_LICENSE_FILES:=LICENSE
+
+PKG_MAINTAINER:=Jo-Philipp Wich <jow@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/host-build.mk
+
+define Package/libiconv
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=Tiny drop-in replacement for the GNU Character set conversion library
+endef
+
+define Build/Prepare
+ $(INSTALL_DIR) $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+ $(TARGET_CC) $(TARGET_CFLAGS) -c $(PKG_BUILD_DIR)/iconv.c -o $(PKG_BUILD_DIR)/iconv.o -I$(PKG_BUILD_DIR)/include $(FPIC)
+ $(TARGET_CROSS)ar rcs $(PKG_BUILD_DIR)/libiconv.a $(PKG_BUILD_DIR)/iconv.o
+endef
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/lib/libiconv-stub/lib
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/libiconv.a $(1)/usr/lib/libiconv-stub/lib/
+
+ $(INSTALL_DIR) $(1)/usr/lib/libiconv-stub/include
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/include/iconv.h $(1)/usr/lib/libiconv-stub/include/
+
+ $(INSTALL_DIR) $(1)/usr/share/aclocal
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/m4/* $(1)/usr/share/aclocal/
+endef
+
+define Package/libiconv/install
+ $(INSTALL_DIR) $(1)/tmp
+ touch $(1)/tmp/.libiconv-placeholder
+endef
+
+define Host/Prepare
+ mkdir -p $(HOST_BUILD_DIR)
+endef
+
+define Host/Configure
+
+endef
+
+define Host/Compile
+ $(HOSTCC) -c src/iconv.c -o $(HOST_BUILD_DIR)/iconv.o -Isrc/include -fPIC
+ ar rcs $(HOST_BUILD_DIR)/libiconv.a $(HOST_BUILD_DIR)/iconv.o
+endef
+
+define Host/Install
+ $(INSTALL_DIR) $(STAGING_DIR_HOST)/lib
+ $(INSTALL_DATA) $(HOST_BUILD_DIR)/libiconv.a $(STAGING_DIR_HOST)/lib/
+
+ $(INSTALL_DIR) $(STAGING_DIR_HOST)/include
+ $(INSTALL_DATA) ./src/include/iconv.h $(STAGING_DIR_HOST)/include/
+
+ $(INSTALL_DIR) $(STAGING_DIR_HOST)/share/aclocal
+ $(INSTALL_DATA) ./src/m4/* $(STAGING_DIR_HOST)/share/aclocal/
+endef
+
+$(eval $(call HostBuild))
+$(eval $(call BuildPackage,libiconv))
diff --git a/package/libs/libiconv/src/.svn/entries b/package/libs/libiconv/src/.svn/entries
new file mode 100644
index 0000000..dcf5a95
--- /dev/null
+++ b/package/libs/libiconv/src/.svn/entries
@@ -0,0 +1,102 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs/libiconv/src
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-19T15:34:28.915431Z
+33861
+hcg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+iconv.c
+file
+
+
+
+
+2013-03-17T12:13:07.000000Z
+b7c08897a3e65d98fdac76a30f9e6ffb
+2012-02-03T15:43:33.394828Z
+30014
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+9235
+
+m4
+dir
+
+LICENSE
+file
+
+
+
+
+2013-03-17T12:13:07.000000Z
+1dc86535707468b2867a82da5361fae2
+2012-10-19T15:34:28.915431Z
+33861
+hcg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+305
+
+include
+dir
+
diff --git a/package/libs/libiconv/src/.svn/text-base/LICENSE.svn-base b/package/libs/libiconv/src/.svn/text-base/LICENSE.svn-base
new file mode 100644
index 0000000..b59e7be
--- /dev/null
+++ b/package/libs/libiconv/src/.svn/text-base/LICENSE.svn-base
@@ -0,0 +1,6 @@
+The source file iconv.m4 contains the following message
+
+Copyright (C) 2000-2002, 2007-2010 Free Software Foundation, Inc.
+This file is free software; the Free Software Foundation
+gives unlimited permission to copy and/or distribute it,
+with or without modifications, as long as this notice is preserved.
diff --git a/package/libs/libiconv/src/.svn/text-base/iconv.c.svn-base b/package/libs/libiconv/src/.svn/text-base/iconv.c.svn-base
new file mode 100644
index 0000000..cb4e947
--- /dev/null
+++ b/package/libs/libiconv/src/.svn/text-base/iconv.c.svn-base
@@ -0,0 +1,440 @@
+#include <iconv.h>
+#include <errno.h>
+#include <wchar.h>
+#include <string.h>
+#include <strings.h>
+#include <stdlib.h>
+#include <limits.h>
+
+#include <dirent.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <stdint.h>
+
+/* builtin charmaps */
+#include "charmaps.h"
+
+/* only 0-7 are valid as dest charset */
+#define UTF_16BE 000
+#define UTF_16LE 001
+#define UTF_32BE 002
+#define UTF_32LE 003
+#define WCHAR_T 004
+#define UTF_8 005
+#define US_ASCII 006
+#define LATIN_1 007
+
+/* additional charsets with algorithmic conversion */
+#define LATIN_9 010
+#define TIS_620 011
+#define JIS_0201 012
+
+/* some programs like php need this */
+int _libiconv_version = _LIBICONV_VERSION;
+
+/* these must match the constants above */
+static const unsigned char charsets[] =
+ "\005" "UTF-8" "\0"
+ "\004" "WCHAR_T" "\0"
+ "\000" "UTF-16BE" "\0"
+ "\001" "UTF-16LE" "\0"
+ "\002" "UTF-32BE" "\0"
+ "\003" "UTF-32LE" "\0"
+ "\006" "ASCII" "\0"
+ "\006" "US-ASCII" "\0"
+ "\007" "ISO-8859-1" "\0"
+ "\007" "LATIN1" "\0"
+ "\010" "ISO-8859-15""\0"
+ "\010" "LATIN9" "\0"
+ "\011" "ISO-8859-11""\0"
+ "\011" "TIS-620" "\0"
+ "\012" "JIS-0201" "\0"
+ "\377";
+
+/* separate identifiers for sbcs/dbcs/etc map type */
+#define UCS2_8BIT 000
+#define UCS3_8BIT 001
+#define EUC 002
+#define EUC_TW 003
+#define SHIFT_JIS 004
+#define BIG5 005
+#define GBK 006
+
+/* FIXME: these are not implemented yet
+// EUC: A1-FE A1-FE
+// GBK: 81-FE 40-7E,80-FE
+// Big5: A1-FE 40-7E,A1-FE
+*/
+
+static const unsigned short maplen[] = {
+ [UCS2_8BIT] = 4+ 2* 128,
+ [UCS3_8BIT] = 4+ 3* 128,
+ [EUC] = 4+ 2* 94*94,
+ [SHIFT_JIS] = 4+ 2* 94*94,
+ [BIG5] = 4+ 2* 94*157,
+ [GBK] = 4+ 2* 126*190,
+ [EUC_TW] = 4+ 2* 2*94*94,
+};
+
+static int find_charmap(const char *name)
+{
+ int i;
+ for (i = 0; i < (sizeof(charmaps) / sizeof(charmaps[0])); i++)
+ if (!strcasecmp(charmaps[i].name, name))
+ return i;
+ return -1;
+}
+
+static int find_charset(const char *name)
+{
+ const unsigned char *s;
+ for (s=charsets; *s<0xff && strcasecmp(s+1, name); s+=strlen(s)+1);
+ return *s;
+}
+
+iconv_t iconv_open(const char *to, const char *from)
+{
+ unsigned f, t;
+ int m;
+
+ if ((t = find_charset(to)) > 8)
+ return -1;
+
+ if ((f = find_charset(from)) < 255)
+ return 0 | (t<<1) | (f<<8);
+
+ if ((m = find_charmap(from)) > -1)
+ return 1 | (t<<1) | (m<<8);
+
+ return -1;
+}
+
+int iconv_close(iconv_t cd)
+{
+ return 0;
+}
+
+static inline wchar_t get_16(const unsigned char *s, int endian)
+{
+ endian &= 1;
+ return s[endian]<<8 | s[endian^1];
+}
+
+static inline void put_16(unsigned char *s, wchar_t c, int endian)
+{
+ endian &= 1;
+ s[endian] = c>>8;
+ s[endian^1] = c;
+}
+
+static inline int utf8enc_wchar(char *outb, wchar_t c)
+{
+ if (c <= 0x7F) {
+ *outb = c;
+ return 1;
+ }
+ else if (c <= 0x7FF) {
+ *outb++ = ((c >> 6) & 0x1F) | 0xC0;
+ *outb++ = ( c & 0x3F) | 0x80;
+ return 2;
+ }
+ else if (c <= 0xFFFF) {
+ *outb++ = ((c >> 12) & 0x0F) | 0xE0;
+ *outb++ = ((c >> 6) & 0x3F) | 0x80;
+ *outb++ = ( c & 0x3F) | 0x80;
+ return 3;
+ }
+ else if (c <= 0x10FFFF) {
+ *outb++ = ((c >> 18) & 0x07) | 0xF0;
+ *outb++ = ((c >> 12) & 0x3F) | 0x80;
+ *outb++ = ((c >> 6) & 0x3F) | 0x80;
+ *outb++ = ( c & 0x3F) | 0x80;
+ return 4;
+ }
+ else {
+ *outb++ = '?';
+ return 1;
+ }
+}
+
+static inline int utf8seq_is_overlong(char *s, int n)
+{
+ switch (n)
+ {
+ case 2:
+ /* 1100000x (10xxxxxx) */
+ return (((*s >> 1) == 0x60) &&
+ ((*(s+1) >> 6) == 0x02));
+
+ case 3:
+ /* 11100000 100xxxxx (10xxxxxx) */
+ return ((*s == 0xE0) &&
+ ((*(s+1) >> 5) == 0x04) &&
+ ((*(s+2) >> 6) == 0x02));
+
+ case 4:
+ /* 11110000 1000xxxx (10xxxxxx 10xxxxxx) */
+ return ((*s == 0xF0) &&
+ ((*(s+1) >> 4) == 0x08) &&
+ ((*(s+2) >> 6) == 0x02) &&
+ ((*(s+3) >> 6) == 0x02));
+ }
+
+ return 0;
+}
+
+static inline int utf8seq_is_surrogate(char *s, int n)
+{
+ return ((n == 3) && (*s == 0xED) && (*(s+1) >= 0xA0) && (*(s+1) <= 0xBF));
+}
+
+static inline int utf8seq_is_illegal(char *s, int n)
+{
+ return ((n == 3) && (*s == 0xEF) && (*(s+1) == 0xBF) &&
+ (*(s+2) >= 0xBE) && (*(s+2) <= 0xBF));
+}
+
+static inline int utf8dec_wchar(wchar_t *c, unsigned char *in, size_t inb)
+{
+ int i;
+ int n = -1;
+
+ /* trivial char */
+ if (*in <= 0x7F) {
+ *c = *in;
+ return 1;
+ }
+
+ /* find utf8 sequence length */
+ if ((*in & 0xE0) == 0xC0) n = 2;
+ else if ((*in & 0xF0) == 0xE0) n = 3;
+ else if ((*in & 0xF8) == 0xF0) n = 4;
+ else if ((*in & 0xFC) == 0xF8) n = 5;
+ else if ((*in & 0xFE) == 0xFC) n = 6;
+
+ /* starved? */
+ if (n > inb)
+ return -2;
+
+ /* decode ... */
+ if (n > 1 && n < 5) {
+ /* reject invalid sequences */
+ if (utf8seq_is_overlong(in, n) ||
+ utf8seq_is_surrogate(in, n) ||
+ utf8seq_is_illegal(in, n))
+ return -1;
+
+ /* decode ... */
+ *c = (char)(*in++ & (0x7F >> n));
+
+ for (i = 1; i < n; i++) {
+ /* illegal continuation byte */
+ if (*in < 0x80 || *in > 0xBF)
+ return -1;
+
+ *c = (*c << 6) | (*in++ & 0x3F);
+ }
+
+ return n;
+ }
+
+ /* unmapped sequence (> 4) */
+ return -1;
+}
+
+static inline char latin9_translit(wchar_t c)
+{
+ /* a number of trivial iso-8859-15 <> utf-8 transliterations */
+ switch (c) {
+ case 0x20AC: return 0xA4; /* Euro */
+ case 0x0160: return 0xA6; /* S caron */
+ case 0x0161: return 0xA8; /* s caron */
+ case 0x017D: return 0xB4; /* Z caron */
+ case 0x017E: return 0xB8; /* z caron */
+ case 0x0152: return 0xBC; /* OE */
+ case 0x0153: return 0xBD; /* oe */
+ case 0x0178: return 0xBE; /* Y diaeresis */
+ default: return '?';
+ }
+}
+
+size_t iconv(iconv_t cd, char **in, size_t *inb, char **out, size_t *outb)
+{
+ size_t x=0;
+ unsigned char to = (cd>>1)&127;
+ unsigned char from = 255;
+ const unsigned char *map = 0;
+ char tmp[MB_LEN_MAX];
+ wchar_t c, d;
+ size_t k, l;
+ int err;
+
+ if (!in || !*in || !*inb) return 0;
+
+ if (cd & 1)
+ map = charmaps[cd>>8].map;
+ else
+ from = cd>>8;
+
+ for (; *inb; *in+=l, *inb-=l) {
+ c = *(unsigned char *)*in;
+ l = 1;
+ if (from >= UTF_8 && c < 0x80) goto charok;
+ switch (from) {
+ case WCHAR_T:
+ l = sizeof(wchar_t);
+ if (*inb < l) goto starved;
+ c = *(wchar_t *)*in;
+ break;
+ case UTF_8:
+ l = utf8dec_wchar(&c, *in, *inb);
+ if (!l) l++;
+ else if (l == (size_t)-1) goto ilseq;
+ else if (l == (size_t)-2) goto starved;
+ break;
+ case US_ASCII:
+ goto ilseq;
+ case LATIN_9:
+ if ((unsigned)c - 0xa4 <= 0xbe - 0xa4) {
+ static const unsigned char map[] = {
+ 0, 0x60, 0, 0x61, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x7d, 0, 0, 0, 0x7e, 0, 0, 0,
+ 0x52, 0x53, 0x78
+ };
+ if (c == 0xa4) c = 0x20ac;
+ else if (map[c-0xa5]) c = 0x100 | map[c-0xa5];
+ }
+ case LATIN_1:
+ goto charok;
+ case TIS_620:
+ if (c >= 0xa1) c += 0x0e01-0xa1;
+ goto charok;
+ case JIS_0201:
+ if (c >= 0xa1) {
+ if (c <= 0xdf) c += 0xff61-0xa1;
+ else goto ilseq;
+ }
+ goto charok;
+ case UTF_16BE:
+ case UTF_16LE:
+ l = 2;
+ if (*inb < 2) goto starved;
+ c = get_16(*in, from);
+ if ((unsigned)(c-0xdc00) < 0x400) goto ilseq;
+ if ((unsigned)(c-0xd800) < 0x400) {
+ l = 4;
+ if (*inb < 4) goto starved;
+ d = get_16(*in + 2, from);
+ if ((unsigned)(c-0xdc00) >= 0x400) goto ilseq;
+ c = ((c-0xd800)<<10) | (d-0xdc00);
+ }
+ break;
+ case UTF_32BE:
+ case UTF_32LE:
+ l = 4;
+ if (*inb < 4) goto starved;
+ // FIXME
+ // c = get_32(*in, from);
+ break;
+ default:
+ /* only support ascii supersets */
+ if (c < 0x80) break;
+ switch (map[0]) {
+ case UCS2_8BIT:
+ c -= 0x80;
+ break;
+ case EUC:
+ if ((unsigned)c - 0xa1 >= 94) goto ilseq;
+ if ((unsigned)in[0][1] - 0xa1 >= 94) goto ilseq;
+ c = (c-0xa1)*94 + (in[0][1]-0xa1);
+ l = 2;
+ break;
+ case SHIFT_JIS:
+ if ((unsigned)c - 0xa1 <= 0xdf-0xa1) {
+ c += 0xff61-0xa1;
+ goto charok;
+ }
+ // FIXME...
+ l = 2;
+ break;
+ default:
+ goto badf;
+ }
+ c = get_16(map + 4 + 2*c, 0);
+ if (c == 0xffff) goto ilseq;
+ goto charok;
+ }
+
+ if ((unsigned)c - 0xd800 < 0x800 || (unsigned)c >= 0x110000)
+ goto ilseq;
+charok:
+ switch (to) {
+ case WCHAR_T:
+ if (*outb < sizeof(wchar_t)) goto toobig;
+ *(wchar_t *)*out = c;
+ *out += sizeof(wchar_t);
+ *outb -= sizeof(wchar_t);
+ break;
+ case UTF_8:
+ if (*outb < 4) {
+ k = utf8enc_wchar(tmp, c);
+ if (*outb < k) goto toobig;
+ memcpy(*out, tmp, k);
+ } else k = utf8enc_wchar(*out, c);
+ *out += k;
+ *outb -= k;
+ break;
+ case US_ASCII:
+ if (c > 0x7f) c = 0xfffd;
+ /* fall thru and count replacement in latin1 case */
+ case LATIN_9:
+ if (c >= 0x100 && c != 0xfffd)
+ c = latin9_translit(c);
+ /* fall through */
+ case LATIN_1:
+ if (!*outb) goto toobig;
+ if (c < 0x100) **out = c;
+ else x++, **out = '*'; //FIXME: translit?
+ ++*out;
+ --*outb;
+ break;
+ case UTF_16BE:
+ case UTF_16LE:
+ if (c < 0x10000) {
+ if (*outb < 2) goto toobig;
+ put_16(*out, c, to);
+ *out += 2;
+ *outb -= 2;
+ break;
+ }
+ if (*outb < 4) goto toobig;
+ put_16(*out, (c>>10)|0xd800, to);
+ put_16(*out + 2, (c&0x3ff)|0xdc00, to);
+ *out += 4;
+ *outb -= 4;
+ break;
+ default:
+ goto badf;
+ }
+ }
+ return x;
+ilseq:
+ err = EILSEQ;
+ x = -1;
+ goto end;
+badf:
+ err = EBADF;
+ x = -1;
+ goto end;
+toobig:
+ err = E2BIG;
+ x = -1;
+ goto end;
+starved:
+ err = EINVAL;
+end:
+ errno = err;
+ return x;
+}
diff --git a/package/libs/libiconv/src/LICENSE b/package/libs/libiconv/src/LICENSE
new file mode 100644
index 0000000..b59e7be
--- /dev/null
+++ b/package/libs/libiconv/src/LICENSE
@@ -0,0 +1,6 @@
+The source file iconv.m4 contains the following message
+
+Copyright (C) 2000-2002, 2007-2010 Free Software Foundation, Inc.
+This file is free software; the Free Software Foundation
+gives unlimited permission to copy and/or distribute it,
+with or without modifications, as long as this notice is preserved.
diff --git a/package/libs/libiconv/src/iconv.c b/package/libs/libiconv/src/iconv.c
new file mode 100644
index 0000000..cb4e947
--- /dev/null
+++ b/package/libs/libiconv/src/iconv.c
@@ -0,0 +1,440 @@
+#include <iconv.h>
+#include <errno.h>
+#include <wchar.h>
+#include <string.h>
+#include <strings.h>
+#include <stdlib.h>
+#include <limits.h>
+
+#include <dirent.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <stdint.h>
+
+/* builtin charmaps */
+#include "charmaps.h"
+
+/* only 0-7 are valid as dest charset */
+#define UTF_16BE 000
+#define UTF_16LE 001
+#define UTF_32BE 002
+#define UTF_32LE 003
+#define WCHAR_T 004
+#define UTF_8 005
+#define US_ASCII 006
+#define LATIN_1 007
+
+/* additional charsets with algorithmic conversion */
+#define LATIN_9 010
+#define TIS_620 011
+#define JIS_0201 012
+
+/* some programs like php need this */
+int _libiconv_version = _LIBICONV_VERSION;
+
+/* these must match the constants above */
+static const unsigned char charsets[] =
+ "\005" "UTF-8" "\0"
+ "\004" "WCHAR_T" "\0"
+ "\000" "UTF-16BE" "\0"
+ "\001" "UTF-16LE" "\0"
+ "\002" "UTF-32BE" "\0"
+ "\003" "UTF-32LE" "\0"
+ "\006" "ASCII" "\0"
+ "\006" "US-ASCII" "\0"
+ "\007" "ISO-8859-1" "\0"
+ "\007" "LATIN1" "\0"
+ "\010" "ISO-8859-15""\0"
+ "\010" "LATIN9" "\0"
+ "\011" "ISO-8859-11""\0"
+ "\011" "TIS-620" "\0"
+ "\012" "JIS-0201" "\0"
+ "\377";
+
+/* separate identifiers for sbcs/dbcs/etc map type */
+#define UCS2_8BIT 000
+#define UCS3_8BIT 001
+#define EUC 002
+#define EUC_TW 003
+#define SHIFT_JIS 004
+#define BIG5 005
+#define GBK 006
+
+/* FIXME: these are not implemented yet
+// EUC: A1-FE A1-FE
+// GBK: 81-FE 40-7E,80-FE
+// Big5: A1-FE 40-7E,A1-FE
+*/
+
+static const unsigned short maplen[] = {
+ [UCS2_8BIT] = 4+ 2* 128,
+ [UCS3_8BIT] = 4+ 3* 128,
+ [EUC] = 4+ 2* 94*94,
+ [SHIFT_JIS] = 4+ 2* 94*94,
+ [BIG5] = 4+ 2* 94*157,
+ [GBK] = 4+ 2* 126*190,
+ [EUC_TW] = 4+ 2* 2*94*94,
+};
+
+static int find_charmap(const char *name)
+{
+ int i;
+ for (i = 0; i < (sizeof(charmaps) / sizeof(charmaps[0])); i++)
+ if (!strcasecmp(charmaps[i].name, name))
+ return i;
+ return -1;
+}
+
+static int find_charset(const char *name)
+{
+ const unsigned char *s;
+ for (s=charsets; *s<0xff && strcasecmp(s+1, name); s+=strlen(s)+1);
+ return *s;
+}
+
+iconv_t iconv_open(const char *to, const char *from)
+{
+ unsigned f, t;
+ int m;
+
+ if ((t = find_charset(to)) > 8)
+ return -1;
+
+ if ((f = find_charset(from)) < 255)
+ return 0 | (t<<1) | (f<<8);
+
+ if ((m = find_charmap(from)) > -1)
+ return 1 | (t<<1) | (m<<8);
+
+ return -1;
+}
+
+int iconv_close(iconv_t cd)
+{
+ return 0;
+}
+
+static inline wchar_t get_16(const unsigned char *s, int endian)
+{
+ endian &= 1;
+ return s[endian]<<8 | s[endian^1];
+}
+
+static inline void put_16(unsigned char *s, wchar_t c, int endian)
+{
+ endian &= 1;
+ s[endian] = c>>8;
+ s[endian^1] = c;
+}
+
+static inline int utf8enc_wchar(char *outb, wchar_t c)
+{
+ if (c <= 0x7F) {
+ *outb = c;
+ return 1;
+ }
+ else if (c <= 0x7FF) {
+ *outb++ = ((c >> 6) & 0x1F) | 0xC0;
+ *outb++ = ( c & 0x3F) | 0x80;
+ return 2;
+ }
+ else if (c <= 0xFFFF) {
+ *outb++ = ((c >> 12) & 0x0F) | 0xE0;
+ *outb++ = ((c >> 6) & 0x3F) | 0x80;
+ *outb++ = ( c & 0x3F) | 0x80;
+ return 3;
+ }
+ else if (c <= 0x10FFFF) {
+ *outb++ = ((c >> 18) & 0x07) | 0xF0;
+ *outb++ = ((c >> 12) & 0x3F) | 0x80;
+ *outb++ = ((c >> 6) & 0x3F) | 0x80;
+ *outb++ = ( c & 0x3F) | 0x80;
+ return 4;
+ }
+ else {
+ *outb++ = '?';
+ return 1;
+ }
+}
+
+static inline int utf8seq_is_overlong(char *s, int n)
+{
+ switch (n)
+ {
+ case 2:
+ /* 1100000x (10xxxxxx) */
+ return (((*s >> 1) == 0x60) &&
+ ((*(s+1) >> 6) == 0x02));
+
+ case 3:
+ /* 11100000 100xxxxx (10xxxxxx) */
+ return ((*s == 0xE0) &&
+ ((*(s+1) >> 5) == 0x04) &&
+ ((*(s+2) >> 6) == 0x02));
+
+ case 4:
+ /* 11110000 1000xxxx (10xxxxxx 10xxxxxx) */
+ return ((*s == 0xF0) &&
+ ((*(s+1) >> 4) == 0x08) &&
+ ((*(s+2) >> 6) == 0x02) &&
+ ((*(s+3) >> 6) == 0x02));
+ }
+
+ return 0;
+}
+
+static inline int utf8seq_is_surrogate(char *s, int n)
+{
+ return ((n == 3) && (*s == 0xED) && (*(s+1) >= 0xA0) && (*(s+1) <= 0xBF));
+}
+
+static inline int utf8seq_is_illegal(char *s, int n)
+{
+ return ((n == 3) && (*s == 0xEF) && (*(s+1) == 0xBF) &&
+ (*(s+2) >= 0xBE) && (*(s+2) <= 0xBF));
+}
+
+static inline int utf8dec_wchar(wchar_t *c, unsigned char *in, size_t inb)
+{
+ int i;
+ int n = -1;
+
+ /* trivial char */
+ if (*in <= 0x7F) {
+ *c = *in;
+ return 1;
+ }
+
+ /* find utf8 sequence length */
+ if ((*in & 0xE0) == 0xC0) n = 2;
+ else if ((*in & 0xF0) == 0xE0) n = 3;
+ else if ((*in & 0xF8) == 0xF0) n = 4;
+ else if ((*in & 0xFC) == 0xF8) n = 5;
+ else if ((*in & 0xFE) == 0xFC) n = 6;
+
+ /* starved? */
+ if (n > inb)
+ return -2;
+
+ /* decode ... */
+ if (n > 1 && n < 5) {
+ /* reject invalid sequences */
+ if (utf8seq_is_overlong(in, n) ||
+ utf8seq_is_surrogate(in, n) ||
+ utf8seq_is_illegal(in, n))
+ return -1;
+
+ /* decode ... */
+ *c = (char)(*in++ & (0x7F >> n));
+
+ for (i = 1; i < n; i++) {
+ /* illegal continuation byte */
+ if (*in < 0x80 || *in > 0xBF)
+ return -1;
+
+ *c = (*c << 6) | (*in++ & 0x3F);
+ }
+
+ return n;
+ }
+
+ /* unmapped sequence (> 4) */
+ return -1;
+}
+
+static inline char latin9_translit(wchar_t c)
+{
+ /* a number of trivial iso-8859-15 <> utf-8 transliterations */
+ switch (c) {
+ case 0x20AC: return 0xA4; /* Euro */
+ case 0x0160: return 0xA6; /* S caron */
+ case 0x0161: return 0xA8; /* s caron */
+ case 0x017D: return 0xB4; /* Z caron */
+ case 0x017E: return 0xB8; /* z caron */
+ case 0x0152: return 0xBC; /* OE */
+ case 0x0153: return 0xBD; /* oe */
+ case 0x0178: return 0xBE; /* Y diaeresis */
+ default: return '?';
+ }
+}
+
+size_t iconv(iconv_t cd, char **in, size_t *inb, char **out, size_t *outb)
+{
+ size_t x=0;
+ unsigned char to = (cd>>1)&127;
+ unsigned char from = 255;
+ const unsigned char *map = 0;
+ char tmp[MB_LEN_MAX];
+ wchar_t c, d;
+ size_t k, l;
+ int err;
+
+ if (!in || !*in || !*inb) return 0;
+
+ if (cd & 1)
+ map = charmaps[cd>>8].map;
+ else
+ from = cd>>8;
+
+ for (; *inb; *in+=l, *inb-=l) {
+ c = *(unsigned char *)*in;
+ l = 1;
+ if (from >= UTF_8 && c < 0x80) goto charok;
+ switch (from) {
+ case WCHAR_T:
+ l = sizeof(wchar_t);
+ if (*inb < l) goto starved;
+ c = *(wchar_t *)*in;
+ break;
+ case UTF_8:
+ l = utf8dec_wchar(&c, *in, *inb);
+ if (!l) l++;
+ else if (l == (size_t)-1) goto ilseq;
+ else if (l == (size_t)-2) goto starved;
+ break;
+ case US_ASCII:
+ goto ilseq;
+ case LATIN_9:
+ if ((unsigned)c - 0xa4 <= 0xbe - 0xa4) {
+ static const unsigned char map[] = {
+ 0, 0x60, 0, 0x61, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x7d, 0, 0, 0, 0x7e, 0, 0, 0,
+ 0x52, 0x53, 0x78
+ };
+ if (c == 0xa4) c = 0x20ac;
+ else if (map[c-0xa5]) c = 0x100 | map[c-0xa5];
+ }
+ case LATIN_1:
+ goto charok;
+ case TIS_620:
+ if (c >= 0xa1) c += 0x0e01-0xa1;
+ goto charok;
+ case JIS_0201:
+ if (c >= 0xa1) {
+ if (c <= 0xdf) c += 0xff61-0xa1;
+ else goto ilseq;
+ }
+ goto charok;
+ case UTF_16BE:
+ case UTF_16LE:
+ l = 2;
+ if (*inb < 2) goto starved;
+ c = get_16(*in, from);
+ if ((unsigned)(c-0xdc00) < 0x400) goto ilseq;
+ if ((unsigned)(c-0xd800) < 0x400) {
+ l = 4;
+ if (*inb < 4) goto starved;
+ d = get_16(*in + 2, from);
+ if ((unsigned)(c-0xdc00) >= 0x400) goto ilseq;
+ c = ((c-0xd800)<<10) | (d-0xdc00);
+ }
+ break;
+ case UTF_32BE:
+ case UTF_32LE:
+ l = 4;
+ if (*inb < 4) goto starved;
+ // FIXME
+ // c = get_32(*in, from);
+ break;
+ default:
+ /* only support ascii supersets */
+ if (c < 0x80) break;
+ switch (map[0]) {
+ case UCS2_8BIT:
+ c -= 0x80;
+ break;
+ case EUC:
+ if ((unsigned)c - 0xa1 >= 94) goto ilseq;
+ if ((unsigned)in[0][1] - 0xa1 >= 94) goto ilseq;
+ c = (c-0xa1)*94 + (in[0][1]-0xa1);
+ l = 2;
+ break;
+ case SHIFT_JIS:
+ if ((unsigned)c - 0xa1 <= 0xdf-0xa1) {
+ c += 0xff61-0xa1;
+ goto charok;
+ }
+ // FIXME...
+ l = 2;
+ break;
+ default:
+ goto badf;
+ }
+ c = get_16(map + 4 + 2*c, 0);
+ if (c == 0xffff) goto ilseq;
+ goto charok;
+ }
+
+ if ((unsigned)c - 0xd800 < 0x800 || (unsigned)c >= 0x110000)
+ goto ilseq;
+charok:
+ switch (to) {
+ case WCHAR_T:
+ if (*outb < sizeof(wchar_t)) goto toobig;
+ *(wchar_t *)*out = c;
+ *out += sizeof(wchar_t);
+ *outb -= sizeof(wchar_t);
+ break;
+ case UTF_8:
+ if (*outb < 4) {
+ k = utf8enc_wchar(tmp, c);
+ if (*outb < k) goto toobig;
+ memcpy(*out, tmp, k);
+ } else k = utf8enc_wchar(*out, c);
+ *out += k;
+ *outb -= k;
+ break;
+ case US_ASCII:
+ if (c > 0x7f) c = 0xfffd;
+ /* fall thru and count replacement in latin1 case */
+ case LATIN_9:
+ if (c >= 0x100 && c != 0xfffd)
+ c = latin9_translit(c);
+ /* fall through */
+ case LATIN_1:
+ if (!*outb) goto toobig;
+ if (c < 0x100) **out = c;
+ else x++, **out = '*'; //FIXME: translit?
+ ++*out;
+ --*outb;
+ break;
+ case UTF_16BE:
+ case UTF_16LE:
+ if (c < 0x10000) {
+ if (*outb < 2) goto toobig;
+ put_16(*out, c, to);
+ *out += 2;
+ *outb -= 2;
+ break;
+ }
+ if (*outb < 4) goto toobig;
+ put_16(*out, (c>>10)|0xd800, to);
+ put_16(*out + 2, (c&0x3ff)|0xdc00, to);
+ *out += 4;
+ *outb -= 4;
+ break;
+ default:
+ goto badf;
+ }
+ }
+ return x;
+ilseq:
+ err = EILSEQ;
+ x = -1;
+ goto end;
+badf:
+ err = EBADF;
+ x = -1;
+ goto end;
+toobig:
+ err = E2BIG;
+ x = -1;
+ goto end;
+starved:
+ err = EINVAL;
+end:
+ errno = err;
+ return x;
+}
diff --git a/package/libs/libiconv/src/include/.svn/entries b/package/libs/libiconv/src/include/.svn/entries
new file mode 100644
index 0000000..cf4f442
--- /dev/null
+++ b/package/libs/libiconv/src/include/.svn/entries
@@ -0,0 +1,99 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs/libiconv/src/include
+svn://svn.openwrt.org/openwrt
+
+
+
+2011-02-01T20:31:41.287235Z
+25290
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+charmaps.h
+file
+
+
+
+
+2013-03-17T12:13:07.000000Z
+9bd18fe692885df550ee9ed1e3d3bbde
+2011-01-01T23:11:48.338490Z
+24870
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2268
+
+iconv.h
+file
+
+
+
+
+2013-03-17T12:13:07.000000Z
+56176d1ec37ab95f34c431704ed57c7d
+2011-02-01T20:31:41.287235Z
+25290
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+587
+
+charmaps
+dir
+
diff --git a/package/libs/libiconv/src/include/.svn/text-base/charmaps.h.svn-base b/package/libs/libiconv/src/include/.svn/text-base/charmaps.h.svn-base
new file mode 100644
index 0000000..083cd69
--- /dev/null
+++ b/package/libs/libiconv/src/include/.svn/text-base/charmaps.h.svn-base
@@ -0,0 +1,80 @@
+#include "charmaps/iso-8859-2.h"
+#include "charmaps/iso-8859-10.h"
+#include "charmaps/windows-874.h"
+#include "charmaps/windows-1250.h"
+#include "charmaps/koi8-r.h"
+
+#ifdef ALL_CHARSETS
+#include "charmaps/iso-8859-3.h"
+#include "charmaps/iso-8859-4.h"
+#include "charmaps/iso-8859-5.h"
+#include "charmaps/iso-8859-6.h"
+#include "charmaps/iso-8859-7.h"
+#include "charmaps/iso-8859-8.h"
+#include "charmaps/iso-8859-9.h"
+#include "charmaps/iso-8859-13.h"
+#include "charmaps/iso-8859-14.h"
+#include "charmaps/iso-8859-16.h"
+#include "charmaps/windows-1251.h"
+#include "charmaps/windows-1252.h"
+#include "charmaps/windows-1253.h"
+#include "charmaps/windows-1254.h"
+#include "charmaps/windows-1255.h"
+#include "charmaps/windows-1256.h"
+#include "charmaps/windows-1257.h"
+#include "charmaps/windows-1258.h"
+#endif
+
+
+struct charmap {
+ const char name[13];
+ const unsigned char *map;
+};
+
+static struct charmap charmaps[] = {
+ { "ISO-8859-2", map_iso_8859_2 },
+ { "ISO-8859-10", map_iso_8859_10 },
+
+#ifdef ALL_CHARSETS
+ { "ISO-8859-3", map_iso_8859_3 },
+ { "ISO-8859-4", map_iso_8859_4 },
+ { "ISO-8859-5", map_iso_8859_5 },
+ { "ISO-8859-6", map_iso_8859_6 },
+ { "ISO-8859-7", map_iso_8859_7 },
+ { "ISO-8859-8", map_iso_8859_8 },
+ { "ISO-8859-9", map_iso_8859_9 },
+ { "ISO-8859-13", map_iso_8859_13 },
+ { "ISO-8859-14", map_iso_8859_14 },
+ { "ISO-8859-16", map_iso_8859_16 },
+#endif
+
+ { "WINDOWS-874", map_windows_874 },
+ { "WINDOWS-1250", map_windows_1250 },
+
+#ifdef ALL_CHARSETS
+ { "WINDOWS-1251", map_windows_1251 },
+ { "WINDOWS-1252", map_windows_1252 },
+ { "WINDOWS-1253", map_windows_1253 },
+ { "WINDOWS-1254", map_windows_1254 },
+ { "WINDOWS-1255", map_windows_1255 },
+ { "WINDOWS-1256", map_windows_1256 },
+ { "WINDOWS-1257", map_windows_1257 },
+ { "WINDOWS-1258", map_windows_1258 },
+#endif
+
+ { "KOI8-R", map_koi8_r },
+
+ /* Aliases */
+ { "LATIN2", map_iso_8859_2 },
+ { "LATIN6", map_iso_8859_10 },
+
+#ifdef ALL_CHARSETS
+ { "ARABIC", map_iso_8859_6 },
+ { "CYRILLIC", map_iso_8859_5 },
+ { "GREEK", map_iso_8859_7 },
+ { "HEBREW", map_iso_8859_8 },
+ { "LATIN3", map_iso_8859_3 },
+ { "LATIN4", map_iso_8859_4 },
+ { "LATIN5", map_iso_8859_9 },
+#endif
+};
diff --git a/package/libs/libiconv/src/include/.svn/text-base/iconv.h.svn-base b/package/libs/libiconv/src/include/.svn/text-base/iconv.h.svn-base
new file mode 100644
index 0000000..dfab27f
--- /dev/null
+++ b/package/libs/libiconv/src/include/.svn/text-base/iconv.h.svn-base
@@ -0,0 +1,32 @@
+#ifndef _ICONV_H
+#define _ICONV_H 1
+
+#define _LIBICONV_VERSION 0x010B /* version number: (major<<8) + minor */
+
+#include <stddef.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern int _libiconv_version; /* Likewise */
+
+typedef long iconv_t;
+
+extern iconv_t
+iconv_open(const char *tocode, const char *fromcode);
+
+extern size_t
+iconv(iconv_t cd, char **inbuf, size_t *inbytesleft,
+ char **outbuf, size_t *outbytesleft);
+
+extern int
+iconv_close(iconv_t cd);
+
+#define libiconv_set_relocation_prefix(...) do {} while(0)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _ICONV_H */
diff --git a/package/libs/libiconv/src/include/charmaps.h b/package/libs/libiconv/src/include/charmaps.h
new file mode 100644
index 0000000..083cd69
--- /dev/null
+++ b/package/libs/libiconv/src/include/charmaps.h
@@ -0,0 +1,80 @@
+#include "charmaps/iso-8859-2.h"
+#include "charmaps/iso-8859-10.h"
+#include "charmaps/windows-874.h"
+#include "charmaps/windows-1250.h"
+#include "charmaps/koi8-r.h"
+
+#ifdef ALL_CHARSETS
+#include "charmaps/iso-8859-3.h"
+#include "charmaps/iso-8859-4.h"
+#include "charmaps/iso-8859-5.h"
+#include "charmaps/iso-8859-6.h"
+#include "charmaps/iso-8859-7.h"
+#include "charmaps/iso-8859-8.h"
+#include "charmaps/iso-8859-9.h"
+#include "charmaps/iso-8859-13.h"
+#include "charmaps/iso-8859-14.h"
+#include "charmaps/iso-8859-16.h"
+#include "charmaps/windows-1251.h"
+#include "charmaps/windows-1252.h"
+#include "charmaps/windows-1253.h"
+#include "charmaps/windows-1254.h"
+#include "charmaps/windows-1255.h"
+#include "charmaps/windows-1256.h"
+#include "charmaps/windows-1257.h"
+#include "charmaps/windows-1258.h"
+#endif
+
+
+struct charmap {
+ const char name[13];
+ const unsigned char *map;
+};
+
+static struct charmap charmaps[] = {
+ { "ISO-8859-2", map_iso_8859_2 },
+ { "ISO-8859-10", map_iso_8859_10 },
+
+#ifdef ALL_CHARSETS
+ { "ISO-8859-3", map_iso_8859_3 },
+ { "ISO-8859-4", map_iso_8859_4 },
+ { "ISO-8859-5", map_iso_8859_5 },
+ { "ISO-8859-6", map_iso_8859_6 },
+ { "ISO-8859-7", map_iso_8859_7 },
+ { "ISO-8859-8", map_iso_8859_8 },
+ { "ISO-8859-9", map_iso_8859_9 },
+ { "ISO-8859-13", map_iso_8859_13 },
+ { "ISO-8859-14", map_iso_8859_14 },
+ { "ISO-8859-16", map_iso_8859_16 },
+#endif
+
+ { "WINDOWS-874", map_windows_874 },
+ { "WINDOWS-1250", map_windows_1250 },
+
+#ifdef ALL_CHARSETS
+ { "WINDOWS-1251", map_windows_1251 },
+ { "WINDOWS-1252", map_windows_1252 },
+ { "WINDOWS-1253", map_windows_1253 },
+ { "WINDOWS-1254", map_windows_1254 },
+ { "WINDOWS-1255", map_windows_1255 },
+ { "WINDOWS-1256", map_windows_1256 },
+ { "WINDOWS-1257", map_windows_1257 },
+ { "WINDOWS-1258", map_windows_1258 },
+#endif
+
+ { "KOI8-R", map_koi8_r },
+
+ /* Aliases */
+ { "LATIN2", map_iso_8859_2 },
+ { "LATIN6", map_iso_8859_10 },
+
+#ifdef ALL_CHARSETS
+ { "ARABIC", map_iso_8859_6 },
+ { "CYRILLIC", map_iso_8859_5 },
+ { "GREEK", map_iso_8859_7 },
+ { "HEBREW", map_iso_8859_8 },
+ { "LATIN3", map_iso_8859_3 },
+ { "LATIN4", map_iso_8859_4 },
+ { "LATIN5", map_iso_8859_9 },
+#endif
+};
diff --git a/package/libs/libiconv/src/include/charmaps/.svn/entries b/package/libs/libiconv/src/include/charmaps/.svn/entries
new file mode 100644
index 0000000..3d5ff4d
--- /dev/null
+++ b/package/libs/libiconv/src/include/charmaps/.svn/entries
@@ -0,0 +1,810 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs/libiconv/src/include/charmaps
+svn://svn.openwrt.org/openwrt
+
+
+
+2011-01-01T23:11:48.338490Z
+24870
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+iso-8859-16.h
+file
+
+
+
+
+2013-03-17T12:13:07.000000Z
+80a358de59f578d6e8c9d897d98bba1d
+2011-01-01T23:11:48.338490Z
+24870
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1633
+
+iso-8859-2.h
+file
+
+
+
+
+2013-03-17T12:13:07.000000Z
+05397294d6d2ca669095a7d586599278
+2011-01-01T23:11:48.338490Z
+24870
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1632
+
+iso-8859-3.h
+file
+
+
+
+
+2013-03-17T12:13:07.000000Z
+e161986bcbebeec9ee7138bc6318f55e
+2011-01-01T23:11:48.338490Z
+24870
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1632
+
+iso-8859-4.h
+file
+
+
+
+
+2013-03-17T12:13:07.000000Z
+8cd0715ca198c7d8f5d24592c6c0dd6c
+2011-01-01T23:11:48.338490Z
+24870
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1632
+
+iso-8859-5.h
+file
+
+
+
+
+2013-03-17T12:13:07.000000Z
+d25e40cfafb04f0f6b63b2728a904d26
+2011-01-01T23:11:48.338490Z
+24870
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1632
+
+iso-8859-6.h
+file
+
+
+
+
+2013-03-17T12:13:07.000000Z
+eb46259c93a232f01d51b35ac3a2eebe
+2011-01-01T23:11:48.338490Z
+24870
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1632
+
+koi8-r.h
+file
+
+
+
+
+2013-03-17T12:13:07.000000Z
+1e283b69447178c80f32f9d1ffbd692d
+2011-01-01T23:11:48.338490Z
+24870
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1628
+
+iso-8859-7.h
+file
+
+
+
+
+2013-03-17T12:13:07.000000Z
+61fe1649c327e916b673a2dac4cf62b9
+2011-01-01T23:11:48.338490Z
+24870
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1632
+
+windows-874.h
+file
+
+
+
+
+2013-03-17T12:13:07.000000Z
+5aec0ccf82cf4d56d32dc9eed395f98c
+2011-01-01T23:11:48.338490Z
+24870
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1633
+
+iso-8859-8.h
+file
+
+
+
+
+2013-03-17T12:13:07.000000Z
+a208c4cd0f9692bd8991a7a2ed34cee2
+2011-01-01T23:11:48.338490Z
+24870
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1632
+
+iso-8859-9.h
+file
+
+
+
+
+2013-03-17T12:13:07.000000Z
+dc65fae8ab023975042b120bae1bc76c
+2011-01-01T23:11:48.338490Z
+24870
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1632
+
+windows-1250.h
+file
+
+
+
+
+2013-03-17T12:13:07.000000Z
+37d06f23eed60cab384ca317dbb02a64
+2011-01-01T23:11:48.338490Z
+24870
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1634
+
+windows-1251.h
+file
+
+
+
+
+2013-03-17T12:13:07.000000Z
+83831c53e8e6f48b7b4982bb514345c6
+2011-01-01T23:11:48.338490Z
+24870
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1634
+
+windows-1252.h
+file
+
+
+
+
+2013-03-17T12:13:07.000000Z
+239d356c0bf4858cbae1f0da68baa27a
+2011-01-01T23:11:48.338490Z
+24870
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1635
+
+windows-1253.h
+file
+
+
+
+
+2013-03-17T12:13:07.000000Z
+3e4875cdb3b2dcf356566c77dad8b2c5
+2011-01-01T23:11:48.338490Z
+24870
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1634
+
+windows-1254.h
+file
+
+
+
+
+2013-03-17T12:13:07.000000Z
+b97ec6cddc44532df421678d024eee6f
+2011-01-01T23:11:48.338490Z
+24870
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1634
+
+iso-8859-10.h
+file
+
+
+
+
+2013-03-17T12:13:07.000000Z
+1428b180d66631641b4a8a1944a9f596
+2011-01-01T23:11:48.338490Z
+24870
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1633
+
+windows-1255.h
+file
+
+
+
+
+2013-03-17T12:13:07.000000Z
+5da8d73d8955af18804fae31d4712bd8
+2011-01-01T23:11:48.338490Z
+24870
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1634
+
+windows-1256.h
+file
+
+
+
+
+2013-03-17T12:13:07.000000Z
+ff9fa03dd383160462973cf266486309
+2011-01-01T23:11:48.338490Z
+24870
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1634
+
+windows-1257.h
+file
+
+
+
+
+2013-03-17T12:13:07.000000Z
+75324124f07c9812088faa0cca7f6141
+2011-01-01T23:11:48.338490Z
+24870
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1634
+
+iso-8859-13.h
+file
+
+
+
+
+2013-03-17T12:13:07.000000Z
+731b72fbcc5ef713644d1f6d7f8f0c1b
+2011-01-01T23:11:48.338490Z
+24870
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1633
+
+windows-1258.h
+file
+
+
+
+
+2013-03-17T12:13:07.000000Z
+a8d07080c24b035d83824b27b1415c34
+2011-01-01T23:11:48.338490Z
+24870
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1634
+
+iso-8859-14.h
+file
+
+
+
+
+2013-03-17T12:13:07.000000Z
+85a10631557aa2c195d0c25af69db7f1
+2011-01-01T23:11:48.338490Z
+24870
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1634
+
diff --git a/package/libs/libiconv/src/include/charmaps/.svn/text-base/iso-8859-10.h.svn-base b/package/libs/libiconv/src/include/charmaps/.svn/text-base/iso-8859-10.h.svn-base
new file mode 100644
index 0000000..cb93d02
--- /dev/null
+++ b/package/libs/libiconv/src/include/charmaps/.svn/text-base/iso-8859-10.h.svn-base
@@ -0,0 +1,24 @@
+static const unsigned char map_iso_8859_10[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x81, 0x00, 0x82, 0x00, 0x83,
+ 0x00, 0x84, 0x00, 0x85, 0x00, 0x86, 0x00, 0x87, 0x00, 0x88, 0x00, 0x89,
+ 0x00, 0x8a, 0x00, 0x8b, 0x00, 0x8c, 0x00, 0x8d, 0x00, 0x8e, 0x00, 0x8f,
+ 0x00, 0x90, 0x00, 0x91, 0x00, 0x92, 0x00, 0x93, 0x00, 0x94, 0x00, 0x95,
+ 0x00, 0x96, 0x00, 0x97, 0x00, 0x98, 0x00, 0x99, 0x00, 0x9a, 0x00, 0x9b,
+ 0x00, 0x9c, 0x00, 0x9d, 0x00, 0x9e, 0x00, 0x9f, 0x00, 0xa0, 0x01, 0x04,
+ 0x01, 0x12, 0x01, 0x22, 0x01, 0x2a, 0x01, 0x28, 0x01, 0x36, 0x00, 0xa7,
+ 0x01, 0x3b, 0x01, 0x10, 0x01, 0x60, 0x01, 0x66, 0x01, 0x7d, 0x00, 0xad,
+ 0x01, 0x6a, 0x01, 0x4a, 0x00, 0xb0, 0x01, 0x05, 0x01, 0x13, 0x01, 0x23,
+ 0x01, 0x2b, 0x01, 0x29, 0x01, 0x37, 0x00, 0xb7, 0x01, 0x3c, 0x01, 0x11,
+ 0x01, 0x61, 0x01, 0x67, 0x01, 0x7e, 0x20, 0x15, 0x01, 0x6b, 0x01, 0x4b,
+ 0x01, 0x00, 0x00, 0xc1, 0x00, 0xc2, 0x00, 0xc3, 0x00, 0xc4, 0x00, 0xc5,
+ 0x00, 0xc6, 0x01, 0x2e, 0x01, 0x0c, 0x00, 0xc9, 0x01, 0x18, 0x00, 0xcb,
+ 0x01, 0x16, 0x00, 0xcd, 0x00, 0xce, 0x00, 0xcf, 0x00, 0xd0, 0x01, 0x45,
+ 0x01, 0x4c, 0x00, 0xd3, 0x00, 0xd4, 0x00, 0xd5, 0x00, 0xd6, 0x01, 0x68,
+ 0x00, 0xd8, 0x01, 0x72, 0x00, 0xda, 0x00, 0xdb, 0x00, 0xdc, 0x00, 0xdd,
+ 0x00, 0xde, 0x00, 0xdf, 0x01, 0x01, 0x00, 0xe1, 0x00, 0xe2, 0x00, 0xe3,
+ 0x00, 0xe4, 0x00, 0xe5, 0x00, 0xe6, 0x01, 0x2f, 0x01, 0x0d, 0x00, 0xe9,
+ 0x01, 0x19, 0x00, 0xeb, 0x01, 0x17, 0x00, 0xed, 0x00, 0xee, 0x00, 0xef,
+ 0x00, 0xf0, 0x01, 0x46, 0x01, 0x4d, 0x00, 0xf3, 0x00, 0xf4, 0x00, 0xf5,
+ 0x00, 0xf6, 0x01, 0x69, 0x00, 0xf8, 0x01, 0x73, 0x00, 0xfa, 0x00, 0xfb,
+ 0x00, 0xfc, 0x00, 0xfd, 0x00, 0xfe, 0x01, 0x38
+};
diff --git a/package/libs/libiconv/src/include/charmaps/.svn/text-base/iso-8859-13.h.svn-base b/package/libs/libiconv/src/include/charmaps/.svn/text-base/iso-8859-13.h.svn-base
new file mode 100644
index 0000000..b44d1b4
--- /dev/null
+++ b/package/libs/libiconv/src/include/charmaps/.svn/text-base/iso-8859-13.h.svn-base
@@ -0,0 +1,24 @@
+static const unsigned char map_iso_8859_13[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x81, 0x00, 0x82, 0x00, 0x83,
+ 0x00, 0x84, 0x00, 0x85, 0x00, 0x86, 0x00, 0x87, 0x00, 0x88, 0x00, 0x89,
+ 0x00, 0x8a, 0x00, 0x8b, 0x00, 0x8c, 0x00, 0x8d, 0x00, 0x8e, 0x00, 0x8f,
+ 0x00, 0x90, 0x00, 0x91, 0x00, 0x92, 0x00, 0x93, 0x00, 0x94, 0x00, 0x95,
+ 0x00, 0x96, 0x00, 0x97, 0x00, 0x98, 0x00, 0x99, 0x00, 0x9a, 0x00, 0x9b,
+ 0x00, 0x9c, 0x00, 0x9d, 0x00, 0x9e, 0x00, 0x9f, 0x00, 0xa0, 0x20, 0x1d,
+ 0x00, 0xa2, 0x00, 0xa3, 0x00, 0xa4, 0x20, 0x1e, 0x00, 0xa6, 0x00, 0xa7,
+ 0x00, 0xd8, 0x00, 0xa9, 0x01, 0x56, 0x00, 0xab, 0x00, 0xac, 0x00, 0xad,
+ 0x00, 0xae, 0x00, 0xc6, 0x00, 0xb0, 0x00, 0xb1, 0x00, 0xb2, 0x00, 0xb3,
+ 0x20, 0x1c, 0x00, 0xb5, 0x00, 0xb6, 0x00, 0xb7, 0x00, 0xf8, 0x00, 0xb9,
+ 0x01, 0x57, 0x00, 0xbb, 0x00, 0xbc, 0x00, 0xbd, 0x00, 0xbe, 0x00, 0xe6,
+ 0x01, 0x04, 0x01, 0x2e, 0x01, 0x00, 0x01, 0x06, 0x00, 0xc4, 0x00, 0xc5,
+ 0x01, 0x18, 0x01, 0x12, 0x01, 0x0c, 0x00, 0xc9, 0x01, 0x79, 0x01, 0x16,
+ 0x01, 0x22, 0x01, 0x36, 0x01, 0x2a, 0x01, 0x3b, 0x01, 0x60, 0x01, 0x43,
+ 0x01, 0x45, 0x00, 0xd3, 0x01, 0x4c, 0x00, 0xd5, 0x00, 0xd6, 0x00, 0xd7,
+ 0x01, 0x72, 0x01, 0x41, 0x01, 0x5a, 0x01, 0x6a, 0x00, 0xdc, 0x01, 0x7b,
+ 0x01, 0x7d, 0x00, 0xdf, 0x01, 0x05, 0x01, 0x2f, 0x01, 0x01, 0x01, 0x07,
+ 0x00, 0xe4, 0x00, 0xe5, 0x01, 0x19, 0x01, 0x13, 0x01, 0x0d, 0x00, 0xe9,
+ 0x01, 0x7a, 0x01, 0x17, 0x01, 0x23, 0x01, 0x37, 0x01, 0x2b, 0x01, 0x3c,
+ 0x01, 0x61, 0x01, 0x44, 0x01, 0x46, 0x00, 0xf3, 0x01, 0x4d, 0x00, 0xf5,
+ 0x00, 0xf6, 0x00, 0xf7, 0x01, 0x73, 0x01, 0x42, 0x01, 0x5b, 0x01, 0x6b,
+ 0x00, 0xfc, 0x01, 0x7c, 0x01, 0x7e, 0x20, 0x19
+};
diff --git a/package/libs/libiconv/src/include/charmaps/.svn/text-base/iso-8859-14.h.svn-base b/package/libs/libiconv/src/include/charmaps/.svn/text-base/iso-8859-14.h.svn-base
new file mode 100644
index 0000000..76cead9
--- /dev/null
+++ b/package/libs/libiconv/src/include/charmaps/.svn/text-base/iso-8859-14.h.svn-base
@@ -0,0 +1,25 @@
+static const unsigned char map_iso_8859_14[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x81, 0x00, 0x82, 0x00, 0x83,
+ 0x00, 0x84, 0x00, 0x85, 0x00, 0x86, 0x00, 0x87, 0x00, 0x88, 0x00, 0x89,
+ 0x00, 0x8a, 0x00, 0x8b, 0x00, 0x8c, 0x00, 0x8d, 0x00, 0x8e, 0x00, 0x8f,
+ 0x00, 0x90, 0x00, 0x91, 0x00, 0x92, 0x00, 0x93, 0x00, 0x94, 0x00, 0x95,
+ 0x00, 0x96, 0x00, 0x97, 0x00, 0x98, 0x00, 0x99, 0x00, 0x9a, 0x00, 0x9b,
+ 0x00, 0x9c, 0x00, 0x9d, 0x00, 0x9e, 0x00, 0x9f, 0x00, 0xa0, 0x1e, 0x02,
+ 0x1e, 0x03, 0x00, 0xa3, 0x01, 0x0a, 0x01, 0x0b, 0x1e, 0x0a, 0x00, 0xa7,
+ 0x1e, 0x80, 0x00, 0xa9, 0x1e, 0x82, 0x1e, 0x0b, 0x1e, 0xf2, 0x00, 0xad,
+ 0x00, 0xae, 0x01, 0x78, 0x1e, 0x1e, 0x1e, 0x1f, 0x01, 0x20, 0x01, 0x21,
+ 0x1e, 0x40, 0x1e, 0x41, 0x00, 0xb6, 0x1e, 0x56, 0x1e, 0x81, 0x1e, 0x57,
+ 0x1e, 0x83, 0x1e, 0x60, 0x1e, 0xf3, 0x1e, 0x84, 0x1e, 0x85, 0x1e, 0x61,
+ 0x00, 0xc0, 0x00, 0xc1, 0x00, 0xc2, 0x00, 0xc3, 0x00, 0xc4, 0x00, 0xc5,
+ 0x00, 0xc6, 0x00, 0xc7, 0x00, 0xc8, 0x00, 0xc9, 0x00, 0xca, 0x00, 0xcb,
+ 0x00, 0xcc, 0x00, 0xcd, 0x00, 0xce, 0x00, 0xcf, 0x01, 0x74, 0x00, 0xd1,
+ 0x00, 0xd2, 0x00, 0xd3, 0x00, 0xd4, 0x00, 0xd5, 0x00, 0xd6, 0x1e, 0x6a,
+ 0x00, 0xd8, 0x00, 0xd9, 0x00, 0xda, 0x00, 0xdb, 0x00, 0xdc, 0x00, 0xdd,
+ 0x01, 0x76, 0x00, 0xdf, 0x00, 0xe0, 0x00, 0xe1, 0x00, 0xe2, 0x00, 0xe3,
+ 0x00, 0xe4, 0x00, 0xe5, 0x00, 0xe6, 0x00, 0xe7, 0x00, 0xe8, 0x00, 0xe9,
+ 0x00, 0xea, 0x00, 0xeb, 0x00, 0xec, 0x00, 0xed, 0x00, 0xee, 0x00, 0xef,
+ 0x01, 0x75, 0x00, 0xf1, 0x00, 0xf2, 0x00, 0xf3, 0x00, 0xf4, 0x00, 0xf5,
+ 0x00, 0xf6, 0x1e, 0x6b, 0x00, 0xf8, 0x00, 0xf9, 0x00, 0xfa, 0x00, 0xfb,
+ 0x00, 0xfc, 0x00, 0xfd, 0x01, 0x77, 0x00, 0xff
+};
+
diff --git a/package/libs/libiconv/src/include/charmaps/.svn/text-base/iso-8859-16.h.svn-base b/package/libs/libiconv/src/include/charmaps/.svn/text-base/iso-8859-16.h.svn-base
new file mode 100644
index 0000000..4437a41
--- /dev/null
+++ b/package/libs/libiconv/src/include/charmaps/.svn/text-base/iso-8859-16.h.svn-base
@@ -0,0 +1,24 @@
+static const unsigned char map_iso_8859_16[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x81, 0x00, 0x82, 0x00, 0x83,
+ 0x00, 0x84, 0x00, 0x85, 0x00, 0x86, 0x00, 0x87, 0x00, 0x88, 0x00, 0x89,
+ 0x00, 0x8a, 0x00, 0x8b, 0x00, 0x8c, 0x00, 0x8d, 0x00, 0x8e, 0x00, 0x8f,
+ 0x00, 0x90, 0x00, 0x91, 0x00, 0x92, 0x00, 0x93, 0x00, 0x94, 0x00, 0x95,
+ 0x00, 0x96, 0x00, 0x97, 0x00, 0x98, 0x00, 0x99, 0x00, 0x9a, 0x00, 0x9b,
+ 0x00, 0x9c, 0x00, 0x9d, 0x00, 0x9e, 0x00, 0x9f, 0x00, 0xa0, 0x01, 0x04,
+ 0x01, 0x05, 0x01, 0x41, 0x20, 0xac, 0x20, 0x1e, 0x01, 0x60, 0x00, 0xa7,
+ 0x01, 0x61, 0x00, 0xa9, 0x02, 0x18, 0x00, 0xab, 0x01, 0x79, 0x00, 0xad,
+ 0x01, 0x7a, 0x01, 0x7b, 0x00, 0xb0, 0x00, 0xb1, 0x01, 0x0c, 0x01, 0x42,
+ 0x01, 0x7d, 0x20, 0x1d, 0x00, 0xb6, 0x00, 0xb7, 0x01, 0x7e, 0x01, 0x0d,
+ 0x02, 0x19, 0x00, 0xbb, 0x01, 0x52, 0x01, 0x53, 0x01, 0x78, 0x01, 0x7c,
+ 0x00, 0xc0, 0x00, 0xc1, 0x00, 0xc2, 0x01, 0x02, 0x00, 0xc4, 0x01, 0x06,
+ 0x00, 0xc6, 0x00, 0xc7, 0x00, 0xc8, 0x00, 0xc9, 0x00, 0xca, 0x00, 0xcb,
+ 0x00, 0xcc, 0x00, 0xcd, 0x00, 0xce, 0x00, 0xcf, 0x01, 0x10, 0x01, 0x43,
+ 0x00, 0xd2, 0x00, 0xd3, 0x00, 0xd4, 0x01, 0x50, 0x00, 0xd6, 0x01, 0x5a,
+ 0x01, 0x70, 0x00, 0xd9, 0x00, 0xda, 0x00, 0xdb, 0x00, 0xdc, 0x01, 0x18,
+ 0x02, 0x1a, 0x00, 0xdf, 0x00, 0xe0, 0x00, 0xe1, 0x00, 0xe2, 0x01, 0x03,
+ 0x00, 0xe4, 0x01, 0x07, 0x00, 0xe6, 0x00, 0xe7, 0x00, 0xe8, 0x00, 0xe9,
+ 0x00, 0xea, 0x00, 0xeb, 0x00, 0xec, 0x00, 0xed, 0x00, 0xee, 0x00, 0xef,
+ 0x01, 0x11, 0x01, 0x44, 0x00, 0xf2, 0x00, 0xf3, 0x00, 0xf4, 0x01, 0x51,
+ 0x00, 0xf6, 0x01, 0x5b, 0x01, 0x71, 0x00, 0xf9, 0x00, 0xfa, 0x00, 0xfb,
+ 0x00, 0xfc, 0x01, 0x19, 0x02, 0x1b, 0x00, 0xff
+};
diff --git a/package/libs/libiconv/src/include/charmaps/.svn/text-base/iso-8859-2.h.svn-base b/package/libs/libiconv/src/include/charmaps/.svn/text-base/iso-8859-2.h.svn-base
new file mode 100644
index 0000000..631610e
--- /dev/null
+++ b/package/libs/libiconv/src/include/charmaps/.svn/text-base/iso-8859-2.h.svn-base
@@ -0,0 +1,24 @@
+static const unsigned char map_iso_8859_2[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x81, 0x00, 0x82, 0x00, 0x83,
+ 0x00, 0x84, 0x00, 0x85, 0x00, 0x86, 0x00, 0x87, 0x00, 0x88, 0x00, 0x89,
+ 0x00, 0x8a, 0x00, 0x8b, 0x00, 0x8c, 0x00, 0x8d, 0x00, 0x8e, 0x00, 0x8f,
+ 0x00, 0x90, 0x00, 0x91, 0x00, 0x92, 0x00, 0x93, 0x00, 0x94, 0x00, 0x95,
+ 0x00, 0x96, 0x00, 0x97, 0x00, 0x98, 0x00, 0x99, 0x00, 0x9a, 0x00, 0x9b,
+ 0x00, 0x9c, 0x00, 0x9d, 0x00, 0x9e, 0x00, 0x9f, 0x00, 0xa0, 0x01, 0x04,
+ 0x02, 0xd8, 0x01, 0x41, 0x00, 0xa4, 0x01, 0x3d, 0x01, 0x5a, 0x00, 0xa7,
+ 0x00, 0xa8, 0x01, 0x60, 0x01, 0x5e, 0x01, 0x64, 0x01, 0x79, 0x00, 0xad,
+ 0x01, 0x7d, 0x01, 0x7b, 0x00, 0xb0, 0x01, 0x05, 0x02, 0xdb, 0x01, 0x42,
+ 0x00, 0xb4, 0x01, 0x3e, 0x01, 0x5b, 0x02, 0xc7, 0x00, 0xb8, 0x01, 0x61,
+ 0x01, 0x5f, 0x01, 0x65, 0x01, 0x7a, 0x02, 0xdd, 0x01, 0x7e, 0x01, 0x7c,
+ 0x01, 0x54, 0x00, 0xc1, 0x00, 0xc2, 0x01, 0x02, 0x00, 0xc4, 0x01, 0x39,
+ 0x01, 0x06, 0x00, 0xc7, 0x01, 0x0c, 0x00, 0xc9, 0x01, 0x18, 0x00, 0xcb,
+ 0x01, 0x1a, 0x00, 0xcd, 0x00, 0xce, 0x01, 0x0e, 0x01, 0x10, 0x01, 0x43,
+ 0x01, 0x47, 0x00, 0xd3, 0x00, 0xd4, 0x01, 0x50, 0x00, 0xd6, 0x00, 0xd7,
+ 0x01, 0x58, 0x01, 0x6e, 0x00, 0xda, 0x01, 0x70, 0x00, 0xdc, 0x00, 0xdd,
+ 0x01, 0x62, 0x00, 0xdf, 0x01, 0x55, 0x00, 0xe1, 0x00, 0xe2, 0x01, 0x03,
+ 0x00, 0xe4, 0x01, 0x3a, 0x01, 0x07, 0x00, 0xe7, 0x01, 0x0d, 0x00, 0xe9,
+ 0x01, 0x19, 0x00, 0xeb, 0x01, 0x1b, 0x00, 0xed, 0x00, 0xee, 0x01, 0x0f,
+ 0x01, 0x11, 0x01, 0x44, 0x01, 0x48, 0x00, 0xf3, 0x00, 0xf4, 0x01, 0x51,
+ 0x00, 0xf6, 0x00, 0xf7, 0x01, 0x59, 0x01, 0x6f, 0x00, 0xfa, 0x01, 0x71,
+ 0x00, 0xfc, 0x00, 0xfd, 0x01, 0x63, 0x02, 0xd9
+};
diff --git a/package/libs/libiconv/src/include/charmaps/.svn/text-base/iso-8859-3.h.svn-base b/package/libs/libiconv/src/include/charmaps/.svn/text-base/iso-8859-3.h.svn-base
new file mode 100644
index 0000000..cd76d59
--- /dev/null
+++ b/package/libs/libiconv/src/include/charmaps/.svn/text-base/iso-8859-3.h.svn-base
@@ -0,0 +1,24 @@
+static const unsigned char map_iso_8859_3[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x81, 0x00, 0x82, 0x00, 0x83,
+ 0x00, 0x84, 0x00, 0x85, 0x00, 0x86, 0x00, 0x87, 0x00, 0x88, 0x00, 0x89,
+ 0x00, 0x8a, 0x00, 0x8b, 0x00, 0x8c, 0x00, 0x8d, 0x00, 0x8e, 0x00, 0x8f,
+ 0x00, 0x90, 0x00, 0x91, 0x00, 0x92, 0x00, 0x93, 0x00, 0x94, 0x00, 0x95,
+ 0x00, 0x96, 0x00, 0x97, 0x00, 0x98, 0x00, 0x99, 0x00, 0x9a, 0x00, 0x9b,
+ 0x00, 0x9c, 0x00, 0x9d, 0x00, 0x9e, 0x00, 0x9f, 0x00, 0xa0, 0x01, 0x26,
+ 0x02, 0xd8, 0x00, 0xa3, 0x00, 0xa4, 0xff, 0xff, 0x01, 0x24, 0x00, 0xa7,
+ 0x00, 0xa8, 0x01, 0x30, 0x01, 0x5e, 0x01, 0x1e, 0x01, 0x34, 0x00, 0xad,
+ 0xff, 0xff, 0x01, 0x7b, 0x00, 0xb0, 0x01, 0x27, 0x00, 0xb2, 0x00, 0xb3,
+ 0x00, 0xb4, 0x00, 0xb5, 0x01, 0x25, 0x00, 0xb7, 0x00, 0xb8, 0x01, 0x31,
+ 0x01, 0x5f, 0x01, 0x1f, 0x01, 0x35, 0x00, 0xbd, 0xff, 0xff, 0x01, 0x7c,
+ 0x00, 0xc0, 0x00, 0xc1, 0x00, 0xc2, 0xff, 0xff, 0x00, 0xc4, 0x01, 0x0a,
+ 0x01, 0x08, 0x00, 0xc7, 0x00, 0xc8, 0x00, 0xc9, 0x00, 0xca, 0x00, 0xcb,
+ 0x00, 0xcc, 0x00, 0xcd, 0x00, 0xce, 0x00, 0xcf, 0xff, 0xff, 0x00, 0xd1,
+ 0x00, 0xd2, 0x00, 0xd3, 0x00, 0xd4, 0x01, 0x20, 0x00, 0xd6, 0x00, 0xd7,
+ 0x01, 0x1c, 0x00, 0xd9, 0x00, 0xda, 0x00, 0xdb, 0x00, 0xdc, 0x01, 0x6c,
+ 0x01, 0x5c, 0x00, 0xdf, 0x00, 0xe0, 0x00, 0xe1, 0x00, 0xe2, 0xff, 0xff,
+ 0x00, 0xe4, 0x01, 0x0b, 0x01, 0x09, 0x00, 0xe7, 0x00, 0xe8, 0x00, 0xe9,
+ 0x00, 0xea, 0x00, 0xeb, 0x00, 0xec, 0x00, 0xed, 0x00, 0xee, 0x00, 0xef,
+ 0xff, 0xff, 0x00, 0xf1, 0x00, 0xf2, 0x00, 0xf3, 0x00, 0xf4, 0x01, 0x21,
+ 0x00, 0xf6, 0x00, 0xf7, 0x01, 0x1d, 0x00, 0xf9, 0x00, 0xfa, 0x00, 0xfb,
+ 0x00, 0xfc, 0x01, 0x6d, 0x01, 0x5d, 0x02, 0xd9
+};
diff --git a/package/libs/libiconv/src/include/charmaps/.svn/text-base/iso-8859-4.h.svn-base b/package/libs/libiconv/src/include/charmaps/.svn/text-base/iso-8859-4.h.svn-base
new file mode 100644
index 0000000..5db2f77
--- /dev/null
+++ b/package/libs/libiconv/src/include/charmaps/.svn/text-base/iso-8859-4.h.svn-base
@@ -0,0 +1,24 @@
+static const unsigned char map_iso_8859_4[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x81, 0x00, 0x82, 0x00, 0x83,
+ 0x00, 0x84, 0x00, 0x85, 0x00, 0x86, 0x00, 0x87, 0x00, 0x88, 0x00, 0x89,
+ 0x00, 0x8a, 0x00, 0x8b, 0x00, 0x8c, 0x00, 0x8d, 0x00, 0x8e, 0x00, 0x8f,
+ 0x00, 0x90, 0x00, 0x91, 0x00, 0x92, 0x00, 0x93, 0x00, 0x94, 0x00, 0x95,
+ 0x00, 0x96, 0x00, 0x97, 0x00, 0x98, 0x00, 0x99, 0x00, 0x9a, 0x00, 0x9b,
+ 0x00, 0x9c, 0x00, 0x9d, 0x00, 0x9e, 0x00, 0x9f, 0x00, 0xa0, 0x01, 0x04,
+ 0x01, 0x38, 0x01, 0x56, 0x00, 0xa4, 0x01, 0x28, 0x01, 0x3b, 0x00, 0xa7,
+ 0x00, 0xa8, 0x01, 0x60, 0x01, 0x12, 0x01, 0x22, 0x01, 0x66, 0x00, 0xad,
+ 0x01, 0x7d, 0x00, 0xaf, 0x00, 0xb0, 0x01, 0x05, 0x02, 0xdb, 0x01, 0x57,
+ 0x00, 0xb4, 0x01, 0x29, 0x01, 0x3c, 0x02, 0xc7, 0x00, 0xb8, 0x01, 0x61,
+ 0x01, 0x13, 0x01, 0x23, 0x01, 0x67, 0x01, 0x4a, 0x01, 0x7e, 0x01, 0x4b,
+ 0x01, 0x00, 0x00, 0xc1, 0x00, 0xc2, 0x00, 0xc3, 0x00, 0xc4, 0x00, 0xc5,
+ 0x00, 0xc6, 0x01, 0x2e, 0x01, 0x0c, 0x00, 0xc9, 0x01, 0x18, 0x00, 0xcb,
+ 0x01, 0x16, 0x00, 0xcd, 0x00, 0xce, 0x01, 0x2a, 0x01, 0x10, 0x01, 0x45,
+ 0x01, 0x4c, 0x01, 0x36, 0x00, 0xd4, 0x00, 0xd5, 0x00, 0xd6, 0x00, 0xd7,
+ 0x00, 0xd8, 0x01, 0x72, 0x00, 0xda, 0x00, 0xdb, 0x00, 0xdc, 0x01, 0x68,
+ 0x01, 0x6a, 0x00, 0xdf, 0x01, 0x01, 0x00, 0xe1, 0x00, 0xe2, 0x00, 0xe3,
+ 0x00, 0xe4, 0x00, 0xe5, 0x00, 0xe6, 0x01, 0x2f, 0x01, 0x0d, 0x00, 0xe9,
+ 0x01, 0x19, 0x00, 0xeb, 0x01, 0x17, 0x00, 0xed, 0x00, 0xee, 0x01, 0x2b,
+ 0x01, 0x11, 0x01, 0x46, 0x01, 0x4d, 0x01, 0x37, 0x00, 0xf4, 0x00, 0xf5,
+ 0x00, 0xf6, 0x00, 0xf7, 0x00, 0xf8, 0x01, 0x73, 0x00, 0xfa, 0x00, 0xfb,
+ 0x00, 0xfc, 0x01, 0x69, 0x01, 0x6b, 0x02, 0xd9
+};
diff --git a/package/libs/libiconv/src/include/charmaps/.svn/text-base/iso-8859-5.h.svn-base b/package/libs/libiconv/src/include/charmaps/.svn/text-base/iso-8859-5.h.svn-base
new file mode 100644
index 0000000..d9fe684
--- /dev/null
+++ b/package/libs/libiconv/src/include/charmaps/.svn/text-base/iso-8859-5.h.svn-base
@@ -0,0 +1,24 @@
+static const unsigned char map_iso_8859_5[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x81, 0x00, 0x82, 0x00, 0x83,
+ 0x00, 0x84, 0x00, 0x85, 0x00, 0x86, 0x00, 0x87, 0x00, 0x88, 0x00, 0x89,
+ 0x00, 0x8a, 0x00, 0x8b, 0x00, 0x8c, 0x00, 0x8d, 0x00, 0x8e, 0x00, 0x8f,
+ 0x00, 0x90, 0x00, 0x91, 0x00, 0x92, 0x00, 0x93, 0x00, 0x94, 0x00, 0x95,
+ 0x00, 0x96, 0x00, 0x97, 0x00, 0x98, 0x00, 0x99, 0x00, 0x9a, 0x00, 0x9b,
+ 0x00, 0x9c, 0x00, 0x9d, 0x00, 0x9e, 0x00, 0x9f, 0x00, 0xa0, 0x04, 0x01,
+ 0x04, 0x02, 0x04, 0x03, 0x04, 0x04, 0x04, 0x05, 0x04, 0x06, 0x04, 0x07,
+ 0x04, 0x08, 0x04, 0x09, 0x04, 0x0a, 0x04, 0x0b, 0x04, 0x0c, 0x00, 0xad,
+ 0x04, 0x0e, 0x04, 0x0f, 0x04, 0x10, 0x04, 0x11, 0x04, 0x12, 0x04, 0x13,
+ 0x04, 0x14, 0x04, 0x15, 0x04, 0x16, 0x04, 0x17, 0x04, 0x18, 0x04, 0x19,
+ 0x04, 0x1a, 0x04, 0x1b, 0x04, 0x1c, 0x04, 0x1d, 0x04, 0x1e, 0x04, 0x1f,
+ 0x04, 0x20, 0x04, 0x21, 0x04, 0x22, 0x04, 0x23, 0x04, 0x24, 0x04, 0x25,
+ 0x04, 0x26, 0x04, 0x27, 0x04, 0x28, 0x04, 0x29, 0x04, 0x2a, 0x04, 0x2b,
+ 0x04, 0x2c, 0x04, 0x2d, 0x04, 0x2e, 0x04, 0x2f, 0x04, 0x30, 0x04, 0x31,
+ 0x04, 0x32, 0x04, 0x33, 0x04, 0x34, 0x04, 0x35, 0x04, 0x36, 0x04, 0x37,
+ 0x04, 0x38, 0x04, 0x39, 0x04, 0x3a, 0x04, 0x3b, 0x04, 0x3c, 0x04, 0x3d,
+ 0x04, 0x3e, 0x04, 0x3f, 0x04, 0x40, 0x04, 0x41, 0x04, 0x42, 0x04, 0x43,
+ 0x04, 0x44, 0x04, 0x45, 0x04, 0x46, 0x04, 0x47, 0x04, 0x48, 0x04, 0x49,
+ 0x04, 0x4a, 0x04, 0x4b, 0x04, 0x4c, 0x04, 0x4d, 0x04, 0x4e, 0x04, 0x4f,
+ 0x21, 0x16, 0x04, 0x51, 0x04, 0x52, 0x04, 0x53, 0x04, 0x54, 0x04, 0x55,
+ 0x04, 0x56, 0x04, 0x57, 0x04, 0x58, 0x04, 0x59, 0x04, 0x5a, 0x04, 0x5b,
+ 0x04, 0x5c, 0x00, 0xa7, 0x04, 0x5e, 0x04, 0x5f
+};
diff --git a/package/libs/libiconv/src/include/charmaps/.svn/text-base/iso-8859-6.h.svn-base b/package/libs/libiconv/src/include/charmaps/.svn/text-base/iso-8859-6.h.svn-base
new file mode 100644
index 0000000..820020f
--- /dev/null
+++ b/package/libs/libiconv/src/include/charmaps/.svn/text-base/iso-8859-6.h.svn-base
@@ -0,0 +1,24 @@
+static const unsigned char map_iso_8859_6[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x81, 0x00, 0x82, 0x00, 0x83,
+ 0x00, 0x84, 0x00, 0x85, 0x00, 0x86, 0x00, 0x87, 0x00, 0x88, 0x00, 0x89,
+ 0x00, 0x8a, 0x00, 0x8b, 0x00, 0x8c, 0x00, 0x8d, 0x00, 0x8e, 0x00, 0x8f,
+ 0x00, 0x90, 0x00, 0x91, 0x00, 0x92, 0x00, 0x93, 0x00, 0x94, 0x00, 0x95,
+ 0x00, 0x96, 0x00, 0x97, 0x00, 0x98, 0x00, 0x99, 0x00, 0x9a, 0x00, 0x9b,
+ 0x00, 0x9c, 0x00, 0x9d, 0x00, 0x9e, 0x00, 0x9f, 0x00, 0xa0, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0x00, 0xa4, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x06, 0x0c, 0x00, 0xad,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0x06, 0x1b, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x06, 0x1f,
+ 0xff, 0xff, 0x06, 0x21, 0x06, 0x22, 0x06, 0x23, 0x06, 0x24, 0x06, 0x25,
+ 0x06, 0x26, 0x06, 0x27, 0x06, 0x28, 0x06, 0x29, 0x06, 0x2a, 0x06, 0x2b,
+ 0x06, 0x2c, 0x06, 0x2d, 0x06, 0x2e, 0x06, 0x2f, 0x06, 0x30, 0x06, 0x31,
+ 0x06, 0x32, 0x06, 0x33, 0x06, 0x34, 0x06, 0x35, 0x06, 0x36, 0x06, 0x37,
+ 0x06, 0x38, 0x06, 0x39, 0x06, 0x3a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0x06, 0x40, 0x06, 0x41, 0x06, 0x42, 0x06, 0x43,
+ 0x06, 0x44, 0x06, 0x45, 0x06, 0x46, 0x06, 0x47, 0x06, 0x48, 0x06, 0x49,
+ 0x06, 0x4a, 0x06, 0x4b, 0x06, 0x4c, 0x06, 0x4d, 0x06, 0x4e, 0x06, 0x4f,
+ 0x06, 0x50, 0x06, 0x51, 0x06, 0x52, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
+};
diff --git a/package/libs/libiconv/src/include/charmaps/.svn/text-base/iso-8859-7.h.svn-base b/package/libs/libiconv/src/include/charmaps/.svn/text-base/iso-8859-7.h.svn-base
new file mode 100644
index 0000000..174f9d3
--- /dev/null
+++ b/package/libs/libiconv/src/include/charmaps/.svn/text-base/iso-8859-7.h.svn-base
@@ -0,0 +1,24 @@
+static const unsigned char map_iso_8859_7[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x81, 0x00, 0x82, 0x00, 0x83,
+ 0x00, 0x84, 0x00, 0x85, 0x00, 0x86, 0x00, 0x87, 0x00, 0x88, 0x00, 0x89,
+ 0x00, 0x8a, 0x00, 0x8b, 0x00, 0x8c, 0x00, 0x8d, 0x00, 0x8e, 0x00, 0x8f,
+ 0x00, 0x90, 0x00, 0x91, 0x00, 0x92, 0x00, 0x93, 0x00, 0x94, 0x00, 0x95,
+ 0x00, 0x96, 0x00, 0x97, 0x00, 0x98, 0x00, 0x99, 0x00, 0x9a, 0x00, 0x9b,
+ 0x00, 0x9c, 0x00, 0x9d, 0x00, 0x9e, 0x00, 0x9f, 0x00, 0xa0, 0x20, 0x18,
+ 0x20, 0x19, 0x00, 0xa3, 0x20, 0xac, 0x20, 0xaf, 0x00, 0xa6, 0x00, 0xa7,
+ 0x00, 0xa8, 0x00, 0xa9, 0x03, 0x7a, 0x00, 0xab, 0x00, 0xac, 0x00, 0xad,
+ 0xff, 0xff, 0x20, 0x15, 0x00, 0xb0, 0x00, 0xb1, 0x00, 0xb2, 0x00, 0xb3,
+ 0x03, 0x84, 0x03, 0x85, 0x03, 0x86, 0x00, 0xb7, 0x03, 0x88, 0x03, 0x89,
+ 0x03, 0x8a, 0x00, 0xbb, 0x03, 0x8c, 0x00, 0xbd, 0x03, 0x8e, 0x03, 0x8f,
+ 0x03, 0x90, 0x03, 0x91, 0x03, 0x92, 0x03, 0x93, 0x03, 0x94, 0x03, 0x95,
+ 0x03, 0x96, 0x03, 0x97, 0x03, 0x98, 0x03, 0x99, 0x03, 0x9a, 0x03, 0x9b,
+ 0x03, 0x9c, 0x03, 0x9d, 0x03, 0x9e, 0x03, 0x9f, 0x03, 0xa0, 0x03, 0xa1,
+ 0xff, 0xff, 0x03, 0xa3, 0x03, 0xa4, 0x03, 0xa5, 0x03, 0xa6, 0x03, 0xa7,
+ 0x03, 0xa8, 0x03, 0xa9, 0x03, 0xaa, 0x03, 0xab, 0x03, 0xac, 0x03, 0xad,
+ 0x03, 0xae, 0x03, 0xaf, 0x03, 0xb0, 0x03, 0xb1, 0x03, 0xb2, 0x03, 0xb3,
+ 0x03, 0xb4, 0x03, 0xb5, 0x03, 0xb6, 0x03, 0xb7, 0x03, 0xb8, 0x03, 0xb9,
+ 0x03, 0xba, 0x03, 0xbb, 0x03, 0xbc, 0x03, 0xbd, 0x03, 0xbe, 0x03, 0xbf,
+ 0x03, 0xc0, 0x03, 0xc1, 0x03, 0xc2, 0x03, 0xc3, 0x03, 0xc4, 0x03, 0xc5,
+ 0x03, 0xc6, 0x03, 0xc7, 0x03, 0xc8, 0x03, 0xc9, 0x03, 0xca, 0x03, 0xcb,
+ 0x03, 0xcc, 0x03, 0xcd, 0x03, 0xce, 0xff, 0xff
+};
diff --git a/package/libs/libiconv/src/include/charmaps/.svn/text-base/iso-8859-8.h.svn-base b/package/libs/libiconv/src/include/charmaps/.svn/text-base/iso-8859-8.h.svn-base
new file mode 100644
index 0000000..66d4a5e
--- /dev/null
+++ b/package/libs/libiconv/src/include/charmaps/.svn/text-base/iso-8859-8.h.svn-base
@@ -0,0 +1,24 @@
+static const unsigned char map_iso_8859_8[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x81, 0x00, 0x82, 0x00, 0x83,
+ 0x00, 0x84, 0x00, 0x85, 0x00, 0x86, 0x00, 0x87, 0x00, 0x88, 0x00, 0x89,
+ 0x00, 0x8a, 0x00, 0x8b, 0x00, 0x8c, 0x00, 0x8d, 0x00, 0x8e, 0x00, 0x8f,
+ 0x00, 0x90, 0x00, 0x91, 0x00, 0x92, 0x00, 0x93, 0x00, 0x94, 0x00, 0x95,
+ 0x00, 0x96, 0x00, 0x97, 0x00, 0x98, 0x00, 0x99, 0x00, 0x9a, 0x00, 0x9b,
+ 0x00, 0x9c, 0x00, 0x9d, 0x00, 0x9e, 0x00, 0x9f, 0x00, 0xa0, 0xff, 0xff,
+ 0x00, 0xa2, 0x00, 0xa3, 0x00, 0xa4, 0x00, 0xa5, 0x00, 0xa6, 0x00, 0xa7,
+ 0x00, 0xa8, 0x00, 0xa9, 0x00, 0xd7, 0x00, 0xab, 0x00, 0xac, 0x00, 0xad,
+ 0x00, 0xae, 0x00, 0xaf, 0x00, 0xb0, 0x00, 0xb1, 0x00, 0xb2, 0x00, 0xb3,
+ 0x00, 0xb4, 0x00, 0xb5, 0x00, 0xb6, 0x00, 0xb7, 0x00, 0xb8, 0x00, 0xb9,
+ 0x00, 0xf7, 0x00, 0xbb, 0x00, 0xbc, 0x00, 0xbd, 0x00, 0xbe, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0x20, 0x17, 0x05, 0xd0, 0x05, 0xd1, 0x05, 0xd2, 0x05, 0xd3,
+ 0x05, 0xd4, 0x05, 0xd5, 0x05, 0xd6, 0x05, 0xd7, 0x05, 0xd8, 0x05, 0xd9,
+ 0x05, 0xda, 0x05, 0xdb, 0x05, 0xdc, 0x05, 0xdd, 0x05, 0xde, 0x05, 0xdf,
+ 0x05, 0xe0, 0x05, 0xe1, 0x05, 0xe2, 0x05, 0xe3, 0x05, 0xe4, 0x05, 0xe5,
+ 0x05, 0xe6, 0x05, 0xe7, 0x05, 0xe8, 0x05, 0xe9, 0x05, 0xea, 0xff, 0xff,
+ 0xff, 0xff, 0x20, 0x0e, 0x20, 0x0f, 0xff, 0xff
+};
diff --git a/package/libs/libiconv/src/include/charmaps/.svn/text-base/iso-8859-9.h.svn-base b/package/libs/libiconv/src/include/charmaps/.svn/text-base/iso-8859-9.h.svn-base
new file mode 100644
index 0000000..f1a8646
--- /dev/null
+++ b/package/libs/libiconv/src/include/charmaps/.svn/text-base/iso-8859-9.h.svn-base
@@ -0,0 +1,24 @@
+static const unsigned char map_iso_8859_9[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x81, 0x00, 0x82, 0x00, 0x83,
+ 0x00, 0x84, 0x00, 0x85, 0x00, 0x86, 0x00, 0x87, 0x00, 0x88, 0x00, 0x89,
+ 0x00, 0x8a, 0x00, 0x8b, 0x00, 0x8c, 0x00, 0x8d, 0x00, 0x8e, 0x00, 0x8f,
+ 0x00, 0x90, 0x00, 0x91, 0x00, 0x92, 0x00, 0x93, 0x00, 0x94, 0x00, 0x95,
+ 0x00, 0x96, 0x00, 0x97, 0x00, 0x98, 0x00, 0x99, 0x00, 0x9a, 0x00, 0x9b,
+ 0x00, 0x9c, 0x00, 0x9d, 0x00, 0x9e, 0x00, 0x9f, 0x00, 0xa0, 0x00, 0xa1,
+ 0x00, 0xa2, 0x00, 0xa3, 0x00, 0xa4, 0x00, 0xa5, 0x00, 0xa6, 0x00, 0xa7,
+ 0x00, 0xa8, 0x00, 0xa9, 0x00, 0xaa, 0x00, 0xab, 0x00, 0xac, 0x00, 0xad,
+ 0x00, 0xae, 0x00, 0xaf, 0x00, 0xb0, 0x00, 0xb1, 0x00, 0xb2, 0x00, 0xb3,
+ 0x00, 0xb4, 0x00, 0xb5, 0x00, 0xb6, 0x00, 0xb7, 0x00, 0xb8, 0x00, 0xb9,
+ 0x00, 0xba, 0x00, 0xbb, 0x00, 0xbc, 0x00, 0xbd, 0x00, 0xbe, 0x00, 0xbf,
+ 0x00, 0xc0, 0x00, 0xc1, 0x00, 0xc2, 0x00, 0xc3, 0x00, 0xc4, 0x00, 0xc5,
+ 0x00, 0xc6, 0x00, 0xc7, 0x00, 0xc8, 0x00, 0xc9, 0x00, 0xca, 0x00, 0xcb,
+ 0x00, 0xcc, 0x00, 0xcd, 0x00, 0xce, 0x00, 0xcf, 0x01, 0x1e, 0x00, 0xd1,
+ 0x00, 0xd2, 0x00, 0xd3, 0x00, 0xd4, 0x00, 0xd5, 0x00, 0xd6, 0x00, 0xd7,
+ 0x00, 0xd8, 0x00, 0xd9, 0x00, 0xda, 0x00, 0xdb, 0x00, 0xdc, 0x01, 0x30,
+ 0x01, 0x5e, 0x00, 0xdf, 0x00, 0xe0, 0x00, 0xe1, 0x00, 0xe2, 0x00, 0xe3,
+ 0x00, 0xe4, 0x00, 0xe5, 0x00, 0xe6, 0x00, 0xe7, 0x00, 0xe8, 0x00, 0xe9,
+ 0x00, 0xea, 0x00, 0xeb, 0x00, 0xec, 0x00, 0xed, 0x00, 0xee, 0x00, 0xef,
+ 0x01, 0x1f, 0x00, 0xf1, 0x00, 0xf2, 0x00, 0xf3, 0x00, 0xf4, 0x00, 0xf5,
+ 0x00, 0xf6, 0x00, 0xf7, 0x00, 0xf8, 0x00, 0xf9, 0x00, 0xfa, 0x00, 0xfb,
+ 0x00, 0xfc, 0x01, 0x31, 0x01, 0x5f, 0x00, 0xff
+};
diff --git a/package/libs/libiconv/src/include/charmaps/.svn/text-base/koi8-r.h.svn-base b/package/libs/libiconv/src/include/charmaps/.svn/text-base/koi8-r.h.svn-base
new file mode 100644
index 0000000..c2453a5
--- /dev/null
+++ b/package/libs/libiconv/src/include/charmaps/.svn/text-base/koi8-r.h.svn-base
@@ -0,0 +1,24 @@
+static const unsigned char map_koi8_r[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x25, 0x00, 0x25, 0x02, 0x25, 0x0c, 0x25, 0x10,
+ 0x25, 0x14, 0x25, 0x18, 0x25, 0x1c, 0x25, 0x24, 0x25, 0x2c, 0x25, 0x34,
+ 0x25, 0x3c, 0x25, 0x80, 0x25, 0x84, 0x25, 0x88, 0x25, 0x8c, 0x25, 0x90,
+ 0x25, 0x91, 0x25, 0x92, 0x25, 0x93, 0x23, 0x20, 0x25, 0xa0, 0x22, 0x19,
+ 0x22, 0x1a, 0x22, 0x48, 0x22, 0x64, 0x22, 0x65, 0x00, 0xa0, 0x23, 0x21,
+ 0x00, 0xb0, 0x00, 0xb2, 0x00, 0xb7, 0x00, 0xf7, 0x25, 0x50, 0x25, 0x51,
+ 0x25, 0x52, 0x04, 0x51, 0x25, 0x53, 0x25, 0x54, 0x25, 0x55, 0x25, 0x56,
+ 0x25, 0x57, 0x25, 0x58, 0x25, 0x59, 0x25, 0x5a, 0x25, 0x5b, 0x25, 0x5c,
+ 0x25, 0x5d, 0x25, 0x5e, 0x25, 0x5f, 0x25, 0x60, 0x25, 0x61, 0x04, 0x01,
+ 0x25, 0x62, 0x25, 0x63, 0x25, 0x64, 0x25, 0x65, 0x25, 0x66, 0x25, 0x67,
+ 0x25, 0x68, 0x25, 0x69, 0x25, 0x6a, 0x25, 0x6b, 0x25, 0x6c, 0x00, 0xa9,
+ 0x04, 0x4e, 0x04, 0x30, 0x04, 0x31, 0x04, 0x46, 0x04, 0x34, 0x04, 0x35,
+ 0x04, 0x44, 0x04, 0x33, 0x04, 0x45, 0x04, 0x38, 0x04, 0x39, 0x04, 0x3a,
+ 0x04, 0x3b, 0x04, 0x3c, 0x04, 0x3d, 0x04, 0x3e, 0x04, 0x3f, 0x04, 0x4f,
+ 0x04, 0x40, 0x04, 0x41, 0x04, 0x42, 0x04, 0x43, 0x04, 0x36, 0x04, 0x32,
+ 0x04, 0x4c, 0x04, 0x4b, 0x04, 0x37, 0x04, 0x48, 0x04, 0x4d, 0x04, 0x49,
+ 0x04, 0x47, 0x04, 0x4a, 0x04, 0x2e, 0x04, 0x10, 0x04, 0x11, 0x04, 0x26,
+ 0x04, 0x14, 0x04, 0x15, 0x04, 0x24, 0x04, 0x13, 0x04, 0x25, 0x04, 0x18,
+ 0x04, 0x19, 0x04, 0x1a, 0x04, 0x1b, 0x04, 0x1c, 0x04, 0x1d, 0x04, 0x1e,
+ 0x04, 0x1f, 0x04, 0x2f, 0x04, 0x20, 0x04, 0x21, 0x04, 0x22, 0x04, 0x23,
+ 0x04, 0x16, 0x04, 0x12, 0x04, 0x2c, 0x04, 0x2b, 0x04, 0x17, 0x04, 0x28,
+ 0x04, 0x2d, 0x04, 0x29, 0x04, 0x27, 0x04, 0x2a
+};
diff --git a/package/libs/libiconv/src/include/charmaps/.svn/text-base/windows-1250.h.svn-base b/package/libs/libiconv/src/include/charmaps/.svn/text-base/windows-1250.h.svn-base
new file mode 100644
index 0000000..8e4723e
--- /dev/null
+++ b/package/libs/libiconv/src/include/charmaps/.svn/text-base/windows-1250.h.svn-base
@@ -0,0 +1,24 @@
+static const unsigned char map_windows_1250[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x20, 0xac, 0xff, 0xff, 0x20, 0x1a, 0xff, 0xff,
+ 0x20, 0x1e, 0x20, 0x26, 0x20, 0x20, 0x20, 0x21, 0xff, 0xff, 0x20, 0x30,
+ 0x01, 0x60, 0x20, 0x39, 0x01, 0x5a, 0x01, 0x64, 0x01, 0x7d, 0x01, 0x79,
+ 0xff, 0xff, 0x20, 0x18, 0x20, 0x19, 0x20, 0x1c, 0x20, 0x1d, 0x20, 0x22,
+ 0x20, 0x13, 0x20, 0x14, 0xff, 0xff, 0x21, 0x22, 0x01, 0x61, 0x20, 0x3a,
+ 0x01, 0x5b, 0x01, 0x65, 0x01, 0x7e, 0x01, 0x7a, 0x00, 0xa0, 0x02, 0xc7,
+ 0x02, 0xd8, 0x01, 0x41, 0x00, 0xa4, 0x01, 0x04, 0x00, 0xa6, 0x00, 0xa7,
+ 0x00, 0xa8, 0x00, 0xa9, 0x01, 0x5e, 0x00, 0xab, 0x00, 0xac, 0x00, 0xad,
+ 0x00, 0xae, 0x01, 0x7b, 0x00, 0xb0, 0x00, 0xb1, 0x02, 0xdb, 0x01, 0x42,
+ 0x00, 0xb4, 0x00, 0xb5, 0x00, 0xb6, 0x00, 0xb7, 0x00, 0xb8, 0x01, 0x05,
+ 0x01, 0x5f, 0x00, 0xbb, 0x01, 0x3d, 0x02, 0xdd, 0x01, 0x3e, 0x01, 0x7c,
+ 0x01, 0x54, 0x00, 0xc1, 0x00, 0xc2, 0x01, 0x02, 0x00, 0xc4, 0x01, 0x39,
+ 0x01, 0x06, 0x00, 0xc7, 0x01, 0x0c, 0x00, 0xc9, 0x01, 0x18, 0x00, 0xcb,
+ 0x01, 0x1a, 0x00, 0xcd, 0x00, 0xce, 0x01, 0x0e, 0x01, 0x10, 0x01, 0x43,
+ 0x01, 0x47, 0x00, 0xd3, 0x00, 0xd4, 0x01, 0x50, 0x00, 0xd6, 0x00, 0xd7,
+ 0x01, 0x58, 0x01, 0x6e, 0x00, 0xda, 0x01, 0x70, 0x00, 0xdc, 0x00, 0xdd,
+ 0x01, 0x62, 0x00, 0xdf, 0x01, 0x55, 0x00, 0xe1, 0x00, 0xe2, 0x01, 0x03,
+ 0x00, 0xe4, 0x01, 0x3a, 0x01, 0x07, 0x00, 0xe7, 0x01, 0x0d, 0x00, 0xe9,
+ 0x01, 0x19, 0x00, 0xeb, 0x01, 0x1b, 0x00, 0xed, 0x00, 0xee, 0x01, 0x0f,
+ 0x01, 0x11, 0x01, 0x44, 0x01, 0x48, 0x00, 0xf3, 0x00, 0xf4, 0x01, 0x51,
+ 0x00, 0xf6, 0x00, 0xf7, 0x01, 0x59, 0x01, 0x6f, 0x00, 0xfa, 0x01, 0x71,
+ 0x00, 0xfc, 0x00, 0xfd, 0x01, 0x63, 0x02, 0xd9
+};
diff --git a/package/libs/libiconv/src/include/charmaps/.svn/text-base/windows-1251.h.svn-base b/package/libs/libiconv/src/include/charmaps/.svn/text-base/windows-1251.h.svn-base
new file mode 100644
index 0000000..e278850
--- /dev/null
+++ b/package/libs/libiconv/src/include/charmaps/.svn/text-base/windows-1251.h.svn-base
@@ -0,0 +1,24 @@
+static const unsigned char map_windows_1251[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x04, 0x02, 0x04, 0x03, 0x20, 0x1a, 0x04, 0x53,
+ 0x20, 0x1e, 0x20, 0x26, 0x20, 0x20, 0x20, 0x21, 0x20, 0xac, 0x20, 0x30,
+ 0x04, 0x09, 0x20, 0x39, 0x04, 0x0a, 0x04, 0x0c, 0x04, 0x0b, 0x04, 0x0f,
+ 0x04, 0x52, 0x20, 0x18, 0x20, 0x19, 0x20, 0x1c, 0x20, 0x1d, 0x20, 0x22,
+ 0x20, 0x13, 0x20, 0x14, 0xff, 0xff, 0x21, 0x22, 0x04, 0x59, 0x20, 0x3a,
+ 0x04, 0x5a, 0x04, 0x5c, 0x04, 0x5b, 0x04, 0x5f, 0x00, 0xa0, 0x04, 0x0e,
+ 0x04, 0x5e, 0x04, 0x08, 0x00, 0xa4, 0x04, 0x90, 0x00, 0xa6, 0x00, 0xa7,
+ 0x04, 0x01, 0x00, 0xa9, 0x04, 0x04, 0x00, 0xab, 0x00, 0xac, 0x00, 0xad,
+ 0x00, 0xae, 0x04, 0x07, 0x00, 0xb0, 0x00, 0xb1, 0x04, 0x06, 0x04, 0x56,
+ 0x04, 0x91, 0x00, 0xb5, 0x00, 0xb6, 0x00, 0xb7, 0x04, 0x51, 0x21, 0x16,
+ 0x04, 0x54, 0x00, 0xbb, 0x04, 0x58, 0x04, 0x05, 0x04, 0x55, 0x04, 0x57,
+ 0x04, 0x10, 0x04, 0x11, 0x04, 0x12, 0x04, 0x13, 0x04, 0x14, 0x04, 0x15,
+ 0x04, 0x16, 0x04, 0x17, 0x04, 0x18, 0x04, 0x19, 0x04, 0x1a, 0x04, 0x1b,
+ 0x04, 0x1c, 0x04, 0x1d, 0x04, 0x1e, 0x04, 0x1f, 0x04, 0x20, 0x04, 0x21,
+ 0x04, 0x22, 0x04, 0x23, 0x04, 0x24, 0x04, 0x25, 0x04, 0x26, 0x04, 0x27,
+ 0x04, 0x28, 0x04, 0x29, 0x04, 0x2a, 0x04, 0x2b, 0x04, 0x2c, 0x04, 0x2d,
+ 0x04, 0x2e, 0x04, 0x2f, 0x04, 0x30, 0x04, 0x31, 0x04, 0x32, 0x04, 0x33,
+ 0x04, 0x34, 0x04, 0x35, 0x04, 0x36, 0x04, 0x37, 0x04, 0x38, 0x04, 0x39,
+ 0x04, 0x3a, 0x04, 0x3b, 0x04, 0x3c, 0x04, 0x3d, 0x04, 0x3e, 0x04, 0x3f,
+ 0x04, 0x40, 0x04, 0x41, 0x04, 0x42, 0x04, 0x43, 0x04, 0x44, 0x04, 0x45,
+ 0x04, 0x46, 0x04, 0x47, 0x04, 0x48, 0x04, 0x49, 0x04, 0x4a, 0x04, 0x4b,
+ 0x04, 0x4c, 0x04, 0x4d, 0x04, 0x4e, 0x04, 0x4f
+};
diff --git a/package/libs/libiconv/src/include/charmaps/.svn/text-base/windows-1252.h.svn-base b/package/libs/libiconv/src/include/charmaps/.svn/text-base/windows-1252.h.svn-base
new file mode 100644
index 0000000..a6dad8a
--- /dev/null
+++ b/package/libs/libiconv/src/include/charmaps/.svn/text-base/windows-1252.h.svn-base
@@ -0,0 +1,25 @@
+static const unsigned char map_windows_1252[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x20, 0xac, 0xff, 0xff, 0x20, 0x1a, 0x01, 0x92,
+ 0x20, 0x1e, 0x20, 0x26, 0x20, 0x20, 0x20, 0x21, 0x02, 0xc6, 0x20, 0x30,
+ 0x01, 0x60, 0x20, 0x39, 0x01, 0x52, 0xff, 0xff, 0x01, 0x7d, 0xff, 0xff,
+ 0xff, 0xff, 0x20, 0x18, 0x20, 0x19, 0x20, 0x1c, 0x20, 0x1d, 0x20, 0x22,
+ 0x20, 0x13, 0x20, 0x14, 0x02, 0xdc, 0x21, 0x22, 0x01, 0x61, 0x20, 0x3a,
+ 0x01, 0x53, 0xff, 0xff, 0x01, 0x7e, 0x01, 0x78, 0x00, 0xa0, 0x00, 0xa1,
+ 0x00, 0xa2, 0x00, 0xa3, 0x00, 0xa4, 0x00, 0xa5, 0x00, 0xa6, 0x00, 0xa7,
+ 0x00, 0xa8, 0x00, 0xa9, 0x00, 0xaa, 0x00, 0xab, 0x00, 0xac, 0x00, 0xad,
+ 0x00, 0xae, 0x00, 0xaf, 0x00, 0xb0, 0x00, 0xb1, 0x00, 0xb2, 0x00, 0xb3,
+ 0x00, 0xb4, 0x00, 0xb5, 0x00, 0xb6, 0x00, 0xb7, 0x00, 0xb8, 0x00, 0xb9,
+ 0x00, 0xba, 0x00, 0xbb, 0x00, 0xbc, 0x00, 0xbd, 0x00, 0xbe, 0x00, 0xbf,
+ 0x00, 0xc0, 0x00, 0xc1, 0x00, 0xc2, 0x00, 0xc3, 0x00, 0xc4, 0x00, 0xc5,
+ 0x00, 0xc6, 0x00, 0xc7, 0x00, 0xc8, 0x00, 0xc9, 0x00, 0xca, 0x00, 0xcb,
+ 0x00, 0xcc, 0x00, 0xcd, 0x00, 0xce, 0x00, 0xcf, 0x00, 0xd0, 0x00, 0xd1,
+ 0x00, 0xd2, 0x00, 0xd3, 0x00, 0xd4, 0x00, 0xd5, 0x00, 0xd6, 0x00, 0xd7,
+ 0x00, 0xd8, 0x00, 0xd9, 0x00, 0xda, 0x00, 0xdb, 0x00, 0xdc, 0x00, 0xdd,
+ 0x00, 0xde, 0x00, 0xdf, 0x00, 0xe0, 0x00, 0xe1, 0x00, 0xe2, 0x00, 0xe3,
+ 0x00, 0xe4, 0x00, 0xe5, 0x00, 0xe6, 0x00, 0xe7, 0x00, 0xe8, 0x00, 0xe9,
+ 0x00, 0xea, 0x00, 0xeb, 0x00, 0xec, 0x00, 0xed, 0x00, 0xee, 0x00, 0xef,
+ 0x00, 0xf0, 0x00, 0xf1, 0x00, 0xf2, 0x00, 0xf3, 0x00, 0xf4, 0x00, 0xf5,
+ 0x00, 0xf6, 0x00, 0xf7, 0x00, 0xf8, 0x00, 0xf9, 0x00, 0xfa, 0x00, 0xfb,
+ 0x00, 0xfc, 0x00, 0xfd, 0x00, 0xfe, 0x00, 0xff
+};
+
diff --git a/package/libs/libiconv/src/include/charmaps/.svn/text-base/windows-1253.h.svn-base b/package/libs/libiconv/src/include/charmaps/.svn/text-base/windows-1253.h.svn-base
new file mode 100644
index 0000000..b0bdf1e
--- /dev/null
+++ b/package/libs/libiconv/src/include/charmaps/.svn/text-base/windows-1253.h.svn-base
@@ -0,0 +1,24 @@
+static const unsigned char map_windows_1253[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x20, 0xac, 0xff, 0xff, 0x20, 0x1a, 0x01, 0x92,
+ 0x20, 0x1e, 0x20, 0x26, 0x20, 0x20, 0x20, 0x21, 0xff, 0xff, 0x20, 0x30,
+ 0xff, 0xff, 0x20, 0x39, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0x20, 0x18, 0x20, 0x19, 0x20, 0x1c, 0x20, 0x1d, 0x20, 0x22,
+ 0x20, 0x13, 0x20, 0x14, 0xff, 0xff, 0x21, 0x22, 0xff, 0xff, 0x20, 0x3a,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xa0, 0x03, 0x85,
+ 0x03, 0x86, 0x00, 0xa3, 0x00, 0xa4, 0x00, 0xa5, 0x00, 0xa6, 0x00, 0xa7,
+ 0x00, 0xa8, 0x00, 0xa9, 0xff, 0xff, 0x00, 0xab, 0x00, 0xac, 0x00, 0xad,
+ 0x00, 0xae, 0x20, 0x15, 0x00, 0xb0, 0x00, 0xb1, 0x00, 0xb2, 0x00, 0xb3,
+ 0x03, 0x84, 0x00, 0xb5, 0x00, 0xb6, 0x00, 0xb7, 0x03, 0x88, 0x03, 0x89,
+ 0x03, 0x8a, 0x00, 0xbb, 0x03, 0x8c, 0x00, 0xbd, 0x03, 0x8e, 0x03, 0x8f,
+ 0x03, 0x90, 0x03, 0x91, 0x03, 0x92, 0x03, 0x93, 0x03, 0x94, 0x03, 0x95,
+ 0x03, 0x96, 0x03, 0x97, 0x03, 0x98, 0x03, 0x99, 0x03, 0x9a, 0x03, 0x9b,
+ 0x03, 0x9c, 0x03, 0x9d, 0x03, 0x9e, 0x03, 0x9f, 0x03, 0xa0, 0x03, 0xa1,
+ 0xff, 0xff, 0x03, 0xa3, 0x03, 0xa4, 0x03, 0xa5, 0x03, 0xa6, 0x03, 0xa7,
+ 0x03, 0xa8, 0x03, 0xa9, 0x03, 0xaa, 0x03, 0xab, 0x03, 0xac, 0x03, 0xad,
+ 0x03, 0xae, 0x03, 0xaf, 0x03, 0xb0, 0x03, 0xb1, 0x03, 0xb2, 0x03, 0xb3,
+ 0x03, 0xb4, 0x03, 0xb5, 0x03, 0xb6, 0x03, 0xb7, 0x03, 0xb8, 0x03, 0xb9,
+ 0x03, 0xba, 0x03, 0xbb, 0x03, 0xbc, 0x03, 0xbd, 0x03, 0xbe, 0x03, 0xbf,
+ 0x03, 0xc0, 0x03, 0xc1, 0x03, 0xc2, 0x03, 0xc3, 0x03, 0xc4, 0x03, 0xc5,
+ 0x03, 0xc6, 0x03, 0xc7, 0x03, 0xc8, 0x03, 0xc9, 0x03, 0xca, 0x03, 0xcb,
+ 0x03, 0xcc, 0x03, 0xcd, 0x03, 0xce, 0xff, 0xff
+};
diff --git a/package/libs/libiconv/src/include/charmaps/.svn/text-base/windows-1254.h.svn-base b/package/libs/libiconv/src/include/charmaps/.svn/text-base/windows-1254.h.svn-base
new file mode 100644
index 0000000..be22600
--- /dev/null
+++ b/package/libs/libiconv/src/include/charmaps/.svn/text-base/windows-1254.h.svn-base
@@ -0,0 +1,24 @@
+static const unsigned char map_windows_1254[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x20, 0xac, 0xff, 0xff, 0x20, 0x1a, 0x01, 0x92,
+ 0x20, 0x1e, 0x20, 0x26, 0x20, 0x20, 0x20, 0x21, 0x02, 0xc6, 0x20, 0x30,
+ 0x01, 0x60, 0x20, 0x39, 0x01, 0x52, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0x20, 0x18, 0x20, 0x19, 0x20, 0x1c, 0x20, 0x1d, 0x20, 0x22,
+ 0x20, 0x13, 0x20, 0x14, 0x02, 0xdc, 0x21, 0x22, 0x01, 0x61, 0x20, 0x3a,
+ 0x01, 0x53, 0xff, 0xff, 0xff, 0xff, 0x01, 0x78, 0x00, 0xa0, 0x00, 0xa1,
+ 0x00, 0xa2, 0x00, 0xa3, 0x00, 0xa4, 0x00, 0xa5, 0x00, 0xa6, 0x00, 0xa7,
+ 0x00, 0xa8, 0x00, 0xa9, 0x00, 0xaa, 0x00, 0xab, 0x00, 0xac, 0x00, 0xad,
+ 0x00, 0xae, 0x00, 0xaf, 0x00, 0xb0, 0x00, 0xb1, 0x00, 0xb2, 0x00, 0xb3,
+ 0x00, 0xb4, 0x00, 0xb5, 0x00, 0xb6, 0x00, 0xb7, 0x00, 0xb8, 0x00, 0xb9,
+ 0x00, 0xba, 0x00, 0xbb, 0x00, 0xbc, 0x00, 0xbd, 0x00, 0xbe, 0x00, 0xbf,
+ 0x00, 0xc0, 0x00, 0xc1, 0x00, 0xc2, 0x00, 0xc3, 0x00, 0xc4, 0x00, 0xc5,
+ 0x00, 0xc6, 0x00, 0xc7, 0x00, 0xc8, 0x00, 0xc9, 0x00, 0xca, 0x00, 0xcb,
+ 0x00, 0xcc, 0x00, 0xcd, 0x00, 0xce, 0x00, 0xcf, 0x01, 0x1e, 0x00, 0xd1,
+ 0x00, 0xd2, 0x00, 0xd3, 0x00, 0xd4, 0x00, 0xd5, 0x00, 0xd6, 0x00, 0xd7,
+ 0x00, 0xd8, 0x00, 0xd9, 0x00, 0xda, 0x00, 0xdb, 0x00, 0xdc, 0x01, 0x30,
+ 0x01, 0x5e, 0x00, 0xdf, 0x00, 0xe0, 0x00, 0xe1, 0x00, 0xe2, 0x00, 0xe3,
+ 0x00, 0xe4, 0x00, 0xe5, 0x00, 0xe6, 0x00, 0xe7, 0x00, 0xe8, 0x00, 0xe9,
+ 0x00, 0xea, 0x00, 0xeb, 0x00, 0xec, 0x00, 0xed, 0x00, 0xee, 0x00, 0xef,
+ 0x01, 0x1f, 0x00, 0xf1, 0x00, 0xf2, 0x00, 0xf3, 0x00, 0xf4, 0x00, 0xf5,
+ 0x00, 0xf6, 0x00, 0xf7, 0x00, 0xf8, 0x00, 0xf9, 0x00, 0xfa, 0x00, 0xfb,
+ 0x00, 0xfc, 0x01, 0x31, 0x01, 0x5f, 0x00, 0xff
+};
diff --git a/package/libs/libiconv/src/include/charmaps/.svn/text-base/windows-1255.h.svn-base b/package/libs/libiconv/src/include/charmaps/.svn/text-base/windows-1255.h.svn-base
new file mode 100644
index 0000000..28bf513
--- /dev/null
+++ b/package/libs/libiconv/src/include/charmaps/.svn/text-base/windows-1255.h.svn-base
@@ -0,0 +1,24 @@
+static const unsigned char map_windows_1255[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x20, 0xac, 0xff, 0xff, 0x20, 0x1a, 0x01, 0x92,
+ 0x20, 0x1e, 0x20, 0x26, 0x20, 0x20, 0x20, 0x21, 0x02, 0xc6, 0x20, 0x30,
+ 0xff, 0xff, 0x20, 0x39, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0x20, 0x18, 0x20, 0x19, 0x20, 0x1c, 0x20, 0x1d, 0x20, 0x22,
+ 0x20, 0x13, 0x20, 0x14, 0x02, 0xdc, 0x21, 0x22, 0xff, 0xff, 0x20, 0x3a,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xa0, 0x00, 0xa1,
+ 0x00, 0xa2, 0x00, 0xa3, 0x20, 0xaa, 0x00, 0xa5, 0x00, 0xa6, 0x00, 0xa7,
+ 0x00, 0xa8, 0x00, 0xa9, 0x00, 0xd7, 0x00, 0xab, 0x00, 0xac, 0x00, 0xad,
+ 0x00, 0xae, 0x00, 0xaf, 0x00, 0xb0, 0x00, 0xb1, 0x00, 0xb2, 0x00, 0xb3,
+ 0x00, 0xb4, 0x00, 0xb5, 0x00, 0xb6, 0x00, 0xb7, 0x00, 0xb8, 0x00, 0xb9,
+ 0x00, 0xf7, 0x00, 0xbb, 0x00, 0xbc, 0x00, 0xbd, 0x00, 0xbe, 0x00, 0xbf,
+ 0x05, 0xb0, 0x05, 0xb1, 0x05, 0xb2, 0x05, 0xb3, 0x05, 0xb4, 0x05, 0xb5,
+ 0x05, 0xb6, 0x05, 0xb7, 0x05, 0xb8, 0x05, 0xb9, 0xff, 0xff, 0x05, 0xbb,
+ 0x05, 0xbc, 0x05, 0xbd, 0x05, 0xbe, 0x05, 0xbf, 0x05, 0xc0, 0x05, 0xc1,
+ 0x05, 0xc2, 0x05, 0xc3, 0x05, 0xf0, 0x05, 0xf1, 0x05, 0xf2, 0x05, 0xf3,
+ 0x05, 0xf4, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0x05, 0xd0, 0x05, 0xd1, 0x05, 0xd2, 0x05, 0xd3,
+ 0x05, 0xd4, 0x05, 0xd5, 0x05, 0xd6, 0x05, 0xd7, 0x05, 0xd8, 0x05, 0xd9,
+ 0x05, 0xda, 0x05, 0xdb, 0x05, 0xdc, 0x05, 0xdd, 0x05, 0xde, 0x05, 0xdf,
+ 0x05, 0xe0, 0x05, 0xe1, 0x05, 0xe2, 0x05, 0xe3, 0x05, 0xe4, 0x05, 0xe5,
+ 0x05, 0xe6, 0x05, 0xe7, 0x05, 0xe8, 0x05, 0xe9, 0x05, 0xea, 0xff, 0xff,
+ 0xff, 0xff, 0x20, 0x0e, 0x20, 0x0f, 0xff, 0xff
+};
diff --git a/package/libs/libiconv/src/include/charmaps/.svn/text-base/windows-1256.h.svn-base b/package/libs/libiconv/src/include/charmaps/.svn/text-base/windows-1256.h.svn-base
new file mode 100644
index 0000000..fbca315
--- /dev/null
+++ b/package/libs/libiconv/src/include/charmaps/.svn/text-base/windows-1256.h.svn-base
@@ -0,0 +1,24 @@
+static const unsigned char map_windows_1256[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x20, 0xac, 0x06, 0x7e, 0x20, 0x1a, 0x01, 0x92,
+ 0x20, 0x1e, 0x20, 0x26, 0x20, 0x20, 0x20, 0x21, 0x02, 0xc6, 0x20, 0x30,
+ 0x06, 0x79, 0x20, 0x39, 0x01, 0x52, 0x06, 0x86, 0x06, 0x98, 0x06, 0x88,
+ 0x06, 0xaf, 0x20, 0x18, 0x20, 0x19, 0x20, 0x1c, 0x20, 0x1d, 0x20, 0x22,
+ 0x20, 0x13, 0x20, 0x14, 0x06, 0xa9, 0x21, 0x22, 0x06, 0x91, 0x20, 0x3a,
+ 0x01, 0x53, 0x20, 0x0c, 0x20, 0x0d, 0x06, 0xba, 0x00, 0xa0, 0x06, 0x0c,
+ 0x00, 0xa2, 0x00, 0xa3, 0x00, 0xa4, 0x00, 0xa5, 0x00, 0xa6, 0x00, 0xa7,
+ 0x00, 0xa8, 0x00, 0xa9, 0x06, 0xbe, 0x00, 0xab, 0x00, 0xac, 0x00, 0xad,
+ 0x00, 0xae, 0x00, 0xaf, 0x00, 0xb0, 0x00, 0xb1, 0x00, 0xb2, 0x00, 0xb3,
+ 0x00, 0xb4, 0x00, 0xb5, 0x00, 0xb6, 0x00, 0xb7, 0x00, 0xb8, 0x00, 0xb9,
+ 0x06, 0x1b, 0x00, 0xbb, 0x00, 0xbc, 0x00, 0xbd, 0x00, 0xbe, 0x06, 0x1f,
+ 0x06, 0xc1, 0x06, 0x21, 0x06, 0x22, 0x06, 0x23, 0x06, 0x24, 0x06, 0x25,
+ 0x06, 0x26, 0x06, 0x27, 0x06, 0x28, 0x06, 0x29, 0x06, 0x2a, 0x06, 0x2b,
+ 0x06, 0x2c, 0x06, 0x2d, 0x06, 0x2e, 0x06, 0x2f, 0x06, 0x30, 0x06, 0x31,
+ 0x06, 0x32, 0x06, 0x33, 0x06, 0x34, 0x06, 0x35, 0x06, 0x36, 0x00, 0xd7,
+ 0x06, 0x37, 0x06, 0x38, 0x06, 0x39, 0x06, 0x3a, 0x06, 0x40, 0x06, 0x41,
+ 0x06, 0x42, 0x06, 0x43, 0x00, 0xe0, 0x06, 0x44, 0x00, 0xe2, 0x06, 0x45,
+ 0x06, 0x46, 0x06, 0x47, 0x06, 0x48, 0x00, 0xe7, 0x00, 0xe8, 0x00, 0xe9,
+ 0x00, 0xea, 0x00, 0xeb, 0x06, 0x49, 0x06, 0x4a, 0x00, 0xee, 0x00, 0xef,
+ 0x06, 0x4b, 0x06, 0x4c, 0x06, 0x4d, 0x06, 0x4e, 0x00, 0xf4, 0x06, 0x4f,
+ 0x06, 0x50, 0x00, 0xf7, 0x06, 0x51, 0x00, 0xf9, 0x06, 0x52, 0x00, 0xfb,
+ 0x00, 0xfc, 0x20, 0x0e, 0x20, 0x0f, 0x06, 0xd2
+};
diff --git a/package/libs/libiconv/src/include/charmaps/.svn/text-base/windows-1257.h.svn-base b/package/libs/libiconv/src/include/charmaps/.svn/text-base/windows-1257.h.svn-base
new file mode 100644
index 0000000..69d4474
--- /dev/null
+++ b/package/libs/libiconv/src/include/charmaps/.svn/text-base/windows-1257.h.svn-base
@@ -0,0 +1,24 @@
+static const unsigned char map_windows_1257[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x20, 0xac, 0xff, 0xff, 0x20, 0x1a, 0xff, 0xff,
+ 0x20, 0x1e, 0x20, 0x26, 0x20, 0x20, 0x20, 0x21, 0xff, 0xff, 0x20, 0x30,
+ 0xff, 0xff, 0x20, 0x39, 0xff, 0xff, 0x00, 0xa8, 0x02, 0xc7, 0x00, 0xb8,
+ 0xff, 0xff, 0x20, 0x18, 0x20, 0x19, 0x20, 0x1c, 0x20, 0x1d, 0x20, 0x22,
+ 0x20, 0x13, 0x20, 0x14, 0xff, 0xff, 0x21, 0x22, 0xff, 0xff, 0x20, 0x3a,
+ 0xff, 0xff, 0x00, 0xaf, 0x02, 0xdb, 0xff, 0xff, 0x00, 0xa0, 0xff, 0xff,
+ 0x00, 0xa2, 0x00, 0xa3, 0x00, 0xa4, 0xff, 0xff, 0x00, 0xa6, 0x00, 0xa7,
+ 0x00, 0xd8, 0x00, 0xa9, 0x01, 0x56, 0x00, 0xab, 0x00, 0xac, 0x00, 0xad,
+ 0x00, 0xae, 0x00, 0xc6, 0x00, 0xb0, 0x00, 0xb1, 0x00, 0xb2, 0x00, 0xb3,
+ 0x00, 0xb4, 0x00, 0xb5, 0x00, 0xb6, 0x00, 0xb7, 0x00, 0xf8, 0x00, 0xb9,
+ 0x01, 0x57, 0x00, 0xbb, 0x00, 0xbc, 0x00, 0xbd, 0x00, 0xbe, 0x00, 0xe6,
+ 0x01, 0x04, 0x01, 0x2e, 0x01, 0x00, 0x01, 0x06, 0x00, 0xc4, 0x00, 0xc5,
+ 0x01, 0x18, 0x01, 0x12, 0x01, 0x0c, 0x00, 0xc9, 0x01, 0x79, 0x01, 0x16,
+ 0x01, 0x22, 0x01, 0x36, 0x01, 0x2a, 0x01, 0x3b, 0x01, 0x60, 0x01, 0x43,
+ 0x01, 0x45, 0x00, 0xd3, 0x01, 0x4c, 0x00, 0xd5, 0x00, 0xd6, 0x00, 0xd7,
+ 0x01, 0x72, 0x01, 0x41, 0x01, 0x5a, 0x01, 0x6a, 0x00, 0xdc, 0x01, 0x7b,
+ 0x01, 0x7d, 0x00, 0xdf, 0x01, 0x05, 0x01, 0x2f, 0x01, 0x01, 0x01, 0x07,
+ 0x00, 0xe4, 0x00, 0xe5, 0x01, 0x19, 0x01, 0x13, 0x01, 0x0d, 0x00, 0xe9,
+ 0x01, 0x7a, 0x01, 0x17, 0x01, 0x23, 0x01, 0x37, 0x01, 0x2b, 0x01, 0x3c,
+ 0x01, 0x61, 0x01, 0x44, 0x01, 0x46, 0x00, 0xf3, 0x01, 0x4d, 0x00, 0xf5,
+ 0x00, 0xf6, 0x00, 0xf7, 0x01, 0x73, 0x01, 0x42, 0x01, 0x5b, 0x01, 0x6b,
+ 0x00, 0xfc, 0x01, 0x7c, 0x01, 0x7e, 0x02, 0xd9
+};
diff --git a/package/libs/libiconv/src/include/charmaps/.svn/text-base/windows-1258.h.svn-base b/package/libs/libiconv/src/include/charmaps/.svn/text-base/windows-1258.h.svn-base
new file mode 100644
index 0000000..5bbd737
--- /dev/null
+++ b/package/libs/libiconv/src/include/charmaps/.svn/text-base/windows-1258.h.svn-base
@@ -0,0 +1,24 @@
+static const unsigned char map_windows_1258[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x20, 0xac, 0xff, 0xff, 0x20, 0x1a, 0x01, 0x92,
+ 0x20, 0x1e, 0x20, 0x26, 0x20, 0x20, 0x20, 0x21, 0x02, 0xc6, 0x20, 0x30,
+ 0xff, 0xff, 0x20, 0x39, 0x01, 0x52, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0x20, 0x18, 0x20, 0x19, 0x20, 0x1c, 0x20, 0x1d, 0x20, 0x22,
+ 0x20, 0x13, 0x20, 0x14, 0x02, 0xdc, 0x21, 0x22, 0xff, 0xff, 0x20, 0x3a,
+ 0x01, 0x53, 0xff, 0xff, 0xff, 0xff, 0x01, 0x78, 0x00, 0xa0, 0x00, 0xa1,
+ 0x00, 0xa2, 0x00, 0xa3, 0x00, 0xa4, 0x00, 0xa5, 0x00, 0xa6, 0x00, 0xa7,
+ 0x00, 0xa8, 0x00, 0xa9, 0x00, 0xaa, 0x00, 0xab, 0x00, 0xac, 0x00, 0xad,
+ 0x00, 0xae, 0x00, 0xaf, 0x00, 0xb0, 0x00, 0xb1, 0x00, 0xb2, 0x00, 0xb3,
+ 0x00, 0xb4, 0x00, 0xb5, 0x00, 0xb6, 0x00, 0xb7, 0x00, 0xb8, 0x00, 0xb9,
+ 0x00, 0xba, 0x00, 0xbb, 0x00, 0xbc, 0x00, 0xbd, 0x00, 0xbe, 0x00, 0xbf,
+ 0x00, 0xc0, 0x00, 0xc1, 0x00, 0xc2, 0x01, 0x02, 0x00, 0xc4, 0x00, 0xc5,
+ 0x00, 0xc6, 0x00, 0xc7, 0x00, 0xc8, 0x00, 0xc9, 0x00, 0xca, 0x00, 0xcb,
+ 0x03, 0x00, 0x00, 0xcd, 0x00, 0xce, 0x00, 0xcf, 0x01, 0x10, 0x00, 0xd1,
+ 0x03, 0x09, 0x00, 0xd3, 0x00, 0xd4, 0x01, 0xa0, 0x00, 0xd6, 0x00, 0xd7,
+ 0x00, 0xd8, 0x00, 0xd9, 0x00, 0xda, 0x00, 0xdb, 0x00, 0xdc, 0x01, 0xaf,
+ 0x03, 0x03, 0x00, 0xdf, 0x00, 0xe0, 0x00, 0xe1, 0x00, 0xe2, 0x01, 0x03,
+ 0x00, 0xe4, 0x00, 0xe5, 0x00, 0xe6, 0x00, 0xe7, 0x00, 0xe8, 0x00, 0xe9,
+ 0x00, 0xea, 0x00, 0xeb, 0x03, 0x01, 0x00, 0xed, 0x00, 0xee, 0x00, 0xef,
+ 0x01, 0x11, 0x00, 0xf1, 0x03, 0x23, 0x00, 0xf3, 0x00, 0xf4, 0x01, 0xa1,
+ 0x00, 0xf6, 0x00, 0xf7, 0x00, 0xf8, 0x00, 0xf9, 0x00, 0xfa, 0x00, 0xfb,
+ 0x00, 0xfc, 0x01, 0xb0, 0x20, 0xab, 0x00, 0xff
+};
diff --git a/package/libs/libiconv/src/include/charmaps/.svn/text-base/windows-874.h.svn-base b/package/libs/libiconv/src/include/charmaps/.svn/text-base/windows-874.h.svn-base
new file mode 100644
index 0000000..5749280
--- /dev/null
+++ b/package/libs/libiconv/src/include/charmaps/.svn/text-base/windows-874.h.svn-base
@@ -0,0 +1,24 @@
+static const unsigned char map_windows_874[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x20, 0xac, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0x20, 0x26, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0x20, 0x18, 0x20, 0x19, 0x20, 0x1c, 0x20, 0x1d, 0x20, 0x22,
+ 0x20, 0x13, 0x20, 0x14, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xa0, 0x0e, 0x01,
+ 0x0e, 0x02, 0x0e, 0x03, 0x0e, 0x04, 0x0e, 0x05, 0x0e, 0x06, 0x0e, 0x07,
+ 0x0e, 0x08, 0x0e, 0x09, 0x0e, 0x0a, 0x0e, 0x0b, 0x0e, 0x0c, 0x0e, 0x0d,
+ 0x0e, 0x0e, 0x0e, 0x0f, 0x0e, 0x10, 0x0e, 0x11, 0x0e, 0x12, 0x0e, 0x13,
+ 0x0e, 0x14, 0x0e, 0x15, 0x0e, 0x16, 0x0e, 0x17, 0x0e, 0x18, 0x0e, 0x19,
+ 0x0e, 0x1a, 0x0e, 0x1b, 0x0e, 0x1c, 0x0e, 0x1d, 0x0e, 0x1e, 0x0e, 0x1f,
+ 0x0e, 0x20, 0x0e, 0x21, 0x0e, 0x22, 0x0e, 0x23, 0x0e, 0x24, 0x0e, 0x25,
+ 0x0e, 0x26, 0x0e, 0x27, 0x0e, 0x28, 0x0e, 0x29, 0x0e, 0x2a, 0x0e, 0x2b,
+ 0x0e, 0x2c, 0x0e, 0x2d, 0x0e, 0x2e, 0x0e, 0x2f, 0x0e, 0x30, 0x0e, 0x31,
+ 0x0e, 0x32, 0x0e, 0x33, 0x0e, 0x34, 0x0e, 0x35, 0x0e, 0x36, 0x0e, 0x37,
+ 0x0e, 0x38, 0x0e, 0x39, 0x0e, 0x3a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0x0e, 0x3f, 0x0e, 0x40, 0x0e, 0x41, 0x0e, 0x42, 0x0e, 0x43,
+ 0x0e, 0x44, 0x0e, 0x45, 0x0e, 0x46, 0x0e, 0x47, 0x0e, 0x48, 0x0e, 0x49,
+ 0x0e, 0x4a, 0x0e, 0x4b, 0x0e, 0x4c, 0x0e, 0x4d, 0x0e, 0x4e, 0x0e, 0x4f,
+ 0x0e, 0x50, 0x0e, 0x51, 0x0e, 0x52, 0x0e, 0x53, 0x0e, 0x54, 0x0e, 0x55,
+ 0x0e, 0x56, 0x0e, 0x57, 0x0e, 0x58, 0x0e, 0x59, 0x0e, 0x5a, 0x0e, 0x5b,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
+};
diff --git a/package/libs/libiconv/src/include/charmaps/iso-8859-10.h b/package/libs/libiconv/src/include/charmaps/iso-8859-10.h
new file mode 100644
index 0000000..cb93d02
--- /dev/null
+++ b/package/libs/libiconv/src/include/charmaps/iso-8859-10.h
@@ -0,0 +1,24 @@
+static const unsigned char map_iso_8859_10[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x81, 0x00, 0x82, 0x00, 0x83,
+ 0x00, 0x84, 0x00, 0x85, 0x00, 0x86, 0x00, 0x87, 0x00, 0x88, 0x00, 0x89,
+ 0x00, 0x8a, 0x00, 0x8b, 0x00, 0x8c, 0x00, 0x8d, 0x00, 0x8e, 0x00, 0x8f,
+ 0x00, 0x90, 0x00, 0x91, 0x00, 0x92, 0x00, 0x93, 0x00, 0x94, 0x00, 0x95,
+ 0x00, 0x96, 0x00, 0x97, 0x00, 0x98, 0x00, 0x99, 0x00, 0x9a, 0x00, 0x9b,
+ 0x00, 0x9c, 0x00, 0x9d, 0x00, 0x9e, 0x00, 0x9f, 0x00, 0xa0, 0x01, 0x04,
+ 0x01, 0x12, 0x01, 0x22, 0x01, 0x2a, 0x01, 0x28, 0x01, 0x36, 0x00, 0xa7,
+ 0x01, 0x3b, 0x01, 0x10, 0x01, 0x60, 0x01, 0x66, 0x01, 0x7d, 0x00, 0xad,
+ 0x01, 0x6a, 0x01, 0x4a, 0x00, 0xb0, 0x01, 0x05, 0x01, 0x13, 0x01, 0x23,
+ 0x01, 0x2b, 0x01, 0x29, 0x01, 0x37, 0x00, 0xb7, 0x01, 0x3c, 0x01, 0x11,
+ 0x01, 0x61, 0x01, 0x67, 0x01, 0x7e, 0x20, 0x15, 0x01, 0x6b, 0x01, 0x4b,
+ 0x01, 0x00, 0x00, 0xc1, 0x00, 0xc2, 0x00, 0xc3, 0x00, 0xc4, 0x00, 0xc5,
+ 0x00, 0xc6, 0x01, 0x2e, 0x01, 0x0c, 0x00, 0xc9, 0x01, 0x18, 0x00, 0xcb,
+ 0x01, 0x16, 0x00, 0xcd, 0x00, 0xce, 0x00, 0xcf, 0x00, 0xd0, 0x01, 0x45,
+ 0x01, 0x4c, 0x00, 0xd3, 0x00, 0xd4, 0x00, 0xd5, 0x00, 0xd6, 0x01, 0x68,
+ 0x00, 0xd8, 0x01, 0x72, 0x00, 0xda, 0x00, 0xdb, 0x00, 0xdc, 0x00, 0xdd,
+ 0x00, 0xde, 0x00, 0xdf, 0x01, 0x01, 0x00, 0xe1, 0x00, 0xe2, 0x00, 0xe3,
+ 0x00, 0xe4, 0x00, 0xe5, 0x00, 0xe6, 0x01, 0x2f, 0x01, 0x0d, 0x00, 0xe9,
+ 0x01, 0x19, 0x00, 0xeb, 0x01, 0x17, 0x00, 0xed, 0x00, 0xee, 0x00, 0xef,
+ 0x00, 0xf0, 0x01, 0x46, 0x01, 0x4d, 0x00, 0xf3, 0x00, 0xf4, 0x00, 0xf5,
+ 0x00, 0xf6, 0x01, 0x69, 0x00, 0xf8, 0x01, 0x73, 0x00, 0xfa, 0x00, 0xfb,
+ 0x00, 0xfc, 0x00, 0xfd, 0x00, 0xfe, 0x01, 0x38
+};
diff --git a/package/libs/libiconv/src/include/charmaps/iso-8859-13.h b/package/libs/libiconv/src/include/charmaps/iso-8859-13.h
new file mode 100644
index 0000000..b44d1b4
--- /dev/null
+++ b/package/libs/libiconv/src/include/charmaps/iso-8859-13.h
@@ -0,0 +1,24 @@
+static const unsigned char map_iso_8859_13[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x81, 0x00, 0x82, 0x00, 0x83,
+ 0x00, 0x84, 0x00, 0x85, 0x00, 0x86, 0x00, 0x87, 0x00, 0x88, 0x00, 0x89,
+ 0x00, 0x8a, 0x00, 0x8b, 0x00, 0x8c, 0x00, 0x8d, 0x00, 0x8e, 0x00, 0x8f,
+ 0x00, 0x90, 0x00, 0x91, 0x00, 0x92, 0x00, 0x93, 0x00, 0x94, 0x00, 0x95,
+ 0x00, 0x96, 0x00, 0x97, 0x00, 0x98, 0x00, 0x99, 0x00, 0x9a, 0x00, 0x9b,
+ 0x00, 0x9c, 0x00, 0x9d, 0x00, 0x9e, 0x00, 0x9f, 0x00, 0xa0, 0x20, 0x1d,
+ 0x00, 0xa2, 0x00, 0xa3, 0x00, 0xa4, 0x20, 0x1e, 0x00, 0xa6, 0x00, 0xa7,
+ 0x00, 0xd8, 0x00, 0xa9, 0x01, 0x56, 0x00, 0xab, 0x00, 0xac, 0x00, 0xad,
+ 0x00, 0xae, 0x00, 0xc6, 0x00, 0xb0, 0x00, 0xb1, 0x00, 0xb2, 0x00, 0xb3,
+ 0x20, 0x1c, 0x00, 0xb5, 0x00, 0xb6, 0x00, 0xb7, 0x00, 0xf8, 0x00, 0xb9,
+ 0x01, 0x57, 0x00, 0xbb, 0x00, 0xbc, 0x00, 0xbd, 0x00, 0xbe, 0x00, 0xe6,
+ 0x01, 0x04, 0x01, 0x2e, 0x01, 0x00, 0x01, 0x06, 0x00, 0xc4, 0x00, 0xc5,
+ 0x01, 0x18, 0x01, 0x12, 0x01, 0x0c, 0x00, 0xc9, 0x01, 0x79, 0x01, 0x16,
+ 0x01, 0x22, 0x01, 0x36, 0x01, 0x2a, 0x01, 0x3b, 0x01, 0x60, 0x01, 0x43,
+ 0x01, 0x45, 0x00, 0xd3, 0x01, 0x4c, 0x00, 0xd5, 0x00, 0xd6, 0x00, 0xd7,
+ 0x01, 0x72, 0x01, 0x41, 0x01, 0x5a, 0x01, 0x6a, 0x00, 0xdc, 0x01, 0x7b,
+ 0x01, 0x7d, 0x00, 0xdf, 0x01, 0x05, 0x01, 0x2f, 0x01, 0x01, 0x01, 0x07,
+ 0x00, 0xe4, 0x00, 0xe5, 0x01, 0x19, 0x01, 0x13, 0x01, 0x0d, 0x00, 0xe9,
+ 0x01, 0x7a, 0x01, 0x17, 0x01, 0x23, 0x01, 0x37, 0x01, 0x2b, 0x01, 0x3c,
+ 0x01, 0x61, 0x01, 0x44, 0x01, 0x46, 0x00, 0xf3, 0x01, 0x4d, 0x00, 0xf5,
+ 0x00, 0xf6, 0x00, 0xf7, 0x01, 0x73, 0x01, 0x42, 0x01, 0x5b, 0x01, 0x6b,
+ 0x00, 0xfc, 0x01, 0x7c, 0x01, 0x7e, 0x20, 0x19
+};
diff --git a/package/libs/libiconv/src/include/charmaps/iso-8859-14.h b/package/libs/libiconv/src/include/charmaps/iso-8859-14.h
new file mode 100644
index 0000000..76cead9
--- /dev/null
+++ b/package/libs/libiconv/src/include/charmaps/iso-8859-14.h
@@ -0,0 +1,25 @@
+static const unsigned char map_iso_8859_14[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x81, 0x00, 0x82, 0x00, 0x83,
+ 0x00, 0x84, 0x00, 0x85, 0x00, 0x86, 0x00, 0x87, 0x00, 0x88, 0x00, 0x89,
+ 0x00, 0x8a, 0x00, 0x8b, 0x00, 0x8c, 0x00, 0x8d, 0x00, 0x8e, 0x00, 0x8f,
+ 0x00, 0x90, 0x00, 0x91, 0x00, 0x92, 0x00, 0x93, 0x00, 0x94, 0x00, 0x95,
+ 0x00, 0x96, 0x00, 0x97, 0x00, 0x98, 0x00, 0x99, 0x00, 0x9a, 0x00, 0x9b,
+ 0x00, 0x9c, 0x00, 0x9d, 0x00, 0x9e, 0x00, 0x9f, 0x00, 0xa0, 0x1e, 0x02,
+ 0x1e, 0x03, 0x00, 0xa3, 0x01, 0x0a, 0x01, 0x0b, 0x1e, 0x0a, 0x00, 0xa7,
+ 0x1e, 0x80, 0x00, 0xa9, 0x1e, 0x82, 0x1e, 0x0b, 0x1e, 0xf2, 0x00, 0xad,
+ 0x00, 0xae, 0x01, 0x78, 0x1e, 0x1e, 0x1e, 0x1f, 0x01, 0x20, 0x01, 0x21,
+ 0x1e, 0x40, 0x1e, 0x41, 0x00, 0xb6, 0x1e, 0x56, 0x1e, 0x81, 0x1e, 0x57,
+ 0x1e, 0x83, 0x1e, 0x60, 0x1e, 0xf3, 0x1e, 0x84, 0x1e, 0x85, 0x1e, 0x61,
+ 0x00, 0xc0, 0x00, 0xc1, 0x00, 0xc2, 0x00, 0xc3, 0x00, 0xc4, 0x00, 0xc5,
+ 0x00, 0xc6, 0x00, 0xc7, 0x00, 0xc8, 0x00, 0xc9, 0x00, 0xca, 0x00, 0xcb,
+ 0x00, 0xcc, 0x00, 0xcd, 0x00, 0xce, 0x00, 0xcf, 0x01, 0x74, 0x00, 0xd1,
+ 0x00, 0xd2, 0x00, 0xd3, 0x00, 0xd4, 0x00, 0xd5, 0x00, 0xd6, 0x1e, 0x6a,
+ 0x00, 0xd8, 0x00, 0xd9, 0x00, 0xda, 0x00, 0xdb, 0x00, 0xdc, 0x00, 0xdd,
+ 0x01, 0x76, 0x00, 0xdf, 0x00, 0xe0, 0x00, 0xe1, 0x00, 0xe2, 0x00, 0xe3,
+ 0x00, 0xe4, 0x00, 0xe5, 0x00, 0xe6, 0x00, 0xe7, 0x00, 0xe8, 0x00, 0xe9,
+ 0x00, 0xea, 0x00, 0xeb, 0x00, 0xec, 0x00, 0xed, 0x00, 0xee, 0x00, 0xef,
+ 0x01, 0x75, 0x00, 0xf1, 0x00, 0xf2, 0x00, 0xf3, 0x00, 0xf4, 0x00, 0xf5,
+ 0x00, 0xf6, 0x1e, 0x6b, 0x00, 0xf8, 0x00, 0xf9, 0x00, 0xfa, 0x00, 0xfb,
+ 0x00, 0xfc, 0x00, 0xfd, 0x01, 0x77, 0x00, 0xff
+};
+
diff --git a/package/libs/libiconv/src/include/charmaps/iso-8859-16.h b/package/libs/libiconv/src/include/charmaps/iso-8859-16.h
new file mode 100644
index 0000000..4437a41
--- /dev/null
+++ b/package/libs/libiconv/src/include/charmaps/iso-8859-16.h
@@ -0,0 +1,24 @@
+static const unsigned char map_iso_8859_16[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x81, 0x00, 0x82, 0x00, 0x83,
+ 0x00, 0x84, 0x00, 0x85, 0x00, 0x86, 0x00, 0x87, 0x00, 0x88, 0x00, 0x89,
+ 0x00, 0x8a, 0x00, 0x8b, 0x00, 0x8c, 0x00, 0x8d, 0x00, 0x8e, 0x00, 0x8f,
+ 0x00, 0x90, 0x00, 0x91, 0x00, 0x92, 0x00, 0x93, 0x00, 0x94, 0x00, 0x95,
+ 0x00, 0x96, 0x00, 0x97, 0x00, 0x98, 0x00, 0x99, 0x00, 0x9a, 0x00, 0x9b,
+ 0x00, 0x9c, 0x00, 0x9d, 0x00, 0x9e, 0x00, 0x9f, 0x00, 0xa0, 0x01, 0x04,
+ 0x01, 0x05, 0x01, 0x41, 0x20, 0xac, 0x20, 0x1e, 0x01, 0x60, 0x00, 0xa7,
+ 0x01, 0x61, 0x00, 0xa9, 0x02, 0x18, 0x00, 0xab, 0x01, 0x79, 0x00, 0xad,
+ 0x01, 0x7a, 0x01, 0x7b, 0x00, 0xb0, 0x00, 0xb1, 0x01, 0x0c, 0x01, 0x42,
+ 0x01, 0x7d, 0x20, 0x1d, 0x00, 0xb6, 0x00, 0xb7, 0x01, 0x7e, 0x01, 0x0d,
+ 0x02, 0x19, 0x00, 0xbb, 0x01, 0x52, 0x01, 0x53, 0x01, 0x78, 0x01, 0x7c,
+ 0x00, 0xc0, 0x00, 0xc1, 0x00, 0xc2, 0x01, 0x02, 0x00, 0xc4, 0x01, 0x06,
+ 0x00, 0xc6, 0x00, 0xc7, 0x00, 0xc8, 0x00, 0xc9, 0x00, 0xca, 0x00, 0xcb,
+ 0x00, 0xcc, 0x00, 0xcd, 0x00, 0xce, 0x00, 0xcf, 0x01, 0x10, 0x01, 0x43,
+ 0x00, 0xd2, 0x00, 0xd3, 0x00, 0xd4, 0x01, 0x50, 0x00, 0xd6, 0x01, 0x5a,
+ 0x01, 0x70, 0x00, 0xd9, 0x00, 0xda, 0x00, 0xdb, 0x00, 0xdc, 0x01, 0x18,
+ 0x02, 0x1a, 0x00, 0xdf, 0x00, 0xe0, 0x00, 0xe1, 0x00, 0xe2, 0x01, 0x03,
+ 0x00, 0xe4, 0x01, 0x07, 0x00, 0xe6, 0x00, 0xe7, 0x00, 0xe8, 0x00, 0xe9,
+ 0x00, 0xea, 0x00, 0xeb, 0x00, 0xec, 0x00, 0xed, 0x00, 0xee, 0x00, 0xef,
+ 0x01, 0x11, 0x01, 0x44, 0x00, 0xf2, 0x00, 0xf3, 0x00, 0xf4, 0x01, 0x51,
+ 0x00, 0xf6, 0x01, 0x5b, 0x01, 0x71, 0x00, 0xf9, 0x00, 0xfa, 0x00, 0xfb,
+ 0x00, 0xfc, 0x01, 0x19, 0x02, 0x1b, 0x00, 0xff
+};
diff --git a/package/libs/libiconv/src/include/charmaps/iso-8859-2.h b/package/libs/libiconv/src/include/charmaps/iso-8859-2.h
new file mode 100644
index 0000000..631610e
--- /dev/null
+++ b/package/libs/libiconv/src/include/charmaps/iso-8859-2.h
@@ -0,0 +1,24 @@
+static const unsigned char map_iso_8859_2[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x81, 0x00, 0x82, 0x00, 0x83,
+ 0x00, 0x84, 0x00, 0x85, 0x00, 0x86, 0x00, 0x87, 0x00, 0x88, 0x00, 0x89,
+ 0x00, 0x8a, 0x00, 0x8b, 0x00, 0x8c, 0x00, 0x8d, 0x00, 0x8e, 0x00, 0x8f,
+ 0x00, 0x90, 0x00, 0x91, 0x00, 0x92, 0x00, 0x93, 0x00, 0x94, 0x00, 0x95,
+ 0x00, 0x96, 0x00, 0x97, 0x00, 0x98, 0x00, 0x99, 0x00, 0x9a, 0x00, 0x9b,
+ 0x00, 0x9c, 0x00, 0x9d, 0x00, 0x9e, 0x00, 0x9f, 0x00, 0xa0, 0x01, 0x04,
+ 0x02, 0xd8, 0x01, 0x41, 0x00, 0xa4, 0x01, 0x3d, 0x01, 0x5a, 0x00, 0xa7,
+ 0x00, 0xa8, 0x01, 0x60, 0x01, 0x5e, 0x01, 0x64, 0x01, 0x79, 0x00, 0xad,
+ 0x01, 0x7d, 0x01, 0x7b, 0x00, 0xb0, 0x01, 0x05, 0x02, 0xdb, 0x01, 0x42,
+ 0x00, 0xb4, 0x01, 0x3e, 0x01, 0x5b, 0x02, 0xc7, 0x00, 0xb8, 0x01, 0x61,
+ 0x01, 0x5f, 0x01, 0x65, 0x01, 0x7a, 0x02, 0xdd, 0x01, 0x7e, 0x01, 0x7c,
+ 0x01, 0x54, 0x00, 0xc1, 0x00, 0xc2, 0x01, 0x02, 0x00, 0xc4, 0x01, 0x39,
+ 0x01, 0x06, 0x00, 0xc7, 0x01, 0x0c, 0x00, 0xc9, 0x01, 0x18, 0x00, 0xcb,
+ 0x01, 0x1a, 0x00, 0xcd, 0x00, 0xce, 0x01, 0x0e, 0x01, 0x10, 0x01, 0x43,
+ 0x01, 0x47, 0x00, 0xd3, 0x00, 0xd4, 0x01, 0x50, 0x00, 0xd6, 0x00, 0xd7,
+ 0x01, 0x58, 0x01, 0x6e, 0x00, 0xda, 0x01, 0x70, 0x00, 0xdc, 0x00, 0xdd,
+ 0x01, 0x62, 0x00, 0xdf, 0x01, 0x55, 0x00, 0xe1, 0x00, 0xe2, 0x01, 0x03,
+ 0x00, 0xe4, 0x01, 0x3a, 0x01, 0x07, 0x00, 0xe7, 0x01, 0x0d, 0x00, 0xe9,
+ 0x01, 0x19, 0x00, 0xeb, 0x01, 0x1b, 0x00, 0xed, 0x00, 0xee, 0x01, 0x0f,
+ 0x01, 0x11, 0x01, 0x44, 0x01, 0x48, 0x00, 0xf3, 0x00, 0xf4, 0x01, 0x51,
+ 0x00, 0xf6, 0x00, 0xf7, 0x01, 0x59, 0x01, 0x6f, 0x00, 0xfa, 0x01, 0x71,
+ 0x00, 0xfc, 0x00, 0xfd, 0x01, 0x63, 0x02, 0xd9
+};
diff --git a/package/libs/libiconv/src/include/charmaps/iso-8859-3.h b/package/libs/libiconv/src/include/charmaps/iso-8859-3.h
new file mode 100644
index 0000000..cd76d59
--- /dev/null
+++ b/package/libs/libiconv/src/include/charmaps/iso-8859-3.h
@@ -0,0 +1,24 @@
+static const unsigned char map_iso_8859_3[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x81, 0x00, 0x82, 0x00, 0x83,
+ 0x00, 0x84, 0x00, 0x85, 0x00, 0x86, 0x00, 0x87, 0x00, 0x88, 0x00, 0x89,
+ 0x00, 0x8a, 0x00, 0x8b, 0x00, 0x8c, 0x00, 0x8d, 0x00, 0x8e, 0x00, 0x8f,
+ 0x00, 0x90, 0x00, 0x91, 0x00, 0x92, 0x00, 0x93, 0x00, 0x94, 0x00, 0x95,
+ 0x00, 0x96, 0x00, 0x97, 0x00, 0x98, 0x00, 0x99, 0x00, 0x9a, 0x00, 0x9b,
+ 0x00, 0x9c, 0x00, 0x9d, 0x00, 0x9e, 0x00, 0x9f, 0x00, 0xa0, 0x01, 0x26,
+ 0x02, 0xd8, 0x00, 0xa3, 0x00, 0xa4, 0xff, 0xff, 0x01, 0x24, 0x00, 0xa7,
+ 0x00, 0xa8, 0x01, 0x30, 0x01, 0x5e, 0x01, 0x1e, 0x01, 0x34, 0x00, 0xad,
+ 0xff, 0xff, 0x01, 0x7b, 0x00, 0xb0, 0x01, 0x27, 0x00, 0xb2, 0x00, 0xb3,
+ 0x00, 0xb4, 0x00, 0xb5, 0x01, 0x25, 0x00, 0xb7, 0x00, 0xb8, 0x01, 0x31,
+ 0x01, 0x5f, 0x01, 0x1f, 0x01, 0x35, 0x00, 0xbd, 0xff, 0xff, 0x01, 0x7c,
+ 0x00, 0xc0, 0x00, 0xc1, 0x00, 0xc2, 0xff, 0xff, 0x00, 0xc4, 0x01, 0x0a,
+ 0x01, 0x08, 0x00, 0xc7, 0x00, 0xc8, 0x00, 0xc9, 0x00, 0xca, 0x00, 0xcb,
+ 0x00, 0xcc, 0x00, 0xcd, 0x00, 0xce, 0x00, 0xcf, 0xff, 0xff, 0x00, 0xd1,
+ 0x00, 0xd2, 0x00, 0xd3, 0x00, 0xd4, 0x01, 0x20, 0x00, 0xd6, 0x00, 0xd7,
+ 0x01, 0x1c, 0x00, 0xd9, 0x00, 0xda, 0x00, 0xdb, 0x00, 0xdc, 0x01, 0x6c,
+ 0x01, 0x5c, 0x00, 0xdf, 0x00, 0xe0, 0x00, 0xe1, 0x00, 0xe2, 0xff, 0xff,
+ 0x00, 0xe4, 0x01, 0x0b, 0x01, 0x09, 0x00, 0xe7, 0x00, 0xe8, 0x00, 0xe9,
+ 0x00, 0xea, 0x00, 0xeb, 0x00, 0xec, 0x00, 0xed, 0x00, 0xee, 0x00, 0xef,
+ 0xff, 0xff, 0x00, 0xf1, 0x00, 0xf2, 0x00, 0xf3, 0x00, 0xf4, 0x01, 0x21,
+ 0x00, 0xf6, 0x00, 0xf7, 0x01, 0x1d, 0x00, 0xf9, 0x00, 0xfa, 0x00, 0xfb,
+ 0x00, 0xfc, 0x01, 0x6d, 0x01, 0x5d, 0x02, 0xd9
+};
diff --git a/package/libs/libiconv/src/include/charmaps/iso-8859-4.h b/package/libs/libiconv/src/include/charmaps/iso-8859-4.h
new file mode 100644
index 0000000..5db2f77
--- /dev/null
+++ b/package/libs/libiconv/src/include/charmaps/iso-8859-4.h
@@ -0,0 +1,24 @@
+static const unsigned char map_iso_8859_4[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x81, 0x00, 0x82, 0x00, 0x83,
+ 0x00, 0x84, 0x00, 0x85, 0x00, 0x86, 0x00, 0x87, 0x00, 0x88, 0x00, 0x89,
+ 0x00, 0x8a, 0x00, 0x8b, 0x00, 0x8c, 0x00, 0x8d, 0x00, 0x8e, 0x00, 0x8f,
+ 0x00, 0x90, 0x00, 0x91, 0x00, 0x92, 0x00, 0x93, 0x00, 0x94, 0x00, 0x95,
+ 0x00, 0x96, 0x00, 0x97, 0x00, 0x98, 0x00, 0x99, 0x00, 0x9a, 0x00, 0x9b,
+ 0x00, 0x9c, 0x00, 0x9d, 0x00, 0x9e, 0x00, 0x9f, 0x00, 0xa0, 0x01, 0x04,
+ 0x01, 0x38, 0x01, 0x56, 0x00, 0xa4, 0x01, 0x28, 0x01, 0x3b, 0x00, 0xa7,
+ 0x00, 0xa8, 0x01, 0x60, 0x01, 0x12, 0x01, 0x22, 0x01, 0x66, 0x00, 0xad,
+ 0x01, 0x7d, 0x00, 0xaf, 0x00, 0xb0, 0x01, 0x05, 0x02, 0xdb, 0x01, 0x57,
+ 0x00, 0xb4, 0x01, 0x29, 0x01, 0x3c, 0x02, 0xc7, 0x00, 0xb8, 0x01, 0x61,
+ 0x01, 0x13, 0x01, 0x23, 0x01, 0x67, 0x01, 0x4a, 0x01, 0x7e, 0x01, 0x4b,
+ 0x01, 0x00, 0x00, 0xc1, 0x00, 0xc2, 0x00, 0xc3, 0x00, 0xc4, 0x00, 0xc5,
+ 0x00, 0xc6, 0x01, 0x2e, 0x01, 0x0c, 0x00, 0xc9, 0x01, 0x18, 0x00, 0xcb,
+ 0x01, 0x16, 0x00, 0xcd, 0x00, 0xce, 0x01, 0x2a, 0x01, 0x10, 0x01, 0x45,
+ 0x01, 0x4c, 0x01, 0x36, 0x00, 0xd4, 0x00, 0xd5, 0x00, 0xd6, 0x00, 0xd7,
+ 0x00, 0xd8, 0x01, 0x72, 0x00, 0xda, 0x00, 0xdb, 0x00, 0xdc, 0x01, 0x68,
+ 0x01, 0x6a, 0x00, 0xdf, 0x01, 0x01, 0x00, 0xe1, 0x00, 0xe2, 0x00, 0xe3,
+ 0x00, 0xe4, 0x00, 0xe5, 0x00, 0xe6, 0x01, 0x2f, 0x01, 0x0d, 0x00, 0xe9,
+ 0x01, 0x19, 0x00, 0xeb, 0x01, 0x17, 0x00, 0xed, 0x00, 0xee, 0x01, 0x2b,
+ 0x01, 0x11, 0x01, 0x46, 0x01, 0x4d, 0x01, 0x37, 0x00, 0xf4, 0x00, 0xf5,
+ 0x00, 0xf6, 0x00, 0xf7, 0x00, 0xf8, 0x01, 0x73, 0x00, 0xfa, 0x00, 0xfb,
+ 0x00, 0xfc, 0x01, 0x69, 0x01, 0x6b, 0x02, 0xd9
+};
diff --git a/package/libs/libiconv/src/include/charmaps/iso-8859-5.h b/package/libs/libiconv/src/include/charmaps/iso-8859-5.h
new file mode 100644
index 0000000..d9fe684
--- /dev/null
+++ b/package/libs/libiconv/src/include/charmaps/iso-8859-5.h
@@ -0,0 +1,24 @@
+static const unsigned char map_iso_8859_5[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x81, 0x00, 0x82, 0x00, 0x83,
+ 0x00, 0x84, 0x00, 0x85, 0x00, 0x86, 0x00, 0x87, 0x00, 0x88, 0x00, 0x89,
+ 0x00, 0x8a, 0x00, 0x8b, 0x00, 0x8c, 0x00, 0x8d, 0x00, 0x8e, 0x00, 0x8f,
+ 0x00, 0x90, 0x00, 0x91, 0x00, 0x92, 0x00, 0x93, 0x00, 0x94, 0x00, 0x95,
+ 0x00, 0x96, 0x00, 0x97, 0x00, 0x98, 0x00, 0x99, 0x00, 0x9a, 0x00, 0x9b,
+ 0x00, 0x9c, 0x00, 0x9d, 0x00, 0x9e, 0x00, 0x9f, 0x00, 0xa0, 0x04, 0x01,
+ 0x04, 0x02, 0x04, 0x03, 0x04, 0x04, 0x04, 0x05, 0x04, 0x06, 0x04, 0x07,
+ 0x04, 0x08, 0x04, 0x09, 0x04, 0x0a, 0x04, 0x0b, 0x04, 0x0c, 0x00, 0xad,
+ 0x04, 0x0e, 0x04, 0x0f, 0x04, 0x10, 0x04, 0x11, 0x04, 0x12, 0x04, 0x13,
+ 0x04, 0x14, 0x04, 0x15, 0x04, 0x16, 0x04, 0x17, 0x04, 0x18, 0x04, 0x19,
+ 0x04, 0x1a, 0x04, 0x1b, 0x04, 0x1c, 0x04, 0x1d, 0x04, 0x1e, 0x04, 0x1f,
+ 0x04, 0x20, 0x04, 0x21, 0x04, 0x22, 0x04, 0x23, 0x04, 0x24, 0x04, 0x25,
+ 0x04, 0x26, 0x04, 0x27, 0x04, 0x28, 0x04, 0x29, 0x04, 0x2a, 0x04, 0x2b,
+ 0x04, 0x2c, 0x04, 0x2d, 0x04, 0x2e, 0x04, 0x2f, 0x04, 0x30, 0x04, 0x31,
+ 0x04, 0x32, 0x04, 0x33, 0x04, 0x34, 0x04, 0x35, 0x04, 0x36, 0x04, 0x37,
+ 0x04, 0x38, 0x04, 0x39, 0x04, 0x3a, 0x04, 0x3b, 0x04, 0x3c, 0x04, 0x3d,
+ 0x04, 0x3e, 0x04, 0x3f, 0x04, 0x40, 0x04, 0x41, 0x04, 0x42, 0x04, 0x43,
+ 0x04, 0x44, 0x04, 0x45, 0x04, 0x46, 0x04, 0x47, 0x04, 0x48, 0x04, 0x49,
+ 0x04, 0x4a, 0x04, 0x4b, 0x04, 0x4c, 0x04, 0x4d, 0x04, 0x4e, 0x04, 0x4f,
+ 0x21, 0x16, 0x04, 0x51, 0x04, 0x52, 0x04, 0x53, 0x04, 0x54, 0x04, 0x55,
+ 0x04, 0x56, 0x04, 0x57, 0x04, 0x58, 0x04, 0x59, 0x04, 0x5a, 0x04, 0x5b,
+ 0x04, 0x5c, 0x00, 0xa7, 0x04, 0x5e, 0x04, 0x5f
+};
diff --git a/package/libs/libiconv/src/include/charmaps/iso-8859-6.h b/package/libs/libiconv/src/include/charmaps/iso-8859-6.h
new file mode 100644
index 0000000..820020f
--- /dev/null
+++ b/package/libs/libiconv/src/include/charmaps/iso-8859-6.h
@@ -0,0 +1,24 @@
+static const unsigned char map_iso_8859_6[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x81, 0x00, 0x82, 0x00, 0x83,
+ 0x00, 0x84, 0x00, 0x85, 0x00, 0x86, 0x00, 0x87, 0x00, 0x88, 0x00, 0x89,
+ 0x00, 0x8a, 0x00, 0x8b, 0x00, 0x8c, 0x00, 0x8d, 0x00, 0x8e, 0x00, 0x8f,
+ 0x00, 0x90, 0x00, 0x91, 0x00, 0x92, 0x00, 0x93, 0x00, 0x94, 0x00, 0x95,
+ 0x00, 0x96, 0x00, 0x97, 0x00, 0x98, 0x00, 0x99, 0x00, 0x9a, 0x00, 0x9b,
+ 0x00, 0x9c, 0x00, 0x9d, 0x00, 0x9e, 0x00, 0x9f, 0x00, 0xa0, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0x00, 0xa4, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x06, 0x0c, 0x00, 0xad,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0x06, 0x1b, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x06, 0x1f,
+ 0xff, 0xff, 0x06, 0x21, 0x06, 0x22, 0x06, 0x23, 0x06, 0x24, 0x06, 0x25,
+ 0x06, 0x26, 0x06, 0x27, 0x06, 0x28, 0x06, 0x29, 0x06, 0x2a, 0x06, 0x2b,
+ 0x06, 0x2c, 0x06, 0x2d, 0x06, 0x2e, 0x06, 0x2f, 0x06, 0x30, 0x06, 0x31,
+ 0x06, 0x32, 0x06, 0x33, 0x06, 0x34, 0x06, 0x35, 0x06, 0x36, 0x06, 0x37,
+ 0x06, 0x38, 0x06, 0x39, 0x06, 0x3a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0x06, 0x40, 0x06, 0x41, 0x06, 0x42, 0x06, 0x43,
+ 0x06, 0x44, 0x06, 0x45, 0x06, 0x46, 0x06, 0x47, 0x06, 0x48, 0x06, 0x49,
+ 0x06, 0x4a, 0x06, 0x4b, 0x06, 0x4c, 0x06, 0x4d, 0x06, 0x4e, 0x06, 0x4f,
+ 0x06, 0x50, 0x06, 0x51, 0x06, 0x52, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
+};
diff --git a/package/libs/libiconv/src/include/charmaps/iso-8859-7.h b/package/libs/libiconv/src/include/charmaps/iso-8859-7.h
new file mode 100644
index 0000000..174f9d3
--- /dev/null
+++ b/package/libs/libiconv/src/include/charmaps/iso-8859-7.h
@@ -0,0 +1,24 @@
+static const unsigned char map_iso_8859_7[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x81, 0x00, 0x82, 0x00, 0x83,
+ 0x00, 0x84, 0x00, 0x85, 0x00, 0x86, 0x00, 0x87, 0x00, 0x88, 0x00, 0x89,
+ 0x00, 0x8a, 0x00, 0x8b, 0x00, 0x8c, 0x00, 0x8d, 0x00, 0x8e, 0x00, 0x8f,
+ 0x00, 0x90, 0x00, 0x91, 0x00, 0x92, 0x00, 0x93, 0x00, 0x94, 0x00, 0x95,
+ 0x00, 0x96, 0x00, 0x97, 0x00, 0x98, 0x00, 0x99, 0x00, 0x9a, 0x00, 0x9b,
+ 0x00, 0x9c, 0x00, 0x9d, 0x00, 0x9e, 0x00, 0x9f, 0x00, 0xa0, 0x20, 0x18,
+ 0x20, 0x19, 0x00, 0xa3, 0x20, 0xac, 0x20, 0xaf, 0x00, 0xa6, 0x00, 0xa7,
+ 0x00, 0xa8, 0x00, 0xa9, 0x03, 0x7a, 0x00, 0xab, 0x00, 0xac, 0x00, 0xad,
+ 0xff, 0xff, 0x20, 0x15, 0x00, 0xb0, 0x00, 0xb1, 0x00, 0xb2, 0x00, 0xb3,
+ 0x03, 0x84, 0x03, 0x85, 0x03, 0x86, 0x00, 0xb7, 0x03, 0x88, 0x03, 0x89,
+ 0x03, 0x8a, 0x00, 0xbb, 0x03, 0x8c, 0x00, 0xbd, 0x03, 0x8e, 0x03, 0x8f,
+ 0x03, 0x90, 0x03, 0x91, 0x03, 0x92, 0x03, 0x93, 0x03, 0x94, 0x03, 0x95,
+ 0x03, 0x96, 0x03, 0x97, 0x03, 0x98, 0x03, 0x99, 0x03, 0x9a, 0x03, 0x9b,
+ 0x03, 0x9c, 0x03, 0x9d, 0x03, 0x9e, 0x03, 0x9f, 0x03, 0xa0, 0x03, 0xa1,
+ 0xff, 0xff, 0x03, 0xa3, 0x03, 0xa4, 0x03, 0xa5, 0x03, 0xa6, 0x03, 0xa7,
+ 0x03, 0xa8, 0x03, 0xa9, 0x03, 0xaa, 0x03, 0xab, 0x03, 0xac, 0x03, 0xad,
+ 0x03, 0xae, 0x03, 0xaf, 0x03, 0xb0, 0x03, 0xb1, 0x03, 0xb2, 0x03, 0xb3,
+ 0x03, 0xb4, 0x03, 0xb5, 0x03, 0xb6, 0x03, 0xb7, 0x03, 0xb8, 0x03, 0xb9,
+ 0x03, 0xba, 0x03, 0xbb, 0x03, 0xbc, 0x03, 0xbd, 0x03, 0xbe, 0x03, 0xbf,
+ 0x03, 0xc0, 0x03, 0xc1, 0x03, 0xc2, 0x03, 0xc3, 0x03, 0xc4, 0x03, 0xc5,
+ 0x03, 0xc6, 0x03, 0xc7, 0x03, 0xc8, 0x03, 0xc9, 0x03, 0xca, 0x03, 0xcb,
+ 0x03, 0xcc, 0x03, 0xcd, 0x03, 0xce, 0xff, 0xff
+};
diff --git a/package/libs/libiconv/src/include/charmaps/iso-8859-8.h b/package/libs/libiconv/src/include/charmaps/iso-8859-8.h
new file mode 100644
index 0000000..66d4a5e
--- /dev/null
+++ b/package/libs/libiconv/src/include/charmaps/iso-8859-8.h
@@ -0,0 +1,24 @@
+static const unsigned char map_iso_8859_8[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x81, 0x00, 0x82, 0x00, 0x83,
+ 0x00, 0x84, 0x00, 0x85, 0x00, 0x86, 0x00, 0x87, 0x00, 0x88, 0x00, 0x89,
+ 0x00, 0x8a, 0x00, 0x8b, 0x00, 0x8c, 0x00, 0x8d, 0x00, 0x8e, 0x00, 0x8f,
+ 0x00, 0x90, 0x00, 0x91, 0x00, 0x92, 0x00, 0x93, 0x00, 0x94, 0x00, 0x95,
+ 0x00, 0x96, 0x00, 0x97, 0x00, 0x98, 0x00, 0x99, 0x00, 0x9a, 0x00, 0x9b,
+ 0x00, 0x9c, 0x00, 0x9d, 0x00, 0x9e, 0x00, 0x9f, 0x00, 0xa0, 0xff, 0xff,
+ 0x00, 0xa2, 0x00, 0xa3, 0x00, 0xa4, 0x00, 0xa5, 0x00, 0xa6, 0x00, 0xa7,
+ 0x00, 0xa8, 0x00, 0xa9, 0x00, 0xd7, 0x00, 0xab, 0x00, 0xac, 0x00, 0xad,
+ 0x00, 0xae, 0x00, 0xaf, 0x00, 0xb0, 0x00, 0xb1, 0x00, 0xb2, 0x00, 0xb3,
+ 0x00, 0xb4, 0x00, 0xb5, 0x00, 0xb6, 0x00, 0xb7, 0x00, 0xb8, 0x00, 0xb9,
+ 0x00, 0xf7, 0x00, 0xbb, 0x00, 0xbc, 0x00, 0xbd, 0x00, 0xbe, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0x20, 0x17, 0x05, 0xd0, 0x05, 0xd1, 0x05, 0xd2, 0x05, 0xd3,
+ 0x05, 0xd4, 0x05, 0xd5, 0x05, 0xd6, 0x05, 0xd7, 0x05, 0xd8, 0x05, 0xd9,
+ 0x05, 0xda, 0x05, 0xdb, 0x05, 0xdc, 0x05, 0xdd, 0x05, 0xde, 0x05, 0xdf,
+ 0x05, 0xe0, 0x05, 0xe1, 0x05, 0xe2, 0x05, 0xe3, 0x05, 0xe4, 0x05, 0xe5,
+ 0x05, 0xe6, 0x05, 0xe7, 0x05, 0xe8, 0x05, 0xe9, 0x05, 0xea, 0xff, 0xff,
+ 0xff, 0xff, 0x20, 0x0e, 0x20, 0x0f, 0xff, 0xff
+};
diff --git a/package/libs/libiconv/src/include/charmaps/iso-8859-9.h b/package/libs/libiconv/src/include/charmaps/iso-8859-9.h
new file mode 100644
index 0000000..f1a8646
--- /dev/null
+++ b/package/libs/libiconv/src/include/charmaps/iso-8859-9.h
@@ -0,0 +1,24 @@
+static const unsigned char map_iso_8859_9[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x81, 0x00, 0x82, 0x00, 0x83,
+ 0x00, 0x84, 0x00, 0x85, 0x00, 0x86, 0x00, 0x87, 0x00, 0x88, 0x00, 0x89,
+ 0x00, 0x8a, 0x00, 0x8b, 0x00, 0x8c, 0x00, 0x8d, 0x00, 0x8e, 0x00, 0x8f,
+ 0x00, 0x90, 0x00, 0x91, 0x00, 0x92, 0x00, 0x93, 0x00, 0x94, 0x00, 0x95,
+ 0x00, 0x96, 0x00, 0x97, 0x00, 0x98, 0x00, 0x99, 0x00, 0x9a, 0x00, 0x9b,
+ 0x00, 0x9c, 0x00, 0x9d, 0x00, 0x9e, 0x00, 0x9f, 0x00, 0xa0, 0x00, 0xa1,
+ 0x00, 0xa2, 0x00, 0xa3, 0x00, 0xa4, 0x00, 0xa5, 0x00, 0xa6, 0x00, 0xa7,
+ 0x00, 0xa8, 0x00, 0xa9, 0x00, 0xaa, 0x00, 0xab, 0x00, 0xac, 0x00, 0xad,
+ 0x00, 0xae, 0x00, 0xaf, 0x00, 0xb0, 0x00, 0xb1, 0x00, 0xb2, 0x00, 0xb3,
+ 0x00, 0xb4, 0x00, 0xb5, 0x00, 0xb6, 0x00, 0xb7, 0x00, 0xb8, 0x00, 0xb9,
+ 0x00, 0xba, 0x00, 0xbb, 0x00, 0xbc, 0x00, 0xbd, 0x00, 0xbe, 0x00, 0xbf,
+ 0x00, 0xc0, 0x00, 0xc1, 0x00, 0xc2, 0x00, 0xc3, 0x00, 0xc4, 0x00, 0xc5,
+ 0x00, 0xc6, 0x00, 0xc7, 0x00, 0xc8, 0x00, 0xc9, 0x00, 0xca, 0x00, 0xcb,
+ 0x00, 0xcc, 0x00, 0xcd, 0x00, 0xce, 0x00, 0xcf, 0x01, 0x1e, 0x00, 0xd1,
+ 0x00, 0xd2, 0x00, 0xd3, 0x00, 0xd4, 0x00, 0xd5, 0x00, 0xd6, 0x00, 0xd7,
+ 0x00, 0xd8, 0x00, 0xd9, 0x00, 0xda, 0x00, 0xdb, 0x00, 0xdc, 0x01, 0x30,
+ 0x01, 0x5e, 0x00, 0xdf, 0x00, 0xe0, 0x00, 0xe1, 0x00, 0xe2, 0x00, 0xe3,
+ 0x00, 0xe4, 0x00, 0xe5, 0x00, 0xe6, 0x00, 0xe7, 0x00, 0xe8, 0x00, 0xe9,
+ 0x00, 0xea, 0x00, 0xeb, 0x00, 0xec, 0x00, 0xed, 0x00, 0xee, 0x00, 0xef,
+ 0x01, 0x1f, 0x00, 0xf1, 0x00, 0xf2, 0x00, 0xf3, 0x00, 0xf4, 0x00, 0xf5,
+ 0x00, 0xf6, 0x00, 0xf7, 0x00, 0xf8, 0x00, 0xf9, 0x00, 0xfa, 0x00, 0xfb,
+ 0x00, 0xfc, 0x01, 0x31, 0x01, 0x5f, 0x00, 0xff
+};
diff --git a/package/libs/libiconv/src/include/charmaps/koi8-r.h b/package/libs/libiconv/src/include/charmaps/koi8-r.h
new file mode 100644
index 0000000..c2453a5
--- /dev/null
+++ b/package/libs/libiconv/src/include/charmaps/koi8-r.h
@@ -0,0 +1,24 @@
+static const unsigned char map_koi8_r[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x25, 0x00, 0x25, 0x02, 0x25, 0x0c, 0x25, 0x10,
+ 0x25, 0x14, 0x25, 0x18, 0x25, 0x1c, 0x25, 0x24, 0x25, 0x2c, 0x25, 0x34,
+ 0x25, 0x3c, 0x25, 0x80, 0x25, 0x84, 0x25, 0x88, 0x25, 0x8c, 0x25, 0x90,
+ 0x25, 0x91, 0x25, 0x92, 0x25, 0x93, 0x23, 0x20, 0x25, 0xa0, 0x22, 0x19,
+ 0x22, 0x1a, 0x22, 0x48, 0x22, 0x64, 0x22, 0x65, 0x00, 0xa0, 0x23, 0x21,
+ 0x00, 0xb0, 0x00, 0xb2, 0x00, 0xb7, 0x00, 0xf7, 0x25, 0x50, 0x25, 0x51,
+ 0x25, 0x52, 0x04, 0x51, 0x25, 0x53, 0x25, 0x54, 0x25, 0x55, 0x25, 0x56,
+ 0x25, 0x57, 0x25, 0x58, 0x25, 0x59, 0x25, 0x5a, 0x25, 0x5b, 0x25, 0x5c,
+ 0x25, 0x5d, 0x25, 0x5e, 0x25, 0x5f, 0x25, 0x60, 0x25, 0x61, 0x04, 0x01,
+ 0x25, 0x62, 0x25, 0x63, 0x25, 0x64, 0x25, 0x65, 0x25, 0x66, 0x25, 0x67,
+ 0x25, 0x68, 0x25, 0x69, 0x25, 0x6a, 0x25, 0x6b, 0x25, 0x6c, 0x00, 0xa9,
+ 0x04, 0x4e, 0x04, 0x30, 0x04, 0x31, 0x04, 0x46, 0x04, 0x34, 0x04, 0x35,
+ 0x04, 0x44, 0x04, 0x33, 0x04, 0x45, 0x04, 0x38, 0x04, 0x39, 0x04, 0x3a,
+ 0x04, 0x3b, 0x04, 0x3c, 0x04, 0x3d, 0x04, 0x3e, 0x04, 0x3f, 0x04, 0x4f,
+ 0x04, 0x40, 0x04, 0x41, 0x04, 0x42, 0x04, 0x43, 0x04, 0x36, 0x04, 0x32,
+ 0x04, 0x4c, 0x04, 0x4b, 0x04, 0x37, 0x04, 0x48, 0x04, 0x4d, 0x04, 0x49,
+ 0x04, 0x47, 0x04, 0x4a, 0x04, 0x2e, 0x04, 0x10, 0x04, 0x11, 0x04, 0x26,
+ 0x04, 0x14, 0x04, 0x15, 0x04, 0x24, 0x04, 0x13, 0x04, 0x25, 0x04, 0x18,
+ 0x04, 0x19, 0x04, 0x1a, 0x04, 0x1b, 0x04, 0x1c, 0x04, 0x1d, 0x04, 0x1e,
+ 0x04, 0x1f, 0x04, 0x2f, 0x04, 0x20, 0x04, 0x21, 0x04, 0x22, 0x04, 0x23,
+ 0x04, 0x16, 0x04, 0x12, 0x04, 0x2c, 0x04, 0x2b, 0x04, 0x17, 0x04, 0x28,
+ 0x04, 0x2d, 0x04, 0x29, 0x04, 0x27, 0x04, 0x2a
+};
diff --git a/package/libs/libiconv/src/include/charmaps/windows-1250.h b/package/libs/libiconv/src/include/charmaps/windows-1250.h
new file mode 100644
index 0000000..8e4723e
--- /dev/null
+++ b/package/libs/libiconv/src/include/charmaps/windows-1250.h
@@ -0,0 +1,24 @@
+static const unsigned char map_windows_1250[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x20, 0xac, 0xff, 0xff, 0x20, 0x1a, 0xff, 0xff,
+ 0x20, 0x1e, 0x20, 0x26, 0x20, 0x20, 0x20, 0x21, 0xff, 0xff, 0x20, 0x30,
+ 0x01, 0x60, 0x20, 0x39, 0x01, 0x5a, 0x01, 0x64, 0x01, 0x7d, 0x01, 0x79,
+ 0xff, 0xff, 0x20, 0x18, 0x20, 0x19, 0x20, 0x1c, 0x20, 0x1d, 0x20, 0x22,
+ 0x20, 0x13, 0x20, 0x14, 0xff, 0xff, 0x21, 0x22, 0x01, 0x61, 0x20, 0x3a,
+ 0x01, 0x5b, 0x01, 0x65, 0x01, 0x7e, 0x01, 0x7a, 0x00, 0xa0, 0x02, 0xc7,
+ 0x02, 0xd8, 0x01, 0x41, 0x00, 0xa4, 0x01, 0x04, 0x00, 0xa6, 0x00, 0xa7,
+ 0x00, 0xa8, 0x00, 0xa9, 0x01, 0x5e, 0x00, 0xab, 0x00, 0xac, 0x00, 0xad,
+ 0x00, 0xae, 0x01, 0x7b, 0x00, 0xb0, 0x00, 0xb1, 0x02, 0xdb, 0x01, 0x42,
+ 0x00, 0xb4, 0x00, 0xb5, 0x00, 0xb6, 0x00, 0xb7, 0x00, 0xb8, 0x01, 0x05,
+ 0x01, 0x5f, 0x00, 0xbb, 0x01, 0x3d, 0x02, 0xdd, 0x01, 0x3e, 0x01, 0x7c,
+ 0x01, 0x54, 0x00, 0xc1, 0x00, 0xc2, 0x01, 0x02, 0x00, 0xc4, 0x01, 0x39,
+ 0x01, 0x06, 0x00, 0xc7, 0x01, 0x0c, 0x00, 0xc9, 0x01, 0x18, 0x00, 0xcb,
+ 0x01, 0x1a, 0x00, 0xcd, 0x00, 0xce, 0x01, 0x0e, 0x01, 0x10, 0x01, 0x43,
+ 0x01, 0x47, 0x00, 0xd3, 0x00, 0xd4, 0x01, 0x50, 0x00, 0xd6, 0x00, 0xd7,
+ 0x01, 0x58, 0x01, 0x6e, 0x00, 0xda, 0x01, 0x70, 0x00, 0xdc, 0x00, 0xdd,
+ 0x01, 0x62, 0x00, 0xdf, 0x01, 0x55, 0x00, 0xe1, 0x00, 0xe2, 0x01, 0x03,
+ 0x00, 0xe4, 0x01, 0x3a, 0x01, 0x07, 0x00, 0xe7, 0x01, 0x0d, 0x00, 0xe9,
+ 0x01, 0x19, 0x00, 0xeb, 0x01, 0x1b, 0x00, 0xed, 0x00, 0xee, 0x01, 0x0f,
+ 0x01, 0x11, 0x01, 0x44, 0x01, 0x48, 0x00, 0xf3, 0x00, 0xf4, 0x01, 0x51,
+ 0x00, 0xf6, 0x00, 0xf7, 0x01, 0x59, 0x01, 0x6f, 0x00, 0xfa, 0x01, 0x71,
+ 0x00, 0xfc, 0x00, 0xfd, 0x01, 0x63, 0x02, 0xd9
+};
diff --git a/package/libs/libiconv/src/include/charmaps/windows-1251.h b/package/libs/libiconv/src/include/charmaps/windows-1251.h
new file mode 100644
index 0000000..e278850
--- /dev/null
+++ b/package/libs/libiconv/src/include/charmaps/windows-1251.h
@@ -0,0 +1,24 @@
+static const unsigned char map_windows_1251[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x04, 0x02, 0x04, 0x03, 0x20, 0x1a, 0x04, 0x53,
+ 0x20, 0x1e, 0x20, 0x26, 0x20, 0x20, 0x20, 0x21, 0x20, 0xac, 0x20, 0x30,
+ 0x04, 0x09, 0x20, 0x39, 0x04, 0x0a, 0x04, 0x0c, 0x04, 0x0b, 0x04, 0x0f,
+ 0x04, 0x52, 0x20, 0x18, 0x20, 0x19, 0x20, 0x1c, 0x20, 0x1d, 0x20, 0x22,
+ 0x20, 0x13, 0x20, 0x14, 0xff, 0xff, 0x21, 0x22, 0x04, 0x59, 0x20, 0x3a,
+ 0x04, 0x5a, 0x04, 0x5c, 0x04, 0x5b, 0x04, 0x5f, 0x00, 0xa0, 0x04, 0x0e,
+ 0x04, 0x5e, 0x04, 0x08, 0x00, 0xa4, 0x04, 0x90, 0x00, 0xa6, 0x00, 0xa7,
+ 0x04, 0x01, 0x00, 0xa9, 0x04, 0x04, 0x00, 0xab, 0x00, 0xac, 0x00, 0xad,
+ 0x00, 0xae, 0x04, 0x07, 0x00, 0xb0, 0x00, 0xb1, 0x04, 0x06, 0x04, 0x56,
+ 0x04, 0x91, 0x00, 0xb5, 0x00, 0xb6, 0x00, 0xb7, 0x04, 0x51, 0x21, 0x16,
+ 0x04, 0x54, 0x00, 0xbb, 0x04, 0x58, 0x04, 0x05, 0x04, 0x55, 0x04, 0x57,
+ 0x04, 0x10, 0x04, 0x11, 0x04, 0x12, 0x04, 0x13, 0x04, 0x14, 0x04, 0x15,
+ 0x04, 0x16, 0x04, 0x17, 0x04, 0x18, 0x04, 0x19, 0x04, 0x1a, 0x04, 0x1b,
+ 0x04, 0x1c, 0x04, 0x1d, 0x04, 0x1e, 0x04, 0x1f, 0x04, 0x20, 0x04, 0x21,
+ 0x04, 0x22, 0x04, 0x23, 0x04, 0x24, 0x04, 0x25, 0x04, 0x26, 0x04, 0x27,
+ 0x04, 0x28, 0x04, 0x29, 0x04, 0x2a, 0x04, 0x2b, 0x04, 0x2c, 0x04, 0x2d,
+ 0x04, 0x2e, 0x04, 0x2f, 0x04, 0x30, 0x04, 0x31, 0x04, 0x32, 0x04, 0x33,
+ 0x04, 0x34, 0x04, 0x35, 0x04, 0x36, 0x04, 0x37, 0x04, 0x38, 0x04, 0x39,
+ 0x04, 0x3a, 0x04, 0x3b, 0x04, 0x3c, 0x04, 0x3d, 0x04, 0x3e, 0x04, 0x3f,
+ 0x04, 0x40, 0x04, 0x41, 0x04, 0x42, 0x04, 0x43, 0x04, 0x44, 0x04, 0x45,
+ 0x04, 0x46, 0x04, 0x47, 0x04, 0x48, 0x04, 0x49, 0x04, 0x4a, 0x04, 0x4b,
+ 0x04, 0x4c, 0x04, 0x4d, 0x04, 0x4e, 0x04, 0x4f
+};
diff --git a/package/libs/libiconv/src/include/charmaps/windows-1252.h b/package/libs/libiconv/src/include/charmaps/windows-1252.h
new file mode 100644
index 0000000..a6dad8a
--- /dev/null
+++ b/package/libs/libiconv/src/include/charmaps/windows-1252.h
@@ -0,0 +1,25 @@
+static const unsigned char map_windows_1252[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x20, 0xac, 0xff, 0xff, 0x20, 0x1a, 0x01, 0x92,
+ 0x20, 0x1e, 0x20, 0x26, 0x20, 0x20, 0x20, 0x21, 0x02, 0xc6, 0x20, 0x30,
+ 0x01, 0x60, 0x20, 0x39, 0x01, 0x52, 0xff, 0xff, 0x01, 0x7d, 0xff, 0xff,
+ 0xff, 0xff, 0x20, 0x18, 0x20, 0x19, 0x20, 0x1c, 0x20, 0x1d, 0x20, 0x22,
+ 0x20, 0x13, 0x20, 0x14, 0x02, 0xdc, 0x21, 0x22, 0x01, 0x61, 0x20, 0x3a,
+ 0x01, 0x53, 0xff, 0xff, 0x01, 0x7e, 0x01, 0x78, 0x00, 0xa0, 0x00, 0xa1,
+ 0x00, 0xa2, 0x00, 0xa3, 0x00, 0xa4, 0x00, 0xa5, 0x00, 0xa6, 0x00, 0xa7,
+ 0x00, 0xa8, 0x00, 0xa9, 0x00, 0xaa, 0x00, 0xab, 0x00, 0xac, 0x00, 0xad,
+ 0x00, 0xae, 0x00, 0xaf, 0x00, 0xb0, 0x00, 0xb1, 0x00, 0xb2, 0x00, 0xb3,
+ 0x00, 0xb4, 0x00, 0xb5, 0x00, 0xb6, 0x00, 0xb7, 0x00, 0xb8, 0x00, 0xb9,
+ 0x00, 0xba, 0x00, 0xbb, 0x00, 0xbc, 0x00, 0xbd, 0x00, 0xbe, 0x00, 0xbf,
+ 0x00, 0xc0, 0x00, 0xc1, 0x00, 0xc2, 0x00, 0xc3, 0x00, 0xc4, 0x00, 0xc5,
+ 0x00, 0xc6, 0x00, 0xc7, 0x00, 0xc8, 0x00, 0xc9, 0x00, 0xca, 0x00, 0xcb,
+ 0x00, 0xcc, 0x00, 0xcd, 0x00, 0xce, 0x00, 0xcf, 0x00, 0xd0, 0x00, 0xd1,
+ 0x00, 0xd2, 0x00, 0xd3, 0x00, 0xd4, 0x00, 0xd5, 0x00, 0xd6, 0x00, 0xd7,
+ 0x00, 0xd8, 0x00, 0xd9, 0x00, 0xda, 0x00, 0xdb, 0x00, 0xdc, 0x00, 0xdd,
+ 0x00, 0xde, 0x00, 0xdf, 0x00, 0xe0, 0x00, 0xe1, 0x00, 0xe2, 0x00, 0xe3,
+ 0x00, 0xe4, 0x00, 0xe5, 0x00, 0xe6, 0x00, 0xe7, 0x00, 0xe8, 0x00, 0xe9,
+ 0x00, 0xea, 0x00, 0xeb, 0x00, 0xec, 0x00, 0xed, 0x00, 0xee, 0x00, 0xef,
+ 0x00, 0xf0, 0x00, 0xf1, 0x00, 0xf2, 0x00, 0xf3, 0x00, 0xf4, 0x00, 0xf5,
+ 0x00, 0xf6, 0x00, 0xf7, 0x00, 0xf8, 0x00, 0xf9, 0x00, 0xfa, 0x00, 0xfb,
+ 0x00, 0xfc, 0x00, 0xfd, 0x00, 0xfe, 0x00, 0xff
+};
+
diff --git a/package/libs/libiconv/src/include/charmaps/windows-1253.h b/package/libs/libiconv/src/include/charmaps/windows-1253.h
new file mode 100644
index 0000000..b0bdf1e
--- /dev/null
+++ b/package/libs/libiconv/src/include/charmaps/windows-1253.h
@@ -0,0 +1,24 @@
+static const unsigned char map_windows_1253[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x20, 0xac, 0xff, 0xff, 0x20, 0x1a, 0x01, 0x92,
+ 0x20, 0x1e, 0x20, 0x26, 0x20, 0x20, 0x20, 0x21, 0xff, 0xff, 0x20, 0x30,
+ 0xff, 0xff, 0x20, 0x39, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0x20, 0x18, 0x20, 0x19, 0x20, 0x1c, 0x20, 0x1d, 0x20, 0x22,
+ 0x20, 0x13, 0x20, 0x14, 0xff, 0xff, 0x21, 0x22, 0xff, 0xff, 0x20, 0x3a,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xa0, 0x03, 0x85,
+ 0x03, 0x86, 0x00, 0xa3, 0x00, 0xa4, 0x00, 0xa5, 0x00, 0xa6, 0x00, 0xa7,
+ 0x00, 0xa8, 0x00, 0xa9, 0xff, 0xff, 0x00, 0xab, 0x00, 0xac, 0x00, 0xad,
+ 0x00, 0xae, 0x20, 0x15, 0x00, 0xb0, 0x00, 0xb1, 0x00, 0xb2, 0x00, 0xb3,
+ 0x03, 0x84, 0x00, 0xb5, 0x00, 0xb6, 0x00, 0xb7, 0x03, 0x88, 0x03, 0x89,
+ 0x03, 0x8a, 0x00, 0xbb, 0x03, 0x8c, 0x00, 0xbd, 0x03, 0x8e, 0x03, 0x8f,
+ 0x03, 0x90, 0x03, 0x91, 0x03, 0x92, 0x03, 0x93, 0x03, 0x94, 0x03, 0x95,
+ 0x03, 0x96, 0x03, 0x97, 0x03, 0x98, 0x03, 0x99, 0x03, 0x9a, 0x03, 0x9b,
+ 0x03, 0x9c, 0x03, 0x9d, 0x03, 0x9e, 0x03, 0x9f, 0x03, 0xa0, 0x03, 0xa1,
+ 0xff, 0xff, 0x03, 0xa3, 0x03, 0xa4, 0x03, 0xa5, 0x03, 0xa6, 0x03, 0xa7,
+ 0x03, 0xa8, 0x03, 0xa9, 0x03, 0xaa, 0x03, 0xab, 0x03, 0xac, 0x03, 0xad,
+ 0x03, 0xae, 0x03, 0xaf, 0x03, 0xb0, 0x03, 0xb1, 0x03, 0xb2, 0x03, 0xb3,
+ 0x03, 0xb4, 0x03, 0xb5, 0x03, 0xb6, 0x03, 0xb7, 0x03, 0xb8, 0x03, 0xb9,
+ 0x03, 0xba, 0x03, 0xbb, 0x03, 0xbc, 0x03, 0xbd, 0x03, 0xbe, 0x03, 0xbf,
+ 0x03, 0xc0, 0x03, 0xc1, 0x03, 0xc2, 0x03, 0xc3, 0x03, 0xc4, 0x03, 0xc5,
+ 0x03, 0xc6, 0x03, 0xc7, 0x03, 0xc8, 0x03, 0xc9, 0x03, 0xca, 0x03, 0xcb,
+ 0x03, 0xcc, 0x03, 0xcd, 0x03, 0xce, 0xff, 0xff
+};
diff --git a/package/libs/libiconv/src/include/charmaps/windows-1254.h b/package/libs/libiconv/src/include/charmaps/windows-1254.h
new file mode 100644
index 0000000..be22600
--- /dev/null
+++ b/package/libs/libiconv/src/include/charmaps/windows-1254.h
@@ -0,0 +1,24 @@
+static const unsigned char map_windows_1254[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x20, 0xac, 0xff, 0xff, 0x20, 0x1a, 0x01, 0x92,
+ 0x20, 0x1e, 0x20, 0x26, 0x20, 0x20, 0x20, 0x21, 0x02, 0xc6, 0x20, 0x30,
+ 0x01, 0x60, 0x20, 0x39, 0x01, 0x52, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0x20, 0x18, 0x20, 0x19, 0x20, 0x1c, 0x20, 0x1d, 0x20, 0x22,
+ 0x20, 0x13, 0x20, 0x14, 0x02, 0xdc, 0x21, 0x22, 0x01, 0x61, 0x20, 0x3a,
+ 0x01, 0x53, 0xff, 0xff, 0xff, 0xff, 0x01, 0x78, 0x00, 0xa0, 0x00, 0xa1,
+ 0x00, 0xa2, 0x00, 0xa3, 0x00, 0xa4, 0x00, 0xa5, 0x00, 0xa6, 0x00, 0xa7,
+ 0x00, 0xa8, 0x00, 0xa9, 0x00, 0xaa, 0x00, 0xab, 0x00, 0xac, 0x00, 0xad,
+ 0x00, 0xae, 0x00, 0xaf, 0x00, 0xb0, 0x00, 0xb1, 0x00, 0xb2, 0x00, 0xb3,
+ 0x00, 0xb4, 0x00, 0xb5, 0x00, 0xb6, 0x00, 0xb7, 0x00, 0xb8, 0x00, 0xb9,
+ 0x00, 0xba, 0x00, 0xbb, 0x00, 0xbc, 0x00, 0xbd, 0x00, 0xbe, 0x00, 0xbf,
+ 0x00, 0xc0, 0x00, 0xc1, 0x00, 0xc2, 0x00, 0xc3, 0x00, 0xc4, 0x00, 0xc5,
+ 0x00, 0xc6, 0x00, 0xc7, 0x00, 0xc8, 0x00, 0xc9, 0x00, 0xca, 0x00, 0xcb,
+ 0x00, 0xcc, 0x00, 0xcd, 0x00, 0xce, 0x00, 0xcf, 0x01, 0x1e, 0x00, 0xd1,
+ 0x00, 0xd2, 0x00, 0xd3, 0x00, 0xd4, 0x00, 0xd5, 0x00, 0xd6, 0x00, 0xd7,
+ 0x00, 0xd8, 0x00, 0xd9, 0x00, 0xda, 0x00, 0xdb, 0x00, 0xdc, 0x01, 0x30,
+ 0x01, 0x5e, 0x00, 0xdf, 0x00, 0xe0, 0x00, 0xe1, 0x00, 0xe2, 0x00, 0xe3,
+ 0x00, 0xe4, 0x00, 0xe5, 0x00, 0xe6, 0x00, 0xe7, 0x00, 0xe8, 0x00, 0xe9,
+ 0x00, 0xea, 0x00, 0xeb, 0x00, 0xec, 0x00, 0xed, 0x00, 0xee, 0x00, 0xef,
+ 0x01, 0x1f, 0x00, 0xf1, 0x00, 0xf2, 0x00, 0xf3, 0x00, 0xf4, 0x00, 0xf5,
+ 0x00, 0xf6, 0x00, 0xf7, 0x00, 0xf8, 0x00, 0xf9, 0x00, 0xfa, 0x00, 0xfb,
+ 0x00, 0xfc, 0x01, 0x31, 0x01, 0x5f, 0x00, 0xff
+};
diff --git a/package/libs/libiconv/src/include/charmaps/windows-1255.h b/package/libs/libiconv/src/include/charmaps/windows-1255.h
new file mode 100644
index 0000000..28bf513
--- /dev/null
+++ b/package/libs/libiconv/src/include/charmaps/windows-1255.h
@@ -0,0 +1,24 @@
+static const unsigned char map_windows_1255[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x20, 0xac, 0xff, 0xff, 0x20, 0x1a, 0x01, 0x92,
+ 0x20, 0x1e, 0x20, 0x26, 0x20, 0x20, 0x20, 0x21, 0x02, 0xc6, 0x20, 0x30,
+ 0xff, 0xff, 0x20, 0x39, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0x20, 0x18, 0x20, 0x19, 0x20, 0x1c, 0x20, 0x1d, 0x20, 0x22,
+ 0x20, 0x13, 0x20, 0x14, 0x02, 0xdc, 0x21, 0x22, 0xff, 0xff, 0x20, 0x3a,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xa0, 0x00, 0xa1,
+ 0x00, 0xa2, 0x00, 0xa3, 0x20, 0xaa, 0x00, 0xa5, 0x00, 0xa6, 0x00, 0xa7,
+ 0x00, 0xa8, 0x00, 0xa9, 0x00, 0xd7, 0x00, 0xab, 0x00, 0xac, 0x00, 0xad,
+ 0x00, 0xae, 0x00, 0xaf, 0x00, 0xb0, 0x00, 0xb1, 0x00, 0xb2, 0x00, 0xb3,
+ 0x00, 0xb4, 0x00, 0xb5, 0x00, 0xb6, 0x00, 0xb7, 0x00, 0xb8, 0x00, 0xb9,
+ 0x00, 0xf7, 0x00, 0xbb, 0x00, 0xbc, 0x00, 0xbd, 0x00, 0xbe, 0x00, 0xbf,
+ 0x05, 0xb0, 0x05, 0xb1, 0x05, 0xb2, 0x05, 0xb3, 0x05, 0xb4, 0x05, 0xb5,
+ 0x05, 0xb6, 0x05, 0xb7, 0x05, 0xb8, 0x05, 0xb9, 0xff, 0xff, 0x05, 0xbb,
+ 0x05, 0xbc, 0x05, 0xbd, 0x05, 0xbe, 0x05, 0xbf, 0x05, 0xc0, 0x05, 0xc1,
+ 0x05, 0xc2, 0x05, 0xc3, 0x05, 0xf0, 0x05, 0xf1, 0x05, 0xf2, 0x05, 0xf3,
+ 0x05, 0xf4, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0x05, 0xd0, 0x05, 0xd1, 0x05, 0xd2, 0x05, 0xd3,
+ 0x05, 0xd4, 0x05, 0xd5, 0x05, 0xd6, 0x05, 0xd7, 0x05, 0xd8, 0x05, 0xd9,
+ 0x05, 0xda, 0x05, 0xdb, 0x05, 0xdc, 0x05, 0xdd, 0x05, 0xde, 0x05, 0xdf,
+ 0x05, 0xe0, 0x05, 0xe1, 0x05, 0xe2, 0x05, 0xe3, 0x05, 0xe4, 0x05, 0xe5,
+ 0x05, 0xe6, 0x05, 0xe7, 0x05, 0xe8, 0x05, 0xe9, 0x05, 0xea, 0xff, 0xff,
+ 0xff, 0xff, 0x20, 0x0e, 0x20, 0x0f, 0xff, 0xff
+};
diff --git a/package/libs/libiconv/src/include/charmaps/windows-1256.h b/package/libs/libiconv/src/include/charmaps/windows-1256.h
new file mode 100644
index 0000000..fbca315
--- /dev/null
+++ b/package/libs/libiconv/src/include/charmaps/windows-1256.h
@@ -0,0 +1,24 @@
+static const unsigned char map_windows_1256[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x20, 0xac, 0x06, 0x7e, 0x20, 0x1a, 0x01, 0x92,
+ 0x20, 0x1e, 0x20, 0x26, 0x20, 0x20, 0x20, 0x21, 0x02, 0xc6, 0x20, 0x30,
+ 0x06, 0x79, 0x20, 0x39, 0x01, 0x52, 0x06, 0x86, 0x06, 0x98, 0x06, 0x88,
+ 0x06, 0xaf, 0x20, 0x18, 0x20, 0x19, 0x20, 0x1c, 0x20, 0x1d, 0x20, 0x22,
+ 0x20, 0x13, 0x20, 0x14, 0x06, 0xa9, 0x21, 0x22, 0x06, 0x91, 0x20, 0x3a,
+ 0x01, 0x53, 0x20, 0x0c, 0x20, 0x0d, 0x06, 0xba, 0x00, 0xa0, 0x06, 0x0c,
+ 0x00, 0xa2, 0x00, 0xa3, 0x00, 0xa4, 0x00, 0xa5, 0x00, 0xa6, 0x00, 0xa7,
+ 0x00, 0xa8, 0x00, 0xa9, 0x06, 0xbe, 0x00, 0xab, 0x00, 0xac, 0x00, 0xad,
+ 0x00, 0xae, 0x00, 0xaf, 0x00, 0xb0, 0x00, 0xb1, 0x00, 0xb2, 0x00, 0xb3,
+ 0x00, 0xb4, 0x00, 0xb5, 0x00, 0xb6, 0x00, 0xb7, 0x00, 0xb8, 0x00, 0xb9,
+ 0x06, 0x1b, 0x00, 0xbb, 0x00, 0xbc, 0x00, 0xbd, 0x00, 0xbe, 0x06, 0x1f,
+ 0x06, 0xc1, 0x06, 0x21, 0x06, 0x22, 0x06, 0x23, 0x06, 0x24, 0x06, 0x25,
+ 0x06, 0x26, 0x06, 0x27, 0x06, 0x28, 0x06, 0x29, 0x06, 0x2a, 0x06, 0x2b,
+ 0x06, 0x2c, 0x06, 0x2d, 0x06, 0x2e, 0x06, 0x2f, 0x06, 0x30, 0x06, 0x31,
+ 0x06, 0x32, 0x06, 0x33, 0x06, 0x34, 0x06, 0x35, 0x06, 0x36, 0x00, 0xd7,
+ 0x06, 0x37, 0x06, 0x38, 0x06, 0x39, 0x06, 0x3a, 0x06, 0x40, 0x06, 0x41,
+ 0x06, 0x42, 0x06, 0x43, 0x00, 0xe0, 0x06, 0x44, 0x00, 0xe2, 0x06, 0x45,
+ 0x06, 0x46, 0x06, 0x47, 0x06, 0x48, 0x00, 0xe7, 0x00, 0xe8, 0x00, 0xe9,
+ 0x00, 0xea, 0x00, 0xeb, 0x06, 0x49, 0x06, 0x4a, 0x00, 0xee, 0x00, 0xef,
+ 0x06, 0x4b, 0x06, 0x4c, 0x06, 0x4d, 0x06, 0x4e, 0x00, 0xf4, 0x06, 0x4f,
+ 0x06, 0x50, 0x00, 0xf7, 0x06, 0x51, 0x00, 0xf9, 0x06, 0x52, 0x00, 0xfb,
+ 0x00, 0xfc, 0x20, 0x0e, 0x20, 0x0f, 0x06, 0xd2
+};
diff --git a/package/libs/libiconv/src/include/charmaps/windows-1257.h b/package/libs/libiconv/src/include/charmaps/windows-1257.h
new file mode 100644
index 0000000..69d4474
--- /dev/null
+++ b/package/libs/libiconv/src/include/charmaps/windows-1257.h
@@ -0,0 +1,24 @@
+static const unsigned char map_windows_1257[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x20, 0xac, 0xff, 0xff, 0x20, 0x1a, 0xff, 0xff,
+ 0x20, 0x1e, 0x20, 0x26, 0x20, 0x20, 0x20, 0x21, 0xff, 0xff, 0x20, 0x30,
+ 0xff, 0xff, 0x20, 0x39, 0xff, 0xff, 0x00, 0xa8, 0x02, 0xc7, 0x00, 0xb8,
+ 0xff, 0xff, 0x20, 0x18, 0x20, 0x19, 0x20, 0x1c, 0x20, 0x1d, 0x20, 0x22,
+ 0x20, 0x13, 0x20, 0x14, 0xff, 0xff, 0x21, 0x22, 0xff, 0xff, 0x20, 0x3a,
+ 0xff, 0xff, 0x00, 0xaf, 0x02, 0xdb, 0xff, 0xff, 0x00, 0xa0, 0xff, 0xff,
+ 0x00, 0xa2, 0x00, 0xa3, 0x00, 0xa4, 0xff, 0xff, 0x00, 0xa6, 0x00, 0xa7,
+ 0x00, 0xd8, 0x00, 0xa9, 0x01, 0x56, 0x00, 0xab, 0x00, 0xac, 0x00, 0xad,
+ 0x00, 0xae, 0x00, 0xc6, 0x00, 0xb0, 0x00, 0xb1, 0x00, 0xb2, 0x00, 0xb3,
+ 0x00, 0xb4, 0x00, 0xb5, 0x00, 0xb6, 0x00, 0xb7, 0x00, 0xf8, 0x00, 0xb9,
+ 0x01, 0x57, 0x00, 0xbb, 0x00, 0xbc, 0x00, 0xbd, 0x00, 0xbe, 0x00, 0xe6,
+ 0x01, 0x04, 0x01, 0x2e, 0x01, 0x00, 0x01, 0x06, 0x00, 0xc4, 0x00, 0xc5,
+ 0x01, 0x18, 0x01, 0x12, 0x01, 0x0c, 0x00, 0xc9, 0x01, 0x79, 0x01, 0x16,
+ 0x01, 0x22, 0x01, 0x36, 0x01, 0x2a, 0x01, 0x3b, 0x01, 0x60, 0x01, 0x43,
+ 0x01, 0x45, 0x00, 0xd3, 0x01, 0x4c, 0x00, 0xd5, 0x00, 0xd6, 0x00, 0xd7,
+ 0x01, 0x72, 0x01, 0x41, 0x01, 0x5a, 0x01, 0x6a, 0x00, 0xdc, 0x01, 0x7b,
+ 0x01, 0x7d, 0x00, 0xdf, 0x01, 0x05, 0x01, 0x2f, 0x01, 0x01, 0x01, 0x07,
+ 0x00, 0xe4, 0x00, 0xe5, 0x01, 0x19, 0x01, 0x13, 0x01, 0x0d, 0x00, 0xe9,
+ 0x01, 0x7a, 0x01, 0x17, 0x01, 0x23, 0x01, 0x37, 0x01, 0x2b, 0x01, 0x3c,
+ 0x01, 0x61, 0x01, 0x44, 0x01, 0x46, 0x00, 0xf3, 0x01, 0x4d, 0x00, 0xf5,
+ 0x00, 0xf6, 0x00, 0xf7, 0x01, 0x73, 0x01, 0x42, 0x01, 0x5b, 0x01, 0x6b,
+ 0x00, 0xfc, 0x01, 0x7c, 0x01, 0x7e, 0x02, 0xd9
+};
diff --git a/package/libs/libiconv/src/include/charmaps/windows-1258.h b/package/libs/libiconv/src/include/charmaps/windows-1258.h
new file mode 100644
index 0000000..5bbd737
--- /dev/null
+++ b/package/libs/libiconv/src/include/charmaps/windows-1258.h
@@ -0,0 +1,24 @@
+static const unsigned char map_windows_1258[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x20, 0xac, 0xff, 0xff, 0x20, 0x1a, 0x01, 0x92,
+ 0x20, 0x1e, 0x20, 0x26, 0x20, 0x20, 0x20, 0x21, 0x02, 0xc6, 0x20, 0x30,
+ 0xff, 0xff, 0x20, 0x39, 0x01, 0x52, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0x20, 0x18, 0x20, 0x19, 0x20, 0x1c, 0x20, 0x1d, 0x20, 0x22,
+ 0x20, 0x13, 0x20, 0x14, 0x02, 0xdc, 0x21, 0x22, 0xff, 0xff, 0x20, 0x3a,
+ 0x01, 0x53, 0xff, 0xff, 0xff, 0xff, 0x01, 0x78, 0x00, 0xa0, 0x00, 0xa1,
+ 0x00, 0xa2, 0x00, 0xa3, 0x00, 0xa4, 0x00, 0xa5, 0x00, 0xa6, 0x00, 0xa7,
+ 0x00, 0xa8, 0x00, 0xa9, 0x00, 0xaa, 0x00, 0xab, 0x00, 0xac, 0x00, 0xad,
+ 0x00, 0xae, 0x00, 0xaf, 0x00, 0xb0, 0x00, 0xb1, 0x00, 0xb2, 0x00, 0xb3,
+ 0x00, 0xb4, 0x00, 0xb5, 0x00, 0xb6, 0x00, 0xb7, 0x00, 0xb8, 0x00, 0xb9,
+ 0x00, 0xba, 0x00, 0xbb, 0x00, 0xbc, 0x00, 0xbd, 0x00, 0xbe, 0x00, 0xbf,
+ 0x00, 0xc0, 0x00, 0xc1, 0x00, 0xc2, 0x01, 0x02, 0x00, 0xc4, 0x00, 0xc5,
+ 0x00, 0xc6, 0x00, 0xc7, 0x00, 0xc8, 0x00, 0xc9, 0x00, 0xca, 0x00, 0xcb,
+ 0x03, 0x00, 0x00, 0xcd, 0x00, 0xce, 0x00, 0xcf, 0x01, 0x10, 0x00, 0xd1,
+ 0x03, 0x09, 0x00, 0xd3, 0x00, 0xd4, 0x01, 0xa0, 0x00, 0xd6, 0x00, 0xd7,
+ 0x00, 0xd8, 0x00, 0xd9, 0x00, 0xda, 0x00, 0xdb, 0x00, 0xdc, 0x01, 0xaf,
+ 0x03, 0x03, 0x00, 0xdf, 0x00, 0xe0, 0x00, 0xe1, 0x00, 0xe2, 0x01, 0x03,
+ 0x00, 0xe4, 0x00, 0xe5, 0x00, 0xe6, 0x00, 0xe7, 0x00, 0xe8, 0x00, 0xe9,
+ 0x00, 0xea, 0x00, 0xeb, 0x03, 0x01, 0x00, 0xed, 0x00, 0xee, 0x00, 0xef,
+ 0x01, 0x11, 0x00, 0xf1, 0x03, 0x23, 0x00, 0xf3, 0x00, 0xf4, 0x01, 0xa1,
+ 0x00, 0xf6, 0x00, 0xf7, 0x00, 0xf8, 0x00, 0xf9, 0x00, 0xfa, 0x00, 0xfb,
+ 0x00, 0xfc, 0x01, 0xb0, 0x20, 0xab, 0x00, 0xff
+};
diff --git a/package/libs/libiconv/src/include/charmaps/windows-874.h b/package/libs/libiconv/src/include/charmaps/windows-874.h
new file mode 100644
index 0000000..5749280
--- /dev/null
+++ b/package/libs/libiconv/src/include/charmaps/windows-874.h
@@ -0,0 +1,24 @@
+static const unsigned char map_windows_874[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x20, 0xac, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0x20, 0x26, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0x20, 0x18, 0x20, 0x19, 0x20, 0x1c, 0x20, 0x1d, 0x20, 0x22,
+ 0x20, 0x13, 0x20, 0x14, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xa0, 0x0e, 0x01,
+ 0x0e, 0x02, 0x0e, 0x03, 0x0e, 0x04, 0x0e, 0x05, 0x0e, 0x06, 0x0e, 0x07,
+ 0x0e, 0x08, 0x0e, 0x09, 0x0e, 0x0a, 0x0e, 0x0b, 0x0e, 0x0c, 0x0e, 0x0d,
+ 0x0e, 0x0e, 0x0e, 0x0f, 0x0e, 0x10, 0x0e, 0x11, 0x0e, 0x12, 0x0e, 0x13,
+ 0x0e, 0x14, 0x0e, 0x15, 0x0e, 0x16, 0x0e, 0x17, 0x0e, 0x18, 0x0e, 0x19,
+ 0x0e, 0x1a, 0x0e, 0x1b, 0x0e, 0x1c, 0x0e, 0x1d, 0x0e, 0x1e, 0x0e, 0x1f,
+ 0x0e, 0x20, 0x0e, 0x21, 0x0e, 0x22, 0x0e, 0x23, 0x0e, 0x24, 0x0e, 0x25,
+ 0x0e, 0x26, 0x0e, 0x27, 0x0e, 0x28, 0x0e, 0x29, 0x0e, 0x2a, 0x0e, 0x2b,
+ 0x0e, 0x2c, 0x0e, 0x2d, 0x0e, 0x2e, 0x0e, 0x2f, 0x0e, 0x30, 0x0e, 0x31,
+ 0x0e, 0x32, 0x0e, 0x33, 0x0e, 0x34, 0x0e, 0x35, 0x0e, 0x36, 0x0e, 0x37,
+ 0x0e, 0x38, 0x0e, 0x39, 0x0e, 0x3a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0x0e, 0x3f, 0x0e, 0x40, 0x0e, 0x41, 0x0e, 0x42, 0x0e, 0x43,
+ 0x0e, 0x44, 0x0e, 0x45, 0x0e, 0x46, 0x0e, 0x47, 0x0e, 0x48, 0x0e, 0x49,
+ 0x0e, 0x4a, 0x0e, 0x4b, 0x0e, 0x4c, 0x0e, 0x4d, 0x0e, 0x4e, 0x0e, 0x4f,
+ 0x0e, 0x50, 0x0e, 0x51, 0x0e, 0x52, 0x0e, 0x53, 0x0e, 0x54, 0x0e, 0x55,
+ 0x0e, 0x56, 0x0e, 0x57, 0x0e, 0x58, 0x0e, 0x59, 0x0e, 0x5a, 0x0e, 0x5b,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
+};
diff --git a/package/libs/libiconv/src/include/iconv.h b/package/libs/libiconv/src/include/iconv.h
new file mode 100644
index 0000000..dfab27f
--- /dev/null
+++ b/package/libs/libiconv/src/include/iconv.h
@@ -0,0 +1,32 @@
+#ifndef _ICONV_H
+#define _ICONV_H 1
+
+#define _LIBICONV_VERSION 0x010B /* version number: (major<<8) + minor */
+
+#include <stddef.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern int _libiconv_version; /* Likewise */
+
+typedef long iconv_t;
+
+extern iconv_t
+iconv_open(const char *tocode, const char *fromcode);
+
+extern size_t
+iconv(iconv_t cd, char **inbuf, size_t *inbytesleft,
+ char **outbuf, size_t *outbytesleft);
+
+extern int
+iconv_close(iconv_t cd);
+
+#define libiconv_set_relocation_prefix(...) do {} while(0)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _ICONV_H */
diff --git a/package/libs/libiconv/src/m4/.svn/entries b/package/libs/libiconv/src/m4/.svn/entries
new file mode 100644
index 0000000..0a4319a
--- /dev/null
+++ b/package/libs/libiconv/src/m4/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs/libiconv/src/m4
+svn://svn.openwrt.org/openwrt
+
+
+
+2010-12-19T04:38:28.843714Z
+24705
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+iconv.m4
+file
+
+
+
+
+2013-03-17T12:13:07.000000Z
+0d56b24090e4fcb47ba26142b0053279
+2010-12-19T04:38:28.843714Z
+24705
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+7519
+
diff --git a/package/libs/libiconv/src/m4/.svn/text-base/iconv.m4.svn-base b/package/libs/libiconv/src/m4/.svn/text-base/iconv.m4.svn-base
new file mode 100644
index 0000000..e2041b9
--- /dev/null
+++ b/package/libs/libiconv/src/m4/.svn/text-base/iconv.m4.svn-base
@@ -0,0 +1,214 @@
+# iconv.m4 serial 11 (gettext-0.18.1)
+dnl Copyright (C) 2000-2002, 2007-2010 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Bruno Haible.
+
+AC_DEFUN([AM_ICONV_LINKFLAGS_BODY],
+[
+ dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
+ AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
+ AC_REQUIRE([AC_LIB_RPATH])
+
+ dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
+ dnl accordingly.
+ AC_LIB_LINKFLAGS_BODY([iconv])
+])
+
+AC_DEFUN([AM_ICONV_LINK],
+[
+ dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
+ dnl those with the standalone portable GNU libiconv installed).
+ AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+
+ dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
+ dnl accordingly.
+ AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY])
+
+ dnl Add $INCICONV to CPPFLAGS before performing the following checks,
+ dnl because if the user has installed libiconv and not disabled its use
+ dnl via --without-libiconv-prefix, he wants to use it. The first
+ dnl AC_TRY_LINK will then fail, the second AC_TRY_LINK will succeed.
+ am_save_CPPFLAGS="$CPPFLAGS"
+ AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV])
+
+ AC_CACHE_CHECK([for iconv], [am_cv_func_iconv], [
+ am_cv_func_iconv="no, consider installing GNU libiconv"
+ am_cv_lib_iconv=no
+ AC_TRY_LINK([#include <stdlib.h>
+#include <iconv.h>],
+ [iconv_t cd = iconv_open("","");
+ iconv(cd,NULL,NULL,NULL,NULL);
+ iconv_close(cd);],
+ [am_cv_func_iconv=yes])
+ if test "$am_cv_func_iconv" != yes; then
+ am_save_LIBS="$LIBS"
+ LIBS="$LIBS $LIBICONV"
+ AC_TRY_LINK([#include <stdlib.h>
+#include <iconv.h>],
+ [iconv_t cd = iconv_open("","");
+ iconv(cd,NULL,NULL,NULL,NULL);
+ iconv_close(cd);],
+ [am_cv_lib_iconv=yes]
+ [am_cv_func_iconv=yes])
+ LIBS="$am_save_LIBS"
+ fi
+ ])
+ if test "$am_cv_func_iconv" = yes; then
+ AC_CACHE_CHECK([for working iconv], [am_cv_func_iconv_works], [
+ dnl This tests against bugs in AIX 5.1, HP-UX 11.11, Solaris 10.
+ am_save_LIBS="$LIBS"
+ if test $am_cv_lib_iconv = yes; then
+ LIBS="$LIBS $LIBICONV"
+ fi
+ AC_TRY_RUN([
+#include <iconv.h>
+#include <string.h>
+int main ()
+{
+ /* Test against AIX 5.1 bug: Failures are not distinguishable from successful
+ returns. */
+ {
+ iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8");
+ if (cd_utf8_to_88591 != (iconv_t)(-1))
+ {
+ static const char input[] = "\342\202\254"; /* EURO SIGN */
+ char buf[10];
+ const char *inptr = input;
+ size_t inbytesleft = strlen (input);
+ char *outptr = buf;
+ size_t outbytesleft = sizeof (buf);
+ size_t res = iconv (cd_utf8_to_88591,
+ (char **) &inptr, &inbytesleft,
+ &outptr, &outbytesleft);
+ if (res == 0)
+ return 1;
+ }
+ }
+ /* Test against Solaris 10 bug: Failures are not distinguishable from
+ successful returns. */
+ {
+ iconv_t cd_ascii_to_88591 = iconv_open ("ISO8859-1", "646");
+ if (cd_ascii_to_88591 != (iconv_t)(-1))
+ {
+ static const char input[] = "\263";
+ char buf[10];
+ const char *inptr = input;
+ size_t inbytesleft = strlen (input);
+ char *outptr = buf;
+ size_t outbytesleft = sizeof (buf);
+ size_t res = iconv (cd_ascii_to_88591,
+ (char **) &inptr, &inbytesleft,
+ &outptr, &outbytesleft);
+ if (res == 0)
+ return 1;
+ }
+ }
+#if 0 /* This bug could be worked around by the caller. */
+ /* Test against HP-UX 11.11 bug: Positive return value instead of 0. */
+ {
+ iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591");
+ if (cd_88591_to_utf8 != (iconv_t)(-1))
+ {
+ static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
+ char buf[50];
+ const char *inptr = input;
+ size_t inbytesleft = strlen (input);
+ char *outptr = buf;
+ size_t outbytesleft = sizeof (buf);
+ size_t res = iconv (cd_88591_to_utf8,
+ (char **) &inptr, &inbytesleft,
+ &outptr, &outbytesleft);
+ if ((int)res > 0)
+ return 1;
+ }
+ }
+#endif
+ /* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is
+ provided. */
+ if (/* Try standardized names. */
+ iconv_open ("UTF-8", "EUC-JP") == (iconv_t)(-1)
+ /* Try IRIX, OSF/1 names. */
+ && iconv_open ("UTF-8", "eucJP") == (iconv_t)(-1)
+ /* Try AIX names. */
+ && iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1)
+ /* Try HP-UX names. */
+ && iconv_open ("utf8", "eucJP") == (iconv_t)(-1))
+ return 1;
+ return 0;
+}], [am_cv_func_iconv_works=yes], [am_cv_func_iconv_works=no],
+ [case "$host_os" in
+ aix* | hpux*) am_cv_func_iconv_works="guessing no" ;;
+ *) am_cv_func_iconv_works="guessing yes" ;;
+ esac])
+ LIBS="$am_save_LIBS"
+ ])
+ case "$am_cv_func_iconv_works" in
+ *no) am_func_iconv=no am_cv_lib_iconv=no ;;
+ *) am_func_iconv=yes ;;
+ esac
+ else
+ am_func_iconv=no am_cv_lib_iconv=no
+ fi
+ if test "$am_func_iconv" = yes; then
+ AC_DEFINE([HAVE_ICONV], [1],
+ [Define if you have the iconv() function and it works.])
+ fi
+ if test "$am_cv_lib_iconv" = yes; then
+ AC_MSG_CHECKING([how to link with libiconv])
+ AC_MSG_RESULT([$LIBICONV])
+ else
+ dnl If $LIBICONV didn't lead to a usable library, we don't need $INCICONV
+ dnl either.
+ CPPFLAGS="$am_save_CPPFLAGS"
+ LIBICONV=
+ LTLIBICONV=
+ fi
+ AC_SUBST([LIBICONV])
+ AC_SUBST([LTLIBICONV])
+])
+
+dnl Define AM_ICONV using AC_DEFUN_ONCE for Autoconf >= 2.64, in order to
+dnl avoid warnings like
+dnl "warning: AC_REQUIRE: `AM_ICONV' was expanded before it was required".
+dnl This is tricky because of the way 'aclocal' is implemented:
+dnl - It requires defining an auxiliary macro whose name ends in AC_DEFUN.
+dnl Otherwise aclocal's initial scan pass would miss the macro definition.
+dnl - It requires a line break inside the AC_DEFUN_ONCE and AC_DEFUN expansions.
+dnl Otherwise aclocal would emit many "Use of uninitialized value $1"
+dnl warnings.
+m4_define([gl_iconv_AC_DEFUN],
+ m4_version_prereq([2.64],
+ [[AC_DEFUN_ONCE(
+ [$1], [$2])]],
+ [[AC_DEFUN(
+ [$1], [$2])]]))
+gl_iconv_AC_DEFUN([AM_ICONV],
+[
+ AM_ICONV_LINK
+ if test "$am_cv_func_iconv" = yes; then
+ AC_MSG_CHECKING([for iconv declaration])
+ AC_CACHE_VAL([am_cv_proto_iconv], [
+ AC_TRY_COMPILE([
+#include <stdlib.h>
+#include <iconv.h>
+extern
+#ifdef __cplusplus
+"C"
+#endif
+#if defined(__STDC__) || defined(__cplusplus)
+size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
+#else
+size_t iconv();
+#endif
+], [], [am_cv_proto_iconv_arg1=""], [am_cv_proto_iconv_arg1="const"])
+ am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"])
+ am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
+ AC_MSG_RESULT([
+ $am_cv_proto_iconv])
+ AC_DEFINE_UNQUOTED([ICONV_CONST], [$am_cv_proto_iconv_arg1],
+ [Define as const if the declaration of iconv() needs const.])
+ fi
+])
diff --git a/package/libs/libiconv/src/m4/iconv.m4 b/package/libs/libiconv/src/m4/iconv.m4
new file mode 100644
index 0000000..e2041b9
--- /dev/null
+++ b/package/libs/libiconv/src/m4/iconv.m4
@@ -0,0 +1,214 @@
+# iconv.m4 serial 11 (gettext-0.18.1)
+dnl Copyright (C) 2000-2002, 2007-2010 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Bruno Haible.
+
+AC_DEFUN([AM_ICONV_LINKFLAGS_BODY],
+[
+ dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
+ AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
+ AC_REQUIRE([AC_LIB_RPATH])
+
+ dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
+ dnl accordingly.
+ AC_LIB_LINKFLAGS_BODY([iconv])
+])
+
+AC_DEFUN([AM_ICONV_LINK],
+[
+ dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
+ dnl those with the standalone portable GNU libiconv installed).
+ AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+
+ dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
+ dnl accordingly.
+ AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY])
+
+ dnl Add $INCICONV to CPPFLAGS before performing the following checks,
+ dnl because if the user has installed libiconv and not disabled its use
+ dnl via --without-libiconv-prefix, he wants to use it. The first
+ dnl AC_TRY_LINK will then fail, the second AC_TRY_LINK will succeed.
+ am_save_CPPFLAGS="$CPPFLAGS"
+ AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV])
+
+ AC_CACHE_CHECK([for iconv], [am_cv_func_iconv], [
+ am_cv_func_iconv="no, consider installing GNU libiconv"
+ am_cv_lib_iconv=no
+ AC_TRY_LINK([#include <stdlib.h>
+#include <iconv.h>],
+ [iconv_t cd = iconv_open("","");
+ iconv(cd,NULL,NULL,NULL,NULL);
+ iconv_close(cd);],
+ [am_cv_func_iconv=yes])
+ if test "$am_cv_func_iconv" != yes; then
+ am_save_LIBS="$LIBS"
+ LIBS="$LIBS $LIBICONV"
+ AC_TRY_LINK([#include <stdlib.h>
+#include <iconv.h>],
+ [iconv_t cd = iconv_open("","");
+ iconv(cd,NULL,NULL,NULL,NULL);
+ iconv_close(cd);],
+ [am_cv_lib_iconv=yes]
+ [am_cv_func_iconv=yes])
+ LIBS="$am_save_LIBS"
+ fi
+ ])
+ if test "$am_cv_func_iconv" = yes; then
+ AC_CACHE_CHECK([for working iconv], [am_cv_func_iconv_works], [
+ dnl This tests against bugs in AIX 5.1, HP-UX 11.11, Solaris 10.
+ am_save_LIBS="$LIBS"
+ if test $am_cv_lib_iconv = yes; then
+ LIBS="$LIBS $LIBICONV"
+ fi
+ AC_TRY_RUN([
+#include <iconv.h>
+#include <string.h>
+int main ()
+{
+ /* Test against AIX 5.1 bug: Failures are not distinguishable from successful
+ returns. */
+ {
+ iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8");
+ if (cd_utf8_to_88591 != (iconv_t)(-1))
+ {
+ static const char input[] = "\342\202\254"; /* EURO SIGN */
+ char buf[10];
+ const char *inptr = input;
+ size_t inbytesleft = strlen (input);
+ char *outptr = buf;
+ size_t outbytesleft = sizeof (buf);
+ size_t res = iconv (cd_utf8_to_88591,
+ (char **) &inptr, &inbytesleft,
+ &outptr, &outbytesleft);
+ if (res == 0)
+ return 1;
+ }
+ }
+ /* Test against Solaris 10 bug: Failures are not distinguishable from
+ successful returns. */
+ {
+ iconv_t cd_ascii_to_88591 = iconv_open ("ISO8859-1", "646");
+ if (cd_ascii_to_88591 != (iconv_t)(-1))
+ {
+ static const char input[] = "\263";
+ char buf[10];
+ const char *inptr = input;
+ size_t inbytesleft = strlen (input);
+ char *outptr = buf;
+ size_t outbytesleft = sizeof (buf);
+ size_t res = iconv (cd_ascii_to_88591,
+ (char **) &inptr, &inbytesleft,
+ &outptr, &outbytesleft);
+ if (res == 0)
+ return 1;
+ }
+ }
+#if 0 /* This bug could be worked around by the caller. */
+ /* Test against HP-UX 11.11 bug: Positive return value instead of 0. */
+ {
+ iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591");
+ if (cd_88591_to_utf8 != (iconv_t)(-1))
+ {
+ static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
+ char buf[50];
+ const char *inptr = input;
+ size_t inbytesleft = strlen (input);
+ char *outptr = buf;
+ size_t outbytesleft = sizeof (buf);
+ size_t res = iconv (cd_88591_to_utf8,
+ (char **) &inptr, &inbytesleft,
+ &outptr, &outbytesleft);
+ if ((int)res > 0)
+ return 1;
+ }
+ }
+#endif
+ /* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is
+ provided. */
+ if (/* Try standardized names. */
+ iconv_open ("UTF-8", "EUC-JP") == (iconv_t)(-1)
+ /* Try IRIX, OSF/1 names. */
+ && iconv_open ("UTF-8", "eucJP") == (iconv_t)(-1)
+ /* Try AIX names. */
+ && iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1)
+ /* Try HP-UX names. */
+ && iconv_open ("utf8", "eucJP") == (iconv_t)(-1))
+ return 1;
+ return 0;
+}], [am_cv_func_iconv_works=yes], [am_cv_func_iconv_works=no],
+ [case "$host_os" in
+ aix* | hpux*) am_cv_func_iconv_works="guessing no" ;;
+ *) am_cv_func_iconv_works="guessing yes" ;;
+ esac])
+ LIBS="$am_save_LIBS"
+ ])
+ case "$am_cv_func_iconv_works" in
+ *no) am_func_iconv=no am_cv_lib_iconv=no ;;
+ *) am_func_iconv=yes ;;
+ esac
+ else
+ am_func_iconv=no am_cv_lib_iconv=no
+ fi
+ if test "$am_func_iconv" = yes; then
+ AC_DEFINE([HAVE_ICONV], [1],
+ [Define if you have the iconv() function and it works.])
+ fi
+ if test "$am_cv_lib_iconv" = yes; then
+ AC_MSG_CHECKING([how to link with libiconv])
+ AC_MSG_RESULT([$LIBICONV])
+ else
+ dnl If $LIBICONV didn't lead to a usable library, we don't need $INCICONV
+ dnl either.
+ CPPFLAGS="$am_save_CPPFLAGS"
+ LIBICONV=
+ LTLIBICONV=
+ fi
+ AC_SUBST([LIBICONV])
+ AC_SUBST([LTLIBICONV])
+])
+
+dnl Define AM_ICONV using AC_DEFUN_ONCE for Autoconf >= 2.64, in order to
+dnl avoid warnings like
+dnl "warning: AC_REQUIRE: `AM_ICONV' was expanded before it was required".
+dnl This is tricky because of the way 'aclocal' is implemented:
+dnl - It requires defining an auxiliary macro whose name ends in AC_DEFUN.
+dnl Otherwise aclocal's initial scan pass would miss the macro definition.
+dnl - It requires a line break inside the AC_DEFUN_ONCE and AC_DEFUN expansions.
+dnl Otherwise aclocal would emit many "Use of uninitialized value $1"
+dnl warnings.
+m4_define([gl_iconv_AC_DEFUN],
+ m4_version_prereq([2.64],
+ [[AC_DEFUN_ONCE(
+ [$1], [$2])]],
+ [[AC_DEFUN(
+ [$1], [$2])]]))
+gl_iconv_AC_DEFUN([AM_ICONV],
+[
+ AM_ICONV_LINK
+ if test "$am_cv_func_iconv" = yes; then
+ AC_MSG_CHECKING([for iconv declaration])
+ AC_CACHE_VAL([am_cv_proto_iconv], [
+ AC_TRY_COMPILE([
+#include <stdlib.h>
+#include <iconv.h>
+extern
+#ifdef __cplusplus
+"C"
+#endif
+#if defined(__STDC__) || defined(__cplusplus)
+size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
+#else
+size_t iconv();
+#endif
+], [], [am_cv_proto_iconv_arg1=""], [am_cv_proto_iconv_arg1="const"])
+ am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"])
+ am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
+ AC_MSG_RESULT([
+ $am_cv_proto_iconv])
+ AC_DEFINE_UNQUOTED([ICONV_CONST], [$am_cv_proto_iconv_arg1],
+ [Define as const if the declaration of iconv() needs const.])
+ fi
+])
diff --git a/package/libs/libjson-c/.svn/entries b/package/libs/libjson-c/.svn/entries
new file mode 100644
index 0000000..6278b29
--- /dev/null
+++ b/package/libs/libjson-c/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs/libjson-c
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-19T15:34:28.915431Z
+33861
+hcg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+d79418a68af4671f21cc4690bab76c24
+2012-10-19T15:34:28.915431Z
+33861
+hcg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1333
+
diff --git a/package/libs/libjson-c/.svn/text-base/Makefile.svn-base b/package/libs/libjson-c/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..5dd83f2
--- /dev/null
+++ b/package/libs/libjson-c/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,55 @@
+#
+# Copyright (C) 2006-2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=json-c
+PKG_VERSION:=0.9
+PKG_RELEASE:=2
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://oss.metaparadigm.com/json-c/
+PKG_MD5SUM:=3a13d264528dcbaf3931b0cede24abae
+
+PKG_LICENSE:=MIT
+PKG_LICENSE_FILES:=COPYING
+
+PKG_FIXUP:=autoreconf
+PKG_INSTALL:=1
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+
+TARGET_CFLAGS += $(FPIC)
+
+define Package/libjson
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=javascript object notation
+ URL:=http://oss.metaparadigm.com/json-c/
+endef
+
+define Package/libjson/description
+ This package contains a library for javascript object notation backends.
+endef
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include
+ $(CP) $(PKG_INSTALL_DIR)/usr/include/json $(1)/usr/include/
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libjson.{a,so*} $(1)/usr/lib/
+ $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/json.pc $(1)/usr/lib/pkgconfig/
+endef
+
+define Package/libjson/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libjson.so.* $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,libjson))
diff --git a/package/libs/libjson-c/Makefile b/package/libs/libjson-c/Makefile
new file mode 100644
index 0000000..5dd83f2
--- /dev/null
+++ b/package/libs/libjson-c/Makefile
@@ -0,0 +1,55 @@
+#
+# Copyright (C) 2006-2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=json-c
+PKG_VERSION:=0.9
+PKG_RELEASE:=2
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://oss.metaparadigm.com/json-c/
+PKG_MD5SUM:=3a13d264528dcbaf3931b0cede24abae
+
+PKG_LICENSE:=MIT
+PKG_LICENSE_FILES:=COPYING
+
+PKG_FIXUP:=autoreconf
+PKG_INSTALL:=1
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+
+TARGET_CFLAGS += $(FPIC)
+
+define Package/libjson
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=javascript object notation
+ URL:=http://oss.metaparadigm.com/json-c/
+endef
+
+define Package/libjson/description
+ This package contains a library for javascript object notation backends.
+endef
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include
+ $(CP) $(PKG_INSTALL_DIR)/usr/include/json $(1)/usr/include/
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libjson.{a,so*} $(1)/usr/lib/
+ $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/json.pc $(1)/usr/lib/pkgconfig/
+endef
+
+define Package/libjson/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libjson.so.* $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,libjson))
diff --git a/package/libs/libmnl/.svn/entries b/package/libs/libmnl/.svn/entries
new file mode 100644
index 0000000..9a1c31e
--- /dev/null
+++ b/package/libs/libmnl/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs/libmnl
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-12T12:15:36.335867Z
+33734
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+4dd0c7afae8a7d5ebf8d126e5a08c7a7
+2012-10-12T12:15:36.335867Z
+33734
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2393
+
diff --git a/package/libs/libmnl/.svn/text-base/Makefile.svn-base b/package/libs/libmnl/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..42958e7
--- /dev/null
+++ b/package/libs/libmnl/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,76 @@
+#
+# Copyright (C) 2011-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=libmnl
+PKG_VERSION:=1.0.1
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:= \
+ http://www.netfilter.org/projects/libmnl/files \
+ ftp://ftp.netfilter.org/pub/libmnl
+PKG_MD5SUM:=e936236bb57a2375afa4e70e75dc3ba9
+
+PKG_MAINTAINER:=Jo-Philipp Wich <jow@openwrt.org>
+
+PKG_FIXUP:=autoreconf
+PKG_INSTALL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/libmnl
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=Minimalistic user-space library for Netlink
+ URL:=http://www.netfilter.org/projects/libmnl/
+endef
+
+define Package/libmnl/description
+ libmnl is a minimalistic user-space library oriented to Netlink developers.
+ There are a lot of common tasks in parsing, validating, constructing of
+ both the Netlink header and TLVs that are repetitive and easy to get wrong.
+ This library aims to provide simple helpers that allows you to re-use code
+ and to avoid re-inventing the wheel. The main features of this library are:
+ .
+ * Small: the shared library requires around 30KB for an x86-based computer.
+ .
+ * Simple: this library avoids complexity and elaborated abstractions that
+ tend to hide Netlink details.
+ .
+ * Easy to use: the library simplifies the work for Netlink-wise developers.
+ It provides functions to make socket handling, message building, validating,
+ parsing and sequence tracking, easier.
+ .
+ * Easy to re-use: you can use the library to build your own abstraction layer
+ on top of this library.
+ .
+ * Decoupling: the interdependency of the main bricks that compose the library
+ is reduced, i.e. the library provides many helpers, but the programmer is not
+ forced to use them.
+endef
+
+CONFIGURE_ARGS+= \
+ --enable-shared \
+ --enable-static \
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include
+ $(CP) $(PKG_INSTALL_DIR)/usr/include/libmnl $(1)/usr/include/
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libmnl.{a,so*} $(1)/usr/lib/
+ $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libmnl.pc $(1)/usr/lib/pkgconfig/
+endef
+
+define Package/libmnl/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libmnl.so.* $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,libmnl))
diff --git a/package/libs/libmnl/Makefile b/package/libs/libmnl/Makefile
new file mode 100644
index 0000000..42958e7
--- /dev/null
+++ b/package/libs/libmnl/Makefile
@@ -0,0 +1,76 @@
+#
+# Copyright (C) 2011-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=libmnl
+PKG_VERSION:=1.0.1
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:= \
+ http://www.netfilter.org/projects/libmnl/files \
+ ftp://ftp.netfilter.org/pub/libmnl
+PKG_MD5SUM:=e936236bb57a2375afa4e70e75dc3ba9
+
+PKG_MAINTAINER:=Jo-Philipp Wich <jow@openwrt.org>
+
+PKG_FIXUP:=autoreconf
+PKG_INSTALL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/libmnl
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=Minimalistic user-space library for Netlink
+ URL:=http://www.netfilter.org/projects/libmnl/
+endef
+
+define Package/libmnl/description
+ libmnl is a minimalistic user-space library oriented to Netlink developers.
+ There are a lot of common tasks in parsing, validating, constructing of
+ both the Netlink header and TLVs that are repetitive and easy to get wrong.
+ This library aims to provide simple helpers that allows you to re-use code
+ and to avoid re-inventing the wheel. The main features of this library are:
+ .
+ * Small: the shared library requires around 30KB for an x86-based computer.
+ .
+ * Simple: this library avoids complexity and elaborated abstractions that
+ tend to hide Netlink details.
+ .
+ * Easy to use: the library simplifies the work for Netlink-wise developers.
+ It provides functions to make socket handling, message building, validating,
+ parsing and sequence tracking, easier.
+ .
+ * Easy to re-use: you can use the library to build your own abstraction layer
+ on top of this library.
+ .
+ * Decoupling: the interdependency of the main bricks that compose the library
+ is reduced, i.e. the library provides many helpers, but the programmer is not
+ forced to use them.
+endef
+
+CONFIGURE_ARGS+= \
+ --enable-shared \
+ --enable-static \
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include
+ $(CP) $(PKG_INSTALL_DIR)/usr/include/libmnl $(1)/usr/include/
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libmnl.{a,so*} $(1)/usr/lib/
+ $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libmnl.pc $(1)/usr/lib/pkgconfig/
+endef
+
+define Package/libmnl/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libmnl.so.* $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,libmnl))
diff --git a/package/libs/libnetfilter-conntrack/.svn/entries b/package/libs/libnetfilter-conntrack/.svn/entries
new file mode 100644
index 0000000..28cadb1
--- /dev/null
+++ b/package/libs/libnetfilter-conntrack/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs/libnetfilter-conntrack
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-17T12:47:54.810041Z
+33804
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:07.000000Z
+fdd6b0a0651f0f201addb1c2271dd00d
+2012-10-17T12:47:54.810041Z
+33804
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2021
+
diff --git a/package/libs/libnetfilter-conntrack/.svn/text-base/Makefile.svn-base b/package/libs/libnetfilter-conntrack/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..8499277
--- /dev/null
+++ b/package/libs/libnetfilter-conntrack/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,73 @@
+#
+# Copyright (C) 2009-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=libnetfilter_conntrack
+PKG_VERSION:=0.9.1
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:= \
+ http://www.netfilter.org/projects/libnetfilter_conntrack/files/ \
+ ftp://ftp.netfilter.org/pub/libnetfilter_conntrack/
+PKG_MD5SUM:=b7506cbb7580433859809d8eac53a199
+PKG_MAINTAINER:=Jo-Philipp Wich <jow@openwrt.org>
+
+PKG_FIXUP:=autoreconf
+
+PKG_INSTALL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/libnetfilter-conntrack
+ SECTION:=libs
+ CATEGORY:=Libraries
+ DEPENDS:=+libnfnetlink +kmod-nf-conntrack-netlink
+ TITLE:=API to the in-kernel connection tracking state table
+ URL:=http://www.netfilter.org/projects/libnetfilter_conntrack/
+endef
+
+define Package/libnetfilter-conntrack/description
+ libnetfilter_conntrack is a userspace library providing a programming
+ interface (API) to the in-kernel connection tracking state table. The
+ library libnetfilter_conntrack has been previously known as
+ libnfnetlink_conntrack and libctnetlink. This library is currently
+ used by conntrack-tools among many other applications.
+endef
+
+TARGET_CFLAGS += $(FPIC)
+
+CONFIGURE_ARGS += \
+ --enable-static \
+ --enable-shared \
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include/libnetfilter_conntrack
+ $(CP) \
+ $(PKG_INSTALL_DIR)/usr/include/libnetfilter_conntrack/*.h \
+ $(1)/usr/include/libnetfilter_conntrack/
+
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) \
+ $(PKG_INSTALL_DIR)/usr/lib/libnetfilter_conntrack.{so*,a,la} \
+ $(1)/usr/lib/
+
+ $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
+ $(CP) \
+ $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libnetfilter_conntrack.pc \
+ $(1)/usr/lib/pkgconfig/
+endef
+
+define Package/libnetfilter-conntrack/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) \
+ $(PKG_INSTALL_DIR)/usr/lib/libnetfilter_conntrack.so.* \
+ $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,libnetfilter-conntrack))
diff --git a/package/libs/libnetfilter-conntrack/Makefile b/package/libs/libnetfilter-conntrack/Makefile
new file mode 100644
index 0000000..8499277
--- /dev/null
+++ b/package/libs/libnetfilter-conntrack/Makefile
@@ -0,0 +1,73 @@
+#
+# Copyright (C) 2009-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=libnetfilter_conntrack
+PKG_VERSION:=0.9.1
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:= \
+ http://www.netfilter.org/projects/libnetfilter_conntrack/files/ \
+ ftp://ftp.netfilter.org/pub/libnetfilter_conntrack/
+PKG_MD5SUM:=b7506cbb7580433859809d8eac53a199
+PKG_MAINTAINER:=Jo-Philipp Wich <jow@openwrt.org>
+
+PKG_FIXUP:=autoreconf
+
+PKG_INSTALL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/libnetfilter-conntrack
+ SECTION:=libs
+ CATEGORY:=Libraries
+ DEPENDS:=+libnfnetlink +kmod-nf-conntrack-netlink
+ TITLE:=API to the in-kernel connection tracking state table
+ URL:=http://www.netfilter.org/projects/libnetfilter_conntrack/
+endef
+
+define Package/libnetfilter-conntrack/description
+ libnetfilter_conntrack is a userspace library providing a programming
+ interface (API) to the in-kernel connection tracking state table. The
+ library libnetfilter_conntrack has been previously known as
+ libnfnetlink_conntrack and libctnetlink. This library is currently
+ used by conntrack-tools among many other applications.
+endef
+
+TARGET_CFLAGS += $(FPIC)
+
+CONFIGURE_ARGS += \
+ --enable-static \
+ --enable-shared \
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include/libnetfilter_conntrack
+ $(CP) \
+ $(PKG_INSTALL_DIR)/usr/include/libnetfilter_conntrack/*.h \
+ $(1)/usr/include/libnetfilter_conntrack/
+
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) \
+ $(PKG_INSTALL_DIR)/usr/lib/libnetfilter_conntrack.{so*,a,la} \
+ $(1)/usr/lib/
+
+ $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
+ $(CP) \
+ $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libnetfilter_conntrack.pc \
+ $(1)/usr/lib/pkgconfig/
+endef
+
+define Package/libnetfilter-conntrack/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) \
+ $(PKG_INSTALL_DIR)/usr/lib/libnetfilter_conntrack.so.* \
+ $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,libnetfilter-conntrack))
diff --git a/package/libs/libnfnetlink/.svn/entries b/package/libs/libnfnetlink/.svn/entries
new file mode 100644
index 0000000..6ea4b36
--- /dev/null
+++ b/package/libs/libnfnetlink/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs/libnfnetlink
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-13T19:49:06.463965Z
+35142
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+155fe06c3e2d3f916f3788cc4c763d18
+2013-01-13T19:49:06.463965Z
+35142
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1927
+
diff --git a/package/libs/libnfnetlink/.svn/text-base/Makefile.svn-base b/package/libs/libnfnetlink/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..f9ade14
--- /dev/null
+++ b/package/libs/libnfnetlink/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,70 @@
+#
+# Copyright (C) 2007-2013 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=libnfnetlink
+PKG_VERSION:=1.0.1
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:= \
+ http://www.netfilter.org/projects/libnfnetlink/files/ \
+ ftp://ftp.netfilter.org/pub/libnfnetlink/ \
+ http://mirrors.evolva.ro/netfilter.org/libnfnetlink/
+PKG_MD5SUM:=98927583d2016a9fb1936fed992e2c5e
+PKG_MAINTAINER:=Jo-Philipp Wich <jow@openwrt.org>
+
+PKG_FIXUP:=autoreconf
+
+PKG_INSTALL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/libnfnetlink
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=A low-level library for netfilter related kernel/userspace communication
+ URL:=http://netfilter.org/projects/libnfnetlink/
+endef
+
+define Package/libnfnetlink/description
+ libnfnetlink is is the low-level library for netfilter related kernel/userspace communication.
+ It provides a generic messaging infrastructure for in-kernel netfilter subsystems
+ (such as nfnetlink_log, nfnetlink_queue, nfnetlink_conntrack) and their respective users
+ and/or management tools in userspace.
+endef
+
+TARGET_CFLAGS += $(FPIC)
+
+CONFIGURE_ARGS += \
+ --enable-static \
+ --enable-shared
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include/libnfnetlink
+ $(CP) \
+ $(PKG_INSTALL_DIR)/usr/include/libnfnetlink/{libnfnetlink,linux_nfnetlink,linux_nfnetlink_compat}.h \
+ $(1)/usr/include/libnfnetlink/
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) \
+ $(PKG_INSTALL_DIR)/usr/lib/libnfnetlink.{a,so*} \
+ $(1)/usr/lib/
+ $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
+ $(CP) \
+ $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libnfnetlink.pc \
+ $(1)/usr/lib/pkgconfig/
+endef
+
+define Package/libnfnetlink/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) \
+ $(PKG_INSTALL_DIR)/usr/lib/libnfnetlink.so.* \
+ $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,libnfnetlink))
diff --git a/package/libs/libnfnetlink/Makefile b/package/libs/libnfnetlink/Makefile
new file mode 100644
index 0000000..f9ade14
--- /dev/null
+++ b/package/libs/libnfnetlink/Makefile
@@ -0,0 +1,70 @@
+#
+# Copyright (C) 2007-2013 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=libnfnetlink
+PKG_VERSION:=1.0.1
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:= \
+ http://www.netfilter.org/projects/libnfnetlink/files/ \
+ ftp://ftp.netfilter.org/pub/libnfnetlink/ \
+ http://mirrors.evolva.ro/netfilter.org/libnfnetlink/
+PKG_MD5SUM:=98927583d2016a9fb1936fed992e2c5e
+PKG_MAINTAINER:=Jo-Philipp Wich <jow@openwrt.org>
+
+PKG_FIXUP:=autoreconf
+
+PKG_INSTALL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/libnfnetlink
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=A low-level library for netfilter related kernel/userspace communication
+ URL:=http://netfilter.org/projects/libnfnetlink/
+endef
+
+define Package/libnfnetlink/description
+ libnfnetlink is is the low-level library for netfilter related kernel/userspace communication.
+ It provides a generic messaging infrastructure for in-kernel netfilter subsystems
+ (such as nfnetlink_log, nfnetlink_queue, nfnetlink_conntrack) and their respective users
+ and/or management tools in userspace.
+endef
+
+TARGET_CFLAGS += $(FPIC)
+
+CONFIGURE_ARGS += \
+ --enable-static \
+ --enable-shared
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include/libnfnetlink
+ $(CP) \
+ $(PKG_INSTALL_DIR)/usr/include/libnfnetlink/{libnfnetlink,linux_nfnetlink,linux_nfnetlink_compat}.h \
+ $(1)/usr/include/libnfnetlink/
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) \
+ $(PKG_INSTALL_DIR)/usr/lib/libnfnetlink.{a,so*} \
+ $(1)/usr/lib/
+ $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
+ $(CP) \
+ $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libnfnetlink.pc \
+ $(1)/usr/lib/pkgconfig/
+endef
+
+define Package/libnfnetlink/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) \
+ $(PKG_INSTALL_DIR)/usr/lib/libnfnetlink.so.* \
+ $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,libnfnetlink))
diff --git a/package/libs/libnl-tiny/.svn/entries b/package/libs/libnl-tiny/.svn/entries
new file mode 100644
index 0000000..2255941
--- /dev/null
+++ b/package/libs/libnl-tiny/.svn/entries
@@ -0,0 +1,68 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs/libnl-tiny
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-12-22T18:56:01.032328Z
+34864
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+files
+dir
+
+src
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+06cd63aa4ddd972c14c94f6f3449f163
+2012-10-19T15:34:28.915431Z
+33861
+hcg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1240
+
diff --git a/package/libs/libnl-tiny/.svn/text-base/Makefile.svn-base b/package/libs/libnl-tiny/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..9639ac3
--- /dev/null
+++ b/package/libs/libnl-tiny/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,57 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=libnl-tiny
+PKG_VERSION:=0.1
+PKG_RELEASE:=3
+
+PKG_LICENSE:=GPLv2 LGPLv2.1
+PKG_LICENSE_FILES:=
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/libnl-tiny
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=netlink socket library
+endef
+
+define Package/libnl-tiny/description
+ This package contains a stripped down version of libnl
+endef
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+TARGET_CFLAGS += $(FPIC)
+
+define Build/Compile
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ $(TARGET_CONFIGURE_OPTS) \
+ CFLAGS="$(TARGET_CFLAGS)" \
+ all
+endef
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/lib/pkgconfig $(1)/usr/include/libnl-tiny
+ $(CP) $(PKG_BUILD_DIR)/include/* $(1)/usr/include/libnl-tiny
+ $(CP) $(PKG_BUILD_DIR)/libnl-tiny.so $(1)/usr/lib/
+ $(CP) ./files/libnl-tiny.pc $(1)/usr/lib/pkgconfig
+endef
+
+define Package/libnl-tiny/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_BUILD_DIR)/libnl-tiny.so $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,libnl-tiny))
diff --git a/package/libs/libnl-tiny/Makefile b/package/libs/libnl-tiny/Makefile
new file mode 100644
index 0000000..9639ac3
--- /dev/null
+++ b/package/libs/libnl-tiny/Makefile
@@ -0,0 +1,57 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=libnl-tiny
+PKG_VERSION:=0.1
+PKG_RELEASE:=3
+
+PKG_LICENSE:=GPLv2 LGPLv2.1
+PKG_LICENSE_FILES:=
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/libnl-tiny
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=netlink socket library
+endef
+
+define Package/libnl-tiny/description
+ This package contains a stripped down version of libnl
+endef
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+TARGET_CFLAGS += $(FPIC)
+
+define Build/Compile
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ $(TARGET_CONFIGURE_OPTS) \
+ CFLAGS="$(TARGET_CFLAGS)" \
+ all
+endef
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/lib/pkgconfig $(1)/usr/include/libnl-tiny
+ $(CP) $(PKG_BUILD_DIR)/include/* $(1)/usr/include/libnl-tiny
+ $(CP) $(PKG_BUILD_DIR)/libnl-tiny.so $(1)/usr/lib/
+ $(CP) ./files/libnl-tiny.pc $(1)/usr/lib/pkgconfig
+endef
+
+define Package/libnl-tiny/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_BUILD_DIR)/libnl-tiny.so $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,libnl-tiny))
diff --git a/package/libs/libnl-tiny/files/.svn/entries b/package/libs/libnl-tiny/files/.svn/entries
new file mode 100644
index 0000000..cbae58d
--- /dev/null
+++ b/package/libs/libnl-tiny/files/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs/libnl-tiny/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-12-22T18:56:01.032328Z
+34864
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+libnl-tiny.pc
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+91a78ee501f581617be2060f2ab9a05f
+2012-12-22T18:56:01.032328Z
+34864
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+231
+
diff --git a/package/libs/libnl-tiny/files/.svn/text-base/libnl-tiny.pc.svn-base b/package/libs/libnl-tiny/files/.svn/text-base/libnl-tiny.pc.svn-base
new file mode 100644
index 0000000..af79cd3
--- /dev/null
+++ b/package/libs/libnl-tiny/files/.svn/text-base/libnl-tiny.pc.svn-base
@@ -0,0 +1,10 @@
+prefix=/usr
+exec_prefix=/usr
+libdir=${exec_prefix}/lib
+includedir=${prefix}/include/libnl-tiny
+
+Name: libnl-tiny
+Description: Convenience library for netlink sockets
+Version: 2.0
+Libs: -L${libdir} -lnl-tiny
+Cflags: -I${includedir}
diff --git a/package/libs/libnl-tiny/files/libnl-tiny.pc b/package/libs/libnl-tiny/files/libnl-tiny.pc
new file mode 100644
index 0000000..af79cd3
--- /dev/null
+++ b/package/libs/libnl-tiny/files/libnl-tiny.pc
@@ -0,0 +1,10 @@
+prefix=/usr
+exec_prefix=/usr
+libdir=${exec_prefix}/lib
+includedir=${prefix}/include/libnl-tiny
+
+Name: libnl-tiny
+Description: Convenience library for netlink sockets
+Version: 2.0
+Libs: -L${libdir} -lnl-tiny
+Cflags: -I${includedir}
diff --git a/package/libs/libnl-tiny/src/.svn/entries b/package/libs/libnl-tiny/src/.svn/entries
new file mode 100644
index 0000000..f09b21b
--- /dev/null
+++ b/package/libs/libnl-tiny/src/.svn/entries
@@ -0,0 +1,541 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs/libnl-tiny/src
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+unl.c
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+b9c675e4a1fb167e979e6b7d0e272c87
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5409
+
+handlers.c
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+6245a26d067c45da665b3d5de9bb9562
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3266
+
+include
+dir
+
+cache.c
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+2c68636b65f11d40dac9993e10e8ce1b
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+18945
+
+object.c
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+a6b158e4e41304996c996adee7a06df1
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5903
+
+nl.c
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+ec05beaa0bce812c08c78d431e4a9b9d
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+17706
+
+genl_ctrl.c
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+6953e8a2a8961bfc950088a26ed44d19
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+6939
+
+attr.c
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+b51db172000c6f3b79077be3c20cf5c4
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+22157
+
+genl_mngt.c
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+d8d1f71a904b6afad2791fc594bd14b5
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5876
+
+genl.c
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+9708594a56dc1e15978dd57cfeee2a1a
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+6679
+
+msg.c
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+36ec77518f7910d399e7dc6680c8ffb9
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+15721
+
+genl_family.c
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+27f32eb592ee97d5374199393759b5ec
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2974
+
+socket.c
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+58c0bb26b3528187806d1190f4755345
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+8124
+
+cache_mngt.c
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+97ae1d8452d02e1c272106a6bdaf1c4c
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5598
+
+error.c
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+f2b69a6b456e30db8f9478b54fb0f9a2
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3197
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+cf7fd2e03ffc7b6e43e06afdb4513057
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+360
+
diff --git a/package/libs/libnl-tiny/src/.svn/text-base/Makefile.svn-base b/package/libs/libnl-tiny/src/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..f6f90ec
--- /dev/null
+++ b/package/libs/libnl-tiny/src/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,17 @@
+CC=gcc
+WFLAGS=-Wall
+CFLAGS=-O2
+INCLUDES=-Iinclude
+
+LIBNAME=libnl-tiny.so
+
+all: $(LIBNAME)
+
+%.o: %.c
+ $(CC) $(WFLAGS) -c -o $@ $(INCLUDES) $(CFLAGS) $<
+
+LIBNL_OBJ=nl.o handlers.o msg.o attr.o cache.o cache_mngt.o object.o socket.o error.o
+GENL_OBJ=genl.o genl_family.o genl_ctrl.o genl_mngt.o unl.o
+
+$(LIBNAME): $(LIBNL_OBJ) $(GENL_OBJ)
+ $(CC) -shared -o $@ $^
diff --git a/package/libs/libnl-tiny/src/.svn/text-base/attr.c.svn-base b/package/libs/libnl-tiny/src/.svn/text-base/attr.c.svn-base
new file mode 100644
index 0000000..e0f5061
--- /dev/null
+++ b/package/libs/libnl-tiny/src/.svn/text-base/attr.c.svn-base
@@ -0,0 +1,668 @@
+/*
+ * lib/attr.c Netlink Attributes
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
+ */
+
+#include <netlink-local.h>
+#include <netlink/netlink.h>
+#include <netlink/utils.h>
+#include <netlink/addr.h>
+#include <netlink/attr.h>
+#include <netlink/msg.h>
+#include <linux/socket.h>
+
+/**
+ * @ingroup msg
+ * @defgroup attr Attributes
+ * Netlink Attributes Construction/Parsing Interface
+ *
+ * \section attr_sec Netlink Attributes
+ * Netlink attributes allow for data chunks of arbitary length to be
+ * attached to a netlink message. Each attribute is encoded with a
+ * type and length field, both 16 bits, stored in the attribute header
+ * preceding the attribute data. The main advantage of using attributes
+ * over packing everything into the family header is that the interface
+ * stays extendable as new attributes can supersede old attributes while
+ * remaining backwards compatible. Also attributes can be defined optional
+ * thus avoiding the transmission of unnecessary empty data blocks.
+ * Special nested attributes allow for more complex data structures to
+ * be transmitted, e.g. trees, lists, etc.
+ *
+ * While not required, netlink attributes typically follow the family
+ * header of a netlink message and must be properly aligned to NLA_ALIGNTO:
+ * @code
+ * +----------------+- - -+---------------+- - -+------------+- - -+
+ * | Netlink Header | Pad | Family Header | Pad | Attributes | Pad |
+ * +----------------+- - -+---------------+- - -+------------+- - -+
+ * @endcode
+ *
+ * The actual attributes are chained together each separately aligned to
+ * NLA_ALIGNTO. The position of an attribute is defined based on the
+ * length field of the preceding attributes:
+ * @code
+ * +-------------+- - -+-------------+- - -+------
+ * | Attribute 1 | Pad | Attribute 2 | Pad | ...
+ * +-------------+- - -+-------------+- - -+------
+ * nla_next(attr1)------^
+ * @endcode
+ *
+ * The attribute itself consists of the attribute header followed by
+ * the actual payload also aligned to NLA_ALIGNTO. The function nla_data()
+ * returns a pointer to the start of the payload while nla_len() returns
+ * the length of the payload in bytes.
+ *
+ * \b Note: Be aware, NLA_ALIGNTO equals to 4 bytes, therefore it is not
+ * safe to dereference any 64 bit data types directly.
+ *
+ * @code
+ * <----------- nla_total_size(payload) ----------->
+ * <-------- nla_attr_size(payload) --------->
+ * +------------------+- - -+- - - - - - - - - +- - -+
+ * | Attribute Header | Pad | Payload | Pad |
+ * +------------------+- - -+- - - - - - - - - +- - -+
+ * nla_data(nla)-------------^
+ * <- nla_len(nla) ->
+ * @endcode
+ *
+ * @subsection attr_datatypes Attribute Data Types
+ * A number of basic data types are supported to simplify access and
+ * validation of netlink attributes. This data type information is
+ * not encoded in the attribute, both the kernel and userspace part
+ * are required to share this information on their own.
+ *
+ * One of the major advantages of these basic types is the automatic
+ * validation of each attribute based on an attribute policy. The
+ * validation covers most of the checks required to safely use
+ * attributes and thus keeps the individual sanity check to a minimum.
+ *
+ * Never access attribute payload without ensuring basic validation
+ * first, attributes may:
+ * - not be present even though required
+ * - contain less actual payload than expected
+ * - fake a attribute length which exceeds the end of the message
+ * - contain unterminated character strings
+ *
+ * Policies are defined as array of the struct nla_policy. The array is
+ * indexed with the attribute type, therefore the array must be sized
+ * accordingly.
+ * @code
+ * static struct nla_policy my_policy[ATTR_MAX+1] = {
+ * [ATTR_FOO] = { .type = ..., .minlen = ..., .maxlen = ... },
+ * };
+ *
+ * err = nla_validate(attrs, attrlen, ATTR_MAX, &my_policy);
+ * @endcode
+ *
+ * Some basic validations are performed on every attribute, regardless of type.
+ * - If the attribute type exceeds the maximum attribute type specified or
+ * the attribute type is lesser-or-equal than zero, the attribute will
+ * be silently ignored.
+ * - If the payload length falls below the \a minlen value the attribute
+ * will be rejected.
+ * - If \a maxlen is non-zero and the payload length exceeds the \a maxlen
+ * value the attribute will be rejected.
+ *
+ *
+ * @par Unspecific Attribute (NLA_UNSPEC)
+ * This is the standard type if no type is specified. It is used for
+ * binary data of arbitary length. Typically this attribute carries
+ * a binary structure or a stream of bytes.
+ * @par
+ * @code
+ * // In this example, we will assume a binary structure requires to
+ * // be transmitted. The definition of the structure will typically
+ * // go into a header file available to both the kernel and userspace
+ * // side.
+ * //
+ * // Note: Be careful when putting 64 bit data types into a structure.
+ * // The attribute payload is only aligned to 4 bytes, dereferencing
+ * // the member may fail.
+ * struct my_struct {
+ * int a;
+ * int b;
+ * };
+ *
+ * // The validation function will not enforce an exact length match to
+ * // allow structures to grow as required. Note: While it is allowed
+ * // to add members to the end of the structure, changing the order or
+ * // inserting members in the middle of the structure will break your
+ * // binary interface.
+ * static struct nla_policy my_policy[ATTR_MAX+1] = {
+ * [ATTR_MY_STRICT] = { .type = NLA_UNSPEC,
+ * .minlen = sizeof(struct my_struct) },
+ *
+ * // The binary structure is appened to the message using nla_put()
+ * struct my_struct foo = { .a = 1, .b = 2 };
+ * nla_put(msg, ATTR_MY_STRUCT, sizeof(foo), &foo);
+ *
+ * // On the receiving side, a pointer to the structure pointing inside
+ * // the message payload is returned by nla_get().
+ * if (attrs[ATTR_MY_STRUCT])
+ * struct my_struct *foo = nla_get(attrs[ATTR_MY_STRUCT]);
+ * @endcode
+ *
+ * @par Integers (NLA_U8, NLA_U16, NLA_U32, NLA_U64)
+ * Integers come in different sizes from 8 bit to 64 bit. However, since the
+ * payload length is aligned to 4 bytes, integers smaller than 32 bit are
+ * only useful to enforce the maximum range of values.
+ * @par
+ * \b Note: There is no difference made between signed and unsigned integers.
+ * The validation only enforces the minimal payload length required to store
+ * an integer of specified type.
+ * @par
+ * @code
+ * // Even though possible, it does not make sense to specify .minlen or
+ * // .maxlen for integer types. The data types implies the corresponding
+ * // minimal payload length.
+ * static struct nla_policy my_policy[ATTR_MAX+1] = {
+ * [ATTR_FOO] = { .type = NLA_U32 },
+ *
+ * // Numeric values can be appended directly using the respective
+ * // nla_put_uxxx() function
+ * nla_put_u32(msg, ATTR_FOO, 123);
+ *
+ * // Same for the receiving side.
+ * if (attrs[ATTR_FOO])
+ * uint32_t foo = nla_get_u32(attrs[ATTR_FOO]);
+ * @endcode
+ *
+ * @par Character string (NLA_STRING)
+ * This data type represents a NUL terminated character string of variable
+ * length. For binary data streams the type NLA_UNSPEC is recommended.
+ * @par
+ * @code
+ * // Enforce a NUL terminated character string of at most 4 characters
+ * // including the NUL termination.
+ * static struct nla_policy my_policy[ATTR_MAX+1] = {
+ * [ATTR_BAR] = { .type = NLA_STRING, maxlen = 4 },
+ *
+ * // nla_put_string() creates a string attribute of the necessary length
+ * // and appends it to the message including the NUL termination.
+ * nla_put_string(msg, ATTR_BAR, "some text");
+ *
+ * // It is safe to use the returned character string directly if the
+ * // attribute has been validated as the validation enforces the proper
+ * // termination of the string.
+ * if (attrs[ATTR_BAR])
+ * char *text = nla_get_string(attrs[ATTR_BAR]);
+ * @endcode
+ *
+ * @par Flag (NLA_FLAG)
+ * This attribute type may be used to indicate the presence of a flag. The
+ * attribute is only valid if the payload length is zero. The presence of
+ * the attribute header indicates the presence of the flag.
+ * @par
+ * @code
+ * // This attribute type is special as .minlen and .maxlen have no effect.
+ * static struct nla_policy my_policy[ATTR_MAX+1] = {
+ * [ATTR_FLAG] = { .type = NLA_FLAG },
+ *
+ * // nla_put_flag() appends a zero sized attribute to the message.
+ * nla_put_flag(msg, ATTR_FLAG);
+ *
+ * // There is no need for a receival function, the presence is the value.
+ * if (attrs[ATTR_FLAG])
+ * // flag is present
+ * @endcode
+ *
+ * @par Micro Seconds (NLA_MSECS)
+ *
+ * @par Nested Attribute (NLA_NESTED)
+ * Attributes can be nested and put into a container to create groups, lists
+ * or to construct trees of attributes. Nested attributes are often used to
+ * pass attributes to a subsystem where the top layer has no knowledge of the
+ * configuration possibilities of each subsystem.
+ * @par
+ * \b Note: When validating the attributes using nlmsg_validate() or
+ * nlmsg_parse() it will only affect the top level attributes. Each
+ * level of nested attributes must be validated seperately using
+ * nla_parse_nested() or nla_validate().
+ * @par
+ * @code
+ * // The minimal length policy may be used to enforce the presence of at
+ * // least one attribute.
+ * static struct nla_policy my_policy[ATTR_MAX+1] = {
+ * [ATTR_OPTS] = { .type = NLA_NESTED, minlen = NLA_HDRLEN },
+ *
+ * // Nested attributes are constructed by enclosing the attributes
+ * // to be nested with calls to nla_nest_start() respetively nla_nest_end().
+ * struct nlattr *opts = nla_nest_start(msg, ATTR_OPTS);
+ * nla_put_u32(msg, ATTR_FOO, 123);
+ * nla_put_string(msg, ATTR_BAR, "some text");
+ * nla_nest_end(msg, opts);
+ *
+ * // Various methods exist to parse nested attributes, the easiest being
+ * // nla_parse_nested() which also allows validation in the same step.
+ * if (attrs[ATTR_OPTS]) {
+ * struct nlattr *nested[ATTR_MAX+1];
+ *
+ * nla_parse_nested(nested, ATTR_MAX, attrs[ATTR_OPTS], &policy);
+ *
+ * if (nested[ATTR_FOO])
+ * uint32_t foo = nla_get_u32(nested[ATTR_FOO]);
+ * }
+ * @endcode
+ *
+ * @subsection attr_exceptions Exception Based Attribute Construction
+ * Often a large number of attributes are added to a message in a single
+ * function. In order to simplify error handling, a second set of
+ * construction functions exist which jump to a error label when they
+ * fail instead of returning an error code. This second set consists
+ * of macros which are named after their error code based counterpart
+ * except that the name is written all uppercase.
+ *
+ * All of the macros jump to the target \c nla_put_failure if they fail.
+ * @code
+ * void my_func(struct nl_msg *msg)
+ * {
+ * NLA_PUT_U32(msg, ATTR_FOO, 10);
+ * NLA_PUT_STRING(msg, ATTR_BAR, "bar");
+ *
+ * return 0;
+ *
+ * nla_put_failure:
+ * return -NLE_NOMEM;
+ * }
+ * @endcode
+ *
+ * @subsection attr_examples Examples
+ * @par Example 1.1 Constructing a netlink message with attributes.
+ * @code
+ * struct nl_msg *build_msg(int ifindex, struct nl_addr *lladdr, int mtu)
+ * {
+ * struct nl_msg *msg;
+ * struct nlattr *info, *vlan;
+ * struct ifinfomsg ifi = {
+ * .ifi_family = AF_INET,
+ * .ifi_index = ifindex,
+ * };
+ *
+ * // Allocate a new netlink message, type=RTM_SETLINK, flags=NLM_F_ECHO
+ * if (!(msg = nlmsg_alloc_simple(RTM_SETLINK, NLM_F_ECHO)))
+ * return NULL;
+ *
+ * // Append the family specific header (struct ifinfomsg)
+ * if (nlmsg_append(msg, &ifi, sizeof(ifi), NLMSG_ALIGNTO) < 0)
+ * goto nla_put_failure
+ *
+ * // Append a 32 bit integer attribute to carry the MTU
+ * NLA_PUT_U32(msg, IFLA_MTU, mtu);
+ *
+ * // Append a unspecific attribute to carry the link layer address
+ * NLA_PUT_ADDR(msg, IFLA_ADDRESS, lladdr);
+ *
+ * // Append a container for nested attributes to carry link information
+ * if (!(info = nla_nest_start(msg, IFLA_LINKINFO)))
+ * goto nla_put_failure;
+ *
+ * // Put a string attribute into the container
+ * NLA_PUT_STRING(msg, IFLA_INFO_KIND, "vlan");
+ *
+ * // Append another container inside the open container to carry
+ * // vlan specific attributes
+ * if (!(vlan = nla_nest_start(msg, IFLA_INFO_DATA)))
+ * goto nla_put_failure;
+ *
+ * // add vlan specific info attributes here...
+ *
+ * // Finish nesting the vlan attributes and close the second container.
+ * nla_nest_end(msg, vlan);
+ *
+ * // Finish nesting the link info attribute and close the first container.
+ * nla_nest_end(msg, info);
+ *
+ * return msg;
+ *
+ * // If any of the construction macros fails, we end up here.
+ * nla_put_failure:
+ * nlmsg_free(msg);
+ * return NULL;
+ * }
+ * @endcode
+ *
+ * @par Example 2.1 Parsing a netlink message with attributes.
+ * @code
+ * int parse_message(struct nl_msg *msg)
+ * {
+ * // The policy defines two attributes: a 32 bit integer and a container
+ * // for nested attributes.
+ * struct nla_policy attr_policy[ATTR_MAX+1] = {
+ * [ATTR_FOO] = { .type = NLA_U32 },
+ * [ATTR_BAR] = { .type = NLA_NESTED },
+ * };
+ * struct nlattr *attrs[ATTR_MAX+1];
+ * int err;
+ *
+ * // The nlmsg_parse() function will make sure that the message contains
+ * // enough payload to hold the header (struct my_hdr), validates any
+ * // attributes attached to the messages and stores a pointer to each
+ * // attribute in the attrs[] array accessable by attribute type.
+ * if ((err = nlmsg_parse(nlmsg_hdr(msg), sizeof(struct my_hdr), attrs,
+ * ATTR_MAX, attr_policy)) < 0)
+ * goto errout;
+ *
+ * if (attrs[ATTR_FOO]) {
+ * // It is safe to directly access the attribute payload without
+ * // any further checks since nlmsg_parse() enforced the policy.
+ * uint32_t foo = nla_get_u32(attrs[ATTR_FOO]);
+ * }
+ *
+ * if (attrs[ATTR_BAR]) {
+ * struct nlattr *nested[NESTED_MAX+1];
+ *
+ * // Attributes nested in a container can be parsed the same way
+ * // as top level attributes.
+ * if ((err = nla_parse_nested(nested, NESTED_MAX, attrs[ATTR_BAR],
+ * nested_policy)) < 0)
+ * goto errout;
+ *
+ * // Process nested attributes here.
+ * }
+ *
+ * err = 0;
+ * errout:
+ * return err;
+ * }
+ * @endcode
+ *
+ * @{
+ */
+
+/**
+ * @name Attribute Size Calculation
+ * @{
+ */
+
+/** @} */
+
+/**
+ * @name Parsing Attributes
+ * @{
+ */
+
+/**
+ * Check if the attribute header and payload can be accessed safely.
+ * @arg nla Attribute of any kind.
+ * @arg remaining Number of bytes remaining in attribute stream.
+ *
+ * Verifies that the header and payload do not exceed the number of
+ * bytes left in the attribute stream. This function must be called
+ * before access the attribute header or payload when iterating over
+ * the attribute stream using nla_next().
+ *
+ * @return True if the attribute can be accessed safely, false otherwise.
+ */
+int nla_ok(const struct nlattr *nla, int remaining)
+{
+ return remaining >= sizeof(*nla) &&
+ nla->nla_len >= sizeof(*nla) &&
+ nla->nla_len <= remaining;
+}
+
+/**
+ * Return next attribute in a stream of attributes.
+ * @arg nla Attribute of any kind.
+ * @arg remaining Variable to count remaining bytes in stream.
+ *
+ * Calculates the offset to the next attribute based on the attribute
+ * given. The attribute provided is assumed to be accessible, the
+ * caller is responsible to use nla_ok() beforehand. The offset (length
+ * of specified attribute including padding) is then subtracted from
+ * the remaining bytes variable and a pointer to the next attribute is
+ * returned.
+ *
+ * nla_next() can be called as long as remainig is >0.
+ *
+ * @return Pointer to next attribute.
+ */
+struct nlattr *nla_next(const struct nlattr *nla, int *remaining)
+{
+ int totlen = NLA_ALIGN(nla->nla_len);
+
+ *remaining -= totlen;
+ return (struct nlattr *) ((char *) nla + totlen);
+}
+
+static uint16_t nla_attr_minlen[NLA_TYPE_MAX+1] = {
+ [NLA_U8] = sizeof(uint8_t),
+ [NLA_U16] = sizeof(uint16_t),
+ [NLA_U32] = sizeof(uint32_t),
+ [NLA_U64] = sizeof(uint64_t),
+ [NLA_STRING] = 1,
+};
+
+static int validate_nla(struct nlattr *nla, int maxtype,
+ struct nla_policy *policy)
+{
+ struct nla_policy *pt;
+ int minlen = 0, type = nla_type(nla);
+
+ if (type <= 0 || type > maxtype)
+ return 0;
+
+ pt = &policy[type];
+
+ if (pt->type > NLA_TYPE_MAX)
+ BUG();
+
+ if (pt->minlen)
+ minlen = pt->minlen;
+ else if (pt->type != NLA_UNSPEC)
+ minlen = nla_attr_minlen[pt->type];
+
+ if (pt->type == NLA_FLAG && nla_len(nla) > 0)
+ return -NLE_RANGE;
+
+ if (nla_len(nla) < minlen)
+ return -NLE_RANGE;
+
+ if (pt->maxlen && nla_len(nla) > pt->maxlen)
+ return -NLE_RANGE;
+
+ if (pt->type == NLA_STRING) {
+ char *data = nla_data(nla);
+ if (data[nla_len(nla) - 1] != '\0')
+ return -NLE_INVAL;
+ }
+
+ return 0;
+}
+
+
+/**
+ * Create attribute index based on a stream of attributes.
+ * @arg tb Index array to be filled (maxtype+1 elements).
+ * @arg maxtype Maximum attribute type expected and accepted.
+ * @arg head Head of attribute stream.
+ * @arg len Length of attribute stream.
+ * @arg policy Attribute validation policy.
+ *
+ * Iterates over the stream of attributes and stores a pointer to each
+ * attribute in the index array using the attribute type as index to
+ * the array. Attribute with a type greater than the maximum type
+ * specified will be silently ignored in order to maintain backwards
+ * compatibility. If \a policy is not NULL, the attribute will be
+ * validated using the specified policy.
+ *
+ * @see nla_validate
+ * @return 0 on success or a negative error code.
+ */
+int nla_parse(struct nlattr *tb[], int maxtype, struct nlattr *head, int len,
+ struct nla_policy *policy)
+{
+ struct nlattr *nla;
+ int rem, err;
+
+ memset(tb, 0, sizeof(struct nlattr *) * (maxtype + 1));
+
+ nla_for_each_attr(nla, head, len, rem) {
+ int type = nla_type(nla);
+
+ if (type == 0) {
+ fprintf(stderr, "Illegal nla->nla_type == 0\n");
+ continue;
+ }
+
+ if (type <= maxtype) {
+ if (policy) {
+ err = validate_nla(nla, maxtype, policy);
+ if (err < 0)
+ goto errout;
+ }
+
+ tb[type] = nla;
+ }
+ }
+
+ if (rem > 0)
+ fprintf(stderr, "netlink: %d bytes leftover after parsing "
+ "attributes.\n", rem);
+
+ err = 0;
+errout:
+ return err;
+}
+
+/**
+ * Validate a stream of attributes.
+ * @arg head Head of attributes stream.
+ * @arg len Length of attributes stream.
+ * @arg maxtype Maximum attribute type expected and accepted.
+ * @arg policy Validation policy.
+ *
+ * Iterates over the stream of attributes and validates each attribute
+ * one by one using the specified policy. Attributes with a type greater
+ * than the maximum type specified will be silently ignored in order to
+ * maintain backwards compatibility.
+ *
+ * See \ref attr_datatypes for more details on what kind of validation
+ * checks are performed on each attribute data type.
+ *
+ * @return 0 on success or a negative error code.
+ */
+int nla_validate(struct nlattr *head, int len, int maxtype,
+ struct nla_policy *policy)
+{
+ struct nlattr *nla;
+ int rem, err;
+
+ nla_for_each_attr(nla, head, len, rem) {
+ err = validate_nla(nla, maxtype, policy);
+ if (err < 0)
+ goto errout;
+ }
+
+ err = 0;
+errout:
+ return err;
+}
+
+/**
+ * Find a single attribute in a stream of attributes.
+ * @arg head Head of attributes stream.
+ * @arg len Length of attributes stream.
+ * @arg attrtype Attribute type to look for.
+ *
+ * Iterates over the stream of attributes and compares each type with
+ * the type specified. Returns the first attribute which matches the
+ * type.
+ *
+ * @return Pointer to attribute found or NULL.
+ */
+struct nlattr *nla_find(struct nlattr *head, int len, int attrtype)
+{
+ struct nlattr *nla;
+ int rem;
+
+ nla_for_each_attr(nla, head, len, rem)
+ if (nla_type(nla) == attrtype)
+ return nla;
+
+ return NULL;
+}
+
+/** @} */
+
+/**
+ * @name Unspecific Attribute
+ * @{
+ */
+
+/**
+ * Reserve space for a attribute.
+ * @arg msg Netlink Message.
+ * @arg attrtype Attribute Type.
+ * @arg attrlen Length of payload.
+ *
+ * Reserves room for a attribute in the specified netlink message and
+ * fills in the attribute header (type, length). Returns NULL if there
+ * is unsuficient space for the attribute.
+ *
+ * Any padding between payload and the start of the next attribute is
+ * zeroed out.
+ *
+ * @return Pointer to start of attribute or NULL on failure.
+ */
+struct nlattr *nla_reserve(struct nl_msg *msg, int attrtype, int attrlen)
+{
+ struct nlattr *nla;
+ int tlen;
+
+ tlen = NLMSG_ALIGN(msg->nm_nlh->nlmsg_len) + nla_total_size(attrlen);
+
+ if ((tlen + msg->nm_nlh->nlmsg_len) > msg->nm_size)
+ return NULL;
+
+ nla = (struct nlattr *) nlmsg_tail(msg->nm_nlh);
+ nla->nla_type = attrtype;
+ nla->nla_len = nla_attr_size(attrlen);
+
+ memset((unsigned char *) nla + nla->nla_len, 0, nla_padlen(attrlen));
+ msg->nm_nlh->nlmsg_len = tlen;
+
+ NL_DBG(2, "msg %p: Reserved %d bytes at offset +%td for attr %d "
+ "nlmsg_len=%d\n", msg, attrlen,
+ (void *) nla - nlmsg_data(msg->nm_nlh),
+ attrtype, msg->nm_nlh->nlmsg_len);
+
+ return nla;
+}
+
+/**
+ * Add a unspecific attribute to netlink message.
+ * @arg msg Netlink message.
+ * @arg attrtype Attribute type.
+ * @arg datalen Length of data to be used as payload.
+ * @arg data Pointer to data to be used as attribute payload.
+ *
+ * Reserves room for a unspecific attribute and copies the provided data
+ * into the message as payload of the attribute. Returns an error if there
+ * is insufficient space for the attribute.
+ *
+ * @see nla_reserve
+ * @return 0 on success or a negative error code.
+ */
+int nla_put(struct nl_msg *msg, int attrtype, int datalen, const void *data)
+{
+ struct nlattr *nla;
+
+ nla = nla_reserve(msg, attrtype, datalen);
+ if (!nla)
+ return -NLE_NOMEM;
+
+ memcpy(nla_data(nla), data, datalen);
+ NL_DBG(2, "msg %p: Wrote %d bytes at offset +%td for attr %d\n",
+ msg, datalen, (void *) nla - nlmsg_data(msg->nm_nlh), attrtype);
+
+ return 0;
+}
+
+
+
+/** @} */
diff --git a/package/libs/libnl-tiny/src/.svn/text-base/cache.c.svn-base b/package/libs/libnl-tiny/src/.svn/text-base/cache.c.svn-base
new file mode 100644
index 0000000..0e14574
--- /dev/null
+++ b/package/libs/libnl-tiny/src/.svn/text-base/cache.c.svn-base
@@ -0,0 +1,839 @@
+/*
+ * lib/cache.c Caching Module
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
+ */
+
+/**
+ * @ingroup cache_mngt
+ * @defgroup cache Cache
+ *
+ * @code
+ * Cache Management | | Type Specific Cache Operations
+ *
+ * | | +----------------+ +------------+
+ * | request update | | msg_parser |
+ * | | +----------------+ +------------+
+ * +- - - - -^- - - - - - - -^- -|- - - -
+ * nl_cache_update: | | | |
+ * 1) --------- co_request_update ------+ | |
+ * | | |
+ * 2) destroy old cache +----------- pp_cb ---------|---+
+ * | | |
+ * 3) ---------- nl_recvmsgs ----------+ +- cb_valid -+
+ * +--------------+ | | | |
+ * | nl_cache_add |<-----+ + - - -v- -|- - - - - - - - - - -
+ * +--------------+ | | +-------------+
+ * | nl_recvmsgs |
+ * | | +-----|-^-----+
+ * +---v-|---+
+ * | | | nl_recv |
+ * +---------+
+ * | | Core Netlink
+ * @endcode
+ *
+ * @{
+ */
+
+#include <netlink-local.h>
+#include <netlink/netlink.h>
+#include <netlink/cache.h>
+#include <netlink/object.h>
+#include <netlink/utils.h>
+
+/**
+ * @name Access Functions
+ * @{
+ */
+
+#ifdef disabled
+/**
+ * Return the number of items in the cache
+ * @arg cache cache handle
+ */
+int nl_cache_nitems(struct nl_cache *cache)
+{
+ return cache->c_nitems;
+}
+
+/**
+ * Return the number of items matching a filter in the cache
+ * @arg cache Cache object.
+ * @arg filter Filter object.
+ */
+int nl_cache_nitems_filter(struct nl_cache *cache, struct nl_object *filter)
+{
+ struct nl_object_ops *ops;
+ struct nl_object *obj;
+ int nitems = 0;
+
+ if (cache->c_ops == NULL)
+ BUG();
+
+ ops = cache->c_ops->co_obj_ops;
+
+ nl_list_for_each_entry(obj, &cache->c_items, ce_list) {
+ if (filter && !nl_object_match_filter(obj, filter))
+ continue;
+
+ nitems++;
+ }
+
+ return nitems;
+}
+
+/**
+ * Returns \b true if the cache is empty.
+ * @arg cache Cache to check
+ * @return \a true if the cache is empty, otherwise \b false is returned.
+ */
+int nl_cache_is_empty(struct nl_cache *cache)
+{
+ return nl_list_empty(&cache->c_items);
+}
+
+/**
+ * Return the operations set of the cache
+ * @arg cache cache handle
+ */
+struct nl_cache_ops *nl_cache_get_ops(struct nl_cache *cache)
+{
+ return cache->c_ops;
+}
+
+/**
+ * Return the first element in the cache
+ * @arg cache cache handle
+ */
+struct nl_object *nl_cache_get_first(struct nl_cache *cache)
+{
+ if (nl_list_empty(&cache->c_items))
+ return NULL;
+
+ return nl_list_entry(cache->c_items.next,
+ struct nl_object, ce_list);
+}
+
+/**
+ * Return the last element in the cache
+ * @arg cache cache handle
+ */
+struct nl_object *nl_cache_get_last(struct nl_cache *cache)
+{
+ if (nl_list_empty(&cache->c_items))
+ return NULL;
+
+ return nl_list_entry(cache->c_items.prev,
+ struct nl_object, ce_list);
+}
+
+/**
+ * Return the next element in the cache
+ * @arg obj current object
+ */
+struct nl_object *nl_cache_get_next(struct nl_object *obj)
+{
+ if (nl_list_at_tail(obj, &obj->ce_cache->c_items, ce_list))
+ return NULL;
+ else
+ return nl_list_entry(obj->ce_list.next,
+ struct nl_object, ce_list);
+}
+
+/**
+ * Return the previous element in the cache
+ * @arg obj current object
+ */
+struct nl_object *nl_cache_get_prev(struct nl_object *obj)
+{
+ if (nl_list_at_head(obj, &obj->ce_cache->c_items, ce_list))
+ return NULL;
+ else
+ return nl_list_entry(obj->ce_list.prev,
+ struct nl_object, ce_list);
+}
+#endif
+
+/** @} */
+
+/**
+ * @name Cache Creation/Deletion
+ * @{
+ */
+
+/**
+ * Allocate an empty cache
+ * @arg ops cache operations to base the cache on
+ *
+ * @return A newly allocated and initialized cache.
+ */
+struct nl_cache *nl_cache_alloc(struct nl_cache_ops *ops)
+{
+ struct nl_cache *cache;
+
+ cache = calloc(1, sizeof(*cache));
+ if (!cache)
+ return NULL;
+
+ nl_init_list_head(&cache->c_items);
+ cache->c_ops = ops;
+
+ NL_DBG(2, "Allocated cache %p <%s>.\n", cache, nl_cache_name(cache));
+
+ return cache;
+}
+
+int nl_cache_alloc_and_fill(struct nl_cache_ops *ops, struct nl_sock *sock,
+ struct nl_cache **result)
+{
+ struct nl_cache *cache;
+ int err;
+
+ if (!(cache = nl_cache_alloc(ops)))
+ return -NLE_NOMEM;
+
+ if (sock && (err = nl_cache_refill(sock, cache)) < 0) {
+ nl_cache_free(cache);
+ return err;
+ }
+
+ *result = cache;
+ return 0;
+}
+
+#ifdef disabled
+/**
+ * Allocate an empty cache based on type name
+ * @arg kind Name of cache type
+ * @return A newly allocated and initialized cache.
+ */
+int nl_cache_alloc_name(const char *kind, struct nl_cache **result)
+{
+ struct nl_cache_ops *ops;
+ struct nl_cache *cache;
+
+ ops = nl_cache_ops_lookup(kind);
+ if (!ops)
+ return -NLE_NOCACHE;
+
+ if (!(cache = nl_cache_alloc(ops)))
+ return -NLE_NOMEM;
+
+ *result = cache;
+ return 0;
+}
+
+/**
+ * Allocate a new cache containing a subset of a cache
+ * @arg orig Original cache to be based on
+ * @arg filter Filter defining the subset to be filled into new cache
+ * @return A newly allocated cache or NULL.
+ */
+struct nl_cache *nl_cache_subset(struct nl_cache *orig,
+ struct nl_object *filter)
+{
+ struct nl_cache *cache;
+ struct nl_object_ops *ops;
+ struct nl_object *obj;
+
+ if (!filter)
+ BUG();
+
+ cache = nl_cache_alloc(orig->c_ops);
+ if (!cache)
+ return NULL;
+
+ ops = orig->c_ops->co_obj_ops;
+
+ nl_list_for_each_entry(obj, &orig->c_items, ce_list) {
+ if (!nl_object_match_filter(obj, filter))
+ continue;
+
+ nl_cache_add(cache, obj);
+ }
+
+ return cache;
+}
+#endif
+
+/**
+ * Clear a cache.
+ * @arg cache cache to clear
+ *
+ * Removes all elements of a cache.
+ */
+void nl_cache_clear(struct nl_cache *cache)
+{
+ struct nl_object *obj, *tmp;
+
+ NL_DBG(1, "Clearing cache %p <%s>...\n", cache, nl_cache_name(cache));
+
+ nl_list_for_each_entry_safe(obj, tmp, &cache->c_items, ce_list)
+ nl_cache_remove(obj);
+}
+
+/**
+ * Free a cache.
+ * @arg cache Cache to free.
+ *
+ * Removes all elements of a cache and frees all memory.
+ *
+ * @note Use this function if you are working with allocated caches.
+ */
+void nl_cache_free(struct nl_cache *cache)
+{
+ if (!cache)
+ return;
+
+ nl_cache_clear(cache);
+ NL_DBG(1, "Freeing cache %p <%s>...\n", cache, nl_cache_name(cache));
+ free(cache);
+}
+
+/** @} */
+
+/**
+ * @name Cache Modifications
+ * @{
+ */
+
+static int __cache_add(struct nl_cache *cache, struct nl_object *obj)
+{
+ obj->ce_cache = cache;
+
+ nl_list_add_tail(&obj->ce_list, &cache->c_items);
+ cache->c_nitems++;
+
+ NL_DBG(1, "Added %p to cache %p <%s>.\n",
+ obj, cache, nl_cache_name(cache));
+
+ return 0;
+}
+
+/**
+ * Add object to a cache.
+ * @arg cache Cache to add object to
+ * @arg obj Object to be added to the cache
+ *
+ * Adds the given object to the specified cache. The object is cloned
+ * if it has been added to another cache already.
+ *
+ * @return 0 or a negative error code.
+ */
+int nl_cache_add(struct nl_cache *cache, struct nl_object *obj)
+{
+ struct nl_object *new;
+
+ if (cache->c_ops->co_obj_ops != obj->ce_ops)
+ return -NLE_OBJ_MISMATCH;
+
+ if (!nl_list_empty(&obj->ce_list)) {
+ new = nl_object_clone(obj);
+ if (!new)
+ return -NLE_NOMEM;
+ } else {
+ nl_object_get(obj);
+ new = obj;
+ }
+
+ return __cache_add(cache, new);
+}
+
+#ifdef disabled
+/**
+ * Move object from one cache to another
+ * @arg cache Cache to move object to.
+ * @arg obj Object subject to be moved
+ *
+ * Removes the given object from its associated cache if needed
+ * and adds it to the new cache.
+ *
+ * @return 0 on success or a negative error code.
+ */
+int nl_cache_move(struct nl_cache *cache, struct nl_object *obj)
+{
+ if (cache->c_ops->co_obj_ops != obj->ce_ops)
+ return -NLE_OBJ_MISMATCH;
+
+ NL_DBG(3, "Moving object %p to cache %p\n", obj, cache);
+
+ /* Acquire reference, if already in a cache this will be
+ * reverted during removal */
+ nl_object_get(obj);
+
+ if (!nl_list_empty(&obj->ce_list))
+ nl_cache_remove(obj);
+
+ return __cache_add(cache, obj);
+}
+#endif
+
+/**
+ * Removes an object from a cache.
+ * @arg obj Object to remove from its cache
+ *
+ * Removes the object \c obj from the cache it is assigned to, since
+ * an object can only be assigned to one cache at a time, the cache
+ * must ne be passed along with it.
+ */
+void nl_cache_remove(struct nl_object *obj)
+{
+ struct nl_cache *cache = obj->ce_cache;
+
+ if (cache == NULL)
+ return;
+
+ nl_list_del(&obj->ce_list);
+ obj->ce_cache = NULL;
+ nl_object_put(obj);
+ cache->c_nitems--;
+
+ NL_DBG(1, "Deleted %p from cache %p <%s>.\n",
+ obj, cache, nl_cache_name(cache));
+}
+
+#ifdef disabled
+/**
+ * Search for an object in a cache
+ * @arg cache Cache to search in.
+ * @arg needle Object to look for.
+ *
+ * Iterates over the cache and looks for an object with identical
+ * identifiers as the needle.
+ *
+ * @return Reference to object or NULL if not found.
+ * @note The returned object must be returned via nl_object_put().
+ */
+struct nl_object *nl_cache_search(struct nl_cache *cache,
+ struct nl_object *needle)
+{
+ struct nl_object *obj;
+
+ nl_list_for_each_entry(obj, &cache->c_items, ce_list) {
+ if (nl_object_identical(obj, needle)) {
+ nl_object_get(obj);
+ return obj;
+ }
+ }
+
+ return NULL;
+}
+#endif
+
+/** @} */
+
+/**
+ * @name Synchronization
+ * @{
+ */
+
+/**
+ * Request a full dump from the kernel to fill a cache
+ * @arg sk Netlink socket.
+ * @arg cache Cache subjected to be filled.
+ *
+ * Send a dumping request to the kernel causing it to dump all objects
+ * related to the specified cache to the netlink socket.
+ *
+ * Use nl_cache_pickup() to read the objects from the socket and fill them
+ * into a cache.
+ */
+int nl_cache_request_full_dump(struct nl_sock *sk, struct nl_cache *cache)
+{
+ NL_DBG(2, "Requesting dump from kernel for cache %p <%s>...\n",
+ cache, nl_cache_name(cache));
+
+ if (cache->c_ops->co_request_update == NULL)
+ return -NLE_OPNOTSUPP;
+
+ return cache->c_ops->co_request_update(cache, sk);
+}
+
+/** @cond SKIP */
+struct update_xdata {
+ struct nl_cache_ops *ops;
+ struct nl_parser_param *params;
+};
+
+static int update_msg_parser(struct nl_msg *msg, void *arg)
+{
+ struct update_xdata *x = arg;
+
+ return nl_cache_parse(x->ops, &msg->nm_src, msg->nm_nlh, x->params);
+}
+/** @endcond */
+
+int __cache_pickup(struct nl_sock *sk, struct nl_cache *cache,
+ struct nl_parser_param *param)
+{
+ int err;
+ struct nl_cb *cb;
+ struct update_xdata x = {
+ .ops = cache->c_ops,
+ .params = param,
+ };
+
+ NL_DBG(1, "Picking up answer for cache %p <%s>...\n",
+ cache, nl_cache_name(cache));
+
+ cb = nl_cb_clone(sk->s_cb);
+ if (cb == NULL)
+ return -NLE_NOMEM;
+
+ nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, update_msg_parser, &x);
+
+ err = nl_recvmsgs(sk, cb);
+ if (err < 0)
+ NL_DBG(2, "While picking up for %p <%s>, recvmsgs() returned " \
+ "%d: %s", cache, nl_cache_name(cache),
+ err, nl_geterror(err));
+
+ nl_cb_put(cb);
+
+ return err;
+}
+
+static int pickup_cb(struct nl_object *c, struct nl_parser_param *p)
+{
+ return nl_cache_add((struct nl_cache *) p->pp_arg, c);
+}
+
+/**
+ * Pickup a netlink dump response and put it into a cache.
+ * @arg sk Netlink socket.
+ * @arg cache Cache to put items into.
+ *
+ * Waits for netlink messages to arrive, parses them and puts them into
+ * the specified cache.
+ *
+ * @return 0 on success or a negative error code.
+ */
+int nl_cache_pickup(struct nl_sock *sk, struct nl_cache *cache)
+{
+ struct nl_parser_param p = {
+ .pp_cb = pickup_cb,
+ .pp_arg = cache,
+ };
+
+ return __cache_pickup(sk, cache, &p);
+}
+
+#ifdef disabled
+static int cache_include(struct nl_cache *cache, struct nl_object *obj,
+ struct nl_msgtype *type, change_func_t cb)
+{
+ struct nl_object *old;
+
+ switch (type->mt_act) {
+ case NL_ACT_NEW:
+ case NL_ACT_DEL:
+ old = nl_cache_search(cache, obj);
+ if (old) {
+ nl_cache_remove(old);
+ if (type->mt_act == NL_ACT_DEL) {
+ if (cb)
+ cb(cache, old, NL_ACT_DEL);
+ nl_object_put(old);
+ }
+ }
+
+ if (type->mt_act == NL_ACT_NEW) {
+ nl_cache_move(cache, obj);
+ if (old == NULL && cb)
+ cb(cache, obj, NL_ACT_NEW);
+ else if (old) {
+ if (nl_object_diff(old, obj) && cb)
+ cb(cache, obj, NL_ACT_CHANGE);
+
+ nl_object_put(old);
+ }
+ }
+ break;
+ default:
+ NL_DBG(2, "Unknown action associated to object %p\n", obj);
+ return 0;
+ }
+
+ return 0;
+}
+
+int nl_cache_include(struct nl_cache *cache, struct nl_object *obj,
+ change_func_t change_cb)
+{
+ struct nl_cache_ops *ops = cache->c_ops;
+ int i;
+
+ if (ops->co_obj_ops != obj->ce_ops)
+ return -NLE_OBJ_MISMATCH;
+
+ for (i = 0; ops->co_msgtypes[i].mt_id >= 0; i++)
+ if (ops->co_msgtypes[i].mt_id == obj->ce_msgtype)
+ return cache_include(cache, obj, &ops->co_msgtypes[i],
+ change_cb);
+
+ return -NLE_MSGTYPE_NOSUPPORT;
+}
+
+static int resync_cb(struct nl_object *c, struct nl_parser_param *p)
+{
+ struct nl_cache_assoc *ca = p->pp_arg;
+
+ return nl_cache_include(ca->ca_cache, c, ca->ca_change);
+}
+
+int nl_cache_resync(struct nl_sock *sk, struct nl_cache *cache,
+ change_func_t change_cb)
+{
+ struct nl_object *obj, *next;
+ struct nl_cache_assoc ca = {
+ .ca_cache = cache,
+ .ca_change = change_cb,
+ };
+ struct nl_parser_param p = {
+ .pp_cb = resync_cb,
+ .pp_arg = &ca,
+ };
+ int err;
+
+ NL_DBG(1, "Resyncing cache %p <%s>...\n", cache, nl_cache_name(cache));
+
+ /* Mark all objects so we can see if some of them are obsolete */
+ nl_cache_mark_all(cache);
+
+ err = nl_cache_request_full_dump(sk, cache);
+ if (err < 0)
+ goto errout;
+
+ err = __cache_pickup(sk, cache, &p);
+ if (err < 0)
+ goto errout;
+
+ nl_list_for_each_entry_safe(obj, next, &cache->c_items, ce_list)
+ if (nl_object_is_marked(obj))
+ nl_cache_remove(obj);
+
+ NL_DBG(1, "Finished resyncing %p <%s>\n", cache, nl_cache_name(cache));
+
+ err = 0;
+errout:
+ return err;
+}
+#endif
+
+/** @} */
+
+/**
+ * @name Parsing
+ * @{
+ */
+
+/** @cond SKIP */
+int nl_cache_parse(struct nl_cache_ops *ops, struct sockaddr_nl *who,
+ struct nlmsghdr *nlh, struct nl_parser_param *params)
+{
+ int i, err;
+
+ if (!nlmsg_valid_hdr(nlh, ops->co_hdrsize))
+ return -NLE_MSG_TOOSHORT;
+
+ for (i = 0; ops->co_msgtypes[i].mt_id >= 0; i++) {
+ if (ops->co_msgtypes[i].mt_id == nlh->nlmsg_type) {
+ err = ops->co_msg_parser(ops, who, nlh, params);
+ if (err != -NLE_OPNOTSUPP)
+ goto errout;
+ }
+ }
+
+
+ err = -NLE_MSGTYPE_NOSUPPORT;
+errout:
+ return err;
+}
+/** @endcond */
+
+/**
+ * Parse a netlink message and add it to the cache.
+ * @arg cache cache to add element to
+ * @arg msg netlink message
+ *
+ * Parses a netlink message by calling the cache specific message parser
+ * and adds the new element to the cache.
+ *
+ * @return 0 or a negative error code.
+ */
+int nl_cache_parse_and_add(struct nl_cache *cache, struct nl_msg *msg)
+{
+ struct nl_parser_param p = {
+ .pp_cb = pickup_cb,
+ .pp_arg = cache,
+ };
+
+ return nl_cache_parse(cache->c_ops, NULL, nlmsg_hdr(msg), &p);
+}
+
+/**
+ * (Re)fill a cache with the contents in the kernel.
+ * @arg sk Netlink socket.
+ * @arg cache cache to update
+ *
+ * Clears the specified cache and fills it with the current state in
+ * the kernel.
+ *
+ * @return 0 or a negative error code.
+ */
+int nl_cache_refill(struct nl_sock *sk, struct nl_cache *cache)
+{
+ int err;
+
+ err = nl_cache_request_full_dump(sk, cache);
+ if (err < 0)
+ return err;
+
+ NL_DBG(2, "Upading cache %p <%s>, request sent, waiting for dump...\n",
+ cache, nl_cache_name(cache));
+ nl_cache_clear(cache);
+
+ return nl_cache_pickup(sk, cache);
+}
+
+/** @} */
+#ifdef disabled
+
+/**
+ * @name Utillities
+ * @{
+ */
+
+/**
+ * Mark all objects in a cache
+ * @arg cache Cache to mark all objects in
+ */
+void nl_cache_mark_all(struct nl_cache *cache)
+{
+ struct nl_object *obj;
+
+ NL_DBG(2, "Marking all objects in cache %p <%s>...\n",
+ cache, nl_cache_name(cache));
+
+ nl_list_for_each_entry(obj, &cache->c_items, ce_list)
+ nl_object_mark(obj);
+}
+
+/** @} */
+
+/**
+ * @name Dumping
+ * @{
+ */
+/**
+ * Dump all elements of a cache.
+ * @arg cache cache to dump
+ * @arg params dumping parameters
+ *
+ * Dumps all elements of the \a cache to the file descriptor \a fd.
+ */
+void nl_cache_dump(struct nl_cache *cache, struct nl_dump_params *params)
+{
+ nl_cache_dump_filter(cache, params, NULL);
+}
+
+/**
+ * Dump all elements of a cache (filtered).
+ * @arg cache cache to dump
+ * @arg params dumping parameters (optional)
+ * @arg filter filter object
+ *
+ * Dumps all elements of the \a cache to the file descriptor \a fd
+ * given they match the given filter \a filter.
+ */
+void nl_cache_dump_filter(struct nl_cache *cache,
+ struct nl_dump_params *params,
+ struct nl_object *filter)
+{
+ int type = params ? params->dp_type : NL_DUMP_DETAILS;
+ struct nl_object_ops *ops;
+ struct nl_object *obj;
+
+ NL_DBG(2, "Dumping cache %p <%s> filter %p\n",
+ cache, nl_cache_name(cache), filter);
+
+ if (type > NL_DUMP_MAX || type < 0)
+ BUG();
+
+ if (cache->c_ops == NULL)
+ BUG();
+
+ ops = cache->c_ops->co_obj_ops;
+ if (!ops->oo_dump[type])
+ return;
+
+ nl_list_for_each_entry(obj, &cache->c_items, ce_list) {
+ if (filter && !nl_object_match_filter(obj, filter))
+ continue;
+
+ NL_DBG(4, "Dumping object %p...\n", obj);
+ dump_from_ops(obj, params);
+ }
+}
+
+/** @} */
+
+/**
+ * @name Iterators
+ * @{
+ */
+
+/**
+ * Call a callback on each element of the cache.
+ * @arg cache cache to iterate on
+ * @arg cb callback function
+ * @arg arg argument passed to callback function
+ *
+ * Calls a callback function \a cb on each element of the \a cache.
+ * The argument \a arg is passed on the callback function.
+ */
+void nl_cache_foreach(struct nl_cache *cache,
+ void (*cb)(struct nl_object *, void *), void *arg)
+{
+ nl_cache_foreach_filter(cache, NULL, cb, arg);
+}
+
+/**
+ * Call a callback on each element of the cache (filtered).
+ * @arg cache cache to iterate on
+ * @arg filter filter object
+ * @arg cb callback function
+ * @arg arg argument passed to callback function
+ *
+ * Calls a callback function \a cb on each element of the \a cache
+ * that matches the \a filter. The argument \a arg is passed on
+ * to the callback function.
+ */
+void nl_cache_foreach_filter(struct nl_cache *cache, struct nl_object *filter,
+ void (*cb)(struct nl_object *, void *), void *arg)
+{
+ struct nl_object *obj, *tmp;
+ struct nl_object_ops *ops;
+
+ if (cache->c_ops == NULL)
+ BUG();
+
+ ops = cache->c_ops->co_obj_ops;
+
+ nl_list_for_each_entry_safe(obj, tmp, &cache->c_items, ce_list) {
+ if (filter && !nl_object_match_filter(obj, filter))
+ continue;
+
+ cb(obj, arg);
+ }
+}
+
+/** @} */
+#endif
+
+/** @} */
diff --git a/package/libs/libnl-tiny/src/.svn/text-base/cache_mngt.c.svn-base b/package/libs/libnl-tiny/src/.svn/text-base/cache_mngt.c.svn-base
new file mode 100644
index 0000000..5c32d2a
--- /dev/null
+++ b/package/libs/libnl-tiny/src/.svn/text-base/cache_mngt.c.svn-base
@@ -0,0 +1,253 @@
+/*
+ * lib/cache_mngt.c Cache Management
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
+ */
+
+/**
+ * @ingroup core
+ * @defgroup cache_mngt Caching
+ * @{
+ */
+
+#include <netlink-local.h>
+#include <netlink/netlink.h>
+#include <netlink/cache.h>
+#include <netlink/utils.h>
+
+static struct nl_cache_ops *cache_ops;
+
+/**
+ * @name Cache Operations Sets
+ * @{
+ */
+
+/**
+ * Lookup the set cache operations of a certain cache type
+ * @arg name name of the cache type
+ *
+ * @return The cache operations or NULL if no operations
+ * have been registered under the specified name.
+ */
+struct nl_cache_ops *nl_cache_ops_lookup(const char *name)
+{
+ struct nl_cache_ops *ops;
+
+ for (ops = cache_ops; ops; ops = ops->co_next)
+ if (!strcmp(ops->co_name, name))
+ return ops;
+
+ return NULL;
+}
+
+/**
+ * Associate a message type to a set of cache operations
+ * @arg protocol netlink protocol
+ * @arg msgtype netlink message type
+ *
+ * Associates the specified netlink message type with
+ * a registered set of cache operations.
+ *
+ * @return The cache operations or NULL if no association
+ * could be made.
+ */
+struct nl_cache_ops *nl_cache_ops_associate(int protocol, int msgtype)
+{
+ int i;
+ struct nl_cache_ops *ops;
+
+ for (ops = cache_ops; ops; ops = ops->co_next) {
+ if (ops->co_protocol != protocol)
+ continue;
+
+ for (i = 0; ops->co_msgtypes[i].mt_id >= 0; i++)
+ if (ops->co_msgtypes[i].mt_id == msgtype)
+ return ops;
+ }
+
+ return NULL;
+}
+
+#ifdef disabled
+
+/**
+ * Lookup message type cache association
+ * @arg ops cache operations
+ * @arg msgtype netlink message type
+ *
+ * Searches for a matching message type association ing the specified
+ * cache operations.
+ *
+ * @return A message type association or NULL.
+ */
+struct nl_msgtype *nl_msgtype_lookup(struct nl_cache_ops *ops, int msgtype)
+{
+ int i;
+
+ for (i = 0; ops->co_msgtypes[i].mt_id >= 0; i++)
+ if (ops->co_msgtypes[i].mt_id == msgtype)
+ return &ops->co_msgtypes[i];
+
+ return NULL;
+}
+
+static struct nl_cache_ops *cache_ops_lookup_for_obj(struct nl_object_ops *obj_ops)
+{
+ struct nl_cache_ops *ops;
+
+ for (ops = cache_ops; ops; ops = ops->co_next)
+ if (ops->co_obj_ops == obj_ops)
+ return ops;
+
+ return NULL;
+
+}
+
+/**
+ * Call a function for each registered cache operation
+ * @arg cb Callback function to be called
+ * @arg arg User specific argument.
+ */
+void nl_cache_ops_foreach(void (*cb)(struct nl_cache_ops *, void *), void *arg)
+{
+ struct nl_cache_ops *ops;
+
+ for (ops = cache_ops; ops; ops = ops->co_next)
+ cb(ops, arg);
+}
+#endif
+
+/**
+ * Register a set of cache operations
+ * @arg ops cache operations
+ *
+ * Called by users of caches to announce the avaibility of
+ * a certain cache type.
+ *
+ * @return 0 on success or a negative error code.
+ */
+int nl_cache_mngt_register(struct nl_cache_ops *ops)
+{
+ if (!ops->co_name || !ops->co_obj_ops)
+ return -NLE_INVAL;
+
+ if (nl_cache_ops_lookup(ops->co_name))
+ return -NLE_EXIST;
+
+ ops->co_next = cache_ops;
+ cache_ops = ops;
+
+ NL_DBG(1, "Registered cache operations %s\n", ops->co_name);
+
+ return 0;
+}
+
+/**
+ * Unregister a set of cache operations
+ * @arg ops cache operations
+ *
+ * Called by users of caches to announce a set of
+ * cache operations is no longer available. The
+ * specified cache operations must have been registered
+ * previously using nl_cache_mngt_register()
+ *
+ * @return 0 on success or a negative error code
+ */
+int nl_cache_mngt_unregister(struct nl_cache_ops *ops)
+{
+ struct nl_cache_ops *t, **tp;
+
+ for (tp = &cache_ops; (t=*tp) != NULL; tp = &t->co_next)
+ if (t == ops)
+ break;
+
+ if (!t)
+ return -NLE_NOCACHE;
+
+ NL_DBG(1, "Unregistered cache operations %s\n", ops->co_name);
+
+ *tp = t->co_next;
+ return 0;
+}
+
+/** @} */
+
+/**
+ * @name Global Cache Provisioning/Requiring
+ * @{
+ */
+#ifdef disabled
+/**
+ * Provide a cache for global use
+ * @arg cache cache to provide
+ *
+ * Offers the specified cache to be used by other modules.
+ * Only one cache per type may be shared at a time,
+ * a previsouly provided caches will be overwritten.
+ */
+void nl_cache_mngt_provide(struct nl_cache *cache)
+{
+ struct nl_cache_ops *ops;
+
+ ops = cache_ops_lookup_for_obj(cache->c_ops->co_obj_ops);
+ if (!ops)
+ BUG();
+ else
+ ops->co_major_cache = cache;
+}
+
+/**
+ * Unprovide a cache for global use
+ * @arg cache cache to unprovide
+ *
+ * Cancels the offer to use a cache globally. The
+ * cache will no longer be returned via lookups but
+ * may still be in use.
+ */
+void nl_cache_mngt_unprovide(struct nl_cache *cache)
+{
+ struct nl_cache_ops *ops;
+
+ ops = cache_ops_lookup_for_obj(cache->c_ops->co_obj_ops);
+ if (!ops)
+ BUG();
+ else if (ops->co_major_cache == cache)
+ ops->co_major_cache = NULL;
+}
+
+/**
+ * Demand the use of a global cache
+ * @arg name name of the required object type
+ *
+ * Trys to find a cache of the specified type for global
+ * use.
+ *
+ * @return A cache provided by another subsystem of the
+ * specified type marked to be available.
+ */
+struct nl_cache *nl_cache_mngt_require(const char *name)
+{
+ struct nl_cache_ops *ops;
+
+ ops = nl_cache_ops_lookup(name);
+ if (!ops || !ops->co_major_cache) {
+ fprintf(stderr, "Application BUG: Your application must "
+ "call nl_cache_mngt_provide() and\nprovide a valid "
+ "%s cache to be used for internal lookups.\nSee the "
+ " API documentation for more details.\n", name);
+
+ return NULL;
+ }
+
+ return ops->co_major_cache;
+}
+
+#endif
+/** @} */
+
+/** @} */
diff --git a/package/libs/libnl-tiny/src/.svn/text-base/error.c.svn-base b/package/libs/libnl-tiny/src/.svn/text-base/error.c.svn-base
new file mode 100644
index 0000000..71ae722
--- /dev/null
+++ b/package/libs/libnl-tiny/src/.svn/text-base/error.c.svn-base
@@ -0,0 +1,108 @@
+/*
+ * lib/error.c Error Handling
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2008 Thomas Graf <tgraf@suug.ch>
+ */
+
+#include <netlink-local.h>
+#include <netlink/netlink.h>
+
+static const char *errmsg[NLE_MAX+1] = {
+[NLE_SUCCESS] = "Success",
+[NLE_FAILURE] = "Unspecific failure",
+[NLE_INTR] = "Interrupted system call",
+[NLE_BAD_SOCK] = "Bad socket",
+[NLE_AGAIN] = "Try again",
+[NLE_NOMEM] = "Out of memory",
+[NLE_EXIST] = "Object exists",
+[NLE_INVAL] = "Invalid input data or parameter",
+[NLE_RANGE] = "Input data out of range",
+[NLE_MSGSIZE] = "Message size not sufficient",
+[NLE_OPNOTSUPP] = "Operation not supported",
+[NLE_AF_NOSUPPORT] = "Address family not supported",
+[NLE_OBJ_NOTFOUND] = "Object not found",
+[NLE_NOATTR] = "Attribute not available",
+[NLE_MISSING_ATTR] = "Missing attribute",
+[NLE_AF_MISMATCH] = "Address family mismatch",
+[NLE_SEQ_MISMATCH] = "Message sequence number mismatch",
+[NLE_MSG_OVERFLOW] = "Kernel reported message overflow",
+[NLE_MSG_TRUNC] = "Kernel reported truncated message",
+[NLE_NOADDR] = "Invalid address for specified address family",
+[NLE_SRCRT_NOSUPPORT] = "Source based routing not supported",
+[NLE_MSG_TOOSHORT] = "Netlink message is too short",
+[NLE_MSGTYPE_NOSUPPORT] = "Netlink message type is not supported",
+[NLE_OBJ_MISMATCH] = "Object type does not match cache",
+[NLE_NOCACHE] = "Unknown or invalid cache type",
+[NLE_BUSY] = "Object busy",
+[NLE_PROTO_MISMATCH] = "Protocol mismatch",
+[NLE_NOACCESS] = "No Access",
+[NLE_PERM] = "Operation not permitted",
+};
+
+/**
+ * Return error message for an error code
+ * @return error message
+ */
+const char *nl_geterror(int error)
+{
+ error = abs(error);
+
+ if (error > NLE_MAX)
+ error = NLE_FAILURE;
+
+ return errmsg[error];
+}
+
+/**
+ * Print a libnl error message
+ * @arg s error message prefix
+ *
+ * Prints the error message of the call that failed last.
+ *
+ * If s is not NULL and *s is not a null byte the argument
+ * string is printed, followed by a colon and a blank. Then
+ * the error message and a new-line.
+ */
+void nl_perror(int error, const char *s)
+{
+ if (s && *s)
+ fprintf(stderr, "%s: %s\n", s, nl_geterror(error));
+ else
+ fprintf(stderr, "%s\n", nl_geterror(error));
+}
+
+int nl_syserr2nlerr(int error)
+{
+ error = abs(error);
+
+ switch (error) {
+ case EBADF: return NLE_BAD_SOCK;
+ case EADDRINUSE: return NLE_EXIST;
+ case EEXIST: return NLE_EXIST;
+ case EADDRNOTAVAIL: return NLE_NOADDR;
+ case ENOENT: return NLE_OBJ_NOTFOUND;
+ case EINTR: return NLE_INTR;
+ case EAGAIN: return NLE_AGAIN;
+ case ENOTSOCK: return NLE_BAD_SOCK;
+ case ENOPROTOOPT: return NLE_INVAL;
+ case EFAULT: return NLE_INVAL;
+ case EACCES: return NLE_NOACCESS;
+ case EINVAL: return NLE_INVAL;
+ case ENOBUFS: return NLE_NOMEM;
+ case ENOMEM: return NLE_NOMEM;
+ case EAFNOSUPPORT: return NLE_AF_NOSUPPORT;
+ case EPROTONOSUPPORT: return NLE_PROTO_MISMATCH;
+ case EOPNOTSUPP: return NLE_OPNOTSUPP;
+ case EPERM: return NLE_PERM;
+ case EBUSY: return NLE_BUSY;
+ default: return NLE_FAILURE;
+ }
+}
+
+/** @} */
+
diff --git a/package/libs/libnl-tiny/src/.svn/text-base/genl.c.svn-base b/package/libs/libnl-tiny/src/.svn/text-base/genl.c.svn-base
new file mode 100644
index 0000000..055be91
--- /dev/null
+++ b/package/libs/libnl-tiny/src/.svn/text-base/genl.c.svn-base
@@ -0,0 +1,268 @@
+/*
+ * lib/genl/genl.c Generic Netlink
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
+ */
+
+/**
+ * @defgroup genl Generic Netlink
+ *
+ * @par Message Format
+ * @code
+ * <------- NLMSG_ALIGN(hlen) ------> <---- NLMSG_ALIGN(len) --->
+ * +----------------------------+- - -+- - - - - - - - - - -+- - -+
+ * | Header | Pad | Payload | Pad |
+ * | struct nlmsghdr | | | |
+ * +----------------------------+- - -+- - - - - - - - - - -+- - -+
+ * @endcode
+ * @code
+ * <-------- GENL_HDRLEN -------> <--- hdrlen -->
+ * <------- genlmsg_len(ghdr) ------>
+ * +------------------------+- - -+---------------+- - -+------------+
+ * | Generic Netlink Header | Pad | Family Header | Pad | Attributes |
+ * | struct genlmsghdr | | | | |
+ * +------------------------+- - -+---------------+- - -+------------+
+ * genlmsg_data(ghdr)--------------^ ^
+ * genlmsg_attrdata(ghdr, hdrlen)-------------------------
+ * @endcode
+ *
+ * @par Example
+ * @code
+ * #include <netlink/netlink.h>
+ * #include <netlink/genl/genl.h>
+ * #include <netlink/genl/ctrl.h>
+ *
+ * struct nl_sock *sock;
+ * struct nl_msg *msg;
+ * int family;
+ *
+ * // Allocate a new netlink socket
+ * sock = nl_socket_alloc();
+ *
+ * // Connect to generic netlink socket on kernel side
+ * genl_connect(sock);
+ *
+ * // Ask kernel to resolve family name to family id
+ * family = genl_ctrl_resolve(sock, "generic_netlink_family_name");
+ *
+ * // Construct a generic netlink by allocating a new message, fill in
+ * // the header and append a simple integer attribute.
+ * msg = nlmsg_alloc();
+ * genlmsg_put(msg, NL_AUTO_PID, NL_AUTO_SEQ, family, 0, NLM_F_ECHO,
+ * CMD_FOO_GET, FOO_VERSION);
+ * nla_put_u32(msg, ATTR_FOO, 123);
+ *
+ * // Send message over netlink socket
+ * nl_send_auto_complete(sock, msg);
+ *
+ * // Free message
+ * nlmsg_free(msg);
+ *
+ * // Prepare socket to receive the answer by specifying the callback
+ * // function to be called for valid messages.
+ * nl_socket_modify_cb(sock, NL_CB_VALID, NL_CB_CUSTOM, parse_cb, NULL);
+ *
+ * // Wait for the answer and receive it
+ * nl_recvmsgs_default(sock);
+ *
+ * static int parse_cb(struct nl_msg *msg, void *arg)
+ * {
+ * struct nlmsghdr *nlh = nlmsg_hdr(msg);
+ * struct nlattr *attrs[ATTR_MAX+1];
+ *
+ * // Validate message and parse attributes
+ * genlmsg_parse(nlh, 0, attrs, ATTR_MAX, policy);
+ *
+ * if (attrs[ATTR_FOO]) {
+ * uint32_t value = nla_get_u32(attrs[ATTR_FOO]);
+ * ...
+ * }
+ *
+ * return 0;
+ * }
+ * @endcode
+ * @{
+ */
+
+#include <netlink-generic.h>
+#include <netlink/netlink.h>
+#include <netlink/genl/genl.h>
+#include <netlink/utils.h>
+
+/**
+ * @name Socket Creating
+ * @{
+ */
+
+int genl_connect(struct nl_sock *sk)
+{
+ return nl_connect(sk, NETLINK_GENERIC);
+}
+
+/** @} */
+
+/**
+ * @name Sending
+ * @{
+ */
+
+/**
+ * Send trivial generic netlink message
+ * @arg sk Netlink socket.
+ * @arg family Generic netlink family
+ * @arg cmd Command
+ * @arg version Version
+ * @arg flags Additional netlink message flags.
+ *
+ * Fills out a routing netlink request message and sends it out
+ * using nl_send_simple().
+ *
+ * @return 0 on success or a negative error code.
+ */
+int genl_send_simple(struct nl_sock *sk, int family, int cmd,
+ int version, int flags)
+{
+ struct genlmsghdr hdr = {
+ .cmd = cmd,
+ .version = version,
+ };
+
+ return nl_send_simple(sk, family, flags, &hdr, sizeof(hdr));
+}
+
+/** @} */
+
+
+/**
+ * @name Message Parsing
+ * @{
+ */
+
+int genlmsg_valid_hdr(struct nlmsghdr *nlh, int hdrlen)
+{
+ struct genlmsghdr *ghdr;
+
+ if (!nlmsg_valid_hdr(nlh, GENL_HDRLEN))
+ return 0;
+
+ ghdr = nlmsg_data(nlh);
+ if (genlmsg_len(ghdr) < NLMSG_ALIGN(hdrlen))
+ return 0;
+
+ return 1;
+}
+
+int genlmsg_validate(struct nlmsghdr *nlh, int hdrlen, int maxtype,
+ struct nla_policy *policy)
+{
+ struct genlmsghdr *ghdr;
+
+ if (!genlmsg_valid_hdr(nlh, hdrlen))
+ return -NLE_MSG_TOOSHORT;
+
+ ghdr = nlmsg_data(nlh);
+ return nla_validate(genlmsg_attrdata(ghdr, hdrlen),
+ genlmsg_attrlen(ghdr, hdrlen), maxtype, policy);
+}
+
+int genlmsg_parse(struct nlmsghdr *nlh, int hdrlen, struct nlattr *tb[],
+ int maxtype, struct nla_policy *policy)
+{
+ struct genlmsghdr *ghdr;
+
+ if (!genlmsg_valid_hdr(nlh, hdrlen))
+ return -NLE_MSG_TOOSHORT;
+
+ ghdr = nlmsg_data(nlh);
+ return nla_parse(tb, maxtype, genlmsg_attrdata(ghdr, hdrlen),
+ genlmsg_attrlen(ghdr, hdrlen), policy);
+}
+
+/**
+ * Get head of message payload
+ * @arg gnlh genetlink messsage header
+ */
+void *genlmsg_data(const struct genlmsghdr *gnlh)
+{
+ return ((unsigned char *) gnlh + GENL_HDRLEN);
+}
+
+/**
+ * Get lenght of message payload
+ * @arg gnlh genetlink message header
+ */
+int genlmsg_len(const struct genlmsghdr *gnlh)
+{
+ struct nlmsghdr *nlh = (struct nlmsghdr *)((unsigned char *)gnlh -
+ NLMSG_HDRLEN);
+ return (nlh->nlmsg_len - GENL_HDRLEN - NLMSG_HDRLEN);
+}
+
+/**
+ * Get head of attribute data
+ * @arg gnlh generic netlink message header
+ * @arg hdrlen length of family specific header
+ */
+struct nlattr *genlmsg_attrdata(const struct genlmsghdr *gnlh, int hdrlen)
+{
+ return genlmsg_data(gnlh) + NLMSG_ALIGN(hdrlen);
+}
+
+/**
+ * Get length of attribute data
+ * @arg gnlh generic netlink message header
+ * @arg hdrlen length of family specific header
+ */
+int genlmsg_attrlen(const struct genlmsghdr *gnlh, int hdrlen)
+{
+ return genlmsg_len(gnlh) - NLMSG_ALIGN(hdrlen);
+}
+
+/** @} */
+
+/**
+ * @name Message Building
+ * @{
+ */
+
+/**
+ * Add generic netlink header to netlink message
+ * @arg msg netlink message
+ * @arg pid netlink process id or NL_AUTO_PID
+ * @arg seq sequence number of message or NL_AUTO_SEQ
+ * @arg family generic netlink family
+ * @arg hdrlen length of user specific header
+ * @arg flags message flags
+ * @arg cmd generic netlink command
+ * @arg version protocol version
+ *
+ * Returns pointer to user specific header.
+ */
+void *genlmsg_put(struct nl_msg *msg, uint32_t pid, uint32_t seq, int family,
+ int hdrlen, int flags, uint8_t cmd, uint8_t version)
+{
+ struct nlmsghdr *nlh;
+ struct genlmsghdr hdr = {
+ .cmd = cmd,
+ .version = version,
+ };
+
+ nlh = nlmsg_put(msg, pid, seq, family, GENL_HDRLEN + hdrlen, flags);
+ if (nlh == NULL)
+ return NULL;
+
+ memcpy(nlmsg_data(nlh), &hdr, sizeof(hdr));
+ NL_DBG(2, "msg %p: Added generic netlink header cmd=%d version=%d\n",
+ msg, cmd, version);
+
+ return nlmsg_data(nlh) + GENL_HDRLEN;
+}
+
+/** @} */
+
+/** @} */
diff --git a/package/libs/libnl-tiny/src/.svn/text-base/genl_ctrl.c.svn-base b/package/libs/libnl-tiny/src/.svn/text-base/genl_ctrl.c.svn-base
new file mode 100644
index 0000000..1301642
--- /dev/null
+++ b/package/libs/libnl-tiny/src/.svn/text-base/genl_ctrl.c.svn-base
@@ -0,0 +1,302 @@
+/*
+ * lib/genl/ctrl.c Generic Netlink Controller
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
+ */
+
+/**
+ * @ingroup genl_mngt
+ * @defgroup ctrl Controller
+ * @brief
+ *
+ * @{
+ */
+
+#include <netlink-generic.h>
+#include <netlink/netlink.h>
+#include <netlink/genl/genl.h>
+#include <netlink/genl/family.h>
+#include <netlink/genl/mngt.h>
+#include <netlink/genl/ctrl.h>
+#include <netlink/utils.h>
+
+/** @cond SKIP */
+#define CTRL_VERSION 0x0001
+
+static struct nl_cache_ops genl_ctrl_ops;
+/** @endcond */
+
+static int ctrl_request_update(struct nl_cache *c, struct nl_sock *h)
+{
+ return genl_send_simple(h, GENL_ID_CTRL, CTRL_CMD_GETFAMILY,
+ CTRL_VERSION, NLM_F_DUMP);
+}
+
+static struct nla_policy ctrl_policy[CTRL_ATTR_MAX+1] = {
+ [CTRL_ATTR_FAMILY_ID] = { .type = NLA_U16 },
+ [CTRL_ATTR_FAMILY_NAME] = { .type = NLA_STRING,
+ .maxlen = GENL_NAMSIZ },
+ [CTRL_ATTR_VERSION] = { .type = NLA_U32 },
+ [CTRL_ATTR_HDRSIZE] = { .type = NLA_U32 },
+ [CTRL_ATTR_MAXATTR] = { .type = NLA_U32 },
+ [CTRL_ATTR_OPS] = { .type = NLA_NESTED },
+};
+
+static struct nla_policy family_op_policy[CTRL_ATTR_OP_MAX+1] = {
+ [CTRL_ATTR_OP_ID] = { .type = NLA_U32 },
+ [CTRL_ATTR_OP_FLAGS] = { .type = NLA_U32 },
+};
+
+static int ctrl_msg_parser(struct nl_cache_ops *ops, struct genl_cmd *cmd,
+ struct genl_info *info, void *arg)
+{
+ struct genl_family *family;
+ struct nl_parser_param *pp = arg;
+ int err;
+
+ family = genl_family_alloc();
+ if (family == NULL) {
+ err = -NLE_NOMEM;
+ goto errout;
+ }
+
+ if (info->attrs[CTRL_ATTR_FAMILY_NAME] == NULL) {
+ err = -NLE_MISSING_ATTR;
+ goto errout;
+ }
+
+ if (info->attrs[CTRL_ATTR_FAMILY_ID] == NULL) {
+ err = -NLE_MISSING_ATTR;
+ goto errout;
+ }
+
+ family->ce_msgtype = info->nlh->nlmsg_type;
+ genl_family_set_id(family,
+ nla_get_u16(info->attrs[CTRL_ATTR_FAMILY_ID]));
+ genl_family_set_name(family,
+ nla_get_string(info->attrs[CTRL_ATTR_FAMILY_NAME]));
+
+ if (info->attrs[CTRL_ATTR_VERSION]) {
+ uint32_t version = nla_get_u32(info->attrs[CTRL_ATTR_VERSION]);
+ genl_family_set_version(family, version);
+ }
+
+ if (info->attrs[CTRL_ATTR_HDRSIZE]) {
+ uint32_t hdrsize = nla_get_u32(info->attrs[CTRL_ATTR_HDRSIZE]);
+ genl_family_set_hdrsize(family, hdrsize);
+ }
+
+ if (info->attrs[CTRL_ATTR_MAXATTR]) {
+ uint32_t maxattr = nla_get_u32(info->attrs[CTRL_ATTR_MAXATTR]);
+ genl_family_set_maxattr(family, maxattr);
+ }
+
+ if (info->attrs[CTRL_ATTR_OPS]) {
+ struct nlattr *nla, *nla_ops;
+ int remaining;
+
+ nla_ops = info->attrs[CTRL_ATTR_OPS];
+ nla_for_each_nested(nla, nla_ops, remaining) {
+ struct nlattr *tb[CTRL_ATTR_OP_MAX+1];
+ int flags = 0, id;
+
+ err = nla_parse_nested(tb, CTRL_ATTR_OP_MAX, nla,
+ family_op_policy);
+ if (err < 0)
+ goto errout;
+
+ if (tb[CTRL_ATTR_OP_ID] == NULL) {
+ err = -NLE_MISSING_ATTR;
+ goto errout;
+ }
+
+ id = nla_get_u32(tb[CTRL_ATTR_OP_ID]);
+
+ if (tb[CTRL_ATTR_OP_FLAGS])
+ flags = nla_get_u32(tb[CTRL_ATTR_OP_FLAGS]);
+
+ err = genl_family_add_op(family, id, flags);
+ if (err < 0)
+ goto errout;
+
+ }
+ }
+
+ err = pp->pp_cb((struct nl_object *) family, pp);
+errout:
+ genl_family_put(family);
+ return err;
+}
+
+/**
+ * @name Cache Management
+ * @{
+ */
+
+int genl_ctrl_alloc_cache(struct nl_sock *sock, struct nl_cache **result)
+{
+ return nl_cache_alloc_and_fill(&genl_ctrl_ops, sock, result);
+}
+
+/**
+ * Look up generic netlink family by id in the provided cache.
+ * @arg cache Generic netlink family cache.
+ * @arg id Family identifier.
+ *
+ * Searches through the cache looking for a registered family
+ * matching the specified identifier. The caller will own a
+ * reference on the returned object which needs to be given
+ * back after usage using genl_family_put().
+ *
+ * @return Generic netlink family object or NULL if no match was found.
+ */
+struct genl_family *genl_ctrl_search(struct nl_cache *cache, int id)
+{
+ struct genl_family *fam;
+
+ if (cache->c_ops != &genl_ctrl_ops)
+ BUG();
+
+ nl_list_for_each_entry(fam, &cache->c_items, ce_list) {
+ if (fam->gf_id == id) {
+ nl_object_get((struct nl_object *) fam);
+ return fam;
+ }
+ }
+
+ return NULL;
+}
+
+/**
+ * @name Resolver
+ * @{
+ */
+
+/**
+ * Look up generic netlink family by family name in the provided cache.
+ * @arg cache Generic netlink family cache.
+ * @arg name Family name.
+ *
+ * Searches through the cache looking for a registered family
+ * matching the specified name. The caller will own a reference
+ * on the returned object which needs to be given back after
+ * usage using genl_family_put().
+ *
+ * @return Generic netlink family object or NULL if no match was found.
+ */
+struct genl_family *genl_ctrl_search_by_name(struct nl_cache *cache,
+ const char *name)
+{
+ struct genl_family *fam;
+
+ if (cache->c_ops != &genl_ctrl_ops)
+ BUG();
+
+ nl_list_for_each_entry(fam, &cache->c_items, ce_list) {
+ if (!strcmp(name, fam->gf_name)) {
+ nl_object_get((struct nl_object *) fam);
+ return fam;
+ }
+ }
+
+ return NULL;
+}
+
+/** @} */
+
+/**
+ * Resolve generic netlink family name to its identifier
+ * @arg sk Netlink socket.
+ * @arg name Name of generic netlink family
+ *
+ * Resolves the generic netlink family name to its identifer and returns
+ * it.
+ *
+ * @return A positive identifier or a negative error code.
+ */
+int genl_ctrl_resolve(struct nl_sock *sk, const char *name)
+{
+ struct nl_cache *cache;
+ struct genl_family *family;
+ int err;
+
+ if ((err = genl_ctrl_alloc_cache(sk, &cache)) < 0)
+ return err;
+
+ family = genl_ctrl_search_by_name(cache, name);
+ if (family == NULL) {
+ err = -NLE_OBJ_NOTFOUND;
+ goto errout;
+ }
+
+ err = genl_family_get_id(family);
+ genl_family_put(family);
+errout:
+ nl_cache_free(cache);
+
+ return err;
+}
+
+/** @} */
+
+static struct genl_cmd genl_cmds[] = {
+ {
+ .c_id = CTRL_CMD_NEWFAMILY,
+ .c_name = "NEWFAMILY" ,
+ .c_maxattr = CTRL_ATTR_MAX,
+ .c_attr_policy = ctrl_policy,
+ .c_msg_parser = ctrl_msg_parser,
+ },
+ {
+ .c_id = CTRL_CMD_DELFAMILY,
+ .c_name = "DELFAMILY" ,
+ },
+ {
+ .c_id = CTRL_CMD_GETFAMILY,
+ .c_name = "GETFAMILY" ,
+ },
+ {
+ .c_id = CTRL_CMD_NEWOPS,
+ .c_name = "NEWOPS" ,
+ },
+ {
+ .c_id = CTRL_CMD_DELOPS,
+ .c_name = "DELOPS" ,
+ },
+};
+
+static struct genl_ops genl_ops = {
+ .o_cmds = genl_cmds,
+ .o_ncmds = ARRAY_SIZE(genl_cmds),
+};
+
+/** @cond SKIP */
+extern struct nl_object_ops genl_family_ops;
+/** @endcond */
+
+static struct nl_cache_ops genl_ctrl_ops = {
+ .co_name = "genl/family",
+ .co_hdrsize = GENL_HDRSIZE(0),
+ .co_msgtypes = GENL_FAMILY(GENL_ID_CTRL, "nlctrl"),
+ .co_genl = &genl_ops,
+ .co_protocol = NETLINK_GENERIC,
+ .co_request_update = ctrl_request_update,
+ .co_obj_ops = &genl_family_ops,
+};
+
+static void __init ctrl_init(void)
+{
+ genl_register(&genl_ctrl_ops);
+}
+
+static void __exit ctrl_exit(void)
+{
+ genl_unregister(&genl_ctrl_ops);
+}
+
+/** @} */
diff --git a/package/libs/libnl-tiny/src/.svn/text-base/genl_family.c.svn-base b/package/libs/libnl-tiny/src/.svn/text-base/genl_family.c.svn-base
new file mode 100644
index 0000000..88aaad9
--- /dev/null
+++ b/package/libs/libnl-tiny/src/.svn/text-base/genl_family.c.svn-base
@@ -0,0 +1,136 @@
+/*
+ * lib/genl/family.c Generic Netlink Family
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
+ */
+
+/**
+ * @ingroup genl
+ * @defgroup genl_family Generic Netlink Family
+ * @brief
+ *
+ * @{
+ */
+
+#include <netlink-generic.h>
+#include <netlink/netlink.h>
+#include <netlink/genl/genl.h>
+#include <netlink/genl/family.h>
+#include <netlink/utils.h>
+
+struct nl_object_ops genl_family_ops;
+/** @endcond */
+
+static void family_constructor(struct nl_object *c)
+{
+ struct genl_family *family = (struct genl_family *) c;
+
+ nl_init_list_head(&family->gf_ops);
+}
+
+static void family_free_data(struct nl_object *c)
+{
+ struct genl_family *family = (struct genl_family *) c;
+ struct genl_family_op *ops, *tmp;
+
+ if (family == NULL)
+ return;
+
+ nl_list_for_each_entry_safe(ops, tmp, &family->gf_ops, o_list) {
+ nl_list_del(&ops->o_list);
+ free(ops);
+ }
+}
+
+static int family_clone(struct nl_object *_dst, struct nl_object *_src)
+{
+ struct genl_family *dst = nl_object_priv(_dst);
+ struct genl_family *src = nl_object_priv(_src);
+ struct genl_family_op *ops;
+ int err;
+
+ nl_list_for_each_entry(ops, &src->gf_ops, o_list) {
+ err = genl_family_add_op(dst, ops->o_id, ops->o_flags);
+ if (err < 0)
+ return err;
+ }
+
+ return 0;
+}
+
+static int family_compare(struct nl_object *_a, struct nl_object *_b,
+ uint32_t attrs, int flags)
+{
+ struct genl_family *a = (struct genl_family *) _a;
+ struct genl_family *b = (struct genl_family *) _b;
+ int diff = 0;
+
+#define FAM_DIFF(ATTR, EXPR) ATTR_DIFF(attrs, FAMILY_ATTR_##ATTR, a, b, EXPR)
+
+ diff |= FAM_DIFF(ID, a->gf_id != b->gf_id);
+ diff |= FAM_DIFF(VERSION, a->gf_version != b->gf_version);
+ diff |= FAM_DIFF(HDRSIZE, a->gf_hdrsize != b->gf_hdrsize);
+ diff |= FAM_DIFF(MAXATTR, a->gf_maxattr != b->gf_maxattr);
+ diff |= FAM_DIFF(NAME, strcmp(a->gf_name, b->gf_name));
+
+#undef FAM_DIFF
+
+ return diff;
+}
+
+
+/**
+ * @name Family Object
+ * @{
+ */
+
+struct genl_family *genl_family_alloc(void)
+{
+ return (struct genl_family *) nl_object_alloc(&genl_family_ops);
+}
+
+void genl_family_put(struct genl_family *family)
+{
+ nl_object_put((struct nl_object *) family);
+}
+
+/** @} */
+
+
+int genl_family_add_op(struct genl_family *family, int id, int flags)
+{
+ struct genl_family_op *op;
+
+ op = calloc(1, sizeof(*op));
+ if (op == NULL)
+ return -NLE_NOMEM;
+
+ op->o_id = id;
+ op->o_flags = flags;
+
+ nl_list_add_tail(&op->o_list, &family->gf_ops);
+ family->ce_mask |= FAMILY_ATTR_OPS;
+
+ return 0;
+}
+
+/** @} */
+
+/** @cond SKIP */
+struct nl_object_ops genl_family_ops = {
+ .oo_name = "genl/family",
+ .oo_size = sizeof(struct genl_family),
+ .oo_constructor = family_constructor,
+ .oo_free_data = family_free_data,
+ .oo_clone = family_clone,
+ .oo_compare = family_compare,
+ .oo_id_attrs = FAMILY_ATTR_ID,
+};
+/** @endcond */
+
+/** @} */
diff --git a/package/libs/libnl-tiny/src/.svn/text-base/genl_mngt.c.svn-base b/package/libs/libnl-tiny/src/.svn/text-base/genl_mngt.c.svn-base
new file mode 100644
index 0000000..6c65179
--- /dev/null
+++ b/package/libs/libnl-tiny/src/.svn/text-base/genl_mngt.c.svn-base
@@ -0,0 +1,274 @@
+/*
+ * lib/genl/mngt.c Generic Netlink Management
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
+ */
+
+/**
+ * @ingroup genl
+ * @defgroup genl_mngt Management
+ *
+ * @par 1) Registering a generic netlink module
+ * @code
+ * #include <netlink/genl/mngt.h>
+ *
+ * // First step is to define all the commands being used in
+ * // particular generic netlink family. The ID and name are
+ * // mandatory to be filled out. A callback function and
+ * // most the attribute policy that comes with it must be
+ * // defined for commands expected to be issued towards
+ * // userspace.
+ * static struct genl_cmd foo_cmds[] = {
+ * {
+ * .c_id = FOO_CMD_NEW,
+ * .c_name = "NEWFOO" ,
+ * .c_maxattr = FOO_ATTR_MAX,
+ * .c_attr_policy = foo_policy,
+ * .c_msg_parser = foo_msg_parser,
+ * },
+ * {
+ * .c_id = FOO_CMD_DEL,
+ * .c_name = "DELFOO" ,
+ * },
+ * };
+ *
+ * // The list of commands must then be integrated into a
+ * // struct genl_ops serving as handle for this particular
+ * // family.
+ * static struct genl_ops my_genl_ops = {
+ * .o_cmds = foo_cmds,
+ * .o_ncmds = ARRAY_SIZE(foo_cmds),
+ * };
+ *
+ * // Using the above struct genl_ops an arbitary number of
+ * // cache handles can be associated to it.
+ * //
+ * // The macro GENL_HDRSIZE() must be used to specify the
+ * // length of the header to automatically take headers on
+ * // generic layers into account.
+ * //
+ * // The macro GENL_FAMILY() is used to represent the generic
+ * // netlink family id.
+ * static struct nl_cache_ops genl_foo_ops = {
+ * .co_name = "genl/foo",
+ * .co_hdrsize = GENL_HDRSIZE(sizeof(struct my_hdr)),
+ * .co_msgtypes = GENL_FAMILY(GENL_ID_GENERATE, "foo"),
+ * .co_genl = &my_genl_ops,
+ * .co_protocol = NETLINK_GENERIC,
+ * .co_request_update = foo_request_update,
+ * .co_obj_ops = &genl_foo_ops,
+ * };
+ *
+ * // Finally each cache handle for a generic netlink family
+ * // must be registered using genl_register().
+ * static void __init foo_init(void)
+ * {
+ * genl_register(&genl_foo_ops);
+ * }
+ *
+ * // ... respectively unregsted again.
+ * static void __exit foo_exit(void)
+ * {
+ * genl_unregister(&genl_foo_ops);
+ * }
+ * @endcode
+ * @{
+ */
+
+#include <netlink-generic.h>
+#include <netlink/netlink.h>
+#include <netlink/genl/genl.h>
+#include <netlink/genl/mngt.h>
+#include <netlink/genl/family.h>
+#include <netlink/genl/ctrl.h>
+#include <netlink/utils.h>
+
+static NL_LIST_HEAD(genl_ops_list);
+
+static int genl_msg_parser(struct nl_cache_ops *ops, struct sockaddr_nl *who,
+ struct nlmsghdr *nlh, struct nl_parser_param *pp)
+{
+ int i, err;
+ struct genlmsghdr *ghdr;
+ struct genl_cmd *cmd;
+
+ ghdr = nlmsg_data(nlh);
+
+ if (ops->co_genl == NULL)
+ BUG();
+
+ for (i = 0; i < ops->co_genl->o_ncmds; i++) {
+ cmd = &ops->co_genl->o_cmds[i];
+ if (cmd->c_id == ghdr->cmd)
+ goto found;
+ }
+
+ err = -NLE_MSGTYPE_NOSUPPORT;
+ goto errout;
+
+found:
+ if (cmd->c_msg_parser == NULL)
+ err = -NLE_OPNOTSUPP;
+ else {
+ struct nlattr *tb[cmd->c_maxattr + 1];
+ struct genl_info info = {
+ .who = who,
+ .nlh = nlh,
+ .genlhdr = ghdr,
+ .userhdr = genlmsg_data(ghdr),
+ .attrs = tb,
+ };
+
+ err = nlmsg_parse(nlh, ops->co_hdrsize, tb, cmd->c_maxattr,
+ cmd->c_attr_policy);
+ if (err < 0)
+ goto errout;
+
+ err = cmd->c_msg_parser(ops, cmd, &info, pp);
+ }
+errout:
+ return err;
+
+}
+
+#ifdef disabled
+char *genl_op2name(int family, int op, char *buf, size_t len)
+{
+ struct genl_ops *ops;
+ int i;
+
+ nl_list_for_each_entry(ops, &genl_ops_list, o_list) {
+ if (ops->o_family == family) {
+ for (i = 0; i < ops->o_ncmds; i++) {
+ struct genl_cmd *cmd;
+ cmd = &ops->o_cmds[i];
+
+ if (cmd->c_id == op) {
+ strncpy(buf, cmd->c_name, len - 1);
+ return buf;
+ }
+ }
+ }
+ }
+
+ strncpy(buf, "unknown", len - 1);
+ return NULL;
+}
+#endif
+
+/**
+ * @name Register/Unregister
+ * @{
+ */
+
+/**
+ * Register generic netlink operations
+ * @arg ops cache operations
+ */
+int genl_register(struct nl_cache_ops *ops)
+{
+ int err;
+
+ if (ops->co_protocol != NETLINK_GENERIC) {
+ err = -NLE_PROTO_MISMATCH;
+ goto errout;
+ }
+
+ if (ops->co_hdrsize < GENL_HDRSIZE(0)) {
+ err = -NLE_INVAL;
+ goto errout;
+ }
+
+ if (ops->co_genl == NULL) {
+ err = -NLE_INVAL;
+ goto errout;
+ }
+
+ ops->co_genl->o_cache_ops = ops;
+ ops->co_genl->o_name = ops->co_msgtypes[0].mt_name;
+ ops->co_genl->o_family = ops->co_msgtypes[0].mt_id;
+ ops->co_msg_parser = genl_msg_parser;
+
+ /* FIXME: check for dup */
+
+ nl_list_add_tail(&ops->co_genl->o_list, &genl_ops_list);
+
+ err = nl_cache_mngt_register(ops);
+errout:
+ return err;
+}
+
+/**
+ * Unregister generic netlink operations
+ * @arg ops cache operations
+ */
+void genl_unregister(struct nl_cache_ops *ops)
+{
+ nl_cache_mngt_unregister(ops);
+ nl_list_del(&ops->co_genl->o_list);
+}
+
+/** @} */
+
+/**
+ * @name Resolving ID/Name
+ * @{
+ */
+#ifdef disabled
+static int __genl_ops_resolve(struct nl_cache *ctrl, struct genl_ops *ops)
+{
+ struct genl_family *family;
+
+ family = genl_ctrl_search_by_name(ctrl, ops->o_name);
+ if (family != NULL) {
+ ops->o_id = genl_family_get_id(family);
+ genl_family_put(family);
+
+ return 0;
+ }
+
+ return -NLE_OBJ_NOTFOUND;
+}
+
+int genl_ops_resolve(struct nl_sock *sk, struct genl_ops *ops)
+{
+ struct nl_cache *ctrl;
+ int err;
+
+ if ((err = genl_ctrl_alloc_cache(sk, &ctrl)) < 0)
+ goto errout;
+
+ err = __genl_ops_resolve(ctrl, ops);
+
+ nl_cache_free(ctrl);
+errout:
+ return err;
+}
+
+int genl_mngt_resolve(struct nl_sock *sk)
+{
+ struct nl_cache *ctrl;
+ struct genl_ops *ops;
+ int err = 0;
+
+ if ((err = genl_ctrl_alloc_cache(sk, &ctrl)) < 0)
+ goto errout;
+
+ nl_list_for_each_entry(ops, &genl_ops_list, o_list) {
+ err = __genl_ops_resolve(ctrl, ops);
+ }
+
+ nl_cache_free(ctrl);
+errout:
+ return err;
+}
+#endif
+/** @} */
+
+
+/** @} */
diff --git a/package/libs/libnl-tiny/src/.svn/text-base/handlers.c.svn-base b/package/libs/libnl-tiny/src/.svn/text-base/handlers.c.svn-base
new file mode 100644
index 0000000..12ebda5
--- /dev/null
+++ b/package/libs/libnl-tiny/src/.svn/text-base/handlers.c.svn-base
@@ -0,0 +1,162 @@
+/*
+ * lib/handlers.c default netlink message handlers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
+ */
+
+/**
+ * @ingroup core
+ * @defgroup cb Callbacks/Customization
+ *
+ * @details
+ * @par 1) Setting up a callback set
+ * @code
+ * // Allocate a callback set and initialize it to the verbose default set
+ * struct nl_cb *cb = nl_cb_alloc(NL_CB_VERBOSE);
+ *
+ * // Modify the set to call my_func() for all valid messages
+ * nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, my_func, NULL);
+ *
+ * // Set the error message handler to the verbose default implementation
+ * // and direct it to print all errors to the given file descriptor.
+ * FILE *file = fopen(...);
+ * nl_cb_err(cb, NL_CB_VERBOSE, NULL, file);
+ * @endcode
+ * @{
+ */
+
+#include <netlink-local.h>
+#include <netlink/netlink.h>
+#include <netlink/utils.h>
+#include <netlink/msg.h>
+#include <netlink/handlers.h>
+
+/**
+ * @name Callback Handle Management
+ * @{
+ */
+
+/**
+ * Allocate a new callback handle
+ * @arg kind callback kind to be used for initialization
+ * @return Newly allocated callback handle or NULL
+ */
+struct nl_cb *nl_cb_alloc(enum nl_cb_kind kind)
+{
+ int i;
+ struct nl_cb *cb;
+
+ if (kind < 0 || kind > NL_CB_KIND_MAX)
+ return NULL;
+
+ cb = calloc(1, sizeof(*cb));
+ if (!cb)
+ return NULL;
+
+ cb->cb_refcnt = 1;
+
+ for (i = 0; i <= NL_CB_TYPE_MAX; i++)
+ nl_cb_set(cb, i, kind, NULL, NULL);
+
+ nl_cb_err(cb, kind, NULL, NULL);
+
+ return cb;
+}
+
+/**
+ * Clone an existing callback handle
+ * @arg orig original callback handle
+ * @return Newly allocated callback handle being a duplicate of
+ * orig or NULL
+ */
+struct nl_cb *nl_cb_clone(struct nl_cb *orig)
+{
+ struct nl_cb *cb;
+
+ cb = nl_cb_alloc(NL_CB_DEFAULT);
+ if (!cb)
+ return NULL;
+
+ memcpy(cb, orig, sizeof(*orig));
+ cb->cb_refcnt = 1;
+
+ return cb;
+}
+
+void nl_cb_put(struct nl_cb *cb)
+{
+ if (!cb)
+ return;
+
+ cb->cb_refcnt--;
+
+ if (cb->cb_refcnt < 0)
+ BUG();
+
+ if (cb->cb_refcnt <= 0)
+ free(cb);
+}
+
+/** @} */
+
+/**
+ * @name Callback Setup
+ * @{
+ */
+
+/**
+ * Set up a callback
+ * @arg cb callback set
+ * @arg type callback to modify
+ * @arg kind kind of implementation
+ * @arg func callback function (NL_CB_CUSTOM)
+ * @arg arg argument passed to callback
+ *
+ * @return 0 on success or a negative error code
+ */
+int nl_cb_set(struct nl_cb *cb, enum nl_cb_type type, enum nl_cb_kind kind,
+ nl_recvmsg_msg_cb_t func, void *arg)
+{
+ if (type < 0 || type > NL_CB_TYPE_MAX)
+ return -NLE_RANGE;
+
+ if (kind < 0 || kind > NL_CB_KIND_MAX)
+ return -NLE_RANGE;
+
+ if (kind == NL_CB_CUSTOM) {
+ cb->cb_set[type] = func;
+ cb->cb_args[type] = arg;
+ }
+
+ return 0;
+}
+
+/**
+ * Set up an error callback
+ * @arg cb callback set
+ * @arg kind kind of callback
+ * @arg func callback function
+ * @arg arg argument to be passed to callback function
+ */
+int nl_cb_err(struct nl_cb *cb, enum nl_cb_kind kind,
+ nl_recvmsg_err_cb_t func, void *arg)
+{
+ if (kind < 0 || kind > NL_CB_KIND_MAX)
+ return -NLE_RANGE;
+
+ if (kind == NL_CB_CUSTOM) {
+ cb->cb_err = func;
+ cb->cb_err_arg = arg;
+ }
+
+ return 0;
+}
+
+/** @} */
+
+/** @} */
diff --git a/package/libs/libnl-tiny/src/.svn/text-base/msg.c.svn-base b/package/libs/libnl-tiny/src/.svn/text-base/msg.c.svn-base
new file mode 100644
index 0000000..e84c281
--- /dev/null
+++ b/package/libs/libnl-tiny/src/.svn/text-base/msg.c.svn-base
@@ -0,0 +1,566 @@
+/*
+ * lib/msg.c Netlink Messages Interface
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
+ */
+
+/**
+ * @ingroup core
+ * @defgroup msg Messages
+ * Netlink Message Construction/Parsing Interface
+ *
+ * The following information is partly extracted from RFC3549
+ * (ftp://ftp.rfc-editor.org/in-notes/rfc3549.txt)
+ *
+ * @par Message Format
+ * Netlink messages consist of a byte stream with one or multiple
+ * Netlink headers and an associated payload. If the payload is too big
+ * to fit into a single message it, can be split over multiple Netlink
+ * messages, collectively called a multipart message. For multipart
+ * messages, the first and all following headers have the \c NLM_F_MULTI
+ * Netlink header flag set, except for the last header which has the
+ * Netlink header type \c NLMSG_DONE.
+ *
+ * @par
+ * The Netlink message header (\link nlmsghdr struct nlmsghdr\endlink) is shown below.
+ * @code
+ * 0 1 2 3
+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Length |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Type | Flags |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Sequence Number |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Process ID (PID) |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * @endcode
+ *
+ * @par
+ * The netlink message header and payload must be aligned properly:
+ * @code
+ * <------- NLMSG_ALIGN(hlen) ------> <---- NLMSG_ALIGN(len) --->
+ * +----------------------------+- - -+- - - - - - - - - - -+- - -+
+ * | Header | Pad | Payload | Pad |
+ * | struct nlmsghdr | | | |
+ * +----------------------------+- - -+- - - - - - - - - - -+- - -+
+ * @endcode
+ * @par
+ * Message Format:
+ * @code
+ * <--- nlmsg_total_size(payload) --->
+ * <-- nlmsg_msg_size(payload) ->
+ * +----------+- - -+-------------+- - -+-------- - -
+ * | nlmsghdr | Pad | Payload | Pad | nlmsghdr
+ * +----------+- - -+-------------+- - -+-------- - -
+ * nlmsg_data(nlh)---^ ^
+ * nlmsg_next(nlh)-----------------------+
+ * @endcode
+ * @par
+ * The payload may consist of arbitary data but may have strict
+ * alignment and formatting rules depening on the specific netlink
+ * families.
+ * @par
+ * @code
+ * <---------------------- nlmsg_len(nlh) --------------------->
+ * <------ hdrlen ------> <- nlmsg_attrlen(nlh, hdrlen) ->
+ * +----------------------+- - -+--------------------------------+
+ * | Family Header | Pad | Attributes |
+ * +----------------------+- - -+--------------------------------+
+ * nlmsg_attrdata(nlh, hdrlen)---^
+ * @endcode
+ * @par The ACK Netlink Message
+ * This message is actually used to denote both an ACK and a NACK.
+ * Typically, the direction is from FEC to CPC (in response to an ACK
+ * request message). However, the CPC should be able to send ACKs back
+ * to FEC when requested.
+ * @code
+ * 0 1 2 3
+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Netlink message header |
+ * | type = NLMSG_ERROR |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Error code |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | OLD Netlink message header |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * @endcode
+ *
+ * @par Example
+ * @code
+ * // Various methods exist to create/allocate a new netlink
+ * // message.
+ * //
+ * // nlmsg_alloc() will allocate an empty netlink message with
+ * // a maximum payload size which defaults to the page size of
+ * // the system. This default size can be modified using the
+ * // function nlmsg_set_default_size().
+ * struct nl_msg *msg = nlmsg_alloc();
+ *
+ * // Very often, the message type and message flags are known
+ * // at allocation time while the other fields are auto generated:
+ * struct nl_msg *msg = nlmsg_alloc_simple(MY_TYPE, MY_FLAGS);
+ *
+ * // Alternatively an existing netlink message header can be used
+ * // to inherit the header values:
+ * struct nlmsghdr hdr = {
+ * .nlmsg_type = MY_TYPE,
+ * .nlmsg_flags = MY_FLAGS,
+ * };
+ * struct nl_msg *msg = nlmsg_inherit(&hdr);
+ *
+ * // Last but not least, netlink messages received from netlink sockets
+ * // can be converted into nl_msg objects using nlmsg_convert(). This
+ * // will create a message with a maximum payload size which equals the
+ * // length of the existing netlink message, therefore no more data can
+ * // be appened without calling nlmsg_expand() first.
+ * struct nl_msg *msg = nlmsg_convert(nlh_from_nl_sock);
+ *
+ * // Payload may be added to the message via nlmsg_append(). The fourth
+ * // parameter specifies the number of alignment bytes the data should
+ * // be padding with at the end. Common values are 0 to disable it or
+ * // NLMSG_ALIGNTO to ensure proper netlink message padding.
+ * nlmsg_append(msg, &mydata, sizeof(mydata), 0);
+ *
+ * // Sometimes it may be necessary to reserve room for data but defer
+ * // the actual copying to a later point, nlmsg_reserve() can be used
+ * // for this purpose:
+ * void *data = nlmsg_reserve(msg, sizeof(mydata), NLMSG_ALIGNTO);
+ *
+ * // Attributes may be added using the attributes interface.
+ *
+ * // After successful use of the message, the memory must be freed
+ * // using nlmsg_free()
+ * nlmsg_free(msg);
+ * @endcode
+ *
+ * @par 4) Parsing messages
+ * @code
+ * int n;
+ * unsigned char *buf;
+ * struct nlmsghdr *hdr;
+ *
+ * n = nl_recv(handle, NULL, &buf);
+ *
+ * hdr = (struct nlmsghdr *) buf;
+ * while (nlmsg_ok(hdr, n)) {
+ * // Process message here...
+ * hdr = nlmsg_next(hdr, &n);
+ * }
+ * @endcode
+ * @{
+ */
+
+#include <netlink-local.h>
+#include <netlink/netlink.h>
+#include <netlink/utils.h>
+#include <netlink/cache.h>
+#include <netlink/attr.h>
+#include <netlink/msg.h>
+#include <linux/socket.h>
+
+static size_t default_msg_size;
+
+static void __init init_msg_size(void)
+{
+ default_msg_size = getpagesize();
+}
+
+/**
+ * @name Attribute Access
+ * @{
+ */
+
+//** @} */
+
+/**
+ * @name Message Parsing
+ * @{
+ */
+
+/**
+ * check if the netlink message fits into the remaining bytes
+ * @arg nlh netlink message header
+ * @arg remaining number of bytes remaining in message stream
+ */
+int nlmsg_ok(const struct nlmsghdr *nlh, int remaining)
+{
+ return (remaining >= sizeof(struct nlmsghdr) &&
+ nlh->nlmsg_len >= sizeof(struct nlmsghdr) &&
+ nlh->nlmsg_len <= remaining);
+}
+
+/**
+ * next netlink message in message stream
+ * @arg nlh netlink message header
+ * @arg remaining number of bytes remaining in message stream
+ *
+ * @returns the next netlink message in the message stream and
+ * decrements remaining by the size of the current message.
+ */
+struct nlmsghdr *nlmsg_next(struct nlmsghdr *nlh, int *remaining)
+{
+ int totlen = NLMSG_ALIGN(nlh->nlmsg_len);
+
+ *remaining -= totlen;
+
+ return (struct nlmsghdr *) ((unsigned char *) nlh + totlen);
+}
+
+/**
+ * parse attributes of a netlink message
+ * @arg nlh netlink message header
+ * @arg hdrlen length of family specific header
+ * @arg tb destination array with maxtype+1 elements
+ * @arg maxtype maximum attribute type to be expected
+ * @arg policy validation policy
+ *
+ * See nla_parse()
+ */
+int nlmsg_parse(struct nlmsghdr *nlh, int hdrlen, struct nlattr *tb[],
+ int maxtype, struct nla_policy *policy)
+{
+ if (!nlmsg_valid_hdr(nlh, hdrlen))
+ return -NLE_MSG_TOOSHORT;
+
+ return nla_parse(tb, maxtype, nlmsg_attrdata(nlh, hdrlen),
+ nlmsg_attrlen(nlh, hdrlen), policy);
+}
+
+/**
+ * nlmsg_validate - validate a netlink message including attributes
+ * @arg nlh netlinket message header
+ * @arg hdrlen length of familiy specific header
+ * @arg maxtype maximum attribute type to be expected
+ * @arg policy validation policy
+ */
+int nlmsg_validate(struct nlmsghdr *nlh, int hdrlen, int maxtype,
+ struct nla_policy *policy)
+{
+ if (!nlmsg_valid_hdr(nlh, hdrlen))
+ return -NLE_MSG_TOOSHORT;
+
+ return nla_validate(nlmsg_attrdata(nlh, hdrlen),
+ nlmsg_attrlen(nlh, hdrlen), maxtype, policy);
+}
+
+/** @} */
+
+/**
+ * @name Message Building/Access
+ * @{
+ */
+
+static struct nl_msg *__nlmsg_alloc(size_t len)
+{
+ struct nl_msg *nm;
+
+ nm = calloc(1, sizeof(*nm));
+ if (!nm)
+ goto errout;
+
+ nm->nm_refcnt = 1;
+
+ nm->nm_nlh = malloc(len);
+ if (!nm->nm_nlh)
+ goto errout;
+
+ memset(nm->nm_nlh, 0, sizeof(struct nlmsghdr));
+
+ nm->nm_protocol = -1;
+ nm->nm_size = len;
+ nm->nm_nlh->nlmsg_len = nlmsg_total_size(0);
+
+ NL_DBG(2, "msg %p: Allocated new message, maxlen=%zu\n", nm, len);
+
+ return nm;
+errout:
+ free(nm);
+ return NULL;
+}
+
+/**
+ * Allocate a new netlink message with the default maximum payload size.
+ *
+ * Allocates a new netlink message without any further payload. The
+ * maximum payload size defaults to PAGESIZE or as otherwise specified
+ * with nlmsg_set_default_size().
+ *
+ * @return Newly allocated netlink message or NULL.
+ */
+struct nl_msg *nlmsg_alloc(void)
+{
+ return __nlmsg_alloc(default_msg_size);
+}
+
+/**
+ * Allocate a new netlink message with maximum payload size specified.
+ */
+struct nl_msg *nlmsg_alloc_size(size_t max)
+{
+ return __nlmsg_alloc(max);
+}
+
+/**
+ * Allocate a new netlink message and inherit netlink message header
+ * @arg hdr Netlink message header template
+ *
+ * Allocates a new netlink message and inherits the original message
+ * header. If \a hdr is not NULL it will be used as a template for
+ * the netlink message header, otherwise the header is left blank.
+ *
+ * @return Newly allocated netlink message or NULL
+ */
+struct nl_msg *nlmsg_inherit(struct nlmsghdr *hdr)
+{
+ struct nl_msg *nm;
+
+ nm = nlmsg_alloc();
+ if (nm && hdr) {
+ struct nlmsghdr *new = nm->nm_nlh;
+
+ new->nlmsg_type = hdr->nlmsg_type;
+ new->nlmsg_flags = hdr->nlmsg_flags;
+ new->nlmsg_seq = hdr->nlmsg_seq;
+ new->nlmsg_pid = hdr->nlmsg_pid;
+ }
+
+ return nm;
+}
+
+/**
+ * Allocate a new netlink message
+ * @arg nlmsgtype Netlink message type
+ * @arg flags Message flags.
+ *
+ * @return Newly allocated netlink message or NULL.
+ */
+struct nl_msg *nlmsg_alloc_simple(int nlmsgtype, int flags)
+{
+ struct nl_msg *msg;
+ struct nlmsghdr nlh = {
+ .nlmsg_type = nlmsgtype,
+ .nlmsg_flags = flags,
+ };
+
+ msg = nlmsg_inherit(&nlh);
+ if (msg)
+ NL_DBG(2, "msg %p: Allocated new simple message\n", msg);
+
+ return msg;
+}
+
+/**
+ * Set the default maximum message payload size for allocated messages
+ * @arg max Size of payload in bytes.
+ */
+void nlmsg_set_default_size(size_t max)
+{
+ if (max < nlmsg_total_size(0))
+ max = nlmsg_total_size(0);
+
+ default_msg_size = max;
+}
+
+/**
+ * Convert a netlink message received from a netlink socket to a nl_msg
+ * @arg hdr Netlink message received from netlink socket.
+ *
+ * Allocates a new netlink message and copies all of the data pointed to
+ * by \a hdr into the new message object.
+ *
+ * @return Newly allocated netlink message or NULL.
+ */
+struct nl_msg *nlmsg_convert(struct nlmsghdr *hdr)
+{
+ struct nl_msg *nm;
+
+ nm = __nlmsg_alloc(NLMSG_ALIGN(hdr->nlmsg_len));
+ if (!nm)
+ goto errout;
+
+ memcpy(nm->nm_nlh, hdr, hdr->nlmsg_len);
+
+ return nm;
+errout:
+ nlmsg_free(nm);
+ return NULL;
+}
+
+/**
+ * Reserve room for additional data in a netlink message
+ * @arg n netlink message
+ * @arg len length of additional data to reserve room for
+ * @arg pad number of bytes to align data to
+ *
+ * Reserves room for additional data at the tail of the an
+ * existing netlink message. Eventual padding required will
+ * be zeroed out.
+ *
+ * @return Pointer to start of additional data tailroom or NULL.
+ */
+void *nlmsg_reserve(struct nl_msg *n, size_t len, int pad)
+{
+ void *buf = n->nm_nlh;
+ size_t nlmsg_len = n->nm_nlh->nlmsg_len;
+ size_t tlen;
+
+ tlen = pad ? ((len + (pad - 1)) & ~(pad - 1)) : len;
+
+ if ((tlen + nlmsg_len) > n->nm_size)
+ return NULL;
+
+ buf += nlmsg_len;
+ n->nm_nlh->nlmsg_len += tlen;
+
+ if (tlen > len)
+ memset(buf + len, 0, tlen - len);
+
+ NL_DBG(2, "msg %p: Reserved %zu bytes, pad=%d, nlmsg_len=%d\n",
+ n, len, pad, n->nm_nlh->nlmsg_len);
+
+ return buf;
+}
+
+/**
+ * Append data to tail of a netlink message
+ * @arg n netlink message
+ * @arg data data to add
+ * @arg len length of data
+ * @arg pad Number of bytes to align data to.
+ *
+ * Extends the netlink message as needed and appends the data of given
+ * length to the message.
+ *
+ * @return 0 on success or a negative error code
+ */
+int nlmsg_append(struct nl_msg *n, void *data, size_t len, int pad)
+{
+ void *tmp;
+
+ tmp = nlmsg_reserve(n, len, pad);
+ if (tmp == NULL)
+ return -NLE_NOMEM;
+
+ memcpy(tmp, data, len);
+ NL_DBG(2, "msg %p: Appended %zu bytes with padding %d\n", n, len, pad);
+
+ return 0;
+}
+
+/**
+ * Add a netlink message header to a netlink message
+ * @arg n netlink message
+ * @arg pid netlink process id or NL_AUTO_PID
+ * @arg seq sequence number of message or NL_AUTO_SEQ
+ * @arg type message type
+ * @arg payload length of message payload
+ * @arg flags message flags
+ *
+ * Adds or overwrites the netlink message header in an existing message
+ * object. If \a payload is greater-than zero additional room will be
+ * reserved, f.e. for family specific headers. It can be accesed via
+ * nlmsg_data().
+ *
+ * @return A pointer to the netlink message header or NULL.
+ */
+struct nlmsghdr *nlmsg_put(struct nl_msg *n, uint32_t pid, uint32_t seq,
+ int type, int payload, int flags)
+{
+ struct nlmsghdr *nlh;
+
+ if (n->nm_nlh->nlmsg_len < NLMSG_HDRLEN)
+ BUG();
+
+ nlh = (struct nlmsghdr *) n->nm_nlh;
+ nlh->nlmsg_type = type;
+ nlh->nlmsg_flags = flags;
+ nlh->nlmsg_pid = pid;
+ nlh->nlmsg_seq = seq;
+
+ NL_DBG(2, "msg %p: Added netlink header type=%d, flags=%d, pid=%d, "
+ "seq=%d\n", n, type, flags, pid, seq);
+
+ if (payload > 0 &&
+ nlmsg_reserve(n, payload, NLMSG_ALIGNTO) == NULL)
+ return NULL;
+
+ return nlh;
+}
+
+/**
+ * Release a reference from an netlink message
+ * @arg msg message to release reference from
+ *
+ * Frees memory after the last reference has been released.
+ */
+void nlmsg_free(struct nl_msg *msg)
+{
+ if (!msg)
+ return;
+
+ msg->nm_refcnt--;
+ NL_DBG(4, "Returned message reference %p, %d remaining\n",
+ msg, msg->nm_refcnt);
+
+ if (msg->nm_refcnt < 0)
+ BUG();
+
+ if (msg->nm_refcnt <= 0) {
+ free(msg->nm_nlh);
+ free(msg);
+ NL_DBG(2, "msg %p: Freed\n", msg);
+ }
+}
+
+/** @} */
+
+/**
+ * @name Direct Parsing
+ * @{
+ */
+
+/** @cond SKIP */
+struct dp_xdata {
+ void (*cb)(struct nl_object *, void *);
+ void *arg;
+};
+/** @endcond */
+
+static int parse_cb(struct nl_object *obj, struct nl_parser_param *p)
+{
+ struct dp_xdata *x = p->pp_arg;
+
+ x->cb(obj, x->arg);
+ return 0;
+}
+
+int nl_msg_parse(struct nl_msg *msg, void (*cb)(struct nl_object *, void *),
+ void *arg)
+{
+ struct nl_cache_ops *ops;
+ struct nl_parser_param p = {
+ .pp_cb = parse_cb
+ };
+ struct dp_xdata x = {
+ .cb = cb,
+ .arg = arg,
+ };
+
+ ops = nl_cache_ops_associate(nlmsg_get_proto(msg),
+ nlmsg_hdr(msg)->nlmsg_type);
+ if (ops == NULL)
+ return -NLE_MSGTYPE_NOSUPPORT;
+ p.pp_arg = &x;
+
+ return nl_cache_parse(ops, NULL, nlmsg_hdr(msg), &p);
+}
+
+/** @} */
diff --git a/package/libs/libnl-tiny/src/.svn/text-base/nl.c.svn-base b/package/libs/libnl-tiny/src/.svn/text-base/nl.c.svn-base
new file mode 100644
index 0000000..99e9aeb
--- /dev/null
+++ b/package/libs/libnl-tiny/src/.svn/text-base/nl.c.svn-base
@@ -0,0 +1,720 @@
+/*
+ * lib/nl.c Core Netlink Interface
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
+ */
+
+/**
+ * @defgroup core Core
+ *
+ * @details
+ * @par 1) Connecting the socket
+ * @code
+ * // Bind and connect the socket to a protocol, NETLINK_ROUTE in this example.
+ * nl_connect(sk, NETLINK_ROUTE);
+ * @endcode
+ *
+ * @par 2) Sending data
+ * @code
+ * // The most rudimentary method is to use nl_sendto() simply pushing
+ * // a piece of data to the other netlink peer. This method is not
+ * // recommended.
+ * const char buf[] = { 0x01, 0x02, 0x03, 0x04 };
+ * nl_sendto(sk, buf, sizeof(buf));
+ *
+ * // A more comfortable interface is nl_send() taking a pointer to
+ * // a netlink message.
+ * struct nl_msg *msg = my_msg_builder();
+ * nl_send(sk, nlmsg_hdr(msg));
+ *
+ * // nl_sendmsg() provides additional control over the sendmsg() message
+ * // header in order to allow more specific addressing of multiple peers etc.
+ * struct msghdr hdr = { ... };
+ * nl_sendmsg(sk, nlmsg_hdr(msg), &hdr);
+ *
+ * // You're probably too lazy to fill out the netlink pid, sequence number
+ * // and message flags all the time. nl_send_auto_complete() automatically
+ * // extends your message header as needed with an appropriate sequence
+ * // number, the netlink pid stored in the netlink socket and the message
+ * // flags NLM_F_REQUEST and NLM_F_ACK (if not disabled in the socket)
+ * nl_send_auto_complete(sk, nlmsg_hdr(msg));
+ *
+ * // Simple protocols don't require the complex message construction interface
+ * // and may favour nl_send_simple() to easly send a bunch of payload
+ * // encapsulated in a netlink message header.
+ * nl_send_simple(sk, MY_MSG_TYPE, 0, buf, sizeof(buf));
+ * @endcode
+ *
+ * @par 3) Receiving data
+ * @code
+ * // nl_recv() receives a single message allocating a buffer for the message
+ * // content and gives back the pointer to you.
+ * struct sockaddr_nl peer;
+ * unsigned char *msg;
+ * nl_recv(sk, &peer, &msg);
+ *
+ * // nl_recvmsgs() receives a bunch of messages until the callback system
+ * // orders it to state, usually after receving a compolete multi part
+ * // message series.
+ * nl_recvmsgs(sk, my_callback_configuration);
+ *
+ * // nl_recvmsgs_default() acts just like nl_recvmsg() but uses the callback
+ * // configuration stored in the socket.
+ * nl_recvmsgs_default(sk);
+ *
+ * // In case you want to wait for the ACK to be recieved that you requested
+ * // with your latest message, you can call nl_wait_for_ack()
+ * nl_wait_for_ack(sk);
+ * @endcode
+ *
+ * @par 4) Closing
+ * @code
+ * // Close the socket first to release kernel memory
+ * nl_close(sk);
+ * @endcode
+ *
+ * @{
+ */
+
+#include <netlink-local.h>
+#include <netlink/netlink.h>
+#include <netlink/utils.h>
+#include <netlink/handlers.h>
+#include <netlink/msg.h>
+#include <netlink/attr.h>
+
+/**
+ * @name Connection Management
+ * @{
+ */
+
+/**
+ * Create and connect netlink socket.
+ * @arg sk Netlink socket.
+ * @arg protocol Netlink protocol to use.
+ *
+ * Creates a netlink socket using the specified protocol, binds the socket
+ * and issues a connection attempt.
+ *
+ * @return 0 on success or a negative error code.
+ */
+int nl_connect(struct nl_sock *sk, int protocol)
+{
+ int err;
+ socklen_t addrlen;
+
+ sk->s_fd = socket(AF_NETLINK, SOCK_RAW, protocol);
+ if (sk->s_fd < 0) {
+ err = -nl_syserr2nlerr(errno);
+ goto errout;
+ }
+
+ if (!(sk->s_flags & NL_SOCK_BUFSIZE_SET)) {
+ err = nl_socket_set_buffer_size(sk, 0, 0);
+ if (err < 0)
+ goto errout;
+ }
+
+ err = bind(sk->s_fd, (struct sockaddr*) &sk->s_local,
+ sizeof(sk->s_local));
+ if (err < 0) {
+ err = -nl_syserr2nlerr(errno);
+ goto errout;
+ }
+
+ addrlen = sizeof(sk->s_local);
+ err = getsockname(sk->s_fd, (struct sockaddr *) &sk->s_local,
+ &addrlen);
+ if (err < 0) {
+ err = -nl_syserr2nlerr(errno);
+ goto errout;
+ }
+
+ if (addrlen != sizeof(sk->s_local)) {
+ err = -NLE_NOADDR;
+ goto errout;
+ }
+
+ if (sk->s_local.nl_family != AF_NETLINK) {
+ err = -NLE_AF_NOSUPPORT;
+ goto errout;
+ }
+
+ sk->s_proto = protocol;
+
+ return 0;
+errout:
+ close(sk->s_fd);
+ sk->s_fd = -1;
+
+ return err;
+}
+
+/**
+ * Close/Disconnect netlink socket.
+ * @arg sk Netlink socket.
+ */
+void nl_close(struct nl_sock *sk)
+{
+ if (sk->s_fd >= 0) {
+ close(sk->s_fd);
+ sk->s_fd = -1;
+ }
+
+ sk->s_proto = 0;
+}
+
+/** @} */
+
+/**
+ * @name Send
+ * @{
+ */
+
+/**
+ * Send raw data over netlink socket.
+ * @arg sk Netlink socket.
+ * @arg buf Data buffer.
+ * @arg size Size of data buffer.
+ * @return Number of characters written on success or a negative error code.
+ */
+int nl_sendto(struct nl_sock *sk, void *buf, size_t size)
+{
+ int ret;
+
+ ret = sendto(sk->s_fd, buf, size, 0, (struct sockaddr *)
+ &sk->s_peer, sizeof(sk->s_peer));
+ if (ret < 0)
+ return -nl_syserr2nlerr(errno);
+
+ return ret;
+}
+
+/**
+ * Send netlink message with control over sendmsg() message header.
+ * @arg sk Netlink socket.
+ * @arg msg Netlink message to be sent.
+ * @arg hdr Sendmsg() message header.
+ * @return Number of characters sent on sucess or a negative error code.
+ */
+int nl_sendmsg(struct nl_sock *sk, struct nl_msg *msg, struct msghdr *hdr)
+{
+ struct nl_cb *cb;
+ int ret;
+
+ struct iovec iov = {
+ .iov_base = (void *) nlmsg_hdr(msg),
+ .iov_len = nlmsg_hdr(msg)->nlmsg_len,
+ };
+
+ hdr->msg_iov = &iov;
+ hdr->msg_iovlen = 1;
+
+ nlmsg_set_src(msg, &sk->s_local);
+
+ cb = sk->s_cb;
+ if (cb->cb_set[NL_CB_MSG_OUT])
+ if (nl_cb_call(cb, NL_CB_MSG_OUT, msg) != NL_OK)
+ return 0;
+
+ ret = sendmsg(sk->s_fd, hdr, 0);
+ if (ret < 0)
+ return -nl_syserr2nlerr(errno);
+
+ return ret;
+}
+
+
+/**
+ * Send netlink message.
+ * @arg sk Netlink socket.
+ * @arg msg Netlink message to be sent.
+ * @see nl_sendmsg()
+ * @return Number of characters sent on success or a negative error code.
+ */
+int nl_send(struct nl_sock *sk, struct nl_msg *msg)
+{
+ struct sockaddr_nl *dst;
+ struct ucred *creds;
+
+ struct msghdr hdr = {
+ .msg_name = (void *) &sk->s_peer,
+ .msg_namelen = sizeof(struct sockaddr_nl),
+ };
+
+ /* Overwrite destination if specified in the message itself, defaults
+ * to the peer address of the socket.
+ */
+ dst = nlmsg_get_dst(msg);
+ if (dst->nl_family == AF_NETLINK)
+ hdr.msg_name = dst;
+
+ /* Add credentials if present. */
+ creds = nlmsg_get_creds(msg);
+ if (creds != NULL) {
+ char buf[CMSG_SPACE(sizeof(struct ucred))];
+ struct cmsghdr *cmsg;
+
+ hdr.msg_control = buf;
+ hdr.msg_controllen = sizeof(buf);
+
+ cmsg = CMSG_FIRSTHDR(&hdr);
+ cmsg->cmsg_level = SOL_SOCKET;
+ cmsg->cmsg_type = SCM_CREDENTIALS;
+ cmsg->cmsg_len = CMSG_LEN(sizeof(struct ucred));
+ memcpy(CMSG_DATA(cmsg), creds, sizeof(struct ucred));
+ }
+
+ return nl_sendmsg(sk, msg, &hdr);
+}
+
+/**
+ * Send netlink message and check & extend header values as needed.
+ * @arg sk Netlink socket.
+ * @arg msg Netlink message to be sent.
+ *
+ * Checks the netlink message \c nlh for completness and extends it
+ * as required before sending it out. Checked fields include pid,
+ * sequence nr, and flags.
+ *
+ * @see nl_send()
+ * @return Number of characters sent or a negative error code.
+ */
+int nl_send_auto_complete(struct nl_sock *sk, struct nl_msg *msg)
+{
+ struct nlmsghdr *nlh;
+ struct nl_cb *cb = sk->s_cb;
+
+ nlh = nlmsg_hdr(msg);
+ if (nlh->nlmsg_pid == 0)
+ nlh->nlmsg_pid = sk->s_local.nl_pid;
+
+ if (nlh->nlmsg_seq == 0)
+ nlh->nlmsg_seq = sk->s_seq_next++;
+
+ if (msg->nm_protocol == -1)
+ msg->nm_protocol = sk->s_proto;
+
+ nlh->nlmsg_flags |= NLM_F_REQUEST;
+
+ if (!(sk->s_flags & NL_NO_AUTO_ACK))
+ nlh->nlmsg_flags |= NLM_F_ACK;
+
+ if (cb->cb_send_ow)
+ return cb->cb_send_ow(sk, msg);
+ else
+ return nl_send(sk, msg);
+}
+
+/**
+ * Send simple netlink message using nl_send_auto_complete()
+ * @arg sk Netlink socket.
+ * @arg type Netlink message type.
+ * @arg flags Netlink message flags.
+ * @arg buf Data buffer.
+ * @arg size Size of data buffer.
+ *
+ * Builds a netlink message with the specified type and flags and
+ * appends the specified data as payload to the message.
+ *
+ * @see nl_send_auto_complete()
+ * @return Number of characters sent on success or a negative error code.
+ */
+int nl_send_simple(struct nl_sock *sk, int type, int flags, void *buf,
+ size_t size)
+{
+ int err;
+ struct nl_msg *msg;
+
+ msg = nlmsg_alloc_simple(type, flags);
+ if (!msg)
+ return -NLE_NOMEM;
+
+ if (buf && size) {
+ err = nlmsg_append(msg, buf, size, NLMSG_ALIGNTO);
+ if (err < 0)
+ goto errout;
+ }
+
+
+ err = nl_send_auto_complete(sk, msg);
+errout:
+ nlmsg_free(msg);
+
+ return err;
+}
+
+/** @} */
+
+/**
+ * @name Receive
+ * @{
+ */
+
+/**
+ * Receive data from netlink socket
+ * @arg sk Netlink socket.
+ * @arg nla Destination pointer for peer's netlink address.
+ * @arg buf Destination pointer for message content.
+ * @arg creds Destination pointer for credentials.
+ *
+ * Receives a netlink message, allocates a buffer in \c *buf and
+ * stores the message content. The peer's netlink address is stored
+ * in \c *nla. The caller is responsible for freeing the buffer allocated
+ * in \c *buf if a positive value is returned. Interruped system calls
+ * are handled by repeating the read. The input buffer size is determined
+ * by peeking before the actual read is done.
+ *
+ * A non-blocking sockets causes the function to return immediately with
+ * a return value of 0 if no data is available.
+ *
+ * @return Number of octets read, 0 on EOF or a negative error code.
+ */
+int nl_recv(struct nl_sock *sk, struct sockaddr_nl *nla,
+ unsigned char **buf, struct ucred **creds)
+{
+ int n;
+ int flags = 0;
+ static int page_size = 0;
+ struct iovec iov;
+ struct msghdr msg = {
+ .msg_name = (void *) nla,
+ .msg_namelen = sizeof(struct sockaddr_nl),
+ .msg_iov = &iov,
+ .msg_iovlen = 1,
+ .msg_control = NULL,
+ .msg_controllen = 0,
+ .msg_flags = 0,
+ };
+ struct cmsghdr *cmsg;
+
+ if (sk->s_flags & NL_MSG_PEEK)
+ flags |= MSG_PEEK;
+
+ if (page_size == 0)
+ page_size = getpagesize();
+
+ iov.iov_len = page_size;
+ iov.iov_base = *buf = malloc(iov.iov_len);
+
+ if (sk->s_flags & NL_SOCK_PASSCRED) {
+ msg.msg_controllen = CMSG_SPACE(sizeof(struct ucred));
+ msg.msg_control = calloc(1, msg.msg_controllen);
+ }
+retry:
+
+ n = recvmsg(sk->s_fd, &msg, flags);
+ if (!n)
+ goto abort;
+ else if (n < 0) {
+ if (errno == EINTR) {
+ NL_DBG(3, "recvmsg() returned EINTR, retrying\n");
+ goto retry;
+ } else if (errno == EAGAIN) {
+ NL_DBG(3, "recvmsg() returned EAGAIN, aborting\n");
+ goto abort;
+ } else {
+ free(msg.msg_control);
+ free(*buf);
+ return -nl_syserr2nlerr(errno);
+ }
+ }
+
+ if (iov.iov_len < n ||
+ msg.msg_flags & MSG_TRUNC) {
+ /* Provided buffer is not long enough, enlarge it
+ * and try again. */
+ iov.iov_len *= 2;
+ iov.iov_base = *buf = realloc(*buf, iov.iov_len);
+ goto retry;
+ } else if (msg.msg_flags & MSG_CTRUNC) {
+ msg.msg_controllen *= 2;
+ msg.msg_control = realloc(msg.msg_control, msg.msg_controllen);
+ goto retry;
+ } else if (flags != 0) {
+ /* Buffer is big enough, do the actual reading */
+ flags = 0;
+ goto retry;
+ }
+
+ if (msg.msg_namelen != sizeof(struct sockaddr_nl)) {
+ free(msg.msg_control);
+ free(*buf);
+ return -NLE_NOADDR;
+ }
+
+ for (cmsg = CMSG_FIRSTHDR(&msg); cmsg; cmsg = CMSG_NXTHDR(&msg, cmsg)) {
+ if (cmsg->cmsg_level == SOL_SOCKET &&
+ cmsg->cmsg_type == SCM_CREDENTIALS) {
+ *creds = calloc(1, sizeof(struct ucred));
+ memcpy(*creds, CMSG_DATA(cmsg), sizeof(struct ucred));
+ break;
+ }
+ }
+
+ free(msg.msg_control);
+ return n;
+
+abort:
+ free(msg.msg_control);
+ free(*buf);
+ return 0;
+}
+
+#define NL_CB_CALL(cb, type, msg) \
+do { \
+ err = nl_cb_call(cb, type, msg); \
+ switch (err) { \
+ case NL_OK: \
+ err = 0; \
+ break; \
+ case NL_SKIP: \
+ goto skip; \
+ case NL_STOP: \
+ goto stop; \
+ default: \
+ goto out; \
+ } \
+} while (0)
+
+static int recvmsgs(struct nl_sock *sk, struct nl_cb *cb)
+{
+ int n, err = 0, multipart = 0;
+ unsigned char *buf = NULL;
+ struct nlmsghdr *hdr;
+ struct sockaddr_nl nla = {0};
+ struct nl_msg *msg = NULL;
+ struct ucred *creds = NULL;
+
+continue_reading:
+ NL_DBG(3, "Attempting to read from %p\n", sk);
+ if (cb->cb_recv_ow)
+ n = cb->cb_recv_ow(sk, &nla, &buf, &creds);
+ else
+ n = nl_recv(sk, &nla, &buf, &creds);
+
+ if (n <= 0)
+ return n;
+
+ NL_DBG(3, "recvmsgs(%p): Read %d bytes\n", sk, n);
+
+ hdr = (struct nlmsghdr *) buf;
+ while (nlmsg_ok(hdr, n)) {
+ NL_DBG(3, "recgmsgs(%p): Processing valid message...\n", sk);
+
+ nlmsg_free(msg);
+ msg = nlmsg_convert(hdr);
+ if (!msg) {
+ err = -NLE_NOMEM;
+ goto out;
+ }
+
+ nlmsg_set_proto(msg, sk->s_proto);
+ nlmsg_set_src(msg, &nla);
+ if (creds)
+ nlmsg_set_creds(msg, creds);
+
+ /* Raw callback is the first, it gives the most control
+ * to the user and he can do his very own parsing. */
+ if (cb->cb_set[NL_CB_MSG_IN])
+ NL_CB_CALL(cb, NL_CB_MSG_IN, msg);
+
+ /* Sequence number checking. The check may be done by
+ * the user, otherwise a very simple check is applied
+ * enforcing strict ordering */
+ if (cb->cb_set[NL_CB_SEQ_CHECK])
+ NL_CB_CALL(cb, NL_CB_SEQ_CHECK, msg);
+ else if (hdr->nlmsg_seq != sk->s_seq_expect) {
+ if (cb->cb_set[NL_CB_INVALID])
+ NL_CB_CALL(cb, NL_CB_INVALID, msg);
+ else {
+ err = -NLE_SEQ_MISMATCH;
+ goto out;
+ }
+ }
+
+ if (hdr->nlmsg_type == NLMSG_DONE ||
+ hdr->nlmsg_type == NLMSG_ERROR ||
+ hdr->nlmsg_type == NLMSG_NOOP ||
+ hdr->nlmsg_type == NLMSG_OVERRUN) {
+ /* We can't check for !NLM_F_MULTI since some netlink
+ * users in the kernel are broken. */
+ sk->s_seq_expect++;
+ NL_DBG(3, "recvmsgs(%p): Increased expected " \
+ "sequence number to %d\n",
+ sk, sk->s_seq_expect);
+ }
+
+ if (hdr->nlmsg_flags & NLM_F_MULTI)
+ multipart = 1;
+
+ /* Other side wishes to see an ack for this message */
+ if (hdr->nlmsg_flags & NLM_F_ACK) {
+ if (cb->cb_set[NL_CB_SEND_ACK])
+ NL_CB_CALL(cb, NL_CB_SEND_ACK, msg);
+ else {
+ /* FIXME: implement */
+ }
+ }
+
+ /* messages terminates a multpart message, this is
+ * usually the end of a message and therefore we slip
+ * out of the loop by default. the user may overrule
+ * this action by skipping this packet. */
+ if (hdr->nlmsg_type == NLMSG_DONE) {
+ multipart = 0;
+ if (cb->cb_set[NL_CB_FINISH])
+ NL_CB_CALL(cb, NL_CB_FINISH, msg);
+ }
+
+ /* Message to be ignored, the default action is to
+ * skip this message if no callback is specified. The
+ * user may overrule this action by returning
+ * NL_PROCEED. */
+ else if (hdr->nlmsg_type == NLMSG_NOOP) {
+ if (cb->cb_set[NL_CB_SKIPPED])
+ NL_CB_CALL(cb, NL_CB_SKIPPED, msg);
+ else
+ goto skip;
+ }
+
+ /* Data got lost, report back to user. The default action is to
+ * quit parsing. The user may overrule this action by retuning
+ * NL_SKIP or NL_PROCEED (dangerous) */
+ else if (hdr->nlmsg_type == NLMSG_OVERRUN) {
+ if (cb->cb_set[NL_CB_OVERRUN])
+ NL_CB_CALL(cb, NL_CB_OVERRUN, msg);
+ else {
+ err = -NLE_MSG_OVERFLOW;
+ goto out;
+ }
+ }
+
+ /* Message carries a nlmsgerr */
+ else if (hdr->nlmsg_type == NLMSG_ERROR) {
+ struct nlmsgerr *e = nlmsg_data(hdr);
+
+ if (hdr->nlmsg_len < nlmsg_msg_size(sizeof(*e))) {
+ /* Truncated error message, the default action
+ * is to stop parsing. The user may overrule
+ * this action by returning NL_SKIP or
+ * NL_PROCEED (dangerous) */
+ if (cb->cb_set[NL_CB_INVALID])
+ NL_CB_CALL(cb, NL_CB_INVALID, msg);
+ else {
+ err = -NLE_MSG_TRUNC;
+ goto out;
+ }
+ } else if (e->error) {
+ /* Error message reported back from kernel. */
+ if (cb->cb_err) {
+ err = cb->cb_err(&nla, e,
+ cb->cb_err_arg);
+ if (err < 0)
+ goto out;
+ else if (err == NL_SKIP)
+ goto skip;
+ else if (err == NL_STOP) {
+ err = -nl_syserr2nlerr(e->error);
+ goto out;
+ }
+ } else {
+ err = -nl_syserr2nlerr(e->error);
+ goto out;
+ }
+ } else if (cb->cb_set[NL_CB_ACK])
+ NL_CB_CALL(cb, NL_CB_ACK, msg);
+ } else {
+ /* Valid message (not checking for MULTIPART bit to
+ * get along with broken kernels. NL_SKIP has no
+ * effect on this. */
+ if (cb->cb_set[NL_CB_VALID])
+ NL_CB_CALL(cb, NL_CB_VALID, msg);
+ }
+skip:
+ err = 0;
+ hdr = nlmsg_next(hdr, &n);
+ }
+
+ nlmsg_free(msg);
+ free(buf);
+ free(creds);
+ buf = NULL;
+ msg = NULL;
+ creds = NULL;
+
+ if (multipart) {
+ /* Multipart message not yet complete, continue reading */
+ goto continue_reading;
+ }
+stop:
+ err = 0;
+out:
+ nlmsg_free(msg);
+ free(buf);
+ free(creds);
+
+ return err;
+}
+
+/**
+ * Receive a set of messages from a netlink socket.
+ * @arg sk Netlink socket.
+ * @arg cb set of callbacks to control behaviour.
+ *
+ * Repeatedly calls nl_recv() or the respective replacement if provided
+ * by the application (see nl_cb_overwrite_recv()) and parses the
+ * received data as netlink messages. Stops reading if one of the
+ * callbacks returns NL_STOP or nl_recv returns either 0 or a negative error code.
+ *
+ * A non-blocking sockets causes the function to return immediately if
+ * no data is available.
+ *
+ * @return 0 on success or a negative error code from nl_recv().
+ */
+int nl_recvmsgs(struct nl_sock *sk, struct nl_cb *cb)
+{
+ if (cb->cb_recvmsgs_ow)
+ return cb->cb_recvmsgs_ow(sk, cb);
+ else
+ return recvmsgs(sk, cb);
+}
+
+
+static int ack_wait_handler(struct nl_msg *msg, void *arg)
+{
+ return NL_STOP;
+}
+
+/**
+ * Wait for ACK.
+ * @arg sk Netlink socket.
+ * @pre The netlink socket must be in blocking state.
+ *
+ * Waits until an ACK is received for the latest not yet acknowledged
+ * netlink message.
+ */
+int nl_wait_for_ack(struct nl_sock *sk)
+{
+ int err;
+ struct nl_cb *cb;
+
+ cb = nl_cb_clone(sk->s_cb);
+ if (cb == NULL)
+ return -NLE_NOMEM;
+
+ nl_cb_set(cb, NL_CB_ACK, NL_CB_CUSTOM, ack_wait_handler, NULL);
+ err = nl_recvmsgs(sk, cb);
+ nl_cb_put(cb);
+
+ return err;
+}
+
+/** @} */
+
+/** @} */
diff --git a/package/libs/libnl-tiny/src/.svn/text-base/object.c.svn-base b/package/libs/libnl-tiny/src/.svn/text-base/object.c.svn-base
new file mode 100644
index 0000000..f915551
--- /dev/null
+++ b/package/libs/libnl-tiny/src/.svn/text-base/object.c.svn-base
@@ -0,0 +1,279 @@
+/*
+ * lib/object.c Generic Cacheable Object
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
+ */
+
+/**
+ * @ingroup cache
+ * @defgroup object Object
+ * @{
+ */
+
+#include <netlink-local.h>
+#include <netlink/netlink.h>
+#include <netlink/cache.h>
+#include <netlink/object.h>
+#include <netlink/utils.h>
+
+static inline struct nl_object_ops *obj_ops(struct nl_object *obj)
+{
+ if (!obj->ce_ops)
+ BUG();
+
+ return obj->ce_ops;
+}
+
+/**
+ * @name Object Creation/Deletion
+ * @{
+ */
+
+/**
+ * Allocate a new object of kind specified by the operations handle
+ * @arg ops cache operations handle
+ * @return The new object or NULL
+ */
+struct nl_object *nl_object_alloc(struct nl_object_ops *ops)
+{
+ struct nl_object *new;
+
+ if (ops->oo_size < sizeof(*new))
+ BUG();
+
+ new = calloc(1, ops->oo_size);
+ if (!new)
+ return NULL;
+
+ new->ce_refcnt = 1;
+ nl_init_list_head(&new->ce_list);
+
+ new->ce_ops = ops;
+ if (ops->oo_constructor)
+ ops->oo_constructor(new);
+
+ NL_DBG(4, "Allocated new object %p\n", new);
+
+ return new;
+}
+
+#ifdef disabled
+/**
+ * Allocate a new object of kind specified by the name
+ * @arg kind name of object type
+ * @return The new object or nULL
+ */
+int nl_object_alloc_name(const char *kind, struct nl_object **result)
+{
+ struct nl_cache_ops *ops;
+
+ ops = nl_cache_ops_lookup(kind);
+ if (!ops)
+ return -NLE_OPNOTSUPP;
+
+ if (!(*result = nl_object_alloc(ops->co_obj_ops)))
+ return -NLE_NOMEM;
+
+ return 0;
+}
+#endif
+
+struct nl_derived_object {
+ NLHDR_COMMON
+ char data;
+};
+
+/**
+ * Allocate a new object and copy all data from an existing object
+ * @arg obj object to inherite data from
+ * @return The new object or NULL.
+ */
+struct nl_object *nl_object_clone(struct nl_object *obj)
+{
+ struct nl_object *new;
+ struct nl_object_ops *ops = obj_ops(obj);
+ int doff = offsetof(struct nl_derived_object, data);
+ int size;
+
+ new = nl_object_alloc(ops);
+ if (!new)
+ return NULL;
+
+ size = ops->oo_size - doff;
+ if (size < 0)
+ BUG();
+
+ new->ce_ops = obj->ce_ops;
+ new->ce_msgtype = obj->ce_msgtype;
+
+ if (size)
+ memcpy((void *)new + doff, (void *)obj + doff, size);
+
+ if (ops->oo_clone) {
+ if (ops->oo_clone(new, obj) < 0) {
+ nl_object_free(new);
+ return NULL;
+ }
+ } else if (size && ops->oo_free_data)
+ BUG();
+
+ return new;
+}
+
+/**
+ * Free a cacheable object
+ * @arg obj object to free
+ *
+ * @return 0 or a negative error code.
+ */
+void nl_object_free(struct nl_object *obj)
+{
+ struct nl_object_ops *ops = obj_ops(obj);
+
+ if (obj->ce_refcnt > 0)
+ NL_DBG(1, "Warning: Freeing object in use...\n");
+
+ if (obj->ce_cache)
+ nl_cache_remove(obj);
+
+ if (ops->oo_free_data)
+ ops->oo_free_data(obj);
+
+ free(obj);
+
+ NL_DBG(4, "Freed object %p\n", obj);
+}
+
+/** @} */
+
+/**
+ * @name Reference Management
+ * @{
+ */
+
+/** @} */
+
+/**
+ * @name Utillities
+ * @{
+ */
+
+#ifdef disabled
+/**
+ * Dump this object according to the specified parameters
+ * @arg obj object to dump
+ * @arg params dumping parameters
+ */
+void nl_object_dump(struct nl_object *obj, struct nl_dump_params *params)
+{
+ dump_from_ops(obj, params);
+}
+
+/**
+ * Check if the identifiers of two objects are identical
+ * @arg a an object
+ * @arg b another object of same type
+ *
+ * @return true if both objects have equal identifiers, otherwise false.
+ */
+int nl_object_identical(struct nl_object *a, struct nl_object *b)
+{
+ struct nl_object_ops *ops = obj_ops(a);
+ int req_attrs;
+
+ /* Both objects must be of same type */
+ if (ops != obj_ops(b))
+ return 0;
+
+ req_attrs = ops->oo_id_attrs;
+
+ /* Both objects must provide all required attributes to uniquely
+ * identify an object */
+ if ((a->ce_mask & req_attrs) != req_attrs ||
+ (b->ce_mask & req_attrs) != req_attrs)
+ return 0;
+
+ /* Can't judge unless we can compare */
+ if (ops->oo_compare == NULL)
+ return 0;
+
+ return !(ops->oo_compare(a, b, req_attrs, 0));
+}
+
+/**
+ * Compute bitmask representing difference in attribute values
+ * @arg a an object
+ * @arg b another object of same type
+ *
+ * The bitmask returned is specific to an object type, each bit set represents
+ * an attribute which mismatches in either of the two objects. Unavailability
+ * of an attribute in one object and presence in the other is regarded a
+ * mismatch as well.
+ *
+ * @return Bitmask describing differences or 0 if they are completely identical.
+ */
+uint32_t nl_object_diff(struct nl_object *a, struct nl_object *b)
+{
+ struct nl_object_ops *ops = obj_ops(a);
+
+ if (ops != obj_ops(b) || ops->oo_compare == NULL)
+ return UINT_MAX;
+
+ return ops->oo_compare(a, b, ~0, 0);
+}
+
+/**
+ * Match a filter against an object
+ * @arg obj object to check
+ * @arg filter object of same type acting as filter
+ *
+ * @return 1 if the object matches the filter or 0
+ * if no filter procedure is available or if the
+ * filter does not match.
+ */
+int nl_object_match_filter(struct nl_object *obj, struct nl_object *filter)
+{
+ struct nl_object_ops *ops = obj_ops(obj);
+
+ if (ops != obj_ops(filter) || ops->oo_compare == NULL)
+ return 0;
+
+ return !(ops->oo_compare(obj, filter, filter->ce_mask,
+ LOOSE_COMPARISON));
+}
+
+/**
+ * Convert bitmask of attributes to a character string
+ * @arg obj object of same type as attribute bitmask
+ * @arg attrs bitmask of attribute types
+ * @arg buf destination buffer
+ * @arg len length of destination buffer
+ *
+ * Converts the bitmask of attribute types into a list of attribute
+ * names separated by comas.
+ *
+ * @return destination buffer.
+ */
+char *nl_object_attrs2str(struct nl_object *obj, uint32_t attrs,
+ char *buf, size_t len)
+{
+ struct nl_object_ops *ops = obj_ops(obj);
+
+ if (ops->oo_attrs2str != NULL)
+ return ops->oo_attrs2str(attrs, buf, len);
+ else {
+ memset(buf, 0, len);
+ return buf;
+ }
+}
+
+#endif
+
+/** @} */
+
+/** @} */
diff --git a/package/libs/libnl-tiny/src/.svn/text-base/socket.c.svn-base b/package/libs/libnl-tiny/src/.svn/text-base/socket.c.svn-base
new file mode 100644
index 0000000..1429825
--- /dev/null
+++ b/package/libs/libnl-tiny/src/.svn/text-base/socket.c.svn-base
@@ -0,0 +1,406 @@
+/*
+ * lib/socket.c Netlink Socket
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
+ */
+
+/**
+ * @ingroup core
+ * @defgroup socket Socket
+ * @{
+ */
+
+#include <netlink-local.h>
+#include <netlink/netlink.h>
+#include <netlink/utils.h>
+#include <netlink/handlers.h>
+#include <netlink/msg.h>
+#include <netlink/attr.h>
+
+static uint32_t used_ports_map[32];
+
+static uint32_t generate_local_port(void)
+{
+ int i, n;
+ uint32_t pid = getpid() & 0x3FFFFF;
+
+ for (i = 0; i < 32; i++) {
+ if (used_ports_map[i] == 0xFFFFFFFF)
+ continue;
+
+ for (n = 0; n < 32; n++) {
+ if (1UL & (used_ports_map[i] >> n))
+ continue;
+
+ used_ports_map[i] |= (1UL << n);
+ n += (i * 32);
+
+ /* PID_MAX_LIMIT is currently at 2^22, leaving 10 bit
+ * to, i.e. 1024 unique ports per application. */
+ return pid + (n << 22);
+
+ }
+ }
+
+ /* Out of sockets in our own PID namespace, what to do? FIXME */
+ return UINT_MAX;
+}
+
+static void release_local_port(uint32_t port)
+{
+ int nr;
+
+ if (port == UINT_MAX)
+ return;
+
+ nr = port >> 22;
+ used_ports_map[nr / 32] &= ~(1 << nr % 32);
+}
+
+/**
+ * @name Allocation
+ * @{
+ */
+
+static struct nl_sock *__alloc_socket(struct nl_cb *cb)
+{
+ struct nl_sock *sk;
+
+ sk = calloc(1, sizeof(*sk));
+ if (!sk)
+ return NULL;
+
+ sk->s_fd = -1;
+ sk->s_cb = cb;
+ sk->s_local.nl_family = AF_NETLINK;
+ sk->s_peer.nl_family = AF_NETLINK;
+ sk->s_seq_expect = sk->s_seq_next = time(0);
+ sk->s_local.nl_pid = generate_local_port();
+ if (sk->s_local.nl_pid == UINT_MAX) {
+ nl_socket_free(sk);
+ return NULL;
+ }
+
+ return sk;
+}
+
+/**
+ * Allocate new netlink socket
+ *
+ * @return Newly allocated netlink socket or NULL.
+ */
+struct nl_sock *nl_socket_alloc(void)
+{
+ struct nl_cb *cb;
+
+ cb = nl_cb_alloc(NL_CB_DEFAULT);
+ if (!cb)
+ return NULL;
+
+ return __alloc_socket(cb);
+}
+
+/**
+ * Allocate new socket with custom callbacks
+ * @arg cb Callback handler
+ *
+ * The reference to the callback handler is taken into account
+ * automatically, it is released again upon calling nl_socket_free().
+ *
+ *@return Newly allocted socket handle or NULL.
+ */
+struct nl_sock *nl_socket_alloc_cb(struct nl_cb *cb)
+{
+ if (cb == NULL)
+ BUG();
+
+ return __alloc_socket(nl_cb_get(cb));
+}
+
+/**
+ * Free a netlink socket.
+ * @arg sk Netlink socket.
+ */
+void nl_socket_free(struct nl_sock *sk)
+{
+ if (!sk)
+ return;
+
+ if (sk->s_fd >= 0)
+ close(sk->s_fd);
+
+ if (!(sk->s_flags & NL_OWN_PORT))
+ release_local_port(sk->s_local.nl_pid);
+
+ nl_cb_put(sk->s_cb);
+ free(sk);
+}
+
+/** @} */
+
+/**
+ * @name Sequence Numbers
+ * @{
+ */
+
+static int noop_seq_check(struct nl_msg *msg, void *arg)
+{
+ return NL_OK;
+}
+
+
+/**
+ * Disable sequence number checking.
+ * @arg sk Netlink socket.
+ *
+ * Disables checking of sequence numbers on the netlink socket This is
+ * required to allow messages to be processed which were not requested by
+ * a preceding request message, e.g. netlink events.
+ *
+ * @note This function modifies the NL_CB_SEQ_CHECK configuration in
+ * the callback handle associated with the socket.
+ */
+void nl_socket_disable_seq_check(struct nl_sock *sk)
+{
+ nl_cb_set(sk->s_cb, NL_CB_SEQ_CHECK,
+ NL_CB_CUSTOM, noop_seq_check, NULL);
+}
+
+/** @} */
+
+/**
+ * Set local port of socket
+ * @arg sk Netlink socket.
+ * @arg port Local port identifier
+ *
+ * Assigns a local port identifier to the socket. If port is 0
+ * a unique port identifier will be generated automatically.
+ */
+void nl_socket_set_local_port(struct nl_sock *sk, uint32_t port)
+{
+ if (port == 0) {
+ port = generate_local_port();
+ sk->s_flags &= ~NL_OWN_PORT;
+ } else {
+ if (!(sk->s_flags & NL_OWN_PORT))
+ release_local_port(sk->s_local.nl_pid);
+ sk->s_flags |= NL_OWN_PORT;
+ }
+
+ sk->s_local.nl_pid = port;
+}
+
+/** @} */
+
+/**
+ * @name Group Subscriptions
+ * @{
+ */
+
+/**
+ * Join groups
+ * @arg sk Netlink socket
+ * @arg group Group identifier
+ *
+ * Joins the specified groups using the modern socket option which
+ * is available since kernel version 2.6.14. It allows joining an
+ * almost arbitary number of groups without limitation. The list
+ * of groups has to be terminated by 0 (%NFNLGRP_NONE).
+ *
+ * Make sure to use the correct group definitions as the older
+ * bitmask definitions for nl_join_groups() are likely to still
+ * be present for backward compatibility reasons.
+ *
+ * @return 0 on sucess or a negative error code.
+ */
+int nl_socket_add_memberships(struct nl_sock *sk, int group, ...)
+{
+ int err;
+ va_list ap;
+
+ if (sk->s_fd == -1)
+ return -NLE_BAD_SOCK;
+
+ va_start(ap, group);
+
+ while (group != 0) {
+ if (group < 0)
+ return -NLE_INVAL;
+
+ err = setsockopt(sk->s_fd, SOL_NETLINK, NETLINK_ADD_MEMBERSHIP,
+ &group, sizeof(group));
+ if (err < 0)
+ return -nl_syserr2nlerr(errno);
+
+ group = va_arg(ap, int);
+ }
+
+ va_end(ap);
+
+ return 0;
+}
+
+/**
+ * Leave groups
+ * @arg sk Netlink socket
+ * @arg group Group identifier
+ *
+ * Leaves the specified groups using the modern socket option
+ * which is available since kernel version 2.6.14. The list of groups
+ * has to terminated by 0 (%NFNLGRP_NONE).
+ *
+ * @see nl_socket_add_membership
+ * @return 0 on success or a negative error code.
+ */
+int nl_socket_drop_memberships(struct nl_sock *sk, int group, ...)
+{
+ int err;
+ va_list ap;
+
+ if (sk->s_fd == -1)
+ return -NLE_BAD_SOCK;
+
+ va_start(ap, group);
+
+ while (group != 0) {
+ if (group < 0)
+ return -NLE_INVAL;
+
+ err = setsockopt(sk->s_fd, SOL_NETLINK, NETLINK_DROP_MEMBERSHIP,
+ &group, sizeof(group));
+ if (err < 0)
+ return -nl_syserr2nlerr(errno);
+
+ group = va_arg(ap, int);
+ }
+
+ va_end(ap);
+
+ return 0;
+}
+
+
+/** @} */
+
+/**
+ * Set file descriptor of socket to non-blocking state
+ * @arg sk Netlink socket.
+ *
+ * @return 0 on success or a negative error code.
+ */
+int nl_socket_set_nonblocking(struct nl_sock *sk)
+{
+ if (sk->s_fd == -1)
+ return -NLE_BAD_SOCK;
+
+ if (fcntl(sk->s_fd, F_SETFL, O_NONBLOCK) < 0)
+ return -nl_syserr2nlerr(errno);
+
+ return 0;
+}
+
+/** @} */
+
+/**
+ * @name Utilities
+ * @{
+ */
+
+/**
+ * Set socket buffer size of netlink socket.
+ * @arg sk Netlink socket.
+ * @arg rxbuf New receive socket buffer size in bytes.
+ * @arg txbuf New transmit socket buffer size in bytes.
+ *
+ * Sets the socket buffer size of a netlink socket to the specified
+ * values \c rxbuf and \c txbuf. Providing a value of \c 0 assumes a
+ * good default value.
+ *
+ * @note It is not required to call this function prior to nl_connect().
+ * @return 0 on sucess or a negative error code.
+ */
+int nl_socket_set_buffer_size(struct nl_sock *sk, int rxbuf, int txbuf)
+{
+ int err;
+
+ if (rxbuf <= 0)
+ rxbuf = 32768;
+
+ if (txbuf <= 0)
+ txbuf = 32768;
+
+ if (sk->s_fd == -1)
+ return -NLE_BAD_SOCK;
+
+ err = setsockopt(sk->s_fd, SOL_SOCKET, SO_SNDBUF,
+ &txbuf, sizeof(txbuf));
+ if (err < 0)
+ return -nl_syserr2nlerr(errno);
+
+ err = setsockopt(sk->s_fd, SOL_SOCKET, SO_RCVBUF,
+ &rxbuf, sizeof(rxbuf));
+ if (err < 0)
+ return -nl_syserr2nlerr(errno);
+
+ sk->s_flags |= NL_SOCK_BUFSIZE_SET;
+
+ return 0;
+}
+
+/**
+ * Enable/disable credential passing on netlink socket.
+ * @arg sk Netlink socket.
+ * @arg state New state (0 - disabled, 1 - enabled)
+ *
+ * @return 0 on success or a negative error code
+ */
+int nl_socket_set_passcred(struct nl_sock *sk, int state)
+{
+ int err;
+
+ if (sk->s_fd == -1)
+ return -NLE_BAD_SOCK;
+
+ err = setsockopt(sk->s_fd, SOL_SOCKET, SO_PASSCRED,
+ &state, sizeof(state));
+ if (err < 0)
+ return -nl_syserr2nlerr(errno);
+
+ if (state)
+ sk->s_flags |= NL_SOCK_PASSCRED;
+ else
+ sk->s_flags &= ~NL_SOCK_PASSCRED;
+
+ return 0;
+}
+
+/**
+ * Enable/disable receival of additional packet information
+ * @arg sk Netlink socket.
+ * @arg state New state (0 - disabled, 1 - enabled)
+ *
+ * @return 0 on success or a negative error code
+ */
+int nl_socket_recv_pktinfo(struct nl_sock *sk, int state)
+{
+ int err;
+
+ if (sk->s_fd == -1)
+ return -NLE_BAD_SOCK;
+
+ err = setsockopt(sk->s_fd, SOL_NETLINK, NETLINK_PKTINFO,
+ &state, sizeof(state));
+ if (err < 0)
+ return -nl_syserr2nlerr(errno);
+
+ return 0;
+}
+
+/** @} */
+
+/** @} */
diff --git a/package/libs/libnl-tiny/src/.svn/text-base/unl.c.svn-base b/package/libs/libnl-tiny/src/.svn/text-base/unl.c.svn-base
new file mode 100644
index 0000000..b38dab8
--- /dev/null
+++ b/package/libs/libnl-tiny/src/.svn/text-base/unl.c.svn-base
@@ -0,0 +1,290 @@
+#define _GNU_SOURCE
+#include <netlink/netlink.h>
+#include <netlink/genl/genl.h>
+#include <netlink/genl/ctrl.h>
+#include <netlink/genl/family.h>
+#include <sys/types.h>
+#include <net/if.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <linux/nl80211.h>
+
+#include "unl.h"
+
+static int unl_init(struct unl *unl)
+{
+ unl->sock = nl_socket_alloc();
+ if (!unl->sock)
+ return -1;
+
+ return 0;
+}
+
+int unl_genl_init(struct unl *unl, const char *family)
+{
+ memset(unl, 0, sizeof(*unl));
+
+ if (unl_init(unl))
+ goto error_out;
+
+ unl->hdrlen = NLMSG_ALIGN(sizeof(struct genlmsghdr));
+ unl->family_name = strdup(family);
+ if (!unl->family_name)
+ goto error;
+
+ if (genl_connect(unl->sock))
+ goto error;
+
+ if (genl_ctrl_alloc_cache(unl->sock, &unl->cache))
+ goto error;
+
+ unl->family = genl_ctrl_search_by_name(unl->cache, family);
+ if (!unl->family)
+ goto error;
+
+ return 0;
+
+error:
+ unl_free(unl);
+error_out:
+ return -1;
+}
+
+void unl_free(struct unl *unl)
+{
+ if (unl->family_name)
+ free(unl->family_name);
+
+ if (unl->sock)
+ nl_socket_free(unl->sock);
+
+ if (unl->cache)
+ nl_cache_free(unl->cache);
+
+ memset(unl, 0, sizeof(*unl));
+}
+
+static int
+ack_handler(struct nl_msg *msg, void *arg)
+{
+ int *err = arg;
+ *err = 0;
+ return NL_STOP;
+}
+
+static int
+finish_handler(struct nl_msg *msg, void *arg)
+{
+ int *err = arg;
+ *err = 0;
+ return NL_SKIP;
+}
+
+static int
+error_handler(struct sockaddr_nl *nla, struct nlmsgerr *err, void *arg)
+{
+ int *ret = arg;
+ *ret = err->error;
+ return NL_SKIP;
+}
+
+struct nl_msg *unl_genl_msg(struct unl *unl, int cmd, bool dump)
+{
+ struct nl_msg *msg;
+ int flags = 0;
+
+ msg = nlmsg_alloc();
+ if (!msg)
+ goto out;
+
+ if (dump)
+ flags |= NLM_F_DUMP;
+
+ genlmsg_put(msg, NL_AUTO_PID, NL_AUTO_SEQ,
+ genl_family_get_id(unl->family), 0, flags, cmd, 0);
+
+out:
+ return msg;
+}
+
+int unl_genl_request(struct unl *unl, struct nl_msg *msg, unl_cb handler, void *arg)
+{
+ struct nlmsghdr *nlh;
+ struct nl_cb *cb;
+ int err;
+
+ cb = nl_cb_alloc(NL_CB_CUSTOM);
+ nlh = nlmsg_hdr(msg);
+
+ err = nl_send_auto_complete(unl->sock, msg);
+ if (err < 0)
+ goto out;
+
+ err = 1;
+ nl_cb_err(cb, NL_CB_CUSTOM, error_handler, &err);
+ nl_cb_set(cb, NL_CB_FINISH, NL_CB_CUSTOM, finish_handler, &err);
+ nl_cb_set(cb, NL_CB_ACK, NL_CB_CUSTOM, ack_handler, &err);
+ if (handler)
+ nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, handler, arg);
+
+ while (err > 0)
+ nl_recvmsgs(unl->sock, cb);
+
+out:
+ nlmsg_free(msg);
+ nl_cb_put(cb);
+ return err;
+}
+
+static int request_single_cb(struct nl_msg *msg, void *arg)
+{
+ struct nl_msg **dest = arg;
+
+ if (!*dest) {
+ nlmsg_get(msg);
+ *dest = msg;
+ }
+ return NL_SKIP;
+}
+
+int unl_genl_request_single(struct unl *unl, struct nl_msg *msg, struct nl_msg **dest)
+{
+ *dest = NULL;
+ return unl_genl_request(unl, msg, request_single_cb, dest);
+}
+
+static int no_seq_check(struct nl_msg *msg, void *arg)
+{
+ return NL_OK;
+}
+
+void unl_genl_loop(struct unl *unl, unl_cb handler, void *arg)
+{
+ struct nl_cb *cb;
+
+ cb = nl_cb_alloc(NL_CB_CUSTOM);
+ unl->loop_done = false;
+ nl_cb_set(cb, NL_CB_SEQ_CHECK, NL_CB_CUSTOM, no_seq_check, NULL);
+ nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, handler, arg);
+
+ while (!unl->loop_done)
+ nl_recvmsgs(unl->sock, cb);
+
+ nl_cb_put(cb);
+}
+
+int unl_genl_multicast_id(struct unl *unl, const char *name)
+{
+ struct nlattr *tb[CTRL_ATTR_MCAST_GRP_MAX + 1];
+ struct nlattr *groups, *group;
+ struct nl_msg *msg;
+ int ctrlid;
+ int ret = -1;
+ int rem;
+
+ msg = nlmsg_alloc();
+ if (!msg)
+ return -1;
+
+ ctrlid = genl_ctrl_resolve(unl->sock, "nlctrl");
+ genlmsg_put(msg, 0, 0, ctrlid, 0, 0, CTRL_CMD_GETFAMILY, 0);
+ NLA_PUT_STRING(msg, CTRL_ATTR_FAMILY_NAME, unl->family_name);
+ unl_genl_request_single(unl, msg, &msg);
+ if (!msg)
+ return -1;
+
+ groups = unl_find_attr(unl, msg, CTRL_ATTR_MCAST_GROUPS);
+ if (!groups)
+ goto nla_put_failure;
+
+ nla_for_each_nested(group, groups, rem) {
+ const char *gn;
+
+ nla_parse(tb, CTRL_ATTR_MCAST_GRP_MAX, nla_data(group),
+ nla_len(group), NULL);
+
+ if (!tb[CTRL_ATTR_MCAST_GRP_NAME] ||
+ !tb[CTRL_ATTR_MCAST_GRP_ID])
+ continue;
+
+ gn = nla_data(tb[CTRL_ATTR_MCAST_GRP_NAME]);
+ if (strcmp(gn, name) != 0)
+ continue;
+
+ ret = nla_get_u32(tb[CTRL_ATTR_MCAST_GRP_ID]);
+ break;
+ }
+
+nla_put_failure:
+ nlmsg_free(msg);
+ return ret;
+}
+
+int unl_genl_subscribe(struct unl *unl, const char *name)
+{
+ int mcid;
+
+ mcid = unl_genl_multicast_id(unl, name);
+ if (mcid < 0)
+ return mcid;
+
+ return nl_socket_add_membership(unl->sock, mcid);
+}
+
+int unl_genl_unsubscribe(struct unl *unl, const char *name)
+{
+ int mcid;
+
+ mcid = unl_genl_multicast_id(unl, name);
+ if (mcid < 0)
+ return mcid;
+
+ return nl_socket_drop_membership(unl->sock, mcid);
+}
+
+int unl_nl80211_phy_lookup(const char *name)
+{
+ char buf[32];
+ int fd, pos;
+
+ snprintf(buf, sizeof(buf), "/sys/class/ieee80211/%s/index", name);
+
+ fd = open(buf, O_RDONLY);
+ if (fd < 0)
+ return -1;
+ pos = read(fd, buf, sizeof(buf) - 1);
+ if (pos < 0) {
+ close(fd);
+ return -1;
+ }
+ buf[pos] = '\0';
+ close(fd);
+ return atoi(buf);
+}
+
+int unl_nl80211_wdev_to_phy(struct unl *unl, int wdev)
+{
+ struct nl_msg *msg;
+ struct nlattr *attr;
+ int ret = -1;
+
+ msg = unl_genl_msg(unl, NL80211_CMD_GET_INTERFACE, false);
+ if (!msg)
+ return -1;
+
+ NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, wdev);
+ if (unl_genl_request_single(unl, msg, &msg) < 0)
+ return -1;
+
+ attr = unl_find_attr(unl, msg, NL80211_ATTR_WIPHY);
+ if (!attr)
+ goto out;
+
+ ret = nla_get_u32(attr);
+out:
+nla_put_failure:
+ nlmsg_free(msg);
+ return ret;
+}
+
+
diff --git a/package/libs/libnl-tiny/src/Makefile b/package/libs/libnl-tiny/src/Makefile
new file mode 100644
index 0000000..f6f90ec
--- /dev/null
+++ b/package/libs/libnl-tiny/src/Makefile
@@ -0,0 +1,17 @@
+CC=gcc
+WFLAGS=-Wall
+CFLAGS=-O2
+INCLUDES=-Iinclude
+
+LIBNAME=libnl-tiny.so
+
+all: $(LIBNAME)
+
+%.o: %.c
+ $(CC) $(WFLAGS) -c -o $@ $(INCLUDES) $(CFLAGS) $<
+
+LIBNL_OBJ=nl.o handlers.o msg.o attr.o cache.o cache_mngt.o object.o socket.o error.o
+GENL_OBJ=genl.o genl_family.o genl_ctrl.o genl_mngt.o unl.o
+
+$(LIBNAME): $(LIBNL_OBJ) $(GENL_OBJ)
+ $(CC) -shared -o $@ $^
diff --git a/package/libs/libnl-tiny/src/attr.c b/package/libs/libnl-tiny/src/attr.c
new file mode 100644
index 0000000..e0f5061
--- /dev/null
+++ b/package/libs/libnl-tiny/src/attr.c
@@ -0,0 +1,668 @@
+/*
+ * lib/attr.c Netlink Attributes
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
+ */
+
+#include <netlink-local.h>
+#include <netlink/netlink.h>
+#include <netlink/utils.h>
+#include <netlink/addr.h>
+#include <netlink/attr.h>
+#include <netlink/msg.h>
+#include <linux/socket.h>
+
+/**
+ * @ingroup msg
+ * @defgroup attr Attributes
+ * Netlink Attributes Construction/Parsing Interface
+ *
+ * \section attr_sec Netlink Attributes
+ * Netlink attributes allow for data chunks of arbitary length to be
+ * attached to a netlink message. Each attribute is encoded with a
+ * type and length field, both 16 bits, stored in the attribute header
+ * preceding the attribute data. The main advantage of using attributes
+ * over packing everything into the family header is that the interface
+ * stays extendable as new attributes can supersede old attributes while
+ * remaining backwards compatible. Also attributes can be defined optional
+ * thus avoiding the transmission of unnecessary empty data blocks.
+ * Special nested attributes allow for more complex data structures to
+ * be transmitted, e.g. trees, lists, etc.
+ *
+ * While not required, netlink attributes typically follow the family
+ * header of a netlink message and must be properly aligned to NLA_ALIGNTO:
+ * @code
+ * +----------------+- - -+---------------+- - -+------------+- - -+
+ * | Netlink Header | Pad | Family Header | Pad | Attributes | Pad |
+ * +----------------+- - -+---------------+- - -+------------+- - -+
+ * @endcode
+ *
+ * The actual attributes are chained together each separately aligned to
+ * NLA_ALIGNTO. The position of an attribute is defined based on the
+ * length field of the preceding attributes:
+ * @code
+ * +-------------+- - -+-------------+- - -+------
+ * | Attribute 1 | Pad | Attribute 2 | Pad | ...
+ * +-------------+- - -+-------------+- - -+------
+ * nla_next(attr1)------^
+ * @endcode
+ *
+ * The attribute itself consists of the attribute header followed by
+ * the actual payload also aligned to NLA_ALIGNTO. The function nla_data()
+ * returns a pointer to the start of the payload while nla_len() returns
+ * the length of the payload in bytes.
+ *
+ * \b Note: Be aware, NLA_ALIGNTO equals to 4 bytes, therefore it is not
+ * safe to dereference any 64 bit data types directly.
+ *
+ * @code
+ * <----------- nla_total_size(payload) ----------->
+ * <-------- nla_attr_size(payload) --------->
+ * +------------------+- - -+- - - - - - - - - +- - -+
+ * | Attribute Header | Pad | Payload | Pad |
+ * +------------------+- - -+- - - - - - - - - +- - -+
+ * nla_data(nla)-------------^
+ * <- nla_len(nla) ->
+ * @endcode
+ *
+ * @subsection attr_datatypes Attribute Data Types
+ * A number of basic data types are supported to simplify access and
+ * validation of netlink attributes. This data type information is
+ * not encoded in the attribute, both the kernel and userspace part
+ * are required to share this information on their own.
+ *
+ * One of the major advantages of these basic types is the automatic
+ * validation of each attribute based on an attribute policy. The
+ * validation covers most of the checks required to safely use
+ * attributes and thus keeps the individual sanity check to a minimum.
+ *
+ * Never access attribute payload without ensuring basic validation
+ * first, attributes may:
+ * - not be present even though required
+ * - contain less actual payload than expected
+ * - fake a attribute length which exceeds the end of the message
+ * - contain unterminated character strings
+ *
+ * Policies are defined as array of the struct nla_policy. The array is
+ * indexed with the attribute type, therefore the array must be sized
+ * accordingly.
+ * @code
+ * static struct nla_policy my_policy[ATTR_MAX+1] = {
+ * [ATTR_FOO] = { .type = ..., .minlen = ..., .maxlen = ... },
+ * };
+ *
+ * err = nla_validate(attrs, attrlen, ATTR_MAX, &my_policy);
+ * @endcode
+ *
+ * Some basic validations are performed on every attribute, regardless of type.
+ * - If the attribute type exceeds the maximum attribute type specified or
+ * the attribute type is lesser-or-equal than zero, the attribute will
+ * be silently ignored.
+ * - If the payload length falls below the \a minlen value the attribute
+ * will be rejected.
+ * - If \a maxlen is non-zero and the payload length exceeds the \a maxlen
+ * value the attribute will be rejected.
+ *
+ *
+ * @par Unspecific Attribute (NLA_UNSPEC)
+ * This is the standard type if no type is specified. It is used for
+ * binary data of arbitary length. Typically this attribute carries
+ * a binary structure or a stream of bytes.
+ * @par
+ * @code
+ * // In this example, we will assume a binary structure requires to
+ * // be transmitted. The definition of the structure will typically
+ * // go into a header file available to both the kernel and userspace
+ * // side.
+ * //
+ * // Note: Be careful when putting 64 bit data types into a structure.
+ * // The attribute payload is only aligned to 4 bytes, dereferencing
+ * // the member may fail.
+ * struct my_struct {
+ * int a;
+ * int b;
+ * };
+ *
+ * // The validation function will not enforce an exact length match to
+ * // allow structures to grow as required. Note: While it is allowed
+ * // to add members to the end of the structure, changing the order or
+ * // inserting members in the middle of the structure will break your
+ * // binary interface.
+ * static struct nla_policy my_policy[ATTR_MAX+1] = {
+ * [ATTR_MY_STRICT] = { .type = NLA_UNSPEC,
+ * .minlen = sizeof(struct my_struct) },
+ *
+ * // The binary structure is appened to the message using nla_put()
+ * struct my_struct foo = { .a = 1, .b = 2 };
+ * nla_put(msg, ATTR_MY_STRUCT, sizeof(foo), &foo);
+ *
+ * // On the receiving side, a pointer to the structure pointing inside
+ * // the message payload is returned by nla_get().
+ * if (attrs[ATTR_MY_STRUCT])
+ * struct my_struct *foo = nla_get(attrs[ATTR_MY_STRUCT]);
+ * @endcode
+ *
+ * @par Integers (NLA_U8, NLA_U16, NLA_U32, NLA_U64)
+ * Integers come in different sizes from 8 bit to 64 bit. However, since the
+ * payload length is aligned to 4 bytes, integers smaller than 32 bit are
+ * only useful to enforce the maximum range of values.
+ * @par
+ * \b Note: There is no difference made between signed and unsigned integers.
+ * The validation only enforces the minimal payload length required to store
+ * an integer of specified type.
+ * @par
+ * @code
+ * // Even though possible, it does not make sense to specify .minlen or
+ * // .maxlen for integer types. The data types implies the corresponding
+ * // minimal payload length.
+ * static struct nla_policy my_policy[ATTR_MAX+1] = {
+ * [ATTR_FOO] = { .type = NLA_U32 },
+ *
+ * // Numeric values can be appended directly using the respective
+ * // nla_put_uxxx() function
+ * nla_put_u32(msg, ATTR_FOO, 123);
+ *
+ * // Same for the receiving side.
+ * if (attrs[ATTR_FOO])
+ * uint32_t foo = nla_get_u32(attrs[ATTR_FOO]);
+ * @endcode
+ *
+ * @par Character string (NLA_STRING)
+ * This data type represents a NUL terminated character string of variable
+ * length. For binary data streams the type NLA_UNSPEC is recommended.
+ * @par
+ * @code
+ * // Enforce a NUL terminated character string of at most 4 characters
+ * // including the NUL termination.
+ * static struct nla_policy my_policy[ATTR_MAX+1] = {
+ * [ATTR_BAR] = { .type = NLA_STRING, maxlen = 4 },
+ *
+ * // nla_put_string() creates a string attribute of the necessary length
+ * // and appends it to the message including the NUL termination.
+ * nla_put_string(msg, ATTR_BAR, "some text");
+ *
+ * // It is safe to use the returned character string directly if the
+ * // attribute has been validated as the validation enforces the proper
+ * // termination of the string.
+ * if (attrs[ATTR_BAR])
+ * char *text = nla_get_string(attrs[ATTR_BAR]);
+ * @endcode
+ *
+ * @par Flag (NLA_FLAG)
+ * This attribute type may be used to indicate the presence of a flag. The
+ * attribute is only valid if the payload length is zero. The presence of
+ * the attribute header indicates the presence of the flag.
+ * @par
+ * @code
+ * // This attribute type is special as .minlen and .maxlen have no effect.
+ * static struct nla_policy my_policy[ATTR_MAX+1] = {
+ * [ATTR_FLAG] = { .type = NLA_FLAG },
+ *
+ * // nla_put_flag() appends a zero sized attribute to the message.
+ * nla_put_flag(msg, ATTR_FLAG);
+ *
+ * // There is no need for a receival function, the presence is the value.
+ * if (attrs[ATTR_FLAG])
+ * // flag is present
+ * @endcode
+ *
+ * @par Micro Seconds (NLA_MSECS)
+ *
+ * @par Nested Attribute (NLA_NESTED)
+ * Attributes can be nested and put into a container to create groups, lists
+ * or to construct trees of attributes. Nested attributes are often used to
+ * pass attributes to a subsystem where the top layer has no knowledge of the
+ * configuration possibilities of each subsystem.
+ * @par
+ * \b Note: When validating the attributes using nlmsg_validate() or
+ * nlmsg_parse() it will only affect the top level attributes. Each
+ * level of nested attributes must be validated seperately using
+ * nla_parse_nested() or nla_validate().
+ * @par
+ * @code
+ * // The minimal length policy may be used to enforce the presence of at
+ * // least one attribute.
+ * static struct nla_policy my_policy[ATTR_MAX+1] = {
+ * [ATTR_OPTS] = { .type = NLA_NESTED, minlen = NLA_HDRLEN },
+ *
+ * // Nested attributes are constructed by enclosing the attributes
+ * // to be nested with calls to nla_nest_start() respetively nla_nest_end().
+ * struct nlattr *opts = nla_nest_start(msg, ATTR_OPTS);
+ * nla_put_u32(msg, ATTR_FOO, 123);
+ * nla_put_string(msg, ATTR_BAR, "some text");
+ * nla_nest_end(msg, opts);
+ *
+ * // Various methods exist to parse nested attributes, the easiest being
+ * // nla_parse_nested() which also allows validation in the same step.
+ * if (attrs[ATTR_OPTS]) {
+ * struct nlattr *nested[ATTR_MAX+1];
+ *
+ * nla_parse_nested(nested, ATTR_MAX, attrs[ATTR_OPTS], &policy);
+ *
+ * if (nested[ATTR_FOO])
+ * uint32_t foo = nla_get_u32(nested[ATTR_FOO]);
+ * }
+ * @endcode
+ *
+ * @subsection attr_exceptions Exception Based Attribute Construction
+ * Often a large number of attributes are added to a message in a single
+ * function. In order to simplify error handling, a second set of
+ * construction functions exist which jump to a error label when they
+ * fail instead of returning an error code. This second set consists
+ * of macros which are named after their error code based counterpart
+ * except that the name is written all uppercase.
+ *
+ * All of the macros jump to the target \c nla_put_failure if they fail.
+ * @code
+ * void my_func(struct nl_msg *msg)
+ * {
+ * NLA_PUT_U32(msg, ATTR_FOO, 10);
+ * NLA_PUT_STRING(msg, ATTR_BAR, "bar");
+ *
+ * return 0;
+ *
+ * nla_put_failure:
+ * return -NLE_NOMEM;
+ * }
+ * @endcode
+ *
+ * @subsection attr_examples Examples
+ * @par Example 1.1 Constructing a netlink message with attributes.
+ * @code
+ * struct nl_msg *build_msg(int ifindex, struct nl_addr *lladdr, int mtu)
+ * {
+ * struct nl_msg *msg;
+ * struct nlattr *info, *vlan;
+ * struct ifinfomsg ifi = {
+ * .ifi_family = AF_INET,
+ * .ifi_index = ifindex,
+ * };
+ *
+ * // Allocate a new netlink message, type=RTM_SETLINK, flags=NLM_F_ECHO
+ * if (!(msg = nlmsg_alloc_simple(RTM_SETLINK, NLM_F_ECHO)))
+ * return NULL;
+ *
+ * // Append the family specific header (struct ifinfomsg)
+ * if (nlmsg_append(msg, &ifi, sizeof(ifi), NLMSG_ALIGNTO) < 0)
+ * goto nla_put_failure
+ *
+ * // Append a 32 bit integer attribute to carry the MTU
+ * NLA_PUT_U32(msg, IFLA_MTU, mtu);
+ *
+ * // Append a unspecific attribute to carry the link layer address
+ * NLA_PUT_ADDR(msg, IFLA_ADDRESS, lladdr);
+ *
+ * // Append a container for nested attributes to carry link information
+ * if (!(info = nla_nest_start(msg, IFLA_LINKINFO)))
+ * goto nla_put_failure;
+ *
+ * // Put a string attribute into the container
+ * NLA_PUT_STRING(msg, IFLA_INFO_KIND, "vlan");
+ *
+ * // Append another container inside the open container to carry
+ * // vlan specific attributes
+ * if (!(vlan = nla_nest_start(msg, IFLA_INFO_DATA)))
+ * goto nla_put_failure;
+ *
+ * // add vlan specific info attributes here...
+ *
+ * // Finish nesting the vlan attributes and close the second container.
+ * nla_nest_end(msg, vlan);
+ *
+ * // Finish nesting the link info attribute and close the first container.
+ * nla_nest_end(msg, info);
+ *
+ * return msg;
+ *
+ * // If any of the construction macros fails, we end up here.
+ * nla_put_failure:
+ * nlmsg_free(msg);
+ * return NULL;
+ * }
+ * @endcode
+ *
+ * @par Example 2.1 Parsing a netlink message with attributes.
+ * @code
+ * int parse_message(struct nl_msg *msg)
+ * {
+ * // The policy defines two attributes: a 32 bit integer and a container
+ * // for nested attributes.
+ * struct nla_policy attr_policy[ATTR_MAX+1] = {
+ * [ATTR_FOO] = { .type = NLA_U32 },
+ * [ATTR_BAR] = { .type = NLA_NESTED },
+ * };
+ * struct nlattr *attrs[ATTR_MAX+1];
+ * int err;
+ *
+ * // The nlmsg_parse() function will make sure that the message contains
+ * // enough payload to hold the header (struct my_hdr), validates any
+ * // attributes attached to the messages and stores a pointer to each
+ * // attribute in the attrs[] array accessable by attribute type.
+ * if ((err = nlmsg_parse(nlmsg_hdr(msg), sizeof(struct my_hdr), attrs,
+ * ATTR_MAX, attr_policy)) < 0)
+ * goto errout;
+ *
+ * if (attrs[ATTR_FOO]) {
+ * // It is safe to directly access the attribute payload without
+ * // any further checks since nlmsg_parse() enforced the policy.
+ * uint32_t foo = nla_get_u32(attrs[ATTR_FOO]);
+ * }
+ *
+ * if (attrs[ATTR_BAR]) {
+ * struct nlattr *nested[NESTED_MAX+1];
+ *
+ * // Attributes nested in a container can be parsed the same way
+ * // as top level attributes.
+ * if ((err = nla_parse_nested(nested, NESTED_MAX, attrs[ATTR_BAR],
+ * nested_policy)) < 0)
+ * goto errout;
+ *
+ * // Process nested attributes here.
+ * }
+ *
+ * err = 0;
+ * errout:
+ * return err;
+ * }
+ * @endcode
+ *
+ * @{
+ */
+
+/**
+ * @name Attribute Size Calculation
+ * @{
+ */
+
+/** @} */
+
+/**
+ * @name Parsing Attributes
+ * @{
+ */
+
+/**
+ * Check if the attribute header and payload can be accessed safely.
+ * @arg nla Attribute of any kind.
+ * @arg remaining Number of bytes remaining in attribute stream.
+ *
+ * Verifies that the header and payload do not exceed the number of
+ * bytes left in the attribute stream. This function must be called
+ * before access the attribute header or payload when iterating over
+ * the attribute stream using nla_next().
+ *
+ * @return True if the attribute can be accessed safely, false otherwise.
+ */
+int nla_ok(const struct nlattr *nla, int remaining)
+{
+ return remaining >= sizeof(*nla) &&
+ nla->nla_len >= sizeof(*nla) &&
+ nla->nla_len <= remaining;
+}
+
+/**
+ * Return next attribute in a stream of attributes.
+ * @arg nla Attribute of any kind.
+ * @arg remaining Variable to count remaining bytes in stream.
+ *
+ * Calculates the offset to the next attribute based on the attribute
+ * given. The attribute provided is assumed to be accessible, the
+ * caller is responsible to use nla_ok() beforehand. The offset (length
+ * of specified attribute including padding) is then subtracted from
+ * the remaining bytes variable and a pointer to the next attribute is
+ * returned.
+ *
+ * nla_next() can be called as long as remainig is >0.
+ *
+ * @return Pointer to next attribute.
+ */
+struct nlattr *nla_next(const struct nlattr *nla, int *remaining)
+{
+ int totlen = NLA_ALIGN(nla->nla_len);
+
+ *remaining -= totlen;
+ return (struct nlattr *) ((char *) nla + totlen);
+}
+
+static uint16_t nla_attr_minlen[NLA_TYPE_MAX+1] = {
+ [NLA_U8] = sizeof(uint8_t),
+ [NLA_U16] = sizeof(uint16_t),
+ [NLA_U32] = sizeof(uint32_t),
+ [NLA_U64] = sizeof(uint64_t),
+ [NLA_STRING] = 1,
+};
+
+static int validate_nla(struct nlattr *nla, int maxtype,
+ struct nla_policy *policy)
+{
+ struct nla_policy *pt;
+ int minlen = 0, type = nla_type(nla);
+
+ if (type <= 0 || type > maxtype)
+ return 0;
+
+ pt = &policy[type];
+
+ if (pt->type > NLA_TYPE_MAX)
+ BUG();
+
+ if (pt->minlen)
+ minlen = pt->minlen;
+ else if (pt->type != NLA_UNSPEC)
+ minlen = nla_attr_minlen[pt->type];
+
+ if (pt->type == NLA_FLAG && nla_len(nla) > 0)
+ return -NLE_RANGE;
+
+ if (nla_len(nla) < minlen)
+ return -NLE_RANGE;
+
+ if (pt->maxlen && nla_len(nla) > pt->maxlen)
+ return -NLE_RANGE;
+
+ if (pt->type == NLA_STRING) {
+ char *data = nla_data(nla);
+ if (data[nla_len(nla) - 1] != '\0')
+ return -NLE_INVAL;
+ }
+
+ return 0;
+}
+
+
+/**
+ * Create attribute index based on a stream of attributes.
+ * @arg tb Index array to be filled (maxtype+1 elements).
+ * @arg maxtype Maximum attribute type expected and accepted.
+ * @arg head Head of attribute stream.
+ * @arg len Length of attribute stream.
+ * @arg policy Attribute validation policy.
+ *
+ * Iterates over the stream of attributes and stores a pointer to each
+ * attribute in the index array using the attribute type as index to
+ * the array. Attribute with a type greater than the maximum type
+ * specified will be silently ignored in order to maintain backwards
+ * compatibility. If \a policy is not NULL, the attribute will be
+ * validated using the specified policy.
+ *
+ * @see nla_validate
+ * @return 0 on success or a negative error code.
+ */
+int nla_parse(struct nlattr *tb[], int maxtype, struct nlattr *head, int len,
+ struct nla_policy *policy)
+{
+ struct nlattr *nla;
+ int rem, err;
+
+ memset(tb, 0, sizeof(struct nlattr *) * (maxtype + 1));
+
+ nla_for_each_attr(nla, head, len, rem) {
+ int type = nla_type(nla);
+
+ if (type == 0) {
+ fprintf(stderr, "Illegal nla->nla_type == 0\n");
+ continue;
+ }
+
+ if (type <= maxtype) {
+ if (policy) {
+ err = validate_nla(nla, maxtype, policy);
+ if (err < 0)
+ goto errout;
+ }
+
+ tb[type] = nla;
+ }
+ }
+
+ if (rem > 0)
+ fprintf(stderr, "netlink: %d bytes leftover after parsing "
+ "attributes.\n", rem);
+
+ err = 0;
+errout:
+ return err;
+}
+
+/**
+ * Validate a stream of attributes.
+ * @arg head Head of attributes stream.
+ * @arg len Length of attributes stream.
+ * @arg maxtype Maximum attribute type expected and accepted.
+ * @arg policy Validation policy.
+ *
+ * Iterates over the stream of attributes and validates each attribute
+ * one by one using the specified policy. Attributes with a type greater
+ * than the maximum type specified will be silently ignored in order to
+ * maintain backwards compatibility.
+ *
+ * See \ref attr_datatypes for more details on what kind of validation
+ * checks are performed on each attribute data type.
+ *
+ * @return 0 on success or a negative error code.
+ */
+int nla_validate(struct nlattr *head, int len, int maxtype,
+ struct nla_policy *policy)
+{
+ struct nlattr *nla;
+ int rem, err;
+
+ nla_for_each_attr(nla, head, len, rem) {
+ err = validate_nla(nla, maxtype, policy);
+ if (err < 0)
+ goto errout;
+ }
+
+ err = 0;
+errout:
+ return err;
+}
+
+/**
+ * Find a single attribute in a stream of attributes.
+ * @arg head Head of attributes stream.
+ * @arg len Length of attributes stream.
+ * @arg attrtype Attribute type to look for.
+ *
+ * Iterates over the stream of attributes and compares each type with
+ * the type specified. Returns the first attribute which matches the
+ * type.
+ *
+ * @return Pointer to attribute found or NULL.
+ */
+struct nlattr *nla_find(struct nlattr *head, int len, int attrtype)
+{
+ struct nlattr *nla;
+ int rem;
+
+ nla_for_each_attr(nla, head, len, rem)
+ if (nla_type(nla) == attrtype)
+ return nla;
+
+ return NULL;
+}
+
+/** @} */
+
+/**
+ * @name Unspecific Attribute
+ * @{
+ */
+
+/**
+ * Reserve space for a attribute.
+ * @arg msg Netlink Message.
+ * @arg attrtype Attribute Type.
+ * @arg attrlen Length of payload.
+ *
+ * Reserves room for a attribute in the specified netlink message and
+ * fills in the attribute header (type, length). Returns NULL if there
+ * is unsuficient space for the attribute.
+ *
+ * Any padding between payload and the start of the next attribute is
+ * zeroed out.
+ *
+ * @return Pointer to start of attribute or NULL on failure.
+ */
+struct nlattr *nla_reserve(struct nl_msg *msg, int attrtype, int attrlen)
+{
+ struct nlattr *nla;
+ int tlen;
+
+ tlen = NLMSG_ALIGN(msg->nm_nlh->nlmsg_len) + nla_total_size(attrlen);
+
+ if ((tlen + msg->nm_nlh->nlmsg_len) > msg->nm_size)
+ return NULL;
+
+ nla = (struct nlattr *) nlmsg_tail(msg->nm_nlh);
+ nla->nla_type = attrtype;
+ nla->nla_len = nla_attr_size(attrlen);
+
+ memset((unsigned char *) nla + nla->nla_len, 0, nla_padlen(attrlen));
+ msg->nm_nlh->nlmsg_len = tlen;
+
+ NL_DBG(2, "msg %p: Reserved %d bytes at offset +%td for attr %d "
+ "nlmsg_len=%d\n", msg, attrlen,
+ (void *) nla - nlmsg_data(msg->nm_nlh),
+ attrtype, msg->nm_nlh->nlmsg_len);
+
+ return nla;
+}
+
+/**
+ * Add a unspecific attribute to netlink message.
+ * @arg msg Netlink message.
+ * @arg attrtype Attribute type.
+ * @arg datalen Length of data to be used as payload.
+ * @arg data Pointer to data to be used as attribute payload.
+ *
+ * Reserves room for a unspecific attribute and copies the provided data
+ * into the message as payload of the attribute. Returns an error if there
+ * is insufficient space for the attribute.
+ *
+ * @see nla_reserve
+ * @return 0 on success or a negative error code.
+ */
+int nla_put(struct nl_msg *msg, int attrtype, int datalen, const void *data)
+{
+ struct nlattr *nla;
+
+ nla = nla_reserve(msg, attrtype, datalen);
+ if (!nla)
+ return -NLE_NOMEM;
+
+ memcpy(nla_data(nla), data, datalen);
+ NL_DBG(2, "msg %p: Wrote %d bytes at offset +%td for attr %d\n",
+ msg, datalen, (void *) nla - nlmsg_data(msg->nm_nlh), attrtype);
+
+ return 0;
+}
+
+
+
+/** @} */
diff --git a/package/libs/libnl-tiny/src/cache.c b/package/libs/libnl-tiny/src/cache.c
new file mode 100644
index 0000000..0e14574
--- /dev/null
+++ b/package/libs/libnl-tiny/src/cache.c
@@ -0,0 +1,839 @@
+/*
+ * lib/cache.c Caching Module
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
+ */
+
+/**
+ * @ingroup cache_mngt
+ * @defgroup cache Cache
+ *
+ * @code
+ * Cache Management | | Type Specific Cache Operations
+ *
+ * | | +----------------+ +------------+
+ * | request update | | msg_parser |
+ * | | +----------------+ +------------+
+ * +- - - - -^- - - - - - - -^- -|- - - -
+ * nl_cache_update: | | | |
+ * 1) --------- co_request_update ------+ | |
+ * | | |
+ * 2) destroy old cache +----------- pp_cb ---------|---+
+ * | | |
+ * 3) ---------- nl_recvmsgs ----------+ +- cb_valid -+
+ * +--------------+ | | | |
+ * | nl_cache_add |<-----+ + - - -v- -|- - - - - - - - - - -
+ * +--------------+ | | +-------------+
+ * | nl_recvmsgs |
+ * | | +-----|-^-----+
+ * +---v-|---+
+ * | | | nl_recv |
+ * +---------+
+ * | | Core Netlink
+ * @endcode
+ *
+ * @{
+ */
+
+#include <netlink-local.h>
+#include <netlink/netlink.h>
+#include <netlink/cache.h>
+#include <netlink/object.h>
+#include <netlink/utils.h>
+
+/**
+ * @name Access Functions
+ * @{
+ */
+
+#ifdef disabled
+/**
+ * Return the number of items in the cache
+ * @arg cache cache handle
+ */
+int nl_cache_nitems(struct nl_cache *cache)
+{
+ return cache->c_nitems;
+}
+
+/**
+ * Return the number of items matching a filter in the cache
+ * @arg cache Cache object.
+ * @arg filter Filter object.
+ */
+int nl_cache_nitems_filter(struct nl_cache *cache, struct nl_object *filter)
+{
+ struct nl_object_ops *ops;
+ struct nl_object *obj;
+ int nitems = 0;
+
+ if (cache->c_ops == NULL)
+ BUG();
+
+ ops = cache->c_ops->co_obj_ops;
+
+ nl_list_for_each_entry(obj, &cache->c_items, ce_list) {
+ if (filter && !nl_object_match_filter(obj, filter))
+ continue;
+
+ nitems++;
+ }
+
+ return nitems;
+}
+
+/**
+ * Returns \b true if the cache is empty.
+ * @arg cache Cache to check
+ * @return \a true if the cache is empty, otherwise \b false is returned.
+ */
+int nl_cache_is_empty(struct nl_cache *cache)
+{
+ return nl_list_empty(&cache->c_items);
+}
+
+/**
+ * Return the operations set of the cache
+ * @arg cache cache handle
+ */
+struct nl_cache_ops *nl_cache_get_ops(struct nl_cache *cache)
+{
+ return cache->c_ops;
+}
+
+/**
+ * Return the first element in the cache
+ * @arg cache cache handle
+ */
+struct nl_object *nl_cache_get_first(struct nl_cache *cache)
+{
+ if (nl_list_empty(&cache->c_items))
+ return NULL;
+
+ return nl_list_entry(cache->c_items.next,
+ struct nl_object, ce_list);
+}
+
+/**
+ * Return the last element in the cache
+ * @arg cache cache handle
+ */
+struct nl_object *nl_cache_get_last(struct nl_cache *cache)
+{
+ if (nl_list_empty(&cache->c_items))
+ return NULL;
+
+ return nl_list_entry(cache->c_items.prev,
+ struct nl_object, ce_list);
+}
+
+/**
+ * Return the next element in the cache
+ * @arg obj current object
+ */
+struct nl_object *nl_cache_get_next(struct nl_object *obj)
+{
+ if (nl_list_at_tail(obj, &obj->ce_cache->c_items, ce_list))
+ return NULL;
+ else
+ return nl_list_entry(obj->ce_list.next,
+ struct nl_object, ce_list);
+}
+
+/**
+ * Return the previous element in the cache
+ * @arg obj current object
+ */
+struct nl_object *nl_cache_get_prev(struct nl_object *obj)
+{
+ if (nl_list_at_head(obj, &obj->ce_cache->c_items, ce_list))
+ return NULL;
+ else
+ return nl_list_entry(obj->ce_list.prev,
+ struct nl_object, ce_list);
+}
+#endif
+
+/** @} */
+
+/**
+ * @name Cache Creation/Deletion
+ * @{
+ */
+
+/**
+ * Allocate an empty cache
+ * @arg ops cache operations to base the cache on
+ *
+ * @return A newly allocated and initialized cache.
+ */
+struct nl_cache *nl_cache_alloc(struct nl_cache_ops *ops)
+{
+ struct nl_cache *cache;
+
+ cache = calloc(1, sizeof(*cache));
+ if (!cache)
+ return NULL;
+
+ nl_init_list_head(&cache->c_items);
+ cache->c_ops = ops;
+
+ NL_DBG(2, "Allocated cache %p <%s>.\n", cache, nl_cache_name(cache));
+
+ return cache;
+}
+
+int nl_cache_alloc_and_fill(struct nl_cache_ops *ops, struct nl_sock *sock,
+ struct nl_cache **result)
+{
+ struct nl_cache *cache;
+ int err;
+
+ if (!(cache = nl_cache_alloc(ops)))
+ return -NLE_NOMEM;
+
+ if (sock && (err = nl_cache_refill(sock, cache)) < 0) {
+ nl_cache_free(cache);
+ return err;
+ }
+
+ *result = cache;
+ return 0;
+}
+
+#ifdef disabled
+/**
+ * Allocate an empty cache based on type name
+ * @arg kind Name of cache type
+ * @return A newly allocated and initialized cache.
+ */
+int nl_cache_alloc_name(const char *kind, struct nl_cache **result)
+{
+ struct nl_cache_ops *ops;
+ struct nl_cache *cache;
+
+ ops = nl_cache_ops_lookup(kind);
+ if (!ops)
+ return -NLE_NOCACHE;
+
+ if (!(cache = nl_cache_alloc(ops)))
+ return -NLE_NOMEM;
+
+ *result = cache;
+ return 0;
+}
+
+/**
+ * Allocate a new cache containing a subset of a cache
+ * @arg orig Original cache to be based on
+ * @arg filter Filter defining the subset to be filled into new cache
+ * @return A newly allocated cache or NULL.
+ */
+struct nl_cache *nl_cache_subset(struct nl_cache *orig,
+ struct nl_object *filter)
+{
+ struct nl_cache *cache;
+ struct nl_object_ops *ops;
+ struct nl_object *obj;
+
+ if (!filter)
+ BUG();
+
+ cache = nl_cache_alloc(orig->c_ops);
+ if (!cache)
+ return NULL;
+
+ ops = orig->c_ops->co_obj_ops;
+
+ nl_list_for_each_entry(obj, &orig->c_items, ce_list) {
+ if (!nl_object_match_filter(obj, filter))
+ continue;
+
+ nl_cache_add(cache, obj);
+ }
+
+ return cache;
+}
+#endif
+
+/**
+ * Clear a cache.
+ * @arg cache cache to clear
+ *
+ * Removes all elements of a cache.
+ */
+void nl_cache_clear(struct nl_cache *cache)
+{
+ struct nl_object *obj, *tmp;
+
+ NL_DBG(1, "Clearing cache %p <%s>...\n", cache, nl_cache_name(cache));
+
+ nl_list_for_each_entry_safe(obj, tmp, &cache->c_items, ce_list)
+ nl_cache_remove(obj);
+}
+
+/**
+ * Free a cache.
+ * @arg cache Cache to free.
+ *
+ * Removes all elements of a cache and frees all memory.
+ *
+ * @note Use this function if you are working with allocated caches.
+ */
+void nl_cache_free(struct nl_cache *cache)
+{
+ if (!cache)
+ return;
+
+ nl_cache_clear(cache);
+ NL_DBG(1, "Freeing cache %p <%s>...\n", cache, nl_cache_name(cache));
+ free(cache);
+}
+
+/** @} */
+
+/**
+ * @name Cache Modifications
+ * @{
+ */
+
+static int __cache_add(struct nl_cache *cache, struct nl_object *obj)
+{
+ obj->ce_cache = cache;
+
+ nl_list_add_tail(&obj->ce_list, &cache->c_items);
+ cache->c_nitems++;
+
+ NL_DBG(1, "Added %p to cache %p <%s>.\n",
+ obj, cache, nl_cache_name(cache));
+
+ return 0;
+}
+
+/**
+ * Add object to a cache.
+ * @arg cache Cache to add object to
+ * @arg obj Object to be added to the cache
+ *
+ * Adds the given object to the specified cache. The object is cloned
+ * if it has been added to another cache already.
+ *
+ * @return 0 or a negative error code.
+ */
+int nl_cache_add(struct nl_cache *cache, struct nl_object *obj)
+{
+ struct nl_object *new;
+
+ if (cache->c_ops->co_obj_ops != obj->ce_ops)
+ return -NLE_OBJ_MISMATCH;
+
+ if (!nl_list_empty(&obj->ce_list)) {
+ new = nl_object_clone(obj);
+ if (!new)
+ return -NLE_NOMEM;
+ } else {
+ nl_object_get(obj);
+ new = obj;
+ }
+
+ return __cache_add(cache, new);
+}
+
+#ifdef disabled
+/**
+ * Move object from one cache to another
+ * @arg cache Cache to move object to.
+ * @arg obj Object subject to be moved
+ *
+ * Removes the given object from its associated cache if needed
+ * and adds it to the new cache.
+ *
+ * @return 0 on success or a negative error code.
+ */
+int nl_cache_move(struct nl_cache *cache, struct nl_object *obj)
+{
+ if (cache->c_ops->co_obj_ops != obj->ce_ops)
+ return -NLE_OBJ_MISMATCH;
+
+ NL_DBG(3, "Moving object %p to cache %p\n", obj, cache);
+
+ /* Acquire reference, if already in a cache this will be
+ * reverted during removal */
+ nl_object_get(obj);
+
+ if (!nl_list_empty(&obj->ce_list))
+ nl_cache_remove(obj);
+
+ return __cache_add(cache, obj);
+}
+#endif
+
+/**
+ * Removes an object from a cache.
+ * @arg obj Object to remove from its cache
+ *
+ * Removes the object \c obj from the cache it is assigned to, since
+ * an object can only be assigned to one cache at a time, the cache
+ * must ne be passed along with it.
+ */
+void nl_cache_remove(struct nl_object *obj)
+{
+ struct nl_cache *cache = obj->ce_cache;
+
+ if (cache == NULL)
+ return;
+
+ nl_list_del(&obj->ce_list);
+ obj->ce_cache = NULL;
+ nl_object_put(obj);
+ cache->c_nitems--;
+
+ NL_DBG(1, "Deleted %p from cache %p <%s>.\n",
+ obj, cache, nl_cache_name(cache));
+}
+
+#ifdef disabled
+/**
+ * Search for an object in a cache
+ * @arg cache Cache to search in.
+ * @arg needle Object to look for.
+ *
+ * Iterates over the cache and looks for an object with identical
+ * identifiers as the needle.
+ *
+ * @return Reference to object or NULL if not found.
+ * @note The returned object must be returned via nl_object_put().
+ */
+struct nl_object *nl_cache_search(struct nl_cache *cache,
+ struct nl_object *needle)
+{
+ struct nl_object *obj;
+
+ nl_list_for_each_entry(obj, &cache->c_items, ce_list) {
+ if (nl_object_identical(obj, needle)) {
+ nl_object_get(obj);
+ return obj;
+ }
+ }
+
+ return NULL;
+}
+#endif
+
+/** @} */
+
+/**
+ * @name Synchronization
+ * @{
+ */
+
+/**
+ * Request a full dump from the kernel to fill a cache
+ * @arg sk Netlink socket.
+ * @arg cache Cache subjected to be filled.
+ *
+ * Send a dumping request to the kernel causing it to dump all objects
+ * related to the specified cache to the netlink socket.
+ *
+ * Use nl_cache_pickup() to read the objects from the socket and fill them
+ * into a cache.
+ */
+int nl_cache_request_full_dump(struct nl_sock *sk, struct nl_cache *cache)
+{
+ NL_DBG(2, "Requesting dump from kernel for cache %p <%s>...\n",
+ cache, nl_cache_name(cache));
+
+ if (cache->c_ops->co_request_update == NULL)
+ return -NLE_OPNOTSUPP;
+
+ return cache->c_ops->co_request_update(cache, sk);
+}
+
+/** @cond SKIP */
+struct update_xdata {
+ struct nl_cache_ops *ops;
+ struct nl_parser_param *params;
+};
+
+static int update_msg_parser(struct nl_msg *msg, void *arg)
+{
+ struct update_xdata *x = arg;
+
+ return nl_cache_parse(x->ops, &msg->nm_src, msg->nm_nlh, x->params);
+}
+/** @endcond */
+
+int __cache_pickup(struct nl_sock *sk, struct nl_cache *cache,
+ struct nl_parser_param *param)
+{
+ int err;
+ struct nl_cb *cb;
+ struct update_xdata x = {
+ .ops = cache->c_ops,
+ .params = param,
+ };
+
+ NL_DBG(1, "Picking up answer for cache %p <%s>...\n",
+ cache, nl_cache_name(cache));
+
+ cb = nl_cb_clone(sk->s_cb);
+ if (cb == NULL)
+ return -NLE_NOMEM;
+
+ nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, update_msg_parser, &x);
+
+ err = nl_recvmsgs(sk, cb);
+ if (err < 0)
+ NL_DBG(2, "While picking up for %p <%s>, recvmsgs() returned " \
+ "%d: %s", cache, nl_cache_name(cache),
+ err, nl_geterror(err));
+
+ nl_cb_put(cb);
+
+ return err;
+}
+
+static int pickup_cb(struct nl_object *c, struct nl_parser_param *p)
+{
+ return nl_cache_add((struct nl_cache *) p->pp_arg, c);
+}
+
+/**
+ * Pickup a netlink dump response and put it into a cache.
+ * @arg sk Netlink socket.
+ * @arg cache Cache to put items into.
+ *
+ * Waits for netlink messages to arrive, parses them and puts them into
+ * the specified cache.
+ *
+ * @return 0 on success or a negative error code.
+ */
+int nl_cache_pickup(struct nl_sock *sk, struct nl_cache *cache)
+{
+ struct nl_parser_param p = {
+ .pp_cb = pickup_cb,
+ .pp_arg = cache,
+ };
+
+ return __cache_pickup(sk, cache, &p);
+}
+
+#ifdef disabled
+static int cache_include(struct nl_cache *cache, struct nl_object *obj,
+ struct nl_msgtype *type, change_func_t cb)
+{
+ struct nl_object *old;
+
+ switch (type->mt_act) {
+ case NL_ACT_NEW:
+ case NL_ACT_DEL:
+ old = nl_cache_search(cache, obj);
+ if (old) {
+ nl_cache_remove(old);
+ if (type->mt_act == NL_ACT_DEL) {
+ if (cb)
+ cb(cache, old, NL_ACT_DEL);
+ nl_object_put(old);
+ }
+ }
+
+ if (type->mt_act == NL_ACT_NEW) {
+ nl_cache_move(cache, obj);
+ if (old == NULL && cb)
+ cb(cache, obj, NL_ACT_NEW);
+ else if (old) {
+ if (nl_object_diff(old, obj) && cb)
+ cb(cache, obj, NL_ACT_CHANGE);
+
+ nl_object_put(old);
+ }
+ }
+ break;
+ default:
+ NL_DBG(2, "Unknown action associated to object %p\n", obj);
+ return 0;
+ }
+
+ return 0;
+}
+
+int nl_cache_include(struct nl_cache *cache, struct nl_object *obj,
+ change_func_t change_cb)
+{
+ struct nl_cache_ops *ops = cache->c_ops;
+ int i;
+
+ if (ops->co_obj_ops != obj->ce_ops)
+ return -NLE_OBJ_MISMATCH;
+
+ for (i = 0; ops->co_msgtypes[i].mt_id >= 0; i++)
+ if (ops->co_msgtypes[i].mt_id == obj->ce_msgtype)
+ return cache_include(cache, obj, &ops->co_msgtypes[i],
+ change_cb);
+
+ return -NLE_MSGTYPE_NOSUPPORT;
+}
+
+static int resync_cb(struct nl_object *c, struct nl_parser_param *p)
+{
+ struct nl_cache_assoc *ca = p->pp_arg;
+
+ return nl_cache_include(ca->ca_cache, c, ca->ca_change);
+}
+
+int nl_cache_resync(struct nl_sock *sk, struct nl_cache *cache,
+ change_func_t change_cb)
+{
+ struct nl_object *obj, *next;
+ struct nl_cache_assoc ca = {
+ .ca_cache = cache,
+ .ca_change = change_cb,
+ };
+ struct nl_parser_param p = {
+ .pp_cb = resync_cb,
+ .pp_arg = &ca,
+ };
+ int err;
+
+ NL_DBG(1, "Resyncing cache %p <%s>...\n", cache, nl_cache_name(cache));
+
+ /* Mark all objects so we can see if some of them are obsolete */
+ nl_cache_mark_all(cache);
+
+ err = nl_cache_request_full_dump(sk, cache);
+ if (err < 0)
+ goto errout;
+
+ err = __cache_pickup(sk, cache, &p);
+ if (err < 0)
+ goto errout;
+
+ nl_list_for_each_entry_safe(obj, next, &cache->c_items, ce_list)
+ if (nl_object_is_marked(obj))
+ nl_cache_remove(obj);
+
+ NL_DBG(1, "Finished resyncing %p <%s>\n", cache, nl_cache_name(cache));
+
+ err = 0;
+errout:
+ return err;
+}
+#endif
+
+/** @} */
+
+/**
+ * @name Parsing
+ * @{
+ */
+
+/** @cond SKIP */
+int nl_cache_parse(struct nl_cache_ops *ops, struct sockaddr_nl *who,
+ struct nlmsghdr *nlh, struct nl_parser_param *params)
+{
+ int i, err;
+
+ if (!nlmsg_valid_hdr(nlh, ops->co_hdrsize))
+ return -NLE_MSG_TOOSHORT;
+
+ for (i = 0; ops->co_msgtypes[i].mt_id >= 0; i++) {
+ if (ops->co_msgtypes[i].mt_id == nlh->nlmsg_type) {
+ err = ops->co_msg_parser(ops, who, nlh, params);
+ if (err != -NLE_OPNOTSUPP)
+ goto errout;
+ }
+ }
+
+
+ err = -NLE_MSGTYPE_NOSUPPORT;
+errout:
+ return err;
+}
+/** @endcond */
+
+/**
+ * Parse a netlink message and add it to the cache.
+ * @arg cache cache to add element to
+ * @arg msg netlink message
+ *
+ * Parses a netlink message by calling the cache specific message parser
+ * and adds the new element to the cache.
+ *
+ * @return 0 or a negative error code.
+ */
+int nl_cache_parse_and_add(struct nl_cache *cache, struct nl_msg *msg)
+{
+ struct nl_parser_param p = {
+ .pp_cb = pickup_cb,
+ .pp_arg = cache,
+ };
+
+ return nl_cache_parse(cache->c_ops, NULL, nlmsg_hdr(msg), &p);
+}
+
+/**
+ * (Re)fill a cache with the contents in the kernel.
+ * @arg sk Netlink socket.
+ * @arg cache cache to update
+ *
+ * Clears the specified cache and fills it with the current state in
+ * the kernel.
+ *
+ * @return 0 or a negative error code.
+ */
+int nl_cache_refill(struct nl_sock *sk, struct nl_cache *cache)
+{
+ int err;
+
+ err = nl_cache_request_full_dump(sk, cache);
+ if (err < 0)
+ return err;
+
+ NL_DBG(2, "Upading cache %p <%s>, request sent, waiting for dump...\n",
+ cache, nl_cache_name(cache));
+ nl_cache_clear(cache);
+
+ return nl_cache_pickup(sk, cache);
+}
+
+/** @} */
+#ifdef disabled
+
+/**
+ * @name Utillities
+ * @{
+ */
+
+/**
+ * Mark all objects in a cache
+ * @arg cache Cache to mark all objects in
+ */
+void nl_cache_mark_all(struct nl_cache *cache)
+{
+ struct nl_object *obj;
+
+ NL_DBG(2, "Marking all objects in cache %p <%s>...\n",
+ cache, nl_cache_name(cache));
+
+ nl_list_for_each_entry(obj, &cache->c_items, ce_list)
+ nl_object_mark(obj);
+}
+
+/** @} */
+
+/**
+ * @name Dumping
+ * @{
+ */
+/**
+ * Dump all elements of a cache.
+ * @arg cache cache to dump
+ * @arg params dumping parameters
+ *
+ * Dumps all elements of the \a cache to the file descriptor \a fd.
+ */
+void nl_cache_dump(struct nl_cache *cache, struct nl_dump_params *params)
+{
+ nl_cache_dump_filter(cache, params, NULL);
+}
+
+/**
+ * Dump all elements of a cache (filtered).
+ * @arg cache cache to dump
+ * @arg params dumping parameters (optional)
+ * @arg filter filter object
+ *
+ * Dumps all elements of the \a cache to the file descriptor \a fd
+ * given they match the given filter \a filter.
+ */
+void nl_cache_dump_filter(struct nl_cache *cache,
+ struct nl_dump_params *params,
+ struct nl_object *filter)
+{
+ int type = params ? params->dp_type : NL_DUMP_DETAILS;
+ struct nl_object_ops *ops;
+ struct nl_object *obj;
+
+ NL_DBG(2, "Dumping cache %p <%s> filter %p\n",
+ cache, nl_cache_name(cache), filter);
+
+ if (type > NL_DUMP_MAX || type < 0)
+ BUG();
+
+ if (cache->c_ops == NULL)
+ BUG();
+
+ ops = cache->c_ops->co_obj_ops;
+ if (!ops->oo_dump[type])
+ return;
+
+ nl_list_for_each_entry(obj, &cache->c_items, ce_list) {
+ if (filter && !nl_object_match_filter(obj, filter))
+ continue;
+
+ NL_DBG(4, "Dumping object %p...\n", obj);
+ dump_from_ops(obj, params);
+ }
+}
+
+/** @} */
+
+/**
+ * @name Iterators
+ * @{
+ */
+
+/**
+ * Call a callback on each element of the cache.
+ * @arg cache cache to iterate on
+ * @arg cb callback function
+ * @arg arg argument passed to callback function
+ *
+ * Calls a callback function \a cb on each element of the \a cache.
+ * The argument \a arg is passed on the callback function.
+ */
+void nl_cache_foreach(struct nl_cache *cache,
+ void (*cb)(struct nl_object *, void *), void *arg)
+{
+ nl_cache_foreach_filter(cache, NULL, cb, arg);
+}
+
+/**
+ * Call a callback on each element of the cache (filtered).
+ * @arg cache cache to iterate on
+ * @arg filter filter object
+ * @arg cb callback function
+ * @arg arg argument passed to callback function
+ *
+ * Calls a callback function \a cb on each element of the \a cache
+ * that matches the \a filter. The argument \a arg is passed on
+ * to the callback function.
+ */
+void nl_cache_foreach_filter(struct nl_cache *cache, struct nl_object *filter,
+ void (*cb)(struct nl_object *, void *), void *arg)
+{
+ struct nl_object *obj, *tmp;
+ struct nl_object_ops *ops;
+
+ if (cache->c_ops == NULL)
+ BUG();
+
+ ops = cache->c_ops->co_obj_ops;
+
+ nl_list_for_each_entry_safe(obj, tmp, &cache->c_items, ce_list) {
+ if (filter && !nl_object_match_filter(obj, filter))
+ continue;
+
+ cb(obj, arg);
+ }
+}
+
+/** @} */
+#endif
+
+/** @} */
diff --git a/package/libs/libnl-tiny/src/cache_mngt.c b/package/libs/libnl-tiny/src/cache_mngt.c
new file mode 100644
index 0000000..5c32d2a
--- /dev/null
+++ b/package/libs/libnl-tiny/src/cache_mngt.c
@@ -0,0 +1,253 @@
+/*
+ * lib/cache_mngt.c Cache Management
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
+ */
+
+/**
+ * @ingroup core
+ * @defgroup cache_mngt Caching
+ * @{
+ */
+
+#include <netlink-local.h>
+#include <netlink/netlink.h>
+#include <netlink/cache.h>
+#include <netlink/utils.h>
+
+static struct nl_cache_ops *cache_ops;
+
+/**
+ * @name Cache Operations Sets
+ * @{
+ */
+
+/**
+ * Lookup the set cache operations of a certain cache type
+ * @arg name name of the cache type
+ *
+ * @return The cache operations or NULL if no operations
+ * have been registered under the specified name.
+ */
+struct nl_cache_ops *nl_cache_ops_lookup(const char *name)
+{
+ struct nl_cache_ops *ops;
+
+ for (ops = cache_ops; ops; ops = ops->co_next)
+ if (!strcmp(ops->co_name, name))
+ return ops;
+
+ return NULL;
+}
+
+/**
+ * Associate a message type to a set of cache operations
+ * @arg protocol netlink protocol
+ * @arg msgtype netlink message type
+ *
+ * Associates the specified netlink message type with
+ * a registered set of cache operations.
+ *
+ * @return The cache operations or NULL if no association
+ * could be made.
+ */
+struct nl_cache_ops *nl_cache_ops_associate(int protocol, int msgtype)
+{
+ int i;
+ struct nl_cache_ops *ops;
+
+ for (ops = cache_ops; ops; ops = ops->co_next) {
+ if (ops->co_protocol != protocol)
+ continue;
+
+ for (i = 0; ops->co_msgtypes[i].mt_id >= 0; i++)
+ if (ops->co_msgtypes[i].mt_id == msgtype)
+ return ops;
+ }
+
+ return NULL;
+}
+
+#ifdef disabled
+
+/**
+ * Lookup message type cache association
+ * @arg ops cache operations
+ * @arg msgtype netlink message type
+ *
+ * Searches for a matching message type association ing the specified
+ * cache operations.
+ *
+ * @return A message type association or NULL.
+ */
+struct nl_msgtype *nl_msgtype_lookup(struct nl_cache_ops *ops, int msgtype)
+{
+ int i;
+
+ for (i = 0; ops->co_msgtypes[i].mt_id >= 0; i++)
+ if (ops->co_msgtypes[i].mt_id == msgtype)
+ return &ops->co_msgtypes[i];
+
+ return NULL;
+}
+
+static struct nl_cache_ops *cache_ops_lookup_for_obj(struct nl_object_ops *obj_ops)
+{
+ struct nl_cache_ops *ops;
+
+ for (ops = cache_ops; ops; ops = ops->co_next)
+ if (ops->co_obj_ops == obj_ops)
+ return ops;
+
+ return NULL;
+
+}
+
+/**
+ * Call a function for each registered cache operation
+ * @arg cb Callback function to be called
+ * @arg arg User specific argument.
+ */
+void nl_cache_ops_foreach(void (*cb)(struct nl_cache_ops *, void *), void *arg)
+{
+ struct nl_cache_ops *ops;
+
+ for (ops = cache_ops; ops; ops = ops->co_next)
+ cb(ops, arg);
+}
+#endif
+
+/**
+ * Register a set of cache operations
+ * @arg ops cache operations
+ *
+ * Called by users of caches to announce the avaibility of
+ * a certain cache type.
+ *
+ * @return 0 on success or a negative error code.
+ */
+int nl_cache_mngt_register(struct nl_cache_ops *ops)
+{
+ if (!ops->co_name || !ops->co_obj_ops)
+ return -NLE_INVAL;
+
+ if (nl_cache_ops_lookup(ops->co_name))
+ return -NLE_EXIST;
+
+ ops->co_next = cache_ops;
+ cache_ops = ops;
+
+ NL_DBG(1, "Registered cache operations %s\n", ops->co_name);
+
+ return 0;
+}
+
+/**
+ * Unregister a set of cache operations
+ * @arg ops cache operations
+ *
+ * Called by users of caches to announce a set of
+ * cache operations is no longer available. The
+ * specified cache operations must have been registered
+ * previously using nl_cache_mngt_register()
+ *
+ * @return 0 on success or a negative error code
+ */
+int nl_cache_mngt_unregister(struct nl_cache_ops *ops)
+{
+ struct nl_cache_ops *t, **tp;
+
+ for (tp = &cache_ops; (t=*tp) != NULL; tp = &t->co_next)
+ if (t == ops)
+ break;
+
+ if (!t)
+ return -NLE_NOCACHE;
+
+ NL_DBG(1, "Unregistered cache operations %s\n", ops->co_name);
+
+ *tp = t->co_next;
+ return 0;
+}
+
+/** @} */
+
+/**
+ * @name Global Cache Provisioning/Requiring
+ * @{
+ */
+#ifdef disabled
+/**
+ * Provide a cache for global use
+ * @arg cache cache to provide
+ *
+ * Offers the specified cache to be used by other modules.
+ * Only one cache per type may be shared at a time,
+ * a previsouly provided caches will be overwritten.
+ */
+void nl_cache_mngt_provide(struct nl_cache *cache)
+{
+ struct nl_cache_ops *ops;
+
+ ops = cache_ops_lookup_for_obj(cache->c_ops->co_obj_ops);
+ if (!ops)
+ BUG();
+ else
+ ops->co_major_cache = cache;
+}
+
+/**
+ * Unprovide a cache for global use
+ * @arg cache cache to unprovide
+ *
+ * Cancels the offer to use a cache globally. The
+ * cache will no longer be returned via lookups but
+ * may still be in use.
+ */
+void nl_cache_mngt_unprovide(struct nl_cache *cache)
+{
+ struct nl_cache_ops *ops;
+
+ ops = cache_ops_lookup_for_obj(cache->c_ops->co_obj_ops);
+ if (!ops)
+ BUG();
+ else if (ops->co_major_cache == cache)
+ ops->co_major_cache = NULL;
+}
+
+/**
+ * Demand the use of a global cache
+ * @arg name name of the required object type
+ *
+ * Trys to find a cache of the specified type for global
+ * use.
+ *
+ * @return A cache provided by another subsystem of the
+ * specified type marked to be available.
+ */
+struct nl_cache *nl_cache_mngt_require(const char *name)
+{
+ struct nl_cache_ops *ops;
+
+ ops = nl_cache_ops_lookup(name);
+ if (!ops || !ops->co_major_cache) {
+ fprintf(stderr, "Application BUG: Your application must "
+ "call nl_cache_mngt_provide() and\nprovide a valid "
+ "%s cache to be used for internal lookups.\nSee the "
+ " API documentation for more details.\n", name);
+
+ return NULL;
+ }
+
+ return ops->co_major_cache;
+}
+
+#endif
+/** @} */
+
+/** @} */
diff --git a/package/libs/libnl-tiny/src/error.c b/package/libs/libnl-tiny/src/error.c
new file mode 100644
index 0000000..71ae722
--- /dev/null
+++ b/package/libs/libnl-tiny/src/error.c
@@ -0,0 +1,108 @@
+/*
+ * lib/error.c Error Handling
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2008 Thomas Graf <tgraf@suug.ch>
+ */
+
+#include <netlink-local.h>
+#include <netlink/netlink.h>
+
+static const char *errmsg[NLE_MAX+1] = {
+[NLE_SUCCESS] = "Success",
+[NLE_FAILURE] = "Unspecific failure",
+[NLE_INTR] = "Interrupted system call",
+[NLE_BAD_SOCK] = "Bad socket",
+[NLE_AGAIN] = "Try again",
+[NLE_NOMEM] = "Out of memory",
+[NLE_EXIST] = "Object exists",
+[NLE_INVAL] = "Invalid input data or parameter",
+[NLE_RANGE] = "Input data out of range",
+[NLE_MSGSIZE] = "Message size not sufficient",
+[NLE_OPNOTSUPP] = "Operation not supported",
+[NLE_AF_NOSUPPORT] = "Address family not supported",
+[NLE_OBJ_NOTFOUND] = "Object not found",
+[NLE_NOATTR] = "Attribute not available",
+[NLE_MISSING_ATTR] = "Missing attribute",
+[NLE_AF_MISMATCH] = "Address family mismatch",
+[NLE_SEQ_MISMATCH] = "Message sequence number mismatch",
+[NLE_MSG_OVERFLOW] = "Kernel reported message overflow",
+[NLE_MSG_TRUNC] = "Kernel reported truncated message",
+[NLE_NOADDR] = "Invalid address for specified address family",
+[NLE_SRCRT_NOSUPPORT] = "Source based routing not supported",
+[NLE_MSG_TOOSHORT] = "Netlink message is too short",
+[NLE_MSGTYPE_NOSUPPORT] = "Netlink message type is not supported",
+[NLE_OBJ_MISMATCH] = "Object type does not match cache",
+[NLE_NOCACHE] = "Unknown or invalid cache type",
+[NLE_BUSY] = "Object busy",
+[NLE_PROTO_MISMATCH] = "Protocol mismatch",
+[NLE_NOACCESS] = "No Access",
+[NLE_PERM] = "Operation not permitted",
+};
+
+/**
+ * Return error message for an error code
+ * @return error message
+ */
+const char *nl_geterror(int error)
+{
+ error = abs(error);
+
+ if (error > NLE_MAX)
+ error = NLE_FAILURE;
+
+ return errmsg[error];
+}
+
+/**
+ * Print a libnl error message
+ * @arg s error message prefix
+ *
+ * Prints the error message of the call that failed last.
+ *
+ * If s is not NULL and *s is not a null byte the argument
+ * string is printed, followed by a colon and a blank. Then
+ * the error message and a new-line.
+ */
+void nl_perror(int error, const char *s)
+{
+ if (s && *s)
+ fprintf(stderr, "%s: %s\n", s, nl_geterror(error));
+ else
+ fprintf(stderr, "%s\n", nl_geterror(error));
+}
+
+int nl_syserr2nlerr(int error)
+{
+ error = abs(error);
+
+ switch (error) {
+ case EBADF: return NLE_BAD_SOCK;
+ case EADDRINUSE: return NLE_EXIST;
+ case EEXIST: return NLE_EXIST;
+ case EADDRNOTAVAIL: return NLE_NOADDR;
+ case ENOENT: return NLE_OBJ_NOTFOUND;
+ case EINTR: return NLE_INTR;
+ case EAGAIN: return NLE_AGAIN;
+ case ENOTSOCK: return NLE_BAD_SOCK;
+ case ENOPROTOOPT: return NLE_INVAL;
+ case EFAULT: return NLE_INVAL;
+ case EACCES: return NLE_NOACCESS;
+ case EINVAL: return NLE_INVAL;
+ case ENOBUFS: return NLE_NOMEM;
+ case ENOMEM: return NLE_NOMEM;
+ case EAFNOSUPPORT: return NLE_AF_NOSUPPORT;
+ case EPROTONOSUPPORT: return NLE_PROTO_MISMATCH;
+ case EOPNOTSUPP: return NLE_OPNOTSUPP;
+ case EPERM: return NLE_PERM;
+ case EBUSY: return NLE_BUSY;
+ default: return NLE_FAILURE;
+ }
+}
+
+/** @} */
+
diff --git a/package/libs/libnl-tiny/src/genl.c b/package/libs/libnl-tiny/src/genl.c
new file mode 100644
index 0000000..055be91
--- /dev/null
+++ b/package/libs/libnl-tiny/src/genl.c
@@ -0,0 +1,268 @@
+/*
+ * lib/genl/genl.c Generic Netlink
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
+ */
+
+/**
+ * @defgroup genl Generic Netlink
+ *
+ * @par Message Format
+ * @code
+ * <------- NLMSG_ALIGN(hlen) ------> <---- NLMSG_ALIGN(len) --->
+ * +----------------------------+- - -+- - - - - - - - - - -+- - -+
+ * | Header | Pad | Payload | Pad |
+ * | struct nlmsghdr | | | |
+ * +----------------------------+- - -+- - - - - - - - - - -+- - -+
+ * @endcode
+ * @code
+ * <-------- GENL_HDRLEN -------> <--- hdrlen -->
+ * <------- genlmsg_len(ghdr) ------>
+ * +------------------------+- - -+---------------+- - -+------------+
+ * | Generic Netlink Header | Pad | Family Header | Pad | Attributes |
+ * | struct genlmsghdr | | | | |
+ * +------------------------+- - -+---------------+- - -+------------+
+ * genlmsg_data(ghdr)--------------^ ^
+ * genlmsg_attrdata(ghdr, hdrlen)-------------------------
+ * @endcode
+ *
+ * @par Example
+ * @code
+ * #include <netlink/netlink.h>
+ * #include <netlink/genl/genl.h>
+ * #include <netlink/genl/ctrl.h>
+ *
+ * struct nl_sock *sock;
+ * struct nl_msg *msg;
+ * int family;
+ *
+ * // Allocate a new netlink socket
+ * sock = nl_socket_alloc();
+ *
+ * // Connect to generic netlink socket on kernel side
+ * genl_connect(sock);
+ *
+ * // Ask kernel to resolve family name to family id
+ * family = genl_ctrl_resolve(sock, "generic_netlink_family_name");
+ *
+ * // Construct a generic netlink by allocating a new message, fill in
+ * // the header and append a simple integer attribute.
+ * msg = nlmsg_alloc();
+ * genlmsg_put(msg, NL_AUTO_PID, NL_AUTO_SEQ, family, 0, NLM_F_ECHO,
+ * CMD_FOO_GET, FOO_VERSION);
+ * nla_put_u32(msg, ATTR_FOO, 123);
+ *
+ * // Send message over netlink socket
+ * nl_send_auto_complete(sock, msg);
+ *
+ * // Free message
+ * nlmsg_free(msg);
+ *
+ * // Prepare socket to receive the answer by specifying the callback
+ * // function to be called for valid messages.
+ * nl_socket_modify_cb(sock, NL_CB_VALID, NL_CB_CUSTOM, parse_cb, NULL);
+ *
+ * // Wait for the answer and receive it
+ * nl_recvmsgs_default(sock);
+ *
+ * static int parse_cb(struct nl_msg *msg, void *arg)
+ * {
+ * struct nlmsghdr *nlh = nlmsg_hdr(msg);
+ * struct nlattr *attrs[ATTR_MAX+1];
+ *
+ * // Validate message and parse attributes
+ * genlmsg_parse(nlh, 0, attrs, ATTR_MAX, policy);
+ *
+ * if (attrs[ATTR_FOO]) {
+ * uint32_t value = nla_get_u32(attrs[ATTR_FOO]);
+ * ...
+ * }
+ *
+ * return 0;
+ * }
+ * @endcode
+ * @{
+ */
+
+#include <netlink-generic.h>
+#include <netlink/netlink.h>
+#include <netlink/genl/genl.h>
+#include <netlink/utils.h>
+
+/**
+ * @name Socket Creating
+ * @{
+ */
+
+int genl_connect(struct nl_sock *sk)
+{
+ return nl_connect(sk, NETLINK_GENERIC);
+}
+
+/** @} */
+
+/**
+ * @name Sending
+ * @{
+ */
+
+/**
+ * Send trivial generic netlink message
+ * @arg sk Netlink socket.
+ * @arg family Generic netlink family
+ * @arg cmd Command
+ * @arg version Version
+ * @arg flags Additional netlink message flags.
+ *
+ * Fills out a routing netlink request message and sends it out
+ * using nl_send_simple().
+ *
+ * @return 0 on success or a negative error code.
+ */
+int genl_send_simple(struct nl_sock *sk, int family, int cmd,
+ int version, int flags)
+{
+ struct genlmsghdr hdr = {
+ .cmd = cmd,
+ .version = version,
+ };
+
+ return nl_send_simple(sk, family, flags, &hdr, sizeof(hdr));
+}
+
+/** @} */
+
+
+/**
+ * @name Message Parsing
+ * @{
+ */
+
+int genlmsg_valid_hdr(struct nlmsghdr *nlh, int hdrlen)
+{
+ struct genlmsghdr *ghdr;
+
+ if (!nlmsg_valid_hdr(nlh, GENL_HDRLEN))
+ return 0;
+
+ ghdr = nlmsg_data(nlh);
+ if (genlmsg_len(ghdr) < NLMSG_ALIGN(hdrlen))
+ return 0;
+
+ return 1;
+}
+
+int genlmsg_validate(struct nlmsghdr *nlh, int hdrlen, int maxtype,
+ struct nla_policy *policy)
+{
+ struct genlmsghdr *ghdr;
+
+ if (!genlmsg_valid_hdr(nlh, hdrlen))
+ return -NLE_MSG_TOOSHORT;
+
+ ghdr = nlmsg_data(nlh);
+ return nla_validate(genlmsg_attrdata(ghdr, hdrlen),
+ genlmsg_attrlen(ghdr, hdrlen), maxtype, policy);
+}
+
+int genlmsg_parse(struct nlmsghdr *nlh, int hdrlen, struct nlattr *tb[],
+ int maxtype, struct nla_policy *policy)
+{
+ struct genlmsghdr *ghdr;
+
+ if (!genlmsg_valid_hdr(nlh, hdrlen))
+ return -NLE_MSG_TOOSHORT;
+
+ ghdr = nlmsg_data(nlh);
+ return nla_parse(tb, maxtype, genlmsg_attrdata(ghdr, hdrlen),
+ genlmsg_attrlen(ghdr, hdrlen), policy);
+}
+
+/**
+ * Get head of message payload
+ * @arg gnlh genetlink messsage header
+ */
+void *genlmsg_data(const struct genlmsghdr *gnlh)
+{
+ return ((unsigned char *) gnlh + GENL_HDRLEN);
+}
+
+/**
+ * Get lenght of message payload
+ * @arg gnlh genetlink message header
+ */
+int genlmsg_len(const struct genlmsghdr *gnlh)
+{
+ struct nlmsghdr *nlh = (struct nlmsghdr *)((unsigned char *)gnlh -
+ NLMSG_HDRLEN);
+ return (nlh->nlmsg_len - GENL_HDRLEN - NLMSG_HDRLEN);
+}
+
+/**
+ * Get head of attribute data
+ * @arg gnlh generic netlink message header
+ * @arg hdrlen length of family specific header
+ */
+struct nlattr *genlmsg_attrdata(const struct genlmsghdr *gnlh, int hdrlen)
+{
+ return genlmsg_data(gnlh) + NLMSG_ALIGN(hdrlen);
+}
+
+/**
+ * Get length of attribute data
+ * @arg gnlh generic netlink message header
+ * @arg hdrlen length of family specific header
+ */
+int genlmsg_attrlen(const struct genlmsghdr *gnlh, int hdrlen)
+{
+ return genlmsg_len(gnlh) - NLMSG_ALIGN(hdrlen);
+}
+
+/** @} */
+
+/**
+ * @name Message Building
+ * @{
+ */
+
+/**
+ * Add generic netlink header to netlink message
+ * @arg msg netlink message
+ * @arg pid netlink process id or NL_AUTO_PID
+ * @arg seq sequence number of message or NL_AUTO_SEQ
+ * @arg family generic netlink family
+ * @arg hdrlen length of user specific header
+ * @arg flags message flags
+ * @arg cmd generic netlink command
+ * @arg version protocol version
+ *
+ * Returns pointer to user specific header.
+ */
+void *genlmsg_put(struct nl_msg *msg, uint32_t pid, uint32_t seq, int family,
+ int hdrlen, int flags, uint8_t cmd, uint8_t version)
+{
+ struct nlmsghdr *nlh;
+ struct genlmsghdr hdr = {
+ .cmd = cmd,
+ .version = version,
+ };
+
+ nlh = nlmsg_put(msg, pid, seq, family, GENL_HDRLEN + hdrlen, flags);
+ if (nlh == NULL)
+ return NULL;
+
+ memcpy(nlmsg_data(nlh), &hdr, sizeof(hdr));
+ NL_DBG(2, "msg %p: Added generic netlink header cmd=%d version=%d\n",
+ msg, cmd, version);
+
+ return nlmsg_data(nlh) + GENL_HDRLEN;
+}
+
+/** @} */
+
+/** @} */
diff --git a/package/libs/libnl-tiny/src/genl_ctrl.c b/package/libs/libnl-tiny/src/genl_ctrl.c
new file mode 100644
index 0000000..1301642
--- /dev/null
+++ b/package/libs/libnl-tiny/src/genl_ctrl.c
@@ -0,0 +1,302 @@
+/*
+ * lib/genl/ctrl.c Generic Netlink Controller
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
+ */
+
+/**
+ * @ingroup genl_mngt
+ * @defgroup ctrl Controller
+ * @brief
+ *
+ * @{
+ */
+
+#include <netlink-generic.h>
+#include <netlink/netlink.h>
+#include <netlink/genl/genl.h>
+#include <netlink/genl/family.h>
+#include <netlink/genl/mngt.h>
+#include <netlink/genl/ctrl.h>
+#include <netlink/utils.h>
+
+/** @cond SKIP */
+#define CTRL_VERSION 0x0001
+
+static struct nl_cache_ops genl_ctrl_ops;
+/** @endcond */
+
+static int ctrl_request_update(struct nl_cache *c, struct nl_sock *h)
+{
+ return genl_send_simple(h, GENL_ID_CTRL, CTRL_CMD_GETFAMILY,
+ CTRL_VERSION, NLM_F_DUMP);
+}
+
+static struct nla_policy ctrl_policy[CTRL_ATTR_MAX+1] = {
+ [CTRL_ATTR_FAMILY_ID] = { .type = NLA_U16 },
+ [CTRL_ATTR_FAMILY_NAME] = { .type = NLA_STRING,
+ .maxlen = GENL_NAMSIZ },
+ [CTRL_ATTR_VERSION] = { .type = NLA_U32 },
+ [CTRL_ATTR_HDRSIZE] = { .type = NLA_U32 },
+ [CTRL_ATTR_MAXATTR] = { .type = NLA_U32 },
+ [CTRL_ATTR_OPS] = { .type = NLA_NESTED },
+};
+
+static struct nla_policy family_op_policy[CTRL_ATTR_OP_MAX+1] = {
+ [CTRL_ATTR_OP_ID] = { .type = NLA_U32 },
+ [CTRL_ATTR_OP_FLAGS] = { .type = NLA_U32 },
+};
+
+static int ctrl_msg_parser(struct nl_cache_ops *ops, struct genl_cmd *cmd,
+ struct genl_info *info, void *arg)
+{
+ struct genl_family *family;
+ struct nl_parser_param *pp = arg;
+ int err;
+
+ family = genl_family_alloc();
+ if (family == NULL) {
+ err = -NLE_NOMEM;
+ goto errout;
+ }
+
+ if (info->attrs[CTRL_ATTR_FAMILY_NAME] == NULL) {
+ err = -NLE_MISSING_ATTR;
+ goto errout;
+ }
+
+ if (info->attrs[CTRL_ATTR_FAMILY_ID] == NULL) {
+ err = -NLE_MISSING_ATTR;
+ goto errout;
+ }
+
+ family->ce_msgtype = info->nlh->nlmsg_type;
+ genl_family_set_id(family,
+ nla_get_u16(info->attrs[CTRL_ATTR_FAMILY_ID]));
+ genl_family_set_name(family,
+ nla_get_string(info->attrs[CTRL_ATTR_FAMILY_NAME]));
+
+ if (info->attrs[CTRL_ATTR_VERSION]) {
+ uint32_t version = nla_get_u32(info->attrs[CTRL_ATTR_VERSION]);
+ genl_family_set_version(family, version);
+ }
+
+ if (info->attrs[CTRL_ATTR_HDRSIZE]) {
+ uint32_t hdrsize = nla_get_u32(info->attrs[CTRL_ATTR_HDRSIZE]);
+ genl_family_set_hdrsize(family, hdrsize);
+ }
+
+ if (info->attrs[CTRL_ATTR_MAXATTR]) {
+ uint32_t maxattr = nla_get_u32(info->attrs[CTRL_ATTR_MAXATTR]);
+ genl_family_set_maxattr(family, maxattr);
+ }
+
+ if (info->attrs[CTRL_ATTR_OPS]) {
+ struct nlattr *nla, *nla_ops;
+ int remaining;
+
+ nla_ops = info->attrs[CTRL_ATTR_OPS];
+ nla_for_each_nested(nla, nla_ops, remaining) {
+ struct nlattr *tb[CTRL_ATTR_OP_MAX+1];
+ int flags = 0, id;
+
+ err = nla_parse_nested(tb, CTRL_ATTR_OP_MAX, nla,
+ family_op_policy);
+ if (err < 0)
+ goto errout;
+
+ if (tb[CTRL_ATTR_OP_ID] == NULL) {
+ err = -NLE_MISSING_ATTR;
+ goto errout;
+ }
+
+ id = nla_get_u32(tb[CTRL_ATTR_OP_ID]);
+
+ if (tb[CTRL_ATTR_OP_FLAGS])
+ flags = nla_get_u32(tb[CTRL_ATTR_OP_FLAGS]);
+
+ err = genl_family_add_op(family, id, flags);
+ if (err < 0)
+ goto errout;
+
+ }
+ }
+
+ err = pp->pp_cb((struct nl_object *) family, pp);
+errout:
+ genl_family_put(family);
+ return err;
+}
+
+/**
+ * @name Cache Management
+ * @{
+ */
+
+int genl_ctrl_alloc_cache(struct nl_sock *sock, struct nl_cache **result)
+{
+ return nl_cache_alloc_and_fill(&genl_ctrl_ops, sock, result);
+}
+
+/**
+ * Look up generic netlink family by id in the provided cache.
+ * @arg cache Generic netlink family cache.
+ * @arg id Family identifier.
+ *
+ * Searches through the cache looking for a registered family
+ * matching the specified identifier. The caller will own a
+ * reference on the returned object which needs to be given
+ * back after usage using genl_family_put().
+ *
+ * @return Generic netlink family object or NULL if no match was found.
+ */
+struct genl_family *genl_ctrl_search(struct nl_cache *cache, int id)
+{
+ struct genl_family *fam;
+
+ if (cache->c_ops != &genl_ctrl_ops)
+ BUG();
+
+ nl_list_for_each_entry(fam, &cache->c_items, ce_list) {
+ if (fam->gf_id == id) {
+ nl_object_get((struct nl_object *) fam);
+ return fam;
+ }
+ }
+
+ return NULL;
+}
+
+/**
+ * @name Resolver
+ * @{
+ */
+
+/**
+ * Look up generic netlink family by family name in the provided cache.
+ * @arg cache Generic netlink family cache.
+ * @arg name Family name.
+ *
+ * Searches through the cache looking for a registered family
+ * matching the specified name. The caller will own a reference
+ * on the returned object which needs to be given back after
+ * usage using genl_family_put().
+ *
+ * @return Generic netlink family object or NULL if no match was found.
+ */
+struct genl_family *genl_ctrl_search_by_name(struct nl_cache *cache,
+ const char *name)
+{
+ struct genl_family *fam;
+
+ if (cache->c_ops != &genl_ctrl_ops)
+ BUG();
+
+ nl_list_for_each_entry(fam, &cache->c_items, ce_list) {
+ if (!strcmp(name, fam->gf_name)) {
+ nl_object_get((struct nl_object *) fam);
+ return fam;
+ }
+ }
+
+ return NULL;
+}
+
+/** @} */
+
+/**
+ * Resolve generic netlink family name to its identifier
+ * @arg sk Netlink socket.
+ * @arg name Name of generic netlink family
+ *
+ * Resolves the generic netlink family name to its identifer and returns
+ * it.
+ *
+ * @return A positive identifier or a negative error code.
+ */
+int genl_ctrl_resolve(struct nl_sock *sk, const char *name)
+{
+ struct nl_cache *cache;
+ struct genl_family *family;
+ int err;
+
+ if ((err = genl_ctrl_alloc_cache(sk, &cache)) < 0)
+ return err;
+
+ family = genl_ctrl_search_by_name(cache, name);
+ if (family == NULL) {
+ err = -NLE_OBJ_NOTFOUND;
+ goto errout;
+ }
+
+ err = genl_family_get_id(family);
+ genl_family_put(family);
+errout:
+ nl_cache_free(cache);
+
+ return err;
+}
+
+/** @} */
+
+static struct genl_cmd genl_cmds[] = {
+ {
+ .c_id = CTRL_CMD_NEWFAMILY,
+ .c_name = "NEWFAMILY" ,
+ .c_maxattr = CTRL_ATTR_MAX,
+ .c_attr_policy = ctrl_policy,
+ .c_msg_parser = ctrl_msg_parser,
+ },
+ {
+ .c_id = CTRL_CMD_DELFAMILY,
+ .c_name = "DELFAMILY" ,
+ },
+ {
+ .c_id = CTRL_CMD_GETFAMILY,
+ .c_name = "GETFAMILY" ,
+ },
+ {
+ .c_id = CTRL_CMD_NEWOPS,
+ .c_name = "NEWOPS" ,
+ },
+ {
+ .c_id = CTRL_CMD_DELOPS,
+ .c_name = "DELOPS" ,
+ },
+};
+
+static struct genl_ops genl_ops = {
+ .o_cmds = genl_cmds,
+ .o_ncmds = ARRAY_SIZE(genl_cmds),
+};
+
+/** @cond SKIP */
+extern struct nl_object_ops genl_family_ops;
+/** @endcond */
+
+static struct nl_cache_ops genl_ctrl_ops = {
+ .co_name = "genl/family",
+ .co_hdrsize = GENL_HDRSIZE(0),
+ .co_msgtypes = GENL_FAMILY(GENL_ID_CTRL, "nlctrl"),
+ .co_genl = &genl_ops,
+ .co_protocol = NETLINK_GENERIC,
+ .co_request_update = ctrl_request_update,
+ .co_obj_ops = &genl_family_ops,
+};
+
+static void __init ctrl_init(void)
+{
+ genl_register(&genl_ctrl_ops);
+}
+
+static void __exit ctrl_exit(void)
+{
+ genl_unregister(&genl_ctrl_ops);
+}
+
+/** @} */
diff --git a/package/libs/libnl-tiny/src/genl_family.c b/package/libs/libnl-tiny/src/genl_family.c
new file mode 100644
index 0000000..88aaad9
--- /dev/null
+++ b/package/libs/libnl-tiny/src/genl_family.c
@@ -0,0 +1,136 @@
+/*
+ * lib/genl/family.c Generic Netlink Family
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
+ */
+
+/**
+ * @ingroup genl
+ * @defgroup genl_family Generic Netlink Family
+ * @brief
+ *
+ * @{
+ */
+
+#include <netlink-generic.h>
+#include <netlink/netlink.h>
+#include <netlink/genl/genl.h>
+#include <netlink/genl/family.h>
+#include <netlink/utils.h>
+
+struct nl_object_ops genl_family_ops;
+/** @endcond */
+
+static void family_constructor(struct nl_object *c)
+{
+ struct genl_family *family = (struct genl_family *) c;
+
+ nl_init_list_head(&family->gf_ops);
+}
+
+static void family_free_data(struct nl_object *c)
+{
+ struct genl_family *family = (struct genl_family *) c;
+ struct genl_family_op *ops, *tmp;
+
+ if (family == NULL)
+ return;
+
+ nl_list_for_each_entry_safe(ops, tmp, &family->gf_ops, o_list) {
+ nl_list_del(&ops->o_list);
+ free(ops);
+ }
+}
+
+static int family_clone(struct nl_object *_dst, struct nl_object *_src)
+{
+ struct genl_family *dst = nl_object_priv(_dst);
+ struct genl_family *src = nl_object_priv(_src);
+ struct genl_family_op *ops;
+ int err;
+
+ nl_list_for_each_entry(ops, &src->gf_ops, o_list) {
+ err = genl_family_add_op(dst, ops->o_id, ops->o_flags);
+ if (err < 0)
+ return err;
+ }
+
+ return 0;
+}
+
+static int family_compare(struct nl_object *_a, struct nl_object *_b,
+ uint32_t attrs, int flags)
+{
+ struct genl_family *a = (struct genl_family *) _a;
+ struct genl_family *b = (struct genl_family *) _b;
+ int diff = 0;
+
+#define FAM_DIFF(ATTR, EXPR) ATTR_DIFF(attrs, FAMILY_ATTR_##ATTR, a, b, EXPR)
+
+ diff |= FAM_DIFF(ID, a->gf_id != b->gf_id);
+ diff |= FAM_DIFF(VERSION, a->gf_version != b->gf_version);
+ diff |= FAM_DIFF(HDRSIZE, a->gf_hdrsize != b->gf_hdrsize);
+ diff |= FAM_DIFF(MAXATTR, a->gf_maxattr != b->gf_maxattr);
+ diff |= FAM_DIFF(NAME, strcmp(a->gf_name, b->gf_name));
+
+#undef FAM_DIFF
+
+ return diff;
+}
+
+
+/**
+ * @name Family Object
+ * @{
+ */
+
+struct genl_family *genl_family_alloc(void)
+{
+ return (struct genl_family *) nl_object_alloc(&genl_family_ops);
+}
+
+void genl_family_put(struct genl_family *family)
+{
+ nl_object_put((struct nl_object *) family);
+}
+
+/** @} */
+
+
+int genl_family_add_op(struct genl_family *family, int id, int flags)
+{
+ struct genl_family_op *op;
+
+ op = calloc(1, sizeof(*op));
+ if (op == NULL)
+ return -NLE_NOMEM;
+
+ op->o_id = id;
+ op->o_flags = flags;
+
+ nl_list_add_tail(&op->o_list, &family->gf_ops);
+ family->ce_mask |= FAMILY_ATTR_OPS;
+
+ return 0;
+}
+
+/** @} */
+
+/** @cond SKIP */
+struct nl_object_ops genl_family_ops = {
+ .oo_name = "genl/family",
+ .oo_size = sizeof(struct genl_family),
+ .oo_constructor = family_constructor,
+ .oo_free_data = family_free_data,
+ .oo_clone = family_clone,
+ .oo_compare = family_compare,
+ .oo_id_attrs = FAMILY_ATTR_ID,
+};
+/** @endcond */
+
+/** @} */
diff --git a/package/libs/libnl-tiny/src/genl_mngt.c b/package/libs/libnl-tiny/src/genl_mngt.c
new file mode 100644
index 0000000..6c65179
--- /dev/null
+++ b/package/libs/libnl-tiny/src/genl_mngt.c
@@ -0,0 +1,274 @@
+/*
+ * lib/genl/mngt.c Generic Netlink Management
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
+ */
+
+/**
+ * @ingroup genl
+ * @defgroup genl_mngt Management
+ *
+ * @par 1) Registering a generic netlink module
+ * @code
+ * #include <netlink/genl/mngt.h>
+ *
+ * // First step is to define all the commands being used in
+ * // particular generic netlink family. The ID and name are
+ * // mandatory to be filled out. A callback function and
+ * // most the attribute policy that comes with it must be
+ * // defined for commands expected to be issued towards
+ * // userspace.
+ * static struct genl_cmd foo_cmds[] = {
+ * {
+ * .c_id = FOO_CMD_NEW,
+ * .c_name = "NEWFOO" ,
+ * .c_maxattr = FOO_ATTR_MAX,
+ * .c_attr_policy = foo_policy,
+ * .c_msg_parser = foo_msg_parser,
+ * },
+ * {
+ * .c_id = FOO_CMD_DEL,
+ * .c_name = "DELFOO" ,
+ * },
+ * };
+ *
+ * // The list of commands must then be integrated into a
+ * // struct genl_ops serving as handle for this particular
+ * // family.
+ * static struct genl_ops my_genl_ops = {
+ * .o_cmds = foo_cmds,
+ * .o_ncmds = ARRAY_SIZE(foo_cmds),
+ * };
+ *
+ * // Using the above struct genl_ops an arbitary number of
+ * // cache handles can be associated to it.
+ * //
+ * // The macro GENL_HDRSIZE() must be used to specify the
+ * // length of the header to automatically take headers on
+ * // generic layers into account.
+ * //
+ * // The macro GENL_FAMILY() is used to represent the generic
+ * // netlink family id.
+ * static struct nl_cache_ops genl_foo_ops = {
+ * .co_name = "genl/foo",
+ * .co_hdrsize = GENL_HDRSIZE(sizeof(struct my_hdr)),
+ * .co_msgtypes = GENL_FAMILY(GENL_ID_GENERATE, "foo"),
+ * .co_genl = &my_genl_ops,
+ * .co_protocol = NETLINK_GENERIC,
+ * .co_request_update = foo_request_update,
+ * .co_obj_ops = &genl_foo_ops,
+ * };
+ *
+ * // Finally each cache handle for a generic netlink family
+ * // must be registered using genl_register().
+ * static void __init foo_init(void)
+ * {
+ * genl_register(&genl_foo_ops);
+ * }
+ *
+ * // ... respectively unregsted again.
+ * static void __exit foo_exit(void)
+ * {
+ * genl_unregister(&genl_foo_ops);
+ * }
+ * @endcode
+ * @{
+ */
+
+#include <netlink-generic.h>
+#include <netlink/netlink.h>
+#include <netlink/genl/genl.h>
+#include <netlink/genl/mngt.h>
+#include <netlink/genl/family.h>
+#include <netlink/genl/ctrl.h>
+#include <netlink/utils.h>
+
+static NL_LIST_HEAD(genl_ops_list);
+
+static int genl_msg_parser(struct nl_cache_ops *ops, struct sockaddr_nl *who,
+ struct nlmsghdr *nlh, struct nl_parser_param *pp)
+{
+ int i, err;
+ struct genlmsghdr *ghdr;
+ struct genl_cmd *cmd;
+
+ ghdr = nlmsg_data(nlh);
+
+ if (ops->co_genl == NULL)
+ BUG();
+
+ for (i = 0; i < ops->co_genl->o_ncmds; i++) {
+ cmd = &ops->co_genl->o_cmds[i];
+ if (cmd->c_id == ghdr->cmd)
+ goto found;
+ }
+
+ err = -NLE_MSGTYPE_NOSUPPORT;
+ goto errout;
+
+found:
+ if (cmd->c_msg_parser == NULL)
+ err = -NLE_OPNOTSUPP;
+ else {
+ struct nlattr *tb[cmd->c_maxattr + 1];
+ struct genl_info info = {
+ .who = who,
+ .nlh = nlh,
+ .genlhdr = ghdr,
+ .userhdr = genlmsg_data(ghdr),
+ .attrs = tb,
+ };
+
+ err = nlmsg_parse(nlh, ops->co_hdrsize, tb, cmd->c_maxattr,
+ cmd->c_attr_policy);
+ if (err < 0)
+ goto errout;
+
+ err = cmd->c_msg_parser(ops, cmd, &info, pp);
+ }
+errout:
+ return err;
+
+}
+
+#ifdef disabled
+char *genl_op2name(int family, int op, char *buf, size_t len)
+{
+ struct genl_ops *ops;
+ int i;
+
+ nl_list_for_each_entry(ops, &genl_ops_list, o_list) {
+ if (ops->o_family == family) {
+ for (i = 0; i < ops->o_ncmds; i++) {
+ struct genl_cmd *cmd;
+ cmd = &ops->o_cmds[i];
+
+ if (cmd->c_id == op) {
+ strncpy(buf, cmd->c_name, len - 1);
+ return buf;
+ }
+ }
+ }
+ }
+
+ strncpy(buf, "unknown", len - 1);
+ return NULL;
+}
+#endif
+
+/**
+ * @name Register/Unregister
+ * @{
+ */
+
+/**
+ * Register generic netlink operations
+ * @arg ops cache operations
+ */
+int genl_register(struct nl_cache_ops *ops)
+{
+ int err;
+
+ if (ops->co_protocol != NETLINK_GENERIC) {
+ err = -NLE_PROTO_MISMATCH;
+ goto errout;
+ }
+
+ if (ops->co_hdrsize < GENL_HDRSIZE(0)) {
+ err = -NLE_INVAL;
+ goto errout;
+ }
+
+ if (ops->co_genl == NULL) {
+ err = -NLE_INVAL;
+ goto errout;
+ }
+
+ ops->co_genl->o_cache_ops = ops;
+ ops->co_genl->o_name = ops->co_msgtypes[0].mt_name;
+ ops->co_genl->o_family = ops->co_msgtypes[0].mt_id;
+ ops->co_msg_parser = genl_msg_parser;
+
+ /* FIXME: check for dup */
+
+ nl_list_add_tail(&ops->co_genl->o_list, &genl_ops_list);
+
+ err = nl_cache_mngt_register(ops);
+errout:
+ return err;
+}
+
+/**
+ * Unregister generic netlink operations
+ * @arg ops cache operations
+ */
+void genl_unregister(struct nl_cache_ops *ops)
+{
+ nl_cache_mngt_unregister(ops);
+ nl_list_del(&ops->co_genl->o_list);
+}
+
+/** @} */
+
+/**
+ * @name Resolving ID/Name
+ * @{
+ */
+#ifdef disabled
+static int __genl_ops_resolve(struct nl_cache *ctrl, struct genl_ops *ops)
+{
+ struct genl_family *family;
+
+ family = genl_ctrl_search_by_name(ctrl, ops->o_name);
+ if (family != NULL) {
+ ops->o_id = genl_family_get_id(family);
+ genl_family_put(family);
+
+ return 0;
+ }
+
+ return -NLE_OBJ_NOTFOUND;
+}
+
+int genl_ops_resolve(struct nl_sock *sk, struct genl_ops *ops)
+{
+ struct nl_cache *ctrl;
+ int err;
+
+ if ((err = genl_ctrl_alloc_cache(sk, &ctrl)) < 0)
+ goto errout;
+
+ err = __genl_ops_resolve(ctrl, ops);
+
+ nl_cache_free(ctrl);
+errout:
+ return err;
+}
+
+int genl_mngt_resolve(struct nl_sock *sk)
+{
+ struct nl_cache *ctrl;
+ struct genl_ops *ops;
+ int err = 0;
+
+ if ((err = genl_ctrl_alloc_cache(sk, &ctrl)) < 0)
+ goto errout;
+
+ nl_list_for_each_entry(ops, &genl_ops_list, o_list) {
+ err = __genl_ops_resolve(ctrl, ops);
+ }
+
+ nl_cache_free(ctrl);
+errout:
+ return err;
+}
+#endif
+/** @} */
+
+
+/** @} */
diff --git a/package/libs/libnl-tiny/src/handlers.c b/package/libs/libnl-tiny/src/handlers.c
new file mode 100644
index 0000000..12ebda5
--- /dev/null
+++ b/package/libs/libnl-tiny/src/handlers.c
@@ -0,0 +1,162 @@
+/*
+ * lib/handlers.c default netlink message handlers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
+ */
+
+/**
+ * @ingroup core
+ * @defgroup cb Callbacks/Customization
+ *
+ * @details
+ * @par 1) Setting up a callback set
+ * @code
+ * // Allocate a callback set and initialize it to the verbose default set
+ * struct nl_cb *cb = nl_cb_alloc(NL_CB_VERBOSE);
+ *
+ * // Modify the set to call my_func() for all valid messages
+ * nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, my_func, NULL);
+ *
+ * // Set the error message handler to the verbose default implementation
+ * // and direct it to print all errors to the given file descriptor.
+ * FILE *file = fopen(...);
+ * nl_cb_err(cb, NL_CB_VERBOSE, NULL, file);
+ * @endcode
+ * @{
+ */
+
+#include <netlink-local.h>
+#include <netlink/netlink.h>
+#include <netlink/utils.h>
+#include <netlink/msg.h>
+#include <netlink/handlers.h>
+
+/**
+ * @name Callback Handle Management
+ * @{
+ */
+
+/**
+ * Allocate a new callback handle
+ * @arg kind callback kind to be used for initialization
+ * @return Newly allocated callback handle or NULL
+ */
+struct nl_cb *nl_cb_alloc(enum nl_cb_kind kind)
+{
+ int i;
+ struct nl_cb *cb;
+
+ if (kind < 0 || kind > NL_CB_KIND_MAX)
+ return NULL;
+
+ cb = calloc(1, sizeof(*cb));
+ if (!cb)
+ return NULL;
+
+ cb->cb_refcnt = 1;
+
+ for (i = 0; i <= NL_CB_TYPE_MAX; i++)
+ nl_cb_set(cb, i, kind, NULL, NULL);
+
+ nl_cb_err(cb, kind, NULL, NULL);
+
+ return cb;
+}
+
+/**
+ * Clone an existing callback handle
+ * @arg orig original callback handle
+ * @return Newly allocated callback handle being a duplicate of
+ * orig or NULL
+ */
+struct nl_cb *nl_cb_clone(struct nl_cb *orig)
+{
+ struct nl_cb *cb;
+
+ cb = nl_cb_alloc(NL_CB_DEFAULT);
+ if (!cb)
+ return NULL;
+
+ memcpy(cb, orig, sizeof(*orig));
+ cb->cb_refcnt = 1;
+
+ return cb;
+}
+
+void nl_cb_put(struct nl_cb *cb)
+{
+ if (!cb)
+ return;
+
+ cb->cb_refcnt--;
+
+ if (cb->cb_refcnt < 0)
+ BUG();
+
+ if (cb->cb_refcnt <= 0)
+ free(cb);
+}
+
+/** @} */
+
+/**
+ * @name Callback Setup
+ * @{
+ */
+
+/**
+ * Set up a callback
+ * @arg cb callback set
+ * @arg type callback to modify
+ * @arg kind kind of implementation
+ * @arg func callback function (NL_CB_CUSTOM)
+ * @arg arg argument passed to callback
+ *
+ * @return 0 on success or a negative error code
+ */
+int nl_cb_set(struct nl_cb *cb, enum nl_cb_type type, enum nl_cb_kind kind,
+ nl_recvmsg_msg_cb_t func, void *arg)
+{
+ if (type < 0 || type > NL_CB_TYPE_MAX)
+ return -NLE_RANGE;
+
+ if (kind < 0 || kind > NL_CB_KIND_MAX)
+ return -NLE_RANGE;
+
+ if (kind == NL_CB_CUSTOM) {
+ cb->cb_set[type] = func;
+ cb->cb_args[type] = arg;
+ }
+
+ return 0;
+}
+
+/**
+ * Set up an error callback
+ * @arg cb callback set
+ * @arg kind kind of callback
+ * @arg func callback function
+ * @arg arg argument to be passed to callback function
+ */
+int nl_cb_err(struct nl_cb *cb, enum nl_cb_kind kind,
+ nl_recvmsg_err_cb_t func, void *arg)
+{
+ if (kind < 0 || kind > NL_CB_KIND_MAX)
+ return -NLE_RANGE;
+
+ if (kind == NL_CB_CUSTOM) {
+ cb->cb_err = func;
+ cb->cb_err_arg = arg;
+ }
+
+ return 0;
+}
+
+/** @} */
+
+/** @} */
diff --git a/package/libs/libnl-tiny/src/include/.svn/entries b/package/libs/libnl-tiny/src/include/.svn/entries
new file mode 100644
index 0000000..42ae963
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/.svn/entries
@@ -0,0 +1,170 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs/libnl-tiny/src/include
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+linux
+dir
+
+netlink-local.h
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+32328f8ced9a8069b753716a52a2bb1f
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3672
+
+netlink
+dir
+
+netlink-generic.h
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+f31164850d33750242bfb16b85070a50
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+514
+
+unl.h
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+1a8c1e12437e0e03c6e0658b19ead0b9
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1426
+
+netlink-types.h
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+23e745583f678a84ce1daed266bc8af7
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1338
+
diff --git a/package/libs/libnl-tiny/src/include/.svn/text-base/netlink-generic.h.svn-base b/package/libs/libnl-tiny/src/include/.svn/text-base/netlink-generic.h.svn-base
new file mode 100644
index 0000000..10aa2f0
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/.svn/text-base/netlink-generic.h.svn-base
@@ -0,0 +1,20 @@
+/*
+ * netlink-generic.h Local Generic Netlink Interface
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
+ */
+
+#ifndef NETLINK_GENL_PRIV_H_
+#define NETLINK_GENL_PRIV_H_
+
+#include <netlink-local.h>
+#include <netlink/netlink.h>
+
+#define GENL_HDRSIZE(hdrlen) (GENL_HDRLEN + (hdrlen))
+
+#endif
diff --git a/package/libs/libnl-tiny/src/include/.svn/text-base/netlink-local.h.svn-base b/package/libs/libnl-tiny/src/include/.svn/text-base/netlink-local.h.svn-base
new file mode 100644
index 0000000..330100e
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/.svn/text-base/netlink-local.h.svn-base
@@ -0,0 +1,158 @@
+/*
+ * netlink-local.h Local Netlink Interface
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
+ */
+
+#ifndef NETLINK_LOCAL_H_
+#define NETLINK_LOCAL_H_
+#define _GNU_SOURCE
+
+#include <stdio.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <math.h>
+#include <time.h>
+#include <stdarg.h>
+#include <ctype.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <inttypes.h>
+#include <assert.h>
+#include <limits.h>
+
+#include <arpa/inet.h>
+#include <netdb.h>
+
+#ifndef SOL_NETLINK
+#define SOL_NETLINK 270
+#endif
+
+#include <linux/types.h>
+
+/* local header copies */
+#include <linux/if.h>
+#include <linux/if_arp.h>
+#include <linux/if_ether.h>
+#include <linux/pkt_sched.h>
+#include <linux/pkt_cls.h>
+#include <linux/gen_stats.h>
+
+#include <netlink/netlink.h>
+#include <netlink/handlers.h>
+#include <netlink/cache.h>
+#include <netlink/object-api.h>
+#include <netlink/cache-api.h>
+#include <netlink-types.h>
+
+struct trans_tbl {
+ int i;
+ const char *a;
+};
+
+#define __ADD(id, name) { .i = id, .a = #name },
+
+struct trans_list {
+ int i;
+ char *a;
+ struct nl_list_head list;
+};
+
+#define NL_DEBUG 1
+
+#define NL_DBG(LVL,FMT,ARG...) \
+ do {} while (0)
+
+#define BUG() \
+ do { \
+ fprintf(stderr, "BUG: %s:%d\n", \
+ __FILE__, __LINE__); \
+ assert(0); \
+ } while (0)
+
+extern int __nl_read_num_str_file(const char *path,
+ int (*cb)(long, const char *));
+
+extern int __trans_list_add(int, const char *, struct nl_list_head *);
+extern void __trans_list_clear(struct nl_list_head *);
+
+extern char *__type2str(int, char *, size_t, struct trans_tbl *, size_t);
+extern int __str2type(const char *, struct trans_tbl *, size_t);
+
+extern char *__list_type2str(int, char *, size_t, struct nl_list_head *);
+extern int __list_str2type(const char *, struct nl_list_head *);
+
+extern char *__flags2str(int, char *, size_t, struct trans_tbl *, size_t);
+extern int __str2flags(const char *, struct trans_tbl *, size_t);
+
+extern void dump_from_ops(struct nl_object *, struct nl_dump_params *);
+
+#ifdef disabled
+static inline struct nl_cache *dp_cache(struct nl_object *obj)
+{
+ if (obj->ce_cache == NULL)
+ return nl_cache_mngt_require(obj->ce_ops->oo_name);
+
+ return obj->ce_cache;
+}
+#endif
+
+static inline int nl_cb_call(struct nl_cb *cb, int type, struct nl_msg *msg)
+{
+ return cb->cb_set[type](msg, cb->cb_args[type]);
+}
+
+#define ARRAY_SIZE(X) (sizeof(X) / sizeof((X)[0]))
+#ifndef offsetof
+#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
+#endif
+
+#define __init __attribute__ ((constructor))
+#define __exit __attribute__ ((destructor))
+#undef __deprecated
+#define __deprecated __attribute__ ((deprecated))
+
+#define min(x,y) ({ \
+ typeof(x) _x = (x); \
+ typeof(y) _y = (y); \
+ (void) (&_x == &_y); \
+ _x < _y ? _x : _y; })
+
+#define max(x,y) ({ \
+ typeof(x) _x = (x); \
+ typeof(y) _y = (y); \
+ (void) (&_x == &_y); \
+ _x > _y ? _x : _y; })
+
+extern int nl_cache_parse(struct nl_cache_ops *, struct sockaddr_nl *,
+ struct nlmsghdr *, struct nl_parser_param *);
+
+
+static inline char *nl_cache_name(struct nl_cache *cache)
+{
+ return cache->c_ops ? cache->c_ops->co_name : "unknown";
+}
+
+#define GENL_FAMILY(id, name) \
+ { \
+ { id, NL_ACT_UNSPEC, name }, \
+ END_OF_MSGTYPES_LIST, \
+ }
+
+static inline int wait_for_ack(struct nl_sock *sk)
+{
+ if (sk->s_flags & NL_NO_AUTO_ACK)
+ return 0;
+ else
+ return nl_wait_for_ack(sk);
+}
+
+#endif
diff --git a/package/libs/libnl-tiny/src/include/.svn/text-base/netlink-types.h.svn-base b/package/libs/libnl-tiny/src/include/.svn/text-base/netlink-types.h.svn-base
new file mode 100644
index 0000000..0d00593
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/.svn/text-base/netlink-types.h.svn-base
@@ -0,0 +1,81 @@
+/*
+ * netlink-types.h Netlink Types (Private)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
+ */
+
+#ifndef NETLINK_LOCAL_TYPES_H_
+#define NETLINK_LOCAL_TYPES_H_
+
+#include <netlink/list.h>
+
+struct nl_cache_ops;
+struct nl_sock;
+struct nl_object;
+
+struct nl_cache
+{
+ struct nl_list_head c_items;
+ int c_nitems;
+ int c_iarg1;
+ int c_iarg2;
+ struct nl_cache_ops * c_ops;
+};
+
+struct nl_cache_assoc
+{
+ struct nl_cache * ca_cache;
+ change_func_t ca_change;
+};
+
+struct nl_cache_mngr
+{
+ int cm_protocol;
+ int cm_flags;
+ int cm_nassocs;
+ struct nl_sock * cm_handle;
+ struct nl_cache_assoc * cm_assocs;
+};
+
+struct nl_parser_param;
+
+#define LOOSE_COMPARISON 1
+
+
+struct nl_data
+{
+ size_t d_size;
+ void * d_data;
+};
+
+struct nl_addr
+{
+ int a_family;
+ unsigned int a_maxsize;
+ unsigned int a_len;
+ int a_prefixlen;
+ int a_refcnt;
+ char a_addr[0];
+};
+
+#define IFQDISCSIZ 32
+
+#define GENL_OP_HAS_POLICY 1
+#define GENL_OP_HAS_DOIT 2
+#define GENL_OP_HAS_DUMPIT 4
+
+struct genl_family_op
+{
+ uint32_t o_id;
+ uint32_t o_flags;
+
+ struct nl_list_head o_list;
+};
+
+
+#endif
diff --git a/package/libs/libnl-tiny/src/include/.svn/text-base/unl.h.svn-base b/package/libs/libnl-tiny/src/include/.svn/text-base/unl.h.svn-base
new file mode 100644
index 0000000..4fe7dc7
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/.svn/text-base/unl.h.svn-base
@@ -0,0 +1,47 @@
+#ifndef __UNL_H
+#define __UNL_H
+
+#include <netlink/netlink.h>
+#include <netlink/genl/genl.h>
+#include <netlink/genl/family.h>
+#include <stdbool.h>
+
+struct unl {
+ struct nl_sock *sock;
+ struct nl_cache *cache;
+ struct genl_family *family;
+ char *family_name;
+ int hdrlen;
+ bool loop_done;
+};
+
+int unl_genl_init(struct unl *unl, const char *family);
+void unl_free(struct unl *unl);
+
+typedef int (*unl_cb)(struct nl_msg *, void *);
+
+struct nl_msg *unl_genl_msg(struct unl *unl, int cmd, bool dump);
+int unl_genl_request(struct unl *unl, struct nl_msg *msg, unl_cb handler, void *arg);
+int unl_genl_request_single(struct unl *unl, struct nl_msg *msg, struct nl_msg **dest);
+void unl_genl_loop(struct unl *unl, unl_cb handler, void *arg);
+
+int unl_genl_multicast_id(struct unl *unl, const char *name);
+int unl_genl_subscribe(struct unl *unl, const char *name);
+int unl_genl_unsubscribe(struct unl *unl, const char *name);
+
+int unl_nl80211_phy_lookup(const char *name);
+int unl_nl80211_wdev_to_phy(struct unl *unl, int wdev);
+struct nl_msg *unl_nl80211_phy_msg(struct unl *unl, int phy, int cmd, bool dump);
+struct nl_msg *unl_nl80211_vif_msg(struct unl *unl, int dev, int cmd, bool dump);
+
+static inline void unl_loop_done(struct unl *unl)
+{
+ unl->loop_done = true;
+}
+
+static inline struct nlattr *unl_find_attr(struct unl *unl, struct nl_msg *msg, int attr)
+{
+ return nlmsg_find_attr(nlmsg_hdr(msg), unl->hdrlen, attr);
+}
+
+#endif
diff --git a/package/libs/libnl-tiny/src/include/linux/.svn/entries b/package/libs/libnl-tiny/src/include/linux/.svn/entries
new file mode 100644
index 0000000..e5d598c
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/linux/.svn/entries
@@ -0,0 +1,198 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs/libnl-tiny/src/include/linux
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+if.h
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+b85b9f0b61aae83f410a43a3a27a7d50
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4914
+
+genetlink.h
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+a2002670691831fc2f1ef44a619098d3
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1682
+
+netlink.h
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+7ef4cbe98f089f8d038f6838426e001e
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4779
+
+gen_stats.h
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+e3edccaf2ec0315bcbdf135cbdce2a21
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1213
+
+if_addr.h
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+7879062539e83f9ad5b6060a7a926c55
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1427
+
diff --git a/package/libs/libnl-tiny/src/include/linux/.svn/text-base/gen_stats.h.svn-base b/package/libs/libnl-tiny/src/include/linux/.svn/text-base/gen_stats.h.svn-base
new file mode 100644
index 0000000..13f4e74
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/linux/.svn/text-base/gen_stats.h.svn-base
@@ -0,0 +1,67 @@
+#ifndef __LINUX_GEN_STATS_H
+#define __LINUX_GEN_STATS_H
+
+#include <linux/types.h>
+
+enum {
+ TCA_STATS_UNSPEC,
+ TCA_STATS_BASIC,
+ TCA_STATS_RATE_EST,
+ TCA_STATS_QUEUE,
+ TCA_STATS_APP,
+ __TCA_STATS_MAX,
+};
+#define TCA_STATS_MAX (__TCA_STATS_MAX - 1)
+
+/**
+ * struct gnet_stats_basic - byte/packet throughput statistics
+ * @bytes: number of seen bytes
+ * @packets: number of seen packets
+ */
+struct gnet_stats_basic
+{
+ __u64 bytes;
+ __u32 packets;
+};
+
+/**
+ * struct gnet_stats_rate_est - rate estimator
+ * @bps: current byte rate
+ * @pps: current packet rate
+ */
+struct gnet_stats_rate_est
+{
+ __u32 bps;
+ __u32 pps;
+};
+
+/**
+ * struct gnet_stats_queue - queuing statistics
+ * @qlen: queue length
+ * @backlog: backlog size of queue
+ * @drops: number of dropped packets
+ * @requeues: number of requeues
+ * @overlimits: number of enqueues over the limit
+ */
+struct gnet_stats_queue
+{
+ __u32 qlen;
+ __u32 backlog;
+ __u32 drops;
+ __u32 requeues;
+ __u32 overlimits;
+};
+
+/**
+ * struct gnet_estimator - rate estimator configuration
+ * @interval: sampling period
+ * @ewma_log: the log of measurement window weight
+ */
+struct gnet_estimator
+{
+ signed char interval;
+ unsigned char ewma_log;
+};
+
+
+#endif /* __LINUX_GEN_STATS_H */
diff --git a/package/libs/libnl-tiny/src/include/linux/.svn/text-base/genetlink.h.svn-base b/package/libs/libnl-tiny/src/include/linux/.svn/text-base/genetlink.h.svn-base
new file mode 100644
index 0000000..b834ef6
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/linux/.svn/text-base/genetlink.h.svn-base
@@ -0,0 +1,83 @@
+#ifndef __LINUX_GENERIC_NETLINK_H
+#define __LINUX_GENERIC_NETLINK_H
+
+#include <linux/types.h>
+#include <linux/netlink.h>
+
+#define GENL_NAMSIZ 16 /* length of family name */
+
+#define GENL_MIN_ID NLMSG_MIN_TYPE
+#define GENL_MAX_ID 1023
+
+struct genlmsghdr {
+ __u8 cmd;
+ __u8 version;
+ __u16 reserved;
+};
+
+#define GENL_HDRLEN NLMSG_ALIGN(sizeof(struct genlmsghdr))
+
+#define GENL_ADMIN_PERM 0x01
+#define GENL_CMD_CAP_DO 0x02
+#define GENL_CMD_CAP_DUMP 0x04
+#define GENL_CMD_CAP_HASPOL 0x08
+
+/*
+ * List of reserved static generic netlink identifiers:
+ */
+#define GENL_ID_GENERATE 0
+#define GENL_ID_CTRL NLMSG_MIN_TYPE
+
+/**************************************************************************
+ * Controller
+ **************************************************************************/
+
+enum {
+ CTRL_CMD_UNSPEC,
+ CTRL_CMD_NEWFAMILY,
+ CTRL_CMD_DELFAMILY,
+ CTRL_CMD_GETFAMILY,
+ CTRL_CMD_NEWOPS,
+ CTRL_CMD_DELOPS,
+ CTRL_CMD_GETOPS,
+ CTRL_CMD_NEWMCAST_GRP,
+ CTRL_CMD_DELMCAST_GRP,
+ CTRL_CMD_GETMCAST_GRP, /* unused */
+ __CTRL_CMD_MAX,
+};
+
+#define CTRL_CMD_MAX (__CTRL_CMD_MAX - 1)
+
+enum {
+ CTRL_ATTR_UNSPEC,
+ CTRL_ATTR_FAMILY_ID,
+ CTRL_ATTR_FAMILY_NAME,
+ CTRL_ATTR_VERSION,
+ CTRL_ATTR_HDRSIZE,
+ CTRL_ATTR_MAXATTR,
+ CTRL_ATTR_OPS,
+ CTRL_ATTR_MCAST_GROUPS,
+ __CTRL_ATTR_MAX,
+};
+
+#define CTRL_ATTR_MAX (__CTRL_ATTR_MAX - 1)
+
+enum {
+ CTRL_ATTR_OP_UNSPEC,
+ CTRL_ATTR_OP_ID,
+ CTRL_ATTR_OP_FLAGS,
+ __CTRL_ATTR_OP_MAX,
+};
+
+#define CTRL_ATTR_OP_MAX (__CTRL_ATTR_OP_MAX - 1)
+
+enum {
+ CTRL_ATTR_MCAST_GRP_UNSPEC,
+ CTRL_ATTR_MCAST_GRP_NAME,
+ CTRL_ATTR_MCAST_GRP_ID,
+ __CTRL_ATTR_MCAST_GRP_MAX,
+};
+
+#define CTRL_ATTR_MCAST_GRP_MAX (__CTRL_ATTR_MCAST_GRP_MAX - 1)
+
+#endif /* __LINUX_GENERIC_NETLINK_H */
diff --git a/package/libs/libnl-tiny/src/include/linux/.svn/text-base/if.h.svn-base b/package/libs/libnl-tiny/src/include/linux/.svn/text-base/if.h.svn-base
new file mode 100644
index 0000000..4c1bcfe
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/linux/.svn/text-base/if.h.svn-base
@@ -0,0 +1,131 @@
+/*
+ * INET An implementation of the TCP/IP protocol suite for the LINUX
+ * operating system. INET is implemented using the BSD Socket
+ * interface as the means of communication with the user level.
+ *
+ * Global definitions for the INET interface module.
+ *
+ * Version: @(#)if.h 1.0.2 04/18/93
+ *
+ * Authors: Original taken from Berkeley UNIX 4.3, (c) UCB 1982-1988
+ * Ross Biro
+ * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
+ *
+ * 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 of the License, or (at your option) any later version.
+ */
+#ifndef _LINUX_IF_H
+#define _LINUX_IF_H
+
+#include <linux/types.h> /* for "__kernel_caddr_t" et al */
+
+#define IFNAMSIZ 16
+
+/* Standard interface flags (netdevice->flags). */
+#define IFF_UP 0x1 /* interface is up */
+#define IFF_BROADCAST 0x2 /* broadcast address valid */
+#define IFF_DEBUG 0x4 /* turn on debugging */
+#define IFF_LOOPBACK 0x8 /* is a loopback net */
+#define IFF_POINTOPOINT 0x10 /* interface is has p-p link */
+#define IFF_NOTRAILERS 0x20 /* avoid use of trailers */
+#define IFF_RUNNING 0x40 /* interface RFC2863 OPER_UP */
+#define IFF_NOARP 0x80 /* no ARP protocol */
+#define IFF_PROMISC 0x100 /* receive all packets */
+#define IFF_ALLMULTI 0x200 /* receive all multicast packets*/
+
+#define IFF_MASTER 0x400 /* master of a load balancer */
+#define IFF_SLAVE 0x800 /* slave of a load balancer */
+
+#define IFF_MULTICAST 0x1000 /* Supports multicast */
+
+#define IFF_PORTSEL 0x2000 /* can set media type */
+#define IFF_AUTOMEDIA 0x4000 /* auto media select active */
+#define IFF_DYNAMIC 0x8000 /* dialup device with changing addresses*/
+
+#define IFF_LOWER_UP 0x10000 /* driver signals L1 up */
+#define IFF_DORMANT 0x20000 /* driver signals dormant */
+
+#define IFF_ECHO 0x40000 /* echo sent packets */
+
+#define IFF_VOLATILE (IFF_LOOPBACK|IFF_POINTOPOINT|IFF_BROADCAST|IFF_ECHO|\
+ IFF_MASTER|IFF_SLAVE|IFF_RUNNING|IFF_LOWER_UP|IFF_DORMANT)
+
+/* Private (from user) interface flags (netdevice->priv_flags). */
+#define IFF_802_1Q_VLAN 0x1 /* 802.1Q VLAN device. */
+#define IFF_EBRIDGE 0x2 /* Ethernet bridging device. */
+#define IFF_SLAVE_INACTIVE 0x4 /* bonding slave not the curr. active */
+#define IFF_MASTER_8023AD 0x8 /* bonding master, 802.3ad. */
+#define IFF_MASTER_ALB 0x10 /* bonding master, balance-alb. */
+#define IFF_BONDING 0x20 /* bonding master or slave */
+#define IFF_SLAVE_NEEDARP 0x40 /* need ARPs for validation */
+#define IFF_ISATAP 0x80 /* ISATAP interface (RFC4214) */
+
+#define IF_GET_IFACE 0x0001 /* for querying only */
+#define IF_GET_PROTO 0x0002
+
+/* For definitions see hdlc.h */
+#define IF_IFACE_V35 0x1000 /* V.35 serial interface */
+#define IF_IFACE_V24 0x1001 /* V.24 serial interface */
+#define IF_IFACE_X21 0x1002 /* X.21 serial interface */
+#define IF_IFACE_T1 0x1003 /* T1 telco serial interface */
+#define IF_IFACE_E1 0x1004 /* E1 telco serial interface */
+#define IF_IFACE_SYNC_SERIAL 0x1005 /* can't be set by software */
+#define IF_IFACE_X21D 0x1006 /* X.21 Dual Clocking (FarSite) */
+
+/* For definitions see hdlc.h */
+#define IF_PROTO_HDLC 0x2000 /* raw HDLC protocol */
+#define IF_PROTO_PPP 0x2001 /* PPP protocol */
+#define IF_PROTO_CISCO 0x2002 /* Cisco HDLC protocol */
+#define IF_PROTO_FR 0x2003 /* Frame Relay protocol */
+#define IF_PROTO_FR_ADD_PVC 0x2004 /* Create FR PVC */
+#define IF_PROTO_FR_DEL_PVC 0x2005 /* Delete FR PVC */
+#define IF_PROTO_X25 0x2006 /* X.25 */
+#define IF_PROTO_HDLC_ETH 0x2007 /* raw HDLC, Ethernet emulation */
+#define IF_PROTO_FR_ADD_ETH_PVC 0x2008 /* Create FR Ethernet-bridged PVC */
+#define IF_PROTO_FR_DEL_ETH_PVC 0x2009 /* Delete FR Ethernet-bridged PVC */
+#define IF_PROTO_FR_PVC 0x200A /* for reading PVC status */
+#define IF_PROTO_FR_ETH_PVC 0x200B
+#define IF_PROTO_RAW 0x200C /* RAW Socket */
+
+/* RFC 2863 operational status */
+enum {
+ IF_OPER_UNKNOWN,
+ IF_OPER_NOTPRESENT,
+ IF_OPER_DOWN,
+ IF_OPER_LOWERLAYERDOWN,
+ IF_OPER_TESTING,
+ IF_OPER_DORMANT,
+ IF_OPER_UP,
+};
+
+/* link modes */
+enum {
+ IF_LINK_MODE_DEFAULT,
+ IF_LINK_MODE_DORMANT, /* limit upward transition to dormant */
+};
+
+/*
+ * Device mapping structure. I'd just gone off and designed a
+ * beautiful scheme using only loadable modules with arguments
+ * for driver options and along come the PCMCIA people 8)
+ *
+ * Ah well. The get() side of this is good for WDSETUP, and it'll
+ * be handy for debugging things. The set side is fine for now and
+ * being very small might be worth keeping for clean configuration.
+ */
+
+struct ifmap
+{
+ unsigned long mem_start;
+ unsigned long mem_end;
+ unsigned short base_addr;
+ unsigned char irq;
+ unsigned char dma;
+ unsigned char port;
+ /* 3 bytes spare */
+};
+
+
+#endif /* _LINUX_IF_H */
diff --git a/package/libs/libnl-tiny/src/include/linux/.svn/text-base/if_addr.h.svn-base b/package/libs/libnl-tiny/src/include/linux/.svn/text-base/if_addr.h.svn-base
new file mode 100644
index 0000000..43f3bed
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/linux/.svn/text-base/if_addr.h.svn-base
@@ -0,0 +1,62 @@
+#ifndef __LINUX_IF_ADDR_H
+#define __LINUX_IF_ADDR_H
+
+#include <linux/netlink.h>
+
+struct ifaddrmsg
+{
+ __u8 ifa_family;
+ __u8 ifa_prefixlen; /* The prefix length */
+ __u8 ifa_flags; /* Flags */
+ __u8 ifa_scope; /* Address scope */
+ __u32 ifa_index; /* Link index */
+};
+
+/*
+ * Important comment:
+ * IFA_ADDRESS is prefix address, rather than local interface address.
+ * It makes no difference for normally configured broadcast interfaces,
+ * but for point-to-point IFA_ADDRESS is DESTINATION address,
+ * local address is supplied in IFA_LOCAL attribute.
+ */
+enum
+{
+ IFA_UNSPEC,
+ IFA_ADDRESS,
+ IFA_LOCAL,
+ IFA_LABEL,
+ IFA_BROADCAST,
+ IFA_ANYCAST,
+ IFA_CACHEINFO,
+ IFA_MULTICAST,
+ __IFA_MAX,
+};
+
+#define IFA_MAX (__IFA_MAX - 1)
+
+/* ifa_flags */
+#define IFA_F_SECONDARY 0x01
+#define IFA_F_TEMPORARY IFA_F_SECONDARY
+
+#define IFA_F_NODAD 0x02
+#define IFA_F_OPTIMISTIC 0x04
+#define IFA_F_HOMEADDRESS 0x10
+#define IFA_F_DEPRECATED 0x20
+#define IFA_F_TENTATIVE 0x40
+#define IFA_F_PERMANENT 0x80
+
+struct ifa_cacheinfo
+{
+ __u32 ifa_prefered;
+ __u32 ifa_valid;
+ __u32 cstamp; /* created timestamp, hundredths of seconds */
+ __u32 tstamp; /* updated timestamp, hundredths of seconds */
+};
+
+/* backwards compatibility for userspace */
+#ifndef __KERNEL__
+#define IFA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifaddrmsg))))
+#define IFA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifaddrmsg))
+#endif
+
+#endif
diff --git a/package/libs/libnl-tiny/src/include/linux/.svn/text-base/netlink.h.svn-base b/package/libs/libnl-tiny/src/include/linux/.svn/text-base/netlink.h.svn-base
new file mode 100644
index 0000000..d252103
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/linux/.svn/text-base/netlink.h.svn-base
@@ -0,0 +1,150 @@
+#ifndef __LINUX_NETLINK_H
+#define __LINUX_NETLINK_H
+
+#include <linux/socket.h> /* for sa_family_t */
+#include <linux/types.h>
+
+#define NETLINK_ROUTE 0 /* Routing/device hook */
+#define NETLINK_UNUSED 1 /* Unused number */
+#define NETLINK_USERSOCK 2 /* Reserved for user mode socket protocols */
+#define NETLINK_FIREWALL 3 /* Firewalling hook */
+#define NETLINK_INET_DIAG 4 /* INET socket monitoring */
+#define NETLINK_NFLOG 5 /* netfilter/iptables ULOG */
+#define NETLINK_XFRM 6 /* ipsec */
+#define NETLINK_SELINUX 7 /* SELinux event notifications */
+#define NETLINK_ISCSI 8 /* Open-iSCSI */
+#define NETLINK_AUDIT 9 /* auditing */
+#define NETLINK_FIB_LOOKUP 10
+#define NETLINK_CONNECTOR 11
+#define NETLINK_NETFILTER 12 /* netfilter subsystem */
+#define NETLINK_IP6_FW 13
+#define NETLINK_DNRTMSG 14 /* DECnet routing messages */
+#define NETLINK_KOBJECT_UEVENT 15 /* Kernel messages to userspace */
+#define NETLINK_GENERIC 16
+/* leave room for NETLINK_DM (DM Events) */
+#define NETLINK_SCSITRANSPORT 18 /* SCSI Transports */
+#define NETLINK_ECRYPTFS 19
+
+#define MAX_LINKS 32
+
+struct sockaddr_nl
+{
+ sa_family_t nl_family; /* AF_NETLINK */
+ unsigned short nl_pad; /* zero */
+ __u32 nl_pid; /* port ID */
+ __u32 nl_groups; /* multicast groups mask */
+};
+
+struct nlmsghdr
+{
+ __u32 nlmsg_len; /* Length of message including header */
+ __u16 nlmsg_type; /* Message content */
+ __u16 nlmsg_flags; /* Additional flags */
+ __u32 nlmsg_seq; /* Sequence number */
+ __u32 nlmsg_pid; /* Sending process port ID */
+};
+
+/* Flags values */
+
+#define NLM_F_REQUEST 1 /* It is request message. */
+#define NLM_F_MULTI 2 /* Multipart message, terminated by NLMSG_DONE */
+#define NLM_F_ACK 4 /* Reply with ack, with zero or error code */
+#define NLM_F_ECHO 8 /* Echo this request */
+
+/* Modifiers to GET request */
+#define NLM_F_ROOT 0x100 /* specify tree root */
+#define NLM_F_MATCH 0x200 /* return all matching */
+#define NLM_F_ATOMIC 0x400 /* atomic GET */
+#define NLM_F_DUMP (NLM_F_ROOT|NLM_F_MATCH)
+
+/* Modifiers to NEW request */
+#define NLM_F_REPLACE 0x100 /* Override existing */
+#define NLM_F_EXCL 0x200 /* Do not touch, if it exists */
+#define NLM_F_CREATE 0x400 /* Create, if it does not exist */
+#define NLM_F_APPEND 0x800 /* Add to end of list */
+
+/*
+ 4.4BSD ADD NLM_F_CREATE|NLM_F_EXCL
+ 4.4BSD CHANGE NLM_F_REPLACE
+
+ True CHANGE NLM_F_CREATE|NLM_F_REPLACE
+ Append NLM_F_CREATE
+ Check NLM_F_EXCL
+ */
+
+#define NLMSG_ALIGNTO 4
+#define NLMSG_ALIGN(len) ( ((len)+NLMSG_ALIGNTO-1) & ~(NLMSG_ALIGNTO-1) )
+#define NLMSG_HDRLEN ((int) NLMSG_ALIGN(sizeof(struct nlmsghdr)))
+#define NLMSG_LENGTH(len) ((len)+NLMSG_ALIGN(NLMSG_HDRLEN))
+#define NLMSG_SPACE(len) NLMSG_ALIGN(NLMSG_LENGTH(len))
+#define NLMSG_DATA(nlh) ((void*)(((char*)nlh) + NLMSG_LENGTH(0)))
+#define NLMSG_NEXT(nlh,len) ((len) -= NLMSG_ALIGN((nlh)->nlmsg_len), \
+ (struct nlmsghdr*)(((char*)(nlh)) + NLMSG_ALIGN((nlh)->nlmsg_len)))
+#define NLMSG_OK(nlh,len) ((len) >= (int)sizeof(struct nlmsghdr) && \
+ (nlh)->nlmsg_len >= sizeof(struct nlmsghdr) && \
+ (nlh)->nlmsg_len <= (len))
+#define NLMSG_PAYLOAD(nlh,len) ((nlh)->nlmsg_len - NLMSG_SPACE((len)))
+
+#define NLMSG_NOOP 0x1 /* Nothing. */
+#define NLMSG_ERROR 0x2 /* Error */
+#define NLMSG_DONE 0x3 /* End of a dump */
+#define NLMSG_OVERRUN 0x4 /* Data lost */
+
+#define NLMSG_MIN_TYPE 0x10 /* < 0x10: reserved control messages */
+
+struct nlmsgerr
+{
+ int error;
+ struct nlmsghdr msg;
+};
+
+#define NETLINK_ADD_MEMBERSHIP 1
+#define NETLINK_DROP_MEMBERSHIP 2
+#define NETLINK_PKTINFO 3
+
+struct nl_pktinfo
+{
+ __u32 group;
+};
+
+#define NET_MAJOR 36 /* Major 36 is reserved for networking */
+
+enum {
+ NETLINK_UNCONNECTED = 0,
+ NETLINK_CONNECTED,
+};
+
+/*
+ * <------- NLA_HDRLEN ------> <-- NLA_ALIGN(payload)-->
+ * +---------------------+- - -+- - - - - - - - - -+- - -+
+ * | Header | Pad | Payload | Pad |
+ * | (struct nlattr) | ing | | ing |
+ * +---------------------+- - -+- - - - - - - - - -+- - -+
+ * <-------------- nlattr->nla_len -------------->
+ */
+
+struct nlattr
+{
+ __u16 nla_len;
+ __u16 nla_type;
+};
+
+/*
+ * nla_type (16 bits)
+ * +---+---+-------------------------------+
+ * | N | O | Attribute Type |
+ * +---+---+-------------------------------+
+ * N := Carries nested attributes
+ * O := Payload stored in network byte order
+ *
+ * Note: The N and O flag are mutually exclusive.
+ */
+#define NLA_F_NESTED (1 << 15)
+#define NLA_F_NET_BYTEORDER (1 << 14)
+#define NLA_TYPE_MASK ~(NLA_F_NESTED | NLA_F_NET_BYTEORDER)
+
+#define NLA_ALIGNTO 4
+#define NLA_ALIGN(len) (((len) + NLA_ALIGNTO - 1) & ~(NLA_ALIGNTO - 1))
+#define NLA_HDRLEN ((int) NLA_ALIGN(sizeof(struct nlattr)))
+
+#endif /* __LINUX_NETLINK_H */
diff --git a/package/libs/libnl-tiny/src/include/linux/gen_stats.h b/package/libs/libnl-tiny/src/include/linux/gen_stats.h
new file mode 100644
index 0000000..13f4e74
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/linux/gen_stats.h
@@ -0,0 +1,67 @@
+#ifndef __LINUX_GEN_STATS_H
+#define __LINUX_GEN_STATS_H
+
+#include <linux/types.h>
+
+enum {
+ TCA_STATS_UNSPEC,
+ TCA_STATS_BASIC,
+ TCA_STATS_RATE_EST,
+ TCA_STATS_QUEUE,
+ TCA_STATS_APP,
+ __TCA_STATS_MAX,
+};
+#define TCA_STATS_MAX (__TCA_STATS_MAX - 1)
+
+/**
+ * struct gnet_stats_basic - byte/packet throughput statistics
+ * @bytes: number of seen bytes
+ * @packets: number of seen packets
+ */
+struct gnet_stats_basic
+{
+ __u64 bytes;
+ __u32 packets;
+};
+
+/**
+ * struct gnet_stats_rate_est - rate estimator
+ * @bps: current byte rate
+ * @pps: current packet rate
+ */
+struct gnet_stats_rate_est
+{
+ __u32 bps;
+ __u32 pps;
+};
+
+/**
+ * struct gnet_stats_queue - queuing statistics
+ * @qlen: queue length
+ * @backlog: backlog size of queue
+ * @drops: number of dropped packets
+ * @requeues: number of requeues
+ * @overlimits: number of enqueues over the limit
+ */
+struct gnet_stats_queue
+{
+ __u32 qlen;
+ __u32 backlog;
+ __u32 drops;
+ __u32 requeues;
+ __u32 overlimits;
+};
+
+/**
+ * struct gnet_estimator - rate estimator configuration
+ * @interval: sampling period
+ * @ewma_log: the log of measurement window weight
+ */
+struct gnet_estimator
+{
+ signed char interval;
+ unsigned char ewma_log;
+};
+
+
+#endif /* __LINUX_GEN_STATS_H */
diff --git a/package/libs/libnl-tiny/src/include/linux/genetlink.h b/package/libs/libnl-tiny/src/include/linux/genetlink.h
new file mode 100644
index 0000000..b834ef6
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/linux/genetlink.h
@@ -0,0 +1,83 @@
+#ifndef __LINUX_GENERIC_NETLINK_H
+#define __LINUX_GENERIC_NETLINK_H
+
+#include <linux/types.h>
+#include <linux/netlink.h>
+
+#define GENL_NAMSIZ 16 /* length of family name */
+
+#define GENL_MIN_ID NLMSG_MIN_TYPE
+#define GENL_MAX_ID 1023
+
+struct genlmsghdr {
+ __u8 cmd;
+ __u8 version;
+ __u16 reserved;
+};
+
+#define GENL_HDRLEN NLMSG_ALIGN(sizeof(struct genlmsghdr))
+
+#define GENL_ADMIN_PERM 0x01
+#define GENL_CMD_CAP_DO 0x02
+#define GENL_CMD_CAP_DUMP 0x04
+#define GENL_CMD_CAP_HASPOL 0x08
+
+/*
+ * List of reserved static generic netlink identifiers:
+ */
+#define GENL_ID_GENERATE 0
+#define GENL_ID_CTRL NLMSG_MIN_TYPE
+
+/**************************************************************************
+ * Controller
+ **************************************************************************/
+
+enum {
+ CTRL_CMD_UNSPEC,
+ CTRL_CMD_NEWFAMILY,
+ CTRL_CMD_DELFAMILY,
+ CTRL_CMD_GETFAMILY,
+ CTRL_CMD_NEWOPS,
+ CTRL_CMD_DELOPS,
+ CTRL_CMD_GETOPS,
+ CTRL_CMD_NEWMCAST_GRP,
+ CTRL_CMD_DELMCAST_GRP,
+ CTRL_CMD_GETMCAST_GRP, /* unused */
+ __CTRL_CMD_MAX,
+};
+
+#define CTRL_CMD_MAX (__CTRL_CMD_MAX - 1)
+
+enum {
+ CTRL_ATTR_UNSPEC,
+ CTRL_ATTR_FAMILY_ID,
+ CTRL_ATTR_FAMILY_NAME,
+ CTRL_ATTR_VERSION,
+ CTRL_ATTR_HDRSIZE,
+ CTRL_ATTR_MAXATTR,
+ CTRL_ATTR_OPS,
+ CTRL_ATTR_MCAST_GROUPS,
+ __CTRL_ATTR_MAX,
+};
+
+#define CTRL_ATTR_MAX (__CTRL_ATTR_MAX - 1)
+
+enum {
+ CTRL_ATTR_OP_UNSPEC,
+ CTRL_ATTR_OP_ID,
+ CTRL_ATTR_OP_FLAGS,
+ __CTRL_ATTR_OP_MAX,
+};
+
+#define CTRL_ATTR_OP_MAX (__CTRL_ATTR_OP_MAX - 1)
+
+enum {
+ CTRL_ATTR_MCAST_GRP_UNSPEC,
+ CTRL_ATTR_MCAST_GRP_NAME,
+ CTRL_ATTR_MCAST_GRP_ID,
+ __CTRL_ATTR_MCAST_GRP_MAX,
+};
+
+#define CTRL_ATTR_MCAST_GRP_MAX (__CTRL_ATTR_MCAST_GRP_MAX - 1)
+
+#endif /* __LINUX_GENERIC_NETLINK_H */
diff --git a/package/libs/libnl-tiny/src/include/linux/if.h b/package/libs/libnl-tiny/src/include/linux/if.h
new file mode 100644
index 0000000..4c1bcfe
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/linux/if.h
@@ -0,0 +1,131 @@
+/*
+ * INET An implementation of the TCP/IP protocol suite for the LINUX
+ * operating system. INET is implemented using the BSD Socket
+ * interface as the means of communication with the user level.
+ *
+ * Global definitions for the INET interface module.
+ *
+ * Version: @(#)if.h 1.0.2 04/18/93
+ *
+ * Authors: Original taken from Berkeley UNIX 4.3, (c) UCB 1982-1988
+ * Ross Biro
+ * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
+ *
+ * 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 of the License, or (at your option) any later version.
+ */
+#ifndef _LINUX_IF_H
+#define _LINUX_IF_H
+
+#include <linux/types.h> /* for "__kernel_caddr_t" et al */
+
+#define IFNAMSIZ 16
+
+/* Standard interface flags (netdevice->flags). */
+#define IFF_UP 0x1 /* interface is up */
+#define IFF_BROADCAST 0x2 /* broadcast address valid */
+#define IFF_DEBUG 0x4 /* turn on debugging */
+#define IFF_LOOPBACK 0x8 /* is a loopback net */
+#define IFF_POINTOPOINT 0x10 /* interface is has p-p link */
+#define IFF_NOTRAILERS 0x20 /* avoid use of trailers */
+#define IFF_RUNNING 0x40 /* interface RFC2863 OPER_UP */
+#define IFF_NOARP 0x80 /* no ARP protocol */
+#define IFF_PROMISC 0x100 /* receive all packets */
+#define IFF_ALLMULTI 0x200 /* receive all multicast packets*/
+
+#define IFF_MASTER 0x400 /* master of a load balancer */
+#define IFF_SLAVE 0x800 /* slave of a load balancer */
+
+#define IFF_MULTICAST 0x1000 /* Supports multicast */
+
+#define IFF_PORTSEL 0x2000 /* can set media type */
+#define IFF_AUTOMEDIA 0x4000 /* auto media select active */
+#define IFF_DYNAMIC 0x8000 /* dialup device with changing addresses*/
+
+#define IFF_LOWER_UP 0x10000 /* driver signals L1 up */
+#define IFF_DORMANT 0x20000 /* driver signals dormant */
+
+#define IFF_ECHO 0x40000 /* echo sent packets */
+
+#define IFF_VOLATILE (IFF_LOOPBACK|IFF_POINTOPOINT|IFF_BROADCAST|IFF_ECHO|\
+ IFF_MASTER|IFF_SLAVE|IFF_RUNNING|IFF_LOWER_UP|IFF_DORMANT)
+
+/* Private (from user) interface flags (netdevice->priv_flags). */
+#define IFF_802_1Q_VLAN 0x1 /* 802.1Q VLAN device. */
+#define IFF_EBRIDGE 0x2 /* Ethernet bridging device. */
+#define IFF_SLAVE_INACTIVE 0x4 /* bonding slave not the curr. active */
+#define IFF_MASTER_8023AD 0x8 /* bonding master, 802.3ad. */
+#define IFF_MASTER_ALB 0x10 /* bonding master, balance-alb. */
+#define IFF_BONDING 0x20 /* bonding master or slave */
+#define IFF_SLAVE_NEEDARP 0x40 /* need ARPs for validation */
+#define IFF_ISATAP 0x80 /* ISATAP interface (RFC4214) */
+
+#define IF_GET_IFACE 0x0001 /* for querying only */
+#define IF_GET_PROTO 0x0002
+
+/* For definitions see hdlc.h */
+#define IF_IFACE_V35 0x1000 /* V.35 serial interface */
+#define IF_IFACE_V24 0x1001 /* V.24 serial interface */
+#define IF_IFACE_X21 0x1002 /* X.21 serial interface */
+#define IF_IFACE_T1 0x1003 /* T1 telco serial interface */
+#define IF_IFACE_E1 0x1004 /* E1 telco serial interface */
+#define IF_IFACE_SYNC_SERIAL 0x1005 /* can't be set by software */
+#define IF_IFACE_X21D 0x1006 /* X.21 Dual Clocking (FarSite) */
+
+/* For definitions see hdlc.h */
+#define IF_PROTO_HDLC 0x2000 /* raw HDLC protocol */
+#define IF_PROTO_PPP 0x2001 /* PPP protocol */
+#define IF_PROTO_CISCO 0x2002 /* Cisco HDLC protocol */
+#define IF_PROTO_FR 0x2003 /* Frame Relay protocol */
+#define IF_PROTO_FR_ADD_PVC 0x2004 /* Create FR PVC */
+#define IF_PROTO_FR_DEL_PVC 0x2005 /* Delete FR PVC */
+#define IF_PROTO_X25 0x2006 /* X.25 */
+#define IF_PROTO_HDLC_ETH 0x2007 /* raw HDLC, Ethernet emulation */
+#define IF_PROTO_FR_ADD_ETH_PVC 0x2008 /* Create FR Ethernet-bridged PVC */
+#define IF_PROTO_FR_DEL_ETH_PVC 0x2009 /* Delete FR Ethernet-bridged PVC */
+#define IF_PROTO_FR_PVC 0x200A /* for reading PVC status */
+#define IF_PROTO_FR_ETH_PVC 0x200B
+#define IF_PROTO_RAW 0x200C /* RAW Socket */
+
+/* RFC 2863 operational status */
+enum {
+ IF_OPER_UNKNOWN,
+ IF_OPER_NOTPRESENT,
+ IF_OPER_DOWN,
+ IF_OPER_LOWERLAYERDOWN,
+ IF_OPER_TESTING,
+ IF_OPER_DORMANT,
+ IF_OPER_UP,
+};
+
+/* link modes */
+enum {
+ IF_LINK_MODE_DEFAULT,
+ IF_LINK_MODE_DORMANT, /* limit upward transition to dormant */
+};
+
+/*
+ * Device mapping structure. I'd just gone off and designed a
+ * beautiful scheme using only loadable modules with arguments
+ * for driver options and along come the PCMCIA people 8)
+ *
+ * Ah well. The get() side of this is good for WDSETUP, and it'll
+ * be handy for debugging things. The set side is fine for now and
+ * being very small might be worth keeping for clean configuration.
+ */
+
+struct ifmap
+{
+ unsigned long mem_start;
+ unsigned long mem_end;
+ unsigned short base_addr;
+ unsigned char irq;
+ unsigned char dma;
+ unsigned char port;
+ /* 3 bytes spare */
+};
+
+
+#endif /* _LINUX_IF_H */
diff --git a/package/libs/libnl-tiny/src/include/linux/if_addr.h b/package/libs/libnl-tiny/src/include/linux/if_addr.h
new file mode 100644
index 0000000..43f3bed
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/linux/if_addr.h
@@ -0,0 +1,62 @@
+#ifndef __LINUX_IF_ADDR_H
+#define __LINUX_IF_ADDR_H
+
+#include <linux/netlink.h>
+
+struct ifaddrmsg
+{
+ __u8 ifa_family;
+ __u8 ifa_prefixlen; /* The prefix length */
+ __u8 ifa_flags; /* Flags */
+ __u8 ifa_scope; /* Address scope */
+ __u32 ifa_index; /* Link index */
+};
+
+/*
+ * Important comment:
+ * IFA_ADDRESS is prefix address, rather than local interface address.
+ * It makes no difference for normally configured broadcast interfaces,
+ * but for point-to-point IFA_ADDRESS is DESTINATION address,
+ * local address is supplied in IFA_LOCAL attribute.
+ */
+enum
+{
+ IFA_UNSPEC,
+ IFA_ADDRESS,
+ IFA_LOCAL,
+ IFA_LABEL,
+ IFA_BROADCAST,
+ IFA_ANYCAST,
+ IFA_CACHEINFO,
+ IFA_MULTICAST,
+ __IFA_MAX,
+};
+
+#define IFA_MAX (__IFA_MAX - 1)
+
+/* ifa_flags */
+#define IFA_F_SECONDARY 0x01
+#define IFA_F_TEMPORARY IFA_F_SECONDARY
+
+#define IFA_F_NODAD 0x02
+#define IFA_F_OPTIMISTIC 0x04
+#define IFA_F_HOMEADDRESS 0x10
+#define IFA_F_DEPRECATED 0x20
+#define IFA_F_TENTATIVE 0x40
+#define IFA_F_PERMANENT 0x80
+
+struct ifa_cacheinfo
+{
+ __u32 ifa_prefered;
+ __u32 ifa_valid;
+ __u32 cstamp; /* created timestamp, hundredths of seconds */
+ __u32 tstamp; /* updated timestamp, hundredths of seconds */
+};
+
+/* backwards compatibility for userspace */
+#ifndef __KERNEL__
+#define IFA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifaddrmsg))))
+#define IFA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifaddrmsg))
+#endif
+
+#endif
diff --git a/package/libs/libnl-tiny/src/include/linux/netlink.h b/package/libs/libnl-tiny/src/include/linux/netlink.h
new file mode 100644
index 0000000..d252103
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/linux/netlink.h
@@ -0,0 +1,150 @@
+#ifndef __LINUX_NETLINK_H
+#define __LINUX_NETLINK_H
+
+#include <linux/socket.h> /* for sa_family_t */
+#include <linux/types.h>
+
+#define NETLINK_ROUTE 0 /* Routing/device hook */
+#define NETLINK_UNUSED 1 /* Unused number */
+#define NETLINK_USERSOCK 2 /* Reserved for user mode socket protocols */
+#define NETLINK_FIREWALL 3 /* Firewalling hook */
+#define NETLINK_INET_DIAG 4 /* INET socket monitoring */
+#define NETLINK_NFLOG 5 /* netfilter/iptables ULOG */
+#define NETLINK_XFRM 6 /* ipsec */
+#define NETLINK_SELINUX 7 /* SELinux event notifications */
+#define NETLINK_ISCSI 8 /* Open-iSCSI */
+#define NETLINK_AUDIT 9 /* auditing */
+#define NETLINK_FIB_LOOKUP 10
+#define NETLINK_CONNECTOR 11
+#define NETLINK_NETFILTER 12 /* netfilter subsystem */
+#define NETLINK_IP6_FW 13
+#define NETLINK_DNRTMSG 14 /* DECnet routing messages */
+#define NETLINK_KOBJECT_UEVENT 15 /* Kernel messages to userspace */
+#define NETLINK_GENERIC 16
+/* leave room for NETLINK_DM (DM Events) */
+#define NETLINK_SCSITRANSPORT 18 /* SCSI Transports */
+#define NETLINK_ECRYPTFS 19
+
+#define MAX_LINKS 32
+
+struct sockaddr_nl
+{
+ sa_family_t nl_family; /* AF_NETLINK */
+ unsigned short nl_pad; /* zero */
+ __u32 nl_pid; /* port ID */
+ __u32 nl_groups; /* multicast groups mask */
+};
+
+struct nlmsghdr
+{
+ __u32 nlmsg_len; /* Length of message including header */
+ __u16 nlmsg_type; /* Message content */
+ __u16 nlmsg_flags; /* Additional flags */
+ __u32 nlmsg_seq; /* Sequence number */
+ __u32 nlmsg_pid; /* Sending process port ID */
+};
+
+/* Flags values */
+
+#define NLM_F_REQUEST 1 /* It is request message. */
+#define NLM_F_MULTI 2 /* Multipart message, terminated by NLMSG_DONE */
+#define NLM_F_ACK 4 /* Reply with ack, with zero or error code */
+#define NLM_F_ECHO 8 /* Echo this request */
+
+/* Modifiers to GET request */
+#define NLM_F_ROOT 0x100 /* specify tree root */
+#define NLM_F_MATCH 0x200 /* return all matching */
+#define NLM_F_ATOMIC 0x400 /* atomic GET */
+#define NLM_F_DUMP (NLM_F_ROOT|NLM_F_MATCH)
+
+/* Modifiers to NEW request */
+#define NLM_F_REPLACE 0x100 /* Override existing */
+#define NLM_F_EXCL 0x200 /* Do not touch, if it exists */
+#define NLM_F_CREATE 0x400 /* Create, if it does not exist */
+#define NLM_F_APPEND 0x800 /* Add to end of list */
+
+/*
+ 4.4BSD ADD NLM_F_CREATE|NLM_F_EXCL
+ 4.4BSD CHANGE NLM_F_REPLACE
+
+ True CHANGE NLM_F_CREATE|NLM_F_REPLACE
+ Append NLM_F_CREATE
+ Check NLM_F_EXCL
+ */
+
+#define NLMSG_ALIGNTO 4
+#define NLMSG_ALIGN(len) ( ((len)+NLMSG_ALIGNTO-1) & ~(NLMSG_ALIGNTO-1) )
+#define NLMSG_HDRLEN ((int) NLMSG_ALIGN(sizeof(struct nlmsghdr)))
+#define NLMSG_LENGTH(len) ((len)+NLMSG_ALIGN(NLMSG_HDRLEN))
+#define NLMSG_SPACE(len) NLMSG_ALIGN(NLMSG_LENGTH(len))
+#define NLMSG_DATA(nlh) ((void*)(((char*)nlh) + NLMSG_LENGTH(0)))
+#define NLMSG_NEXT(nlh,len) ((len) -= NLMSG_ALIGN((nlh)->nlmsg_len), \
+ (struct nlmsghdr*)(((char*)(nlh)) + NLMSG_ALIGN((nlh)->nlmsg_len)))
+#define NLMSG_OK(nlh,len) ((len) >= (int)sizeof(struct nlmsghdr) && \
+ (nlh)->nlmsg_len >= sizeof(struct nlmsghdr) && \
+ (nlh)->nlmsg_len <= (len))
+#define NLMSG_PAYLOAD(nlh,len) ((nlh)->nlmsg_len - NLMSG_SPACE((len)))
+
+#define NLMSG_NOOP 0x1 /* Nothing. */
+#define NLMSG_ERROR 0x2 /* Error */
+#define NLMSG_DONE 0x3 /* End of a dump */
+#define NLMSG_OVERRUN 0x4 /* Data lost */
+
+#define NLMSG_MIN_TYPE 0x10 /* < 0x10: reserved control messages */
+
+struct nlmsgerr
+{
+ int error;
+ struct nlmsghdr msg;
+};
+
+#define NETLINK_ADD_MEMBERSHIP 1
+#define NETLINK_DROP_MEMBERSHIP 2
+#define NETLINK_PKTINFO 3
+
+struct nl_pktinfo
+{
+ __u32 group;
+};
+
+#define NET_MAJOR 36 /* Major 36 is reserved for networking */
+
+enum {
+ NETLINK_UNCONNECTED = 0,
+ NETLINK_CONNECTED,
+};
+
+/*
+ * <------- NLA_HDRLEN ------> <-- NLA_ALIGN(payload)-->
+ * +---------------------+- - -+- - - - - - - - - -+- - -+
+ * | Header | Pad | Payload | Pad |
+ * | (struct nlattr) | ing | | ing |
+ * +---------------------+- - -+- - - - - - - - - -+- - -+
+ * <-------------- nlattr->nla_len -------------->
+ */
+
+struct nlattr
+{
+ __u16 nla_len;
+ __u16 nla_type;
+};
+
+/*
+ * nla_type (16 bits)
+ * +---+---+-------------------------------+
+ * | N | O | Attribute Type |
+ * +---+---+-------------------------------+
+ * N := Carries nested attributes
+ * O := Payload stored in network byte order
+ *
+ * Note: The N and O flag are mutually exclusive.
+ */
+#define NLA_F_NESTED (1 << 15)
+#define NLA_F_NET_BYTEORDER (1 << 14)
+#define NLA_TYPE_MASK ~(NLA_F_NESTED | NLA_F_NET_BYTEORDER)
+
+#define NLA_ALIGNTO 4
+#define NLA_ALIGN(len) (((len) + NLA_ALIGNTO - 1) & ~(NLA_ALIGNTO - 1))
+#define NLA_HDRLEN ((int) NLA_ALIGN(sizeof(struct nlattr)))
+
+#endif /* __LINUX_NETLINK_H */
diff --git a/package/libs/libnl-tiny/src/include/netlink-generic.h b/package/libs/libnl-tiny/src/include/netlink-generic.h
new file mode 100644
index 0000000..10aa2f0
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/netlink-generic.h
@@ -0,0 +1,20 @@
+/*
+ * netlink-generic.h Local Generic Netlink Interface
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
+ */
+
+#ifndef NETLINK_GENL_PRIV_H_
+#define NETLINK_GENL_PRIV_H_
+
+#include <netlink-local.h>
+#include <netlink/netlink.h>
+
+#define GENL_HDRSIZE(hdrlen) (GENL_HDRLEN + (hdrlen))
+
+#endif
diff --git a/package/libs/libnl-tiny/src/include/netlink-local.h b/package/libs/libnl-tiny/src/include/netlink-local.h
new file mode 100644
index 0000000..330100e
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/netlink-local.h
@@ -0,0 +1,158 @@
+/*
+ * netlink-local.h Local Netlink Interface
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
+ */
+
+#ifndef NETLINK_LOCAL_H_
+#define NETLINK_LOCAL_H_
+#define _GNU_SOURCE
+
+#include <stdio.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <math.h>
+#include <time.h>
+#include <stdarg.h>
+#include <ctype.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <inttypes.h>
+#include <assert.h>
+#include <limits.h>
+
+#include <arpa/inet.h>
+#include <netdb.h>
+
+#ifndef SOL_NETLINK
+#define SOL_NETLINK 270
+#endif
+
+#include <linux/types.h>
+
+/* local header copies */
+#include <linux/if.h>
+#include <linux/if_arp.h>
+#include <linux/if_ether.h>
+#include <linux/pkt_sched.h>
+#include <linux/pkt_cls.h>
+#include <linux/gen_stats.h>
+
+#include <netlink/netlink.h>
+#include <netlink/handlers.h>
+#include <netlink/cache.h>
+#include <netlink/object-api.h>
+#include <netlink/cache-api.h>
+#include <netlink-types.h>
+
+struct trans_tbl {
+ int i;
+ const char *a;
+};
+
+#define __ADD(id, name) { .i = id, .a = #name },
+
+struct trans_list {
+ int i;
+ char *a;
+ struct nl_list_head list;
+};
+
+#define NL_DEBUG 1
+
+#define NL_DBG(LVL,FMT,ARG...) \
+ do {} while (0)
+
+#define BUG() \
+ do { \
+ fprintf(stderr, "BUG: %s:%d\n", \
+ __FILE__, __LINE__); \
+ assert(0); \
+ } while (0)
+
+extern int __nl_read_num_str_file(const char *path,
+ int (*cb)(long, const char *));
+
+extern int __trans_list_add(int, const char *, struct nl_list_head *);
+extern void __trans_list_clear(struct nl_list_head *);
+
+extern char *__type2str(int, char *, size_t, struct trans_tbl *, size_t);
+extern int __str2type(const char *, struct trans_tbl *, size_t);
+
+extern char *__list_type2str(int, char *, size_t, struct nl_list_head *);
+extern int __list_str2type(const char *, struct nl_list_head *);
+
+extern char *__flags2str(int, char *, size_t, struct trans_tbl *, size_t);
+extern int __str2flags(const char *, struct trans_tbl *, size_t);
+
+extern void dump_from_ops(struct nl_object *, struct nl_dump_params *);
+
+#ifdef disabled
+static inline struct nl_cache *dp_cache(struct nl_object *obj)
+{
+ if (obj->ce_cache == NULL)
+ return nl_cache_mngt_require(obj->ce_ops->oo_name);
+
+ return obj->ce_cache;
+}
+#endif
+
+static inline int nl_cb_call(struct nl_cb *cb, int type, struct nl_msg *msg)
+{
+ return cb->cb_set[type](msg, cb->cb_args[type]);
+}
+
+#define ARRAY_SIZE(X) (sizeof(X) / sizeof((X)[0]))
+#ifndef offsetof
+#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
+#endif
+
+#define __init __attribute__ ((constructor))
+#define __exit __attribute__ ((destructor))
+#undef __deprecated
+#define __deprecated __attribute__ ((deprecated))
+
+#define min(x,y) ({ \
+ typeof(x) _x = (x); \
+ typeof(y) _y = (y); \
+ (void) (&_x == &_y); \
+ _x < _y ? _x : _y; })
+
+#define max(x,y) ({ \
+ typeof(x) _x = (x); \
+ typeof(y) _y = (y); \
+ (void) (&_x == &_y); \
+ _x > _y ? _x : _y; })
+
+extern int nl_cache_parse(struct nl_cache_ops *, struct sockaddr_nl *,
+ struct nlmsghdr *, struct nl_parser_param *);
+
+
+static inline char *nl_cache_name(struct nl_cache *cache)
+{
+ return cache->c_ops ? cache->c_ops->co_name : "unknown";
+}
+
+#define GENL_FAMILY(id, name) \
+ { \
+ { id, NL_ACT_UNSPEC, name }, \
+ END_OF_MSGTYPES_LIST, \
+ }
+
+static inline int wait_for_ack(struct nl_sock *sk)
+{
+ if (sk->s_flags & NL_NO_AUTO_ACK)
+ return 0;
+ else
+ return nl_wait_for_ack(sk);
+}
+
+#endif
diff --git a/package/libs/libnl-tiny/src/include/netlink-types.h b/package/libs/libnl-tiny/src/include/netlink-types.h
new file mode 100644
index 0000000..0d00593
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/netlink-types.h
@@ -0,0 +1,81 @@
+/*
+ * netlink-types.h Netlink Types (Private)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
+ */
+
+#ifndef NETLINK_LOCAL_TYPES_H_
+#define NETLINK_LOCAL_TYPES_H_
+
+#include <netlink/list.h>
+
+struct nl_cache_ops;
+struct nl_sock;
+struct nl_object;
+
+struct nl_cache
+{
+ struct nl_list_head c_items;
+ int c_nitems;
+ int c_iarg1;
+ int c_iarg2;
+ struct nl_cache_ops * c_ops;
+};
+
+struct nl_cache_assoc
+{
+ struct nl_cache * ca_cache;
+ change_func_t ca_change;
+};
+
+struct nl_cache_mngr
+{
+ int cm_protocol;
+ int cm_flags;
+ int cm_nassocs;
+ struct nl_sock * cm_handle;
+ struct nl_cache_assoc * cm_assocs;
+};
+
+struct nl_parser_param;
+
+#define LOOSE_COMPARISON 1
+
+
+struct nl_data
+{
+ size_t d_size;
+ void * d_data;
+};
+
+struct nl_addr
+{
+ int a_family;
+ unsigned int a_maxsize;
+ unsigned int a_len;
+ int a_prefixlen;
+ int a_refcnt;
+ char a_addr[0];
+};
+
+#define IFQDISCSIZ 32
+
+#define GENL_OP_HAS_POLICY 1
+#define GENL_OP_HAS_DOIT 2
+#define GENL_OP_HAS_DUMPIT 4
+
+struct genl_family_op
+{
+ uint32_t o_id;
+ uint32_t o_flags;
+
+ struct nl_list_head o_list;
+};
+
+
+#endif
diff --git a/package/libs/libnl-tiny/src/include/netlink/.svn/entries b/package/libs/libnl-tiny/src/include/netlink/.svn/entries
new file mode 100644
index 0000000..d00cb28
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/netlink/.svn/entries
@@ -0,0 +1,643 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs/libnl-tiny/src/include/netlink
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+genl
+dir
+
+handlers.h
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+bd771081d6969e025390a628412e885b
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5293
+
+utils.h
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+5cbc63239c889d821aa8efd8b2db4189
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1882
+
+cache.h
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+742a6da7abd7a7ab114c54f86e6875d7
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4092
+
+netlink.h
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+44d8f531c12914c856e314e677002c77
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2098
+
+types.h
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+dd13f7f954318661bdde149510fb3a64
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2475
+
+object.h
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+14a5292fc2112c7924b77aa29b28e09c
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3186
+
+data.h
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+c43b67441de105f7293d6b8694949541
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+976
+
+addr.h
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+f9f9f1097531f641dc614d90f825c9f8
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2201
+
+attr.h
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+dbd27941627b96fdc95d3bffaf9b4658
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+17786
+
+cache-api.h
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+df253211debbabccb07ea1650f2f4972
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5166
+
+list.h
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+9c9652281aefd05dae46fceb89982e79
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2389
+
+object-api.h
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+e053eaa7ab7cf694030d3f28f067ee98
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+9483
+
+netlink-kernel.h
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+3420fd4e299d7063943d050a4826681e
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3049
+
+netlink-compat.h
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+a282e19590d23b4145008dd492451d80
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+988
+
+errno.h
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+6a2c9b23623e6c3d999f4b9410d93a71
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1309
+
+version.h
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+e0f397bba4ee82ccb0086dead3741b10
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+455
+
+msg.h
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+f299d20e909f97e1650bc359527862c9
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+7330
+
+socket.h
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+f4f3de279f23ec6fbdcf555c20d68379
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4997
+
diff --git a/package/libs/libnl-tiny/src/include/netlink/.svn/text-base/addr.h.svn-base b/package/libs/libnl-tiny/src/include/netlink/.svn/text-base/addr.h.svn-base
new file mode 100644
index 0000000..cc3d201
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/netlink/.svn/text-base/addr.h.svn-base
@@ -0,0 +1,69 @@
+/*
+ * netlink/addr.h Abstract Address
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
+ */
+
+#ifndef NETLINK_ADDR_H_
+#define NETLINK_ADDR_H_
+
+#include <netlink/netlink.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct nl_addr;
+
+/* Creation */
+extern struct nl_addr * nl_addr_alloc(size_t);
+extern struct nl_addr * nl_addr_alloc_attr(struct nlattr *, int);
+extern struct nl_addr * nl_addr_build(int, void *, size_t);
+extern int nl_addr_parse(const char *, int, struct nl_addr **);
+extern struct nl_addr * nl_addr_clone(struct nl_addr *);
+
+/* Destroyage */
+extern void nl_addr_destroy(struct nl_addr *);
+
+/* Usage Management */
+extern struct nl_addr * nl_addr_get(struct nl_addr *);
+extern void nl_addr_put(struct nl_addr *);
+extern int nl_addr_shared(struct nl_addr *);
+
+extern int nl_addr_cmp(struct nl_addr *, struct nl_addr *);
+extern int nl_addr_cmp_prefix(struct nl_addr *, struct nl_addr *);
+extern int nl_addr_iszero(struct nl_addr *);
+extern int nl_addr_valid(char *, int);
+extern int nl_addr_guess_family(struct nl_addr *);
+extern int nl_addr_fill_sockaddr(struct nl_addr *,
+ struct sockaddr *, socklen_t *);
+extern int nl_addr_info(struct nl_addr *, struct addrinfo **);
+extern int nl_addr_resolve(struct nl_addr *addr, char *host, size_t hostlen);
+
+/* Access Functions */
+extern void nl_addr_set_family(struct nl_addr *, int);
+extern int nl_addr_get_family(struct nl_addr *);
+extern int nl_addr_set_binary_addr(struct nl_addr *, void *,
+ size_t);
+extern void * nl_addr_get_binary_addr(struct nl_addr *);
+extern unsigned int nl_addr_get_len(struct nl_addr *);
+extern void nl_addr_set_prefixlen(struct nl_addr *, int);
+extern unsigned int nl_addr_get_prefixlen(struct nl_addr *);
+
+/* Address Family Translations */
+extern char * nl_af2str(int, char *, size_t);
+extern int nl_str2af(const char *);
+
+/* Translations to Strings */
+extern char * nl_addr2str(struct nl_addr *, char *, size_t);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/package/libs/libnl-tiny/src/include/netlink/.svn/text-base/attr.h.svn-base b/package/libs/libnl-tiny/src/include/netlink/.svn/text-base/attr.h.svn-base
new file mode 100644
index 0000000..3b56a82
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/netlink/.svn/text-base/attr.h.svn-base
@@ -0,0 +1,726 @@
+/*
+ * netlink/attr.h Netlink Attributes
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
+ */
+
+#ifndef NETLINK_ATTR_H_
+#define NETLINK_ATTR_H_
+
+#include <netlink/netlink.h>
+#include <netlink/object.h>
+#include <netlink/addr.h>
+#include <netlink/data.h>
+#include <netlink/msg.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct nl_msg;
+
+/**
+ * @name Basic Attribute Data Types
+ * @{
+ */
+
+ /**
+ * @ingroup attr
+ * Basic attribute data types
+ *
+ * See \ref attr_datatypes for more details.
+ */
+enum {
+ NLA_UNSPEC, /**< Unspecified type, binary data chunk */
+ NLA_U8, /**< 8 bit integer */
+ NLA_U16, /**< 16 bit integer */
+ NLA_U32, /**< 32 bit integer */
+ NLA_U64, /**< 64 bit integer */
+ NLA_STRING, /**< NUL terminated character string */
+ NLA_FLAG, /**< Flag */
+ NLA_MSECS, /**< Micro seconds (64bit) */
+ NLA_NESTED, /**< Nested attributes */
+ __NLA_TYPE_MAX,
+};
+
+#define NLA_TYPE_MAX (__NLA_TYPE_MAX - 1)
+
+/** @} */
+
+/**
+ * @ingroup attr
+ * Attribute validation policy.
+ *
+ * See \ref attr_datatypes for more details.
+ */
+struct nla_policy {
+ /** Type of attribute or NLA_UNSPEC */
+ uint16_t type;
+
+ /** Minimal length of payload required */
+ uint16_t minlen;
+
+ /** Maximal length of payload allowed */
+ uint16_t maxlen;
+};
+
+/* Attribute parsing */
+extern int nla_ok(const struct nlattr *, int);
+extern struct nlattr * nla_next(const struct nlattr *, int *);
+extern int nla_parse(struct nlattr **, int, struct nlattr *,
+ int, struct nla_policy *);
+extern int nla_validate(struct nlattr *, int, int,
+ struct nla_policy *);
+extern struct nlattr * nla_find(struct nlattr *, int, int);
+
+/* Unspecific attribute */
+extern struct nlattr * nla_reserve(struct nl_msg *, int, int);
+extern int nla_put(struct nl_msg *, int, int, const void *);
+
+/**
+ * nlmsg_find_attr - find a specific attribute in a netlink message
+ * @arg nlh netlink message header
+ * @arg hdrlen length of familiy specific header
+ * @arg attrtype type of attribute to look for
+ *
+ * Returns the first attribute which matches the specified type.
+ */
+static inline struct nlattr *nlmsg_find_attr(struct nlmsghdr *nlh, int hdrlen, int attrtype)
+{
+ return nla_find(nlmsg_attrdata(nlh, hdrlen),
+ nlmsg_attrlen(nlh, hdrlen), attrtype);
+}
+
+
+/**
+ * Return size of attribute whithout padding.
+ * @arg payload Payload length of attribute.
+ *
+ * @code
+ * <-------- nla_attr_size(payload) --------->
+ * +------------------+- - -+- - - - - - - - - +- - -+
+ * | Attribute Header | Pad | Payload | Pad |
+ * +------------------+- - -+- - - - - - - - - +- - -+
+ * @endcode
+ *
+ * @return Size of attribute in bytes without padding.
+ */
+static inline int nla_attr_size(int payload)
+{
+ return NLA_HDRLEN + payload;
+}
+
+/**
+ * Return size of attribute including padding.
+ * @arg payload Payload length of attribute.
+ *
+ * @code
+ * <----------- nla_total_size(payload) ----------->
+ * +------------------+- - -+- - - - - - - - - +- - -+
+ * | Attribute Header | Pad | Payload | Pad |
+ * +------------------+- - -+- - - - - - - - - +- - -+
+ * @endcode
+ *
+ * @return Size of attribute in bytes.
+ */
+static inline int nla_total_size(int payload)
+{
+ return NLA_ALIGN(nla_attr_size(payload));
+}
+
+/**
+ * Return length of padding at the tail of the attribute.
+ * @arg payload Payload length of attribute.
+ *
+ * @code
+ * +------------------+- - -+- - - - - - - - - +- - -+
+ * | Attribute Header | Pad | Payload | Pad |
+ * +------------------+- - -+- - - - - - - - - +- - -+
+ * <--->
+ * @endcode
+ *
+ * @return Length of padding in bytes.
+ */
+static inline int nla_padlen(int payload)
+{
+ return nla_total_size(payload) - nla_attr_size(payload);
+}
+
+/**
+ * Return type of the attribute.
+ * @arg nla Attribute.
+ *
+ * @return Type of attribute.
+ */
+static inline int nla_type(const struct nlattr *nla)
+{
+ return nla->nla_type & NLA_TYPE_MASK;
+}
+
+/**
+ * Return pointer to the payload section.
+ * @arg nla Attribute.
+ *
+ * @return Pointer to start of payload section.
+ */
+static inline void *nla_data(const struct nlattr *nla)
+{
+ return (char *) nla + NLA_HDRLEN;
+}
+
+/**
+ * Return length of the payload .
+ * @arg nla Attribute
+ *
+ * @return Length of payload in bytes.
+ */
+static inline int nla_len(const struct nlattr *nla)
+{
+ return nla->nla_len - NLA_HDRLEN;
+}
+
+/**
+ * Copy attribute payload to another memory area.
+ * @arg dest Pointer to destination memory area.
+ * @arg src Attribute
+ * @arg count Number of bytes to copy at most.
+ *
+ * Note: The number of bytes copied is limited by the length of
+ * the attribute payload.
+ *
+ * @return The number of bytes copied to dest.
+ */
+static inline int nla_memcpy(void *dest, struct nlattr *src, int count)
+{
+ int minlen;
+
+ if (!src)
+ return 0;
+
+ minlen = min_t(int, count, nla_len(src));
+ memcpy(dest, nla_data(src), minlen);
+
+ return minlen;
+}
+
+
+/**
+ * Add abstract data as unspecific attribute to netlink message.
+ * @arg msg Netlink message.
+ * @arg attrtype Attribute type.
+ * @arg data Abstract data object.
+ *
+ * Equivalent to nla_put() except that the length of the payload is
+ * derived from the abstract data object.
+ *
+ * @see nla_put
+ * @return 0 on success or a negative error code.
+ */
+static inline int nla_put_data(struct nl_msg *msg, int attrtype, struct nl_data *data)
+{
+ return nla_put(msg, attrtype, nl_data_get_size(data),
+ nl_data_get(data));
+}
+
+/**
+ * Add abstract address as unspecific attribute to netlink message.
+ * @arg msg Netlink message.
+ * @arg attrtype Attribute type.
+ * @arg addr Abstract address object.
+ *
+ * @see nla_put
+ * @return 0 on success or a negative error code.
+ */
+static inline int nla_put_addr(struct nl_msg *msg, int attrtype, struct nl_addr *addr)
+{
+ return nla_put(msg, attrtype, nl_addr_get_len(addr),
+ nl_addr_get_binary_addr(addr));
+}
+
+/** @} */
+
+/**
+ * @name Integer Attributes
+ */
+
+/**
+ * Add 8 bit integer attribute to netlink message.
+ * @arg msg Netlink message.
+ * @arg attrtype Attribute type.
+ * @arg value Numeric value to store as payload.
+ *
+ * @see nla_put
+ * @return 0 on success or a negative error code.
+ */
+static inline int nla_put_u8(struct nl_msg *msg, int attrtype, uint8_t value)
+{
+ return nla_put(msg, attrtype, sizeof(uint8_t), &value);
+}
+
+/**
+ * Return value of 8 bit integer attribute.
+ * @arg nla 8 bit integer attribute
+ *
+ * @return Payload as 8 bit integer.
+ */
+static inline uint8_t nla_get_u8(struct nlattr *nla)
+{
+ return *(uint8_t *) nla_data(nla);
+}
+
+/**
+ * Add 16 bit integer attribute to netlink message.
+ * @arg msg Netlink message.
+ * @arg attrtype Attribute type.
+ * @arg value Numeric value to store as payload.
+ *
+ * @see nla_put
+ * @return 0 on success or a negative error code.
+ */
+static inline int nla_put_u16(struct nl_msg *msg, int attrtype, uint16_t value)
+{
+ return nla_put(msg, attrtype, sizeof(uint16_t), &value);
+}
+
+/**
+ * Return payload of 16 bit integer attribute.
+ * @arg nla 16 bit integer attribute
+ *
+ * @return Payload as 16 bit integer.
+ */
+static inline uint16_t nla_get_u16(struct nlattr *nla)
+{
+ return *(uint16_t *) nla_data(nla);
+}
+
+/**
+ * Add 32 bit integer attribute to netlink message.
+ * @arg msg Netlink message.
+ * @arg attrtype Attribute type.
+ * @arg value Numeric value to store as payload.
+ *
+ * @see nla_put
+ * @return 0 on success or a negative error code.
+ */
+static inline int nla_put_u32(struct nl_msg *msg, int attrtype, uint32_t value)
+{
+ return nla_put(msg, attrtype, sizeof(uint32_t), &value);
+}
+
+/**
+ * Return payload of 32 bit integer attribute.
+ * @arg nla 32 bit integer attribute.
+ *
+ * @return Payload as 32 bit integer.
+ */
+static inline uint32_t nla_get_u32(struct nlattr *nla)
+{
+ return *(uint32_t *) nla_data(nla);
+}
+
+/**
+ * Add 64 bit integer attribute to netlink message.
+ * @arg msg Netlink message.
+ * @arg attrtype Attribute type.
+ * @arg value Numeric value to store as payload.
+ *
+ * @see nla_put
+ * @return 0 on success or a negative error code.
+ */
+static inline int nla_put_u64(struct nl_msg *msg, int attrtype, uint64_t value)
+{
+ return nla_put(msg, attrtype, sizeof(uint64_t), &value);
+}
+
+/**
+ * Return payload of u64 attribute
+ * @arg nla u64 netlink attribute
+ *
+ * @return Payload as 64 bit integer.
+ */
+static inline uint64_t nla_get_u64(struct nlattr *nla)
+{
+ uint64_t tmp;
+
+ nla_memcpy(&tmp, nla, sizeof(tmp));
+
+ return tmp;
+}
+
+/**
+ * Add string attribute to netlink message.
+ * @arg msg Netlink message.
+ * @arg attrtype Attribute type.
+ * @arg str NUL terminated string.
+ *
+ * @see nla_put
+ * @return 0 on success or a negative error code.
+ */
+static inline int nla_put_string(struct nl_msg *msg, int attrtype, const char *str)
+{
+ return nla_put(msg, attrtype, strlen(str) + 1, str);
+}
+
+/**
+ * Return payload of string attribute.
+ * @arg nla String attribute.
+ *
+ * @return Pointer to attribute payload.
+ */
+static inline char *nla_get_string(struct nlattr *nla)
+{
+ return (char *) nla_data(nla);
+}
+
+static inline char *nla_strdup(struct nlattr *nla)
+{
+ return strdup(nla_get_string(nla));
+}
+
+/** @} */
+
+/**
+ * @name Flag Attribute
+ */
+
+/**
+ * Add flag netlink attribute to netlink message.
+ * @arg msg Netlink message.
+ * @arg attrtype Attribute type.
+ *
+ * @see nla_put
+ * @return 0 on success or a negative error code.
+ */
+static inline int nla_put_flag(struct nl_msg *msg, int attrtype)
+{
+ return nla_put(msg, attrtype, 0, NULL);
+}
+
+/**
+ * Return true if flag attribute is set.
+ * @arg nla Flag netlink attribute.
+ *
+ * @return True if flag is set, otherwise false.
+ */
+static inline int nla_get_flag(struct nlattr *nla)
+{
+ return !!nla;
+}
+
+/** @} */
+
+/**
+ * @name Microseconds Attribute
+ */
+
+/**
+ * Add a msecs netlink attribute to a netlink message
+ * @arg n netlink message
+ * @arg attrtype attribute type
+ * @arg msecs number of msecs
+ */
+static inline int nla_put_msecs(struct nl_msg *n, int attrtype, unsigned long msecs)
+{
+ return nla_put_u64(n, attrtype, msecs);
+}
+
+/**
+ * Return payload of msecs attribute
+ * @arg nla msecs netlink attribute
+ *
+ * @return the number of milliseconds.
+ */
+static inline unsigned long nla_get_msecs(struct nlattr *nla)
+{
+ return nla_get_u64(nla);
+}
+
+/**
+ * Add nested attributes to netlink message.
+ * @arg msg Netlink message.
+ * @arg attrtype Attribute type.
+ * @arg nested Message containing attributes to be nested.
+ *
+ * Takes the attributes found in the \a nested message and appends them
+ * to the message \a msg nested in a container of the type \a attrtype.
+ * The \a nested message may not have a family specific header.
+ *
+ * @see nla_put
+ * @return 0 on success or a negative error code.
+ */
+static inline int nla_put_nested(struct nl_msg *msg, int attrtype, struct nl_msg *nested)
+{
+ return nla_put(msg, attrtype, nlmsg_len(nested->nm_nlh),
+ nlmsg_data(nested->nm_nlh));
+}
+
+/**
+ * Start a new level of nested attributes.
+ * @arg msg Netlink message.
+ * @arg attrtype Attribute type of container.
+ *
+ * @return Pointer to container attribute.
+ */
+static inline struct nlattr *nla_nest_start(struct nl_msg *msg, int attrtype)
+{
+ struct nlattr *start = (struct nlattr *) nlmsg_tail(msg->nm_nlh);
+
+ if (nla_put(msg, attrtype, 0, NULL) < 0)
+ return NULL;
+
+ return start;
+}
+
+/**
+ * Finalize nesting of attributes.
+ * @arg msg Netlink message.
+ * @arg start Container attribute as returned from nla_nest_start().
+ *
+ * Corrects the container attribute header to include the appeneded attributes.
+ *
+ * @return 0
+ */
+static inline int nla_nest_end(struct nl_msg *msg, struct nlattr *start)
+{
+ start->nla_len = (unsigned char *) nlmsg_tail(msg->nm_nlh) -
+ (unsigned char *) start;
+ return 0;
+}
+
+/**
+ * Create attribute index based on nested attribute
+ * @arg tb Index array to be filled (maxtype+1 elements).
+ * @arg maxtype Maximum attribute type expected and accepted.
+ * @arg nla Nested Attribute.
+ * @arg policy Attribute validation policy.
+ *
+ * Feeds the stream of attributes nested into the specified attribute
+ * to nla_parse().
+ *
+ * @see nla_parse
+ * @return 0 on success or a negative error code.
+ */
+static inline int nla_parse_nested(struct nlattr *tb[], int maxtype, struct nlattr *nla,
+ struct nla_policy *policy)
+{
+ return nla_parse(tb, maxtype, (struct nlattr *)nla_data(nla), nla_len(nla), policy);
+}
+
+/**
+ * Compare attribute payload with memory area.
+ * @arg nla Attribute.
+ * @arg data Memory area to compare to.
+ * @arg size Number of bytes to compare.
+ *
+ * @see memcmp(3)
+ * @return An integer less than, equal to, or greater than zero.
+ */
+static inline int nla_memcmp(const struct nlattr *nla, const void *data, size_t size)
+{
+ int d = nla_len(nla) - size;
+
+ if (d == 0)
+ d = memcmp(nla_data(nla), data, size);
+
+ return d;
+}
+
+/**
+ * Compare string attribute payload with string
+ * @arg nla Attribute of type NLA_STRING.
+ * @arg str NUL terminated string.
+ *
+ * @see strcmp(3)
+ * @return An integer less than, equal to, or greater than zero.
+ */
+static inline int nla_strcmp(const struct nlattr *nla, const char *str)
+{
+ int len = strlen(str) + 1;
+ int d = nla_len(nla) - len;
+
+ if (d == 0)
+ d = memcmp(nla_data(nla), str, len);
+
+ return d;
+}
+
+/**
+ * Copy string attribute payload to a buffer.
+ * @arg dst Pointer to destination buffer.
+ * @arg nla Attribute of type NLA_STRING.
+ * @arg dstsize Size of destination buffer in bytes.
+ *
+ * Copies at most dstsize - 1 bytes to the destination buffer.
+ * The result is always a valid NUL terminated string. Unlike
+ * strlcpy the destination buffer is always padded out.
+ *
+ * @return The length of string attribute without the terminating NUL.
+ */
+static inline size_t nla_strlcpy(char *dst, const struct nlattr *nla, size_t dstsize)
+{
+ size_t srclen = (size_t)nla_len(nla);
+ char *src = (char*)nla_data(nla);
+
+ if (srclen > 0 && src[srclen - 1] == '\0')
+ srclen--;
+
+ if (dstsize > 0) {
+ size_t len = (srclen >= dstsize) ? dstsize - 1 : srclen;
+
+ memset(dst, 0, dstsize);
+ memcpy(dst, src, len);
+ }
+
+ return srclen;
+}
+
+
+/**
+ * @name Attribute Construction (Exception Based)
+ * @{
+ */
+
+/**
+ * @ingroup attr
+ * Add unspecific attribute to netlink message.
+ * @arg msg Netlink message.
+ * @arg attrtype Attribute type.
+ * @arg attrlen Length of attribute payload.
+ * @arg data Head of attribute payload.
+ */
+#define NLA_PUT(msg, attrtype, attrlen, data) \
+ do { \
+ if (nla_put(msg, attrtype, attrlen, data) < 0) \
+ goto nla_put_failure; \
+ } while(0)
+
+/**
+ * @ingroup attr
+ * Add atomic type attribute to netlink message.
+ * @arg msg Netlink message.
+ * @arg type Atomic type.
+ * @arg attrtype Attribute type.
+ * @arg value Head of attribute payload.
+ */
+#define NLA_PUT_TYPE(msg, type, attrtype, value) \
+ do { \
+ type __tmp = value; \
+ NLA_PUT(msg, attrtype, sizeof(type), &__tmp); \
+ } while(0)
+
+/**
+ * Add 8 bit integer attribute to netlink message.
+ * @arg msg Netlink message.
+ * @arg attrtype Attribute type.
+ * @arg value Numeric value.
+ */
+#define NLA_PUT_U8(msg, attrtype, value) \
+ NLA_PUT_TYPE(msg, uint8_t, attrtype, value)
+
+/**
+ * Add 16 bit integer attribute to netlink message.
+ * @arg msg Netlink message.
+ * @arg attrtype Attribute type.
+ * @arg value Numeric value.
+ */
+#define NLA_PUT_U16(msg, attrtype, value) \
+ NLA_PUT_TYPE(msg, uint16_t, attrtype, value)
+
+/**
+ * Add 32 bit integer attribute to netlink message.
+ * @arg msg Netlink message.
+ * @arg attrtype Attribute type.
+ * @arg value Numeric value.
+ */
+#define NLA_PUT_U32(msg, attrtype, value) \
+ NLA_PUT_TYPE(msg, uint32_t, attrtype, value)
+
+/**
+ * Add 64 bit integer attribute to netlink message.
+ * @arg msg Netlink message.
+ * @arg attrtype Attribute type.
+ * @arg value Numeric value.
+ */
+#define NLA_PUT_U64(msg, attrtype, value) \
+ NLA_PUT_TYPE(msg, uint64_t, attrtype, value)
+
+/**
+ * Add string attribute to netlink message.
+ * @arg msg Netlink message.
+ * @arg attrtype Attribute type.
+ * @arg value NUL terminated character string.
+ */
+#define NLA_PUT_STRING(msg, attrtype, value) \
+ NLA_PUT(msg, attrtype, strlen(value) + 1, value)
+
+/**
+ * Add flag attribute to netlink message.
+ * @arg msg Netlink message.
+ * @arg attrtype Attribute type.
+ */
+#define NLA_PUT_FLAG(msg, attrtype) \
+ NLA_PUT(msg, attrtype, 0, NULL)
+
+/**
+ * Add msecs attribute to netlink message.
+ * @arg msg Netlink message.
+ * @arg attrtype Attribute type.
+ * @arg msecs Numeric value in micro seconds.
+ */
+#define NLA_PUT_MSECS(msg, attrtype, msecs) \
+ NLA_PUT_U64(msg, attrtype, msecs)
+
+/**
+ * Add address attribute to netlink message.
+ * @arg msg Netlink message.
+ * @arg attrtype Attribute type.
+ * @arg addr Abstract address object.
+ */
+#define NLA_PUT_ADDR(msg, attrtype, addr) \
+ NLA_PUT(msg, attrtype, nl_addr_get_len(addr), \
+ nl_addr_get_binary_addr(addr))
+
+/** @} */
+
+/**
+ * @name Iterators
+ * @{
+ */
+
+/**
+ * @ingroup attr
+ * Iterate over a stream of attributes
+ * @arg pos loop counter, set to current attribute
+ * @arg head head of attribute stream
+ * @arg len length of attribute stream
+ * @arg rem initialized to len, holds bytes currently remaining in stream
+ */
+#define nla_for_each_attr(pos, head, len, rem) \
+ for (pos = head, rem = len; \
+ nla_ok(pos, rem); \
+ pos = nla_next(pos, &(rem)))
+
+/**
+ * @ingroup attr
+ * Iterate over a stream of nested attributes
+ * @arg pos loop counter, set to current attribute
+ * @arg nla attribute containing the nested attributes
+ * @arg rem initialized to len, holds bytes currently remaining in stream
+ */
+#define nla_for_each_nested(pos, nla, rem) \
+ for (pos = (struct nlattr *)nla_data(nla), rem = nla_len(nla); \
+ nla_ok(pos, rem); \
+ pos = nla_next(pos, &(rem)))
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/package/libs/libnl-tiny/src/include/netlink/.svn/text-base/cache-api.h.svn-base b/package/libs/libnl-tiny/src/include/netlink/.svn/text-base/cache-api.h.svn-base
new file mode 100644
index 0000000..22fc449
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/netlink/.svn/text-base/cache-api.h.svn-base
@@ -0,0 +1,199 @@
+/*
+ * netlink/cache-api.h Caching API
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
+ */
+
+#ifndef NETLINK_CACHE_API_H_
+#define NETLINK_CACHE_API_H_
+
+#include <netlink/netlink.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @ingroup cache
+ * @defgroup cache_api Cache Implementation
+ * @brief
+ *
+ * @par 1) Cache Definition
+ * @code
+ * struct nl_cache_ops my_cache_ops = {
+ * .co_name = "route/link",
+ * .co_protocol = NETLINK_ROUTE,
+ * .co_hdrsize = sizeof(struct ifinfomsg),
+ * .co_obj_ops = &my_obj_ops,
+ * };
+ * @endcode
+ *
+ * @par 2)
+ * @code
+ * // The simplest way to fill a cache is by providing a request-update
+ * // function which must trigger a complete dump on the kernel-side of
+ * // whatever the cache covers.
+ * static int my_request_update(struct nl_cache *cache,
+ * struct nl_sock *socket)
+ * {
+ * // In this example, we request a full dump of the interface table
+ * return nl_rtgen_request(socket, RTM_GETLINK, AF_UNSPEC, NLM_F_DUMP);
+ * }
+ *
+ * // The resulting netlink messages sent back will be fed into a message
+ * // parser one at a time. The message parser has to extract all relevant
+ * // information from the message and create an object reflecting the
+ * // contents of the message and pass it on to the parser callback function
+ * // provide which will add the object to the cache.
+ * static int my_msg_parser(struct nl_cache_ops *ops, struct sockaddr_nl *who,
+ * struct nlmsghdr *nlh, struct nl_parser_param *pp)
+ * {
+ * struct my_obj *obj;
+ *
+ * obj = my_obj_alloc();
+ * obj->ce_msgtype = nlh->nlmsg_type;
+ *
+ * // Parse the netlink message and continue creating the object.
+ *
+ * err = pp->pp_cb((struct nl_object *) obj, pp);
+ * if (err < 0)
+ * goto errout;
+ * }
+ *
+ * struct nl_cache_ops my_cache_ops = {
+ * ...
+ * .co_request_update = my_request_update,
+ * .co_msg_parser = my_msg_parser,
+ * };
+ * @endcode
+ *
+ * @par 3) Notification based Updates
+ * @code
+ * // Caches can be kept up-to-date based on notifications if the kernel
+ * // sends out notifications whenever an object is added/removed/changed.
+ * //
+ * // It is trivial to support this, first a list of groups needs to be
+ * // defined which are required to join in order to receive all necessary
+ * // notifications. The groups are separated by address family to support
+ * // the common situation where a separate group is used for each address
+ * // family. If there is only one group, simply specify AF_UNSPEC.
+ * static struct nl_af_group addr_groups[] = {
+ * { AF_INET, RTNLGRP_IPV4_IFADDR },
+ * { AF_INET6, RTNLGRP_IPV6_IFADDR },
+ * { END_OF_GROUP_LIST },
+ * };
+ *
+ * // In order for the caching system to know the meaning of each message
+ * // type it requires a table which maps each supported message type to
+ * // a cache action, e.g. RTM_NEWADDR means address has been added or
+ * // updated, RTM_DELADDR means address has been removed.
+ * static struct nl_cache_ops rtnl_addr_ops = {
+ * ...
+ * .co_msgtypes = {
+ * { RTM_NEWADDR, NL_ACT_NEW, "new" },
+ * { RTM_DELADDR, NL_ACT_DEL, "del" },
+ * { RTM_GETADDR, NL_ACT_GET, "get" },
+ * END_OF_MSGTYPES_LIST,
+ * },
+ * .co_groups = addr_groups,
+ * };
+ *
+ * // It is now possible to keep the cache up-to-date using the cache manager.
+ * @endcode
+ * @{
+ */
+
+enum {
+ NL_ACT_UNSPEC,
+ NL_ACT_NEW,
+ NL_ACT_DEL,
+ NL_ACT_GET,
+ NL_ACT_SET,
+ NL_ACT_CHANGE,
+ __NL_ACT_MAX,
+};
+
+#define NL_ACT_MAX (__NL_ACT_MAX - 1)
+
+#define END_OF_MSGTYPES_LIST { -1, -1, NULL }
+
+/**
+ * Message type to cache action association
+ */
+struct nl_msgtype
+{
+ /** Netlink message type */
+ int mt_id;
+
+ /** Cache action to take */
+ int mt_act;
+
+ /** Name of operation for human-readable printing */
+ char * mt_name;
+};
+
+/**
+ * Address family to netlink group association
+ */
+struct nl_af_group
+{
+ /** Address family */
+ int ag_family;
+
+ /** Netlink group identifier */
+ int ag_group;
+};
+
+#define END_OF_GROUP_LIST AF_UNSPEC, 0
+
+struct nl_parser_param
+{
+ int (*pp_cb)(struct nl_object *, struct nl_parser_param *);
+ void * pp_arg;
+};
+
+/**
+ * Cache Operations
+ */
+struct nl_cache_ops
+{
+ char * co_name;
+
+ int co_hdrsize;
+ int co_protocol;
+ struct nl_af_group * co_groups;
+
+ /**
+ * Called whenever an update of the cache is required. Must send
+ * a request message to the kernel requesting a complete dump.
+ */
+ int (*co_request_update)(struct nl_cache *, struct nl_sock *);
+
+ /**
+ * Called whenever a message was received that needs to be parsed.
+ * Must parse the message and call the paser callback function
+ * (nl_parser_param) provided via the argument.
+ */
+ int (*co_msg_parser)(struct nl_cache_ops *, struct sockaddr_nl *,
+ struct nlmsghdr *, struct nl_parser_param *);
+
+ struct nl_object_ops * co_obj_ops;
+
+ struct nl_cache_ops *co_next;
+ struct nl_cache *co_major_cache;
+ struct genl_ops * co_genl;
+ struct nl_msgtype co_msgtypes[];
+};
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/package/libs/libnl-tiny/src/include/netlink/.svn/text-base/cache.h.svn-base b/package/libs/libnl-tiny/src/include/netlink/.svn/text-base/cache.h.svn-base
new file mode 100644
index 0000000..09719f3
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/netlink/.svn/text-base/cache.h.svn-base
@@ -0,0 +1,128 @@
+/*
+ * netlink/cache.h Caching Module
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
+ */
+
+#ifndef NETLINK_CACHE_H_
+#define NETLINK_CACHE_H_
+
+#include <netlink/netlink.h>
+#include <netlink/msg.h>
+#include <netlink/utils.h>
+#include <netlink/object.h>
+#include <netlink/cache-api.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct nl_cache;
+
+typedef void (*change_func_t)(struct nl_cache *, struct nl_object *, int);
+
+/* Access Functions */
+extern int nl_cache_nitems(struct nl_cache *);
+extern int nl_cache_nitems_filter(struct nl_cache *,
+ struct nl_object *);
+extern struct nl_cache_ops * nl_cache_get_ops(struct nl_cache *);
+extern struct nl_object * nl_cache_get_first(struct nl_cache *);
+extern struct nl_object * nl_cache_get_last(struct nl_cache *);
+extern struct nl_object * nl_cache_get_next(struct nl_object *);
+extern struct nl_object * nl_cache_get_prev(struct nl_object *);
+
+extern struct nl_cache * nl_cache_alloc(struct nl_cache_ops *);
+extern int nl_cache_alloc_and_fill(struct nl_cache_ops *,
+ struct nl_sock *,
+ struct nl_cache **);
+extern int nl_cache_alloc_name(const char *,
+ struct nl_cache **);
+extern struct nl_cache * nl_cache_subset(struct nl_cache *,
+ struct nl_object *);
+extern void nl_cache_clear(struct nl_cache *);
+extern void nl_cache_free(struct nl_cache *);
+
+/* Cache modification */
+extern int nl_cache_add(struct nl_cache *,
+ struct nl_object *);
+extern int nl_cache_parse_and_add(struct nl_cache *,
+ struct nl_msg *);
+extern void nl_cache_remove(struct nl_object *);
+extern int nl_cache_refill(struct nl_sock *,
+ struct nl_cache *);
+extern int nl_cache_pickup(struct nl_sock *,
+ struct nl_cache *);
+extern int nl_cache_resync(struct nl_sock *,
+ struct nl_cache *,
+ change_func_t);
+extern int nl_cache_include(struct nl_cache *,
+ struct nl_object *,
+ change_func_t);
+
+/* General */
+extern int nl_cache_is_empty(struct nl_cache *);
+extern void nl_cache_mark_all(struct nl_cache *);
+
+/* Dumping */
+extern void nl_cache_dump(struct nl_cache *,
+ struct nl_dump_params *);
+extern void nl_cache_dump_filter(struct nl_cache *,
+ struct nl_dump_params *,
+ struct nl_object *);
+
+/* Iterators */
+#ifdef disabled
+extern void nl_cache_foreach(struct nl_cache *,
+ void (*cb)(struct nl_object *,
+ void *),
+ void *arg);
+extern void nl_cache_foreach_filter(struct nl_cache *,
+ struct nl_object *,
+ void (*cb)(struct
+ nl_object *,
+ void *),
+ void *arg);
+#endif
+
+/* --- cache management --- */
+
+/* Cache type management */
+extern struct nl_cache_ops * nl_cache_ops_lookup(const char *);
+extern struct nl_cache_ops * nl_cache_ops_associate(int, int);
+extern struct nl_msgtype * nl_msgtype_lookup(struct nl_cache_ops *, int);
+extern void nl_cache_ops_foreach(void (*cb)(struct nl_cache_ops *, void *), void *);
+extern int nl_cache_mngt_register(struct nl_cache_ops *);
+extern int nl_cache_mngt_unregister(struct nl_cache_ops *);
+
+/* Global cache provisioning/requiring */
+extern void nl_cache_mngt_provide(struct nl_cache *);
+extern void nl_cache_mngt_unprovide(struct nl_cache *);
+extern struct nl_cache * nl_cache_mngt_require(const char *);
+
+struct nl_cache_mngr;
+
+#define NL_AUTO_PROVIDE 1
+
+extern int nl_cache_mngr_alloc(struct nl_sock *,
+ int, int,
+ struct nl_cache_mngr **);
+extern int nl_cache_mngr_add(struct nl_cache_mngr *,
+ const char *,
+ change_func_t,
+ struct nl_cache **);
+extern int nl_cache_mngr_get_fd(struct nl_cache_mngr *);
+extern int nl_cache_mngr_poll(struct nl_cache_mngr *,
+ int);
+extern int nl_cache_mngr_data_ready(struct nl_cache_mngr *);
+extern void nl_cache_mngr_free(struct nl_cache_mngr *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/package/libs/libnl-tiny/src/include/netlink/.svn/text-base/data.h.svn-base b/package/libs/libnl-tiny/src/include/netlink/.svn/text-base/data.h.svn-base
new file mode 100644
index 0000000..071159e
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/netlink/.svn/text-base/data.h.svn-base
@@ -0,0 +1,41 @@
+/*
+ * netlink/data.h Abstract Data
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
+ */
+
+#ifndef NETLINK_DATA_H_
+#define NETLINK_DATA_H_
+
+#include <netlink/netlink.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct nl_data;
+
+/* General */
+extern struct nl_data * nl_data_alloc(void *, size_t);
+extern struct nl_data * nl_data_alloc_attr(struct nlattr *);
+extern struct nl_data * nl_data_clone(struct nl_data *);
+extern int nl_data_append(struct nl_data *, void *, size_t);
+extern void nl_data_free(struct nl_data *);
+
+/* Access Functions */
+extern void * nl_data_get(struct nl_data *);
+extern size_t nl_data_get_size(struct nl_data *);
+
+/* Misc */
+extern int nl_data_cmp(struct nl_data *, struct nl_data *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/package/libs/libnl-tiny/src/include/netlink/.svn/text-base/errno.h.svn-base b/package/libs/libnl-tiny/src/include/netlink/.svn/text-base/errno.h.svn-base
new file mode 100644
index 0000000..0b43da0
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/netlink/.svn/text-base/errno.h.svn-base
@@ -0,0 +1,59 @@
+/*
+ * netlink/errno.h Error Numbers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2008 Thomas Graf <tgraf@suug.ch>
+ */
+
+#ifndef NETLINK_ERRNO_H_
+#define NETLINK_ERRNO_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define NLE_SUCCESS 0
+#define NLE_FAILURE 1
+#define NLE_INTR 2
+#define NLE_BAD_SOCK 3
+#define NLE_AGAIN 4
+#define NLE_NOMEM 5
+#define NLE_EXIST 6
+#define NLE_INVAL 7
+#define NLE_RANGE 8
+#define NLE_MSGSIZE 9
+#define NLE_OPNOTSUPP 10
+#define NLE_AF_NOSUPPORT 11
+#define NLE_OBJ_NOTFOUND 12
+#define NLE_NOATTR 13
+#define NLE_MISSING_ATTR 14
+#define NLE_AF_MISMATCH 15
+#define NLE_SEQ_MISMATCH 16
+#define NLE_MSG_OVERFLOW 17
+#define NLE_MSG_TRUNC 18
+#define NLE_NOADDR 19
+#define NLE_SRCRT_NOSUPPORT 20
+#define NLE_MSG_TOOSHORT 21
+#define NLE_MSGTYPE_NOSUPPORT 22
+#define NLE_OBJ_MISMATCH 23
+#define NLE_NOCACHE 24
+#define NLE_BUSY 25
+#define NLE_PROTO_MISMATCH 26
+#define NLE_NOACCESS 27
+#define NLE_PERM 28
+
+#define NLE_MAX NLE_PERM
+
+extern const char * nl_geterror(int);
+extern void nl_perror(int, const char *);
+extern int nl_syserr2nlerr(int);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/package/libs/libnl-tiny/src/include/netlink/.svn/text-base/handlers.h.svn-base b/package/libs/libnl-tiny/src/include/netlink/.svn/text-base/handlers.h.svn-base
new file mode 100644
index 0000000..7fb53b4
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/netlink/.svn/text-base/handlers.h.svn-base
@@ -0,0 +1,230 @@
+/*
+ * netlink/handlers.c default netlink message handlers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
+ */
+
+#ifndef NETLINK_HANDLERS_H_
+#define NETLINK_HANDLERS_H_
+
+#include <stdio.h>
+#include <stdint.h>
+#include <sys/types.h>
+#include <netlink/netlink-compat.h>
+#include <netlink/netlink-kernel.h>
+#include <netlink/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct nl_sock;
+struct nl_msg;
+struct nl_cb;
+/**
+ * @name Callback Typedefs
+ * @{
+ */
+
+/**
+ * nl_recvmsgs() callback for message processing customization
+ * @ingroup cb
+ * @arg msg netlink message being processed
+ * @arg arg argument passwd on through caller
+ */
+typedef int (*nl_recvmsg_msg_cb_t)(struct nl_msg *msg, void *arg);
+
+/**
+ * nl_recvmsgs() callback for error message processing customization
+ * @ingroup cb
+ * @arg nla netlink address of the peer
+ * @arg nlerr netlink error message being processed
+ * @arg arg argument passed on through caller
+ */
+typedef int (*nl_recvmsg_err_cb_t)(struct sockaddr_nl *nla,
+ struct nlmsgerr *nlerr, void *arg);
+
+/** @} */
+
+/**
+ * Callback actions
+ * @ingroup cb
+ */
+enum nl_cb_action {
+ /** Proceed with wathever would come next */
+ NL_OK,
+ /** Skip this message */
+ NL_SKIP,
+ /** Stop parsing altogether and discard remaining messages */
+ NL_STOP,
+};
+
+/**
+ * Callback kinds
+ * @ingroup cb
+ */
+enum nl_cb_kind {
+ /** Default handlers (quiet) */
+ NL_CB_DEFAULT,
+ /** Verbose default handlers (error messages printed) */
+ NL_CB_VERBOSE,
+ /** Debug handlers for debugging */
+ NL_CB_DEBUG,
+ /** Customized handler specified by the user */
+ NL_CB_CUSTOM,
+ __NL_CB_KIND_MAX,
+};
+
+#define NL_CB_KIND_MAX (__NL_CB_KIND_MAX - 1)
+
+/**
+ * Callback types
+ * @ingroup cb
+ */
+enum nl_cb_type {
+ /** Message is valid */
+ NL_CB_VALID,
+ /** Last message in a series of multi part messages received */
+ NL_CB_FINISH,
+ /** Report received that data was lost */
+ NL_CB_OVERRUN,
+ /** Message wants to be skipped */
+ NL_CB_SKIPPED,
+ /** Message is an acknowledge */
+ NL_CB_ACK,
+ /** Called for every message received */
+ NL_CB_MSG_IN,
+ /** Called for every message sent out except for nl_sendto() */
+ NL_CB_MSG_OUT,
+ /** Message is malformed and invalid */
+ NL_CB_INVALID,
+ /** Called instead of internal sequence number checking */
+ NL_CB_SEQ_CHECK,
+ /** Sending of an acknowledge message has been requested */
+ NL_CB_SEND_ACK,
+ __NL_CB_TYPE_MAX,
+};
+
+#define NL_CB_TYPE_MAX (__NL_CB_TYPE_MAX - 1)
+
+struct nl_cb
+{
+ nl_recvmsg_msg_cb_t cb_set[NL_CB_TYPE_MAX+1];
+ void * cb_args[NL_CB_TYPE_MAX+1];
+
+ nl_recvmsg_err_cb_t cb_err;
+ void * cb_err_arg;
+
+ /** May be used to replace nl_recvmsgs with your own implementation
+ * in all internal calls to nl_recvmsgs. */
+ int (*cb_recvmsgs_ow)(struct nl_sock *,
+ struct nl_cb *);
+
+ /** Overwrite internal calls to nl_recv, must return the number of
+ * octets read and allocate a buffer for the received data. */
+ int (*cb_recv_ow)(struct nl_sock *,
+ struct sockaddr_nl *,
+ unsigned char **,
+ struct ucred **);
+
+ /** Overwrites internal calls to nl_send, must send the netlink
+ * message. */
+ int (*cb_send_ow)(struct nl_sock *,
+ struct nl_msg *);
+
+ int cb_refcnt;
+};
+
+
+extern struct nl_cb * nl_cb_alloc(enum nl_cb_kind);
+extern struct nl_cb * nl_cb_clone(struct nl_cb *);
+extern void nl_cb_put(struct nl_cb *);
+
+extern int nl_cb_set(struct nl_cb *, enum nl_cb_type, enum nl_cb_kind,
+ nl_recvmsg_msg_cb_t, void *);
+extern int nl_cb_err(struct nl_cb *, enum nl_cb_kind, nl_recvmsg_err_cb_t,
+ void *);
+
+static inline struct nl_cb *nl_cb_get(struct nl_cb *cb)
+{
+ cb->cb_refcnt++;
+
+ return cb;
+}
+
+/**
+ * Set up a all callbacks
+ * @arg cb callback set
+ * @arg kind kind of callback
+ * @arg func callback function
+ * @arg arg argument to be passwd to callback function
+ *
+ * @return 0 on success or a negative error code
+ */
+static inline int nl_cb_set_all(struct nl_cb *cb, enum nl_cb_kind kind,
+ nl_recvmsg_msg_cb_t func, void *arg)
+{
+ int i, err;
+
+ for (i = 0; i <= NL_CB_TYPE_MAX; i++) {
+ err = nl_cb_set(cb,(enum nl_cb_type)i, kind, func, arg);
+ if (err < 0)
+ return err;
+ }
+
+ return 0;
+}
+
+
+/**
+ * @name Overwriting
+ * @{
+ */
+
+/**
+ * Overwrite internal calls to nl_recvmsgs()
+ * @arg cb callback set
+ * @arg func replacement callback for nl_recvmsgs()
+ */
+static inline void nl_cb_overwrite_recvmsgs(struct nl_cb *cb,
+ int (*func)(struct nl_sock *, struct nl_cb *))
+{
+ cb->cb_recvmsgs_ow = func;
+}
+
+/**
+ * Overwrite internal calls to nl_recv()
+ * @arg cb callback set
+ * @arg func replacement callback for nl_recv()
+ */
+static inline void nl_cb_overwrite_recv(struct nl_cb *cb,
+ int (*func)(struct nl_sock *, struct sockaddr_nl *,
+ unsigned char **, struct ucred **))
+{
+ cb->cb_recv_ow = func;
+}
+
+/**
+ * Overwrite internal calls to nl_send()
+ * @arg cb callback set
+ * @arg func replacement callback for nl_send()
+ */
+static inline void nl_cb_overwrite_send(struct nl_cb *cb,
+ int (*func)(struct nl_sock *, struct nl_msg *))
+{
+ cb->cb_send_ow = func;
+}
+
+/** @} */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/package/libs/libnl-tiny/src/include/netlink/.svn/text-base/list.h.svn-base b/package/libs/libnl-tiny/src/include/netlink/.svn/text-base/list.h.svn-base
new file mode 100644
index 0000000..c6876a7
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/netlink/.svn/text-base/list.h.svn-base
@@ -0,0 +1,88 @@
+/*
+ * netlink/list.h Netlink List Utilities
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
+ */
+
+#ifndef NETLINK_LIST_H_
+#define NETLINK_LIST_H_
+
+struct nl_list_head
+{
+ struct nl_list_head * next;
+ struct nl_list_head * prev;
+};
+
+
+static inline void __nl_list_add(struct nl_list_head *obj,
+ struct nl_list_head *prev,
+ struct nl_list_head *next)
+{
+ prev->next = obj;
+ obj->prev = prev;
+ next->prev = obj;
+ obj->next = next;
+}
+
+static inline void nl_list_add_tail(struct nl_list_head *obj,
+ struct nl_list_head *head)
+{
+ __nl_list_add(obj, head->prev, head);
+}
+
+static inline void nl_list_add_head(struct nl_list_head *obj,
+ struct nl_list_head *head)
+{
+ __nl_list_add(obj, head, head->next);
+}
+
+static inline void nl_list_del(struct nl_list_head *obj)
+{
+ obj->next->prev = obj->prev;
+ obj->prev->next = obj->next;
+}
+
+static inline int nl_list_empty(struct nl_list_head *head)
+{
+ return head->next == head;
+}
+
+#define nl_container_of(ptr, type, member) ({ \
+ const typeof( ((type *)0)->member ) *__mptr = (ptr); \
+ (type *)( (char *)__mptr - ((size_t) &((type *)0)->member));})
+
+#define nl_list_entry(ptr, type, member) \
+ nl_container_of(ptr, type, member)
+
+#define nl_list_at_tail(pos, head, member) \
+ ((pos)->member.next == (head))
+
+#define nl_list_at_head(pos, head, member) \
+ ((pos)->member.prev == (head))
+
+#define NL_LIST_HEAD(name) \
+ struct nl_list_head name = { &(name), &(name) }
+
+#define nl_list_first_entry(head, type, member) \
+ nl_list_entry((head)->next, type, member)
+
+#define nl_list_for_each_entry(pos, head, member) \
+ for (pos = nl_list_entry((head)->next, typeof(*pos), member); \
+ &(pos)->member != (head); \
+ (pos) = nl_list_entry((pos)->member.next, typeof(*(pos)), member))
+
+#define nl_list_for_each_entry_safe(pos, n, head, member) \
+ for (pos = nl_list_entry((head)->next, typeof(*pos), member), \
+ n = nl_list_entry(pos->member.next, typeof(*pos), member); \
+ &(pos)->member != (head); \
+ pos = n, n = nl_list_entry(n->member.next, typeof(*n), member))
+
+#define nl_init_list_head(head) \
+ do { (head)->next = (head); (head)->prev = (head); } while (0)
+
+#endif
diff --git a/package/libs/libnl-tiny/src/include/netlink/.svn/text-base/msg.h.svn-base b/package/libs/libnl-tiny/src/include/netlink/.svn/text-base/msg.h.svn-base
new file mode 100644
index 0000000..b3e2b0b
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/netlink/.svn/text-base/msg.h.svn-base
@@ -0,0 +1,308 @@
+/*
+ * netlink/msg.c Netlink Messages Interface
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
+ */
+
+#ifndef NETLINK_MSG_H_
+#define NETLINK_MSG_H_
+
+#include <netlink/netlink.h>
+#include <netlink/object.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct nla_policy;
+
+#define NL_DONTPAD 0
+
+/**
+ * @ingroup msg
+ * @brief
+ * Will cause the netlink pid to be set to the pid assigned to
+ * the netlink handle (socket) just before sending the message off.
+ * @note Requires the use of nl_send_auto_complete()!
+ */
+#define NL_AUTO_PID 0
+
+/**
+ * @ingroup msg
+ * @brief
+ * May be used to refer to a sequence number which should be
+ * automatically set just before sending the message off.
+ * @note Requires the use of nl_send_auto_complete()!
+ */
+#define NL_AUTO_SEQ 0
+
+#define NL_MSG_CRED_PRESENT 1
+
+struct nl_msg
+{
+ int nm_protocol;
+ int nm_flags;
+ struct sockaddr_nl nm_src;
+ struct sockaddr_nl nm_dst;
+ struct ucred nm_creds;
+ struct nlmsghdr * nm_nlh;
+ size_t nm_size;
+ int nm_refcnt;
+};
+
+
+struct nl_msg;
+struct nl_tree;
+struct ucred;
+
+/* message parsing */
+extern int nlmsg_ok(const struct nlmsghdr *, int);
+extern struct nlmsghdr * nlmsg_next(struct nlmsghdr *, int *);
+extern int nlmsg_parse(struct nlmsghdr *, int, struct nlattr **,
+ int, struct nla_policy *);
+extern int nlmsg_validate(struct nlmsghdr *, int, int,
+ struct nla_policy *);
+
+extern struct nl_msg * nlmsg_alloc(void);
+extern struct nl_msg * nlmsg_alloc_size(size_t);
+extern struct nl_msg * nlmsg_alloc_simple(int, int);
+extern void nlmsg_set_default_size(size_t);
+extern struct nl_msg * nlmsg_inherit(struct nlmsghdr *);
+extern struct nl_msg * nlmsg_convert(struct nlmsghdr *);
+extern void * nlmsg_reserve(struct nl_msg *, size_t, int);
+extern int nlmsg_append(struct nl_msg *, void *, size_t, int);
+
+extern struct nlmsghdr * nlmsg_put(struct nl_msg *, uint32_t, uint32_t,
+ int, int, int);
+extern void nlmsg_free(struct nl_msg *);
+
+extern int nl_msg_parse(struct nl_msg *,
+ void (*cb)(struct nl_object *, void *),
+ void *);
+
+extern void nl_msg_dump(struct nl_msg *, FILE *);
+
+/**
+ * length of netlink message not including padding
+ * @arg payload length of message payload
+ */
+static inline int nlmsg_msg_size(int payload)
+{
+ return NLMSG_HDRLEN + payload;
+}
+
+/**
+ * length of netlink message including padding
+ * @arg payload length of message payload
+ */
+static inline int nlmsg_total_size(int payload)
+{
+ return NLMSG_ALIGN(nlmsg_msg_size(payload));
+}
+
+/**
+ * length of padding at the message's tail
+ * @arg payload length of message payload
+ */
+static inline int nlmsg_padlen(int payload)
+{
+ return nlmsg_total_size(payload) - nlmsg_msg_size(payload);
+}
+
+/**
+ * head of message payload
+ * @arg nlh netlink messsage header
+ */
+static inline void *nlmsg_data(const struct nlmsghdr *nlh)
+{
+ return (unsigned char *) nlh + NLMSG_HDRLEN;
+}
+
+static inline void *nlmsg_tail(const struct nlmsghdr *nlh)
+{
+ return (unsigned char *) nlh + NLMSG_ALIGN(nlh->nlmsg_len);
+}
+
+/**
+ * length of message payload
+ * @arg nlh netlink message header
+ */
+static inline int nlmsg_len(const struct nlmsghdr *nlh)
+{
+ return nlh->nlmsg_len - NLMSG_HDRLEN;
+}
+
+/**
+ * head of attributes data
+ * @arg nlh netlink message header
+ * @arg hdrlen length of family specific header
+ */
+static inline struct nlattr *nlmsg_attrdata(const struct nlmsghdr *nlh, int hdrlen)
+{
+ unsigned char *data = (unsigned char*)nlmsg_data(nlh);
+ return (struct nlattr *) (data + NLMSG_ALIGN(hdrlen));
+}
+
+/**
+ * length of attributes data
+ * @arg nlh netlink message header
+ * @arg hdrlen length of family specific header
+ */
+static inline int nlmsg_attrlen(const struct nlmsghdr *nlh, int hdrlen)
+{
+ return nlmsg_len(nlh) - NLMSG_ALIGN(hdrlen);
+}
+
+static inline int nlmsg_valid_hdr(const struct nlmsghdr *nlh, int hdrlen)
+{
+ if (nlh->nlmsg_len < (uint)nlmsg_msg_size(hdrlen))
+ return 0;
+
+ return 1;
+}
+
+
+static inline void nlmsg_set_proto(struct nl_msg *msg, int protocol)
+{
+ msg->nm_protocol = protocol;
+}
+
+static inline int nlmsg_get_proto(struct nl_msg *msg)
+{
+ return msg->nm_protocol;
+}
+
+static inline size_t nlmsg_get_max_size(struct nl_msg *msg)
+{
+ return msg->nm_size;
+}
+
+static inline void nlmsg_set_src(struct nl_msg *msg, struct sockaddr_nl *addr)
+{
+ memcpy(&msg->nm_src, addr, sizeof(*addr));
+}
+
+static inline struct sockaddr_nl *nlmsg_get_src(struct nl_msg *msg)
+{
+ return &msg->nm_src;
+}
+
+static inline void nlmsg_set_dst(struct nl_msg *msg, struct sockaddr_nl *addr)
+{
+ memcpy(&msg->nm_dst, addr, sizeof(*addr));
+}
+
+static inline struct sockaddr_nl *nlmsg_get_dst(struct nl_msg *msg)
+{
+ return &msg->nm_dst;
+}
+
+static inline void nlmsg_set_creds(struct nl_msg *msg, struct ucred *creds)
+{
+ memcpy(&msg->nm_creds, creds, sizeof(*creds));
+ msg->nm_flags |= NL_MSG_CRED_PRESENT;
+}
+
+static inline struct ucred *nlmsg_get_creds(struct nl_msg *msg)
+{
+ if (msg->nm_flags & NL_MSG_CRED_PRESENT)
+ return &msg->nm_creds;
+ return NULL;
+}
+
+/**
+ * Return actual netlink message
+ * @arg n netlink message
+ *
+ * Returns the actual netlink message casted to the type of the netlink
+ * message header.
+ *
+ * @return A pointer to the netlink message.
+ */
+static inline struct nlmsghdr *nlmsg_hdr(struct nl_msg *n)
+{
+ return n->nm_nlh;
+}
+
+/**
+ * Acquire a reference on a netlink message
+ * @arg msg message to acquire reference from
+ */
+static inline void nlmsg_get(struct nl_msg *msg)
+{
+ msg->nm_refcnt++;
+}
+
+/**
+ * Expand maximum payload size of a netlink message
+ * @arg n Netlink message.
+ * @arg newlen New maximum payload size.
+ *
+ * Reallocates the payload section of a netlink message and increases
+ * the maximum payload size of the message.
+ *
+ * @note Any pointers pointing to old payload block will be stale and
+ * need to be refetched. Therfore, do not expand while constructing
+ * nested attributes or while reserved data blocks are held.
+ *
+ * @return 0 on success or a negative error code.
+ */
+static inline int nlmsg_expand(struct nl_msg *n, size_t newlen)
+{
+ void *tmp;
+
+ if (newlen <= n->nm_size)
+ return -NLE_INVAL;
+
+ tmp = realloc(n->nm_nlh, newlen);
+ if (tmp == NULL)
+ return -NLE_NOMEM;
+
+ n->nm_nlh = (struct nlmsghdr*)tmp;
+ n->nm_size = newlen;
+
+ return 0;
+}
+
+
+/**
+ * @name Iterators
+ * @{
+ */
+
+/**
+ * @ingroup msg
+ * Iterate over a stream of attributes in a message
+ * @arg pos loop counter, set to current attribute
+ * @arg nlh netlink message header
+ * @arg hdrlen length of family header
+ * @arg rem initialized to len, holds bytes currently remaining in stream
+ */
+#define nlmsg_for_each_attr(pos, nlh, hdrlen, rem) \
+ nla_for_each_attr(pos, nlmsg_attrdata(nlh, hdrlen), \
+ nlmsg_attrlen(nlh, hdrlen), rem)
+
+/**
+ * Iterate over a stream of messages
+ * @arg pos loop counter, set to current message
+ * @arg head head of message stream
+ * @arg len length of message stream
+ * @arg rem initialized to len, holds bytes currently remaining in stream
+ */
+#define nlmsg_for_each_msg(pos, head, len, rem) \
+ for (pos = head, rem = len; \
+ nlmsg_ok(pos, rem); \
+ pos = nlmsg_next(pos, &(rem)))
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/package/libs/libnl-tiny/src/include/netlink/.svn/text-base/netlink-compat.h.svn-base b/package/libs/libnl-tiny/src/include/netlink/.svn/text-base/netlink-compat.h.svn-base
new file mode 100644
index 0000000..17ec9fc
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/netlink/.svn/text-base/netlink-compat.h.svn-base
@@ -0,0 +1,50 @@
+/*
+ * netlink/netlink-compat.h Netlink Compatability
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
+ */
+
+#ifndef NETLINK_COMPAT_H_
+#define NETLINK_COMPAT_H_
+
+#if !defined _LINUX_SOCKET_H && !defined _BITS_SOCKADDR_H
+typedef unsigned short sa_family_t;
+#endif
+
+#ifndef IFNAMSIZ
+/** Maximum length of a interface name */
+#define IFNAMSIZ 16
+#endif
+
+/* patch 2.4.x if_arp */
+#ifndef ARPHRD_INFINIBAND
+#define ARPHRD_INFINIBAND 32
+#endif
+
+/* patch 2.4.x eth header file */
+#ifndef ETH_P_MPLS_UC
+#define ETH_P_MPLS_UC 0x8847
+#endif
+
+#ifndef ETH_P_MPLS_MC
+#define ETH_P_MPLS_MC 0x8848
+#endif
+
+#ifndef ETH_P_EDP2
+#define ETH_P_EDP2 0x88A2
+#endif
+
+#ifndef ETH_P_HDLC
+#define ETH_P_HDLC 0x0019
+#endif
+
+#ifndef AF_LLC
+#define AF_LLC 26
+#endif
+
+#endif
diff --git a/package/libs/libnl-tiny/src/include/netlink/.svn/text-base/netlink-kernel.h.svn-base b/package/libs/libnl-tiny/src/include/netlink/.svn/text-base/netlink-kernel.h.svn-base
new file mode 100644
index 0000000..a0f5535
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/netlink/.svn/text-base/netlink-kernel.h.svn-base
@@ -0,0 +1,196 @@
+#ifndef __LINUX_NETLINK_H
+#define __LINUX_NETLINK_H
+
+/**
+ * Netlink socket address
+ * @ingroup nl
+ */
+struct sockaddr_nl
+{
+ /** socket family (AF_NETLINK) */
+ sa_family_t nl_family;
+
+ /** Padding (unused) */
+ unsigned short nl_pad;
+
+ /** Unique process ID */
+ uint32_t nl_pid;
+
+ /** Multicast group subscriptions */
+ uint32_t nl_groups;
+};
+
+/**
+ * Netlink message header
+ * @ingroup msg
+ */
+struct nlmsghdr
+{
+ /**
+ * Length of message including header.
+ */
+ uint32_t nlmsg_len;
+
+ /**
+ * Message type (content type)
+ */
+ uint16_t nlmsg_type;
+
+ /**
+ * Message flags
+ */
+ uint16_t nlmsg_flags;
+
+ /**
+ * Sequence number
+ */
+ uint32_t nlmsg_seq;
+
+ /**
+ * Netlink PID of the proccess sending the message.
+ */
+ uint32_t nlmsg_pid;
+};
+
+/**
+ * @name Standard message flags
+ * @{
+ */
+
+/**
+ * Must be set on all request messages (typically from user space to
+ * kernel space).
+ * @ingroup msg
+ */
+#define NLM_F_REQUEST 1
+
+/**
+ * Indicates the message is part of a multipart message terminated
+ * by NLMSG_DONE.
+ */
+#define NLM_F_MULTI 2
+
+/**
+ * Request for an acknowledgment on success.
+ */
+#define NLM_F_ACK 4
+
+/**
+ * Echo this request
+ */
+#define NLM_F_ECHO 8
+
+/** @} */
+
+/**
+ * @name Additional message flags for GET requests
+ * @{
+ */
+
+/**
+ * Return the complete table instead of a single entry.
+ * @ingroup msg
+ */
+#define NLM_F_ROOT 0x100
+
+/**
+ * Return all entries matching criteria passed in message content.
+ */
+#define NLM_F_MATCH 0x200
+
+/**
+ * Return an atomic snapshot of the table being referenced. This
+ * may require special privileges because it has the potential to
+ * interrupt service in the FE for a longer time.
+ */
+#define NLM_F_ATOMIC 0x400
+
+/**
+ * Dump all entries
+ */
+#define NLM_F_DUMP (NLM_F_ROOT|NLM_F_MATCH)
+
+/** @} */
+
+/**
+ * @name Additional messsage flags for NEW requests
+ * @{
+ */
+
+/**
+ * Replace existing matching config object with this request.
+ * @ingroup msg
+ */
+#define NLM_F_REPLACE 0x100
+
+/**
+ * Don't replace the config object if it already exists.
+ */
+#define NLM_F_EXCL 0x200
+
+/**
+ * Create config object if it doesn't already exist.
+ */
+#define NLM_F_CREATE 0x400
+
+/**
+ * Add to the end of the object list.
+ */
+#define NLM_F_APPEND 0x800
+
+/** @} */
+
+/**
+ * @name Standard Message types
+ * @{
+ */
+
+/**
+ * No operation, message must be ignored
+ * @ingroup msg
+ */
+#define NLMSG_NOOP 0x1
+
+/**
+ * The message signals an error and the payload contains a nlmsgerr
+ * structure. This can be looked at as a NACK and typically it is
+ * from FEC to CPC.
+ */
+#define NLMSG_ERROR 0x2
+
+/**
+ * Message terminates a multipart message.
+ */
+#define NLMSG_DONE 0x3
+
+/**
+ * The message signals that data got lost
+ */
+#define NLMSG_OVERRUN 0x4
+
+/**
+ * Lower limit of reserved message types
+ */
+#define NLMSG_MIN_TYPE 0x10
+
+/** @} */
+
+/**
+ * Netlink error message
+ * @ingroup msg
+ */
+struct nlmsgerr
+{
+ /** Error code (errno number) */
+ int error;
+
+ /** Original netlink message causing the error */
+ struct nlmsghdr msg;
+};
+
+struct nl_pktinfo
+{
+ __u32 group;
+};
+
+#endif /* __LINUX_NETLINK_H */
diff --git a/package/libs/libnl-tiny/src/include/netlink/.svn/text-base/netlink.h.svn-base b/package/libs/libnl-tiny/src/include/netlink/.svn/text-base/netlink.h.svn-base
new file mode 100644
index 0000000..e06fb7f
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/netlink/.svn/text-base/netlink.h.svn-base
@@ -0,0 +1,82 @@
+/*
+ * netlink/netlink.h Netlink Interface
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
+ */
+
+#ifndef NETLINK_NETLINK_H_
+#define NETLINK_NETLINK_H_
+
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+#include <sys/poll.h>
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <netdb.h>
+#include <netlink/netlink-compat.h>
+#include <linux/netlink.h>
+#include <linux/genetlink.h>
+#include <netlink/version.h>
+#include <netlink/errno.h>
+#include <netlink/types.h>
+#include <netlink/handlers.h>
+#include <netlink/socket.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern int nl_debug;
+extern struct nl_dump_params nl_debug_dp;
+
+/* Connection Management */
+extern int nl_connect(struct nl_sock *, int);
+extern void nl_close(struct nl_sock *);
+
+/* Send */
+extern int nl_sendto(struct nl_sock *, void *, size_t);
+extern int nl_sendmsg(struct nl_sock *, struct nl_msg *,
+ struct msghdr *);
+extern int nl_send(struct nl_sock *, struct nl_msg *);
+extern int nl_send_auto_complete(struct nl_sock *,
+ struct nl_msg *);
+extern int nl_send_simple(struct nl_sock *, int, int,
+ void *, size_t);
+
+/* Receive */
+extern int nl_recv(struct nl_sock *,
+ struct sockaddr_nl *, unsigned char **,
+ struct ucred **);
+extern int nl_recvmsgs(struct nl_sock *sk, struct nl_cb *cb);
+
+extern int nl_wait_for_ack(struct nl_sock *);
+
+/* Netlink Family Translations */
+extern char * nl_nlfamily2str(int, char *, size_t);
+extern int nl_str2nlfamily(const char *);
+
+/**
+ * Receive a set of message from a netlink socket using handlers in nl_sock.
+ * @arg sk Netlink socket.
+ *
+ * Calls nl_recvmsgs() with the handlers configured in the netlink socket.
+ */
+static inline int nl_recvmsgs_default(struct nl_sock *sk)
+{
+ return nl_recvmsgs(sk, sk->s_cb);
+}
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/package/libs/libnl-tiny/src/include/netlink/.svn/text-base/object-api.h.svn-base b/package/libs/libnl-tiny/src/include/netlink/.svn/text-base/object-api.h.svn-base
new file mode 100644
index 0000000..8a44fe9
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/netlink/.svn/text-base/object-api.h.svn-base
@@ -0,0 +1,331 @@
+/*
+ * netlink/object-api.c Object API
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2007 Thomas Graf <tgraf@suug.ch>
+ */
+
+#ifndef NETLINK_OBJECT_API_H_
+#define NETLINK_OBJECT_API_H_
+
+#include <netlink/netlink.h>
+#include <netlink/utils.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @ingroup object
+ * @defgroup object_api Object API
+ * @brief
+ *
+ * @par 1) Object Definition
+ * @code
+ * // Define your object starting with the common object header
+ * struct my_obj {
+ * NLHDR_COMMON
+ * int my_data;
+ * };
+ *
+ * // Fill out the object operations structure
+ * struct nl_object_ops my_ops = {
+ * .oo_name = "my_obj",
+ * .oo_size = sizeof(struct my_obj),
+ * };
+ *
+ * // At this point the object can be allocated, you may want to provide a
+ * // separate _alloc() function to ease allocting objects of this kind.
+ * struct nl_object *obj = nl_object_alloc(&my_ops);
+ *
+ * // And release it again...
+ * nl_object_put(obj);
+ * @endcode
+ *
+ * @par 2) Allocating additional data
+ * @code
+ * // You may require to allocate additional data and store it inside
+ * // object, f.e. assuming there is a field `ptr'.
+ * struct my_obj {
+ * NLHDR_COMMON
+ * void * ptr;
+ * };
+ *
+ * // And at some point you may assign allocated data to this field:
+ * my_obj->ptr = calloc(1, ...);
+ *
+ * // In order to not introduce any memory leaks you have to release
+ * // this data again when the last reference is given back.
+ * static void my_obj_free_data(struct nl_object *obj)
+ * {
+ * struct my_obj *my_obj = nl_object_priv(obj);
+ *
+ * free(my_obj->ptr);
+ * }
+ *
+ * // Also when the object is cloned, you must ensure for your pointer
+ * // stay valid even if one of the clones is freed by either making
+ * // a clone as well or increase the reference count.
+ * static int my_obj_clone(struct nl_object *src, struct nl_object *dst)
+ * {
+ * struct my_obj *my_src = nl_object_priv(src);
+ * struct my_obj *my_dst = nl_object_priv(dst);
+ *
+ * if (src->ptr) {
+ * dst->ptr = calloc(1, ...);
+ * memcpy(dst->ptr, src->ptr, ...);
+ * }
+ * }
+ *
+ * struct nl_object_ops my_ops = {
+ * ...
+ * .oo_free_data = my_obj_free_data,
+ * .oo_clone = my_obj_clone,
+ * };
+ * @endcode
+ *
+ * @par 3) Object Dumping
+ * @code
+ * static int my_obj_dump_detailed(struct nl_object *obj,
+ * struct nl_dump_params *params)
+ * {
+ * struct my_obj *my_obj = nl_object_priv(obj);
+ *
+ * // It is absolutely essential to use nl_dump() when printing
+ * // any text to make sure the dumping parameters are respected.
+ * nl_dump(params, "Obj Integer: %d\n", my_obj->my_int);
+ *
+ * // Before we can dump the next line, make sure to prefix
+ * // this line correctly.
+ * nl_new_line(params);
+ *
+ * // You may also split a line into multiple nl_dump() calls.
+ * nl_dump(params, "String: %s ", my_obj->my_string);
+ * nl_dump(params, "String-2: %s\n", my_obj->another_string);
+ * }
+ *
+ * struct nl_object_ops my_ops = {
+ * ...
+ * .oo_dump[NL_DUMP_FULL] = my_obj_dump_detailed,
+ * };
+ * @endcode
+ *
+ * @par 4) Object Attributes
+ * @code
+ * // The concept of object attributes is optional but can ease the typical
+ * // case of objects that have optional attributes, e.g. a route may have a
+ * // nexthop assigned but it is not required to.
+ *
+ * // The first step to define your object specific bitmask listing all
+ * // attributes
+ * #define MY_ATTR_FOO (1<<0)
+ * #define MY_ATTR_BAR (1<<1)
+ *
+ * // When assigning an optional attribute to the object, make sure
+ * // to mark its availability.
+ * my_obj->foo = 123123;
+ * my_obj->ce_mask |= MY_ATTR_FOO;
+ *
+ * // At any time you may use this mask to check for the availability
+ * // of the attribute, e.g. while dumping
+ * if (my_obj->ce_mask & MY_ATTR_FOO)
+ * nl_dump(params, "foo %d ", my_obj->foo);
+ *
+ * // One of the big advantages of this concept is that it allows for
+ * // standardized comparisons which make it trivial for caches to
+ * // identify unique objects by use of unified comparison functions.
+ * // In order for it to work, your object implementation must provide
+ * // a comparison function and define a list of attributes which
+ * // combined together make an object unique.
+ *
+ * static int my_obj_compare(struct nl_object *_a, struct nl_object *_b,
+ * uint32_t attrs, int flags)
+ * {
+ * struct my_obj *a = nl_object_priv(_a):
+ * struct my_obj *b = nl_object_priv(_b):
+ * int diff = 0;
+ *
+ * // We help ourselves in defining our own DIFF macro which will
+ * // call ATTR_DIFF() on both objects which will make sure to only
+ * // compare the attributes if required.
+ * #define MY_DIFF(ATTR, EXPR) ATTR_DIFF(attrs, MY_ATTR_##ATTR, a, b, EXPR)
+ *
+ * // Call our own diff macro for each attribute to build a bitmask
+ * // representing the attributes which mismatch.
+ * diff |= MY_DIFF(FOO, a->foo != b->foo)
+ * diff |= MY_DIFF(BAR, strcmp(a->bar, b->bar))
+ *
+ * return diff;
+ * }
+ *
+ * // In order to identify identical objects with differing attributes
+ * // you must specify the attributes required to uniquely identify
+ * // your object. Make sure to not include too many attributes, this
+ * // list is used when caches look for an old version of an object.
+ * struct nl_object_ops my_ops = {
+ * ...
+ * .oo_id_attrs = MY_ATTR_FOO,
+ * .oo_compare = my_obj_compare,
+ * };
+ * @endcode
+ * @{
+ */
+
+/**
+ * Common Object Header
+ *
+ * This macro must be included as first member in every object
+ * definition to allow objects to be cached.
+ */
+#define NLHDR_COMMON \
+ int ce_refcnt; \
+ struct nl_object_ops * ce_ops; \
+ struct nl_cache * ce_cache; \
+ struct nl_list_head ce_list; \
+ int ce_msgtype; \
+ int ce_flags; \
+ uint32_t ce_mask;
+
+/**
+ * Return true if attribute is available in both objects
+ * @arg A an object
+ * @arg B another object
+ * @arg ATTR attribute bit
+ *
+ * @return True if the attribute is available, otherwise false is returned.
+ */
+#define AVAILABLE(A, B, ATTR) (((A)->ce_mask & (B)->ce_mask) & (ATTR))
+
+/**
+ * Return true if attributes mismatch
+ * @arg A an object
+ * @arg B another object
+ * @arg ATTR attribute bit
+ * @arg EXPR Comparison expression
+ *
+ * This function will check if the attribute in question is available
+ * in both objects, if not this will count as a mismatch.
+ *
+ * If available the function will execute the expression which must
+ * return true if the attributes mismatch.
+ *
+ * @return True if the attribute mismatch, or false if they match.
+ */
+#define ATTR_MISMATCH(A, B, ATTR, EXPR) (!AVAILABLE(A, B, ATTR) || (EXPR))
+
+/**
+ * Return attribute bit if attribute does not match
+ * @arg LIST list of attributes to be compared
+ * @arg ATTR attribute bit
+ * @arg A an object
+ * @arg B another object
+ * @arg EXPR Comparison expression
+ *
+ * This function will check if the attribute in question is available
+ * in both objects, if not this will count as a mismatch.
+ *
+ * If available the function will execute the expression which must
+ * return true if the attributes mismatch.
+ *
+ * In case the attributes mismatch, the attribute is returned, otherwise
+ * 0 is returned.
+ *
+ * @code
+ * diff |= ATTR_DIFF(attrs, MY_ATTR_FOO, a, b, a->foo != b->foo);
+ * @endcode
+ */
+#define ATTR_DIFF(LIST, ATTR, A, B, EXPR) \
+({ int diff = 0; \
+ if (((LIST) & (ATTR)) && ATTR_MISMATCH(A, B, ATTR, EXPR)) \
+ diff = ATTR; \
+ diff; })
+
+/**
+ * Object Operations
+ */
+struct nl_object;
+struct nl_object_ops
+{
+ /**
+ * Unique name of object type
+ *
+ * Must be in the form family/name, e.g. "route/addr"
+ */
+ char * oo_name;
+
+ /** Size of object including its header */
+ size_t oo_size;
+
+ /* List of attributes needed to uniquely identify the object */
+ uint32_t oo_id_attrs;
+
+ /**
+ * Constructor function
+ *
+ * Will be called when a new object of this type is allocated.
+ * Can be used to initialize members such as lists etc.
+ */
+ void (*oo_constructor)(struct nl_object *);
+
+ /**
+ * Destructor function
+ *
+ * Will be called when an object is freed. Must free all
+ * resources which may have been allocated as part of this
+ * object.
+ */
+ void (*oo_free_data)(struct nl_object *);
+
+ /**
+ * Cloning function
+ *
+ * Will be called when an object needs to be cloned. Please
+ * note that the generic object code will make an exact
+ * copy of the object first, therefore you only need to take
+ * care of members which require reference counting etc.
+ *
+ * May return a negative error code to abort cloning.
+ */
+ int (*oo_clone)(struct nl_object *, struct nl_object *);
+
+ /**
+ * Dumping functions
+ *
+ * Will be called when an object is dumped. The implementations
+ * have to use nl_dump(), nl_dump_line(), and nl_new_line() to
+ * dump objects.
+ *
+ * The functions must return the number of lines printed.
+ */
+ void (*oo_dump[NL_DUMP_MAX+1])(struct nl_object *,
+ struct nl_dump_params *);
+
+ /**
+ * Comparison function
+ *
+ * Will be called when two objects of the same type are
+ * compared. It takes the two objects in question, an object
+ * specific bitmask defining which attributes should be
+ * compared and flags to control the behaviour.
+ *
+ * The function must return a bitmask with the relevant bit
+ * set for each attribute that mismatches.
+ */
+ int (*oo_compare)(struct nl_object *, struct nl_object *,
+ uint32_t, int);
+
+
+ char *(*oo_attrs2str)(int, char *, size_t);
+};
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/package/libs/libnl-tiny/src/include/netlink/.svn/text-base/object.h.svn-base b/package/libs/libnl-tiny/src/include/netlink/.svn/text-base/object.h.svn-base
new file mode 100644
index 0000000..8aabe7b
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/netlink/.svn/text-base/object.h.svn-base
@@ -0,0 +1,164 @@
+/*
+ * netlink/object.c Generic Cacheable Object
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
+ */
+
+#ifndef NETLINK_OBJECT_H_
+#define NETLINK_OBJECT_H_
+
+#include <netlink/netlink.h>
+#include <netlink/utils.h>
+#include <netlink/object-api.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define NL_OBJ_MARK 1
+
+struct nl_cache;
+struct nl_object;
+struct nl_object_ops;
+
+struct nl_object
+{
+ NLHDR_COMMON
+};
+
+#define OBJ_CAST(ptr) ((struct nl_object *) (ptr))
+
+/* General */
+extern struct nl_object * nl_object_alloc(struct nl_object_ops *);
+extern void nl_object_free(struct nl_object *);
+extern struct nl_object * nl_object_clone(struct nl_object *obj);
+
+#ifdef disabled
+
+extern int nl_object_alloc_name(const char *,
+ struct nl_object **);
+extern void nl_object_dump(struct nl_object *,
+ struct nl_dump_params *);
+
+extern uint32_t nl_object_diff(struct nl_object *,
+ struct nl_object *);
+extern int nl_object_match_filter(struct nl_object *,
+ struct nl_object *);
+extern int nl_object_identical(struct nl_object *,
+ struct nl_object *);
+extern char * nl_object_attrs2str(struct nl_object *,
+ uint32_t attrs, char *buf,
+ size_t);
+#endif
+/**
+ * Check whether this object is used by multiple users
+ * @arg obj object to check
+ * @return true or false
+ */
+static inline int nl_object_shared(struct nl_object *obj)
+{
+ return obj->ce_refcnt > 1;
+}
+
+
+static inline void nl_object_get(struct nl_object *obj)
+{
+ obj->ce_refcnt++;
+}
+
+static inline void nl_object_put(struct nl_object *obj)
+{
+ if (!obj)
+ return;
+
+ obj->ce_refcnt--;
+
+ if (obj->ce_refcnt <= 0)
+ nl_object_free(obj);
+}
+
+
+/**
+ * @name Marks
+ * @{
+ */
+
+/**
+ * Add mark to object
+ * @arg obj Object to mark
+ */
+static inline void nl_object_mark(struct nl_object *obj)
+{
+ obj->ce_flags |= NL_OBJ_MARK;
+}
+
+/**
+ * Remove mark from object
+ * @arg obj Object to unmark
+ */
+static inline void nl_object_unmark(struct nl_object *obj)
+{
+ obj->ce_flags &= ~NL_OBJ_MARK;
+}
+
+/**
+ * Return true if object is marked
+ * @arg obj Object to check
+ * @return true if object is marked, otherwise false
+ */
+static inline int nl_object_is_marked(struct nl_object *obj)
+{
+ return (obj->ce_flags & NL_OBJ_MARK);
+}
+
+/** @} */
+
+#ifdef disabled
+/**
+ * Return list of attributes present in an object
+ * @arg obj an object
+ * @arg buf destination buffer
+ * @arg len length of destination buffer
+ *
+ * @return destination buffer.
+ */
+static inline char *nl_object_attr_list(struct nl_object *obj, char *buf, size_t len)
+{
+ return nl_object_attrs2str(obj, obj->ce_mask, buf, len);
+}
+#endif
+
+/**
+ * @name Attributes
+ * @{
+ */
+
+static inline int nl_object_get_refcnt(struct nl_object *obj)
+{
+ return obj->ce_refcnt;
+}
+
+static inline struct nl_cache *nl_object_get_cache(struct nl_object *obj)
+{
+ return obj->ce_cache;
+}
+
+static inline void * nl_object_priv(struct nl_object *obj)
+{
+ return obj;
+}
+
+
+/** @} */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/package/libs/libnl-tiny/src/include/netlink/.svn/text-base/socket.h.svn-base b/package/libs/libnl-tiny/src/include/netlink/.svn/text-base/socket.h.svn-base
new file mode 100644
index 0000000..9f7f422
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/netlink/.svn/text-base/socket.h.svn-base
@@ -0,0 +1,221 @@
+/*
+ * netlink/socket.h Netlink Socket
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
+ */
+
+#ifndef NETLINK_SOCKET_H_
+#define NETLINK_SOCKET_H_
+
+#include <netlink/types.h>
+#include <netlink/handlers.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define NL_SOCK_BUFSIZE_SET (1<<0)
+#define NL_SOCK_PASSCRED (1<<1)
+#define NL_OWN_PORT (1<<2)
+#define NL_MSG_PEEK (1<<3)
+#define NL_NO_AUTO_ACK (1<<4)
+
+struct nl_cb;
+struct nl_sock
+{
+ struct sockaddr_nl s_local;
+ struct sockaddr_nl s_peer;
+ int s_fd;
+ int s_proto;
+ unsigned int s_seq_next;
+ unsigned int s_seq_expect;
+ int s_flags;
+ struct nl_cb * s_cb;
+};
+
+
+extern struct nl_sock * nl_socket_alloc(void);
+extern struct nl_sock * nl_socket_alloc_cb(struct nl_cb *);
+extern void nl_socket_free(struct nl_sock *);
+
+extern void nl_socket_set_local_port(struct nl_sock *, uint32_t);
+
+extern int nl_socket_add_memberships(struct nl_sock *, int, ...);
+extern int nl_socket_drop_memberships(struct nl_sock *, int, ...);
+
+extern int nl_socket_set_buffer_size(struct nl_sock *, int, int);
+extern int nl_socket_set_passcred(struct nl_sock *, int);
+extern int nl_socket_recv_pktinfo(struct nl_sock *, int);
+
+extern void nl_socket_disable_seq_check(struct nl_sock *);
+
+extern int nl_socket_set_nonblocking(struct nl_sock *);
+
+/**
+ * Use next sequence number
+ * @arg sk Netlink socket.
+ *
+ * Uses the next available sequence number and increases the counter
+ * by one for subsequent calls.
+ *
+ * @return Unique serial sequence number
+ */
+static inline unsigned int nl_socket_use_seq(struct nl_sock *sk)
+{
+ return sk->s_seq_next++;
+}
+
+/**
+ * Disable automatic request for ACK
+ * @arg sk Netlink socket.
+ *
+ * The default behaviour of a socket is to request an ACK for
+ * each message sent to allow for the caller to synchronize to
+ * the completion of the netlink operation. This function
+ * disables this behaviour and will result in requests being
+ * sent which will not have the NLM_F_ACK flag set automatically.
+ * However, it is still possible for the caller to set the
+ * NLM_F_ACK flag explicitely.
+ */
+static inline void nl_socket_disable_auto_ack(struct nl_sock *sk)
+{
+ sk->s_flags |= NL_NO_AUTO_ACK;
+}
+
+/**
+ * Enable automatic request for ACK (default)
+ * @arg sk Netlink socket.
+ * @see nl_socket_disable_auto_ack
+ */
+static inline void nl_socket_enable_auto_ack(struct nl_sock *sk)
+{
+ sk->s_flags &= ~NL_NO_AUTO_ACK;
+}
+
+/**
+ * @name Source Idenficiation
+ * @{
+ */
+
+static inline uint32_t nl_socket_get_local_port(struct nl_sock *sk)
+{
+ return sk->s_local.nl_pid;
+}
+
+/**
+ * Join multicast groups (deprecated)
+ * @arg sk Netlink socket.
+ * @arg groups Bitmask of groups to join.
+ *
+ * This function defines the old way of joining multicast group which
+ * has to be done prior to calling nl_connect(). It works on any kernel
+ * version but is very limited as only 32 groups can be joined.
+ */
+static inline void nl_join_groups(struct nl_sock *sk, int groups)
+{
+ sk->s_local.nl_groups |= groups;
+}
+
+/**
+ * @name Peer Identfication
+ * @{
+ */
+
+static inline uint32_t nl_socket_get_peer_port(struct nl_sock *sk)
+{
+ return sk->s_peer.nl_pid;
+}
+
+static inline void nl_socket_set_peer_port(struct nl_sock *sk, uint32_t port)
+{
+ sk->s_peer.nl_pid = port;
+}
+
+/** @} */
+
+/**
+ * @name File Descriptor
+ * @{
+ */
+
+static inline int nl_socket_get_fd(struct nl_sock *sk)
+{
+ return sk->s_fd;
+}
+
+/**
+ * Enable use of MSG_PEEK when reading from socket
+ * @arg sk Netlink socket.
+ */
+static inline void nl_socket_enable_msg_peek(struct nl_sock *sk)
+{
+ sk->s_flags |= NL_MSG_PEEK;
+}
+
+/**
+ * Disable use of MSG_PEEK when reading from socket
+ * @arg sk Netlink socket.
+ */
+static inline void nl_socket_disable_msg_peek(struct nl_sock *sk)
+{
+ sk->s_flags &= ~NL_MSG_PEEK;
+}
+
+/**
+ * @name Callback Handler
+ * @{
+ */
+
+static inline struct nl_cb *nl_socket_get_cb(struct nl_sock *sk)
+{
+ return nl_cb_get(sk->s_cb);
+}
+
+static inline void nl_socket_set_cb(struct nl_sock *sk, struct nl_cb *cb)
+{
+ nl_cb_put(sk->s_cb);
+ sk->s_cb = nl_cb_get(cb);
+}
+
+/**
+ * Modify the callback handler associated to the socket
+ * @arg sk Netlink socket.
+ * @arg type which type callback to set
+ * @arg kind kind of callback
+ * @arg func callback function
+ * @arg arg argument to be passwd to callback function
+ *
+ * @see nl_cb_set
+ */
+static inline int nl_socket_modify_cb(struct nl_sock *sk, enum nl_cb_type type,
+ enum nl_cb_kind kind, nl_recvmsg_msg_cb_t func,
+ void *arg)
+{
+ return nl_cb_set(sk->s_cb, type, kind, func, arg);
+}
+
+/** @} */
+
+static inline int nl_socket_add_membership(struct nl_sock *sk, int group)
+{
+ return nl_socket_add_memberships(sk, group, 0);
+}
+
+
+static inline int nl_socket_drop_membership(struct nl_sock *sk, int group)
+{
+ return nl_socket_drop_memberships(sk, group, 0);
+}
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/package/libs/libnl-tiny/src/include/netlink/.svn/text-base/types.h.svn-base b/package/libs/libnl-tiny/src/include/netlink/.svn/text-base/types.h.svn-base
new file mode 100644
index 0000000..de81ace
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/netlink/.svn/text-base/types.h.svn-base
@@ -0,0 +1,121 @@
+/*
+ * netlink/netlink-types.h Netlink Types
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
+ */
+
+#ifndef __NETLINK_TYPES_H_
+#define __NETLINK_TYPES_H_
+
+#include <stdio.h>
+
+/**
+ * Dumping types (dp_type)
+ * @ingroup utils
+ */
+enum nl_dump_type {
+ NL_DUMP_LINE, /**< Dump object briefly on one line */
+ NL_DUMP_DETAILS, /**< Dump all attributes but no statistics */
+ NL_DUMP_STATS, /**< Dump all attributes including statistics */
+ NL_DUMP_ENV, /**< Dump all attribtues as env variables */
+ __NL_DUMP_MAX,
+};
+#define NL_DUMP_MAX (__NL_DUMP_MAX - 1)
+
+/**
+ * Dumping parameters
+ * @ingroup utils
+ */
+struct nl_dump_params
+{
+ /**
+ * Specifies the type of dump that is requested.
+ */
+ enum nl_dump_type dp_type;
+
+ /**
+ * Specifies the number of whitespaces to be put in front
+ * of every new line (indentation).
+ */
+ int dp_prefix;
+
+ /**
+ * Causes the cache index to be printed for each element.
+ */
+ int dp_print_index;
+
+ /**
+ * Causes each element to be prefixed with the message type.
+ */
+ int dp_dump_msgtype;
+
+ /**
+ * A callback invoked for output
+ *
+ * Passed arguments are:
+ * - dumping parameters
+ * - string to append to the output
+ */
+ void (*dp_cb)(struct nl_dump_params *, char *);
+
+ /**
+ * A callback invoked for every new line, can be used to
+ * customize the indentation.
+ *
+ * Passed arguments are:
+ * - dumping parameters
+ * - line number starting from 0
+ */
+ void (*dp_nl_cb)(struct nl_dump_params *, int);
+
+ /**
+ * User data pointer, can be used to pass data to callbacks.
+ */
+ void *dp_data;
+
+ /**
+ * File descriptor the dumping output should go to
+ */
+ FILE * dp_fd;
+
+ /**
+ * Alternatively the output may be redirected into a buffer
+ */
+ char * dp_buf;
+
+ /**
+ * Length of the buffer dp_buf
+ */
+ size_t dp_buflen;
+
+ /**
+ * PRIVATE
+ * Set if a dump was performed prior to the actual dump handler.
+ */
+ int dp_pre_dump;
+
+ /**
+ * PRIVATE
+ * Owned by the current caller
+ */
+ int dp_ivar;
+
+ unsigned int dp_line;
+};
+
+#ifndef __GNUC__
+#define __extension__
+#endif
+
+#define min_t(type,x,y) \
+ __extension__({ type __x = (x); type __y = (y); __x < __y ? __x: __y; })
+#define max_t(type,x,y) \
+ __extension__({ type __x = (x); type __y = (y); __x > __y ? __x: __y; })
+
+
+#endif
diff --git a/package/libs/libnl-tiny/src/include/netlink/.svn/text-base/utils.h.svn-base b/package/libs/libnl-tiny/src/include/netlink/.svn/text-base/utils.h.svn-base
new file mode 100644
index 0000000..480bab6
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/netlink/.svn/text-base/utils.h.svn-base
@@ -0,0 +1,78 @@
+/*
+ * netlink/utils.h Utility Functions
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
+ */
+
+#ifndef NETLINK_UTILS_H_
+#define NETLINK_UTILS_H_
+
+#include <netlink/netlink.h>
+#include <netlink/list.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @name Probability Constants
+ * @{
+ */
+
+/**
+ * Lower probability limit
+ * @ingroup utils
+ */
+#define NL_PROB_MIN 0x0
+
+/**
+ * Upper probability limit
+ * @ingroup utils
+ */
+#define NL_PROB_MAX 0xffffffff
+
+/** @} */
+
+/* unit pretty-printing */
+extern double nl_cancel_down_bytes(unsigned long long, char **);
+extern double nl_cancel_down_bits(unsigned long long, char **);
+extern double nl_cancel_down_us(uint32_t, char **);
+
+/* generic unit translations */
+extern long nl_size2int(const char *);
+extern long nl_prob2int(const char *);
+
+/* time translations */
+extern int nl_get_hz(void);
+extern uint32_t nl_us2ticks(uint32_t);
+extern uint32_t nl_ticks2us(uint32_t);
+extern int nl_str2msec(const char *, uint64_t *);
+extern char * nl_msec2str(uint64_t, char *, size_t);
+
+/* link layer protocol translations */
+extern char * nl_llproto2str(int, char *, size_t);
+extern int nl_str2llproto(const char *);
+
+/* ethernet protocol translations */
+extern char * nl_ether_proto2str(int, char *, size_t);
+extern int nl_str2ether_proto(const char *);
+
+/* IP protocol translations */
+extern char * nl_ip_proto2str(int, char *, size_t);
+extern int nl_str2ip_proto(const char *);
+
+/* Dumping helpers */
+extern void nl_new_line(struct nl_dump_params *);
+extern void nl_dump(struct nl_dump_params *, const char *, ...);
+extern void nl_dump_line(struct nl_dump_params *, const char *, ...);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/package/libs/libnl-tiny/src/include/netlink/.svn/text-base/version.h.svn-base b/package/libs/libnl-tiny/src/include/netlink/.svn/text-base/version.h.svn-base
new file mode 100644
index 0000000..6a316d4
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/netlink/.svn/text-base/version.h.svn-base
@@ -0,0 +1,18 @@
+/*
+ * netlink/version.h Compile Time Versioning Information
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2008 Thomas Graf <tgraf@suug.ch>
+ */
+
+#ifndef NETLINK_VERSION_H_
+#define NETLINK_VERSION_H_
+
+#define LIBNL_STRING "libnl"
+#define LIBNL_VERSION "2.0"
+
+#endif
diff --git a/package/libs/libnl-tiny/src/include/netlink/addr.h b/package/libs/libnl-tiny/src/include/netlink/addr.h
new file mode 100644
index 0000000..cc3d201
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/netlink/addr.h
@@ -0,0 +1,69 @@
+/*
+ * netlink/addr.h Abstract Address
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
+ */
+
+#ifndef NETLINK_ADDR_H_
+#define NETLINK_ADDR_H_
+
+#include <netlink/netlink.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct nl_addr;
+
+/* Creation */
+extern struct nl_addr * nl_addr_alloc(size_t);
+extern struct nl_addr * nl_addr_alloc_attr(struct nlattr *, int);
+extern struct nl_addr * nl_addr_build(int, void *, size_t);
+extern int nl_addr_parse(const char *, int, struct nl_addr **);
+extern struct nl_addr * nl_addr_clone(struct nl_addr *);
+
+/* Destroyage */
+extern void nl_addr_destroy(struct nl_addr *);
+
+/* Usage Management */
+extern struct nl_addr * nl_addr_get(struct nl_addr *);
+extern void nl_addr_put(struct nl_addr *);
+extern int nl_addr_shared(struct nl_addr *);
+
+extern int nl_addr_cmp(struct nl_addr *, struct nl_addr *);
+extern int nl_addr_cmp_prefix(struct nl_addr *, struct nl_addr *);
+extern int nl_addr_iszero(struct nl_addr *);
+extern int nl_addr_valid(char *, int);
+extern int nl_addr_guess_family(struct nl_addr *);
+extern int nl_addr_fill_sockaddr(struct nl_addr *,
+ struct sockaddr *, socklen_t *);
+extern int nl_addr_info(struct nl_addr *, struct addrinfo **);
+extern int nl_addr_resolve(struct nl_addr *addr, char *host, size_t hostlen);
+
+/* Access Functions */
+extern void nl_addr_set_family(struct nl_addr *, int);
+extern int nl_addr_get_family(struct nl_addr *);
+extern int nl_addr_set_binary_addr(struct nl_addr *, void *,
+ size_t);
+extern void * nl_addr_get_binary_addr(struct nl_addr *);
+extern unsigned int nl_addr_get_len(struct nl_addr *);
+extern void nl_addr_set_prefixlen(struct nl_addr *, int);
+extern unsigned int nl_addr_get_prefixlen(struct nl_addr *);
+
+/* Address Family Translations */
+extern char * nl_af2str(int, char *, size_t);
+extern int nl_str2af(const char *);
+
+/* Translations to Strings */
+extern char * nl_addr2str(struct nl_addr *, char *, size_t);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/package/libs/libnl-tiny/src/include/netlink/attr.h b/package/libs/libnl-tiny/src/include/netlink/attr.h
new file mode 100644
index 0000000..3b56a82
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/netlink/attr.h
@@ -0,0 +1,726 @@
+/*
+ * netlink/attr.h Netlink Attributes
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
+ */
+
+#ifndef NETLINK_ATTR_H_
+#define NETLINK_ATTR_H_
+
+#include <netlink/netlink.h>
+#include <netlink/object.h>
+#include <netlink/addr.h>
+#include <netlink/data.h>
+#include <netlink/msg.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct nl_msg;
+
+/**
+ * @name Basic Attribute Data Types
+ * @{
+ */
+
+ /**
+ * @ingroup attr
+ * Basic attribute data types
+ *
+ * See \ref attr_datatypes for more details.
+ */
+enum {
+ NLA_UNSPEC, /**< Unspecified type, binary data chunk */
+ NLA_U8, /**< 8 bit integer */
+ NLA_U16, /**< 16 bit integer */
+ NLA_U32, /**< 32 bit integer */
+ NLA_U64, /**< 64 bit integer */
+ NLA_STRING, /**< NUL terminated character string */
+ NLA_FLAG, /**< Flag */
+ NLA_MSECS, /**< Micro seconds (64bit) */
+ NLA_NESTED, /**< Nested attributes */
+ __NLA_TYPE_MAX,
+};
+
+#define NLA_TYPE_MAX (__NLA_TYPE_MAX - 1)
+
+/** @} */
+
+/**
+ * @ingroup attr
+ * Attribute validation policy.
+ *
+ * See \ref attr_datatypes for more details.
+ */
+struct nla_policy {
+ /** Type of attribute or NLA_UNSPEC */
+ uint16_t type;
+
+ /** Minimal length of payload required */
+ uint16_t minlen;
+
+ /** Maximal length of payload allowed */
+ uint16_t maxlen;
+};
+
+/* Attribute parsing */
+extern int nla_ok(const struct nlattr *, int);
+extern struct nlattr * nla_next(const struct nlattr *, int *);
+extern int nla_parse(struct nlattr **, int, struct nlattr *,
+ int, struct nla_policy *);
+extern int nla_validate(struct nlattr *, int, int,
+ struct nla_policy *);
+extern struct nlattr * nla_find(struct nlattr *, int, int);
+
+/* Unspecific attribute */
+extern struct nlattr * nla_reserve(struct nl_msg *, int, int);
+extern int nla_put(struct nl_msg *, int, int, const void *);
+
+/**
+ * nlmsg_find_attr - find a specific attribute in a netlink message
+ * @arg nlh netlink message header
+ * @arg hdrlen length of familiy specific header
+ * @arg attrtype type of attribute to look for
+ *
+ * Returns the first attribute which matches the specified type.
+ */
+static inline struct nlattr *nlmsg_find_attr(struct nlmsghdr *nlh, int hdrlen, int attrtype)
+{
+ return nla_find(nlmsg_attrdata(nlh, hdrlen),
+ nlmsg_attrlen(nlh, hdrlen), attrtype);
+}
+
+
+/**
+ * Return size of attribute whithout padding.
+ * @arg payload Payload length of attribute.
+ *
+ * @code
+ * <-------- nla_attr_size(payload) --------->
+ * +------------------+- - -+- - - - - - - - - +- - -+
+ * | Attribute Header | Pad | Payload | Pad |
+ * +------------------+- - -+- - - - - - - - - +- - -+
+ * @endcode
+ *
+ * @return Size of attribute in bytes without padding.
+ */
+static inline int nla_attr_size(int payload)
+{
+ return NLA_HDRLEN + payload;
+}
+
+/**
+ * Return size of attribute including padding.
+ * @arg payload Payload length of attribute.
+ *
+ * @code
+ * <----------- nla_total_size(payload) ----------->
+ * +------------------+- - -+- - - - - - - - - +- - -+
+ * | Attribute Header | Pad | Payload | Pad |
+ * +------------------+- - -+- - - - - - - - - +- - -+
+ * @endcode
+ *
+ * @return Size of attribute in bytes.
+ */
+static inline int nla_total_size(int payload)
+{
+ return NLA_ALIGN(nla_attr_size(payload));
+}
+
+/**
+ * Return length of padding at the tail of the attribute.
+ * @arg payload Payload length of attribute.
+ *
+ * @code
+ * +------------------+- - -+- - - - - - - - - +- - -+
+ * | Attribute Header | Pad | Payload | Pad |
+ * +------------------+- - -+- - - - - - - - - +- - -+
+ * <--->
+ * @endcode
+ *
+ * @return Length of padding in bytes.
+ */
+static inline int nla_padlen(int payload)
+{
+ return nla_total_size(payload) - nla_attr_size(payload);
+}
+
+/**
+ * Return type of the attribute.
+ * @arg nla Attribute.
+ *
+ * @return Type of attribute.
+ */
+static inline int nla_type(const struct nlattr *nla)
+{
+ return nla->nla_type & NLA_TYPE_MASK;
+}
+
+/**
+ * Return pointer to the payload section.
+ * @arg nla Attribute.
+ *
+ * @return Pointer to start of payload section.
+ */
+static inline void *nla_data(const struct nlattr *nla)
+{
+ return (char *) nla + NLA_HDRLEN;
+}
+
+/**
+ * Return length of the payload .
+ * @arg nla Attribute
+ *
+ * @return Length of payload in bytes.
+ */
+static inline int nla_len(const struct nlattr *nla)
+{
+ return nla->nla_len - NLA_HDRLEN;
+}
+
+/**
+ * Copy attribute payload to another memory area.
+ * @arg dest Pointer to destination memory area.
+ * @arg src Attribute
+ * @arg count Number of bytes to copy at most.
+ *
+ * Note: The number of bytes copied is limited by the length of
+ * the attribute payload.
+ *
+ * @return The number of bytes copied to dest.
+ */
+static inline int nla_memcpy(void *dest, struct nlattr *src, int count)
+{
+ int minlen;
+
+ if (!src)
+ return 0;
+
+ minlen = min_t(int, count, nla_len(src));
+ memcpy(dest, nla_data(src), minlen);
+
+ return minlen;
+}
+
+
+/**
+ * Add abstract data as unspecific attribute to netlink message.
+ * @arg msg Netlink message.
+ * @arg attrtype Attribute type.
+ * @arg data Abstract data object.
+ *
+ * Equivalent to nla_put() except that the length of the payload is
+ * derived from the abstract data object.
+ *
+ * @see nla_put
+ * @return 0 on success or a negative error code.
+ */
+static inline int nla_put_data(struct nl_msg *msg, int attrtype, struct nl_data *data)
+{
+ return nla_put(msg, attrtype, nl_data_get_size(data),
+ nl_data_get(data));
+}
+
+/**
+ * Add abstract address as unspecific attribute to netlink message.
+ * @arg msg Netlink message.
+ * @arg attrtype Attribute type.
+ * @arg addr Abstract address object.
+ *
+ * @see nla_put
+ * @return 0 on success or a negative error code.
+ */
+static inline int nla_put_addr(struct nl_msg *msg, int attrtype, struct nl_addr *addr)
+{
+ return nla_put(msg, attrtype, nl_addr_get_len(addr),
+ nl_addr_get_binary_addr(addr));
+}
+
+/** @} */
+
+/**
+ * @name Integer Attributes
+ */
+
+/**
+ * Add 8 bit integer attribute to netlink message.
+ * @arg msg Netlink message.
+ * @arg attrtype Attribute type.
+ * @arg value Numeric value to store as payload.
+ *
+ * @see nla_put
+ * @return 0 on success or a negative error code.
+ */
+static inline int nla_put_u8(struct nl_msg *msg, int attrtype, uint8_t value)
+{
+ return nla_put(msg, attrtype, sizeof(uint8_t), &value);
+}
+
+/**
+ * Return value of 8 bit integer attribute.
+ * @arg nla 8 bit integer attribute
+ *
+ * @return Payload as 8 bit integer.
+ */
+static inline uint8_t nla_get_u8(struct nlattr *nla)
+{
+ return *(uint8_t *) nla_data(nla);
+}
+
+/**
+ * Add 16 bit integer attribute to netlink message.
+ * @arg msg Netlink message.
+ * @arg attrtype Attribute type.
+ * @arg value Numeric value to store as payload.
+ *
+ * @see nla_put
+ * @return 0 on success or a negative error code.
+ */
+static inline int nla_put_u16(struct nl_msg *msg, int attrtype, uint16_t value)
+{
+ return nla_put(msg, attrtype, sizeof(uint16_t), &value);
+}
+
+/**
+ * Return payload of 16 bit integer attribute.
+ * @arg nla 16 bit integer attribute
+ *
+ * @return Payload as 16 bit integer.
+ */
+static inline uint16_t nla_get_u16(struct nlattr *nla)
+{
+ return *(uint16_t *) nla_data(nla);
+}
+
+/**
+ * Add 32 bit integer attribute to netlink message.
+ * @arg msg Netlink message.
+ * @arg attrtype Attribute type.
+ * @arg value Numeric value to store as payload.
+ *
+ * @see nla_put
+ * @return 0 on success or a negative error code.
+ */
+static inline int nla_put_u32(struct nl_msg *msg, int attrtype, uint32_t value)
+{
+ return nla_put(msg, attrtype, sizeof(uint32_t), &value);
+}
+
+/**
+ * Return payload of 32 bit integer attribute.
+ * @arg nla 32 bit integer attribute.
+ *
+ * @return Payload as 32 bit integer.
+ */
+static inline uint32_t nla_get_u32(struct nlattr *nla)
+{
+ return *(uint32_t *) nla_data(nla);
+}
+
+/**
+ * Add 64 bit integer attribute to netlink message.
+ * @arg msg Netlink message.
+ * @arg attrtype Attribute type.
+ * @arg value Numeric value to store as payload.
+ *
+ * @see nla_put
+ * @return 0 on success or a negative error code.
+ */
+static inline int nla_put_u64(struct nl_msg *msg, int attrtype, uint64_t value)
+{
+ return nla_put(msg, attrtype, sizeof(uint64_t), &value);
+}
+
+/**
+ * Return payload of u64 attribute
+ * @arg nla u64 netlink attribute
+ *
+ * @return Payload as 64 bit integer.
+ */
+static inline uint64_t nla_get_u64(struct nlattr *nla)
+{
+ uint64_t tmp;
+
+ nla_memcpy(&tmp, nla, sizeof(tmp));
+
+ return tmp;
+}
+
+/**
+ * Add string attribute to netlink message.
+ * @arg msg Netlink message.
+ * @arg attrtype Attribute type.
+ * @arg str NUL terminated string.
+ *
+ * @see nla_put
+ * @return 0 on success or a negative error code.
+ */
+static inline int nla_put_string(struct nl_msg *msg, int attrtype, const char *str)
+{
+ return nla_put(msg, attrtype, strlen(str) + 1, str);
+}
+
+/**
+ * Return payload of string attribute.
+ * @arg nla String attribute.
+ *
+ * @return Pointer to attribute payload.
+ */
+static inline char *nla_get_string(struct nlattr *nla)
+{
+ return (char *) nla_data(nla);
+}
+
+static inline char *nla_strdup(struct nlattr *nla)
+{
+ return strdup(nla_get_string(nla));
+}
+
+/** @} */
+
+/**
+ * @name Flag Attribute
+ */
+
+/**
+ * Add flag netlink attribute to netlink message.
+ * @arg msg Netlink message.
+ * @arg attrtype Attribute type.
+ *
+ * @see nla_put
+ * @return 0 on success or a negative error code.
+ */
+static inline int nla_put_flag(struct nl_msg *msg, int attrtype)
+{
+ return nla_put(msg, attrtype, 0, NULL);
+}
+
+/**
+ * Return true if flag attribute is set.
+ * @arg nla Flag netlink attribute.
+ *
+ * @return True if flag is set, otherwise false.
+ */
+static inline int nla_get_flag(struct nlattr *nla)
+{
+ return !!nla;
+}
+
+/** @} */
+
+/**
+ * @name Microseconds Attribute
+ */
+
+/**
+ * Add a msecs netlink attribute to a netlink message
+ * @arg n netlink message
+ * @arg attrtype attribute type
+ * @arg msecs number of msecs
+ */
+static inline int nla_put_msecs(struct nl_msg *n, int attrtype, unsigned long msecs)
+{
+ return nla_put_u64(n, attrtype, msecs);
+}
+
+/**
+ * Return payload of msecs attribute
+ * @arg nla msecs netlink attribute
+ *
+ * @return the number of milliseconds.
+ */
+static inline unsigned long nla_get_msecs(struct nlattr *nla)
+{
+ return nla_get_u64(nla);
+}
+
+/**
+ * Add nested attributes to netlink message.
+ * @arg msg Netlink message.
+ * @arg attrtype Attribute type.
+ * @arg nested Message containing attributes to be nested.
+ *
+ * Takes the attributes found in the \a nested message and appends them
+ * to the message \a msg nested in a container of the type \a attrtype.
+ * The \a nested message may not have a family specific header.
+ *
+ * @see nla_put
+ * @return 0 on success or a negative error code.
+ */
+static inline int nla_put_nested(struct nl_msg *msg, int attrtype, struct nl_msg *nested)
+{
+ return nla_put(msg, attrtype, nlmsg_len(nested->nm_nlh),
+ nlmsg_data(nested->nm_nlh));
+}
+
+/**
+ * Start a new level of nested attributes.
+ * @arg msg Netlink message.
+ * @arg attrtype Attribute type of container.
+ *
+ * @return Pointer to container attribute.
+ */
+static inline struct nlattr *nla_nest_start(struct nl_msg *msg, int attrtype)
+{
+ struct nlattr *start = (struct nlattr *) nlmsg_tail(msg->nm_nlh);
+
+ if (nla_put(msg, attrtype, 0, NULL) < 0)
+ return NULL;
+
+ return start;
+}
+
+/**
+ * Finalize nesting of attributes.
+ * @arg msg Netlink message.
+ * @arg start Container attribute as returned from nla_nest_start().
+ *
+ * Corrects the container attribute header to include the appeneded attributes.
+ *
+ * @return 0
+ */
+static inline int nla_nest_end(struct nl_msg *msg, struct nlattr *start)
+{
+ start->nla_len = (unsigned char *) nlmsg_tail(msg->nm_nlh) -
+ (unsigned char *) start;
+ return 0;
+}
+
+/**
+ * Create attribute index based on nested attribute
+ * @arg tb Index array to be filled (maxtype+1 elements).
+ * @arg maxtype Maximum attribute type expected and accepted.
+ * @arg nla Nested Attribute.
+ * @arg policy Attribute validation policy.
+ *
+ * Feeds the stream of attributes nested into the specified attribute
+ * to nla_parse().
+ *
+ * @see nla_parse
+ * @return 0 on success or a negative error code.
+ */
+static inline int nla_parse_nested(struct nlattr *tb[], int maxtype, struct nlattr *nla,
+ struct nla_policy *policy)
+{
+ return nla_parse(tb, maxtype, (struct nlattr *)nla_data(nla), nla_len(nla), policy);
+}
+
+/**
+ * Compare attribute payload with memory area.
+ * @arg nla Attribute.
+ * @arg data Memory area to compare to.
+ * @arg size Number of bytes to compare.
+ *
+ * @see memcmp(3)
+ * @return An integer less than, equal to, or greater than zero.
+ */
+static inline int nla_memcmp(const struct nlattr *nla, const void *data, size_t size)
+{
+ int d = nla_len(nla) - size;
+
+ if (d == 0)
+ d = memcmp(nla_data(nla), data, size);
+
+ return d;
+}
+
+/**
+ * Compare string attribute payload with string
+ * @arg nla Attribute of type NLA_STRING.
+ * @arg str NUL terminated string.
+ *
+ * @see strcmp(3)
+ * @return An integer less than, equal to, or greater than zero.
+ */
+static inline int nla_strcmp(const struct nlattr *nla, const char *str)
+{
+ int len = strlen(str) + 1;
+ int d = nla_len(nla) - len;
+
+ if (d == 0)
+ d = memcmp(nla_data(nla), str, len);
+
+ return d;
+}
+
+/**
+ * Copy string attribute payload to a buffer.
+ * @arg dst Pointer to destination buffer.
+ * @arg nla Attribute of type NLA_STRING.
+ * @arg dstsize Size of destination buffer in bytes.
+ *
+ * Copies at most dstsize - 1 bytes to the destination buffer.
+ * The result is always a valid NUL terminated string. Unlike
+ * strlcpy the destination buffer is always padded out.
+ *
+ * @return The length of string attribute without the terminating NUL.
+ */
+static inline size_t nla_strlcpy(char *dst, const struct nlattr *nla, size_t dstsize)
+{
+ size_t srclen = (size_t)nla_len(nla);
+ char *src = (char*)nla_data(nla);
+
+ if (srclen > 0 && src[srclen - 1] == '\0')
+ srclen--;
+
+ if (dstsize > 0) {
+ size_t len = (srclen >= dstsize) ? dstsize - 1 : srclen;
+
+ memset(dst, 0, dstsize);
+ memcpy(dst, src, len);
+ }
+
+ return srclen;
+}
+
+
+/**
+ * @name Attribute Construction (Exception Based)
+ * @{
+ */
+
+/**
+ * @ingroup attr
+ * Add unspecific attribute to netlink message.
+ * @arg msg Netlink message.
+ * @arg attrtype Attribute type.
+ * @arg attrlen Length of attribute payload.
+ * @arg data Head of attribute payload.
+ */
+#define NLA_PUT(msg, attrtype, attrlen, data) \
+ do { \
+ if (nla_put(msg, attrtype, attrlen, data) < 0) \
+ goto nla_put_failure; \
+ } while(0)
+
+/**
+ * @ingroup attr
+ * Add atomic type attribute to netlink message.
+ * @arg msg Netlink message.
+ * @arg type Atomic type.
+ * @arg attrtype Attribute type.
+ * @arg value Head of attribute payload.
+ */
+#define NLA_PUT_TYPE(msg, type, attrtype, value) \
+ do { \
+ type __tmp = value; \
+ NLA_PUT(msg, attrtype, sizeof(type), &__tmp); \
+ } while(0)
+
+/**
+ * Add 8 bit integer attribute to netlink message.
+ * @arg msg Netlink message.
+ * @arg attrtype Attribute type.
+ * @arg value Numeric value.
+ */
+#define NLA_PUT_U8(msg, attrtype, value) \
+ NLA_PUT_TYPE(msg, uint8_t, attrtype, value)
+
+/**
+ * Add 16 bit integer attribute to netlink message.
+ * @arg msg Netlink message.
+ * @arg attrtype Attribute type.
+ * @arg value Numeric value.
+ */
+#define NLA_PUT_U16(msg, attrtype, value) \
+ NLA_PUT_TYPE(msg, uint16_t, attrtype, value)
+
+/**
+ * Add 32 bit integer attribute to netlink message.
+ * @arg msg Netlink message.
+ * @arg attrtype Attribute type.
+ * @arg value Numeric value.
+ */
+#define NLA_PUT_U32(msg, attrtype, value) \
+ NLA_PUT_TYPE(msg, uint32_t, attrtype, value)
+
+/**
+ * Add 64 bit integer attribute to netlink message.
+ * @arg msg Netlink message.
+ * @arg attrtype Attribute type.
+ * @arg value Numeric value.
+ */
+#define NLA_PUT_U64(msg, attrtype, value) \
+ NLA_PUT_TYPE(msg, uint64_t, attrtype, value)
+
+/**
+ * Add string attribute to netlink message.
+ * @arg msg Netlink message.
+ * @arg attrtype Attribute type.
+ * @arg value NUL terminated character string.
+ */
+#define NLA_PUT_STRING(msg, attrtype, value) \
+ NLA_PUT(msg, attrtype, strlen(value) + 1, value)
+
+/**
+ * Add flag attribute to netlink message.
+ * @arg msg Netlink message.
+ * @arg attrtype Attribute type.
+ */
+#define NLA_PUT_FLAG(msg, attrtype) \
+ NLA_PUT(msg, attrtype, 0, NULL)
+
+/**
+ * Add msecs attribute to netlink message.
+ * @arg msg Netlink message.
+ * @arg attrtype Attribute type.
+ * @arg msecs Numeric value in micro seconds.
+ */
+#define NLA_PUT_MSECS(msg, attrtype, msecs) \
+ NLA_PUT_U64(msg, attrtype, msecs)
+
+/**
+ * Add address attribute to netlink message.
+ * @arg msg Netlink message.
+ * @arg attrtype Attribute type.
+ * @arg addr Abstract address object.
+ */
+#define NLA_PUT_ADDR(msg, attrtype, addr) \
+ NLA_PUT(msg, attrtype, nl_addr_get_len(addr), \
+ nl_addr_get_binary_addr(addr))
+
+/** @} */
+
+/**
+ * @name Iterators
+ * @{
+ */
+
+/**
+ * @ingroup attr
+ * Iterate over a stream of attributes
+ * @arg pos loop counter, set to current attribute
+ * @arg head head of attribute stream
+ * @arg len length of attribute stream
+ * @arg rem initialized to len, holds bytes currently remaining in stream
+ */
+#define nla_for_each_attr(pos, head, len, rem) \
+ for (pos = head, rem = len; \
+ nla_ok(pos, rem); \
+ pos = nla_next(pos, &(rem)))
+
+/**
+ * @ingroup attr
+ * Iterate over a stream of nested attributes
+ * @arg pos loop counter, set to current attribute
+ * @arg nla attribute containing the nested attributes
+ * @arg rem initialized to len, holds bytes currently remaining in stream
+ */
+#define nla_for_each_nested(pos, nla, rem) \
+ for (pos = (struct nlattr *)nla_data(nla), rem = nla_len(nla); \
+ nla_ok(pos, rem); \
+ pos = nla_next(pos, &(rem)))
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/package/libs/libnl-tiny/src/include/netlink/cache-api.h b/package/libs/libnl-tiny/src/include/netlink/cache-api.h
new file mode 100644
index 0000000..22fc449
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/netlink/cache-api.h
@@ -0,0 +1,199 @@
+/*
+ * netlink/cache-api.h Caching API
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
+ */
+
+#ifndef NETLINK_CACHE_API_H_
+#define NETLINK_CACHE_API_H_
+
+#include <netlink/netlink.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @ingroup cache
+ * @defgroup cache_api Cache Implementation
+ * @brief
+ *
+ * @par 1) Cache Definition
+ * @code
+ * struct nl_cache_ops my_cache_ops = {
+ * .co_name = "route/link",
+ * .co_protocol = NETLINK_ROUTE,
+ * .co_hdrsize = sizeof(struct ifinfomsg),
+ * .co_obj_ops = &my_obj_ops,
+ * };
+ * @endcode
+ *
+ * @par 2)
+ * @code
+ * // The simplest way to fill a cache is by providing a request-update
+ * // function which must trigger a complete dump on the kernel-side of
+ * // whatever the cache covers.
+ * static int my_request_update(struct nl_cache *cache,
+ * struct nl_sock *socket)
+ * {
+ * // In this example, we request a full dump of the interface table
+ * return nl_rtgen_request(socket, RTM_GETLINK, AF_UNSPEC, NLM_F_DUMP);
+ * }
+ *
+ * // The resulting netlink messages sent back will be fed into a message
+ * // parser one at a time. The message parser has to extract all relevant
+ * // information from the message and create an object reflecting the
+ * // contents of the message and pass it on to the parser callback function
+ * // provide which will add the object to the cache.
+ * static int my_msg_parser(struct nl_cache_ops *ops, struct sockaddr_nl *who,
+ * struct nlmsghdr *nlh, struct nl_parser_param *pp)
+ * {
+ * struct my_obj *obj;
+ *
+ * obj = my_obj_alloc();
+ * obj->ce_msgtype = nlh->nlmsg_type;
+ *
+ * // Parse the netlink message and continue creating the object.
+ *
+ * err = pp->pp_cb((struct nl_object *) obj, pp);
+ * if (err < 0)
+ * goto errout;
+ * }
+ *
+ * struct nl_cache_ops my_cache_ops = {
+ * ...
+ * .co_request_update = my_request_update,
+ * .co_msg_parser = my_msg_parser,
+ * };
+ * @endcode
+ *
+ * @par 3) Notification based Updates
+ * @code
+ * // Caches can be kept up-to-date based on notifications if the kernel
+ * // sends out notifications whenever an object is added/removed/changed.
+ * //
+ * // It is trivial to support this, first a list of groups needs to be
+ * // defined which are required to join in order to receive all necessary
+ * // notifications. The groups are separated by address family to support
+ * // the common situation where a separate group is used for each address
+ * // family. If there is only one group, simply specify AF_UNSPEC.
+ * static struct nl_af_group addr_groups[] = {
+ * { AF_INET, RTNLGRP_IPV4_IFADDR },
+ * { AF_INET6, RTNLGRP_IPV6_IFADDR },
+ * { END_OF_GROUP_LIST },
+ * };
+ *
+ * // In order for the caching system to know the meaning of each message
+ * // type it requires a table which maps each supported message type to
+ * // a cache action, e.g. RTM_NEWADDR means address has been added or
+ * // updated, RTM_DELADDR means address has been removed.
+ * static struct nl_cache_ops rtnl_addr_ops = {
+ * ...
+ * .co_msgtypes = {
+ * { RTM_NEWADDR, NL_ACT_NEW, "new" },
+ * { RTM_DELADDR, NL_ACT_DEL, "del" },
+ * { RTM_GETADDR, NL_ACT_GET, "get" },
+ * END_OF_MSGTYPES_LIST,
+ * },
+ * .co_groups = addr_groups,
+ * };
+ *
+ * // It is now possible to keep the cache up-to-date using the cache manager.
+ * @endcode
+ * @{
+ */
+
+enum {
+ NL_ACT_UNSPEC,
+ NL_ACT_NEW,
+ NL_ACT_DEL,
+ NL_ACT_GET,
+ NL_ACT_SET,
+ NL_ACT_CHANGE,
+ __NL_ACT_MAX,
+};
+
+#define NL_ACT_MAX (__NL_ACT_MAX - 1)
+
+#define END_OF_MSGTYPES_LIST { -1, -1, NULL }
+
+/**
+ * Message type to cache action association
+ */
+struct nl_msgtype
+{
+ /** Netlink message type */
+ int mt_id;
+
+ /** Cache action to take */
+ int mt_act;
+
+ /** Name of operation for human-readable printing */
+ char * mt_name;
+};
+
+/**
+ * Address family to netlink group association
+ */
+struct nl_af_group
+{
+ /** Address family */
+ int ag_family;
+
+ /** Netlink group identifier */
+ int ag_group;
+};
+
+#define END_OF_GROUP_LIST AF_UNSPEC, 0
+
+struct nl_parser_param
+{
+ int (*pp_cb)(struct nl_object *, struct nl_parser_param *);
+ void * pp_arg;
+};
+
+/**
+ * Cache Operations
+ */
+struct nl_cache_ops
+{
+ char * co_name;
+
+ int co_hdrsize;
+ int co_protocol;
+ struct nl_af_group * co_groups;
+
+ /**
+ * Called whenever an update of the cache is required. Must send
+ * a request message to the kernel requesting a complete dump.
+ */
+ int (*co_request_update)(struct nl_cache *, struct nl_sock *);
+
+ /**
+ * Called whenever a message was received that needs to be parsed.
+ * Must parse the message and call the paser callback function
+ * (nl_parser_param) provided via the argument.
+ */
+ int (*co_msg_parser)(struct nl_cache_ops *, struct sockaddr_nl *,
+ struct nlmsghdr *, struct nl_parser_param *);
+
+ struct nl_object_ops * co_obj_ops;
+
+ struct nl_cache_ops *co_next;
+ struct nl_cache *co_major_cache;
+ struct genl_ops * co_genl;
+ struct nl_msgtype co_msgtypes[];
+};
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/package/libs/libnl-tiny/src/include/netlink/cache.h b/package/libs/libnl-tiny/src/include/netlink/cache.h
new file mode 100644
index 0000000..09719f3
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/netlink/cache.h
@@ -0,0 +1,128 @@
+/*
+ * netlink/cache.h Caching Module
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
+ */
+
+#ifndef NETLINK_CACHE_H_
+#define NETLINK_CACHE_H_
+
+#include <netlink/netlink.h>
+#include <netlink/msg.h>
+#include <netlink/utils.h>
+#include <netlink/object.h>
+#include <netlink/cache-api.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct nl_cache;
+
+typedef void (*change_func_t)(struct nl_cache *, struct nl_object *, int);
+
+/* Access Functions */
+extern int nl_cache_nitems(struct nl_cache *);
+extern int nl_cache_nitems_filter(struct nl_cache *,
+ struct nl_object *);
+extern struct nl_cache_ops * nl_cache_get_ops(struct nl_cache *);
+extern struct nl_object * nl_cache_get_first(struct nl_cache *);
+extern struct nl_object * nl_cache_get_last(struct nl_cache *);
+extern struct nl_object * nl_cache_get_next(struct nl_object *);
+extern struct nl_object * nl_cache_get_prev(struct nl_object *);
+
+extern struct nl_cache * nl_cache_alloc(struct nl_cache_ops *);
+extern int nl_cache_alloc_and_fill(struct nl_cache_ops *,
+ struct nl_sock *,
+ struct nl_cache **);
+extern int nl_cache_alloc_name(const char *,
+ struct nl_cache **);
+extern struct nl_cache * nl_cache_subset(struct nl_cache *,
+ struct nl_object *);
+extern void nl_cache_clear(struct nl_cache *);
+extern void nl_cache_free(struct nl_cache *);
+
+/* Cache modification */
+extern int nl_cache_add(struct nl_cache *,
+ struct nl_object *);
+extern int nl_cache_parse_and_add(struct nl_cache *,
+ struct nl_msg *);
+extern void nl_cache_remove(struct nl_object *);
+extern int nl_cache_refill(struct nl_sock *,
+ struct nl_cache *);
+extern int nl_cache_pickup(struct nl_sock *,
+ struct nl_cache *);
+extern int nl_cache_resync(struct nl_sock *,
+ struct nl_cache *,
+ change_func_t);
+extern int nl_cache_include(struct nl_cache *,
+ struct nl_object *,
+ change_func_t);
+
+/* General */
+extern int nl_cache_is_empty(struct nl_cache *);
+extern void nl_cache_mark_all(struct nl_cache *);
+
+/* Dumping */
+extern void nl_cache_dump(struct nl_cache *,
+ struct nl_dump_params *);
+extern void nl_cache_dump_filter(struct nl_cache *,
+ struct nl_dump_params *,
+ struct nl_object *);
+
+/* Iterators */
+#ifdef disabled
+extern void nl_cache_foreach(struct nl_cache *,
+ void (*cb)(struct nl_object *,
+ void *),
+ void *arg);
+extern void nl_cache_foreach_filter(struct nl_cache *,
+ struct nl_object *,
+ void (*cb)(struct
+ nl_object *,
+ void *),
+ void *arg);
+#endif
+
+/* --- cache management --- */
+
+/* Cache type management */
+extern struct nl_cache_ops * nl_cache_ops_lookup(const char *);
+extern struct nl_cache_ops * nl_cache_ops_associate(int, int);
+extern struct nl_msgtype * nl_msgtype_lookup(struct nl_cache_ops *, int);
+extern void nl_cache_ops_foreach(void (*cb)(struct nl_cache_ops *, void *), void *);
+extern int nl_cache_mngt_register(struct nl_cache_ops *);
+extern int nl_cache_mngt_unregister(struct nl_cache_ops *);
+
+/* Global cache provisioning/requiring */
+extern void nl_cache_mngt_provide(struct nl_cache *);
+extern void nl_cache_mngt_unprovide(struct nl_cache *);
+extern struct nl_cache * nl_cache_mngt_require(const char *);
+
+struct nl_cache_mngr;
+
+#define NL_AUTO_PROVIDE 1
+
+extern int nl_cache_mngr_alloc(struct nl_sock *,
+ int, int,
+ struct nl_cache_mngr **);
+extern int nl_cache_mngr_add(struct nl_cache_mngr *,
+ const char *,
+ change_func_t,
+ struct nl_cache **);
+extern int nl_cache_mngr_get_fd(struct nl_cache_mngr *);
+extern int nl_cache_mngr_poll(struct nl_cache_mngr *,
+ int);
+extern int nl_cache_mngr_data_ready(struct nl_cache_mngr *);
+extern void nl_cache_mngr_free(struct nl_cache_mngr *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/package/libs/libnl-tiny/src/include/netlink/data.h b/package/libs/libnl-tiny/src/include/netlink/data.h
new file mode 100644
index 0000000..071159e
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/netlink/data.h
@@ -0,0 +1,41 @@
+/*
+ * netlink/data.h Abstract Data
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
+ */
+
+#ifndef NETLINK_DATA_H_
+#define NETLINK_DATA_H_
+
+#include <netlink/netlink.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct nl_data;
+
+/* General */
+extern struct nl_data * nl_data_alloc(void *, size_t);
+extern struct nl_data * nl_data_alloc_attr(struct nlattr *);
+extern struct nl_data * nl_data_clone(struct nl_data *);
+extern int nl_data_append(struct nl_data *, void *, size_t);
+extern void nl_data_free(struct nl_data *);
+
+/* Access Functions */
+extern void * nl_data_get(struct nl_data *);
+extern size_t nl_data_get_size(struct nl_data *);
+
+/* Misc */
+extern int nl_data_cmp(struct nl_data *, struct nl_data *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/package/libs/libnl-tiny/src/include/netlink/errno.h b/package/libs/libnl-tiny/src/include/netlink/errno.h
new file mode 100644
index 0000000..0b43da0
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/netlink/errno.h
@@ -0,0 +1,59 @@
+/*
+ * netlink/errno.h Error Numbers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2008 Thomas Graf <tgraf@suug.ch>
+ */
+
+#ifndef NETLINK_ERRNO_H_
+#define NETLINK_ERRNO_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define NLE_SUCCESS 0
+#define NLE_FAILURE 1
+#define NLE_INTR 2
+#define NLE_BAD_SOCK 3
+#define NLE_AGAIN 4
+#define NLE_NOMEM 5
+#define NLE_EXIST 6
+#define NLE_INVAL 7
+#define NLE_RANGE 8
+#define NLE_MSGSIZE 9
+#define NLE_OPNOTSUPP 10
+#define NLE_AF_NOSUPPORT 11
+#define NLE_OBJ_NOTFOUND 12
+#define NLE_NOATTR 13
+#define NLE_MISSING_ATTR 14
+#define NLE_AF_MISMATCH 15
+#define NLE_SEQ_MISMATCH 16
+#define NLE_MSG_OVERFLOW 17
+#define NLE_MSG_TRUNC 18
+#define NLE_NOADDR 19
+#define NLE_SRCRT_NOSUPPORT 20
+#define NLE_MSG_TOOSHORT 21
+#define NLE_MSGTYPE_NOSUPPORT 22
+#define NLE_OBJ_MISMATCH 23
+#define NLE_NOCACHE 24
+#define NLE_BUSY 25
+#define NLE_PROTO_MISMATCH 26
+#define NLE_NOACCESS 27
+#define NLE_PERM 28
+
+#define NLE_MAX NLE_PERM
+
+extern const char * nl_geterror(int);
+extern void nl_perror(int, const char *);
+extern int nl_syserr2nlerr(int);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/package/libs/libnl-tiny/src/include/netlink/genl/.svn/entries b/package/libs/libnl-tiny/src/include/netlink/genl/.svn/entries
new file mode 100644
index 0000000..c47b238
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/netlink/genl/.svn/entries
@@ -0,0 +1,164 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs/libnl-tiny/src/include/netlink/genl
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+family.h
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+563a48c0aca4bddc96eed546234f196f
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2826
+
+ctrl.h
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+e377d154c80d7a4f7a0ed35b08bda24c
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+897
+
+genl.h
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+cf1a75c97f6f8540792424c02c99e2c1
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1301
+
+mngt.h
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+98c340306f8fdffb155296c438c00937
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1659
+
diff --git a/package/libs/libnl-tiny/src/include/netlink/genl/.svn/text-base/ctrl.h.svn-base b/package/libs/libnl-tiny/src/include/netlink/genl/.svn/text-base/ctrl.h.svn-base
new file mode 100644
index 0000000..1ae62f4
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/netlink/genl/.svn/text-base/ctrl.h.svn-base
@@ -0,0 +1,37 @@
+/*
+ * netlink/genl/ctrl.h Generic Netlink Controller
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
+ */
+
+#ifndef NETLINK_GENL_CTRL_H_
+#define NETLINK_GENL_CTRL_H_
+
+#include <netlink/netlink.h>
+#include <netlink/cache.h>
+#include <netlink/addr.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct genl_family;
+
+extern int genl_ctrl_alloc_cache(struct nl_sock *,
+ struct nl_cache **);
+extern struct genl_family * genl_ctrl_search(struct nl_cache *, int);
+extern struct genl_family * genl_ctrl_search_by_name(struct nl_cache *,
+ const char *);
+extern int genl_ctrl_resolve(struct nl_sock *,
+ const char *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/package/libs/libnl-tiny/src/include/netlink/genl/.svn/text-base/family.h.svn-base b/package/libs/libnl-tiny/src/include/netlink/genl/.svn/text-base/family.h.svn-base
new file mode 100644
index 0000000..0257cbe2
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/netlink/genl/.svn/text-base/family.h.svn-base
@@ -0,0 +1,130 @@
+/*
+ * netlink/genl/family.h Generic Netlink Family
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
+ */
+
+#ifndef NETLINK_GENL_FAMILY_H_
+#define NETLINK_GENL_FAMILY_H_
+
+#include <netlink/netlink.h>
+#include <netlink/cache.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** @cond SKIP */
+#define FAMILY_ATTR_ID 0x01
+#define FAMILY_ATTR_NAME 0x02
+#define FAMILY_ATTR_VERSION 0x04
+#define FAMILY_ATTR_HDRSIZE 0x08
+#define FAMILY_ATTR_MAXATTR 0x10
+#define FAMILY_ATTR_OPS 0x20
+
+
+struct genl_family
+{
+ NLHDR_COMMON
+
+ uint16_t gf_id;
+ char gf_name[GENL_NAMSIZ];
+ uint32_t gf_version;
+ uint32_t gf_hdrsize;
+ uint32_t gf_maxattr;
+
+ struct nl_list_head gf_ops;
+};
+
+
+extern struct genl_family * genl_family_alloc(void);
+extern void genl_family_put(struct genl_family *);
+
+extern int genl_family_add_op(struct genl_family *,
+ int, int);
+
+/**
+ * @name Attributes
+ * @{
+ */
+
+static inline unsigned int genl_family_get_id(struct genl_family *family)
+{
+ if (family->ce_mask & FAMILY_ATTR_ID)
+ return family->gf_id;
+ else
+ return GENL_ID_GENERATE;
+}
+
+static inline void genl_family_set_id(struct genl_family *family, unsigned int id)
+{
+ family->gf_id = id;
+ family->ce_mask |= FAMILY_ATTR_ID;
+}
+
+static inline char *genl_family_get_name(struct genl_family *family)
+{
+ if (family->ce_mask & FAMILY_ATTR_NAME)
+ return family->gf_name;
+ else
+ return NULL;
+}
+
+static inline void genl_family_set_name(struct genl_family *family, const char *name)
+{
+ strncpy(family->gf_name, name, GENL_NAMSIZ-1);
+ family->ce_mask |= FAMILY_ATTR_NAME;
+}
+
+static inline uint8_t genl_family_get_version(struct genl_family *family)
+{
+ if (family->ce_mask & FAMILY_ATTR_VERSION)
+ return family->gf_version;
+ else
+ return 0;
+}
+
+static inline void genl_family_set_version(struct genl_family *family, uint8_t version)
+{
+ family->gf_version = version;
+ family->ce_mask |= FAMILY_ATTR_VERSION;
+}
+
+static inline uint32_t genl_family_get_hdrsize(struct genl_family *family)
+{
+ if (family->ce_mask & FAMILY_ATTR_HDRSIZE)
+ return family->gf_hdrsize;
+ else
+ return 0;
+}
+
+static inline void genl_family_set_hdrsize(struct genl_family *family, uint32_t hdrsize)
+{
+ family->gf_hdrsize = hdrsize;
+ family->ce_mask |= FAMILY_ATTR_HDRSIZE;
+}
+
+static inline uint32_t genl_family_get_maxattr(struct genl_family *family)
+{
+ if (family->ce_mask & FAMILY_ATTR_MAXATTR)
+ return family->gf_maxattr;
+ else
+ return family->gf_maxattr;
+}
+
+static inline void genl_family_set_maxattr(struct genl_family *family, uint32_t maxattr)
+{
+ family->gf_maxattr = maxattr;
+ family->ce_mask |= FAMILY_ATTR_MAXATTR;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/package/libs/libnl-tiny/src/include/netlink/genl/.svn/text-base/genl.h.svn-base b/package/libs/libnl-tiny/src/include/netlink/genl/.svn/text-base/genl.h.svn-base
new file mode 100644
index 0000000..3f3340c
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/netlink/genl/.svn/text-base/genl.h.svn-base
@@ -0,0 +1,47 @@
+/*
+ * netlink/genl/genl.h Generic Netlink
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
+ */
+
+#ifndef NETLINK_GENL_H_
+#define NETLINK_GENL_H_
+
+#include <netlink/netlink.h>
+#include <netlink/msg.h>
+#include <netlink/attr.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern int genl_connect(struct nl_sock *);
+
+extern int genl_send_simple(struct nl_sock *, int, int,
+ int, int);
+
+extern void * genlmsg_put(struct nl_msg *, uint32_t, uint32_t,
+ int, int, int, uint8_t, uint8_t);
+
+extern int genlmsg_valid_hdr(struct nlmsghdr *, int);
+extern int genlmsg_validate(struct nlmsghdr *, int, int,
+ struct nla_policy *);
+extern int genlmsg_parse(struct nlmsghdr *, int, struct nlattr **,
+ int, struct nla_policy *);
+extern void * genlmsg_data(const struct genlmsghdr *);
+extern int genlmsg_len(const struct genlmsghdr *);
+extern struct nlattr * genlmsg_attrdata(const struct genlmsghdr *, int);
+extern int genlmsg_attrlen(const struct genlmsghdr *, int);
+
+extern char * genl_op2name(int, int, char *, size_t);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/package/libs/libnl-tiny/src/include/netlink/genl/.svn/text-base/mngt.h.svn-base b/package/libs/libnl-tiny/src/include/netlink/genl/.svn/text-base/mngt.h.svn-base
new file mode 100644
index 0000000..8b0244f
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/netlink/genl/.svn/text-base/mngt.h.svn-base
@@ -0,0 +1,87 @@
+/*
+ * netlink/genl/mngt.h Generic Netlink Management
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
+ */
+
+#ifndef NETLINK_GENL_MNGT_H_
+#define NETLINK_GENL_MNGT_H_
+
+#include <netlink/netlink.h>
+#include <netlink/attr.h>
+#include <netlink/list.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct nl_cache_ops;
+
+struct genl_info
+{
+ struct sockaddr_nl * who;
+ struct nlmsghdr * nlh;
+ struct genlmsghdr * genlhdr;
+ void * userhdr;
+ struct nlattr ** attrs;
+};
+
+/**
+ * @ingroup genl_mngt
+ * Generic Netlink Command
+ */
+struct genl_cmd
+{
+ /** Unique command identifier */
+ int c_id;
+
+ /** Name/description of command */
+ char * c_name;
+
+ /**
+ * Maximum attribute identifier, must be provided if
+ * a message parser is available.
+ */
+ int c_maxattr;
+
+ int (*c_msg_parser)(struct nl_cache_ops *,
+ struct genl_cmd *,
+ struct genl_info *, void *);
+
+ /**
+ * Attribute validation policy (optional)
+ */
+ struct nla_policy * c_attr_policy;
+};
+
+/**
+ * @ingroup genl_mngt
+ * Generic Netlink Operations
+ */
+struct genl_ops
+{
+ int o_family;
+ int o_id;
+ char * o_name;
+ struct nl_cache_ops * o_cache_ops;
+ struct genl_cmd * o_cmds;
+ int o_ncmds;
+
+ /* linked list of all genl cache operations */
+ struct nl_list_head o_list;
+};
+
+
+extern int genl_register(struct nl_cache_ops *);
+extern void genl_unregister(struct nl_cache_ops *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/package/libs/libnl-tiny/src/include/netlink/genl/ctrl.h b/package/libs/libnl-tiny/src/include/netlink/genl/ctrl.h
new file mode 100644
index 0000000..1ae62f4
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/netlink/genl/ctrl.h
@@ -0,0 +1,37 @@
+/*
+ * netlink/genl/ctrl.h Generic Netlink Controller
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
+ */
+
+#ifndef NETLINK_GENL_CTRL_H_
+#define NETLINK_GENL_CTRL_H_
+
+#include <netlink/netlink.h>
+#include <netlink/cache.h>
+#include <netlink/addr.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct genl_family;
+
+extern int genl_ctrl_alloc_cache(struct nl_sock *,
+ struct nl_cache **);
+extern struct genl_family * genl_ctrl_search(struct nl_cache *, int);
+extern struct genl_family * genl_ctrl_search_by_name(struct nl_cache *,
+ const char *);
+extern int genl_ctrl_resolve(struct nl_sock *,
+ const char *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/package/libs/libnl-tiny/src/include/netlink/genl/family.h b/package/libs/libnl-tiny/src/include/netlink/genl/family.h
new file mode 100644
index 0000000..0257cbe2
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/netlink/genl/family.h
@@ -0,0 +1,130 @@
+/*
+ * netlink/genl/family.h Generic Netlink Family
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
+ */
+
+#ifndef NETLINK_GENL_FAMILY_H_
+#define NETLINK_GENL_FAMILY_H_
+
+#include <netlink/netlink.h>
+#include <netlink/cache.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** @cond SKIP */
+#define FAMILY_ATTR_ID 0x01
+#define FAMILY_ATTR_NAME 0x02
+#define FAMILY_ATTR_VERSION 0x04
+#define FAMILY_ATTR_HDRSIZE 0x08
+#define FAMILY_ATTR_MAXATTR 0x10
+#define FAMILY_ATTR_OPS 0x20
+
+
+struct genl_family
+{
+ NLHDR_COMMON
+
+ uint16_t gf_id;
+ char gf_name[GENL_NAMSIZ];
+ uint32_t gf_version;
+ uint32_t gf_hdrsize;
+ uint32_t gf_maxattr;
+
+ struct nl_list_head gf_ops;
+};
+
+
+extern struct genl_family * genl_family_alloc(void);
+extern void genl_family_put(struct genl_family *);
+
+extern int genl_family_add_op(struct genl_family *,
+ int, int);
+
+/**
+ * @name Attributes
+ * @{
+ */
+
+static inline unsigned int genl_family_get_id(struct genl_family *family)
+{
+ if (family->ce_mask & FAMILY_ATTR_ID)
+ return family->gf_id;
+ else
+ return GENL_ID_GENERATE;
+}
+
+static inline void genl_family_set_id(struct genl_family *family, unsigned int id)
+{
+ family->gf_id = id;
+ family->ce_mask |= FAMILY_ATTR_ID;
+}
+
+static inline char *genl_family_get_name(struct genl_family *family)
+{
+ if (family->ce_mask & FAMILY_ATTR_NAME)
+ return family->gf_name;
+ else
+ return NULL;
+}
+
+static inline void genl_family_set_name(struct genl_family *family, const char *name)
+{
+ strncpy(family->gf_name, name, GENL_NAMSIZ-1);
+ family->ce_mask |= FAMILY_ATTR_NAME;
+}
+
+static inline uint8_t genl_family_get_version(struct genl_family *family)
+{
+ if (family->ce_mask & FAMILY_ATTR_VERSION)
+ return family->gf_version;
+ else
+ return 0;
+}
+
+static inline void genl_family_set_version(struct genl_family *family, uint8_t version)
+{
+ family->gf_version = version;
+ family->ce_mask |= FAMILY_ATTR_VERSION;
+}
+
+static inline uint32_t genl_family_get_hdrsize(struct genl_family *family)
+{
+ if (family->ce_mask & FAMILY_ATTR_HDRSIZE)
+ return family->gf_hdrsize;
+ else
+ return 0;
+}
+
+static inline void genl_family_set_hdrsize(struct genl_family *family, uint32_t hdrsize)
+{
+ family->gf_hdrsize = hdrsize;
+ family->ce_mask |= FAMILY_ATTR_HDRSIZE;
+}
+
+static inline uint32_t genl_family_get_maxattr(struct genl_family *family)
+{
+ if (family->ce_mask & FAMILY_ATTR_MAXATTR)
+ return family->gf_maxattr;
+ else
+ return family->gf_maxattr;
+}
+
+static inline void genl_family_set_maxattr(struct genl_family *family, uint32_t maxattr)
+{
+ family->gf_maxattr = maxattr;
+ family->ce_mask |= FAMILY_ATTR_MAXATTR;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/package/libs/libnl-tiny/src/include/netlink/genl/genl.h b/package/libs/libnl-tiny/src/include/netlink/genl/genl.h
new file mode 100644
index 0000000..3f3340c
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/netlink/genl/genl.h
@@ -0,0 +1,47 @@
+/*
+ * netlink/genl/genl.h Generic Netlink
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
+ */
+
+#ifndef NETLINK_GENL_H_
+#define NETLINK_GENL_H_
+
+#include <netlink/netlink.h>
+#include <netlink/msg.h>
+#include <netlink/attr.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern int genl_connect(struct nl_sock *);
+
+extern int genl_send_simple(struct nl_sock *, int, int,
+ int, int);
+
+extern void * genlmsg_put(struct nl_msg *, uint32_t, uint32_t,
+ int, int, int, uint8_t, uint8_t);
+
+extern int genlmsg_valid_hdr(struct nlmsghdr *, int);
+extern int genlmsg_validate(struct nlmsghdr *, int, int,
+ struct nla_policy *);
+extern int genlmsg_parse(struct nlmsghdr *, int, struct nlattr **,
+ int, struct nla_policy *);
+extern void * genlmsg_data(const struct genlmsghdr *);
+extern int genlmsg_len(const struct genlmsghdr *);
+extern struct nlattr * genlmsg_attrdata(const struct genlmsghdr *, int);
+extern int genlmsg_attrlen(const struct genlmsghdr *, int);
+
+extern char * genl_op2name(int, int, char *, size_t);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/package/libs/libnl-tiny/src/include/netlink/genl/mngt.h b/package/libs/libnl-tiny/src/include/netlink/genl/mngt.h
new file mode 100644
index 0000000..8b0244f
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/netlink/genl/mngt.h
@@ -0,0 +1,87 @@
+/*
+ * netlink/genl/mngt.h Generic Netlink Management
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
+ */
+
+#ifndef NETLINK_GENL_MNGT_H_
+#define NETLINK_GENL_MNGT_H_
+
+#include <netlink/netlink.h>
+#include <netlink/attr.h>
+#include <netlink/list.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct nl_cache_ops;
+
+struct genl_info
+{
+ struct sockaddr_nl * who;
+ struct nlmsghdr * nlh;
+ struct genlmsghdr * genlhdr;
+ void * userhdr;
+ struct nlattr ** attrs;
+};
+
+/**
+ * @ingroup genl_mngt
+ * Generic Netlink Command
+ */
+struct genl_cmd
+{
+ /** Unique command identifier */
+ int c_id;
+
+ /** Name/description of command */
+ char * c_name;
+
+ /**
+ * Maximum attribute identifier, must be provided if
+ * a message parser is available.
+ */
+ int c_maxattr;
+
+ int (*c_msg_parser)(struct nl_cache_ops *,
+ struct genl_cmd *,
+ struct genl_info *, void *);
+
+ /**
+ * Attribute validation policy (optional)
+ */
+ struct nla_policy * c_attr_policy;
+};
+
+/**
+ * @ingroup genl_mngt
+ * Generic Netlink Operations
+ */
+struct genl_ops
+{
+ int o_family;
+ int o_id;
+ char * o_name;
+ struct nl_cache_ops * o_cache_ops;
+ struct genl_cmd * o_cmds;
+ int o_ncmds;
+
+ /* linked list of all genl cache operations */
+ struct nl_list_head o_list;
+};
+
+
+extern int genl_register(struct nl_cache_ops *);
+extern void genl_unregister(struct nl_cache_ops *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/package/libs/libnl-tiny/src/include/netlink/handlers.h b/package/libs/libnl-tiny/src/include/netlink/handlers.h
new file mode 100644
index 0000000..7fb53b4
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/netlink/handlers.h
@@ -0,0 +1,230 @@
+/*
+ * netlink/handlers.c default netlink message handlers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
+ */
+
+#ifndef NETLINK_HANDLERS_H_
+#define NETLINK_HANDLERS_H_
+
+#include <stdio.h>
+#include <stdint.h>
+#include <sys/types.h>
+#include <netlink/netlink-compat.h>
+#include <netlink/netlink-kernel.h>
+#include <netlink/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct nl_sock;
+struct nl_msg;
+struct nl_cb;
+/**
+ * @name Callback Typedefs
+ * @{
+ */
+
+/**
+ * nl_recvmsgs() callback for message processing customization
+ * @ingroup cb
+ * @arg msg netlink message being processed
+ * @arg arg argument passwd on through caller
+ */
+typedef int (*nl_recvmsg_msg_cb_t)(struct nl_msg *msg, void *arg);
+
+/**
+ * nl_recvmsgs() callback for error message processing customization
+ * @ingroup cb
+ * @arg nla netlink address of the peer
+ * @arg nlerr netlink error message being processed
+ * @arg arg argument passed on through caller
+ */
+typedef int (*nl_recvmsg_err_cb_t)(struct sockaddr_nl *nla,
+ struct nlmsgerr *nlerr, void *arg);
+
+/** @} */
+
+/**
+ * Callback actions
+ * @ingroup cb
+ */
+enum nl_cb_action {
+ /** Proceed with wathever would come next */
+ NL_OK,
+ /** Skip this message */
+ NL_SKIP,
+ /** Stop parsing altogether and discard remaining messages */
+ NL_STOP,
+};
+
+/**
+ * Callback kinds
+ * @ingroup cb
+ */
+enum nl_cb_kind {
+ /** Default handlers (quiet) */
+ NL_CB_DEFAULT,
+ /** Verbose default handlers (error messages printed) */
+ NL_CB_VERBOSE,
+ /** Debug handlers for debugging */
+ NL_CB_DEBUG,
+ /** Customized handler specified by the user */
+ NL_CB_CUSTOM,
+ __NL_CB_KIND_MAX,
+};
+
+#define NL_CB_KIND_MAX (__NL_CB_KIND_MAX - 1)
+
+/**
+ * Callback types
+ * @ingroup cb
+ */
+enum nl_cb_type {
+ /** Message is valid */
+ NL_CB_VALID,
+ /** Last message in a series of multi part messages received */
+ NL_CB_FINISH,
+ /** Report received that data was lost */
+ NL_CB_OVERRUN,
+ /** Message wants to be skipped */
+ NL_CB_SKIPPED,
+ /** Message is an acknowledge */
+ NL_CB_ACK,
+ /** Called for every message received */
+ NL_CB_MSG_IN,
+ /** Called for every message sent out except for nl_sendto() */
+ NL_CB_MSG_OUT,
+ /** Message is malformed and invalid */
+ NL_CB_INVALID,
+ /** Called instead of internal sequence number checking */
+ NL_CB_SEQ_CHECK,
+ /** Sending of an acknowledge message has been requested */
+ NL_CB_SEND_ACK,
+ __NL_CB_TYPE_MAX,
+};
+
+#define NL_CB_TYPE_MAX (__NL_CB_TYPE_MAX - 1)
+
+struct nl_cb
+{
+ nl_recvmsg_msg_cb_t cb_set[NL_CB_TYPE_MAX+1];
+ void * cb_args[NL_CB_TYPE_MAX+1];
+
+ nl_recvmsg_err_cb_t cb_err;
+ void * cb_err_arg;
+
+ /** May be used to replace nl_recvmsgs with your own implementation
+ * in all internal calls to nl_recvmsgs. */
+ int (*cb_recvmsgs_ow)(struct nl_sock *,
+ struct nl_cb *);
+
+ /** Overwrite internal calls to nl_recv, must return the number of
+ * octets read and allocate a buffer for the received data. */
+ int (*cb_recv_ow)(struct nl_sock *,
+ struct sockaddr_nl *,
+ unsigned char **,
+ struct ucred **);
+
+ /** Overwrites internal calls to nl_send, must send the netlink
+ * message. */
+ int (*cb_send_ow)(struct nl_sock *,
+ struct nl_msg *);
+
+ int cb_refcnt;
+};
+
+
+extern struct nl_cb * nl_cb_alloc(enum nl_cb_kind);
+extern struct nl_cb * nl_cb_clone(struct nl_cb *);
+extern void nl_cb_put(struct nl_cb *);
+
+extern int nl_cb_set(struct nl_cb *, enum nl_cb_type, enum nl_cb_kind,
+ nl_recvmsg_msg_cb_t, void *);
+extern int nl_cb_err(struct nl_cb *, enum nl_cb_kind, nl_recvmsg_err_cb_t,
+ void *);
+
+static inline struct nl_cb *nl_cb_get(struct nl_cb *cb)
+{
+ cb->cb_refcnt++;
+
+ return cb;
+}
+
+/**
+ * Set up a all callbacks
+ * @arg cb callback set
+ * @arg kind kind of callback
+ * @arg func callback function
+ * @arg arg argument to be passwd to callback function
+ *
+ * @return 0 on success or a negative error code
+ */
+static inline int nl_cb_set_all(struct nl_cb *cb, enum nl_cb_kind kind,
+ nl_recvmsg_msg_cb_t func, void *arg)
+{
+ int i, err;
+
+ for (i = 0; i <= NL_CB_TYPE_MAX; i++) {
+ err = nl_cb_set(cb,(enum nl_cb_type)i, kind, func, arg);
+ if (err < 0)
+ return err;
+ }
+
+ return 0;
+}
+
+
+/**
+ * @name Overwriting
+ * @{
+ */
+
+/**
+ * Overwrite internal calls to nl_recvmsgs()
+ * @arg cb callback set
+ * @arg func replacement callback for nl_recvmsgs()
+ */
+static inline void nl_cb_overwrite_recvmsgs(struct nl_cb *cb,
+ int (*func)(struct nl_sock *, struct nl_cb *))
+{
+ cb->cb_recvmsgs_ow = func;
+}
+
+/**
+ * Overwrite internal calls to nl_recv()
+ * @arg cb callback set
+ * @arg func replacement callback for nl_recv()
+ */
+static inline void nl_cb_overwrite_recv(struct nl_cb *cb,
+ int (*func)(struct nl_sock *, struct sockaddr_nl *,
+ unsigned char **, struct ucred **))
+{
+ cb->cb_recv_ow = func;
+}
+
+/**
+ * Overwrite internal calls to nl_send()
+ * @arg cb callback set
+ * @arg func replacement callback for nl_send()
+ */
+static inline void nl_cb_overwrite_send(struct nl_cb *cb,
+ int (*func)(struct nl_sock *, struct nl_msg *))
+{
+ cb->cb_send_ow = func;
+}
+
+/** @} */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/package/libs/libnl-tiny/src/include/netlink/list.h b/package/libs/libnl-tiny/src/include/netlink/list.h
new file mode 100644
index 0000000..c6876a7
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/netlink/list.h
@@ -0,0 +1,88 @@
+/*
+ * netlink/list.h Netlink List Utilities
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
+ */
+
+#ifndef NETLINK_LIST_H_
+#define NETLINK_LIST_H_
+
+struct nl_list_head
+{
+ struct nl_list_head * next;
+ struct nl_list_head * prev;
+};
+
+
+static inline void __nl_list_add(struct nl_list_head *obj,
+ struct nl_list_head *prev,
+ struct nl_list_head *next)
+{
+ prev->next = obj;
+ obj->prev = prev;
+ next->prev = obj;
+ obj->next = next;
+}
+
+static inline void nl_list_add_tail(struct nl_list_head *obj,
+ struct nl_list_head *head)
+{
+ __nl_list_add(obj, head->prev, head);
+}
+
+static inline void nl_list_add_head(struct nl_list_head *obj,
+ struct nl_list_head *head)
+{
+ __nl_list_add(obj, head, head->next);
+}
+
+static inline void nl_list_del(struct nl_list_head *obj)
+{
+ obj->next->prev = obj->prev;
+ obj->prev->next = obj->next;
+}
+
+static inline int nl_list_empty(struct nl_list_head *head)
+{
+ return head->next == head;
+}
+
+#define nl_container_of(ptr, type, member) ({ \
+ const typeof( ((type *)0)->member ) *__mptr = (ptr); \
+ (type *)( (char *)__mptr - ((size_t) &((type *)0)->member));})
+
+#define nl_list_entry(ptr, type, member) \
+ nl_container_of(ptr, type, member)
+
+#define nl_list_at_tail(pos, head, member) \
+ ((pos)->member.next == (head))
+
+#define nl_list_at_head(pos, head, member) \
+ ((pos)->member.prev == (head))
+
+#define NL_LIST_HEAD(name) \
+ struct nl_list_head name = { &(name), &(name) }
+
+#define nl_list_first_entry(head, type, member) \
+ nl_list_entry((head)->next, type, member)
+
+#define nl_list_for_each_entry(pos, head, member) \
+ for (pos = nl_list_entry((head)->next, typeof(*pos), member); \
+ &(pos)->member != (head); \
+ (pos) = nl_list_entry((pos)->member.next, typeof(*(pos)), member))
+
+#define nl_list_for_each_entry_safe(pos, n, head, member) \
+ for (pos = nl_list_entry((head)->next, typeof(*pos), member), \
+ n = nl_list_entry(pos->member.next, typeof(*pos), member); \
+ &(pos)->member != (head); \
+ pos = n, n = nl_list_entry(n->member.next, typeof(*n), member))
+
+#define nl_init_list_head(head) \
+ do { (head)->next = (head); (head)->prev = (head); } while (0)
+
+#endif
diff --git a/package/libs/libnl-tiny/src/include/netlink/msg.h b/package/libs/libnl-tiny/src/include/netlink/msg.h
new file mode 100644
index 0000000..b3e2b0b
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/netlink/msg.h
@@ -0,0 +1,308 @@
+/*
+ * netlink/msg.c Netlink Messages Interface
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
+ */
+
+#ifndef NETLINK_MSG_H_
+#define NETLINK_MSG_H_
+
+#include <netlink/netlink.h>
+#include <netlink/object.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct nla_policy;
+
+#define NL_DONTPAD 0
+
+/**
+ * @ingroup msg
+ * @brief
+ * Will cause the netlink pid to be set to the pid assigned to
+ * the netlink handle (socket) just before sending the message off.
+ * @note Requires the use of nl_send_auto_complete()!
+ */
+#define NL_AUTO_PID 0
+
+/**
+ * @ingroup msg
+ * @brief
+ * May be used to refer to a sequence number which should be
+ * automatically set just before sending the message off.
+ * @note Requires the use of nl_send_auto_complete()!
+ */
+#define NL_AUTO_SEQ 0
+
+#define NL_MSG_CRED_PRESENT 1
+
+struct nl_msg
+{
+ int nm_protocol;
+ int nm_flags;
+ struct sockaddr_nl nm_src;
+ struct sockaddr_nl nm_dst;
+ struct ucred nm_creds;
+ struct nlmsghdr * nm_nlh;
+ size_t nm_size;
+ int nm_refcnt;
+};
+
+
+struct nl_msg;
+struct nl_tree;
+struct ucred;
+
+/* message parsing */
+extern int nlmsg_ok(const struct nlmsghdr *, int);
+extern struct nlmsghdr * nlmsg_next(struct nlmsghdr *, int *);
+extern int nlmsg_parse(struct nlmsghdr *, int, struct nlattr **,
+ int, struct nla_policy *);
+extern int nlmsg_validate(struct nlmsghdr *, int, int,
+ struct nla_policy *);
+
+extern struct nl_msg * nlmsg_alloc(void);
+extern struct nl_msg * nlmsg_alloc_size(size_t);
+extern struct nl_msg * nlmsg_alloc_simple(int, int);
+extern void nlmsg_set_default_size(size_t);
+extern struct nl_msg * nlmsg_inherit(struct nlmsghdr *);
+extern struct nl_msg * nlmsg_convert(struct nlmsghdr *);
+extern void * nlmsg_reserve(struct nl_msg *, size_t, int);
+extern int nlmsg_append(struct nl_msg *, void *, size_t, int);
+
+extern struct nlmsghdr * nlmsg_put(struct nl_msg *, uint32_t, uint32_t,
+ int, int, int);
+extern void nlmsg_free(struct nl_msg *);
+
+extern int nl_msg_parse(struct nl_msg *,
+ void (*cb)(struct nl_object *, void *),
+ void *);
+
+extern void nl_msg_dump(struct nl_msg *, FILE *);
+
+/**
+ * length of netlink message not including padding
+ * @arg payload length of message payload
+ */
+static inline int nlmsg_msg_size(int payload)
+{
+ return NLMSG_HDRLEN + payload;
+}
+
+/**
+ * length of netlink message including padding
+ * @arg payload length of message payload
+ */
+static inline int nlmsg_total_size(int payload)
+{
+ return NLMSG_ALIGN(nlmsg_msg_size(payload));
+}
+
+/**
+ * length of padding at the message's tail
+ * @arg payload length of message payload
+ */
+static inline int nlmsg_padlen(int payload)
+{
+ return nlmsg_total_size(payload) - nlmsg_msg_size(payload);
+}
+
+/**
+ * head of message payload
+ * @arg nlh netlink messsage header
+ */
+static inline void *nlmsg_data(const struct nlmsghdr *nlh)
+{
+ return (unsigned char *) nlh + NLMSG_HDRLEN;
+}
+
+static inline void *nlmsg_tail(const struct nlmsghdr *nlh)
+{
+ return (unsigned char *) nlh + NLMSG_ALIGN(nlh->nlmsg_len);
+}
+
+/**
+ * length of message payload
+ * @arg nlh netlink message header
+ */
+static inline int nlmsg_len(const struct nlmsghdr *nlh)
+{
+ return nlh->nlmsg_len - NLMSG_HDRLEN;
+}
+
+/**
+ * head of attributes data
+ * @arg nlh netlink message header
+ * @arg hdrlen length of family specific header
+ */
+static inline struct nlattr *nlmsg_attrdata(const struct nlmsghdr *nlh, int hdrlen)
+{
+ unsigned char *data = (unsigned char*)nlmsg_data(nlh);
+ return (struct nlattr *) (data + NLMSG_ALIGN(hdrlen));
+}
+
+/**
+ * length of attributes data
+ * @arg nlh netlink message header
+ * @arg hdrlen length of family specific header
+ */
+static inline int nlmsg_attrlen(const struct nlmsghdr *nlh, int hdrlen)
+{
+ return nlmsg_len(nlh) - NLMSG_ALIGN(hdrlen);
+}
+
+static inline int nlmsg_valid_hdr(const struct nlmsghdr *nlh, int hdrlen)
+{
+ if (nlh->nlmsg_len < (uint)nlmsg_msg_size(hdrlen))
+ return 0;
+
+ return 1;
+}
+
+
+static inline void nlmsg_set_proto(struct nl_msg *msg, int protocol)
+{
+ msg->nm_protocol = protocol;
+}
+
+static inline int nlmsg_get_proto(struct nl_msg *msg)
+{
+ return msg->nm_protocol;
+}
+
+static inline size_t nlmsg_get_max_size(struct nl_msg *msg)
+{
+ return msg->nm_size;
+}
+
+static inline void nlmsg_set_src(struct nl_msg *msg, struct sockaddr_nl *addr)
+{
+ memcpy(&msg->nm_src, addr, sizeof(*addr));
+}
+
+static inline struct sockaddr_nl *nlmsg_get_src(struct nl_msg *msg)
+{
+ return &msg->nm_src;
+}
+
+static inline void nlmsg_set_dst(struct nl_msg *msg, struct sockaddr_nl *addr)
+{
+ memcpy(&msg->nm_dst, addr, sizeof(*addr));
+}
+
+static inline struct sockaddr_nl *nlmsg_get_dst(struct nl_msg *msg)
+{
+ return &msg->nm_dst;
+}
+
+static inline void nlmsg_set_creds(struct nl_msg *msg, struct ucred *creds)
+{
+ memcpy(&msg->nm_creds, creds, sizeof(*creds));
+ msg->nm_flags |= NL_MSG_CRED_PRESENT;
+}
+
+static inline struct ucred *nlmsg_get_creds(struct nl_msg *msg)
+{
+ if (msg->nm_flags & NL_MSG_CRED_PRESENT)
+ return &msg->nm_creds;
+ return NULL;
+}
+
+/**
+ * Return actual netlink message
+ * @arg n netlink message
+ *
+ * Returns the actual netlink message casted to the type of the netlink
+ * message header.
+ *
+ * @return A pointer to the netlink message.
+ */
+static inline struct nlmsghdr *nlmsg_hdr(struct nl_msg *n)
+{
+ return n->nm_nlh;
+}
+
+/**
+ * Acquire a reference on a netlink message
+ * @arg msg message to acquire reference from
+ */
+static inline void nlmsg_get(struct nl_msg *msg)
+{
+ msg->nm_refcnt++;
+}
+
+/**
+ * Expand maximum payload size of a netlink message
+ * @arg n Netlink message.
+ * @arg newlen New maximum payload size.
+ *
+ * Reallocates the payload section of a netlink message and increases
+ * the maximum payload size of the message.
+ *
+ * @note Any pointers pointing to old payload block will be stale and
+ * need to be refetched. Therfore, do not expand while constructing
+ * nested attributes or while reserved data blocks are held.
+ *
+ * @return 0 on success or a negative error code.
+ */
+static inline int nlmsg_expand(struct nl_msg *n, size_t newlen)
+{
+ void *tmp;
+
+ if (newlen <= n->nm_size)
+ return -NLE_INVAL;
+
+ tmp = realloc(n->nm_nlh, newlen);
+ if (tmp == NULL)
+ return -NLE_NOMEM;
+
+ n->nm_nlh = (struct nlmsghdr*)tmp;
+ n->nm_size = newlen;
+
+ return 0;
+}
+
+
+/**
+ * @name Iterators
+ * @{
+ */
+
+/**
+ * @ingroup msg
+ * Iterate over a stream of attributes in a message
+ * @arg pos loop counter, set to current attribute
+ * @arg nlh netlink message header
+ * @arg hdrlen length of family header
+ * @arg rem initialized to len, holds bytes currently remaining in stream
+ */
+#define nlmsg_for_each_attr(pos, nlh, hdrlen, rem) \
+ nla_for_each_attr(pos, nlmsg_attrdata(nlh, hdrlen), \
+ nlmsg_attrlen(nlh, hdrlen), rem)
+
+/**
+ * Iterate over a stream of messages
+ * @arg pos loop counter, set to current message
+ * @arg head head of message stream
+ * @arg len length of message stream
+ * @arg rem initialized to len, holds bytes currently remaining in stream
+ */
+#define nlmsg_for_each_msg(pos, head, len, rem) \
+ for (pos = head, rem = len; \
+ nlmsg_ok(pos, rem); \
+ pos = nlmsg_next(pos, &(rem)))
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/package/libs/libnl-tiny/src/include/netlink/netlink-compat.h b/package/libs/libnl-tiny/src/include/netlink/netlink-compat.h
new file mode 100644
index 0000000..17ec9fc
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/netlink/netlink-compat.h
@@ -0,0 +1,50 @@
+/*
+ * netlink/netlink-compat.h Netlink Compatability
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
+ */
+
+#ifndef NETLINK_COMPAT_H_
+#define NETLINK_COMPAT_H_
+
+#if !defined _LINUX_SOCKET_H && !defined _BITS_SOCKADDR_H
+typedef unsigned short sa_family_t;
+#endif
+
+#ifndef IFNAMSIZ
+/** Maximum length of a interface name */
+#define IFNAMSIZ 16
+#endif
+
+/* patch 2.4.x if_arp */
+#ifndef ARPHRD_INFINIBAND
+#define ARPHRD_INFINIBAND 32
+#endif
+
+/* patch 2.4.x eth header file */
+#ifndef ETH_P_MPLS_UC
+#define ETH_P_MPLS_UC 0x8847
+#endif
+
+#ifndef ETH_P_MPLS_MC
+#define ETH_P_MPLS_MC 0x8848
+#endif
+
+#ifndef ETH_P_EDP2
+#define ETH_P_EDP2 0x88A2
+#endif
+
+#ifndef ETH_P_HDLC
+#define ETH_P_HDLC 0x0019
+#endif
+
+#ifndef AF_LLC
+#define AF_LLC 26
+#endif
+
+#endif
diff --git a/package/libs/libnl-tiny/src/include/netlink/netlink-kernel.h b/package/libs/libnl-tiny/src/include/netlink/netlink-kernel.h
new file mode 100644
index 0000000..a0f5535
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/netlink/netlink-kernel.h
@@ -0,0 +1,196 @@
+#ifndef __LINUX_NETLINK_H
+#define __LINUX_NETLINK_H
+
+/**
+ * Netlink socket address
+ * @ingroup nl
+ */
+struct sockaddr_nl
+{
+ /** socket family (AF_NETLINK) */
+ sa_family_t nl_family;
+
+ /** Padding (unused) */
+ unsigned short nl_pad;
+
+ /** Unique process ID */
+ uint32_t nl_pid;
+
+ /** Multicast group subscriptions */
+ uint32_t nl_groups;
+};
+
+/**
+ * Netlink message header
+ * @ingroup msg
+ */
+struct nlmsghdr
+{
+ /**
+ * Length of message including header.
+ */
+ uint32_t nlmsg_len;
+
+ /**
+ * Message type (content type)
+ */
+ uint16_t nlmsg_type;
+
+ /**
+ * Message flags
+ */
+ uint16_t nlmsg_flags;
+
+ /**
+ * Sequence number
+ */
+ uint32_t nlmsg_seq;
+
+ /**
+ * Netlink PID of the proccess sending the message.
+ */
+ uint32_t nlmsg_pid;
+};
+
+/**
+ * @name Standard message flags
+ * @{
+ */
+
+/**
+ * Must be set on all request messages (typically from user space to
+ * kernel space).
+ * @ingroup msg
+ */
+#define NLM_F_REQUEST 1
+
+/**
+ * Indicates the message is part of a multipart message terminated
+ * by NLMSG_DONE.
+ */
+#define NLM_F_MULTI 2
+
+/**
+ * Request for an acknowledgment on success.
+ */
+#define NLM_F_ACK 4
+
+/**
+ * Echo this request
+ */
+#define NLM_F_ECHO 8
+
+/** @} */
+
+/**
+ * @name Additional message flags for GET requests
+ * @{
+ */
+
+/**
+ * Return the complete table instead of a single entry.
+ * @ingroup msg
+ */
+#define NLM_F_ROOT 0x100
+
+/**
+ * Return all entries matching criteria passed in message content.
+ */
+#define NLM_F_MATCH 0x200
+
+/**
+ * Return an atomic snapshot of the table being referenced. This
+ * may require special privileges because it has the potential to
+ * interrupt service in the FE for a longer time.
+ */
+#define NLM_F_ATOMIC 0x400
+
+/**
+ * Dump all entries
+ */
+#define NLM_F_DUMP (NLM_F_ROOT|NLM_F_MATCH)
+
+/** @} */
+
+/**
+ * @name Additional messsage flags for NEW requests
+ * @{
+ */
+
+/**
+ * Replace existing matching config object with this request.
+ * @ingroup msg
+ */
+#define NLM_F_REPLACE 0x100
+
+/**
+ * Don't replace the config object if it already exists.
+ */
+#define NLM_F_EXCL 0x200
+
+/**
+ * Create config object if it doesn't already exist.
+ */
+#define NLM_F_CREATE 0x400
+
+/**
+ * Add to the end of the object list.
+ */
+#define NLM_F_APPEND 0x800
+
+/** @} */
+
+/**
+ * @name Standard Message types
+ * @{
+ */
+
+/**
+ * No operation, message must be ignored
+ * @ingroup msg
+ */
+#define NLMSG_NOOP 0x1
+
+/**
+ * The message signals an error and the payload contains a nlmsgerr
+ * structure. This can be looked at as a NACK and typically it is
+ * from FEC to CPC.
+ */
+#define NLMSG_ERROR 0x2
+
+/**
+ * Message terminates a multipart message.
+ */
+#define NLMSG_DONE 0x3
+
+/**
+ * The message signals that data got lost
+ */
+#define NLMSG_OVERRUN 0x4
+
+/**
+ * Lower limit of reserved message types
+ */
+#define NLMSG_MIN_TYPE 0x10
+
+/** @} */
+
+/**
+ * Netlink error message
+ * @ingroup msg
+ */
+struct nlmsgerr
+{
+ /** Error code (errno number) */
+ int error;
+
+ /** Original netlink message causing the error */
+ struct nlmsghdr msg;
+};
+
+struct nl_pktinfo
+{
+ __u32 group;
+};
+
+#endif /* __LINUX_NETLINK_H */
diff --git a/package/libs/libnl-tiny/src/include/netlink/netlink.h b/package/libs/libnl-tiny/src/include/netlink/netlink.h
new file mode 100644
index 0000000..e06fb7f
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/netlink/netlink.h
@@ -0,0 +1,82 @@
+/*
+ * netlink/netlink.h Netlink Interface
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
+ */
+
+#ifndef NETLINK_NETLINK_H_
+#define NETLINK_NETLINK_H_
+
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+#include <sys/poll.h>
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <netdb.h>
+#include <netlink/netlink-compat.h>
+#include <linux/netlink.h>
+#include <linux/genetlink.h>
+#include <netlink/version.h>
+#include <netlink/errno.h>
+#include <netlink/types.h>
+#include <netlink/handlers.h>
+#include <netlink/socket.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern int nl_debug;
+extern struct nl_dump_params nl_debug_dp;
+
+/* Connection Management */
+extern int nl_connect(struct nl_sock *, int);
+extern void nl_close(struct nl_sock *);
+
+/* Send */
+extern int nl_sendto(struct nl_sock *, void *, size_t);
+extern int nl_sendmsg(struct nl_sock *, struct nl_msg *,
+ struct msghdr *);
+extern int nl_send(struct nl_sock *, struct nl_msg *);
+extern int nl_send_auto_complete(struct nl_sock *,
+ struct nl_msg *);
+extern int nl_send_simple(struct nl_sock *, int, int,
+ void *, size_t);
+
+/* Receive */
+extern int nl_recv(struct nl_sock *,
+ struct sockaddr_nl *, unsigned char **,
+ struct ucred **);
+extern int nl_recvmsgs(struct nl_sock *sk, struct nl_cb *cb);
+
+extern int nl_wait_for_ack(struct nl_sock *);
+
+/* Netlink Family Translations */
+extern char * nl_nlfamily2str(int, char *, size_t);
+extern int nl_str2nlfamily(const char *);
+
+/**
+ * Receive a set of message from a netlink socket using handlers in nl_sock.
+ * @arg sk Netlink socket.
+ *
+ * Calls nl_recvmsgs() with the handlers configured in the netlink socket.
+ */
+static inline int nl_recvmsgs_default(struct nl_sock *sk)
+{
+ return nl_recvmsgs(sk, sk->s_cb);
+}
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/package/libs/libnl-tiny/src/include/netlink/object-api.h b/package/libs/libnl-tiny/src/include/netlink/object-api.h
new file mode 100644
index 0000000..8a44fe9
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/netlink/object-api.h
@@ -0,0 +1,331 @@
+/*
+ * netlink/object-api.c Object API
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2007 Thomas Graf <tgraf@suug.ch>
+ */
+
+#ifndef NETLINK_OBJECT_API_H_
+#define NETLINK_OBJECT_API_H_
+
+#include <netlink/netlink.h>
+#include <netlink/utils.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @ingroup object
+ * @defgroup object_api Object API
+ * @brief
+ *
+ * @par 1) Object Definition
+ * @code
+ * // Define your object starting with the common object header
+ * struct my_obj {
+ * NLHDR_COMMON
+ * int my_data;
+ * };
+ *
+ * // Fill out the object operations structure
+ * struct nl_object_ops my_ops = {
+ * .oo_name = "my_obj",
+ * .oo_size = sizeof(struct my_obj),
+ * };
+ *
+ * // At this point the object can be allocated, you may want to provide a
+ * // separate _alloc() function to ease allocting objects of this kind.
+ * struct nl_object *obj = nl_object_alloc(&my_ops);
+ *
+ * // And release it again...
+ * nl_object_put(obj);
+ * @endcode
+ *
+ * @par 2) Allocating additional data
+ * @code
+ * // You may require to allocate additional data and store it inside
+ * // object, f.e. assuming there is a field `ptr'.
+ * struct my_obj {
+ * NLHDR_COMMON
+ * void * ptr;
+ * };
+ *
+ * // And at some point you may assign allocated data to this field:
+ * my_obj->ptr = calloc(1, ...);
+ *
+ * // In order to not introduce any memory leaks you have to release
+ * // this data again when the last reference is given back.
+ * static void my_obj_free_data(struct nl_object *obj)
+ * {
+ * struct my_obj *my_obj = nl_object_priv(obj);
+ *
+ * free(my_obj->ptr);
+ * }
+ *
+ * // Also when the object is cloned, you must ensure for your pointer
+ * // stay valid even if one of the clones is freed by either making
+ * // a clone as well or increase the reference count.
+ * static int my_obj_clone(struct nl_object *src, struct nl_object *dst)
+ * {
+ * struct my_obj *my_src = nl_object_priv(src);
+ * struct my_obj *my_dst = nl_object_priv(dst);
+ *
+ * if (src->ptr) {
+ * dst->ptr = calloc(1, ...);
+ * memcpy(dst->ptr, src->ptr, ...);
+ * }
+ * }
+ *
+ * struct nl_object_ops my_ops = {
+ * ...
+ * .oo_free_data = my_obj_free_data,
+ * .oo_clone = my_obj_clone,
+ * };
+ * @endcode
+ *
+ * @par 3) Object Dumping
+ * @code
+ * static int my_obj_dump_detailed(struct nl_object *obj,
+ * struct nl_dump_params *params)
+ * {
+ * struct my_obj *my_obj = nl_object_priv(obj);
+ *
+ * // It is absolutely essential to use nl_dump() when printing
+ * // any text to make sure the dumping parameters are respected.
+ * nl_dump(params, "Obj Integer: %d\n", my_obj->my_int);
+ *
+ * // Before we can dump the next line, make sure to prefix
+ * // this line correctly.
+ * nl_new_line(params);
+ *
+ * // You may also split a line into multiple nl_dump() calls.
+ * nl_dump(params, "String: %s ", my_obj->my_string);
+ * nl_dump(params, "String-2: %s\n", my_obj->another_string);
+ * }
+ *
+ * struct nl_object_ops my_ops = {
+ * ...
+ * .oo_dump[NL_DUMP_FULL] = my_obj_dump_detailed,
+ * };
+ * @endcode
+ *
+ * @par 4) Object Attributes
+ * @code
+ * // The concept of object attributes is optional but can ease the typical
+ * // case of objects that have optional attributes, e.g. a route may have a
+ * // nexthop assigned but it is not required to.
+ *
+ * // The first step to define your object specific bitmask listing all
+ * // attributes
+ * #define MY_ATTR_FOO (1<<0)
+ * #define MY_ATTR_BAR (1<<1)
+ *
+ * // When assigning an optional attribute to the object, make sure
+ * // to mark its availability.
+ * my_obj->foo = 123123;
+ * my_obj->ce_mask |= MY_ATTR_FOO;
+ *
+ * // At any time you may use this mask to check for the availability
+ * // of the attribute, e.g. while dumping
+ * if (my_obj->ce_mask & MY_ATTR_FOO)
+ * nl_dump(params, "foo %d ", my_obj->foo);
+ *
+ * // One of the big advantages of this concept is that it allows for
+ * // standardized comparisons which make it trivial for caches to
+ * // identify unique objects by use of unified comparison functions.
+ * // In order for it to work, your object implementation must provide
+ * // a comparison function and define a list of attributes which
+ * // combined together make an object unique.
+ *
+ * static int my_obj_compare(struct nl_object *_a, struct nl_object *_b,
+ * uint32_t attrs, int flags)
+ * {
+ * struct my_obj *a = nl_object_priv(_a):
+ * struct my_obj *b = nl_object_priv(_b):
+ * int diff = 0;
+ *
+ * // We help ourselves in defining our own DIFF macro which will
+ * // call ATTR_DIFF() on both objects which will make sure to only
+ * // compare the attributes if required.
+ * #define MY_DIFF(ATTR, EXPR) ATTR_DIFF(attrs, MY_ATTR_##ATTR, a, b, EXPR)
+ *
+ * // Call our own diff macro for each attribute to build a bitmask
+ * // representing the attributes which mismatch.
+ * diff |= MY_DIFF(FOO, a->foo != b->foo)
+ * diff |= MY_DIFF(BAR, strcmp(a->bar, b->bar))
+ *
+ * return diff;
+ * }
+ *
+ * // In order to identify identical objects with differing attributes
+ * // you must specify the attributes required to uniquely identify
+ * // your object. Make sure to not include too many attributes, this
+ * // list is used when caches look for an old version of an object.
+ * struct nl_object_ops my_ops = {
+ * ...
+ * .oo_id_attrs = MY_ATTR_FOO,
+ * .oo_compare = my_obj_compare,
+ * };
+ * @endcode
+ * @{
+ */
+
+/**
+ * Common Object Header
+ *
+ * This macro must be included as first member in every object
+ * definition to allow objects to be cached.
+ */
+#define NLHDR_COMMON \
+ int ce_refcnt; \
+ struct nl_object_ops * ce_ops; \
+ struct nl_cache * ce_cache; \
+ struct nl_list_head ce_list; \
+ int ce_msgtype; \
+ int ce_flags; \
+ uint32_t ce_mask;
+
+/**
+ * Return true if attribute is available in both objects
+ * @arg A an object
+ * @arg B another object
+ * @arg ATTR attribute bit
+ *
+ * @return True if the attribute is available, otherwise false is returned.
+ */
+#define AVAILABLE(A, B, ATTR) (((A)->ce_mask & (B)->ce_mask) & (ATTR))
+
+/**
+ * Return true if attributes mismatch
+ * @arg A an object
+ * @arg B another object
+ * @arg ATTR attribute bit
+ * @arg EXPR Comparison expression
+ *
+ * This function will check if the attribute in question is available
+ * in both objects, if not this will count as a mismatch.
+ *
+ * If available the function will execute the expression which must
+ * return true if the attributes mismatch.
+ *
+ * @return True if the attribute mismatch, or false if they match.
+ */
+#define ATTR_MISMATCH(A, B, ATTR, EXPR) (!AVAILABLE(A, B, ATTR) || (EXPR))
+
+/**
+ * Return attribute bit if attribute does not match
+ * @arg LIST list of attributes to be compared
+ * @arg ATTR attribute bit
+ * @arg A an object
+ * @arg B another object
+ * @arg EXPR Comparison expression
+ *
+ * This function will check if the attribute in question is available
+ * in both objects, if not this will count as a mismatch.
+ *
+ * If available the function will execute the expression which must
+ * return true if the attributes mismatch.
+ *
+ * In case the attributes mismatch, the attribute is returned, otherwise
+ * 0 is returned.
+ *
+ * @code
+ * diff |= ATTR_DIFF(attrs, MY_ATTR_FOO, a, b, a->foo != b->foo);
+ * @endcode
+ */
+#define ATTR_DIFF(LIST, ATTR, A, B, EXPR) \
+({ int diff = 0; \
+ if (((LIST) & (ATTR)) && ATTR_MISMATCH(A, B, ATTR, EXPR)) \
+ diff = ATTR; \
+ diff; })
+
+/**
+ * Object Operations
+ */
+struct nl_object;
+struct nl_object_ops
+{
+ /**
+ * Unique name of object type
+ *
+ * Must be in the form family/name, e.g. "route/addr"
+ */
+ char * oo_name;
+
+ /** Size of object including its header */
+ size_t oo_size;
+
+ /* List of attributes needed to uniquely identify the object */
+ uint32_t oo_id_attrs;
+
+ /**
+ * Constructor function
+ *
+ * Will be called when a new object of this type is allocated.
+ * Can be used to initialize members such as lists etc.
+ */
+ void (*oo_constructor)(struct nl_object *);
+
+ /**
+ * Destructor function
+ *
+ * Will be called when an object is freed. Must free all
+ * resources which may have been allocated as part of this
+ * object.
+ */
+ void (*oo_free_data)(struct nl_object *);
+
+ /**
+ * Cloning function
+ *
+ * Will be called when an object needs to be cloned. Please
+ * note that the generic object code will make an exact
+ * copy of the object first, therefore you only need to take
+ * care of members which require reference counting etc.
+ *
+ * May return a negative error code to abort cloning.
+ */
+ int (*oo_clone)(struct nl_object *, struct nl_object *);
+
+ /**
+ * Dumping functions
+ *
+ * Will be called when an object is dumped. The implementations
+ * have to use nl_dump(), nl_dump_line(), and nl_new_line() to
+ * dump objects.
+ *
+ * The functions must return the number of lines printed.
+ */
+ void (*oo_dump[NL_DUMP_MAX+1])(struct nl_object *,
+ struct nl_dump_params *);
+
+ /**
+ * Comparison function
+ *
+ * Will be called when two objects of the same type are
+ * compared. It takes the two objects in question, an object
+ * specific bitmask defining which attributes should be
+ * compared and flags to control the behaviour.
+ *
+ * The function must return a bitmask with the relevant bit
+ * set for each attribute that mismatches.
+ */
+ int (*oo_compare)(struct nl_object *, struct nl_object *,
+ uint32_t, int);
+
+
+ char *(*oo_attrs2str)(int, char *, size_t);
+};
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/package/libs/libnl-tiny/src/include/netlink/object.h b/package/libs/libnl-tiny/src/include/netlink/object.h
new file mode 100644
index 0000000..8aabe7b
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/netlink/object.h
@@ -0,0 +1,164 @@
+/*
+ * netlink/object.c Generic Cacheable Object
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
+ */
+
+#ifndef NETLINK_OBJECT_H_
+#define NETLINK_OBJECT_H_
+
+#include <netlink/netlink.h>
+#include <netlink/utils.h>
+#include <netlink/object-api.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define NL_OBJ_MARK 1
+
+struct nl_cache;
+struct nl_object;
+struct nl_object_ops;
+
+struct nl_object
+{
+ NLHDR_COMMON
+};
+
+#define OBJ_CAST(ptr) ((struct nl_object *) (ptr))
+
+/* General */
+extern struct nl_object * nl_object_alloc(struct nl_object_ops *);
+extern void nl_object_free(struct nl_object *);
+extern struct nl_object * nl_object_clone(struct nl_object *obj);
+
+#ifdef disabled
+
+extern int nl_object_alloc_name(const char *,
+ struct nl_object **);
+extern void nl_object_dump(struct nl_object *,
+ struct nl_dump_params *);
+
+extern uint32_t nl_object_diff(struct nl_object *,
+ struct nl_object *);
+extern int nl_object_match_filter(struct nl_object *,
+ struct nl_object *);
+extern int nl_object_identical(struct nl_object *,
+ struct nl_object *);
+extern char * nl_object_attrs2str(struct nl_object *,
+ uint32_t attrs, char *buf,
+ size_t);
+#endif
+/**
+ * Check whether this object is used by multiple users
+ * @arg obj object to check
+ * @return true or false
+ */
+static inline int nl_object_shared(struct nl_object *obj)
+{
+ return obj->ce_refcnt > 1;
+}
+
+
+static inline void nl_object_get(struct nl_object *obj)
+{
+ obj->ce_refcnt++;
+}
+
+static inline void nl_object_put(struct nl_object *obj)
+{
+ if (!obj)
+ return;
+
+ obj->ce_refcnt--;
+
+ if (obj->ce_refcnt <= 0)
+ nl_object_free(obj);
+}
+
+
+/**
+ * @name Marks
+ * @{
+ */
+
+/**
+ * Add mark to object
+ * @arg obj Object to mark
+ */
+static inline void nl_object_mark(struct nl_object *obj)
+{
+ obj->ce_flags |= NL_OBJ_MARK;
+}
+
+/**
+ * Remove mark from object
+ * @arg obj Object to unmark
+ */
+static inline void nl_object_unmark(struct nl_object *obj)
+{
+ obj->ce_flags &= ~NL_OBJ_MARK;
+}
+
+/**
+ * Return true if object is marked
+ * @arg obj Object to check
+ * @return true if object is marked, otherwise false
+ */
+static inline int nl_object_is_marked(struct nl_object *obj)
+{
+ return (obj->ce_flags & NL_OBJ_MARK);
+}
+
+/** @} */
+
+#ifdef disabled
+/**
+ * Return list of attributes present in an object
+ * @arg obj an object
+ * @arg buf destination buffer
+ * @arg len length of destination buffer
+ *
+ * @return destination buffer.
+ */
+static inline char *nl_object_attr_list(struct nl_object *obj, char *buf, size_t len)
+{
+ return nl_object_attrs2str(obj, obj->ce_mask, buf, len);
+}
+#endif
+
+/**
+ * @name Attributes
+ * @{
+ */
+
+static inline int nl_object_get_refcnt(struct nl_object *obj)
+{
+ return obj->ce_refcnt;
+}
+
+static inline struct nl_cache *nl_object_get_cache(struct nl_object *obj)
+{
+ return obj->ce_cache;
+}
+
+static inline void * nl_object_priv(struct nl_object *obj)
+{
+ return obj;
+}
+
+
+/** @} */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/package/libs/libnl-tiny/src/include/netlink/socket.h b/package/libs/libnl-tiny/src/include/netlink/socket.h
new file mode 100644
index 0000000..9f7f422
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/netlink/socket.h
@@ -0,0 +1,221 @@
+/*
+ * netlink/socket.h Netlink Socket
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
+ */
+
+#ifndef NETLINK_SOCKET_H_
+#define NETLINK_SOCKET_H_
+
+#include <netlink/types.h>
+#include <netlink/handlers.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define NL_SOCK_BUFSIZE_SET (1<<0)
+#define NL_SOCK_PASSCRED (1<<1)
+#define NL_OWN_PORT (1<<2)
+#define NL_MSG_PEEK (1<<3)
+#define NL_NO_AUTO_ACK (1<<4)
+
+struct nl_cb;
+struct nl_sock
+{
+ struct sockaddr_nl s_local;
+ struct sockaddr_nl s_peer;
+ int s_fd;
+ int s_proto;
+ unsigned int s_seq_next;
+ unsigned int s_seq_expect;
+ int s_flags;
+ struct nl_cb * s_cb;
+};
+
+
+extern struct nl_sock * nl_socket_alloc(void);
+extern struct nl_sock * nl_socket_alloc_cb(struct nl_cb *);
+extern void nl_socket_free(struct nl_sock *);
+
+extern void nl_socket_set_local_port(struct nl_sock *, uint32_t);
+
+extern int nl_socket_add_memberships(struct nl_sock *, int, ...);
+extern int nl_socket_drop_memberships(struct nl_sock *, int, ...);
+
+extern int nl_socket_set_buffer_size(struct nl_sock *, int, int);
+extern int nl_socket_set_passcred(struct nl_sock *, int);
+extern int nl_socket_recv_pktinfo(struct nl_sock *, int);
+
+extern void nl_socket_disable_seq_check(struct nl_sock *);
+
+extern int nl_socket_set_nonblocking(struct nl_sock *);
+
+/**
+ * Use next sequence number
+ * @arg sk Netlink socket.
+ *
+ * Uses the next available sequence number and increases the counter
+ * by one for subsequent calls.
+ *
+ * @return Unique serial sequence number
+ */
+static inline unsigned int nl_socket_use_seq(struct nl_sock *sk)
+{
+ return sk->s_seq_next++;
+}
+
+/**
+ * Disable automatic request for ACK
+ * @arg sk Netlink socket.
+ *
+ * The default behaviour of a socket is to request an ACK for
+ * each message sent to allow for the caller to synchronize to
+ * the completion of the netlink operation. This function
+ * disables this behaviour and will result in requests being
+ * sent which will not have the NLM_F_ACK flag set automatically.
+ * However, it is still possible for the caller to set the
+ * NLM_F_ACK flag explicitely.
+ */
+static inline void nl_socket_disable_auto_ack(struct nl_sock *sk)
+{
+ sk->s_flags |= NL_NO_AUTO_ACK;
+}
+
+/**
+ * Enable automatic request for ACK (default)
+ * @arg sk Netlink socket.
+ * @see nl_socket_disable_auto_ack
+ */
+static inline void nl_socket_enable_auto_ack(struct nl_sock *sk)
+{
+ sk->s_flags &= ~NL_NO_AUTO_ACK;
+}
+
+/**
+ * @name Source Idenficiation
+ * @{
+ */
+
+static inline uint32_t nl_socket_get_local_port(struct nl_sock *sk)
+{
+ return sk->s_local.nl_pid;
+}
+
+/**
+ * Join multicast groups (deprecated)
+ * @arg sk Netlink socket.
+ * @arg groups Bitmask of groups to join.
+ *
+ * This function defines the old way of joining multicast group which
+ * has to be done prior to calling nl_connect(). It works on any kernel
+ * version but is very limited as only 32 groups can be joined.
+ */
+static inline void nl_join_groups(struct nl_sock *sk, int groups)
+{
+ sk->s_local.nl_groups |= groups;
+}
+
+/**
+ * @name Peer Identfication
+ * @{
+ */
+
+static inline uint32_t nl_socket_get_peer_port(struct nl_sock *sk)
+{
+ return sk->s_peer.nl_pid;
+}
+
+static inline void nl_socket_set_peer_port(struct nl_sock *sk, uint32_t port)
+{
+ sk->s_peer.nl_pid = port;
+}
+
+/** @} */
+
+/**
+ * @name File Descriptor
+ * @{
+ */
+
+static inline int nl_socket_get_fd(struct nl_sock *sk)
+{
+ return sk->s_fd;
+}
+
+/**
+ * Enable use of MSG_PEEK when reading from socket
+ * @arg sk Netlink socket.
+ */
+static inline void nl_socket_enable_msg_peek(struct nl_sock *sk)
+{
+ sk->s_flags |= NL_MSG_PEEK;
+}
+
+/**
+ * Disable use of MSG_PEEK when reading from socket
+ * @arg sk Netlink socket.
+ */
+static inline void nl_socket_disable_msg_peek(struct nl_sock *sk)
+{
+ sk->s_flags &= ~NL_MSG_PEEK;
+}
+
+/**
+ * @name Callback Handler
+ * @{
+ */
+
+static inline struct nl_cb *nl_socket_get_cb(struct nl_sock *sk)
+{
+ return nl_cb_get(sk->s_cb);
+}
+
+static inline void nl_socket_set_cb(struct nl_sock *sk, struct nl_cb *cb)
+{
+ nl_cb_put(sk->s_cb);
+ sk->s_cb = nl_cb_get(cb);
+}
+
+/**
+ * Modify the callback handler associated to the socket
+ * @arg sk Netlink socket.
+ * @arg type which type callback to set
+ * @arg kind kind of callback
+ * @arg func callback function
+ * @arg arg argument to be passwd to callback function
+ *
+ * @see nl_cb_set
+ */
+static inline int nl_socket_modify_cb(struct nl_sock *sk, enum nl_cb_type type,
+ enum nl_cb_kind kind, nl_recvmsg_msg_cb_t func,
+ void *arg)
+{
+ return nl_cb_set(sk->s_cb, type, kind, func, arg);
+}
+
+/** @} */
+
+static inline int nl_socket_add_membership(struct nl_sock *sk, int group)
+{
+ return nl_socket_add_memberships(sk, group, 0);
+}
+
+
+static inline int nl_socket_drop_membership(struct nl_sock *sk, int group)
+{
+ return nl_socket_drop_memberships(sk, group, 0);
+}
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/package/libs/libnl-tiny/src/include/netlink/types.h b/package/libs/libnl-tiny/src/include/netlink/types.h
new file mode 100644
index 0000000..de81ace
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/netlink/types.h
@@ -0,0 +1,121 @@
+/*
+ * netlink/netlink-types.h Netlink Types
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
+ */
+
+#ifndef __NETLINK_TYPES_H_
+#define __NETLINK_TYPES_H_
+
+#include <stdio.h>
+
+/**
+ * Dumping types (dp_type)
+ * @ingroup utils
+ */
+enum nl_dump_type {
+ NL_DUMP_LINE, /**< Dump object briefly on one line */
+ NL_DUMP_DETAILS, /**< Dump all attributes but no statistics */
+ NL_DUMP_STATS, /**< Dump all attributes including statistics */
+ NL_DUMP_ENV, /**< Dump all attribtues as env variables */
+ __NL_DUMP_MAX,
+};
+#define NL_DUMP_MAX (__NL_DUMP_MAX - 1)
+
+/**
+ * Dumping parameters
+ * @ingroup utils
+ */
+struct nl_dump_params
+{
+ /**
+ * Specifies the type of dump that is requested.
+ */
+ enum nl_dump_type dp_type;
+
+ /**
+ * Specifies the number of whitespaces to be put in front
+ * of every new line (indentation).
+ */
+ int dp_prefix;
+
+ /**
+ * Causes the cache index to be printed for each element.
+ */
+ int dp_print_index;
+
+ /**
+ * Causes each element to be prefixed with the message type.
+ */
+ int dp_dump_msgtype;
+
+ /**
+ * A callback invoked for output
+ *
+ * Passed arguments are:
+ * - dumping parameters
+ * - string to append to the output
+ */
+ void (*dp_cb)(struct nl_dump_params *, char *);
+
+ /**
+ * A callback invoked for every new line, can be used to
+ * customize the indentation.
+ *
+ * Passed arguments are:
+ * - dumping parameters
+ * - line number starting from 0
+ */
+ void (*dp_nl_cb)(struct nl_dump_params *, int);
+
+ /**
+ * User data pointer, can be used to pass data to callbacks.
+ */
+ void *dp_data;
+
+ /**
+ * File descriptor the dumping output should go to
+ */
+ FILE * dp_fd;
+
+ /**
+ * Alternatively the output may be redirected into a buffer
+ */
+ char * dp_buf;
+
+ /**
+ * Length of the buffer dp_buf
+ */
+ size_t dp_buflen;
+
+ /**
+ * PRIVATE
+ * Set if a dump was performed prior to the actual dump handler.
+ */
+ int dp_pre_dump;
+
+ /**
+ * PRIVATE
+ * Owned by the current caller
+ */
+ int dp_ivar;
+
+ unsigned int dp_line;
+};
+
+#ifndef __GNUC__
+#define __extension__
+#endif
+
+#define min_t(type,x,y) \
+ __extension__({ type __x = (x); type __y = (y); __x < __y ? __x: __y; })
+#define max_t(type,x,y) \
+ __extension__({ type __x = (x); type __y = (y); __x > __y ? __x: __y; })
+
+
+#endif
diff --git a/package/libs/libnl-tiny/src/include/netlink/utils.h b/package/libs/libnl-tiny/src/include/netlink/utils.h
new file mode 100644
index 0000000..480bab6
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/netlink/utils.h
@@ -0,0 +1,78 @@
+/*
+ * netlink/utils.h Utility Functions
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
+ */
+
+#ifndef NETLINK_UTILS_H_
+#define NETLINK_UTILS_H_
+
+#include <netlink/netlink.h>
+#include <netlink/list.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @name Probability Constants
+ * @{
+ */
+
+/**
+ * Lower probability limit
+ * @ingroup utils
+ */
+#define NL_PROB_MIN 0x0
+
+/**
+ * Upper probability limit
+ * @ingroup utils
+ */
+#define NL_PROB_MAX 0xffffffff
+
+/** @} */
+
+/* unit pretty-printing */
+extern double nl_cancel_down_bytes(unsigned long long, char **);
+extern double nl_cancel_down_bits(unsigned long long, char **);
+extern double nl_cancel_down_us(uint32_t, char **);
+
+/* generic unit translations */
+extern long nl_size2int(const char *);
+extern long nl_prob2int(const char *);
+
+/* time translations */
+extern int nl_get_hz(void);
+extern uint32_t nl_us2ticks(uint32_t);
+extern uint32_t nl_ticks2us(uint32_t);
+extern int nl_str2msec(const char *, uint64_t *);
+extern char * nl_msec2str(uint64_t, char *, size_t);
+
+/* link layer protocol translations */
+extern char * nl_llproto2str(int, char *, size_t);
+extern int nl_str2llproto(const char *);
+
+/* ethernet protocol translations */
+extern char * nl_ether_proto2str(int, char *, size_t);
+extern int nl_str2ether_proto(const char *);
+
+/* IP protocol translations */
+extern char * nl_ip_proto2str(int, char *, size_t);
+extern int nl_str2ip_proto(const char *);
+
+/* Dumping helpers */
+extern void nl_new_line(struct nl_dump_params *);
+extern void nl_dump(struct nl_dump_params *, const char *, ...);
+extern void nl_dump_line(struct nl_dump_params *, const char *, ...);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/package/libs/libnl-tiny/src/include/netlink/version.h b/package/libs/libnl-tiny/src/include/netlink/version.h
new file mode 100644
index 0000000..6a316d4
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/netlink/version.h
@@ -0,0 +1,18 @@
+/*
+ * netlink/version.h Compile Time Versioning Information
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2008 Thomas Graf <tgraf@suug.ch>
+ */
+
+#ifndef NETLINK_VERSION_H_
+#define NETLINK_VERSION_H_
+
+#define LIBNL_STRING "libnl"
+#define LIBNL_VERSION "2.0"
+
+#endif
diff --git a/package/libs/libnl-tiny/src/include/unl.h b/package/libs/libnl-tiny/src/include/unl.h
new file mode 100644
index 0000000..4fe7dc7
--- /dev/null
+++ b/package/libs/libnl-tiny/src/include/unl.h
@@ -0,0 +1,47 @@
+#ifndef __UNL_H
+#define __UNL_H
+
+#include <netlink/netlink.h>
+#include <netlink/genl/genl.h>
+#include <netlink/genl/family.h>
+#include <stdbool.h>
+
+struct unl {
+ struct nl_sock *sock;
+ struct nl_cache *cache;
+ struct genl_family *family;
+ char *family_name;
+ int hdrlen;
+ bool loop_done;
+};
+
+int unl_genl_init(struct unl *unl, const char *family);
+void unl_free(struct unl *unl);
+
+typedef int (*unl_cb)(struct nl_msg *, void *);
+
+struct nl_msg *unl_genl_msg(struct unl *unl, int cmd, bool dump);
+int unl_genl_request(struct unl *unl, struct nl_msg *msg, unl_cb handler, void *arg);
+int unl_genl_request_single(struct unl *unl, struct nl_msg *msg, struct nl_msg **dest);
+void unl_genl_loop(struct unl *unl, unl_cb handler, void *arg);
+
+int unl_genl_multicast_id(struct unl *unl, const char *name);
+int unl_genl_subscribe(struct unl *unl, const char *name);
+int unl_genl_unsubscribe(struct unl *unl, const char *name);
+
+int unl_nl80211_phy_lookup(const char *name);
+int unl_nl80211_wdev_to_phy(struct unl *unl, int wdev);
+struct nl_msg *unl_nl80211_phy_msg(struct unl *unl, int phy, int cmd, bool dump);
+struct nl_msg *unl_nl80211_vif_msg(struct unl *unl, int dev, int cmd, bool dump);
+
+static inline void unl_loop_done(struct unl *unl)
+{
+ unl->loop_done = true;
+}
+
+static inline struct nlattr *unl_find_attr(struct unl *unl, struct nl_msg *msg, int attr)
+{
+ return nlmsg_find_attr(nlmsg_hdr(msg), unl->hdrlen, attr);
+}
+
+#endif
diff --git a/package/libs/libnl-tiny/src/msg.c b/package/libs/libnl-tiny/src/msg.c
new file mode 100644
index 0000000..e84c281
--- /dev/null
+++ b/package/libs/libnl-tiny/src/msg.c
@@ -0,0 +1,566 @@
+/*
+ * lib/msg.c Netlink Messages Interface
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
+ */
+
+/**
+ * @ingroup core
+ * @defgroup msg Messages
+ * Netlink Message Construction/Parsing Interface
+ *
+ * The following information is partly extracted from RFC3549
+ * (ftp://ftp.rfc-editor.org/in-notes/rfc3549.txt)
+ *
+ * @par Message Format
+ * Netlink messages consist of a byte stream with one or multiple
+ * Netlink headers and an associated payload. If the payload is too big
+ * to fit into a single message it, can be split over multiple Netlink
+ * messages, collectively called a multipart message. For multipart
+ * messages, the first and all following headers have the \c NLM_F_MULTI
+ * Netlink header flag set, except for the last header which has the
+ * Netlink header type \c NLMSG_DONE.
+ *
+ * @par
+ * The Netlink message header (\link nlmsghdr struct nlmsghdr\endlink) is shown below.
+ * @code
+ * 0 1 2 3
+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Length |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Type | Flags |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Sequence Number |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Process ID (PID) |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * @endcode
+ *
+ * @par
+ * The netlink message header and payload must be aligned properly:
+ * @code
+ * <------- NLMSG_ALIGN(hlen) ------> <---- NLMSG_ALIGN(len) --->
+ * +----------------------------+- - -+- - - - - - - - - - -+- - -+
+ * | Header | Pad | Payload | Pad |
+ * | struct nlmsghdr | | | |
+ * +----------------------------+- - -+- - - - - - - - - - -+- - -+
+ * @endcode
+ * @par
+ * Message Format:
+ * @code
+ * <--- nlmsg_total_size(payload) --->
+ * <-- nlmsg_msg_size(payload) ->
+ * +----------+- - -+-------------+- - -+-------- - -
+ * | nlmsghdr | Pad | Payload | Pad | nlmsghdr
+ * +----------+- - -+-------------+- - -+-------- - -
+ * nlmsg_data(nlh)---^ ^
+ * nlmsg_next(nlh)-----------------------+
+ * @endcode
+ * @par
+ * The payload may consist of arbitary data but may have strict
+ * alignment and formatting rules depening on the specific netlink
+ * families.
+ * @par
+ * @code
+ * <---------------------- nlmsg_len(nlh) --------------------->
+ * <------ hdrlen ------> <- nlmsg_attrlen(nlh, hdrlen) ->
+ * +----------------------+- - -+--------------------------------+
+ * | Family Header | Pad | Attributes |
+ * +----------------------+- - -+--------------------------------+
+ * nlmsg_attrdata(nlh, hdrlen)---^
+ * @endcode
+ * @par The ACK Netlink Message
+ * This message is actually used to denote both an ACK and a NACK.
+ * Typically, the direction is from FEC to CPC (in response to an ACK
+ * request message). However, the CPC should be able to send ACKs back
+ * to FEC when requested.
+ * @code
+ * 0 1 2 3
+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Netlink message header |
+ * | type = NLMSG_ERROR |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Error code |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | OLD Netlink message header |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * @endcode
+ *
+ * @par Example
+ * @code
+ * // Various methods exist to create/allocate a new netlink
+ * // message.
+ * //
+ * // nlmsg_alloc() will allocate an empty netlink message with
+ * // a maximum payload size which defaults to the page size of
+ * // the system. This default size can be modified using the
+ * // function nlmsg_set_default_size().
+ * struct nl_msg *msg = nlmsg_alloc();
+ *
+ * // Very often, the message type and message flags are known
+ * // at allocation time while the other fields are auto generated:
+ * struct nl_msg *msg = nlmsg_alloc_simple(MY_TYPE, MY_FLAGS);
+ *
+ * // Alternatively an existing netlink message header can be used
+ * // to inherit the header values:
+ * struct nlmsghdr hdr = {
+ * .nlmsg_type = MY_TYPE,
+ * .nlmsg_flags = MY_FLAGS,
+ * };
+ * struct nl_msg *msg = nlmsg_inherit(&hdr);
+ *
+ * // Last but not least, netlink messages received from netlink sockets
+ * // can be converted into nl_msg objects using nlmsg_convert(). This
+ * // will create a message with a maximum payload size which equals the
+ * // length of the existing netlink message, therefore no more data can
+ * // be appened without calling nlmsg_expand() first.
+ * struct nl_msg *msg = nlmsg_convert(nlh_from_nl_sock);
+ *
+ * // Payload may be added to the message via nlmsg_append(). The fourth
+ * // parameter specifies the number of alignment bytes the data should
+ * // be padding with at the end. Common values are 0 to disable it or
+ * // NLMSG_ALIGNTO to ensure proper netlink message padding.
+ * nlmsg_append(msg, &mydata, sizeof(mydata), 0);
+ *
+ * // Sometimes it may be necessary to reserve room for data but defer
+ * // the actual copying to a later point, nlmsg_reserve() can be used
+ * // for this purpose:
+ * void *data = nlmsg_reserve(msg, sizeof(mydata), NLMSG_ALIGNTO);
+ *
+ * // Attributes may be added using the attributes interface.
+ *
+ * // After successful use of the message, the memory must be freed
+ * // using nlmsg_free()
+ * nlmsg_free(msg);
+ * @endcode
+ *
+ * @par 4) Parsing messages
+ * @code
+ * int n;
+ * unsigned char *buf;
+ * struct nlmsghdr *hdr;
+ *
+ * n = nl_recv(handle, NULL, &buf);
+ *
+ * hdr = (struct nlmsghdr *) buf;
+ * while (nlmsg_ok(hdr, n)) {
+ * // Process message here...
+ * hdr = nlmsg_next(hdr, &n);
+ * }
+ * @endcode
+ * @{
+ */
+
+#include <netlink-local.h>
+#include <netlink/netlink.h>
+#include <netlink/utils.h>
+#include <netlink/cache.h>
+#include <netlink/attr.h>
+#include <netlink/msg.h>
+#include <linux/socket.h>
+
+static size_t default_msg_size;
+
+static void __init init_msg_size(void)
+{
+ default_msg_size = getpagesize();
+}
+
+/**
+ * @name Attribute Access
+ * @{
+ */
+
+//** @} */
+
+/**
+ * @name Message Parsing
+ * @{
+ */
+
+/**
+ * check if the netlink message fits into the remaining bytes
+ * @arg nlh netlink message header
+ * @arg remaining number of bytes remaining in message stream
+ */
+int nlmsg_ok(const struct nlmsghdr *nlh, int remaining)
+{
+ return (remaining >= sizeof(struct nlmsghdr) &&
+ nlh->nlmsg_len >= sizeof(struct nlmsghdr) &&
+ nlh->nlmsg_len <= remaining);
+}
+
+/**
+ * next netlink message in message stream
+ * @arg nlh netlink message header
+ * @arg remaining number of bytes remaining in message stream
+ *
+ * @returns the next netlink message in the message stream and
+ * decrements remaining by the size of the current message.
+ */
+struct nlmsghdr *nlmsg_next(struct nlmsghdr *nlh, int *remaining)
+{
+ int totlen = NLMSG_ALIGN(nlh->nlmsg_len);
+
+ *remaining -= totlen;
+
+ return (struct nlmsghdr *) ((unsigned char *) nlh + totlen);
+}
+
+/**
+ * parse attributes of a netlink message
+ * @arg nlh netlink message header
+ * @arg hdrlen length of family specific header
+ * @arg tb destination array with maxtype+1 elements
+ * @arg maxtype maximum attribute type to be expected
+ * @arg policy validation policy
+ *
+ * See nla_parse()
+ */
+int nlmsg_parse(struct nlmsghdr *nlh, int hdrlen, struct nlattr *tb[],
+ int maxtype, struct nla_policy *policy)
+{
+ if (!nlmsg_valid_hdr(nlh, hdrlen))
+ return -NLE_MSG_TOOSHORT;
+
+ return nla_parse(tb, maxtype, nlmsg_attrdata(nlh, hdrlen),
+ nlmsg_attrlen(nlh, hdrlen), policy);
+}
+
+/**
+ * nlmsg_validate - validate a netlink message including attributes
+ * @arg nlh netlinket message header
+ * @arg hdrlen length of familiy specific header
+ * @arg maxtype maximum attribute type to be expected
+ * @arg policy validation policy
+ */
+int nlmsg_validate(struct nlmsghdr *nlh, int hdrlen, int maxtype,
+ struct nla_policy *policy)
+{
+ if (!nlmsg_valid_hdr(nlh, hdrlen))
+ return -NLE_MSG_TOOSHORT;
+
+ return nla_validate(nlmsg_attrdata(nlh, hdrlen),
+ nlmsg_attrlen(nlh, hdrlen), maxtype, policy);
+}
+
+/** @} */
+
+/**
+ * @name Message Building/Access
+ * @{
+ */
+
+static struct nl_msg *__nlmsg_alloc(size_t len)
+{
+ struct nl_msg *nm;
+
+ nm = calloc(1, sizeof(*nm));
+ if (!nm)
+ goto errout;
+
+ nm->nm_refcnt = 1;
+
+ nm->nm_nlh = malloc(len);
+ if (!nm->nm_nlh)
+ goto errout;
+
+ memset(nm->nm_nlh, 0, sizeof(struct nlmsghdr));
+
+ nm->nm_protocol = -1;
+ nm->nm_size = len;
+ nm->nm_nlh->nlmsg_len = nlmsg_total_size(0);
+
+ NL_DBG(2, "msg %p: Allocated new message, maxlen=%zu\n", nm, len);
+
+ return nm;
+errout:
+ free(nm);
+ return NULL;
+}
+
+/**
+ * Allocate a new netlink message with the default maximum payload size.
+ *
+ * Allocates a new netlink message without any further payload. The
+ * maximum payload size defaults to PAGESIZE or as otherwise specified
+ * with nlmsg_set_default_size().
+ *
+ * @return Newly allocated netlink message or NULL.
+ */
+struct nl_msg *nlmsg_alloc(void)
+{
+ return __nlmsg_alloc(default_msg_size);
+}
+
+/**
+ * Allocate a new netlink message with maximum payload size specified.
+ */
+struct nl_msg *nlmsg_alloc_size(size_t max)
+{
+ return __nlmsg_alloc(max);
+}
+
+/**
+ * Allocate a new netlink message and inherit netlink message header
+ * @arg hdr Netlink message header template
+ *
+ * Allocates a new netlink message and inherits the original message
+ * header. If \a hdr is not NULL it will be used as a template for
+ * the netlink message header, otherwise the header is left blank.
+ *
+ * @return Newly allocated netlink message or NULL
+ */
+struct nl_msg *nlmsg_inherit(struct nlmsghdr *hdr)
+{
+ struct nl_msg *nm;
+
+ nm = nlmsg_alloc();
+ if (nm && hdr) {
+ struct nlmsghdr *new = nm->nm_nlh;
+
+ new->nlmsg_type = hdr->nlmsg_type;
+ new->nlmsg_flags = hdr->nlmsg_flags;
+ new->nlmsg_seq = hdr->nlmsg_seq;
+ new->nlmsg_pid = hdr->nlmsg_pid;
+ }
+
+ return nm;
+}
+
+/**
+ * Allocate a new netlink message
+ * @arg nlmsgtype Netlink message type
+ * @arg flags Message flags.
+ *
+ * @return Newly allocated netlink message or NULL.
+ */
+struct nl_msg *nlmsg_alloc_simple(int nlmsgtype, int flags)
+{
+ struct nl_msg *msg;
+ struct nlmsghdr nlh = {
+ .nlmsg_type = nlmsgtype,
+ .nlmsg_flags = flags,
+ };
+
+ msg = nlmsg_inherit(&nlh);
+ if (msg)
+ NL_DBG(2, "msg %p: Allocated new simple message\n", msg);
+
+ return msg;
+}
+
+/**
+ * Set the default maximum message payload size for allocated messages
+ * @arg max Size of payload in bytes.
+ */
+void nlmsg_set_default_size(size_t max)
+{
+ if (max < nlmsg_total_size(0))
+ max = nlmsg_total_size(0);
+
+ default_msg_size = max;
+}
+
+/**
+ * Convert a netlink message received from a netlink socket to a nl_msg
+ * @arg hdr Netlink message received from netlink socket.
+ *
+ * Allocates a new netlink message and copies all of the data pointed to
+ * by \a hdr into the new message object.
+ *
+ * @return Newly allocated netlink message or NULL.
+ */
+struct nl_msg *nlmsg_convert(struct nlmsghdr *hdr)
+{
+ struct nl_msg *nm;
+
+ nm = __nlmsg_alloc(NLMSG_ALIGN(hdr->nlmsg_len));
+ if (!nm)
+ goto errout;
+
+ memcpy(nm->nm_nlh, hdr, hdr->nlmsg_len);
+
+ return nm;
+errout:
+ nlmsg_free(nm);
+ return NULL;
+}
+
+/**
+ * Reserve room for additional data in a netlink message
+ * @arg n netlink message
+ * @arg len length of additional data to reserve room for
+ * @arg pad number of bytes to align data to
+ *
+ * Reserves room for additional data at the tail of the an
+ * existing netlink message. Eventual padding required will
+ * be zeroed out.
+ *
+ * @return Pointer to start of additional data tailroom or NULL.
+ */
+void *nlmsg_reserve(struct nl_msg *n, size_t len, int pad)
+{
+ void *buf = n->nm_nlh;
+ size_t nlmsg_len = n->nm_nlh->nlmsg_len;
+ size_t tlen;
+
+ tlen = pad ? ((len + (pad - 1)) & ~(pad - 1)) : len;
+
+ if ((tlen + nlmsg_len) > n->nm_size)
+ return NULL;
+
+ buf += nlmsg_len;
+ n->nm_nlh->nlmsg_len += tlen;
+
+ if (tlen > len)
+ memset(buf + len, 0, tlen - len);
+
+ NL_DBG(2, "msg %p: Reserved %zu bytes, pad=%d, nlmsg_len=%d\n",
+ n, len, pad, n->nm_nlh->nlmsg_len);
+
+ return buf;
+}
+
+/**
+ * Append data to tail of a netlink message
+ * @arg n netlink message
+ * @arg data data to add
+ * @arg len length of data
+ * @arg pad Number of bytes to align data to.
+ *
+ * Extends the netlink message as needed and appends the data of given
+ * length to the message.
+ *
+ * @return 0 on success or a negative error code
+ */
+int nlmsg_append(struct nl_msg *n, void *data, size_t len, int pad)
+{
+ void *tmp;
+
+ tmp = nlmsg_reserve(n, len, pad);
+ if (tmp == NULL)
+ return -NLE_NOMEM;
+
+ memcpy(tmp, data, len);
+ NL_DBG(2, "msg %p: Appended %zu bytes with padding %d\n", n, len, pad);
+
+ return 0;
+}
+
+/**
+ * Add a netlink message header to a netlink message
+ * @arg n netlink message
+ * @arg pid netlink process id or NL_AUTO_PID
+ * @arg seq sequence number of message or NL_AUTO_SEQ
+ * @arg type message type
+ * @arg payload length of message payload
+ * @arg flags message flags
+ *
+ * Adds or overwrites the netlink message header in an existing message
+ * object. If \a payload is greater-than zero additional room will be
+ * reserved, f.e. for family specific headers. It can be accesed via
+ * nlmsg_data().
+ *
+ * @return A pointer to the netlink message header or NULL.
+ */
+struct nlmsghdr *nlmsg_put(struct nl_msg *n, uint32_t pid, uint32_t seq,
+ int type, int payload, int flags)
+{
+ struct nlmsghdr *nlh;
+
+ if (n->nm_nlh->nlmsg_len < NLMSG_HDRLEN)
+ BUG();
+
+ nlh = (struct nlmsghdr *) n->nm_nlh;
+ nlh->nlmsg_type = type;
+ nlh->nlmsg_flags = flags;
+ nlh->nlmsg_pid = pid;
+ nlh->nlmsg_seq = seq;
+
+ NL_DBG(2, "msg %p: Added netlink header type=%d, flags=%d, pid=%d, "
+ "seq=%d\n", n, type, flags, pid, seq);
+
+ if (payload > 0 &&
+ nlmsg_reserve(n, payload, NLMSG_ALIGNTO) == NULL)
+ return NULL;
+
+ return nlh;
+}
+
+/**
+ * Release a reference from an netlink message
+ * @arg msg message to release reference from
+ *
+ * Frees memory after the last reference has been released.
+ */
+void nlmsg_free(struct nl_msg *msg)
+{
+ if (!msg)
+ return;
+
+ msg->nm_refcnt--;
+ NL_DBG(4, "Returned message reference %p, %d remaining\n",
+ msg, msg->nm_refcnt);
+
+ if (msg->nm_refcnt < 0)
+ BUG();
+
+ if (msg->nm_refcnt <= 0) {
+ free(msg->nm_nlh);
+ free(msg);
+ NL_DBG(2, "msg %p: Freed\n", msg);
+ }
+}
+
+/** @} */
+
+/**
+ * @name Direct Parsing
+ * @{
+ */
+
+/** @cond SKIP */
+struct dp_xdata {
+ void (*cb)(struct nl_object *, void *);
+ void *arg;
+};
+/** @endcond */
+
+static int parse_cb(struct nl_object *obj, struct nl_parser_param *p)
+{
+ struct dp_xdata *x = p->pp_arg;
+
+ x->cb(obj, x->arg);
+ return 0;
+}
+
+int nl_msg_parse(struct nl_msg *msg, void (*cb)(struct nl_object *, void *),
+ void *arg)
+{
+ struct nl_cache_ops *ops;
+ struct nl_parser_param p = {
+ .pp_cb = parse_cb
+ };
+ struct dp_xdata x = {
+ .cb = cb,
+ .arg = arg,
+ };
+
+ ops = nl_cache_ops_associate(nlmsg_get_proto(msg),
+ nlmsg_hdr(msg)->nlmsg_type);
+ if (ops == NULL)
+ return -NLE_MSGTYPE_NOSUPPORT;
+ p.pp_arg = &x;
+
+ return nl_cache_parse(ops, NULL, nlmsg_hdr(msg), &p);
+}
+
+/** @} */
diff --git a/package/libs/libnl-tiny/src/nl.c b/package/libs/libnl-tiny/src/nl.c
new file mode 100644
index 0000000..99e9aeb
--- /dev/null
+++ b/package/libs/libnl-tiny/src/nl.c
@@ -0,0 +1,720 @@
+/*
+ * lib/nl.c Core Netlink Interface
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
+ */
+
+/**
+ * @defgroup core Core
+ *
+ * @details
+ * @par 1) Connecting the socket
+ * @code
+ * // Bind and connect the socket to a protocol, NETLINK_ROUTE in this example.
+ * nl_connect(sk, NETLINK_ROUTE);
+ * @endcode
+ *
+ * @par 2) Sending data
+ * @code
+ * // The most rudimentary method is to use nl_sendto() simply pushing
+ * // a piece of data to the other netlink peer. This method is not
+ * // recommended.
+ * const char buf[] = { 0x01, 0x02, 0x03, 0x04 };
+ * nl_sendto(sk, buf, sizeof(buf));
+ *
+ * // A more comfortable interface is nl_send() taking a pointer to
+ * // a netlink message.
+ * struct nl_msg *msg = my_msg_builder();
+ * nl_send(sk, nlmsg_hdr(msg));
+ *
+ * // nl_sendmsg() provides additional control over the sendmsg() message
+ * // header in order to allow more specific addressing of multiple peers etc.
+ * struct msghdr hdr = { ... };
+ * nl_sendmsg(sk, nlmsg_hdr(msg), &hdr);
+ *
+ * // You're probably too lazy to fill out the netlink pid, sequence number
+ * // and message flags all the time. nl_send_auto_complete() automatically
+ * // extends your message header as needed with an appropriate sequence
+ * // number, the netlink pid stored in the netlink socket and the message
+ * // flags NLM_F_REQUEST and NLM_F_ACK (if not disabled in the socket)
+ * nl_send_auto_complete(sk, nlmsg_hdr(msg));
+ *
+ * // Simple protocols don't require the complex message construction interface
+ * // and may favour nl_send_simple() to easly send a bunch of payload
+ * // encapsulated in a netlink message header.
+ * nl_send_simple(sk, MY_MSG_TYPE, 0, buf, sizeof(buf));
+ * @endcode
+ *
+ * @par 3) Receiving data
+ * @code
+ * // nl_recv() receives a single message allocating a buffer for the message
+ * // content and gives back the pointer to you.
+ * struct sockaddr_nl peer;
+ * unsigned char *msg;
+ * nl_recv(sk, &peer, &msg);
+ *
+ * // nl_recvmsgs() receives a bunch of messages until the callback system
+ * // orders it to state, usually after receving a compolete multi part
+ * // message series.
+ * nl_recvmsgs(sk, my_callback_configuration);
+ *
+ * // nl_recvmsgs_default() acts just like nl_recvmsg() but uses the callback
+ * // configuration stored in the socket.
+ * nl_recvmsgs_default(sk);
+ *
+ * // In case you want to wait for the ACK to be recieved that you requested
+ * // with your latest message, you can call nl_wait_for_ack()
+ * nl_wait_for_ack(sk);
+ * @endcode
+ *
+ * @par 4) Closing
+ * @code
+ * // Close the socket first to release kernel memory
+ * nl_close(sk);
+ * @endcode
+ *
+ * @{
+ */
+
+#include <netlink-local.h>
+#include <netlink/netlink.h>
+#include <netlink/utils.h>
+#include <netlink/handlers.h>
+#include <netlink/msg.h>
+#include <netlink/attr.h>
+
+/**
+ * @name Connection Management
+ * @{
+ */
+
+/**
+ * Create and connect netlink socket.
+ * @arg sk Netlink socket.
+ * @arg protocol Netlink protocol to use.
+ *
+ * Creates a netlink socket using the specified protocol, binds the socket
+ * and issues a connection attempt.
+ *
+ * @return 0 on success or a negative error code.
+ */
+int nl_connect(struct nl_sock *sk, int protocol)
+{
+ int err;
+ socklen_t addrlen;
+
+ sk->s_fd = socket(AF_NETLINK, SOCK_RAW, protocol);
+ if (sk->s_fd < 0) {
+ err = -nl_syserr2nlerr(errno);
+ goto errout;
+ }
+
+ if (!(sk->s_flags & NL_SOCK_BUFSIZE_SET)) {
+ err = nl_socket_set_buffer_size(sk, 0, 0);
+ if (err < 0)
+ goto errout;
+ }
+
+ err = bind(sk->s_fd, (struct sockaddr*) &sk->s_local,
+ sizeof(sk->s_local));
+ if (err < 0) {
+ err = -nl_syserr2nlerr(errno);
+ goto errout;
+ }
+
+ addrlen = sizeof(sk->s_local);
+ err = getsockname(sk->s_fd, (struct sockaddr *) &sk->s_local,
+ &addrlen);
+ if (err < 0) {
+ err = -nl_syserr2nlerr(errno);
+ goto errout;
+ }
+
+ if (addrlen != sizeof(sk->s_local)) {
+ err = -NLE_NOADDR;
+ goto errout;
+ }
+
+ if (sk->s_local.nl_family != AF_NETLINK) {
+ err = -NLE_AF_NOSUPPORT;
+ goto errout;
+ }
+
+ sk->s_proto = protocol;
+
+ return 0;
+errout:
+ close(sk->s_fd);
+ sk->s_fd = -1;
+
+ return err;
+}
+
+/**
+ * Close/Disconnect netlink socket.
+ * @arg sk Netlink socket.
+ */
+void nl_close(struct nl_sock *sk)
+{
+ if (sk->s_fd >= 0) {
+ close(sk->s_fd);
+ sk->s_fd = -1;
+ }
+
+ sk->s_proto = 0;
+}
+
+/** @} */
+
+/**
+ * @name Send
+ * @{
+ */
+
+/**
+ * Send raw data over netlink socket.
+ * @arg sk Netlink socket.
+ * @arg buf Data buffer.
+ * @arg size Size of data buffer.
+ * @return Number of characters written on success or a negative error code.
+ */
+int nl_sendto(struct nl_sock *sk, void *buf, size_t size)
+{
+ int ret;
+
+ ret = sendto(sk->s_fd, buf, size, 0, (struct sockaddr *)
+ &sk->s_peer, sizeof(sk->s_peer));
+ if (ret < 0)
+ return -nl_syserr2nlerr(errno);
+
+ return ret;
+}
+
+/**
+ * Send netlink message with control over sendmsg() message header.
+ * @arg sk Netlink socket.
+ * @arg msg Netlink message to be sent.
+ * @arg hdr Sendmsg() message header.
+ * @return Number of characters sent on sucess or a negative error code.
+ */
+int nl_sendmsg(struct nl_sock *sk, struct nl_msg *msg, struct msghdr *hdr)
+{
+ struct nl_cb *cb;
+ int ret;
+
+ struct iovec iov = {
+ .iov_base = (void *) nlmsg_hdr(msg),
+ .iov_len = nlmsg_hdr(msg)->nlmsg_len,
+ };
+
+ hdr->msg_iov = &iov;
+ hdr->msg_iovlen = 1;
+
+ nlmsg_set_src(msg, &sk->s_local);
+
+ cb = sk->s_cb;
+ if (cb->cb_set[NL_CB_MSG_OUT])
+ if (nl_cb_call(cb, NL_CB_MSG_OUT, msg) != NL_OK)
+ return 0;
+
+ ret = sendmsg(sk->s_fd, hdr, 0);
+ if (ret < 0)
+ return -nl_syserr2nlerr(errno);
+
+ return ret;
+}
+
+
+/**
+ * Send netlink message.
+ * @arg sk Netlink socket.
+ * @arg msg Netlink message to be sent.
+ * @see nl_sendmsg()
+ * @return Number of characters sent on success or a negative error code.
+ */
+int nl_send(struct nl_sock *sk, struct nl_msg *msg)
+{
+ struct sockaddr_nl *dst;
+ struct ucred *creds;
+
+ struct msghdr hdr = {
+ .msg_name = (void *) &sk->s_peer,
+ .msg_namelen = sizeof(struct sockaddr_nl),
+ };
+
+ /* Overwrite destination if specified in the message itself, defaults
+ * to the peer address of the socket.
+ */
+ dst = nlmsg_get_dst(msg);
+ if (dst->nl_family == AF_NETLINK)
+ hdr.msg_name = dst;
+
+ /* Add credentials if present. */
+ creds = nlmsg_get_creds(msg);
+ if (creds != NULL) {
+ char buf[CMSG_SPACE(sizeof(struct ucred))];
+ struct cmsghdr *cmsg;
+
+ hdr.msg_control = buf;
+ hdr.msg_controllen = sizeof(buf);
+
+ cmsg = CMSG_FIRSTHDR(&hdr);
+ cmsg->cmsg_level = SOL_SOCKET;
+ cmsg->cmsg_type = SCM_CREDENTIALS;
+ cmsg->cmsg_len = CMSG_LEN(sizeof(struct ucred));
+ memcpy(CMSG_DATA(cmsg), creds, sizeof(struct ucred));
+ }
+
+ return nl_sendmsg(sk, msg, &hdr);
+}
+
+/**
+ * Send netlink message and check & extend header values as needed.
+ * @arg sk Netlink socket.
+ * @arg msg Netlink message to be sent.
+ *
+ * Checks the netlink message \c nlh for completness and extends it
+ * as required before sending it out. Checked fields include pid,
+ * sequence nr, and flags.
+ *
+ * @see nl_send()
+ * @return Number of characters sent or a negative error code.
+ */
+int nl_send_auto_complete(struct nl_sock *sk, struct nl_msg *msg)
+{
+ struct nlmsghdr *nlh;
+ struct nl_cb *cb = sk->s_cb;
+
+ nlh = nlmsg_hdr(msg);
+ if (nlh->nlmsg_pid == 0)
+ nlh->nlmsg_pid = sk->s_local.nl_pid;
+
+ if (nlh->nlmsg_seq == 0)
+ nlh->nlmsg_seq = sk->s_seq_next++;
+
+ if (msg->nm_protocol == -1)
+ msg->nm_protocol = sk->s_proto;
+
+ nlh->nlmsg_flags |= NLM_F_REQUEST;
+
+ if (!(sk->s_flags & NL_NO_AUTO_ACK))
+ nlh->nlmsg_flags |= NLM_F_ACK;
+
+ if (cb->cb_send_ow)
+ return cb->cb_send_ow(sk, msg);
+ else
+ return nl_send(sk, msg);
+}
+
+/**
+ * Send simple netlink message using nl_send_auto_complete()
+ * @arg sk Netlink socket.
+ * @arg type Netlink message type.
+ * @arg flags Netlink message flags.
+ * @arg buf Data buffer.
+ * @arg size Size of data buffer.
+ *
+ * Builds a netlink message with the specified type and flags and
+ * appends the specified data as payload to the message.
+ *
+ * @see nl_send_auto_complete()
+ * @return Number of characters sent on success or a negative error code.
+ */
+int nl_send_simple(struct nl_sock *sk, int type, int flags, void *buf,
+ size_t size)
+{
+ int err;
+ struct nl_msg *msg;
+
+ msg = nlmsg_alloc_simple(type, flags);
+ if (!msg)
+ return -NLE_NOMEM;
+
+ if (buf && size) {
+ err = nlmsg_append(msg, buf, size, NLMSG_ALIGNTO);
+ if (err < 0)
+ goto errout;
+ }
+
+
+ err = nl_send_auto_complete(sk, msg);
+errout:
+ nlmsg_free(msg);
+
+ return err;
+}
+
+/** @} */
+
+/**
+ * @name Receive
+ * @{
+ */
+
+/**
+ * Receive data from netlink socket
+ * @arg sk Netlink socket.
+ * @arg nla Destination pointer for peer's netlink address.
+ * @arg buf Destination pointer for message content.
+ * @arg creds Destination pointer for credentials.
+ *
+ * Receives a netlink message, allocates a buffer in \c *buf and
+ * stores the message content. The peer's netlink address is stored
+ * in \c *nla. The caller is responsible for freeing the buffer allocated
+ * in \c *buf if a positive value is returned. Interruped system calls
+ * are handled by repeating the read. The input buffer size is determined
+ * by peeking before the actual read is done.
+ *
+ * A non-blocking sockets causes the function to return immediately with
+ * a return value of 0 if no data is available.
+ *
+ * @return Number of octets read, 0 on EOF or a negative error code.
+ */
+int nl_recv(struct nl_sock *sk, struct sockaddr_nl *nla,
+ unsigned char **buf, struct ucred **creds)
+{
+ int n;
+ int flags = 0;
+ static int page_size = 0;
+ struct iovec iov;
+ struct msghdr msg = {
+ .msg_name = (void *) nla,
+ .msg_namelen = sizeof(struct sockaddr_nl),
+ .msg_iov = &iov,
+ .msg_iovlen = 1,
+ .msg_control = NULL,
+ .msg_controllen = 0,
+ .msg_flags = 0,
+ };
+ struct cmsghdr *cmsg;
+
+ if (sk->s_flags & NL_MSG_PEEK)
+ flags |= MSG_PEEK;
+
+ if (page_size == 0)
+ page_size = getpagesize();
+
+ iov.iov_len = page_size;
+ iov.iov_base = *buf = malloc(iov.iov_len);
+
+ if (sk->s_flags & NL_SOCK_PASSCRED) {
+ msg.msg_controllen = CMSG_SPACE(sizeof(struct ucred));
+ msg.msg_control = calloc(1, msg.msg_controllen);
+ }
+retry:
+
+ n = recvmsg(sk->s_fd, &msg, flags);
+ if (!n)
+ goto abort;
+ else if (n < 0) {
+ if (errno == EINTR) {
+ NL_DBG(3, "recvmsg() returned EINTR, retrying\n");
+ goto retry;
+ } else if (errno == EAGAIN) {
+ NL_DBG(3, "recvmsg() returned EAGAIN, aborting\n");
+ goto abort;
+ } else {
+ free(msg.msg_control);
+ free(*buf);
+ return -nl_syserr2nlerr(errno);
+ }
+ }
+
+ if (iov.iov_len < n ||
+ msg.msg_flags & MSG_TRUNC) {
+ /* Provided buffer is not long enough, enlarge it
+ * and try again. */
+ iov.iov_len *= 2;
+ iov.iov_base = *buf = realloc(*buf, iov.iov_len);
+ goto retry;
+ } else if (msg.msg_flags & MSG_CTRUNC) {
+ msg.msg_controllen *= 2;
+ msg.msg_control = realloc(msg.msg_control, msg.msg_controllen);
+ goto retry;
+ } else if (flags != 0) {
+ /* Buffer is big enough, do the actual reading */
+ flags = 0;
+ goto retry;
+ }
+
+ if (msg.msg_namelen != sizeof(struct sockaddr_nl)) {
+ free(msg.msg_control);
+ free(*buf);
+ return -NLE_NOADDR;
+ }
+
+ for (cmsg = CMSG_FIRSTHDR(&msg); cmsg; cmsg = CMSG_NXTHDR(&msg, cmsg)) {
+ if (cmsg->cmsg_level == SOL_SOCKET &&
+ cmsg->cmsg_type == SCM_CREDENTIALS) {
+ *creds = calloc(1, sizeof(struct ucred));
+ memcpy(*creds, CMSG_DATA(cmsg), sizeof(struct ucred));
+ break;
+ }
+ }
+
+ free(msg.msg_control);
+ return n;
+
+abort:
+ free(msg.msg_control);
+ free(*buf);
+ return 0;
+}
+
+#define NL_CB_CALL(cb, type, msg) \
+do { \
+ err = nl_cb_call(cb, type, msg); \
+ switch (err) { \
+ case NL_OK: \
+ err = 0; \
+ break; \
+ case NL_SKIP: \
+ goto skip; \
+ case NL_STOP: \
+ goto stop; \
+ default: \
+ goto out; \
+ } \
+} while (0)
+
+static int recvmsgs(struct nl_sock *sk, struct nl_cb *cb)
+{
+ int n, err = 0, multipart = 0;
+ unsigned char *buf = NULL;
+ struct nlmsghdr *hdr;
+ struct sockaddr_nl nla = {0};
+ struct nl_msg *msg = NULL;
+ struct ucred *creds = NULL;
+
+continue_reading:
+ NL_DBG(3, "Attempting to read from %p\n", sk);
+ if (cb->cb_recv_ow)
+ n = cb->cb_recv_ow(sk, &nla, &buf, &creds);
+ else
+ n = nl_recv(sk, &nla, &buf, &creds);
+
+ if (n <= 0)
+ return n;
+
+ NL_DBG(3, "recvmsgs(%p): Read %d bytes\n", sk, n);
+
+ hdr = (struct nlmsghdr *) buf;
+ while (nlmsg_ok(hdr, n)) {
+ NL_DBG(3, "recgmsgs(%p): Processing valid message...\n", sk);
+
+ nlmsg_free(msg);
+ msg = nlmsg_convert(hdr);
+ if (!msg) {
+ err = -NLE_NOMEM;
+ goto out;
+ }
+
+ nlmsg_set_proto(msg, sk->s_proto);
+ nlmsg_set_src(msg, &nla);
+ if (creds)
+ nlmsg_set_creds(msg, creds);
+
+ /* Raw callback is the first, it gives the most control
+ * to the user and he can do his very own parsing. */
+ if (cb->cb_set[NL_CB_MSG_IN])
+ NL_CB_CALL(cb, NL_CB_MSG_IN, msg);
+
+ /* Sequence number checking. The check may be done by
+ * the user, otherwise a very simple check is applied
+ * enforcing strict ordering */
+ if (cb->cb_set[NL_CB_SEQ_CHECK])
+ NL_CB_CALL(cb, NL_CB_SEQ_CHECK, msg);
+ else if (hdr->nlmsg_seq != sk->s_seq_expect) {
+ if (cb->cb_set[NL_CB_INVALID])
+ NL_CB_CALL(cb, NL_CB_INVALID, msg);
+ else {
+ err = -NLE_SEQ_MISMATCH;
+ goto out;
+ }
+ }
+
+ if (hdr->nlmsg_type == NLMSG_DONE ||
+ hdr->nlmsg_type == NLMSG_ERROR ||
+ hdr->nlmsg_type == NLMSG_NOOP ||
+ hdr->nlmsg_type == NLMSG_OVERRUN) {
+ /* We can't check for !NLM_F_MULTI since some netlink
+ * users in the kernel are broken. */
+ sk->s_seq_expect++;
+ NL_DBG(3, "recvmsgs(%p): Increased expected " \
+ "sequence number to %d\n",
+ sk, sk->s_seq_expect);
+ }
+
+ if (hdr->nlmsg_flags & NLM_F_MULTI)
+ multipart = 1;
+
+ /* Other side wishes to see an ack for this message */
+ if (hdr->nlmsg_flags & NLM_F_ACK) {
+ if (cb->cb_set[NL_CB_SEND_ACK])
+ NL_CB_CALL(cb, NL_CB_SEND_ACK, msg);
+ else {
+ /* FIXME: implement */
+ }
+ }
+
+ /* messages terminates a multpart message, this is
+ * usually the end of a message and therefore we slip
+ * out of the loop by default. the user may overrule
+ * this action by skipping this packet. */
+ if (hdr->nlmsg_type == NLMSG_DONE) {
+ multipart = 0;
+ if (cb->cb_set[NL_CB_FINISH])
+ NL_CB_CALL(cb, NL_CB_FINISH, msg);
+ }
+
+ /* Message to be ignored, the default action is to
+ * skip this message if no callback is specified. The
+ * user may overrule this action by returning
+ * NL_PROCEED. */
+ else if (hdr->nlmsg_type == NLMSG_NOOP) {
+ if (cb->cb_set[NL_CB_SKIPPED])
+ NL_CB_CALL(cb, NL_CB_SKIPPED, msg);
+ else
+ goto skip;
+ }
+
+ /* Data got lost, report back to user. The default action is to
+ * quit parsing. The user may overrule this action by retuning
+ * NL_SKIP or NL_PROCEED (dangerous) */
+ else if (hdr->nlmsg_type == NLMSG_OVERRUN) {
+ if (cb->cb_set[NL_CB_OVERRUN])
+ NL_CB_CALL(cb, NL_CB_OVERRUN, msg);
+ else {
+ err = -NLE_MSG_OVERFLOW;
+ goto out;
+ }
+ }
+
+ /* Message carries a nlmsgerr */
+ else if (hdr->nlmsg_type == NLMSG_ERROR) {
+ struct nlmsgerr *e = nlmsg_data(hdr);
+
+ if (hdr->nlmsg_len < nlmsg_msg_size(sizeof(*e))) {
+ /* Truncated error message, the default action
+ * is to stop parsing. The user may overrule
+ * this action by returning NL_SKIP or
+ * NL_PROCEED (dangerous) */
+ if (cb->cb_set[NL_CB_INVALID])
+ NL_CB_CALL(cb, NL_CB_INVALID, msg);
+ else {
+ err = -NLE_MSG_TRUNC;
+ goto out;
+ }
+ } else if (e->error) {
+ /* Error message reported back from kernel. */
+ if (cb->cb_err) {
+ err = cb->cb_err(&nla, e,
+ cb->cb_err_arg);
+ if (err < 0)
+ goto out;
+ else if (err == NL_SKIP)
+ goto skip;
+ else if (err == NL_STOP) {
+ err = -nl_syserr2nlerr(e->error);
+ goto out;
+ }
+ } else {
+ err = -nl_syserr2nlerr(e->error);
+ goto out;
+ }
+ } else if (cb->cb_set[NL_CB_ACK])
+ NL_CB_CALL(cb, NL_CB_ACK, msg);
+ } else {
+ /* Valid message (not checking for MULTIPART bit to
+ * get along with broken kernels. NL_SKIP has no
+ * effect on this. */
+ if (cb->cb_set[NL_CB_VALID])
+ NL_CB_CALL(cb, NL_CB_VALID, msg);
+ }
+skip:
+ err = 0;
+ hdr = nlmsg_next(hdr, &n);
+ }
+
+ nlmsg_free(msg);
+ free(buf);
+ free(creds);
+ buf = NULL;
+ msg = NULL;
+ creds = NULL;
+
+ if (multipart) {
+ /* Multipart message not yet complete, continue reading */
+ goto continue_reading;
+ }
+stop:
+ err = 0;
+out:
+ nlmsg_free(msg);
+ free(buf);
+ free(creds);
+
+ return err;
+}
+
+/**
+ * Receive a set of messages from a netlink socket.
+ * @arg sk Netlink socket.
+ * @arg cb set of callbacks to control behaviour.
+ *
+ * Repeatedly calls nl_recv() or the respective replacement if provided
+ * by the application (see nl_cb_overwrite_recv()) and parses the
+ * received data as netlink messages. Stops reading if one of the
+ * callbacks returns NL_STOP or nl_recv returns either 0 or a negative error code.
+ *
+ * A non-blocking sockets causes the function to return immediately if
+ * no data is available.
+ *
+ * @return 0 on success or a negative error code from nl_recv().
+ */
+int nl_recvmsgs(struct nl_sock *sk, struct nl_cb *cb)
+{
+ if (cb->cb_recvmsgs_ow)
+ return cb->cb_recvmsgs_ow(sk, cb);
+ else
+ return recvmsgs(sk, cb);
+}
+
+
+static int ack_wait_handler(struct nl_msg *msg, void *arg)
+{
+ return NL_STOP;
+}
+
+/**
+ * Wait for ACK.
+ * @arg sk Netlink socket.
+ * @pre The netlink socket must be in blocking state.
+ *
+ * Waits until an ACK is received for the latest not yet acknowledged
+ * netlink message.
+ */
+int nl_wait_for_ack(struct nl_sock *sk)
+{
+ int err;
+ struct nl_cb *cb;
+
+ cb = nl_cb_clone(sk->s_cb);
+ if (cb == NULL)
+ return -NLE_NOMEM;
+
+ nl_cb_set(cb, NL_CB_ACK, NL_CB_CUSTOM, ack_wait_handler, NULL);
+ err = nl_recvmsgs(sk, cb);
+ nl_cb_put(cb);
+
+ return err;
+}
+
+/** @} */
+
+/** @} */
diff --git a/package/libs/libnl-tiny/src/object.c b/package/libs/libnl-tiny/src/object.c
new file mode 100644
index 0000000..f915551
--- /dev/null
+++ b/package/libs/libnl-tiny/src/object.c
@@ -0,0 +1,279 @@
+/*
+ * lib/object.c Generic Cacheable Object
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
+ */
+
+/**
+ * @ingroup cache
+ * @defgroup object Object
+ * @{
+ */
+
+#include <netlink-local.h>
+#include <netlink/netlink.h>
+#include <netlink/cache.h>
+#include <netlink/object.h>
+#include <netlink/utils.h>
+
+static inline struct nl_object_ops *obj_ops(struct nl_object *obj)
+{
+ if (!obj->ce_ops)
+ BUG();
+
+ return obj->ce_ops;
+}
+
+/**
+ * @name Object Creation/Deletion
+ * @{
+ */
+
+/**
+ * Allocate a new object of kind specified by the operations handle
+ * @arg ops cache operations handle
+ * @return The new object or NULL
+ */
+struct nl_object *nl_object_alloc(struct nl_object_ops *ops)
+{
+ struct nl_object *new;
+
+ if (ops->oo_size < sizeof(*new))
+ BUG();
+
+ new = calloc(1, ops->oo_size);
+ if (!new)
+ return NULL;
+
+ new->ce_refcnt = 1;
+ nl_init_list_head(&new->ce_list);
+
+ new->ce_ops = ops;
+ if (ops->oo_constructor)
+ ops->oo_constructor(new);
+
+ NL_DBG(4, "Allocated new object %p\n", new);
+
+ return new;
+}
+
+#ifdef disabled
+/**
+ * Allocate a new object of kind specified by the name
+ * @arg kind name of object type
+ * @return The new object or nULL
+ */
+int nl_object_alloc_name(const char *kind, struct nl_object **result)
+{
+ struct nl_cache_ops *ops;
+
+ ops = nl_cache_ops_lookup(kind);
+ if (!ops)
+ return -NLE_OPNOTSUPP;
+
+ if (!(*result = nl_object_alloc(ops->co_obj_ops)))
+ return -NLE_NOMEM;
+
+ return 0;
+}
+#endif
+
+struct nl_derived_object {
+ NLHDR_COMMON
+ char data;
+};
+
+/**
+ * Allocate a new object and copy all data from an existing object
+ * @arg obj object to inherite data from
+ * @return The new object or NULL.
+ */
+struct nl_object *nl_object_clone(struct nl_object *obj)
+{
+ struct nl_object *new;
+ struct nl_object_ops *ops = obj_ops(obj);
+ int doff = offsetof(struct nl_derived_object, data);
+ int size;
+
+ new = nl_object_alloc(ops);
+ if (!new)
+ return NULL;
+
+ size = ops->oo_size - doff;
+ if (size < 0)
+ BUG();
+
+ new->ce_ops = obj->ce_ops;
+ new->ce_msgtype = obj->ce_msgtype;
+
+ if (size)
+ memcpy((void *)new + doff, (void *)obj + doff, size);
+
+ if (ops->oo_clone) {
+ if (ops->oo_clone(new, obj) < 0) {
+ nl_object_free(new);
+ return NULL;
+ }
+ } else if (size && ops->oo_free_data)
+ BUG();
+
+ return new;
+}
+
+/**
+ * Free a cacheable object
+ * @arg obj object to free
+ *
+ * @return 0 or a negative error code.
+ */
+void nl_object_free(struct nl_object *obj)
+{
+ struct nl_object_ops *ops = obj_ops(obj);
+
+ if (obj->ce_refcnt > 0)
+ NL_DBG(1, "Warning: Freeing object in use...\n");
+
+ if (obj->ce_cache)
+ nl_cache_remove(obj);
+
+ if (ops->oo_free_data)
+ ops->oo_free_data(obj);
+
+ free(obj);
+
+ NL_DBG(4, "Freed object %p\n", obj);
+}
+
+/** @} */
+
+/**
+ * @name Reference Management
+ * @{
+ */
+
+/** @} */
+
+/**
+ * @name Utillities
+ * @{
+ */
+
+#ifdef disabled
+/**
+ * Dump this object according to the specified parameters
+ * @arg obj object to dump
+ * @arg params dumping parameters
+ */
+void nl_object_dump(struct nl_object *obj, struct nl_dump_params *params)
+{
+ dump_from_ops(obj, params);
+}
+
+/**
+ * Check if the identifiers of two objects are identical
+ * @arg a an object
+ * @arg b another object of same type
+ *
+ * @return true if both objects have equal identifiers, otherwise false.
+ */
+int nl_object_identical(struct nl_object *a, struct nl_object *b)
+{
+ struct nl_object_ops *ops = obj_ops(a);
+ int req_attrs;
+
+ /* Both objects must be of same type */
+ if (ops != obj_ops(b))
+ return 0;
+
+ req_attrs = ops->oo_id_attrs;
+
+ /* Both objects must provide all required attributes to uniquely
+ * identify an object */
+ if ((a->ce_mask & req_attrs) != req_attrs ||
+ (b->ce_mask & req_attrs) != req_attrs)
+ return 0;
+
+ /* Can't judge unless we can compare */
+ if (ops->oo_compare == NULL)
+ return 0;
+
+ return !(ops->oo_compare(a, b, req_attrs, 0));
+}
+
+/**
+ * Compute bitmask representing difference in attribute values
+ * @arg a an object
+ * @arg b another object of same type
+ *
+ * The bitmask returned is specific to an object type, each bit set represents
+ * an attribute which mismatches in either of the two objects. Unavailability
+ * of an attribute in one object and presence in the other is regarded a
+ * mismatch as well.
+ *
+ * @return Bitmask describing differences or 0 if they are completely identical.
+ */
+uint32_t nl_object_diff(struct nl_object *a, struct nl_object *b)
+{
+ struct nl_object_ops *ops = obj_ops(a);
+
+ if (ops != obj_ops(b) || ops->oo_compare == NULL)
+ return UINT_MAX;
+
+ return ops->oo_compare(a, b, ~0, 0);
+}
+
+/**
+ * Match a filter against an object
+ * @arg obj object to check
+ * @arg filter object of same type acting as filter
+ *
+ * @return 1 if the object matches the filter or 0
+ * if no filter procedure is available or if the
+ * filter does not match.
+ */
+int nl_object_match_filter(struct nl_object *obj, struct nl_object *filter)
+{
+ struct nl_object_ops *ops = obj_ops(obj);
+
+ if (ops != obj_ops(filter) || ops->oo_compare == NULL)
+ return 0;
+
+ return !(ops->oo_compare(obj, filter, filter->ce_mask,
+ LOOSE_COMPARISON));
+}
+
+/**
+ * Convert bitmask of attributes to a character string
+ * @arg obj object of same type as attribute bitmask
+ * @arg attrs bitmask of attribute types
+ * @arg buf destination buffer
+ * @arg len length of destination buffer
+ *
+ * Converts the bitmask of attribute types into a list of attribute
+ * names separated by comas.
+ *
+ * @return destination buffer.
+ */
+char *nl_object_attrs2str(struct nl_object *obj, uint32_t attrs,
+ char *buf, size_t len)
+{
+ struct nl_object_ops *ops = obj_ops(obj);
+
+ if (ops->oo_attrs2str != NULL)
+ return ops->oo_attrs2str(attrs, buf, len);
+ else {
+ memset(buf, 0, len);
+ return buf;
+ }
+}
+
+#endif
+
+/** @} */
+
+/** @} */
diff --git a/package/libs/libnl-tiny/src/socket.c b/package/libs/libnl-tiny/src/socket.c
new file mode 100644
index 0000000..1429825
--- /dev/null
+++ b/package/libs/libnl-tiny/src/socket.c
@@ -0,0 +1,406 @@
+/*
+ * lib/socket.c Netlink Socket
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
+ */
+
+/**
+ * @ingroup core
+ * @defgroup socket Socket
+ * @{
+ */
+
+#include <netlink-local.h>
+#include <netlink/netlink.h>
+#include <netlink/utils.h>
+#include <netlink/handlers.h>
+#include <netlink/msg.h>
+#include <netlink/attr.h>
+
+static uint32_t used_ports_map[32];
+
+static uint32_t generate_local_port(void)
+{
+ int i, n;
+ uint32_t pid = getpid() & 0x3FFFFF;
+
+ for (i = 0; i < 32; i++) {
+ if (used_ports_map[i] == 0xFFFFFFFF)
+ continue;
+
+ for (n = 0; n < 32; n++) {
+ if (1UL & (used_ports_map[i] >> n))
+ continue;
+
+ used_ports_map[i] |= (1UL << n);
+ n += (i * 32);
+
+ /* PID_MAX_LIMIT is currently at 2^22, leaving 10 bit
+ * to, i.e. 1024 unique ports per application. */
+ return pid + (n << 22);
+
+ }
+ }
+
+ /* Out of sockets in our own PID namespace, what to do? FIXME */
+ return UINT_MAX;
+}
+
+static void release_local_port(uint32_t port)
+{
+ int nr;
+
+ if (port == UINT_MAX)
+ return;
+
+ nr = port >> 22;
+ used_ports_map[nr / 32] &= ~(1 << nr % 32);
+}
+
+/**
+ * @name Allocation
+ * @{
+ */
+
+static struct nl_sock *__alloc_socket(struct nl_cb *cb)
+{
+ struct nl_sock *sk;
+
+ sk = calloc(1, sizeof(*sk));
+ if (!sk)
+ return NULL;
+
+ sk->s_fd = -1;
+ sk->s_cb = cb;
+ sk->s_local.nl_family = AF_NETLINK;
+ sk->s_peer.nl_family = AF_NETLINK;
+ sk->s_seq_expect = sk->s_seq_next = time(0);
+ sk->s_local.nl_pid = generate_local_port();
+ if (sk->s_local.nl_pid == UINT_MAX) {
+ nl_socket_free(sk);
+ return NULL;
+ }
+
+ return sk;
+}
+
+/**
+ * Allocate new netlink socket
+ *
+ * @return Newly allocated netlink socket or NULL.
+ */
+struct nl_sock *nl_socket_alloc(void)
+{
+ struct nl_cb *cb;
+
+ cb = nl_cb_alloc(NL_CB_DEFAULT);
+ if (!cb)
+ return NULL;
+
+ return __alloc_socket(cb);
+}
+
+/**
+ * Allocate new socket with custom callbacks
+ * @arg cb Callback handler
+ *
+ * The reference to the callback handler is taken into account
+ * automatically, it is released again upon calling nl_socket_free().
+ *
+ *@return Newly allocted socket handle or NULL.
+ */
+struct nl_sock *nl_socket_alloc_cb(struct nl_cb *cb)
+{
+ if (cb == NULL)
+ BUG();
+
+ return __alloc_socket(nl_cb_get(cb));
+}
+
+/**
+ * Free a netlink socket.
+ * @arg sk Netlink socket.
+ */
+void nl_socket_free(struct nl_sock *sk)
+{
+ if (!sk)
+ return;
+
+ if (sk->s_fd >= 0)
+ close(sk->s_fd);
+
+ if (!(sk->s_flags & NL_OWN_PORT))
+ release_local_port(sk->s_local.nl_pid);
+
+ nl_cb_put(sk->s_cb);
+ free(sk);
+}
+
+/** @} */
+
+/**
+ * @name Sequence Numbers
+ * @{
+ */
+
+static int noop_seq_check(struct nl_msg *msg, void *arg)
+{
+ return NL_OK;
+}
+
+
+/**
+ * Disable sequence number checking.
+ * @arg sk Netlink socket.
+ *
+ * Disables checking of sequence numbers on the netlink socket This is
+ * required to allow messages to be processed which were not requested by
+ * a preceding request message, e.g. netlink events.
+ *
+ * @note This function modifies the NL_CB_SEQ_CHECK configuration in
+ * the callback handle associated with the socket.
+ */
+void nl_socket_disable_seq_check(struct nl_sock *sk)
+{
+ nl_cb_set(sk->s_cb, NL_CB_SEQ_CHECK,
+ NL_CB_CUSTOM, noop_seq_check, NULL);
+}
+
+/** @} */
+
+/**
+ * Set local port of socket
+ * @arg sk Netlink socket.
+ * @arg port Local port identifier
+ *
+ * Assigns a local port identifier to the socket. If port is 0
+ * a unique port identifier will be generated automatically.
+ */
+void nl_socket_set_local_port(struct nl_sock *sk, uint32_t port)
+{
+ if (port == 0) {
+ port = generate_local_port();
+ sk->s_flags &= ~NL_OWN_PORT;
+ } else {
+ if (!(sk->s_flags & NL_OWN_PORT))
+ release_local_port(sk->s_local.nl_pid);
+ sk->s_flags |= NL_OWN_PORT;
+ }
+
+ sk->s_local.nl_pid = port;
+}
+
+/** @} */
+
+/**
+ * @name Group Subscriptions
+ * @{
+ */
+
+/**
+ * Join groups
+ * @arg sk Netlink socket
+ * @arg group Group identifier
+ *
+ * Joins the specified groups using the modern socket option which
+ * is available since kernel version 2.6.14. It allows joining an
+ * almost arbitary number of groups without limitation. The list
+ * of groups has to be terminated by 0 (%NFNLGRP_NONE).
+ *
+ * Make sure to use the correct group definitions as the older
+ * bitmask definitions for nl_join_groups() are likely to still
+ * be present for backward compatibility reasons.
+ *
+ * @return 0 on sucess or a negative error code.
+ */
+int nl_socket_add_memberships(struct nl_sock *sk, int group, ...)
+{
+ int err;
+ va_list ap;
+
+ if (sk->s_fd == -1)
+ return -NLE_BAD_SOCK;
+
+ va_start(ap, group);
+
+ while (group != 0) {
+ if (group < 0)
+ return -NLE_INVAL;
+
+ err = setsockopt(sk->s_fd, SOL_NETLINK, NETLINK_ADD_MEMBERSHIP,
+ &group, sizeof(group));
+ if (err < 0)
+ return -nl_syserr2nlerr(errno);
+
+ group = va_arg(ap, int);
+ }
+
+ va_end(ap);
+
+ return 0;
+}
+
+/**
+ * Leave groups
+ * @arg sk Netlink socket
+ * @arg group Group identifier
+ *
+ * Leaves the specified groups using the modern socket option
+ * which is available since kernel version 2.6.14. The list of groups
+ * has to terminated by 0 (%NFNLGRP_NONE).
+ *
+ * @see nl_socket_add_membership
+ * @return 0 on success or a negative error code.
+ */
+int nl_socket_drop_memberships(struct nl_sock *sk, int group, ...)
+{
+ int err;
+ va_list ap;
+
+ if (sk->s_fd == -1)
+ return -NLE_BAD_SOCK;
+
+ va_start(ap, group);
+
+ while (group != 0) {
+ if (group < 0)
+ return -NLE_INVAL;
+
+ err = setsockopt(sk->s_fd, SOL_NETLINK, NETLINK_DROP_MEMBERSHIP,
+ &group, sizeof(group));
+ if (err < 0)
+ return -nl_syserr2nlerr(errno);
+
+ group = va_arg(ap, int);
+ }
+
+ va_end(ap);
+
+ return 0;
+}
+
+
+/** @} */
+
+/**
+ * Set file descriptor of socket to non-blocking state
+ * @arg sk Netlink socket.
+ *
+ * @return 0 on success or a negative error code.
+ */
+int nl_socket_set_nonblocking(struct nl_sock *sk)
+{
+ if (sk->s_fd == -1)
+ return -NLE_BAD_SOCK;
+
+ if (fcntl(sk->s_fd, F_SETFL, O_NONBLOCK) < 0)
+ return -nl_syserr2nlerr(errno);
+
+ return 0;
+}
+
+/** @} */
+
+/**
+ * @name Utilities
+ * @{
+ */
+
+/**
+ * Set socket buffer size of netlink socket.
+ * @arg sk Netlink socket.
+ * @arg rxbuf New receive socket buffer size in bytes.
+ * @arg txbuf New transmit socket buffer size in bytes.
+ *
+ * Sets the socket buffer size of a netlink socket to the specified
+ * values \c rxbuf and \c txbuf. Providing a value of \c 0 assumes a
+ * good default value.
+ *
+ * @note It is not required to call this function prior to nl_connect().
+ * @return 0 on sucess or a negative error code.
+ */
+int nl_socket_set_buffer_size(struct nl_sock *sk, int rxbuf, int txbuf)
+{
+ int err;
+
+ if (rxbuf <= 0)
+ rxbuf = 32768;
+
+ if (txbuf <= 0)
+ txbuf = 32768;
+
+ if (sk->s_fd == -1)
+ return -NLE_BAD_SOCK;
+
+ err = setsockopt(sk->s_fd, SOL_SOCKET, SO_SNDBUF,
+ &txbuf, sizeof(txbuf));
+ if (err < 0)
+ return -nl_syserr2nlerr(errno);
+
+ err = setsockopt(sk->s_fd, SOL_SOCKET, SO_RCVBUF,
+ &rxbuf, sizeof(rxbuf));
+ if (err < 0)
+ return -nl_syserr2nlerr(errno);
+
+ sk->s_flags |= NL_SOCK_BUFSIZE_SET;
+
+ return 0;
+}
+
+/**
+ * Enable/disable credential passing on netlink socket.
+ * @arg sk Netlink socket.
+ * @arg state New state (0 - disabled, 1 - enabled)
+ *
+ * @return 0 on success or a negative error code
+ */
+int nl_socket_set_passcred(struct nl_sock *sk, int state)
+{
+ int err;
+
+ if (sk->s_fd == -1)
+ return -NLE_BAD_SOCK;
+
+ err = setsockopt(sk->s_fd, SOL_SOCKET, SO_PASSCRED,
+ &state, sizeof(state));
+ if (err < 0)
+ return -nl_syserr2nlerr(errno);
+
+ if (state)
+ sk->s_flags |= NL_SOCK_PASSCRED;
+ else
+ sk->s_flags &= ~NL_SOCK_PASSCRED;
+
+ return 0;
+}
+
+/**
+ * Enable/disable receival of additional packet information
+ * @arg sk Netlink socket.
+ * @arg state New state (0 - disabled, 1 - enabled)
+ *
+ * @return 0 on success or a negative error code
+ */
+int nl_socket_recv_pktinfo(struct nl_sock *sk, int state)
+{
+ int err;
+
+ if (sk->s_fd == -1)
+ return -NLE_BAD_SOCK;
+
+ err = setsockopt(sk->s_fd, SOL_NETLINK, NETLINK_PKTINFO,
+ &state, sizeof(state));
+ if (err < 0)
+ return -nl_syserr2nlerr(errno);
+
+ return 0;
+}
+
+/** @} */
+
+/** @} */
diff --git a/package/libs/libnl-tiny/src/unl.c b/package/libs/libnl-tiny/src/unl.c
new file mode 100644
index 0000000..b38dab8
--- /dev/null
+++ b/package/libs/libnl-tiny/src/unl.c
@@ -0,0 +1,290 @@
+#define _GNU_SOURCE
+#include <netlink/netlink.h>
+#include <netlink/genl/genl.h>
+#include <netlink/genl/ctrl.h>
+#include <netlink/genl/family.h>
+#include <sys/types.h>
+#include <net/if.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <linux/nl80211.h>
+
+#include "unl.h"
+
+static int unl_init(struct unl *unl)
+{
+ unl->sock = nl_socket_alloc();
+ if (!unl->sock)
+ return -1;
+
+ return 0;
+}
+
+int unl_genl_init(struct unl *unl, const char *family)
+{
+ memset(unl, 0, sizeof(*unl));
+
+ if (unl_init(unl))
+ goto error_out;
+
+ unl->hdrlen = NLMSG_ALIGN(sizeof(struct genlmsghdr));
+ unl->family_name = strdup(family);
+ if (!unl->family_name)
+ goto error;
+
+ if (genl_connect(unl->sock))
+ goto error;
+
+ if (genl_ctrl_alloc_cache(unl->sock, &unl->cache))
+ goto error;
+
+ unl->family = genl_ctrl_search_by_name(unl->cache, family);
+ if (!unl->family)
+ goto error;
+
+ return 0;
+
+error:
+ unl_free(unl);
+error_out:
+ return -1;
+}
+
+void unl_free(struct unl *unl)
+{
+ if (unl->family_name)
+ free(unl->family_name);
+
+ if (unl->sock)
+ nl_socket_free(unl->sock);
+
+ if (unl->cache)
+ nl_cache_free(unl->cache);
+
+ memset(unl, 0, sizeof(*unl));
+}
+
+static int
+ack_handler(struct nl_msg *msg, void *arg)
+{
+ int *err = arg;
+ *err = 0;
+ return NL_STOP;
+}
+
+static int
+finish_handler(struct nl_msg *msg, void *arg)
+{
+ int *err = arg;
+ *err = 0;
+ return NL_SKIP;
+}
+
+static int
+error_handler(struct sockaddr_nl *nla, struct nlmsgerr *err, void *arg)
+{
+ int *ret = arg;
+ *ret = err->error;
+ return NL_SKIP;
+}
+
+struct nl_msg *unl_genl_msg(struct unl *unl, int cmd, bool dump)
+{
+ struct nl_msg *msg;
+ int flags = 0;
+
+ msg = nlmsg_alloc();
+ if (!msg)
+ goto out;
+
+ if (dump)
+ flags |= NLM_F_DUMP;
+
+ genlmsg_put(msg, NL_AUTO_PID, NL_AUTO_SEQ,
+ genl_family_get_id(unl->family), 0, flags, cmd, 0);
+
+out:
+ return msg;
+}
+
+int unl_genl_request(struct unl *unl, struct nl_msg *msg, unl_cb handler, void *arg)
+{
+ struct nlmsghdr *nlh;
+ struct nl_cb *cb;
+ int err;
+
+ cb = nl_cb_alloc(NL_CB_CUSTOM);
+ nlh = nlmsg_hdr(msg);
+
+ err = nl_send_auto_complete(unl->sock, msg);
+ if (err < 0)
+ goto out;
+
+ err = 1;
+ nl_cb_err(cb, NL_CB_CUSTOM, error_handler, &err);
+ nl_cb_set(cb, NL_CB_FINISH, NL_CB_CUSTOM, finish_handler, &err);
+ nl_cb_set(cb, NL_CB_ACK, NL_CB_CUSTOM, ack_handler, &err);
+ if (handler)
+ nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, handler, arg);
+
+ while (err > 0)
+ nl_recvmsgs(unl->sock, cb);
+
+out:
+ nlmsg_free(msg);
+ nl_cb_put(cb);
+ return err;
+}
+
+static int request_single_cb(struct nl_msg *msg, void *arg)
+{
+ struct nl_msg **dest = arg;
+
+ if (!*dest) {
+ nlmsg_get(msg);
+ *dest = msg;
+ }
+ return NL_SKIP;
+}
+
+int unl_genl_request_single(struct unl *unl, struct nl_msg *msg, struct nl_msg **dest)
+{
+ *dest = NULL;
+ return unl_genl_request(unl, msg, request_single_cb, dest);
+}
+
+static int no_seq_check(struct nl_msg *msg, void *arg)
+{
+ return NL_OK;
+}
+
+void unl_genl_loop(struct unl *unl, unl_cb handler, void *arg)
+{
+ struct nl_cb *cb;
+
+ cb = nl_cb_alloc(NL_CB_CUSTOM);
+ unl->loop_done = false;
+ nl_cb_set(cb, NL_CB_SEQ_CHECK, NL_CB_CUSTOM, no_seq_check, NULL);
+ nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, handler, arg);
+
+ while (!unl->loop_done)
+ nl_recvmsgs(unl->sock, cb);
+
+ nl_cb_put(cb);
+}
+
+int unl_genl_multicast_id(struct unl *unl, const char *name)
+{
+ struct nlattr *tb[CTRL_ATTR_MCAST_GRP_MAX + 1];
+ struct nlattr *groups, *group;
+ struct nl_msg *msg;
+ int ctrlid;
+ int ret = -1;
+ int rem;
+
+ msg = nlmsg_alloc();
+ if (!msg)
+ return -1;
+
+ ctrlid = genl_ctrl_resolve(unl->sock, "nlctrl");
+ genlmsg_put(msg, 0, 0, ctrlid, 0, 0, CTRL_CMD_GETFAMILY, 0);
+ NLA_PUT_STRING(msg, CTRL_ATTR_FAMILY_NAME, unl->family_name);
+ unl_genl_request_single(unl, msg, &msg);
+ if (!msg)
+ return -1;
+
+ groups = unl_find_attr(unl, msg, CTRL_ATTR_MCAST_GROUPS);
+ if (!groups)
+ goto nla_put_failure;
+
+ nla_for_each_nested(group, groups, rem) {
+ const char *gn;
+
+ nla_parse(tb, CTRL_ATTR_MCAST_GRP_MAX, nla_data(group),
+ nla_len(group), NULL);
+
+ if (!tb[CTRL_ATTR_MCAST_GRP_NAME] ||
+ !tb[CTRL_ATTR_MCAST_GRP_ID])
+ continue;
+
+ gn = nla_data(tb[CTRL_ATTR_MCAST_GRP_NAME]);
+ if (strcmp(gn, name) != 0)
+ continue;
+
+ ret = nla_get_u32(tb[CTRL_ATTR_MCAST_GRP_ID]);
+ break;
+ }
+
+nla_put_failure:
+ nlmsg_free(msg);
+ return ret;
+}
+
+int unl_genl_subscribe(struct unl *unl, const char *name)
+{
+ int mcid;
+
+ mcid = unl_genl_multicast_id(unl, name);
+ if (mcid < 0)
+ return mcid;
+
+ return nl_socket_add_membership(unl->sock, mcid);
+}
+
+int unl_genl_unsubscribe(struct unl *unl, const char *name)
+{
+ int mcid;
+
+ mcid = unl_genl_multicast_id(unl, name);
+ if (mcid < 0)
+ return mcid;
+
+ return nl_socket_drop_membership(unl->sock, mcid);
+}
+
+int unl_nl80211_phy_lookup(const char *name)
+{
+ char buf[32];
+ int fd, pos;
+
+ snprintf(buf, sizeof(buf), "/sys/class/ieee80211/%s/index", name);
+
+ fd = open(buf, O_RDONLY);
+ if (fd < 0)
+ return -1;
+ pos = read(fd, buf, sizeof(buf) - 1);
+ if (pos < 0) {
+ close(fd);
+ return -1;
+ }
+ buf[pos] = '\0';
+ close(fd);
+ return atoi(buf);
+}
+
+int unl_nl80211_wdev_to_phy(struct unl *unl, int wdev)
+{
+ struct nl_msg *msg;
+ struct nlattr *attr;
+ int ret = -1;
+
+ msg = unl_genl_msg(unl, NL80211_CMD_GET_INTERFACE, false);
+ if (!msg)
+ return -1;
+
+ NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, wdev);
+ if (unl_genl_request_single(unl, msg, &msg) < 0)
+ return -1;
+
+ attr = unl_find_attr(unl, msg, NL80211_ATTR_WIPHY);
+ if (!attr)
+ goto out;
+
+ ret = nla_get_u32(attr);
+out:
+nla_put_failure:
+ nlmsg_free(msg);
+ return ret;
+}
+
+
diff --git a/package/libs/libnl/.svn/entries b/package/libs/libnl/.svn/entries
new file mode 100644
index 0000000..f38bcc4
--- /dev/null
+++ b/package/libs/libnl/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs/libnl
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:07.000000Z
+dbe5e34274043edb23d403032d512df8
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1450
+
diff --git a/package/libs/libnl/.svn/prop-base/Makefile.svn-base b/package/libs/libnl/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/libs/libnl/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/libs/libnl/.svn/text-base/Makefile.svn-base b/package/libs/libnl/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..1375699
--- /dev/null
+++ b/package/libs/libnl/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,56 @@
+#
+# Copyright (C) 2006-2009 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=libnl
+PKG_VERSION:=2.0
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://www.infradead.org/~tgr/libnl/files/
+PKG_MD5SUM:=6aaf1e9802a17a7d702bb0638044ffa7
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/libnl
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=netlink socket library
+ URL:=http://people.suug.ch/~tgr/libnl/
+endef
+
+define Package/libnl/description
+ This package contains a library for applications dealing with netlink sockets
+endef
+
+TARGET_CFLAGS += -ffunction-sections $(FPIC)
+
+define Build/Compile
+ $(call Build/Compile/Default)
+ make -C $(PKG_BUILD_DIR) \
+ DESTDIR="$(PKG_INSTALL_DIR)" \
+ install
+endef
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)
+ $(CP) $(PKG_INSTALL_DIR)/* $(1)/
+ mkdir -p $(1)/usr/include/libnl
+ $(CP) $(PKG_BUILD_DIR)/include/linux $(1)/usr/include/libnl/
+endef
+
+define Package/libnl/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libnl-route.so.* $(1)/usr/lib/
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libnl-genl.so.* $(1)/usr/lib/
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libnl-nf.so.* $(1)/usr/lib/
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libnl-route.so.* $(1)/usr/lib/
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libnl.so.* $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,libnl))
diff --git a/package/libs/libnl/Makefile b/package/libs/libnl/Makefile
new file mode 100644
index 0000000..1375699
--- /dev/null
+++ b/package/libs/libnl/Makefile
@@ -0,0 +1,56 @@
+#
+# Copyright (C) 2006-2009 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=libnl
+PKG_VERSION:=2.0
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://www.infradead.org/~tgr/libnl/files/
+PKG_MD5SUM:=6aaf1e9802a17a7d702bb0638044ffa7
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/libnl
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=netlink socket library
+ URL:=http://people.suug.ch/~tgr/libnl/
+endef
+
+define Package/libnl/description
+ This package contains a library for applications dealing with netlink sockets
+endef
+
+TARGET_CFLAGS += -ffunction-sections $(FPIC)
+
+define Build/Compile
+ $(call Build/Compile/Default)
+ make -C $(PKG_BUILD_DIR) \
+ DESTDIR="$(PKG_INSTALL_DIR)" \
+ install
+endef
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)
+ $(CP) $(PKG_INSTALL_DIR)/* $(1)/
+ mkdir -p $(1)/usr/include/libnl
+ $(CP) $(PKG_BUILD_DIR)/include/linux $(1)/usr/include/libnl/
+endef
+
+define Package/libnl/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libnl-route.so.* $(1)/usr/lib/
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libnl-genl.so.* $(1)/usr/lib/
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libnl-nf.so.* $(1)/usr/lib/
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libnl-route.so.* $(1)/usr/lib/
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libnl.so.* $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,libnl))
diff --git a/package/libs/libnl/patches/.svn/entries b/package/libs/libnl/patches/.svn/entries
new file mode 100644
index 0000000..2db1aa2
--- /dev/null
+++ b/package/libs/libnl/patches/.svn/entries
@@ -0,0 +1,96 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs/libnl/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+160-update_includes_for_iw.patch
+file
+
+
+
+
+2013-03-17T12:13:07.000000Z
+71a291a7fd4281f7eeeaec4ea6d130c1
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+708
+
+110-offsetof.patch
+file
+
+
+
+
+2013-03-17T12:13:07.000000Z
+5e65e234d511fa1669cad21b217c9a6f
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+361
+
diff --git a/package/libs/libnl/patches/.svn/text-base/110-offsetof.patch.svn-base b/package/libs/libnl/patches/.svn/text-base/110-offsetof.patch.svn-base
new file mode 100644
index 0000000..fa944a9
--- /dev/null
+++ b/package/libs/libnl/patches/.svn/text-base/110-offsetof.patch.svn-base
@@ -0,0 +1,12 @@
+--- a/include/netlink-local.h
++++ b/include/netlink-local.h
+@@ -337,7 +337,9 @@ static inline int nl_cb_call(struct nl_c
+ }
+
+ #define ARRAY_SIZE(X) (sizeof(X) / sizeof((X)[0]))
++#ifndef offsetof
+ #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
++#endif
+
+ #define __init __attribute__ ((constructor))
+ #define __exit __attribute__ ((destructor))
diff --git a/package/libs/libnl/patches/.svn/text-base/160-update_includes_for_iw.patch.svn-base b/package/libs/libnl/patches/.svn/text-base/160-update_includes_for_iw.patch.svn-base
new file mode 100644
index 0000000..ad36dab
--- /dev/null
+++ b/package/libs/libnl/patches/.svn/text-base/160-update_includes_for_iw.patch.svn-base
@@ -0,0 +1,34 @@
+--- a/include/linux/genetlink.h
++++ b/include/linux/genetlink.h
+@@ -39,6 +39,9 @@ enum {
+ CTRL_CMD_NEWOPS,
+ CTRL_CMD_DELOPS,
+ CTRL_CMD_GETOPS,
++ CTRL_CMD_NEWMCAST_GRP,
++ CTRL_CMD_DELMCAST_GRP,
++ CTRL_CMD_GETMCAST_GRP, /* unused */
+ __CTRL_CMD_MAX,
+ };
+
+@@ -52,6 +55,7 @@ enum {
+ CTRL_ATTR_HDRSIZE,
+ CTRL_ATTR_MAXATTR,
+ CTRL_ATTR_OPS,
++ CTRL_ATTR_MCAST_GROUPS,
+ __CTRL_ATTR_MAX,
+ };
+
+@@ -66,4 +70,13 @@ enum {
+
+ #define CTRL_ATTR_OP_MAX (__CTRL_ATTR_OP_MAX - 1)
+
++enum {
++ CTRL_ATTR_MCAST_GRP_UNSPEC,
++ CTRL_ATTR_MCAST_GRP_NAME,
++ CTRL_ATTR_MCAST_GRP_ID,
++ __CTRL_ATTR_MCAST_GRP_MAX,
++};
++
++#define CTRL_ATTR_MCAST_GRP_MAX (__CTRL_ATTR_MCAST_GRP_MAX - 1)
++
+ #endif /* __LINUX_GENERIC_NETLINK_H */
diff --git a/package/libs/libnl/patches/110-offsetof.patch b/package/libs/libnl/patches/110-offsetof.patch
new file mode 100644
index 0000000..fa944a9
--- /dev/null
+++ b/package/libs/libnl/patches/110-offsetof.patch
@@ -0,0 +1,12 @@
+--- a/include/netlink-local.h
++++ b/include/netlink-local.h
+@@ -337,7 +337,9 @@ static inline int nl_cb_call(struct nl_c
+ }
+
+ #define ARRAY_SIZE(X) (sizeof(X) / sizeof((X)[0]))
++#ifndef offsetof
+ #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
++#endif
+
+ #define __init __attribute__ ((constructor))
+ #define __exit __attribute__ ((destructor))
diff --git a/package/libs/libnl/patches/160-update_includes_for_iw.patch b/package/libs/libnl/patches/160-update_includes_for_iw.patch
new file mode 100644
index 0000000..ad36dab
--- /dev/null
+++ b/package/libs/libnl/patches/160-update_includes_for_iw.patch
@@ -0,0 +1,34 @@
+--- a/include/linux/genetlink.h
++++ b/include/linux/genetlink.h
+@@ -39,6 +39,9 @@ enum {
+ CTRL_CMD_NEWOPS,
+ CTRL_CMD_DELOPS,
+ CTRL_CMD_GETOPS,
++ CTRL_CMD_NEWMCAST_GRP,
++ CTRL_CMD_DELMCAST_GRP,
++ CTRL_CMD_GETMCAST_GRP, /* unused */
+ __CTRL_CMD_MAX,
+ };
+
+@@ -52,6 +55,7 @@ enum {
+ CTRL_ATTR_HDRSIZE,
+ CTRL_ATTR_MAXATTR,
+ CTRL_ATTR_OPS,
++ CTRL_ATTR_MCAST_GROUPS,
+ __CTRL_ATTR_MAX,
+ };
+
+@@ -66,4 +70,13 @@ enum {
+
+ #define CTRL_ATTR_OP_MAX (__CTRL_ATTR_OP_MAX - 1)
+
++enum {
++ CTRL_ATTR_MCAST_GRP_UNSPEC,
++ CTRL_ATTR_MCAST_GRP_NAME,
++ CTRL_ATTR_MCAST_GRP_ID,
++ __CTRL_ATTR_MCAST_GRP_MAX,
++};
++
++#define CTRL_ATTR_MCAST_GRP_MAX (__CTRL_ATTR_MCAST_GRP_MAX - 1)
++
+ #endif /* __LINUX_GENERIC_NETLINK_H */
diff --git a/package/libs/libpcap/.svn/entries b/package/libs/libpcap/.svn/entries
new file mode 100644
index 0000000..69832f9
--- /dev/null
+++ b/package/libs/libpcap/.svn/entries
@@ -0,0 +1,99 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs/libpcap
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-10T12:49:37.020840Z
+33693
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+patches
+dir
+
+Config.in
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+734743b7911fcb10b492b2b4e913c8a1
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+259
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+19e167d4c80bdd4e0e0d339f0f07854c
+2012-10-10T12:49:37.020840Z
+33693
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2085
+
diff --git a/package/libs/libpcap/.svn/prop-base/Makefile.svn-base b/package/libs/libpcap/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..8e522ae
--- /dev/null
+++ b/package/libs/libpcap/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:copyright
+V 30
+Copyright (C) 2006 OpenWrt.org
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/libs/libpcap/.svn/text-base/Config.in.svn-base b/package/libs/libpcap/.svn/text-base/Config.in.svn-base
new file mode 100644
index 0000000..ef32c1b
--- /dev/null
+++ b/package/libs/libpcap/.svn/text-base/Config.in.svn-base
@@ -0,0 +1,15 @@
+menu "Configuration"
+ depends PACKAGE_libpcap
+
+config PCAP_HAS_USB
+ bool "Include USB support"
+ depends PACKAGE_kmod-usb-core
+ default n
+
+config PCAP_HAS_BT
+ bool "Include bluetooth support"
+ depends PACKAGE_kmod-bluetooth
+ depends BROKEN
+ default n
+
+endmenu
diff --git a/package/libs/libpcap/.svn/text-base/Makefile.svn-base b/package/libs/libpcap/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..de77c00
--- /dev/null
+++ b/package/libs/libpcap/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,85 @@
+#
+# Copyright (C) 2006-2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=libpcap
+PKG_VERSION:=1.1.1
+PKG_RELEASE:=2
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://www.tcpdump.org/release/
+PKG_MD5SUM:=1bca27d206970badae248cfa471bbb47
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+
+PKG_INSTALL:=1
+PKG_BUILD_PARALLEL:=1
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+define Package/libpcap
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=Low-level packet capture library
+ URL:=http://www.tcpdump.org/
+ MENU:=1
+endef
+
+define Package/libpcap/description
+This package contains a system-independent library for user-level network packet
+capture.
+endef
+
+define Package/libpcap/config
+ source "$(SOURCE)/Config.in"
+endef
+
+TARGET_CFLAGS += \
+ -ffunction-sections \
+ -fdata-sections
+
+CONFIGURE_VARS += \
+ ac_cv_linux_vers=$(LINUX_VERSION)
+
+CONFIGURE_ARGS += \
+ --enable-shared \
+ --enable-static \
+ --disable-yydebug \
+ --enable-ipv6 \
+ --with-build-cc="$(HOSTCC)" \
+ --with-pcap=linux \
+ --without-septel \
+ --without-dag \
+ --without-libnl
+
+MAKE_FLAGS += \
+ CCOPT="$(TARGET_CFLAGS) -I$(BUILD_DIR)/linux/include"
+
+define Build/Configure
+ $(call Build/Configure/Default)
+ $(if $(CONFIG_PCAP_HAS_USB),,$(SED) '/^#define PCAP_SUPPORT_USB/D' $(PKG_BUILD_DIR)/config.h)
+ $(if $(CONFIG_PCAP_HAS_USB),,$(SED) 's/pcap-usb-linux.c *//' $(PKG_BUILD_DIR)/Makefile)
+ $(if $(CONFIG_PCAP_HAS_BT),,$(SED) '/^#define PCAP_SUPPORT_BT/D' $(PKG_BUILD_DIR)/config.h)
+ $(if $(CONFIG_PCAP_HAS_BT),,$(SED) 's/pcap-bt-linux.c *//' $(PKG_BUILD_DIR)/Makefile)
+endef
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include
+ $(CP) $(PKG_INSTALL_DIR)/usr/include/pcap* $(1)/usr/include/
+
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpcap.{a,so*} $(1)/usr/lib/
+endef
+
+define Package/libpcap/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpcap.so* $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,libpcap))
diff --git a/package/libs/libpcap/Config.in b/package/libs/libpcap/Config.in
new file mode 100644
index 0000000..ef32c1b
--- /dev/null
+++ b/package/libs/libpcap/Config.in
@@ -0,0 +1,15 @@
+menu "Configuration"
+ depends PACKAGE_libpcap
+
+config PCAP_HAS_USB
+ bool "Include USB support"
+ depends PACKAGE_kmod-usb-core
+ default n
+
+config PCAP_HAS_BT
+ bool "Include bluetooth support"
+ depends PACKAGE_kmod-bluetooth
+ depends BROKEN
+ default n
+
+endmenu
diff --git a/package/libs/libpcap/Makefile b/package/libs/libpcap/Makefile
new file mode 100644
index 0000000..de77c00
--- /dev/null
+++ b/package/libs/libpcap/Makefile
@@ -0,0 +1,85 @@
+#
+# Copyright (C) 2006-2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=libpcap
+PKG_VERSION:=1.1.1
+PKG_RELEASE:=2
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://www.tcpdump.org/release/
+PKG_MD5SUM:=1bca27d206970badae248cfa471bbb47
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+
+PKG_INSTALL:=1
+PKG_BUILD_PARALLEL:=1
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+define Package/libpcap
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=Low-level packet capture library
+ URL:=http://www.tcpdump.org/
+ MENU:=1
+endef
+
+define Package/libpcap/description
+This package contains a system-independent library for user-level network packet
+capture.
+endef
+
+define Package/libpcap/config
+ source "$(SOURCE)/Config.in"
+endef
+
+TARGET_CFLAGS += \
+ -ffunction-sections \
+ -fdata-sections
+
+CONFIGURE_VARS += \
+ ac_cv_linux_vers=$(LINUX_VERSION)
+
+CONFIGURE_ARGS += \
+ --enable-shared \
+ --enable-static \
+ --disable-yydebug \
+ --enable-ipv6 \
+ --with-build-cc="$(HOSTCC)" \
+ --with-pcap=linux \
+ --without-septel \
+ --without-dag \
+ --without-libnl
+
+MAKE_FLAGS += \
+ CCOPT="$(TARGET_CFLAGS) -I$(BUILD_DIR)/linux/include"
+
+define Build/Configure
+ $(call Build/Configure/Default)
+ $(if $(CONFIG_PCAP_HAS_USB),,$(SED) '/^#define PCAP_SUPPORT_USB/D' $(PKG_BUILD_DIR)/config.h)
+ $(if $(CONFIG_PCAP_HAS_USB),,$(SED) 's/pcap-usb-linux.c *//' $(PKG_BUILD_DIR)/Makefile)
+ $(if $(CONFIG_PCAP_HAS_BT),,$(SED) '/^#define PCAP_SUPPORT_BT/D' $(PKG_BUILD_DIR)/config.h)
+ $(if $(CONFIG_PCAP_HAS_BT),,$(SED) 's/pcap-bt-linux.c *//' $(PKG_BUILD_DIR)/Makefile)
+endef
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include
+ $(CP) $(PKG_INSTALL_DIR)/usr/include/pcap* $(1)/usr/include/
+
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpcap.{a,so*} $(1)/usr/lib/
+endef
+
+define Package/libpcap/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpcap.so* $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,libpcap))
diff --git a/package/libs/libpcap/patches/.svn/entries b/package/libs/libpcap/patches/.svn/entries
new file mode 100644
index 0000000..3a61035
--- /dev/null
+++ b/package/libs/libpcap/patches/.svn/entries
@@ -0,0 +1,232 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs/libpcap/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+201-space_optimization.patch
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+4a95d7c550452e8e576f0c33af09c3a1
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3172
+
+103-makefile_flex_workaround.patch
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+93d7dcbf6d36ae6f32d712fb6c6ee6c5
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+296
+
+102-makefile_disable_manpages.patch
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+31d5fca7f62fa46abe35d4bcc2bd095b
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4555
+
+202-protocol_api.patch
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+d876b826267d3d8b4315a2f1bc820aea
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4379
+
+100-debian_shared_lib.patch
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+e2135ef91ef18aa0ec96a5cdf6d2c087
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5253
+
+203-undef_iw_mode_monitor.patch
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+44255d1cc9cec1dea9343fa2762452ce
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+245
+
diff --git a/package/libs/libpcap/patches/.svn/prop-base/100-debian_shared_lib.patch.svn-base b/package/libs/libpcap/patches/.svn/prop-base/100-debian_shared_lib.patch.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/libs/libpcap/patches/.svn/prop-base/100-debian_shared_lib.patch.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/libs/libpcap/patches/.svn/text-base/100-debian_shared_lib.patch.svn-base b/package/libs/libpcap/patches/.svn/text-base/100-debian_shared_lib.patch.svn-base
new file mode 100644
index 0000000..5be33b0
--- /dev/null
+++ b/package/libs/libpcap/patches/.svn/text-base/100-debian_shared_lib.patch.svn-base
@@ -0,0 +1,178 @@
+Debian-specific modifications to the upstream Makefile.in to
+build a shared library.
+---
+ Makefile.in | 45 ++++++++++++++++++++++++++++++++++++++++++---
+ configure | 2 +-
+ configure.in | 2 +-
+ 3 files changed, 44 insertions(+), 5 deletions(-)
+
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -40,6 +40,14 @@ mandir = @mandir@
+ srcdir = @srcdir@
+ VPATH = @srcdir@
+
++# some defines for shared library compilation
++MAJ=1.1
++LIBVERSION=$(MAJ).1
++LIBNAME=pcap
++LIBRARY=lib$(LIBNAME).a
++SOLIBRARY=lib$(LIBNAME).so
++SHAREDLIB=$(SOLIBRARY).$(LIBVERSION)
++
+ #
+ # You shouldn't need to edit anything below.
+ #
+@@ -59,6 +67,7 @@ PROG=libpcap
+
+ # Standard CFLAGS
+ CFLAGS = $(CCOPT) $(INCLS) $(DEFS)
++CFLAGS_SHARED = -shared -Wl,-soname,$(SOLIBRARY).$(MAJ)
+
+ INSTALL = @INSTALL@
+ INSTALL_PROGRAM = @INSTALL_PROGRAM@
+@@ -78,7 +87,11 @@ YACC = @V_YACC@
+ # problem if you don't own the file but can write to the directory.
+ .c.o:
+ @rm -f $@
+- $(CC) $(CFLAGS) -c $(srcdir)/$*.c
++ $(CC) $(CFLAGS) -c -o $@ $(srcdir)/$*.c
++
++%_pic.o: %.c
++ @rm -f $@
++ $(CC) -fPIC $(CFLAGS) -c -o $@ $(srcdir)/$*.c
+
+ PSRC = pcap-@V_PCAP@.c @USB_SRC@ @BT_SRC@ @CAN_SRC@
+ FSRC = fad-@V_FINDALLDEVS@.c
+@@ -94,6 +107,7 @@ SRC = $(PSRC) $(FSRC) $(CSRC) $(SSRC) $(
+ # We would like to say "OBJ = $(SRC:.c=.o)" but Ultrix's make cannot
+ # hack the extra indirection
+ OBJ = $(PSRC:.c=.o) $(FSRC:.c=.o) $(CSRC:.c=.o) $(SSRC:.c=.o) $(GENSRC:.c=.o) $(LIBOBJS)
++OBJ_PIC = $(PSRC:.c=_pic.o) $(FSRC:.c=_pic.o) $(CSRC:.c=_pic.o) $(SSRC:.c=_pic.o) $(GENSRC:.c=_pic.o)
+ PUBHDR = \
+ pcap.h \
+ pcap-bpf.h \
+@@ -131,7 +145,7 @@ TAGFILES = \
+
+ CLEANFILES = $(OBJ) libpcap.* filtertest findalldevstest selpolltest \
+ opentest $(PROG)-`cat $(srcdir)/VERSION`.tar.gz $(GENSRC) $(GENHDR) \
+- lex.yy.c pcap-config
++ lex.yy.c pcap-config $(OBJ_PIC)
+
+ MAN1 = pcap-config.1
+
+@@ -324,21 +338,14 @@ EXTRA_DIST = \
+ Win32/Src/inet_net.c \
+ Win32/Src/inet_pton.c
+
+-all: libpcap.a shared pcap-config
++all: libpcap.a shared pcap-config $(SHAREDLIB)
+
+ libpcap.a: $(OBJ)
+ @rm -f $@
+ ar rc $@ $(OBJ) $(ADDLARCHIVEOBJS)
+ $(RANLIB) $@
+
+-shared: libpcap.$(DYEXT)
+-
+-libpcap.so: $(OBJ)
+- @rm -f $@
+- VER=`cat $(srcdir)/VERSION`; \
+- MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
+- @V_SHLIB_CMD@ @V_SHLIB_OPT@ @V_SONAME_OPT@$@.$$MAJOR_VER $(LDFLAGS) \
+- -o $@.$$VER $(OBJ) $(ADDLOBJS) $(LIBS)
++shared: $(SHAREDLIB)
+
+ #
+ # The following rule succeeds, but the result is untested.
+@@ -409,6 +416,13 @@ libpcap.shareda: $(OBJ)
+ #
+ libpcap.none:
+
++$(SHAREDLIB): $(OBJ_PIC)
++ -@rm -f $@
++ -@rm -f $(SOLIBRARY) $(SOLIBRARY).$(MAJ)
++ $(CC) $(CFLAGS_SHARED) -o $(SHAREDLIB) $(OBJ_PIC) -lc
++ ln -s $(SHAREDLIB) $(SOLIBRARY).$(MAJ)
++ ln -s $(SOLIBRARY).$(MAJ) $(SOLIBRARY)
++
+ scanner.c: $(srcdir)/scanner.l
+ @rm -f $@
+ $(srcdir)/runlex.sh $(LEX) -o$@ $<
+@@ -416,6 +430,9 @@ scanner.c: $(srcdir)/scanner.l
+ scanner.o: scanner.c tokdefs.h
+ $(CC) $(CFLAGS) -c scanner.c
+
++scanner_pic.o: scanner.c tokdefs.h
++ $(CC) -fPIC $(CFLAGS) -o $@ -c scanner.c
++
+ pcap.o: version.h
+
+ tokdefs.h: grammar.c
+@@ -429,9 +446,17 @@ grammar.o: grammar.c
+ @rm -f $@
+ $(CC) $(CFLAGS) -Dyylval=pcap_lval -c grammar.c
+
++grammar_pic.o: grammar.c
++ @rm -f $@
++ $(CC) -fPIC $(CFLAGS) -Dyylval=pcap_lval -o $@ -c grammar.c
++
+ version.o: version.c
+ $(CC) $(CFLAGS) -c version.c
+
++version_pic.o: version.c
++ $(CC) -fPIC $(CFLAGS) -c version.c -o $@
++
++
+ snprintf.o: $(srcdir)/missing/snprintf.c
+ $(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/snprintf.c
+
+@@ -469,6 +494,9 @@ bpf_filter.c: $(srcdir)/bpf/net/bpf_filt
+ bpf_filter.o: bpf_filter.c
+ $(CC) $(CFLAGS) -c bpf_filter.c
+
++bpf_filter_pic.o: bpf_filter.c
++ $(CC) -fPIC $(CFLAGS) -c bpf_filter.c -o $@
++
+ #
+ # Generate the pcap-config script.
+ #
+@@ -562,14 +590,12 @@ install: install-shared install-archive
+ $(DESTDIR)$(mandir)/man@MAN_MISC_INFO@/`echo $$i | sed 's/.manmisc.in/.@MAN_MISC_INFO@/'`; done
+
+ install-shared: install-shared-$(DYEXT)
+-install-shared-so: libpcap.so
++install-shared-so: $(SHAREDLIB)
+ [ -d $(DESTDIR)$(libdir) ] || \
+ (mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
+- VER=`cat $(srcdir)/VERSION`; \
+- MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
+- $(INSTALL_PROGRAM) libpcap.so.$$VER $(DESTDIR)$(libdir)/libpcap.so.$$VER; \
+- ln -sf libpcap.so.$$VER $(DESTDIR)$(libdir)/libpcap.so.$$MAJOR_VER; \
+- ln -sf libpcap.so.$$MAJOR_VER $(DESTDIR)$(libdir)/libpcap.so
++ $(INSTALL_DATA) $(SHAREDLIB) $(DESTDIR)$(libdir)/
++ ln -sf $(SHAREDLIB) $(DESTDIR)$(libdir)/$(SOLIBRARY).$(MAJ)
++ ln -sf $(SOLIBRARY).$(MAJ) $(DESTDIR)$(libdir)/$(SOLIBRARY)
+ install-shared-dylib: libpcap.dylib
+ [ -d $(DESTDIR)$(libdir) ] || \
+ (mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
+--- a/configure
++++ b/configure
+@@ -3229,7 +3229,7 @@ _ACEOF
+ # or accepts command-line arguments like
+ # those the GNU linker accepts.
+ #
+- V_CCOPT="$V_CCOPT -fpic"
++ V_CCOPT="$V_CCOPT"
+ V_SONAME_OPT="-Wl,-soname,"
+ V_RPATH_OPT="-Wl,-rpath,"
+ ;;
+@@ -3292,7 +3292,7 @@ _ACEOF
+ #
+ # "cc" is GCC.
+ #
+- V_CCOPT="$V_CCOPT -fpic"
++ V_CCOPT="$V_CCOPT"
+ V_SHLIB_CMD="\$(CC)"
+ V_SHLIB_OPT="-shared"
+ V_SONAME_OPT="-Wl,-soname,"
diff --git a/package/libs/libpcap/patches/.svn/text-base/102-makefile_disable_manpages.patch.svn-base b/package/libs/libpcap/patches/.svn/text-base/102-makefile_disable_manpages.patch.svn-base
new file mode 100644
index 0000000..4674df5
--- /dev/null
+++ b/package/libs/libpcap/patches/.svn/text-base/102-makefile_disable_manpages.patch.svn-base
@@ -0,0 +1,89 @@
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -532,62 +532,12 @@ install: install-shared install-archive
+ (mkdir -p $(DESTDIR)$(includedir); chmod 755 $(DESTDIR)$(includedir))
+ [ -d $(DESTDIR)$(includedir)/pcap ] || \
+ (mkdir -p $(DESTDIR)$(includedir)/pcap; chmod 755 $(DESTDIR)$(includedir)/pcap)
+- [ -d $(DESTDIR)$(mandir)/man1 ] || \
+- (mkdir -p $(DESTDIR)$(mandir)/man1; chmod 755 $(DESTDIR)$(mandir)/man1)
+- [ -d $(DESTDIR)$(mandir)/man3 ] || \
+- (mkdir -p $(DESTDIR)$(mandir)/man3; chmod 755 $(DESTDIR)$(mandir)/man3)
+- [ -d $(DESTDIR)$(mandir)/man@MAN_FILE_FORMATS@ ] || \
+- (mkdir -p $(DESTDIR)$(mandir)/man@MAN_FILE_FORMATS@; chmod 755 $(DESTDIR)$(mandir)/man@MAN_FILE_FORMATS@)
+- [ -d $(DESTDIR)$(mandir)/man@MAN_MISC_INFO@ ] || \
+- (mkdir -p $(DESTDIR)$(mandir)/man@MAN_MISC_INFO@; chmod 755 $(DESTDIR)$(mandir)/man@MAN_MISC_INFO@)
+ for i in $(PUBHDR); do \
+ $(INSTALL_DATA) $(srcdir)/$$i \
+ $(DESTDIR)$(includedir)/$$i; done
+ [ -d $(DESTDIR)$(bindir) ] || \
+ (mkdir -p $(DESTDIR)$(bindir); chmod 755 $(DESTDIR)$(bindir))
+ $(INSTALL_PROGRAM) pcap-config $(DESTDIR)$(bindir)/pcap-config
+- for i in $(MAN1); do \
+- $(INSTALL_DATA) $(srcdir)/$$i \
+- $(DESTDIR)$(mandir)/man1/$$i; done
+- for i in $(MAN3PCAP_NOEXPAND); do \
+- $(INSTALL_DATA) $(srcdir)/$$i \
+- $(DESTDIR)$(mandir)/man3/$$i; done
+- for i in $(MAN3PCAP_EXPAND:.in=); do \
+- $(INSTALL_DATA) $$i \
+- $(DESTDIR)$(mandir)/man3/$$i; done
+- rm -f $(DESTDIR)$(mandir)/man3/pcap_datalink_val_to_description.3pcap
+- ln $(DESTDIR)$(mandir)/man3/pcap_datalink_val_to_name.3pcap \
+- $(DESTDIR)$(mandir)/man3/pcap_datalink_val_to_description.3pcap
+- rm -f $(DESTDIR)$(mandir)/man3/pcap_dump_fopen.3pcap
+- ln $(DESTDIR)$(mandir)/man3/pcap_dump_open.3pcap \
+- $(DESTDIR)$(mandir)/man3/pcap_dump_fopen.3pcap
+- rm -f $(DESTDIR)$(mandir)/man3/pcap_perror.3pcap
+- ln $(DESTDIR)$(mandir)/man3/pcap_geterr.3pcap \
+- $(DESTDIR)$(mandir)/man3/pcap_perror.3pcap
+- rm -f $(DESTDIR)$(mandir)/man3/pcap_sendpacket.3pcap
+- ln $(DESTDIR)$(mandir)/man3/pcap_inject.3pcap \
+- $(DESTDIR)$(mandir)/man3/pcap_sendpacket.3pcap
+- rm -f $(DESTDIR)$(mandir)/man3/pcap_dispatch.3pcap
+- ln $(DESTDIR)$(mandir)/man3/pcap_loop.3pcap \
+- $(DESTDIR)$(mandir)/man3/pcap_dispatch.3pcap
+- rm -f $(DESTDIR)$(mandir)/man3/pcap_minor_version.3pcap
+- ln $(DESTDIR)$(mandir)/man3/pcap_major_version.3pcap \
+- $(DESTDIR)$(mandir)/man3/pcap_minor_version.3pcap
+- rm -f $(DESTDIR)$(mandir)/man3/pcap_next.3pcap
+- ln $(DESTDIR)$(mandir)/man3/pcap_next_ex.3pcap \
+- $(DESTDIR)$(mandir)/man3/pcap_next.3pcap
+- rm -f $(DESTDIR)$(mandir)/man3/pcap_fopen_offline.3pcap
+- ln $(DESTDIR)$(mandir)/man3/pcap_open_offline.3pcap \
+- $(DESTDIR)$(mandir)/man3/pcap_fopen_offline.3pcap
+- rm -f $(DESTDIR)$(mandir)/man3/pcap_getnonblock.3pcap
+- ln $(DESTDIR)$(mandir)/man3/pcap_setnonblock.3pcap \
+- $(DESTDIR)$(mandir)/man3/pcap_getnonblock.3pcap
+- for i in $(MANFILE); do \
+- $(INSTALL_DATA) `echo $$i | sed 's/.manfile.in/.manfile/'` \
+- $(DESTDIR)$(mandir)/man@MAN_FILE_FORMATS@/`echo $$i | sed 's/.manfile.in/.@MAN_FILE_FORMATS@/'`; done
+- for i in $(MANMISC); do \
+- $(INSTALL_DATA) `echo $$i | sed 's/.manmisc.in/.manmisc/'` \
+- $(DESTDIR)$(mandir)/man@MAN_MISC_INFO@/`echo $$i | sed 's/.manmisc.in/.@MAN_MISC_INFO@/'`; done
+
+ install-shared: install-shared-$(DYEXT)
+ install-shared-so: $(SHAREDLIB)
+@@ -642,23 +592,6 @@ uninstall: uninstall-shared
+ rm -f $(DESTDIR)$(includedir)/$$i; done
+ -rmdir $(DESTDIR)$(includedir)/pcap
+ rm -f $(DESTDIR)/$(bindir)/pcap-config
+- for i in $(MAN1); do \
+- rm -f $(DESTDIR)$(mandir)/man1/$$i; done
+- for i in $(MAN3PCAP); do \
+- rm -f $(DESTDIR)$(mandir)/man3/$$i; done
+- rm -f $(DESTDIR)$(mandir)/man3/pcap_datalink_val_to_description.3pcap
+- rm -f $(DESTDIR)$(mandir)/man3/pcap_dump_fopen.3pcap
+- rm -f $(DESTDIR)$(mandir)/man3/pcap_perror.3pcap
+- rm -f $(DESTDIR)$(mandir)/man3/pcap_sendpacket.3pcap
+- rm -f $(DESTDIR)$(mandir)/man3/pcap_dispatch.3pcap
+- rm -f $(DESTDIR)$(mandir)/man3/pcap_minor_version.3pcap
+- rm -f $(DESTDIR)$(mandir)/man3/pcap_next.3pcap
+- rm -f $(DESTDIR)$(mandir)/man3/pcap_fopen_offline.3pcap
+- rm -f $(DESTDIR)$(mandir)/man3/pcap_getnonblock.3pcap
+- for i in $(MANFILE); do \
+- rm -f $(DESTDIR)$(mandir)/man@MAN_FILE_FORMATS@/`echo $$i | sed 's/.manfile.in/.@MAN_FILE_FORMATS@/'`; done
+- for i in $(MANMISC); do \
+- rm -f $(DESTDIR)$(mandir)/man@MAN_MISC_INFO@/`echo $$i | sed 's/.manmisc.in/.@MAN_MISC_INFO@/'`; done
+
+ uninstall-shared: uninstall-shared-$(DYEXT)
+ uninstall-shared-so:
diff --git a/package/libs/libpcap/patches/.svn/text-base/103-makefile_flex_workaround.patch.svn-base b/package/libs/libpcap/patches/.svn/text-base/103-makefile_flex_workaround.patch.svn-base
new file mode 100644
index 0000000..a90e0ce
--- /dev/null
+++ b/package/libs/libpcap/patches/.svn/text-base/103-makefile_flex_workaround.patch.svn-base
@@ -0,0 +1,14 @@
+
+ Copyright (C) 2006 Markus Wigge
+
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -56,7 +56,7 @@ LD = /usr/bin/ld
+ CC = @CC@
+ CCOPT = @V_CCOPT@
+ INCLS = -I. @V_INCLS@
+-DEFS = @DEFS@ @V_DEFS@
++DEFS = -D_BSD_SOURCE @DEFS@ @V_DEFS@
+ ADDLOBJS = @ADDLOBJS@
+ ADDLARCHIVEOBJS = @ADDLARCHIVEOBJS@
+ LIBS = @LIBS@
diff --git a/package/libs/libpcap/patches/.svn/text-base/201-space_optimization.patch.svn-base b/package/libs/libpcap/patches/.svn/text-base/201-space_optimization.patch.svn-base
new file mode 100644
index 0000000..f3eec4c
--- /dev/null
+++ b/package/libs/libpcap/patches/.svn/text-base/201-space_optimization.patch.svn-base
@@ -0,0 +1,133 @@
+--- a/gencode.c
++++ b/gencode.c
+@@ -491,20 +491,6 @@ pcap_compile_nopcap(int snaplen_arg, int
+ }
+
+ /*
+- * Clean up a "struct bpf_program" by freeing all the memory allocated
+- * in it.
+- */
+-void
+-pcap_freecode(struct bpf_program *program)
+-{
+- program->bf_len = 0;
+- if (program->bf_insns != NULL) {
+- free((char *)program->bf_insns);
+- program->bf_insns = NULL;
+- }
+-}
+-
+-/*
+ * Backpatch the blocks in 'list' to 'target'. The 'sense' field indicates
+ * which of the jt and jf fields has been resolved and which is a pointer
+ * back to another unresolved block (or nil). At least one of the fields
+--- a/pcap.c
++++ b/pcap.c
+@@ -748,6 +748,59 @@ static const u_char charmap[] = {
+ (u_char)'\374', (u_char)'\375', (u_char)'\376', (u_char)'\377',
+ };
+
++/*
++ * Clean up a "struct bpf_program" by freeing all the memory allocated
++ * in it.
++ */
++void
++pcap_freecode(struct bpf_program *program)
++{
++ program->bf_len = 0;
++ if (program->bf_insns != NULL) {
++ free((char *)program->bf_insns);
++ program->bf_insns = NULL;
++ }
++}
++
++/*
++ * Make a copy of a BPF program and put it in the "fcode" member of
++ * a "pcap_t".
++ *
++ * If we fail to allocate memory for the copy, fill in the "errbuf"
++ * member of the "pcap_t" with an error message, and return -1;
++ * otherwise, return 0.
++ */
++int
++install_bpf_program(pcap_t *p, struct bpf_program *fp)
++{
++ size_t prog_size;
++
++ /*
++ * Validate the program.
++ */
++ if (!bpf_validate(fp->bf_insns, fp->bf_len)) {
++ snprintf(p->errbuf, sizeof(p->errbuf),
++ "BPF program is not valid");
++ return (-1);
++ }
++
++ /*
++ * Free up any already installed program.
++ */
++ pcap_freecode(&p->fcode);
++
++ prog_size = sizeof(*fp->bf_insns) * fp->bf_len;
++ p->fcode.bf_len = fp->bf_len;
++ p->fcode.bf_insns = (struct bpf_insn *)malloc(prog_size);
++ if (p->fcode.bf_insns == NULL) {
++ snprintf(p->errbuf, sizeof(p->errbuf),
++ "malloc: %s", pcap_strerror(errno));
++ return (-1);
++ }
++ memcpy(p->fcode.bf_insns, fp->bf_insns, prog_size);
++ return (0);
++}
++
+ int
+ pcap_strcasecmp(const char *s1, const char *s2)
+ {
+--- a/optimize.c
++++ b/optimize.c
+@@ -2292,45 +2292,6 @@ icode_to_fcode(root, lenp)
+ return fp;
+ }
+
+-/*
+- * Make a copy of a BPF program and put it in the "fcode" member of
+- * a "pcap_t".
+- *
+- * If we fail to allocate memory for the copy, fill in the "errbuf"
+- * member of the "pcap_t" with an error message, and return -1;
+- * otherwise, return 0.
+- */
+-int
+-install_bpf_program(pcap_t *p, struct bpf_program *fp)
+-{
+- size_t prog_size;
+-
+- /*
+- * Validate the program.
+- */
+- if (!bpf_validate(fp->bf_insns, fp->bf_len)) {
+- snprintf(p->errbuf, sizeof(p->errbuf),
+- "BPF program is not valid");
+- return (-1);
+- }
+-
+- /*
+- * Free up any already installed program.
+- */
+- pcap_freecode(&p->fcode);
+-
+- prog_size = sizeof(*fp->bf_insns) * fp->bf_len;
+- p->fcode.bf_len = fp->bf_len;
+- p->fcode.bf_insns = (struct bpf_insn *)malloc(prog_size);
+- if (p->fcode.bf_insns == NULL) {
+- snprintf(p->errbuf, sizeof(p->errbuf),
+- "malloc: %s", pcap_strerror(errno));
+- return (-1);
+- }
+- memcpy(p->fcode.bf_insns, fp->bf_insns, prog_size);
+- return (0);
+-}
+-
+ #ifdef BDEBUG
+ static void
+ opt_dump(root)
diff --git a/package/libs/libpcap/patches/.svn/text-base/202-protocol_api.patch.svn-base b/package/libs/libpcap/patches/.svn/text-base/202-protocol_api.patch.svn-base
new file mode 100644
index 0000000..892aeb7
--- /dev/null
+++ b/package/libs/libpcap/patches/.svn/text-base/202-protocol_api.patch.svn-base
@@ -0,0 +1,141 @@
+--- a/pcap-int.h
++++ b/pcap-int.h
+@@ -209,6 +209,7 @@ struct pcap_opt {
+ char *source;
+ int promisc;
+ int rfmon;
++ int proto; /* protocol for packet socket (linux) */
+ };
+
+ /*
+--- a/pcap-linux.c
++++ b/pcap-linux.c
+@@ -335,7 +335,7 @@ static int iface_get_id(int fd, const ch
+ static int iface_get_mtu(int fd, const char *device, char *ebuf);
+ static int iface_get_arptype(int fd, const char *device, char *ebuf);
+ #ifdef HAVE_PF_PACKET_SOCKETS
+-static int iface_bind(int fd, int ifindex, char *ebuf);
++static int iface_bind(int fd, int ifindex, char *ebuf, unsigned short proto);
+ #ifdef IW_MODE_MONITOR
+ static int has_wext(int sock_fd, const char *device, char *ebuf);
+ #endif /* IW_MODE_MONITOR */
+@@ -881,7 +881,7 @@ pcap_can_set_rfmon_linux(pcap_t *handle)
+ * (We assume that if we have Wireless Extensions support
+ * we also have PF_PACKET support.)
+ */
+- sock_fd = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
++ sock_fd = socket(PF_PACKET, SOCK_RAW, p->opt.proto);
+ if (sock_fd == -1) {
+ (void)snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
+ "socket: %s", pcap_strerror(errno));
+@@ -1128,6 +1128,9 @@ pcap_activate_linux(pcap_t *handle)
+ handle->read_op = pcap_read_linux;
+ handle->stats_op = pcap_stats_linux;
+
++ if (handle->opt.proto < 0)
++ handle->opt.proto = (int) htons(ETH_P_ALL);
++
+ /*
+ * The "any" device is a special device which causes us not
+ * to bind to a particular device and thus to look at all
+@@ -2684,8 +2687,8 @@ activate_new(pcap_t *handle)
+ * try a SOCK_RAW socket for the raw interface.
+ */
+ sock_fd = is_any_device ?
+- socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_ALL)) :
+- socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
++ socket(PF_PACKET, SOCK_DGRAM, handle->opt.proto) :
++ socket(PF_PACKET, SOCK_RAW, handle->opt.proto);
+
+ if (sock_fd == -1) {
+ snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "socket: %s",
+@@ -2783,7 +2786,7 @@ activate_new(pcap_t *handle)
+ return PCAP_ERROR;
+ }
+ sock_fd = socket(PF_PACKET, SOCK_DGRAM,
+- htons(ETH_P_ALL));
++ handle->opt.proto);
+ if (sock_fd == -1) {
+ snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
+ "socket: %s", pcap_strerror(errno));
+@@ -2835,7 +2838,7 @@ activate_new(pcap_t *handle)
+ }
+
+ if ((err = iface_bind(sock_fd, handle->md.ifindex,
+- handle->errbuf)) != 1) {
++ handle->errbuf, handle->opt.proto)) != 1) {
+ close(sock_fd);
+ if (err < 0)
+ return err;
+@@ -3640,7 +3643,7 @@ iface_get_id(int fd, const char *device,
+ * or a PCAP_ERROR_ value on a hard error.
+ */
+ static int
+-iface_bind(int fd, int ifindex, char *ebuf)
++iface_bind(int fd, int ifindex, char *ebuf, unsigned short proto)
+ {
+ struct sockaddr_ll sll;
+ int err;
+@@ -3649,7 +3652,7 @@ iface_bind(int fd, int ifindex, char *eb
+ memset(&sll, 0, sizeof(sll));
+ sll.sll_family = AF_PACKET;
+ sll.sll_ifindex = ifindex;
+- sll.sll_protocol = htons(ETH_P_ALL);
++ sll.sll_protocol = proto;
+
+ if (bind(fd, (struct sockaddr *) &sll, sizeof(sll)) == -1) {
+ if (errno == ENETDOWN) {
+@@ -4359,7 +4362,7 @@ activate_old(pcap_t *handle)
+
+ /* Open the socket */
+
+- handle->fd = socket(PF_INET, SOCK_PACKET, htons(ETH_P_ALL));
++ handle->fd = socket(PF_INET, SOCK_PACKET, handle->opt.proto);
+ if (handle->fd == -1) {
+ snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
+ "socket: %s", pcap_strerror(errno));
+--- a/pcap.c
++++ b/pcap.c
+@@ -258,6 +258,8 @@ pcap_create_common(const char *source, c
+ pcap_set_snaplen(p, 65535); /* max packet size */
+ p->opt.promisc = 0;
+ p->opt.buffer_size = 0;
++ p->opt.proto = -1;
++
+ return (p);
+ }
+
+@@ -317,6 +319,15 @@ pcap_set_buffer_size(pcap_t *p, int buff
+ return 0;
+ }
+
++int
++pcap_set_protocol(pcap_t *p, unsigned short proto)
++{
++ if (pcap_check_activated(p))
++ return PCAP_ERROR_ACTIVATED;
++ p->opt.proto = proto;
++ return 0;
++}
++
+ int
+ pcap_activate(pcap_t *p)
+ {
+--- a/pcap/pcap.h
++++ b/pcap/pcap.h
+@@ -68,6 +68,7 @@ extern "C" {
+ #define PCAP_VERSION_MINOR 4
+
+ #define PCAP_ERRBUF_SIZE 256
++#define HAS_PROTO_EXTENSION
+
+ /*
+ * Compatibility for systems that have a bpf.h that
+@@ -276,6 +277,7 @@ int pcap_can_set_rfmon(pcap_t *);
+ int pcap_set_rfmon(pcap_t *, int);
+ int pcap_set_timeout(pcap_t *, int);
+ int pcap_set_buffer_size(pcap_t *, int);
++int pcap_set_protocol(pcap_t *, unsigned short);
+ int pcap_activate(pcap_t *);
+
+ pcap_t *pcap_open_live(const char *, int, int, int, char *);
diff --git a/package/libs/libpcap/patches/.svn/text-base/203-undef_iw_mode_monitor.patch.svn-base b/package/libs/libpcap/patches/.svn/text-base/203-undef_iw_mode_monitor.patch.svn-base
new file mode 100644
index 0000000..508c659
--- /dev/null
+++ b/package/libs/libpcap/patches/.svn/text-base/203-undef_iw_mode_monitor.patch.svn-base
@@ -0,0 +1,11 @@
+--- a/pcap-linux.c
++++ b/pcap-linux.c
+@@ -254,6 +254,8 @@ static const char rcsid[] _U_ =
+ typedef int socklen_t;
+ #endif
+
++#undef IW_MODE_MONITOR
++
+ #ifndef MSG_TRUNC
+ /*
+ * This is being compiled on a system that lacks MSG_TRUNC; define it
diff --git a/package/libs/libpcap/patches/100-debian_shared_lib.patch b/package/libs/libpcap/patches/100-debian_shared_lib.patch
new file mode 100644
index 0000000..5be33b0
--- /dev/null
+++ b/package/libs/libpcap/patches/100-debian_shared_lib.patch
@@ -0,0 +1,178 @@
+Debian-specific modifications to the upstream Makefile.in to
+build a shared library.
+---
+ Makefile.in | 45 ++++++++++++++++++++++++++++++++++++++++++---
+ configure | 2 +-
+ configure.in | 2 +-
+ 3 files changed, 44 insertions(+), 5 deletions(-)
+
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -40,6 +40,14 @@ mandir = @mandir@
+ srcdir = @srcdir@
+ VPATH = @srcdir@
+
++# some defines for shared library compilation
++MAJ=1.1
++LIBVERSION=$(MAJ).1
++LIBNAME=pcap
++LIBRARY=lib$(LIBNAME).a
++SOLIBRARY=lib$(LIBNAME).so
++SHAREDLIB=$(SOLIBRARY).$(LIBVERSION)
++
+ #
+ # You shouldn't need to edit anything below.
+ #
+@@ -59,6 +67,7 @@ PROG=libpcap
+
+ # Standard CFLAGS
+ CFLAGS = $(CCOPT) $(INCLS) $(DEFS)
++CFLAGS_SHARED = -shared -Wl,-soname,$(SOLIBRARY).$(MAJ)
+
+ INSTALL = @INSTALL@
+ INSTALL_PROGRAM = @INSTALL_PROGRAM@
+@@ -78,7 +87,11 @@ YACC = @V_YACC@
+ # problem if you don't own the file but can write to the directory.
+ .c.o:
+ @rm -f $@
+- $(CC) $(CFLAGS) -c $(srcdir)/$*.c
++ $(CC) $(CFLAGS) -c -o $@ $(srcdir)/$*.c
++
++%_pic.o: %.c
++ @rm -f $@
++ $(CC) -fPIC $(CFLAGS) -c -o $@ $(srcdir)/$*.c
+
+ PSRC = pcap-@V_PCAP@.c @USB_SRC@ @BT_SRC@ @CAN_SRC@
+ FSRC = fad-@V_FINDALLDEVS@.c
+@@ -94,6 +107,7 @@ SRC = $(PSRC) $(FSRC) $(CSRC) $(SSRC) $(
+ # We would like to say "OBJ = $(SRC:.c=.o)" but Ultrix's make cannot
+ # hack the extra indirection
+ OBJ = $(PSRC:.c=.o) $(FSRC:.c=.o) $(CSRC:.c=.o) $(SSRC:.c=.o) $(GENSRC:.c=.o) $(LIBOBJS)
++OBJ_PIC = $(PSRC:.c=_pic.o) $(FSRC:.c=_pic.o) $(CSRC:.c=_pic.o) $(SSRC:.c=_pic.o) $(GENSRC:.c=_pic.o)
+ PUBHDR = \
+ pcap.h \
+ pcap-bpf.h \
+@@ -131,7 +145,7 @@ TAGFILES = \
+
+ CLEANFILES = $(OBJ) libpcap.* filtertest findalldevstest selpolltest \
+ opentest $(PROG)-`cat $(srcdir)/VERSION`.tar.gz $(GENSRC) $(GENHDR) \
+- lex.yy.c pcap-config
++ lex.yy.c pcap-config $(OBJ_PIC)
+
+ MAN1 = pcap-config.1
+
+@@ -324,21 +338,14 @@ EXTRA_DIST = \
+ Win32/Src/inet_net.c \
+ Win32/Src/inet_pton.c
+
+-all: libpcap.a shared pcap-config
++all: libpcap.a shared pcap-config $(SHAREDLIB)
+
+ libpcap.a: $(OBJ)
+ @rm -f $@
+ ar rc $@ $(OBJ) $(ADDLARCHIVEOBJS)
+ $(RANLIB) $@
+
+-shared: libpcap.$(DYEXT)
+-
+-libpcap.so: $(OBJ)
+- @rm -f $@
+- VER=`cat $(srcdir)/VERSION`; \
+- MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
+- @V_SHLIB_CMD@ @V_SHLIB_OPT@ @V_SONAME_OPT@$@.$$MAJOR_VER $(LDFLAGS) \
+- -o $@.$$VER $(OBJ) $(ADDLOBJS) $(LIBS)
++shared: $(SHAREDLIB)
+
+ #
+ # The following rule succeeds, but the result is untested.
+@@ -409,6 +416,13 @@ libpcap.shareda: $(OBJ)
+ #
+ libpcap.none:
+
++$(SHAREDLIB): $(OBJ_PIC)
++ -@rm -f $@
++ -@rm -f $(SOLIBRARY) $(SOLIBRARY).$(MAJ)
++ $(CC) $(CFLAGS_SHARED) -o $(SHAREDLIB) $(OBJ_PIC) -lc
++ ln -s $(SHAREDLIB) $(SOLIBRARY).$(MAJ)
++ ln -s $(SOLIBRARY).$(MAJ) $(SOLIBRARY)
++
+ scanner.c: $(srcdir)/scanner.l
+ @rm -f $@
+ $(srcdir)/runlex.sh $(LEX) -o$@ $<
+@@ -416,6 +430,9 @@ scanner.c: $(srcdir)/scanner.l
+ scanner.o: scanner.c tokdefs.h
+ $(CC) $(CFLAGS) -c scanner.c
+
++scanner_pic.o: scanner.c tokdefs.h
++ $(CC) -fPIC $(CFLAGS) -o $@ -c scanner.c
++
+ pcap.o: version.h
+
+ tokdefs.h: grammar.c
+@@ -429,9 +446,17 @@ grammar.o: grammar.c
+ @rm -f $@
+ $(CC) $(CFLAGS) -Dyylval=pcap_lval -c grammar.c
+
++grammar_pic.o: grammar.c
++ @rm -f $@
++ $(CC) -fPIC $(CFLAGS) -Dyylval=pcap_lval -o $@ -c grammar.c
++
+ version.o: version.c
+ $(CC) $(CFLAGS) -c version.c
+
++version_pic.o: version.c
++ $(CC) -fPIC $(CFLAGS) -c version.c -o $@
++
++
+ snprintf.o: $(srcdir)/missing/snprintf.c
+ $(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/snprintf.c
+
+@@ -469,6 +494,9 @@ bpf_filter.c: $(srcdir)/bpf/net/bpf_filt
+ bpf_filter.o: bpf_filter.c
+ $(CC) $(CFLAGS) -c bpf_filter.c
+
++bpf_filter_pic.o: bpf_filter.c
++ $(CC) -fPIC $(CFLAGS) -c bpf_filter.c -o $@
++
+ #
+ # Generate the pcap-config script.
+ #
+@@ -562,14 +590,12 @@ install: install-shared install-archive
+ $(DESTDIR)$(mandir)/man@MAN_MISC_INFO@/`echo $$i | sed 's/.manmisc.in/.@MAN_MISC_INFO@/'`; done
+
+ install-shared: install-shared-$(DYEXT)
+-install-shared-so: libpcap.so
++install-shared-so: $(SHAREDLIB)
+ [ -d $(DESTDIR)$(libdir) ] || \
+ (mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
+- VER=`cat $(srcdir)/VERSION`; \
+- MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
+- $(INSTALL_PROGRAM) libpcap.so.$$VER $(DESTDIR)$(libdir)/libpcap.so.$$VER; \
+- ln -sf libpcap.so.$$VER $(DESTDIR)$(libdir)/libpcap.so.$$MAJOR_VER; \
+- ln -sf libpcap.so.$$MAJOR_VER $(DESTDIR)$(libdir)/libpcap.so
++ $(INSTALL_DATA) $(SHAREDLIB) $(DESTDIR)$(libdir)/
++ ln -sf $(SHAREDLIB) $(DESTDIR)$(libdir)/$(SOLIBRARY).$(MAJ)
++ ln -sf $(SOLIBRARY).$(MAJ) $(DESTDIR)$(libdir)/$(SOLIBRARY)
+ install-shared-dylib: libpcap.dylib
+ [ -d $(DESTDIR)$(libdir) ] || \
+ (mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
+--- a/configure
++++ b/configure
+@@ -3229,7 +3229,7 @@ _ACEOF
+ # or accepts command-line arguments like
+ # those the GNU linker accepts.
+ #
+- V_CCOPT="$V_CCOPT -fpic"
++ V_CCOPT="$V_CCOPT"
+ V_SONAME_OPT="-Wl,-soname,"
+ V_RPATH_OPT="-Wl,-rpath,"
+ ;;
+@@ -3292,7 +3292,7 @@ _ACEOF
+ #
+ # "cc" is GCC.
+ #
+- V_CCOPT="$V_CCOPT -fpic"
++ V_CCOPT="$V_CCOPT"
+ V_SHLIB_CMD="\$(CC)"
+ V_SHLIB_OPT="-shared"
+ V_SONAME_OPT="-Wl,-soname,"
diff --git a/package/libs/libpcap/patches/102-makefile_disable_manpages.patch b/package/libs/libpcap/patches/102-makefile_disable_manpages.patch
new file mode 100644
index 0000000..4674df5
--- /dev/null
+++ b/package/libs/libpcap/patches/102-makefile_disable_manpages.patch
@@ -0,0 +1,89 @@
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -532,62 +532,12 @@ install: install-shared install-archive
+ (mkdir -p $(DESTDIR)$(includedir); chmod 755 $(DESTDIR)$(includedir))
+ [ -d $(DESTDIR)$(includedir)/pcap ] || \
+ (mkdir -p $(DESTDIR)$(includedir)/pcap; chmod 755 $(DESTDIR)$(includedir)/pcap)
+- [ -d $(DESTDIR)$(mandir)/man1 ] || \
+- (mkdir -p $(DESTDIR)$(mandir)/man1; chmod 755 $(DESTDIR)$(mandir)/man1)
+- [ -d $(DESTDIR)$(mandir)/man3 ] || \
+- (mkdir -p $(DESTDIR)$(mandir)/man3; chmod 755 $(DESTDIR)$(mandir)/man3)
+- [ -d $(DESTDIR)$(mandir)/man@MAN_FILE_FORMATS@ ] || \
+- (mkdir -p $(DESTDIR)$(mandir)/man@MAN_FILE_FORMATS@; chmod 755 $(DESTDIR)$(mandir)/man@MAN_FILE_FORMATS@)
+- [ -d $(DESTDIR)$(mandir)/man@MAN_MISC_INFO@ ] || \
+- (mkdir -p $(DESTDIR)$(mandir)/man@MAN_MISC_INFO@; chmod 755 $(DESTDIR)$(mandir)/man@MAN_MISC_INFO@)
+ for i in $(PUBHDR); do \
+ $(INSTALL_DATA) $(srcdir)/$$i \
+ $(DESTDIR)$(includedir)/$$i; done
+ [ -d $(DESTDIR)$(bindir) ] || \
+ (mkdir -p $(DESTDIR)$(bindir); chmod 755 $(DESTDIR)$(bindir))
+ $(INSTALL_PROGRAM) pcap-config $(DESTDIR)$(bindir)/pcap-config
+- for i in $(MAN1); do \
+- $(INSTALL_DATA) $(srcdir)/$$i \
+- $(DESTDIR)$(mandir)/man1/$$i; done
+- for i in $(MAN3PCAP_NOEXPAND); do \
+- $(INSTALL_DATA) $(srcdir)/$$i \
+- $(DESTDIR)$(mandir)/man3/$$i; done
+- for i in $(MAN3PCAP_EXPAND:.in=); do \
+- $(INSTALL_DATA) $$i \
+- $(DESTDIR)$(mandir)/man3/$$i; done
+- rm -f $(DESTDIR)$(mandir)/man3/pcap_datalink_val_to_description.3pcap
+- ln $(DESTDIR)$(mandir)/man3/pcap_datalink_val_to_name.3pcap \
+- $(DESTDIR)$(mandir)/man3/pcap_datalink_val_to_description.3pcap
+- rm -f $(DESTDIR)$(mandir)/man3/pcap_dump_fopen.3pcap
+- ln $(DESTDIR)$(mandir)/man3/pcap_dump_open.3pcap \
+- $(DESTDIR)$(mandir)/man3/pcap_dump_fopen.3pcap
+- rm -f $(DESTDIR)$(mandir)/man3/pcap_perror.3pcap
+- ln $(DESTDIR)$(mandir)/man3/pcap_geterr.3pcap \
+- $(DESTDIR)$(mandir)/man3/pcap_perror.3pcap
+- rm -f $(DESTDIR)$(mandir)/man3/pcap_sendpacket.3pcap
+- ln $(DESTDIR)$(mandir)/man3/pcap_inject.3pcap \
+- $(DESTDIR)$(mandir)/man3/pcap_sendpacket.3pcap
+- rm -f $(DESTDIR)$(mandir)/man3/pcap_dispatch.3pcap
+- ln $(DESTDIR)$(mandir)/man3/pcap_loop.3pcap \
+- $(DESTDIR)$(mandir)/man3/pcap_dispatch.3pcap
+- rm -f $(DESTDIR)$(mandir)/man3/pcap_minor_version.3pcap
+- ln $(DESTDIR)$(mandir)/man3/pcap_major_version.3pcap \
+- $(DESTDIR)$(mandir)/man3/pcap_minor_version.3pcap
+- rm -f $(DESTDIR)$(mandir)/man3/pcap_next.3pcap
+- ln $(DESTDIR)$(mandir)/man3/pcap_next_ex.3pcap \
+- $(DESTDIR)$(mandir)/man3/pcap_next.3pcap
+- rm -f $(DESTDIR)$(mandir)/man3/pcap_fopen_offline.3pcap
+- ln $(DESTDIR)$(mandir)/man3/pcap_open_offline.3pcap \
+- $(DESTDIR)$(mandir)/man3/pcap_fopen_offline.3pcap
+- rm -f $(DESTDIR)$(mandir)/man3/pcap_getnonblock.3pcap
+- ln $(DESTDIR)$(mandir)/man3/pcap_setnonblock.3pcap \
+- $(DESTDIR)$(mandir)/man3/pcap_getnonblock.3pcap
+- for i in $(MANFILE); do \
+- $(INSTALL_DATA) `echo $$i | sed 's/.manfile.in/.manfile/'` \
+- $(DESTDIR)$(mandir)/man@MAN_FILE_FORMATS@/`echo $$i | sed 's/.manfile.in/.@MAN_FILE_FORMATS@/'`; done
+- for i in $(MANMISC); do \
+- $(INSTALL_DATA) `echo $$i | sed 's/.manmisc.in/.manmisc/'` \
+- $(DESTDIR)$(mandir)/man@MAN_MISC_INFO@/`echo $$i | sed 's/.manmisc.in/.@MAN_MISC_INFO@/'`; done
+
+ install-shared: install-shared-$(DYEXT)
+ install-shared-so: $(SHAREDLIB)
+@@ -642,23 +592,6 @@ uninstall: uninstall-shared
+ rm -f $(DESTDIR)$(includedir)/$$i; done
+ -rmdir $(DESTDIR)$(includedir)/pcap
+ rm -f $(DESTDIR)/$(bindir)/pcap-config
+- for i in $(MAN1); do \
+- rm -f $(DESTDIR)$(mandir)/man1/$$i; done
+- for i in $(MAN3PCAP); do \
+- rm -f $(DESTDIR)$(mandir)/man3/$$i; done
+- rm -f $(DESTDIR)$(mandir)/man3/pcap_datalink_val_to_description.3pcap
+- rm -f $(DESTDIR)$(mandir)/man3/pcap_dump_fopen.3pcap
+- rm -f $(DESTDIR)$(mandir)/man3/pcap_perror.3pcap
+- rm -f $(DESTDIR)$(mandir)/man3/pcap_sendpacket.3pcap
+- rm -f $(DESTDIR)$(mandir)/man3/pcap_dispatch.3pcap
+- rm -f $(DESTDIR)$(mandir)/man3/pcap_minor_version.3pcap
+- rm -f $(DESTDIR)$(mandir)/man3/pcap_next.3pcap
+- rm -f $(DESTDIR)$(mandir)/man3/pcap_fopen_offline.3pcap
+- rm -f $(DESTDIR)$(mandir)/man3/pcap_getnonblock.3pcap
+- for i in $(MANFILE); do \
+- rm -f $(DESTDIR)$(mandir)/man@MAN_FILE_FORMATS@/`echo $$i | sed 's/.manfile.in/.@MAN_FILE_FORMATS@/'`; done
+- for i in $(MANMISC); do \
+- rm -f $(DESTDIR)$(mandir)/man@MAN_MISC_INFO@/`echo $$i | sed 's/.manmisc.in/.@MAN_MISC_INFO@/'`; done
+
+ uninstall-shared: uninstall-shared-$(DYEXT)
+ uninstall-shared-so:
diff --git a/package/libs/libpcap/patches/103-makefile_flex_workaround.patch b/package/libs/libpcap/patches/103-makefile_flex_workaround.patch
new file mode 100644
index 0000000..a90e0ce
--- /dev/null
+++ b/package/libs/libpcap/patches/103-makefile_flex_workaround.patch
@@ -0,0 +1,14 @@
+
+ Copyright (C) 2006 Markus Wigge
+
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -56,7 +56,7 @@ LD = /usr/bin/ld
+ CC = @CC@
+ CCOPT = @V_CCOPT@
+ INCLS = -I. @V_INCLS@
+-DEFS = @DEFS@ @V_DEFS@
++DEFS = -D_BSD_SOURCE @DEFS@ @V_DEFS@
+ ADDLOBJS = @ADDLOBJS@
+ ADDLARCHIVEOBJS = @ADDLARCHIVEOBJS@
+ LIBS = @LIBS@
diff --git a/package/libs/libpcap/patches/201-space_optimization.patch b/package/libs/libpcap/patches/201-space_optimization.patch
new file mode 100644
index 0000000..f3eec4c
--- /dev/null
+++ b/package/libs/libpcap/patches/201-space_optimization.patch
@@ -0,0 +1,133 @@
+--- a/gencode.c
++++ b/gencode.c
+@@ -491,20 +491,6 @@ pcap_compile_nopcap(int snaplen_arg, int
+ }
+
+ /*
+- * Clean up a "struct bpf_program" by freeing all the memory allocated
+- * in it.
+- */
+-void
+-pcap_freecode(struct bpf_program *program)
+-{
+- program->bf_len = 0;
+- if (program->bf_insns != NULL) {
+- free((char *)program->bf_insns);
+- program->bf_insns = NULL;
+- }
+-}
+-
+-/*
+ * Backpatch the blocks in 'list' to 'target'. The 'sense' field indicates
+ * which of the jt and jf fields has been resolved and which is a pointer
+ * back to another unresolved block (or nil). At least one of the fields
+--- a/pcap.c
++++ b/pcap.c
+@@ -748,6 +748,59 @@ static const u_char charmap[] = {
+ (u_char)'\374', (u_char)'\375', (u_char)'\376', (u_char)'\377',
+ };
+
++/*
++ * Clean up a "struct bpf_program" by freeing all the memory allocated
++ * in it.
++ */
++void
++pcap_freecode(struct bpf_program *program)
++{
++ program->bf_len = 0;
++ if (program->bf_insns != NULL) {
++ free((char *)program->bf_insns);
++ program->bf_insns = NULL;
++ }
++}
++
++/*
++ * Make a copy of a BPF program and put it in the "fcode" member of
++ * a "pcap_t".
++ *
++ * If we fail to allocate memory for the copy, fill in the "errbuf"
++ * member of the "pcap_t" with an error message, and return -1;
++ * otherwise, return 0.
++ */
++int
++install_bpf_program(pcap_t *p, struct bpf_program *fp)
++{
++ size_t prog_size;
++
++ /*
++ * Validate the program.
++ */
++ if (!bpf_validate(fp->bf_insns, fp->bf_len)) {
++ snprintf(p->errbuf, sizeof(p->errbuf),
++ "BPF program is not valid");
++ return (-1);
++ }
++
++ /*
++ * Free up any already installed program.
++ */
++ pcap_freecode(&p->fcode);
++
++ prog_size = sizeof(*fp->bf_insns) * fp->bf_len;
++ p->fcode.bf_len = fp->bf_len;
++ p->fcode.bf_insns = (struct bpf_insn *)malloc(prog_size);
++ if (p->fcode.bf_insns == NULL) {
++ snprintf(p->errbuf, sizeof(p->errbuf),
++ "malloc: %s", pcap_strerror(errno));
++ return (-1);
++ }
++ memcpy(p->fcode.bf_insns, fp->bf_insns, prog_size);
++ return (0);
++}
++
+ int
+ pcap_strcasecmp(const char *s1, const char *s2)
+ {
+--- a/optimize.c
++++ b/optimize.c
+@@ -2292,45 +2292,6 @@ icode_to_fcode(root, lenp)
+ return fp;
+ }
+
+-/*
+- * Make a copy of a BPF program and put it in the "fcode" member of
+- * a "pcap_t".
+- *
+- * If we fail to allocate memory for the copy, fill in the "errbuf"
+- * member of the "pcap_t" with an error message, and return -1;
+- * otherwise, return 0.
+- */
+-int
+-install_bpf_program(pcap_t *p, struct bpf_program *fp)
+-{
+- size_t prog_size;
+-
+- /*
+- * Validate the program.
+- */
+- if (!bpf_validate(fp->bf_insns, fp->bf_len)) {
+- snprintf(p->errbuf, sizeof(p->errbuf),
+- "BPF program is not valid");
+- return (-1);
+- }
+-
+- /*
+- * Free up any already installed program.
+- */
+- pcap_freecode(&p->fcode);
+-
+- prog_size = sizeof(*fp->bf_insns) * fp->bf_len;
+- p->fcode.bf_len = fp->bf_len;
+- p->fcode.bf_insns = (struct bpf_insn *)malloc(prog_size);
+- if (p->fcode.bf_insns == NULL) {
+- snprintf(p->errbuf, sizeof(p->errbuf),
+- "malloc: %s", pcap_strerror(errno));
+- return (-1);
+- }
+- memcpy(p->fcode.bf_insns, fp->bf_insns, prog_size);
+- return (0);
+-}
+-
+ #ifdef BDEBUG
+ static void
+ opt_dump(root)
diff --git a/package/libs/libpcap/patches/202-protocol_api.patch b/package/libs/libpcap/patches/202-protocol_api.patch
new file mode 100644
index 0000000..892aeb7
--- /dev/null
+++ b/package/libs/libpcap/patches/202-protocol_api.patch
@@ -0,0 +1,141 @@
+--- a/pcap-int.h
++++ b/pcap-int.h
+@@ -209,6 +209,7 @@ struct pcap_opt {
+ char *source;
+ int promisc;
+ int rfmon;
++ int proto; /* protocol for packet socket (linux) */
+ };
+
+ /*
+--- a/pcap-linux.c
++++ b/pcap-linux.c
+@@ -335,7 +335,7 @@ static int iface_get_id(int fd, const ch
+ static int iface_get_mtu(int fd, const char *device, char *ebuf);
+ static int iface_get_arptype(int fd, const char *device, char *ebuf);
+ #ifdef HAVE_PF_PACKET_SOCKETS
+-static int iface_bind(int fd, int ifindex, char *ebuf);
++static int iface_bind(int fd, int ifindex, char *ebuf, unsigned short proto);
+ #ifdef IW_MODE_MONITOR
+ static int has_wext(int sock_fd, const char *device, char *ebuf);
+ #endif /* IW_MODE_MONITOR */
+@@ -881,7 +881,7 @@ pcap_can_set_rfmon_linux(pcap_t *handle)
+ * (We assume that if we have Wireless Extensions support
+ * we also have PF_PACKET support.)
+ */
+- sock_fd = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
++ sock_fd = socket(PF_PACKET, SOCK_RAW, p->opt.proto);
+ if (sock_fd == -1) {
+ (void)snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
+ "socket: %s", pcap_strerror(errno));
+@@ -1128,6 +1128,9 @@ pcap_activate_linux(pcap_t *handle)
+ handle->read_op = pcap_read_linux;
+ handle->stats_op = pcap_stats_linux;
+
++ if (handle->opt.proto < 0)
++ handle->opt.proto = (int) htons(ETH_P_ALL);
++
+ /*
+ * The "any" device is a special device which causes us not
+ * to bind to a particular device and thus to look at all
+@@ -2684,8 +2687,8 @@ activate_new(pcap_t *handle)
+ * try a SOCK_RAW socket for the raw interface.
+ */
+ sock_fd = is_any_device ?
+- socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_ALL)) :
+- socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
++ socket(PF_PACKET, SOCK_DGRAM, handle->opt.proto) :
++ socket(PF_PACKET, SOCK_RAW, handle->opt.proto);
+
+ if (sock_fd == -1) {
+ snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "socket: %s",
+@@ -2783,7 +2786,7 @@ activate_new(pcap_t *handle)
+ return PCAP_ERROR;
+ }
+ sock_fd = socket(PF_PACKET, SOCK_DGRAM,
+- htons(ETH_P_ALL));
++ handle->opt.proto);
+ if (sock_fd == -1) {
+ snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
+ "socket: %s", pcap_strerror(errno));
+@@ -2835,7 +2838,7 @@ activate_new(pcap_t *handle)
+ }
+
+ if ((err = iface_bind(sock_fd, handle->md.ifindex,
+- handle->errbuf)) != 1) {
++ handle->errbuf, handle->opt.proto)) != 1) {
+ close(sock_fd);
+ if (err < 0)
+ return err;
+@@ -3640,7 +3643,7 @@ iface_get_id(int fd, const char *device,
+ * or a PCAP_ERROR_ value on a hard error.
+ */
+ static int
+-iface_bind(int fd, int ifindex, char *ebuf)
++iface_bind(int fd, int ifindex, char *ebuf, unsigned short proto)
+ {
+ struct sockaddr_ll sll;
+ int err;
+@@ -3649,7 +3652,7 @@ iface_bind(int fd, int ifindex, char *eb
+ memset(&sll, 0, sizeof(sll));
+ sll.sll_family = AF_PACKET;
+ sll.sll_ifindex = ifindex;
+- sll.sll_protocol = htons(ETH_P_ALL);
++ sll.sll_protocol = proto;
+
+ if (bind(fd, (struct sockaddr *) &sll, sizeof(sll)) == -1) {
+ if (errno == ENETDOWN) {
+@@ -4359,7 +4362,7 @@ activate_old(pcap_t *handle)
+
+ /* Open the socket */
+
+- handle->fd = socket(PF_INET, SOCK_PACKET, htons(ETH_P_ALL));
++ handle->fd = socket(PF_INET, SOCK_PACKET, handle->opt.proto);
+ if (handle->fd == -1) {
+ snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
+ "socket: %s", pcap_strerror(errno));
+--- a/pcap.c
++++ b/pcap.c
+@@ -258,6 +258,8 @@ pcap_create_common(const char *source, c
+ pcap_set_snaplen(p, 65535); /* max packet size */
+ p->opt.promisc = 0;
+ p->opt.buffer_size = 0;
++ p->opt.proto = -1;
++
+ return (p);
+ }
+
+@@ -317,6 +319,15 @@ pcap_set_buffer_size(pcap_t *p, int buff
+ return 0;
+ }
+
++int
++pcap_set_protocol(pcap_t *p, unsigned short proto)
++{
++ if (pcap_check_activated(p))
++ return PCAP_ERROR_ACTIVATED;
++ p->opt.proto = proto;
++ return 0;
++}
++
+ int
+ pcap_activate(pcap_t *p)
+ {
+--- a/pcap/pcap.h
++++ b/pcap/pcap.h
+@@ -68,6 +68,7 @@ extern "C" {
+ #define PCAP_VERSION_MINOR 4
+
+ #define PCAP_ERRBUF_SIZE 256
++#define HAS_PROTO_EXTENSION
+
+ /*
+ * Compatibility for systems that have a bpf.h that
+@@ -276,6 +277,7 @@ int pcap_can_set_rfmon(pcap_t *);
+ int pcap_set_rfmon(pcap_t *, int);
+ int pcap_set_timeout(pcap_t *, int);
+ int pcap_set_buffer_size(pcap_t *, int);
++int pcap_set_protocol(pcap_t *, unsigned short);
+ int pcap_activate(pcap_t *);
+
+ pcap_t *pcap_open_live(const char *, int, int, int, char *);
diff --git a/package/libs/libpcap/patches/203-undef_iw_mode_monitor.patch b/package/libs/libpcap/patches/203-undef_iw_mode_monitor.patch
new file mode 100644
index 0000000..508c659
--- /dev/null
+++ b/package/libs/libpcap/patches/203-undef_iw_mode_monitor.patch
@@ -0,0 +1,11 @@
+--- a/pcap-linux.c
++++ b/pcap-linux.c
+@@ -254,6 +254,8 @@ static const char rcsid[] _U_ =
+ typedef int socklen_t;
+ #endif
+
++#undef IW_MODE_MONITOR
++
+ #ifndef MSG_TRUNC
+ /*
+ * This is being compiled on a system that lacks MSG_TRUNC; define it
diff --git a/package/libs/libreadline/.svn/entries b/package/libs/libreadline/.svn/entries
new file mode 100644
index 0000000..0145d88
--- /dev/null
+++ b/package/libs/libreadline/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs/libreadline
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-29T19:25:21.635659Z
+33997
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+c5d1580eebb5572e42f97f677bcd5222
+2012-10-29T19:25:21.635659Z
+33997
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1932
+
diff --git a/package/libs/libreadline/.svn/text-base/Makefile.svn-base b/package/libs/libreadline/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..0ce11a3
--- /dev/null
+++ b/package/libs/libreadline/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,72 @@
+#
+# Copyright (C) 2006 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=readline
+PKG_VERSION:=6.2
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=@GNU/readline
+PKG_MD5SUM:=67948acb2ca081f23359d0256e9a271c
+
+PKG_LICENSE:=GPLv3
+PKG_LICENSE_FILES:=COPYING
+
+PKG_BUILD_PARALLEL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/libreadline
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=Command lines edition library
+ URL:=http://cnswww.cns.cwru.edu/php/chet/readline/rltop.html
+endef
+
+define Package/libreadline/description
+ The Readline library provides a set of functions for use by applications
+ that allow users to edit command lines as they are typed in. Both Emacs
+ and vi editing modes are available. The Readline library includes
+ additional functions to maintain a list of previously-entered command
+ lines, to recall and perhaps reedit those lines, and perform csh-like
+ history expansion on previous commands.
+endef
+
+define Build/Configure
+ $(CP) $(SCRIPT_DIR)/config.guess $(SCRIPT_DIR)/config.sub $(PKG_BUILD_DIR)/support/
+ $(call Build/Configure/Default, \
+ --enable-shared \
+ --enable-static \
+ --without-curses \
+ )
+endef
+
+TARGET_CPPFLAGS:=-I. -I.. $(TARGET_CPPFLAGS)
+
+TARGET_CFLAGS += $(FPIC)
+
+define Build/Compile
+ $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
+ DESTDIR="$(PKG_INSTALL_DIR)" \
+ all install
+endef
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include
+ $(CP) $(PKG_INSTALL_DIR)/usr/include/readline $(1)/usr/include/
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{history,readline}.{a,so,so.6,so.6.2} $(1)/usr/lib/
+endef
+
+define Package/libreadline/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{history,readline}.{so,so.6,so.6.2} $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,libreadline))
diff --git a/package/libs/libreadline/Makefile b/package/libs/libreadline/Makefile
new file mode 100644
index 0000000..0ce11a3
--- /dev/null
+++ b/package/libs/libreadline/Makefile
@@ -0,0 +1,72 @@
+#
+# Copyright (C) 2006 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=readline
+PKG_VERSION:=6.2
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=@GNU/readline
+PKG_MD5SUM:=67948acb2ca081f23359d0256e9a271c
+
+PKG_LICENSE:=GPLv3
+PKG_LICENSE_FILES:=COPYING
+
+PKG_BUILD_PARALLEL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/libreadline
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=Command lines edition library
+ URL:=http://cnswww.cns.cwru.edu/php/chet/readline/rltop.html
+endef
+
+define Package/libreadline/description
+ The Readline library provides a set of functions for use by applications
+ that allow users to edit command lines as they are typed in. Both Emacs
+ and vi editing modes are available. The Readline library includes
+ additional functions to maintain a list of previously-entered command
+ lines, to recall and perhaps reedit those lines, and perform csh-like
+ history expansion on previous commands.
+endef
+
+define Build/Configure
+ $(CP) $(SCRIPT_DIR)/config.guess $(SCRIPT_DIR)/config.sub $(PKG_BUILD_DIR)/support/
+ $(call Build/Configure/Default, \
+ --enable-shared \
+ --enable-static \
+ --without-curses \
+ )
+endef
+
+TARGET_CPPFLAGS:=-I. -I.. $(TARGET_CPPFLAGS)
+
+TARGET_CFLAGS += $(FPIC)
+
+define Build/Compile
+ $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
+ DESTDIR="$(PKG_INSTALL_DIR)" \
+ all install
+endef
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include
+ $(CP) $(PKG_INSTALL_DIR)/usr/include/readline $(1)/usr/include/
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{history,readline}.{a,so,so.6,so.6.2} $(1)/usr/lib/
+endef
+
+define Package/libreadline/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{history,readline}.{so,so.6,so.6.2} $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,libreadline))
diff --git a/package/libs/librpc/.svn/entries b/package/libs/librpc/.svn/entries
new file mode 100644
index 0000000..a4e3fc3
--- /dev/null
+++ b/package/libs/librpc/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs/librpc
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-19T15:34:28.915431Z
+33861
+hcg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+4123909ea4fc4877aef8d64b249b9bde
+2012-10-19T15:34:28.915431Z
+33861
+hcg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+788
+
diff --git a/package/libs/librpc/.svn/text-base/Makefile.svn-base b/package/libs/librpc/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..21d81f0
--- /dev/null
+++ b/package/libs/librpc/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,33 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=librpc
+PKG_VERSION:=0.9.32-rc2
+PKG_RELEASE=$(PKG_SOURCE_VERSION)
+
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL:=git://nbd.name/uclibc-rpc.git
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE_VERSION:=0a2179bbc0844928f2a0ec01dba93d9b5d6d41a7
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
+CMAKE_INSTALL:=1
+
+PKG_LICENSE:=GPLv2 LGPLv2.1
+PKG_LICENSE_FILES:=
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/cmake.mk
+
+define Package/librpc
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=uClibc RPC library
+endef
+
+define Package/librpc/install
+ $(INSTALL_DIR) $(1)/lib/
+ $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/librpc.so $(1)/lib/
+endef
+
+$(eval $(call BuildPackage,librpc))
diff --git a/package/libs/librpc/Makefile b/package/libs/librpc/Makefile
new file mode 100644
index 0000000..21d81f0
--- /dev/null
+++ b/package/libs/librpc/Makefile
@@ -0,0 +1,33 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=librpc
+PKG_VERSION:=0.9.32-rc2
+PKG_RELEASE=$(PKG_SOURCE_VERSION)
+
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL:=git://nbd.name/uclibc-rpc.git
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE_VERSION:=0a2179bbc0844928f2a0ec01dba93d9b5d6d41a7
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
+CMAKE_INSTALL:=1
+
+PKG_LICENSE:=GPLv2 LGPLv2.1
+PKG_LICENSE_FILES:=
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/cmake.mk
+
+define Package/librpc
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=uClibc RPC library
+endef
+
+define Package/librpc/install
+ $(INSTALL_DIR) $(1)/lib/
+ $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/librpc.so $(1)/lib/
+endef
+
+$(eval $(call BuildPackage,librpc))
diff --git a/package/libs/librpc/patches/.svn/entries b/package/libs/librpc/patches/.svn/entries
new file mode 100644
index 0000000..b4fb799
--- /dev/null
+++ b/package/libs/librpc/patches/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs/librpc/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+100-compat_fix.patch
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+200c3548e87d1204937b31e03cbdd772
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5151
+
diff --git a/package/libs/librpc/patches/.svn/text-base/100-compat_fix.patch.svn-base b/package/libs/librpc/patches/.svn/text-base/100-compat_fix.patch.svn-base
new file mode 100644
index 0000000..a0f03f6
--- /dev/null
+++ b/package/libs/librpc/patches/.svn/text-base/100-compat_fix.patch.svn-base
@@ -0,0 +1,214 @@
+--- a/compat.h
++++ /dev/null
+@@ -1,32 +0,0 @@
+-#ifndef __UCLIBC_COMPAT_H
+-#define __UCLIBC_COMPAT_H
+-
+-#define _XOPEN_SOURCE
+-#define _GNU_SOURCE
+-
+-#include <features.h>
+-#include <errno.h>
+-
+-#undef __UCLIBC_HAS_THREADS__
+-#include <bits/uClibc_mutex.h>
+-#include <sys/poll.h>
+-
+-#if 0
+-#undef __UCLIBC_MUTEX_LOCK
+-#undef __UCLIBC_MUTEX_UNLOCK
+-#define __UCLIBC_MUTEX_LOCK(M) pthread_mutex_lock(&(M))
+-#define __UCLIBC_MUTEX_UNLOCK(M) pthread_mutex_unlock(&(M))
+-#endif
+-
+-#define smallint int
+-
+-#define _(...) __VA_ARGS__
+-#define internal_function
+-#define attribute_hidden
+-#define attribute_unused
+-#define attribute_noreturn
+-#define libc_hidden_def(...)
+-
+-#define __set_errno(_val) errno = _val
+-
+-#endif
+--- a/rcmd.c
++++ b/rcmd.c
+@@ -85,7 +85,6 @@ static char sccsid[] = "@(#)rcmd.c 8.3 (
+ #include <wchar.h>
+ #endif
+ #include <sys/uio.h>
+-#include <bits/uClibc_alloc.h>
+
+
+ /* some forward declarations */
+--- a/create_xid.c
++++ b/create_xid.c
+@@ -28,7 +28,6 @@
+
+ /* The RPC code is not threadsafe, but new code should be threadsafe. */
+
+-#include <bits/uClibc_mutex.h>
+ __UCLIBC_MUTEX_STATIC(mylock, PTHREAD_MUTEX_INITIALIZER);
+
+ static smallint is_initialized;
+--- a/getrpcent.c
++++ b/getrpcent.c
+@@ -257,7 +257,6 @@ static struct rpcent *interpret(register
+
+ #if defined(__UCLIBC_HAS_REENTRANT_RPC__)
+
+-#include <bits/uClibc_mutex.h>
+ __UCLIBC_MUTEX_STATIC(mylock, PTHREAD_MUTEX_INITIALIZER);
+
+
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -1,7 +1,7 @@
+ cmake_minimum_required(VERSION 2.6)
+
+ PROJECT(rpc C)
+-ADD_DEFINITIONS(-Os -Wall --std=gnu99 -g3 -I. -include compat.h)
++ADD_DEFINITIONS(-Os -Wall --std=gnu99 -g3 -I. -include rpc/compat.h)
+
+ FILE(GLOB SOURCES *.c)
+
+--- a/rpc/types.h
++++ b/rpc/types.h
+@@ -33,6 +33,8 @@
+ #ifndef _RPC_TYPES_H
+ #define _RPC_TYPES_H 1
+
++#include "compat.h"
++
+ #ifdef _LIBC
+ /* Some adjustments to make the libc source from glibc
+ * compile more easily with uClibc... */
+--- a/clnt_perror.c
++++ b/clnt_perror.c
+@@ -246,7 +246,7 @@ clnt_sperror (CLIENT * rpch, const char
+
+ case RPC_CANTSEND:
+ case RPC_CANTRECV:
+- __glibc_strerror_r (e.re_errno, chrbuf, sizeof chrbuf);
++ strerror_r (e.re_errno, chrbuf, sizeof chrbuf);
+ len = sprintf (str, "; errno = %s", chrbuf);
+ str += len;
+ break;
+@@ -336,7 +336,7 @@ clnt_spcreateerror (const char *msg)
+ (void) strcpy(cp, " - ");
+ cp += strlen(cp);
+
+- __glibc_strerror_r (ce->cf_error.re_errno, chrbuf, sizeof chrbuf);
++ strerror_r (ce->cf_error.re_errno, chrbuf, sizeof chrbuf);
+ (void) strcpy(cp, chrbuf);
+ cp += strlen(cp);
+ break;
+--- a/rpc_thread.c
++++ b/rpc_thread.c
+@@ -13,9 +13,6 @@
+
+ #ifdef __UCLIBC_HAS_THREADS__
+
+-#include <bits/libc-tsd.h>
+-#include <bits/libc-lock.h>
+-
+ /* Variable used in non-threaded applications or for the first thread. */
+ static struct rpc_thread_variables __libc_tsd_RPC_VARS_mem;
+ __libc_tsd_define (, RPC_VARS)
+@@ -52,16 +49,17 @@ rpc_thread_multi (void)
+ __libc_tsd_set (RPC_VARS, &__libc_tsd_RPC_VARS_mem);
+ }
+
++__UCLIBC_MUTEX_STATIC(mylock, PTHREAD_MUTEX_INITIALIZER);
+
+ struct rpc_thread_variables attribute_hidden *
+ __rpc_thread_variables (void)
+ {
+- __libc_once_define (static, once);
+ struct rpc_thread_variables *tvp;
+
++ __UCLIBC_MUTEX_LOCK(mylock);
+ tvp = __libc_tsd_get (RPC_VARS);
+ if (tvp == NULL) {
+- __libc_once (once, rpc_thread_multi);
++ rpc_thread_multi();
+ tvp = __libc_tsd_get (RPC_VARS);
+ if (tvp == NULL) {
+ tvp = calloc (1, sizeof *tvp);
+@@ -71,6 +69,7 @@ __rpc_thread_variables (void)
+ tvp = __libc_tsd_get (RPC_VARS);
+ }
+ }
++ __UCLIBC_MUTEX_UNLOCK(mylock);
+ return tvp;
+ }
+
+--- /dev/null
++++ b/rpc/compat.h
+@@ -0,0 +1,53 @@
++#ifndef __UCLIBC_COMPAT_H
++#define __UCLIBC_COMPAT_H
++
++#define _XOPEN_SOURCE
++#define _GNU_SOURCE
++
++#include <features.h>
++#include <errno.h>
++
++#ifndef __UCLIBC_HAS_THREADS__
++#define __UCLIBC_HAS_THREADS__
++#endif
++
++#include <sys/poll.h>
++#include <pthread.h>
++
++#ifdef __UCLIBC__
++#include <bits/libc-lock.h>
++#else
++#undef __UCLIBC_MUTEX_STATIC
++#undef __UCLIBC_MUTEX_LOCK
++#undef __UCLIBC_MUTEX_UNLOCK
++#define __UCLIBC_MUTEX_STATIC(M,I) static pthread_mutex_t M = I
++#define __UCLIBC_MUTEX_LOCK(M) pthread_mutex_lock(&(M))
++#define __UCLIBC_MUTEX_UNLOCK(M) pthread_mutex_unlock(&(M))
++#endif
++
++#define smallint int
++
++#define _(...) __VA_ARGS__
++#define internal_function
++#define attribute_hidden
++#define attribute_unused
++#define attribute_noreturn
++#define libc_hidden_def(...)
++
++#ifndef libc_hidden_proto
++#define libc_hidden_proto(name, attrs...)
++#endif
++
++#define __set_errno(_val) errno = _val
++
++# define attribute_tls_model_ie __attribute__ ((tls_model ("initial-exec")))
++
++# define __libc_tsd_define(CLASS, KEY) \
++ CLASS __thread void *__libc_tsd_##KEY attribute_tls_model_ie;
++
++# define __libc_tsd_address(KEY) (&__libc_tsd_##KEY)
++# define __libc_tsd_get(KEY) (__libc_tsd_##KEY)
++# define __libc_tsd_set(KEY, VALUE) (__libc_tsd_##KEY = (VALUE))
++
++
++#endif
+--- a/rpc/netdb.h
++++ b/rpc/netdb.h
+@@ -41,6 +41,8 @@
+ #define __need_size_t
+ #include <stddef.h>
+
++#include "types.h"
++
+ __BEGIN_DECLS
+
+ struct rpcent
diff --git a/package/libs/librpc/patches/100-compat_fix.patch b/package/libs/librpc/patches/100-compat_fix.patch
new file mode 100644
index 0000000..a0f03f6
--- /dev/null
+++ b/package/libs/librpc/patches/100-compat_fix.patch
@@ -0,0 +1,214 @@
+--- a/compat.h
++++ /dev/null
+@@ -1,32 +0,0 @@
+-#ifndef __UCLIBC_COMPAT_H
+-#define __UCLIBC_COMPAT_H
+-
+-#define _XOPEN_SOURCE
+-#define _GNU_SOURCE
+-
+-#include <features.h>
+-#include <errno.h>
+-
+-#undef __UCLIBC_HAS_THREADS__
+-#include <bits/uClibc_mutex.h>
+-#include <sys/poll.h>
+-
+-#if 0
+-#undef __UCLIBC_MUTEX_LOCK
+-#undef __UCLIBC_MUTEX_UNLOCK
+-#define __UCLIBC_MUTEX_LOCK(M) pthread_mutex_lock(&(M))
+-#define __UCLIBC_MUTEX_UNLOCK(M) pthread_mutex_unlock(&(M))
+-#endif
+-
+-#define smallint int
+-
+-#define _(...) __VA_ARGS__
+-#define internal_function
+-#define attribute_hidden
+-#define attribute_unused
+-#define attribute_noreturn
+-#define libc_hidden_def(...)
+-
+-#define __set_errno(_val) errno = _val
+-
+-#endif
+--- a/rcmd.c
++++ b/rcmd.c
+@@ -85,7 +85,6 @@ static char sccsid[] = "@(#)rcmd.c 8.3 (
+ #include <wchar.h>
+ #endif
+ #include <sys/uio.h>
+-#include <bits/uClibc_alloc.h>
+
+
+ /* some forward declarations */
+--- a/create_xid.c
++++ b/create_xid.c
+@@ -28,7 +28,6 @@
+
+ /* The RPC code is not threadsafe, but new code should be threadsafe. */
+
+-#include <bits/uClibc_mutex.h>
+ __UCLIBC_MUTEX_STATIC(mylock, PTHREAD_MUTEX_INITIALIZER);
+
+ static smallint is_initialized;
+--- a/getrpcent.c
++++ b/getrpcent.c
+@@ -257,7 +257,6 @@ static struct rpcent *interpret(register
+
+ #if defined(__UCLIBC_HAS_REENTRANT_RPC__)
+
+-#include <bits/uClibc_mutex.h>
+ __UCLIBC_MUTEX_STATIC(mylock, PTHREAD_MUTEX_INITIALIZER);
+
+
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -1,7 +1,7 @@
+ cmake_minimum_required(VERSION 2.6)
+
+ PROJECT(rpc C)
+-ADD_DEFINITIONS(-Os -Wall --std=gnu99 -g3 -I. -include compat.h)
++ADD_DEFINITIONS(-Os -Wall --std=gnu99 -g3 -I. -include rpc/compat.h)
+
+ FILE(GLOB SOURCES *.c)
+
+--- a/rpc/types.h
++++ b/rpc/types.h
+@@ -33,6 +33,8 @@
+ #ifndef _RPC_TYPES_H
+ #define _RPC_TYPES_H 1
+
++#include "compat.h"
++
+ #ifdef _LIBC
+ /* Some adjustments to make the libc source from glibc
+ * compile more easily with uClibc... */
+--- a/clnt_perror.c
++++ b/clnt_perror.c
+@@ -246,7 +246,7 @@ clnt_sperror (CLIENT * rpch, const char
+
+ case RPC_CANTSEND:
+ case RPC_CANTRECV:
+- __glibc_strerror_r (e.re_errno, chrbuf, sizeof chrbuf);
++ strerror_r (e.re_errno, chrbuf, sizeof chrbuf);
+ len = sprintf (str, "; errno = %s", chrbuf);
+ str += len;
+ break;
+@@ -336,7 +336,7 @@ clnt_spcreateerror (const char *msg)
+ (void) strcpy(cp, " - ");
+ cp += strlen(cp);
+
+- __glibc_strerror_r (ce->cf_error.re_errno, chrbuf, sizeof chrbuf);
++ strerror_r (ce->cf_error.re_errno, chrbuf, sizeof chrbuf);
+ (void) strcpy(cp, chrbuf);
+ cp += strlen(cp);
+ break;
+--- a/rpc_thread.c
++++ b/rpc_thread.c
+@@ -13,9 +13,6 @@
+
+ #ifdef __UCLIBC_HAS_THREADS__
+
+-#include <bits/libc-tsd.h>
+-#include <bits/libc-lock.h>
+-
+ /* Variable used in non-threaded applications or for the first thread. */
+ static struct rpc_thread_variables __libc_tsd_RPC_VARS_mem;
+ __libc_tsd_define (, RPC_VARS)
+@@ -52,16 +49,17 @@ rpc_thread_multi (void)
+ __libc_tsd_set (RPC_VARS, &__libc_tsd_RPC_VARS_mem);
+ }
+
++__UCLIBC_MUTEX_STATIC(mylock, PTHREAD_MUTEX_INITIALIZER);
+
+ struct rpc_thread_variables attribute_hidden *
+ __rpc_thread_variables (void)
+ {
+- __libc_once_define (static, once);
+ struct rpc_thread_variables *tvp;
+
++ __UCLIBC_MUTEX_LOCK(mylock);
+ tvp = __libc_tsd_get (RPC_VARS);
+ if (tvp == NULL) {
+- __libc_once (once, rpc_thread_multi);
++ rpc_thread_multi();
+ tvp = __libc_tsd_get (RPC_VARS);
+ if (tvp == NULL) {
+ tvp = calloc (1, sizeof *tvp);
+@@ -71,6 +69,7 @@ __rpc_thread_variables (void)
+ tvp = __libc_tsd_get (RPC_VARS);
+ }
+ }
++ __UCLIBC_MUTEX_UNLOCK(mylock);
+ return tvp;
+ }
+
+--- /dev/null
++++ b/rpc/compat.h
+@@ -0,0 +1,53 @@
++#ifndef __UCLIBC_COMPAT_H
++#define __UCLIBC_COMPAT_H
++
++#define _XOPEN_SOURCE
++#define _GNU_SOURCE
++
++#include <features.h>
++#include <errno.h>
++
++#ifndef __UCLIBC_HAS_THREADS__
++#define __UCLIBC_HAS_THREADS__
++#endif
++
++#include <sys/poll.h>
++#include <pthread.h>
++
++#ifdef __UCLIBC__
++#include <bits/libc-lock.h>
++#else
++#undef __UCLIBC_MUTEX_STATIC
++#undef __UCLIBC_MUTEX_LOCK
++#undef __UCLIBC_MUTEX_UNLOCK
++#define __UCLIBC_MUTEX_STATIC(M,I) static pthread_mutex_t M = I
++#define __UCLIBC_MUTEX_LOCK(M) pthread_mutex_lock(&(M))
++#define __UCLIBC_MUTEX_UNLOCK(M) pthread_mutex_unlock(&(M))
++#endif
++
++#define smallint int
++
++#define _(...) __VA_ARGS__
++#define internal_function
++#define attribute_hidden
++#define attribute_unused
++#define attribute_noreturn
++#define libc_hidden_def(...)
++
++#ifndef libc_hidden_proto
++#define libc_hidden_proto(name, attrs...)
++#endif
++
++#define __set_errno(_val) errno = _val
++
++# define attribute_tls_model_ie __attribute__ ((tls_model ("initial-exec")))
++
++# define __libc_tsd_define(CLASS, KEY) \
++ CLASS __thread void *__libc_tsd_##KEY attribute_tls_model_ie;
++
++# define __libc_tsd_address(KEY) (&__libc_tsd_##KEY)
++# define __libc_tsd_get(KEY) (__libc_tsd_##KEY)
++# define __libc_tsd_set(KEY, VALUE) (__libc_tsd_##KEY = (VALUE))
++
++
++#endif
+--- a/rpc/netdb.h
++++ b/rpc/netdb.h
+@@ -41,6 +41,8 @@
+ #define __need_size_t
+ #include <stddef.h>
+
++#include "types.h"
++
+ __BEGIN_DECLS
+
+ struct rpcent
diff --git a/package/libs/libtool/.svn/entries b/package/libs/libtool/.svn/entries
new file mode 100644
index 0000000..d1ecd10
--- /dev/null
+++ b/package/libs/libtool/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs/libtool
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-19T15:34:28.915431Z
+33861
+hcg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:07.000000Z
+37ae8febd199c8347042b59196d3a03c
+2012-10-19T15:34:28.915431Z
+33861
+hcg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1143
+
diff --git a/package/libs/libtool/.svn/text-base/Makefile.svn-base b/package/libs/libtool/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..df18c1d
--- /dev/null
+++ b/package/libs/libtool/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,52 @@
+#
+# Copyright (C) 2006 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=libtool
+PKG_VERSION:=2.4
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=@GNU/libtool
+PKG_MD5SUM:=b32b04148ecdd7344abc6fe8bd1bb021
+
+PKG_LICENSE:=GPLv2
+PKG_LICENSE_FILES:=COPYING
+
+PKG_BUILD_PARALLEL:=0
+
+include $(INCLUDE_DIR)/package.mk
+
+CONFIGURE_PREFIX=$(STAGING_DIR)/host
+export GLOBAL_LIBDIR=$(STAGING_DIR)/usr/lib
+
+define Package/libltdl
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=A generic dynamic object loading library
+ URL:=http://www.gnu.org/software/libtool/
+endef
+
+define Build/InstallDev
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ bindir="$(2)/bin" \
+ datadir="$(2)/share" \
+ prefix="$(2)" \
+ exec_prefix="$(2)" \
+ install
+ $(INSTALL_DIR) $(1)/usr/lib $(1)/usr/include
+ mv $(2)/lib/* $(1)/usr/lib/
+ mv $(2)/include/* $(1)/usr/include/
+endef
+
+define Package/libltdl/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_BUILD_DIR)/libltdl/.libs/libltdl.so.* $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,libltdl))
diff --git a/package/libs/libtool/Makefile b/package/libs/libtool/Makefile
new file mode 100644
index 0000000..df18c1d
--- /dev/null
+++ b/package/libs/libtool/Makefile
@@ -0,0 +1,52 @@
+#
+# Copyright (C) 2006 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=libtool
+PKG_VERSION:=2.4
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=@GNU/libtool
+PKG_MD5SUM:=b32b04148ecdd7344abc6fe8bd1bb021
+
+PKG_LICENSE:=GPLv2
+PKG_LICENSE_FILES:=COPYING
+
+PKG_BUILD_PARALLEL:=0
+
+include $(INCLUDE_DIR)/package.mk
+
+CONFIGURE_PREFIX=$(STAGING_DIR)/host
+export GLOBAL_LIBDIR=$(STAGING_DIR)/usr/lib
+
+define Package/libltdl
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=A generic dynamic object loading library
+ URL:=http://www.gnu.org/software/libtool/
+endef
+
+define Build/InstallDev
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ bindir="$(2)/bin" \
+ datadir="$(2)/share" \
+ prefix="$(2)" \
+ exec_prefix="$(2)" \
+ install
+ $(INSTALL_DIR) $(1)/usr/lib $(1)/usr/include
+ mv $(2)/lib/* $(1)/usr/lib/
+ mv $(2)/include/* $(1)/usr/include/
+endef
+
+define Package/libltdl/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_BUILD_DIR)/libltdl/.libs/libltdl.so.* $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,libltdl))
diff --git a/package/libs/libubox/.svn/entries b/package/libs/libubox/.svn/entries
new file mode 100644
index 0000000..59221d1
--- /dev/null
+++ b/package/libs/libubox/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs/libubox
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-13T15:44:08.492023Z
+35996
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:07.000000Z
+bfa51cac95a7bef377b76302e2975916
+2013-03-13T15:44:08.492023Z
+35996
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2127
+
diff --git a/package/libs/libubox/.svn/text-base/Makefile.svn-base b/package/libs/libubox/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..ea440c4
--- /dev/null
+++ b/package/libs/libubox/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,85 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=libubox
+PKG_VERSION:=2013-03-05
+PKG_RELEASE=$(PKG_SOURCE_VERSION)
+
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL:=git://nbd.name/luci2/libubox.git
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE_VERSION:=49e6e062b8effe281a85de167c16c5f039b74442
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
+PKG_MIRROR_MD5SUM:=b32d297d846b271585925f190fad2c60
+CMAKE_INSTALL:=1
+
+PKG_LICENSE:=ISC BSD-3c
+PKG_LICENSE_FILES:=
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+
+PKG_BUILD_DEPENDS:=lua
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/cmake.mk
+
+define Package/libubox
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=Basic utility library
+ DEPENDS:=
+endef
+
+define Package/libblobmsg-json
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=blobmsg <-> json conversion library
+ DEPENDS:=+libjson +libubox
+endef
+
+define Package/jshn
+ SECTION:=utils
+ CATEGORY:=Utilities
+ DEPENDS:=+libjson
+ TITLE:=JSON SHell Notation
+endef
+
+define Package/jshn/description
+ Library for parsing and generating JSON from shell scripts
+endef
+
+define Package/libjson-script
+ SECTION:=utils
+ CATEGORY:=Utilities
+ DEPENDS:=+libubox
+ TITLE:=Minimalistic JSON based scripting engine
+endef
+
+TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include
+CMAKE_OPTIONS = \
+ -DLUAPATH=/usr/lib/lua
+
+define Package/libubox/install
+ $(INSTALL_DIR) $(1)/lib/
+ $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libubox.so $(1)/lib/
+endef
+
+define Package/libblobmsg-json/install
+ $(INSTALL_DIR) $(1)/lib/
+ $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libblobmsg_json.so $(1)/lib/
+endef
+
+define Package/jshn/install
+ $(INSTALL_DIR) $(1)/usr/bin $(1)/usr/share/libubox
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/jshn $(1)/usr/bin
+ $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/share/libubox/jshn.sh $(1)/usr/share/libubox
+endef
+
+define Package/libjson-script/install
+ $(INSTALL_DIR) $(1)/lib/
+ $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libjson_script.so $(1)/lib/
+endef
+
+$(eval $(call BuildPackage,libubox))
+$(eval $(call BuildPackage,libblobmsg-json))
+$(eval $(call BuildPackage,jshn))
+$(eval $(call BuildPackage,libjson-script))
diff --git a/package/libs/libubox/Makefile b/package/libs/libubox/Makefile
new file mode 100644
index 0000000..ea440c4
--- /dev/null
+++ b/package/libs/libubox/Makefile
@@ -0,0 +1,85 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=libubox
+PKG_VERSION:=2013-03-05
+PKG_RELEASE=$(PKG_SOURCE_VERSION)
+
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL:=git://nbd.name/luci2/libubox.git
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE_VERSION:=49e6e062b8effe281a85de167c16c5f039b74442
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
+PKG_MIRROR_MD5SUM:=b32d297d846b271585925f190fad2c60
+CMAKE_INSTALL:=1
+
+PKG_LICENSE:=ISC BSD-3c
+PKG_LICENSE_FILES:=
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+
+PKG_BUILD_DEPENDS:=lua
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/cmake.mk
+
+define Package/libubox
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=Basic utility library
+ DEPENDS:=
+endef
+
+define Package/libblobmsg-json
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=blobmsg <-> json conversion library
+ DEPENDS:=+libjson +libubox
+endef
+
+define Package/jshn
+ SECTION:=utils
+ CATEGORY:=Utilities
+ DEPENDS:=+libjson
+ TITLE:=JSON SHell Notation
+endef
+
+define Package/jshn/description
+ Library for parsing and generating JSON from shell scripts
+endef
+
+define Package/libjson-script
+ SECTION:=utils
+ CATEGORY:=Utilities
+ DEPENDS:=+libubox
+ TITLE:=Minimalistic JSON based scripting engine
+endef
+
+TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include
+CMAKE_OPTIONS = \
+ -DLUAPATH=/usr/lib/lua
+
+define Package/libubox/install
+ $(INSTALL_DIR) $(1)/lib/
+ $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libubox.so $(1)/lib/
+endef
+
+define Package/libblobmsg-json/install
+ $(INSTALL_DIR) $(1)/lib/
+ $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libblobmsg_json.so $(1)/lib/
+endef
+
+define Package/jshn/install
+ $(INSTALL_DIR) $(1)/usr/bin $(1)/usr/share/libubox
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/jshn $(1)/usr/bin
+ $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/share/libubox/jshn.sh $(1)/usr/share/libubox
+endef
+
+define Package/libjson-script/install
+ $(INSTALL_DIR) $(1)/lib/
+ $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libjson_script.so $(1)/lib/
+endef
+
+$(eval $(call BuildPackage,libubox))
+$(eval $(call BuildPackage,libblobmsg-json))
+$(eval $(call BuildPackage,jshn))
+$(eval $(call BuildPackage,libjson-script))
diff --git a/package/libs/libusb-compat/.svn/entries b/package/libs/libusb-compat/.svn/entries
new file mode 100644
index 0000000..507be3b
--- /dev/null
+++ b/package/libs/libusb-compat/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs/libusb-compat
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-29T16:12:00.814933Z
+35387
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:07.000000Z
+b5b52a9c660bd7cdd53f65e72e05a227
+2013-01-29T16:12:00.814933Z
+35387
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1102
+
diff --git a/package/libs/libusb-compat/.svn/text-base/Makefile.svn-base b/package/libs/libusb-compat/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..e80f80b
--- /dev/null
+++ b/package/libs/libusb-compat/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,49 @@
+#
+# Copyright (C) 2010-2013 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=libusb-compat
+PKG_VERSION:=0.1.4
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=@SF/libusb
+PKG_MD5SUM:=2ca521fffadd0c28fdf174e6ec73865b
+
+PKG_INSTALL:=1
+PKG_BUILD_PARALLEL:=1
+
+PKG_MAINTAINER := Felix Fietkau <nbd@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/libusb-compat
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=libusb-0.1 compatibility library
+ DEPENDS:=+libusb-1.0
+ URL:=http://libusb.wiki.sourceforge.net/
+endef
+
+define Package/libusb-compat/description
+ libusb is a C library that gives applications easy access to USB devices on
+ many different operating systems.
+endef
+
+TARGET_CFLAGS += $(FPIC)
+
+define Build/InstallDev
+ $(CP) $(PKG_INSTALL_DIR)/* $(1)/
+endef
+
+define Package/libusb-compat/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libusb-0.1.so* $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,libusb-compat))
diff --git a/package/libs/libusb-compat/Makefile b/package/libs/libusb-compat/Makefile
new file mode 100644
index 0000000..e80f80b
--- /dev/null
+++ b/package/libs/libusb-compat/Makefile
@@ -0,0 +1,49 @@
+#
+# Copyright (C) 2010-2013 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=libusb-compat
+PKG_VERSION:=0.1.4
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=@SF/libusb
+PKG_MD5SUM:=2ca521fffadd0c28fdf174e6ec73865b
+
+PKG_INSTALL:=1
+PKG_BUILD_PARALLEL:=1
+
+PKG_MAINTAINER := Felix Fietkau <nbd@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/libusb-compat
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=libusb-0.1 compatibility library
+ DEPENDS:=+libusb-1.0
+ URL:=http://libusb.wiki.sourceforge.net/
+endef
+
+define Package/libusb-compat/description
+ libusb is a C library that gives applications easy access to USB devices on
+ many different operating systems.
+endef
+
+TARGET_CFLAGS += $(FPIC)
+
+define Build/InstallDev
+ $(CP) $(PKG_INSTALL_DIR)/* $(1)/
+endef
+
+define Package/libusb-compat/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libusb-0.1.so* $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,libusb-compat))
diff --git a/package/libs/libusb/.svn/entries b/package/libs/libusb/.svn/entries
new file mode 100644
index 0000000..283e9fc
--- /dev/null
+++ b/package/libs/libusb/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs/libusb
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-29T10:48:37.032580Z
+35373
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+bf689335e8e1ee33d925bdf5b08069f4
+2013-01-29T10:48:37.032580Z
+35373
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1101
+
diff --git a/package/libs/libusb/.svn/text-base/Makefile.svn-base b/package/libs/libusb/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..d1bdb01
--- /dev/null
+++ b/package/libs/libusb/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,49 @@
+#
+# Copyright (C) 2010-2013 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=libusb
+PKG_VERSION:=1.0.9
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=@SF/$(PKG_NAME)
+PKG_MD5SUM:=7f5a02375ad960d4e33a6dae7d63cfcb
+
+PKG_INSTALL:=1
+PKG_BUILD_PARALLEL:=1
+
+PKG_MAINTAINER := Felix Fietkau <nbd@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/libusb-1.0
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=A library for accessing Linux USB devices
+ DEPENDS:=+libpthread +librt
+ URL:=http://libusb.wiki.sourceforge.net/
+endef
+
+define Package/libusb-1.0/description
+ libusb is a C library that gives applications easy access to USB devices on
+ many different operating systems.
+endef
+
+TARGET_CFLAGS += $(FPIC)
+
+define Build/InstallDev
+ $(CP) $(PKG_INSTALL_DIR)/* $(1)/
+endef
+
+define Package/libusb-1.0/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libusb*.so* $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,libusb-1.0))
diff --git a/package/libs/libusb/Makefile b/package/libs/libusb/Makefile
new file mode 100644
index 0000000..d1bdb01
--- /dev/null
+++ b/package/libs/libusb/Makefile
@@ -0,0 +1,49 @@
+#
+# Copyright (C) 2010-2013 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=libusb
+PKG_VERSION:=1.0.9
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=@SF/$(PKG_NAME)
+PKG_MD5SUM:=7f5a02375ad960d4e33a6dae7d63cfcb
+
+PKG_INSTALL:=1
+PKG_BUILD_PARALLEL:=1
+
+PKG_MAINTAINER := Felix Fietkau <nbd@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/libusb-1.0
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=A library for accessing Linux USB devices
+ DEPENDS:=+libpthread +librt
+ URL:=http://libusb.wiki.sourceforge.net/
+endef
+
+define Package/libusb-1.0/description
+ libusb is a C library that gives applications easy access to USB devices on
+ many different operating systems.
+endef
+
+TARGET_CFLAGS += $(FPIC)
+
+define Build/InstallDev
+ $(CP) $(PKG_INSTALL_DIR)/* $(1)/
+endef
+
+define Package/libusb-1.0/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libusb*.so* $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,libusb-1.0))
diff --git a/package/libs/libusb/patches/.svn/entries b/package/libs/libusb/patches/.svn/entries
new file mode 100644
index 0000000..e2856df
--- /dev/null
+++ b/package/libs/libusb/patches/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs/libusb/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-29T10:48:37.032580Z
+35373
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+001-timerfd.patch
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+dc81a91f10d4e67d54ed457b791d09be
+2013-01-29T10:48:37.032580Z
+35373
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1075
+
diff --git a/package/libs/libusb/patches/.svn/text-base/001-timerfd.patch.svn-base b/package/libs/libusb/patches/.svn/text-base/001-timerfd.patch.svn-base
new file mode 100644
index 0000000..de48a7f
--- /dev/null
+++ b/package/libs/libusb/patches/.svn/text-base/001-timerfd.patch.svn-base
@@ -0,0 +1,33 @@
+commit cadb77d99e314e42c3eb02d016e9d90136ec6959
+Author: Alexander Gordeev <lasaine@lvk.cs.msu.su>
+Date: Thu Jan 27 06:39:16 2011 +0300
+
+ fix timerfd initialization
+
+ sys/timerfd.h defines TFD_NONBLOCK as 0x800 but in kernel TFD_NONBLOCK
+ is an alias for O_NONBLOCK which is defined in arch-specific fcntl.h.
+ While it's still 0x800 for most of archs but for mips it's 0x80. So
+ timerfd_create(..., TFD_NONBLOCK) returns -EINVAL because of that. Fix
+ this by using O_NONBLOCK instead.
+
+ Signed-off-by: Alexander Gordeev <lasaine@lvk.cs.msu.su>
+
+--- a/libusb/io.c
++++ b/libusb/io.c
+@@ -20,6 +20,7 @@
+
+ #include <config.h>
+ #include <errno.h>
++#include <fcntl.h>
+ #include <signal.h>
+ #include <stdint.h>
+ #include <stdlib.h>
+@@ -1072,7 +1073,7 @@ int usbi_io_init(struct libusb_context *
+
+ #ifdef USBI_TIMERFD_AVAILABLE
+ ctx->timerfd = timerfd_create(usbi_backend->get_timerfd_clockid(),
+- TFD_NONBLOCK);
++ O_NONBLOCK);
+ if (ctx->timerfd >= 0) {
+ usbi_dbg("using timerfd for timeouts");
+ r = usbi_add_pollfd(ctx, ctx->timerfd, POLLIN);
diff --git a/package/libs/libusb/patches/001-timerfd.patch b/package/libs/libusb/patches/001-timerfd.patch
new file mode 100644
index 0000000..de48a7f
--- /dev/null
+++ b/package/libs/libusb/patches/001-timerfd.patch
@@ -0,0 +1,33 @@
+commit cadb77d99e314e42c3eb02d016e9d90136ec6959
+Author: Alexander Gordeev <lasaine@lvk.cs.msu.su>
+Date: Thu Jan 27 06:39:16 2011 +0300
+
+ fix timerfd initialization
+
+ sys/timerfd.h defines TFD_NONBLOCK as 0x800 but in kernel TFD_NONBLOCK
+ is an alias for O_NONBLOCK which is defined in arch-specific fcntl.h.
+ While it's still 0x800 for most of archs but for mips it's 0x80. So
+ timerfd_create(..., TFD_NONBLOCK) returns -EINVAL because of that. Fix
+ this by using O_NONBLOCK instead.
+
+ Signed-off-by: Alexander Gordeev <lasaine@lvk.cs.msu.su>
+
+--- a/libusb/io.c
++++ b/libusb/io.c
+@@ -20,6 +20,7 @@
+
+ #include <config.h>
+ #include <errno.h>
++#include <fcntl.h>
+ #include <signal.h>
+ #include <stdint.h>
+ #include <stdlib.h>
+@@ -1072,7 +1073,7 @@ int usbi_io_init(struct libusb_context *
+
+ #ifdef USBI_TIMERFD_AVAILABLE
+ ctx->timerfd = timerfd_create(usbi_backend->get_timerfd_clockid(),
+- TFD_NONBLOCK);
++ O_NONBLOCK);
+ if (ctx->timerfd >= 0) {
+ usbi_dbg("using timerfd for timeouts");
+ r = usbi_add_pollfd(ctx, ctx->timerfd, POLLIN);
diff --git a/package/libs/lzo/.svn/entries b/package/libs/lzo/.svn/entries
new file mode 100644
index 0000000..a9cbce7
--- /dev/null
+++ b/package/libs/lzo/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs/lzo
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-30T19:52:03.969386Z
+35410
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:07.000000Z
+4d0fe6d7e89fac267d13d23df55f9da7
+2012-07-16T21:52:09.302401Z
+32755
+luka
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1350
+
diff --git a/package/libs/lzo/.svn/prop-base/Makefile.svn-base b/package/libs/lzo/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..f899379
--- /dev/null
+++ b/package/libs/lzo/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,13 @@
+K 9
+copyright
+V 30
+Copyright (C) 2006 OpenWrt.org
+K 7
+licence
+V 5
+GPLv2
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/libs/lzo/.svn/text-base/Makefile.svn-base b/package/libs/lzo/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..87e858e
--- /dev/null
+++ b/package/libs/lzo/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,56 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=lzo
+PKG_VERSION:=2.06
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://www.oberhumer.com/opensource/lzo/download/
+PKG_MD5SUM:=95380bd4081f85ef08c5209f4107e9f8
+
+PKG_FIXUP:=autoreconf
+PKG_INSTALL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/liblzo
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=A real-time data compression library
+ URL:=http://www.oberhumer.com/opensource/lzo/
+endef
+
+define Package/liblzo/description
+ LZO is a data compression library which is suitable for data de-/compression
+ in real-time. This means it favours speed over compression ratio.
+endef
+
+define Build/Configure
+ $(call Build/Configure/Default, \
+ --enable-shared \
+ --enable-static \
+ )
+endef
+
+TARGET_CFLAGS += $(FPIC)
+MAKE_FLAGS += CFLAGS_O="$(TARGET_CFLAGS)"
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/include/lzo $(1)/usr/include/
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/liblzo2.{a,so*} $(1)/usr/lib/
+endef
+
+define Package/liblzo/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/liblzo2.so* $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,liblzo))
diff --git a/package/libs/lzo/Makefile b/package/libs/lzo/Makefile
new file mode 100644
index 0000000..87e858e
--- /dev/null
+++ b/package/libs/lzo/Makefile
@@ -0,0 +1,56 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=lzo
+PKG_VERSION:=2.06
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://www.oberhumer.com/opensource/lzo/download/
+PKG_MD5SUM:=95380bd4081f85ef08c5209f4107e9f8
+
+PKG_FIXUP:=autoreconf
+PKG_INSTALL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/liblzo
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=A real-time data compression library
+ URL:=http://www.oberhumer.com/opensource/lzo/
+endef
+
+define Package/liblzo/description
+ LZO is a data compression library which is suitable for data de-/compression
+ in real-time. This means it favours speed over compression ratio.
+endef
+
+define Build/Configure
+ $(call Build/Configure/Default, \
+ --enable-shared \
+ --enable-static \
+ )
+endef
+
+TARGET_CFLAGS += $(FPIC)
+MAKE_FLAGS += CFLAGS_O="$(TARGET_CFLAGS)"
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/include/lzo $(1)/usr/include/
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/liblzo2.{a,so*} $(1)/usr/lib/
+endef
+
+define Package/liblzo/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/liblzo2.so* $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,liblzo))
diff --git a/package/libs/ncurses/.svn/entries b/package/libs/ncurses/.svn/entries
new file mode 100644
index 0000000..c51a3c5
--- /dev/null
+++ b/package/libs/ncurses/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs/ncurses
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-02-26T16:40:07.984842Z
+35811
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+43a7abdca4a74084a8df1d7617391409
+2013-01-07T18:19:31.323108Z
+35047
+florian
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4121
+
diff --git a/package/libs/ncurses/.svn/prop-base/Makefile.svn-base b/package/libs/ncurses/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..f899379
--- /dev/null
+++ b/package/libs/ncurses/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,13 @@
+K 9
+copyright
+V 30
+Copyright (C) 2006 OpenWrt.org
+K 7
+licence
+V 5
+GPLv2
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/libs/ncurses/.svn/text-base/Makefile.svn-base b/package/libs/ncurses/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..befc8f0
--- /dev/null
+++ b/package/libs/ncurses/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,159 @@
+#
+# Copyright (C) 2006-2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=ncurses
+PKG_VERSION:=5.7
+PKG_RELEASE:=5
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=@GNU/ncurses
+PKG_MD5SUM:=cce05daf61a64501ef6cd8da1f727ec6
+
+PKG_LICENSE:=FREE
+PKG_LICENSE_FILES:=README
+
+PKG_INSTALL:=1
+PKG_BUILD_PARALLEL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/libncurses
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=Terminal handling library
+ URL:=http://www.gnu.org/software/ncurses/
+ DEPENDS:= +terminfo
+ VARIANT:=libncurses
+endef
+
+define Package/terminfo
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=Terminal Info Database (ncurses)
+ URL:=http://www.gnu.org/software/ncurses/
+ VARIANT:=libncurses
+endef
+
+define Package/libncursesw
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=Terminal handling library (Unicode)
+ URL:=http://www.gnu.org/software/ncurses/
+ VARIANT:=libncursesw
+endef
+
+TARGET_CFLAGS += $(FPIC)
+
+CONFIGURE_ARGS += \
+ --enable-echo \
+ --enable-const \
+ --enable-overwrite \
+ --disable-rpath \
+ --without-ada \
+ --without-debug \
+ --without-profile \
+ --without-progs \
+ --disable-big-core \
+ --disable-home-terminfo \
+ --with-normal \
+ --with-shared \
+ --with-terminfo-dirs=/usr/share/terminfo \
+ --with-default-terminfo-dir=/usr/share/terminfo
+
+ifneq ($(CONFIG_INSTALL_LIBSTDCPP),y)
+CONFIGURE_ARGS += \
+ --without-cxx-binding
+endif
+
+ifeq ($(HOST_OS),FreeBSD)
+ CONFIGURE_ARGS +=
+ --with-terminfo=/usr/share/terminfo.db
+endif
+
+ifeq ($(BUILD_VARIANT),libncursesw)
+ CONFIGURE_ARGS += \
+ --enable-widec \
+ --with-build-cppflags=-D_GNU_SOURCE
+endif
+
+MAKE_FLAGS += \
+ BUILD_CC="$(HOSTCC)" \
+ HOSTCC="$(HOSTCC)" \
+ HOSTCCFLAGS="" \
+ libs
+
+define Build/Install/Default
+ $(MAKE_VARS) \
+ $(MAKE) -C $(PKG_BUILD_DIR)/$(MAKE_PATH) \
+ $(MAKE_INSTALL_FLAGS) \
+ $(1) install.libs install.data;
+endef
+
+define Package/terminfo/install
+ echo ""
+ifneq ($(HOST_OS),FreeBSD)
+ $(INSTALL_DIR) $(1)/usr/share/terminfo
+ (cd $(PKG_INSTALL_DIR)/usr/share/terminfo; \
+ for dir in ??; do \
+ [ -d "$$$$dir" ] || continue; \
+ mv $$$$dir $$$$(echo -ne "\x$$$$dir"); \
+ done \
+ )
+ for file in a/ansi d/dumb l/linux r/rxvt r/rxvt-unicode s/screen v/vt100 v/vt102 x/xterm x/xterm-color; do \
+ $(INSTALL_DIR) $(1)/usr/share/terminfo/`dirname $$$$file`; \
+ $(CP) $(PKG_INSTALL_DIR)/usr/share/terminfo/$$$$file \
+ $(1)/usr/share/terminfo/$$$$file; \
+ done
+endif
+endef
+
+define Package/libncurses/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{curses,ncurses,panel,menu,form}.so* $(1)/usr/lib/
+endef
+
+define Package/libncursesw/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{ncurses,panel,menu,form}w.so* $(1)/usr/lib/
+endef
+
+ifeq ($(BUILD_VARIANT),libncursesw)
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include/ncursesw/
+ $(CP) $(PKG_INSTALL_DIR)/usr/include/*.h $(1)/usr/include/ncursesw/
+
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{ncurses,panel,menu,form}w.{a,so*} $(1)/usr/lib/
+
+ $(INSTALL_DIR) $(1)/usr/bin $(2)/bin
+ $(CP) $(PKG_INSTALL_DIR)/usr/bin/ncursesw5-config $(2)/bin/
+ $(SED) 's,^\(prefix\|exec_prefix\)=.*,\1=$(STAGING_DIR)/usr,g' -e 's/$$$$INCS //g' \
+ $(2)/bin/ncursesw5-config
+ ln -sf $(STAGING_DIR)/host/bin/ncursesw5-config $(1)/usr/bin/ncursesw5-config
+endef
+else
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include
+ $(CP) $(PKG_INSTALL_DIR)/usr/include/*.h $(1)/usr/include/
+
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{curses,ncurses,panel,menu,form}.{a,so*} $(1)/usr/lib/
+
+ $(INSTALL_DIR) $(1)/usr/bin $(2)/bin
+ $(CP) $(PKG_INSTALL_DIR)/usr/bin/ncurses5-config $(2)/bin/
+ $(SED) 's,^\(prefix\|exec_prefix\)=.*,\1=$(STAGING_DIR)/usr,g' \
+ $(2)/bin/ncurses5-config
+ ln -sf $(STAGING_DIR)/host/bin/ncurses5-config $(1)/usr/bin/ncurses5-config
+endef
+endif
+
+$(eval $(call BuildPackage,terminfo))
+$(eval $(call BuildPackage,libncurses))
+$(eval $(call BuildPackage,libncursesw))
diff --git a/package/libs/ncurses/Makefile b/package/libs/ncurses/Makefile
new file mode 100644
index 0000000..befc8f0
--- /dev/null
+++ b/package/libs/ncurses/Makefile
@@ -0,0 +1,159 @@
+#
+# Copyright (C) 2006-2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=ncurses
+PKG_VERSION:=5.7
+PKG_RELEASE:=5
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=@GNU/ncurses
+PKG_MD5SUM:=cce05daf61a64501ef6cd8da1f727ec6
+
+PKG_LICENSE:=FREE
+PKG_LICENSE_FILES:=README
+
+PKG_INSTALL:=1
+PKG_BUILD_PARALLEL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/libncurses
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=Terminal handling library
+ URL:=http://www.gnu.org/software/ncurses/
+ DEPENDS:= +terminfo
+ VARIANT:=libncurses
+endef
+
+define Package/terminfo
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=Terminal Info Database (ncurses)
+ URL:=http://www.gnu.org/software/ncurses/
+ VARIANT:=libncurses
+endef
+
+define Package/libncursesw
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=Terminal handling library (Unicode)
+ URL:=http://www.gnu.org/software/ncurses/
+ VARIANT:=libncursesw
+endef
+
+TARGET_CFLAGS += $(FPIC)
+
+CONFIGURE_ARGS += \
+ --enable-echo \
+ --enable-const \
+ --enable-overwrite \
+ --disable-rpath \
+ --without-ada \
+ --without-debug \
+ --without-profile \
+ --without-progs \
+ --disable-big-core \
+ --disable-home-terminfo \
+ --with-normal \
+ --with-shared \
+ --with-terminfo-dirs=/usr/share/terminfo \
+ --with-default-terminfo-dir=/usr/share/terminfo
+
+ifneq ($(CONFIG_INSTALL_LIBSTDCPP),y)
+CONFIGURE_ARGS += \
+ --without-cxx-binding
+endif
+
+ifeq ($(HOST_OS),FreeBSD)
+ CONFIGURE_ARGS +=
+ --with-terminfo=/usr/share/terminfo.db
+endif
+
+ifeq ($(BUILD_VARIANT),libncursesw)
+ CONFIGURE_ARGS += \
+ --enable-widec \
+ --with-build-cppflags=-D_GNU_SOURCE
+endif
+
+MAKE_FLAGS += \
+ BUILD_CC="$(HOSTCC)" \
+ HOSTCC="$(HOSTCC)" \
+ HOSTCCFLAGS="" \
+ libs
+
+define Build/Install/Default
+ $(MAKE_VARS) \
+ $(MAKE) -C $(PKG_BUILD_DIR)/$(MAKE_PATH) \
+ $(MAKE_INSTALL_FLAGS) \
+ $(1) install.libs install.data;
+endef
+
+define Package/terminfo/install
+ echo ""
+ifneq ($(HOST_OS),FreeBSD)
+ $(INSTALL_DIR) $(1)/usr/share/terminfo
+ (cd $(PKG_INSTALL_DIR)/usr/share/terminfo; \
+ for dir in ??; do \
+ [ -d "$$$$dir" ] || continue; \
+ mv $$$$dir $$$$(echo -ne "\x$$$$dir"); \
+ done \
+ )
+ for file in a/ansi d/dumb l/linux r/rxvt r/rxvt-unicode s/screen v/vt100 v/vt102 x/xterm x/xterm-color; do \
+ $(INSTALL_DIR) $(1)/usr/share/terminfo/`dirname $$$$file`; \
+ $(CP) $(PKG_INSTALL_DIR)/usr/share/terminfo/$$$$file \
+ $(1)/usr/share/terminfo/$$$$file; \
+ done
+endif
+endef
+
+define Package/libncurses/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{curses,ncurses,panel,menu,form}.so* $(1)/usr/lib/
+endef
+
+define Package/libncursesw/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{ncurses,panel,menu,form}w.so* $(1)/usr/lib/
+endef
+
+ifeq ($(BUILD_VARIANT),libncursesw)
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include/ncursesw/
+ $(CP) $(PKG_INSTALL_DIR)/usr/include/*.h $(1)/usr/include/ncursesw/
+
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{ncurses,panel,menu,form}w.{a,so*} $(1)/usr/lib/
+
+ $(INSTALL_DIR) $(1)/usr/bin $(2)/bin
+ $(CP) $(PKG_INSTALL_DIR)/usr/bin/ncursesw5-config $(2)/bin/
+ $(SED) 's,^\(prefix\|exec_prefix\)=.*,\1=$(STAGING_DIR)/usr,g' -e 's/$$$$INCS //g' \
+ $(2)/bin/ncursesw5-config
+ ln -sf $(STAGING_DIR)/host/bin/ncursesw5-config $(1)/usr/bin/ncursesw5-config
+endef
+else
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include
+ $(CP) $(PKG_INSTALL_DIR)/usr/include/*.h $(1)/usr/include/
+
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{curses,ncurses,panel,menu,form}.{a,so*} $(1)/usr/lib/
+
+ $(INSTALL_DIR) $(1)/usr/bin $(2)/bin
+ $(CP) $(PKG_INSTALL_DIR)/usr/bin/ncurses5-config $(2)/bin/
+ $(SED) 's,^\(prefix\|exec_prefix\)=.*,\1=$(STAGING_DIR)/usr,g' \
+ $(2)/bin/ncurses5-config
+ ln -sf $(STAGING_DIR)/host/bin/ncurses5-config $(1)/usr/bin/ncurses5-config
+endef
+endif
+
+$(eval $(call BuildPackage,terminfo))
+$(eval $(call BuildPackage,libncurses))
+$(eval $(call BuildPackage,libncursesw))
diff --git a/package/libs/ncurses/patches/.svn/entries b/package/libs/ncurses/patches/.svn/entries
new file mode 100644
index 0000000..15434d7
--- /dev/null
+++ b/package/libs/ncurses/patches/.svn/entries
@@ -0,0 +1,198 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs/ncurses/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-02-26T16:40:07.984842Z
+35811
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+200-fix_missing_include.patch
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+fdf637b7adaeced46f443f619b1784a7
+2013-02-26T16:40:07.984842Z
+35811
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+266
+
+100-ncurses-5.6-20080112-urxvt.patch
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+c9ba451784c80b36c6d54c88486181f6
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3294
+
+900-terminfo.patch
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+c5c0f76225226c434c76afed34436365
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+995
+
+101-ncurses-5.6-20080628-kbs.patch
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+4fc22b51d850f08bd1893a673b2090ea
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2498
+
+500-cross.patch
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+d75e7f270a2704c01220b74bafc234bf
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+420
+
diff --git a/package/libs/ncurses/patches/.svn/prop-base/500-cross.patch.svn-base b/package/libs/ncurses/patches/.svn/prop-base/500-cross.patch.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/libs/ncurses/patches/.svn/prop-base/500-cross.patch.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/libs/ncurses/patches/.svn/text-base/100-ncurses-5.6-20080112-urxvt.patch.svn-base b/package/libs/ncurses/patches/.svn/text-base/100-ncurses-5.6-20080112-urxvt.patch.svn-base
new file mode 100644
index 0000000..39e60ba
--- /dev/null
+++ b/package/libs/ncurses/patches/.svn/text-base/100-ncurses-5.6-20080112-urxvt.patch.svn-base
@@ -0,0 +1,175 @@
+--- a/misc/terminfo.src
++++ b/misc/terminfo.src
+@@ -3965,6 +3965,172 @@ rxvt-cygwin-native|rxvt terminal emulato
+ rxvt-16color|xterm with 16 colors like aixterm,
+ ncv#32, use=ibm+16color, use=rxvt,
+
++# rxvt-unicode
++# http://cvs.schmorp.de/rxvt-unicode/doc/etc/rxvt-unicode.terminfo?revision=1.20
++# From: Thomas Dickey <dickey@clark.net> 04 Oct 1997
++# Updated: Özgür Kesim <kesim@math.fu-berlin.de> 02 Nov 1997
++# Updated: Marc Lehmann <pcg@goof.com>, 17 Feb 2005
++rxvt-unicode|rxvt-unicode terminal (X Window System),
++ am,
++ bce,
++ eo,
++ km,
++ msgr,
++ xenl,
++ hs,
++ cols#80,
++ it#8,
++ lines#24,
++ acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~-A.B+C\,D0EhFiG,
++ bel=^G,
++ blink=\E[5m,
++ bold=\E[1m,
++ civis=\E[?25l,
++ clear=\E[H\E[2J,
++ cnorm=\E[?25h,
++ cr=^M,
++ csr=\E[%i%p1%d;%p2%dr,
++ cub=\E[%p1%dD,
++ cub1=^H,
++ cud=\E[%p1%dB,
++ cud1=^J,
++ cuf=\E[%p1%dC,
++ cuf1=\E[C,
++ cup=\E[%i%p1%d;%p2%dH,
++ cuu=\E[%p1%dA,
++ cuu1=\E[A,
++ cvvis=\E[?25h,
++ dch=\E[%p1%dP,
++ dch1=\E[P,
++ dl=\E[%p1%dM,
++ dl1=\E[M,
++ ed=\E[J,
++ el=\E[K,
++ el1=\E[1K,
++ flash=\E[?5h$<20/>\E[?5l,
++ home=\E[H,
++ hpa=\E[%i%p1%dG,
++ ht=^I,
++ hts=\EH,
++ ich=\E[%p1%d@,
++ ich1=\E[@,
++ il=\E[%p1%dL,
++ il1=\E[L,
++ ind=^J,
++ is1=\E[?47l\E=\E[?1l,
++ is2=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l\E[4l,
++ kDC=\E[3$,
++ kIC=\E2$,
++ kEND=\E[8$,
++ kHOM=\E[7$,
++ kLFT=\E[d,
++ kNXT=\E[6$,
++ kPRV=\E[5$,
++ kRIT=\E[c,
++ kbs=\177,
++ ka1=\EOw,
++ ka3=\EOy,
++ kb2=\EOu,
++ kc1=\EOq,
++ kc3=\EOs,
++ kcbt=\E[Z,
++ kcub1=\E[D,
++ kcud1=\E[B,
++ kcuf1=\E[C,
++ kcuu1=\E[A,
++ kdch1=\E[3~,
++ kel=\E[8\^,
++ kend=\E[8~,
++ kent=\EOM,
++ kf1=\E[11~,
++ kf10=\E[21~,
++ kf11=\E[23~,
++ kf12=\E[24~,
++ kf13=\E[25~,
++ kf14=\E[26~,
++ kf15=\E[28~,
++ kf16=\E[29~,
++ kf17=\E[31~,
++ kf18=\E[32~,
++ kf19=\E[33~,
++ kf2=\E[12~,
++ kf20=\E[34~,
++ kf3=\E[13~,
++ kf4=\E[14~,
++ kf5=\E[15~,
++ kf6=\E[17~,
++ kf7=\E[18~,
++ kf8=\E[19~,
++ kf9=\E[20~,
++ kfnd=\E[1~,
++ khome=\E[7~,
++ kich1=\E[2~,
++ kmous=\E[M,
++ knp=\E[6~,
++ kpp=\E[5~,
++ kslt=\E[4~,
++ rc=\E8,
++ rev=\E[7m,
++ ri=\EM,
++ rmso=\E[27m,
++ rmul=\E[24m,
++ rs1=\Ec,
++ rs2=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l\E[4l\E>,
++ sgr0=\E[m\017,
++ enacs=,
++ smacs=\E(0,
++ rmacs=\E(B,
++ smso=\E[7m,
++ smul=\E[4m,
++ tbc=\E[3g,
++ vpa=\E[%i%p1%dd,
++ colors#88,
++ pairs#256,
++ btns#5,
++ lm#0,
++ ccc,
++ npc,
++ mc5i,
++ ncv#0,
++ mir,
++ xon,
++ bw,
++ ech=\E[%p1%dX,
++ mc0=\E[i,
++ mc4=\E[4i,
++ mc5=\E[5i,
++ sitm=\E[3m,
++ ritm=\E[23m,
++ smam=\E[?7h,
++ rmam=\E[?7l,
++ smir=\E[4h,
++ rmir=\E[4l,
++ smcup=\E[?1049h,
++ rmcup=\E[r\E[?1049l,
++ smkx=\E=,
++ rmkx=\E>,
++ indn=\E[%p1%dS,
++ rin=\E[%p1%dT,
++ sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;m%?%p9%t\E(0%e\E(B%;,
++ op=\E[39;49m,
++ setaf=\E[38;5;%p1%dm,
++ setab=\E[48;5;%p1%dm,
++ setf=%?%p1%{7}%>%t\E[38;5;%p1%dm%e\E[3%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m%;,
++ setb=%?%p1%{7}%>%t\E[48;5;%p1%dm%e\E[4%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m%;,
++ initc=\E]4;%p1%d;rgb\:%p2%{65535}%*%{1000}%/%4.4X/%p3%{65535}%*%{1000}%/%4.4X/%p4%{65535}%*%{1000}%/%4.4X\E\\,
++ sc=\E7,
++ s0ds=\E(B,
++ s1ds=\E(0,
++ s2ds=\E*B,
++ s3ds=\E+B,
++ u6=\E[%i%d;%dR,
++ u7=\E[6n,
++ u8=\E[?1;2c,
++ u9=\E[c,
++ tsl=\E]2;,
++ fsl=\007,
++ dsl=\E]2;\007,
++
+ # mrxvt 0.5.3
+ #
+ # mrxvt is based on rxvt 2.7.11, but has by default XTERM_FKEYS defined, which
diff --git a/package/libs/ncurses/patches/.svn/text-base/101-ncurses-5.6-20080628-kbs.patch.svn-base b/package/libs/ncurses/patches/.svn/text-base/101-ncurses-5.6-20080628-kbs.patch.svn-base
new file mode 100644
index 0000000..3b3abd7
--- /dev/null
+++ b/package/libs/ncurses/patches/.svn/text-base/101-ncurses-5.6-20080628-kbs.patch.svn-base
@@ -0,0 +1,52 @@
+--- a/misc/terminfo.src
++++ b/misc/terminfo.src
+@@ -3054,6 +3054,7 @@ xterm-xfree86|xterm terminal emulator (X
+ # This version reflects the current xterm features.
+ xterm-new|modern xterm terminal emulator,
+ npc,
++ kbs=\177,
+ indn=\E[%p1%dS, kDC=\E[3;2~, kEND=\E[1;2F, kHOM=\E[1;2H,
+ kIC=\E[2;2~, kNXT=\E[6;2~, kPRV=\E[5;2~, kb2=\EOE,
+ kcbt=\E[Z, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA,
+@@ -3818,6 +3819,7 @@ mlterm+pcfkeys|fragment for PC-style fke
+ rxvt-basic|rxvt terminal base (X Window System),
+ OTbs, am, bce, eo, mir, msgr, xenl, xon,
+ cols#80, it#8, lines#24,
++ kbs=\177,
+ acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
+ bel=^G, blink=\E[5m, bold=\E[1m, civis=\E[?25l,
+ clear=\E[H\E[2J, cnorm=\E[?25h, cr=^M,
+@@ -3828,7 +3830,7 @@ rxvt-basic|rxvt terminal base (X Window
+ enacs=\E(B\E)0, flash=\E[?5h\E[?5l, home=\E[H, ht=^I,
+ hts=\EH, ich=\E[%p1%d@, ich1=\E[@, il=\E[%p1%dL, il1=\E[L,
+ ind=^J, is1=\E[?47l\E=\E[?1l,
+- is2=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l\E[4l, kbs=^H,
++ is2=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l\E[4l,
+ kcbt=\E[Z, kmous=\E[M, rc=\E8, rev=\E[7m, ri=\EM, rmacs=^O,
+ rmcup=\E[2J\E[?47l\E8, rmir=\E[4l, rmkx=\E>, rmso=\E[27m,
+ rmul=\E[24m,
+@@ -4541,6 +4543,7 @@ eterm|gnu emacs term.el terminal emulati
+ screen|VT 100/ANSI X3.64 virtual terminal,
+ OTbs, OTpt, am, km, mir, msgr, xenl, G0,
+ colors#8, cols#80, it#8, lines#24, pairs#64,
++ kbs=\177,
+ acsc=++\,\,--..00``aaffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
+ bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, civis=\E[?25l,
+ clear=\E[H\E[J, cnorm=\E[34h\E[?25h, cr=^M,
+@@ -4550,7 +4553,7 @@ screen|VT 100/ANSI X3.64 virtual termina
+ cvvis=\E[34l, dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM,
+ dl1=\E[M, ed=\E[J, el=\E[K, el1=\E[1K, enacs=\E(B\E)0,
+ flash=\Eg, home=\E[H, ht=^I, hts=\EH, ich=\E[%p1%d@,
+- il=\E[%p1%dL, il1=\E[L, ind=^J, is2=\E)0, kbs=^H, kcbt=\E[Z,
++ il=\E[%p1%dL, il1=\E[L, ind=^J, is2=\E)0, kcbt=\E[Z,
+ kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA,
+ kdch1=\E[3~, kend=\E[4~, kf1=\EOP, kf10=\E[21~,
+ kf11=\E[23~, kf12=\E[24~, kf2=\EOQ, kf3=\EOR, kf4=\EOS,
+@@ -4655,6 +4658,7 @@ screen.xterm-r6|screen customized for X1
+ # on Solaris because Sun's curses implementation gets confused.
+ screen.teraterm|disable ncv in teraterm,
+ ncv#127,
++ kbs=^H,
+ acsc=+\020\,\021-\030.^Y0\333`\004a\261f\370g\361h\260i\316j\331k\277l\332m\300n\305o~p\304q\304r\304s_t\303u\264v\301w\302x\263y\363z\362{\343|\330}\234~\376,
+ use=screen+fkeys, use=screen,
+ # Other terminals
diff --git a/package/libs/ncurses/patches/.svn/text-base/200-fix_missing_include.patch.svn-base b/package/libs/ncurses/patches/.svn/text-base/200-fix_missing_include.patch.svn-base
new file mode 100644
index 0000000..c5d48d4
--- /dev/null
+++ b/package/libs/ncurses/patches/.svn/text-base/200-fix_missing_include.patch.svn-base
@@ -0,0 +1,14 @@
+--- a/ncurses/curses.priv.h
++++ b/ncurses/curses.priv.h
+@@ -54,6 +54,11 @@ extern "C" {
+
+ #include <ncurses_cfg.h>
+
++#if NEED_WCHAR_H
++#include <stdarg.h>
++#include <wchar.h>
++#endif
++
+ #if USE_RCS_IDS
+ #define MODULE_ID(id) static const char Ident[] = id;
+ #else
diff --git a/package/libs/ncurses/patches/.svn/text-base/500-cross.patch.svn-base b/package/libs/ncurses/patches/.svn/text-base/500-cross.patch.svn-base
new file mode 100644
index 0000000..ace6252
--- /dev/null
+++ b/package/libs/ncurses/patches/.svn/text-base/500-cross.patch.svn-base
@@ -0,0 +1,11 @@
+--- a/aclocal.m4
++++ b/aclocal.m4
+@@ -4298,7 +4298,7 @@ CF_EOF
+ EXTRA_LDFLAGS="-Wl,-rpath,\${libdir} $EXTRA_LDFLAGS"
+ fi
+ CF_SHARED_SONAME
+- MK_SHARED_LIB='${CC} ${CFLAGS} -shared -Wl,-soname,'$cf_cv_shared_soname',-stats,-lc -o $[@]'
++ MK_SHARED_LIB='${CC} ${CFLAGS} -shared -Wl,-soname,'$cf_shared_soname',-stats,$(LDFLAGS) -lc -o $[@]'
+ ;;
+ openbsd[[2-9]].*)
+ if test "$DFT_LWR_MODEL" = "shared" ; then
diff --git a/package/libs/ncurses/patches/.svn/text-base/900-terminfo.patch.svn-base b/package/libs/ncurses/patches/.svn/text-base/900-terminfo.patch.svn-base
new file mode 100644
index 0000000..7aab3db
--- /dev/null
+++ b/package/libs/ncurses/patches/.svn/text-base/900-terminfo.patch.svn-base
@@ -0,0 +1,20 @@
+--- a/misc/terminfo.src
++++ b/misc/terminfo.src
+@@ -3707,12 +3707,11 @@ konsole-xf3x|KDE console window with key
+ # The value for kbs reflects local customization rather than the settings used
+ # for XFree86 xterm.
+ konsole-xf4x|KDE console window with keyboard for XFree86 4.x xterm,
+- kend=\EOF, khome=\EOH, use=konsole+pcfkeys,
+- use=konsole-vt100,
+-# Konsole does not implement shifted cursor-keys.
+-konsole+pcfkeys|konsole subset of xterm+pcfkeys,
+- kLFT@, kRIT@, kcbt=\E[Z, kind@, kri@, kDN@, kUP@, use=xterm+pcc2,
+- use=xterm+pcf0,
++ kend=\EOF, kf1=\EOP, kf13=\EO2P, kf14=\EO2Q, kf15=\EO2R,
++ kf16=\EO2S, kf17=\E[15;2~, kf18=\E[17;2~, kf19=\E[18;2~,
++ kf2=\EOQ, kf20=\E[19;2~, kf21=\E[20;2~, kf22=\E[21;2~,
++ kf23=\E[23;2~, kf24=\E[24;2~, kf3=\EOR, kf4=\EOS,
++ khome=\EOH, use=konsole-vt100,
+ # KDE's "vt100" keyboard has no relationship to any terminal that DEC made, but
+ # it is still useful for deriving the other entries.
+ konsole-vt100|KDE console window with vt100 (sic) keyboard,
diff --git a/package/libs/ncurses/patches/100-ncurses-5.6-20080112-urxvt.patch b/package/libs/ncurses/patches/100-ncurses-5.6-20080112-urxvt.patch
new file mode 100644
index 0000000..39e60ba
--- /dev/null
+++ b/package/libs/ncurses/patches/100-ncurses-5.6-20080112-urxvt.patch
@@ -0,0 +1,175 @@
+--- a/misc/terminfo.src
++++ b/misc/terminfo.src
+@@ -3965,6 +3965,172 @@ rxvt-cygwin-native|rxvt terminal emulato
+ rxvt-16color|xterm with 16 colors like aixterm,
+ ncv#32, use=ibm+16color, use=rxvt,
+
++# rxvt-unicode
++# http://cvs.schmorp.de/rxvt-unicode/doc/etc/rxvt-unicode.terminfo?revision=1.20
++# From: Thomas Dickey <dickey@clark.net> 04 Oct 1997
++# Updated: Özgür Kesim <kesim@math.fu-berlin.de> 02 Nov 1997
++# Updated: Marc Lehmann <pcg@goof.com>, 17 Feb 2005
++rxvt-unicode|rxvt-unicode terminal (X Window System),
++ am,
++ bce,
++ eo,
++ km,
++ msgr,
++ xenl,
++ hs,
++ cols#80,
++ it#8,
++ lines#24,
++ acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~-A.B+C\,D0EhFiG,
++ bel=^G,
++ blink=\E[5m,
++ bold=\E[1m,
++ civis=\E[?25l,
++ clear=\E[H\E[2J,
++ cnorm=\E[?25h,
++ cr=^M,
++ csr=\E[%i%p1%d;%p2%dr,
++ cub=\E[%p1%dD,
++ cub1=^H,
++ cud=\E[%p1%dB,
++ cud1=^J,
++ cuf=\E[%p1%dC,
++ cuf1=\E[C,
++ cup=\E[%i%p1%d;%p2%dH,
++ cuu=\E[%p1%dA,
++ cuu1=\E[A,
++ cvvis=\E[?25h,
++ dch=\E[%p1%dP,
++ dch1=\E[P,
++ dl=\E[%p1%dM,
++ dl1=\E[M,
++ ed=\E[J,
++ el=\E[K,
++ el1=\E[1K,
++ flash=\E[?5h$<20/>\E[?5l,
++ home=\E[H,
++ hpa=\E[%i%p1%dG,
++ ht=^I,
++ hts=\EH,
++ ich=\E[%p1%d@,
++ ich1=\E[@,
++ il=\E[%p1%dL,
++ il1=\E[L,
++ ind=^J,
++ is1=\E[?47l\E=\E[?1l,
++ is2=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l\E[4l,
++ kDC=\E[3$,
++ kIC=\E2$,
++ kEND=\E[8$,
++ kHOM=\E[7$,
++ kLFT=\E[d,
++ kNXT=\E[6$,
++ kPRV=\E[5$,
++ kRIT=\E[c,
++ kbs=\177,
++ ka1=\EOw,
++ ka3=\EOy,
++ kb2=\EOu,
++ kc1=\EOq,
++ kc3=\EOs,
++ kcbt=\E[Z,
++ kcub1=\E[D,
++ kcud1=\E[B,
++ kcuf1=\E[C,
++ kcuu1=\E[A,
++ kdch1=\E[3~,
++ kel=\E[8\^,
++ kend=\E[8~,
++ kent=\EOM,
++ kf1=\E[11~,
++ kf10=\E[21~,
++ kf11=\E[23~,
++ kf12=\E[24~,
++ kf13=\E[25~,
++ kf14=\E[26~,
++ kf15=\E[28~,
++ kf16=\E[29~,
++ kf17=\E[31~,
++ kf18=\E[32~,
++ kf19=\E[33~,
++ kf2=\E[12~,
++ kf20=\E[34~,
++ kf3=\E[13~,
++ kf4=\E[14~,
++ kf5=\E[15~,
++ kf6=\E[17~,
++ kf7=\E[18~,
++ kf8=\E[19~,
++ kf9=\E[20~,
++ kfnd=\E[1~,
++ khome=\E[7~,
++ kich1=\E[2~,
++ kmous=\E[M,
++ knp=\E[6~,
++ kpp=\E[5~,
++ kslt=\E[4~,
++ rc=\E8,
++ rev=\E[7m,
++ ri=\EM,
++ rmso=\E[27m,
++ rmul=\E[24m,
++ rs1=\Ec,
++ rs2=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l\E[4l\E>,
++ sgr0=\E[m\017,
++ enacs=,
++ smacs=\E(0,
++ rmacs=\E(B,
++ smso=\E[7m,
++ smul=\E[4m,
++ tbc=\E[3g,
++ vpa=\E[%i%p1%dd,
++ colors#88,
++ pairs#256,
++ btns#5,
++ lm#0,
++ ccc,
++ npc,
++ mc5i,
++ ncv#0,
++ mir,
++ xon,
++ bw,
++ ech=\E[%p1%dX,
++ mc0=\E[i,
++ mc4=\E[4i,
++ mc5=\E[5i,
++ sitm=\E[3m,
++ ritm=\E[23m,
++ smam=\E[?7h,
++ rmam=\E[?7l,
++ smir=\E[4h,
++ rmir=\E[4l,
++ smcup=\E[?1049h,
++ rmcup=\E[r\E[?1049l,
++ smkx=\E=,
++ rmkx=\E>,
++ indn=\E[%p1%dS,
++ rin=\E[%p1%dT,
++ sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;m%?%p9%t\E(0%e\E(B%;,
++ op=\E[39;49m,
++ setaf=\E[38;5;%p1%dm,
++ setab=\E[48;5;%p1%dm,
++ setf=%?%p1%{7}%>%t\E[38;5;%p1%dm%e\E[3%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m%;,
++ setb=%?%p1%{7}%>%t\E[48;5;%p1%dm%e\E[4%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m%;,
++ initc=\E]4;%p1%d;rgb\:%p2%{65535}%*%{1000}%/%4.4X/%p3%{65535}%*%{1000}%/%4.4X/%p4%{65535}%*%{1000}%/%4.4X\E\\,
++ sc=\E7,
++ s0ds=\E(B,
++ s1ds=\E(0,
++ s2ds=\E*B,
++ s3ds=\E+B,
++ u6=\E[%i%d;%dR,
++ u7=\E[6n,
++ u8=\E[?1;2c,
++ u9=\E[c,
++ tsl=\E]2;,
++ fsl=\007,
++ dsl=\E]2;\007,
++
+ # mrxvt 0.5.3
+ #
+ # mrxvt is based on rxvt 2.7.11, but has by default XTERM_FKEYS defined, which
diff --git a/package/libs/ncurses/patches/101-ncurses-5.6-20080628-kbs.patch b/package/libs/ncurses/patches/101-ncurses-5.6-20080628-kbs.patch
new file mode 100644
index 0000000..3b3abd7
--- /dev/null
+++ b/package/libs/ncurses/patches/101-ncurses-5.6-20080628-kbs.patch
@@ -0,0 +1,52 @@
+--- a/misc/terminfo.src
++++ b/misc/terminfo.src
+@@ -3054,6 +3054,7 @@ xterm-xfree86|xterm terminal emulator (X
+ # This version reflects the current xterm features.
+ xterm-new|modern xterm terminal emulator,
+ npc,
++ kbs=\177,
+ indn=\E[%p1%dS, kDC=\E[3;2~, kEND=\E[1;2F, kHOM=\E[1;2H,
+ kIC=\E[2;2~, kNXT=\E[6;2~, kPRV=\E[5;2~, kb2=\EOE,
+ kcbt=\E[Z, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA,
+@@ -3818,6 +3819,7 @@ mlterm+pcfkeys|fragment for PC-style fke
+ rxvt-basic|rxvt terminal base (X Window System),
+ OTbs, am, bce, eo, mir, msgr, xenl, xon,
+ cols#80, it#8, lines#24,
++ kbs=\177,
+ acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
+ bel=^G, blink=\E[5m, bold=\E[1m, civis=\E[?25l,
+ clear=\E[H\E[2J, cnorm=\E[?25h, cr=^M,
+@@ -3828,7 +3830,7 @@ rxvt-basic|rxvt terminal base (X Window
+ enacs=\E(B\E)0, flash=\E[?5h\E[?5l, home=\E[H, ht=^I,
+ hts=\EH, ich=\E[%p1%d@, ich1=\E[@, il=\E[%p1%dL, il1=\E[L,
+ ind=^J, is1=\E[?47l\E=\E[?1l,
+- is2=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l\E[4l, kbs=^H,
++ is2=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l\E[4l,
+ kcbt=\E[Z, kmous=\E[M, rc=\E8, rev=\E[7m, ri=\EM, rmacs=^O,
+ rmcup=\E[2J\E[?47l\E8, rmir=\E[4l, rmkx=\E>, rmso=\E[27m,
+ rmul=\E[24m,
+@@ -4541,6 +4543,7 @@ eterm|gnu emacs term.el terminal emulati
+ screen|VT 100/ANSI X3.64 virtual terminal,
+ OTbs, OTpt, am, km, mir, msgr, xenl, G0,
+ colors#8, cols#80, it#8, lines#24, pairs#64,
++ kbs=\177,
+ acsc=++\,\,--..00``aaffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
+ bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, civis=\E[?25l,
+ clear=\E[H\E[J, cnorm=\E[34h\E[?25h, cr=^M,
+@@ -4550,7 +4553,7 @@ screen|VT 100/ANSI X3.64 virtual termina
+ cvvis=\E[34l, dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM,
+ dl1=\E[M, ed=\E[J, el=\E[K, el1=\E[1K, enacs=\E(B\E)0,
+ flash=\Eg, home=\E[H, ht=^I, hts=\EH, ich=\E[%p1%d@,
+- il=\E[%p1%dL, il1=\E[L, ind=^J, is2=\E)0, kbs=^H, kcbt=\E[Z,
++ il=\E[%p1%dL, il1=\E[L, ind=^J, is2=\E)0, kcbt=\E[Z,
+ kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA,
+ kdch1=\E[3~, kend=\E[4~, kf1=\EOP, kf10=\E[21~,
+ kf11=\E[23~, kf12=\E[24~, kf2=\EOQ, kf3=\EOR, kf4=\EOS,
+@@ -4655,6 +4658,7 @@ screen.xterm-r6|screen customized for X1
+ # on Solaris because Sun's curses implementation gets confused.
+ screen.teraterm|disable ncv in teraterm,
+ ncv#127,
++ kbs=^H,
+ acsc=+\020\,\021-\030.^Y0\333`\004a\261f\370g\361h\260i\316j\331k\277l\332m\300n\305o~p\304q\304r\304s_t\303u\264v\301w\302x\263y\363z\362{\343|\330}\234~\376,
+ use=screen+fkeys, use=screen,
+ # Other terminals
diff --git a/package/libs/ncurses/patches/200-fix_missing_include.patch b/package/libs/ncurses/patches/200-fix_missing_include.patch
new file mode 100644
index 0000000..c5d48d4
--- /dev/null
+++ b/package/libs/ncurses/patches/200-fix_missing_include.patch
@@ -0,0 +1,14 @@
+--- a/ncurses/curses.priv.h
++++ b/ncurses/curses.priv.h
+@@ -54,6 +54,11 @@ extern "C" {
+
+ #include <ncurses_cfg.h>
+
++#if NEED_WCHAR_H
++#include <stdarg.h>
++#include <wchar.h>
++#endif
++
+ #if USE_RCS_IDS
+ #define MODULE_ID(id) static const char Ident[] = id;
+ #else
diff --git a/package/libs/ncurses/patches/500-cross.patch b/package/libs/ncurses/patches/500-cross.patch
new file mode 100644
index 0000000..ace6252
--- /dev/null
+++ b/package/libs/ncurses/patches/500-cross.patch
@@ -0,0 +1,11 @@
+--- a/aclocal.m4
++++ b/aclocal.m4
+@@ -4298,7 +4298,7 @@ CF_EOF
+ EXTRA_LDFLAGS="-Wl,-rpath,\${libdir} $EXTRA_LDFLAGS"
+ fi
+ CF_SHARED_SONAME
+- MK_SHARED_LIB='${CC} ${CFLAGS} -shared -Wl,-soname,'$cf_cv_shared_soname',-stats,-lc -o $[@]'
++ MK_SHARED_LIB='${CC} ${CFLAGS} -shared -Wl,-soname,'$cf_shared_soname',-stats,$(LDFLAGS) -lc -o $[@]'
+ ;;
+ openbsd[[2-9]].*)
+ if test "$DFT_LWR_MODEL" = "shared" ; then
diff --git a/package/libs/ncurses/patches/900-terminfo.patch b/package/libs/ncurses/patches/900-terminfo.patch
new file mode 100644
index 0000000..7aab3db
--- /dev/null
+++ b/package/libs/ncurses/patches/900-terminfo.patch
@@ -0,0 +1,20 @@
+--- a/misc/terminfo.src
++++ b/misc/terminfo.src
+@@ -3707,12 +3707,11 @@ konsole-xf3x|KDE console window with key
+ # The value for kbs reflects local customization rather than the settings used
+ # for XFree86 xterm.
+ konsole-xf4x|KDE console window with keyboard for XFree86 4.x xterm,
+- kend=\EOF, khome=\EOH, use=konsole+pcfkeys,
+- use=konsole-vt100,
+-# Konsole does not implement shifted cursor-keys.
+-konsole+pcfkeys|konsole subset of xterm+pcfkeys,
+- kLFT@, kRIT@, kcbt=\E[Z, kind@, kri@, kDN@, kUP@, use=xterm+pcc2,
+- use=xterm+pcf0,
++ kend=\EOF, kf1=\EOP, kf13=\EO2P, kf14=\EO2Q, kf15=\EO2R,
++ kf16=\EO2S, kf17=\E[15;2~, kf18=\E[17;2~, kf19=\E[18;2~,
++ kf2=\EOQ, kf20=\E[19;2~, kf21=\E[20;2~, kf22=\E[21;2~,
++ kf23=\E[23;2~, kf24=\E[24;2~, kf3=\EOR, kf4=\EOS,
++ khome=\EOH, use=konsole-vt100,
+ # KDE's "vt100" keyboard has no relationship to any terminal that DEC made, but
+ # it is still useful for deriving the other entries.
+ konsole-vt100|KDE console window with vt100 (sic) keyboard,
diff --git a/package/libs/ocf-crypto-headers/.svn/entries b/package/libs/ocf-crypto-headers/.svn/entries
new file mode 100644
index 0000000..34741c5
--- /dev/null
+++ b/package/libs/ocf-crypto-headers/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs/ocf-crypto-headers
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-19T15:45:59.553265Z
+33863
+hcg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+src
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:07.000000Z
+8bf475ac46d33606f6e49ee0c1ee5c53
+2012-10-19T15:45:59.553265Z
+33863
+hcg
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+770
+
diff --git a/package/libs/ocf-crypto-headers/.svn/prop-base/Makefile.svn-base b/package/libs/ocf-crypto-headers/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/libs/ocf-crypto-headers/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/libs/ocf-crypto-headers/.svn/text-base/Makefile.svn-base b/package/libs/ocf-crypto-headers/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..0b1c6bd
--- /dev/null
+++ b/package/libs/ocf-crypto-headers/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,39 @@
+#
+# Copyright (C) 2008-2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=ocf-crypto-headers
+PKG_VERSION:=20110720
+PKG_RELEASE:=1
+
+PKG_LICENSE:=GPLv2
+PKG_LICENSE_FILES:=cryptodev.h
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/ocf-crypto-headers
+ SECTION:=utils
+ CATEGORY:=Utilities
+ TITLE:=OCF-Linux cryptodev header
+ PKGARCH:=all
+ URL:=http://ocf-linux.sourceforge.net/
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+endef
+
+define Build/InstallDev
+ mkdir -p $(1)/usr/include/crypto
+ $(CP) ./src/cryptodev.h $(1)/usr/include/crypto
+endef
+
+$(eval $(call BuildPackage,ocf-crypto-headers))
diff --git a/package/libs/ocf-crypto-headers/Makefile b/package/libs/ocf-crypto-headers/Makefile
new file mode 100644
index 0000000..0b1c6bd
--- /dev/null
+++ b/package/libs/ocf-crypto-headers/Makefile
@@ -0,0 +1,39 @@
+#
+# Copyright (C) 2008-2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=ocf-crypto-headers
+PKG_VERSION:=20110720
+PKG_RELEASE:=1
+
+PKG_LICENSE:=GPLv2
+PKG_LICENSE_FILES:=cryptodev.h
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/ocf-crypto-headers
+ SECTION:=utils
+ CATEGORY:=Utilities
+ TITLE:=OCF-Linux cryptodev header
+ PKGARCH:=all
+ URL:=http://ocf-linux.sourceforge.net/
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+endef
+
+define Build/InstallDev
+ mkdir -p $(1)/usr/include/crypto
+ $(CP) ./src/cryptodev.h $(1)/usr/include/crypto
+endef
+
+$(eval $(call BuildPackage,ocf-crypto-headers))
diff --git a/package/libs/ocf-crypto-headers/src/.svn/entries b/package/libs/ocf-crypto-headers/src/.svn/entries
new file mode 100644
index 0000000..f41bac8
--- /dev/null
+++ b/package/libs/ocf-crypto-headers/src/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs/ocf-crypto-headers/src
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+cryptodev.h
+file
+
+
+
+
+2013-03-17T12:13:06.000000Z
+23cb69fef410e5ed0d4057f67ef63742
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+17214
+
diff --git a/package/libs/ocf-crypto-headers/src/.svn/prop-base/cryptodev.h.svn-base b/package/libs/ocf-crypto-headers/src/.svn/prop-base/cryptodev.h.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/libs/ocf-crypto-headers/src/.svn/prop-base/cryptodev.h.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/libs/ocf-crypto-headers/src/.svn/text-base/cryptodev.h.svn-base b/package/libs/ocf-crypto-headers/src/.svn/text-base/cryptodev.h.svn-base
new file mode 100644
index 0000000..cca0ec8
--- /dev/null
+++ b/package/libs/ocf-crypto-headers/src/.svn/text-base/cryptodev.h.svn-base
@@ -0,0 +1,480 @@
+/* $FreeBSD: src/sys/opencrypto/cryptodev.h,v 1.25 2007/05/09 19:37:02 gnn Exp $ */
+/* $OpenBSD: cryptodev.h,v 1.31 2002/06/11 11:14:29 beck Exp $ */
+
+/*-
+ * Linux port done by David McCullough <david_mccullough@mcafee.com>
+ * Copyright (C) 2006-2010 David McCullough
+ * Copyright (C) 2004-2005 Intel Corporation.
+ * The license and original author are listed below.
+ *
+ * The author of this code is Angelos D. Keromytis (angelos@cis.upenn.edu)
+ * Copyright (c) 2002-2006 Sam Leffler, Errno Consulting
+ *
+ * This code was written by Angelos D. Keromytis in Athens, Greece, in
+ * February 2000. Network Security Technologies Inc. (NSTI) kindly
+ * supported the development of this code.
+ *
+ * Copyright (c) 2000 Angelos D. Keromytis
+ *
+ * Permission to use, copy, and modify this software with or without fee
+ * is hereby granted, provided that this entire notice is included in
+ * all source code copies of any software which is or includes a copy or
+ * modification of this software.
+ *
+ * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTY. IN PARTICULAR, NONE OF THE AUTHORS MAKES ANY
+ * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE
+ * MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR
+ * PURPOSE.
+ *
+ * Copyright (c) 2001 Theo de Raadt
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Effort sponsored in part by the Defense Advanced Research Projects
+ * Agency (DARPA) and Air Force Research Laboratory, Air Force
+ * Materiel Command, USAF, under agreement number F30602-01-2-0537.
+ *
+ */
+
+#ifndef _CRYPTO_CRYPTO_H_
+#define _CRYPTO_CRYPTO_H_
+
+/* Some initial values */
+#define CRYPTO_DRIVERS_INITIAL 4
+#define CRYPTO_SW_SESSIONS 32
+
+/* Hash values */
+#define NULL_HASH_LEN 0
+#define MD5_HASH_LEN 16
+#define SHA1_HASH_LEN 20
+#define RIPEMD160_HASH_LEN 20
+#define SHA2_256_HASH_LEN 32
+#define SHA2_384_HASH_LEN 48
+#define SHA2_512_HASH_LEN 64
+#define MD5_KPDK_HASH_LEN 16
+#define SHA1_KPDK_HASH_LEN 20
+/* Maximum hash algorithm result length */
+#define HASH_MAX_LEN SHA2_512_HASH_LEN /* Keep this updated */
+
+/* HMAC values */
+#define NULL_HMAC_BLOCK_LEN 1
+#define MD5_HMAC_BLOCK_LEN 64
+#define SHA1_HMAC_BLOCK_LEN 64
+#define RIPEMD160_HMAC_BLOCK_LEN 64
+#define SHA2_256_HMAC_BLOCK_LEN 64
+#define SHA2_384_HMAC_BLOCK_LEN 128
+#define SHA2_512_HMAC_BLOCK_LEN 128
+/* Maximum HMAC block length */
+#define HMAC_MAX_BLOCK_LEN SHA2_512_HMAC_BLOCK_LEN /* Keep this updated */
+#define HMAC_IPAD_VAL 0x36
+#define HMAC_OPAD_VAL 0x5C
+
+/* Encryption algorithm block sizes */
+#define NULL_BLOCK_LEN 1
+#define DES_BLOCK_LEN 8
+#define DES3_BLOCK_LEN 8
+#define BLOWFISH_BLOCK_LEN 8
+#define SKIPJACK_BLOCK_LEN 8
+#define CAST128_BLOCK_LEN 8
+#define RIJNDAEL128_BLOCK_LEN 16
+#define AES_BLOCK_LEN RIJNDAEL128_BLOCK_LEN
+#define CAMELLIA_BLOCK_LEN 16
+#define ARC4_BLOCK_LEN 1
+#define EALG_MAX_BLOCK_LEN AES_BLOCK_LEN /* Keep this updated */
+
+/* Encryption algorithm min and max key sizes */
+#define NULL_MIN_KEY_LEN 0
+#define NULL_MAX_KEY_LEN 0
+#define DES_MIN_KEY_LEN 8
+#define DES_MAX_KEY_LEN 8
+#define DES3_MIN_KEY_LEN 24
+#define DES3_MAX_KEY_LEN 24
+#define BLOWFISH_MIN_KEY_LEN 4
+#define BLOWFISH_MAX_KEY_LEN 56
+#define SKIPJACK_MIN_KEY_LEN 10
+#define SKIPJACK_MAX_KEY_LEN 10
+#define CAST128_MIN_KEY_LEN 5
+#define CAST128_MAX_KEY_LEN 16
+#define RIJNDAEL128_MIN_KEY_LEN 16
+#define RIJNDAEL128_MAX_KEY_LEN 32
+#define AES_MIN_KEY_LEN RIJNDAEL128_MIN_KEY_LEN
+#define AES_MAX_KEY_LEN RIJNDAEL128_MAX_KEY_LEN
+#define CAMELLIA_MIN_KEY_LEN 16
+#define CAMELLIA_MAX_KEY_LEN 32
+#define ARC4_MIN_KEY_LEN 1
+#define ARC4_MAX_KEY_LEN 256
+
+/* Max size of data that can be processed */
+#define CRYPTO_MAX_DATA_LEN 64*1024 - 1
+
+#define CRYPTO_ALGORITHM_MIN 1
+#define CRYPTO_DES_CBC 1
+#define CRYPTO_3DES_CBC 2
+#define CRYPTO_BLF_CBC 3
+#define CRYPTO_CAST_CBC 4
+#define CRYPTO_SKIPJACK_CBC 5
+#define CRYPTO_MD5_HMAC 6
+#define CRYPTO_SHA1_HMAC 7
+#define CRYPTO_RIPEMD160_HMAC 8
+#define CRYPTO_MD5_KPDK 9
+#define CRYPTO_SHA1_KPDK 10
+#define CRYPTO_RIJNDAEL128_CBC 11 /* 128 bit blocksize */
+#define CRYPTO_AES_CBC 11 /* 128 bit blocksize -- the same as above */
+#define CRYPTO_ARC4 12
+#define CRYPTO_MD5 13
+#define CRYPTO_SHA1 14
+#define CRYPTO_NULL_HMAC 15
+#define CRYPTO_NULL_CBC 16
+#define CRYPTO_DEFLATE_COMP 17 /* Deflate compression algorithm */
+#define CRYPTO_SHA2_256_HMAC 18
+#define CRYPTO_SHA2_384_HMAC 19
+#define CRYPTO_SHA2_512_HMAC 20
+#define CRYPTO_CAMELLIA_CBC 21
+#define CRYPTO_SHA2_256 22
+#define CRYPTO_SHA2_384 23
+#define CRYPTO_SHA2_512 24
+#define CRYPTO_RIPEMD160 25
+#define CRYPTO_LZS_COMP 26
+#define CRYPTO_ALGORITHM_MAX 26 /* Keep updated - see above */
+
+/* Algorithm flags */
+#define CRYPTO_ALG_FLAG_SUPPORTED 0x01 /* Algorithm is supported */
+#define CRYPTO_ALG_FLAG_RNG_ENABLE 0x02 /* Has HW RNG for DH/DSA */
+#define CRYPTO_ALG_FLAG_DSA_SHA 0x04 /* Can do SHA on msg */
+
+/*
+ * Crypto driver/device flags. They can set in the crid
+ * parameter when creating a session or submitting a key
+ * op to affect the device/driver assigned. If neither
+ * of these are specified then the crid is assumed to hold
+ * the driver id of an existing (and suitable) device that
+ * must be used to satisfy the request.
+ */
+#define CRYPTO_FLAG_HARDWARE 0x01000000 /* hardware accelerated */
+#define CRYPTO_FLAG_SOFTWARE 0x02000000 /* software implementation */
+
+/* NB: deprecated */
+struct session_op {
+ u_int32_t cipher; /* ie. CRYPTO_DES_CBC */
+ u_int32_t mac; /* ie. CRYPTO_MD5_HMAC */
+
+ u_int32_t keylen; /* cipher key */
+ caddr_t key;
+ int mackeylen; /* mac key */
+ caddr_t mackey;
+
+ u_int32_t ses; /* returns: session # */
+};
+
+struct session2_op {
+ u_int32_t cipher; /* ie. CRYPTO_DES_CBC */
+ u_int32_t mac; /* ie. CRYPTO_MD5_HMAC */
+
+ u_int32_t keylen; /* cipher key */
+ caddr_t key;
+ int mackeylen; /* mac key */
+ caddr_t mackey;
+
+ u_int32_t ses; /* returns: session # */
+ int crid; /* driver id + flags (rw) */
+ int pad[4]; /* for future expansion */
+};
+
+struct crypt_op {
+ u_int32_t ses;
+ u_int16_t op; /* i.e. COP_ENCRYPT */
+#define COP_NONE 0
+#define COP_ENCRYPT 1
+#define COP_DECRYPT 2
+ u_int16_t flags;
+#define COP_F_BATCH 0x0008 /* Batch op if possible */
+ u_int len;
+ caddr_t src, dst; /* become iov[] inside kernel */
+ caddr_t mac; /* must be big enough for chosen MAC */
+ caddr_t iv;
+};
+
+/*
+ * Parameters for looking up a crypto driver/device by
+ * device name or by id. The latter are returned for
+ * created sessions (crid) and completed key operations.
+ */
+struct crypt_find_op {
+ int crid; /* driver id + flags */
+ char name[32]; /* device/driver name */
+};
+
+/* bignum parameter, in packed bytes, ... */
+struct crparam {
+ caddr_t crp_p;
+ u_int crp_nbits;
+};
+
+#define CRK_MAXPARAM 8
+
+struct crypt_kop {
+ u_int crk_op; /* ie. CRK_MOD_EXP or other */
+ u_int crk_status; /* return status */
+ u_short crk_iparams; /* # of input parameters */
+ u_short crk_oparams; /* # of output parameters */
+ u_int crk_crid; /* NB: only used by CIOCKEY2 (rw) */
+ struct crparam crk_param[CRK_MAXPARAM];
+};
+#define CRK_ALGORITM_MIN 0
+#define CRK_MOD_EXP 0
+#define CRK_MOD_EXP_CRT 1
+#define CRK_DSA_SIGN 2
+#define CRK_DSA_VERIFY 3
+#define CRK_DH_COMPUTE_KEY 4
+#define CRK_ALGORITHM_MAX 4 /* Keep updated - see below */
+
+#define CRF_MOD_EXP (1 << CRK_MOD_EXP)
+#define CRF_MOD_EXP_CRT (1 << CRK_MOD_EXP_CRT)
+#define CRF_DSA_SIGN (1 << CRK_DSA_SIGN)
+#define CRF_DSA_VERIFY (1 << CRK_DSA_VERIFY)
+#define CRF_DH_COMPUTE_KEY (1 << CRK_DH_COMPUTE_KEY)
+
+/*
+ * done against open of /dev/crypto, to get a cloned descriptor.
+ * Please use F_SETFD against the cloned descriptor.
+ */
+#define CRIOGET _IOWR('c', 100, u_int32_t)
+#define CRIOASYMFEAT CIOCASYMFEAT
+#define CRIOFINDDEV CIOCFINDDEV
+
+/* the following are done against the cloned descriptor */
+#define CIOCGSESSION _IOWR('c', 101, struct session_op)
+#define CIOCFSESSION _IOW('c', 102, u_int32_t)
+#define CIOCCRYPT _IOWR('c', 103, struct crypt_op)
+#define CIOCKEY _IOWR('c', 104, struct crypt_kop)
+#define CIOCASYMFEAT _IOR('c', 105, u_int32_t)
+#define CIOCGSESSION2 _IOWR('c', 106, struct session2_op)
+#define CIOCKEY2 _IOWR('c', 107, struct crypt_kop)
+#define CIOCFINDDEV _IOWR('c', 108, struct crypt_find_op)
+
+struct cryptotstat {
+ struct timespec acc; /* total accumulated time */
+ struct timespec min; /* min time */
+ struct timespec max; /* max time */
+ u_int32_t count; /* number of observations */
+};
+
+struct cryptostats {
+ u_int32_t cs_ops; /* symmetric crypto ops submitted */
+ u_int32_t cs_errs; /* symmetric crypto ops that failed */
+ u_int32_t cs_kops; /* asymetric/key ops submitted */
+ u_int32_t cs_kerrs; /* asymetric/key ops that failed */
+ u_int32_t cs_intrs; /* crypto swi thread activations */
+ u_int32_t cs_rets; /* crypto return thread activations */
+ u_int32_t cs_blocks; /* symmetric op driver block */
+ u_int32_t cs_kblocks; /* symmetric op driver block */
+ /*
+ * When CRYPTO_TIMING is defined at compile time and the
+ * sysctl debug.crypto is set to 1, the crypto system will
+ * accumulate statistics about how long it takes to process
+ * crypto requests at various points during processing.
+ */
+ struct cryptotstat cs_invoke; /* crypto_dipsatch -> crypto_invoke */
+ struct cryptotstat cs_done; /* crypto_invoke -> crypto_done */
+ struct cryptotstat cs_cb; /* crypto_done -> callback */
+ struct cryptotstat cs_finis; /* callback -> callback return */
+
+ u_int32_t cs_drops; /* crypto ops dropped due to congestion */
+};
+
+#ifdef __KERNEL__
+
+/* Standard initialization structure beginning */
+struct cryptoini {
+ int cri_alg; /* Algorithm to use */
+ int cri_klen; /* Key length, in bits */
+ int cri_mlen; /* Number of bytes we want from the
+ entire hash. 0 means all. */
+ caddr_t cri_key; /* key to use */
+ u_int8_t cri_iv[EALG_MAX_BLOCK_LEN]; /* IV to use */
+ struct cryptoini *cri_next;
+};
+
+/* Describe boundaries of a single crypto operation */
+struct cryptodesc {
+ int crd_skip; /* How many bytes to ignore from start */
+ int crd_len; /* How many bytes to process */
+ int crd_inject; /* Where to inject results, if applicable */
+ int crd_flags;
+
+#define CRD_F_ENCRYPT 0x01 /* Set when doing encryption */
+#define CRD_F_IV_PRESENT 0x02 /* When encrypting, IV is already in
+ place, so don't copy. */
+#define CRD_F_IV_EXPLICIT 0x04 /* IV explicitly provided */
+#define CRD_F_DSA_SHA_NEEDED 0x08 /* Compute SHA-1 of buffer for DSA */
+#define CRD_F_KEY_EXPLICIT 0x10 /* Key explicitly provided */
+#define CRD_F_COMP 0x0f /* Set when doing compression */
+
+ struct cryptoini CRD_INI; /* Initialization/context data */
+#define crd_iv CRD_INI.cri_iv
+#define crd_key CRD_INI.cri_key
+#define crd_alg CRD_INI.cri_alg
+#define crd_klen CRD_INI.cri_klen
+#define crd_mlen CRD_INI.cri_mlen
+
+ struct cryptodesc *crd_next;
+};
+
+/* Structure describing complete operation */
+struct cryptop {
+ struct list_head crp_next;
+ wait_queue_head_t crp_waitq;
+
+ u_int64_t crp_sid; /* Session ID */
+ int crp_ilen; /* Input data total length */
+ int crp_olen; /* Result total length */
+
+ int crp_etype; /*
+ * Error type (zero means no error).
+ * All error codes except EAGAIN
+ * indicate possible data corruption (as in,
+ * the data have been touched). On all
+ * errors, the crp_sid may have changed
+ * (reset to a new one), so the caller
+ * should always check and use the new
+ * value on future requests.
+ */
+ int crp_flags;
+
+#define CRYPTO_F_SKBUF 0x0001 /* Input/output are skbuf chains */
+#define CRYPTO_F_IOV 0x0002 /* Input/output are uio */
+#define CRYPTO_F_REL 0x0004 /* Must return data in same place */
+#define CRYPTO_F_BATCH 0x0008 /* Batch op if possible */
+#define CRYPTO_F_CBIMM 0x0010 /* Do callback immediately */
+#define CRYPTO_F_DONE 0x0020 /* Operation completed */
+#define CRYPTO_F_CBIFSYNC 0x0040 /* Do CBIMM if op is synchronous */
+
+ caddr_t crp_buf; /* Data to be processed */
+ caddr_t crp_opaque; /* Opaque pointer, passed along */
+ struct cryptodesc *crp_desc; /* Linked list of processing descriptors */
+
+ int (*crp_callback)(struct cryptop *); /* Callback function */
+};
+
+#define CRYPTO_BUF_CONTIG 0x0
+#define CRYPTO_BUF_IOV 0x1
+#define CRYPTO_BUF_SKBUF 0x2
+
+#define CRYPTO_OP_DECRYPT 0x0
+#define CRYPTO_OP_ENCRYPT 0x1
+
+/*
+ * Hints passed to process methods.
+ */
+#define CRYPTO_HINT_MORE 0x1 /* more ops coming shortly */
+
+struct cryptkop {
+ struct list_head krp_next;
+ wait_queue_head_t krp_waitq;
+
+ int krp_flags;
+#define CRYPTO_KF_DONE 0x0001 /* Operation completed */
+#define CRYPTO_KF_CBIMM 0x0002 /* Do callback immediately */
+
+ u_int krp_op; /* ie. CRK_MOD_EXP or other */
+ u_int krp_status; /* return status */
+ u_short krp_iparams; /* # of input parameters */
+ u_short krp_oparams; /* # of output parameters */
+ u_int krp_crid; /* desired device, etc. */
+ u_int32_t krp_hid;
+ struct crparam krp_param[CRK_MAXPARAM]; /* kvm */
+ int (*krp_callback)(struct cryptkop *);
+};
+
+#include <ocf-compat.h>
+
+/*
+ * Session ids are 64 bits. The lower 32 bits contain a "local id" which
+ * is a driver-private session identifier. The upper 32 bits contain a
+ * "hardware id" used by the core crypto code to identify the driver and
+ * a copy of the driver's capabilities that can be used by client code to
+ * optimize operation.
+ */
+#define CRYPTO_SESID2HID(_sid) (((_sid) >> 32) & 0x00ffffff)
+#define CRYPTO_SESID2CAPS(_sid) (((_sid) >> 32) & 0xff000000)
+#define CRYPTO_SESID2LID(_sid) (((u_int32_t) (_sid)) & 0xffffffff)
+
+extern int crypto_newsession(u_int64_t *sid, struct cryptoini *cri, int hard);
+extern int crypto_freesession(u_int64_t sid);
+#define CRYPTOCAP_F_HARDWARE CRYPTO_FLAG_HARDWARE
+#define CRYPTOCAP_F_SOFTWARE CRYPTO_FLAG_SOFTWARE
+#define CRYPTOCAP_F_SYNC 0x04000000 /* operates synchronously */
+extern int32_t crypto_get_driverid(device_t dev, int flags);
+extern int crypto_find_driver(const char *);
+extern device_t crypto_find_device_byhid(int hid);
+extern int crypto_getcaps(int hid);
+extern int crypto_register(u_int32_t driverid, int alg, u_int16_t maxoplen,
+ u_int32_t flags);
+extern int crypto_kregister(u_int32_t, int, u_int32_t);
+extern int crypto_unregister(u_int32_t driverid, int alg);
+extern int crypto_unregister_all(u_int32_t driverid);
+extern int crypto_dispatch(struct cryptop *crp);
+extern int crypto_kdispatch(struct cryptkop *);
+#define CRYPTO_SYMQ 0x1
+#define CRYPTO_ASYMQ 0x2
+extern int crypto_unblock(u_int32_t, int);
+extern void crypto_done(struct cryptop *crp);
+extern void crypto_kdone(struct cryptkop *);
+extern int crypto_getfeat(int *);
+
+extern void crypto_freereq(struct cryptop *crp);
+extern struct cryptop *crypto_getreq(int num);
+
+extern int crypto_usercrypto; /* userland may do crypto requests */
+extern int crypto_userasymcrypto; /* userland may do asym crypto reqs */
+extern int crypto_devallowsoft; /* only use hardware crypto */
+
+/*
+ * random number support, crypto_unregister_all will unregister
+ */
+extern int crypto_rregister(u_int32_t driverid,
+ int (*read_random)(void *arg, u_int32_t *buf, int len), void *arg);
+extern int crypto_runregister_all(u_int32_t driverid);
+
+/*
+ * Crypto-related utility routines used mainly by drivers.
+ *
+ * XXX these don't really belong here; but for now they're
+ * kept apart from the rest of the system.
+ */
+struct uio;
+extern void cuio_copydata(struct uio* uio, int off, int len, caddr_t cp);
+extern void cuio_copyback(struct uio* uio, int off, int len, caddr_t cp);
+extern struct iovec *cuio_getptr(struct uio *uio, int loc, int *off);
+
+extern void crypto_copyback(int flags, caddr_t buf, int off, int size,
+ caddr_t in);
+extern void crypto_copydata(int flags, caddr_t buf, int off, int size,
+ caddr_t out);
+extern int crypto_apply(int flags, caddr_t buf, int off, int len,
+ int (*f)(void *, void *, u_int), void *arg);
+
+#endif /* __KERNEL__ */
+#endif /* _CRYPTO_CRYPTO_H_ */
diff --git a/package/libs/ocf-crypto-headers/src/cryptodev.h b/package/libs/ocf-crypto-headers/src/cryptodev.h
new file mode 100644
index 0000000..cca0ec8
--- /dev/null
+++ b/package/libs/ocf-crypto-headers/src/cryptodev.h
@@ -0,0 +1,480 @@
+/* $FreeBSD: src/sys/opencrypto/cryptodev.h,v 1.25 2007/05/09 19:37:02 gnn Exp $ */
+/* $OpenBSD: cryptodev.h,v 1.31 2002/06/11 11:14:29 beck Exp $ */
+
+/*-
+ * Linux port done by David McCullough <david_mccullough@mcafee.com>
+ * Copyright (C) 2006-2010 David McCullough
+ * Copyright (C) 2004-2005 Intel Corporation.
+ * The license and original author are listed below.
+ *
+ * The author of this code is Angelos D. Keromytis (angelos@cis.upenn.edu)
+ * Copyright (c) 2002-2006 Sam Leffler, Errno Consulting
+ *
+ * This code was written by Angelos D. Keromytis in Athens, Greece, in
+ * February 2000. Network Security Technologies Inc. (NSTI) kindly
+ * supported the development of this code.
+ *
+ * Copyright (c) 2000 Angelos D. Keromytis
+ *
+ * Permission to use, copy, and modify this software with or without fee
+ * is hereby granted, provided that this entire notice is included in
+ * all source code copies of any software which is or includes a copy or
+ * modification of this software.
+ *
+ * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTY. IN PARTICULAR, NONE OF THE AUTHORS MAKES ANY
+ * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE
+ * MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR
+ * PURPOSE.
+ *
+ * Copyright (c) 2001 Theo de Raadt
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Effort sponsored in part by the Defense Advanced Research Projects
+ * Agency (DARPA) and Air Force Research Laboratory, Air Force
+ * Materiel Command, USAF, under agreement number F30602-01-2-0537.
+ *
+ */
+
+#ifndef _CRYPTO_CRYPTO_H_
+#define _CRYPTO_CRYPTO_H_
+
+/* Some initial values */
+#define CRYPTO_DRIVERS_INITIAL 4
+#define CRYPTO_SW_SESSIONS 32
+
+/* Hash values */
+#define NULL_HASH_LEN 0
+#define MD5_HASH_LEN 16
+#define SHA1_HASH_LEN 20
+#define RIPEMD160_HASH_LEN 20
+#define SHA2_256_HASH_LEN 32
+#define SHA2_384_HASH_LEN 48
+#define SHA2_512_HASH_LEN 64
+#define MD5_KPDK_HASH_LEN 16
+#define SHA1_KPDK_HASH_LEN 20
+/* Maximum hash algorithm result length */
+#define HASH_MAX_LEN SHA2_512_HASH_LEN /* Keep this updated */
+
+/* HMAC values */
+#define NULL_HMAC_BLOCK_LEN 1
+#define MD5_HMAC_BLOCK_LEN 64
+#define SHA1_HMAC_BLOCK_LEN 64
+#define RIPEMD160_HMAC_BLOCK_LEN 64
+#define SHA2_256_HMAC_BLOCK_LEN 64
+#define SHA2_384_HMAC_BLOCK_LEN 128
+#define SHA2_512_HMAC_BLOCK_LEN 128
+/* Maximum HMAC block length */
+#define HMAC_MAX_BLOCK_LEN SHA2_512_HMAC_BLOCK_LEN /* Keep this updated */
+#define HMAC_IPAD_VAL 0x36
+#define HMAC_OPAD_VAL 0x5C
+
+/* Encryption algorithm block sizes */
+#define NULL_BLOCK_LEN 1
+#define DES_BLOCK_LEN 8
+#define DES3_BLOCK_LEN 8
+#define BLOWFISH_BLOCK_LEN 8
+#define SKIPJACK_BLOCK_LEN 8
+#define CAST128_BLOCK_LEN 8
+#define RIJNDAEL128_BLOCK_LEN 16
+#define AES_BLOCK_LEN RIJNDAEL128_BLOCK_LEN
+#define CAMELLIA_BLOCK_LEN 16
+#define ARC4_BLOCK_LEN 1
+#define EALG_MAX_BLOCK_LEN AES_BLOCK_LEN /* Keep this updated */
+
+/* Encryption algorithm min and max key sizes */
+#define NULL_MIN_KEY_LEN 0
+#define NULL_MAX_KEY_LEN 0
+#define DES_MIN_KEY_LEN 8
+#define DES_MAX_KEY_LEN 8
+#define DES3_MIN_KEY_LEN 24
+#define DES3_MAX_KEY_LEN 24
+#define BLOWFISH_MIN_KEY_LEN 4
+#define BLOWFISH_MAX_KEY_LEN 56
+#define SKIPJACK_MIN_KEY_LEN 10
+#define SKIPJACK_MAX_KEY_LEN 10
+#define CAST128_MIN_KEY_LEN 5
+#define CAST128_MAX_KEY_LEN 16
+#define RIJNDAEL128_MIN_KEY_LEN 16
+#define RIJNDAEL128_MAX_KEY_LEN 32
+#define AES_MIN_KEY_LEN RIJNDAEL128_MIN_KEY_LEN
+#define AES_MAX_KEY_LEN RIJNDAEL128_MAX_KEY_LEN
+#define CAMELLIA_MIN_KEY_LEN 16
+#define CAMELLIA_MAX_KEY_LEN 32
+#define ARC4_MIN_KEY_LEN 1
+#define ARC4_MAX_KEY_LEN 256
+
+/* Max size of data that can be processed */
+#define CRYPTO_MAX_DATA_LEN 64*1024 - 1
+
+#define CRYPTO_ALGORITHM_MIN 1
+#define CRYPTO_DES_CBC 1
+#define CRYPTO_3DES_CBC 2
+#define CRYPTO_BLF_CBC 3
+#define CRYPTO_CAST_CBC 4
+#define CRYPTO_SKIPJACK_CBC 5
+#define CRYPTO_MD5_HMAC 6
+#define CRYPTO_SHA1_HMAC 7
+#define CRYPTO_RIPEMD160_HMAC 8
+#define CRYPTO_MD5_KPDK 9
+#define CRYPTO_SHA1_KPDK 10
+#define CRYPTO_RIJNDAEL128_CBC 11 /* 128 bit blocksize */
+#define CRYPTO_AES_CBC 11 /* 128 bit blocksize -- the same as above */
+#define CRYPTO_ARC4 12
+#define CRYPTO_MD5 13
+#define CRYPTO_SHA1 14
+#define CRYPTO_NULL_HMAC 15
+#define CRYPTO_NULL_CBC 16
+#define CRYPTO_DEFLATE_COMP 17 /* Deflate compression algorithm */
+#define CRYPTO_SHA2_256_HMAC 18
+#define CRYPTO_SHA2_384_HMAC 19
+#define CRYPTO_SHA2_512_HMAC 20
+#define CRYPTO_CAMELLIA_CBC 21
+#define CRYPTO_SHA2_256 22
+#define CRYPTO_SHA2_384 23
+#define CRYPTO_SHA2_512 24
+#define CRYPTO_RIPEMD160 25
+#define CRYPTO_LZS_COMP 26
+#define CRYPTO_ALGORITHM_MAX 26 /* Keep updated - see above */
+
+/* Algorithm flags */
+#define CRYPTO_ALG_FLAG_SUPPORTED 0x01 /* Algorithm is supported */
+#define CRYPTO_ALG_FLAG_RNG_ENABLE 0x02 /* Has HW RNG for DH/DSA */
+#define CRYPTO_ALG_FLAG_DSA_SHA 0x04 /* Can do SHA on msg */
+
+/*
+ * Crypto driver/device flags. They can set in the crid
+ * parameter when creating a session or submitting a key
+ * op to affect the device/driver assigned. If neither
+ * of these are specified then the crid is assumed to hold
+ * the driver id of an existing (and suitable) device that
+ * must be used to satisfy the request.
+ */
+#define CRYPTO_FLAG_HARDWARE 0x01000000 /* hardware accelerated */
+#define CRYPTO_FLAG_SOFTWARE 0x02000000 /* software implementation */
+
+/* NB: deprecated */
+struct session_op {
+ u_int32_t cipher; /* ie. CRYPTO_DES_CBC */
+ u_int32_t mac; /* ie. CRYPTO_MD5_HMAC */
+
+ u_int32_t keylen; /* cipher key */
+ caddr_t key;
+ int mackeylen; /* mac key */
+ caddr_t mackey;
+
+ u_int32_t ses; /* returns: session # */
+};
+
+struct session2_op {
+ u_int32_t cipher; /* ie. CRYPTO_DES_CBC */
+ u_int32_t mac; /* ie. CRYPTO_MD5_HMAC */
+
+ u_int32_t keylen; /* cipher key */
+ caddr_t key;
+ int mackeylen; /* mac key */
+ caddr_t mackey;
+
+ u_int32_t ses; /* returns: session # */
+ int crid; /* driver id + flags (rw) */
+ int pad[4]; /* for future expansion */
+};
+
+struct crypt_op {
+ u_int32_t ses;
+ u_int16_t op; /* i.e. COP_ENCRYPT */
+#define COP_NONE 0
+#define COP_ENCRYPT 1
+#define COP_DECRYPT 2
+ u_int16_t flags;
+#define COP_F_BATCH 0x0008 /* Batch op if possible */
+ u_int len;
+ caddr_t src, dst; /* become iov[] inside kernel */
+ caddr_t mac; /* must be big enough for chosen MAC */
+ caddr_t iv;
+};
+
+/*
+ * Parameters for looking up a crypto driver/device by
+ * device name or by id. The latter are returned for
+ * created sessions (crid) and completed key operations.
+ */
+struct crypt_find_op {
+ int crid; /* driver id + flags */
+ char name[32]; /* device/driver name */
+};
+
+/* bignum parameter, in packed bytes, ... */
+struct crparam {
+ caddr_t crp_p;
+ u_int crp_nbits;
+};
+
+#define CRK_MAXPARAM 8
+
+struct crypt_kop {
+ u_int crk_op; /* ie. CRK_MOD_EXP or other */
+ u_int crk_status; /* return status */
+ u_short crk_iparams; /* # of input parameters */
+ u_short crk_oparams; /* # of output parameters */
+ u_int crk_crid; /* NB: only used by CIOCKEY2 (rw) */
+ struct crparam crk_param[CRK_MAXPARAM];
+};
+#define CRK_ALGORITM_MIN 0
+#define CRK_MOD_EXP 0
+#define CRK_MOD_EXP_CRT 1
+#define CRK_DSA_SIGN 2
+#define CRK_DSA_VERIFY 3
+#define CRK_DH_COMPUTE_KEY 4
+#define CRK_ALGORITHM_MAX 4 /* Keep updated - see below */
+
+#define CRF_MOD_EXP (1 << CRK_MOD_EXP)
+#define CRF_MOD_EXP_CRT (1 << CRK_MOD_EXP_CRT)
+#define CRF_DSA_SIGN (1 << CRK_DSA_SIGN)
+#define CRF_DSA_VERIFY (1 << CRK_DSA_VERIFY)
+#define CRF_DH_COMPUTE_KEY (1 << CRK_DH_COMPUTE_KEY)
+
+/*
+ * done against open of /dev/crypto, to get a cloned descriptor.
+ * Please use F_SETFD against the cloned descriptor.
+ */
+#define CRIOGET _IOWR('c', 100, u_int32_t)
+#define CRIOASYMFEAT CIOCASYMFEAT
+#define CRIOFINDDEV CIOCFINDDEV
+
+/* the following are done against the cloned descriptor */
+#define CIOCGSESSION _IOWR('c', 101, struct session_op)
+#define CIOCFSESSION _IOW('c', 102, u_int32_t)
+#define CIOCCRYPT _IOWR('c', 103, struct crypt_op)
+#define CIOCKEY _IOWR('c', 104, struct crypt_kop)
+#define CIOCASYMFEAT _IOR('c', 105, u_int32_t)
+#define CIOCGSESSION2 _IOWR('c', 106, struct session2_op)
+#define CIOCKEY2 _IOWR('c', 107, struct crypt_kop)
+#define CIOCFINDDEV _IOWR('c', 108, struct crypt_find_op)
+
+struct cryptotstat {
+ struct timespec acc; /* total accumulated time */
+ struct timespec min; /* min time */
+ struct timespec max; /* max time */
+ u_int32_t count; /* number of observations */
+};
+
+struct cryptostats {
+ u_int32_t cs_ops; /* symmetric crypto ops submitted */
+ u_int32_t cs_errs; /* symmetric crypto ops that failed */
+ u_int32_t cs_kops; /* asymetric/key ops submitted */
+ u_int32_t cs_kerrs; /* asymetric/key ops that failed */
+ u_int32_t cs_intrs; /* crypto swi thread activations */
+ u_int32_t cs_rets; /* crypto return thread activations */
+ u_int32_t cs_blocks; /* symmetric op driver block */
+ u_int32_t cs_kblocks; /* symmetric op driver block */
+ /*
+ * When CRYPTO_TIMING is defined at compile time and the
+ * sysctl debug.crypto is set to 1, the crypto system will
+ * accumulate statistics about how long it takes to process
+ * crypto requests at various points during processing.
+ */
+ struct cryptotstat cs_invoke; /* crypto_dipsatch -> crypto_invoke */
+ struct cryptotstat cs_done; /* crypto_invoke -> crypto_done */
+ struct cryptotstat cs_cb; /* crypto_done -> callback */
+ struct cryptotstat cs_finis; /* callback -> callback return */
+
+ u_int32_t cs_drops; /* crypto ops dropped due to congestion */
+};
+
+#ifdef __KERNEL__
+
+/* Standard initialization structure beginning */
+struct cryptoini {
+ int cri_alg; /* Algorithm to use */
+ int cri_klen; /* Key length, in bits */
+ int cri_mlen; /* Number of bytes we want from the
+ entire hash. 0 means all. */
+ caddr_t cri_key; /* key to use */
+ u_int8_t cri_iv[EALG_MAX_BLOCK_LEN]; /* IV to use */
+ struct cryptoini *cri_next;
+};
+
+/* Describe boundaries of a single crypto operation */
+struct cryptodesc {
+ int crd_skip; /* How many bytes to ignore from start */
+ int crd_len; /* How many bytes to process */
+ int crd_inject; /* Where to inject results, if applicable */
+ int crd_flags;
+
+#define CRD_F_ENCRYPT 0x01 /* Set when doing encryption */
+#define CRD_F_IV_PRESENT 0x02 /* When encrypting, IV is already in
+ place, so don't copy. */
+#define CRD_F_IV_EXPLICIT 0x04 /* IV explicitly provided */
+#define CRD_F_DSA_SHA_NEEDED 0x08 /* Compute SHA-1 of buffer for DSA */
+#define CRD_F_KEY_EXPLICIT 0x10 /* Key explicitly provided */
+#define CRD_F_COMP 0x0f /* Set when doing compression */
+
+ struct cryptoini CRD_INI; /* Initialization/context data */
+#define crd_iv CRD_INI.cri_iv
+#define crd_key CRD_INI.cri_key
+#define crd_alg CRD_INI.cri_alg
+#define crd_klen CRD_INI.cri_klen
+#define crd_mlen CRD_INI.cri_mlen
+
+ struct cryptodesc *crd_next;
+};
+
+/* Structure describing complete operation */
+struct cryptop {
+ struct list_head crp_next;
+ wait_queue_head_t crp_waitq;
+
+ u_int64_t crp_sid; /* Session ID */
+ int crp_ilen; /* Input data total length */
+ int crp_olen; /* Result total length */
+
+ int crp_etype; /*
+ * Error type (zero means no error).
+ * All error codes except EAGAIN
+ * indicate possible data corruption (as in,
+ * the data have been touched). On all
+ * errors, the crp_sid may have changed
+ * (reset to a new one), so the caller
+ * should always check and use the new
+ * value on future requests.
+ */
+ int crp_flags;
+
+#define CRYPTO_F_SKBUF 0x0001 /* Input/output are skbuf chains */
+#define CRYPTO_F_IOV 0x0002 /* Input/output are uio */
+#define CRYPTO_F_REL 0x0004 /* Must return data in same place */
+#define CRYPTO_F_BATCH 0x0008 /* Batch op if possible */
+#define CRYPTO_F_CBIMM 0x0010 /* Do callback immediately */
+#define CRYPTO_F_DONE 0x0020 /* Operation completed */
+#define CRYPTO_F_CBIFSYNC 0x0040 /* Do CBIMM if op is synchronous */
+
+ caddr_t crp_buf; /* Data to be processed */
+ caddr_t crp_opaque; /* Opaque pointer, passed along */
+ struct cryptodesc *crp_desc; /* Linked list of processing descriptors */
+
+ int (*crp_callback)(struct cryptop *); /* Callback function */
+};
+
+#define CRYPTO_BUF_CONTIG 0x0
+#define CRYPTO_BUF_IOV 0x1
+#define CRYPTO_BUF_SKBUF 0x2
+
+#define CRYPTO_OP_DECRYPT 0x0
+#define CRYPTO_OP_ENCRYPT 0x1
+
+/*
+ * Hints passed to process methods.
+ */
+#define CRYPTO_HINT_MORE 0x1 /* more ops coming shortly */
+
+struct cryptkop {
+ struct list_head krp_next;
+ wait_queue_head_t krp_waitq;
+
+ int krp_flags;
+#define CRYPTO_KF_DONE 0x0001 /* Operation completed */
+#define CRYPTO_KF_CBIMM 0x0002 /* Do callback immediately */
+
+ u_int krp_op; /* ie. CRK_MOD_EXP or other */
+ u_int krp_status; /* return status */
+ u_short krp_iparams; /* # of input parameters */
+ u_short krp_oparams; /* # of output parameters */
+ u_int krp_crid; /* desired device, etc. */
+ u_int32_t krp_hid;
+ struct crparam krp_param[CRK_MAXPARAM]; /* kvm */
+ int (*krp_callback)(struct cryptkop *);
+};
+
+#include <ocf-compat.h>
+
+/*
+ * Session ids are 64 bits. The lower 32 bits contain a "local id" which
+ * is a driver-private session identifier. The upper 32 bits contain a
+ * "hardware id" used by the core crypto code to identify the driver and
+ * a copy of the driver's capabilities that can be used by client code to
+ * optimize operation.
+ */
+#define CRYPTO_SESID2HID(_sid) (((_sid) >> 32) & 0x00ffffff)
+#define CRYPTO_SESID2CAPS(_sid) (((_sid) >> 32) & 0xff000000)
+#define CRYPTO_SESID2LID(_sid) (((u_int32_t) (_sid)) & 0xffffffff)
+
+extern int crypto_newsession(u_int64_t *sid, struct cryptoini *cri, int hard);
+extern int crypto_freesession(u_int64_t sid);
+#define CRYPTOCAP_F_HARDWARE CRYPTO_FLAG_HARDWARE
+#define CRYPTOCAP_F_SOFTWARE CRYPTO_FLAG_SOFTWARE
+#define CRYPTOCAP_F_SYNC 0x04000000 /* operates synchronously */
+extern int32_t crypto_get_driverid(device_t dev, int flags);
+extern int crypto_find_driver(const char *);
+extern device_t crypto_find_device_byhid(int hid);
+extern int crypto_getcaps(int hid);
+extern int crypto_register(u_int32_t driverid, int alg, u_int16_t maxoplen,
+ u_int32_t flags);
+extern int crypto_kregister(u_int32_t, int, u_int32_t);
+extern int crypto_unregister(u_int32_t driverid, int alg);
+extern int crypto_unregister_all(u_int32_t driverid);
+extern int crypto_dispatch(struct cryptop *crp);
+extern int crypto_kdispatch(struct cryptkop *);
+#define CRYPTO_SYMQ 0x1
+#define CRYPTO_ASYMQ 0x2
+extern int crypto_unblock(u_int32_t, int);
+extern void crypto_done(struct cryptop *crp);
+extern void crypto_kdone(struct cryptkop *);
+extern int crypto_getfeat(int *);
+
+extern void crypto_freereq(struct cryptop *crp);
+extern struct cryptop *crypto_getreq(int num);
+
+extern int crypto_usercrypto; /* userland may do crypto requests */
+extern int crypto_userasymcrypto; /* userland may do asym crypto reqs */
+extern int crypto_devallowsoft; /* only use hardware crypto */
+
+/*
+ * random number support, crypto_unregister_all will unregister
+ */
+extern int crypto_rregister(u_int32_t driverid,
+ int (*read_random)(void *arg, u_int32_t *buf, int len), void *arg);
+extern int crypto_runregister_all(u_int32_t driverid);
+
+/*
+ * Crypto-related utility routines used mainly by drivers.
+ *
+ * XXX these don't really belong here; but for now they're
+ * kept apart from the rest of the system.
+ */
+struct uio;
+extern void cuio_copydata(struct uio* uio, int off, int len, caddr_t cp);
+extern void cuio_copyback(struct uio* uio, int off, int len, caddr_t cp);
+extern struct iovec *cuio_getptr(struct uio *uio, int loc, int *off);
+
+extern void crypto_copyback(int flags, caddr_t buf, int off, int size,
+ caddr_t in);
+extern void crypto_copydata(int flags, caddr_t buf, int off, int size,
+ caddr_t out);
+extern int crypto_apply(int flags, caddr_t buf, int off, int len,
+ int (*f)(void *, void *, u_int), void *arg);
+
+#endif /* __KERNEL__ */
+#endif /* _CRYPTO_CRYPTO_H_ */
diff --git a/package/libs/openssl/.svn/entries b/package/libs/openssl/.svn/entries
new file mode 100644
index 0000000..cd69627
--- /dev/null
+++ b/package/libs/openssl/.svn/entries
@@ -0,0 +1,99 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs/openssl
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-02-19T17:22:51.449811Z
+35684
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+patches
+dir
+
+Config.in
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+db03c18ff9ebacf4f2f605dd2407a85e
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+241
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+f851293b095726aade36464bc97d77cd
+2013-02-14T13:00:03.576038Z
+35600
+florian
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5133
+
diff --git a/package/libs/openssl/.svn/prop-base/Makefile.svn-base b/package/libs/openssl/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..8e522ae
--- /dev/null
+++ b/package/libs/openssl/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:copyright
+V 30
+Copyright (C) 2006 OpenWrt.org
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/libs/openssl/.svn/text-base/Config.in.svn-base b/package/libs/openssl/.svn/text-base/Config.in.svn-base
new file mode 100644
index 0000000..11591de
--- /dev/null
+++ b/package/libs/openssl/.svn/text-base/Config.in.svn-base
@@ -0,0 +1,13 @@
+menu "Configuration"
+ depends on PACKAGE_libopenssl
+
+config OPENSSL_ENGINE_CRYPTO
+ bool
+ prompt "Crypto acceleration support"
+
+config OPENSSL_ENGINE_DIGEST
+ bool
+ depends OPENSSL_ENGINE_CRYPTO
+ prompt "Digests acceleration support"
+
+endmenu
diff --git a/package/libs/openssl/.svn/text-base/Makefile.svn-base b/package/libs/openssl/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..a8b3257
--- /dev/null
+++ b/package/libs/openssl/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,180 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=openssl
+PKG_VERSION:=1.0.1e
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://www.openssl.org/source/ \
+ ftp://ftp.funet.fi/pub/crypt/mirrors/ftp.openssl.org/source \
+ ftp://ftp.sunet.se/pub/security/tools/net/openssl/source/
+PKG_MD5SUM:=66bf6f10f060d561929de96f9dfe5b8c
+
+PKG_LICENSE:=SSLEAY OPENSSL
+PKG_LICENSE_FILES:=LICENSE
+PKG_BUILD_DEPENDS:=ocf-crypto-headers
+PKG_CONFIG_DEPENDS:=CONFIG_OPENSSL_ENGINE_CRYPTO CONFIG_OPENSSL_ENGINE_DIGEST
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/openssl/Default
+ TITLE:=Open source SSL toolkit
+ URL:=http://www.openssl.org/
+endef
+
+define Package/libopenssl/config
+source "$(SOURCE)/Config.in"
+endef
+
+define Package/openssl/Default/description
+The OpenSSL Project is a collaborative effort to develop a robust,
+commercial-grade, full-featured, and Open Source toolkit implementing the Secure
+Sockets Layer (SSL v2/v3) and Transport Layer Security (TLS v1) protocols as well
+as a full-strength general purpose cryptography library.
+endef
+
+define Package/libopenssl
+$(call Package/openssl/Default)
+ SECTION:=libs
+ SUBMENU:=SSL
+ CATEGORY:=Libraries
+ DEPENDS:=+zlib
+ TITLE+= (libraries)
+ MENU:=1
+endef
+
+define Package/libopenssl/description
+$(call Package/openssl/Default/description)
+This package contains the OpenSSL shared libraries, needed by other programs.
+endef
+
+define Package/openssl-util
+ $(call Package/openssl/Default)
+ SECTION:=utils
+ CATEGORY:=Utilities
+ DEPENDS:=+libopenssl
+ TITLE+= (utility)
+endef
+
+define Package/openssl-util/conffiles
+/etc/ssl/openssl.cnf
+endef
+
+define Package/openssl-util/description
+$(call Package/openssl/Default/description)
+This package contains the OpenSSL command-line utility.
+endef
+
+
+OPENSSL_NO_CIPHERS:= no-idea no-md2 no-mdc2 no-rc5 no-sha0 no-smime \
+ no-rmd160 no-aes192 no-ripemd no-camellia no-ans1 no-krb5
+OPENSSL_OPTIONS:= shared no-ec no-err no-hw no-threads zlib-dynamic no-sse2
+
+ifdef CONFIG_OPENSSL_ENGINE_CRYPTO
+ OPENSSL_OPTIONS += -DHAVE_CRYPTODEV
+ ifdef CONFIG_OPENSSL_ENGINE_DIGEST
+ OPENSSL_OPTIONS += -DUSE_CRYPTODEV_DIGESTS
+ endif
+else
+ OPENSSL_OPTIONS += no-engines
+endif
+
+ifeq ($(CONFIG_x86_64),y)
+ OPENSSL_TARGET:=linux-x86_64
+else
+ OPENSSL_OPTIONS+=no-sse2
+ ifeq ($(CONFIG_mips)$(CONFIG_mipsel),y)
+ OPENSSL_TARGET:=linux-mips-openwrt
+ else
+ OPENSSL_TARGET:=linux-generic-openwrt
+ OPENSSL_OPTIONS+=no-perlasm
+ endif
+endif
+
+define Build/Configure
+ (cd $(PKG_BUILD_DIR); \
+ ./Configure $(OPENSSL_TARGET) \
+ --prefix=/usr \
+ --openssldir=/etc/ssl \
+ $(TARGET_CPPFLAGS) \
+ $(TARGET_LDFLAGS) -ldl \
+ -DOPENSSL_SMALL_FOOTPRINT \
+ $(OPENSSL_NO_CIPHERS) \
+ $(OPENSSL_OPTIONS) \
+ )
+endef
+
+TARGET_CFLAGS += $(FPIC)
+
+define Build/Compile
+ # XXX: OpenSSL "make depend" will look for installed headers before its own,
+ # so remove installed stuff first
+ -$(SUBMAKE) -j1 clean-staging
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ MAKEDEPPROG="$(TARGET_CROSS)gcc" \
+ OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
+ $(OPENSSL_MAKEFLAGS) \
+ depend
+ $(_SINGLE)$(MAKE) -C $(PKG_BUILD_DIR) \
+ CC="$(TARGET_CC)" \
+ AR="$(TARGET_CROSS)ar r" \
+ RANLIB="$(TARGET_CROSS)ranlib" \
+ OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
+ $(OPENSSL_MAKEFLAGS) \
+ all
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ CC="$(TARGET_CC)" \
+ AR="$(TARGET_CROSS)ar r" \
+ RANLIB="$(TARGET_CROSS)ranlib" \
+ OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
+ $(OPENSSL_MAKEFLAGS) \
+ build-shared
+ # Work around openssl build bug to link libssl.so with libcrypto.so.
+ -rm $(PKG_BUILD_DIR)/libssl.so.*.*.*
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ CC="$(TARGET_CC)" \
+ OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
+ $(OPENSSL_MAKEFLAGS) \
+ do_linux-shared
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ CC="$(TARGET_CC)" \
+ INSTALL_PREFIX="$(PKG_INSTALL_DIR)" \
+ $(OPENSSL_MAKEFLAGS) \
+ install
+endef
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include
+ $(CP) $(PKG_INSTALL_DIR)/usr/include/openssl $(1)/usr/include/
+ $(INSTALL_DIR) $(1)/usr/lib/
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{crypto,ssl}.{a,so*} $(1)/usr/lib/
+ $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/{openssl,libcrypto,libssl}.pc $(1)/usr/lib/pkgconfig/
+ [ -n "$(TARGET_LDFLAGS)" ] && $(SED) 's#$(TARGET_LDFLAGS)##g' $(1)/usr/lib/pkgconfig/{openssl,libcrypto,libssl}.pc || true
+endef
+
+define Package/libopenssl/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libcrypto.so.* $(1)/usr/lib/
+ $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libssl.so.* $(1)/usr/lib/
+endef
+
+define Package/openssl-util/install
+ $(INSTALL_DIR) $(1)/etc/ssl
+ $(CP) $(PKG_INSTALL_DIR)/etc/ssl/openssl.cnf $(1)/etc/ssl/
+ $(INSTALL_DIR) $(1)/etc/ssl/certs
+ $(INSTALL_DIR) $(1)/etc/ssl/private
+ chmod 0700 $(1)/etc/ssl/private
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/openssl $(1)/usr/bin/
+endef
+
+$(eval $(call BuildPackage,libopenssl))
+$(eval $(call BuildPackage,openssl-util))
diff --git a/package/libs/openssl/Config.in b/package/libs/openssl/Config.in
new file mode 100644
index 0000000..11591de
--- /dev/null
+++ b/package/libs/openssl/Config.in
@@ -0,0 +1,13 @@
+menu "Configuration"
+ depends on PACKAGE_libopenssl
+
+config OPENSSL_ENGINE_CRYPTO
+ bool
+ prompt "Crypto acceleration support"
+
+config OPENSSL_ENGINE_DIGEST
+ bool
+ depends OPENSSL_ENGINE_CRYPTO
+ prompt "Digests acceleration support"
+
+endmenu
diff --git a/package/libs/openssl/Makefile b/package/libs/openssl/Makefile
new file mode 100644
index 0000000..a8b3257
--- /dev/null
+++ b/package/libs/openssl/Makefile
@@ -0,0 +1,180 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=openssl
+PKG_VERSION:=1.0.1e
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://www.openssl.org/source/ \
+ ftp://ftp.funet.fi/pub/crypt/mirrors/ftp.openssl.org/source \
+ ftp://ftp.sunet.se/pub/security/tools/net/openssl/source/
+PKG_MD5SUM:=66bf6f10f060d561929de96f9dfe5b8c
+
+PKG_LICENSE:=SSLEAY OPENSSL
+PKG_LICENSE_FILES:=LICENSE
+PKG_BUILD_DEPENDS:=ocf-crypto-headers
+PKG_CONFIG_DEPENDS:=CONFIG_OPENSSL_ENGINE_CRYPTO CONFIG_OPENSSL_ENGINE_DIGEST
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/openssl/Default
+ TITLE:=Open source SSL toolkit
+ URL:=http://www.openssl.org/
+endef
+
+define Package/libopenssl/config
+source "$(SOURCE)/Config.in"
+endef
+
+define Package/openssl/Default/description
+The OpenSSL Project is a collaborative effort to develop a robust,
+commercial-grade, full-featured, and Open Source toolkit implementing the Secure
+Sockets Layer (SSL v2/v3) and Transport Layer Security (TLS v1) protocols as well
+as a full-strength general purpose cryptography library.
+endef
+
+define Package/libopenssl
+$(call Package/openssl/Default)
+ SECTION:=libs
+ SUBMENU:=SSL
+ CATEGORY:=Libraries
+ DEPENDS:=+zlib
+ TITLE+= (libraries)
+ MENU:=1
+endef
+
+define Package/libopenssl/description
+$(call Package/openssl/Default/description)
+This package contains the OpenSSL shared libraries, needed by other programs.
+endef
+
+define Package/openssl-util
+ $(call Package/openssl/Default)
+ SECTION:=utils
+ CATEGORY:=Utilities
+ DEPENDS:=+libopenssl
+ TITLE+= (utility)
+endef
+
+define Package/openssl-util/conffiles
+/etc/ssl/openssl.cnf
+endef
+
+define Package/openssl-util/description
+$(call Package/openssl/Default/description)
+This package contains the OpenSSL command-line utility.
+endef
+
+
+OPENSSL_NO_CIPHERS:= no-idea no-md2 no-mdc2 no-rc5 no-sha0 no-smime \
+ no-rmd160 no-aes192 no-ripemd no-camellia no-ans1 no-krb5
+OPENSSL_OPTIONS:= shared no-ec no-err no-hw no-threads zlib-dynamic no-sse2
+
+ifdef CONFIG_OPENSSL_ENGINE_CRYPTO
+ OPENSSL_OPTIONS += -DHAVE_CRYPTODEV
+ ifdef CONFIG_OPENSSL_ENGINE_DIGEST
+ OPENSSL_OPTIONS += -DUSE_CRYPTODEV_DIGESTS
+ endif
+else
+ OPENSSL_OPTIONS += no-engines
+endif
+
+ifeq ($(CONFIG_x86_64),y)
+ OPENSSL_TARGET:=linux-x86_64
+else
+ OPENSSL_OPTIONS+=no-sse2
+ ifeq ($(CONFIG_mips)$(CONFIG_mipsel),y)
+ OPENSSL_TARGET:=linux-mips-openwrt
+ else
+ OPENSSL_TARGET:=linux-generic-openwrt
+ OPENSSL_OPTIONS+=no-perlasm
+ endif
+endif
+
+define Build/Configure
+ (cd $(PKG_BUILD_DIR); \
+ ./Configure $(OPENSSL_TARGET) \
+ --prefix=/usr \
+ --openssldir=/etc/ssl \
+ $(TARGET_CPPFLAGS) \
+ $(TARGET_LDFLAGS) -ldl \
+ -DOPENSSL_SMALL_FOOTPRINT \
+ $(OPENSSL_NO_CIPHERS) \
+ $(OPENSSL_OPTIONS) \
+ )
+endef
+
+TARGET_CFLAGS += $(FPIC)
+
+define Build/Compile
+ # XXX: OpenSSL "make depend" will look for installed headers before its own,
+ # so remove installed stuff first
+ -$(SUBMAKE) -j1 clean-staging
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ MAKEDEPPROG="$(TARGET_CROSS)gcc" \
+ OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
+ $(OPENSSL_MAKEFLAGS) \
+ depend
+ $(_SINGLE)$(MAKE) -C $(PKG_BUILD_DIR) \
+ CC="$(TARGET_CC)" \
+ AR="$(TARGET_CROSS)ar r" \
+ RANLIB="$(TARGET_CROSS)ranlib" \
+ OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
+ $(OPENSSL_MAKEFLAGS) \
+ all
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ CC="$(TARGET_CC)" \
+ AR="$(TARGET_CROSS)ar r" \
+ RANLIB="$(TARGET_CROSS)ranlib" \
+ OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
+ $(OPENSSL_MAKEFLAGS) \
+ build-shared
+ # Work around openssl build bug to link libssl.so with libcrypto.so.
+ -rm $(PKG_BUILD_DIR)/libssl.so.*.*.*
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ CC="$(TARGET_CC)" \
+ OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
+ $(OPENSSL_MAKEFLAGS) \
+ do_linux-shared
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ CC="$(TARGET_CC)" \
+ INSTALL_PREFIX="$(PKG_INSTALL_DIR)" \
+ $(OPENSSL_MAKEFLAGS) \
+ install
+endef
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include
+ $(CP) $(PKG_INSTALL_DIR)/usr/include/openssl $(1)/usr/include/
+ $(INSTALL_DIR) $(1)/usr/lib/
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{crypto,ssl}.{a,so*} $(1)/usr/lib/
+ $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/{openssl,libcrypto,libssl}.pc $(1)/usr/lib/pkgconfig/
+ [ -n "$(TARGET_LDFLAGS)" ] && $(SED) 's#$(TARGET_LDFLAGS)##g' $(1)/usr/lib/pkgconfig/{openssl,libcrypto,libssl}.pc || true
+endef
+
+define Package/libopenssl/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libcrypto.so.* $(1)/usr/lib/
+ $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libssl.so.* $(1)/usr/lib/
+endef
+
+define Package/openssl-util/install
+ $(INSTALL_DIR) $(1)/etc/ssl
+ $(CP) $(PKG_INSTALL_DIR)/etc/ssl/openssl.cnf $(1)/etc/ssl/
+ $(INSTALL_DIR) $(1)/etc/ssl/certs
+ $(INSTALL_DIR) $(1)/etc/ssl/private
+ chmod 0700 $(1)/etc/ssl/private
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/openssl $(1)/usr/bin/
+endef
+
+$(eval $(call BuildPackage,libopenssl))
+$(eval $(call BuildPackage,openssl-util))
diff --git a/package/libs/openssl/patches/.svn/entries b/package/libs/openssl/patches/.svn/entries
new file mode 100644
index 0000000..bd8371e
--- /dev/null
+++ b/package/libs/openssl/patches/.svn/entries
@@ -0,0 +1,334 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs/openssl/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-02-19T17:22:51.449811Z
+35684
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+180-fix_link_segfault.patch
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+bfdf3fa3a83b422e933acc9a28e9c0e5
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+857
+
+190-remove_timestamp_check.patch
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+8db1faab003d9753a87b7d294e6758e5
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+877
+
+150-no_engines.patch
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+00bc725aead92d3b47d6607c24ac8e57
+2013-02-08T19:36:06.852386Z
+35524
+yardley
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4711
+
+120-cisco-dtls-fix.patch
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+593eee387437dc2030eaccda9d88b5b9
+2013-02-14T13:00:03.576038Z
+35600
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1077
+
+110-optimize-for-size.patch
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+1db64a89394dc47eb707ff1ae26f0774
+2013-02-08T19:36:06.852386Z
+35524
+yardley
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1550
+
+130-perl-path.patch
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+6460bc4a54c252e3a84955f49ae23d57
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1407
+
+140-makefile-dirs.patch
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+c2d8d1721fd6c241027242aacf420b97
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+196
+
+160-disable_doc_tests.patch
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+4587085c82575a8edd6f34b0240e076d
+2013-02-08T19:36:06.852386Z
+35524
+yardley
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1515
+
+170-bash_path.patch
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+b4d518058f28873758901a65f4880704
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+195
+
diff --git a/package/libs/openssl/patches/.svn/prop-base/110-optimize-for-size.patch.svn-base b/package/libs/openssl/patches/.svn/prop-base/110-optimize-for-size.patch.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/libs/openssl/patches/.svn/prop-base/110-optimize-for-size.patch.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/libs/openssl/patches/.svn/prop-base/130-perl-path.patch.svn-base b/package/libs/openssl/patches/.svn/prop-base/130-perl-path.patch.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/libs/openssl/patches/.svn/prop-base/130-perl-path.patch.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/libs/openssl/patches/.svn/prop-base/140-makefile-dirs.patch.svn-base b/package/libs/openssl/patches/.svn/prop-base/140-makefile-dirs.patch.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/libs/openssl/patches/.svn/prop-base/140-makefile-dirs.patch.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/libs/openssl/patches/.svn/prop-base/150-no_engines.patch.svn-base b/package/libs/openssl/patches/.svn/prop-base/150-no_engines.patch.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/libs/openssl/patches/.svn/prop-base/150-no_engines.patch.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/libs/openssl/patches/.svn/prop-base/160-disable_doc_tests.patch.svn-base b/package/libs/openssl/patches/.svn/prop-base/160-disable_doc_tests.patch.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/libs/openssl/patches/.svn/prop-base/160-disable_doc_tests.patch.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/libs/openssl/patches/.svn/prop-base/170-bash_path.patch.svn-base b/package/libs/openssl/patches/.svn/prop-base/170-bash_path.patch.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/libs/openssl/patches/.svn/prop-base/170-bash_path.patch.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/libs/openssl/patches/.svn/text-base/110-optimize-for-size.patch.svn-base b/package/libs/openssl/patches/.svn/text-base/110-optimize-for-size.patch.svn-base
new file mode 100644
index 0000000..85dba1e
--- /dev/null
+++ b/package/libs/openssl/patches/.svn/text-base/110-optimize-for-size.patch.svn-base
@@ -0,0 +1,13 @@
+--- a/Configure
++++ b/Configure
+@@ -402,6 +402,10 @@ my %table=(
+ "linux-alpha-ccc","ccc:-fast -readonly_strings -DL_ENDIAN -DTERMIO::-D_REENTRANT:::SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL:${alpha_asm}",
+ "linux-alpha+bwx-ccc","ccc:-fast -readonly_strings -DL_ENDIAN -DTERMIO::-D_REENTRANT:::SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL:${alpha_asm}",
+
++# OpenWrt targets
++"linux-mips-openwrt","gcc:-DTERMIO \$(OPENWRT_OPTIMIZATION_FLAGS) -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${mips32_asm}:o32:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
++"linux-generic-openwrt","gcc:-DTERMIO \$(OPENWRT_OPTIMIZATION_FLAGS) -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
++
+ # Android: linux-* but without -DTERMIO and pointers to headers and libs.
+ "android","gcc:-mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
+ "android-x86","gcc:-mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:".eval{my $asm=${x86_elf_asm};$asm=~s/:elf/:android/;$asm}.":dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
diff --git a/package/libs/openssl/patches/.svn/text-base/120-cisco-dtls-fix.patch.svn-base b/package/libs/openssl/patches/.svn/text-base/120-cisco-dtls-fix.patch.svn-base
new file mode 100644
index 0000000..11e6bb5
--- /dev/null
+++ b/package/libs/openssl/patches/.svn/text-base/120-cisco-dtls-fix.patch.svn-base
@@ -0,0 +1,31 @@
+From 9fe4603b8245425a4c46986ed000fca054231253 Mon Sep 17 00:00:00 2001
+From: David Woodhouse <dwmw2@infradead.org>
+Date: Tue, 12 Feb 2013 14:55:32 +0000
+Subject: [PATCH] Check DTLS_BAD_VER for version number.
+
+The version check for DTLS1_VERSION was redundant as
+DTLS1_VERSION > TLS1_1_VERSION, however we do need to
+check for DTLS1_BAD_VER for compatibility.
+
+PR:2984
+(cherry picked from commit d980abb22e22661e98e5cee33d760ab0c7584ecc)
+---
+ ssl/s3_cbc.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/ssl/s3_cbc.c b/ssl/s3_cbc.c
+index 02edf3f..443a31e 100644
+--- a/ssl/s3_cbc.c
++++ b/ssl/s3_cbc.c
+@@ -148,7 +148,7 @@ int tls1_cbc_remove_padding(const SSL* s,
+ unsigned padding_length, good, to_check, i;
+ const unsigned overhead = 1 /* padding length byte */ + mac_size;
+ /* Check if version requires explicit IV */
+- if (s->version >= TLS1_1_VERSION || s->version == DTLS1_VERSION)
++ if (s->version >= TLS1_1_VERSION || s->version == DTLS1_BAD_VER)
+ {
+ /* These lengths are all public so we can test them in
+ * non-constant time.
+--
+1.8.1.2
+
diff --git a/package/libs/openssl/patches/.svn/text-base/130-perl-path.patch.svn-base b/package/libs/openssl/patches/.svn/text-base/130-perl-path.patch.svn-base
new file mode 100644
index 0000000..dd4fa54
--- /dev/null
+++ b/package/libs/openssl/patches/.svn/text-base/130-perl-path.patch.svn-base
@@ -0,0 +1,64 @@
+--- a/Configure
++++ b/Configure
+@@ -1,4 +1,4 @@
+-:
++#!/usr/bin/perl
+ eval 'exec perl -S $0 ${1+"$@"}'
+ if $running_under_some_shell;
+ ##
+--- a/tools/c_rehash.in
++++ b/tools/c_rehash.in
+@@ -1,4 +1,4 @@
+-#!/usr/local/bin/perl
++#!/usr/bin/perl
+
+
+ # Perl c_rehash script, scan all files in a directory
+--- a/util/clean-depend.pl
++++ b/util/clean-depend.pl
+@@ -1,4 +1,4 @@
+-#!/usr/local/bin/perl -w
++#!/usr/bin/perl
+ # Clean the dependency list in a makefile of standard includes...
+ # Written by Ben Laurie <ben@algroup.co.uk> 19 Jan 1999
+
+--- a/util/mkdef.pl
++++ b/util/mkdef.pl
+@@ -1,4 +1,4 @@
+-#!/usr/local/bin/perl -w
++#!/usr/bin/perl
+ #
+ # generate a .def file
+ #
+--- a/util/mkerr.pl
++++ b/util/mkerr.pl
+@@ -1,4 +1,4 @@
+-#!/usr/local/bin/perl -w
++#!/usr/bin/perl
+
+ my $config = "crypto/err/openssl.ec";
+ my $hprefix = "openssl/";
+--- a/util/mkstack.pl
++++ b/util/mkstack.pl
+@@ -1,4 +1,4 @@
+-#!/usr/local/bin/perl -w
++#!/usr/bin/perl
+
+ # This is a utility that searches out "DECLARE_STACK_OF()"
+ # declarations in .h and .c files, and updates/creates/replaces
+--- a/util/pod2man.pl
++++ b/util/pod2man.pl
+@@ -1,4 +1,4 @@
+-: #!/usr/bin/perl-5.005
++#!/usr/bin/perl
+ eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
+ if $running_under_some_shell;
+
+--- a/util/selftest.pl
++++ b/util/selftest.pl
+@@ -1,4 +1,4 @@
+-#!/usr/local/bin/perl -w
++#!/usr/bin/perl
+ #
+ # Run the test suite and generate a report
+ #
diff --git a/package/libs/openssl/patches/.svn/text-base/140-makefile-dirs.patch.svn-base b/package/libs/openssl/patches/.svn/text-base/140-makefile-dirs.patch.svn-base
new file mode 100644
index 0000000..b51ca28
--- /dev/null
+++ b/package/libs/openssl/patches/.svn/text-base/140-makefile-dirs.patch.svn-base
@@ -0,0 +1,11 @@
+--- a/Makefile.org
++++ b/Makefile.org
+@@ -135,7 +135,7 @@ FIPSCANLIB=
+
+ BASEADDR=
+
+-DIRS= crypto ssl engines apps test tools
++DIRS= crypto ssl apps
+ ENGDIRS= ccgost
+ SHLIBDIRS= crypto ssl
+
diff --git a/package/libs/openssl/patches/.svn/text-base/150-no_engines.patch.svn-base b/package/libs/openssl/patches/.svn/text-base/150-no_engines.patch.svn-base
new file mode 100644
index 0000000..8e93970
--- /dev/null
+++ b/package/libs/openssl/patches/.svn/text-base/150-no_engines.patch.svn-base
@@ -0,0 +1,81 @@
+--- a/Configure
++++ b/Configure
+@@ -2003,6 +2003,11 @@ EOF
+ close(OUT);
+ }
+
++# ugly hack to disable engines
++if($target eq "mingwx") {
++ system("sed -e s/^LIB/XLIB/g -i engines/Makefile");
++}
++
+ print <<EOF;
+
+ Configured for $target.
+--- a/util/libeay.num
++++ b/util/libeay.num
+@@ -2071,7 +2071,6 @@ PKCS7_ATTR_SIGN_it
+ UI_add_error_string 2633 EXIST::FUNCTION:
+ KRB5_CHECKSUM_free 2634 EXIST::FUNCTION:
+ OCSP_REQUEST_get_ext 2635 EXIST::FUNCTION:
+-ENGINE_load_ubsec 2636 EXIST::FUNCTION:ENGINE,STATIC_ENGINE
+ ENGINE_register_all_digests 2637 EXIST::FUNCTION:ENGINE
+ PKEY_USAGE_PERIOD_it 2638 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
+ PKEY_USAGE_PERIOD_it 2638 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
+@@ -2545,7 +2544,6 @@ OCSP_RESPONSE_new
+ AES_set_encrypt_key 3024 EXIST::FUNCTION:AES
+ OCSP_resp_count 3025 EXIST::FUNCTION:
+ KRB5_CHECKSUM_new 3026 EXIST::FUNCTION:
+-ENGINE_load_cswift 3027 EXIST::FUNCTION:ENGINE,STATIC_ENGINE
+ OCSP_onereq_get0_id 3028 EXIST::FUNCTION:
+ ENGINE_set_default_ciphers 3029 EXIST::FUNCTION:ENGINE
+ NOTICEREF_it 3030 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
+@@ -2576,7 +2574,6 @@ ASN1_primitive_free
+ i2d_EXTENDED_KEY_USAGE 3052 EXIST::FUNCTION:
+ i2d_OCSP_SIGNATURE 3053 EXIST::FUNCTION:
+ asn1_enc_save 3054 EXIST::FUNCTION:
+-ENGINE_load_nuron 3055 EXIST::FUNCTION:ENGINE,STATIC_ENGINE
+ _ossl_old_des_pcbc_encrypt 3056 EXIST::FUNCTION:DES
+ PKCS12_MAC_DATA_it 3057 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
+ PKCS12_MAC_DATA_it 3057 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
+@@ -2600,7 +2597,6 @@ asn1_get_choice_selector
+ i2d_KRB5_CHECKSUM 3072 EXIST::FUNCTION:
+ ENGINE_set_table_flags 3073 EXIST::FUNCTION:ENGINE
+ AES_options 3074 EXIST::FUNCTION:AES
+-ENGINE_load_chil 3075 EXIST::FUNCTION:ENGINE,STATIC_ENGINE
+ OCSP_id_cmp 3076 EXIST::FUNCTION:
+ OCSP_BASICRESP_new 3077 EXIST::FUNCTION:
+ OCSP_REQUEST_get_ext_by_NID 3078 EXIST::FUNCTION:
+@@ -2667,7 +2663,6 @@ OCSP_CRLID_it
+ OCSP_CRLID_it 3127 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
+ i2d_KRB5_AUTHENTBODY 3128 EXIST::FUNCTION:
+ OCSP_REQUEST_get_ext_count 3129 EXIST::FUNCTION:
+-ENGINE_load_atalla 3130 EXIST::FUNCTION:ENGINE,STATIC_ENGINE
+ X509_NAME_it 3131 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
+ X509_NAME_it 3131 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
+ USERNOTICE_it 3132 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
+@@ -2762,8 +2757,6 @@ DES_read_2passwords
+ DES_read_password 3207 EXIST::FUNCTION:DES
+ UI_UTIL_read_pw 3208 EXIST::FUNCTION:
+ UI_UTIL_read_pw_string 3209 EXIST::FUNCTION:
+-ENGINE_load_aep 3210 EXIST::FUNCTION:ENGINE,STATIC_ENGINE
+-ENGINE_load_sureware 3211 EXIST::FUNCTION:ENGINE,STATIC_ENGINE
+ OPENSSL_add_all_algorithms_noconf 3212 EXIST:!VMS:FUNCTION:
+ OPENSSL_add_all_algo_noconf 3212 EXIST:VMS:FUNCTION:
+ OPENSSL_add_all_algorithms_conf 3213 EXIST:!VMS:FUNCTION:
+@@ -2772,7 +2765,6 @@ OPENSSL_load_builtin_modules
+ AES_ofb128_encrypt 3215 EXIST::FUNCTION:AES
+ AES_ctr128_encrypt 3216 EXIST::FUNCTION:AES
+ AES_cfb128_encrypt 3217 EXIST::FUNCTION:AES
+-ENGINE_load_4758cca 3218 EXIST::FUNCTION:ENGINE,STATIC_ENGINE
+ _ossl_096_des_random_seed 3219 EXIST::FUNCTION:DES
+ EVP_aes_256_ofb 3220 EXIST::FUNCTION:AES
+ EVP_aes_192_ofb 3221 EXIST::FUNCTION:AES
+@@ -3107,7 +3099,6 @@ EC_GFp_nist_method
+ STORE_meth_set_modify_fn 3530 NOEXIST::FUNCTION:
+ STORE_method_set_modify_function 3530 NOEXIST::FUNCTION:
+ STORE_parse_attrs_next 3531 NOEXIST::FUNCTION:
+-ENGINE_load_padlock 3532 EXIST::FUNCTION:ENGINE,STATIC_ENGINE
+ EC_GROUP_set_curve_name 3533 EXIST::FUNCTION:EC
+ X509_CERT_PAIR_it 3534 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
+ X509_CERT_PAIR_it 3534 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
diff --git a/package/libs/openssl/patches/.svn/text-base/160-disable_doc_tests.patch.svn-base b/package/libs/openssl/patches/.svn/text-base/160-disable_doc_tests.patch.svn-base
new file mode 100644
index 0000000..d0bf19a
--- /dev/null
+++ b/package/libs/openssl/patches/.svn/text-base/160-disable_doc_tests.patch.svn-base
@@ -0,0 +1,58 @@
+--- a/Makefile
++++ b/Makefile
+@@ -137,7 +137,7 @@ FIPSCANLIB=
+
+ BASEADDR=0xFB00000
+
+-DIRS= crypto ssl engines apps test tools
++DIRS= crypto ssl engines apps tools
+ ENGDIRS= ccgost
+ SHLIBDIRS= crypto ssl
+
+@@ -155,7 +155,7 @@ SDIRS= \
+
+ # tests to perform. "alltests" is a special word indicating that all tests
+ # should be performed.
+-TESTS = alltests
++TESTS =
+
+ MAKEFILE= Makefile
+
+@@ -169,7 +169,7 @@ SHELL=/bin/sh
+
+ TOP= .
+ ONEDIRS=out tmp
+-EDIRS= times doc bugs util include certs ms shlib mt demos perl sf dep VMS
++EDIRS= times bugs util include certs ms shlib mt demos perl sf dep VMS
+ WDIRS= windows
+ LIBS= libcrypto.a libssl.a
+ SHARED_CRYPTO=libcrypto$(SHLIB_EXT)
+@@ -270,7 +270,7 @@ reflect:
+ @[ -n "$(THIS)" ] && $(CLEARENV) && $(MAKE) $(THIS) -e $(BUILDENV)
+
+ sub_all: build_all
+-build_all: build_libs build_apps build_tests build_tools
++build_all: build_libs build_apps build_tools
+
+ build_libs: build_crypto build_ssl build_engines
+
+@@ -539,7 +539,7 @@ dist:
+ dist_pem_h:
+ (cd crypto/pem; $(MAKE) -e $(BUILDENV) pem.h; $(MAKE) clean)
+
+-install: all install_docs install_sw
++install: all install_sw
+
+ install_sw:
+ @$(PERL) $(TOP)/util/mkdir-p.pl $(INSTALL_PREFIX)$(INSTALLTOP)/bin \
+--- a/Makefile.org
++++ b/Makefile.org
+@@ -537,7 +537,7 @@ dist:
+ dist_pem_h:
+ (cd crypto/pem; $(MAKE) -e $(BUILDENV) pem.h; $(MAKE) clean)
+
+-install: all install_docs install_sw
++install: all install_sw
+
+ install_sw:
+ @$(PERL) $(TOP)/util/mkdir-p.pl $(INSTALL_PREFIX)$(INSTALLTOP)/bin \
diff --git a/package/libs/openssl/patches/.svn/text-base/170-bash_path.patch.svn-base b/package/libs/openssl/patches/.svn/text-base/170-bash_path.patch.svn-base
new file mode 100644
index 0000000..c29b59a
--- /dev/null
+++ b/package/libs/openssl/patches/.svn/text-base/170-bash_path.patch.svn-base
@@ -0,0 +1,8 @@
+--- a/util/domd
++++ b/util/domd
+@@ -1,4 +1,4 @@
+-#!/bin/sh
++#!/usr/bin/env bash
+ # Do a makedepend, only leave out the standard headers
+ # Written by Ben Laurie <ben@algroup.co.uk> 19 Jan 1999
+
diff --git a/package/libs/openssl/patches/.svn/text-base/180-fix_link_segfault.patch.svn-base b/package/libs/openssl/patches/.svn/text-base/180-fix_link_segfault.patch.svn-base
new file mode 100644
index 0000000..3e36beb
--- /dev/null
+++ b/package/libs/openssl/patches/.svn/text-base/180-fix_link_segfault.patch.svn-base
@@ -0,0 +1,18 @@
+--- a/Makefile.shared
++++ b/Makefile.shared
+@@ -95,7 +95,6 @@ LINK_APP= \
+ LDCMD="$${LDCMD:-$(CC)}"; LDFLAGS="$${LDFLAGS:-$(CFLAGS)}"; \
+ LIBPATH=`for x in $$LIBDEPS; do echo $$x; done | sed -e 's/^ *-L//;t' -e d | uniq`; \
+ LIBPATH=`echo $$LIBPATH | sed -e 's/ /:/g'`; \
+- LD_LIBRARY_PATH=$$LIBPATH:$$LD_LIBRARY_PATH \
+ $${LDCMD} $${LDFLAGS} -o $${APPNAME:=$(APPNAME)} $(OBJECTS) $${LIBDEPS} )
+
+ LINK_SO= \
+@@ -105,7 +104,6 @@ LINK_SO= \
+ SHAREDFLAGS="$${SHAREDFLAGS:-$(CFLAGS) $(SHARED_LDFLAGS)}"; \
+ LIBPATH=`for x in $$LIBDEPS; do echo $$x; done | sed -e 's/^ *-L//;t' -e d | uniq`; \
+ LIBPATH=`echo $$LIBPATH | sed -e 's/ /:/g'`; \
+- LD_LIBRARY_PATH=$$LIBPATH:$$LD_LIBRARY_PATH \
+ $${SHAREDCMD} $${SHAREDFLAGS} \
+ -o $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX \
+ $$ALLSYMSFLAGS $$SHOBJECTS $$NOALLSYMSFLAGS $$LIBDEPS \
diff --git a/package/libs/openssl/patches/.svn/text-base/190-remove_timestamp_check.patch.svn-base b/package/libs/openssl/patches/.svn/text-base/190-remove_timestamp_check.patch.svn-base
new file mode 100644
index 0000000..2677b2d
--- /dev/null
+++ b/package/libs/openssl/patches/.svn/text-base/190-remove_timestamp_check.patch.svn-base
@@ -0,0 +1,23 @@
+--- a/Makefile.org
++++ b/Makefile.org
+@@ -184,7 +184,7 @@ WTARFILE= $(NAME)-win.tar
+ EXHEADER= e_os2.h
+ HEADER= e_os.h
+
+-all: Makefile build_all openssl.pc libssl.pc libcrypto.pc
++all: build_all openssl.pc libssl.pc libcrypto.pc
+
+ # as we stick to -e, CLEARENV ensures that local variables in lower
+ # Makefiles remain local and variable. $${VAR+VAR} is tribute to Korn
+@@ -396,11 +396,6 @@ openssl.pc: Makefile
+ echo 'Libs.private: $(EX_LIBS)'; \
+ echo 'Cflags: -I$${includedir} $(KRB5_INCLUDES)' ) > openssl.pc
+
+-Makefile: Makefile.org Configure config
+- @echo "Makefile is older than Makefile.org, Configure or config."
+- @echo "Reconfigure the source tree (via './config' or 'perl Configure'), please."
+- @false
+-
+ libclean:
+ rm -f *.map *.so *.so.* *.dylib *.dll engines/*.so engines/*.dll engines/*.dylib *.a engines/*.a */lib */*/lib
+
diff --git a/package/libs/openssl/patches/110-optimize-for-size.patch b/package/libs/openssl/patches/110-optimize-for-size.patch
new file mode 100644
index 0000000..85dba1e
--- /dev/null
+++ b/package/libs/openssl/patches/110-optimize-for-size.patch
@@ -0,0 +1,13 @@
+--- a/Configure
++++ b/Configure
+@@ -402,6 +402,10 @@ my %table=(
+ "linux-alpha-ccc","ccc:-fast -readonly_strings -DL_ENDIAN -DTERMIO::-D_REENTRANT:::SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL:${alpha_asm}",
+ "linux-alpha+bwx-ccc","ccc:-fast -readonly_strings -DL_ENDIAN -DTERMIO::-D_REENTRANT:::SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL:${alpha_asm}",
+
++# OpenWrt targets
++"linux-mips-openwrt","gcc:-DTERMIO \$(OPENWRT_OPTIMIZATION_FLAGS) -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${mips32_asm}:o32:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
++"linux-generic-openwrt","gcc:-DTERMIO \$(OPENWRT_OPTIMIZATION_FLAGS) -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
++
+ # Android: linux-* but without -DTERMIO and pointers to headers and libs.
+ "android","gcc:-mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
+ "android-x86","gcc:-mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:".eval{my $asm=${x86_elf_asm};$asm=~s/:elf/:android/;$asm}.":dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
diff --git a/package/libs/openssl/patches/120-cisco-dtls-fix.patch b/package/libs/openssl/patches/120-cisco-dtls-fix.patch
new file mode 100644
index 0000000..11e6bb5
--- /dev/null
+++ b/package/libs/openssl/patches/120-cisco-dtls-fix.patch
@@ -0,0 +1,31 @@
+From 9fe4603b8245425a4c46986ed000fca054231253 Mon Sep 17 00:00:00 2001
+From: David Woodhouse <dwmw2@infradead.org>
+Date: Tue, 12 Feb 2013 14:55:32 +0000
+Subject: [PATCH] Check DTLS_BAD_VER for version number.
+
+The version check for DTLS1_VERSION was redundant as
+DTLS1_VERSION > TLS1_1_VERSION, however we do need to
+check for DTLS1_BAD_VER for compatibility.
+
+PR:2984
+(cherry picked from commit d980abb22e22661e98e5cee33d760ab0c7584ecc)
+---
+ ssl/s3_cbc.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/ssl/s3_cbc.c b/ssl/s3_cbc.c
+index 02edf3f..443a31e 100644
+--- a/ssl/s3_cbc.c
++++ b/ssl/s3_cbc.c
+@@ -148,7 +148,7 @@ int tls1_cbc_remove_padding(const SSL* s,
+ unsigned padding_length, good, to_check, i;
+ const unsigned overhead = 1 /* padding length byte */ + mac_size;
+ /* Check if version requires explicit IV */
+- if (s->version >= TLS1_1_VERSION || s->version == DTLS1_VERSION)
++ if (s->version >= TLS1_1_VERSION || s->version == DTLS1_BAD_VER)
+ {
+ /* These lengths are all public so we can test them in
+ * non-constant time.
+--
+1.8.1.2
+
diff --git a/package/libs/openssl/patches/130-perl-path.patch b/package/libs/openssl/patches/130-perl-path.patch
new file mode 100644
index 0000000..dd4fa54
--- /dev/null
+++ b/package/libs/openssl/patches/130-perl-path.patch
@@ -0,0 +1,64 @@
+--- a/Configure
++++ b/Configure
+@@ -1,4 +1,4 @@
+-:
++#!/usr/bin/perl
+ eval 'exec perl -S $0 ${1+"$@"}'
+ if $running_under_some_shell;
+ ##
+--- a/tools/c_rehash.in
++++ b/tools/c_rehash.in
+@@ -1,4 +1,4 @@
+-#!/usr/local/bin/perl
++#!/usr/bin/perl
+
+
+ # Perl c_rehash script, scan all files in a directory
+--- a/util/clean-depend.pl
++++ b/util/clean-depend.pl
+@@ -1,4 +1,4 @@
+-#!/usr/local/bin/perl -w
++#!/usr/bin/perl
+ # Clean the dependency list in a makefile of standard includes...
+ # Written by Ben Laurie <ben@algroup.co.uk> 19 Jan 1999
+
+--- a/util/mkdef.pl
++++ b/util/mkdef.pl
+@@ -1,4 +1,4 @@
+-#!/usr/local/bin/perl -w
++#!/usr/bin/perl
+ #
+ # generate a .def file
+ #
+--- a/util/mkerr.pl
++++ b/util/mkerr.pl
+@@ -1,4 +1,4 @@
+-#!/usr/local/bin/perl -w
++#!/usr/bin/perl
+
+ my $config = "crypto/err/openssl.ec";
+ my $hprefix = "openssl/";
+--- a/util/mkstack.pl
++++ b/util/mkstack.pl
+@@ -1,4 +1,4 @@
+-#!/usr/local/bin/perl -w
++#!/usr/bin/perl
+
+ # This is a utility that searches out "DECLARE_STACK_OF()"
+ # declarations in .h and .c files, and updates/creates/replaces
+--- a/util/pod2man.pl
++++ b/util/pod2man.pl
+@@ -1,4 +1,4 @@
+-: #!/usr/bin/perl-5.005
++#!/usr/bin/perl
+ eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
+ if $running_under_some_shell;
+
+--- a/util/selftest.pl
++++ b/util/selftest.pl
+@@ -1,4 +1,4 @@
+-#!/usr/local/bin/perl -w
++#!/usr/bin/perl
+ #
+ # Run the test suite and generate a report
+ #
diff --git a/package/libs/openssl/patches/140-makefile-dirs.patch b/package/libs/openssl/patches/140-makefile-dirs.patch
new file mode 100644
index 0000000..b51ca28
--- /dev/null
+++ b/package/libs/openssl/patches/140-makefile-dirs.patch
@@ -0,0 +1,11 @@
+--- a/Makefile.org
++++ b/Makefile.org
+@@ -135,7 +135,7 @@ FIPSCANLIB=
+
+ BASEADDR=
+
+-DIRS= crypto ssl engines apps test tools
++DIRS= crypto ssl apps
+ ENGDIRS= ccgost
+ SHLIBDIRS= crypto ssl
+
diff --git a/package/libs/openssl/patches/150-no_engines.patch b/package/libs/openssl/patches/150-no_engines.patch
new file mode 100644
index 0000000..8e93970
--- /dev/null
+++ b/package/libs/openssl/patches/150-no_engines.patch
@@ -0,0 +1,81 @@
+--- a/Configure
++++ b/Configure
+@@ -2003,6 +2003,11 @@ EOF
+ close(OUT);
+ }
+
++# ugly hack to disable engines
++if($target eq "mingwx") {
++ system("sed -e s/^LIB/XLIB/g -i engines/Makefile");
++}
++
+ print <<EOF;
+
+ Configured for $target.
+--- a/util/libeay.num
++++ b/util/libeay.num
+@@ -2071,7 +2071,6 @@ PKCS7_ATTR_SIGN_it
+ UI_add_error_string 2633 EXIST::FUNCTION:
+ KRB5_CHECKSUM_free 2634 EXIST::FUNCTION:
+ OCSP_REQUEST_get_ext 2635 EXIST::FUNCTION:
+-ENGINE_load_ubsec 2636 EXIST::FUNCTION:ENGINE,STATIC_ENGINE
+ ENGINE_register_all_digests 2637 EXIST::FUNCTION:ENGINE
+ PKEY_USAGE_PERIOD_it 2638 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
+ PKEY_USAGE_PERIOD_it 2638 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
+@@ -2545,7 +2544,6 @@ OCSP_RESPONSE_new
+ AES_set_encrypt_key 3024 EXIST::FUNCTION:AES
+ OCSP_resp_count 3025 EXIST::FUNCTION:
+ KRB5_CHECKSUM_new 3026 EXIST::FUNCTION:
+-ENGINE_load_cswift 3027 EXIST::FUNCTION:ENGINE,STATIC_ENGINE
+ OCSP_onereq_get0_id 3028 EXIST::FUNCTION:
+ ENGINE_set_default_ciphers 3029 EXIST::FUNCTION:ENGINE
+ NOTICEREF_it 3030 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
+@@ -2576,7 +2574,6 @@ ASN1_primitive_free
+ i2d_EXTENDED_KEY_USAGE 3052 EXIST::FUNCTION:
+ i2d_OCSP_SIGNATURE 3053 EXIST::FUNCTION:
+ asn1_enc_save 3054 EXIST::FUNCTION:
+-ENGINE_load_nuron 3055 EXIST::FUNCTION:ENGINE,STATIC_ENGINE
+ _ossl_old_des_pcbc_encrypt 3056 EXIST::FUNCTION:DES
+ PKCS12_MAC_DATA_it 3057 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
+ PKCS12_MAC_DATA_it 3057 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
+@@ -2600,7 +2597,6 @@ asn1_get_choice_selector
+ i2d_KRB5_CHECKSUM 3072 EXIST::FUNCTION:
+ ENGINE_set_table_flags 3073 EXIST::FUNCTION:ENGINE
+ AES_options 3074 EXIST::FUNCTION:AES
+-ENGINE_load_chil 3075 EXIST::FUNCTION:ENGINE,STATIC_ENGINE
+ OCSP_id_cmp 3076 EXIST::FUNCTION:
+ OCSP_BASICRESP_new 3077 EXIST::FUNCTION:
+ OCSP_REQUEST_get_ext_by_NID 3078 EXIST::FUNCTION:
+@@ -2667,7 +2663,6 @@ OCSP_CRLID_it
+ OCSP_CRLID_it 3127 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
+ i2d_KRB5_AUTHENTBODY 3128 EXIST::FUNCTION:
+ OCSP_REQUEST_get_ext_count 3129 EXIST::FUNCTION:
+-ENGINE_load_atalla 3130 EXIST::FUNCTION:ENGINE,STATIC_ENGINE
+ X509_NAME_it 3131 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
+ X509_NAME_it 3131 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
+ USERNOTICE_it 3132 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
+@@ -2762,8 +2757,6 @@ DES_read_2passwords
+ DES_read_password 3207 EXIST::FUNCTION:DES
+ UI_UTIL_read_pw 3208 EXIST::FUNCTION:
+ UI_UTIL_read_pw_string 3209 EXIST::FUNCTION:
+-ENGINE_load_aep 3210 EXIST::FUNCTION:ENGINE,STATIC_ENGINE
+-ENGINE_load_sureware 3211 EXIST::FUNCTION:ENGINE,STATIC_ENGINE
+ OPENSSL_add_all_algorithms_noconf 3212 EXIST:!VMS:FUNCTION:
+ OPENSSL_add_all_algo_noconf 3212 EXIST:VMS:FUNCTION:
+ OPENSSL_add_all_algorithms_conf 3213 EXIST:!VMS:FUNCTION:
+@@ -2772,7 +2765,6 @@ OPENSSL_load_builtin_modules
+ AES_ofb128_encrypt 3215 EXIST::FUNCTION:AES
+ AES_ctr128_encrypt 3216 EXIST::FUNCTION:AES
+ AES_cfb128_encrypt 3217 EXIST::FUNCTION:AES
+-ENGINE_load_4758cca 3218 EXIST::FUNCTION:ENGINE,STATIC_ENGINE
+ _ossl_096_des_random_seed 3219 EXIST::FUNCTION:DES
+ EVP_aes_256_ofb 3220 EXIST::FUNCTION:AES
+ EVP_aes_192_ofb 3221 EXIST::FUNCTION:AES
+@@ -3107,7 +3099,6 @@ EC_GFp_nist_method
+ STORE_meth_set_modify_fn 3530 NOEXIST::FUNCTION:
+ STORE_method_set_modify_function 3530 NOEXIST::FUNCTION:
+ STORE_parse_attrs_next 3531 NOEXIST::FUNCTION:
+-ENGINE_load_padlock 3532 EXIST::FUNCTION:ENGINE,STATIC_ENGINE
+ EC_GROUP_set_curve_name 3533 EXIST::FUNCTION:EC
+ X509_CERT_PAIR_it 3534 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
+ X509_CERT_PAIR_it 3534 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
diff --git a/package/libs/openssl/patches/160-disable_doc_tests.patch b/package/libs/openssl/patches/160-disable_doc_tests.patch
new file mode 100644
index 0000000..d0bf19a
--- /dev/null
+++ b/package/libs/openssl/patches/160-disable_doc_tests.patch
@@ -0,0 +1,58 @@
+--- a/Makefile
++++ b/Makefile
+@@ -137,7 +137,7 @@ FIPSCANLIB=
+
+ BASEADDR=0xFB00000
+
+-DIRS= crypto ssl engines apps test tools
++DIRS= crypto ssl engines apps tools
+ ENGDIRS= ccgost
+ SHLIBDIRS= crypto ssl
+
+@@ -155,7 +155,7 @@ SDIRS= \
+
+ # tests to perform. "alltests" is a special word indicating that all tests
+ # should be performed.
+-TESTS = alltests
++TESTS =
+
+ MAKEFILE= Makefile
+
+@@ -169,7 +169,7 @@ SHELL=/bin/sh
+
+ TOP= .
+ ONEDIRS=out tmp
+-EDIRS= times doc bugs util include certs ms shlib mt demos perl sf dep VMS
++EDIRS= times bugs util include certs ms shlib mt demos perl sf dep VMS
+ WDIRS= windows
+ LIBS= libcrypto.a libssl.a
+ SHARED_CRYPTO=libcrypto$(SHLIB_EXT)
+@@ -270,7 +270,7 @@ reflect:
+ @[ -n "$(THIS)" ] && $(CLEARENV) && $(MAKE) $(THIS) -e $(BUILDENV)
+
+ sub_all: build_all
+-build_all: build_libs build_apps build_tests build_tools
++build_all: build_libs build_apps build_tools
+
+ build_libs: build_crypto build_ssl build_engines
+
+@@ -539,7 +539,7 @@ dist:
+ dist_pem_h:
+ (cd crypto/pem; $(MAKE) -e $(BUILDENV) pem.h; $(MAKE) clean)
+
+-install: all install_docs install_sw
++install: all install_sw
+
+ install_sw:
+ @$(PERL) $(TOP)/util/mkdir-p.pl $(INSTALL_PREFIX)$(INSTALLTOP)/bin \
+--- a/Makefile.org
++++ b/Makefile.org
+@@ -537,7 +537,7 @@ dist:
+ dist_pem_h:
+ (cd crypto/pem; $(MAKE) -e $(BUILDENV) pem.h; $(MAKE) clean)
+
+-install: all install_docs install_sw
++install: all install_sw
+
+ install_sw:
+ @$(PERL) $(TOP)/util/mkdir-p.pl $(INSTALL_PREFIX)$(INSTALLTOP)/bin \
diff --git a/package/libs/openssl/patches/170-bash_path.patch b/package/libs/openssl/patches/170-bash_path.patch
new file mode 100644
index 0000000..c29b59a
--- /dev/null
+++ b/package/libs/openssl/patches/170-bash_path.patch
@@ -0,0 +1,8 @@
+--- a/util/domd
++++ b/util/domd
+@@ -1,4 +1,4 @@
+-#!/bin/sh
++#!/usr/bin/env bash
+ # Do a makedepend, only leave out the standard headers
+ # Written by Ben Laurie <ben@algroup.co.uk> 19 Jan 1999
+
diff --git a/package/libs/openssl/patches/180-fix_link_segfault.patch b/package/libs/openssl/patches/180-fix_link_segfault.patch
new file mode 100644
index 0000000..3e36beb
--- /dev/null
+++ b/package/libs/openssl/patches/180-fix_link_segfault.patch
@@ -0,0 +1,18 @@
+--- a/Makefile.shared
++++ b/Makefile.shared
+@@ -95,7 +95,6 @@ LINK_APP= \
+ LDCMD="$${LDCMD:-$(CC)}"; LDFLAGS="$${LDFLAGS:-$(CFLAGS)}"; \
+ LIBPATH=`for x in $$LIBDEPS; do echo $$x; done | sed -e 's/^ *-L//;t' -e d | uniq`; \
+ LIBPATH=`echo $$LIBPATH | sed -e 's/ /:/g'`; \
+- LD_LIBRARY_PATH=$$LIBPATH:$$LD_LIBRARY_PATH \
+ $${LDCMD} $${LDFLAGS} -o $${APPNAME:=$(APPNAME)} $(OBJECTS) $${LIBDEPS} )
+
+ LINK_SO= \
+@@ -105,7 +104,6 @@ LINK_SO= \
+ SHAREDFLAGS="$${SHAREDFLAGS:-$(CFLAGS) $(SHARED_LDFLAGS)}"; \
+ LIBPATH=`for x in $$LIBDEPS; do echo $$x; done | sed -e 's/^ *-L//;t' -e d | uniq`; \
+ LIBPATH=`echo $$LIBPATH | sed -e 's/ /:/g'`; \
+- LD_LIBRARY_PATH=$$LIBPATH:$$LD_LIBRARY_PATH \
+ $${SHAREDCMD} $${SHAREDFLAGS} \
+ -o $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX \
+ $$ALLSYMSFLAGS $$SHOBJECTS $$NOALLSYMSFLAGS $$LIBDEPS \
diff --git a/package/libs/openssl/patches/190-remove_timestamp_check.patch b/package/libs/openssl/patches/190-remove_timestamp_check.patch
new file mode 100644
index 0000000..2677b2d
--- /dev/null
+++ b/package/libs/openssl/patches/190-remove_timestamp_check.patch
@@ -0,0 +1,23 @@
+--- a/Makefile.org
++++ b/Makefile.org
+@@ -184,7 +184,7 @@ WTARFILE= $(NAME)-win.tar
+ EXHEADER= e_os2.h
+ HEADER= e_os.h
+
+-all: Makefile build_all openssl.pc libssl.pc libcrypto.pc
++all: build_all openssl.pc libssl.pc libcrypto.pc
+
+ # as we stick to -e, CLEARENV ensures that local variables in lower
+ # Makefiles remain local and variable. $${VAR+VAR} is tribute to Korn
+@@ -396,11 +396,6 @@ openssl.pc: Makefile
+ echo 'Libs.private: $(EX_LIBS)'; \
+ echo 'Cflags: -I$${includedir} $(KRB5_INCLUDES)' ) > openssl.pc
+
+-Makefile: Makefile.org Configure config
+- @echo "Makefile is older than Makefile.org, Configure or config."
+- @echo "Reconfigure the source tree (via './config' or 'perl Configure'), please."
+- @false
+-
+ libclean:
+ rm -f *.map *.so *.so.* *.dylib *.dll engines/*.so engines/*.dll engines/*.dylib *.a engines/*.a */lib */*/lib
+
diff --git a/package/libs/polarssl/.svn/entries b/package/libs/polarssl/.svn/entries
new file mode 100644
index 0000000..9e92c65
--- /dev/null
+++ b/package/libs/polarssl/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs/polarssl
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-02-08T19:47:48.767455Z
+35525
+yardley
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:07.000000Z
+72836fdf35167b4db392039160a2520d
+2013-02-08T19:47:48.767455Z
+35525
+yardley
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1983
+
diff --git a/package/libs/polarssl/.svn/text-base/Makefile.svn-base b/package/libs/polarssl/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..a66402c
--- /dev/null
+++ b/package/libs/polarssl/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,81 @@
+#
+# Copyright (C) 2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=polarssl
+PKG_VERSION:=1.2.5
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-gpl.tgz
+PKG_SOURCE_URL:=https://polarssl.org/code/releases
+PKG_MD5SUM:=f42dd79cd85384ac9ad482caa665ac8f
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/cmake.mk
+
+define Package/polarssl/Default
+ SUBMENU:=SSL
+ TITLE:=Embedded SSL
+ URL:=http://polarssl.org/
+endef
+
+define Package/polarssl/Default/description
+The aim of the PolarSSL project is to provide a quality, open-source
+cryptographic library written in C and targeted at embedded systems.
+endef
+
+define Package/libpolarssl
+$(call Package/polarssl/Default)
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE+= (library)
+endef
+
+define Package/libpolarssl/description
+$(call Package/polarssl/Default/description)
+This package contains the PolarSSL library.
+endef
+
+define Package/polarssl-progs
+$(call Package/polarssl/Default)
+ SECTION:=utils
+ CATEGORY:=Utilities
+ DEPENDS:=+libpolarssl
+ TITLE+= (programs)
+endef
+
+define Package/polarssl-progs/description
+$(call Package/polarssl/Default/description)
+This package contains the PolarSSL programs.
+endef
+
+PKG_INSTALL:=1
+
+CMAKE_OPTIONS += \
+ -DCMAKE_BUILD_TYPE:String="Release" \
+ -DUSE_SHARED_POLARSSL_LIBRARY:Bool=ON \
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include
+ $(CP) $(PKG_INSTALL_DIR)/usr/include/polarssl $(1)/usr/include/
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpolarssl.so* $(1)/usr/lib/
+endef
+
+define Package/libpolarssl/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpolarssl.so* $(1)/usr/lib/
+endef
+
+define Package/polarssl-progs/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/* $(1)/usr/bin/
+endef
+
+$(eval $(call BuildPackage,libpolarssl))
+$(eval $(call BuildPackage,polarssl-progs))
diff --git a/package/libs/polarssl/Makefile b/package/libs/polarssl/Makefile
new file mode 100644
index 0000000..a66402c
--- /dev/null
+++ b/package/libs/polarssl/Makefile
@@ -0,0 +1,81 @@
+#
+# Copyright (C) 2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=polarssl
+PKG_VERSION:=1.2.5
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-gpl.tgz
+PKG_SOURCE_URL:=https://polarssl.org/code/releases
+PKG_MD5SUM:=f42dd79cd85384ac9ad482caa665ac8f
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/cmake.mk
+
+define Package/polarssl/Default
+ SUBMENU:=SSL
+ TITLE:=Embedded SSL
+ URL:=http://polarssl.org/
+endef
+
+define Package/polarssl/Default/description
+The aim of the PolarSSL project is to provide a quality, open-source
+cryptographic library written in C and targeted at embedded systems.
+endef
+
+define Package/libpolarssl
+$(call Package/polarssl/Default)
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE+= (library)
+endef
+
+define Package/libpolarssl/description
+$(call Package/polarssl/Default/description)
+This package contains the PolarSSL library.
+endef
+
+define Package/polarssl-progs
+$(call Package/polarssl/Default)
+ SECTION:=utils
+ CATEGORY:=Utilities
+ DEPENDS:=+libpolarssl
+ TITLE+= (programs)
+endef
+
+define Package/polarssl-progs/description
+$(call Package/polarssl/Default/description)
+This package contains the PolarSSL programs.
+endef
+
+PKG_INSTALL:=1
+
+CMAKE_OPTIONS += \
+ -DCMAKE_BUILD_TYPE:String="Release" \
+ -DUSE_SHARED_POLARSSL_LIBRARY:Bool=ON \
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include
+ $(CP) $(PKG_INSTALL_DIR)/usr/include/polarssl $(1)/usr/include/
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpolarssl.so* $(1)/usr/lib/
+endef
+
+define Package/libpolarssl/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpolarssl.so* $(1)/usr/lib/
+endef
+
+define Package/polarssl-progs/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/* $(1)/usr/bin/
+endef
+
+$(eval $(call BuildPackage,libpolarssl))
+$(eval $(call BuildPackage,polarssl-progs))
diff --git a/package/libs/polarssl/patches/.svn/entries b/package/libs/polarssl/patches/.svn/entries
new file mode 100644
index 0000000..9df2522
--- /dev/null
+++ b/package/libs/polarssl/patches/.svn/entries
@@ -0,0 +1,164 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs/polarssl/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-02-08T19:47:48.767455Z
+35525
+yardley
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+310-fix_blowfish_key_len.patch
+file
+
+
+
+
+2013-03-17T12:13:07.000000Z
+4b4b94fd373188387bc23600546cce34
+2013-01-30T20:07:04.784853Z
+35411
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+698
+
+100-disable-testsuites.patch
+file
+
+
+
+
+2013-03-17T12:13:07.000000Z
+24ac43df7734b072c1eb34d945cd475a
+2013-01-30T20:07:04.784853Z
+35411
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+530
+
+200-reduce_config.patch
+file
+
+
+
+
+2013-03-17T12:13:07.000000Z
+a6227d1541d6ab0b150e6a08b142549a
+2013-02-08T19:47:48.767455Z
+35525
+yardley
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2038
+
+300-openssl_cipher_name_compat.patch
+file
+
+
+
+
+2013-03-17T12:13:07.000000Z
+45a8286a43aa68da8a5c08ec988fba93
+2013-01-30T20:07:04.784853Z
+35411
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1736
+
diff --git a/package/libs/polarssl/patches/.svn/text-base/100-disable-testsuites.patch.svn-base b/package/libs/polarssl/patches/.svn/text-base/100-disable-testsuites.patch.svn-base
new file mode 100644
index 0000000..cf9485e
--- /dev/null
+++ b/package/libs/polarssl/patches/.svn/text-base/100-disable-testsuites.patch.svn-base
@@ -0,0 +1,21 @@
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -38,7 +38,7 @@ add_subdirectory(library)
+ add_subdirectory(include)
+
+ if(CMAKE_COMPILER_IS_GNUCC)
+- add_subdirectory(tests)
++# add_subdirectory(tests)
+ endif(CMAKE_COMPILER_IS_GNUCC)
+
+ add_subdirectory(programs)
+--- a/programs/CMakeLists.txt
++++ b/programs/CMakeLists.txt
+@@ -3,6 +3,6 @@ add_subdirectory(hash)
+ add_subdirectory(pkey)
+ add_subdirectory(random)
+ add_subdirectory(ssl)
+-add_subdirectory(test)
++#add_subdirectory(test)
+ add_subdirectory(x509)
+ add_subdirectory(util)
diff --git a/package/libs/polarssl/patches/.svn/text-base/200-reduce_config.patch.svn-base b/package/libs/polarssl/patches/.svn/text-base/200-reduce_config.patch.svn-base
new file mode 100644
index 0000000..c66bb3f
--- /dev/null
+++ b/package/libs/polarssl/patches/.svn/text-base/200-reduce_config.patch.svn-base
@@ -0,0 +1,112 @@
+--- a/include/polarssl/config.h
++++ b/include/polarssl/config.h
+@@ -177,8 +177,8 @@
+ * Requires: POLARSSL_BIGNUM_C, POLARSSL_RSA_C
+ *
+ * Enable the RSA prime-number generation code.
+- */
+ #define POLARSSL_GENPRIME
++ */
+
+ /**
+ * \def POLARSSL_FS_IO
+@@ -235,8 +235,8 @@
+ * \def POLARSSL_SELF_TEST
+ *
+ * Enable the checkup functions (*_self_test).
+- */
+ #define POLARSSL_SELF_TEST
++ */
+
+ /**
+ * \def POLARSSL_SSL_ALL_ALERT_MESSAGES
+@@ -425,8 +425,8 @@
+ * TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256
+ * TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256
+ * TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256
+- */
+ #define POLARSSL_CAMELLIA_C
++ */
+
+ /**
+ * \def POLARSSL_CERTS_C
+@@ -437,8 +437,8 @@
+ * Caller:
+ *
+ * This module is used for testing (ssl_client/server).
+- */
+ #define POLARSSL_CERTS_C
++ */
+
+ /**
+ * \def POLARSSL_CIPHER_C
+@@ -477,8 +477,8 @@
+ * library/ssl_tls.c
+ *
+ * This module provides debugging functions.
+- */
+ #define POLARSSL_DEBUG_C
++ */
+
+ /**
+ * \def POLARSSL_DES_C
+@@ -560,8 +560,8 @@
+ * enabled as well):
+ * TLS_RSA_WITH_AES_128_GCM_SHA256
+ * TLS_RSA_WITH_AES_256_GCM_SHA384
+- */
+ #define POLARSSL_GCM_C
++ */
+
+ /**
+ * \def POLARSSL_HAVEGE_C
+@@ -574,8 +574,8 @@
+ * Requires: POLARSSL_TIMING_C
+ *
+ * This module enables the HAVEGE random number generator.
+- */
+ #define POLARSSL_HAVEGE_C
++ */
+
+ /**
+ * \def POLARSSL_MD_C
+@@ -649,8 +649,8 @@
+ * Caller: library/aes.c
+ *
+ * This modules adds support for the VIA PadLock on x86.
+- */
+ #define POLARSSL_PADLOCK_C
++ */
+
+ /**
+ * \def POLARSSL_PBKDF2_C
+@@ -763,8 +763,8 @@
+ * Caller:
+ *
+ * Requires: POLARSSL_SSL_CACHE_C
+- */
+ #define POLARSSL_SSL_CACHE_C
++ */
+
+ /**
+ * \def POLARSSL_SSL_CLI_C
+@@ -818,8 +818,8 @@
+ * Caller: library/havege.c
+ *
+ * This module is used by the HAVEGE random number generator.
+- */
+ #define POLARSSL_TIMING_C
++ */
+
+ /**
+ * \def POLARSSL_VERSION_C
+@@ -868,8 +868,8 @@
+ *
+ * Module: library/xtea.c
+ * Caller:
+- */
+ #define POLARSSL_XTEA_C
++ */
+ /* \} name */
+
+ #endif /* config.h */
diff --git a/package/libs/polarssl/patches/.svn/text-base/300-openssl_cipher_name_compat.patch.svn-base b/package/libs/polarssl/patches/.svn/text-base/300-openssl_cipher_name_compat.patch.svn-base
new file mode 100644
index 0000000..6ca43c3
--- /dev/null
+++ b/package/libs/polarssl/patches/.svn/text-base/300-openssl_cipher_name_compat.patch.svn-base
@@ -0,0 +1,53 @@
+--- a/library/cipher.c
++++ b/library/cipher.c
+@@ -279,15 +279,21 @@ const cipher_info_t *cipher_info_from_st
+ #if defined(POLARSSL_BLOWFISH_C)
+ if( !strcasecmp( "BLOWFISH-CBC", cipher_name ) )
+ return cipher_info_from_type( POLARSSL_CIPHER_BLOWFISH_CBC );
++ if( !strcasecmp( "BF-CBC", cipher_name ) )
++ return cipher_info_from_type( POLARSSL_CIPHER_BLOWFISH_CBC );
+
+ #if defined(POLARSSL_CIPHER_MODE_CFB)
+ if( !strcasecmp( "BLOWFISH-CFB64", cipher_name ) )
+ return cipher_info_from_type( POLARSSL_CIPHER_BLOWFISH_CFB64 );
++ if( !strcasecmp( "BF-CFB64", cipher_name ) )
++ return cipher_info_from_type( POLARSSL_CIPHER_BLOWFISH_CFB64 );
+ #endif /* defined(POLARSSL_CIPHER_MODE_CFB) */
+
+ #if defined(POLARSSL_CIPHER_MODE_CTR)
+ if( !strcasecmp( "BLOWFISH-CTR", cipher_name ) )
+ return cipher_info_from_type( POLARSSL_CIPHER_BLOWFISH_CTR );
++ if( !strcasecmp( "BF-CTR", cipher_name ) )
++ return cipher_info_from_type( POLARSSL_CIPHER_BLOWFISH_CTR );
+ #endif /* defined(POLARSSL_CIPHER_MODE_CTR) */
+ #endif
+
+--- a/library/cipher_wrap.c
++++ b/library/cipher_wrap.c
+@@ -643,7 +643,7 @@ const cipher_info_t blowfish_cbc_info =
+ POLARSSL_CIPHER_BLOWFISH_CBC,
+ POLARSSL_MODE_CBC,
+ 32,
+- "BLOWFISH-CBC",
++ "BF-CBC",
+ 8,
+ 8,
+ &blowfish_info
+@@ -654,7 +654,7 @@ const cipher_info_t blowfish_cfb64_info
+ POLARSSL_CIPHER_BLOWFISH_CFB64,
+ POLARSSL_MODE_CFB,
+ 32,
+- "BLOWFISH-CFB64",
++ "BF-CFB64",
+ 8,
+ 8,
+ &blowfish_info
+@@ -666,7 +666,7 @@ const cipher_info_t blowfish_ctr_info =
+ POLARSSL_CIPHER_BLOWFISH_CTR,
+ POLARSSL_MODE_CTR,
+ 32,
+- "BLOWFISH-CTR",
++ "BF-CTR",
+ 8,
+ 8,
+ &blowfish_info
diff --git a/package/libs/polarssl/patches/.svn/text-base/310-fix_blowfish_key_len.patch.svn-base b/package/libs/polarssl/patches/.svn/text-base/310-fix_blowfish_key_len.patch.svn-base
new file mode 100644
index 0000000..0b4878e
--- /dev/null
+++ b/package/libs/polarssl/patches/.svn/text-base/310-fix_blowfish_key_len.patch.svn-base
@@ -0,0 +1,29 @@
+--- a/library/cipher_wrap.c
++++ b/library/cipher_wrap.c
+@@ -642,7 +642,7 @@ const cipher_base_t blowfish_info = {
+ const cipher_info_t blowfish_cbc_info = {
+ POLARSSL_CIPHER_BLOWFISH_CBC,
+ POLARSSL_MODE_CBC,
+- 32,
++ 128,
+ "BF-CBC",
+ 8,
+ 8,
+@@ -653,7 +653,7 @@ const cipher_info_t blowfish_cbc_info =
+ const cipher_info_t blowfish_cfb64_info = {
+ POLARSSL_CIPHER_BLOWFISH_CFB64,
+ POLARSSL_MODE_CFB,
+- 32,
++ 128,
+ "BF-CFB64",
+ 8,
+ 8,
+@@ -665,7 +665,7 @@ const cipher_info_t blowfish_cfb64_info
+ const cipher_info_t blowfish_ctr_info = {
+ POLARSSL_CIPHER_BLOWFISH_CTR,
+ POLARSSL_MODE_CTR,
+- 32,
++ 128,
+ "BF-CTR",
+ 8,
+ 8,
diff --git a/package/libs/polarssl/patches/100-disable-testsuites.patch b/package/libs/polarssl/patches/100-disable-testsuites.patch
new file mode 100644
index 0000000..cf9485e
--- /dev/null
+++ b/package/libs/polarssl/patches/100-disable-testsuites.patch
@@ -0,0 +1,21 @@
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -38,7 +38,7 @@ add_subdirectory(library)
+ add_subdirectory(include)
+
+ if(CMAKE_COMPILER_IS_GNUCC)
+- add_subdirectory(tests)
++# add_subdirectory(tests)
+ endif(CMAKE_COMPILER_IS_GNUCC)
+
+ add_subdirectory(programs)
+--- a/programs/CMakeLists.txt
++++ b/programs/CMakeLists.txt
+@@ -3,6 +3,6 @@ add_subdirectory(hash)
+ add_subdirectory(pkey)
+ add_subdirectory(random)
+ add_subdirectory(ssl)
+-add_subdirectory(test)
++#add_subdirectory(test)
+ add_subdirectory(x509)
+ add_subdirectory(util)
diff --git a/package/libs/polarssl/patches/200-reduce_config.patch b/package/libs/polarssl/patches/200-reduce_config.patch
new file mode 100644
index 0000000..c66bb3f
--- /dev/null
+++ b/package/libs/polarssl/patches/200-reduce_config.patch
@@ -0,0 +1,112 @@
+--- a/include/polarssl/config.h
++++ b/include/polarssl/config.h
+@@ -177,8 +177,8 @@
+ * Requires: POLARSSL_BIGNUM_C, POLARSSL_RSA_C
+ *
+ * Enable the RSA prime-number generation code.
+- */
+ #define POLARSSL_GENPRIME
++ */
+
+ /**
+ * \def POLARSSL_FS_IO
+@@ -235,8 +235,8 @@
+ * \def POLARSSL_SELF_TEST
+ *
+ * Enable the checkup functions (*_self_test).
+- */
+ #define POLARSSL_SELF_TEST
++ */
+
+ /**
+ * \def POLARSSL_SSL_ALL_ALERT_MESSAGES
+@@ -425,8 +425,8 @@
+ * TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256
+ * TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256
+ * TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256
+- */
+ #define POLARSSL_CAMELLIA_C
++ */
+
+ /**
+ * \def POLARSSL_CERTS_C
+@@ -437,8 +437,8 @@
+ * Caller:
+ *
+ * This module is used for testing (ssl_client/server).
+- */
+ #define POLARSSL_CERTS_C
++ */
+
+ /**
+ * \def POLARSSL_CIPHER_C
+@@ -477,8 +477,8 @@
+ * library/ssl_tls.c
+ *
+ * This module provides debugging functions.
+- */
+ #define POLARSSL_DEBUG_C
++ */
+
+ /**
+ * \def POLARSSL_DES_C
+@@ -560,8 +560,8 @@
+ * enabled as well):
+ * TLS_RSA_WITH_AES_128_GCM_SHA256
+ * TLS_RSA_WITH_AES_256_GCM_SHA384
+- */
+ #define POLARSSL_GCM_C
++ */
+
+ /**
+ * \def POLARSSL_HAVEGE_C
+@@ -574,8 +574,8 @@
+ * Requires: POLARSSL_TIMING_C
+ *
+ * This module enables the HAVEGE random number generator.
+- */
+ #define POLARSSL_HAVEGE_C
++ */
+
+ /**
+ * \def POLARSSL_MD_C
+@@ -649,8 +649,8 @@
+ * Caller: library/aes.c
+ *
+ * This modules adds support for the VIA PadLock on x86.
+- */
+ #define POLARSSL_PADLOCK_C
++ */
+
+ /**
+ * \def POLARSSL_PBKDF2_C
+@@ -763,8 +763,8 @@
+ * Caller:
+ *
+ * Requires: POLARSSL_SSL_CACHE_C
+- */
+ #define POLARSSL_SSL_CACHE_C
++ */
+
+ /**
+ * \def POLARSSL_SSL_CLI_C
+@@ -818,8 +818,8 @@
+ * Caller: library/havege.c
+ *
+ * This module is used by the HAVEGE random number generator.
+- */
+ #define POLARSSL_TIMING_C
++ */
+
+ /**
+ * \def POLARSSL_VERSION_C
+@@ -868,8 +868,8 @@
+ *
+ * Module: library/xtea.c
+ * Caller:
+- */
+ #define POLARSSL_XTEA_C
++ */
+ /* \} name */
+
+ #endif /* config.h */
diff --git a/package/libs/polarssl/patches/300-openssl_cipher_name_compat.patch b/package/libs/polarssl/patches/300-openssl_cipher_name_compat.patch
new file mode 100644
index 0000000..6ca43c3
--- /dev/null
+++ b/package/libs/polarssl/patches/300-openssl_cipher_name_compat.patch
@@ -0,0 +1,53 @@
+--- a/library/cipher.c
++++ b/library/cipher.c
+@@ -279,15 +279,21 @@ const cipher_info_t *cipher_info_from_st
+ #if defined(POLARSSL_BLOWFISH_C)
+ if( !strcasecmp( "BLOWFISH-CBC", cipher_name ) )
+ return cipher_info_from_type( POLARSSL_CIPHER_BLOWFISH_CBC );
++ if( !strcasecmp( "BF-CBC", cipher_name ) )
++ return cipher_info_from_type( POLARSSL_CIPHER_BLOWFISH_CBC );
+
+ #if defined(POLARSSL_CIPHER_MODE_CFB)
+ if( !strcasecmp( "BLOWFISH-CFB64", cipher_name ) )
+ return cipher_info_from_type( POLARSSL_CIPHER_BLOWFISH_CFB64 );
++ if( !strcasecmp( "BF-CFB64", cipher_name ) )
++ return cipher_info_from_type( POLARSSL_CIPHER_BLOWFISH_CFB64 );
+ #endif /* defined(POLARSSL_CIPHER_MODE_CFB) */
+
+ #if defined(POLARSSL_CIPHER_MODE_CTR)
+ if( !strcasecmp( "BLOWFISH-CTR", cipher_name ) )
+ return cipher_info_from_type( POLARSSL_CIPHER_BLOWFISH_CTR );
++ if( !strcasecmp( "BF-CTR", cipher_name ) )
++ return cipher_info_from_type( POLARSSL_CIPHER_BLOWFISH_CTR );
+ #endif /* defined(POLARSSL_CIPHER_MODE_CTR) */
+ #endif
+
+--- a/library/cipher_wrap.c
++++ b/library/cipher_wrap.c
+@@ -643,7 +643,7 @@ const cipher_info_t blowfish_cbc_info =
+ POLARSSL_CIPHER_BLOWFISH_CBC,
+ POLARSSL_MODE_CBC,
+ 32,
+- "BLOWFISH-CBC",
++ "BF-CBC",
+ 8,
+ 8,
+ &blowfish_info
+@@ -654,7 +654,7 @@ const cipher_info_t blowfish_cfb64_info
+ POLARSSL_CIPHER_BLOWFISH_CFB64,
+ POLARSSL_MODE_CFB,
+ 32,
+- "BLOWFISH-CFB64",
++ "BF-CFB64",
+ 8,
+ 8,
+ &blowfish_info
+@@ -666,7 +666,7 @@ const cipher_info_t blowfish_ctr_info =
+ POLARSSL_CIPHER_BLOWFISH_CTR,
+ POLARSSL_MODE_CTR,
+ 32,
+- "BLOWFISH-CTR",
++ "BF-CTR",
+ 8,
+ 8,
+ &blowfish_info
diff --git a/package/libs/polarssl/patches/310-fix_blowfish_key_len.patch b/package/libs/polarssl/patches/310-fix_blowfish_key_len.patch
new file mode 100644
index 0000000..0b4878e
--- /dev/null
+++ b/package/libs/polarssl/patches/310-fix_blowfish_key_len.patch
@@ -0,0 +1,29 @@
+--- a/library/cipher_wrap.c
++++ b/library/cipher_wrap.c
+@@ -642,7 +642,7 @@ const cipher_base_t blowfish_info = {
+ const cipher_info_t blowfish_cbc_info = {
+ POLARSSL_CIPHER_BLOWFISH_CBC,
+ POLARSSL_MODE_CBC,
+- 32,
++ 128,
+ "BF-CBC",
+ 8,
+ 8,
+@@ -653,7 +653,7 @@ const cipher_info_t blowfish_cbc_info =
+ const cipher_info_t blowfish_cfb64_info = {
+ POLARSSL_CIPHER_BLOWFISH_CFB64,
+ POLARSSL_MODE_CFB,
+- 32,
++ 128,
+ "BF-CFB64",
+ 8,
+ 8,
+@@ -665,7 +665,7 @@ const cipher_info_t blowfish_cfb64_info
+ const cipher_info_t blowfish_ctr_info = {
+ POLARSSL_CIPHER_BLOWFISH_CTR,
+ POLARSSL_MODE_CTR,
+- 32,
++ 128,
+ "BF-CTR",
+ 8,
+ 8,
diff --git a/package/libs/popt/.svn/entries b/package/libs/popt/.svn/entries
new file mode 100644
index 0000000..ef0e2c9
--- /dev/null
+++ b/package/libs/popt/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs/popt
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-10T13:26:27.622493Z
+33705
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+3b43d1e057fa5702952029e94747c2f5
+2012-06-11T21:18:33.553794Z
+32206
+jow
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1330
+
diff --git a/package/libs/popt/.svn/prop-base/Makefile.svn-base b/package/libs/popt/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..f899379
--- /dev/null
+++ b/package/libs/popt/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,13 @@
+K 9
+copyright
+V 30
+Copyright (C) 2006 OpenWrt.org
+K 7
+licence
+V 5
+GPLv2
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/libs/popt/.svn/text-base/Makefile.svn-base b/package/libs/popt/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..1cdcc40
--- /dev/null
+++ b/package/libs/popt/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,59 @@
+#
+# Copyright (C) 2006-2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=popt
+PKG_VERSION:=1.7
+PKG_RELEASE:=5
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://downloads.openwrt.org/sources/
+PKG_MD5SUM:=5988e7aeb0ae4dac8d83561265984cc9
+
+PKG_FIXUP:=autoreconf
+PKG_REMOVE_FILES:=autogen.sh aclocal.m4
+
+PKG_INSTALL:=1
+PKG_BUILD_PARALLEL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+TARGET_CFLAGS += $(FPIC)
+
+define Package/libpopt
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=A command line option parsing library
+ URL:=http://rpm5.org/files/popt/
+endef
+
+define Build/Configure
+ $(call Build/Configure/Default, \
+ --enable-shared \
+ --enable-static \
+ )
+endef
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include
+ $(CP) $(PKG_INSTALL_DIR)/usr/include/popt.h $(1)/usr/include/
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpopt.{a,so*} $(1)/usr/lib/
+endef
+
+define Package/libpopt/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpopt.so.* $(1)/usr/lib/
+endef
+
+$(eval $(call RequireCommand,xgettext, \
+ $(PKG_NAME) requires the GNU gettext development package installed on the local system to build. \
+))
+
+$(eval $(call BuildPackage,libpopt))
+
diff --git a/package/libs/popt/Makefile b/package/libs/popt/Makefile
new file mode 100644
index 0000000..1cdcc40
--- /dev/null
+++ b/package/libs/popt/Makefile
@@ -0,0 +1,59 @@
+#
+# Copyright (C) 2006-2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=popt
+PKG_VERSION:=1.7
+PKG_RELEASE:=5
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://downloads.openwrt.org/sources/
+PKG_MD5SUM:=5988e7aeb0ae4dac8d83561265984cc9
+
+PKG_FIXUP:=autoreconf
+PKG_REMOVE_FILES:=autogen.sh aclocal.m4
+
+PKG_INSTALL:=1
+PKG_BUILD_PARALLEL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+TARGET_CFLAGS += $(FPIC)
+
+define Package/libpopt
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=A command line option parsing library
+ URL:=http://rpm5.org/files/popt/
+endef
+
+define Build/Configure
+ $(call Build/Configure/Default, \
+ --enable-shared \
+ --enable-static \
+ )
+endef
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include
+ $(CP) $(PKG_INSTALL_DIR)/usr/include/popt.h $(1)/usr/include/
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpopt.{a,so*} $(1)/usr/lib/
+endef
+
+define Package/libpopt/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpopt.so.* $(1)/usr/lib/
+endef
+
+$(eval $(call RequireCommand,xgettext, \
+ $(PKG_NAME) requires the GNU gettext development package installed on the local system to build. \
+))
+
+$(eval $(call BuildPackage,libpopt))
+
diff --git a/package/libs/popt/patches/.svn/entries b/package/libs/popt/patches/.svn/entries
new file mode 100644
index 0000000..85bda16
--- /dev/null
+++ b/package/libs/popt/patches/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs/popt/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2010-12-22T01:24:34.004655Z
+24764
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+002-no-intl.patch
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+7cc30073c9116a66ac8056491ffe00f8
+2010-12-11T18:42:27.203759Z
+24491
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2391
+
diff --git a/package/libs/popt/patches/.svn/text-base/002-no-intl.patch.svn-base b/package/libs/popt/patches/.svn/text-base/002-no-intl.patch.svn-base
new file mode 100644
index 0000000..2f9a4e0
--- /dev/null
+++ b/package/libs/popt/patches/.svn/text-base/002-no-intl.patch.svn-base
@@ -0,0 +1,81 @@
+--- a/configure.in
++++ b/configure.in
+@@ -64,25 +64,14 @@ else
+ AC_MSG_RESULT(no)
+ fi
+
+-if test ! -f ../rpm.c
+-then
+- AC_MSG_CHECKING(for GNU xgettext)
+- xgettext --version 2>&1 | grep 'GNU gettext' >/dev/null 2>&1 || AC_MSG_ERROR([
+- *** GNU gettext is required. The latest version
+- *** is always available from ftp://ftp.gnu.org/gnu/gettext/.])
+- AC_MSG_RESULT(yes)
+-fi
+-
+ AC_CHECK_FUNCS(strerror mtrace getuid geteuid)
+ AC_CHECK_FUNC(setreuid, [], [
+ AC_CHECK_LIB(ucb, setreuid, [if echo $LIBS | grep -- -lucb >/dev/null ;then :; else LIBS="$LIBS -lc -lucb" USEUCB=y;fi])
+ ])
+
+-AM_GNU_GETTEXT
+-
+ POPT_SOURCE_PATH="`pwd`"
+ AC_DEFINE_UNQUOTED(POPT_SOURCE_PATH, "$POPT_SOURCE_PATH",
+ [Full path to popt top_sourcedir.])
+ AC_SUBST(POPT_SOURCE_PATH)
+
+-AC_OUTPUT([Doxyfile Makefile intl/Makefile po/Makefile.in])
++AC_OUTPUT([Doxyfile Makefile])
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -4,10 +4,9 @@ AUTOMAKE_OPTIONS = 1.4 foreign
+
+ EXTRA_DIST = autogen.sh CHANGES $(man_MANS) popt.spec \
+ testit.sh test-poptrc \
+- po/*.in po/*.po po/popt.pot \
+ popt.ps
+
+-SUBDIRS = intl po
++SUBDIRS =
+
+ INCLUDES = -I. -I$(top_srcdir)
+
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -124,7 +124,7 @@ EXTRA_DIST = autogen.sh CHANGES $(man_MA
+ popt.ps
+
+
+-SUBDIRS = intl po
++SUBDIRS =
+
+ INCLUDES = -I. -I$(top_srcdir)
+
+@@ -160,7 +160,7 @@ subdir = .
+ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+ mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+ CONFIG_HEADER = config.h
+-CONFIG_CLEAN_FILES = Doxyfile intl/Makefile
++CONFIG_CLEAN_FILES = Doxyfile
+ LTLIBRARIES = $(lib_LTLIBRARIES)
+
+ libpopt_la_LDFLAGS =
+@@ -261,8 +261,6 @@ distclean-hdr:
+ -rm -f config.h stamp-h1
+ Doxyfile: $(top_builddir)/config.status Doxyfile.in
+ cd $(top_builddir) && $(SHELL) ./config.status $@
+-intl/Makefile: $(top_builddir)/config.status $(top_srcdir)/intl/Makefile.in
+- cd $(top_builddir) && $(SHELL) ./config.status $@
+ libLTLIBRARIES_INSTALL = $(INSTALL)
+ install-libLTLIBRARIES: $(lib_LTLIBRARIES)
+ @$(NORMAL_INSTALL)
+@@ -584,7 +582,7 @@ distcleancheck_listfiles = find . -type
+ distdir: $(DISTFILES)
+ $(am__remove_distdir)
+ mkdir $(distdir)
+- $(mkinstalldirs) $(distdir)/. $(distdir)/intl $(distdir)/po
++ $(mkinstalldirs) $(distdir)/.
+ @list='$(DISTFILES)'; for file in $$list; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
diff --git a/package/libs/popt/patches/002-no-intl.patch b/package/libs/popt/patches/002-no-intl.patch
new file mode 100644
index 0000000..2f9a4e0
--- /dev/null
+++ b/package/libs/popt/patches/002-no-intl.patch
@@ -0,0 +1,81 @@
+--- a/configure.in
++++ b/configure.in
+@@ -64,25 +64,14 @@ else
+ AC_MSG_RESULT(no)
+ fi
+
+-if test ! -f ../rpm.c
+-then
+- AC_MSG_CHECKING(for GNU xgettext)
+- xgettext --version 2>&1 | grep 'GNU gettext' >/dev/null 2>&1 || AC_MSG_ERROR([
+- *** GNU gettext is required. The latest version
+- *** is always available from ftp://ftp.gnu.org/gnu/gettext/.])
+- AC_MSG_RESULT(yes)
+-fi
+-
+ AC_CHECK_FUNCS(strerror mtrace getuid geteuid)
+ AC_CHECK_FUNC(setreuid, [], [
+ AC_CHECK_LIB(ucb, setreuid, [if echo $LIBS | grep -- -lucb >/dev/null ;then :; else LIBS="$LIBS -lc -lucb" USEUCB=y;fi])
+ ])
+
+-AM_GNU_GETTEXT
+-
+ POPT_SOURCE_PATH="`pwd`"
+ AC_DEFINE_UNQUOTED(POPT_SOURCE_PATH, "$POPT_SOURCE_PATH",
+ [Full path to popt top_sourcedir.])
+ AC_SUBST(POPT_SOURCE_PATH)
+
+-AC_OUTPUT([Doxyfile Makefile intl/Makefile po/Makefile.in])
++AC_OUTPUT([Doxyfile Makefile])
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -4,10 +4,9 @@ AUTOMAKE_OPTIONS = 1.4 foreign
+
+ EXTRA_DIST = autogen.sh CHANGES $(man_MANS) popt.spec \
+ testit.sh test-poptrc \
+- po/*.in po/*.po po/popt.pot \
+ popt.ps
+
+-SUBDIRS = intl po
++SUBDIRS =
+
+ INCLUDES = -I. -I$(top_srcdir)
+
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -124,7 +124,7 @@ EXTRA_DIST = autogen.sh CHANGES $(man_MA
+ popt.ps
+
+
+-SUBDIRS = intl po
++SUBDIRS =
+
+ INCLUDES = -I. -I$(top_srcdir)
+
+@@ -160,7 +160,7 @@ subdir = .
+ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+ mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+ CONFIG_HEADER = config.h
+-CONFIG_CLEAN_FILES = Doxyfile intl/Makefile
++CONFIG_CLEAN_FILES = Doxyfile
+ LTLIBRARIES = $(lib_LTLIBRARIES)
+
+ libpopt_la_LDFLAGS =
+@@ -261,8 +261,6 @@ distclean-hdr:
+ -rm -f config.h stamp-h1
+ Doxyfile: $(top_builddir)/config.status Doxyfile.in
+ cd $(top_builddir) && $(SHELL) ./config.status $@
+-intl/Makefile: $(top_builddir)/config.status $(top_srcdir)/intl/Makefile.in
+- cd $(top_builddir) && $(SHELL) ./config.status $@
+ libLTLIBRARIES_INSTALL = $(INSTALL)
+ install-libLTLIBRARIES: $(lib_LTLIBRARIES)
+ @$(NORMAL_INSTALL)
+@@ -584,7 +582,7 @@ distcleancheck_listfiles = find . -type
+ distdir: $(DISTFILES)
+ $(am__remove_distdir)
+ mkdir $(distdir)
+- $(mkinstalldirs) $(distdir)/. $(distdir)/intl $(distdir)/po
++ $(mkinstalldirs) $(distdir)/.
+ @list='$(DISTFILES)'; for file in $$list; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
diff --git a/package/libs/sysfsutils/.svn/entries b/package/libs/sysfsutils/.svn/entries
new file mode 100644
index 0000000..eb4bc17
--- /dev/null
+++ b/package/libs/sysfsutils/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs/sysfsutils
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-19T15:34:28.915431Z
+33861
+hcg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:06.000000Z
+dfc2c67d2b21e16bb0e5a7123d8ba0d2
+2012-10-19T15:34:28.915431Z
+33861
+hcg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1800
+
diff --git a/package/libs/sysfsutils/.svn/text-base/Makefile.svn-base b/package/libs/sysfsutils/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..09bf528
--- /dev/null
+++ b/package/libs/sysfsutils/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,73 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=sysfsutils
+PKG_VERSION:=2.1.0
+PKG_RELEASE:=2
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=@SF/linux-diag
+PKG_MD5SUM:=14e7dcd0436d2f49aa403f67e1ef7ddc
+PKG_MAINTAINER:=Jo-Philipp Wich <jow@openwrt.org>
+
+PKG_LICENSE:=GPLv2 LGPLv2.1
+PKG_LICENSE_FILES:=COPYING cmd/GPL lib/LGPL
+
+PKG_FIXUP:=autoreconf
+
+PKG_INSTALL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/libsysfs
+ SECTION:=libs
+ CATEGORY:=Libraries
+ SUBMENU:=Filesystem
+ TITLE:=Sysfs library
+ URL:=http://linux-diag.sourceforge.net/Sysfsutils.html
+endef
+
+define Package/sysfsutils
+ SECTION:=utils
+ CATEGORY:=Utilities
+ SUBMENU:=Filesystem
+ DEPENDS:=+libsysfs
+ TITLE:=System Utilities Based on Sysfs
+ URL:=http://linux-diag.sourceforge.net/Sysfsutils.html
+endef
+
+define Package/libsysfs/description
+The library's purpose is to provide a consistant and stable interface for
+querying system device information exposed through sysfs.
+endef
+
+define Package/sysfsutils/description
+A utility built upon libsysfs that lists devices by bus, class, and topology.
+endef
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include
+ $(CP) $(PKG_INSTALL_DIR)/usr/include/sysfs $(1)/usr/include/
+
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libsysfs.{a,so*,la} $(1)/usr/lib/
+endef
+
+define Package/libsysfs/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libsysfs.so* $(1)/usr/lib/
+endef
+
+define Package/sysfsutils/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(CP) $(PKG_INSTALL_DIR)/usr/bin/systool $(1)/usr/bin/
+endef
+
+$(eval $(call BuildPackage,libsysfs))
+$(eval $(call BuildPackage,sysfsutils))
diff --git a/package/libs/sysfsutils/Makefile b/package/libs/sysfsutils/Makefile
new file mode 100644
index 0000000..09bf528
--- /dev/null
+++ b/package/libs/sysfsutils/Makefile
@@ -0,0 +1,73 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=sysfsutils
+PKG_VERSION:=2.1.0
+PKG_RELEASE:=2
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=@SF/linux-diag
+PKG_MD5SUM:=14e7dcd0436d2f49aa403f67e1ef7ddc
+PKG_MAINTAINER:=Jo-Philipp Wich <jow@openwrt.org>
+
+PKG_LICENSE:=GPLv2 LGPLv2.1
+PKG_LICENSE_FILES:=COPYING cmd/GPL lib/LGPL
+
+PKG_FIXUP:=autoreconf
+
+PKG_INSTALL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/libsysfs
+ SECTION:=libs
+ CATEGORY:=Libraries
+ SUBMENU:=Filesystem
+ TITLE:=Sysfs library
+ URL:=http://linux-diag.sourceforge.net/Sysfsutils.html
+endef
+
+define Package/sysfsutils
+ SECTION:=utils
+ CATEGORY:=Utilities
+ SUBMENU:=Filesystem
+ DEPENDS:=+libsysfs
+ TITLE:=System Utilities Based on Sysfs
+ URL:=http://linux-diag.sourceforge.net/Sysfsutils.html
+endef
+
+define Package/libsysfs/description
+The library's purpose is to provide a consistant and stable interface for
+querying system device information exposed through sysfs.
+endef
+
+define Package/sysfsutils/description
+A utility built upon libsysfs that lists devices by bus, class, and topology.
+endef
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include
+ $(CP) $(PKG_INSTALL_DIR)/usr/include/sysfs $(1)/usr/include/
+
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libsysfs.{a,so*,la} $(1)/usr/lib/
+endef
+
+define Package/libsysfs/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libsysfs.so* $(1)/usr/lib/
+endef
+
+define Package/sysfsutils/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(CP) $(PKG_INSTALL_DIR)/usr/bin/systool $(1)/usr/bin/
+endef
+
+$(eval $(call BuildPackage,libsysfs))
+$(eval $(call BuildPackage,sysfsutils))
diff --git a/package/libs/sysfsutils/patches/.svn/entries b/package/libs/sysfsutils/patches/.svn/entries
new file mode 100644
index 0000000..3c42643
--- /dev/null
+++ b/package/libs/sysfsutils/patches/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs/sysfsutils/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2010-02-27T08:22:13.277208Z
+19881
+spudz76
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+200-mnt_path_check.patch
+file
+
+
+
+
+2013-03-17T12:13:06.000000Z
+7961a1b78c29a67dd145103f222576f1
+2010-02-27T08:22:13.277208Z
+19881
+spudz76
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1245
+
diff --git a/package/libs/sysfsutils/patches/.svn/text-base/200-mnt_path_check.patch.svn-base b/package/libs/sysfsutils/patches/.svn/text-base/200-mnt_path_check.patch.svn-base
new file mode 100644
index 0000000..8710578
--- /dev/null
+++ b/package/libs/sysfsutils/patches/.svn/text-base/200-mnt_path_check.patch.svn-base
@@ -0,0 +1,55 @@
+--- a/lib/sysfs_utils.c
++++ b/lib/sysfs_utils.c
+@@ -22,6 +22,7 @@
+ */
+ #include "libsysfs.h"
+ #include "sysfs.h"
++#include <mntent.h>
+
+ /**
+ * sysfs_remove_trailing_slash: Removes any trailing '/' in the given path
+@@ -53,6 +54,9 @@ int sysfs_get_mnt_path(char *mnt_path, s
+ {
+ static char sysfs_path[SYSFS_PATH_MAX] = "";
+ const char *sysfs_path_env;
++ FILE *mnt;
++ struct mntent *mntent;
++ int ret;
+
+ if (len == 0 || mnt_path == NULL)
+ return -1;
+@@ -64,12 +68,31 @@ int sysfs_get_mnt_path(char *mnt_path, s
+ if (sysfs_path_env != NULL) {
+ safestrcpymax(mnt_path, sysfs_path_env, len);
+ sysfs_remove_trailing_slash(mnt_path);
+- return 0;
++ } else {
++ safestrcpymax(mnt_path, SYSFS_MNT_PATH, len);
+ }
+- safestrcpymax(mnt_path, SYSFS_MNT_PATH, len);
+ }
+
+- return 0;
++ /* check that mount point is indeed mounted */
++ ret = -1;
++ if ((mnt = setmntent(SYSFS_PROC_MNTS, "r")) == NULL) {
++ dprintf("Error getting mount information\n");
++ return -1;
++ }
++ while ((mntent = getmntent(mnt)) != NULL) {
++ if (strcmp(mntent->mnt_type, SYSFS_FSTYPE_NAME) == 0 &&
++ strcmp(mntent->mnt_dir, mnt_path) == 0) {
++ ret = 0;
++ break;
++ }
++ }
++
++ endmntent(mnt);
++
++ if (ret < 0)
++ errno = ENOENT;
++
++ return ret;
+ }
+
+ /**
diff --git a/package/libs/sysfsutils/patches/200-mnt_path_check.patch b/package/libs/sysfsutils/patches/200-mnt_path_check.patch
new file mode 100644
index 0000000..8710578
--- /dev/null
+++ b/package/libs/sysfsutils/patches/200-mnt_path_check.patch
@@ -0,0 +1,55 @@
+--- a/lib/sysfs_utils.c
++++ b/lib/sysfs_utils.c
+@@ -22,6 +22,7 @@
+ */
+ #include "libsysfs.h"
+ #include "sysfs.h"
++#include <mntent.h>
+
+ /**
+ * sysfs_remove_trailing_slash: Removes any trailing '/' in the given path
+@@ -53,6 +54,9 @@ int sysfs_get_mnt_path(char *mnt_path, s
+ {
+ static char sysfs_path[SYSFS_PATH_MAX] = "";
+ const char *sysfs_path_env;
++ FILE *mnt;
++ struct mntent *mntent;
++ int ret;
+
+ if (len == 0 || mnt_path == NULL)
+ return -1;
+@@ -64,12 +68,31 @@ int sysfs_get_mnt_path(char *mnt_path, s
+ if (sysfs_path_env != NULL) {
+ safestrcpymax(mnt_path, sysfs_path_env, len);
+ sysfs_remove_trailing_slash(mnt_path);
+- return 0;
++ } else {
++ safestrcpymax(mnt_path, SYSFS_MNT_PATH, len);
+ }
+- safestrcpymax(mnt_path, SYSFS_MNT_PATH, len);
+ }
+
+- return 0;
++ /* check that mount point is indeed mounted */
++ ret = -1;
++ if ((mnt = setmntent(SYSFS_PROC_MNTS, "r")) == NULL) {
++ dprintf("Error getting mount information\n");
++ return -1;
++ }
++ while ((mntent = getmntent(mnt)) != NULL) {
++ if (strcmp(mntent->mnt_type, SYSFS_FSTYPE_NAME) == 0 &&
++ strcmp(mntent->mnt_dir, mnt_path) == 0) {
++ ret = 0;
++ break;
++ }
++ }
++
++ endmntent(mnt);
++
++ if (ret < 0)
++ errno = ENOENT;
++
++ return ret;
+ }
+
+ /**
diff --git a/package/libs/uclibc++/.svn/entries b/package/libs/uclibc++/.svn/entries
new file mode 100644
index 0000000..6142fad
--- /dev/null
+++ b/package/libs/uclibc++/.svn/entries
@@ -0,0 +1,68 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs/uclibc++
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-24T13:05:18.979715Z
+33910
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+files
+dir
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+23b32a82772c48f890cd6e6e8ee6a64c
+2012-10-24T13:05:18.979715Z
+33910
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2624
+
diff --git a/package/libs/uclibc++/.svn/text-base/Makefile.svn-base b/package/libs/uclibc++/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..2dd8f65
--- /dev/null
+++ b/package/libs/uclibc++/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,92 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=uclibc++
+PKG_VERSION:=0.2.4
+PKG_RELEASE:=1
+
+PKG_SOURCE:=uClibc++-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=http://cxx.uclibc.org/src/
+PKG_MD5SUM:=394c119363dd8b469fb898442a6764b8
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/uClibc++-$(PKG_VERSION)
+PKG_BUILD_PARALLEL:=1
+
+PKG_INSTALL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/uclibcxx
+ NAME:=uclibc++
+ SECTION:=libs
+ CATEGORY:=Libraries
+ DEPENDS:=@INSTALL_LIBSTDCPP
+ TITLE:=C++ library for embedded systems
+ URL:=http://cxx.uclibc.org/src/
+endef
+
+UCLIBC_TARGET_ARCH:=$(shell echo $(ARCH) | sed -e s'/-.*//' \
+ -e 's/i.86/i386/' \
+ -e 's/sparc.*/sparc/' \
+ -e 's/m68k.*/m68k/' \
+ -e 's/ppc/powerpc/g' \
+ -e 's/v850.*/v850/g' \
+ -e 's/sh64/sh/' \
+ -e 's/sh[234].*/sh/' \
+ -e 's/mips.*/mips/' \
+ -e 's/mipsel.*/mips/' \
+ -e 's/cris.*/cris/' \
+)
+
+TARGET_CFLAGS += $(FPIC)
+
+ifneq ($(CONFIG_CCACHE),)
+TARGET_CXX=$(TARGET_CXX_NOCACHE)
+endif
+
+MAKE_FLAGS:= \
+ TOPDIR="$(PKG_BUILD_DIR)/" \
+ $(TARGET_CONFIGURE_OPTS) \
+ CPU_CFLAGS="$(TARGET_CFLAGS)" \
+ CROSS="$(TARGET_CROSS)" \
+ CP="$(CP)" \
+ GEN_LIBS="-lc $(LIBGCC_S)" \
+ check_as_needed=
+
+# check_as_needed overrides dependency on libgcc_s
+
+define Build/Configure
+ if [ -f ./files/config.$(UCLIBC_TARGET_ARCH) ]; then \
+ cp ./files/config.$(UCLIBC_TARGET_ARCH) $(PKG_BUILD_DIR)/.config; \
+ else \
+ cp ./files/config.default $(PKG_BUILD_DIR)/.config; \
+ fi
+endef
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(2)/bin $(1)/usr/include/uClibc++ $(1)/usr/lib
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/bin/g++-uc $(TOOLCHAIN_DIR)/bin/
+ $(CP) $(PKG_INSTALL_DIR)/include/* $(1)/usr/include/uClibc++/
+ $(CP) $(PKG_INSTALL_DIR)/lib/libuClibc++*.{a,so}* $(1)/usr/lib/
+ $(SED) 's|-I/include/|-I$(STAGING_DIR)/usr/include/uClibc++/|g' $(TOOLCHAIN_DIR)/bin/g++-uc
+ $(SED) 's|-L/lib/|-L$(STAGING_DIR)/usr/lib/|g' $(TOOLCHAIN_DIR)/bin/g++-uc
+# add another wrapper which links against both uClibc++ and libstdc++
+ $(INSTALL_BIN) $(TOOLCHAIN_DIR)/bin/g++-uc $(TOOLCHAIN_DIR)/bin/g++-uc+std
+ $(SED) 's|^WRAPPER_INCLUDEDIR=.*||g' $(TOOLCHAIN_DIR)/bin/g++-uc+std
+ $(SED) 's|-luClibc++|-Wl,-Bdynamic,-luClibc++,-Bstatic,-lstdc++,-Bdynamic|g' $(TOOLCHAIN_DIR)/bin/g++-uc+std
+ $(SED) 's|-nostdinc++||g' $(TOOLCHAIN_DIR)/bin/g++-uc+std
+endef
+
+define Package/uclibcxx/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/lib/libuClibc++.so.* $(1)/usr/lib/
+ $(CP) $(PKG_INSTALL_DIR)/lib/libuClibc++-*.so $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,uclibcxx))
diff --git a/package/libs/uclibc++/Makefile b/package/libs/uclibc++/Makefile
new file mode 100644
index 0000000..2dd8f65
--- /dev/null
+++ b/package/libs/uclibc++/Makefile
@@ -0,0 +1,92 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=uclibc++
+PKG_VERSION:=0.2.4
+PKG_RELEASE:=1
+
+PKG_SOURCE:=uClibc++-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=http://cxx.uclibc.org/src/
+PKG_MD5SUM:=394c119363dd8b469fb898442a6764b8
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/uClibc++-$(PKG_VERSION)
+PKG_BUILD_PARALLEL:=1
+
+PKG_INSTALL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/uclibcxx
+ NAME:=uclibc++
+ SECTION:=libs
+ CATEGORY:=Libraries
+ DEPENDS:=@INSTALL_LIBSTDCPP
+ TITLE:=C++ library for embedded systems
+ URL:=http://cxx.uclibc.org/src/
+endef
+
+UCLIBC_TARGET_ARCH:=$(shell echo $(ARCH) | sed -e s'/-.*//' \
+ -e 's/i.86/i386/' \
+ -e 's/sparc.*/sparc/' \
+ -e 's/m68k.*/m68k/' \
+ -e 's/ppc/powerpc/g' \
+ -e 's/v850.*/v850/g' \
+ -e 's/sh64/sh/' \
+ -e 's/sh[234].*/sh/' \
+ -e 's/mips.*/mips/' \
+ -e 's/mipsel.*/mips/' \
+ -e 's/cris.*/cris/' \
+)
+
+TARGET_CFLAGS += $(FPIC)
+
+ifneq ($(CONFIG_CCACHE),)
+TARGET_CXX=$(TARGET_CXX_NOCACHE)
+endif
+
+MAKE_FLAGS:= \
+ TOPDIR="$(PKG_BUILD_DIR)/" \
+ $(TARGET_CONFIGURE_OPTS) \
+ CPU_CFLAGS="$(TARGET_CFLAGS)" \
+ CROSS="$(TARGET_CROSS)" \
+ CP="$(CP)" \
+ GEN_LIBS="-lc $(LIBGCC_S)" \
+ check_as_needed=
+
+# check_as_needed overrides dependency on libgcc_s
+
+define Build/Configure
+ if [ -f ./files/config.$(UCLIBC_TARGET_ARCH) ]; then \
+ cp ./files/config.$(UCLIBC_TARGET_ARCH) $(PKG_BUILD_DIR)/.config; \
+ else \
+ cp ./files/config.default $(PKG_BUILD_DIR)/.config; \
+ fi
+endef
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(2)/bin $(1)/usr/include/uClibc++ $(1)/usr/lib
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/bin/g++-uc $(TOOLCHAIN_DIR)/bin/
+ $(CP) $(PKG_INSTALL_DIR)/include/* $(1)/usr/include/uClibc++/
+ $(CP) $(PKG_INSTALL_DIR)/lib/libuClibc++*.{a,so}* $(1)/usr/lib/
+ $(SED) 's|-I/include/|-I$(STAGING_DIR)/usr/include/uClibc++/|g' $(TOOLCHAIN_DIR)/bin/g++-uc
+ $(SED) 's|-L/lib/|-L$(STAGING_DIR)/usr/lib/|g' $(TOOLCHAIN_DIR)/bin/g++-uc
+# add another wrapper which links against both uClibc++ and libstdc++
+ $(INSTALL_BIN) $(TOOLCHAIN_DIR)/bin/g++-uc $(TOOLCHAIN_DIR)/bin/g++-uc+std
+ $(SED) 's|^WRAPPER_INCLUDEDIR=.*||g' $(TOOLCHAIN_DIR)/bin/g++-uc+std
+ $(SED) 's|-luClibc++|-Wl,-Bdynamic,-luClibc++,-Bstatic,-lstdc++,-Bdynamic|g' $(TOOLCHAIN_DIR)/bin/g++-uc+std
+ $(SED) 's|-nostdinc++||g' $(TOOLCHAIN_DIR)/bin/g++-uc+std
+endef
+
+define Package/uclibcxx/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/lib/libuClibc++.so.* $(1)/usr/lib/
+ $(CP) $(PKG_INSTALL_DIR)/lib/libuClibc++-*.so $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,uclibcxx))
diff --git a/package/libs/uclibc++/files/.svn/entries b/package/libs/uclibc++/files/.svn/entries
new file mode 100644
index 0000000..0d4db80
--- /dev/null
+++ b/package/libs/uclibc++/files/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs/uclibc++/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+config.default
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+5f1e66bfe55125a146c33f762f396ac2
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1261
+
diff --git a/package/libs/uclibc++/files/.svn/text-base/config.default.svn-base b/package/libs/uclibc++/files/.svn/text-base/config.default.svn-base
new file mode 100644
index 0000000..944e1a6
--- /dev/null
+++ b/package/libs/uclibc++/files/.svn/text-base/config.default.svn-base
@@ -0,0 +1,58 @@
+#
+# Automatically generated make config: don't edit
+#
+
+#
+# Target Features and Options
+#
+UCLIBCXX_HAS_FLOATS=y
+# UCLIBCXX_HAS_LONG_DOUBLE is not set
+# UCLIBCXX_HAS_TLS is not set
+WARNINGS="-Wall"
+BUILD_EXTRA_LIBRARIES=""
+HAVE_DOT_CONFIG=y
+
+#
+# String and I/O Stream Support
+#
+UCLIBCXX_HAS_WCHAR=y
+UCLIBCXX_IOSTREAM_BUFSIZE=32
+UCLIBCXX_HAS_LFS=y
+UCLIBCXX_SUPPORT_CDIR=y
+UCLIBCXX_SUPPORT_CIN=y
+UCLIBCXX_SUPPORT_COUT=y
+UCLIBCXX_SUPPORT_CERR=y
+UCLIBCXX_SUPPORT_CLOG=y
+UCLIBCXX_SUPPORT_WCIN=y
+UCLIBCXX_SUPPORT_WCOUT=y
+UCLIBCXX_SUPPORT_WCERR=y
+UCLIBCXX_SUPPORT_WCLOG=y
+
+#
+# STL and Code Expansion
+#
+UCLIBCXX_STL_BUFFER_SIZE=32
+UCLIBCXX_CODE_EXPANSION=y
+UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS=y
+UCLIBCXX_EXPAND_STRING_CHAR=y
+UCLIBCXX_EXPAND_VECTOR_BASIC=y
+UCLIBCXX_EXPAND_IOS_CHAR=y
+UCLIBCXX_EXPAND_STREAMBUF_CHAR=y
+UCLIBCXX_EXPAND_ISTREAM_CHAR=y
+UCLIBCXX_EXPAND_OSTREAM_CHAR=y
+UCLIBCXX_EXPAND_FSTREAM_CHAR=y
+UCLIBCXX_EXPAND_SSTREAM_CHAR=y
+
+#
+# Library Installation Options
+#
+UCLIBCXX_RUNTIME_PREFIX=""
+UCLIBCXX_RUNTIME_INCLUDE_SUBDIR="/include"
+UCLIBCXX_RUNTIME_LIB_SUBDIR="/lib"
+UCLIBCXX_RUNTIME_BIN_SUBDIR="/bin"
+UCLIBCXX_EXCEPTION_SUPPORT=y
+IMPORT_LIBSUP=y
+# IMPORT_LIBGCC_EH is not set
+BUILD_STATIC_LIB=y
+# BUILD_ONLY_STATIC_LIB is not set
+# DODEBUG is not set
diff --git a/package/libs/uclibc++/files/config.default b/package/libs/uclibc++/files/config.default
new file mode 100644
index 0000000..944e1a6
--- /dev/null
+++ b/package/libs/uclibc++/files/config.default
@@ -0,0 +1,58 @@
+#
+# Automatically generated make config: don't edit
+#
+
+#
+# Target Features and Options
+#
+UCLIBCXX_HAS_FLOATS=y
+# UCLIBCXX_HAS_LONG_DOUBLE is not set
+# UCLIBCXX_HAS_TLS is not set
+WARNINGS="-Wall"
+BUILD_EXTRA_LIBRARIES=""
+HAVE_DOT_CONFIG=y
+
+#
+# String and I/O Stream Support
+#
+UCLIBCXX_HAS_WCHAR=y
+UCLIBCXX_IOSTREAM_BUFSIZE=32
+UCLIBCXX_HAS_LFS=y
+UCLIBCXX_SUPPORT_CDIR=y
+UCLIBCXX_SUPPORT_CIN=y
+UCLIBCXX_SUPPORT_COUT=y
+UCLIBCXX_SUPPORT_CERR=y
+UCLIBCXX_SUPPORT_CLOG=y
+UCLIBCXX_SUPPORT_WCIN=y
+UCLIBCXX_SUPPORT_WCOUT=y
+UCLIBCXX_SUPPORT_WCERR=y
+UCLIBCXX_SUPPORT_WCLOG=y
+
+#
+# STL and Code Expansion
+#
+UCLIBCXX_STL_BUFFER_SIZE=32
+UCLIBCXX_CODE_EXPANSION=y
+UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS=y
+UCLIBCXX_EXPAND_STRING_CHAR=y
+UCLIBCXX_EXPAND_VECTOR_BASIC=y
+UCLIBCXX_EXPAND_IOS_CHAR=y
+UCLIBCXX_EXPAND_STREAMBUF_CHAR=y
+UCLIBCXX_EXPAND_ISTREAM_CHAR=y
+UCLIBCXX_EXPAND_OSTREAM_CHAR=y
+UCLIBCXX_EXPAND_FSTREAM_CHAR=y
+UCLIBCXX_EXPAND_SSTREAM_CHAR=y
+
+#
+# Library Installation Options
+#
+UCLIBCXX_RUNTIME_PREFIX=""
+UCLIBCXX_RUNTIME_INCLUDE_SUBDIR="/include"
+UCLIBCXX_RUNTIME_LIB_SUBDIR="/lib"
+UCLIBCXX_RUNTIME_BIN_SUBDIR="/bin"
+UCLIBCXX_EXCEPTION_SUPPORT=y
+IMPORT_LIBSUP=y
+# IMPORT_LIBGCC_EH is not set
+BUILD_STATIC_LIB=y
+# BUILD_ONLY_STATIC_LIB is not set
+# DODEBUG is not set
diff --git a/package/libs/uclibc++/patches/.svn/entries b/package/libs/uclibc++/patches/.svn/entries
new file mode 100644
index 0000000..324a6a3
--- /dev/null
+++ b/package/libs/uclibc++/patches/.svn/entries
@@ -0,0 +1,96 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs/uclibc++/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+006-eabi_fix.patch
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+6b8f1a7c16793650ed58978282792c9a
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1217
+
+002-path_to_bash.patch
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+53862636fd67effae44a40bcb6471b47
+2012-10-08T11:24:12.513797Z
+33657
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+404
+
diff --git a/package/libs/uclibc++/patches/.svn/text-base/002-path_to_bash.patch.svn-base b/package/libs/uclibc++/patches/.svn/text-base/002-path_to_bash.patch.svn-base
new file mode 100644
index 0000000..26d88ee
--- /dev/null
+++ b/package/libs/uclibc++/patches/.svn/text-base/002-path_to_bash.patch.svn-base
@@ -0,0 +1,11 @@
+--- a/bin/Makefile
++++ b/bin/Makefile
+@@ -13,7 +13,7 @@ install:
+ $(INSTALL) -m 755 $(WRAPPER) $(PREFIX)$(UCLIBCXX_RUNTIME_BINDIR)
+
+ $(WRAPPER): Makefile
+- echo '#!/bin/sh' > $@
++ echo '#!/usr/bin/env bash' > $@
+ echo '' >> $@
+ echo 'WRAPPER_INCLUDEDIR="$${WRAPPER_INCLUDEDIR:=-I$(UCLIBCXX_RUNTIME_INCLUDEDIR)}"' >> $@
+ echo 'WRAPPER_LIBDIR="$${WRAPPER_LIBDIR:=-L$(UCLIBCXX_RUNTIME_LIBDIR)}"' >> $@
diff --git a/package/libs/uclibc++/patches/.svn/text-base/006-eabi_fix.patch.svn-base b/package/libs/uclibc++/patches/.svn/text-base/006-eabi_fix.patch.svn-base
new file mode 100644
index 0000000..65b436c
--- /dev/null
+++ b/package/libs/uclibc++/patches/.svn/text-base/006-eabi_fix.patch.svn-base
@@ -0,0 +1,38 @@
+--- a/include/typeinfo
++++ b/include/typeinfo
+@@ -44,6 +44,7 @@ namespace __cxxabiv1
+ class __class_type_info;
+ } // namespace __cxxabiv1
+
++#ifndef __GXX_MERGED_TYPEINFO_NAMES
+ #if !__GXX_WEAK__
+ // If weak symbols are not supported, typeinfo names are not merged.
+ #define __GXX_MERGED_TYPEINFO_NAMES 0
+@@ -51,6 +52,7 @@ namespace __cxxabiv1
+ // On platforms that support weak symbols, typeinfo names are merged.
+ #define __GXX_MERGED_TYPEINFO_NAMES 1
+ #endif
++#endif
+
+ namespace std
+ {
+--- a/include/unwind-cxx.h
++++ b/include/unwind-cxx.h
+@@ -173,6 +173,7 @@ extern std::unexpected_handler __unexpec
+
+ // This is the exception class we report -- "GNUCC++\0".
+ const _Unwind_Exception_Class __gxx_exception_class
++#ifndef __ARM_EABI_UNWINDER__
+ = ((((((((_Unwind_Exception_Class) 'G'
+ << 8 | (_Unwind_Exception_Class) 'N')
+ << 8 | (_Unwind_Exception_Class) 'U')
+@@ -181,6 +182,9 @@ const _Unwind_Exception_Class __gxx_exce
+ << 8 | (_Unwind_Exception_Class) '+')
+ << 8 | (_Unwind_Exception_Class) '+')
+ << 8 | (_Unwind_Exception_Class) '\0');
++#else
++= "GNUC++";
++#endif
+
+ // GNU C++ personality routine, Version 0.
+ extern "C" _Unwind_Reason_Code __gxx_personality_v0
diff --git a/package/libs/uclibc++/patches/002-path_to_bash.patch b/package/libs/uclibc++/patches/002-path_to_bash.patch
new file mode 100644
index 0000000..26d88ee
--- /dev/null
+++ b/package/libs/uclibc++/patches/002-path_to_bash.patch
@@ -0,0 +1,11 @@
+--- a/bin/Makefile
++++ b/bin/Makefile
+@@ -13,7 +13,7 @@ install:
+ $(INSTALL) -m 755 $(WRAPPER) $(PREFIX)$(UCLIBCXX_RUNTIME_BINDIR)
+
+ $(WRAPPER): Makefile
+- echo '#!/bin/sh' > $@
++ echo '#!/usr/bin/env bash' > $@
+ echo '' >> $@
+ echo 'WRAPPER_INCLUDEDIR="$${WRAPPER_INCLUDEDIR:=-I$(UCLIBCXX_RUNTIME_INCLUDEDIR)}"' >> $@
+ echo 'WRAPPER_LIBDIR="$${WRAPPER_LIBDIR:=-L$(UCLIBCXX_RUNTIME_LIBDIR)}"' >> $@
diff --git a/package/libs/uclibc++/patches/006-eabi_fix.patch b/package/libs/uclibc++/patches/006-eabi_fix.patch
new file mode 100644
index 0000000..65b436c
--- /dev/null
+++ b/package/libs/uclibc++/patches/006-eabi_fix.patch
@@ -0,0 +1,38 @@
+--- a/include/typeinfo
++++ b/include/typeinfo
+@@ -44,6 +44,7 @@ namespace __cxxabiv1
+ class __class_type_info;
+ } // namespace __cxxabiv1
+
++#ifndef __GXX_MERGED_TYPEINFO_NAMES
+ #if !__GXX_WEAK__
+ // If weak symbols are not supported, typeinfo names are not merged.
+ #define __GXX_MERGED_TYPEINFO_NAMES 0
+@@ -51,6 +52,7 @@ namespace __cxxabiv1
+ // On platforms that support weak symbols, typeinfo names are merged.
+ #define __GXX_MERGED_TYPEINFO_NAMES 1
+ #endif
++#endif
+
+ namespace std
+ {
+--- a/include/unwind-cxx.h
++++ b/include/unwind-cxx.h
+@@ -173,6 +173,7 @@ extern std::unexpected_handler __unexpec
+
+ // This is the exception class we report -- "GNUCC++\0".
+ const _Unwind_Exception_Class __gxx_exception_class
++#ifndef __ARM_EABI_UNWINDER__
+ = ((((((((_Unwind_Exception_Class) 'G'
+ << 8 | (_Unwind_Exception_Class) 'N')
+ << 8 | (_Unwind_Exception_Class) 'U')
+@@ -181,6 +182,9 @@ const _Unwind_Exception_Class __gxx_exce
+ << 8 | (_Unwind_Exception_Class) '+')
+ << 8 | (_Unwind_Exception_Class) '+')
+ << 8 | (_Unwind_Exception_Class) '\0');
++#else
++= "GNUC++";
++#endif
+
+ // GNU C++ personality routine, Version 0.
+ extern "C" _Unwind_Reason_Code __gxx_personality_v0
diff --git a/package/libs/ustream-ssl/.svn/entries b/package/libs/ustream-ssl/.svn/entries
new file mode 100644
index 0000000..0c6bb94
--- /dev/null
+++ b/package/libs/ustream-ssl/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs/ustream-ssl
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-22T14:52:52.421189Z
+35294
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:08.000000Z
+17b1856bab8b3abec85e81c3f328ca5d
+2013-01-22T14:52:52.421189Z
+35294
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1520
+
diff --git a/package/libs/ustream-ssl/.svn/text-base/Makefile.svn-base b/package/libs/ustream-ssl/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..28b9a99
--- /dev/null
+++ b/package/libs/ustream-ssl/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,59 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=ustream-ssl
+PKG_VERSION:=2013-01-22
+PKG_RELEASE=$(PKG_SOURCE_VERSION)
+
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL:=git://nbd.name/ustream-ssl.git
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE_VERSION:=da607e6272d789ed5dae3b0efff90912fda6f81f
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
+CMAKE_INSTALL:=1
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_SOURCE_SUBDIR)
+
+PKG_LICENSE:=ISC
+PKG_LICENSE_FILES:=
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/cmake.mk
+
+define Package/libustream/default
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=ustream SSL Library
+ DEPENDS:=+libubox
+endef
+
+define Package/libustream-openssl
+ $(Package/libustream/default)
+ TITLE += (openssl)
+ DEPENDS += +libopenssl
+ VARIANT:=openssl
+endef
+
+define Package/libustream-cyassl
+ $(Package/libustream/default)
+ TITLE += (cyassl)
+ DEPENDS += +libcyassl
+ VARIANT:=cyassl
+endef
+
+ifeq ($(BUILD_VARIANT),cyassl)
+ TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include/cyassl
+ CMAKE_OPTIONS += -DCYASSL=on
+endif
+
+define Package/libustream/default/install
+ $(INSTALL_DIR) $(1)/lib/
+ $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libustream-ssl.so $(1)/lib/
+endef
+
+Package/libustream-openssl/install = $(Package/libustream/default/install)
+Package/libustream-cyassl/install = $(Package/libustream/default/install)
+
+$(eval $(call BuildPackage,libustream-cyassl))
+$(eval $(call BuildPackage,libustream-openssl))
diff --git a/package/libs/ustream-ssl/Makefile b/package/libs/ustream-ssl/Makefile
new file mode 100644
index 0000000..28b9a99
--- /dev/null
+++ b/package/libs/ustream-ssl/Makefile
@@ -0,0 +1,59 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=ustream-ssl
+PKG_VERSION:=2013-01-22
+PKG_RELEASE=$(PKG_SOURCE_VERSION)
+
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL:=git://nbd.name/ustream-ssl.git
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE_VERSION:=da607e6272d789ed5dae3b0efff90912fda6f81f
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
+CMAKE_INSTALL:=1
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_SOURCE_SUBDIR)
+
+PKG_LICENSE:=ISC
+PKG_LICENSE_FILES:=
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/cmake.mk
+
+define Package/libustream/default
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=ustream SSL Library
+ DEPENDS:=+libubox
+endef
+
+define Package/libustream-openssl
+ $(Package/libustream/default)
+ TITLE += (openssl)
+ DEPENDS += +libopenssl
+ VARIANT:=openssl
+endef
+
+define Package/libustream-cyassl
+ $(Package/libustream/default)
+ TITLE += (cyassl)
+ DEPENDS += +libcyassl
+ VARIANT:=cyassl
+endef
+
+ifeq ($(BUILD_VARIANT),cyassl)
+ TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include/cyassl
+ CMAKE_OPTIONS += -DCYASSL=on
+endif
+
+define Package/libustream/default/install
+ $(INSTALL_DIR) $(1)/lib/
+ $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libustream-ssl.so $(1)/lib/
+endef
+
+Package/libustream-openssl/install = $(Package/libustream/default/install)
+Package/libustream-cyassl/install = $(Package/libustream/default/install)
+
+$(eval $(call BuildPackage,libustream-cyassl))
+$(eval $(call BuildPackage,libustream-openssl))
diff --git a/package/libs/zlib/.svn/entries b/package/libs/zlib/.svn/entries
new file mode 100644
index 0000000..1547502
--- /dev/null
+++ b/package/libs/zlib/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/libs/zlib
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-19T15:34:28.915431Z
+33861
+hcg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:07.000000Z
+b3d07a0a8ebe90c09cee299272bcef01
+2012-10-19T15:34:28.915431Z
+33861
+hcg
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1720
+
diff --git a/package/libs/zlib/.svn/prop-base/Makefile.svn-base b/package/libs/zlib/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..8e522ae
--- /dev/null
+++ b/package/libs/zlib/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:copyright
+V 30
+Copyright (C) 2006 OpenWrt.org
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/libs/zlib/.svn/text-base/Makefile.svn-base b/package/libs/zlib/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..2abb3c4
--- /dev/null
+++ b/package/libs/zlib/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,72 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=zlib
+PKG_VERSION:=1.2.7
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=http://www.zlib.net @SF/libpng
+PKG_MD5SUM:=2ab442d169156f34c379c968f3f482dd
+
+PKG_LICENSE:=ZLIB
+PKG_LICENSE_FILES:=README
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/zlib
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=Library implementing the deflate compression method
+ URL:=http://www.zlib.net/
+endef
+
+define Build/Configure
+ (cd $(PKG_BUILD_DIR); \
+ $(TARGET_CONFIGURE_OPTS) \
+ LDSHARED="$(TARGET_CC) -shared -Wl,-soname,libz.so.1" \
+ CFLAGS="$(TARGET_CFLAGS) $(FPIC)" \
+ ./configure \
+ --prefix=/usr \
+ --shared \
+ --uname=Linux \
+ );
+endef
+
+define Build/Compile
+ +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
+ $(TARGET_CONFIGURE_OPTS) \
+ CFLAGS="$(TARGET_CFLAGS)" \
+ libz.a libz.so.$(PKG_VERSION)
+ mkdir -p $(PKG_INSTALL_DIR)
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ DESTDIR="$(PKG_INSTALL_DIR)" \
+ install
+endef
+
+define Build/InstallDev
+ mkdir -p $(1)/usr/include
+ $(CP) $(PKG_INSTALL_DIR)/usr/include/z{conf,lib}.h \
+ $(1)/usr/include/
+ mkdir -p $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libz.{a,so*} \
+ $(1)/usr/lib/
+ mkdir -p $(1)/usr/lib/pkgconfig
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/zlib.pc \
+ $(1)/usr/lib/pkgconfig/
+endef
+
+# libz.so is needed for openssl (zlib-dynamic)
+define Package/zlib/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libz.so $(1)/usr/lib/
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libz.so.* $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,zlib))
diff --git a/package/libs/zlib/Makefile b/package/libs/zlib/Makefile
new file mode 100644
index 0000000..2abb3c4
--- /dev/null
+++ b/package/libs/zlib/Makefile
@@ -0,0 +1,72 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=zlib
+PKG_VERSION:=1.2.7
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=http://www.zlib.net @SF/libpng
+PKG_MD5SUM:=2ab442d169156f34c379c968f3f482dd
+
+PKG_LICENSE:=ZLIB
+PKG_LICENSE_FILES:=README
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/zlib
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=Library implementing the deflate compression method
+ URL:=http://www.zlib.net/
+endef
+
+define Build/Configure
+ (cd $(PKG_BUILD_DIR); \
+ $(TARGET_CONFIGURE_OPTS) \
+ LDSHARED="$(TARGET_CC) -shared -Wl,-soname,libz.so.1" \
+ CFLAGS="$(TARGET_CFLAGS) $(FPIC)" \
+ ./configure \
+ --prefix=/usr \
+ --shared \
+ --uname=Linux \
+ );
+endef
+
+define Build/Compile
+ +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
+ $(TARGET_CONFIGURE_OPTS) \
+ CFLAGS="$(TARGET_CFLAGS)" \
+ libz.a libz.so.$(PKG_VERSION)
+ mkdir -p $(PKG_INSTALL_DIR)
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ DESTDIR="$(PKG_INSTALL_DIR)" \
+ install
+endef
+
+define Build/InstallDev
+ mkdir -p $(1)/usr/include
+ $(CP) $(PKG_INSTALL_DIR)/usr/include/z{conf,lib}.h \
+ $(1)/usr/include/
+ mkdir -p $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libz.{a,so*} \
+ $(1)/usr/lib/
+ mkdir -p $(1)/usr/lib/pkgconfig
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/zlib.pc \
+ $(1)/usr/lib/pkgconfig/
+endef
+
+# libz.so is needed for openssl (zlib-dynamic)
+define Package/zlib/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libz.so $(1)/usr/lib/
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libz.so.* $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,zlib))
diff --git a/package/linux-atm/.svn/entries b/package/linux-atm/.svn/entries
new file mode 100644
index 0000000..4a337b9
--- /dev/null
+++ b/package/linux-atm/.svn/entries
@@ -0,0 +1,68 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/linux-atm
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-12-05T14:58:54.360193Z
+34504
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+files
+dir
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+159a5c59048e3c52069decb201a49f41
+2012-12-05T14:58:54.360193Z
+34504
+florian
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5740
+
diff --git a/package/linux-atm/.svn/prop-base/Makefile.svn-base b/package/linux-atm/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..8e522ae
--- /dev/null
+++ b/package/linux-atm/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:copyright
+V 30
+Copyright (C) 2006 OpenWrt.org
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/linux-atm/.svn/text-base/Makefile.svn-base b/package/linux-atm/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..12f871c
--- /dev/null
+++ b/package/linux-atm/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,190 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=linux-atm
+PKG_VERSION:=2.5.2
+PKG_RELEASE:=5
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=@SF/$(PKG_NAME)
+PKG_MD5SUM:=d49499368c3cf15f73a05d9bce8824a8
+
+PKG_INSTALL:=1
+PKG_BUILD_PARALLEL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+ATM_DEBUG_BINS:=aread awrite atmdiag atmdump atmswitch saaldump \
+ sonetdiag svc_recv svc_send ttcp_atm
+ATM_DEBUG_SBINS:=atmaddr atmloop atmtcp esi atmsigd bus \
+ ilmid ilmidiag lecs les mpcd zeppelin
+ATM_DEBUG_TOOLS:=$(ATM_DEBUG_BINS) $(ATM_DEBUG_SBINS)
+
+define Package/linux-atm
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=Linux ATM library
+ URL:=http://linux-atm.sourceforge.net/
+endef
+
+define Package/linux-atm/description
+ This package contains a library for accessing the Linux ATM subsystem.
+endef
+
+define Package/linux-atm/Default
+ SECTION:=net
+ CATEGORY:=Network
+ DEPENDS:=linux-atm
+ URL:=http://linux-atm.sourceforge.net/
+ SUBMENU:=Linux ATM tools
+endef
+
+define Package/atm-tools
+ $(call Package/linux-atm/Default)
+ TITLE:=Linux ATM tools
+endef
+
+define Package/atm-tools/description
+ This package contains the Linux ATM tools.
+endef
+
+define Package/atm-diagnostics
+ $(call Package/linux-atm/Default)
+ TITLE:=Linux ATM Diagnostics
+endef
+
+define Package/atm-diagnostics/description
+ This package contains the Linux ATM diagnostics.
+endef
+
+define Package/atm-debug-tools
+ $(call Package/linux-atm/Default)
+ TITLE:=Linux ATM debugging tools
+endef
+
+define Package/atm-debug-tools/description
+ This package contains the Linux ATM debugging tools.
+endef
+
+define Package/br2684ctl
+ $(call Package/linux-atm/Default)
+ TITLE:=ATM Ethernet bridging configuration utility
+endef
+
+define Package/br2684ctl/description
+ Support for AAL5 encapsulation (RFC-1483/RFC-2684) over ATM.
+endef
+
+define GenAtmPlugin
+ define Package/$(1)
+ $(call Package/linux-atm/Default)
+ TITLE:=Linux ATM tool $(2)
+ endef
+
+ define Package/$(1)/description
+ Linux ATM tool $(2).
+ endef
+endef
+
+$(foreach t,$(ATM_DEBUG_TOOLS),$(eval $(call GenAtmPlugin,atm-$(t),$(t))))
+
+define Build/Configure
+ $(call Build/Configure/Default)
+ # prevent autoheader invocation
+ touch $(PKG_BUILD_DIR)/stamp-h.in
+endef
+
+unexport PREFIX
+
+define Build/Compile
+ # src/qgen is built with HOSTCC, which does not really like our LDFLAGS
+ +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR)/src/qgen \
+ LDFLAGS="" \
+ all
+ +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) OBJCOPY=$(TARGET_CROSS)objcopy all
+endef
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr
+ $(CP) \
+ $(PKG_INSTALL_DIR)/usr/include \
+ $(PKG_INSTALL_DIR)/usr/lib \
+ $(1)/usr/
+endef
+
+define Package/linux-atm/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libatm.so* $(1)/usr/lib/
+endef
+
+define Package/atm-tools/install
+ $(INSTALL_DIR) $(1)/usr/sbin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/atmarp{,d} $(1)/usr/sbin/
+endef
+
+
+define BuildAtmPlugin
+ define Package/$(1)/install
+ $(INSTALL_DIR) $$(1)/usr/$(3)
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/$(3)/$(2) $$(1)/usr/$(3)
+ endef
+
+ $$(eval $$(call BuildPackage,$(1)))
+endef
+
+define Package/atm-debug-tools/install
+ $(INSTALL_DIR) $(1)/usr/bin/
+ $(INSTALL_DIR) $(1)/usr/sbin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/atmaddr $(1)/usr/sbin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/atmloop $(1)/usr/sbin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/atmtcp $(1)/usr/sbin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/esi $(1)/usr/sbin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/aread $(1)/usr/bin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/awrite $(1)/usr/bin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/atmdiag $(1)/usr/bin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/atmdump $(1)/usr/bin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/atmsigd $(1)/usr/sbin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/bus $(1)/usr/sbin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/ilmid $(1)/usr/sbin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/ilmidiag $(1)/usr/sbin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/lecs $(1)/usr/sbin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/les $(1)/usr/sbin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/mpcd $(1)/usr/sbin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/zeppelin $(1)/usr/sbin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/atmswitch $(1)/usr/bin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/saaldump $(1)/usr/bin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/sonetdiag $(1)/usr/bin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/svc_recv $(1)/usr/bin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/svc_send $(1)/usr/bin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/ttcp_atm $(1)/usr/bin/
+endef
+
+define Package/atm-diagnostics/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/aread $(1)/usr/bin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/awrite $(1)/usr/bin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/atmdiag $(1)/usr/bin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/atmdump $(1)/usr/bin/
+endef
+
+define Package/br2684ctl/install
+ $(INSTALL_DIR) $(1)/etc/init.d/
+ $(INSTALL_BIN) ./files/br2684ctl $(1)/etc/init.d/
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/br2684ctl $(1)/usr/sbin/
+endef
+
+$(eval $(call BuildPackage,linux-atm))
+$(eval $(call BuildPackage,atm-tools))
+$(eval $(call BuildPackage,atm-debug-tools))
+$(eval $(call BuildPackage,atm-diagnostics))
+$(eval $(call BuildPackage,br2684ctl))
+$(foreach t,$(ATM_DEBUG_BINS),$(eval $(call BuildAtmPlugin,atm-$(t),$(t),bin)))
+$(foreach t,$(ATM_DEBUG_SBINS),$(eval $(call BuildAtmPlugin,atm-$(t),$(t),sbin)))
diff --git a/package/linux-atm/Makefile b/package/linux-atm/Makefile
new file mode 100644
index 0000000..12f871c
--- /dev/null
+++ b/package/linux-atm/Makefile
@@ -0,0 +1,190 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=linux-atm
+PKG_VERSION:=2.5.2
+PKG_RELEASE:=5
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=@SF/$(PKG_NAME)
+PKG_MD5SUM:=d49499368c3cf15f73a05d9bce8824a8
+
+PKG_INSTALL:=1
+PKG_BUILD_PARALLEL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+ATM_DEBUG_BINS:=aread awrite atmdiag atmdump atmswitch saaldump \
+ sonetdiag svc_recv svc_send ttcp_atm
+ATM_DEBUG_SBINS:=atmaddr atmloop atmtcp esi atmsigd bus \
+ ilmid ilmidiag lecs les mpcd zeppelin
+ATM_DEBUG_TOOLS:=$(ATM_DEBUG_BINS) $(ATM_DEBUG_SBINS)
+
+define Package/linux-atm
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=Linux ATM library
+ URL:=http://linux-atm.sourceforge.net/
+endef
+
+define Package/linux-atm/description
+ This package contains a library for accessing the Linux ATM subsystem.
+endef
+
+define Package/linux-atm/Default
+ SECTION:=net
+ CATEGORY:=Network
+ DEPENDS:=linux-atm
+ URL:=http://linux-atm.sourceforge.net/
+ SUBMENU:=Linux ATM tools
+endef
+
+define Package/atm-tools
+ $(call Package/linux-atm/Default)
+ TITLE:=Linux ATM tools
+endef
+
+define Package/atm-tools/description
+ This package contains the Linux ATM tools.
+endef
+
+define Package/atm-diagnostics
+ $(call Package/linux-atm/Default)
+ TITLE:=Linux ATM Diagnostics
+endef
+
+define Package/atm-diagnostics/description
+ This package contains the Linux ATM diagnostics.
+endef
+
+define Package/atm-debug-tools
+ $(call Package/linux-atm/Default)
+ TITLE:=Linux ATM debugging tools
+endef
+
+define Package/atm-debug-tools/description
+ This package contains the Linux ATM debugging tools.
+endef
+
+define Package/br2684ctl
+ $(call Package/linux-atm/Default)
+ TITLE:=ATM Ethernet bridging configuration utility
+endef
+
+define Package/br2684ctl/description
+ Support for AAL5 encapsulation (RFC-1483/RFC-2684) over ATM.
+endef
+
+define GenAtmPlugin
+ define Package/$(1)
+ $(call Package/linux-atm/Default)
+ TITLE:=Linux ATM tool $(2)
+ endef
+
+ define Package/$(1)/description
+ Linux ATM tool $(2).
+ endef
+endef
+
+$(foreach t,$(ATM_DEBUG_TOOLS),$(eval $(call GenAtmPlugin,atm-$(t),$(t))))
+
+define Build/Configure
+ $(call Build/Configure/Default)
+ # prevent autoheader invocation
+ touch $(PKG_BUILD_DIR)/stamp-h.in
+endef
+
+unexport PREFIX
+
+define Build/Compile
+ # src/qgen is built with HOSTCC, which does not really like our LDFLAGS
+ +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR)/src/qgen \
+ LDFLAGS="" \
+ all
+ +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) OBJCOPY=$(TARGET_CROSS)objcopy all
+endef
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr
+ $(CP) \
+ $(PKG_INSTALL_DIR)/usr/include \
+ $(PKG_INSTALL_DIR)/usr/lib \
+ $(1)/usr/
+endef
+
+define Package/linux-atm/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libatm.so* $(1)/usr/lib/
+endef
+
+define Package/atm-tools/install
+ $(INSTALL_DIR) $(1)/usr/sbin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/atmarp{,d} $(1)/usr/sbin/
+endef
+
+
+define BuildAtmPlugin
+ define Package/$(1)/install
+ $(INSTALL_DIR) $$(1)/usr/$(3)
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/$(3)/$(2) $$(1)/usr/$(3)
+ endef
+
+ $$(eval $$(call BuildPackage,$(1)))
+endef
+
+define Package/atm-debug-tools/install
+ $(INSTALL_DIR) $(1)/usr/bin/
+ $(INSTALL_DIR) $(1)/usr/sbin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/atmaddr $(1)/usr/sbin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/atmloop $(1)/usr/sbin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/atmtcp $(1)/usr/sbin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/esi $(1)/usr/sbin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/aread $(1)/usr/bin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/awrite $(1)/usr/bin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/atmdiag $(1)/usr/bin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/atmdump $(1)/usr/bin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/atmsigd $(1)/usr/sbin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/bus $(1)/usr/sbin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/ilmid $(1)/usr/sbin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/ilmidiag $(1)/usr/sbin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/lecs $(1)/usr/sbin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/les $(1)/usr/sbin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/mpcd $(1)/usr/sbin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/zeppelin $(1)/usr/sbin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/atmswitch $(1)/usr/bin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/saaldump $(1)/usr/bin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/sonetdiag $(1)/usr/bin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/svc_recv $(1)/usr/bin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/svc_send $(1)/usr/bin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/ttcp_atm $(1)/usr/bin/
+endef
+
+define Package/atm-diagnostics/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/aread $(1)/usr/bin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/awrite $(1)/usr/bin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/atmdiag $(1)/usr/bin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/atmdump $(1)/usr/bin/
+endef
+
+define Package/br2684ctl/install
+ $(INSTALL_DIR) $(1)/etc/init.d/
+ $(INSTALL_BIN) ./files/br2684ctl $(1)/etc/init.d/
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/br2684ctl $(1)/usr/sbin/
+endef
+
+$(eval $(call BuildPackage,linux-atm))
+$(eval $(call BuildPackage,atm-tools))
+$(eval $(call BuildPackage,atm-debug-tools))
+$(eval $(call BuildPackage,atm-diagnostics))
+$(eval $(call BuildPackage,br2684ctl))
+$(foreach t,$(ATM_DEBUG_BINS),$(eval $(call BuildAtmPlugin,atm-$(t),$(t),bin)))
+$(foreach t,$(ATM_DEBUG_SBINS),$(eval $(call BuildAtmPlugin,atm-$(t),$(t),sbin)))
diff --git a/package/linux-atm/files/.svn/entries b/package/linux-atm/files/.svn/entries
new file mode 100644
index 0000000..3500c3f
--- /dev/null
+++ b/package/linux-atm/files/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/linux-atm/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-23T19:53:44.357353Z
+33900
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+br2684ctl
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+31507e9f96b97c3b22e954f46b53c2cb
+2012-10-23T19:53:44.357353Z
+33900
+jow
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1433
+
diff --git a/package/linux-atm/files/.svn/prop-base/br2684ctl.svn-base b/package/linux-atm/files/.svn/prop-base/br2684ctl.svn-base
new file mode 100644
index 0000000..869ac71
--- /dev/null
+++ b/package/linux-atm/files/.svn/prop-base/br2684ctl.svn-base
@@ -0,0 +1,5 @@
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/linux-atm/files/.svn/text-base/br2684ctl.svn-base b/package/linux-atm/files/.svn/text-base/br2684ctl.svn-base
new file mode 100644
index 0000000..30b1a44
--- /dev/null
+++ b/package/linux-atm/files/.svn/text-base/br2684ctl.svn-base
@@ -0,0 +1,89 @@
+#!/bin/sh /etc/rc.common
+
+START=50
+
+SERVICE_DAEMONIZE=1
+SERVICE_WRITE_PID=1
+
+start_daemon() {
+ . /lib/functions/network.sh
+
+ local cfg="$1"
+
+ local atmdev
+ config_get atmdev "$cfg" atmdev 0
+
+ local unit
+ config_get unit "$cfg" unit 0
+
+ local vpi
+ config_get vpi "$cfg" vpi 8
+
+ local vci
+ config_get vci "$cfg" vci 35
+
+ local encaps
+ config_get encaps "$cfg" encaps
+
+ case "$encaps" in
+ 1|vc) encaps=1;;
+ *) encaps=0;;
+ esac
+
+ local payload
+ config_get payload "$cfg" payload
+
+ case "$payload" in
+ 0|routed) payload=0;;
+ *) payload=1;;
+ esac
+
+ local qos
+ config_get qos "$cfg" qos
+
+ local sendsize
+ config_get sendsize "$cfg" sendsize
+
+ local circuit="$atmdev.$vpi.$vci"
+
+ network_defer_device "nas$unit"
+
+ SERVICE_PID_FILE="/var/run/br2684ctl-$circuit.pid" \
+ service_start /usr/sbin/br2684ctl \
+ -c "$unit" -e "$encaps" -p "$payload" \
+ -a "$circuit" ${qos:+-q "$qos"} ${sendsize:+-s "$sendsize"}
+ sleep 1
+
+ network_ready_device "nas$unit"
+}
+
+stop_daemon() {
+ local cfg="$1"
+
+ local atmdev
+ config_get atmdev "$cfg" atmdev 0
+
+ local unit
+ config_get unit "$cfg" unit 0
+
+ local vpi
+ config_get vpi "$cfg" vpi 8
+
+ local vci
+ config_get vci "$cfg" vci 35
+
+ local circuit="$atmdev.$vpi.$vci"
+
+ SERVICE_PID_FILE="/var/run/br2684ctl-$circuit.pid" \
+ service_stop /usr/sbin/br2684ctl
+}
+
+start() {
+ config_load network
+ config_foreach start_daemon atm-bridge
+}
+
+stop() {
+ config_load network
+ config_foreach stop_daemon atm-bridge
+}
diff --git a/package/linux-atm/files/br2684ctl b/package/linux-atm/files/br2684ctl
new file mode 100755
index 0000000..30b1a44
--- /dev/null
+++ b/package/linux-atm/files/br2684ctl
@@ -0,0 +1,89 @@
+#!/bin/sh /etc/rc.common
+
+START=50
+
+SERVICE_DAEMONIZE=1
+SERVICE_WRITE_PID=1
+
+start_daemon() {
+ . /lib/functions/network.sh
+
+ local cfg="$1"
+
+ local atmdev
+ config_get atmdev "$cfg" atmdev 0
+
+ local unit
+ config_get unit "$cfg" unit 0
+
+ local vpi
+ config_get vpi "$cfg" vpi 8
+
+ local vci
+ config_get vci "$cfg" vci 35
+
+ local encaps
+ config_get encaps "$cfg" encaps
+
+ case "$encaps" in
+ 1|vc) encaps=1;;
+ *) encaps=0;;
+ esac
+
+ local payload
+ config_get payload "$cfg" payload
+
+ case "$payload" in
+ 0|routed) payload=0;;
+ *) payload=1;;
+ esac
+
+ local qos
+ config_get qos "$cfg" qos
+
+ local sendsize
+ config_get sendsize "$cfg" sendsize
+
+ local circuit="$atmdev.$vpi.$vci"
+
+ network_defer_device "nas$unit"
+
+ SERVICE_PID_FILE="/var/run/br2684ctl-$circuit.pid" \
+ service_start /usr/sbin/br2684ctl \
+ -c "$unit" -e "$encaps" -p "$payload" \
+ -a "$circuit" ${qos:+-q "$qos"} ${sendsize:+-s "$sendsize"}
+ sleep 1
+
+ network_ready_device "nas$unit"
+}
+
+stop_daemon() {
+ local cfg="$1"
+
+ local atmdev
+ config_get atmdev "$cfg" atmdev 0
+
+ local unit
+ config_get unit "$cfg" unit 0
+
+ local vpi
+ config_get vpi "$cfg" vpi 8
+
+ local vci
+ config_get vci "$cfg" vci 35
+
+ local circuit="$atmdev.$vpi.$vci"
+
+ SERVICE_PID_FILE="/var/run/br2684ctl-$circuit.pid" \
+ service_stop /usr/sbin/br2684ctl
+}
+
+start() {
+ config_load network
+ config_foreach start_daemon atm-bridge
+}
+
+stop() {
+ config_load network
+ config_foreach stop_daemon atm-bridge
+}
diff --git a/package/linux-atm/patches/.svn/entries b/package/linux-atm/patches/.svn/entries
new file mode 100644
index 0000000..9ab9a75
--- /dev/null
+++ b/package/linux-atm/patches/.svn/entries
@@ -0,0 +1,164 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/linux-atm/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-11-23T20:02:19.217513Z
+34312
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+300-objcopy_path.patch
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+81fb9ffac5de2f6e33ab1cad9347f03f
+2011-02-01T18:58:48.381863Z
+25285
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1197
+
+400-portability_fixes.patch
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+375708a430002b6f83514165847da9d8
+2012-11-23T20:02:19.217513Z
+34312
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2238
+
+200-no_libfl.patch
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+9bc29fdfa24d8b4b6e05fd8548aa3012
+2011-01-22T22:44:58.652564Z
+25067
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4660
+
+000-debian_16.patch
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+e274994e104fbedcad183f74d1b64dc5
+2010-03-14T18:58:33.003955Z
+20216
+thepeople
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+7516
+
diff --git a/package/linux-atm/patches/.svn/prop-base/000-debian_16.patch.svn-base b/package/linux-atm/patches/.svn/prop-base/000-debian_16.patch.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/linux-atm/patches/.svn/prop-base/000-debian_16.patch.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/linux-atm/patches/.svn/text-base/000-debian_16.patch.svn-base b/package/linux-atm/patches/.svn/text-base/000-debian_16.patch.svn-base
new file mode 100644
index 0000000..4abaac0
--- /dev/null
+++ b/package/linux-atm/patches/.svn/text-base/000-debian_16.patch.svn-base
@@ -0,0 +1,270 @@
+--- a/src/arpd/io.c
++++ b/src/arpd/io.c
+@@ -277,7 +277,8 @@ static void accept_new(void)
+ struct atm_qos qos;
+ ENTRY *entry;
+ VCC *vcc;
+- int fd,len,size,error;
++ int fd,error;
++ socklen_t len,size;
+
+ len = sizeof(addr);
+ if ((fd = accept(incoming,(struct sockaddr *) &addr,&len)) < 0) {
+@@ -614,7 +615,8 @@ int ip_itf_info(int number,uint32_t *ip,
+
+ int get_local(int fd,struct sockaddr_atmsvc *addr)
+ {
+- int length,result;
++ int result;
++ size_t length;
+
+ length = sizeof(struct sockaddr_atmsvc);
+ result = getsockname(fd,(struct sockaddr *) addr,&length);
+--- a/src/arpd/table.c
++++ b/src/arpd/table.c
+@@ -101,7 +101,8 @@ static void dump_vcc(VCC *vcc)
+ char addr_buf[MAX_ATM_ADDR_LEN+1];
+ char qos_buf[MAX_ATM_QOS_LEN+1];
+ struct atm_qos qos;
+- int size,sndbuf;
++ int sndbuf;
++ socklen_t size;
+
+ size = sizeof(addr);
+ if (getpeername(vcc->fd,(struct sockaddr *) &addr,&size) < 0) {
+--- a/src/ilmid/asn1/asn_int.c
++++ b/src/ilmid/asn1/asn_int.c
+@@ -185,7 +185,7 @@ FILE* f _AND_
+ AsnInt* v _AND_
+ unsigned short int indent)
+ {
+- fprintf(f,"%d", *v);
++ fprintf(f,"%ld", *v);
+ }
+
+
+@@ -370,5 +370,5 @@ FILE* f _AND_
+ UAsnInt* v _AND_
+ unsigned short int indent)
+ {
+- fprintf(f,"%u", *v);
++ fprintf(f,"%lu", *v);
+ }
+--- a/src/ilmid/asn1/asn_oid.c
++++ b/src/ilmid/asn1/asn_oid.c
+@@ -127,7 +127,7 @@ unsigned short int indent)
+ if (firstArcNum > 2)
+ firstArcNum = 2;
+
+- fprintf(f,"%u %u", firstArcNum, arcNum - (firstArcNum * 40));
++ fprintf(f,"%d %lu", firstArcNum, arcNum - (firstArcNum * 40));
+
+ for (; i < v->octetLen ; )
+ {
+@@ -136,7 +136,7 @@ unsigned short int indent)
+
+ arcNum = (arcNum << 7) + (v->octs[i] & 0x7f);
+ i++;
+- fprintf(f," %u", arcNum);
++ fprintf(f," %lu", arcNum);
+ }
+ fprintf(f,"}");
+
+--- a/src/lane/connect.c
++++ b/src/lane/connect.c
+@@ -258,7 +258,8 @@ static int
+ data_handler(const Event_t *event, void *funcdata)
+ {
+ Conn_t *tmp, *newconn;
+- int fd, nbytes;
++ int fd;
++ socklen_t nbytes;
+ static char buffer[BUFSIZE];
+ LaneControl_t *ctmp;
+ struct sockaddr_atmsvc addr;
+--- a/src/lane/connect_bus.c
++++ b/src/lane/connect_bus.c
+@@ -170,7 +170,8 @@ static int
+ data_handler(const Event_t *event, void *funcdata)
+ {
+ Conn_t *tmp, *newconn;
+- int fd, nbytes;
++ int fd;
++ socklen_t nbytes;
+ static char buffer[BUFSIZE];
+ struct sockaddr_atmsvc addr;
+
+--- a/src/lane/lane_atm.c
++++ b/src/lane/lane_atm.c
+@@ -138,7 +138,7 @@ atm_connect_back(const AtmAddr_t *our_ad
+ struct atm_blli blli;
+ struct atm_qos qos;
+ int fd, ret;
+- int len = sizeof(address);
++ socklen_t len = sizeof(address);
+
+ fd = socket(PF_ATMSVC, SOCK_DGRAM, 0);
+ if (fd <0) {
+--- a/src/lane/lecs.c
++++ b/src/lane/lecs.c
+@@ -119,7 +119,7 @@ int main(int argc, char **argv)
+ int just_dump=0;
+ fd_set fds;
+ struct sockaddr_atmsvc client;
+- int len;
++ socklen_t len;
+ unsigned char buffer[P_SIZE];
+
+ while(i!=-1) {
+--- a/src/lib/ans.c
++++ b/src/lib/ans.c
+@@ -41,7 +41,7 @@
+ static int ans(const char *text,int wanted,void *result,int res_len)
+ {
+ unsigned char answer[MAX_ANSWER];
+- unsigned char name[MAX_NAME];
++ char name[MAX_NAME];
+ unsigned char *pos,*data,*found;
+ int answer_len,name_len,data_len,found_len;
+ int questions,answers;
+--- a/src/lib/sdu2cell.c
++++ b/src/lib/sdu2cell.c
+@@ -15,7 +15,8 @@ int sdu2cell(int s,int sizes,const int *
+ {
+ struct atm_qos qos;
+ int trailer,total,cells;
+- int size,i;
++ int i;
++ socklen_t size;
+
+ size = sizeof(qos);
+ if (getsockopt(s,SOL_AAL,SO_ATMQOS,&qos,&size) < 0) return -1;
+--- a/src/lib/unix.c
++++ b/src/lib/unix.c
+@@ -63,8 +63,8 @@ int un_attach(const char *path)
+ int un_recv_connect(int s,void *buf,int size)
+ {
+ struct sockaddr_un addr;
+- int addr_size;
+ int len;
++ socklen_t addr_size;
+
+ addr_size = sizeof(addr);
+ len = recvfrom(s,buf,size,0,(struct sockaddr *) &addr,&addr_size);
+--- a/src/maint/atmtcp.c
++++ b/src/maint/atmtcp.c
+@@ -817,7 +817,8 @@ int main(int argc,char **argv)
+ }
+ else if (!strcmp(ARG,"listen") ||
+ (do_background = !strcmp(ARG,"listen-bg"))) {
+- int fd,port,addr_len;
++ int fd,port;
++ socklen_t addr_len;
+ int *fd2 = alloc_t(int);
+
+ if ((fd = socket(PF_INET,SOCK_STREAM,0)) < 0) {
+--- a/src/maint/hediag.c
++++ b/src/maint/hediag.c
+@@ -1,6 +1,7 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <unistd.h>
++#include <string.h>
+ #include <sys/ioctl.h>
+ #include <sys/types.h>
+ #include <sys/socket.h>
+--- a/src/mpoad/io.c
++++ b/src/mpoad/io.c
+@@ -521,7 +521,8 @@ static int msg_from_mps(int slot)
+ static int accept_conn(int slot)
+ {
+ struct sockaddr_atmsvc sa;
+- int i, new_fd, sa_len;
++ int i, new_fd;
++ socklen_t sa_len;
+
+ sa_len = sizeof(sa);
+ new_fd = accept(fds[slot].fd, (struct sockaddr *)&sa, &sa_len);
+--- a/src/sigd/io.c
++++ b/src/sigd/io.c
+@@ -355,7 +355,7 @@ int get_pvc(int itf,int *vci)
+ error = 0;
+ if (bind(s,(struct sockaddr *) &addr,sizeof(addr)) < 0) error = errno;
+ else {
+- int size;
++ socklen_t size;
+
+ size = sizeof(addr);
+ if (getsockname(s,(struct sockaddr *) &addr,&size) < 0)
+--- a/src/test/ttcp.c
++++ b/src/test/ttcp.c
+@@ -92,7 +92,8 @@ struct sockaddr_in frominet;
+ struct sockaddr_atmsvc satm;
+ struct atm_qos qos;
+
+-int domain, fromlen;
++int domain;
++socklen_t fromlen;
+ int fd; /* fd of network socket */
+
+ int buflen = 8 * 1024; /* length of buffer */
+@@ -466,7 +467,7 @@ int no_check = 0;
+
+ {
+ struct sockaddr_atmsvc peer;
+- int peerlen = sizeof(peer);
++ socklen_t peerlen = sizeof(peer);
+ if (getpeername(fd, (struct sockaddr *) &peer,
+ &peerlen) < 0) {
+ err("getpeername");
+@@ -498,7 +499,7 @@ int no_check = 0;
+ /* set socket buffer size */
+ #if defined(SO_SNDBUF) || defined(SO_RCVBUF)
+ if (sockbufsize) {
+- int len;
++ socklen_t len;
+
+ if (trans) {
+ /* set send socket buffer if we are transmitting */
+--- a/src/mpoad/mpcd.8
++++ b/src/mpoad/mpcd.8
+@@ -28,7 +28,7 @@ mpcd \- ATM MPOA (Multi\-Protocol Over A
+ .B ]]
+ .SH DESCRIPTION
+ MPOA client
+-.SM(MPC) is responsible for creating and receiving
++.SM (MPC) is responsible for creating and receiving
+ internetwork layer shortcuts. Using these shortcuts MPCs forward
+ unicast internetwork layer packets effectively over ATM without need
+ for routing protocols.
+@@ -43,7 +43,7 @@ accepts shortcuts and packets arriving o
+ shortcuts is done with the help of
+ .SM MPOA
+ server
+-.SM(MPS).
++.SM (MPS).
+ .PP
+ Just as the Linux
+ .SM LAN
+--- a/src/led/zeppelin.8
++++ b/src/led/zeppelin.8
+@@ -99,7 +99,7 @@ Ring and ATM parts of the ELAN, so using
+ recommended. Token Ring support has received less testing than its
+ Ethernet counterpart.
+ .SH FILES
+-.IP \fI/var/run/lec[interface number].pid\fP
++.IP \fI/var/run/lec[interface\ number].pid\fP
+ The file containing the process id of zeppelin.
+ .SH BUGS
+ John Bonham died 1980 and Led Zeppelin broke.
+--- a/src/sigd/atmsigd.conf.4
++++ b/src/sigd/atmsigd.conf.4
+@@ -125,7 +125,7 @@ a comment. The `#' character cannot be e
+ .P
+ If an option is specified in \fBatmsigd.conf\fP and on the command
+ line, the command line has priority.
+-.COMPATIBILITY
++.SH COMPATIBILITY
+ Certain options used by past versions of \fBatmsigd\fP but no longer documented
+ on the man page are still recognized and supported, but they also yield a
+ warning message. Future versions of \fBatmsigd\fP will not recognize those
diff --git a/package/linux-atm/patches/.svn/text-base/200-no_libfl.patch.svn-base b/package/linux-atm/patches/.svn/text-base/200-no_libfl.patch.svn-base
new file mode 100644
index 0000000..6db8779
--- /dev/null
+++ b/package/linux-atm/patches/.svn/text-base/200-no_libfl.patch.svn-base
@@ -0,0 +1,179 @@
+--- a/src/qgen/Makefile.am
++++ b/src/qgen/Makefile.am
+@@ -2,7 +2,7 @@ noinst_PROGRAMS = qgen
+
+ qgen_SOURCES = common.c common.h file.c file.h first.c ql_y.y ql_l.l qgen.c \
+ qgen.h second.c third.c
+-qgen_LDADD = -lfl
++qgen_LDADD =
+
+ COMPILE = @CC_FOR_BUILD@ @CFLAGS_FOR_BUILD@
+ LINK = @CC_FOR_BUILD@ @CFLAGS_FOR_BUILD@ -o $@
+--- a/src/qgen/Makefile.in
++++ b/src/qgen/Makefile.in
+@@ -204,7 +204,7 @@ top_srcdir = @top_srcdir@
+ qgen_SOURCES = common.c common.h file.c file.h first.c ql_y.y ql_l.l qgen.c \
+ qgen.h second.c third.c
+
+-qgen_LDADD = -lfl
++qgen_LDADD =
+ COMPILE = @CC_FOR_BUILD@ @CFLAGS_FOR_BUILD@
+ LINK = @CC_FOR_BUILD@ @CFLAGS_FOR_BUILD@ -o $@
+
+--- a/src/sigd/Makefile.am
++++ b/src/sigd/Makefile.am
+@@ -8,7 +8,7 @@ atmsigd_XTRAS = mess.o $(top_builddir)/s
+ $(top_builddir)/src/q2931/qd.dump.o \
+ $(top_builddir)/src/lib/libatm.la \
+ $(top_builddir)/src/saal/libsaal.a
+-atmsigd_LDADD = $(atmsigd_XTRAS) -lfl
++atmsigd_LDADD = $(atmsigd_XTRAS)
+ atmsigd_DEPENDENCIES = mess.c $(atmsigd_XTRAS)
+
+ CLEANFILES = mess.c
+--- a/src/sigd/Makefile.in
++++ b/src/sigd/Makefile.in
+@@ -245,7 +245,7 @@ atmsigd_XTRAS = mess.o $(top_builddir)/s
+ $(top_builddir)/src/lib/libatm.la \
+ $(top_builddir)/src/saal/libsaal.a
+
+-atmsigd_LDADD = $(atmsigd_XTRAS) -lfl
++atmsigd_LDADD = $(atmsigd_XTRAS)
+ atmsigd_DEPENDENCIES = mess.c $(atmsigd_XTRAS)
+ CLEANFILES = mess.c
+ sysconf_DATA = atmsigd.conf
+--- a/src/switch/debug/debug.c
++++ b/src/switch/debug/debug.c
+@@ -20,6 +20,11 @@
+
+ #define PRV(call) ((FAB *) (call)->fab)
+
++int yywrap(void)
++{
++ return 1;
++}
++
+
+ typedef struct _fab {
+ CALL *next; /* relay.c may not keep track of calls, but WE are */
+--- a/src/switch/debug/Makefile.am
++++ b/src/switch/debug/Makefile.am
+@@ -5,7 +5,7 @@ INCLUDES = -I$(srcdir)/../../q2931
+ sw_debug_SOURCES = debug.c
+ sw_debug_XTRAS = $(top_builddir)/src/switch/libsw.a \
+ $(top_builddir)/src/lib/libatm.la
+-sw_debug_LDADD = $(sw_debug_XTRAS) -lfl
++sw_debug_LDADD = $(sw_debug_XTRAS)
+
+ sw_debug_DEPENDENCIES = $(sw_debug_XTRAS)
+
+--- a/src/switch/debug/Makefile.in
++++ b/src/switch/debug/Makefile.in
+@@ -200,7 +200,8 @@ sw_debug_SOURCES = debug.c
+ sw_debug_XTRAS = $(top_builddir)/src/switch/libsw.a \
+ $(top_builddir)/src/lib/libatm.la
+
+-sw_debug_LDADD = $(sw_debug_XTRAS) -lfl
++sw_debug_LDADD = $(sw_debug_XTRAS)
++
+ sw_debug_DEPENDENCIES = $(sw_debug_XTRAS)
+ EXTRA_DIST = demo README
+ all: all-am
+--- a/src/switch/tcp/Makefile.am
++++ b/src/switch/tcp/Makefile.am
+@@ -5,7 +5,7 @@ INCLUDES = -I$(srcdir)/../../q2931
+ sw_tcp_SOURCES = tcpsw.c
+ sw_tcp_XTRAS = $(top_builddir)/src/switch/libsw.a \
+ $(top_builddir)/src/lib/libatm.la
+-sw_tcp_LDADD = $(sw_tcp_XTRAS) -lfl
++sw_tcp_LDADD = $(sw_tcp_XTRAS)
+ sw_tcp_DEPENDENCIES = $(sw_tcp_XTRAS)
+
+ EXTRA_DIST = mkfiles README
+--- a/src/switch/tcp/Makefile.in
++++ b/src/switch/tcp/Makefile.in
+@@ -200,7 +200,7 @@ sw_tcp_SOURCES = tcpsw.c
+ sw_tcp_XTRAS = $(top_builddir)/src/switch/libsw.a \
+ $(top_builddir)/src/lib/libatm.la
+
+-sw_tcp_LDADD = $(sw_tcp_XTRAS) -lfl
++sw_tcp_LDADD = $(sw_tcp_XTRAS)
+ sw_tcp_DEPENDENCIES = $(sw_tcp_XTRAS)
+ EXTRA_DIST = mkfiles README
+ all: all-am
+--- a/src/switch/tcp/tcpsw.c
++++ b/src/switch/tcp/tcpsw.c
+@@ -35,6 +35,10 @@
+ #define MAX_PACKET (ATM_MAX_AAL5_PDU+sizeof(struct atmtcp_hdr))
+ #define BUFFER_SIZE (MAX_PACKET*2)
+
++int yywrap(void)
++{
++ return 1;
++}
+
+ typedef struct _table {
+ struct _link *out; /* output port */
+--- a/src/test/Makefile.am
++++ b/src/test/Makefile.am
+@@ -20,7 +20,7 @@ br_SOURCES = br.c
+ bw_SOURCES = bw.c
+ isp_SOURCES = isp.c isp.h ispl_y.y ispl_l.l
+ isp_XTRAS = $(LDADD)
+-isp_LDADD = $(isp_XTRAS) -lfl
++isp_LDADD = $(isp_XTRAS)
+ isp_DEPENDENCIES = $(isp_XTRAS)
+ window_SOURCES = window.c
+
+--- a/src/test/Makefile.in
++++ b/src/test/Makefile.in
+@@ -283,7 +283,7 @@ br_SOURCES = br.c
+ bw_SOURCES = bw.c
+ isp_SOURCES = isp.c isp.h ispl_y.y ispl_l.l
+ isp_XTRAS = $(LDADD)
+-isp_LDADD = $(isp_XTRAS) -lfl
++isp_LDADD = $(isp_XTRAS)
+ isp_DEPENDENCIES = $(isp_XTRAS)
+ window_SOURCES = window.c
+ CLEANFILES = errnos.inc
+--- a/src/test/ispl_l.l
++++ b/src/test/ispl_l.l
+@@ -18,6 +18,11 @@
+ #include "ispl_y.h"
+
+
++int yywrap(void)
++{
++ return 1;
++}
++
+ static int lineno = 1;
+
+ %}
+--- a/src/qgen/ql_l.l
++++ b/src/qgen/ql_l.l
+@@ -11,6 +11,11 @@
+ #include "ql_y.h"
+
+
++int yywrap(void)
++{
++ return 1;
++}
++
+ typedef struct _tree {
+ struct _tree *left,*right;
+ const char str[0];
+--- a/src/sigd/cfg_l.l
++++ b/src/sigd/cfg_l.l
+@@ -16,6 +16,10 @@
+
+ #include "cfg_y.h"
+
++int yywrap(void)
++{
++ return 1;
++}
+
+ static int lineno = 1;
+ static int token; /* f@#%ing flex doesn't grok return after BEGIN */
diff --git a/package/linux-atm/patches/.svn/text-base/300-objcopy_path.patch.svn-base b/package/linux-atm/patches/.svn/text-base/300-objcopy_path.patch.svn-base
new file mode 100644
index 0000000..4f11516
--- /dev/null
+++ b/package/linux-atm/patches/.svn/text-base/300-objcopy_path.patch.svn-base
@@ -0,0 +1,40 @@
+--- a/src/extra/Makefile.am
++++ b/src/extra/Makefile.am
+@@ -7,6 +7,8 @@ EXTRA_DIST = linux-atm.spec.in \
+ BUILT_SOURCES = pca200e.bin pca200e_ecd.bin2 sba200e_ecd.bin2
+ CLEANFILES = pca200e.bin pca200e_ecd.bin2 sba200e_ecd.bin2
+
++OBJCOPY = objcopy
++
+ install-exec-hook:
+ $(MKDIR_P) $(DESTDIR)/lib/firmware
+ $(INSTALL_DATA) $(srcdir)/pca200e.bin $(DESTDIR)/lib/firmware
+@@ -14,7 +16,7 @@ install-exec-hook:
+ $(INSTALL_DATA) $(srcdir)/sba200e_ecd.bin2 $(DESTDIR)/lib/firmware
+
+ %.bin %.bin2: %.data
+- objcopy -Iihex $< -Obinary $@.gz
++ $(OBJCOPY) -Iihex $< -Obinary $@.gz
+ gzip -n -df $@.gz
+
+
+--- a/src/extra/Makefile.in
++++ b/src/extra/Makefile.in
+@@ -187,6 +187,8 @@ CLEANFILES = pca200e.bin pca200e_ecd.bin
+ all: $(BUILT_SOURCES)
+ $(MAKE) $(AM_MAKEFLAGS) all-am
+
++OBJCOPY = objcopy
++
+ .SUFFIXES:
+ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+@@ -385,7 +387,7 @@ install-exec-hook:
+ $(INSTALL_DATA) $(srcdir)/sba200e_ecd.bin2 $(DESTDIR)/lib/firmware
+
+ %.bin %.bin2: %.data
+- objcopy -Iihex $< -Obinary $@.gz
++ $(OBJCOPY) -Iihex $< -Obinary $@.gz
+ gzip -n -df $@.gz
+
+ # Tell versions [3.59,3.63) of GNU make to not export all variables.
diff --git a/package/linux-atm/patches/.svn/text-base/400-portability_fixes.patch.svn-base b/package/linux-atm/patches/.svn/text-base/400-portability_fixes.patch.svn-base
new file mode 100644
index 0000000..462f57c
--- /dev/null
+++ b/package/linux-atm/patches/.svn/text-base/400-portability_fixes.patch.svn-base
@@ -0,0 +1,60 @@
+diff -urN linux-atm-2.5.2/src/ilmid/io.c linux-atm-2.5.2.new/src/ilmid/io.c
+--- linux-atm-2.5.2/src/ilmid/io.c 2008-01-01 01:14:50.000000000 +0100
++++ linux-atm-2.5.2.new/src/ilmid/io.c 2012-11-23 17:32:18.149268039 +0100
+@@ -48,6 +48,14 @@
+ be manually configured (after ilmid has
+ registered the "official" address) - HACK */
+
++#ifndef SUN_LEN
++# include <string.h> /* For prototype of `strlen'. */
++
++/* Evaluate to actual length of the `sockaddr_un' structure. */
++# define SUN_LEN(ptr) ((size_t) (((struct sockaddr_un *) 0)->sun_path) \
++ + strlen ((ptr)->sun_path))
++#endif
++
+ extern SysGroup *remsys;
+ extern State ilmi_state;
+ static short atm_itf = -1; /* bad value */
+diff -urN linux-atm-2.5.2/src/mpoad/io.c linux-atm-2.5.2.new/src/mpoad/io.c
+--- linux-atm-2.5.2/src/mpoad/io.c 2008-01-01 01:14:51.000000000 +0100
++++ linux-atm-2.5.2.new/src/mpoad/io.c 2012-11-23 17:34:17.745271101 +0100
+@@ -10,14 +10,7 @@
+ #include <errno.h>
+ #include <sys/ioctl.h>
+ #include <sys/param.h> /* for OPEN_MAX */
+-#if __GLIBC__ >= 2
+ #include <sys/poll.h>
+-#else /* ugly hack to make it compile on RH 4.2 - WA */
+-#include <syscall.h>
+-#include <linux/poll.h>
+-#define SYS_poll 168
+-_syscall3(int,poll,struct pollfd *,ufds,unsigned int,nfds,int,timeout);
+-#endif
+ #include <atm.h>
+ #include <linux/types.h>
+ #include <linux/atmioc.h>
+diff -urN linux-atm-2.5.2/src/sigd/atmsigd.c linux-atm-2.5.2.new/src/sigd/atmsigd.c
+--- linux-atm-2.5.2/src/sigd/atmsigd.c 2008-01-01 01:14:52.000000000 +0100
++++ linux-atm-2.5.2.new/src/sigd/atmsigd.c 2012-11-23 17:30:38.689265492 +0100
+@@ -517,7 +517,7 @@
+ exit(0);
+ }
+ }
+- (void) on_exit(trace_on_exit,NULL);
++ (void) atexit(trace_on_exit);
+ poll_loop();
+ close_all();
+ for (sig = entities; sig; sig = sig->next) stop_saal(&sig->saal);
+diff -urN linux-atm-2.5.2/src/test/align.c linux-atm-2.5.2.new/src/test/align.c
+--- linux-atm-2.5.2/src/test/align.c 2001-10-10 00:33:08.000000000 +0200
++++ linux-atm-2.5.2.new/src/test/align.c 2012-11-23 17:25:15.077257206 +0100
+@@ -24,7 +24,7 @@
+ #include <signal.h>
+ #include <sys/types.h>
+ #include <sys/socket.h>
+-#include <sys/errno.h>
++#include <errno.h>
+ #include <atm.h>
+
+
diff --git a/package/linux-atm/patches/000-debian_16.patch b/package/linux-atm/patches/000-debian_16.patch
new file mode 100644
index 0000000..4abaac0
--- /dev/null
+++ b/package/linux-atm/patches/000-debian_16.patch
@@ -0,0 +1,270 @@
+--- a/src/arpd/io.c
++++ b/src/arpd/io.c
+@@ -277,7 +277,8 @@ static void accept_new(void)
+ struct atm_qos qos;
+ ENTRY *entry;
+ VCC *vcc;
+- int fd,len,size,error;
++ int fd,error;
++ socklen_t len,size;
+
+ len = sizeof(addr);
+ if ((fd = accept(incoming,(struct sockaddr *) &addr,&len)) < 0) {
+@@ -614,7 +615,8 @@ int ip_itf_info(int number,uint32_t *ip,
+
+ int get_local(int fd,struct sockaddr_atmsvc *addr)
+ {
+- int length,result;
++ int result;
++ size_t length;
+
+ length = sizeof(struct sockaddr_atmsvc);
+ result = getsockname(fd,(struct sockaddr *) addr,&length);
+--- a/src/arpd/table.c
++++ b/src/arpd/table.c
+@@ -101,7 +101,8 @@ static void dump_vcc(VCC *vcc)
+ char addr_buf[MAX_ATM_ADDR_LEN+1];
+ char qos_buf[MAX_ATM_QOS_LEN+1];
+ struct atm_qos qos;
+- int size,sndbuf;
++ int sndbuf;
++ socklen_t size;
+
+ size = sizeof(addr);
+ if (getpeername(vcc->fd,(struct sockaddr *) &addr,&size) < 0) {
+--- a/src/ilmid/asn1/asn_int.c
++++ b/src/ilmid/asn1/asn_int.c
+@@ -185,7 +185,7 @@ FILE* f _AND_
+ AsnInt* v _AND_
+ unsigned short int indent)
+ {
+- fprintf(f,"%d", *v);
++ fprintf(f,"%ld", *v);
+ }
+
+
+@@ -370,5 +370,5 @@ FILE* f _AND_
+ UAsnInt* v _AND_
+ unsigned short int indent)
+ {
+- fprintf(f,"%u", *v);
++ fprintf(f,"%lu", *v);
+ }
+--- a/src/ilmid/asn1/asn_oid.c
++++ b/src/ilmid/asn1/asn_oid.c
+@@ -127,7 +127,7 @@ unsigned short int indent)
+ if (firstArcNum > 2)
+ firstArcNum = 2;
+
+- fprintf(f,"%u %u", firstArcNum, arcNum - (firstArcNum * 40));
++ fprintf(f,"%d %lu", firstArcNum, arcNum - (firstArcNum * 40));
+
+ for (; i < v->octetLen ; )
+ {
+@@ -136,7 +136,7 @@ unsigned short int indent)
+
+ arcNum = (arcNum << 7) + (v->octs[i] & 0x7f);
+ i++;
+- fprintf(f," %u", arcNum);
++ fprintf(f," %lu", arcNum);
+ }
+ fprintf(f,"}");
+
+--- a/src/lane/connect.c
++++ b/src/lane/connect.c
+@@ -258,7 +258,8 @@ static int
+ data_handler(const Event_t *event, void *funcdata)
+ {
+ Conn_t *tmp, *newconn;
+- int fd, nbytes;
++ int fd;
++ socklen_t nbytes;
+ static char buffer[BUFSIZE];
+ LaneControl_t *ctmp;
+ struct sockaddr_atmsvc addr;
+--- a/src/lane/connect_bus.c
++++ b/src/lane/connect_bus.c
+@@ -170,7 +170,8 @@ static int
+ data_handler(const Event_t *event, void *funcdata)
+ {
+ Conn_t *tmp, *newconn;
+- int fd, nbytes;
++ int fd;
++ socklen_t nbytes;
+ static char buffer[BUFSIZE];
+ struct sockaddr_atmsvc addr;
+
+--- a/src/lane/lane_atm.c
++++ b/src/lane/lane_atm.c
+@@ -138,7 +138,7 @@ atm_connect_back(const AtmAddr_t *our_ad
+ struct atm_blli blli;
+ struct atm_qos qos;
+ int fd, ret;
+- int len = sizeof(address);
++ socklen_t len = sizeof(address);
+
+ fd = socket(PF_ATMSVC, SOCK_DGRAM, 0);
+ if (fd <0) {
+--- a/src/lane/lecs.c
++++ b/src/lane/lecs.c
+@@ -119,7 +119,7 @@ int main(int argc, char **argv)
+ int just_dump=0;
+ fd_set fds;
+ struct sockaddr_atmsvc client;
+- int len;
++ socklen_t len;
+ unsigned char buffer[P_SIZE];
+
+ while(i!=-1) {
+--- a/src/lib/ans.c
++++ b/src/lib/ans.c
+@@ -41,7 +41,7 @@
+ static int ans(const char *text,int wanted,void *result,int res_len)
+ {
+ unsigned char answer[MAX_ANSWER];
+- unsigned char name[MAX_NAME];
++ char name[MAX_NAME];
+ unsigned char *pos,*data,*found;
+ int answer_len,name_len,data_len,found_len;
+ int questions,answers;
+--- a/src/lib/sdu2cell.c
++++ b/src/lib/sdu2cell.c
+@@ -15,7 +15,8 @@ int sdu2cell(int s,int sizes,const int *
+ {
+ struct atm_qos qos;
+ int trailer,total,cells;
+- int size,i;
++ int i;
++ socklen_t size;
+
+ size = sizeof(qos);
+ if (getsockopt(s,SOL_AAL,SO_ATMQOS,&qos,&size) < 0) return -1;
+--- a/src/lib/unix.c
++++ b/src/lib/unix.c
+@@ -63,8 +63,8 @@ int un_attach(const char *path)
+ int un_recv_connect(int s,void *buf,int size)
+ {
+ struct sockaddr_un addr;
+- int addr_size;
+ int len;
++ socklen_t addr_size;
+
+ addr_size = sizeof(addr);
+ len = recvfrom(s,buf,size,0,(struct sockaddr *) &addr,&addr_size);
+--- a/src/maint/atmtcp.c
++++ b/src/maint/atmtcp.c
+@@ -817,7 +817,8 @@ int main(int argc,char **argv)
+ }
+ else if (!strcmp(ARG,"listen") ||
+ (do_background = !strcmp(ARG,"listen-bg"))) {
+- int fd,port,addr_len;
++ int fd,port;
++ socklen_t addr_len;
+ int *fd2 = alloc_t(int);
+
+ if ((fd = socket(PF_INET,SOCK_STREAM,0)) < 0) {
+--- a/src/maint/hediag.c
++++ b/src/maint/hediag.c
+@@ -1,6 +1,7 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <unistd.h>
++#include <string.h>
+ #include <sys/ioctl.h>
+ #include <sys/types.h>
+ #include <sys/socket.h>
+--- a/src/mpoad/io.c
++++ b/src/mpoad/io.c
+@@ -521,7 +521,8 @@ static int msg_from_mps(int slot)
+ static int accept_conn(int slot)
+ {
+ struct sockaddr_atmsvc sa;
+- int i, new_fd, sa_len;
++ int i, new_fd;
++ socklen_t sa_len;
+
+ sa_len = sizeof(sa);
+ new_fd = accept(fds[slot].fd, (struct sockaddr *)&sa, &sa_len);
+--- a/src/sigd/io.c
++++ b/src/sigd/io.c
+@@ -355,7 +355,7 @@ int get_pvc(int itf,int *vci)
+ error = 0;
+ if (bind(s,(struct sockaddr *) &addr,sizeof(addr)) < 0) error = errno;
+ else {
+- int size;
++ socklen_t size;
+
+ size = sizeof(addr);
+ if (getsockname(s,(struct sockaddr *) &addr,&size) < 0)
+--- a/src/test/ttcp.c
++++ b/src/test/ttcp.c
+@@ -92,7 +92,8 @@ struct sockaddr_in frominet;
+ struct sockaddr_atmsvc satm;
+ struct atm_qos qos;
+
+-int domain, fromlen;
++int domain;
++socklen_t fromlen;
+ int fd; /* fd of network socket */
+
+ int buflen = 8 * 1024; /* length of buffer */
+@@ -466,7 +467,7 @@ int no_check = 0;
+
+ {
+ struct sockaddr_atmsvc peer;
+- int peerlen = sizeof(peer);
++ socklen_t peerlen = sizeof(peer);
+ if (getpeername(fd, (struct sockaddr *) &peer,
+ &peerlen) < 0) {
+ err("getpeername");
+@@ -498,7 +499,7 @@ int no_check = 0;
+ /* set socket buffer size */
+ #if defined(SO_SNDBUF) || defined(SO_RCVBUF)
+ if (sockbufsize) {
+- int len;
++ socklen_t len;
+
+ if (trans) {
+ /* set send socket buffer if we are transmitting */
+--- a/src/mpoad/mpcd.8
++++ b/src/mpoad/mpcd.8
+@@ -28,7 +28,7 @@ mpcd \- ATM MPOA (Multi\-Protocol Over A
+ .B ]]
+ .SH DESCRIPTION
+ MPOA client
+-.SM(MPC) is responsible for creating and receiving
++.SM (MPC) is responsible for creating and receiving
+ internetwork layer shortcuts. Using these shortcuts MPCs forward
+ unicast internetwork layer packets effectively over ATM without need
+ for routing protocols.
+@@ -43,7 +43,7 @@ accepts shortcuts and packets arriving o
+ shortcuts is done with the help of
+ .SM MPOA
+ server
+-.SM(MPS).
++.SM (MPS).
+ .PP
+ Just as the Linux
+ .SM LAN
+--- a/src/led/zeppelin.8
++++ b/src/led/zeppelin.8
+@@ -99,7 +99,7 @@ Ring and ATM parts of the ELAN, so using
+ recommended. Token Ring support has received less testing than its
+ Ethernet counterpart.
+ .SH FILES
+-.IP \fI/var/run/lec[interface number].pid\fP
++.IP \fI/var/run/lec[interface\ number].pid\fP
+ The file containing the process id of zeppelin.
+ .SH BUGS
+ John Bonham died 1980 and Led Zeppelin broke.
+--- a/src/sigd/atmsigd.conf.4
++++ b/src/sigd/atmsigd.conf.4
+@@ -125,7 +125,7 @@ a comment. The `#' character cannot be e
+ .P
+ If an option is specified in \fBatmsigd.conf\fP and on the command
+ line, the command line has priority.
+-.COMPATIBILITY
++.SH COMPATIBILITY
+ Certain options used by past versions of \fBatmsigd\fP but no longer documented
+ on the man page are still recognized and supported, but they also yield a
+ warning message. Future versions of \fBatmsigd\fP will not recognize those
diff --git a/package/linux-atm/patches/200-no_libfl.patch b/package/linux-atm/patches/200-no_libfl.patch
new file mode 100644
index 0000000..6db8779
--- /dev/null
+++ b/package/linux-atm/patches/200-no_libfl.patch
@@ -0,0 +1,179 @@
+--- a/src/qgen/Makefile.am
++++ b/src/qgen/Makefile.am
+@@ -2,7 +2,7 @@ noinst_PROGRAMS = qgen
+
+ qgen_SOURCES = common.c common.h file.c file.h first.c ql_y.y ql_l.l qgen.c \
+ qgen.h second.c third.c
+-qgen_LDADD = -lfl
++qgen_LDADD =
+
+ COMPILE = @CC_FOR_BUILD@ @CFLAGS_FOR_BUILD@
+ LINK = @CC_FOR_BUILD@ @CFLAGS_FOR_BUILD@ -o $@
+--- a/src/qgen/Makefile.in
++++ b/src/qgen/Makefile.in
+@@ -204,7 +204,7 @@ top_srcdir = @top_srcdir@
+ qgen_SOURCES = common.c common.h file.c file.h first.c ql_y.y ql_l.l qgen.c \
+ qgen.h second.c third.c
+
+-qgen_LDADD = -lfl
++qgen_LDADD =
+ COMPILE = @CC_FOR_BUILD@ @CFLAGS_FOR_BUILD@
+ LINK = @CC_FOR_BUILD@ @CFLAGS_FOR_BUILD@ -o $@
+
+--- a/src/sigd/Makefile.am
++++ b/src/sigd/Makefile.am
+@@ -8,7 +8,7 @@ atmsigd_XTRAS = mess.o $(top_builddir)/s
+ $(top_builddir)/src/q2931/qd.dump.o \
+ $(top_builddir)/src/lib/libatm.la \
+ $(top_builddir)/src/saal/libsaal.a
+-atmsigd_LDADD = $(atmsigd_XTRAS) -lfl
++atmsigd_LDADD = $(atmsigd_XTRAS)
+ atmsigd_DEPENDENCIES = mess.c $(atmsigd_XTRAS)
+
+ CLEANFILES = mess.c
+--- a/src/sigd/Makefile.in
++++ b/src/sigd/Makefile.in
+@@ -245,7 +245,7 @@ atmsigd_XTRAS = mess.o $(top_builddir)/s
+ $(top_builddir)/src/lib/libatm.la \
+ $(top_builddir)/src/saal/libsaal.a
+
+-atmsigd_LDADD = $(atmsigd_XTRAS) -lfl
++atmsigd_LDADD = $(atmsigd_XTRAS)
+ atmsigd_DEPENDENCIES = mess.c $(atmsigd_XTRAS)
+ CLEANFILES = mess.c
+ sysconf_DATA = atmsigd.conf
+--- a/src/switch/debug/debug.c
++++ b/src/switch/debug/debug.c
+@@ -20,6 +20,11 @@
+
+ #define PRV(call) ((FAB *) (call)->fab)
+
++int yywrap(void)
++{
++ return 1;
++}
++
+
+ typedef struct _fab {
+ CALL *next; /* relay.c may not keep track of calls, but WE are */
+--- a/src/switch/debug/Makefile.am
++++ b/src/switch/debug/Makefile.am
+@@ -5,7 +5,7 @@ INCLUDES = -I$(srcdir)/../../q2931
+ sw_debug_SOURCES = debug.c
+ sw_debug_XTRAS = $(top_builddir)/src/switch/libsw.a \
+ $(top_builddir)/src/lib/libatm.la
+-sw_debug_LDADD = $(sw_debug_XTRAS) -lfl
++sw_debug_LDADD = $(sw_debug_XTRAS)
+
+ sw_debug_DEPENDENCIES = $(sw_debug_XTRAS)
+
+--- a/src/switch/debug/Makefile.in
++++ b/src/switch/debug/Makefile.in
+@@ -200,7 +200,8 @@ sw_debug_SOURCES = debug.c
+ sw_debug_XTRAS = $(top_builddir)/src/switch/libsw.a \
+ $(top_builddir)/src/lib/libatm.la
+
+-sw_debug_LDADD = $(sw_debug_XTRAS) -lfl
++sw_debug_LDADD = $(sw_debug_XTRAS)
++
+ sw_debug_DEPENDENCIES = $(sw_debug_XTRAS)
+ EXTRA_DIST = demo README
+ all: all-am
+--- a/src/switch/tcp/Makefile.am
++++ b/src/switch/tcp/Makefile.am
+@@ -5,7 +5,7 @@ INCLUDES = -I$(srcdir)/../../q2931
+ sw_tcp_SOURCES = tcpsw.c
+ sw_tcp_XTRAS = $(top_builddir)/src/switch/libsw.a \
+ $(top_builddir)/src/lib/libatm.la
+-sw_tcp_LDADD = $(sw_tcp_XTRAS) -lfl
++sw_tcp_LDADD = $(sw_tcp_XTRAS)
+ sw_tcp_DEPENDENCIES = $(sw_tcp_XTRAS)
+
+ EXTRA_DIST = mkfiles README
+--- a/src/switch/tcp/Makefile.in
++++ b/src/switch/tcp/Makefile.in
+@@ -200,7 +200,7 @@ sw_tcp_SOURCES = tcpsw.c
+ sw_tcp_XTRAS = $(top_builddir)/src/switch/libsw.a \
+ $(top_builddir)/src/lib/libatm.la
+
+-sw_tcp_LDADD = $(sw_tcp_XTRAS) -lfl
++sw_tcp_LDADD = $(sw_tcp_XTRAS)
+ sw_tcp_DEPENDENCIES = $(sw_tcp_XTRAS)
+ EXTRA_DIST = mkfiles README
+ all: all-am
+--- a/src/switch/tcp/tcpsw.c
++++ b/src/switch/tcp/tcpsw.c
+@@ -35,6 +35,10 @@
+ #define MAX_PACKET (ATM_MAX_AAL5_PDU+sizeof(struct atmtcp_hdr))
+ #define BUFFER_SIZE (MAX_PACKET*2)
+
++int yywrap(void)
++{
++ return 1;
++}
+
+ typedef struct _table {
+ struct _link *out; /* output port */
+--- a/src/test/Makefile.am
++++ b/src/test/Makefile.am
+@@ -20,7 +20,7 @@ br_SOURCES = br.c
+ bw_SOURCES = bw.c
+ isp_SOURCES = isp.c isp.h ispl_y.y ispl_l.l
+ isp_XTRAS = $(LDADD)
+-isp_LDADD = $(isp_XTRAS) -lfl
++isp_LDADD = $(isp_XTRAS)
+ isp_DEPENDENCIES = $(isp_XTRAS)
+ window_SOURCES = window.c
+
+--- a/src/test/Makefile.in
++++ b/src/test/Makefile.in
+@@ -283,7 +283,7 @@ br_SOURCES = br.c
+ bw_SOURCES = bw.c
+ isp_SOURCES = isp.c isp.h ispl_y.y ispl_l.l
+ isp_XTRAS = $(LDADD)
+-isp_LDADD = $(isp_XTRAS) -lfl
++isp_LDADD = $(isp_XTRAS)
+ isp_DEPENDENCIES = $(isp_XTRAS)
+ window_SOURCES = window.c
+ CLEANFILES = errnos.inc
+--- a/src/test/ispl_l.l
++++ b/src/test/ispl_l.l
+@@ -18,6 +18,11 @@
+ #include "ispl_y.h"
+
+
++int yywrap(void)
++{
++ return 1;
++}
++
+ static int lineno = 1;
+
+ %}
+--- a/src/qgen/ql_l.l
++++ b/src/qgen/ql_l.l
+@@ -11,6 +11,11 @@
+ #include "ql_y.h"
+
+
++int yywrap(void)
++{
++ return 1;
++}
++
+ typedef struct _tree {
+ struct _tree *left,*right;
+ const char str[0];
+--- a/src/sigd/cfg_l.l
++++ b/src/sigd/cfg_l.l
+@@ -16,6 +16,10 @@
+
+ #include "cfg_y.h"
+
++int yywrap(void)
++{
++ return 1;
++}
+
+ static int lineno = 1;
+ static int token; /* f@#%ing flex doesn't grok return after BEGIN */
diff --git a/package/linux-atm/patches/300-objcopy_path.patch b/package/linux-atm/patches/300-objcopy_path.patch
new file mode 100644
index 0000000..4f11516
--- /dev/null
+++ b/package/linux-atm/patches/300-objcopy_path.patch
@@ -0,0 +1,40 @@
+--- a/src/extra/Makefile.am
++++ b/src/extra/Makefile.am
+@@ -7,6 +7,8 @@ EXTRA_DIST = linux-atm.spec.in \
+ BUILT_SOURCES = pca200e.bin pca200e_ecd.bin2 sba200e_ecd.bin2
+ CLEANFILES = pca200e.bin pca200e_ecd.bin2 sba200e_ecd.bin2
+
++OBJCOPY = objcopy
++
+ install-exec-hook:
+ $(MKDIR_P) $(DESTDIR)/lib/firmware
+ $(INSTALL_DATA) $(srcdir)/pca200e.bin $(DESTDIR)/lib/firmware
+@@ -14,7 +16,7 @@ install-exec-hook:
+ $(INSTALL_DATA) $(srcdir)/sba200e_ecd.bin2 $(DESTDIR)/lib/firmware
+
+ %.bin %.bin2: %.data
+- objcopy -Iihex $< -Obinary $@.gz
++ $(OBJCOPY) -Iihex $< -Obinary $@.gz
+ gzip -n -df $@.gz
+
+
+--- a/src/extra/Makefile.in
++++ b/src/extra/Makefile.in
+@@ -187,6 +187,8 @@ CLEANFILES = pca200e.bin pca200e_ecd.bin
+ all: $(BUILT_SOURCES)
+ $(MAKE) $(AM_MAKEFLAGS) all-am
+
++OBJCOPY = objcopy
++
+ .SUFFIXES:
+ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+@@ -385,7 +387,7 @@ install-exec-hook:
+ $(INSTALL_DATA) $(srcdir)/sba200e_ecd.bin2 $(DESTDIR)/lib/firmware
+
+ %.bin %.bin2: %.data
+- objcopy -Iihex $< -Obinary $@.gz
++ $(OBJCOPY) -Iihex $< -Obinary $@.gz
+ gzip -n -df $@.gz
+
+ # Tell versions [3.59,3.63) of GNU make to not export all variables.
diff --git a/package/linux-atm/patches/400-portability_fixes.patch b/package/linux-atm/patches/400-portability_fixes.patch
new file mode 100644
index 0000000..462f57c
--- /dev/null
+++ b/package/linux-atm/patches/400-portability_fixes.patch
@@ -0,0 +1,60 @@
+diff -urN linux-atm-2.5.2/src/ilmid/io.c linux-atm-2.5.2.new/src/ilmid/io.c
+--- linux-atm-2.5.2/src/ilmid/io.c 2008-01-01 01:14:50.000000000 +0100
++++ linux-atm-2.5.2.new/src/ilmid/io.c 2012-11-23 17:32:18.149268039 +0100
+@@ -48,6 +48,14 @@
+ be manually configured (after ilmid has
+ registered the "official" address) - HACK */
+
++#ifndef SUN_LEN
++# include <string.h> /* For prototype of `strlen'. */
++
++/* Evaluate to actual length of the `sockaddr_un' structure. */
++# define SUN_LEN(ptr) ((size_t) (((struct sockaddr_un *) 0)->sun_path) \
++ + strlen ((ptr)->sun_path))
++#endif
++
+ extern SysGroup *remsys;
+ extern State ilmi_state;
+ static short atm_itf = -1; /* bad value */
+diff -urN linux-atm-2.5.2/src/mpoad/io.c linux-atm-2.5.2.new/src/mpoad/io.c
+--- linux-atm-2.5.2/src/mpoad/io.c 2008-01-01 01:14:51.000000000 +0100
++++ linux-atm-2.5.2.new/src/mpoad/io.c 2012-11-23 17:34:17.745271101 +0100
+@@ -10,14 +10,7 @@
+ #include <errno.h>
+ #include <sys/ioctl.h>
+ #include <sys/param.h> /* for OPEN_MAX */
+-#if __GLIBC__ >= 2
+ #include <sys/poll.h>
+-#else /* ugly hack to make it compile on RH 4.2 - WA */
+-#include <syscall.h>
+-#include <linux/poll.h>
+-#define SYS_poll 168
+-_syscall3(int,poll,struct pollfd *,ufds,unsigned int,nfds,int,timeout);
+-#endif
+ #include <atm.h>
+ #include <linux/types.h>
+ #include <linux/atmioc.h>
+diff -urN linux-atm-2.5.2/src/sigd/atmsigd.c linux-atm-2.5.2.new/src/sigd/atmsigd.c
+--- linux-atm-2.5.2/src/sigd/atmsigd.c 2008-01-01 01:14:52.000000000 +0100
++++ linux-atm-2.5.2.new/src/sigd/atmsigd.c 2012-11-23 17:30:38.689265492 +0100
+@@ -517,7 +517,7 @@
+ exit(0);
+ }
+ }
+- (void) on_exit(trace_on_exit,NULL);
++ (void) atexit(trace_on_exit);
+ poll_loop();
+ close_all();
+ for (sig = entities; sig; sig = sig->next) stop_saal(&sig->saal);
+diff -urN linux-atm-2.5.2/src/test/align.c linux-atm-2.5.2.new/src/test/align.c
+--- linux-atm-2.5.2/src/test/align.c 2001-10-10 00:33:08.000000000 +0200
++++ linux-atm-2.5.2.new/src/test/align.c 2012-11-23 17:25:15.077257206 +0100
+@@ -24,7 +24,7 @@
+ #include <signal.h>
+ #include <sys/types.h>
+ #include <sys/socket.h>
+-#include <sys/errno.h>
++#include <errno.h>
+ #include <atm.h>
+
+
diff --git a/package/lua/.svn/entries b/package/lua/.svn/entries
new file mode 100644
index 0000000..d45c412
--- /dev/null
+++ b/package/lua/.svn/entries
@@ -0,0 +1,68 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/lua
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-19T15:34:28.915431Z
+33861
+hcg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+patches-host
+dir
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+6eaaa826a4aa26f6632de3e3b25a4959
+2012-10-19T15:34:28.915431Z
+33861
+hcg
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4395
+
diff --git a/package/lua/.svn/prop-base/Makefile.svn-base b/package/lua/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..f899379
--- /dev/null
+++ b/package/lua/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,13 @@
+K 9
+copyright
+V 30
+Copyright (C) 2006 OpenWrt.org
+K 7
+licence
+V 5
+GPLv2
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/lua/.svn/text-base/Makefile.svn-base b/package/lua/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..e7e011a
--- /dev/null
+++ b/package/lua/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,183 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=lua
+PKG_VERSION:=5.1.5
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://www.lua.org/ftp/ \
+ http://ftp.gwdg.de/pub/languages/lua/ \
+ http://mirrors.dotsrc.org/lua/ \
+ http://www.tecgraf.puc-rio.br/lua/ftp/
+PKG_MD5SUM:=2e115fe26e435e33b0d5c022e4490567
+PKG_BUILD_PARALLEL:=1
+
+PKG_LICENSE:=MIT
+PKG_LICENSE_FILES:=COPYRIGHT
+
+HOST_PATCH_DIR := ./patches-host
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/host-build.mk
+
+define Package/lua/Default
+ SUBMENU:=Lua
+ SECTION:=lang
+ CATEGORY:=Languages
+ TITLE:=Lua programming language
+ URL:=http://www.lua.org/
+ MAINTAINER:=Jo-Philipp Wich <jow@openwrt.org>
+endef
+
+define Package/lua/Default/description
+ Lua is a powerful light-weight programming language designed for extending
+ applications. Lua is also frequently used as a general-purpose, stand-alone
+ language. Lua is free software.
+endef
+
+define Package/liblua
+$(call Package/lua/Default)
+ SUBMENU:=
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE+= (libraries)
+endef
+
+define Package/liblua/description
+$(call Package/lua/Default/description)
+ This package contains the Lua shared libraries, needed by other programs.
+endef
+
+define Package/lua
+$(call Package/lua/Default)
+ DEPENDS:=+liblua
+ TITLE+= (interpreter)
+endef
+
+define Package/lua/description
+$(call Package/lua/Default/description)
+ This package contains the Lua language interpreter.
+endef
+
+define Package/luac
+$(call Package/lua/Default)
+ DEPENDS:=+liblua
+ TITLE+= (compiler)
+endef
+
+define Package/luac/description
+$(call Package/lua/Default/description)
+ This package contains the Lua language compiler.
+endef
+
+define Package/lua-examples
+$(call Package/lua/Default)
+ DEPENDS:=lua
+ TITLE+= (examples)
+endef
+
+define Package/lua-examples/description
+$(call Package/lua/Default/description)
+ This package contains Lua language examples.
+endef
+
+define Build/Configure
+endef
+
+TARGET_CFLAGS += -DLUA_USE_LINUX $(FPIC) -std=gnu99
+
+ifneq ($(CONFIG_USE_EGLIBC),)
+ ifeq ($(CONFIG_EGLIBC_OPTION_EGLIBC_UTMP),)
+ TARGET_CFLAGS += -DNO_GETLOGIN
+ endif
+endif
+
+define Build/Compile
+ $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
+ CC="$(TARGET_CROSS)gcc" \
+ AR="$(TARGET_CROSS)ar rcu" \
+ RANLIB="$(TARGET_CROSS)ranlib" \
+ INSTALL_ROOT=/usr \
+ CFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" \
+ MYLDFLAGS="$(TARGET_LDFLAGS)" \
+ PKG_VERSION=$(PKG_VERSION) \
+ linux
+ rm -rf $(PKG_INSTALL_DIR)
+ mkdir -p $(PKG_INSTALL_DIR)
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ INSTALL_TOP="$(PKG_INSTALL_DIR)/usr" \
+ install
+endef
+
+define Host/Configure
+ $(SED) 's,"/usr/local/","$(STAGING_DIR_HOST)/",' $(HOST_BUILD_DIR)/src/luaconf.h
+endef
+
+ifeq ($(HOST_OS),Darwin)
+ LUA_OS:=macosx
+else
+ ifeq ($(HOST_OS),FreeBSD)
+ LUA_OS:=freebsd
+ else
+ LUA_OS:=linux
+ endif
+endif
+
+define Host/Compile
+ $(MAKE) -C $(HOST_BUILD_DIR) \
+ CC="$(HOSTCC) -std=gnu99" \
+ $(LUA_OS)
+endef
+
+define Host/Install
+ $(MAKE) -C $(HOST_BUILD_DIR) \
+ INSTALL_TOP="$(STAGING_DIR_HOST)" \
+ install
+endef
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include
+ $(CP) $(PKG_INSTALL_DIR)/usr/include/lua{,lib,conf}.h $(1)/usr/include/
+ $(CP) $(PKG_INSTALL_DIR)/usr/include/lauxlib.h $(1)/usr/include/
+ $(CP) $(PKG_INSTALL_DIR)/usr/include/lnum_config.h $(1)/usr/include/
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/liblua.{a,so*} $(1)/usr/lib/
+ ln -sf liblua.so.$(PKG_VERSION) $(1)/usr/lib/liblualib.so
+ $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
+ $(CP) $(PKG_BUILD_DIR)/etc/lua.pc $(1)/usr/lib/pkgconfig/
+endef
+
+define Package/liblua/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/liblua.so.* $(1)/usr/lib/
+endef
+
+define Package/lua/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/lua $(1)/usr/bin/
+endef
+
+define Package/luac/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/luac $(1)/usr/bin/
+endef
+
+define Package/lua-examples/install
+ $(INSTALL_DIR) $(1)/usr/share/lua/examples
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/test/*.lua \
+ $(1)/usr/share/lua/examples/
+endef
+
+$(eval $(call BuildPackage,liblua))
+$(eval $(call BuildPackage,lua))
+$(eval $(call BuildPackage,luac))
+$(eval $(call BuildPackage,lua-examples))
+$(eval $(call HostBuild))
+
diff --git a/package/lua/Makefile b/package/lua/Makefile
new file mode 100644
index 0000000..e7e011a
--- /dev/null
+++ b/package/lua/Makefile
@@ -0,0 +1,183 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=lua
+PKG_VERSION:=5.1.5
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://www.lua.org/ftp/ \
+ http://ftp.gwdg.de/pub/languages/lua/ \
+ http://mirrors.dotsrc.org/lua/ \
+ http://www.tecgraf.puc-rio.br/lua/ftp/
+PKG_MD5SUM:=2e115fe26e435e33b0d5c022e4490567
+PKG_BUILD_PARALLEL:=1
+
+PKG_LICENSE:=MIT
+PKG_LICENSE_FILES:=COPYRIGHT
+
+HOST_PATCH_DIR := ./patches-host
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/host-build.mk
+
+define Package/lua/Default
+ SUBMENU:=Lua
+ SECTION:=lang
+ CATEGORY:=Languages
+ TITLE:=Lua programming language
+ URL:=http://www.lua.org/
+ MAINTAINER:=Jo-Philipp Wich <jow@openwrt.org>
+endef
+
+define Package/lua/Default/description
+ Lua is a powerful light-weight programming language designed for extending
+ applications. Lua is also frequently used as a general-purpose, stand-alone
+ language. Lua is free software.
+endef
+
+define Package/liblua
+$(call Package/lua/Default)
+ SUBMENU:=
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE+= (libraries)
+endef
+
+define Package/liblua/description
+$(call Package/lua/Default/description)
+ This package contains the Lua shared libraries, needed by other programs.
+endef
+
+define Package/lua
+$(call Package/lua/Default)
+ DEPENDS:=+liblua
+ TITLE+= (interpreter)
+endef
+
+define Package/lua/description
+$(call Package/lua/Default/description)
+ This package contains the Lua language interpreter.
+endef
+
+define Package/luac
+$(call Package/lua/Default)
+ DEPENDS:=+liblua
+ TITLE+= (compiler)
+endef
+
+define Package/luac/description
+$(call Package/lua/Default/description)
+ This package contains the Lua language compiler.
+endef
+
+define Package/lua-examples
+$(call Package/lua/Default)
+ DEPENDS:=lua
+ TITLE+= (examples)
+endef
+
+define Package/lua-examples/description
+$(call Package/lua/Default/description)
+ This package contains Lua language examples.
+endef
+
+define Build/Configure
+endef
+
+TARGET_CFLAGS += -DLUA_USE_LINUX $(FPIC) -std=gnu99
+
+ifneq ($(CONFIG_USE_EGLIBC),)
+ ifeq ($(CONFIG_EGLIBC_OPTION_EGLIBC_UTMP),)
+ TARGET_CFLAGS += -DNO_GETLOGIN
+ endif
+endif
+
+define Build/Compile
+ $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
+ CC="$(TARGET_CROSS)gcc" \
+ AR="$(TARGET_CROSS)ar rcu" \
+ RANLIB="$(TARGET_CROSS)ranlib" \
+ INSTALL_ROOT=/usr \
+ CFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" \
+ MYLDFLAGS="$(TARGET_LDFLAGS)" \
+ PKG_VERSION=$(PKG_VERSION) \
+ linux
+ rm -rf $(PKG_INSTALL_DIR)
+ mkdir -p $(PKG_INSTALL_DIR)
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ INSTALL_TOP="$(PKG_INSTALL_DIR)/usr" \
+ install
+endef
+
+define Host/Configure
+ $(SED) 's,"/usr/local/","$(STAGING_DIR_HOST)/",' $(HOST_BUILD_DIR)/src/luaconf.h
+endef
+
+ifeq ($(HOST_OS),Darwin)
+ LUA_OS:=macosx
+else
+ ifeq ($(HOST_OS),FreeBSD)
+ LUA_OS:=freebsd
+ else
+ LUA_OS:=linux
+ endif
+endif
+
+define Host/Compile
+ $(MAKE) -C $(HOST_BUILD_DIR) \
+ CC="$(HOSTCC) -std=gnu99" \
+ $(LUA_OS)
+endef
+
+define Host/Install
+ $(MAKE) -C $(HOST_BUILD_DIR) \
+ INSTALL_TOP="$(STAGING_DIR_HOST)" \
+ install
+endef
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include
+ $(CP) $(PKG_INSTALL_DIR)/usr/include/lua{,lib,conf}.h $(1)/usr/include/
+ $(CP) $(PKG_INSTALL_DIR)/usr/include/lauxlib.h $(1)/usr/include/
+ $(CP) $(PKG_INSTALL_DIR)/usr/include/lnum_config.h $(1)/usr/include/
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/liblua.{a,so*} $(1)/usr/lib/
+ ln -sf liblua.so.$(PKG_VERSION) $(1)/usr/lib/liblualib.so
+ $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
+ $(CP) $(PKG_BUILD_DIR)/etc/lua.pc $(1)/usr/lib/pkgconfig/
+endef
+
+define Package/liblua/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/liblua.so.* $(1)/usr/lib/
+endef
+
+define Package/lua/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/lua $(1)/usr/bin/
+endef
+
+define Package/luac/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/luac $(1)/usr/bin/
+endef
+
+define Package/lua-examples/install
+ $(INSTALL_DIR) $(1)/usr/share/lua/examples
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/test/*.lua \
+ $(1)/usr/share/lua/examples/
+endef
+
+$(eval $(call BuildPackage,liblua))
+$(eval $(call BuildPackage,lua))
+$(eval $(call BuildPackage,luac))
+$(eval $(call BuildPackage,lua-examples))
+$(eval $(call HostBuild))
+
diff --git a/package/lua/patches-host/.svn/entries b/package/lua/patches-host/.svn/entries
new file mode 100644
index 0000000..f8e6279
--- /dev/null
+++ b/package/lua/patches-host/.svn/entries
@@ -0,0 +1,198 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/lua/patches-host
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-10T20:44:22.046139Z
+33715
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+030-archindependent-bytecode.patch
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+6b38446b0ffa9ee7ddc3b0b26377ce2b
+2012-10-10T20:44:22.046139Z
+33715
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2306
+
+010-lua-5.1.3-lnum-full-260308.patch
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+cafe42fc70c953a4db32c49abf40d515
+2012-10-10T20:44:22.046139Z
+33715
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+117861
+
+011-lnum-use-double.patch
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+f71cc92df350f29d1e2aa1c309e10379
+2010-10-07T11:03:18.001599Z
+23284
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+324
+
+100-no_readline.patch
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+d8a85fc4aa0780d9f2d9d88255b66c1d
+2009-10-28T13:56:33.110578Z
+18195
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1428
+
+015-lnum-ppc-compat.patch
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+17e1ebbbc2aad43a211fe9319a15f4b1
+2012-10-10T20:44:22.046139Z
+33715
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+286
+
diff --git a/package/lua/patches-host/.svn/text-base/010-lua-5.1.3-lnum-full-260308.patch.svn-base b/package/lua/patches-host/.svn/text-base/010-lua-5.1.3-lnum-full-260308.patch.svn-base
new file mode 100644
index 0000000..74b8c6f
--- /dev/null
+++ b/package/lua/patches-host/.svn/text-base/010-lua-5.1.3-lnum-full-260308.patch.svn-base
@@ -0,0 +1,3736 @@
+--- a/src/Makefile
++++ b/src/Makefile
+@@ -25,7 +25,7 @@ PLATS= aix ansi bsd freebsd generic linu
+ LUA_A= liblua.a
+ CORE_O= lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o \
+ lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o \
+- lundump.o lvm.o lzio.o
++ lundump.o lvm.o lzio.o lnum.o
+ LIB_O= lauxlib.o lbaselib.o ldblib.o liolib.o lmathlib.o loslib.o ltablib.o \
+ lstrlib.o loadlib.o linit.o
+
+@@ -148,6 +148,7 @@ llex.o: llex.c lua.h luaconf.h ldo.h lob
+ lmathlib.o: lmathlib.c lua.h luaconf.h lauxlib.h lualib.h
+ lmem.o: lmem.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h \
+ ltm.h lzio.h lmem.h ldo.h
++lnum.o: lnum.c lua.h llex.h lnum.h
+ loadlib.o: loadlib.c lua.h luaconf.h lauxlib.h lualib.h
+ lobject.o: lobject.c lua.h luaconf.h ldo.h lobject.h llimits.h lstate.h \
+ ltm.h lzio.h lmem.h lstring.h lgc.h lvm.h
+@@ -179,4 +180,18 @@ lzio.o: lzio.c lua.h luaconf.h llimits.h
+ print.o: print.c ldebug.h lstate.h lua.h luaconf.h lobject.h llimits.h \
+ ltm.h lzio.h lmem.h lopcodes.h lundump.h
+
++luaconf.h: lnum_config.h
++lapi.c: lnum.h
++lauxlib.c: llimits.h
++lbaselib.c: llimits.h lobject.h lapi.h
++lcode.c: lnum.h
++liolib.c: lnum.h llex.h
++llex.c: lnum.h
++lnum.h: lobject.h
++lobject.c: llex.h lnum.h
++ltable.c: lnum.h
++lua.c: llimits.h
++lvm.c: llex.h lnum.h
++print.c: lnum.h
++
+ # (end of Makefile)
+--- a/src/lapi.c
++++ b/src/lapi.c
+@@ -28,7 +28,7 @@
+ #include "ltm.h"
+ #include "lundump.h"
+ #include "lvm.h"
+-
++#include "lnum.h"
+
+
+ const char lua_ident[] =
+@@ -241,12 +241,13 @@ LUA_API void lua_pushvalue (lua_State *L
+
+ LUA_API int lua_type (lua_State *L, int idx) {
+ StkId o = index2adr(L, idx);
+- return (o == luaO_nilobject) ? LUA_TNONE : ttype(o);
++ return (o == luaO_nilobject) ? LUA_TNONE : ttype_ext(o);
+ }
+
+
+ LUA_API const char *lua_typename (lua_State *L, int t) {
+ UNUSED(L);
++ lua_assert( t!= LUA_TINT );
+ return (t == LUA_TNONE) ? "no value" : luaT_typenames[t];
+ }
+
+@@ -264,6 +265,14 @@ LUA_API int lua_isnumber (lua_State *L,
+ }
+
+
++LUA_API int lua_isinteger (lua_State *L, int idx) {
++ TValue tmp;
++ lua_Integer dum;
++ const TValue *o = index2adr(L, idx);
++ return tonumber(o,&tmp) && (ttisint(o) || tt_integer_valued(o,&dum));
++}
++
++
+ LUA_API int lua_isstring (lua_State *L, int idx) {
+ int t = lua_type(L, idx);
+ return (t == LUA_TSTRING || t == LUA_TNUMBER);
+@@ -309,31 +318,66 @@ LUA_API int lua_lessthan (lua_State *L,
+ }
+
+
+-
+ LUA_API lua_Number lua_tonumber (lua_State *L, int idx) {
+ TValue n;
+ const TValue *o = index2adr(L, idx);
+- if (tonumber(o, &n))
++ if (tonumber(o, &n)) {
++#ifdef LNUM_COMPLEX
++ if (nvalue_img(o) != 0)
++ luaG_runerror(L, "expecting a real number");
++#endif
+ return nvalue(o);
+- else
+- return 0;
++ }
++ return 0;
+ }
+
+
+ LUA_API lua_Integer lua_tointeger (lua_State *L, int idx) {
+ TValue n;
++ /* Lua 5.1 documented behaviour is to return nonzero for non-integer:
++ * "If the number is not an integer, it is truncated in some non-specified way."
++ * I would suggest to change this, to return 0 for anything that would
++ * not fit in 'lua_Integer'.
++ */
++#ifdef LUA_COMPAT_TOINTEGER
++ /* Lua 5.1 compatible */
+ const TValue *o = index2adr(L, idx);
+ if (tonumber(o, &n)) {
+- lua_Integer res;
+- lua_Number num = nvalue(o);
+- lua_number2integer(res, num);
+- return res;
++ lua_Integer i;
++ lua_Number d;
++ if (ttisint(o)) return ivalue(o);
++ d= nvalue_fast(o);
++# ifdef LNUM_COMPLEX
++ if (nvalue_img_fast(o) != 0)
++ luaG_runerror(L, "expecting a real number");
++# endif
++ lua_number2integer(i, d);
++ return i;
+ }
+- else
+- return 0;
++#else
++ /* New suggestion */
++ const TValue *o = index2adr(L, idx);
++ if (tonumber(o, &n)) {
++ lua_Integer i;
++ if (ttisint(o)) return ivalue(o);
++ if (tt_integer_valued(o,&i)) return i;
++ }
++#endif
++ return 0;
+ }
+
+
++#ifdef LNUM_COMPLEX
++LUA_API lua_Complex lua_tocomplex (lua_State *L, int idx) {
++ TValue tmp;
++ const TValue *o = index2adr(L, idx);
++ if (tonumber(o, &tmp))
++ return nvalue_complex(o);
++ return 0;
++}
++#endif
++
++
+ LUA_API int lua_toboolean (lua_State *L, int idx) {
+ const TValue *o = index2adr(L, idx);
+ return !l_isfalse(o);
+@@ -364,6 +408,7 @@ LUA_API size_t lua_objlen (lua_State *L,
+ case LUA_TSTRING: return tsvalue(o)->len;
+ case LUA_TUSERDATA: return uvalue(o)->len;
+ case LUA_TTABLE: return luaH_getn(hvalue(o));
++ case LUA_TINT:
+ case LUA_TNUMBER: {
+ size_t l;
+ lua_lock(L); /* `luaV_tostring' may create a new string */
+@@ -426,6 +471,8 @@ LUA_API void lua_pushnil (lua_State *L)
+ }
+
+
++/* 'lua_pushnumber()' may lose accuracy on integers, 'lua_pushinteger' will not.
++ */
+ LUA_API void lua_pushnumber (lua_State *L, lua_Number n) {
+ lua_lock(L);
+ setnvalue(L->top, n);
+@@ -434,12 +481,22 @@ LUA_API void lua_pushnumber (lua_State *
+ }
+
+
+-LUA_API void lua_pushinteger (lua_State *L, lua_Integer n) {
++LUA_API void lua_pushinteger (lua_State *L, lua_Integer i) {
++ lua_lock(L);
++ setivalue(L->top, i);
++ api_incr_top(L);
++ lua_unlock(L);
++}
++
++
++#ifdef LNUM_COMPLEX
++LUA_API void lua_pushcomplex (lua_State *L, lua_Complex v) {
+ lua_lock(L);
+- setnvalue(L->top, cast_num(n));
++ setnvalue_complex( L->top, v );
+ api_incr_top(L);
+ lua_unlock(L);
+ }
++#endif
+
+
+ LUA_API void lua_pushlstring (lua_State *L, const char *s, size_t len) {
+@@ -569,7 +626,7 @@ LUA_API void lua_rawgeti (lua_State *L,
+ lua_lock(L);
+ o = index2adr(L, idx);
+ api_check(L, ttistable(o));
+- setobj2s(L, L->top, luaH_getnum(hvalue(o), n));
++ setobj2s(L, L->top, luaH_getint(hvalue(o), n));
+ api_incr_top(L);
+ lua_unlock(L);
+ }
+@@ -597,6 +654,9 @@ LUA_API int lua_getmetatable (lua_State
+ case LUA_TUSERDATA:
+ mt = uvalue(obj)->metatable;
+ break;
++ case LUA_TINT:
++ mt = G(L)->mt[LUA_TNUMBER];
++ break;
+ default:
+ mt = G(L)->mt[ttype(obj)];
+ break;
+@@ -687,7 +747,7 @@ LUA_API void lua_rawseti (lua_State *L,
+ api_checknelems(L, 1);
+ o = index2adr(L, idx);
+ api_check(L, ttistable(o));
+- setobj2t(L, luaH_setnum(L, hvalue(o), n), L->top-1);
++ setobj2t(L, luaH_setint(L, hvalue(o), n), L->top-1);
+ luaC_barriert(L, hvalue(o), L->top-1);
+ L->top--;
+ lua_unlock(L);
+@@ -721,7 +781,7 @@ LUA_API int lua_setmetatable (lua_State
+ break;
+ }
+ default: {
+- G(L)->mt[ttype(obj)] = mt;
++ G(L)->mt[ttype_ext(obj)] = mt;
+ break;
+ }
+ }
+@@ -1085,3 +1145,32 @@ LUA_API const char *lua_setupvalue (lua_
+ return name;
+ }
+
++
++/* Help function for 'luaB_tonumber()', avoids multiple str->number
++ * conversions for Lua "tonumber()".
++ *
++ * Also pushes floating point numbers with integer value as integer, which
++ * can be used by 'tonumber()' in scripts to bring values back to integer
++ * realm.
++ *
++ * Note: The 'back to integer realm' is _not_ to affect string conversions:
++ * 'tonumber("4294967295.1")' should give a floating point value, although
++ * the value would be 4294967296 (and storable in int64 realm).
++ */
++int lua_pushvalue_as_number (lua_State *L, int idx)
++{
++ const TValue *o = index2adr(L, idx);
++ TValue tmp;
++ lua_Integer i;
++ if (ttisnumber(o)) {
++ if ( (!ttisint(o)) && tt_integer_valued(o,&i)) {
++ lua_pushinteger( L, i );
++ return 1;
++ }
++ } else if (!tonumber(o, &tmp)) {
++ return 0;
++ }
++ if (ttisint(o)) lua_pushinteger( L, ivalue(o) );
++ else lua_pushnumber( L, nvalue_fast(o) );
++ return 1;
++}
+--- a/src/lapi.h
++++ b/src/lapi.h
+@@ -13,4 +13,6 @@
+
+ LUAI_FUNC void luaA_pushobject (lua_State *L, const TValue *o);
+
++int lua_pushvalue_as_number (lua_State *L, int idx);
++
+ #endif
+--- a/src/lauxlib.c
++++ b/src/lauxlib.c
+@@ -23,7 +23,7 @@
+ #include "lua.h"
+
+ #include "lauxlib.h"
+-
++#include "llimits.h"
+
+ #define FREELIST_REF 0 /* free list of references */
+
+@@ -66,7 +66,7 @@ LUALIB_API int luaL_typerror (lua_State
+
+
+ static void tag_error (lua_State *L, int narg, int tag) {
+- luaL_typerror(L, narg, lua_typename(L, tag));
++ luaL_typerror(L, narg, tag==LUA_TINT ? "integer" : lua_typename(L, tag));
+ }
+
+
+@@ -188,8 +188,8 @@ LUALIB_API lua_Number luaL_optnumber (lu
+
+ LUALIB_API lua_Integer luaL_checkinteger (lua_State *L, int narg) {
+ lua_Integer d = lua_tointeger(L, narg);
+- if (d == 0 && !lua_isnumber(L, narg)) /* avoid extra test when d is not 0 */
+- tag_error(L, narg, LUA_TNUMBER);
++ if (d == 0 && !lua_isinteger(L, narg)) /* avoid extra test when d is not 0 */
++ tag_error(L, narg, LUA_TINT);
+ return d;
+ }
+
+@@ -200,6 +200,16 @@ LUALIB_API lua_Integer luaL_optinteger (
+ }
+
+
++#ifdef LNUM_COMPLEX
++LUALIB_API lua_Complex luaL_checkcomplex (lua_State *L, int narg) {
++ lua_Complex c = lua_tocomplex(L, narg);
++ if (c == 0 && !lua_isnumber(L, narg)) /* avoid extra test when c is not 0 */
++ tag_error(L, narg, LUA_TNUMBER);
++ return c;
++}
++#endif
++
++
+ LUALIB_API int luaL_getmetafield (lua_State *L, int obj, const char *event) {
+ if (!lua_getmetatable(L, obj)) /* no metatable? */
+ return 0;
+--- a/src/lauxlib.h
++++ b/src/lauxlib.h
+@@ -57,6 +57,12 @@ LUALIB_API lua_Number (luaL_optnumber) (
+ LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int numArg);
+ LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int nArg,
+ lua_Integer def);
++#define luaL_checkint32(L,narg) ((int)luaL_checkinteger(L,narg))
++#define luaL_optint32(L,narg,def) ((int)luaL_optinteger(L,narg,def))
++
++#ifdef LNUM_COMPLEX
++ LUALIB_API lua_Complex (luaL_checkcomplex) (lua_State *L, int narg);
++#endif
+
+ LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg);
+ LUALIB_API void (luaL_checktype) (lua_State *L, int narg, int t);
+--- a/src/lbaselib.c
++++ b/src/lbaselib.c
+@@ -18,7 +18,9 @@
+
+ #include "lauxlib.h"
+ #include "lualib.h"
+-
++#include "llimits.h"
++#include "lobject.h"
++#include "lapi.h"
+
+
+
+@@ -54,20 +56,25 @@ static int luaB_tonumber (lua_State *L)
+ int base = luaL_optint(L, 2, 10);
+ if (base == 10) { /* standard conversion */
+ luaL_checkany(L, 1);
+- if (lua_isnumber(L, 1)) {
+- lua_pushnumber(L, lua_tonumber(L, 1));
++ if (lua_isnumber(L, 1)) { /* numeric string, or a number */
++ lua_pushvalue_as_number(L,1); /* API extension (not to lose accuracy here) */
+ return 1;
+- }
++ }
+ }
+ else {
+ const char *s1 = luaL_checkstring(L, 1);
+ char *s2;
+- unsigned long n;
++ unsigned LUA_INTEGER n;
+ luaL_argcheck(L, 2 <= base && base <= 36, 2, "base out of range");
+- n = strtoul(s1, &s2, base);
++ n = lua_str2ul(s1, &s2, base);
+ if (s1 != s2) { /* at least one valid digit? */
+ while (isspace((unsigned char)(*s2))) s2++; /* skip trailing spaces */
+ if (*s2 == '\0') { /* no invalid trailing characters? */
++
++ /* Push as number, there needs to be separate 'luaB_tointeger' for
++ * when the caller wants to preserve the bits (matters if unsigned
++ * values are used).
++ */
+ lua_pushnumber(L, (lua_Number)n);
+ return 1;
+ }
+@@ -144,7 +151,7 @@ static int luaB_setfenv (lua_State *L) {
+ luaL_checktype(L, 2, LUA_TTABLE);
+ getfunc(L, 0);
+ lua_pushvalue(L, 2);
+- if (lua_isnumber(L, 1) && lua_tonumber(L, 1) == 0) {
++ if (lua_isnumber(L, 1) && lua_tointeger(L, 1) == 0) {
+ /* change environment of current thread */
+ lua_pushthread(L);
+ lua_insert(L, -2);
+@@ -209,7 +216,7 @@ static int luaB_collectgarbage (lua_Stat
+ return 1;
+ }
+ default: {
+- lua_pushnumber(L, res);
++ lua_pushinteger(L, res);
+ return 1;
+ }
+ }
+@@ -631,6 +638,8 @@ static void base_open (lua_State *L) {
+ luaL_register(L, "_G", base_funcs);
+ lua_pushliteral(L, LUA_VERSION);
+ lua_setglobal(L, "_VERSION"); /* set global _VERSION */
++ lua_pushliteral(L, LUA_LNUM);
++ lua_setglobal(L, "_LNUM"); /* "[complex] double|float|ldouble int32|int64" */
+ /* `ipairs' and `pairs' need auxiliary functions as upvalues */
+ auxopen(L, "ipairs", luaB_ipairs, ipairsaux);
+ auxopen(L, "pairs", luaB_pairs, luaB_next);
+--- a/src/lcode.c
++++ b/src/lcode.c
+@@ -22,13 +22,18 @@
+ #include "lopcodes.h"
+ #include "lparser.h"
+ #include "ltable.h"
++#include "lnum.h"
+
+
+ #define hasjumps(e) ((e)->t != (e)->f)
+
+-
+ static int isnumeral(expdesc *e) {
+- return (e->k == VKNUM && e->t == NO_JUMP && e->f == NO_JUMP);
++ int ek=
++#ifdef LNUM_COMPLEX
++ (e->k == VKNUM2) ||
++#endif
++ (e->k == VKINT) || (e->k == VKNUM);
++ return (ek && e->t == NO_JUMP && e->f == NO_JUMP);
+ }
+
+
+@@ -231,12 +236,16 @@ static int addk (FuncState *fs, TValue *
+ TValue *idx = luaH_set(L, fs->h, k);
+ Proto *f = fs->f;
+ int oldsize = f->sizek;
+- if (ttisnumber(idx)) {
+- lua_assert(luaO_rawequalObj(&fs->f->k[cast_int(nvalue(idx))], v));
+- return cast_int(nvalue(idx));
++ if (ttype(idx)==LUA_TNUMBER) {
++ luai_normalize(idx);
++ lua_assert( ttype(idx)==LUA_TINT ); /* had no fraction */
++ }
++ if (ttisint(idx)) {
++ lua_assert(luaO_rawequalObj(&fs->f->k[ivalue(idx)], v));
++ return cast_int(ivalue(idx));
+ }
+ else { /* constant not found; create a new entry */
+- setnvalue(idx, cast_num(fs->nk));
++ setivalue(idx, fs->nk);
+ luaM_growvector(L, f->k, fs->nk, f->sizek, TValue,
+ MAXARG_Bx, "constant table overflow");
+ while (oldsize < f->sizek) setnilvalue(&f->k[oldsize++]);
+@@ -261,6 +270,21 @@ int luaK_numberK (FuncState *fs, lua_Num
+ }
+
+
++int luaK_integerK (FuncState *fs, lua_Integer r) {
++ TValue o;
++ setivalue(&o, r);
++ return addk(fs, &o, &o);
++}
++
++
++#ifdef LNUM_COMPLEX
++static int luaK_imagK (FuncState *fs, lua_Number r) {
++ TValue o;
++ setnvalue_complex(&o, r*I);
++ return addk(fs, &o, &o);
++}
++#endif
++
+ static int boolK (FuncState *fs, int b) {
+ TValue o;
+ setbvalue(&o, b);
+@@ -359,6 +383,16 @@ static void discharge2reg (FuncState *fs
+ luaK_codeABx(fs, OP_LOADK, reg, luaK_numberK(fs, e->u.nval));
+ break;
+ }
++ case VKINT: {
++ luaK_codeABx(fs, OP_LOADK, reg, luaK_integerK(fs, e->u.ival));
++ break;
++ }
++#ifdef LNUM_COMPLEX
++ case VKNUM2: {
++ luaK_codeABx(fs, OP_LOADK, reg, luaK_imagK(fs, e->u.nval));
++ break;
++ }
++#endif
+ case VRELOCABLE: {
+ Instruction *pc = &getcode(fs, e);
+ SETARG_A(*pc, reg);
+@@ -444,6 +478,10 @@ void luaK_exp2val (FuncState *fs, expdes
+ int luaK_exp2RK (FuncState *fs, expdesc *e) {
+ luaK_exp2val(fs, e);
+ switch (e->k) {
++#ifdef LNUM_COMPLEX
++ case VKNUM2:
++#endif
++ case VKINT:
+ case VKNUM:
+ case VTRUE:
+ case VFALSE:
+@@ -451,6 +489,10 @@ int luaK_exp2RK (FuncState *fs, expdesc
+ if (fs->nk <= MAXINDEXRK) { /* constant fit in RK operand? */
+ e->u.s.info = (e->k == VNIL) ? nilK(fs) :
+ (e->k == VKNUM) ? luaK_numberK(fs, e->u.nval) :
++ (e->k == VKINT) ? luaK_integerK(fs, e->u.ival) :
++#ifdef LNUM_COMPLEX
++ (e->k == VKNUM2) ? luaK_imagK(fs, e->u.nval) :
++#endif
+ boolK(fs, (e->k == VTRUE));
+ e->k = VK;
+ return RKASK(e->u.s.info);
+@@ -540,7 +582,10 @@ void luaK_goiftrue (FuncState *fs, expde
+ int pc; /* pc of last jump */
+ luaK_dischargevars(fs, e);
+ switch (e->k) {
+- case VK: case VKNUM: case VTRUE: {
++#ifdef LNUM_COMPLEX
++ case VKNUM2:
++#endif
++ case VKINT: case VK: case VKNUM: case VTRUE: {
+ pc = NO_JUMP; /* always true; do nothing */
+ break;
+ }
+@@ -590,7 +635,10 @@ static void codenot (FuncState *fs, expd
+ e->k = VTRUE;
+ break;
+ }
+- case VK: case VKNUM: case VTRUE: {
++#ifdef LNUM_COMPLEX
++ case VKNUM2:
++#endif
++ case VKINT: case VK: case VKNUM: case VTRUE: {
+ e->k = VFALSE;
+ break;
+ }
+@@ -626,25 +674,70 @@ void luaK_indexed (FuncState *fs, expdes
+
+ static int constfolding (OpCode op, expdesc *e1, expdesc *e2) {
+ lua_Number v1, v2, r;
++ int vkres= VKNUM;
+ if (!isnumeral(e1) || !isnumeral(e2)) return 0;
+- v1 = e1->u.nval;
+- v2 = e2->u.nval;
++
++ /* real and imaginary parts don't mix. */
++#ifdef LNUM_COMPLEX
++ if (e1->k == VKNUM2) {
++ if ((op != OP_UNM) && (e2->k != VKNUM2)) return 0;
++ vkres= VKNUM2; }
++ else if (e2->k == VKNUM2) { return 0; }
++#endif
++ if ((e1->k == VKINT) && (e2->k == VKINT)) {
++ lua_Integer i1= e1->u.ival, i2= e2->u.ival;
++ lua_Integer rr;
++ int done= 0;
++ /* Integer/integer calculations (may end up producing floating point) */
++ switch (op) {
++ case OP_ADD: done= try_addint( &rr, i1, i2 ); break;
++ case OP_SUB: done= try_subint( &rr, i1, i2 ); break;
++ case OP_MUL: done= try_mulint( &rr, i1, i2 ); break;
++ case OP_DIV: done= try_divint( &rr, i1, i2 ); break;
++ case OP_MOD: done= try_modint( &rr, i1, i2 ); break;
++ case OP_POW: done= try_powint( &rr, i1, i2 ); break;
++ case OP_UNM: done= try_unmint( &rr, i1 ); break;
++ default: done= 0; break;
++ }
++ if (done) {
++ e1->u.ival = rr; /* remained within integer range */
++ return 1;
++ }
++ }
++ v1 = (e1->k == VKINT) ? ((lua_Number)e1->u.ival) : e1->u.nval;
++ v2 = (e2->k == VKINT) ? ((lua_Number)e2->u.ival) : e2->u.nval;
++
+ switch (op) {
+ case OP_ADD: r = luai_numadd(v1, v2); break;
+ case OP_SUB: r = luai_numsub(v1, v2); break;
+- case OP_MUL: r = luai_nummul(v1, v2); break;
++ case OP_MUL:
++#ifdef LNUM_COMPLEX
++ if (vkres==VKNUM2) return 0; /* leave to runtime (could do here, but not worth it?) */
++#endif
++ r = luai_nummul(v1, v2); break;
+ case OP_DIV:
+ if (v2 == 0) return 0; /* do not attempt to divide by 0 */
+- r = luai_numdiv(v1, v2); break;
++#ifdef LNUM_COMPLEX
++ if (vkres==VKNUM2) return 0; /* leave to runtime */
++#endif
++ r = luai_numdiv(v1, v2); break;
+ case OP_MOD:
+ if (v2 == 0) return 0; /* do not attempt to divide by 0 */
++#ifdef LNUM_COMPLEX
++ if (vkres==VKNUM2) return 0; /* leave to runtime */
++#endif
+ r = luai_nummod(v1, v2); break;
+- case OP_POW: r = luai_numpow(v1, v2); break;
++ case OP_POW:
++#ifdef LNUM_COMPLEX
++ if (vkres==VKNUM2) return 0; /* leave to runtime */
++#endif
++ r = luai_numpow(v1, v2); break;
+ case OP_UNM: r = luai_numunm(v1); break;
+ case OP_LEN: return 0; /* no constant folding for 'len' */
+ default: lua_assert(0); r = 0; break;
+ }
+ if (luai_numisnan(r)) return 0; /* do not attempt to produce NaN */
++ e1->k = cast(expkind,vkres);
+ e1->u.nval = r;
+ return 1;
+ }
+@@ -688,7 +781,8 @@ static void codecomp (FuncState *fs, OpC
+
+ void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e) {
+ expdesc e2;
+- e2.t = e2.f = NO_JUMP; e2.k = VKNUM; e2.u.nval = 0;
++ e2.t = e2.f = NO_JUMP; e2.k = VKINT; e2.u.ival = 0;
++
+ switch (op) {
+ case OPR_MINUS: {
+ if (!isnumeral(e))
+--- a/src/lcode.h
++++ b/src/lcode.h
+@@ -71,6 +71,6 @@ LUAI_FUNC void luaK_prefix (FuncState *f
+ LUAI_FUNC void luaK_infix (FuncState *fs, BinOpr op, expdesc *v);
+ LUAI_FUNC void luaK_posfix (FuncState *fs, BinOpr op, expdesc *v1, expdesc *v2);
+ LUAI_FUNC void luaK_setlist (FuncState *fs, int base, int nelems, int tostore);
+-
++LUAI_FUNC int luaK_integerK (FuncState *fs, lua_Integer r);
+
+ #endif
+--- a/src/ldebug.c
++++ b/src/ldebug.c
+@@ -183,7 +183,7 @@ static void collectvalidlines (lua_State
+ int *lineinfo = f->l.p->lineinfo;
+ int i;
+ for (i=0; i<f->l.p->sizelineinfo; i++)
+- setbvalue(luaH_setnum(L, t, lineinfo[i]), 1);
++ setbvalue(luaH_setint(L, t, lineinfo[i]), 1);
+ sethvalue(L, L->top, t);
+ }
+ incr_top(L);
+@@ -566,7 +566,7 @@ static int isinstack (CallInfo *ci, cons
+
+ void luaG_typeerror (lua_State *L, const TValue *o, const char *op) {
+ const char *name = NULL;
+- const char *t = luaT_typenames[ttype(o)];
++ const char *t = luaT_typenames[ttype_ext(o)];
+ const char *kind = (isinstack(L->ci, o)) ?
+ getobjname(L, L->ci, cast_int(o - L->base), &name) :
+ NULL;
+@@ -594,8 +594,8 @@ void luaG_aritherror (lua_State *L, cons
+
+
+ int luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2) {
+- const char *t1 = luaT_typenames[ttype(p1)];
+- const char *t2 = luaT_typenames[ttype(p2)];
++ const char *t1 = luaT_typenames[ttype_ext(p1)];
++ const char *t2 = luaT_typenames[ttype_ext(p2)];
+ if (t1[2] == t2[2])
+ luaG_runerror(L, "attempt to compare two %s values", t1);
+ else
+--- a/src/ldo.c
++++ b/src/ldo.c
+@@ -220,9 +220,9 @@ static StkId adjust_varargs (lua_State *
+ luaD_checkstack(L, p->maxstacksize);
+ htab = luaH_new(L, nvar, 1); /* create `arg' table */
+ for (i=0; i<nvar; i++) /* put extra arguments into `arg' table */
+- setobj2n(L, luaH_setnum(L, htab, i+1), L->top - nvar + i);
++ setobj2n(L, luaH_setint(L, htab, i+1), L->top - nvar + i);
+ /* store counter in field `n' */
+- setnvalue(luaH_setstr(L, htab, luaS_newliteral(L, "n")), cast_num(nvar));
++ setivalue(luaH_setstr(L, htab, luaS_newliteral(L, "n")), nvar);
+ }
+ #endif
+ /* move fixed parameters to final position */
+--- a/src/ldump.c
++++ b/src/ldump.c
+@@ -52,6 +52,11 @@ static void DumpNumber(lua_Number x, Dum
+ DumpVar(x,D);
+ }
+
++static void DumpInteger(lua_Integer x, DumpState* D)
++{
++ DumpVar(x,D);
++}
++
+ static void DumpVector(const void* b, int n, size_t size, DumpState* D)
+ {
+ DumpInt(n,D);
+@@ -93,8 +98,11 @@ static void DumpConstants(const Proto* f
+ DumpChar(bvalue(o),D);
+ break;
+ case LUA_TNUMBER:
+- DumpNumber(nvalue(o),D);
++ DumpNumber(nvalue_fast(o),D);
+ break;
++ case LUA_TINT:
++ DumpInteger(ivalue(o),D);
++ break;
+ case LUA_TSTRING:
+ DumpString(rawtsvalue(o),D);
+ break;
+--- a/src/liolib.c
++++ b/src/liolib.c
+@@ -9,6 +9,7 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
++#include <ctype.h>
+
+ #define liolib_c
+ #define LUA_LIB
+@@ -18,7 +19,8 @@
+ #include "lauxlib.h"
+ #include "lualib.h"
+
+-
++#include "lnum.h"
++#include "llex.h"
+
+ #define IO_INPUT 1
+ #define IO_OUTPUT 2
+@@ -269,6 +271,13 @@ static int io_lines (lua_State *L) {
+ ** =======================================================
+ */
+
++/*
++* Many problems if we intend the same 'n' format specifier (see 'file:read()')
++* to work for both FP and integer numbers, without losing their accuracy. So
++* we don't. 'n' reads numbers as floating points, 'i' as integers. Old code
++* remains valid, but won't provide full integer accuracy (this only matters
++* with float FP and/or 64-bit integers).
++*/
+
+ static int read_number (lua_State *L, FILE *f) {
+ lua_Number d;
+@@ -282,6 +291,43 @@ static int read_number (lua_State *L, FI
+ }
+ }
+
++static int read_integer (lua_State *L, FILE *f) {
++ lua_Integer i;
++ if (fscanf(f, LUA_INTEGER_SCAN, &i) == 1) {
++ lua_pushinteger(L, i);
++ return 1;
++ }
++ else return 0; /* read fails */
++}
++
++#ifdef LNUM_COMPLEX
++static int read_complex (lua_State *L, FILE *f) {
++ /* NNN / NNNi / NNN+MMMi / NNN-MMMi */
++ lua_Number a,b;
++ if (fscanf(f, LUA_NUMBER_SCAN, &a) == 1) {
++ int c=fgetc(f);
++ switch(c) {
++ case 'i':
++ lua_pushcomplex(L, a*I);
++ return 1;
++ case '+':
++ case '-':
++ /* "i" is consumed if at the end; just 'NNN+MMM' will most likely
++ * behave as if "i" was there? (TBD: test)
++ */
++ if (fscanf(f, LUA_NUMBER_SCAN "i", &b) == 1) {
++ lua_pushcomplex(L, a+ (c=='+' ? b:-b)*I);
++ return 1;
++ }
++ }
++ ungetc( c,f );
++ lua_pushnumber(L,a); /*real part only*/
++ return 1;
++ }
++ return 0; /* read fails */
++}
++#endif
++
+
+ static int test_eof (lua_State *L, FILE *f) {
+ int c = getc(f);
+@@ -355,6 +401,14 @@ static int g_read (lua_State *L, FILE *f
+ case 'n': /* number */
+ success = read_number(L, f);
+ break;
++ case 'i': /* integer (full accuracy) */
++ success = read_integer(L, f);
++ break;
++#ifdef LNUM_COMPLEX
++ case 'c': /* complex */
++ success = read_complex(L, f);
++ break;
++#endif
+ case 'l': /* line */
+ success = read_line(L, f);
+ break;
+@@ -415,9 +469,10 @@ static int g_write (lua_State *L, FILE *
+ int status = 1;
+ for (; nargs--; arg++) {
+ if (lua_type(L, arg) == LUA_TNUMBER) {
+- /* optimization: could be done exactly as for strings */
+- status = status &&
+- fprintf(f, LUA_NUMBER_FMT, lua_tonumber(L, arg)) > 0;
++ if (lua_isinteger(L,arg))
++ status = status && fprintf(f, LUA_INTEGER_FMT, lua_tointeger(L, arg)) > 0;
++ else
++ status = status && fprintf(f, LUA_NUMBER_FMT, lua_tonumber(L, arg)) > 0;
+ }
+ else {
+ size_t l;
+@@ -460,7 +515,7 @@ static int f_setvbuf (lua_State *L) {
+ static const char *const modenames[] = {"no", "full", "line", NULL};
+ FILE *f = tofile(L);
+ int op = luaL_checkoption(L, 2, NULL, modenames);
+- lua_Integer sz = luaL_optinteger(L, 3, LUAL_BUFFERSIZE);
++ size_t sz = luaL_optint32(L, 3, LUAL_BUFFERSIZE);
+ int res = setvbuf(f, NULL, mode[op], sz);
+ return pushresult(L, res == 0, NULL);
+ }
+--- a/src/llex.c
++++ b/src/llex.c
+@@ -22,6 +22,7 @@
+ #include "lstring.h"
+ #include "ltable.h"
+ #include "lzio.h"
++#include "lnum.h"
+
+
+
+@@ -34,13 +35,17 @@
+
+
+ /* ORDER RESERVED */
+-const char *const luaX_tokens [] = {
++static const char *const luaX_tokens [] = {
+ "and", "break", "do", "else", "elseif",
+ "end", "false", "for", "function", "if",
+ "in", "local", "nil", "not", "or", "repeat",
+ "return", "then", "true", "until", "while",
+ "..", "...", "==", ">=", "<=", "~=",
+ "<number>", "<name>", "<string>", "<eof>",
++ "<integer>",
++#ifdef LNUM_COMPLEX
++ "<number2>",
++#endif
+ NULL
+ };
+
+@@ -90,7 +95,11 @@ static const char *txtToken (LexState *l
+ switch (token) {
+ case TK_NAME:
+ case TK_STRING:
++ case TK_INT:
+ case TK_NUMBER:
++#ifdef LNUM_COMPLEX
++ case TK_NUMBER2:
++#endif
+ save(ls, '\0');
+ return luaZ_buffer(ls->buff);
+ default:
+@@ -175,23 +184,27 @@ static void buffreplace (LexState *ls, c
+ if (p[n] == from) p[n] = to;
+ }
+
+-
+-static void trydecpoint (LexState *ls, SemInfo *seminfo) {
++/* TK_NUMBER (/ TK_NUMBER2) */
++static int trydecpoint (LexState *ls, SemInfo *seminfo) {
+ /* format error: try to update decimal point separator */
+ struct lconv *cv = localeconv();
+ char old = ls->decpoint;
++ int ret;
+ ls->decpoint = (cv ? cv->decimal_point[0] : '.');
+ buffreplace(ls, old, ls->decpoint); /* try updated decimal separator */
+- if (!luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r)) {
++ ret= luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r, NULL);
++ if (!ret) {
+ /* format error with correct decimal point: no more options */
+ buffreplace(ls, ls->decpoint, '.'); /* undo change (for error message) */
+ luaX_lexerror(ls, "malformed number", TK_NUMBER);
+ }
++ return ret;
+ }
+
+
+-/* LUA_NUMBER */
+-static void read_numeral (LexState *ls, SemInfo *seminfo) {
++/* TK_NUMBER / TK_INT (/TK_NUMBER2) */
++static int read_numeral (LexState *ls, SemInfo *seminfo) {
++ int ret;
+ lua_assert(isdigit(ls->current));
+ do {
+ save_and_next(ls);
+@@ -202,8 +215,9 @@ static void read_numeral (LexState *ls,
+ save_and_next(ls);
+ save(ls, '\0');
+ buffreplace(ls, '.', ls->decpoint); /* follow locale for decimal point */
+- if (!luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r)) /* format error? */
+- trydecpoint(ls, seminfo); /* try to update decimal point separator */
++ ret= luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r, &seminfo->i );
++ if (!ret) return trydecpoint(ls, seminfo); /* try to update decimal point separator */
++ return ret;
+ }
+
+
+@@ -331,6 +345,7 @@ static void read_string (LexState *ls, i
+ }
+
+
++/* char / TK_* */
+ static int llex (LexState *ls, SemInfo *seminfo) {
+ luaZ_resetbuffer(ls->buff);
+ for (;;) {
+@@ -402,8 +417,7 @@ static int llex (LexState *ls, SemInfo *
+ }
+ else if (!isdigit(ls->current)) return '.';
+ else {
+- read_numeral(ls, seminfo);
+- return TK_NUMBER;
++ return read_numeral(ls, seminfo);
+ }
+ }
+ case EOZ: {
+@@ -416,8 +430,7 @@ static int llex (LexState *ls, SemInfo *
+ continue;
+ }
+ else if (isdigit(ls->current)) {
+- read_numeral(ls, seminfo);
+- return TK_NUMBER;
++ return read_numeral(ls, seminfo);
+ }
+ else if (isalpha(ls->current) || ls->current == '_') {
+ /* identifier or reserved word */
+--- a/src/llex.h
++++ b/src/llex.h
+@@ -29,19 +29,22 @@ enum RESERVED {
+ TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE,
+ /* other terminal symbols */
+ TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, TK_NUMBER,
+- TK_NAME, TK_STRING, TK_EOS
++ TK_NAME, TK_STRING, TK_EOS, TK_INT
++#ifdef LNUM_COMPLEX
++ , TK_NUMBER2 /* imaginary constants: Ni */
++#endif
+ };
+
+ /* number of reserved words */
+ #define NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1))
+
+
+-/* array with token `names' */
+-LUAI_DATA const char *const luaX_tokens [];
+-
+-
++/* SemInfo is a local data structure of 'llex.c', used for carrying a string
++ * or a number. A separate token (TK_*) will tell, how to interpret the data.
++ */
+ typedef union {
+ lua_Number r;
++ lua_Integer i;
+ TString *ts;
+ } SemInfo; /* semantics information */
+
+--- a/src/llimits.h
++++ b/src/llimits.h
+@@ -49,6 +49,7 @@ typedef LUAI_USER_ALIGNMENT_T L_Umaxalig
+
+ /* result of a `usual argument conversion' over lua_Number */
+ typedef LUAI_UACNUMBER l_uacNumber;
++typedef LUAI_UACINTEGER l_uacInteger;
+
+
+ /* internal assertions for in-house debugging */
+@@ -80,7 +81,6 @@ typedef LUAI_UACNUMBER l_uacNumber;
+ #define cast_int(i) cast(int, (i))
+
+
+-
+ /*
+ ** type for virtual-machine instructions
+ ** must be an unsigned with (at least) 4 bytes (see details in lopcodes.h)
+--- a/src/lmathlib.c
++++ b/src/lmathlib.c
+@@ -4,7 +4,6 @@
+ ** See Copyright Notice in lua.h
+ */
+
+-
+ #include <stdlib.h>
+ #include <math.h>
+
+@@ -16,113 +15,210 @@
+ #include "lauxlib.h"
+ #include "lualib.h"
+
++/* 'luai_vectpow()' as a replacement for 'cpow()'. Defined in the header; we
++ * don't intrude the code libs internal functions.
++ */
++#ifdef LNUM_COMPLEX
++# include "lnum.h"
++#endif
+
+ #undef PI
+-#define PI (3.14159265358979323846)
+-#define RADIANS_PER_DEGREE (PI/180.0)
+-
++#ifdef LNUM_FLOAT
++# define PI (3.14159265358979323846F)
++#elif defined(M_PI)
++# define PI M_PI
++#else
++# define PI (3.14159265358979323846264338327950288)
++#endif
++#define RADIANS_PER_DEGREE (PI/180)
+
++#undef HUGE
++#ifdef LNUM_FLOAT
++# define HUGE HUGE_VALF
++#elif defined(LNUM_LDOUBLE)
++# define HUGE HUGE_VALL
++#else
++# define HUGE HUGE_VAL
++#endif
+
+ static int math_abs (lua_State *L) {
+- lua_pushnumber(L, fabs(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_pushnumber(L, _LF(cabs) (luaL_checkcomplex(L,1)));
++#else
++ lua_pushnumber(L, _LF(fabs) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+ static int math_sin (lua_State *L) {
+- lua_pushnumber(L, sin(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(csin) (luaL_checkcomplex(L,1)));
++#else
++ lua_pushnumber(L, _LF(sin) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+ static int math_sinh (lua_State *L) {
+- lua_pushnumber(L, sinh(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(csinh) (luaL_checkcomplex(L,1)));
++#else
++ lua_pushnumber(L, _LF(sinh) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+ static int math_cos (lua_State *L) {
+- lua_pushnumber(L, cos(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(ccos) (luaL_checkcomplex(L,1)));
++#else
++ lua_pushnumber(L, _LF(cos) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+ static int math_cosh (lua_State *L) {
+- lua_pushnumber(L, cosh(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(ccosh) (luaL_checkcomplex(L,1)));
++#else
++ lua_pushnumber(L, _LF(cosh) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+ static int math_tan (lua_State *L) {
+- lua_pushnumber(L, tan(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(ctan) (luaL_checkcomplex(L,1)));
++#else
++ lua_pushnumber(L, _LF(tan) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+ static int math_tanh (lua_State *L) {
+- lua_pushnumber(L, tanh(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(ctanh) (luaL_checkcomplex(L,1)));
++#else
++ lua_pushnumber(L, _LF(tanh) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+ static int math_asin (lua_State *L) {
+- lua_pushnumber(L, asin(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(casin) (luaL_checkcomplex(L,1)));
++#else
++ lua_pushnumber(L, _LF(asin) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+ static int math_acos (lua_State *L) {
+- lua_pushnumber(L, acos(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(cacos) (luaL_checkcomplex(L,1)));
++#else
++ lua_pushnumber(L, _LF(acos) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+ static int math_atan (lua_State *L) {
+- lua_pushnumber(L, atan(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(catan) (luaL_checkcomplex(L,1)));
++#else
++ lua_pushnumber(L, _LF(atan) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+ static int math_atan2 (lua_State *L) {
+- lua_pushnumber(L, atan2(luaL_checknumber(L, 1), luaL_checknumber(L, 2)));
++ /* scalars only */
++ lua_pushnumber(L, _LF(atan2) (luaL_checknumber(L, 1), luaL_checknumber(L, 2)));
+ return 1;
+ }
+
+ static int math_ceil (lua_State *L) {
+- lua_pushnumber(L, ceil(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_Complex v= luaL_checkcomplex(L, 1);
++ lua_pushcomplex(L, _LF(ceil) (_LF(creal)(v)) + _LF(ceil) (_LF(cimag)(v))*I);
++#else
++ lua_pushnumber(L, _LF(ceil) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+ static int math_floor (lua_State *L) {
+- lua_pushnumber(L, floor(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_Complex v= luaL_checkcomplex(L, 1);
++ lua_pushcomplex(L, _LF(floor) (_LF(creal)(v)) + _LF(floor) (_LF(cimag)(v))*I);
++#else
++ lua_pushnumber(L, _LF(floor) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+-static int math_fmod (lua_State *L) {
+- lua_pushnumber(L, fmod(luaL_checknumber(L, 1), luaL_checknumber(L, 2)));
++static int math_fmod (lua_State *L) {
++ /* scalars only */
++ lua_pushnumber(L, _LF(fmod) (luaL_checknumber(L, 1), luaL_checknumber(L, 2)));
+ return 1;
+ }
+
+ static int math_modf (lua_State *L) {
+- double ip;
+- double fp = modf(luaL_checknumber(L, 1), &ip);
++ /* scalars only */
++ lua_Number ip;
++ lua_Number fp = _LF(modf) (luaL_checknumber(L, 1), &ip);
+ lua_pushnumber(L, ip);
+ lua_pushnumber(L, fp);
+ return 2;
+ }
+
+ static int math_sqrt (lua_State *L) {
+- lua_pushnumber(L, sqrt(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(csqrt) (luaL_checkcomplex(L,1)));
++#else
++ lua_pushnumber(L, _LF(sqrt) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+ static int math_pow (lua_State *L) {
+- lua_pushnumber(L, pow(luaL_checknumber(L, 1), luaL_checknumber(L, 2)));
++#ifdef LNUM_COMPLEX
++ /* C99 'cpow' gives somewhat inaccurate results (i.e. (-1)^2 = -1+1.2246467991474e-16i).
++ * 'luai_vectpow' smoothens such, reusing it is the reason we need to #include "lnum.h".
++ */
++ lua_pushcomplex(L, luai_vectpow(luaL_checkcomplex(L,1), luaL_checkcomplex(L,2)));
++#else
++ lua_pushnumber(L, _LF(pow) (luaL_checknumber(L, 1), luaL_checknumber(L, 2)));
++#endif
+ return 1;
+ }
+
+ static int math_log (lua_State *L) {
+- lua_pushnumber(L, log(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(clog) (luaL_checkcomplex(L,1)));
++#else
++ lua_pushnumber(L, _LF(log) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+ static int math_log10 (lua_State *L) {
+- lua_pushnumber(L, log10(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ /* Not in standard <complex.h> , but easy to calculate: log_a(x) = log_b(x) / log_b(a)
++ */
++ lua_pushcomplex(L, _LF(clog) (luaL_checkcomplex(L,1)) / _LF(log) (10));
++#else
++ lua_pushnumber(L, _LF(log10) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+ static int math_exp (lua_State *L) {
+- lua_pushnumber(L, exp(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(cexp) (luaL_checkcomplex(L,1)));
++#else
++ lua_pushnumber(L, _LF(exp) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+@@ -138,19 +234,20 @@ static int math_rad (lua_State *L) {
+
+ static int math_frexp (lua_State *L) {
+ int e;
+- lua_pushnumber(L, frexp(luaL_checknumber(L, 1), &e));
++ lua_pushnumber(L, _LF(frexp) (luaL_checknumber(L, 1), &e));
+ lua_pushinteger(L, e);
+ return 2;
+ }
+
+ static int math_ldexp (lua_State *L) {
+- lua_pushnumber(L, ldexp(luaL_checknumber(L, 1), luaL_checkint(L, 2)));
++ lua_pushnumber(L, _LF(ldexp) (luaL_checknumber(L, 1), luaL_checkint(L, 2)));
+ return 1;
+ }
+
+
+
+ static int math_min (lua_State *L) {
++ /* scalars only */
+ int n = lua_gettop(L); /* number of arguments */
+ lua_Number dmin = luaL_checknumber(L, 1);
+ int i;
+@@ -165,6 +262,7 @@ static int math_min (lua_State *L) {
+
+
+ static int math_max (lua_State *L) {
++ /* scalars only */
+ int n = lua_gettop(L); /* number of arguments */
+ lua_Number dmax = luaL_checknumber(L, 1);
+ int i;
+@@ -182,25 +280,20 @@ static int math_random (lua_State *L) {
+ /* the `%' avoids the (rare) case of r==1, and is needed also because on
+ some systems (SunOS!) `rand()' may return a value larger than RAND_MAX */
+ lua_Number r = (lua_Number)(rand()%RAND_MAX) / (lua_Number)RAND_MAX;
+- switch (lua_gettop(L)) { /* check number of arguments */
+- case 0: { /* no arguments */
+- lua_pushnumber(L, r); /* Number between 0 and 1 */
+- break;
+- }
+- case 1: { /* only upper limit */
+- int u = luaL_checkint(L, 1);
+- luaL_argcheck(L, 1<=u, 1, "interval is empty");
+- lua_pushnumber(L, floor(r*u)+1); /* int between 1 and `u' */
+- break;
+- }
+- case 2: { /* lower and upper limits */
+- int l = luaL_checkint(L, 1);
+- int u = luaL_checkint(L, 2);
+- luaL_argcheck(L, l<=u, 2, "interval is empty");
+- lua_pushnumber(L, floor(r*(u-l+1))+l); /* int between `l' and `u' */
+- break;
+- }
+- default: return luaL_error(L, "wrong number of arguments");
++ int n= lua_gettop(L); /* number of arguments */
++ if (n==0) { /* no arguments: range [0,1) */
++ lua_pushnumber(L, r);
++ } else if (n<=2) { /* int range [1,u] or [l,u] */
++ int l= n==1 ? 1 : luaL_checkint(L, 1);
++ int u = luaL_checkint(L, n);
++ int tmp;
++ lua_Number d;
++ luaL_argcheck(L, l<=u, n, "interval is empty");
++ d= _LF(floor)(r*(u-l+1));
++ lua_number2int(tmp,d);
++ lua_pushinteger(L, l+tmp);
++ } else {
++ return luaL_error(L, "wrong number of arguments");
+ }
+ return 1;
+ }
+@@ -211,6 +304,66 @@ static int math_randomseed (lua_State *L
+ return 0;
+ }
+
++/*
++* Lua 5.1 does not have acosh, asinh, atanh for scalars (not ANSI C)
++*/
++#if __STDC_VERSION__ >= 199901L
++static int math_acosh (lua_State *L) {
++# ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(cacosh) (luaL_checkcomplex(L,1)));
++# else
++ lua_pushnumber(L, _LF(acosh) (luaL_checknumber(L,1)));
++# endif
++ return 1;
++}
++static int math_asinh (lua_State *L) {
++# ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(casinh) (luaL_checkcomplex(L,1)));
++# else
++ lua_pushnumber(L, _LF(asinh) (luaL_checknumber(L,1)));
++# endif
++ return 1;
++}
++static int math_atanh (lua_State *L) {
++# ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(catanh) (luaL_checkcomplex(L,1)));
++# else
++ lua_pushnumber(L, _LF(atanh) (luaL_checknumber(L,1)));
++# endif
++ return 1;
++}
++#endif
++
++/*
++ * C99 complex functions, not covered above.
++*/
++#ifdef LNUM_COMPLEX
++static int math_arg (lua_State *L) {
++ lua_pushnumber(L, _LF(carg) (luaL_checkcomplex(L,1)));
++ return 1;
++}
++
++static int math_imag (lua_State *L) {
++ lua_pushnumber(L, _LF(cimag) (luaL_checkcomplex(L,1)));
++ return 1;
++}
++
++static int math_real (lua_State *L) {
++ lua_pushnumber(L, _LF(creal) (luaL_checkcomplex(L,1)));
++ return 1;
++}
++
++static int math_conj (lua_State *L) {
++ lua_pushcomplex(L, _LF(conj) (luaL_checkcomplex(L,1)));
++ return 1;
++}
++
++static int math_proj (lua_State *L) {
++ lua_pushcomplex(L, _LF(cproj) (luaL_checkcomplex(L,1)));
++ return 1;
++}
++#endif
++
+
+ static const luaL_Reg mathlib[] = {
+ {"abs", math_abs},
+@@ -241,6 +394,18 @@ static const luaL_Reg mathlib[] = {
+ {"sqrt", math_sqrt},
+ {"tanh", math_tanh},
+ {"tan", math_tan},
++#if __STDC_VERSION__ >= 199901L
++ {"acosh", math_acosh},
++ {"asinh", math_asinh},
++ {"atanh", math_atanh},
++#endif
++#ifdef LNUM_COMPLEX
++ {"arg", math_arg},
++ {"imag", math_imag},
++ {"real", math_real},
++ {"conj", math_conj},
++ {"proj", math_proj},
++#endif
+ {NULL, NULL}
+ };
+
+@@ -252,8 +417,10 @@ LUALIB_API int luaopen_math (lua_State *
+ luaL_register(L, LUA_MATHLIBNAME, mathlib);
+ lua_pushnumber(L, PI);
+ lua_setfield(L, -2, "pi");
+- lua_pushnumber(L, HUGE_VAL);
++ lua_pushnumber(L, HUGE);
+ lua_setfield(L, -2, "huge");
++ lua_pushinteger(L, LUA_INTEGER_MAX );
++ lua_setfield(L, -2, "hugeint");
+ #if defined(LUA_COMPAT_MOD)
+ lua_getfield(L, -1, "fmod");
+ lua_setfield(L, -2, "mod");
+--- /dev/null
++++ b/src/lnum.c
+@@ -0,0 +1,312 @@
++/*
++** $Id: lnum.c,v ... $
++** Internal number model
++** See Copyright Notice in lua.h
++*/
++
++#include <stdlib.h>
++#include <math.h>
++#include <ctype.h>
++#include <string.h>
++#include <stdio.h>
++#include <errno.h>
++
++#define lnum_c
++#define LUA_CORE
++
++#include "lua.h"
++#include "llex.h"
++#include "lnum.h"
++
++/*
++** lua_real2str converts a (non-complex) number to a string.
++** lua_str2real converts a string to a (non-complex) number.
++*/
++#define lua_real2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n))
++
++/*
++* Note: Only 'strtod()' is part of ANSI C; others are C99 and
++* may need '--std=c99' compiler setting (at least on Ubuntu 7.10).
++*
++* Visual C++ 2008 Express does not have 'strtof()', nor 'strtold()'.
++* References to '_strtold()' exist but don't compile. It seems best
++* to leave Windows users with DOUBLE only (or compile with MinGW).
++*
++* In practise, using '(long double)strtod' is a risky thing, since
++* it will cause accuracy loss in reading in numbers, and such losses
++* will pile up in later processing. Get a real 'strtold()' or don't
++* use that mode at all.
++*/
++#ifdef LNUM_DOUBLE
++# define lua_str2real strtod
++#elif defined(LNUM_FLOAT)
++# define lua_str2real strtof
++#elif defined(LNUM_LDOUBLE)
++# define lua_str2real strtold
++#endif
++
++#define lua_integer2str(s,v) sprintf((s), LUA_INTEGER_FMT, (v))
++
++/* 's' is expected to be LUAI_MAXNUMBER2STR long (enough for any number)
++*/
++void luaO_num2buf( char *s, const TValue *o )
++{
++ lua_Number n;
++ lua_assert( ttisnumber(o) );
++
++ /* Reason to handle integers differently is not only speed, but accuracy as
++ * well. We want to make any integer tostring() without roundings, at all.
++ */
++ if (ttisint(o)) {
++ lua_integer2str( s, ivalue(o) );
++ return;
++ }
++ n= nvalue_fast(o);
++ lua_real2str(s, n);
++
++#ifdef LNUM_COMPLEX
++ lua_Number n2= nvalue_img_fast(o);
++ if (n2!=0) { /* Postfix with +-Ni */
++ int re0= (n == 0);
++ char *s2= re0 ? s : strchr(s,'\0');
++ if ((!re0) && (n2>0)) *s2++= '+';
++ lua_real2str( s2, n2 );
++ strcat(s2,"i");
++ }
++#endif
++}
++
++/*
++* If a LUA_TNUMBER has integer value, give it.
++*/
++int /*bool*/ tt_integer_valued( const TValue *o, lua_Integer *ref ) {
++ lua_Number d;
++ lua_Integer i;
++
++ lua_assert( ttype(o)==LUA_TNUMBER );
++ lua_assert( ref );
++#ifdef LNUM_COMPLEX
++ if (nvalue_img_fast(o)!=0) return 0;
++#endif
++ d= nvalue_fast(o);
++ lua_number2integer(i, d);
++ if (cast_num(i) == d) {
++ *ref= i; return 1;
++ }
++ return 0;
++}
++
++/*
++ * Lua 5.1.3 (using 'strtod()') allows 0x+hex but not 0+octal. This is good,
++ * and we should NOT use 'autobase' 0 with 'strtoul[l]()' for this reason.
++ *
++ * Lua 5.1.3 allows '0x...' numbers to overflow and lose precision; this is not
++ * good. On Visual C++ 2008, 'strtod()' does not even take them in. Better to
++ * require hex values to fit 'lua_Integer' or give an error that they don't?
++ *
++ * Full hex range (0 .. 0xff..ff) is stored as integers, not to lose any bits.
++ * Numerical value of 0xff..ff will be -1, if used in calculations.
++ *
++ * Returns: TK_INT for a valid integer, '*endptr_ref' updated
++ * TK_NUMBER for seemingly numeric, to be parsed as floating point
++ * 0 for bad characters, not a number (or '0x' out of range)
++ */
++static int luaO_str2i (const char *s, lua_Integer *res, char **endptr_ref) {
++ char *endptr;
++ /* 'v' gets ULONG_MAX on possible overflow (which is > LUA_INTEGER_MAX);
++ * we don't have to check 'errno' here.
++ */
++ unsigned LUA_INTEGER v= lua_str2ul(s, &endptr, 10);
++ if (endptr == s) return 0; /* nothing numeric */
++ if (v==0 && *endptr=='x') {
++ errno= 0; /* needs to be set, 'strtoul[l]' does not clear it */
++ v= lua_str2ul(endptr+1, &endptr, 16); /* retry as hex, unsigned range */
++ if (errno==ERANGE) { /* clamped to 0xff..ff */
++#if (defined(LNUM_INT32) && !defined(LNUM_FLOAT)) || defined(LNUM_LDOUBLE)
++ return TK_NUMBER; /* Allow to be read as floating point (has more integer range) */
++#else
++ return 0; /* Reject the number */
++#endif
++ }
++ } else if ((v > LUA_INTEGER_MAX) || (*endptr && (!isspace(*endptr)))) {
++ return TK_NUMBER; /* not in signed range, or has '.', 'e' etc. trailing */
++ }
++ *res= (lua_Integer)v;
++ *endptr_ref= endptr;
++ return TK_INT;
++}
++
++/* 0 / TK_NUMBER / TK_INT (/ TK_NUMBER2) */
++int luaO_str2d (const char *s, lua_Number *res_n, lua_Integer *res_i) {
++ char *endptr;
++ int ret= TK_NUMBER;
++ /* Check integers first, if caller is allowing.
++ * If 'res2'==NULL, they're only looking for floating point.
++ */
++ if (res_i) {
++ ret= luaO_str2i(s,res_i,&endptr);
++ if (ret==0) return 0;
++ }
++ if (ret==TK_NUMBER) {
++ lua_assert(res_n);
++ /* Note: Visual C++ 2008 Express 'strtod()' does not read in "0x..."
++ * numbers; it will read '0' and spit 'x' as endptr.
++ * This means hex constants not fitting in 'lua_Integer' won't
++ * be read in at all. What to do?
++ */
++ *res_n = lua_str2real(s, &endptr);
++ if (endptr == s) return 0; /* conversion failed */
++ /* Visual C++ 2008 'strtod()' does not allow "0x..." input. */
++#if defined(_MSC_VER) && !defined(LNUM_FLOAT) && !defined(LNUM_INT64)
++ if (*res_n==0 && *endptr=='x') {
++ /* Hex constant too big for 'lua_Integer' but that could fit in 'lua_Number'
++ * integer bits
++ */
++ unsigned __int64 v= _strtoui64( s, &endptr, 16 );
++ /* We just let > 64 bit values be clamped to _UI64_MAX (MSDN does not say 'errno'==ERANGE would be set) */
++ *res_n= cast_num(v);
++ if (*res_n != v) return 0; /* Would have lost accuracy */
++ }
++#endif
++#ifdef LNUM_COMPLEX
++ if (*endptr == 'i') { endptr++; ret= TK_NUMBER2; }
++#endif
++ }
++ if (*endptr) {
++ while (isspace(cast(unsigned char, *endptr))) endptr++;
++ if (*endptr) return 0; /* invalid trail */
++ }
++ return ret;
++}
++
++
++/* Functions for finding out, when integer operations remain in range
++ * (and doing them).
++ */
++int try_addint( lua_Integer *r, lua_Integer ib, lua_Integer ic ) {
++ lua_Integer v= ib+ic; /* may overflow */
++ if (ib>0 && ic>0) { if (v < 0) return 0; /*overflow, use floats*/ }
++ else if (ib<0 && ic<0) { if (v >= 0) return 0; }
++ *r= v;
++ return 1;
++}
++
++int try_subint( lua_Integer *r, lua_Integer ib, lua_Integer ic ) {
++ lua_Integer v= ib-ic; /* may overflow */
++ if (ib>=0 && ic<0) { if (v < 0) return 0; /*overflow, use floats*/ }
++ else if (ib<0 && ic>0) { if (v >= 0) return 0; }
++ *r= v;
++ return 1;
++}
++
++int try_mulint( lua_Integer *r, lua_Integer ib, lua_Integer ic ) {
++ if (ib!=LUA_INTEGER_MIN && ic!=LUA_INTEGER_MIN) {
++ lua_Integer b= luai_abs(ib), c= luai_abs(ic);
++ if ( (ib==0) || (LUA_INTEGER_MAX/b >= c) ) {
++ *r= ib*ic; /* no overflow */
++ return 1;
++ }
++ } else if (ib==0 || ic==0) {
++ *r= 0; return 1;
++ }
++
++ /* Result can be LUA_INTEGER_MIN; if it is, calculating it using floating
++ * point will not cause accuracy loss.
++ */
++ if ( luai_nummul( cast_num(ib), cast_num(ic) ) == LUA_INTEGER_MIN ) {
++ *r= LUA_INTEGER_MIN;
++ return 1;
++ }
++ return 0;
++}
++
++int try_divint( lua_Integer *r, lua_Integer ib, lua_Integer ic ) {
++ /* N/0: leave to float side, to give an error
++ */
++ if (ic==0) return 0;
++
++ /* N/LUA_INTEGER_MIN: always non-integer results, or 0 or +1
++ */
++ if (ic==LUA_INTEGER_MIN) {
++ if (ib==LUA_INTEGER_MIN) { *r=1; return 1; }
++ if (ib==0) { *r=0; return 1; }
++
++ /* LUA_INTEGER_MIN (-2^31|63)/N: calculate using float side (either the division
++ * causes non-integer results, or there is no accuracy loss in int->fp->int
++ * conversions (N=2,4,8,..,256 and N=2^30,2^29,..2^23).
++ */
++ } else if (ib==LUA_INTEGER_MIN) {
++ lua_Number d= luai_numdiv( cast_num(LUA_INTEGER_MIN), cast_num(ic) );
++ lua_Integer i; lua_number2integer(i,d);
++ if (cast_num(i)==d) { *r= i; return 1; }
++
++ } else {
++ /* Note: We _can_ use ANSI C mod here, even on negative values, since
++ * we only test for == 0 (the sign would be implementation dependent).
++ */
++ if (ib%ic == 0) { *r= ib/ic; return 1; }
++ }
++
++ return 0;
++}
++
++int try_modint( lua_Integer *r, lua_Integer ib, lua_Integer ic ) {
++ if (ic!=0) {
++ /* ANSI C can be trusted when b%c==0, or when values are non-negative.
++ * b - (floor(b/c) * c)
++ * -->
++ * + +: b - (b/c) * c (b % c can be used)
++ * - -: b - (b/c) * c (b % c could work, but not defined by ANSI C)
++ * 0 -: b - (b/c) * c (=0, b % c could work, but not defined by ANSI C)
++ * - +: b - (b/c-1) * c (when b!=-c)
++ * + -: b - (b/c-1) * c (when b!=-c)
++ *
++ * o MIN%MIN ends up 0, via overflow in calcs but that does not matter.
++ * o MIN%MAX ends up MAX-1 (and other such numbers), also after overflow,
++ * but that does not matter, results do.
++ */
++ lua_Integer v= ib % ic;
++ if ( v!=0 && (ib<0 || ic<0) ) {
++ v= ib - ((ib/ic) - ((ib<=0 && ic<0) ? 0:1)) * ic;
++ }
++ /* Result should always have same sign as 2nd argument. (PIL2) */
++ lua_assert( (v<0) ? (ic<0) : (v>0) ? (ic>0) : 1 );
++ *r= v;
++ return 1;
++ }
++ return 0; /* let float side return NaN */
++}
++
++int try_powint( lua_Integer *r, lua_Integer ib, lua_Integer ic ) {
++
++ /* In FLOAT/INT32 or FLOAT|DOUBLE/INT64 modes, calculating integer powers
++ * via FP realm may lose accuracy (i.e. 7^11 = 1977326743, which fits int32
++ * but not 23-bit float mantissa).
++ *
++ * The current solution is dumb, but it works and uses little code. Use of
++ * integer powers is not anticipated to be very frequent (apart from 2^x,
++ * which is separately optimized).
++ */
++ if (ib==0) *r=0;
++ else if (ic<0) return 0; /* FP realm */
++ else if (ib==2 && ic < (int)sizeof(lua_Integer)*8-1) *r= ((lua_Integer)1)<<ic; /* 1,2,4,...2^30 | 2^62 optimization */
++ else if (ic==0) *r=1;
++ else if (luai_abs(ib)==1) *r= (ic%2) ? ib:1;
++ else {
++ lua_Integer x= ib;
++ while( --ic ) {
++ if (!try_mulint( &x, x, ib ))
++ return 0; /* FP realm */
++ }
++ *r= x;
++ }
++ return 1;
++}
++
++int try_unmint( lua_Integer *r, lua_Integer ib ) {
++ /* Negating LUA_INTEGER_MIN leaves the range. */
++ if ( ib != LUA_INTEGER_MIN )
++ { *r= -ib; return 1; }
++ return 0;
++}
++
+--- /dev/null
++++ b/src/lnum.h
+@@ -0,0 +1,116 @@
++/*
++** $Id: lnum.h,v ... $
++** Internal Number model
++** See Copyright Notice in lua.h
++*/
++
++#ifndef lnum_h
++#define lnum_h
++
++#include <math.h>
++
++#include "lobject.h"
++
++/*
++** The luai_num* macros define the primitive operations over 'lua_Number's
++** (not 'lua_Integer's, not 'lua_Complex').
++*/
++#define luai_numadd(a,b) ((a)+(b))
++#define luai_numsub(a,b) ((a)-(b))
++#define luai_nummul(a,b) ((a)*(b))
++#define luai_numdiv(a,b) ((a)/(b))
++#define luai_nummod(a,b) ((a) - _LF(floor)((a)/(b))*(b))
++#define luai_numpow(a,b) (_LF(pow)(a,b))
++#define luai_numunm(a) (-(a))
++#define luai_numeq(a,b) ((a)==(b))
++#define luai_numlt(a,b) ((a)<(b))
++#define luai_numle(a,b) ((a)<=(b))
++#define luai_numisnan(a) (!luai_numeq((a), (a)))
++
++int try_addint( lua_Integer *r, lua_Integer ib, lua_Integer ic );
++int try_subint( lua_Integer *r, lua_Integer ib, lua_Integer ic );
++int try_mulint( lua_Integer *r, lua_Integer ib, lua_Integer ic );
++int try_divint( lua_Integer *r, lua_Integer ib, lua_Integer ic );
++int try_modint( lua_Integer *r, lua_Integer ib, lua_Integer ic );
++int try_powint( lua_Integer *r, lua_Integer ib, lua_Integer ic );
++int try_unmint( lua_Integer *r, lua_Integer ib );
++
++#ifdef LNUM_COMPLEX
++ static inline lua_Complex luai_vectunm( lua_Complex a ) { return -a; }
++ static inline lua_Complex luai_vectadd( lua_Complex a, lua_Complex b ) { return a+b; }
++ static inline lua_Complex luai_vectsub( lua_Complex a, lua_Complex b ) { return a-b; }
++ static inline lua_Complex luai_vectmul( lua_Complex a, lua_Complex b ) { return a*b; }
++ static inline lua_Complex luai_vectdiv( lua_Complex a, lua_Complex b ) { return a/b; }
++
++/*
++ * C99 does not provide modulus for complex numbers. It most likely is not
++ * meaningful at all.
++ */
++
++/*
++ * Complex power
++ *
++ * C99 'cpow' gives inaccurate results for many common cases s.a. (1i)^2 ->
++ * -1+1.2246467991474e-16i (OS X 10.4, gcc 4.0.1 build 5367)
++ *
++ * [(a+bi)^(c+di)] = (r^c) * exp(-d*t) * cos(c*t + d*ln(r)) +
++ * = (r^c) * exp(-d*t) * sin(c*t + d*ln(r)) *i
++ * r = sqrt(a^2+b^2), t = arctan( b/a )
++ *
++ * Reference: <http://home.att.net/~srschmitt/complexnumbers.html>
++ * Could also be calculated using: x^y = exp(ln(x)*y)
++ *
++ * Note: Defined here (and not in .c) so 'lmathlib.c' can share the
++ * implementation.
++ */
++ static inline
++ lua_Complex luai_vectpow( lua_Complex a, lua_Complex b )
++ {
++# if 1
++ lua_Number ar= _LF(creal)(a), ai= _LF(cimag)(a);
++ lua_Number br= _LF(creal)(b), bi= _LF(cimag)(b);
++
++ if (ai==0 && bi==0) { /* a^c (real) */
++ return luai_numpow( ar, br );
++ }
++
++ int br_int= (int)br;
++
++ if ( ai!=0 && bi==0 && br_int==br && br_int!=0 && br_int!=INT_MIN ) {
++ /* (a+bi)^N, N = { +-1,+-2, ... +-INT_MAX }
++ */
++ lua_Number k= luai_numpow( _LF(sqrt) (ar*ar + ai*ai), br );
++ lua_Number cos_z, sin_z;
++
++ /* Situation depends upon c (N) in the following manner:
++ *
++ * N%4==0 => cos(c*t)=1, sin(c*t)=0
++ * (N*sign(b))%4==1 or (N*sign(b))%4==-3 => cos(c*t)=0, sin(c*t)=1
++ * N%4==2 or N%4==-2 => cos(c*t)=-1, sin(c*t)=0
++ * (N*sign(b))%4==-1 or (N*sign(b))%4==3 => cos(c*t)=0, sin(c*t)=-1
++ */
++ int br_int_abs = br_int<0 ? -br_int:br_int;
++
++ switch( (br_int_abs%4) * (br_int<0 ? -1:1) * (ai<0 ? -1:1) ) {
++ case 0: cos_z=1, sin_z=0; break;
++ case 2: case -2: cos_z=-1, sin_z=0; break;
++ case 1: case -3: cos_z=0, sin_z=1; break;
++ case 3: case -1: cos_z=0, sin_z=-1; break;
++ default: lua_assert(0); return 0;
++ }
++ return k*cos_z + (k*sin_z)*I;
++ }
++# endif
++ return _LF(cpow) ( a, b );
++ }
++#endif
++
++LUAI_FUNC int luaO_str2d (const char *s, lua_Number *res1, lua_Integer *res2);
++LUAI_FUNC void luaO_num2buf( char *s, const TValue *o );
++
++LUAI_FUNC int /*bool*/ tt_integer_valued( const TValue *o, lua_Integer *ref );
++
++#define luai_normalize(o) \
++{ lua_Integer _i; if (tt_integer_valued(o,&_i)) setivalue(o,_i); }
++
++#endif
+--- /dev/null
++++ b/src/lnum_config.h
+@@ -0,0 +1,221 @@
++/*
++** $Id: lnum_config.h,v ... $
++** Internal Number model
++** See Copyright Notice in lua.h
++*/
++
++#ifndef lnum_config_h
++#define lnum_config_h
++
++/*
++** Default number modes
++*/
++#if (!defined LNUM_DOUBLE) && (!defined LNUM_FLOAT) && (!defined LNUM_LDOUBLE)
++# define LNUM_FLOAT
++#endif
++#if (!defined LNUM_INT16) && (!defined LNUM_INT32) && (!defined LNUM_INT64)
++# define LNUM_INT32
++#endif
++
++/*
++** Require C99 mode for COMPLEX, FLOAT and LDOUBLE (only DOUBLE is ANSI C).
++*/
++#if defined(LNUM_COMPLEX) && (__STDC_VERSION__ < 199901L)
++# error "Need C99 for complex (use '--std=c99' or similar)"
++#elif defined(LNUM_LDOUBLE) && (__STDC_VERSION__ < 199901L) && !defined(_MSC_VER)
++# error "Need C99 for 'long double' (use '--std=c99' or similar)"
++#elif defined(LNUM_FLOAT) && (__STDC_VERSION__ < 199901L)
++/* LNUM_FLOAT not supported on Windows */
++# error "Need C99 for 'float' (use '--std=c99' or similar)"
++#endif
++
++/*
++** Number mode identifier to accompany the version string.
++*/
++#ifdef LNUM_COMPLEX
++# define _LNUM1 "complex "
++#else
++# define _LNUM1 ""
++#endif
++#ifdef LNUM_DOUBLE
++# define _LNUM2 "double"
++#elif defined(LNUM_FLOAT)
++# define _LNUM2 "float"
++#elif defined(LNUM_LDOUBLE)
++# define _LNUM2 "ldouble"
++#endif
++#ifdef LNUM_INT32
++# define _LNUM3 "int32"
++#elif defined(LNUM_INT64)
++# define _LNUM3 "int64"
++#elif defined(LNUM_INT16)
++# define _LNUM3 "int16"
++#endif
++#define LUA_LNUM _LNUM1 _LNUM2 " " _LNUM3
++
++/*
++** LUA_NUMBER is the type of floating point number in Lua
++** LUA_NUMBER_SCAN is the format for reading numbers.
++** LUA_NUMBER_FMT is the format for writing numbers.
++*/
++#ifdef LNUM_FLOAT
++# define LUA_NUMBER float
++# define LUA_NUMBER_SCAN "%f"
++# define LUA_NUMBER_FMT "%g"
++#elif (defined LNUM_DOUBLE)
++# define LUA_NUMBER double
++# define LUA_NUMBER_SCAN "%lf"
++# define LUA_NUMBER_FMT "%.14g"
++#elif (defined LNUM_LDOUBLE)
++# define LUA_NUMBER long double
++# define LUA_NUMBER_SCAN "%Lg"
++# define LUA_NUMBER_FMT "%.20Lg"
++#endif
++
++
++/*
++** LUAI_MAXNUMBER2STR: size of a buffer fitting any number->string result.
++**
++** double: 24 (sign, x.xxxxxxxxxxxxxxe+nnnn, and \0)
++** int64: 21 (19 digits, sign, and \0)
++** long double: 43 for 128-bit (sign, x.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxe+nnnn, and \0)
++** 30 for 80-bit (sign, x.xxxxxxxxxxxxxxxxxxxxe+nnnn, and \0)
++*/
++#ifdef LNUM_LDOUBLE
++# define _LUAI_MN2S 44
++#else
++# define _LUAI_MN2S 24
++#endif
++
++#ifdef LNUM_COMPLEX
++# define LUAI_MAXNUMBER2STR (2*_LUAI_MN2S)
++#else
++# define LUAI_MAXNUMBER2STR _LUAI_MN2S
++#endif
++
++/*
++** LUA_INTEGER is the integer type used by lua_pushinteger/lua_tointeger/lua_isinteger.
++** LUA_INTEGER_SCAN is the format for reading integers
++** LUA_INTEGER_FMT is the format for writing integers
++**
++** Note: Visual C++ 2005 does not have 'strtoull()', use '_strtoui64()' instead.
++*/
++#ifdef LNUM_INT32
++# if LUAI_BITSINT > 16
++# define LUA_INTEGER int
++# define LUA_INTEGER_SCAN "%d"
++# define LUA_INTEGER_FMT "%d"
++# else
++/* Note: 'LUA_INTEGER' being 'ptrdiff_t' (as in Lua 5.1) causes problems with
++ * 'printf()' operations. Also 'unsigned ptrdiff_t' is invalid.
++ */
++# define LUA_INTEGER long
++# define LUA_INTEGER_SCAN "%ld"
++# define LUA_INTEGER_FMT "%ld"
++# endif
++# define LUA_INTEGER_MAX 0x7FFFFFFF /* 2^31-1 */
++/* */
++#elif defined(LNUM_INT64)
++# define LUA_INTEGER long long
++# ifdef _MSC_VER
++# define lua_str2ul _strtoui64
++# else
++# define lua_str2ul strtoull
++# endif
++# define LUA_INTEGER_SCAN "%lld"
++# define LUA_INTEGER_FMT "%lld"
++# define LUA_INTEGER_MAX 0x7fffffffffffffffLL /* 2^63-1 */
++# define LUA_INTEGER_MIN (-LUA_INTEGER_MAX - 1LL) /* -2^63 */
++/* */
++#elif defined(LNUM_INT16)
++# if LUAI_BITSINT > 16
++# define LUA_INTEGER short
++# define LUA_INTEGER_SCAN "%hd"
++# define LUA_INTEGER_FMT "%hd"
++# else
++# define LUA_INTEGER int
++# define LUA_INTEGER_SCAN "%d"
++# define LUA_INTEGER_FMT "%d"
++# endif
++# define LUA_INTEGER_MAX 0x7FFF /* 2^16-1 */
++#endif
++
++#ifndef lua_str2ul
++# define lua_str2ul (unsigned LUA_INTEGER)strtoul
++#endif
++#ifndef LUA_INTEGER_MIN
++# define LUA_INTEGER_MIN (-LUA_INTEGER_MAX -1) /* -2^16|32 */
++#endif
++
++/*
++@@ lua_number2int is a macro to convert lua_Number to int.
++@@ lua_number2integer is a macro to convert lua_Number to lua_Integer.
++** CHANGE them if you know a faster way to convert a lua_Number to
++** int (with any rounding method and without throwing errors) in your
++** system. In Pentium machines, a naive typecast from double to int
++** in C is extremely slow, so any alternative is worth trying.
++*/
++
++/* On a Pentium, resort to a trick */
++#if defined(LNUM_DOUBLE) && !defined(LUA_ANSI) && !defined(__SSE2__) && \
++ (defined(__i386) || defined (_M_IX86) || defined(__i386__))
++
++/* On a Microsoft compiler, use assembler */
++# if defined(_MSC_VER)
++# define lua_number2int(i,d) __asm fld d __asm fistp i
++# else
++
++/* the next trick should work on any Pentium, but sometimes clashes
++ with a DirectX idiosyncrasy */
++union luai_Cast { double l_d; long l_l; };
++# define lua_number2int(i,d) \
++ { volatile union luai_Cast u; u.l_d = (d) + 6755399441055744.0; (i) = u.l_l; }
++# endif
++
++# ifndef LNUM_INT64
++# define lua_number2integer lua_number2int
++# endif
++
++/* this option always works, but may be slow */
++#else
++# define lua_number2int(i,d) ((i)=(int)(d))
++#endif
++
++/* Note: Some compilers (OS X gcc 4.0?) may choke on double->long long conversion
++ * since it can lose precision. Others do require 'long long' there.
++ */
++#ifndef lua_number2integer
++# define lua_number2integer(i,d) ((i)=(lua_Integer)(d))
++#endif
++
++/*
++** 'luai_abs()' to give absolute value of 'lua_Integer'
++*/
++#ifdef LNUM_INT32
++# define luai_abs abs
++#elif defined(LNUM_INT64) && (__STDC_VERSION__ >= 199901L)
++# define luai_abs llabs
++#else
++# define luai_abs(v) ((v) >= 0 ? (v) : -(v))
++#endif
++
++/*
++** LUAI_UACNUMBER is the result of an 'usual argument conversion' over a number.
++** LUAI_UACINTEGER the same, over an integer.
++*/
++#define LUAI_UACNUMBER double
++#define LUAI_UACINTEGER long
++
++/* ANSI C only has math funcs for 'double. C99 required for float and long double
++ * variants.
++ */
++#ifdef LNUM_DOUBLE
++# define _LF(name) name
++#elif defined(LNUM_FLOAT)
++# define _LF(name) name ## f
++#elif defined(LNUM_LDOUBLE)
++# define _LF(name) name ## l
++#endif
++
++#endif
++
+--- a/src/lobject.c
++++ b/src/lobject.c
+@@ -21,7 +21,8 @@
+ #include "lstate.h"
+ #include "lstring.h"
+ #include "lvm.h"
+-
++#include "llex.h"
++#include "lnum.h"
+
+
+ const TValue luaO_nilobject_ = {{NULL}, LUA_TNIL};
+@@ -70,12 +71,31 @@ int luaO_log2 (unsigned int x) {
+
+
+ int luaO_rawequalObj (const TValue *t1, const TValue *t2) {
+- if (ttype(t1) != ttype(t2)) return 0;
++ if (!ttype_ext_same(t1,t2)) return 0;
+ else switch (ttype(t1)) {
+ case LUA_TNIL:
+ return 1;
++ case LUA_TINT:
++ if (ttype(t2)==LUA_TINT)
++ return ivalue(t1) == ivalue(t2);
++ else { /* t1:int, t2:num */
++#ifdef LNUM_COMPLEX
++ if (nvalue_img_fast(t2) != 0) return 0;
++#endif
++ /* Avoid doing accuracy losing cast, if possible. */
++ lua_Integer tmp;
++ if (tt_integer_valued(t2,&tmp))
++ return ivalue(t1) == tmp;
++ else
++ return luai_numeq( cast_num(ivalue(t1)), nvalue_fast(t2) );
++ }
+ case LUA_TNUMBER:
+- return luai_numeq(nvalue(t1), nvalue(t2));
++ if (ttype(t2)==LUA_TINT)
++ return luaO_rawequalObj(t2, t1); /* swap LUA_TINT to left */
++#ifdef LNUM_COMPLEX
++ if (!luai_numeq(nvalue_img_fast(t1), nvalue_img_fast(t2))) return 0;
++#endif
++ return luai_numeq(nvalue_fast(t1), nvalue_fast(t2));
+ case LUA_TBOOLEAN:
+ return bvalue(t1) == bvalue(t2); /* boolean true must be 1 !! */
+ case LUA_TLIGHTUSERDATA:
+@@ -86,21 +106,6 @@ int luaO_rawequalObj (const TValue *t1,
+ }
+ }
+
+-
+-int luaO_str2d (const char *s, lua_Number *result) {
+- char *endptr;
+- *result = lua_str2number(s, &endptr);
+- if (endptr == s) return 0; /* conversion failed */
+- if (*endptr == 'x' || *endptr == 'X') /* maybe an hexadecimal constant? */
+- *result = cast_num(strtoul(s, &endptr, 16));
+- if (*endptr == '\0') return 1; /* most common case */
+- while (isspace(cast(unsigned char, *endptr))) endptr++;
+- if (*endptr != '\0') return 0; /* invalid trailing characters? */
+- return 1;
+-}
+-
+-
+-
+ static void pushstr (lua_State *L, const char *str) {
+ setsvalue2s(L, L->top, luaS_new(L, str));
+ incr_top(L);
+@@ -131,7 +136,11 @@ const char *luaO_pushvfstring (lua_State
+ break;
+ }
+ case 'd': {
+- setnvalue(L->top, cast_num(va_arg(argp, int)));
++ /* This is tricky for 64-bit integers; maybe they even cannot be
++ * supported on all compilers; depends on the conversions applied to
++ * variable argument lists. TBD: test!
++ */
++ setivalue(L->top, (lua_Integer) va_arg(argp, l_uacInteger));
+ incr_top(L);
+ break;
+ }
+@@ -212,3 +221,4 @@ void luaO_chunkid (char *out, const char
+ }
+ }
+ }
++
+--- a/src/lobject.h
++++ b/src/lobject.h
+@@ -17,7 +17,11 @@
+
+
+ /* tags for values visible from Lua */
+-#define LAST_TAG LUA_TTHREAD
++#if LUA_TINT > LUA_TTHREAD
++# define LAST_TAG LUA_TINT
++#else
++# define LAST_TAG LUA_TTHREAD
++#endif
+
+ #define NUM_TAGS (LAST_TAG+1)
+
+@@ -59,7 +63,12 @@ typedef struct GCheader {
+ typedef union {
+ GCObject *gc;
+ void *p;
++#ifdef LNUM_COMPLEX
++ lua_Complex n;
++#else
+ lua_Number n;
++#endif
++ lua_Integer i;
+ int b;
+ } Value;
+
+@@ -77,7 +86,11 @@ typedef struct lua_TValue {
+
+ /* Macros to test type */
+ #define ttisnil(o) (ttype(o) == LUA_TNIL)
+-#define ttisnumber(o) (ttype(o) == LUA_TNUMBER)
++#define ttisint(o) (ttype(o) == LUA_TINT)
++#define ttisnumber(o) ((ttype(o) == LUA_TINT) || (ttype(o) == LUA_TNUMBER))
++#ifdef LNUM_COMPLEX
++# define ttiscomplex(o) ((ttype(o) == LUA_TNUMBER) && (nvalue_img_fast(o)!=0))
++#endif
+ #define ttisstring(o) (ttype(o) == LUA_TSTRING)
+ #define ttistable(o) (ttype(o) == LUA_TTABLE)
+ #define ttisfunction(o) (ttype(o) == LUA_TFUNCTION)
+@@ -90,7 +103,25 @@ typedef struct lua_TValue {
+ #define ttype(o) ((o)->tt)
+ #define gcvalue(o) check_exp(iscollectable(o), (o)->value.gc)
+ #define pvalue(o) check_exp(ttislightuserdata(o), (o)->value.p)
+-#define nvalue(o) check_exp(ttisnumber(o), (o)->value.n)
++
++#define ttype_ext(o) ( ttype(o) == LUA_TINT ? LUA_TNUMBER : ttype(o) )
++#define ttype_ext_same(o1,o2) ( (ttype(o1)==ttype(o2)) || (ttisnumber(o1) && ttisnumber(o2)) )
++
++/* '_fast' variants are for cases where 'ttype(o)' is known to be LUA_TNUMBER.
++ */
++#ifdef LNUM_COMPLEX
++# define nvalue_complex_fast(o) check_exp( ttype(o)==LUA_TNUMBER, (o)->value.n )
++# define nvalue_fast(o) ( _LF(creal) ( nvalue_complex_fast(o) ) )
++# define nvalue_img_fast(o) ( _LF(cimag) ( nvalue_complex_fast(o) ) )
++# define nvalue_complex(o) check_exp( ttisnumber(o), (ttype(o)==LUA_TINT) ? (o)->value.i : (o)->value.n )
++# define nvalue_img(o) check_exp( ttisnumber(o), (ttype(o)==LUA_TINT) ? 0 : _LF(cimag)( (o)->value.n ) )
++# define nvalue(o) check_exp( ttisnumber(o), (ttype(o)==LUA_TINT) ? cast_num((o)->value.i) : _LF(creal)((o)->value.n) )
++#else
++# define nvalue(o) check_exp( ttisnumber(o), (ttype(o)==LUA_TINT) ? cast_num((o)->value.i) : (o)->value.n )
++# define nvalue_fast(o) check_exp( ttype(o)==LUA_TNUMBER, (o)->value.n )
++#endif
++#define ivalue(o) check_exp( ttype(o)==LUA_TINT, (o)->value.i )
++
+ #define rawtsvalue(o) check_exp(ttisstring(o), &(o)->value.gc->ts)
+ #define tsvalue(o) (&rawtsvalue(o)->tsv)
+ #define rawuvalue(o) check_exp(ttisuserdata(o), &(o)->value.gc->u)
+@@ -116,8 +147,27 @@ typedef struct lua_TValue {
+ /* Macros to set values */
+ #define setnilvalue(obj) ((obj)->tt=LUA_TNIL)
+
+-#define setnvalue(obj,x) \
+- { TValue *i_o=(obj); i_o->value.n=(x); i_o->tt=LUA_TNUMBER; }
++/* Must not have side effects, 'x' may be expression.
++*/
++#define setivalue(obj,x) \
++ { TValue *i_o=(obj); i_o->value.i=(x); i_o->tt=LUA_TINT; }
++
++# define setnvalue(obj,x) \
++ { TValue *i_o=(obj); i_o->value.n= (x); i_o->tt=LUA_TNUMBER; }
++
++/* Note: Complex always has "inline", both are C99.
++*/
++#ifdef LNUM_COMPLEX
++ static inline void setnvalue_complex_fast( TValue *obj, lua_Complex x ) {
++ lua_assert( _LF(cimag)(x) != 0 );
++ obj->value.n= x; obj->tt= LUA_TNUMBER;
++ }
++ static inline void setnvalue_complex( TValue *obj, lua_Complex x ) {
++ if (_LF(cimag)(x) == 0) { setnvalue(obj, _LF(creal)(x)); }
++ else { obj->value.n= x; obj->tt= LUA_TNUMBER; }
++ }
++#endif
++
+
+ #define setpvalue(obj,x) \
+ { TValue *i_o=(obj); i_o->value.p=(x); i_o->tt=LUA_TLIGHTUSERDATA; }
+@@ -155,9 +205,6 @@ typedef struct lua_TValue {
+ i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TPROTO; \
+ checkliveness(G(L),i_o); }
+
+-
+-
+-
+ #define setobj(L,obj1,obj2) \
+ { const TValue *o2=(obj2); TValue *o1=(obj1); \
+ o1->value = o2->value; o1->tt=o2->tt; \
+@@ -185,8 +232,11 @@ typedef struct lua_TValue {
+
+ #define setttype(obj, tt) (ttype(obj) = (tt))
+
+-
+-#define iscollectable(o) (ttype(o) >= LUA_TSTRING)
++#if LUA_TINT >= LUA_TSTRING
++# define iscollectable(o) ((ttype(o) >= LUA_TSTRING) && (ttype(o) != LUA_TINT))
++#else
++# define iscollectable(o) (ttype(o) >= LUA_TSTRING)
++#endif
+
+
+
+@@ -370,12 +420,10 @@ LUAI_FUNC int luaO_log2 (unsigned int x)
+ LUAI_FUNC int luaO_int2fb (unsigned int x);
+ LUAI_FUNC int luaO_fb2int (int x);
+ LUAI_FUNC int luaO_rawequalObj (const TValue *t1, const TValue *t2);
+-LUAI_FUNC int luaO_str2d (const char *s, lua_Number *result);
+ LUAI_FUNC const char *luaO_pushvfstring (lua_State *L, const char *fmt,
+ va_list argp);
+ LUAI_FUNC const char *luaO_pushfstring (lua_State *L, const char *fmt, ...);
+ LUAI_FUNC void luaO_chunkid (char *out, const char *source, size_t len);
+
+-
+ #endif
+
+--- a/src/loslib.c
++++ b/src/loslib.c
+@@ -186,15 +186,30 @@ static int os_time (lua_State *L) {
+ }
+ if (t == (time_t)(-1))
+ lua_pushnil(L);
+- else
+- lua_pushnumber(L, (lua_Number)t);
++ else {
++ /* On float systems the pushed value must be an integer, NOT a number.
++ * Otherwise, accuracy is lost in the time_t->float conversion.
++ */
++#ifdef LNUM_FLOAT
++ lua_pushinteger(L, (lua_Integer) t);
++#else
++ lua_pushnumber(L, (lua_Number) t);
++#endif
++ }
+ return 1;
+ }
+
+
+ static int os_difftime (lua_State *L) {
++#ifdef LNUM_FLOAT
++ lua_Integer i= (lua_Integer)
++ difftime( (time_t)(luaL_checkinteger(L, 1)),
++ (time_t)(luaL_optinteger(L, 2, 0)));
++ lua_pushinteger(L, i);
++#else
+ lua_pushnumber(L, difftime((time_t)(luaL_checknumber(L, 1)),
+ (time_t)(luaL_optnumber(L, 2, 0))));
++#endif
+ return 1;
+ }
+
+--- a/src/lparser.c
++++ b/src/lparser.c
+@@ -33,7 +33,6 @@
+
+ #define luaY_checklimit(fs,v,l,m) if ((v)>(l)) errorlimit(fs,l,m)
+
+-
+ /*
+ ** nodes for block list (list of active blocks)
+ */
+@@ -72,7 +71,7 @@ static void errorlimit (FuncState *fs, i
+ const char *msg = (fs->f->linedefined == 0) ?
+ luaO_pushfstring(fs->L, "main function has more than %d %s", limit, what) :
+ luaO_pushfstring(fs->L, "function at line %d has more than %d %s",
+- fs->f->linedefined, limit, what);
++ (fs->f->linedefined), limit, what);
+ luaX_lexerror(fs->ls, msg, 0);
+ }
+
+@@ -733,6 +732,18 @@ static void simpleexp (LexState *ls, exp
+ v->u.nval = ls->t.seminfo.r;
+ break;
+ }
++ case TK_INT: {
++ init_exp(v, VKINT, 0);
++ v->u.ival = ls->t.seminfo.i;
++ break;
++ }
++#ifdef LNUM_COMPLEX
++ case TK_NUMBER2: {
++ init_exp(v, VKNUM2, 0);
++ v->u.nval = ls->t.seminfo.r;
++ break;
++ }
++#endif
+ case TK_STRING: {
+ codestring(ls, v, ls->t.seminfo.ts);
+ break;
+@@ -1079,7 +1090,7 @@ static void fornum (LexState *ls, TStrin
+ if (testnext(ls, ','))
+ exp1(ls); /* optional step */
+ else { /* default step = 1 */
+- luaK_codeABx(fs, OP_LOADK, fs->freereg, luaK_numberK(fs, 1));
++ luaK_codeABx(fs, OP_LOADK, fs->freereg, luaK_integerK(fs, 1));
+ luaK_reserveregs(fs, 1);
+ }
+ forbody(ls, base, line, 1, 1);
+--- a/src/lparser.h
++++ b/src/lparser.h
+@@ -31,7 +31,11 @@ typedef enum {
+ VRELOCABLE, /* info = instruction pc */
+ VNONRELOC, /* info = result register */
+ VCALL, /* info = instruction pc */
+- VVARARG /* info = instruction pc */
++ VVARARG, /* info = instruction pc */
++ VKINT /* ival = integer value */
++#ifdef LNUM_COMPLEX
++ ,VKNUM2 /* nval = imaginary value */
++#endif
+ } expkind;
+
+ typedef struct expdesc {
+@@ -39,6 +43,7 @@ typedef struct expdesc {
+ union {
+ struct { int info, aux; } s;
+ lua_Number nval;
++ lua_Integer ival;
+ } u;
+ int t; /* patch list of `exit when true' */
+ int f; /* patch list of `exit when false' */
+--- a/src/lstrlib.c
++++ b/src/lstrlib.c
+@@ -43,8 +43,8 @@ static ptrdiff_t posrelat (ptrdiff_t pos
+ static int str_sub (lua_State *L) {
+ size_t l;
+ const char *s = luaL_checklstring(L, 1, &l);
+- ptrdiff_t start = posrelat(luaL_checkinteger(L, 2), l);
+- ptrdiff_t end = posrelat(luaL_optinteger(L, 3, -1), l);
++ ptrdiff_t start = posrelat(luaL_checkint32(L, 2), l);
++ ptrdiff_t end = posrelat(luaL_optint32(L, 3, -1), l);
+ if (start < 1) start = 1;
+ if (end > (ptrdiff_t)l) end = (ptrdiff_t)l;
+ if (start <= end)
+@@ -106,8 +106,8 @@ static int str_rep (lua_State *L) {
+ static int str_byte (lua_State *L) {
+ size_t l;
+ const char *s = luaL_checklstring(L, 1, &l);
+- ptrdiff_t posi = posrelat(luaL_optinteger(L, 2, 1), l);
+- ptrdiff_t pose = posrelat(luaL_optinteger(L, 3, posi), l);
++ ptrdiff_t posi = posrelat(luaL_optint32(L, 2, 1), l);
++ ptrdiff_t pose = posrelat(luaL_optint32(L, 3, posi), l);
+ int n, i;
+ if (posi <= 0) posi = 1;
+ if ((size_t)pose > l) pose = l;
+@@ -496,7 +496,7 @@ static int str_find_aux (lua_State *L, i
+ size_t l1, l2;
+ const char *s = luaL_checklstring(L, 1, &l1);
+ const char *p = luaL_checklstring(L, 2, &l2);
+- ptrdiff_t init = posrelat(luaL_optinteger(L, 3, 1), l1) - 1;
++ ptrdiff_t init = posrelat(luaL_optint32(L, 3, 1), l1) - 1;
+ if (init < 0) init = 0;
+ else if ((size_t)(init) > l1) init = (ptrdiff_t)l1;
+ if (find && (lua_toboolean(L, 4) || /* explicit request? */
+@@ -690,7 +690,7 @@ static int str_gsub (lua_State *L) {
+ ** maximum size of each format specification (such as '%-099.99d')
+ ** (+10 accounts for %99.99x plus margin of error)
+ */
+-#define MAX_FORMAT (sizeof(FLAGS) + sizeof(LUA_INTFRMLEN) + 10)
++#define MAX_FORMAT (sizeof(FLAGS) + sizeof(LUA_INTEGER_FMT)-2 + 10)
+
+
+ static void addquoted (lua_State *L, luaL_Buffer *b, int arg) {
+@@ -747,9 +747,9 @@ static const char *scanformat (lua_State
+ static void addintlen (char *form) {
+ size_t l = strlen(form);
+ char spec = form[l - 1];
+- strcpy(form + l - 1, LUA_INTFRMLEN);
+- form[l + sizeof(LUA_INTFRMLEN) - 2] = spec;
+- form[l + sizeof(LUA_INTFRMLEN) - 1] = '\0';
++ const char *tmp= LUA_INTEGER_FMT; /* "%lld" or "%ld" */
++ strcpy(form + l - 1, tmp+1);
++ form[l + sizeof(LUA_INTEGER_FMT)-4] = spec;
+ }
+
+
+@@ -779,12 +779,12 @@ static int str_format (lua_State *L) {
+ }
+ case 'd': case 'i': {
+ addintlen(form);
+- sprintf(buff, form, (LUA_INTFRM_T)luaL_checknumber(L, arg));
++ sprintf(buff, form, luaL_checkinteger(L, arg));
+ break;
+ }
+ case 'o': case 'u': case 'x': case 'X': {
+ addintlen(form);
+- sprintf(buff, form, (unsigned LUA_INTFRM_T)luaL_checknumber(L, arg));
++ sprintf(buff, form, (unsigned LUA_INTEGER)luaL_checkinteger(L, arg));
+ break;
+ }
+ case 'e': case 'E': case 'f':
+--- a/src/ltable.c
++++ b/src/ltable.c
+@@ -33,6 +33,7 @@
+ #include "lobject.h"
+ #include "lstate.h"
+ #include "ltable.h"
++#include "lnum.h"
+
+
+ /*
+@@ -51,25 +52,15 @@
+
+ #define hashstr(t,str) hashpow2(t, (str)->tsv.hash)
+ #define hashboolean(t,p) hashpow2(t, p)
+-
++#define hashint(t,i) hashpow2(t,i)
+
+ /*
+ ** for some types, it is better to avoid modulus by power of 2, as
+ ** they tend to have many 2 factors.
+ */
+ #define hashmod(t,n) (gnode(t, ((n) % ((sizenode(t)-1)|1))))
+-
+-
+ #define hashpointer(t,p) hashmod(t, IntPoint(p))
+
+-
+-/*
+-** number of ints inside a lua_Number
+-*/
+-#define numints cast_int(sizeof(lua_Number)/sizeof(int))
+-
+-
+-
+ #define dummynode (&dummynode_)
+
+ static const Node dummynode_ = {
+@@ -80,27 +71,46 @@ static const Node dummynode_ = {
+
+ /*
+ ** hash for lua_Numbers
++**
++** for non-complex modes, never called with 'lua_Integer' value range (s.a. 0)
+ */
+ static Node *hashnum (const Table *t, lua_Number n) {
+- unsigned int a[numints];
+- int i;
+- if (luai_numeq(n, 0)) /* avoid problems with -0 */
+- return gnode(t, 0);
+- memcpy(a, &n, sizeof(a));
+- for (i = 1; i < numints; i++) a[0] += a[i];
+- return hashmod(t, a[0]);
++ const unsigned int *p= cast(const unsigned int *,&n);
++ unsigned int sum= *p;
++ unsigned int m= sizeof(lua_Number)/sizeof(int);
++ unsigned int i;
++ /* OS X Intel has 'm'==4 and gives "Bus error" if the last integer of
++ * 'n' is read; the actual size of long double is only 80 bits = 10 bytes.
++ * Linux x86 has 'm'==3, and does not require reduction.
++ */
++#if defined(LNUM_LDOUBLE) && defined(__i386__)
++ if (m>3) m--;
++#endif
++ for (i = 1; i < m; i++) sum += p[i];
++ return hashmod(t, sum);
+ }
+
+
+-
+ /*
+ ** returns the `main' position of an element in a table (that is, the index
+ ** of its hash value)
++**
++** Floating point numbers with integer value give the hash position of the
++** integer (so they use the same table position).
+ */
+ static Node *mainposition (const Table *t, const TValue *key) {
++ lua_Integer i;
+ switch (ttype(key)) {
+ case LUA_TNUMBER:
+- return hashnum(t, nvalue(key));
++ if (tt_integer_valued(key,&i))
++ return hashint(t, i);
++#ifdef LNUM_COMPLEX
++ if (nvalue_img_fast(key)!=0 && luai_numeq(nvalue_fast(key),0))
++ return gnode(t, 0); /* 0 and -0 to give same hash */
++#endif
++ return hashnum(t, nvalue_fast(key));
++ case LUA_TINT:
++ return hashint(t, ivalue(key));
+ case LUA_TSTRING:
+ return hashstr(t, rawtsvalue(key));
+ case LUA_TBOOLEAN:
+@@ -116,16 +126,20 @@ static Node *mainposition (const Table *
+ /*
+ ** returns the index for `key' if `key' is an appropriate key to live in
+ ** the array part of the table, -1 otherwise.
++**
++** Anything <=0 is taken as not being in the array part.
+ */
+-static int arrayindex (const TValue *key) {
+- if (ttisnumber(key)) {
+- lua_Number n = nvalue(key);
+- int k;
+- lua_number2int(k, n);
+- if (luai_numeq(cast_num(k), n))
+- return k;
++static int arrayindex (const TValue *key, int max) {
++ lua_Integer k;
++ switch( ttype(key) ) {
++ case LUA_TINT:
++ k= ivalue(key); break;
++ case LUA_TNUMBER:
++ if (tt_integer_valued(key,&k)) break;
++ default:
++ return -1; /* not to be used as array index */
+ }
+- return -1; /* `key' did not match some condition */
++ return ((k>0) && (k <= max)) ? cast_int(k) : -1;
+ }
+
+
+@@ -137,8 +151,8 @@ static int arrayindex (const TValue *key
+ static int findindex (lua_State *L, Table *t, StkId key) {
+ int i;
+ if (ttisnil(key)) return -1; /* first iteration */
+- i = arrayindex(key);
+- if (0 < i && i <= t->sizearray) /* is `key' inside array part? */
++ i = arrayindex(key, t->sizearray);
++ if (i>0) /* inside array part? */
+ return i-1; /* yes; that's the index (corrected to C) */
+ else {
+ Node *n = mainposition(t, key);
+@@ -163,7 +177,7 @@ int luaH_next (lua_State *L, Table *t, S
+ int i = findindex(L, t, key); /* find original element */
+ for (i++; i < t->sizearray; i++) { /* try first array part */
+ if (!ttisnil(&t->array[i])) { /* a non-nil value? */
+- setnvalue(key, cast_num(i+1));
++ setivalue(key, i+1);
+ setobj2s(L, key+1, &t->array[i]);
+ return 1;
+ }
+@@ -209,8 +223,8 @@ static int computesizes (int nums[], int
+
+
+ static int countint (const TValue *key, int *nums) {
+- int k = arrayindex(key);
+- if (0 < k && k <= MAXASIZE) { /* is `key' an appropriate array index? */
++ int k = arrayindex(key,MAXASIZE);
++ if (k>0) { /* appropriate array index? */
+ nums[ceillog2(k)]++; /* count as such */
+ return 1;
+ }
+@@ -308,7 +322,7 @@ static void resize (lua_State *L, Table
+ /* re-insert elements from vanishing slice */
+ for (i=nasize; i<oldasize; i++) {
+ if (!ttisnil(&t->array[i]))
+- setobjt2t(L, luaH_setnum(L, t, i+1), &t->array[i]);
++ setobjt2t(L, luaH_setint(L, t, i+1), &t->array[i]);
+ }
+ /* shrink array */
+ luaM_reallocvector(L, t->array, oldasize, nasize, TValue);
+@@ -409,7 +423,9 @@ static TValue *newkey (lua_State *L, Tab
+ othern = mainposition(t, key2tval(mp));
+ if (othern != mp) { /* is colliding node out of its main position? */
+ /* yes; move colliding node into free position */
+- while (gnext(othern) != mp) othern = gnext(othern); /* find previous */
++ while (gnext(othern) != mp) {
++ othern = gnext(othern); /* find previous */
++ }
+ gnext(othern) = n; /* redo the chain with `n' in place of `mp' */
+ *n = *mp; /* copy colliding node into free pos. (mp->next also goes) */
+ gnext(mp) = NULL; /* now `mp' is free */
+@@ -432,17 +448,18 @@ static TValue *newkey (lua_State *L, Tab
+ /*
+ ** search function for integers
+ */
+-const TValue *luaH_getnum (Table *t, int key) {
++const TValue *luaH_getint (Table *t, lua_Integer key) {
+ /* (1 <= key && key <= t->sizearray) */
+ if (cast(unsigned int, key-1) < cast(unsigned int, t->sizearray))
+ return &t->array[key-1];
+ else {
+- lua_Number nk = cast_num(key);
+- Node *n = hashnum(t, nk);
++ Node *n = hashint(t, key);
+ do { /* check whether `key' is somewhere in the chain */
+- if (ttisnumber(gkey(n)) && luai_numeq(nvalue(gkey(n)), nk))
++ if (ttisint(gkey(n)) && (ivalue(gkey(n)) == key)) {
+ return gval(n); /* that's it */
+- else n = gnext(n);
++ } else {
++ n = gnext(n);
++ }
+ } while (n);
+ return luaO_nilobject;
+ }
+@@ -470,14 +487,12 @@ const TValue *luaH_get (Table *t, const
+ switch (ttype(key)) {
+ case LUA_TNIL: return luaO_nilobject;
+ case LUA_TSTRING: return luaH_getstr(t, rawtsvalue(key));
++ case LUA_TINT: return luaH_getint(t, ivalue(key));
+ case LUA_TNUMBER: {
+- int k;
+- lua_Number n = nvalue(key);
+- lua_number2int(k, n);
+- if (luai_numeq(cast_num(k), nvalue(key))) /* index is int? */
+- return luaH_getnum(t, k); /* use specialized version */
+- /* else go through */
+- }
++ lua_Integer i;
++ if (tt_integer_valued(key,&i))
++ return luaH_getint(t,i);
++ } /* pass through */
+ default: {
+ Node *n = mainposition(t, key);
+ do { /* check whether `key' is somewhere in the chain */
+@@ -498,20 +513,25 @@ TValue *luaH_set (lua_State *L, Table *t
+ return cast(TValue *, p);
+ else {
+ if (ttisnil(key)) luaG_runerror(L, "table index is nil");
+- else if (ttisnumber(key) && luai_numisnan(nvalue(key)))
+- luaG_runerror(L, "table index is NaN");
++ else if (ttype(key)==LUA_TNUMBER) {
++ lua_Integer k;
++ if (luai_numisnan(nvalue_fast(key)))
++ luaG_runerror(L, "table index is NaN");
++ if (tt_integer_valued(key,&k))
++ return luaH_setint(L, t, k);
++ }
+ return newkey(L, t, key);
+ }
+ }
+
+
+-TValue *luaH_setnum (lua_State *L, Table *t, int key) {
+- const TValue *p = luaH_getnum(t, key);
++TValue *luaH_setint (lua_State *L, Table *t, lua_Integer key) {
++ const TValue *p = luaH_getint(t, key);
+ if (p != luaO_nilobject)
+ return cast(TValue *, p);
+ else {
+ TValue k;
+- setnvalue(&k, cast_num(key));
++ setivalue(&k, key);
+ return newkey(L, t, &k);
+ }
+ }
+@@ -533,20 +553,21 @@ static int unbound_search (Table *t, uns
+ unsigned int i = j; /* i is zero or a present index */
+ j++;
+ /* find `i' and `j' such that i is present and j is not */
+- while (!ttisnil(luaH_getnum(t, j))) {
++ while (!ttisnil(luaH_getint(t, j))) {
+ i = j;
+ j *= 2;
+ if (j > cast(unsigned int, MAX_INT)) { /* overflow? */
+ /* table was built with bad purposes: resort to linear search */
+- i = 1;
+- while (!ttisnil(luaH_getnum(t, i))) i++;
+- return i - 1;
++ for( i = 1; i<MAX_INT+1; i++ ) {
++ if (ttisnil(luaH_getint(t, i))) break;
++ }
++ return i - 1; /* up to MAX_INT */
+ }
+ }
+ /* now do a binary search between them */
+ while (j - i > 1) {
+ unsigned int m = (i+j)/2;
+- if (ttisnil(luaH_getnum(t, m))) j = m;
++ if (ttisnil(luaH_getint(t, m))) j = m;
+ else i = m;
+ }
+ return i;
+--- a/src/ltable.h
++++ b/src/ltable.h
+@@ -18,8 +18,8 @@
+ #define key2tval(n) (&(n)->i_key.tvk)
+
+
+-LUAI_FUNC const TValue *luaH_getnum (Table *t, int key);
+-LUAI_FUNC TValue *luaH_setnum (lua_State *L, Table *t, int key);
++LUAI_FUNC const TValue *luaH_getint (Table *t, lua_Integer key);
++LUAI_FUNC TValue *luaH_setint (lua_State *L, Table *t, lua_Integer key);
+ LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key);
+ LUAI_FUNC TValue *luaH_setstr (lua_State *L, Table *t, TString *key);
+ LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key);
+--- a/src/ltm.c
++++ b/src/ltm.c
+@@ -19,7 +19,6 @@
+ #include "ltm.h"
+
+
+-
+ const char *const luaT_typenames[] = {
+ "nil", "boolean", "userdata", "number",
+ "string", "table", "function", "userdata", "thread",
+@@ -67,6 +66,9 @@ const TValue *luaT_gettmbyobj (lua_State
+ case LUA_TUSERDATA:
+ mt = uvalue(o)->metatable;
+ break;
++ case LUA_TINT:
++ mt = G(L)->mt[LUA_TNUMBER];
++ break;
+ default:
+ mt = G(L)->mt[ttype(o)];
+ }
+--- a/src/lua.c
++++ b/src/lua.c
+@@ -16,7 +16,7 @@
+
+ #include "lauxlib.h"
+ #include "lualib.h"
+-
++#include "llimits.h"
+
+
+ static lua_State *globalL = NULL;
+@@ -382,6 +382,15 @@ int main (int argc, char **argv) {
+ l_message(argv[0], "cannot create state: not enough memory");
+ return EXIT_FAILURE;
+ }
++ /* Checking 'sizeof(lua_Integer)' cannot be made in preprocessor on all compilers.
++ */
++#ifdef LNUM_INT16
++ lua_assert( sizeof(lua_Integer) == 2 );
++#elif defined(LNUM_INT32)
++ lua_assert( sizeof(lua_Integer) == 4 );
++#elif defined(LNUM_INT64)
++ lua_assert( sizeof(lua_Integer) == 8 );
++#endif
+ s.argc = argc;
+ s.argv = argv;
+ status = lua_cpcall(L, &pmain, &s);
+--- a/src/lua.h
++++ b/src/lua.h
+@@ -19,7 +19,7 @@
+ #define LUA_VERSION "Lua 5.1"
+ #define LUA_RELEASE "Lua 5.1.5"
+ #define LUA_VERSION_NUM 501
+-#define LUA_COPYRIGHT "Copyright (C) 1994-2012 Lua.org, PUC-Rio"
++#define LUA_COPYRIGHT "Copyright (C) 1994-2012 Lua.org, PUC-Rio" " (" LUA_LNUM ")"
+ #define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo & W. Celes"
+
+
+@@ -71,6 +71,16 @@ typedef void * (*lua_Alloc) (void *ud, v
+ */
+ #define LUA_TNONE (-1)
+
++/* LUA_TINT is an internal type, not visible to applications. There are three
++ * potential values where it can be tweaked to (code autoadjusts to these):
++ *
++ * -2: not 'usual' type value; good since 'LUA_TINT' is not part of the API
++ * LUA_TNUMBER+1: shifts other type values upwards, breaking binary compatibility
++ * not acceptable for 5.1, maybe 5.2 onwards?
++ * 9: greater than existing (5.1) type values.
++*/
++#define LUA_TINT (-2)
++
+ #define LUA_TNIL 0
+ #define LUA_TBOOLEAN 1
+ #define LUA_TLIGHTUSERDATA 2
+@@ -139,6 +149,8 @@ LUA_API int (lua_isuserdata)
+ LUA_API int (lua_type) (lua_State *L, int idx);
+ LUA_API const char *(lua_typename) (lua_State *L, int tp);
+
++LUA_API int (lua_isinteger) (lua_State *L, int idx);
++
+ LUA_API int (lua_equal) (lua_State *L, int idx1, int idx2);
+ LUA_API int (lua_rawequal) (lua_State *L, int idx1, int idx2);
+ LUA_API int (lua_lessthan) (lua_State *L, int idx1, int idx2);
+@@ -244,6 +256,19 @@ LUA_API lua_Alloc (lua_getallocf) (lua_S
+ LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud);
+
+
++/*
++* It is unnecessary to break Lua C API 'lua_tonumber()' compatibility, just
++* because the Lua number type is complex. Most C modules would use scalars
++* only. We'll introduce new 'lua_tocomplex' and 'lua_pushcomplex' for when
++* the module really wants to use them.
++*/
++#ifdef LNUM_COMPLEX
++ #include <complex.h>
++ typedef LUA_NUMBER complex lua_Complex;
++ LUA_API lua_Complex (lua_tocomplex) (lua_State *L, int idx);
++ LUA_API void (lua_pushcomplex) (lua_State *L, lua_Complex v);
++#endif
++
+
+ /*
+ ** ===============================================================
+@@ -268,7 +293,12 @@ LUA_API void lua_setallocf (lua_State *L
+ #define lua_isboolean(L,n) (lua_type(L, (n)) == LUA_TBOOLEAN)
+ #define lua_isthread(L,n) (lua_type(L, (n)) == LUA_TTHREAD)
+ #define lua_isnone(L,n) (lua_type(L, (n)) == LUA_TNONE)
+-#define lua_isnoneornil(L, n) (lua_type(L, (n)) <= 0)
++
++#if LUA_TINT < 0
++# define lua_isnoneornil(L, n) ( (lua_type(L,(n)) <= 0) && (lua_type(L,(n)) != LUA_TINT) )
++#else
++# define lua_isnoneornil(L, n) (lua_type(L, (n)) <= 0)
++#endif
+
+ #define lua_pushliteral(L, s) \
+ lua_pushlstring(L, "" s, (sizeof(s)/sizeof(char))-1)
+@@ -386,3 +416,4 @@ struct lua_Debug {
+
+
+ #endif
++
+--- a/src/luaconf.h
++++ b/src/luaconf.h
+@@ -10,7 +10,9 @@
+
+ #include <limits.h>
+ #include <stddef.h>
+-
++#ifdef lua_assert
++# include <assert.h>
++#endif
+
+ /*
+ ** ==================================================================
+@@ -136,14 +138,38 @@
+
+
+ /*
+-@@ LUA_INTEGER is the integral type used by lua_pushinteger/lua_tointeger.
+-** CHANGE that if ptrdiff_t is not adequate on your machine. (On most
+-** machines, ptrdiff_t gives a good choice between int or long.)
++@@ LUAI_BITSINT defines the number of bits in an int.
++** CHANGE here if Lua cannot automatically detect the number of bits of
++** your machine. Probably you do not need to change this.
+ */
+-#define LUA_INTEGER ptrdiff_t
++/* avoid overflows in comparison */
++#if INT_MAX-20 < 32760
++#define LUAI_BITSINT 16
++#elif INT_MAX > 2147483640L
++/* int has at least 32 bits */
++#define LUAI_BITSINT 32
++#else
++#error "you must define LUA_BITSINT with number of bits in an integer"
++#endif
+
+
+ /*
++@@ LNUM_DOUBLE | LNUM_FLOAT | LNUM_LDOUBLE: Generic Lua number mode
++@@ LNUM_INT32 | LNUM_INT64: Integer type
++@@ LNUM_COMPLEX: Define for using 'a+bi' numbers
++@@
++@@ You can combine LNUM_xxx but only one of each group. I.e. '-DLNUM_FLOAT
++@@ -DLNUM_INT32 -DLNUM_COMPLEX' gives float range complex numbers, with
++@@ 32-bit scalar integer range optimized.
++**
++** These are kept in a separate configuration file mainly for ease of patching
++** (can be changed if integerated to Lua proper).
++*/
++/*#define LNUM_DOUBLE*/
++/*#define LNUM_INT32*/
++#include "lnum_config.h"
++
++/*
+ @@ LUA_API is a mark for all core API functions.
+ @@ LUALIB_API is a mark for all standard library functions.
+ ** CHANGE them if you need to define those functions in some special way.
+@@ -383,22 +409,6 @@
+
+
+ /*
+-@@ LUAI_BITSINT defines the number of bits in an int.
+-** CHANGE here if Lua cannot automatically detect the number of bits of
+-** your machine. Probably you do not need to change this.
+-*/
+-/* avoid overflows in comparison */
+-#if INT_MAX-20 < 32760
+-#define LUAI_BITSINT 16
+-#elif INT_MAX > 2147483640L
+-/* int has at least 32 bits */
+-#define LUAI_BITSINT 32
+-#else
+-#error "you must define LUA_BITSINT with number of bits in an integer"
+-#endif
+-
+-
+-/*
+ @@ LUAI_UINT32 is an unsigned integer with at least 32 bits.
+ @@ LUAI_INT32 is an signed integer with at least 32 bits.
+ @@ LUAI_UMEM is an unsigned integer big enough to count the total
+@@ -425,6 +435,15 @@
+ #define LUAI_MEM long
+ #endif
+
++/*
++@@ LUAI_BOOL carries 0 and nonzero (normally 1). It may be defined as 'char'
++** (to save memory), 'int' (for speed), 'bool' (for C++) or '_Bool' (C99)
++*/
++#ifdef __cplusplus
++# define LUAI_BOOL bool
++#else
++# define LUAI_BOOL int
++#endif
+
+ /*
+ @@ LUAI_MAXCALLS limits the number of nested calls.
+@@ -490,101 +509,6 @@
+ /* }================================================================== */
+
+
+-
+-
+-/*
+-** {==================================================================
+-@@ LUA_NUMBER is the type of numbers in Lua.
+-** CHANGE the following definitions only if you want to build Lua
+-** with a number type different from double. You may also need to
+-** change lua_number2int & lua_number2integer.
+-** ===================================================================
+-*/
+-
+-#define LUA_NUMBER_DOUBLE
+-#define LUA_NUMBER double
+-
+-/*
+-@@ LUAI_UACNUMBER is the result of an 'usual argument conversion'
+-@* over a number.
+-*/
+-#define LUAI_UACNUMBER double
+-
+-
+-/*
+-@@ LUA_NUMBER_SCAN is the format for reading numbers.
+-@@ LUA_NUMBER_FMT is the format for writing numbers.
+-@@ lua_number2str converts a number to a string.
+-@@ LUAI_MAXNUMBER2STR is maximum size of previous conversion.
+-@@ lua_str2number converts a string to a number.
+-*/
+-#define LUA_NUMBER_SCAN "%lf"
+-#define LUA_NUMBER_FMT "%.14g"
+-#define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n))
+-#define LUAI_MAXNUMBER2STR 32 /* 16 digits, sign, point, and \0 */
+-#define lua_str2number(s,p) strtod((s), (p))
+-
+-
+-/*
+-@@ The luai_num* macros define the primitive operations over numbers.
+-*/
+-#if defined(LUA_CORE)
+-#include <math.h>
+-#define luai_numadd(a,b) ((a)+(b))
+-#define luai_numsub(a,b) ((a)-(b))
+-#define luai_nummul(a,b) ((a)*(b))
+-#define luai_numdiv(a,b) ((a)/(b))
+-#define luai_nummod(a,b) ((a) - floor((a)/(b))*(b))
+-#define luai_numpow(a,b) (pow(a,b))
+-#define luai_numunm(a) (-(a))
+-#define luai_numeq(a,b) ((a)==(b))
+-#define luai_numlt(a,b) ((a)<(b))
+-#define luai_numle(a,b) ((a)<=(b))
+-#define luai_numisnan(a) (!luai_numeq((a), (a)))
+-#endif
+-
+-
+-/*
+-@@ lua_number2int is a macro to convert lua_Number to int.
+-@@ lua_number2integer is a macro to convert lua_Number to lua_Integer.
+-** CHANGE them if you know a faster way to convert a lua_Number to
+-** int (with any rounding method and without throwing errors) in your
+-** system. In Pentium machines, a naive typecast from double to int
+-** in C is extremely slow, so any alternative is worth trying.
+-*/
+-
+-/* On a Pentium, resort to a trick */
+-#if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) && !defined(__SSE2__) && \
+- (defined(__i386) || defined (_M_IX86) || defined(__i386__))
+-
+-/* On a Microsoft compiler, use assembler */
+-#if defined(_MSC_VER)
+-
+-#define lua_number2int(i,d) __asm fld d __asm fistp i
+-#define lua_number2integer(i,n) lua_number2int(i, n)
+-
+-/* the next trick should work on any Pentium, but sometimes clashes
+- with a DirectX idiosyncrasy */
+-#else
+-
+-union luai_Cast { double l_d; long l_l; };
+-#define lua_number2int(i,d) \
+- { volatile union luai_Cast u; u.l_d = (d) + 6755399441055744.0; (i) = u.l_l; }
+-#define lua_number2integer(i,n) lua_number2int(i, n)
+-
+-#endif
+-
+-
+-/* this option always works, but may be slow */
+-#else
+-#define lua_number2int(i,d) ((i)=(int)(d))
+-#define lua_number2integer(i,d) ((i)=(lua_Integer)(d))
+-
+-#endif
+-
+-/* }================================================================== */
+-
+-
+ /*
+ @@ LUAI_USER_ALIGNMENT_T is a type that requires maximum alignment.
+ ** CHANGE it if your system requires alignments larger than double. (For
+@@ -728,28 +652,6 @@ union luai_Cast { double l_d; long l_l;
+ #define luai_userstateyield(L,n) ((void)L)
+
+
+-/*
+-@@ LUA_INTFRMLEN is the length modifier for integer conversions
+-@* in 'string.format'.
+-@@ LUA_INTFRM_T is the integer type correspoding to the previous length
+-@* modifier.
+-** CHANGE them if your system supports long long or does not support long.
+-*/
+-
+-#if defined(LUA_USELONGLONG)
+-
+-#define LUA_INTFRMLEN "ll"
+-#define LUA_INTFRM_T long long
+-
+-#else
+-
+-#define LUA_INTFRMLEN "l"
+-#define LUA_INTFRM_T long
+-
+-#endif
+-
+-
+-
+ /* =================================================================== */
+
+ /*
+--- a/src/lundump.c
++++ b/src/lundump.c
+@@ -73,6 +73,13 @@ static lua_Number LoadNumber(LoadState*
+ return x;
+ }
+
++static lua_Integer LoadInteger(LoadState* S)
++{
++ lua_Integer x;
++ LoadVar(S,x);
++ return x;
++}
++
+ static TString* LoadString(LoadState* S)
+ {
+ size_t size;
+@@ -119,6 +126,9 @@ static void LoadConstants(LoadState* S,
+ case LUA_TNUMBER:
+ setnvalue(o,LoadNumber(S));
+ break;
++ case LUA_TINT: /* Integer type saved in bytecode (see lcode.c) */
++ setivalue(o,LoadInteger(S));
++ break;
+ case LUA_TSTRING:
+ setsvalue2n(S->L,o,LoadString(S));
+ break;
+@@ -223,5 +233,22 @@ void luaU_header (char* h)
+ *h++=(char)sizeof(size_t);
+ *h++=(char)sizeof(Instruction);
+ *h++=(char)sizeof(lua_Number);
+- *h++=(char)(((lua_Number)0.5)==0); /* is lua_Number integral? */
++
++ /*
++ * Last byte of header (0/1 in unpatched Lua 5.1.3):
++ *
++ * 0: lua_Number is float or double, lua_Integer not used. (nonpatched only)
++ * 1: lua_Number is integer (nonpatched only)
++ *
++ * +2: LNUM_INT16: sizeof(lua_Integer)
++ * +4: LNUM_INT32: sizeof(lua_Integer)
++ * +8: LNUM_INT64: sizeof(lua_Integer)
++ *
++ * +0x80: LNUM_COMPLEX
++ */
++ *h++ = (char)(sizeof(lua_Integer)
++#ifdef LNUM_COMPLEX
++ | 0x80
++#endif
++ );
+ }
+--- a/src/lvm.c
++++ b/src/lvm.c
+@@ -25,22 +25,35 @@
+ #include "ltable.h"
+ #include "ltm.h"
+ #include "lvm.h"
+-
+-
++#include "llex.h"
++#include "lnum.h"
+
+ /* limit for table tag-method chains (to avoid loops) */
+ #define MAXTAGLOOP 100
+
+
+-const TValue *luaV_tonumber (const TValue *obj, TValue *n) {
+- lua_Number num;
++/*
++ * If 'obj' is a string, it is tried to be interpreted as a number.
++ */
++const TValue *luaV_tonumber ( const TValue *obj, TValue *n) {
++ lua_Number d;
++ lua_Integer i;
++
+ if (ttisnumber(obj)) return obj;
+- if (ttisstring(obj) && luaO_str2d(svalue(obj), &num)) {
+- setnvalue(n, num);
+- return n;
+- }
+- else
+- return NULL;
++
++ if (ttisstring(obj)) {
++ switch( luaO_str2d( svalue(obj), &d, &i ) ) {
++ case TK_INT:
++ setivalue(n,i); return n;
++ case TK_NUMBER:
++ setnvalue(n,d); return n;
++#ifdef LNUM_COMPLEX
++ case TK_NUMBER2: /* "N.NNNi", != 0 */
++ setnvalue_complex_fast(n, d*I); return n;
++#endif
++ }
++ }
++ return NULL;
+ }
+
+
+@@ -49,8 +62,7 @@ int luaV_tostring (lua_State *L, StkId o
+ return 0;
+ else {
+ char s[LUAI_MAXNUMBER2STR];
+- lua_Number n = nvalue(obj);
+- lua_number2str(s, n);
++ luaO_num2buf(s,obj);
+ setsvalue2s(L, obj, luaS_new(L, s));
+ return 1;
+ }
+@@ -222,59 +234,127 @@ static int l_strcmp (const TString *ls,
+ }
+
+
++#ifdef LNUM_COMPLEX
++void error_complex( lua_State *L, const TValue *l, const TValue *r )
++{
++ char buf1[ LUAI_MAXNUMBER2STR ];
++ char buf2[ LUAI_MAXNUMBER2STR ];
++ luaO_num2buf( buf1, l );
++ luaO_num2buf( buf2, r );
++ luaG_runerror( L, "unable to compare: %s with %s", buf1, buf2 );
++ /* no return */
++}
++#endif
++
++
+ int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r) {
+ int res;
+- if (ttype(l) != ttype(r))
++ int tl,tr;
++ lua_Integer tmp;
++
++ if (!ttype_ext_same(l,r))
+ return luaG_ordererror(L, l, r);
+- else if (ttisnumber(l))
+- return luai_numlt(nvalue(l), nvalue(r));
+- else if (ttisstring(l))
+- return l_strcmp(rawtsvalue(l), rawtsvalue(r)) < 0;
+- else if ((res = call_orderTM(L, l, r, TM_LT)) != -1)
++#ifdef LNUM_COMPLEX
++ if ( (nvalue_img(l)!=0) || (nvalue_img(r)!=0) )
++ error_complex( L, l, r );
++#endif
++ tl= ttype(l); tr= ttype(r);
++ if (tl==tr) { /* clear arithmetics */
++ switch(tl) {
++ case LUA_TINT: return ivalue(l) < ivalue(r);
++ case LUA_TNUMBER: return luai_numlt(nvalue_fast(l), nvalue_fast(r));
++ case LUA_TSTRING: return l_strcmp(rawtsvalue(l), rawtsvalue(r)) < 0;
++ }
++ } else if (tl==LUA_TINT) { /* l:int, r:num */
++ /* Avoid accuracy losing casts: if 'r' is integer by value, do comparisons
++ * in integer realm. Only otherwise cast 'l' to FP (which might change its
++ * value).
++ */
++ if (tt_integer_valued(r,&tmp))
++ return ivalue(l) < tmp;
++ else
++ return luai_numlt( cast_num(ivalue(l)), nvalue_fast(r) );
++
++ } else if (tl==LUA_TNUMBER) { /* l:num, r:int */
++ if (tt_integer_valued(l,&tmp))
++ return tmp < ivalue(r);
++ else
++ return luai_numlt( nvalue_fast(l), cast_num(ivalue(r)) );
++
++ } else if ((res = call_orderTM(L, l, r, TM_LT)) != -1)
+ return res;
++
+ return luaG_ordererror(L, l, r);
+ }
+
+
+ static int lessequal (lua_State *L, const TValue *l, const TValue *r) {
+ int res;
+- if (ttype(l) != ttype(r))
++ int tl, tr;
++ lua_Integer tmp;
++
++ if (!ttype_ext_same(l,r))
+ return luaG_ordererror(L, l, r);
+- else if (ttisnumber(l))
+- return luai_numle(nvalue(l), nvalue(r));
+- else if (ttisstring(l))
+- return l_strcmp(rawtsvalue(l), rawtsvalue(r)) <= 0;
+- else if ((res = call_orderTM(L, l, r, TM_LE)) != -1) /* first try `le' */
++#ifdef LNUM_COMPLEX
++ if ( (nvalue_img(l)!=0) || (nvalue_img(r)!=0) )
++ error_complex( L, l, r );
++#endif
++ tl= ttype(l); tr= ttype(r);
++ if (tl==tr) { /* clear arithmetics */
++ switch(tl) {
++ case LUA_TINT: return ivalue(l) <= ivalue(r);
++ case LUA_TNUMBER: return luai_numle(nvalue_fast(l), nvalue_fast(r));
++ case LUA_TSTRING: return l_strcmp(rawtsvalue(l), rawtsvalue(r)) <= 0;
++ }
++ }
++ if (tl==LUA_TINT) { /* l:int, r:num */
++ if (tt_integer_valued(r,&tmp))
++ return ivalue(l) <= tmp;
++ else
++ return luai_numle( cast_num(ivalue(l)), nvalue_fast(r) );
++
++ } else if (tl==LUA_TNUMBER) { /* l:num, r:int */
++ if (tt_integer_valued(l,&tmp))
++ return tmp <= ivalue(r);
++ else
++ return luai_numle( nvalue_fast(l), cast_num(ivalue(r)) );
++
++ } else if ((res = call_orderTM(L, l, r, TM_LE)) != -1) /* first try `le' */
+ return res;
+ else if ((res = call_orderTM(L, r, l, TM_LT)) != -1) /* else try `lt' */
+ return !res;
++
+ return luaG_ordererror(L, l, r);
+ }
+
+
+-int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2) {
++/* Note: 'luaV_equalval()' and 'luaO_rawequalObj()' have largely overlapping
++ * implementation. LUA_TNIL..LUA_TLIGHTUSERDATA cases could be handled
++ * simply by the 'default' case here.
++ */
++int luaV_equalval (lua_State *L, const TValue *l, const TValue *r) {
+ const TValue *tm;
+- lua_assert(ttype(t1) == ttype(t2));
+- switch (ttype(t1)) {
++ lua_assert(ttype_ext_same(l,r));
++ switch (ttype(l)) {
+ case LUA_TNIL: return 1;
+- case LUA_TNUMBER: return luai_numeq(nvalue(t1), nvalue(t2));
+- case LUA_TBOOLEAN: return bvalue(t1) == bvalue(t2); /* true must be 1 !! */
+- case LUA_TLIGHTUSERDATA: return pvalue(t1) == pvalue(t2);
++ case LUA_TINT:
++ case LUA_TNUMBER: return luaO_rawequalObj(l,r);
++ case LUA_TBOOLEAN: return bvalue(l) == bvalue(r); /* true must be 1 !! */
++ case LUA_TLIGHTUSERDATA: return pvalue(l) == pvalue(r);
+ case LUA_TUSERDATA: {
+- if (uvalue(t1) == uvalue(t2)) return 1;
+- tm = get_compTM(L, uvalue(t1)->metatable, uvalue(t2)->metatable,
+- TM_EQ);
++ if (uvalue(l) == uvalue(r)) return 1;
++ tm = get_compTM(L, uvalue(l)->metatable, uvalue(r)->metatable, TM_EQ);
+ break; /* will try TM */
+ }
+ case LUA_TTABLE: {
+- if (hvalue(t1) == hvalue(t2)) return 1;
+- tm = get_compTM(L, hvalue(t1)->metatable, hvalue(t2)->metatable, TM_EQ);
++ if (hvalue(l) == hvalue(r)) return 1;
++ tm = get_compTM(L, hvalue(l)->metatable, hvalue(r)->metatable, TM_EQ);
+ break; /* will try TM */
+ }
+- default: return gcvalue(t1) == gcvalue(t2);
++ default: return gcvalue(l) == gcvalue(r);
+ }
+ if (tm == NULL) return 0; /* no TM? */
+- callTMres(L, L->top, tm, t1, t2); /* call TM */
++ callTMres(L, L->top, tm, l, r); /* call TM */
+ return !l_isfalse(L->top);
+ }
+
+@@ -314,30 +394,6 @@ void luaV_concat (lua_State *L, int tota
+ }
+
+
+-static void Arith (lua_State *L, StkId ra, const TValue *rb,
+- const TValue *rc, TMS op) {
+- TValue tempb, tempc;
+- const TValue *b, *c;
+- if ((b = luaV_tonumber(rb, &tempb)) != NULL &&
+- (c = luaV_tonumber(rc, &tempc)) != NULL) {
+- lua_Number nb = nvalue(b), nc = nvalue(c);
+- switch (op) {
+- case TM_ADD: setnvalue(ra, luai_numadd(nb, nc)); break;
+- case TM_SUB: setnvalue(ra, luai_numsub(nb, nc)); break;
+- case TM_MUL: setnvalue(ra, luai_nummul(nb, nc)); break;
+- case TM_DIV: setnvalue(ra, luai_numdiv(nb, nc)); break;
+- case TM_MOD: setnvalue(ra, luai_nummod(nb, nc)); break;
+- case TM_POW: setnvalue(ra, luai_numpow(nb, nc)); break;
+- case TM_UNM: setnvalue(ra, luai_numunm(nb)); break;
+- default: lua_assert(0); break;
+- }
+- }
+- else if (!call_binTM(L, rb, rc, ra, op))
+- luaG_aritherror(L, rb, rc);
+-}
+-
+-
+-
+ /*
+ ** some macros for common tasks in `luaV_execute'
+ */
+@@ -361,17 +417,154 @@ static void Arith (lua_State *L, StkId r
+ #define Protect(x) { L->savedpc = pc; {x;}; base = L->base; }
+
+
+-#define arith_op(op,tm) { \
+- TValue *rb = RKB(i); \
+- TValue *rc = RKC(i); \
+- if (ttisnumber(rb) && ttisnumber(rc)) { \
+- lua_Number nb = nvalue(rb), nc = nvalue(rc); \
+- setnvalue(ra, op(nb, nc)); \
+- } \
+- else \
+- Protect(Arith(L, ra, rb, rc, tm)); \
++/* Note: if called for unary operations, 'rc'=='rb'.
++ */
++static void Arith (lua_State *L, StkId ra, const TValue *rb,
++ const TValue *rc, TMS op) {
++ TValue tempb, tempc;
++ const TValue *b, *c;
++ lua_Number nb,nc;
++
++ if ((b = luaV_tonumber(rb, &tempb)) != NULL &&
++ (c = luaV_tonumber(rc, &tempc)) != NULL) {
++
++ /* Keep integer arithmetics in the integer realm, if possible.
++ */
++ if (ttisint(b) && ttisint(c)) {
++ lua_Integer ib = ivalue(b), ic = ivalue(c);
++ lua_Integer *ri = &ra->value.i;
++ ra->tt= LUA_TINT; /* part of 'setivalue(ra)' */
++ switch (op) {
++ case TM_ADD: if (try_addint( ri, ib, ic)) return; break;
++ case TM_SUB: if (try_subint( ri, ib, ic)) return; break;
++ case TM_MUL: if (try_mulint( ri, ib, ic)) return; break;
++ case TM_DIV: if (try_divint( ri, ib, ic)) return; break;
++ case TM_MOD: if (try_modint( ri, ib, ic)) return; break;
++ case TM_POW: if (try_powint( ri, ib, ic)) return; break;
++ case TM_UNM: if (try_unmint( ri, ib)) return; break;
++ default: lua_assert(0);
++ }
++ }
++ /* Fallback to floating point, when leaving range. */
++
++#ifdef LNUM_COMPLEX
++ if ((nvalue_img(b)!=0) || (nvalue_img(c)!=0)) {
++ lua_Complex r;
++ if (op==TM_UNM) {
++ r= -nvalue_complex_fast(b); /* never an integer (or scalar) */
++ setnvalue_complex_fast( ra, r );
++ } else {
++ lua_Complex bb= nvalue_complex(b), cc= nvalue_complex(c);
++ switch (op) {
++ case TM_ADD: r= bb + cc; break;
++ case TM_SUB: r= bb - cc; break;
++ case TM_MUL: r= bb * cc; break;
++ case TM_DIV: r= bb / cc; break;
++ case TM_MOD:
++ luaG_runerror(L, "attempt to use %% on complex numbers"); /* no return */
++ case TM_POW: r= luai_vectpow( bb, cc ); break;
++ default: lua_assert(0); r=0;
++ }
++ setnvalue_complex( ra, r );
+ }
++ return;
++ }
++#endif
++ nb = nvalue(b); nc = nvalue(c);
++ switch (op) {
++ case TM_ADD: setnvalue(ra, luai_numadd(nb, nc)); return;
++ case TM_SUB: setnvalue(ra, luai_numsub(nb, nc)); return;
++ case TM_MUL: setnvalue(ra, luai_nummul(nb, nc)); return;
++ case TM_DIV: setnvalue(ra, luai_numdiv(nb, nc)); return;
++ case TM_MOD: setnvalue(ra, luai_nummod(nb, nc)); return;
++ case TM_POW: setnvalue(ra, luai_numpow(nb, nc)); return;
++ case TM_UNM: setnvalue(ra, luai_numunm(nb)); return;
++ default: lua_assert(0);
++ }
++ }
++
++ /* Either operand not a number */
++ if (!call_binTM(L, rb, rc, ra, op))
++ luaG_aritherror(L, rb, rc);
++}
+
++/* Helper macro to sort arithmetic operations into four categories:
++ * TK_INT: integer - integer operands
++ * TK_NUMBER: number - number (non complex, either may be integer)
++ * TK_NUMBER2: complex numbers (at least the other)
++ * 0: non-numeric (at least the other)
++*/
++#ifdef LNUM_COMPLEX
++static inline int arith_mode( const TValue *rb, const TValue *rc ) {
++ if (ttisint(rb) && ttisint(rc)) return TK_INT;
++ if (ttiscomplex(rb) || ttiscomplex(rc)) return TK_NUMBER2;
++ if (ttisnumber(rb) && ttisnumber(rc)) return TK_NUMBER;
++ return 0;
++}
++#else
++# define arith_mode(rb,rc) \
++ ( (ttisint(rb) && ttisint(rc)) ? TK_INT : \
++ (ttisnumber(rb) && ttisnumber(rc)) ? TK_NUMBER : 0 )
++#endif
++
++/* arith_op macro for two operators:
++ * automatically chooses, which function (number, integer, complex) to use
++ */
++#define ARITH_OP2_START( op_num, op_int ) \
++ int failed= 0; \
++ switch( arith_mode(rb,rc) ) { \
++ case TK_INT: \
++ if (op_int ( &(ra)->value.i, ivalue(rb), ivalue(rc) )) \
++ { ra->tt= LUA_TINT; break; } /* else flow through */ \
++ case TK_NUMBER: \
++ setnvalue(ra, op_num ( nvalue(rb), nvalue(rc) )); break;
++
++#define ARITH_OP2_END \
++ default: \
++ failed= 1; break; \
++ } if (!failed) continue;
++
++#define arith_op_continue_scalar( op_num, op_int ) \
++ ARITH_OP2_START( op_num, op_int ) \
++ ARITH_OP2_END
++
++#ifdef LNUM_COMPLEX
++# define arith_op_continue( op_num, op_int, op_complex ) \
++ ARITH_OP2_START( op_num, op_int ) \
++ case TK_NUMBER2: \
++ setnvalue_complex( ra, op_complex ( nvalue_complex(rb), nvalue_complex(rc) ) ); break; \
++ ARITH_OP2_END
++#else
++# define arith_op_continue(op_num,op_int,_) arith_op_continue_scalar(op_num,op_int)
++#endif
++
++/* arith_op macro for one operator:
++ */
++#define ARITH_OP1_START( op_num, op_int ) \
++ int failed= 0; \
++ switch( arith_mode(rb,rb) ) { \
++ case TK_INT: \
++ if (op_int ( &(ra)->value.i, ivalue(rb) )) \
++ { ra->tt= LUA_TINT; break; } /* else flow through */ \
++ case TK_NUMBER: \
++ setnvalue(ra, op_num (nvalue(rb))); break; \
++
++#define ARITH_OP1_END \
++ default: \
++ failed= 1; break; \
++ } if (!failed) continue;
++
++#ifdef LNUM_COMPLEX
++# define arith_op1_continue( op_num, op_int, op_complex ) \
++ ARITH_OP1_START( op_num, op_int ) \
++ case TK_NUMBER2: \
++ setnvalue_complex( ra, op_complex ( nvalue_complex_fast(rb) )); break; \
++ ARITH_OP1_END
++#else
++# define arith_op1_continue( op_num, op_int, _ ) \
++ ARITH_OP1_START( op_num, op_int ) \
++ ARITH_OP1_END
++#endif
+
+
+ void luaV_execute (lua_State *L, int nexeccalls) {
+@@ -472,38 +665,45 @@ void luaV_execute (lua_State *L, int nex
+ continue;
+ }
+ case OP_ADD: {
+- arith_op(luai_numadd, TM_ADD);
++ TValue *rb = RKB(i), *rc= RKC(i);
++ arith_op_continue( luai_numadd, try_addint, luai_vectadd );
++ Protect(Arith(L, ra, rb, rc, TM_ADD)); \
+ continue;
+ }
+ case OP_SUB: {
+- arith_op(luai_numsub, TM_SUB);
++ TValue *rb = RKB(i), *rc= RKC(i);
++ arith_op_continue( luai_numsub, try_subint, luai_vectsub );
++ Protect(Arith(L, ra, rb, rc, TM_SUB));
+ continue;
+ }
+ case OP_MUL: {
+- arith_op(luai_nummul, TM_MUL);
++ TValue *rb = RKB(i), *rc= RKC(i);
++ arith_op_continue(luai_nummul, try_mulint, luai_vectmul);
++ Protect(Arith(L, ra, rb, rc, TM_MUL));
+ continue;
+ }
+ case OP_DIV: {
+- arith_op(luai_numdiv, TM_DIV);
++ TValue *rb = RKB(i), *rc= RKC(i);
++ arith_op_continue(luai_numdiv, try_divint, luai_vectdiv);
++ Protect(Arith(L, ra, rb, rc, TM_DIV));
+ continue;
+ }
+ case OP_MOD: {
+- arith_op(luai_nummod, TM_MOD);
++ TValue *rb = RKB(i), *rc= RKC(i);
++ arith_op_continue_scalar(luai_nummod, try_modint); /* scalars only */
++ Protect(Arith(L, ra, rb, rc, TM_MOD));
+ continue;
+ }
+ case OP_POW: {
+- arith_op(luai_numpow, TM_POW);
++ TValue *rb = RKB(i), *rc= RKC(i);
++ arith_op_continue(luai_numpow, try_powint, luai_vectpow);
++ Protect(Arith(L, ra, rb, rc, TM_POW));
+ continue;
+ }
+ case OP_UNM: {
+ TValue *rb = RB(i);
+- if (ttisnumber(rb)) {
+- lua_Number nb = nvalue(rb);
+- setnvalue(ra, luai_numunm(nb));
+- }
+- else {
+- Protect(Arith(L, ra, rb, rb, TM_UNM));
+- }
++ arith_op1_continue(luai_numunm, try_unmint, luai_vectunm);
++ Protect(Arith(L, ra, rb, rb, TM_UNM));
+ continue;
+ }
+ case OP_NOT: {
+@@ -515,11 +715,11 @@ void luaV_execute (lua_State *L, int nex
+ const TValue *rb = RB(i);
+ switch (ttype(rb)) {
+ case LUA_TTABLE: {
+- setnvalue(ra, cast_num(luaH_getn(hvalue(rb))));
++ setivalue(ra, luaH_getn(hvalue(rb)));
+ break;
+ }
+ case LUA_TSTRING: {
+- setnvalue(ra, cast_num(tsvalue(rb)->len));
++ setivalue(ra, tsvalue(rb)->len);
+ break;
+ }
+ default: { /* try metamethod */
+@@ -652,14 +852,30 @@ void luaV_execute (lua_State *L, int nex
+ }
+ }
+ case OP_FORLOOP: {
+- lua_Number step = nvalue(ra+2);
+- lua_Number idx = luai_numadd(nvalue(ra), step); /* increment index */
+- lua_Number limit = nvalue(ra+1);
+- if (luai_numlt(0, step) ? luai_numle(idx, limit)
+- : luai_numle(limit, idx)) {
+- dojump(L, pc, GETARG_sBx(i)); /* jump back */
+- setnvalue(ra, idx); /* update internal index... */
+- setnvalue(ra+3, idx); /* ...and external index */
++ /* If start,step and limit are all integers, we don't need to check
++ * against overflow in the looping.
++ */
++ if (ttisint(ra) && ttisint(ra+1) && ttisint(ra+2)) {
++ lua_Integer step = ivalue(ra+2);
++ lua_Integer idx = ivalue(ra) + step; /* increment index */
++ lua_Integer limit = ivalue(ra+1);
++ if (step > 0 ? (idx <= limit) : (limit <= idx)) {
++ dojump(L, pc, GETARG_sBx(i)); /* jump back */
++ setivalue(ra, idx); /* update internal index... */
++ setivalue(ra+3, idx); /* ...and external index */
++ }
++ } else {
++ /* non-integer looping (don't use 'nvalue_fast', some may be integer!)
++ */
++ lua_Number step = nvalue(ra+2);
++ lua_Number idx = luai_numadd(nvalue(ra), step); /* increment index */
++ lua_Number limit = nvalue(ra+1);
++ if (luai_numlt(0, step) ? luai_numle(idx, limit)
++ : luai_numle(limit, idx)) {
++ dojump(L, pc, GETARG_sBx(i)); /* jump back */
++ setnvalue(ra, idx); /* update internal index... */
++ setnvalue(ra+3, idx); /* ...and external index */
++ }
+ }
+ continue;
+ }
+@@ -668,13 +884,21 @@ void luaV_execute (lua_State *L, int nex
+ const TValue *plimit = ra+1;
+ const TValue *pstep = ra+2;
+ L->savedpc = pc; /* next steps may throw errors */
++ /* Using same location for tonumber's both arguments, effectively does
++ * in-place modification (string->number). */
+ if (!tonumber(init, ra))
+ luaG_runerror(L, LUA_QL("for") " initial value must be a number");
+ else if (!tonumber(plimit, ra+1))
+ luaG_runerror(L, LUA_QL("for") " limit must be a number");
+ else if (!tonumber(pstep, ra+2))
+ luaG_runerror(L, LUA_QL("for") " step must be a number");
+- setnvalue(ra, luai_numsub(nvalue(ra), nvalue(pstep)));
++ /* Step back one value (keep within integers if we can)
++ */
++ if (!( ttisint(ra) && ttisint(pstep) &&
++ try_subint( &ra->value.i, ivalue(ra), ivalue(pstep) ) )) {
++ /* don't use 'nvalue_fast()', values may be integer */
++ setnvalue(ra, luai_numsub(nvalue(ra), nvalue(pstep)));
++ }
+ dojump(L, pc, GETARG_sBx(i));
+ continue;
+ }
+@@ -711,7 +935,7 @@ void luaV_execute (lua_State *L, int nex
+ luaH_resizearray(L, h, last); /* pre-alloc it at once */
+ for (; n > 0; n--) {
+ TValue *val = ra+n;
+- setobj2t(L, luaH_setnum(L, h, last--), val);
++ setobj2t(L, luaH_setint(L, h, last--), val);
+ luaC_barriert(L, h, val);
+ }
+ continue;
+--- a/src/lvm.h
++++ b/src/lvm.h
+@@ -15,11 +15,9 @@
+
+ #define tostring(L,o) ((ttype(o) == LUA_TSTRING) || (luaV_tostring(L, o)))
+
+-#define tonumber(o,n) (ttype(o) == LUA_TNUMBER || \
+- (((o) = luaV_tonumber(o,n)) != NULL))
++#define tonumber(o,n) (ttisnumber(o) || (((o) = luaV_tonumber(o,n)) != NULL))
+
+-#define equalobj(L,o1,o2) \
+- (ttype(o1) == ttype(o2) && luaV_equalval(L, o1, o2))
++#define equalobj(L,o1,o2) (ttype_ext_same(o1,o2) && luaV_equalval(L, o1, o2))
+
+
+ LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r);
+--- a/src/print.c
++++ b/src/print.c
+@@ -14,6 +14,7 @@
+ #include "lobject.h"
+ #include "lopcodes.h"
+ #include "lundump.h"
++#include "lnum.h"
+
+ #define PrintFunction luaU_print
+
+@@ -59,8 +60,16 @@ static void PrintConstant(const Proto* f
+ case LUA_TBOOLEAN:
+ printf(bvalue(o) ? "true" : "false");
+ break;
++ case LUA_TINT:
++ printf(LUA_INTEGER_FMT,ivalue(o));
++ break;
+ case LUA_TNUMBER:
+- printf(LUA_NUMBER_FMT,nvalue(o));
++#ifdef LNUM_COMPLEX
++ // TBD: Do we get complex values here?
++ { lua_Number b= nvalue_img_fast(o);
++ printf( LUA_NUMBER_FMT "%s" LUA_NUMBER_FMT "i", nvalue_fast(o), b>=0 ? "+":"", b ); }
++#endif
++ printf(LUA_NUMBER_FMT,nvalue_fast(o));
+ break;
+ case LUA_TSTRING:
+ PrintString(rawtsvalue(o));
diff --git a/package/lua/patches-host/.svn/text-base/011-lnum-use-double.patch.svn-base b/package/lua/patches-host/.svn/text-base/011-lnum-use-double.patch.svn-base
new file mode 100644
index 0000000..14c720b
--- /dev/null
+++ b/package/lua/patches-host/.svn/text-base/011-lnum-use-double.patch.svn-base
@@ -0,0 +1,11 @@
+--- a/src/lnum_config.h
++++ b/src/lnum_config.h
+@@ -11,7 +11,7 @@
+ ** Default number modes
+ */
+ #if (!defined LNUM_DOUBLE) && (!defined LNUM_FLOAT) && (!defined LNUM_LDOUBLE)
+-# define LNUM_FLOAT
++# define LNUM_DOUBLE
+ #endif
+ #if (!defined LNUM_INT16) && (!defined LNUM_INT32) && (!defined LNUM_INT64)
+ # define LNUM_INT32
diff --git a/package/lua/patches-host/.svn/text-base/015-lnum-ppc-compat.patch.svn-base b/package/lua/patches-host/.svn/text-base/015-lnum-ppc-compat.patch.svn-base
new file mode 100644
index 0000000..2ea59f1
--- /dev/null
+++ b/package/lua/patches-host/.svn/text-base/015-lnum-ppc-compat.patch.svn-base
@@ -0,0 +1,11 @@
+--- a/src/lua.h
++++ b/src/lua.h
+@@ -79,7 +79,7 @@ typedef void * (*lua_Alloc) (void *ud, v
+ * not acceptable for 5.1, maybe 5.2 onwards?
+ * 9: greater than existing (5.1) type values.
+ */
+-#define LUA_TINT (-2)
++#define LUA_TINT 9
+
+ #define LUA_TNIL 0
+ #define LUA_TBOOLEAN 1
diff --git a/package/lua/patches-host/.svn/text-base/030-archindependent-bytecode.patch.svn-base b/package/lua/patches-host/.svn/text-base/030-archindependent-bytecode.patch.svn-base
new file mode 100644
index 0000000..8dfef85
--- /dev/null
+++ b/package/lua/patches-host/.svn/text-base/030-archindependent-bytecode.patch.svn-base
@@ -0,0 +1,111 @@
+--- a/src/ldump.c
++++ b/src/ldump.c
+@@ -67,12 +67,12 @@ static void DumpString(const TString* s,
+ {
+ if (s==NULL || getstr(s)==NULL)
+ {
+- size_t size=0;
++ unsigned int size=0;
+ DumpVar(size,D);
+ }
+ else
+ {
+- size_t size=s->tsv.len+1; /* include trailing '\0' */
++ unsigned int size=s->tsv.len+1; /* include trailing '\0' */
+ DumpVar(size,D);
+ DumpBlock(getstr(s),size,D);
+ }
+--- a/src/lundump.c
++++ b/src/lundump.c
+@@ -25,6 +25,7 @@ typedef struct {
+ ZIO* Z;
+ Mbuffer* b;
+ const char* name;
++ int swap;
+ } LoadState;
+
+ #ifdef LUAC_TRUST_BINARIES
+@@ -40,7 +41,6 @@ static void error(LoadState* S, const ch
+ }
+ #endif
+
+-#define LoadMem(S,b,n,size) LoadBlock(S,b,(n)*(size))
+ #define LoadByte(S) (lu_byte)LoadChar(S)
+ #define LoadVar(S,x) LoadMem(S,&x,1,sizeof(x))
+ #define LoadVector(S,b,n,size) LoadMem(S,b,n,size)
+@@ -51,6 +51,49 @@ static void LoadBlock(LoadState* S, void
+ IF (r!=0, "unexpected end");
+ }
+
++static void LoadMem (LoadState* S, void* b, int n, size_t size)
++{
++ LoadBlock(S,b,n*size);
++ if (S->swap)
++ {
++ char* p=(char*) b;
++ char c;
++ switch (size)
++ {
++ case 1:
++ break;
++ case 2:
++ while (n--)
++ {
++ c=p[0]; p[0]=p[1]; p[1]=c;
++ p+=2;
++ }
++ break;
++ case 4:
++ while (n--)
++ {
++ c=p[0]; p[0]=p[3]; p[3]=c;
++ c=p[1]; p[1]=p[2]; p[2]=c;
++ p+=4;
++ }
++ break;
++ case 8:
++ while (n--)
++ {
++ c=p[0]; p[0]=p[7]; p[7]=c;
++ c=p[1]; p[1]=p[6]; p[6]=c;
++ c=p[2]; p[2]=p[5]; p[5]=c;
++ c=p[3]; p[3]=p[4]; p[4]=c;
++ p+=8;
++ }
++ break;
++ default:
++ IF(1, "bad size");
++ break;
++ }
++ }
++}
++
+ static int LoadChar(LoadState* S)
+ {
+ char x;
+@@ -82,7 +125,7 @@ static lua_Integer LoadInteger(LoadState
+
+ static TString* LoadString(LoadState* S)
+ {
+- size_t size;
++ unsigned int size;
+ LoadVar(S,size);
+ if (size==0)
+ return NULL;
+@@ -196,6 +239,7 @@ static void LoadHeader(LoadState* S)
+ char s[LUAC_HEADERSIZE];
+ luaU_header(h);
+ LoadBlock(S,s,LUAC_HEADERSIZE);
++ S->swap=(s[6]!=h[6]); s[6]=h[6];
+ IF (memcmp(h,s,LUAC_HEADERSIZE)!=0, "bad header");
+ }
+
+@@ -230,7 +274,7 @@ void luaU_header (char* h)
+ *h++=(char)LUAC_FORMAT;
+ *h++=(char)*(char*)&x; /* endianness */
+ *h++=(char)sizeof(int);
+- *h++=(char)sizeof(size_t);
++ *h++=(char)sizeof(unsigned int);
+ *h++=(char)sizeof(Instruction);
+ *h++=(char)sizeof(lua_Number);
+
diff --git a/package/lua/patches-host/.svn/text-base/100-no_readline.patch.svn-base b/package/lua/patches-host/.svn/text-base/100-no_readline.patch.svn-base
new file mode 100644
index 0000000..209c302
--- /dev/null
+++ b/package/lua/patches-host/.svn/text-base/100-no_readline.patch.svn-base
@@ -0,0 +1,49 @@
+--- a/src/luaconf.h
++++ b/src/luaconf.h
+@@ -38,7 +38,6 @@
+ #if defined(LUA_USE_LINUX)
+ #define LUA_USE_POSIX
+ #define LUA_USE_DLOPEN /* needs an extra library: -ldl */
+-#define LUA_USE_READLINE /* needs some extra libraries */
+ #endif
+
+ #if defined(LUA_USE_MACOSX)
+--- a/src/Makefile
++++ b/src/Makefile
+@@ -17,6 +17,7 @@
+ MYCFLAGS=
+ MYLDFLAGS=
+ MYLIBS=
++# USE_READLINE=1
+
+ # == END OF USER SETTINGS. NO NEED TO CHANGE ANYTHING BELOW THIS LINE =========
+
+@@ -75,7 +76,7 @@
+ @echo "MYLIBS = $(MYLIBS)"
+
+ # convenience targets for popular platforms
+-
++RFLAG=$(if $(USE_READLINE),-DLUA_USE_READLINE)
+ none:
+ @echo "Please choose a platform:"
+ @echo " $(PLATS)"
+@@ -90,16 +91,16 @@
+ $(MAKE) all MYCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-Wl,-E"
+
+ freebsd:
+- $(MAKE) all MYCFLAGS="-DLUA_USE_LINUX" MYLIBS="-Wl,-E -lreadline"
++ $(MAKE) all MYCFLAGS="-DLUA_USE_LINUX" $(RFLAG)" MYLIBS="-Wl,-E$(if $(USE_READLINE), -lreadline)"
+
+ generic:
+ $(MAKE) all MYCFLAGS=
+
+ linux:
+- $(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-Wl,-E -ldl -lreadline -lhistory -lncurses"
++ $(MAKE) all MYCFLAGS="-DLUA_USE_LINUX $(RFLAG)" MYLIBS="-Wl,-E -ldl $(if $(USE_READLINE), -lreadline -lhistory -lncurses)"
+
+ macosx:
+- $(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-lreadline"
++ $(MAKE) all MYCFLAGS=-DLUA_USE_LINUX $(if $(USE_READLINE), MYLIBS="-lreadline")
+ # use this on Mac OS X 10.3-
+ # $(MAKE) all MYCFLAGS=-DLUA_USE_MACOSX
+
diff --git a/package/lua/patches-host/010-lua-5.1.3-lnum-full-260308.patch b/package/lua/patches-host/010-lua-5.1.3-lnum-full-260308.patch
new file mode 100644
index 0000000..74b8c6f
--- /dev/null
+++ b/package/lua/patches-host/010-lua-5.1.3-lnum-full-260308.patch
@@ -0,0 +1,3736 @@
+--- a/src/Makefile
++++ b/src/Makefile
+@@ -25,7 +25,7 @@ PLATS= aix ansi bsd freebsd generic linu
+ LUA_A= liblua.a
+ CORE_O= lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o \
+ lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o \
+- lundump.o lvm.o lzio.o
++ lundump.o lvm.o lzio.o lnum.o
+ LIB_O= lauxlib.o lbaselib.o ldblib.o liolib.o lmathlib.o loslib.o ltablib.o \
+ lstrlib.o loadlib.o linit.o
+
+@@ -148,6 +148,7 @@ llex.o: llex.c lua.h luaconf.h ldo.h lob
+ lmathlib.o: lmathlib.c lua.h luaconf.h lauxlib.h lualib.h
+ lmem.o: lmem.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h \
+ ltm.h lzio.h lmem.h ldo.h
++lnum.o: lnum.c lua.h llex.h lnum.h
+ loadlib.o: loadlib.c lua.h luaconf.h lauxlib.h lualib.h
+ lobject.o: lobject.c lua.h luaconf.h ldo.h lobject.h llimits.h lstate.h \
+ ltm.h lzio.h lmem.h lstring.h lgc.h lvm.h
+@@ -179,4 +180,18 @@ lzio.o: lzio.c lua.h luaconf.h llimits.h
+ print.o: print.c ldebug.h lstate.h lua.h luaconf.h lobject.h llimits.h \
+ ltm.h lzio.h lmem.h lopcodes.h lundump.h
+
++luaconf.h: lnum_config.h
++lapi.c: lnum.h
++lauxlib.c: llimits.h
++lbaselib.c: llimits.h lobject.h lapi.h
++lcode.c: lnum.h
++liolib.c: lnum.h llex.h
++llex.c: lnum.h
++lnum.h: lobject.h
++lobject.c: llex.h lnum.h
++ltable.c: lnum.h
++lua.c: llimits.h
++lvm.c: llex.h lnum.h
++print.c: lnum.h
++
+ # (end of Makefile)
+--- a/src/lapi.c
++++ b/src/lapi.c
+@@ -28,7 +28,7 @@
+ #include "ltm.h"
+ #include "lundump.h"
+ #include "lvm.h"
+-
++#include "lnum.h"
+
+
+ const char lua_ident[] =
+@@ -241,12 +241,13 @@ LUA_API void lua_pushvalue (lua_State *L
+
+ LUA_API int lua_type (lua_State *L, int idx) {
+ StkId o = index2adr(L, idx);
+- return (o == luaO_nilobject) ? LUA_TNONE : ttype(o);
++ return (o == luaO_nilobject) ? LUA_TNONE : ttype_ext(o);
+ }
+
+
+ LUA_API const char *lua_typename (lua_State *L, int t) {
+ UNUSED(L);
++ lua_assert( t!= LUA_TINT );
+ return (t == LUA_TNONE) ? "no value" : luaT_typenames[t];
+ }
+
+@@ -264,6 +265,14 @@ LUA_API int lua_isnumber (lua_State *L,
+ }
+
+
++LUA_API int lua_isinteger (lua_State *L, int idx) {
++ TValue tmp;
++ lua_Integer dum;
++ const TValue *o = index2adr(L, idx);
++ return tonumber(o,&tmp) && (ttisint(o) || tt_integer_valued(o,&dum));
++}
++
++
+ LUA_API int lua_isstring (lua_State *L, int idx) {
+ int t = lua_type(L, idx);
+ return (t == LUA_TSTRING || t == LUA_TNUMBER);
+@@ -309,31 +318,66 @@ LUA_API int lua_lessthan (lua_State *L,
+ }
+
+
+-
+ LUA_API lua_Number lua_tonumber (lua_State *L, int idx) {
+ TValue n;
+ const TValue *o = index2adr(L, idx);
+- if (tonumber(o, &n))
++ if (tonumber(o, &n)) {
++#ifdef LNUM_COMPLEX
++ if (nvalue_img(o) != 0)
++ luaG_runerror(L, "expecting a real number");
++#endif
+ return nvalue(o);
+- else
+- return 0;
++ }
++ return 0;
+ }
+
+
+ LUA_API lua_Integer lua_tointeger (lua_State *L, int idx) {
+ TValue n;
++ /* Lua 5.1 documented behaviour is to return nonzero for non-integer:
++ * "If the number is not an integer, it is truncated in some non-specified way."
++ * I would suggest to change this, to return 0 for anything that would
++ * not fit in 'lua_Integer'.
++ */
++#ifdef LUA_COMPAT_TOINTEGER
++ /* Lua 5.1 compatible */
+ const TValue *o = index2adr(L, idx);
+ if (tonumber(o, &n)) {
+- lua_Integer res;
+- lua_Number num = nvalue(o);
+- lua_number2integer(res, num);
+- return res;
++ lua_Integer i;
++ lua_Number d;
++ if (ttisint(o)) return ivalue(o);
++ d= nvalue_fast(o);
++# ifdef LNUM_COMPLEX
++ if (nvalue_img_fast(o) != 0)
++ luaG_runerror(L, "expecting a real number");
++# endif
++ lua_number2integer(i, d);
++ return i;
+ }
+- else
+- return 0;
++#else
++ /* New suggestion */
++ const TValue *o = index2adr(L, idx);
++ if (tonumber(o, &n)) {
++ lua_Integer i;
++ if (ttisint(o)) return ivalue(o);
++ if (tt_integer_valued(o,&i)) return i;
++ }
++#endif
++ return 0;
+ }
+
+
++#ifdef LNUM_COMPLEX
++LUA_API lua_Complex lua_tocomplex (lua_State *L, int idx) {
++ TValue tmp;
++ const TValue *o = index2adr(L, idx);
++ if (tonumber(o, &tmp))
++ return nvalue_complex(o);
++ return 0;
++}
++#endif
++
++
+ LUA_API int lua_toboolean (lua_State *L, int idx) {
+ const TValue *o = index2adr(L, idx);
+ return !l_isfalse(o);
+@@ -364,6 +408,7 @@ LUA_API size_t lua_objlen (lua_State *L,
+ case LUA_TSTRING: return tsvalue(o)->len;
+ case LUA_TUSERDATA: return uvalue(o)->len;
+ case LUA_TTABLE: return luaH_getn(hvalue(o));
++ case LUA_TINT:
+ case LUA_TNUMBER: {
+ size_t l;
+ lua_lock(L); /* `luaV_tostring' may create a new string */
+@@ -426,6 +471,8 @@ LUA_API void lua_pushnil (lua_State *L)
+ }
+
+
++/* 'lua_pushnumber()' may lose accuracy on integers, 'lua_pushinteger' will not.
++ */
+ LUA_API void lua_pushnumber (lua_State *L, lua_Number n) {
+ lua_lock(L);
+ setnvalue(L->top, n);
+@@ -434,12 +481,22 @@ LUA_API void lua_pushnumber (lua_State *
+ }
+
+
+-LUA_API void lua_pushinteger (lua_State *L, lua_Integer n) {
++LUA_API void lua_pushinteger (lua_State *L, lua_Integer i) {
++ lua_lock(L);
++ setivalue(L->top, i);
++ api_incr_top(L);
++ lua_unlock(L);
++}
++
++
++#ifdef LNUM_COMPLEX
++LUA_API void lua_pushcomplex (lua_State *L, lua_Complex v) {
+ lua_lock(L);
+- setnvalue(L->top, cast_num(n));
++ setnvalue_complex( L->top, v );
+ api_incr_top(L);
+ lua_unlock(L);
+ }
++#endif
+
+
+ LUA_API void lua_pushlstring (lua_State *L, const char *s, size_t len) {
+@@ -569,7 +626,7 @@ LUA_API void lua_rawgeti (lua_State *L,
+ lua_lock(L);
+ o = index2adr(L, idx);
+ api_check(L, ttistable(o));
+- setobj2s(L, L->top, luaH_getnum(hvalue(o), n));
++ setobj2s(L, L->top, luaH_getint(hvalue(o), n));
+ api_incr_top(L);
+ lua_unlock(L);
+ }
+@@ -597,6 +654,9 @@ LUA_API int lua_getmetatable (lua_State
+ case LUA_TUSERDATA:
+ mt = uvalue(obj)->metatable;
+ break;
++ case LUA_TINT:
++ mt = G(L)->mt[LUA_TNUMBER];
++ break;
+ default:
+ mt = G(L)->mt[ttype(obj)];
+ break;
+@@ -687,7 +747,7 @@ LUA_API void lua_rawseti (lua_State *L,
+ api_checknelems(L, 1);
+ o = index2adr(L, idx);
+ api_check(L, ttistable(o));
+- setobj2t(L, luaH_setnum(L, hvalue(o), n), L->top-1);
++ setobj2t(L, luaH_setint(L, hvalue(o), n), L->top-1);
+ luaC_barriert(L, hvalue(o), L->top-1);
+ L->top--;
+ lua_unlock(L);
+@@ -721,7 +781,7 @@ LUA_API int lua_setmetatable (lua_State
+ break;
+ }
+ default: {
+- G(L)->mt[ttype(obj)] = mt;
++ G(L)->mt[ttype_ext(obj)] = mt;
+ break;
+ }
+ }
+@@ -1085,3 +1145,32 @@ LUA_API const char *lua_setupvalue (lua_
+ return name;
+ }
+
++
++/* Help function for 'luaB_tonumber()', avoids multiple str->number
++ * conversions for Lua "tonumber()".
++ *
++ * Also pushes floating point numbers with integer value as integer, which
++ * can be used by 'tonumber()' in scripts to bring values back to integer
++ * realm.
++ *
++ * Note: The 'back to integer realm' is _not_ to affect string conversions:
++ * 'tonumber("4294967295.1")' should give a floating point value, although
++ * the value would be 4294967296 (and storable in int64 realm).
++ */
++int lua_pushvalue_as_number (lua_State *L, int idx)
++{
++ const TValue *o = index2adr(L, idx);
++ TValue tmp;
++ lua_Integer i;
++ if (ttisnumber(o)) {
++ if ( (!ttisint(o)) && tt_integer_valued(o,&i)) {
++ lua_pushinteger( L, i );
++ return 1;
++ }
++ } else if (!tonumber(o, &tmp)) {
++ return 0;
++ }
++ if (ttisint(o)) lua_pushinteger( L, ivalue(o) );
++ else lua_pushnumber( L, nvalue_fast(o) );
++ return 1;
++}
+--- a/src/lapi.h
++++ b/src/lapi.h
+@@ -13,4 +13,6 @@
+
+ LUAI_FUNC void luaA_pushobject (lua_State *L, const TValue *o);
+
++int lua_pushvalue_as_number (lua_State *L, int idx);
++
+ #endif
+--- a/src/lauxlib.c
++++ b/src/lauxlib.c
+@@ -23,7 +23,7 @@
+ #include "lua.h"
+
+ #include "lauxlib.h"
+-
++#include "llimits.h"
+
+ #define FREELIST_REF 0 /* free list of references */
+
+@@ -66,7 +66,7 @@ LUALIB_API int luaL_typerror (lua_State
+
+
+ static void tag_error (lua_State *L, int narg, int tag) {
+- luaL_typerror(L, narg, lua_typename(L, tag));
++ luaL_typerror(L, narg, tag==LUA_TINT ? "integer" : lua_typename(L, tag));
+ }
+
+
+@@ -188,8 +188,8 @@ LUALIB_API lua_Number luaL_optnumber (lu
+
+ LUALIB_API lua_Integer luaL_checkinteger (lua_State *L, int narg) {
+ lua_Integer d = lua_tointeger(L, narg);
+- if (d == 0 && !lua_isnumber(L, narg)) /* avoid extra test when d is not 0 */
+- tag_error(L, narg, LUA_TNUMBER);
++ if (d == 0 && !lua_isinteger(L, narg)) /* avoid extra test when d is not 0 */
++ tag_error(L, narg, LUA_TINT);
+ return d;
+ }
+
+@@ -200,6 +200,16 @@ LUALIB_API lua_Integer luaL_optinteger (
+ }
+
+
++#ifdef LNUM_COMPLEX
++LUALIB_API lua_Complex luaL_checkcomplex (lua_State *L, int narg) {
++ lua_Complex c = lua_tocomplex(L, narg);
++ if (c == 0 && !lua_isnumber(L, narg)) /* avoid extra test when c is not 0 */
++ tag_error(L, narg, LUA_TNUMBER);
++ return c;
++}
++#endif
++
++
+ LUALIB_API int luaL_getmetafield (lua_State *L, int obj, const char *event) {
+ if (!lua_getmetatable(L, obj)) /* no metatable? */
+ return 0;
+--- a/src/lauxlib.h
++++ b/src/lauxlib.h
+@@ -57,6 +57,12 @@ LUALIB_API lua_Number (luaL_optnumber) (
+ LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int numArg);
+ LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int nArg,
+ lua_Integer def);
++#define luaL_checkint32(L,narg) ((int)luaL_checkinteger(L,narg))
++#define luaL_optint32(L,narg,def) ((int)luaL_optinteger(L,narg,def))
++
++#ifdef LNUM_COMPLEX
++ LUALIB_API lua_Complex (luaL_checkcomplex) (lua_State *L, int narg);
++#endif
+
+ LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg);
+ LUALIB_API void (luaL_checktype) (lua_State *L, int narg, int t);
+--- a/src/lbaselib.c
++++ b/src/lbaselib.c
+@@ -18,7 +18,9 @@
+
+ #include "lauxlib.h"
+ #include "lualib.h"
+-
++#include "llimits.h"
++#include "lobject.h"
++#include "lapi.h"
+
+
+
+@@ -54,20 +56,25 @@ static int luaB_tonumber (lua_State *L)
+ int base = luaL_optint(L, 2, 10);
+ if (base == 10) { /* standard conversion */
+ luaL_checkany(L, 1);
+- if (lua_isnumber(L, 1)) {
+- lua_pushnumber(L, lua_tonumber(L, 1));
++ if (lua_isnumber(L, 1)) { /* numeric string, or a number */
++ lua_pushvalue_as_number(L,1); /* API extension (not to lose accuracy here) */
+ return 1;
+- }
++ }
+ }
+ else {
+ const char *s1 = luaL_checkstring(L, 1);
+ char *s2;
+- unsigned long n;
++ unsigned LUA_INTEGER n;
+ luaL_argcheck(L, 2 <= base && base <= 36, 2, "base out of range");
+- n = strtoul(s1, &s2, base);
++ n = lua_str2ul(s1, &s2, base);
+ if (s1 != s2) { /* at least one valid digit? */
+ while (isspace((unsigned char)(*s2))) s2++; /* skip trailing spaces */
+ if (*s2 == '\0') { /* no invalid trailing characters? */
++
++ /* Push as number, there needs to be separate 'luaB_tointeger' for
++ * when the caller wants to preserve the bits (matters if unsigned
++ * values are used).
++ */
+ lua_pushnumber(L, (lua_Number)n);
+ return 1;
+ }
+@@ -144,7 +151,7 @@ static int luaB_setfenv (lua_State *L) {
+ luaL_checktype(L, 2, LUA_TTABLE);
+ getfunc(L, 0);
+ lua_pushvalue(L, 2);
+- if (lua_isnumber(L, 1) && lua_tonumber(L, 1) == 0) {
++ if (lua_isnumber(L, 1) && lua_tointeger(L, 1) == 0) {
+ /* change environment of current thread */
+ lua_pushthread(L);
+ lua_insert(L, -2);
+@@ -209,7 +216,7 @@ static int luaB_collectgarbage (lua_Stat
+ return 1;
+ }
+ default: {
+- lua_pushnumber(L, res);
++ lua_pushinteger(L, res);
+ return 1;
+ }
+ }
+@@ -631,6 +638,8 @@ static void base_open (lua_State *L) {
+ luaL_register(L, "_G", base_funcs);
+ lua_pushliteral(L, LUA_VERSION);
+ lua_setglobal(L, "_VERSION"); /* set global _VERSION */
++ lua_pushliteral(L, LUA_LNUM);
++ lua_setglobal(L, "_LNUM"); /* "[complex] double|float|ldouble int32|int64" */
+ /* `ipairs' and `pairs' need auxiliary functions as upvalues */
+ auxopen(L, "ipairs", luaB_ipairs, ipairsaux);
+ auxopen(L, "pairs", luaB_pairs, luaB_next);
+--- a/src/lcode.c
++++ b/src/lcode.c
+@@ -22,13 +22,18 @@
+ #include "lopcodes.h"
+ #include "lparser.h"
+ #include "ltable.h"
++#include "lnum.h"
+
+
+ #define hasjumps(e) ((e)->t != (e)->f)
+
+-
+ static int isnumeral(expdesc *e) {
+- return (e->k == VKNUM && e->t == NO_JUMP && e->f == NO_JUMP);
++ int ek=
++#ifdef LNUM_COMPLEX
++ (e->k == VKNUM2) ||
++#endif
++ (e->k == VKINT) || (e->k == VKNUM);
++ return (ek && e->t == NO_JUMP && e->f == NO_JUMP);
+ }
+
+
+@@ -231,12 +236,16 @@ static int addk (FuncState *fs, TValue *
+ TValue *idx = luaH_set(L, fs->h, k);
+ Proto *f = fs->f;
+ int oldsize = f->sizek;
+- if (ttisnumber(idx)) {
+- lua_assert(luaO_rawequalObj(&fs->f->k[cast_int(nvalue(idx))], v));
+- return cast_int(nvalue(idx));
++ if (ttype(idx)==LUA_TNUMBER) {
++ luai_normalize(idx);
++ lua_assert( ttype(idx)==LUA_TINT ); /* had no fraction */
++ }
++ if (ttisint(idx)) {
++ lua_assert(luaO_rawequalObj(&fs->f->k[ivalue(idx)], v));
++ return cast_int(ivalue(idx));
+ }
+ else { /* constant not found; create a new entry */
+- setnvalue(idx, cast_num(fs->nk));
++ setivalue(idx, fs->nk);
+ luaM_growvector(L, f->k, fs->nk, f->sizek, TValue,
+ MAXARG_Bx, "constant table overflow");
+ while (oldsize < f->sizek) setnilvalue(&f->k[oldsize++]);
+@@ -261,6 +270,21 @@ int luaK_numberK (FuncState *fs, lua_Num
+ }
+
+
++int luaK_integerK (FuncState *fs, lua_Integer r) {
++ TValue o;
++ setivalue(&o, r);
++ return addk(fs, &o, &o);
++}
++
++
++#ifdef LNUM_COMPLEX
++static int luaK_imagK (FuncState *fs, lua_Number r) {
++ TValue o;
++ setnvalue_complex(&o, r*I);
++ return addk(fs, &o, &o);
++}
++#endif
++
+ static int boolK (FuncState *fs, int b) {
+ TValue o;
+ setbvalue(&o, b);
+@@ -359,6 +383,16 @@ static void discharge2reg (FuncState *fs
+ luaK_codeABx(fs, OP_LOADK, reg, luaK_numberK(fs, e->u.nval));
+ break;
+ }
++ case VKINT: {
++ luaK_codeABx(fs, OP_LOADK, reg, luaK_integerK(fs, e->u.ival));
++ break;
++ }
++#ifdef LNUM_COMPLEX
++ case VKNUM2: {
++ luaK_codeABx(fs, OP_LOADK, reg, luaK_imagK(fs, e->u.nval));
++ break;
++ }
++#endif
+ case VRELOCABLE: {
+ Instruction *pc = &getcode(fs, e);
+ SETARG_A(*pc, reg);
+@@ -444,6 +478,10 @@ void luaK_exp2val (FuncState *fs, expdes
+ int luaK_exp2RK (FuncState *fs, expdesc *e) {
+ luaK_exp2val(fs, e);
+ switch (e->k) {
++#ifdef LNUM_COMPLEX
++ case VKNUM2:
++#endif
++ case VKINT:
+ case VKNUM:
+ case VTRUE:
+ case VFALSE:
+@@ -451,6 +489,10 @@ int luaK_exp2RK (FuncState *fs, expdesc
+ if (fs->nk <= MAXINDEXRK) { /* constant fit in RK operand? */
+ e->u.s.info = (e->k == VNIL) ? nilK(fs) :
+ (e->k == VKNUM) ? luaK_numberK(fs, e->u.nval) :
++ (e->k == VKINT) ? luaK_integerK(fs, e->u.ival) :
++#ifdef LNUM_COMPLEX
++ (e->k == VKNUM2) ? luaK_imagK(fs, e->u.nval) :
++#endif
+ boolK(fs, (e->k == VTRUE));
+ e->k = VK;
+ return RKASK(e->u.s.info);
+@@ -540,7 +582,10 @@ void luaK_goiftrue (FuncState *fs, expde
+ int pc; /* pc of last jump */
+ luaK_dischargevars(fs, e);
+ switch (e->k) {
+- case VK: case VKNUM: case VTRUE: {
++#ifdef LNUM_COMPLEX
++ case VKNUM2:
++#endif
++ case VKINT: case VK: case VKNUM: case VTRUE: {
+ pc = NO_JUMP; /* always true; do nothing */
+ break;
+ }
+@@ -590,7 +635,10 @@ static void codenot (FuncState *fs, expd
+ e->k = VTRUE;
+ break;
+ }
+- case VK: case VKNUM: case VTRUE: {
++#ifdef LNUM_COMPLEX
++ case VKNUM2:
++#endif
++ case VKINT: case VK: case VKNUM: case VTRUE: {
+ e->k = VFALSE;
+ break;
+ }
+@@ -626,25 +674,70 @@ void luaK_indexed (FuncState *fs, expdes
+
+ static int constfolding (OpCode op, expdesc *e1, expdesc *e2) {
+ lua_Number v1, v2, r;
++ int vkres= VKNUM;
+ if (!isnumeral(e1) || !isnumeral(e2)) return 0;
+- v1 = e1->u.nval;
+- v2 = e2->u.nval;
++
++ /* real and imaginary parts don't mix. */
++#ifdef LNUM_COMPLEX
++ if (e1->k == VKNUM2) {
++ if ((op != OP_UNM) && (e2->k != VKNUM2)) return 0;
++ vkres= VKNUM2; }
++ else if (e2->k == VKNUM2) { return 0; }
++#endif
++ if ((e1->k == VKINT) && (e2->k == VKINT)) {
++ lua_Integer i1= e1->u.ival, i2= e2->u.ival;
++ lua_Integer rr;
++ int done= 0;
++ /* Integer/integer calculations (may end up producing floating point) */
++ switch (op) {
++ case OP_ADD: done= try_addint( &rr, i1, i2 ); break;
++ case OP_SUB: done= try_subint( &rr, i1, i2 ); break;
++ case OP_MUL: done= try_mulint( &rr, i1, i2 ); break;
++ case OP_DIV: done= try_divint( &rr, i1, i2 ); break;
++ case OP_MOD: done= try_modint( &rr, i1, i2 ); break;
++ case OP_POW: done= try_powint( &rr, i1, i2 ); break;
++ case OP_UNM: done= try_unmint( &rr, i1 ); break;
++ default: done= 0; break;
++ }
++ if (done) {
++ e1->u.ival = rr; /* remained within integer range */
++ return 1;
++ }
++ }
++ v1 = (e1->k == VKINT) ? ((lua_Number)e1->u.ival) : e1->u.nval;
++ v2 = (e2->k == VKINT) ? ((lua_Number)e2->u.ival) : e2->u.nval;
++
+ switch (op) {
+ case OP_ADD: r = luai_numadd(v1, v2); break;
+ case OP_SUB: r = luai_numsub(v1, v2); break;
+- case OP_MUL: r = luai_nummul(v1, v2); break;
++ case OP_MUL:
++#ifdef LNUM_COMPLEX
++ if (vkres==VKNUM2) return 0; /* leave to runtime (could do here, but not worth it?) */
++#endif
++ r = luai_nummul(v1, v2); break;
+ case OP_DIV:
+ if (v2 == 0) return 0; /* do not attempt to divide by 0 */
+- r = luai_numdiv(v1, v2); break;
++#ifdef LNUM_COMPLEX
++ if (vkres==VKNUM2) return 0; /* leave to runtime */
++#endif
++ r = luai_numdiv(v1, v2); break;
+ case OP_MOD:
+ if (v2 == 0) return 0; /* do not attempt to divide by 0 */
++#ifdef LNUM_COMPLEX
++ if (vkres==VKNUM2) return 0; /* leave to runtime */
++#endif
+ r = luai_nummod(v1, v2); break;
+- case OP_POW: r = luai_numpow(v1, v2); break;
++ case OP_POW:
++#ifdef LNUM_COMPLEX
++ if (vkres==VKNUM2) return 0; /* leave to runtime */
++#endif
++ r = luai_numpow(v1, v2); break;
+ case OP_UNM: r = luai_numunm(v1); break;
+ case OP_LEN: return 0; /* no constant folding for 'len' */
+ default: lua_assert(0); r = 0; break;
+ }
+ if (luai_numisnan(r)) return 0; /* do not attempt to produce NaN */
++ e1->k = cast(expkind,vkres);
+ e1->u.nval = r;
+ return 1;
+ }
+@@ -688,7 +781,8 @@ static void codecomp (FuncState *fs, OpC
+
+ void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e) {
+ expdesc e2;
+- e2.t = e2.f = NO_JUMP; e2.k = VKNUM; e2.u.nval = 0;
++ e2.t = e2.f = NO_JUMP; e2.k = VKINT; e2.u.ival = 0;
++
+ switch (op) {
+ case OPR_MINUS: {
+ if (!isnumeral(e))
+--- a/src/lcode.h
++++ b/src/lcode.h
+@@ -71,6 +71,6 @@ LUAI_FUNC void luaK_prefix (FuncState *f
+ LUAI_FUNC void luaK_infix (FuncState *fs, BinOpr op, expdesc *v);
+ LUAI_FUNC void luaK_posfix (FuncState *fs, BinOpr op, expdesc *v1, expdesc *v2);
+ LUAI_FUNC void luaK_setlist (FuncState *fs, int base, int nelems, int tostore);
+-
++LUAI_FUNC int luaK_integerK (FuncState *fs, lua_Integer r);
+
+ #endif
+--- a/src/ldebug.c
++++ b/src/ldebug.c
+@@ -183,7 +183,7 @@ static void collectvalidlines (lua_State
+ int *lineinfo = f->l.p->lineinfo;
+ int i;
+ for (i=0; i<f->l.p->sizelineinfo; i++)
+- setbvalue(luaH_setnum(L, t, lineinfo[i]), 1);
++ setbvalue(luaH_setint(L, t, lineinfo[i]), 1);
+ sethvalue(L, L->top, t);
+ }
+ incr_top(L);
+@@ -566,7 +566,7 @@ static int isinstack (CallInfo *ci, cons
+
+ void luaG_typeerror (lua_State *L, const TValue *o, const char *op) {
+ const char *name = NULL;
+- const char *t = luaT_typenames[ttype(o)];
++ const char *t = luaT_typenames[ttype_ext(o)];
+ const char *kind = (isinstack(L->ci, o)) ?
+ getobjname(L, L->ci, cast_int(o - L->base), &name) :
+ NULL;
+@@ -594,8 +594,8 @@ void luaG_aritherror (lua_State *L, cons
+
+
+ int luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2) {
+- const char *t1 = luaT_typenames[ttype(p1)];
+- const char *t2 = luaT_typenames[ttype(p2)];
++ const char *t1 = luaT_typenames[ttype_ext(p1)];
++ const char *t2 = luaT_typenames[ttype_ext(p2)];
+ if (t1[2] == t2[2])
+ luaG_runerror(L, "attempt to compare two %s values", t1);
+ else
+--- a/src/ldo.c
++++ b/src/ldo.c
+@@ -220,9 +220,9 @@ static StkId adjust_varargs (lua_State *
+ luaD_checkstack(L, p->maxstacksize);
+ htab = luaH_new(L, nvar, 1); /* create `arg' table */
+ for (i=0; i<nvar; i++) /* put extra arguments into `arg' table */
+- setobj2n(L, luaH_setnum(L, htab, i+1), L->top - nvar + i);
++ setobj2n(L, luaH_setint(L, htab, i+1), L->top - nvar + i);
+ /* store counter in field `n' */
+- setnvalue(luaH_setstr(L, htab, luaS_newliteral(L, "n")), cast_num(nvar));
++ setivalue(luaH_setstr(L, htab, luaS_newliteral(L, "n")), nvar);
+ }
+ #endif
+ /* move fixed parameters to final position */
+--- a/src/ldump.c
++++ b/src/ldump.c
+@@ -52,6 +52,11 @@ static void DumpNumber(lua_Number x, Dum
+ DumpVar(x,D);
+ }
+
++static void DumpInteger(lua_Integer x, DumpState* D)
++{
++ DumpVar(x,D);
++}
++
+ static void DumpVector(const void* b, int n, size_t size, DumpState* D)
+ {
+ DumpInt(n,D);
+@@ -93,8 +98,11 @@ static void DumpConstants(const Proto* f
+ DumpChar(bvalue(o),D);
+ break;
+ case LUA_TNUMBER:
+- DumpNumber(nvalue(o),D);
++ DumpNumber(nvalue_fast(o),D);
+ break;
++ case LUA_TINT:
++ DumpInteger(ivalue(o),D);
++ break;
+ case LUA_TSTRING:
+ DumpString(rawtsvalue(o),D);
+ break;
+--- a/src/liolib.c
++++ b/src/liolib.c
+@@ -9,6 +9,7 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
++#include <ctype.h>
+
+ #define liolib_c
+ #define LUA_LIB
+@@ -18,7 +19,8 @@
+ #include "lauxlib.h"
+ #include "lualib.h"
+
+-
++#include "lnum.h"
++#include "llex.h"
+
+ #define IO_INPUT 1
+ #define IO_OUTPUT 2
+@@ -269,6 +271,13 @@ static int io_lines (lua_State *L) {
+ ** =======================================================
+ */
+
++/*
++* Many problems if we intend the same 'n' format specifier (see 'file:read()')
++* to work for both FP and integer numbers, without losing their accuracy. So
++* we don't. 'n' reads numbers as floating points, 'i' as integers. Old code
++* remains valid, but won't provide full integer accuracy (this only matters
++* with float FP and/or 64-bit integers).
++*/
+
+ static int read_number (lua_State *L, FILE *f) {
+ lua_Number d;
+@@ -282,6 +291,43 @@ static int read_number (lua_State *L, FI
+ }
+ }
+
++static int read_integer (lua_State *L, FILE *f) {
++ lua_Integer i;
++ if (fscanf(f, LUA_INTEGER_SCAN, &i) == 1) {
++ lua_pushinteger(L, i);
++ return 1;
++ }
++ else return 0; /* read fails */
++}
++
++#ifdef LNUM_COMPLEX
++static int read_complex (lua_State *L, FILE *f) {
++ /* NNN / NNNi / NNN+MMMi / NNN-MMMi */
++ lua_Number a,b;
++ if (fscanf(f, LUA_NUMBER_SCAN, &a) == 1) {
++ int c=fgetc(f);
++ switch(c) {
++ case 'i':
++ lua_pushcomplex(L, a*I);
++ return 1;
++ case '+':
++ case '-':
++ /* "i" is consumed if at the end; just 'NNN+MMM' will most likely
++ * behave as if "i" was there? (TBD: test)
++ */
++ if (fscanf(f, LUA_NUMBER_SCAN "i", &b) == 1) {
++ lua_pushcomplex(L, a+ (c=='+' ? b:-b)*I);
++ return 1;
++ }
++ }
++ ungetc( c,f );
++ lua_pushnumber(L,a); /*real part only*/
++ return 1;
++ }
++ return 0; /* read fails */
++}
++#endif
++
+
+ static int test_eof (lua_State *L, FILE *f) {
+ int c = getc(f);
+@@ -355,6 +401,14 @@ static int g_read (lua_State *L, FILE *f
+ case 'n': /* number */
+ success = read_number(L, f);
+ break;
++ case 'i': /* integer (full accuracy) */
++ success = read_integer(L, f);
++ break;
++#ifdef LNUM_COMPLEX
++ case 'c': /* complex */
++ success = read_complex(L, f);
++ break;
++#endif
+ case 'l': /* line */
+ success = read_line(L, f);
+ break;
+@@ -415,9 +469,10 @@ static int g_write (lua_State *L, FILE *
+ int status = 1;
+ for (; nargs--; arg++) {
+ if (lua_type(L, arg) == LUA_TNUMBER) {
+- /* optimization: could be done exactly as for strings */
+- status = status &&
+- fprintf(f, LUA_NUMBER_FMT, lua_tonumber(L, arg)) > 0;
++ if (lua_isinteger(L,arg))
++ status = status && fprintf(f, LUA_INTEGER_FMT, lua_tointeger(L, arg)) > 0;
++ else
++ status = status && fprintf(f, LUA_NUMBER_FMT, lua_tonumber(L, arg)) > 0;
+ }
+ else {
+ size_t l;
+@@ -460,7 +515,7 @@ static int f_setvbuf (lua_State *L) {
+ static const char *const modenames[] = {"no", "full", "line", NULL};
+ FILE *f = tofile(L);
+ int op = luaL_checkoption(L, 2, NULL, modenames);
+- lua_Integer sz = luaL_optinteger(L, 3, LUAL_BUFFERSIZE);
++ size_t sz = luaL_optint32(L, 3, LUAL_BUFFERSIZE);
+ int res = setvbuf(f, NULL, mode[op], sz);
+ return pushresult(L, res == 0, NULL);
+ }
+--- a/src/llex.c
++++ b/src/llex.c
+@@ -22,6 +22,7 @@
+ #include "lstring.h"
+ #include "ltable.h"
+ #include "lzio.h"
++#include "lnum.h"
+
+
+
+@@ -34,13 +35,17 @@
+
+
+ /* ORDER RESERVED */
+-const char *const luaX_tokens [] = {
++static const char *const luaX_tokens [] = {
+ "and", "break", "do", "else", "elseif",
+ "end", "false", "for", "function", "if",
+ "in", "local", "nil", "not", "or", "repeat",
+ "return", "then", "true", "until", "while",
+ "..", "...", "==", ">=", "<=", "~=",
+ "<number>", "<name>", "<string>", "<eof>",
++ "<integer>",
++#ifdef LNUM_COMPLEX
++ "<number2>",
++#endif
+ NULL
+ };
+
+@@ -90,7 +95,11 @@ static const char *txtToken (LexState *l
+ switch (token) {
+ case TK_NAME:
+ case TK_STRING:
++ case TK_INT:
+ case TK_NUMBER:
++#ifdef LNUM_COMPLEX
++ case TK_NUMBER2:
++#endif
+ save(ls, '\0');
+ return luaZ_buffer(ls->buff);
+ default:
+@@ -175,23 +184,27 @@ static void buffreplace (LexState *ls, c
+ if (p[n] == from) p[n] = to;
+ }
+
+-
+-static void trydecpoint (LexState *ls, SemInfo *seminfo) {
++/* TK_NUMBER (/ TK_NUMBER2) */
++static int trydecpoint (LexState *ls, SemInfo *seminfo) {
+ /* format error: try to update decimal point separator */
+ struct lconv *cv = localeconv();
+ char old = ls->decpoint;
++ int ret;
+ ls->decpoint = (cv ? cv->decimal_point[0] : '.');
+ buffreplace(ls, old, ls->decpoint); /* try updated decimal separator */
+- if (!luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r)) {
++ ret= luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r, NULL);
++ if (!ret) {
+ /* format error with correct decimal point: no more options */
+ buffreplace(ls, ls->decpoint, '.'); /* undo change (for error message) */
+ luaX_lexerror(ls, "malformed number", TK_NUMBER);
+ }
++ return ret;
+ }
+
+
+-/* LUA_NUMBER */
+-static void read_numeral (LexState *ls, SemInfo *seminfo) {
++/* TK_NUMBER / TK_INT (/TK_NUMBER2) */
++static int read_numeral (LexState *ls, SemInfo *seminfo) {
++ int ret;
+ lua_assert(isdigit(ls->current));
+ do {
+ save_and_next(ls);
+@@ -202,8 +215,9 @@ static void read_numeral (LexState *ls,
+ save_and_next(ls);
+ save(ls, '\0');
+ buffreplace(ls, '.', ls->decpoint); /* follow locale for decimal point */
+- if (!luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r)) /* format error? */
+- trydecpoint(ls, seminfo); /* try to update decimal point separator */
++ ret= luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r, &seminfo->i );
++ if (!ret) return trydecpoint(ls, seminfo); /* try to update decimal point separator */
++ return ret;
+ }
+
+
+@@ -331,6 +345,7 @@ static void read_string (LexState *ls, i
+ }
+
+
++/* char / TK_* */
+ static int llex (LexState *ls, SemInfo *seminfo) {
+ luaZ_resetbuffer(ls->buff);
+ for (;;) {
+@@ -402,8 +417,7 @@ static int llex (LexState *ls, SemInfo *
+ }
+ else if (!isdigit(ls->current)) return '.';
+ else {
+- read_numeral(ls, seminfo);
+- return TK_NUMBER;
++ return read_numeral(ls, seminfo);
+ }
+ }
+ case EOZ: {
+@@ -416,8 +430,7 @@ static int llex (LexState *ls, SemInfo *
+ continue;
+ }
+ else if (isdigit(ls->current)) {
+- read_numeral(ls, seminfo);
+- return TK_NUMBER;
++ return read_numeral(ls, seminfo);
+ }
+ else if (isalpha(ls->current) || ls->current == '_') {
+ /* identifier or reserved word */
+--- a/src/llex.h
++++ b/src/llex.h
+@@ -29,19 +29,22 @@ enum RESERVED {
+ TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE,
+ /* other terminal symbols */
+ TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, TK_NUMBER,
+- TK_NAME, TK_STRING, TK_EOS
++ TK_NAME, TK_STRING, TK_EOS, TK_INT
++#ifdef LNUM_COMPLEX
++ , TK_NUMBER2 /* imaginary constants: Ni */
++#endif
+ };
+
+ /* number of reserved words */
+ #define NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1))
+
+
+-/* array with token `names' */
+-LUAI_DATA const char *const luaX_tokens [];
+-
+-
++/* SemInfo is a local data structure of 'llex.c', used for carrying a string
++ * or a number. A separate token (TK_*) will tell, how to interpret the data.
++ */
+ typedef union {
+ lua_Number r;
++ lua_Integer i;
+ TString *ts;
+ } SemInfo; /* semantics information */
+
+--- a/src/llimits.h
++++ b/src/llimits.h
+@@ -49,6 +49,7 @@ typedef LUAI_USER_ALIGNMENT_T L_Umaxalig
+
+ /* result of a `usual argument conversion' over lua_Number */
+ typedef LUAI_UACNUMBER l_uacNumber;
++typedef LUAI_UACINTEGER l_uacInteger;
+
+
+ /* internal assertions for in-house debugging */
+@@ -80,7 +81,6 @@ typedef LUAI_UACNUMBER l_uacNumber;
+ #define cast_int(i) cast(int, (i))
+
+
+-
+ /*
+ ** type for virtual-machine instructions
+ ** must be an unsigned with (at least) 4 bytes (see details in lopcodes.h)
+--- a/src/lmathlib.c
++++ b/src/lmathlib.c
+@@ -4,7 +4,6 @@
+ ** See Copyright Notice in lua.h
+ */
+
+-
+ #include <stdlib.h>
+ #include <math.h>
+
+@@ -16,113 +15,210 @@
+ #include "lauxlib.h"
+ #include "lualib.h"
+
++/* 'luai_vectpow()' as a replacement for 'cpow()'. Defined in the header; we
++ * don't intrude the code libs internal functions.
++ */
++#ifdef LNUM_COMPLEX
++# include "lnum.h"
++#endif
+
+ #undef PI
+-#define PI (3.14159265358979323846)
+-#define RADIANS_PER_DEGREE (PI/180.0)
+-
++#ifdef LNUM_FLOAT
++# define PI (3.14159265358979323846F)
++#elif defined(M_PI)
++# define PI M_PI
++#else
++# define PI (3.14159265358979323846264338327950288)
++#endif
++#define RADIANS_PER_DEGREE (PI/180)
+
++#undef HUGE
++#ifdef LNUM_FLOAT
++# define HUGE HUGE_VALF
++#elif defined(LNUM_LDOUBLE)
++# define HUGE HUGE_VALL
++#else
++# define HUGE HUGE_VAL
++#endif
+
+ static int math_abs (lua_State *L) {
+- lua_pushnumber(L, fabs(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_pushnumber(L, _LF(cabs) (luaL_checkcomplex(L,1)));
++#else
++ lua_pushnumber(L, _LF(fabs) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+ static int math_sin (lua_State *L) {
+- lua_pushnumber(L, sin(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(csin) (luaL_checkcomplex(L,1)));
++#else
++ lua_pushnumber(L, _LF(sin) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+ static int math_sinh (lua_State *L) {
+- lua_pushnumber(L, sinh(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(csinh) (luaL_checkcomplex(L,1)));
++#else
++ lua_pushnumber(L, _LF(sinh) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+ static int math_cos (lua_State *L) {
+- lua_pushnumber(L, cos(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(ccos) (luaL_checkcomplex(L,1)));
++#else
++ lua_pushnumber(L, _LF(cos) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+ static int math_cosh (lua_State *L) {
+- lua_pushnumber(L, cosh(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(ccosh) (luaL_checkcomplex(L,1)));
++#else
++ lua_pushnumber(L, _LF(cosh) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+ static int math_tan (lua_State *L) {
+- lua_pushnumber(L, tan(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(ctan) (luaL_checkcomplex(L,1)));
++#else
++ lua_pushnumber(L, _LF(tan) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+ static int math_tanh (lua_State *L) {
+- lua_pushnumber(L, tanh(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(ctanh) (luaL_checkcomplex(L,1)));
++#else
++ lua_pushnumber(L, _LF(tanh) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+ static int math_asin (lua_State *L) {
+- lua_pushnumber(L, asin(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(casin) (luaL_checkcomplex(L,1)));
++#else
++ lua_pushnumber(L, _LF(asin) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+ static int math_acos (lua_State *L) {
+- lua_pushnumber(L, acos(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(cacos) (luaL_checkcomplex(L,1)));
++#else
++ lua_pushnumber(L, _LF(acos) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+ static int math_atan (lua_State *L) {
+- lua_pushnumber(L, atan(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(catan) (luaL_checkcomplex(L,1)));
++#else
++ lua_pushnumber(L, _LF(atan) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+ static int math_atan2 (lua_State *L) {
+- lua_pushnumber(L, atan2(luaL_checknumber(L, 1), luaL_checknumber(L, 2)));
++ /* scalars only */
++ lua_pushnumber(L, _LF(atan2) (luaL_checknumber(L, 1), luaL_checknumber(L, 2)));
+ return 1;
+ }
+
+ static int math_ceil (lua_State *L) {
+- lua_pushnumber(L, ceil(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_Complex v= luaL_checkcomplex(L, 1);
++ lua_pushcomplex(L, _LF(ceil) (_LF(creal)(v)) + _LF(ceil) (_LF(cimag)(v))*I);
++#else
++ lua_pushnumber(L, _LF(ceil) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+ static int math_floor (lua_State *L) {
+- lua_pushnumber(L, floor(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_Complex v= luaL_checkcomplex(L, 1);
++ lua_pushcomplex(L, _LF(floor) (_LF(creal)(v)) + _LF(floor) (_LF(cimag)(v))*I);
++#else
++ lua_pushnumber(L, _LF(floor) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+-static int math_fmod (lua_State *L) {
+- lua_pushnumber(L, fmod(luaL_checknumber(L, 1), luaL_checknumber(L, 2)));
++static int math_fmod (lua_State *L) {
++ /* scalars only */
++ lua_pushnumber(L, _LF(fmod) (luaL_checknumber(L, 1), luaL_checknumber(L, 2)));
+ return 1;
+ }
+
+ static int math_modf (lua_State *L) {
+- double ip;
+- double fp = modf(luaL_checknumber(L, 1), &ip);
++ /* scalars only */
++ lua_Number ip;
++ lua_Number fp = _LF(modf) (luaL_checknumber(L, 1), &ip);
+ lua_pushnumber(L, ip);
+ lua_pushnumber(L, fp);
+ return 2;
+ }
+
+ static int math_sqrt (lua_State *L) {
+- lua_pushnumber(L, sqrt(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(csqrt) (luaL_checkcomplex(L,1)));
++#else
++ lua_pushnumber(L, _LF(sqrt) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+ static int math_pow (lua_State *L) {
+- lua_pushnumber(L, pow(luaL_checknumber(L, 1), luaL_checknumber(L, 2)));
++#ifdef LNUM_COMPLEX
++ /* C99 'cpow' gives somewhat inaccurate results (i.e. (-1)^2 = -1+1.2246467991474e-16i).
++ * 'luai_vectpow' smoothens such, reusing it is the reason we need to #include "lnum.h".
++ */
++ lua_pushcomplex(L, luai_vectpow(luaL_checkcomplex(L,1), luaL_checkcomplex(L,2)));
++#else
++ lua_pushnumber(L, _LF(pow) (luaL_checknumber(L, 1), luaL_checknumber(L, 2)));
++#endif
+ return 1;
+ }
+
+ static int math_log (lua_State *L) {
+- lua_pushnumber(L, log(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(clog) (luaL_checkcomplex(L,1)));
++#else
++ lua_pushnumber(L, _LF(log) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+ static int math_log10 (lua_State *L) {
+- lua_pushnumber(L, log10(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ /* Not in standard <complex.h> , but easy to calculate: log_a(x) = log_b(x) / log_b(a)
++ */
++ lua_pushcomplex(L, _LF(clog) (luaL_checkcomplex(L,1)) / _LF(log) (10));
++#else
++ lua_pushnumber(L, _LF(log10) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+ static int math_exp (lua_State *L) {
+- lua_pushnumber(L, exp(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(cexp) (luaL_checkcomplex(L,1)));
++#else
++ lua_pushnumber(L, _LF(exp) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+@@ -138,19 +234,20 @@ static int math_rad (lua_State *L) {
+
+ static int math_frexp (lua_State *L) {
+ int e;
+- lua_pushnumber(L, frexp(luaL_checknumber(L, 1), &e));
++ lua_pushnumber(L, _LF(frexp) (luaL_checknumber(L, 1), &e));
+ lua_pushinteger(L, e);
+ return 2;
+ }
+
+ static int math_ldexp (lua_State *L) {
+- lua_pushnumber(L, ldexp(luaL_checknumber(L, 1), luaL_checkint(L, 2)));
++ lua_pushnumber(L, _LF(ldexp) (luaL_checknumber(L, 1), luaL_checkint(L, 2)));
+ return 1;
+ }
+
+
+
+ static int math_min (lua_State *L) {
++ /* scalars only */
+ int n = lua_gettop(L); /* number of arguments */
+ lua_Number dmin = luaL_checknumber(L, 1);
+ int i;
+@@ -165,6 +262,7 @@ static int math_min (lua_State *L) {
+
+
+ static int math_max (lua_State *L) {
++ /* scalars only */
+ int n = lua_gettop(L); /* number of arguments */
+ lua_Number dmax = luaL_checknumber(L, 1);
+ int i;
+@@ -182,25 +280,20 @@ static int math_random (lua_State *L) {
+ /* the `%' avoids the (rare) case of r==1, and is needed also because on
+ some systems (SunOS!) `rand()' may return a value larger than RAND_MAX */
+ lua_Number r = (lua_Number)(rand()%RAND_MAX) / (lua_Number)RAND_MAX;
+- switch (lua_gettop(L)) { /* check number of arguments */
+- case 0: { /* no arguments */
+- lua_pushnumber(L, r); /* Number between 0 and 1 */
+- break;
+- }
+- case 1: { /* only upper limit */
+- int u = luaL_checkint(L, 1);
+- luaL_argcheck(L, 1<=u, 1, "interval is empty");
+- lua_pushnumber(L, floor(r*u)+1); /* int between 1 and `u' */
+- break;
+- }
+- case 2: { /* lower and upper limits */
+- int l = luaL_checkint(L, 1);
+- int u = luaL_checkint(L, 2);
+- luaL_argcheck(L, l<=u, 2, "interval is empty");
+- lua_pushnumber(L, floor(r*(u-l+1))+l); /* int between `l' and `u' */
+- break;
+- }
+- default: return luaL_error(L, "wrong number of arguments");
++ int n= lua_gettop(L); /* number of arguments */
++ if (n==0) { /* no arguments: range [0,1) */
++ lua_pushnumber(L, r);
++ } else if (n<=2) { /* int range [1,u] or [l,u] */
++ int l= n==1 ? 1 : luaL_checkint(L, 1);
++ int u = luaL_checkint(L, n);
++ int tmp;
++ lua_Number d;
++ luaL_argcheck(L, l<=u, n, "interval is empty");
++ d= _LF(floor)(r*(u-l+1));
++ lua_number2int(tmp,d);
++ lua_pushinteger(L, l+tmp);
++ } else {
++ return luaL_error(L, "wrong number of arguments");
+ }
+ return 1;
+ }
+@@ -211,6 +304,66 @@ static int math_randomseed (lua_State *L
+ return 0;
+ }
+
++/*
++* Lua 5.1 does not have acosh, asinh, atanh for scalars (not ANSI C)
++*/
++#if __STDC_VERSION__ >= 199901L
++static int math_acosh (lua_State *L) {
++# ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(cacosh) (luaL_checkcomplex(L,1)));
++# else
++ lua_pushnumber(L, _LF(acosh) (luaL_checknumber(L,1)));
++# endif
++ return 1;
++}
++static int math_asinh (lua_State *L) {
++# ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(casinh) (luaL_checkcomplex(L,1)));
++# else
++ lua_pushnumber(L, _LF(asinh) (luaL_checknumber(L,1)));
++# endif
++ return 1;
++}
++static int math_atanh (lua_State *L) {
++# ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(catanh) (luaL_checkcomplex(L,1)));
++# else
++ lua_pushnumber(L, _LF(atanh) (luaL_checknumber(L,1)));
++# endif
++ return 1;
++}
++#endif
++
++/*
++ * C99 complex functions, not covered above.
++*/
++#ifdef LNUM_COMPLEX
++static int math_arg (lua_State *L) {
++ lua_pushnumber(L, _LF(carg) (luaL_checkcomplex(L,1)));
++ return 1;
++}
++
++static int math_imag (lua_State *L) {
++ lua_pushnumber(L, _LF(cimag) (luaL_checkcomplex(L,1)));
++ return 1;
++}
++
++static int math_real (lua_State *L) {
++ lua_pushnumber(L, _LF(creal) (luaL_checkcomplex(L,1)));
++ return 1;
++}
++
++static int math_conj (lua_State *L) {
++ lua_pushcomplex(L, _LF(conj) (luaL_checkcomplex(L,1)));
++ return 1;
++}
++
++static int math_proj (lua_State *L) {
++ lua_pushcomplex(L, _LF(cproj) (luaL_checkcomplex(L,1)));
++ return 1;
++}
++#endif
++
+
+ static const luaL_Reg mathlib[] = {
+ {"abs", math_abs},
+@@ -241,6 +394,18 @@ static const luaL_Reg mathlib[] = {
+ {"sqrt", math_sqrt},
+ {"tanh", math_tanh},
+ {"tan", math_tan},
++#if __STDC_VERSION__ >= 199901L
++ {"acosh", math_acosh},
++ {"asinh", math_asinh},
++ {"atanh", math_atanh},
++#endif
++#ifdef LNUM_COMPLEX
++ {"arg", math_arg},
++ {"imag", math_imag},
++ {"real", math_real},
++ {"conj", math_conj},
++ {"proj", math_proj},
++#endif
+ {NULL, NULL}
+ };
+
+@@ -252,8 +417,10 @@ LUALIB_API int luaopen_math (lua_State *
+ luaL_register(L, LUA_MATHLIBNAME, mathlib);
+ lua_pushnumber(L, PI);
+ lua_setfield(L, -2, "pi");
+- lua_pushnumber(L, HUGE_VAL);
++ lua_pushnumber(L, HUGE);
+ lua_setfield(L, -2, "huge");
++ lua_pushinteger(L, LUA_INTEGER_MAX );
++ lua_setfield(L, -2, "hugeint");
+ #if defined(LUA_COMPAT_MOD)
+ lua_getfield(L, -1, "fmod");
+ lua_setfield(L, -2, "mod");
+--- /dev/null
++++ b/src/lnum.c
+@@ -0,0 +1,312 @@
++/*
++** $Id: lnum.c,v ... $
++** Internal number model
++** See Copyright Notice in lua.h
++*/
++
++#include <stdlib.h>
++#include <math.h>
++#include <ctype.h>
++#include <string.h>
++#include <stdio.h>
++#include <errno.h>
++
++#define lnum_c
++#define LUA_CORE
++
++#include "lua.h"
++#include "llex.h"
++#include "lnum.h"
++
++/*
++** lua_real2str converts a (non-complex) number to a string.
++** lua_str2real converts a string to a (non-complex) number.
++*/
++#define lua_real2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n))
++
++/*
++* Note: Only 'strtod()' is part of ANSI C; others are C99 and
++* may need '--std=c99' compiler setting (at least on Ubuntu 7.10).
++*
++* Visual C++ 2008 Express does not have 'strtof()', nor 'strtold()'.
++* References to '_strtold()' exist but don't compile. It seems best
++* to leave Windows users with DOUBLE only (or compile with MinGW).
++*
++* In practise, using '(long double)strtod' is a risky thing, since
++* it will cause accuracy loss in reading in numbers, and such losses
++* will pile up in later processing. Get a real 'strtold()' or don't
++* use that mode at all.
++*/
++#ifdef LNUM_DOUBLE
++# define lua_str2real strtod
++#elif defined(LNUM_FLOAT)
++# define lua_str2real strtof
++#elif defined(LNUM_LDOUBLE)
++# define lua_str2real strtold
++#endif
++
++#define lua_integer2str(s,v) sprintf((s), LUA_INTEGER_FMT, (v))
++
++/* 's' is expected to be LUAI_MAXNUMBER2STR long (enough for any number)
++*/
++void luaO_num2buf( char *s, const TValue *o )
++{
++ lua_Number n;
++ lua_assert( ttisnumber(o) );
++
++ /* Reason to handle integers differently is not only speed, but accuracy as
++ * well. We want to make any integer tostring() without roundings, at all.
++ */
++ if (ttisint(o)) {
++ lua_integer2str( s, ivalue(o) );
++ return;
++ }
++ n= nvalue_fast(o);
++ lua_real2str(s, n);
++
++#ifdef LNUM_COMPLEX
++ lua_Number n2= nvalue_img_fast(o);
++ if (n2!=0) { /* Postfix with +-Ni */
++ int re0= (n == 0);
++ char *s2= re0 ? s : strchr(s,'\0');
++ if ((!re0) && (n2>0)) *s2++= '+';
++ lua_real2str( s2, n2 );
++ strcat(s2,"i");
++ }
++#endif
++}
++
++/*
++* If a LUA_TNUMBER has integer value, give it.
++*/
++int /*bool*/ tt_integer_valued( const TValue *o, lua_Integer *ref ) {
++ lua_Number d;
++ lua_Integer i;
++
++ lua_assert( ttype(o)==LUA_TNUMBER );
++ lua_assert( ref );
++#ifdef LNUM_COMPLEX
++ if (nvalue_img_fast(o)!=0) return 0;
++#endif
++ d= nvalue_fast(o);
++ lua_number2integer(i, d);
++ if (cast_num(i) == d) {
++ *ref= i; return 1;
++ }
++ return 0;
++}
++
++/*
++ * Lua 5.1.3 (using 'strtod()') allows 0x+hex but not 0+octal. This is good,
++ * and we should NOT use 'autobase' 0 with 'strtoul[l]()' for this reason.
++ *
++ * Lua 5.1.3 allows '0x...' numbers to overflow and lose precision; this is not
++ * good. On Visual C++ 2008, 'strtod()' does not even take them in. Better to
++ * require hex values to fit 'lua_Integer' or give an error that they don't?
++ *
++ * Full hex range (0 .. 0xff..ff) is stored as integers, not to lose any bits.
++ * Numerical value of 0xff..ff will be -1, if used in calculations.
++ *
++ * Returns: TK_INT for a valid integer, '*endptr_ref' updated
++ * TK_NUMBER for seemingly numeric, to be parsed as floating point
++ * 0 for bad characters, not a number (or '0x' out of range)
++ */
++static int luaO_str2i (const char *s, lua_Integer *res, char **endptr_ref) {
++ char *endptr;
++ /* 'v' gets ULONG_MAX on possible overflow (which is > LUA_INTEGER_MAX);
++ * we don't have to check 'errno' here.
++ */
++ unsigned LUA_INTEGER v= lua_str2ul(s, &endptr, 10);
++ if (endptr == s) return 0; /* nothing numeric */
++ if (v==0 && *endptr=='x') {
++ errno= 0; /* needs to be set, 'strtoul[l]' does not clear it */
++ v= lua_str2ul(endptr+1, &endptr, 16); /* retry as hex, unsigned range */
++ if (errno==ERANGE) { /* clamped to 0xff..ff */
++#if (defined(LNUM_INT32) && !defined(LNUM_FLOAT)) || defined(LNUM_LDOUBLE)
++ return TK_NUMBER; /* Allow to be read as floating point (has more integer range) */
++#else
++ return 0; /* Reject the number */
++#endif
++ }
++ } else if ((v > LUA_INTEGER_MAX) || (*endptr && (!isspace(*endptr)))) {
++ return TK_NUMBER; /* not in signed range, or has '.', 'e' etc. trailing */
++ }
++ *res= (lua_Integer)v;
++ *endptr_ref= endptr;
++ return TK_INT;
++}
++
++/* 0 / TK_NUMBER / TK_INT (/ TK_NUMBER2) */
++int luaO_str2d (const char *s, lua_Number *res_n, lua_Integer *res_i) {
++ char *endptr;
++ int ret= TK_NUMBER;
++ /* Check integers first, if caller is allowing.
++ * If 'res2'==NULL, they're only looking for floating point.
++ */
++ if (res_i) {
++ ret= luaO_str2i(s,res_i,&endptr);
++ if (ret==0) return 0;
++ }
++ if (ret==TK_NUMBER) {
++ lua_assert(res_n);
++ /* Note: Visual C++ 2008 Express 'strtod()' does not read in "0x..."
++ * numbers; it will read '0' and spit 'x' as endptr.
++ * This means hex constants not fitting in 'lua_Integer' won't
++ * be read in at all. What to do?
++ */
++ *res_n = lua_str2real(s, &endptr);
++ if (endptr == s) return 0; /* conversion failed */
++ /* Visual C++ 2008 'strtod()' does not allow "0x..." input. */
++#if defined(_MSC_VER) && !defined(LNUM_FLOAT) && !defined(LNUM_INT64)
++ if (*res_n==0 && *endptr=='x') {
++ /* Hex constant too big for 'lua_Integer' but that could fit in 'lua_Number'
++ * integer bits
++ */
++ unsigned __int64 v= _strtoui64( s, &endptr, 16 );
++ /* We just let > 64 bit values be clamped to _UI64_MAX (MSDN does not say 'errno'==ERANGE would be set) */
++ *res_n= cast_num(v);
++ if (*res_n != v) return 0; /* Would have lost accuracy */
++ }
++#endif
++#ifdef LNUM_COMPLEX
++ if (*endptr == 'i') { endptr++; ret= TK_NUMBER2; }
++#endif
++ }
++ if (*endptr) {
++ while (isspace(cast(unsigned char, *endptr))) endptr++;
++ if (*endptr) return 0; /* invalid trail */
++ }
++ return ret;
++}
++
++
++/* Functions for finding out, when integer operations remain in range
++ * (and doing them).
++ */
++int try_addint( lua_Integer *r, lua_Integer ib, lua_Integer ic ) {
++ lua_Integer v= ib+ic; /* may overflow */
++ if (ib>0 && ic>0) { if (v < 0) return 0; /*overflow, use floats*/ }
++ else if (ib<0 && ic<0) { if (v >= 0) return 0; }
++ *r= v;
++ return 1;
++}
++
++int try_subint( lua_Integer *r, lua_Integer ib, lua_Integer ic ) {
++ lua_Integer v= ib-ic; /* may overflow */
++ if (ib>=0 && ic<0) { if (v < 0) return 0; /*overflow, use floats*/ }
++ else if (ib<0 && ic>0) { if (v >= 0) return 0; }
++ *r= v;
++ return 1;
++}
++
++int try_mulint( lua_Integer *r, lua_Integer ib, lua_Integer ic ) {
++ if (ib!=LUA_INTEGER_MIN && ic!=LUA_INTEGER_MIN) {
++ lua_Integer b= luai_abs(ib), c= luai_abs(ic);
++ if ( (ib==0) || (LUA_INTEGER_MAX/b >= c) ) {
++ *r= ib*ic; /* no overflow */
++ return 1;
++ }
++ } else if (ib==0 || ic==0) {
++ *r= 0; return 1;
++ }
++
++ /* Result can be LUA_INTEGER_MIN; if it is, calculating it using floating
++ * point will not cause accuracy loss.
++ */
++ if ( luai_nummul( cast_num(ib), cast_num(ic) ) == LUA_INTEGER_MIN ) {
++ *r= LUA_INTEGER_MIN;
++ return 1;
++ }
++ return 0;
++}
++
++int try_divint( lua_Integer *r, lua_Integer ib, lua_Integer ic ) {
++ /* N/0: leave to float side, to give an error
++ */
++ if (ic==0) return 0;
++
++ /* N/LUA_INTEGER_MIN: always non-integer results, or 0 or +1
++ */
++ if (ic==LUA_INTEGER_MIN) {
++ if (ib==LUA_INTEGER_MIN) { *r=1; return 1; }
++ if (ib==0) { *r=0; return 1; }
++
++ /* LUA_INTEGER_MIN (-2^31|63)/N: calculate using float side (either the division
++ * causes non-integer results, or there is no accuracy loss in int->fp->int
++ * conversions (N=2,4,8,..,256 and N=2^30,2^29,..2^23).
++ */
++ } else if (ib==LUA_INTEGER_MIN) {
++ lua_Number d= luai_numdiv( cast_num(LUA_INTEGER_MIN), cast_num(ic) );
++ lua_Integer i; lua_number2integer(i,d);
++ if (cast_num(i)==d) { *r= i; return 1; }
++
++ } else {
++ /* Note: We _can_ use ANSI C mod here, even on negative values, since
++ * we only test for == 0 (the sign would be implementation dependent).
++ */
++ if (ib%ic == 0) { *r= ib/ic; return 1; }
++ }
++
++ return 0;
++}
++
++int try_modint( lua_Integer *r, lua_Integer ib, lua_Integer ic ) {
++ if (ic!=0) {
++ /* ANSI C can be trusted when b%c==0, or when values are non-negative.
++ * b - (floor(b/c) * c)
++ * -->
++ * + +: b - (b/c) * c (b % c can be used)
++ * - -: b - (b/c) * c (b % c could work, but not defined by ANSI C)
++ * 0 -: b - (b/c) * c (=0, b % c could work, but not defined by ANSI C)
++ * - +: b - (b/c-1) * c (when b!=-c)
++ * + -: b - (b/c-1) * c (when b!=-c)
++ *
++ * o MIN%MIN ends up 0, via overflow in calcs but that does not matter.
++ * o MIN%MAX ends up MAX-1 (and other such numbers), also after overflow,
++ * but that does not matter, results do.
++ */
++ lua_Integer v= ib % ic;
++ if ( v!=0 && (ib<0 || ic<0) ) {
++ v= ib - ((ib/ic) - ((ib<=0 && ic<0) ? 0:1)) * ic;
++ }
++ /* Result should always have same sign as 2nd argument. (PIL2) */
++ lua_assert( (v<0) ? (ic<0) : (v>0) ? (ic>0) : 1 );
++ *r= v;
++ return 1;
++ }
++ return 0; /* let float side return NaN */
++}
++
++int try_powint( lua_Integer *r, lua_Integer ib, lua_Integer ic ) {
++
++ /* In FLOAT/INT32 or FLOAT|DOUBLE/INT64 modes, calculating integer powers
++ * via FP realm may lose accuracy (i.e. 7^11 = 1977326743, which fits int32
++ * but not 23-bit float mantissa).
++ *
++ * The current solution is dumb, but it works and uses little code. Use of
++ * integer powers is not anticipated to be very frequent (apart from 2^x,
++ * which is separately optimized).
++ */
++ if (ib==0) *r=0;
++ else if (ic<0) return 0; /* FP realm */
++ else if (ib==2 && ic < (int)sizeof(lua_Integer)*8-1) *r= ((lua_Integer)1)<<ic; /* 1,2,4,...2^30 | 2^62 optimization */
++ else if (ic==0) *r=1;
++ else if (luai_abs(ib)==1) *r= (ic%2) ? ib:1;
++ else {
++ lua_Integer x= ib;
++ while( --ic ) {
++ if (!try_mulint( &x, x, ib ))
++ return 0; /* FP realm */
++ }
++ *r= x;
++ }
++ return 1;
++}
++
++int try_unmint( lua_Integer *r, lua_Integer ib ) {
++ /* Negating LUA_INTEGER_MIN leaves the range. */
++ if ( ib != LUA_INTEGER_MIN )
++ { *r= -ib; return 1; }
++ return 0;
++}
++
+--- /dev/null
++++ b/src/lnum.h
+@@ -0,0 +1,116 @@
++/*
++** $Id: lnum.h,v ... $
++** Internal Number model
++** See Copyright Notice in lua.h
++*/
++
++#ifndef lnum_h
++#define lnum_h
++
++#include <math.h>
++
++#include "lobject.h"
++
++/*
++** The luai_num* macros define the primitive operations over 'lua_Number's
++** (not 'lua_Integer's, not 'lua_Complex').
++*/
++#define luai_numadd(a,b) ((a)+(b))
++#define luai_numsub(a,b) ((a)-(b))
++#define luai_nummul(a,b) ((a)*(b))
++#define luai_numdiv(a,b) ((a)/(b))
++#define luai_nummod(a,b) ((a) - _LF(floor)((a)/(b))*(b))
++#define luai_numpow(a,b) (_LF(pow)(a,b))
++#define luai_numunm(a) (-(a))
++#define luai_numeq(a,b) ((a)==(b))
++#define luai_numlt(a,b) ((a)<(b))
++#define luai_numle(a,b) ((a)<=(b))
++#define luai_numisnan(a) (!luai_numeq((a), (a)))
++
++int try_addint( lua_Integer *r, lua_Integer ib, lua_Integer ic );
++int try_subint( lua_Integer *r, lua_Integer ib, lua_Integer ic );
++int try_mulint( lua_Integer *r, lua_Integer ib, lua_Integer ic );
++int try_divint( lua_Integer *r, lua_Integer ib, lua_Integer ic );
++int try_modint( lua_Integer *r, lua_Integer ib, lua_Integer ic );
++int try_powint( lua_Integer *r, lua_Integer ib, lua_Integer ic );
++int try_unmint( lua_Integer *r, lua_Integer ib );
++
++#ifdef LNUM_COMPLEX
++ static inline lua_Complex luai_vectunm( lua_Complex a ) { return -a; }
++ static inline lua_Complex luai_vectadd( lua_Complex a, lua_Complex b ) { return a+b; }
++ static inline lua_Complex luai_vectsub( lua_Complex a, lua_Complex b ) { return a-b; }
++ static inline lua_Complex luai_vectmul( lua_Complex a, lua_Complex b ) { return a*b; }
++ static inline lua_Complex luai_vectdiv( lua_Complex a, lua_Complex b ) { return a/b; }
++
++/*
++ * C99 does not provide modulus for complex numbers. It most likely is not
++ * meaningful at all.
++ */
++
++/*
++ * Complex power
++ *
++ * C99 'cpow' gives inaccurate results for many common cases s.a. (1i)^2 ->
++ * -1+1.2246467991474e-16i (OS X 10.4, gcc 4.0.1 build 5367)
++ *
++ * [(a+bi)^(c+di)] = (r^c) * exp(-d*t) * cos(c*t + d*ln(r)) +
++ * = (r^c) * exp(-d*t) * sin(c*t + d*ln(r)) *i
++ * r = sqrt(a^2+b^2), t = arctan( b/a )
++ *
++ * Reference: <http://home.att.net/~srschmitt/complexnumbers.html>
++ * Could also be calculated using: x^y = exp(ln(x)*y)
++ *
++ * Note: Defined here (and not in .c) so 'lmathlib.c' can share the
++ * implementation.
++ */
++ static inline
++ lua_Complex luai_vectpow( lua_Complex a, lua_Complex b )
++ {
++# if 1
++ lua_Number ar= _LF(creal)(a), ai= _LF(cimag)(a);
++ lua_Number br= _LF(creal)(b), bi= _LF(cimag)(b);
++
++ if (ai==0 && bi==0) { /* a^c (real) */
++ return luai_numpow( ar, br );
++ }
++
++ int br_int= (int)br;
++
++ if ( ai!=0 && bi==0 && br_int==br && br_int!=0 && br_int!=INT_MIN ) {
++ /* (a+bi)^N, N = { +-1,+-2, ... +-INT_MAX }
++ */
++ lua_Number k= luai_numpow( _LF(sqrt) (ar*ar + ai*ai), br );
++ lua_Number cos_z, sin_z;
++
++ /* Situation depends upon c (N) in the following manner:
++ *
++ * N%4==0 => cos(c*t)=1, sin(c*t)=0
++ * (N*sign(b))%4==1 or (N*sign(b))%4==-3 => cos(c*t)=0, sin(c*t)=1
++ * N%4==2 or N%4==-2 => cos(c*t)=-1, sin(c*t)=0
++ * (N*sign(b))%4==-1 or (N*sign(b))%4==3 => cos(c*t)=0, sin(c*t)=-1
++ */
++ int br_int_abs = br_int<0 ? -br_int:br_int;
++
++ switch( (br_int_abs%4) * (br_int<0 ? -1:1) * (ai<0 ? -1:1) ) {
++ case 0: cos_z=1, sin_z=0; break;
++ case 2: case -2: cos_z=-1, sin_z=0; break;
++ case 1: case -3: cos_z=0, sin_z=1; break;
++ case 3: case -1: cos_z=0, sin_z=-1; break;
++ default: lua_assert(0); return 0;
++ }
++ return k*cos_z + (k*sin_z)*I;
++ }
++# endif
++ return _LF(cpow) ( a, b );
++ }
++#endif
++
++LUAI_FUNC int luaO_str2d (const char *s, lua_Number *res1, lua_Integer *res2);
++LUAI_FUNC void luaO_num2buf( char *s, const TValue *o );
++
++LUAI_FUNC int /*bool*/ tt_integer_valued( const TValue *o, lua_Integer *ref );
++
++#define luai_normalize(o) \
++{ lua_Integer _i; if (tt_integer_valued(o,&_i)) setivalue(o,_i); }
++
++#endif
+--- /dev/null
++++ b/src/lnum_config.h
+@@ -0,0 +1,221 @@
++/*
++** $Id: lnum_config.h,v ... $
++** Internal Number model
++** See Copyright Notice in lua.h
++*/
++
++#ifndef lnum_config_h
++#define lnum_config_h
++
++/*
++** Default number modes
++*/
++#if (!defined LNUM_DOUBLE) && (!defined LNUM_FLOAT) && (!defined LNUM_LDOUBLE)
++# define LNUM_FLOAT
++#endif
++#if (!defined LNUM_INT16) && (!defined LNUM_INT32) && (!defined LNUM_INT64)
++# define LNUM_INT32
++#endif
++
++/*
++** Require C99 mode for COMPLEX, FLOAT and LDOUBLE (only DOUBLE is ANSI C).
++*/
++#if defined(LNUM_COMPLEX) && (__STDC_VERSION__ < 199901L)
++# error "Need C99 for complex (use '--std=c99' or similar)"
++#elif defined(LNUM_LDOUBLE) && (__STDC_VERSION__ < 199901L) && !defined(_MSC_VER)
++# error "Need C99 for 'long double' (use '--std=c99' or similar)"
++#elif defined(LNUM_FLOAT) && (__STDC_VERSION__ < 199901L)
++/* LNUM_FLOAT not supported on Windows */
++# error "Need C99 for 'float' (use '--std=c99' or similar)"
++#endif
++
++/*
++** Number mode identifier to accompany the version string.
++*/
++#ifdef LNUM_COMPLEX
++# define _LNUM1 "complex "
++#else
++# define _LNUM1 ""
++#endif
++#ifdef LNUM_DOUBLE
++# define _LNUM2 "double"
++#elif defined(LNUM_FLOAT)
++# define _LNUM2 "float"
++#elif defined(LNUM_LDOUBLE)
++# define _LNUM2 "ldouble"
++#endif
++#ifdef LNUM_INT32
++# define _LNUM3 "int32"
++#elif defined(LNUM_INT64)
++# define _LNUM3 "int64"
++#elif defined(LNUM_INT16)
++# define _LNUM3 "int16"
++#endif
++#define LUA_LNUM _LNUM1 _LNUM2 " " _LNUM3
++
++/*
++** LUA_NUMBER is the type of floating point number in Lua
++** LUA_NUMBER_SCAN is the format for reading numbers.
++** LUA_NUMBER_FMT is the format for writing numbers.
++*/
++#ifdef LNUM_FLOAT
++# define LUA_NUMBER float
++# define LUA_NUMBER_SCAN "%f"
++# define LUA_NUMBER_FMT "%g"
++#elif (defined LNUM_DOUBLE)
++# define LUA_NUMBER double
++# define LUA_NUMBER_SCAN "%lf"
++# define LUA_NUMBER_FMT "%.14g"
++#elif (defined LNUM_LDOUBLE)
++# define LUA_NUMBER long double
++# define LUA_NUMBER_SCAN "%Lg"
++# define LUA_NUMBER_FMT "%.20Lg"
++#endif
++
++
++/*
++** LUAI_MAXNUMBER2STR: size of a buffer fitting any number->string result.
++**
++** double: 24 (sign, x.xxxxxxxxxxxxxxe+nnnn, and \0)
++** int64: 21 (19 digits, sign, and \0)
++** long double: 43 for 128-bit (sign, x.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxe+nnnn, and \0)
++** 30 for 80-bit (sign, x.xxxxxxxxxxxxxxxxxxxxe+nnnn, and \0)
++*/
++#ifdef LNUM_LDOUBLE
++# define _LUAI_MN2S 44
++#else
++# define _LUAI_MN2S 24
++#endif
++
++#ifdef LNUM_COMPLEX
++# define LUAI_MAXNUMBER2STR (2*_LUAI_MN2S)
++#else
++# define LUAI_MAXNUMBER2STR _LUAI_MN2S
++#endif
++
++/*
++** LUA_INTEGER is the integer type used by lua_pushinteger/lua_tointeger/lua_isinteger.
++** LUA_INTEGER_SCAN is the format for reading integers
++** LUA_INTEGER_FMT is the format for writing integers
++**
++** Note: Visual C++ 2005 does not have 'strtoull()', use '_strtoui64()' instead.
++*/
++#ifdef LNUM_INT32
++# if LUAI_BITSINT > 16
++# define LUA_INTEGER int
++# define LUA_INTEGER_SCAN "%d"
++# define LUA_INTEGER_FMT "%d"
++# else
++/* Note: 'LUA_INTEGER' being 'ptrdiff_t' (as in Lua 5.1) causes problems with
++ * 'printf()' operations. Also 'unsigned ptrdiff_t' is invalid.
++ */
++# define LUA_INTEGER long
++# define LUA_INTEGER_SCAN "%ld"
++# define LUA_INTEGER_FMT "%ld"
++# endif
++# define LUA_INTEGER_MAX 0x7FFFFFFF /* 2^31-1 */
++/* */
++#elif defined(LNUM_INT64)
++# define LUA_INTEGER long long
++# ifdef _MSC_VER
++# define lua_str2ul _strtoui64
++# else
++# define lua_str2ul strtoull
++# endif
++# define LUA_INTEGER_SCAN "%lld"
++# define LUA_INTEGER_FMT "%lld"
++# define LUA_INTEGER_MAX 0x7fffffffffffffffLL /* 2^63-1 */
++# define LUA_INTEGER_MIN (-LUA_INTEGER_MAX - 1LL) /* -2^63 */
++/* */
++#elif defined(LNUM_INT16)
++# if LUAI_BITSINT > 16
++# define LUA_INTEGER short
++# define LUA_INTEGER_SCAN "%hd"
++# define LUA_INTEGER_FMT "%hd"
++# else
++# define LUA_INTEGER int
++# define LUA_INTEGER_SCAN "%d"
++# define LUA_INTEGER_FMT "%d"
++# endif
++# define LUA_INTEGER_MAX 0x7FFF /* 2^16-1 */
++#endif
++
++#ifndef lua_str2ul
++# define lua_str2ul (unsigned LUA_INTEGER)strtoul
++#endif
++#ifndef LUA_INTEGER_MIN
++# define LUA_INTEGER_MIN (-LUA_INTEGER_MAX -1) /* -2^16|32 */
++#endif
++
++/*
++@@ lua_number2int is a macro to convert lua_Number to int.
++@@ lua_number2integer is a macro to convert lua_Number to lua_Integer.
++** CHANGE them if you know a faster way to convert a lua_Number to
++** int (with any rounding method and without throwing errors) in your
++** system. In Pentium machines, a naive typecast from double to int
++** in C is extremely slow, so any alternative is worth trying.
++*/
++
++/* On a Pentium, resort to a trick */
++#if defined(LNUM_DOUBLE) && !defined(LUA_ANSI) && !defined(__SSE2__) && \
++ (defined(__i386) || defined (_M_IX86) || defined(__i386__))
++
++/* On a Microsoft compiler, use assembler */
++# if defined(_MSC_VER)
++# define lua_number2int(i,d) __asm fld d __asm fistp i
++# else
++
++/* the next trick should work on any Pentium, but sometimes clashes
++ with a DirectX idiosyncrasy */
++union luai_Cast { double l_d; long l_l; };
++# define lua_number2int(i,d) \
++ { volatile union luai_Cast u; u.l_d = (d) + 6755399441055744.0; (i) = u.l_l; }
++# endif
++
++# ifndef LNUM_INT64
++# define lua_number2integer lua_number2int
++# endif
++
++/* this option always works, but may be slow */
++#else
++# define lua_number2int(i,d) ((i)=(int)(d))
++#endif
++
++/* Note: Some compilers (OS X gcc 4.0?) may choke on double->long long conversion
++ * since it can lose precision. Others do require 'long long' there.
++ */
++#ifndef lua_number2integer
++# define lua_number2integer(i,d) ((i)=(lua_Integer)(d))
++#endif
++
++/*
++** 'luai_abs()' to give absolute value of 'lua_Integer'
++*/
++#ifdef LNUM_INT32
++# define luai_abs abs
++#elif defined(LNUM_INT64) && (__STDC_VERSION__ >= 199901L)
++# define luai_abs llabs
++#else
++# define luai_abs(v) ((v) >= 0 ? (v) : -(v))
++#endif
++
++/*
++** LUAI_UACNUMBER is the result of an 'usual argument conversion' over a number.
++** LUAI_UACINTEGER the same, over an integer.
++*/
++#define LUAI_UACNUMBER double
++#define LUAI_UACINTEGER long
++
++/* ANSI C only has math funcs for 'double. C99 required for float and long double
++ * variants.
++ */
++#ifdef LNUM_DOUBLE
++# define _LF(name) name
++#elif defined(LNUM_FLOAT)
++# define _LF(name) name ## f
++#elif defined(LNUM_LDOUBLE)
++# define _LF(name) name ## l
++#endif
++
++#endif
++
+--- a/src/lobject.c
++++ b/src/lobject.c
+@@ -21,7 +21,8 @@
+ #include "lstate.h"
+ #include "lstring.h"
+ #include "lvm.h"
+-
++#include "llex.h"
++#include "lnum.h"
+
+
+ const TValue luaO_nilobject_ = {{NULL}, LUA_TNIL};
+@@ -70,12 +71,31 @@ int luaO_log2 (unsigned int x) {
+
+
+ int luaO_rawequalObj (const TValue *t1, const TValue *t2) {
+- if (ttype(t1) != ttype(t2)) return 0;
++ if (!ttype_ext_same(t1,t2)) return 0;
+ else switch (ttype(t1)) {
+ case LUA_TNIL:
+ return 1;
++ case LUA_TINT:
++ if (ttype(t2)==LUA_TINT)
++ return ivalue(t1) == ivalue(t2);
++ else { /* t1:int, t2:num */
++#ifdef LNUM_COMPLEX
++ if (nvalue_img_fast(t2) != 0) return 0;
++#endif
++ /* Avoid doing accuracy losing cast, if possible. */
++ lua_Integer tmp;
++ if (tt_integer_valued(t2,&tmp))
++ return ivalue(t1) == tmp;
++ else
++ return luai_numeq( cast_num(ivalue(t1)), nvalue_fast(t2) );
++ }
+ case LUA_TNUMBER:
+- return luai_numeq(nvalue(t1), nvalue(t2));
++ if (ttype(t2)==LUA_TINT)
++ return luaO_rawequalObj(t2, t1); /* swap LUA_TINT to left */
++#ifdef LNUM_COMPLEX
++ if (!luai_numeq(nvalue_img_fast(t1), nvalue_img_fast(t2))) return 0;
++#endif
++ return luai_numeq(nvalue_fast(t1), nvalue_fast(t2));
+ case LUA_TBOOLEAN:
+ return bvalue(t1) == bvalue(t2); /* boolean true must be 1 !! */
+ case LUA_TLIGHTUSERDATA:
+@@ -86,21 +106,6 @@ int luaO_rawequalObj (const TValue *t1,
+ }
+ }
+
+-
+-int luaO_str2d (const char *s, lua_Number *result) {
+- char *endptr;
+- *result = lua_str2number(s, &endptr);
+- if (endptr == s) return 0; /* conversion failed */
+- if (*endptr == 'x' || *endptr == 'X') /* maybe an hexadecimal constant? */
+- *result = cast_num(strtoul(s, &endptr, 16));
+- if (*endptr == '\0') return 1; /* most common case */
+- while (isspace(cast(unsigned char, *endptr))) endptr++;
+- if (*endptr != '\0') return 0; /* invalid trailing characters? */
+- return 1;
+-}
+-
+-
+-
+ static void pushstr (lua_State *L, const char *str) {
+ setsvalue2s(L, L->top, luaS_new(L, str));
+ incr_top(L);
+@@ -131,7 +136,11 @@ const char *luaO_pushvfstring (lua_State
+ break;
+ }
+ case 'd': {
+- setnvalue(L->top, cast_num(va_arg(argp, int)));
++ /* This is tricky for 64-bit integers; maybe they even cannot be
++ * supported on all compilers; depends on the conversions applied to
++ * variable argument lists. TBD: test!
++ */
++ setivalue(L->top, (lua_Integer) va_arg(argp, l_uacInteger));
+ incr_top(L);
+ break;
+ }
+@@ -212,3 +221,4 @@ void luaO_chunkid (char *out, const char
+ }
+ }
+ }
++
+--- a/src/lobject.h
++++ b/src/lobject.h
+@@ -17,7 +17,11 @@
+
+
+ /* tags for values visible from Lua */
+-#define LAST_TAG LUA_TTHREAD
++#if LUA_TINT > LUA_TTHREAD
++# define LAST_TAG LUA_TINT
++#else
++# define LAST_TAG LUA_TTHREAD
++#endif
+
+ #define NUM_TAGS (LAST_TAG+1)
+
+@@ -59,7 +63,12 @@ typedef struct GCheader {
+ typedef union {
+ GCObject *gc;
+ void *p;
++#ifdef LNUM_COMPLEX
++ lua_Complex n;
++#else
+ lua_Number n;
++#endif
++ lua_Integer i;
+ int b;
+ } Value;
+
+@@ -77,7 +86,11 @@ typedef struct lua_TValue {
+
+ /* Macros to test type */
+ #define ttisnil(o) (ttype(o) == LUA_TNIL)
+-#define ttisnumber(o) (ttype(o) == LUA_TNUMBER)
++#define ttisint(o) (ttype(o) == LUA_TINT)
++#define ttisnumber(o) ((ttype(o) == LUA_TINT) || (ttype(o) == LUA_TNUMBER))
++#ifdef LNUM_COMPLEX
++# define ttiscomplex(o) ((ttype(o) == LUA_TNUMBER) && (nvalue_img_fast(o)!=0))
++#endif
+ #define ttisstring(o) (ttype(o) == LUA_TSTRING)
+ #define ttistable(o) (ttype(o) == LUA_TTABLE)
+ #define ttisfunction(o) (ttype(o) == LUA_TFUNCTION)
+@@ -90,7 +103,25 @@ typedef struct lua_TValue {
+ #define ttype(o) ((o)->tt)
+ #define gcvalue(o) check_exp(iscollectable(o), (o)->value.gc)
+ #define pvalue(o) check_exp(ttislightuserdata(o), (o)->value.p)
+-#define nvalue(o) check_exp(ttisnumber(o), (o)->value.n)
++
++#define ttype_ext(o) ( ttype(o) == LUA_TINT ? LUA_TNUMBER : ttype(o) )
++#define ttype_ext_same(o1,o2) ( (ttype(o1)==ttype(o2)) || (ttisnumber(o1) && ttisnumber(o2)) )
++
++/* '_fast' variants are for cases where 'ttype(o)' is known to be LUA_TNUMBER.
++ */
++#ifdef LNUM_COMPLEX
++# define nvalue_complex_fast(o) check_exp( ttype(o)==LUA_TNUMBER, (o)->value.n )
++# define nvalue_fast(o) ( _LF(creal) ( nvalue_complex_fast(o) ) )
++# define nvalue_img_fast(o) ( _LF(cimag) ( nvalue_complex_fast(o) ) )
++# define nvalue_complex(o) check_exp( ttisnumber(o), (ttype(o)==LUA_TINT) ? (o)->value.i : (o)->value.n )
++# define nvalue_img(o) check_exp( ttisnumber(o), (ttype(o)==LUA_TINT) ? 0 : _LF(cimag)( (o)->value.n ) )
++# define nvalue(o) check_exp( ttisnumber(o), (ttype(o)==LUA_TINT) ? cast_num((o)->value.i) : _LF(creal)((o)->value.n) )
++#else
++# define nvalue(o) check_exp( ttisnumber(o), (ttype(o)==LUA_TINT) ? cast_num((o)->value.i) : (o)->value.n )
++# define nvalue_fast(o) check_exp( ttype(o)==LUA_TNUMBER, (o)->value.n )
++#endif
++#define ivalue(o) check_exp( ttype(o)==LUA_TINT, (o)->value.i )
++
+ #define rawtsvalue(o) check_exp(ttisstring(o), &(o)->value.gc->ts)
+ #define tsvalue(o) (&rawtsvalue(o)->tsv)
+ #define rawuvalue(o) check_exp(ttisuserdata(o), &(o)->value.gc->u)
+@@ -116,8 +147,27 @@ typedef struct lua_TValue {
+ /* Macros to set values */
+ #define setnilvalue(obj) ((obj)->tt=LUA_TNIL)
+
+-#define setnvalue(obj,x) \
+- { TValue *i_o=(obj); i_o->value.n=(x); i_o->tt=LUA_TNUMBER; }
++/* Must not have side effects, 'x' may be expression.
++*/
++#define setivalue(obj,x) \
++ { TValue *i_o=(obj); i_o->value.i=(x); i_o->tt=LUA_TINT; }
++
++# define setnvalue(obj,x) \
++ { TValue *i_o=(obj); i_o->value.n= (x); i_o->tt=LUA_TNUMBER; }
++
++/* Note: Complex always has "inline", both are C99.
++*/
++#ifdef LNUM_COMPLEX
++ static inline void setnvalue_complex_fast( TValue *obj, lua_Complex x ) {
++ lua_assert( _LF(cimag)(x) != 0 );
++ obj->value.n= x; obj->tt= LUA_TNUMBER;
++ }
++ static inline void setnvalue_complex( TValue *obj, lua_Complex x ) {
++ if (_LF(cimag)(x) == 0) { setnvalue(obj, _LF(creal)(x)); }
++ else { obj->value.n= x; obj->tt= LUA_TNUMBER; }
++ }
++#endif
++
+
+ #define setpvalue(obj,x) \
+ { TValue *i_o=(obj); i_o->value.p=(x); i_o->tt=LUA_TLIGHTUSERDATA; }
+@@ -155,9 +205,6 @@ typedef struct lua_TValue {
+ i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TPROTO; \
+ checkliveness(G(L),i_o); }
+
+-
+-
+-
+ #define setobj(L,obj1,obj2) \
+ { const TValue *o2=(obj2); TValue *o1=(obj1); \
+ o1->value = o2->value; o1->tt=o2->tt; \
+@@ -185,8 +232,11 @@ typedef struct lua_TValue {
+
+ #define setttype(obj, tt) (ttype(obj) = (tt))
+
+-
+-#define iscollectable(o) (ttype(o) >= LUA_TSTRING)
++#if LUA_TINT >= LUA_TSTRING
++# define iscollectable(o) ((ttype(o) >= LUA_TSTRING) && (ttype(o) != LUA_TINT))
++#else
++# define iscollectable(o) (ttype(o) >= LUA_TSTRING)
++#endif
+
+
+
+@@ -370,12 +420,10 @@ LUAI_FUNC int luaO_log2 (unsigned int x)
+ LUAI_FUNC int luaO_int2fb (unsigned int x);
+ LUAI_FUNC int luaO_fb2int (int x);
+ LUAI_FUNC int luaO_rawequalObj (const TValue *t1, const TValue *t2);
+-LUAI_FUNC int luaO_str2d (const char *s, lua_Number *result);
+ LUAI_FUNC const char *luaO_pushvfstring (lua_State *L, const char *fmt,
+ va_list argp);
+ LUAI_FUNC const char *luaO_pushfstring (lua_State *L, const char *fmt, ...);
+ LUAI_FUNC void luaO_chunkid (char *out, const char *source, size_t len);
+
+-
+ #endif
+
+--- a/src/loslib.c
++++ b/src/loslib.c
+@@ -186,15 +186,30 @@ static int os_time (lua_State *L) {
+ }
+ if (t == (time_t)(-1))
+ lua_pushnil(L);
+- else
+- lua_pushnumber(L, (lua_Number)t);
++ else {
++ /* On float systems the pushed value must be an integer, NOT a number.
++ * Otherwise, accuracy is lost in the time_t->float conversion.
++ */
++#ifdef LNUM_FLOAT
++ lua_pushinteger(L, (lua_Integer) t);
++#else
++ lua_pushnumber(L, (lua_Number) t);
++#endif
++ }
+ return 1;
+ }
+
+
+ static int os_difftime (lua_State *L) {
++#ifdef LNUM_FLOAT
++ lua_Integer i= (lua_Integer)
++ difftime( (time_t)(luaL_checkinteger(L, 1)),
++ (time_t)(luaL_optinteger(L, 2, 0)));
++ lua_pushinteger(L, i);
++#else
+ lua_pushnumber(L, difftime((time_t)(luaL_checknumber(L, 1)),
+ (time_t)(luaL_optnumber(L, 2, 0))));
++#endif
+ return 1;
+ }
+
+--- a/src/lparser.c
++++ b/src/lparser.c
+@@ -33,7 +33,6 @@
+
+ #define luaY_checklimit(fs,v,l,m) if ((v)>(l)) errorlimit(fs,l,m)
+
+-
+ /*
+ ** nodes for block list (list of active blocks)
+ */
+@@ -72,7 +71,7 @@ static void errorlimit (FuncState *fs, i
+ const char *msg = (fs->f->linedefined == 0) ?
+ luaO_pushfstring(fs->L, "main function has more than %d %s", limit, what) :
+ luaO_pushfstring(fs->L, "function at line %d has more than %d %s",
+- fs->f->linedefined, limit, what);
++ (fs->f->linedefined), limit, what);
+ luaX_lexerror(fs->ls, msg, 0);
+ }
+
+@@ -733,6 +732,18 @@ static void simpleexp (LexState *ls, exp
+ v->u.nval = ls->t.seminfo.r;
+ break;
+ }
++ case TK_INT: {
++ init_exp(v, VKINT, 0);
++ v->u.ival = ls->t.seminfo.i;
++ break;
++ }
++#ifdef LNUM_COMPLEX
++ case TK_NUMBER2: {
++ init_exp(v, VKNUM2, 0);
++ v->u.nval = ls->t.seminfo.r;
++ break;
++ }
++#endif
+ case TK_STRING: {
+ codestring(ls, v, ls->t.seminfo.ts);
+ break;
+@@ -1079,7 +1090,7 @@ static void fornum (LexState *ls, TStrin
+ if (testnext(ls, ','))
+ exp1(ls); /* optional step */
+ else { /* default step = 1 */
+- luaK_codeABx(fs, OP_LOADK, fs->freereg, luaK_numberK(fs, 1));
++ luaK_codeABx(fs, OP_LOADK, fs->freereg, luaK_integerK(fs, 1));
+ luaK_reserveregs(fs, 1);
+ }
+ forbody(ls, base, line, 1, 1);
+--- a/src/lparser.h
++++ b/src/lparser.h
+@@ -31,7 +31,11 @@ typedef enum {
+ VRELOCABLE, /* info = instruction pc */
+ VNONRELOC, /* info = result register */
+ VCALL, /* info = instruction pc */
+- VVARARG /* info = instruction pc */
++ VVARARG, /* info = instruction pc */
++ VKINT /* ival = integer value */
++#ifdef LNUM_COMPLEX
++ ,VKNUM2 /* nval = imaginary value */
++#endif
+ } expkind;
+
+ typedef struct expdesc {
+@@ -39,6 +43,7 @@ typedef struct expdesc {
+ union {
+ struct { int info, aux; } s;
+ lua_Number nval;
++ lua_Integer ival;
+ } u;
+ int t; /* patch list of `exit when true' */
+ int f; /* patch list of `exit when false' */
+--- a/src/lstrlib.c
++++ b/src/lstrlib.c
+@@ -43,8 +43,8 @@ static ptrdiff_t posrelat (ptrdiff_t pos
+ static int str_sub (lua_State *L) {
+ size_t l;
+ const char *s = luaL_checklstring(L, 1, &l);
+- ptrdiff_t start = posrelat(luaL_checkinteger(L, 2), l);
+- ptrdiff_t end = posrelat(luaL_optinteger(L, 3, -1), l);
++ ptrdiff_t start = posrelat(luaL_checkint32(L, 2), l);
++ ptrdiff_t end = posrelat(luaL_optint32(L, 3, -1), l);
+ if (start < 1) start = 1;
+ if (end > (ptrdiff_t)l) end = (ptrdiff_t)l;
+ if (start <= end)
+@@ -106,8 +106,8 @@ static int str_rep (lua_State *L) {
+ static int str_byte (lua_State *L) {
+ size_t l;
+ const char *s = luaL_checklstring(L, 1, &l);
+- ptrdiff_t posi = posrelat(luaL_optinteger(L, 2, 1), l);
+- ptrdiff_t pose = posrelat(luaL_optinteger(L, 3, posi), l);
++ ptrdiff_t posi = posrelat(luaL_optint32(L, 2, 1), l);
++ ptrdiff_t pose = posrelat(luaL_optint32(L, 3, posi), l);
+ int n, i;
+ if (posi <= 0) posi = 1;
+ if ((size_t)pose > l) pose = l;
+@@ -496,7 +496,7 @@ static int str_find_aux (lua_State *L, i
+ size_t l1, l2;
+ const char *s = luaL_checklstring(L, 1, &l1);
+ const char *p = luaL_checklstring(L, 2, &l2);
+- ptrdiff_t init = posrelat(luaL_optinteger(L, 3, 1), l1) - 1;
++ ptrdiff_t init = posrelat(luaL_optint32(L, 3, 1), l1) - 1;
+ if (init < 0) init = 0;
+ else if ((size_t)(init) > l1) init = (ptrdiff_t)l1;
+ if (find && (lua_toboolean(L, 4) || /* explicit request? */
+@@ -690,7 +690,7 @@ static int str_gsub (lua_State *L) {
+ ** maximum size of each format specification (such as '%-099.99d')
+ ** (+10 accounts for %99.99x plus margin of error)
+ */
+-#define MAX_FORMAT (sizeof(FLAGS) + sizeof(LUA_INTFRMLEN) + 10)
++#define MAX_FORMAT (sizeof(FLAGS) + sizeof(LUA_INTEGER_FMT)-2 + 10)
+
+
+ static void addquoted (lua_State *L, luaL_Buffer *b, int arg) {
+@@ -747,9 +747,9 @@ static const char *scanformat (lua_State
+ static void addintlen (char *form) {
+ size_t l = strlen(form);
+ char spec = form[l - 1];
+- strcpy(form + l - 1, LUA_INTFRMLEN);
+- form[l + sizeof(LUA_INTFRMLEN) - 2] = spec;
+- form[l + sizeof(LUA_INTFRMLEN) - 1] = '\0';
++ const char *tmp= LUA_INTEGER_FMT; /* "%lld" or "%ld" */
++ strcpy(form + l - 1, tmp+1);
++ form[l + sizeof(LUA_INTEGER_FMT)-4] = spec;
+ }
+
+
+@@ -779,12 +779,12 @@ static int str_format (lua_State *L) {
+ }
+ case 'd': case 'i': {
+ addintlen(form);
+- sprintf(buff, form, (LUA_INTFRM_T)luaL_checknumber(L, arg));
++ sprintf(buff, form, luaL_checkinteger(L, arg));
+ break;
+ }
+ case 'o': case 'u': case 'x': case 'X': {
+ addintlen(form);
+- sprintf(buff, form, (unsigned LUA_INTFRM_T)luaL_checknumber(L, arg));
++ sprintf(buff, form, (unsigned LUA_INTEGER)luaL_checkinteger(L, arg));
+ break;
+ }
+ case 'e': case 'E': case 'f':
+--- a/src/ltable.c
++++ b/src/ltable.c
+@@ -33,6 +33,7 @@
+ #include "lobject.h"
+ #include "lstate.h"
+ #include "ltable.h"
++#include "lnum.h"
+
+
+ /*
+@@ -51,25 +52,15 @@
+
+ #define hashstr(t,str) hashpow2(t, (str)->tsv.hash)
+ #define hashboolean(t,p) hashpow2(t, p)
+-
++#define hashint(t,i) hashpow2(t,i)
+
+ /*
+ ** for some types, it is better to avoid modulus by power of 2, as
+ ** they tend to have many 2 factors.
+ */
+ #define hashmod(t,n) (gnode(t, ((n) % ((sizenode(t)-1)|1))))
+-
+-
+ #define hashpointer(t,p) hashmod(t, IntPoint(p))
+
+-
+-/*
+-** number of ints inside a lua_Number
+-*/
+-#define numints cast_int(sizeof(lua_Number)/sizeof(int))
+-
+-
+-
+ #define dummynode (&dummynode_)
+
+ static const Node dummynode_ = {
+@@ -80,27 +71,46 @@ static const Node dummynode_ = {
+
+ /*
+ ** hash for lua_Numbers
++**
++** for non-complex modes, never called with 'lua_Integer' value range (s.a. 0)
+ */
+ static Node *hashnum (const Table *t, lua_Number n) {
+- unsigned int a[numints];
+- int i;
+- if (luai_numeq(n, 0)) /* avoid problems with -0 */
+- return gnode(t, 0);
+- memcpy(a, &n, sizeof(a));
+- for (i = 1; i < numints; i++) a[0] += a[i];
+- return hashmod(t, a[0]);
++ const unsigned int *p= cast(const unsigned int *,&n);
++ unsigned int sum= *p;
++ unsigned int m= sizeof(lua_Number)/sizeof(int);
++ unsigned int i;
++ /* OS X Intel has 'm'==4 and gives "Bus error" if the last integer of
++ * 'n' is read; the actual size of long double is only 80 bits = 10 bytes.
++ * Linux x86 has 'm'==3, and does not require reduction.
++ */
++#if defined(LNUM_LDOUBLE) && defined(__i386__)
++ if (m>3) m--;
++#endif
++ for (i = 1; i < m; i++) sum += p[i];
++ return hashmod(t, sum);
+ }
+
+
+-
+ /*
+ ** returns the `main' position of an element in a table (that is, the index
+ ** of its hash value)
++**
++** Floating point numbers with integer value give the hash position of the
++** integer (so they use the same table position).
+ */
+ static Node *mainposition (const Table *t, const TValue *key) {
++ lua_Integer i;
+ switch (ttype(key)) {
+ case LUA_TNUMBER:
+- return hashnum(t, nvalue(key));
++ if (tt_integer_valued(key,&i))
++ return hashint(t, i);
++#ifdef LNUM_COMPLEX
++ if (nvalue_img_fast(key)!=0 && luai_numeq(nvalue_fast(key),0))
++ return gnode(t, 0); /* 0 and -0 to give same hash */
++#endif
++ return hashnum(t, nvalue_fast(key));
++ case LUA_TINT:
++ return hashint(t, ivalue(key));
+ case LUA_TSTRING:
+ return hashstr(t, rawtsvalue(key));
+ case LUA_TBOOLEAN:
+@@ -116,16 +126,20 @@ static Node *mainposition (const Table *
+ /*
+ ** returns the index for `key' if `key' is an appropriate key to live in
+ ** the array part of the table, -1 otherwise.
++**
++** Anything <=0 is taken as not being in the array part.
+ */
+-static int arrayindex (const TValue *key) {
+- if (ttisnumber(key)) {
+- lua_Number n = nvalue(key);
+- int k;
+- lua_number2int(k, n);
+- if (luai_numeq(cast_num(k), n))
+- return k;
++static int arrayindex (const TValue *key, int max) {
++ lua_Integer k;
++ switch( ttype(key) ) {
++ case LUA_TINT:
++ k= ivalue(key); break;
++ case LUA_TNUMBER:
++ if (tt_integer_valued(key,&k)) break;
++ default:
++ return -1; /* not to be used as array index */
+ }
+- return -1; /* `key' did not match some condition */
++ return ((k>0) && (k <= max)) ? cast_int(k) : -1;
+ }
+
+
+@@ -137,8 +151,8 @@ static int arrayindex (const TValue *key
+ static int findindex (lua_State *L, Table *t, StkId key) {
+ int i;
+ if (ttisnil(key)) return -1; /* first iteration */
+- i = arrayindex(key);
+- if (0 < i && i <= t->sizearray) /* is `key' inside array part? */
++ i = arrayindex(key, t->sizearray);
++ if (i>0) /* inside array part? */
+ return i-1; /* yes; that's the index (corrected to C) */
+ else {
+ Node *n = mainposition(t, key);
+@@ -163,7 +177,7 @@ int luaH_next (lua_State *L, Table *t, S
+ int i = findindex(L, t, key); /* find original element */
+ for (i++; i < t->sizearray; i++) { /* try first array part */
+ if (!ttisnil(&t->array[i])) { /* a non-nil value? */
+- setnvalue(key, cast_num(i+1));
++ setivalue(key, i+1);
+ setobj2s(L, key+1, &t->array[i]);
+ return 1;
+ }
+@@ -209,8 +223,8 @@ static int computesizes (int nums[], int
+
+
+ static int countint (const TValue *key, int *nums) {
+- int k = arrayindex(key);
+- if (0 < k && k <= MAXASIZE) { /* is `key' an appropriate array index? */
++ int k = arrayindex(key,MAXASIZE);
++ if (k>0) { /* appropriate array index? */
+ nums[ceillog2(k)]++; /* count as such */
+ return 1;
+ }
+@@ -308,7 +322,7 @@ static void resize (lua_State *L, Table
+ /* re-insert elements from vanishing slice */
+ for (i=nasize; i<oldasize; i++) {
+ if (!ttisnil(&t->array[i]))
+- setobjt2t(L, luaH_setnum(L, t, i+1), &t->array[i]);
++ setobjt2t(L, luaH_setint(L, t, i+1), &t->array[i]);
+ }
+ /* shrink array */
+ luaM_reallocvector(L, t->array, oldasize, nasize, TValue);
+@@ -409,7 +423,9 @@ static TValue *newkey (lua_State *L, Tab
+ othern = mainposition(t, key2tval(mp));
+ if (othern != mp) { /* is colliding node out of its main position? */
+ /* yes; move colliding node into free position */
+- while (gnext(othern) != mp) othern = gnext(othern); /* find previous */
++ while (gnext(othern) != mp) {
++ othern = gnext(othern); /* find previous */
++ }
+ gnext(othern) = n; /* redo the chain with `n' in place of `mp' */
+ *n = *mp; /* copy colliding node into free pos. (mp->next also goes) */
+ gnext(mp) = NULL; /* now `mp' is free */
+@@ -432,17 +448,18 @@ static TValue *newkey (lua_State *L, Tab
+ /*
+ ** search function for integers
+ */
+-const TValue *luaH_getnum (Table *t, int key) {
++const TValue *luaH_getint (Table *t, lua_Integer key) {
+ /* (1 <= key && key <= t->sizearray) */
+ if (cast(unsigned int, key-1) < cast(unsigned int, t->sizearray))
+ return &t->array[key-1];
+ else {
+- lua_Number nk = cast_num(key);
+- Node *n = hashnum(t, nk);
++ Node *n = hashint(t, key);
+ do { /* check whether `key' is somewhere in the chain */
+- if (ttisnumber(gkey(n)) && luai_numeq(nvalue(gkey(n)), nk))
++ if (ttisint(gkey(n)) && (ivalue(gkey(n)) == key)) {
+ return gval(n); /* that's it */
+- else n = gnext(n);
++ } else {
++ n = gnext(n);
++ }
+ } while (n);
+ return luaO_nilobject;
+ }
+@@ -470,14 +487,12 @@ const TValue *luaH_get (Table *t, const
+ switch (ttype(key)) {
+ case LUA_TNIL: return luaO_nilobject;
+ case LUA_TSTRING: return luaH_getstr(t, rawtsvalue(key));
++ case LUA_TINT: return luaH_getint(t, ivalue(key));
+ case LUA_TNUMBER: {
+- int k;
+- lua_Number n = nvalue(key);
+- lua_number2int(k, n);
+- if (luai_numeq(cast_num(k), nvalue(key))) /* index is int? */
+- return luaH_getnum(t, k); /* use specialized version */
+- /* else go through */
+- }
++ lua_Integer i;
++ if (tt_integer_valued(key,&i))
++ return luaH_getint(t,i);
++ } /* pass through */
+ default: {
+ Node *n = mainposition(t, key);
+ do { /* check whether `key' is somewhere in the chain */
+@@ -498,20 +513,25 @@ TValue *luaH_set (lua_State *L, Table *t
+ return cast(TValue *, p);
+ else {
+ if (ttisnil(key)) luaG_runerror(L, "table index is nil");
+- else if (ttisnumber(key) && luai_numisnan(nvalue(key)))
+- luaG_runerror(L, "table index is NaN");
++ else if (ttype(key)==LUA_TNUMBER) {
++ lua_Integer k;
++ if (luai_numisnan(nvalue_fast(key)))
++ luaG_runerror(L, "table index is NaN");
++ if (tt_integer_valued(key,&k))
++ return luaH_setint(L, t, k);
++ }
+ return newkey(L, t, key);
+ }
+ }
+
+
+-TValue *luaH_setnum (lua_State *L, Table *t, int key) {
+- const TValue *p = luaH_getnum(t, key);
++TValue *luaH_setint (lua_State *L, Table *t, lua_Integer key) {
++ const TValue *p = luaH_getint(t, key);
+ if (p != luaO_nilobject)
+ return cast(TValue *, p);
+ else {
+ TValue k;
+- setnvalue(&k, cast_num(key));
++ setivalue(&k, key);
+ return newkey(L, t, &k);
+ }
+ }
+@@ -533,20 +553,21 @@ static int unbound_search (Table *t, uns
+ unsigned int i = j; /* i is zero or a present index */
+ j++;
+ /* find `i' and `j' such that i is present and j is not */
+- while (!ttisnil(luaH_getnum(t, j))) {
++ while (!ttisnil(luaH_getint(t, j))) {
+ i = j;
+ j *= 2;
+ if (j > cast(unsigned int, MAX_INT)) { /* overflow? */
+ /* table was built with bad purposes: resort to linear search */
+- i = 1;
+- while (!ttisnil(luaH_getnum(t, i))) i++;
+- return i - 1;
++ for( i = 1; i<MAX_INT+1; i++ ) {
++ if (ttisnil(luaH_getint(t, i))) break;
++ }
++ return i - 1; /* up to MAX_INT */
+ }
+ }
+ /* now do a binary search between them */
+ while (j - i > 1) {
+ unsigned int m = (i+j)/2;
+- if (ttisnil(luaH_getnum(t, m))) j = m;
++ if (ttisnil(luaH_getint(t, m))) j = m;
+ else i = m;
+ }
+ return i;
+--- a/src/ltable.h
++++ b/src/ltable.h
+@@ -18,8 +18,8 @@
+ #define key2tval(n) (&(n)->i_key.tvk)
+
+
+-LUAI_FUNC const TValue *luaH_getnum (Table *t, int key);
+-LUAI_FUNC TValue *luaH_setnum (lua_State *L, Table *t, int key);
++LUAI_FUNC const TValue *luaH_getint (Table *t, lua_Integer key);
++LUAI_FUNC TValue *luaH_setint (lua_State *L, Table *t, lua_Integer key);
+ LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key);
+ LUAI_FUNC TValue *luaH_setstr (lua_State *L, Table *t, TString *key);
+ LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key);
+--- a/src/ltm.c
++++ b/src/ltm.c
+@@ -19,7 +19,6 @@
+ #include "ltm.h"
+
+
+-
+ const char *const luaT_typenames[] = {
+ "nil", "boolean", "userdata", "number",
+ "string", "table", "function", "userdata", "thread",
+@@ -67,6 +66,9 @@ const TValue *luaT_gettmbyobj (lua_State
+ case LUA_TUSERDATA:
+ mt = uvalue(o)->metatable;
+ break;
++ case LUA_TINT:
++ mt = G(L)->mt[LUA_TNUMBER];
++ break;
+ default:
+ mt = G(L)->mt[ttype(o)];
+ }
+--- a/src/lua.c
++++ b/src/lua.c
+@@ -16,7 +16,7 @@
+
+ #include "lauxlib.h"
+ #include "lualib.h"
+-
++#include "llimits.h"
+
+
+ static lua_State *globalL = NULL;
+@@ -382,6 +382,15 @@ int main (int argc, char **argv) {
+ l_message(argv[0], "cannot create state: not enough memory");
+ return EXIT_FAILURE;
+ }
++ /* Checking 'sizeof(lua_Integer)' cannot be made in preprocessor on all compilers.
++ */
++#ifdef LNUM_INT16
++ lua_assert( sizeof(lua_Integer) == 2 );
++#elif defined(LNUM_INT32)
++ lua_assert( sizeof(lua_Integer) == 4 );
++#elif defined(LNUM_INT64)
++ lua_assert( sizeof(lua_Integer) == 8 );
++#endif
+ s.argc = argc;
+ s.argv = argv;
+ status = lua_cpcall(L, &pmain, &s);
+--- a/src/lua.h
++++ b/src/lua.h
+@@ -19,7 +19,7 @@
+ #define LUA_VERSION "Lua 5.1"
+ #define LUA_RELEASE "Lua 5.1.5"
+ #define LUA_VERSION_NUM 501
+-#define LUA_COPYRIGHT "Copyright (C) 1994-2012 Lua.org, PUC-Rio"
++#define LUA_COPYRIGHT "Copyright (C) 1994-2012 Lua.org, PUC-Rio" " (" LUA_LNUM ")"
+ #define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo & W. Celes"
+
+
+@@ -71,6 +71,16 @@ typedef void * (*lua_Alloc) (void *ud, v
+ */
+ #define LUA_TNONE (-1)
+
++/* LUA_TINT is an internal type, not visible to applications. There are three
++ * potential values where it can be tweaked to (code autoadjusts to these):
++ *
++ * -2: not 'usual' type value; good since 'LUA_TINT' is not part of the API
++ * LUA_TNUMBER+1: shifts other type values upwards, breaking binary compatibility
++ * not acceptable for 5.1, maybe 5.2 onwards?
++ * 9: greater than existing (5.1) type values.
++*/
++#define LUA_TINT (-2)
++
+ #define LUA_TNIL 0
+ #define LUA_TBOOLEAN 1
+ #define LUA_TLIGHTUSERDATA 2
+@@ -139,6 +149,8 @@ LUA_API int (lua_isuserdata)
+ LUA_API int (lua_type) (lua_State *L, int idx);
+ LUA_API const char *(lua_typename) (lua_State *L, int tp);
+
++LUA_API int (lua_isinteger) (lua_State *L, int idx);
++
+ LUA_API int (lua_equal) (lua_State *L, int idx1, int idx2);
+ LUA_API int (lua_rawequal) (lua_State *L, int idx1, int idx2);
+ LUA_API int (lua_lessthan) (lua_State *L, int idx1, int idx2);
+@@ -244,6 +256,19 @@ LUA_API lua_Alloc (lua_getallocf) (lua_S
+ LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud);
+
+
++/*
++* It is unnecessary to break Lua C API 'lua_tonumber()' compatibility, just
++* because the Lua number type is complex. Most C modules would use scalars
++* only. We'll introduce new 'lua_tocomplex' and 'lua_pushcomplex' for when
++* the module really wants to use them.
++*/
++#ifdef LNUM_COMPLEX
++ #include <complex.h>
++ typedef LUA_NUMBER complex lua_Complex;
++ LUA_API lua_Complex (lua_tocomplex) (lua_State *L, int idx);
++ LUA_API void (lua_pushcomplex) (lua_State *L, lua_Complex v);
++#endif
++
+
+ /*
+ ** ===============================================================
+@@ -268,7 +293,12 @@ LUA_API void lua_setallocf (lua_State *L
+ #define lua_isboolean(L,n) (lua_type(L, (n)) == LUA_TBOOLEAN)
+ #define lua_isthread(L,n) (lua_type(L, (n)) == LUA_TTHREAD)
+ #define lua_isnone(L,n) (lua_type(L, (n)) == LUA_TNONE)
+-#define lua_isnoneornil(L, n) (lua_type(L, (n)) <= 0)
++
++#if LUA_TINT < 0
++# define lua_isnoneornil(L, n) ( (lua_type(L,(n)) <= 0) && (lua_type(L,(n)) != LUA_TINT) )
++#else
++# define lua_isnoneornil(L, n) (lua_type(L, (n)) <= 0)
++#endif
+
+ #define lua_pushliteral(L, s) \
+ lua_pushlstring(L, "" s, (sizeof(s)/sizeof(char))-1)
+@@ -386,3 +416,4 @@ struct lua_Debug {
+
+
+ #endif
++
+--- a/src/luaconf.h
++++ b/src/luaconf.h
+@@ -10,7 +10,9 @@
+
+ #include <limits.h>
+ #include <stddef.h>
+-
++#ifdef lua_assert
++# include <assert.h>
++#endif
+
+ /*
+ ** ==================================================================
+@@ -136,14 +138,38 @@
+
+
+ /*
+-@@ LUA_INTEGER is the integral type used by lua_pushinteger/lua_tointeger.
+-** CHANGE that if ptrdiff_t is not adequate on your machine. (On most
+-** machines, ptrdiff_t gives a good choice between int or long.)
++@@ LUAI_BITSINT defines the number of bits in an int.
++** CHANGE here if Lua cannot automatically detect the number of bits of
++** your machine. Probably you do not need to change this.
+ */
+-#define LUA_INTEGER ptrdiff_t
++/* avoid overflows in comparison */
++#if INT_MAX-20 < 32760
++#define LUAI_BITSINT 16
++#elif INT_MAX > 2147483640L
++/* int has at least 32 bits */
++#define LUAI_BITSINT 32
++#else
++#error "you must define LUA_BITSINT with number of bits in an integer"
++#endif
+
+
+ /*
++@@ LNUM_DOUBLE | LNUM_FLOAT | LNUM_LDOUBLE: Generic Lua number mode
++@@ LNUM_INT32 | LNUM_INT64: Integer type
++@@ LNUM_COMPLEX: Define for using 'a+bi' numbers
++@@
++@@ You can combine LNUM_xxx but only one of each group. I.e. '-DLNUM_FLOAT
++@@ -DLNUM_INT32 -DLNUM_COMPLEX' gives float range complex numbers, with
++@@ 32-bit scalar integer range optimized.
++**
++** These are kept in a separate configuration file mainly for ease of patching
++** (can be changed if integerated to Lua proper).
++*/
++/*#define LNUM_DOUBLE*/
++/*#define LNUM_INT32*/
++#include "lnum_config.h"
++
++/*
+ @@ LUA_API is a mark for all core API functions.
+ @@ LUALIB_API is a mark for all standard library functions.
+ ** CHANGE them if you need to define those functions in some special way.
+@@ -383,22 +409,6 @@
+
+
+ /*
+-@@ LUAI_BITSINT defines the number of bits in an int.
+-** CHANGE here if Lua cannot automatically detect the number of bits of
+-** your machine. Probably you do not need to change this.
+-*/
+-/* avoid overflows in comparison */
+-#if INT_MAX-20 < 32760
+-#define LUAI_BITSINT 16
+-#elif INT_MAX > 2147483640L
+-/* int has at least 32 bits */
+-#define LUAI_BITSINT 32
+-#else
+-#error "you must define LUA_BITSINT with number of bits in an integer"
+-#endif
+-
+-
+-/*
+ @@ LUAI_UINT32 is an unsigned integer with at least 32 bits.
+ @@ LUAI_INT32 is an signed integer with at least 32 bits.
+ @@ LUAI_UMEM is an unsigned integer big enough to count the total
+@@ -425,6 +435,15 @@
+ #define LUAI_MEM long
+ #endif
+
++/*
++@@ LUAI_BOOL carries 0 and nonzero (normally 1). It may be defined as 'char'
++** (to save memory), 'int' (for speed), 'bool' (for C++) or '_Bool' (C99)
++*/
++#ifdef __cplusplus
++# define LUAI_BOOL bool
++#else
++# define LUAI_BOOL int
++#endif
+
+ /*
+ @@ LUAI_MAXCALLS limits the number of nested calls.
+@@ -490,101 +509,6 @@
+ /* }================================================================== */
+
+
+-
+-
+-/*
+-** {==================================================================
+-@@ LUA_NUMBER is the type of numbers in Lua.
+-** CHANGE the following definitions only if you want to build Lua
+-** with a number type different from double. You may also need to
+-** change lua_number2int & lua_number2integer.
+-** ===================================================================
+-*/
+-
+-#define LUA_NUMBER_DOUBLE
+-#define LUA_NUMBER double
+-
+-/*
+-@@ LUAI_UACNUMBER is the result of an 'usual argument conversion'
+-@* over a number.
+-*/
+-#define LUAI_UACNUMBER double
+-
+-
+-/*
+-@@ LUA_NUMBER_SCAN is the format for reading numbers.
+-@@ LUA_NUMBER_FMT is the format for writing numbers.
+-@@ lua_number2str converts a number to a string.
+-@@ LUAI_MAXNUMBER2STR is maximum size of previous conversion.
+-@@ lua_str2number converts a string to a number.
+-*/
+-#define LUA_NUMBER_SCAN "%lf"
+-#define LUA_NUMBER_FMT "%.14g"
+-#define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n))
+-#define LUAI_MAXNUMBER2STR 32 /* 16 digits, sign, point, and \0 */
+-#define lua_str2number(s,p) strtod((s), (p))
+-
+-
+-/*
+-@@ The luai_num* macros define the primitive operations over numbers.
+-*/
+-#if defined(LUA_CORE)
+-#include <math.h>
+-#define luai_numadd(a,b) ((a)+(b))
+-#define luai_numsub(a,b) ((a)-(b))
+-#define luai_nummul(a,b) ((a)*(b))
+-#define luai_numdiv(a,b) ((a)/(b))
+-#define luai_nummod(a,b) ((a) - floor((a)/(b))*(b))
+-#define luai_numpow(a,b) (pow(a,b))
+-#define luai_numunm(a) (-(a))
+-#define luai_numeq(a,b) ((a)==(b))
+-#define luai_numlt(a,b) ((a)<(b))
+-#define luai_numle(a,b) ((a)<=(b))
+-#define luai_numisnan(a) (!luai_numeq((a), (a)))
+-#endif
+-
+-
+-/*
+-@@ lua_number2int is a macro to convert lua_Number to int.
+-@@ lua_number2integer is a macro to convert lua_Number to lua_Integer.
+-** CHANGE them if you know a faster way to convert a lua_Number to
+-** int (with any rounding method and without throwing errors) in your
+-** system. In Pentium machines, a naive typecast from double to int
+-** in C is extremely slow, so any alternative is worth trying.
+-*/
+-
+-/* On a Pentium, resort to a trick */
+-#if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) && !defined(__SSE2__) && \
+- (defined(__i386) || defined (_M_IX86) || defined(__i386__))
+-
+-/* On a Microsoft compiler, use assembler */
+-#if defined(_MSC_VER)
+-
+-#define lua_number2int(i,d) __asm fld d __asm fistp i
+-#define lua_number2integer(i,n) lua_number2int(i, n)
+-
+-/* the next trick should work on any Pentium, but sometimes clashes
+- with a DirectX idiosyncrasy */
+-#else
+-
+-union luai_Cast { double l_d; long l_l; };
+-#define lua_number2int(i,d) \
+- { volatile union luai_Cast u; u.l_d = (d) + 6755399441055744.0; (i) = u.l_l; }
+-#define lua_number2integer(i,n) lua_number2int(i, n)
+-
+-#endif
+-
+-
+-/* this option always works, but may be slow */
+-#else
+-#define lua_number2int(i,d) ((i)=(int)(d))
+-#define lua_number2integer(i,d) ((i)=(lua_Integer)(d))
+-
+-#endif
+-
+-/* }================================================================== */
+-
+-
+ /*
+ @@ LUAI_USER_ALIGNMENT_T is a type that requires maximum alignment.
+ ** CHANGE it if your system requires alignments larger than double. (For
+@@ -728,28 +652,6 @@ union luai_Cast { double l_d; long l_l;
+ #define luai_userstateyield(L,n) ((void)L)
+
+
+-/*
+-@@ LUA_INTFRMLEN is the length modifier for integer conversions
+-@* in 'string.format'.
+-@@ LUA_INTFRM_T is the integer type correspoding to the previous length
+-@* modifier.
+-** CHANGE them if your system supports long long or does not support long.
+-*/
+-
+-#if defined(LUA_USELONGLONG)
+-
+-#define LUA_INTFRMLEN "ll"
+-#define LUA_INTFRM_T long long
+-
+-#else
+-
+-#define LUA_INTFRMLEN "l"
+-#define LUA_INTFRM_T long
+-
+-#endif
+-
+-
+-
+ /* =================================================================== */
+
+ /*
+--- a/src/lundump.c
++++ b/src/lundump.c
+@@ -73,6 +73,13 @@ static lua_Number LoadNumber(LoadState*
+ return x;
+ }
+
++static lua_Integer LoadInteger(LoadState* S)
++{
++ lua_Integer x;
++ LoadVar(S,x);
++ return x;
++}
++
+ static TString* LoadString(LoadState* S)
+ {
+ size_t size;
+@@ -119,6 +126,9 @@ static void LoadConstants(LoadState* S,
+ case LUA_TNUMBER:
+ setnvalue(o,LoadNumber(S));
+ break;
++ case LUA_TINT: /* Integer type saved in bytecode (see lcode.c) */
++ setivalue(o,LoadInteger(S));
++ break;
+ case LUA_TSTRING:
+ setsvalue2n(S->L,o,LoadString(S));
+ break;
+@@ -223,5 +233,22 @@ void luaU_header (char* h)
+ *h++=(char)sizeof(size_t);
+ *h++=(char)sizeof(Instruction);
+ *h++=(char)sizeof(lua_Number);
+- *h++=(char)(((lua_Number)0.5)==0); /* is lua_Number integral? */
++
++ /*
++ * Last byte of header (0/1 in unpatched Lua 5.1.3):
++ *
++ * 0: lua_Number is float or double, lua_Integer not used. (nonpatched only)
++ * 1: lua_Number is integer (nonpatched only)
++ *
++ * +2: LNUM_INT16: sizeof(lua_Integer)
++ * +4: LNUM_INT32: sizeof(lua_Integer)
++ * +8: LNUM_INT64: sizeof(lua_Integer)
++ *
++ * +0x80: LNUM_COMPLEX
++ */
++ *h++ = (char)(sizeof(lua_Integer)
++#ifdef LNUM_COMPLEX
++ | 0x80
++#endif
++ );
+ }
+--- a/src/lvm.c
++++ b/src/lvm.c
+@@ -25,22 +25,35 @@
+ #include "ltable.h"
+ #include "ltm.h"
+ #include "lvm.h"
+-
+-
++#include "llex.h"
++#include "lnum.h"
+
+ /* limit for table tag-method chains (to avoid loops) */
+ #define MAXTAGLOOP 100
+
+
+-const TValue *luaV_tonumber (const TValue *obj, TValue *n) {
+- lua_Number num;
++/*
++ * If 'obj' is a string, it is tried to be interpreted as a number.
++ */
++const TValue *luaV_tonumber ( const TValue *obj, TValue *n) {
++ lua_Number d;
++ lua_Integer i;
++
+ if (ttisnumber(obj)) return obj;
+- if (ttisstring(obj) && luaO_str2d(svalue(obj), &num)) {
+- setnvalue(n, num);
+- return n;
+- }
+- else
+- return NULL;
++
++ if (ttisstring(obj)) {
++ switch( luaO_str2d( svalue(obj), &d, &i ) ) {
++ case TK_INT:
++ setivalue(n,i); return n;
++ case TK_NUMBER:
++ setnvalue(n,d); return n;
++#ifdef LNUM_COMPLEX
++ case TK_NUMBER2: /* "N.NNNi", != 0 */
++ setnvalue_complex_fast(n, d*I); return n;
++#endif
++ }
++ }
++ return NULL;
+ }
+
+
+@@ -49,8 +62,7 @@ int luaV_tostring (lua_State *L, StkId o
+ return 0;
+ else {
+ char s[LUAI_MAXNUMBER2STR];
+- lua_Number n = nvalue(obj);
+- lua_number2str(s, n);
++ luaO_num2buf(s,obj);
+ setsvalue2s(L, obj, luaS_new(L, s));
+ return 1;
+ }
+@@ -222,59 +234,127 @@ static int l_strcmp (const TString *ls,
+ }
+
+
++#ifdef LNUM_COMPLEX
++void error_complex( lua_State *L, const TValue *l, const TValue *r )
++{
++ char buf1[ LUAI_MAXNUMBER2STR ];
++ char buf2[ LUAI_MAXNUMBER2STR ];
++ luaO_num2buf( buf1, l );
++ luaO_num2buf( buf2, r );
++ luaG_runerror( L, "unable to compare: %s with %s", buf1, buf2 );
++ /* no return */
++}
++#endif
++
++
+ int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r) {
+ int res;
+- if (ttype(l) != ttype(r))
++ int tl,tr;
++ lua_Integer tmp;
++
++ if (!ttype_ext_same(l,r))
+ return luaG_ordererror(L, l, r);
+- else if (ttisnumber(l))
+- return luai_numlt(nvalue(l), nvalue(r));
+- else if (ttisstring(l))
+- return l_strcmp(rawtsvalue(l), rawtsvalue(r)) < 0;
+- else if ((res = call_orderTM(L, l, r, TM_LT)) != -1)
++#ifdef LNUM_COMPLEX
++ if ( (nvalue_img(l)!=0) || (nvalue_img(r)!=0) )
++ error_complex( L, l, r );
++#endif
++ tl= ttype(l); tr= ttype(r);
++ if (tl==tr) { /* clear arithmetics */
++ switch(tl) {
++ case LUA_TINT: return ivalue(l) < ivalue(r);
++ case LUA_TNUMBER: return luai_numlt(nvalue_fast(l), nvalue_fast(r));
++ case LUA_TSTRING: return l_strcmp(rawtsvalue(l), rawtsvalue(r)) < 0;
++ }
++ } else if (tl==LUA_TINT) { /* l:int, r:num */
++ /* Avoid accuracy losing casts: if 'r' is integer by value, do comparisons
++ * in integer realm. Only otherwise cast 'l' to FP (which might change its
++ * value).
++ */
++ if (tt_integer_valued(r,&tmp))
++ return ivalue(l) < tmp;
++ else
++ return luai_numlt( cast_num(ivalue(l)), nvalue_fast(r) );
++
++ } else if (tl==LUA_TNUMBER) { /* l:num, r:int */
++ if (tt_integer_valued(l,&tmp))
++ return tmp < ivalue(r);
++ else
++ return luai_numlt( nvalue_fast(l), cast_num(ivalue(r)) );
++
++ } else if ((res = call_orderTM(L, l, r, TM_LT)) != -1)
+ return res;
++
+ return luaG_ordererror(L, l, r);
+ }
+
+
+ static int lessequal (lua_State *L, const TValue *l, const TValue *r) {
+ int res;
+- if (ttype(l) != ttype(r))
++ int tl, tr;
++ lua_Integer tmp;
++
++ if (!ttype_ext_same(l,r))
+ return luaG_ordererror(L, l, r);
+- else if (ttisnumber(l))
+- return luai_numle(nvalue(l), nvalue(r));
+- else if (ttisstring(l))
+- return l_strcmp(rawtsvalue(l), rawtsvalue(r)) <= 0;
+- else if ((res = call_orderTM(L, l, r, TM_LE)) != -1) /* first try `le' */
++#ifdef LNUM_COMPLEX
++ if ( (nvalue_img(l)!=0) || (nvalue_img(r)!=0) )
++ error_complex( L, l, r );
++#endif
++ tl= ttype(l); tr= ttype(r);
++ if (tl==tr) { /* clear arithmetics */
++ switch(tl) {
++ case LUA_TINT: return ivalue(l) <= ivalue(r);
++ case LUA_TNUMBER: return luai_numle(nvalue_fast(l), nvalue_fast(r));
++ case LUA_TSTRING: return l_strcmp(rawtsvalue(l), rawtsvalue(r)) <= 0;
++ }
++ }
++ if (tl==LUA_TINT) { /* l:int, r:num */
++ if (tt_integer_valued(r,&tmp))
++ return ivalue(l) <= tmp;
++ else
++ return luai_numle( cast_num(ivalue(l)), nvalue_fast(r) );
++
++ } else if (tl==LUA_TNUMBER) { /* l:num, r:int */
++ if (tt_integer_valued(l,&tmp))
++ return tmp <= ivalue(r);
++ else
++ return luai_numle( nvalue_fast(l), cast_num(ivalue(r)) );
++
++ } else if ((res = call_orderTM(L, l, r, TM_LE)) != -1) /* first try `le' */
+ return res;
+ else if ((res = call_orderTM(L, r, l, TM_LT)) != -1) /* else try `lt' */
+ return !res;
++
+ return luaG_ordererror(L, l, r);
+ }
+
+
+-int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2) {
++/* Note: 'luaV_equalval()' and 'luaO_rawequalObj()' have largely overlapping
++ * implementation. LUA_TNIL..LUA_TLIGHTUSERDATA cases could be handled
++ * simply by the 'default' case here.
++ */
++int luaV_equalval (lua_State *L, const TValue *l, const TValue *r) {
+ const TValue *tm;
+- lua_assert(ttype(t1) == ttype(t2));
+- switch (ttype(t1)) {
++ lua_assert(ttype_ext_same(l,r));
++ switch (ttype(l)) {
+ case LUA_TNIL: return 1;
+- case LUA_TNUMBER: return luai_numeq(nvalue(t1), nvalue(t2));
+- case LUA_TBOOLEAN: return bvalue(t1) == bvalue(t2); /* true must be 1 !! */
+- case LUA_TLIGHTUSERDATA: return pvalue(t1) == pvalue(t2);
++ case LUA_TINT:
++ case LUA_TNUMBER: return luaO_rawequalObj(l,r);
++ case LUA_TBOOLEAN: return bvalue(l) == bvalue(r); /* true must be 1 !! */
++ case LUA_TLIGHTUSERDATA: return pvalue(l) == pvalue(r);
+ case LUA_TUSERDATA: {
+- if (uvalue(t1) == uvalue(t2)) return 1;
+- tm = get_compTM(L, uvalue(t1)->metatable, uvalue(t2)->metatable,
+- TM_EQ);
++ if (uvalue(l) == uvalue(r)) return 1;
++ tm = get_compTM(L, uvalue(l)->metatable, uvalue(r)->metatable, TM_EQ);
+ break; /* will try TM */
+ }
+ case LUA_TTABLE: {
+- if (hvalue(t1) == hvalue(t2)) return 1;
+- tm = get_compTM(L, hvalue(t1)->metatable, hvalue(t2)->metatable, TM_EQ);
++ if (hvalue(l) == hvalue(r)) return 1;
++ tm = get_compTM(L, hvalue(l)->metatable, hvalue(r)->metatable, TM_EQ);
+ break; /* will try TM */
+ }
+- default: return gcvalue(t1) == gcvalue(t2);
++ default: return gcvalue(l) == gcvalue(r);
+ }
+ if (tm == NULL) return 0; /* no TM? */
+- callTMres(L, L->top, tm, t1, t2); /* call TM */
++ callTMres(L, L->top, tm, l, r); /* call TM */
+ return !l_isfalse(L->top);
+ }
+
+@@ -314,30 +394,6 @@ void luaV_concat (lua_State *L, int tota
+ }
+
+
+-static void Arith (lua_State *L, StkId ra, const TValue *rb,
+- const TValue *rc, TMS op) {
+- TValue tempb, tempc;
+- const TValue *b, *c;
+- if ((b = luaV_tonumber(rb, &tempb)) != NULL &&
+- (c = luaV_tonumber(rc, &tempc)) != NULL) {
+- lua_Number nb = nvalue(b), nc = nvalue(c);
+- switch (op) {
+- case TM_ADD: setnvalue(ra, luai_numadd(nb, nc)); break;
+- case TM_SUB: setnvalue(ra, luai_numsub(nb, nc)); break;
+- case TM_MUL: setnvalue(ra, luai_nummul(nb, nc)); break;
+- case TM_DIV: setnvalue(ra, luai_numdiv(nb, nc)); break;
+- case TM_MOD: setnvalue(ra, luai_nummod(nb, nc)); break;
+- case TM_POW: setnvalue(ra, luai_numpow(nb, nc)); break;
+- case TM_UNM: setnvalue(ra, luai_numunm(nb)); break;
+- default: lua_assert(0); break;
+- }
+- }
+- else if (!call_binTM(L, rb, rc, ra, op))
+- luaG_aritherror(L, rb, rc);
+-}
+-
+-
+-
+ /*
+ ** some macros for common tasks in `luaV_execute'
+ */
+@@ -361,17 +417,154 @@ static void Arith (lua_State *L, StkId r
+ #define Protect(x) { L->savedpc = pc; {x;}; base = L->base; }
+
+
+-#define arith_op(op,tm) { \
+- TValue *rb = RKB(i); \
+- TValue *rc = RKC(i); \
+- if (ttisnumber(rb) && ttisnumber(rc)) { \
+- lua_Number nb = nvalue(rb), nc = nvalue(rc); \
+- setnvalue(ra, op(nb, nc)); \
+- } \
+- else \
+- Protect(Arith(L, ra, rb, rc, tm)); \
++/* Note: if called for unary operations, 'rc'=='rb'.
++ */
++static void Arith (lua_State *L, StkId ra, const TValue *rb,
++ const TValue *rc, TMS op) {
++ TValue tempb, tempc;
++ const TValue *b, *c;
++ lua_Number nb,nc;
++
++ if ((b = luaV_tonumber(rb, &tempb)) != NULL &&
++ (c = luaV_tonumber(rc, &tempc)) != NULL) {
++
++ /* Keep integer arithmetics in the integer realm, if possible.
++ */
++ if (ttisint(b) && ttisint(c)) {
++ lua_Integer ib = ivalue(b), ic = ivalue(c);
++ lua_Integer *ri = &ra->value.i;
++ ra->tt= LUA_TINT; /* part of 'setivalue(ra)' */
++ switch (op) {
++ case TM_ADD: if (try_addint( ri, ib, ic)) return; break;
++ case TM_SUB: if (try_subint( ri, ib, ic)) return; break;
++ case TM_MUL: if (try_mulint( ri, ib, ic)) return; break;
++ case TM_DIV: if (try_divint( ri, ib, ic)) return; break;
++ case TM_MOD: if (try_modint( ri, ib, ic)) return; break;
++ case TM_POW: if (try_powint( ri, ib, ic)) return; break;
++ case TM_UNM: if (try_unmint( ri, ib)) return; break;
++ default: lua_assert(0);
++ }
++ }
++ /* Fallback to floating point, when leaving range. */
++
++#ifdef LNUM_COMPLEX
++ if ((nvalue_img(b)!=0) || (nvalue_img(c)!=0)) {
++ lua_Complex r;
++ if (op==TM_UNM) {
++ r= -nvalue_complex_fast(b); /* never an integer (or scalar) */
++ setnvalue_complex_fast( ra, r );
++ } else {
++ lua_Complex bb= nvalue_complex(b), cc= nvalue_complex(c);
++ switch (op) {
++ case TM_ADD: r= bb + cc; break;
++ case TM_SUB: r= bb - cc; break;
++ case TM_MUL: r= bb * cc; break;
++ case TM_DIV: r= bb / cc; break;
++ case TM_MOD:
++ luaG_runerror(L, "attempt to use %% on complex numbers"); /* no return */
++ case TM_POW: r= luai_vectpow( bb, cc ); break;
++ default: lua_assert(0); r=0;
++ }
++ setnvalue_complex( ra, r );
+ }
++ return;
++ }
++#endif
++ nb = nvalue(b); nc = nvalue(c);
++ switch (op) {
++ case TM_ADD: setnvalue(ra, luai_numadd(nb, nc)); return;
++ case TM_SUB: setnvalue(ra, luai_numsub(nb, nc)); return;
++ case TM_MUL: setnvalue(ra, luai_nummul(nb, nc)); return;
++ case TM_DIV: setnvalue(ra, luai_numdiv(nb, nc)); return;
++ case TM_MOD: setnvalue(ra, luai_nummod(nb, nc)); return;
++ case TM_POW: setnvalue(ra, luai_numpow(nb, nc)); return;
++ case TM_UNM: setnvalue(ra, luai_numunm(nb)); return;
++ default: lua_assert(0);
++ }
++ }
++
++ /* Either operand not a number */
++ if (!call_binTM(L, rb, rc, ra, op))
++ luaG_aritherror(L, rb, rc);
++}
+
++/* Helper macro to sort arithmetic operations into four categories:
++ * TK_INT: integer - integer operands
++ * TK_NUMBER: number - number (non complex, either may be integer)
++ * TK_NUMBER2: complex numbers (at least the other)
++ * 0: non-numeric (at least the other)
++*/
++#ifdef LNUM_COMPLEX
++static inline int arith_mode( const TValue *rb, const TValue *rc ) {
++ if (ttisint(rb) && ttisint(rc)) return TK_INT;
++ if (ttiscomplex(rb) || ttiscomplex(rc)) return TK_NUMBER2;
++ if (ttisnumber(rb) && ttisnumber(rc)) return TK_NUMBER;
++ return 0;
++}
++#else
++# define arith_mode(rb,rc) \
++ ( (ttisint(rb) && ttisint(rc)) ? TK_INT : \
++ (ttisnumber(rb) && ttisnumber(rc)) ? TK_NUMBER : 0 )
++#endif
++
++/* arith_op macro for two operators:
++ * automatically chooses, which function (number, integer, complex) to use
++ */
++#define ARITH_OP2_START( op_num, op_int ) \
++ int failed= 0; \
++ switch( arith_mode(rb,rc) ) { \
++ case TK_INT: \
++ if (op_int ( &(ra)->value.i, ivalue(rb), ivalue(rc) )) \
++ { ra->tt= LUA_TINT; break; } /* else flow through */ \
++ case TK_NUMBER: \
++ setnvalue(ra, op_num ( nvalue(rb), nvalue(rc) )); break;
++
++#define ARITH_OP2_END \
++ default: \
++ failed= 1; break; \
++ } if (!failed) continue;
++
++#define arith_op_continue_scalar( op_num, op_int ) \
++ ARITH_OP2_START( op_num, op_int ) \
++ ARITH_OP2_END
++
++#ifdef LNUM_COMPLEX
++# define arith_op_continue( op_num, op_int, op_complex ) \
++ ARITH_OP2_START( op_num, op_int ) \
++ case TK_NUMBER2: \
++ setnvalue_complex( ra, op_complex ( nvalue_complex(rb), nvalue_complex(rc) ) ); break; \
++ ARITH_OP2_END
++#else
++# define arith_op_continue(op_num,op_int,_) arith_op_continue_scalar(op_num,op_int)
++#endif
++
++/* arith_op macro for one operator:
++ */
++#define ARITH_OP1_START( op_num, op_int ) \
++ int failed= 0; \
++ switch( arith_mode(rb,rb) ) { \
++ case TK_INT: \
++ if (op_int ( &(ra)->value.i, ivalue(rb) )) \
++ { ra->tt= LUA_TINT; break; } /* else flow through */ \
++ case TK_NUMBER: \
++ setnvalue(ra, op_num (nvalue(rb))); break; \
++
++#define ARITH_OP1_END \
++ default: \
++ failed= 1; break; \
++ } if (!failed) continue;
++
++#ifdef LNUM_COMPLEX
++# define arith_op1_continue( op_num, op_int, op_complex ) \
++ ARITH_OP1_START( op_num, op_int ) \
++ case TK_NUMBER2: \
++ setnvalue_complex( ra, op_complex ( nvalue_complex_fast(rb) )); break; \
++ ARITH_OP1_END
++#else
++# define arith_op1_continue( op_num, op_int, _ ) \
++ ARITH_OP1_START( op_num, op_int ) \
++ ARITH_OP1_END
++#endif
+
+
+ void luaV_execute (lua_State *L, int nexeccalls) {
+@@ -472,38 +665,45 @@ void luaV_execute (lua_State *L, int nex
+ continue;
+ }
+ case OP_ADD: {
+- arith_op(luai_numadd, TM_ADD);
++ TValue *rb = RKB(i), *rc= RKC(i);
++ arith_op_continue( luai_numadd, try_addint, luai_vectadd );
++ Protect(Arith(L, ra, rb, rc, TM_ADD)); \
+ continue;
+ }
+ case OP_SUB: {
+- arith_op(luai_numsub, TM_SUB);
++ TValue *rb = RKB(i), *rc= RKC(i);
++ arith_op_continue( luai_numsub, try_subint, luai_vectsub );
++ Protect(Arith(L, ra, rb, rc, TM_SUB));
+ continue;
+ }
+ case OP_MUL: {
+- arith_op(luai_nummul, TM_MUL);
++ TValue *rb = RKB(i), *rc= RKC(i);
++ arith_op_continue(luai_nummul, try_mulint, luai_vectmul);
++ Protect(Arith(L, ra, rb, rc, TM_MUL));
+ continue;
+ }
+ case OP_DIV: {
+- arith_op(luai_numdiv, TM_DIV);
++ TValue *rb = RKB(i), *rc= RKC(i);
++ arith_op_continue(luai_numdiv, try_divint, luai_vectdiv);
++ Protect(Arith(L, ra, rb, rc, TM_DIV));
+ continue;
+ }
+ case OP_MOD: {
+- arith_op(luai_nummod, TM_MOD);
++ TValue *rb = RKB(i), *rc= RKC(i);
++ arith_op_continue_scalar(luai_nummod, try_modint); /* scalars only */
++ Protect(Arith(L, ra, rb, rc, TM_MOD));
+ continue;
+ }
+ case OP_POW: {
+- arith_op(luai_numpow, TM_POW);
++ TValue *rb = RKB(i), *rc= RKC(i);
++ arith_op_continue(luai_numpow, try_powint, luai_vectpow);
++ Protect(Arith(L, ra, rb, rc, TM_POW));
+ continue;
+ }
+ case OP_UNM: {
+ TValue *rb = RB(i);
+- if (ttisnumber(rb)) {
+- lua_Number nb = nvalue(rb);
+- setnvalue(ra, luai_numunm(nb));
+- }
+- else {
+- Protect(Arith(L, ra, rb, rb, TM_UNM));
+- }
++ arith_op1_continue(luai_numunm, try_unmint, luai_vectunm);
++ Protect(Arith(L, ra, rb, rb, TM_UNM));
+ continue;
+ }
+ case OP_NOT: {
+@@ -515,11 +715,11 @@ void luaV_execute (lua_State *L, int nex
+ const TValue *rb = RB(i);
+ switch (ttype(rb)) {
+ case LUA_TTABLE: {
+- setnvalue(ra, cast_num(luaH_getn(hvalue(rb))));
++ setivalue(ra, luaH_getn(hvalue(rb)));
+ break;
+ }
+ case LUA_TSTRING: {
+- setnvalue(ra, cast_num(tsvalue(rb)->len));
++ setivalue(ra, tsvalue(rb)->len);
+ break;
+ }
+ default: { /* try metamethod */
+@@ -652,14 +852,30 @@ void luaV_execute (lua_State *L, int nex
+ }
+ }
+ case OP_FORLOOP: {
+- lua_Number step = nvalue(ra+2);
+- lua_Number idx = luai_numadd(nvalue(ra), step); /* increment index */
+- lua_Number limit = nvalue(ra+1);
+- if (luai_numlt(0, step) ? luai_numle(idx, limit)
+- : luai_numle(limit, idx)) {
+- dojump(L, pc, GETARG_sBx(i)); /* jump back */
+- setnvalue(ra, idx); /* update internal index... */
+- setnvalue(ra+3, idx); /* ...and external index */
++ /* If start,step and limit are all integers, we don't need to check
++ * against overflow in the looping.
++ */
++ if (ttisint(ra) && ttisint(ra+1) && ttisint(ra+2)) {
++ lua_Integer step = ivalue(ra+2);
++ lua_Integer idx = ivalue(ra) + step; /* increment index */
++ lua_Integer limit = ivalue(ra+1);
++ if (step > 0 ? (idx <= limit) : (limit <= idx)) {
++ dojump(L, pc, GETARG_sBx(i)); /* jump back */
++ setivalue(ra, idx); /* update internal index... */
++ setivalue(ra+3, idx); /* ...and external index */
++ }
++ } else {
++ /* non-integer looping (don't use 'nvalue_fast', some may be integer!)
++ */
++ lua_Number step = nvalue(ra+2);
++ lua_Number idx = luai_numadd(nvalue(ra), step); /* increment index */
++ lua_Number limit = nvalue(ra+1);
++ if (luai_numlt(0, step) ? luai_numle(idx, limit)
++ : luai_numle(limit, idx)) {
++ dojump(L, pc, GETARG_sBx(i)); /* jump back */
++ setnvalue(ra, idx); /* update internal index... */
++ setnvalue(ra+3, idx); /* ...and external index */
++ }
+ }
+ continue;
+ }
+@@ -668,13 +884,21 @@ void luaV_execute (lua_State *L, int nex
+ const TValue *plimit = ra+1;
+ const TValue *pstep = ra+2;
+ L->savedpc = pc; /* next steps may throw errors */
++ /* Using same location for tonumber's both arguments, effectively does
++ * in-place modification (string->number). */
+ if (!tonumber(init, ra))
+ luaG_runerror(L, LUA_QL("for") " initial value must be a number");
+ else if (!tonumber(plimit, ra+1))
+ luaG_runerror(L, LUA_QL("for") " limit must be a number");
+ else if (!tonumber(pstep, ra+2))
+ luaG_runerror(L, LUA_QL("for") " step must be a number");
+- setnvalue(ra, luai_numsub(nvalue(ra), nvalue(pstep)));
++ /* Step back one value (keep within integers if we can)
++ */
++ if (!( ttisint(ra) && ttisint(pstep) &&
++ try_subint( &ra->value.i, ivalue(ra), ivalue(pstep) ) )) {
++ /* don't use 'nvalue_fast()', values may be integer */
++ setnvalue(ra, luai_numsub(nvalue(ra), nvalue(pstep)));
++ }
+ dojump(L, pc, GETARG_sBx(i));
+ continue;
+ }
+@@ -711,7 +935,7 @@ void luaV_execute (lua_State *L, int nex
+ luaH_resizearray(L, h, last); /* pre-alloc it at once */
+ for (; n > 0; n--) {
+ TValue *val = ra+n;
+- setobj2t(L, luaH_setnum(L, h, last--), val);
++ setobj2t(L, luaH_setint(L, h, last--), val);
+ luaC_barriert(L, h, val);
+ }
+ continue;
+--- a/src/lvm.h
++++ b/src/lvm.h
+@@ -15,11 +15,9 @@
+
+ #define tostring(L,o) ((ttype(o) == LUA_TSTRING) || (luaV_tostring(L, o)))
+
+-#define tonumber(o,n) (ttype(o) == LUA_TNUMBER || \
+- (((o) = luaV_tonumber(o,n)) != NULL))
++#define tonumber(o,n) (ttisnumber(o) || (((o) = luaV_tonumber(o,n)) != NULL))
+
+-#define equalobj(L,o1,o2) \
+- (ttype(o1) == ttype(o2) && luaV_equalval(L, o1, o2))
++#define equalobj(L,o1,o2) (ttype_ext_same(o1,o2) && luaV_equalval(L, o1, o2))
+
+
+ LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r);
+--- a/src/print.c
++++ b/src/print.c
+@@ -14,6 +14,7 @@
+ #include "lobject.h"
+ #include "lopcodes.h"
+ #include "lundump.h"
++#include "lnum.h"
+
+ #define PrintFunction luaU_print
+
+@@ -59,8 +60,16 @@ static void PrintConstant(const Proto* f
+ case LUA_TBOOLEAN:
+ printf(bvalue(o) ? "true" : "false");
+ break;
++ case LUA_TINT:
++ printf(LUA_INTEGER_FMT,ivalue(o));
++ break;
+ case LUA_TNUMBER:
+- printf(LUA_NUMBER_FMT,nvalue(o));
++#ifdef LNUM_COMPLEX
++ // TBD: Do we get complex values here?
++ { lua_Number b= nvalue_img_fast(o);
++ printf( LUA_NUMBER_FMT "%s" LUA_NUMBER_FMT "i", nvalue_fast(o), b>=0 ? "+":"", b ); }
++#endif
++ printf(LUA_NUMBER_FMT,nvalue_fast(o));
+ break;
+ case LUA_TSTRING:
+ PrintString(rawtsvalue(o));
diff --git a/package/lua/patches-host/011-lnum-use-double.patch b/package/lua/patches-host/011-lnum-use-double.patch
new file mode 100644
index 0000000..14c720b
--- /dev/null
+++ b/package/lua/patches-host/011-lnum-use-double.patch
@@ -0,0 +1,11 @@
+--- a/src/lnum_config.h
++++ b/src/lnum_config.h
+@@ -11,7 +11,7 @@
+ ** Default number modes
+ */
+ #if (!defined LNUM_DOUBLE) && (!defined LNUM_FLOAT) && (!defined LNUM_LDOUBLE)
+-# define LNUM_FLOAT
++# define LNUM_DOUBLE
+ #endif
+ #if (!defined LNUM_INT16) && (!defined LNUM_INT32) && (!defined LNUM_INT64)
+ # define LNUM_INT32
diff --git a/package/lua/patches-host/015-lnum-ppc-compat.patch b/package/lua/patches-host/015-lnum-ppc-compat.patch
new file mode 100644
index 0000000..2ea59f1
--- /dev/null
+++ b/package/lua/patches-host/015-lnum-ppc-compat.patch
@@ -0,0 +1,11 @@
+--- a/src/lua.h
++++ b/src/lua.h
+@@ -79,7 +79,7 @@ typedef void * (*lua_Alloc) (void *ud, v
+ * not acceptable for 5.1, maybe 5.2 onwards?
+ * 9: greater than existing (5.1) type values.
+ */
+-#define LUA_TINT (-2)
++#define LUA_TINT 9
+
+ #define LUA_TNIL 0
+ #define LUA_TBOOLEAN 1
diff --git a/package/lua/patches-host/030-archindependent-bytecode.patch b/package/lua/patches-host/030-archindependent-bytecode.patch
new file mode 100644
index 0000000..8dfef85
--- /dev/null
+++ b/package/lua/patches-host/030-archindependent-bytecode.patch
@@ -0,0 +1,111 @@
+--- a/src/ldump.c
++++ b/src/ldump.c
+@@ -67,12 +67,12 @@ static void DumpString(const TString* s,
+ {
+ if (s==NULL || getstr(s)==NULL)
+ {
+- size_t size=0;
++ unsigned int size=0;
+ DumpVar(size,D);
+ }
+ else
+ {
+- size_t size=s->tsv.len+1; /* include trailing '\0' */
++ unsigned int size=s->tsv.len+1; /* include trailing '\0' */
+ DumpVar(size,D);
+ DumpBlock(getstr(s),size,D);
+ }
+--- a/src/lundump.c
++++ b/src/lundump.c
+@@ -25,6 +25,7 @@ typedef struct {
+ ZIO* Z;
+ Mbuffer* b;
+ const char* name;
++ int swap;
+ } LoadState;
+
+ #ifdef LUAC_TRUST_BINARIES
+@@ -40,7 +41,6 @@ static void error(LoadState* S, const ch
+ }
+ #endif
+
+-#define LoadMem(S,b,n,size) LoadBlock(S,b,(n)*(size))
+ #define LoadByte(S) (lu_byte)LoadChar(S)
+ #define LoadVar(S,x) LoadMem(S,&x,1,sizeof(x))
+ #define LoadVector(S,b,n,size) LoadMem(S,b,n,size)
+@@ -51,6 +51,49 @@ static void LoadBlock(LoadState* S, void
+ IF (r!=0, "unexpected end");
+ }
+
++static void LoadMem (LoadState* S, void* b, int n, size_t size)
++{
++ LoadBlock(S,b,n*size);
++ if (S->swap)
++ {
++ char* p=(char*) b;
++ char c;
++ switch (size)
++ {
++ case 1:
++ break;
++ case 2:
++ while (n--)
++ {
++ c=p[0]; p[0]=p[1]; p[1]=c;
++ p+=2;
++ }
++ break;
++ case 4:
++ while (n--)
++ {
++ c=p[0]; p[0]=p[3]; p[3]=c;
++ c=p[1]; p[1]=p[2]; p[2]=c;
++ p+=4;
++ }
++ break;
++ case 8:
++ while (n--)
++ {
++ c=p[0]; p[0]=p[7]; p[7]=c;
++ c=p[1]; p[1]=p[6]; p[6]=c;
++ c=p[2]; p[2]=p[5]; p[5]=c;
++ c=p[3]; p[3]=p[4]; p[4]=c;
++ p+=8;
++ }
++ break;
++ default:
++ IF(1, "bad size");
++ break;
++ }
++ }
++}
++
+ static int LoadChar(LoadState* S)
+ {
+ char x;
+@@ -82,7 +125,7 @@ static lua_Integer LoadInteger(LoadState
+
+ static TString* LoadString(LoadState* S)
+ {
+- size_t size;
++ unsigned int size;
+ LoadVar(S,size);
+ if (size==0)
+ return NULL;
+@@ -196,6 +239,7 @@ static void LoadHeader(LoadState* S)
+ char s[LUAC_HEADERSIZE];
+ luaU_header(h);
+ LoadBlock(S,s,LUAC_HEADERSIZE);
++ S->swap=(s[6]!=h[6]); s[6]=h[6];
+ IF (memcmp(h,s,LUAC_HEADERSIZE)!=0, "bad header");
+ }
+
+@@ -230,7 +274,7 @@ void luaU_header (char* h)
+ *h++=(char)LUAC_FORMAT;
+ *h++=(char)*(char*)&x; /* endianness */
+ *h++=(char)sizeof(int);
+- *h++=(char)sizeof(size_t);
++ *h++=(char)sizeof(unsigned int);
+ *h++=(char)sizeof(Instruction);
+ *h++=(char)sizeof(lua_Number);
+
diff --git a/package/lua/patches-host/100-no_readline.patch b/package/lua/patches-host/100-no_readline.patch
new file mode 100644
index 0000000..209c302
--- /dev/null
+++ b/package/lua/patches-host/100-no_readline.patch
@@ -0,0 +1,49 @@
+--- a/src/luaconf.h
++++ b/src/luaconf.h
+@@ -38,7 +38,6 @@
+ #if defined(LUA_USE_LINUX)
+ #define LUA_USE_POSIX
+ #define LUA_USE_DLOPEN /* needs an extra library: -ldl */
+-#define LUA_USE_READLINE /* needs some extra libraries */
+ #endif
+
+ #if defined(LUA_USE_MACOSX)
+--- a/src/Makefile
++++ b/src/Makefile
+@@ -17,6 +17,7 @@
+ MYCFLAGS=
+ MYLDFLAGS=
+ MYLIBS=
++# USE_READLINE=1
+
+ # == END OF USER SETTINGS. NO NEED TO CHANGE ANYTHING BELOW THIS LINE =========
+
+@@ -75,7 +76,7 @@
+ @echo "MYLIBS = $(MYLIBS)"
+
+ # convenience targets for popular platforms
+-
++RFLAG=$(if $(USE_READLINE),-DLUA_USE_READLINE)
+ none:
+ @echo "Please choose a platform:"
+ @echo " $(PLATS)"
+@@ -90,16 +91,16 @@
+ $(MAKE) all MYCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-Wl,-E"
+
+ freebsd:
+- $(MAKE) all MYCFLAGS="-DLUA_USE_LINUX" MYLIBS="-Wl,-E -lreadline"
++ $(MAKE) all MYCFLAGS="-DLUA_USE_LINUX" $(RFLAG)" MYLIBS="-Wl,-E$(if $(USE_READLINE), -lreadline)"
+
+ generic:
+ $(MAKE) all MYCFLAGS=
+
+ linux:
+- $(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-Wl,-E -ldl -lreadline -lhistory -lncurses"
++ $(MAKE) all MYCFLAGS="-DLUA_USE_LINUX $(RFLAG)" MYLIBS="-Wl,-E -ldl $(if $(USE_READLINE), -lreadline -lhistory -lncurses)"
+
+ macosx:
+- $(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-lreadline"
++ $(MAKE) all MYCFLAGS=-DLUA_USE_LINUX $(if $(USE_READLINE), MYLIBS="-lreadline")
+ # use this on Mac OS X 10.3-
+ # $(MAKE) all MYCFLAGS=-DLUA_USE_MACOSX
+
diff --git a/package/lua/patches/.svn/entries b/package/lua/patches/.svn/entries
new file mode 100644
index 0000000..1d417f7
--- /dev/null
+++ b/package/lua/patches/.svn/entries
@@ -0,0 +1,300 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/lua/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-10T17:53:46.373999Z
+33707
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+030-archindependent-bytecode.patch
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+6b38446b0ffa9ee7ddc3b0b26377ce2b
+2010-03-26T14:29:03.186010Z
+20470
+juhosg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2306
+
+010-lua-5.1.3-lnum-full-260308.patch
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+cafe42fc70c953a4db32c49abf40d515
+2012-10-10T17:53:46.373999Z
+33707
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+117861
+
+200-lua-path.patch
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+97bbb3b2c4fe2fbe98647b74740fe1f2
+2010-03-26T14:29:03.186010Z
+20470
+juhosg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+483
+
+300-opcode_performance.patch
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+dcaf26d73ad3f3d67c65fdd778b7ad55
+2012-10-10T17:53:46.373999Z
+33707
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+10461
+
+011-lnum-use-double.patch
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+f71cc92df350f29d1e2aa1c309e10379
+2010-10-07T11:03:18.001599Z
+23284
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+324
+
+020-shared_liblua.patch
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+84b711adadd94292ac83a419a3209cac
+2012-10-10T17:53:46.373999Z
+33707
+jow
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4633
+
+100-no_readline.patch
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+200adf377164943626cd494fa4f1da42
+2010-03-26T14:29:03.186010Z
+20470
+juhosg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1462
+
+015-lnum-ppc-compat.patch
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+17e1ebbbc2aad43a211fe9319a15f4b1
+2010-03-26T14:29:03.186010Z
+20470
+juhosg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+286
+
diff --git a/package/lua/patches/.svn/prop-base/020-shared_liblua.patch.svn-base b/package/lua/patches/.svn/prop-base/020-shared_liblua.patch.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/lua/patches/.svn/prop-base/020-shared_liblua.patch.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/lua/patches/.svn/text-base/010-lua-5.1.3-lnum-full-260308.patch.svn-base b/package/lua/patches/.svn/text-base/010-lua-5.1.3-lnum-full-260308.patch.svn-base
new file mode 100644
index 0000000..74b8c6f
--- /dev/null
+++ b/package/lua/patches/.svn/text-base/010-lua-5.1.3-lnum-full-260308.patch.svn-base
@@ -0,0 +1,3736 @@
+--- a/src/Makefile
++++ b/src/Makefile
+@@ -25,7 +25,7 @@ PLATS= aix ansi bsd freebsd generic linu
+ LUA_A= liblua.a
+ CORE_O= lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o \
+ lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o \
+- lundump.o lvm.o lzio.o
++ lundump.o lvm.o lzio.o lnum.o
+ LIB_O= lauxlib.o lbaselib.o ldblib.o liolib.o lmathlib.o loslib.o ltablib.o \
+ lstrlib.o loadlib.o linit.o
+
+@@ -148,6 +148,7 @@ llex.o: llex.c lua.h luaconf.h ldo.h lob
+ lmathlib.o: lmathlib.c lua.h luaconf.h lauxlib.h lualib.h
+ lmem.o: lmem.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h \
+ ltm.h lzio.h lmem.h ldo.h
++lnum.o: lnum.c lua.h llex.h lnum.h
+ loadlib.o: loadlib.c lua.h luaconf.h lauxlib.h lualib.h
+ lobject.o: lobject.c lua.h luaconf.h ldo.h lobject.h llimits.h lstate.h \
+ ltm.h lzio.h lmem.h lstring.h lgc.h lvm.h
+@@ -179,4 +180,18 @@ lzio.o: lzio.c lua.h luaconf.h llimits.h
+ print.o: print.c ldebug.h lstate.h lua.h luaconf.h lobject.h llimits.h \
+ ltm.h lzio.h lmem.h lopcodes.h lundump.h
+
++luaconf.h: lnum_config.h
++lapi.c: lnum.h
++lauxlib.c: llimits.h
++lbaselib.c: llimits.h lobject.h lapi.h
++lcode.c: lnum.h
++liolib.c: lnum.h llex.h
++llex.c: lnum.h
++lnum.h: lobject.h
++lobject.c: llex.h lnum.h
++ltable.c: lnum.h
++lua.c: llimits.h
++lvm.c: llex.h lnum.h
++print.c: lnum.h
++
+ # (end of Makefile)
+--- a/src/lapi.c
++++ b/src/lapi.c
+@@ -28,7 +28,7 @@
+ #include "ltm.h"
+ #include "lundump.h"
+ #include "lvm.h"
+-
++#include "lnum.h"
+
+
+ const char lua_ident[] =
+@@ -241,12 +241,13 @@ LUA_API void lua_pushvalue (lua_State *L
+
+ LUA_API int lua_type (lua_State *L, int idx) {
+ StkId o = index2adr(L, idx);
+- return (o == luaO_nilobject) ? LUA_TNONE : ttype(o);
++ return (o == luaO_nilobject) ? LUA_TNONE : ttype_ext(o);
+ }
+
+
+ LUA_API const char *lua_typename (lua_State *L, int t) {
+ UNUSED(L);
++ lua_assert( t!= LUA_TINT );
+ return (t == LUA_TNONE) ? "no value" : luaT_typenames[t];
+ }
+
+@@ -264,6 +265,14 @@ LUA_API int lua_isnumber (lua_State *L,
+ }
+
+
++LUA_API int lua_isinteger (lua_State *L, int idx) {
++ TValue tmp;
++ lua_Integer dum;
++ const TValue *o = index2adr(L, idx);
++ return tonumber(o,&tmp) && (ttisint(o) || tt_integer_valued(o,&dum));
++}
++
++
+ LUA_API int lua_isstring (lua_State *L, int idx) {
+ int t = lua_type(L, idx);
+ return (t == LUA_TSTRING || t == LUA_TNUMBER);
+@@ -309,31 +318,66 @@ LUA_API int lua_lessthan (lua_State *L,
+ }
+
+
+-
+ LUA_API lua_Number lua_tonumber (lua_State *L, int idx) {
+ TValue n;
+ const TValue *o = index2adr(L, idx);
+- if (tonumber(o, &n))
++ if (tonumber(o, &n)) {
++#ifdef LNUM_COMPLEX
++ if (nvalue_img(o) != 0)
++ luaG_runerror(L, "expecting a real number");
++#endif
+ return nvalue(o);
+- else
+- return 0;
++ }
++ return 0;
+ }
+
+
+ LUA_API lua_Integer lua_tointeger (lua_State *L, int idx) {
+ TValue n;
++ /* Lua 5.1 documented behaviour is to return nonzero for non-integer:
++ * "If the number is not an integer, it is truncated in some non-specified way."
++ * I would suggest to change this, to return 0 for anything that would
++ * not fit in 'lua_Integer'.
++ */
++#ifdef LUA_COMPAT_TOINTEGER
++ /* Lua 5.1 compatible */
+ const TValue *o = index2adr(L, idx);
+ if (tonumber(o, &n)) {
+- lua_Integer res;
+- lua_Number num = nvalue(o);
+- lua_number2integer(res, num);
+- return res;
++ lua_Integer i;
++ lua_Number d;
++ if (ttisint(o)) return ivalue(o);
++ d= nvalue_fast(o);
++# ifdef LNUM_COMPLEX
++ if (nvalue_img_fast(o) != 0)
++ luaG_runerror(L, "expecting a real number");
++# endif
++ lua_number2integer(i, d);
++ return i;
+ }
+- else
+- return 0;
++#else
++ /* New suggestion */
++ const TValue *o = index2adr(L, idx);
++ if (tonumber(o, &n)) {
++ lua_Integer i;
++ if (ttisint(o)) return ivalue(o);
++ if (tt_integer_valued(o,&i)) return i;
++ }
++#endif
++ return 0;
+ }
+
+
++#ifdef LNUM_COMPLEX
++LUA_API lua_Complex lua_tocomplex (lua_State *L, int idx) {
++ TValue tmp;
++ const TValue *o = index2adr(L, idx);
++ if (tonumber(o, &tmp))
++ return nvalue_complex(o);
++ return 0;
++}
++#endif
++
++
+ LUA_API int lua_toboolean (lua_State *L, int idx) {
+ const TValue *o = index2adr(L, idx);
+ return !l_isfalse(o);
+@@ -364,6 +408,7 @@ LUA_API size_t lua_objlen (lua_State *L,
+ case LUA_TSTRING: return tsvalue(o)->len;
+ case LUA_TUSERDATA: return uvalue(o)->len;
+ case LUA_TTABLE: return luaH_getn(hvalue(o));
++ case LUA_TINT:
+ case LUA_TNUMBER: {
+ size_t l;
+ lua_lock(L); /* `luaV_tostring' may create a new string */
+@@ -426,6 +471,8 @@ LUA_API void lua_pushnil (lua_State *L)
+ }
+
+
++/* 'lua_pushnumber()' may lose accuracy on integers, 'lua_pushinteger' will not.
++ */
+ LUA_API void lua_pushnumber (lua_State *L, lua_Number n) {
+ lua_lock(L);
+ setnvalue(L->top, n);
+@@ -434,12 +481,22 @@ LUA_API void lua_pushnumber (lua_State *
+ }
+
+
+-LUA_API void lua_pushinteger (lua_State *L, lua_Integer n) {
++LUA_API void lua_pushinteger (lua_State *L, lua_Integer i) {
++ lua_lock(L);
++ setivalue(L->top, i);
++ api_incr_top(L);
++ lua_unlock(L);
++}
++
++
++#ifdef LNUM_COMPLEX
++LUA_API void lua_pushcomplex (lua_State *L, lua_Complex v) {
+ lua_lock(L);
+- setnvalue(L->top, cast_num(n));
++ setnvalue_complex( L->top, v );
+ api_incr_top(L);
+ lua_unlock(L);
+ }
++#endif
+
+
+ LUA_API void lua_pushlstring (lua_State *L, const char *s, size_t len) {
+@@ -569,7 +626,7 @@ LUA_API void lua_rawgeti (lua_State *L,
+ lua_lock(L);
+ o = index2adr(L, idx);
+ api_check(L, ttistable(o));
+- setobj2s(L, L->top, luaH_getnum(hvalue(o), n));
++ setobj2s(L, L->top, luaH_getint(hvalue(o), n));
+ api_incr_top(L);
+ lua_unlock(L);
+ }
+@@ -597,6 +654,9 @@ LUA_API int lua_getmetatable (lua_State
+ case LUA_TUSERDATA:
+ mt = uvalue(obj)->metatable;
+ break;
++ case LUA_TINT:
++ mt = G(L)->mt[LUA_TNUMBER];
++ break;
+ default:
+ mt = G(L)->mt[ttype(obj)];
+ break;
+@@ -687,7 +747,7 @@ LUA_API void lua_rawseti (lua_State *L,
+ api_checknelems(L, 1);
+ o = index2adr(L, idx);
+ api_check(L, ttistable(o));
+- setobj2t(L, luaH_setnum(L, hvalue(o), n), L->top-1);
++ setobj2t(L, luaH_setint(L, hvalue(o), n), L->top-1);
+ luaC_barriert(L, hvalue(o), L->top-1);
+ L->top--;
+ lua_unlock(L);
+@@ -721,7 +781,7 @@ LUA_API int lua_setmetatable (lua_State
+ break;
+ }
+ default: {
+- G(L)->mt[ttype(obj)] = mt;
++ G(L)->mt[ttype_ext(obj)] = mt;
+ break;
+ }
+ }
+@@ -1085,3 +1145,32 @@ LUA_API const char *lua_setupvalue (lua_
+ return name;
+ }
+
++
++/* Help function for 'luaB_tonumber()', avoids multiple str->number
++ * conversions for Lua "tonumber()".
++ *
++ * Also pushes floating point numbers with integer value as integer, which
++ * can be used by 'tonumber()' in scripts to bring values back to integer
++ * realm.
++ *
++ * Note: The 'back to integer realm' is _not_ to affect string conversions:
++ * 'tonumber("4294967295.1")' should give a floating point value, although
++ * the value would be 4294967296 (and storable in int64 realm).
++ */
++int lua_pushvalue_as_number (lua_State *L, int idx)
++{
++ const TValue *o = index2adr(L, idx);
++ TValue tmp;
++ lua_Integer i;
++ if (ttisnumber(o)) {
++ if ( (!ttisint(o)) && tt_integer_valued(o,&i)) {
++ lua_pushinteger( L, i );
++ return 1;
++ }
++ } else if (!tonumber(o, &tmp)) {
++ return 0;
++ }
++ if (ttisint(o)) lua_pushinteger( L, ivalue(o) );
++ else lua_pushnumber( L, nvalue_fast(o) );
++ return 1;
++}
+--- a/src/lapi.h
++++ b/src/lapi.h
+@@ -13,4 +13,6 @@
+
+ LUAI_FUNC void luaA_pushobject (lua_State *L, const TValue *o);
+
++int lua_pushvalue_as_number (lua_State *L, int idx);
++
+ #endif
+--- a/src/lauxlib.c
++++ b/src/lauxlib.c
+@@ -23,7 +23,7 @@
+ #include "lua.h"
+
+ #include "lauxlib.h"
+-
++#include "llimits.h"
+
+ #define FREELIST_REF 0 /* free list of references */
+
+@@ -66,7 +66,7 @@ LUALIB_API int luaL_typerror (lua_State
+
+
+ static void tag_error (lua_State *L, int narg, int tag) {
+- luaL_typerror(L, narg, lua_typename(L, tag));
++ luaL_typerror(L, narg, tag==LUA_TINT ? "integer" : lua_typename(L, tag));
+ }
+
+
+@@ -188,8 +188,8 @@ LUALIB_API lua_Number luaL_optnumber (lu
+
+ LUALIB_API lua_Integer luaL_checkinteger (lua_State *L, int narg) {
+ lua_Integer d = lua_tointeger(L, narg);
+- if (d == 0 && !lua_isnumber(L, narg)) /* avoid extra test when d is not 0 */
+- tag_error(L, narg, LUA_TNUMBER);
++ if (d == 0 && !lua_isinteger(L, narg)) /* avoid extra test when d is not 0 */
++ tag_error(L, narg, LUA_TINT);
+ return d;
+ }
+
+@@ -200,6 +200,16 @@ LUALIB_API lua_Integer luaL_optinteger (
+ }
+
+
++#ifdef LNUM_COMPLEX
++LUALIB_API lua_Complex luaL_checkcomplex (lua_State *L, int narg) {
++ lua_Complex c = lua_tocomplex(L, narg);
++ if (c == 0 && !lua_isnumber(L, narg)) /* avoid extra test when c is not 0 */
++ tag_error(L, narg, LUA_TNUMBER);
++ return c;
++}
++#endif
++
++
+ LUALIB_API int luaL_getmetafield (lua_State *L, int obj, const char *event) {
+ if (!lua_getmetatable(L, obj)) /* no metatable? */
+ return 0;
+--- a/src/lauxlib.h
++++ b/src/lauxlib.h
+@@ -57,6 +57,12 @@ LUALIB_API lua_Number (luaL_optnumber) (
+ LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int numArg);
+ LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int nArg,
+ lua_Integer def);
++#define luaL_checkint32(L,narg) ((int)luaL_checkinteger(L,narg))
++#define luaL_optint32(L,narg,def) ((int)luaL_optinteger(L,narg,def))
++
++#ifdef LNUM_COMPLEX
++ LUALIB_API lua_Complex (luaL_checkcomplex) (lua_State *L, int narg);
++#endif
+
+ LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg);
+ LUALIB_API void (luaL_checktype) (lua_State *L, int narg, int t);
+--- a/src/lbaselib.c
++++ b/src/lbaselib.c
+@@ -18,7 +18,9 @@
+
+ #include "lauxlib.h"
+ #include "lualib.h"
+-
++#include "llimits.h"
++#include "lobject.h"
++#include "lapi.h"
+
+
+
+@@ -54,20 +56,25 @@ static int luaB_tonumber (lua_State *L)
+ int base = luaL_optint(L, 2, 10);
+ if (base == 10) { /* standard conversion */
+ luaL_checkany(L, 1);
+- if (lua_isnumber(L, 1)) {
+- lua_pushnumber(L, lua_tonumber(L, 1));
++ if (lua_isnumber(L, 1)) { /* numeric string, or a number */
++ lua_pushvalue_as_number(L,1); /* API extension (not to lose accuracy here) */
+ return 1;
+- }
++ }
+ }
+ else {
+ const char *s1 = luaL_checkstring(L, 1);
+ char *s2;
+- unsigned long n;
++ unsigned LUA_INTEGER n;
+ luaL_argcheck(L, 2 <= base && base <= 36, 2, "base out of range");
+- n = strtoul(s1, &s2, base);
++ n = lua_str2ul(s1, &s2, base);
+ if (s1 != s2) { /* at least one valid digit? */
+ while (isspace((unsigned char)(*s2))) s2++; /* skip trailing spaces */
+ if (*s2 == '\0') { /* no invalid trailing characters? */
++
++ /* Push as number, there needs to be separate 'luaB_tointeger' for
++ * when the caller wants to preserve the bits (matters if unsigned
++ * values are used).
++ */
+ lua_pushnumber(L, (lua_Number)n);
+ return 1;
+ }
+@@ -144,7 +151,7 @@ static int luaB_setfenv (lua_State *L) {
+ luaL_checktype(L, 2, LUA_TTABLE);
+ getfunc(L, 0);
+ lua_pushvalue(L, 2);
+- if (lua_isnumber(L, 1) && lua_tonumber(L, 1) == 0) {
++ if (lua_isnumber(L, 1) && lua_tointeger(L, 1) == 0) {
+ /* change environment of current thread */
+ lua_pushthread(L);
+ lua_insert(L, -2);
+@@ -209,7 +216,7 @@ static int luaB_collectgarbage (lua_Stat
+ return 1;
+ }
+ default: {
+- lua_pushnumber(L, res);
++ lua_pushinteger(L, res);
+ return 1;
+ }
+ }
+@@ -631,6 +638,8 @@ static void base_open (lua_State *L) {
+ luaL_register(L, "_G", base_funcs);
+ lua_pushliteral(L, LUA_VERSION);
+ lua_setglobal(L, "_VERSION"); /* set global _VERSION */
++ lua_pushliteral(L, LUA_LNUM);
++ lua_setglobal(L, "_LNUM"); /* "[complex] double|float|ldouble int32|int64" */
+ /* `ipairs' and `pairs' need auxiliary functions as upvalues */
+ auxopen(L, "ipairs", luaB_ipairs, ipairsaux);
+ auxopen(L, "pairs", luaB_pairs, luaB_next);
+--- a/src/lcode.c
++++ b/src/lcode.c
+@@ -22,13 +22,18 @@
+ #include "lopcodes.h"
+ #include "lparser.h"
+ #include "ltable.h"
++#include "lnum.h"
+
+
+ #define hasjumps(e) ((e)->t != (e)->f)
+
+-
+ static int isnumeral(expdesc *e) {
+- return (e->k == VKNUM && e->t == NO_JUMP && e->f == NO_JUMP);
++ int ek=
++#ifdef LNUM_COMPLEX
++ (e->k == VKNUM2) ||
++#endif
++ (e->k == VKINT) || (e->k == VKNUM);
++ return (ek && e->t == NO_JUMP && e->f == NO_JUMP);
+ }
+
+
+@@ -231,12 +236,16 @@ static int addk (FuncState *fs, TValue *
+ TValue *idx = luaH_set(L, fs->h, k);
+ Proto *f = fs->f;
+ int oldsize = f->sizek;
+- if (ttisnumber(idx)) {
+- lua_assert(luaO_rawequalObj(&fs->f->k[cast_int(nvalue(idx))], v));
+- return cast_int(nvalue(idx));
++ if (ttype(idx)==LUA_TNUMBER) {
++ luai_normalize(idx);
++ lua_assert( ttype(idx)==LUA_TINT ); /* had no fraction */
++ }
++ if (ttisint(idx)) {
++ lua_assert(luaO_rawequalObj(&fs->f->k[ivalue(idx)], v));
++ return cast_int(ivalue(idx));
+ }
+ else { /* constant not found; create a new entry */
+- setnvalue(idx, cast_num(fs->nk));
++ setivalue(idx, fs->nk);
+ luaM_growvector(L, f->k, fs->nk, f->sizek, TValue,
+ MAXARG_Bx, "constant table overflow");
+ while (oldsize < f->sizek) setnilvalue(&f->k[oldsize++]);
+@@ -261,6 +270,21 @@ int luaK_numberK (FuncState *fs, lua_Num
+ }
+
+
++int luaK_integerK (FuncState *fs, lua_Integer r) {
++ TValue o;
++ setivalue(&o, r);
++ return addk(fs, &o, &o);
++}
++
++
++#ifdef LNUM_COMPLEX
++static int luaK_imagK (FuncState *fs, lua_Number r) {
++ TValue o;
++ setnvalue_complex(&o, r*I);
++ return addk(fs, &o, &o);
++}
++#endif
++
+ static int boolK (FuncState *fs, int b) {
+ TValue o;
+ setbvalue(&o, b);
+@@ -359,6 +383,16 @@ static void discharge2reg (FuncState *fs
+ luaK_codeABx(fs, OP_LOADK, reg, luaK_numberK(fs, e->u.nval));
+ break;
+ }
++ case VKINT: {
++ luaK_codeABx(fs, OP_LOADK, reg, luaK_integerK(fs, e->u.ival));
++ break;
++ }
++#ifdef LNUM_COMPLEX
++ case VKNUM2: {
++ luaK_codeABx(fs, OP_LOADK, reg, luaK_imagK(fs, e->u.nval));
++ break;
++ }
++#endif
+ case VRELOCABLE: {
+ Instruction *pc = &getcode(fs, e);
+ SETARG_A(*pc, reg);
+@@ -444,6 +478,10 @@ void luaK_exp2val (FuncState *fs, expdes
+ int luaK_exp2RK (FuncState *fs, expdesc *e) {
+ luaK_exp2val(fs, e);
+ switch (e->k) {
++#ifdef LNUM_COMPLEX
++ case VKNUM2:
++#endif
++ case VKINT:
+ case VKNUM:
+ case VTRUE:
+ case VFALSE:
+@@ -451,6 +489,10 @@ int luaK_exp2RK (FuncState *fs, expdesc
+ if (fs->nk <= MAXINDEXRK) { /* constant fit in RK operand? */
+ e->u.s.info = (e->k == VNIL) ? nilK(fs) :
+ (e->k == VKNUM) ? luaK_numberK(fs, e->u.nval) :
++ (e->k == VKINT) ? luaK_integerK(fs, e->u.ival) :
++#ifdef LNUM_COMPLEX
++ (e->k == VKNUM2) ? luaK_imagK(fs, e->u.nval) :
++#endif
+ boolK(fs, (e->k == VTRUE));
+ e->k = VK;
+ return RKASK(e->u.s.info);
+@@ -540,7 +582,10 @@ void luaK_goiftrue (FuncState *fs, expde
+ int pc; /* pc of last jump */
+ luaK_dischargevars(fs, e);
+ switch (e->k) {
+- case VK: case VKNUM: case VTRUE: {
++#ifdef LNUM_COMPLEX
++ case VKNUM2:
++#endif
++ case VKINT: case VK: case VKNUM: case VTRUE: {
+ pc = NO_JUMP; /* always true; do nothing */
+ break;
+ }
+@@ -590,7 +635,10 @@ static void codenot (FuncState *fs, expd
+ e->k = VTRUE;
+ break;
+ }
+- case VK: case VKNUM: case VTRUE: {
++#ifdef LNUM_COMPLEX
++ case VKNUM2:
++#endif
++ case VKINT: case VK: case VKNUM: case VTRUE: {
+ e->k = VFALSE;
+ break;
+ }
+@@ -626,25 +674,70 @@ void luaK_indexed (FuncState *fs, expdes
+
+ static int constfolding (OpCode op, expdesc *e1, expdesc *e2) {
+ lua_Number v1, v2, r;
++ int vkres= VKNUM;
+ if (!isnumeral(e1) || !isnumeral(e2)) return 0;
+- v1 = e1->u.nval;
+- v2 = e2->u.nval;
++
++ /* real and imaginary parts don't mix. */
++#ifdef LNUM_COMPLEX
++ if (e1->k == VKNUM2) {
++ if ((op != OP_UNM) && (e2->k != VKNUM2)) return 0;
++ vkres= VKNUM2; }
++ else if (e2->k == VKNUM2) { return 0; }
++#endif
++ if ((e1->k == VKINT) && (e2->k == VKINT)) {
++ lua_Integer i1= e1->u.ival, i2= e2->u.ival;
++ lua_Integer rr;
++ int done= 0;
++ /* Integer/integer calculations (may end up producing floating point) */
++ switch (op) {
++ case OP_ADD: done= try_addint( &rr, i1, i2 ); break;
++ case OP_SUB: done= try_subint( &rr, i1, i2 ); break;
++ case OP_MUL: done= try_mulint( &rr, i1, i2 ); break;
++ case OP_DIV: done= try_divint( &rr, i1, i2 ); break;
++ case OP_MOD: done= try_modint( &rr, i1, i2 ); break;
++ case OP_POW: done= try_powint( &rr, i1, i2 ); break;
++ case OP_UNM: done= try_unmint( &rr, i1 ); break;
++ default: done= 0; break;
++ }
++ if (done) {
++ e1->u.ival = rr; /* remained within integer range */
++ return 1;
++ }
++ }
++ v1 = (e1->k == VKINT) ? ((lua_Number)e1->u.ival) : e1->u.nval;
++ v2 = (e2->k == VKINT) ? ((lua_Number)e2->u.ival) : e2->u.nval;
++
+ switch (op) {
+ case OP_ADD: r = luai_numadd(v1, v2); break;
+ case OP_SUB: r = luai_numsub(v1, v2); break;
+- case OP_MUL: r = luai_nummul(v1, v2); break;
++ case OP_MUL:
++#ifdef LNUM_COMPLEX
++ if (vkres==VKNUM2) return 0; /* leave to runtime (could do here, but not worth it?) */
++#endif
++ r = luai_nummul(v1, v2); break;
+ case OP_DIV:
+ if (v2 == 0) return 0; /* do not attempt to divide by 0 */
+- r = luai_numdiv(v1, v2); break;
++#ifdef LNUM_COMPLEX
++ if (vkres==VKNUM2) return 0; /* leave to runtime */
++#endif
++ r = luai_numdiv(v1, v2); break;
+ case OP_MOD:
+ if (v2 == 0) return 0; /* do not attempt to divide by 0 */
++#ifdef LNUM_COMPLEX
++ if (vkres==VKNUM2) return 0; /* leave to runtime */
++#endif
+ r = luai_nummod(v1, v2); break;
+- case OP_POW: r = luai_numpow(v1, v2); break;
++ case OP_POW:
++#ifdef LNUM_COMPLEX
++ if (vkres==VKNUM2) return 0; /* leave to runtime */
++#endif
++ r = luai_numpow(v1, v2); break;
+ case OP_UNM: r = luai_numunm(v1); break;
+ case OP_LEN: return 0; /* no constant folding for 'len' */
+ default: lua_assert(0); r = 0; break;
+ }
+ if (luai_numisnan(r)) return 0; /* do not attempt to produce NaN */
++ e1->k = cast(expkind,vkres);
+ e1->u.nval = r;
+ return 1;
+ }
+@@ -688,7 +781,8 @@ static void codecomp (FuncState *fs, OpC
+
+ void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e) {
+ expdesc e2;
+- e2.t = e2.f = NO_JUMP; e2.k = VKNUM; e2.u.nval = 0;
++ e2.t = e2.f = NO_JUMP; e2.k = VKINT; e2.u.ival = 0;
++
+ switch (op) {
+ case OPR_MINUS: {
+ if (!isnumeral(e))
+--- a/src/lcode.h
++++ b/src/lcode.h
+@@ -71,6 +71,6 @@ LUAI_FUNC void luaK_prefix (FuncState *f
+ LUAI_FUNC void luaK_infix (FuncState *fs, BinOpr op, expdesc *v);
+ LUAI_FUNC void luaK_posfix (FuncState *fs, BinOpr op, expdesc *v1, expdesc *v2);
+ LUAI_FUNC void luaK_setlist (FuncState *fs, int base, int nelems, int tostore);
+-
++LUAI_FUNC int luaK_integerK (FuncState *fs, lua_Integer r);
+
+ #endif
+--- a/src/ldebug.c
++++ b/src/ldebug.c
+@@ -183,7 +183,7 @@ static void collectvalidlines (lua_State
+ int *lineinfo = f->l.p->lineinfo;
+ int i;
+ for (i=0; i<f->l.p->sizelineinfo; i++)
+- setbvalue(luaH_setnum(L, t, lineinfo[i]), 1);
++ setbvalue(luaH_setint(L, t, lineinfo[i]), 1);
+ sethvalue(L, L->top, t);
+ }
+ incr_top(L);
+@@ -566,7 +566,7 @@ static int isinstack (CallInfo *ci, cons
+
+ void luaG_typeerror (lua_State *L, const TValue *o, const char *op) {
+ const char *name = NULL;
+- const char *t = luaT_typenames[ttype(o)];
++ const char *t = luaT_typenames[ttype_ext(o)];
+ const char *kind = (isinstack(L->ci, o)) ?
+ getobjname(L, L->ci, cast_int(o - L->base), &name) :
+ NULL;
+@@ -594,8 +594,8 @@ void luaG_aritherror (lua_State *L, cons
+
+
+ int luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2) {
+- const char *t1 = luaT_typenames[ttype(p1)];
+- const char *t2 = luaT_typenames[ttype(p2)];
++ const char *t1 = luaT_typenames[ttype_ext(p1)];
++ const char *t2 = luaT_typenames[ttype_ext(p2)];
+ if (t1[2] == t2[2])
+ luaG_runerror(L, "attempt to compare two %s values", t1);
+ else
+--- a/src/ldo.c
++++ b/src/ldo.c
+@@ -220,9 +220,9 @@ static StkId adjust_varargs (lua_State *
+ luaD_checkstack(L, p->maxstacksize);
+ htab = luaH_new(L, nvar, 1); /* create `arg' table */
+ for (i=0; i<nvar; i++) /* put extra arguments into `arg' table */
+- setobj2n(L, luaH_setnum(L, htab, i+1), L->top - nvar + i);
++ setobj2n(L, luaH_setint(L, htab, i+1), L->top - nvar + i);
+ /* store counter in field `n' */
+- setnvalue(luaH_setstr(L, htab, luaS_newliteral(L, "n")), cast_num(nvar));
++ setivalue(luaH_setstr(L, htab, luaS_newliteral(L, "n")), nvar);
+ }
+ #endif
+ /* move fixed parameters to final position */
+--- a/src/ldump.c
++++ b/src/ldump.c
+@@ -52,6 +52,11 @@ static void DumpNumber(lua_Number x, Dum
+ DumpVar(x,D);
+ }
+
++static void DumpInteger(lua_Integer x, DumpState* D)
++{
++ DumpVar(x,D);
++}
++
+ static void DumpVector(const void* b, int n, size_t size, DumpState* D)
+ {
+ DumpInt(n,D);
+@@ -93,8 +98,11 @@ static void DumpConstants(const Proto* f
+ DumpChar(bvalue(o),D);
+ break;
+ case LUA_TNUMBER:
+- DumpNumber(nvalue(o),D);
++ DumpNumber(nvalue_fast(o),D);
+ break;
++ case LUA_TINT:
++ DumpInteger(ivalue(o),D);
++ break;
+ case LUA_TSTRING:
+ DumpString(rawtsvalue(o),D);
+ break;
+--- a/src/liolib.c
++++ b/src/liolib.c
+@@ -9,6 +9,7 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
++#include <ctype.h>
+
+ #define liolib_c
+ #define LUA_LIB
+@@ -18,7 +19,8 @@
+ #include "lauxlib.h"
+ #include "lualib.h"
+
+-
++#include "lnum.h"
++#include "llex.h"
+
+ #define IO_INPUT 1
+ #define IO_OUTPUT 2
+@@ -269,6 +271,13 @@ static int io_lines (lua_State *L) {
+ ** =======================================================
+ */
+
++/*
++* Many problems if we intend the same 'n' format specifier (see 'file:read()')
++* to work for both FP and integer numbers, without losing their accuracy. So
++* we don't. 'n' reads numbers as floating points, 'i' as integers. Old code
++* remains valid, but won't provide full integer accuracy (this only matters
++* with float FP and/or 64-bit integers).
++*/
+
+ static int read_number (lua_State *L, FILE *f) {
+ lua_Number d;
+@@ -282,6 +291,43 @@ static int read_number (lua_State *L, FI
+ }
+ }
+
++static int read_integer (lua_State *L, FILE *f) {
++ lua_Integer i;
++ if (fscanf(f, LUA_INTEGER_SCAN, &i) == 1) {
++ lua_pushinteger(L, i);
++ return 1;
++ }
++ else return 0; /* read fails */
++}
++
++#ifdef LNUM_COMPLEX
++static int read_complex (lua_State *L, FILE *f) {
++ /* NNN / NNNi / NNN+MMMi / NNN-MMMi */
++ lua_Number a,b;
++ if (fscanf(f, LUA_NUMBER_SCAN, &a) == 1) {
++ int c=fgetc(f);
++ switch(c) {
++ case 'i':
++ lua_pushcomplex(L, a*I);
++ return 1;
++ case '+':
++ case '-':
++ /* "i" is consumed if at the end; just 'NNN+MMM' will most likely
++ * behave as if "i" was there? (TBD: test)
++ */
++ if (fscanf(f, LUA_NUMBER_SCAN "i", &b) == 1) {
++ lua_pushcomplex(L, a+ (c=='+' ? b:-b)*I);
++ return 1;
++ }
++ }
++ ungetc( c,f );
++ lua_pushnumber(L,a); /*real part only*/
++ return 1;
++ }
++ return 0; /* read fails */
++}
++#endif
++
+
+ static int test_eof (lua_State *L, FILE *f) {
+ int c = getc(f);
+@@ -355,6 +401,14 @@ static int g_read (lua_State *L, FILE *f
+ case 'n': /* number */
+ success = read_number(L, f);
+ break;
++ case 'i': /* integer (full accuracy) */
++ success = read_integer(L, f);
++ break;
++#ifdef LNUM_COMPLEX
++ case 'c': /* complex */
++ success = read_complex(L, f);
++ break;
++#endif
+ case 'l': /* line */
+ success = read_line(L, f);
+ break;
+@@ -415,9 +469,10 @@ static int g_write (lua_State *L, FILE *
+ int status = 1;
+ for (; nargs--; arg++) {
+ if (lua_type(L, arg) == LUA_TNUMBER) {
+- /* optimization: could be done exactly as for strings */
+- status = status &&
+- fprintf(f, LUA_NUMBER_FMT, lua_tonumber(L, arg)) > 0;
++ if (lua_isinteger(L,arg))
++ status = status && fprintf(f, LUA_INTEGER_FMT, lua_tointeger(L, arg)) > 0;
++ else
++ status = status && fprintf(f, LUA_NUMBER_FMT, lua_tonumber(L, arg)) > 0;
+ }
+ else {
+ size_t l;
+@@ -460,7 +515,7 @@ static int f_setvbuf (lua_State *L) {
+ static const char *const modenames[] = {"no", "full", "line", NULL};
+ FILE *f = tofile(L);
+ int op = luaL_checkoption(L, 2, NULL, modenames);
+- lua_Integer sz = luaL_optinteger(L, 3, LUAL_BUFFERSIZE);
++ size_t sz = luaL_optint32(L, 3, LUAL_BUFFERSIZE);
+ int res = setvbuf(f, NULL, mode[op], sz);
+ return pushresult(L, res == 0, NULL);
+ }
+--- a/src/llex.c
++++ b/src/llex.c
+@@ -22,6 +22,7 @@
+ #include "lstring.h"
+ #include "ltable.h"
+ #include "lzio.h"
++#include "lnum.h"
+
+
+
+@@ -34,13 +35,17 @@
+
+
+ /* ORDER RESERVED */
+-const char *const luaX_tokens [] = {
++static const char *const luaX_tokens [] = {
+ "and", "break", "do", "else", "elseif",
+ "end", "false", "for", "function", "if",
+ "in", "local", "nil", "not", "or", "repeat",
+ "return", "then", "true", "until", "while",
+ "..", "...", "==", ">=", "<=", "~=",
+ "<number>", "<name>", "<string>", "<eof>",
++ "<integer>",
++#ifdef LNUM_COMPLEX
++ "<number2>",
++#endif
+ NULL
+ };
+
+@@ -90,7 +95,11 @@ static const char *txtToken (LexState *l
+ switch (token) {
+ case TK_NAME:
+ case TK_STRING:
++ case TK_INT:
+ case TK_NUMBER:
++#ifdef LNUM_COMPLEX
++ case TK_NUMBER2:
++#endif
+ save(ls, '\0');
+ return luaZ_buffer(ls->buff);
+ default:
+@@ -175,23 +184,27 @@ static void buffreplace (LexState *ls, c
+ if (p[n] == from) p[n] = to;
+ }
+
+-
+-static void trydecpoint (LexState *ls, SemInfo *seminfo) {
++/* TK_NUMBER (/ TK_NUMBER2) */
++static int trydecpoint (LexState *ls, SemInfo *seminfo) {
+ /* format error: try to update decimal point separator */
+ struct lconv *cv = localeconv();
+ char old = ls->decpoint;
++ int ret;
+ ls->decpoint = (cv ? cv->decimal_point[0] : '.');
+ buffreplace(ls, old, ls->decpoint); /* try updated decimal separator */
+- if (!luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r)) {
++ ret= luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r, NULL);
++ if (!ret) {
+ /* format error with correct decimal point: no more options */
+ buffreplace(ls, ls->decpoint, '.'); /* undo change (for error message) */
+ luaX_lexerror(ls, "malformed number", TK_NUMBER);
+ }
++ return ret;
+ }
+
+
+-/* LUA_NUMBER */
+-static void read_numeral (LexState *ls, SemInfo *seminfo) {
++/* TK_NUMBER / TK_INT (/TK_NUMBER2) */
++static int read_numeral (LexState *ls, SemInfo *seminfo) {
++ int ret;
+ lua_assert(isdigit(ls->current));
+ do {
+ save_and_next(ls);
+@@ -202,8 +215,9 @@ static void read_numeral (LexState *ls,
+ save_and_next(ls);
+ save(ls, '\0');
+ buffreplace(ls, '.', ls->decpoint); /* follow locale for decimal point */
+- if (!luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r)) /* format error? */
+- trydecpoint(ls, seminfo); /* try to update decimal point separator */
++ ret= luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r, &seminfo->i );
++ if (!ret) return trydecpoint(ls, seminfo); /* try to update decimal point separator */
++ return ret;
+ }
+
+
+@@ -331,6 +345,7 @@ static void read_string (LexState *ls, i
+ }
+
+
++/* char / TK_* */
+ static int llex (LexState *ls, SemInfo *seminfo) {
+ luaZ_resetbuffer(ls->buff);
+ for (;;) {
+@@ -402,8 +417,7 @@ static int llex (LexState *ls, SemInfo *
+ }
+ else if (!isdigit(ls->current)) return '.';
+ else {
+- read_numeral(ls, seminfo);
+- return TK_NUMBER;
++ return read_numeral(ls, seminfo);
+ }
+ }
+ case EOZ: {
+@@ -416,8 +430,7 @@ static int llex (LexState *ls, SemInfo *
+ continue;
+ }
+ else if (isdigit(ls->current)) {
+- read_numeral(ls, seminfo);
+- return TK_NUMBER;
++ return read_numeral(ls, seminfo);
+ }
+ else if (isalpha(ls->current) || ls->current == '_') {
+ /* identifier or reserved word */
+--- a/src/llex.h
++++ b/src/llex.h
+@@ -29,19 +29,22 @@ enum RESERVED {
+ TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE,
+ /* other terminal symbols */
+ TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, TK_NUMBER,
+- TK_NAME, TK_STRING, TK_EOS
++ TK_NAME, TK_STRING, TK_EOS, TK_INT
++#ifdef LNUM_COMPLEX
++ , TK_NUMBER2 /* imaginary constants: Ni */
++#endif
+ };
+
+ /* number of reserved words */
+ #define NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1))
+
+
+-/* array with token `names' */
+-LUAI_DATA const char *const luaX_tokens [];
+-
+-
++/* SemInfo is a local data structure of 'llex.c', used for carrying a string
++ * or a number. A separate token (TK_*) will tell, how to interpret the data.
++ */
+ typedef union {
+ lua_Number r;
++ lua_Integer i;
+ TString *ts;
+ } SemInfo; /* semantics information */
+
+--- a/src/llimits.h
++++ b/src/llimits.h
+@@ -49,6 +49,7 @@ typedef LUAI_USER_ALIGNMENT_T L_Umaxalig
+
+ /* result of a `usual argument conversion' over lua_Number */
+ typedef LUAI_UACNUMBER l_uacNumber;
++typedef LUAI_UACINTEGER l_uacInteger;
+
+
+ /* internal assertions for in-house debugging */
+@@ -80,7 +81,6 @@ typedef LUAI_UACNUMBER l_uacNumber;
+ #define cast_int(i) cast(int, (i))
+
+
+-
+ /*
+ ** type for virtual-machine instructions
+ ** must be an unsigned with (at least) 4 bytes (see details in lopcodes.h)
+--- a/src/lmathlib.c
++++ b/src/lmathlib.c
+@@ -4,7 +4,6 @@
+ ** See Copyright Notice in lua.h
+ */
+
+-
+ #include <stdlib.h>
+ #include <math.h>
+
+@@ -16,113 +15,210 @@
+ #include "lauxlib.h"
+ #include "lualib.h"
+
++/* 'luai_vectpow()' as a replacement for 'cpow()'. Defined in the header; we
++ * don't intrude the code libs internal functions.
++ */
++#ifdef LNUM_COMPLEX
++# include "lnum.h"
++#endif
+
+ #undef PI
+-#define PI (3.14159265358979323846)
+-#define RADIANS_PER_DEGREE (PI/180.0)
+-
++#ifdef LNUM_FLOAT
++# define PI (3.14159265358979323846F)
++#elif defined(M_PI)
++# define PI M_PI
++#else
++# define PI (3.14159265358979323846264338327950288)
++#endif
++#define RADIANS_PER_DEGREE (PI/180)
+
++#undef HUGE
++#ifdef LNUM_FLOAT
++# define HUGE HUGE_VALF
++#elif defined(LNUM_LDOUBLE)
++# define HUGE HUGE_VALL
++#else
++# define HUGE HUGE_VAL
++#endif
+
+ static int math_abs (lua_State *L) {
+- lua_pushnumber(L, fabs(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_pushnumber(L, _LF(cabs) (luaL_checkcomplex(L,1)));
++#else
++ lua_pushnumber(L, _LF(fabs) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+ static int math_sin (lua_State *L) {
+- lua_pushnumber(L, sin(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(csin) (luaL_checkcomplex(L,1)));
++#else
++ lua_pushnumber(L, _LF(sin) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+ static int math_sinh (lua_State *L) {
+- lua_pushnumber(L, sinh(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(csinh) (luaL_checkcomplex(L,1)));
++#else
++ lua_pushnumber(L, _LF(sinh) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+ static int math_cos (lua_State *L) {
+- lua_pushnumber(L, cos(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(ccos) (luaL_checkcomplex(L,1)));
++#else
++ lua_pushnumber(L, _LF(cos) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+ static int math_cosh (lua_State *L) {
+- lua_pushnumber(L, cosh(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(ccosh) (luaL_checkcomplex(L,1)));
++#else
++ lua_pushnumber(L, _LF(cosh) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+ static int math_tan (lua_State *L) {
+- lua_pushnumber(L, tan(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(ctan) (luaL_checkcomplex(L,1)));
++#else
++ lua_pushnumber(L, _LF(tan) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+ static int math_tanh (lua_State *L) {
+- lua_pushnumber(L, tanh(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(ctanh) (luaL_checkcomplex(L,1)));
++#else
++ lua_pushnumber(L, _LF(tanh) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+ static int math_asin (lua_State *L) {
+- lua_pushnumber(L, asin(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(casin) (luaL_checkcomplex(L,1)));
++#else
++ lua_pushnumber(L, _LF(asin) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+ static int math_acos (lua_State *L) {
+- lua_pushnumber(L, acos(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(cacos) (luaL_checkcomplex(L,1)));
++#else
++ lua_pushnumber(L, _LF(acos) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+ static int math_atan (lua_State *L) {
+- lua_pushnumber(L, atan(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(catan) (luaL_checkcomplex(L,1)));
++#else
++ lua_pushnumber(L, _LF(atan) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+ static int math_atan2 (lua_State *L) {
+- lua_pushnumber(L, atan2(luaL_checknumber(L, 1), luaL_checknumber(L, 2)));
++ /* scalars only */
++ lua_pushnumber(L, _LF(atan2) (luaL_checknumber(L, 1), luaL_checknumber(L, 2)));
+ return 1;
+ }
+
+ static int math_ceil (lua_State *L) {
+- lua_pushnumber(L, ceil(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_Complex v= luaL_checkcomplex(L, 1);
++ lua_pushcomplex(L, _LF(ceil) (_LF(creal)(v)) + _LF(ceil) (_LF(cimag)(v))*I);
++#else
++ lua_pushnumber(L, _LF(ceil) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+ static int math_floor (lua_State *L) {
+- lua_pushnumber(L, floor(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_Complex v= luaL_checkcomplex(L, 1);
++ lua_pushcomplex(L, _LF(floor) (_LF(creal)(v)) + _LF(floor) (_LF(cimag)(v))*I);
++#else
++ lua_pushnumber(L, _LF(floor) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+-static int math_fmod (lua_State *L) {
+- lua_pushnumber(L, fmod(luaL_checknumber(L, 1), luaL_checknumber(L, 2)));
++static int math_fmod (lua_State *L) {
++ /* scalars only */
++ lua_pushnumber(L, _LF(fmod) (luaL_checknumber(L, 1), luaL_checknumber(L, 2)));
+ return 1;
+ }
+
+ static int math_modf (lua_State *L) {
+- double ip;
+- double fp = modf(luaL_checknumber(L, 1), &ip);
++ /* scalars only */
++ lua_Number ip;
++ lua_Number fp = _LF(modf) (luaL_checknumber(L, 1), &ip);
+ lua_pushnumber(L, ip);
+ lua_pushnumber(L, fp);
+ return 2;
+ }
+
+ static int math_sqrt (lua_State *L) {
+- lua_pushnumber(L, sqrt(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(csqrt) (luaL_checkcomplex(L,1)));
++#else
++ lua_pushnumber(L, _LF(sqrt) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+ static int math_pow (lua_State *L) {
+- lua_pushnumber(L, pow(luaL_checknumber(L, 1), luaL_checknumber(L, 2)));
++#ifdef LNUM_COMPLEX
++ /* C99 'cpow' gives somewhat inaccurate results (i.e. (-1)^2 = -1+1.2246467991474e-16i).
++ * 'luai_vectpow' smoothens such, reusing it is the reason we need to #include "lnum.h".
++ */
++ lua_pushcomplex(L, luai_vectpow(luaL_checkcomplex(L,1), luaL_checkcomplex(L,2)));
++#else
++ lua_pushnumber(L, _LF(pow) (luaL_checknumber(L, 1), luaL_checknumber(L, 2)));
++#endif
+ return 1;
+ }
+
+ static int math_log (lua_State *L) {
+- lua_pushnumber(L, log(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(clog) (luaL_checkcomplex(L,1)));
++#else
++ lua_pushnumber(L, _LF(log) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+ static int math_log10 (lua_State *L) {
+- lua_pushnumber(L, log10(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ /* Not in standard <complex.h> , but easy to calculate: log_a(x) = log_b(x) / log_b(a)
++ */
++ lua_pushcomplex(L, _LF(clog) (luaL_checkcomplex(L,1)) / _LF(log) (10));
++#else
++ lua_pushnumber(L, _LF(log10) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+ static int math_exp (lua_State *L) {
+- lua_pushnumber(L, exp(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(cexp) (luaL_checkcomplex(L,1)));
++#else
++ lua_pushnumber(L, _LF(exp) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+@@ -138,19 +234,20 @@ static int math_rad (lua_State *L) {
+
+ static int math_frexp (lua_State *L) {
+ int e;
+- lua_pushnumber(L, frexp(luaL_checknumber(L, 1), &e));
++ lua_pushnumber(L, _LF(frexp) (luaL_checknumber(L, 1), &e));
+ lua_pushinteger(L, e);
+ return 2;
+ }
+
+ static int math_ldexp (lua_State *L) {
+- lua_pushnumber(L, ldexp(luaL_checknumber(L, 1), luaL_checkint(L, 2)));
++ lua_pushnumber(L, _LF(ldexp) (luaL_checknumber(L, 1), luaL_checkint(L, 2)));
+ return 1;
+ }
+
+
+
+ static int math_min (lua_State *L) {
++ /* scalars only */
+ int n = lua_gettop(L); /* number of arguments */
+ lua_Number dmin = luaL_checknumber(L, 1);
+ int i;
+@@ -165,6 +262,7 @@ static int math_min (lua_State *L) {
+
+
+ static int math_max (lua_State *L) {
++ /* scalars only */
+ int n = lua_gettop(L); /* number of arguments */
+ lua_Number dmax = luaL_checknumber(L, 1);
+ int i;
+@@ -182,25 +280,20 @@ static int math_random (lua_State *L) {
+ /* the `%' avoids the (rare) case of r==1, and is needed also because on
+ some systems (SunOS!) `rand()' may return a value larger than RAND_MAX */
+ lua_Number r = (lua_Number)(rand()%RAND_MAX) / (lua_Number)RAND_MAX;
+- switch (lua_gettop(L)) { /* check number of arguments */
+- case 0: { /* no arguments */
+- lua_pushnumber(L, r); /* Number between 0 and 1 */
+- break;
+- }
+- case 1: { /* only upper limit */
+- int u = luaL_checkint(L, 1);
+- luaL_argcheck(L, 1<=u, 1, "interval is empty");
+- lua_pushnumber(L, floor(r*u)+1); /* int between 1 and `u' */
+- break;
+- }
+- case 2: { /* lower and upper limits */
+- int l = luaL_checkint(L, 1);
+- int u = luaL_checkint(L, 2);
+- luaL_argcheck(L, l<=u, 2, "interval is empty");
+- lua_pushnumber(L, floor(r*(u-l+1))+l); /* int between `l' and `u' */
+- break;
+- }
+- default: return luaL_error(L, "wrong number of arguments");
++ int n= lua_gettop(L); /* number of arguments */
++ if (n==0) { /* no arguments: range [0,1) */
++ lua_pushnumber(L, r);
++ } else if (n<=2) { /* int range [1,u] or [l,u] */
++ int l= n==1 ? 1 : luaL_checkint(L, 1);
++ int u = luaL_checkint(L, n);
++ int tmp;
++ lua_Number d;
++ luaL_argcheck(L, l<=u, n, "interval is empty");
++ d= _LF(floor)(r*(u-l+1));
++ lua_number2int(tmp,d);
++ lua_pushinteger(L, l+tmp);
++ } else {
++ return luaL_error(L, "wrong number of arguments");
+ }
+ return 1;
+ }
+@@ -211,6 +304,66 @@ static int math_randomseed (lua_State *L
+ return 0;
+ }
+
++/*
++* Lua 5.1 does not have acosh, asinh, atanh for scalars (not ANSI C)
++*/
++#if __STDC_VERSION__ >= 199901L
++static int math_acosh (lua_State *L) {
++# ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(cacosh) (luaL_checkcomplex(L,1)));
++# else
++ lua_pushnumber(L, _LF(acosh) (luaL_checknumber(L,1)));
++# endif
++ return 1;
++}
++static int math_asinh (lua_State *L) {
++# ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(casinh) (luaL_checkcomplex(L,1)));
++# else
++ lua_pushnumber(L, _LF(asinh) (luaL_checknumber(L,1)));
++# endif
++ return 1;
++}
++static int math_atanh (lua_State *L) {
++# ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(catanh) (luaL_checkcomplex(L,1)));
++# else
++ lua_pushnumber(L, _LF(atanh) (luaL_checknumber(L,1)));
++# endif
++ return 1;
++}
++#endif
++
++/*
++ * C99 complex functions, not covered above.
++*/
++#ifdef LNUM_COMPLEX
++static int math_arg (lua_State *L) {
++ lua_pushnumber(L, _LF(carg) (luaL_checkcomplex(L,1)));
++ return 1;
++}
++
++static int math_imag (lua_State *L) {
++ lua_pushnumber(L, _LF(cimag) (luaL_checkcomplex(L,1)));
++ return 1;
++}
++
++static int math_real (lua_State *L) {
++ lua_pushnumber(L, _LF(creal) (luaL_checkcomplex(L,1)));
++ return 1;
++}
++
++static int math_conj (lua_State *L) {
++ lua_pushcomplex(L, _LF(conj) (luaL_checkcomplex(L,1)));
++ return 1;
++}
++
++static int math_proj (lua_State *L) {
++ lua_pushcomplex(L, _LF(cproj) (luaL_checkcomplex(L,1)));
++ return 1;
++}
++#endif
++
+
+ static const luaL_Reg mathlib[] = {
+ {"abs", math_abs},
+@@ -241,6 +394,18 @@ static const luaL_Reg mathlib[] = {
+ {"sqrt", math_sqrt},
+ {"tanh", math_tanh},
+ {"tan", math_tan},
++#if __STDC_VERSION__ >= 199901L
++ {"acosh", math_acosh},
++ {"asinh", math_asinh},
++ {"atanh", math_atanh},
++#endif
++#ifdef LNUM_COMPLEX
++ {"arg", math_arg},
++ {"imag", math_imag},
++ {"real", math_real},
++ {"conj", math_conj},
++ {"proj", math_proj},
++#endif
+ {NULL, NULL}
+ };
+
+@@ -252,8 +417,10 @@ LUALIB_API int luaopen_math (lua_State *
+ luaL_register(L, LUA_MATHLIBNAME, mathlib);
+ lua_pushnumber(L, PI);
+ lua_setfield(L, -2, "pi");
+- lua_pushnumber(L, HUGE_VAL);
++ lua_pushnumber(L, HUGE);
+ lua_setfield(L, -2, "huge");
++ lua_pushinteger(L, LUA_INTEGER_MAX );
++ lua_setfield(L, -2, "hugeint");
+ #if defined(LUA_COMPAT_MOD)
+ lua_getfield(L, -1, "fmod");
+ lua_setfield(L, -2, "mod");
+--- /dev/null
++++ b/src/lnum.c
+@@ -0,0 +1,312 @@
++/*
++** $Id: lnum.c,v ... $
++** Internal number model
++** See Copyright Notice in lua.h
++*/
++
++#include <stdlib.h>
++#include <math.h>
++#include <ctype.h>
++#include <string.h>
++#include <stdio.h>
++#include <errno.h>
++
++#define lnum_c
++#define LUA_CORE
++
++#include "lua.h"
++#include "llex.h"
++#include "lnum.h"
++
++/*
++** lua_real2str converts a (non-complex) number to a string.
++** lua_str2real converts a string to a (non-complex) number.
++*/
++#define lua_real2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n))
++
++/*
++* Note: Only 'strtod()' is part of ANSI C; others are C99 and
++* may need '--std=c99' compiler setting (at least on Ubuntu 7.10).
++*
++* Visual C++ 2008 Express does not have 'strtof()', nor 'strtold()'.
++* References to '_strtold()' exist but don't compile. It seems best
++* to leave Windows users with DOUBLE only (or compile with MinGW).
++*
++* In practise, using '(long double)strtod' is a risky thing, since
++* it will cause accuracy loss in reading in numbers, and such losses
++* will pile up in later processing. Get a real 'strtold()' or don't
++* use that mode at all.
++*/
++#ifdef LNUM_DOUBLE
++# define lua_str2real strtod
++#elif defined(LNUM_FLOAT)
++# define lua_str2real strtof
++#elif defined(LNUM_LDOUBLE)
++# define lua_str2real strtold
++#endif
++
++#define lua_integer2str(s,v) sprintf((s), LUA_INTEGER_FMT, (v))
++
++/* 's' is expected to be LUAI_MAXNUMBER2STR long (enough for any number)
++*/
++void luaO_num2buf( char *s, const TValue *o )
++{
++ lua_Number n;
++ lua_assert( ttisnumber(o) );
++
++ /* Reason to handle integers differently is not only speed, but accuracy as
++ * well. We want to make any integer tostring() without roundings, at all.
++ */
++ if (ttisint(o)) {
++ lua_integer2str( s, ivalue(o) );
++ return;
++ }
++ n= nvalue_fast(o);
++ lua_real2str(s, n);
++
++#ifdef LNUM_COMPLEX
++ lua_Number n2= nvalue_img_fast(o);
++ if (n2!=0) { /* Postfix with +-Ni */
++ int re0= (n == 0);
++ char *s2= re0 ? s : strchr(s,'\0');
++ if ((!re0) && (n2>0)) *s2++= '+';
++ lua_real2str( s2, n2 );
++ strcat(s2,"i");
++ }
++#endif
++}
++
++/*
++* If a LUA_TNUMBER has integer value, give it.
++*/
++int /*bool*/ tt_integer_valued( const TValue *o, lua_Integer *ref ) {
++ lua_Number d;
++ lua_Integer i;
++
++ lua_assert( ttype(o)==LUA_TNUMBER );
++ lua_assert( ref );
++#ifdef LNUM_COMPLEX
++ if (nvalue_img_fast(o)!=0) return 0;
++#endif
++ d= nvalue_fast(o);
++ lua_number2integer(i, d);
++ if (cast_num(i) == d) {
++ *ref= i; return 1;
++ }
++ return 0;
++}
++
++/*
++ * Lua 5.1.3 (using 'strtod()') allows 0x+hex but not 0+octal. This is good,
++ * and we should NOT use 'autobase' 0 with 'strtoul[l]()' for this reason.
++ *
++ * Lua 5.1.3 allows '0x...' numbers to overflow and lose precision; this is not
++ * good. On Visual C++ 2008, 'strtod()' does not even take them in. Better to
++ * require hex values to fit 'lua_Integer' or give an error that they don't?
++ *
++ * Full hex range (0 .. 0xff..ff) is stored as integers, not to lose any bits.
++ * Numerical value of 0xff..ff will be -1, if used in calculations.
++ *
++ * Returns: TK_INT for a valid integer, '*endptr_ref' updated
++ * TK_NUMBER for seemingly numeric, to be parsed as floating point
++ * 0 for bad characters, not a number (or '0x' out of range)
++ */
++static int luaO_str2i (const char *s, lua_Integer *res, char **endptr_ref) {
++ char *endptr;
++ /* 'v' gets ULONG_MAX on possible overflow (which is > LUA_INTEGER_MAX);
++ * we don't have to check 'errno' here.
++ */
++ unsigned LUA_INTEGER v= lua_str2ul(s, &endptr, 10);
++ if (endptr == s) return 0; /* nothing numeric */
++ if (v==0 && *endptr=='x') {
++ errno= 0; /* needs to be set, 'strtoul[l]' does not clear it */
++ v= lua_str2ul(endptr+1, &endptr, 16); /* retry as hex, unsigned range */
++ if (errno==ERANGE) { /* clamped to 0xff..ff */
++#if (defined(LNUM_INT32) && !defined(LNUM_FLOAT)) || defined(LNUM_LDOUBLE)
++ return TK_NUMBER; /* Allow to be read as floating point (has more integer range) */
++#else
++ return 0; /* Reject the number */
++#endif
++ }
++ } else if ((v > LUA_INTEGER_MAX) || (*endptr && (!isspace(*endptr)))) {
++ return TK_NUMBER; /* not in signed range, or has '.', 'e' etc. trailing */
++ }
++ *res= (lua_Integer)v;
++ *endptr_ref= endptr;
++ return TK_INT;
++}
++
++/* 0 / TK_NUMBER / TK_INT (/ TK_NUMBER2) */
++int luaO_str2d (const char *s, lua_Number *res_n, lua_Integer *res_i) {
++ char *endptr;
++ int ret= TK_NUMBER;
++ /* Check integers first, if caller is allowing.
++ * If 'res2'==NULL, they're only looking for floating point.
++ */
++ if (res_i) {
++ ret= luaO_str2i(s,res_i,&endptr);
++ if (ret==0) return 0;
++ }
++ if (ret==TK_NUMBER) {
++ lua_assert(res_n);
++ /* Note: Visual C++ 2008 Express 'strtod()' does not read in "0x..."
++ * numbers; it will read '0' and spit 'x' as endptr.
++ * This means hex constants not fitting in 'lua_Integer' won't
++ * be read in at all. What to do?
++ */
++ *res_n = lua_str2real(s, &endptr);
++ if (endptr == s) return 0; /* conversion failed */
++ /* Visual C++ 2008 'strtod()' does not allow "0x..." input. */
++#if defined(_MSC_VER) && !defined(LNUM_FLOAT) && !defined(LNUM_INT64)
++ if (*res_n==0 && *endptr=='x') {
++ /* Hex constant too big for 'lua_Integer' but that could fit in 'lua_Number'
++ * integer bits
++ */
++ unsigned __int64 v= _strtoui64( s, &endptr, 16 );
++ /* We just let > 64 bit values be clamped to _UI64_MAX (MSDN does not say 'errno'==ERANGE would be set) */
++ *res_n= cast_num(v);
++ if (*res_n != v) return 0; /* Would have lost accuracy */
++ }
++#endif
++#ifdef LNUM_COMPLEX
++ if (*endptr == 'i') { endptr++; ret= TK_NUMBER2; }
++#endif
++ }
++ if (*endptr) {
++ while (isspace(cast(unsigned char, *endptr))) endptr++;
++ if (*endptr) return 0; /* invalid trail */
++ }
++ return ret;
++}
++
++
++/* Functions for finding out, when integer operations remain in range
++ * (and doing them).
++ */
++int try_addint( lua_Integer *r, lua_Integer ib, lua_Integer ic ) {
++ lua_Integer v= ib+ic; /* may overflow */
++ if (ib>0 && ic>0) { if (v < 0) return 0; /*overflow, use floats*/ }
++ else if (ib<0 && ic<0) { if (v >= 0) return 0; }
++ *r= v;
++ return 1;
++}
++
++int try_subint( lua_Integer *r, lua_Integer ib, lua_Integer ic ) {
++ lua_Integer v= ib-ic; /* may overflow */
++ if (ib>=0 && ic<0) { if (v < 0) return 0; /*overflow, use floats*/ }
++ else if (ib<0 && ic>0) { if (v >= 0) return 0; }
++ *r= v;
++ return 1;
++}
++
++int try_mulint( lua_Integer *r, lua_Integer ib, lua_Integer ic ) {
++ if (ib!=LUA_INTEGER_MIN && ic!=LUA_INTEGER_MIN) {
++ lua_Integer b= luai_abs(ib), c= luai_abs(ic);
++ if ( (ib==0) || (LUA_INTEGER_MAX/b >= c) ) {
++ *r= ib*ic; /* no overflow */
++ return 1;
++ }
++ } else if (ib==0 || ic==0) {
++ *r= 0; return 1;
++ }
++
++ /* Result can be LUA_INTEGER_MIN; if it is, calculating it using floating
++ * point will not cause accuracy loss.
++ */
++ if ( luai_nummul( cast_num(ib), cast_num(ic) ) == LUA_INTEGER_MIN ) {
++ *r= LUA_INTEGER_MIN;
++ return 1;
++ }
++ return 0;
++}
++
++int try_divint( lua_Integer *r, lua_Integer ib, lua_Integer ic ) {
++ /* N/0: leave to float side, to give an error
++ */
++ if (ic==0) return 0;
++
++ /* N/LUA_INTEGER_MIN: always non-integer results, or 0 or +1
++ */
++ if (ic==LUA_INTEGER_MIN) {
++ if (ib==LUA_INTEGER_MIN) { *r=1; return 1; }
++ if (ib==0) { *r=0; return 1; }
++
++ /* LUA_INTEGER_MIN (-2^31|63)/N: calculate using float side (either the division
++ * causes non-integer results, or there is no accuracy loss in int->fp->int
++ * conversions (N=2,4,8,..,256 and N=2^30,2^29,..2^23).
++ */
++ } else if (ib==LUA_INTEGER_MIN) {
++ lua_Number d= luai_numdiv( cast_num(LUA_INTEGER_MIN), cast_num(ic) );
++ lua_Integer i; lua_number2integer(i,d);
++ if (cast_num(i)==d) { *r= i; return 1; }
++
++ } else {
++ /* Note: We _can_ use ANSI C mod here, even on negative values, since
++ * we only test for == 0 (the sign would be implementation dependent).
++ */
++ if (ib%ic == 0) { *r= ib/ic; return 1; }
++ }
++
++ return 0;
++}
++
++int try_modint( lua_Integer *r, lua_Integer ib, lua_Integer ic ) {
++ if (ic!=0) {
++ /* ANSI C can be trusted when b%c==0, or when values are non-negative.
++ * b - (floor(b/c) * c)
++ * -->
++ * + +: b - (b/c) * c (b % c can be used)
++ * - -: b - (b/c) * c (b % c could work, but not defined by ANSI C)
++ * 0 -: b - (b/c) * c (=0, b % c could work, but not defined by ANSI C)
++ * - +: b - (b/c-1) * c (when b!=-c)
++ * + -: b - (b/c-1) * c (when b!=-c)
++ *
++ * o MIN%MIN ends up 0, via overflow in calcs but that does not matter.
++ * o MIN%MAX ends up MAX-1 (and other such numbers), also after overflow,
++ * but that does not matter, results do.
++ */
++ lua_Integer v= ib % ic;
++ if ( v!=0 && (ib<0 || ic<0) ) {
++ v= ib - ((ib/ic) - ((ib<=0 && ic<0) ? 0:1)) * ic;
++ }
++ /* Result should always have same sign as 2nd argument. (PIL2) */
++ lua_assert( (v<0) ? (ic<0) : (v>0) ? (ic>0) : 1 );
++ *r= v;
++ return 1;
++ }
++ return 0; /* let float side return NaN */
++}
++
++int try_powint( lua_Integer *r, lua_Integer ib, lua_Integer ic ) {
++
++ /* In FLOAT/INT32 or FLOAT|DOUBLE/INT64 modes, calculating integer powers
++ * via FP realm may lose accuracy (i.e. 7^11 = 1977326743, which fits int32
++ * but not 23-bit float mantissa).
++ *
++ * The current solution is dumb, but it works and uses little code. Use of
++ * integer powers is not anticipated to be very frequent (apart from 2^x,
++ * which is separately optimized).
++ */
++ if (ib==0) *r=0;
++ else if (ic<0) return 0; /* FP realm */
++ else if (ib==2 && ic < (int)sizeof(lua_Integer)*8-1) *r= ((lua_Integer)1)<<ic; /* 1,2,4,...2^30 | 2^62 optimization */
++ else if (ic==0) *r=1;
++ else if (luai_abs(ib)==1) *r= (ic%2) ? ib:1;
++ else {
++ lua_Integer x= ib;
++ while( --ic ) {
++ if (!try_mulint( &x, x, ib ))
++ return 0; /* FP realm */
++ }
++ *r= x;
++ }
++ return 1;
++}
++
++int try_unmint( lua_Integer *r, lua_Integer ib ) {
++ /* Negating LUA_INTEGER_MIN leaves the range. */
++ if ( ib != LUA_INTEGER_MIN )
++ { *r= -ib; return 1; }
++ return 0;
++}
++
+--- /dev/null
++++ b/src/lnum.h
+@@ -0,0 +1,116 @@
++/*
++** $Id: lnum.h,v ... $
++** Internal Number model
++** See Copyright Notice in lua.h
++*/
++
++#ifndef lnum_h
++#define lnum_h
++
++#include <math.h>
++
++#include "lobject.h"
++
++/*
++** The luai_num* macros define the primitive operations over 'lua_Number's
++** (not 'lua_Integer's, not 'lua_Complex').
++*/
++#define luai_numadd(a,b) ((a)+(b))
++#define luai_numsub(a,b) ((a)-(b))
++#define luai_nummul(a,b) ((a)*(b))
++#define luai_numdiv(a,b) ((a)/(b))
++#define luai_nummod(a,b) ((a) - _LF(floor)((a)/(b))*(b))
++#define luai_numpow(a,b) (_LF(pow)(a,b))
++#define luai_numunm(a) (-(a))
++#define luai_numeq(a,b) ((a)==(b))
++#define luai_numlt(a,b) ((a)<(b))
++#define luai_numle(a,b) ((a)<=(b))
++#define luai_numisnan(a) (!luai_numeq((a), (a)))
++
++int try_addint( lua_Integer *r, lua_Integer ib, lua_Integer ic );
++int try_subint( lua_Integer *r, lua_Integer ib, lua_Integer ic );
++int try_mulint( lua_Integer *r, lua_Integer ib, lua_Integer ic );
++int try_divint( lua_Integer *r, lua_Integer ib, lua_Integer ic );
++int try_modint( lua_Integer *r, lua_Integer ib, lua_Integer ic );
++int try_powint( lua_Integer *r, lua_Integer ib, lua_Integer ic );
++int try_unmint( lua_Integer *r, lua_Integer ib );
++
++#ifdef LNUM_COMPLEX
++ static inline lua_Complex luai_vectunm( lua_Complex a ) { return -a; }
++ static inline lua_Complex luai_vectadd( lua_Complex a, lua_Complex b ) { return a+b; }
++ static inline lua_Complex luai_vectsub( lua_Complex a, lua_Complex b ) { return a-b; }
++ static inline lua_Complex luai_vectmul( lua_Complex a, lua_Complex b ) { return a*b; }
++ static inline lua_Complex luai_vectdiv( lua_Complex a, lua_Complex b ) { return a/b; }
++
++/*
++ * C99 does not provide modulus for complex numbers. It most likely is not
++ * meaningful at all.
++ */
++
++/*
++ * Complex power
++ *
++ * C99 'cpow' gives inaccurate results for many common cases s.a. (1i)^2 ->
++ * -1+1.2246467991474e-16i (OS X 10.4, gcc 4.0.1 build 5367)
++ *
++ * [(a+bi)^(c+di)] = (r^c) * exp(-d*t) * cos(c*t + d*ln(r)) +
++ * = (r^c) * exp(-d*t) * sin(c*t + d*ln(r)) *i
++ * r = sqrt(a^2+b^2), t = arctan( b/a )
++ *
++ * Reference: <http://home.att.net/~srschmitt/complexnumbers.html>
++ * Could also be calculated using: x^y = exp(ln(x)*y)
++ *
++ * Note: Defined here (and not in .c) so 'lmathlib.c' can share the
++ * implementation.
++ */
++ static inline
++ lua_Complex luai_vectpow( lua_Complex a, lua_Complex b )
++ {
++# if 1
++ lua_Number ar= _LF(creal)(a), ai= _LF(cimag)(a);
++ lua_Number br= _LF(creal)(b), bi= _LF(cimag)(b);
++
++ if (ai==0 && bi==0) { /* a^c (real) */
++ return luai_numpow( ar, br );
++ }
++
++ int br_int= (int)br;
++
++ if ( ai!=0 && bi==0 && br_int==br && br_int!=0 && br_int!=INT_MIN ) {
++ /* (a+bi)^N, N = { +-1,+-2, ... +-INT_MAX }
++ */
++ lua_Number k= luai_numpow( _LF(sqrt) (ar*ar + ai*ai), br );
++ lua_Number cos_z, sin_z;
++
++ /* Situation depends upon c (N) in the following manner:
++ *
++ * N%4==0 => cos(c*t)=1, sin(c*t)=0
++ * (N*sign(b))%4==1 or (N*sign(b))%4==-3 => cos(c*t)=0, sin(c*t)=1
++ * N%4==2 or N%4==-2 => cos(c*t)=-1, sin(c*t)=0
++ * (N*sign(b))%4==-1 or (N*sign(b))%4==3 => cos(c*t)=0, sin(c*t)=-1
++ */
++ int br_int_abs = br_int<0 ? -br_int:br_int;
++
++ switch( (br_int_abs%4) * (br_int<0 ? -1:1) * (ai<0 ? -1:1) ) {
++ case 0: cos_z=1, sin_z=0; break;
++ case 2: case -2: cos_z=-1, sin_z=0; break;
++ case 1: case -3: cos_z=0, sin_z=1; break;
++ case 3: case -1: cos_z=0, sin_z=-1; break;
++ default: lua_assert(0); return 0;
++ }
++ return k*cos_z + (k*sin_z)*I;
++ }
++# endif
++ return _LF(cpow) ( a, b );
++ }
++#endif
++
++LUAI_FUNC int luaO_str2d (const char *s, lua_Number *res1, lua_Integer *res2);
++LUAI_FUNC void luaO_num2buf( char *s, const TValue *o );
++
++LUAI_FUNC int /*bool*/ tt_integer_valued( const TValue *o, lua_Integer *ref );
++
++#define luai_normalize(o) \
++{ lua_Integer _i; if (tt_integer_valued(o,&_i)) setivalue(o,_i); }
++
++#endif
+--- /dev/null
++++ b/src/lnum_config.h
+@@ -0,0 +1,221 @@
++/*
++** $Id: lnum_config.h,v ... $
++** Internal Number model
++** See Copyright Notice in lua.h
++*/
++
++#ifndef lnum_config_h
++#define lnum_config_h
++
++/*
++** Default number modes
++*/
++#if (!defined LNUM_DOUBLE) && (!defined LNUM_FLOAT) && (!defined LNUM_LDOUBLE)
++# define LNUM_FLOAT
++#endif
++#if (!defined LNUM_INT16) && (!defined LNUM_INT32) && (!defined LNUM_INT64)
++# define LNUM_INT32
++#endif
++
++/*
++** Require C99 mode for COMPLEX, FLOAT and LDOUBLE (only DOUBLE is ANSI C).
++*/
++#if defined(LNUM_COMPLEX) && (__STDC_VERSION__ < 199901L)
++# error "Need C99 for complex (use '--std=c99' or similar)"
++#elif defined(LNUM_LDOUBLE) && (__STDC_VERSION__ < 199901L) && !defined(_MSC_VER)
++# error "Need C99 for 'long double' (use '--std=c99' or similar)"
++#elif defined(LNUM_FLOAT) && (__STDC_VERSION__ < 199901L)
++/* LNUM_FLOAT not supported on Windows */
++# error "Need C99 for 'float' (use '--std=c99' or similar)"
++#endif
++
++/*
++** Number mode identifier to accompany the version string.
++*/
++#ifdef LNUM_COMPLEX
++# define _LNUM1 "complex "
++#else
++# define _LNUM1 ""
++#endif
++#ifdef LNUM_DOUBLE
++# define _LNUM2 "double"
++#elif defined(LNUM_FLOAT)
++# define _LNUM2 "float"
++#elif defined(LNUM_LDOUBLE)
++# define _LNUM2 "ldouble"
++#endif
++#ifdef LNUM_INT32
++# define _LNUM3 "int32"
++#elif defined(LNUM_INT64)
++# define _LNUM3 "int64"
++#elif defined(LNUM_INT16)
++# define _LNUM3 "int16"
++#endif
++#define LUA_LNUM _LNUM1 _LNUM2 " " _LNUM3
++
++/*
++** LUA_NUMBER is the type of floating point number in Lua
++** LUA_NUMBER_SCAN is the format for reading numbers.
++** LUA_NUMBER_FMT is the format for writing numbers.
++*/
++#ifdef LNUM_FLOAT
++# define LUA_NUMBER float
++# define LUA_NUMBER_SCAN "%f"
++# define LUA_NUMBER_FMT "%g"
++#elif (defined LNUM_DOUBLE)
++# define LUA_NUMBER double
++# define LUA_NUMBER_SCAN "%lf"
++# define LUA_NUMBER_FMT "%.14g"
++#elif (defined LNUM_LDOUBLE)
++# define LUA_NUMBER long double
++# define LUA_NUMBER_SCAN "%Lg"
++# define LUA_NUMBER_FMT "%.20Lg"
++#endif
++
++
++/*
++** LUAI_MAXNUMBER2STR: size of a buffer fitting any number->string result.
++**
++** double: 24 (sign, x.xxxxxxxxxxxxxxe+nnnn, and \0)
++** int64: 21 (19 digits, sign, and \0)
++** long double: 43 for 128-bit (sign, x.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxe+nnnn, and \0)
++** 30 for 80-bit (sign, x.xxxxxxxxxxxxxxxxxxxxe+nnnn, and \0)
++*/
++#ifdef LNUM_LDOUBLE
++# define _LUAI_MN2S 44
++#else
++# define _LUAI_MN2S 24
++#endif
++
++#ifdef LNUM_COMPLEX
++# define LUAI_MAXNUMBER2STR (2*_LUAI_MN2S)
++#else
++# define LUAI_MAXNUMBER2STR _LUAI_MN2S
++#endif
++
++/*
++** LUA_INTEGER is the integer type used by lua_pushinteger/lua_tointeger/lua_isinteger.
++** LUA_INTEGER_SCAN is the format for reading integers
++** LUA_INTEGER_FMT is the format for writing integers
++**
++** Note: Visual C++ 2005 does not have 'strtoull()', use '_strtoui64()' instead.
++*/
++#ifdef LNUM_INT32
++# if LUAI_BITSINT > 16
++# define LUA_INTEGER int
++# define LUA_INTEGER_SCAN "%d"
++# define LUA_INTEGER_FMT "%d"
++# else
++/* Note: 'LUA_INTEGER' being 'ptrdiff_t' (as in Lua 5.1) causes problems with
++ * 'printf()' operations. Also 'unsigned ptrdiff_t' is invalid.
++ */
++# define LUA_INTEGER long
++# define LUA_INTEGER_SCAN "%ld"
++# define LUA_INTEGER_FMT "%ld"
++# endif
++# define LUA_INTEGER_MAX 0x7FFFFFFF /* 2^31-1 */
++/* */
++#elif defined(LNUM_INT64)
++# define LUA_INTEGER long long
++# ifdef _MSC_VER
++# define lua_str2ul _strtoui64
++# else
++# define lua_str2ul strtoull
++# endif
++# define LUA_INTEGER_SCAN "%lld"
++# define LUA_INTEGER_FMT "%lld"
++# define LUA_INTEGER_MAX 0x7fffffffffffffffLL /* 2^63-1 */
++# define LUA_INTEGER_MIN (-LUA_INTEGER_MAX - 1LL) /* -2^63 */
++/* */
++#elif defined(LNUM_INT16)
++# if LUAI_BITSINT > 16
++# define LUA_INTEGER short
++# define LUA_INTEGER_SCAN "%hd"
++# define LUA_INTEGER_FMT "%hd"
++# else
++# define LUA_INTEGER int
++# define LUA_INTEGER_SCAN "%d"
++# define LUA_INTEGER_FMT "%d"
++# endif
++# define LUA_INTEGER_MAX 0x7FFF /* 2^16-1 */
++#endif
++
++#ifndef lua_str2ul
++# define lua_str2ul (unsigned LUA_INTEGER)strtoul
++#endif
++#ifndef LUA_INTEGER_MIN
++# define LUA_INTEGER_MIN (-LUA_INTEGER_MAX -1) /* -2^16|32 */
++#endif
++
++/*
++@@ lua_number2int is a macro to convert lua_Number to int.
++@@ lua_number2integer is a macro to convert lua_Number to lua_Integer.
++** CHANGE them if you know a faster way to convert a lua_Number to
++** int (with any rounding method and without throwing errors) in your
++** system. In Pentium machines, a naive typecast from double to int
++** in C is extremely slow, so any alternative is worth trying.
++*/
++
++/* On a Pentium, resort to a trick */
++#if defined(LNUM_DOUBLE) && !defined(LUA_ANSI) && !defined(__SSE2__) && \
++ (defined(__i386) || defined (_M_IX86) || defined(__i386__))
++
++/* On a Microsoft compiler, use assembler */
++# if defined(_MSC_VER)
++# define lua_number2int(i,d) __asm fld d __asm fistp i
++# else
++
++/* the next trick should work on any Pentium, but sometimes clashes
++ with a DirectX idiosyncrasy */
++union luai_Cast { double l_d; long l_l; };
++# define lua_number2int(i,d) \
++ { volatile union luai_Cast u; u.l_d = (d) + 6755399441055744.0; (i) = u.l_l; }
++# endif
++
++# ifndef LNUM_INT64
++# define lua_number2integer lua_number2int
++# endif
++
++/* this option always works, but may be slow */
++#else
++# define lua_number2int(i,d) ((i)=(int)(d))
++#endif
++
++/* Note: Some compilers (OS X gcc 4.0?) may choke on double->long long conversion
++ * since it can lose precision. Others do require 'long long' there.
++ */
++#ifndef lua_number2integer
++# define lua_number2integer(i,d) ((i)=(lua_Integer)(d))
++#endif
++
++/*
++** 'luai_abs()' to give absolute value of 'lua_Integer'
++*/
++#ifdef LNUM_INT32
++# define luai_abs abs
++#elif defined(LNUM_INT64) && (__STDC_VERSION__ >= 199901L)
++# define luai_abs llabs
++#else
++# define luai_abs(v) ((v) >= 0 ? (v) : -(v))
++#endif
++
++/*
++** LUAI_UACNUMBER is the result of an 'usual argument conversion' over a number.
++** LUAI_UACINTEGER the same, over an integer.
++*/
++#define LUAI_UACNUMBER double
++#define LUAI_UACINTEGER long
++
++/* ANSI C only has math funcs for 'double. C99 required for float and long double
++ * variants.
++ */
++#ifdef LNUM_DOUBLE
++# define _LF(name) name
++#elif defined(LNUM_FLOAT)
++# define _LF(name) name ## f
++#elif defined(LNUM_LDOUBLE)
++# define _LF(name) name ## l
++#endif
++
++#endif
++
+--- a/src/lobject.c
++++ b/src/lobject.c
+@@ -21,7 +21,8 @@
+ #include "lstate.h"
+ #include "lstring.h"
+ #include "lvm.h"
+-
++#include "llex.h"
++#include "lnum.h"
+
+
+ const TValue luaO_nilobject_ = {{NULL}, LUA_TNIL};
+@@ -70,12 +71,31 @@ int luaO_log2 (unsigned int x) {
+
+
+ int luaO_rawequalObj (const TValue *t1, const TValue *t2) {
+- if (ttype(t1) != ttype(t2)) return 0;
++ if (!ttype_ext_same(t1,t2)) return 0;
+ else switch (ttype(t1)) {
+ case LUA_TNIL:
+ return 1;
++ case LUA_TINT:
++ if (ttype(t2)==LUA_TINT)
++ return ivalue(t1) == ivalue(t2);
++ else { /* t1:int, t2:num */
++#ifdef LNUM_COMPLEX
++ if (nvalue_img_fast(t2) != 0) return 0;
++#endif
++ /* Avoid doing accuracy losing cast, if possible. */
++ lua_Integer tmp;
++ if (tt_integer_valued(t2,&tmp))
++ return ivalue(t1) == tmp;
++ else
++ return luai_numeq( cast_num(ivalue(t1)), nvalue_fast(t2) );
++ }
+ case LUA_TNUMBER:
+- return luai_numeq(nvalue(t1), nvalue(t2));
++ if (ttype(t2)==LUA_TINT)
++ return luaO_rawequalObj(t2, t1); /* swap LUA_TINT to left */
++#ifdef LNUM_COMPLEX
++ if (!luai_numeq(nvalue_img_fast(t1), nvalue_img_fast(t2))) return 0;
++#endif
++ return luai_numeq(nvalue_fast(t1), nvalue_fast(t2));
+ case LUA_TBOOLEAN:
+ return bvalue(t1) == bvalue(t2); /* boolean true must be 1 !! */
+ case LUA_TLIGHTUSERDATA:
+@@ -86,21 +106,6 @@ int luaO_rawequalObj (const TValue *t1,
+ }
+ }
+
+-
+-int luaO_str2d (const char *s, lua_Number *result) {
+- char *endptr;
+- *result = lua_str2number(s, &endptr);
+- if (endptr == s) return 0; /* conversion failed */
+- if (*endptr == 'x' || *endptr == 'X') /* maybe an hexadecimal constant? */
+- *result = cast_num(strtoul(s, &endptr, 16));
+- if (*endptr == '\0') return 1; /* most common case */
+- while (isspace(cast(unsigned char, *endptr))) endptr++;
+- if (*endptr != '\0') return 0; /* invalid trailing characters? */
+- return 1;
+-}
+-
+-
+-
+ static void pushstr (lua_State *L, const char *str) {
+ setsvalue2s(L, L->top, luaS_new(L, str));
+ incr_top(L);
+@@ -131,7 +136,11 @@ const char *luaO_pushvfstring (lua_State
+ break;
+ }
+ case 'd': {
+- setnvalue(L->top, cast_num(va_arg(argp, int)));
++ /* This is tricky for 64-bit integers; maybe they even cannot be
++ * supported on all compilers; depends on the conversions applied to
++ * variable argument lists. TBD: test!
++ */
++ setivalue(L->top, (lua_Integer) va_arg(argp, l_uacInteger));
+ incr_top(L);
+ break;
+ }
+@@ -212,3 +221,4 @@ void luaO_chunkid (char *out, const char
+ }
+ }
+ }
++
+--- a/src/lobject.h
++++ b/src/lobject.h
+@@ -17,7 +17,11 @@
+
+
+ /* tags for values visible from Lua */
+-#define LAST_TAG LUA_TTHREAD
++#if LUA_TINT > LUA_TTHREAD
++# define LAST_TAG LUA_TINT
++#else
++# define LAST_TAG LUA_TTHREAD
++#endif
+
+ #define NUM_TAGS (LAST_TAG+1)
+
+@@ -59,7 +63,12 @@ typedef struct GCheader {
+ typedef union {
+ GCObject *gc;
+ void *p;
++#ifdef LNUM_COMPLEX
++ lua_Complex n;
++#else
+ lua_Number n;
++#endif
++ lua_Integer i;
+ int b;
+ } Value;
+
+@@ -77,7 +86,11 @@ typedef struct lua_TValue {
+
+ /* Macros to test type */
+ #define ttisnil(o) (ttype(o) == LUA_TNIL)
+-#define ttisnumber(o) (ttype(o) == LUA_TNUMBER)
++#define ttisint(o) (ttype(o) == LUA_TINT)
++#define ttisnumber(o) ((ttype(o) == LUA_TINT) || (ttype(o) == LUA_TNUMBER))
++#ifdef LNUM_COMPLEX
++# define ttiscomplex(o) ((ttype(o) == LUA_TNUMBER) && (nvalue_img_fast(o)!=0))
++#endif
+ #define ttisstring(o) (ttype(o) == LUA_TSTRING)
+ #define ttistable(o) (ttype(o) == LUA_TTABLE)
+ #define ttisfunction(o) (ttype(o) == LUA_TFUNCTION)
+@@ -90,7 +103,25 @@ typedef struct lua_TValue {
+ #define ttype(o) ((o)->tt)
+ #define gcvalue(o) check_exp(iscollectable(o), (o)->value.gc)
+ #define pvalue(o) check_exp(ttislightuserdata(o), (o)->value.p)
+-#define nvalue(o) check_exp(ttisnumber(o), (o)->value.n)
++
++#define ttype_ext(o) ( ttype(o) == LUA_TINT ? LUA_TNUMBER : ttype(o) )
++#define ttype_ext_same(o1,o2) ( (ttype(o1)==ttype(o2)) || (ttisnumber(o1) && ttisnumber(o2)) )
++
++/* '_fast' variants are for cases where 'ttype(o)' is known to be LUA_TNUMBER.
++ */
++#ifdef LNUM_COMPLEX
++# define nvalue_complex_fast(o) check_exp( ttype(o)==LUA_TNUMBER, (o)->value.n )
++# define nvalue_fast(o) ( _LF(creal) ( nvalue_complex_fast(o) ) )
++# define nvalue_img_fast(o) ( _LF(cimag) ( nvalue_complex_fast(o) ) )
++# define nvalue_complex(o) check_exp( ttisnumber(o), (ttype(o)==LUA_TINT) ? (o)->value.i : (o)->value.n )
++# define nvalue_img(o) check_exp( ttisnumber(o), (ttype(o)==LUA_TINT) ? 0 : _LF(cimag)( (o)->value.n ) )
++# define nvalue(o) check_exp( ttisnumber(o), (ttype(o)==LUA_TINT) ? cast_num((o)->value.i) : _LF(creal)((o)->value.n) )
++#else
++# define nvalue(o) check_exp( ttisnumber(o), (ttype(o)==LUA_TINT) ? cast_num((o)->value.i) : (o)->value.n )
++# define nvalue_fast(o) check_exp( ttype(o)==LUA_TNUMBER, (o)->value.n )
++#endif
++#define ivalue(o) check_exp( ttype(o)==LUA_TINT, (o)->value.i )
++
+ #define rawtsvalue(o) check_exp(ttisstring(o), &(o)->value.gc->ts)
+ #define tsvalue(o) (&rawtsvalue(o)->tsv)
+ #define rawuvalue(o) check_exp(ttisuserdata(o), &(o)->value.gc->u)
+@@ -116,8 +147,27 @@ typedef struct lua_TValue {
+ /* Macros to set values */
+ #define setnilvalue(obj) ((obj)->tt=LUA_TNIL)
+
+-#define setnvalue(obj,x) \
+- { TValue *i_o=(obj); i_o->value.n=(x); i_o->tt=LUA_TNUMBER; }
++/* Must not have side effects, 'x' may be expression.
++*/
++#define setivalue(obj,x) \
++ { TValue *i_o=(obj); i_o->value.i=(x); i_o->tt=LUA_TINT; }
++
++# define setnvalue(obj,x) \
++ { TValue *i_o=(obj); i_o->value.n= (x); i_o->tt=LUA_TNUMBER; }
++
++/* Note: Complex always has "inline", both are C99.
++*/
++#ifdef LNUM_COMPLEX
++ static inline void setnvalue_complex_fast( TValue *obj, lua_Complex x ) {
++ lua_assert( _LF(cimag)(x) != 0 );
++ obj->value.n= x; obj->tt= LUA_TNUMBER;
++ }
++ static inline void setnvalue_complex( TValue *obj, lua_Complex x ) {
++ if (_LF(cimag)(x) == 0) { setnvalue(obj, _LF(creal)(x)); }
++ else { obj->value.n= x; obj->tt= LUA_TNUMBER; }
++ }
++#endif
++
+
+ #define setpvalue(obj,x) \
+ { TValue *i_o=(obj); i_o->value.p=(x); i_o->tt=LUA_TLIGHTUSERDATA; }
+@@ -155,9 +205,6 @@ typedef struct lua_TValue {
+ i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TPROTO; \
+ checkliveness(G(L),i_o); }
+
+-
+-
+-
+ #define setobj(L,obj1,obj2) \
+ { const TValue *o2=(obj2); TValue *o1=(obj1); \
+ o1->value = o2->value; o1->tt=o2->tt; \
+@@ -185,8 +232,11 @@ typedef struct lua_TValue {
+
+ #define setttype(obj, tt) (ttype(obj) = (tt))
+
+-
+-#define iscollectable(o) (ttype(o) >= LUA_TSTRING)
++#if LUA_TINT >= LUA_TSTRING
++# define iscollectable(o) ((ttype(o) >= LUA_TSTRING) && (ttype(o) != LUA_TINT))
++#else
++# define iscollectable(o) (ttype(o) >= LUA_TSTRING)
++#endif
+
+
+
+@@ -370,12 +420,10 @@ LUAI_FUNC int luaO_log2 (unsigned int x)
+ LUAI_FUNC int luaO_int2fb (unsigned int x);
+ LUAI_FUNC int luaO_fb2int (int x);
+ LUAI_FUNC int luaO_rawequalObj (const TValue *t1, const TValue *t2);
+-LUAI_FUNC int luaO_str2d (const char *s, lua_Number *result);
+ LUAI_FUNC const char *luaO_pushvfstring (lua_State *L, const char *fmt,
+ va_list argp);
+ LUAI_FUNC const char *luaO_pushfstring (lua_State *L, const char *fmt, ...);
+ LUAI_FUNC void luaO_chunkid (char *out, const char *source, size_t len);
+
+-
+ #endif
+
+--- a/src/loslib.c
++++ b/src/loslib.c
+@@ -186,15 +186,30 @@ static int os_time (lua_State *L) {
+ }
+ if (t == (time_t)(-1))
+ lua_pushnil(L);
+- else
+- lua_pushnumber(L, (lua_Number)t);
++ else {
++ /* On float systems the pushed value must be an integer, NOT a number.
++ * Otherwise, accuracy is lost in the time_t->float conversion.
++ */
++#ifdef LNUM_FLOAT
++ lua_pushinteger(L, (lua_Integer) t);
++#else
++ lua_pushnumber(L, (lua_Number) t);
++#endif
++ }
+ return 1;
+ }
+
+
+ static int os_difftime (lua_State *L) {
++#ifdef LNUM_FLOAT
++ lua_Integer i= (lua_Integer)
++ difftime( (time_t)(luaL_checkinteger(L, 1)),
++ (time_t)(luaL_optinteger(L, 2, 0)));
++ lua_pushinteger(L, i);
++#else
+ lua_pushnumber(L, difftime((time_t)(luaL_checknumber(L, 1)),
+ (time_t)(luaL_optnumber(L, 2, 0))));
++#endif
+ return 1;
+ }
+
+--- a/src/lparser.c
++++ b/src/lparser.c
+@@ -33,7 +33,6 @@
+
+ #define luaY_checklimit(fs,v,l,m) if ((v)>(l)) errorlimit(fs,l,m)
+
+-
+ /*
+ ** nodes for block list (list of active blocks)
+ */
+@@ -72,7 +71,7 @@ static void errorlimit (FuncState *fs, i
+ const char *msg = (fs->f->linedefined == 0) ?
+ luaO_pushfstring(fs->L, "main function has more than %d %s", limit, what) :
+ luaO_pushfstring(fs->L, "function at line %d has more than %d %s",
+- fs->f->linedefined, limit, what);
++ (fs->f->linedefined), limit, what);
+ luaX_lexerror(fs->ls, msg, 0);
+ }
+
+@@ -733,6 +732,18 @@ static void simpleexp (LexState *ls, exp
+ v->u.nval = ls->t.seminfo.r;
+ break;
+ }
++ case TK_INT: {
++ init_exp(v, VKINT, 0);
++ v->u.ival = ls->t.seminfo.i;
++ break;
++ }
++#ifdef LNUM_COMPLEX
++ case TK_NUMBER2: {
++ init_exp(v, VKNUM2, 0);
++ v->u.nval = ls->t.seminfo.r;
++ break;
++ }
++#endif
+ case TK_STRING: {
+ codestring(ls, v, ls->t.seminfo.ts);
+ break;
+@@ -1079,7 +1090,7 @@ static void fornum (LexState *ls, TStrin
+ if (testnext(ls, ','))
+ exp1(ls); /* optional step */
+ else { /* default step = 1 */
+- luaK_codeABx(fs, OP_LOADK, fs->freereg, luaK_numberK(fs, 1));
++ luaK_codeABx(fs, OP_LOADK, fs->freereg, luaK_integerK(fs, 1));
+ luaK_reserveregs(fs, 1);
+ }
+ forbody(ls, base, line, 1, 1);
+--- a/src/lparser.h
++++ b/src/lparser.h
+@@ -31,7 +31,11 @@ typedef enum {
+ VRELOCABLE, /* info = instruction pc */
+ VNONRELOC, /* info = result register */
+ VCALL, /* info = instruction pc */
+- VVARARG /* info = instruction pc */
++ VVARARG, /* info = instruction pc */
++ VKINT /* ival = integer value */
++#ifdef LNUM_COMPLEX
++ ,VKNUM2 /* nval = imaginary value */
++#endif
+ } expkind;
+
+ typedef struct expdesc {
+@@ -39,6 +43,7 @@ typedef struct expdesc {
+ union {
+ struct { int info, aux; } s;
+ lua_Number nval;
++ lua_Integer ival;
+ } u;
+ int t; /* patch list of `exit when true' */
+ int f; /* patch list of `exit when false' */
+--- a/src/lstrlib.c
++++ b/src/lstrlib.c
+@@ -43,8 +43,8 @@ static ptrdiff_t posrelat (ptrdiff_t pos
+ static int str_sub (lua_State *L) {
+ size_t l;
+ const char *s = luaL_checklstring(L, 1, &l);
+- ptrdiff_t start = posrelat(luaL_checkinteger(L, 2), l);
+- ptrdiff_t end = posrelat(luaL_optinteger(L, 3, -1), l);
++ ptrdiff_t start = posrelat(luaL_checkint32(L, 2), l);
++ ptrdiff_t end = posrelat(luaL_optint32(L, 3, -1), l);
+ if (start < 1) start = 1;
+ if (end > (ptrdiff_t)l) end = (ptrdiff_t)l;
+ if (start <= end)
+@@ -106,8 +106,8 @@ static int str_rep (lua_State *L) {
+ static int str_byte (lua_State *L) {
+ size_t l;
+ const char *s = luaL_checklstring(L, 1, &l);
+- ptrdiff_t posi = posrelat(luaL_optinteger(L, 2, 1), l);
+- ptrdiff_t pose = posrelat(luaL_optinteger(L, 3, posi), l);
++ ptrdiff_t posi = posrelat(luaL_optint32(L, 2, 1), l);
++ ptrdiff_t pose = posrelat(luaL_optint32(L, 3, posi), l);
+ int n, i;
+ if (posi <= 0) posi = 1;
+ if ((size_t)pose > l) pose = l;
+@@ -496,7 +496,7 @@ static int str_find_aux (lua_State *L, i
+ size_t l1, l2;
+ const char *s = luaL_checklstring(L, 1, &l1);
+ const char *p = luaL_checklstring(L, 2, &l2);
+- ptrdiff_t init = posrelat(luaL_optinteger(L, 3, 1), l1) - 1;
++ ptrdiff_t init = posrelat(luaL_optint32(L, 3, 1), l1) - 1;
+ if (init < 0) init = 0;
+ else if ((size_t)(init) > l1) init = (ptrdiff_t)l1;
+ if (find && (lua_toboolean(L, 4) || /* explicit request? */
+@@ -690,7 +690,7 @@ static int str_gsub (lua_State *L) {
+ ** maximum size of each format specification (such as '%-099.99d')
+ ** (+10 accounts for %99.99x plus margin of error)
+ */
+-#define MAX_FORMAT (sizeof(FLAGS) + sizeof(LUA_INTFRMLEN) + 10)
++#define MAX_FORMAT (sizeof(FLAGS) + sizeof(LUA_INTEGER_FMT)-2 + 10)
+
+
+ static void addquoted (lua_State *L, luaL_Buffer *b, int arg) {
+@@ -747,9 +747,9 @@ static const char *scanformat (lua_State
+ static void addintlen (char *form) {
+ size_t l = strlen(form);
+ char spec = form[l - 1];
+- strcpy(form + l - 1, LUA_INTFRMLEN);
+- form[l + sizeof(LUA_INTFRMLEN) - 2] = spec;
+- form[l + sizeof(LUA_INTFRMLEN) - 1] = '\0';
++ const char *tmp= LUA_INTEGER_FMT; /* "%lld" or "%ld" */
++ strcpy(form + l - 1, tmp+1);
++ form[l + sizeof(LUA_INTEGER_FMT)-4] = spec;
+ }
+
+
+@@ -779,12 +779,12 @@ static int str_format (lua_State *L) {
+ }
+ case 'd': case 'i': {
+ addintlen(form);
+- sprintf(buff, form, (LUA_INTFRM_T)luaL_checknumber(L, arg));
++ sprintf(buff, form, luaL_checkinteger(L, arg));
+ break;
+ }
+ case 'o': case 'u': case 'x': case 'X': {
+ addintlen(form);
+- sprintf(buff, form, (unsigned LUA_INTFRM_T)luaL_checknumber(L, arg));
++ sprintf(buff, form, (unsigned LUA_INTEGER)luaL_checkinteger(L, arg));
+ break;
+ }
+ case 'e': case 'E': case 'f':
+--- a/src/ltable.c
++++ b/src/ltable.c
+@@ -33,6 +33,7 @@
+ #include "lobject.h"
+ #include "lstate.h"
+ #include "ltable.h"
++#include "lnum.h"
+
+
+ /*
+@@ -51,25 +52,15 @@
+
+ #define hashstr(t,str) hashpow2(t, (str)->tsv.hash)
+ #define hashboolean(t,p) hashpow2(t, p)
+-
++#define hashint(t,i) hashpow2(t,i)
+
+ /*
+ ** for some types, it is better to avoid modulus by power of 2, as
+ ** they tend to have many 2 factors.
+ */
+ #define hashmod(t,n) (gnode(t, ((n) % ((sizenode(t)-1)|1))))
+-
+-
+ #define hashpointer(t,p) hashmod(t, IntPoint(p))
+
+-
+-/*
+-** number of ints inside a lua_Number
+-*/
+-#define numints cast_int(sizeof(lua_Number)/sizeof(int))
+-
+-
+-
+ #define dummynode (&dummynode_)
+
+ static const Node dummynode_ = {
+@@ -80,27 +71,46 @@ static const Node dummynode_ = {
+
+ /*
+ ** hash for lua_Numbers
++**
++** for non-complex modes, never called with 'lua_Integer' value range (s.a. 0)
+ */
+ static Node *hashnum (const Table *t, lua_Number n) {
+- unsigned int a[numints];
+- int i;
+- if (luai_numeq(n, 0)) /* avoid problems with -0 */
+- return gnode(t, 0);
+- memcpy(a, &n, sizeof(a));
+- for (i = 1; i < numints; i++) a[0] += a[i];
+- return hashmod(t, a[0]);
++ const unsigned int *p= cast(const unsigned int *,&n);
++ unsigned int sum= *p;
++ unsigned int m= sizeof(lua_Number)/sizeof(int);
++ unsigned int i;
++ /* OS X Intel has 'm'==4 and gives "Bus error" if the last integer of
++ * 'n' is read; the actual size of long double is only 80 bits = 10 bytes.
++ * Linux x86 has 'm'==3, and does not require reduction.
++ */
++#if defined(LNUM_LDOUBLE) && defined(__i386__)
++ if (m>3) m--;
++#endif
++ for (i = 1; i < m; i++) sum += p[i];
++ return hashmod(t, sum);
+ }
+
+
+-
+ /*
+ ** returns the `main' position of an element in a table (that is, the index
+ ** of its hash value)
++**
++** Floating point numbers with integer value give the hash position of the
++** integer (so they use the same table position).
+ */
+ static Node *mainposition (const Table *t, const TValue *key) {
++ lua_Integer i;
+ switch (ttype(key)) {
+ case LUA_TNUMBER:
+- return hashnum(t, nvalue(key));
++ if (tt_integer_valued(key,&i))
++ return hashint(t, i);
++#ifdef LNUM_COMPLEX
++ if (nvalue_img_fast(key)!=0 && luai_numeq(nvalue_fast(key),0))
++ return gnode(t, 0); /* 0 and -0 to give same hash */
++#endif
++ return hashnum(t, nvalue_fast(key));
++ case LUA_TINT:
++ return hashint(t, ivalue(key));
+ case LUA_TSTRING:
+ return hashstr(t, rawtsvalue(key));
+ case LUA_TBOOLEAN:
+@@ -116,16 +126,20 @@ static Node *mainposition (const Table *
+ /*
+ ** returns the index for `key' if `key' is an appropriate key to live in
+ ** the array part of the table, -1 otherwise.
++**
++** Anything <=0 is taken as not being in the array part.
+ */
+-static int arrayindex (const TValue *key) {
+- if (ttisnumber(key)) {
+- lua_Number n = nvalue(key);
+- int k;
+- lua_number2int(k, n);
+- if (luai_numeq(cast_num(k), n))
+- return k;
++static int arrayindex (const TValue *key, int max) {
++ lua_Integer k;
++ switch( ttype(key) ) {
++ case LUA_TINT:
++ k= ivalue(key); break;
++ case LUA_TNUMBER:
++ if (tt_integer_valued(key,&k)) break;
++ default:
++ return -1; /* not to be used as array index */
+ }
+- return -1; /* `key' did not match some condition */
++ return ((k>0) && (k <= max)) ? cast_int(k) : -1;
+ }
+
+
+@@ -137,8 +151,8 @@ static int arrayindex (const TValue *key
+ static int findindex (lua_State *L, Table *t, StkId key) {
+ int i;
+ if (ttisnil(key)) return -1; /* first iteration */
+- i = arrayindex(key);
+- if (0 < i && i <= t->sizearray) /* is `key' inside array part? */
++ i = arrayindex(key, t->sizearray);
++ if (i>0) /* inside array part? */
+ return i-1; /* yes; that's the index (corrected to C) */
+ else {
+ Node *n = mainposition(t, key);
+@@ -163,7 +177,7 @@ int luaH_next (lua_State *L, Table *t, S
+ int i = findindex(L, t, key); /* find original element */
+ for (i++; i < t->sizearray; i++) { /* try first array part */
+ if (!ttisnil(&t->array[i])) { /* a non-nil value? */
+- setnvalue(key, cast_num(i+1));
++ setivalue(key, i+1);
+ setobj2s(L, key+1, &t->array[i]);
+ return 1;
+ }
+@@ -209,8 +223,8 @@ static int computesizes (int nums[], int
+
+
+ static int countint (const TValue *key, int *nums) {
+- int k = arrayindex(key);
+- if (0 < k && k <= MAXASIZE) { /* is `key' an appropriate array index? */
++ int k = arrayindex(key,MAXASIZE);
++ if (k>0) { /* appropriate array index? */
+ nums[ceillog2(k)]++; /* count as such */
+ return 1;
+ }
+@@ -308,7 +322,7 @@ static void resize (lua_State *L, Table
+ /* re-insert elements from vanishing slice */
+ for (i=nasize; i<oldasize; i++) {
+ if (!ttisnil(&t->array[i]))
+- setobjt2t(L, luaH_setnum(L, t, i+1), &t->array[i]);
++ setobjt2t(L, luaH_setint(L, t, i+1), &t->array[i]);
+ }
+ /* shrink array */
+ luaM_reallocvector(L, t->array, oldasize, nasize, TValue);
+@@ -409,7 +423,9 @@ static TValue *newkey (lua_State *L, Tab
+ othern = mainposition(t, key2tval(mp));
+ if (othern != mp) { /* is colliding node out of its main position? */
+ /* yes; move colliding node into free position */
+- while (gnext(othern) != mp) othern = gnext(othern); /* find previous */
++ while (gnext(othern) != mp) {
++ othern = gnext(othern); /* find previous */
++ }
+ gnext(othern) = n; /* redo the chain with `n' in place of `mp' */
+ *n = *mp; /* copy colliding node into free pos. (mp->next also goes) */
+ gnext(mp) = NULL; /* now `mp' is free */
+@@ -432,17 +448,18 @@ static TValue *newkey (lua_State *L, Tab
+ /*
+ ** search function for integers
+ */
+-const TValue *luaH_getnum (Table *t, int key) {
++const TValue *luaH_getint (Table *t, lua_Integer key) {
+ /* (1 <= key && key <= t->sizearray) */
+ if (cast(unsigned int, key-1) < cast(unsigned int, t->sizearray))
+ return &t->array[key-1];
+ else {
+- lua_Number nk = cast_num(key);
+- Node *n = hashnum(t, nk);
++ Node *n = hashint(t, key);
+ do { /* check whether `key' is somewhere in the chain */
+- if (ttisnumber(gkey(n)) && luai_numeq(nvalue(gkey(n)), nk))
++ if (ttisint(gkey(n)) && (ivalue(gkey(n)) == key)) {
+ return gval(n); /* that's it */
+- else n = gnext(n);
++ } else {
++ n = gnext(n);
++ }
+ } while (n);
+ return luaO_nilobject;
+ }
+@@ -470,14 +487,12 @@ const TValue *luaH_get (Table *t, const
+ switch (ttype(key)) {
+ case LUA_TNIL: return luaO_nilobject;
+ case LUA_TSTRING: return luaH_getstr(t, rawtsvalue(key));
++ case LUA_TINT: return luaH_getint(t, ivalue(key));
+ case LUA_TNUMBER: {
+- int k;
+- lua_Number n = nvalue(key);
+- lua_number2int(k, n);
+- if (luai_numeq(cast_num(k), nvalue(key))) /* index is int? */
+- return luaH_getnum(t, k); /* use specialized version */
+- /* else go through */
+- }
++ lua_Integer i;
++ if (tt_integer_valued(key,&i))
++ return luaH_getint(t,i);
++ } /* pass through */
+ default: {
+ Node *n = mainposition(t, key);
+ do { /* check whether `key' is somewhere in the chain */
+@@ -498,20 +513,25 @@ TValue *luaH_set (lua_State *L, Table *t
+ return cast(TValue *, p);
+ else {
+ if (ttisnil(key)) luaG_runerror(L, "table index is nil");
+- else if (ttisnumber(key) && luai_numisnan(nvalue(key)))
+- luaG_runerror(L, "table index is NaN");
++ else if (ttype(key)==LUA_TNUMBER) {
++ lua_Integer k;
++ if (luai_numisnan(nvalue_fast(key)))
++ luaG_runerror(L, "table index is NaN");
++ if (tt_integer_valued(key,&k))
++ return luaH_setint(L, t, k);
++ }
+ return newkey(L, t, key);
+ }
+ }
+
+
+-TValue *luaH_setnum (lua_State *L, Table *t, int key) {
+- const TValue *p = luaH_getnum(t, key);
++TValue *luaH_setint (lua_State *L, Table *t, lua_Integer key) {
++ const TValue *p = luaH_getint(t, key);
+ if (p != luaO_nilobject)
+ return cast(TValue *, p);
+ else {
+ TValue k;
+- setnvalue(&k, cast_num(key));
++ setivalue(&k, key);
+ return newkey(L, t, &k);
+ }
+ }
+@@ -533,20 +553,21 @@ static int unbound_search (Table *t, uns
+ unsigned int i = j; /* i is zero or a present index */
+ j++;
+ /* find `i' and `j' such that i is present and j is not */
+- while (!ttisnil(luaH_getnum(t, j))) {
++ while (!ttisnil(luaH_getint(t, j))) {
+ i = j;
+ j *= 2;
+ if (j > cast(unsigned int, MAX_INT)) { /* overflow? */
+ /* table was built with bad purposes: resort to linear search */
+- i = 1;
+- while (!ttisnil(luaH_getnum(t, i))) i++;
+- return i - 1;
++ for( i = 1; i<MAX_INT+1; i++ ) {
++ if (ttisnil(luaH_getint(t, i))) break;
++ }
++ return i - 1; /* up to MAX_INT */
+ }
+ }
+ /* now do a binary search between them */
+ while (j - i > 1) {
+ unsigned int m = (i+j)/2;
+- if (ttisnil(luaH_getnum(t, m))) j = m;
++ if (ttisnil(luaH_getint(t, m))) j = m;
+ else i = m;
+ }
+ return i;
+--- a/src/ltable.h
++++ b/src/ltable.h
+@@ -18,8 +18,8 @@
+ #define key2tval(n) (&(n)->i_key.tvk)
+
+
+-LUAI_FUNC const TValue *luaH_getnum (Table *t, int key);
+-LUAI_FUNC TValue *luaH_setnum (lua_State *L, Table *t, int key);
++LUAI_FUNC const TValue *luaH_getint (Table *t, lua_Integer key);
++LUAI_FUNC TValue *luaH_setint (lua_State *L, Table *t, lua_Integer key);
+ LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key);
+ LUAI_FUNC TValue *luaH_setstr (lua_State *L, Table *t, TString *key);
+ LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key);
+--- a/src/ltm.c
++++ b/src/ltm.c
+@@ -19,7 +19,6 @@
+ #include "ltm.h"
+
+
+-
+ const char *const luaT_typenames[] = {
+ "nil", "boolean", "userdata", "number",
+ "string", "table", "function", "userdata", "thread",
+@@ -67,6 +66,9 @@ const TValue *luaT_gettmbyobj (lua_State
+ case LUA_TUSERDATA:
+ mt = uvalue(o)->metatable;
+ break;
++ case LUA_TINT:
++ mt = G(L)->mt[LUA_TNUMBER];
++ break;
+ default:
+ mt = G(L)->mt[ttype(o)];
+ }
+--- a/src/lua.c
++++ b/src/lua.c
+@@ -16,7 +16,7 @@
+
+ #include "lauxlib.h"
+ #include "lualib.h"
+-
++#include "llimits.h"
+
+
+ static lua_State *globalL = NULL;
+@@ -382,6 +382,15 @@ int main (int argc, char **argv) {
+ l_message(argv[0], "cannot create state: not enough memory");
+ return EXIT_FAILURE;
+ }
++ /* Checking 'sizeof(lua_Integer)' cannot be made in preprocessor on all compilers.
++ */
++#ifdef LNUM_INT16
++ lua_assert( sizeof(lua_Integer) == 2 );
++#elif defined(LNUM_INT32)
++ lua_assert( sizeof(lua_Integer) == 4 );
++#elif defined(LNUM_INT64)
++ lua_assert( sizeof(lua_Integer) == 8 );
++#endif
+ s.argc = argc;
+ s.argv = argv;
+ status = lua_cpcall(L, &pmain, &s);
+--- a/src/lua.h
++++ b/src/lua.h
+@@ -19,7 +19,7 @@
+ #define LUA_VERSION "Lua 5.1"
+ #define LUA_RELEASE "Lua 5.1.5"
+ #define LUA_VERSION_NUM 501
+-#define LUA_COPYRIGHT "Copyright (C) 1994-2012 Lua.org, PUC-Rio"
++#define LUA_COPYRIGHT "Copyright (C) 1994-2012 Lua.org, PUC-Rio" " (" LUA_LNUM ")"
+ #define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo & W. Celes"
+
+
+@@ -71,6 +71,16 @@ typedef void * (*lua_Alloc) (void *ud, v
+ */
+ #define LUA_TNONE (-1)
+
++/* LUA_TINT is an internal type, not visible to applications. There are three
++ * potential values where it can be tweaked to (code autoadjusts to these):
++ *
++ * -2: not 'usual' type value; good since 'LUA_TINT' is not part of the API
++ * LUA_TNUMBER+1: shifts other type values upwards, breaking binary compatibility
++ * not acceptable for 5.1, maybe 5.2 onwards?
++ * 9: greater than existing (5.1) type values.
++*/
++#define LUA_TINT (-2)
++
+ #define LUA_TNIL 0
+ #define LUA_TBOOLEAN 1
+ #define LUA_TLIGHTUSERDATA 2
+@@ -139,6 +149,8 @@ LUA_API int (lua_isuserdata)
+ LUA_API int (lua_type) (lua_State *L, int idx);
+ LUA_API const char *(lua_typename) (lua_State *L, int tp);
+
++LUA_API int (lua_isinteger) (lua_State *L, int idx);
++
+ LUA_API int (lua_equal) (lua_State *L, int idx1, int idx2);
+ LUA_API int (lua_rawequal) (lua_State *L, int idx1, int idx2);
+ LUA_API int (lua_lessthan) (lua_State *L, int idx1, int idx2);
+@@ -244,6 +256,19 @@ LUA_API lua_Alloc (lua_getallocf) (lua_S
+ LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud);
+
+
++/*
++* It is unnecessary to break Lua C API 'lua_tonumber()' compatibility, just
++* because the Lua number type is complex. Most C modules would use scalars
++* only. We'll introduce new 'lua_tocomplex' and 'lua_pushcomplex' for when
++* the module really wants to use them.
++*/
++#ifdef LNUM_COMPLEX
++ #include <complex.h>
++ typedef LUA_NUMBER complex lua_Complex;
++ LUA_API lua_Complex (lua_tocomplex) (lua_State *L, int idx);
++ LUA_API void (lua_pushcomplex) (lua_State *L, lua_Complex v);
++#endif
++
+
+ /*
+ ** ===============================================================
+@@ -268,7 +293,12 @@ LUA_API void lua_setallocf (lua_State *L
+ #define lua_isboolean(L,n) (lua_type(L, (n)) == LUA_TBOOLEAN)
+ #define lua_isthread(L,n) (lua_type(L, (n)) == LUA_TTHREAD)
+ #define lua_isnone(L,n) (lua_type(L, (n)) == LUA_TNONE)
+-#define lua_isnoneornil(L, n) (lua_type(L, (n)) <= 0)
++
++#if LUA_TINT < 0
++# define lua_isnoneornil(L, n) ( (lua_type(L,(n)) <= 0) && (lua_type(L,(n)) != LUA_TINT) )
++#else
++# define lua_isnoneornil(L, n) (lua_type(L, (n)) <= 0)
++#endif
+
+ #define lua_pushliteral(L, s) \
+ lua_pushlstring(L, "" s, (sizeof(s)/sizeof(char))-1)
+@@ -386,3 +416,4 @@ struct lua_Debug {
+
+
+ #endif
++
+--- a/src/luaconf.h
++++ b/src/luaconf.h
+@@ -10,7 +10,9 @@
+
+ #include <limits.h>
+ #include <stddef.h>
+-
++#ifdef lua_assert
++# include <assert.h>
++#endif
+
+ /*
+ ** ==================================================================
+@@ -136,14 +138,38 @@
+
+
+ /*
+-@@ LUA_INTEGER is the integral type used by lua_pushinteger/lua_tointeger.
+-** CHANGE that if ptrdiff_t is not adequate on your machine. (On most
+-** machines, ptrdiff_t gives a good choice between int or long.)
++@@ LUAI_BITSINT defines the number of bits in an int.
++** CHANGE here if Lua cannot automatically detect the number of bits of
++** your machine. Probably you do not need to change this.
+ */
+-#define LUA_INTEGER ptrdiff_t
++/* avoid overflows in comparison */
++#if INT_MAX-20 < 32760
++#define LUAI_BITSINT 16
++#elif INT_MAX > 2147483640L
++/* int has at least 32 bits */
++#define LUAI_BITSINT 32
++#else
++#error "you must define LUA_BITSINT with number of bits in an integer"
++#endif
+
+
+ /*
++@@ LNUM_DOUBLE | LNUM_FLOAT | LNUM_LDOUBLE: Generic Lua number mode
++@@ LNUM_INT32 | LNUM_INT64: Integer type
++@@ LNUM_COMPLEX: Define for using 'a+bi' numbers
++@@
++@@ You can combine LNUM_xxx but only one of each group. I.e. '-DLNUM_FLOAT
++@@ -DLNUM_INT32 -DLNUM_COMPLEX' gives float range complex numbers, with
++@@ 32-bit scalar integer range optimized.
++**
++** These are kept in a separate configuration file mainly for ease of patching
++** (can be changed if integerated to Lua proper).
++*/
++/*#define LNUM_DOUBLE*/
++/*#define LNUM_INT32*/
++#include "lnum_config.h"
++
++/*
+ @@ LUA_API is a mark for all core API functions.
+ @@ LUALIB_API is a mark for all standard library functions.
+ ** CHANGE them if you need to define those functions in some special way.
+@@ -383,22 +409,6 @@
+
+
+ /*
+-@@ LUAI_BITSINT defines the number of bits in an int.
+-** CHANGE here if Lua cannot automatically detect the number of bits of
+-** your machine. Probably you do not need to change this.
+-*/
+-/* avoid overflows in comparison */
+-#if INT_MAX-20 < 32760
+-#define LUAI_BITSINT 16
+-#elif INT_MAX > 2147483640L
+-/* int has at least 32 bits */
+-#define LUAI_BITSINT 32
+-#else
+-#error "you must define LUA_BITSINT with number of bits in an integer"
+-#endif
+-
+-
+-/*
+ @@ LUAI_UINT32 is an unsigned integer with at least 32 bits.
+ @@ LUAI_INT32 is an signed integer with at least 32 bits.
+ @@ LUAI_UMEM is an unsigned integer big enough to count the total
+@@ -425,6 +435,15 @@
+ #define LUAI_MEM long
+ #endif
+
++/*
++@@ LUAI_BOOL carries 0 and nonzero (normally 1). It may be defined as 'char'
++** (to save memory), 'int' (for speed), 'bool' (for C++) or '_Bool' (C99)
++*/
++#ifdef __cplusplus
++# define LUAI_BOOL bool
++#else
++# define LUAI_BOOL int
++#endif
+
+ /*
+ @@ LUAI_MAXCALLS limits the number of nested calls.
+@@ -490,101 +509,6 @@
+ /* }================================================================== */
+
+
+-
+-
+-/*
+-** {==================================================================
+-@@ LUA_NUMBER is the type of numbers in Lua.
+-** CHANGE the following definitions only if you want to build Lua
+-** with a number type different from double. You may also need to
+-** change lua_number2int & lua_number2integer.
+-** ===================================================================
+-*/
+-
+-#define LUA_NUMBER_DOUBLE
+-#define LUA_NUMBER double
+-
+-/*
+-@@ LUAI_UACNUMBER is the result of an 'usual argument conversion'
+-@* over a number.
+-*/
+-#define LUAI_UACNUMBER double
+-
+-
+-/*
+-@@ LUA_NUMBER_SCAN is the format for reading numbers.
+-@@ LUA_NUMBER_FMT is the format for writing numbers.
+-@@ lua_number2str converts a number to a string.
+-@@ LUAI_MAXNUMBER2STR is maximum size of previous conversion.
+-@@ lua_str2number converts a string to a number.
+-*/
+-#define LUA_NUMBER_SCAN "%lf"
+-#define LUA_NUMBER_FMT "%.14g"
+-#define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n))
+-#define LUAI_MAXNUMBER2STR 32 /* 16 digits, sign, point, and \0 */
+-#define lua_str2number(s,p) strtod((s), (p))
+-
+-
+-/*
+-@@ The luai_num* macros define the primitive operations over numbers.
+-*/
+-#if defined(LUA_CORE)
+-#include <math.h>
+-#define luai_numadd(a,b) ((a)+(b))
+-#define luai_numsub(a,b) ((a)-(b))
+-#define luai_nummul(a,b) ((a)*(b))
+-#define luai_numdiv(a,b) ((a)/(b))
+-#define luai_nummod(a,b) ((a) - floor((a)/(b))*(b))
+-#define luai_numpow(a,b) (pow(a,b))
+-#define luai_numunm(a) (-(a))
+-#define luai_numeq(a,b) ((a)==(b))
+-#define luai_numlt(a,b) ((a)<(b))
+-#define luai_numle(a,b) ((a)<=(b))
+-#define luai_numisnan(a) (!luai_numeq((a), (a)))
+-#endif
+-
+-
+-/*
+-@@ lua_number2int is a macro to convert lua_Number to int.
+-@@ lua_number2integer is a macro to convert lua_Number to lua_Integer.
+-** CHANGE them if you know a faster way to convert a lua_Number to
+-** int (with any rounding method and without throwing errors) in your
+-** system. In Pentium machines, a naive typecast from double to int
+-** in C is extremely slow, so any alternative is worth trying.
+-*/
+-
+-/* On a Pentium, resort to a trick */
+-#if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) && !defined(__SSE2__) && \
+- (defined(__i386) || defined (_M_IX86) || defined(__i386__))
+-
+-/* On a Microsoft compiler, use assembler */
+-#if defined(_MSC_VER)
+-
+-#define lua_number2int(i,d) __asm fld d __asm fistp i
+-#define lua_number2integer(i,n) lua_number2int(i, n)
+-
+-/* the next trick should work on any Pentium, but sometimes clashes
+- with a DirectX idiosyncrasy */
+-#else
+-
+-union luai_Cast { double l_d; long l_l; };
+-#define lua_number2int(i,d) \
+- { volatile union luai_Cast u; u.l_d = (d) + 6755399441055744.0; (i) = u.l_l; }
+-#define lua_number2integer(i,n) lua_number2int(i, n)
+-
+-#endif
+-
+-
+-/* this option always works, but may be slow */
+-#else
+-#define lua_number2int(i,d) ((i)=(int)(d))
+-#define lua_number2integer(i,d) ((i)=(lua_Integer)(d))
+-
+-#endif
+-
+-/* }================================================================== */
+-
+-
+ /*
+ @@ LUAI_USER_ALIGNMENT_T is a type that requires maximum alignment.
+ ** CHANGE it if your system requires alignments larger than double. (For
+@@ -728,28 +652,6 @@ union luai_Cast { double l_d; long l_l;
+ #define luai_userstateyield(L,n) ((void)L)
+
+
+-/*
+-@@ LUA_INTFRMLEN is the length modifier for integer conversions
+-@* in 'string.format'.
+-@@ LUA_INTFRM_T is the integer type correspoding to the previous length
+-@* modifier.
+-** CHANGE them if your system supports long long or does not support long.
+-*/
+-
+-#if defined(LUA_USELONGLONG)
+-
+-#define LUA_INTFRMLEN "ll"
+-#define LUA_INTFRM_T long long
+-
+-#else
+-
+-#define LUA_INTFRMLEN "l"
+-#define LUA_INTFRM_T long
+-
+-#endif
+-
+-
+-
+ /* =================================================================== */
+
+ /*
+--- a/src/lundump.c
++++ b/src/lundump.c
+@@ -73,6 +73,13 @@ static lua_Number LoadNumber(LoadState*
+ return x;
+ }
+
++static lua_Integer LoadInteger(LoadState* S)
++{
++ lua_Integer x;
++ LoadVar(S,x);
++ return x;
++}
++
+ static TString* LoadString(LoadState* S)
+ {
+ size_t size;
+@@ -119,6 +126,9 @@ static void LoadConstants(LoadState* S,
+ case LUA_TNUMBER:
+ setnvalue(o,LoadNumber(S));
+ break;
++ case LUA_TINT: /* Integer type saved in bytecode (see lcode.c) */
++ setivalue(o,LoadInteger(S));
++ break;
+ case LUA_TSTRING:
+ setsvalue2n(S->L,o,LoadString(S));
+ break;
+@@ -223,5 +233,22 @@ void luaU_header (char* h)
+ *h++=(char)sizeof(size_t);
+ *h++=(char)sizeof(Instruction);
+ *h++=(char)sizeof(lua_Number);
+- *h++=(char)(((lua_Number)0.5)==0); /* is lua_Number integral? */
++
++ /*
++ * Last byte of header (0/1 in unpatched Lua 5.1.3):
++ *
++ * 0: lua_Number is float or double, lua_Integer not used. (nonpatched only)
++ * 1: lua_Number is integer (nonpatched only)
++ *
++ * +2: LNUM_INT16: sizeof(lua_Integer)
++ * +4: LNUM_INT32: sizeof(lua_Integer)
++ * +8: LNUM_INT64: sizeof(lua_Integer)
++ *
++ * +0x80: LNUM_COMPLEX
++ */
++ *h++ = (char)(sizeof(lua_Integer)
++#ifdef LNUM_COMPLEX
++ | 0x80
++#endif
++ );
+ }
+--- a/src/lvm.c
++++ b/src/lvm.c
+@@ -25,22 +25,35 @@
+ #include "ltable.h"
+ #include "ltm.h"
+ #include "lvm.h"
+-
+-
++#include "llex.h"
++#include "lnum.h"
+
+ /* limit for table tag-method chains (to avoid loops) */
+ #define MAXTAGLOOP 100
+
+
+-const TValue *luaV_tonumber (const TValue *obj, TValue *n) {
+- lua_Number num;
++/*
++ * If 'obj' is a string, it is tried to be interpreted as a number.
++ */
++const TValue *luaV_tonumber ( const TValue *obj, TValue *n) {
++ lua_Number d;
++ lua_Integer i;
++
+ if (ttisnumber(obj)) return obj;
+- if (ttisstring(obj) && luaO_str2d(svalue(obj), &num)) {
+- setnvalue(n, num);
+- return n;
+- }
+- else
+- return NULL;
++
++ if (ttisstring(obj)) {
++ switch( luaO_str2d( svalue(obj), &d, &i ) ) {
++ case TK_INT:
++ setivalue(n,i); return n;
++ case TK_NUMBER:
++ setnvalue(n,d); return n;
++#ifdef LNUM_COMPLEX
++ case TK_NUMBER2: /* "N.NNNi", != 0 */
++ setnvalue_complex_fast(n, d*I); return n;
++#endif
++ }
++ }
++ return NULL;
+ }
+
+
+@@ -49,8 +62,7 @@ int luaV_tostring (lua_State *L, StkId o
+ return 0;
+ else {
+ char s[LUAI_MAXNUMBER2STR];
+- lua_Number n = nvalue(obj);
+- lua_number2str(s, n);
++ luaO_num2buf(s,obj);
+ setsvalue2s(L, obj, luaS_new(L, s));
+ return 1;
+ }
+@@ -222,59 +234,127 @@ static int l_strcmp (const TString *ls,
+ }
+
+
++#ifdef LNUM_COMPLEX
++void error_complex( lua_State *L, const TValue *l, const TValue *r )
++{
++ char buf1[ LUAI_MAXNUMBER2STR ];
++ char buf2[ LUAI_MAXNUMBER2STR ];
++ luaO_num2buf( buf1, l );
++ luaO_num2buf( buf2, r );
++ luaG_runerror( L, "unable to compare: %s with %s", buf1, buf2 );
++ /* no return */
++}
++#endif
++
++
+ int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r) {
+ int res;
+- if (ttype(l) != ttype(r))
++ int tl,tr;
++ lua_Integer tmp;
++
++ if (!ttype_ext_same(l,r))
+ return luaG_ordererror(L, l, r);
+- else if (ttisnumber(l))
+- return luai_numlt(nvalue(l), nvalue(r));
+- else if (ttisstring(l))
+- return l_strcmp(rawtsvalue(l), rawtsvalue(r)) < 0;
+- else if ((res = call_orderTM(L, l, r, TM_LT)) != -1)
++#ifdef LNUM_COMPLEX
++ if ( (nvalue_img(l)!=0) || (nvalue_img(r)!=0) )
++ error_complex( L, l, r );
++#endif
++ tl= ttype(l); tr= ttype(r);
++ if (tl==tr) { /* clear arithmetics */
++ switch(tl) {
++ case LUA_TINT: return ivalue(l) < ivalue(r);
++ case LUA_TNUMBER: return luai_numlt(nvalue_fast(l), nvalue_fast(r));
++ case LUA_TSTRING: return l_strcmp(rawtsvalue(l), rawtsvalue(r)) < 0;
++ }
++ } else if (tl==LUA_TINT) { /* l:int, r:num */
++ /* Avoid accuracy losing casts: if 'r' is integer by value, do comparisons
++ * in integer realm. Only otherwise cast 'l' to FP (which might change its
++ * value).
++ */
++ if (tt_integer_valued(r,&tmp))
++ return ivalue(l) < tmp;
++ else
++ return luai_numlt( cast_num(ivalue(l)), nvalue_fast(r) );
++
++ } else if (tl==LUA_TNUMBER) { /* l:num, r:int */
++ if (tt_integer_valued(l,&tmp))
++ return tmp < ivalue(r);
++ else
++ return luai_numlt( nvalue_fast(l), cast_num(ivalue(r)) );
++
++ } else if ((res = call_orderTM(L, l, r, TM_LT)) != -1)
+ return res;
++
+ return luaG_ordererror(L, l, r);
+ }
+
+
+ static int lessequal (lua_State *L, const TValue *l, const TValue *r) {
+ int res;
+- if (ttype(l) != ttype(r))
++ int tl, tr;
++ lua_Integer tmp;
++
++ if (!ttype_ext_same(l,r))
+ return luaG_ordererror(L, l, r);
+- else if (ttisnumber(l))
+- return luai_numle(nvalue(l), nvalue(r));
+- else if (ttisstring(l))
+- return l_strcmp(rawtsvalue(l), rawtsvalue(r)) <= 0;
+- else if ((res = call_orderTM(L, l, r, TM_LE)) != -1) /* first try `le' */
++#ifdef LNUM_COMPLEX
++ if ( (nvalue_img(l)!=0) || (nvalue_img(r)!=0) )
++ error_complex( L, l, r );
++#endif
++ tl= ttype(l); tr= ttype(r);
++ if (tl==tr) { /* clear arithmetics */
++ switch(tl) {
++ case LUA_TINT: return ivalue(l) <= ivalue(r);
++ case LUA_TNUMBER: return luai_numle(nvalue_fast(l), nvalue_fast(r));
++ case LUA_TSTRING: return l_strcmp(rawtsvalue(l), rawtsvalue(r)) <= 0;
++ }
++ }
++ if (tl==LUA_TINT) { /* l:int, r:num */
++ if (tt_integer_valued(r,&tmp))
++ return ivalue(l) <= tmp;
++ else
++ return luai_numle( cast_num(ivalue(l)), nvalue_fast(r) );
++
++ } else if (tl==LUA_TNUMBER) { /* l:num, r:int */
++ if (tt_integer_valued(l,&tmp))
++ return tmp <= ivalue(r);
++ else
++ return luai_numle( nvalue_fast(l), cast_num(ivalue(r)) );
++
++ } else if ((res = call_orderTM(L, l, r, TM_LE)) != -1) /* first try `le' */
+ return res;
+ else if ((res = call_orderTM(L, r, l, TM_LT)) != -1) /* else try `lt' */
+ return !res;
++
+ return luaG_ordererror(L, l, r);
+ }
+
+
+-int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2) {
++/* Note: 'luaV_equalval()' and 'luaO_rawequalObj()' have largely overlapping
++ * implementation. LUA_TNIL..LUA_TLIGHTUSERDATA cases could be handled
++ * simply by the 'default' case here.
++ */
++int luaV_equalval (lua_State *L, const TValue *l, const TValue *r) {
+ const TValue *tm;
+- lua_assert(ttype(t1) == ttype(t2));
+- switch (ttype(t1)) {
++ lua_assert(ttype_ext_same(l,r));
++ switch (ttype(l)) {
+ case LUA_TNIL: return 1;
+- case LUA_TNUMBER: return luai_numeq(nvalue(t1), nvalue(t2));
+- case LUA_TBOOLEAN: return bvalue(t1) == bvalue(t2); /* true must be 1 !! */
+- case LUA_TLIGHTUSERDATA: return pvalue(t1) == pvalue(t2);
++ case LUA_TINT:
++ case LUA_TNUMBER: return luaO_rawequalObj(l,r);
++ case LUA_TBOOLEAN: return bvalue(l) == bvalue(r); /* true must be 1 !! */
++ case LUA_TLIGHTUSERDATA: return pvalue(l) == pvalue(r);
+ case LUA_TUSERDATA: {
+- if (uvalue(t1) == uvalue(t2)) return 1;
+- tm = get_compTM(L, uvalue(t1)->metatable, uvalue(t2)->metatable,
+- TM_EQ);
++ if (uvalue(l) == uvalue(r)) return 1;
++ tm = get_compTM(L, uvalue(l)->metatable, uvalue(r)->metatable, TM_EQ);
+ break; /* will try TM */
+ }
+ case LUA_TTABLE: {
+- if (hvalue(t1) == hvalue(t2)) return 1;
+- tm = get_compTM(L, hvalue(t1)->metatable, hvalue(t2)->metatable, TM_EQ);
++ if (hvalue(l) == hvalue(r)) return 1;
++ tm = get_compTM(L, hvalue(l)->metatable, hvalue(r)->metatable, TM_EQ);
+ break; /* will try TM */
+ }
+- default: return gcvalue(t1) == gcvalue(t2);
++ default: return gcvalue(l) == gcvalue(r);
+ }
+ if (tm == NULL) return 0; /* no TM? */
+- callTMres(L, L->top, tm, t1, t2); /* call TM */
++ callTMres(L, L->top, tm, l, r); /* call TM */
+ return !l_isfalse(L->top);
+ }
+
+@@ -314,30 +394,6 @@ void luaV_concat (lua_State *L, int tota
+ }
+
+
+-static void Arith (lua_State *L, StkId ra, const TValue *rb,
+- const TValue *rc, TMS op) {
+- TValue tempb, tempc;
+- const TValue *b, *c;
+- if ((b = luaV_tonumber(rb, &tempb)) != NULL &&
+- (c = luaV_tonumber(rc, &tempc)) != NULL) {
+- lua_Number nb = nvalue(b), nc = nvalue(c);
+- switch (op) {
+- case TM_ADD: setnvalue(ra, luai_numadd(nb, nc)); break;
+- case TM_SUB: setnvalue(ra, luai_numsub(nb, nc)); break;
+- case TM_MUL: setnvalue(ra, luai_nummul(nb, nc)); break;
+- case TM_DIV: setnvalue(ra, luai_numdiv(nb, nc)); break;
+- case TM_MOD: setnvalue(ra, luai_nummod(nb, nc)); break;
+- case TM_POW: setnvalue(ra, luai_numpow(nb, nc)); break;
+- case TM_UNM: setnvalue(ra, luai_numunm(nb)); break;
+- default: lua_assert(0); break;
+- }
+- }
+- else if (!call_binTM(L, rb, rc, ra, op))
+- luaG_aritherror(L, rb, rc);
+-}
+-
+-
+-
+ /*
+ ** some macros for common tasks in `luaV_execute'
+ */
+@@ -361,17 +417,154 @@ static void Arith (lua_State *L, StkId r
+ #define Protect(x) { L->savedpc = pc; {x;}; base = L->base; }
+
+
+-#define arith_op(op,tm) { \
+- TValue *rb = RKB(i); \
+- TValue *rc = RKC(i); \
+- if (ttisnumber(rb) && ttisnumber(rc)) { \
+- lua_Number nb = nvalue(rb), nc = nvalue(rc); \
+- setnvalue(ra, op(nb, nc)); \
+- } \
+- else \
+- Protect(Arith(L, ra, rb, rc, tm)); \
++/* Note: if called for unary operations, 'rc'=='rb'.
++ */
++static void Arith (lua_State *L, StkId ra, const TValue *rb,
++ const TValue *rc, TMS op) {
++ TValue tempb, tempc;
++ const TValue *b, *c;
++ lua_Number nb,nc;
++
++ if ((b = luaV_tonumber(rb, &tempb)) != NULL &&
++ (c = luaV_tonumber(rc, &tempc)) != NULL) {
++
++ /* Keep integer arithmetics in the integer realm, if possible.
++ */
++ if (ttisint(b) && ttisint(c)) {
++ lua_Integer ib = ivalue(b), ic = ivalue(c);
++ lua_Integer *ri = &ra->value.i;
++ ra->tt= LUA_TINT; /* part of 'setivalue(ra)' */
++ switch (op) {
++ case TM_ADD: if (try_addint( ri, ib, ic)) return; break;
++ case TM_SUB: if (try_subint( ri, ib, ic)) return; break;
++ case TM_MUL: if (try_mulint( ri, ib, ic)) return; break;
++ case TM_DIV: if (try_divint( ri, ib, ic)) return; break;
++ case TM_MOD: if (try_modint( ri, ib, ic)) return; break;
++ case TM_POW: if (try_powint( ri, ib, ic)) return; break;
++ case TM_UNM: if (try_unmint( ri, ib)) return; break;
++ default: lua_assert(0);
++ }
++ }
++ /* Fallback to floating point, when leaving range. */
++
++#ifdef LNUM_COMPLEX
++ if ((nvalue_img(b)!=0) || (nvalue_img(c)!=0)) {
++ lua_Complex r;
++ if (op==TM_UNM) {
++ r= -nvalue_complex_fast(b); /* never an integer (or scalar) */
++ setnvalue_complex_fast( ra, r );
++ } else {
++ lua_Complex bb= nvalue_complex(b), cc= nvalue_complex(c);
++ switch (op) {
++ case TM_ADD: r= bb + cc; break;
++ case TM_SUB: r= bb - cc; break;
++ case TM_MUL: r= bb * cc; break;
++ case TM_DIV: r= bb / cc; break;
++ case TM_MOD:
++ luaG_runerror(L, "attempt to use %% on complex numbers"); /* no return */
++ case TM_POW: r= luai_vectpow( bb, cc ); break;
++ default: lua_assert(0); r=0;
++ }
++ setnvalue_complex( ra, r );
+ }
++ return;
++ }
++#endif
++ nb = nvalue(b); nc = nvalue(c);
++ switch (op) {
++ case TM_ADD: setnvalue(ra, luai_numadd(nb, nc)); return;
++ case TM_SUB: setnvalue(ra, luai_numsub(nb, nc)); return;
++ case TM_MUL: setnvalue(ra, luai_nummul(nb, nc)); return;
++ case TM_DIV: setnvalue(ra, luai_numdiv(nb, nc)); return;
++ case TM_MOD: setnvalue(ra, luai_nummod(nb, nc)); return;
++ case TM_POW: setnvalue(ra, luai_numpow(nb, nc)); return;
++ case TM_UNM: setnvalue(ra, luai_numunm(nb)); return;
++ default: lua_assert(0);
++ }
++ }
++
++ /* Either operand not a number */
++ if (!call_binTM(L, rb, rc, ra, op))
++ luaG_aritherror(L, rb, rc);
++}
+
++/* Helper macro to sort arithmetic operations into four categories:
++ * TK_INT: integer - integer operands
++ * TK_NUMBER: number - number (non complex, either may be integer)
++ * TK_NUMBER2: complex numbers (at least the other)
++ * 0: non-numeric (at least the other)
++*/
++#ifdef LNUM_COMPLEX
++static inline int arith_mode( const TValue *rb, const TValue *rc ) {
++ if (ttisint(rb) && ttisint(rc)) return TK_INT;
++ if (ttiscomplex(rb) || ttiscomplex(rc)) return TK_NUMBER2;
++ if (ttisnumber(rb) && ttisnumber(rc)) return TK_NUMBER;
++ return 0;
++}
++#else
++# define arith_mode(rb,rc) \
++ ( (ttisint(rb) && ttisint(rc)) ? TK_INT : \
++ (ttisnumber(rb) && ttisnumber(rc)) ? TK_NUMBER : 0 )
++#endif
++
++/* arith_op macro for two operators:
++ * automatically chooses, which function (number, integer, complex) to use
++ */
++#define ARITH_OP2_START( op_num, op_int ) \
++ int failed= 0; \
++ switch( arith_mode(rb,rc) ) { \
++ case TK_INT: \
++ if (op_int ( &(ra)->value.i, ivalue(rb), ivalue(rc) )) \
++ { ra->tt= LUA_TINT; break; } /* else flow through */ \
++ case TK_NUMBER: \
++ setnvalue(ra, op_num ( nvalue(rb), nvalue(rc) )); break;
++
++#define ARITH_OP2_END \
++ default: \
++ failed= 1; break; \
++ } if (!failed) continue;
++
++#define arith_op_continue_scalar( op_num, op_int ) \
++ ARITH_OP2_START( op_num, op_int ) \
++ ARITH_OP2_END
++
++#ifdef LNUM_COMPLEX
++# define arith_op_continue( op_num, op_int, op_complex ) \
++ ARITH_OP2_START( op_num, op_int ) \
++ case TK_NUMBER2: \
++ setnvalue_complex( ra, op_complex ( nvalue_complex(rb), nvalue_complex(rc) ) ); break; \
++ ARITH_OP2_END
++#else
++# define arith_op_continue(op_num,op_int,_) arith_op_continue_scalar(op_num,op_int)
++#endif
++
++/* arith_op macro for one operator:
++ */
++#define ARITH_OP1_START( op_num, op_int ) \
++ int failed= 0; \
++ switch( arith_mode(rb,rb) ) { \
++ case TK_INT: \
++ if (op_int ( &(ra)->value.i, ivalue(rb) )) \
++ { ra->tt= LUA_TINT; break; } /* else flow through */ \
++ case TK_NUMBER: \
++ setnvalue(ra, op_num (nvalue(rb))); break; \
++
++#define ARITH_OP1_END \
++ default: \
++ failed= 1; break; \
++ } if (!failed) continue;
++
++#ifdef LNUM_COMPLEX
++# define arith_op1_continue( op_num, op_int, op_complex ) \
++ ARITH_OP1_START( op_num, op_int ) \
++ case TK_NUMBER2: \
++ setnvalue_complex( ra, op_complex ( nvalue_complex_fast(rb) )); break; \
++ ARITH_OP1_END
++#else
++# define arith_op1_continue( op_num, op_int, _ ) \
++ ARITH_OP1_START( op_num, op_int ) \
++ ARITH_OP1_END
++#endif
+
+
+ void luaV_execute (lua_State *L, int nexeccalls) {
+@@ -472,38 +665,45 @@ void luaV_execute (lua_State *L, int nex
+ continue;
+ }
+ case OP_ADD: {
+- arith_op(luai_numadd, TM_ADD);
++ TValue *rb = RKB(i), *rc= RKC(i);
++ arith_op_continue( luai_numadd, try_addint, luai_vectadd );
++ Protect(Arith(L, ra, rb, rc, TM_ADD)); \
+ continue;
+ }
+ case OP_SUB: {
+- arith_op(luai_numsub, TM_SUB);
++ TValue *rb = RKB(i), *rc= RKC(i);
++ arith_op_continue( luai_numsub, try_subint, luai_vectsub );
++ Protect(Arith(L, ra, rb, rc, TM_SUB));
+ continue;
+ }
+ case OP_MUL: {
+- arith_op(luai_nummul, TM_MUL);
++ TValue *rb = RKB(i), *rc= RKC(i);
++ arith_op_continue(luai_nummul, try_mulint, luai_vectmul);
++ Protect(Arith(L, ra, rb, rc, TM_MUL));
+ continue;
+ }
+ case OP_DIV: {
+- arith_op(luai_numdiv, TM_DIV);
++ TValue *rb = RKB(i), *rc= RKC(i);
++ arith_op_continue(luai_numdiv, try_divint, luai_vectdiv);
++ Protect(Arith(L, ra, rb, rc, TM_DIV));
+ continue;
+ }
+ case OP_MOD: {
+- arith_op(luai_nummod, TM_MOD);
++ TValue *rb = RKB(i), *rc= RKC(i);
++ arith_op_continue_scalar(luai_nummod, try_modint); /* scalars only */
++ Protect(Arith(L, ra, rb, rc, TM_MOD));
+ continue;
+ }
+ case OP_POW: {
+- arith_op(luai_numpow, TM_POW);
++ TValue *rb = RKB(i), *rc= RKC(i);
++ arith_op_continue(luai_numpow, try_powint, luai_vectpow);
++ Protect(Arith(L, ra, rb, rc, TM_POW));
+ continue;
+ }
+ case OP_UNM: {
+ TValue *rb = RB(i);
+- if (ttisnumber(rb)) {
+- lua_Number nb = nvalue(rb);
+- setnvalue(ra, luai_numunm(nb));
+- }
+- else {
+- Protect(Arith(L, ra, rb, rb, TM_UNM));
+- }
++ arith_op1_continue(luai_numunm, try_unmint, luai_vectunm);
++ Protect(Arith(L, ra, rb, rb, TM_UNM));
+ continue;
+ }
+ case OP_NOT: {
+@@ -515,11 +715,11 @@ void luaV_execute (lua_State *L, int nex
+ const TValue *rb = RB(i);
+ switch (ttype(rb)) {
+ case LUA_TTABLE: {
+- setnvalue(ra, cast_num(luaH_getn(hvalue(rb))));
++ setivalue(ra, luaH_getn(hvalue(rb)));
+ break;
+ }
+ case LUA_TSTRING: {
+- setnvalue(ra, cast_num(tsvalue(rb)->len));
++ setivalue(ra, tsvalue(rb)->len);
+ break;
+ }
+ default: { /* try metamethod */
+@@ -652,14 +852,30 @@ void luaV_execute (lua_State *L, int nex
+ }
+ }
+ case OP_FORLOOP: {
+- lua_Number step = nvalue(ra+2);
+- lua_Number idx = luai_numadd(nvalue(ra), step); /* increment index */
+- lua_Number limit = nvalue(ra+1);
+- if (luai_numlt(0, step) ? luai_numle(idx, limit)
+- : luai_numle(limit, idx)) {
+- dojump(L, pc, GETARG_sBx(i)); /* jump back */
+- setnvalue(ra, idx); /* update internal index... */
+- setnvalue(ra+3, idx); /* ...and external index */
++ /* If start,step and limit are all integers, we don't need to check
++ * against overflow in the looping.
++ */
++ if (ttisint(ra) && ttisint(ra+1) && ttisint(ra+2)) {
++ lua_Integer step = ivalue(ra+2);
++ lua_Integer idx = ivalue(ra) + step; /* increment index */
++ lua_Integer limit = ivalue(ra+1);
++ if (step > 0 ? (idx <= limit) : (limit <= idx)) {
++ dojump(L, pc, GETARG_sBx(i)); /* jump back */
++ setivalue(ra, idx); /* update internal index... */
++ setivalue(ra+3, idx); /* ...and external index */
++ }
++ } else {
++ /* non-integer looping (don't use 'nvalue_fast', some may be integer!)
++ */
++ lua_Number step = nvalue(ra+2);
++ lua_Number idx = luai_numadd(nvalue(ra), step); /* increment index */
++ lua_Number limit = nvalue(ra+1);
++ if (luai_numlt(0, step) ? luai_numle(idx, limit)
++ : luai_numle(limit, idx)) {
++ dojump(L, pc, GETARG_sBx(i)); /* jump back */
++ setnvalue(ra, idx); /* update internal index... */
++ setnvalue(ra+3, idx); /* ...and external index */
++ }
+ }
+ continue;
+ }
+@@ -668,13 +884,21 @@ void luaV_execute (lua_State *L, int nex
+ const TValue *plimit = ra+1;
+ const TValue *pstep = ra+2;
+ L->savedpc = pc; /* next steps may throw errors */
++ /* Using same location for tonumber's both arguments, effectively does
++ * in-place modification (string->number). */
+ if (!tonumber(init, ra))
+ luaG_runerror(L, LUA_QL("for") " initial value must be a number");
+ else if (!tonumber(plimit, ra+1))
+ luaG_runerror(L, LUA_QL("for") " limit must be a number");
+ else if (!tonumber(pstep, ra+2))
+ luaG_runerror(L, LUA_QL("for") " step must be a number");
+- setnvalue(ra, luai_numsub(nvalue(ra), nvalue(pstep)));
++ /* Step back one value (keep within integers if we can)
++ */
++ if (!( ttisint(ra) && ttisint(pstep) &&
++ try_subint( &ra->value.i, ivalue(ra), ivalue(pstep) ) )) {
++ /* don't use 'nvalue_fast()', values may be integer */
++ setnvalue(ra, luai_numsub(nvalue(ra), nvalue(pstep)));
++ }
+ dojump(L, pc, GETARG_sBx(i));
+ continue;
+ }
+@@ -711,7 +935,7 @@ void luaV_execute (lua_State *L, int nex
+ luaH_resizearray(L, h, last); /* pre-alloc it at once */
+ for (; n > 0; n--) {
+ TValue *val = ra+n;
+- setobj2t(L, luaH_setnum(L, h, last--), val);
++ setobj2t(L, luaH_setint(L, h, last--), val);
+ luaC_barriert(L, h, val);
+ }
+ continue;
+--- a/src/lvm.h
++++ b/src/lvm.h
+@@ -15,11 +15,9 @@
+
+ #define tostring(L,o) ((ttype(o) == LUA_TSTRING) || (luaV_tostring(L, o)))
+
+-#define tonumber(o,n) (ttype(o) == LUA_TNUMBER || \
+- (((o) = luaV_tonumber(o,n)) != NULL))
++#define tonumber(o,n) (ttisnumber(o) || (((o) = luaV_tonumber(o,n)) != NULL))
+
+-#define equalobj(L,o1,o2) \
+- (ttype(o1) == ttype(o2) && luaV_equalval(L, o1, o2))
++#define equalobj(L,o1,o2) (ttype_ext_same(o1,o2) && luaV_equalval(L, o1, o2))
+
+
+ LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r);
+--- a/src/print.c
++++ b/src/print.c
+@@ -14,6 +14,7 @@
+ #include "lobject.h"
+ #include "lopcodes.h"
+ #include "lundump.h"
++#include "lnum.h"
+
+ #define PrintFunction luaU_print
+
+@@ -59,8 +60,16 @@ static void PrintConstant(const Proto* f
+ case LUA_TBOOLEAN:
+ printf(bvalue(o) ? "true" : "false");
+ break;
++ case LUA_TINT:
++ printf(LUA_INTEGER_FMT,ivalue(o));
++ break;
+ case LUA_TNUMBER:
+- printf(LUA_NUMBER_FMT,nvalue(o));
++#ifdef LNUM_COMPLEX
++ // TBD: Do we get complex values here?
++ { lua_Number b= nvalue_img_fast(o);
++ printf( LUA_NUMBER_FMT "%s" LUA_NUMBER_FMT "i", nvalue_fast(o), b>=0 ? "+":"", b ); }
++#endif
++ printf(LUA_NUMBER_FMT,nvalue_fast(o));
+ break;
+ case LUA_TSTRING:
+ PrintString(rawtsvalue(o));
diff --git a/package/lua/patches/.svn/text-base/011-lnum-use-double.patch.svn-base b/package/lua/patches/.svn/text-base/011-lnum-use-double.patch.svn-base
new file mode 100644
index 0000000..14c720b
--- /dev/null
+++ b/package/lua/patches/.svn/text-base/011-lnum-use-double.patch.svn-base
@@ -0,0 +1,11 @@
+--- a/src/lnum_config.h
++++ b/src/lnum_config.h
+@@ -11,7 +11,7 @@
+ ** Default number modes
+ */
+ #if (!defined LNUM_DOUBLE) && (!defined LNUM_FLOAT) && (!defined LNUM_LDOUBLE)
+-# define LNUM_FLOAT
++# define LNUM_DOUBLE
+ #endif
+ #if (!defined LNUM_INT16) && (!defined LNUM_INT32) && (!defined LNUM_INT64)
+ # define LNUM_INT32
diff --git a/package/lua/patches/.svn/text-base/015-lnum-ppc-compat.patch.svn-base b/package/lua/patches/.svn/text-base/015-lnum-ppc-compat.patch.svn-base
new file mode 100644
index 0000000..2ea59f1
--- /dev/null
+++ b/package/lua/patches/.svn/text-base/015-lnum-ppc-compat.patch.svn-base
@@ -0,0 +1,11 @@
+--- a/src/lua.h
++++ b/src/lua.h
+@@ -79,7 +79,7 @@ typedef void * (*lua_Alloc) (void *ud, v
+ * not acceptable for 5.1, maybe 5.2 onwards?
+ * 9: greater than existing (5.1) type values.
+ */
+-#define LUA_TINT (-2)
++#define LUA_TINT 9
+
+ #define LUA_TNIL 0
+ #define LUA_TBOOLEAN 1
diff --git a/package/lua/patches/.svn/text-base/020-shared_liblua.patch.svn-base b/package/lua/patches/.svn/text-base/020-shared_liblua.patch.svn-base
new file mode 100644
index 0000000..bcd410f
--- /dev/null
+++ b/package/lua/patches/.svn/text-base/020-shared_liblua.patch.svn-base
@@ -0,0 +1,140 @@
+--- a/Makefile
++++ b/Makefile
+@@ -42,8 +42,8 @@ PLATS= aix ansi bsd freebsd generic linu
+
+ # What to install.
+ TO_BIN= lua luac
+-TO_INC= lua.h luaconf.h lualib.h lauxlib.h ../etc/lua.hpp
+-TO_LIB= liblua.a
++TO_INC= lua.h luaconf.h lualib.h lauxlib.h ../etc/lua.hpp lnum_config.h
++TO_LIB= liblua.a liblua.so.$R
+ TO_MAN= lua.1 luac.1
+
+ # Lua version and release.
+@@ -63,6 +63,7 @@ install: dummy
+ cd src && $(INSTALL_EXEC) $(TO_BIN) $(INSTALL_BIN)
+ cd src && $(INSTALL_DATA) $(TO_INC) $(INSTALL_INC)
+ cd src && $(INSTALL_DATA) $(TO_LIB) $(INSTALL_LIB)
++ ln -s liblua.so.$R $(INSTALL_LIB)/liblua.so
+ cd doc && $(INSTALL_DATA) $(TO_MAN) $(INSTALL_MAN)
+
+ ranlib:
+--- a/src/ldo.h
++++ b/src/ldo.h
+@@ -46,7 +46,7 @@ LUAI_FUNC int luaD_pcall (lua_State *L,
+ LUAI_FUNC int luaD_poscall (lua_State *L, StkId firstResult);
+ LUAI_FUNC void luaD_reallocCI (lua_State *L, int newsize);
+ LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize);
+-LUAI_FUNC void luaD_growstack (lua_State *L, int n);
++LUA_API void luaD_growstack (lua_State *L, int n);
+
+ LUAI_FUNC void luaD_throw (lua_State *L, int errcode);
+ LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud);
+--- a/src/lfunc.h
++++ b/src/lfunc.h
+@@ -18,7 +18,7 @@
+ cast(int, sizeof(TValue *)*((n)-1)))
+
+
+-LUAI_FUNC Proto *luaF_newproto (lua_State *L);
++LUA_API Proto *luaF_newproto (lua_State *L);
+ LUAI_FUNC Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e);
+ LUAI_FUNC Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e);
+ LUAI_FUNC UpVal *luaF_newupval (lua_State *L);
+--- a/src/lmem.h
++++ b/src/lmem.h
+@@ -38,9 +38,9 @@
+ ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t))))
+
+
+-LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize,
++LUA_API void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize,
+ size_t size);
+-LUAI_FUNC void *luaM_toobig (lua_State *L);
++LUA_API void *luaM_toobig (lua_State *L);
+ LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size,
+ size_t size_elem, int limit,
+ const char *errormsg);
+--- a/src/lstring.h
++++ b/src/lstring.h
+@@ -25,7 +25,7 @@
+
+ LUAI_FUNC void luaS_resize (lua_State *L, int newsize);
+ LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, Table *e);
+-LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l);
++LUA_API TString *luaS_newlstr (lua_State *L, const char *str, size_t l);
+
+
+ #endif
+--- a/src/lundump.h
++++ b/src/lundump.h
+@@ -17,7 +17,7 @@ LUAI_FUNC Proto* luaU_undump (lua_State*
+ LUAI_FUNC void luaU_header (char* h);
+
+ /* dump one chunk; from ldump.c */
+-LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip);
++LUA_API int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip);
+
+ #ifdef luac_c
+ /* print one chunk; from print.c */
+--- a/src/Makefile
++++ b/src/Makefile
+@@ -23,6 +23,7 @@ MYLIBS=
+ PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris
+
+ LUA_A= liblua.a
++LUA_SO= liblua.so
+ CORE_O= lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o \
+ lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o \
+ lundump.o lvm.o lzio.o lnum.o
+@@ -33,11 +34,12 @@ LUA_T= lua
+ LUA_O= lua.o
+
+ LUAC_T= luac
+-LUAC_O= luac.o print.o
++LUAC_O= luac.o print.o lopcodes.o
+
+ ALL_O= $(CORE_O) $(LIB_O) $(LUA_O) $(LUAC_O)
+-ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T)
++ALL_T= $(LUA_A) $(LUA_SO) $(LUA_T) $(LUAC_T)
+ ALL_A= $(LUA_A)
++ALL_SO= $(LUA_SO)
+
+ default: $(PLAT)
+
+@@ -47,14 +49,23 @@ o: $(ALL_O)
+
+ a: $(ALL_A)
+
++so: $(ALL_SO)
++
+ $(LUA_A): $(CORE_O) $(LIB_O)
+ $(AR) $@ $(CORE_O) $(LIB_O) # DLL needs all object files
+ $(RANLIB) $@
+
+-$(LUA_T): $(LUA_O) $(LUA_A)
+- $(CC) -o $@ $(MYLDFLAGS) $(LUA_O) $(LUA_A) $(LIBS)
++$(LUA_SO): $(CORE_O) $(LIB_O)
++ $(CC) -o $@.$(PKG_VERSION) -shared -Wl,-soname="$@.$(PKG_VERSION)" $?
++ ln -fs $@.$(PKG_VERSION) $@
++
++$(LUA_T): $(LUA_O) $(LUA_SO)
++ $(CC) -o $@ -L. -llua $(MYLDFLAGS) $(LUA_O) $(LIBS)
++
++$(LUAC_T): $(LUAC_O) $(LUA_SO)
++ $(CC) -o $@ -L. -llua $(MYLDFLAGS) $(LUAC_O) $(LIBS)
+
+-$(LUAC_T): $(LUAC_O) $(LUA_A)
++$(LUAC_T)-host: $(LUAC_O) $(LUA_A)
+ $(CC) -o $@ $(MYLDFLAGS) $(LUAC_O) $(LUA_A) $(LIBS)
+
+ clean:
+@@ -96,7 +107,7 @@ generic:
+ $(MAKE) all MYCFLAGS=
+
+ linux:
+- $(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-Wl,-E -ldl -lreadline -lhistory -lncurses"
++ $(MAKE) all MYCFLAGS+=-DLUA_USE_LINUX MYLIBS="-Wl,-E -ldl -lreadline -lhistory -lncurses"
+
+ macosx:
+ $(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-lreadline"
diff --git a/package/lua/patches/.svn/text-base/030-archindependent-bytecode.patch.svn-base b/package/lua/patches/.svn/text-base/030-archindependent-bytecode.patch.svn-base
new file mode 100644
index 0000000..8dfef85
--- /dev/null
+++ b/package/lua/patches/.svn/text-base/030-archindependent-bytecode.patch.svn-base
@@ -0,0 +1,111 @@
+--- a/src/ldump.c
++++ b/src/ldump.c
+@@ -67,12 +67,12 @@ static void DumpString(const TString* s,
+ {
+ if (s==NULL || getstr(s)==NULL)
+ {
+- size_t size=0;
++ unsigned int size=0;
+ DumpVar(size,D);
+ }
+ else
+ {
+- size_t size=s->tsv.len+1; /* include trailing '\0' */
++ unsigned int size=s->tsv.len+1; /* include trailing '\0' */
+ DumpVar(size,D);
+ DumpBlock(getstr(s),size,D);
+ }
+--- a/src/lundump.c
++++ b/src/lundump.c
+@@ -25,6 +25,7 @@ typedef struct {
+ ZIO* Z;
+ Mbuffer* b;
+ const char* name;
++ int swap;
+ } LoadState;
+
+ #ifdef LUAC_TRUST_BINARIES
+@@ -40,7 +41,6 @@ static void error(LoadState* S, const ch
+ }
+ #endif
+
+-#define LoadMem(S,b,n,size) LoadBlock(S,b,(n)*(size))
+ #define LoadByte(S) (lu_byte)LoadChar(S)
+ #define LoadVar(S,x) LoadMem(S,&x,1,sizeof(x))
+ #define LoadVector(S,b,n,size) LoadMem(S,b,n,size)
+@@ -51,6 +51,49 @@ static void LoadBlock(LoadState* S, void
+ IF (r!=0, "unexpected end");
+ }
+
++static void LoadMem (LoadState* S, void* b, int n, size_t size)
++{
++ LoadBlock(S,b,n*size);
++ if (S->swap)
++ {
++ char* p=(char*) b;
++ char c;
++ switch (size)
++ {
++ case 1:
++ break;
++ case 2:
++ while (n--)
++ {
++ c=p[0]; p[0]=p[1]; p[1]=c;
++ p+=2;
++ }
++ break;
++ case 4:
++ while (n--)
++ {
++ c=p[0]; p[0]=p[3]; p[3]=c;
++ c=p[1]; p[1]=p[2]; p[2]=c;
++ p+=4;
++ }
++ break;
++ case 8:
++ while (n--)
++ {
++ c=p[0]; p[0]=p[7]; p[7]=c;
++ c=p[1]; p[1]=p[6]; p[6]=c;
++ c=p[2]; p[2]=p[5]; p[5]=c;
++ c=p[3]; p[3]=p[4]; p[4]=c;
++ p+=8;
++ }
++ break;
++ default:
++ IF(1, "bad size");
++ break;
++ }
++ }
++}
++
+ static int LoadChar(LoadState* S)
+ {
+ char x;
+@@ -82,7 +125,7 @@ static lua_Integer LoadInteger(LoadState
+
+ static TString* LoadString(LoadState* S)
+ {
+- size_t size;
++ unsigned int size;
+ LoadVar(S,size);
+ if (size==0)
+ return NULL;
+@@ -196,6 +239,7 @@ static void LoadHeader(LoadState* S)
+ char s[LUAC_HEADERSIZE];
+ luaU_header(h);
+ LoadBlock(S,s,LUAC_HEADERSIZE);
++ S->swap=(s[6]!=h[6]); s[6]=h[6];
+ IF (memcmp(h,s,LUAC_HEADERSIZE)!=0, "bad header");
+ }
+
+@@ -230,7 +274,7 @@ void luaU_header (char* h)
+ *h++=(char)LUAC_FORMAT;
+ *h++=(char)*(char*)&x; /* endianness */
+ *h++=(char)sizeof(int);
+- *h++=(char)sizeof(size_t);
++ *h++=(char)sizeof(unsigned int);
+ *h++=(char)sizeof(Instruction);
+ *h++=(char)sizeof(lua_Number);
+
diff --git a/package/lua/patches/.svn/text-base/100-no_readline.patch.svn-base b/package/lua/patches/.svn/text-base/100-no_readline.patch.svn-base
new file mode 100644
index 0000000..0350e47
--- /dev/null
+++ b/package/lua/patches/.svn/text-base/100-no_readline.patch.svn-base
@@ -0,0 +1,49 @@
+--- a/src/luaconf.h
++++ b/src/luaconf.h
+@@ -38,7 +38,6 @@
+ #if defined(LUA_USE_LINUX)
+ #define LUA_USE_POSIX
+ #define LUA_USE_DLOPEN /* needs an extra library: -ldl */
+-#define LUA_USE_READLINE /* needs some extra libraries */
+ #endif
+
+ #if defined(LUA_USE_MACOSX)
+--- a/src/Makefile
++++ b/src/Makefile
+@@ -17,6 +17,7 @@ LIBS= -lm $(MYLIBS)
+ MYCFLAGS=
+ MYLDFLAGS=
+ MYLIBS=
++# USE_READLINE=1
+
+ # == END OF USER SETTINGS. NO NEED TO CHANGE ANYTHING BELOW THIS LINE =========
+
+@@ -86,7 +87,7 @@ echo:
+ @echo "MYLIBS = $(MYLIBS)"
+
+ # convenience targets for popular platforms
+-
++RFLAG=$(if $(USE_READLINE),-DLUA_USE_READLINE)
+ none:
+ @echo "Please choose a platform:"
+ @echo " $(PLATS)"
+@@ -101,16 +102,16 @@ bsd:
+ $(MAKE) all MYCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-Wl,-E"
+
+ freebsd:
+- $(MAKE) all MYCFLAGS="-DLUA_USE_LINUX" MYLIBS="-Wl,-E -lreadline"
++ $(MAKE) all MYCFLAGS="-DLUA_USE_LINUX $(RFLAG)" MYLIBS="-Wl,-E$(if $(USE_READLINE), -lreadline)"
+
+ generic:
+ $(MAKE) all MYCFLAGS=
+
+ linux:
+- $(MAKE) all MYCFLAGS+=-DLUA_USE_LINUX MYLIBS="-Wl,-E -ldl -lreadline -lhistory -lncurses"
++ $(MAKE) all MYCFLAGS+="-DLUA_USE_LINUX $(RFLAG)" MYLIBS="-Wl,-E -ldl $(if $(USE_READLINE), -lreadline -lhistory -lncurses)"
+
+ macosx:
+- $(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-lreadline"
++ $(MAKE) all MYCFLAGS=-DLUA_USE_LINUX $(if $(USE_READLINE), MYLIBS="-lreadline")
+ # use this on Mac OS X 10.3-
+ # $(MAKE) all MYCFLAGS=-DLUA_USE_MACOSX
+
diff --git a/package/lua/patches/.svn/text-base/200-lua-path.patch.svn-base b/package/lua/patches/.svn/text-base/200-lua-path.patch.svn-base
new file mode 100644
index 0000000..0544577
--- /dev/null
+++ b/package/lua/patches/.svn/text-base/200-lua-path.patch.svn-base
@@ -0,0 +1,15 @@
+--- a/src/luaconf.h
++++ b/src/luaconf.h
+@@ -95,9 +95,9 @@
+ ".\\?.dll;" LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll"
+
+ #else
+-#define LUA_ROOT "/usr/local/"
+-#define LUA_LDIR LUA_ROOT "share/lua/5.1/"
+-#define LUA_CDIR LUA_ROOT "lib/lua/5.1/"
++#define LUA_ROOT "/usr/"
++#define LUA_LDIR LUA_ROOT "share/lua/"
++#define LUA_CDIR LUA_ROOT "lib/lua/"
+ #define LUA_PATH_DEFAULT \
+ "./?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \
+ LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua"
diff --git a/package/lua/patches/.svn/text-base/300-opcode_performance.patch.svn-base b/package/lua/patches/.svn/text-base/300-opcode_performance.patch.svn-base
new file mode 100644
index 0000000..5fbb873
--- /dev/null
+++ b/package/lua/patches/.svn/text-base/300-opcode_performance.patch.svn-base
@@ -0,0 +1,363 @@
+--- a/src/lvm.c
++++ b/src/lvm.c
+@@ -31,6 +31,9 @@
+ /* limit for table tag-method chains (to avoid loops) */
+ #define MAXTAGLOOP 100
+
++#ifdef __GNUC__
++#define COMPUTED_GOTO 1
++#endif
+
+ /*
+ * If 'obj' is a string, it is tried to be interpreted as a number.
+@@ -566,12 +569,63 @@ static inline int arith_mode( const TVal
+ ARITH_OP1_END
+ #endif
+
++#ifdef COMPUTED_GOTO
++#define OPCODE_TARGET(op) DO_OP_##op:
++#define CALL_OPCODE(op) goto *opcodes[op];
++#define OPCODE_PTR(op) [OP_##op] = &&DO_OP_##op
++#else
++#define OPCODE_TARGET(op) case OP_##op:
++#define CALL_OPCODE(op) switch (op)
++#endif
++
+
+ void luaV_execute (lua_State *L, int nexeccalls) {
+ LClosure *cl;
+ StkId base;
+ TValue *k;
+ const Instruction *pc;
++#ifdef COMPUTED_GOTO
++ static const void *opcodes[] = {
++ OPCODE_PTR(MOVE),
++ OPCODE_PTR(LOADK),
++ OPCODE_PTR(LOADBOOL),
++ OPCODE_PTR(LOADNIL),
++ OPCODE_PTR(GETUPVAL),
++ OPCODE_PTR(GETGLOBAL),
++ OPCODE_PTR(GETTABLE),
++ OPCODE_PTR(SETGLOBAL),
++ OPCODE_PTR(SETUPVAL),
++ OPCODE_PTR(SETTABLE),
++ OPCODE_PTR(NEWTABLE),
++ OPCODE_PTR(SELF),
++ OPCODE_PTR(ADD),
++ OPCODE_PTR(SUB),
++ OPCODE_PTR(MUL),
++ OPCODE_PTR(DIV),
++ OPCODE_PTR(MOD),
++ OPCODE_PTR(POW),
++ OPCODE_PTR(UNM),
++ OPCODE_PTR(NOT),
++ OPCODE_PTR(LEN),
++ OPCODE_PTR(CONCAT),
++ OPCODE_PTR(JMP),
++ OPCODE_PTR(EQ),
++ OPCODE_PTR(LT),
++ OPCODE_PTR(LE),
++ OPCODE_PTR(TEST),
++ OPCODE_PTR(TESTSET),
++ OPCODE_PTR(CALL),
++ OPCODE_PTR(TAILCALL),
++ OPCODE_PTR(RETURN),
++ OPCODE_PTR(FORLOOP),
++ OPCODE_PTR(FORPREP),
++ OPCODE_PTR(TFORLOOP),
++ OPCODE_PTR(SETLIST),
++ OPCODE_PTR(CLOSE),
++ OPCODE_PTR(CLOSURE),
++ OPCODE_PTR(VARARG)
++ };
++#endif
+ reentry: /* entry point */
+ lua_assert(isLua(L->ci));
+ pc = L->savedpc;
+@@ -596,33 +650,33 @@ void luaV_execute (lua_State *L, int nex
+ lua_assert(base == L->base && L->base == L->ci->base);
+ lua_assert(base <= L->top && L->top <= L->stack + L->stacksize);
+ lua_assert(L->top == L->ci->top || luaG_checkopenop(i));
+- switch (GET_OPCODE(i)) {
+- case OP_MOVE: {
++ CALL_OPCODE(GET_OPCODE(i)) {
++ OPCODE_TARGET(MOVE) {
+ setobjs2s(L, ra, RB(i));
+ continue;
+ }
+- case OP_LOADK: {
++ OPCODE_TARGET(LOADK) {
+ setobj2s(L, ra, KBx(i));
+ continue;
+ }
+- case OP_LOADBOOL: {
++ OPCODE_TARGET(LOADBOOL) {
+ setbvalue(ra, GETARG_B(i));
+ if (GETARG_C(i)) pc++; /* skip next instruction (if C) */
+ continue;
+ }
+- case OP_LOADNIL: {
++ OPCODE_TARGET(LOADNIL) {
+ TValue *rb = RB(i);
+ do {
+ setnilvalue(rb--);
+ } while (rb >= ra);
+ continue;
+ }
+- case OP_GETUPVAL: {
++ OPCODE_TARGET(GETUPVAL) {
+ int b = GETARG_B(i);
+ setobj2s(L, ra, cl->upvals[b]->v);
+ continue;
+ }
+- case OP_GETGLOBAL: {
++ OPCODE_TARGET(GETGLOBAL) {
+ TValue g;
+ TValue *rb = KBx(i);
+ sethvalue(L, &g, cl->env);
+@@ -630,88 +684,88 @@ void luaV_execute (lua_State *L, int nex
+ Protect(luaV_gettable(L, &g, rb, ra));
+ continue;
+ }
+- case OP_GETTABLE: {
++ OPCODE_TARGET(GETTABLE) {
+ Protect(luaV_gettable(L, RB(i), RKC(i), ra));
+ continue;
+ }
+- case OP_SETGLOBAL: {
++ OPCODE_TARGET(SETGLOBAL) {
+ TValue g;
+ sethvalue(L, &g, cl->env);
+ lua_assert(ttisstring(KBx(i)));
+ Protect(luaV_settable(L, &g, KBx(i), ra));
+ continue;
+ }
+- case OP_SETUPVAL: {
++ OPCODE_TARGET(SETUPVAL) {
+ UpVal *uv = cl->upvals[GETARG_B(i)];
+ setobj(L, uv->v, ra);
+ luaC_barrier(L, uv, ra);
+ continue;
+ }
+- case OP_SETTABLE: {
++ OPCODE_TARGET(SETTABLE) {
+ Protect(luaV_settable(L, ra, RKB(i), RKC(i)));
+ continue;
+ }
+- case OP_NEWTABLE: {
++ OPCODE_TARGET(NEWTABLE) {
+ int b = GETARG_B(i);
+ int c = GETARG_C(i);
+ sethvalue(L, ra, luaH_new(L, luaO_fb2int(b), luaO_fb2int(c)));
+ Protect(luaC_checkGC(L));
+ continue;
+ }
+- case OP_SELF: {
++ OPCODE_TARGET(SELF) {
+ StkId rb = RB(i);
+ setobjs2s(L, ra+1, rb);
+ Protect(luaV_gettable(L, rb, RKC(i), ra));
+ continue;
+ }
+- case OP_ADD: {
++ OPCODE_TARGET(ADD) {
+ TValue *rb = RKB(i), *rc= RKC(i);
+ arith_op_continue( luai_numadd, try_addint, luai_vectadd );
+ Protect(Arith(L, ra, rb, rc, TM_ADD)); \
+ continue;
+ }
+- case OP_SUB: {
++ OPCODE_TARGET(SUB) {
+ TValue *rb = RKB(i), *rc= RKC(i);
+ arith_op_continue( luai_numsub, try_subint, luai_vectsub );
+ Protect(Arith(L, ra, rb, rc, TM_SUB));
+ continue;
+ }
+- case OP_MUL: {
++ OPCODE_TARGET(MUL) {
+ TValue *rb = RKB(i), *rc= RKC(i);
+ arith_op_continue(luai_nummul, try_mulint, luai_vectmul);
+ Protect(Arith(L, ra, rb, rc, TM_MUL));
+ continue;
+ }
+- case OP_DIV: {
++ OPCODE_TARGET(DIV) {
+ TValue *rb = RKB(i), *rc= RKC(i);
+ arith_op_continue(luai_numdiv, try_divint, luai_vectdiv);
+ Protect(Arith(L, ra, rb, rc, TM_DIV));
+ continue;
+ }
+- case OP_MOD: {
++ OPCODE_TARGET(MOD) {
+ TValue *rb = RKB(i), *rc= RKC(i);
+ arith_op_continue_scalar(luai_nummod, try_modint); /* scalars only */
+ Protect(Arith(L, ra, rb, rc, TM_MOD));
+ continue;
+ }
+- case OP_POW: {
++ OPCODE_TARGET(POW) {
+ TValue *rb = RKB(i), *rc= RKC(i);
+ arith_op_continue(luai_numpow, try_powint, luai_vectpow);
+ Protect(Arith(L, ra, rb, rc, TM_POW));
+ continue;
+ }
+- case OP_UNM: {
++ OPCODE_TARGET(UNM) {
+ TValue *rb = RB(i);
+ arith_op1_continue(luai_numunm, try_unmint, luai_vectunm);
+ Protect(Arith(L, ra, rb, rb, TM_UNM));
+ continue;
+ }
+- case OP_NOT: {
++ OPCODE_TARGET(NOT) {
+ int res = l_isfalse(RB(i)); /* next assignment may change this value */
+ setbvalue(ra, res);
+ continue;
+ }
+- case OP_LEN: {
++ OPCODE_TARGET(LEN) {
+ const TValue *rb = RB(i);
+ switch (ttype(rb)) {
+ case LUA_TTABLE: {
+@@ -731,18 +785,18 @@ void luaV_execute (lua_State *L, int nex
+ }
+ continue;
+ }
+- case OP_CONCAT: {
++ OPCODE_TARGET(CONCAT) {
+ int b = GETARG_B(i);
+ int c = GETARG_C(i);
+ Protect(luaV_concat(L, c-b+1, c); luaC_checkGC(L));
+ setobjs2s(L, RA(i), base+b);
+ continue;
+ }
+- case OP_JMP: {
++ OPCODE_TARGET(JMP) {
+ dojump(L, pc, GETARG_sBx(i));
+ continue;
+ }
+- case OP_EQ: {
++ OPCODE_TARGET(EQ) {
+ TValue *rb = RKB(i);
+ TValue *rc = RKC(i);
+ Protect(
+@@ -752,7 +806,7 @@ void luaV_execute (lua_State *L, int nex
+ pc++;
+ continue;
+ }
+- case OP_LT: {
++ OPCODE_TARGET(LT) {
+ Protect(
+ if (luaV_lessthan(L, RKB(i), RKC(i)) == GETARG_A(i))
+ dojump(L, pc, GETARG_sBx(*pc));
+@@ -760,7 +814,7 @@ void luaV_execute (lua_State *L, int nex
+ pc++;
+ continue;
+ }
+- case OP_LE: {
++ OPCODE_TARGET(LE) {
+ Protect(
+ if (lessequal(L, RKB(i), RKC(i)) == GETARG_A(i))
+ dojump(L, pc, GETARG_sBx(*pc));
+@@ -768,13 +822,13 @@ void luaV_execute (lua_State *L, int nex
+ pc++;
+ continue;
+ }
+- case OP_TEST: {
++ OPCODE_TARGET(TEST) {
+ if (l_isfalse(ra) != GETARG_C(i))
+ dojump(L, pc, GETARG_sBx(*pc));
+ pc++;
+ continue;
+ }
+- case OP_TESTSET: {
++ OPCODE_TARGET(TESTSET) {
+ TValue *rb = RB(i);
+ if (l_isfalse(rb) != GETARG_C(i)) {
+ setobjs2s(L, ra, rb);
+@@ -783,7 +837,7 @@ void luaV_execute (lua_State *L, int nex
+ pc++;
+ continue;
+ }
+- case OP_CALL: {
++ OPCODE_TARGET(CALL) {
+ int b = GETARG_B(i);
+ int nresults = GETARG_C(i) - 1;
+ if (b != 0) L->top = ra+b; /* else previous instruction set top */
+@@ -804,7 +858,7 @@ void luaV_execute (lua_State *L, int nex
+ }
+ }
+ }
+- case OP_TAILCALL: {
++ OPCODE_TARGET(TAILCALL) {
+ int b = GETARG_B(i);
+ if (b != 0) L->top = ra+b; /* else previous instruction set top */
+ L->savedpc = pc;
+@@ -836,7 +890,7 @@ void luaV_execute (lua_State *L, int nex
+ }
+ }
+ }
+- case OP_RETURN: {
++ OPCODE_TARGET(RETURN) {
+ int b = GETARG_B(i);
+ if (b != 0) L->top = ra+b-1;
+ if (L->openupval) luaF_close(L, base);
+@@ -851,7 +905,7 @@ void luaV_execute (lua_State *L, int nex
+ goto reentry;
+ }
+ }
+- case OP_FORLOOP: {
++ OPCODE_TARGET(FORLOOP) {
+ /* If start,step and limit are all integers, we don't need to check
+ * against overflow in the looping.
+ */
+@@ -879,7 +933,7 @@ void luaV_execute (lua_State *L, int nex
+ }
+ continue;
+ }
+- case OP_FORPREP: {
++ OPCODE_TARGET(FORPREP) {
+ const TValue *init = ra;
+ const TValue *plimit = ra+1;
+ const TValue *pstep = ra+2;
+@@ -902,7 +956,7 @@ void luaV_execute (lua_State *L, int nex
+ dojump(L, pc, GETARG_sBx(i));
+ continue;
+ }
+- case OP_TFORLOOP: {
++ OPCODE_TARGET(TFORLOOP) {
+ StkId cb = ra + 3; /* call base */
+ setobjs2s(L, cb+2, ra+2);
+ setobjs2s(L, cb+1, ra+1);
+@@ -918,7 +972,7 @@ void luaV_execute (lua_State *L, int nex
+ pc++;
+ continue;
+ }
+- case OP_SETLIST: {
++ OPCODE_TARGET(SETLIST) {
+ int n = GETARG_B(i);
+ int c = GETARG_C(i);
+ int last;
+@@ -940,11 +994,11 @@ void luaV_execute (lua_State *L, int nex
+ }
+ continue;
+ }
+- case OP_CLOSE: {
++ OPCODE_TARGET(CLOSE) {
+ luaF_close(L, ra);
+ continue;
+ }
+- case OP_CLOSURE: {
++ OPCODE_TARGET(CLOSURE) {
+ Proto *p;
+ Closure *ncl;
+ int nup, j;
+@@ -964,7 +1018,7 @@ void luaV_execute (lua_State *L, int nex
+ Protect(luaC_checkGC(L));
+ continue;
+ }
+- case OP_VARARG: {
++ OPCODE_TARGET(VARARG) {
+ int b = GETARG_B(i) - 1;
+ int j;
+ CallInfo *ci = L->ci;
diff --git a/package/lua/patches/010-lua-5.1.3-lnum-full-260308.patch b/package/lua/patches/010-lua-5.1.3-lnum-full-260308.patch
new file mode 100644
index 0000000..74b8c6f
--- /dev/null
+++ b/package/lua/patches/010-lua-5.1.3-lnum-full-260308.patch
@@ -0,0 +1,3736 @@
+--- a/src/Makefile
++++ b/src/Makefile
+@@ -25,7 +25,7 @@ PLATS= aix ansi bsd freebsd generic linu
+ LUA_A= liblua.a
+ CORE_O= lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o \
+ lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o \
+- lundump.o lvm.o lzio.o
++ lundump.o lvm.o lzio.o lnum.o
+ LIB_O= lauxlib.o lbaselib.o ldblib.o liolib.o lmathlib.o loslib.o ltablib.o \
+ lstrlib.o loadlib.o linit.o
+
+@@ -148,6 +148,7 @@ llex.o: llex.c lua.h luaconf.h ldo.h lob
+ lmathlib.o: lmathlib.c lua.h luaconf.h lauxlib.h lualib.h
+ lmem.o: lmem.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h \
+ ltm.h lzio.h lmem.h ldo.h
++lnum.o: lnum.c lua.h llex.h lnum.h
+ loadlib.o: loadlib.c lua.h luaconf.h lauxlib.h lualib.h
+ lobject.o: lobject.c lua.h luaconf.h ldo.h lobject.h llimits.h lstate.h \
+ ltm.h lzio.h lmem.h lstring.h lgc.h lvm.h
+@@ -179,4 +180,18 @@ lzio.o: lzio.c lua.h luaconf.h llimits.h
+ print.o: print.c ldebug.h lstate.h lua.h luaconf.h lobject.h llimits.h \
+ ltm.h lzio.h lmem.h lopcodes.h lundump.h
+
++luaconf.h: lnum_config.h
++lapi.c: lnum.h
++lauxlib.c: llimits.h
++lbaselib.c: llimits.h lobject.h lapi.h
++lcode.c: lnum.h
++liolib.c: lnum.h llex.h
++llex.c: lnum.h
++lnum.h: lobject.h
++lobject.c: llex.h lnum.h
++ltable.c: lnum.h
++lua.c: llimits.h
++lvm.c: llex.h lnum.h
++print.c: lnum.h
++
+ # (end of Makefile)
+--- a/src/lapi.c
++++ b/src/lapi.c
+@@ -28,7 +28,7 @@
+ #include "ltm.h"
+ #include "lundump.h"
+ #include "lvm.h"
+-
++#include "lnum.h"
+
+
+ const char lua_ident[] =
+@@ -241,12 +241,13 @@ LUA_API void lua_pushvalue (lua_State *L
+
+ LUA_API int lua_type (lua_State *L, int idx) {
+ StkId o = index2adr(L, idx);
+- return (o == luaO_nilobject) ? LUA_TNONE : ttype(o);
++ return (o == luaO_nilobject) ? LUA_TNONE : ttype_ext(o);
+ }
+
+
+ LUA_API const char *lua_typename (lua_State *L, int t) {
+ UNUSED(L);
++ lua_assert( t!= LUA_TINT );
+ return (t == LUA_TNONE) ? "no value" : luaT_typenames[t];
+ }
+
+@@ -264,6 +265,14 @@ LUA_API int lua_isnumber (lua_State *L,
+ }
+
+
++LUA_API int lua_isinteger (lua_State *L, int idx) {
++ TValue tmp;
++ lua_Integer dum;
++ const TValue *o = index2adr(L, idx);
++ return tonumber(o,&tmp) && (ttisint(o) || tt_integer_valued(o,&dum));
++}
++
++
+ LUA_API int lua_isstring (lua_State *L, int idx) {
+ int t = lua_type(L, idx);
+ return (t == LUA_TSTRING || t == LUA_TNUMBER);
+@@ -309,31 +318,66 @@ LUA_API int lua_lessthan (lua_State *L,
+ }
+
+
+-
+ LUA_API lua_Number lua_tonumber (lua_State *L, int idx) {
+ TValue n;
+ const TValue *o = index2adr(L, idx);
+- if (tonumber(o, &n))
++ if (tonumber(o, &n)) {
++#ifdef LNUM_COMPLEX
++ if (nvalue_img(o) != 0)
++ luaG_runerror(L, "expecting a real number");
++#endif
+ return nvalue(o);
+- else
+- return 0;
++ }
++ return 0;
+ }
+
+
+ LUA_API lua_Integer lua_tointeger (lua_State *L, int idx) {
+ TValue n;
++ /* Lua 5.1 documented behaviour is to return nonzero for non-integer:
++ * "If the number is not an integer, it is truncated in some non-specified way."
++ * I would suggest to change this, to return 0 for anything that would
++ * not fit in 'lua_Integer'.
++ */
++#ifdef LUA_COMPAT_TOINTEGER
++ /* Lua 5.1 compatible */
+ const TValue *o = index2adr(L, idx);
+ if (tonumber(o, &n)) {
+- lua_Integer res;
+- lua_Number num = nvalue(o);
+- lua_number2integer(res, num);
+- return res;
++ lua_Integer i;
++ lua_Number d;
++ if (ttisint(o)) return ivalue(o);
++ d= nvalue_fast(o);
++# ifdef LNUM_COMPLEX
++ if (nvalue_img_fast(o) != 0)
++ luaG_runerror(L, "expecting a real number");
++# endif
++ lua_number2integer(i, d);
++ return i;
+ }
+- else
+- return 0;
++#else
++ /* New suggestion */
++ const TValue *o = index2adr(L, idx);
++ if (tonumber(o, &n)) {
++ lua_Integer i;
++ if (ttisint(o)) return ivalue(o);
++ if (tt_integer_valued(o,&i)) return i;
++ }
++#endif
++ return 0;
+ }
+
+
++#ifdef LNUM_COMPLEX
++LUA_API lua_Complex lua_tocomplex (lua_State *L, int idx) {
++ TValue tmp;
++ const TValue *o = index2adr(L, idx);
++ if (tonumber(o, &tmp))
++ return nvalue_complex(o);
++ return 0;
++}
++#endif
++
++
+ LUA_API int lua_toboolean (lua_State *L, int idx) {
+ const TValue *o = index2adr(L, idx);
+ return !l_isfalse(o);
+@@ -364,6 +408,7 @@ LUA_API size_t lua_objlen (lua_State *L,
+ case LUA_TSTRING: return tsvalue(o)->len;
+ case LUA_TUSERDATA: return uvalue(o)->len;
+ case LUA_TTABLE: return luaH_getn(hvalue(o));
++ case LUA_TINT:
+ case LUA_TNUMBER: {
+ size_t l;
+ lua_lock(L); /* `luaV_tostring' may create a new string */
+@@ -426,6 +471,8 @@ LUA_API void lua_pushnil (lua_State *L)
+ }
+
+
++/* 'lua_pushnumber()' may lose accuracy on integers, 'lua_pushinteger' will not.
++ */
+ LUA_API void lua_pushnumber (lua_State *L, lua_Number n) {
+ lua_lock(L);
+ setnvalue(L->top, n);
+@@ -434,12 +481,22 @@ LUA_API void lua_pushnumber (lua_State *
+ }
+
+
+-LUA_API void lua_pushinteger (lua_State *L, lua_Integer n) {
++LUA_API void lua_pushinteger (lua_State *L, lua_Integer i) {
++ lua_lock(L);
++ setivalue(L->top, i);
++ api_incr_top(L);
++ lua_unlock(L);
++}
++
++
++#ifdef LNUM_COMPLEX
++LUA_API void lua_pushcomplex (lua_State *L, lua_Complex v) {
+ lua_lock(L);
+- setnvalue(L->top, cast_num(n));
++ setnvalue_complex( L->top, v );
+ api_incr_top(L);
+ lua_unlock(L);
+ }
++#endif
+
+
+ LUA_API void lua_pushlstring (lua_State *L, const char *s, size_t len) {
+@@ -569,7 +626,7 @@ LUA_API void lua_rawgeti (lua_State *L,
+ lua_lock(L);
+ o = index2adr(L, idx);
+ api_check(L, ttistable(o));
+- setobj2s(L, L->top, luaH_getnum(hvalue(o), n));
++ setobj2s(L, L->top, luaH_getint(hvalue(o), n));
+ api_incr_top(L);
+ lua_unlock(L);
+ }
+@@ -597,6 +654,9 @@ LUA_API int lua_getmetatable (lua_State
+ case LUA_TUSERDATA:
+ mt = uvalue(obj)->metatable;
+ break;
++ case LUA_TINT:
++ mt = G(L)->mt[LUA_TNUMBER];
++ break;
+ default:
+ mt = G(L)->mt[ttype(obj)];
+ break;
+@@ -687,7 +747,7 @@ LUA_API void lua_rawseti (lua_State *L,
+ api_checknelems(L, 1);
+ o = index2adr(L, idx);
+ api_check(L, ttistable(o));
+- setobj2t(L, luaH_setnum(L, hvalue(o), n), L->top-1);
++ setobj2t(L, luaH_setint(L, hvalue(o), n), L->top-1);
+ luaC_barriert(L, hvalue(o), L->top-1);
+ L->top--;
+ lua_unlock(L);
+@@ -721,7 +781,7 @@ LUA_API int lua_setmetatable (lua_State
+ break;
+ }
+ default: {
+- G(L)->mt[ttype(obj)] = mt;
++ G(L)->mt[ttype_ext(obj)] = mt;
+ break;
+ }
+ }
+@@ -1085,3 +1145,32 @@ LUA_API const char *lua_setupvalue (lua_
+ return name;
+ }
+
++
++/* Help function for 'luaB_tonumber()', avoids multiple str->number
++ * conversions for Lua "tonumber()".
++ *
++ * Also pushes floating point numbers with integer value as integer, which
++ * can be used by 'tonumber()' in scripts to bring values back to integer
++ * realm.
++ *
++ * Note: The 'back to integer realm' is _not_ to affect string conversions:
++ * 'tonumber("4294967295.1")' should give a floating point value, although
++ * the value would be 4294967296 (and storable in int64 realm).
++ */
++int lua_pushvalue_as_number (lua_State *L, int idx)
++{
++ const TValue *o = index2adr(L, idx);
++ TValue tmp;
++ lua_Integer i;
++ if (ttisnumber(o)) {
++ if ( (!ttisint(o)) && tt_integer_valued(o,&i)) {
++ lua_pushinteger( L, i );
++ return 1;
++ }
++ } else if (!tonumber(o, &tmp)) {
++ return 0;
++ }
++ if (ttisint(o)) lua_pushinteger( L, ivalue(o) );
++ else lua_pushnumber( L, nvalue_fast(o) );
++ return 1;
++}
+--- a/src/lapi.h
++++ b/src/lapi.h
+@@ -13,4 +13,6 @@
+
+ LUAI_FUNC void luaA_pushobject (lua_State *L, const TValue *o);
+
++int lua_pushvalue_as_number (lua_State *L, int idx);
++
+ #endif
+--- a/src/lauxlib.c
++++ b/src/lauxlib.c
+@@ -23,7 +23,7 @@
+ #include "lua.h"
+
+ #include "lauxlib.h"
+-
++#include "llimits.h"
+
+ #define FREELIST_REF 0 /* free list of references */
+
+@@ -66,7 +66,7 @@ LUALIB_API int luaL_typerror (lua_State
+
+
+ static void tag_error (lua_State *L, int narg, int tag) {
+- luaL_typerror(L, narg, lua_typename(L, tag));
++ luaL_typerror(L, narg, tag==LUA_TINT ? "integer" : lua_typename(L, tag));
+ }
+
+
+@@ -188,8 +188,8 @@ LUALIB_API lua_Number luaL_optnumber (lu
+
+ LUALIB_API lua_Integer luaL_checkinteger (lua_State *L, int narg) {
+ lua_Integer d = lua_tointeger(L, narg);
+- if (d == 0 && !lua_isnumber(L, narg)) /* avoid extra test when d is not 0 */
+- tag_error(L, narg, LUA_TNUMBER);
++ if (d == 0 && !lua_isinteger(L, narg)) /* avoid extra test when d is not 0 */
++ tag_error(L, narg, LUA_TINT);
+ return d;
+ }
+
+@@ -200,6 +200,16 @@ LUALIB_API lua_Integer luaL_optinteger (
+ }
+
+
++#ifdef LNUM_COMPLEX
++LUALIB_API lua_Complex luaL_checkcomplex (lua_State *L, int narg) {
++ lua_Complex c = lua_tocomplex(L, narg);
++ if (c == 0 && !lua_isnumber(L, narg)) /* avoid extra test when c is not 0 */
++ tag_error(L, narg, LUA_TNUMBER);
++ return c;
++}
++#endif
++
++
+ LUALIB_API int luaL_getmetafield (lua_State *L, int obj, const char *event) {
+ if (!lua_getmetatable(L, obj)) /* no metatable? */
+ return 0;
+--- a/src/lauxlib.h
++++ b/src/lauxlib.h
+@@ -57,6 +57,12 @@ LUALIB_API lua_Number (luaL_optnumber) (
+ LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int numArg);
+ LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int nArg,
+ lua_Integer def);
++#define luaL_checkint32(L,narg) ((int)luaL_checkinteger(L,narg))
++#define luaL_optint32(L,narg,def) ((int)luaL_optinteger(L,narg,def))
++
++#ifdef LNUM_COMPLEX
++ LUALIB_API lua_Complex (luaL_checkcomplex) (lua_State *L, int narg);
++#endif
+
+ LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg);
+ LUALIB_API void (luaL_checktype) (lua_State *L, int narg, int t);
+--- a/src/lbaselib.c
++++ b/src/lbaselib.c
+@@ -18,7 +18,9 @@
+
+ #include "lauxlib.h"
+ #include "lualib.h"
+-
++#include "llimits.h"
++#include "lobject.h"
++#include "lapi.h"
+
+
+
+@@ -54,20 +56,25 @@ static int luaB_tonumber (lua_State *L)
+ int base = luaL_optint(L, 2, 10);
+ if (base == 10) { /* standard conversion */
+ luaL_checkany(L, 1);
+- if (lua_isnumber(L, 1)) {
+- lua_pushnumber(L, lua_tonumber(L, 1));
++ if (lua_isnumber(L, 1)) { /* numeric string, or a number */
++ lua_pushvalue_as_number(L,1); /* API extension (not to lose accuracy here) */
+ return 1;
+- }
++ }
+ }
+ else {
+ const char *s1 = luaL_checkstring(L, 1);
+ char *s2;
+- unsigned long n;
++ unsigned LUA_INTEGER n;
+ luaL_argcheck(L, 2 <= base && base <= 36, 2, "base out of range");
+- n = strtoul(s1, &s2, base);
++ n = lua_str2ul(s1, &s2, base);
+ if (s1 != s2) { /* at least one valid digit? */
+ while (isspace((unsigned char)(*s2))) s2++; /* skip trailing spaces */
+ if (*s2 == '\0') { /* no invalid trailing characters? */
++
++ /* Push as number, there needs to be separate 'luaB_tointeger' for
++ * when the caller wants to preserve the bits (matters if unsigned
++ * values are used).
++ */
+ lua_pushnumber(L, (lua_Number)n);
+ return 1;
+ }
+@@ -144,7 +151,7 @@ static int luaB_setfenv (lua_State *L) {
+ luaL_checktype(L, 2, LUA_TTABLE);
+ getfunc(L, 0);
+ lua_pushvalue(L, 2);
+- if (lua_isnumber(L, 1) && lua_tonumber(L, 1) == 0) {
++ if (lua_isnumber(L, 1) && lua_tointeger(L, 1) == 0) {
+ /* change environment of current thread */
+ lua_pushthread(L);
+ lua_insert(L, -2);
+@@ -209,7 +216,7 @@ static int luaB_collectgarbage (lua_Stat
+ return 1;
+ }
+ default: {
+- lua_pushnumber(L, res);
++ lua_pushinteger(L, res);
+ return 1;
+ }
+ }
+@@ -631,6 +638,8 @@ static void base_open (lua_State *L) {
+ luaL_register(L, "_G", base_funcs);
+ lua_pushliteral(L, LUA_VERSION);
+ lua_setglobal(L, "_VERSION"); /* set global _VERSION */
++ lua_pushliteral(L, LUA_LNUM);
++ lua_setglobal(L, "_LNUM"); /* "[complex] double|float|ldouble int32|int64" */
+ /* `ipairs' and `pairs' need auxiliary functions as upvalues */
+ auxopen(L, "ipairs", luaB_ipairs, ipairsaux);
+ auxopen(L, "pairs", luaB_pairs, luaB_next);
+--- a/src/lcode.c
++++ b/src/lcode.c
+@@ -22,13 +22,18 @@
+ #include "lopcodes.h"
+ #include "lparser.h"
+ #include "ltable.h"
++#include "lnum.h"
+
+
+ #define hasjumps(e) ((e)->t != (e)->f)
+
+-
+ static int isnumeral(expdesc *e) {
+- return (e->k == VKNUM && e->t == NO_JUMP && e->f == NO_JUMP);
++ int ek=
++#ifdef LNUM_COMPLEX
++ (e->k == VKNUM2) ||
++#endif
++ (e->k == VKINT) || (e->k == VKNUM);
++ return (ek && e->t == NO_JUMP && e->f == NO_JUMP);
+ }
+
+
+@@ -231,12 +236,16 @@ static int addk (FuncState *fs, TValue *
+ TValue *idx = luaH_set(L, fs->h, k);
+ Proto *f = fs->f;
+ int oldsize = f->sizek;
+- if (ttisnumber(idx)) {
+- lua_assert(luaO_rawequalObj(&fs->f->k[cast_int(nvalue(idx))], v));
+- return cast_int(nvalue(idx));
++ if (ttype(idx)==LUA_TNUMBER) {
++ luai_normalize(idx);
++ lua_assert( ttype(idx)==LUA_TINT ); /* had no fraction */
++ }
++ if (ttisint(idx)) {
++ lua_assert(luaO_rawequalObj(&fs->f->k[ivalue(idx)], v));
++ return cast_int(ivalue(idx));
+ }
+ else { /* constant not found; create a new entry */
+- setnvalue(idx, cast_num(fs->nk));
++ setivalue(idx, fs->nk);
+ luaM_growvector(L, f->k, fs->nk, f->sizek, TValue,
+ MAXARG_Bx, "constant table overflow");
+ while (oldsize < f->sizek) setnilvalue(&f->k[oldsize++]);
+@@ -261,6 +270,21 @@ int luaK_numberK (FuncState *fs, lua_Num
+ }
+
+
++int luaK_integerK (FuncState *fs, lua_Integer r) {
++ TValue o;
++ setivalue(&o, r);
++ return addk(fs, &o, &o);
++}
++
++
++#ifdef LNUM_COMPLEX
++static int luaK_imagK (FuncState *fs, lua_Number r) {
++ TValue o;
++ setnvalue_complex(&o, r*I);
++ return addk(fs, &o, &o);
++}
++#endif
++
+ static int boolK (FuncState *fs, int b) {
+ TValue o;
+ setbvalue(&o, b);
+@@ -359,6 +383,16 @@ static void discharge2reg (FuncState *fs
+ luaK_codeABx(fs, OP_LOADK, reg, luaK_numberK(fs, e->u.nval));
+ break;
+ }
++ case VKINT: {
++ luaK_codeABx(fs, OP_LOADK, reg, luaK_integerK(fs, e->u.ival));
++ break;
++ }
++#ifdef LNUM_COMPLEX
++ case VKNUM2: {
++ luaK_codeABx(fs, OP_LOADK, reg, luaK_imagK(fs, e->u.nval));
++ break;
++ }
++#endif
+ case VRELOCABLE: {
+ Instruction *pc = &getcode(fs, e);
+ SETARG_A(*pc, reg);
+@@ -444,6 +478,10 @@ void luaK_exp2val (FuncState *fs, expdes
+ int luaK_exp2RK (FuncState *fs, expdesc *e) {
+ luaK_exp2val(fs, e);
+ switch (e->k) {
++#ifdef LNUM_COMPLEX
++ case VKNUM2:
++#endif
++ case VKINT:
+ case VKNUM:
+ case VTRUE:
+ case VFALSE:
+@@ -451,6 +489,10 @@ int luaK_exp2RK (FuncState *fs, expdesc
+ if (fs->nk <= MAXINDEXRK) { /* constant fit in RK operand? */
+ e->u.s.info = (e->k == VNIL) ? nilK(fs) :
+ (e->k == VKNUM) ? luaK_numberK(fs, e->u.nval) :
++ (e->k == VKINT) ? luaK_integerK(fs, e->u.ival) :
++#ifdef LNUM_COMPLEX
++ (e->k == VKNUM2) ? luaK_imagK(fs, e->u.nval) :
++#endif
+ boolK(fs, (e->k == VTRUE));
+ e->k = VK;
+ return RKASK(e->u.s.info);
+@@ -540,7 +582,10 @@ void luaK_goiftrue (FuncState *fs, expde
+ int pc; /* pc of last jump */
+ luaK_dischargevars(fs, e);
+ switch (e->k) {
+- case VK: case VKNUM: case VTRUE: {
++#ifdef LNUM_COMPLEX
++ case VKNUM2:
++#endif
++ case VKINT: case VK: case VKNUM: case VTRUE: {
+ pc = NO_JUMP; /* always true; do nothing */
+ break;
+ }
+@@ -590,7 +635,10 @@ static void codenot (FuncState *fs, expd
+ e->k = VTRUE;
+ break;
+ }
+- case VK: case VKNUM: case VTRUE: {
++#ifdef LNUM_COMPLEX
++ case VKNUM2:
++#endif
++ case VKINT: case VK: case VKNUM: case VTRUE: {
+ e->k = VFALSE;
+ break;
+ }
+@@ -626,25 +674,70 @@ void luaK_indexed (FuncState *fs, expdes
+
+ static int constfolding (OpCode op, expdesc *e1, expdesc *e2) {
+ lua_Number v1, v2, r;
++ int vkres= VKNUM;
+ if (!isnumeral(e1) || !isnumeral(e2)) return 0;
+- v1 = e1->u.nval;
+- v2 = e2->u.nval;
++
++ /* real and imaginary parts don't mix. */
++#ifdef LNUM_COMPLEX
++ if (e1->k == VKNUM2) {
++ if ((op != OP_UNM) && (e2->k != VKNUM2)) return 0;
++ vkres= VKNUM2; }
++ else if (e2->k == VKNUM2) { return 0; }
++#endif
++ if ((e1->k == VKINT) && (e2->k == VKINT)) {
++ lua_Integer i1= e1->u.ival, i2= e2->u.ival;
++ lua_Integer rr;
++ int done= 0;
++ /* Integer/integer calculations (may end up producing floating point) */
++ switch (op) {
++ case OP_ADD: done= try_addint( &rr, i1, i2 ); break;
++ case OP_SUB: done= try_subint( &rr, i1, i2 ); break;
++ case OP_MUL: done= try_mulint( &rr, i1, i2 ); break;
++ case OP_DIV: done= try_divint( &rr, i1, i2 ); break;
++ case OP_MOD: done= try_modint( &rr, i1, i2 ); break;
++ case OP_POW: done= try_powint( &rr, i1, i2 ); break;
++ case OP_UNM: done= try_unmint( &rr, i1 ); break;
++ default: done= 0; break;
++ }
++ if (done) {
++ e1->u.ival = rr; /* remained within integer range */
++ return 1;
++ }
++ }
++ v1 = (e1->k == VKINT) ? ((lua_Number)e1->u.ival) : e1->u.nval;
++ v2 = (e2->k == VKINT) ? ((lua_Number)e2->u.ival) : e2->u.nval;
++
+ switch (op) {
+ case OP_ADD: r = luai_numadd(v1, v2); break;
+ case OP_SUB: r = luai_numsub(v1, v2); break;
+- case OP_MUL: r = luai_nummul(v1, v2); break;
++ case OP_MUL:
++#ifdef LNUM_COMPLEX
++ if (vkres==VKNUM2) return 0; /* leave to runtime (could do here, but not worth it?) */
++#endif
++ r = luai_nummul(v1, v2); break;
+ case OP_DIV:
+ if (v2 == 0) return 0; /* do not attempt to divide by 0 */
+- r = luai_numdiv(v1, v2); break;
++#ifdef LNUM_COMPLEX
++ if (vkres==VKNUM2) return 0; /* leave to runtime */
++#endif
++ r = luai_numdiv(v1, v2); break;
+ case OP_MOD:
+ if (v2 == 0) return 0; /* do not attempt to divide by 0 */
++#ifdef LNUM_COMPLEX
++ if (vkres==VKNUM2) return 0; /* leave to runtime */
++#endif
+ r = luai_nummod(v1, v2); break;
+- case OP_POW: r = luai_numpow(v1, v2); break;
++ case OP_POW:
++#ifdef LNUM_COMPLEX
++ if (vkres==VKNUM2) return 0; /* leave to runtime */
++#endif
++ r = luai_numpow(v1, v2); break;
+ case OP_UNM: r = luai_numunm(v1); break;
+ case OP_LEN: return 0; /* no constant folding for 'len' */
+ default: lua_assert(0); r = 0; break;
+ }
+ if (luai_numisnan(r)) return 0; /* do not attempt to produce NaN */
++ e1->k = cast(expkind,vkres);
+ e1->u.nval = r;
+ return 1;
+ }
+@@ -688,7 +781,8 @@ static void codecomp (FuncState *fs, OpC
+
+ void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e) {
+ expdesc e2;
+- e2.t = e2.f = NO_JUMP; e2.k = VKNUM; e2.u.nval = 0;
++ e2.t = e2.f = NO_JUMP; e2.k = VKINT; e2.u.ival = 0;
++
+ switch (op) {
+ case OPR_MINUS: {
+ if (!isnumeral(e))
+--- a/src/lcode.h
++++ b/src/lcode.h
+@@ -71,6 +71,6 @@ LUAI_FUNC void luaK_prefix (FuncState *f
+ LUAI_FUNC void luaK_infix (FuncState *fs, BinOpr op, expdesc *v);
+ LUAI_FUNC void luaK_posfix (FuncState *fs, BinOpr op, expdesc *v1, expdesc *v2);
+ LUAI_FUNC void luaK_setlist (FuncState *fs, int base, int nelems, int tostore);
+-
++LUAI_FUNC int luaK_integerK (FuncState *fs, lua_Integer r);
+
+ #endif
+--- a/src/ldebug.c
++++ b/src/ldebug.c
+@@ -183,7 +183,7 @@ static void collectvalidlines (lua_State
+ int *lineinfo = f->l.p->lineinfo;
+ int i;
+ for (i=0; i<f->l.p->sizelineinfo; i++)
+- setbvalue(luaH_setnum(L, t, lineinfo[i]), 1);
++ setbvalue(luaH_setint(L, t, lineinfo[i]), 1);
+ sethvalue(L, L->top, t);
+ }
+ incr_top(L);
+@@ -566,7 +566,7 @@ static int isinstack (CallInfo *ci, cons
+
+ void luaG_typeerror (lua_State *L, const TValue *o, const char *op) {
+ const char *name = NULL;
+- const char *t = luaT_typenames[ttype(o)];
++ const char *t = luaT_typenames[ttype_ext(o)];
+ const char *kind = (isinstack(L->ci, o)) ?
+ getobjname(L, L->ci, cast_int(o - L->base), &name) :
+ NULL;
+@@ -594,8 +594,8 @@ void luaG_aritherror (lua_State *L, cons
+
+
+ int luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2) {
+- const char *t1 = luaT_typenames[ttype(p1)];
+- const char *t2 = luaT_typenames[ttype(p2)];
++ const char *t1 = luaT_typenames[ttype_ext(p1)];
++ const char *t2 = luaT_typenames[ttype_ext(p2)];
+ if (t1[2] == t2[2])
+ luaG_runerror(L, "attempt to compare two %s values", t1);
+ else
+--- a/src/ldo.c
++++ b/src/ldo.c
+@@ -220,9 +220,9 @@ static StkId adjust_varargs (lua_State *
+ luaD_checkstack(L, p->maxstacksize);
+ htab = luaH_new(L, nvar, 1); /* create `arg' table */
+ for (i=0; i<nvar; i++) /* put extra arguments into `arg' table */
+- setobj2n(L, luaH_setnum(L, htab, i+1), L->top - nvar + i);
++ setobj2n(L, luaH_setint(L, htab, i+1), L->top - nvar + i);
+ /* store counter in field `n' */
+- setnvalue(luaH_setstr(L, htab, luaS_newliteral(L, "n")), cast_num(nvar));
++ setivalue(luaH_setstr(L, htab, luaS_newliteral(L, "n")), nvar);
+ }
+ #endif
+ /* move fixed parameters to final position */
+--- a/src/ldump.c
++++ b/src/ldump.c
+@@ -52,6 +52,11 @@ static void DumpNumber(lua_Number x, Dum
+ DumpVar(x,D);
+ }
+
++static void DumpInteger(lua_Integer x, DumpState* D)
++{
++ DumpVar(x,D);
++}
++
+ static void DumpVector(const void* b, int n, size_t size, DumpState* D)
+ {
+ DumpInt(n,D);
+@@ -93,8 +98,11 @@ static void DumpConstants(const Proto* f
+ DumpChar(bvalue(o),D);
+ break;
+ case LUA_TNUMBER:
+- DumpNumber(nvalue(o),D);
++ DumpNumber(nvalue_fast(o),D);
+ break;
++ case LUA_TINT:
++ DumpInteger(ivalue(o),D);
++ break;
+ case LUA_TSTRING:
+ DumpString(rawtsvalue(o),D);
+ break;
+--- a/src/liolib.c
++++ b/src/liolib.c
+@@ -9,6 +9,7 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
++#include <ctype.h>
+
+ #define liolib_c
+ #define LUA_LIB
+@@ -18,7 +19,8 @@
+ #include "lauxlib.h"
+ #include "lualib.h"
+
+-
++#include "lnum.h"
++#include "llex.h"
+
+ #define IO_INPUT 1
+ #define IO_OUTPUT 2
+@@ -269,6 +271,13 @@ static int io_lines (lua_State *L) {
+ ** =======================================================
+ */
+
++/*
++* Many problems if we intend the same 'n' format specifier (see 'file:read()')
++* to work for both FP and integer numbers, without losing their accuracy. So
++* we don't. 'n' reads numbers as floating points, 'i' as integers. Old code
++* remains valid, but won't provide full integer accuracy (this only matters
++* with float FP and/or 64-bit integers).
++*/
+
+ static int read_number (lua_State *L, FILE *f) {
+ lua_Number d;
+@@ -282,6 +291,43 @@ static int read_number (lua_State *L, FI
+ }
+ }
+
++static int read_integer (lua_State *L, FILE *f) {
++ lua_Integer i;
++ if (fscanf(f, LUA_INTEGER_SCAN, &i) == 1) {
++ lua_pushinteger(L, i);
++ return 1;
++ }
++ else return 0; /* read fails */
++}
++
++#ifdef LNUM_COMPLEX
++static int read_complex (lua_State *L, FILE *f) {
++ /* NNN / NNNi / NNN+MMMi / NNN-MMMi */
++ lua_Number a,b;
++ if (fscanf(f, LUA_NUMBER_SCAN, &a) == 1) {
++ int c=fgetc(f);
++ switch(c) {
++ case 'i':
++ lua_pushcomplex(L, a*I);
++ return 1;
++ case '+':
++ case '-':
++ /* "i" is consumed if at the end; just 'NNN+MMM' will most likely
++ * behave as if "i" was there? (TBD: test)
++ */
++ if (fscanf(f, LUA_NUMBER_SCAN "i", &b) == 1) {
++ lua_pushcomplex(L, a+ (c=='+' ? b:-b)*I);
++ return 1;
++ }
++ }
++ ungetc( c,f );
++ lua_pushnumber(L,a); /*real part only*/
++ return 1;
++ }
++ return 0; /* read fails */
++}
++#endif
++
+
+ static int test_eof (lua_State *L, FILE *f) {
+ int c = getc(f);
+@@ -355,6 +401,14 @@ static int g_read (lua_State *L, FILE *f
+ case 'n': /* number */
+ success = read_number(L, f);
+ break;
++ case 'i': /* integer (full accuracy) */
++ success = read_integer(L, f);
++ break;
++#ifdef LNUM_COMPLEX
++ case 'c': /* complex */
++ success = read_complex(L, f);
++ break;
++#endif
+ case 'l': /* line */
+ success = read_line(L, f);
+ break;
+@@ -415,9 +469,10 @@ static int g_write (lua_State *L, FILE *
+ int status = 1;
+ for (; nargs--; arg++) {
+ if (lua_type(L, arg) == LUA_TNUMBER) {
+- /* optimization: could be done exactly as for strings */
+- status = status &&
+- fprintf(f, LUA_NUMBER_FMT, lua_tonumber(L, arg)) > 0;
++ if (lua_isinteger(L,arg))
++ status = status && fprintf(f, LUA_INTEGER_FMT, lua_tointeger(L, arg)) > 0;
++ else
++ status = status && fprintf(f, LUA_NUMBER_FMT, lua_tonumber(L, arg)) > 0;
+ }
+ else {
+ size_t l;
+@@ -460,7 +515,7 @@ static int f_setvbuf (lua_State *L) {
+ static const char *const modenames[] = {"no", "full", "line", NULL};
+ FILE *f = tofile(L);
+ int op = luaL_checkoption(L, 2, NULL, modenames);
+- lua_Integer sz = luaL_optinteger(L, 3, LUAL_BUFFERSIZE);
++ size_t sz = luaL_optint32(L, 3, LUAL_BUFFERSIZE);
+ int res = setvbuf(f, NULL, mode[op], sz);
+ return pushresult(L, res == 0, NULL);
+ }
+--- a/src/llex.c
++++ b/src/llex.c
+@@ -22,6 +22,7 @@
+ #include "lstring.h"
+ #include "ltable.h"
+ #include "lzio.h"
++#include "lnum.h"
+
+
+
+@@ -34,13 +35,17 @@
+
+
+ /* ORDER RESERVED */
+-const char *const luaX_tokens [] = {
++static const char *const luaX_tokens [] = {
+ "and", "break", "do", "else", "elseif",
+ "end", "false", "for", "function", "if",
+ "in", "local", "nil", "not", "or", "repeat",
+ "return", "then", "true", "until", "while",
+ "..", "...", "==", ">=", "<=", "~=",
+ "<number>", "<name>", "<string>", "<eof>",
++ "<integer>",
++#ifdef LNUM_COMPLEX
++ "<number2>",
++#endif
+ NULL
+ };
+
+@@ -90,7 +95,11 @@ static const char *txtToken (LexState *l
+ switch (token) {
+ case TK_NAME:
+ case TK_STRING:
++ case TK_INT:
+ case TK_NUMBER:
++#ifdef LNUM_COMPLEX
++ case TK_NUMBER2:
++#endif
+ save(ls, '\0');
+ return luaZ_buffer(ls->buff);
+ default:
+@@ -175,23 +184,27 @@ static void buffreplace (LexState *ls, c
+ if (p[n] == from) p[n] = to;
+ }
+
+-
+-static void trydecpoint (LexState *ls, SemInfo *seminfo) {
++/* TK_NUMBER (/ TK_NUMBER2) */
++static int trydecpoint (LexState *ls, SemInfo *seminfo) {
+ /* format error: try to update decimal point separator */
+ struct lconv *cv = localeconv();
+ char old = ls->decpoint;
++ int ret;
+ ls->decpoint = (cv ? cv->decimal_point[0] : '.');
+ buffreplace(ls, old, ls->decpoint); /* try updated decimal separator */
+- if (!luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r)) {
++ ret= luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r, NULL);
++ if (!ret) {
+ /* format error with correct decimal point: no more options */
+ buffreplace(ls, ls->decpoint, '.'); /* undo change (for error message) */
+ luaX_lexerror(ls, "malformed number", TK_NUMBER);
+ }
++ return ret;
+ }
+
+
+-/* LUA_NUMBER */
+-static void read_numeral (LexState *ls, SemInfo *seminfo) {
++/* TK_NUMBER / TK_INT (/TK_NUMBER2) */
++static int read_numeral (LexState *ls, SemInfo *seminfo) {
++ int ret;
+ lua_assert(isdigit(ls->current));
+ do {
+ save_and_next(ls);
+@@ -202,8 +215,9 @@ static void read_numeral (LexState *ls,
+ save_and_next(ls);
+ save(ls, '\0');
+ buffreplace(ls, '.', ls->decpoint); /* follow locale for decimal point */
+- if (!luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r)) /* format error? */
+- trydecpoint(ls, seminfo); /* try to update decimal point separator */
++ ret= luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r, &seminfo->i );
++ if (!ret) return trydecpoint(ls, seminfo); /* try to update decimal point separator */
++ return ret;
+ }
+
+
+@@ -331,6 +345,7 @@ static void read_string (LexState *ls, i
+ }
+
+
++/* char / TK_* */
+ static int llex (LexState *ls, SemInfo *seminfo) {
+ luaZ_resetbuffer(ls->buff);
+ for (;;) {
+@@ -402,8 +417,7 @@ static int llex (LexState *ls, SemInfo *
+ }
+ else if (!isdigit(ls->current)) return '.';
+ else {
+- read_numeral(ls, seminfo);
+- return TK_NUMBER;
++ return read_numeral(ls, seminfo);
+ }
+ }
+ case EOZ: {
+@@ -416,8 +430,7 @@ static int llex (LexState *ls, SemInfo *
+ continue;
+ }
+ else if (isdigit(ls->current)) {
+- read_numeral(ls, seminfo);
+- return TK_NUMBER;
++ return read_numeral(ls, seminfo);
+ }
+ else if (isalpha(ls->current) || ls->current == '_') {
+ /* identifier or reserved word */
+--- a/src/llex.h
++++ b/src/llex.h
+@@ -29,19 +29,22 @@ enum RESERVED {
+ TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE,
+ /* other terminal symbols */
+ TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, TK_NUMBER,
+- TK_NAME, TK_STRING, TK_EOS
++ TK_NAME, TK_STRING, TK_EOS, TK_INT
++#ifdef LNUM_COMPLEX
++ , TK_NUMBER2 /* imaginary constants: Ni */
++#endif
+ };
+
+ /* number of reserved words */
+ #define NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1))
+
+
+-/* array with token `names' */
+-LUAI_DATA const char *const luaX_tokens [];
+-
+-
++/* SemInfo is a local data structure of 'llex.c', used for carrying a string
++ * or a number. A separate token (TK_*) will tell, how to interpret the data.
++ */
+ typedef union {
+ lua_Number r;
++ lua_Integer i;
+ TString *ts;
+ } SemInfo; /* semantics information */
+
+--- a/src/llimits.h
++++ b/src/llimits.h
+@@ -49,6 +49,7 @@ typedef LUAI_USER_ALIGNMENT_T L_Umaxalig
+
+ /* result of a `usual argument conversion' over lua_Number */
+ typedef LUAI_UACNUMBER l_uacNumber;
++typedef LUAI_UACINTEGER l_uacInteger;
+
+
+ /* internal assertions for in-house debugging */
+@@ -80,7 +81,6 @@ typedef LUAI_UACNUMBER l_uacNumber;
+ #define cast_int(i) cast(int, (i))
+
+
+-
+ /*
+ ** type for virtual-machine instructions
+ ** must be an unsigned with (at least) 4 bytes (see details in lopcodes.h)
+--- a/src/lmathlib.c
++++ b/src/lmathlib.c
+@@ -4,7 +4,6 @@
+ ** See Copyright Notice in lua.h
+ */
+
+-
+ #include <stdlib.h>
+ #include <math.h>
+
+@@ -16,113 +15,210 @@
+ #include "lauxlib.h"
+ #include "lualib.h"
+
++/* 'luai_vectpow()' as a replacement for 'cpow()'. Defined in the header; we
++ * don't intrude the code libs internal functions.
++ */
++#ifdef LNUM_COMPLEX
++# include "lnum.h"
++#endif
+
+ #undef PI
+-#define PI (3.14159265358979323846)
+-#define RADIANS_PER_DEGREE (PI/180.0)
+-
++#ifdef LNUM_FLOAT
++# define PI (3.14159265358979323846F)
++#elif defined(M_PI)
++# define PI M_PI
++#else
++# define PI (3.14159265358979323846264338327950288)
++#endif
++#define RADIANS_PER_DEGREE (PI/180)
+
++#undef HUGE
++#ifdef LNUM_FLOAT
++# define HUGE HUGE_VALF
++#elif defined(LNUM_LDOUBLE)
++# define HUGE HUGE_VALL
++#else
++# define HUGE HUGE_VAL
++#endif
+
+ static int math_abs (lua_State *L) {
+- lua_pushnumber(L, fabs(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_pushnumber(L, _LF(cabs) (luaL_checkcomplex(L,1)));
++#else
++ lua_pushnumber(L, _LF(fabs) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+ static int math_sin (lua_State *L) {
+- lua_pushnumber(L, sin(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(csin) (luaL_checkcomplex(L,1)));
++#else
++ lua_pushnumber(L, _LF(sin) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+ static int math_sinh (lua_State *L) {
+- lua_pushnumber(L, sinh(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(csinh) (luaL_checkcomplex(L,1)));
++#else
++ lua_pushnumber(L, _LF(sinh) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+ static int math_cos (lua_State *L) {
+- lua_pushnumber(L, cos(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(ccos) (luaL_checkcomplex(L,1)));
++#else
++ lua_pushnumber(L, _LF(cos) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+ static int math_cosh (lua_State *L) {
+- lua_pushnumber(L, cosh(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(ccosh) (luaL_checkcomplex(L,1)));
++#else
++ lua_pushnumber(L, _LF(cosh) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+ static int math_tan (lua_State *L) {
+- lua_pushnumber(L, tan(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(ctan) (luaL_checkcomplex(L,1)));
++#else
++ lua_pushnumber(L, _LF(tan) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+ static int math_tanh (lua_State *L) {
+- lua_pushnumber(L, tanh(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(ctanh) (luaL_checkcomplex(L,1)));
++#else
++ lua_pushnumber(L, _LF(tanh) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+ static int math_asin (lua_State *L) {
+- lua_pushnumber(L, asin(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(casin) (luaL_checkcomplex(L,1)));
++#else
++ lua_pushnumber(L, _LF(asin) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+ static int math_acos (lua_State *L) {
+- lua_pushnumber(L, acos(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(cacos) (luaL_checkcomplex(L,1)));
++#else
++ lua_pushnumber(L, _LF(acos) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+ static int math_atan (lua_State *L) {
+- lua_pushnumber(L, atan(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(catan) (luaL_checkcomplex(L,1)));
++#else
++ lua_pushnumber(L, _LF(atan) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+ static int math_atan2 (lua_State *L) {
+- lua_pushnumber(L, atan2(luaL_checknumber(L, 1), luaL_checknumber(L, 2)));
++ /* scalars only */
++ lua_pushnumber(L, _LF(atan2) (luaL_checknumber(L, 1), luaL_checknumber(L, 2)));
+ return 1;
+ }
+
+ static int math_ceil (lua_State *L) {
+- lua_pushnumber(L, ceil(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_Complex v= luaL_checkcomplex(L, 1);
++ lua_pushcomplex(L, _LF(ceil) (_LF(creal)(v)) + _LF(ceil) (_LF(cimag)(v))*I);
++#else
++ lua_pushnumber(L, _LF(ceil) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+ static int math_floor (lua_State *L) {
+- lua_pushnumber(L, floor(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_Complex v= luaL_checkcomplex(L, 1);
++ lua_pushcomplex(L, _LF(floor) (_LF(creal)(v)) + _LF(floor) (_LF(cimag)(v))*I);
++#else
++ lua_pushnumber(L, _LF(floor) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+-static int math_fmod (lua_State *L) {
+- lua_pushnumber(L, fmod(luaL_checknumber(L, 1), luaL_checknumber(L, 2)));
++static int math_fmod (lua_State *L) {
++ /* scalars only */
++ lua_pushnumber(L, _LF(fmod) (luaL_checknumber(L, 1), luaL_checknumber(L, 2)));
+ return 1;
+ }
+
+ static int math_modf (lua_State *L) {
+- double ip;
+- double fp = modf(luaL_checknumber(L, 1), &ip);
++ /* scalars only */
++ lua_Number ip;
++ lua_Number fp = _LF(modf) (luaL_checknumber(L, 1), &ip);
+ lua_pushnumber(L, ip);
+ lua_pushnumber(L, fp);
+ return 2;
+ }
+
+ static int math_sqrt (lua_State *L) {
+- lua_pushnumber(L, sqrt(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(csqrt) (luaL_checkcomplex(L,1)));
++#else
++ lua_pushnumber(L, _LF(sqrt) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+ static int math_pow (lua_State *L) {
+- lua_pushnumber(L, pow(luaL_checknumber(L, 1), luaL_checknumber(L, 2)));
++#ifdef LNUM_COMPLEX
++ /* C99 'cpow' gives somewhat inaccurate results (i.e. (-1)^2 = -1+1.2246467991474e-16i).
++ * 'luai_vectpow' smoothens such, reusing it is the reason we need to #include "lnum.h".
++ */
++ lua_pushcomplex(L, luai_vectpow(luaL_checkcomplex(L,1), luaL_checkcomplex(L,2)));
++#else
++ lua_pushnumber(L, _LF(pow) (luaL_checknumber(L, 1), luaL_checknumber(L, 2)));
++#endif
+ return 1;
+ }
+
+ static int math_log (lua_State *L) {
+- lua_pushnumber(L, log(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(clog) (luaL_checkcomplex(L,1)));
++#else
++ lua_pushnumber(L, _LF(log) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+ static int math_log10 (lua_State *L) {
+- lua_pushnumber(L, log10(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ /* Not in standard <complex.h> , but easy to calculate: log_a(x) = log_b(x) / log_b(a)
++ */
++ lua_pushcomplex(L, _LF(clog) (luaL_checkcomplex(L,1)) / _LF(log) (10));
++#else
++ lua_pushnumber(L, _LF(log10) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+ static int math_exp (lua_State *L) {
+- lua_pushnumber(L, exp(luaL_checknumber(L, 1)));
++#ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(cexp) (luaL_checkcomplex(L,1)));
++#else
++ lua_pushnumber(L, _LF(exp) (luaL_checknumber(L, 1)));
++#endif
+ return 1;
+ }
+
+@@ -138,19 +234,20 @@ static int math_rad (lua_State *L) {
+
+ static int math_frexp (lua_State *L) {
+ int e;
+- lua_pushnumber(L, frexp(luaL_checknumber(L, 1), &e));
++ lua_pushnumber(L, _LF(frexp) (luaL_checknumber(L, 1), &e));
+ lua_pushinteger(L, e);
+ return 2;
+ }
+
+ static int math_ldexp (lua_State *L) {
+- lua_pushnumber(L, ldexp(luaL_checknumber(L, 1), luaL_checkint(L, 2)));
++ lua_pushnumber(L, _LF(ldexp) (luaL_checknumber(L, 1), luaL_checkint(L, 2)));
+ return 1;
+ }
+
+
+
+ static int math_min (lua_State *L) {
++ /* scalars only */
+ int n = lua_gettop(L); /* number of arguments */
+ lua_Number dmin = luaL_checknumber(L, 1);
+ int i;
+@@ -165,6 +262,7 @@ static int math_min (lua_State *L) {
+
+
+ static int math_max (lua_State *L) {
++ /* scalars only */
+ int n = lua_gettop(L); /* number of arguments */
+ lua_Number dmax = luaL_checknumber(L, 1);
+ int i;
+@@ -182,25 +280,20 @@ static int math_random (lua_State *L) {
+ /* the `%' avoids the (rare) case of r==1, and is needed also because on
+ some systems (SunOS!) `rand()' may return a value larger than RAND_MAX */
+ lua_Number r = (lua_Number)(rand()%RAND_MAX) / (lua_Number)RAND_MAX;
+- switch (lua_gettop(L)) { /* check number of arguments */
+- case 0: { /* no arguments */
+- lua_pushnumber(L, r); /* Number between 0 and 1 */
+- break;
+- }
+- case 1: { /* only upper limit */
+- int u = luaL_checkint(L, 1);
+- luaL_argcheck(L, 1<=u, 1, "interval is empty");
+- lua_pushnumber(L, floor(r*u)+1); /* int between 1 and `u' */
+- break;
+- }
+- case 2: { /* lower and upper limits */
+- int l = luaL_checkint(L, 1);
+- int u = luaL_checkint(L, 2);
+- luaL_argcheck(L, l<=u, 2, "interval is empty");
+- lua_pushnumber(L, floor(r*(u-l+1))+l); /* int between `l' and `u' */
+- break;
+- }
+- default: return luaL_error(L, "wrong number of arguments");
++ int n= lua_gettop(L); /* number of arguments */
++ if (n==0) { /* no arguments: range [0,1) */
++ lua_pushnumber(L, r);
++ } else if (n<=2) { /* int range [1,u] or [l,u] */
++ int l= n==1 ? 1 : luaL_checkint(L, 1);
++ int u = luaL_checkint(L, n);
++ int tmp;
++ lua_Number d;
++ luaL_argcheck(L, l<=u, n, "interval is empty");
++ d= _LF(floor)(r*(u-l+1));
++ lua_number2int(tmp,d);
++ lua_pushinteger(L, l+tmp);
++ } else {
++ return luaL_error(L, "wrong number of arguments");
+ }
+ return 1;
+ }
+@@ -211,6 +304,66 @@ static int math_randomseed (lua_State *L
+ return 0;
+ }
+
++/*
++* Lua 5.1 does not have acosh, asinh, atanh for scalars (not ANSI C)
++*/
++#if __STDC_VERSION__ >= 199901L
++static int math_acosh (lua_State *L) {
++# ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(cacosh) (luaL_checkcomplex(L,1)));
++# else
++ lua_pushnumber(L, _LF(acosh) (luaL_checknumber(L,1)));
++# endif
++ return 1;
++}
++static int math_asinh (lua_State *L) {
++# ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(casinh) (luaL_checkcomplex(L,1)));
++# else
++ lua_pushnumber(L, _LF(asinh) (luaL_checknumber(L,1)));
++# endif
++ return 1;
++}
++static int math_atanh (lua_State *L) {
++# ifdef LNUM_COMPLEX
++ lua_pushcomplex(L, _LF(catanh) (luaL_checkcomplex(L,1)));
++# else
++ lua_pushnumber(L, _LF(atanh) (luaL_checknumber(L,1)));
++# endif
++ return 1;
++}
++#endif
++
++/*
++ * C99 complex functions, not covered above.
++*/
++#ifdef LNUM_COMPLEX
++static int math_arg (lua_State *L) {
++ lua_pushnumber(L, _LF(carg) (luaL_checkcomplex(L,1)));
++ return 1;
++}
++
++static int math_imag (lua_State *L) {
++ lua_pushnumber(L, _LF(cimag) (luaL_checkcomplex(L,1)));
++ return 1;
++}
++
++static int math_real (lua_State *L) {
++ lua_pushnumber(L, _LF(creal) (luaL_checkcomplex(L,1)));
++ return 1;
++}
++
++static int math_conj (lua_State *L) {
++ lua_pushcomplex(L, _LF(conj) (luaL_checkcomplex(L,1)));
++ return 1;
++}
++
++static int math_proj (lua_State *L) {
++ lua_pushcomplex(L, _LF(cproj) (luaL_checkcomplex(L,1)));
++ return 1;
++}
++#endif
++
+
+ static const luaL_Reg mathlib[] = {
+ {"abs", math_abs},
+@@ -241,6 +394,18 @@ static const luaL_Reg mathlib[] = {
+ {"sqrt", math_sqrt},
+ {"tanh", math_tanh},
+ {"tan", math_tan},
++#if __STDC_VERSION__ >= 199901L
++ {"acosh", math_acosh},
++ {"asinh", math_asinh},
++ {"atanh", math_atanh},
++#endif
++#ifdef LNUM_COMPLEX
++ {"arg", math_arg},
++ {"imag", math_imag},
++ {"real", math_real},
++ {"conj", math_conj},
++ {"proj", math_proj},
++#endif
+ {NULL, NULL}
+ };
+
+@@ -252,8 +417,10 @@ LUALIB_API int luaopen_math (lua_State *
+ luaL_register(L, LUA_MATHLIBNAME, mathlib);
+ lua_pushnumber(L, PI);
+ lua_setfield(L, -2, "pi");
+- lua_pushnumber(L, HUGE_VAL);
++ lua_pushnumber(L, HUGE);
+ lua_setfield(L, -2, "huge");
++ lua_pushinteger(L, LUA_INTEGER_MAX );
++ lua_setfield(L, -2, "hugeint");
+ #if defined(LUA_COMPAT_MOD)
+ lua_getfield(L, -1, "fmod");
+ lua_setfield(L, -2, "mod");
+--- /dev/null
++++ b/src/lnum.c
+@@ -0,0 +1,312 @@
++/*
++** $Id: lnum.c,v ... $
++** Internal number model
++** See Copyright Notice in lua.h
++*/
++
++#include <stdlib.h>
++#include <math.h>
++#include <ctype.h>
++#include <string.h>
++#include <stdio.h>
++#include <errno.h>
++
++#define lnum_c
++#define LUA_CORE
++
++#include "lua.h"
++#include "llex.h"
++#include "lnum.h"
++
++/*
++** lua_real2str converts a (non-complex) number to a string.
++** lua_str2real converts a string to a (non-complex) number.
++*/
++#define lua_real2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n))
++
++/*
++* Note: Only 'strtod()' is part of ANSI C; others are C99 and
++* may need '--std=c99' compiler setting (at least on Ubuntu 7.10).
++*
++* Visual C++ 2008 Express does not have 'strtof()', nor 'strtold()'.
++* References to '_strtold()' exist but don't compile. It seems best
++* to leave Windows users with DOUBLE only (or compile with MinGW).
++*
++* In practise, using '(long double)strtod' is a risky thing, since
++* it will cause accuracy loss in reading in numbers, and such losses
++* will pile up in later processing. Get a real 'strtold()' or don't
++* use that mode at all.
++*/
++#ifdef LNUM_DOUBLE
++# define lua_str2real strtod
++#elif defined(LNUM_FLOAT)
++# define lua_str2real strtof
++#elif defined(LNUM_LDOUBLE)
++# define lua_str2real strtold
++#endif
++
++#define lua_integer2str(s,v) sprintf((s), LUA_INTEGER_FMT, (v))
++
++/* 's' is expected to be LUAI_MAXNUMBER2STR long (enough for any number)
++*/
++void luaO_num2buf( char *s, const TValue *o )
++{
++ lua_Number n;
++ lua_assert( ttisnumber(o) );
++
++ /* Reason to handle integers differently is not only speed, but accuracy as
++ * well. We want to make any integer tostring() without roundings, at all.
++ */
++ if (ttisint(o)) {
++ lua_integer2str( s, ivalue(o) );
++ return;
++ }
++ n= nvalue_fast(o);
++ lua_real2str(s, n);
++
++#ifdef LNUM_COMPLEX
++ lua_Number n2= nvalue_img_fast(o);
++ if (n2!=0) { /* Postfix with +-Ni */
++ int re0= (n == 0);
++ char *s2= re0 ? s : strchr(s,'\0');
++ if ((!re0) && (n2>0)) *s2++= '+';
++ lua_real2str( s2, n2 );
++ strcat(s2,"i");
++ }
++#endif
++}
++
++/*
++* If a LUA_TNUMBER has integer value, give it.
++*/
++int /*bool*/ tt_integer_valued( const TValue *o, lua_Integer *ref ) {
++ lua_Number d;
++ lua_Integer i;
++
++ lua_assert( ttype(o)==LUA_TNUMBER );
++ lua_assert( ref );
++#ifdef LNUM_COMPLEX
++ if (nvalue_img_fast(o)!=0) return 0;
++#endif
++ d= nvalue_fast(o);
++ lua_number2integer(i, d);
++ if (cast_num(i) == d) {
++ *ref= i; return 1;
++ }
++ return 0;
++}
++
++/*
++ * Lua 5.1.3 (using 'strtod()') allows 0x+hex but not 0+octal. This is good,
++ * and we should NOT use 'autobase' 0 with 'strtoul[l]()' for this reason.
++ *
++ * Lua 5.1.3 allows '0x...' numbers to overflow and lose precision; this is not
++ * good. On Visual C++ 2008, 'strtod()' does not even take them in. Better to
++ * require hex values to fit 'lua_Integer' or give an error that they don't?
++ *
++ * Full hex range (0 .. 0xff..ff) is stored as integers, not to lose any bits.
++ * Numerical value of 0xff..ff will be -1, if used in calculations.
++ *
++ * Returns: TK_INT for a valid integer, '*endptr_ref' updated
++ * TK_NUMBER for seemingly numeric, to be parsed as floating point
++ * 0 for bad characters, not a number (or '0x' out of range)
++ */
++static int luaO_str2i (const char *s, lua_Integer *res, char **endptr_ref) {
++ char *endptr;
++ /* 'v' gets ULONG_MAX on possible overflow (which is > LUA_INTEGER_MAX);
++ * we don't have to check 'errno' here.
++ */
++ unsigned LUA_INTEGER v= lua_str2ul(s, &endptr, 10);
++ if (endptr == s) return 0; /* nothing numeric */
++ if (v==0 && *endptr=='x') {
++ errno= 0; /* needs to be set, 'strtoul[l]' does not clear it */
++ v= lua_str2ul(endptr+1, &endptr, 16); /* retry as hex, unsigned range */
++ if (errno==ERANGE) { /* clamped to 0xff..ff */
++#if (defined(LNUM_INT32) && !defined(LNUM_FLOAT)) || defined(LNUM_LDOUBLE)
++ return TK_NUMBER; /* Allow to be read as floating point (has more integer range) */
++#else
++ return 0; /* Reject the number */
++#endif
++ }
++ } else if ((v > LUA_INTEGER_MAX) || (*endptr && (!isspace(*endptr)))) {
++ return TK_NUMBER; /* not in signed range, or has '.', 'e' etc. trailing */
++ }
++ *res= (lua_Integer)v;
++ *endptr_ref= endptr;
++ return TK_INT;
++}
++
++/* 0 / TK_NUMBER / TK_INT (/ TK_NUMBER2) */
++int luaO_str2d (const char *s, lua_Number *res_n, lua_Integer *res_i) {
++ char *endptr;
++ int ret= TK_NUMBER;
++ /* Check integers first, if caller is allowing.
++ * If 'res2'==NULL, they're only looking for floating point.
++ */
++ if (res_i) {
++ ret= luaO_str2i(s,res_i,&endptr);
++ if (ret==0) return 0;
++ }
++ if (ret==TK_NUMBER) {
++ lua_assert(res_n);
++ /* Note: Visual C++ 2008 Express 'strtod()' does not read in "0x..."
++ * numbers; it will read '0' and spit 'x' as endptr.
++ * This means hex constants not fitting in 'lua_Integer' won't
++ * be read in at all. What to do?
++ */
++ *res_n = lua_str2real(s, &endptr);
++ if (endptr == s) return 0; /* conversion failed */
++ /* Visual C++ 2008 'strtod()' does not allow "0x..." input. */
++#if defined(_MSC_VER) && !defined(LNUM_FLOAT) && !defined(LNUM_INT64)
++ if (*res_n==0 && *endptr=='x') {
++ /* Hex constant too big for 'lua_Integer' but that could fit in 'lua_Number'
++ * integer bits
++ */
++ unsigned __int64 v= _strtoui64( s, &endptr, 16 );
++ /* We just let > 64 bit values be clamped to _UI64_MAX (MSDN does not say 'errno'==ERANGE would be set) */
++ *res_n= cast_num(v);
++ if (*res_n != v) return 0; /* Would have lost accuracy */
++ }
++#endif
++#ifdef LNUM_COMPLEX
++ if (*endptr == 'i') { endptr++; ret= TK_NUMBER2; }
++#endif
++ }
++ if (*endptr) {
++ while (isspace(cast(unsigned char, *endptr))) endptr++;
++ if (*endptr) return 0; /* invalid trail */
++ }
++ return ret;
++}
++
++
++/* Functions for finding out, when integer operations remain in range
++ * (and doing them).
++ */
++int try_addint( lua_Integer *r, lua_Integer ib, lua_Integer ic ) {
++ lua_Integer v= ib+ic; /* may overflow */
++ if (ib>0 && ic>0) { if (v < 0) return 0; /*overflow, use floats*/ }
++ else if (ib<0 && ic<0) { if (v >= 0) return 0; }
++ *r= v;
++ return 1;
++}
++
++int try_subint( lua_Integer *r, lua_Integer ib, lua_Integer ic ) {
++ lua_Integer v= ib-ic; /* may overflow */
++ if (ib>=0 && ic<0) { if (v < 0) return 0; /*overflow, use floats*/ }
++ else if (ib<0 && ic>0) { if (v >= 0) return 0; }
++ *r= v;
++ return 1;
++}
++
++int try_mulint( lua_Integer *r, lua_Integer ib, lua_Integer ic ) {
++ if (ib!=LUA_INTEGER_MIN && ic!=LUA_INTEGER_MIN) {
++ lua_Integer b= luai_abs(ib), c= luai_abs(ic);
++ if ( (ib==0) || (LUA_INTEGER_MAX/b >= c) ) {
++ *r= ib*ic; /* no overflow */
++ return 1;
++ }
++ } else if (ib==0 || ic==0) {
++ *r= 0; return 1;
++ }
++
++ /* Result can be LUA_INTEGER_MIN; if it is, calculating it using floating
++ * point will not cause accuracy loss.
++ */
++ if ( luai_nummul( cast_num(ib), cast_num(ic) ) == LUA_INTEGER_MIN ) {
++ *r= LUA_INTEGER_MIN;
++ return 1;
++ }
++ return 0;
++}
++
++int try_divint( lua_Integer *r, lua_Integer ib, lua_Integer ic ) {
++ /* N/0: leave to float side, to give an error
++ */
++ if (ic==0) return 0;
++
++ /* N/LUA_INTEGER_MIN: always non-integer results, or 0 or +1
++ */
++ if (ic==LUA_INTEGER_MIN) {
++ if (ib==LUA_INTEGER_MIN) { *r=1; return 1; }
++ if (ib==0) { *r=0; return 1; }
++
++ /* LUA_INTEGER_MIN (-2^31|63)/N: calculate using float side (either the division
++ * causes non-integer results, or there is no accuracy loss in int->fp->int
++ * conversions (N=2,4,8,..,256 and N=2^30,2^29,..2^23).
++ */
++ } else if (ib==LUA_INTEGER_MIN) {
++ lua_Number d= luai_numdiv( cast_num(LUA_INTEGER_MIN), cast_num(ic) );
++ lua_Integer i; lua_number2integer(i,d);
++ if (cast_num(i)==d) { *r= i; return 1; }
++
++ } else {
++ /* Note: We _can_ use ANSI C mod here, even on negative values, since
++ * we only test for == 0 (the sign would be implementation dependent).
++ */
++ if (ib%ic == 0) { *r= ib/ic; return 1; }
++ }
++
++ return 0;
++}
++
++int try_modint( lua_Integer *r, lua_Integer ib, lua_Integer ic ) {
++ if (ic!=0) {
++ /* ANSI C can be trusted when b%c==0, or when values are non-negative.
++ * b - (floor(b/c) * c)
++ * -->
++ * + +: b - (b/c) * c (b % c can be used)
++ * - -: b - (b/c) * c (b % c could work, but not defined by ANSI C)
++ * 0 -: b - (b/c) * c (=0, b % c could work, but not defined by ANSI C)
++ * - +: b - (b/c-1) * c (when b!=-c)
++ * + -: b - (b/c-1) * c (when b!=-c)
++ *
++ * o MIN%MIN ends up 0, via overflow in calcs but that does not matter.
++ * o MIN%MAX ends up MAX-1 (and other such numbers), also after overflow,
++ * but that does not matter, results do.
++ */
++ lua_Integer v= ib % ic;
++ if ( v!=0 && (ib<0 || ic<0) ) {
++ v= ib - ((ib/ic) - ((ib<=0 && ic<0) ? 0:1)) * ic;
++ }
++ /* Result should always have same sign as 2nd argument. (PIL2) */
++ lua_assert( (v<0) ? (ic<0) : (v>0) ? (ic>0) : 1 );
++ *r= v;
++ return 1;
++ }
++ return 0; /* let float side return NaN */
++}
++
++int try_powint( lua_Integer *r, lua_Integer ib, lua_Integer ic ) {
++
++ /* In FLOAT/INT32 or FLOAT|DOUBLE/INT64 modes, calculating integer powers
++ * via FP realm may lose accuracy (i.e. 7^11 = 1977326743, which fits int32
++ * but not 23-bit float mantissa).
++ *
++ * The current solution is dumb, but it works and uses little code. Use of
++ * integer powers is not anticipated to be very frequent (apart from 2^x,
++ * which is separately optimized).
++ */
++ if (ib==0) *r=0;
++ else if (ic<0) return 0; /* FP realm */
++ else if (ib==2 && ic < (int)sizeof(lua_Integer)*8-1) *r= ((lua_Integer)1)<<ic; /* 1,2,4,...2^30 | 2^62 optimization */
++ else if (ic==0) *r=1;
++ else if (luai_abs(ib)==1) *r= (ic%2) ? ib:1;
++ else {
++ lua_Integer x= ib;
++ while( --ic ) {
++ if (!try_mulint( &x, x, ib ))
++ return 0; /* FP realm */
++ }
++ *r= x;
++ }
++ return 1;
++}
++
++int try_unmint( lua_Integer *r, lua_Integer ib ) {
++ /* Negating LUA_INTEGER_MIN leaves the range. */
++ if ( ib != LUA_INTEGER_MIN )
++ { *r= -ib; return 1; }
++ return 0;
++}
++
+--- /dev/null
++++ b/src/lnum.h
+@@ -0,0 +1,116 @@
++/*
++** $Id: lnum.h,v ... $
++** Internal Number model
++** See Copyright Notice in lua.h
++*/
++
++#ifndef lnum_h
++#define lnum_h
++
++#include <math.h>
++
++#include "lobject.h"
++
++/*
++** The luai_num* macros define the primitive operations over 'lua_Number's
++** (not 'lua_Integer's, not 'lua_Complex').
++*/
++#define luai_numadd(a,b) ((a)+(b))
++#define luai_numsub(a,b) ((a)-(b))
++#define luai_nummul(a,b) ((a)*(b))
++#define luai_numdiv(a,b) ((a)/(b))
++#define luai_nummod(a,b) ((a) - _LF(floor)((a)/(b))*(b))
++#define luai_numpow(a,b) (_LF(pow)(a,b))
++#define luai_numunm(a) (-(a))
++#define luai_numeq(a,b) ((a)==(b))
++#define luai_numlt(a,b) ((a)<(b))
++#define luai_numle(a,b) ((a)<=(b))
++#define luai_numisnan(a) (!luai_numeq((a), (a)))
++
++int try_addint( lua_Integer *r, lua_Integer ib, lua_Integer ic );
++int try_subint( lua_Integer *r, lua_Integer ib, lua_Integer ic );
++int try_mulint( lua_Integer *r, lua_Integer ib, lua_Integer ic );
++int try_divint( lua_Integer *r, lua_Integer ib, lua_Integer ic );
++int try_modint( lua_Integer *r, lua_Integer ib, lua_Integer ic );
++int try_powint( lua_Integer *r, lua_Integer ib, lua_Integer ic );
++int try_unmint( lua_Integer *r, lua_Integer ib );
++
++#ifdef LNUM_COMPLEX
++ static inline lua_Complex luai_vectunm( lua_Complex a ) { return -a; }
++ static inline lua_Complex luai_vectadd( lua_Complex a, lua_Complex b ) { return a+b; }
++ static inline lua_Complex luai_vectsub( lua_Complex a, lua_Complex b ) { return a-b; }
++ static inline lua_Complex luai_vectmul( lua_Complex a, lua_Complex b ) { return a*b; }
++ static inline lua_Complex luai_vectdiv( lua_Complex a, lua_Complex b ) { return a/b; }
++
++/*
++ * C99 does not provide modulus for complex numbers. It most likely is not
++ * meaningful at all.
++ */
++
++/*
++ * Complex power
++ *
++ * C99 'cpow' gives inaccurate results for many common cases s.a. (1i)^2 ->
++ * -1+1.2246467991474e-16i (OS X 10.4, gcc 4.0.1 build 5367)
++ *
++ * [(a+bi)^(c+di)] = (r^c) * exp(-d*t) * cos(c*t + d*ln(r)) +
++ * = (r^c) * exp(-d*t) * sin(c*t + d*ln(r)) *i
++ * r = sqrt(a^2+b^2), t = arctan( b/a )
++ *
++ * Reference: <http://home.att.net/~srschmitt/complexnumbers.html>
++ * Could also be calculated using: x^y = exp(ln(x)*y)
++ *
++ * Note: Defined here (and not in .c) so 'lmathlib.c' can share the
++ * implementation.
++ */
++ static inline
++ lua_Complex luai_vectpow( lua_Complex a, lua_Complex b )
++ {
++# if 1
++ lua_Number ar= _LF(creal)(a), ai= _LF(cimag)(a);
++ lua_Number br= _LF(creal)(b), bi= _LF(cimag)(b);
++
++ if (ai==0 && bi==0) { /* a^c (real) */
++ return luai_numpow( ar, br );
++ }
++
++ int br_int= (int)br;
++
++ if ( ai!=0 && bi==0 && br_int==br && br_int!=0 && br_int!=INT_MIN ) {
++ /* (a+bi)^N, N = { +-1,+-2, ... +-INT_MAX }
++ */
++ lua_Number k= luai_numpow( _LF(sqrt) (ar*ar + ai*ai), br );
++ lua_Number cos_z, sin_z;
++
++ /* Situation depends upon c (N) in the following manner:
++ *
++ * N%4==0 => cos(c*t)=1, sin(c*t)=0
++ * (N*sign(b))%4==1 or (N*sign(b))%4==-3 => cos(c*t)=0, sin(c*t)=1
++ * N%4==2 or N%4==-2 => cos(c*t)=-1, sin(c*t)=0
++ * (N*sign(b))%4==-1 or (N*sign(b))%4==3 => cos(c*t)=0, sin(c*t)=-1
++ */
++ int br_int_abs = br_int<0 ? -br_int:br_int;
++
++ switch( (br_int_abs%4) * (br_int<0 ? -1:1) * (ai<0 ? -1:1) ) {
++ case 0: cos_z=1, sin_z=0; break;
++ case 2: case -2: cos_z=-1, sin_z=0; break;
++ case 1: case -3: cos_z=0, sin_z=1; break;
++ case 3: case -1: cos_z=0, sin_z=-1; break;
++ default: lua_assert(0); return 0;
++ }
++ return k*cos_z + (k*sin_z)*I;
++ }
++# endif
++ return _LF(cpow) ( a, b );
++ }
++#endif
++
++LUAI_FUNC int luaO_str2d (const char *s, lua_Number *res1, lua_Integer *res2);
++LUAI_FUNC void luaO_num2buf( char *s, const TValue *o );
++
++LUAI_FUNC int /*bool*/ tt_integer_valued( const TValue *o, lua_Integer *ref );
++
++#define luai_normalize(o) \
++{ lua_Integer _i; if (tt_integer_valued(o,&_i)) setivalue(o,_i); }
++
++#endif
+--- /dev/null
++++ b/src/lnum_config.h
+@@ -0,0 +1,221 @@
++/*
++** $Id: lnum_config.h,v ... $
++** Internal Number model
++** See Copyright Notice in lua.h
++*/
++
++#ifndef lnum_config_h
++#define lnum_config_h
++
++/*
++** Default number modes
++*/
++#if (!defined LNUM_DOUBLE) && (!defined LNUM_FLOAT) && (!defined LNUM_LDOUBLE)
++# define LNUM_FLOAT
++#endif
++#if (!defined LNUM_INT16) && (!defined LNUM_INT32) && (!defined LNUM_INT64)
++# define LNUM_INT32
++#endif
++
++/*
++** Require C99 mode for COMPLEX, FLOAT and LDOUBLE (only DOUBLE is ANSI C).
++*/
++#if defined(LNUM_COMPLEX) && (__STDC_VERSION__ < 199901L)
++# error "Need C99 for complex (use '--std=c99' or similar)"
++#elif defined(LNUM_LDOUBLE) && (__STDC_VERSION__ < 199901L) && !defined(_MSC_VER)
++# error "Need C99 for 'long double' (use '--std=c99' or similar)"
++#elif defined(LNUM_FLOAT) && (__STDC_VERSION__ < 199901L)
++/* LNUM_FLOAT not supported on Windows */
++# error "Need C99 for 'float' (use '--std=c99' or similar)"
++#endif
++
++/*
++** Number mode identifier to accompany the version string.
++*/
++#ifdef LNUM_COMPLEX
++# define _LNUM1 "complex "
++#else
++# define _LNUM1 ""
++#endif
++#ifdef LNUM_DOUBLE
++# define _LNUM2 "double"
++#elif defined(LNUM_FLOAT)
++# define _LNUM2 "float"
++#elif defined(LNUM_LDOUBLE)
++# define _LNUM2 "ldouble"
++#endif
++#ifdef LNUM_INT32
++# define _LNUM3 "int32"
++#elif defined(LNUM_INT64)
++# define _LNUM3 "int64"
++#elif defined(LNUM_INT16)
++# define _LNUM3 "int16"
++#endif
++#define LUA_LNUM _LNUM1 _LNUM2 " " _LNUM3
++
++/*
++** LUA_NUMBER is the type of floating point number in Lua
++** LUA_NUMBER_SCAN is the format for reading numbers.
++** LUA_NUMBER_FMT is the format for writing numbers.
++*/
++#ifdef LNUM_FLOAT
++# define LUA_NUMBER float
++# define LUA_NUMBER_SCAN "%f"
++# define LUA_NUMBER_FMT "%g"
++#elif (defined LNUM_DOUBLE)
++# define LUA_NUMBER double
++# define LUA_NUMBER_SCAN "%lf"
++# define LUA_NUMBER_FMT "%.14g"
++#elif (defined LNUM_LDOUBLE)
++# define LUA_NUMBER long double
++# define LUA_NUMBER_SCAN "%Lg"
++# define LUA_NUMBER_FMT "%.20Lg"
++#endif
++
++
++/*
++** LUAI_MAXNUMBER2STR: size of a buffer fitting any number->string result.
++**
++** double: 24 (sign, x.xxxxxxxxxxxxxxe+nnnn, and \0)
++** int64: 21 (19 digits, sign, and \0)
++** long double: 43 for 128-bit (sign, x.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxe+nnnn, and \0)
++** 30 for 80-bit (sign, x.xxxxxxxxxxxxxxxxxxxxe+nnnn, and \0)
++*/
++#ifdef LNUM_LDOUBLE
++# define _LUAI_MN2S 44
++#else
++# define _LUAI_MN2S 24
++#endif
++
++#ifdef LNUM_COMPLEX
++# define LUAI_MAXNUMBER2STR (2*_LUAI_MN2S)
++#else
++# define LUAI_MAXNUMBER2STR _LUAI_MN2S
++#endif
++
++/*
++** LUA_INTEGER is the integer type used by lua_pushinteger/lua_tointeger/lua_isinteger.
++** LUA_INTEGER_SCAN is the format for reading integers
++** LUA_INTEGER_FMT is the format for writing integers
++**
++** Note: Visual C++ 2005 does not have 'strtoull()', use '_strtoui64()' instead.
++*/
++#ifdef LNUM_INT32
++# if LUAI_BITSINT > 16
++# define LUA_INTEGER int
++# define LUA_INTEGER_SCAN "%d"
++# define LUA_INTEGER_FMT "%d"
++# else
++/* Note: 'LUA_INTEGER' being 'ptrdiff_t' (as in Lua 5.1) causes problems with
++ * 'printf()' operations. Also 'unsigned ptrdiff_t' is invalid.
++ */
++# define LUA_INTEGER long
++# define LUA_INTEGER_SCAN "%ld"
++# define LUA_INTEGER_FMT "%ld"
++# endif
++# define LUA_INTEGER_MAX 0x7FFFFFFF /* 2^31-1 */
++/* */
++#elif defined(LNUM_INT64)
++# define LUA_INTEGER long long
++# ifdef _MSC_VER
++# define lua_str2ul _strtoui64
++# else
++# define lua_str2ul strtoull
++# endif
++# define LUA_INTEGER_SCAN "%lld"
++# define LUA_INTEGER_FMT "%lld"
++# define LUA_INTEGER_MAX 0x7fffffffffffffffLL /* 2^63-1 */
++# define LUA_INTEGER_MIN (-LUA_INTEGER_MAX - 1LL) /* -2^63 */
++/* */
++#elif defined(LNUM_INT16)
++# if LUAI_BITSINT > 16
++# define LUA_INTEGER short
++# define LUA_INTEGER_SCAN "%hd"
++# define LUA_INTEGER_FMT "%hd"
++# else
++# define LUA_INTEGER int
++# define LUA_INTEGER_SCAN "%d"
++# define LUA_INTEGER_FMT "%d"
++# endif
++# define LUA_INTEGER_MAX 0x7FFF /* 2^16-1 */
++#endif
++
++#ifndef lua_str2ul
++# define lua_str2ul (unsigned LUA_INTEGER)strtoul
++#endif
++#ifndef LUA_INTEGER_MIN
++# define LUA_INTEGER_MIN (-LUA_INTEGER_MAX -1) /* -2^16|32 */
++#endif
++
++/*
++@@ lua_number2int is a macro to convert lua_Number to int.
++@@ lua_number2integer is a macro to convert lua_Number to lua_Integer.
++** CHANGE them if you know a faster way to convert a lua_Number to
++** int (with any rounding method and without throwing errors) in your
++** system. In Pentium machines, a naive typecast from double to int
++** in C is extremely slow, so any alternative is worth trying.
++*/
++
++/* On a Pentium, resort to a trick */
++#if defined(LNUM_DOUBLE) && !defined(LUA_ANSI) && !defined(__SSE2__) && \
++ (defined(__i386) || defined (_M_IX86) || defined(__i386__))
++
++/* On a Microsoft compiler, use assembler */
++# if defined(_MSC_VER)
++# define lua_number2int(i,d) __asm fld d __asm fistp i
++# else
++
++/* the next trick should work on any Pentium, but sometimes clashes
++ with a DirectX idiosyncrasy */
++union luai_Cast { double l_d; long l_l; };
++# define lua_number2int(i,d) \
++ { volatile union luai_Cast u; u.l_d = (d) + 6755399441055744.0; (i) = u.l_l; }
++# endif
++
++# ifndef LNUM_INT64
++# define lua_number2integer lua_number2int
++# endif
++
++/* this option always works, but may be slow */
++#else
++# define lua_number2int(i,d) ((i)=(int)(d))
++#endif
++
++/* Note: Some compilers (OS X gcc 4.0?) may choke on double->long long conversion
++ * since it can lose precision. Others do require 'long long' there.
++ */
++#ifndef lua_number2integer
++# define lua_number2integer(i,d) ((i)=(lua_Integer)(d))
++#endif
++
++/*
++** 'luai_abs()' to give absolute value of 'lua_Integer'
++*/
++#ifdef LNUM_INT32
++# define luai_abs abs
++#elif defined(LNUM_INT64) && (__STDC_VERSION__ >= 199901L)
++# define luai_abs llabs
++#else
++# define luai_abs(v) ((v) >= 0 ? (v) : -(v))
++#endif
++
++/*
++** LUAI_UACNUMBER is the result of an 'usual argument conversion' over a number.
++** LUAI_UACINTEGER the same, over an integer.
++*/
++#define LUAI_UACNUMBER double
++#define LUAI_UACINTEGER long
++
++/* ANSI C only has math funcs for 'double. C99 required for float and long double
++ * variants.
++ */
++#ifdef LNUM_DOUBLE
++# define _LF(name) name
++#elif defined(LNUM_FLOAT)
++# define _LF(name) name ## f
++#elif defined(LNUM_LDOUBLE)
++# define _LF(name) name ## l
++#endif
++
++#endif
++
+--- a/src/lobject.c
++++ b/src/lobject.c
+@@ -21,7 +21,8 @@
+ #include "lstate.h"
+ #include "lstring.h"
+ #include "lvm.h"
+-
++#include "llex.h"
++#include "lnum.h"
+
+
+ const TValue luaO_nilobject_ = {{NULL}, LUA_TNIL};
+@@ -70,12 +71,31 @@ int luaO_log2 (unsigned int x) {
+
+
+ int luaO_rawequalObj (const TValue *t1, const TValue *t2) {
+- if (ttype(t1) != ttype(t2)) return 0;
++ if (!ttype_ext_same(t1,t2)) return 0;
+ else switch (ttype(t1)) {
+ case LUA_TNIL:
+ return 1;
++ case LUA_TINT:
++ if (ttype(t2)==LUA_TINT)
++ return ivalue(t1) == ivalue(t2);
++ else { /* t1:int, t2:num */
++#ifdef LNUM_COMPLEX
++ if (nvalue_img_fast(t2) != 0) return 0;
++#endif
++ /* Avoid doing accuracy losing cast, if possible. */
++ lua_Integer tmp;
++ if (tt_integer_valued(t2,&tmp))
++ return ivalue(t1) == tmp;
++ else
++ return luai_numeq( cast_num(ivalue(t1)), nvalue_fast(t2) );
++ }
+ case LUA_TNUMBER:
+- return luai_numeq(nvalue(t1), nvalue(t2));
++ if (ttype(t2)==LUA_TINT)
++ return luaO_rawequalObj(t2, t1); /* swap LUA_TINT to left */
++#ifdef LNUM_COMPLEX
++ if (!luai_numeq(nvalue_img_fast(t1), nvalue_img_fast(t2))) return 0;
++#endif
++ return luai_numeq(nvalue_fast(t1), nvalue_fast(t2));
+ case LUA_TBOOLEAN:
+ return bvalue(t1) == bvalue(t2); /* boolean true must be 1 !! */
+ case LUA_TLIGHTUSERDATA:
+@@ -86,21 +106,6 @@ int luaO_rawequalObj (const TValue *t1,
+ }
+ }
+
+-
+-int luaO_str2d (const char *s, lua_Number *result) {
+- char *endptr;
+- *result = lua_str2number(s, &endptr);
+- if (endptr == s) return 0; /* conversion failed */
+- if (*endptr == 'x' || *endptr == 'X') /* maybe an hexadecimal constant? */
+- *result = cast_num(strtoul(s, &endptr, 16));
+- if (*endptr == '\0') return 1; /* most common case */
+- while (isspace(cast(unsigned char, *endptr))) endptr++;
+- if (*endptr != '\0') return 0; /* invalid trailing characters? */
+- return 1;
+-}
+-
+-
+-
+ static void pushstr (lua_State *L, const char *str) {
+ setsvalue2s(L, L->top, luaS_new(L, str));
+ incr_top(L);
+@@ -131,7 +136,11 @@ const char *luaO_pushvfstring (lua_State
+ break;
+ }
+ case 'd': {
+- setnvalue(L->top, cast_num(va_arg(argp, int)));
++ /* This is tricky for 64-bit integers; maybe they even cannot be
++ * supported on all compilers; depends on the conversions applied to
++ * variable argument lists. TBD: test!
++ */
++ setivalue(L->top, (lua_Integer) va_arg(argp, l_uacInteger));
+ incr_top(L);
+ break;
+ }
+@@ -212,3 +221,4 @@ void luaO_chunkid (char *out, const char
+ }
+ }
+ }
++
+--- a/src/lobject.h
++++ b/src/lobject.h
+@@ -17,7 +17,11 @@
+
+
+ /* tags for values visible from Lua */
+-#define LAST_TAG LUA_TTHREAD
++#if LUA_TINT > LUA_TTHREAD
++# define LAST_TAG LUA_TINT
++#else
++# define LAST_TAG LUA_TTHREAD
++#endif
+
+ #define NUM_TAGS (LAST_TAG+1)
+
+@@ -59,7 +63,12 @@ typedef struct GCheader {
+ typedef union {
+ GCObject *gc;
+ void *p;
++#ifdef LNUM_COMPLEX
++ lua_Complex n;
++#else
+ lua_Number n;
++#endif
++ lua_Integer i;
+ int b;
+ } Value;
+
+@@ -77,7 +86,11 @@ typedef struct lua_TValue {
+
+ /* Macros to test type */
+ #define ttisnil(o) (ttype(o) == LUA_TNIL)
+-#define ttisnumber(o) (ttype(o) == LUA_TNUMBER)
++#define ttisint(o) (ttype(o) == LUA_TINT)
++#define ttisnumber(o) ((ttype(o) == LUA_TINT) || (ttype(o) == LUA_TNUMBER))
++#ifdef LNUM_COMPLEX
++# define ttiscomplex(o) ((ttype(o) == LUA_TNUMBER) && (nvalue_img_fast(o)!=0))
++#endif
+ #define ttisstring(o) (ttype(o) == LUA_TSTRING)
+ #define ttistable(o) (ttype(o) == LUA_TTABLE)
+ #define ttisfunction(o) (ttype(o) == LUA_TFUNCTION)
+@@ -90,7 +103,25 @@ typedef struct lua_TValue {
+ #define ttype(o) ((o)->tt)
+ #define gcvalue(o) check_exp(iscollectable(o), (o)->value.gc)
+ #define pvalue(o) check_exp(ttislightuserdata(o), (o)->value.p)
+-#define nvalue(o) check_exp(ttisnumber(o), (o)->value.n)
++
++#define ttype_ext(o) ( ttype(o) == LUA_TINT ? LUA_TNUMBER : ttype(o) )
++#define ttype_ext_same(o1,o2) ( (ttype(o1)==ttype(o2)) || (ttisnumber(o1) && ttisnumber(o2)) )
++
++/* '_fast' variants are for cases where 'ttype(o)' is known to be LUA_TNUMBER.
++ */
++#ifdef LNUM_COMPLEX
++# define nvalue_complex_fast(o) check_exp( ttype(o)==LUA_TNUMBER, (o)->value.n )
++# define nvalue_fast(o) ( _LF(creal) ( nvalue_complex_fast(o) ) )
++# define nvalue_img_fast(o) ( _LF(cimag) ( nvalue_complex_fast(o) ) )
++# define nvalue_complex(o) check_exp( ttisnumber(o), (ttype(o)==LUA_TINT) ? (o)->value.i : (o)->value.n )
++# define nvalue_img(o) check_exp( ttisnumber(o), (ttype(o)==LUA_TINT) ? 0 : _LF(cimag)( (o)->value.n ) )
++# define nvalue(o) check_exp( ttisnumber(o), (ttype(o)==LUA_TINT) ? cast_num((o)->value.i) : _LF(creal)((o)->value.n) )
++#else
++# define nvalue(o) check_exp( ttisnumber(o), (ttype(o)==LUA_TINT) ? cast_num((o)->value.i) : (o)->value.n )
++# define nvalue_fast(o) check_exp( ttype(o)==LUA_TNUMBER, (o)->value.n )
++#endif
++#define ivalue(o) check_exp( ttype(o)==LUA_TINT, (o)->value.i )
++
+ #define rawtsvalue(o) check_exp(ttisstring(o), &(o)->value.gc->ts)
+ #define tsvalue(o) (&rawtsvalue(o)->tsv)
+ #define rawuvalue(o) check_exp(ttisuserdata(o), &(o)->value.gc->u)
+@@ -116,8 +147,27 @@ typedef struct lua_TValue {
+ /* Macros to set values */
+ #define setnilvalue(obj) ((obj)->tt=LUA_TNIL)
+
+-#define setnvalue(obj,x) \
+- { TValue *i_o=(obj); i_o->value.n=(x); i_o->tt=LUA_TNUMBER; }
++/* Must not have side effects, 'x' may be expression.
++*/
++#define setivalue(obj,x) \
++ { TValue *i_o=(obj); i_o->value.i=(x); i_o->tt=LUA_TINT; }
++
++# define setnvalue(obj,x) \
++ { TValue *i_o=(obj); i_o->value.n= (x); i_o->tt=LUA_TNUMBER; }
++
++/* Note: Complex always has "inline", both are C99.
++*/
++#ifdef LNUM_COMPLEX
++ static inline void setnvalue_complex_fast( TValue *obj, lua_Complex x ) {
++ lua_assert( _LF(cimag)(x) != 0 );
++ obj->value.n= x; obj->tt= LUA_TNUMBER;
++ }
++ static inline void setnvalue_complex( TValue *obj, lua_Complex x ) {
++ if (_LF(cimag)(x) == 0) { setnvalue(obj, _LF(creal)(x)); }
++ else { obj->value.n= x; obj->tt= LUA_TNUMBER; }
++ }
++#endif
++
+
+ #define setpvalue(obj,x) \
+ { TValue *i_o=(obj); i_o->value.p=(x); i_o->tt=LUA_TLIGHTUSERDATA; }
+@@ -155,9 +205,6 @@ typedef struct lua_TValue {
+ i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TPROTO; \
+ checkliveness(G(L),i_o); }
+
+-
+-
+-
+ #define setobj(L,obj1,obj2) \
+ { const TValue *o2=(obj2); TValue *o1=(obj1); \
+ o1->value = o2->value; o1->tt=o2->tt; \
+@@ -185,8 +232,11 @@ typedef struct lua_TValue {
+
+ #define setttype(obj, tt) (ttype(obj) = (tt))
+
+-
+-#define iscollectable(o) (ttype(o) >= LUA_TSTRING)
++#if LUA_TINT >= LUA_TSTRING
++# define iscollectable(o) ((ttype(o) >= LUA_TSTRING) && (ttype(o) != LUA_TINT))
++#else
++# define iscollectable(o) (ttype(o) >= LUA_TSTRING)
++#endif
+
+
+
+@@ -370,12 +420,10 @@ LUAI_FUNC int luaO_log2 (unsigned int x)
+ LUAI_FUNC int luaO_int2fb (unsigned int x);
+ LUAI_FUNC int luaO_fb2int (int x);
+ LUAI_FUNC int luaO_rawequalObj (const TValue *t1, const TValue *t2);
+-LUAI_FUNC int luaO_str2d (const char *s, lua_Number *result);
+ LUAI_FUNC const char *luaO_pushvfstring (lua_State *L, const char *fmt,
+ va_list argp);
+ LUAI_FUNC const char *luaO_pushfstring (lua_State *L, const char *fmt, ...);
+ LUAI_FUNC void luaO_chunkid (char *out, const char *source, size_t len);
+
+-
+ #endif
+
+--- a/src/loslib.c
++++ b/src/loslib.c
+@@ -186,15 +186,30 @@ static int os_time (lua_State *L) {
+ }
+ if (t == (time_t)(-1))
+ lua_pushnil(L);
+- else
+- lua_pushnumber(L, (lua_Number)t);
++ else {
++ /* On float systems the pushed value must be an integer, NOT a number.
++ * Otherwise, accuracy is lost in the time_t->float conversion.
++ */
++#ifdef LNUM_FLOAT
++ lua_pushinteger(L, (lua_Integer) t);
++#else
++ lua_pushnumber(L, (lua_Number) t);
++#endif
++ }
+ return 1;
+ }
+
+
+ static int os_difftime (lua_State *L) {
++#ifdef LNUM_FLOAT
++ lua_Integer i= (lua_Integer)
++ difftime( (time_t)(luaL_checkinteger(L, 1)),
++ (time_t)(luaL_optinteger(L, 2, 0)));
++ lua_pushinteger(L, i);
++#else
+ lua_pushnumber(L, difftime((time_t)(luaL_checknumber(L, 1)),
+ (time_t)(luaL_optnumber(L, 2, 0))));
++#endif
+ return 1;
+ }
+
+--- a/src/lparser.c
++++ b/src/lparser.c
+@@ -33,7 +33,6 @@
+
+ #define luaY_checklimit(fs,v,l,m) if ((v)>(l)) errorlimit(fs,l,m)
+
+-
+ /*
+ ** nodes for block list (list of active blocks)
+ */
+@@ -72,7 +71,7 @@ static void errorlimit (FuncState *fs, i
+ const char *msg = (fs->f->linedefined == 0) ?
+ luaO_pushfstring(fs->L, "main function has more than %d %s", limit, what) :
+ luaO_pushfstring(fs->L, "function at line %d has more than %d %s",
+- fs->f->linedefined, limit, what);
++ (fs->f->linedefined), limit, what);
+ luaX_lexerror(fs->ls, msg, 0);
+ }
+
+@@ -733,6 +732,18 @@ static void simpleexp (LexState *ls, exp
+ v->u.nval = ls->t.seminfo.r;
+ break;
+ }
++ case TK_INT: {
++ init_exp(v, VKINT, 0);
++ v->u.ival = ls->t.seminfo.i;
++ break;
++ }
++#ifdef LNUM_COMPLEX
++ case TK_NUMBER2: {
++ init_exp(v, VKNUM2, 0);
++ v->u.nval = ls->t.seminfo.r;
++ break;
++ }
++#endif
+ case TK_STRING: {
+ codestring(ls, v, ls->t.seminfo.ts);
+ break;
+@@ -1079,7 +1090,7 @@ static void fornum (LexState *ls, TStrin
+ if (testnext(ls, ','))
+ exp1(ls); /* optional step */
+ else { /* default step = 1 */
+- luaK_codeABx(fs, OP_LOADK, fs->freereg, luaK_numberK(fs, 1));
++ luaK_codeABx(fs, OP_LOADK, fs->freereg, luaK_integerK(fs, 1));
+ luaK_reserveregs(fs, 1);
+ }
+ forbody(ls, base, line, 1, 1);
+--- a/src/lparser.h
++++ b/src/lparser.h
+@@ -31,7 +31,11 @@ typedef enum {
+ VRELOCABLE, /* info = instruction pc */
+ VNONRELOC, /* info = result register */
+ VCALL, /* info = instruction pc */
+- VVARARG /* info = instruction pc */
++ VVARARG, /* info = instruction pc */
++ VKINT /* ival = integer value */
++#ifdef LNUM_COMPLEX
++ ,VKNUM2 /* nval = imaginary value */
++#endif
+ } expkind;
+
+ typedef struct expdesc {
+@@ -39,6 +43,7 @@ typedef struct expdesc {
+ union {
+ struct { int info, aux; } s;
+ lua_Number nval;
++ lua_Integer ival;
+ } u;
+ int t; /* patch list of `exit when true' */
+ int f; /* patch list of `exit when false' */
+--- a/src/lstrlib.c
++++ b/src/lstrlib.c
+@@ -43,8 +43,8 @@ static ptrdiff_t posrelat (ptrdiff_t pos
+ static int str_sub (lua_State *L) {
+ size_t l;
+ const char *s = luaL_checklstring(L, 1, &l);
+- ptrdiff_t start = posrelat(luaL_checkinteger(L, 2), l);
+- ptrdiff_t end = posrelat(luaL_optinteger(L, 3, -1), l);
++ ptrdiff_t start = posrelat(luaL_checkint32(L, 2), l);
++ ptrdiff_t end = posrelat(luaL_optint32(L, 3, -1), l);
+ if (start < 1) start = 1;
+ if (end > (ptrdiff_t)l) end = (ptrdiff_t)l;
+ if (start <= end)
+@@ -106,8 +106,8 @@ static int str_rep (lua_State *L) {
+ static int str_byte (lua_State *L) {
+ size_t l;
+ const char *s = luaL_checklstring(L, 1, &l);
+- ptrdiff_t posi = posrelat(luaL_optinteger(L, 2, 1), l);
+- ptrdiff_t pose = posrelat(luaL_optinteger(L, 3, posi), l);
++ ptrdiff_t posi = posrelat(luaL_optint32(L, 2, 1), l);
++ ptrdiff_t pose = posrelat(luaL_optint32(L, 3, posi), l);
+ int n, i;
+ if (posi <= 0) posi = 1;
+ if ((size_t)pose > l) pose = l;
+@@ -496,7 +496,7 @@ static int str_find_aux (lua_State *L, i
+ size_t l1, l2;
+ const char *s = luaL_checklstring(L, 1, &l1);
+ const char *p = luaL_checklstring(L, 2, &l2);
+- ptrdiff_t init = posrelat(luaL_optinteger(L, 3, 1), l1) - 1;
++ ptrdiff_t init = posrelat(luaL_optint32(L, 3, 1), l1) - 1;
+ if (init < 0) init = 0;
+ else if ((size_t)(init) > l1) init = (ptrdiff_t)l1;
+ if (find && (lua_toboolean(L, 4) || /* explicit request? */
+@@ -690,7 +690,7 @@ static int str_gsub (lua_State *L) {
+ ** maximum size of each format specification (such as '%-099.99d')
+ ** (+10 accounts for %99.99x plus margin of error)
+ */
+-#define MAX_FORMAT (sizeof(FLAGS) + sizeof(LUA_INTFRMLEN) + 10)
++#define MAX_FORMAT (sizeof(FLAGS) + sizeof(LUA_INTEGER_FMT)-2 + 10)
+
+
+ static void addquoted (lua_State *L, luaL_Buffer *b, int arg) {
+@@ -747,9 +747,9 @@ static const char *scanformat (lua_State
+ static void addintlen (char *form) {
+ size_t l = strlen(form);
+ char spec = form[l - 1];
+- strcpy(form + l - 1, LUA_INTFRMLEN);
+- form[l + sizeof(LUA_INTFRMLEN) - 2] = spec;
+- form[l + sizeof(LUA_INTFRMLEN) - 1] = '\0';
++ const char *tmp= LUA_INTEGER_FMT; /* "%lld" or "%ld" */
++ strcpy(form + l - 1, tmp+1);
++ form[l + sizeof(LUA_INTEGER_FMT)-4] = spec;
+ }
+
+
+@@ -779,12 +779,12 @@ static int str_format (lua_State *L) {
+ }
+ case 'd': case 'i': {
+ addintlen(form);
+- sprintf(buff, form, (LUA_INTFRM_T)luaL_checknumber(L, arg));
++ sprintf(buff, form, luaL_checkinteger(L, arg));
+ break;
+ }
+ case 'o': case 'u': case 'x': case 'X': {
+ addintlen(form);
+- sprintf(buff, form, (unsigned LUA_INTFRM_T)luaL_checknumber(L, arg));
++ sprintf(buff, form, (unsigned LUA_INTEGER)luaL_checkinteger(L, arg));
+ break;
+ }
+ case 'e': case 'E': case 'f':
+--- a/src/ltable.c
++++ b/src/ltable.c
+@@ -33,6 +33,7 @@
+ #include "lobject.h"
+ #include "lstate.h"
+ #include "ltable.h"
++#include "lnum.h"
+
+
+ /*
+@@ -51,25 +52,15 @@
+
+ #define hashstr(t,str) hashpow2(t, (str)->tsv.hash)
+ #define hashboolean(t,p) hashpow2(t, p)
+-
++#define hashint(t,i) hashpow2(t,i)
+
+ /*
+ ** for some types, it is better to avoid modulus by power of 2, as
+ ** they tend to have many 2 factors.
+ */
+ #define hashmod(t,n) (gnode(t, ((n) % ((sizenode(t)-1)|1))))
+-
+-
+ #define hashpointer(t,p) hashmod(t, IntPoint(p))
+
+-
+-/*
+-** number of ints inside a lua_Number
+-*/
+-#define numints cast_int(sizeof(lua_Number)/sizeof(int))
+-
+-
+-
+ #define dummynode (&dummynode_)
+
+ static const Node dummynode_ = {
+@@ -80,27 +71,46 @@ static const Node dummynode_ = {
+
+ /*
+ ** hash for lua_Numbers
++**
++** for non-complex modes, never called with 'lua_Integer' value range (s.a. 0)
+ */
+ static Node *hashnum (const Table *t, lua_Number n) {
+- unsigned int a[numints];
+- int i;
+- if (luai_numeq(n, 0)) /* avoid problems with -0 */
+- return gnode(t, 0);
+- memcpy(a, &n, sizeof(a));
+- for (i = 1; i < numints; i++) a[0] += a[i];
+- return hashmod(t, a[0]);
++ const unsigned int *p= cast(const unsigned int *,&n);
++ unsigned int sum= *p;
++ unsigned int m= sizeof(lua_Number)/sizeof(int);
++ unsigned int i;
++ /* OS X Intel has 'm'==4 and gives "Bus error" if the last integer of
++ * 'n' is read; the actual size of long double is only 80 bits = 10 bytes.
++ * Linux x86 has 'm'==3, and does not require reduction.
++ */
++#if defined(LNUM_LDOUBLE) && defined(__i386__)
++ if (m>3) m--;
++#endif
++ for (i = 1; i < m; i++) sum += p[i];
++ return hashmod(t, sum);
+ }
+
+
+-
+ /*
+ ** returns the `main' position of an element in a table (that is, the index
+ ** of its hash value)
++**
++** Floating point numbers with integer value give the hash position of the
++** integer (so they use the same table position).
+ */
+ static Node *mainposition (const Table *t, const TValue *key) {
++ lua_Integer i;
+ switch (ttype(key)) {
+ case LUA_TNUMBER:
+- return hashnum(t, nvalue(key));
++ if (tt_integer_valued(key,&i))
++ return hashint(t, i);
++#ifdef LNUM_COMPLEX
++ if (nvalue_img_fast(key)!=0 && luai_numeq(nvalue_fast(key),0))
++ return gnode(t, 0); /* 0 and -0 to give same hash */
++#endif
++ return hashnum(t, nvalue_fast(key));
++ case LUA_TINT:
++ return hashint(t, ivalue(key));
+ case LUA_TSTRING:
+ return hashstr(t, rawtsvalue(key));
+ case LUA_TBOOLEAN:
+@@ -116,16 +126,20 @@ static Node *mainposition (const Table *
+ /*
+ ** returns the index for `key' if `key' is an appropriate key to live in
+ ** the array part of the table, -1 otherwise.
++**
++** Anything <=0 is taken as not being in the array part.
+ */
+-static int arrayindex (const TValue *key) {
+- if (ttisnumber(key)) {
+- lua_Number n = nvalue(key);
+- int k;
+- lua_number2int(k, n);
+- if (luai_numeq(cast_num(k), n))
+- return k;
++static int arrayindex (const TValue *key, int max) {
++ lua_Integer k;
++ switch( ttype(key) ) {
++ case LUA_TINT:
++ k= ivalue(key); break;
++ case LUA_TNUMBER:
++ if (tt_integer_valued(key,&k)) break;
++ default:
++ return -1; /* not to be used as array index */
+ }
+- return -1; /* `key' did not match some condition */
++ return ((k>0) && (k <= max)) ? cast_int(k) : -1;
+ }
+
+
+@@ -137,8 +151,8 @@ static int arrayindex (const TValue *key
+ static int findindex (lua_State *L, Table *t, StkId key) {
+ int i;
+ if (ttisnil(key)) return -1; /* first iteration */
+- i = arrayindex(key);
+- if (0 < i && i <= t->sizearray) /* is `key' inside array part? */
++ i = arrayindex(key, t->sizearray);
++ if (i>0) /* inside array part? */
+ return i-1; /* yes; that's the index (corrected to C) */
+ else {
+ Node *n = mainposition(t, key);
+@@ -163,7 +177,7 @@ int luaH_next (lua_State *L, Table *t, S
+ int i = findindex(L, t, key); /* find original element */
+ for (i++; i < t->sizearray; i++) { /* try first array part */
+ if (!ttisnil(&t->array[i])) { /* a non-nil value? */
+- setnvalue(key, cast_num(i+1));
++ setivalue(key, i+1);
+ setobj2s(L, key+1, &t->array[i]);
+ return 1;
+ }
+@@ -209,8 +223,8 @@ static int computesizes (int nums[], int
+
+
+ static int countint (const TValue *key, int *nums) {
+- int k = arrayindex(key);
+- if (0 < k && k <= MAXASIZE) { /* is `key' an appropriate array index? */
++ int k = arrayindex(key,MAXASIZE);
++ if (k>0) { /* appropriate array index? */
+ nums[ceillog2(k)]++; /* count as such */
+ return 1;
+ }
+@@ -308,7 +322,7 @@ static void resize (lua_State *L, Table
+ /* re-insert elements from vanishing slice */
+ for (i=nasize; i<oldasize; i++) {
+ if (!ttisnil(&t->array[i]))
+- setobjt2t(L, luaH_setnum(L, t, i+1), &t->array[i]);
++ setobjt2t(L, luaH_setint(L, t, i+1), &t->array[i]);
+ }
+ /* shrink array */
+ luaM_reallocvector(L, t->array, oldasize, nasize, TValue);
+@@ -409,7 +423,9 @@ static TValue *newkey (lua_State *L, Tab
+ othern = mainposition(t, key2tval(mp));
+ if (othern != mp) { /* is colliding node out of its main position? */
+ /* yes; move colliding node into free position */
+- while (gnext(othern) != mp) othern = gnext(othern); /* find previous */
++ while (gnext(othern) != mp) {
++ othern = gnext(othern); /* find previous */
++ }
+ gnext(othern) = n; /* redo the chain with `n' in place of `mp' */
+ *n = *mp; /* copy colliding node into free pos. (mp->next also goes) */
+ gnext(mp) = NULL; /* now `mp' is free */
+@@ -432,17 +448,18 @@ static TValue *newkey (lua_State *L, Tab
+ /*
+ ** search function for integers
+ */
+-const TValue *luaH_getnum (Table *t, int key) {
++const TValue *luaH_getint (Table *t, lua_Integer key) {
+ /* (1 <= key && key <= t->sizearray) */
+ if (cast(unsigned int, key-1) < cast(unsigned int, t->sizearray))
+ return &t->array[key-1];
+ else {
+- lua_Number nk = cast_num(key);
+- Node *n = hashnum(t, nk);
++ Node *n = hashint(t, key);
+ do { /* check whether `key' is somewhere in the chain */
+- if (ttisnumber(gkey(n)) && luai_numeq(nvalue(gkey(n)), nk))
++ if (ttisint(gkey(n)) && (ivalue(gkey(n)) == key)) {
+ return gval(n); /* that's it */
+- else n = gnext(n);
++ } else {
++ n = gnext(n);
++ }
+ } while (n);
+ return luaO_nilobject;
+ }
+@@ -470,14 +487,12 @@ const TValue *luaH_get (Table *t, const
+ switch (ttype(key)) {
+ case LUA_TNIL: return luaO_nilobject;
+ case LUA_TSTRING: return luaH_getstr(t, rawtsvalue(key));
++ case LUA_TINT: return luaH_getint(t, ivalue(key));
+ case LUA_TNUMBER: {
+- int k;
+- lua_Number n = nvalue(key);
+- lua_number2int(k, n);
+- if (luai_numeq(cast_num(k), nvalue(key))) /* index is int? */
+- return luaH_getnum(t, k); /* use specialized version */
+- /* else go through */
+- }
++ lua_Integer i;
++ if (tt_integer_valued(key,&i))
++ return luaH_getint(t,i);
++ } /* pass through */
+ default: {
+ Node *n = mainposition(t, key);
+ do { /* check whether `key' is somewhere in the chain */
+@@ -498,20 +513,25 @@ TValue *luaH_set (lua_State *L, Table *t
+ return cast(TValue *, p);
+ else {
+ if (ttisnil(key)) luaG_runerror(L, "table index is nil");
+- else if (ttisnumber(key) && luai_numisnan(nvalue(key)))
+- luaG_runerror(L, "table index is NaN");
++ else if (ttype(key)==LUA_TNUMBER) {
++ lua_Integer k;
++ if (luai_numisnan(nvalue_fast(key)))
++ luaG_runerror(L, "table index is NaN");
++ if (tt_integer_valued(key,&k))
++ return luaH_setint(L, t, k);
++ }
+ return newkey(L, t, key);
+ }
+ }
+
+
+-TValue *luaH_setnum (lua_State *L, Table *t, int key) {
+- const TValue *p = luaH_getnum(t, key);
++TValue *luaH_setint (lua_State *L, Table *t, lua_Integer key) {
++ const TValue *p = luaH_getint(t, key);
+ if (p != luaO_nilobject)
+ return cast(TValue *, p);
+ else {
+ TValue k;
+- setnvalue(&k, cast_num(key));
++ setivalue(&k, key);
+ return newkey(L, t, &k);
+ }
+ }
+@@ -533,20 +553,21 @@ static int unbound_search (Table *t, uns
+ unsigned int i = j; /* i is zero or a present index */
+ j++;
+ /* find `i' and `j' such that i is present and j is not */
+- while (!ttisnil(luaH_getnum(t, j))) {
++ while (!ttisnil(luaH_getint(t, j))) {
+ i = j;
+ j *= 2;
+ if (j > cast(unsigned int, MAX_INT)) { /* overflow? */
+ /* table was built with bad purposes: resort to linear search */
+- i = 1;
+- while (!ttisnil(luaH_getnum(t, i))) i++;
+- return i - 1;
++ for( i = 1; i<MAX_INT+1; i++ ) {
++ if (ttisnil(luaH_getint(t, i))) break;
++ }
++ return i - 1; /* up to MAX_INT */
+ }
+ }
+ /* now do a binary search between them */
+ while (j - i > 1) {
+ unsigned int m = (i+j)/2;
+- if (ttisnil(luaH_getnum(t, m))) j = m;
++ if (ttisnil(luaH_getint(t, m))) j = m;
+ else i = m;
+ }
+ return i;
+--- a/src/ltable.h
++++ b/src/ltable.h
+@@ -18,8 +18,8 @@
+ #define key2tval(n) (&(n)->i_key.tvk)
+
+
+-LUAI_FUNC const TValue *luaH_getnum (Table *t, int key);
+-LUAI_FUNC TValue *luaH_setnum (lua_State *L, Table *t, int key);
++LUAI_FUNC const TValue *luaH_getint (Table *t, lua_Integer key);
++LUAI_FUNC TValue *luaH_setint (lua_State *L, Table *t, lua_Integer key);
+ LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key);
+ LUAI_FUNC TValue *luaH_setstr (lua_State *L, Table *t, TString *key);
+ LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key);
+--- a/src/ltm.c
++++ b/src/ltm.c
+@@ -19,7 +19,6 @@
+ #include "ltm.h"
+
+
+-
+ const char *const luaT_typenames[] = {
+ "nil", "boolean", "userdata", "number",
+ "string", "table", "function", "userdata", "thread",
+@@ -67,6 +66,9 @@ const TValue *luaT_gettmbyobj (lua_State
+ case LUA_TUSERDATA:
+ mt = uvalue(o)->metatable;
+ break;
++ case LUA_TINT:
++ mt = G(L)->mt[LUA_TNUMBER];
++ break;
+ default:
+ mt = G(L)->mt[ttype(o)];
+ }
+--- a/src/lua.c
++++ b/src/lua.c
+@@ -16,7 +16,7 @@
+
+ #include "lauxlib.h"
+ #include "lualib.h"
+-
++#include "llimits.h"
+
+
+ static lua_State *globalL = NULL;
+@@ -382,6 +382,15 @@ int main (int argc, char **argv) {
+ l_message(argv[0], "cannot create state: not enough memory");
+ return EXIT_FAILURE;
+ }
++ /* Checking 'sizeof(lua_Integer)' cannot be made in preprocessor on all compilers.
++ */
++#ifdef LNUM_INT16
++ lua_assert( sizeof(lua_Integer) == 2 );
++#elif defined(LNUM_INT32)
++ lua_assert( sizeof(lua_Integer) == 4 );
++#elif defined(LNUM_INT64)
++ lua_assert( sizeof(lua_Integer) == 8 );
++#endif
+ s.argc = argc;
+ s.argv = argv;
+ status = lua_cpcall(L, &pmain, &s);
+--- a/src/lua.h
++++ b/src/lua.h
+@@ -19,7 +19,7 @@
+ #define LUA_VERSION "Lua 5.1"
+ #define LUA_RELEASE "Lua 5.1.5"
+ #define LUA_VERSION_NUM 501
+-#define LUA_COPYRIGHT "Copyright (C) 1994-2012 Lua.org, PUC-Rio"
++#define LUA_COPYRIGHT "Copyright (C) 1994-2012 Lua.org, PUC-Rio" " (" LUA_LNUM ")"
+ #define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo & W. Celes"
+
+
+@@ -71,6 +71,16 @@ typedef void * (*lua_Alloc) (void *ud, v
+ */
+ #define LUA_TNONE (-1)
+
++/* LUA_TINT is an internal type, not visible to applications. There are three
++ * potential values where it can be tweaked to (code autoadjusts to these):
++ *
++ * -2: not 'usual' type value; good since 'LUA_TINT' is not part of the API
++ * LUA_TNUMBER+1: shifts other type values upwards, breaking binary compatibility
++ * not acceptable for 5.1, maybe 5.2 onwards?
++ * 9: greater than existing (5.1) type values.
++*/
++#define LUA_TINT (-2)
++
+ #define LUA_TNIL 0
+ #define LUA_TBOOLEAN 1
+ #define LUA_TLIGHTUSERDATA 2
+@@ -139,6 +149,8 @@ LUA_API int (lua_isuserdata)
+ LUA_API int (lua_type) (lua_State *L, int idx);
+ LUA_API const char *(lua_typename) (lua_State *L, int tp);
+
++LUA_API int (lua_isinteger) (lua_State *L, int idx);
++
+ LUA_API int (lua_equal) (lua_State *L, int idx1, int idx2);
+ LUA_API int (lua_rawequal) (lua_State *L, int idx1, int idx2);
+ LUA_API int (lua_lessthan) (lua_State *L, int idx1, int idx2);
+@@ -244,6 +256,19 @@ LUA_API lua_Alloc (lua_getallocf) (lua_S
+ LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud);
+
+
++/*
++* It is unnecessary to break Lua C API 'lua_tonumber()' compatibility, just
++* because the Lua number type is complex. Most C modules would use scalars
++* only. We'll introduce new 'lua_tocomplex' and 'lua_pushcomplex' for when
++* the module really wants to use them.
++*/
++#ifdef LNUM_COMPLEX
++ #include <complex.h>
++ typedef LUA_NUMBER complex lua_Complex;
++ LUA_API lua_Complex (lua_tocomplex) (lua_State *L, int idx);
++ LUA_API void (lua_pushcomplex) (lua_State *L, lua_Complex v);
++#endif
++
+
+ /*
+ ** ===============================================================
+@@ -268,7 +293,12 @@ LUA_API void lua_setallocf (lua_State *L
+ #define lua_isboolean(L,n) (lua_type(L, (n)) == LUA_TBOOLEAN)
+ #define lua_isthread(L,n) (lua_type(L, (n)) == LUA_TTHREAD)
+ #define lua_isnone(L,n) (lua_type(L, (n)) == LUA_TNONE)
+-#define lua_isnoneornil(L, n) (lua_type(L, (n)) <= 0)
++
++#if LUA_TINT < 0
++# define lua_isnoneornil(L, n) ( (lua_type(L,(n)) <= 0) && (lua_type(L,(n)) != LUA_TINT) )
++#else
++# define lua_isnoneornil(L, n) (lua_type(L, (n)) <= 0)
++#endif
+
+ #define lua_pushliteral(L, s) \
+ lua_pushlstring(L, "" s, (sizeof(s)/sizeof(char))-1)
+@@ -386,3 +416,4 @@ struct lua_Debug {
+
+
+ #endif
++
+--- a/src/luaconf.h
++++ b/src/luaconf.h
+@@ -10,7 +10,9 @@
+
+ #include <limits.h>
+ #include <stddef.h>
+-
++#ifdef lua_assert
++# include <assert.h>
++#endif
+
+ /*
+ ** ==================================================================
+@@ -136,14 +138,38 @@
+
+
+ /*
+-@@ LUA_INTEGER is the integral type used by lua_pushinteger/lua_tointeger.
+-** CHANGE that if ptrdiff_t is not adequate on your machine. (On most
+-** machines, ptrdiff_t gives a good choice between int or long.)
++@@ LUAI_BITSINT defines the number of bits in an int.
++** CHANGE here if Lua cannot automatically detect the number of bits of
++** your machine. Probably you do not need to change this.
+ */
+-#define LUA_INTEGER ptrdiff_t
++/* avoid overflows in comparison */
++#if INT_MAX-20 < 32760
++#define LUAI_BITSINT 16
++#elif INT_MAX > 2147483640L
++/* int has at least 32 bits */
++#define LUAI_BITSINT 32
++#else
++#error "you must define LUA_BITSINT with number of bits in an integer"
++#endif
+
+
+ /*
++@@ LNUM_DOUBLE | LNUM_FLOAT | LNUM_LDOUBLE: Generic Lua number mode
++@@ LNUM_INT32 | LNUM_INT64: Integer type
++@@ LNUM_COMPLEX: Define for using 'a+bi' numbers
++@@
++@@ You can combine LNUM_xxx but only one of each group. I.e. '-DLNUM_FLOAT
++@@ -DLNUM_INT32 -DLNUM_COMPLEX' gives float range complex numbers, with
++@@ 32-bit scalar integer range optimized.
++**
++** These are kept in a separate configuration file mainly for ease of patching
++** (can be changed if integerated to Lua proper).
++*/
++/*#define LNUM_DOUBLE*/
++/*#define LNUM_INT32*/
++#include "lnum_config.h"
++
++/*
+ @@ LUA_API is a mark for all core API functions.
+ @@ LUALIB_API is a mark for all standard library functions.
+ ** CHANGE them if you need to define those functions in some special way.
+@@ -383,22 +409,6 @@
+
+
+ /*
+-@@ LUAI_BITSINT defines the number of bits in an int.
+-** CHANGE here if Lua cannot automatically detect the number of bits of
+-** your machine. Probably you do not need to change this.
+-*/
+-/* avoid overflows in comparison */
+-#if INT_MAX-20 < 32760
+-#define LUAI_BITSINT 16
+-#elif INT_MAX > 2147483640L
+-/* int has at least 32 bits */
+-#define LUAI_BITSINT 32
+-#else
+-#error "you must define LUA_BITSINT with number of bits in an integer"
+-#endif
+-
+-
+-/*
+ @@ LUAI_UINT32 is an unsigned integer with at least 32 bits.
+ @@ LUAI_INT32 is an signed integer with at least 32 bits.
+ @@ LUAI_UMEM is an unsigned integer big enough to count the total
+@@ -425,6 +435,15 @@
+ #define LUAI_MEM long
+ #endif
+
++/*
++@@ LUAI_BOOL carries 0 and nonzero (normally 1). It may be defined as 'char'
++** (to save memory), 'int' (for speed), 'bool' (for C++) or '_Bool' (C99)
++*/
++#ifdef __cplusplus
++# define LUAI_BOOL bool
++#else
++# define LUAI_BOOL int
++#endif
+
+ /*
+ @@ LUAI_MAXCALLS limits the number of nested calls.
+@@ -490,101 +509,6 @@
+ /* }================================================================== */
+
+
+-
+-
+-/*
+-** {==================================================================
+-@@ LUA_NUMBER is the type of numbers in Lua.
+-** CHANGE the following definitions only if you want to build Lua
+-** with a number type different from double. You may also need to
+-** change lua_number2int & lua_number2integer.
+-** ===================================================================
+-*/
+-
+-#define LUA_NUMBER_DOUBLE
+-#define LUA_NUMBER double
+-
+-/*
+-@@ LUAI_UACNUMBER is the result of an 'usual argument conversion'
+-@* over a number.
+-*/
+-#define LUAI_UACNUMBER double
+-
+-
+-/*
+-@@ LUA_NUMBER_SCAN is the format for reading numbers.
+-@@ LUA_NUMBER_FMT is the format for writing numbers.
+-@@ lua_number2str converts a number to a string.
+-@@ LUAI_MAXNUMBER2STR is maximum size of previous conversion.
+-@@ lua_str2number converts a string to a number.
+-*/
+-#define LUA_NUMBER_SCAN "%lf"
+-#define LUA_NUMBER_FMT "%.14g"
+-#define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n))
+-#define LUAI_MAXNUMBER2STR 32 /* 16 digits, sign, point, and \0 */
+-#define lua_str2number(s,p) strtod((s), (p))
+-
+-
+-/*
+-@@ The luai_num* macros define the primitive operations over numbers.
+-*/
+-#if defined(LUA_CORE)
+-#include <math.h>
+-#define luai_numadd(a,b) ((a)+(b))
+-#define luai_numsub(a,b) ((a)-(b))
+-#define luai_nummul(a,b) ((a)*(b))
+-#define luai_numdiv(a,b) ((a)/(b))
+-#define luai_nummod(a,b) ((a) - floor((a)/(b))*(b))
+-#define luai_numpow(a,b) (pow(a,b))
+-#define luai_numunm(a) (-(a))
+-#define luai_numeq(a,b) ((a)==(b))
+-#define luai_numlt(a,b) ((a)<(b))
+-#define luai_numle(a,b) ((a)<=(b))
+-#define luai_numisnan(a) (!luai_numeq((a), (a)))
+-#endif
+-
+-
+-/*
+-@@ lua_number2int is a macro to convert lua_Number to int.
+-@@ lua_number2integer is a macro to convert lua_Number to lua_Integer.
+-** CHANGE them if you know a faster way to convert a lua_Number to
+-** int (with any rounding method and without throwing errors) in your
+-** system. In Pentium machines, a naive typecast from double to int
+-** in C is extremely slow, so any alternative is worth trying.
+-*/
+-
+-/* On a Pentium, resort to a trick */
+-#if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) && !defined(__SSE2__) && \
+- (defined(__i386) || defined (_M_IX86) || defined(__i386__))
+-
+-/* On a Microsoft compiler, use assembler */
+-#if defined(_MSC_VER)
+-
+-#define lua_number2int(i,d) __asm fld d __asm fistp i
+-#define lua_number2integer(i,n) lua_number2int(i, n)
+-
+-/* the next trick should work on any Pentium, but sometimes clashes
+- with a DirectX idiosyncrasy */
+-#else
+-
+-union luai_Cast { double l_d; long l_l; };
+-#define lua_number2int(i,d) \
+- { volatile union luai_Cast u; u.l_d = (d) + 6755399441055744.0; (i) = u.l_l; }
+-#define lua_number2integer(i,n) lua_number2int(i, n)
+-
+-#endif
+-
+-
+-/* this option always works, but may be slow */
+-#else
+-#define lua_number2int(i,d) ((i)=(int)(d))
+-#define lua_number2integer(i,d) ((i)=(lua_Integer)(d))
+-
+-#endif
+-
+-/* }================================================================== */
+-
+-
+ /*
+ @@ LUAI_USER_ALIGNMENT_T is a type that requires maximum alignment.
+ ** CHANGE it if your system requires alignments larger than double. (For
+@@ -728,28 +652,6 @@ union luai_Cast { double l_d; long l_l;
+ #define luai_userstateyield(L,n) ((void)L)
+
+
+-/*
+-@@ LUA_INTFRMLEN is the length modifier for integer conversions
+-@* in 'string.format'.
+-@@ LUA_INTFRM_T is the integer type correspoding to the previous length
+-@* modifier.
+-** CHANGE them if your system supports long long or does not support long.
+-*/
+-
+-#if defined(LUA_USELONGLONG)
+-
+-#define LUA_INTFRMLEN "ll"
+-#define LUA_INTFRM_T long long
+-
+-#else
+-
+-#define LUA_INTFRMLEN "l"
+-#define LUA_INTFRM_T long
+-
+-#endif
+-
+-
+-
+ /* =================================================================== */
+
+ /*
+--- a/src/lundump.c
++++ b/src/lundump.c
+@@ -73,6 +73,13 @@ static lua_Number LoadNumber(LoadState*
+ return x;
+ }
+
++static lua_Integer LoadInteger(LoadState* S)
++{
++ lua_Integer x;
++ LoadVar(S,x);
++ return x;
++}
++
+ static TString* LoadString(LoadState* S)
+ {
+ size_t size;
+@@ -119,6 +126,9 @@ static void LoadConstants(LoadState* S,
+ case LUA_TNUMBER:
+ setnvalue(o,LoadNumber(S));
+ break;
++ case LUA_TINT: /* Integer type saved in bytecode (see lcode.c) */
++ setivalue(o,LoadInteger(S));
++ break;
+ case LUA_TSTRING:
+ setsvalue2n(S->L,o,LoadString(S));
+ break;
+@@ -223,5 +233,22 @@ void luaU_header (char* h)
+ *h++=(char)sizeof(size_t);
+ *h++=(char)sizeof(Instruction);
+ *h++=(char)sizeof(lua_Number);
+- *h++=(char)(((lua_Number)0.5)==0); /* is lua_Number integral? */
++
++ /*
++ * Last byte of header (0/1 in unpatched Lua 5.1.3):
++ *
++ * 0: lua_Number is float or double, lua_Integer not used. (nonpatched only)
++ * 1: lua_Number is integer (nonpatched only)
++ *
++ * +2: LNUM_INT16: sizeof(lua_Integer)
++ * +4: LNUM_INT32: sizeof(lua_Integer)
++ * +8: LNUM_INT64: sizeof(lua_Integer)
++ *
++ * +0x80: LNUM_COMPLEX
++ */
++ *h++ = (char)(sizeof(lua_Integer)
++#ifdef LNUM_COMPLEX
++ | 0x80
++#endif
++ );
+ }
+--- a/src/lvm.c
++++ b/src/lvm.c
+@@ -25,22 +25,35 @@
+ #include "ltable.h"
+ #include "ltm.h"
+ #include "lvm.h"
+-
+-
++#include "llex.h"
++#include "lnum.h"
+
+ /* limit for table tag-method chains (to avoid loops) */
+ #define MAXTAGLOOP 100
+
+
+-const TValue *luaV_tonumber (const TValue *obj, TValue *n) {
+- lua_Number num;
++/*
++ * If 'obj' is a string, it is tried to be interpreted as a number.
++ */
++const TValue *luaV_tonumber ( const TValue *obj, TValue *n) {
++ lua_Number d;
++ lua_Integer i;
++
+ if (ttisnumber(obj)) return obj;
+- if (ttisstring(obj) && luaO_str2d(svalue(obj), &num)) {
+- setnvalue(n, num);
+- return n;
+- }
+- else
+- return NULL;
++
++ if (ttisstring(obj)) {
++ switch( luaO_str2d( svalue(obj), &d, &i ) ) {
++ case TK_INT:
++ setivalue(n,i); return n;
++ case TK_NUMBER:
++ setnvalue(n,d); return n;
++#ifdef LNUM_COMPLEX
++ case TK_NUMBER2: /* "N.NNNi", != 0 */
++ setnvalue_complex_fast(n, d*I); return n;
++#endif
++ }
++ }
++ return NULL;
+ }
+
+
+@@ -49,8 +62,7 @@ int luaV_tostring (lua_State *L, StkId o
+ return 0;
+ else {
+ char s[LUAI_MAXNUMBER2STR];
+- lua_Number n = nvalue(obj);
+- lua_number2str(s, n);
++ luaO_num2buf(s,obj);
+ setsvalue2s(L, obj, luaS_new(L, s));
+ return 1;
+ }
+@@ -222,59 +234,127 @@ static int l_strcmp (const TString *ls,
+ }
+
+
++#ifdef LNUM_COMPLEX
++void error_complex( lua_State *L, const TValue *l, const TValue *r )
++{
++ char buf1[ LUAI_MAXNUMBER2STR ];
++ char buf2[ LUAI_MAXNUMBER2STR ];
++ luaO_num2buf( buf1, l );
++ luaO_num2buf( buf2, r );
++ luaG_runerror( L, "unable to compare: %s with %s", buf1, buf2 );
++ /* no return */
++}
++#endif
++
++
+ int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r) {
+ int res;
+- if (ttype(l) != ttype(r))
++ int tl,tr;
++ lua_Integer tmp;
++
++ if (!ttype_ext_same(l,r))
+ return luaG_ordererror(L, l, r);
+- else if (ttisnumber(l))
+- return luai_numlt(nvalue(l), nvalue(r));
+- else if (ttisstring(l))
+- return l_strcmp(rawtsvalue(l), rawtsvalue(r)) < 0;
+- else if ((res = call_orderTM(L, l, r, TM_LT)) != -1)
++#ifdef LNUM_COMPLEX
++ if ( (nvalue_img(l)!=0) || (nvalue_img(r)!=0) )
++ error_complex( L, l, r );
++#endif
++ tl= ttype(l); tr= ttype(r);
++ if (tl==tr) { /* clear arithmetics */
++ switch(tl) {
++ case LUA_TINT: return ivalue(l) < ivalue(r);
++ case LUA_TNUMBER: return luai_numlt(nvalue_fast(l), nvalue_fast(r));
++ case LUA_TSTRING: return l_strcmp(rawtsvalue(l), rawtsvalue(r)) < 0;
++ }
++ } else if (tl==LUA_TINT) { /* l:int, r:num */
++ /* Avoid accuracy losing casts: if 'r' is integer by value, do comparisons
++ * in integer realm. Only otherwise cast 'l' to FP (which might change its
++ * value).
++ */
++ if (tt_integer_valued(r,&tmp))
++ return ivalue(l) < tmp;
++ else
++ return luai_numlt( cast_num(ivalue(l)), nvalue_fast(r) );
++
++ } else if (tl==LUA_TNUMBER) { /* l:num, r:int */
++ if (tt_integer_valued(l,&tmp))
++ return tmp < ivalue(r);
++ else
++ return luai_numlt( nvalue_fast(l), cast_num(ivalue(r)) );
++
++ } else if ((res = call_orderTM(L, l, r, TM_LT)) != -1)
+ return res;
++
+ return luaG_ordererror(L, l, r);
+ }
+
+
+ static int lessequal (lua_State *L, const TValue *l, const TValue *r) {
+ int res;
+- if (ttype(l) != ttype(r))
++ int tl, tr;
++ lua_Integer tmp;
++
++ if (!ttype_ext_same(l,r))
+ return luaG_ordererror(L, l, r);
+- else if (ttisnumber(l))
+- return luai_numle(nvalue(l), nvalue(r));
+- else if (ttisstring(l))
+- return l_strcmp(rawtsvalue(l), rawtsvalue(r)) <= 0;
+- else if ((res = call_orderTM(L, l, r, TM_LE)) != -1) /* first try `le' */
++#ifdef LNUM_COMPLEX
++ if ( (nvalue_img(l)!=0) || (nvalue_img(r)!=0) )
++ error_complex( L, l, r );
++#endif
++ tl= ttype(l); tr= ttype(r);
++ if (tl==tr) { /* clear arithmetics */
++ switch(tl) {
++ case LUA_TINT: return ivalue(l) <= ivalue(r);
++ case LUA_TNUMBER: return luai_numle(nvalue_fast(l), nvalue_fast(r));
++ case LUA_TSTRING: return l_strcmp(rawtsvalue(l), rawtsvalue(r)) <= 0;
++ }
++ }
++ if (tl==LUA_TINT) { /* l:int, r:num */
++ if (tt_integer_valued(r,&tmp))
++ return ivalue(l) <= tmp;
++ else
++ return luai_numle( cast_num(ivalue(l)), nvalue_fast(r) );
++
++ } else if (tl==LUA_TNUMBER) { /* l:num, r:int */
++ if (tt_integer_valued(l,&tmp))
++ return tmp <= ivalue(r);
++ else
++ return luai_numle( nvalue_fast(l), cast_num(ivalue(r)) );
++
++ } else if ((res = call_orderTM(L, l, r, TM_LE)) != -1) /* first try `le' */
+ return res;
+ else if ((res = call_orderTM(L, r, l, TM_LT)) != -1) /* else try `lt' */
+ return !res;
++
+ return luaG_ordererror(L, l, r);
+ }
+
+
+-int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2) {
++/* Note: 'luaV_equalval()' and 'luaO_rawequalObj()' have largely overlapping
++ * implementation. LUA_TNIL..LUA_TLIGHTUSERDATA cases could be handled
++ * simply by the 'default' case here.
++ */
++int luaV_equalval (lua_State *L, const TValue *l, const TValue *r) {
+ const TValue *tm;
+- lua_assert(ttype(t1) == ttype(t2));
+- switch (ttype(t1)) {
++ lua_assert(ttype_ext_same(l,r));
++ switch (ttype(l)) {
+ case LUA_TNIL: return 1;
+- case LUA_TNUMBER: return luai_numeq(nvalue(t1), nvalue(t2));
+- case LUA_TBOOLEAN: return bvalue(t1) == bvalue(t2); /* true must be 1 !! */
+- case LUA_TLIGHTUSERDATA: return pvalue(t1) == pvalue(t2);
++ case LUA_TINT:
++ case LUA_TNUMBER: return luaO_rawequalObj(l,r);
++ case LUA_TBOOLEAN: return bvalue(l) == bvalue(r); /* true must be 1 !! */
++ case LUA_TLIGHTUSERDATA: return pvalue(l) == pvalue(r);
+ case LUA_TUSERDATA: {
+- if (uvalue(t1) == uvalue(t2)) return 1;
+- tm = get_compTM(L, uvalue(t1)->metatable, uvalue(t2)->metatable,
+- TM_EQ);
++ if (uvalue(l) == uvalue(r)) return 1;
++ tm = get_compTM(L, uvalue(l)->metatable, uvalue(r)->metatable, TM_EQ);
+ break; /* will try TM */
+ }
+ case LUA_TTABLE: {
+- if (hvalue(t1) == hvalue(t2)) return 1;
+- tm = get_compTM(L, hvalue(t1)->metatable, hvalue(t2)->metatable, TM_EQ);
++ if (hvalue(l) == hvalue(r)) return 1;
++ tm = get_compTM(L, hvalue(l)->metatable, hvalue(r)->metatable, TM_EQ);
+ break; /* will try TM */
+ }
+- default: return gcvalue(t1) == gcvalue(t2);
++ default: return gcvalue(l) == gcvalue(r);
+ }
+ if (tm == NULL) return 0; /* no TM? */
+- callTMres(L, L->top, tm, t1, t2); /* call TM */
++ callTMres(L, L->top, tm, l, r); /* call TM */
+ return !l_isfalse(L->top);
+ }
+
+@@ -314,30 +394,6 @@ void luaV_concat (lua_State *L, int tota
+ }
+
+
+-static void Arith (lua_State *L, StkId ra, const TValue *rb,
+- const TValue *rc, TMS op) {
+- TValue tempb, tempc;
+- const TValue *b, *c;
+- if ((b = luaV_tonumber(rb, &tempb)) != NULL &&
+- (c = luaV_tonumber(rc, &tempc)) != NULL) {
+- lua_Number nb = nvalue(b), nc = nvalue(c);
+- switch (op) {
+- case TM_ADD: setnvalue(ra, luai_numadd(nb, nc)); break;
+- case TM_SUB: setnvalue(ra, luai_numsub(nb, nc)); break;
+- case TM_MUL: setnvalue(ra, luai_nummul(nb, nc)); break;
+- case TM_DIV: setnvalue(ra, luai_numdiv(nb, nc)); break;
+- case TM_MOD: setnvalue(ra, luai_nummod(nb, nc)); break;
+- case TM_POW: setnvalue(ra, luai_numpow(nb, nc)); break;
+- case TM_UNM: setnvalue(ra, luai_numunm(nb)); break;
+- default: lua_assert(0); break;
+- }
+- }
+- else if (!call_binTM(L, rb, rc, ra, op))
+- luaG_aritherror(L, rb, rc);
+-}
+-
+-
+-
+ /*
+ ** some macros for common tasks in `luaV_execute'
+ */
+@@ -361,17 +417,154 @@ static void Arith (lua_State *L, StkId r
+ #define Protect(x) { L->savedpc = pc; {x;}; base = L->base; }
+
+
+-#define arith_op(op,tm) { \
+- TValue *rb = RKB(i); \
+- TValue *rc = RKC(i); \
+- if (ttisnumber(rb) && ttisnumber(rc)) { \
+- lua_Number nb = nvalue(rb), nc = nvalue(rc); \
+- setnvalue(ra, op(nb, nc)); \
+- } \
+- else \
+- Protect(Arith(L, ra, rb, rc, tm)); \
++/* Note: if called for unary operations, 'rc'=='rb'.
++ */
++static void Arith (lua_State *L, StkId ra, const TValue *rb,
++ const TValue *rc, TMS op) {
++ TValue tempb, tempc;
++ const TValue *b, *c;
++ lua_Number nb,nc;
++
++ if ((b = luaV_tonumber(rb, &tempb)) != NULL &&
++ (c = luaV_tonumber(rc, &tempc)) != NULL) {
++
++ /* Keep integer arithmetics in the integer realm, if possible.
++ */
++ if (ttisint(b) && ttisint(c)) {
++ lua_Integer ib = ivalue(b), ic = ivalue(c);
++ lua_Integer *ri = &ra->value.i;
++ ra->tt= LUA_TINT; /* part of 'setivalue(ra)' */
++ switch (op) {
++ case TM_ADD: if (try_addint( ri, ib, ic)) return; break;
++ case TM_SUB: if (try_subint( ri, ib, ic)) return; break;
++ case TM_MUL: if (try_mulint( ri, ib, ic)) return; break;
++ case TM_DIV: if (try_divint( ri, ib, ic)) return; break;
++ case TM_MOD: if (try_modint( ri, ib, ic)) return; break;
++ case TM_POW: if (try_powint( ri, ib, ic)) return; break;
++ case TM_UNM: if (try_unmint( ri, ib)) return; break;
++ default: lua_assert(0);
++ }
++ }
++ /* Fallback to floating point, when leaving range. */
++
++#ifdef LNUM_COMPLEX
++ if ((nvalue_img(b)!=0) || (nvalue_img(c)!=0)) {
++ lua_Complex r;
++ if (op==TM_UNM) {
++ r= -nvalue_complex_fast(b); /* never an integer (or scalar) */
++ setnvalue_complex_fast( ra, r );
++ } else {
++ lua_Complex bb= nvalue_complex(b), cc= nvalue_complex(c);
++ switch (op) {
++ case TM_ADD: r= bb + cc; break;
++ case TM_SUB: r= bb - cc; break;
++ case TM_MUL: r= bb * cc; break;
++ case TM_DIV: r= bb / cc; break;
++ case TM_MOD:
++ luaG_runerror(L, "attempt to use %% on complex numbers"); /* no return */
++ case TM_POW: r= luai_vectpow( bb, cc ); break;
++ default: lua_assert(0); r=0;
++ }
++ setnvalue_complex( ra, r );
+ }
++ return;
++ }
++#endif
++ nb = nvalue(b); nc = nvalue(c);
++ switch (op) {
++ case TM_ADD: setnvalue(ra, luai_numadd(nb, nc)); return;
++ case TM_SUB: setnvalue(ra, luai_numsub(nb, nc)); return;
++ case TM_MUL: setnvalue(ra, luai_nummul(nb, nc)); return;
++ case TM_DIV: setnvalue(ra, luai_numdiv(nb, nc)); return;
++ case TM_MOD: setnvalue(ra, luai_nummod(nb, nc)); return;
++ case TM_POW: setnvalue(ra, luai_numpow(nb, nc)); return;
++ case TM_UNM: setnvalue(ra, luai_numunm(nb)); return;
++ default: lua_assert(0);
++ }
++ }
++
++ /* Either operand not a number */
++ if (!call_binTM(L, rb, rc, ra, op))
++ luaG_aritherror(L, rb, rc);
++}
+
++/* Helper macro to sort arithmetic operations into four categories:
++ * TK_INT: integer - integer operands
++ * TK_NUMBER: number - number (non complex, either may be integer)
++ * TK_NUMBER2: complex numbers (at least the other)
++ * 0: non-numeric (at least the other)
++*/
++#ifdef LNUM_COMPLEX
++static inline int arith_mode( const TValue *rb, const TValue *rc ) {
++ if (ttisint(rb) && ttisint(rc)) return TK_INT;
++ if (ttiscomplex(rb) || ttiscomplex(rc)) return TK_NUMBER2;
++ if (ttisnumber(rb) && ttisnumber(rc)) return TK_NUMBER;
++ return 0;
++}
++#else
++# define arith_mode(rb,rc) \
++ ( (ttisint(rb) && ttisint(rc)) ? TK_INT : \
++ (ttisnumber(rb) && ttisnumber(rc)) ? TK_NUMBER : 0 )
++#endif
++
++/* arith_op macro for two operators:
++ * automatically chooses, which function (number, integer, complex) to use
++ */
++#define ARITH_OP2_START( op_num, op_int ) \
++ int failed= 0; \
++ switch( arith_mode(rb,rc) ) { \
++ case TK_INT: \
++ if (op_int ( &(ra)->value.i, ivalue(rb), ivalue(rc) )) \
++ { ra->tt= LUA_TINT; break; } /* else flow through */ \
++ case TK_NUMBER: \
++ setnvalue(ra, op_num ( nvalue(rb), nvalue(rc) )); break;
++
++#define ARITH_OP2_END \
++ default: \
++ failed= 1; break; \
++ } if (!failed) continue;
++
++#define arith_op_continue_scalar( op_num, op_int ) \
++ ARITH_OP2_START( op_num, op_int ) \
++ ARITH_OP2_END
++
++#ifdef LNUM_COMPLEX
++# define arith_op_continue( op_num, op_int, op_complex ) \
++ ARITH_OP2_START( op_num, op_int ) \
++ case TK_NUMBER2: \
++ setnvalue_complex( ra, op_complex ( nvalue_complex(rb), nvalue_complex(rc) ) ); break; \
++ ARITH_OP2_END
++#else
++# define arith_op_continue(op_num,op_int,_) arith_op_continue_scalar(op_num,op_int)
++#endif
++
++/* arith_op macro for one operator:
++ */
++#define ARITH_OP1_START( op_num, op_int ) \
++ int failed= 0; \
++ switch( arith_mode(rb,rb) ) { \
++ case TK_INT: \
++ if (op_int ( &(ra)->value.i, ivalue(rb) )) \
++ { ra->tt= LUA_TINT; break; } /* else flow through */ \
++ case TK_NUMBER: \
++ setnvalue(ra, op_num (nvalue(rb))); break; \
++
++#define ARITH_OP1_END \
++ default: \
++ failed= 1; break; \
++ } if (!failed) continue;
++
++#ifdef LNUM_COMPLEX
++# define arith_op1_continue( op_num, op_int, op_complex ) \
++ ARITH_OP1_START( op_num, op_int ) \
++ case TK_NUMBER2: \
++ setnvalue_complex( ra, op_complex ( nvalue_complex_fast(rb) )); break; \
++ ARITH_OP1_END
++#else
++# define arith_op1_continue( op_num, op_int, _ ) \
++ ARITH_OP1_START( op_num, op_int ) \
++ ARITH_OP1_END
++#endif
+
+
+ void luaV_execute (lua_State *L, int nexeccalls) {
+@@ -472,38 +665,45 @@ void luaV_execute (lua_State *L, int nex
+ continue;
+ }
+ case OP_ADD: {
+- arith_op(luai_numadd, TM_ADD);
++ TValue *rb = RKB(i), *rc= RKC(i);
++ arith_op_continue( luai_numadd, try_addint, luai_vectadd );
++ Protect(Arith(L, ra, rb, rc, TM_ADD)); \
+ continue;
+ }
+ case OP_SUB: {
+- arith_op(luai_numsub, TM_SUB);
++ TValue *rb = RKB(i), *rc= RKC(i);
++ arith_op_continue( luai_numsub, try_subint, luai_vectsub );
++ Protect(Arith(L, ra, rb, rc, TM_SUB));
+ continue;
+ }
+ case OP_MUL: {
+- arith_op(luai_nummul, TM_MUL);
++ TValue *rb = RKB(i), *rc= RKC(i);
++ arith_op_continue(luai_nummul, try_mulint, luai_vectmul);
++ Protect(Arith(L, ra, rb, rc, TM_MUL));
+ continue;
+ }
+ case OP_DIV: {
+- arith_op(luai_numdiv, TM_DIV);
++ TValue *rb = RKB(i), *rc= RKC(i);
++ arith_op_continue(luai_numdiv, try_divint, luai_vectdiv);
++ Protect(Arith(L, ra, rb, rc, TM_DIV));
+ continue;
+ }
+ case OP_MOD: {
+- arith_op(luai_nummod, TM_MOD);
++ TValue *rb = RKB(i), *rc= RKC(i);
++ arith_op_continue_scalar(luai_nummod, try_modint); /* scalars only */
++ Protect(Arith(L, ra, rb, rc, TM_MOD));
+ continue;
+ }
+ case OP_POW: {
+- arith_op(luai_numpow, TM_POW);
++ TValue *rb = RKB(i), *rc= RKC(i);
++ arith_op_continue(luai_numpow, try_powint, luai_vectpow);
++ Protect(Arith(L, ra, rb, rc, TM_POW));
+ continue;
+ }
+ case OP_UNM: {
+ TValue *rb = RB(i);
+- if (ttisnumber(rb)) {
+- lua_Number nb = nvalue(rb);
+- setnvalue(ra, luai_numunm(nb));
+- }
+- else {
+- Protect(Arith(L, ra, rb, rb, TM_UNM));
+- }
++ arith_op1_continue(luai_numunm, try_unmint, luai_vectunm);
++ Protect(Arith(L, ra, rb, rb, TM_UNM));
+ continue;
+ }
+ case OP_NOT: {
+@@ -515,11 +715,11 @@ void luaV_execute (lua_State *L, int nex
+ const TValue *rb = RB(i);
+ switch (ttype(rb)) {
+ case LUA_TTABLE: {
+- setnvalue(ra, cast_num(luaH_getn(hvalue(rb))));
++ setivalue(ra, luaH_getn(hvalue(rb)));
+ break;
+ }
+ case LUA_TSTRING: {
+- setnvalue(ra, cast_num(tsvalue(rb)->len));
++ setivalue(ra, tsvalue(rb)->len);
+ break;
+ }
+ default: { /* try metamethod */
+@@ -652,14 +852,30 @@ void luaV_execute (lua_State *L, int nex
+ }
+ }
+ case OP_FORLOOP: {
+- lua_Number step = nvalue(ra+2);
+- lua_Number idx = luai_numadd(nvalue(ra), step); /* increment index */
+- lua_Number limit = nvalue(ra+1);
+- if (luai_numlt(0, step) ? luai_numle(idx, limit)
+- : luai_numle(limit, idx)) {
+- dojump(L, pc, GETARG_sBx(i)); /* jump back */
+- setnvalue(ra, idx); /* update internal index... */
+- setnvalue(ra+3, idx); /* ...and external index */
++ /* If start,step and limit are all integers, we don't need to check
++ * against overflow in the looping.
++ */
++ if (ttisint(ra) && ttisint(ra+1) && ttisint(ra+2)) {
++ lua_Integer step = ivalue(ra+2);
++ lua_Integer idx = ivalue(ra) + step; /* increment index */
++ lua_Integer limit = ivalue(ra+1);
++ if (step > 0 ? (idx <= limit) : (limit <= idx)) {
++ dojump(L, pc, GETARG_sBx(i)); /* jump back */
++ setivalue(ra, idx); /* update internal index... */
++ setivalue(ra+3, idx); /* ...and external index */
++ }
++ } else {
++ /* non-integer looping (don't use 'nvalue_fast', some may be integer!)
++ */
++ lua_Number step = nvalue(ra+2);
++ lua_Number idx = luai_numadd(nvalue(ra), step); /* increment index */
++ lua_Number limit = nvalue(ra+1);
++ if (luai_numlt(0, step) ? luai_numle(idx, limit)
++ : luai_numle(limit, idx)) {
++ dojump(L, pc, GETARG_sBx(i)); /* jump back */
++ setnvalue(ra, idx); /* update internal index... */
++ setnvalue(ra+3, idx); /* ...and external index */
++ }
+ }
+ continue;
+ }
+@@ -668,13 +884,21 @@ void luaV_execute (lua_State *L, int nex
+ const TValue *plimit = ra+1;
+ const TValue *pstep = ra+2;
+ L->savedpc = pc; /* next steps may throw errors */
++ /* Using same location for tonumber's both arguments, effectively does
++ * in-place modification (string->number). */
+ if (!tonumber(init, ra))
+ luaG_runerror(L, LUA_QL("for") " initial value must be a number");
+ else if (!tonumber(plimit, ra+1))
+ luaG_runerror(L, LUA_QL("for") " limit must be a number");
+ else if (!tonumber(pstep, ra+2))
+ luaG_runerror(L, LUA_QL("for") " step must be a number");
+- setnvalue(ra, luai_numsub(nvalue(ra), nvalue(pstep)));
++ /* Step back one value (keep within integers if we can)
++ */
++ if (!( ttisint(ra) && ttisint(pstep) &&
++ try_subint( &ra->value.i, ivalue(ra), ivalue(pstep) ) )) {
++ /* don't use 'nvalue_fast()', values may be integer */
++ setnvalue(ra, luai_numsub(nvalue(ra), nvalue(pstep)));
++ }
+ dojump(L, pc, GETARG_sBx(i));
+ continue;
+ }
+@@ -711,7 +935,7 @@ void luaV_execute (lua_State *L, int nex
+ luaH_resizearray(L, h, last); /* pre-alloc it at once */
+ for (; n > 0; n--) {
+ TValue *val = ra+n;
+- setobj2t(L, luaH_setnum(L, h, last--), val);
++ setobj2t(L, luaH_setint(L, h, last--), val);
+ luaC_barriert(L, h, val);
+ }
+ continue;
+--- a/src/lvm.h
++++ b/src/lvm.h
+@@ -15,11 +15,9 @@
+
+ #define tostring(L,o) ((ttype(o) == LUA_TSTRING) || (luaV_tostring(L, o)))
+
+-#define tonumber(o,n) (ttype(o) == LUA_TNUMBER || \
+- (((o) = luaV_tonumber(o,n)) != NULL))
++#define tonumber(o,n) (ttisnumber(o) || (((o) = luaV_tonumber(o,n)) != NULL))
+
+-#define equalobj(L,o1,o2) \
+- (ttype(o1) == ttype(o2) && luaV_equalval(L, o1, o2))
++#define equalobj(L,o1,o2) (ttype_ext_same(o1,o2) && luaV_equalval(L, o1, o2))
+
+
+ LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r);
+--- a/src/print.c
++++ b/src/print.c
+@@ -14,6 +14,7 @@
+ #include "lobject.h"
+ #include "lopcodes.h"
+ #include "lundump.h"
++#include "lnum.h"
+
+ #define PrintFunction luaU_print
+
+@@ -59,8 +60,16 @@ static void PrintConstant(const Proto* f
+ case LUA_TBOOLEAN:
+ printf(bvalue(o) ? "true" : "false");
+ break;
++ case LUA_TINT:
++ printf(LUA_INTEGER_FMT,ivalue(o));
++ break;
+ case LUA_TNUMBER:
+- printf(LUA_NUMBER_FMT,nvalue(o));
++#ifdef LNUM_COMPLEX
++ // TBD: Do we get complex values here?
++ { lua_Number b= nvalue_img_fast(o);
++ printf( LUA_NUMBER_FMT "%s" LUA_NUMBER_FMT "i", nvalue_fast(o), b>=0 ? "+":"", b ); }
++#endif
++ printf(LUA_NUMBER_FMT,nvalue_fast(o));
+ break;
+ case LUA_TSTRING:
+ PrintString(rawtsvalue(o));
diff --git a/package/lua/patches/011-lnum-use-double.patch b/package/lua/patches/011-lnum-use-double.patch
new file mode 100644
index 0000000..14c720b
--- /dev/null
+++ b/package/lua/patches/011-lnum-use-double.patch
@@ -0,0 +1,11 @@
+--- a/src/lnum_config.h
++++ b/src/lnum_config.h
+@@ -11,7 +11,7 @@
+ ** Default number modes
+ */
+ #if (!defined LNUM_DOUBLE) && (!defined LNUM_FLOAT) && (!defined LNUM_LDOUBLE)
+-# define LNUM_FLOAT
++# define LNUM_DOUBLE
+ #endif
+ #if (!defined LNUM_INT16) && (!defined LNUM_INT32) && (!defined LNUM_INT64)
+ # define LNUM_INT32
diff --git a/package/lua/patches/015-lnum-ppc-compat.patch b/package/lua/patches/015-lnum-ppc-compat.patch
new file mode 100644
index 0000000..2ea59f1
--- /dev/null
+++ b/package/lua/patches/015-lnum-ppc-compat.patch
@@ -0,0 +1,11 @@
+--- a/src/lua.h
++++ b/src/lua.h
+@@ -79,7 +79,7 @@ typedef void * (*lua_Alloc) (void *ud, v
+ * not acceptable for 5.1, maybe 5.2 onwards?
+ * 9: greater than existing (5.1) type values.
+ */
+-#define LUA_TINT (-2)
++#define LUA_TINT 9
+
+ #define LUA_TNIL 0
+ #define LUA_TBOOLEAN 1
diff --git a/package/lua/patches/020-shared_liblua.patch b/package/lua/patches/020-shared_liblua.patch
new file mode 100644
index 0000000..bcd410f
--- /dev/null
+++ b/package/lua/patches/020-shared_liblua.patch
@@ -0,0 +1,140 @@
+--- a/Makefile
++++ b/Makefile
+@@ -42,8 +42,8 @@ PLATS= aix ansi bsd freebsd generic linu
+
+ # What to install.
+ TO_BIN= lua luac
+-TO_INC= lua.h luaconf.h lualib.h lauxlib.h ../etc/lua.hpp
+-TO_LIB= liblua.a
++TO_INC= lua.h luaconf.h lualib.h lauxlib.h ../etc/lua.hpp lnum_config.h
++TO_LIB= liblua.a liblua.so.$R
+ TO_MAN= lua.1 luac.1
+
+ # Lua version and release.
+@@ -63,6 +63,7 @@ install: dummy
+ cd src && $(INSTALL_EXEC) $(TO_BIN) $(INSTALL_BIN)
+ cd src && $(INSTALL_DATA) $(TO_INC) $(INSTALL_INC)
+ cd src && $(INSTALL_DATA) $(TO_LIB) $(INSTALL_LIB)
++ ln -s liblua.so.$R $(INSTALL_LIB)/liblua.so
+ cd doc && $(INSTALL_DATA) $(TO_MAN) $(INSTALL_MAN)
+
+ ranlib:
+--- a/src/ldo.h
++++ b/src/ldo.h
+@@ -46,7 +46,7 @@ LUAI_FUNC int luaD_pcall (lua_State *L,
+ LUAI_FUNC int luaD_poscall (lua_State *L, StkId firstResult);
+ LUAI_FUNC void luaD_reallocCI (lua_State *L, int newsize);
+ LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize);
+-LUAI_FUNC void luaD_growstack (lua_State *L, int n);
++LUA_API void luaD_growstack (lua_State *L, int n);
+
+ LUAI_FUNC void luaD_throw (lua_State *L, int errcode);
+ LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud);
+--- a/src/lfunc.h
++++ b/src/lfunc.h
+@@ -18,7 +18,7 @@
+ cast(int, sizeof(TValue *)*((n)-1)))
+
+
+-LUAI_FUNC Proto *luaF_newproto (lua_State *L);
++LUA_API Proto *luaF_newproto (lua_State *L);
+ LUAI_FUNC Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e);
+ LUAI_FUNC Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e);
+ LUAI_FUNC UpVal *luaF_newupval (lua_State *L);
+--- a/src/lmem.h
++++ b/src/lmem.h
+@@ -38,9 +38,9 @@
+ ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t))))
+
+
+-LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize,
++LUA_API void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize,
+ size_t size);
+-LUAI_FUNC void *luaM_toobig (lua_State *L);
++LUA_API void *luaM_toobig (lua_State *L);
+ LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size,
+ size_t size_elem, int limit,
+ const char *errormsg);
+--- a/src/lstring.h
++++ b/src/lstring.h
+@@ -25,7 +25,7 @@
+
+ LUAI_FUNC void luaS_resize (lua_State *L, int newsize);
+ LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, Table *e);
+-LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l);
++LUA_API TString *luaS_newlstr (lua_State *L, const char *str, size_t l);
+
+
+ #endif
+--- a/src/lundump.h
++++ b/src/lundump.h
+@@ -17,7 +17,7 @@ LUAI_FUNC Proto* luaU_undump (lua_State*
+ LUAI_FUNC void luaU_header (char* h);
+
+ /* dump one chunk; from ldump.c */
+-LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip);
++LUA_API int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip);
+
+ #ifdef luac_c
+ /* print one chunk; from print.c */
+--- a/src/Makefile
++++ b/src/Makefile
+@@ -23,6 +23,7 @@ MYLIBS=
+ PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris
+
+ LUA_A= liblua.a
++LUA_SO= liblua.so
+ CORE_O= lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o \
+ lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o \
+ lundump.o lvm.o lzio.o lnum.o
+@@ -33,11 +34,12 @@ LUA_T= lua
+ LUA_O= lua.o
+
+ LUAC_T= luac
+-LUAC_O= luac.o print.o
++LUAC_O= luac.o print.o lopcodes.o
+
+ ALL_O= $(CORE_O) $(LIB_O) $(LUA_O) $(LUAC_O)
+-ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T)
++ALL_T= $(LUA_A) $(LUA_SO) $(LUA_T) $(LUAC_T)
+ ALL_A= $(LUA_A)
++ALL_SO= $(LUA_SO)
+
+ default: $(PLAT)
+
+@@ -47,14 +49,23 @@ o: $(ALL_O)
+
+ a: $(ALL_A)
+
++so: $(ALL_SO)
++
+ $(LUA_A): $(CORE_O) $(LIB_O)
+ $(AR) $@ $(CORE_O) $(LIB_O) # DLL needs all object files
+ $(RANLIB) $@
+
+-$(LUA_T): $(LUA_O) $(LUA_A)
+- $(CC) -o $@ $(MYLDFLAGS) $(LUA_O) $(LUA_A) $(LIBS)
++$(LUA_SO): $(CORE_O) $(LIB_O)
++ $(CC) -o $@.$(PKG_VERSION) -shared -Wl,-soname="$@.$(PKG_VERSION)" $?
++ ln -fs $@.$(PKG_VERSION) $@
++
++$(LUA_T): $(LUA_O) $(LUA_SO)
++ $(CC) -o $@ -L. -llua $(MYLDFLAGS) $(LUA_O) $(LIBS)
++
++$(LUAC_T): $(LUAC_O) $(LUA_SO)
++ $(CC) -o $@ -L. -llua $(MYLDFLAGS) $(LUAC_O) $(LIBS)
+
+-$(LUAC_T): $(LUAC_O) $(LUA_A)
++$(LUAC_T)-host: $(LUAC_O) $(LUA_A)
+ $(CC) -o $@ $(MYLDFLAGS) $(LUAC_O) $(LUA_A) $(LIBS)
+
+ clean:
+@@ -96,7 +107,7 @@ generic:
+ $(MAKE) all MYCFLAGS=
+
+ linux:
+- $(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-Wl,-E -ldl -lreadline -lhistory -lncurses"
++ $(MAKE) all MYCFLAGS+=-DLUA_USE_LINUX MYLIBS="-Wl,-E -ldl -lreadline -lhistory -lncurses"
+
+ macosx:
+ $(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-lreadline"
diff --git a/package/lua/patches/030-archindependent-bytecode.patch b/package/lua/patches/030-archindependent-bytecode.patch
new file mode 100644
index 0000000..8dfef85
--- /dev/null
+++ b/package/lua/patches/030-archindependent-bytecode.patch
@@ -0,0 +1,111 @@
+--- a/src/ldump.c
++++ b/src/ldump.c
+@@ -67,12 +67,12 @@ static void DumpString(const TString* s,
+ {
+ if (s==NULL || getstr(s)==NULL)
+ {
+- size_t size=0;
++ unsigned int size=0;
+ DumpVar(size,D);
+ }
+ else
+ {
+- size_t size=s->tsv.len+1; /* include trailing '\0' */
++ unsigned int size=s->tsv.len+1; /* include trailing '\0' */
+ DumpVar(size,D);
+ DumpBlock(getstr(s),size,D);
+ }
+--- a/src/lundump.c
++++ b/src/lundump.c
+@@ -25,6 +25,7 @@ typedef struct {
+ ZIO* Z;
+ Mbuffer* b;
+ const char* name;
++ int swap;
+ } LoadState;
+
+ #ifdef LUAC_TRUST_BINARIES
+@@ -40,7 +41,6 @@ static void error(LoadState* S, const ch
+ }
+ #endif
+
+-#define LoadMem(S,b,n,size) LoadBlock(S,b,(n)*(size))
+ #define LoadByte(S) (lu_byte)LoadChar(S)
+ #define LoadVar(S,x) LoadMem(S,&x,1,sizeof(x))
+ #define LoadVector(S,b,n,size) LoadMem(S,b,n,size)
+@@ -51,6 +51,49 @@ static void LoadBlock(LoadState* S, void
+ IF (r!=0, "unexpected end");
+ }
+
++static void LoadMem (LoadState* S, void* b, int n, size_t size)
++{
++ LoadBlock(S,b,n*size);
++ if (S->swap)
++ {
++ char* p=(char*) b;
++ char c;
++ switch (size)
++ {
++ case 1:
++ break;
++ case 2:
++ while (n--)
++ {
++ c=p[0]; p[0]=p[1]; p[1]=c;
++ p+=2;
++ }
++ break;
++ case 4:
++ while (n--)
++ {
++ c=p[0]; p[0]=p[3]; p[3]=c;
++ c=p[1]; p[1]=p[2]; p[2]=c;
++ p+=4;
++ }
++ break;
++ case 8:
++ while (n--)
++ {
++ c=p[0]; p[0]=p[7]; p[7]=c;
++ c=p[1]; p[1]=p[6]; p[6]=c;
++ c=p[2]; p[2]=p[5]; p[5]=c;
++ c=p[3]; p[3]=p[4]; p[4]=c;
++ p+=8;
++ }
++ break;
++ default:
++ IF(1, "bad size");
++ break;
++ }
++ }
++}
++
+ static int LoadChar(LoadState* S)
+ {
+ char x;
+@@ -82,7 +125,7 @@ static lua_Integer LoadInteger(LoadState
+
+ static TString* LoadString(LoadState* S)
+ {
+- size_t size;
++ unsigned int size;
+ LoadVar(S,size);
+ if (size==0)
+ return NULL;
+@@ -196,6 +239,7 @@ static void LoadHeader(LoadState* S)
+ char s[LUAC_HEADERSIZE];
+ luaU_header(h);
+ LoadBlock(S,s,LUAC_HEADERSIZE);
++ S->swap=(s[6]!=h[6]); s[6]=h[6];
+ IF (memcmp(h,s,LUAC_HEADERSIZE)!=0, "bad header");
+ }
+
+@@ -230,7 +274,7 @@ void luaU_header (char* h)
+ *h++=(char)LUAC_FORMAT;
+ *h++=(char)*(char*)&x; /* endianness */
+ *h++=(char)sizeof(int);
+- *h++=(char)sizeof(size_t);
++ *h++=(char)sizeof(unsigned int);
+ *h++=(char)sizeof(Instruction);
+ *h++=(char)sizeof(lua_Number);
+
diff --git a/package/lua/patches/100-no_readline.patch b/package/lua/patches/100-no_readline.patch
new file mode 100644
index 0000000..0350e47
--- /dev/null
+++ b/package/lua/patches/100-no_readline.patch
@@ -0,0 +1,49 @@
+--- a/src/luaconf.h
++++ b/src/luaconf.h
+@@ -38,7 +38,6 @@
+ #if defined(LUA_USE_LINUX)
+ #define LUA_USE_POSIX
+ #define LUA_USE_DLOPEN /* needs an extra library: -ldl */
+-#define LUA_USE_READLINE /* needs some extra libraries */
+ #endif
+
+ #if defined(LUA_USE_MACOSX)
+--- a/src/Makefile
++++ b/src/Makefile
+@@ -17,6 +17,7 @@ LIBS= -lm $(MYLIBS)
+ MYCFLAGS=
+ MYLDFLAGS=
+ MYLIBS=
++# USE_READLINE=1
+
+ # == END OF USER SETTINGS. NO NEED TO CHANGE ANYTHING BELOW THIS LINE =========
+
+@@ -86,7 +87,7 @@ echo:
+ @echo "MYLIBS = $(MYLIBS)"
+
+ # convenience targets for popular platforms
+-
++RFLAG=$(if $(USE_READLINE),-DLUA_USE_READLINE)
+ none:
+ @echo "Please choose a platform:"
+ @echo " $(PLATS)"
+@@ -101,16 +102,16 @@ bsd:
+ $(MAKE) all MYCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-Wl,-E"
+
+ freebsd:
+- $(MAKE) all MYCFLAGS="-DLUA_USE_LINUX" MYLIBS="-Wl,-E -lreadline"
++ $(MAKE) all MYCFLAGS="-DLUA_USE_LINUX $(RFLAG)" MYLIBS="-Wl,-E$(if $(USE_READLINE), -lreadline)"
+
+ generic:
+ $(MAKE) all MYCFLAGS=
+
+ linux:
+- $(MAKE) all MYCFLAGS+=-DLUA_USE_LINUX MYLIBS="-Wl,-E -ldl -lreadline -lhistory -lncurses"
++ $(MAKE) all MYCFLAGS+="-DLUA_USE_LINUX $(RFLAG)" MYLIBS="-Wl,-E -ldl $(if $(USE_READLINE), -lreadline -lhistory -lncurses)"
+
+ macosx:
+- $(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-lreadline"
++ $(MAKE) all MYCFLAGS=-DLUA_USE_LINUX $(if $(USE_READLINE), MYLIBS="-lreadline")
+ # use this on Mac OS X 10.3-
+ # $(MAKE) all MYCFLAGS=-DLUA_USE_MACOSX
+
diff --git a/package/lua/patches/200-lua-path.patch b/package/lua/patches/200-lua-path.patch
new file mode 100644
index 0000000..0544577
--- /dev/null
+++ b/package/lua/patches/200-lua-path.patch
@@ -0,0 +1,15 @@
+--- a/src/luaconf.h
++++ b/src/luaconf.h
+@@ -95,9 +95,9 @@
+ ".\\?.dll;" LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll"
+
+ #else
+-#define LUA_ROOT "/usr/local/"
+-#define LUA_LDIR LUA_ROOT "share/lua/5.1/"
+-#define LUA_CDIR LUA_ROOT "lib/lua/5.1/"
++#define LUA_ROOT "/usr/"
++#define LUA_LDIR LUA_ROOT "share/lua/"
++#define LUA_CDIR LUA_ROOT "lib/lua/"
+ #define LUA_PATH_DEFAULT \
+ "./?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \
+ LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua"
diff --git a/package/lua/patches/300-opcode_performance.patch b/package/lua/patches/300-opcode_performance.patch
new file mode 100644
index 0000000..5fbb873
--- /dev/null
+++ b/package/lua/patches/300-opcode_performance.patch
@@ -0,0 +1,363 @@
+--- a/src/lvm.c
++++ b/src/lvm.c
+@@ -31,6 +31,9 @@
+ /* limit for table tag-method chains (to avoid loops) */
+ #define MAXTAGLOOP 100
+
++#ifdef __GNUC__
++#define COMPUTED_GOTO 1
++#endif
+
+ /*
+ * If 'obj' is a string, it is tried to be interpreted as a number.
+@@ -566,12 +569,63 @@ static inline int arith_mode( const TVal
+ ARITH_OP1_END
+ #endif
+
++#ifdef COMPUTED_GOTO
++#define OPCODE_TARGET(op) DO_OP_##op:
++#define CALL_OPCODE(op) goto *opcodes[op];
++#define OPCODE_PTR(op) [OP_##op] = &&DO_OP_##op
++#else
++#define OPCODE_TARGET(op) case OP_##op:
++#define CALL_OPCODE(op) switch (op)
++#endif
++
+
+ void luaV_execute (lua_State *L, int nexeccalls) {
+ LClosure *cl;
+ StkId base;
+ TValue *k;
+ const Instruction *pc;
++#ifdef COMPUTED_GOTO
++ static const void *opcodes[] = {
++ OPCODE_PTR(MOVE),
++ OPCODE_PTR(LOADK),
++ OPCODE_PTR(LOADBOOL),
++ OPCODE_PTR(LOADNIL),
++ OPCODE_PTR(GETUPVAL),
++ OPCODE_PTR(GETGLOBAL),
++ OPCODE_PTR(GETTABLE),
++ OPCODE_PTR(SETGLOBAL),
++ OPCODE_PTR(SETUPVAL),
++ OPCODE_PTR(SETTABLE),
++ OPCODE_PTR(NEWTABLE),
++ OPCODE_PTR(SELF),
++ OPCODE_PTR(ADD),
++ OPCODE_PTR(SUB),
++ OPCODE_PTR(MUL),
++ OPCODE_PTR(DIV),
++ OPCODE_PTR(MOD),
++ OPCODE_PTR(POW),
++ OPCODE_PTR(UNM),
++ OPCODE_PTR(NOT),
++ OPCODE_PTR(LEN),
++ OPCODE_PTR(CONCAT),
++ OPCODE_PTR(JMP),
++ OPCODE_PTR(EQ),
++ OPCODE_PTR(LT),
++ OPCODE_PTR(LE),
++ OPCODE_PTR(TEST),
++ OPCODE_PTR(TESTSET),
++ OPCODE_PTR(CALL),
++ OPCODE_PTR(TAILCALL),
++ OPCODE_PTR(RETURN),
++ OPCODE_PTR(FORLOOP),
++ OPCODE_PTR(FORPREP),
++ OPCODE_PTR(TFORLOOP),
++ OPCODE_PTR(SETLIST),
++ OPCODE_PTR(CLOSE),
++ OPCODE_PTR(CLOSURE),
++ OPCODE_PTR(VARARG)
++ };
++#endif
+ reentry: /* entry point */
+ lua_assert(isLua(L->ci));
+ pc = L->savedpc;
+@@ -596,33 +650,33 @@ void luaV_execute (lua_State *L, int nex
+ lua_assert(base == L->base && L->base == L->ci->base);
+ lua_assert(base <= L->top && L->top <= L->stack + L->stacksize);
+ lua_assert(L->top == L->ci->top || luaG_checkopenop(i));
+- switch (GET_OPCODE(i)) {
+- case OP_MOVE: {
++ CALL_OPCODE(GET_OPCODE(i)) {
++ OPCODE_TARGET(MOVE) {
+ setobjs2s(L, ra, RB(i));
+ continue;
+ }
+- case OP_LOADK: {
++ OPCODE_TARGET(LOADK) {
+ setobj2s(L, ra, KBx(i));
+ continue;
+ }
+- case OP_LOADBOOL: {
++ OPCODE_TARGET(LOADBOOL) {
+ setbvalue(ra, GETARG_B(i));
+ if (GETARG_C(i)) pc++; /* skip next instruction (if C) */
+ continue;
+ }
+- case OP_LOADNIL: {
++ OPCODE_TARGET(LOADNIL) {
+ TValue *rb = RB(i);
+ do {
+ setnilvalue(rb--);
+ } while (rb >= ra);
+ continue;
+ }
+- case OP_GETUPVAL: {
++ OPCODE_TARGET(GETUPVAL) {
+ int b = GETARG_B(i);
+ setobj2s(L, ra, cl->upvals[b]->v);
+ continue;
+ }
+- case OP_GETGLOBAL: {
++ OPCODE_TARGET(GETGLOBAL) {
+ TValue g;
+ TValue *rb = KBx(i);
+ sethvalue(L, &g, cl->env);
+@@ -630,88 +684,88 @@ void luaV_execute (lua_State *L, int nex
+ Protect(luaV_gettable(L, &g, rb, ra));
+ continue;
+ }
+- case OP_GETTABLE: {
++ OPCODE_TARGET(GETTABLE) {
+ Protect(luaV_gettable(L, RB(i), RKC(i), ra));
+ continue;
+ }
+- case OP_SETGLOBAL: {
++ OPCODE_TARGET(SETGLOBAL) {
+ TValue g;
+ sethvalue(L, &g, cl->env);
+ lua_assert(ttisstring(KBx(i)));
+ Protect(luaV_settable(L, &g, KBx(i), ra));
+ continue;
+ }
+- case OP_SETUPVAL: {
++ OPCODE_TARGET(SETUPVAL) {
+ UpVal *uv = cl->upvals[GETARG_B(i)];
+ setobj(L, uv->v, ra);
+ luaC_barrier(L, uv, ra);
+ continue;
+ }
+- case OP_SETTABLE: {
++ OPCODE_TARGET(SETTABLE) {
+ Protect(luaV_settable(L, ra, RKB(i), RKC(i)));
+ continue;
+ }
+- case OP_NEWTABLE: {
++ OPCODE_TARGET(NEWTABLE) {
+ int b = GETARG_B(i);
+ int c = GETARG_C(i);
+ sethvalue(L, ra, luaH_new(L, luaO_fb2int(b), luaO_fb2int(c)));
+ Protect(luaC_checkGC(L));
+ continue;
+ }
+- case OP_SELF: {
++ OPCODE_TARGET(SELF) {
+ StkId rb = RB(i);
+ setobjs2s(L, ra+1, rb);
+ Protect(luaV_gettable(L, rb, RKC(i), ra));
+ continue;
+ }
+- case OP_ADD: {
++ OPCODE_TARGET(ADD) {
+ TValue *rb = RKB(i), *rc= RKC(i);
+ arith_op_continue( luai_numadd, try_addint, luai_vectadd );
+ Protect(Arith(L, ra, rb, rc, TM_ADD)); \
+ continue;
+ }
+- case OP_SUB: {
++ OPCODE_TARGET(SUB) {
+ TValue *rb = RKB(i), *rc= RKC(i);
+ arith_op_continue( luai_numsub, try_subint, luai_vectsub );
+ Protect(Arith(L, ra, rb, rc, TM_SUB));
+ continue;
+ }
+- case OP_MUL: {
++ OPCODE_TARGET(MUL) {
+ TValue *rb = RKB(i), *rc= RKC(i);
+ arith_op_continue(luai_nummul, try_mulint, luai_vectmul);
+ Protect(Arith(L, ra, rb, rc, TM_MUL));
+ continue;
+ }
+- case OP_DIV: {
++ OPCODE_TARGET(DIV) {
+ TValue *rb = RKB(i), *rc= RKC(i);
+ arith_op_continue(luai_numdiv, try_divint, luai_vectdiv);
+ Protect(Arith(L, ra, rb, rc, TM_DIV));
+ continue;
+ }
+- case OP_MOD: {
++ OPCODE_TARGET(MOD) {
+ TValue *rb = RKB(i), *rc= RKC(i);
+ arith_op_continue_scalar(luai_nummod, try_modint); /* scalars only */
+ Protect(Arith(L, ra, rb, rc, TM_MOD));
+ continue;
+ }
+- case OP_POW: {
++ OPCODE_TARGET(POW) {
+ TValue *rb = RKB(i), *rc= RKC(i);
+ arith_op_continue(luai_numpow, try_powint, luai_vectpow);
+ Protect(Arith(L, ra, rb, rc, TM_POW));
+ continue;
+ }
+- case OP_UNM: {
++ OPCODE_TARGET(UNM) {
+ TValue *rb = RB(i);
+ arith_op1_continue(luai_numunm, try_unmint, luai_vectunm);
+ Protect(Arith(L, ra, rb, rb, TM_UNM));
+ continue;
+ }
+- case OP_NOT: {
++ OPCODE_TARGET(NOT) {
+ int res = l_isfalse(RB(i)); /* next assignment may change this value */
+ setbvalue(ra, res);
+ continue;
+ }
+- case OP_LEN: {
++ OPCODE_TARGET(LEN) {
+ const TValue *rb = RB(i);
+ switch (ttype(rb)) {
+ case LUA_TTABLE: {
+@@ -731,18 +785,18 @@ void luaV_execute (lua_State *L, int nex
+ }
+ continue;
+ }
+- case OP_CONCAT: {
++ OPCODE_TARGET(CONCAT) {
+ int b = GETARG_B(i);
+ int c = GETARG_C(i);
+ Protect(luaV_concat(L, c-b+1, c); luaC_checkGC(L));
+ setobjs2s(L, RA(i), base+b);
+ continue;
+ }
+- case OP_JMP: {
++ OPCODE_TARGET(JMP) {
+ dojump(L, pc, GETARG_sBx(i));
+ continue;
+ }
+- case OP_EQ: {
++ OPCODE_TARGET(EQ) {
+ TValue *rb = RKB(i);
+ TValue *rc = RKC(i);
+ Protect(
+@@ -752,7 +806,7 @@ void luaV_execute (lua_State *L, int nex
+ pc++;
+ continue;
+ }
+- case OP_LT: {
++ OPCODE_TARGET(LT) {
+ Protect(
+ if (luaV_lessthan(L, RKB(i), RKC(i)) == GETARG_A(i))
+ dojump(L, pc, GETARG_sBx(*pc));
+@@ -760,7 +814,7 @@ void luaV_execute (lua_State *L, int nex
+ pc++;
+ continue;
+ }
+- case OP_LE: {
++ OPCODE_TARGET(LE) {
+ Protect(
+ if (lessequal(L, RKB(i), RKC(i)) == GETARG_A(i))
+ dojump(L, pc, GETARG_sBx(*pc));
+@@ -768,13 +822,13 @@ void luaV_execute (lua_State *L, int nex
+ pc++;
+ continue;
+ }
+- case OP_TEST: {
++ OPCODE_TARGET(TEST) {
+ if (l_isfalse(ra) != GETARG_C(i))
+ dojump(L, pc, GETARG_sBx(*pc));
+ pc++;
+ continue;
+ }
+- case OP_TESTSET: {
++ OPCODE_TARGET(TESTSET) {
+ TValue *rb = RB(i);
+ if (l_isfalse(rb) != GETARG_C(i)) {
+ setobjs2s(L, ra, rb);
+@@ -783,7 +837,7 @@ void luaV_execute (lua_State *L, int nex
+ pc++;
+ continue;
+ }
+- case OP_CALL: {
++ OPCODE_TARGET(CALL) {
+ int b = GETARG_B(i);
+ int nresults = GETARG_C(i) - 1;
+ if (b != 0) L->top = ra+b; /* else previous instruction set top */
+@@ -804,7 +858,7 @@ void luaV_execute (lua_State *L, int nex
+ }
+ }
+ }
+- case OP_TAILCALL: {
++ OPCODE_TARGET(TAILCALL) {
+ int b = GETARG_B(i);
+ if (b != 0) L->top = ra+b; /* else previous instruction set top */
+ L->savedpc = pc;
+@@ -836,7 +890,7 @@ void luaV_execute (lua_State *L, int nex
+ }
+ }
+ }
+- case OP_RETURN: {
++ OPCODE_TARGET(RETURN) {
+ int b = GETARG_B(i);
+ if (b != 0) L->top = ra+b-1;
+ if (L->openupval) luaF_close(L, base);
+@@ -851,7 +905,7 @@ void luaV_execute (lua_State *L, int nex
+ goto reentry;
+ }
+ }
+- case OP_FORLOOP: {
++ OPCODE_TARGET(FORLOOP) {
+ /* If start,step and limit are all integers, we don't need to check
+ * against overflow in the looping.
+ */
+@@ -879,7 +933,7 @@ void luaV_execute (lua_State *L, int nex
+ }
+ continue;
+ }
+- case OP_FORPREP: {
++ OPCODE_TARGET(FORPREP) {
+ const TValue *init = ra;
+ const TValue *plimit = ra+1;
+ const TValue *pstep = ra+2;
+@@ -902,7 +956,7 @@ void luaV_execute (lua_State *L, int nex
+ dojump(L, pc, GETARG_sBx(i));
+ continue;
+ }
+- case OP_TFORLOOP: {
++ OPCODE_TARGET(TFORLOOP) {
+ StkId cb = ra + 3; /* call base */
+ setobjs2s(L, cb+2, ra+2);
+ setobjs2s(L, cb+1, ra+1);
+@@ -918,7 +972,7 @@ void luaV_execute (lua_State *L, int nex
+ pc++;
+ continue;
+ }
+- case OP_SETLIST: {
++ OPCODE_TARGET(SETLIST) {
+ int n = GETARG_B(i);
+ int c = GETARG_C(i);
+ int last;
+@@ -940,11 +994,11 @@ void luaV_execute (lua_State *L, int nex
+ }
+ continue;
+ }
+- case OP_CLOSE: {
++ OPCODE_TARGET(CLOSE) {
+ luaF_close(L, ra);
+ continue;
+ }
+- case OP_CLOSURE: {
++ OPCODE_TARGET(CLOSURE) {
+ Proto *p;
+ Closure *ncl;
+ int nup, j;
+@@ -964,7 +1018,7 @@ void luaV_execute (lua_State *L, int nex
+ Protect(luaC_checkGC(L));
+ continue;
+ }
+- case OP_VARARG: {
++ OPCODE_TARGET(VARARG) {
+ int b = GETARG_B(i) - 1;
+ int j;
+ CallInfo *ci = L->ci;
diff --git a/package/mac80211/.svn/entries b/package/mac80211/.svn/entries
new file mode 100644
index 0000000..789935d
--- /dev/null
+++ b/package/mac80211/.svn/entries
@@ -0,0 +1,68 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/mac80211
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-16T16:11:43.462930Z
+36056
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+files
+dir
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+437dab0588f491d10b538de88a3fa1ba
+2013-02-23T12:13:18.371919Z
+35758
+jogo
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+57200
+
diff --git a/package/mac80211/.svn/text-base/Makefile.svn-base b/package/mac80211/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..64233bd
--- /dev/null
+++ b/package/mac80211/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,1701 @@
+#
+# Copyright (C) 2007-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=mac80211
+
+PKG_VERSION:=2013-02-22
+PKG_RELEASE:=1
+PKG_SOURCE_URL:=http://mirror2.openwrt.org/sources
+PKG_MD5SUM:=de1a03ca1f72748d4523672c8facbf7e
+
+PKG_SOURCE:=compat-wireless-$(PKG_VERSION).tar.bz2
+PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/compat-wireless-$(PKG_VERSION)
+PKG_BUILD_PARALLEL:=1
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+
+PKG_DRIVERS = \
+ adm8211 ath5k libertas-usb libertas-sd p54-common p54-pci p54-usb p54-spi \
+ rt2x00-lib rt2x00-pci rt2x00-usb rt2x00-soc rt2800-lib rt2400-pci \
+ rt2500-pci rt2500-usb rt61-pci rt73-usb rt2800-pci rt2800-usb \
+ rtl8180 rtl8187 zd1211rw mac80211-hwsim carl9170 b43 b43legacy \
+ ath9k-common ath9k ath9k-htc ath net-libipw net-ipw2100 net-ipw2200 \
+ mwl8k net-hermes net-hermes-pci net-hermes-plx net-hermes-pcmcia \
+ iwl-legacy iwl3945 iwl4965 iwlagn wl12xx lib80211
+
+PKG_CONFIG_DEPENDS:= \
+ CONFIG_PACKAGE_kmod-mac80211 \
+ $(patsubst %,CONFIG_PACKAGE_kmod-%,$(PKG_DRIVERS)) \
+ CONFIG_PACKAGE_MAC80211_DEBUGFS \
+ CONFIG_PACKAGE_MAC80211_MESH \
+ CONFIG_PACKAGE_ATH_DEBUG \
+ CONFIG_PACKAGE_B43_DEBUG \
+ CONFIG_PACKAGE_B43_PIO \
+ CONFIG_PACKAGE_B43_N_PHY \
+ CONFIG_ATH_USER_REGD \
+
+CARL9170_FW_VERSION:=1.9.6
+
+include $(INCLUDE_DIR)/package.mk
+
+WMENU:=Wireless Drivers
+
+define KernelPackage/mac80211/Default
+ SUBMENU:=$(WMENU)
+ URL:=http://linuxwireless.org/
+ MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+ DEPENDS:=@(!(TARGET_avr32||TARGET_ps3||TARGET_pxcab)||BROKEN)
+endef
+
+define KernelPackage/cfg80211
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=cfg80211 - wireless configuration API
+ DEPENDS+= +iw
+ FILES:= \
+ $(PKG_BUILD_DIR)/compat/compat.ko \
+ $(PKG_BUILD_DIR)/net/wireless/cfg80211.ko
+ AUTOLOAD:=$(call AutoLoad,20,compat cfg80211)
+endef
+
+define KernelPackage/cfg80211/description
+cfg80211 is the Linux wireless LAN (802.11) configuration API.
+endef
+
+define KernelPackage/mac80211
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=Linux 802.11 Wireless Networking Stack
+ DEPENDS+= +kmod-crypto-core +kmod-crypto-arc4 +kmod-crypto-aes +kmod-cfg80211
+ KCONFIG:=\
+ CONFIG_AVERAGE=y
+ FILES:= $(PKG_BUILD_DIR)/net/mac80211/mac80211.ko
+ AUTOLOAD:=$(call AutoLoad,21,mac80211)
+ MENU:=1
+endef
+
+define KernelPackage/mac80211/config
+ if PACKAGE_kmod-mac80211
+
+ config PACKAGE_MAC80211_DEBUGFS
+ bool "Export mac80211 internals in DebugFS"
+ select KERNEL_DEBUG_FS
+ select KERNEL_RELAY if PACKAGE_kmod-ath9k-common
+ default y
+ help
+ Select this to see extensive information about
+ the internal state of mac80211 in debugfs.
+
+ config PACKAGE_MAC80211_MESH
+ bool "Enable 802.11s mesh support"
+ default y
+
+ endif
+endef
+
+define KernelPackage/mac80211/description
+Generic IEEE 802.11 Networking Stack (mac80211)
+endef
+
+PKG_LINUX_FIRMWARE_NAME:=linux-firmware
+PKG_LINUX_FIRMWARE_VERSION:=6942dba419d2ebf8c15514972e89734fd7a8cebc
+PKG_LINUX_FIRMWARE_SOURCE:=$(PKG_LINUX_FIRMWARE_NAME)-$(PKG_LINUX_FIRMWARE_VERSION).tar.bz2
+PKG_LINUX_FIRMWARE_PROTO:=git
+PKG_LINUX_FIRMWARE_SOURCE_URL:=git://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git
+PKG_LINUX_FIRMWARE_SUBDIR:=$(PKG_LINUX_FIRMWARE_NAME)-$(PKG_LINUX_FIRMWARE_VERSION)
+PKG_LINUX_FIRMWARE_MIRROR_MD5SUM:=a5f8c27af9e43f0ad24d7f821c5a781e
+
+define Download/linux-firmware
+ FILE:=$(PKG_LINUX_FIRMWARE_SOURCE)
+ URL:=$(PKG_LINUX_FIRMWARE_SOURCE_URL)
+ MD5SUM:=$(PKG_LINUX_FIRMWARE_MD5SUM)
+ PROTO:=$(PKG_LINUX_FIRMWARE_PROTO)
+ VERSION:=$(PKG_LINUX_FIRMWARE_VERSION)
+ SUBDIR:=$(PKG_LINUX_FIRMWARE_SUBDIR)
+ MIRROR_MD5SUM:=$(PKG_LINUX_FIRMWARE_MIRROR_MD5SUM)
+endef
+$(eval $(call Download,linux-firmware))
+
+# Prism54 drivers
+P54PCIFW:=2.13.12.0.arm
+P54USBFW:=2.13.24.0.lm87.arm
+P54SPIFW:=2.13.0.0.a.13.14.arm
+CARL9170_FW:=carl9170-1.fw
+
+define Download/p54usb
+ FILE:=$(P54USBFW)
+ URL:=http://daemonizer.de/prism54/prism54-fw/fw-usb
+ MD5SUM:=8e8ab005a4f8f0123bcdc51bc25b47f6
+endef
+$(eval $(call Download,p54usb))
+
+define Download/p54pci
+ FILE:=$(P54PCIFW)
+ URL:=http://daemonizer.de/prism54/prism54-fw/fw-softmac
+ MD5SUM:=ff7536af2092b1c4b21315bd103ef4c4
+endef
+$(eval $(call Download,p54pci))
+
+define Download/p54spi
+ FILE:=$(P54SPIFW)
+ URL:=http://daemonizer.de/prism54/prism54-fw/stlc4560
+ MD5SUM:=42661f8ecbadd88012807493f596081d
+endef
+$(eval $(call Download,p54spi))
+
+define Download/carl9170
+ FILE:=$(CARL9170_FW)-$(CARL9170_FW_VERSION)
+ URL:=http://downloads.openwrt.org/sources/
+ MD5SUM:=2fa6ed98d53d0b5fbcc136d1cf5e9609
+endef
+$(eval $(call Download,carl9170))
+
+define KernelPackage/p54/Default
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=Prism54 Drivers
+endef
+
+define KernelPackage/p54/description
+ Kernel module for Prism54 chipsets (mac80211)
+endef
+
+define KernelPackage/p54-common
+ $(call KernelPackage/p54/Default)
+ DEPENDS+= @PCI_SUPPORT||@USB_SUPPORT||@TARGET_omap24xx +kmod-mac80211 +kmod-lib-crc-ccitt
+ TITLE+= (COMMON)
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/p54/p54common.ko
+ AUTOLOAD:=$(call AutoLoad,30,p54common)
+endef
+
+define KernelPackage/p54-pci
+ $(call KernelPackage/p54/Default)
+ TITLE+= (PCI)
+ DEPENDS+= @PCI_SUPPORT +kmod-p54-common
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/p54/p54pci.ko
+ AUTOLOAD:=$(call AutoLoad,31,p54pci)
+endef
+
+define KernelPackage/p54-usb
+ $(call KernelPackage/p54/Default)
+ TITLE+= (USB)
+ DEPENDS+= @USB_SUPPORT +kmod-usb-core +kmod-p54-common
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/p54/p54usb.ko
+ AUTOLOAD:=$(call AutoLoad,31,p54usb)
+endef
+
+define KernelPackage/p54-spi
+ $(call KernelPackage/p54/Default)
+ TITLE+= (SPI)
+ DEPENDS+= @TARGET_omap24xx +kmod-p54-common
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/p54/p54spi.ko
+ AUTOLOAD:=$(call AutoLoad,31,p54spi)
+endef
+
+NEED_RT2X00_LIB_CRYPTO:=y
+NEED_RT2X00_LIB_FIRMWARE:=y
+NEED_RT2X00_LIB_EEPROM:=y
+NEED_RT2X00_LIB_HT:=y
+NEED_RT2X00_LIB_LEDS:=y
+
+define KernelPackage/rt2x00/Default
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=Ralink Drivers for RT2x00 cards
+endef
+
+define KernelPackage/rt2x00-lib
+$(call KernelPackage/rt2x00/Default)
+ DEPENDS+= @(PCI_SUPPORT||USB_SUPPORT||TARGET_ramips) +kmod-mac80211 +kmod-lib-crc-itu-t
+ TITLE+= (LIB)
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/rt2x00/rt2x00lib.ko
+ AUTOLOAD:=$(call AutoLoad,25,rt2x00lib)
+ MENU:=1
+endef
+
+define KernelPackage/rt2x00-lib/config
+ if PACKAGE_kmod-rt2x00-lib
+
+ config PACKAGE_RT2X00_LIB_DEBUGFS
+ bool "Enable rt2x00 debugfs support"
+ depends PACKAGE_MAC80211_DEBUGFS
+ help
+ Enable creation of debugfs files for the rt2x00 drivers.
+ These debugfs files support both reading and writing of the
+ most important register types of the rt2x00 hardware.
+
+ config PACKAGE_RT2X00_DEBUG
+ bool "Enable rt2x00 debug output"
+ help
+ Enable debugging output for all rt2x00 modules
+
+ endif
+endef
+
+define KernelPackage/rt2x00-pci
+$(call KernelPackage/rt2x00/Default)
+ DEPENDS+= @(PCI_SUPPORT||TARGET_ramips) +kmod-rt2x00-lib +kmod-eeprom-93cx6
+ TITLE+= (PCI)
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/rt2x00/rt2x00pci.ko
+ AUTOLOAD:=$(call AutoLoad,26,rt2x00pci)
+endef
+
+define KernelPackage/rt2x00-usb
+$(call KernelPackage/rt2x00/Default)
+ DEPENDS+= @USB_SUPPORT +kmod-rt2x00-lib +kmod-usb-core
+ TITLE+= (USB)
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/rt2x00/rt2x00usb.ko
+ AUTOLOAD:=$(call AutoLoad,26,rt2x00usb)
+endef
+
+define KernelPackage/rt2x00-soc
+$(call KernelPackage/rt2x00/Default)
+ DEPENDS+= @TARGET_ramips +kmod-rt2x00-lib
+ TITLE+= (SoC)
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/rt2x00/rt2x00soc.ko
+ AUTOLOAD:=$(call AutoLoad,26,rt2x00soc)
+endef
+
+define KernelPackage/rt2800-lib
+$(call KernelPackage/rt2x00/Default)
+ DEPENDS+= @(PCI_SUPPORT||USB_SUPPORT||TARGET_ramips) +kmod-rt2x00-lib +TARGET_ramips:kmod-rt2x00-soc +@DRIVER_11N_SUPPORT
+ TITLE+= (rt2800 LIB)
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/rt2x00/rt2800lib.ko
+ AUTOLOAD:=$(call AutoLoad,27,rt2800lib)
+endef
+
+define KernelPackage/rt2400-pci
+$(call KernelPackage/rt2x00/Default)
+ DEPENDS+= @PCI_SUPPORT +kmod-rt2x00-pci
+ TITLE+= (RT2400 PCI)
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/rt2x00/rt2400pci.ko
+ AUTOLOAD:=$(call AutoLoad,27,rt2400pci)
+endef
+
+define KernelPackage/rt2500-pci
+$(call KernelPackage/rt2x00/Default)
+ DEPENDS+= @PCI_SUPPORT +kmod-rt2x00-pci
+ TITLE+= (RT2500 PCI)
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/rt2x00/rt2500pci.ko
+ AUTOLOAD:=$(call AutoLoad,27,rt2500pci)
+endef
+
+define KernelPackage/rt2500-usb
+$(call KernelPackage/rt2x00/Default)
+ DEPENDS+= @USB_SUPPORT +kmod-rt2x00-usb
+ TITLE+= (RT2500 USB)
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/rt2x00/rt2500usb.ko
+ AUTOLOAD:=$(call AutoLoad,27,rt2500usb)
+endef
+
+define KernelPackage/rt61-pci
+$(call KernelPackage/rt2x00/Default)
+ DEPENDS+= @PCI_SUPPORT +kmod-rt2x00-pci
+ TITLE+= (RT2x61 PCI)
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/rt2x00/rt61pci.ko
+ AUTOLOAD:=$(call AutoLoad,27,rt61pci)
+endef
+
+define KernelPackage/rt73-usb
+ $(call KernelPackage/rt2x00/Default)
+ DEPENDS+= @USB_SUPPORT +kmod-rt2x00-usb
+ TITLE+= (RT73 USB)
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/rt2x00/rt73usb.ko
+ AUTOLOAD:=$(call AutoLoad,27,rt73usb)
+endef
+
+define KernelPackage/rt2800-pci
+$(call KernelPackage/rt2x00/Default)
+ DEPENDS+= @(PCI_SUPPORT||TARGET_ramips) +kmod-rt2x00-pci +kmod-rt2800-lib +kmod-lib-crc-ccitt +TARGET_ramips:kmod-rt2x00-soc
+ TITLE+= (RT2860 PCI)
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/rt2x00/rt2800pci.ko
+ AUTOLOAD:=$(call AutoLoad,28,rt2800pci)
+endef
+
+define KernelPackage/rt2800-usb
+$(call KernelPackage/rt2x00/Default)
+ DEPENDS+= @USB_SUPPORT +kmod-rt2x00-usb +kmod-rt2800-lib +kmod-lib-crc-ccitt
+ TITLE+= (RT2870 USB)
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/rt2x00/rt2800usb.ko
+ AUTOLOAD:=$(call AutoLoad,28,rt2800usb)
+endef
+
+define KernelPackage/rtl818x/Default
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=Realtek Drivers for RTL818x devices
+ URL:=http://wireless.kernel.org/en/users/Drivers/rtl8187
+ DEPENDS+= +kmod-eeprom-93cx6 +kmod-mac80211
+endef
+
+define KernelPackage/rtl8180
+ $(call KernelPackage/rtl818x/Default)
+ DEPENDS+= @PCI_SUPPORT
+ TITLE+= (RTL8180 PCI)
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/rtl818x/rtl8180/rtl8180.ko
+ AUTOLOAD:=$(call AutoLoad,27,rtl8180)
+endef
+
+define KernelPackage/rtl8187
+$(call KernelPackage/rtl818x/Default)
+ DEPENDS+= @USB_SUPPORT +kmod-usb-core
+ TITLE+= (RTL8187 USB)
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/rtl818x/rtl8187/rtl8187.ko
+ AUTOLOAD:=$(call AutoLoad,27,rtl8187)
+endef
+
+ZD1211FW_NAME:=zd1211-firmware
+ZD1211FW_VERSION:=1.4
+define Download/zd1211rw
+ FILE:=$(ZD1211FW_NAME)-$(ZD1211FW_VERSION).tar.bz2
+ URL:=@SF/zd1211/
+ MD5SUM:=19f28781d76569af8551c9d11294c870
+endef
+$(eval $(call Download,zd1211rw))
+
+define KernelPackage/zd1211rw
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=Zydas ZD1211 support
+ DEPENDS+= @USB_SUPPORT +kmod-usb-core +kmod-mac80211
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/zd1211rw/zd1211rw.ko
+ AUTOLOAD:=$(call AutoLoad,60,zd1211rw)
+endef
+
+define KernelPackage/adm8211
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=ADMTek 8211 support
+ DEPENDS+=@PCI_SUPPORT +kmod-mac80211 +kmod-eeprom-93cx6
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/adm8211.ko
+ AUTOLOAD:=$(call AutoLoad,60,adm8211)
+endef
+
+define KernelPackage/ath/config
+ if PACKAGE_kmod-ath
+ config ATH_USER_REGD
+ bool "Force Atheros drivers to respect the user's regdomain settings"
+ help
+ Atheros' idea of regulatory handling is that the EEPROM of the card defines
+ the regulatory limits and the user is only allowed to restrict the settings
+ even further, even if the country allows frequencies or power levels that
+ are forbidden by the EEPROM settings.
+
+ Select this option if you want the driver to respect the user's decision about
+ regulatory settings.
+
+ config PACKAGE_ATH_DEBUG
+ bool "Atheros wireless debugging"
+ help
+ Say Y, if you want to debug atheros wireless drivers.
+ Right now only ath9k makes use of this.
+ endif
+endef
+
+define KernelPackage/ath
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=Atheros common driver part
+ DEPENDS+= @PCI_SUPPORT||USB_SUPPORT||TARGET_ar71xx||TARGET_atheros +kmod-mac80211
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/ath/ath.ko
+ AUTOLOAD:=$(call AutoLoad,26,ath)
+ MENU:=1
+endef
+
+define KernelPackage/ath/description
+ This module contains some common parts needed by Atheros Wireless drivers.
+endef
+
+define KernelPackage/ath5k
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=Atheros 5xxx wireless cards support
+ URL:=http://linuxwireless.org/en/users/Drivers/ath5k
+ DEPENDS+= @PCI_SUPPORT||@TARGET_atheros +kmod-ath
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/ath/ath5k/ath5k.ko
+ AUTOLOAD:=$(call AutoLoad,27,ath5k)
+endef
+
+define KernelPackage/ath5k/description
+ This module adds support for wireless adapters based on
+ Atheros 5xxx chipset.
+endef
+
+define KernelPackage/ath9k-common
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=Atheros 802.11n wireless devices (common code for ath9k and ath9k_htc)
+ URL:=http://linuxwireless.org/en/users/Drivers/ath9k
+ DEPENDS+= @PCI_SUPPORT||USB_SUPPORT||TARGET_ar71xx +kmod-ath +@DRIVER_11N_SUPPORT
+ FILES:= \
+ $(PKG_BUILD_DIR)/drivers/net/wireless/ath/ath9k/ath9k_common.ko \
+ $(PKG_BUILD_DIR)/drivers/net/wireless/ath/ath9k/ath9k_hw.ko
+ AUTOLOAD:=$(call AutoLoad,27,ath9k_hw ath9k_common)
+endef
+
+define KernelPackage/ath9k
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=Atheros 802.11n PCI wireless cards support
+ URL:=http://linuxwireless.org/en/users/Drivers/ath9k
+ DEPENDS+= @PCI_SUPPORT||TARGET_ar71xx +kmod-ath9k-common
+ FILES:= \
+ $(PKG_BUILD_DIR)/drivers/net/wireless/ath/ath9k/ath9k.ko
+ AUTOLOAD:=$(call AutoLoad,28,ath9k)
+endef
+
+define KernelPackage/ath9k/description
+This module adds support for wireless adapters based on
+Atheros IEEE 802.11n AR5008 and AR9001 family of chipsets.
+endef
+
+define KernelPackage/ath9k-htc
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=Atheros 802.11n USB device support
+ URL:=http://linuxwireless.org/en/users/Drivers/ath9k
+ DEPENDS+= @USB_SUPPORT +kmod-ath9k-common +kmod-usb-core
+ FILES:= \
+ $(PKG_BUILD_DIR)/drivers/net/wireless/ath/ath9k/ath9k_htc.ko
+ AUTOLOAD:=$(call AutoLoad,55,ath9k_htc)
+endef
+
+define KernelPackage/ath9k-htc/description
+This module adds support for wireless adapters based on
+Atheros USB AR9271 and AR7010 family of chipsets.
+endef
+
+define KernelPackage/carl9170
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=Driver for Atheros AR9170 USB sticks
+ DEPENDS:=@USB_SUPPORT +kmod-mac80211 +kmod-ath +kmod-usb-core +kmod-input-core +@DRIVER_11N_SUPPORT
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/ath/carl9170/carl9170.ko
+ AUTOLOAD:=$(call AutoLoad,60,carl9170)
+endef
+
+define KernelPackage/carl9170/install
+ $(INSTALL_DIR) $(1)/lib/firmware
+ $(INSTALL_DATA) $(DL_DIR)/$(CARL9170_FW)-$(CARL9170_FW_VERSION) $(1)/lib/firmware/$(CARL9170_FW)
+endef
+
+define KernelPackage/lib80211
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=802.11 Networking stack
+ FILES:= \
+ $(PKG_BUILD_DIR)/net/wireless/lib80211.ko \
+ $(PKG_BUILD_DIR)/net/wireless/lib80211_crypt_wep.ko \
+ $(PKG_BUILD_DIR)/net/wireless/lib80211_crypt_ccmp.ko \
+ $(PKG_BUILD_DIR)/net/wireless/lib80211_crypt_tkip.ko
+ AUTOLOAD:=$(call AutoLoad,21, \
+ lib80211 \
+ lib80211_crypt_wep \
+ lib80211_crypt_ccmp \
+ lib80211_crypt_tkip \
+ )
+endef
+
+define KernelPackage/lib80211/description
+ Kernel modules for 802.11 Networking stack
+ Includes:
+ - lib80211
+ - lib80211_crypt_wep
+ - lib80211_crypt_tkip
+ - lib80211_crytp_ccmp
+endef
+
+define KernelPackage/libertas-usb
+ $(call KernelPackage/mac80211/Default)
+ DEPENDS+= @USB_SUPPORT +kmod-cfg80211 +kmod-usb-core +kmod-lib80211 +@DRIVER_WEXT_SUPPORT
+ TITLE:=Marvell 88W8015 Wireless Driver
+ FILES:= \
+ $(PKG_BUILD_DIR)/drivers/net/wireless/libertas/libertas.ko \
+ $(PKG_BUILD_DIR)/drivers/net/wireless/libertas/usb8xxx.ko
+ AUTOLOAD:=$(call AutoLoad,27,libertas usb8xxx)
+endef
+
+define KernelPackage/libertas-sd
+ $(call KernelPackage/mac80211/Default)
+ DEPENDS+= +kmod-cfg80211 +kmod-lib80211 +@DRIVER_WEXT_SUPPORT
+ TITLE:=Marvell 88W8686 Wireless Driver
+ FILES:= \
+ $(PKG_BUILD_DIR)/drivers/net/wireless/libertas/libertas.ko \
+ $(PKG_BUILD_DIR)/drivers/net/wireless/libertas/libertas_sdio.ko
+ AUTOLOAD:=$(call AutoLoad,91,libertas libertas_sdio)
+endef
+
+define KernelPackage/mac80211-hwsim
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=mac80211 HW simulation device
+ DEPENDS+= +kmod-mac80211
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/mac80211_hwsim.ko
+ AUTOLOAD:=$(call AutoLoad,60,mac80211_hwsim)
+endef
+
+define KernelPackage/net-libipw
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=libipw for ipw2100 and ipw2200
+ DEPENDS:=@PCI_SUPPORT +kmod-crypto-core +kmod-crypto-arc4 +kmod-crypto-aes +kmod-crypto-michael-mic +kmod-lib80211 +kmod-cfg80211 +@DRIVER_WEXT_SUPPORT
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/ipw2x00/libipw.ko
+ AUTOLOAD:=$(call AutoLoad,49,libipw)
+endef
+
+define KernelPackage/net-libipw/description
+ Hardware independent IEEE 802.11 networking stack for ipw2100 and ipw2200.
+endef
+
+IPW2100_NAME:=ipw2100-fw
+IPW2100_VERSION:=1.3
+
+define Download/net-ipw2100
+ URL:=http://bughost.org/firmware/
+ FILE:=$(IPW2100_NAME)-$(IPW2100_VERSION).tgz
+ MD5SUM=46aa75bcda1a00efa841f9707bbbd113
+endef
+$(eval $(call Download,net-ipw2100))
+
+define KernelPackage/net-ipw2100
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=Intel IPW2100 driver
+ DEPENDS:=@PCI_SUPPORT +kmod-net-libipw
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/ipw2x00/ipw2100.ko
+ AUTOLOAD:=$(call AutoLoad,50,ipw2100)
+endef
+
+define KernelPackage/net-ipw2100/description
+ Kernel support for Intel IPW2100
+ Includes:
+ - ipw2100
+endef
+
+IPW2200_NAME:=ipw2200-fw
+IPW2200_VERSION:=3.1
+
+define Download/net-ipw2200
+ URL:=http://bughost.org/firmware/
+ FILE:=$(IPW2200_NAME)-$(IPW2200_VERSION).tgz
+ MD5SUM=eaba788643c7cc7483dd67ace70f6e99
+endef
+$(eval $(call Download,net-ipw2200))
+
+define KernelPackage/net-ipw2200
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=Intel IPW2200 driver
+ DEPENDS:=@PCI_SUPPORT +kmod-net-libipw
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/ipw2x00/ipw2200.ko
+ AUTOLOAD:=$(call AutoLoad,50,ipw2200)
+endef
+
+define KernelPackage/net-ipw2200/description
+ Kernel support for Intel IPW2200
+ Includes:
+ - ipw2200
+endef
+
+
+define KernelPackage/net-hermes
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=Hermes 802.11b chipset support
+ DEPENDS:=@PCI_SUPPORT||PCMCIA_SUPPORT +kmod-cfg80211 +@DRIVER_WEXT_SUPPORT
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/orinoco/orinoco.ko
+ AUTOLOAD:=$(call AutoLoad,50,orinoco)
+endef
+
+define KernelPackage/net-hermes/description
+ Kernel support for Hermes 802.11b chipsets
+endef
+
+define KernelPackage/net-hermes-pci
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=Intersil Prism 2.5 PCI support
+ DEPENDS:=@PCI_SUPPORT +kmod-net-hermes
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/orinoco/orinoco_pci.ko
+ AUTOLOAD:=$(call AutoLoad,55,orinoco_pci)
+endef
+
+define KernelPackage/net-hermes-pci/description
+ Kernel modules for Intersil Prism 2.5 PCI support
+endef
+
+define KernelPackage/net-hermes-plx
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=PLX9052 based PCI adaptor
+ DEPENDS:=@PCI_SUPPORT +kmod-net-hermes
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/orinoco/orinoco_plx.ko
+ AUTOLOAD:=$(call AutoLoad,55,orinoco_plx)
+endef
+
+define KernelPackage/net-hermes-plx/description
+ Kernel modules for Hermes in PLX9052 based PCI adaptors
+endef
+
+define KernelPackage/net-hermes-pcmcia
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=Hermes based PCMCIA adaptors
+ DEPENDS:=@PCMCIA_SUPPORT +kmod-net-hermes @BROKEN
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/orinoco/orinoco_cs.ko
+ AUTOLOAD:=$(call AutoLoad,55,orinoco_cs)
+endef
+
+define KernelPackage/net-hermes-pcmcia/description
+ Kernel modules for Hermes based PCMCIA adaptors
+endef
+
+define KernelPackage/iwlagn
+ $(call KernelPackage/mac80211/Default)
+ DEPENDS:= +kmod-mac80211 @PCI_SUPPORT +@DRIVER_11N_SUPPORT
+ TITLE:=Intel AGN Wireless support
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/iwlwifi/iwlwifi.ko
+ AUTOLOAD:=$(call AutoLoad,60,iwlwifi)
+ MENU:=1
+endef
+
+define KernelPackage/iwlagn/description
+ iwlagn kernel module for Intel 5000/5150/1000/6000/6050/6005/6030/100 support
+endef
+
+define KernelPackage/iwlagn/config
+ if PACKAGE_kmod-iwlagn
+
+ config IWL5000_FW
+ bool "Intel 5000 Firmware"
+ default y
+ help
+ Download and install firmware for:
+ Intel Wireless WiFi 5100AGN, 5300AGN, and 5350AGN
+
+ config IWL5150_FW
+ bool "Intel 5150 Firmware"
+ default y
+ help
+ Download and install firmware for:
+ Intel Wireless WiFi 5150AGN
+
+ config IWL1000_FW
+ bool "Intel 1000 Firmware"
+ default y
+ help
+ Download and install firmware for:
+ Intel Centrino Wireless-N 1000
+
+ config IWL6000_FW
+ bool "Intel 6000 Firmware"
+ default y
+ help
+ Download and install firmware for:
+ Intel Centrino Ultimate-N 6300 and Advanced-N 6200
+
+ config IWL6050_FW
+ bool "Intel 6050 Firmware"
+ default y
+ help
+ Download and install firmware for:
+ Intel Centrino Advanced-N + WiMAX 6250 and Wireless-N + WiMAX 6150
+
+ config IWL6005_FW
+ bool "Intel 6005 Firmware"
+ default y
+ help
+ Download and install firmware for:
+ Intel Centrino Advanced-N 6205
+
+ config IWL6030_FW
+ bool "Intel 6030 Firmware"
+ default y
+ help
+ Download and install firmware for:
+ Intel Centrino Advanced-N 6230, Wireless-N 1030, Wireless-N 130 and Advanced-N 6235
+
+ config IWL100_FW
+ bool "Intel 100 Firmware"
+ default y
+ help
+ Download and install firmware for:
+ Intel Centrino Wireless-N 100
+
+ config IWL2000_FW
+ bool "Intel 2000 Firmware"
+ default y
+ help
+ Download and install firmware for:
+ Intel Centrino Wireless-N 2200
+
+ config IWL2030_FW
+ bool "Intel 2030 Firmware"
+ default y
+ help
+ Download and install firmware for:
+ Intel Centrino Wireless-N 2230
+
+ config IWL105_FW
+ bool "Intel 105 Firmware"
+ default y
+ help
+ Download and install firmware for:
+ Intel Centrino Wireless-N 105
+
+ config IWL135_FW
+ bool "Intel 135 Firmware"
+ default y
+ help
+ Download and install firmware for:
+ Intel Centrino Wireless-N 135
+ endif
+endef
+
+define KernelPackage/iwl-legacy
+ $(call KernelPackage/mac80211/Default)
+ DEPENDS:= +kmod-mac80211 @PCI_SUPPORT
+ TITLE:=Intel legacy Wireless support
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/iwlegacy/iwlegacy.ko
+ AUTOLOAD:=$(call AutoLoad,60,iwlegacy)
+endef
+
+define KernelPackage/iwl-legacy/description
+ iwl-legacy kernel module for legacy Intel wireless support
+endef
+
+define KernelPackage/iwl3945
+ $(call KernelPackage/mac80211/Default)
+ DEPENDS:= +kmod-mac80211 +kmod-iwl-legacy
+ TITLE:=Intel iwl3945 Wireless support
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/iwlegacy/iwl3945.ko
+ AUTOLOAD:=$(call AutoLoad,61,iwl3945)
+endef
+
+define KernelPackage/iwl3945/description
+ iwl3945 kernel module for Intel 3945 support
+endef
+
+define KernelPackage/iwl4965
+ $(call KernelPackage/mac80211/Default)
+ DEPENDS:= +kmod-mac80211 +kmod-iwl-legacy +@DRIVER_11N_SUPPORT
+ TITLE:=Intel iwl4965 Wireless support
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/iwlegacy/iwl4965.ko
+ AUTOLOAD:=$(call AutoLoad,61,iwl4965)
+endef
+
+define KernelPackage/iwl4965/description
+ iwl4965 kernel module for Intel 4965 support
+endef
+
+
+define KernelPackage/mwl8k
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=Driver for Marvell TOPDOG 802.11 Wireless cards
+ URL:=http://wireless.kernel.org/en/users/Drivers/mwl8k
+ DEPENDS+= @PCI_SUPPORT +kmod-mac80211 +@DRIVER_11N_SUPPORT
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/mwl8k.ko
+ AUTOLOAD:=$(call AutoLoad,27,mwl8k)
+endef
+
+define KernelPackage/mwl8k/description
+ Kernel modules for Marvell TOPDOG 802.11 Wireless cards
+endef
+
+
+define KernelPackage/wl12xx
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=Driver for TI WL12xx
+ URL:=http://wireless.kernel.org/en/users/Drivers/wl12xx
+ DEPENDS+= @TARGET_omap4 +kmod-mac80211
+ FILES:= \
+ $(PKG_BUILD_DIR)/drivers/net/wireless/ti/wl12xx/wl12xx.ko \
+ $(PKG_BUILD_DIR)/drivers/net/wireless/ti/wlcore/wlcore.ko \
+ $(PKG_BUILD_DIR)/drivers/net/wireless/ti/wlcore/wlcore_sdio.ko
+ AUTOLOAD:=$(call AutoLoad,61,wlcore wlcore_sdio wl12xx)
+endef
+
+define KernelPackage/wl12xx/description
+ Kernel modules for TI WL12xx
+endef
+
+#Broadcom firmware
+ifneq ($(CONFIG_B43_FW_5_10),)
+ PKG_B43_FWV4_NAME:=broadcom-wl
+ PKG_B43_FWV4_VERSION:=5.10.56.27.3
+ PKG_B43_FWV4_OBJECT:=$(PKG_B43_FWV4_NAME)-$(PKG_B43_FWV4_VERSION)/driver/wl_apsta/wl_prebuilt.o
+ PKG_B43_FWV4_SOURCE:=$(PKG_B43_FWV4_NAME)-$(PKG_B43_FWV4_VERSION)_mipsel.tar.bz2
+ PKG_B43_FWV4_SOURCE_URL:=http://mirror2.openwrt.org/sources/
+ PKG_B43_FWV4_MD5SUM:=3363e3a6b3d9d73c49dea870c7834eac
+else
+ifneq ($(CONFIG_B43_FW_4_178),)
+ PKG_B43_FWV4_NAME:=broadcom-wl
+ PKG_B43_FWV4_VERSION:=4.178.10.4
+ PKG_B43_FWV4_OBJECT:=$(PKG_B43_FWV4_NAME)-$(PKG_B43_FWV4_VERSION)/linux/wl_apsta.o
+ PKG_B43_FWV4_SOURCE:=$(PKG_B43_FWV4_NAME)-$(PKG_B43_FWV4_VERSION).tar.bz2
+ PKG_B43_FWV4_SOURCE_URL:=http://mirror2.openwrt.org/sources/
+ PKG_B43_FWV4_MD5SUM:=14477e8cbbb91b11896affac9b219fdb
+else
+ifneq ($(CONFIG_B43_FW_5_100_138),)
+ PKG_B43_FWV4_NAME:=broadcom-wl
+ PKG_B43_FWV4_VERSION:=5.100.138
+ PKG_B43_FWV4_OBJECT:=$(PKG_B43_FWV4_NAME)-$(PKG_B43_FWV4_VERSION)/linux/wl_apsta.o
+ PKG_B43_FWV4_SOURCE:=$(PKG_B43_FWV4_NAME)-$(PKG_B43_FWV4_VERSION).tar.bz2
+ PKG_B43_FWV4_SOURCE_URL:=http://www.lwfinger.com/b43-firmware/
+ PKG_B43_FWV4_MD5SUM:=f4e357b09eaf5d8b1f1920cf3493a555
+else
+ PKG_B43_FWV4_NAME:=broadcom-wl
+ PKG_B43_FWV4_VERSION:=4.150.10.5
+ PKG_B43_FWV4_OBJECT:=$(PKG_B43_FWV4_NAME)-$(PKG_B43_FWV4_VERSION)/driver/wl_apsta_mimo.o
+ PKG_B43_FWV4_SOURCE:=$(PKG_B43_FWV4_NAME)-$(PKG_B43_FWV4_VERSION).tar.bz2
+ PKG_B43_FWV4_SOURCE_URL:=http://mirror2.openwrt.org/sources/
+ PKG_B43_FWV4_MD5SUM:=0c6ba9687114c6b598e8019e262d9a60
+endif
+endif
+endif
+ifneq ($(CONFIG_B43_OPENFIRMWARE),)
+ PKG_B43_FWV4_NAME:=broadcom-wl
+ PKG_B43_FWV4_VERSION:=5.2
+ PKG_B43_FWV4_OBJECT:=openfwwf-$(PKG_B43_FWV4_VERSION)
+ PKG_B43_FWV4_SOURCE:=openfwwf-$(PKG_B43_FWV4_VERSION).tar.gz
+ PKG_B43_FWV4_SOURCE_URL:=http://www.ing.unibs.it/openfwwf/firmware/
+ PKG_B43_FWV4_MD5SUM:=e045a135453274e439ae183f8498b0fa
+endif
+
+
+PKG_B43_FWV3_NAME:=wl_apsta
+PKG_B43_FWV3_VERSION:=3.130.20.0
+PKG_B43_FWV3_SOURCE:=$(PKG_B43_FWV3_NAME)-$(PKG_B43_FWV3_VERSION).o
+PKG_B43_FWV3_SOURCE_URL:=http://downloads.openwrt.org/sources/
+PKG_B43_FWV3_MD5SUM:=e08665c5c5b66beb9c3b2dd54aa80cb3
+
+define Download/b43
+ FILE:=$(PKG_B43_FWV4_SOURCE)
+ URL:=$(PKG_B43_FWV4_SOURCE_URL)
+ MD5SUM:=$(PKG_B43_FWV4_MD5SUM)
+endef
+$(eval $(call Download,b43))
+
+define Download/b43legacy
+ FILE:=$(PKG_B43_FWV3_SOURCE)
+ URL:=$(PKG_B43_FWV3_SOURCE_URL)
+ MD5SUM:=$(PKG_B43_FWV3_MD5SUM)
+endef
+$(eval $(call Download,b43legacy))
+
+
+define KernelPackage/b43
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=Broadcom 43xx wireless support
+ URL:=http://linuxwireless.org/en/users/Drivers/b43
+ KCONFIG:= \
+ CONFIG_HW_RANDOM=y
+ DEPENDS+= +kmod-mac80211 +!TARGET_brcm47xx:kmod-bcma +!(TARGET_brcm47xx||TARGET_brcm63xx):kmod-ssb
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/b43/b43.ko
+ AUTOLOAD:=$(call AutoLoad,30,b43)
+ MENU:=1
+endef
+
+define KernelPackage/b43/config
+ if PACKAGE_kmod-b43
+
+ choice
+ prompt "b43 firmware version"
+ default B43_FW_5_100_138
+ help
+ This option allows you to select the version of the b43 firmware.
+
+ config B43_FW_4_150
+ bool "Firmware 410.2160 from driver 4.150.10.5 (old stable)"
+ help
+ Stable firmware for BCM43xx devices.
+
+ If unsure, select this.
+
+ config B43_FW_4_178
+ bool "Firmware 478.104 from driver 4.178.10.4"
+ help
+ Experimental firmware for BCM43xx devices.
+
+ This firmware is not tested as much as the "stable" firmware.
+
+ If unsure, select the "stable" firmware.
+
+ config B43_FW_5_10
+ bool "Firmware 508.1084 from driver 5.10.56.27"
+ help
+ Newer experimental firmware for BCM43xx devices.
+
+ This firmware is mostly untested. It is needed for some N-PHY devices.
+
+ If unsure, select the "stable" firmware.
+
+ config B43_FW_5_100_138
+ bool "Firmware 666.2 from driver 5.100.138 (stable)"
+ help
+ Newer experimental firmware for BCM43xx devices.
+
+ This firmware is mostly untested. It is needed for some N-PHY devices.
+
+ If unsure, select the "stable" firmware.
+
+ config B43_OPENFIRMWARE
+ bool "Open FirmWare for WiFi networks"
+ help
+ Opensource firmware for BCM43xx devices.
+
+ Do _not_ select this, unless you know what you are doing.
+ The Opensource firmware is not suitable for embedded devices, yet.
+ It does not support QoS, which is bad for AccessPoints.
+ It does not support hardware crypto acceleration, which is a showstopper
+ for embedded devices with low CPU resources.
+
+ If unsure, select the "stable" firmware.
+
+ endchoice
+
+ config B43_FW_SQUASH
+ bool "Remove unnecessary firmware files"
+ depends on !B43_OPENFIRMWARE
+ default y
+ help
+ This options allows you to remove unnecessary b43 firmware files
+ from the final rootfs image. This can reduce the rootfs size by
+ up to 200k.
+
+ If unsure, say Y.
+
+ config B43_FW_SQUASH_COREREVS
+ string "Core revisions to include"
+ depends on B43_FW_SQUASH
+ default "5,6,7,8,9,10,11,13,15,16,29"
+ help
+ This is a comma seperated list of core revision numbers.
+
+ Example (keep files for rev5 only):
+ 5
+
+ Example (keep files for rev5 and rev11):
+ 5,11
+
+ config B43_FW_SQUASH_PHYTYPES
+ string "PHY types to include"
+ depends on B43_FW_SQUASH
+ default "G,LP,N,HT"
+ help
+ This is a comma seperated list of PHY types:
+ A => A-PHY
+ AG => Dual A-PHY G-PHY
+ G => G-PHY
+ LP => LP-PHY
+ N => N-PHY
+ HT => HT-PHY
+ LCN => LCN-PHY
+
+ Example (keep files for G-PHY only):
+ G
+
+ Example (keep files for G-PHY and N-PHY):
+ G,N
+
+ config PACKAGE_B43_DEBUG
+ bool "Enable debug output and debugfs for b43"
+ default n
+ help
+ Enable additional debug output and runtime sanity checks for b43
+ and enables the debugfs interface.
+
+ If unsure, say N.
+
+ config PACKAGE_B43_PIO
+ bool "Enable support for PIO transfer mode"
+ default n
+ help
+ Enable support for using PIO instead of DMA. Unless you have DMA
+ transfer problems you don't need this.
+
+ If unsure, say N.
+
+ config PACKAGE_B43_PHY_N
+ bool "Enable support for N-PHYs"
+ default y
+ help
+ Enable support for N-PHY. This includes support for the following devices:
+ PCI: BCM4321, BCM4322, BCM43222, BCM43224, BCM43225
+ SoC: BCM4716, BCM4717, BCM4718
+
+ Currently only 11g speed is available.
+
+ If unsure, say Y.
+
+ config PACKAGE_B43_PHY_HT
+ bool "Enable support for HT-PHYs"
+ default y
+ help
+ Enable support for HT-PHY. This includes support for the following devices:
+ PCI: BCM4331
+
+ Currently only 11g speed is available.
+
+ If unsure, say Y.
+
+ config PACKAGE_B43_PHY_LCN
+ bool "Enable support for LCN-PHYs"
+ depends on BROKEN
+ default n
+ help
+ Currently broken.
+
+ If unsure, say N.
+
+ endif
+endef
+
+define KernelPackage/b43/description
+Kernel module for Broadcom 43xx wireless support (mac80211 stack) new
+endef
+
+define KernelPackage/b43legacy
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=Broadcom 43xx-legacy wireless support
+ URL:=http://linuxwireless.org/en/users/Drivers/b43
+ KCONFIG:= \
+ CONFIG_HW_RANDOM=y
+ DEPENDS+= +kmod-mac80211 +!(TARGET_brcm47xx||TARGET_brcm63xx):kmod-ssb
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/b43legacy/b43legacy.ko
+ AUTOLOAD:=$(call AutoLoad,30,b43legacy)
+ MENU:=1
+endef
+
+define KernelPackage/b43legacy/config
+ if PACKAGE_kmod-b43legacy
+
+ config B43LEGACY_FW_SQUASH
+ bool "Remove unnecessary firmware files"
+ default y
+ help
+ This options allows you to remove unnecessary b43legacy firmware files
+ from the final rootfs image. This can reduce the rootfs size by
+ up to 50k.
+
+ If unsure, say Y.
+
+ config B43LEGACY_FW_SQUASH_COREREVS
+ string "Core revisions to include"
+ depends on B43LEGACY_FW_SQUASH
+ default "1,2,3,4"
+ help
+ This is a comma seperated list of core revision numbers.
+
+ Example (keep files for rev4 only):
+ 4
+
+ Example (keep files for rev2 and rev4):
+ 2,4
+
+ endif
+endef
+
+define KernelPackage/b43legacy/description
+Kernel module for Broadcom 43xx-legacy wireless support (mac80211 stack) new
+endef
+
+
+define KernelPackage/brcmutil
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=Broadcom IEEE802.11n common driver parts
+ URL:=http://linuxwireless.org/en/users/Drivers/brcm80211
+ DEPENDS+=@PCI_SUPPORT||USB_SUPPORT
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/brcm80211/brcmutil/brcmutil.ko
+ AUTOLOAD:=$(call AutoLoad,30,brcmutil)
+ MENU:=1
+endef
+
+define KernelPackage/brcmutil/description
+ This module contains some common parts needed by Broadcom Wireless drivers brcmsmac and brcmfmac.
+endef
+
+define KernelPackage/brcmutil/config
+ if PACKAGE_kmod-brcmutil
+
+ config PACKAGE_BRCM80211_DEBUG
+ bool "Broadcom wireless driver debugging"
+ help
+ Say Y, if you want to debug brcmsmac and brcmfmac wireless driver.
+
+ endif
+endef
+
+PKG_BRCMSMAC_FW_NAME:=broadcom-wl
+PKG_BRCMSMAC_FW_VERSION:=5.100.138
+PKG_BRCMSMAC_FW_OBJECT:=$(PKG_BRCMSMAC_FW_NAME)-$(PKG_BRCMSMAC_FW_VERSION)/linux/wl_apsta.o
+PKG_BRCMSMAC_FW_SOURCE:=$(PKG_BRCMSMAC_FW_NAME)-$(PKG_BRCMSMAC_FW_VERSION).tar.bz2
+PKG_BRCMSMAC_FW_SOURCE_URL:=http://www.lwfinger.com/b43-firmware/
+PKG_BRCMSMAC_FW_MD5SUM:=f4e357b09eaf5d8b1f1920cf3493a555
+
+define KernelPackage/brcmsmac
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=Broadcom IEEE802.11n PCIe SoftMAC WLAN driver
+ URL:=http://linuxwireless.org/en/users/Drivers/brcm80211
+ DEPENDS+= +kmod-mac80211 +@DRIVER_11N_SUPPORT +!TARGET_brcm47xx:kmod-bcma +kmod-lib-cordic +kmod-lib-crc8 +kmod-brcmutil
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/brcm80211/brcmsmac/brcmsmac.ko
+ AUTOLOAD:=$(call AutoLoad,31,brcmsmac)
+ MENU:=1
+endef
+
+define KernelPackage/brcmsmac/description
+ Kernel module for Broadcom IEEE802.11n PCIe Wireless cards
+endef
+
+define KernelPackage/brcmsmac/config
+ if PACKAGE_kmod-brcmsmac
+
+ config BRCMSMAC_USE_FW_FROM_WL
+ bool "Use firmware extracted from broadcom proprietary driver"
+ default y
+ help
+ Instead of using the official brcmsmac firmware a firmware
+ version 666.2 extracted from the proprietary Broadcom driver
+ is used. This is needed to get core rev 17 used in bcm4716
+ to work.
+
+ If unsure, say Y.
+
+ endif
+endef
+
+
+define KernelPackage/brcmfmac
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=Broadcom IEEE802.11n USB FullMAC WLAN driver
+ URL:=http://linuxwireless.org/en/users/Drivers/brcm80211
+ DEPENDS+= @USB_SUPPORT +kmod-usb-core +kmod-cfg80211 +@DRIVER_11N_SUPPORT +kmod-brcmutil
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/brcm80211/brcmfmac/brcmfmac.ko
+ AUTOLOAD:=$(call AutoLoad,60,brcmfmac)
+endef
+
+define KernelPackage/brcmfmac/description
+ Kernel module for Broadcom IEEE802.11n USB Wireless cards
+endef
+
+BUILDFLAGS:= \
+ -I$(PKG_BUILD_DIR)/include \
+ -DCONFIG_CFG80211_INTERNAL_REGDB=y \
+ $(foreach opt,$(CONFOPTS),-DCONFIG_$(opt)) \
+ $(if $(CONFIG_PCI),-DCONFIG_B43_PCI_AUTOSELECT -DCONFIG_B43_PCICORE_AUTOSELECT) \
+ $(if $(CONFIG_LEDS_TRIGGERS), -DCONFIG_MAC80211_LEDS -DCONFIG_LEDS_TRIGGERS -DCONFIG_B43_LEDS -DCONFIG_B43LEGACY_LEDS) \
+ -DCONFIG_B43_HWRNG -DCONFIG_B43LEGACY_HWRNG \
+ $(if $(CONFIG_PCI),-DCONFIG_ATH9K_PCI) \
+ $(if $(CONFIG_TARGET_ar71xx),-DCONFIG_ATH9K_AHB) \
+ $(if $(CONFIG_PACKAGE_MAC80211_DEBUGFS), -DCONFIG_CFG80211_DEBUGFS -DCONFIG_MAC80211_DEBUGFS -DCONFIG_ATH9K_DEBUGFS -DCONFIG_CARL9170_DEBUGFS -DCONFIG_ATH9K_HTC_DEBUGFS -DCONFIG_ATH5K_DEBUG) \
+ $(if $(CONFIG_PACKAGE_MAC80211_MESH),-DCONFIG_MAC80211_MESH) \
+ $(if $(CONFIG_PACKAGE_ATH_DEBUG),-DCONFIG_ATH_DEBUG -DCONFIG_ATH9K_PKTLOG) \
+ -D__CONFIG_MAC80211_RC_DEFAULT=minstrel \
+ -DCONFIG_MAC80211_RC_MINSTREL_HT \
+ $(if $(CONFIG_ATH_USER_REGD),-DATH_USER_REGD=1) \
+ $(if $(CONFIG_PACKAGE_B43_DEBUG),-DCONFIG_B43_DEBUG) \
+ $(if $(CONFIG_PACKAGE_B43_PIO),-DCONFIG_B43_PIO) \
+ $(if $(CONFIG_PACKAGE_B43_PIO),-DCONFIG_B43_BCMA_PIO) \
+ $(if $(CONFIG_PACKAGE_B43_PHY_N),-DCONFIG_B43_PHY_N) \
+ $(if $(CONFIG_PACKAGE_B43_PHY_HT),-DCONFIG_B43_PHY_HT) \
+ $(if $(CONFIG_PACKAGE_B43_PHY_LCN),-DCONFIG_B43_PHY_LCN) \
+ -DCONFIG_B43_BCMA -DCONFIG_B43_BCMA_EXTRA \
+ -DCONFIG_B43_SSB \
+ $(if $(CONFIG_PACKAGE_RT2X00_LIB_DEBUGFS),-DCONFIG_RT2X00_LIB_DEBUGFS) \
+ $(if $(CONFIG_PACKAGE_RT2X00_DEBUG),-DCONFIG_RT2X00_DEBUG) \
+ $(if $(NEED_RT2X00_LIB_HT),-DCONFIG_RT2X00_LIB_HT) \
+ $(if $(NEED_RT2X00_LIB_CRYPTO),-DCONFIG_RT2X00_LIB_CRYPTO) \
+ $(if $(NEED_RT2X00_LIB_FIRMWARE),-DCONFIG_RT2X00_LIB_FIRMWARE) \
+ $(if $(NEED_RT2X00_LIB_EEPROM),-DCONFIG_RT2X00_LIB_EEPROM) \
+ $(if $(NEED_RT2X00_LIB_LEDS),-DCONFIG_RT2X00_LIB_LEDS) \
+ $(if $(CONFIG_PACKAGE_kmod-rt2x00-pci),-DCONFIG_RT2X00_LIB_PCI) \
+ $(if $(CONFIG_PACKAGE_kmod-rt2x00-usb),-DCONFIG_RT2X00_LIB_USB) \
+ $(if $(CONFIG_PACKAGE_kmod-rt2x00-usb),-DCONFIG_RT2800USB_RT53XX) \
+ $(if $(CONFIG_PACKAGE_kmod-rt2x00-soc),-DCONFIG_RT2X00_LIB_SOC) \
+ $(if $(CONFIG_TARGET_atheros),-DCONFIG_ATH5K_AHB,-DCONFIG_ATH5K_PCI) \
+ $(if $(CONFIG_PACKAGE_kmod-iwl3945),-DCONFIG_IWL3945) \
+ $(if $(CONFIG_PACKAGE_kmod-iwl4965),-DCONFIG_COMPAT_IWL4965) \
+ $(if $(CONFIG_PACKAGE_kmod-wl12xx),-DCONFIG_WL12XX -DCONFIG_COMPAT_WL12XX_SDIO) \
+ $(if $(CONFIG_PACKAGE_BRCM80211_DEBUG),-DCONFIG_BRCMDBG) \
+ $(if $(CONFIG_PACKAGE_kmod-brcmfmac),-DCONFIG_BRCMFMAC_USB)
+
+MAKE_OPTS:= \
+ CROSS_COMPILE="$(KERNEL_CROSS)" \
+ ARCH="$(LINUX_KARCH)" \
+ EXTRA_CFLAGS="$(BUILDFLAGS)" \
+ $(foreach opt,$(CONFOPTS),CONFIG_$(opt)=m) \
+ CONFIG_CFG80211_INTERNAL_REGDB=y \
+ CONFIG_CFG80211=$(if $(CONFIG_PACKAGE_kmod-cfg80211),m) \
+ CONFIG_MAC80211=$(if $(CONFIG_PACKAGE_kmod-mac80211),m) \
+ CONFIG_MAC80211_RC_MINSTREL=y \
+ CONFIG_MAC80211_MESH=$(CONFIG_PACKAGE_MAC80211_MESH) \
+ CONFIG_MAC80211_LEDS=$(CONFIG_LEDS_TRIGGERS) \
+ CONFIG_CFG80211_DEBUGFS=$(if $(CONFIG_PACKAGE_MAC80211_DEBUGFS),y) \
+ CONFIG_MAC80211_DEBUGFS=$(if $(CONFIG_PACKAGE_MAC80211_DEBUGFS),y) \
+ CONFIG_B43_PCMCIA=n CONFIG_B43_PIO=n \
+ CONFIG_B43_PCI_AUTOSELECT=$(if $(CONFIG_PCI),y) \
+ CONFIG_B43_PCICORE_AUTOSELECT=$(if $(CONFIG_PCI),y) \
+ CONFIG_B43LEGACY_LEDS=$(CONFIG_LEDS_TRIGGERS) \
+ CONFIG_B43_LEDS=$(CONFIG_LEDS_TRIGGERS) \
+ CONFIG_B43_HWRNG=$(if $(CONFIG_HW_RANDOM),y) \
+ CONFIG_B43LEGACY_HWRNG=$(if $(CONFIG_HW_RANDOM),y) \
+ CONFIG_B43=$(if $(CONFIG_PACKAGE_kmod-b43),m) \
+ CONFIG_B43LEGACY=$(if $(CONFIG_PACKAGE_kmod-b43legacy),m) \
+ CONFIG_B43_DEBUG=$(if $(CONFIG_PACKAGE_B43_DEBUG),y) \
+ CONFIG_B43_PIO=$(if $(CONFIG_PACKAGE_B43_PIO),y) \
+ CONFIG_B43_BCMA_PIO=$(if $(CONFIG_PACKAGE_B43_PIO),y) \
+ CONFIG_B43_PHY_N=$(if $(CONFIG_PACKAGE_B43_PHY_N),y) \
+ CONFIG_B43_PHY_HT=$(if $(CONFIG_PACKAGE_B43_PHY_HT),y) \
+ CONFIG_B43_PHY_LCN=$(if $(CONFIG_PACKAGE_B43_PHY_LCN),y) \
+ CONFIG_B43_BCMA=y \
+ CONFIG_B43_SSB=y \
+ CONFIG_ATH_CARDS=$(if $(CONFIG_PACKAGE_kmod-ath),m) \
+ CONFIG_ATH_COMMON=$(if $(CONFIG_PACKAGE_kmod-ath),m) \
+ CONFIG_ATH_DEBUG=$(if $(CONFIG_PACKAGE_ATH_DEBUG),y) \
+ CONFIG_ATH9K_PKTLOG=$(if $(CONFIG_PACKAGE_ATH_DEBUG),y) \
+ CONFIG_ATH5K=$(if $(CONFIG_PACKAGE_kmod-ath5k),m) \
+ CONFIG_ATH5K_PCI=$(if $(CONFIG_TARGET_atheros),,y) \
+ CONFIG_ATH5K_AHB=$(if $(CONFIG_TARGET_atheros),y) \
+ CONFIG_ATH5K_DEBUG=$(if $(CONFIG_PACKAGE_MAC80211_DEBUGFS),y) \
+ CONFIG_ATH9K=$(if $(CONFIG_PACKAGE_kmod-ath9k),m) \
+ CONFIG_ATH9K_PCI=$(CONFIG_PCI) \
+ CONFIG_ATH9K_AHB=$(if $(CONFIG_TARGET_ar71xx),y) \
+ CONFIG_ATH9K_HTC=$(if $(CONFIG_PACKAGE_kmod-ath9k-htc),m) \
+ CONFIG_ATH9K_HTC_DEBUGFS=$(if $(CONFIG_PACKAGE_MAC80211_DEBUGFS),y) \
+ CONFIG_ATH9K_HW=$(if $(CONFIG_PACKAGE_kmod-ath9k-common),m) \
+ CONFIG_ATH9K_COMMON=$(if $(CONFIG_PACKAGE_kmod-ath9k-common),m) \
+ CONFIG_ATH9K_DEBUGFS=$(if $(CONFIG_PACKAGE_MAC80211_DEBUGFS),y) \
+ CONFIG_AR5523= \
+ CONFIG_WIL6210= \
+ CONFIG_CARL9170=$(if $(CONFIG_PACKAGE_kmod-carl9170),m) \
+ CONFIG_CARL9170_DEBUGFS=$(if $(CONFIG_PACKAGE_MAC80211_DEBUGFS),y) \
+ CONFIG_COMPAT_ZD1211RW=$(if $(CONFIG_PACKAGE_kmod-zd1211rw),m) \
+ CONFIG_P54_COMMON=$(if $(CONFIG_PACKAGE_kmod-p54-common),m) \
+ CONFIG_P54_PCI=$(if $(CONFIG_PACKAGE_kmod-p54-pci),m) \
+ CONFIG_P54_USB=$(if $(CONFIG_PACKAGE_kmod-p54-usb),m) \
+ CONFIG_P54_SPI=$(if $(CONFIG_PACKAGE_kmod-p54-spi),m) \
+ CONFIG_P54_SPI_DEFAULT_EEPROM=n \
+ CONFIG_RT2X00=$(if $(CONFIG_PACKAGE_kmod-rt2x00-lib),m) \
+ CONFIG_RT2X00_LIB=$(if $(CONFIG_PACKAGE_kmod-rt2x00-lib),m) \
+ CONFIG_RT2X00_LIB_PCI=$(if $(CONFIG_PACKAGE_kmod-rt2x00-pci),m) \
+ CONFIG_RT2X00_LIB_USB=$(if $(CONFIG_PACKAGE_kmod-rt2x00-usb),m) \
+ CONFIG_RT2X00_LIB_SOC=$(if $(CONFIG_PACKAGE_kmod-rt2x00-soc),m) \
+ CONFIG_RT2X00_LIB_DEBUGFS=$(CONFIG_PACKAGE_RT2X00_LIB_DEBUGFS) \
+ CONFIG_RT2X00_LIB_CRYPTO=$(NEED_RT2X00_LIB_CRYPTO) \
+ CONFIG_RT2X00_LIB_FIRMWARE=$(NEED_RT2X00_LIB_FIRMWARE) \
+ CONFIG_RT2X00_LIB_EEPROM=$(NEED_RT2X00_LIB_EEPROM) \
+ CONFIG_RT2X00_LIB_HT=$(NEED_RT2X00_LIB_HT) \
+ CONFIG_RT2X00_LIB_LEDS=$(NEED_RT2X00_LIB_LEDS) \
+ CONFIG_RT2400PCI=$(if $(CONFIG_PACKAGE_kmod-rt2400-pci),m) \
+ CONFIG_RT2500PCI=$(if $(CONFIG_PACKAGE_kmod-rt2500-pci),m) \
+ CONFIG_RT2500USB=$(if $(CONFIG_PACKAGE_kmod-rt2500-usb),m) \
+ CONFIG_RT61PCI=$(if $(CONFIG_PACKAGE_kmod-rt61-pci),m) \
+ CONFIG_RT73USB=$(if $(CONFIG_PACKAGE_kmod-rt73-usb),m) \
+ CONFIG_RT2800_LIB=$(if $(CONFIG_PACKAGE_kmod-rt2800-lib),m) \
+ CONFIG_RT2800PCI=$(if $(CONFIG_PACKAGE_kmod-rt2800-pci),m) \
+ CONFIG_RT2800USB=$(if $(CONFIG_PACKAGE_kmod-rt2800-usb),m) \
+ CONFIG_RTL8180=$(if $(CONFIG_PACKAGE_kmod-rtl8180),m) \
+ CONFIG_RTL8187=$(if $(CONFIG_PACKAGE_kmod-rtl8187),m) \
+ CONFIG_RTL8192CE= \
+ CONFIG_RTLWIFI= \
+ CONFIG_MAC80211_HWSIM=$(if $(CONFIG_PACKAGE_kmod-mac80211-hwsim),m) \
+ CONFIG_PCMCIA= \
+ CONFIG_LIBIPW=$(if $(CONFIG_PACKAGE_kmod-net-libipw),m) \
+ CONFIG_LIBERTAS=$(if $(CONFIG_PACKAGE_kmod-libertas-sd)$(CONFIG_PACKAGE_kmod-libertas-usb),m) \
+ CONFIG_LIBERTAS_CS= \
+ CONFIG_LIBERTAS_SPI= \
+ CONFIG_COMPAT_LIBERTAS_SDIO=$(if $(CONFIG_PACKAGE_kmod-libertas-sd),m) \
+ CONFIG_LIBERTAS_THINFIRM= \
+ CONFIG_LIBERTAS_USB=$(if $(CONFIG_PACKAGE_kmod-libertas-usb),m) \
+ CONFIG_IPW2100=$(if $(CONFIG_PACKAGE_kmod-net-ipw2100),m) \
+ CONFIG_IPW2200=$(if $(CONFIG_PACKAGE_kmod-net-ipw2200),m) \
+ CONFIG_NL80211=y \
+ CONFIG_LIB80211=$(if $(CONFIG_PACKAGE_kmod-lib80211),m) \
+ CONFIG_LIB80211_CRYPT_WEP=$(if $(CONFIG_PACKAGE_kmod-lib80211),m) \
+ CONFIG_LIB80211_CRYPT_CCMP=$(if $(CONFIG_PACKAGE_kmod-lib80211),m) \
+ CONFIG_LIB80211_CRYPT_TKIP=$(if $(CONFIG_PACKAGE_kmod-lib80211),m) \
+ CONFIG_IWLWIFI=$(if $(CONFIG_PACKAGE_kmod-iwlagn),m) \
+ CONFIG_IWLEGACY=$(if $(CONFIG_PACKAGE_kmod-iwl-legacy),m) \
+ CONFIG_COMPAT_IWL4965=$(if $(CONFIG_PACKAGE_kmod-iwl4965),m) \
+ CONFIG_IWL3945=$(if $(CONFIG_PACKAGE_kmod-iwl3945),m) \
+ CONFIG_MWL8K=$(if $(CONFIG_PACKAGE_kmod-mwl8k),m) \
+ CONFIG_ATMEL= \
+ CONFIG_PCMCIA_ATMEL= \
+ CONFIG_ADM8211=$(if $(CONFIG_PACKAGE_kmod-adm8211),m) \
+ CONFIG_USB_NET_RNDIS_HOST= \
+ CONFIG_USB_NET_RNDIS_WLAN= \
+ CONFIG_USB_NET_CDCETHER= \
+ CONFIG_USB_USBNET= \
+ CONFIG_AT76C50X_USB= \
+ CONFIG_WL_TI=$(if $(CONFIG_PACKAGE_kmod-wl12xx),m) \
+ CONFIG_WLCORE=$(if $(CONFIG_PACKAGE_kmod-wl12xx),m) \
+ CONFIG_WL12XX=$(if $(CONFIG_PACKAGE_kmod-wl12xx),m) \
+ CONFIG_WLCORE_SDIO=$(if $(CONFIG_PACKAGE_kmod-wl12xx),m) \
+ CONFIG_EEPROM_93CX6= \
+ CONFIG_HERMES=$(if $(CONFIG_PACKAGE_kmod-net-hermes),m) \
+ CONFIG_HERMES_CACHE_FW_ON_INIT= \
+ CONFIG_PCI_HERMES=$(if $(CONFIG_PACKAGE_kmod-net-hermes-pci),m) \
+ CONFIG_PLX_HERMES=$(if $(CONFIG_PACKAGE_kmod-net-hermes-plx),m) \
+ CONFIG_PCMCIA_HERMES=$(if $(CONFIG_PACKAGE_kmod-net-hermes-pcmcia),m) \
+ CONFIG_HERMES_PRISM= \
+ CONFIG_APPLE_AIRPORT= \
+ CONFIG_TMD_HERMES= \
+ CONFIG_NORTEL_HERMES= \
+ CONFIG_PCMCIA_SPECTRUM= \
+ CONFIG_ORINOCO_USB= \
+ CONFIG_IWM= \
+ CONFIG_MWIFIEX= \
+ CONFIG_ATH6KL= \
+ CONFIG_MAC80211_RC_MINSTREL_HT=y \
+ MADWIFI= \
+ CONFIG_BRCMUTIL=$(if $(CONFIG_PACKAGE_kmod-brcmutil),m) \
+ CONFIG_BRCMSMAC=$(if $(CONFIG_PACKAGE_kmod-brcmsmac),m) \
+ CONFIG_BRCMFMAC=$(if $(CONFIG_PACKAGE_kmod-brcmfmac),m) \
+ CONFIG_BRCMFMAC_USB=$(if $(CONFIG_PACKAGE_kmod-brcmfmac),y) \
+ CONFIG_BRCMDBG=$(if $(CONFIG_PACKAGE_BRCM80211_DEBUG),y) \
+ KLIB_BUILD="$(LINUX_DIR)" \
+ MODPROBE=true \
+ KLIB=$(TARGET_MODULES_DIR) \
+ KERNEL_SUBLEVEL=$(lastword $(subst ., ,$(KERNEL_PATCHVER))) \
+ KBUILD_LDFLAGS_MODULE_PREREQ=
+
+ifeq ($(CONFIG_PACKAGE_kmod-libertas-sd)$(CONFIG_PACKAGE_kmod-libertas-usb)$(CONFIG_PACKAGE_kmod-rt2x00-lib),)
+ MAKE_OPTS += CONFIG_COMPAT_KFIFO=
+endif
+
+DISABLE_CONFIG = \
+ COMPAT_BLUETOOTH.* \
+ COMPAT_CORDIC \
+ COMPAT_CRC8 \
+ COMPAT_MDIO \
+ COMPAT_NETWORK_MODULES \
+ COMPAT_NET_USB_MODULES \
+ COMPAT_VAR_MODULES \
+ COMPAT_RFKILL \
+ COMPAT_RFKILL_.* \
+ COMPAT_STAGING \
+ \
+ B43_PCMCIA \
+ B43_SDIO \
+ BCMA.* \
+ COMPAT_ATH9K_RATE_CONTROL \
+ HID_GENERIC \
+ MAC80211_RC_PID \
+ PCMCIA \
+ RFKILL_BACKPORT.* \
+ SSB \
+ SSB_SDIOHOST \
+ \
+ ATH5K_PCI \
+ ATH9K_BTCOEX_SUPPORT \
+ B43_PHY_N \
+ B43_PHY_HT \
+ B43_BCMA.* \
+ MAC80211_MESH \
+ RT2X00_LIB_PCI \
+ RT2X00_LIB_USB \
+ COMPAT_MWIFIEX
+
+
+define Build/Prepare
+ rm -rf $(PKG_BUILD_DIR)
+ mkdir -p $(PKG_BUILD_DIR)
+ $(PKG_UNPACK)
+ $(Build/Patch)
+ $(TAR) -C $(PKG_BUILD_DIR) -xzf $(DL_DIR)/$(IPW2100_NAME)-$(IPW2100_VERSION).tgz
+ $(TAR) -C $(PKG_BUILD_DIR) -xzf $(DL_DIR)/$(IPW2200_NAME)-$(IPW2200_VERSION).tgz
+ $(TAR) -C $(PKG_BUILD_DIR) -xjf $(DL_DIR)/$(ZD1211FW_NAME)-$(ZD1211FW_VERSION).tar.bz2
+ $(TAR) -C $(PKG_BUILD_DIR) -xjf $(DL_DIR)/$(PKG_LINUX_FIRMWARE_SOURCE)
+ rm -rf \
+ $(PKG_BUILD_DIR)/include/linux/ssb \
+ $(PKG_BUILD_DIR)/include/linux/bcma \
+ $(PKG_BUILD_DIR)/include/net/bluetooth
+
+ rm -f \
+ $(PKG_BUILD_DIR)/include/linux/cordic.h \
+ $(PKG_BUILD_DIR)/include/linux/crc8.h \
+ $(PKG_BUILD_DIR)/include/linux/eeprom_93cx6.h \
+ $(PKG_BUILD_DIR)/include/linux/wl12xx.h \
+ $(PKG_BUILD_DIR)/include/linux/spi/libertas_spi.h \
+ $(PKG_BUILD_DIR)/include/net/ieee80211.h
+
+ echo 'compat-wireless-$(PKG_VERSION)-$(PKG_RELEASE)-$(REVISION)' > $(PKG_BUILD_DIR)/compat_version
+ $(CP) ./files/regdb.txt $(PKG_BUILD_DIR)/net/wireless/db.txt
+
+ sed -i $(foreach config,$(DISABLE_CONFIG),-e 's,^\([ ]*export *CONFIG_$(config)=\),# \1,') $(PKG_BUILD_DIR)/config.mk
+endef
+
+ifneq ($(CONFIG_PACKAGE_kmod-cfg80211)$(CONFIG_PACKAGE_kmod-lib80211),)
+ define Build/Compile/kmod
+ rm -rf $(PKG_BUILD_DIR)/modules
+ +$(MAKE) $(PKG_JOBS) -C "$(PKG_BUILD_DIR)" $(MAKE_OPTS) modules
+ endef
+endif
+
+define Build/Configure
+ cmp $(PKG_BUILD_DIR)/include/linux/ath9k_platform.h $(LINUX_DIR)/include/linux/ath9k_platform.h
+ cmp $(PKG_BUILD_DIR)/include/linux/ath5k_platform.h $(LINUX_DIR)/include/linux/ath5k_platform.h
+ cmp $(PKG_BUILD_DIR)/include/linux/rt2x00_platform.h $(LINUX_DIR)/include/linux/rt2x00_platform.h
+endef
+
+define Build/Compile
+ $(call Build/Compile/kmod)
+endef
+
+define Build/InstallDev
+ mkdir -p \
+ $(1)/usr/include/mac80211 \
+ $(1)/usr/include/mac80211/ath \
+ $(1)/usr/include/net/mac80211
+ $(CP) $(PKG_BUILD_DIR)/net/mac80211/*.h $(PKG_BUILD_DIR)/include/* $(1)/usr/include/mac80211/
+ $(CP) $(PKG_BUILD_DIR)/net/mac80211/rate.h $(1)/usr/include/net/mac80211/
+ $(CP) $(PKG_BUILD_DIR)/drivers/net/wireless/ath/*.h $(1)/usr/include/mac80211/ath/
+endef
+
+define KernelPackage/libertas-usb/install
+ $(INSTALL_DIR) $(1)/lib/firmware/libertas
+ $(INSTALL_DATA) \
+ $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/libertas/usb8388_v9.bin \
+ $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/libertas/usb8682.bin \
+ $(1)/lib/firmware/libertas/
+endef
+
+define KernelPackage/libertas-sd/install
+ $(INSTALL_DIR) $(1)/lib/firmware/libertas
+ $(INSTALL_DATA) \
+ $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/libertas/sd8385_helper.bin \
+ $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/libertas/sd8385.bin \
+ $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/libertas/sd8686_v9_helper.bin \
+ $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/libertas/sd8686_v9.bin \
+ $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/libertas/sd8688_helper.bin \
+ $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/libertas/sd8688.bin \
+ $(1)/lib/firmware/libertas
+endef
+
+define KernelPackage/cfg80211/install
+ $(INSTALL_DIR) $(1)/lib/wifi
+ $(INSTALL_DATA) ./files/lib/wifi/mac80211.sh $(1)/lib/wifi
+endef
+
+define KernelPackage/p54-pci/install
+ $(INSTALL_DIR) $(1)/lib/firmware
+ $(INSTALL_DATA) $(DL_DIR)/$(P54PCIFW) $(1)/lib/firmware/isl3886pci
+endef
+
+define KernelPackage/p54-usb/install
+ $(INSTALL_DIR) $(1)/lib/firmware
+ $(INSTALL_DATA) $(DL_DIR)/$(P54USBFW) $(1)/lib/firmware/isl3887usb
+endef
+
+define KernelPackage/p54-spi/install
+ $(INSTALL_DIR) $(1)/lib/firmware
+ $(INSTALL_DATA) $(DL_DIR)/$(P54SPIFW) $(1)/lib/firmware/3826.arm
+endef
+
+define KernelPackage/rt61-pci/install
+ $(INSTALL_DIR) $(1)/lib/firmware
+ $(INSTALL_DATA) \
+ $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/rt2561.bin \
+ $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/rt2561s.bin \
+ $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/rt2661.bin \
+ $(1)/lib/firmware/
+endef
+
+define KernelPackage/rt73-usb/install
+ $(INSTALL_DIR) $(1)/lib/firmware
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/rt73.bin $(1)/lib/firmware/
+endef
+
+define KernelPackage/rt2800-pci/install
+ $(INSTALL_DIR) $(1)/lib/firmware
+ $(INSTALL_DATA) \
+ $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/rt2860.bin \
+ $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/rt3290.bin \
+ $(1)/lib/firmware
+endef
+
+define KernelPackage/rt2800-usb/install
+ $(INSTALL_DIR) $(1)/lib/firmware
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/rt2870.bin $(1)/lib/firmware/
+endef
+
+define KernelPackage/wl12xx/install
+ $(INSTALL_DIR) $(1)/lib/firmware/ti-connectivity
+ $(INSTALL_DATA) \
+ $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/ti-connectivity/wl127x-fw-5-mr.bin \
+ $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/ti-connectivity/wl127x-fw-5-plt.bin \
+ $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/ti-connectivity/wl127x-fw-5-sr.bin \
+ $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/ti-connectivity/wl1271-nvs.bin \
+ $(1)/lib/firmware/ti-connectivity
+endef
+
+
+define KernelPackage/zd1211rw/install
+ $(INSTALL_DIR) $(1)/lib/firmware/zd1211
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/$(ZD1211FW_NAME)/zd1211* $(1)/lib/firmware/zd1211
+endef
+
+define KernelPackage/ath9k-htc/install
+ $(INSTALL_DIR) $(1)/lib/firmware
+ $(INSTALL_DATA) \
+ $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/htc_9271.fw \
+ $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/htc_7010.fw \
+ $(1)/lib/firmware/
+endef
+
+define KernelPackage/mwl8k/install
+ $(INSTALL_DIR) $(1)/lib/firmware/mwl8k
+ $(INSTALL_DATA) \
+ $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/mwl8k/fmimage_8366_ap-3.fw \
+ $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/mwl8k/fmimage_8366.fw \
+ $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/mwl8k/helper_8366.fw \
+ $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/mwl8k/fmimage_8687.fw \
+ $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/mwl8k/helper_8687.fw \
+ $(1)/lib/firmware/mwl8k/
+endef
+
+define KernelPackage/net-ipw2100/install
+ $(INSTALL_DIR) $(1)/lib/firmware
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/ipw2100-$(IPW2100_VERSION)*.fw $(1)/lib/firmware
+endef
+
+define KernelPackage/net-ipw2200/install
+ $(INSTALL_DIR) $(1)/lib/firmware
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/$(IPW2200_NAME)-$(IPW2200_VERSION)/ipw2200*.fw $(1)/lib/firmware
+endef
+
+define KernelPackage/iwlagn/install
+ $(INSTALL_DIR) $(1)/lib/firmware
+ifneq ($(CONFIG_IWL5000_FW),)
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/iwlwifi-5000-5.ucode $(1)/lib/firmware
+endif
+ifneq ($(CONFIG_IWL5150_FW),)
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/iwlwifi-5150-2.ucode $(1)/lib/firmware
+endif
+ifneq ($(CONFIG_IWL1000_FW),)
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/iwlwifi-1000-5.ucode $(1)/lib/firmware
+endif
+ifneq ($(CONFIG_IWL6000_FW),)
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/iwlwifi-6000-4.ucode $(1)/lib/firmware
+endif
+ifneq ($(CONFIG_IWL6050_FW),)
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/iwlwifi-6050-5.ucode $(1)/lib/firmware
+endif
+ifneq ($(CONFIG_IWL6005_FW),)
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/iwlwifi-6000g2a-6.ucode $(1)/lib/firmware
+endif
+ifneq ($(CONFIG_IWL6030_FW),)
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/iwlwifi-6000g2b-6.ucode $(1)/lib/firmware
+endif
+ifneq ($(CONFIG_IWL100_FW),)
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/iwlwifi-100-5.ucode $(1)/lib/firmware
+endif
+ifneq ($(CONFIG_IWL2000_FW),)
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/iwlwifi-2000-6.ucode $(1)/lib/firmware
+endif
+ifneq ($(CONFIG_IWL2030_FW),)
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/iwlwifi-2030-6.ucode $(1)/lib/firmware
+endif
+ifneq ($(CONFIG_IWL105_FW),)
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/iwlwifi-105-6.ucode $(1)/lib/firmware
+endif
+ifneq ($(CONFIG_IWL135_FW),)
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/iwlwifi-135-6.ucode $(1)/lib/firmware
+endif
+endef
+
+define KernelPackage/iwl3945/install
+ $(INSTALL_DIR) $(1)/lib/firmware
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/iwlwifi-3945-2.ucode $(1)/lib/firmware
+endef
+
+define KernelPackage/iwl4965/install
+ $(INSTALL_DIR) $(1)/lib/firmware
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/iwlwifi-4965-2.ucode $(1)/lib/firmware
+endef
+
+define KernelPackage/b43/install
+ rm -rf $(1)/lib/firmware/
+ifeq ($(CONFIG_B43_OPENFIRMWARE),y)
+ tar xzf "$(DL_DIR)/$(PKG_B43_FWV4_SOURCE)" -C "$(PKG_BUILD_DIR)"
+else
+ tar xjf "$(DL_DIR)/$(PKG_B43_FWV4_SOURCE)" -C "$(PKG_BUILD_DIR)"
+endif
+ $(INSTALL_DIR) $(1)/lib/firmware/
+ifeq ($(CONFIG_B43_OPENFIRMWARE),y)
+ $(MAKE) -C "$(PKG_BUILD_DIR)/$(PKG_B43_FWV4_OBJECT)/"
+ $(INSTALL_DIR) $(1)/lib/firmware/b43-open/
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/$(PKG_B43_FWV4_OBJECT)/ucode5.fw $(1)/lib/firmware/b43-open/ucode5.fw
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/$(PKG_B43_FWV4_OBJECT)/b0g0bsinitvals5.fw $(1)/lib/firmware/b43-open/b0g0bsinitvals5.fw
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/$(PKG_B43_FWV4_OBJECT)/b0g0initvals5.fw $(1)/lib/firmware/b43-open/b0g0initvals5.fw
+else
+ b43-fwcutter -w $(1)/lib/firmware/ $(PKG_BUILD_DIR)/$(PKG_B43_FWV4_OBJECT)
+endif
+ifneq ($(CONFIG_B43_FW_SQUASH),)
+ b43-fwsquash.py "$(CONFIG_B43_FW_SQUASH_PHYTYPES)" "$(CONFIG_B43_FW_SQUASH_COREREVS)" "$(1)/lib/firmware/b43"
+endif
+endef
+
+define KernelPackage/b43legacy/install
+ $(INSTALL_DIR) $(1)/lib/firmware/
+ b43-fwcutter --unsupported -w $(1)/lib/firmware/ $(DL_DIR)/$(PKG_B43_FWV3_SOURCE)
+ifneq ($(CONFIG_B43LEGACY_FW_SQUASH),)
+ b43-fwsquash.py "G" "$(CONFIG_B43LEGACY_FW_SQUASH_COREREVS)" "$(1)/lib/firmware/b43legacy"
+endif
+endef
+
+define KernelPackage/brcmsmac/install
+ $(INSTALL_DIR) $(1)/lib/firmware/brcm
+ifeq ($(CONFIG_BRCMSMAC_USE_FW_FROM_WL),y)
+ tar xjf "$(DL_DIR)/$(PKG_BRCMSMAC_FW_SOURCE)" -C "$(PKG_BUILD_DIR)"
+ b43-fwcutter --brcmsmac -w $(1)/lib/firmware/ $(PKG_BUILD_DIR)/$(PKG_BRCMSMAC_FW_OBJECT)
+else
+ $(INSTALL_DATA) \
+ $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/brcm/bcm43xx-0.fw \
+ $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/brcm/bcm43xx_hdr-0.fw \
+ $(1)/lib/firmware/brcm/
+endif
+endef
+
+define KernelPackage/brcmfmac/install
+ $(INSTALL_DIR) $(1)/lib/firmware/brcm
+ $(INSTALL_DATA) \
+ $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/brcm/brcmfmac43236b.bin \
+ $(1)/lib/firmware/brcm/
+endef
+
+$(eval $(call KernelPackage,adm8211))
+$(eval $(call KernelPackage,ath5k))
+$(eval $(call KernelPackage,lib80211))
+$(eval $(call KernelPackage,libertas-usb))
+$(eval $(call KernelPackage,libertas-sd))
+$(eval $(call KernelPackage,cfg80211))
+$(eval $(call KernelPackage,mac80211))
+$(eval $(call KernelPackage,p54-common))
+$(eval $(call KernelPackage,p54-pci))
+$(eval $(call KernelPackage,p54-usb))
+$(eval $(call KernelPackage,p54-spi))
+$(eval $(call KernelPackage,rt2x00-lib))
+$(eval $(call KernelPackage,rt2x00-pci))
+$(eval $(call KernelPackage,rt2x00-usb))
+$(eval $(call KernelPackage,rt2x00-soc))
+$(eval $(call KernelPackage,rt2800-lib))
+$(eval $(call KernelPackage,rt2400-pci))
+$(eval $(call KernelPackage,rt2500-pci))
+$(eval $(call KernelPackage,rt2500-usb))
+$(eval $(call KernelPackage,rt61-pci))
+$(eval $(call KernelPackage,rt73-usb))
+$(eval $(call KernelPackage,rt2800-pci))
+$(eval $(call KernelPackage,rt2800-usb))
+$(eval $(call KernelPackage,rtl8180))
+$(eval $(call KernelPackage,rtl8187))
+$(eval $(call KernelPackage,zd1211rw))
+$(eval $(call KernelPackage,mac80211-hwsim))
+$(eval $(call KernelPackage,ath9k-common))
+$(eval $(call KernelPackage,ath9k))
+$(eval $(call KernelPackage,ath9k-htc))
+$(eval $(call KernelPackage,ath))
+$(eval $(call KernelPackage,carl9170))
+$(eval $(call KernelPackage,b43))
+$(eval $(call KernelPackage,b43legacy))
+$(eval $(call KernelPackage,brcmutil))
+$(eval $(call KernelPackage,brcmsmac))
+$(eval $(call KernelPackage,brcmfmac))
+$(eval $(call KernelPackage,net-libipw))
+$(eval $(call KernelPackage,net-ipw2100))
+$(eval $(call KernelPackage,net-ipw2200))
+$(eval $(call KernelPackage,iwlagn))
+$(eval $(call KernelPackage,iwl-legacy))
+$(eval $(call KernelPackage,iwl4965))
+$(eval $(call KernelPackage,iwl3945))
+$(eval $(call KernelPackage,mwl8k))
+$(eval $(call KernelPackage,net-hermes))
+$(eval $(call KernelPackage,net-hermes-pci))
+$(eval $(call KernelPackage,net-hermes-plx))
+$(eval $(call KernelPackage,net-hermes-pcmcia))
+$(eval $(call KernelPackage,wl12xx))
diff --git a/package/mac80211/Makefile b/package/mac80211/Makefile
new file mode 100644
index 0000000..64233bd
--- /dev/null
+++ b/package/mac80211/Makefile
@@ -0,0 +1,1701 @@
+#
+# Copyright (C) 2007-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=mac80211
+
+PKG_VERSION:=2013-02-22
+PKG_RELEASE:=1
+PKG_SOURCE_URL:=http://mirror2.openwrt.org/sources
+PKG_MD5SUM:=de1a03ca1f72748d4523672c8facbf7e
+
+PKG_SOURCE:=compat-wireless-$(PKG_VERSION).tar.bz2
+PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/compat-wireless-$(PKG_VERSION)
+PKG_BUILD_PARALLEL:=1
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+
+PKG_DRIVERS = \
+ adm8211 ath5k libertas-usb libertas-sd p54-common p54-pci p54-usb p54-spi \
+ rt2x00-lib rt2x00-pci rt2x00-usb rt2x00-soc rt2800-lib rt2400-pci \
+ rt2500-pci rt2500-usb rt61-pci rt73-usb rt2800-pci rt2800-usb \
+ rtl8180 rtl8187 zd1211rw mac80211-hwsim carl9170 b43 b43legacy \
+ ath9k-common ath9k ath9k-htc ath net-libipw net-ipw2100 net-ipw2200 \
+ mwl8k net-hermes net-hermes-pci net-hermes-plx net-hermes-pcmcia \
+ iwl-legacy iwl3945 iwl4965 iwlagn wl12xx lib80211
+
+PKG_CONFIG_DEPENDS:= \
+ CONFIG_PACKAGE_kmod-mac80211 \
+ $(patsubst %,CONFIG_PACKAGE_kmod-%,$(PKG_DRIVERS)) \
+ CONFIG_PACKAGE_MAC80211_DEBUGFS \
+ CONFIG_PACKAGE_MAC80211_MESH \
+ CONFIG_PACKAGE_ATH_DEBUG \
+ CONFIG_PACKAGE_B43_DEBUG \
+ CONFIG_PACKAGE_B43_PIO \
+ CONFIG_PACKAGE_B43_N_PHY \
+ CONFIG_ATH_USER_REGD \
+
+CARL9170_FW_VERSION:=1.9.6
+
+include $(INCLUDE_DIR)/package.mk
+
+WMENU:=Wireless Drivers
+
+define KernelPackage/mac80211/Default
+ SUBMENU:=$(WMENU)
+ URL:=http://linuxwireless.org/
+ MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+ DEPENDS:=@(!(TARGET_avr32||TARGET_ps3||TARGET_pxcab)||BROKEN)
+endef
+
+define KernelPackage/cfg80211
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=cfg80211 - wireless configuration API
+ DEPENDS+= +iw
+ FILES:= \
+ $(PKG_BUILD_DIR)/compat/compat.ko \
+ $(PKG_BUILD_DIR)/net/wireless/cfg80211.ko
+ AUTOLOAD:=$(call AutoLoad,20,compat cfg80211)
+endef
+
+define KernelPackage/cfg80211/description
+cfg80211 is the Linux wireless LAN (802.11) configuration API.
+endef
+
+define KernelPackage/mac80211
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=Linux 802.11 Wireless Networking Stack
+ DEPENDS+= +kmod-crypto-core +kmod-crypto-arc4 +kmod-crypto-aes +kmod-cfg80211
+ KCONFIG:=\
+ CONFIG_AVERAGE=y
+ FILES:= $(PKG_BUILD_DIR)/net/mac80211/mac80211.ko
+ AUTOLOAD:=$(call AutoLoad,21,mac80211)
+ MENU:=1
+endef
+
+define KernelPackage/mac80211/config
+ if PACKAGE_kmod-mac80211
+
+ config PACKAGE_MAC80211_DEBUGFS
+ bool "Export mac80211 internals in DebugFS"
+ select KERNEL_DEBUG_FS
+ select KERNEL_RELAY if PACKAGE_kmod-ath9k-common
+ default y
+ help
+ Select this to see extensive information about
+ the internal state of mac80211 in debugfs.
+
+ config PACKAGE_MAC80211_MESH
+ bool "Enable 802.11s mesh support"
+ default y
+
+ endif
+endef
+
+define KernelPackage/mac80211/description
+Generic IEEE 802.11 Networking Stack (mac80211)
+endef
+
+PKG_LINUX_FIRMWARE_NAME:=linux-firmware
+PKG_LINUX_FIRMWARE_VERSION:=6942dba419d2ebf8c15514972e89734fd7a8cebc
+PKG_LINUX_FIRMWARE_SOURCE:=$(PKG_LINUX_FIRMWARE_NAME)-$(PKG_LINUX_FIRMWARE_VERSION).tar.bz2
+PKG_LINUX_FIRMWARE_PROTO:=git
+PKG_LINUX_FIRMWARE_SOURCE_URL:=git://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git
+PKG_LINUX_FIRMWARE_SUBDIR:=$(PKG_LINUX_FIRMWARE_NAME)-$(PKG_LINUX_FIRMWARE_VERSION)
+PKG_LINUX_FIRMWARE_MIRROR_MD5SUM:=a5f8c27af9e43f0ad24d7f821c5a781e
+
+define Download/linux-firmware
+ FILE:=$(PKG_LINUX_FIRMWARE_SOURCE)
+ URL:=$(PKG_LINUX_FIRMWARE_SOURCE_URL)
+ MD5SUM:=$(PKG_LINUX_FIRMWARE_MD5SUM)
+ PROTO:=$(PKG_LINUX_FIRMWARE_PROTO)
+ VERSION:=$(PKG_LINUX_FIRMWARE_VERSION)
+ SUBDIR:=$(PKG_LINUX_FIRMWARE_SUBDIR)
+ MIRROR_MD5SUM:=$(PKG_LINUX_FIRMWARE_MIRROR_MD5SUM)
+endef
+$(eval $(call Download,linux-firmware))
+
+# Prism54 drivers
+P54PCIFW:=2.13.12.0.arm
+P54USBFW:=2.13.24.0.lm87.arm
+P54SPIFW:=2.13.0.0.a.13.14.arm
+CARL9170_FW:=carl9170-1.fw
+
+define Download/p54usb
+ FILE:=$(P54USBFW)
+ URL:=http://daemonizer.de/prism54/prism54-fw/fw-usb
+ MD5SUM:=8e8ab005a4f8f0123bcdc51bc25b47f6
+endef
+$(eval $(call Download,p54usb))
+
+define Download/p54pci
+ FILE:=$(P54PCIFW)
+ URL:=http://daemonizer.de/prism54/prism54-fw/fw-softmac
+ MD5SUM:=ff7536af2092b1c4b21315bd103ef4c4
+endef
+$(eval $(call Download,p54pci))
+
+define Download/p54spi
+ FILE:=$(P54SPIFW)
+ URL:=http://daemonizer.de/prism54/prism54-fw/stlc4560
+ MD5SUM:=42661f8ecbadd88012807493f596081d
+endef
+$(eval $(call Download,p54spi))
+
+define Download/carl9170
+ FILE:=$(CARL9170_FW)-$(CARL9170_FW_VERSION)
+ URL:=http://downloads.openwrt.org/sources/
+ MD5SUM:=2fa6ed98d53d0b5fbcc136d1cf5e9609
+endef
+$(eval $(call Download,carl9170))
+
+define KernelPackage/p54/Default
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=Prism54 Drivers
+endef
+
+define KernelPackage/p54/description
+ Kernel module for Prism54 chipsets (mac80211)
+endef
+
+define KernelPackage/p54-common
+ $(call KernelPackage/p54/Default)
+ DEPENDS+= @PCI_SUPPORT||@USB_SUPPORT||@TARGET_omap24xx +kmod-mac80211 +kmod-lib-crc-ccitt
+ TITLE+= (COMMON)
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/p54/p54common.ko
+ AUTOLOAD:=$(call AutoLoad,30,p54common)
+endef
+
+define KernelPackage/p54-pci
+ $(call KernelPackage/p54/Default)
+ TITLE+= (PCI)
+ DEPENDS+= @PCI_SUPPORT +kmod-p54-common
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/p54/p54pci.ko
+ AUTOLOAD:=$(call AutoLoad,31,p54pci)
+endef
+
+define KernelPackage/p54-usb
+ $(call KernelPackage/p54/Default)
+ TITLE+= (USB)
+ DEPENDS+= @USB_SUPPORT +kmod-usb-core +kmod-p54-common
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/p54/p54usb.ko
+ AUTOLOAD:=$(call AutoLoad,31,p54usb)
+endef
+
+define KernelPackage/p54-spi
+ $(call KernelPackage/p54/Default)
+ TITLE+= (SPI)
+ DEPENDS+= @TARGET_omap24xx +kmod-p54-common
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/p54/p54spi.ko
+ AUTOLOAD:=$(call AutoLoad,31,p54spi)
+endef
+
+NEED_RT2X00_LIB_CRYPTO:=y
+NEED_RT2X00_LIB_FIRMWARE:=y
+NEED_RT2X00_LIB_EEPROM:=y
+NEED_RT2X00_LIB_HT:=y
+NEED_RT2X00_LIB_LEDS:=y
+
+define KernelPackage/rt2x00/Default
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=Ralink Drivers for RT2x00 cards
+endef
+
+define KernelPackage/rt2x00-lib
+$(call KernelPackage/rt2x00/Default)
+ DEPENDS+= @(PCI_SUPPORT||USB_SUPPORT||TARGET_ramips) +kmod-mac80211 +kmod-lib-crc-itu-t
+ TITLE+= (LIB)
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/rt2x00/rt2x00lib.ko
+ AUTOLOAD:=$(call AutoLoad,25,rt2x00lib)
+ MENU:=1
+endef
+
+define KernelPackage/rt2x00-lib/config
+ if PACKAGE_kmod-rt2x00-lib
+
+ config PACKAGE_RT2X00_LIB_DEBUGFS
+ bool "Enable rt2x00 debugfs support"
+ depends PACKAGE_MAC80211_DEBUGFS
+ help
+ Enable creation of debugfs files for the rt2x00 drivers.
+ These debugfs files support both reading and writing of the
+ most important register types of the rt2x00 hardware.
+
+ config PACKAGE_RT2X00_DEBUG
+ bool "Enable rt2x00 debug output"
+ help
+ Enable debugging output for all rt2x00 modules
+
+ endif
+endef
+
+define KernelPackage/rt2x00-pci
+$(call KernelPackage/rt2x00/Default)
+ DEPENDS+= @(PCI_SUPPORT||TARGET_ramips) +kmod-rt2x00-lib +kmod-eeprom-93cx6
+ TITLE+= (PCI)
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/rt2x00/rt2x00pci.ko
+ AUTOLOAD:=$(call AutoLoad,26,rt2x00pci)
+endef
+
+define KernelPackage/rt2x00-usb
+$(call KernelPackage/rt2x00/Default)
+ DEPENDS+= @USB_SUPPORT +kmod-rt2x00-lib +kmod-usb-core
+ TITLE+= (USB)
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/rt2x00/rt2x00usb.ko
+ AUTOLOAD:=$(call AutoLoad,26,rt2x00usb)
+endef
+
+define KernelPackage/rt2x00-soc
+$(call KernelPackage/rt2x00/Default)
+ DEPENDS+= @TARGET_ramips +kmod-rt2x00-lib
+ TITLE+= (SoC)
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/rt2x00/rt2x00soc.ko
+ AUTOLOAD:=$(call AutoLoad,26,rt2x00soc)
+endef
+
+define KernelPackage/rt2800-lib
+$(call KernelPackage/rt2x00/Default)
+ DEPENDS+= @(PCI_SUPPORT||USB_SUPPORT||TARGET_ramips) +kmod-rt2x00-lib +TARGET_ramips:kmod-rt2x00-soc +@DRIVER_11N_SUPPORT
+ TITLE+= (rt2800 LIB)
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/rt2x00/rt2800lib.ko
+ AUTOLOAD:=$(call AutoLoad,27,rt2800lib)
+endef
+
+define KernelPackage/rt2400-pci
+$(call KernelPackage/rt2x00/Default)
+ DEPENDS+= @PCI_SUPPORT +kmod-rt2x00-pci
+ TITLE+= (RT2400 PCI)
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/rt2x00/rt2400pci.ko
+ AUTOLOAD:=$(call AutoLoad,27,rt2400pci)
+endef
+
+define KernelPackage/rt2500-pci
+$(call KernelPackage/rt2x00/Default)
+ DEPENDS+= @PCI_SUPPORT +kmod-rt2x00-pci
+ TITLE+= (RT2500 PCI)
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/rt2x00/rt2500pci.ko
+ AUTOLOAD:=$(call AutoLoad,27,rt2500pci)
+endef
+
+define KernelPackage/rt2500-usb
+$(call KernelPackage/rt2x00/Default)
+ DEPENDS+= @USB_SUPPORT +kmod-rt2x00-usb
+ TITLE+= (RT2500 USB)
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/rt2x00/rt2500usb.ko
+ AUTOLOAD:=$(call AutoLoad,27,rt2500usb)
+endef
+
+define KernelPackage/rt61-pci
+$(call KernelPackage/rt2x00/Default)
+ DEPENDS+= @PCI_SUPPORT +kmod-rt2x00-pci
+ TITLE+= (RT2x61 PCI)
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/rt2x00/rt61pci.ko
+ AUTOLOAD:=$(call AutoLoad,27,rt61pci)
+endef
+
+define KernelPackage/rt73-usb
+ $(call KernelPackage/rt2x00/Default)
+ DEPENDS+= @USB_SUPPORT +kmod-rt2x00-usb
+ TITLE+= (RT73 USB)
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/rt2x00/rt73usb.ko
+ AUTOLOAD:=$(call AutoLoad,27,rt73usb)
+endef
+
+define KernelPackage/rt2800-pci
+$(call KernelPackage/rt2x00/Default)
+ DEPENDS+= @(PCI_SUPPORT||TARGET_ramips) +kmod-rt2x00-pci +kmod-rt2800-lib +kmod-lib-crc-ccitt +TARGET_ramips:kmod-rt2x00-soc
+ TITLE+= (RT2860 PCI)
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/rt2x00/rt2800pci.ko
+ AUTOLOAD:=$(call AutoLoad,28,rt2800pci)
+endef
+
+define KernelPackage/rt2800-usb
+$(call KernelPackage/rt2x00/Default)
+ DEPENDS+= @USB_SUPPORT +kmod-rt2x00-usb +kmod-rt2800-lib +kmod-lib-crc-ccitt
+ TITLE+= (RT2870 USB)
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/rt2x00/rt2800usb.ko
+ AUTOLOAD:=$(call AutoLoad,28,rt2800usb)
+endef
+
+define KernelPackage/rtl818x/Default
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=Realtek Drivers for RTL818x devices
+ URL:=http://wireless.kernel.org/en/users/Drivers/rtl8187
+ DEPENDS+= +kmod-eeprom-93cx6 +kmod-mac80211
+endef
+
+define KernelPackage/rtl8180
+ $(call KernelPackage/rtl818x/Default)
+ DEPENDS+= @PCI_SUPPORT
+ TITLE+= (RTL8180 PCI)
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/rtl818x/rtl8180/rtl8180.ko
+ AUTOLOAD:=$(call AutoLoad,27,rtl8180)
+endef
+
+define KernelPackage/rtl8187
+$(call KernelPackage/rtl818x/Default)
+ DEPENDS+= @USB_SUPPORT +kmod-usb-core
+ TITLE+= (RTL8187 USB)
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/rtl818x/rtl8187/rtl8187.ko
+ AUTOLOAD:=$(call AutoLoad,27,rtl8187)
+endef
+
+ZD1211FW_NAME:=zd1211-firmware
+ZD1211FW_VERSION:=1.4
+define Download/zd1211rw
+ FILE:=$(ZD1211FW_NAME)-$(ZD1211FW_VERSION).tar.bz2
+ URL:=@SF/zd1211/
+ MD5SUM:=19f28781d76569af8551c9d11294c870
+endef
+$(eval $(call Download,zd1211rw))
+
+define KernelPackage/zd1211rw
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=Zydas ZD1211 support
+ DEPENDS+= @USB_SUPPORT +kmod-usb-core +kmod-mac80211
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/zd1211rw/zd1211rw.ko
+ AUTOLOAD:=$(call AutoLoad,60,zd1211rw)
+endef
+
+define KernelPackage/adm8211
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=ADMTek 8211 support
+ DEPENDS+=@PCI_SUPPORT +kmod-mac80211 +kmod-eeprom-93cx6
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/adm8211.ko
+ AUTOLOAD:=$(call AutoLoad,60,adm8211)
+endef
+
+define KernelPackage/ath/config
+ if PACKAGE_kmod-ath
+ config ATH_USER_REGD
+ bool "Force Atheros drivers to respect the user's regdomain settings"
+ help
+ Atheros' idea of regulatory handling is that the EEPROM of the card defines
+ the regulatory limits and the user is only allowed to restrict the settings
+ even further, even if the country allows frequencies or power levels that
+ are forbidden by the EEPROM settings.
+
+ Select this option if you want the driver to respect the user's decision about
+ regulatory settings.
+
+ config PACKAGE_ATH_DEBUG
+ bool "Atheros wireless debugging"
+ help
+ Say Y, if you want to debug atheros wireless drivers.
+ Right now only ath9k makes use of this.
+ endif
+endef
+
+define KernelPackage/ath
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=Atheros common driver part
+ DEPENDS+= @PCI_SUPPORT||USB_SUPPORT||TARGET_ar71xx||TARGET_atheros +kmod-mac80211
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/ath/ath.ko
+ AUTOLOAD:=$(call AutoLoad,26,ath)
+ MENU:=1
+endef
+
+define KernelPackage/ath/description
+ This module contains some common parts needed by Atheros Wireless drivers.
+endef
+
+define KernelPackage/ath5k
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=Atheros 5xxx wireless cards support
+ URL:=http://linuxwireless.org/en/users/Drivers/ath5k
+ DEPENDS+= @PCI_SUPPORT||@TARGET_atheros +kmod-ath
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/ath/ath5k/ath5k.ko
+ AUTOLOAD:=$(call AutoLoad,27,ath5k)
+endef
+
+define KernelPackage/ath5k/description
+ This module adds support for wireless adapters based on
+ Atheros 5xxx chipset.
+endef
+
+define KernelPackage/ath9k-common
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=Atheros 802.11n wireless devices (common code for ath9k and ath9k_htc)
+ URL:=http://linuxwireless.org/en/users/Drivers/ath9k
+ DEPENDS+= @PCI_SUPPORT||USB_SUPPORT||TARGET_ar71xx +kmod-ath +@DRIVER_11N_SUPPORT
+ FILES:= \
+ $(PKG_BUILD_DIR)/drivers/net/wireless/ath/ath9k/ath9k_common.ko \
+ $(PKG_BUILD_DIR)/drivers/net/wireless/ath/ath9k/ath9k_hw.ko
+ AUTOLOAD:=$(call AutoLoad,27,ath9k_hw ath9k_common)
+endef
+
+define KernelPackage/ath9k
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=Atheros 802.11n PCI wireless cards support
+ URL:=http://linuxwireless.org/en/users/Drivers/ath9k
+ DEPENDS+= @PCI_SUPPORT||TARGET_ar71xx +kmod-ath9k-common
+ FILES:= \
+ $(PKG_BUILD_DIR)/drivers/net/wireless/ath/ath9k/ath9k.ko
+ AUTOLOAD:=$(call AutoLoad,28,ath9k)
+endef
+
+define KernelPackage/ath9k/description
+This module adds support for wireless adapters based on
+Atheros IEEE 802.11n AR5008 and AR9001 family of chipsets.
+endef
+
+define KernelPackage/ath9k-htc
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=Atheros 802.11n USB device support
+ URL:=http://linuxwireless.org/en/users/Drivers/ath9k
+ DEPENDS+= @USB_SUPPORT +kmod-ath9k-common +kmod-usb-core
+ FILES:= \
+ $(PKG_BUILD_DIR)/drivers/net/wireless/ath/ath9k/ath9k_htc.ko
+ AUTOLOAD:=$(call AutoLoad,55,ath9k_htc)
+endef
+
+define KernelPackage/ath9k-htc/description
+This module adds support for wireless adapters based on
+Atheros USB AR9271 and AR7010 family of chipsets.
+endef
+
+define KernelPackage/carl9170
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=Driver for Atheros AR9170 USB sticks
+ DEPENDS:=@USB_SUPPORT +kmod-mac80211 +kmod-ath +kmod-usb-core +kmod-input-core +@DRIVER_11N_SUPPORT
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/ath/carl9170/carl9170.ko
+ AUTOLOAD:=$(call AutoLoad,60,carl9170)
+endef
+
+define KernelPackage/carl9170/install
+ $(INSTALL_DIR) $(1)/lib/firmware
+ $(INSTALL_DATA) $(DL_DIR)/$(CARL9170_FW)-$(CARL9170_FW_VERSION) $(1)/lib/firmware/$(CARL9170_FW)
+endef
+
+define KernelPackage/lib80211
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=802.11 Networking stack
+ FILES:= \
+ $(PKG_BUILD_DIR)/net/wireless/lib80211.ko \
+ $(PKG_BUILD_DIR)/net/wireless/lib80211_crypt_wep.ko \
+ $(PKG_BUILD_DIR)/net/wireless/lib80211_crypt_ccmp.ko \
+ $(PKG_BUILD_DIR)/net/wireless/lib80211_crypt_tkip.ko
+ AUTOLOAD:=$(call AutoLoad,21, \
+ lib80211 \
+ lib80211_crypt_wep \
+ lib80211_crypt_ccmp \
+ lib80211_crypt_tkip \
+ )
+endef
+
+define KernelPackage/lib80211/description
+ Kernel modules for 802.11 Networking stack
+ Includes:
+ - lib80211
+ - lib80211_crypt_wep
+ - lib80211_crypt_tkip
+ - lib80211_crytp_ccmp
+endef
+
+define KernelPackage/libertas-usb
+ $(call KernelPackage/mac80211/Default)
+ DEPENDS+= @USB_SUPPORT +kmod-cfg80211 +kmod-usb-core +kmod-lib80211 +@DRIVER_WEXT_SUPPORT
+ TITLE:=Marvell 88W8015 Wireless Driver
+ FILES:= \
+ $(PKG_BUILD_DIR)/drivers/net/wireless/libertas/libertas.ko \
+ $(PKG_BUILD_DIR)/drivers/net/wireless/libertas/usb8xxx.ko
+ AUTOLOAD:=$(call AutoLoad,27,libertas usb8xxx)
+endef
+
+define KernelPackage/libertas-sd
+ $(call KernelPackage/mac80211/Default)
+ DEPENDS+= +kmod-cfg80211 +kmod-lib80211 +@DRIVER_WEXT_SUPPORT
+ TITLE:=Marvell 88W8686 Wireless Driver
+ FILES:= \
+ $(PKG_BUILD_DIR)/drivers/net/wireless/libertas/libertas.ko \
+ $(PKG_BUILD_DIR)/drivers/net/wireless/libertas/libertas_sdio.ko
+ AUTOLOAD:=$(call AutoLoad,91,libertas libertas_sdio)
+endef
+
+define KernelPackage/mac80211-hwsim
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=mac80211 HW simulation device
+ DEPENDS+= +kmod-mac80211
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/mac80211_hwsim.ko
+ AUTOLOAD:=$(call AutoLoad,60,mac80211_hwsim)
+endef
+
+define KernelPackage/net-libipw
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=libipw for ipw2100 and ipw2200
+ DEPENDS:=@PCI_SUPPORT +kmod-crypto-core +kmod-crypto-arc4 +kmod-crypto-aes +kmod-crypto-michael-mic +kmod-lib80211 +kmod-cfg80211 +@DRIVER_WEXT_SUPPORT
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/ipw2x00/libipw.ko
+ AUTOLOAD:=$(call AutoLoad,49,libipw)
+endef
+
+define KernelPackage/net-libipw/description
+ Hardware independent IEEE 802.11 networking stack for ipw2100 and ipw2200.
+endef
+
+IPW2100_NAME:=ipw2100-fw
+IPW2100_VERSION:=1.3
+
+define Download/net-ipw2100
+ URL:=http://bughost.org/firmware/
+ FILE:=$(IPW2100_NAME)-$(IPW2100_VERSION).tgz
+ MD5SUM=46aa75bcda1a00efa841f9707bbbd113
+endef
+$(eval $(call Download,net-ipw2100))
+
+define KernelPackage/net-ipw2100
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=Intel IPW2100 driver
+ DEPENDS:=@PCI_SUPPORT +kmod-net-libipw
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/ipw2x00/ipw2100.ko
+ AUTOLOAD:=$(call AutoLoad,50,ipw2100)
+endef
+
+define KernelPackage/net-ipw2100/description
+ Kernel support for Intel IPW2100
+ Includes:
+ - ipw2100
+endef
+
+IPW2200_NAME:=ipw2200-fw
+IPW2200_VERSION:=3.1
+
+define Download/net-ipw2200
+ URL:=http://bughost.org/firmware/
+ FILE:=$(IPW2200_NAME)-$(IPW2200_VERSION).tgz
+ MD5SUM=eaba788643c7cc7483dd67ace70f6e99
+endef
+$(eval $(call Download,net-ipw2200))
+
+define KernelPackage/net-ipw2200
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=Intel IPW2200 driver
+ DEPENDS:=@PCI_SUPPORT +kmod-net-libipw
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/ipw2x00/ipw2200.ko
+ AUTOLOAD:=$(call AutoLoad,50,ipw2200)
+endef
+
+define KernelPackage/net-ipw2200/description
+ Kernel support for Intel IPW2200
+ Includes:
+ - ipw2200
+endef
+
+
+define KernelPackage/net-hermes
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=Hermes 802.11b chipset support
+ DEPENDS:=@PCI_SUPPORT||PCMCIA_SUPPORT +kmod-cfg80211 +@DRIVER_WEXT_SUPPORT
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/orinoco/orinoco.ko
+ AUTOLOAD:=$(call AutoLoad,50,orinoco)
+endef
+
+define KernelPackage/net-hermes/description
+ Kernel support for Hermes 802.11b chipsets
+endef
+
+define KernelPackage/net-hermes-pci
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=Intersil Prism 2.5 PCI support
+ DEPENDS:=@PCI_SUPPORT +kmod-net-hermes
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/orinoco/orinoco_pci.ko
+ AUTOLOAD:=$(call AutoLoad,55,orinoco_pci)
+endef
+
+define KernelPackage/net-hermes-pci/description
+ Kernel modules for Intersil Prism 2.5 PCI support
+endef
+
+define KernelPackage/net-hermes-plx
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=PLX9052 based PCI adaptor
+ DEPENDS:=@PCI_SUPPORT +kmod-net-hermes
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/orinoco/orinoco_plx.ko
+ AUTOLOAD:=$(call AutoLoad,55,orinoco_plx)
+endef
+
+define KernelPackage/net-hermes-plx/description
+ Kernel modules for Hermes in PLX9052 based PCI adaptors
+endef
+
+define KernelPackage/net-hermes-pcmcia
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=Hermes based PCMCIA adaptors
+ DEPENDS:=@PCMCIA_SUPPORT +kmod-net-hermes @BROKEN
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/orinoco/orinoco_cs.ko
+ AUTOLOAD:=$(call AutoLoad,55,orinoco_cs)
+endef
+
+define KernelPackage/net-hermes-pcmcia/description
+ Kernel modules for Hermes based PCMCIA adaptors
+endef
+
+define KernelPackage/iwlagn
+ $(call KernelPackage/mac80211/Default)
+ DEPENDS:= +kmod-mac80211 @PCI_SUPPORT +@DRIVER_11N_SUPPORT
+ TITLE:=Intel AGN Wireless support
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/iwlwifi/iwlwifi.ko
+ AUTOLOAD:=$(call AutoLoad,60,iwlwifi)
+ MENU:=1
+endef
+
+define KernelPackage/iwlagn/description
+ iwlagn kernel module for Intel 5000/5150/1000/6000/6050/6005/6030/100 support
+endef
+
+define KernelPackage/iwlagn/config
+ if PACKAGE_kmod-iwlagn
+
+ config IWL5000_FW
+ bool "Intel 5000 Firmware"
+ default y
+ help
+ Download and install firmware for:
+ Intel Wireless WiFi 5100AGN, 5300AGN, and 5350AGN
+
+ config IWL5150_FW
+ bool "Intel 5150 Firmware"
+ default y
+ help
+ Download and install firmware for:
+ Intel Wireless WiFi 5150AGN
+
+ config IWL1000_FW
+ bool "Intel 1000 Firmware"
+ default y
+ help
+ Download and install firmware for:
+ Intel Centrino Wireless-N 1000
+
+ config IWL6000_FW
+ bool "Intel 6000 Firmware"
+ default y
+ help
+ Download and install firmware for:
+ Intel Centrino Ultimate-N 6300 and Advanced-N 6200
+
+ config IWL6050_FW
+ bool "Intel 6050 Firmware"
+ default y
+ help
+ Download and install firmware for:
+ Intel Centrino Advanced-N + WiMAX 6250 and Wireless-N + WiMAX 6150
+
+ config IWL6005_FW
+ bool "Intel 6005 Firmware"
+ default y
+ help
+ Download and install firmware for:
+ Intel Centrino Advanced-N 6205
+
+ config IWL6030_FW
+ bool "Intel 6030 Firmware"
+ default y
+ help
+ Download and install firmware for:
+ Intel Centrino Advanced-N 6230, Wireless-N 1030, Wireless-N 130 and Advanced-N 6235
+
+ config IWL100_FW
+ bool "Intel 100 Firmware"
+ default y
+ help
+ Download and install firmware for:
+ Intel Centrino Wireless-N 100
+
+ config IWL2000_FW
+ bool "Intel 2000 Firmware"
+ default y
+ help
+ Download and install firmware for:
+ Intel Centrino Wireless-N 2200
+
+ config IWL2030_FW
+ bool "Intel 2030 Firmware"
+ default y
+ help
+ Download and install firmware for:
+ Intel Centrino Wireless-N 2230
+
+ config IWL105_FW
+ bool "Intel 105 Firmware"
+ default y
+ help
+ Download and install firmware for:
+ Intel Centrino Wireless-N 105
+
+ config IWL135_FW
+ bool "Intel 135 Firmware"
+ default y
+ help
+ Download and install firmware for:
+ Intel Centrino Wireless-N 135
+ endif
+endef
+
+define KernelPackage/iwl-legacy
+ $(call KernelPackage/mac80211/Default)
+ DEPENDS:= +kmod-mac80211 @PCI_SUPPORT
+ TITLE:=Intel legacy Wireless support
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/iwlegacy/iwlegacy.ko
+ AUTOLOAD:=$(call AutoLoad,60,iwlegacy)
+endef
+
+define KernelPackage/iwl-legacy/description
+ iwl-legacy kernel module for legacy Intel wireless support
+endef
+
+define KernelPackage/iwl3945
+ $(call KernelPackage/mac80211/Default)
+ DEPENDS:= +kmod-mac80211 +kmod-iwl-legacy
+ TITLE:=Intel iwl3945 Wireless support
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/iwlegacy/iwl3945.ko
+ AUTOLOAD:=$(call AutoLoad,61,iwl3945)
+endef
+
+define KernelPackage/iwl3945/description
+ iwl3945 kernel module for Intel 3945 support
+endef
+
+define KernelPackage/iwl4965
+ $(call KernelPackage/mac80211/Default)
+ DEPENDS:= +kmod-mac80211 +kmod-iwl-legacy +@DRIVER_11N_SUPPORT
+ TITLE:=Intel iwl4965 Wireless support
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/iwlegacy/iwl4965.ko
+ AUTOLOAD:=$(call AutoLoad,61,iwl4965)
+endef
+
+define KernelPackage/iwl4965/description
+ iwl4965 kernel module for Intel 4965 support
+endef
+
+
+define KernelPackage/mwl8k
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=Driver for Marvell TOPDOG 802.11 Wireless cards
+ URL:=http://wireless.kernel.org/en/users/Drivers/mwl8k
+ DEPENDS+= @PCI_SUPPORT +kmod-mac80211 +@DRIVER_11N_SUPPORT
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/mwl8k.ko
+ AUTOLOAD:=$(call AutoLoad,27,mwl8k)
+endef
+
+define KernelPackage/mwl8k/description
+ Kernel modules for Marvell TOPDOG 802.11 Wireless cards
+endef
+
+
+define KernelPackage/wl12xx
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=Driver for TI WL12xx
+ URL:=http://wireless.kernel.org/en/users/Drivers/wl12xx
+ DEPENDS+= @TARGET_omap4 +kmod-mac80211
+ FILES:= \
+ $(PKG_BUILD_DIR)/drivers/net/wireless/ti/wl12xx/wl12xx.ko \
+ $(PKG_BUILD_DIR)/drivers/net/wireless/ti/wlcore/wlcore.ko \
+ $(PKG_BUILD_DIR)/drivers/net/wireless/ti/wlcore/wlcore_sdio.ko
+ AUTOLOAD:=$(call AutoLoad,61,wlcore wlcore_sdio wl12xx)
+endef
+
+define KernelPackage/wl12xx/description
+ Kernel modules for TI WL12xx
+endef
+
+#Broadcom firmware
+ifneq ($(CONFIG_B43_FW_5_10),)
+ PKG_B43_FWV4_NAME:=broadcom-wl
+ PKG_B43_FWV4_VERSION:=5.10.56.27.3
+ PKG_B43_FWV4_OBJECT:=$(PKG_B43_FWV4_NAME)-$(PKG_B43_FWV4_VERSION)/driver/wl_apsta/wl_prebuilt.o
+ PKG_B43_FWV4_SOURCE:=$(PKG_B43_FWV4_NAME)-$(PKG_B43_FWV4_VERSION)_mipsel.tar.bz2
+ PKG_B43_FWV4_SOURCE_URL:=http://mirror2.openwrt.org/sources/
+ PKG_B43_FWV4_MD5SUM:=3363e3a6b3d9d73c49dea870c7834eac
+else
+ifneq ($(CONFIG_B43_FW_4_178),)
+ PKG_B43_FWV4_NAME:=broadcom-wl
+ PKG_B43_FWV4_VERSION:=4.178.10.4
+ PKG_B43_FWV4_OBJECT:=$(PKG_B43_FWV4_NAME)-$(PKG_B43_FWV4_VERSION)/linux/wl_apsta.o
+ PKG_B43_FWV4_SOURCE:=$(PKG_B43_FWV4_NAME)-$(PKG_B43_FWV4_VERSION).tar.bz2
+ PKG_B43_FWV4_SOURCE_URL:=http://mirror2.openwrt.org/sources/
+ PKG_B43_FWV4_MD5SUM:=14477e8cbbb91b11896affac9b219fdb
+else
+ifneq ($(CONFIG_B43_FW_5_100_138),)
+ PKG_B43_FWV4_NAME:=broadcom-wl
+ PKG_B43_FWV4_VERSION:=5.100.138
+ PKG_B43_FWV4_OBJECT:=$(PKG_B43_FWV4_NAME)-$(PKG_B43_FWV4_VERSION)/linux/wl_apsta.o
+ PKG_B43_FWV4_SOURCE:=$(PKG_B43_FWV4_NAME)-$(PKG_B43_FWV4_VERSION).tar.bz2
+ PKG_B43_FWV4_SOURCE_URL:=http://www.lwfinger.com/b43-firmware/
+ PKG_B43_FWV4_MD5SUM:=f4e357b09eaf5d8b1f1920cf3493a555
+else
+ PKG_B43_FWV4_NAME:=broadcom-wl
+ PKG_B43_FWV4_VERSION:=4.150.10.5
+ PKG_B43_FWV4_OBJECT:=$(PKG_B43_FWV4_NAME)-$(PKG_B43_FWV4_VERSION)/driver/wl_apsta_mimo.o
+ PKG_B43_FWV4_SOURCE:=$(PKG_B43_FWV4_NAME)-$(PKG_B43_FWV4_VERSION).tar.bz2
+ PKG_B43_FWV4_SOURCE_URL:=http://mirror2.openwrt.org/sources/
+ PKG_B43_FWV4_MD5SUM:=0c6ba9687114c6b598e8019e262d9a60
+endif
+endif
+endif
+ifneq ($(CONFIG_B43_OPENFIRMWARE),)
+ PKG_B43_FWV4_NAME:=broadcom-wl
+ PKG_B43_FWV4_VERSION:=5.2
+ PKG_B43_FWV4_OBJECT:=openfwwf-$(PKG_B43_FWV4_VERSION)
+ PKG_B43_FWV4_SOURCE:=openfwwf-$(PKG_B43_FWV4_VERSION).tar.gz
+ PKG_B43_FWV4_SOURCE_URL:=http://www.ing.unibs.it/openfwwf/firmware/
+ PKG_B43_FWV4_MD5SUM:=e045a135453274e439ae183f8498b0fa
+endif
+
+
+PKG_B43_FWV3_NAME:=wl_apsta
+PKG_B43_FWV3_VERSION:=3.130.20.0
+PKG_B43_FWV3_SOURCE:=$(PKG_B43_FWV3_NAME)-$(PKG_B43_FWV3_VERSION).o
+PKG_B43_FWV3_SOURCE_URL:=http://downloads.openwrt.org/sources/
+PKG_B43_FWV3_MD5SUM:=e08665c5c5b66beb9c3b2dd54aa80cb3
+
+define Download/b43
+ FILE:=$(PKG_B43_FWV4_SOURCE)
+ URL:=$(PKG_B43_FWV4_SOURCE_URL)
+ MD5SUM:=$(PKG_B43_FWV4_MD5SUM)
+endef
+$(eval $(call Download,b43))
+
+define Download/b43legacy
+ FILE:=$(PKG_B43_FWV3_SOURCE)
+ URL:=$(PKG_B43_FWV3_SOURCE_URL)
+ MD5SUM:=$(PKG_B43_FWV3_MD5SUM)
+endef
+$(eval $(call Download,b43legacy))
+
+
+define KernelPackage/b43
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=Broadcom 43xx wireless support
+ URL:=http://linuxwireless.org/en/users/Drivers/b43
+ KCONFIG:= \
+ CONFIG_HW_RANDOM=y
+ DEPENDS+= +kmod-mac80211 +!TARGET_brcm47xx:kmod-bcma +!(TARGET_brcm47xx||TARGET_brcm63xx):kmod-ssb
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/b43/b43.ko
+ AUTOLOAD:=$(call AutoLoad,30,b43)
+ MENU:=1
+endef
+
+define KernelPackage/b43/config
+ if PACKAGE_kmod-b43
+
+ choice
+ prompt "b43 firmware version"
+ default B43_FW_5_100_138
+ help
+ This option allows you to select the version of the b43 firmware.
+
+ config B43_FW_4_150
+ bool "Firmware 410.2160 from driver 4.150.10.5 (old stable)"
+ help
+ Stable firmware for BCM43xx devices.
+
+ If unsure, select this.
+
+ config B43_FW_4_178
+ bool "Firmware 478.104 from driver 4.178.10.4"
+ help
+ Experimental firmware for BCM43xx devices.
+
+ This firmware is not tested as much as the "stable" firmware.
+
+ If unsure, select the "stable" firmware.
+
+ config B43_FW_5_10
+ bool "Firmware 508.1084 from driver 5.10.56.27"
+ help
+ Newer experimental firmware for BCM43xx devices.
+
+ This firmware is mostly untested. It is needed for some N-PHY devices.
+
+ If unsure, select the "stable" firmware.
+
+ config B43_FW_5_100_138
+ bool "Firmware 666.2 from driver 5.100.138 (stable)"
+ help
+ Newer experimental firmware for BCM43xx devices.
+
+ This firmware is mostly untested. It is needed for some N-PHY devices.
+
+ If unsure, select the "stable" firmware.
+
+ config B43_OPENFIRMWARE
+ bool "Open FirmWare for WiFi networks"
+ help
+ Opensource firmware for BCM43xx devices.
+
+ Do _not_ select this, unless you know what you are doing.
+ The Opensource firmware is not suitable for embedded devices, yet.
+ It does not support QoS, which is bad for AccessPoints.
+ It does not support hardware crypto acceleration, which is a showstopper
+ for embedded devices with low CPU resources.
+
+ If unsure, select the "stable" firmware.
+
+ endchoice
+
+ config B43_FW_SQUASH
+ bool "Remove unnecessary firmware files"
+ depends on !B43_OPENFIRMWARE
+ default y
+ help
+ This options allows you to remove unnecessary b43 firmware files
+ from the final rootfs image. This can reduce the rootfs size by
+ up to 200k.
+
+ If unsure, say Y.
+
+ config B43_FW_SQUASH_COREREVS
+ string "Core revisions to include"
+ depends on B43_FW_SQUASH
+ default "5,6,7,8,9,10,11,13,15,16,29"
+ help
+ This is a comma seperated list of core revision numbers.
+
+ Example (keep files for rev5 only):
+ 5
+
+ Example (keep files for rev5 and rev11):
+ 5,11
+
+ config B43_FW_SQUASH_PHYTYPES
+ string "PHY types to include"
+ depends on B43_FW_SQUASH
+ default "G,LP,N,HT"
+ help
+ This is a comma seperated list of PHY types:
+ A => A-PHY
+ AG => Dual A-PHY G-PHY
+ G => G-PHY
+ LP => LP-PHY
+ N => N-PHY
+ HT => HT-PHY
+ LCN => LCN-PHY
+
+ Example (keep files for G-PHY only):
+ G
+
+ Example (keep files for G-PHY and N-PHY):
+ G,N
+
+ config PACKAGE_B43_DEBUG
+ bool "Enable debug output and debugfs for b43"
+ default n
+ help
+ Enable additional debug output and runtime sanity checks for b43
+ and enables the debugfs interface.
+
+ If unsure, say N.
+
+ config PACKAGE_B43_PIO
+ bool "Enable support for PIO transfer mode"
+ default n
+ help
+ Enable support for using PIO instead of DMA. Unless you have DMA
+ transfer problems you don't need this.
+
+ If unsure, say N.
+
+ config PACKAGE_B43_PHY_N
+ bool "Enable support for N-PHYs"
+ default y
+ help
+ Enable support for N-PHY. This includes support for the following devices:
+ PCI: BCM4321, BCM4322, BCM43222, BCM43224, BCM43225
+ SoC: BCM4716, BCM4717, BCM4718
+
+ Currently only 11g speed is available.
+
+ If unsure, say Y.
+
+ config PACKAGE_B43_PHY_HT
+ bool "Enable support for HT-PHYs"
+ default y
+ help
+ Enable support for HT-PHY. This includes support for the following devices:
+ PCI: BCM4331
+
+ Currently only 11g speed is available.
+
+ If unsure, say Y.
+
+ config PACKAGE_B43_PHY_LCN
+ bool "Enable support for LCN-PHYs"
+ depends on BROKEN
+ default n
+ help
+ Currently broken.
+
+ If unsure, say N.
+
+ endif
+endef
+
+define KernelPackage/b43/description
+Kernel module for Broadcom 43xx wireless support (mac80211 stack) new
+endef
+
+define KernelPackage/b43legacy
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=Broadcom 43xx-legacy wireless support
+ URL:=http://linuxwireless.org/en/users/Drivers/b43
+ KCONFIG:= \
+ CONFIG_HW_RANDOM=y
+ DEPENDS+= +kmod-mac80211 +!(TARGET_brcm47xx||TARGET_brcm63xx):kmod-ssb
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/b43legacy/b43legacy.ko
+ AUTOLOAD:=$(call AutoLoad,30,b43legacy)
+ MENU:=1
+endef
+
+define KernelPackage/b43legacy/config
+ if PACKAGE_kmod-b43legacy
+
+ config B43LEGACY_FW_SQUASH
+ bool "Remove unnecessary firmware files"
+ default y
+ help
+ This options allows you to remove unnecessary b43legacy firmware files
+ from the final rootfs image. This can reduce the rootfs size by
+ up to 50k.
+
+ If unsure, say Y.
+
+ config B43LEGACY_FW_SQUASH_COREREVS
+ string "Core revisions to include"
+ depends on B43LEGACY_FW_SQUASH
+ default "1,2,3,4"
+ help
+ This is a comma seperated list of core revision numbers.
+
+ Example (keep files for rev4 only):
+ 4
+
+ Example (keep files for rev2 and rev4):
+ 2,4
+
+ endif
+endef
+
+define KernelPackage/b43legacy/description
+Kernel module for Broadcom 43xx-legacy wireless support (mac80211 stack) new
+endef
+
+
+define KernelPackage/brcmutil
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=Broadcom IEEE802.11n common driver parts
+ URL:=http://linuxwireless.org/en/users/Drivers/brcm80211
+ DEPENDS+=@PCI_SUPPORT||USB_SUPPORT
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/brcm80211/brcmutil/brcmutil.ko
+ AUTOLOAD:=$(call AutoLoad,30,brcmutil)
+ MENU:=1
+endef
+
+define KernelPackage/brcmutil/description
+ This module contains some common parts needed by Broadcom Wireless drivers brcmsmac and brcmfmac.
+endef
+
+define KernelPackage/brcmutil/config
+ if PACKAGE_kmod-brcmutil
+
+ config PACKAGE_BRCM80211_DEBUG
+ bool "Broadcom wireless driver debugging"
+ help
+ Say Y, if you want to debug brcmsmac and brcmfmac wireless driver.
+
+ endif
+endef
+
+PKG_BRCMSMAC_FW_NAME:=broadcom-wl
+PKG_BRCMSMAC_FW_VERSION:=5.100.138
+PKG_BRCMSMAC_FW_OBJECT:=$(PKG_BRCMSMAC_FW_NAME)-$(PKG_BRCMSMAC_FW_VERSION)/linux/wl_apsta.o
+PKG_BRCMSMAC_FW_SOURCE:=$(PKG_BRCMSMAC_FW_NAME)-$(PKG_BRCMSMAC_FW_VERSION).tar.bz2
+PKG_BRCMSMAC_FW_SOURCE_URL:=http://www.lwfinger.com/b43-firmware/
+PKG_BRCMSMAC_FW_MD5SUM:=f4e357b09eaf5d8b1f1920cf3493a555
+
+define KernelPackage/brcmsmac
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=Broadcom IEEE802.11n PCIe SoftMAC WLAN driver
+ URL:=http://linuxwireless.org/en/users/Drivers/brcm80211
+ DEPENDS+= +kmod-mac80211 +@DRIVER_11N_SUPPORT +!TARGET_brcm47xx:kmod-bcma +kmod-lib-cordic +kmod-lib-crc8 +kmod-brcmutil
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/brcm80211/brcmsmac/brcmsmac.ko
+ AUTOLOAD:=$(call AutoLoad,31,brcmsmac)
+ MENU:=1
+endef
+
+define KernelPackage/brcmsmac/description
+ Kernel module for Broadcom IEEE802.11n PCIe Wireless cards
+endef
+
+define KernelPackage/brcmsmac/config
+ if PACKAGE_kmod-brcmsmac
+
+ config BRCMSMAC_USE_FW_FROM_WL
+ bool "Use firmware extracted from broadcom proprietary driver"
+ default y
+ help
+ Instead of using the official brcmsmac firmware a firmware
+ version 666.2 extracted from the proprietary Broadcom driver
+ is used. This is needed to get core rev 17 used in bcm4716
+ to work.
+
+ If unsure, say Y.
+
+ endif
+endef
+
+
+define KernelPackage/brcmfmac
+ $(call KernelPackage/mac80211/Default)
+ TITLE:=Broadcom IEEE802.11n USB FullMAC WLAN driver
+ URL:=http://linuxwireless.org/en/users/Drivers/brcm80211
+ DEPENDS+= @USB_SUPPORT +kmod-usb-core +kmod-cfg80211 +@DRIVER_11N_SUPPORT +kmod-brcmutil
+ FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/brcm80211/brcmfmac/brcmfmac.ko
+ AUTOLOAD:=$(call AutoLoad,60,brcmfmac)
+endef
+
+define KernelPackage/brcmfmac/description
+ Kernel module for Broadcom IEEE802.11n USB Wireless cards
+endef
+
+BUILDFLAGS:= \
+ -I$(PKG_BUILD_DIR)/include \
+ -DCONFIG_CFG80211_INTERNAL_REGDB=y \
+ $(foreach opt,$(CONFOPTS),-DCONFIG_$(opt)) \
+ $(if $(CONFIG_PCI),-DCONFIG_B43_PCI_AUTOSELECT -DCONFIG_B43_PCICORE_AUTOSELECT) \
+ $(if $(CONFIG_LEDS_TRIGGERS), -DCONFIG_MAC80211_LEDS -DCONFIG_LEDS_TRIGGERS -DCONFIG_B43_LEDS -DCONFIG_B43LEGACY_LEDS) \
+ -DCONFIG_B43_HWRNG -DCONFIG_B43LEGACY_HWRNG \
+ $(if $(CONFIG_PCI),-DCONFIG_ATH9K_PCI) \
+ $(if $(CONFIG_TARGET_ar71xx),-DCONFIG_ATH9K_AHB) \
+ $(if $(CONFIG_PACKAGE_MAC80211_DEBUGFS), -DCONFIG_CFG80211_DEBUGFS -DCONFIG_MAC80211_DEBUGFS -DCONFIG_ATH9K_DEBUGFS -DCONFIG_CARL9170_DEBUGFS -DCONFIG_ATH9K_HTC_DEBUGFS -DCONFIG_ATH5K_DEBUG) \
+ $(if $(CONFIG_PACKAGE_MAC80211_MESH),-DCONFIG_MAC80211_MESH) \
+ $(if $(CONFIG_PACKAGE_ATH_DEBUG),-DCONFIG_ATH_DEBUG -DCONFIG_ATH9K_PKTLOG) \
+ -D__CONFIG_MAC80211_RC_DEFAULT=minstrel \
+ -DCONFIG_MAC80211_RC_MINSTREL_HT \
+ $(if $(CONFIG_ATH_USER_REGD),-DATH_USER_REGD=1) \
+ $(if $(CONFIG_PACKAGE_B43_DEBUG),-DCONFIG_B43_DEBUG) \
+ $(if $(CONFIG_PACKAGE_B43_PIO),-DCONFIG_B43_PIO) \
+ $(if $(CONFIG_PACKAGE_B43_PIO),-DCONFIG_B43_BCMA_PIO) \
+ $(if $(CONFIG_PACKAGE_B43_PHY_N),-DCONFIG_B43_PHY_N) \
+ $(if $(CONFIG_PACKAGE_B43_PHY_HT),-DCONFIG_B43_PHY_HT) \
+ $(if $(CONFIG_PACKAGE_B43_PHY_LCN),-DCONFIG_B43_PHY_LCN) \
+ -DCONFIG_B43_BCMA -DCONFIG_B43_BCMA_EXTRA \
+ -DCONFIG_B43_SSB \
+ $(if $(CONFIG_PACKAGE_RT2X00_LIB_DEBUGFS),-DCONFIG_RT2X00_LIB_DEBUGFS) \
+ $(if $(CONFIG_PACKAGE_RT2X00_DEBUG),-DCONFIG_RT2X00_DEBUG) \
+ $(if $(NEED_RT2X00_LIB_HT),-DCONFIG_RT2X00_LIB_HT) \
+ $(if $(NEED_RT2X00_LIB_CRYPTO),-DCONFIG_RT2X00_LIB_CRYPTO) \
+ $(if $(NEED_RT2X00_LIB_FIRMWARE),-DCONFIG_RT2X00_LIB_FIRMWARE) \
+ $(if $(NEED_RT2X00_LIB_EEPROM),-DCONFIG_RT2X00_LIB_EEPROM) \
+ $(if $(NEED_RT2X00_LIB_LEDS),-DCONFIG_RT2X00_LIB_LEDS) \
+ $(if $(CONFIG_PACKAGE_kmod-rt2x00-pci),-DCONFIG_RT2X00_LIB_PCI) \
+ $(if $(CONFIG_PACKAGE_kmod-rt2x00-usb),-DCONFIG_RT2X00_LIB_USB) \
+ $(if $(CONFIG_PACKAGE_kmod-rt2x00-usb),-DCONFIG_RT2800USB_RT53XX) \
+ $(if $(CONFIG_PACKAGE_kmod-rt2x00-soc),-DCONFIG_RT2X00_LIB_SOC) \
+ $(if $(CONFIG_TARGET_atheros),-DCONFIG_ATH5K_AHB,-DCONFIG_ATH5K_PCI) \
+ $(if $(CONFIG_PACKAGE_kmod-iwl3945),-DCONFIG_IWL3945) \
+ $(if $(CONFIG_PACKAGE_kmod-iwl4965),-DCONFIG_COMPAT_IWL4965) \
+ $(if $(CONFIG_PACKAGE_kmod-wl12xx),-DCONFIG_WL12XX -DCONFIG_COMPAT_WL12XX_SDIO) \
+ $(if $(CONFIG_PACKAGE_BRCM80211_DEBUG),-DCONFIG_BRCMDBG) \
+ $(if $(CONFIG_PACKAGE_kmod-brcmfmac),-DCONFIG_BRCMFMAC_USB)
+
+MAKE_OPTS:= \
+ CROSS_COMPILE="$(KERNEL_CROSS)" \
+ ARCH="$(LINUX_KARCH)" \
+ EXTRA_CFLAGS="$(BUILDFLAGS)" \
+ $(foreach opt,$(CONFOPTS),CONFIG_$(opt)=m) \
+ CONFIG_CFG80211_INTERNAL_REGDB=y \
+ CONFIG_CFG80211=$(if $(CONFIG_PACKAGE_kmod-cfg80211),m) \
+ CONFIG_MAC80211=$(if $(CONFIG_PACKAGE_kmod-mac80211),m) \
+ CONFIG_MAC80211_RC_MINSTREL=y \
+ CONFIG_MAC80211_MESH=$(CONFIG_PACKAGE_MAC80211_MESH) \
+ CONFIG_MAC80211_LEDS=$(CONFIG_LEDS_TRIGGERS) \
+ CONFIG_CFG80211_DEBUGFS=$(if $(CONFIG_PACKAGE_MAC80211_DEBUGFS),y) \
+ CONFIG_MAC80211_DEBUGFS=$(if $(CONFIG_PACKAGE_MAC80211_DEBUGFS),y) \
+ CONFIG_B43_PCMCIA=n CONFIG_B43_PIO=n \
+ CONFIG_B43_PCI_AUTOSELECT=$(if $(CONFIG_PCI),y) \
+ CONFIG_B43_PCICORE_AUTOSELECT=$(if $(CONFIG_PCI),y) \
+ CONFIG_B43LEGACY_LEDS=$(CONFIG_LEDS_TRIGGERS) \
+ CONFIG_B43_LEDS=$(CONFIG_LEDS_TRIGGERS) \
+ CONFIG_B43_HWRNG=$(if $(CONFIG_HW_RANDOM),y) \
+ CONFIG_B43LEGACY_HWRNG=$(if $(CONFIG_HW_RANDOM),y) \
+ CONFIG_B43=$(if $(CONFIG_PACKAGE_kmod-b43),m) \
+ CONFIG_B43LEGACY=$(if $(CONFIG_PACKAGE_kmod-b43legacy),m) \
+ CONFIG_B43_DEBUG=$(if $(CONFIG_PACKAGE_B43_DEBUG),y) \
+ CONFIG_B43_PIO=$(if $(CONFIG_PACKAGE_B43_PIO),y) \
+ CONFIG_B43_BCMA_PIO=$(if $(CONFIG_PACKAGE_B43_PIO),y) \
+ CONFIG_B43_PHY_N=$(if $(CONFIG_PACKAGE_B43_PHY_N),y) \
+ CONFIG_B43_PHY_HT=$(if $(CONFIG_PACKAGE_B43_PHY_HT),y) \
+ CONFIG_B43_PHY_LCN=$(if $(CONFIG_PACKAGE_B43_PHY_LCN),y) \
+ CONFIG_B43_BCMA=y \
+ CONFIG_B43_SSB=y \
+ CONFIG_ATH_CARDS=$(if $(CONFIG_PACKAGE_kmod-ath),m) \
+ CONFIG_ATH_COMMON=$(if $(CONFIG_PACKAGE_kmod-ath),m) \
+ CONFIG_ATH_DEBUG=$(if $(CONFIG_PACKAGE_ATH_DEBUG),y) \
+ CONFIG_ATH9K_PKTLOG=$(if $(CONFIG_PACKAGE_ATH_DEBUG),y) \
+ CONFIG_ATH5K=$(if $(CONFIG_PACKAGE_kmod-ath5k),m) \
+ CONFIG_ATH5K_PCI=$(if $(CONFIG_TARGET_atheros),,y) \
+ CONFIG_ATH5K_AHB=$(if $(CONFIG_TARGET_atheros),y) \
+ CONFIG_ATH5K_DEBUG=$(if $(CONFIG_PACKAGE_MAC80211_DEBUGFS),y) \
+ CONFIG_ATH9K=$(if $(CONFIG_PACKAGE_kmod-ath9k),m) \
+ CONFIG_ATH9K_PCI=$(CONFIG_PCI) \
+ CONFIG_ATH9K_AHB=$(if $(CONFIG_TARGET_ar71xx),y) \
+ CONFIG_ATH9K_HTC=$(if $(CONFIG_PACKAGE_kmod-ath9k-htc),m) \
+ CONFIG_ATH9K_HTC_DEBUGFS=$(if $(CONFIG_PACKAGE_MAC80211_DEBUGFS),y) \
+ CONFIG_ATH9K_HW=$(if $(CONFIG_PACKAGE_kmod-ath9k-common),m) \
+ CONFIG_ATH9K_COMMON=$(if $(CONFIG_PACKAGE_kmod-ath9k-common),m) \
+ CONFIG_ATH9K_DEBUGFS=$(if $(CONFIG_PACKAGE_MAC80211_DEBUGFS),y) \
+ CONFIG_AR5523= \
+ CONFIG_WIL6210= \
+ CONFIG_CARL9170=$(if $(CONFIG_PACKAGE_kmod-carl9170),m) \
+ CONFIG_CARL9170_DEBUGFS=$(if $(CONFIG_PACKAGE_MAC80211_DEBUGFS),y) \
+ CONFIG_COMPAT_ZD1211RW=$(if $(CONFIG_PACKAGE_kmod-zd1211rw),m) \
+ CONFIG_P54_COMMON=$(if $(CONFIG_PACKAGE_kmod-p54-common),m) \
+ CONFIG_P54_PCI=$(if $(CONFIG_PACKAGE_kmod-p54-pci),m) \
+ CONFIG_P54_USB=$(if $(CONFIG_PACKAGE_kmod-p54-usb),m) \
+ CONFIG_P54_SPI=$(if $(CONFIG_PACKAGE_kmod-p54-spi),m) \
+ CONFIG_P54_SPI_DEFAULT_EEPROM=n \
+ CONFIG_RT2X00=$(if $(CONFIG_PACKAGE_kmod-rt2x00-lib),m) \
+ CONFIG_RT2X00_LIB=$(if $(CONFIG_PACKAGE_kmod-rt2x00-lib),m) \
+ CONFIG_RT2X00_LIB_PCI=$(if $(CONFIG_PACKAGE_kmod-rt2x00-pci),m) \
+ CONFIG_RT2X00_LIB_USB=$(if $(CONFIG_PACKAGE_kmod-rt2x00-usb),m) \
+ CONFIG_RT2X00_LIB_SOC=$(if $(CONFIG_PACKAGE_kmod-rt2x00-soc),m) \
+ CONFIG_RT2X00_LIB_DEBUGFS=$(CONFIG_PACKAGE_RT2X00_LIB_DEBUGFS) \
+ CONFIG_RT2X00_LIB_CRYPTO=$(NEED_RT2X00_LIB_CRYPTO) \
+ CONFIG_RT2X00_LIB_FIRMWARE=$(NEED_RT2X00_LIB_FIRMWARE) \
+ CONFIG_RT2X00_LIB_EEPROM=$(NEED_RT2X00_LIB_EEPROM) \
+ CONFIG_RT2X00_LIB_HT=$(NEED_RT2X00_LIB_HT) \
+ CONFIG_RT2X00_LIB_LEDS=$(NEED_RT2X00_LIB_LEDS) \
+ CONFIG_RT2400PCI=$(if $(CONFIG_PACKAGE_kmod-rt2400-pci),m) \
+ CONFIG_RT2500PCI=$(if $(CONFIG_PACKAGE_kmod-rt2500-pci),m) \
+ CONFIG_RT2500USB=$(if $(CONFIG_PACKAGE_kmod-rt2500-usb),m) \
+ CONFIG_RT61PCI=$(if $(CONFIG_PACKAGE_kmod-rt61-pci),m) \
+ CONFIG_RT73USB=$(if $(CONFIG_PACKAGE_kmod-rt73-usb),m) \
+ CONFIG_RT2800_LIB=$(if $(CONFIG_PACKAGE_kmod-rt2800-lib),m) \
+ CONFIG_RT2800PCI=$(if $(CONFIG_PACKAGE_kmod-rt2800-pci),m) \
+ CONFIG_RT2800USB=$(if $(CONFIG_PACKAGE_kmod-rt2800-usb),m) \
+ CONFIG_RTL8180=$(if $(CONFIG_PACKAGE_kmod-rtl8180),m) \
+ CONFIG_RTL8187=$(if $(CONFIG_PACKAGE_kmod-rtl8187),m) \
+ CONFIG_RTL8192CE= \
+ CONFIG_RTLWIFI= \
+ CONFIG_MAC80211_HWSIM=$(if $(CONFIG_PACKAGE_kmod-mac80211-hwsim),m) \
+ CONFIG_PCMCIA= \
+ CONFIG_LIBIPW=$(if $(CONFIG_PACKAGE_kmod-net-libipw),m) \
+ CONFIG_LIBERTAS=$(if $(CONFIG_PACKAGE_kmod-libertas-sd)$(CONFIG_PACKAGE_kmod-libertas-usb),m) \
+ CONFIG_LIBERTAS_CS= \
+ CONFIG_LIBERTAS_SPI= \
+ CONFIG_COMPAT_LIBERTAS_SDIO=$(if $(CONFIG_PACKAGE_kmod-libertas-sd),m) \
+ CONFIG_LIBERTAS_THINFIRM= \
+ CONFIG_LIBERTAS_USB=$(if $(CONFIG_PACKAGE_kmod-libertas-usb),m) \
+ CONFIG_IPW2100=$(if $(CONFIG_PACKAGE_kmod-net-ipw2100),m) \
+ CONFIG_IPW2200=$(if $(CONFIG_PACKAGE_kmod-net-ipw2200),m) \
+ CONFIG_NL80211=y \
+ CONFIG_LIB80211=$(if $(CONFIG_PACKAGE_kmod-lib80211),m) \
+ CONFIG_LIB80211_CRYPT_WEP=$(if $(CONFIG_PACKAGE_kmod-lib80211),m) \
+ CONFIG_LIB80211_CRYPT_CCMP=$(if $(CONFIG_PACKAGE_kmod-lib80211),m) \
+ CONFIG_LIB80211_CRYPT_TKIP=$(if $(CONFIG_PACKAGE_kmod-lib80211),m) \
+ CONFIG_IWLWIFI=$(if $(CONFIG_PACKAGE_kmod-iwlagn),m) \
+ CONFIG_IWLEGACY=$(if $(CONFIG_PACKAGE_kmod-iwl-legacy),m) \
+ CONFIG_COMPAT_IWL4965=$(if $(CONFIG_PACKAGE_kmod-iwl4965),m) \
+ CONFIG_IWL3945=$(if $(CONFIG_PACKAGE_kmod-iwl3945),m) \
+ CONFIG_MWL8K=$(if $(CONFIG_PACKAGE_kmod-mwl8k),m) \
+ CONFIG_ATMEL= \
+ CONFIG_PCMCIA_ATMEL= \
+ CONFIG_ADM8211=$(if $(CONFIG_PACKAGE_kmod-adm8211),m) \
+ CONFIG_USB_NET_RNDIS_HOST= \
+ CONFIG_USB_NET_RNDIS_WLAN= \
+ CONFIG_USB_NET_CDCETHER= \
+ CONFIG_USB_USBNET= \
+ CONFIG_AT76C50X_USB= \
+ CONFIG_WL_TI=$(if $(CONFIG_PACKAGE_kmod-wl12xx),m) \
+ CONFIG_WLCORE=$(if $(CONFIG_PACKAGE_kmod-wl12xx),m) \
+ CONFIG_WL12XX=$(if $(CONFIG_PACKAGE_kmod-wl12xx),m) \
+ CONFIG_WLCORE_SDIO=$(if $(CONFIG_PACKAGE_kmod-wl12xx),m) \
+ CONFIG_EEPROM_93CX6= \
+ CONFIG_HERMES=$(if $(CONFIG_PACKAGE_kmod-net-hermes),m) \
+ CONFIG_HERMES_CACHE_FW_ON_INIT= \
+ CONFIG_PCI_HERMES=$(if $(CONFIG_PACKAGE_kmod-net-hermes-pci),m) \
+ CONFIG_PLX_HERMES=$(if $(CONFIG_PACKAGE_kmod-net-hermes-plx),m) \
+ CONFIG_PCMCIA_HERMES=$(if $(CONFIG_PACKAGE_kmod-net-hermes-pcmcia),m) \
+ CONFIG_HERMES_PRISM= \
+ CONFIG_APPLE_AIRPORT= \
+ CONFIG_TMD_HERMES= \
+ CONFIG_NORTEL_HERMES= \
+ CONFIG_PCMCIA_SPECTRUM= \
+ CONFIG_ORINOCO_USB= \
+ CONFIG_IWM= \
+ CONFIG_MWIFIEX= \
+ CONFIG_ATH6KL= \
+ CONFIG_MAC80211_RC_MINSTREL_HT=y \
+ MADWIFI= \
+ CONFIG_BRCMUTIL=$(if $(CONFIG_PACKAGE_kmod-brcmutil),m) \
+ CONFIG_BRCMSMAC=$(if $(CONFIG_PACKAGE_kmod-brcmsmac),m) \
+ CONFIG_BRCMFMAC=$(if $(CONFIG_PACKAGE_kmod-brcmfmac),m) \
+ CONFIG_BRCMFMAC_USB=$(if $(CONFIG_PACKAGE_kmod-brcmfmac),y) \
+ CONFIG_BRCMDBG=$(if $(CONFIG_PACKAGE_BRCM80211_DEBUG),y) \
+ KLIB_BUILD="$(LINUX_DIR)" \
+ MODPROBE=true \
+ KLIB=$(TARGET_MODULES_DIR) \
+ KERNEL_SUBLEVEL=$(lastword $(subst ., ,$(KERNEL_PATCHVER))) \
+ KBUILD_LDFLAGS_MODULE_PREREQ=
+
+ifeq ($(CONFIG_PACKAGE_kmod-libertas-sd)$(CONFIG_PACKAGE_kmod-libertas-usb)$(CONFIG_PACKAGE_kmod-rt2x00-lib),)
+ MAKE_OPTS += CONFIG_COMPAT_KFIFO=
+endif
+
+DISABLE_CONFIG = \
+ COMPAT_BLUETOOTH.* \
+ COMPAT_CORDIC \
+ COMPAT_CRC8 \
+ COMPAT_MDIO \
+ COMPAT_NETWORK_MODULES \
+ COMPAT_NET_USB_MODULES \
+ COMPAT_VAR_MODULES \
+ COMPAT_RFKILL \
+ COMPAT_RFKILL_.* \
+ COMPAT_STAGING \
+ \
+ B43_PCMCIA \
+ B43_SDIO \
+ BCMA.* \
+ COMPAT_ATH9K_RATE_CONTROL \
+ HID_GENERIC \
+ MAC80211_RC_PID \
+ PCMCIA \
+ RFKILL_BACKPORT.* \
+ SSB \
+ SSB_SDIOHOST \
+ \
+ ATH5K_PCI \
+ ATH9K_BTCOEX_SUPPORT \
+ B43_PHY_N \
+ B43_PHY_HT \
+ B43_BCMA.* \
+ MAC80211_MESH \
+ RT2X00_LIB_PCI \
+ RT2X00_LIB_USB \
+ COMPAT_MWIFIEX
+
+
+define Build/Prepare
+ rm -rf $(PKG_BUILD_DIR)
+ mkdir -p $(PKG_BUILD_DIR)
+ $(PKG_UNPACK)
+ $(Build/Patch)
+ $(TAR) -C $(PKG_BUILD_DIR) -xzf $(DL_DIR)/$(IPW2100_NAME)-$(IPW2100_VERSION).tgz
+ $(TAR) -C $(PKG_BUILD_DIR) -xzf $(DL_DIR)/$(IPW2200_NAME)-$(IPW2200_VERSION).tgz
+ $(TAR) -C $(PKG_BUILD_DIR) -xjf $(DL_DIR)/$(ZD1211FW_NAME)-$(ZD1211FW_VERSION).tar.bz2
+ $(TAR) -C $(PKG_BUILD_DIR) -xjf $(DL_DIR)/$(PKG_LINUX_FIRMWARE_SOURCE)
+ rm -rf \
+ $(PKG_BUILD_DIR)/include/linux/ssb \
+ $(PKG_BUILD_DIR)/include/linux/bcma \
+ $(PKG_BUILD_DIR)/include/net/bluetooth
+
+ rm -f \
+ $(PKG_BUILD_DIR)/include/linux/cordic.h \
+ $(PKG_BUILD_DIR)/include/linux/crc8.h \
+ $(PKG_BUILD_DIR)/include/linux/eeprom_93cx6.h \
+ $(PKG_BUILD_DIR)/include/linux/wl12xx.h \
+ $(PKG_BUILD_DIR)/include/linux/spi/libertas_spi.h \
+ $(PKG_BUILD_DIR)/include/net/ieee80211.h
+
+ echo 'compat-wireless-$(PKG_VERSION)-$(PKG_RELEASE)-$(REVISION)' > $(PKG_BUILD_DIR)/compat_version
+ $(CP) ./files/regdb.txt $(PKG_BUILD_DIR)/net/wireless/db.txt
+
+ sed -i $(foreach config,$(DISABLE_CONFIG),-e 's,^\([ ]*export *CONFIG_$(config)=\),# \1,') $(PKG_BUILD_DIR)/config.mk
+endef
+
+ifneq ($(CONFIG_PACKAGE_kmod-cfg80211)$(CONFIG_PACKAGE_kmod-lib80211),)
+ define Build/Compile/kmod
+ rm -rf $(PKG_BUILD_DIR)/modules
+ +$(MAKE) $(PKG_JOBS) -C "$(PKG_BUILD_DIR)" $(MAKE_OPTS) modules
+ endef
+endif
+
+define Build/Configure
+ cmp $(PKG_BUILD_DIR)/include/linux/ath9k_platform.h $(LINUX_DIR)/include/linux/ath9k_platform.h
+ cmp $(PKG_BUILD_DIR)/include/linux/ath5k_platform.h $(LINUX_DIR)/include/linux/ath5k_platform.h
+ cmp $(PKG_BUILD_DIR)/include/linux/rt2x00_platform.h $(LINUX_DIR)/include/linux/rt2x00_platform.h
+endef
+
+define Build/Compile
+ $(call Build/Compile/kmod)
+endef
+
+define Build/InstallDev
+ mkdir -p \
+ $(1)/usr/include/mac80211 \
+ $(1)/usr/include/mac80211/ath \
+ $(1)/usr/include/net/mac80211
+ $(CP) $(PKG_BUILD_DIR)/net/mac80211/*.h $(PKG_BUILD_DIR)/include/* $(1)/usr/include/mac80211/
+ $(CP) $(PKG_BUILD_DIR)/net/mac80211/rate.h $(1)/usr/include/net/mac80211/
+ $(CP) $(PKG_BUILD_DIR)/drivers/net/wireless/ath/*.h $(1)/usr/include/mac80211/ath/
+endef
+
+define KernelPackage/libertas-usb/install
+ $(INSTALL_DIR) $(1)/lib/firmware/libertas
+ $(INSTALL_DATA) \
+ $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/libertas/usb8388_v9.bin \
+ $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/libertas/usb8682.bin \
+ $(1)/lib/firmware/libertas/
+endef
+
+define KernelPackage/libertas-sd/install
+ $(INSTALL_DIR) $(1)/lib/firmware/libertas
+ $(INSTALL_DATA) \
+ $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/libertas/sd8385_helper.bin \
+ $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/libertas/sd8385.bin \
+ $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/libertas/sd8686_v9_helper.bin \
+ $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/libertas/sd8686_v9.bin \
+ $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/libertas/sd8688_helper.bin \
+ $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/libertas/sd8688.bin \
+ $(1)/lib/firmware/libertas
+endef
+
+define KernelPackage/cfg80211/install
+ $(INSTALL_DIR) $(1)/lib/wifi
+ $(INSTALL_DATA) ./files/lib/wifi/mac80211.sh $(1)/lib/wifi
+endef
+
+define KernelPackage/p54-pci/install
+ $(INSTALL_DIR) $(1)/lib/firmware
+ $(INSTALL_DATA) $(DL_DIR)/$(P54PCIFW) $(1)/lib/firmware/isl3886pci
+endef
+
+define KernelPackage/p54-usb/install
+ $(INSTALL_DIR) $(1)/lib/firmware
+ $(INSTALL_DATA) $(DL_DIR)/$(P54USBFW) $(1)/lib/firmware/isl3887usb
+endef
+
+define KernelPackage/p54-spi/install
+ $(INSTALL_DIR) $(1)/lib/firmware
+ $(INSTALL_DATA) $(DL_DIR)/$(P54SPIFW) $(1)/lib/firmware/3826.arm
+endef
+
+define KernelPackage/rt61-pci/install
+ $(INSTALL_DIR) $(1)/lib/firmware
+ $(INSTALL_DATA) \
+ $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/rt2561.bin \
+ $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/rt2561s.bin \
+ $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/rt2661.bin \
+ $(1)/lib/firmware/
+endef
+
+define KernelPackage/rt73-usb/install
+ $(INSTALL_DIR) $(1)/lib/firmware
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/rt73.bin $(1)/lib/firmware/
+endef
+
+define KernelPackage/rt2800-pci/install
+ $(INSTALL_DIR) $(1)/lib/firmware
+ $(INSTALL_DATA) \
+ $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/rt2860.bin \
+ $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/rt3290.bin \
+ $(1)/lib/firmware
+endef
+
+define KernelPackage/rt2800-usb/install
+ $(INSTALL_DIR) $(1)/lib/firmware
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/rt2870.bin $(1)/lib/firmware/
+endef
+
+define KernelPackage/wl12xx/install
+ $(INSTALL_DIR) $(1)/lib/firmware/ti-connectivity
+ $(INSTALL_DATA) \
+ $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/ti-connectivity/wl127x-fw-5-mr.bin \
+ $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/ti-connectivity/wl127x-fw-5-plt.bin \
+ $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/ti-connectivity/wl127x-fw-5-sr.bin \
+ $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/ti-connectivity/wl1271-nvs.bin \
+ $(1)/lib/firmware/ti-connectivity
+endef
+
+
+define KernelPackage/zd1211rw/install
+ $(INSTALL_DIR) $(1)/lib/firmware/zd1211
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/$(ZD1211FW_NAME)/zd1211* $(1)/lib/firmware/zd1211
+endef
+
+define KernelPackage/ath9k-htc/install
+ $(INSTALL_DIR) $(1)/lib/firmware
+ $(INSTALL_DATA) \
+ $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/htc_9271.fw \
+ $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/htc_7010.fw \
+ $(1)/lib/firmware/
+endef
+
+define KernelPackage/mwl8k/install
+ $(INSTALL_DIR) $(1)/lib/firmware/mwl8k
+ $(INSTALL_DATA) \
+ $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/mwl8k/fmimage_8366_ap-3.fw \
+ $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/mwl8k/fmimage_8366.fw \
+ $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/mwl8k/helper_8366.fw \
+ $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/mwl8k/fmimage_8687.fw \
+ $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/mwl8k/helper_8687.fw \
+ $(1)/lib/firmware/mwl8k/
+endef
+
+define KernelPackage/net-ipw2100/install
+ $(INSTALL_DIR) $(1)/lib/firmware
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/ipw2100-$(IPW2100_VERSION)*.fw $(1)/lib/firmware
+endef
+
+define KernelPackage/net-ipw2200/install
+ $(INSTALL_DIR) $(1)/lib/firmware
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/$(IPW2200_NAME)-$(IPW2200_VERSION)/ipw2200*.fw $(1)/lib/firmware
+endef
+
+define KernelPackage/iwlagn/install
+ $(INSTALL_DIR) $(1)/lib/firmware
+ifneq ($(CONFIG_IWL5000_FW),)
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/iwlwifi-5000-5.ucode $(1)/lib/firmware
+endif
+ifneq ($(CONFIG_IWL5150_FW),)
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/iwlwifi-5150-2.ucode $(1)/lib/firmware
+endif
+ifneq ($(CONFIG_IWL1000_FW),)
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/iwlwifi-1000-5.ucode $(1)/lib/firmware
+endif
+ifneq ($(CONFIG_IWL6000_FW),)
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/iwlwifi-6000-4.ucode $(1)/lib/firmware
+endif
+ifneq ($(CONFIG_IWL6050_FW),)
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/iwlwifi-6050-5.ucode $(1)/lib/firmware
+endif
+ifneq ($(CONFIG_IWL6005_FW),)
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/iwlwifi-6000g2a-6.ucode $(1)/lib/firmware
+endif
+ifneq ($(CONFIG_IWL6030_FW),)
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/iwlwifi-6000g2b-6.ucode $(1)/lib/firmware
+endif
+ifneq ($(CONFIG_IWL100_FW),)
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/iwlwifi-100-5.ucode $(1)/lib/firmware
+endif
+ifneq ($(CONFIG_IWL2000_FW),)
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/iwlwifi-2000-6.ucode $(1)/lib/firmware
+endif
+ifneq ($(CONFIG_IWL2030_FW),)
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/iwlwifi-2030-6.ucode $(1)/lib/firmware
+endif
+ifneq ($(CONFIG_IWL105_FW),)
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/iwlwifi-105-6.ucode $(1)/lib/firmware
+endif
+ifneq ($(CONFIG_IWL135_FW),)
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/iwlwifi-135-6.ucode $(1)/lib/firmware
+endif
+endef
+
+define KernelPackage/iwl3945/install
+ $(INSTALL_DIR) $(1)/lib/firmware
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/iwlwifi-3945-2.ucode $(1)/lib/firmware
+endef
+
+define KernelPackage/iwl4965/install
+ $(INSTALL_DIR) $(1)/lib/firmware
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/iwlwifi-4965-2.ucode $(1)/lib/firmware
+endef
+
+define KernelPackage/b43/install
+ rm -rf $(1)/lib/firmware/
+ifeq ($(CONFIG_B43_OPENFIRMWARE),y)
+ tar xzf "$(DL_DIR)/$(PKG_B43_FWV4_SOURCE)" -C "$(PKG_BUILD_DIR)"
+else
+ tar xjf "$(DL_DIR)/$(PKG_B43_FWV4_SOURCE)" -C "$(PKG_BUILD_DIR)"
+endif
+ $(INSTALL_DIR) $(1)/lib/firmware/
+ifeq ($(CONFIG_B43_OPENFIRMWARE),y)
+ $(MAKE) -C "$(PKG_BUILD_DIR)/$(PKG_B43_FWV4_OBJECT)/"
+ $(INSTALL_DIR) $(1)/lib/firmware/b43-open/
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/$(PKG_B43_FWV4_OBJECT)/ucode5.fw $(1)/lib/firmware/b43-open/ucode5.fw
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/$(PKG_B43_FWV4_OBJECT)/b0g0bsinitvals5.fw $(1)/lib/firmware/b43-open/b0g0bsinitvals5.fw
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/$(PKG_B43_FWV4_OBJECT)/b0g0initvals5.fw $(1)/lib/firmware/b43-open/b0g0initvals5.fw
+else
+ b43-fwcutter -w $(1)/lib/firmware/ $(PKG_BUILD_DIR)/$(PKG_B43_FWV4_OBJECT)
+endif
+ifneq ($(CONFIG_B43_FW_SQUASH),)
+ b43-fwsquash.py "$(CONFIG_B43_FW_SQUASH_PHYTYPES)" "$(CONFIG_B43_FW_SQUASH_COREREVS)" "$(1)/lib/firmware/b43"
+endif
+endef
+
+define KernelPackage/b43legacy/install
+ $(INSTALL_DIR) $(1)/lib/firmware/
+ b43-fwcutter --unsupported -w $(1)/lib/firmware/ $(DL_DIR)/$(PKG_B43_FWV3_SOURCE)
+ifneq ($(CONFIG_B43LEGACY_FW_SQUASH),)
+ b43-fwsquash.py "G" "$(CONFIG_B43LEGACY_FW_SQUASH_COREREVS)" "$(1)/lib/firmware/b43legacy"
+endif
+endef
+
+define KernelPackage/brcmsmac/install
+ $(INSTALL_DIR) $(1)/lib/firmware/brcm
+ifeq ($(CONFIG_BRCMSMAC_USE_FW_FROM_WL),y)
+ tar xjf "$(DL_DIR)/$(PKG_BRCMSMAC_FW_SOURCE)" -C "$(PKG_BUILD_DIR)"
+ b43-fwcutter --brcmsmac -w $(1)/lib/firmware/ $(PKG_BUILD_DIR)/$(PKG_BRCMSMAC_FW_OBJECT)
+else
+ $(INSTALL_DATA) \
+ $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/brcm/bcm43xx-0.fw \
+ $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/brcm/bcm43xx_hdr-0.fw \
+ $(1)/lib/firmware/brcm/
+endif
+endef
+
+define KernelPackage/brcmfmac/install
+ $(INSTALL_DIR) $(1)/lib/firmware/brcm
+ $(INSTALL_DATA) \
+ $(PKG_BUILD_DIR)/$(PKG_LINUX_FIRMWARE_SUBDIR)/brcm/brcmfmac43236b.bin \
+ $(1)/lib/firmware/brcm/
+endef
+
+$(eval $(call KernelPackage,adm8211))
+$(eval $(call KernelPackage,ath5k))
+$(eval $(call KernelPackage,lib80211))
+$(eval $(call KernelPackage,libertas-usb))
+$(eval $(call KernelPackage,libertas-sd))
+$(eval $(call KernelPackage,cfg80211))
+$(eval $(call KernelPackage,mac80211))
+$(eval $(call KernelPackage,p54-common))
+$(eval $(call KernelPackage,p54-pci))
+$(eval $(call KernelPackage,p54-usb))
+$(eval $(call KernelPackage,p54-spi))
+$(eval $(call KernelPackage,rt2x00-lib))
+$(eval $(call KernelPackage,rt2x00-pci))
+$(eval $(call KernelPackage,rt2x00-usb))
+$(eval $(call KernelPackage,rt2x00-soc))
+$(eval $(call KernelPackage,rt2800-lib))
+$(eval $(call KernelPackage,rt2400-pci))
+$(eval $(call KernelPackage,rt2500-pci))
+$(eval $(call KernelPackage,rt2500-usb))
+$(eval $(call KernelPackage,rt61-pci))
+$(eval $(call KernelPackage,rt73-usb))
+$(eval $(call KernelPackage,rt2800-pci))
+$(eval $(call KernelPackage,rt2800-usb))
+$(eval $(call KernelPackage,rtl8180))
+$(eval $(call KernelPackage,rtl8187))
+$(eval $(call KernelPackage,zd1211rw))
+$(eval $(call KernelPackage,mac80211-hwsim))
+$(eval $(call KernelPackage,ath9k-common))
+$(eval $(call KernelPackage,ath9k))
+$(eval $(call KernelPackage,ath9k-htc))
+$(eval $(call KernelPackage,ath))
+$(eval $(call KernelPackage,carl9170))
+$(eval $(call KernelPackage,b43))
+$(eval $(call KernelPackage,b43legacy))
+$(eval $(call KernelPackage,brcmutil))
+$(eval $(call KernelPackage,brcmsmac))
+$(eval $(call KernelPackage,brcmfmac))
+$(eval $(call KernelPackage,net-libipw))
+$(eval $(call KernelPackage,net-ipw2100))
+$(eval $(call KernelPackage,net-ipw2200))
+$(eval $(call KernelPackage,iwlagn))
+$(eval $(call KernelPackage,iwl-legacy))
+$(eval $(call KernelPackage,iwl4965))
+$(eval $(call KernelPackage,iwl3945))
+$(eval $(call KernelPackage,mwl8k))
+$(eval $(call KernelPackage,net-hermes))
+$(eval $(call KernelPackage,net-hermes-pci))
+$(eval $(call KernelPackage,net-hermes-plx))
+$(eval $(call KernelPackage,net-hermes-pcmcia))
+$(eval $(call KernelPackage,wl12xx))
diff --git a/package/mac80211/files/.svn/entries b/package/mac80211/files/.svn/entries
new file mode 100644
index 0000000..16110bf
--- /dev/null
+++ b/package/mac80211/files/.svn/entries
@@ -0,0 +1,68 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/mac80211/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-12T13:52:20.922845Z
+35986
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+regdb.txt
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+9edecdce4b0536148a643fe36efd7830
+2012-06-08T12:09:36.088683Z
+32126
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+17490
+
+host_bin
+dir
+
+lib
+dir
+
diff --git a/package/mac80211/files/.svn/text-base/regdb.txt.svn-base b/package/mac80211/files/.svn/text-base/regdb.txt.svn-base
new file mode 100644
index 0000000..b250e69
--- /dev/null
+++ b/package/mac80211/files/.svn/text-base/regdb.txt.svn-base
@@ -0,0 +1,697 @@
+# This is the world regulatory domain
+country 00:
+ (2402 - 2472 @ 40), (3, 20)
+ # Channel 12 - 13. No HT40 channel fits here
+ (2457 - 2482 @ 20), (3, 20), PASSIVE-SCAN, NO-IBSS
+ # Channel 14. Only JP enables this and for 802.11b only
+ (2474 - 2494 @ 20), (3, 20), PASSIVE-SCAN, NO-IBSS, NO-OFDM
+ # Channel 36 - 48
+ (5170 - 5250 @ 40), (3, 20)
+ # NB: 5260 MHz - 5700 MHz requies DFS
+ # Channel 149 - 165
+ (5735 - 5835 @ 40), (3, 20), PASSIVE-SCAN, NO-IBSS
+
+
+country AE:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country AL:
+ (2402 - 2482 @ 20), (N/A, 20)
+
+country AM:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 20), (N/A, 18)
+ (5250 - 5330 @ 20), (N/A, 18), DFS
+
+country AN:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country AR:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (3, 17)
+ (5250 - 5330 @ 40), (3, 20), DFS
+ (5490 - 5710 @ 40), (3, 20), DFS
+ (5735 - 5835 @ 40), (3, 30)
+
+country AT: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country AU:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (3, 23)
+ (5250 - 5330 @ 40), (3, 23), DFS
+ (5735 - 5835 @ 40), (3, 30)
+
+country AW:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country AZ:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 18)
+ (5250 - 5330 @ 40), (N/A, 18), DFS
+
+country BA: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country BB:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (3, 23)
+ (5250 - 5330 @ 40), (3, 23), DFS
+ (5735 - 5835 @ 40), (3, 30)
+
+country BD:
+ (2402 - 2482 @ 40), (N/A, 20)
+
+country BE: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country BG: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 23)
+ (5250 - 5290 @ 40), (N/A, 23), DFS
+ (5490 - 5710 @ 40), (N/A, 30), DFS
+
+country BH:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 20), (N/A, 20)
+ (5250 - 5330 @ 20), (N/A, 20), DFS
+ (5735 - 5835 @ 20), (N/A, 20)
+
+country BL:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 18)
+ (5250 - 5330 @ 40), (N/A, 18), DFS
+
+country BN:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5735 - 5835 @ 40), (N/A, 30)
+
+country BO:
+ (2402 - 2482 @ 40), (N/A, 30)
+ (5735 - 5835 @ 40), (N/A, 30)
+
+country BR:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (3, 17)
+ (5250 - 5330 @ 40), (3, 20), DFS
+ (5490 - 5710 @ 40), (3, 20), DFS
+ (5735 - 5835 @ 40), (3, 30)
+
+country BY:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country BZ:
+ (2402 - 2482 @ 40), (N/A, 30)
+ (5735 - 5835 @ 40), (N/A, 30)
+
+country CA:
+ (2402 - 2472 @ 40), (3, 27)
+ (5170 - 5250 @ 40), (3, 17)
+ (5250 - 5330 @ 40), (3, 20), DFS
+ (5490 - 5710 @ 40), (3, 20), DFS
+ (5735 - 5835 @ 40), (3, 30)
+
+country CH: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country CL:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5735 - 5835 @ 40), (N/A, 20)
+
+country CN:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5735 - 5835 @ 40), (N/A, 30)
+
+country CO:
+ (2402 - 2472 @ 40), (3, 27)
+ (5170 - 5250 @ 40), (3, 17)
+ (5250 - 5330 @ 40), (3, 23), DFS
+ (5735 - 5835 @ 40), (3, 30)
+
+country CR:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 20), (3, 17)
+ (5250 - 5330 @ 20), (3, 23), DFS
+ (5735 - 5835 @ 20), (3, 30)
+
+country CS:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country CY: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+# Data from http://www.ctu.eu/164/download/VOR/VOR-12-08-2005-34.pdf
+# and http://www.ctu.eu/164/download/VOR/VOR-12-05-2007-6-AN.pdf
+# Power at 5250 - 5350 MHz and 5470 - 5725 MHz can be doubled if TPC is
+# implemented.
+country CZ: DFS-ETSI
+ (2400 - 2483.5 @ 40), (N/A, 100 mW)
+ (5150 - 5250 @ 40), (N/A, 200 mW), NO-OUTDOOR
+ (5250 - 5350 @ 40), (N/A, 100 mW), NO-OUTDOOR, DFS
+ (5470 - 5725 @ 40), (N/A, 500 mW), DFS
+
+# Data from "Frequenznutzungsplan" (as published in April 2008), downloaded from
+# http://www.bundesnetzagentur.de/cae/servlet/contentblob/38448/publicationFile/2659/Frequenznutzungsplan2008_Id17448pdf.pdf
+# For the 5GHz range also see
+# http://www.bundesnetzagentur.de/cae/servlet/contentblob/38216/publicationFile/6579/WLAN5GHzVfg7_2010_28042010pdf.pdf
+# The values have been reduced by a factor of 2 (3db) for non TPC devices
+# (in other words: devices with TPC can use twice the tx power of this table).
+# Note that the docs do not require TPC for 5150--5250; the reduction to
+# 100mW thus is not strictly required -- however the conservative 100mW
+# limit is used here as the non-interference with radar and satellite
+# apps relies on the attenuation by the building walls only in the
+# absence of DFS; the neighbour countries have 100mW limit here as well.
+
+country DE: DFS-ETSI
+ # entries 279004 and 280006
+ (2400 - 2483.5 @ 40), (N/A, 100 mW)
+ # entry 303005
+ (5150 - 5250 @ 40), (N/A, 100 mW), NO-OUTDOOR
+ # entries 304002 and 305002
+ (5250 - 5350 @ 40), (N/A, 100 mW), NO-OUTDOOR, DFS
+ # entries 308002, 309001 and 310003
+ (5470 - 5725 @ 40), (N/A, 500 mW), DFS
+
+country DK: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country DO:
+ (2402 - 2472 @ 40), (3, 27)
+ (5170 - 5250 @ 40), (3, 17)
+ (5250 - 5330 @ 40), (3, 23), DFS
+ (5735 - 5835 @ 40), (3, 30)
+
+country DZ:
+ (2402 - 2482 @ 40), (N/A, 20)
+
+country EC:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 20), (3, 17)
+ (5250 - 5330 @ 20), (3, 23), DFS
+ (5735 - 5835 @ 20), (3, 30)
+
+country EE: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country EG:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 20), (N/A, 20)
+ (5250 - 5330 @ 20), (N/A, 20), DFS
+
+country ES: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country FI: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country FR: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country GE:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 18)
+ (5250 - 5330 @ 40), (N/A, 18), DFS
+
+country GB: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country GD:
+ (2402 - 2472 @ 40), (3, 27)
+ (5170 - 5250 @ 40), (3, 17)
+ (5250 - 5330 @ 40), (3, 20), DFS
+ (5490 - 5710 @ 40), (3, 20), DFS
+ (5735 - 5835 @ 40), (3, 30)
+
+country GR: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country GL: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 20), (N/A, 20)
+ (5250 - 5330 @ 20), (N/A, 20), DFS
+ (5490 - 5710 @ 20), (N/A, 27), DFS
+
+country GT:
+ (2402 - 2472 @ 40), (3, 27)
+ (5170 - 5250 @ 40), (3, 17)
+ (5250 - 5330 @ 40), (3, 23), DFS
+ (5735 - 5835 @ 40), (3, 30)
+
+country GU:
+ (2402 - 2472 @ 40), (3, 27)
+ (5170 - 5250 @ 20), (3, 17)
+ (5250 - 5330 @ 20), (3, 23), DFS
+ (5735 - 5835 @ 20), (3, 30)
+
+country HN:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (3, 17)
+ (5250 - 5330 @ 40), (3, 20), DFS
+ (5490 - 5710 @ 40), (3, 20), DFS
+ (5735 - 5835 @ 40), (3, 30)
+
+country HK:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (3, 17)
+ (5250 - 5330 @ 40), (3, 20), DFS
+ (5490 - 5710 @ 40), (3, 20), DFS
+ (5735 - 5835 @ 40), (3, 30)
+
+country HR: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country HT:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country HU: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country ID:
+ (2402 - 2482 @ 40), (N/A, 20)
+
+country IE: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country IL:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5150 - 5250 @ 40), (N/A, 200 mW), NO-OUTDOOR
+ (5250 - 5350 @ 40), (N/A, 200 mW), NO-OUTDOOR, DFS
+
+country IN:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5735 - 5835 @ 40), (N/A, 20)
+
+country IS: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country IR:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5735 - 5835 @ 40), (N/A, 30)
+
+country IT: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country JM:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (3, 17)
+ (5250 - 5330 @ 40), (3, 20), DFS
+ (5490 - 5710 @ 40), (3, 20), DFS
+ (5735 - 5835 @ 40), (3, 30)
+
+country JP:
+ (2402 - 2472 @ 40), (N/A, 20)
+ (2457 - 2482 @ 20), (N/A, 20)
+ (2474 - 2494 @ 20), (N/A, 20), NO-OFDM
+ (4910 - 4930 @ 10), (N/A, 23)
+ (4910 - 4990 @ 40), (N/A, 23)
+ (4930 - 4950 @ 10), (N/A, 23)
+ (5030 - 5045 @ 10), (N/A, 23)
+ (5030 - 5090 @ 40), (N/A, 23)
+ (5050 - 5060 @ 10), (N/A, 23)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 23), DFS
+
+country JO:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 18)
+
+country KE:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5735 - 5835 @ 40), (N/A, 30)
+
+country KH:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country KP:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5330 @ 40), (3, 20)
+ (5160 - 5250 @ 40), (3, 20), DFS
+ (5490 - 5630 @ 40), (3, 30), DFS
+ (5735 - 5815 @ 40), (3, 30)
+
+country KR:
+ (2402 - 2482 @ 20), (N/A, 20)
+ (5170 - 5250 @ 20), (3, 20)
+ (5250 - 5330 @ 20), (3, 20), DFS
+ (5490 - 5630 @ 20), (3, 30), DFS
+ (5735 - 5815 @ 20), (3, 30)
+
+country KW:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+
+country KZ:
+ (2402 - 2482 @ 40), (N/A, 20)
+
+country LB:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5735 - 5835 @ 40), (N/A, 30)
+
+country LI: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country LK:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 20), (3, 17)
+ (5250 - 5330 @ 20), (3, 20), DFS
+ (5490 - 5710 @ 20), (3, 20), DFS
+ (5735 - 5835 @ 20), (3, 30)
+
+country LT: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country LU: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country LV: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country MC: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 18)
+ (5250 - 5330 @ 40), (N/A, 18), DFS
+
+country MA:
+ (2402 - 2482 @ 40), (N/A, 20)
+
+country MO:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (3, 23)
+ (5250 - 5330 @ 40), (3, 23), DFS
+ (5735 - 5835 @ 40), (3, 30)
+
+country MK: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country MT: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country MY:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 30), DFS
+ (5735 - 5835 @ 40), (N/A, 30)
+
+country MX:
+ (2402 - 2472 @ 40), (3, 27)
+ (5170 - 5250 @ 40), (3, 17)
+ (5250 - 5330 @ 40), (3, 23), DFS
+ (5735 - 5835 @ 40), (3, 30)
+
+country NL: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20), NO-OUTDOOR
+ (5250 - 5330 @ 40), (N/A, 20), NO-OUTDOOR, DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country NO: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country NP:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5735 - 5835 @ 40), (N/A, 30)
+
+country NZ:
+ (2402 - 2482 @ 40), (N/A, 30)
+ (5170 - 5250 @ 20), (3, 23)
+ (5250 - 5330 @ 20), (3, 23), DFS
+ (5735 - 5835 @ 20), (3, 30)
+
+country OM:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (3, 17)
+ (5250 - 5330 @ 40), (3, 20), DFS
+ (5490 - 5710 @ 40), (3, 20), DFS
+ (5735 - 5835 @ 40), (3, 30)
+
+country PA:
+ (2402 - 2472 @ 40), (3, 27)
+ (5170 - 5250 @ 40), (3, 17)
+ (5250 - 5330 @ 40), (3, 23), DFS
+ (5735 - 5835 @ 40), (3, 30)
+
+country PE:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5735 - 5835 @ 40), (N/A, 30)
+
+country PG:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (3, 17)
+ (5250 - 5330 @ 40), (3, 23), DFS
+ (5735 - 5835 @ 40), (3, 30)
+
+country PH:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5735 - 5835 @ 40), (N/A, 30)
+
+country PK:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5735 - 5835 @ 40), (N/A, 30)
+
+country PL: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country PT: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country PR:
+ (2402 - 2472 @ 40), (3, 27)
+ (5170 - 5250 @ 40), (3, 17)
+ (5250 - 5330 @ 40), (3, 23), DFS
+ (5735 - 5835 @ 40), (3, 30)
+
+country QA:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5735 - 5835 @ 40), (N/A, 30)
+
+country RO: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country RU:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5735 - 5835 @ 20), (N/A, 30)
+
+country SA:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 20), (3, 23)
+ (5250 - 5330 @ 20), (3, 23), DFS
+ (5735 - 5835 @ 20), (3, 30)
+
+country SE: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country SG:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5735 - 5835 @ 40), (N/A, 20)
+
+country SI: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country SK: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country SV:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 20), (3, 17)
+ (5250 - 5330 @ 20), (3, 23), DFS
+ (5735 - 5835 @ 20), (3, 30)
+
+country SY:
+ (2402 - 2482 @ 40), (N/A, 20)
+
+country TW:
+ (2402 - 2472 @ 40), (3, 27)
+ (5270 - 5330 @ 40), (3, 17), DFS
+ (5735 - 5815 @ 40), (3, 30)
+
+country TH:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (3, 17)
+ (5250 - 5330 @ 40), (3, 20), DFS
+ (5490 - 5710 @ 40), (3, 20), DFS
+ (5735 - 5835 @ 40), (3, 30)
+
+country TT:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (3, 17)
+ (5250 - 5330 @ 40), (3, 20), DFS
+ (5490 - 5710 @ 40), (3, 20), DFS
+ (5735 - 5835 @ 40), (3, 30)
+
+country TN:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 20), (N/A, 20)
+ (5250 - 5330 @ 20), (N/A, 20), DFS
+
+country TR: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 20), (N/A, 20)
+ (5250 - 5330 @ 20), (N/A, 20), DFS
+
+country UA:
+ (2402 - 2482 @ 40), (N/A, 20)
+
+country US: DFS-FCC
+ (2402 - 2472 @ 40), (3, 27)
+ (5170 - 5250 @ 40), (3, 17)
+ (5250 - 5330 @ 40), (3, 20), DFS
+ (5490 - 5600 @ 40), (3, 20), DFS
+ (5650 - 5710 @ 40), (3, 20), DFS
+ (5735 - 5835 @ 40), (3, 30)
+
+country UY:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (3, 17)
+ (5250 - 5330 @ 40), (3, 20), DFS
+ (5490 - 5710 @ 40), (3, 20), DFS
+ (5735 - 5835 @ 40), (3, 30)
+
+country UZ:
+ (2402 - 2472 @ 40), (3, 27)
+ (5170 - 5250 @ 40), (3, 17)
+ (5250 - 5330 @ 40), (3, 20), DFS
+ (5490 - 5710 @ 40), (3, 20), DFS
+ (5735 - 5835 @ 40), (3, 30)
+
+country VE:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5735 - 5815 @ 40), (N/A, 23)
+
+country VN:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+
+country YE:
+ (2402 - 2482 @ 40), (N/A, 20)
+
+country ZA:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (3, 17)
+ (5250 - 5330 @ 40), (3, 20), DFS
+ (5490 - 5710 @ 40), (3, 20), DFS
+ (5735 - 5835 @ 40), (3, 30)
+
+country ZW:
+ (2402 - 2482 @ 40), (N/A, 20)
+
diff --git a/package/mac80211/files/host_bin/.svn/entries b/package/mac80211/files/host_bin/.svn/entries
new file mode 100644
index 0000000..01ee89c
--- /dev/null
+++ b/package/mac80211/files/host_bin/.svn/entries
@@ -0,0 +1,28 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/mac80211/files/host_bin
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-08T20:15:42.151953Z
+33668
+hauke
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
diff --git a/package/mac80211/files/lib/.svn/entries b/package/mac80211/files/lib/.svn/entries
new file mode 100644
index 0000000..6d0c37d
--- /dev/null
+++ b/package/mac80211/files/lib/.svn/entries
@@ -0,0 +1,31 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/mac80211/files/lib
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-12T13:52:20.922845Z
+35986
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+wifi
+dir
+
diff --git a/package/mac80211/files/lib/wifi/.svn/entries b/package/mac80211/files/lib/wifi/.svn/entries
new file mode 100644
index 0000000..5ec8210
--- /dev/null
+++ b/package/mac80211/files/lib/wifi/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/mac80211/files/lib/wifi
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-12T13:52:20.922845Z
+35986
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+mac80211.sh
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+9fb97b95bc2da8cdeb7367da9461acb0
+2013-03-12T13:52:20.922845Z
+35986
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+16368
+
diff --git a/package/mac80211/files/lib/wifi/.svn/text-base/mac80211.sh.svn-base b/package/mac80211/files/lib/wifi/.svn/text-base/mac80211.sh.svn-base
new file mode 100644
index 0000000..4c214e8
--- /dev/null
+++ b/package/mac80211/files/lib/wifi/.svn/text-base/mac80211.sh.svn-base
@@ -0,0 +1,606 @@
+#!/bin/sh
+append DRIVERS "mac80211"
+
+mac80211_hostapd_setup_base() {
+ local phy="$1"
+ local ifname="$2"
+
+ cfgfile="/var/run/hostapd-$phy.conf"
+
+ config_get device "$vif" device
+ config_get country "$device" country
+ config_get hwmode "$device" hwmode
+ config_get channel "$device" channel
+ config_get beacon_int "$device" beacon_int
+ config_get basic_rate_list "$device" basic_rate
+ config_get_bool noscan "$device" noscan
+
+ hostapd_set_log_options base_cfg "$device"
+
+ [ -n "$channel" -a -z "$hwmode" ] && wifi_fixup_hwmode "$device"
+
+ [ "$channel" = auto ] && {
+ channel=$(iw phy "$phy" info | \
+ sed -ne '/MHz/ { /disabled\|passive\|radar/d; s/.*\[//; s/\].*//; p; q }')
+ config_set "$device" channel "$channel"
+ }
+
+ [ -n "$hwmode" ] && {
+ config_get hwmode_11n "$device" hwmode_11n
+ [ -n "$hwmode_11n" ] && {
+ hwmode="$hwmode_11n"
+ append base_cfg "ieee80211n=1" "$N"
+ config_get htmode "$device" htmode
+ config_get ht_capab_list "$device" ht_capab
+ case "$htmode" in
+ HT20|HT40+|HT40-) ht_capab="[$htmode]";;
+ *)ht_capab=;;
+ esac
+ for cap in $ht_capab_list; do
+ ht_capab="$ht_capab[$cap]"
+ done
+ [ -n "$ht_capab" ] && append base_cfg "ht_capab=$ht_capab" "$N"
+ }
+ }
+
+ local country_ie=0
+ [ -n "$country" ] && country_ie=1
+ config_get_bool country_ie "$device" country_ie "$country_ie"
+ [ "$country_ie" -gt 0 ] && append base_cfg "ieee80211d=1" "$N"
+
+ local br brval brstr
+ [ -n "$basic_rate_list" ] && {
+ for br in $basic_rate_list; do
+ brval="$(($br / 100))"
+ [ -n "$brstr" ] && brstr="$brstr "
+ brstr="$brstr$brval"
+ done
+ }
+
+ cat >> "$cfgfile" <<EOF
+ctrl_interface=/var/run/hostapd-$phy
+driver=nl80211
+wmm_ac_bk_cwmin=4
+wmm_ac_bk_cwmax=10
+wmm_ac_bk_aifs=7
+wmm_ac_bk_txop_limit=0
+wmm_ac_bk_acm=0
+wmm_ac_be_aifs=3
+wmm_ac_be_cwmin=4
+wmm_ac_be_cwmax=10
+wmm_ac_be_txop_limit=0
+wmm_ac_be_acm=0
+wmm_ac_vi_aifs=2
+wmm_ac_vi_cwmin=3
+wmm_ac_vi_cwmax=4
+wmm_ac_vi_txop_limit=94
+wmm_ac_vi_acm=0
+wmm_ac_vo_aifs=2
+wmm_ac_vo_cwmin=2
+wmm_ac_vo_cwmax=3
+wmm_ac_vo_txop_limit=47
+wmm_ac_vo_acm=0
+tx_queue_data3_aifs=7
+tx_queue_data3_cwmin=15
+tx_queue_data3_cwmax=1023
+tx_queue_data3_burst=0
+tx_queue_data2_aifs=3
+tx_queue_data2_cwmin=15
+tx_queue_data2_cwmax=63
+tx_queue_data2_burst=0
+tx_queue_data1_aifs=1
+tx_queue_data1_cwmin=7
+tx_queue_data1_cwmax=15
+tx_queue_data1_burst=3.0
+tx_queue_data0_aifs=1
+tx_queue_data0_cwmin=3
+tx_queue_data0_cwmax=7
+tx_queue_data0_burst=1.5
+${hwmode:+hw_mode=$hwmode}
+${channel:+channel=$channel}
+${beacon_int:+beacon_int=$beacon_int}
+${country:+country_code=$country}
+${noscan:+noscan=$noscan}
+${brstr:+basic_rates=$brstr}
+$base_cfg
+
+EOF
+}
+
+mac80211_hostapd_setup_bss() {
+ local phy="$1"
+ local vif="$2"
+
+ hostapd_cfg=
+ cfgfile="/var/run/hostapd-$phy.conf"
+ config_get ifname "$vif" ifname
+
+ if [ -f "$cfgfile" ]; then
+ append hostapd_cfg "bss=$ifname" "$N"
+ else
+ mac80211_hostapd_setup_base "$phy" "$ifname"
+ append hostapd_cfg "interface=$ifname" "$N"
+ fi
+
+ local net_cfg bridge
+ net_cfg="$(find_net_config "$vif")"
+ [ -z "$net_cfg" ] || bridge="$(bridge_interface "$net_cfg")"
+ config_set "$vif" bridge "$bridge"
+
+ hostapd_set_bss_options hostapd_cfg "$vif"
+
+ config_get_bool wds "$vif" wds 0
+ [ "$wds" -gt 0 ] && append hostapd_cfg "wds_sta=1" "$N"
+
+ local macaddr hidden maxassoc wmm
+ config_get macaddr "$vif" macaddr
+ config_get maxassoc "$vif" maxassoc
+ config_get dtim_period "$vif" dtim_period
+ config_get max_listen_int "$vif" max_listen_int
+ config_get_bool hidden "$vif" hidden 0
+ config_get_bool wmm "$vif" wmm 1
+ cat >> /var/run/hostapd-$phy.conf <<EOF
+$hostapd_cfg
+wmm_enabled=$wmm
+bssid=$macaddr
+ignore_broadcast_ssid=$hidden
+${dtim_period:+dtim_period=$dtim_period}
+${max_listen_int:+max_listen_interval=$max_listen_int}
+${maxassoc:+max_num_sta=$maxassoc}
+EOF
+}
+
+mac80211_start_vif() {
+ local vif="$1"
+ local ifname="$2"
+
+ local net_cfg
+ net_cfg="$(find_net_config "$vif")"
+ [ -z "$net_cfg" ] || start_net "$ifname" "$net_cfg"
+
+ set_wifi_up "$vif" "$ifname"
+}
+
+lookup_phy() {
+ [ -n "$phy" ] && {
+ [ -d /sys/class/ieee80211/$phy ] && return
+ }
+
+ local devpath
+ config_get devpath "$device" path
+ [ -n "$devpath" -a -d "/sys/devices/$devpath/ieee80211" ] && {
+ phy="$(ls /sys/devices/$devpath/ieee80211 | grep -m 1 phy)"
+ [ -n "$phy" ] && return
+ }
+
+ local macaddr="$(config_get "$device" macaddr | tr 'A-Z' 'a-z')"
+ [ -n "$macaddr" ] && {
+ for _phy in $(ls /sys/class/ieee80211 2>/dev/null); do
+ [ "$macaddr" = "$(cat /sys/class/ieee80211/${_phy}/macaddress)" ] || continue
+ phy="$_phy"
+ return
+ done
+ }
+ phy=
+ return
+}
+
+find_mac80211_phy() {
+ local device="$1"
+
+ config_get phy "$device" phy
+ lookup_phy
+ [ -n "$phy" -a -d "/sys/class/ieee80211/$phy" ] || {
+ echo "PHY for wifi device $1 not found"
+ return 1
+ }
+ config_set "$device" phy "$phy"
+
+ config_get macaddr "$device" macaddr
+ [ -z "$macaddr" ] && {
+ config_set "$device" macaddr "$(cat /sys/class/ieee80211/${phy}/macaddress)"
+ }
+
+ return 0
+}
+
+scan_mac80211() {
+ local device="$1"
+ local adhoc sta ap monitor mesh disabled
+
+ config_get vifs "$device" vifs
+ for vif in $vifs; do
+ config_get_bool disabled "$vif" disabled 0
+ [ $disabled = 0 ] || continue
+
+ config_get mode "$vif" mode
+ case "$mode" in
+ adhoc|sta|ap|monitor|mesh)
+ append $mode "$vif"
+ ;;
+ *) echo "$device($vif): Invalid mode, ignored."; continue;;
+ esac
+ done
+
+ config_set "$device" vifs "${ap:+$ap }${adhoc:+$adhoc }${sta:+$sta }${monitor:+$monitor }${mesh:+$mesh}"
+}
+
+list_phy_interfaces() {
+ local phy="$1"
+ if [ -d "/sys/class/ieee80211/${phy}/device/net" ]; then
+ ls "/sys/class/ieee80211/${phy}/device/net" 2>/dev/null;
+ else
+ ls "/sys/class/ieee80211/${phy}/device" 2>/dev/null | grep net: | sed -e 's,net:,,g'
+ fi
+}
+
+disable_mac80211() (
+ local device="$1"
+
+ find_mac80211_phy "$device" || return 0
+ config_get phy "$device" phy
+
+ set_wifi_down "$device"
+ # kill all running hostapd and wpa_supplicant processes that
+ # are running on atheros/mac80211 vifs
+ for pid in `pidof hostapd`; do
+ grep -E "$phy" /proc/$pid/cmdline >/dev/null && \
+ kill $pid
+ done
+
+ include /lib/network
+ for wdev in $(list_phy_interfaces "$phy"); do
+ [ -f "/var/run/$wdev.pid" ] && kill $(cat /var/run/$wdev.pid) >&/dev/null 2>&1
+ for pid in `pidof wpa_supplicant`; do
+ grep "$wdev" /proc/$pid/cmdline >/dev/null && \
+ kill $pid
+ done
+ ifconfig "$wdev" down 2>/dev/null
+ unbridge "$dev"
+ iw dev "$wdev" del
+ done
+
+ return 0
+)
+
+get_freq() {
+ local phy="$1"
+ local chan="$2"
+ iw "$phy" info | grep -E -m1 "(\* ${chan:-....} MHz${chan:+|\\[$chan\\]})" | grep MHz | awk '{print $2}'
+}
+
+mac80211_generate_mac() {
+ local off="$1"
+ local mac="$2"
+ local mask="$3"
+ local oIFS="$IFS"; IFS=":"; set -- $mac; IFS="$oIFS"
+
+ local b2mask=0x00
+ [ $off -gt 0 ] &&
+ [ "$mask" = "00:00:00:00:00:00" -o $(( 0x${mask%%:*} & 0x2 )) -gt 0 ] && b2mask=0x02
+
+ printf "%02x:%s:%s:%s:%02x:%02x" \
+ $(( 0x$1 | $b2mask )) $2 $3 $4 \
+ $(( (0x$5 + ($off / 0x100)) % 0x100 )) \
+ $(( (0x$6 + $off) % 0x100 ))
+}
+
+enable_mac80211() {
+ local device="$1"
+ config_get channel "$device" channel
+ config_get vifs "$device" vifs
+ config_get txpower "$device" txpower
+ config_get country "$device" country
+ config_get distance "$device" distance
+ config_get txantenna "$device" txantenna all
+ config_get rxantenna "$device" rxantenna all
+ config_get antenna_gain "$device" antenna_gain 0
+ config_get frag "$device" frag
+ config_get rts "$device" rts
+ find_mac80211_phy "$device" || return 0
+ config_get phy "$device" phy
+ local i=0
+ local macidx=0
+ local apidx=0
+ fixed=""
+ local hostapd_ctrl=""
+
+ [ -n "$country" ] && {
+ iw reg get | grep -q "^country $country:" || {
+ iw reg set "$country"
+ sleep 1
+ }
+ }
+
+ config_get chanbw "$device" chanbw
+ [ -n "$chanbw" -a -d /sys/kernel/debug/ieee80211/$phy/ath9k ] && echo "$chanbw" > /sys/kernel/debug/ieee80211/$phy/ath9k/chanbw
+ [ -n "$chanbw" -a -d /sys/kernel/debug/ieee80211/$phy/ath5k ] && echo "$chanbw" > /sys/kernel/debug/ieee80211/$phy/ath5k/bwmode
+
+ [ "$channel" = "auto" -o "$channel" = "0" ] || {
+ fixed=1
+ }
+
+ iw phy "$phy" set antenna $txantenna $rxantenna >/dev/null 2>&1
+ iw phy "$phy" set antenna_gain $antenna_gain
+
+ [ -n "$distance" ] && iw phy "$phy" set distance "$distance"
+ [ -n "$frag" ] && iw phy "$phy" set frag "${frag%%.*}"
+ [ -n "$rts" ] && iw phy "$phy" set rts "${rts%%.*}"
+
+ export channel fixed
+ # convert channel to frequency
+ local freq="$(get_freq "$phy" "${fixed:+$channel}")"
+
+ wifi_fixup_hwmode "$device" "g"
+ for vif in $vifs; do
+ config_get ifname "$vif" ifname
+ [ -n "$ifname" ] || {
+ [ $i -gt 0 ] && ifname="wlan${phy#phy}-$i" || ifname="wlan${phy#phy}"
+ }
+ config_set "$vif" ifname "$ifname"
+
+ config_get mode "$vif" mode
+ config_get ssid "$vif" ssid
+
+ # It is far easier to delete and create the desired interface
+ case "$mode" in
+ adhoc)
+ iw phy "$phy" interface add "$ifname" type adhoc
+ ;;
+ ap)
+ # Hostapd will handle recreating the interface and
+ # it's accompanying monitor
+ apidx="$(($apidx + 1))"
+ [ "$apidx" -gt 1 ] || iw phy "$phy" interface add "$ifname" type managed
+ ;;
+ mesh)
+ config_get mesh_id "$vif" mesh_id
+ iw phy "$phy" interface add "$ifname" type mp mesh_id "$mesh_id"
+ ;;
+ monitor)
+ iw phy "$phy" interface add "$ifname" type monitor
+ ;;
+ sta)
+ local wdsflag
+ config_get_bool wds "$vif" wds 0
+ [ "$wds" -gt 0 ] && wdsflag="4addr on"
+ iw phy "$phy" interface add "$ifname" type managed $wdsflag
+ config_get_bool powersave "$vif" powersave 0
+ [ "$powersave" -gt 0 ] && powersave="on" || powersave="off"
+ iw "$ifname" set power_save "$powersave"
+ ;;
+ esac
+
+ # All interfaces must have unique mac addresses
+ # which can either be explicitly set in the device
+ # section, or automatically generated
+ config_get macaddr "$device" macaddr
+ config_get vif_mac "$vif" macaddr
+ [ -n "$vif_mac" ] || {
+ vif_mac="$(mac80211_generate_mac $macidx $macaddr $(cat /sys/class/ieee80211/${phy}/address_mask))"
+ macidx="$(($macidx + 1))"
+ }
+ [ "$mode" = "ap" ] || ifconfig "$ifname" hw ether "$vif_mac"
+ config_set "$vif" macaddr "$vif_mac"
+
+ # !! ap !!
+ #
+ # ALL ap functionality will be passed to hostapd
+ #
+ # !! station !!
+ #
+ # ALL station functionality will be passed to wpa_supplicant
+ #
+ if [ ! "$mode" = "ap" ]; then
+ # We attempt to set the channel for all interfaces, although
+ # mac80211 may not support it or the driver might not yet
+ # for ap mode this is handled by hostapd
+ [ -n "$fixed" -a -n "$channel" ] && iw dev "$ifname" set channel "$channel"
+ fi
+
+ i=$(($i + 1))
+ done
+
+ local start_hostapd=
+ rm -f /var/run/hostapd-$phy.conf
+ for vif in $vifs; do
+ config_get mode "$vif" mode
+ [ "$mode" = "ap" ] || continue
+ mac80211_hostapd_setup_bss "$phy" "$vif"
+ start_hostapd=1
+ done
+
+ [ -n "$start_hostapd" ] && {
+ hostapd -P /var/run/wifi-$phy.pid -B /var/run/hostapd-$phy.conf || {
+ echo "Failed to start hostapd for $phy"
+ return
+ }
+ sleep 2
+
+ for vif in $vifs; do
+ config_get mode "$vif" mode
+ config_get ifname "$vif" ifname
+ [ "$mode" = "ap" ] || continue
+ hostapd_ctrl="${hostapd_ctrl:-/var/run/hostapd-$phy/$ifname}"
+ mac80211_start_vif "$vif" "$ifname"
+ done
+ }
+
+ for vif in $vifs; do
+ config_get mode "$vif" mode
+ config_get ifname "$vif" ifname
+ [ "$mode" = "ap" ] || ifconfig "$ifname" up
+
+ config_get vif_txpower "$vif" txpower
+ # use vif_txpower (from wifi-iface) to override txpower (from
+ # wifi-device) if the latter doesn't exist
+ txpower="${txpower:-$vif_txpower}"
+ [ -z "$txpower" ] || iw dev "$ifname" set txpower fixed "${txpower%%.*}00"
+
+ case "$mode" in
+ adhoc)
+ config_get bssid "$vif" bssid
+ config_get ssid "$vif" ssid
+ config_get beacon_int "$device" beacon_int
+ config_get basic_rate_list "$device" basic_rate
+ config_get encryption "$vif" encryption
+ config_get key "$vif" key 1
+ config_get mcast_rate "$vif" mcast_rate
+ config_get htmode "$device" htmode
+ case "$htmode" in
+ HT20|HT40+|HT40-) ;;
+ *) htmode= ;;
+ esac
+
+
+ local keyspec=""
+ [ "$encryption" == "psk" -o "$encryption" == "psk2" ] && {
+ if eval "type wpa_supplicant_setup_vif" 2>/dev/null >/dev/null; then
+ wpa_supplicant_setup_vif "$vif" nl80211 "${hostapd_ctrl:+-H $hostapd_ctrl}" $freq $htmode || {
+ echo "enable_mac80211($device): Failed to set up wpa_supplicant for interface $ifname" >&2
+ # make sure this wifi interface won't accidentally stay open without encryption
+ ifconfig "$ifname" down
+ }
+ mac80211_start_vif "$vif" "$ifname"
+ continue
+ fi
+ }
+
+ [ "$encryption" == "wep" ] && {
+ case "$key" in
+ [1234])
+ local idx
+ for idx in 1 2 3 4; do
+ local ikey
+ config_get ikey "$vif" "key$idx"
+
+ [ -n "$ikey" ] && {
+ ikey="$(($idx - 1)):$(prepare_key_wep "$ikey")"
+ [ $idx -eq $key ] && ikey="d:$ikey"
+ append keyspec "$ikey"
+ }
+ done
+ ;;
+ *) append keyspec "d:0:$(prepare_key_wep "$key")" ;;
+ esac
+ }
+
+ local br brval brsub brstr
+ [ -n "$basic_rate_list" ] && {
+ for br in $basic_rate_list; do
+ brval="$(($br / 1000))"
+ brsub="$((($br / 100) % 10))"
+ [ "$brsub" -gt 0 ] && brval="$brval.$brsub"
+ [ -n "$brstr" ] && brstr="$brstr,"
+ brstr="$brstr$brval"
+ done
+ }
+
+ local mcval=""
+ [ -n "$mcast_rate" ] && {
+ mcval="$(($mcast_rate / 1000))"
+ mcsub="$(( ($mcast_rate / 100) % 10 ))"
+ [ "$mcsub" -gt 0 ] && mcval="$mcval.$mcsub"
+ }
+
+ iw dev "$ifname" ibss join "$ssid" $freq $htmode \
+ ${fixed:+fixed-freq} $bssid \
+ ${beacon_int:+beacon-interval $beacon_int} \
+ ${brstr:+basic-rates $brstr} \
+ ${mcval:+mcast-rate $mcval} \
+ ${keyspec:+keys $keyspec}
+ ;;
+ sta)
+ if eval "type wpa_supplicant_setup_vif" 2>/dev/null >/dev/null; then
+ wpa_supplicant_setup_vif "$vif" nl80211 "${hostapd_ctrl:+-H $hostapd_ctrl}" || {
+ echo "enable_mac80211($device): Failed to set up wpa_supplicant for interface $ifname" >&2
+ # make sure this wifi interface won't accidentally stay open without encryption
+ ifconfig "$ifname" down
+ continue
+ }
+ fi
+ ;;
+ esac
+ [ "$mode" = "ap" ] || mac80211_start_vif "$vif" "$ifname"
+ done
+
+}
+
+
+check_mac80211_device() {
+ config_get phy "$1" phy
+ [ -z "$phy" ] && {
+ find_mac80211_phy "$1" >/dev/null || return 0
+ config_get phy "$1" phy
+ }
+ [ "$phy" = "$dev" ] && found=1
+}
+
+detect_mac80211() {
+ devidx=0
+ config_load wireless
+ while :; do
+ config_get type "radio$devidx" type
+ [ -n "$type" ] || break
+ devidx=$(($devidx + 1))
+ done
+ for dev in $(ls /sys/class/ieee80211); do
+ found=0
+ config_foreach check_mac80211_device wifi-device
+ [ "$found" -gt 0 ] && continue
+
+ mode_11n=""
+ mode_band="g"
+ channel="11"
+ ht_cap=0
+ for cap in $(iw phy "$dev" info | grep 'Capabilities:' | cut -d: -f2); do
+ ht_cap="$(($ht_cap | $cap))"
+ done
+ ht_capab="";
+ [ "$ht_cap" -gt 0 ] && {
+ mode_11n="n"
+ append ht_capab " option htmode HT20" "$N"
+
+ list=" list ht_capab"
+ [ "$(($ht_cap & 1))" -eq 1 ] && append ht_capab "$list LDPC" "$N"
+ [ "$(($ht_cap & 16))" -eq 16 ] && append ht_capab "$list GF" "$N"
+ [ "$(($ht_cap & 32))" -eq 32 ] && append ht_capab "$list SHORT-GI-20" "$N"
+ [ "$(($ht_cap & 64))" -eq 64 ] && append ht_capab "$list SHORT-GI-40" "$N"
+ [ "$(($ht_cap & 128))" -eq 128 ] && append ht_capab "$list TX-STBC" "$N"
+ [ "$(($ht_cap & 768))" -eq 256 ] && append ht_capab "$list RX-STBC1" "$N"
+ [ "$(($ht_cap & 768))" -eq 512 ] && append ht_capab "$list RX-STBC12" "$N"
+ [ "$(($ht_cap & 768))" -eq 768 ] && append ht_capab "$list RX-STBC123" "$N"
+ [ "$(($ht_cap & 4096))" -eq 4096 ] && append ht_capab "$list DSSS_CCK-40" "$N"
+ }
+ iw phy "$dev" info | grep -q '2412 MHz' || { mode_band="a"; channel="36"; }
+
+ if [ -x /usr/bin/readlink ]; then
+ path="$(readlink -f /sys/class/ieee80211/${dev}/device)"
+ path="${path##/sys/devices/}"
+ dev_id=" option path '$path'"
+ else
+ dev_id=" option macaddr $(cat /sys/class/ieee80211/${dev}/macaddress)"
+ fi
+
+ cat <<EOF
+config wifi-device radio$devidx
+ option type mac80211
+ option channel ${channel}
+ option hwmode 11${mode_11n}${mode_band}
+$dev_id
+$ht_capab
+ # REMOVE THIS LINE TO ENABLE WIFI:
+ option disabled 1
+
+config wifi-iface
+ option device radio$devidx
+ option network lan
+ option mode ap
+ option ssid OpenWrt
+ option encryption none
+
+EOF
+ devidx=$(($devidx + 1))
+ done
+}
+
diff --git a/package/mac80211/files/lib/wifi/mac80211.sh b/package/mac80211/files/lib/wifi/mac80211.sh
new file mode 100644
index 0000000..4c214e8
--- /dev/null
+++ b/package/mac80211/files/lib/wifi/mac80211.sh
@@ -0,0 +1,606 @@
+#!/bin/sh
+append DRIVERS "mac80211"
+
+mac80211_hostapd_setup_base() {
+ local phy="$1"
+ local ifname="$2"
+
+ cfgfile="/var/run/hostapd-$phy.conf"
+
+ config_get device "$vif" device
+ config_get country "$device" country
+ config_get hwmode "$device" hwmode
+ config_get channel "$device" channel
+ config_get beacon_int "$device" beacon_int
+ config_get basic_rate_list "$device" basic_rate
+ config_get_bool noscan "$device" noscan
+
+ hostapd_set_log_options base_cfg "$device"
+
+ [ -n "$channel" -a -z "$hwmode" ] && wifi_fixup_hwmode "$device"
+
+ [ "$channel" = auto ] && {
+ channel=$(iw phy "$phy" info | \
+ sed -ne '/MHz/ { /disabled\|passive\|radar/d; s/.*\[//; s/\].*//; p; q }')
+ config_set "$device" channel "$channel"
+ }
+
+ [ -n "$hwmode" ] && {
+ config_get hwmode_11n "$device" hwmode_11n
+ [ -n "$hwmode_11n" ] && {
+ hwmode="$hwmode_11n"
+ append base_cfg "ieee80211n=1" "$N"
+ config_get htmode "$device" htmode
+ config_get ht_capab_list "$device" ht_capab
+ case "$htmode" in
+ HT20|HT40+|HT40-) ht_capab="[$htmode]";;
+ *)ht_capab=;;
+ esac
+ for cap in $ht_capab_list; do
+ ht_capab="$ht_capab[$cap]"
+ done
+ [ -n "$ht_capab" ] && append base_cfg "ht_capab=$ht_capab" "$N"
+ }
+ }
+
+ local country_ie=0
+ [ -n "$country" ] && country_ie=1
+ config_get_bool country_ie "$device" country_ie "$country_ie"
+ [ "$country_ie" -gt 0 ] && append base_cfg "ieee80211d=1" "$N"
+
+ local br brval brstr
+ [ -n "$basic_rate_list" ] && {
+ for br in $basic_rate_list; do
+ brval="$(($br / 100))"
+ [ -n "$brstr" ] && brstr="$brstr "
+ brstr="$brstr$brval"
+ done
+ }
+
+ cat >> "$cfgfile" <<EOF
+ctrl_interface=/var/run/hostapd-$phy
+driver=nl80211
+wmm_ac_bk_cwmin=4
+wmm_ac_bk_cwmax=10
+wmm_ac_bk_aifs=7
+wmm_ac_bk_txop_limit=0
+wmm_ac_bk_acm=0
+wmm_ac_be_aifs=3
+wmm_ac_be_cwmin=4
+wmm_ac_be_cwmax=10
+wmm_ac_be_txop_limit=0
+wmm_ac_be_acm=0
+wmm_ac_vi_aifs=2
+wmm_ac_vi_cwmin=3
+wmm_ac_vi_cwmax=4
+wmm_ac_vi_txop_limit=94
+wmm_ac_vi_acm=0
+wmm_ac_vo_aifs=2
+wmm_ac_vo_cwmin=2
+wmm_ac_vo_cwmax=3
+wmm_ac_vo_txop_limit=47
+wmm_ac_vo_acm=0
+tx_queue_data3_aifs=7
+tx_queue_data3_cwmin=15
+tx_queue_data3_cwmax=1023
+tx_queue_data3_burst=0
+tx_queue_data2_aifs=3
+tx_queue_data2_cwmin=15
+tx_queue_data2_cwmax=63
+tx_queue_data2_burst=0
+tx_queue_data1_aifs=1
+tx_queue_data1_cwmin=7
+tx_queue_data1_cwmax=15
+tx_queue_data1_burst=3.0
+tx_queue_data0_aifs=1
+tx_queue_data0_cwmin=3
+tx_queue_data0_cwmax=7
+tx_queue_data0_burst=1.5
+${hwmode:+hw_mode=$hwmode}
+${channel:+channel=$channel}
+${beacon_int:+beacon_int=$beacon_int}
+${country:+country_code=$country}
+${noscan:+noscan=$noscan}
+${brstr:+basic_rates=$brstr}
+$base_cfg
+
+EOF
+}
+
+mac80211_hostapd_setup_bss() {
+ local phy="$1"
+ local vif="$2"
+
+ hostapd_cfg=
+ cfgfile="/var/run/hostapd-$phy.conf"
+ config_get ifname "$vif" ifname
+
+ if [ -f "$cfgfile" ]; then
+ append hostapd_cfg "bss=$ifname" "$N"
+ else
+ mac80211_hostapd_setup_base "$phy" "$ifname"
+ append hostapd_cfg "interface=$ifname" "$N"
+ fi
+
+ local net_cfg bridge
+ net_cfg="$(find_net_config "$vif")"
+ [ -z "$net_cfg" ] || bridge="$(bridge_interface "$net_cfg")"
+ config_set "$vif" bridge "$bridge"
+
+ hostapd_set_bss_options hostapd_cfg "$vif"
+
+ config_get_bool wds "$vif" wds 0
+ [ "$wds" -gt 0 ] && append hostapd_cfg "wds_sta=1" "$N"
+
+ local macaddr hidden maxassoc wmm
+ config_get macaddr "$vif" macaddr
+ config_get maxassoc "$vif" maxassoc
+ config_get dtim_period "$vif" dtim_period
+ config_get max_listen_int "$vif" max_listen_int
+ config_get_bool hidden "$vif" hidden 0
+ config_get_bool wmm "$vif" wmm 1
+ cat >> /var/run/hostapd-$phy.conf <<EOF
+$hostapd_cfg
+wmm_enabled=$wmm
+bssid=$macaddr
+ignore_broadcast_ssid=$hidden
+${dtim_period:+dtim_period=$dtim_period}
+${max_listen_int:+max_listen_interval=$max_listen_int}
+${maxassoc:+max_num_sta=$maxassoc}
+EOF
+}
+
+mac80211_start_vif() {
+ local vif="$1"
+ local ifname="$2"
+
+ local net_cfg
+ net_cfg="$(find_net_config "$vif")"
+ [ -z "$net_cfg" ] || start_net "$ifname" "$net_cfg"
+
+ set_wifi_up "$vif" "$ifname"
+}
+
+lookup_phy() {
+ [ -n "$phy" ] && {
+ [ -d /sys/class/ieee80211/$phy ] && return
+ }
+
+ local devpath
+ config_get devpath "$device" path
+ [ -n "$devpath" -a -d "/sys/devices/$devpath/ieee80211" ] && {
+ phy="$(ls /sys/devices/$devpath/ieee80211 | grep -m 1 phy)"
+ [ -n "$phy" ] && return
+ }
+
+ local macaddr="$(config_get "$device" macaddr | tr 'A-Z' 'a-z')"
+ [ -n "$macaddr" ] && {
+ for _phy in $(ls /sys/class/ieee80211 2>/dev/null); do
+ [ "$macaddr" = "$(cat /sys/class/ieee80211/${_phy}/macaddress)" ] || continue
+ phy="$_phy"
+ return
+ done
+ }
+ phy=
+ return
+}
+
+find_mac80211_phy() {
+ local device="$1"
+
+ config_get phy "$device" phy
+ lookup_phy
+ [ -n "$phy" -a -d "/sys/class/ieee80211/$phy" ] || {
+ echo "PHY for wifi device $1 not found"
+ return 1
+ }
+ config_set "$device" phy "$phy"
+
+ config_get macaddr "$device" macaddr
+ [ -z "$macaddr" ] && {
+ config_set "$device" macaddr "$(cat /sys/class/ieee80211/${phy}/macaddress)"
+ }
+
+ return 0
+}
+
+scan_mac80211() {
+ local device="$1"
+ local adhoc sta ap monitor mesh disabled
+
+ config_get vifs "$device" vifs
+ for vif in $vifs; do
+ config_get_bool disabled "$vif" disabled 0
+ [ $disabled = 0 ] || continue
+
+ config_get mode "$vif" mode
+ case "$mode" in
+ adhoc|sta|ap|monitor|mesh)
+ append $mode "$vif"
+ ;;
+ *) echo "$device($vif): Invalid mode, ignored."; continue;;
+ esac
+ done
+
+ config_set "$device" vifs "${ap:+$ap }${adhoc:+$adhoc }${sta:+$sta }${monitor:+$monitor }${mesh:+$mesh}"
+}
+
+list_phy_interfaces() {
+ local phy="$1"
+ if [ -d "/sys/class/ieee80211/${phy}/device/net" ]; then
+ ls "/sys/class/ieee80211/${phy}/device/net" 2>/dev/null;
+ else
+ ls "/sys/class/ieee80211/${phy}/device" 2>/dev/null | grep net: | sed -e 's,net:,,g'
+ fi
+}
+
+disable_mac80211() (
+ local device="$1"
+
+ find_mac80211_phy "$device" || return 0
+ config_get phy "$device" phy
+
+ set_wifi_down "$device"
+ # kill all running hostapd and wpa_supplicant processes that
+ # are running on atheros/mac80211 vifs
+ for pid in `pidof hostapd`; do
+ grep -E "$phy" /proc/$pid/cmdline >/dev/null && \
+ kill $pid
+ done
+
+ include /lib/network
+ for wdev in $(list_phy_interfaces "$phy"); do
+ [ -f "/var/run/$wdev.pid" ] && kill $(cat /var/run/$wdev.pid) >&/dev/null 2>&1
+ for pid in `pidof wpa_supplicant`; do
+ grep "$wdev" /proc/$pid/cmdline >/dev/null && \
+ kill $pid
+ done
+ ifconfig "$wdev" down 2>/dev/null
+ unbridge "$dev"
+ iw dev "$wdev" del
+ done
+
+ return 0
+)
+
+get_freq() {
+ local phy="$1"
+ local chan="$2"
+ iw "$phy" info | grep -E -m1 "(\* ${chan:-....} MHz${chan:+|\\[$chan\\]})" | grep MHz | awk '{print $2}'
+}
+
+mac80211_generate_mac() {
+ local off="$1"
+ local mac="$2"
+ local mask="$3"
+ local oIFS="$IFS"; IFS=":"; set -- $mac; IFS="$oIFS"
+
+ local b2mask=0x00
+ [ $off -gt 0 ] &&
+ [ "$mask" = "00:00:00:00:00:00" -o $(( 0x${mask%%:*} & 0x2 )) -gt 0 ] && b2mask=0x02
+
+ printf "%02x:%s:%s:%s:%02x:%02x" \
+ $(( 0x$1 | $b2mask )) $2 $3 $4 \
+ $(( (0x$5 + ($off / 0x100)) % 0x100 )) \
+ $(( (0x$6 + $off) % 0x100 ))
+}
+
+enable_mac80211() {
+ local device="$1"
+ config_get channel "$device" channel
+ config_get vifs "$device" vifs
+ config_get txpower "$device" txpower
+ config_get country "$device" country
+ config_get distance "$device" distance
+ config_get txantenna "$device" txantenna all
+ config_get rxantenna "$device" rxantenna all
+ config_get antenna_gain "$device" antenna_gain 0
+ config_get frag "$device" frag
+ config_get rts "$device" rts
+ find_mac80211_phy "$device" || return 0
+ config_get phy "$device" phy
+ local i=0
+ local macidx=0
+ local apidx=0
+ fixed=""
+ local hostapd_ctrl=""
+
+ [ -n "$country" ] && {
+ iw reg get | grep -q "^country $country:" || {
+ iw reg set "$country"
+ sleep 1
+ }
+ }
+
+ config_get chanbw "$device" chanbw
+ [ -n "$chanbw" -a -d /sys/kernel/debug/ieee80211/$phy/ath9k ] && echo "$chanbw" > /sys/kernel/debug/ieee80211/$phy/ath9k/chanbw
+ [ -n "$chanbw" -a -d /sys/kernel/debug/ieee80211/$phy/ath5k ] && echo "$chanbw" > /sys/kernel/debug/ieee80211/$phy/ath5k/bwmode
+
+ [ "$channel" = "auto" -o "$channel" = "0" ] || {
+ fixed=1
+ }
+
+ iw phy "$phy" set antenna $txantenna $rxantenna >/dev/null 2>&1
+ iw phy "$phy" set antenna_gain $antenna_gain
+
+ [ -n "$distance" ] && iw phy "$phy" set distance "$distance"
+ [ -n "$frag" ] && iw phy "$phy" set frag "${frag%%.*}"
+ [ -n "$rts" ] && iw phy "$phy" set rts "${rts%%.*}"
+
+ export channel fixed
+ # convert channel to frequency
+ local freq="$(get_freq "$phy" "${fixed:+$channel}")"
+
+ wifi_fixup_hwmode "$device" "g"
+ for vif in $vifs; do
+ config_get ifname "$vif" ifname
+ [ -n "$ifname" ] || {
+ [ $i -gt 0 ] && ifname="wlan${phy#phy}-$i" || ifname="wlan${phy#phy}"
+ }
+ config_set "$vif" ifname "$ifname"
+
+ config_get mode "$vif" mode
+ config_get ssid "$vif" ssid
+
+ # It is far easier to delete and create the desired interface
+ case "$mode" in
+ adhoc)
+ iw phy "$phy" interface add "$ifname" type adhoc
+ ;;
+ ap)
+ # Hostapd will handle recreating the interface and
+ # it's accompanying monitor
+ apidx="$(($apidx + 1))"
+ [ "$apidx" -gt 1 ] || iw phy "$phy" interface add "$ifname" type managed
+ ;;
+ mesh)
+ config_get mesh_id "$vif" mesh_id
+ iw phy "$phy" interface add "$ifname" type mp mesh_id "$mesh_id"
+ ;;
+ monitor)
+ iw phy "$phy" interface add "$ifname" type monitor
+ ;;
+ sta)
+ local wdsflag
+ config_get_bool wds "$vif" wds 0
+ [ "$wds" -gt 0 ] && wdsflag="4addr on"
+ iw phy "$phy" interface add "$ifname" type managed $wdsflag
+ config_get_bool powersave "$vif" powersave 0
+ [ "$powersave" -gt 0 ] && powersave="on" || powersave="off"
+ iw "$ifname" set power_save "$powersave"
+ ;;
+ esac
+
+ # All interfaces must have unique mac addresses
+ # which can either be explicitly set in the device
+ # section, or automatically generated
+ config_get macaddr "$device" macaddr
+ config_get vif_mac "$vif" macaddr
+ [ -n "$vif_mac" ] || {
+ vif_mac="$(mac80211_generate_mac $macidx $macaddr $(cat /sys/class/ieee80211/${phy}/address_mask))"
+ macidx="$(($macidx + 1))"
+ }
+ [ "$mode" = "ap" ] || ifconfig "$ifname" hw ether "$vif_mac"
+ config_set "$vif" macaddr "$vif_mac"
+
+ # !! ap !!
+ #
+ # ALL ap functionality will be passed to hostapd
+ #
+ # !! station !!
+ #
+ # ALL station functionality will be passed to wpa_supplicant
+ #
+ if [ ! "$mode" = "ap" ]; then
+ # We attempt to set the channel for all interfaces, although
+ # mac80211 may not support it or the driver might not yet
+ # for ap mode this is handled by hostapd
+ [ -n "$fixed" -a -n "$channel" ] && iw dev "$ifname" set channel "$channel"
+ fi
+
+ i=$(($i + 1))
+ done
+
+ local start_hostapd=
+ rm -f /var/run/hostapd-$phy.conf
+ for vif in $vifs; do
+ config_get mode "$vif" mode
+ [ "$mode" = "ap" ] || continue
+ mac80211_hostapd_setup_bss "$phy" "$vif"
+ start_hostapd=1
+ done
+
+ [ -n "$start_hostapd" ] && {
+ hostapd -P /var/run/wifi-$phy.pid -B /var/run/hostapd-$phy.conf || {
+ echo "Failed to start hostapd for $phy"
+ return
+ }
+ sleep 2
+
+ for vif in $vifs; do
+ config_get mode "$vif" mode
+ config_get ifname "$vif" ifname
+ [ "$mode" = "ap" ] || continue
+ hostapd_ctrl="${hostapd_ctrl:-/var/run/hostapd-$phy/$ifname}"
+ mac80211_start_vif "$vif" "$ifname"
+ done
+ }
+
+ for vif in $vifs; do
+ config_get mode "$vif" mode
+ config_get ifname "$vif" ifname
+ [ "$mode" = "ap" ] || ifconfig "$ifname" up
+
+ config_get vif_txpower "$vif" txpower
+ # use vif_txpower (from wifi-iface) to override txpower (from
+ # wifi-device) if the latter doesn't exist
+ txpower="${txpower:-$vif_txpower}"
+ [ -z "$txpower" ] || iw dev "$ifname" set txpower fixed "${txpower%%.*}00"
+
+ case "$mode" in
+ adhoc)
+ config_get bssid "$vif" bssid
+ config_get ssid "$vif" ssid
+ config_get beacon_int "$device" beacon_int
+ config_get basic_rate_list "$device" basic_rate
+ config_get encryption "$vif" encryption
+ config_get key "$vif" key 1
+ config_get mcast_rate "$vif" mcast_rate
+ config_get htmode "$device" htmode
+ case "$htmode" in
+ HT20|HT40+|HT40-) ;;
+ *) htmode= ;;
+ esac
+
+
+ local keyspec=""
+ [ "$encryption" == "psk" -o "$encryption" == "psk2" ] && {
+ if eval "type wpa_supplicant_setup_vif" 2>/dev/null >/dev/null; then
+ wpa_supplicant_setup_vif "$vif" nl80211 "${hostapd_ctrl:+-H $hostapd_ctrl}" $freq $htmode || {
+ echo "enable_mac80211($device): Failed to set up wpa_supplicant for interface $ifname" >&2
+ # make sure this wifi interface won't accidentally stay open without encryption
+ ifconfig "$ifname" down
+ }
+ mac80211_start_vif "$vif" "$ifname"
+ continue
+ fi
+ }
+
+ [ "$encryption" == "wep" ] && {
+ case "$key" in
+ [1234])
+ local idx
+ for idx in 1 2 3 4; do
+ local ikey
+ config_get ikey "$vif" "key$idx"
+
+ [ -n "$ikey" ] && {
+ ikey="$(($idx - 1)):$(prepare_key_wep "$ikey")"
+ [ $idx -eq $key ] && ikey="d:$ikey"
+ append keyspec "$ikey"
+ }
+ done
+ ;;
+ *) append keyspec "d:0:$(prepare_key_wep "$key")" ;;
+ esac
+ }
+
+ local br brval brsub brstr
+ [ -n "$basic_rate_list" ] && {
+ for br in $basic_rate_list; do
+ brval="$(($br / 1000))"
+ brsub="$((($br / 100) % 10))"
+ [ "$brsub" -gt 0 ] && brval="$brval.$brsub"
+ [ -n "$brstr" ] && brstr="$brstr,"
+ brstr="$brstr$brval"
+ done
+ }
+
+ local mcval=""
+ [ -n "$mcast_rate" ] && {
+ mcval="$(($mcast_rate / 1000))"
+ mcsub="$(( ($mcast_rate / 100) % 10 ))"
+ [ "$mcsub" -gt 0 ] && mcval="$mcval.$mcsub"
+ }
+
+ iw dev "$ifname" ibss join "$ssid" $freq $htmode \
+ ${fixed:+fixed-freq} $bssid \
+ ${beacon_int:+beacon-interval $beacon_int} \
+ ${brstr:+basic-rates $brstr} \
+ ${mcval:+mcast-rate $mcval} \
+ ${keyspec:+keys $keyspec}
+ ;;
+ sta)
+ if eval "type wpa_supplicant_setup_vif" 2>/dev/null >/dev/null; then
+ wpa_supplicant_setup_vif "$vif" nl80211 "${hostapd_ctrl:+-H $hostapd_ctrl}" || {
+ echo "enable_mac80211($device): Failed to set up wpa_supplicant for interface $ifname" >&2
+ # make sure this wifi interface won't accidentally stay open without encryption
+ ifconfig "$ifname" down
+ continue
+ }
+ fi
+ ;;
+ esac
+ [ "$mode" = "ap" ] || mac80211_start_vif "$vif" "$ifname"
+ done
+
+}
+
+
+check_mac80211_device() {
+ config_get phy "$1" phy
+ [ -z "$phy" ] && {
+ find_mac80211_phy "$1" >/dev/null || return 0
+ config_get phy "$1" phy
+ }
+ [ "$phy" = "$dev" ] && found=1
+}
+
+detect_mac80211() {
+ devidx=0
+ config_load wireless
+ while :; do
+ config_get type "radio$devidx" type
+ [ -n "$type" ] || break
+ devidx=$(($devidx + 1))
+ done
+ for dev in $(ls /sys/class/ieee80211); do
+ found=0
+ config_foreach check_mac80211_device wifi-device
+ [ "$found" -gt 0 ] && continue
+
+ mode_11n=""
+ mode_band="g"
+ channel="11"
+ ht_cap=0
+ for cap in $(iw phy "$dev" info | grep 'Capabilities:' | cut -d: -f2); do
+ ht_cap="$(($ht_cap | $cap))"
+ done
+ ht_capab="";
+ [ "$ht_cap" -gt 0 ] && {
+ mode_11n="n"
+ append ht_capab " option htmode HT20" "$N"
+
+ list=" list ht_capab"
+ [ "$(($ht_cap & 1))" -eq 1 ] && append ht_capab "$list LDPC" "$N"
+ [ "$(($ht_cap & 16))" -eq 16 ] && append ht_capab "$list GF" "$N"
+ [ "$(($ht_cap & 32))" -eq 32 ] && append ht_capab "$list SHORT-GI-20" "$N"
+ [ "$(($ht_cap & 64))" -eq 64 ] && append ht_capab "$list SHORT-GI-40" "$N"
+ [ "$(($ht_cap & 128))" -eq 128 ] && append ht_capab "$list TX-STBC" "$N"
+ [ "$(($ht_cap & 768))" -eq 256 ] && append ht_capab "$list RX-STBC1" "$N"
+ [ "$(($ht_cap & 768))" -eq 512 ] && append ht_capab "$list RX-STBC12" "$N"
+ [ "$(($ht_cap & 768))" -eq 768 ] && append ht_capab "$list RX-STBC123" "$N"
+ [ "$(($ht_cap & 4096))" -eq 4096 ] && append ht_capab "$list DSSS_CCK-40" "$N"
+ }
+ iw phy "$dev" info | grep -q '2412 MHz' || { mode_band="a"; channel="36"; }
+
+ if [ -x /usr/bin/readlink ]; then
+ path="$(readlink -f /sys/class/ieee80211/${dev}/device)"
+ path="${path##/sys/devices/}"
+ dev_id=" option path '$path'"
+ else
+ dev_id=" option macaddr $(cat /sys/class/ieee80211/${dev}/macaddress)"
+ fi
+
+ cat <<EOF
+config wifi-device radio$devidx
+ option type mac80211
+ option channel ${channel}
+ option hwmode 11${mode_11n}${mode_band}
+$dev_id
+$ht_capab
+ # REMOVE THIS LINE TO ENABLE WIFI:
+ option disabled 1
+
+config wifi-iface
+ option device radio$devidx
+ option network lan
+ option mode ap
+ option ssid OpenWrt
+ option encryption none
+
+EOF
+ devidx=$(($devidx + 1))
+ done
+}
+
diff --git a/package/mac80211/files/regdb.txt b/package/mac80211/files/regdb.txt
new file mode 100644
index 0000000..b250e69
--- /dev/null
+++ b/package/mac80211/files/regdb.txt
@@ -0,0 +1,697 @@
+# This is the world regulatory domain
+country 00:
+ (2402 - 2472 @ 40), (3, 20)
+ # Channel 12 - 13. No HT40 channel fits here
+ (2457 - 2482 @ 20), (3, 20), PASSIVE-SCAN, NO-IBSS
+ # Channel 14. Only JP enables this and for 802.11b only
+ (2474 - 2494 @ 20), (3, 20), PASSIVE-SCAN, NO-IBSS, NO-OFDM
+ # Channel 36 - 48
+ (5170 - 5250 @ 40), (3, 20)
+ # NB: 5260 MHz - 5700 MHz requies DFS
+ # Channel 149 - 165
+ (5735 - 5835 @ 40), (3, 20), PASSIVE-SCAN, NO-IBSS
+
+
+country AE:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country AL:
+ (2402 - 2482 @ 20), (N/A, 20)
+
+country AM:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 20), (N/A, 18)
+ (5250 - 5330 @ 20), (N/A, 18), DFS
+
+country AN:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country AR:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (3, 17)
+ (5250 - 5330 @ 40), (3, 20), DFS
+ (5490 - 5710 @ 40), (3, 20), DFS
+ (5735 - 5835 @ 40), (3, 30)
+
+country AT: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country AU:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (3, 23)
+ (5250 - 5330 @ 40), (3, 23), DFS
+ (5735 - 5835 @ 40), (3, 30)
+
+country AW:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country AZ:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 18)
+ (5250 - 5330 @ 40), (N/A, 18), DFS
+
+country BA: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country BB:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (3, 23)
+ (5250 - 5330 @ 40), (3, 23), DFS
+ (5735 - 5835 @ 40), (3, 30)
+
+country BD:
+ (2402 - 2482 @ 40), (N/A, 20)
+
+country BE: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country BG: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 23)
+ (5250 - 5290 @ 40), (N/A, 23), DFS
+ (5490 - 5710 @ 40), (N/A, 30), DFS
+
+country BH:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 20), (N/A, 20)
+ (5250 - 5330 @ 20), (N/A, 20), DFS
+ (5735 - 5835 @ 20), (N/A, 20)
+
+country BL:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 18)
+ (5250 - 5330 @ 40), (N/A, 18), DFS
+
+country BN:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5735 - 5835 @ 40), (N/A, 30)
+
+country BO:
+ (2402 - 2482 @ 40), (N/A, 30)
+ (5735 - 5835 @ 40), (N/A, 30)
+
+country BR:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (3, 17)
+ (5250 - 5330 @ 40), (3, 20), DFS
+ (5490 - 5710 @ 40), (3, 20), DFS
+ (5735 - 5835 @ 40), (3, 30)
+
+country BY:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country BZ:
+ (2402 - 2482 @ 40), (N/A, 30)
+ (5735 - 5835 @ 40), (N/A, 30)
+
+country CA:
+ (2402 - 2472 @ 40), (3, 27)
+ (5170 - 5250 @ 40), (3, 17)
+ (5250 - 5330 @ 40), (3, 20), DFS
+ (5490 - 5710 @ 40), (3, 20), DFS
+ (5735 - 5835 @ 40), (3, 30)
+
+country CH: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country CL:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5735 - 5835 @ 40), (N/A, 20)
+
+country CN:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5735 - 5835 @ 40), (N/A, 30)
+
+country CO:
+ (2402 - 2472 @ 40), (3, 27)
+ (5170 - 5250 @ 40), (3, 17)
+ (5250 - 5330 @ 40), (3, 23), DFS
+ (5735 - 5835 @ 40), (3, 30)
+
+country CR:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 20), (3, 17)
+ (5250 - 5330 @ 20), (3, 23), DFS
+ (5735 - 5835 @ 20), (3, 30)
+
+country CS:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country CY: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+# Data from http://www.ctu.eu/164/download/VOR/VOR-12-08-2005-34.pdf
+# and http://www.ctu.eu/164/download/VOR/VOR-12-05-2007-6-AN.pdf
+# Power at 5250 - 5350 MHz and 5470 - 5725 MHz can be doubled if TPC is
+# implemented.
+country CZ: DFS-ETSI
+ (2400 - 2483.5 @ 40), (N/A, 100 mW)
+ (5150 - 5250 @ 40), (N/A, 200 mW), NO-OUTDOOR
+ (5250 - 5350 @ 40), (N/A, 100 mW), NO-OUTDOOR, DFS
+ (5470 - 5725 @ 40), (N/A, 500 mW), DFS
+
+# Data from "Frequenznutzungsplan" (as published in April 2008), downloaded from
+# http://www.bundesnetzagentur.de/cae/servlet/contentblob/38448/publicationFile/2659/Frequenznutzungsplan2008_Id17448pdf.pdf
+# For the 5GHz range also see
+# http://www.bundesnetzagentur.de/cae/servlet/contentblob/38216/publicationFile/6579/WLAN5GHzVfg7_2010_28042010pdf.pdf
+# The values have been reduced by a factor of 2 (3db) for non TPC devices
+# (in other words: devices with TPC can use twice the tx power of this table).
+# Note that the docs do not require TPC for 5150--5250; the reduction to
+# 100mW thus is not strictly required -- however the conservative 100mW
+# limit is used here as the non-interference with radar and satellite
+# apps relies on the attenuation by the building walls only in the
+# absence of DFS; the neighbour countries have 100mW limit here as well.
+
+country DE: DFS-ETSI
+ # entries 279004 and 280006
+ (2400 - 2483.5 @ 40), (N/A, 100 mW)
+ # entry 303005
+ (5150 - 5250 @ 40), (N/A, 100 mW), NO-OUTDOOR
+ # entries 304002 and 305002
+ (5250 - 5350 @ 40), (N/A, 100 mW), NO-OUTDOOR, DFS
+ # entries 308002, 309001 and 310003
+ (5470 - 5725 @ 40), (N/A, 500 mW), DFS
+
+country DK: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country DO:
+ (2402 - 2472 @ 40), (3, 27)
+ (5170 - 5250 @ 40), (3, 17)
+ (5250 - 5330 @ 40), (3, 23), DFS
+ (5735 - 5835 @ 40), (3, 30)
+
+country DZ:
+ (2402 - 2482 @ 40), (N/A, 20)
+
+country EC:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 20), (3, 17)
+ (5250 - 5330 @ 20), (3, 23), DFS
+ (5735 - 5835 @ 20), (3, 30)
+
+country EE: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country EG:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 20), (N/A, 20)
+ (5250 - 5330 @ 20), (N/A, 20), DFS
+
+country ES: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country FI: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country FR: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country GE:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 18)
+ (5250 - 5330 @ 40), (N/A, 18), DFS
+
+country GB: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country GD:
+ (2402 - 2472 @ 40), (3, 27)
+ (5170 - 5250 @ 40), (3, 17)
+ (5250 - 5330 @ 40), (3, 20), DFS
+ (5490 - 5710 @ 40), (3, 20), DFS
+ (5735 - 5835 @ 40), (3, 30)
+
+country GR: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country GL: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 20), (N/A, 20)
+ (5250 - 5330 @ 20), (N/A, 20), DFS
+ (5490 - 5710 @ 20), (N/A, 27), DFS
+
+country GT:
+ (2402 - 2472 @ 40), (3, 27)
+ (5170 - 5250 @ 40), (3, 17)
+ (5250 - 5330 @ 40), (3, 23), DFS
+ (5735 - 5835 @ 40), (3, 30)
+
+country GU:
+ (2402 - 2472 @ 40), (3, 27)
+ (5170 - 5250 @ 20), (3, 17)
+ (5250 - 5330 @ 20), (3, 23), DFS
+ (5735 - 5835 @ 20), (3, 30)
+
+country HN:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (3, 17)
+ (5250 - 5330 @ 40), (3, 20), DFS
+ (5490 - 5710 @ 40), (3, 20), DFS
+ (5735 - 5835 @ 40), (3, 30)
+
+country HK:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (3, 17)
+ (5250 - 5330 @ 40), (3, 20), DFS
+ (5490 - 5710 @ 40), (3, 20), DFS
+ (5735 - 5835 @ 40), (3, 30)
+
+country HR: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country HT:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country HU: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country ID:
+ (2402 - 2482 @ 40), (N/A, 20)
+
+country IE: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country IL:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5150 - 5250 @ 40), (N/A, 200 mW), NO-OUTDOOR
+ (5250 - 5350 @ 40), (N/A, 200 mW), NO-OUTDOOR, DFS
+
+country IN:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5735 - 5835 @ 40), (N/A, 20)
+
+country IS: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country IR:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5735 - 5835 @ 40), (N/A, 30)
+
+country IT: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country JM:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (3, 17)
+ (5250 - 5330 @ 40), (3, 20), DFS
+ (5490 - 5710 @ 40), (3, 20), DFS
+ (5735 - 5835 @ 40), (3, 30)
+
+country JP:
+ (2402 - 2472 @ 40), (N/A, 20)
+ (2457 - 2482 @ 20), (N/A, 20)
+ (2474 - 2494 @ 20), (N/A, 20), NO-OFDM
+ (4910 - 4930 @ 10), (N/A, 23)
+ (4910 - 4990 @ 40), (N/A, 23)
+ (4930 - 4950 @ 10), (N/A, 23)
+ (5030 - 5045 @ 10), (N/A, 23)
+ (5030 - 5090 @ 40), (N/A, 23)
+ (5050 - 5060 @ 10), (N/A, 23)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 23), DFS
+
+country JO:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 18)
+
+country KE:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5735 - 5835 @ 40), (N/A, 30)
+
+country KH:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country KP:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5330 @ 40), (3, 20)
+ (5160 - 5250 @ 40), (3, 20), DFS
+ (5490 - 5630 @ 40), (3, 30), DFS
+ (5735 - 5815 @ 40), (3, 30)
+
+country KR:
+ (2402 - 2482 @ 20), (N/A, 20)
+ (5170 - 5250 @ 20), (3, 20)
+ (5250 - 5330 @ 20), (3, 20), DFS
+ (5490 - 5630 @ 20), (3, 30), DFS
+ (5735 - 5815 @ 20), (3, 30)
+
+country KW:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+
+country KZ:
+ (2402 - 2482 @ 40), (N/A, 20)
+
+country LB:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5735 - 5835 @ 40), (N/A, 30)
+
+country LI: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country LK:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 20), (3, 17)
+ (5250 - 5330 @ 20), (3, 20), DFS
+ (5490 - 5710 @ 20), (3, 20), DFS
+ (5735 - 5835 @ 20), (3, 30)
+
+country LT: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country LU: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country LV: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country MC: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 18)
+ (5250 - 5330 @ 40), (N/A, 18), DFS
+
+country MA:
+ (2402 - 2482 @ 40), (N/A, 20)
+
+country MO:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (3, 23)
+ (5250 - 5330 @ 40), (3, 23), DFS
+ (5735 - 5835 @ 40), (3, 30)
+
+country MK: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country MT: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country MY:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 30), DFS
+ (5735 - 5835 @ 40), (N/A, 30)
+
+country MX:
+ (2402 - 2472 @ 40), (3, 27)
+ (5170 - 5250 @ 40), (3, 17)
+ (5250 - 5330 @ 40), (3, 23), DFS
+ (5735 - 5835 @ 40), (3, 30)
+
+country NL: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20), NO-OUTDOOR
+ (5250 - 5330 @ 40), (N/A, 20), NO-OUTDOOR, DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country NO: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country NP:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5735 - 5835 @ 40), (N/A, 30)
+
+country NZ:
+ (2402 - 2482 @ 40), (N/A, 30)
+ (5170 - 5250 @ 20), (3, 23)
+ (5250 - 5330 @ 20), (3, 23), DFS
+ (5735 - 5835 @ 20), (3, 30)
+
+country OM:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (3, 17)
+ (5250 - 5330 @ 40), (3, 20), DFS
+ (5490 - 5710 @ 40), (3, 20), DFS
+ (5735 - 5835 @ 40), (3, 30)
+
+country PA:
+ (2402 - 2472 @ 40), (3, 27)
+ (5170 - 5250 @ 40), (3, 17)
+ (5250 - 5330 @ 40), (3, 23), DFS
+ (5735 - 5835 @ 40), (3, 30)
+
+country PE:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5735 - 5835 @ 40), (N/A, 30)
+
+country PG:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (3, 17)
+ (5250 - 5330 @ 40), (3, 23), DFS
+ (5735 - 5835 @ 40), (3, 30)
+
+country PH:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5735 - 5835 @ 40), (N/A, 30)
+
+country PK:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5735 - 5835 @ 40), (N/A, 30)
+
+country PL: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country PT: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country PR:
+ (2402 - 2472 @ 40), (3, 27)
+ (5170 - 5250 @ 40), (3, 17)
+ (5250 - 5330 @ 40), (3, 23), DFS
+ (5735 - 5835 @ 40), (3, 30)
+
+country QA:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5735 - 5835 @ 40), (N/A, 30)
+
+country RO: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country RU:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5735 - 5835 @ 20), (N/A, 30)
+
+country SA:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 20), (3, 23)
+ (5250 - 5330 @ 20), (3, 23), DFS
+ (5735 - 5835 @ 20), (3, 30)
+
+country SE: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country SG:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5735 - 5835 @ 40), (N/A, 20)
+
+country SI: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country SK: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+ (5490 - 5710 @ 40), (N/A, 27), DFS
+
+country SV:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 20), (3, 17)
+ (5250 - 5330 @ 20), (3, 23), DFS
+ (5735 - 5835 @ 20), (3, 30)
+
+country SY:
+ (2402 - 2482 @ 40), (N/A, 20)
+
+country TW:
+ (2402 - 2472 @ 40), (3, 27)
+ (5270 - 5330 @ 40), (3, 17), DFS
+ (5735 - 5815 @ 40), (3, 30)
+
+country TH:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (3, 17)
+ (5250 - 5330 @ 40), (3, 20), DFS
+ (5490 - 5710 @ 40), (3, 20), DFS
+ (5735 - 5835 @ 40), (3, 30)
+
+country TT:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (3, 17)
+ (5250 - 5330 @ 40), (3, 20), DFS
+ (5490 - 5710 @ 40), (3, 20), DFS
+ (5735 - 5835 @ 40), (3, 30)
+
+country TN:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 20), (N/A, 20)
+ (5250 - 5330 @ 20), (N/A, 20), DFS
+
+country TR: DFS-ETSI
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 20), (N/A, 20)
+ (5250 - 5330 @ 20), (N/A, 20), DFS
+
+country UA:
+ (2402 - 2482 @ 40), (N/A, 20)
+
+country US: DFS-FCC
+ (2402 - 2472 @ 40), (3, 27)
+ (5170 - 5250 @ 40), (3, 17)
+ (5250 - 5330 @ 40), (3, 20), DFS
+ (5490 - 5600 @ 40), (3, 20), DFS
+ (5650 - 5710 @ 40), (3, 20), DFS
+ (5735 - 5835 @ 40), (3, 30)
+
+country UY:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (3, 17)
+ (5250 - 5330 @ 40), (3, 20), DFS
+ (5490 - 5710 @ 40), (3, 20), DFS
+ (5735 - 5835 @ 40), (3, 30)
+
+country UZ:
+ (2402 - 2472 @ 40), (3, 27)
+ (5170 - 5250 @ 40), (3, 17)
+ (5250 - 5330 @ 40), (3, 20), DFS
+ (5490 - 5710 @ 40), (3, 20), DFS
+ (5735 - 5835 @ 40), (3, 30)
+
+country VE:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5735 - 5815 @ 40), (N/A, 23)
+
+country VN:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (N/A, 20)
+ (5250 - 5330 @ 40), (N/A, 20), DFS
+
+country YE:
+ (2402 - 2482 @ 40), (N/A, 20)
+
+country ZA:
+ (2402 - 2482 @ 40), (N/A, 20)
+ (5170 - 5250 @ 40), (3, 17)
+ (5250 - 5330 @ 40), (3, 20), DFS
+ (5490 - 5710 @ 40), (3, 20), DFS
+ (5735 - 5835 @ 40), (3, 30)
+
+country ZW:
+ (2402 - 2482 @ 40), (N/A, 20)
+
diff --git a/package/mac80211/patches/.svn/entries b/package/mac80211/patches/.svn/entries
new file mode 100644
index 0000000..7932f2c
--- /dev/null
+++ b/package/mac80211/patches/.svn/entries
@@ -0,0 +1,2782 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/mac80211/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-16T16:11:43.462930Z
+36056
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+502-ath9k_ahb_init.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+40b06401a153ff40ebedc61c4230391a
+2013-02-23T01:12:36.399536Z
+35753
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+693
+
+555-ath9k-allow-to-disable-bands-via-platform-data.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+64a0d0314f6bcbe093b80ee07aa94925
+2013-02-25T19:53:31.155469Z
+35785
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2049
+
+420-ath5k_disable_fast_cc.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+6da2e23895ba887899e19ad23e9c39a8
+2013-02-23T01:12:36.399536Z
+35753
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+476
+
+432-ath5k_add_pciids.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+cb0e9eb68b99d62d59ad6e45bcb3c218
+2012-05-30T01:01:06.845483Z
+32002
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+514
+
+820-b43-add-antenna-control.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+24f84d16282dbdcb477f123c295ce2b1
+2013-01-09T12:45:28.153269Z
+35063
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4076
+
+403-ath_regd_optional.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+153d7a330deea6111aa97cf3ec3f3bb8
+2013-02-23T01:12:36.399536Z
+35753
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1022
+
+500-ath9k_eeprom_debugfs.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+0c42f101bc3b9ba65e4857dff79fd3bf
+2013-02-23T01:12:36.399536Z
+35753
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1617
+
+402-ath9k-fix-invalid-mac-address-handling.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+67b678d5cbeb5b547b0dbe9c7dc94a4b
+2013-03-14T14:45:36.195379Z
+36007
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+757
+
+810-b43_no_pio.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+6a2a580a23a1c9b2b919435b9d501f7a
+2012-12-07T16:46:04.924663Z
+34571
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1973
+
+431-add_platform_eeprom_support_to_ath5k.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+b74e210e3d82b8a71258998020a5140b
+2013-03-14T14:45:36.195379Z
+36007
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1402
+
+601-rt2x00-set_pci_mwi.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+40fec906a6ed5029adfdc7429834ad92
+2012-07-10T00:21:25.484920Z
+32655
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+389
+
+531-ath9k_extra_platform_leds.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+8d80ebe4e4abe1b9f318c394816ef504
+2012-12-10T15:46:15.202656Z
+34606
+juhosg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1641
+
+401-ath9k_blink_default.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+c95b59c8d689093a81d54efaedd7b12e
+2013-02-23T01:12:36.399536Z
+35753
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+414
+
+607-rt2x00-allow_disabling_bands_through_platform_data.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+e7109dbf224f31197a07937df993e125
+2013-02-23T01:12:36.399536Z
+35753
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1304
+
+611-rt2x00-rf_vals-rt3352-xtal20.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+3d1f5fd781a57eb9845e91abc4db192f
+2013-02-23T01:12:36.399536Z
+35753
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3303
+
+513-mac80211_reduce_txqueuelen.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+6255b475fbe1a9e5e997d8bb31789bd6
+2013-03-14T14:45:36.195379Z
+36007
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+362
+
+404-world_regd_fixup.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+0b225baa89920f0f843a2d559c4bde8e
+2012-05-30T01:01:06.845483Z
+32002
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2175
+
+551-ath9k_revert_initval_change.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+9095009d9deccf5490165fa724827c91
+2013-01-11T13:24:20.155948Z
+35096
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+629
+
+411-ath5k_allow_adhoc_and_ap.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+2997de07a19f25a8a99db580109890e3
+2013-03-14T14:45:36.195379Z
+36007
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1836
+
+862-brcmsmac-remove-brcms_bss_cfg-BSS.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+376bbcba418d6bb5aa145278d7e6f33b
+2013-02-24T01:11:20.558202Z
+35763
+hauke
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2284
+
+020-disable_tty_set_termios.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+cfaf26eb1d37fcab3708cb918dcfadca
+2012-12-06T14:11:09.951161Z
+34531
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+416
+
+511-ath9k_reduce_rxbuf.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+58c7b70aab3d39c8d554c1835f49f30a
+2013-01-09T12:45:28.153269Z
+35063
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+398
+
+604-rt2x00-add-CONFIG_RT2X00_LIB_EEPROM-option.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+12836024c9face73bcb37d66682ac72f
+2013-02-23T01:12:36.399536Z
+35753
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+307
+
+552-ath9k_rx_dma_stop_check.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+68d253f524cdcce345111044a69abc11
+2013-03-14T14:45:36.195379Z
+36007
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+819
+
+521-ath9k_cur_txpower.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+5d0ee69e2321d14854e4d5519181b388
+2013-02-23T01:12:36.399536Z
+35753
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+649
+
+430-add_ath5k_platform.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+5642537a0de169348d13fdda86e5778f
+2012-04-16T21:08:41.501886Z
+31322
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1263
+
+440-ath5k_channel_bw_debugfs.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+c21f03f415936f553b4b065c3ffee426
+2013-03-14T14:45:36.195379Z
+36007
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3305
+
+603-rt2x00-introduce-rt2x00eeprom.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+45897a3147f3d44006c160637875cd3b
+2013-03-14T14:45:36.195379Z
+36007
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+7868
+
+866-brcmsmac-remove-brcms_bss_cfg-cur_etheraddr.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+a28cbba2854b7ff8a5b0d2e5f4532372
+2013-02-24T01:11:20.558202Z
+35763
+hauke
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1124
+
+602-rt2x00-introduce-rt2x00_platform_h.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+41a8804742d77e70c543285eb1bec31e
+2012-04-16T21:08:41.501886Z
+31322
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+802
+
+003-disable_codel.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+344b527146edbf9856bb8ba6b475250f
+2012-12-06T14:11:09.951161Z
+34531
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+713
+
+522-ath9k_per_chain_signal_strength.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+36a67c56861146fb7fc9091d42936024
+2013-03-14T14:45:36.195379Z
+36007
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+13176
+
+540-mac80211_optimize_mcs_rate_mask.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+852201246209dec6cb80614230482f6c
+2013-02-26T21:52:59.134909Z
+35819
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3335
+
+553-ath9k_debugfs_diag.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+31819c1787871765d3c20d9f4063313e
+2013-02-25T19:53:31.155469Z
+35785
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3904
+
+861-brcmsmac-add-interface-type-to-brcms_bss_cfg.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+74c17f5f14efb1bd906f7ba0295a7751
+2013-02-24T01:11:20.558202Z
+35763
+hauke
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2140
+
+410-ath9k_allow_adhoc_and_ap.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+e88175bd804385a848413872ffded98e
+2013-02-23T01:12:36.399536Z
+35753
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+343
+
+010-add_include_for_bcma.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+41885f9a79f1027aee33ac4f5e0e5328
+2012-12-06T14:11:09.951161Z
+34531
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+310
+
+850-brcmsmac-start-adding-support-for-core-rev-28.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+5a28bb666604c090668aa65e44e94a06
+2013-03-14T14:45:36.195379Z
+36007
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3137
+
+300-pending_work.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+9d2abaae4dfea8552157ccaaf2dd818b
+2013-03-16T16:11:43.462930Z
+36056
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+29321
+
+867-brcmsmac-remove-brcms_pub-bcmerr.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+fd41d0b43102341f3cedd5ca14ac0376
+2013-02-24T01:11:20.558202Z
+35763
+hauke
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+710
+
+002-disable_ssb_build.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+d03af401d49722ee2bae03d94237ef47
+2013-02-23T01:12:36.399536Z
+35753
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+502
+
+830-b43-workaround-pcie-bcm4716.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+78f09ffddbbc278ad51679c6462cfef8
+2013-01-09T12:45:28.153269Z
+35063
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4635
+
+406-ath_regd_us.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+8b150a9de67aa33fa49a14a387d1fd1e
+2012-04-16T21:08:41.501886Z
+31322
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+976
+
+700-mwl8k-missing-pci-id-for-WNR854T.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+1780c4a0a7d297506157d7e42ae7394e
+2013-02-23T01:12:36.399536Z
+35753
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+493
+
+510-ath9k_intr_mitigation_tweak.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+5a9db3e7a2d84c246537ca7a808979c2
+2013-02-25T19:53:31.155469Z
+35785
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+465
+
+150-disable_addr_notifier.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+f09901a2575b6f63531d5ab0058b0067
+2013-03-14T14:45:36.195379Z
+36007
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2002
+
+530-ath9k_extra_leds.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+a230516cf2f7cb05cb0be91f950a17e9
+2013-03-14T14:45:36.195379Z
+36007
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+6562
+
+501-ath9k-eeprom_endianess.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+ddb14be7ba8ce94b8b3fcd80513d05ca
+2013-02-23T01:12:36.399536Z
+35753
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3105
+
+871-brcmsmac-add-support-for-probe-response-template.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+9614bbec15a75983590a5935e351c3e2
+2013-02-24T01:11:20.558202Z
+35763
+hauke
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+6793
+
+840-b43-increase_number_of_rx_dma_slots.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+62b1f9760c8fd2a21dca7f5a87d29857
+2013-03-10T20:24:15.965765Z
+35944
+hauke
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+418
+
+605-rt2x00-pci-eeprom.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+9748384edd84c11f34438faccde0d708
+2013-03-14T14:45:36.195379Z
+36007
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1639
+
+310-ap_scan.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+f0581eb821f2a145913325ba742bf959
+2013-02-23T01:12:36.399536Z
+35753
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+385
+
+863-brcmsmac-remove-brcms_bss_cfg-associated.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+ad4d52ba7897d5fe5fb56896d152cab6
+2013-02-24T01:11:20.558202Z
+35763
+hauke
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2200
+
+004-use_env_for_bash.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+dd9c27199d52b651a3373bcb46e929d1
+2013-03-14T14:45:36.195379Z
+36007
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+262
+
+860-brcmsmac-implement-ieee80211_ops-get_tsf-and-set_tsf.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+fb12c93bb7cac7dc7ddf9cdc89aeb238
+2013-02-24T01:11:20.558202Z
+35763
+hauke
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3540
+
+800-b43-gpio-mask-module-option.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+74640b89dc58bda2287d7e120b089ee0
+2013-01-09T12:45:28.153269Z
+35063
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1369
+
+040-linux_3_9_compat.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+2c1c654801dbb98d515152761f9f8858
+2013-03-14T14:45:36.195379Z
+36007
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4392
+
+865-brcmsmac-remove-brcms_bss_cfg-up.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+f85abc7ec0747ac082549ebbba67eb48
+2013-02-24T01:11:20.558202Z
+35763
+hauke
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1545
+
+864-brcmsmac-remove-brcms_bss_cfg-enable.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+af3f92e78e0c337b4594e4f24d6c2a71
+2013-02-24T01:11:20.558202Z
+35763
+hauke
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1159
+
+868-brcmsmac-write-beacon-period-to-hardware.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+679541ffefe03526488713bf0e871c23
+2013-02-24T01:11:20.558202Z
+35763
+hauke
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+621
+
+610-rt2x00-fix-rt3352-ext-pa.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+67b3a056529ae6c7642e09fd3e29374f
+2013-02-23T01:12:36.399536Z
+35753
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+7371
+
+870-brcmsmac-react-on-changing-SSID.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+cb5ca614fc812619794d2ed9b7532ace
+2013-02-24T01:11:20.558202Z
+35763
+hauke
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1704
+
+030-wext.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+e260d856bda20160e44b1e8ed12cb6b2
+2013-02-23T12:48:14.101459Z
+35759
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+688
+
+554-ath9k_ani_mrc_fix.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+ccafb7e5b3baf4c849946b15df6a65bf
+2013-01-21T12:46:37.387841Z
+35264
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+432
+
+873-brcmsmac-remove-extra-regulation-restriction.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+a56eba3fe492a5f4e2d24535d5062730
+2013-02-24T01:11:20.558202Z
+35763
+hauke
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1058
+
+130-mesh_pathtbl_backport.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+9c5aab5f45eeb4b20b5bbe8f9809685c
+2013-03-14T14:45:36.195379Z
+36007
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+6789
+
+520-mac80211_cur_txpower.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+8365727732bd37d6eb5c3be428a8dce8
+2013-02-23T01:12:36.399536Z
+35753
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1023
+
+201-ath5k-WAR-for-AR71xx-PCI-bug.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+4f2950eefc27ca8a84d7509b71e6ead9
+2012-05-30T01:01:06.845483Z
+32002
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1309
+
+400-ath_move_debug_code.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+37307549c3497b7d9bb44943ed2b75eb
+2013-01-09T12:45:28.153269Z
+35063
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+741
+
+001-disable_rfkill.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+73c099a34ed5531434856ff097390fda
+2012-12-06T14:11:09.951161Z
+34531
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+252
+
+512-ath9k_channelbw_debugfs.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+e21e30b0ecb2d99da918da2a3f3dd2ef
+2013-02-23T01:12:36.399536Z
+35753
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3777
+
+606-rt2x00_no_realign.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+e539b554e9cc07de1ffb23871eff8a62
+2013-02-23T01:12:36.399536Z
+35753
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2264
+
+523-mac80211_configure_antenna_gain.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+e3f1c003a6919535a37db8cd4738faf3
+2013-03-14T14:45:36.195379Z
+36007
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5157
+
+541-ath9k_optimize_interrupt_mitigation.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+1c20a6c1f53699909f0ec79d050b9189
+2012-12-07T16:46:04.924663Z
+34571
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1009
+
+600-rt2x00-disable-pci-code-if-CONFIG_PCI-not-defined.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+4477aaece3810d929f09fbc12915c13f
+2012-07-10T00:21:25.484920Z
+32655
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+446
+
+869-brcmsmac-add-beacon-template-support.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+f562bbf9ccefa63c3ca3940157e0b64a
+2013-02-24T01:11:20.558202Z
+35763
+hauke
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+8604
+
+550-ath9k_reduce_ani_interval.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+77a8fcf5ecc9ed1d3a409a71f32ab4c0
+2012-12-07T16:46:04.924663Z
+34571
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+353
+
+608-add_platform_data_mac_addr.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+abd14a350bf251805db39bb04c28d1b6
+2013-02-23T01:12:36.399536Z
+35753
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1815
+
+872-brcmsmac-activate-AP-support.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+53d08c771fa3048600144322f08d7b95
+2013-02-24T01:11:20.558202Z
+35763
+hauke
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2861
+
+524-ath9k_use_configured_antenna_gain.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+4a335c8f0792da11a6c0d82598058c81
+2013-02-25T19:53:31.155469Z
+35785
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1264
+
+405-regd_no_assoc_hints.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+a7d3aea1029144ebdbab05d87f21d748
+2013-02-23T01:12:36.399536Z
+35753
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+514
+
diff --git a/package/mac80211/patches/.svn/text-base/001-disable_rfkill.patch.svn-base b/package/mac80211/patches/.svn/text-base/001-disable_rfkill.patch.svn-base
new file mode 100644
index 0000000..7af485f
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/001-disable_rfkill.patch.svn-base
@@ -0,0 +1,13 @@
+--- a/include/linux/rfkill.h
++++ b/include/linux/rfkill.h
+@@ -3,6 +3,10 @@
+
+ #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31))
+
++#undef CONFIG_RFKILL
++#undef CONFIG_RFKILL_LEDS
++#undef CONFIG_RFKILL_MODULE
++
+ #include_next <linux/rfkill.h>
+
+ #else
diff --git a/package/mac80211/patches/.svn/text-base/002-disable_ssb_build.patch.svn-base b/package/mac80211/patches/.svn/text-base/002-disable_ssb_build.patch.svn-base
new file mode 100644
index 0000000..ef184c4
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/002-disable_ssb_build.patch.svn-base
@@ -0,0 +1,21 @@
+--- a/config.mk
++++ b/config.mk
+@@ -364,7 +364,8 @@ export CONFIG_IPW2200_QOS=y
+ # % echo 1 > /sys/bus/pci/drivers/ipw2200/*/rtap_iface
+ endif #CONFIG_WIRELESS_EXT
+
+-ifdef CONFIG_SSB
++# disabled
++ifdef __CONFIG_SSB
+ # Sonics Silicon Backplane
+ export CONFIG_SSB_SPROM=y
+
+@@ -377,7 +378,7 @@ endif #CONFIG_PCMCIA
+ # export CONFIG_SSB_DEBUG=y
+ export CONFIG_SSB_DRIVER_PCICORE=y
+ export CONFIG_B43_SSB=y
+-endif #CONFIG_SSB
++endif #__CONFIG_SSB
+
+ # export CONFIG_BCMA=m
+ # export CONFIG_BCMA_BLOCKIO=y
diff --git a/package/mac80211/patches/.svn/text-base/003-disable_codel.patch.svn-base b/package/mac80211/patches/.svn/text-base/003-disable_codel.patch.svn-base
new file mode 100644
index 0000000..0d6d749
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/003-disable_codel.patch.svn-base
@@ -0,0 +1,19 @@
+--- a/compat/scripts/gen-compat-config.sh
++++ b/compat/scripts/gen-compat-config.sh
+@@ -66,16 +66,3 @@ if [[ ${CONFIG_COMPAT_KERNEL_2_6_36} = "
+ echo "export CONFIG_COMPAT_KFIFO=y"
+ fi
+ fi
+-
+-if [[ ${CONFIG_COMPAT_KERNEL_3_5} = "y" ]]; then
+- # We don't have 2.6.24 backport support yet for Codel / FQ CoDel
+- # For those who want to try this is what is required that I can tell
+- # so far:
+- # * struct Qdisc_ops
+- # - init and change callback ops use a different argument dataype
+- # - you need to parse data received from userspace differently
+- if [[ ${CONFIG_COMPAT_KERNEL_2_6_25} != "y" ]]; then
+- echo "export CONFIG_COMPAT_NET_SCH_CODEL=m"
+- echo "export CONFIG_COMPAT_NET_SCH_FQ_CODEL=m"
+- fi
+-fi
diff --git a/package/mac80211/patches/.svn/text-base/004-use_env_for_bash.patch.svn-base b/package/mac80211/patches/.svn/text-base/004-use_env_for_bash.patch.svn-base
new file mode 100644
index 0000000..0ae3820
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/004-use_env_for_bash.patch.svn-base
@@ -0,0 +1,8 @@
+--- a/compat/scripts/gen-compat-config.sh
++++ b/compat/scripts/gen-compat-config.sh
+@@ -1,4 +1,4 @@
+-#!/bin/bash
++#!/usr/bin/env bash
+ # Copyright 2012 Luis R. Rodriguez <mcgrof@frijolero.org>
+ # Copyright 2012 Hauke Mehrtens <hauke@hauke-m.de>
+ #
diff --git a/package/mac80211/patches/.svn/text-base/010-add_include_for_bcma.patch.svn-base b/package/mac80211/patches/.svn/text-base/010-add_include_for_bcma.patch.svn-base
new file mode 100644
index 0000000..e2e856e
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/010-add_include_for_bcma.patch.svn-base
@@ -0,0 +1,11 @@
+--- a/include/linux/compat-3.0.h
++++ b/include/linux/compat-3.0.h
+@@ -36,6 +36,8 @@ static inline struct page *shmem_read_ma
+ #endif
+
+
++#include <linux/mod_devicetable.h>
++
+ /*
+ * since commit 1c5cae815d19ffe02bdfda1260949ef2b1806171
+ * "net: call dev_alloc_name from register_netdevice" dev_alloc_name is
diff --git a/package/mac80211/patches/.svn/text-base/020-disable_tty_set_termios.patch.svn-base b/package/mac80211/patches/.svn/text-base/020-disable_tty_set_termios.patch.svn-base
new file mode 100644
index 0000000..fc5d4d6
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/020-disable_tty_set_termios.patch.svn-base
@@ -0,0 +1,16 @@
+--- a/compat/compat-2.6.39.c
++++ b/compat/compat-2.6.39.c
+@@ -12,6 +12,7 @@
+ #include <linux/tty.h>
+ #include <linux/sched.h>
+
++#ifdef CONFIG_COMPAT_BLUETOOTH
+ #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27))
+ /*
+ * Termios Helper Methods
+@@ -111,4 +112,4 @@ int tty_set_termios(struct tty_struct *t
+ }
+ EXPORT_SYMBOL_GPL(tty_set_termios);
+ #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)) */
+-
++#endif
diff --git a/package/mac80211/patches/.svn/text-base/030-wext.patch.svn-base b/package/mac80211/patches/.svn/text-base/030-wext.patch.svn-base
new file mode 100644
index 0000000..cb52e7c
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/030-wext.patch.svn-base
@@ -0,0 +1,18 @@
+--- a/net/wireless/core.c
++++ b/net/wireless/core.c
+@@ -884,6 +884,15 @@ static int cfg80211_netdev_notifier_call
+ wdev->sme_state = CFG80211_SME_IDLE;
+ mutex_unlock(&rdev->devlist_mtx);
+ #ifdef CONFIG_CFG80211_WEXT
++#ifdef CONFIG_WIRELESS_EXT
++ if (!dev->wireless_handlers)
++ dev->wireless_handlers = &cfg80211_wext_handler;
++#else
++ printk_once(KERN_WARNING "cfg80211: wext will not work because "
++ "kernel was compiled with CONFIG_WIRELESS_EXT=n. "
++ "Tools using wext interface, like iwconfig will "
++ "not work.\n");
++#endif
+ wdev->wext.default_key = -1;
+ wdev->wext.default_mgmt_key = -1;
+ wdev->wext.connect.auth_type = NL80211_AUTHTYPE_AUTOMATIC;
diff --git a/package/mac80211/patches/.svn/text-base/040-linux_3_9_compat.patch.svn-base b/package/mac80211/patches/.svn/text-base/040-linux_3_9_compat.patch.svn-base
new file mode 100644
index 0000000..d83c39c
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/040-linux_3_9_compat.patch.svn-base
@@ -0,0 +1,153 @@
+--- a/include/linux/compat-2.6.h
++++ b/include/linux/compat-2.6.h
+@@ -69,6 +69,7 @@ void compat_dependency_symbol(void);
+ #include <linux/compat-3.6.h>
+ #include <linux/compat-3.7.h>
+ #include <linux/compat-3.8.h>
++#include <linux/compat-3.9.h>
+
+ #endif /* __ASSEMBLY__ */
+
+--- /dev/null
++++ b/include/linux/compat-3.9.h
+@@ -0,0 +1,140 @@
++#ifndef LINUX_3_9_COMPAT_H
++#define LINUX_3_9_COMPAT_H
++
++#include <linux/version.h>
++
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0))
++
++#include <linux/idr.h>
++#include <linux/list.h>
++#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,25))
++#include <linux/rculist.h>
++#endif
++#include <net/sock.h>
++#include <linux/tty.h>
++#include <linux/tty_flip.h>
++
++/* include this before changing hlist_for_each_* to use the old versions. */
++#include <net/sch_generic.h>
++
++
++/**
++ * backport of idr idr_alloc() usage
++ *
++ * This backports a patch series send by Tejun Heo:
++ * https://lkml.org/lkml/2013/2/2/159
++ */
++static inline void compat_idr_destroy(struct idr *idp)
++{
++ idr_remove_all(idp);
++ idr_destroy(idp);
++}
++#define idr_destroy(idp) compat_idr_destroy(idp)
++
++static inline int idr_alloc(struct idr *idr, void *ptr, int start, int end,
++ gfp_t gfp_mask)
++{
++ int id, ret;
++
++ do {
++ if (!idr_pre_get(idr, gfp_mask))
++ return -ENOMEM;
++ ret = idr_get_new_above(idr, ptr, start, &id);
++ if (!ret && id > end) {
++ idr_remove(idr, id);
++ ret = -ENOSPC;
++ }
++ } while (ret == -EAGAIN);
++
++ return ret ? ret : id;
++}
++
++static inline void idr_preload(gfp_t gfp_mask)
++{
++}
++
++static inline void idr_preload_end(void)
++{
++}
++
++
++/**
++ * backport:
++ *
++ * commit 0bbacca7c3911451cea923b0ad6389d58e3d9ce9
++ * Author: Sasha Levin <sasha.levin@oracle.com>
++ * Date: Thu Feb 7 12:32:18 2013 +1100
++ *
++ * hlist: drop the node parameter from iterators
++ */
++
++#define hlist_entry_safe(ptr, type, member) \
++ (ptr) ? hlist_entry(ptr, type, member) : NULL
++
++#undef hlist_for_each_entry
++/**
++ * hlist_for_each_entry - iterate over list of given type
++ * @pos: the type * to use as a loop cursor.
++ * @head: the head for your list.
++ * @member: the name of the hlist_node within the struct.
++ */
++#define hlist_for_each_entry(pos, head, member) \
++ for (pos = hlist_entry_safe((head)->first, typeof(*(pos)), member); \
++ pos; \
++ pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member))
++
++#undef hlist_for_each_entry_safe
++/**
++ * hlist_for_each_entry_safe - iterate over list of given type safe against removal of list entry
++ * @pos: the type * to use as a loop cursor.
++ * @n: another &struct hlist_node to use as temporary storage
++ * @head: the head for your list.
++ * @member: the name of the hlist_node within the struct.
++ */
++#define hlist_for_each_entry_safe(pos, n, head, member) \
++ for (pos = hlist_entry_safe((head)->first, typeof(*pos), member); \
++ pos && ({ n = pos->member.next; 1; }); \
++ pos = hlist_entry_safe(n, typeof(*pos), member))
++
++#undef hlist_for_each_entry_rcu
++/**
++ * hlist_for_each_entry_rcu - iterate over rcu list of given type
++ * @pos: the type * to use as a loop cursor.
++ * @head: the head for your list.
++ * @member: the name of the hlist_node within the struct.
++ *
++ * This list-traversal primitive may safely run concurrently with
++ * the _rcu list-mutation primitives such as hlist_add_head_rcu()
++ * as long as the traversal is guarded by rcu_read_lock().
++ */
++#define hlist_for_each_entry_rcu(pos, head, member) \
++ for (pos = hlist_entry_safe (rcu_dereference_raw(hlist_first_rcu(head)),\
++ typeof(*(pos)), member); \
++ pos; \
++ pos = hlist_entry_safe(rcu_dereference_raw(hlist_next_rcu( \
++ &(pos)->member)), typeof(*(pos)), member))
++
++#undef sk_for_each
++#define sk_for_each(__sk, list) \
++ hlist_for_each_entry(__sk, list, sk_node)
++
++#define tty_flip_buffer_push(port) tty_flip_buffer_push((port)->tty)
++#define tty_insert_flip_string(port, chars, size) tty_insert_flip_string((port)->tty, chars, size)
++
++/**
++ * backport of:
++ *
++ * commit 496ad9aa8ef448058e36ca7a787c61f2e63f0f54
++ * Author: Al Viro <viro@zeniv.linux.org.uk>
++ * Date: Wed Jan 23 17:07:38 2013 -0500
++ *
++ * new helper: file_inode(file)
++ */
++static inline struct inode *file_inode(struct file *f)
++{
++ return f->f_path.dentry->d_inode;
++}
++
++#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)) */
++
++#endif /* LINUX_3_9_COMPAT_H */
diff --git a/package/mac80211/patches/.svn/text-base/130-mesh_pathtbl_backport.patch.svn-base b/package/mac80211/patches/.svn/text-base/130-mesh_pathtbl_backport.patch.svn-base
new file mode 100644
index 0000000..1322099
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/130-mesh_pathtbl_backport.patch.svn-base
@@ -0,0 +1,212 @@
+--- a/net/mac80211/mesh_pathtbl.c
++++ b/net/mac80211/mesh_pathtbl.c
+@@ -72,9 +72,9 @@ static inline struct mesh_table *resize_
+ * it's used twice. So it is illegal to do
+ * for_each_mesh_entry(rcu_dereference(...), ...)
+ */
+-#define for_each_mesh_entry(tbl, p, node, i) \
++#define for_each_mesh_entry(tbl, node, i) \
+ for (i = 0; i <= tbl->hash_mask; i++) \
+- hlist_for_each_entry_rcu(node, p, &tbl->hash_buckets[i], list)
++ hlist_for_each_entry_rcu(node, &tbl->hash_buckets[i], list)
+
+
+ static struct mesh_table *mesh_table_alloc(int size_order)
+@@ -139,7 +139,7 @@ static void mesh_table_free(struct mesh_
+ }
+ if (free_leafs) {
+ spin_lock_bh(&tbl->gates_lock);
+- hlist_for_each_entry_safe(gate, p, q,
++ hlist_for_each_entry_safe(gate, q,
+ tbl->known_gates, list) {
+ hlist_del(&gate->list);
+ kfree(gate);
+@@ -333,12 +333,11 @@ static struct mesh_path *mpath_lookup(st
+ struct ieee80211_sub_if_data *sdata)
+ {
+ struct mesh_path *mpath;
+- struct hlist_node *n;
+ struct hlist_head *bucket;
+ struct mpath_node *node;
+
+ bucket = &tbl->hash_buckets[mesh_table_hash(dst, sdata, tbl)];
+- hlist_for_each_entry_rcu(node, n, bucket, list) {
++ hlist_for_each_entry_rcu(node, bucket, list) {
+ mpath = node->mpath;
+ if (mpath->sdata == sdata &&
+ ether_addr_equal(dst, mpath->dst)) {
+@@ -389,11 +388,10 @@ mesh_path_lookup_by_idx(struct ieee80211
+ {
+ struct mesh_table *tbl = rcu_dereference(mesh_paths);
+ struct mpath_node *node;
+- struct hlist_node *p;
+ int i;
+ int j = 0;
+
+- for_each_mesh_entry(tbl, p, node, i) {
++ for_each_mesh_entry(tbl, node, i) {
+ if (sdata && node->mpath->sdata != sdata)
+ continue;
+ if (j++ == idx) {
+@@ -417,13 +415,12 @@ int mesh_path_add_gate(struct mesh_path
+ {
+ struct mesh_table *tbl;
+ struct mpath_node *gate, *new_gate;
+- struct hlist_node *n;
+ int err;
+
+ rcu_read_lock();
+ tbl = rcu_dereference(mesh_paths);
+
+- hlist_for_each_entry_rcu(gate, n, tbl->known_gates, list)
++ hlist_for_each_entry_rcu(gate, tbl->known_gates, list)
+ if (gate->mpath == mpath) {
+ err = -EEXIST;
+ goto err_rcu;
+@@ -460,9 +457,9 @@ err_rcu:
+ static void mesh_gate_del(struct mesh_table *tbl, struct mesh_path *mpath)
+ {
+ struct mpath_node *gate;
+- struct hlist_node *p, *q;
++ struct hlist_node *q;
+
+- hlist_for_each_entry_safe(gate, p, q, tbl->known_gates, list) {
++ hlist_for_each_entry_safe(gate, q, tbl->known_gates, list) {
+ if (gate->mpath != mpath)
+ continue;
+ spin_lock_bh(&tbl->gates_lock);
+@@ -504,7 +501,6 @@ int mesh_path_add(struct ieee80211_sub_i
+ struct mesh_path *mpath, *new_mpath;
+ struct mpath_node *node, *new_node;
+ struct hlist_head *bucket;
+- struct hlist_node *n;
+ int grow = 0;
+ int err = 0;
+ u32 hash_idx;
+@@ -550,7 +546,7 @@ int mesh_path_add(struct ieee80211_sub_i
+ spin_lock(&tbl->hashwlock[hash_idx]);
+
+ err = -EEXIST;
+- hlist_for_each_entry(node, n, bucket, list) {
++ hlist_for_each_entry(node, bucket, list) {
+ mpath = node->mpath;
+ if (mpath->sdata == sdata &&
+ ether_addr_equal(dst, mpath->dst))
+@@ -640,7 +636,6 @@ int mpp_path_add(struct ieee80211_sub_if
+ struct mesh_path *mpath, *new_mpath;
+ struct mpath_node *node, *new_node;
+ struct hlist_head *bucket;
+- struct hlist_node *n;
+ int grow = 0;
+ int err = 0;
+ u32 hash_idx;
+@@ -680,7 +675,7 @@ int mpp_path_add(struct ieee80211_sub_if
+ spin_lock(&tbl->hashwlock[hash_idx]);
+
+ err = -EEXIST;
+- hlist_for_each_entry(node, n, bucket, list) {
++ hlist_for_each_entry(node, bucket, list) {
+ mpath = node->mpath;
+ if (mpath->sdata == sdata &&
+ ether_addr_equal(dst, mpath->dst))
+@@ -725,14 +720,13 @@ void mesh_plink_broken(struct sta_info *
+ static const u8 bcast[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
+ struct mesh_path *mpath;
+ struct mpath_node *node;
+- struct hlist_node *p;
+ struct ieee80211_sub_if_data *sdata = sta->sdata;
+ int i;
+ __le16 reason = cpu_to_le16(WLAN_REASON_MESH_PATH_DEST_UNREACHABLE);
+
+ rcu_read_lock();
+ tbl = rcu_dereference(mesh_paths);
+- for_each_mesh_entry(tbl, p, node, i) {
++ for_each_mesh_entry(tbl, node, i) {
+ mpath = node->mpath;
+ if (rcu_dereference(mpath->next_hop) == sta &&
+ mpath->flags & MESH_PATH_ACTIVE &&
+@@ -792,13 +786,12 @@ void mesh_path_flush_by_nexthop(struct s
+ struct mesh_table *tbl;
+ struct mesh_path *mpath;
+ struct mpath_node *node;
+- struct hlist_node *p;
+ int i;
+
+ rcu_read_lock();
+ read_lock_bh(&pathtbl_resize_lock);
+ tbl = resize_dereference_mesh_paths();
+- for_each_mesh_entry(tbl, p, node, i) {
++ for_each_mesh_entry(tbl, node, i) {
+ mpath = node->mpath;
+ if (rcu_dereference(mpath->next_hop) == sta) {
+ spin_lock(&tbl->hashwlock[i]);
+@@ -815,11 +808,9 @@ static void table_flush_by_iface(struct
+ {
+ struct mesh_path *mpath;
+ struct mpath_node *node;
+- struct hlist_node *p;
+ int i;
+
+- WARN_ON(!rcu_read_lock_held());
+- for_each_mesh_entry(tbl, p, node, i) {
++ for_each_mesh_entry(tbl, node, i) {
+ mpath = node->mpath;
+ if (mpath->sdata != sdata)
+ continue;
+@@ -865,7 +856,6 @@ int mesh_path_del(struct ieee80211_sub_i
+ struct mesh_path *mpath;
+ struct mpath_node *node;
+ struct hlist_head *bucket;
+- struct hlist_node *n;
+ int hash_idx;
+ int err = 0;
+
+@@ -875,7 +865,7 @@ int mesh_path_del(struct ieee80211_sub_i
+ bucket = &tbl->hash_buckets[hash_idx];
+
+ spin_lock(&tbl->hashwlock[hash_idx]);
+- hlist_for_each_entry(node, n, bucket, list) {
++ hlist_for_each_entry(node, bucket, list) {
+ mpath = node->mpath;
+ if (mpath->sdata == sdata &&
+ ether_addr_equal(addr, mpath->dst)) {
+@@ -920,7 +910,6 @@ void mesh_path_tx_pending(struct mesh_pa
+ int mesh_path_send_to_gates(struct mesh_path *mpath)
+ {
+ struct ieee80211_sub_if_data *sdata = mpath->sdata;
+- struct hlist_node *n;
+ struct mesh_table *tbl;
+ struct mesh_path *from_mpath = mpath;
+ struct mpath_node *gate = NULL;
+@@ -935,7 +924,7 @@ int mesh_path_send_to_gates(struct mesh_
+ if (!known_gates)
+ return -EHOSTUNREACH;
+
+- hlist_for_each_entry_rcu(gate, n, known_gates, list) {
++ hlist_for_each_entry_rcu(gate, known_gates, list) {
+ if (gate->mpath->sdata != sdata)
+ continue;
+
+@@ -951,7 +940,7 @@ int mesh_path_send_to_gates(struct mesh_
+ }
+ }
+
+- hlist_for_each_entry_rcu(gate, n, known_gates, list)
++ hlist_for_each_entry_rcu(gate, known_gates, list)
+ if (gate->mpath->sdata == sdata) {
+ mpath_dbg(sdata, "Sending to %pM\n", gate->mpath->dst);
+ mesh_path_tx_pending(gate->mpath);
+@@ -1096,12 +1085,11 @@ void mesh_path_expire(struct ieee80211_s
+ struct mesh_table *tbl;
+ struct mesh_path *mpath;
+ struct mpath_node *node;
+- struct hlist_node *p;
+ int i;
+
+ rcu_read_lock();
+ tbl = rcu_dereference(mesh_paths);
+- for_each_mesh_entry(tbl, p, node, i) {
++ for_each_mesh_entry(tbl, node, i) {
+ if (node->mpath->sdata != sdata)
+ continue;
+ mpath = node->mpath;
diff --git a/package/mac80211/patches/.svn/text-base/150-disable_addr_notifier.patch.svn-base b/package/mac80211/patches/.svn/text-base/150-disable_addr_notifier.patch.svn-base
new file mode 100644
index 0000000..9714696
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/150-disable_addr_notifier.patch.svn-base
@@ -0,0 +1,67 @@
+--- a/net/mac80211/main.c
++++ b/net/mac80211/main.c
+@@ -313,7 +313,7 @@ void ieee80211_restart_hw(struct ieee802
+ }
+ EXPORT_SYMBOL(ieee80211_restart_hw);
+
+-#ifdef CONFIG_INET
++#ifdef __disabled__CONFIG_INET
+ static int ieee80211_ifa_changed(struct notifier_block *nb,
+ unsigned long data, void *arg)
+ {
+@@ -372,7 +372,7 @@ static int ieee80211_ifa_changed(struct
+ }
+ #endif
+
+-#if IS_ENABLED(CONFIG_IPV6)
++#if IS_ENABLED(__disabled__CONFIG_IPV6)
+ static int ieee80211_ifa6_changed(struct notifier_block *nb,
+ unsigned long data, void *arg)
+ {
+@@ -1015,14 +1015,14 @@ int ieee80211_register_hw(struct ieee802
+ goto fail_pm_qos;
+ }
+
+-#ifdef CONFIG_INET
++#ifdef __disabled__CONFIG_INET
+ local->ifa_notifier.notifier_call = ieee80211_ifa_changed;
+ result = register_inetaddr_notifier(&local->ifa_notifier);
+ if (result)
+ goto fail_ifa;
+ #endif
+
+-#if IS_ENABLED(CONFIG_IPV6)
++#if IS_ENABLED(__disabled__CONFIG_IPV6)
+ local->ifa6_notifier.notifier_call = ieee80211_ifa6_changed;
+ result = register_inet6addr_notifier(&local->ifa6_notifier);
+ if (result)
+@@ -1034,13 +1034,13 @@ int ieee80211_register_hw(struct ieee802
+
+ return 0;
+
+-#if IS_ENABLED(CONFIG_IPV6)
++#if IS_ENABLED(__disabled__CONFIG_IPV6)
+ fail_ifa6:
+-#ifdef CONFIG_INET
++#ifdef __disabled__CONFIG_INET
+ unregister_inetaddr_notifier(&local->ifa_notifier);
+ #endif
+ #endif
+-#if defined(CONFIG_INET) || defined(CONFIG_IPV6)
++#if defined(__disabled__CONFIG_INET) || defined(__disabled__CONFIG_IPV6)
+ fail_ifa:
+ pm_qos_remove_notifier(PM_QOS_NETWORK_LATENCY,
+ &local->network_latency_notifier);
+@@ -1073,10 +1073,10 @@ void ieee80211_unregister_hw(struct ieee
+
+ pm_qos_remove_notifier(PM_QOS_NETWORK_LATENCY,
+ &local->network_latency_notifier);
+-#ifdef CONFIG_INET
++#ifdef __disabled__CONFIG_INET
+ unregister_inetaddr_notifier(&local->ifa_notifier);
+ #endif
+-#if IS_ENABLED(CONFIG_IPV6)
++#if IS_ENABLED(__disabled__CONFIG_IPV6)
+ unregister_inet6addr_notifier(&local->ifa6_notifier);
+ #endif
+
diff --git a/package/mac80211/patches/.svn/text-base/201-ath5k-WAR-for-AR71xx-PCI-bug.patch.svn-base b/package/mac80211/patches/.svn/text-base/201-ath5k-WAR-for-AR71xx-PCI-bug.patch.svn-base
new file mode 100644
index 0000000..9e08a08
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/201-ath5k-WAR-for-AR71xx-PCI-bug.patch.svn-base
@@ -0,0 +1,38 @@
+--- a/drivers/net/wireless/ath/ath5k/initvals.c
++++ b/drivers/net/wireless/ath/ath5k/initvals.c
+@@ -65,8 +65,14 @@ static const struct ath5k_ini ar5210_ini
+ { AR5K_IMR, 0 },
+ { AR5K_IER, AR5K_IER_DISABLE },
+ { AR5K_BSR, 0, AR5K_INI_READ },
++#if !defined(CONFIG_ATHEROS_AR71XX) && !defined(CONFIG_ATH79)
+ { AR5K_TXCFG, AR5K_DMASIZE_128B },
+ { AR5K_RXCFG, AR5K_DMASIZE_128B },
++#else
++ /* WAR for AR71xx PCI bug */
++ { AR5K_TXCFG, AR5K_DMASIZE_128B },
++ { AR5K_RXCFG, AR5K_DMASIZE_4B },
++#endif
+ { AR5K_CFG, AR5K_INIT_CFG },
+ { AR5K_TOPS, 8 },
+ { AR5K_RXNOFRM, 8 },
+--- a/drivers/net/wireless/ath/ath5k/dma.c
++++ b/drivers/net/wireless/ath/ath5k/dma.c
+@@ -863,10 +863,18 @@ ath5k_hw_dma_init(struct ath5k_hw *ah)
+ * guess we can tweak it and see how it goes ;-)
+ */
+ if (ah->ah_version != AR5K_AR5210) {
++#if !defined(CONFIG_ATHEROS_AR71XX) && !defined(CONFIG_ATH79)
+ AR5K_REG_WRITE_BITS(ah, AR5K_TXCFG,
+ AR5K_TXCFG_SDMAMR, AR5K_DMASIZE_128B);
+ AR5K_REG_WRITE_BITS(ah, AR5K_RXCFG,
+ AR5K_RXCFG_SDMAMW, AR5K_DMASIZE_128B);
++#else
++ /* WAR for AR71xx PCI bug */
++ AR5K_REG_WRITE_BITS(ah, AR5K_TXCFG,
++ AR5K_TXCFG_SDMAMR, AR5K_DMASIZE_128B);
++ AR5K_REG_WRITE_BITS(ah, AR5K_RXCFG,
++ AR5K_RXCFG_SDMAMW, AR5K_DMASIZE_4B);
++#endif
+ }
+
+ /* Pre-enable interrupts on 5211/5212*/
diff --git a/package/mac80211/patches/.svn/text-base/300-pending_work.patch.svn-base b/package/mac80211/patches/.svn/text-base/300-pending_work.patch.svn-base
new file mode 100644
index 0000000..cf51aae
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/300-pending_work.patch.svn-base
@@ -0,0 +1,963 @@
+--- a/drivers/net/wireless/ath/ath9k/common.h
++++ b/drivers/net/wireless/ath/ath9k/common.h
+@@ -27,7 +27,7 @@
+ #define WME_MAX_BA WME_BA_BMP_SIZE
+ #define ATH_TID_MAX_BUFS (2 * WME_MAX_BA)
+
+-#define ATH_RSSI_DUMMY_MARKER 0x127
++#define ATH_RSSI_DUMMY_MARKER 127
+ #define ATH_RSSI_LPF_LEN 10
+ #define RSSI_LPF_THRESHOLD -20
+ #define ATH_RSSI_EP_MULTIPLIER (1<<7)
+--- a/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
++++ b/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
+@@ -1067,15 +1067,19 @@ static bool ath9k_rx_prepare(struct ath9
+
+ last_rssi = priv->rx.last_rssi;
+
+- if (likely(last_rssi != ATH_RSSI_DUMMY_MARKER))
+- rxbuf->rxstatus.rs_rssi = ATH_EP_RND(last_rssi,
+- ATH_RSSI_EP_MULTIPLIER);
++ if (ieee80211_is_beacon(hdr->frame_control) &&
++ !is_zero_ether_addr(common->curbssid) &&
++ ether_addr_equal(hdr->addr3, common->curbssid)) {
++ s8 rssi = rxbuf->rxstatus.rs_rssi;
+
+- if (rxbuf->rxstatus.rs_rssi < 0)
+- rxbuf->rxstatus.rs_rssi = 0;
++ if (likely(last_rssi != ATH_RSSI_DUMMY_MARKER))
++ rssi = ATH_EP_RND(last_rssi, ATH_RSSI_EP_MULTIPLIER);
+
+- if (ieee80211_is_beacon(fc))
+- priv->ah->stats.avgbrssi = rxbuf->rxstatus.rs_rssi;
++ if (rssi < 0)
++ rssi = 0;
++
++ priv->ah->stats.avgbrssi = rssi;
++ }
+
+ rx_status->mactime = be64_to_cpu(rxbuf->rxstatus.rs_tstamp);
+ rx_status->band = hw->conf.channel->band;
+--- a/include/linux/ieee80211.h
++++ b/include/linux/ieee80211.h
+@@ -185,7 +185,7 @@ struct ieee80211_hdr {
+ u8 addr3[6];
+ __le16 seq_ctrl;
+ u8 addr4[6];
+-} __packed;
++} __packed __aligned(2);
+
+ struct ieee80211_hdr_3addr {
+ __le16 frame_control;
+@@ -194,7 +194,7 @@ struct ieee80211_hdr_3addr {
+ u8 addr2[6];
+ u8 addr3[6];
+ __le16 seq_ctrl;
+-} __packed;
++} __packed __aligned(2);
+
+ struct ieee80211_qos_hdr {
+ __le16 frame_control;
+@@ -204,7 +204,7 @@ struct ieee80211_qos_hdr {
+ u8 addr3[6];
+ __le16 seq_ctrl;
+ __le16 qos_ctrl;
+-} __packed;
++} __packed __aligned(2);
+
+ /**
+ * ieee80211_has_tods - check if IEEE80211_FCTL_TODS is set
+@@ -581,7 +581,7 @@ struct ieee80211s_hdr {
+ __le32 seqnum;
+ u8 eaddr1[6];
+ u8 eaddr2[6];
+-} __packed;
++} __packed __aligned(2);
+
+ /* Mesh flags */
+ #define MESH_FLAGS_AE_A4 0x1
+@@ -875,7 +875,7 @@ struct ieee80211_mgmt {
+ } u;
+ } __packed action;
+ } u;
+-} __packed;
++} __packed __aligned(2);
+
+ /* Supported Rates value encodings in 802.11n-2009 7.3.2.2 */
+ #define BSS_MEMBERSHIP_SELECTOR_HT_PHY 127
+@@ -906,20 +906,20 @@ struct ieee80211_rts {
+ __le16 duration;
+ u8 ra[6];
+ u8 ta[6];
+-} __packed;
++} __packed __aligned(2);
+
+ struct ieee80211_cts {
+ __le16 frame_control;
+ __le16 duration;
+ u8 ra[6];
+-} __packed;
++} __packed __aligned(2);
+
+ struct ieee80211_pspoll {
+ __le16 frame_control;
+ __le16 aid;
+ u8 bssid[6];
+ u8 ta[6];
+-} __packed;
++} __packed __aligned(2);
+
+ /* TDLS */
+
+--- a/net/mac80211/agg-rx.c
++++ b/net/mac80211/agg-rx.c
+@@ -204,6 +204,8 @@ static void ieee80211_send_addba_resp(st
+ memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
+ else if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
+ memcpy(mgmt->bssid, sdata->u.ibss.bssid, ETH_ALEN);
++ else if (sdata->vif.type == NL80211_IFTYPE_WDS)
++ memcpy(mgmt->bssid, da, ETH_ALEN);
+
+ mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
+ IEEE80211_STYPE_ACTION);
+--- a/net/mac80211/agg-tx.c
++++ b/net/mac80211/agg-tx.c
+@@ -81,7 +81,8 @@ static void ieee80211_send_addba_request
+ memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
+ if (sdata->vif.type == NL80211_IFTYPE_AP ||
+ sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
+- sdata->vif.type == NL80211_IFTYPE_MESH_POINT)
++ sdata->vif.type == NL80211_IFTYPE_MESH_POINT ||
++ sdata->vif.type == NL80211_IFTYPE_WDS)
+ memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN);
+ else if (sdata->vif.type == NL80211_IFTYPE_STATION)
+ memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
+@@ -527,6 +528,7 @@ int ieee80211_start_tx_ba_session(struct
+ sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
+ sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
+ sdata->vif.type != NL80211_IFTYPE_AP &&
++ sdata->vif.type != NL80211_IFTYPE_WDS &&
+ sdata->vif.type != NL80211_IFTYPE_ADHOC)
+ return -EINVAL;
+
+--- a/net/mac80211/debugfs_sta.c
++++ b/net/mac80211/debugfs_sta.c
+@@ -65,11 +65,11 @@ static ssize_t sta_flags_read(struct fil
+ test_sta_flag(sta, WLAN_STA_##flg) ? #flg "\n" : ""
+
+ int res = scnprintf(buf, sizeof(buf),
+- "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
++ "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
+ TEST(AUTH), TEST(ASSOC), TEST(PS_STA),
+ TEST(PS_DRIVER), TEST(AUTHORIZED),
+ TEST(SHORT_PREAMBLE),
+- TEST(WME), TEST(WDS), TEST(CLEAR_PS_FILT),
++ TEST(WME), TEST(CLEAR_PS_FILT),
+ TEST(MFP), TEST(BLOCK_BA), TEST(PSPOLL),
+ TEST(UAPSD), TEST(SP), TEST(TDLS_PEER),
+ TEST(TDLS_PEER_AUTH), TEST(4ADDR_EVENT),
+--- a/net/mac80211/iface.c
++++ b/net/mac80211/iface.c
+@@ -107,7 +107,7 @@ void ieee80211_recalc_idle(struct ieee80
+
+ lockdep_assert_held(&local->mtx);
+
+- active = !list_empty(&local->chanctx_list);
++ active = !list_empty(&local->chanctx_list) || local->monitors;
+
+ if (!local->ops->remain_on_channel) {
+ list_for_each_entry(roc, &local->roc_list, list) {
+@@ -436,7 +436,6 @@ int ieee80211_do_open(struct wireless_de
+ struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
+ struct net_device *dev = wdev->netdev;
+ struct ieee80211_local *local = sdata->local;
+- struct sta_info *sta;
+ u32 changed = 0;
+ int res;
+ u32 hw_reconf_flags = 0;
+@@ -541,6 +540,9 @@ int ieee80211_do_open(struct wireless_de
+
+ ieee80211_adjust_monitor_flags(sdata, 1);
+ ieee80211_configure_filter(local);
++ mutex_lock(&local->mtx);
++ ieee80211_recalc_idle(local);
++ mutex_unlock(&local->mtx);
+
+ netif_carrier_on(dev);
+ break;
+@@ -595,30 +597,8 @@ int ieee80211_do_open(struct wireless_de
+
+ set_bit(SDATA_STATE_RUNNING, &sdata->state);
+
+- if (sdata->vif.type == NL80211_IFTYPE_WDS) {
+- /* Create STA entry for the WDS peer */
+- sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
+- GFP_KERNEL);
+- if (!sta) {
+- res = -ENOMEM;
+- goto err_del_interface;
+- }
+-
+- sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
+- sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
+- sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED);
+-
+- res = sta_info_insert(sta);
+- if (res) {
+- /* STA has been freed */
+- goto err_del_interface;
+- }
+-
+- rate_control_rate_init(sta);
+- netif_carrier_on(dev);
+- } else if (sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE) {
++ if (sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE)
+ rcu_assign_pointer(local->p2p_sdata, sdata);
+- }
+
+ /*
+ * set_multicast_list will be invoked by the networking core
+@@ -817,6 +797,9 @@ static void ieee80211_do_stop(struct iee
+
+ ieee80211_adjust_monitor_flags(sdata, -1);
+ ieee80211_configure_filter(local);
++ mutex_lock(&local->mtx);
++ ieee80211_recalc_idle(local);
++ mutex_unlock(&local->mtx);
+ break;
+ case NL80211_IFTYPE_P2P_DEVICE:
+ /* relies on synchronize_rcu() below */
+@@ -1022,6 +1005,72 @@ static void ieee80211_if_setup(struct ne
+ dev->destructor = free_netdev;
+ }
+
++static void ieee80211_wds_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
++ struct sk_buff *skb)
++{
++ struct ieee80211_local *local = sdata->local;
++ struct ieee80211_rx_status *rx_status;
++ struct ieee802_11_elems elems;
++ struct ieee80211_mgmt *mgmt;
++ struct sta_info *sta;
++ size_t baselen;
++ u32 rates = 0;
++ u16 stype;
++ bool new = false;
++ enum ieee80211_band band = local->hw.conf.channel->band;
++ struct ieee80211_supported_band *sband = local->hw.wiphy->bands[band];
++
++ rx_status = IEEE80211_SKB_RXCB(skb);
++ mgmt = (struct ieee80211_mgmt *) skb->data;
++ stype = le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE;
++
++ if (stype != IEEE80211_STYPE_BEACON)
++ return;
++
++ baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
++ if (baselen > skb->len)
++ return;
++
++ ieee802_11_parse_elems(mgmt->u.probe_resp.variable,
++ skb->len - baselen, &elems);
++
++ rates = ieee80211_sta_get_rates(local, &elems, band, NULL);
++
++ rcu_read_lock();
++
++ sta = sta_info_get(sdata, sdata->u.wds.remote_addr);
++
++ if (!sta) {
++ rcu_read_unlock();
++ sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
++ GFP_KERNEL);
++ if (!sta)
++ return;
++
++ new = true;
++ }
++
++ sta->last_rx = jiffies;
++ sta->sta.supp_rates[local->hw.conf.channel->band] = rates;
++
++ if (elems.ht_cap_elem)
++ ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband,
++ elems.ht_cap_elem, sta);
++
++ if (elems.wmm_param)
++ set_sta_flag(sta, WLAN_STA_WME);
++
++ if (new) {
++ sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
++ sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
++ sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED);
++ rate_control_rate_init(sta);
++ sta_info_insert_rcu(sta);
++ }
++
++ rcu_read_unlock();
++}
++
+ static void ieee80211_iface_work(struct work_struct *work)
+ {
+ struct ieee80211_sub_if_data *sdata =
+@@ -1126,6 +1175,9 @@ static void ieee80211_iface_work(struct
+ break;
+ ieee80211_mesh_rx_queued_mgmt(sdata, skb);
+ break;
++ case NL80211_IFTYPE_WDS:
++ ieee80211_wds_rx_queued_mgmt(sdata, skb);
++ break;
+ default:
+ WARN(1, "frame for unexpected interface type");
+ break;
+--- a/net/mac80211/rx.c
++++ b/net/mac80211/rx.c
+@@ -2365,6 +2365,7 @@ ieee80211_rx_h_action(struct ieee80211_r
+ sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
+ sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
+ sdata->vif.type != NL80211_IFTYPE_AP &&
++ sdata->vif.type != NL80211_IFTYPE_WDS &&
+ sdata->vif.type != NL80211_IFTYPE_ADHOC)
+ break;
+
+@@ -2692,14 +2693,15 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_
+
+ if (!ieee80211_vif_is_mesh(&sdata->vif) &&
+ sdata->vif.type != NL80211_IFTYPE_ADHOC &&
+- sdata->vif.type != NL80211_IFTYPE_STATION)
++ sdata->vif.type != NL80211_IFTYPE_STATION &&
++ sdata->vif.type != NL80211_IFTYPE_WDS)
+ return RX_DROP_MONITOR;
+
+ switch (stype) {
+ case cpu_to_le16(IEEE80211_STYPE_AUTH):
+ case cpu_to_le16(IEEE80211_STYPE_BEACON):
+ case cpu_to_le16(IEEE80211_STYPE_PROBE_RESP):
+- /* process for all: mesh, mlme, ibss */
++ /* process for all: mesh, mlme, ibss, wds */
+ break;
+ case cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP):
+ case cpu_to_le16(IEEE80211_STYPE_REASSOC_RESP):
+@@ -3028,10 +3030,16 @@ static int prepare_for_handlers(struct i
+ }
+ break;
+ case NL80211_IFTYPE_WDS:
+- if (bssid || !ieee80211_is_data(hdr->frame_control))
+- return 0;
+ if (!ether_addr_equal(sdata->u.wds.remote_addr, hdr->addr2))
+ return 0;
++
++ if (ieee80211_is_data(hdr->frame_control) ||
++ ieee80211_is_action(hdr->frame_control)) {
++ if (compare_ether_addr(sdata->vif.addr, hdr->addr1))
++ return 0;
++ } else if (!ieee80211_is_beacon(hdr->frame_control))
++ return 0;
++
+ break;
+ case NL80211_IFTYPE_P2P_DEVICE:
+ if (!ieee80211_is_public_action(hdr, skb->len) &&
+--- a/net/mac80211/sta_info.h
++++ b/net/mac80211/sta_info.h
+@@ -32,7 +32,6 @@
+ * @WLAN_STA_SHORT_PREAMBLE: Station is capable of receiving short-preamble
+ * frames.
+ * @WLAN_STA_WME: Station is a QoS-STA.
+- * @WLAN_STA_WDS: Station is one of our WDS peers.
+ * @WLAN_STA_CLEAR_PS_FILT: Clear PS filter in hardware (using the
+ * IEEE80211_TX_CTL_CLEAR_PS_FILT control flag) when the next
+ * frame to this station is transmitted.
+@@ -66,7 +65,6 @@ enum ieee80211_sta_info_flags {
+ WLAN_STA_AUTHORIZED,
+ WLAN_STA_SHORT_PREAMBLE,
+ WLAN_STA_WME,
+- WLAN_STA_WDS,
+ WLAN_STA_CLEAR_PS_FILT,
+ WLAN_STA_MFP,
+ WLAN_STA_BLOCK_BA,
+--- a/net/mac80211/tx.c
++++ b/net/mac80211/tx.c
+@@ -1231,34 +1231,40 @@ static bool ieee80211_tx_frags(struct ie
+ if (local->queue_stop_reasons[q] ||
+ (!txpending && !skb_queue_empty(&local->pending[q]))) {
+ if (unlikely(info->flags &
+- IEEE80211_TX_INTFL_OFFCHAN_TX_OK &&
+- local->queue_stop_reasons[q] &
+- ~BIT(IEEE80211_QUEUE_STOP_REASON_OFFCHANNEL))) {
++ IEEE80211_TX_INTFL_OFFCHAN_TX_OK)) {
++ if (local->queue_stop_reasons[q] &
++ ~BIT(IEEE80211_QUEUE_STOP_REASON_OFFCHANNEL)) {
++ /*
++ * Drop off-channel frames if queues
++ * are stopped for any reason other
++ * than off-channel operation. Never
++ * queue them.
++ */
++ spin_unlock_irqrestore(
++ &local->queue_stop_reason_lock,
++ flags);
++ ieee80211_purge_tx_queue(&local->hw,
++ skbs);
++ return true;
++ }
++ } else {
++
+ /*
+- * Drop off-channel frames if queues are stopped
+- * for any reason other than off-channel
+- * operation. Never queue them.
++ * Since queue is stopped, queue up frames for
++ * later transmission from the tx-pending
++ * tasklet when the queue is woken again.
+ */
+- spin_unlock_irqrestore(
+- &local->queue_stop_reason_lock, flags);
+- ieee80211_purge_tx_queue(&local->hw, skbs);
+- return true;
++ if (txpending)
++ skb_queue_splice_init(skbs,
++ &local->pending[q]);
++ else
++ skb_queue_splice_tail_init(skbs,
++ &local->pending[q]);
++
++ spin_unlock_irqrestore(&local->queue_stop_reason_lock,
++ flags);
++ return false;
+ }
+-
+- /*
+- * Since queue is stopped, queue up frames for later
+- * transmission from the tx-pending tasklet when the
+- * queue is woken again.
+- */
+- if (txpending)
+- skb_queue_splice_init(skbs, &local->pending[q]);
+- else
+- skb_queue_splice_tail_init(skbs,
+- &local->pending[q]);
+-
+- spin_unlock_irqrestore(&local->queue_stop_reason_lock,
+- flags);
+- return false;
+ }
+ spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
+
+@@ -1848,9 +1854,24 @@ netdev_tx_t ieee80211_subif_start_xmit(s
+ }
+
+ if (!is_multicast_ether_addr(skb->data)) {
++ struct sta_info *next_hop;
++ bool mpp_lookup = true;
++
+ mpath = mesh_path_lookup(sdata, skb->data);
+- if (!mpath)
++ if (mpath) {
++ mpp_lookup = false;
++ next_hop = rcu_dereference(mpath->next_hop);
++ if (!next_hop ||
++ !(mpath->flags & (MESH_PATH_ACTIVE |
++ MESH_PATH_RESOLVING)))
++ mpp_lookup = true;
++ }
++
++ if (mpp_lookup)
+ mppath = mpp_path_lookup(sdata, skb->data);
++
++ if (mppath && mpath)
++ mesh_path_del(mpath->sdata, mpath->dst);
+ }
+
+ /*
+--- a/net/wireless/nl80211.c
++++ b/net/wireless/nl80211.c
+@@ -554,16 +554,9 @@ static int nl80211_msg_put_channel(struc
+ if ((chan->flags & IEEE80211_CHAN_NO_IBSS) &&
+ nla_put_flag(msg, NL80211_FREQUENCY_ATTR_NO_IBSS))
+ goto nla_put_failure;
+- if (chan->flags & IEEE80211_CHAN_RADAR) {
+- u32 time = elapsed_jiffies_msecs(chan->dfs_state_entered);
+- if (nla_put_flag(msg, NL80211_FREQUENCY_ATTR_RADAR))
+- goto nla_put_failure;
+- if (nla_put_u32(msg, NL80211_FREQUENCY_ATTR_DFS_STATE,
+- chan->dfs_state))
+- goto nla_put_failure;
+- if (nla_put_u32(msg, NL80211_FREQUENCY_ATTR_DFS_TIME, time))
+- goto nla_put_failure;
+- }
++ if ((chan->flags & IEEE80211_CHAN_RADAR) &&
++ nla_put_flag(msg, NL80211_FREQUENCY_ATTR_RADAR))
++ goto nla_put_failure;
+ if ((chan->flags & IEEE80211_CHAN_NO_HT40MINUS) &&
+ nla_put_flag(msg, NL80211_FREQUENCY_ATTR_NO_HT40_MINUS))
+ goto nla_put_failure;
+@@ -900,9 +893,6 @@ static int nl80211_put_iface_combination
+ nla_put_u32(msg, NL80211_IFACE_COMB_MAXNUM,
+ c->max_interfaces))
+ goto nla_put_failure;
+- if (nla_put_u32(msg, NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS,
+- c->radar_detect_widths))
+- goto nla_put_failure;
+
+ nla_nest_end(msg, nl_combi);
+ }
+@@ -914,48 +904,6 @@ nla_put_failure:
+ return -ENOBUFS;
+ }
+
+-#ifdef CONFIG_PM
+-static int nl80211_send_wowlan_tcp_caps(struct cfg80211_registered_device *rdev,
+- struct sk_buff *msg)
+-{
+- const struct wiphy_wowlan_tcp_support *tcp = rdev->wiphy.wowlan.tcp;
+- struct nlattr *nl_tcp;
+-
+- if (!tcp)
+- return 0;
+-
+- nl_tcp = nla_nest_start(msg, NL80211_WOWLAN_TRIG_TCP_CONNECTION);
+- if (!nl_tcp)
+- return -ENOBUFS;
+-
+- if (nla_put_u32(msg, NL80211_WOWLAN_TCP_DATA_PAYLOAD,
+- tcp->data_payload_max))
+- return -ENOBUFS;
+-
+- if (nla_put_u32(msg, NL80211_WOWLAN_TCP_DATA_PAYLOAD,
+- tcp->data_payload_max))
+- return -ENOBUFS;
+-
+- if (tcp->seq && nla_put_flag(msg, NL80211_WOWLAN_TCP_DATA_PAYLOAD_SEQ))
+- return -ENOBUFS;
+-
+- if (tcp->tok && nla_put(msg, NL80211_WOWLAN_TCP_DATA_PAYLOAD_TOKEN,
+- sizeof(*tcp->tok), tcp->tok))
+- return -ENOBUFS;
+-
+- if (nla_put_u32(msg, NL80211_WOWLAN_TCP_DATA_INTERVAL,
+- tcp->data_interval_max))
+- return -ENOBUFS;
+-
+- if (nla_put_u32(msg, NL80211_WOWLAN_TCP_WAKE_PAYLOAD,
+- tcp->wake_payload_max))
+- return -ENOBUFS;
+-
+- nla_nest_end(msg, nl_tcp);
+- return 0;
+-}
+-#endif
+-
+ static int nl80211_send_wiphy(struct sk_buff *msg, u32 portid, u32 seq, int flags,
+ struct cfg80211_registered_device *dev)
+ {
+@@ -1330,9 +1278,6 @@ static int nl80211_send_wiphy(struct sk_
+ goto nla_put_failure;
+ }
+
+- if (nl80211_send_wowlan_tcp_caps(dev, msg))
+- goto nla_put_failure;
+-
+ nla_nest_end(msg, nl_wowlan);
+ }
+ #endif
+--- a/net/mac80211/cfg.c
++++ b/net/mac80211/cfg.c
+@@ -3285,13 +3285,19 @@ static int ieee80211_cfg_get_channel(str
+ struct cfg80211_chan_def *chandef)
+ {
+ struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
++ struct ieee80211_local *local = wiphy_priv(wiphy);
+ struct ieee80211_chanctx_conf *chanctx_conf;
+ int ret = -ENODATA;
+
+ rcu_read_lock();
+- chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
+- if (chanctx_conf) {
+- *chandef = chanctx_conf->def;
++ if (local->use_chanctx) {
++ chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
++ if (chanctx_conf) {
++ *chandef = chanctx_conf->def;
++ ret = 0;
++ }
++ } else if (local->open_count == local->monitors) {
++ *chandef = local->monitor_chandef;
+ ret = 0;
+ }
+ rcu_read_unlock();
+--- a/drivers/net/wireless/ath/ath9k/hw.c
++++ b/drivers/net/wireless/ath/ath9k/hw.c
+@@ -1463,7 +1463,9 @@ static bool ath9k_hw_chip_reset(struct a
+ reset_type = ATH9K_RESET_POWER_ON;
+ else
+ reset_type = ATH9K_RESET_COLD;
+- }
++ } else if (ah->chip_fullsleep || REG_READ(ah, AR_Q_TXE) ||
++ (REG_READ(ah, AR_CR) & AR_CR_RXE))
++ reset_type = ATH9K_RESET_COLD;
+
+ if (!ath9k_hw_set_reset_reg(ah, reset_type))
+ return false;
+--- a/drivers/net/wireless/rt2x00/rt2x00dev.c
++++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
+@@ -1236,8 +1236,10 @@ static inline void rt2x00lib_set_if_comb
+ */
+ if_limit = &rt2x00dev->if_limits_ap;
+ if_limit->max = rt2x00dev->ops->max_ap_intf;
+- if_limit->types = BIT(NL80211_IFTYPE_AP) |
+- BIT(NL80211_IFTYPE_MESH_POINT);
++ if_limit->types = BIT(NL80211_IFTYPE_AP);
++#ifdef CONFIG_MAC80211_MESH
++ if_limit->types |= BIT(NL80211_IFTYPE_MESH_POINT);
++#endif
+
+ /*
+ * Build up AP interface combinations structure.
+@@ -1309,7 +1311,9 @@ int rt2x00lib_probe_dev(struct rt2x00_de
+ rt2x00dev->hw->wiphy->interface_modes |=
+ BIT(NL80211_IFTYPE_ADHOC) |
+ BIT(NL80211_IFTYPE_AP) |
++#ifdef CONFIG_MAC80211_MESH
+ BIT(NL80211_IFTYPE_MESH_POINT) |
++#endif
+ BIT(NL80211_IFTYPE_WDS);
+
+ rt2x00dev->hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN;
+--- a/net/mac80211/rc80211_minstrel_ht.c
++++ b/net/mac80211/rc80211_minstrel_ht.c
+@@ -26,11 +26,11 @@
+ /* Number of symbols for a packet with (bps) bits per symbol */
+ #define MCS_NSYMS(bps) ((MCS_NBITS + (bps) - 1) / (bps))
+
+-/* Transmission time for a packet containing (syms) symbols */
++/* Transmission time (nanoseconds) for a packet containing (syms) symbols */
+ #define MCS_SYMBOL_TIME(sgi, syms) \
+ (sgi ? \
+- ((syms) * 18 + 4) / 5 : /* syms * 3.6 us */ \
+- (syms) << 2 /* syms * 4 us */ \
++ ((syms) * 18000 + 4000) / 5 : /* syms * 3.6 us */ \
++ ((syms) * 1000) << 2 /* syms * 4 us */ \
+ )
+
+ /* Transmit duration for the raw data part of an average sized packet */
+@@ -64,9 +64,9 @@
+ }
+
+ #define CCK_DURATION(_bitrate, _short, _len) \
+- (10 /* SIFS */ + \
++ (1000 * (10 /* SIFS */ + \
+ (_short ? 72 + 24 : 144 + 48 ) + \
+- (8 * (_len + 4) * 10) / (_bitrate))
++ (8 * (_len + 4) * 10) / (_bitrate)))
+
+ #define CCK_ACK_DURATION(_bitrate, _short) \
+ (CCK_DURATION((_bitrate > 10 ? 20 : 10), false, 60) + \
+@@ -211,20 +211,32 @@ static void
+ minstrel_ht_calc_tp(struct minstrel_ht_sta *mi, int group, int rate)
+ {
+ struct minstrel_rate_stats *mr;
+- unsigned int usecs = 0;
++ unsigned int nsecs = 0;
++ unsigned int tp;
++ unsigned int prob;
+
+ mr = &mi->groups[group].rates[rate];
++ prob = mr->probability;
+
+- if (mr->probability < MINSTREL_FRAC(1, 10)) {
++ if (prob < MINSTREL_FRAC(1, 10)) {
+ mr->cur_tp = 0;
+ return;
+ }
+
++ /*
++ * For the throughput calculation, limit the probability value to 90% to
++ * account for collision related packet error rate fluctuation
++ */
++ if (prob > MINSTREL_FRAC(9, 10))
++ prob = MINSTREL_FRAC(9, 10);
++
+ if (group != MINSTREL_CCK_GROUP)
+- usecs = mi->overhead / MINSTREL_TRUNC(mi->avg_ampdu_len);
++ nsecs = 1000 * mi->overhead / MINSTREL_TRUNC(mi->avg_ampdu_len);
+
+- usecs += minstrel_mcs_groups[group].duration[rate];
+- mr->cur_tp = MINSTREL_TRUNC((1000000 / usecs) * mr->probability);
++ nsecs += minstrel_mcs_groups[group].duration[rate];
++ tp = 1000000 * ((mr->probability * 1000) / nsecs);
++
++ mr->cur_tp = MINSTREL_TRUNC(tp);
+ }
+
+ /*
+@@ -308,8 +320,8 @@ minstrel_ht_update_stats(struct minstrel
+ }
+ }
+
+- /* try to sample up to half of the available rates during each interval */
+- mi->sample_count *= 4;
++ /* try to sample all available rates during each interval */
++ mi->sample_count *= 8;
+
+ cur_prob = 0;
+ cur_prob_tp = 0;
+@@ -320,20 +332,13 @@ minstrel_ht_update_stats(struct minstrel
+ if (!mg->supported)
+ continue;
+
+- mr = minstrel_get_ratestats(mi, mg->max_prob_rate);
+- if (cur_prob_tp < mr->cur_tp &&
+- minstrel_mcs_groups[group].streams == 1) {
+- mi->max_prob_rate = mg->max_prob_rate;
+- cur_prob = mr->cur_prob;
+- cur_prob_tp = mr->cur_tp;
+- }
+-
+ mr = minstrel_get_ratestats(mi, mg->max_tp_rate);
+ if (cur_tp < mr->cur_tp) {
+ mi->max_tp_rate2 = mi->max_tp_rate;
+ cur_tp2 = cur_tp;
+ mi->max_tp_rate = mg->max_tp_rate;
+ cur_tp = mr->cur_tp;
++ mi->max_prob_streams = minstrel_mcs_groups[group].streams - 1;
+ }
+
+ mr = minstrel_get_ratestats(mi, mg->max_tp_rate2);
+@@ -343,6 +348,23 @@ minstrel_ht_update_stats(struct minstrel
+ }
+ }
+
++ if (mi->max_prob_streams < 1)
++ mi->max_prob_streams = 1;
++
++ for (group = 0; group < ARRAY_SIZE(minstrel_mcs_groups); group++) {
++ mg = &mi->groups[group];
++ if (!mg->supported)
++ continue;
++ mr = minstrel_get_ratestats(mi, mg->max_prob_rate);
++ if (cur_prob_tp < mr->cur_tp &&
++ minstrel_mcs_groups[group].streams <= mi->max_prob_streams) {
++ mi->max_prob_rate = mg->max_prob_rate;
++ cur_prob = mr->cur_prob;
++ cur_prob_tp = mr->cur_tp;
++ }
++ }
++
++
+ mi->stats_update = jiffies;
+ }
+
+@@ -467,7 +489,7 @@ minstrel_ht_tx_status(void *priv, struct
+
+ if (!mi->sample_wait && !mi->sample_tries && mi->sample_count > 0) {
+ mi->sample_wait = 16 + 2 * MINSTREL_TRUNC(mi->avg_ampdu_len);
+- mi->sample_tries = 2;
++ mi->sample_tries = 1;
+ mi->sample_count--;
+ }
+
+@@ -536,7 +558,7 @@ minstrel_calc_retransmit(struct minstrel
+ mr->retry_updated = true;
+
+ group = &minstrel_mcs_groups[index / MCS_GROUP_RATES];
+- tx_time_data = group->duration[index % MCS_GROUP_RATES] * ampdu_len;
++ tx_time_data = group->duration[index % MCS_GROUP_RATES] * ampdu_len / 1000;
+
+ /* Contention time for first 2 tries */
+ ctime = (t_slot * cw) >> 1;
+@@ -616,6 +638,7 @@ minstrel_get_sample_rate(struct minstrel
+ {
+ struct minstrel_rate_stats *mr;
+ struct minstrel_mcs_group_data *mg;
++ unsigned int sample_dur, sample_group;
+ int sample_idx = 0;
+
+ if (mi->sample_wait > 0) {
+@@ -626,39 +649,46 @@ minstrel_get_sample_rate(struct minstrel
+ if (!mi->sample_tries)
+ return -1;
+
+- mi->sample_tries--;
+ mg = &mi->groups[mi->sample_group];
+ sample_idx = sample_table[mg->column][mg->index];
+ mr = &mg->rates[sample_idx];
+- sample_idx += mi->sample_group * MCS_GROUP_RATES;
++ sample_group = mi->sample_group;
++ sample_idx += sample_group * MCS_GROUP_RATES;
+ minstrel_next_sample_idx(mi);
+
+ /*
+ * Sampling might add some overhead (RTS, no aggregation)
+ * to the frame. Hence, don't use sampling for the currently
+- * used max TP rate.
++ * used rates.
+ */
+- if (sample_idx == mi->max_tp_rate)
++ if (sample_idx == mi->max_tp_rate ||
++ sample_idx == mi->max_tp_rate2 ||
++ sample_idx == mi->max_prob_rate)
+ return -1;
++
+ /*
+- * When not using MRR, do not sample if the probability is already
+- * higher than 95% to avoid wasting airtime
++ * Do not sample if the probability is already higher than 95%
++ * to avoid wasting airtime.
+ */
+- if (!mp->has_mrr && (mr->probability > MINSTREL_FRAC(95, 100)))
++ if (mr->probability > MINSTREL_FRAC(95, 100))
+ return -1;
+
+ /*
+ * Make sure that lower rates get sampled only occasionally,
+ * if the link is working perfectly.
+ */
+- if (minstrel_get_duration(sample_idx) >
+- minstrel_get_duration(mi->max_tp_rate)) {
++ sample_dur = minstrel_get_duration(sample_idx);
++ if (sample_dur >= minstrel_get_duration(mi->max_tp_rate2) &&
++ (mi->max_prob_streams <
++ minstrel_mcs_groups[sample_group].streams ||
++ sample_dur >= minstrel_get_duration(mi->max_prob_rate))) {
+ if (mr->sample_skipped < 20)
+ return -1;
+
+ if (mi->sample_slow++ > 2)
+ return -1;
+ }
++ mi->sample_tries--;
+
+ return sample_idx;
+ }
+--- a/net/mac80211/rc80211_minstrel_ht.h
++++ b/net/mac80211/rc80211_minstrel_ht.h
+@@ -85,6 +85,7 @@ struct minstrel_ht_sta {
+
+ /* best probability rate */
+ unsigned int max_prob_rate;
++ unsigned int max_prob_streams;
+
+ /* time of last status update */
+ unsigned long stats_update;
+--- a/drivers/net/wireless/ath/ath9k/ar9003_calib.c
++++ b/drivers/net/wireless/ath/ath9k/ar9003_calib.c
+@@ -1023,6 +1023,7 @@ static bool ar9003_hw_init_cal(struct at
+ AR_PHY_AGC_CONTROL_FLTR_CAL |
+ AR_PHY_AGC_CONTROL_PKDET_CAL;
+
++ /* Use chip chainmask only for calibration */
+ ar9003_hw_set_chain_masks(ah, ah->caps.rx_chainmask, ah->caps.tx_chainmask);
+
+ if (rtt) {
+@@ -1150,6 +1151,9 @@ skip_tx_iqcal:
+ ar9003_hw_rtt_disable(ah);
+ }
+
++ /* Revert chainmask to runtime parameters */
++ ar9003_hw_set_chain_masks(ah, ah->rxchainmask, ah->txchainmask);
++
+ /* Initialize list pointers */
+ ah->cal_list = ah->cal_list_last = ah->cal_list_curr = NULL;
+
+--- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
++++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
+@@ -3606,6 +3606,12 @@ static void ar9003_hw_ant_ctrl_apply(str
+ value = ar9003_hw_ant_ctrl_common_2_get(ah, is2ghz);
+ REG_RMW_FIELD(ah, AR_PHY_SWITCH_COM_2, AR_SWITCH_TABLE_COM2_ALL, value);
+
++ if ((AR_SREV_9462(ah)) && (ah->rxchainmask == 0x2)) {
++ value = ar9003_hw_ant_ctrl_chain_get(ah, 1, is2ghz);
++ REG_RMW_FIELD(ah, switch_chain_reg[0],
++ AR_SWITCH_TABLE_ALL, value);
++ }
++
+ for (chain = 0; chain < AR9300_MAX_CHAINS; chain++) {
+ if ((ah->rxchainmask & BIT(chain)) ||
+ (ah->txchainmask & BIT(chain))) {
+@@ -3772,6 +3778,17 @@ static void ar9003_hw_atten_apply(struct
+ AR_PHY_EXT_ATTEN_CTL_2,
+ };
+
++ if ((AR_SREV_9462(ah)) && (ah->rxchainmask == 0x2)) {
++ value = ar9003_hw_atten_chain_get(ah, 1, chan);
++ REG_RMW_FIELD(ah, ext_atten_reg[0],
++ AR_PHY_EXT_ATTEN_CTL_XATTEN1_DB, value);
++
++ value = ar9003_hw_atten_chain_get_margin(ah, 1, chan);
++ REG_RMW_FIELD(ah, ext_atten_reg[0],
++ AR_PHY_EXT_ATTEN_CTL_XATTEN1_MARGIN,
++ value);
++ }
++
+ /* Test value. if 0 then attenuation is unused. Don't load anything. */
+ for (i = 0; i < 3; i++) {
+ if (ah->txchainmask & BIT(i)) {
+--- a/drivers/net/wireless/ath/ath9k/link.c
++++ b/drivers/net/wireless/ath/ath9k/link.c
+@@ -28,21 +28,21 @@ void ath_tx_complete_poll_work(struct wo
+ int i;
+ bool needreset = false;
+
+- for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++)
+- if (ATH_TXQ_SETUP(sc, i)) {
+- txq = &sc->tx.txq[i];
+- ath_txq_lock(sc, txq);
+- if (txq->axq_depth) {
+- if (txq->axq_tx_inprogress) {
+- needreset = true;
+- ath_txq_unlock(sc, txq);
+- break;
+- } else {
+- txq->axq_tx_inprogress = true;
+- }
++ for (i = 0; i < IEEE80211_NUM_ACS; i++) {
++ txq = sc->tx.txq_map[i];
++
++ ath_txq_lock(sc, txq);
++ if (txq->axq_depth) {
++ if (txq->axq_tx_inprogress) {
++ needreset = true;
++ ath_txq_unlock(sc, txq);
++ break;
++ } else {
++ txq->axq_tx_inprogress = true;
+ }
+- ath_txq_unlock_complete(sc, txq);
+ }
++ ath_txq_unlock_complete(sc, txq);
++ }
+
+ if (needreset) {
+ ath_dbg(ath9k_hw_common(sc->sc_ah), RESET,
+--- a/net/mac80211/sta_info.c
++++ b/net/mac80211/sta_info.c
+@@ -766,6 +766,7 @@ int __must_check __sta_info_destroy(stru
+ struct ieee80211_local *local;
+ struct ieee80211_sub_if_data *sdata;
+ int ret, i;
++ bool have_key = false;
+
+ might_sleep();
+
+@@ -793,12 +794,19 @@ int __must_check __sta_info_destroy(stru
+ list_del_rcu(&sta->list);
+
+ mutex_lock(&local->key_mtx);
+- for (i = 0; i < NUM_DEFAULT_KEYS; i++)
++ for (i = 0; i < NUM_DEFAULT_KEYS; i++) {
+ __ieee80211_key_free(key_mtx_dereference(local, sta->gtk[i]));
+- if (sta->ptk)
++ have_key = true;
++ }
++ if (sta->ptk) {
+ __ieee80211_key_free(key_mtx_dereference(local, sta->ptk));
++ have_key = true;
++ }
+ mutex_unlock(&local->key_mtx);
+
++ if (!have_key)
++ synchronize_net();
++
+ sta->dead = true;
+
+ local->num_sta--;
diff --git a/package/mac80211/patches/.svn/text-base/310-ap_scan.patch.svn-base b/package/mac80211/patches/.svn/text-base/310-ap_scan.patch.svn-base
new file mode 100644
index 0000000..b8f2671
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/310-ap_scan.patch.svn-base
@@ -0,0 +1,11 @@
+--- a/net/mac80211/cfg.c
++++ b/net/mac80211/cfg.c
+@@ -2009,7 +2009,7 @@ static int ieee80211_scan(struct wiphy *
+ * the frames sent while scanning on other channel will be
+ * lost)
+ */
+- if (sdata->u.ap.beacon &&
++ if (0 && sdata->u.ap.beacon &&
+ (!(wiphy->features & NL80211_FEATURE_AP_SCAN) ||
+ !(req->flags & NL80211_SCAN_FLAG_AP)))
+ return -EOPNOTSUPP;
diff --git a/package/mac80211/patches/.svn/text-base/400-ath_move_debug_code.patch.svn-base b/package/mac80211/patches/.svn/text-base/400-ath_move_debug_code.patch.svn-base
new file mode 100644
index 0000000..c91128d
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/400-ath_move_debug_code.patch.svn-base
@@ -0,0 +1,28 @@
+--- a/drivers/net/wireless/ath/Makefile
++++ b/drivers/net/wireless/ath/Makefile
+@@ -10,7 +10,7 @@ obj-$(CONFIG_ATH_COMMON) += ath.o
+ ath-objs := main.o \
+ regd.o \
+ hw.o \
+- key.o
++ key.o \
++ debug.o
+
+-ath-$(CONFIG_ATH_DEBUG) += debug.o
+ ccflags-y += -D__CHECK_ENDIAN__
+--- a/drivers/net/wireless/ath/ath.h
++++ b/drivers/net/wireless/ath/ath.h
+@@ -281,13 +281,6 @@ void _ath_dbg(struct ath_common *common,
+ #endif /* CONFIG_ATH_DEBUG */
+
+ /** Returns string describing opmode, or NULL if unknown mode. */
+-#ifdef CONFIG_ATH_DEBUG
+ const char *ath_opmode_to_string(enum nl80211_iftype opmode);
+-#else
+-static inline const char *ath_opmode_to_string(enum nl80211_iftype opmode)
+-{
+- return "UNKNOWN";
+-}
+-#endif
+
+ #endif /* ATH_H */
diff --git a/package/mac80211/patches/.svn/text-base/401-ath9k_blink_default.patch.svn-base b/package/mac80211/patches/.svn/text-base/401-ath9k_blink_default.patch.svn-base
new file mode 100644
index 0000000..421e785
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/401-ath9k_blink_default.patch.svn-base
@@ -0,0 +1,11 @@
+--- a/drivers/net/wireless/ath/ath9k/init.c
++++ b/drivers/net/wireless/ath/ath9k/init.c
+@@ -46,7 +46,7 @@ int ath9k_modparam_nohwcrypt;
+ module_param_named(nohwcrypt, ath9k_modparam_nohwcrypt, int, 0444);
+ MODULE_PARM_DESC(nohwcrypt, "Disable hardware encryption");
+
+-int led_blink;
++int led_blink = 1;
+ module_param_named(blink, led_blink, int, 0444);
+ MODULE_PARM_DESC(blink, "Enable LED blink on activity");
+
diff --git a/package/mac80211/patches/.svn/text-base/402-ath9k-fix-invalid-mac-address-handling.patch.svn-base b/package/mac80211/patches/.svn/text-base/402-ath9k-fix-invalid-mac-address-handling.patch.svn-base
new file mode 100644
index 0000000..3dbdba0
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/402-ath9k-fix-invalid-mac-address-handling.patch.svn-base
@@ -0,0 +1,29 @@
+--- a/drivers/net/wireless/ath/ath9k/hw.c
++++ b/drivers/net/wireless/ath/ath9k/hw.c
+@@ -17,6 +17,7 @@
+ #include <linux/io.h>
+ #include <linux/slab.h>
+ #include <linux/module.h>
++#include <linux/etherdevice.h>
+ #include <asm/unaligned.h>
+
+ #include "hw.h"
+@@ -519,8 +520,16 @@ static int ath9k_hw_init_macaddr(struct
+ common->macaddr[2 * i] = eeval >> 8;
+ common->macaddr[2 * i + 1] = eeval & 0xff;
+ }
+- if (sum == 0 || sum == 0xffff * 3)
+- return -EADDRNOTAVAIL;
++ if (!is_valid_ether_addr(common->macaddr)) {
++ ath_err(common,
++ "eeprom contains invalid mac address: %pM\n",
++ common->macaddr);
++
++ random_ether_addr(common->macaddr);
++ ath_err(common,
++ "random mac address will be used: %pM\n",
++ common->macaddr);
++ }
+
+ return 0;
+ }
diff --git a/package/mac80211/patches/.svn/text-base/403-ath_regd_optional.patch.svn-base b/package/mac80211/patches/.svn/text-base/403-ath_regd_optional.patch.svn-base
new file mode 100644
index 0000000..683417b
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/403-ath_regd_optional.patch.svn-base
@@ -0,0 +1,46 @@
+--- a/drivers/net/wireless/ath/regd.c
++++ b/drivers/net/wireless/ath/regd.c
+@@ -198,6 +198,10 @@ ath_reg_apply_beaconing_flags(struct wip
+ struct ieee80211_channel *ch;
+ unsigned int i;
+
++#ifdef ATH_USER_REGD
++ return;
++#endif
++
+ for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
+
+ if (!wiphy->bands[band])
+@@ -252,6 +256,10 @@ ath_reg_apply_active_scan_flags(struct w
+ struct ieee80211_channel *ch;
+ const struct ieee80211_reg_rule *reg_rule;
+
++#ifdef ATH_USER_REGD
++ return;
++#endif
++
+ sband = wiphy->bands[IEEE80211_BAND_2GHZ];
+ if (!sband)
+ return;
+@@ -301,6 +309,10 @@ static void ath_reg_apply_radar_flags(st
+ struct ieee80211_channel *ch;
+ unsigned int i;
+
++#ifdef ATH_USER_REGD
++ return;
++#endif
++
+ if (!wiphy->bands[IEEE80211_BAND_5GHZ])
+ return;
+
+@@ -505,6 +517,10 @@ ath_regd_init_wiphy(struct ath_regulator
+ {
+ const struct ieee80211_regdomain *regd;
+
++#ifdef ATH_USER_REGD
++ return 0;
++#endif
++
+ wiphy->reg_notifier = reg_notifier;
+ wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY;
+
diff --git a/package/mac80211/patches/.svn/text-base/404-world_regd_fixup.patch.svn-base b/package/mac80211/patches/.svn/text-base/404-world_regd_fixup.patch.svn-base
new file mode 100644
index 0000000..d609b55
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/404-world_regd_fixup.patch.svn-base
@@ -0,0 +1,84 @@
+--- a/drivers/net/wireless/ath/regd.c
++++ b/drivers/net/wireless/ath/regd.c
+@@ -44,7 +44,8 @@ static int __ath_regd_init(struct ath_re
+ NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_OFDM)
+
+ /* We allow IBSS on these on a case by case basis by regulatory domain */
+-#define ATH9K_5GHZ_5150_5350 REG_RULE(5150-10, 5350+10, 40, 0, 30,\
++#define ATH9K_5GHZ_5150_5350 REG_RULE(5150-10, 5250, 40, 0, 30, 0), \
++ REG_RULE(5250, 5350+10, 40, 0, 30,\
+ NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_IBSS)
+ #define ATH9K_5GHZ_5470_5850 REG_RULE(5470-10, 5850+10, 40, 0, 30,\
+ NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_IBSS)
+@@ -62,57 +63,56 @@ static int __ath_regd_init(struct ath_re
+ #define ATH9K_5GHZ_NO_MIDBAND ATH9K_5GHZ_5150_5350, \
+ ATH9K_5GHZ_5725_5850
+
++#define REGD_RULES(...) \
++ .reg_rules = { __VA_ARGS__ }, \
++ .n_reg_rules = ARRAY_SIZE(((struct ieee80211_reg_rule[]) { __VA_ARGS__ }))
++
+ /* Can be used for:
+ * 0x60, 0x61, 0x62 */
+ static const struct ieee80211_regdomain ath_world_regdom_60_61_62 = {
+- .n_reg_rules = 5,
+ .alpha2 = "99",
+- .reg_rules = {
++ REGD_RULES(
+ ATH9K_2GHZ_ALL,
+ ATH9K_5GHZ_ALL,
+- }
++ )
+ };
+
+ /* Can be used by 0x63 and 0x65 */
+ static const struct ieee80211_regdomain ath_world_regdom_63_65 = {
+- .n_reg_rules = 4,
+ .alpha2 = "99",
+- .reg_rules = {
++ REGD_RULES(
+ ATH9K_2GHZ_CH01_11,
+ ATH9K_2GHZ_CH12_13,
+ ATH9K_5GHZ_NO_MIDBAND,
+- }
++ )
+ };
+
+ /* Can be used by 0x64 only */
+ static const struct ieee80211_regdomain ath_world_regdom_64 = {
+- .n_reg_rules = 3,
+ .alpha2 = "99",
+- .reg_rules = {
++ REGD_RULES(
+ ATH9K_2GHZ_CH01_11,
+ ATH9K_5GHZ_NO_MIDBAND,
+- }
++ )
+ };
+
+ /* Can be used by 0x66 and 0x69 */
+ static const struct ieee80211_regdomain ath_world_regdom_66_69 = {
+- .n_reg_rules = 3,
+ .alpha2 = "99",
+- .reg_rules = {
++ REGD_RULES(
+ ATH9K_2GHZ_CH01_11,
+ ATH9K_5GHZ_ALL,
+- }
++ )
+ };
+
+ /* Can be used by 0x67, 0x68, 0x6A and 0x6C */
+ static const struct ieee80211_regdomain ath_world_regdom_67_68_6A_6C = {
+- .n_reg_rules = 4,
+ .alpha2 = "99",
+- .reg_rules = {
++ REGD_RULES(
+ ATH9K_2GHZ_CH01_11,
+ ATH9K_2GHZ_CH12_13,
+ ATH9K_5GHZ_ALL,
+- }
++ )
+ };
+
+ static inline bool is_wwr_sku(u16 regd)
diff --git a/package/mac80211/patches/.svn/text-base/405-regd_no_assoc_hints.patch.svn-base b/package/mac80211/patches/.svn/text-base/405-regd_no_assoc_hints.patch.svn-base
new file mode 100644
index 0000000..938ac42
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/405-regd_no_assoc_hints.patch.svn-base
@@ -0,0 +1,19 @@
+--- a/net/wireless/reg.c
++++ b/net/wireless/reg.c
+@@ -1730,6 +1730,8 @@ void regulatory_hint_11d(struct wiphy *w
+ enum environment_cap env = ENVIRON_ANY;
+ struct regulatory_request *request, *lr;
+
++ return;
++
+ mutex_lock(&reg_mutex);
+ lr = get_last_request();
+
+@@ -1926,6 +1928,7 @@ static void restore_regulatory_settings(
+
+ void regulatory_hint_disconnect(void)
+ {
++ return;
+ REG_DBG_PRINT("All devices are disconnected, going to restore regulatory settings\n");
+ restore_regulatory_settings(false);
+ }
diff --git a/package/mac80211/patches/.svn/text-base/406-ath_regd_us.patch.svn-base b/package/mac80211/patches/.svn/text-base/406-ath_regd_us.patch.svn-base
new file mode 100644
index 0000000..cc55877
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/406-ath_regd_us.patch.svn-base
@@ -0,0 +1,26 @@
+--- a/drivers/net/wireless/ath/regd_common.h
++++ b/drivers/net/wireless/ath/regd_common.h
+@@ -32,6 +32,7 @@ enum EnumRd {
+ FCC2_WORLD = 0x21,
+ FCC2_ETSIC = 0x22,
+ FCC6_WORLD = 0x23,
++ FCC3_FCCA_2 = 0x2A,
+ FRANCE_RES = 0x31,
+ FCC3_FCCA = 0x3A,
+ FCC3_WORLD = 0x3B,
+@@ -167,6 +168,7 @@ static struct reg_dmn_pair_mapping regDo
+ {FCC2_WORLD, CTL_FCC, CTL_ETSI},
+ {FCC2_ETSIC, CTL_FCC, CTL_ETSI},
+ {FCC3_FCCA, CTL_FCC, CTL_FCC},
++ {FCC3_FCCA_2, CTL_FCC, CTL_FCC},
+ {FCC3_WORLD, CTL_FCC, CTL_ETSI},
+ {FCC4_FCCA, CTL_FCC, CTL_FCC},
+ {FCC5_FCCA, CTL_FCC, CTL_FCC},
+@@ -463,6 +465,7 @@ static struct country_code_to_enum_rd al
+ {CTRY_UAE, NULL1_WORLD, "AE"},
+ {CTRY_UNITED_KINGDOM, ETSI1_WORLD, "GB"},
+ {CTRY_UNITED_STATES, FCC3_FCCA, "US"},
++ {CTRY_UNITED_STATES, FCC3_FCCA_2, "US"},
+ /* This "PS" is for US public safety actually... to support this we
+ * would need to assign new special alpha2 to CRDA db as with the world
+ * regdomain and use another alpha2 */
diff --git a/package/mac80211/patches/.svn/text-base/410-ath9k_allow_adhoc_and_ap.patch.svn-base b/package/mac80211/patches/.svn/text-base/410-ath9k_allow_adhoc_and_ap.patch.svn-base
new file mode 100644
index 0000000..7a07eb6
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/410-ath9k_allow_adhoc_and_ap.patch.svn-base
@@ -0,0 +1,10 @@
+--- a/drivers/net/wireless/ath/ath9k/init.c
++++ b/drivers/net/wireless/ath/ath9k/init.c
+@@ -727,6 +727,7 @@ static const struct ieee80211_iface_limi
+ #endif
+ BIT(NL80211_IFTYPE_AP) |
+ BIT(NL80211_IFTYPE_P2P_GO) },
++ { .max = 1, .types = BIT(NL80211_IFTYPE_ADHOC) },
+ };
+
+ static const struct ieee80211_iface_combination if_comb = {
diff --git a/package/mac80211/patches/.svn/text-base/411-ath5k_allow_adhoc_and_ap.patch.svn-base b/package/mac80211/patches/.svn/text-base/411-ath5k_allow_adhoc_and_ap.patch.svn-base
new file mode 100644
index 0000000..3d885bb
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/411-ath5k_allow_adhoc_and_ap.patch.svn-base
@@ -0,0 +1,46 @@
+--- a/drivers/net/wireless/ath/ath5k/mac80211-ops.c
++++ b/drivers/net/wireless/ath/ath5k/mac80211-ops.c
+@@ -89,13 +89,8 @@ ath5k_add_interface(struct ieee80211_hw
+ goto end;
+ }
+
+- /* Don't allow other interfaces if one ad-hoc is configured.
+- * TODO: Fix the problems with ad-hoc and multiple other interfaces.
+- * We would need to operate the HW in ad-hoc mode to allow TSF updates
+- * for the IBSS, but this breaks with additional AP or STA interfaces
+- * at the moment. */
+- if (ah->num_adhoc_vifs ||
+- (ah->nvifs && vif->type == NL80211_IFTYPE_ADHOC)) {
++ /* Don't allow more than one ad-hoc interface */
++ if (ah->num_adhoc_vifs && vif->type == NL80211_IFTYPE_ADHOC) {
+ ATH5K_ERR(ah, "Only one single ad-hoc interface is allowed.\n");
+ ret = -ELNRNG;
+ goto end;
+--- a/drivers/net/wireless/ath/ath5k/base.c
++++ b/drivers/net/wireless/ath/ath5k/base.c
+@@ -1868,7 +1868,7 @@ ath5k_beacon_send(struct ath5k_hw *ah)
+ }
+
+ if ((ah->opmode == NL80211_IFTYPE_AP && ah->num_ap_vifs +
+- ah->num_mesh_vifs > 1) ||
++ ah->num_adhoc_vifs + ah->num_mesh_vifs > 1) ||
+ ah->opmode == NL80211_IFTYPE_MESH_POINT) {
+ u64 tsf = ath5k_hw_get_tsf64(ah);
+ u32 tsftu = TSF_TO_TU(tsf);
+@@ -1954,7 +1954,7 @@ ath5k_beacon_update_timers(struct ath5k_
+
+ intval = ah->bintval & AR5K_BEACON_PERIOD;
+ if (ah->opmode == NL80211_IFTYPE_AP && ah->num_ap_vifs
+- + ah->num_mesh_vifs > 1) {
++ + ah->num_adhoc_vifs + ah->num_mesh_vifs > 1) {
+ intval /= ATH_BCBUF; /* staggered multi-bss beacons */
+ if (intval < 15)
+ ATH5K_WARN(ah, "intval %u is too low, min 15\n",
+@@ -2418,6 +2418,7 @@ static const struct ieee80211_iface_limi
+ BIT(NL80211_IFTYPE_MESH_POINT) |
+ #endif
+ BIT(NL80211_IFTYPE_AP) },
++ { .max = 1, .types = BIT(NL80211_IFTYPE_ADHOC) },
+ };
+
+ static const struct ieee80211_iface_combination if_comb = {
diff --git a/package/mac80211/patches/.svn/text-base/420-ath5k_disable_fast_cc.patch.svn-base b/package/mac80211/patches/.svn/text-base/420-ath5k_disable_fast_cc.patch.svn-base
new file mode 100644
index 0000000..48b8467
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/420-ath5k_disable_fast_cc.patch.svn-base
@@ -0,0 +1,18 @@
+--- a/drivers/net/wireless/ath/ath5k/reset.c
++++ b/drivers/net/wireless/ath/ath5k/reset.c
+@@ -1158,6 +1158,7 @@ ath5k_hw_reset(struct ath5k_hw *ah, enum
+ tsf_lo = 0;
+ mode = 0;
+
++#if 0
+ /*
+ * Sanity check for fast flag
+ * Fast channel change only available
+@@ -1165,6 +1166,7 @@ ath5k_hw_reset(struct ath5k_hw *ah, enum
+ */
+ if (fast && (ah->ah_radio != AR5K_RF2413) &&
+ (ah->ah_radio != AR5K_RF5413))
++#endif
+ fast = false;
+
+ /* Disable sleep clock operation
diff --git a/package/mac80211/patches/.svn/text-base/430-add_ath5k_platform.patch.svn-base b/package/mac80211/patches/.svn/text-base/430-add_ath5k_platform.patch.svn-base
new file mode 100644
index 0000000..b213e2a
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/430-add_ath5k_platform.patch.svn-base
@@ -0,0 +1,33 @@
+--- /dev/null
++++ b/include/linux/ath5k_platform.h
+@@ -0,0 +1,30 @@
++/*
++ * Copyright (c) 2008 Atheros Communications Inc.
++ * Copyright (c) 2009 Gabor Juhos <juhosg@openwrt.org>
++ * Copyright (c) 2009 Imre Kaloz <kaloz@openwrt.org>
++ * Copyright (c) 2010 Daniel Golle <daniel.golle@gmail.com>
++ *
++ * Permission to use, copy, modify, and/or distribute this software for any
++ * purpose with or without fee is hereby granted, provided that the above
++ * copyright notice and this permission notice appear in all copies.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
++ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
++ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
++ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
++ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
++ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
++ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
++ */
++
++#ifndef _LINUX_ATH5K_PLATFORM_H
++#define _LINUX_ATH5K_PLATFORM_H
++
++#define ATH5K_PLAT_EEP_MAX_WORDS 2048
++
++struct ath5k_platform_data {
++ u16 *eeprom_data;
++ u8 *macaddr;
++};
++
++#endif /* _LINUX_ATH5K_PLATFORM_H */
diff --git a/package/mac80211/patches/.svn/text-base/431-add_platform_eeprom_support_to_ath5k.patch.svn-base b/package/mac80211/patches/.svn/text-base/431-add_platform_eeprom_support_to_ath5k.patch.svn-base
new file mode 100644
index 0000000..d4967b6
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/431-add_platform_eeprom_support_to_ath5k.patch.svn-base
@@ -0,0 +1,56 @@
+--- a/drivers/net/wireless/ath/ath5k/pci.c
++++ b/drivers/net/wireless/ath/ath5k/pci.c
+@@ -23,6 +23,7 @@
+ #include <linux/pci-aspm.h>
+ #include <linux/etherdevice.h>
+ #include <linux/module.h>
++#include <linux/ath5k_platform.h>
+ #include "../ath.h"
+ #include "ath5k.h"
+ #include "debug.h"
+@@ -74,7 +75,7 @@ static void ath5k_pci_read_cachesize(str
+ }
+
+ /*
+- * Read from eeprom
++ * Read from eeprom or platform_data
+ */
+ static bool
+ ath5k_pci_eeprom_read(struct ath_common *common, u32 offset, u16 *data)
+@@ -82,6 +83,19 @@ ath5k_pci_eeprom_read(struct ath_common
+ struct ath5k_hw *ah = (struct ath5k_hw *) common->ah;
+ u32 status, timeout;
+
++ struct ath5k_platform_data *pdata = NULL;
++
++ if (ah->pdev)
++ pdata = ah->pdev->dev.platform_data;
++
++ if (pdata && pdata->eeprom_data && pdata->eeprom_data[61] == AR5K_EEPROM_MAGIC_VALUE) {
++ if (offset >= ATH5K_PLAT_EEP_MAX_WORDS)
++ return false;
++
++ *data = pdata->eeprom_data[offset];
++ return true;
++ }
++
+ /*
+ * Initialize EEPROM access
+ */
+@@ -125,6 +139,16 @@ static int ath5k_pci_eeprom_read_mac(str
+ u16 data;
+ int octet;
+
++ struct ath5k_platform_data *pdata = NULL;
++
++ if (ah->pdev)
++ pdata = ah->pdev->dev.platform_data;
++
++ if (pdata && pdata->macaddr) {
++ memcpy(mac, pdata->macaddr, ETH_ALEN);
++ return 0;
++ }
++
+ AR5K_EEPROM_READ(0x20, data);
+
+ for (offset = 0x1f, octet = 0, total = 0; offset >= 0x1d; offset--) {
diff --git a/package/mac80211/patches/.svn/text-base/432-ath5k_add_pciids.patch.svn-base b/package/mac80211/patches/.svn/text-base/432-ath5k_add_pciids.patch.svn-base
new file mode 100644
index 0000000..8db5e1b
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/432-ath5k_add_pciids.patch.svn-base
@@ -0,0 +1,11 @@
+--- a/drivers/net/wireless/ath/ath5k/pci.c
++++ b/drivers/net/wireless/ath/ath5k/pci.c
+@@ -50,6 +50,8 @@ static DEFINE_PCI_DEVICE_TABLE(ath5k_pci
+ { PCI_VDEVICE(ATHEROS, 0x001b) }, /* 5413 Eagle */
+ { PCI_VDEVICE(ATHEROS, 0x001c) }, /* PCI-E cards */
+ { PCI_VDEVICE(ATHEROS, 0x001d) }, /* 2417 Nala */
++ { PCI_VDEVICE(ATHEROS, 0xff16) }, /* 2413,2414 sx76x on lantiq_danube */
++ { PCI_VDEVICE(ATHEROS, 0xff1a) }, /* 2417 arv45xx on lantiq_danube */
+ { PCI_VDEVICE(ATHEROS, 0xff1b) }, /* AR5BXB63 */
+ { 0 }
+ };
diff --git a/package/mac80211/patches/.svn/text-base/440-ath5k_channel_bw_debugfs.patch.svn-base b/package/mac80211/patches/.svn/text-base/440-ath5k_channel_bw_debugfs.patch.svn-base
new file mode 100644
index 0000000..f9c2a09
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/440-ath5k_channel_bw_debugfs.patch.svn-base
@@ -0,0 +1,113 @@
+This adds a bwmode debugfs file which can be used to set alternate
+channel operating bandwidths. Only tested with AR5413 and only at
+5 and 20 mhz channels.
+
+Signed-off-by: Pat Erley <pat-lkml at erley.org>
+---
+Other devices will need to be added to the switch in write_file_bwmode
+
+drivers/net/wireless/ath/ath5k/debug.c | 86 ++++++++++++++++++++++++++++++++
+ 1 files changed, 86 insertions(+), 0 deletions(-)
+
+--- a/drivers/net/wireless/ath/ath5k/debug.c
++++ b/drivers/net/wireless/ath/ath5k/debug.c
+@@ -813,6 +813,89 @@ static const struct file_operations fops
+ .llseek = default_llseek,
+ };
+
++/* debugfs: bwmode */
++
++static ssize_t read_file_bwmode(struct file *file, char __user *user_buf,
++ size_t count, loff_t *ppos)
++{
++ struct ath5k_hw *ah = file->private_data;
++ char buf[15];
++ unsigned int len = 0;
++
++ int cur_ah_bwmode = ah->ah_bwmode;
++
++#define print_selected(MODE, LABEL) \
++ if (cur_ah_bwmode == MODE) \
++ len += snprintf(buf+len, sizeof(buf)-len, "[%s]", LABEL); \
++ else \
++ len += snprintf(buf+len, sizeof(buf)-len, "%s", LABEL); \
++ len += snprintf(buf+len, sizeof(buf)-len, " ");
++
++ print_selected(AR5K_BWMODE_5MHZ, "5");
++ print_selected(AR5K_BWMODE_10MHZ, "10");
++ print_selected(AR5K_BWMODE_DEFAULT, "20");
++ print_selected(AR5K_BWMODE_40MHZ, "40");
++#undef print_selected
++
++ len += snprintf(buf+len, sizeof(buf)-len, "\n");
++
++ return simple_read_from_buffer(user_buf, count, ppos, buf, len);
++}
++
++static ssize_t write_file_bwmode(struct file *file,
++ const char __user *userbuf,
++ size_t count, loff_t *ppos)
++{
++ struct ath5k_hw *ah = file->private_data;
++ char buf[3];
++ int bw = 20;
++ int tobwmode = AR5K_BWMODE_DEFAULT;
++
++ if (copy_from_user(buf, userbuf, min(count, sizeof(buf))))
++ return -EFAULT;
++
++ /* TODO: Add check for active interface */
++
++ if(strncmp(buf, "5", 1) == 0 ) {
++ tobwmode = AR5K_BWMODE_5MHZ;
++ bw = 5;
++ } else if ( strncmp(buf, "10", 2) == 0 ) {
++ tobwmode = AR5K_BWMODE_10MHZ;
++ bw = 10;
++ } else if ( strncmp(buf, "20", 2) == 0 ) {
++ tobwmode = AR5K_BWMODE_DEFAULT;
++ bw = 20;
++ } else if ( strncmp(buf, "40", 2) == 0 ) {
++ tobwmode = AR5K_BWMODE_40MHZ;
++ bw = 40;
++ } else
++ return -EINVAL;
++
++ ATH5K_INFO(ah, "Changing to %imhz channel width[%i]\n",
++ bw, tobwmode);
++
++ switch (ah->ah_radio) {
++ /* TODO: only define radios that actually support 5/10mhz channels */
++ case AR5K_RF5413: case AR5K_RF5110: case AR5K_RF5111: case AR5K_RF5112: case AR5K_RF2413: case AR5K_RF2316: case AR5K_RF2317: case AR5K_RF2425:
++ if(ah->ah_bwmode != tobwmode) {
++ mutex_lock(&ah->lock);
++ ah->ah_bwmode = tobwmode;
++ mutex_unlock(&ah->lock);
++ }
++ break;
++ default:
++ return -EOPNOTSUPP;
++ }
++ return count;
++}
++
++static const struct file_operations fops_bwmode = {
++ .read = read_file_bwmode,
++ .write = write_file_bwmode,
++ .open = simple_open,
++ .owner = THIS_MODULE,
++ .llseek = default_llseek,
++};
+
+ /* debugfs: queues etc */
+
+@@ -904,6 +987,9 @@ ath5k_debug_init_device(struct ath5k_hw
+ debugfs_create_file("beacon", S_IWUSR | S_IRUSR, phydir, ah,
+ &fops_beacon);
+
++ debugfs_create_file("bwmode", S_IWUSR | S_IRUSR, phydir, ah,
++ &fops_bwmode);
++
+ debugfs_create_file("reset", S_IWUSR, phydir, ah, &fops_reset);
+
+ debugfs_create_file("antenna", S_IWUSR | S_IRUSR, phydir, ah,
diff --git a/package/mac80211/patches/.svn/text-base/500-ath9k_eeprom_debugfs.patch.svn-base b/package/mac80211/patches/.svn/text-base/500-ath9k_eeprom_debugfs.patch.svn-base
new file mode 100644
index 0000000..285fce2
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/500-ath9k_eeprom_debugfs.patch.svn-base
@@ -0,0 +1,65 @@
+--- a/drivers/net/wireless/ath/ath9k/debug.c
++++ b/drivers/net/wireless/ath/ath9k/debug.c
+@@ -2003,6 +2003,53 @@ void ath9k_get_et_stats(struct ieee80211
+ WARN_ON(i != ATH9K_SSTATS_LEN);
+ }
+
++static ssize_t read_file_eeprom(struct file *file, char __user *user_buf,
++ size_t count, loff_t *ppos)
++{
++ struct ath_softc *sc = file->private_data;
++ struct ath_hw *ah = sc->sc_ah;
++ struct ath_common *common = ath9k_hw_common(ah);
++ int bytes = 0;
++ int pos = *ppos;
++ int size = 4096;
++ u16 val;
++ int i;
++
++ if (AR_SREV_9300_20_OR_LATER(ah))
++ size = 16384;
++
++ if (*ppos < 0)
++ return -EINVAL;
++
++ if (count > size - *ppos)
++ count = size - *ppos;
++
++ for (i = *ppos / 2; count > 0; count -= bytes, *ppos += bytes, i++) {
++ void *from = &val;
++
++ if (!common->bus_ops->eeprom_read(common, i, &val))
++ val = 0xffff;
++
++ if (*ppos % 2) {
++ from++;
++ bytes = 1;
++ } else if (count == 1) {
++ bytes = 1;
++ } else {
++ bytes = 2;
++ }
++ copy_to_user(user_buf, from, bytes);
++ user_buf += bytes;
++ }
++ return *ppos - pos;
++}
++
++static const struct file_operations fops_eeprom = {
++ .read = read_file_eeprom,
++ .open = simple_open,
++ .owner = THIS_MODULE
++};
++
+ int ath9k_init_debug(struct ath_hw *ah)
+ {
+ struct ath_common *common = ath9k_hw_common(ah);
+@@ -2020,6 +2067,8 @@ int ath9k_init_debug(struct ath_hw *ah)
+
+ ath9k_dfs_init_debug(sc);
+
++ debugfs_create_file("eeprom", S_IRUSR, sc->debug.debugfs_phy, sc,
++ &fops_eeprom);
+ debugfs_create_file("dma", S_IRUSR, sc->debug.debugfs_phy, sc,
+ &fops_dma);
+ debugfs_create_file("interrupt", S_IRUSR, sc->debug.debugfs_phy, sc,
diff --git a/package/mac80211/patches/.svn/text-base/501-ath9k-eeprom_endianess.patch.svn-base b/package/mac80211/patches/.svn/text-base/501-ath9k-eeprom_endianess.patch.svn-base
new file mode 100644
index 0000000..bdd7e19
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/501-ath9k-eeprom_endianess.patch.svn-base
@@ -0,0 +1,102 @@
+--- a/drivers/net/wireless/ath/ath9k/eeprom_def.c
++++ b/drivers/net/wireless/ath/ath9k/eeprom_def.c
+@@ -262,7 +262,7 @@ static int ath9k_hw_def_check_eeprom(str
+ {
+ struct ar5416_eeprom_def *eep = &ah->eeprom.def;
+ struct ath_common *common = ath9k_hw_common(ah);
+- u16 *eepdata, temp, magic, magic2;
++ u16 *eepdata, temp, magic;
+ u32 sum = 0, el;
+ bool need_swap = false;
+ int i, addr, size;
+@@ -272,27 +272,16 @@ static int ath9k_hw_def_check_eeprom(str
+ return false;
+ }
+
+- if (!ath9k_hw_use_flash(ah)) {
+- ath_dbg(common, EEPROM, "Read Magic = 0x%04X\n", magic);
+-
+- if (magic != AR5416_EEPROM_MAGIC) {
+- magic2 = swab16(magic);
+-
+- if (magic2 == AR5416_EEPROM_MAGIC) {
+- size = sizeof(struct ar5416_eeprom_def);
+- need_swap = true;
+- eepdata = (u16 *) (&ah->eeprom);
+-
+- for (addr = 0; addr < size / sizeof(u16); addr++) {
+- temp = swab16(*eepdata);
+- *eepdata = temp;
+- eepdata++;
+- }
+- } else {
+- ath_err(common,
+- "Invalid EEPROM Magic. Endianness mismatch.\n");
+- return -EINVAL;
+- }
++ if (swab16(magic) == AR5416_EEPROM_MAGIC &&
++ !(ah->ah_flags & AH_NO_EEP_SWAP)) {
++ size = sizeof(struct ar5416_eeprom_def);
++ need_swap = true;
++ eepdata = (u16 *) (&ah->eeprom);
++
++ for (addr = 0; addr < size / sizeof(u16); addr++) {
++ temp = swab16(*eepdata);
++ *eepdata = temp;
++ eepdata++;
+ }
+ }
+
+--- a/drivers/net/wireless/ath/ath9k/eeprom_4k.c
++++ b/drivers/net/wireless/ath/ath9k/eeprom_4k.c
+@@ -57,7 +57,7 @@ static bool ath9k_hw_4k_fill_eeprom(stru
+ {
+ struct ath_common *common = ath9k_hw_common(ah);
+
+- if (!ath9k_hw_use_flash(ah)) {
++ if (!(ah->ah_flags & AH_NO_EEP_SWAP)) {
+ ath_dbg(common, EEPROM, "Reading from EEPROM, not flash\n");
+ }
+
+--- a/drivers/net/wireless/ath/ath9k/eeprom_9287.c
++++ b/drivers/net/wireless/ath/ath9k/eeprom_9287.c
+@@ -60,7 +60,7 @@ static bool ath9k_hw_ar9287_fill_eeprom(
+ {
+ struct ath_common *common = ath9k_hw_common(ah);
+
+- if (!ath9k_hw_use_flash(ah)) {
++ if (!(ah->ah_flags & AH_NO_EEP_SWAP)) {
+ ath_dbg(common, EEPROM, "Reading from EEPROM, not flash\n");
+ }
+
+--- a/drivers/net/wireless/ath/ath9k/hw.h
++++ b/drivers/net/wireless/ath/ath9k/hw.h
+@@ -740,6 +740,7 @@ enum ath_cal_list {
+ #define AH_USE_EEPROM 0x1
+ #define AH_UNPLUGGED 0x2 /* The card has been physically removed. */
+ #define AH_FASTCC 0x4
++#define AH_NO_EEP_SWAP 0x8 /* Do not swap EEPROM data */
+
+ struct ath_hw {
+ struct ath_ops reg_ops;
+--- a/drivers/net/wireless/ath/ath9k/init.c
++++ b/drivers/net/wireless/ath/ath9k/init.c
+@@ -587,6 +587,8 @@ static int ath9k_init_softc(u16 devid, s
+ ah->is_clk_25mhz = pdata->is_clk_25mhz;
+ ah->get_mac_revision = pdata->get_mac_revision;
+ ah->external_reset = pdata->external_reset;
++ if (!pdata->endian_check)
++ ah->ah_flags |= AH_NO_EEP_SWAP;
+ }
+
+ common = ath9k_hw_common(ah);
+--- a/include/linux/ath9k_platform.h
++++ b/include/linux/ath9k_platform.h
+@@ -31,6 +31,7 @@ struct ath9k_platform_data {
+ u32 gpio_mask;
+ u32 gpio_val;
+
++ bool endian_check;
+ bool is_clk_25mhz;
+ int (*get_mac_revision)(void);
+ int (*external_reset)(void);
diff --git a/package/mac80211/patches/.svn/text-base/502-ath9k_ahb_init.patch.svn-base b/package/mac80211/patches/.svn/text-base/502-ath9k_ahb_init.patch.svn-base
new file mode 100644
index 0000000..8884163
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/502-ath9k_ahb_init.patch.svn-base
@@ -0,0 +1,32 @@
+--- a/drivers/net/wireless/ath/ath9k/init.c
++++ b/drivers/net/wireless/ath/ath9k/init.c
+@@ -965,23 +965,23 @@ static int __init ath9k_init(void)
+ goto err_out;
+ }
+
+- error = ath_pci_init();
++ error = ath_ahb_init();
+ if (error < 0) {
+- pr_err("No PCI devices found, driver not installed\n");
+ error = -ENODEV;
+ goto err_rate_unregister;
+ }
+
+- error = ath_ahb_init();
++ error = ath_pci_init();
+ if (error < 0) {
++ pr_err("No PCI devices found, driver not installed\n");
+ error = -ENODEV;
+- goto err_pci_exit;
++ goto err_ahb_exit;
+ }
+
+ return 0;
+
+- err_pci_exit:
+- ath_pci_exit();
++ err_ahb_exit:
++ ath_ahb_exit();
+
+ err_rate_unregister:
+ ath_rate_control_unregister();
diff --git a/package/mac80211/patches/.svn/text-base/510-ath9k_intr_mitigation_tweak.patch.svn-base b/package/mac80211/patches/.svn/text-base/510-ath9k_intr_mitigation_tweak.patch.svn-base
new file mode 100644
index 0000000..ff6ff27
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/510-ath9k_intr_mitigation_tweak.patch.svn-base
@@ -0,0 +1,13 @@
+--- a/drivers/net/wireless/ath/ath9k/hw.c
++++ b/drivers/net/wireless/ath/ath9k/hw.c
+@@ -1947,8 +1947,8 @@ int ath9k_hw_reset(struct ath_hw *ah, st
+ REG_WRITE(ah, AR_OBS, 8);
+
+ if (ah->config.rx_intr_mitigation) {
+- REG_RMW_FIELD(ah, AR_RIMT, AR_RIMT_LAST, 500);
+- REG_RMW_FIELD(ah, AR_RIMT, AR_RIMT_FIRST, 2000);
++ REG_RMW_FIELD(ah, AR_RIMT, AR_RIMT_LAST, 250);
++ REG_RMW_FIELD(ah, AR_RIMT, AR_RIMT_FIRST, 500);
+ }
+
+ if (ah->config.tx_intr_mitigation) {
diff --git a/package/mac80211/patches/.svn/text-base/511-ath9k_reduce_rxbuf.patch.svn-base b/package/mac80211/patches/.svn/text-base/511-ath9k_reduce_rxbuf.patch.svn-base
new file mode 100644
index 0000000..8d8c5fd
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/511-ath9k_reduce_rxbuf.patch.svn-base
@@ -0,0 +1,11 @@
+--- a/drivers/net/wireless/ath/ath9k/ath9k.h
++++ b/drivers/net/wireless/ath/ath9k/ath9k.h
+@@ -119,7 +119,7 @@ int ath_descdma_setup(struct ath_softc *
+ /* RX / TX */
+ /***********/
+
+-#define ATH_RXBUF 512
++#define ATH_RXBUF 256
+ #define ATH_TXBUF 512
+ #define ATH_TXBUF_RESERVE 5
+ #define ATH_MAX_QDEPTH (ATH_TXBUF / 4 - ATH_TXBUF_RESERVE)
diff --git a/package/mac80211/patches/.svn/text-base/512-ath9k_channelbw_debugfs.patch.svn-base b/package/mac80211/patches/.svn/text-base/512-ath9k_channelbw_debugfs.patch.svn-base
new file mode 100644
index 0000000..1af9de0
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/512-ath9k_channelbw_debugfs.patch.svn-base
@@ -0,0 +1,128 @@
+--- a/drivers/net/wireless/ath/ath9k/ath9k.h
++++ b/drivers/net/wireless/ath/ath9k/ath9k.h
+@@ -690,6 +690,7 @@ struct ath_softc {
+ struct ieee80211_hw *hw;
+ struct device *dev;
+
++ u32 chan_bw;
+ struct survey_info *cur_survey;
+ struct survey_info survey[ATH9K_NUM_CHANNELS];
+
+@@ -894,6 +895,7 @@ struct fft_sample_ht20 {
+ u8 data[SPECTRAL_HT20_NUM_BINS];
+ } __packed;
+
++int ath9k_config(struct ieee80211_hw *hw, u32 changed);
+ void ath9k_tasklet(unsigned long data);
+ int ath_cabq_update(struct ath_softc *);
+
+--- a/drivers/net/wireless/ath/ath9k/debug.c
++++ b/drivers/net/wireless/ath/ath9k/debug.c
+@@ -2050,6 +2050,50 @@ static const struct file_operations fops
+ .owner = THIS_MODULE
+ };
+
++
++static ssize_t read_file_chan_bw(struct file *file, char __user *user_buf,
++ size_t count, loff_t *ppos)
++{
++ struct ath_softc *sc = file->private_data;
++ char buf[32];
++ unsigned int len;
++
++ len = sprintf(buf, "0x%08x\n", sc->chan_bw);
++ return simple_read_from_buffer(user_buf, count, ppos, buf, len);
++}
++
++static ssize_t write_file_chan_bw(struct file *file, const char __user *user_buf,
++ size_t count, loff_t *ppos)
++{
++ struct ath_softc *sc = file->private_data;
++ unsigned long chan_bw;
++ char buf[32];
++ ssize_t len;
++
++ len = min(count, sizeof(buf) - 1);
++ if (copy_from_user(buf, user_buf, len))
++ return -EFAULT;
++
++ buf[len] = '\0';
++ if (strict_strtoul(buf, 0, &chan_bw))
++ return -EINVAL;
++
++ sc->chan_bw = chan_bw;
++ if (!test_bit(SC_OP_INVALID, &sc->sc_flags))
++ ath9k_config(sc->hw, IEEE80211_CONF_CHANGE_CHANNEL);
++
++ return count;
++}
++
++static const struct file_operations fops_chanbw = {
++ .read = read_file_chan_bw,
++ .write = write_file_chan_bw,
++ .open = simple_open,
++ .owner = THIS_MODULE,
++ .llseek = default_llseek,
++};
++
++
+ int ath9k_init_debug(struct ath_hw *ah)
+ {
+ struct ath_common *common = ath9k_hw_common(ah);
+@@ -2069,6 +2113,8 @@ int ath9k_init_debug(struct ath_hw *ah)
+
+ debugfs_create_file("eeprom", S_IRUSR, sc->debug.debugfs_phy, sc,
+ &fops_eeprom);
++ debugfs_create_file("chanbw", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
++ sc, &fops_chanbw);
+ debugfs_create_file("dma", S_IRUSR, sc->debug.debugfs_phy, sc,
+ &fops_dma);
+ debugfs_create_file("interrupt", S_IRUSR, sc->debug.debugfs_phy, sc,
+--- a/drivers/net/wireless/ath/ath9k/main.c
++++ b/drivers/net/wireless/ath/ath9k/main.c
+@@ -1131,7 +1131,7 @@ int ath9k_spectral_scan_config(struct ie
+ return 0;
+ }
+
+-static int ath9k_config(struct ieee80211_hw *hw, u32 changed)
++int ath9k_config(struct ieee80211_hw *hw, u32 changed)
+ {
+ struct ath_softc *sc = hw->priv;
+ struct ath_hw *ah = sc->sc_ah;
+@@ -1185,9 +1185,11 @@ static int ath9k_config(struct ieee80211
+
+ if ((changed & IEEE80211_CONF_CHANGE_CHANNEL) || reset_channel) {
+ struct ieee80211_channel *curchan = hw->conf.channel;
++ struct ath9k_channel *hchan;
+ int pos = curchan->hw_value;
+ int old_pos = -1;
+ unsigned long flags;
++ u32 oldflags;
+
+ if (ah->curchan)
+ old_pos = ah->curchan - &ah->channels[0];
+@@ -1230,7 +1232,23 @@ static int ath9k_config(struct ieee80211
+ memset(&sc->survey[pos], 0, sizeof(struct survey_info));
+ }
+
+- if (ath_set_channel(sc, hw, &sc->sc_ah->channels[pos]) < 0) {
++ hchan = &sc->sc_ah->channels[pos];
++ oldflags = hchan->channelFlags;
++ switch (sc->chan_bw) {
++ case 5:
++ hchan->channelFlags &= ~CHANNEL_HALF;
++ hchan->channelFlags |= CHANNEL_QUARTER;
++ break;
++ case 10:
++ hchan->channelFlags &= ~CHANNEL_QUARTER;
++ hchan->channelFlags |= CHANNEL_HALF;
++ break;
++ default:
++ hchan->channelFlags &= ~(CHANNEL_HALF | CHANNEL_QUARTER);
++ break;
++ }
++
++ if (ath_set_channel(sc, hw, hchan) < 0) {
+ ath_err(common, "Unable to set channel\n");
+ mutex_unlock(&sc->mutex);
+ ath9k_ps_restore(sc);
diff --git a/package/mac80211/patches/.svn/text-base/513-mac80211_reduce_txqueuelen.patch.svn-base b/package/mac80211/patches/.svn/text-base/513-mac80211_reduce_txqueuelen.patch.svn-base
new file mode 100644
index 0000000..fe44cdb
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/513-mac80211_reduce_txqueuelen.patch.svn-base
@@ -0,0 +1,10 @@
+--- a/net/mac80211/iface.c
++++ b/net/mac80211/iface.c
+@@ -995,6 +995,7 @@ static const struct net_device_ops ieee8
+ static void ieee80211_if_setup(struct net_device *dev)
+ {
+ ether_setup(dev);
++ dev->tx_queue_len = 32;
+ dev->priv_flags &= ~IFF_TX_SKB_SHARING;
+ netdev_attach_ops(dev, &ieee80211_dataif_ops);
+ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29))
diff --git a/package/mac80211/patches/.svn/text-base/520-mac80211_cur_txpower.patch.svn-base b/package/mac80211/patches/.svn/text-base/520-mac80211_cur_txpower.patch.svn-base
new file mode 100644
index 0000000..f0ed3d9
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/520-mac80211_cur_txpower.patch.svn-base
@@ -0,0 +1,33 @@
+--- a/include/net/mac80211.h
++++ b/include/net/mac80211.h
+@@ -1554,6 +1554,7 @@ struct ieee80211_hw {
+ u8 max_tx_aggregation_subframes;
+ u8 offchannel_tx_hw_queue;
+ u8 radiotap_mcs_details;
++ s8 cur_power_level;
+ u16 radiotap_vht_details;
+ netdev_features_t netdev_features;
+ };
+--- a/net/mac80211/cfg.c
++++ b/net/mac80211/cfg.c
+@@ -2190,7 +2190,9 @@ static int ieee80211_get_tx_power(struct
+ struct ieee80211_local *local = wiphy_priv(wiphy);
+ struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
+
+- if (!local->use_chanctx)
++ if (local->hw.cur_power_level)
++ *dbm = local->hw.cur_power_level;
++ else if (!local->use_chanctx)
+ *dbm = local->hw.conf.power_level;
+ else
+ *dbm = sdata->vif.bss_conf.txpower;
+--- a/net/mac80211/main.c
++++ b/net/mac80211/main.c
+@@ -166,6 +166,7 @@ static u32 ieee80211_hw_conf_chan(struct
+
+ if (local->hw.conf.power_level != power) {
+ changed |= IEEE80211_CONF_CHANGE_POWER;
++ local->hw.cur_power_level = power;
+ local->hw.conf.power_level = power;
+ }
+
diff --git a/package/mac80211/patches/.svn/text-base/521-ath9k_cur_txpower.patch.svn-base b/package/mac80211/patches/.svn/text-base/521-ath9k_cur_txpower.patch.svn-base
new file mode 100644
index 0000000..fc091f2
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/521-ath9k_cur_txpower.patch.svn-base
@@ -0,0 +1,19 @@
+--- a/drivers/net/wireless/ath/ath9k/main.c
++++ b/drivers/net/wireless/ath/ath9k/main.c
+@@ -1255,6 +1255,8 @@ int ath9k_config(struct ieee80211_hw *hw
+ return -EINVAL;
+ }
+
++ hw->cur_power_level = sc->curtxpow / 2;
++
+ /*
+ * The most recent snapshot of channel->noisefloor for the old
+ * channel is only available after the hardware reset. Copy it to
+@@ -1274,6 +1276,7 @@ int ath9k_config(struct ieee80211_hw *hw
+ sc->config.txpowlimit = 2 * conf->power_level;
+ ath9k_cmn_update_txpow(ah, sc->curtxpow,
+ sc->config.txpowlimit, &sc->curtxpow);
++ hw->cur_power_level = sc->curtxpow / 2;
+ }
+
+ mutex_unlock(&sc->mutex);
diff --git a/package/mac80211/patches/.svn/text-base/522-ath9k_per_chain_signal_strength.patch.svn-base b/package/mac80211/patches/.svn/text-base/522-ath9k_per_chain_signal_strength.patch.svn-base
new file mode 100644
index 0000000..c0feedd
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/522-ath9k_per_chain_signal_strength.patch.svn-base
@@ -0,0 +1,393 @@
+--- a/include/net/mac80211.h
++++ b/include/net/mac80211.h
+@@ -839,6 +839,9 @@ enum mac80211_rx_flags {
+ * @signal: signal strength when receiving this frame, either in dBm, in dB or
+ * unspecified depending on the hardware capabilities flags
+ * @IEEE80211_HW_SIGNAL_*
++ * @chains: bitmask of receive chains for which separate signal strength
++ * values were filled.
++ * @chain_signal: per-chain signal strength, same format as @signal
+ * @antenna: antenna used
+ * @rate_idx: index of data rate into band's supported rates or MCS index if
+ * HT or VHT is used (%RX_FLAG_HT/%RX_FLAG_VHT)
+@@ -870,6 +873,8 @@ struct ieee80211_rx_status {
+ u8 band;
+ u8 antenna;
+ s8 signal;
++ u8 chains;
++ s8 chain_signal[4];
+ u8 ampdu_delimiter_crc;
+ u8 vendor_radiotap_align;
+ u8 vendor_radiotap_oui[3];
+--- a/net/mac80211/sta_info.h
++++ b/net/mac80211/sta_info.h
+@@ -342,6 +342,11 @@ struct sta_info {
+ int last_signal;
+ struct ewma avg_signal;
+ int last_ack_signal;
++
++ u8 chains;
++ s8 chain_signal_last[4];
++ struct ewma chain_signal_avg[4];
++
+ /* Plus 1 for non-QoS frames */
+ __le16 last_seq_ctrl[IEEE80211_NUM_TIDS + 1];
+
+--- a/net/mac80211/rx.c
++++ b/net/mac80211/rx.c
+@@ -1383,6 +1383,7 @@ ieee80211_rx_h_sta_process(struct ieee80
+ struct sk_buff *skb = rx->skb;
+ struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
+ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
++ int i;
+
+ if (!sta)
+ return RX_CONTINUE;
+@@ -1433,6 +1434,19 @@ ieee80211_rx_h_sta_process(struct ieee80
+ ewma_add(&sta->avg_signal, -status->signal);
+ }
+
++ if (status->chains) {
++ sta->chains = status->chains;
++ for (i = 0; i < 4; i++) {
++ int signal = status->chain_signal[i];
++
++ if (!(status->chains & BIT(i)))
++ continue;
++
++ sta->chain_signal_last[i] = signal;
++ ewma_add(&sta->chain_signal_avg[i], -signal);
++ }
++ }
++
+ /*
+ * Change STA power saving mode only at the end of a frame
+ * exchange sequence.
+--- a/net/mac80211/sta_info.c
++++ b/net/mac80211/sta_info.c
+@@ -353,6 +353,8 @@ struct sta_info *sta_info_alloc(struct i
+ do_posix_clock_monotonic_gettime(&uptime);
+ sta->last_connected = uptime.tv_sec;
+ ewma_init(&sta->avg_signal, 1024, 8);
++ for (i = 0; i < ARRAY_SIZE(sta->chain_signal_avg); i++)
++ ewma_init(&sta->chain_signal_avg[i], 1024, 8);
+
+ if (sta_prepare_rate_control(local, sta, gfp)) {
+ kfree(sta);
+--- a/include/net/cfg80211.h
++++ b/include/net/cfg80211.h
+@@ -721,6 +721,8 @@ struct station_parameters {
+ * @STATION_INFO_LOCAL_PM: @local_pm filled
+ * @STATION_INFO_PEER_PM: @peer_pm filled
+ * @STATION_INFO_NONPEER_PM: @nonpeer_pm filled
++ * @STATION_INFO_CHAIN_SIGNAL: @chain_signal filled
++ * @STATION_INFO_CHAIN_SIGNAL_AVG: @chain_signal_avg filled
+ */
+ enum station_info_flags {
+ STATION_INFO_INACTIVE_TIME = 1<<0,
+@@ -749,6 +751,8 @@ enum station_info_flags {
+ STATION_INFO_NONPEER_PM = 1<<23,
+ STATION_INFO_RX_BYTES64 = 1<<24,
+ STATION_INFO_TX_BYTES64 = 1<<25,
++ STATION_INFO_CHAIN_SIGNAL = 1<<26,
++ STATION_INFO_CHAIN_SIGNAL_AVG = 1<<27,
+ };
+
+ /**
+@@ -842,6 +846,9 @@ struct sta_bss_parameters {
+ * For CFG80211_SIGNAL_TYPE_MBM, value is expressed in _dBm_.
+ * @signal_avg: Average signal strength, type depends on the wiphy's signal_type.
+ * For CFG80211_SIGNAL_TYPE_MBM, value is expressed in _dBm_.
++ * @chains: bitmask for filled values in @chain_signal, @chain_signal_avg
++ * @chain_signal: per-chain signal strength of last received packet in dBm
++ * @chain_signal_avg: per-chain signal strength average in dBm
+ * @txrate: current unicast bitrate from this station
+ * @rxrate: current unicast bitrate to this station
+ * @rx_packets: packets received from this station
+@@ -877,6 +884,11 @@ struct station_info {
+ u8 plink_state;
+ s8 signal;
+ s8 signal_avg;
++
++ u8 chains;
++ s8 chain_signal[4];
++ s8 chain_signal_avg[4];
++
+ struct rate_info txrate;
+ struct rate_info rxrate;
+ u32 rx_packets;
+--- a/drivers/net/wireless/ath/ath9k/mac.h
++++ b/drivers/net/wireless/ath/ath9k/mac.h
+@@ -133,12 +133,8 @@ struct ath_rx_status {
+ u8 rs_rate;
+ u8 rs_antenna;
+ u8 rs_more;
+- int8_t rs_rssi_ctl0;
+- int8_t rs_rssi_ctl1;
+- int8_t rs_rssi_ctl2;
+- int8_t rs_rssi_ext0;
+- int8_t rs_rssi_ext1;
+- int8_t rs_rssi_ext2;
++ int8_t rs_rssi_ctl[3];
++ int8_t rs_rssi_ext[3];
+ u8 rs_isaggr;
+ u8 rs_moreaggr;
+ u8 rs_num_delims;
+--- a/drivers/net/wireless/ath/ath9k/recv.c
++++ b/drivers/net/wireless/ath/ath9k/recv.c
+@@ -937,6 +937,7 @@ static int ath9k_rx_skb_preprocess(struc
+ bool *decrypt_error)
+ {
+ struct ath_hw *ah = common->ah;
++ int i, j;
+
+ /*
+ * everything but the rate is checked here, the rate check is done
+@@ -962,6 +963,20 @@ static int ath9k_rx_skb_preprocess(struc
+ if (rx_stats->rs_moreaggr)
+ rx_status->flag |= RX_FLAG_NO_SIGNAL_VAL;
+
++ for (i = 0, j = 0; i < ARRAY_SIZE(rx_stats->rs_rssi_ctl); i++) {
++ s8 rssi;
++
++ if (!(ah->rxchainmask & BIT(i)))
++ continue;
++
++ rssi = rx_stats->rs_rssi_ctl[i];
++ if (rssi != ATH9K_RSSI_BAD) {
++ rx_status->chains |= BIT(j);
++ rx_status->chain_signal[j] = ah->noise + rssi;
++ }
++ j++;
++ }
++
+ return 0;
+ }
+
+@@ -1070,7 +1085,7 @@ static int ath_process_fft(struct ath_so
+ fft_sample.tlv.length = __cpu_to_be16(length);
+
+ fft_sample.freq = __cpu_to_be16(ah->curchan->chan->center_freq);
+- fft_sample.rssi = fix_rssi_inv_only(rs->rs_rssi_ctl0);
++ fft_sample.rssi = fix_rssi_inv_only(rs->rs_rssi_ctl[0]);
+ fft_sample.noise = ah->noise;
+
+ switch (len - SPECTRAL_HT20_TOTAL_DATA_LEN) {
+--- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
++++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
+@@ -475,12 +475,12 @@ int ath9k_hw_process_rxdesc_edma(struct
+
+ /* XXX: Keycache */
+ rxs->rs_rssi = MS(rxsp->status5, AR_RxRSSICombined);
+- rxs->rs_rssi_ctl0 = MS(rxsp->status1, AR_RxRSSIAnt00);
+- rxs->rs_rssi_ctl1 = MS(rxsp->status1, AR_RxRSSIAnt01);
+- rxs->rs_rssi_ctl2 = MS(rxsp->status1, AR_RxRSSIAnt02);
+- rxs->rs_rssi_ext0 = MS(rxsp->status5, AR_RxRSSIAnt10);
+- rxs->rs_rssi_ext1 = MS(rxsp->status5, AR_RxRSSIAnt11);
+- rxs->rs_rssi_ext2 = MS(rxsp->status5, AR_RxRSSIAnt12);
++ rxs->rs_rssi_ctl[0] = MS(rxsp->status1, AR_RxRSSIAnt00);
++ rxs->rs_rssi_ctl[1] = MS(rxsp->status1, AR_RxRSSIAnt01);
++ rxs->rs_rssi_ctl[2] = MS(rxsp->status1, AR_RxRSSIAnt02);
++ rxs->rs_rssi_ext[0] = MS(rxsp->status5, AR_RxRSSIAnt10);
++ rxs->rs_rssi_ext[1] = MS(rxsp->status5, AR_RxRSSIAnt11);
++ rxs->rs_rssi_ext[2] = MS(rxsp->status5, AR_RxRSSIAnt12);
+
+ if (rxsp->status11 & AR_RxKeyIdxValid)
+ rxs->rs_keyix = MS(rxsp->status11, AR_KeyIdx);
+--- a/drivers/net/wireless/ath/ath9k/mac.c
++++ b/drivers/net/wireless/ath/ath9k/mac.c
+@@ -553,25 +553,25 @@ int ath9k_hw_rxprocdesc(struct ath_hw *a
+
+ if (ads.ds_rxstatus8 & AR_PostDelimCRCErr) {
+ rs->rs_rssi = ATH9K_RSSI_BAD;
+- rs->rs_rssi_ctl0 = ATH9K_RSSI_BAD;
+- rs->rs_rssi_ctl1 = ATH9K_RSSI_BAD;
+- rs->rs_rssi_ctl2 = ATH9K_RSSI_BAD;
+- rs->rs_rssi_ext0 = ATH9K_RSSI_BAD;
+- rs->rs_rssi_ext1 = ATH9K_RSSI_BAD;
+- rs->rs_rssi_ext2 = ATH9K_RSSI_BAD;
++ rs->rs_rssi_ctl[0] = ATH9K_RSSI_BAD;
++ rs->rs_rssi_ctl[1] = ATH9K_RSSI_BAD;
++ rs->rs_rssi_ctl[2] = ATH9K_RSSI_BAD;
++ rs->rs_rssi_ext[0] = ATH9K_RSSI_BAD;
++ rs->rs_rssi_ext[1] = ATH9K_RSSI_BAD;
++ rs->rs_rssi_ext[2] = ATH9K_RSSI_BAD;
+ } else {
+ rs->rs_rssi = MS(ads.ds_rxstatus4, AR_RxRSSICombined);
+- rs->rs_rssi_ctl0 = MS(ads.ds_rxstatus0,
++ rs->rs_rssi_ctl[0] = MS(ads.ds_rxstatus0,
+ AR_RxRSSIAnt00);
+- rs->rs_rssi_ctl1 = MS(ads.ds_rxstatus0,
++ rs->rs_rssi_ctl[1] = MS(ads.ds_rxstatus0,
+ AR_RxRSSIAnt01);
+- rs->rs_rssi_ctl2 = MS(ads.ds_rxstatus0,
++ rs->rs_rssi_ctl[2] = MS(ads.ds_rxstatus0,
+ AR_RxRSSIAnt02);
+- rs->rs_rssi_ext0 = MS(ads.ds_rxstatus4,
++ rs->rs_rssi_ext[0] = MS(ads.ds_rxstatus4,
+ AR_RxRSSIAnt10);
+- rs->rs_rssi_ext1 = MS(ads.ds_rxstatus4,
++ rs->rs_rssi_ext[1] = MS(ads.ds_rxstatus4,
+ AR_RxRSSIAnt11);
+- rs->rs_rssi_ext2 = MS(ads.ds_rxstatus4,
++ rs->rs_rssi_ext[2] = MS(ads.ds_rxstatus4,
+ AR_RxRSSIAnt12);
+ }
+ if (ads.ds_rxstatus8 & AR_RxKeyIdxValid)
+--- a/drivers/net/wireless/ath/ath9k/debug.c
++++ b/drivers/net/wireless/ath/ath9k/debug.c
+@@ -940,12 +940,12 @@ void ath_debug_stat_rx(struct ath_softc
+ #ifdef CONFIG_ATH9K_MAC_DEBUG
+ spin_lock(&sc->debug.samp_lock);
+ RX_SAMP_DBG(jiffies) = jiffies;
+- RX_SAMP_DBG(rssi_ctl0) = rs->rs_rssi_ctl0;
+- RX_SAMP_DBG(rssi_ctl1) = rs->rs_rssi_ctl1;
+- RX_SAMP_DBG(rssi_ctl2) = rs->rs_rssi_ctl2;
+- RX_SAMP_DBG(rssi_ext0) = rs->rs_rssi_ext0;
+- RX_SAMP_DBG(rssi_ext1) = rs->rs_rssi_ext1;
+- RX_SAMP_DBG(rssi_ext2) = rs->rs_rssi_ext2;
++ RX_SAMP_DBG(rssi_ctl0) = rs->rs_rssi_ctl[0];
++ RX_SAMP_DBG(rssi_ctl1) = rs->rs_rssi_ctl[1];
++ RX_SAMP_DBG(rssi_ctl2) = rs->rs_rssi_ctl[2];
++ RX_SAMP_DBG(rssi_ext0) = rs->rs_rssi_ext[0];
++ RX_SAMP_DBG(rssi_ext1) = rs->rs_rssi_ext[1];
++ RX_SAMP_DBG(rssi_ext2) = rs->rs_rssi_ext[2];
+ RX_SAMP_DBG(antenna) = rs->rs_antenna;
+ RX_SAMP_DBG(rssi) = rs->rs_rssi;
+ RX_SAMP_DBG(rate) = rs->rs_rate;
+--- a/include/uapi/linux/nl80211.h
++++ b/include/uapi/linux/nl80211.h
+@@ -1918,6 +1918,8 @@ enum nl80211_sta_bss_param {
+ * @NL80211_STA_INFO_PEER_PM: peer mesh STA link-specific power mode
+ * @NL80211_STA_INFO_NONPEER_PM: neighbor mesh STA power save mode towards
+ * non-peer STA
++ * @NL80211_STA_INFO_CHAIN_SIGNAL: per-chain signal strength of last PPDU
++ * @NL80211_STA_INFO_CHAIN_SIGNAL_AVG: per-chain signal strength average
+ * @__NL80211_STA_INFO_AFTER_LAST: internal
+ * @NL80211_STA_INFO_MAX: highest possible station info attribute
+ */
+@@ -1947,6 +1949,8 @@ enum nl80211_sta_info {
+ NL80211_STA_INFO_NONPEER_PM,
+ NL80211_STA_INFO_RX_BYTES64,
+ NL80211_STA_INFO_TX_BYTES64,
++ NL80211_STA_INFO_CHAIN_SIGNAL,
++ NL80211_STA_INFO_CHAIN_SIGNAL_AVG,
+
+ /* keep last */
+ __NL80211_STA_INFO_AFTER_LAST,
+--- a/net/wireless/nl80211.c
++++ b/net/wireless/nl80211.c
+@@ -3082,6 +3082,32 @@ static bool nl80211_put_sta_rate(struct
+ return true;
+ }
+
++static bool nl80211_put_signal(struct sk_buff *msg, u8 mask, s8 *signal,
++ int id)
++{
++ void *attr;
++ int i = 0;
++
++ if (!mask)
++ return true;
++
++ attr = nla_nest_start(msg, id);
++ if (!attr)
++ return false;
++
++ for (i = 0; i < 4; i++) {
++ if (!(mask & BIT(i)))
++ continue;
++
++ if (nla_put_u8(msg, i, signal[i]))
++ return false;
++ }
++
++ nla_nest_end(msg, attr);
++
++ return true;
++}
++
+ static int nl80211_send_station(struct sk_buff *msg, u32 portid, u32 seq,
+ int flags,
+ struct cfg80211_registered_device *rdev,
+@@ -3153,6 +3179,18 @@ static int nl80211_send_station(struct s
+ default:
+ break;
+ }
++ if (sinfo->filled & STATION_INFO_CHAIN_SIGNAL) {
++ if (!nl80211_put_signal(msg, sinfo->chains,
++ sinfo->chain_signal,
++ NL80211_STA_INFO_CHAIN_SIGNAL))
++ goto nla_put_failure;
++ }
++ if (sinfo->filled & STATION_INFO_CHAIN_SIGNAL_AVG) {
++ if (!nl80211_put_signal(msg, sinfo->chains,
++ sinfo->chain_signal_avg,
++ NL80211_STA_INFO_CHAIN_SIGNAL_AVG))
++ goto nla_put_failure;
++ }
+ if (sinfo->filled & STATION_INFO_TX_BITRATE) {
+ if (!nl80211_put_sta_rate(msg, &sinfo->txrate,
+ NL80211_STA_INFO_TX_BITRATE))
+--- a/net/mac80211/cfg.c
++++ b/net/mac80211/cfg.c
+@@ -445,6 +445,7 @@ static void sta_set_sinfo(struct sta_inf
+ struct ieee80211_sub_if_data *sdata = sta->sdata;
+ struct ieee80211_local *local = sdata->local;
+ struct timespec uptime;
++ int i;
+
+ sinfo->generation = sdata->local->sta_generation;
+
+@@ -484,6 +485,17 @@ static void sta_set_sinfo(struct sta_inf
+ sinfo->signal = (s8)sta->last_signal;
+ sinfo->signal_avg = (s8) -ewma_read(&sta->avg_signal);
+ }
++ if (sta->chains) {
++ sinfo->filled |= STATION_INFO_CHAIN_SIGNAL |
++ STATION_INFO_CHAIN_SIGNAL_AVG;
++
++ sinfo->chains = sta->chains;
++ for (i = 0; i < ARRAY_SIZE(sinfo->chain_signal); i++) {
++ sinfo->chain_signal[i] = sta->chain_signal_last[i];
++ sinfo->chain_signal_avg[i] =
++ (s8) -ewma_read(&sta->chain_signal_avg[i]);
++ }
++ }
+
+ sta_set_rate_info_tx(sta, &sta->last_tx_rate, &sinfo->txrate);
+ sta_set_rate_info_rx(sta, &sinfo->rxrate);
+--- a/drivers/net/wireless/ath/ath9k/dfs.c
++++ b/drivers/net/wireless/ath/ath9k/dfs.c
+@@ -164,8 +164,8 @@ void ath9k_dfs_process_phyerr(struct ath
+ return;
+ }
+
+- ard.rssi = rs->rs_rssi_ctl0;
+- ard.ext_rssi = rs->rs_rssi_ext0;
++ ard.rssi = rs->rs_rssi_ctl[0];
++ ard.ext_rssi = rs->rs_rssi_ext[0];
+
+ /*
+ * hardware stores this as 8 bit signed value.
+--- a/drivers/net/wireless/ath/ath9k/antenna.c
++++ b/drivers/net/wireless/ath/ath9k/antenna.c
+@@ -546,14 +546,14 @@ void ath_ant_comb_scan(struct ath_softc
+ struct ath_ant_comb *antcomb = &sc->ant_comb;
+ int alt_ratio = 0, alt_rssi_avg = 0, main_rssi_avg = 0, curr_alt_set;
+ int curr_main_set;
+- int main_rssi = rs->rs_rssi_ctl0;
+- int alt_rssi = rs->rs_rssi_ctl1;
++ int main_rssi = rs->rs_rssi_ctl[0];
++ int alt_rssi = rs->rs_rssi_ctl[1];
+ int rx_ant_conf, main_ant_conf;
+ bool short_scan = false;
+
+- rx_ant_conf = (rs->rs_rssi_ctl2 >> ATH_ANT_RX_CURRENT_SHIFT) &
++ rx_ant_conf = (rs->rs_rssi_ctl[2] >> ATH_ANT_RX_CURRENT_SHIFT) &
+ ATH_ANT_RX_MASK;
+- main_ant_conf = (rs->rs_rssi_ctl2 >> ATH_ANT_RX_MAIN_SHIFT) &
++ main_ant_conf = (rs->rs_rssi_ctl[2] >> ATH_ANT_RX_MAIN_SHIFT) &
+ ATH_ANT_RX_MASK;
+
+ /* Record packet only when both main_rssi and alt_rssi is positive */
diff --git a/package/mac80211/patches/.svn/text-base/523-mac80211_configure_antenna_gain.patch.svn-base b/package/mac80211/patches/.svn/text-base/523-mac80211_configure_antenna_gain.patch.svn-base
new file mode 100644
index 0000000..8c13f32
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/523-mac80211_configure_antenna_gain.patch.svn-base
@@ -0,0 +1,162 @@
+--- a/include/net/mac80211.h
++++ b/include/net/mac80211.h
+@@ -978,6 +978,7 @@ enum ieee80211_smps_mode {
+ *
+ * @power_level: requested transmit power (in dBm), backward compatibility
+ * value only that is set to the minimum of all interfaces
++ * @max_antenna_gain: maximum antenna gain adjusted by user config (in dBi)
+ *
+ * @channel: the channel to tune to
+ * @channel_type: the channel (HT) type
+@@ -1000,6 +1001,7 @@ struct ieee80211_conf {
+ u32 flags;
+ int power_level, dynamic_ps_timeout;
+ int max_sleep_period;
++ int max_antenna_gain;
+
+ u16 listen_interval;
+ u8 ps_dtim_period;
+--- a/net/mac80211/ieee80211_i.h
++++ b/net/mac80211/ieee80211_i.h
+@@ -1116,6 +1116,7 @@ struct ieee80211_local {
+ int dynamic_ps_forced_timeout;
+
+ int user_power_level; /* in dBm, for all interfaces */
++ int user_antenna_gain; /* in dBi */
+
+ enum ieee80211_smps_mode smps_mode;
+
+--- a/include/uapi/linux/nl80211.h
++++ b/include/uapi/linux/nl80211.h
+@@ -1654,6 +1654,8 @@ enum nl80211_attrs {
+ NL80211_ATTR_STA_CAPABILITY,
+ NL80211_ATTR_STA_EXT_CAPABILITY,
+
++ NL80211_ATTR_WIPHY_ANTENNA_GAIN,
++
+ /* add attributes here, update the policy in nl80211.c */
+
+ __NL80211_ATTR_AFTER_LAST,
+--- a/net/wireless/nl80211.c
++++ b/net/wireless/nl80211.c
+@@ -370,6 +370,7 @@ static const struct nla_policy nl80211_p
+ [NL80211_ATTR_MAC_ADDRS] = { .type = NLA_NESTED },
+ [NL80211_ATTR_STA_CAPABILITY] = { .type = NLA_U16 },
+ [NL80211_ATTR_STA_EXT_CAPABILITY] = { .type = NLA_BINARY, },
++ [NL80211_ATTR_WIPHY_ANTENNA_GAIN] = { .type = NLA_U32 },
+ };
+
+ /* policy for the key attributes */
+@@ -1705,6 +1706,22 @@ static int nl80211_set_wiphy(struct sk_b
+ if (result)
+ goto bad_res;
+ }
++
++ if (info->attrs[NL80211_ATTR_WIPHY_ANTENNA_GAIN]) {
++ int idx, dbi = 0;
++
++ if (!rdev->ops->set_antenna_gain) {
++ result = -EOPNOTSUPP;
++ goto bad_res;
++ }
++
++ idx = NL80211_ATTR_WIPHY_ANTENNA_GAIN;
++ dbi = nla_get_u32(info->attrs[idx]);
++
++ result = rdev->ops->set_antenna_gain(&rdev->wiphy, dbi);
++ if (result)
++ goto bad_res;
++ }
+
+ if (info->attrs[NL80211_ATTR_WIPHY_ANTENNA_TX] &&
+ info->attrs[NL80211_ATTR_WIPHY_ANTENNA_RX]) {
+--- a/net/mac80211/cfg.c
++++ b/net/mac80211/cfg.c
+@@ -2212,6 +2212,19 @@ static int ieee80211_get_tx_power(struct
+ return 0;
+ }
+
++static int ieee80211_set_antenna_gain(struct wiphy *wiphy, int dbi)
++{
++ struct ieee80211_local *local = wiphy_priv(wiphy);
++
++ if (dbi < 0)
++ return -EINVAL;
++
++ local->user_antenna_gain = dbi;
++ ieee80211_hw_config(local, 0);
++
++ return 0;
++}
++
+ static int ieee80211_set_wds_peer(struct wiphy *wiphy, struct net_device *dev,
+ const u8 *addr)
+ {
+@@ -3375,6 +3388,7 @@ struct cfg80211_ops mac80211_config_ops
+ .set_wiphy_params = ieee80211_set_wiphy_params,
+ .set_tx_power = ieee80211_set_tx_power,
+ .get_tx_power = ieee80211_get_tx_power,
++ .set_antenna_gain = ieee80211_set_antenna_gain,
+ .set_wds_peer = ieee80211_set_wds_peer,
+ .rfkill_poll = ieee80211_rfkill_poll,
+ CFG80211_TESTMODE_CMD(ieee80211_testmode_cmd)
+--- a/include/net/cfg80211.h
++++ b/include/net/cfg80211.h
+@@ -1862,6 +1862,7 @@ struct cfg80211_gtk_rekey_data {
+ * (as advertised by the nl80211 feature flag.)
+ * @get_tx_power: store the current TX power into the dbm variable;
+ * return 0 if successful
++ * @set_antenna_gain: set antenna gain to reduce maximum tx power if necessary
+ *
+ * @set_wds_peer: set the WDS peer for a WDS interface
+ *
+@@ -2071,6 +2072,7 @@ struct cfg80211_ops {
+ enum nl80211_tx_power_setting type, int mbm);
+ int (*get_tx_power)(struct wiphy *wiphy, struct wireless_dev *wdev,
+ int *dbm);
++ int (*set_antenna_gain)(struct wiphy *wiphy, int dbi);
+
+ int (*set_wds_peer)(struct wiphy *wiphy, struct net_device *dev,
+ const u8 *addr);
+--- a/net/mac80211/main.c
++++ b/net/mac80211/main.c
+@@ -101,7 +101,7 @@ static u32 ieee80211_hw_conf_chan(struct
+ struct ieee80211_sub_if_data *sdata;
+ struct ieee80211_channel *chan;
+ u32 changed = 0;
+- int power;
++ int power, ant_gain, max_power;
+ enum nl80211_channel_type channel_type;
+ u32 offchannel_flag;
+ bool scanning = false;
+@@ -164,8 +164,21 @@ static u32 ieee80211_hw_conf_chan(struct
+ }
+ rcu_read_unlock();
+
+- if (local->hw.conf.power_level != power) {
++ max_power = chan->max_reg_power;
++ ant_gain = chan->max_antenna_gain;
++ if (local->user_antenna_gain > 0) {
++ if (local->user_antenna_gain > ant_gain) {
++ max_power -= local->user_antenna_gain - ant_gain;
++ ant_gain = 0;
++ } else
++ ant_gain -= local->user_antenna_gain;
++ power = min(power, max_power);
++ }
++
++ if (local->hw.conf.power_level != power ||
++ local->hw.conf.max_antenna_gain != ant_gain) {
+ changed |= IEEE80211_CONF_CHANGE_POWER;
++ local->hw.conf.max_antenna_gain = ant_gain;
+ local->hw.cur_power_level = power;
+ local->hw.conf.power_level = power;
+ }
+@@ -612,6 +625,7 @@ struct ieee80211_hw *ieee80211_alloc_hw(
+ IEEE80211_RADIOTAP_MCS_HAVE_BW;
+ local->hw.radiotap_vht_details = IEEE80211_RADIOTAP_VHT_KNOWN_GI |
+ IEEE80211_RADIOTAP_VHT_KNOWN_BANDWIDTH;
++ local->user_antenna_gain = 0;
+ local->user_power_level = IEEE80211_UNSET_POWER_LEVEL;
+ wiphy->ht_capa_mod_mask = &mac80211_ht_capa_mod_mask;
+
diff --git a/package/mac80211/patches/.svn/text-base/524-ath9k_use_configured_antenna_gain.patch.svn-base b/package/mac80211/patches/.svn/text-base/524-ath9k_use_configured_antenna_gain.patch.svn-base
new file mode 100644
index 0000000..fe05212
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/524-ath9k_use_configured_antenna_gain.patch.svn-base
@@ -0,0 +1,34 @@
+--- a/drivers/net/wireless/ath/ath.h
++++ b/drivers/net/wireless/ath/ath.h
+@@ -73,6 +73,7 @@ struct ath_regulatory {
+ u16 max_power_level;
+ u16 current_rd;
+ int16_t power_limit;
++ int16_t max_antenna_gain;
+ struct reg_dmn_pair_mapping *regpair;
+ };
+
+--- a/drivers/net/wireless/ath/ath9k/hw.c
++++ b/drivers/net/wireless/ath/ath9k/hw.c
+@@ -2818,7 +2818,7 @@ void ath9k_hw_apply_txpower(struct ath_h
+ channel = chan->chan;
+ chan_pwr = min_t(int, channel->max_power * 2, MAX_RATE_POWER);
+ new_pwr = min_t(int, chan_pwr, reg->power_limit);
+- max_gain = chan_pwr - new_pwr + channel->max_antenna_gain * 2;
++ max_gain = chan_pwr - new_pwr + reg->max_antenna_gain * 2;
+
+ ant_gain = get_antenna_gain(ah, chan);
+ if (ant_gain > max_gain)
+--- a/drivers/net/wireless/ath/ath9k/main.c
++++ b/drivers/net/wireless/ath/ath9k/main.c
+@@ -1272,7 +1272,10 @@ int ath9k_config(struct ieee80211_hw *hw
+ }
+
+ if (changed & IEEE80211_CONF_CHANGE_POWER) {
++ struct ath_regulatory *reg = ath9k_hw_regulatory(ah);
++
+ ath_dbg(common, CONFIG, "Set power: %d\n", conf->power_level);
++ reg->max_antenna_gain = conf->max_antenna_gain;
+ sc->config.txpowlimit = 2 * conf->power_level;
+ ath9k_cmn_update_txpow(ah, sc->curtxpow,
+ sc->config.txpowlimit, &sc->curtxpow);
diff --git a/package/mac80211/patches/.svn/text-base/530-ath9k_extra_leds.patch.svn-base b/package/mac80211/patches/.svn/text-base/530-ath9k_extra_leds.patch.svn-base
new file mode 100644
index 0000000..a13cb41
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/530-ath9k_extra_leds.patch.svn-base
@@ -0,0 +1,248 @@
+--- a/drivers/net/wireless/ath/ath9k/ath9k.h
++++ b/drivers/net/wireless/ath/ath9k/ath9k.h
+@@ -551,6 +551,9 @@ struct ath9k_wow_pattern {
+ void ath_init_leds(struct ath_softc *sc);
+ void ath_deinit_leds(struct ath_softc *sc);
+ void ath_fill_led_pin(struct ath_softc *sc);
++int ath_create_gpio_led(struct ath_softc *sc, int gpio, const char *name,
++ const char *trigger, bool active_low);
++
+ #else
+ static inline void ath_init_leds(struct ath_softc *sc)
+ {
+@@ -686,6 +689,13 @@ enum spectral_mode {
+ SPECTRAL_CHANSCAN,
+ };
+
++struct ath_led {
++ struct list_head list;
++ struct ath_softc *sc;
++ const struct gpio_led *gpio;
++ struct led_classdev cdev;
++};
++
+ struct ath_softc {
+ struct ieee80211_hw *hw;
+ struct device *dev;
+@@ -727,9 +737,8 @@ struct ath_softc {
+ struct ieee80211_supported_band sbands[IEEE80211_NUM_BANDS];
+
+ #ifdef CONFIG_MAC80211_LEDS
+- bool led_registered;
+- char led_name[32];
+- struct led_classdev led_cdev;
++ const char *led_default_trigger;
++ struct list_head leds;
+ #endif
+
+ struct ath9k_hw_cal_data caldata;
+--- a/drivers/net/wireless/ath/ath9k/gpio.c
++++ b/drivers/net/wireless/ath/ath9k/gpio.c
+@@ -24,40 +24,102 @@
+ static void ath_led_brightness(struct led_classdev *led_cdev,
+ enum led_brightness brightness)
+ {
+- struct ath_softc *sc = container_of(led_cdev, struct ath_softc, led_cdev);
+- ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, (brightness == LED_OFF));
++ struct ath_led *led = container_of(led_cdev, struct ath_led, cdev);
++ struct ath_softc *sc = led->sc;
++
++ ath9k_ps_wakeup(sc);
++ ath9k_hw_set_gpio(sc->sc_ah, led->gpio->gpio,
++ (brightness != LED_OFF) ^ led->gpio->active_low);
++ ath9k_ps_restore(sc);
++}
++
++static int ath_add_led(struct ath_softc *sc, struct ath_led *led)
++{
++ const struct gpio_led *gpio = led->gpio;
++ int ret;
++
++ led->cdev.name = gpio->name;
++ led->cdev.default_trigger = gpio->default_trigger;
++ led->cdev.brightness_set = ath_led_brightness;
++
++ ret = led_classdev_register(wiphy_dev(sc->hw->wiphy), &led->cdev);
++ if (ret < 0)
++ return ret;
++
++ led->sc = sc;
++ list_add(&led->list, &sc->leds);
++
++ /* Configure gpio for output */
++ ath9k_hw_cfg_output(sc->sc_ah, gpio->gpio,
++ AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
++
++ /* LED off */
++ ath9k_hw_set_gpio(sc->sc_ah, gpio->gpio, gpio->active_low);
++
++ return 0;
++}
++
++int ath_create_gpio_led(struct ath_softc *sc, int gpio_num, const char *name,
++ const char *trigger, bool active_low)
++{
++ struct ath_led *led;
++ struct gpio_led *gpio;
++ char *_name;
++ int ret;
++
++ led = kzalloc(sizeof(*led) + sizeof(*gpio) + strlen(name) + 1,
++ GFP_KERNEL);
++ if (!led)
++ return -ENOMEM;
++
++ led->gpio = gpio = (struct gpio_led *) (led + 1);
++ _name = (char *) (led->gpio + 1);
++
++ strcpy(_name, name);
++ gpio->name = _name;
++ gpio->gpio = gpio_num;
++ gpio->active_low = active_low;
++ gpio->default_trigger = trigger;
++
++ ret = ath_add_led(sc, led);
++ if (unlikely(ret < 0))
++ kfree(led);
++
++ return ret;
+ }
+
+ void ath_deinit_leds(struct ath_softc *sc)
+ {
+- if (!sc->led_registered)
+- return;
++ struct ath_led *led;
+
+- ath_led_brightness(&sc->led_cdev, LED_OFF);
+- led_classdev_unregister(&sc->led_cdev);
++ while (!list_empty(&sc->leds)) {
++ led = list_first_entry(&sc->leds, struct ath_led, list);
++ list_del(&led->list);
++ ath_led_brightness(&led->cdev, LED_OFF);
++ led_classdev_unregister(&led->cdev);
++ kfree(led);
++ }
+ }
+
+ void ath_init_leds(struct ath_softc *sc)
+ {
+- int ret;
++ char led_name[32];
++ const char *trigger;
++
++ INIT_LIST_HEAD(&sc->leds);
+
+ if (AR_SREV_9100(sc->sc_ah))
+ return;
+
+- if (!led_blink)
+- sc->led_cdev.default_trigger =
+- ieee80211_get_radio_led_name(sc->hw);
+-
+- snprintf(sc->led_name, sizeof(sc->led_name),
+- "ath9k-%s", wiphy_name(sc->hw->wiphy));
+- sc->led_cdev.name = sc->led_name;
+- sc->led_cdev.brightness_set = ath_led_brightness;
++ snprintf(led_name, sizeof(led_name), "ath9k-%s",
++ wiphy_name(sc->hw->wiphy));
+
+- ret = led_classdev_register(wiphy_dev(sc->hw->wiphy), &sc->led_cdev);
+- if (ret < 0)
+- return;
++ if (led_blink)
++ trigger = sc->led_default_trigger;
++ else
++ trigger = ieee80211_get_radio_led_name(sc->hw);
+
+- sc->led_registered = true;
++ ath_create_gpio_led(sc, sc->sc_ah->led_pin, led_name, trigger, 1);
+ }
+
+ void ath_fill_led_pin(struct ath_softc *sc)
+--- a/drivers/net/wireless/ath/ath9k/init.c
++++ b/drivers/net/wireless/ath/ath9k/init.c
+@@ -870,7 +870,7 @@ int ath9k_init_device(u16 devid, struct
+
+ #ifdef CONFIG_MAC80211_LEDS
+ /* must be initialized before ieee80211_register_hw */
+- sc->led_cdev.default_trigger = ieee80211_create_tpt_led_trigger(sc->hw,
++ sc->led_default_trigger = ieee80211_create_tpt_led_trigger(sc->hw,
+ IEEE80211_TPT_LEDTRIG_FL_RADIO, ath9k_tpt_blink,
+ ARRAY_SIZE(ath9k_tpt_blink));
+ #endif
+--- a/drivers/net/wireless/ath/ath9k/debug.c
++++ b/drivers/net/wireless/ath/ath9k/debug.c
+@@ -1482,6 +1482,61 @@ static const struct file_operations fops
+ .llseek = default_llseek,
+ };
+
++#ifdef CONFIG_MAC80211_LEDS
++
++static ssize_t write_file_gpio_led(struct file *file, const char __user *ubuf,
++ size_t count, loff_t *ppos)
++{
++ struct ath_softc *sc = file->private_data;
++ char buf[32], *str, *name, *c;
++ ssize_t len;
++ unsigned int gpio;
++ bool active_low = false;
++
++ len = min(count, sizeof(buf) - 1);
++ if (copy_from_user(buf, ubuf, len))
++ return -EFAULT;
++
++ buf[len] = '\0';
++ name = strchr(buf, ',');
++ if (!name)
++ return -EINVAL;
++
++ *(name++) = 0;
++ if (!*name)
++ return -EINVAL;
++
++ c = strchr(name, '\n');
++ if (c)
++ *c = 0;
++
++ str = buf;
++ if (*str == '!') {
++ str++;
++ active_low = true;
++ }
++
++ if (kstrtouint(str, 0, &gpio) < 0)
++ return -EINVAL;
++
++ if (gpio >= sc->sc_ah->caps.num_gpio_pins)
++ return -EINVAL;
++
++ if (ath_create_gpio_led(sc, gpio, name, NULL, active_low) < 0)
++ return -EINVAL;
++
++ return count;
++}
++
++static const struct file_operations fops_gpio_led = {
++ .write = write_file_gpio_led,
++ .open = simple_open,
++ .owner = THIS_MODULE,
++ .llseek = default_llseek,
++};
++
++#endif
++
+ #ifdef CONFIG_ATH9K_MAC_DEBUG
+
+ void ath9k_debug_samp_bb_mac(struct ath_softc *sc)
+@@ -2115,6 +2170,10 @@ int ath9k_init_debug(struct ath_hw *ah)
+ &fops_eeprom);
+ debugfs_create_file("chanbw", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
+ sc, &fops_chanbw);
++#ifdef CONFIG_MAC80211_LEDS
++ debugfs_create_file("gpio_led", S_IWUSR,
++ sc->debug.debugfs_phy, sc, &fops_gpio_led);
++#endif
+ debugfs_create_file("dma", S_IRUSR, sc->debug.debugfs_phy, sc,
+ &fops_dma);
+ debugfs_create_file("interrupt", S_IRUSR, sc->debug.debugfs_phy, sc,
diff --git a/package/mac80211/patches/.svn/text-base/531-ath9k_extra_platform_leds.patch.svn-base b/package/mac80211/patches/.svn/text-base/531-ath9k_extra_platform_leds.patch.svn-base
new file mode 100644
index 0000000..d07fc4e
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/531-ath9k_extra_platform_leds.patch.svn-base
@@ -0,0 +1,71 @@
+--- a/include/linux/ath9k_platform.h
++++ b/include/linux/ath9k_platform.h
+@@ -35,6 +35,9 @@ struct ath9k_platform_data {
+ bool is_clk_25mhz;
+ int (*get_mac_revision)(void);
+ int (*external_reset)(void);
++
++ int num_leds;
++ const struct gpio_led *leds;
+ };
+
+ #endif /* _LINUX_ATH9K_PLATFORM_H */
+--- a/drivers/net/wireless/ath/ath9k/gpio.c
++++ b/drivers/net/wireless/ath/ath9k/gpio.c
+@@ -14,6 +14,7 @@
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
++#include <linux/ath9k_platform.h>
+ #include "ath9k.h"
+
+ /********************************/
+@@ -88,6 +89,24 @@ int ath_create_gpio_led(struct ath_softc
+ return ret;
+ }
+
++static int ath_create_platform_led(struct ath_softc *sc,
++ const struct gpio_led *gpio)
++{
++ struct ath_led *led;
++ int ret;
++
++ led = kzalloc(sizeof(*led), GFP_KERNEL);
++ if (!led)
++ return -ENOMEM;
++
++ led->gpio = gpio;
++ ret = ath_add_led(sc, led);
++ if (ret < 0)
++ kfree(led);
++
++ return ret;
++}
++
+ void ath_deinit_leds(struct ath_softc *sc)
+ {
+ struct ath_led *led;
+@@ -103,8 +122,10 @@ void ath_deinit_leds(struct ath_softc *s
+
+ void ath_init_leds(struct ath_softc *sc)
+ {
++ struct ath9k_platform_data *pdata = sc->dev->platform_data;
+ char led_name[32];
+ const char *trigger;
++ int i;
+
+ INIT_LIST_HEAD(&sc->leds);
+
+@@ -120,6 +141,12 @@ void ath_init_leds(struct ath_softc *sc)
+ trigger = ieee80211_get_radio_led_name(sc->hw);
+
+ ath_create_gpio_led(sc, sc->sc_ah->led_pin, led_name, trigger, 1);
++
++ if (!pdata)
++ return;
++
++ for (i = 0; i < pdata->num_leds; i++)
++ ath_create_platform_led(sc, &pdata->leds[i]);
+ }
+
+ void ath_fill_led_pin(struct ath_softc *sc)
diff --git a/package/mac80211/patches/.svn/text-base/540-mac80211_optimize_mcs_rate_mask.patch.svn-base b/package/mac80211/patches/.svn/text-base/540-mac80211_optimize_mcs_rate_mask.patch.svn-base
new file mode 100644
index 0000000..347c920
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/540-mac80211_optimize_mcs_rate_mask.patch.svn-base
@@ -0,0 +1,98 @@
+--- a/net/mac80211/ieee80211_i.h
++++ b/net/mac80211/ieee80211_i.h
+@@ -739,6 +739,8 @@ struct ieee80211_sub_if_data {
+
+ /* bitmap of allowed (non-MCS) rate indexes for rate control */
+ u32 rc_rateidx_mask[IEEE80211_NUM_BANDS];
++
++ bool rc_has_mcs_mask[IEEE80211_NUM_BANDS];
+ u8 rc_rateidx_mcs_mask[IEEE80211_NUM_BANDS][IEEE80211_HT_MCS_MASK_LEN];
+
+ union {
+--- a/net/mac80211/cfg.c
++++ b/net/mac80211/cfg.c
+@@ -2386,9 +2386,20 @@ static int ieee80211_set_bitrate_mask(st
+ }
+
+ for (i = 0; i < IEEE80211_NUM_BANDS; i++) {
++ struct ieee80211_supported_band *sband = wiphy->bands[i];
++
+ sdata->rc_rateidx_mask[i] = mask->control[i].legacy;
+ memcpy(sdata->rc_rateidx_mcs_mask[i], mask->control[i].mcs,
+ sizeof(mask->control[i].mcs));
++
++ sdata->rc_has_mcs_mask[i] = false;
++ if (!sband)
++ continue;
++
++ if (memcmp(sdata->rc_rateidx_mcs_mask[i],
++ sband->ht_cap.mcs.rx_mask,
++ sizeof(sband->ht_cap.mcs.rx_mask)) != 0)
++ sdata->rc_has_mcs_mask[i] = true;
+ }
+
+ return 0;
+--- a/include/net/mac80211.h
++++ b/include/net/mac80211.h
+@@ -4091,7 +4091,7 @@ void ieee80211_send_bar(struct ieee80211
+ * (deprecated; this will be removed once drivers get updated to use
+ * rate_idx_mask)
+ * @rate_idx_mask: user-requested (legacy) rate mask
+- * @rate_idx_mcs_mask: user-requested MCS rate mask
++ * @rate_idx_mcs_mask: user-requested MCS rate mask (NULL if not in use)
+ * @bss: whether this frame is sent out in AP or IBSS mode
+ */
+ struct ieee80211_tx_rate_control {
+@@ -4103,7 +4103,7 @@ struct ieee80211_tx_rate_control {
+ bool rts, short_preamble;
+ u8 max_rate_idx;
+ u32 rate_idx_mask;
+- u8 rate_idx_mcs_mask[IEEE80211_HT_MCS_MASK_LEN];
++ u8 *rate_idx_mcs_mask;
+ bool bss;
+ };
+
+--- a/net/mac80211/tx.c
++++ b/net/mac80211/tx.c
+@@ -641,9 +641,11 @@ ieee80211_tx_h_rate_ctrl(struct ieee8021
+ txrc.max_rate_idx = -1;
+ else
+ txrc.max_rate_idx = fls(txrc.rate_idx_mask) - 1;
+- memcpy(txrc.rate_idx_mcs_mask,
+- tx->sdata->rc_rateidx_mcs_mask[info->band],
+- sizeof(txrc.rate_idx_mcs_mask));
++
++ if (tx->sdata->rc_has_mcs_mask[info->band])
++ txrc.rate_idx_mcs_mask =
++ tx->sdata->rc_rateidx_mcs_mask[info->band];
++
+ txrc.bss = (tx->sdata->vif.type == NL80211_IFTYPE_AP ||
+ tx->sdata->vif.type == NL80211_IFTYPE_MESH_POINT ||
+ tx->sdata->vif.type == NL80211_IFTYPE_ADHOC);
+@@ -2511,8 +2513,6 @@ struct sk_buff *ieee80211_beacon_get_tim
+ txrc.max_rate_idx = -1;
+ else
+ txrc.max_rate_idx = fls(txrc.rate_idx_mask) - 1;
+- memcpy(txrc.rate_idx_mcs_mask, sdata->rc_rateidx_mcs_mask[band],
+- sizeof(txrc.rate_idx_mcs_mask));
+ txrc.bss = true;
+ rate_control_get_rate(sdata, NULL, &txrc);
+
+--- a/net/mac80211/rate.c
++++ b/net/mac80211/rate.c
+@@ -460,9 +460,12 @@ void rate_control_get_rate(struct ieee80
+ * the common case.
+ */
+ mask = sdata->rc_rateidx_mask[info->band];
+- memcpy(mcs_mask, sdata->rc_rateidx_mcs_mask[info->band],
+- sizeof(mcs_mask));
+- if (mask != (1 << txrc->sband->n_bitrates) - 1) {
++ if (mask != (1 << txrc->sband->n_bitrates) - 1 || txrc->rate_idx_mcs_mask) {
++ if (txrc->rate_idx_mcs_mask)
++ memcpy(mcs_mask, txrc->rate_idx_mcs_mask, sizeof(mcs_mask));
++ else
++ memset(mcs_mask, 0xff, sizeof(mcs_mask));
++
+ if (sta) {
+ /* Filter out rates that the STA does not support */
+ mask &= sta->sta.supp_rates[info->band];
diff --git a/package/mac80211/patches/.svn/text-base/541-ath9k_optimize_interrupt_mitigation.patch.svn-base b/package/mac80211/patches/.svn/text-base/541-ath9k_optimize_interrupt_mitigation.patch.svn-base
new file mode 100644
index 0000000..95ceb35
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/541-ath9k_optimize_interrupt_mitigation.patch.svn-base
@@ -0,0 +1,30 @@
+--- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
++++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
+@@ -241,21 +241,19 @@ static bool ar9003_hw_get_isr(struct ath
+
+ *masked = isr & ATH9K_INT_COMMON;
+
+- if (ah->config.rx_intr_mitigation)
++ if (ah->config.rx_intr_mitigation) {
+ if (isr & (AR_ISR_RXMINTR | AR_ISR_RXINTM))
+ *masked |= ATH9K_INT_RXLP;
+-
+- if (ah->config.tx_intr_mitigation)
+- if (isr & (AR_ISR_TXMINTR | AR_ISR_TXINTM))
+- *masked |= ATH9K_INT_TX;
+-
+- if (isr & (AR_ISR_LP_RXOK | AR_ISR_RXERR))
++ } else if (isr & (AR_ISR_LP_RXOK | AR_ISR_RXERR))
+ *masked |= ATH9K_INT_RXLP;
+
+ if (isr & AR_ISR_HP_RXOK)
+ *masked |= ATH9K_INT_RXHP;
+
+- if (isr & (AR_ISR_TXOK | AR_ISR_TXERR | AR_ISR_TXEOL)) {
++ if (ah->config.tx_intr_mitigation) {
++ if (isr & (AR_ISR_TXMINTR | AR_ISR_TXINTM))
++ *masked |= ATH9K_INT_TX;
++ } else if (isr & (AR_ISR_TXOK | AR_ISR_TXERR | AR_ISR_TXEOL)) {
+ *masked |= ATH9K_INT_TX;
+
+ if (!(pCap->hw_caps & ATH9K_HW_CAP_RAC_SUPPORTED)) {
diff --git a/package/mac80211/patches/.svn/text-base/550-ath9k_reduce_ani_interval.patch.svn-base b/package/mac80211/patches/.svn/text-base/550-ath9k_reduce_ani_interval.patch.svn-base
new file mode 100644
index 0000000..e2a0d12
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/550-ath9k_reduce_ani_interval.patch.svn-base
@@ -0,0 +1,11 @@
+--- a/drivers/net/wireless/ath/ath9k/ani.h
++++ b/drivers/net/wireless/ath/ath9k/ani.h
+@@ -51,7 +51,7 @@
+ #define ATH9K_ANI_PERIOD 300
+
+ /* in ms */
+-#define ATH9K_ANI_POLLINTERVAL 1000
++#define ATH9K_ANI_POLLINTERVAL 100
+
+ #define HAL_NOISE_IMMUNE_MAX 4
+ #define HAL_SPUR_IMMUNE_MAX 7
diff --git a/package/mac80211/patches/.svn/text-base/551-ath9k_revert_initval_change.patch.svn-base b/package/mac80211/patches/.svn/text-base/551-ath9k_revert_initval_change.patch.svn-base
new file mode 100644
index 0000000..ffb08bf
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/551-ath9k_revert_initval_change.patch.svn-base
@@ -0,0 +1,19 @@
+--- a/drivers/net/wireless/ath/ath9k/ar9003_2p2_initvals.h
++++ b/drivers/net/wireless/ath/ath9k/ar9003_2p2_initvals.h
+@@ -958,11 +958,11 @@ static const u32 ar9300Common_rx_gain_ta
+ {0x0000a074, 0x00000000},
+ {0x0000a078, 0x00000000},
+ {0x0000a07c, 0x00000000},
+- {0x0000a080, 0x1a1a1a1a},
+- {0x0000a084, 0x1a1a1a1a},
+- {0x0000a088, 0x1a1a1a1a},
+- {0x0000a08c, 0x1a1a1a1a},
+- {0x0000a090, 0x171a1a1a},
++ {0x0000a080, 0x22222229},
++ {0x0000a084, 0x1d1d1d1d},
++ {0x0000a088, 0x1d1d1d1d},
++ {0x0000a08c, 0x1d1d1d1d},
++ {0x0000a090, 0x171d1d1d},
+ {0x0000a094, 0x11111717},
+ {0x0000a098, 0x00030311},
+ {0x0000a09c, 0x00000000},
diff --git a/package/mac80211/patches/.svn/text-base/552-ath9k_rx_dma_stop_check.patch.svn-base b/package/mac80211/patches/.svn/text-base/552-ath9k_rx_dma_stop_check.patch.svn-base
new file mode 100644
index 0000000..1da7207
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/552-ath9k_rx_dma_stop_check.patch.svn-base
@@ -0,0 +1,28 @@
+--- a/drivers/net/wireless/ath/ath9k/mac.c
++++ b/drivers/net/wireless/ath/ath9k/mac.c
+@@ -689,7 +689,7 @@ bool ath9k_hw_stopdmarecv(struct ath_hw
+ {
+ #define AH_RX_STOP_DMA_TIMEOUT 10000 /* usec */
+ struct ath_common *common = ath9k_hw_common(ah);
+- u32 mac_status, last_mac_status = 0;
++ u32 mac_status = 0, last_mac_status = 0;
+ int i;
+
+ /* Enable access to the DMA observation bus */
+@@ -719,6 +719,16 @@ bool ath9k_hw_stopdmarecv(struct ath_hw
+ }
+
+ if (i == 0) {
++ if (!AR_SREV_9300_20_OR_LATER(ah) &&
++ (mac_status & 0x700) == 0) {
++ /*
++ * DMA is idle but the MAC is still stuck
++ * processing events
++ */
++ *reset = true;
++ return true;
++ }
++
+ ath_err(common,
+ "DMA failed to stop in %d ms AR_CR=0x%08x AR_DIAG_SW=0x%08x DMADBG_7=0x%08x\n",
+ AH_RX_STOP_DMA_TIMEOUT / 1000,
diff --git a/package/mac80211/patches/.svn/text-base/553-ath9k_debugfs_diag.patch.svn-base b/package/mac80211/patches/.svn/text-base/553-ath9k_debugfs_diag.patch.svn-base
new file mode 100644
index 0000000..915f30f
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/553-ath9k_debugfs_diag.patch.svn-base
@@ -0,0 +1,139 @@
+--- a/drivers/net/wireless/ath/ath9k/debug.c
++++ b/drivers/net/wireless/ath/ath9k/debug.c
+@@ -2149,6 +2149,50 @@ static const struct file_operations fops
+ };
+
+
++static ssize_t read_file_diag(struct file *file, char __user *user_buf,
++ size_t count, loff_t *ppos)
++{
++ struct ath_softc *sc = file->private_data;
++ struct ath_hw *ah = sc->sc_ah;
++ char buf[32];
++ unsigned int len;
++
++ len = sprintf(buf, "0x%08lx\n", ah->diag);
++ return simple_read_from_buffer(user_buf, count, ppos, buf, len);
++}
++
++static ssize_t write_file_diag(struct file *file, const char __user *user_buf,
++ size_t count, loff_t *ppos)
++{
++ struct ath_softc *sc = file->private_data;
++ struct ath_hw *ah = sc->sc_ah;
++ unsigned long diag;
++ char buf[32];
++ ssize_t len;
++
++ len = min(count, sizeof(buf) - 1);
++ if (copy_from_user(buf, user_buf, len))
++ return -EFAULT;
++
++ buf[len] = '\0';
++ if (strict_strtoul(buf, 0, &diag))
++ return -EINVAL;
++
++ ah->diag = diag;
++ ath9k_hw_update_diag(ah);
++
++ return count;
++}
++
++static const struct file_operations fops_diag = {
++ .read = read_file_diag,
++ .write = write_file_diag,
++ .open = simple_open,
++ .owner = THIS_MODULE,
++ .llseek = default_llseek,
++};
++
++
+ int ath9k_init_debug(struct ath_hw *ah)
+ {
+ struct ath_common *common = ath9k_hw_common(ah);
+@@ -2174,6 +2218,8 @@ int ath9k_init_debug(struct ath_hw *ah)
+ debugfs_create_file("gpio_led", S_IWUSR,
+ sc->debug.debugfs_phy, sc, &fops_gpio_led);
+ #endif
++ debugfs_create_file("diag", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
++ sc, &fops_diag);
+ debugfs_create_file("dma", S_IRUSR, sc->debug.debugfs_phy, sc,
+ &fops_dma);
+ debugfs_create_file("interrupt", S_IRUSR, sc->debug.debugfs_phy, sc,
+--- a/drivers/net/wireless/ath/ath9k/hw.h
++++ b/drivers/net/wireless/ath/ath9k/hw.h
+@@ -500,6 +500,12 @@ enum {
+ ATH9K_RESET_COLD,
+ };
+
++enum {
++ ATH_DIAG_DISABLE_RX,
++ ATH_DIAG_DISABLE_TX,
++ ATH_DIAG_TRIGGER_ERROR,
++};
++
+ struct ath9k_hw_version {
+ u32 magic;
+ u16 devid;
+@@ -778,6 +784,8 @@ struct ath_hw {
+ u32 rfkill_polarity;
+ u32 ah_flags;
+
++ unsigned long diag;
++
+ bool reset_power_on;
+ bool htc_reset_init;
+
+@@ -1041,6 +1049,7 @@ void ath9k_hw_set_sta_beacon_timers(stru
+ bool ath9k_hw_check_alive(struct ath_hw *ah);
+
+ bool ath9k_hw_setpower(struct ath_hw *ah, enum ath9k_power_mode mode);
++void ath9k_hw_update_diag(struct ath_hw *ah);
+
+ #ifdef CONFIG_ATH9K_DEBUGFS
+ void ath9k_debug_sync_cause(struct ath_common *common, u32 sync_cause);
+--- a/drivers/net/wireless/ath/ath9k/hw.c
++++ b/drivers/net/wireless/ath/ath9k/hw.c
+@@ -1747,6 +1747,20 @@ fail:
+ return -EINVAL;
+ }
+
++void ath9k_hw_update_diag(struct ath_hw *ah)
++{
++ if (test_bit(ATH_DIAG_DISABLE_RX, &ah->diag))
++ REG_SET_BIT(ah, AR_DIAG_SW, AR_DIAG_RX_DIS);
++ else
++ REG_CLR_BIT(ah, AR_DIAG_SW, AR_DIAG_RX_DIS);
++
++ if (test_bit(ATH_DIAG_DISABLE_TX, &ah->diag))
++ REG_SET_BIT(ah, AR_DIAG_SW, AR_DIAG_LOOP_BACK);
++ else
++ REG_CLR_BIT(ah, AR_DIAG_SW, AR_DIAG_LOOP_BACK);
++}
++EXPORT_SYMBOL(ath9k_hw_update_diag);
++
+ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
+ struct ath9k_hw_cal_data *caldata, bool fastcc)
+ {
+@@ -2024,6 +2038,7 @@ int ath9k_hw_reset(struct ath_hw *ah, st
+ }
+
+ ath9k_hw_apply_gpio_override(ah);
++ ath9k_hw_update_diag(ah);
+
+ if (AR_SREV_9565(ah) && ah->shared_chain_lnadiv)
+ REG_SET_BIT(ah, AR_BTCOEX_WL_LNADIV, AR_BTCOEX_WL_LNADIV_FORCE_ON);
+--- a/drivers/net/wireless/ath/ath9k/main.c
++++ b/drivers/net/wireless/ath/ath9k/main.c
+@@ -459,6 +459,11 @@ irqreturn_t ath_isr(int irq, void *dev)
+ ath9k_hw_getisr(ah, &status); /* NB: clears ISR too */
+ status &= ah->imask; /* discard unasked-for bits */
+
++ if (test_bit(ATH_DIAG_TRIGGER_ERROR, &ah->diag)) {
++ status |= ATH9K_INT_FATAL;
++ clear_bit(ATH_DIAG_TRIGGER_ERROR, &ah->diag);
++ }
++
+ /*
+ * If there are no status bits set, then this interrupt was not
+ * for me (should have been caught above).
diff --git a/package/mac80211/patches/.svn/text-base/554-ath9k_ani_mrc_fix.patch.svn-base b/package/mac80211/patches/.svn/text-base/554-ath9k_ani_mrc_fix.patch.svn-base
new file mode 100644
index 0000000..6edc8ef
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/554-ath9k_ani_mrc_fix.patch.svn-base
@@ -0,0 +1,13 @@
+--- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c
++++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
+@@ -1075,6 +1075,10 @@ static bool ar9003_hw_ani_control(struct
+ * is_on == 0 means MRC CCK is OFF (more noise imm)
+ */
+ bool is_on = param ? 1 : 0;
++
++ if (ah->caps.rx_chainmask == 1)
++ break;
++
+ REG_RMW_FIELD(ah, AR_PHY_MRC_CCK_CTRL,
+ AR_PHY_MRC_CCK_ENABLE, is_on);
+ REG_RMW_FIELD(ah, AR_PHY_MRC_CCK_CTRL,
diff --git a/package/mac80211/patches/.svn/text-base/555-ath9k-allow-to-disable-bands-via-platform-data.patch.svn-base b/package/mac80211/patches/.svn/text-base/555-ath9k-allow-to-disable-bands-via-platform-data.patch.svn-base
new file mode 100644
index 0000000..515bb8f
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/555-ath9k-allow-to-disable-bands-via-platform-data.patch.svn-base
@@ -0,0 +1,70 @@
+--- a/include/linux/ath9k_platform.h
++++ b/include/linux/ath9k_platform.h
+@@ -33,6 +33,9 @@ struct ath9k_platform_data {
+
+ bool endian_check;
+ bool is_clk_25mhz;
++ bool disable_2ghz;
++ bool disable_5ghz;
++
+ int (*get_mac_revision)(void);
+ int (*external_reset)(void);
+
+--- a/drivers/net/wireless/ath/ath9k/hw.c
++++ b/drivers/net/wireless/ath/ath9k/hw.c
+@@ -2414,17 +2414,25 @@ int ath9k_hw_fill_cap_info(struct ath_hw
+ }
+
+ eeval = ah->eep_ops->get_eeprom(ah, EEP_OP_MODE);
+- if ((eeval & (AR5416_OPFLAGS_11G | AR5416_OPFLAGS_11A)) == 0) {
+- ath_err(common,
+- "no band has been marked as supported in EEPROM\n");
+- return -EINVAL;
++
++ if (eeval & AR5416_OPFLAGS_11A) {
++ if (ah->disable_5ghz)
++ ath_warn(common, "disabling 5GHz band\n");
++ else
++ pCap->hw_caps |= ATH9K_HW_CAP_5GHZ;
+ }
+
+- if (eeval & AR5416_OPFLAGS_11A)
+- pCap->hw_caps |= ATH9K_HW_CAP_5GHZ;
++ if (eeval & AR5416_OPFLAGS_11G) {
++ if (ah->disable_2ghz)
++ ath_warn(common, "disabling 2GHz band\n");
++ else
++ pCap->hw_caps |= ATH9K_HW_CAP_2GHZ;
++ }
+
+- if (eeval & AR5416_OPFLAGS_11G)
+- pCap->hw_caps |= ATH9K_HW_CAP_2GHZ;
++ if ((pCap->hw_caps & (ATH9K_HW_CAP_2GHZ | ATH9K_HW_CAP_5GHZ)) == 0) {
++ ath_err(common, "both bands are disabled\n");
++ return -EINVAL;
++ }
+
+ if (AR_SREV_9485(ah) ||
+ AR_SREV_9285(ah) ||
+--- a/drivers/net/wireless/ath/ath9k/hw.h
++++ b/drivers/net/wireless/ath/ath9k/hw.h
+@@ -961,6 +961,8 @@ struct ath_hw {
+ bool is_clk_25mhz;
+ int (*get_mac_revision)(void);
+ int (*external_reset)(void);
++ bool disable_2ghz;
++ bool disable_5ghz;
+
+ const struct firmware *eeprom_blob;
+ };
+--- a/drivers/net/wireless/ath/ath9k/init.c
++++ b/drivers/net/wireless/ath/ath9k/init.c
+@@ -587,6 +587,8 @@ static int ath9k_init_softc(u16 devid, s
+ ah->is_clk_25mhz = pdata->is_clk_25mhz;
+ ah->get_mac_revision = pdata->get_mac_revision;
+ ah->external_reset = pdata->external_reset;
++ ah->disable_2ghz = pdata->disable_2ghz;
++ ah->disable_5ghz = pdata->disable_5ghz;
+ if (!pdata->endian_check)
+ ah->ah_flags |= AH_NO_EEP_SWAP;
+ }
diff --git a/package/mac80211/patches/.svn/text-base/600-rt2x00-disable-pci-code-if-CONFIG_PCI-not-defined.patch.svn-base b/package/mac80211/patches/.svn/text-base/600-rt2x00-disable-pci-code-if-CONFIG_PCI-not-defined.patch.svn-base
new file mode 100644
index 0000000..a7609ed
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/600-rt2x00-disable-pci-code-if-CONFIG_PCI-not-defined.patch.svn-base
@@ -0,0 +1,18 @@
+--- a/drivers/net/wireless/rt2x00/rt2x00pci.c
++++ b/drivers/net/wireless/rt2x00/rt2x00pci.c
+@@ -208,6 +208,7 @@ void rt2x00pci_uninitialize(struct rt2x0
+ }
+ EXPORT_SYMBOL_GPL(rt2x00pci_uninitialize);
+
++#ifdef CONFIG_PCI
+ /*
+ * PCI driver handlers.
+ */
+@@ -392,6 +393,7 @@ int rt2x00pci_resume(struct pci_dev *pci
+ }
+ EXPORT_SYMBOL_GPL(rt2x00pci_resume);
+ #endif /* CONFIG_PM */
++#endif /* CONFIG_PCI */
+
+ /*
+ * rt2x00pci module information.
diff --git a/package/mac80211/patches/.svn/text-base/601-rt2x00-set_pci_mwi.patch.svn-base b/package/mac80211/patches/.svn/text-base/601-rt2x00-set_pci_mwi.patch.svn-base
new file mode 100644
index 0000000..9ff50b7
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/601-rt2x00-set_pci_mwi.patch.svn-base
@@ -0,0 +1,13 @@
+--- a/drivers/net/wireless/rt2x00/rt2x00pci.c
++++ b/drivers/net/wireless/rt2x00/rt2x00pci.c
+@@ -273,8 +273,10 @@ int rt2x00pci_probe(struct pci_dev *pci_
+
+ pci_set_master(pci_dev);
+
++#ifdef CONFIG_PCI_SET_MWI
+ if (pci_set_mwi(pci_dev))
+ ERROR_PROBE("MWI not available.\n");
++#endif
+
+ if (dma_set_mask(&pci_dev->dev, DMA_BIT_MASK(32))) {
+ ERROR_PROBE("PCI DMA not supported.\n");
diff --git a/package/mac80211/patches/.svn/text-base/602-rt2x00-introduce-rt2x00_platform_h.patch.svn-base b/package/mac80211/patches/.svn/text-base/602-rt2x00-introduce-rt2x00_platform_h.patch.svn-base
new file mode 100644
index 0000000..6c80c3d
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/602-rt2x00-introduce-rt2x00_platform_h.patch.svn-base
@@ -0,0 +1,32 @@
+--- /dev/null
++++ b/include/linux/rt2x00_platform.h
+@@ -0,0 +1,19 @@
++/*
++ * Platform data definition for the rt2x00 driver
++ *
++ * Copyright (C) 2011 Gabor Juhos <juhosg@openwrt.org>
++ *
++ * This program is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License version 2 as published
++ * by the Free Software Foundation.
++ *
++ */
++
++#ifndef _RT2X00_PLATFORM_H
++#define _RT2X00_PLATFORM_H
++
++struct rt2x00_platform_data {
++ char *eeprom_file_name;
++};
++
++#endif /* _RT2X00_PLATFORM_H */
+--- a/drivers/net/wireless/rt2x00/rt2x00.h
++++ b/drivers/net/wireless/rt2x00/rt2x00.h
+@@ -39,6 +39,7 @@
+ #include <linux/input-polldev.h>
+ #include <linux/kfifo.h>
+ #include <linux/hrtimer.h>
++#include <linux/rt2x00_platform.h>
+
+ #include <net/mac80211.h>
+
diff --git a/package/mac80211/patches/.svn/text-base/603-rt2x00-introduce-rt2x00eeprom.patch.svn-base b/package/mac80211/patches/.svn/text-base/603-rt2x00-introduce-rt2x00eeprom.patch.svn-base
new file mode 100644
index 0000000..6b1f030
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/603-rt2x00-introduce-rt2x00eeprom.patch.svn-base
@@ -0,0 +1,279 @@
+--- /dev/null
++++ b/drivers/net/wireless/rt2x00/rt2x00eeprom.c
+@@ -0,0 +1,98 @@
++/*
++ Copyright (C) 2004 - 2009 Ivo van Doorn <IvDoorn@gmail.com>
++ Copyright (C) 2004 - 2009 Gertjan van Wingerde <gwingerde@gmail.com>
++ <http://rt2x00.serialmonkey.com>
++
++ 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 of the License, 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; if not, write to the
++ Free Software Foundation, Inc.,
++ 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
++ */
++
++/*
++ Module: rt2x00lib
++ Abstract: rt2x00 eeprom file loading routines.
++ */
++
++#include <linux/kernel.h>
++#include <linux/module.h>
++
++#include "rt2x00.h"
++#include "rt2x00lib.h"
++
++static int rt2x00lib_request_eeprom_file(struct rt2x00_dev *rt2x00dev)
++{
++ const struct firmware *ee;
++ char *ee_name;
++ int retval;
++
++ ee_name = rt2x00dev->ops->lib->get_eeprom_file_name(rt2x00dev);
++ if (!ee_name) {
++ ERROR(rt2x00dev,
++ "Invalid EEPROM filename.\n"
++ "Please file bug report to %s.\n", DRV_PROJECT);
++ return -EINVAL;
++ }
++
++ INFO(rt2x00dev, "Loading EEPROM data from '%s'.\n", ee_name);
++
++ retval = request_firmware(&ee, ee_name, rt2x00dev->dev);
++ if (retval) {
++ ERROR(rt2x00dev, "Failed to request EEPROM.\n");
++ return retval;
++ }
++
++ if (!ee || !ee->size || !ee->data) {
++ ERROR(rt2x00dev, "Failed to read EEPROM file.\n");
++ retval = -ENOENT;
++ goto err_exit;
++ }
++
++ if (ee->size != rt2x00dev->ops->eeprom_size) {
++ ERROR(rt2x00dev,
++ "EEPROM file size is invalid, it should be %d bytes\n",
++ rt2x00dev->ops->eeprom_size);
++ retval = -EINVAL;
++ goto err_release_ee;
++ }
++
++ rt2x00dev->eeprom_file = ee;
++ return 0;
++
++err_release_ee:
++ release_firmware(ee);
++err_exit:
++ return retval;
++}
++
++int rt2x00lib_load_eeprom_file(struct rt2x00_dev *rt2x00dev)
++{
++ int retval;
++
++ if (!test_bit(REQUIRE_EEPROM_FILE, &rt2x00dev->cap_flags))
++ return 0;
++
++ if (!rt2x00dev->eeprom_file) {
++ retval = rt2x00lib_request_eeprom_file(rt2x00dev);
++ if (retval)
++ return retval;
++ }
++
++ return 0;
++}
++
++void rt2x00lib_free_eeprom_file(struct rt2x00_dev *rt2x00dev)
++{
++ release_firmware(rt2x00dev->eeprom_file);
++ rt2x00dev->eeprom_file = NULL;
++}
+--- a/drivers/net/wireless/rt2x00/rt2x00.h
++++ b/drivers/net/wireless/rt2x00/rt2x00.h
+@@ -559,6 +559,7 @@ struct rt2x00lib_ops {
+ const u8 *data, const size_t len);
+ int (*load_firmware) (struct rt2x00_dev *rt2x00dev,
+ const u8 *data, const size_t len);
++ char *(*get_eeprom_file_name) (struct rt2x00_dev *rt2x00dev);
+
+ /*
+ * Device initialization/deinitialization handlers.
+@@ -719,6 +720,7 @@ enum rt2x00_capability_flags {
+ REQUIRE_SW_SEQNO,
+ REQUIRE_HT_TX_DESC,
+ REQUIRE_PS_AUTOWAKE,
++ REQUIRE_EEPROM_FILE,
+
+ /*
+ * Capabilities
+@@ -988,6 +990,11 @@ struct rt2x00_dev {
+ const struct firmware *fw;
+
+ /*
++ * EEPROM image.
++ */
++ const struct firmware *eeprom_file;
++
++ /*
+ * FIFO for storing tx status reports between isr and tasklet.
+ */
+ DECLARE_KFIFO_PTR(txstatus_fifo, u32);
+--- a/drivers/net/wireless/rt2x00/rt2x00lib.h
++++ b/drivers/net/wireless/rt2x00/rt2x00lib.h
+@@ -322,6 +322,22 @@ static inline void rt2x00lib_free_firmwa
+ #endif /* CONFIG_RT2X00_LIB_FIRMWARE */
+
+ /*
++ * EEPROM file handlers.
++ */
++#ifdef CONFIG_RT2X00_LIB_EEPROM
++int rt2x00lib_load_eeprom_file(struct rt2x00_dev *rt2x00dev);
++void rt2x00lib_free_eeprom_file(struct rt2x00_dev *rt2x00dev);
++#else
++static inline int rt2x00lib_load_eeprom_file(struct rt2x00_dev *rt2x00dev)
++{
++ return 0;
++}
++static inline void rt2x00lib_free_eeprom_file(struct rt2x00_dev *rt2x00dev)
++{
++}
++#endif /* CONFIG_RT2X00_LIB_EEPROM_FILE */
++
++/*
+ * Debugfs handlers.
+ */
+ #ifdef CONFIG_RT2X00_LIB_DEBUGFS
+--- a/drivers/net/wireless/rt2x00/Kconfig
++++ b/drivers/net/wireless/rt2x00/Kconfig
+@@ -60,6 +60,7 @@ config RT2800PCI
+ select RT2X00_LIB_PCI if PCI
+ select RT2X00_LIB_SOC if RALINK_RT288X || RALINK_RT305X
+ select RT2X00_LIB_FIRMWARE
++ select RT2X00_LIB_EEPROM
+ select RT2X00_LIB_CRYPTO
+ select CRC_CCITT
+ select EEPROM_93CX6
+@@ -212,6 +213,9 @@ config RT2X00_LIB_FIRMWARE
+ config RT2X00_LIB_CRYPTO
+ boolean
+
++config RT2X00_LIB_EEPROM
++ boolean
++
+ config RT2X00_LIB_LEDS
+ boolean
+ default y if (RT2X00_LIB=y && LEDS_CLASS=y) || (RT2X00_LIB=m && LEDS_CLASS!=n)
+--- a/drivers/net/wireless/rt2x00/Makefile
++++ b/drivers/net/wireless/rt2x00/Makefile
+@@ -7,6 +7,7 @@ rt2x00lib-$(CONFIG_RT2X00_LIB_DEBUGFS) +
+ rt2x00lib-$(CONFIG_RT2X00_LIB_CRYPTO) += rt2x00crypto.o
+ rt2x00lib-$(CONFIG_RT2X00_LIB_FIRMWARE) += rt2x00firmware.o
+ rt2x00lib-$(CONFIG_RT2X00_LIB_LEDS) += rt2x00leds.o
++rt2x00lib-$(CONFIG_RT2X00_LIB_EEPROM) += rt2x00eeprom.o
+
+ obj-$(CONFIG_RT2X00_LIB) += rt2x00lib.o
+ obj-$(CONFIG_RT2X00_LIB_PCI) += rt2x00pci.o
+--- a/drivers/net/wireless/rt2x00/rt2800pci.c
++++ b/drivers/net/wireless/rt2x00/rt2800pci.c
+@@ -89,25 +89,11 @@ static void rt2800pci_mcu_status(struct
+ rt2x00pci_register_write(rt2x00dev, H2M_MAILBOX_CID, ~0);
+ }
+
+-#if defined(CONFIG_RALINK_RT288X) || defined(CONFIG_RALINK_RT305X)
+ static int rt2800pci_read_eeprom_soc(struct rt2x00_dev *rt2x00dev)
+ {
+- void __iomem *base_addr = ioremap(0x1F040000, EEPROM_SIZE);
+-
+- if (!base_addr)
+- return -ENOMEM;
+-
+- memcpy_fromio(rt2x00dev->eeprom, base_addr, EEPROM_SIZE);
+-
+- iounmap(base_addr);
++ memcpy(rt2x00dev->eeprom, rt2x00dev->eeprom_file->data, EEPROM_SIZE);
+ return 0;
+ }
+-#else
+-static inline int rt2800pci_read_eeprom_soc(struct rt2x00_dev *rt2x00dev)
+-{
+- return -ENOMEM;
+-}
+-#endif /* CONFIG_RALINK_RT288X || CONFIG_RALINK_RT305X */
+
+ #ifdef CONFIG_PCI
+ static void rt2800pci_eepromregister_read(struct eeprom_93cx6 *eeprom)
+@@ -331,6 +317,20 @@ static int rt2800pci_write_firmware(stru
+ }
+
+ /*
++ * EEPROM file functions.
++ */
++static char *rt2800pci_get_eeprom_file_name(struct rt2x00_dev *rt2x00dev)
++{
++ struct rt2x00_platform_data *pdata;
++
++ pdata = rt2x00dev->dev->platform_data;
++ if (pdata)
++ return pdata->eeprom_file_name;
++
++ return NULL;
++}
++
++/*
+ * Initialization functions.
+ */
+ static bool rt2800pci_get_entry_state(struct queue_entry *entry)
+@@ -1046,6 +1046,7 @@ static const struct rt2x00lib_ops rt2800
+ .get_firmware_name = rt2800pci_get_firmware_name,
+ .check_firmware = rt2800_check_firmware,
+ .load_firmware = rt2800_load_firmware,
++ .get_eeprom_file_name = rt2800pci_get_eeprom_file_name,
+ .initialize = rt2x00pci_initialize,
+ .uninitialize = rt2x00pci_uninitialize,
+ .get_entry_state = rt2800pci_get_entry_state,
+--- a/drivers/net/wireless/rt2x00/rt2x00dev.c
++++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
+@@ -1318,6 +1318,10 @@ int rt2x00lib_probe_dev(struct rt2x00_de
+
+ rt2x00dev->hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN;
+
++ retval = rt2x00lib_load_eeprom_file(rt2x00dev);
++ if (retval)
++ goto exit;
++
+ /*
+ * Initialize work.
+ */
+@@ -1442,6 +1446,11 @@ void rt2x00lib_remove_dev(struct rt2x00_
+ */
+ if (rt2x00dev->drv_data)
+ kfree(rt2x00dev->drv_data);
++
++ /*
++ * Free EEPROM image.
++ */
++ rt2x00lib_free_eeprom_file(rt2x00dev);
+ }
+ EXPORT_SYMBOL_GPL(rt2x00lib_remove_dev);
+
+--- a/drivers/net/wireless/rt2x00/rt2x00soc.c
++++ b/drivers/net/wireless/rt2x00/rt2x00soc.c
+@@ -94,6 +94,7 @@ int rt2x00soc_probe(struct platform_devi
+ rt2x00dev->hw = hw;
+ rt2x00dev->irq = platform_get_irq(pdev, 0);
+ rt2x00dev->name = pdev->dev.driver->name;
++ set_bit(REQUIRE_EEPROM_FILE, &rt2x00dev->cap_flags);
+
+ rt2x00_set_chip_intf(rt2x00dev, RT2X00_CHIP_INTF_SOC);
+
diff --git a/package/mac80211/patches/.svn/text-base/604-rt2x00-add-CONFIG_RT2X00_LIB_EEPROM-option.patch.svn-base b/package/mac80211/patches/.svn/text-base/604-rt2x00-add-CONFIG_RT2X00_LIB_EEPROM-option.patch.svn-base
new file mode 100644
index 0000000..d9f1764
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/604-rt2x00-add-CONFIG_RT2X00_LIB_EEPROM-option.patch.svn-base
@@ -0,0 +1,10 @@
+--- a/config.mk
++++ b/config.mk
+@@ -640,6 +640,7 @@ export CONFIG_RT2X00=y
+ export CONFIG_RT2X00_LIB=m
+ export CONFIG_RT2800_LIB=m
+ export CONFIG_RT2X00_LIB_FIRMWARE=y
++export CONFIG_RT2X00_LIB_EEPROM=y
+ export CONFIG_RT2X00_LIB_CRYPTO=y
+ # export CONFIG_RT2X00_LIB_SOC=y
+ ifdef CONFIG_COMPAT_KERNEL_2_6_25
diff --git a/package/mac80211/patches/.svn/text-base/605-rt2x00-pci-eeprom.patch.svn-base b/package/mac80211/patches/.svn/text-base/605-rt2x00-pci-eeprom.patch.svn-base
new file mode 100644
index 0000000..25b21ce
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/605-rt2x00-pci-eeprom.patch.svn-base
@@ -0,0 +1,46 @@
+--- a/drivers/net/wireless/rt2x00/rt2800pci.c
++++ b/drivers/net/wireless/rt2x00/rt2800pci.c
+@@ -89,7 +89,7 @@ static void rt2800pci_mcu_status(struct
+ rt2x00pci_register_write(rt2x00dev, H2M_MAILBOX_CID, ~0);
+ }
+
+-static int rt2800pci_read_eeprom_soc(struct rt2x00_dev *rt2x00dev)
++static int rt2800pci_read_eeprom_file(struct rt2x00_dev *rt2x00dev)
+ {
+ memcpy(rt2x00dev->eeprom, rt2x00dev->eeprom_file->data, EEPROM_SIZE);
+ return 0;
+@@ -983,8 +983,9 @@ static int rt2800pci_read_eeprom(struct
+ {
+ int retval;
+
+- if (rt2x00_is_soc(rt2x00dev))
+- retval = rt2800pci_read_eeprom_soc(rt2x00dev);
++ if (rt2x00_is_soc(rt2x00dev) ||
++ test_bit(REQUIRE_EEPROM_FILE, &rt2x00dev->cap_flags))
++ retval = rt2800pci_read_eeprom_file(rt2x00dev);
+ else if (rt2800pci_efuse_detect(rt2x00dev))
+ retval = rt2800pci_read_eeprom_efuse(rt2x00dev);
+ else
+--- a/drivers/net/wireless/rt2x00/rt2x00pci.c
++++ b/drivers/net/wireless/rt2x00/rt2x00pci.c
+@@ -255,6 +255,7 @@ exit:
+ int rt2x00pci_probe(struct pci_dev *pci_dev, const struct rt2x00_ops *ops)
+ {
+ struct ieee80211_hw *hw;
++ struct rt2x00_platform_data *pdata;
+ struct rt2x00_dev *rt2x00dev;
+ int retval;
+ u16 chip;
+@@ -300,6 +301,12 @@ int rt2x00pci_probe(struct pci_dev *pci_
+ rt2x00dev->irq = pci_dev->irq;
+ rt2x00dev->name = pci_name(pci_dev);
+
++ /* if we get passed the name of a eeprom_file_name, then use this in
++ favour of the eeprom */
++ pdata = rt2x00dev->dev->platform_data;
++ if (pdata && pdata->eeprom_file_name)
++ set_bit(REQUIRE_EEPROM_FILE, &rt2x00dev->cap_flags);
++
+ if (pci_is_pcie(pci_dev))
+ rt2x00_set_chip_intf(rt2x00dev, RT2X00_CHIP_INTF_PCIE);
+ else
diff --git a/package/mac80211/patches/.svn/text-base/606-rt2x00_no_realign.patch.svn-base b/package/mac80211/patches/.svn/text-base/606-rt2x00_no_realign.patch.svn-base
new file mode 100644
index 0000000..2025701
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/606-rt2x00_no_realign.patch.svn-base
@@ -0,0 +1,67 @@
+[RFC] rt2x00: For drivers that only need L2 padding don't realign frames
+
+Signed-off-by: Helmut Schaa <helmut.schaa@...>
+---
+
+Ivo, Gertjan, do you remeber by any chance why this alignment stuff was added
+in the first place? Was it because of DMA restrictions?
+
+While doing some profiling on the rt3052 SoC I noticed that 30-40% time was
+spent in memmove calls. And the culprit is the memmove aligning the payload
+to a 4byte boundary since that has to move a whole bunch of data.
+
+Interesstingly the legacy drivers insert an l2pad between the header and the
+payload but doesn't realign the payload itself to a 4-byte boundary. Hence,
+I came up with this patch and indeed CPU usage improves impressively.
+
+Only tested on rt2800pci!
+
+Thanks,
+Helmut
+
+ drivers/net/wireless/rt2x00/rt2x00queue.c | 30 +++-------------------------
+ 1 files changed, 4 insertions(+), 26 deletions(-)
+
+--- a/drivers/net/wireless/rt2x00/rt2x00queue.c
++++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
+@@ -162,36 +162,14 @@ void rt2x00queue_align_frame(struct sk_b
+ void rt2x00queue_insert_l2pad(struct sk_buff *skb, unsigned int header_length)
+ {
+ unsigned int payload_length = skb->len - header_length;
+- unsigned int header_align = ALIGN_SIZE(skb, 0);
+- unsigned int payload_align = ALIGN_SIZE(skb, header_length);
+ unsigned int l2pad = payload_length ? L2PAD_SIZE(header_length) : 0;
+
+- /*
+- * Adjust the header alignment if the payload needs to be moved more
+- * than the header.
+- */
+- if (payload_align > header_align)
+- header_align += 4;
+-
+- /* There is nothing to do if no alignment is needed */
+- if (!header_align)
++ if (!l2pad)
+ return;
+
+- /* Reserve the amount of space needed in front of the frame */
+- skb_push(skb, header_align);
+-
+- /*
+- * Move the header.
+- */
+- memmove(skb->data, skb->data + header_align, header_length);
+-
+- /* Move the payload, if present and if required */
+- if (payload_length && payload_align)
+- memmove(skb->data + header_length + l2pad,
+- skb->data + header_length + l2pad + payload_align,
+- payload_length);
+-
+- /* Trim the skb to the correct size */
++ /* insert l2pad -> Move header */
++ skb_push(skb, l2pad);
++ memmove(skb->data, skb->data + l2pad, header_length);
+ skb_trim(skb, header_length + l2pad + payload_length);
+ }
+
diff --git a/package/mac80211/patches/.svn/text-base/607-rt2x00-allow_disabling_bands_through_platform_data.patch.svn-base b/package/mac80211/patches/.svn/text-base/607-rt2x00-allow_disabling_bands_through_platform_data.patch.svn-base
new file mode 100644
index 0000000..0b0c30e
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/607-rt2x00-allow_disabling_bands_through_platform_data.patch.svn-base
@@ -0,0 +1,47 @@
+--- a/include/linux/rt2x00_platform.h
++++ b/include/linux/rt2x00_platform.h
+@@ -14,6 +14,9 @@
+
+ struct rt2x00_platform_data {
+ char *eeprom_file_name;
++
++ int disable_2ghz;
++ int disable_5ghz;
+ };
+
+ #endif /* _RT2X00_PLATFORM_H */
+--- a/drivers/net/wireless/rt2x00/rt2x00dev.c
++++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
+@@ -939,6 +939,22 @@ static int rt2x00lib_probe_hw_modes(stru
+ unsigned int num_rates;
+ unsigned int i;
+
++ if (rt2x00dev->dev->platform_data) {
++ struct rt2x00_platform_data *pdata;
++
++ pdata = rt2x00dev->dev->platform_data;
++ if (pdata->disable_2ghz)
++ spec->supported_bands &= ~SUPPORT_BAND_2GHZ;
++ if (pdata->disable_5ghz)
++ spec->supported_bands &= ~SUPPORT_BAND_5GHZ;
++ }
++
++ if ((spec->supported_bands & SUPPORT_BAND_BOTH) == 0) {
++ ERROR(rt2x00dev, "No supported bands\n");
++ return -EINVAL;
++ }
++
++
+ num_rates = 0;
+ if (spec->supported_rates & SUPPORT_RATE_CCK)
+ num_rates += 4;
+--- a/drivers/net/wireless/rt2x00/rt2x00.h
++++ b/drivers/net/wireless/rt2x00/rt2x00.h
+@@ -424,6 +424,7 @@ struct hw_mode_spec {
+ unsigned int supported_bands;
+ #define SUPPORT_BAND_2GHZ 0x00000001
+ #define SUPPORT_BAND_5GHZ 0x00000002
++#define SUPPORT_BAND_BOTH (SUPPORT_BAND_2GHZ | SUPPORT_BAND_5GHZ)
+
+ unsigned int supported_rates;
+ #define SUPPORT_RATE_CCK 0x00000001
diff --git a/package/mac80211/patches/.svn/text-base/608-add_platform_data_mac_addr.patch.svn-base b/package/mac80211/patches/.svn/text-base/608-add_platform_data_mac_addr.patch.svn-base
new file mode 100644
index 0000000..bb77df9
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/608-add_platform_data_mac_addr.patch.svn-base
@@ -0,0 +1,63 @@
+--- a/include/linux/rt2x00_platform.h
++++ b/include/linux/rt2x00_platform.h
+@@ -14,6 +14,7 @@
+
+ struct rt2x00_platform_data {
+ char *eeprom_file_name;
++ const u8 *mac_address;
+
+ int disable_2ghz;
+ int disable_5ghz;
+--- a/drivers/net/wireless/rt2x00/rt2x00dev.c
++++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
+@@ -930,6 +930,18 @@ static void rt2x00lib_rate(struct ieee80
+ entry->flags |= IEEE80211_RATE_SHORT_PREAMBLE;
+ }
+
++const u8 *rt2x00lib_get_mac_address(struct rt2x00_dev *rt2x00dev)
++{
++ struct rt2x00_platform_data *pdata;
++
++ pdata = rt2x00dev->dev->platform_data;
++ if (!pdata)
++ return NULL;
++
++ return pdata->mac_address;
++}
++EXPORT_SYMBOL_GPL(rt2x00lib_get_mac_address);
++
+ static int rt2x00lib_probe_hw_modes(struct rt2x00_dev *rt2x00dev,
+ struct hw_mode_spec *spec)
+ {
+--- a/drivers/net/wireless/rt2x00/rt2x00.h
++++ b/drivers/net/wireless/rt2x00/rt2x00.h
+@@ -1314,6 +1314,7 @@ static inline void rt2x00debug_dump_fram
+ */
+ u32 rt2x00lib_get_bssidx(struct rt2x00_dev *rt2x00dev,
+ struct ieee80211_vif *vif);
++const u8 *rt2x00lib_get_mac_address(struct rt2x00_dev *rt2x00dev);
+
+ /*
+ * Interrupt context handlers.
+--- a/drivers/net/wireless/rt2x00/rt61pci.c
++++ b/drivers/net/wireless/rt2x00/rt61pci.c
+@@ -2392,6 +2392,7 @@ static int rt61pci_validate_eeprom(struc
+ u32 reg;
+ u16 word;
+ u8 *mac;
++ const u8 *pdata_mac;
+ s8 value;
+
+ rt2x00pci_register_read(rt2x00dev, E2PROM_CSR, &reg);
+@@ -2412,7 +2413,11 @@ static int rt61pci_validate_eeprom(struc
+ /*
+ * Start validation of the data that has been read.
+ */
++ pdata_mac = rt2x00lib_get_mac_address(rt2x00dev);
+ mac = rt2x00_eeprom_addr(rt2x00dev, EEPROM_MAC_ADDR_0);
++ if (pdata_mac)
++ memcpy(mac, pdata_mac, 6);
++
+ if (!is_valid_ether_addr(mac)) {
+ eth_random_addr(mac);
+ EEPROM(rt2x00dev, "MAC: %pM\n", mac);
diff --git a/package/mac80211/patches/.svn/text-base/610-rt2x00-fix-rt3352-ext-pa.patch.svn-base b/package/mac80211/patches/.svn/text-base/610-rt2x00-fix-rt3352-ext-pa.patch.svn-base
new file mode 100644
index 0000000..bf070e6
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/610-rt2x00-fix-rt3352-ext-pa.patch.svn-base
@@ -0,0 +1,214 @@
+--- a/drivers/net/wireless/rt2x00/rt2800lib.c
++++ b/drivers/net/wireless/rt2x00/rt2800lib.c
+@@ -2249,15 +2249,18 @@ static void rt2800_config_channel(struct
+ /*
+ * Change BBP settings
+ */
++ rt2800_bbp_write(rt2x00dev, 62, 0x37 - rt2x00dev->lna_gain);
++ rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain);
++ rt2800_bbp_write(rt2x00dev, 64, 0x37 - rt2x00dev->lna_gain);
++
+ if (rt2x00_rt(rt2x00dev, RT3352)) {
+ rt2800_bbp_write(rt2x00dev, 27, 0x0);
+ rt2800_bbp_write(rt2x00dev, 66, 0x26 + rt2x00dev->lna_gain);
+ rt2800_bbp_write(rt2x00dev, 27, 0x20);
+ rt2800_bbp_write(rt2x00dev, 66, 0x26 + rt2x00dev->lna_gain);
++ rt2800_bbp_write(rt2x00dev, 86, 0x38);
++ rt2800_bbp_write(rt2x00dev, 83, 0x6a);
+ } else {
+- rt2800_bbp_write(rt2x00dev, 62, 0x37 - rt2x00dev->lna_gain);
+- rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain);
+- rt2800_bbp_write(rt2x00dev, 64, 0x37 - rt2x00dev->lna_gain);
+ rt2800_bbp_write(rt2x00dev, 86, 0);
+ }
+
+@@ -3670,6 +3673,7 @@ static int rt2800_init_bbp(struct rt2x00
+ rt2800_bbp_write(rt2x00dev, 120, 0x50);
+
+ if (rt2x00_rt(rt2x00dev, RT3290) ||
++ rt2x00_rt(rt2x00dev, RT3352) ||
+ rt2x00_rt(rt2x00dev, RT5390) ||
+ rt2x00_rt(rt2x00dev, RT5392))
+ rt2800_bbp_write(rt2x00dev, 128, 0x12);
+@@ -3976,6 +3980,12 @@ static void rt2800_init_rfcsr_3290(struc
+
+ static void rt2800_init_rfcsr_3352(struct rt2x00_dev *rt2x00dev)
+ {
++ int tx0_int_pa = test_bit(CAPABILITY_INTERNAL_PA_TX0,
++ &rt2x00dev->cap_flags);
++ int tx1_int_pa = test_bit(CAPABILITY_INTERNAL_PA_TX1,
++ &rt2x00dev->cap_flags);
++ u8 rfcsr;
++
+ rt2800_rfcsr_write(rt2x00dev, 0, 0xf0);
+ rt2800_rfcsr_write(rt2x00dev, 1, 0x23);
+ rt2800_rfcsr_write(rt2x00dev, 2, 0x50);
+@@ -4009,15 +4019,30 @@ static void rt2800_init_rfcsr_3352(struc
+ rt2800_rfcsr_write(rt2x00dev, 31, 0x80);
+ rt2800_rfcsr_write(rt2x00dev, 32, 0x80);
+ rt2800_rfcsr_write(rt2x00dev, 33, 0x00);
+- rt2800_rfcsr_write(rt2x00dev, 34, 0x01);
++ rfcsr = 0x01;
++ if (!tx0_int_pa)
++ rt2x00_set_field8(&rfcsr, RFCSR34_TX0_EXT_PA, 1);
++ if (!tx1_int_pa)
++ rt2x00_set_field8(&rfcsr, RFCSR34_TX1_EXT_PA, 1);
++ rt2800_rfcsr_write(rt2x00dev, 34, rfcsr );
+ rt2800_rfcsr_write(rt2x00dev, 35, 0x03);
+ rt2800_rfcsr_write(rt2x00dev, 36, 0xbd);
+ rt2800_rfcsr_write(rt2x00dev, 37, 0x3c);
+ rt2800_rfcsr_write(rt2x00dev, 38, 0x5f);
+ rt2800_rfcsr_write(rt2x00dev, 39, 0xc5);
+ rt2800_rfcsr_write(rt2x00dev, 40, 0x33);
+- rt2800_rfcsr_write(rt2x00dev, 41, 0x5b);
+- rt2800_rfcsr_write(rt2x00dev, 42, 0x5b);
++ rfcsr = 0x52;
++ if (tx0_int_pa) {
++ rt2x00_set_field8(&rfcsr, RFCSR41_BIT1, 1);
++ rt2x00_set_field8(&rfcsr, RFCSR41_BIT4, 1);
++ }
++ rt2800_rfcsr_write(rt2x00dev, 41, rfcsr);
++ rfcsr = 0x52;
++ if (tx1_int_pa) {
++ rt2x00_set_field8(&rfcsr, RFCSR42_BIT1, 1);
++ rt2x00_set_field8(&rfcsr, RFCSR42_BIT4, 1);
++ }
++ rt2800_rfcsr_write(rt2x00dev, 42, rfcsr);
+ rt2800_rfcsr_write(rt2x00dev, 43, 0xdb);
+ rt2800_rfcsr_write(rt2x00dev, 44, 0xdb);
+ rt2800_rfcsr_write(rt2x00dev, 45, 0xdb);
+@@ -4025,15 +4050,20 @@ static void rt2800_init_rfcsr_3352(struc
+ rt2800_rfcsr_write(rt2x00dev, 47, 0x0d);
+ rt2800_rfcsr_write(rt2x00dev, 48, 0x14);
+ rt2800_rfcsr_write(rt2x00dev, 49, 0x00);
+- rt2800_rfcsr_write(rt2x00dev, 50, 0x2d);
+- rt2800_rfcsr_write(rt2x00dev, 51, 0x7f);
+- rt2800_rfcsr_write(rt2x00dev, 52, 0x00);
+- rt2800_rfcsr_write(rt2x00dev, 53, 0x52);
+- rt2800_rfcsr_write(rt2x00dev, 54, 0x1b);
+- rt2800_rfcsr_write(rt2x00dev, 55, 0x7f);
+- rt2800_rfcsr_write(rt2x00dev, 56, 0x00);
+- rt2800_rfcsr_write(rt2x00dev, 57, 0x52);
+- rt2800_rfcsr_write(rt2x00dev, 58, 0x1b);
++ rfcsr = 0x2d;
++ if (!tx0_int_pa)
++ rt2x00_set_field8(&rfcsr, RFCSR50_TX0_EXT_PA, 1);
++ if (!tx1_int_pa)
++ rt2x00_set_field8(&rfcsr, RFCSR50_TX1_EXT_PA, 1);
++ rt2800_rfcsr_write(rt2x00dev, 50, rfcsr);
++ rt2800_rfcsr_write(rt2x00dev, 51, (tx0_int_pa ? 0x7f : 0x52));
++ rt2800_rfcsr_write(rt2x00dev, 52, (tx0_int_pa ? 0x00 : 0xc0));
++ rt2800_rfcsr_write(rt2x00dev, 53, (tx0_int_pa ? 0x52 : 0xd2));
++ rt2800_rfcsr_write(rt2x00dev, 54, (tx0_int_pa ? 0x1b : 0xc0));
++ rt2800_rfcsr_write(rt2x00dev, 55, (tx1_int_pa ? 0x7f : 0x52));
++ rt2800_rfcsr_write(rt2x00dev, 56, (tx1_int_pa ? 0x00 : 0xc0));
++ rt2800_rfcsr_write(rt2x00dev, 57, (tx0_int_pa ? 0x52 : 0x49));
++ rt2800_rfcsr_write(rt2x00dev, 58, (tx1_int_pa ? 0x1b : 0xc0));
+ rt2800_rfcsr_write(rt2x00dev, 59, 0x00);
+ rt2800_rfcsr_write(rt2x00dev, 60, 0x00);
+ rt2800_rfcsr_write(rt2x00dev, 61, 0x00);
+@@ -4949,7 +4979,8 @@ static int rt2800_init_eeprom(struct rt2
+ /*
+ * Detect if this device has Bluetooth co-existence.
+ */
+- if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF1_BT_COEXIST))
++ if (!rt2x00_rt(rt2x00dev, RT3352) &&
++ rt2x00_get_field16(eeprom, EEPROM_NIC_CONF1_BT_COEXIST))
+ __set_bit(CAPABILITY_BT_COEXIST, &rt2x00dev->cap_flags);
+
+ /*
+@@ -4978,6 +5009,22 @@ static int rt2800_init_eeprom(struct rt2
+ EIRP_MAX_TX_POWER_LIMIT)
+ __set_bit(CAPABILITY_POWER_LIMIT, &rt2x00dev->cap_flags);
+
++ /*
++ * Detect if device uses internal or external PA
++ */
++ rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &eeprom);
++
++ if (rt2x00_rt(rt2x00dev, RT3352)) {
++ if (!rt2x00_get_field16(eeprom,
++ EEPROM_NIC_CONF1_EXTERNAL_TX0_PA_3352))
++ __set_bit(CAPABILITY_INTERNAL_PA_TX0,
++ &rt2x00dev->cap_flags);
++ if (!rt2x00_get_field16(eeprom,
++ EEPROM_NIC_CONF1_EXTERNAL_TX1_PA_3352))
++ __set_bit(CAPABILITY_INTERNAL_PA_TX1,
++ &rt2x00dev->cap_flags);
++ }
++
+ return 0;
+ }
+
+--- a/drivers/net/wireless/rt2x00/rt2800.h
++++ b/drivers/net/wireless/rt2x00/rt2800.h
+@@ -2117,6 +2117,12 @@ struct mac_iveiv_entry {
+ #define RFCSR31_RX_CALIB FIELD8(0x7f)
+
+ /*
++ * RFCSR 34:
++ */
++#define RFCSR34_TX0_EXT_PA FIELD8(0x04)
++#define RFCSR34_TX1_EXT_PA FIELD8(0x08)
++
++/*
+ * RFCSR 38:
+ */
+ #define RFCSR38_RX_LO1_EN FIELD8(0x20)
+@@ -2127,6 +2133,18 @@ struct mac_iveiv_entry {
+ #define RFCSR39_RX_LO2_EN FIELD8(0x80)
+
+ /*
++ * RFCSR 41:
++ */
++#define RFCSR41_BIT1 FIELD8(0x01)
++#define RFCSR41_BIT4 FIELD8(0x08)
++
++/*
++ * RFCSR 42:
++ */
++#define RFCSR42_BIT1 FIELD8(0x01)
++#define RFCSR42_BIT4 FIELD8(0x08)
++
++/*
+ * RFCSR 49:
+ */
+ #define RFCSR49_TX FIELD8(0x3f)
+@@ -2135,6 +2153,8 @@ struct mac_iveiv_entry {
+ * RFCSR 50:
+ */
+ #define RFCSR50_TX FIELD8(0x3f)
++#define RFCSR50_TX0_EXT_PA FIELD8(0x02)
++#define RFCSR50_TX1_EXT_PA FIELD8(0x10)
+
+ /*
+ * RF registers
+@@ -2222,6 +2242,8 @@ struct mac_iveiv_entry {
+ * INTERNAL_TX_ALC: 0: disable, 1: enable
+ * BT_COEXIST: 0: disable, 1: enable
+ * DAC_TEST: 0: disable, 1: enable
++ * EXTERNAL_TX0_PA: 0: disable, 1: enable (only on RT3352)
++ * EXTERNAL_TX1_PA: 0: disable, 1: enable (only on RT3352)
+ */
+ #define EEPROM_NIC_CONF1 0x001b
+ #define EEPROM_NIC_CONF1_HW_RADIO FIELD16(0x0001)
+@@ -2239,6 +2261,8 @@ struct mac_iveiv_entry {
+ #define EEPROM_NIC_CONF1_INTERNAL_TX_ALC FIELD16(0x2000)
+ #define EEPROM_NIC_CONF1_BT_COEXIST FIELD16(0x4000)
+ #define EEPROM_NIC_CONF1_DAC_TEST FIELD16(0x8000)
++#define EEPROM_NIC_CONF1_EXTERNAL_TX0_PA_3352 FIELD16(0x4000)
++#define EEPROM_NIC_CONF1_EXTERNAL_TX1_PA_3352 FIELD16(0x8000)
+
+ /*
+ * EEPROM frequency
+--- a/drivers/net/wireless/rt2x00/rt2x00.h
++++ b/drivers/net/wireless/rt2x00/rt2x00.h
+@@ -740,6 +740,8 @@ enum rt2x00_capability_flags {
+ CAPABILITY_DOUBLE_ANTENNA,
+ CAPABILITY_BT_COEXIST,
+ CAPABILITY_VCO_RECALIBRATION,
++ CAPABILITY_INTERNAL_PA_TX0,
++ CAPABILITY_INTERNAL_PA_TX1,
+ };
+
+ /*
diff --git a/package/mac80211/patches/.svn/text-base/611-rt2x00-rf_vals-rt3352-xtal20.patch.svn-base b/package/mac80211/patches/.svn/text-base/611-rt2x00-rf_vals-rt3352-xtal20.patch.svn-base
new file mode 100644
index 0000000..38b56b4
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/611-rt2x00-rf_vals-rt3352-xtal20.patch.svn-base
@@ -0,0 +1,115 @@
+--- a/drivers/net/wireless/rt2x00/rt2800lib.c
++++ b/drivers/net/wireless/rt2x00/rt2800lib.c
+@@ -5169,6 +5169,27 @@ static const struct rf_channel rf_vals_3
+ {173, 0x61, 0, 9},
+ };
+
++/*
++ * RF value list for rt3xxx with Xtal20MHz
++ * Supports: 2.4 GHz (all) (RF3322)
++ */
++static const struct rf_channel rf_vals_xtal20mhz_3x[] = {
++ {1, 0xE2, 2, 0x14},
++ {2, 0xE3, 2, 0x14},
++ {3, 0xE4, 2, 0x14},
++ {4, 0xE5, 2, 0x14},
++ {5, 0xE6, 2, 0x14},
++ {6, 0xE7, 2, 0x14},
++ {7, 0xE8, 2, 0x14},
++ {8, 0xE9, 2, 0x14},
++ {9, 0xEA, 2, 0x14},
++ {10, 0xEB, 2, 0x14},
++ {11, 0xEC, 2, 0x14},
++ {12, 0xED, 2, 0x14},
++ {13, 0xEE, 2, 0x14},
++ {14, 0xF0, 2, 0x18},
++};
++
+ static int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
+ {
+ struct hw_mode_spec *spec = &rt2x00dev->spec;
+@@ -5246,7 +5267,6 @@ static int rt2800_probe_hw_mode(struct r
+ rt2x00_rf(rt2x00dev, RF3022) ||
+ rt2x00_rf(rt2x00dev, RF3290) ||
+ rt2x00_rf(rt2x00dev, RF3320) ||
+- rt2x00_rf(rt2x00dev, RF3322) ||
+ rt2x00_rf(rt2x00dev, RF5360) ||
+ rt2x00_rf(rt2x00dev, RF5370) ||
+ rt2x00_rf(rt2x00dev, RF5372) ||
+@@ -5254,6 +5274,12 @@ static int rt2800_probe_hw_mode(struct r
+ rt2x00_rf(rt2x00dev, RF5392)) {
+ spec->num_channels = 14;
+ spec->channels = rf_vals_3x;
++ } else if (rt2x00_rf(rt2x00dev, RF3322)) {
++ spec->num_channels = 14;
++ if (spec->clk_is_20mhz)
++ spec->channels = rf_vals_xtal20mhz_3x;
++ else
++ spec->channels = rf_vals_3x;
+ } else if (rt2x00_rf(rt2x00dev, RF3052)) {
+ spec->supported_bands |= SUPPORT_BAND_5GHZ;
+ spec->num_channels = ARRAY_SIZE(rf_vals_3x);
+@@ -5347,6 +5373,19 @@ static int rt2800_probe_hw_mode(struct r
+ return 0;
+ }
+
++int rt2800_probe_clk(struct rt2x00_dev *rt2x00dev)
++{
++ struct rt2x00_platform_data *pdata = rt2x00dev->dev->platform_data;
++ struct hw_mode_spec *spec = &rt2x00dev->spec;
++
++ if (!pdata)
++ return -EINVAL;
++
++ spec->clk_is_20mhz = pdata->clk_is_20mhz;
++
++ return 0;
++}
++
+ int rt2800_probe_hw(struct rt2x00_dev *rt2x00dev)
+ {
+ int retval;
+@@ -5372,6 +5411,15 @@ int rt2800_probe_hw(struct rt2x00_dev *r
+ rt2800_register_write(rt2x00dev, GPIO_CTRL, reg);
+
+ /*
++ * Probe SoC clock.
++ */
++ if (rt2x00_is_soc(rt2x00dev)) {
++ retval = rt2800_probe_clk(rt2x00dev);
++ if (retval)
++ return retval;
++ }
++
++ /*
+ * Initialize hw specifications.
+ */
+ retval = rt2800_probe_hw_mode(rt2x00dev);
+--- a/drivers/net/wireless/rt2x00/rt2x00.h
++++ b/drivers/net/wireless/rt2x00/rt2x00.h
+@@ -419,6 +419,7 @@ static inline struct rt2x00_intf* vif_to
+ * @channels: Device/chipset specific channel values (See &struct rf_channel).
+ * @channels_info: Additional information for channels (See &struct channel_info).
+ * @ht: Driver HT Capabilities (See &ieee80211_sta_ht_cap).
++ * @clk_is_20mhz: External crystal of WiSoC is 20MHz instead of 40MHz
+ */
+ struct hw_mode_spec {
+ unsigned int supported_bands;
+@@ -435,6 +436,7 @@ struct hw_mode_spec {
+ const struct channel_info *channels_info;
+
+ struct ieee80211_sta_ht_cap ht;
++ int clk_is_20mhz;
+ };
+
+ /*
+--- a/include/linux/rt2x00_platform.h
++++ b/include/linux/rt2x00_platform.h
+@@ -18,6 +18,7 @@ struct rt2x00_platform_data {
+
+ int disable_2ghz;
+ int disable_5ghz;
++ int clk_is_20mhz;
+ };
+
+ #endif /* _RT2X00_PLATFORM_H */
diff --git a/package/mac80211/patches/.svn/text-base/700-mwl8k-missing-pci-id-for-WNR854T.patch.svn-base b/package/mac80211/patches/.svn/text-base/700-mwl8k-missing-pci-id-for-WNR854T.patch.svn-base
new file mode 100644
index 0000000..80fde27
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/700-mwl8k-missing-pci-id-for-WNR854T.patch.svn-base
@@ -0,0 +1,10 @@
+--- a/drivers/net/wireless/mwl8k.c
++++ b/drivers/net/wireless/mwl8k.c
+@@ -5497,6 +5497,7 @@ MODULE_FIRMWARE("mwl8k/fmimage_8366.fw")
+ MODULE_FIRMWARE(MWL8K_8366_AP_FW(MWL8K_8366_AP_FW_API));
+
+ static DEFINE_PCI_DEVICE_TABLE(mwl8k_pci_id_table) = {
++ { PCI_VDEVICE(MARVELL, 0x2a02), .driver_data = MWL8363, },
+ { PCI_VDEVICE(MARVELL, 0x2a0a), .driver_data = MWL8363, },
+ { PCI_VDEVICE(MARVELL, 0x2a0c), .driver_data = MWL8363, },
+ { PCI_VDEVICE(MARVELL, 0x2a24), .driver_data = MWL8363, },
diff --git a/package/mac80211/patches/.svn/text-base/800-b43-gpio-mask-module-option.patch.svn-base b/package/mac80211/patches/.svn/text-base/800-b43-gpio-mask-module-option.patch.svn-base
new file mode 100644
index 0000000..d8fb06d
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/800-b43-gpio-mask-module-option.patch.svn-base
@@ -0,0 +1,37 @@
+--- a/drivers/net/wireless/b43/b43.h
++++ b/drivers/net/wireless/b43/b43.h
+@@ -812,6 +812,7 @@ struct b43_wldev {
+ bool qos_enabled; /* TRUE, if QoS is used. */
+ bool hwcrypto_enabled; /* TRUE, if HW crypto acceleration is enabled. */
+ bool use_pio; /* TRUE if next init should use PIO */
++ int gpiomask; /* GPIO LED mask as a module parameter */
+
+ /* PHY/Radio device. */
+ struct b43_phy phy;
+--- a/drivers/net/wireless/b43/main.c
++++ b/drivers/net/wireless/b43/main.c
+@@ -76,6 +76,11 @@ MODULE_FIRMWARE("b43/ucode16_mimo.fw");
+ MODULE_FIRMWARE("b43/ucode5.fw");
+ MODULE_FIRMWARE("b43/ucode9.fw");
+
++static int modparam_gpiomask = 0x000F;
++module_param_named(gpiomask, modparam_gpiomask, int, 0444);
++MODULE_PARM_DESC(gpiomask,
++ "GPIO mask for LED control (default 0x000F)");
++
+ static int modparam_bad_frames_preempt;
+ module_param_named(bad_frames_preempt, modparam_bad_frames_preempt, int, 0444);
+ MODULE_PARM_DESC(bad_frames_preempt,
+@@ -2740,10 +2745,10 @@ static int b43_gpio_init(struct b43_wlde
+ u32 mask, set;
+
+ b43_maskset32(dev, B43_MMIO_MACCTL, ~B43_MACCTL_GPOUTSMSK, 0);
+- b43_maskset16(dev, B43_MMIO_GPIO_MASK, ~0, 0xF);
++ b43_maskset16(dev, B43_MMIO_GPIO_MASK, ~0, modparam_gpiomask);
+
+ mask = 0x0000001F;
+- set = 0x0000000F;
++ set = modparam_gpiomask;
+ if (dev->dev->chip_id == 0x4301) {
+ mask |= 0x0060;
+ set |= 0x0060;
diff --git a/package/mac80211/patches/.svn/text-base/810-b43_no_pio.patch.svn-base b/package/mac80211/patches/.svn/text-base/810-b43_no_pio.patch.svn-base
new file mode 100644
index 0000000..5b4c22e
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/810-b43_no_pio.patch.svn-base
@@ -0,0 +1,75 @@
+--- a/drivers/net/wireless/b43/Makefile
++++ b/drivers/net/wireless/b43/Makefile
+@@ -20,7 +20,7 @@ b43-y += xmit.o
+ b43-y += lo.o
+ b43-y += wa.o
+ b43-y += dma.o
+-b43-y += pio.o
++b43-$(CONFIG_B43_PIO) += pio.o
+ b43-y += rfkill.o
+ b43-$(CONFIG_B43_LEDS) += leds.o
+ b43-$(CONFIG_B43_PCMCIA) += pcmcia.o
+--- a/drivers/net/wireless/b43/main.c
++++ b/drivers/net/wireless/b43/main.c
+@@ -1909,10 +1909,12 @@ static void b43_do_interrupt_thread(stru
+ dma_reason[0], dma_reason[1],
+ dma_reason[2], dma_reason[3],
+ dma_reason[4], dma_reason[5]);
++#ifdef CONFIG_B43_PIO
+ b43err(dev->wl, "This device does not support DMA "
+ "on your system. It will now be switched to PIO.\n");
+ /* Fall back to PIO transfers if we get fatal DMA errors! */
+ dev->use_pio = true;
++#endif
+ b43_controller_restart(dev, "DMA error");
+ return;
+ }
+--- a/drivers/net/wireless/b43/pio.h
++++ b/drivers/net/wireless/b43/pio.h
+@@ -150,7 +150,7 @@ static inline void b43_piorx_write32(str
+ b43_write32(q->dev, q->mmio_base + offset, value);
+ }
+
+-
++#ifdef CONFIG_B43_PIO
+ int b43_pio_init(struct b43_wldev *dev);
+ void b43_pio_free(struct b43_wldev *dev);
+
+@@ -161,5 +161,37 @@ void b43_pio_rx(struct b43_pio_rxqueue *
+
+ void b43_pio_tx_suspend(struct b43_wldev *dev);
+ void b43_pio_tx_resume(struct b43_wldev *dev);
++#else
++static inline int b43_pio_init(struct b43_wldev *dev)
++{
++ return 0;
++}
++
++static inline void b43_pio_free(struct b43_wldev *dev)
++{
++}
++
++static inline int b43_pio_tx(struct b43_wldev *dev, struct sk_buff *skb)
++{
++ return 0;
++}
++
++static inline void b43_pio_handle_txstatus(struct b43_wldev *dev,
++ const struct b43_txstatus *status)
++{
++}
++
++static inline void b43_pio_rx(struct b43_pio_rxqueue *q)
++{
++}
++
++static inline void b43_pio_tx_suspend(struct b43_wldev *dev)
++{
++}
++
++static inline void b43_pio_tx_resume(struct b43_wldev *dev)
++{
++}
++#endif /* CONFIG_B43_PIO */
+
+ #endif /* B43_PIO_H_ */
diff --git a/package/mac80211/patches/.svn/text-base/820-b43-add-antenna-control.patch.svn-base b/package/mac80211/patches/.svn/text-base/820-b43-add-antenna-control.patch.svn-base
new file mode 100644
index 0000000..8b6255f
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/820-b43-add-antenna-control.patch.svn-base
@@ -0,0 +1,131 @@
+--- a/drivers/net/wireless/b43/main.c
++++ b/drivers/net/wireless/b43/main.c
+@@ -1553,7 +1553,7 @@ static void b43_write_beacon_template(st
+ len, ram_offset, shm_size_offset, rate);
+
+ /* Write the PHY TX control parameters. */
+- antenna = B43_ANTENNA_DEFAULT;
++ antenna = dev->tx_antenna;
+ antenna = b43_antenna_to_phyctl(antenna);
+ ctl = b43_shm_read16(dev, B43_SHM_SHARED, B43_SHM_SH_BEACPHYCTL);
+ /* We can't send beacons with short preamble. Would get PHY errors. */
+@@ -3101,8 +3101,8 @@ static int b43_chip_init(struct b43_wlde
+
+ /* Select the antennae */
+ if (phy->ops->set_rx_antenna)
+- phy->ops->set_rx_antenna(dev, B43_ANTENNA_DEFAULT);
+- b43_mgmtframe_txantenna(dev, B43_ANTENNA_DEFAULT);
++ phy->ops->set_rx_antenna(dev, dev->rx_antenna);
++ b43_mgmtframe_txantenna(dev, dev->tx_antenna);
+
+ if (phy->type == B43_PHYTYPE_B) {
+ value16 = b43_read16(dev, 0x005E);
+@@ -3846,7 +3846,6 @@ static int b43_op_config(struct ieee8021
+ struct b43_wldev *dev;
+ struct b43_phy *phy;
+ struct ieee80211_conf *conf = &hw->conf;
+- int antenna;
+ int err = 0;
+ bool reload_bss = false;
+
+@@ -3900,11 +3899,9 @@ static int b43_op_config(struct ieee8021
+ }
+
+ /* Antennas for RX and management frame TX. */
+- antenna = B43_ANTENNA_DEFAULT;
+- b43_mgmtframe_txantenna(dev, antenna);
+- antenna = B43_ANTENNA_DEFAULT;
++ b43_mgmtframe_txantenna(dev, dev->tx_antenna);
+ if (phy->ops->set_rx_antenna)
+- phy->ops->set_rx_antenna(dev, antenna);
++ phy->ops->set_rx_antenna(dev, dev->rx_antenna);
+
+ if (wl->radio_enabled != phy->radio_on) {
+ if (wl->radio_enabled) {
+@@ -5030,6 +5027,47 @@ static int b43_op_get_survey(struct ieee
+ return 0;
+ }
+
++static int b43_op_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant)
++{
++ struct b43_wl *wl = hw_to_b43_wl(hw);
++ struct b43_wldev *dev = wl->current_dev;
++
++ if (tx_ant == 1 && rx_ant == 1) {
++ dev->tx_antenna = B43_ANTENNA0;
++ dev->rx_antenna = B43_ANTENNA0;
++ }
++ else if (tx_ant == 2 && rx_ant == 2) {
++ dev->tx_antenna = B43_ANTENNA1;
++ dev->rx_antenna = B43_ANTENNA1;
++ }
++ else if ((tx_ant & 3) == 3 && (rx_ant & 3) == 3) {
++ dev->tx_antenna = B43_ANTENNA_DEFAULT;
++ dev->rx_antenna = B43_ANTENNA_DEFAULT;
++ }
++ else {
++ return -EINVAL;
++ }
++
++ return 0;
++}
++
++
++static int b43_op_get_antenna(struct ieee80211_hw *hw, u32 *tx_ant, u32 *rx_ant)
++{
++ struct b43_wl *wl = hw_to_b43_wl(hw);
++ struct b43_wldev *dev = wl->current_dev;
++
++ switch (dev->tx_antenna) {
++ case B43_ANTENNA0:
++ *tx_ant = 1; *rx_ant = 1; break;
++ case B43_ANTENNA1:
++ *tx_ant = 2; *rx_ant = 2; break;
++ case B43_ANTENNA_DEFAULT:
++ *tx_ant = 3; *rx_ant = 3; break;
++ }
++ return 0;
++}
++
+ static const struct ieee80211_ops b43_hw_ops = {
+ .tx = b43_op_tx,
+ .conf_tx = b43_op_conf_tx,
+@@ -5051,6 +5089,8 @@ static const struct ieee80211_ops b43_hw
+ .sw_scan_complete = b43_op_sw_scan_complete_notifier,
+ .get_survey = b43_op_get_survey,
+ .rfkill_poll = b43_rfkill_poll,
++ .set_antenna = b43_op_set_antenna,
++ .get_antenna = b43_op_get_antenna,
+ };
+
+ /* Hard-reset the chip. Do not call this directly.
+@@ -5297,6 +5337,8 @@ static int b43_one_core_attach(struct b4
+ if (!wldev)
+ goto out;
+
++ wldev->rx_antenna = B43_ANTENNA_DEFAULT;
++ wldev->tx_antenna = B43_ANTENNA_DEFAULT;
+ wldev->use_pio = b43_modparam_pio;
+ wldev->dev = dev;
+ wldev->wl = wl;
+@@ -5387,6 +5429,9 @@ static struct b43_wl *b43_wireless_init(
+
+ hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN;
+
++ hw->wiphy->available_antennas_rx = 0x3;
++ hw->wiphy->available_antennas_tx = 0x3;
++
+ wl->hw_registred = false;
+ hw->max_rates = 2;
+ SET_IEEE80211_DEV(hw, dev->dev);
+--- a/drivers/net/wireless/b43/b43.h
++++ b/drivers/net/wireless/b43/b43.h
+@@ -813,6 +813,8 @@ struct b43_wldev {
+ bool hwcrypto_enabled; /* TRUE, if HW crypto acceleration is enabled. */
+ bool use_pio; /* TRUE if next init should use PIO */
+ int gpiomask; /* GPIO LED mask as a module parameter */
++ int rx_antenna; /* Used RX antenna (B43_ANTENNAxxx) */
++ int tx_antenna; /* Used TX antenna (B43_ANTENNAxxx) */
+
+ /* PHY/Radio device. */
+ struct b43_phy phy;
diff --git a/package/mac80211/patches/.svn/text-base/830-b43-workaround-pcie-bcm4716.patch.svn-base b/package/mac80211/patches/.svn/text-base/830-b43-workaround-pcie-bcm4716.patch.svn-base
new file mode 100644
index 0000000..bd10f99
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/830-b43-workaround-pcie-bcm4716.patch.svn-base
@@ -0,0 +1,134 @@
+From 4f214b1ead0af7439921637645cb63f378516175 Mon Sep 17 00:00:00 2001
+From: Hauke Mehrtens <hauke@hauke-m.de>
+Date: Sat, 21 Jan 2012 18:48:38 +0100
+Subject: [PATCH 33/34] b43: add workaround for b43 on pcie bus of bcm4716.
+
+bcm4716 (which includes 4717 & 4718), plus 4706 on PCIe can reorder
+transactions. As a fix, a read after write is performed on certain
+places in the code. Older chips and the newer 5357 family don't require
+this fix.
+This code is based on the brcmsmac driver.
+
+Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
+---
+ drivers/net/wireless/b43/b43.h | 26 ++++++++++++++++++++++++++
+ drivers/net/wireless/b43/bus.h | 10 ++++++++++
+ drivers/net/wireless/b43/phy_common.c | 6 ++++++
+ drivers/net/wireless/b43/phy_n.c | 10 +++++-----
+ 4 files changed, 47 insertions(+), 5 deletions(-)
+
+--- a/drivers/net/wireless/b43/b43.h
++++ b/drivers/net/wireless/b43/b43.h
+@@ -1053,6 +1053,32 @@ static inline bool b43_using_pio_transfe
+ return dev->__using_pio_transfers;
+ }
+
++/*
++ * bcm4716 (which includes 4717 & 4718), plus 4706 on PCIe can reorder
++ * transactions. As a fix, a read after write is performed on certain places
++ * in the code. Older chips and the newer 5357 family don't require this fix.
++ */
++#ifdef CONFIG_BCM47XX_BCMA
++#include <asm/mach-bcm47xx/bcm47xx.h>
++static inline void b43_wflush16(struct b43_wldev *dev, u16 offset, u16 value)
++{
++ if (b43_bus_host_is_pci(dev->dev) &&
++ bcm47xx_bus_type == BCM47XX_BUS_TYPE_BCMA &&
++ (bcm47xx_bus.bcma.bus.chipinfo.id == 0x4716 ||
++ bcm47xx_bus.bcma.bus.chipinfo.id == 0x5300)) {
++ b43_write16(dev, offset, value);
++ b43_read16(dev, offset);
++ } else {
++ b43_write16(dev, offset, value);
++ }
++}
++#else
++static inline void b43_wflush16(struct b43_wldev *dev, u16 offset, u16 value)
++{
++ b43_write16(dev, offset, value);
++}
++#endif
++
+ /* Message printing */
+ __printf(2, 3) void b43info(struct b43_wl *wl, const char *fmt, ...);
+ __printf(2, 3) void b43err(struct b43_wl *wl, const char *fmt, ...);
+--- a/drivers/net/wireless/b43/bus.h
++++ b/drivers/net/wireless/b43/bus.h
+@@ -60,6 +60,16 @@ static inline bool b43_bus_host_is_sdio(
+ return (dev->bus_type == B43_BUS_SSB &&
+ dev->sdev->bus->bustype == SSB_BUSTYPE_SDIO);
+ }
++static inline bool b43_bus_host_is_pci(struct b43_bus_dev *dev)
++{
++ if (dev->bus_type == B43_BUS_SSB)
++ return (dev->sdev->bus->bustype == SSB_BUSTYPE_PCI);
++#ifdef CONFIG_B43_BCMA
++ if (dev->bus_type == B43_BUS_BCMA)
++ return (dev->bdev->bus->hosttype == BCMA_HOSTTYPE_PCI);
++#endif
++ return false;
++}
+
+ struct b43_bus_dev *b43_bus_dev_bcma_init(struct bcma_device *core);
+ struct b43_bus_dev *b43_bus_dev_ssb_init(struct ssb_device *sdev);
+--- a/drivers/net/wireless/b43/phy_common.c
++++ b/drivers/net/wireless/b43/phy_common.c
+@@ -266,6 +266,12 @@ void b43_phy_write(struct b43_wldev *dev
+ {
+ assert_mac_suspended(dev);
+ dev->phy.ops->phy_write(dev, reg, value);
++#ifdef CONFIG_BCM47XX
++ if (b43_bus_host_is_pci(dev->dev) && reg == 0x72) {
++ b43_read16(dev, B43_MMIO_PHY_VER);
++ return;
++ }
++#endif
+ if (++dev->phy.writes_counter == B43_MAX_WRITES_IN_ROW) {
+ b43_read16(dev, B43_MMIO_PHY_VER);
+ dev->phy.writes_counter = 0;
+--- a/drivers/net/wireless/b43/phy_n.c
++++ b/drivers/net/wireless/b43/phy_n.c
+@@ -5423,14 +5423,14 @@ static inline void check_phyreg(struct b
+ static u16 b43_nphy_op_read(struct b43_wldev *dev, u16 reg)
+ {
+ check_phyreg(dev, reg);
+- b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
++ b43_wflush16(dev, B43_MMIO_PHY_CONTROL, reg);
+ return b43_read16(dev, B43_MMIO_PHY_DATA);
+ }
+
+ static void b43_nphy_op_write(struct b43_wldev *dev, u16 reg, u16 value)
+ {
+ check_phyreg(dev, reg);
+- b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
++ b43_wflush16(dev, B43_MMIO_PHY_CONTROL, reg);
+ b43_write16(dev, B43_MMIO_PHY_DATA, value);
+ }
+
+@@ -5438,7 +5438,7 @@ static void b43_nphy_op_maskset(struct b
+ u16 set)
+ {
+ check_phyreg(dev, reg);
+- b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
++ b43_wflush16(dev, B43_MMIO_PHY_CONTROL, reg);
+ b43_maskset16(dev, B43_MMIO_PHY_DATA, mask, set);
+ }
+
+@@ -5449,7 +5449,7 @@ static u16 b43_nphy_op_radio_read(struct
+ /* N-PHY needs 0x100 for read access */
+ reg |= 0x100;
+
+- b43_write16(dev, B43_MMIO_RADIO_CONTROL, reg);
++ b43_wflush16(dev, B43_MMIO_RADIO_CONTROL, reg);
+ return b43_read16(dev, B43_MMIO_RADIO_DATA_LOW);
+ }
+
+@@ -5458,7 +5458,7 @@ static void b43_nphy_op_radio_write(stru
+ /* Register 1 is a 32-bit register. */
+ B43_WARN_ON(reg == 1);
+
+- b43_write16(dev, B43_MMIO_RADIO_CONTROL, reg);
++ b43_wflush16(dev, B43_MMIO_RADIO_CONTROL, reg);
+ b43_write16(dev, B43_MMIO_RADIO_DATA_LOW, value);
+ }
+
diff --git a/package/mac80211/patches/.svn/text-base/840-b43-increase_number_of_rx_dma_slots.patch.svn-base b/package/mac80211/patches/.svn/text-base/840-b43-increase_number_of_rx_dma_slots.patch.svn-base
new file mode 100644
index 0000000..94c6ff2
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/840-b43-increase_number_of_rx_dma_slots.patch.svn-base
@@ -0,0 +1,11 @@
+--- a/drivers/net/wireless/b43/dma.h
++++ b/drivers/net/wireless/b43/dma.h
+@@ -169,7 +169,7 @@ struct b43_dmadesc_generic {
+
+ /* DMA engine tuning knobs */
+ #define B43_TXRING_SLOTS 256
+-#define B43_RXRING_SLOTS 64
++#define B43_RXRING_SLOTS 256
+ #define B43_DMA0_RX_FW598_BUFSIZE (B43_DMA0_RX_FW598_FO + IEEE80211_MAX_FRAME_LEN)
+ #define B43_DMA0_RX_FW351_BUFSIZE (B43_DMA0_RX_FW351_FO + IEEE80211_MAX_FRAME_LEN)
+
diff --git a/package/mac80211/patches/.svn/text-base/850-brcmsmac-start-adding-support-for-core-rev-28.patch.svn-base b/package/mac80211/patches/.svn/text-base/850-brcmsmac-start-adding-support-for-core-rev-28.patch.svn-base
new file mode 100644
index 0000000..41c4476
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/850-brcmsmac-start-adding-support-for-core-rev-28.patch.svn-base
@@ -0,0 +1,75 @@
+--- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
++++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
+@@ -99,6 +99,7 @@ static struct bcma_device_id brcms_corei
+ BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_80211, 17, BCMA_ANY_CLASS),
+ BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_80211, 23, BCMA_ANY_CLASS),
+ BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_80211, 24, BCMA_ANY_CLASS),
++// BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_80211, 28, BCMA_ANY_CLASS),
+ BCMA_CORETABLE_END
+ };
+ MODULE_DEVICE_TABLE(bcma, brcms_coreid_table);
+--- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
++++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
+@@ -717,7 +717,7 @@ static void brcms_c_ucode_bsinit(struct
+ brcms_c_write_mhf(wlc_hw, wlc_hw->band->mhfs);
+
+ /* do band-specific ucode IHR, SHM, and SCR inits */
+- if (D11REV_IS(wlc_hw->corerev, 17) || D11REV_IS(wlc_hw->corerev, 23)) {
++ if (D11REV_IS(wlc_hw->corerev, 17) || D11REV_IS(wlc_hw->corerev, 23) || D11REV_IS(wlc_hw->corerev, 28)) {
+ if (BRCMS_ISNPHY(wlc_hw->band))
+ brcms_c_write_inits(wlc_hw, ucode->d11n0bsinitvals16);
+ else
+@@ -2257,7 +2257,7 @@ static void brcms_ucode_download(struct
+ if (wlc_hw->ucode_loaded)
+ return;
+
+- if (D11REV_IS(wlc_hw->corerev, 17) || D11REV_IS(wlc_hw->corerev, 23)) {
++ if (D11REV_IS(wlc_hw->corerev, 17) || D11REV_IS(wlc_hw->corerev, 23) || D11REV_IS(wlc_hw->corerev, 28)) {
+ if (BRCMS_ISNPHY(wlc_hw->band)) {
+ brcms_ucode_write(wlc_hw, ucode->bcm43xx_16_mimo,
+ ucode->bcm43xx_16_mimosz);
+@@ -3207,7 +3207,7 @@ static void brcms_b_coreinit(struct brcm
+
+ sflags = bcma_aread32(core, BCMA_IOST);
+
+- if (D11REV_IS(wlc_hw->corerev, 17) || D11REV_IS(wlc_hw->corerev, 23)) {
++ if (D11REV_IS(wlc_hw->corerev, 17) || D11REV_IS(wlc_hw->corerev, 23) || D11REV_IS(wlc_hw->corerev, 28)) {
+ if (BRCMS_ISNPHY(wlc_hw->band))
+ brcms_c_write_inits(wlc_hw, ucode->d11n0initvals16);
+ else
+@@ -5663,6 +5663,8 @@ static bool brcms_c_chipmatch_soc(struct
+
+ if (chipinfo->id == BCMA_CHIP_ID_BCM4716)
+ return true;
++ if (chipinfo->id == BCMA_CHIP_ID_BCM5357)
++ return true;
+
+ pr_err("unknown chip id %04x\n", chipinfo->id);
+ return false;
+--- a/drivers/net/wireless/brcm80211/brcmsmac/main.h
++++ b/drivers/net/wireless/brcm80211/brcmsmac/main.h
+@@ -65,7 +65,7 @@
+ #define SW_TIMER_MAC_STAT_UPD 30 /* periodic MAC stats update */
+
+ /* max # supported core revisions (0 .. MAXCOREREV - 1) */
+-#define MAXCOREREV 28
++#define MAXCOREREV 29
+
+ /* Double check that unsupported cores are not enabled */
+ #if CONF_MSK(D11CONF, 0x4f) || CONF_GE(D11CONF, MAXCOREREV)
+--- a/drivers/net/wireless/brcm80211/brcmsmac/types.h
++++ b/drivers/net/wireless/brcm80211/brcmsmac/types.h
+@@ -93,11 +93,11 @@
+ #define BOARD_GPIO_13 0x2000
+
+ /* **** Core type/rev defaults **** */
+-#define D11CONF 0x0fffffb0 /* Supported D11 revs: 4, 5, 7-27
++#define D11CONF 0x1fffffb0 /* Supported D11 revs: 4, 5, 7-27
+ * also need to update wlc.h MAXCOREREV
+ */
+
+-#define NCONF 0x000001ff /* Supported nphy revs:
++#define NCONF 0x000002ff /* Supported nphy revs:
+ * 0 4321a0
+ * 1 4321a1
+ * 2 4321b0/b1/c0/c1
diff --git a/package/mac80211/patches/.svn/text-base/860-brcmsmac-implement-ieee80211_ops-get_tsf-and-set_tsf.patch.svn-base b/package/mac80211/patches/.svn/text-base/860-brcmsmac-implement-ieee80211_ops-get_tsf-and-set_tsf.patch.svn-base
new file mode 100644
index 0000000..33991bc
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/860-brcmsmac-implement-ieee80211_ops-get_tsf-and-set_tsf.patch.svn-base
@@ -0,0 +1,121 @@
+--- a/drivers/net/wireless/brcm80211/brcmsmac/d11.h
++++ b/drivers/net/wireless/brcm80211/brcmsmac/d11.h
+@@ -457,6 +457,7 @@ struct d11regs {
+ /*== maccontrol register ==*/
+ #define MCTL_GMODE (1U << 31)
+ #define MCTL_DISCARD_PMQ (1 << 30)
++#define MCTL_TBTTHOLD (1 << 28)
+ #define MCTL_WAKE (1 << 26)
+ #define MCTL_HPS (1 << 25)
+ #define MCTL_PROMISC (1 << 24)
+--- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
++++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
+@@ -741,6 +741,28 @@ static void brcms_ops_flush(struct ieee8
+ "ret=%d\n", jiffies_to_msecs(ret));
+ }
+
++static u64 brcms_ops_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
++{
++ struct brcms_info *wl = hw->priv;
++ u64 tsf;
++
++ spin_lock_bh(&wl->lock);
++ tsf = brcms_c_tsf_get(wl->wlc);
++ spin_unlock_bh(&wl->lock);
++
++ return tsf;
++}
++
++static void brcms_ops_set_tsf(struct ieee80211_hw *hw,
++ struct ieee80211_vif *vif, u64 tsf)
++{
++ struct brcms_info *wl = hw->priv;
++
++ spin_lock_bh(&wl->lock);
++ brcms_c_tsf_set(wl->wlc, tsf);
++ spin_unlock_bh(&wl->lock);
++}
++
+ static const struct ieee80211_ops brcms_ops = {
+ .tx = brcms_ops_tx,
+ .start = brcms_ops_start,
+@@ -757,6 +779,8 @@ static const struct ieee80211_ops brcms_
+ .ampdu_action = brcms_ops_ampdu_action,
+ .rfkill_poll = brcms_ops_rfkill_poll,
+ .flush = brcms_ops_flush,
++ .get_tsf = brcms_ops_get_tsf,
++ .set_tsf = brcms_ops_set_tsf,
+ };
+
+ void brcms_dpc(unsigned long data)
+--- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
++++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
+@@ -5545,6 +5545,20 @@ int brcms_c_set_rateset(struct brcms_c_i
+ return bcmerror;
+ }
+
++static void brcms_c_time_lock(struct brcms_c_info *wlc)
++{
++ bcma_set32(wlc->hw->d11core, D11REGOFFS(maccontrol), MCTL_TBTTHOLD);
++ /* Commit the write */
++ bcma_read32(wlc->hw->d11core, D11REGOFFS(maccontrol));
++}
++
++static void brcms_c_time_unlock(struct brcms_c_info *wlc)
++{
++ bcma_mask32(wlc->hw->d11core, D11REGOFFS(maccontrol), ~MCTL_TBTTHOLD);
++ /* Commit the write */
++ bcma_read32(wlc->hw->d11core, D11REGOFFS(maccontrol));
++}
++
+ int brcms_c_set_beacon_period(struct brcms_c_info *wlc, u16 period)
+ {
+ if (period == 0)
+@@ -7530,6 +7544,36 @@ void brcms_c_set_beacon_listen_interval(
+ brcms_c_bcn_li_upd(wlc);
+ }
+
++u64 brcms_c_tsf_get(struct brcms_c_info *wlc)
++{
++ u32 tsf_h, tsf_l;
++ u64 tsf;
++
++ brcms_b_read_tsf(wlc->hw, &tsf_l, &tsf_h);
++
++ tsf = tsf_h;
++ tsf <<= 32;
++ tsf |= tsf_l;
++
++ return tsf;
++}
++
++void brcms_c_tsf_set(struct brcms_c_info *wlc, u64 tsf)
++{
++ u32 tsf_h, tsf_l;
++
++ brcms_c_time_lock(wlc);
++
++ tsf_l = tsf;
++ tsf_h = (tsf >> 32);
++
++ /* read the tsf timer low, then high to get an atomic read */
++ bcma_write32(wlc->hw->d11core, D11REGOFFS(tsf_timerlow), tsf_l);
++ bcma_write32(wlc->hw->d11core, D11REGOFFS(tsf_timerhigh), tsf_h);
++
++ brcms_c_time_unlock(wlc);
++}
++
+ int brcms_c_set_tx_power(struct brcms_c_info *wlc, int txpwr)
+ {
+ uint qdbm;
+--- a/drivers/net/wireless/brcm80211/brcmsmac/pub.h
++++ b/drivers/net/wireless/brcm80211/brcmsmac/pub.h
+@@ -326,6 +326,8 @@ extern void brcms_c_set_shortslot_overri
+ s8 sslot_override);
+ extern void brcms_c_set_beacon_listen_interval(struct brcms_c_info *wlc,
+ u8 interval);
++extern u64 brcms_c_tsf_get(struct brcms_c_info *wlc);
++extern void brcms_c_tsf_set(struct brcms_c_info *wlc, u64 tsf);
+ extern int brcms_c_set_tx_power(struct brcms_c_info *wlc, int txpwr);
+ extern int brcms_c_get_tx_power(struct brcms_c_info *wlc);
+ extern bool brcms_c_check_radio_disabled(struct brcms_c_info *wlc);
diff --git a/package/mac80211/patches/.svn/text-base/861-brcmsmac-add-interface-type-to-brcms_bss_cfg.patch.svn-base b/package/mac80211/patches/.svn/text-base/861-brcmsmac-add-interface-type-to-brcms_bss_cfg.patch.svn-base
new file mode 100644
index 0000000..21b1e0e
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/861-brcmsmac-add-interface-type-to-brcms_bss_cfg.patch.svn-base
@@ -0,0 +1,66 @@
+--- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
++++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
+@@ -367,9 +367,10 @@ brcms_ops_add_interface(struct ieee80211
+ }
+
+ spin_lock_bh(&wl->lock);
+- memcpy(wl->pub->cur_etheraddr, vif->addr, sizeof(vif->addr));
+ wl->mute_tx = false;
+ brcms_c_mute(wl->wlc, false);
++ if (vif->type == NL80211_IFTYPE_STATION)
++ brcms_c_start_station(wl->wlc, vif->addr);
+ spin_unlock_bh(&wl->lock);
+
+ return 0;
+--- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
++++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
+@@ -2165,6 +2165,12 @@ void brcms_b_switch_macfreq(struct brcms
+ }
+ }
+
++void brcms_c_start_station(struct brcms_c_info *wlc, u8 *addr)
++{
++ memcpy(wlc->pub->cur_etheraddr, addr, sizeof(wlc->pub->cur_etheraddr));
++ wlc->bsscfg->type = BRCMS_TYPE_STATION;
++}
++
+ /* Initialize GPIOs that are controlled by D11 core */
+ static void brcms_c_gpio_init(struct brcms_c_info *wlc)
+ {
+--- a/drivers/net/wireless/brcm80211/brcmsmac/main.h
++++ b/drivers/net/wireless/brcm80211/brcmsmac/main.h
+@@ -576,10 +576,17 @@ struct antsel_info {
+ struct brcms_antselcfg antcfg_cur; /* current antenna config (auto) */
+ };
+
++enum brcms_bss_type {
++ BRCMS_TYPE_STATION,
++ BRCMS_TYPE_AP,
++ BRCMS_TYPE_ADHOC,
++};
++
+ /*
+ * BSS configuration state
+ *
+ * wlc: wlc to which this bsscfg belongs to.
++ * type: interface type
+ * up: is this configuration up operational
+ * enable: is this configuration enabled
+ * associated: is BSS in ASSOCIATED state
+@@ -599,6 +606,7 @@ struct antsel_info {
+ */
+ struct brcms_bss_cfg {
+ struct brcms_c_info *wlc;
++ enum brcms_bss_type type;
+ bool up;
+ bool enable;
+ bool associated;
+--- a/drivers/net/wireless/brcm80211/brcmsmac/pub.h
++++ b/drivers/net/wireless/brcm80211/brcmsmac/pub.h
+@@ -333,5 +333,6 @@ extern int brcms_c_get_tx_power(struct b
+ extern bool brcms_c_check_radio_disabled(struct brcms_c_info *wlc);
+ extern void brcms_c_mute(struct brcms_c_info *wlc, bool on);
+ extern bool brcms_c_tx_flush_completed(struct brcms_c_info *wlc);
++extern void brcms_c_start_station(struct brcms_c_info *wlc, u8 *addr);
+
+ #endif /* _BRCM_PUB_H_ */
diff --git a/package/mac80211/patches/.svn/text-base/862-brcmsmac-remove-brcms_bss_cfg-BSS.patch.svn-base b/package/mac80211/patches/.svn/text-base/862-brcmsmac-remove-brcms_bss_cfg-BSS.patch.svn-base
new file mode 100644
index 0000000..a7ffcf6
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/862-brcmsmac-remove-brcms_bss_cfg-BSS.patch.svn-base
@@ -0,0 +1,77 @@
+--- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
++++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
+@@ -1071,7 +1071,7 @@ brcms_b_txstatus(struct brcms_hardware *
+
+ static void brcms_c_tbtt(struct brcms_c_info *wlc)
+ {
+- if (!wlc->bsscfg->BSS)
++ if (wlc->bsscfg->type == BRCMS_TYPE_ADHOC)
+ /*
+ * DirFrmQ is now valid...defer setting until end
+ * of ATIM window
+@@ -3061,16 +3061,8 @@ static bool brcms_c_ps_allowed(struct br
+ if (wlc->filter_flags & FIF_PROMISC_IN_BSS)
+ return false;
+
+- if (cfg->associated) {
+- /*
+- * disallow PS when one of the following
+- * bsscfg specific conditions meets
+- */
+- if (!cfg->BSS)
+- return false;
+-
++ if (cfg->associated)
+ return false;
+- }
+
+ return true;
+ }
+@@ -5080,8 +5072,9 @@ int brcms_c_up(struct brcms_c_info *wlc)
+ struct brcms_bss_cfg *bsscfg = wlc->bsscfg;
+ mboolset(wlc->pub->radio_disabled,
+ WL_RADIO_HW_DISABLE);
+-
+- if (bsscfg->enable && bsscfg->BSS)
++ if (bsscfg->enable &&
++ (bsscfg->type == BRCMS_TYPE_STATION ||
++ bsscfg->type == BRCMS_TYPE_ADHOC))
+ brcms_err(wlc->hw->d11core,
+ "wl%d: up: rfdisable -> "
+ "bsscfg_disable()\n",
+@@ -7390,7 +7383,7 @@ void brcms_c_update_beacon(struct brcms_
+ {
+ struct brcms_bss_cfg *bsscfg = wlc->bsscfg;
+
+- if (bsscfg->up && !bsscfg->BSS)
++ if (bsscfg->up && bsscfg->type == BRCMS_TYPE_AP)
+ /* Clear the soft intmask */
+ wlc->defmacintmask &= ~MI_BCNTPL;
+ }
+@@ -7465,7 +7458,7 @@ void brcms_c_update_probe_resp(struct br
+ struct brcms_bss_cfg *bsscfg = wlc->bsscfg;
+
+ /* update AP or IBSS probe responses */
+- if (bsscfg->up && !bsscfg->BSS)
++ if (bsscfg->up && bsscfg->type == BRCMS_TYPE_AP)
+ brcms_c_bss_update_probe_resp(wlc, bsscfg, suspend);
+ }
+
+--- a/drivers/net/wireless/brcm80211/brcmsmac/main.h
++++ b/drivers/net/wireless/brcm80211/brcmsmac/main.h
+@@ -590,7 +590,6 @@ enum brcms_bss_type {
+ * up: is this configuration up operational
+ * enable: is this configuration enabled
+ * associated: is BSS in ASSOCIATED state
+- * BSS: infraustructure or adhoc
+ * SSID_len: the length of SSID
+ * SSID: SSID string
+ *
+@@ -610,7 +609,6 @@ struct brcms_bss_cfg {
+ bool up;
+ bool enable;
+ bool associated;
+- bool BSS;
+ u8 SSID_len;
+ u8 SSID[IEEE80211_MAX_SSID_LEN];
+ u8 BSSID[ETH_ALEN];
diff --git a/package/mac80211/patches/.svn/text-base/863-brcmsmac-remove-brcms_bss_cfg-associated.patch.svn-base b/package/mac80211/patches/.svn/text-base/863-brcmsmac-remove-brcms_bss_cfg-associated.patch.svn-base
new file mode 100644
index 0000000..7f84f00
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/863-brcmsmac-remove-brcms_bss_cfg-associated.patch.svn-base
@@ -0,0 +1,74 @@
+--- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
++++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
+@@ -3051,8 +3051,6 @@ static void brcms_b_antsel_set(struct br
+ */
+ static bool brcms_c_ps_allowed(struct brcms_c_info *wlc)
+ {
+- struct brcms_bss_cfg *cfg = wlc->bsscfg;
+-
+ /* disallow PS when one of the following global conditions meets */
+ if (!wlc->pub->associated)
+ return false;
+@@ -3061,9 +3059,6 @@ static bool brcms_c_ps_allowed(struct br
+ if (wlc->filter_flags & FIF_PROMISC_IN_BSS)
+ return false;
+
+- if (cfg->associated)
+- return false;
+-
+ return true;
+ }
+
+@@ -3821,7 +3816,7 @@ static void brcms_c_set_home_chanspec(st
+ if (wlc->home_chanspec != chanspec) {
+ wlc->home_chanspec = chanspec;
+
+- if (wlc->bsscfg->associated)
++ if (wlc->pub->associated)
+ wlc->bsscfg->current_bss->chanspec = chanspec;
+ }
+ }
+@@ -5435,7 +5430,7 @@ static void brcms_c_ofdm_rateset_war(str
+ u8 r;
+ bool war = false;
+
+- if (wlc->bsscfg->associated)
++ if (wlc->pub->associated)
+ r = wlc->bsscfg->current_bss->rateset.rates[0];
+ else
+ r = wlc->default_bss->rateset.rates[0];
+@@ -5529,7 +5524,7 @@ int brcms_c_set_rateset(struct brcms_c_i
+ /* merge rateset coming in with the current mcsset */
+ if (wlc->pub->_n_enab & SUPPORT_11N) {
+ struct brcms_bss_info *mcsset_bss;
+- if (wlc->bsscfg->associated)
++ if (wlc->pub->associated)
+ mcsset_bss = wlc->bsscfg->current_bss;
+ else
+ mcsset_bss = wlc->default_bss;
+@@ -7498,7 +7493,6 @@ void brcms_c_scan_stop(struct brcms_c_in
+ void brcms_c_associate_upd(struct brcms_c_info *wlc, bool state)
+ {
+ wlc->pub->associated = state;
+- wlc->bsscfg->associated = state;
+ }
+
+ /*
+--- a/drivers/net/wireless/brcm80211/brcmsmac/main.h
++++ b/drivers/net/wireless/brcm80211/brcmsmac/main.h
+@@ -589,7 +589,6 @@ enum brcms_bss_type {
+ * type: interface type
+ * up: is this configuration up operational
+ * enable: is this configuration enabled
+- * associated: is BSS in ASSOCIATED state
+ * SSID_len: the length of SSID
+ * SSID: SSID string
+ *
+@@ -608,7 +607,6 @@ struct brcms_bss_cfg {
+ enum brcms_bss_type type;
+ bool up;
+ bool enable;
+- bool associated;
+ u8 SSID_len;
+ u8 SSID[IEEE80211_MAX_SSID_LEN];
+ u8 BSSID[ETH_ALEN];
diff --git a/package/mac80211/patches/.svn/text-base/864-brcmsmac-remove-brcms_bss_cfg-enable.patch.svn-base b/package/mac80211/patches/.svn/text-base/864-brcmsmac-remove-brcms_bss_cfg-enable.patch.svn-base
new file mode 100644
index 0000000..9f5c4da
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/864-brcmsmac-remove-brcms_bss_cfg-enable.patch.svn-base
@@ -0,0 +1,32 @@
+--- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
++++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
+@@ -5067,9 +5067,8 @@ int brcms_c_up(struct brcms_c_info *wlc)
+ struct brcms_bss_cfg *bsscfg = wlc->bsscfg;
+ mboolset(wlc->pub->radio_disabled,
+ WL_RADIO_HW_DISABLE);
+- if (bsscfg->enable &&
+- (bsscfg->type == BRCMS_TYPE_STATION ||
+- bsscfg->type == BRCMS_TYPE_ADHOC))
++ if (bsscfg->type == BRCMS_TYPE_STATION ||
++ bsscfg->type == BRCMS_TYPE_ADHOC)
+ brcms_err(wlc->hw->d11core,
+ "wl%d: up: rfdisable -> "
+ "bsscfg_disable()\n",
+--- a/drivers/net/wireless/brcm80211/brcmsmac/main.h
++++ b/drivers/net/wireless/brcm80211/brcmsmac/main.h
+@@ -588,7 +588,6 @@ enum brcms_bss_type {
+ * wlc: wlc to which this bsscfg belongs to.
+ * type: interface type
+ * up: is this configuration up operational
+- * enable: is this configuration enabled
+ * SSID_len: the length of SSID
+ * SSID: SSID string
+ *
+@@ -606,7 +605,6 @@ struct brcms_bss_cfg {
+ struct brcms_c_info *wlc;
+ enum brcms_bss_type type;
+ bool up;
+- bool enable;
+ u8 SSID_len;
+ u8 SSID[IEEE80211_MAX_SSID_LEN];
+ u8 BSSID[ETH_ALEN];
diff --git a/package/mac80211/patches/.svn/text-base/865-brcmsmac-remove-brcms_bss_cfg-up.patch.svn-base b/package/mac80211/patches/.svn/text-base/865-brcmsmac-remove-brcms_bss_cfg-up.patch.svn-base
new file mode 100644
index 0000000..40fe6ea
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/865-brcmsmac-remove-brcms_bss_cfg-up.patch.svn-base
@@ -0,0 +1,47 @@
+--- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
++++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
+@@ -7377,7 +7377,7 @@ void brcms_c_update_beacon(struct brcms_
+ {
+ struct brcms_bss_cfg *bsscfg = wlc->bsscfg;
+
+- if (bsscfg->up && bsscfg->type == BRCMS_TYPE_AP)
++ if (wlc->pub->up && bsscfg->type == BRCMS_TYPE_AP)
+ /* Clear the soft intmask */
+ wlc->defmacintmask &= ~MI_BCNTPL;
+ }
+@@ -7452,7 +7452,7 @@ void brcms_c_update_probe_resp(struct br
+ struct brcms_bss_cfg *bsscfg = wlc->bsscfg;
+
+ /* update AP or IBSS probe responses */
+- if (bsscfg->up && bsscfg->type == BRCMS_TYPE_AP)
++ if (wlc->pub->up && bsscfg->type == BRCMS_TYPE_AP)
+ brcms_c_bss_update_probe_resp(wlc, bsscfg, suspend);
+ }
+
+@@ -7805,7 +7805,7 @@ void brcms_c_init(struct brcms_c_info *w
+ brcms_c_set_bssid(wlc->bsscfg);
+
+ /* Update tsf_cfprep if associated and up */
+- if (wlc->pub->associated && wlc->bsscfg->up) {
++ if (wlc->pub->associated && wlc->pub->up) {
+ u32 bi;
+
+ /* get beacon period and convert to uS */
+--- a/drivers/net/wireless/brcm80211/brcmsmac/main.h
++++ b/drivers/net/wireless/brcm80211/brcmsmac/main.h
+@@ -587,7 +587,6 @@ enum brcms_bss_type {
+ *
+ * wlc: wlc to which this bsscfg belongs to.
+ * type: interface type
+- * up: is this configuration up operational
+ * SSID_len: the length of SSID
+ * SSID: SSID string
+ *
+@@ -604,7 +603,6 @@ enum brcms_bss_type {
+ struct brcms_bss_cfg {
+ struct brcms_c_info *wlc;
+ enum brcms_bss_type type;
+- bool up;
+ u8 SSID_len;
+ u8 SSID[IEEE80211_MAX_SSID_LEN];
+ u8 BSSID[ETH_ALEN];
diff --git a/package/mac80211/patches/.svn/text-base/866-brcmsmac-remove-brcms_bss_cfg-cur_etheraddr.patch.svn-base b/package/mac80211/patches/.svn/text-base/866-brcmsmac-remove-brcms_bss_cfg-cur_etheraddr.patch.svn-base
new file mode 100644
index 0000000..0571932
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/866-brcmsmac-remove-brcms_bss_cfg-cur_etheraddr.patch.svn-base
@@ -0,0 +1,30 @@
+--- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
++++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
+@@ -3766,7 +3766,7 @@ static int brcms_c_set_mac(struct brcms_
+ struct brcms_c_info *wlc = bsscfg->wlc;
+
+ /* enter the MAC addr into the RXE match registers */
+- brcms_c_set_addrmatch(wlc, RCM_MAC_OFFSET, bsscfg->cur_etheraddr);
++ brcms_c_set_addrmatch(wlc, RCM_MAC_OFFSET, wlc->pub->cur_etheraddr);
+
+ brcms_c_ampdu_macaddr_upd(wlc);
+
+@@ -7359,7 +7359,7 @@ brcms_c_bcn_prb_template(struct brcms_c_
+ /* A1 filled in by MAC for prb resp, broadcast for bcn */
+ if (type == IEEE80211_STYPE_BEACON)
+ memcpy(&h->da, &ether_bcast, ETH_ALEN);
+- memcpy(&h->sa, &cfg->cur_etheraddr, ETH_ALEN);
++ memcpy(&h->sa, &wlc->pub->cur_etheraddr, ETH_ALEN);
+ memcpy(&h->bssid, &cfg->BSSID, ETH_ALEN);
+
+ /* SEQ filled in by MAC */
+--- a/drivers/net/wireless/brcm80211/brcmsmac/main.h
++++ b/drivers/net/wireless/brcm80211/brcmsmac/main.h
+@@ -606,7 +606,6 @@ struct brcms_bss_cfg {
+ u8 SSID_len;
+ u8 SSID[IEEE80211_MAX_SSID_LEN];
+ u8 BSSID[ETH_ALEN];
+- u8 cur_etheraddr[ETH_ALEN];
+ struct brcms_bss_info *current_bss;
+ };
+
diff --git a/package/mac80211/patches/.svn/text-base/867-brcmsmac-remove-brcms_pub-bcmerr.patch.svn-base b/package/mac80211/patches/.svn/text-base/867-brcmsmac-remove-brcms_pub-bcmerr.patch.svn-base
new file mode 100644
index 0000000..2e7c166
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/867-brcmsmac-remove-brcms_pub-bcmerr.patch.svn-base
@@ -0,0 +1,21 @@
+--- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
++++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
+@@ -4327,7 +4327,6 @@ static void brcms_c_info_init(struct brc
+
+ /* WME QoS mode is Auto by default */
+ wlc->pub->_ampdu = AMPDU_AGG_HOST;
+- wlc->pub->bcmerror = 0;
+ }
+
+ static uint brcms_c_attach_module(struct brcms_c_info *wlc)
+--- a/drivers/net/wireless/brcm80211/brcmsmac/pub.h
++++ b/drivers/net/wireless/brcm80211/brcmsmac/pub.h
+@@ -164,8 +164,6 @@ struct brcms_pub {
+
+ u8 cur_etheraddr[ETH_ALEN]; /* our local ethernet address */
+
+- int bcmerror; /* last bcm error */
+-
+ u32 radio_disabled; /* bit vector for radio disabled reasons */
+
+ u16 boardrev; /* version # of particular board */
diff --git a/package/mac80211/patches/.svn/text-base/868-brcmsmac-write-beacon-period-to-hardware.patch.svn-base b/package/mac80211/patches/.svn/text-base/868-brcmsmac-write-beacon-period-to-hardware.patch.svn-base
new file mode 100644
index 0000000..fb10e1b
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/868-brcmsmac-write-beacon-period-to-hardware.patch.svn-base
@@ -0,0 +1,23 @@
+--- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
++++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
+@@ -5553,10 +5553,20 @@ static void brcms_c_time_unlock(struct b
+
+ int brcms_c_set_beacon_period(struct brcms_c_info *wlc, u16 period)
+ {
++ u32 bcnint_us;
++
+ if (period == 0)
+ return -EINVAL;
+
+ wlc->default_bss->beacon_period = period;
++
++ bcnint_us = period << 10;
++ brcms_c_time_lock(wlc);
++ bcma_write32(wlc->hw->d11core, D11REGOFFS(tsf_cfprep),
++ (bcnint_us << CFPREP_CBI_SHIFT));
++ bcma_write32(wlc->hw->d11core, D11REGOFFS(tsf_cfpstart), bcnint_us);
++ brcms_c_time_unlock(wlc);
++
+ return 0;
+ }
+
diff --git a/package/mac80211/patches/.svn/text-base/869-brcmsmac-add-beacon-template-support.patch.svn-base b/package/mac80211/patches/.svn/text-base/869-brcmsmac-add-beacon-template-support.patch.svn-base
new file mode 100644
index 0000000..ab864a3
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/869-brcmsmac-add-beacon-template-support.patch.svn-base
@@ -0,0 +1,266 @@
+--- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
++++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
+@@ -1,5 +1,6 @@
+ /*
+ * Copyright (c) 2010 Broadcom Corporation
++ * Copyright (c) 2013 Hauke Mehrtens <hauke@hauke-m.de>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+@@ -522,9 +523,17 @@ brcms_ops_bss_info_changed(struct ieee80
+ brcms_c_set_addrmatch(wl->wlc, RCM_BSSID_OFFSET, info->bssid);
+ spin_unlock_bh(&wl->lock);
+ }
+- if (changed & BSS_CHANGED_BEACON)
++ if (changed & BSS_CHANGED_BEACON) {
+ /* Beacon data changed, retrieve new beacon (beaconing modes) */
+- brcms_err(core, "%s: beacon changed\n", __func__);
++ struct sk_buff *beacon;
++ u16 tim_offset = 0;
++
++ spin_lock_bh(&wl->lock);
++ beacon = ieee80211_beacon_get_tim(hw, vif, &tim_offset, NULL);
++ brcms_c_set_new_beacon(wl->wlc, beacon, tim_offset,
++ info->dtim_period);
++ spin_unlock_bh(&wl->lock);
++ }
+
+ if (changed & BSS_CHANGED_BEACON_ENABLED) {
+ /* Beaconing should be enabled/disabled (beaconing modes) */
+--- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
++++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
+@@ -1,5 +1,6 @@
+ /*
+ * Copyright (c) 2010 Broadcom Corporation
++ * Copyright (c) 2013 Hauke Mehrtens <hauke@hauke-m.de>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+@@ -450,6 +451,8 @@ static void brcms_c_detach_mfree(struct
+ kfree(wlc->corestate);
+ kfree(wlc->hw->bandstate[0]);
+ kfree(wlc->hw);
++ if (wlc->beacon)
++ dev_kfree_skb_any(wlc->beacon);
+
+ /* free the wlc */
+ kfree(wlc);
+@@ -4086,10 +4089,14 @@ void brcms_c_wme_setparams(struct brcms_
+ *shm_entry++);
+ }
+
+- if (suspend) {
++ if (suspend)
+ brcms_c_suspend_mac_and_wait(wlc);
++
++ brcms_c_update_beacon(wlc);
++ brcms_c_update_probe_resp(wlc, false);
++
++ if (suspend)
+ brcms_c_enable_mac(wlc);
+- }
+ }
+
+ static void brcms_c_edcf_setparams(struct brcms_c_info *wlc, bool suspend)
+@@ -7379,6 +7386,107 @@ int brcms_c_get_header_len(void)
+ return TXOFF;
+ }
+
++static void brcms_c_beacon_write(struct brcms_c_info *wlc,
++ struct sk_buff *beacon, u16 tim_offset,
++ u16 dtim_period, bool bcn0, bool bcn1)
++{
++ size_t len;
++ struct ieee80211_tx_info *tx_info;
++ struct brcms_hardware *wlc_hw = wlc->hw;
++ struct ieee80211_hw *ieee_hw = brcms_c_pub(wlc)->ieee_hw;
++
++ /* Get tx_info */
++ tx_info = IEEE80211_SKB_CB(beacon);
++
++ len = min_t(size_t, beacon->len, BCN_TMPL_LEN);
++ wlc->bcn_rspec = ieee80211_get_tx_rate(ieee_hw, tx_info)->hw_value;
++
++ brcms_c_compute_plcp(wlc, wlc->bcn_rspec,
++ len + FCS_LEN - D11_PHY_HDR_LEN, beacon->data);
++
++ /* "Regular" and 16 MBSS but not for 4 MBSS */
++ /* Update the phytxctl for the beacon based on the rspec */
++ brcms_c_beacon_phytxctl_txant_upd(wlc, wlc->bcn_rspec);
++
++ if (bcn0) {
++ /* write the probe response into the template region */
++ brcms_b_write_template_ram(wlc_hw, T_BCN0_TPL_BASE,
++ (len + 3) & ~3, beacon->data);
++
++ /* write beacon length to SCR */
++ brcms_b_write_shm(wlc_hw, M_BCN0_FRM_BYTESZ, (u16) len);
++ }
++ if (bcn1) {
++ /* write the probe response into the template region */
++ brcms_b_write_template_ram(wlc_hw, T_BCN1_TPL_BASE,
++ (len + 3) & ~3, beacon->data);
++
++ /* write beacon length to SCR */
++ brcms_b_write_shm(wlc_hw, M_BCN1_FRM_BYTESZ, (u16) len);
++ }
++
++ if (tim_offset != 0) {
++ brcms_b_write_shm(wlc_hw, M_TIMBPOS_INBEACON,
++ tim_offset + D11B_PHY_HDR_LEN);
++ brcms_b_write_shm(wlc_hw, M_DOT11_DTIMPERIOD, dtim_period);
++ } else {
++ brcms_b_write_shm(wlc_hw, M_TIMBPOS_INBEACON,
++ len + D11B_PHY_HDR_LEN);
++ brcms_b_write_shm(wlc_hw, M_DOT11_DTIMPERIOD, 0);
++ }
++}
++
++static void brcms_c_update_beacon_hw(struct brcms_c_info *wlc,
++ struct sk_buff *beacon, u16 tim_offset,
++ u16 dtim_period)
++{
++ struct brcms_hardware *wlc_hw = wlc->hw;
++ struct bcma_device *core = wlc_hw->d11core;
++
++ /* Hardware beaconing for this config */
++ u32 both_valid = MCMD_BCN0VLD | MCMD_BCN1VLD;
++
++ /* Check if both templates are in use, if so sched. an interrupt
++ * that will call back into this routine
++ */
++ if ((bcma_read32(core, D11REGOFFS(maccommand)) & both_valid) == both_valid)
++ /* clear any previous status */
++ bcma_write32(core, D11REGOFFS(macintstatus), MI_BCNTPL);
++
++ if (wlc->beacon_template_virgin) {
++ wlc->beacon_template_virgin = false;
++ brcms_c_beacon_write(wlc, beacon, tim_offset, dtim_period, true,
++ true);
++ /* mark beacon0 valid */
++ bcma_set32(core, D11REGOFFS(maccommand), MCMD_BCN0VLD);
++ return;
++ }
++
++ /* Check that after scheduling the interrupt both of the
++ * templates are still busy. if not clear the int. & remask
++ */
++ if ((bcma_read32(core, D11REGOFFS(maccommand)) & both_valid) == both_valid) {
++ wlc->defmacintmask |= MI_BCNTPL;
++ return;
++ }
++
++ if (!(bcma_read32(core, D11REGOFFS(maccommand)) & MCMD_BCN0VLD)) {
++ brcms_c_beacon_write(wlc, beacon, tim_offset, dtim_period, true,
++ false);
++ /* mark beacon0 valid */
++ bcma_set32(core, D11REGOFFS(maccommand), MCMD_BCN0VLD);
++ return;
++ }
++ if (!(bcma_read32(core, D11REGOFFS(maccommand)) & MCMD_BCN1VLD)) {
++ brcms_c_beacon_write(wlc, beacon, tim_offset, dtim_period,
++ false, true);
++ /* mark beacon0 valid */
++ bcma_set32(core, D11REGOFFS(maccommand), MCMD_BCN1VLD);
++ return;
++ }
++ return;
++}
++
+ /*
+ * Update all beacons for the system.
+ */
+@@ -7386,9 +7494,31 @@ void brcms_c_update_beacon(struct brcms_
+ {
+ struct brcms_bss_cfg *bsscfg = wlc->bsscfg;
+
+- if (wlc->pub->up && bsscfg->type == BRCMS_TYPE_AP)
++ if (wlc->pub->up && bsscfg->type == BRCMS_TYPE_AP) {
+ /* Clear the soft intmask */
+ wlc->defmacintmask &= ~MI_BCNTPL;
++ if (!wlc->beacon)
++ return;
++ brcms_c_update_beacon_hw(wlc, wlc->beacon,
++ wlc->beacon_tim_offset,
++ wlc->beacon_dtim_period);
++ }
++}
++
++void brcms_c_set_new_beacon(struct brcms_c_info *wlc, struct sk_buff *beacon,
++ u16 tim_offset, u16 dtim_period)
++{
++ if (!beacon)
++ return;
++ if (wlc->beacon)
++ dev_kfree_skb_any(wlc->beacon);
++ wlc->beacon = beacon;
++
++ /* add PLCP */
++ skb_push(wlc->beacon, D11_PHY_HDR_LEN);
++ wlc->beacon_tim_offset = tim_offset;
++ wlc->beacon_dtim_period = dtim_period;
++ brcms_c_update_beacon(wlc);
+ }
+
+ /* Write ssid into shared memory */
+@@ -7786,6 +7916,10 @@ bool brcms_c_dpc(struct brcms_c_info *wl
+ brcms_rfkill_set_hw_state(wlc->wl);
+ }
+
++ /* BCN template is available */
++ if (macintstatus & MI_BCNTPL)
++ brcms_c_update_beacon(wlc);
++
+ /* it isn't done and needs to be resched if macintstatus is non-zero */
+ return wlc->macintstatus != 0;
+
+@@ -7917,6 +8051,7 @@ brcms_c_attach(struct brcms_info *wl, st
+ pub->unit = unit;
+ pub->_piomode = piomode;
+ wlc->bandinit_pending = false;
++ wlc->beacon_template_virgin = true;
+
+ /* populate struct brcms_c_info with default values */
+ brcms_c_info_init(wlc, unit);
+--- a/drivers/net/wireless/brcm80211/brcmsmac/main.h
++++ b/drivers/net/wireless/brcm80211/brcmsmac/main.h
+@@ -492,6 +492,8 @@ struct brcms_c_info {
+ bool radio_monitor;
+ bool going_down;
+
++ bool beacon_template_virgin;
++
+ struct brcms_timer *wdtimer;
+ struct brcms_timer *radio_timer;
+
+@@ -561,6 +563,10 @@ struct brcms_c_info {
+
+ struct wiphy *wiphy;
+ struct scb pri_scb;
++
++ struct sk_buff *beacon;
++ u16 beacon_tim_offset;
++ u16 beacon_dtim_period;
+ };
+
+ /* antsel module specific state */
+@@ -630,7 +636,6 @@ extern u16 brcms_c_compute_rtscts_dur(st
+ extern void brcms_c_inval_dma_pkts(struct brcms_hardware *hw,
+ struct ieee80211_sta *sta,
+ void (*dma_callback_fn));
+-extern void brcms_c_update_beacon(struct brcms_c_info *wlc);
+ extern void brcms_c_update_probe_resp(struct brcms_c_info *wlc, bool suspend);
+ extern int brcms_c_set_nmode(struct brcms_c_info *wlc);
+ extern void brcms_c_beacon_phytxctl_txant_upd(struct brcms_c_info *wlc,
+--- a/drivers/net/wireless/brcm80211/brcmsmac/pub.h
++++ b/drivers/net/wireless/brcm80211/brcmsmac/pub.h
+@@ -332,5 +332,9 @@ extern bool brcms_c_check_radio_disabled
+ extern void brcms_c_mute(struct brcms_c_info *wlc, bool on);
+ extern bool brcms_c_tx_flush_completed(struct brcms_c_info *wlc);
+ extern void brcms_c_start_station(struct brcms_c_info *wlc, u8 *addr);
++extern void brcms_c_update_beacon(struct brcms_c_info *wlc);
++extern void brcms_c_set_new_beacon(struct brcms_c_info *wlc,
++ struct sk_buff *beacon, u16 tim_offset,
++ u16 dtim_period);
+
+ #endif /* _BRCM_PUB_H_ */
diff --git a/package/mac80211/patches/.svn/text-base/870-brcmsmac-react-on-changing-SSID.patch.svn-base b/package/mac80211/patches/.svn/text-base/870-brcmsmac-react-on-changing-SSID.patch.svn-base
new file mode 100644
index 0000000..34969ad
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/870-brcmsmac-react-on-changing-SSID.patch.svn-base
@@ -0,0 +1,43 @@
+--- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
++++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
+@@ -523,6 +523,12 @@ brcms_ops_bss_info_changed(struct ieee80
+ brcms_c_set_addrmatch(wl->wlc, RCM_BSSID_OFFSET, info->bssid);
+ spin_unlock_bh(&wl->lock);
+ }
++ if (changed & BSS_CHANGED_SSID) {
++ /* BSSID changed, for whatever reason (IBSS and managed mode) */
++ spin_lock_bh(&wl->lock);
++ brcms_c_set_ssid(wl->wlc, info->ssid, info->ssid_len);
++ spin_unlock_bh(&wl->lock);
++ }
+ if (changed & BSS_CHANGED_BEACON) {
+ /* Beacon data changed, retrieve new beacon (beaconing modes) */
+ struct sk_buff *beacon;
+--- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
++++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
+@@ -3785,6 +3785,15 @@ static void brcms_c_set_bssid(struct brc
+ brcms_c_set_addrmatch(bsscfg->wlc, RCM_BSSID_OFFSET, bsscfg->BSSID);
+ }
+
++void brcms_c_set_ssid(struct brcms_c_info *wlc, u8 *ssid, size_t ssid_len)
++{
++ u8 len = min_t(u8, sizeof(wlc->bsscfg->SSID), ssid_len);
++ memset(wlc->bsscfg->SSID, 0, sizeof(wlc->bsscfg->SSID));
++
++ memcpy(wlc->bsscfg->SSID, ssid, len);
++ wlc->bsscfg->SSID_len = len;
++}
++
+ static void brcms_b_set_shortslot(struct brcms_hardware *wlc_hw, bool shortslot)
+ {
+ wlc_hw->shortslot = shortslot;
+--- a/drivers/net/wireless/brcm80211/brcmsmac/pub.h
++++ b/drivers/net/wireless/brcm80211/brcmsmac/pub.h
+@@ -336,5 +336,7 @@ extern void brcms_c_update_beacon(struct
+ extern void brcms_c_set_new_beacon(struct brcms_c_info *wlc,
+ struct sk_buff *beacon, u16 tim_offset,
+ u16 dtim_period);
++extern void brcms_c_set_ssid(struct brcms_c_info *wlc, u8 *ssid,
++ size_t ssid_len);
+
+ #endif /* _BRCM_PUB_H_ */
diff --git a/package/mac80211/patches/.svn/text-base/871-brcmsmac-add-support-for-probe-response-template.patch.svn-base b/package/mac80211/patches/.svn/text-base/871-brcmsmac-add-support-for-probe-response-template.patch.svn-base
new file mode 100644
index 0000000..5d022d2
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/871-brcmsmac-add-support-for-probe-response-template.patch.svn-base
@@ -0,0 +1,216 @@
+--- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
++++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
+@@ -541,6 +541,15 @@ brcms_ops_bss_info_changed(struct ieee80
+ spin_unlock_bh(&wl->lock);
+ }
+
++ if (changed & BSS_CHANGED_AP_PROBE_RESP) {
++ struct sk_buff *probe_resp;
++
++ spin_lock_bh(&wl->lock);
++ probe_resp = ieee80211_proberesp_get(hw, vif);
++ brcms_c_set_new_probe_resp(wl->wlc, probe_resp);
++ spin_unlock_bh(&wl->lock);
++ }
++
+ if (changed & BSS_CHANGED_BEACON_ENABLED) {
+ /* Beaconing should be enabled/disabled (beaconing modes) */
+ brcms_err(core, "%s: Beacon enabled: %s\n", __func__,
+@@ -1039,6 +1048,8 @@ static int ieee_hw_init(struct ieee80211
+ hw->channel_change_time = 7 * 1000;
+ hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION);
+
++ hw->wiphy->flags |= WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD;
++
+ hw->rate_control_algorithm = "minstrel_ht";
+
+ hw->sta_data_size = 0;
+--- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
++++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
+@@ -453,6 +453,8 @@ static void brcms_c_detach_mfree(struct
+ kfree(wlc->hw);
+ if (wlc->beacon)
+ dev_kfree_skb_any(wlc->beacon);
++ if (wlc->probe_resp)
++ dev_kfree_skb_any(wlc->probe_resp);
+
+ /* free the wlc */
+ kfree(wlc);
+@@ -7327,69 +7329,6 @@ brcms_c_mod_prb_rsp_rate_table(struct br
+ }
+ }
+
+-/* Max buffering needed for beacon template/prb resp template is 142 bytes.
+- *
+- * PLCP header is 6 bytes.
+- * 802.11 A3 header is 24 bytes.
+- * Max beacon frame body template length is 112 bytes.
+- * Max probe resp frame body template length is 110 bytes.
+- *
+- * *len on input contains the max length of the packet available.
+- *
+- * The *len value is set to the number of bytes in buf used, and starts
+- * with the PLCP and included up to, but not including, the 4 byte FCS.
+- */
+-static void
+-brcms_c_bcn_prb_template(struct brcms_c_info *wlc, u16 type,
+- u32 bcn_rspec,
+- struct brcms_bss_cfg *cfg, u16 *buf, int *len)
+-{
+- static const u8 ether_bcast[ETH_ALEN] = {255, 255, 255, 255, 255, 255};
+- struct cck_phy_hdr *plcp;
+- struct ieee80211_mgmt *h;
+- int hdr_len, body_len;
+-
+- hdr_len = D11_PHY_HDR_LEN + DOT11_MAC_HDR_LEN;
+-
+- /* calc buffer size provided for frame body */
+- body_len = *len - hdr_len;
+- /* return actual size */
+- *len = hdr_len + body_len;
+-
+- /* format PHY and MAC headers */
+- memset(buf, 0, hdr_len);
+-
+- plcp = (struct cck_phy_hdr *) buf;
+-
+- /*
+- * PLCP for Probe Response frames are filled in from
+- * core's rate table
+- */
+- if (type == IEEE80211_STYPE_BEACON)
+- /* fill in PLCP */
+- brcms_c_compute_plcp(wlc, bcn_rspec,
+- (DOT11_MAC_HDR_LEN + body_len + FCS_LEN),
+- (u8 *) plcp);
+-
+- /* "Regular" and 16 MBSS but not for 4 MBSS */
+- /* Update the phytxctl for the beacon based on the rspec */
+- brcms_c_beacon_phytxctl_txant_upd(wlc, bcn_rspec);
+-
+- h = (struct ieee80211_mgmt *)&plcp[1];
+-
+- /* fill in 802.11 header */
+- h->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | type);
+-
+- /* DUR is 0 for multicast bcn, or filled in by MAC for prb resp */
+- /* A1 filled in by MAC for prb resp, broadcast for bcn */
+- if (type == IEEE80211_STYPE_BEACON)
+- memcpy(&h->da, &ether_bcast, ETH_ALEN);
+- memcpy(&h->sa, &wlc->pub->cur_etheraddr, ETH_ALEN);
+- memcpy(&h->bssid, &cfg->BSSID, ETH_ALEN);
+-
+- /* SEQ filled in by MAC */
+-}
+-
+ int brcms_c_get_header_len(void)
+ {
+ return TXOFF;
+@@ -7530,6 +7469,20 @@ void brcms_c_set_new_beacon(struct brcms
+ brcms_c_update_beacon(wlc);
+ }
+
++void brcms_c_set_new_probe_resp(struct brcms_c_info *wlc,
++ struct sk_buff *probe_resp)
++{
++ if (!probe_resp)
++ return;
++ if (wlc->probe_resp)
++ dev_kfree_skb_any(wlc->probe_resp);
++ wlc->probe_resp = probe_resp;
++
++ /* add PLCP */
++ skb_push(wlc->probe_resp, D11_PHY_HDR_LEN);
++ brcms_c_update_probe_resp(wlc, false);
++}
++
+ /* Write ssid into shared memory */
+ static void
+ brcms_c_shm_ssid_upd(struct brcms_c_info *wlc, struct brcms_bss_cfg *cfg)
+@@ -7549,30 +7502,19 @@ brcms_c_shm_ssid_upd(struct brcms_c_info
+ static void
+ brcms_c_bss_update_probe_resp(struct brcms_c_info *wlc,
+ struct brcms_bss_cfg *cfg,
++ struct sk_buff *probe_resp,
+ bool suspend)
+ {
+- u16 *prb_resp;
+- int len = BCN_TMPL_LEN;
++ int len;
+
+- prb_resp = kmalloc(BCN_TMPL_LEN, GFP_ATOMIC);
+- if (!prb_resp)
+- return;
+-
+- /*
+- * write the probe response to hardware, or save in
+- * the config structure
+- */
+-
+- /* create the probe response template */
+- brcms_c_bcn_prb_template(wlc, IEEE80211_STYPE_PROBE_RESP, 0,
+- cfg, prb_resp, &len);
++ len = min_t(size_t, probe_resp->len, BCN_TMPL_LEN);
+
+ if (suspend)
+ brcms_c_suspend_mac_and_wait(wlc);
+
+ /* write the probe response into the template region */
+ brcms_b_write_template_ram(wlc->hw, T_PRS_TPL_BASE,
+- (len + 3) & ~3, prb_resp);
++ (len + 3) & ~3, probe_resp->data);
+
+ /* write the length of the probe response frame (+PLCP/-FCS) */
+ brcms_b_write_shm(wlc->hw, M_PRB_RESP_FRM_LEN, (u16) len);
+@@ -7586,13 +7528,11 @@ brcms_c_bss_update_probe_resp(struct brc
+ * PLCP header for the call to brcms_c_mod_prb_rsp_rate_table()
+ * by subtracting the PLCP len and adding the FCS.
+ */
+- len += (-D11_PHY_HDR_LEN + FCS_LEN);
+- brcms_c_mod_prb_rsp_rate_table(wlc, (u16) len);
++ brcms_c_mod_prb_rsp_rate_table(wlc,
++ (u16)len + FCS_LEN - D11_PHY_HDR_LEN);
+
+ if (suspend)
+ brcms_c_enable_mac(wlc);
+-
+- kfree(prb_resp);
+ }
+
+ void brcms_c_update_probe_resp(struct brcms_c_info *wlc, bool suspend)
+@@ -7600,8 +7540,12 @@ void brcms_c_update_probe_resp(struct br
+ struct brcms_bss_cfg *bsscfg = wlc->bsscfg;
+
+ /* update AP or IBSS probe responses */
+- if (wlc->pub->up && bsscfg->type == BRCMS_TYPE_AP)
+- brcms_c_bss_update_probe_resp(wlc, bsscfg, suspend);
++ if (wlc->pub->up && bsscfg->type == BRCMS_TYPE_AP) {
++ if (!wlc->probe_resp)
++ return;
++ brcms_c_bss_update_probe_resp(wlc, bsscfg, wlc->probe_resp,
++ suspend);
++ }
+ }
+
+ int brcms_b_xmtfifo_sz_get(struct brcms_hardware *wlc_hw, uint fifo,
+--- a/drivers/net/wireless/brcm80211/brcmsmac/main.h
++++ b/drivers/net/wireless/brcm80211/brcmsmac/main.h
+@@ -567,6 +567,7 @@ struct brcms_c_info {
+ struct sk_buff *beacon;
+ u16 beacon_tim_offset;
+ u16 beacon_dtim_period;
++ struct sk_buff *probe_resp;
+ };
+
+ /* antsel module specific state */
+--- a/drivers/net/wireless/brcm80211/brcmsmac/pub.h
++++ b/drivers/net/wireless/brcm80211/brcmsmac/pub.h
+@@ -336,6 +336,8 @@ extern void brcms_c_update_beacon(struct
+ extern void brcms_c_set_new_beacon(struct brcms_c_info *wlc,
+ struct sk_buff *beacon, u16 tim_offset,
+ u16 dtim_period);
++extern void brcms_c_set_new_probe_resp(struct brcms_c_info *wlc,
++ struct sk_buff *probe_resp);
+ extern void brcms_c_set_ssid(struct brcms_c_info *wlc, u8 *ssid,
+ size_t ssid_len);
+
diff --git a/package/mac80211/patches/.svn/text-base/872-brcmsmac-activate-AP-support.patch.svn-base b/package/mac80211/patches/.svn/text-base/872-brcmsmac-activate-AP-support.patch.svn-base
new file mode 100644
index 0000000..aaf6840
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/872-brcmsmac-activate-AP-support.patch.svn-base
@@ -0,0 +1,74 @@
+--- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
++++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
+@@ -360,7 +360,8 @@ brcms_ops_add_interface(struct ieee80211
+ struct brcms_info *wl = hw->priv;
+
+ /* Just STA for now */
+- if (vif->type != NL80211_IFTYPE_STATION) {
++ if (vif->type != NL80211_IFTYPE_STATION &&
++ vif->type != NL80211_IFTYPE_AP) {
+ brcms_err(wl->wlc->hw->d11core,
+ "%s: Attempt to add type %d, only STA for now\n",
+ __func__, vif->type);
+@@ -372,6 +373,9 @@ brcms_ops_add_interface(struct ieee80211
+ brcms_c_mute(wl->wlc, false);
+ if (vif->type == NL80211_IFTYPE_STATION)
+ brcms_c_start_station(wl->wlc, vif->addr);
++ else if (vif->type == NL80211_IFTYPE_AP)
++ brcms_c_start_ap(wl->wlc, vif->addr, vif->bss_conf.bssid,
++ vif->bss_conf.ssid, vif->bss_conf.ssid_len);
+ spin_unlock_bh(&wl->lock);
+
+ return 0;
+@@ -1046,7 +1050,8 @@ static int ieee_hw_init(struct ieee80211
+
+ /* channel change time is dependent on chip and band */
+ hw->channel_change_time = 7 * 1000;
+- hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION);
++ hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
++ BIT(NL80211_IFTYPE_AP);
+
+ hw->wiphy->flags |= WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD;
+
+--- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
++++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
+@@ -2176,6 +2176,18 @@ void brcms_c_start_station(struct brcms_
+ wlc->bsscfg->type = BRCMS_TYPE_STATION;
+ }
+
++void brcms_c_start_ap(struct brcms_c_info *wlc, u8 *addr, const u8 *bssid,
++ u8 *ssid, size_t ssid_len)
++{
++ brcms_c_set_ssid(wlc, ssid, ssid_len);
++
++ memcpy(wlc->pub->cur_etheraddr, addr, sizeof(wlc->pub->cur_etheraddr));
++ memcpy(wlc->bsscfg->BSSID, bssid, sizeof(wlc->bsscfg->BSSID));
++ wlc->bsscfg->type = BRCMS_TYPE_AP;
++
++ brcms_b_mctrl(wlc->hw, MCTL_AP | MCTL_INFRA, MCTL_AP | MCTL_INFRA);
++}
++
+ /* Initialize GPIOs that are controlled by D11 core */
+ static void brcms_c_gpio_init(struct brcms_c_info *wlc)
+ {
+@@ -3064,6 +3076,9 @@ static bool brcms_c_ps_allowed(struct br
+ if (wlc->filter_flags & FIF_PROMISC_IN_BSS)
+ return false;
+
++ if (wlc->bsscfg->type == BRCMS_TYPE_AP)
++ return false;
++
+ return true;
+ }
+
+--- a/drivers/net/wireless/brcm80211/brcmsmac/pub.h
++++ b/drivers/net/wireless/brcm80211/brcmsmac/pub.h
+@@ -332,6 +332,8 @@ extern bool brcms_c_check_radio_disabled
+ extern void brcms_c_mute(struct brcms_c_info *wlc, bool on);
+ extern bool brcms_c_tx_flush_completed(struct brcms_c_info *wlc);
+ extern void brcms_c_start_station(struct brcms_c_info *wlc, u8 *addr);
++extern void brcms_c_start_ap(struct brcms_c_info *wlc, u8 *addr,
++ const u8 *bssid, u8 *ssid, size_t ssid_len);
+ extern void brcms_c_update_beacon(struct brcms_c_info *wlc);
+ extern void brcms_c_set_new_beacon(struct brcms_c_info *wlc,
+ struct sk_buff *beacon, u16 tim_offset,
diff --git a/package/mac80211/patches/.svn/text-base/873-brcmsmac-remove-extra-regulation-restriction.patch.svn-base b/package/mac80211/patches/.svn/text-base/873-brcmsmac-remove-extra-regulation-restriction.patch.svn-base
new file mode 100644
index 0000000..dd1393a
--- /dev/null
+++ b/package/mac80211/patches/.svn/text-base/873-brcmsmac-remove-extra-regulation-restriction.patch.svn-base
@@ -0,0 +1,31 @@
+--- a/drivers/net/wireless/brcm80211/brcmsmac/channel.c
++++ b/drivers/net/wireless/brcm80211/brcmsmac/channel.c
+@@ -59,23 +59,16 @@
+
+ #define BRCM_2GHZ_2412_2462 REG_RULE(2412-10, 2462+10, 40, 0, 19, 0)
+ #define BRCM_2GHZ_2467_2472 REG_RULE(2467-10, 2472+10, 20, 0, 19, \
+- NL80211_RRF_PASSIVE_SCAN | \
+- NL80211_RRF_NO_IBSS)
++ 0)
+
+ #define BRCM_5GHZ_5180_5240 REG_RULE(5180-10, 5240+10, 40, 0, 21, \
+- NL80211_RRF_PASSIVE_SCAN | \
+- NL80211_RRF_NO_IBSS)
++ 0)
+ #define BRCM_5GHZ_5260_5320 REG_RULE(5260-10, 5320+10, 40, 0, 21, \
+- NL80211_RRF_PASSIVE_SCAN | \
+- NL80211_RRF_DFS | \
+- NL80211_RRF_NO_IBSS)
++ 0)
+ #define BRCM_5GHZ_5500_5700 REG_RULE(5500-10, 5700+10, 40, 0, 21, \
+- NL80211_RRF_PASSIVE_SCAN | \
+- NL80211_RRF_DFS | \
+- NL80211_RRF_NO_IBSS)
++ 0)
+ #define BRCM_5GHZ_5745_5825 REG_RULE(5745-10, 5825+10, 40, 0, 21, \
+- NL80211_RRF_PASSIVE_SCAN | \
+- NL80211_RRF_NO_IBSS)
++ 0)
+
+ static const struct ieee80211_regdomain brcms_regdom_x2 = {
+ .n_reg_rules = 6,
diff --git a/package/mac80211/patches/001-disable_rfkill.patch b/package/mac80211/patches/001-disable_rfkill.patch
new file mode 100644
index 0000000..7af485f
--- /dev/null
+++ b/package/mac80211/patches/001-disable_rfkill.patch
@@ -0,0 +1,13 @@
+--- a/include/linux/rfkill.h
++++ b/include/linux/rfkill.h
+@@ -3,6 +3,10 @@
+
+ #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31))
+
++#undef CONFIG_RFKILL
++#undef CONFIG_RFKILL_LEDS
++#undef CONFIG_RFKILL_MODULE
++
+ #include_next <linux/rfkill.h>
+
+ #else
diff --git a/package/mac80211/patches/002-disable_ssb_build.patch b/package/mac80211/patches/002-disable_ssb_build.patch
new file mode 100644
index 0000000..ef184c4
--- /dev/null
+++ b/package/mac80211/patches/002-disable_ssb_build.patch
@@ -0,0 +1,21 @@
+--- a/config.mk
++++ b/config.mk
+@@ -364,7 +364,8 @@ export CONFIG_IPW2200_QOS=y
+ # % echo 1 > /sys/bus/pci/drivers/ipw2200/*/rtap_iface
+ endif #CONFIG_WIRELESS_EXT
+
+-ifdef CONFIG_SSB
++# disabled
++ifdef __CONFIG_SSB
+ # Sonics Silicon Backplane
+ export CONFIG_SSB_SPROM=y
+
+@@ -377,7 +378,7 @@ endif #CONFIG_PCMCIA
+ # export CONFIG_SSB_DEBUG=y
+ export CONFIG_SSB_DRIVER_PCICORE=y
+ export CONFIG_B43_SSB=y
+-endif #CONFIG_SSB
++endif #__CONFIG_SSB
+
+ # export CONFIG_BCMA=m
+ # export CONFIG_BCMA_BLOCKIO=y
diff --git a/package/mac80211/patches/003-disable_codel.patch b/package/mac80211/patches/003-disable_codel.patch
new file mode 100644
index 0000000..0d6d749
--- /dev/null
+++ b/package/mac80211/patches/003-disable_codel.patch
@@ -0,0 +1,19 @@
+--- a/compat/scripts/gen-compat-config.sh
++++ b/compat/scripts/gen-compat-config.sh
+@@ -66,16 +66,3 @@ if [[ ${CONFIG_COMPAT_KERNEL_2_6_36} = "
+ echo "export CONFIG_COMPAT_KFIFO=y"
+ fi
+ fi
+-
+-if [[ ${CONFIG_COMPAT_KERNEL_3_5} = "y" ]]; then
+- # We don't have 2.6.24 backport support yet for Codel / FQ CoDel
+- # For those who want to try this is what is required that I can tell
+- # so far:
+- # * struct Qdisc_ops
+- # - init and change callback ops use a different argument dataype
+- # - you need to parse data received from userspace differently
+- if [[ ${CONFIG_COMPAT_KERNEL_2_6_25} != "y" ]]; then
+- echo "export CONFIG_COMPAT_NET_SCH_CODEL=m"
+- echo "export CONFIG_COMPAT_NET_SCH_FQ_CODEL=m"
+- fi
+-fi
diff --git a/package/mac80211/patches/004-use_env_for_bash.patch b/package/mac80211/patches/004-use_env_for_bash.patch
new file mode 100644
index 0000000..0ae3820
--- /dev/null
+++ b/package/mac80211/patches/004-use_env_for_bash.patch
@@ -0,0 +1,8 @@
+--- a/compat/scripts/gen-compat-config.sh
++++ b/compat/scripts/gen-compat-config.sh
+@@ -1,4 +1,4 @@
+-#!/bin/bash
++#!/usr/bin/env bash
+ # Copyright 2012 Luis R. Rodriguez <mcgrof@frijolero.org>
+ # Copyright 2012 Hauke Mehrtens <hauke@hauke-m.de>
+ #
diff --git a/package/mac80211/patches/010-add_include_for_bcma.patch b/package/mac80211/patches/010-add_include_for_bcma.patch
new file mode 100644
index 0000000..e2e856e
--- /dev/null
+++ b/package/mac80211/patches/010-add_include_for_bcma.patch
@@ -0,0 +1,11 @@
+--- a/include/linux/compat-3.0.h
++++ b/include/linux/compat-3.0.h
+@@ -36,6 +36,8 @@ static inline struct page *shmem_read_ma
+ #endif
+
+
++#include <linux/mod_devicetable.h>
++
+ /*
+ * since commit 1c5cae815d19ffe02bdfda1260949ef2b1806171
+ * "net: call dev_alloc_name from register_netdevice" dev_alloc_name is
diff --git a/package/mac80211/patches/020-disable_tty_set_termios.patch b/package/mac80211/patches/020-disable_tty_set_termios.patch
new file mode 100644
index 0000000..fc5d4d6
--- /dev/null
+++ b/package/mac80211/patches/020-disable_tty_set_termios.patch
@@ -0,0 +1,16 @@
+--- a/compat/compat-2.6.39.c
++++ b/compat/compat-2.6.39.c
+@@ -12,6 +12,7 @@
+ #include <linux/tty.h>
+ #include <linux/sched.h>
+
++#ifdef CONFIG_COMPAT_BLUETOOTH
+ #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27))
+ /*
+ * Termios Helper Methods
+@@ -111,4 +112,4 @@ int tty_set_termios(struct tty_struct *t
+ }
+ EXPORT_SYMBOL_GPL(tty_set_termios);
+ #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)) */
+-
++#endif
diff --git a/package/mac80211/patches/030-wext.patch b/package/mac80211/patches/030-wext.patch
new file mode 100644
index 0000000..cb52e7c
--- /dev/null
+++ b/package/mac80211/patches/030-wext.patch
@@ -0,0 +1,18 @@
+--- a/net/wireless/core.c
++++ b/net/wireless/core.c
+@@ -884,6 +884,15 @@ static int cfg80211_netdev_notifier_call
+ wdev->sme_state = CFG80211_SME_IDLE;
+ mutex_unlock(&rdev->devlist_mtx);
+ #ifdef CONFIG_CFG80211_WEXT
++#ifdef CONFIG_WIRELESS_EXT
++ if (!dev->wireless_handlers)
++ dev->wireless_handlers = &cfg80211_wext_handler;
++#else
++ printk_once(KERN_WARNING "cfg80211: wext will not work because "
++ "kernel was compiled with CONFIG_WIRELESS_EXT=n. "
++ "Tools using wext interface, like iwconfig will "
++ "not work.\n");
++#endif
+ wdev->wext.default_key = -1;
+ wdev->wext.default_mgmt_key = -1;
+ wdev->wext.connect.auth_type = NL80211_AUTHTYPE_AUTOMATIC;
diff --git a/package/mac80211/patches/040-linux_3_9_compat.patch b/package/mac80211/patches/040-linux_3_9_compat.patch
new file mode 100644
index 0000000..d83c39c
--- /dev/null
+++ b/package/mac80211/patches/040-linux_3_9_compat.patch
@@ -0,0 +1,153 @@
+--- a/include/linux/compat-2.6.h
++++ b/include/linux/compat-2.6.h
+@@ -69,6 +69,7 @@ void compat_dependency_symbol(void);
+ #include <linux/compat-3.6.h>
+ #include <linux/compat-3.7.h>
+ #include <linux/compat-3.8.h>
++#include <linux/compat-3.9.h>
+
+ #endif /* __ASSEMBLY__ */
+
+--- /dev/null
++++ b/include/linux/compat-3.9.h
+@@ -0,0 +1,140 @@
++#ifndef LINUX_3_9_COMPAT_H
++#define LINUX_3_9_COMPAT_H
++
++#include <linux/version.h>
++
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0))
++
++#include <linux/idr.h>
++#include <linux/list.h>
++#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,25))
++#include <linux/rculist.h>
++#endif
++#include <net/sock.h>
++#include <linux/tty.h>
++#include <linux/tty_flip.h>
++
++/* include this before changing hlist_for_each_* to use the old versions. */
++#include <net/sch_generic.h>
++
++
++/**
++ * backport of idr idr_alloc() usage
++ *
++ * This backports a patch series send by Tejun Heo:
++ * https://lkml.org/lkml/2013/2/2/159
++ */
++static inline void compat_idr_destroy(struct idr *idp)
++{
++ idr_remove_all(idp);
++ idr_destroy(idp);
++}
++#define idr_destroy(idp) compat_idr_destroy(idp)
++
++static inline int idr_alloc(struct idr *idr, void *ptr, int start, int end,
++ gfp_t gfp_mask)
++{
++ int id, ret;
++
++ do {
++ if (!idr_pre_get(idr, gfp_mask))
++ return -ENOMEM;
++ ret = idr_get_new_above(idr, ptr, start, &id);
++ if (!ret && id > end) {
++ idr_remove(idr, id);
++ ret = -ENOSPC;
++ }
++ } while (ret == -EAGAIN);
++
++ return ret ? ret : id;
++}
++
++static inline void idr_preload(gfp_t gfp_mask)
++{
++}
++
++static inline void idr_preload_end(void)
++{
++}
++
++
++/**
++ * backport:
++ *
++ * commit 0bbacca7c3911451cea923b0ad6389d58e3d9ce9
++ * Author: Sasha Levin <sasha.levin@oracle.com>
++ * Date: Thu Feb 7 12:32:18 2013 +1100
++ *
++ * hlist: drop the node parameter from iterators
++ */
++
++#define hlist_entry_safe(ptr, type, member) \
++ (ptr) ? hlist_entry(ptr, type, member) : NULL
++
++#undef hlist_for_each_entry
++/**
++ * hlist_for_each_entry - iterate over list of given type
++ * @pos: the type * to use as a loop cursor.
++ * @head: the head for your list.
++ * @member: the name of the hlist_node within the struct.
++ */
++#define hlist_for_each_entry(pos, head, member) \
++ for (pos = hlist_entry_safe((head)->first, typeof(*(pos)), member); \
++ pos; \
++ pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member))
++
++#undef hlist_for_each_entry_safe
++/**
++ * hlist_for_each_entry_safe - iterate over list of given type safe against removal of list entry
++ * @pos: the type * to use as a loop cursor.
++ * @n: another &struct hlist_node to use as temporary storage
++ * @head: the head for your list.
++ * @member: the name of the hlist_node within the struct.
++ */
++#define hlist_for_each_entry_safe(pos, n, head, member) \
++ for (pos = hlist_entry_safe((head)->first, typeof(*pos), member); \
++ pos && ({ n = pos->member.next; 1; }); \
++ pos = hlist_entry_safe(n, typeof(*pos), member))
++
++#undef hlist_for_each_entry_rcu
++/**
++ * hlist_for_each_entry_rcu - iterate over rcu list of given type
++ * @pos: the type * to use as a loop cursor.
++ * @head: the head for your list.
++ * @member: the name of the hlist_node within the struct.
++ *
++ * This list-traversal primitive may safely run concurrently with
++ * the _rcu list-mutation primitives such as hlist_add_head_rcu()
++ * as long as the traversal is guarded by rcu_read_lock().
++ */
++#define hlist_for_each_entry_rcu(pos, head, member) \
++ for (pos = hlist_entry_safe (rcu_dereference_raw(hlist_first_rcu(head)),\
++ typeof(*(pos)), member); \
++ pos; \
++ pos = hlist_entry_safe(rcu_dereference_raw(hlist_next_rcu( \
++ &(pos)->member)), typeof(*(pos)), member))
++
++#undef sk_for_each
++#define sk_for_each(__sk, list) \
++ hlist_for_each_entry(__sk, list, sk_node)
++
++#define tty_flip_buffer_push(port) tty_flip_buffer_push((port)->tty)
++#define tty_insert_flip_string(port, chars, size) tty_insert_flip_string((port)->tty, chars, size)
++
++/**
++ * backport of:
++ *
++ * commit 496ad9aa8ef448058e36ca7a787c61f2e63f0f54
++ * Author: Al Viro <viro@zeniv.linux.org.uk>
++ * Date: Wed Jan 23 17:07:38 2013 -0500
++ *
++ * new helper: file_inode(file)
++ */
++static inline struct inode *file_inode(struct file *f)
++{
++ return f->f_path.dentry->d_inode;
++}
++
++#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)) */
++
++#endif /* LINUX_3_9_COMPAT_H */
diff --git a/package/mac80211/patches/130-mesh_pathtbl_backport.patch b/package/mac80211/patches/130-mesh_pathtbl_backport.patch
new file mode 100644
index 0000000..1322099
--- /dev/null
+++ b/package/mac80211/patches/130-mesh_pathtbl_backport.patch
@@ -0,0 +1,212 @@
+--- a/net/mac80211/mesh_pathtbl.c
++++ b/net/mac80211/mesh_pathtbl.c
+@@ -72,9 +72,9 @@ static inline struct mesh_table *resize_
+ * it's used twice. So it is illegal to do
+ * for_each_mesh_entry(rcu_dereference(...), ...)
+ */
+-#define for_each_mesh_entry(tbl, p, node, i) \
++#define for_each_mesh_entry(tbl, node, i) \
+ for (i = 0; i <= tbl->hash_mask; i++) \
+- hlist_for_each_entry_rcu(node, p, &tbl->hash_buckets[i], list)
++ hlist_for_each_entry_rcu(node, &tbl->hash_buckets[i], list)
+
+
+ static struct mesh_table *mesh_table_alloc(int size_order)
+@@ -139,7 +139,7 @@ static void mesh_table_free(struct mesh_
+ }
+ if (free_leafs) {
+ spin_lock_bh(&tbl->gates_lock);
+- hlist_for_each_entry_safe(gate, p, q,
++ hlist_for_each_entry_safe(gate, q,
+ tbl->known_gates, list) {
+ hlist_del(&gate->list);
+ kfree(gate);
+@@ -333,12 +333,11 @@ static struct mesh_path *mpath_lookup(st
+ struct ieee80211_sub_if_data *sdata)
+ {
+ struct mesh_path *mpath;
+- struct hlist_node *n;
+ struct hlist_head *bucket;
+ struct mpath_node *node;
+
+ bucket = &tbl->hash_buckets[mesh_table_hash(dst, sdata, tbl)];
+- hlist_for_each_entry_rcu(node, n, bucket, list) {
++ hlist_for_each_entry_rcu(node, bucket, list) {
+ mpath = node->mpath;
+ if (mpath->sdata == sdata &&
+ ether_addr_equal(dst, mpath->dst)) {
+@@ -389,11 +388,10 @@ mesh_path_lookup_by_idx(struct ieee80211
+ {
+ struct mesh_table *tbl = rcu_dereference(mesh_paths);
+ struct mpath_node *node;
+- struct hlist_node *p;
+ int i;
+ int j = 0;
+
+- for_each_mesh_entry(tbl, p, node, i) {
++ for_each_mesh_entry(tbl, node, i) {
+ if (sdata && node->mpath->sdata != sdata)
+ continue;
+ if (j++ == idx) {
+@@ -417,13 +415,12 @@ int mesh_path_add_gate(struct mesh_path
+ {
+ struct mesh_table *tbl;
+ struct mpath_node *gate, *new_gate;
+- struct hlist_node *n;
+ int err;
+
+ rcu_read_lock();
+ tbl = rcu_dereference(mesh_paths);
+
+- hlist_for_each_entry_rcu(gate, n, tbl->known_gates, list)
++ hlist_for_each_entry_rcu(gate, tbl->known_gates, list)
+ if (gate->mpath == mpath) {
+ err = -EEXIST;
+ goto err_rcu;
+@@ -460,9 +457,9 @@ err_rcu:
+ static void mesh_gate_del(struct mesh_table *tbl, struct mesh_path *mpath)
+ {
+ struct mpath_node *gate;
+- struct hlist_node *p, *q;
++ struct hlist_node *q;
+
+- hlist_for_each_entry_safe(gate, p, q, tbl->known_gates, list) {
++ hlist_for_each_entry_safe(gate, q, tbl->known_gates, list) {
+ if (gate->mpath != mpath)
+ continue;
+ spin_lock_bh(&tbl->gates_lock);
+@@ -504,7 +501,6 @@ int mesh_path_add(struct ieee80211_sub_i
+ struct mesh_path *mpath, *new_mpath;
+ struct mpath_node *node, *new_node;
+ struct hlist_head *bucket;
+- struct hlist_node *n;
+ int grow = 0;
+ int err = 0;
+ u32 hash_idx;
+@@ -550,7 +546,7 @@ int mesh_path_add(struct ieee80211_sub_i
+ spin_lock(&tbl->hashwlock[hash_idx]);
+
+ err = -EEXIST;
+- hlist_for_each_entry(node, n, bucket, list) {
++ hlist_for_each_entry(node, bucket, list) {
+ mpath = node->mpath;
+ if (mpath->sdata == sdata &&
+ ether_addr_equal(dst, mpath->dst))
+@@ -640,7 +636,6 @@ int mpp_path_add(struct ieee80211_sub_if
+ struct mesh_path *mpath, *new_mpath;
+ struct mpath_node *node, *new_node;
+ struct hlist_head *bucket;
+- struct hlist_node *n;
+ int grow = 0;
+ int err = 0;
+ u32 hash_idx;
+@@ -680,7 +675,7 @@ int mpp_path_add(struct ieee80211_sub_if
+ spin_lock(&tbl->hashwlock[hash_idx]);
+
+ err = -EEXIST;
+- hlist_for_each_entry(node, n, bucket, list) {
++ hlist_for_each_entry(node, bucket, list) {
+ mpath = node->mpath;
+ if (mpath->sdata == sdata &&
+ ether_addr_equal(dst, mpath->dst))
+@@ -725,14 +720,13 @@ void mesh_plink_broken(struct sta_info *
+ static const u8 bcast[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
+ struct mesh_path *mpath;
+ struct mpath_node *node;
+- struct hlist_node *p;
+ struct ieee80211_sub_if_data *sdata = sta->sdata;
+ int i;
+ __le16 reason = cpu_to_le16(WLAN_REASON_MESH_PATH_DEST_UNREACHABLE);
+
+ rcu_read_lock();
+ tbl = rcu_dereference(mesh_paths);
+- for_each_mesh_entry(tbl, p, node, i) {
++ for_each_mesh_entry(tbl, node, i) {
+ mpath = node->mpath;
+ if (rcu_dereference(mpath->next_hop) == sta &&
+ mpath->flags & MESH_PATH_ACTIVE &&
+@@ -792,13 +786,12 @@ void mesh_path_flush_by_nexthop(struct s
+ struct mesh_table *tbl;
+ struct mesh_path *mpath;
+ struct mpath_node *node;
+- struct hlist_node *p;
+ int i;
+
+ rcu_read_lock();
+ read_lock_bh(&pathtbl_resize_lock);
+ tbl = resize_dereference_mesh_paths();
+- for_each_mesh_entry(tbl, p, node, i) {
++ for_each_mesh_entry(tbl, node, i) {
+ mpath = node->mpath;
+ if (rcu_dereference(mpath->next_hop) == sta) {
+ spin_lock(&tbl->hashwlock[i]);
+@@ -815,11 +808,9 @@ static void table_flush_by_iface(struct
+ {
+ struct mesh_path *mpath;
+ struct mpath_node *node;
+- struct hlist_node *p;
+ int i;
+
+- WARN_ON(!rcu_read_lock_held());
+- for_each_mesh_entry(tbl, p, node, i) {
++ for_each_mesh_entry(tbl, node, i) {
+ mpath = node->mpath;
+ if (mpath->sdata != sdata)
+ continue;
+@@ -865,7 +856,6 @@ int mesh_path_del(struct ieee80211_sub_i
+ struct mesh_path *mpath;
+ struct mpath_node *node;
+ struct hlist_head *bucket;
+- struct hlist_node *n;
+ int hash_idx;
+ int err = 0;
+
+@@ -875,7 +865,7 @@ int mesh_path_del(struct ieee80211_sub_i
+ bucket = &tbl->hash_buckets[hash_idx];
+
+ spin_lock(&tbl->hashwlock[hash_idx]);
+- hlist_for_each_entry(node, n, bucket, list) {
++ hlist_for_each_entry(node, bucket, list) {
+ mpath = node->mpath;
+ if (mpath->sdata == sdata &&
+ ether_addr_equal(addr, mpath->dst)) {
+@@ -920,7 +910,6 @@ void mesh_path_tx_pending(struct mesh_pa
+ int mesh_path_send_to_gates(struct mesh_path *mpath)
+ {
+ struct ieee80211_sub_if_data *sdata = mpath->sdata;
+- struct hlist_node *n;
+ struct mesh_table *tbl;
+ struct mesh_path *from_mpath = mpath;
+ struct mpath_node *gate = NULL;
+@@ -935,7 +924,7 @@ int mesh_path_send_to_gates(struct mesh_
+ if (!known_gates)
+ return -EHOSTUNREACH;
+
+- hlist_for_each_entry_rcu(gate, n, known_gates, list) {
++ hlist_for_each_entry_rcu(gate, known_gates, list) {
+ if (gate->mpath->sdata != sdata)
+ continue;
+
+@@ -951,7 +940,7 @@ int mesh_path_send_to_gates(struct mesh_
+ }
+ }
+
+- hlist_for_each_entry_rcu(gate, n, known_gates, list)
++ hlist_for_each_entry_rcu(gate, known_gates, list)
+ if (gate->mpath->sdata == sdata) {
+ mpath_dbg(sdata, "Sending to %pM\n", gate->mpath->dst);
+ mesh_path_tx_pending(gate->mpath);
+@@ -1096,12 +1085,11 @@ void mesh_path_expire(struct ieee80211_s
+ struct mesh_table *tbl;
+ struct mesh_path *mpath;
+ struct mpath_node *node;
+- struct hlist_node *p;
+ int i;
+
+ rcu_read_lock();
+ tbl = rcu_dereference(mesh_paths);
+- for_each_mesh_entry(tbl, p, node, i) {
++ for_each_mesh_entry(tbl, node, i) {
+ if (node->mpath->sdata != sdata)
+ continue;
+ mpath = node->mpath;
diff --git a/package/mac80211/patches/150-disable_addr_notifier.patch b/package/mac80211/patches/150-disable_addr_notifier.patch
new file mode 100644
index 0000000..9714696
--- /dev/null
+++ b/package/mac80211/patches/150-disable_addr_notifier.patch
@@ -0,0 +1,67 @@
+--- a/net/mac80211/main.c
++++ b/net/mac80211/main.c
+@@ -313,7 +313,7 @@ void ieee80211_restart_hw(struct ieee802
+ }
+ EXPORT_SYMBOL(ieee80211_restart_hw);
+
+-#ifdef CONFIG_INET
++#ifdef __disabled__CONFIG_INET
+ static int ieee80211_ifa_changed(struct notifier_block *nb,
+ unsigned long data, void *arg)
+ {
+@@ -372,7 +372,7 @@ static int ieee80211_ifa_changed(struct
+ }
+ #endif
+
+-#if IS_ENABLED(CONFIG_IPV6)
++#if IS_ENABLED(__disabled__CONFIG_IPV6)
+ static int ieee80211_ifa6_changed(struct notifier_block *nb,
+ unsigned long data, void *arg)
+ {
+@@ -1015,14 +1015,14 @@ int ieee80211_register_hw(struct ieee802
+ goto fail_pm_qos;
+ }
+
+-#ifdef CONFIG_INET
++#ifdef __disabled__CONFIG_INET
+ local->ifa_notifier.notifier_call = ieee80211_ifa_changed;
+ result = register_inetaddr_notifier(&local->ifa_notifier);
+ if (result)
+ goto fail_ifa;
+ #endif
+
+-#if IS_ENABLED(CONFIG_IPV6)
++#if IS_ENABLED(__disabled__CONFIG_IPV6)
+ local->ifa6_notifier.notifier_call = ieee80211_ifa6_changed;
+ result = register_inet6addr_notifier(&local->ifa6_notifier);
+ if (result)
+@@ -1034,13 +1034,13 @@ int ieee80211_register_hw(struct ieee802
+
+ return 0;
+
+-#if IS_ENABLED(CONFIG_IPV6)
++#if IS_ENABLED(__disabled__CONFIG_IPV6)
+ fail_ifa6:
+-#ifdef CONFIG_INET
++#ifdef __disabled__CONFIG_INET
+ unregister_inetaddr_notifier(&local->ifa_notifier);
+ #endif
+ #endif
+-#if defined(CONFIG_INET) || defined(CONFIG_IPV6)
++#if defined(__disabled__CONFIG_INET) || defined(__disabled__CONFIG_IPV6)
+ fail_ifa:
+ pm_qos_remove_notifier(PM_QOS_NETWORK_LATENCY,
+ &local->network_latency_notifier);
+@@ -1073,10 +1073,10 @@ void ieee80211_unregister_hw(struct ieee
+
+ pm_qos_remove_notifier(PM_QOS_NETWORK_LATENCY,
+ &local->network_latency_notifier);
+-#ifdef CONFIG_INET
++#ifdef __disabled__CONFIG_INET
+ unregister_inetaddr_notifier(&local->ifa_notifier);
+ #endif
+-#if IS_ENABLED(CONFIG_IPV6)
++#if IS_ENABLED(__disabled__CONFIG_IPV6)
+ unregister_inet6addr_notifier(&local->ifa6_notifier);
+ #endif
+
diff --git a/package/mac80211/patches/201-ath5k-WAR-for-AR71xx-PCI-bug.patch b/package/mac80211/patches/201-ath5k-WAR-for-AR71xx-PCI-bug.patch
new file mode 100644
index 0000000..9e08a08
--- /dev/null
+++ b/package/mac80211/patches/201-ath5k-WAR-for-AR71xx-PCI-bug.patch
@@ -0,0 +1,38 @@
+--- a/drivers/net/wireless/ath/ath5k/initvals.c
++++ b/drivers/net/wireless/ath/ath5k/initvals.c
+@@ -65,8 +65,14 @@ static const struct ath5k_ini ar5210_ini
+ { AR5K_IMR, 0 },
+ { AR5K_IER, AR5K_IER_DISABLE },
+ { AR5K_BSR, 0, AR5K_INI_READ },
++#if !defined(CONFIG_ATHEROS_AR71XX) && !defined(CONFIG_ATH79)
+ { AR5K_TXCFG, AR5K_DMASIZE_128B },
+ { AR5K_RXCFG, AR5K_DMASIZE_128B },
++#else
++ /* WAR for AR71xx PCI bug */
++ { AR5K_TXCFG, AR5K_DMASIZE_128B },
++ { AR5K_RXCFG, AR5K_DMASIZE_4B },
++#endif
+ { AR5K_CFG, AR5K_INIT_CFG },
+ { AR5K_TOPS, 8 },
+ { AR5K_RXNOFRM, 8 },
+--- a/drivers/net/wireless/ath/ath5k/dma.c
++++ b/drivers/net/wireless/ath/ath5k/dma.c
+@@ -863,10 +863,18 @@ ath5k_hw_dma_init(struct ath5k_hw *ah)
+ * guess we can tweak it and see how it goes ;-)
+ */
+ if (ah->ah_version != AR5K_AR5210) {
++#if !defined(CONFIG_ATHEROS_AR71XX) && !defined(CONFIG_ATH79)
+ AR5K_REG_WRITE_BITS(ah, AR5K_TXCFG,
+ AR5K_TXCFG_SDMAMR, AR5K_DMASIZE_128B);
+ AR5K_REG_WRITE_BITS(ah, AR5K_RXCFG,
+ AR5K_RXCFG_SDMAMW, AR5K_DMASIZE_128B);
++#else
++ /* WAR for AR71xx PCI bug */
++ AR5K_REG_WRITE_BITS(ah, AR5K_TXCFG,
++ AR5K_TXCFG_SDMAMR, AR5K_DMASIZE_128B);
++ AR5K_REG_WRITE_BITS(ah, AR5K_RXCFG,
++ AR5K_RXCFG_SDMAMW, AR5K_DMASIZE_4B);
++#endif
+ }
+
+ /* Pre-enable interrupts on 5211/5212*/
diff --git a/package/mac80211/patches/300-pending_work.patch b/package/mac80211/patches/300-pending_work.patch
new file mode 100644
index 0000000..cf51aae
--- /dev/null
+++ b/package/mac80211/patches/300-pending_work.patch
@@ -0,0 +1,963 @@
+--- a/drivers/net/wireless/ath/ath9k/common.h
++++ b/drivers/net/wireless/ath/ath9k/common.h
+@@ -27,7 +27,7 @@
+ #define WME_MAX_BA WME_BA_BMP_SIZE
+ #define ATH_TID_MAX_BUFS (2 * WME_MAX_BA)
+
+-#define ATH_RSSI_DUMMY_MARKER 0x127
++#define ATH_RSSI_DUMMY_MARKER 127
+ #define ATH_RSSI_LPF_LEN 10
+ #define RSSI_LPF_THRESHOLD -20
+ #define ATH_RSSI_EP_MULTIPLIER (1<<7)
+--- a/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
++++ b/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
+@@ -1067,15 +1067,19 @@ static bool ath9k_rx_prepare(struct ath9
+
+ last_rssi = priv->rx.last_rssi;
+
+- if (likely(last_rssi != ATH_RSSI_DUMMY_MARKER))
+- rxbuf->rxstatus.rs_rssi = ATH_EP_RND(last_rssi,
+- ATH_RSSI_EP_MULTIPLIER);
++ if (ieee80211_is_beacon(hdr->frame_control) &&
++ !is_zero_ether_addr(common->curbssid) &&
++ ether_addr_equal(hdr->addr3, common->curbssid)) {
++ s8 rssi = rxbuf->rxstatus.rs_rssi;
+
+- if (rxbuf->rxstatus.rs_rssi < 0)
+- rxbuf->rxstatus.rs_rssi = 0;
++ if (likely(last_rssi != ATH_RSSI_DUMMY_MARKER))
++ rssi = ATH_EP_RND(last_rssi, ATH_RSSI_EP_MULTIPLIER);
+
+- if (ieee80211_is_beacon(fc))
+- priv->ah->stats.avgbrssi = rxbuf->rxstatus.rs_rssi;
++ if (rssi < 0)
++ rssi = 0;
++
++ priv->ah->stats.avgbrssi = rssi;
++ }
+
+ rx_status->mactime = be64_to_cpu(rxbuf->rxstatus.rs_tstamp);
+ rx_status->band = hw->conf.channel->band;
+--- a/include/linux/ieee80211.h
++++ b/include/linux/ieee80211.h
+@@ -185,7 +185,7 @@ struct ieee80211_hdr {
+ u8 addr3[6];
+ __le16 seq_ctrl;
+ u8 addr4[6];
+-} __packed;
++} __packed __aligned(2);
+
+ struct ieee80211_hdr_3addr {
+ __le16 frame_control;
+@@ -194,7 +194,7 @@ struct ieee80211_hdr_3addr {
+ u8 addr2[6];
+ u8 addr3[6];
+ __le16 seq_ctrl;
+-} __packed;
++} __packed __aligned(2);
+
+ struct ieee80211_qos_hdr {
+ __le16 frame_control;
+@@ -204,7 +204,7 @@ struct ieee80211_qos_hdr {
+ u8 addr3[6];
+ __le16 seq_ctrl;
+ __le16 qos_ctrl;
+-} __packed;
++} __packed __aligned(2);
+
+ /**
+ * ieee80211_has_tods - check if IEEE80211_FCTL_TODS is set
+@@ -581,7 +581,7 @@ struct ieee80211s_hdr {
+ __le32 seqnum;
+ u8 eaddr1[6];
+ u8 eaddr2[6];
+-} __packed;
++} __packed __aligned(2);
+
+ /* Mesh flags */
+ #define MESH_FLAGS_AE_A4 0x1
+@@ -875,7 +875,7 @@ struct ieee80211_mgmt {
+ } u;
+ } __packed action;
+ } u;
+-} __packed;
++} __packed __aligned(2);
+
+ /* Supported Rates value encodings in 802.11n-2009 7.3.2.2 */
+ #define BSS_MEMBERSHIP_SELECTOR_HT_PHY 127
+@@ -906,20 +906,20 @@ struct ieee80211_rts {
+ __le16 duration;
+ u8 ra[6];
+ u8 ta[6];
+-} __packed;
++} __packed __aligned(2);
+
+ struct ieee80211_cts {
+ __le16 frame_control;
+ __le16 duration;
+ u8 ra[6];
+-} __packed;
++} __packed __aligned(2);
+
+ struct ieee80211_pspoll {
+ __le16 frame_control;
+ __le16 aid;
+ u8 bssid[6];
+ u8 ta[6];
+-} __packed;
++} __packed __aligned(2);
+
+ /* TDLS */
+
+--- a/net/mac80211/agg-rx.c
++++ b/net/mac80211/agg-rx.c
+@@ -204,6 +204,8 @@ static void ieee80211_send_addba_resp(st
+ memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
+ else if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
+ memcpy(mgmt->bssid, sdata->u.ibss.bssid, ETH_ALEN);
++ else if (sdata->vif.type == NL80211_IFTYPE_WDS)
++ memcpy(mgmt->bssid, da, ETH_ALEN);
+
+ mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
+ IEEE80211_STYPE_ACTION);
+--- a/net/mac80211/agg-tx.c
++++ b/net/mac80211/agg-tx.c
+@@ -81,7 +81,8 @@ static void ieee80211_send_addba_request
+ memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
+ if (sdata->vif.type == NL80211_IFTYPE_AP ||
+ sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
+- sdata->vif.type == NL80211_IFTYPE_MESH_POINT)
++ sdata->vif.type == NL80211_IFTYPE_MESH_POINT ||
++ sdata->vif.type == NL80211_IFTYPE_WDS)
+ memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN);
+ else if (sdata->vif.type == NL80211_IFTYPE_STATION)
+ memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
+@@ -527,6 +528,7 @@ int ieee80211_start_tx_ba_session(struct
+ sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
+ sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
+ sdata->vif.type != NL80211_IFTYPE_AP &&
++ sdata->vif.type != NL80211_IFTYPE_WDS &&
+ sdata->vif.type != NL80211_IFTYPE_ADHOC)
+ return -EINVAL;
+
+--- a/net/mac80211/debugfs_sta.c
++++ b/net/mac80211/debugfs_sta.c
+@@ -65,11 +65,11 @@ static ssize_t sta_flags_read(struct fil
+ test_sta_flag(sta, WLAN_STA_##flg) ? #flg "\n" : ""
+
+ int res = scnprintf(buf, sizeof(buf),
+- "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
++ "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
+ TEST(AUTH), TEST(ASSOC), TEST(PS_STA),
+ TEST(PS_DRIVER), TEST(AUTHORIZED),
+ TEST(SHORT_PREAMBLE),
+- TEST(WME), TEST(WDS), TEST(CLEAR_PS_FILT),
++ TEST(WME), TEST(CLEAR_PS_FILT),
+ TEST(MFP), TEST(BLOCK_BA), TEST(PSPOLL),
+ TEST(UAPSD), TEST(SP), TEST(TDLS_PEER),
+ TEST(TDLS_PEER_AUTH), TEST(4ADDR_EVENT),
+--- a/net/mac80211/iface.c
++++ b/net/mac80211/iface.c
+@@ -107,7 +107,7 @@ void ieee80211_recalc_idle(struct ieee80
+
+ lockdep_assert_held(&local->mtx);
+
+- active = !list_empty(&local->chanctx_list);
++ active = !list_empty(&local->chanctx_list) || local->monitors;
+
+ if (!local->ops->remain_on_channel) {
+ list_for_each_entry(roc, &local->roc_list, list) {
+@@ -436,7 +436,6 @@ int ieee80211_do_open(struct wireless_de
+ struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
+ struct net_device *dev = wdev->netdev;
+ struct ieee80211_local *local = sdata->local;
+- struct sta_info *sta;
+ u32 changed = 0;
+ int res;
+ u32 hw_reconf_flags = 0;
+@@ -541,6 +540,9 @@ int ieee80211_do_open(struct wireless_de
+
+ ieee80211_adjust_monitor_flags(sdata, 1);
+ ieee80211_configure_filter(local);
++ mutex_lock(&local->mtx);
++ ieee80211_recalc_idle(local);
++ mutex_unlock(&local->mtx);
+
+ netif_carrier_on(dev);
+ break;
+@@ -595,30 +597,8 @@ int ieee80211_do_open(struct wireless_de
+
+ set_bit(SDATA_STATE_RUNNING, &sdata->state);
+
+- if (sdata->vif.type == NL80211_IFTYPE_WDS) {
+- /* Create STA entry for the WDS peer */
+- sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
+- GFP_KERNEL);
+- if (!sta) {
+- res = -ENOMEM;
+- goto err_del_interface;
+- }
+-
+- sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
+- sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
+- sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED);
+-
+- res = sta_info_insert(sta);
+- if (res) {
+- /* STA has been freed */
+- goto err_del_interface;
+- }
+-
+- rate_control_rate_init(sta);
+- netif_carrier_on(dev);
+- } else if (sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE) {
++ if (sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE)
+ rcu_assign_pointer(local->p2p_sdata, sdata);
+- }
+
+ /*
+ * set_multicast_list will be invoked by the networking core
+@@ -817,6 +797,9 @@ static void ieee80211_do_stop(struct iee
+
+ ieee80211_adjust_monitor_flags(sdata, -1);
+ ieee80211_configure_filter(local);
++ mutex_lock(&local->mtx);
++ ieee80211_recalc_idle(local);
++ mutex_unlock(&local->mtx);
+ break;
+ case NL80211_IFTYPE_P2P_DEVICE:
+ /* relies on synchronize_rcu() below */
+@@ -1022,6 +1005,72 @@ static void ieee80211_if_setup(struct ne
+ dev->destructor = free_netdev;
+ }
+
++static void ieee80211_wds_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
++ struct sk_buff *skb)
++{
++ struct ieee80211_local *local = sdata->local;
++ struct ieee80211_rx_status *rx_status;
++ struct ieee802_11_elems elems;
++ struct ieee80211_mgmt *mgmt;
++ struct sta_info *sta;
++ size_t baselen;
++ u32 rates = 0;
++ u16 stype;
++ bool new = false;
++ enum ieee80211_band band = local->hw.conf.channel->band;
++ struct ieee80211_supported_band *sband = local->hw.wiphy->bands[band];
++
++ rx_status = IEEE80211_SKB_RXCB(skb);
++ mgmt = (struct ieee80211_mgmt *) skb->data;
++ stype = le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE;
++
++ if (stype != IEEE80211_STYPE_BEACON)
++ return;
++
++ baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
++ if (baselen > skb->len)
++ return;
++
++ ieee802_11_parse_elems(mgmt->u.probe_resp.variable,
++ skb->len - baselen, &elems);
++
++ rates = ieee80211_sta_get_rates(local, &elems, band, NULL);
++
++ rcu_read_lock();
++
++ sta = sta_info_get(sdata, sdata->u.wds.remote_addr);
++
++ if (!sta) {
++ rcu_read_unlock();
++ sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
++ GFP_KERNEL);
++ if (!sta)
++ return;
++
++ new = true;
++ }
++
++ sta->last_rx = jiffies;
++ sta->sta.supp_rates[local->hw.conf.channel->band] = rates;
++
++ if (elems.ht_cap_elem)
++ ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband,
++ elems.ht_cap_elem, sta);
++
++ if (elems.wmm_param)
++ set_sta_flag(sta, WLAN_STA_WME);
++
++ if (new) {
++ sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
++ sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
++ sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED);
++ rate_control_rate_init(sta);
++ sta_info_insert_rcu(sta);
++ }
++
++ rcu_read_unlock();
++}
++
+ static void ieee80211_iface_work(struct work_struct *work)
+ {
+ struct ieee80211_sub_if_data *sdata =
+@@ -1126,6 +1175,9 @@ static void ieee80211_iface_work(struct
+ break;
+ ieee80211_mesh_rx_queued_mgmt(sdata, skb);
+ break;
++ case NL80211_IFTYPE_WDS:
++ ieee80211_wds_rx_queued_mgmt(sdata, skb);
++ break;
+ default:
+ WARN(1, "frame for unexpected interface type");
+ break;
+--- a/net/mac80211/rx.c
++++ b/net/mac80211/rx.c
+@@ -2365,6 +2365,7 @@ ieee80211_rx_h_action(struct ieee80211_r
+ sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
+ sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
+ sdata->vif.type != NL80211_IFTYPE_AP &&
++ sdata->vif.type != NL80211_IFTYPE_WDS &&
+ sdata->vif.type != NL80211_IFTYPE_ADHOC)
+ break;
+
+@@ -2692,14 +2693,15 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_
+
+ if (!ieee80211_vif_is_mesh(&sdata->vif) &&
+ sdata->vif.type != NL80211_IFTYPE_ADHOC &&
+- sdata->vif.type != NL80211_IFTYPE_STATION)
++ sdata->vif.type != NL80211_IFTYPE_STATION &&
++ sdata->vif.type != NL80211_IFTYPE_WDS)
+ return RX_DROP_MONITOR;
+
+ switch (stype) {
+ case cpu_to_le16(IEEE80211_STYPE_AUTH):
+ case cpu_to_le16(IEEE80211_STYPE_BEACON):
+ case cpu_to_le16(IEEE80211_STYPE_PROBE_RESP):
+- /* process for all: mesh, mlme, ibss */
++ /* process for all: mesh, mlme, ibss, wds */
+ break;
+ case cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP):
+ case cpu_to_le16(IEEE80211_STYPE_REASSOC_RESP):
+@@ -3028,10 +3030,16 @@ static int prepare_for_handlers(struct i
+ }
+ break;
+ case NL80211_IFTYPE_WDS:
+- if (bssid || !ieee80211_is_data(hdr->frame_control))
+- return 0;
+ if (!ether_addr_equal(sdata->u.wds.remote_addr, hdr->addr2))
+ return 0;
++
++ if (ieee80211_is_data(hdr->frame_control) ||
++ ieee80211_is_action(hdr->frame_control)) {
++ if (compare_ether_addr(sdata->vif.addr, hdr->addr1))
++ return 0;
++ } else if (!ieee80211_is_beacon(hdr->frame_control))
++ return 0;
++
+ break;
+ case NL80211_IFTYPE_P2P_DEVICE:
+ if (!ieee80211_is_public_action(hdr, skb->len) &&
+--- a/net/mac80211/sta_info.h
++++ b/net/mac80211/sta_info.h
+@@ -32,7 +32,6 @@
+ * @WLAN_STA_SHORT_PREAMBLE: Station is capable of receiving short-preamble
+ * frames.
+ * @WLAN_STA_WME: Station is a QoS-STA.
+- * @WLAN_STA_WDS: Station is one of our WDS peers.
+ * @WLAN_STA_CLEAR_PS_FILT: Clear PS filter in hardware (using the
+ * IEEE80211_TX_CTL_CLEAR_PS_FILT control flag) when the next
+ * frame to this station is transmitted.
+@@ -66,7 +65,6 @@ enum ieee80211_sta_info_flags {
+ WLAN_STA_AUTHORIZED,
+ WLAN_STA_SHORT_PREAMBLE,
+ WLAN_STA_WME,
+- WLAN_STA_WDS,
+ WLAN_STA_CLEAR_PS_FILT,
+ WLAN_STA_MFP,
+ WLAN_STA_BLOCK_BA,
+--- a/net/mac80211/tx.c
++++ b/net/mac80211/tx.c
+@@ -1231,34 +1231,40 @@ static bool ieee80211_tx_frags(struct ie
+ if (local->queue_stop_reasons[q] ||
+ (!txpending && !skb_queue_empty(&local->pending[q]))) {
+ if (unlikely(info->flags &
+- IEEE80211_TX_INTFL_OFFCHAN_TX_OK &&
+- local->queue_stop_reasons[q] &
+- ~BIT(IEEE80211_QUEUE_STOP_REASON_OFFCHANNEL))) {
++ IEEE80211_TX_INTFL_OFFCHAN_TX_OK)) {
++ if (local->queue_stop_reasons[q] &
++ ~BIT(IEEE80211_QUEUE_STOP_REASON_OFFCHANNEL)) {
++ /*
++ * Drop off-channel frames if queues
++ * are stopped for any reason other
++ * than off-channel operation. Never
++ * queue them.
++ */
++ spin_unlock_irqrestore(
++ &local->queue_stop_reason_lock,
++ flags);
++ ieee80211_purge_tx_queue(&local->hw,
++ skbs);
++ return true;
++ }
++ } else {
++
+ /*
+- * Drop off-channel frames if queues are stopped
+- * for any reason other than off-channel
+- * operation. Never queue them.
++ * Since queue is stopped, queue up frames for
++ * later transmission from the tx-pending
++ * tasklet when the queue is woken again.
+ */
+- spin_unlock_irqrestore(
+- &local->queue_stop_reason_lock, flags);
+- ieee80211_purge_tx_queue(&local->hw, skbs);
+- return true;
++ if (txpending)
++ skb_queue_splice_init(skbs,
++ &local->pending[q]);
++ else
++ skb_queue_splice_tail_init(skbs,
++ &local->pending[q]);
++
++ spin_unlock_irqrestore(&local->queue_stop_reason_lock,
++ flags);
++ return false;
+ }
+-
+- /*
+- * Since queue is stopped, queue up frames for later
+- * transmission from the tx-pending tasklet when the
+- * queue is woken again.
+- */
+- if (txpending)
+- skb_queue_splice_init(skbs, &local->pending[q]);
+- else
+- skb_queue_splice_tail_init(skbs,
+- &local->pending[q]);
+-
+- spin_unlock_irqrestore(&local->queue_stop_reason_lock,
+- flags);
+- return false;
+ }
+ spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
+
+@@ -1848,9 +1854,24 @@ netdev_tx_t ieee80211_subif_start_xmit(s
+ }
+
+ if (!is_multicast_ether_addr(skb->data)) {
++ struct sta_info *next_hop;
++ bool mpp_lookup = true;
++
+ mpath = mesh_path_lookup(sdata, skb->data);
+- if (!mpath)
++ if (mpath) {
++ mpp_lookup = false;
++ next_hop = rcu_dereference(mpath->next_hop);
++ if (!next_hop ||
++ !(mpath->flags & (MESH_PATH_ACTIVE |
++ MESH_PATH_RESOLVING)))
++ mpp_lookup = true;
++ }
++
++ if (mpp_lookup)
+ mppath = mpp_path_lookup(sdata, skb->data);
++
++ if (mppath && mpath)
++ mesh_path_del(mpath->sdata, mpath->dst);
+ }
+
+ /*
+--- a/net/wireless/nl80211.c
++++ b/net/wireless/nl80211.c
+@@ -554,16 +554,9 @@ static int nl80211_msg_put_channel(struc
+ if ((chan->flags & IEEE80211_CHAN_NO_IBSS) &&
+ nla_put_flag(msg, NL80211_FREQUENCY_ATTR_NO_IBSS))
+ goto nla_put_failure;
+- if (chan->flags & IEEE80211_CHAN_RADAR) {
+- u32 time = elapsed_jiffies_msecs(chan->dfs_state_entered);
+- if (nla_put_flag(msg, NL80211_FREQUENCY_ATTR_RADAR))
+- goto nla_put_failure;
+- if (nla_put_u32(msg, NL80211_FREQUENCY_ATTR_DFS_STATE,
+- chan->dfs_state))
+- goto nla_put_failure;
+- if (nla_put_u32(msg, NL80211_FREQUENCY_ATTR_DFS_TIME, time))
+- goto nla_put_failure;
+- }
++ if ((chan->flags & IEEE80211_CHAN_RADAR) &&
++ nla_put_flag(msg, NL80211_FREQUENCY_ATTR_RADAR))
++ goto nla_put_failure;
+ if ((chan->flags & IEEE80211_CHAN_NO_HT40MINUS) &&
+ nla_put_flag(msg, NL80211_FREQUENCY_ATTR_NO_HT40_MINUS))
+ goto nla_put_failure;
+@@ -900,9 +893,6 @@ static int nl80211_put_iface_combination
+ nla_put_u32(msg, NL80211_IFACE_COMB_MAXNUM,
+ c->max_interfaces))
+ goto nla_put_failure;
+- if (nla_put_u32(msg, NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS,
+- c->radar_detect_widths))
+- goto nla_put_failure;
+
+ nla_nest_end(msg, nl_combi);
+ }
+@@ -914,48 +904,6 @@ nla_put_failure:
+ return -ENOBUFS;
+ }
+
+-#ifdef CONFIG_PM
+-static int nl80211_send_wowlan_tcp_caps(struct cfg80211_registered_device *rdev,
+- struct sk_buff *msg)
+-{
+- const struct wiphy_wowlan_tcp_support *tcp = rdev->wiphy.wowlan.tcp;
+- struct nlattr *nl_tcp;
+-
+- if (!tcp)
+- return 0;
+-
+- nl_tcp = nla_nest_start(msg, NL80211_WOWLAN_TRIG_TCP_CONNECTION);
+- if (!nl_tcp)
+- return -ENOBUFS;
+-
+- if (nla_put_u32(msg, NL80211_WOWLAN_TCP_DATA_PAYLOAD,
+- tcp->data_payload_max))
+- return -ENOBUFS;
+-
+- if (nla_put_u32(msg, NL80211_WOWLAN_TCP_DATA_PAYLOAD,
+- tcp->data_payload_max))
+- return -ENOBUFS;
+-
+- if (tcp->seq && nla_put_flag(msg, NL80211_WOWLAN_TCP_DATA_PAYLOAD_SEQ))
+- return -ENOBUFS;
+-
+- if (tcp->tok && nla_put(msg, NL80211_WOWLAN_TCP_DATA_PAYLOAD_TOKEN,
+- sizeof(*tcp->tok), tcp->tok))
+- return -ENOBUFS;
+-
+- if (nla_put_u32(msg, NL80211_WOWLAN_TCP_DATA_INTERVAL,
+- tcp->data_interval_max))
+- return -ENOBUFS;
+-
+- if (nla_put_u32(msg, NL80211_WOWLAN_TCP_WAKE_PAYLOAD,
+- tcp->wake_payload_max))
+- return -ENOBUFS;
+-
+- nla_nest_end(msg, nl_tcp);
+- return 0;
+-}
+-#endif
+-
+ static int nl80211_send_wiphy(struct sk_buff *msg, u32 portid, u32 seq, int flags,
+ struct cfg80211_registered_device *dev)
+ {
+@@ -1330,9 +1278,6 @@ static int nl80211_send_wiphy(struct sk_
+ goto nla_put_failure;
+ }
+
+- if (nl80211_send_wowlan_tcp_caps(dev, msg))
+- goto nla_put_failure;
+-
+ nla_nest_end(msg, nl_wowlan);
+ }
+ #endif
+--- a/net/mac80211/cfg.c
++++ b/net/mac80211/cfg.c
+@@ -3285,13 +3285,19 @@ static int ieee80211_cfg_get_channel(str
+ struct cfg80211_chan_def *chandef)
+ {
+ struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
++ struct ieee80211_local *local = wiphy_priv(wiphy);
+ struct ieee80211_chanctx_conf *chanctx_conf;
+ int ret = -ENODATA;
+
+ rcu_read_lock();
+- chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
+- if (chanctx_conf) {
+- *chandef = chanctx_conf->def;
++ if (local->use_chanctx) {
++ chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
++ if (chanctx_conf) {
++ *chandef = chanctx_conf->def;
++ ret = 0;
++ }
++ } else if (local->open_count == local->monitors) {
++ *chandef = local->monitor_chandef;
+ ret = 0;
+ }
+ rcu_read_unlock();
+--- a/drivers/net/wireless/ath/ath9k/hw.c
++++ b/drivers/net/wireless/ath/ath9k/hw.c
+@@ -1463,7 +1463,9 @@ static bool ath9k_hw_chip_reset(struct a
+ reset_type = ATH9K_RESET_POWER_ON;
+ else
+ reset_type = ATH9K_RESET_COLD;
+- }
++ } else if (ah->chip_fullsleep || REG_READ(ah, AR_Q_TXE) ||
++ (REG_READ(ah, AR_CR) & AR_CR_RXE))
++ reset_type = ATH9K_RESET_COLD;
+
+ if (!ath9k_hw_set_reset_reg(ah, reset_type))
+ return false;
+--- a/drivers/net/wireless/rt2x00/rt2x00dev.c
++++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
+@@ -1236,8 +1236,10 @@ static inline void rt2x00lib_set_if_comb
+ */
+ if_limit = &rt2x00dev->if_limits_ap;
+ if_limit->max = rt2x00dev->ops->max_ap_intf;
+- if_limit->types = BIT(NL80211_IFTYPE_AP) |
+- BIT(NL80211_IFTYPE_MESH_POINT);
++ if_limit->types = BIT(NL80211_IFTYPE_AP);
++#ifdef CONFIG_MAC80211_MESH
++ if_limit->types |= BIT(NL80211_IFTYPE_MESH_POINT);
++#endif
+
+ /*
+ * Build up AP interface combinations structure.
+@@ -1309,7 +1311,9 @@ int rt2x00lib_probe_dev(struct rt2x00_de
+ rt2x00dev->hw->wiphy->interface_modes |=
+ BIT(NL80211_IFTYPE_ADHOC) |
+ BIT(NL80211_IFTYPE_AP) |
++#ifdef CONFIG_MAC80211_MESH
+ BIT(NL80211_IFTYPE_MESH_POINT) |
++#endif
+ BIT(NL80211_IFTYPE_WDS);
+
+ rt2x00dev->hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN;
+--- a/net/mac80211/rc80211_minstrel_ht.c
++++ b/net/mac80211/rc80211_minstrel_ht.c
+@@ -26,11 +26,11 @@
+ /* Number of symbols for a packet with (bps) bits per symbol */
+ #define MCS_NSYMS(bps) ((MCS_NBITS + (bps) - 1) / (bps))
+
+-/* Transmission time for a packet containing (syms) symbols */
++/* Transmission time (nanoseconds) for a packet containing (syms) symbols */
+ #define MCS_SYMBOL_TIME(sgi, syms) \
+ (sgi ? \
+- ((syms) * 18 + 4) / 5 : /* syms * 3.6 us */ \
+- (syms) << 2 /* syms * 4 us */ \
++ ((syms) * 18000 + 4000) / 5 : /* syms * 3.6 us */ \
++ ((syms) * 1000) << 2 /* syms * 4 us */ \
+ )
+
+ /* Transmit duration for the raw data part of an average sized packet */
+@@ -64,9 +64,9 @@
+ }
+
+ #define CCK_DURATION(_bitrate, _short, _len) \
+- (10 /* SIFS */ + \
++ (1000 * (10 /* SIFS */ + \
+ (_short ? 72 + 24 : 144 + 48 ) + \
+- (8 * (_len + 4) * 10) / (_bitrate))
++ (8 * (_len + 4) * 10) / (_bitrate)))
+
+ #define CCK_ACK_DURATION(_bitrate, _short) \
+ (CCK_DURATION((_bitrate > 10 ? 20 : 10), false, 60) + \
+@@ -211,20 +211,32 @@ static void
+ minstrel_ht_calc_tp(struct minstrel_ht_sta *mi, int group, int rate)
+ {
+ struct minstrel_rate_stats *mr;
+- unsigned int usecs = 0;
++ unsigned int nsecs = 0;
++ unsigned int tp;
++ unsigned int prob;
+
+ mr = &mi->groups[group].rates[rate];
++ prob = mr->probability;
+
+- if (mr->probability < MINSTREL_FRAC(1, 10)) {
++ if (prob < MINSTREL_FRAC(1, 10)) {
+ mr->cur_tp = 0;
+ return;
+ }
+
++ /*
++ * For the throughput calculation, limit the probability value to 90% to
++ * account for collision related packet error rate fluctuation
++ */
++ if (prob > MINSTREL_FRAC(9, 10))
++ prob = MINSTREL_FRAC(9, 10);
++
+ if (group != MINSTREL_CCK_GROUP)
+- usecs = mi->overhead / MINSTREL_TRUNC(mi->avg_ampdu_len);
++ nsecs = 1000 * mi->overhead / MINSTREL_TRUNC(mi->avg_ampdu_len);
+
+- usecs += minstrel_mcs_groups[group].duration[rate];
+- mr->cur_tp = MINSTREL_TRUNC((1000000 / usecs) * mr->probability);
++ nsecs += minstrel_mcs_groups[group].duration[rate];
++ tp = 1000000 * ((mr->probability * 1000) / nsecs);
++
++ mr->cur_tp = MINSTREL_TRUNC(tp);
+ }
+
+ /*
+@@ -308,8 +320,8 @@ minstrel_ht_update_stats(struct minstrel
+ }
+ }
+
+- /* try to sample up to half of the available rates during each interval */
+- mi->sample_count *= 4;
++ /* try to sample all available rates during each interval */
++ mi->sample_count *= 8;
+
+ cur_prob = 0;
+ cur_prob_tp = 0;
+@@ -320,20 +332,13 @@ minstrel_ht_update_stats(struct minstrel
+ if (!mg->supported)
+ continue;
+
+- mr = minstrel_get_ratestats(mi, mg->max_prob_rate);
+- if (cur_prob_tp < mr->cur_tp &&
+- minstrel_mcs_groups[group].streams == 1) {
+- mi->max_prob_rate = mg->max_prob_rate;
+- cur_prob = mr->cur_prob;
+- cur_prob_tp = mr->cur_tp;
+- }
+-
+ mr = minstrel_get_ratestats(mi, mg->max_tp_rate);
+ if (cur_tp < mr->cur_tp) {
+ mi->max_tp_rate2 = mi->max_tp_rate;
+ cur_tp2 = cur_tp;
+ mi->max_tp_rate = mg->max_tp_rate;
+ cur_tp = mr->cur_tp;
++ mi->max_prob_streams = minstrel_mcs_groups[group].streams - 1;
+ }
+
+ mr = minstrel_get_ratestats(mi, mg->max_tp_rate2);
+@@ -343,6 +348,23 @@ minstrel_ht_update_stats(struct minstrel
+ }
+ }
+
++ if (mi->max_prob_streams < 1)
++ mi->max_prob_streams = 1;
++
++ for (group = 0; group < ARRAY_SIZE(minstrel_mcs_groups); group++) {
++ mg = &mi->groups[group];
++ if (!mg->supported)
++ continue;
++ mr = minstrel_get_ratestats(mi, mg->max_prob_rate);
++ if (cur_prob_tp < mr->cur_tp &&
++ minstrel_mcs_groups[group].streams <= mi->max_prob_streams) {
++ mi->max_prob_rate = mg->max_prob_rate;
++ cur_prob = mr->cur_prob;
++ cur_prob_tp = mr->cur_tp;
++ }
++ }
++
++
+ mi->stats_update = jiffies;
+ }
+
+@@ -467,7 +489,7 @@ minstrel_ht_tx_status(void *priv, struct
+
+ if (!mi->sample_wait && !mi->sample_tries && mi->sample_count > 0) {
+ mi->sample_wait = 16 + 2 * MINSTREL_TRUNC(mi->avg_ampdu_len);
+- mi->sample_tries = 2;
++ mi->sample_tries = 1;
+ mi->sample_count--;
+ }
+
+@@ -536,7 +558,7 @@ minstrel_calc_retransmit(struct minstrel
+ mr->retry_updated = true;
+
+ group = &minstrel_mcs_groups[index / MCS_GROUP_RATES];
+- tx_time_data = group->duration[index % MCS_GROUP_RATES] * ampdu_len;
++ tx_time_data = group->duration[index % MCS_GROUP_RATES] * ampdu_len / 1000;
+
+ /* Contention time for first 2 tries */
+ ctime = (t_slot * cw) >> 1;
+@@ -616,6 +638,7 @@ minstrel_get_sample_rate(struct minstrel
+ {
+ struct minstrel_rate_stats *mr;
+ struct minstrel_mcs_group_data *mg;
++ unsigned int sample_dur, sample_group;
+ int sample_idx = 0;
+
+ if (mi->sample_wait > 0) {
+@@ -626,39 +649,46 @@ minstrel_get_sample_rate(struct minstrel
+ if (!mi->sample_tries)
+ return -1;
+
+- mi->sample_tries--;
+ mg = &mi->groups[mi->sample_group];
+ sample_idx = sample_table[mg->column][mg->index];
+ mr = &mg->rates[sample_idx];
+- sample_idx += mi->sample_group * MCS_GROUP_RATES;
++ sample_group = mi->sample_group;
++ sample_idx += sample_group * MCS_GROUP_RATES;
+ minstrel_next_sample_idx(mi);
+
+ /*
+ * Sampling might add some overhead (RTS, no aggregation)
+ * to the frame. Hence, don't use sampling for the currently
+- * used max TP rate.
++ * used rates.
+ */
+- if (sample_idx == mi->max_tp_rate)
++ if (sample_idx == mi->max_tp_rate ||
++ sample_idx == mi->max_tp_rate2 ||
++ sample_idx == mi->max_prob_rate)
+ return -1;
++
+ /*
+- * When not using MRR, do not sample if the probability is already
+- * higher than 95% to avoid wasting airtime
++ * Do not sample if the probability is already higher than 95%
++ * to avoid wasting airtime.
+ */
+- if (!mp->has_mrr && (mr->probability > MINSTREL_FRAC(95, 100)))
++ if (mr->probability > MINSTREL_FRAC(95, 100))
+ return -1;
+
+ /*
+ * Make sure that lower rates get sampled only occasionally,
+ * if the link is working perfectly.
+ */
+- if (minstrel_get_duration(sample_idx) >
+- minstrel_get_duration(mi->max_tp_rate)) {
++ sample_dur = minstrel_get_duration(sample_idx);
++ if (sample_dur >= minstrel_get_duration(mi->max_tp_rate2) &&
++ (mi->max_prob_streams <
++ minstrel_mcs_groups[sample_group].streams ||
++ sample_dur >= minstrel_get_duration(mi->max_prob_rate))) {
+ if (mr->sample_skipped < 20)
+ return -1;
+
+ if (mi->sample_slow++ > 2)
+ return -1;
+ }
++ mi->sample_tries--;
+
+ return sample_idx;
+ }
+--- a/net/mac80211/rc80211_minstrel_ht.h
++++ b/net/mac80211/rc80211_minstrel_ht.h
+@@ -85,6 +85,7 @@ struct minstrel_ht_sta {
+
+ /* best probability rate */
+ unsigned int max_prob_rate;
++ unsigned int max_prob_streams;
+
+ /* time of last status update */
+ unsigned long stats_update;
+--- a/drivers/net/wireless/ath/ath9k/ar9003_calib.c
++++ b/drivers/net/wireless/ath/ath9k/ar9003_calib.c
+@@ -1023,6 +1023,7 @@ static bool ar9003_hw_init_cal(struct at
+ AR_PHY_AGC_CONTROL_FLTR_CAL |
+ AR_PHY_AGC_CONTROL_PKDET_CAL;
+
++ /* Use chip chainmask only for calibration */
+ ar9003_hw_set_chain_masks(ah, ah->caps.rx_chainmask, ah->caps.tx_chainmask);
+
+ if (rtt) {
+@@ -1150,6 +1151,9 @@ skip_tx_iqcal:
+ ar9003_hw_rtt_disable(ah);
+ }
+
++ /* Revert chainmask to runtime parameters */
++ ar9003_hw_set_chain_masks(ah, ah->rxchainmask, ah->txchainmask);
++
+ /* Initialize list pointers */
+ ah->cal_list = ah->cal_list_last = ah->cal_list_curr = NULL;
+
+--- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
++++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
+@@ -3606,6 +3606,12 @@ static void ar9003_hw_ant_ctrl_apply(str
+ value = ar9003_hw_ant_ctrl_common_2_get(ah, is2ghz);
+ REG_RMW_FIELD(ah, AR_PHY_SWITCH_COM_2, AR_SWITCH_TABLE_COM2_ALL, value);
+
++ if ((AR_SREV_9462(ah)) && (ah->rxchainmask == 0x2)) {
++ value = ar9003_hw_ant_ctrl_chain_get(ah, 1, is2ghz);
++ REG_RMW_FIELD(ah, switch_chain_reg[0],
++ AR_SWITCH_TABLE_ALL, value);
++ }
++
+ for (chain = 0; chain < AR9300_MAX_CHAINS; chain++) {
+ if ((ah->rxchainmask & BIT(chain)) ||
+ (ah->txchainmask & BIT(chain))) {
+@@ -3772,6 +3778,17 @@ static void ar9003_hw_atten_apply(struct
+ AR_PHY_EXT_ATTEN_CTL_2,
+ };
+
++ if ((AR_SREV_9462(ah)) && (ah->rxchainmask == 0x2)) {
++ value = ar9003_hw_atten_chain_get(ah, 1, chan);
++ REG_RMW_FIELD(ah, ext_atten_reg[0],
++ AR_PHY_EXT_ATTEN_CTL_XATTEN1_DB, value);
++
++ value = ar9003_hw_atten_chain_get_margin(ah, 1, chan);
++ REG_RMW_FIELD(ah, ext_atten_reg[0],
++ AR_PHY_EXT_ATTEN_CTL_XATTEN1_MARGIN,
++ value);
++ }
++
+ /* Test value. if 0 then attenuation is unused. Don't load anything. */
+ for (i = 0; i < 3; i++) {
+ if (ah->txchainmask & BIT(i)) {
+--- a/drivers/net/wireless/ath/ath9k/link.c
++++ b/drivers/net/wireless/ath/ath9k/link.c
+@@ -28,21 +28,21 @@ void ath_tx_complete_poll_work(struct wo
+ int i;
+ bool needreset = false;
+
+- for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++)
+- if (ATH_TXQ_SETUP(sc, i)) {
+- txq = &sc->tx.txq[i];
+- ath_txq_lock(sc, txq);
+- if (txq->axq_depth) {
+- if (txq->axq_tx_inprogress) {
+- needreset = true;
+- ath_txq_unlock(sc, txq);
+- break;
+- } else {
+- txq->axq_tx_inprogress = true;
+- }
++ for (i = 0; i < IEEE80211_NUM_ACS; i++) {
++ txq = sc->tx.txq_map[i];
++
++ ath_txq_lock(sc, txq);
++ if (txq->axq_depth) {
++ if (txq->axq_tx_inprogress) {
++ needreset = true;
++ ath_txq_unlock(sc, txq);
++ break;
++ } else {
++ txq->axq_tx_inprogress = true;
+ }
+- ath_txq_unlock_complete(sc, txq);
+ }
++ ath_txq_unlock_complete(sc, txq);
++ }
+
+ if (needreset) {
+ ath_dbg(ath9k_hw_common(sc->sc_ah), RESET,
+--- a/net/mac80211/sta_info.c
++++ b/net/mac80211/sta_info.c
+@@ -766,6 +766,7 @@ int __must_check __sta_info_destroy(stru
+ struct ieee80211_local *local;
+ struct ieee80211_sub_if_data *sdata;
+ int ret, i;
++ bool have_key = false;
+
+ might_sleep();
+
+@@ -793,12 +794,19 @@ int __must_check __sta_info_destroy(stru
+ list_del_rcu(&sta->list);
+
+ mutex_lock(&local->key_mtx);
+- for (i = 0; i < NUM_DEFAULT_KEYS; i++)
++ for (i = 0; i < NUM_DEFAULT_KEYS; i++) {
+ __ieee80211_key_free(key_mtx_dereference(local, sta->gtk[i]));
+- if (sta->ptk)
++ have_key = true;
++ }
++ if (sta->ptk) {
+ __ieee80211_key_free(key_mtx_dereference(local, sta->ptk));
++ have_key = true;
++ }
+ mutex_unlock(&local->key_mtx);
+
++ if (!have_key)
++ synchronize_net();
++
+ sta->dead = true;
+
+ local->num_sta--;
diff --git a/package/mac80211/patches/310-ap_scan.patch b/package/mac80211/patches/310-ap_scan.patch
new file mode 100644
index 0000000..b8f2671
--- /dev/null
+++ b/package/mac80211/patches/310-ap_scan.patch
@@ -0,0 +1,11 @@
+--- a/net/mac80211/cfg.c
++++ b/net/mac80211/cfg.c
+@@ -2009,7 +2009,7 @@ static int ieee80211_scan(struct wiphy *
+ * the frames sent while scanning on other channel will be
+ * lost)
+ */
+- if (sdata->u.ap.beacon &&
++ if (0 && sdata->u.ap.beacon &&
+ (!(wiphy->features & NL80211_FEATURE_AP_SCAN) ||
+ !(req->flags & NL80211_SCAN_FLAG_AP)))
+ return -EOPNOTSUPP;
diff --git a/package/mac80211/patches/400-ath_move_debug_code.patch b/package/mac80211/patches/400-ath_move_debug_code.patch
new file mode 100644
index 0000000..c91128d
--- /dev/null
+++ b/package/mac80211/patches/400-ath_move_debug_code.patch
@@ -0,0 +1,28 @@
+--- a/drivers/net/wireless/ath/Makefile
++++ b/drivers/net/wireless/ath/Makefile
+@@ -10,7 +10,7 @@ obj-$(CONFIG_ATH_COMMON) += ath.o
+ ath-objs := main.o \
+ regd.o \
+ hw.o \
+- key.o
++ key.o \
++ debug.o
+
+-ath-$(CONFIG_ATH_DEBUG) += debug.o
+ ccflags-y += -D__CHECK_ENDIAN__
+--- a/drivers/net/wireless/ath/ath.h
++++ b/drivers/net/wireless/ath/ath.h
+@@ -281,13 +281,6 @@ void _ath_dbg(struct ath_common *common,
+ #endif /* CONFIG_ATH_DEBUG */
+
+ /** Returns string describing opmode, or NULL if unknown mode. */
+-#ifdef CONFIG_ATH_DEBUG
+ const char *ath_opmode_to_string(enum nl80211_iftype opmode);
+-#else
+-static inline const char *ath_opmode_to_string(enum nl80211_iftype opmode)
+-{
+- return "UNKNOWN";
+-}
+-#endif
+
+ #endif /* ATH_H */
diff --git a/package/mac80211/patches/401-ath9k_blink_default.patch b/package/mac80211/patches/401-ath9k_blink_default.patch
new file mode 100644
index 0000000..421e785
--- /dev/null
+++ b/package/mac80211/patches/401-ath9k_blink_default.patch
@@ -0,0 +1,11 @@
+--- a/drivers/net/wireless/ath/ath9k/init.c
++++ b/drivers/net/wireless/ath/ath9k/init.c
+@@ -46,7 +46,7 @@ int ath9k_modparam_nohwcrypt;
+ module_param_named(nohwcrypt, ath9k_modparam_nohwcrypt, int, 0444);
+ MODULE_PARM_DESC(nohwcrypt, "Disable hardware encryption");
+
+-int led_blink;
++int led_blink = 1;
+ module_param_named(blink, led_blink, int, 0444);
+ MODULE_PARM_DESC(blink, "Enable LED blink on activity");
+
diff --git a/package/mac80211/patches/402-ath9k-fix-invalid-mac-address-handling.patch b/package/mac80211/patches/402-ath9k-fix-invalid-mac-address-handling.patch
new file mode 100644
index 0000000..3dbdba0
--- /dev/null
+++ b/package/mac80211/patches/402-ath9k-fix-invalid-mac-address-handling.patch
@@ -0,0 +1,29 @@
+--- a/drivers/net/wireless/ath/ath9k/hw.c
++++ b/drivers/net/wireless/ath/ath9k/hw.c
+@@ -17,6 +17,7 @@
+ #include <linux/io.h>
+ #include <linux/slab.h>
+ #include <linux/module.h>
++#include <linux/etherdevice.h>
+ #include <asm/unaligned.h>
+
+ #include "hw.h"
+@@ -519,8 +520,16 @@ static int ath9k_hw_init_macaddr(struct
+ common->macaddr[2 * i] = eeval >> 8;
+ common->macaddr[2 * i + 1] = eeval & 0xff;
+ }
+- if (sum == 0 || sum == 0xffff * 3)
+- return -EADDRNOTAVAIL;
++ if (!is_valid_ether_addr(common->macaddr)) {
++ ath_err(common,
++ "eeprom contains invalid mac address: %pM\n",
++ common->macaddr);
++
++ random_ether_addr(common->macaddr);
++ ath_err(common,
++ "random mac address will be used: %pM\n",
++ common->macaddr);
++ }
+
+ return 0;
+ }
diff --git a/package/mac80211/patches/403-ath_regd_optional.patch b/package/mac80211/patches/403-ath_regd_optional.patch
new file mode 100644
index 0000000..683417b
--- /dev/null
+++ b/package/mac80211/patches/403-ath_regd_optional.patch
@@ -0,0 +1,46 @@
+--- a/drivers/net/wireless/ath/regd.c
++++ b/drivers/net/wireless/ath/regd.c
+@@ -198,6 +198,10 @@ ath_reg_apply_beaconing_flags(struct wip
+ struct ieee80211_channel *ch;
+ unsigned int i;
+
++#ifdef ATH_USER_REGD
++ return;
++#endif
++
+ for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
+
+ if (!wiphy->bands[band])
+@@ -252,6 +256,10 @@ ath_reg_apply_active_scan_flags(struct w
+ struct ieee80211_channel *ch;
+ const struct ieee80211_reg_rule *reg_rule;
+
++#ifdef ATH_USER_REGD
++ return;
++#endif
++
+ sband = wiphy->bands[IEEE80211_BAND_2GHZ];
+ if (!sband)
+ return;
+@@ -301,6 +309,10 @@ static void ath_reg_apply_radar_flags(st
+ struct ieee80211_channel *ch;
+ unsigned int i;
+
++#ifdef ATH_USER_REGD
++ return;
++#endif
++
+ if (!wiphy->bands[IEEE80211_BAND_5GHZ])
+ return;
+
+@@ -505,6 +517,10 @@ ath_regd_init_wiphy(struct ath_regulator
+ {
+ const struct ieee80211_regdomain *regd;
+
++#ifdef ATH_USER_REGD
++ return 0;
++#endif
++
+ wiphy->reg_notifier = reg_notifier;
+ wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY;
+
diff --git a/package/mac80211/patches/404-world_regd_fixup.patch b/package/mac80211/patches/404-world_regd_fixup.patch
new file mode 100644
index 0000000..d609b55
--- /dev/null
+++ b/package/mac80211/patches/404-world_regd_fixup.patch
@@ -0,0 +1,84 @@
+--- a/drivers/net/wireless/ath/regd.c
++++ b/drivers/net/wireless/ath/regd.c
+@@ -44,7 +44,8 @@ static int __ath_regd_init(struct ath_re
+ NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_OFDM)
+
+ /* We allow IBSS on these on a case by case basis by regulatory domain */
+-#define ATH9K_5GHZ_5150_5350 REG_RULE(5150-10, 5350+10, 40, 0, 30,\
++#define ATH9K_5GHZ_5150_5350 REG_RULE(5150-10, 5250, 40, 0, 30, 0), \
++ REG_RULE(5250, 5350+10, 40, 0, 30,\
+ NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_IBSS)
+ #define ATH9K_5GHZ_5470_5850 REG_RULE(5470-10, 5850+10, 40, 0, 30,\
+ NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_IBSS)
+@@ -62,57 +63,56 @@ static int __ath_regd_init(struct ath_re
+ #define ATH9K_5GHZ_NO_MIDBAND ATH9K_5GHZ_5150_5350, \
+ ATH9K_5GHZ_5725_5850
+
++#define REGD_RULES(...) \
++ .reg_rules = { __VA_ARGS__ }, \
++ .n_reg_rules = ARRAY_SIZE(((struct ieee80211_reg_rule[]) { __VA_ARGS__ }))
++
+ /* Can be used for:
+ * 0x60, 0x61, 0x62 */
+ static const struct ieee80211_regdomain ath_world_regdom_60_61_62 = {
+- .n_reg_rules = 5,
+ .alpha2 = "99",
+- .reg_rules = {
++ REGD_RULES(
+ ATH9K_2GHZ_ALL,
+ ATH9K_5GHZ_ALL,
+- }
++ )
+ };
+
+ /* Can be used by 0x63 and 0x65 */
+ static const struct ieee80211_regdomain ath_world_regdom_63_65 = {
+- .n_reg_rules = 4,
+ .alpha2 = "99",
+- .reg_rules = {
++ REGD_RULES(
+ ATH9K_2GHZ_CH01_11,
+ ATH9K_2GHZ_CH12_13,
+ ATH9K_5GHZ_NO_MIDBAND,
+- }
++ )
+ };
+
+ /* Can be used by 0x64 only */
+ static const struct ieee80211_regdomain ath_world_regdom_64 = {
+- .n_reg_rules = 3,
+ .alpha2 = "99",
+- .reg_rules = {
++ REGD_RULES(
+ ATH9K_2GHZ_CH01_11,
+ ATH9K_5GHZ_NO_MIDBAND,
+- }
++ )
+ };
+
+ /* Can be used by 0x66 and 0x69 */
+ static const struct ieee80211_regdomain ath_world_regdom_66_69 = {
+- .n_reg_rules = 3,
+ .alpha2 = "99",
+- .reg_rules = {
++ REGD_RULES(
+ ATH9K_2GHZ_CH01_11,
+ ATH9K_5GHZ_ALL,
+- }
++ )
+ };
+
+ /* Can be used by 0x67, 0x68, 0x6A and 0x6C */
+ static const struct ieee80211_regdomain ath_world_regdom_67_68_6A_6C = {
+- .n_reg_rules = 4,
+ .alpha2 = "99",
+- .reg_rules = {
++ REGD_RULES(
+ ATH9K_2GHZ_CH01_11,
+ ATH9K_2GHZ_CH12_13,
+ ATH9K_5GHZ_ALL,
+- }
++ )
+ };
+
+ static inline bool is_wwr_sku(u16 regd)
diff --git a/package/mac80211/patches/405-regd_no_assoc_hints.patch b/package/mac80211/patches/405-regd_no_assoc_hints.patch
new file mode 100644
index 0000000..938ac42
--- /dev/null
+++ b/package/mac80211/patches/405-regd_no_assoc_hints.patch
@@ -0,0 +1,19 @@
+--- a/net/wireless/reg.c
++++ b/net/wireless/reg.c
+@@ -1730,6 +1730,8 @@ void regulatory_hint_11d(struct wiphy *w
+ enum environment_cap env = ENVIRON_ANY;
+ struct regulatory_request *request, *lr;
+
++ return;
++
+ mutex_lock(&reg_mutex);
+ lr = get_last_request();
+
+@@ -1926,6 +1928,7 @@ static void restore_regulatory_settings(
+
+ void regulatory_hint_disconnect(void)
+ {
++ return;
+ REG_DBG_PRINT("All devices are disconnected, going to restore regulatory settings\n");
+ restore_regulatory_settings(false);
+ }
diff --git a/package/mac80211/patches/406-ath_regd_us.patch b/package/mac80211/patches/406-ath_regd_us.patch
new file mode 100644
index 0000000..cc55877
--- /dev/null
+++ b/package/mac80211/patches/406-ath_regd_us.patch
@@ -0,0 +1,26 @@
+--- a/drivers/net/wireless/ath/regd_common.h
++++ b/drivers/net/wireless/ath/regd_common.h
+@@ -32,6 +32,7 @@ enum EnumRd {
+ FCC2_WORLD = 0x21,
+ FCC2_ETSIC = 0x22,
+ FCC6_WORLD = 0x23,
++ FCC3_FCCA_2 = 0x2A,
+ FRANCE_RES = 0x31,
+ FCC3_FCCA = 0x3A,
+ FCC3_WORLD = 0x3B,
+@@ -167,6 +168,7 @@ static struct reg_dmn_pair_mapping regDo
+ {FCC2_WORLD, CTL_FCC, CTL_ETSI},
+ {FCC2_ETSIC, CTL_FCC, CTL_ETSI},
+ {FCC3_FCCA, CTL_FCC, CTL_FCC},
++ {FCC3_FCCA_2, CTL_FCC, CTL_FCC},
+ {FCC3_WORLD, CTL_FCC, CTL_ETSI},
+ {FCC4_FCCA, CTL_FCC, CTL_FCC},
+ {FCC5_FCCA, CTL_FCC, CTL_FCC},
+@@ -463,6 +465,7 @@ static struct country_code_to_enum_rd al
+ {CTRY_UAE, NULL1_WORLD, "AE"},
+ {CTRY_UNITED_KINGDOM, ETSI1_WORLD, "GB"},
+ {CTRY_UNITED_STATES, FCC3_FCCA, "US"},
++ {CTRY_UNITED_STATES, FCC3_FCCA_2, "US"},
+ /* This "PS" is for US public safety actually... to support this we
+ * would need to assign new special alpha2 to CRDA db as with the world
+ * regdomain and use another alpha2 */
diff --git a/package/mac80211/patches/410-ath9k_allow_adhoc_and_ap.patch b/package/mac80211/patches/410-ath9k_allow_adhoc_and_ap.patch
new file mode 100644
index 0000000..7a07eb6
--- /dev/null
+++ b/package/mac80211/patches/410-ath9k_allow_adhoc_and_ap.patch
@@ -0,0 +1,10 @@
+--- a/drivers/net/wireless/ath/ath9k/init.c
++++ b/drivers/net/wireless/ath/ath9k/init.c
+@@ -727,6 +727,7 @@ static const struct ieee80211_iface_limi
+ #endif
+ BIT(NL80211_IFTYPE_AP) |
+ BIT(NL80211_IFTYPE_P2P_GO) },
++ { .max = 1, .types = BIT(NL80211_IFTYPE_ADHOC) },
+ };
+
+ static const struct ieee80211_iface_combination if_comb = {
diff --git a/package/mac80211/patches/411-ath5k_allow_adhoc_and_ap.patch b/package/mac80211/patches/411-ath5k_allow_adhoc_and_ap.patch
new file mode 100644
index 0000000..3d885bb
--- /dev/null
+++ b/package/mac80211/patches/411-ath5k_allow_adhoc_and_ap.patch
@@ -0,0 +1,46 @@
+--- a/drivers/net/wireless/ath/ath5k/mac80211-ops.c
++++ b/drivers/net/wireless/ath/ath5k/mac80211-ops.c
+@@ -89,13 +89,8 @@ ath5k_add_interface(struct ieee80211_hw
+ goto end;
+ }
+
+- /* Don't allow other interfaces if one ad-hoc is configured.
+- * TODO: Fix the problems with ad-hoc and multiple other interfaces.
+- * We would need to operate the HW in ad-hoc mode to allow TSF updates
+- * for the IBSS, but this breaks with additional AP or STA interfaces
+- * at the moment. */
+- if (ah->num_adhoc_vifs ||
+- (ah->nvifs && vif->type == NL80211_IFTYPE_ADHOC)) {
++ /* Don't allow more than one ad-hoc interface */
++ if (ah->num_adhoc_vifs && vif->type == NL80211_IFTYPE_ADHOC) {
+ ATH5K_ERR(ah, "Only one single ad-hoc interface is allowed.\n");
+ ret = -ELNRNG;
+ goto end;
+--- a/drivers/net/wireless/ath/ath5k/base.c
++++ b/drivers/net/wireless/ath/ath5k/base.c
+@@ -1868,7 +1868,7 @@ ath5k_beacon_send(struct ath5k_hw *ah)
+ }
+
+ if ((ah->opmode == NL80211_IFTYPE_AP && ah->num_ap_vifs +
+- ah->num_mesh_vifs > 1) ||
++ ah->num_adhoc_vifs + ah->num_mesh_vifs > 1) ||
+ ah->opmode == NL80211_IFTYPE_MESH_POINT) {
+ u64 tsf = ath5k_hw_get_tsf64(ah);
+ u32 tsftu = TSF_TO_TU(tsf);
+@@ -1954,7 +1954,7 @@ ath5k_beacon_update_timers(struct ath5k_
+
+ intval = ah->bintval & AR5K_BEACON_PERIOD;
+ if (ah->opmode == NL80211_IFTYPE_AP && ah->num_ap_vifs
+- + ah->num_mesh_vifs > 1) {
++ + ah->num_adhoc_vifs + ah->num_mesh_vifs > 1) {
+ intval /= ATH_BCBUF; /* staggered multi-bss beacons */
+ if (intval < 15)
+ ATH5K_WARN(ah, "intval %u is too low, min 15\n",
+@@ -2418,6 +2418,7 @@ static const struct ieee80211_iface_limi
+ BIT(NL80211_IFTYPE_MESH_POINT) |
+ #endif
+ BIT(NL80211_IFTYPE_AP) },
++ { .max = 1, .types = BIT(NL80211_IFTYPE_ADHOC) },
+ };
+
+ static const struct ieee80211_iface_combination if_comb = {
diff --git a/package/mac80211/patches/420-ath5k_disable_fast_cc.patch b/package/mac80211/patches/420-ath5k_disable_fast_cc.patch
new file mode 100644
index 0000000..48b8467
--- /dev/null
+++ b/package/mac80211/patches/420-ath5k_disable_fast_cc.patch
@@ -0,0 +1,18 @@
+--- a/drivers/net/wireless/ath/ath5k/reset.c
++++ b/drivers/net/wireless/ath/ath5k/reset.c
+@@ -1158,6 +1158,7 @@ ath5k_hw_reset(struct ath5k_hw *ah, enum
+ tsf_lo = 0;
+ mode = 0;
+
++#if 0
+ /*
+ * Sanity check for fast flag
+ * Fast channel change only available
+@@ -1165,6 +1166,7 @@ ath5k_hw_reset(struct ath5k_hw *ah, enum
+ */
+ if (fast && (ah->ah_radio != AR5K_RF2413) &&
+ (ah->ah_radio != AR5K_RF5413))
++#endif
+ fast = false;
+
+ /* Disable sleep clock operation
diff --git a/package/mac80211/patches/430-add_ath5k_platform.patch b/package/mac80211/patches/430-add_ath5k_platform.patch
new file mode 100644
index 0000000..b213e2a
--- /dev/null
+++ b/package/mac80211/patches/430-add_ath5k_platform.patch
@@ -0,0 +1,33 @@
+--- /dev/null
++++ b/include/linux/ath5k_platform.h
+@@ -0,0 +1,30 @@
++/*
++ * Copyright (c) 2008 Atheros Communications Inc.
++ * Copyright (c) 2009 Gabor Juhos <juhosg@openwrt.org>
++ * Copyright (c) 2009 Imre Kaloz <kaloz@openwrt.org>
++ * Copyright (c) 2010 Daniel Golle <daniel.golle@gmail.com>
++ *
++ * Permission to use, copy, modify, and/or distribute this software for any
++ * purpose with or without fee is hereby granted, provided that the above
++ * copyright notice and this permission notice appear in all copies.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
++ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
++ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
++ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
++ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
++ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
++ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
++ */
++
++#ifndef _LINUX_ATH5K_PLATFORM_H
++#define _LINUX_ATH5K_PLATFORM_H
++
++#define ATH5K_PLAT_EEP_MAX_WORDS 2048
++
++struct ath5k_platform_data {
++ u16 *eeprom_data;
++ u8 *macaddr;
++};
++
++#endif /* _LINUX_ATH5K_PLATFORM_H */
diff --git a/package/mac80211/patches/431-add_platform_eeprom_support_to_ath5k.patch b/package/mac80211/patches/431-add_platform_eeprom_support_to_ath5k.patch
new file mode 100644
index 0000000..d4967b6
--- /dev/null
+++ b/package/mac80211/patches/431-add_platform_eeprom_support_to_ath5k.patch
@@ -0,0 +1,56 @@
+--- a/drivers/net/wireless/ath/ath5k/pci.c
++++ b/drivers/net/wireless/ath/ath5k/pci.c
+@@ -23,6 +23,7 @@
+ #include <linux/pci-aspm.h>
+ #include <linux/etherdevice.h>
+ #include <linux/module.h>
++#include <linux/ath5k_platform.h>
+ #include "../ath.h"
+ #include "ath5k.h"
+ #include "debug.h"
+@@ -74,7 +75,7 @@ static void ath5k_pci_read_cachesize(str
+ }
+
+ /*
+- * Read from eeprom
++ * Read from eeprom or platform_data
+ */
+ static bool
+ ath5k_pci_eeprom_read(struct ath_common *common, u32 offset, u16 *data)
+@@ -82,6 +83,19 @@ ath5k_pci_eeprom_read(struct ath_common
+ struct ath5k_hw *ah = (struct ath5k_hw *) common->ah;
+ u32 status, timeout;
+
++ struct ath5k_platform_data *pdata = NULL;
++
++ if (ah->pdev)
++ pdata = ah->pdev->dev.platform_data;
++
++ if (pdata && pdata->eeprom_data && pdata->eeprom_data[61] == AR5K_EEPROM_MAGIC_VALUE) {
++ if (offset >= ATH5K_PLAT_EEP_MAX_WORDS)
++ return false;
++
++ *data = pdata->eeprom_data[offset];
++ return true;
++ }
++
+ /*
+ * Initialize EEPROM access
+ */
+@@ -125,6 +139,16 @@ static int ath5k_pci_eeprom_read_mac(str
+ u16 data;
+ int octet;
+
++ struct ath5k_platform_data *pdata = NULL;
++
++ if (ah->pdev)
++ pdata = ah->pdev->dev.platform_data;
++
++ if (pdata && pdata->macaddr) {
++ memcpy(mac, pdata->macaddr, ETH_ALEN);
++ return 0;
++ }
++
+ AR5K_EEPROM_READ(0x20, data);
+
+ for (offset = 0x1f, octet = 0, total = 0; offset >= 0x1d; offset--) {
diff --git a/package/mac80211/patches/432-ath5k_add_pciids.patch b/package/mac80211/patches/432-ath5k_add_pciids.patch
new file mode 100644
index 0000000..8db5e1b
--- /dev/null
+++ b/package/mac80211/patches/432-ath5k_add_pciids.patch
@@ -0,0 +1,11 @@
+--- a/drivers/net/wireless/ath/ath5k/pci.c
++++ b/drivers/net/wireless/ath/ath5k/pci.c
+@@ -50,6 +50,8 @@ static DEFINE_PCI_DEVICE_TABLE(ath5k_pci
+ { PCI_VDEVICE(ATHEROS, 0x001b) }, /* 5413 Eagle */
+ { PCI_VDEVICE(ATHEROS, 0x001c) }, /* PCI-E cards */
+ { PCI_VDEVICE(ATHEROS, 0x001d) }, /* 2417 Nala */
++ { PCI_VDEVICE(ATHEROS, 0xff16) }, /* 2413,2414 sx76x on lantiq_danube */
++ { PCI_VDEVICE(ATHEROS, 0xff1a) }, /* 2417 arv45xx on lantiq_danube */
+ { PCI_VDEVICE(ATHEROS, 0xff1b) }, /* AR5BXB63 */
+ { 0 }
+ };
diff --git a/package/mac80211/patches/440-ath5k_channel_bw_debugfs.patch b/package/mac80211/patches/440-ath5k_channel_bw_debugfs.patch
new file mode 100644
index 0000000..f9c2a09
--- /dev/null
+++ b/package/mac80211/patches/440-ath5k_channel_bw_debugfs.patch
@@ -0,0 +1,113 @@
+This adds a bwmode debugfs file which can be used to set alternate
+channel operating bandwidths. Only tested with AR5413 and only at
+5 and 20 mhz channels.
+
+Signed-off-by: Pat Erley <pat-lkml at erley.org>
+---
+Other devices will need to be added to the switch in write_file_bwmode
+
+drivers/net/wireless/ath/ath5k/debug.c | 86 ++++++++++++++++++++++++++++++++
+ 1 files changed, 86 insertions(+), 0 deletions(-)
+
+--- a/drivers/net/wireless/ath/ath5k/debug.c
++++ b/drivers/net/wireless/ath/ath5k/debug.c
+@@ -813,6 +813,89 @@ static const struct file_operations fops
+ .llseek = default_llseek,
+ };
+
++/* debugfs: bwmode */
++
++static ssize_t read_file_bwmode(struct file *file, char __user *user_buf,
++ size_t count, loff_t *ppos)
++{
++ struct ath5k_hw *ah = file->private_data;
++ char buf[15];
++ unsigned int len = 0;
++
++ int cur_ah_bwmode = ah->ah_bwmode;
++
++#define print_selected(MODE, LABEL) \
++ if (cur_ah_bwmode == MODE) \
++ len += snprintf(buf+len, sizeof(buf)-len, "[%s]", LABEL); \
++ else \
++ len += snprintf(buf+len, sizeof(buf)-len, "%s", LABEL); \
++ len += snprintf(buf+len, sizeof(buf)-len, " ");
++
++ print_selected(AR5K_BWMODE_5MHZ, "5");
++ print_selected(AR5K_BWMODE_10MHZ, "10");
++ print_selected(AR5K_BWMODE_DEFAULT, "20");
++ print_selected(AR5K_BWMODE_40MHZ, "40");
++#undef print_selected
++
++ len += snprintf(buf+len, sizeof(buf)-len, "\n");
++
++ return simple_read_from_buffer(user_buf, count, ppos, buf, len);
++}
++
++static ssize_t write_file_bwmode(struct file *file,
++ const char __user *userbuf,
++ size_t count, loff_t *ppos)
++{
++ struct ath5k_hw *ah = file->private_data;
++ char buf[3];
++ int bw = 20;
++ int tobwmode = AR5K_BWMODE_DEFAULT;
++
++ if (copy_from_user(buf, userbuf, min(count, sizeof(buf))))
++ return -EFAULT;
++
++ /* TODO: Add check for active interface */
++
++ if(strncmp(buf, "5", 1) == 0 ) {
++ tobwmode = AR5K_BWMODE_5MHZ;
++ bw = 5;
++ } else if ( strncmp(buf, "10", 2) == 0 ) {
++ tobwmode = AR5K_BWMODE_10MHZ;
++ bw = 10;
++ } else if ( strncmp(buf, "20", 2) == 0 ) {
++ tobwmode = AR5K_BWMODE_DEFAULT;
++ bw = 20;
++ } else if ( strncmp(buf, "40", 2) == 0 ) {
++ tobwmode = AR5K_BWMODE_40MHZ;
++ bw = 40;
++ } else
++ return -EINVAL;
++
++ ATH5K_INFO(ah, "Changing to %imhz channel width[%i]\n",
++ bw, tobwmode);
++
++ switch (ah->ah_radio) {
++ /* TODO: only define radios that actually support 5/10mhz channels */
++ case AR5K_RF5413: case AR5K_RF5110: case AR5K_RF5111: case AR5K_RF5112: case AR5K_RF2413: case AR5K_RF2316: case AR5K_RF2317: case AR5K_RF2425:
++ if(ah->ah_bwmode != tobwmode) {
++ mutex_lock(&ah->lock);
++ ah->ah_bwmode = tobwmode;
++ mutex_unlock(&ah->lock);
++ }
++ break;
++ default:
++ return -EOPNOTSUPP;
++ }
++ return count;
++}
++
++static const struct file_operations fops_bwmode = {
++ .read = read_file_bwmode,
++ .write = write_file_bwmode,
++ .open = simple_open,
++ .owner = THIS_MODULE,
++ .llseek = default_llseek,
++};
+
+ /* debugfs: queues etc */
+
+@@ -904,6 +987,9 @@ ath5k_debug_init_device(struct ath5k_hw
+ debugfs_create_file("beacon", S_IWUSR | S_IRUSR, phydir, ah,
+ &fops_beacon);
+
++ debugfs_create_file("bwmode", S_IWUSR | S_IRUSR, phydir, ah,
++ &fops_bwmode);
++
+ debugfs_create_file("reset", S_IWUSR, phydir, ah, &fops_reset);
+
+ debugfs_create_file("antenna", S_IWUSR | S_IRUSR, phydir, ah,
diff --git a/package/mac80211/patches/500-ath9k_eeprom_debugfs.patch b/package/mac80211/patches/500-ath9k_eeprom_debugfs.patch
new file mode 100644
index 0000000..285fce2
--- /dev/null
+++ b/package/mac80211/patches/500-ath9k_eeprom_debugfs.patch
@@ -0,0 +1,65 @@
+--- a/drivers/net/wireless/ath/ath9k/debug.c
++++ b/drivers/net/wireless/ath/ath9k/debug.c
+@@ -2003,6 +2003,53 @@ void ath9k_get_et_stats(struct ieee80211
+ WARN_ON(i != ATH9K_SSTATS_LEN);
+ }
+
++static ssize_t read_file_eeprom(struct file *file, char __user *user_buf,
++ size_t count, loff_t *ppos)
++{
++ struct ath_softc *sc = file->private_data;
++ struct ath_hw *ah = sc->sc_ah;
++ struct ath_common *common = ath9k_hw_common(ah);
++ int bytes = 0;
++ int pos = *ppos;
++ int size = 4096;
++ u16 val;
++ int i;
++
++ if (AR_SREV_9300_20_OR_LATER(ah))
++ size = 16384;
++
++ if (*ppos < 0)
++ return -EINVAL;
++
++ if (count > size - *ppos)
++ count = size - *ppos;
++
++ for (i = *ppos / 2; count > 0; count -= bytes, *ppos += bytes, i++) {
++ void *from = &val;
++
++ if (!common->bus_ops->eeprom_read(common, i, &val))
++ val = 0xffff;
++
++ if (*ppos % 2) {
++ from++;
++ bytes = 1;
++ } else if (count == 1) {
++ bytes = 1;
++ } else {
++ bytes = 2;
++ }
++ copy_to_user(user_buf, from, bytes);
++ user_buf += bytes;
++ }
++ return *ppos - pos;
++}
++
++static const struct file_operations fops_eeprom = {
++ .read = read_file_eeprom,
++ .open = simple_open,
++ .owner = THIS_MODULE
++};
++
+ int ath9k_init_debug(struct ath_hw *ah)
+ {
+ struct ath_common *common = ath9k_hw_common(ah);
+@@ -2020,6 +2067,8 @@ int ath9k_init_debug(struct ath_hw *ah)
+
+ ath9k_dfs_init_debug(sc);
+
++ debugfs_create_file("eeprom", S_IRUSR, sc->debug.debugfs_phy, sc,
++ &fops_eeprom);
+ debugfs_create_file("dma", S_IRUSR, sc->debug.debugfs_phy, sc,
+ &fops_dma);
+ debugfs_create_file("interrupt", S_IRUSR, sc->debug.debugfs_phy, sc,
diff --git a/package/mac80211/patches/501-ath9k-eeprom_endianess.patch b/package/mac80211/patches/501-ath9k-eeprom_endianess.patch
new file mode 100644
index 0000000..bdd7e19
--- /dev/null
+++ b/package/mac80211/patches/501-ath9k-eeprom_endianess.patch
@@ -0,0 +1,102 @@
+--- a/drivers/net/wireless/ath/ath9k/eeprom_def.c
++++ b/drivers/net/wireless/ath/ath9k/eeprom_def.c
+@@ -262,7 +262,7 @@ static int ath9k_hw_def_check_eeprom(str
+ {
+ struct ar5416_eeprom_def *eep = &ah->eeprom.def;
+ struct ath_common *common = ath9k_hw_common(ah);
+- u16 *eepdata, temp, magic, magic2;
++ u16 *eepdata, temp, magic;
+ u32 sum = 0, el;
+ bool need_swap = false;
+ int i, addr, size;
+@@ -272,27 +272,16 @@ static int ath9k_hw_def_check_eeprom(str
+ return false;
+ }
+
+- if (!ath9k_hw_use_flash(ah)) {
+- ath_dbg(common, EEPROM, "Read Magic = 0x%04X\n", magic);
+-
+- if (magic != AR5416_EEPROM_MAGIC) {
+- magic2 = swab16(magic);
+-
+- if (magic2 == AR5416_EEPROM_MAGIC) {
+- size = sizeof(struct ar5416_eeprom_def);
+- need_swap = true;
+- eepdata = (u16 *) (&ah->eeprom);
+-
+- for (addr = 0; addr < size / sizeof(u16); addr++) {
+- temp = swab16(*eepdata);
+- *eepdata = temp;
+- eepdata++;
+- }
+- } else {
+- ath_err(common,
+- "Invalid EEPROM Magic. Endianness mismatch.\n");
+- return -EINVAL;
+- }
++ if (swab16(magic) == AR5416_EEPROM_MAGIC &&
++ !(ah->ah_flags & AH_NO_EEP_SWAP)) {
++ size = sizeof(struct ar5416_eeprom_def);
++ need_swap = true;
++ eepdata = (u16 *) (&ah->eeprom);
++
++ for (addr = 0; addr < size / sizeof(u16); addr++) {
++ temp = swab16(*eepdata);
++ *eepdata = temp;
++ eepdata++;
+ }
+ }
+
+--- a/drivers/net/wireless/ath/ath9k/eeprom_4k.c
++++ b/drivers/net/wireless/ath/ath9k/eeprom_4k.c
+@@ -57,7 +57,7 @@ static bool ath9k_hw_4k_fill_eeprom(stru
+ {
+ struct ath_common *common = ath9k_hw_common(ah);
+
+- if (!ath9k_hw_use_flash(ah)) {
++ if (!(ah->ah_flags & AH_NO_EEP_SWAP)) {
+ ath_dbg(common, EEPROM, "Reading from EEPROM, not flash\n");
+ }
+
+--- a/drivers/net/wireless/ath/ath9k/eeprom_9287.c
++++ b/drivers/net/wireless/ath/ath9k/eeprom_9287.c
+@@ -60,7 +60,7 @@ static bool ath9k_hw_ar9287_fill_eeprom(
+ {
+ struct ath_common *common = ath9k_hw_common(ah);
+
+- if (!ath9k_hw_use_flash(ah)) {
++ if (!(ah->ah_flags & AH_NO_EEP_SWAP)) {
+ ath_dbg(common, EEPROM, "Reading from EEPROM, not flash\n");
+ }
+
+--- a/drivers/net/wireless/ath/ath9k/hw.h
++++ b/drivers/net/wireless/ath/ath9k/hw.h
+@@ -740,6 +740,7 @@ enum ath_cal_list {
+ #define AH_USE_EEPROM 0x1
+ #define AH_UNPLUGGED 0x2 /* The card has been physically removed. */
+ #define AH_FASTCC 0x4
++#define AH_NO_EEP_SWAP 0x8 /* Do not swap EEPROM data */
+
+ struct ath_hw {
+ struct ath_ops reg_ops;
+--- a/drivers/net/wireless/ath/ath9k/init.c
++++ b/drivers/net/wireless/ath/ath9k/init.c
+@@ -587,6 +587,8 @@ static int ath9k_init_softc(u16 devid, s
+ ah->is_clk_25mhz = pdata->is_clk_25mhz;
+ ah->get_mac_revision = pdata->get_mac_revision;
+ ah->external_reset = pdata->external_reset;
++ if (!pdata->endian_check)
++ ah->ah_flags |= AH_NO_EEP_SWAP;
+ }
+
+ common = ath9k_hw_common(ah);
+--- a/include/linux/ath9k_platform.h
++++ b/include/linux/ath9k_platform.h
+@@ -31,6 +31,7 @@ struct ath9k_platform_data {
+ u32 gpio_mask;
+ u32 gpio_val;
+
++ bool endian_check;
+ bool is_clk_25mhz;
+ int (*get_mac_revision)(void);
+ int (*external_reset)(void);
diff --git a/package/mac80211/patches/502-ath9k_ahb_init.patch b/package/mac80211/patches/502-ath9k_ahb_init.patch
new file mode 100644
index 0000000..8884163
--- /dev/null
+++ b/package/mac80211/patches/502-ath9k_ahb_init.patch
@@ -0,0 +1,32 @@
+--- a/drivers/net/wireless/ath/ath9k/init.c
++++ b/drivers/net/wireless/ath/ath9k/init.c
+@@ -965,23 +965,23 @@ static int __init ath9k_init(void)
+ goto err_out;
+ }
+
+- error = ath_pci_init();
++ error = ath_ahb_init();
+ if (error < 0) {
+- pr_err("No PCI devices found, driver not installed\n");
+ error = -ENODEV;
+ goto err_rate_unregister;
+ }
+
+- error = ath_ahb_init();
++ error = ath_pci_init();
+ if (error < 0) {
++ pr_err("No PCI devices found, driver not installed\n");
+ error = -ENODEV;
+- goto err_pci_exit;
++ goto err_ahb_exit;
+ }
+
+ return 0;
+
+- err_pci_exit:
+- ath_pci_exit();
++ err_ahb_exit:
++ ath_ahb_exit();
+
+ err_rate_unregister:
+ ath_rate_control_unregister();
diff --git a/package/mac80211/patches/510-ath9k_intr_mitigation_tweak.patch b/package/mac80211/patches/510-ath9k_intr_mitigation_tweak.patch
new file mode 100644
index 0000000..ff6ff27
--- /dev/null
+++ b/package/mac80211/patches/510-ath9k_intr_mitigation_tweak.patch
@@ -0,0 +1,13 @@
+--- a/drivers/net/wireless/ath/ath9k/hw.c
++++ b/drivers/net/wireless/ath/ath9k/hw.c
+@@ -1947,8 +1947,8 @@ int ath9k_hw_reset(struct ath_hw *ah, st
+ REG_WRITE(ah, AR_OBS, 8);
+
+ if (ah->config.rx_intr_mitigation) {
+- REG_RMW_FIELD(ah, AR_RIMT, AR_RIMT_LAST, 500);
+- REG_RMW_FIELD(ah, AR_RIMT, AR_RIMT_FIRST, 2000);
++ REG_RMW_FIELD(ah, AR_RIMT, AR_RIMT_LAST, 250);
++ REG_RMW_FIELD(ah, AR_RIMT, AR_RIMT_FIRST, 500);
+ }
+
+ if (ah->config.tx_intr_mitigation) {
diff --git a/package/mac80211/patches/511-ath9k_reduce_rxbuf.patch b/package/mac80211/patches/511-ath9k_reduce_rxbuf.patch
new file mode 100644
index 0000000..8d8c5fd
--- /dev/null
+++ b/package/mac80211/patches/511-ath9k_reduce_rxbuf.patch
@@ -0,0 +1,11 @@
+--- a/drivers/net/wireless/ath/ath9k/ath9k.h
++++ b/drivers/net/wireless/ath/ath9k/ath9k.h
+@@ -119,7 +119,7 @@ int ath_descdma_setup(struct ath_softc *
+ /* RX / TX */
+ /***********/
+
+-#define ATH_RXBUF 512
++#define ATH_RXBUF 256
+ #define ATH_TXBUF 512
+ #define ATH_TXBUF_RESERVE 5
+ #define ATH_MAX_QDEPTH (ATH_TXBUF / 4 - ATH_TXBUF_RESERVE)
diff --git a/package/mac80211/patches/512-ath9k_channelbw_debugfs.patch b/package/mac80211/patches/512-ath9k_channelbw_debugfs.patch
new file mode 100644
index 0000000..1af9de0
--- /dev/null
+++ b/package/mac80211/patches/512-ath9k_channelbw_debugfs.patch
@@ -0,0 +1,128 @@
+--- a/drivers/net/wireless/ath/ath9k/ath9k.h
++++ b/drivers/net/wireless/ath/ath9k/ath9k.h
+@@ -690,6 +690,7 @@ struct ath_softc {
+ struct ieee80211_hw *hw;
+ struct device *dev;
+
++ u32 chan_bw;
+ struct survey_info *cur_survey;
+ struct survey_info survey[ATH9K_NUM_CHANNELS];
+
+@@ -894,6 +895,7 @@ struct fft_sample_ht20 {
+ u8 data[SPECTRAL_HT20_NUM_BINS];
+ } __packed;
+
++int ath9k_config(struct ieee80211_hw *hw, u32 changed);
+ void ath9k_tasklet(unsigned long data);
+ int ath_cabq_update(struct ath_softc *);
+
+--- a/drivers/net/wireless/ath/ath9k/debug.c
++++ b/drivers/net/wireless/ath/ath9k/debug.c
+@@ -2050,6 +2050,50 @@ static const struct file_operations fops
+ .owner = THIS_MODULE
+ };
+
++
++static ssize_t read_file_chan_bw(struct file *file, char __user *user_buf,
++ size_t count, loff_t *ppos)
++{
++ struct ath_softc *sc = file->private_data;
++ char buf[32];
++ unsigned int len;
++
++ len = sprintf(buf, "0x%08x\n", sc->chan_bw);
++ return simple_read_from_buffer(user_buf, count, ppos, buf, len);
++}
++
++static ssize_t write_file_chan_bw(struct file *file, const char __user *user_buf,
++ size_t count, loff_t *ppos)
++{
++ struct ath_softc *sc = file->private_data;
++ unsigned long chan_bw;
++ char buf[32];
++ ssize_t len;
++
++ len = min(count, sizeof(buf) - 1);
++ if (copy_from_user(buf, user_buf, len))
++ return -EFAULT;
++
++ buf[len] = '\0';
++ if (strict_strtoul(buf, 0, &chan_bw))
++ return -EINVAL;
++
++ sc->chan_bw = chan_bw;
++ if (!test_bit(SC_OP_INVALID, &sc->sc_flags))
++ ath9k_config(sc->hw, IEEE80211_CONF_CHANGE_CHANNEL);
++
++ return count;
++}
++
++static const struct file_operations fops_chanbw = {
++ .read = read_file_chan_bw,
++ .write = write_file_chan_bw,
++ .open = simple_open,
++ .owner = THIS_MODULE,
++ .llseek = default_llseek,
++};
++
++
+ int ath9k_init_debug(struct ath_hw *ah)
+ {
+ struct ath_common *common = ath9k_hw_common(ah);
+@@ -2069,6 +2113,8 @@ int ath9k_init_debug(struct ath_hw *ah)
+
+ debugfs_create_file("eeprom", S_IRUSR, sc->debug.debugfs_phy, sc,
+ &fops_eeprom);
++ debugfs_create_file("chanbw", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
++ sc, &fops_chanbw);
+ debugfs_create_file("dma", S_IRUSR, sc->debug.debugfs_phy, sc,
+ &fops_dma);
+ debugfs_create_file("interrupt", S_IRUSR, sc->debug.debugfs_phy, sc,
+--- a/drivers/net/wireless/ath/ath9k/main.c
++++ b/drivers/net/wireless/ath/ath9k/main.c
+@@ -1131,7 +1131,7 @@ int ath9k_spectral_scan_config(struct ie
+ return 0;
+ }
+
+-static int ath9k_config(struct ieee80211_hw *hw, u32 changed)
++int ath9k_config(struct ieee80211_hw *hw, u32 changed)
+ {
+ struct ath_softc *sc = hw->priv;
+ struct ath_hw *ah = sc->sc_ah;
+@@ -1185,9 +1185,11 @@ static int ath9k_config(struct ieee80211
+
+ if ((changed & IEEE80211_CONF_CHANGE_CHANNEL) || reset_channel) {
+ struct ieee80211_channel *curchan = hw->conf.channel;
++ struct ath9k_channel *hchan;
+ int pos = curchan->hw_value;
+ int old_pos = -1;
+ unsigned long flags;
++ u32 oldflags;
+
+ if (ah->curchan)
+ old_pos = ah->curchan - &ah->channels[0];
+@@ -1230,7 +1232,23 @@ static int ath9k_config(struct ieee80211
+ memset(&sc->survey[pos], 0, sizeof(struct survey_info));
+ }
+
+- if (ath_set_channel(sc, hw, &sc->sc_ah->channels[pos]) < 0) {
++ hchan = &sc->sc_ah->channels[pos];
++ oldflags = hchan->channelFlags;
++ switch (sc->chan_bw) {
++ case 5:
++ hchan->channelFlags &= ~CHANNEL_HALF;
++ hchan->channelFlags |= CHANNEL_QUARTER;
++ break;
++ case 10:
++ hchan->channelFlags &= ~CHANNEL_QUARTER;
++ hchan->channelFlags |= CHANNEL_HALF;
++ break;
++ default:
++ hchan->channelFlags &= ~(CHANNEL_HALF | CHANNEL_QUARTER);
++ break;
++ }
++
++ if (ath_set_channel(sc, hw, hchan) < 0) {
+ ath_err(common, "Unable to set channel\n");
+ mutex_unlock(&sc->mutex);
+ ath9k_ps_restore(sc);
diff --git a/package/mac80211/patches/513-mac80211_reduce_txqueuelen.patch b/package/mac80211/patches/513-mac80211_reduce_txqueuelen.patch
new file mode 100644
index 0000000..fe44cdb
--- /dev/null
+++ b/package/mac80211/patches/513-mac80211_reduce_txqueuelen.patch
@@ -0,0 +1,10 @@
+--- a/net/mac80211/iface.c
++++ b/net/mac80211/iface.c
+@@ -995,6 +995,7 @@ static const struct net_device_ops ieee8
+ static void ieee80211_if_setup(struct net_device *dev)
+ {
+ ether_setup(dev);
++ dev->tx_queue_len = 32;
+ dev->priv_flags &= ~IFF_TX_SKB_SHARING;
+ netdev_attach_ops(dev, &ieee80211_dataif_ops);
+ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29))
diff --git a/package/mac80211/patches/520-mac80211_cur_txpower.patch b/package/mac80211/patches/520-mac80211_cur_txpower.patch
new file mode 100644
index 0000000..f0ed3d9
--- /dev/null
+++ b/package/mac80211/patches/520-mac80211_cur_txpower.patch
@@ -0,0 +1,33 @@
+--- a/include/net/mac80211.h
++++ b/include/net/mac80211.h
+@@ -1554,6 +1554,7 @@ struct ieee80211_hw {
+ u8 max_tx_aggregation_subframes;
+ u8 offchannel_tx_hw_queue;
+ u8 radiotap_mcs_details;
++ s8 cur_power_level;
+ u16 radiotap_vht_details;
+ netdev_features_t netdev_features;
+ };
+--- a/net/mac80211/cfg.c
++++ b/net/mac80211/cfg.c
+@@ -2190,7 +2190,9 @@ static int ieee80211_get_tx_power(struct
+ struct ieee80211_local *local = wiphy_priv(wiphy);
+ struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
+
+- if (!local->use_chanctx)
++ if (local->hw.cur_power_level)
++ *dbm = local->hw.cur_power_level;
++ else if (!local->use_chanctx)
+ *dbm = local->hw.conf.power_level;
+ else
+ *dbm = sdata->vif.bss_conf.txpower;
+--- a/net/mac80211/main.c
++++ b/net/mac80211/main.c
+@@ -166,6 +166,7 @@ static u32 ieee80211_hw_conf_chan(struct
+
+ if (local->hw.conf.power_level != power) {
+ changed |= IEEE80211_CONF_CHANGE_POWER;
++ local->hw.cur_power_level = power;
+ local->hw.conf.power_level = power;
+ }
+
diff --git a/package/mac80211/patches/521-ath9k_cur_txpower.patch b/package/mac80211/patches/521-ath9k_cur_txpower.patch
new file mode 100644
index 0000000..fc091f2
--- /dev/null
+++ b/package/mac80211/patches/521-ath9k_cur_txpower.patch
@@ -0,0 +1,19 @@
+--- a/drivers/net/wireless/ath/ath9k/main.c
++++ b/drivers/net/wireless/ath/ath9k/main.c
+@@ -1255,6 +1255,8 @@ int ath9k_config(struct ieee80211_hw *hw
+ return -EINVAL;
+ }
+
++ hw->cur_power_level = sc->curtxpow / 2;
++
+ /*
+ * The most recent snapshot of channel->noisefloor for the old
+ * channel is only available after the hardware reset. Copy it to
+@@ -1274,6 +1276,7 @@ int ath9k_config(struct ieee80211_hw *hw
+ sc->config.txpowlimit = 2 * conf->power_level;
+ ath9k_cmn_update_txpow(ah, sc->curtxpow,
+ sc->config.txpowlimit, &sc->curtxpow);
++ hw->cur_power_level = sc->curtxpow / 2;
+ }
+
+ mutex_unlock(&sc->mutex);
diff --git a/package/mac80211/patches/522-ath9k_per_chain_signal_strength.patch b/package/mac80211/patches/522-ath9k_per_chain_signal_strength.patch
new file mode 100644
index 0000000..c0feedd
--- /dev/null
+++ b/package/mac80211/patches/522-ath9k_per_chain_signal_strength.patch
@@ -0,0 +1,393 @@
+--- a/include/net/mac80211.h
++++ b/include/net/mac80211.h
+@@ -839,6 +839,9 @@ enum mac80211_rx_flags {
+ * @signal: signal strength when receiving this frame, either in dBm, in dB or
+ * unspecified depending on the hardware capabilities flags
+ * @IEEE80211_HW_SIGNAL_*
++ * @chains: bitmask of receive chains for which separate signal strength
++ * values were filled.
++ * @chain_signal: per-chain signal strength, same format as @signal
+ * @antenna: antenna used
+ * @rate_idx: index of data rate into band's supported rates or MCS index if
+ * HT or VHT is used (%RX_FLAG_HT/%RX_FLAG_VHT)
+@@ -870,6 +873,8 @@ struct ieee80211_rx_status {
+ u8 band;
+ u8 antenna;
+ s8 signal;
++ u8 chains;
++ s8 chain_signal[4];
+ u8 ampdu_delimiter_crc;
+ u8 vendor_radiotap_align;
+ u8 vendor_radiotap_oui[3];
+--- a/net/mac80211/sta_info.h
++++ b/net/mac80211/sta_info.h
+@@ -342,6 +342,11 @@ struct sta_info {
+ int last_signal;
+ struct ewma avg_signal;
+ int last_ack_signal;
++
++ u8 chains;
++ s8 chain_signal_last[4];
++ struct ewma chain_signal_avg[4];
++
+ /* Plus 1 for non-QoS frames */
+ __le16 last_seq_ctrl[IEEE80211_NUM_TIDS + 1];
+
+--- a/net/mac80211/rx.c
++++ b/net/mac80211/rx.c
+@@ -1383,6 +1383,7 @@ ieee80211_rx_h_sta_process(struct ieee80
+ struct sk_buff *skb = rx->skb;
+ struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
+ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
++ int i;
+
+ if (!sta)
+ return RX_CONTINUE;
+@@ -1433,6 +1434,19 @@ ieee80211_rx_h_sta_process(struct ieee80
+ ewma_add(&sta->avg_signal, -status->signal);
+ }
+
++ if (status->chains) {
++ sta->chains = status->chains;
++ for (i = 0; i < 4; i++) {
++ int signal = status->chain_signal[i];
++
++ if (!(status->chains & BIT(i)))
++ continue;
++
++ sta->chain_signal_last[i] = signal;
++ ewma_add(&sta->chain_signal_avg[i], -signal);
++ }
++ }
++
+ /*
+ * Change STA power saving mode only at the end of a frame
+ * exchange sequence.
+--- a/net/mac80211/sta_info.c
++++ b/net/mac80211/sta_info.c
+@@ -353,6 +353,8 @@ struct sta_info *sta_info_alloc(struct i
+ do_posix_clock_monotonic_gettime(&uptime);
+ sta->last_connected = uptime.tv_sec;
+ ewma_init(&sta->avg_signal, 1024, 8);
++ for (i = 0; i < ARRAY_SIZE(sta->chain_signal_avg); i++)
++ ewma_init(&sta->chain_signal_avg[i], 1024, 8);
+
+ if (sta_prepare_rate_control(local, sta, gfp)) {
+ kfree(sta);
+--- a/include/net/cfg80211.h
++++ b/include/net/cfg80211.h
+@@ -721,6 +721,8 @@ struct station_parameters {
+ * @STATION_INFO_LOCAL_PM: @local_pm filled
+ * @STATION_INFO_PEER_PM: @peer_pm filled
+ * @STATION_INFO_NONPEER_PM: @nonpeer_pm filled
++ * @STATION_INFO_CHAIN_SIGNAL: @chain_signal filled
++ * @STATION_INFO_CHAIN_SIGNAL_AVG: @chain_signal_avg filled
+ */
+ enum station_info_flags {
+ STATION_INFO_INACTIVE_TIME = 1<<0,
+@@ -749,6 +751,8 @@ enum station_info_flags {
+ STATION_INFO_NONPEER_PM = 1<<23,
+ STATION_INFO_RX_BYTES64 = 1<<24,
+ STATION_INFO_TX_BYTES64 = 1<<25,
++ STATION_INFO_CHAIN_SIGNAL = 1<<26,
++ STATION_INFO_CHAIN_SIGNAL_AVG = 1<<27,
+ };
+
+ /**
+@@ -842,6 +846,9 @@ struct sta_bss_parameters {
+ * For CFG80211_SIGNAL_TYPE_MBM, value is expressed in _dBm_.
+ * @signal_avg: Average signal strength, type depends on the wiphy's signal_type.
+ * For CFG80211_SIGNAL_TYPE_MBM, value is expressed in _dBm_.
++ * @chains: bitmask for filled values in @chain_signal, @chain_signal_avg
++ * @chain_signal: per-chain signal strength of last received packet in dBm
++ * @chain_signal_avg: per-chain signal strength average in dBm
+ * @txrate: current unicast bitrate from this station
+ * @rxrate: current unicast bitrate to this station
+ * @rx_packets: packets received from this station
+@@ -877,6 +884,11 @@ struct station_info {
+ u8 plink_state;
+ s8 signal;
+ s8 signal_avg;
++
++ u8 chains;
++ s8 chain_signal[4];
++ s8 chain_signal_avg[4];
++
+ struct rate_info txrate;
+ struct rate_info rxrate;
+ u32 rx_packets;
+--- a/drivers/net/wireless/ath/ath9k/mac.h
++++ b/drivers/net/wireless/ath/ath9k/mac.h
+@@ -133,12 +133,8 @@ struct ath_rx_status {
+ u8 rs_rate;
+ u8 rs_antenna;
+ u8 rs_more;
+- int8_t rs_rssi_ctl0;
+- int8_t rs_rssi_ctl1;
+- int8_t rs_rssi_ctl2;
+- int8_t rs_rssi_ext0;
+- int8_t rs_rssi_ext1;
+- int8_t rs_rssi_ext2;
++ int8_t rs_rssi_ctl[3];
++ int8_t rs_rssi_ext[3];
+ u8 rs_isaggr;
+ u8 rs_moreaggr;
+ u8 rs_num_delims;
+--- a/drivers/net/wireless/ath/ath9k/recv.c
++++ b/drivers/net/wireless/ath/ath9k/recv.c
+@@ -937,6 +937,7 @@ static int ath9k_rx_skb_preprocess(struc
+ bool *decrypt_error)
+ {
+ struct ath_hw *ah = common->ah;
++ int i, j;
+
+ /*
+ * everything but the rate is checked here, the rate check is done
+@@ -962,6 +963,20 @@ static int ath9k_rx_skb_preprocess(struc
+ if (rx_stats->rs_moreaggr)
+ rx_status->flag |= RX_FLAG_NO_SIGNAL_VAL;
+
++ for (i = 0, j = 0; i < ARRAY_SIZE(rx_stats->rs_rssi_ctl); i++) {
++ s8 rssi;
++
++ if (!(ah->rxchainmask & BIT(i)))
++ continue;
++
++ rssi = rx_stats->rs_rssi_ctl[i];
++ if (rssi != ATH9K_RSSI_BAD) {
++ rx_status->chains |= BIT(j);
++ rx_status->chain_signal[j] = ah->noise + rssi;
++ }
++ j++;
++ }
++
+ return 0;
+ }
+
+@@ -1070,7 +1085,7 @@ static int ath_process_fft(struct ath_so
+ fft_sample.tlv.length = __cpu_to_be16(length);
+
+ fft_sample.freq = __cpu_to_be16(ah->curchan->chan->center_freq);
+- fft_sample.rssi = fix_rssi_inv_only(rs->rs_rssi_ctl0);
++ fft_sample.rssi = fix_rssi_inv_only(rs->rs_rssi_ctl[0]);
+ fft_sample.noise = ah->noise;
+
+ switch (len - SPECTRAL_HT20_TOTAL_DATA_LEN) {
+--- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
++++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
+@@ -475,12 +475,12 @@ int ath9k_hw_process_rxdesc_edma(struct
+
+ /* XXX: Keycache */
+ rxs->rs_rssi = MS(rxsp->status5, AR_RxRSSICombined);
+- rxs->rs_rssi_ctl0 = MS(rxsp->status1, AR_RxRSSIAnt00);
+- rxs->rs_rssi_ctl1 = MS(rxsp->status1, AR_RxRSSIAnt01);
+- rxs->rs_rssi_ctl2 = MS(rxsp->status1, AR_RxRSSIAnt02);
+- rxs->rs_rssi_ext0 = MS(rxsp->status5, AR_RxRSSIAnt10);
+- rxs->rs_rssi_ext1 = MS(rxsp->status5, AR_RxRSSIAnt11);
+- rxs->rs_rssi_ext2 = MS(rxsp->status5, AR_RxRSSIAnt12);
++ rxs->rs_rssi_ctl[0] = MS(rxsp->status1, AR_RxRSSIAnt00);
++ rxs->rs_rssi_ctl[1] = MS(rxsp->status1, AR_RxRSSIAnt01);
++ rxs->rs_rssi_ctl[2] = MS(rxsp->status1, AR_RxRSSIAnt02);
++ rxs->rs_rssi_ext[0] = MS(rxsp->status5, AR_RxRSSIAnt10);
++ rxs->rs_rssi_ext[1] = MS(rxsp->status5, AR_RxRSSIAnt11);
++ rxs->rs_rssi_ext[2] = MS(rxsp->status5, AR_RxRSSIAnt12);
+
+ if (rxsp->status11 & AR_RxKeyIdxValid)
+ rxs->rs_keyix = MS(rxsp->status11, AR_KeyIdx);
+--- a/drivers/net/wireless/ath/ath9k/mac.c
++++ b/drivers/net/wireless/ath/ath9k/mac.c
+@@ -553,25 +553,25 @@ int ath9k_hw_rxprocdesc(struct ath_hw *a
+
+ if (ads.ds_rxstatus8 & AR_PostDelimCRCErr) {
+ rs->rs_rssi = ATH9K_RSSI_BAD;
+- rs->rs_rssi_ctl0 = ATH9K_RSSI_BAD;
+- rs->rs_rssi_ctl1 = ATH9K_RSSI_BAD;
+- rs->rs_rssi_ctl2 = ATH9K_RSSI_BAD;
+- rs->rs_rssi_ext0 = ATH9K_RSSI_BAD;
+- rs->rs_rssi_ext1 = ATH9K_RSSI_BAD;
+- rs->rs_rssi_ext2 = ATH9K_RSSI_BAD;
++ rs->rs_rssi_ctl[0] = ATH9K_RSSI_BAD;
++ rs->rs_rssi_ctl[1] = ATH9K_RSSI_BAD;
++ rs->rs_rssi_ctl[2] = ATH9K_RSSI_BAD;
++ rs->rs_rssi_ext[0] = ATH9K_RSSI_BAD;
++ rs->rs_rssi_ext[1] = ATH9K_RSSI_BAD;
++ rs->rs_rssi_ext[2] = ATH9K_RSSI_BAD;
+ } else {
+ rs->rs_rssi = MS(ads.ds_rxstatus4, AR_RxRSSICombined);
+- rs->rs_rssi_ctl0 = MS(ads.ds_rxstatus0,
++ rs->rs_rssi_ctl[0] = MS(ads.ds_rxstatus0,
+ AR_RxRSSIAnt00);
+- rs->rs_rssi_ctl1 = MS(ads.ds_rxstatus0,
++ rs->rs_rssi_ctl[1] = MS(ads.ds_rxstatus0,
+ AR_RxRSSIAnt01);
+- rs->rs_rssi_ctl2 = MS(ads.ds_rxstatus0,
++ rs->rs_rssi_ctl[2] = MS(ads.ds_rxstatus0,
+ AR_RxRSSIAnt02);
+- rs->rs_rssi_ext0 = MS(ads.ds_rxstatus4,
++ rs->rs_rssi_ext[0] = MS(ads.ds_rxstatus4,
+ AR_RxRSSIAnt10);
+- rs->rs_rssi_ext1 = MS(ads.ds_rxstatus4,
++ rs->rs_rssi_ext[1] = MS(ads.ds_rxstatus4,
+ AR_RxRSSIAnt11);
+- rs->rs_rssi_ext2 = MS(ads.ds_rxstatus4,
++ rs->rs_rssi_ext[2] = MS(ads.ds_rxstatus4,
+ AR_RxRSSIAnt12);
+ }
+ if (ads.ds_rxstatus8 & AR_RxKeyIdxValid)
+--- a/drivers/net/wireless/ath/ath9k/debug.c
++++ b/drivers/net/wireless/ath/ath9k/debug.c
+@@ -940,12 +940,12 @@ void ath_debug_stat_rx(struct ath_softc
+ #ifdef CONFIG_ATH9K_MAC_DEBUG
+ spin_lock(&sc->debug.samp_lock);
+ RX_SAMP_DBG(jiffies) = jiffies;
+- RX_SAMP_DBG(rssi_ctl0) = rs->rs_rssi_ctl0;
+- RX_SAMP_DBG(rssi_ctl1) = rs->rs_rssi_ctl1;
+- RX_SAMP_DBG(rssi_ctl2) = rs->rs_rssi_ctl2;
+- RX_SAMP_DBG(rssi_ext0) = rs->rs_rssi_ext0;
+- RX_SAMP_DBG(rssi_ext1) = rs->rs_rssi_ext1;
+- RX_SAMP_DBG(rssi_ext2) = rs->rs_rssi_ext2;
++ RX_SAMP_DBG(rssi_ctl0) = rs->rs_rssi_ctl[0];
++ RX_SAMP_DBG(rssi_ctl1) = rs->rs_rssi_ctl[1];
++ RX_SAMP_DBG(rssi_ctl2) = rs->rs_rssi_ctl[2];
++ RX_SAMP_DBG(rssi_ext0) = rs->rs_rssi_ext[0];
++ RX_SAMP_DBG(rssi_ext1) = rs->rs_rssi_ext[1];
++ RX_SAMP_DBG(rssi_ext2) = rs->rs_rssi_ext[2];
+ RX_SAMP_DBG(antenna) = rs->rs_antenna;
+ RX_SAMP_DBG(rssi) = rs->rs_rssi;
+ RX_SAMP_DBG(rate) = rs->rs_rate;
+--- a/include/uapi/linux/nl80211.h
++++ b/include/uapi/linux/nl80211.h
+@@ -1918,6 +1918,8 @@ enum nl80211_sta_bss_param {
+ * @NL80211_STA_INFO_PEER_PM: peer mesh STA link-specific power mode
+ * @NL80211_STA_INFO_NONPEER_PM: neighbor mesh STA power save mode towards
+ * non-peer STA
++ * @NL80211_STA_INFO_CHAIN_SIGNAL: per-chain signal strength of last PPDU
++ * @NL80211_STA_INFO_CHAIN_SIGNAL_AVG: per-chain signal strength average
+ * @__NL80211_STA_INFO_AFTER_LAST: internal
+ * @NL80211_STA_INFO_MAX: highest possible station info attribute
+ */
+@@ -1947,6 +1949,8 @@ enum nl80211_sta_info {
+ NL80211_STA_INFO_NONPEER_PM,
+ NL80211_STA_INFO_RX_BYTES64,
+ NL80211_STA_INFO_TX_BYTES64,
++ NL80211_STA_INFO_CHAIN_SIGNAL,
++ NL80211_STA_INFO_CHAIN_SIGNAL_AVG,
+
+ /* keep last */
+ __NL80211_STA_INFO_AFTER_LAST,
+--- a/net/wireless/nl80211.c
++++ b/net/wireless/nl80211.c
+@@ -3082,6 +3082,32 @@ static bool nl80211_put_sta_rate(struct
+ return true;
+ }
+
++static bool nl80211_put_signal(struct sk_buff *msg, u8 mask, s8 *signal,
++ int id)
++{
++ void *attr;
++ int i = 0;
++
++ if (!mask)
++ return true;
++
++ attr = nla_nest_start(msg, id);
++ if (!attr)
++ return false;
++
++ for (i = 0; i < 4; i++) {
++ if (!(mask & BIT(i)))
++ continue;
++
++ if (nla_put_u8(msg, i, signal[i]))
++ return false;
++ }
++
++ nla_nest_end(msg, attr);
++
++ return true;
++}
++
+ static int nl80211_send_station(struct sk_buff *msg, u32 portid, u32 seq,
+ int flags,
+ struct cfg80211_registered_device *rdev,
+@@ -3153,6 +3179,18 @@ static int nl80211_send_station(struct s
+ default:
+ break;
+ }
++ if (sinfo->filled & STATION_INFO_CHAIN_SIGNAL) {
++ if (!nl80211_put_signal(msg, sinfo->chains,
++ sinfo->chain_signal,
++ NL80211_STA_INFO_CHAIN_SIGNAL))
++ goto nla_put_failure;
++ }
++ if (sinfo->filled & STATION_INFO_CHAIN_SIGNAL_AVG) {
++ if (!nl80211_put_signal(msg, sinfo->chains,
++ sinfo->chain_signal_avg,
++ NL80211_STA_INFO_CHAIN_SIGNAL_AVG))
++ goto nla_put_failure;
++ }
+ if (sinfo->filled & STATION_INFO_TX_BITRATE) {
+ if (!nl80211_put_sta_rate(msg, &sinfo->txrate,
+ NL80211_STA_INFO_TX_BITRATE))
+--- a/net/mac80211/cfg.c
++++ b/net/mac80211/cfg.c
+@@ -445,6 +445,7 @@ static void sta_set_sinfo(struct sta_inf
+ struct ieee80211_sub_if_data *sdata = sta->sdata;
+ struct ieee80211_local *local = sdata->local;
+ struct timespec uptime;
++ int i;
+
+ sinfo->generation = sdata->local->sta_generation;
+
+@@ -484,6 +485,17 @@ static void sta_set_sinfo(struct sta_inf
+ sinfo->signal = (s8)sta->last_signal;
+ sinfo->signal_avg = (s8) -ewma_read(&sta->avg_signal);
+ }
++ if (sta->chains) {
++ sinfo->filled |= STATION_INFO_CHAIN_SIGNAL |
++ STATION_INFO_CHAIN_SIGNAL_AVG;
++
++ sinfo->chains = sta->chains;
++ for (i = 0; i < ARRAY_SIZE(sinfo->chain_signal); i++) {
++ sinfo->chain_signal[i] = sta->chain_signal_last[i];
++ sinfo->chain_signal_avg[i] =
++ (s8) -ewma_read(&sta->chain_signal_avg[i]);
++ }
++ }
+
+ sta_set_rate_info_tx(sta, &sta->last_tx_rate, &sinfo->txrate);
+ sta_set_rate_info_rx(sta, &sinfo->rxrate);
+--- a/drivers/net/wireless/ath/ath9k/dfs.c
++++ b/drivers/net/wireless/ath/ath9k/dfs.c
+@@ -164,8 +164,8 @@ void ath9k_dfs_process_phyerr(struct ath
+ return;
+ }
+
+- ard.rssi = rs->rs_rssi_ctl0;
+- ard.ext_rssi = rs->rs_rssi_ext0;
++ ard.rssi = rs->rs_rssi_ctl[0];
++ ard.ext_rssi = rs->rs_rssi_ext[0];
+
+ /*
+ * hardware stores this as 8 bit signed value.
+--- a/drivers/net/wireless/ath/ath9k/antenna.c
++++ b/drivers/net/wireless/ath/ath9k/antenna.c
+@@ -546,14 +546,14 @@ void ath_ant_comb_scan(struct ath_softc
+ struct ath_ant_comb *antcomb = &sc->ant_comb;
+ int alt_ratio = 0, alt_rssi_avg = 0, main_rssi_avg = 0, curr_alt_set;
+ int curr_main_set;
+- int main_rssi = rs->rs_rssi_ctl0;
+- int alt_rssi = rs->rs_rssi_ctl1;
++ int main_rssi = rs->rs_rssi_ctl[0];
++ int alt_rssi = rs->rs_rssi_ctl[1];
+ int rx_ant_conf, main_ant_conf;
+ bool short_scan = false;
+
+- rx_ant_conf = (rs->rs_rssi_ctl2 >> ATH_ANT_RX_CURRENT_SHIFT) &
++ rx_ant_conf = (rs->rs_rssi_ctl[2] >> ATH_ANT_RX_CURRENT_SHIFT) &
+ ATH_ANT_RX_MASK;
+- main_ant_conf = (rs->rs_rssi_ctl2 >> ATH_ANT_RX_MAIN_SHIFT) &
++ main_ant_conf = (rs->rs_rssi_ctl[2] >> ATH_ANT_RX_MAIN_SHIFT) &
+ ATH_ANT_RX_MASK;
+
+ /* Record packet only when both main_rssi and alt_rssi is positive */
diff --git a/package/mac80211/patches/523-mac80211_configure_antenna_gain.patch b/package/mac80211/patches/523-mac80211_configure_antenna_gain.patch
new file mode 100644
index 0000000..8c13f32
--- /dev/null
+++ b/package/mac80211/patches/523-mac80211_configure_antenna_gain.patch
@@ -0,0 +1,162 @@
+--- a/include/net/mac80211.h
++++ b/include/net/mac80211.h
+@@ -978,6 +978,7 @@ enum ieee80211_smps_mode {
+ *
+ * @power_level: requested transmit power (in dBm), backward compatibility
+ * value only that is set to the minimum of all interfaces
++ * @max_antenna_gain: maximum antenna gain adjusted by user config (in dBi)
+ *
+ * @channel: the channel to tune to
+ * @channel_type: the channel (HT) type
+@@ -1000,6 +1001,7 @@ struct ieee80211_conf {
+ u32 flags;
+ int power_level, dynamic_ps_timeout;
+ int max_sleep_period;
++ int max_antenna_gain;
+
+ u16 listen_interval;
+ u8 ps_dtim_period;
+--- a/net/mac80211/ieee80211_i.h
++++ b/net/mac80211/ieee80211_i.h
+@@ -1116,6 +1116,7 @@ struct ieee80211_local {
+ int dynamic_ps_forced_timeout;
+
+ int user_power_level; /* in dBm, for all interfaces */
++ int user_antenna_gain; /* in dBi */
+
+ enum ieee80211_smps_mode smps_mode;
+
+--- a/include/uapi/linux/nl80211.h
++++ b/include/uapi/linux/nl80211.h
+@@ -1654,6 +1654,8 @@ enum nl80211_attrs {
+ NL80211_ATTR_STA_CAPABILITY,
+ NL80211_ATTR_STA_EXT_CAPABILITY,
+
++ NL80211_ATTR_WIPHY_ANTENNA_GAIN,
++
+ /* add attributes here, update the policy in nl80211.c */
+
+ __NL80211_ATTR_AFTER_LAST,
+--- a/net/wireless/nl80211.c
++++ b/net/wireless/nl80211.c
+@@ -370,6 +370,7 @@ static const struct nla_policy nl80211_p
+ [NL80211_ATTR_MAC_ADDRS] = { .type = NLA_NESTED },
+ [NL80211_ATTR_STA_CAPABILITY] = { .type = NLA_U16 },
+ [NL80211_ATTR_STA_EXT_CAPABILITY] = { .type = NLA_BINARY, },
++ [NL80211_ATTR_WIPHY_ANTENNA_GAIN] = { .type = NLA_U32 },
+ };
+
+ /* policy for the key attributes */
+@@ -1705,6 +1706,22 @@ static int nl80211_set_wiphy(struct sk_b
+ if (result)
+ goto bad_res;
+ }
++
++ if (info->attrs[NL80211_ATTR_WIPHY_ANTENNA_GAIN]) {
++ int idx, dbi = 0;
++
++ if (!rdev->ops->set_antenna_gain) {
++ result = -EOPNOTSUPP;
++ goto bad_res;
++ }
++
++ idx = NL80211_ATTR_WIPHY_ANTENNA_GAIN;
++ dbi = nla_get_u32(info->attrs[idx]);
++
++ result = rdev->ops->set_antenna_gain(&rdev->wiphy, dbi);
++ if (result)
++ goto bad_res;
++ }
+
+ if (info->attrs[NL80211_ATTR_WIPHY_ANTENNA_TX] &&
+ info->attrs[NL80211_ATTR_WIPHY_ANTENNA_RX]) {
+--- a/net/mac80211/cfg.c
++++ b/net/mac80211/cfg.c
+@@ -2212,6 +2212,19 @@ static int ieee80211_get_tx_power(struct
+ return 0;
+ }
+
++static int ieee80211_set_antenna_gain(struct wiphy *wiphy, int dbi)
++{
++ struct ieee80211_local *local = wiphy_priv(wiphy);
++
++ if (dbi < 0)
++ return -EINVAL;
++
++ local->user_antenna_gain = dbi;
++ ieee80211_hw_config(local, 0);
++
++ return 0;
++}
++
+ static int ieee80211_set_wds_peer(struct wiphy *wiphy, struct net_device *dev,
+ const u8 *addr)
+ {
+@@ -3375,6 +3388,7 @@ struct cfg80211_ops mac80211_config_ops
+ .set_wiphy_params = ieee80211_set_wiphy_params,
+ .set_tx_power = ieee80211_set_tx_power,
+ .get_tx_power = ieee80211_get_tx_power,
++ .set_antenna_gain = ieee80211_set_antenna_gain,
+ .set_wds_peer = ieee80211_set_wds_peer,
+ .rfkill_poll = ieee80211_rfkill_poll,
+ CFG80211_TESTMODE_CMD(ieee80211_testmode_cmd)
+--- a/include/net/cfg80211.h
++++ b/include/net/cfg80211.h
+@@ -1862,6 +1862,7 @@ struct cfg80211_gtk_rekey_data {
+ * (as advertised by the nl80211 feature flag.)
+ * @get_tx_power: store the current TX power into the dbm variable;
+ * return 0 if successful
++ * @set_antenna_gain: set antenna gain to reduce maximum tx power if necessary
+ *
+ * @set_wds_peer: set the WDS peer for a WDS interface
+ *
+@@ -2071,6 +2072,7 @@ struct cfg80211_ops {
+ enum nl80211_tx_power_setting type, int mbm);
+ int (*get_tx_power)(struct wiphy *wiphy, struct wireless_dev *wdev,
+ int *dbm);
++ int (*set_antenna_gain)(struct wiphy *wiphy, int dbi);
+
+ int (*set_wds_peer)(struct wiphy *wiphy, struct net_device *dev,
+ const u8 *addr);
+--- a/net/mac80211/main.c
++++ b/net/mac80211/main.c
+@@ -101,7 +101,7 @@ static u32 ieee80211_hw_conf_chan(struct
+ struct ieee80211_sub_if_data *sdata;
+ struct ieee80211_channel *chan;
+ u32 changed = 0;
+- int power;
++ int power, ant_gain, max_power;
+ enum nl80211_channel_type channel_type;
+ u32 offchannel_flag;
+ bool scanning = false;
+@@ -164,8 +164,21 @@ static u32 ieee80211_hw_conf_chan(struct
+ }
+ rcu_read_unlock();
+
+- if (local->hw.conf.power_level != power) {
++ max_power = chan->max_reg_power;
++ ant_gain = chan->max_antenna_gain;
++ if (local->user_antenna_gain > 0) {
++ if (local->user_antenna_gain > ant_gain) {
++ max_power -= local->user_antenna_gain - ant_gain;
++ ant_gain = 0;
++ } else
++ ant_gain -= local->user_antenna_gain;
++ power = min(power, max_power);
++ }
++
++ if (local->hw.conf.power_level != power ||
++ local->hw.conf.max_antenna_gain != ant_gain) {
+ changed |= IEEE80211_CONF_CHANGE_POWER;
++ local->hw.conf.max_antenna_gain = ant_gain;
+ local->hw.cur_power_level = power;
+ local->hw.conf.power_level = power;
+ }
+@@ -612,6 +625,7 @@ struct ieee80211_hw *ieee80211_alloc_hw(
+ IEEE80211_RADIOTAP_MCS_HAVE_BW;
+ local->hw.radiotap_vht_details = IEEE80211_RADIOTAP_VHT_KNOWN_GI |
+ IEEE80211_RADIOTAP_VHT_KNOWN_BANDWIDTH;
++ local->user_antenna_gain = 0;
+ local->user_power_level = IEEE80211_UNSET_POWER_LEVEL;
+ wiphy->ht_capa_mod_mask = &mac80211_ht_capa_mod_mask;
+
diff --git a/package/mac80211/patches/524-ath9k_use_configured_antenna_gain.patch b/package/mac80211/patches/524-ath9k_use_configured_antenna_gain.patch
new file mode 100644
index 0000000..fe05212
--- /dev/null
+++ b/package/mac80211/patches/524-ath9k_use_configured_antenna_gain.patch
@@ -0,0 +1,34 @@
+--- a/drivers/net/wireless/ath/ath.h
++++ b/drivers/net/wireless/ath/ath.h
+@@ -73,6 +73,7 @@ struct ath_regulatory {
+ u16 max_power_level;
+ u16 current_rd;
+ int16_t power_limit;
++ int16_t max_antenna_gain;
+ struct reg_dmn_pair_mapping *regpair;
+ };
+
+--- a/drivers/net/wireless/ath/ath9k/hw.c
++++ b/drivers/net/wireless/ath/ath9k/hw.c
+@@ -2818,7 +2818,7 @@ void ath9k_hw_apply_txpower(struct ath_h
+ channel = chan->chan;
+ chan_pwr = min_t(int, channel->max_power * 2, MAX_RATE_POWER);
+ new_pwr = min_t(int, chan_pwr, reg->power_limit);
+- max_gain = chan_pwr - new_pwr + channel->max_antenna_gain * 2;
++ max_gain = chan_pwr - new_pwr + reg->max_antenna_gain * 2;
+
+ ant_gain = get_antenna_gain(ah, chan);
+ if (ant_gain > max_gain)
+--- a/drivers/net/wireless/ath/ath9k/main.c
++++ b/drivers/net/wireless/ath/ath9k/main.c
+@@ -1272,7 +1272,10 @@ int ath9k_config(struct ieee80211_hw *hw
+ }
+
+ if (changed & IEEE80211_CONF_CHANGE_POWER) {
++ struct ath_regulatory *reg = ath9k_hw_regulatory(ah);
++
+ ath_dbg(common, CONFIG, "Set power: %d\n", conf->power_level);
++ reg->max_antenna_gain = conf->max_antenna_gain;
+ sc->config.txpowlimit = 2 * conf->power_level;
+ ath9k_cmn_update_txpow(ah, sc->curtxpow,
+ sc->config.txpowlimit, &sc->curtxpow);
diff --git a/package/mac80211/patches/530-ath9k_extra_leds.patch b/package/mac80211/patches/530-ath9k_extra_leds.patch
new file mode 100644
index 0000000..a13cb41
--- /dev/null
+++ b/package/mac80211/patches/530-ath9k_extra_leds.patch
@@ -0,0 +1,248 @@
+--- a/drivers/net/wireless/ath/ath9k/ath9k.h
++++ b/drivers/net/wireless/ath/ath9k/ath9k.h
+@@ -551,6 +551,9 @@ struct ath9k_wow_pattern {
+ void ath_init_leds(struct ath_softc *sc);
+ void ath_deinit_leds(struct ath_softc *sc);
+ void ath_fill_led_pin(struct ath_softc *sc);
++int ath_create_gpio_led(struct ath_softc *sc, int gpio, const char *name,
++ const char *trigger, bool active_low);
++
+ #else
+ static inline void ath_init_leds(struct ath_softc *sc)
+ {
+@@ -686,6 +689,13 @@ enum spectral_mode {
+ SPECTRAL_CHANSCAN,
+ };
+
++struct ath_led {
++ struct list_head list;
++ struct ath_softc *sc;
++ const struct gpio_led *gpio;
++ struct led_classdev cdev;
++};
++
+ struct ath_softc {
+ struct ieee80211_hw *hw;
+ struct device *dev;
+@@ -727,9 +737,8 @@ struct ath_softc {
+ struct ieee80211_supported_band sbands[IEEE80211_NUM_BANDS];
+
+ #ifdef CONFIG_MAC80211_LEDS
+- bool led_registered;
+- char led_name[32];
+- struct led_classdev led_cdev;
++ const char *led_default_trigger;
++ struct list_head leds;
+ #endif
+
+ struct ath9k_hw_cal_data caldata;
+--- a/drivers/net/wireless/ath/ath9k/gpio.c
++++ b/drivers/net/wireless/ath/ath9k/gpio.c
+@@ -24,40 +24,102 @@
+ static void ath_led_brightness(struct led_classdev *led_cdev,
+ enum led_brightness brightness)
+ {
+- struct ath_softc *sc = container_of(led_cdev, struct ath_softc, led_cdev);
+- ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, (brightness == LED_OFF));
++ struct ath_led *led = container_of(led_cdev, struct ath_led, cdev);
++ struct ath_softc *sc = led->sc;
++
++ ath9k_ps_wakeup(sc);
++ ath9k_hw_set_gpio(sc->sc_ah, led->gpio->gpio,
++ (brightness != LED_OFF) ^ led->gpio->active_low);
++ ath9k_ps_restore(sc);
++}
++
++static int ath_add_led(struct ath_softc *sc, struct ath_led *led)
++{
++ const struct gpio_led *gpio = led->gpio;
++ int ret;
++
++ led->cdev.name = gpio->name;
++ led->cdev.default_trigger = gpio->default_trigger;
++ led->cdev.brightness_set = ath_led_brightness;
++
++ ret = led_classdev_register(wiphy_dev(sc->hw->wiphy), &led->cdev);
++ if (ret < 0)
++ return ret;
++
++ led->sc = sc;
++ list_add(&led->list, &sc->leds);
++
++ /* Configure gpio for output */
++ ath9k_hw_cfg_output(sc->sc_ah, gpio->gpio,
++ AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
++
++ /* LED off */
++ ath9k_hw_set_gpio(sc->sc_ah, gpio->gpio, gpio->active_low);
++
++ return 0;
++}
++
++int ath_create_gpio_led(struct ath_softc *sc, int gpio_num, const char *name,
++ const char *trigger, bool active_low)
++{
++ struct ath_led *led;
++ struct gpio_led *gpio;
++ char *_name;
++ int ret;
++
++ led = kzalloc(sizeof(*led) + sizeof(*gpio) + strlen(name) + 1,
++ GFP_KERNEL);
++ if (!led)
++ return -ENOMEM;
++
++ led->gpio = gpio = (struct gpio_led *) (led + 1);
++ _name = (char *) (led->gpio + 1);
++
++ strcpy(_name, name);
++ gpio->name = _name;
++ gpio->gpio = gpio_num;
++ gpio->active_low = active_low;
++ gpio->default_trigger = trigger;
++
++ ret = ath_add_led(sc, led);
++ if (unlikely(ret < 0))
++ kfree(led);
++
++ return ret;
+ }
+
+ void ath_deinit_leds(struct ath_softc *sc)
+ {
+- if (!sc->led_registered)
+- return;
++ struct ath_led *led;
+
+- ath_led_brightness(&sc->led_cdev, LED_OFF);
+- led_classdev_unregister(&sc->led_cdev);
++ while (!list_empty(&sc->leds)) {
++ led = list_first_entry(&sc->leds, struct ath_led, list);
++ list_del(&led->list);
++ ath_led_brightness(&led->cdev, LED_OFF);
++ led_classdev_unregister(&led->cdev);
++ kfree(led);
++ }
+ }
+
+ void ath_init_leds(struct ath_softc *sc)
+ {
+- int ret;
++ char led_name[32];
++ const char *trigger;
++
++ INIT_LIST_HEAD(&sc->leds);
+
+ if (AR_SREV_9100(sc->sc_ah))
+ return;
+
+- if (!led_blink)
+- sc->led_cdev.default_trigger =
+- ieee80211_get_radio_led_name(sc->hw);
+-
+- snprintf(sc->led_name, sizeof(sc->led_name),
+- "ath9k-%s", wiphy_name(sc->hw->wiphy));
+- sc->led_cdev.name = sc->led_name;
+- sc->led_cdev.brightness_set = ath_led_brightness;
++ snprintf(led_name, sizeof(led_name), "ath9k-%s",
++ wiphy_name(sc->hw->wiphy));
+
+- ret = led_classdev_register(wiphy_dev(sc->hw->wiphy), &sc->led_cdev);
+- if (ret < 0)
+- return;
++ if (led_blink)
++ trigger = sc->led_default_trigger;
++ else
++ trigger = ieee80211_get_radio_led_name(sc->hw);
+
+- sc->led_registered = true;
++ ath_create_gpio_led(sc, sc->sc_ah->led_pin, led_name, trigger, 1);
+ }
+
+ void ath_fill_led_pin(struct ath_softc *sc)
+--- a/drivers/net/wireless/ath/ath9k/init.c
++++ b/drivers/net/wireless/ath/ath9k/init.c
+@@ -870,7 +870,7 @@ int ath9k_init_device(u16 devid, struct
+
+ #ifdef CONFIG_MAC80211_LEDS
+ /* must be initialized before ieee80211_register_hw */
+- sc->led_cdev.default_trigger = ieee80211_create_tpt_led_trigger(sc->hw,
++ sc->led_default_trigger = ieee80211_create_tpt_led_trigger(sc->hw,
+ IEEE80211_TPT_LEDTRIG_FL_RADIO, ath9k_tpt_blink,
+ ARRAY_SIZE(ath9k_tpt_blink));
+ #endif
+--- a/drivers/net/wireless/ath/ath9k/debug.c
++++ b/drivers/net/wireless/ath/ath9k/debug.c
+@@ -1482,6 +1482,61 @@ static const struct file_operations fops
+ .llseek = default_llseek,
+ };
+
++#ifdef CONFIG_MAC80211_LEDS
++
++static ssize_t write_file_gpio_led(struct file *file, const char __user *ubuf,
++ size_t count, loff_t *ppos)
++{
++ struct ath_softc *sc = file->private_data;
++ char buf[32], *str, *name, *c;
++ ssize_t len;
++ unsigned int gpio;
++ bool active_low = false;
++
++ len = min(count, sizeof(buf) - 1);
++ if (copy_from_user(buf, ubuf, len))
++ return -EFAULT;
++
++ buf[len] = '\0';
++ name = strchr(buf, ',');
++ if (!name)
++ return -EINVAL;
++
++ *(name++) = 0;
++ if (!*name)
++ return -EINVAL;
++
++ c = strchr(name, '\n');
++ if (c)
++ *c = 0;
++
++ str = buf;
++ if (*str == '!') {
++ str++;
++ active_low = true;
++ }
++
++ if (kstrtouint(str, 0, &gpio) < 0)
++ return -EINVAL;
++
++ if (gpio >= sc->sc_ah->caps.num_gpio_pins)
++ return -EINVAL;
++
++ if (ath_create_gpio_led(sc, gpio, name, NULL, active_low) < 0)
++ return -EINVAL;
++
++ return count;
++}
++
++static const struct file_operations fops_gpio_led = {
++ .write = write_file_gpio_led,
++ .open = simple_open,
++ .owner = THIS_MODULE,
++ .llseek = default_llseek,
++};
++
++#endif
++
+ #ifdef CONFIG_ATH9K_MAC_DEBUG
+
+ void ath9k_debug_samp_bb_mac(struct ath_softc *sc)
+@@ -2115,6 +2170,10 @@ int ath9k_init_debug(struct ath_hw *ah)
+ &fops_eeprom);
+ debugfs_create_file("chanbw", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
+ sc, &fops_chanbw);
++#ifdef CONFIG_MAC80211_LEDS
++ debugfs_create_file("gpio_led", S_IWUSR,
++ sc->debug.debugfs_phy, sc, &fops_gpio_led);
++#endif
+ debugfs_create_file("dma", S_IRUSR, sc->debug.debugfs_phy, sc,
+ &fops_dma);
+ debugfs_create_file("interrupt", S_IRUSR, sc->debug.debugfs_phy, sc,
diff --git a/package/mac80211/patches/531-ath9k_extra_platform_leds.patch b/package/mac80211/patches/531-ath9k_extra_platform_leds.patch
new file mode 100644
index 0000000..d07fc4e
--- /dev/null
+++ b/package/mac80211/patches/531-ath9k_extra_platform_leds.patch
@@ -0,0 +1,71 @@
+--- a/include/linux/ath9k_platform.h
++++ b/include/linux/ath9k_platform.h
+@@ -35,6 +35,9 @@ struct ath9k_platform_data {
+ bool is_clk_25mhz;
+ int (*get_mac_revision)(void);
+ int (*external_reset)(void);
++
++ int num_leds;
++ const struct gpio_led *leds;
+ };
+
+ #endif /* _LINUX_ATH9K_PLATFORM_H */
+--- a/drivers/net/wireless/ath/ath9k/gpio.c
++++ b/drivers/net/wireless/ath/ath9k/gpio.c
+@@ -14,6 +14,7 @@
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
++#include <linux/ath9k_platform.h>
+ #include "ath9k.h"
+
+ /********************************/
+@@ -88,6 +89,24 @@ int ath_create_gpio_led(struct ath_softc
+ return ret;
+ }
+
++static int ath_create_platform_led(struct ath_softc *sc,
++ const struct gpio_led *gpio)
++{
++ struct ath_led *led;
++ int ret;
++
++ led = kzalloc(sizeof(*led), GFP_KERNEL);
++ if (!led)
++ return -ENOMEM;
++
++ led->gpio = gpio;
++ ret = ath_add_led(sc, led);
++ if (ret < 0)
++ kfree(led);
++
++ return ret;
++}
++
+ void ath_deinit_leds(struct ath_softc *sc)
+ {
+ struct ath_led *led;
+@@ -103,8 +122,10 @@ void ath_deinit_leds(struct ath_softc *s
+
+ void ath_init_leds(struct ath_softc *sc)
+ {
++ struct ath9k_platform_data *pdata = sc->dev->platform_data;
+ char led_name[32];
+ const char *trigger;
++ int i;
+
+ INIT_LIST_HEAD(&sc->leds);
+
+@@ -120,6 +141,12 @@ void ath_init_leds(struct ath_softc *sc)
+ trigger = ieee80211_get_radio_led_name(sc->hw);
+
+ ath_create_gpio_led(sc, sc->sc_ah->led_pin, led_name, trigger, 1);
++
++ if (!pdata)
++ return;
++
++ for (i = 0; i < pdata->num_leds; i++)
++ ath_create_platform_led(sc, &pdata->leds[i]);
+ }
+
+ void ath_fill_led_pin(struct ath_softc *sc)
diff --git a/package/mac80211/patches/540-mac80211_optimize_mcs_rate_mask.patch b/package/mac80211/patches/540-mac80211_optimize_mcs_rate_mask.patch
new file mode 100644
index 0000000..347c920
--- /dev/null
+++ b/package/mac80211/patches/540-mac80211_optimize_mcs_rate_mask.patch
@@ -0,0 +1,98 @@
+--- a/net/mac80211/ieee80211_i.h
++++ b/net/mac80211/ieee80211_i.h
+@@ -739,6 +739,8 @@ struct ieee80211_sub_if_data {
+
+ /* bitmap of allowed (non-MCS) rate indexes for rate control */
+ u32 rc_rateidx_mask[IEEE80211_NUM_BANDS];
++
++ bool rc_has_mcs_mask[IEEE80211_NUM_BANDS];
+ u8 rc_rateidx_mcs_mask[IEEE80211_NUM_BANDS][IEEE80211_HT_MCS_MASK_LEN];
+
+ union {
+--- a/net/mac80211/cfg.c
++++ b/net/mac80211/cfg.c
+@@ -2386,9 +2386,20 @@ static int ieee80211_set_bitrate_mask(st
+ }
+
+ for (i = 0; i < IEEE80211_NUM_BANDS; i++) {
++ struct ieee80211_supported_band *sband = wiphy->bands[i];
++
+ sdata->rc_rateidx_mask[i] = mask->control[i].legacy;
+ memcpy(sdata->rc_rateidx_mcs_mask[i], mask->control[i].mcs,
+ sizeof(mask->control[i].mcs));
++
++ sdata->rc_has_mcs_mask[i] = false;
++ if (!sband)
++ continue;
++
++ if (memcmp(sdata->rc_rateidx_mcs_mask[i],
++ sband->ht_cap.mcs.rx_mask,
++ sizeof(sband->ht_cap.mcs.rx_mask)) != 0)
++ sdata->rc_has_mcs_mask[i] = true;
+ }
+
+ return 0;
+--- a/include/net/mac80211.h
++++ b/include/net/mac80211.h
+@@ -4091,7 +4091,7 @@ void ieee80211_send_bar(struct ieee80211
+ * (deprecated; this will be removed once drivers get updated to use
+ * rate_idx_mask)
+ * @rate_idx_mask: user-requested (legacy) rate mask
+- * @rate_idx_mcs_mask: user-requested MCS rate mask
++ * @rate_idx_mcs_mask: user-requested MCS rate mask (NULL if not in use)
+ * @bss: whether this frame is sent out in AP or IBSS mode
+ */
+ struct ieee80211_tx_rate_control {
+@@ -4103,7 +4103,7 @@ struct ieee80211_tx_rate_control {
+ bool rts, short_preamble;
+ u8 max_rate_idx;
+ u32 rate_idx_mask;
+- u8 rate_idx_mcs_mask[IEEE80211_HT_MCS_MASK_LEN];
++ u8 *rate_idx_mcs_mask;
+ bool bss;
+ };
+
+--- a/net/mac80211/tx.c
++++ b/net/mac80211/tx.c
+@@ -641,9 +641,11 @@ ieee80211_tx_h_rate_ctrl(struct ieee8021
+ txrc.max_rate_idx = -1;
+ else
+ txrc.max_rate_idx = fls(txrc.rate_idx_mask) - 1;
+- memcpy(txrc.rate_idx_mcs_mask,
+- tx->sdata->rc_rateidx_mcs_mask[info->band],
+- sizeof(txrc.rate_idx_mcs_mask));
++
++ if (tx->sdata->rc_has_mcs_mask[info->band])
++ txrc.rate_idx_mcs_mask =
++ tx->sdata->rc_rateidx_mcs_mask[info->band];
++
+ txrc.bss = (tx->sdata->vif.type == NL80211_IFTYPE_AP ||
+ tx->sdata->vif.type == NL80211_IFTYPE_MESH_POINT ||
+ tx->sdata->vif.type == NL80211_IFTYPE_ADHOC);
+@@ -2511,8 +2513,6 @@ struct sk_buff *ieee80211_beacon_get_tim
+ txrc.max_rate_idx = -1;
+ else
+ txrc.max_rate_idx = fls(txrc.rate_idx_mask) - 1;
+- memcpy(txrc.rate_idx_mcs_mask, sdata->rc_rateidx_mcs_mask[band],
+- sizeof(txrc.rate_idx_mcs_mask));
+ txrc.bss = true;
+ rate_control_get_rate(sdata, NULL, &txrc);
+
+--- a/net/mac80211/rate.c
++++ b/net/mac80211/rate.c
+@@ -460,9 +460,12 @@ void rate_control_get_rate(struct ieee80
+ * the common case.
+ */
+ mask = sdata->rc_rateidx_mask[info->band];
+- memcpy(mcs_mask, sdata->rc_rateidx_mcs_mask[info->band],
+- sizeof(mcs_mask));
+- if (mask != (1 << txrc->sband->n_bitrates) - 1) {
++ if (mask != (1 << txrc->sband->n_bitrates) - 1 || txrc->rate_idx_mcs_mask) {
++ if (txrc->rate_idx_mcs_mask)
++ memcpy(mcs_mask, txrc->rate_idx_mcs_mask, sizeof(mcs_mask));
++ else
++ memset(mcs_mask, 0xff, sizeof(mcs_mask));
++
+ if (sta) {
+ /* Filter out rates that the STA does not support */
+ mask &= sta->sta.supp_rates[info->band];
diff --git a/package/mac80211/patches/541-ath9k_optimize_interrupt_mitigation.patch b/package/mac80211/patches/541-ath9k_optimize_interrupt_mitigation.patch
new file mode 100644
index 0000000..95ceb35
--- /dev/null
+++ b/package/mac80211/patches/541-ath9k_optimize_interrupt_mitigation.patch
@@ -0,0 +1,30 @@
+--- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
++++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
+@@ -241,21 +241,19 @@ static bool ar9003_hw_get_isr(struct ath
+
+ *masked = isr & ATH9K_INT_COMMON;
+
+- if (ah->config.rx_intr_mitigation)
++ if (ah->config.rx_intr_mitigation) {
+ if (isr & (AR_ISR_RXMINTR | AR_ISR_RXINTM))
+ *masked |= ATH9K_INT_RXLP;
+-
+- if (ah->config.tx_intr_mitigation)
+- if (isr & (AR_ISR_TXMINTR | AR_ISR_TXINTM))
+- *masked |= ATH9K_INT_TX;
+-
+- if (isr & (AR_ISR_LP_RXOK | AR_ISR_RXERR))
++ } else if (isr & (AR_ISR_LP_RXOK | AR_ISR_RXERR))
+ *masked |= ATH9K_INT_RXLP;
+
+ if (isr & AR_ISR_HP_RXOK)
+ *masked |= ATH9K_INT_RXHP;
+
+- if (isr & (AR_ISR_TXOK | AR_ISR_TXERR | AR_ISR_TXEOL)) {
++ if (ah->config.tx_intr_mitigation) {
++ if (isr & (AR_ISR_TXMINTR | AR_ISR_TXINTM))
++ *masked |= ATH9K_INT_TX;
++ } else if (isr & (AR_ISR_TXOK | AR_ISR_TXERR | AR_ISR_TXEOL)) {
+ *masked |= ATH9K_INT_TX;
+
+ if (!(pCap->hw_caps & ATH9K_HW_CAP_RAC_SUPPORTED)) {
diff --git a/package/mac80211/patches/550-ath9k_reduce_ani_interval.patch b/package/mac80211/patches/550-ath9k_reduce_ani_interval.patch
new file mode 100644
index 0000000..e2a0d12
--- /dev/null
+++ b/package/mac80211/patches/550-ath9k_reduce_ani_interval.patch
@@ -0,0 +1,11 @@
+--- a/drivers/net/wireless/ath/ath9k/ani.h
++++ b/drivers/net/wireless/ath/ath9k/ani.h
+@@ -51,7 +51,7 @@
+ #define ATH9K_ANI_PERIOD 300
+
+ /* in ms */
+-#define ATH9K_ANI_POLLINTERVAL 1000
++#define ATH9K_ANI_POLLINTERVAL 100
+
+ #define HAL_NOISE_IMMUNE_MAX 4
+ #define HAL_SPUR_IMMUNE_MAX 7
diff --git a/package/mac80211/patches/551-ath9k_revert_initval_change.patch b/package/mac80211/patches/551-ath9k_revert_initval_change.patch
new file mode 100644
index 0000000..ffb08bf
--- /dev/null
+++ b/package/mac80211/patches/551-ath9k_revert_initval_change.patch
@@ -0,0 +1,19 @@
+--- a/drivers/net/wireless/ath/ath9k/ar9003_2p2_initvals.h
++++ b/drivers/net/wireless/ath/ath9k/ar9003_2p2_initvals.h
+@@ -958,11 +958,11 @@ static const u32 ar9300Common_rx_gain_ta
+ {0x0000a074, 0x00000000},
+ {0x0000a078, 0x00000000},
+ {0x0000a07c, 0x00000000},
+- {0x0000a080, 0x1a1a1a1a},
+- {0x0000a084, 0x1a1a1a1a},
+- {0x0000a088, 0x1a1a1a1a},
+- {0x0000a08c, 0x1a1a1a1a},
+- {0x0000a090, 0x171a1a1a},
++ {0x0000a080, 0x22222229},
++ {0x0000a084, 0x1d1d1d1d},
++ {0x0000a088, 0x1d1d1d1d},
++ {0x0000a08c, 0x1d1d1d1d},
++ {0x0000a090, 0x171d1d1d},
+ {0x0000a094, 0x11111717},
+ {0x0000a098, 0x00030311},
+ {0x0000a09c, 0x00000000},
diff --git a/package/mac80211/patches/552-ath9k_rx_dma_stop_check.patch b/package/mac80211/patches/552-ath9k_rx_dma_stop_check.patch
new file mode 100644
index 0000000..1da7207
--- /dev/null
+++ b/package/mac80211/patches/552-ath9k_rx_dma_stop_check.patch
@@ -0,0 +1,28 @@
+--- a/drivers/net/wireless/ath/ath9k/mac.c
++++ b/drivers/net/wireless/ath/ath9k/mac.c
+@@ -689,7 +689,7 @@ bool ath9k_hw_stopdmarecv(struct ath_hw
+ {
+ #define AH_RX_STOP_DMA_TIMEOUT 10000 /* usec */
+ struct ath_common *common = ath9k_hw_common(ah);
+- u32 mac_status, last_mac_status = 0;
++ u32 mac_status = 0, last_mac_status = 0;
+ int i;
+
+ /* Enable access to the DMA observation bus */
+@@ -719,6 +719,16 @@ bool ath9k_hw_stopdmarecv(struct ath_hw
+ }
+
+ if (i == 0) {
++ if (!AR_SREV_9300_20_OR_LATER(ah) &&
++ (mac_status & 0x700) == 0) {
++ /*
++ * DMA is idle but the MAC is still stuck
++ * processing events
++ */
++ *reset = true;
++ return true;
++ }
++
+ ath_err(common,
+ "DMA failed to stop in %d ms AR_CR=0x%08x AR_DIAG_SW=0x%08x DMADBG_7=0x%08x\n",
+ AH_RX_STOP_DMA_TIMEOUT / 1000,
diff --git a/package/mac80211/patches/553-ath9k_debugfs_diag.patch b/package/mac80211/patches/553-ath9k_debugfs_diag.patch
new file mode 100644
index 0000000..915f30f
--- /dev/null
+++ b/package/mac80211/patches/553-ath9k_debugfs_diag.patch
@@ -0,0 +1,139 @@
+--- a/drivers/net/wireless/ath/ath9k/debug.c
++++ b/drivers/net/wireless/ath/ath9k/debug.c
+@@ -2149,6 +2149,50 @@ static const struct file_operations fops
+ };
+
+
++static ssize_t read_file_diag(struct file *file, char __user *user_buf,
++ size_t count, loff_t *ppos)
++{
++ struct ath_softc *sc = file->private_data;
++ struct ath_hw *ah = sc->sc_ah;
++ char buf[32];
++ unsigned int len;
++
++ len = sprintf(buf, "0x%08lx\n", ah->diag);
++ return simple_read_from_buffer(user_buf, count, ppos, buf, len);
++}
++
++static ssize_t write_file_diag(struct file *file, const char __user *user_buf,
++ size_t count, loff_t *ppos)
++{
++ struct ath_softc *sc = file->private_data;
++ struct ath_hw *ah = sc->sc_ah;
++ unsigned long diag;
++ char buf[32];
++ ssize_t len;
++
++ len = min(count, sizeof(buf) - 1);
++ if (copy_from_user(buf, user_buf, len))
++ return -EFAULT;
++
++ buf[len] = '\0';
++ if (strict_strtoul(buf, 0, &diag))
++ return -EINVAL;
++
++ ah->diag = diag;
++ ath9k_hw_update_diag(ah);
++
++ return count;
++}
++
++static const struct file_operations fops_diag = {
++ .read = read_file_diag,
++ .write = write_file_diag,
++ .open = simple_open,
++ .owner = THIS_MODULE,
++ .llseek = default_llseek,
++};
++
++
+ int ath9k_init_debug(struct ath_hw *ah)
+ {
+ struct ath_common *common = ath9k_hw_common(ah);
+@@ -2174,6 +2218,8 @@ int ath9k_init_debug(struct ath_hw *ah)
+ debugfs_create_file("gpio_led", S_IWUSR,
+ sc->debug.debugfs_phy, sc, &fops_gpio_led);
+ #endif
++ debugfs_create_file("diag", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
++ sc, &fops_diag);
+ debugfs_create_file("dma", S_IRUSR, sc->debug.debugfs_phy, sc,
+ &fops_dma);
+ debugfs_create_file("interrupt", S_IRUSR, sc->debug.debugfs_phy, sc,
+--- a/drivers/net/wireless/ath/ath9k/hw.h
++++ b/drivers/net/wireless/ath/ath9k/hw.h
+@@ -500,6 +500,12 @@ enum {
+ ATH9K_RESET_COLD,
+ };
+
++enum {
++ ATH_DIAG_DISABLE_RX,
++ ATH_DIAG_DISABLE_TX,
++ ATH_DIAG_TRIGGER_ERROR,
++};
++
+ struct ath9k_hw_version {
+ u32 magic;
+ u16 devid;
+@@ -778,6 +784,8 @@ struct ath_hw {
+ u32 rfkill_polarity;
+ u32 ah_flags;
+
++ unsigned long diag;
++
+ bool reset_power_on;
+ bool htc_reset_init;
+
+@@ -1041,6 +1049,7 @@ void ath9k_hw_set_sta_beacon_timers(stru
+ bool ath9k_hw_check_alive(struct ath_hw *ah);
+
+ bool ath9k_hw_setpower(struct ath_hw *ah, enum ath9k_power_mode mode);
++void ath9k_hw_update_diag(struct ath_hw *ah);
+
+ #ifdef CONFIG_ATH9K_DEBUGFS
+ void ath9k_debug_sync_cause(struct ath_common *common, u32 sync_cause);
+--- a/drivers/net/wireless/ath/ath9k/hw.c
++++ b/drivers/net/wireless/ath/ath9k/hw.c
+@@ -1747,6 +1747,20 @@ fail:
+ return -EINVAL;
+ }
+
++void ath9k_hw_update_diag(struct ath_hw *ah)
++{
++ if (test_bit(ATH_DIAG_DISABLE_RX, &ah->diag))
++ REG_SET_BIT(ah, AR_DIAG_SW, AR_DIAG_RX_DIS);
++ else
++ REG_CLR_BIT(ah, AR_DIAG_SW, AR_DIAG_RX_DIS);
++
++ if (test_bit(ATH_DIAG_DISABLE_TX, &ah->diag))
++ REG_SET_BIT(ah, AR_DIAG_SW, AR_DIAG_LOOP_BACK);
++ else
++ REG_CLR_BIT(ah, AR_DIAG_SW, AR_DIAG_LOOP_BACK);
++}
++EXPORT_SYMBOL(ath9k_hw_update_diag);
++
+ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
+ struct ath9k_hw_cal_data *caldata, bool fastcc)
+ {
+@@ -2024,6 +2038,7 @@ int ath9k_hw_reset(struct ath_hw *ah, st
+ }
+
+ ath9k_hw_apply_gpio_override(ah);
++ ath9k_hw_update_diag(ah);
+
+ if (AR_SREV_9565(ah) && ah->shared_chain_lnadiv)
+ REG_SET_BIT(ah, AR_BTCOEX_WL_LNADIV, AR_BTCOEX_WL_LNADIV_FORCE_ON);
+--- a/drivers/net/wireless/ath/ath9k/main.c
++++ b/drivers/net/wireless/ath/ath9k/main.c
+@@ -459,6 +459,11 @@ irqreturn_t ath_isr(int irq, void *dev)
+ ath9k_hw_getisr(ah, &status); /* NB: clears ISR too */
+ status &= ah->imask; /* discard unasked-for bits */
+
++ if (test_bit(ATH_DIAG_TRIGGER_ERROR, &ah->diag)) {
++ status |= ATH9K_INT_FATAL;
++ clear_bit(ATH_DIAG_TRIGGER_ERROR, &ah->diag);
++ }
++
+ /*
+ * If there are no status bits set, then this interrupt was not
+ * for me (should have been caught above).
diff --git a/package/mac80211/patches/554-ath9k_ani_mrc_fix.patch b/package/mac80211/patches/554-ath9k_ani_mrc_fix.patch
new file mode 100644
index 0000000..6edc8ef
--- /dev/null
+++ b/package/mac80211/patches/554-ath9k_ani_mrc_fix.patch
@@ -0,0 +1,13 @@
+--- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c
++++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
+@@ -1075,6 +1075,10 @@ static bool ar9003_hw_ani_control(struct
+ * is_on == 0 means MRC CCK is OFF (more noise imm)
+ */
+ bool is_on = param ? 1 : 0;
++
++ if (ah->caps.rx_chainmask == 1)
++ break;
++
+ REG_RMW_FIELD(ah, AR_PHY_MRC_CCK_CTRL,
+ AR_PHY_MRC_CCK_ENABLE, is_on);
+ REG_RMW_FIELD(ah, AR_PHY_MRC_CCK_CTRL,
diff --git a/package/mac80211/patches/555-ath9k-allow-to-disable-bands-via-platform-data.patch b/package/mac80211/patches/555-ath9k-allow-to-disable-bands-via-platform-data.patch
new file mode 100644
index 0000000..515bb8f
--- /dev/null
+++ b/package/mac80211/patches/555-ath9k-allow-to-disable-bands-via-platform-data.patch
@@ -0,0 +1,70 @@
+--- a/include/linux/ath9k_platform.h
++++ b/include/linux/ath9k_platform.h
+@@ -33,6 +33,9 @@ struct ath9k_platform_data {
+
+ bool endian_check;
+ bool is_clk_25mhz;
++ bool disable_2ghz;
++ bool disable_5ghz;
++
+ int (*get_mac_revision)(void);
+ int (*external_reset)(void);
+
+--- a/drivers/net/wireless/ath/ath9k/hw.c
++++ b/drivers/net/wireless/ath/ath9k/hw.c
+@@ -2414,17 +2414,25 @@ int ath9k_hw_fill_cap_info(struct ath_hw
+ }
+
+ eeval = ah->eep_ops->get_eeprom(ah, EEP_OP_MODE);
+- if ((eeval & (AR5416_OPFLAGS_11G | AR5416_OPFLAGS_11A)) == 0) {
+- ath_err(common,
+- "no band has been marked as supported in EEPROM\n");
+- return -EINVAL;
++
++ if (eeval & AR5416_OPFLAGS_11A) {
++ if (ah->disable_5ghz)
++ ath_warn(common, "disabling 5GHz band\n");
++ else
++ pCap->hw_caps |= ATH9K_HW_CAP_5GHZ;
+ }
+
+- if (eeval & AR5416_OPFLAGS_11A)
+- pCap->hw_caps |= ATH9K_HW_CAP_5GHZ;
++ if (eeval & AR5416_OPFLAGS_11G) {
++ if (ah->disable_2ghz)
++ ath_warn(common, "disabling 2GHz band\n");
++ else
++ pCap->hw_caps |= ATH9K_HW_CAP_2GHZ;
++ }
+
+- if (eeval & AR5416_OPFLAGS_11G)
+- pCap->hw_caps |= ATH9K_HW_CAP_2GHZ;
++ if ((pCap->hw_caps & (ATH9K_HW_CAP_2GHZ | ATH9K_HW_CAP_5GHZ)) == 0) {
++ ath_err(common, "both bands are disabled\n");
++ return -EINVAL;
++ }
+
+ if (AR_SREV_9485(ah) ||
+ AR_SREV_9285(ah) ||
+--- a/drivers/net/wireless/ath/ath9k/hw.h
++++ b/drivers/net/wireless/ath/ath9k/hw.h
+@@ -961,6 +961,8 @@ struct ath_hw {
+ bool is_clk_25mhz;
+ int (*get_mac_revision)(void);
+ int (*external_reset)(void);
++ bool disable_2ghz;
++ bool disable_5ghz;
+
+ const struct firmware *eeprom_blob;
+ };
+--- a/drivers/net/wireless/ath/ath9k/init.c
++++ b/drivers/net/wireless/ath/ath9k/init.c
+@@ -587,6 +587,8 @@ static int ath9k_init_softc(u16 devid, s
+ ah->is_clk_25mhz = pdata->is_clk_25mhz;
+ ah->get_mac_revision = pdata->get_mac_revision;
+ ah->external_reset = pdata->external_reset;
++ ah->disable_2ghz = pdata->disable_2ghz;
++ ah->disable_5ghz = pdata->disable_5ghz;
+ if (!pdata->endian_check)
+ ah->ah_flags |= AH_NO_EEP_SWAP;
+ }
diff --git a/package/mac80211/patches/600-rt2x00-disable-pci-code-if-CONFIG_PCI-not-defined.patch b/package/mac80211/patches/600-rt2x00-disable-pci-code-if-CONFIG_PCI-not-defined.patch
new file mode 100644
index 0000000..a7609ed
--- /dev/null
+++ b/package/mac80211/patches/600-rt2x00-disable-pci-code-if-CONFIG_PCI-not-defined.patch
@@ -0,0 +1,18 @@
+--- a/drivers/net/wireless/rt2x00/rt2x00pci.c
++++ b/drivers/net/wireless/rt2x00/rt2x00pci.c
+@@ -208,6 +208,7 @@ void rt2x00pci_uninitialize(struct rt2x0
+ }
+ EXPORT_SYMBOL_GPL(rt2x00pci_uninitialize);
+
++#ifdef CONFIG_PCI
+ /*
+ * PCI driver handlers.
+ */
+@@ -392,6 +393,7 @@ int rt2x00pci_resume(struct pci_dev *pci
+ }
+ EXPORT_SYMBOL_GPL(rt2x00pci_resume);
+ #endif /* CONFIG_PM */
++#endif /* CONFIG_PCI */
+
+ /*
+ * rt2x00pci module information.
diff --git a/package/mac80211/patches/601-rt2x00-set_pci_mwi.patch b/package/mac80211/patches/601-rt2x00-set_pci_mwi.patch
new file mode 100644
index 0000000..9ff50b7
--- /dev/null
+++ b/package/mac80211/patches/601-rt2x00-set_pci_mwi.patch
@@ -0,0 +1,13 @@
+--- a/drivers/net/wireless/rt2x00/rt2x00pci.c
++++ b/drivers/net/wireless/rt2x00/rt2x00pci.c
+@@ -273,8 +273,10 @@ int rt2x00pci_probe(struct pci_dev *pci_
+
+ pci_set_master(pci_dev);
+
++#ifdef CONFIG_PCI_SET_MWI
+ if (pci_set_mwi(pci_dev))
+ ERROR_PROBE("MWI not available.\n");
++#endif
+
+ if (dma_set_mask(&pci_dev->dev, DMA_BIT_MASK(32))) {
+ ERROR_PROBE("PCI DMA not supported.\n");
diff --git a/package/mac80211/patches/602-rt2x00-introduce-rt2x00_platform_h.patch b/package/mac80211/patches/602-rt2x00-introduce-rt2x00_platform_h.patch
new file mode 100644
index 0000000..6c80c3d
--- /dev/null
+++ b/package/mac80211/patches/602-rt2x00-introduce-rt2x00_platform_h.patch
@@ -0,0 +1,32 @@
+--- /dev/null
++++ b/include/linux/rt2x00_platform.h
+@@ -0,0 +1,19 @@
++/*
++ * Platform data definition for the rt2x00 driver
++ *
++ * Copyright (C) 2011 Gabor Juhos <juhosg@openwrt.org>
++ *
++ * This program is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License version 2 as published
++ * by the Free Software Foundation.
++ *
++ */
++
++#ifndef _RT2X00_PLATFORM_H
++#define _RT2X00_PLATFORM_H
++
++struct rt2x00_platform_data {
++ char *eeprom_file_name;
++};
++
++#endif /* _RT2X00_PLATFORM_H */
+--- a/drivers/net/wireless/rt2x00/rt2x00.h
++++ b/drivers/net/wireless/rt2x00/rt2x00.h
+@@ -39,6 +39,7 @@
+ #include <linux/input-polldev.h>
+ #include <linux/kfifo.h>
+ #include <linux/hrtimer.h>
++#include <linux/rt2x00_platform.h>
+
+ #include <net/mac80211.h>
+
diff --git a/package/mac80211/patches/603-rt2x00-introduce-rt2x00eeprom.patch b/package/mac80211/patches/603-rt2x00-introduce-rt2x00eeprom.patch
new file mode 100644
index 0000000..6b1f030
--- /dev/null
+++ b/package/mac80211/patches/603-rt2x00-introduce-rt2x00eeprom.patch
@@ -0,0 +1,279 @@
+--- /dev/null
++++ b/drivers/net/wireless/rt2x00/rt2x00eeprom.c
+@@ -0,0 +1,98 @@
++/*
++ Copyright (C) 2004 - 2009 Ivo van Doorn <IvDoorn@gmail.com>
++ Copyright (C) 2004 - 2009 Gertjan van Wingerde <gwingerde@gmail.com>
++ <http://rt2x00.serialmonkey.com>
++
++ 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 of the License, 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; if not, write to the
++ Free Software Foundation, Inc.,
++ 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
++ */
++
++/*
++ Module: rt2x00lib
++ Abstract: rt2x00 eeprom file loading routines.
++ */
++
++#include <linux/kernel.h>
++#include <linux/module.h>
++
++#include "rt2x00.h"
++#include "rt2x00lib.h"
++
++static int rt2x00lib_request_eeprom_file(struct rt2x00_dev *rt2x00dev)
++{
++ const struct firmware *ee;
++ char *ee_name;
++ int retval;
++
++ ee_name = rt2x00dev->ops->lib->get_eeprom_file_name(rt2x00dev);
++ if (!ee_name) {
++ ERROR(rt2x00dev,
++ "Invalid EEPROM filename.\n"
++ "Please file bug report to %s.\n", DRV_PROJECT);
++ return -EINVAL;
++ }
++
++ INFO(rt2x00dev, "Loading EEPROM data from '%s'.\n", ee_name);
++
++ retval = request_firmware(&ee, ee_name, rt2x00dev->dev);
++ if (retval) {
++ ERROR(rt2x00dev, "Failed to request EEPROM.\n");
++ return retval;
++ }
++
++ if (!ee || !ee->size || !ee->data) {
++ ERROR(rt2x00dev, "Failed to read EEPROM file.\n");
++ retval = -ENOENT;
++ goto err_exit;
++ }
++
++ if (ee->size != rt2x00dev->ops->eeprom_size) {
++ ERROR(rt2x00dev,
++ "EEPROM file size is invalid, it should be %d bytes\n",
++ rt2x00dev->ops->eeprom_size);
++ retval = -EINVAL;
++ goto err_release_ee;
++ }
++
++ rt2x00dev->eeprom_file = ee;
++ return 0;
++
++err_release_ee:
++ release_firmware(ee);
++err_exit:
++ return retval;
++}
++
++int rt2x00lib_load_eeprom_file(struct rt2x00_dev *rt2x00dev)
++{
++ int retval;
++
++ if (!test_bit(REQUIRE_EEPROM_FILE, &rt2x00dev->cap_flags))
++ return 0;
++
++ if (!rt2x00dev->eeprom_file) {
++ retval = rt2x00lib_request_eeprom_file(rt2x00dev);
++ if (retval)
++ return retval;
++ }
++
++ return 0;
++}
++
++void rt2x00lib_free_eeprom_file(struct rt2x00_dev *rt2x00dev)
++{
++ release_firmware(rt2x00dev->eeprom_file);
++ rt2x00dev->eeprom_file = NULL;
++}
+--- a/drivers/net/wireless/rt2x00/rt2x00.h
++++ b/drivers/net/wireless/rt2x00/rt2x00.h
+@@ -559,6 +559,7 @@ struct rt2x00lib_ops {
+ const u8 *data, const size_t len);
+ int (*load_firmware) (struct rt2x00_dev *rt2x00dev,
+ const u8 *data, const size_t len);
++ char *(*get_eeprom_file_name) (struct rt2x00_dev *rt2x00dev);
+
+ /*
+ * Device initialization/deinitialization handlers.
+@@ -719,6 +720,7 @@ enum rt2x00_capability_flags {
+ REQUIRE_SW_SEQNO,
+ REQUIRE_HT_TX_DESC,
+ REQUIRE_PS_AUTOWAKE,
++ REQUIRE_EEPROM_FILE,
+
+ /*
+ * Capabilities
+@@ -988,6 +990,11 @@ struct rt2x00_dev {
+ const struct firmware *fw;
+
+ /*
++ * EEPROM image.
++ */
++ const struct firmware *eeprom_file;
++
++ /*
+ * FIFO for storing tx status reports between isr and tasklet.
+ */
+ DECLARE_KFIFO_PTR(txstatus_fifo, u32);
+--- a/drivers/net/wireless/rt2x00/rt2x00lib.h
++++ b/drivers/net/wireless/rt2x00/rt2x00lib.h
+@@ -322,6 +322,22 @@ static inline void rt2x00lib_free_firmwa
+ #endif /* CONFIG_RT2X00_LIB_FIRMWARE */
+
+ /*
++ * EEPROM file handlers.
++ */
++#ifdef CONFIG_RT2X00_LIB_EEPROM
++int rt2x00lib_load_eeprom_file(struct rt2x00_dev *rt2x00dev);
++void rt2x00lib_free_eeprom_file(struct rt2x00_dev *rt2x00dev);
++#else
++static inline int rt2x00lib_load_eeprom_file(struct rt2x00_dev *rt2x00dev)
++{
++ return 0;
++}
++static inline void rt2x00lib_free_eeprom_file(struct rt2x00_dev *rt2x00dev)
++{
++}
++#endif /* CONFIG_RT2X00_LIB_EEPROM_FILE */
++
++/*
+ * Debugfs handlers.
+ */
+ #ifdef CONFIG_RT2X00_LIB_DEBUGFS
+--- a/drivers/net/wireless/rt2x00/Kconfig
++++ b/drivers/net/wireless/rt2x00/Kconfig
+@@ -60,6 +60,7 @@ config RT2800PCI
+ select RT2X00_LIB_PCI if PCI
+ select RT2X00_LIB_SOC if RALINK_RT288X || RALINK_RT305X
+ select RT2X00_LIB_FIRMWARE
++ select RT2X00_LIB_EEPROM
+ select RT2X00_LIB_CRYPTO
+ select CRC_CCITT
+ select EEPROM_93CX6
+@@ -212,6 +213,9 @@ config RT2X00_LIB_FIRMWARE
+ config RT2X00_LIB_CRYPTO
+ boolean
+
++config RT2X00_LIB_EEPROM
++ boolean
++
+ config RT2X00_LIB_LEDS
+ boolean
+ default y if (RT2X00_LIB=y && LEDS_CLASS=y) || (RT2X00_LIB=m && LEDS_CLASS!=n)
+--- a/drivers/net/wireless/rt2x00/Makefile
++++ b/drivers/net/wireless/rt2x00/Makefile
+@@ -7,6 +7,7 @@ rt2x00lib-$(CONFIG_RT2X00_LIB_DEBUGFS) +
+ rt2x00lib-$(CONFIG_RT2X00_LIB_CRYPTO) += rt2x00crypto.o
+ rt2x00lib-$(CONFIG_RT2X00_LIB_FIRMWARE) += rt2x00firmware.o
+ rt2x00lib-$(CONFIG_RT2X00_LIB_LEDS) += rt2x00leds.o
++rt2x00lib-$(CONFIG_RT2X00_LIB_EEPROM) += rt2x00eeprom.o
+
+ obj-$(CONFIG_RT2X00_LIB) += rt2x00lib.o
+ obj-$(CONFIG_RT2X00_LIB_PCI) += rt2x00pci.o
+--- a/drivers/net/wireless/rt2x00/rt2800pci.c
++++ b/drivers/net/wireless/rt2x00/rt2800pci.c
+@@ -89,25 +89,11 @@ static void rt2800pci_mcu_status(struct
+ rt2x00pci_register_write(rt2x00dev, H2M_MAILBOX_CID, ~0);
+ }
+
+-#if defined(CONFIG_RALINK_RT288X) || defined(CONFIG_RALINK_RT305X)
+ static int rt2800pci_read_eeprom_soc(struct rt2x00_dev *rt2x00dev)
+ {
+- void __iomem *base_addr = ioremap(0x1F040000, EEPROM_SIZE);
+-
+- if (!base_addr)
+- return -ENOMEM;
+-
+- memcpy_fromio(rt2x00dev->eeprom, base_addr, EEPROM_SIZE);
+-
+- iounmap(base_addr);
++ memcpy(rt2x00dev->eeprom, rt2x00dev->eeprom_file->data, EEPROM_SIZE);
+ return 0;
+ }
+-#else
+-static inline int rt2800pci_read_eeprom_soc(struct rt2x00_dev *rt2x00dev)
+-{
+- return -ENOMEM;
+-}
+-#endif /* CONFIG_RALINK_RT288X || CONFIG_RALINK_RT305X */
+
+ #ifdef CONFIG_PCI
+ static void rt2800pci_eepromregister_read(struct eeprom_93cx6 *eeprom)
+@@ -331,6 +317,20 @@ static int rt2800pci_write_firmware(stru
+ }
+
+ /*
++ * EEPROM file functions.
++ */
++static char *rt2800pci_get_eeprom_file_name(struct rt2x00_dev *rt2x00dev)
++{
++ struct rt2x00_platform_data *pdata;
++
++ pdata = rt2x00dev->dev->platform_data;
++ if (pdata)
++ return pdata->eeprom_file_name;
++
++ return NULL;
++}
++
++/*
+ * Initialization functions.
+ */
+ static bool rt2800pci_get_entry_state(struct queue_entry *entry)
+@@ -1046,6 +1046,7 @@ static const struct rt2x00lib_ops rt2800
+ .get_firmware_name = rt2800pci_get_firmware_name,
+ .check_firmware = rt2800_check_firmware,
+ .load_firmware = rt2800_load_firmware,
++ .get_eeprom_file_name = rt2800pci_get_eeprom_file_name,
+ .initialize = rt2x00pci_initialize,
+ .uninitialize = rt2x00pci_uninitialize,
+ .get_entry_state = rt2800pci_get_entry_state,
+--- a/drivers/net/wireless/rt2x00/rt2x00dev.c
++++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
+@@ -1318,6 +1318,10 @@ int rt2x00lib_probe_dev(struct rt2x00_de
+
+ rt2x00dev->hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN;
+
++ retval = rt2x00lib_load_eeprom_file(rt2x00dev);
++ if (retval)
++ goto exit;
++
+ /*
+ * Initialize work.
+ */
+@@ -1442,6 +1446,11 @@ void rt2x00lib_remove_dev(struct rt2x00_
+ */
+ if (rt2x00dev->drv_data)
+ kfree(rt2x00dev->drv_data);
++
++ /*
++ * Free EEPROM image.
++ */
++ rt2x00lib_free_eeprom_file(rt2x00dev);
+ }
+ EXPORT_SYMBOL_GPL(rt2x00lib_remove_dev);
+
+--- a/drivers/net/wireless/rt2x00/rt2x00soc.c
++++ b/drivers/net/wireless/rt2x00/rt2x00soc.c
+@@ -94,6 +94,7 @@ int rt2x00soc_probe(struct platform_devi
+ rt2x00dev->hw = hw;
+ rt2x00dev->irq = platform_get_irq(pdev, 0);
+ rt2x00dev->name = pdev->dev.driver->name;
++ set_bit(REQUIRE_EEPROM_FILE, &rt2x00dev->cap_flags);
+
+ rt2x00_set_chip_intf(rt2x00dev, RT2X00_CHIP_INTF_SOC);
+
diff --git a/package/mac80211/patches/604-rt2x00-add-CONFIG_RT2X00_LIB_EEPROM-option.patch b/package/mac80211/patches/604-rt2x00-add-CONFIG_RT2X00_LIB_EEPROM-option.patch
new file mode 100644
index 0000000..d9f1764
--- /dev/null
+++ b/package/mac80211/patches/604-rt2x00-add-CONFIG_RT2X00_LIB_EEPROM-option.patch
@@ -0,0 +1,10 @@
+--- a/config.mk
++++ b/config.mk
+@@ -640,6 +640,7 @@ export CONFIG_RT2X00=y
+ export CONFIG_RT2X00_LIB=m
+ export CONFIG_RT2800_LIB=m
+ export CONFIG_RT2X00_LIB_FIRMWARE=y
++export CONFIG_RT2X00_LIB_EEPROM=y
+ export CONFIG_RT2X00_LIB_CRYPTO=y
+ # export CONFIG_RT2X00_LIB_SOC=y
+ ifdef CONFIG_COMPAT_KERNEL_2_6_25
diff --git a/package/mac80211/patches/605-rt2x00-pci-eeprom.patch b/package/mac80211/patches/605-rt2x00-pci-eeprom.patch
new file mode 100644
index 0000000..25b21ce
--- /dev/null
+++ b/package/mac80211/patches/605-rt2x00-pci-eeprom.patch
@@ -0,0 +1,46 @@
+--- a/drivers/net/wireless/rt2x00/rt2800pci.c
++++ b/drivers/net/wireless/rt2x00/rt2800pci.c
+@@ -89,7 +89,7 @@ static void rt2800pci_mcu_status(struct
+ rt2x00pci_register_write(rt2x00dev, H2M_MAILBOX_CID, ~0);
+ }
+
+-static int rt2800pci_read_eeprom_soc(struct rt2x00_dev *rt2x00dev)
++static int rt2800pci_read_eeprom_file(struct rt2x00_dev *rt2x00dev)
+ {
+ memcpy(rt2x00dev->eeprom, rt2x00dev->eeprom_file->data, EEPROM_SIZE);
+ return 0;
+@@ -983,8 +983,9 @@ static int rt2800pci_read_eeprom(struct
+ {
+ int retval;
+
+- if (rt2x00_is_soc(rt2x00dev))
+- retval = rt2800pci_read_eeprom_soc(rt2x00dev);
++ if (rt2x00_is_soc(rt2x00dev) ||
++ test_bit(REQUIRE_EEPROM_FILE, &rt2x00dev->cap_flags))
++ retval = rt2800pci_read_eeprom_file(rt2x00dev);
+ else if (rt2800pci_efuse_detect(rt2x00dev))
+ retval = rt2800pci_read_eeprom_efuse(rt2x00dev);
+ else
+--- a/drivers/net/wireless/rt2x00/rt2x00pci.c
++++ b/drivers/net/wireless/rt2x00/rt2x00pci.c
+@@ -255,6 +255,7 @@ exit:
+ int rt2x00pci_probe(struct pci_dev *pci_dev, const struct rt2x00_ops *ops)
+ {
+ struct ieee80211_hw *hw;
++ struct rt2x00_platform_data *pdata;
+ struct rt2x00_dev *rt2x00dev;
+ int retval;
+ u16 chip;
+@@ -300,6 +301,12 @@ int rt2x00pci_probe(struct pci_dev *pci_
+ rt2x00dev->irq = pci_dev->irq;
+ rt2x00dev->name = pci_name(pci_dev);
+
++ /* if we get passed the name of a eeprom_file_name, then use this in
++ favour of the eeprom */
++ pdata = rt2x00dev->dev->platform_data;
++ if (pdata && pdata->eeprom_file_name)
++ set_bit(REQUIRE_EEPROM_FILE, &rt2x00dev->cap_flags);
++
+ if (pci_is_pcie(pci_dev))
+ rt2x00_set_chip_intf(rt2x00dev, RT2X00_CHIP_INTF_PCIE);
+ else
diff --git a/package/mac80211/patches/606-rt2x00_no_realign.patch b/package/mac80211/patches/606-rt2x00_no_realign.patch
new file mode 100644
index 0000000..2025701
--- /dev/null
+++ b/package/mac80211/patches/606-rt2x00_no_realign.patch
@@ -0,0 +1,67 @@
+[RFC] rt2x00: For drivers that only need L2 padding don't realign frames
+
+Signed-off-by: Helmut Schaa <helmut.schaa@...>
+---
+
+Ivo, Gertjan, do you remeber by any chance why this alignment stuff was added
+in the first place? Was it because of DMA restrictions?
+
+While doing some profiling on the rt3052 SoC I noticed that 30-40% time was
+spent in memmove calls. And the culprit is the memmove aligning the payload
+to a 4byte boundary since that has to move a whole bunch of data.
+
+Interesstingly the legacy drivers insert an l2pad between the header and the
+payload but doesn't realign the payload itself to a 4-byte boundary. Hence,
+I came up with this patch and indeed CPU usage improves impressively.
+
+Only tested on rt2800pci!
+
+Thanks,
+Helmut
+
+ drivers/net/wireless/rt2x00/rt2x00queue.c | 30 +++-------------------------
+ 1 files changed, 4 insertions(+), 26 deletions(-)
+
+--- a/drivers/net/wireless/rt2x00/rt2x00queue.c
++++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
+@@ -162,36 +162,14 @@ void rt2x00queue_align_frame(struct sk_b
+ void rt2x00queue_insert_l2pad(struct sk_buff *skb, unsigned int header_length)
+ {
+ unsigned int payload_length = skb->len - header_length;
+- unsigned int header_align = ALIGN_SIZE(skb, 0);
+- unsigned int payload_align = ALIGN_SIZE(skb, header_length);
+ unsigned int l2pad = payload_length ? L2PAD_SIZE(header_length) : 0;
+
+- /*
+- * Adjust the header alignment if the payload needs to be moved more
+- * than the header.
+- */
+- if (payload_align > header_align)
+- header_align += 4;
+-
+- /* There is nothing to do if no alignment is needed */
+- if (!header_align)
++ if (!l2pad)
+ return;
+
+- /* Reserve the amount of space needed in front of the frame */
+- skb_push(skb, header_align);
+-
+- /*
+- * Move the header.
+- */
+- memmove(skb->data, skb->data + header_align, header_length);
+-
+- /* Move the payload, if present and if required */
+- if (payload_length && payload_align)
+- memmove(skb->data + header_length + l2pad,
+- skb->data + header_length + l2pad + payload_align,
+- payload_length);
+-
+- /* Trim the skb to the correct size */
++ /* insert l2pad -> Move header */
++ skb_push(skb, l2pad);
++ memmove(skb->data, skb->data + l2pad, header_length);
+ skb_trim(skb, header_length + l2pad + payload_length);
+ }
+
diff --git a/package/mac80211/patches/607-rt2x00-allow_disabling_bands_through_platform_data.patch b/package/mac80211/patches/607-rt2x00-allow_disabling_bands_through_platform_data.patch
new file mode 100644
index 0000000..0b0c30e
--- /dev/null
+++ b/package/mac80211/patches/607-rt2x00-allow_disabling_bands_through_platform_data.patch
@@ -0,0 +1,47 @@
+--- a/include/linux/rt2x00_platform.h
++++ b/include/linux/rt2x00_platform.h
+@@ -14,6 +14,9 @@
+
+ struct rt2x00_platform_data {
+ char *eeprom_file_name;
++
++ int disable_2ghz;
++ int disable_5ghz;
+ };
+
+ #endif /* _RT2X00_PLATFORM_H */
+--- a/drivers/net/wireless/rt2x00/rt2x00dev.c
++++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
+@@ -939,6 +939,22 @@ static int rt2x00lib_probe_hw_modes(stru
+ unsigned int num_rates;
+ unsigned int i;
+
++ if (rt2x00dev->dev->platform_data) {
++ struct rt2x00_platform_data *pdata;
++
++ pdata = rt2x00dev->dev->platform_data;
++ if (pdata->disable_2ghz)
++ spec->supported_bands &= ~SUPPORT_BAND_2GHZ;
++ if (pdata->disable_5ghz)
++ spec->supported_bands &= ~SUPPORT_BAND_5GHZ;
++ }
++
++ if ((spec->supported_bands & SUPPORT_BAND_BOTH) == 0) {
++ ERROR(rt2x00dev, "No supported bands\n");
++ return -EINVAL;
++ }
++
++
+ num_rates = 0;
+ if (spec->supported_rates & SUPPORT_RATE_CCK)
+ num_rates += 4;
+--- a/drivers/net/wireless/rt2x00/rt2x00.h
++++ b/drivers/net/wireless/rt2x00/rt2x00.h
+@@ -424,6 +424,7 @@ struct hw_mode_spec {
+ unsigned int supported_bands;
+ #define SUPPORT_BAND_2GHZ 0x00000001
+ #define SUPPORT_BAND_5GHZ 0x00000002
++#define SUPPORT_BAND_BOTH (SUPPORT_BAND_2GHZ | SUPPORT_BAND_5GHZ)
+
+ unsigned int supported_rates;
+ #define SUPPORT_RATE_CCK 0x00000001
diff --git a/package/mac80211/patches/608-add_platform_data_mac_addr.patch b/package/mac80211/patches/608-add_platform_data_mac_addr.patch
new file mode 100644
index 0000000..bb77df9
--- /dev/null
+++ b/package/mac80211/patches/608-add_platform_data_mac_addr.patch
@@ -0,0 +1,63 @@
+--- a/include/linux/rt2x00_platform.h
++++ b/include/linux/rt2x00_platform.h
+@@ -14,6 +14,7 @@
+
+ struct rt2x00_platform_data {
+ char *eeprom_file_name;
++ const u8 *mac_address;
+
+ int disable_2ghz;
+ int disable_5ghz;
+--- a/drivers/net/wireless/rt2x00/rt2x00dev.c
++++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
+@@ -930,6 +930,18 @@ static void rt2x00lib_rate(struct ieee80
+ entry->flags |= IEEE80211_RATE_SHORT_PREAMBLE;
+ }
+
++const u8 *rt2x00lib_get_mac_address(struct rt2x00_dev *rt2x00dev)
++{
++ struct rt2x00_platform_data *pdata;
++
++ pdata = rt2x00dev->dev->platform_data;
++ if (!pdata)
++ return NULL;
++
++ return pdata->mac_address;
++}
++EXPORT_SYMBOL_GPL(rt2x00lib_get_mac_address);
++
+ static int rt2x00lib_probe_hw_modes(struct rt2x00_dev *rt2x00dev,
+ struct hw_mode_spec *spec)
+ {
+--- a/drivers/net/wireless/rt2x00/rt2x00.h
++++ b/drivers/net/wireless/rt2x00/rt2x00.h
+@@ -1314,6 +1314,7 @@ static inline void rt2x00debug_dump_fram
+ */
+ u32 rt2x00lib_get_bssidx(struct rt2x00_dev *rt2x00dev,
+ struct ieee80211_vif *vif);
++const u8 *rt2x00lib_get_mac_address(struct rt2x00_dev *rt2x00dev);
+
+ /*
+ * Interrupt context handlers.
+--- a/drivers/net/wireless/rt2x00/rt61pci.c
++++ b/drivers/net/wireless/rt2x00/rt61pci.c
+@@ -2392,6 +2392,7 @@ static int rt61pci_validate_eeprom(struc
+ u32 reg;
+ u16 word;
+ u8 *mac;
++ const u8 *pdata_mac;
+ s8 value;
+
+ rt2x00pci_register_read(rt2x00dev, E2PROM_CSR, &reg);
+@@ -2412,7 +2413,11 @@ static int rt61pci_validate_eeprom(struc
+ /*
+ * Start validation of the data that has been read.
+ */
++ pdata_mac = rt2x00lib_get_mac_address(rt2x00dev);
+ mac = rt2x00_eeprom_addr(rt2x00dev, EEPROM_MAC_ADDR_0);
++ if (pdata_mac)
++ memcpy(mac, pdata_mac, 6);
++
+ if (!is_valid_ether_addr(mac)) {
+ eth_random_addr(mac);
+ EEPROM(rt2x00dev, "MAC: %pM\n", mac);
diff --git a/package/mac80211/patches/610-rt2x00-fix-rt3352-ext-pa.patch b/package/mac80211/patches/610-rt2x00-fix-rt3352-ext-pa.patch
new file mode 100644
index 0000000..bf070e6
--- /dev/null
+++ b/package/mac80211/patches/610-rt2x00-fix-rt3352-ext-pa.patch
@@ -0,0 +1,214 @@
+--- a/drivers/net/wireless/rt2x00/rt2800lib.c
++++ b/drivers/net/wireless/rt2x00/rt2800lib.c
+@@ -2249,15 +2249,18 @@ static void rt2800_config_channel(struct
+ /*
+ * Change BBP settings
+ */
++ rt2800_bbp_write(rt2x00dev, 62, 0x37 - rt2x00dev->lna_gain);
++ rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain);
++ rt2800_bbp_write(rt2x00dev, 64, 0x37 - rt2x00dev->lna_gain);
++
+ if (rt2x00_rt(rt2x00dev, RT3352)) {
+ rt2800_bbp_write(rt2x00dev, 27, 0x0);
+ rt2800_bbp_write(rt2x00dev, 66, 0x26 + rt2x00dev->lna_gain);
+ rt2800_bbp_write(rt2x00dev, 27, 0x20);
+ rt2800_bbp_write(rt2x00dev, 66, 0x26 + rt2x00dev->lna_gain);
++ rt2800_bbp_write(rt2x00dev, 86, 0x38);
++ rt2800_bbp_write(rt2x00dev, 83, 0x6a);
+ } else {
+- rt2800_bbp_write(rt2x00dev, 62, 0x37 - rt2x00dev->lna_gain);
+- rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain);
+- rt2800_bbp_write(rt2x00dev, 64, 0x37 - rt2x00dev->lna_gain);
+ rt2800_bbp_write(rt2x00dev, 86, 0);
+ }
+
+@@ -3670,6 +3673,7 @@ static int rt2800_init_bbp(struct rt2x00
+ rt2800_bbp_write(rt2x00dev, 120, 0x50);
+
+ if (rt2x00_rt(rt2x00dev, RT3290) ||
++ rt2x00_rt(rt2x00dev, RT3352) ||
+ rt2x00_rt(rt2x00dev, RT5390) ||
+ rt2x00_rt(rt2x00dev, RT5392))
+ rt2800_bbp_write(rt2x00dev, 128, 0x12);
+@@ -3976,6 +3980,12 @@ static void rt2800_init_rfcsr_3290(struc
+
+ static void rt2800_init_rfcsr_3352(struct rt2x00_dev *rt2x00dev)
+ {
++ int tx0_int_pa = test_bit(CAPABILITY_INTERNAL_PA_TX0,
++ &rt2x00dev->cap_flags);
++ int tx1_int_pa = test_bit(CAPABILITY_INTERNAL_PA_TX1,
++ &rt2x00dev->cap_flags);
++ u8 rfcsr;
++
+ rt2800_rfcsr_write(rt2x00dev, 0, 0xf0);
+ rt2800_rfcsr_write(rt2x00dev, 1, 0x23);
+ rt2800_rfcsr_write(rt2x00dev, 2, 0x50);
+@@ -4009,15 +4019,30 @@ static void rt2800_init_rfcsr_3352(struc
+ rt2800_rfcsr_write(rt2x00dev, 31, 0x80);
+ rt2800_rfcsr_write(rt2x00dev, 32, 0x80);
+ rt2800_rfcsr_write(rt2x00dev, 33, 0x00);
+- rt2800_rfcsr_write(rt2x00dev, 34, 0x01);
++ rfcsr = 0x01;
++ if (!tx0_int_pa)
++ rt2x00_set_field8(&rfcsr, RFCSR34_TX0_EXT_PA, 1);
++ if (!tx1_int_pa)
++ rt2x00_set_field8(&rfcsr, RFCSR34_TX1_EXT_PA, 1);
++ rt2800_rfcsr_write(rt2x00dev, 34, rfcsr );
+ rt2800_rfcsr_write(rt2x00dev, 35, 0x03);
+ rt2800_rfcsr_write(rt2x00dev, 36, 0xbd);
+ rt2800_rfcsr_write(rt2x00dev, 37, 0x3c);
+ rt2800_rfcsr_write(rt2x00dev, 38, 0x5f);
+ rt2800_rfcsr_write(rt2x00dev, 39, 0xc5);
+ rt2800_rfcsr_write(rt2x00dev, 40, 0x33);
+- rt2800_rfcsr_write(rt2x00dev, 41, 0x5b);
+- rt2800_rfcsr_write(rt2x00dev, 42, 0x5b);
++ rfcsr = 0x52;
++ if (tx0_int_pa) {
++ rt2x00_set_field8(&rfcsr, RFCSR41_BIT1, 1);
++ rt2x00_set_field8(&rfcsr, RFCSR41_BIT4, 1);
++ }
++ rt2800_rfcsr_write(rt2x00dev, 41, rfcsr);
++ rfcsr = 0x52;
++ if (tx1_int_pa) {
++ rt2x00_set_field8(&rfcsr, RFCSR42_BIT1, 1);
++ rt2x00_set_field8(&rfcsr, RFCSR42_BIT4, 1);
++ }
++ rt2800_rfcsr_write(rt2x00dev, 42, rfcsr);
+ rt2800_rfcsr_write(rt2x00dev, 43, 0xdb);
+ rt2800_rfcsr_write(rt2x00dev, 44, 0xdb);
+ rt2800_rfcsr_write(rt2x00dev, 45, 0xdb);
+@@ -4025,15 +4050,20 @@ static void rt2800_init_rfcsr_3352(struc
+ rt2800_rfcsr_write(rt2x00dev, 47, 0x0d);
+ rt2800_rfcsr_write(rt2x00dev, 48, 0x14);
+ rt2800_rfcsr_write(rt2x00dev, 49, 0x00);
+- rt2800_rfcsr_write(rt2x00dev, 50, 0x2d);
+- rt2800_rfcsr_write(rt2x00dev, 51, 0x7f);
+- rt2800_rfcsr_write(rt2x00dev, 52, 0x00);
+- rt2800_rfcsr_write(rt2x00dev, 53, 0x52);
+- rt2800_rfcsr_write(rt2x00dev, 54, 0x1b);
+- rt2800_rfcsr_write(rt2x00dev, 55, 0x7f);
+- rt2800_rfcsr_write(rt2x00dev, 56, 0x00);
+- rt2800_rfcsr_write(rt2x00dev, 57, 0x52);
+- rt2800_rfcsr_write(rt2x00dev, 58, 0x1b);
++ rfcsr = 0x2d;
++ if (!tx0_int_pa)
++ rt2x00_set_field8(&rfcsr, RFCSR50_TX0_EXT_PA, 1);
++ if (!tx1_int_pa)
++ rt2x00_set_field8(&rfcsr, RFCSR50_TX1_EXT_PA, 1);
++ rt2800_rfcsr_write(rt2x00dev, 50, rfcsr);
++ rt2800_rfcsr_write(rt2x00dev, 51, (tx0_int_pa ? 0x7f : 0x52));
++ rt2800_rfcsr_write(rt2x00dev, 52, (tx0_int_pa ? 0x00 : 0xc0));
++ rt2800_rfcsr_write(rt2x00dev, 53, (tx0_int_pa ? 0x52 : 0xd2));
++ rt2800_rfcsr_write(rt2x00dev, 54, (tx0_int_pa ? 0x1b : 0xc0));
++ rt2800_rfcsr_write(rt2x00dev, 55, (tx1_int_pa ? 0x7f : 0x52));
++ rt2800_rfcsr_write(rt2x00dev, 56, (tx1_int_pa ? 0x00 : 0xc0));
++ rt2800_rfcsr_write(rt2x00dev, 57, (tx0_int_pa ? 0x52 : 0x49));
++ rt2800_rfcsr_write(rt2x00dev, 58, (tx1_int_pa ? 0x1b : 0xc0));
+ rt2800_rfcsr_write(rt2x00dev, 59, 0x00);
+ rt2800_rfcsr_write(rt2x00dev, 60, 0x00);
+ rt2800_rfcsr_write(rt2x00dev, 61, 0x00);
+@@ -4949,7 +4979,8 @@ static int rt2800_init_eeprom(struct rt2
+ /*
+ * Detect if this device has Bluetooth co-existence.
+ */
+- if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF1_BT_COEXIST))
++ if (!rt2x00_rt(rt2x00dev, RT3352) &&
++ rt2x00_get_field16(eeprom, EEPROM_NIC_CONF1_BT_COEXIST))
+ __set_bit(CAPABILITY_BT_COEXIST, &rt2x00dev->cap_flags);
+
+ /*
+@@ -4978,6 +5009,22 @@ static int rt2800_init_eeprom(struct rt2
+ EIRP_MAX_TX_POWER_LIMIT)
+ __set_bit(CAPABILITY_POWER_LIMIT, &rt2x00dev->cap_flags);
+
++ /*
++ * Detect if device uses internal or external PA
++ */
++ rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &eeprom);
++
++ if (rt2x00_rt(rt2x00dev, RT3352)) {
++ if (!rt2x00_get_field16(eeprom,
++ EEPROM_NIC_CONF1_EXTERNAL_TX0_PA_3352))
++ __set_bit(CAPABILITY_INTERNAL_PA_TX0,
++ &rt2x00dev->cap_flags);
++ if (!rt2x00_get_field16(eeprom,
++ EEPROM_NIC_CONF1_EXTERNAL_TX1_PA_3352))
++ __set_bit(CAPABILITY_INTERNAL_PA_TX1,
++ &rt2x00dev->cap_flags);
++ }
++
+ return 0;
+ }
+
+--- a/drivers/net/wireless/rt2x00/rt2800.h
++++ b/drivers/net/wireless/rt2x00/rt2800.h
+@@ -2117,6 +2117,12 @@ struct mac_iveiv_entry {
+ #define RFCSR31_RX_CALIB FIELD8(0x7f)
+
+ /*
++ * RFCSR 34:
++ */
++#define RFCSR34_TX0_EXT_PA FIELD8(0x04)
++#define RFCSR34_TX1_EXT_PA FIELD8(0x08)
++
++/*
+ * RFCSR 38:
+ */
+ #define RFCSR38_RX_LO1_EN FIELD8(0x20)
+@@ -2127,6 +2133,18 @@ struct mac_iveiv_entry {
+ #define RFCSR39_RX_LO2_EN FIELD8(0x80)
+
+ /*
++ * RFCSR 41:
++ */
++#define RFCSR41_BIT1 FIELD8(0x01)
++#define RFCSR41_BIT4 FIELD8(0x08)
++
++/*
++ * RFCSR 42:
++ */
++#define RFCSR42_BIT1 FIELD8(0x01)
++#define RFCSR42_BIT4 FIELD8(0x08)
++
++/*
+ * RFCSR 49:
+ */
+ #define RFCSR49_TX FIELD8(0x3f)
+@@ -2135,6 +2153,8 @@ struct mac_iveiv_entry {
+ * RFCSR 50:
+ */
+ #define RFCSR50_TX FIELD8(0x3f)
++#define RFCSR50_TX0_EXT_PA FIELD8(0x02)
++#define RFCSR50_TX1_EXT_PA FIELD8(0x10)
+
+ /*
+ * RF registers
+@@ -2222,6 +2242,8 @@ struct mac_iveiv_entry {
+ * INTERNAL_TX_ALC: 0: disable, 1: enable
+ * BT_COEXIST: 0: disable, 1: enable
+ * DAC_TEST: 0: disable, 1: enable
++ * EXTERNAL_TX0_PA: 0: disable, 1: enable (only on RT3352)
++ * EXTERNAL_TX1_PA: 0: disable, 1: enable (only on RT3352)
+ */
+ #define EEPROM_NIC_CONF1 0x001b
+ #define EEPROM_NIC_CONF1_HW_RADIO FIELD16(0x0001)
+@@ -2239,6 +2261,8 @@ struct mac_iveiv_entry {
+ #define EEPROM_NIC_CONF1_INTERNAL_TX_ALC FIELD16(0x2000)
+ #define EEPROM_NIC_CONF1_BT_COEXIST FIELD16(0x4000)
+ #define EEPROM_NIC_CONF1_DAC_TEST FIELD16(0x8000)
++#define EEPROM_NIC_CONF1_EXTERNAL_TX0_PA_3352 FIELD16(0x4000)
++#define EEPROM_NIC_CONF1_EXTERNAL_TX1_PA_3352 FIELD16(0x8000)
+
+ /*
+ * EEPROM frequency
+--- a/drivers/net/wireless/rt2x00/rt2x00.h
++++ b/drivers/net/wireless/rt2x00/rt2x00.h
+@@ -740,6 +740,8 @@ enum rt2x00_capability_flags {
+ CAPABILITY_DOUBLE_ANTENNA,
+ CAPABILITY_BT_COEXIST,
+ CAPABILITY_VCO_RECALIBRATION,
++ CAPABILITY_INTERNAL_PA_TX0,
++ CAPABILITY_INTERNAL_PA_TX1,
+ };
+
+ /*
diff --git a/package/mac80211/patches/611-rt2x00-rf_vals-rt3352-xtal20.patch b/package/mac80211/patches/611-rt2x00-rf_vals-rt3352-xtal20.patch
new file mode 100644
index 0000000..38b56b4
--- /dev/null
+++ b/package/mac80211/patches/611-rt2x00-rf_vals-rt3352-xtal20.patch
@@ -0,0 +1,115 @@
+--- a/drivers/net/wireless/rt2x00/rt2800lib.c
++++ b/drivers/net/wireless/rt2x00/rt2800lib.c
+@@ -5169,6 +5169,27 @@ static const struct rf_channel rf_vals_3
+ {173, 0x61, 0, 9},
+ };
+
++/*
++ * RF value list for rt3xxx with Xtal20MHz
++ * Supports: 2.4 GHz (all) (RF3322)
++ */
++static const struct rf_channel rf_vals_xtal20mhz_3x[] = {
++ {1, 0xE2, 2, 0x14},
++ {2, 0xE3, 2, 0x14},
++ {3, 0xE4, 2, 0x14},
++ {4, 0xE5, 2, 0x14},
++ {5, 0xE6, 2, 0x14},
++ {6, 0xE7, 2, 0x14},
++ {7, 0xE8, 2, 0x14},
++ {8, 0xE9, 2, 0x14},
++ {9, 0xEA, 2, 0x14},
++ {10, 0xEB, 2, 0x14},
++ {11, 0xEC, 2, 0x14},
++ {12, 0xED, 2, 0x14},
++ {13, 0xEE, 2, 0x14},
++ {14, 0xF0, 2, 0x18},
++};
++
+ static int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
+ {
+ struct hw_mode_spec *spec = &rt2x00dev->spec;
+@@ -5246,7 +5267,6 @@ static int rt2800_probe_hw_mode(struct r
+ rt2x00_rf(rt2x00dev, RF3022) ||
+ rt2x00_rf(rt2x00dev, RF3290) ||
+ rt2x00_rf(rt2x00dev, RF3320) ||
+- rt2x00_rf(rt2x00dev, RF3322) ||
+ rt2x00_rf(rt2x00dev, RF5360) ||
+ rt2x00_rf(rt2x00dev, RF5370) ||
+ rt2x00_rf(rt2x00dev, RF5372) ||
+@@ -5254,6 +5274,12 @@ static int rt2800_probe_hw_mode(struct r
+ rt2x00_rf(rt2x00dev, RF5392)) {
+ spec->num_channels = 14;
+ spec->channels = rf_vals_3x;
++ } else if (rt2x00_rf(rt2x00dev, RF3322)) {
++ spec->num_channels = 14;
++ if (spec->clk_is_20mhz)
++ spec->channels = rf_vals_xtal20mhz_3x;
++ else
++ spec->channels = rf_vals_3x;
+ } else if (rt2x00_rf(rt2x00dev, RF3052)) {
+ spec->supported_bands |= SUPPORT_BAND_5GHZ;
+ spec->num_channels = ARRAY_SIZE(rf_vals_3x);
+@@ -5347,6 +5373,19 @@ static int rt2800_probe_hw_mode(struct r
+ return 0;
+ }
+
++int rt2800_probe_clk(struct rt2x00_dev *rt2x00dev)
++{
++ struct rt2x00_platform_data *pdata = rt2x00dev->dev->platform_data;
++ struct hw_mode_spec *spec = &rt2x00dev->spec;
++
++ if (!pdata)
++ return -EINVAL;
++
++ spec->clk_is_20mhz = pdata->clk_is_20mhz;
++
++ return 0;
++}
++
+ int rt2800_probe_hw(struct rt2x00_dev *rt2x00dev)
+ {
+ int retval;
+@@ -5372,6 +5411,15 @@ int rt2800_probe_hw(struct rt2x00_dev *r
+ rt2800_register_write(rt2x00dev, GPIO_CTRL, reg);
+
+ /*
++ * Probe SoC clock.
++ */
++ if (rt2x00_is_soc(rt2x00dev)) {
++ retval = rt2800_probe_clk(rt2x00dev);
++ if (retval)
++ return retval;
++ }
++
++ /*
+ * Initialize hw specifications.
+ */
+ retval = rt2800_probe_hw_mode(rt2x00dev);
+--- a/drivers/net/wireless/rt2x00/rt2x00.h
++++ b/drivers/net/wireless/rt2x00/rt2x00.h
+@@ -419,6 +419,7 @@ static inline struct rt2x00_intf* vif_to
+ * @channels: Device/chipset specific channel values (See &struct rf_channel).
+ * @channels_info: Additional information for channels (See &struct channel_info).
+ * @ht: Driver HT Capabilities (See &ieee80211_sta_ht_cap).
++ * @clk_is_20mhz: External crystal of WiSoC is 20MHz instead of 40MHz
+ */
+ struct hw_mode_spec {
+ unsigned int supported_bands;
+@@ -435,6 +436,7 @@ struct hw_mode_spec {
+ const struct channel_info *channels_info;
+
+ struct ieee80211_sta_ht_cap ht;
++ int clk_is_20mhz;
+ };
+
+ /*
+--- a/include/linux/rt2x00_platform.h
++++ b/include/linux/rt2x00_platform.h
+@@ -18,6 +18,7 @@ struct rt2x00_platform_data {
+
+ int disable_2ghz;
+ int disable_5ghz;
++ int clk_is_20mhz;
+ };
+
+ #endif /* _RT2X00_PLATFORM_H */
diff --git a/package/mac80211/patches/700-mwl8k-missing-pci-id-for-WNR854T.patch b/package/mac80211/patches/700-mwl8k-missing-pci-id-for-WNR854T.patch
new file mode 100644
index 0000000..80fde27
--- /dev/null
+++ b/package/mac80211/patches/700-mwl8k-missing-pci-id-for-WNR854T.patch
@@ -0,0 +1,10 @@
+--- a/drivers/net/wireless/mwl8k.c
++++ b/drivers/net/wireless/mwl8k.c
+@@ -5497,6 +5497,7 @@ MODULE_FIRMWARE("mwl8k/fmimage_8366.fw")
+ MODULE_FIRMWARE(MWL8K_8366_AP_FW(MWL8K_8366_AP_FW_API));
+
+ static DEFINE_PCI_DEVICE_TABLE(mwl8k_pci_id_table) = {
++ { PCI_VDEVICE(MARVELL, 0x2a02), .driver_data = MWL8363, },
+ { PCI_VDEVICE(MARVELL, 0x2a0a), .driver_data = MWL8363, },
+ { PCI_VDEVICE(MARVELL, 0x2a0c), .driver_data = MWL8363, },
+ { PCI_VDEVICE(MARVELL, 0x2a24), .driver_data = MWL8363, },
diff --git a/package/mac80211/patches/800-b43-gpio-mask-module-option.patch b/package/mac80211/patches/800-b43-gpio-mask-module-option.patch
new file mode 100644
index 0000000..d8fb06d
--- /dev/null
+++ b/package/mac80211/patches/800-b43-gpio-mask-module-option.patch
@@ -0,0 +1,37 @@
+--- a/drivers/net/wireless/b43/b43.h
++++ b/drivers/net/wireless/b43/b43.h
+@@ -812,6 +812,7 @@ struct b43_wldev {
+ bool qos_enabled; /* TRUE, if QoS is used. */
+ bool hwcrypto_enabled; /* TRUE, if HW crypto acceleration is enabled. */
+ bool use_pio; /* TRUE if next init should use PIO */
++ int gpiomask; /* GPIO LED mask as a module parameter */
+
+ /* PHY/Radio device. */
+ struct b43_phy phy;
+--- a/drivers/net/wireless/b43/main.c
++++ b/drivers/net/wireless/b43/main.c
+@@ -76,6 +76,11 @@ MODULE_FIRMWARE("b43/ucode16_mimo.fw");
+ MODULE_FIRMWARE("b43/ucode5.fw");
+ MODULE_FIRMWARE("b43/ucode9.fw");
+
++static int modparam_gpiomask = 0x000F;
++module_param_named(gpiomask, modparam_gpiomask, int, 0444);
++MODULE_PARM_DESC(gpiomask,
++ "GPIO mask for LED control (default 0x000F)");
++
+ static int modparam_bad_frames_preempt;
+ module_param_named(bad_frames_preempt, modparam_bad_frames_preempt, int, 0444);
+ MODULE_PARM_DESC(bad_frames_preempt,
+@@ -2740,10 +2745,10 @@ static int b43_gpio_init(struct b43_wlde
+ u32 mask, set;
+
+ b43_maskset32(dev, B43_MMIO_MACCTL, ~B43_MACCTL_GPOUTSMSK, 0);
+- b43_maskset16(dev, B43_MMIO_GPIO_MASK, ~0, 0xF);
++ b43_maskset16(dev, B43_MMIO_GPIO_MASK, ~0, modparam_gpiomask);
+
+ mask = 0x0000001F;
+- set = 0x0000000F;
++ set = modparam_gpiomask;
+ if (dev->dev->chip_id == 0x4301) {
+ mask |= 0x0060;
+ set |= 0x0060;
diff --git a/package/mac80211/patches/810-b43_no_pio.patch b/package/mac80211/patches/810-b43_no_pio.patch
new file mode 100644
index 0000000..5b4c22e
--- /dev/null
+++ b/package/mac80211/patches/810-b43_no_pio.patch
@@ -0,0 +1,75 @@
+--- a/drivers/net/wireless/b43/Makefile
++++ b/drivers/net/wireless/b43/Makefile
+@@ -20,7 +20,7 @@ b43-y += xmit.o
+ b43-y += lo.o
+ b43-y += wa.o
+ b43-y += dma.o
+-b43-y += pio.o
++b43-$(CONFIG_B43_PIO) += pio.o
+ b43-y += rfkill.o
+ b43-$(CONFIG_B43_LEDS) += leds.o
+ b43-$(CONFIG_B43_PCMCIA) += pcmcia.o
+--- a/drivers/net/wireless/b43/main.c
++++ b/drivers/net/wireless/b43/main.c
+@@ -1909,10 +1909,12 @@ static void b43_do_interrupt_thread(stru
+ dma_reason[0], dma_reason[1],
+ dma_reason[2], dma_reason[3],
+ dma_reason[4], dma_reason[5]);
++#ifdef CONFIG_B43_PIO
+ b43err(dev->wl, "This device does not support DMA "
+ "on your system. It will now be switched to PIO.\n");
+ /* Fall back to PIO transfers if we get fatal DMA errors! */
+ dev->use_pio = true;
++#endif
+ b43_controller_restart(dev, "DMA error");
+ return;
+ }
+--- a/drivers/net/wireless/b43/pio.h
++++ b/drivers/net/wireless/b43/pio.h
+@@ -150,7 +150,7 @@ static inline void b43_piorx_write32(str
+ b43_write32(q->dev, q->mmio_base + offset, value);
+ }
+
+-
++#ifdef CONFIG_B43_PIO
+ int b43_pio_init(struct b43_wldev *dev);
+ void b43_pio_free(struct b43_wldev *dev);
+
+@@ -161,5 +161,37 @@ void b43_pio_rx(struct b43_pio_rxqueue *
+
+ void b43_pio_tx_suspend(struct b43_wldev *dev);
+ void b43_pio_tx_resume(struct b43_wldev *dev);
++#else
++static inline int b43_pio_init(struct b43_wldev *dev)
++{
++ return 0;
++}
++
++static inline void b43_pio_free(struct b43_wldev *dev)
++{
++}
++
++static inline int b43_pio_tx(struct b43_wldev *dev, struct sk_buff *skb)
++{
++ return 0;
++}
++
++static inline void b43_pio_handle_txstatus(struct b43_wldev *dev,
++ const struct b43_txstatus *status)
++{
++}
++
++static inline void b43_pio_rx(struct b43_pio_rxqueue *q)
++{
++}
++
++static inline void b43_pio_tx_suspend(struct b43_wldev *dev)
++{
++}
++
++static inline void b43_pio_tx_resume(struct b43_wldev *dev)
++{
++}
++#endif /* CONFIG_B43_PIO */
+
+ #endif /* B43_PIO_H_ */
diff --git a/package/mac80211/patches/820-b43-add-antenna-control.patch b/package/mac80211/patches/820-b43-add-antenna-control.patch
new file mode 100644
index 0000000..8b6255f
--- /dev/null
+++ b/package/mac80211/patches/820-b43-add-antenna-control.patch
@@ -0,0 +1,131 @@
+--- a/drivers/net/wireless/b43/main.c
++++ b/drivers/net/wireless/b43/main.c
+@@ -1553,7 +1553,7 @@ static void b43_write_beacon_template(st
+ len, ram_offset, shm_size_offset, rate);
+
+ /* Write the PHY TX control parameters. */
+- antenna = B43_ANTENNA_DEFAULT;
++ antenna = dev->tx_antenna;
+ antenna = b43_antenna_to_phyctl(antenna);
+ ctl = b43_shm_read16(dev, B43_SHM_SHARED, B43_SHM_SH_BEACPHYCTL);
+ /* We can't send beacons with short preamble. Would get PHY errors. */
+@@ -3101,8 +3101,8 @@ static int b43_chip_init(struct b43_wlde
+
+ /* Select the antennae */
+ if (phy->ops->set_rx_antenna)
+- phy->ops->set_rx_antenna(dev, B43_ANTENNA_DEFAULT);
+- b43_mgmtframe_txantenna(dev, B43_ANTENNA_DEFAULT);
++ phy->ops->set_rx_antenna(dev, dev->rx_antenna);
++ b43_mgmtframe_txantenna(dev, dev->tx_antenna);
+
+ if (phy->type == B43_PHYTYPE_B) {
+ value16 = b43_read16(dev, 0x005E);
+@@ -3846,7 +3846,6 @@ static int b43_op_config(struct ieee8021
+ struct b43_wldev *dev;
+ struct b43_phy *phy;
+ struct ieee80211_conf *conf = &hw->conf;
+- int antenna;
+ int err = 0;
+ bool reload_bss = false;
+
+@@ -3900,11 +3899,9 @@ static int b43_op_config(struct ieee8021
+ }
+
+ /* Antennas for RX and management frame TX. */
+- antenna = B43_ANTENNA_DEFAULT;
+- b43_mgmtframe_txantenna(dev, antenna);
+- antenna = B43_ANTENNA_DEFAULT;
++ b43_mgmtframe_txantenna(dev, dev->tx_antenna);
+ if (phy->ops->set_rx_antenna)
+- phy->ops->set_rx_antenna(dev, antenna);
++ phy->ops->set_rx_antenna(dev, dev->rx_antenna);
+
+ if (wl->radio_enabled != phy->radio_on) {
+ if (wl->radio_enabled) {
+@@ -5030,6 +5027,47 @@ static int b43_op_get_survey(struct ieee
+ return 0;
+ }
+
++static int b43_op_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant)
++{
++ struct b43_wl *wl = hw_to_b43_wl(hw);
++ struct b43_wldev *dev = wl->current_dev;
++
++ if (tx_ant == 1 && rx_ant == 1) {
++ dev->tx_antenna = B43_ANTENNA0;
++ dev->rx_antenna = B43_ANTENNA0;
++ }
++ else if (tx_ant == 2 && rx_ant == 2) {
++ dev->tx_antenna = B43_ANTENNA1;
++ dev->rx_antenna = B43_ANTENNA1;
++ }
++ else if ((tx_ant & 3) == 3 && (rx_ant & 3) == 3) {
++ dev->tx_antenna = B43_ANTENNA_DEFAULT;
++ dev->rx_antenna = B43_ANTENNA_DEFAULT;
++ }
++ else {
++ return -EINVAL;
++ }
++
++ return 0;
++}
++
++
++static int b43_op_get_antenna(struct ieee80211_hw *hw, u32 *tx_ant, u32 *rx_ant)
++{
++ struct b43_wl *wl = hw_to_b43_wl(hw);
++ struct b43_wldev *dev = wl->current_dev;
++
++ switch (dev->tx_antenna) {
++ case B43_ANTENNA0:
++ *tx_ant = 1; *rx_ant = 1; break;
++ case B43_ANTENNA1:
++ *tx_ant = 2; *rx_ant = 2; break;
++ case B43_ANTENNA_DEFAULT:
++ *tx_ant = 3; *rx_ant = 3; break;
++ }
++ return 0;
++}
++
+ static const struct ieee80211_ops b43_hw_ops = {
+ .tx = b43_op_tx,
+ .conf_tx = b43_op_conf_tx,
+@@ -5051,6 +5089,8 @@ static const struct ieee80211_ops b43_hw
+ .sw_scan_complete = b43_op_sw_scan_complete_notifier,
+ .get_survey = b43_op_get_survey,
+ .rfkill_poll = b43_rfkill_poll,
++ .set_antenna = b43_op_set_antenna,
++ .get_antenna = b43_op_get_antenna,
+ };
+
+ /* Hard-reset the chip. Do not call this directly.
+@@ -5297,6 +5337,8 @@ static int b43_one_core_attach(struct b4
+ if (!wldev)
+ goto out;
+
++ wldev->rx_antenna = B43_ANTENNA_DEFAULT;
++ wldev->tx_antenna = B43_ANTENNA_DEFAULT;
+ wldev->use_pio = b43_modparam_pio;
+ wldev->dev = dev;
+ wldev->wl = wl;
+@@ -5387,6 +5429,9 @@ static struct b43_wl *b43_wireless_init(
+
+ hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN;
+
++ hw->wiphy->available_antennas_rx = 0x3;
++ hw->wiphy->available_antennas_tx = 0x3;
++
+ wl->hw_registred = false;
+ hw->max_rates = 2;
+ SET_IEEE80211_DEV(hw, dev->dev);
+--- a/drivers/net/wireless/b43/b43.h
++++ b/drivers/net/wireless/b43/b43.h
+@@ -813,6 +813,8 @@ struct b43_wldev {
+ bool hwcrypto_enabled; /* TRUE, if HW crypto acceleration is enabled. */
+ bool use_pio; /* TRUE if next init should use PIO */
+ int gpiomask; /* GPIO LED mask as a module parameter */
++ int rx_antenna; /* Used RX antenna (B43_ANTENNAxxx) */
++ int tx_antenna; /* Used TX antenna (B43_ANTENNAxxx) */
+
+ /* PHY/Radio device. */
+ struct b43_phy phy;
diff --git a/package/mac80211/patches/830-b43-workaround-pcie-bcm4716.patch b/package/mac80211/patches/830-b43-workaround-pcie-bcm4716.patch
new file mode 100644
index 0000000..bd10f99
--- /dev/null
+++ b/package/mac80211/patches/830-b43-workaround-pcie-bcm4716.patch
@@ -0,0 +1,134 @@
+From 4f214b1ead0af7439921637645cb63f378516175 Mon Sep 17 00:00:00 2001
+From: Hauke Mehrtens <hauke@hauke-m.de>
+Date: Sat, 21 Jan 2012 18:48:38 +0100
+Subject: [PATCH 33/34] b43: add workaround for b43 on pcie bus of bcm4716.
+
+bcm4716 (which includes 4717 & 4718), plus 4706 on PCIe can reorder
+transactions. As a fix, a read after write is performed on certain
+places in the code. Older chips and the newer 5357 family don't require
+this fix.
+This code is based on the brcmsmac driver.
+
+Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
+---
+ drivers/net/wireless/b43/b43.h | 26 ++++++++++++++++++++++++++
+ drivers/net/wireless/b43/bus.h | 10 ++++++++++
+ drivers/net/wireless/b43/phy_common.c | 6 ++++++
+ drivers/net/wireless/b43/phy_n.c | 10 +++++-----
+ 4 files changed, 47 insertions(+), 5 deletions(-)
+
+--- a/drivers/net/wireless/b43/b43.h
++++ b/drivers/net/wireless/b43/b43.h
+@@ -1053,6 +1053,32 @@ static inline bool b43_using_pio_transfe
+ return dev->__using_pio_transfers;
+ }
+
++/*
++ * bcm4716 (which includes 4717 & 4718), plus 4706 on PCIe can reorder
++ * transactions. As a fix, a read after write is performed on certain places
++ * in the code. Older chips and the newer 5357 family don't require this fix.
++ */
++#ifdef CONFIG_BCM47XX_BCMA
++#include <asm/mach-bcm47xx/bcm47xx.h>
++static inline void b43_wflush16(struct b43_wldev *dev, u16 offset, u16 value)
++{
++ if (b43_bus_host_is_pci(dev->dev) &&
++ bcm47xx_bus_type == BCM47XX_BUS_TYPE_BCMA &&
++ (bcm47xx_bus.bcma.bus.chipinfo.id == 0x4716 ||
++ bcm47xx_bus.bcma.bus.chipinfo.id == 0x5300)) {
++ b43_write16(dev, offset, value);
++ b43_read16(dev, offset);
++ } else {
++ b43_write16(dev, offset, value);
++ }
++}
++#else
++static inline void b43_wflush16(struct b43_wldev *dev, u16 offset, u16 value)
++{
++ b43_write16(dev, offset, value);
++}
++#endif
++
+ /* Message printing */
+ __printf(2, 3) void b43info(struct b43_wl *wl, const char *fmt, ...);
+ __printf(2, 3) void b43err(struct b43_wl *wl, const char *fmt, ...);
+--- a/drivers/net/wireless/b43/bus.h
++++ b/drivers/net/wireless/b43/bus.h
+@@ -60,6 +60,16 @@ static inline bool b43_bus_host_is_sdio(
+ return (dev->bus_type == B43_BUS_SSB &&
+ dev->sdev->bus->bustype == SSB_BUSTYPE_SDIO);
+ }
++static inline bool b43_bus_host_is_pci(struct b43_bus_dev *dev)
++{
++ if (dev->bus_type == B43_BUS_SSB)
++ return (dev->sdev->bus->bustype == SSB_BUSTYPE_PCI);
++#ifdef CONFIG_B43_BCMA
++ if (dev->bus_type == B43_BUS_BCMA)
++ return (dev->bdev->bus->hosttype == BCMA_HOSTTYPE_PCI);
++#endif
++ return false;
++}
+
+ struct b43_bus_dev *b43_bus_dev_bcma_init(struct bcma_device *core);
+ struct b43_bus_dev *b43_bus_dev_ssb_init(struct ssb_device *sdev);
+--- a/drivers/net/wireless/b43/phy_common.c
++++ b/drivers/net/wireless/b43/phy_common.c
+@@ -266,6 +266,12 @@ void b43_phy_write(struct b43_wldev *dev
+ {
+ assert_mac_suspended(dev);
+ dev->phy.ops->phy_write(dev, reg, value);
++#ifdef CONFIG_BCM47XX
++ if (b43_bus_host_is_pci(dev->dev) && reg == 0x72) {
++ b43_read16(dev, B43_MMIO_PHY_VER);
++ return;
++ }
++#endif
+ if (++dev->phy.writes_counter == B43_MAX_WRITES_IN_ROW) {
+ b43_read16(dev, B43_MMIO_PHY_VER);
+ dev->phy.writes_counter = 0;
+--- a/drivers/net/wireless/b43/phy_n.c
++++ b/drivers/net/wireless/b43/phy_n.c
+@@ -5423,14 +5423,14 @@ static inline void check_phyreg(struct b
+ static u16 b43_nphy_op_read(struct b43_wldev *dev, u16 reg)
+ {
+ check_phyreg(dev, reg);
+- b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
++ b43_wflush16(dev, B43_MMIO_PHY_CONTROL, reg);
+ return b43_read16(dev, B43_MMIO_PHY_DATA);
+ }
+
+ static void b43_nphy_op_write(struct b43_wldev *dev, u16 reg, u16 value)
+ {
+ check_phyreg(dev, reg);
+- b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
++ b43_wflush16(dev, B43_MMIO_PHY_CONTROL, reg);
+ b43_write16(dev, B43_MMIO_PHY_DATA, value);
+ }
+
+@@ -5438,7 +5438,7 @@ static void b43_nphy_op_maskset(struct b
+ u16 set)
+ {
+ check_phyreg(dev, reg);
+- b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
++ b43_wflush16(dev, B43_MMIO_PHY_CONTROL, reg);
+ b43_maskset16(dev, B43_MMIO_PHY_DATA, mask, set);
+ }
+
+@@ -5449,7 +5449,7 @@ static u16 b43_nphy_op_radio_read(struct
+ /* N-PHY needs 0x100 for read access */
+ reg |= 0x100;
+
+- b43_write16(dev, B43_MMIO_RADIO_CONTROL, reg);
++ b43_wflush16(dev, B43_MMIO_RADIO_CONTROL, reg);
+ return b43_read16(dev, B43_MMIO_RADIO_DATA_LOW);
+ }
+
+@@ -5458,7 +5458,7 @@ static void b43_nphy_op_radio_write(stru
+ /* Register 1 is a 32-bit register. */
+ B43_WARN_ON(reg == 1);
+
+- b43_write16(dev, B43_MMIO_RADIO_CONTROL, reg);
++ b43_wflush16(dev, B43_MMIO_RADIO_CONTROL, reg);
+ b43_write16(dev, B43_MMIO_RADIO_DATA_LOW, value);
+ }
+
diff --git a/package/mac80211/patches/840-b43-increase_number_of_rx_dma_slots.patch b/package/mac80211/patches/840-b43-increase_number_of_rx_dma_slots.patch
new file mode 100644
index 0000000..94c6ff2
--- /dev/null
+++ b/package/mac80211/patches/840-b43-increase_number_of_rx_dma_slots.patch
@@ -0,0 +1,11 @@
+--- a/drivers/net/wireless/b43/dma.h
++++ b/drivers/net/wireless/b43/dma.h
+@@ -169,7 +169,7 @@ struct b43_dmadesc_generic {
+
+ /* DMA engine tuning knobs */
+ #define B43_TXRING_SLOTS 256
+-#define B43_RXRING_SLOTS 64
++#define B43_RXRING_SLOTS 256
+ #define B43_DMA0_RX_FW598_BUFSIZE (B43_DMA0_RX_FW598_FO + IEEE80211_MAX_FRAME_LEN)
+ #define B43_DMA0_RX_FW351_BUFSIZE (B43_DMA0_RX_FW351_FO + IEEE80211_MAX_FRAME_LEN)
+
diff --git a/package/mac80211/patches/850-brcmsmac-start-adding-support-for-core-rev-28.patch b/package/mac80211/patches/850-brcmsmac-start-adding-support-for-core-rev-28.patch
new file mode 100644
index 0000000..41c4476
--- /dev/null
+++ b/package/mac80211/patches/850-brcmsmac-start-adding-support-for-core-rev-28.patch
@@ -0,0 +1,75 @@
+--- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
++++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
+@@ -99,6 +99,7 @@ static struct bcma_device_id brcms_corei
+ BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_80211, 17, BCMA_ANY_CLASS),
+ BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_80211, 23, BCMA_ANY_CLASS),
+ BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_80211, 24, BCMA_ANY_CLASS),
++// BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_80211, 28, BCMA_ANY_CLASS),
+ BCMA_CORETABLE_END
+ };
+ MODULE_DEVICE_TABLE(bcma, brcms_coreid_table);
+--- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
++++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
+@@ -717,7 +717,7 @@ static void brcms_c_ucode_bsinit(struct
+ brcms_c_write_mhf(wlc_hw, wlc_hw->band->mhfs);
+
+ /* do band-specific ucode IHR, SHM, and SCR inits */
+- if (D11REV_IS(wlc_hw->corerev, 17) || D11REV_IS(wlc_hw->corerev, 23)) {
++ if (D11REV_IS(wlc_hw->corerev, 17) || D11REV_IS(wlc_hw->corerev, 23) || D11REV_IS(wlc_hw->corerev, 28)) {
+ if (BRCMS_ISNPHY(wlc_hw->band))
+ brcms_c_write_inits(wlc_hw, ucode->d11n0bsinitvals16);
+ else
+@@ -2257,7 +2257,7 @@ static void brcms_ucode_download(struct
+ if (wlc_hw->ucode_loaded)
+ return;
+
+- if (D11REV_IS(wlc_hw->corerev, 17) || D11REV_IS(wlc_hw->corerev, 23)) {
++ if (D11REV_IS(wlc_hw->corerev, 17) || D11REV_IS(wlc_hw->corerev, 23) || D11REV_IS(wlc_hw->corerev, 28)) {
+ if (BRCMS_ISNPHY(wlc_hw->band)) {
+ brcms_ucode_write(wlc_hw, ucode->bcm43xx_16_mimo,
+ ucode->bcm43xx_16_mimosz);
+@@ -3207,7 +3207,7 @@ static void brcms_b_coreinit(struct brcm
+
+ sflags = bcma_aread32(core, BCMA_IOST);
+
+- if (D11REV_IS(wlc_hw->corerev, 17) || D11REV_IS(wlc_hw->corerev, 23)) {
++ if (D11REV_IS(wlc_hw->corerev, 17) || D11REV_IS(wlc_hw->corerev, 23) || D11REV_IS(wlc_hw->corerev, 28)) {
+ if (BRCMS_ISNPHY(wlc_hw->band))
+ brcms_c_write_inits(wlc_hw, ucode->d11n0initvals16);
+ else
+@@ -5663,6 +5663,8 @@ static bool brcms_c_chipmatch_soc(struct
+
+ if (chipinfo->id == BCMA_CHIP_ID_BCM4716)
+ return true;
++ if (chipinfo->id == BCMA_CHIP_ID_BCM5357)
++ return true;
+
+ pr_err("unknown chip id %04x\n", chipinfo->id);
+ return false;
+--- a/drivers/net/wireless/brcm80211/brcmsmac/main.h
++++ b/drivers/net/wireless/brcm80211/brcmsmac/main.h
+@@ -65,7 +65,7 @@
+ #define SW_TIMER_MAC_STAT_UPD 30 /* periodic MAC stats update */
+
+ /* max # supported core revisions (0 .. MAXCOREREV - 1) */
+-#define MAXCOREREV 28
++#define MAXCOREREV 29
+
+ /* Double check that unsupported cores are not enabled */
+ #if CONF_MSK(D11CONF, 0x4f) || CONF_GE(D11CONF, MAXCOREREV)
+--- a/drivers/net/wireless/brcm80211/brcmsmac/types.h
++++ b/drivers/net/wireless/brcm80211/brcmsmac/types.h
+@@ -93,11 +93,11 @@
+ #define BOARD_GPIO_13 0x2000
+
+ /* **** Core type/rev defaults **** */
+-#define D11CONF 0x0fffffb0 /* Supported D11 revs: 4, 5, 7-27
++#define D11CONF 0x1fffffb0 /* Supported D11 revs: 4, 5, 7-27
+ * also need to update wlc.h MAXCOREREV
+ */
+
+-#define NCONF 0x000001ff /* Supported nphy revs:
++#define NCONF 0x000002ff /* Supported nphy revs:
+ * 0 4321a0
+ * 1 4321a1
+ * 2 4321b0/b1/c0/c1
diff --git a/package/mac80211/patches/860-brcmsmac-implement-ieee80211_ops-get_tsf-and-set_tsf.patch b/package/mac80211/patches/860-brcmsmac-implement-ieee80211_ops-get_tsf-and-set_tsf.patch
new file mode 100644
index 0000000..33991bc
--- /dev/null
+++ b/package/mac80211/patches/860-brcmsmac-implement-ieee80211_ops-get_tsf-and-set_tsf.patch
@@ -0,0 +1,121 @@
+--- a/drivers/net/wireless/brcm80211/brcmsmac/d11.h
++++ b/drivers/net/wireless/brcm80211/brcmsmac/d11.h
+@@ -457,6 +457,7 @@ struct d11regs {
+ /*== maccontrol register ==*/
+ #define MCTL_GMODE (1U << 31)
+ #define MCTL_DISCARD_PMQ (1 << 30)
++#define MCTL_TBTTHOLD (1 << 28)
+ #define MCTL_WAKE (1 << 26)
+ #define MCTL_HPS (1 << 25)
+ #define MCTL_PROMISC (1 << 24)
+--- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
++++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
+@@ -741,6 +741,28 @@ static void brcms_ops_flush(struct ieee8
+ "ret=%d\n", jiffies_to_msecs(ret));
+ }
+
++static u64 brcms_ops_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
++{
++ struct brcms_info *wl = hw->priv;
++ u64 tsf;
++
++ spin_lock_bh(&wl->lock);
++ tsf = brcms_c_tsf_get(wl->wlc);
++ spin_unlock_bh(&wl->lock);
++
++ return tsf;
++}
++
++static void brcms_ops_set_tsf(struct ieee80211_hw *hw,
++ struct ieee80211_vif *vif, u64 tsf)
++{
++ struct brcms_info *wl = hw->priv;
++
++ spin_lock_bh(&wl->lock);
++ brcms_c_tsf_set(wl->wlc, tsf);
++ spin_unlock_bh(&wl->lock);
++}
++
+ static const struct ieee80211_ops brcms_ops = {
+ .tx = brcms_ops_tx,
+ .start = brcms_ops_start,
+@@ -757,6 +779,8 @@ static const struct ieee80211_ops brcms_
+ .ampdu_action = brcms_ops_ampdu_action,
+ .rfkill_poll = brcms_ops_rfkill_poll,
+ .flush = brcms_ops_flush,
++ .get_tsf = brcms_ops_get_tsf,
++ .set_tsf = brcms_ops_set_tsf,
+ };
+
+ void brcms_dpc(unsigned long data)
+--- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
++++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
+@@ -5545,6 +5545,20 @@ int brcms_c_set_rateset(struct brcms_c_i
+ return bcmerror;
+ }
+
++static void brcms_c_time_lock(struct brcms_c_info *wlc)
++{
++ bcma_set32(wlc->hw->d11core, D11REGOFFS(maccontrol), MCTL_TBTTHOLD);
++ /* Commit the write */
++ bcma_read32(wlc->hw->d11core, D11REGOFFS(maccontrol));
++}
++
++static void brcms_c_time_unlock(struct brcms_c_info *wlc)
++{
++ bcma_mask32(wlc->hw->d11core, D11REGOFFS(maccontrol), ~MCTL_TBTTHOLD);
++ /* Commit the write */
++ bcma_read32(wlc->hw->d11core, D11REGOFFS(maccontrol));
++}
++
+ int brcms_c_set_beacon_period(struct brcms_c_info *wlc, u16 period)
+ {
+ if (period == 0)
+@@ -7530,6 +7544,36 @@ void brcms_c_set_beacon_listen_interval(
+ brcms_c_bcn_li_upd(wlc);
+ }
+
++u64 brcms_c_tsf_get(struct brcms_c_info *wlc)
++{
++ u32 tsf_h, tsf_l;
++ u64 tsf;
++
++ brcms_b_read_tsf(wlc->hw, &tsf_l, &tsf_h);
++
++ tsf = tsf_h;
++ tsf <<= 32;
++ tsf |= tsf_l;
++
++ return tsf;
++}
++
++void brcms_c_tsf_set(struct brcms_c_info *wlc, u64 tsf)
++{
++ u32 tsf_h, tsf_l;
++
++ brcms_c_time_lock(wlc);
++
++ tsf_l = tsf;
++ tsf_h = (tsf >> 32);
++
++ /* read the tsf timer low, then high to get an atomic read */
++ bcma_write32(wlc->hw->d11core, D11REGOFFS(tsf_timerlow), tsf_l);
++ bcma_write32(wlc->hw->d11core, D11REGOFFS(tsf_timerhigh), tsf_h);
++
++ brcms_c_time_unlock(wlc);
++}
++
+ int brcms_c_set_tx_power(struct brcms_c_info *wlc, int txpwr)
+ {
+ uint qdbm;
+--- a/drivers/net/wireless/brcm80211/brcmsmac/pub.h
++++ b/drivers/net/wireless/brcm80211/brcmsmac/pub.h
+@@ -326,6 +326,8 @@ extern void brcms_c_set_shortslot_overri
+ s8 sslot_override);
+ extern void brcms_c_set_beacon_listen_interval(struct brcms_c_info *wlc,
+ u8 interval);
++extern u64 brcms_c_tsf_get(struct brcms_c_info *wlc);
++extern void brcms_c_tsf_set(struct brcms_c_info *wlc, u64 tsf);
+ extern int brcms_c_set_tx_power(struct brcms_c_info *wlc, int txpwr);
+ extern int brcms_c_get_tx_power(struct brcms_c_info *wlc);
+ extern bool brcms_c_check_radio_disabled(struct brcms_c_info *wlc);
diff --git a/package/mac80211/patches/861-brcmsmac-add-interface-type-to-brcms_bss_cfg.patch b/package/mac80211/patches/861-brcmsmac-add-interface-type-to-brcms_bss_cfg.patch
new file mode 100644
index 0000000..21b1e0e
--- /dev/null
+++ b/package/mac80211/patches/861-brcmsmac-add-interface-type-to-brcms_bss_cfg.patch
@@ -0,0 +1,66 @@
+--- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
++++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
+@@ -367,9 +367,10 @@ brcms_ops_add_interface(struct ieee80211
+ }
+
+ spin_lock_bh(&wl->lock);
+- memcpy(wl->pub->cur_etheraddr, vif->addr, sizeof(vif->addr));
+ wl->mute_tx = false;
+ brcms_c_mute(wl->wlc, false);
++ if (vif->type == NL80211_IFTYPE_STATION)
++ brcms_c_start_station(wl->wlc, vif->addr);
+ spin_unlock_bh(&wl->lock);
+
+ return 0;
+--- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
++++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
+@@ -2165,6 +2165,12 @@ void brcms_b_switch_macfreq(struct brcms
+ }
+ }
+
++void brcms_c_start_station(struct brcms_c_info *wlc, u8 *addr)
++{
++ memcpy(wlc->pub->cur_etheraddr, addr, sizeof(wlc->pub->cur_etheraddr));
++ wlc->bsscfg->type = BRCMS_TYPE_STATION;
++}
++
+ /* Initialize GPIOs that are controlled by D11 core */
+ static void brcms_c_gpio_init(struct brcms_c_info *wlc)
+ {
+--- a/drivers/net/wireless/brcm80211/brcmsmac/main.h
++++ b/drivers/net/wireless/brcm80211/brcmsmac/main.h
+@@ -576,10 +576,17 @@ struct antsel_info {
+ struct brcms_antselcfg antcfg_cur; /* current antenna config (auto) */
+ };
+
++enum brcms_bss_type {
++ BRCMS_TYPE_STATION,
++ BRCMS_TYPE_AP,
++ BRCMS_TYPE_ADHOC,
++};
++
+ /*
+ * BSS configuration state
+ *
+ * wlc: wlc to which this bsscfg belongs to.
++ * type: interface type
+ * up: is this configuration up operational
+ * enable: is this configuration enabled
+ * associated: is BSS in ASSOCIATED state
+@@ -599,6 +606,7 @@ struct antsel_info {
+ */
+ struct brcms_bss_cfg {
+ struct brcms_c_info *wlc;
++ enum brcms_bss_type type;
+ bool up;
+ bool enable;
+ bool associated;
+--- a/drivers/net/wireless/brcm80211/brcmsmac/pub.h
++++ b/drivers/net/wireless/brcm80211/brcmsmac/pub.h
+@@ -333,5 +333,6 @@ extern int brcms_c_get_tx_power(struct b
+ extern bool brcms_c_check_radio_disabled(struct brcms_c_info *wlc);
+ extern void brcms_c_mute(struct brcms_c_info *wlc, bool on);
+ extern bool brcms_c_tx_flush_completed(struct brcms_c_info *wlc);
++extern void brcms_c_start_station(struct brcms_c_info *wlc, u8 *addr);
+
+ #endif /* _BRCM_PUB_H_ */
diff --git a/package/mac80211/patches/862-brcmsmac-remove-brcms_bss_cfg-BSS.patch b/package/mac80211/patches/862-brcmsmac-remove-brcms_bss_cfg-BSS.patch
new file mode 100644
index 0000000..a7ffcf6
--- /dev/null
+++ b/package/mac80211/patches/862-brcmsmac-remove-brcms_bss_cfg-BSS.patch
@@ -0,0 +1,77 @@
+--- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
++++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
+@@ -1071,7 +1071,7 @@ brcms_b_txstatus(struct brcms_hardware *
+
+ static void brcms_c_tbtt(struct brcms_c_info *wlc)
+ {
+- if (!wlc->bsscfg->BSS)
++ if (wlc->bsscfg->type == BRCMS_TYPE_ADHOC)
+ /*
+ * DirFrmQ is now valid...defer setting until end
+ * of ATIM window
+@@ -3061,16 +3061,8 @@ static bool brcms_c_ps_allowed(struct br
+ if (wlc->filter_flags & FIF_PROMISC_IN_BSS)
+ return false;
+
+- if (cfg->associated) {
+- /*
+- * disallow PS when one of the following
+- * bsscfg specific conditions meets
+- */
+- if (!cfg->BSS)
+- return false;
+-
++ if (cfg->associated)
+ return false;
+- }
+
+ return true;
+ }
+@@ -5080,8 +5072,9 @@ int brcms_c_up(struct brcms_c_info *wlc)
+ struct brcms_bss_cfg *bsscfg = wlc->bsscfg;
+ mboolset(wlc->pub->radio_disabled,
+ WL_RADIO_HW_DISABLE);
+-
+- if (bsscfg->enable && bsscfg->BSS)
++ if (bsscfg->enable &&
++ (bsscfg->type == BRCMS_TYPE_STATION ||
++ bsscfg->type == BRCMS_TYPE_ADHOC))
+ brcms_err(wlc->hw->d11core,
+ "wl%d: up: rfdisable -> "
+ "bsscfg_disable()\n",
+@@ -7390,7 +7383,7 @@ void brcms_c_update_beacon(struct brcms_
+ {
+ struct brcms_bss_cfg *bsscfg = wlc->bsscfg;
+
+- if (bsscfg->up && !bsscfg->BSS)
++ if (bsscfg->up && bsscfg->type == BRCMS_TYPE_AP)
+ /* Clear the soft intmask */
+ wlc->defmacintmask &= ~MI_BCNTPL;
+ }
+@@ -7465,7 +7458,7 @@ void brcms_c_update_probe_resp(struct br
+ struct brcms_bss_cfg *bsscfg = wlc->bsscfg;
+
+ /* update AP or IBSS probe responses */
+- if (bsscfg->up && !bsscfg->BSS)
++ if (bsscfg->up && bsscfg->type == BRCMS_TYPE_AP)
+ brcms_c_bss_update_probe_resp(wlc, bsscfg, suspend);
+ }
+
+--- a/drivers/net/wireless/brcm80211/brcmsmac/main.h
++++ b/drivers/net/wireless/brcm80211/brcmsmac/main.h
+@@ -590,7 +590,6 @@ enum brcms_bss_type {
+ * up: is this configuration up operational
+ * enable: is this configuration enabled
+ * associated: is BSS in ASSOCIATED state
+- * BSS: infraustructure or adhoc
+ * SSID_len: the length of SSID
+ * SSID: SSID string
+ *
+@@ -610,7 +609,6 @@ struct brcms_bss_cfg {
+ bool up;
+ bool enable;
+ bool associated;
+- bool BSS;
+ u8 SSID_len;
+ u8 SSID[IEEE80211_MAX_SSID_LEN];
+ u8 BSSID[ETH_ALEN];
diff --git a/package/mac80211/patches/863-brcmsmac-remove-brcms_bss_cfg-associated.patch b/package/mac80211/patches/863-brcmsmac-remove-brcms_bss_cfg-associated.patch
new file mode 100644
index 0000000..7f84f00
--- /dev/null
+++ b/package/mac80211/patches/863-brcmsmac-remove-brcms_bss_cfg-associated.patch
@@ -0,0 +1,74 @@
+--- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
++++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
+@@ -3051,8 +3051,6 @@ static void brcms_b_antsel_set(struct br
+ */
+ static bool brcms_c_ps_allowed(struct brcms_c_info *wlc)
+ {
+- struct brcms_bss_cfg *cfg = wlc->bsscfg;
+-
+ /* disallow PS when one of the following global conditions meets */
+ if (!wlc->pub->associated)
+ return false;
+@@ -3061,9 +3059,6 @@ static bool brcms_c_ps_allowed(struct br
+ if (wlc->filter_flags & FIF_PROMISC_IN_BSS)
+ return false;
+
+- if (cfg->associated)
+- return false;
+-
+ return true;
+ }
+
+@@ -3821,7 +3816,7 @@ static void brcms_c_set_home_chanspec(st
+ if (wlc->home_chanspec != chanspec) {
+ wlc->home_chanspec = chanspec;
+
+- if (wlc->bsscfg->associated)
++ if (wlc->pub->associated)
+ wlc->bsscfg->current_bss->chanspec = chanspec;
+ }
+ }
+@@ -5435,7 +5430,7 @@ static void brcms_c_ofdm_rateset_war(str
+ u8 r;
+ bool war = false;
+
+- if (wlc->bsscfg->associated)
++ if (wlc->pub->associated)
+ r = wlc->bsscfg->current_bss->rateset.rates[0];
+ else
+ r = wlc->default_bss->rateset.rates[0];
+@@ -5529,7 +5524,7 @@ int brcms_c_set_rateset(struct brcms_c_i
+ /* merge rateset coming in with the current mcsset */
+ if (wlc->pub->_n_enab & SUPPORT_11N) {
+ struct brcms_bss_info *mcsset_bss;
+- if (wlc->bsscfg->associated)
++ if (wlc->pub->associated)
+ mcsset_bss = wlc->bsscfg->current_bss;
+ else
+ mcsset_bss = wlc->default_bss;
+@@ -7498,7 +7493,6 @@ void brcms_c_scan_stop(struct brcms_c_in
+ void brcms_c_associate_upd(struct brcms_c_info *wlc, bool state)
+ {
+ wlc->pub->associated = state;
+- wlc->bsscfg->associated = state;
+ }
+
+ /*
+--- a/drivers/net/wireless/brcm80211/brcmsmac/main.h
++++ b/drivers/net/wireless/brcm80211/brcmsmac/main.h
+@@ -589,7 +589,6 @@ enum brcms_bss_type {
+ * type: interface type
+ * up: is this configuration up operational
+ * enable: is this configuration enabled
+- * associated: is BSS in ASSOCIATED state
+ * SSID_len: the length of SSID
+ * SSID: SSID string
+ *
+@@ -608,7 +607,6 @@ struct brcms_bss_cfg {
+ enum brcms_bss_type type;
+ bool up;
+ bool enable;
+- bool associated;
+ u8 SSID_len;
+ u8 SSID[IEEE80211_MAX_SSID_LEN];
+ u8 BSSID[ETH_ALEN];
diff --git a/package/mac80211/patches/864-brcmsmac-remove-brcms_bss_cfg-enable.patch b/package/mac80211/patches/864-brcmsmac-remove-brcms_bss_cfg-enable.patch
new file mode 100644
index 0000000..9f5c4da
--- /dev/null
+++ b/package/mac80211/patches/864-brcmsmac-remove-brcms_bss_cfg-enable.patch
@@ -0,0 +1,32 @@
+--- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
++++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
+@@ -5067,9 +5067,8 @@ int brcms_c_up(struct brcms_c_info *wlc)
+ struct brcms_bss_cfg *bsscfg = wlc->bsscfg;
+ mboolset(wlc->pub->radio_disabled,
+ WL_RADIO_HW_DISABLE);
+- if (bsscfg->enable &&
+- (bsscfg->type == BRCMS_TYPE_STATION ||
+- bsscfg->type == BRCMS_TYPE_ADHOC))
++ if (bsscfg->type == BRCMS_TYPE_STATION ||
++ bsscfg->type == BRCMS_TYPE_ADHOC)
+ brcms_err(wlc->hw->d11core,
+ "wl%d: up: rfdisable -> "
+ "bsscfg_disable()\n",
+--- a/drivers/net/wireless/brcm80211/brcmsmac/main.h
++++ b/drivers/net/wireless/brcm80211/brcmsmac/main.h
+@@ -588,7 +588,6 @@ enum brcms_bss_type {
+ * wlc: wlc to which this bsscfg belongs to.
+ * type: interface type
+ * up: is this configuration up operational
+- * enable: is this configuration enabled
+ * SSID_len: the length of SSID
+ * SSID: SSID string
+ *
+@@ -606,7 +605,6 @@ struct brcms_bss_cfg {
+ struct brcms_c_info *wlc;
+ enum brcms_bss_type type;
+ bool up;
+- bool enable;
+ u8 SSID_len;
+ u8 SSID[IEEE80211_MAX_SSID_LEN];
+ u8 BSSID[ETH_ALEN];
diff --git a/package/mac80211/patches/865-brcmsmac-remove-brcms_bss_cfg-up.patch b/package/mac80211/patches/865-brcmsmac-remove-brcms_bss_cfg-up.patch
new file mode 100644
index 0000000..40fe6ea
--- /dev/null
+++ b/package/mac80211/patches/865-brcmsmac-remove-brcms_bss_cfg-up.patch
@@ -0,0 +1,47 @@
+--- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
++++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
+@@ -7377,7 +7377,7 @@ void brcms_c_update_beacon(struct brcms_
+ {
+ struct brcms_bss_cfg *bsscfg = wlc->bsscfg;
+
+- if (bsscfg->up && bsscfg->type == BRCMS_TYPE_AP)
++ if (wlc->pub->up && bsscfg->type == BRCMS_TYPE_AP)
+ /* Clear the soft intmask */
+ wlc->defmacintmask &= ~MI_BCNTPL;
+ }
+@@ -7452,7 +7452,7 @@ void brcms_c_update_probe_resp(struct br
+ struct brcms_bss_cfg *bsscfg = wlc->bsscfg;
+
+ /* update AP or IBSS probe responses */
+- if (bsscfg->up && bsscfg->type == BRCMS_TYPE_AP)
++ if (wlc->pub->up && bsscfg->type == BRCMS_TYPE_AP)
+ brcms_c_bss_update_probe_resp(wlc, bsscfg, suspend);
+ }
+
+@@ -7805,7 +7805,7 @@ void brcms_c_init(struct brcms_c_info *w
+ brcms_c_set_bssid(wlc->bsscfg);
+
+ /* Update tsf_cfprep if associated and up */
+- if (wlc->pub->associated && wlc->bsscfg->up) {
++ if (wlc->pub->associated && wlc->pub->up) {
+ u32 bi;
+
+ /* get beacon period and convert to uS */
+--- a/drivers/net/wireless/brcm80211/brcmsmac/main.h
++++ b/drivers/net/wireless/brcm80211/brcmsmac/main.h
+@@ -587,7 +587,6 @@ enum brcms_bss_type {
+ *
+ * wlc: wlc to which this bsscfg belongs to.
+ * type: interface type
+- * up: is this configuration up operational
+ * SSID_len: the length of SSID
+ * SSID: SSID string
+ *
+@@ -604,7 +603,6 @@ enum brcms_bss_type {
+ struct brcms_bss_cfg {
+ struct brcms_c_info *wlc;
+ enum brcms_bss_type type;
+- bool up;
+ u8 SSID_len;
+ u8 SSID[IEEE80211_MAX_SSID_LEN];
+ u8 BSSID[ETH_ALEN];
diff --git a/package/mac80211/patches/866-brcmsmac-remove-brcms_bss_cfg-cur_etheraddr.patch b/package/mac80211/patches/866-brcmsmac-remove-brcms_bss_cfg-cur_etheraddr.patch
new file mode 100644
index 0000000..0571932
--- /dev/null
+++ b/package/mac80211/patches/866-brcmsmac-remove-brcms_bss_cfg-cur_etheraddr.patch
@@ -0,0 +1,30 @@
+--- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
++++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
+@@ -3766,7 +3766,7 @@ static int brcms_c_set_mac(struct brcms_
+ struct brcms_c_info *wlc = bsscfg->wlc;
+
+ /* enter the MAC addr into the RXE match registers */
+- brcms_c_set_addrmatch(wlc, RCM_MAC_OFFSET, bsscfg->cur_etheraddr);
++ brcms_c_set_addrmatch(wlc, RCM_MAC_OFFSET, wlc->pub->cur_etheraddr);
+
+ brcms_c_ampdu_macaddr_upd(wlc);
+
+@@ -7359,7 +7359,7 @@ brcms_c_bcn_prb_template(struct brcms_c_
+ /* A1 filled in by MAC for prb resp, broadcast for bcn */
+ if (type == IEEE80211_STYPE_BEACON)
+ memcpy(&h->da, &ether_bcast, ETH_ALEN);
+- memcpy(&h->sa, &cfg->cur_etheraddr, ETH_ALEN);
++ memcpy(&h->sa, &wlc->pub->cur_etheraddr, ETH_ALEN);
+ memcpy(&h->bssid, &cfg->BSSID, ETH_ALEN);
+
+ /* SEQ filled in by MAC */
+--- a/drivers/net/wireless/brcm80211/brcmsmac/main.h
++++ b/drivers/net/wireless/brcm80211/brcmsmac/main.h
+@@ -606,7 +606,6 @@ struct brcms_bss_cfg {
+ u8 SSID_len;
+ u8 SSID[IEEE80211_MAX_SSID_LEN];
+ u8 BSSID[ETH_ALEN];
+- u8 cur_etheraddr[ETH_ALEN];
+ struct brcms_bss_info *current_bss;
+ };
+
diff --git a/package/mac80211/patches/867-brcmsmac-remove-brcms_pub-bcmerr.patch b/package/mac80211/patches/867-brcmsmac-remove-brcms_pub-bcmerr.patch
new file mode 100644
index 0000000..2e7c166
--- /dev/null
+++ b/package/mac80211/patches/867-brcmsmac-remove-brcms_pub-bcmerr.patch
@@ -0,0 +1,21 @@
+--- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
++++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
+@@ -4327,7 +4327,6 @@ static void brcms_c_info_init(struct brc
+
+ /* WME QoS mode is Auto by default */
+ wlc->pub->_ampdu = AMPDU_AGG_HOST;
+- wlc->pub->bcmerror = 0;
+ }
+
+ static uint brcms_c_attach_module(struct brcms_c_info *wlc)
+--- a/drivers/net/wireless/brcm80211/brcmsmac/pub.h
++++ b/drivers/net/wireless/brcm80211/brcmsmac/pub.h
+@@ -164,8 +164,6 @@ struct brcms_pub {
+
+ u8 cur_etheraddr[ETH_ALEN]; /* our local ethernet address */
+
+- int bcmerror; /* last bcm error */
+-
+ u32 radio_disabled; /* bit vector for radio disabled reasons */
+
+ u16 boardrev; /* version # of particular board */
diff --git a/package/mac80211/patches/868-brcmsmac-write-beacon-period-to-hardware.patch b/package/mac80211/patches/868-brcmsmac-write-beacon-period-to-hardware.patch
new file mode 100644
index 0000000..fb10e1b
--- /dev/null
+++ b/package/mac80211/patches/868-brcmsmac-write-beacon-period-to-hardware.patch
@@ -0,0 +1,23 @@
+--- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
++++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
+@@ -5553,10 +5553,20 @@ static void brcms_c_time_unlock(struct b
+
+ int brcms_c_set_beacon_period(struct brcms_c_info *wlc, u16 period)
+ {
++ u32 bcnint_us;
++
+ if (period == 0)
+ return -EINVAL;
+
+ wlc->default_bss->beacon_period = period;
++
++ bcnint_us = period << 10;
++ brcms_c_time_lock(wlc);
++ bcma_write32(wlc->hw->d11core, D11REGOFFS(tsf_cfprep),
++ (bcnint_us << CFPREP_CBI_SHIFT));
++ bcma_write32(wlc->hw->d11core, D11REGOFFS(tsf_cfpstart), bcnint_us);
++ brcms_c_time_unlock(wlc);
++
+ return 0;
+ }
+
diff --git a/package/mac80211/patches/869-brcmsmac-add-beacon-template-support.patch b/package/mac80211/patches/869-brcmsmac-add-beacon-template-support.patch
new file mode 100644
index 0000000..ab864a3
--- /dev/null
+++ b/package/mac80211/patches/869-brcmsmac-add-beacon-template-support.patch
@@ -0,0 +1,266 @@
+--- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
++++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
+@@ -1,5 +1,6 @@
+ /*
+ * Copyright (c) 2010 Broadcom Corporation
++ * Copyright (c) 2013 Hauke Mehrtens <hauke@hauke-m.de>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+@@ -522,9 +523,17 @@ brcms_ops_bss_info_changed(struct ieee80
+ brcms_c_set_addrmatch(wl->wlc, RCM_BSSID_OFFSET, info->bssid);
+ spin_unlock_bh(&wl->lock);
+ }
+- if (changed & BSS_CHANGED_BEACON)
++ if (changed & BSS_CHANGED_BEACON) {
+ /* Beacon data changed, retrieve new beacon (beaconing modes) */
+- brcms_err(core, "%s: beacon changed\n", __func__);
++ struct sk_buff *beacon;
++ u16 tim_offset = 0;
++
++ spin_lock_bh(&wl->lock);
++ beacon = ieee80211_beacon_get_tim(hw, vif, &tim_offset, NULL);
++ brcms_c_set_new_beacon(wl->wlc, beacon, tim_offset,
++ info->dtim_period);
++ spin_unlock_bh(&wl->lock);
++ }
+
+ if (changed & BSS_CHANGED_BEACON_ENABLED) {
+ /* Beaconing should be enabled/disabled (beaconing modes) */
+--- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
++++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
+@@ -1,5 +1,6 @@
+ /*
+ * Copyright (c) 2010 Broadcom Corporation
++ * Copyright (c) 2013 Hauke Mehrtens <hauke@hauke-m.de>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+@@ -450,6 +451,8 @@ static void brcms_c_detach_mfree(struct
+ kfree(wlc->corestate);
+ kfree(wlc->hw->bandstate[0]);
+ kfree(wlc->hw);
++ if (wlc->beacon)
++ dev_kfree_skb_any(wlc->beacon);
+
+ /* free the wlc */
+ kfree(wlc);
+@@ -4086,10 +4089,14 @@ void brcms_c_wme_setparams(struct brcms_
+ *shm_entry++);
+ }
+
+- if (suspend) {
++ if (suspend)
+ brcms_c_suspend_mac_and_wait(wlc);
++
++ brcms_c_update_beacon(wlc);
++ brcms_c_update_probe_resp(wlc, false);
++
++ if (suspend)
+ brcms_c_enable_mac(wlc);
+- }
+ }
+
+ static void brcms_c_edcf_setparams(struct brcms_c_info *wlc, bool suspend)
+@@ -7379,6 +7386,107 @@ int brcms_c_get_header_len(void)
+ return TXOFF;
+ }
+
++static void brcms_c_beacon_write(struct brcms_c_info *wlc,
++ struct sk_buff *beacon, u16 tim_offset,
++ u16 dtim_period, bool bcn0, bool bcn1)
++{
++ size_t len;
++ struct ieee80211_tx_info *tx_info;
++ struct brcms_hardware *wlc_hw = wlc->hw;
++ struct ieee80211_hw *ieee_hw = brcms_c_pub(wlc)->ieee_hw;
++
++ /* Get tx_info */
++ tx_info = IEEE80211_SKB_CB(beacon);
++
++ len = min_t(size_t, beacon->len, BCN_TMPL_LEN);
++ wlc->bcn_rspec = ieee80211_get_tx_rate(ieee_hw, tx_info)->hw_value;
++
++ brcms_c_compute_plcp(wlc, wlc->bcn_rspec,
++ len + FCS_LEN - D11_PHY_HDR_LEN, beacon->data);
++
++ /* "Regular" and 16 MBSS but not for 4 MBSS */
++ /* Update the phytxctl for the beacon based on the rspec */
++ brcms_c_beacon_phytxctl_txant_upd(wlc, wlc->bcn_rspec);
++
++ if (bcn0) {
++ /* write the probe response into the template region */
++ brcms_b_write_template_ram(wlc_hw, T_BCN0_TPL_BASE,
++ (len + 3) & ~3, beacon->data);
++
++ /* write beacon length to SCR */
++ brcms_b_write_shm(wlc_hw, M_BCN0_FRM_BYTESZ, (u16) len);
++ }
++ if (bcn1) {
++ /* write the probe response into the template region */
++ brcms_b_write_template_ram(wlc_hw, T_BCN1_TPL_BASE,
++ (len + 3) & ~3, beacon->data);
++
++ /* write beacon length to SCR */
++ brcms_b_write_shm(wlc_hw, M_BCN1_FRM_BYTESZ, (u16) len);
++ }
++
++ if (tim_offset != 0) {
++ brcms_b_write_shm(wlc_hw, M_TIMBPOS_INBEACON,
++ tim_offset + D11B_PHY_HDR_LEN);
++ brcms_b_write_shm(wlc_hw, M_DOT11_DTIMPERIOD, dtim_period);
++ } else {
++ brcms_b_write_shm(wlc_hw, M_TIMBPOS_INBEACON,
++ len + D11B_PHY_HDR_LEN);
++ brcms_b_write_shm(wlc_hw, M_DOT11_DTIMPERIOD, 0);
++ }
++}
++
++static void brcms_c_update_beacon_hw(struct brcms_c_info *wlc,
++ struct sk_buff *beacon, u16 tim_offset,
++ u16 dtim_period)
++{
++ struct brcms_hardware *wlc_hw = wlc->hw;
++ struct bcma_device *core = wlc_hw->d11core;
++
++ /* Hardware beaconing for this config */
++ u32 both_valid = MCMD_BCN0VLD | MCMD_BCN1VLD;
++
++ /* Check if both templates are in use, if so sched. an interrupt
++ * that will call back into this routine
++ */
++ if ((bcma_read32(core, D11REGOFFS(maccommand)) & both_valid) == both_valid)
++ /* clear any previous status */
++ bcma_write32(core, D11REGOFFS(macintstatus), MI_BCNTPL);
++
++ if (wlc->beacon_template_virgin) {
++ wlc->beacon_template_virgin = false;
++ brcms_c_beacon_write(wlc, beacon, tim_offset, dtim_period, true,
++ true);
++ /* mark beacon0 valid */
++ bcma_set32(core, D11REGOFFS(maccommand), MCMD_BCN0VLD);
++ return;
++ }
++
++ /* Check that after scheduling the interrupt both of the
++ * templates are still busy. if not clear the int. & remask
++ */
++ if ((bcma_read32(core, D11REGOFFS(maccommand)) & both_valid) == both_valid) {
++ wlc->defmacintmask |= MI_BCNTPL;
++ return;
++ }
++
++ if (!(bcma_read32(core, D11REGOFFS(maccommand)) & MCMD_BCN0VLD)) {
++ brcms_c_beacon_write(wlc, beacon, tim_offset, dtim_period, true,
++ false);
++ /* mark beacon0 valid */
++ bcma_set32(core, D11REGOFFS(maccommand), MCMD_BCN0VLD);
++ return;
++ }
++ if (!(bcma_read32(core, D11REGOFFS(maccommand)) & MCMD_BCN1VLD)) {
++ brcms_c_beacon_write(wlc, beacon, tim_offset, dtim_period,
++ false, true);
++ /* mark beacon0 valid */
++ bcma_set32(core, D11REGOFFS(maccommand), MCMD_BCN1VLD);
++ return;
++ }
++ return;
++}
++
+ /*
+ * Update all beacons for the system.
+ */
+@@ -7386,9 +7494,31 @@ void brcms_c_update_beacon(struct brcms_
+ {
+ struct brcms_bss_cfg *bsscfg = wlc->bsscfg;
+
+- if (wlc->pub->up && bsscfg->type == BRCMS_TYPE_AP)
++ if (wlc->pub->up && bsscfg->type == BRCMS_TYPE_AP) {
+ /* Clear the soft intmask */
+ wlc->defmacintmask &= ~MI_BCNTPL;
++ if (!wlc->beacon)
++ return;
++ brcms_c_update_beacon_hw(wlc, wlc->beacon,
++ wlc->beacon_tim_offset,
++ wlc->beacon_dtim_period);
++ }
++}
++
++void brcms_c_set_new_beacon(struct brcms_c_info *wlc, struct sk_buff *beacon,
++ u16 tim_offset, u16 dtim_period)
++{
++ if (!beacon)
++ return;
++ if (wlc->beacon)
++ dev_kfree_skb_any(wlc->beacon);
++ wlc->beacon = beacon;
++
++ /* add PLCP */
++ skb_push(wlc->beacon, D11_PHY_HDR_LEN);
++ wlc->beacon_tim_offset = tim_offset;
++ wlc->beacon_dtim_period = dtim_period;
++ brcms_c_update_beacon(wlc);
+ }
+
+ /* Write ssid into shared memory */
+@@ -7786,6 +7916,10 @@ bool brcms_c_dpc(struct brcms_c_info *wl
+ brcms_rfkill_set_hw_state(wlc->wl);
+ }
+
++ /* BCN template is available */
++ if (macintstatus & MI_BCNTPL)
++ brcms_c_update_beacon(wlc);
++
+ /* it isn't done and needs to be resched if macintstatus is non-zero */
+ return wlc->macintstatus != 0;
+
+@@ -7917,6 +8051,7 @@ brcms_c_attach(struct brcms_info *wl, st
+ pub->unit = unit;
+ pub->_piomode = piomode;
+ wlc->bandinit_pending = false;
++ wlc->beacon_template_virgin = true;
+
+ /* populate struct brcms_c_info with default values */
+ brcms_c_info_init(wlc, unit);
+--- a/drivers/net/wireless/brcm80211/brcmsmac/main.h
++++ b/drivers/net/wireless/brcm80211/brcmsmac/main.h
+@@ -492,6 +492,8 @@ struct brcms_c_info {
+ bool radio_monitor;
+ bool going_down;
+
++ bool beacon_template_virgin;
++
+ struct brcms_timer *wdtimer;
+ struct brcms_timer *radio_timer;
+
+@@ -561,6 +563,10 @@ struct brcms_c_info {
+
+ struct wiphy *wiphy;
+ struct scb pri_scb;
++
++ struct sk_buff *beacon;
++ u16 beacon_tim_offset;
++ u16 beacon_dtim_period;
+ };
+
+ /* antsel module specific state */
+@@ -630,7 +636,6 @@ extern u16 brcms_c_compute_rtscts_dur(st
+ extern void brcms_c_inval_dma_pkts(struct brcms_hardware *hw,
+ struct ieee80211_sta *sta,
+ void (*dma_callback_fn));
+-extern void brcms_c_update_beacon(struct brcms_c_info *wlc);
+ extern void brcms_c_update_probe_resp(struct brcms_c_info *wlc, bool suspend);
+ extern int brcms_c_set_nmode(struct brcms_c_info *wlc);
+ extern void brcms_c_beacon_phytxctl_txant_upd(struct brcms_c_info *wlc,
+--- a/drivers/net/wireless/brcm80211/brcmsmac/pub.h
++++ b/drivers/net/wireless/brcm80211/brcmsmac/pub.h
+@@ -332,5 +332,9 @@ extern bool brcms_c_check_radio_disabled
+ extern void brcms_c_mute(struct brcms_c_info *wlc, bool on);
+ extern bool brcms_c_tx_flush_completed(struct brcms_c_info *wlc);
+ extern void brcms_c_start_station(struct brcms_c_info *wlc, u8 *addr);
++extern void brcms_c_update_beacon(struct brcms_c_info *wlc);
++extern void brcms_c_set_new_beacon(struct brcms_c_info *wlc,
++ struct sk_buff *beacon, u16 tim_offset,
++ u16 dtim_period);
+
+ #endif /* _BRCM_PUB_H_ */
diff --git a/package/mac80211/patches/870-brcmsmac-react-on-changing-SSID.patch b/package/mac80211/patches/870-brcmsmac-react-on-changing-SSID.patch
new file mode 100644
index 0000000..34969ad
--- /dev/null
+++ b/package/mac80211/patches/870-brcmsmac-react-on-changing-SSID.patch
@@ -0,0 +1,43 @@
+--- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
++++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
+@@ -523,6 +523,12 @@ brcms_ops_bss_info_changed(struct ieee80
+ brcms_c_set_addrmatch(wl->wlc, RCM_BSSID_OFFSET, info->bssid);
+ spin_unlock_bh(&wl->lock);
+ }
++ if (changed & BSS_CHANGED_SSID) {
++ /* BSSID changed, for whatever reason (IBSS and managed mode) */
++ spin_lock_bh(&wl->lock);
++ brcms_c_set_ssid(wl->wlc, info->ssid, info->ssid_len);
++ spin_unlock_bh(&wl->lock);
++ }
+ if (changed & BSS_CHANGED_BEACON) {
+ /* Beacon data changed, retrieve new beacon (beaconing modes) */
+ struct sk_buff *beacon;
+--- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
++++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
+@@ -3785,6 +3785,15 @@ static void brcms_c_set_bssid(struct brc
+ brcms_c_set_addrmatch(bsscfg->wlc, RCM_BSSID_OFFSET, bsscfg->BSSID);
+ }
+
++void brcms_c_set_ssid(struct brcms_c_info *wlc, u8 *ssid, size_t ssid_len)
++{
++ u8 len = min_t(u8, sizeof(wlc->bsscfg->SSID), ssid_len);
++ memset(wlc->bsscfg->SSID, 0, sizeof(wlc->bsscfg->SSID));
++
++ memcpy(wlc->bsscfg->SSID, ssid, len);
++ wlc->bsscfg->SSID_len = len;
++}
++
+ static void brcms_b_set_shortslot(struct brcms_hardware *wlc_hw, bool shortslot)
+ {
+ wlc_hw->shortslot = shortslot;
+--- a/drivers/net/wireless/brcm80211/brcmsmac/pub.h
++++ b/drivers/net/wireless/brcm80211/brcmsmac/pub.h
+@@ -336,5 +336,7 @@ extern void brcms_c_update_beacon(struct
+ extern void brcms_c_set_new_beacon(struct brcms_c_info *wlc,
+ struct sk_buff *beacon, u16 tim_offset,
+ u16 dtim_period);
++extern void brcms_c_set_ssid(struct brcms_c_info *wlc, u8 *ssid,
++ size_t ssid_len);
+
+ #endif /* _BRCM_PUB_H_ */
diff --git a/package/mac80211/patches/871-brcmsmac-add-support-for-probe-response-template.patch b/package/mac80211/patches/871-brcmsmac-add-support-for-probe-response-template.patch
new file mode 100644
index 0000000..5d022d2
--- /dev/null
+++ b/package/mac80211/patches/871-brcmsmac-add-support-for-probe-response-template.patch
@@ -0,0 +1,216 @@
+--- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
++++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
+@@ -541,6 +541,15 @@ brcms_ops_bss_info_changed(struct ieee80
+ spin_unlock_bh(&wl->lock);
+ }
+
++ if (changed & BSS_CHANGED_AP_PROBE_RESP) {
++ struct sk_buff *probe_resp;
++
++ spin_lock_bh(&wl->lock);
++ probe_resp = ieee80211_proberesp_get(hw, vif);
++ brcms_c_set_new_probe_resp(wl->wlc, probe_resp);
++ spin_unlock_bh(&wl->lock);
++ }
++
+ if (changed & BSS_CHANGED_BEACON_ENABLED) {
+ /* Beaconing should be enabled/disabled (beaconing modes) */
+ brcms_err(core, "%s: Beacon enabled: %s\n", __func__,
+@@ -1039,6 +1048,8 @@ static int ieee_hw_init(struct ieee80211
+ hw->channel_change_time = 7 * 1000;
+ hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION);
+
++ hw->wiphy->flags |= WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD;
++
+ hw->rate_control_algorithm = "minstrel_ht";
+
+ hw->sta_data_size = 0;
+--- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
++++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
+@@ -453,6 +453,8 @@ static void brcms_c_detach_mfree(struct
+ kfree(wlc->hw);
+ if (wlc->beacon)
+ dev_kfree_skb_any(wlc->beacon);
++ if (wlc->probe_resp)
++ dev_kfree_skb_any(wlc->probe_resp);
+
+ /* free the wlc */
+ kfree(wlc);
+@@ -7327,69 +7329,6 @@ brcms_c_mod_prb_rsp_rate_table(struct br
+ }
+ }
+
+-/* Max buffering needed for beacon template/prb resp template is 142 bytes.
+- *
+- * PLCP header is 6 bytes.
+- * 802.11 A3 header is 24 bytes.
+- * Max beacon frame body template length is 112 bytes.
+- * Max probe resp frame body template length is 110 bytes.
+- *
+- * *len on input contains the max length of the packet available.
+- *
+- * The *len value is set to the number of bytes in buf used, and starts
+- * with the PLCP and included up to, but not including, the 4 byte FCS.
+- */
+-static void
+-brcms_c_bcn_prb_template(struct brcms_c_info *wlc, u16 type,
+- u32 bcn_rspec,
+- struct brcms_bss_cfg *cfg, u16 *buf, int *len)
+-{
+- static const u8 ether_bcast[ETH_ALEN] = {255, 255, 255, 255, 255, 255};
+- struct cck_phy_hdr *plcp;
+- struct ieee80211_mgmt *h;
+- int hdr_len, body_len;
+-
+- hdr_len = D11_PHY_HDR_LEN + DOT11_MAC_HDR_LEN;
+-
+- /* calc buffer size provided for frame body */
+- body_len = *len - hdr_len;
+- /* return actual size */
+- *len = hdr_len + body_len;
+-
+- /* format PHY and MAC headers */
+- memset(buf, 0, hdr_len);
+-
+- plcp = (struct cck_phy_hdr *) buf;
+-
+- /*
+- * PLCP for Probe Response frames are filled in from
+- * core's rate table
+- */
+- if (type == IEEE80211_STYPE_BEACON)
+- /* fill in PLCP */
+- brcms_c_compute_plcp(wlc, bcn_rspec,
+- (DOT11_MAC_HDR_LEN + body_len + FCS_LEN),
+- (u8 *) plcp);
+-
+- /* "Regular" and 16 MBSS but not for 4 MBSS */
+- /* Update the phytxctl for the beacon based on the rspec */
+- brcms_c_beacon_phytxctl_txant_upd(wlc, bcn_rspec);
+-
+- h = (struct ieee80211_mgmt *)&plcp[1];
+-
+- /* fill in 802.11 header */
+- h->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | type);
+-
+- /* DUR is 0 for multicast bcn, or filled in by MAC for prb resp */
+- /* A1 filled in by MAC for prb resp, broadcast for bcn */
+- if (type == IEEE80211_STYPE_BEACON)
+- memcpy(&h->da, &ether_bcast, ETH_ALEN);
+- memcpy(&h->sa, &wlc->pub->cur_etheraddr, ETH_ALEN);
+- memcpy(&h->bssid, &cfg->BSSID, ETH_ALEN);
+-
+- /* SEQ filled in by MAC */
+-}
+-
+ int brcms_c_get_header_len(void)
+ {
+ return TXOFF;
+@@ -7530,6 +7469,20 @@ void brcms_c_set_new_beacon(struct brcms
+ brcms_c_update_beacon(wlc);
+ }
+
++void brcms_c_set_new_probe_resp(struct brcms_c_info *wlc,
++ struct sk_buff *probe_resp)
++{
++ if (!probe_resp)
++ return;
++ if (wlc->probe_resp)
++ dev_kfree_skb_any(wlc->probe_resp);
++ wlc->probe_resp = probe_resp;
++
++ /* add PLCP */
++ skb_push(wlc->probe_resp, D11_PHY_HDR_LEN);
++ brcms_c_update_probe_resp(wlc, false);
++}
++
+ /* Write ssid into shared memory */
+ static void
+ brcms_c_shm_ssid_upd(struct brcms_c_info *wlc, struct brcms_bss_cfg *cfg)
+@@ -7549,30 +7502,19 @@ brcms_c_shm_ssid_upd(struct brcms_c_info
+ static void
+ brcms_c_bss_update_probe_resp(struct brcms_c_info *wlc,
+ struct brcms_bss_cfg *cfg,
++ struct sk_buff *probe_resp,
+ bool suspend)
+ {
+- u16 *prb_resp;
+- int len = BCN_TMPL_LEN;
++ int len;
+
+- prb_resp = kmalloc(BCN_TMPL_LEN, GFP_ATOMIC);
+- if (!prb_resp)
+- return;
+-
+- /*
+- * write the probe response to hardware, or save in
+- * the config structure
+- */
+-
+- /* create the probe response template */
+- brcms_c_bcn_prb_template(wlc, IEEE80211_STYPE_PROBE_RESP, 0,
+- cfg, prb_resp, &len);
++ len = min_t(size_t, probe_resp->len, BCN_TMPL_LEN);
+
+ if (suspend)
+ brcms_c_suspend_mac_and_wait(wlc);
+
+ /* write the probe response into the template region */
+ brcms_b_write_template_ram(wlc->hw, T_PRS_TPL_BASE,
+- (len + 3) & ~3, prb_resp);
++ (len + 3) & ~3, probe_resp->data);
+
+ /* write the length of the probe response frame (+PLCP/-FCS) */
+ brcms_b_write_shm(wlc->hw, M_PRB_RESP_FRM_LEN, (u16) len);
+@@ -7586,13 +7528,11 @@ brcms_c_bss_update_probe_resp(struct brc
+ * PLCP header for the call to brcms_c_mod_prb_rsp_rate_table()
+ * by subtracting the PLCP len and adding the FCS.
+ */
+- len += (-D11_PHY_HDR_LEN + FCS_LEN);
+- brcms_c_mod_prb_rsp_rate_table(wlc, (u16) len);
++ brcms_c_mod_prb_rsp_rate_table(wlc,
++ (u16)len + FCS_LEN - D11_PHY_HDR_LEN);
+
+ if (suspend)
+ brcms_c_enable_mac(wlc);
+-
+- kfree(prb_resp);
+ }
+
+ void brcms_c_update_probe_resp(struct brcms_c_info *wlc, bool suspend)
+@@ -7600,8 +7540,12 @@ void brcms_c_update_probe_resp(struct br
+ struct brcms_bss_cfg *bsscfg = wlc->bsscfg;
+
+ /* update AP or IBSS probe responses */
+- if (wlc->pub->up && bsscfg->type == BRCMS_TYPE_AP)
+- brcms_c_bss_update_probe_resp(wlc, bsscfg, suspend);
++ if (wlc->pub->up && bsscfg->type == BRCMS_TYPE_AP) {
++ if (!wlc->probe_resp)
++ return;
++ brcms_c_bss_update_probe_resp(wlc, bsscfg, wlc->probe_resp,
++ suspend);
++ }
+ }
+
+ int brcms_b_xmtfifo_sz_get(struct brcms_hardware *wlc_hw, uint fifo,
+--- a/drivers/net/wireless/brcm80211/brcmsmac/main.h
++++ b/drivers/net/wireless/brcm80211/brcmsmac/main.h
+@@ -567,6 +567,7 @@ struct brcms_c_info {
+ struct sk_buff *beacon;
+ u16 beacon_tim_offset;
+ u16 beacon_dtim_period;
++ struct sk_buff *probe_resp;
+ };
+
+ /* antsel module specific state */
+--- a/drivers/net/wireless/brcm80211/brcmsmac/pub.h
++++ b/drivers/net/wireless/brcm80211/brcmsmac/pub.h
+@@ -336,6 +336,8 @@ extern void brcms_c_update_beacon(struct
+ extern void brcms_c_set_new_beacon(struct brcms_c_info *wlc,
+ struct sk_buff *beacon, u16 tim_offset,
+ u16 dtim_period);
++extern void brcms_c_set_new_probe_resp(struct brcms_c_info *wlc,
++ struct sk_buff *probe_resp);
+ extern void brcms_c_set_ssid(struct brcms_c_info *wlc, u8 *ssid,
+ size_t ssid_len);
+
diff --git a/package/mac80211/patches/872-brcmsmac-activate-AP-support.patch b/package/mac80211/patches/872-brcmsmac-activate-AP-support.patch
new file mode 100644
index 0000000..aaf6840
--- /dev/null
+++ b/package/mac80211/patches/872-brcmsmac-activate-AP-support.patch
@@ -0,0 +1,74 @@
+--- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
++++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
+@@ -360,7 +360,8 @@ brcms_ops_add_interface(struct ieee80211
+ struct brcms_info *wl = hw->priv;
+
+ /* Just STA for now */
+- if (vif->type != NL80211_IFTYPE_STATION) {
++ if (vif->type != NL80211_IFTYPE_STATION &&
++ vif->type != NL80211_IFTYPE_AP) {
+ brcms_err(wl->wlc->hw->d11core,
+ "%s: Attempt to add type %d, only STA for now\n",
+ __func__, vif->type);
+@@ -372,6 +373,9 @@ brcms_ops_add_interface(struct ieee80211
+ brcms_c_mute(wl->wlc, false);
+ if (vif->type == NL80211_IFTYPE_STATION)
+ brcms_c_start_station(wl->wlc, vif->addr);
++ else if (vif->type == NL80211_IFTYPE_AP)
++ brcms_c_start_ap(wl->wlc, vif->addr, vif->bss_conf.bssid,
++ vif->bss_conf.ssid, vif->bss_conf.ssid_len);
+ spin_unlock_bh(&wl->lock);
+
+ return 0;
+@@ -1046,7 +1050,8 @@ static int ieee_hw_init(struct ieee80211
+
+ /* channel change time is dependent on chip and band */
+ hw->channel_change_time = 7 * 1000;
+- hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION);
++ hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
++ BIT(NL80211_IFTYPE_AP);
+
+ hw->wiphy->flags |= WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD;
+
+--- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
++++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
+@@ -2176,6 +2176,18 @@ void brcms_c_start_station(struct brcms_
+ wlc->bsscfg->type = BRCMS_TYPE_STATION;
+ }
+
++void brcms_c_start_ap(struct brcms_c_info *wlc, u8 *addr, const u8 *bssid,
++ u8 *ssid, size_t ssid_len)
++{
++ brcms_c_set_ssid(wlc, ssid, ssid_len);
++
++ memcpy(wlc->pub->cur_etheraddr, addr, sizeof(wlc->pub->cur_etheraddr));
++ memcpy(wlc->bsscfg->BSSID, bssid, sizeof(wlc->bsscfg->BSSID));
++ wlc->bsscfg->type = BRCMS_TYPE_AP;
++
++ brcms_b_mctrl(wlc->hw, MCTL_AP | MCTL_INFRA, MCTL_AP | MCTL_INFRA);
++}
++
+ /* Initialize GPIOs that are controlled by D11 core */
+ static void brcms_c_gpio_init(struct brcms_c_info *wlc)
+ {
+@@ -3064,6 +3076,9 @@ static bool brcms_c_ps_allowed(struct br
+ if (wlc->filter_flags & FIF_PROMISC_IN_BSS)
+ return false;
+
++ if (wlc->bsscfg->type == BRCMS_TYPE_AP)
++ return false;
++
+ return true;
+ }
+
+--- a/drivers/net/wireless/brcm80211/brcmsmac/pub.h
++++ b/drivers/net/wireless/brcm80211/brcmsmac/pub.h
+@@ -332,6 +332,8 @@ extern bool brcms_c_check_radio_disabled
+ extern void brcms_c_mute(struct brcms_c_info *wlc, bool on);
+ extern bool brcms_c_tx_flush_completed(struct brcms_c_info *wlc);
+ extern void brcms_c_start_station(struct brcms_c_info *wlc, u8 *addr);
++extern void brcms_c_start_ap(struct brcms_c_info *wlc, u8 *addr,
++ const u8 *bssid, u8 *ssid, size_t ssid_len);
+ extern void brcms_c_update_beacon(struct brcms_c_info *wlc);
+ extern void brcms_c_set_new_beacon(struct brcms_c_info *wlc,
+ struct sk_buff *beacon, u16 tim_offset,
diff --git a/package/mac80211/patches/873-brcmsmac-remove-extra-regulation-restriction.patch b/package/mac80211/patches/873-brcmsmac-remove-extra-regulation-restriction.patch
new file mode 100644
index 0000000..dd1393a
--- /dev/null
+++ b/package/mac80211/patches/873-brcmsmac-remove-extra-regulation-restriction.patch
@@ -0,0 +1,31 @@
+--- a/drivers/net/wireless/brcm80211/brcmsmac/channel.c
++++ b/drivers/net/wireless/brcm80211/brcmsmac/channel.c
+@@ -59,23 +59,16 @@
+
+ #define BRCM_2GHZ_2412_2462 REG_RULE(2412-10, 2462+10, 40, 0, 19, 0)
+ #define BRCM_2GHZ_2467_2472 REG_RULE(2467-10, 2472+10, 20, 0, 19, \
+- NL80211_RRF_PASSIVE_SCAN | \
+- NL80211_RRF_NO_IBSS)
++ 0)
+
+ #define BRCM_5GHZ_5180_5240 REG_RULE(5180-10, 5240+10, 40, 0, 21, \
+- NL80211_RRF_PASSIVE_SCAN | \
+- NL80211_RRF_NO_IBSS)
++ 0)
+ #define BRCM_5GHZ_5260_5320 REG_RULE(5260-10, 5320+10, 40, 0, 21, \
+- NL80211_RRF_PASSIVE_SCAN | \
+- NL80211_RRF_DFS | \
+- NL80211_RRF_NO_IBSS)
++ 0)
+ #define BRCM_5GHZ_5500_5700 REG_RULE(5500-10, 5700+10, 40, 0, 21, \
+- NL80211_RRF_PASSIVE_SCAN | \
+- NL80211_RRF_DFS | \
+- NL80211_RRF_NO_IBSS)
++ 0)
+ #define BRCM_5GHZ_5745_5825 REG_RULE(5745-10, 5825+10, 40, 0, 21, \
+- NL80211_RRF_PASSIVE_SCAN | \
+- NL80211_RRF_NO_IBSS)
++ 0)
+
+ static const struct ieee80211_regdomain brcms_regdom_x2 = {
+ .n_reg_rules = 6,
diff --git a/package/mkelfimage/.svn/entries b/package/mkelfimage/.svn/entries
new file mode 100644
index 0000000..7ae0900
--- /dev/null
+++ b/package/mkelfimage/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/mkelfimage
+svn://svn.openwrt.org/openwrt
+
+
+
+2011-07-02T06:49:36.282771Z
+27345
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+c616b4607f64b70e74561accee853ed3
+2011-07-02T06:49:36.282771Z
+27345
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+873
+
diff --git a/package/mkelfimage/.svn/text-base/Makefile.svn-base b/package/mkelfimage/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..2433c72
--- /dev/null
+++ b/package/mkelfimage/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,35 @@
+#
+# Copyright (C) 2006 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=mkelfimage
+PKG_VERSION:=2.7
+
+PKG_SOURCE:=$(PKG_NAME)_$(PKG_VERSION).orig.tar.gz
+PKG_SOURCE_URL:=http://ftp.debian.org/debian/pool/main/m/mkelfimage/
+PKG_MD5SUM:=e505cb87e9c0cdc44cf03d2c4ea8c74b
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/mkelfimage
+ SECTION:=base
+ CATEGORY:=Base system
+ TITLE:=mkelfimage
+ HIDDEN:=1
+ DEPENDS:=@i386
+ DEFAULT:=y if TARGET_x86
+endef
+
+CONFIGURE_VARS += AS="$(TARGET_CROSS)as"
+MAKE_FLAGS += HOST_CC="$(HOSTCC)" DEFS="-I$(STAGING_DIR_HOST)/include"
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(STAGING_DIR_HOST)/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/objdir/sbin/mkelfImage $(STAGING_DIR_HOST)/bin
+endef
+
+$(eval $(call BuildPackage,mkelfimage))
diff --git a/package/mkelfimage/Makefile b/package/mkelfimage/Makefile
new file mode 100644
index 0000000..2433c72
--- /dev/null
+++ b/package/mkelfimage/Makefile
@@ -0,0 +1,35 @@
+#
+# Copyright (C) 2006 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=mkelfimage
+PKG_VERSION:=2.7
+
+PKG_SOURCE:=$(PKG_NAME)_$(PKG_VERSION).orig.tar.gz
+PKG_SOURCE_URL:=http://ftp.debian.org/debian/pool/main/m/mkelfimage/
+PKG_MD5SUM:=e505cb87e9c0cdc44cf03d2c4ea8c74b
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/mkelfimage
+ SECTION:=base
+ CATEGORY:=Base system
+ TITLE:=mkelfimage
+ HIDDEN:=1
+ DEPENDS:=@i386
+ DEFAULT:=y if TARGET_x86
+endef
+
+CONFIGURE_VARS += AS="$(TARGET_CROSS)as"
+MAKE_FLAGS += HOST_CC="$(HOSTCC)" DEFS="-I$(STAGING_DIR_HOST)/include"
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(STAGING_DIR_HOST)/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/objdir/sbin/mkelfImage $(STAGING_DIR_HOST)/bin
+endef
+
+$(eval $(call BuildPackage,mkelfimage))
diff --git a/package/mkelfimage/patches/.svn/entries b/package/mkelfimage/patches/.svn/entries
new file mode 100644
index 0000000..5376c56
--- /dev/null
+++ b/package/mkelfimage/patches/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/mkelfimage/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2011-07-02T06:49:36.282771Z
+27345
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+no-stack-protector.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+c959818791027985a028341e1fb0faee
+2011-07-02T06:49:36.282771Z
+27345
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+535
+
diff --git a/package/mkelfimage/patches/.svn/text-base/no-stack-protector.patch.svn-base b/package/mkelfimage/patches/.svn/text-base/no-stack-protector.patch.svn-base
new file mode 100644
index 0000000..108583a
--- /dev/null
+++ b/package/mkelfimage/patches/.svn/text-base/no-stack-protector.patch.svn-base
@@ -0,0 +1,11 @@
+--- mkelfimage-2.7.old//Makefile 2006-03-28 02:44:59.000000000 +0300
++++ mkelfimage-2.7/Makefile 2011-01-17 14:15:13.000000000 +0200
+@@ -14,7 +14,7 @@
+ pkglibdir = $(libdir)/$(PACKAGE)
+ pkgincludedir = $(includedir)/$(PACKAGE)
+
+-CPPFLAGS=-DVERSION='"$(VERSION)"' -DRELEASE_DATE='"$(RELEASE_DATE)"' -I include
++CPPFLAGS=-DVERSION='"$(VERSION)"' -DRELEASE_DATE='"$(RELEASE_DATE)"' -I include -fno-stack-protector
+ HOST_CPPFLAGS=$(CPPFLAGS)
+ I386_CPPFLAGS=$(CPPFLAGS) -I arch/i386/include
+ IA64_CPPFLAGS=$(CPPFLAGS) -I arch/ia64/include
diff --git a/package/mkelfimage/patches/no-stack-protector.patch b/package/mkelfimage/patches/no-stack-protector.patch
new file mode 100644
index 0000000..108583a
--- /dev/null
+++ b/package/mkelfimage/patches/no-stack-protector.patch
@@ -0,0 +1,11 @@
+--- mkelfimage-2.7.old//Makefile 2006-03-28 02:44:59.000000000 +0300
++++ mkelfimage-2.7/Makefile 2011-01-17 14:15:13.000000000 +0200
+@@ -14,7 +14,7 @@
+ pkglibdir = $(libdir)/$(PACKAGE)
+ pkgincludedir = $(includedir)/$(PACKAGE)
+
+-CPPFLAGS=-DVERSION='"$(VERSION)"' -DRELEASE_DATE='"$(RELEASE_DATE)"' -I include
++CPPFLAGS=-DVERSION='"$(VERSION)"' -DRELEASE_DATE='"$(RELEASE_DATE)"' -I include -fno-stack-protector
+ HOST_CPPFLAGS=$(CPPFLAGS)
+ I386_CPPFLAGS=$(CPPFLAGS) -I arch/i386/include
+ IA64_CPPFLAGS=$(CPPFLAGS) -I arch/ia64/include
diff --git a/package/mountd/.svn/entries b/package/mountd/.svn/entries
new file mode 100644
index 0000000..f079331
--- /dev/null
+++ b/package/mountd/.svn/entries
@@ -0,0 +1,68 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/mountd
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-11T10:05:23.920888Z
+33724
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+files
+dir
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+1312e0563285ffe46c4858c3d2f13b73
+2012-10-11T10:05:23.920888Z
+33724
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1193
+
diff --git a/package/mountd/.svn/text-base/Makefile.svn-base b/package/mountd/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..10534cc
--- /dev/null
+++ b/package/mountd/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,47 @@
+# Copyright (C) 2009-2012 OpenWrt.org
+# All rights reserved.
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=mountd
+PKG_VERSION:=0.1
+PKG_RELEASE:=6
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=http://mirror2.openwrt.org/sources
+PKG_MD5SUM:=b77253ee4321d24d200fffc4f7ca3d15
+PKG_MAINTAINER:=John Crispin <blogic@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/mountd
+ SECTION:=utils
+ CATEGORY:=Utilities
+ TITLE:=OpenWrt automount daemon
+ DEPENDS:=@USB_SUPPORT +uci +kmod-usb-storage +kmod-fs-autofs4
+ URL:=http://www.openwrt.org
+endef
+
+define Package/mountd/description
+ openwrt automount daemon
+endef
+
+define Package/mountd/conffiles
+/etc/config/mountd
+endef
+
+define Build/Compile
+ $(TARGET_CONFIGURE_OPTS) \
+ CFLAGS="$(TARGET_CFLAGS) -I$(STAGING_DIR)/usr/include -I$(PKG_BUILD_DIR)" \
+ LDFLAGS="$(TARGET_LDFLAGS)" \
+ $(MAKE) -C $(PKG_BUILD_DIR)
+endef
+
+define Package/mountd/install
+ $(INSTALL_DIR) $(1)/sbin/ $(1)/etc/config/ $(1)/etc/init.d/
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/mountd $(1)/sbin/
+ $(INSTALL_DATA) ./files/mountd.config $(1)/etc/config/mountd
+ $(INSTALL_BIN) ./files/mountd.init $(1)/etc/init.d/mountd
+endef
+
+$(eval $(call BuildPackage,mountd))
diff --git a/package/mountd/Makefile b/package/mountd/Makefile
new file mode 100644
index 0000000..10534cc
--- /dev/null
+++ b/package/mountd/Makefile
@@ -0,0 +1,47 @@
+# Copyright (C) 2009-2012 OpenWrt.org
+# All rights reserved.
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=mountd
+PKG_VERSION:=0.1
+PKG_RELEASE:=6
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=http://mirror2.openwrt.org/sources
+PKG_MD5SUM:=b77253ee4321d24d200fffc4f7ca3d15
+PKG_MAINTAINER:=John Crispin <blogic@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/mountd
+ SECTION:=utils
+ CATEGORY:=Utilities
+ TITLE:=OpenWrt automount daemon
+ DEPENDS:=@USB_SUPPORT +uci +kmod-usb-storage +kmod-fs-autofs4
+ URL:=http://www.openwrt.org
+endef
+
+define Package/mountd/description
+ openwrt automount daemon
+endef
+
+define Package/mountd/conffiles
+/etc/config/mountd
+endef
+
+define Build/Compile
+ $(TARGET_CONFIGURE_OPTS) \
+ CFLAGS="$(TARGET_CFLAGS) -I$(STAGING_DIR)/usr/include -I$(PKG_BUILD_DIR)" \
+ LDFLAGS="$(TARGET_LDFLAGS)" \
+ $(MAKE) -C $(PKG_BUILD_DIR)
+endef
+
+define Package/mountd/install
+ $(INSTALL_DIR) $(1)/sbin/ $(1)/etc/config/ $(1)/etc/init.d/
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/mountd $(1)/sbin/
+ $(INSTALL_DATA) ./files/mountd.config $(1)/etc/config/mountd
+ $(INSTALL_BIN) ./files/mountd.init $(1)/etc/init.d/mountd
+endef
+
+$(eval $(call BuildPackage,mountd))
diff --git a/package/mountd/files/.svn/entries b/package/mountd/files/.svn/entries
new file mode 100644
index 0000000..2260461
--- /dev/null
+++ b/package/mountd/files/.svn/entries
@@ -0,0 +1,96 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/mountd/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-09-12T10:09:55.847588Z
+33378
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+mountd.init
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+b2ea766f63da47c057a7edcb1f9a9d9c
+2012-09-12T10:09:55.847588Z
+33378
+jow
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+219
+
+mountd.config
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+677b44ad985d4ad28d0571ab2c0a45d3
+2009-10-04T14:01:17.853916Z
+17853
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+68
+
diff --git a/package/mountd/files/.svn/prop-base/mountd.init.svn-base b/package/mountd/files/.svn/prop-base/mountd.init.svn-base
new file mode 100644
index 0000000..869ac71
--- /dev/null
+++ b/package/mountd/files/.svn/prop-base/mountd.init.svn-base
@@ -0,0 +1,5 @@
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/mountd/files/.svn/text-base/mountd.config.svn-base b/package/mountd/files/.svn/text-base/mountd.config.svn-base
new file mode 100644
index 0000000..5610129
--- /dev/null
+++ b/package/mountd/files/.svn/text-base/mountd.config.svn-base
@@ -0,0 +1,3 @@
+config mountd mountd
+ option timeout 60
+ option path /tmp/mounts/
diff --git a/package/mountd/files/.svn/text-base/mountd.init.svn-base b/package/mountd/files/.svn/text-base/mountd.init.svn-base
new file mode 100644
index 0000000..c294c50
--- /dev/null
+++ b/package/mountd/files/.svn/text-base/mountd.init.svn-base
@@ -0,0 +1,19 @@
+#!/bin/sh /etc/rc.common
+
+START=80
+
+SERVICE_DAEMONIZE=1
+SERVICE_WRITE_PID=1
+SERVICE_PID_FILE=/var/run/mountd.pid
+
+MOUNTD_BIN=/sbin/mountd
+
+start()
+{
+ service_start $MOUNTD_BIN -f
+}
+
+stop()
+{
+ service_stop $MOUNTD_BIN
+}
diff --git a/package/mountd/files/mountd.config b/package/mountd/files/mountd.config
new file mode 100644
index 0000000..5610129
--- /dev/null
+++ b/package/mountd/files/mountd.config
@@ -0,0 +1,3 @@
+config mountd mountd
+ option timeout 60
+ option path /tmp/mounts/
diff --git a/package/mountd/files/mountd.init b/package/mountd/files/mountd.init
new file mode 100755
index 0000000..c294c50
--- /dev/null
+++ b/package/mountd/files/mountd.init
@@ -0,0 +1,19 @@
+#!/bin/sh /etc/rc.common
+
+START=80
+
+SERVICE_DAEMONIZE=1
+SERVICE_WRITE_PID=1
+SERVICE_PID_FILE=/var/run/mountd.pid
+
+MOUNTD_BIN=/sbin/mountd
+
+start()
+{
+ service_start $MOUNTD_BIN -f
+}
+
+stop()
+{
+ service_stop $MOUNTD_BIN
+}
diff --git a/package/mountd/patches/.svn/entries b/package/mountd/patches/.svn/entries
new file mode 100644
index 0000000..1bc25f8
--- /dev/null
+++ b/package/mountd/patches/.svn/entries
@@ -0,0 +1,164 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/mountd/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-09-12T10:09:55.847588Z
+33378
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+010-uci_rename_history_to_delta.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+45da859fd46cd1541f01cd8fd7573a22
+2010-10-16T13:57:55.131669Z
+23474
+acinonyx
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+894
+
+040-optional-daemonize.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+8edae5d151755b440ec24657ec7c19bb
+2012-09-12T10:09:55.847588Z
+33378
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+243
+
+020-handle_timeout.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+05e9fc2ef4911a3ffcb039f7034b4f2b
+2011-07-17T11:58:05.253374Z
+27635
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+652
+
+030-ext4_support.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+08253711a8a2560e6ff3e31f02e5135b
+2012-07-24T20:38:26.222821Z
+32818
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2656
+
diff --git a/package/mountd/patches/.svn/text-base/010-uci_rename_history_to_delta.patch.svn-base b/package/mountd/patches/.svn/text-base/010-uci_rename_history_to_delta.patch.svn-base
new file mode 100644
index 0000000..65b2f84
--- /dev/null
+++ b/package/mountd/patches/.svn/text-base/010-uci_rename_history_to_delta.patch.svn-base
@@ -0,0 +1,27 @@
+---
+ lib/uci.c | 2 +-
+ lib/ucix.c | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+--- a/lib/uci.c
++++ b/lib/uci.c
+@@ -28,7 +28,7 @@ struct uci_package *p = NULL;
+ struct uci_context* uci_init(char *config_file)
+ {
+ struct uci_context *ctx = uci_alloc_context();
+- uci_add_history_path(ctx, "/var/state");
++ uci_add_delta_path(ctx, "/var/state");
+ if(uci_load(ctx, config_file, &p) != UCI_OK)
+ {
+ log_printf("/etc/config/%s is missing or corrupt\n", config_file);
+--- a/lib/ucix.c
++++ b/lib/ucix.c
+@@ -18,7 +18,7 @@ static inline int ucix_get_ptr(struct uc
+ struct uci_context* ucix_init(const char *config_file)
+ {
+ struct uci_context *ctx = uci_alloc_context();
+- uci_add_history_path(ctx, "/var/state");
++ uci_add_delta_path(ctx, "/var/state");
+ if(uci_load(ctx, config_file, NULL) != UCI_OK)
+ {
+ printf("%s/%s is missing or corrupt\n", ctx->savedir, config_file);
diff --git a/package/mountd/patches/.svn/text-base/020-handle_timeout.patch.svn-base b/package/mountd/patches/.svn/text-base/020-handle_timeout.patch.svn-base
new file mode 100644
index 0000000..badf40f
--- /dev/null
+++ b/package/mountd/patches/.svn/text-base/020-handle_timeout.patch.svn-base
@@ -0,0 +1,32 @@
+--- a/lib/autofs.c
++++ b/lib/autofs.c
+@@ -140,6 +140,7 @@ static int fullread(void *ptr, size_t le
+
+ static int autofs_in(union autofs_v5_packet_union *pkt)
+ {
++ int res;
+ struct pollfd fds[1];
+
+ fds[0].fd = fdout;
+@@ -147,15 +148,19 @@ static int autofs_in(union autofs_v5_pac
+
+ while(1)
+ {
+- if(poll(fds, 2, 1000) == -1)
++ res = poll(fds, 1, -1);
++
++ if (res == -1)
+ {
+ if (errno == EINTR)
+ continue;
+ log_printf("failed while trying to read packet from kernel\n");
+ return -1;
+ }
+- if(fds[0].revents & POLLIN)
++ else if ((res > 0) && (fds[0].revents & POLLIN))
++ {
+ return fullread(pkt, sizeof(*pkt));
++ }
+ }
+ }
+
diff --git a/package/mountd/patches/.svn/text-base/030-ext4_support.patch.svn-base b/package/mountd/patches/.svn/text-base/030-ext4_support.patch.svn-base
new file mode 100644
index 0000000..7bbaf14
--- /dev/null
+++ b/package/mountd/patches/.svn/text-base/030-ext4_support.patch.svn-base
@@ -0,0 +1,85 @@
+diff -ruN mountd-0.1.orig/include/fs.h mountd-0.1/include/fs.h
+--- mountd-0.1.orig/include/fs.h 2009-10-02 22:57:04.000000000 +0200
++++ mountd-0.1/include/fs.h 2012-07-08 18:42:32.000000000 +0200
+@@ -7,5 +7,6 @@
+ #define EFI 7
+ #define NTFS 8
+ #define EXTENDED 9
++#define EXT4 10
+
+ int detect_fs(char *device);
+diff -ruN mountd-0.1.orig/lib/fs.c mountd-0.1/lib/fs.c
+--- mountd-0.1.orig/lib/fs.c 2009-10-02 23:26:22.000000000 +0200
++++ mountd-0.1/lib/fs.c 2012-07-08 19:28:08.000000000 +0200
+@@ -91,9 +91,14 @@
+ goto out;
+ if(get_le_short(buffer + 56) == 0xEF53)
+ {
+- if((get_le_long(buffer + 96) & 0x0008)
+- || (get_le_long(buffer + 92) & 0x0004))
+- ret = EXT3;
++ if(get_le_long(buffer + 92) & 0x0004)
++ {
++ if ((get_le_long(buffer + 96) < 0x0000040)
++ && (get_le_long(buffer + 100) < 0x0000008))
++ ret = EXT3;
++ else
++ ret = EXT4;
++ }
+ else
+ ret = EXT2;
+ }
+diff -ruN mountd-0.1.orig/lib/mount.c mountd-0.1/lib/mount.c
+--- mountd-0.1.orig/lib/mount.c 2009-10-03 12:54:57.000000000 +0200
++++ mountd-0.1/lib/mount.c 2012-07-08 19:04:29.000000000 +0200
+@@ -53,7 +53,10 @@
+ "EXT3",
+ "FAT",
+ "HFSPLUS",
+- "NTFS"
++ "",
++ "NTFS",
++ "",
++ "EXT4"
+ };
+
+ #define MAX_MOUNTED 32
+@@ -93,7 +96,7 @@
+ ucix_add_option(ctx, mountd, q->serial, "rev", q->rev);
+ snprintf(t, 64, "size%d", atoi(&q->dev[3]));
+ ucix_add_option(ctx, mountd, q->serial, t, q->size);
+- if(q->fs > MBR && q->fs <= NTFS)
++ if(q->fs > MBR && q->fs <= EXT4)
+ {
+ snprintf(t, 64, "fs%d", atoi(&q->dev[3]));
+ ucix_add_option(ctx, mountd, q->serial, t, fs_names[q->fs]);
+@@ -131,7 +134,7 @@
+ {
+ struct mount *mount;
+ char tmp[64], tmp2[64];
+- if(fs <= MBR || fs > NTFS)
++ if(fs <= MBR || fs > EXT4)
+ return;
+ mount = malloc(sizeof(struct mount));
+ INIT_LIST_HEAD(&mount->list);
+@@ -147,7 +150,7 @@
+ mount->mounted = 0;
+ mount->fs = fs;
+ list_add(&mount->list, &mounts);
+- if((!mount->ignore) && (mount->fs > MBR) && (mount->fs <= NTFS))
++ if((!mount->ignore) && (mount->fs > MBR) && (mount->fs <= EXT4))
+ {
+ log_printf("new mount : %s -> %s (%s)\n", name, dev, fs_names[mount->fs]);
+ snprintf(tmp, 64, "%s%s", uci_path, name);
+@@ -226,6 +229,11 @@
+ log_printf("mount -t vfat -o rw,uid=1000,gid=1000 /dev/%s %s", mount->dev, tmp);
+ ret = system_printf("mount -t vfat -o rw,uid=1000,gid=1000 /dev/%s %s", mount->dev, tmp);
+ }
++ if(mount->fs == EXT4)
++ {
++ log_printf("mount -t ext4 -o rw,defaults /dev/%s %s", mount->dev, tmp);
++ ret = system_printf("mount -t ext4 -o rw,defaults /dev/%s %s", mount->dev, tmp);
++ }
+ if(mount->fs == EXT3)
+ {
+ log_printf("mount -t ext3 -o rw,defaults /dev/%s %s", mount->dev, tmp);
diff --git a/package/mountd/patches/.svn/text-base/040-optional-daemonize.patch.svn-base b/package/mountd/patches/.svn/text-base/040-optional-daemonize.patch.svn-base
new file mode 100644
index 0000000..4d159ec
--- /dev/null
+++ b/package/mountd/patches/.svn/text-base/040-optional-daemonize.patch.svn-base
@@ -0,0 +1,13 @@
+--- a/main.c
++++ b/main.c
+@@ -13,7 +13,9 @@
+
+ int main(int argc, char *argv[])
+ {
+- daemon(0,0);
++ if ((argc < 2) || strcmp(argv[1], "-f"))
++ daemon(0,0);
++
+ daemonize = 1;
+ log_start();
+ log_printf("Starting OpenWrt (auto)mountd V1\n");
diff --git a/package/mountd/patches/010-uci_rename_history_to_delta.patch b/package/mountd/patches/010-uci_rename_history_to_delta.patch
new file mode 100644
index 0000000..65b2f84
--- /dev/null
+++ b/package/mountd/patches/010-uci_rename_history_to_delta.patch
@@ -0,0 +1,27 @@
+---
+ lib/uci.c | 2 +-
+ lib/ucix.c | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+--- a/lib/uci.c
++++ b/lib/uci.c
+@@ -28,7 +28,7 @@ struct uci_package *p = NULL;
+ struct uci_context* uci_init(char *config_file)
+ {
+ struct uci_context *ctx = uci_alloc_context();
+- uci_add_history_path(ctx, "/var/state");
++ uci_add_delta_path(ctx, "/var/state");
+ if(uci_load(ctx, config_file, &p) != UCI_OK)
+ {
+ log_printf("/etc/config/%s is missing or corrupt\n", config_file);
+--- a/lib/ucix.c
++++ b/lib/ucix.c
+@@ -18,7 +18,7 @@ static inline int ucix_get_ptr(struct uc
+ struct uci_context* ucix_init(const char *config_file)
+ {
+ struct uci_context *ctx = uci_alloc_context();
+- uci_add_history_path(ctx, "/var/state");
++ uci_add_delta_path(ctx, "/var/state");
+ if(uci_load(ctx, config_file, NULL) != UCI_OK)
+ {
+ printf("%s/%s is missing or corrupt\n", ctx->savedir, config_file);
diff --git a/package/mountd/patches/020-handle_timeout.patch b/package/mountd/patches/020-handle_timeout.patch
new file mode 100644
index 0000000..badf40f
--- /dev/null
+++ b/package/mountd/patches/020-handle_timeout.patch
@@ -0,0 +1,32 @@
+--- a/lib/autofs.c
++++ b/lib/autofs.c
+@@ -140,6 +140,7 @@ static int fullread(void *ptr, size_t le
+
+ static int autofs_in(union autofs_v5_packet_union *pkt)
+ {
++ int res;
+ struct pollfd fds[1];
+
+ fds[0].fd = fdout;
+@@ -147,15 +148,19 @@ static int autofs_in(union autofs_v5_pac
+
+ while(1)
+ {
+- if(poll(fds, 2, 1000) == -1)
++ res = poll(fds, 1, -1);
++
++ if (res == -1)
+ {
+ if (errno == EINTR)
+ continue;
+ log_printf("failed while trying to read packet from kernel\n");
+ return -1;
+ }
+- if(fds[0].revents & POLLIN)
++ else if ((res > 0) && (fds[0].revents & POLLIN))
++ {
+ return fullread(pkt, sizeof(*pkt));
++ }
+ }
+ }
+
diff --git a/package/mountd/patches/030-ext4_support.patch b/package/mountd/patches/030-ext4_support.patch
new file mode 100644
index 0000000..7bbaf14
--- /dev/null
+++ b/package/mountd/patches/030-ext4_support.patch
@@ -0,0 +1,85 @@
+diff -ruN mountd-0.1.orig/include/fs.h mountd-0.1/include/fs.h
+--- mountd-0.1.orig/include/fs.h 2009-10-02 22:57:04.000000000 +0200
++++ mountd-0.1/include/fs.h 2012-07-08 18:42:32.000000000 +0200
+@@ -7,5 +7,6 @@
+ #define EFI 7
+ #define NTFS 8
+ #define EXTENDED 9
++#define EXT4 10
+
+ int detect_fs(char *device);
+diff -ruN mountd-0.1.orig/lib/fs.c mountd-0.1/lib/fs.c
+--- mountd-0.1.orig/lib/fs.c 2009-10-02 23:26:22.000000000 +0200
++++ mountd-0.1/lib/fs.c 2012-07-08 19:28:08.000000000 +0200
+@@ -91,9 +91,14 @@
+ goto out;
+ if(get_le_short(buffer + 56) == 0xEF53)
+ {
+- if((get_le_long(buffer + 96) & 0x0008)
+- || (get_le_long(buffer + 92) & 0x0004))
+- ret = EXT3;
++ if(get_le_long(buffer + 92) & 0x0004)
++ {
++ if ((get_le_long(buffer + 96) < 0x0000040)
++ && (get_le_long(buffer + 100) < 0x0000008))
++ ret = EXT3;
++ else
++ ret = EXT4;
++ }
+ else
+ ret = EXT2;
+ }
+diff -ruN mountd-0.1.orig/lib/mount.c mountd-0.1/lib/mount.c
+--- mountd-0.1.orig/lib/mount.c 2009-10-03 12:54:57.000000000 +0200
++++ mountd-0.1/lib/mount.c 2012-07-08 19:04:29.000000000 +0200
+@@ -53,7 +53,10 @@
+ "EXT3",
+ "FAT",
+ "HFSPLUS",
+- "NTFS"
++ "",
++ "NTFS",
++ "",
++ "EXT4"
+ };
+
+ #define MAX_MOUNTED 32
+@@ -93,7 +96,7 @@
+ ucix_add_option(ctx, mountd, q->serial, "rev", q->rev);
+ snprintf(t, 64, "size%d", atoi(&q->dev[3]));
+ ucix_add_option(ctx, mountd, q->serial, t, q->size);
+- if(q->fs > MBR && q->fs <= NTFS)
++ if(q->fs > MBR && q->fs <= EXT4)
+ {
+ snprintf(t, 64, "fs%d", atoi(&q->dev[3]));
+ ucix_add_option(ctx, mountd, q->serial, t, fs_names[q->fs]);
+@@ -131,7 +134,7 @@
+ {
+ struct mount *mount;
+ char tmp[64], tmp2[64];
+- if(fs <= MBR || fs > NTFS)
++ if(fs <= MBR || fs > EXT4)
+ return;
+ mount = malloc(sizeof(struct mount));
+ INIT_LIST_HEAD(&mount->list);
+@@ -147,7 +150,7 @@
+ mount->mounted = 0;
+ mount->fs = fs;
+ list_add(&mount->list, &mounts);
+- if((!mount->ignore) && (mount->fs > MBR) && (mount->fs <= NTFS))
++ if((!mount->ignore) && (mount->fs > MBR) && (mount->fs <= EXT4))
+ {
+ log_printf("new mount : %s -> %s (%s)\n", name, dev, fs_names[mount->fs]);
+ snprintf(tmp, 64, "%s%s", uci_path, name);
+@@ -226,6 +229,11 @@
+ log_printf("mount -t vfat -o rw,uid=1000,gid=1000 /dev/%s %s", mount->dev, tmp);
+ ret = system_printf("mount -t vfat -o rw,uid=1000,gid=1000 /dev/%s %s", mount->dev, tmp);
+ }
++ if(mount->fs == EXT4)
++ {
++ log_printf("mount -t ext4 -o rw,defaults /dev/%s %s", mount->dev, tmp);
++ ret = system_printf("mount -t ext4 -o rw,defaults /dev/%s %s", mount->dev, tmp);
++ }
+ if(mount->fs == EXT3)
+ {
+ log_printf("mount -t ext3 -o rw,defaults /dev/%s %s", mount->dev, tmp);
diff --git a/package/mountd/patches/040-optional-daemonize.patch b/package/mountd/patches/040-optional-daemonize.patch
new file mode 100644
index 0000000..4d159ec
--- /dev/null
+++ b/package/mountd/patches/040-optional-daemonize.patch
@@ -0,0 +1,13 @@
+--- a/main.c
++++ b/main.c
+@@ -13,7 +13,9 @@
+
+ int main(int argc, char *argv[])
+ {
+- daemon(0,0);
++ if ((argc < 2) || strcmp(argv[1], "-f"))
++ daemon(0,0);
++
+ daemonize = 1;
+ log_start();
+ log_printf("Starting OpenWrt (auto)mountd V1\n");
diff --git a/package/mtd/.svn/entries b/package/mtd/.svn/entries
new file mode 100644
index 0000000..23657a7
--- /dev/null
+++ b/package/mtd/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/mtd
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-11-21T20:27:02.130861Z
+34294
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+src
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+771b1cab822ef879a9700bf02dcaacac
+2012-11-04T17:01:30.838597Z
+34071
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1182
+
diff --git a/package/mtd/.svn/prop-base/Makefile.svn-base b/package/mtd/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..8e522ae
--- /dev/null
+++ b/package/mtd/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:copyright
+V 30
+Copyright (C) 2006 OpenWrt.org
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/mtd/.svn/text-base/Makefile.svn-base b/package/mtd/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..f429128
--- /dev/null
+++ b/package/mtd/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,53 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=mtd
+PKG_RELEASE:=20
+
+PKG_BUILD_DIR := $(KERNEL_BUILD_DIR)/$(PKG_NAME)
+STAMP_PREPARED := $(STAMP_PREPARED)_$(call confvar,CONFIG_MTD_REDBOOT_PARTS)
+
+PKG_LICENSE:=GPLv2 GPLv2+
+PKG_LICENSE_FILES:=
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/mtd
+ SECTION:=utils
+ CATEGORY:=Base system
+ TITLE:=Update utility for trx firmware images
+endef
+
+define Package/mtd/description
+ This package contains an utility useful to upgrade from other firmware or
+ older OpenWrt releases.
+endef
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+target=$(firstword $(subst -, ,$(BOARD)))
+
+MAKE_FLAGS += TARGET="$(target)"
+TARGET_CFLAGS := $(TARGET_CFLAGS) -Dtarget_$(target)=1 -Wall
+
+ifdef CONFIG_MTD_REDBOOT_PARTS
+ MAKE_FLAGS += FIS_SUPPORT=1
+ TARGET_CFLAGS += -DFIS_SUPPORT=1
+endif
+
+define Package/mtd/install
+ $(INSTALL_DIR) $(1)/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/mtd $(1)/sbin/
+endef
+
+$(eval $(call BuildPackage,mtd))
diff --git a/package/mtd/Makefile b/package/mtd/Makefile
new file mode 100644
index 0000000..f429128
--- /dev/null
+++ b/package/mtd/Makefile
@@ -0,0 +1,53 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=mtd
+PKG_RELEASE:=20
+
+PKG_BUILD_DIR := $(KERNEL_BUILD_DIR)/$(PKG_NAME)
+STAMP_PREPARED := $(STAMP_PREPARED)_$(call confvar,CONFIG_MTD_REDBOOT_PARTS)
+
+PKG_LICENSE:=GPLv2 GPLv2+
+PKG_LICENSE_FILES:=
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/mtd
+ SECTION:=utils
+ CATEGORY:=Base system
+ TITLE:=Update utility for trx firmware images
+endef
+
+define Package/mtd/description
+ This package contains an utility useful to upgrade from other firmware or
+ older OpenWrt releases.
+endef
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+target=$(firstword $(subst -, ,$(BOARD)))
+
+MAKE_FLAGS += TARGET="$(target)"
+TARGET_CFLAGS := $(TARGET_CFLAGS) -Dtarget_$(target)=1 -Wall
+
+ifdef CONFIG_MTD_REDBOOT_PARTS
+ MAKE_FLAGS += FIS_SUPPORT=1
+ TARGET_CFLAGS += -DFIS_SUPPORT=1
+endif
+
+define Package/mtd/install
+ $(INSTALL_DIR) $(1)/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/mtd $(1)/sbin/
+endef
+
+$(eval $(call BuildPackage,mtd))
diff --git a/package/mtd/src/.svn/entries b/package/mtd/src/.svn/entries
new file mode 100644
index 0000000..28c0b0d
--- /dev/null
+++ b/package/mtd/src/.svn/entries
@@ -0,0 +1,538 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/mtd/src
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-11-21T20:27:02.130861Z
+34294
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+jffs2.c
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+d7ab64d1b20fb7c0d1c73efd6d827515
+2012-07-25T17:28:32.277078Z
+32866
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+7829
+
+crc32.c
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+a1b18a2ecfafc34ebe73f4e1c3e2c761
+2007-08-20T16:12:24.001813Z
+8444
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5378
+
+trx.c
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+44d7b768576913ea5ed346c27ed19058
+2012-07-25T17:28:32.277078Z
+32866
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5364
+
+imagetag.c
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+9d6e5e328e76b9122599933fcd21712f
+2012-11-06T15:21:46.466031Z
+34103
+jogo
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+8214
+
+jffs2.h
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+380076d4ac31eb013feea0b75d0302f8
+2009-04-17T14:09:46.037367Z
+15242
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+6828
+
+fis.c
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+92ee68aaedbbf820145777b4ddd836f9
+2012-07-04T11:56:25.521001Z
+32601
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5572
+
+crc32.h
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+7a69876bee06b18bf009b34b481b186f
+2010-03-27T17:38:30.080820Z
+20523
+juhosg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+454
+
+mtd.c
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+3d76500cdf3cb59119c956b9b53853ac
+2012-11-21T20:27:02.130861Z
+34294
+florian
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+16205
+
+md5.c
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+8ded3bdcaa9215dd314d9481406ee582
+2012-10-18T07:22:59.227511Z
+33841
+juhosg
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+11560
+
+seama.c
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+0e9116c556619a41da81b95bf086bfdf
+2012-10-18T07:22:59.227511Z
+33841
+juhosg
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4128
+
+fis.h
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+be8ae96d0c3a510610ec41a23bd56340
+2009-09-21T09:58:41.902038Z
+17659
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+307
+
+mtd.h
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+33764ecbc357b128b02a254deee9ec08
+2012-10-18T07:22:59.227511Z
+33841
+juhosg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1044
+
+md5.h
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+676ced93ad98472b30903e9049b7ef20
+2012-10-18T07:22:59.227511Z
+33841
+juhosg
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3120
+
+seama.h
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+1278414a8f362044fa97fa59c2483ca4
+2012-10-18T07:22:59.227511Z
+33841
+juhosg
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3804
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+589771cd2535493e5949c42adac9ea5d
+2012-10-18T07:22:59.227511Z
+33841
+juhosg
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+289
+
diff --git a/package/mtd/src/.svn/prop-base/Makefile.svn-base b/package/mtd/src/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/mtd/src/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/mtd/src/.svn/prop-base/md5.c.svn-base b/package/mtd/src/.svn/prop-base/md5.c.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/mtd/src/.svn/prop-base/md5.c.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/mtd/src/.svn/prop-base/md5.h.svn-base b/package/mtd/src/.svn/prop-base/md5.h.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/mtd/src/.svn/prop-base/md5.h.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/mtd/src/.svn/prop-base/mtd.c.svn-base b/package/mtd/src/.svn/prop-base/mtd.c.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/mtd/src/.svn/prop-base/mtd.c.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/mtd/src/.svn/prop-base/seama.c.svn-base b/package/mtd/src/.svn/prop-base/seama.c.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/mtd/src/.svn/prop-base/seama.c.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/mtd/src/.svn/prop-base/seama.h.svn-base b/package/mtd/src/.svn/prop-base/seama.h.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/mtd/src/.svn/prop-base/seama.h.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/mtd/src/.svn/text-base/Makefile.svn-base b/package/mtd/src/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..4e6aee8
--- /dev/null
+++ b/package/mtd/src/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,18 @@
+CC = gcc
+CFLAGS += -Wall
+
+obj = mtd.o jffs2.o crc32.o
+obj.seama = seama.o md5.o
+obj.ar71xx = trx.o
+obj.brcm = trx.o
+obj.brcm47xx = $(obj.brcm)
+obj.brcm63xx = imagetag.o
+obj.ramips = $(obj.seama)
+
+ifdef FIS_SUPPORT
+ obj += fis.o
+endif
+
+mtd: $(obj) $(obj.$(TARGET))
+clean:
+ rm -f *.o jffs2
diff --git a/package/mtd/src/.svn/text-base/crc32.c.svn-base b/package/mtd/src/.svn/text-base/crc32.c.svn-base
new file mode 100644
index 0000000..6b1e50c
--- /dev/null
+++ b/package/mtd/src/.svn/text-base/crc32.c.svn-base
@@ -0,0 +1,95 @@
+/*
+ * COPYRIGHT (C) 1986 Gary S. Brown. You may use this program, or
+ * code or tables extracted from it, as desired without restriction.
+ *
+ * First, the polynomial itself and its table of feedback terms. The
+ * polynomial is
+ * X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0
+ *
+ * Note that we take it "backwards" and put the highest-order term in
+ * the lowest-order bit. The X^32 term is "implied"; the LSB is the
+ * X^31 term, etc. The X^0 term (usually shown as "+1") results in
+ * the MSB being 1
+ *
+ * Note that the usual hardware shift register implementation, which
+ * is what we're using (we're merely optimizing it by doing eight-bit
+ * chunks at a time) shifts bits into the lowest-order term. In our
+ * implementation, that means shifting towards the right. Why do we
+ * do it this way? Because the calculated CRC must be transmitted in
+ * order from highest-order term to lowest-order term. UARTs transmit
+ * characters in order from LSB to MSB. By storing the CRC this way
+ * we hand it to the UART in the order low-byte to high-byte; the UART
+ * sends each low-bit to hight-bit; and the result is transmission bit
+ * by bit from highest- to lowest-order term without requiring any bit
+ * shuffling on our part. Reception works similarly
+ *
+ * The feedback terms table consists of 256, 32-bit entries. Notes
+ *
+ * The table can be generated at runtime if desired; code to do so
+ * is shown later. It might not be obvious, but the feedback
+ * terms simply represent the results of eight shift/xor opera
+ * tions for all combinations of data and CRC register values
+ *
+ * The values must be right-shifted by eight bits by the "updcrc
+ * logic; the shift must be unsigned (bring in zeroes). On some
+ * hardware you could probably optimize the shift in assembler by
+ * using byte-swap instructions
+ * polynomial $edb88320
+ */
+
+#include <stdint.h>
+
+const uint32_t crc32_table[256] = {
+ 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
+ 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
+ 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
+ 0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL,
+ 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L,
+ 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L,
+ 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L,
+ 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,
+ 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L,
+ 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL,
+ 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L,
+ 0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L,
+ 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L,
+ 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL,
+ 0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL,
+ 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,
+ 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL,
+ 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L,
+ 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L,
+ 0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L,
+ 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL,
+ 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L,
+ 0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L,
+ 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,
+ 0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L,
+ 0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L,
+ 0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L,
+ 0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L,
+ 0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L,
+ 0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL,
+ 0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL,
+ 0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,
+ 0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L,
+ 0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL,
+ 0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL,
+ 0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L,
+ 0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL,
+ 0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L,
+ 0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL,
+ 0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,
+ 0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL,
+ 0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L,
+ 0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L,
+ 0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL,
+ 0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L,
+ 0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L,
+ 0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L,
+ 0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,
+ 0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L,
+ 0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L,
+ 0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL,
+ 0x2d02ef8dL
+};
diff --git a/package/mtd/src/.svn/text-base/crc32.h.svn-base b/package/mtd/src/.svn/text-base/crc32.h.svn-base
new file mode 100644
index 0000000..68f8ee4
--- /dev/null
+++ b/package/mtd/src/.svn/text-base/crc32.h.svn-base
@@ -0,0 +1,26 @@
+#ifndef CRC32_H
+#define CRC32_H
+
+#include <stdint.h>
+
+extern const uint32_t crc32_table[256];
+
+/* Return a 32-bit CRC of the contents of the buffer. */
+
+static inline uint32_t
+crc32(uint32_t val, const void *ss, int len)
+{
+ const unsigned char *s = ss;
+ while (--len >= 0)
+ val = crc32_table[(val ^ *s++) & 0xff] ^ (val >> 8);
+ return val;
+}
+
+static inline unsigned int crc32buf(char *buf, size_t len)
+{
+ return crc32(0xFFFFFFFF, buf, len);
+}
+
+
+
+#endif
diff --git a/package/mtd/src/.svn/text-base/fis.c.svn-base b/package/mtd/src/.svn/text-base/fis.c.svn-base
new file mode 100644
index 0000000..f825f59
--- /dev/null
+++ b/package/mtd/src/.svn/text-base/fis.c.svn-base
@@ -0,0 +1,262 @@
+/*
+ * FIS table updating code for mtd
+ *
+ * Copyright (C) 2009 Felix Fietkau <nbd@openwrt.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License v2
+ * as published by the Free Software Foundation.
+ *
+ * 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.
+ */
+#include <sys/mman.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <stdio.h>
+#include "crc32.h"
+#include "mtd.h"
+#include "fis.h"
+
+struct fis_image_hdr {
+ unsigned char name[16];
+ uint32_t flash_base;
+ uint32_t mem_base;
+ uint32_t size;
+ uint32_t entry_point;
+ uint32_t data_length;
+} __attribute__((packed));
+
+struct fis_image_crc {
+ uint32_t desc;
+ uint32_t file;
+} __attribute__((packed));
+
+struct fis_image_desc {
+ struct fis_image_hdr hdr;
+ char _pad[256 - sizeof(struct fis_image_hdr) - sizeof(struct fis_image_crc)];
+ struct fis_image_crc crc;
+} __attribute__((packed));
+
+static int fis_fd = -1;
+static struct fis_image_desc *fis_desc;
+static int fis_erasesize = 0;
+
+static void
+fis_close(void)
+{
+ if (fis_desc)
+ munmap(fis_desc, fis_erasesize);
+
+ if (fis_fd >= 0)
+ close(fis_fd);
+
+ fis_fd = -1;
+ fis_desc = NULL;
+}
+
+static struct fis_image_desc *
+fis_open(void)
+{
+ struct fis_image_desc *desc;
+
+ if (fis_fd >= 0)
+ fis_close();
+
+ fis_fd = mtd_check_open("FIS directory");
+ if (fis_fd < 0)
+ goto error;
+
+ close(fis_fd);
+ fis_fd = mtd_open("FIS directory", true);
+ if (fis_fd < 0)
+ goto error;
+
+ fis_erasesize = erasesize;
+ desc = mmap(NULL, erasesize, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_LOCKED, fis_fd, 0);
+ if (desc == MAP_FAILED)
+ goto error;
+
+ fis_desc = desc;
+ return desc;
+
+error:
+ fis_close();
+ return NULL;
+}
+
+int
+fis_validate(struct fis_part *old, int n_old, struct fis_part *new, int n_new)
+{
+ struct fis_image_desc *desc;
+ void *end;
+ int found = 0;
+ int i;
+
+ desc = fis_open();
+ if (!desc)
+ return -1;
+
+ for (i = 0; i < n_new - 1; i++) {
+ if (!new[i].size) {
+ fprintf(stderr, "FIS error: only the last partition can detect the size automatically\n");
+ i = -1;
+ goto done;
+ }
+ }
+
+ end = desc;
+ end = (char *) end + fis_erasesize;
+ while ((void *) desc < end) {
+ if (!desc->hdr.name[0] || (desc->hdr.name[0] == 0xff))
+ break;
+
+ for (i = 0; i < n_old; i++) {
+ if (!strncmp((char *) desc->hdr.name, (char *) old[i].name, sizeof(desc->hdr.name))) {
+ found++;
+ goto next;
+ }
+ }
+next:
+ desc++;
+ continue;
+ }
+
+ if (found == n_old)
+ i = 1;
+ else
+ i = -1;
+
+done:
+ fis_close();
+ return i;
+}
+
+int
+fis_remap(struct fis_part *old, int n_old, struct fis_part *new, int n_new)
+{
+ struct fis_image_desc *fisdir = NULL;
+ struct fis_image_desc *redboot = NULL;
+ struct fis_image_desc *first = NULL;
+ struct fis_image_desc *last = NULL;
+ struct fis_image_desc *first_fb = NULL;
+ struct fis_image_desc *last_fb = NULL;
+ struct fis_image_desc *desc;
+ struct fis_part *part;
+ uint32_t offset = 0, size = 0;
+ char *start, *end, *tmp;
+ int i;
+
+ desc = fis_open();
+ if (!desc)
+ return -1;
+
+ if (!quiet)
+ fprintf(stderr, "Updating FIS table... \n");
+
+ start = (char *) desc;
+ end = (char *) desc + fis_erasesize;
+ while ((char *) desc < end) {
+ if (!desc->hdr.name[0] || (desc->hdr.name[0] == 0xff))
+ break;
+
+ if (!strcmp((char *) desc->hdr.name, "FIS directory"))
+ fisdir = desc;
+
+ if (!strcmp((char *) desc->hdr.name, "RedBoot"))
+ redboot = desc;
+
+ /* update max offset */
+ if (offset < desc->hdr.flash_base)
+ offset = desc->hdr.flash_base;
+
+ for (i = 0; i < n_old; i++) {
+ if (!strncmp((char *) desc->hdr.name, (char *) old[i].name, sizeof(desc->hdr.name))) {
+ last = desc;
+ if (!first)
+ first = desc;
+ break;
+ }
+ }
+ desc++;
+ }
+ desc--;
+
+ first_fb = first;
+ last_fb = last;
+
+ if (first_fb->hdr.flash_base > last_fb->hdr.flash_base) {
+ first_fb = last;
+ last_fb = first;
+ }
+
+ /* determine size of available space */
+ desc = (struct fis_image_desc *) start;
+ while ((char *) desc < end) {
+ if (!desc->hdr.name[0] || (desc->hdr.name[0] == 0xff))
+ break;
+
+ if (desc->hdr.flash_base > last_fb->hdr.flash_base &&
+ desc->hdr.flash_base < offset)
+ offset = desc->hdr.flash_base;
+
+ desc++;
+ }
+ desc--;
+
+ size = offset - first_fb->hdr.flash_base;
+
+#ifdef notyet
+ desc = first - 1;
+ if (redboot && (desc >= redboot)) {
+ if (first->hdr.flash_base - desc->hdr.size > desc->hdr.flash_base) {
+ int delta = first->hdr.flash_base - desc->hdr.size - desc->hdr.flash_base;
+
+ offset -= delta;
+ size += delta;
+ }
+ }
+#endif
+
+ last++;
+ desc = first + n_new;
+ offset = first_fb->hdr.flash_base;
+
+ if (desc != last) {
+ if (desc > last)
+ tmp = (char *) desc;
+ else
+ tmp = (char *) last;
+
+ memmove(desc, last, end - tmp);
+ if (desc < last) {
+ tmp = end - (last - desc) * sizeof(struct fis_image_desc);
+ memset(tmp, 0xff, tmp - end);
+ }
+ }
+
+ for (part = new, desc = first; desc < first + n_new; desc++, part++) {
+ memset(desc, 0, sizeof(struct fis_image_desc));
+ memcpy(desc->hdr.name, part->name, sizeof(desc->hdr.name));
+ desc->crc.desc = 0;
+ desc->crc.file = 0;
+
+ desc->hdr.flash_base = offset;
+ desc->hdr.mem_base = part->loadaddr;
+ desc->hdr.entry_point = part->loadaddr;
+ desc->hdr.size = (part->size > 0) ? part->size : size;
+ desc->hdr.data_length = desc->hdr.size;
+
+ offset += desc->hdr.size;
+ size -= desc->hdr.size;
+ }
+
+ msync(fis_desc, fis_erasesize, MS_SYNC|MS_INVALIDATE);
+ fis_close();
+
+ return 0;
+}
diff --git a/package/mtd/src/.svn/text-base/fis.h.svn-base b/package/mtd/src/.svn/text-base/fis.h.svn-base
new file mode 100644
index 0000000..bdf1103
--- /dev/null
+++ b/package/mtd/src/.svn/text-base/fis.h.svn-base
@@ -0,0 +1,14 @@
+#ifndef __FIS_H
+#define __FIS_H
+
+struct fis_part {
+ unsigned char name[16];
+ uint32_t offset;
+ uint32_t loadaddr;
+ uint32_t size;
+};
+
+int fis_validate(struct fis_part *old, int n_old, struct fis_part *new, int n_new);
+int fis_remap(struct fis_part *old, int n_old, struct fis_part *new, int n_new);
+
+#endif
diff --git a/package/mtd/src/.svn/text-base/imagetag.c.svn-base b/package/mtd/src/.svn/text-base/imagetag.c.svn-base
new file mode 100644
index 0000000..a53c17a
--- /dev/null
+++ b/package/mtd/src/.svn/text-base/imagetag.c.svn-base
@@ -0,0 +1,316 @@
+/*
+ * imagetag.c
+ *
+ * Copyright (C) 2005 Mike Baker
+ * Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
+ * Copyrigth (C) 2010 Daniel Dickinson <openwrt@cshore.neomailbox.net>
+ *
+ * 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
+ * of the License, 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stddef.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <string.h>
+#include <errno.h>
+
+#include <sys/ioctl.h>
+#include <mtd/mtd-user.h>
+#include <linux/bcm963xx_tag.h>
+
+#include "mtd.h"
+#include "crc32.h"
+
+ssize_t pread(int fd, void *buf, size_t count, off_t offset);
+ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset);
+
+#define CRC_START 0xFFFFFFFF
+
+static uint32_t strntoul(char *str, char **endptr, int base, size_t len) {
+ char *newstr;
+ uint32_t res = 0;
+
+ newstr = calloc(len + 1, sizeof(char));
+ if (newstr) {
+ strncpy(newstr, str, len);
+ res = strtoul(newstr, endptr, base);
+ free(newstr);
+ }
+ return res;
+}
+
+uint32_t compute_crc32(uint32_t crc, off_t start, size_t compute_len, int fd)
+{
+ uint8_t readbuf[1024];
+ ssize_t res;
+ off_t offset = start;
+
+ /* Read a buffer's worth of bytes */
+ while (fd && (compute_len >= sizeof(readbuf))) {
+ res = pread(fd, readbuf, sizeof(readbuf), offset);
+ crc = crc32(crc, readbuf, res);
+ compute_len = compute_len - res;
+ offset += res;
+ }
+
+ /* Less than buffer-size bytes remains, read compute_len bytes */
+ if (fd && (compute_len > 0)) {
+ res = pread(fd, readbuf, compute_len, offset);
+ crc = crc32(crc, readbuf, res);
+ }
+
+ return crc;
+}
+
+int
+trx_fixup(int fd, const char *name)
+{
+ struct mtd_info_user mtdInfo;
+ unsigned long len;
+ void *ptr, *scan;
+ int bfd;
+ struct bcm_tag *tag;
+ ssize_t res;
+ uint32_t cfelen, imagelen, imagestart, rootfslen;
+ uint32_t imagecrc, rootfscrc, headercrc;
+ uint32_t offset = 0;
+ cfelen = imagelen = imagestart = imagecrc = rootfscrc = headercrc = rootfslen = 0;
+
+
+ if (ioctl(fd, MEMGETINFO, &mtdInfo) < 0) {
+ fprintf(stderr, "Failed to get mtd info\n");
+ goto err;
+ }
+
+ len = mtdInfo.size;
+ if (mtdInfo.size <= 0) {
+ fprintf(stderr, "Invalid MTD device size\n");
+ goto err;
+ }
+
+ bfd = mtd_open(name, true);
+ ptr = mmap(NULL, len, PROT_READ|PROT_WRITE, MAP_SHARED, bfd, 0);
+ if (!ptr || (ptr == (void *) -1)) {
+ perror("mmap");
+ goto err1;
+ }
+
+ tag = (struct bcm_tag *) (ptr);
+
+ cfelen = strntoul(&tag->cfe_length[0], NULL, 10, IMAGE_LEN);
+ if (cfelen) {
+ fprintf(stderr, "Non-zero CFE length. This is currently unsupported.\n");
+ exit(1);
+ }
+
+ headercrc = compute_crc32(CRC_START, offset, offsetof(struct bcm_tag, header_crc), fd);
+ if (headercrc != *(uint32_t *)(&tag->header_crc)) {
+ fprintf(stderr, "Tag verify failed. This may not be a valid image.\n");
+ exit(1);
+ }
+
+ sprintf(&tag->root_length[0], "%u", 0);
+ strncpy(&tag->total_length[0], &tag->kernel_length[0], IMAGE_LEN);
+
+ imagestart = sizeof(tag);
+ memcpy(&tag->image_crc, &tag->kernel_crc, sizeof(uint32_t));
+ memcpy(&tag->fskernel_crc, &tag->kernel_crc, sizeof(uint32_t));
+ rootfscrc = CRC_START;
+ memcpy(&tag->rootfs_crc, &rootfscrc, sizeof(uint32_t));
+ headercrc = crc32(CRC_START, tag, offsetof(struct bcm_tag, header_crc));
+ memcpy(&tag->header_crc, &headercrc, sizeof(uint32_t));
+
+ msync(ptr, sizeof(struct bcm_tag), MS_SYNC|MS_INVALIDATE);
+ munmap(ptr, len);
+ close(bfd);
+ return 0;
+
+err1:
+ close(bfd);
+err:
+ fprintf(stderr, "Error fixing up imagetag header\n");
+ return -1;
+}
+
+
+int
+trx_check(int imagefd, const char *mtd, char *buf, int *len)
+{
+ struct bcm_tag *tag = (const struct bcm_tag *) buf;
+ int fd;
+ uint32_t headerCRC;
+ uint32_t imageLen;
+
+ if (strcmp(mtd, "linux") != 0)
+ return 1;
+
+ *len = read(imagefd, buf, sizeof(struct bcm_tag));
+ if (*len < sizeof(struct bcm_tag)) {
+ fprintf(stdout, "Could not get image header, file too small (%d bytes)\n", *len);
+ return 0;
+ }
+ headerCRC = crc32buf(buf, offsetof(struct bcm_tag, header_crc));
+ if (*(uint32_t *)(&tag->header_crc) != headerCRC) {
+
+ if (quiet < 2) {
+ fprintf(stderr, "Bad header CRC got %08x, calculated %08x\n",
+ *(uint32_t *)(&tag->header_crc), headerCRC);
+ fprintf(stderr, "This is not the correct file format; refusing to flash.\n"
+ "Please specify the correct file or use -f to force.\n");
+ }
+ return 0;
+ }
+
+ /* check if image fits to mtd device */
+ fd = mtd_check_open(mtd);
+ if(fd < 0) {
+ fprintf(stderr, "Could not open mtd device: %s\n", mtd);
+ exit(1);
+ }
+
+ imageLen = strntoul(&tag->total_length[0], NULL, 10, IMAGE_LEN);
+
+ if(mtdsize < imageLen) {
+ fprintf(stderr, "Image too big for partition: %s\n", mtd);
+ close(fd);
+ return 0;
+ }
+
+ close(fd);
+ return 1;
+}
+
+int
+mtd_fixtrx(const char *mtd, size_t offset)
+{
+ int fd;
+ struct bcm_tag *tag;
+ char *buf;
+ ssize_t res;
+ size_t block_offset;
+ uint32_t cfelen, imagelen, imagestart, rootfslen;
+ uint32_t imagecrc, rootfscrc, headercrc;
+ cfelen = imagelen = imagestart = imagecrc = rootfscrc = headercrc = rootfslen = 0;
+
+ if (quiet < 2)
+ fprintf(stderr, "Trying to fix trx header in %s at 0x%x...\n", mtd, offset);
+
+ block_offset = offset & ~(erasesize - 1);
+ offset -= block_offset;
+
+ fd = mtd_check_open(mtd);
+ if(fd < 0) {
+ fprintf(stderr, "Could not open mtd device: %s\n", mtd);
+ exit(1);
+ }
+
+ if (block_offset + erasesize > mtdsize) {
+ fprintf(stderr, "Offset too large, device size 0x%x\n", mtdsize);
+ exit(1);
+ }
+
+ buf = malloc(erasesize);
+ if (!buf) {
+ perror("malloc");
+ exit(1);
+ }
+
+ res = pread(fd, buf, erasesize, block_offset);
+ if (res != erasesize) {
+ perror("pread");
+ exit(1);
+ }
+
+ tag = (struct bcm_tag *) (buf + offset);
+
+ cfelen = strntoul(tag->cfe_length, NULL, 10, IMAGE_LEN);
+ if (cfelen) {
+ fprintf(stderr, "Non-zero CFE length. This is currently unsupported.\n");
+ exit(1);
+ }
+
+ if (quiet < 2) {
+ fprintf(stderr, "Verifying we actually have an imagetag.\n");
+ }
+
+ headercrc = compute_crc32(CRC_START, offset, offsetof(struct bcm_tag, header_crc), fd);
+ if (headercrc != *(uint32_t *)(&tag->header_crc)) {
+ fprintf(stderr, "Tag verify failed. This may not be a valid image.\n");
+ exit(1);
+ }
+
+ if (quiet < 2) {
+ fprintf(stderr, "Checking current fixed status.\n");
+ }
+
+ rootfslen = strntoul(&tag->root_length[0], NULL, 10, IMAGE_LEN);
+ if (rootfslen == 0) {
+ if (quiet < 2)
+ fprintf(stderr, "Header already fixed, exiting\n");
+ close(fd);
+ return 0;
+ }
+
+ if (quiet < 2) {
+ fprintf(stderr, "Setting root length to 0.\n");
+ }
+
+ sprintf(&tag->root_length[0], "%u", 0);
+ strncpy(&tag->total_length[0], &tag->kernel_length[0], IMAGE_LEN);
+
+ if (quiet < 2) {
+ fprintf(stderr, "Recalculating CRCs.\n");
+ }
+
+ imagestart = sizeof(tag);
+ memcpy(&tag->image_crc, &tag->kernel_crc, sizeof(uint32_t));
+ memcpy(&tag->fskernel_crc, &tag->kernel_crc, sizeof(uint32_t));
+ rootfscrc = CRC_START;
+ memcpy(&tag->rootfs_crc, &rootfscrc, sizeof(uint32_t));
+ headercrc = crc32(CRC_START, tag, offsetof(struct bcm_tag, header_crc));
+ memcpy(&tag->header_crc, &headercrc, sizeof(uint32_t));
+
+ if (quiet < 2) {
+ fprintf(stderr, "Erasing imagetag block\n");
+ }
+
+ if (mtd_erase_block(fd, block_offset)) {
+ fprintf(stderr, "Can't erase block at 0x%x (%s)\n", block_offset, strerror(errno));
+ exit(1);
+ }
+
+ if (quiet < 2) {
+ fprintf(stderr, "New image crc32: 0x%x, rewriting block\n",
+ *(uint32_t *)(&tag->image_crc));
+ fprintf(stderr, "New header crc32: 0x%x, rewriting block\n", headercrc);
+ }
+
+ if (pwrite(fd, buf, erasesize, block_offset) != erasesize) {
+ fprintf(stderr, "Error writing block (%s)\n", strerror(errno));
+ exit(1);
+ }
+
+ if (quiet < 2)
+ fprintf(stderr, "Done.\n");
+
+ close (fd);
+ sync();
+ return 0;
+
+}
diff --git a/package/mtd/src/.svn/text-base/jffs2.c.svn-base b/package/mtd/src/.svn/text-base/jffs2.c.svn-base
new file mode 100644
index 0000000..2a83bd4
--- /dev/null
+++ b/package/mtd/src/.svn/text-base/jffs2.c.svn-base
@@ -0,0 +1,357 @@
+/*
+ * jffs2 on-disk structure generator for mtd
+ *
+ * Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License v2
+ * as published by the Free Software Foundation.
+ *
+ * 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.
+ * Based on:
+ * JFFS2 -- Journalling Flash File System, Version 2.
+ * Copyright © 2001-2007 Red Hat, Inc.
+ * Created by David Woodhouse <dwmw2@infradead.org>
+ */
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <string.h>
+#include <dirent.h>
+#include <unistd.h>
+#include <endian.h>
+#include "jffs2.h"
+#include "crc32.h"
+#include "mtd.h"
+
+#define PAD(x) (((x)+3)&~3)
+
+#if BYTE_ORDER == BIG_ENDIAN
+# define CLEANMARKER "\x19\x85\x20\x03\x00\x00\x00\x0c\xf0\x60\xdc\x98"
+#else
+# define CLEANMARKER "\x85\x19\x03\x20\x0c\x00\x00\x00\xb1\xb0\x1e\xe4"
+#endif
+
+static int last_ino = 0;
+static int last_version = 0;
+static char *buf = NULL;
+static int ofs = 0;
+static int outfd = -1;
+static int mtdofs = 0;
+static int target_ino = 0;
+
+static void prep_eraseblock(void);
+
+static void pad(int size)
+{
+ if ((ofs % size == 0) && (ofs < erasesize))
+ return;
+
+ if (ofs < erasesize) {
+ memset(buf + ofs, 0xff, (size - (ofs % size)));
+ ofs += (size - (ofs % size));
+ }
+ ofs = ofs % erasesize;
+ if (ofs == 0) {
+ mtd_erase_block(outfd, mtdofs);
+ write(outfd, buf, erasesize);
+ mtdofs += erasesize;
+ }
+}
+
+static inline int rbytes(void)
+{
+ return erasesize - (ofs % erasesize);
+}
+
+static inline void add_data(char *ptr, int len)
+{
+ if (ofs + len > erasesize) {
+ pad(erasesize);
+ prep_eraseblock();
+ }
+ memcpy(buf + ofs, ptr, len);
+ ofs += len;
+}
+
+static void prep_eraseblock(void)
+{
+ if (ofs > 0)
+ return;
+
+ add_data(CLEANMARKER, sizeof(CLEANMARKER) - 1);
+}
+
+static int add_dirent(const char *name, const char type, int parent)
+{
+ struct jffs2_raw_dirent *de;
+
+ if (ofs - erasesize < sizeof(struct jffs2_raw_dirent) + strlen(name))
+ pad(erasesize);
+
+ prep_eraseblock();
+ last_ino++;
+ memset(buf + ofs, 0, sizeof(struct jffs2_raw_dirent));
+ de = (struct jffs2_raw_dirent *) (buf + ofs);
+
+ de->magic = JFFS2_MAGIC_BITMASK;
+ de->nodetype = JFFS2_NODETYPE_DIRENT;
+ de->type = type;
+ de->name_crc = crc32(0, name, strlen(name));
+ de->ino = last_ino++;
+ de->pino = parent;
+ de->totlen = sizeof(*de) + strlen(name);
+ de->hdr_crc = crc32(0, (void *) de, sizeof(struct jffs2_unknown_node) - 4);
+ de->version = last_version++;
+ de->mctime = 0;
+ de->nsize = strlen(name);
+ de->node_crc = crc32(0, (void *) de, sizeof(*de) - 8);
+ memcpy(de->name, name, strlen(name));
+
+ ofs += sizeof(struct jffs2_raw_dirent) + de->nsize;
+ pad(4);
+
+ return de->ino;
+}
+
+static int add_dir(const char *name, int parent)
+{
+ struct jffs2_raw_inode ri;
+ int inode;
+
+ inode = add_dirent(name, IFTODT(S_IFDIR), parent);
+
+ if (rbytes() < sizeof(ri))
+ pad(erasesize);
+ prep_eraseblock();
+
+ memset(&ri, 0, sizeof(ri));
+ ri.magic = JFFS2_MAGIC_BITMASK;
+ ri.nodetype = JFFS2_NODETYPE_INODE;
+ ri.totlen = sizeof(ri);
+ ri.hdr_crc = crc32(0, &ri, sizeof(struct jffs2_unknown_node) - 4);
+
+ ri.ino = inode;
+ ri.mode = S_IFDIR | 0755;
+ ri.uid = ri.gid = 0;
+ ri.atime = ri.ctime = ri.mtime = 0;
+ ri.isize = ri.csize = ri.dsize = 0;
+ ri.version = 1;
+ ri.node_crc = crc32(0, &ri, sizeof(ri) - 8);
+ ri.data_crc = 0;
+
+ add_data((char *) &ri, sizeof(ri));
+ pad(4);
+ return inode;
+}
+
+static void add_file(const char *name, int parent)
+{
+ int inode, f_offset = 0, fd;
+ struct jffs2_raw_inode ri;
+ struct stat st;
+ char wbuf[4096];
+ const char *fname;
+
+ if (stat(name, &st)) {
+ fprintf(stderr, "File %s does not exist\n", name);
+ return;
+ }
+
+ fname = strrchr(name, '/');
+ if (fname)
+ fname++;
+ else
+ fname = name;
+
+ inode = add_dirent(fname, IFTODT(S_IFREG), parent);
+ memset(&ri, 0, sizeof(ri));
+ ri.magic = JFFS2_MAGIC_BITMASK;
+ ri.nodetype = JFFS2_NODETYPE_INODE;
+
+ ri.ino = inode;
+ ri.mode = st.st_mode;
+ ri.uid = ri.gid = 0;
+ ri.atime = st.st_atime;
+ ri.ctime = st.st_ctime;
+ ri.mtime = st.st_mtime;
+ ri.isize = st.st_size;
+ ri.compr = 0;
+ ri.usercompr = 0;
+
+ fd = open(name, 0);
+ if (fd < 0) {
+ fprintf(stderr, "File %s does not exist\n", name);
+ return;
+ }
+
+ for (;;) {
+ int len = 0;
+
+ for (;;) {
+ len = rbytes() - sizeof(ri);
+ if (len > 128)
+ break;
+
+ pad(erasesize);
+ prep_eraseblock();
+ }
+
+ if (len > sizeof(wbuf))
+ len = sizeof(wbuf);
+
+ len = read(fd, wbuf, len);
+ if (len <= 0)
+ break;
+
+ ri.totlen = sizeof(ri) + len;
+ ri.hdr_crc = crc32(0, &ri, sizeof(struct jffs2_unknown_node) - 4);
+ ri.version = ++last_version;
+ ri.offset = f_offset;
+ ri.csize = ri.dsize = len;
+ ri.node_crc = crc32(0, &ri, sizeof(ri) - 8);
+ ri.data_crc = crc32(0, wbuf, len);
+ f_offset += len;
+ add_data((char *) &ri, sizeof(ri));
+ add_data(wbuf, len);
+ pad(4);
+ prep_eraseblock();
+ }
+
+ close(fd);
+}
+
+int mtd_replace_jffs2(const char *mtd, int fd, int ofs, const char *filename)
+{
+ outfd = fd;
+ mtdofs = ofs;
+
+ buf = malloc(erasesize);
+ target_ino = 1;
+ if (!last_ino)
+ last_ino = 1;
+ add_file(filename, target_ino);
+ pad(erasesize);
+
+ /* add eof marker, pad to eraseblock size and write the data */
+ add_data(JFFS2_EOF, sizeof(JFFS2_EOF) - 1);
+ pad(erasesize);
+ free(buf);
+
+ return (mtdofs - ofs);
+}
+
+void mtd_parse_jffs2data(const char *buf, const char *dir)
+{
+ struct jffs2_unknown_node *node = (struct jffs2_unknown_node *) buf;
+ unsigned int ofs = 0;
+
+ while (ofs < erasesize) {
+ node = (struct jffs2_unknown_node *) (buf + ofs);
+ if (node->magic != 0x1985)
+ break;
+
+ ofs += PAD(node->totlen);
+ if (node->nodetype == JFFS2_NODETYPE_DIRENT) {
+ struct jffs2_raw_dirent *de = (struct jffs2_raw_dirent *) node;
+
+ /* is this the right directory name and is it a subdirectory of / */
+ if (*dir && (de->pino == 1) && !strncmp((char *) de->name, dir, de->nsize))
+ target_ino = de->ino;
+
+ /* store the last inode and version numbers for adding extra files */
+ if (last_ino < de->ino)
+ last_ino = de->ino;
+ if (last_version < de->version)
+ last_version = de->version;
+ }
+ }
+}
+
+int mtd_write_jffs2(const char *mtd, const char *filename, const char *dir)
+{
+ int err = -1, fdeof = 0;
+
+ outfd = mtd_check_open(mtd);
+ if (outfd < 0)
+ return -1;
+
+ if (quiet < 2)
+ fprintf(stderr, "Appending %s to jffs2 partition %s\n", filename, mtd);
+
+ buf = malloc(erasesize);
+ if (!buf) {
+ fprintf(stderr, "Out of memory!\n");
+ goto done;
+ }
+
+ if (!*dir)
+ target_ino = 1;
+
+ /* parse the structure of the jffs2 first
+ * locate the directory that the file is going to be placed in */
+ for(;;) {
+ struct jffs2_unknown_node *node = (struct jffs2_unknown_node *) buf;
+
+ if (read(outfd, buf, erasesize) != erasesize) {
+ fdeof = 1;
+ break;
+ }
+ mtdofs += erasesize;
+
+ if (node->magic == 0x8519) {
+ fprintf(stderr, "Error: wrong endianness filesystem\n");
+ goto done;
+ }
+
+ /* assume no magic == end of filesystem
+ * the filesystem will probably end with be32(0xdeadc0de) */
+ if (node->magic != 0x1985)
+ break;
+
+ mtd_parse_jffs2data(buf, dir);
+ }
+
+ if (fdeof) {
+ fprintf(stderr, "Error: No room for additional data\n");
+ goto done;
+ }
+
+ /* jump back one eraseblock */
+ mtdofs -= erasesize;
+ lseek(outfd, mtdofs, SEEK_SET);
+
+ ofs = 0;
+
+ if (!last_ino)
+ last_ino = 1;
+
+ if (!target_ino)
+ target_ino = add_dir(dir, 1);
+
+ add_file(filename, target_ino);
+ pad(erasesize);
+
+ /* add eof marker, pad to eraseblock size and write the data */
+ add_data(JFFS2_EOF, sizeof(JFFS2_EOF) - 1);
+ pad(erasesize);
+
+ err = 0;
+
+ if (trx_fixup) {
+ trx_fixup(outfd, mtd);
+ }
+
+done:
+ close(outfd);
+ if (buf)
+ free(buf);
+
+ return err;
+}
diff --git a/package/mtd/src/.svn/text-base/jffs2.h.svn-base b/package/mtd/src/.svn/text-base/jffs2.h.svn-base
new file mode 100644
index 0000000..858e77a
--- /dev/null
+++ b/package/mtd/src/.svn/text-base/jffs2.h.svn-base
@@ -0,0 +1,216 @@
+/*
+ * JFFS2 -- Journalling Flash File System, Version 2.
+ *
+ * Copyright (C) 2001-2003 Red Hat, Inc.
+ *
+ * Created by David Woodhouse <dwmw2@infradead.org>
+ *
+ * For licensing information, see the file 'LICENCE' in the
+ * jffs2 directory.
+ *
+ *
+ */
+
+#ifndef __LINUX_JFFS2_H__
+#define __LINUX_JFFS2_H__
+
+#define JFFS2_SUPER_MAGIC 0x72b6
+
+/* You must include something which defines the C99 uintXX_t types.
+ We don't do it from here because this file is used in too many
+ different environments. */
+
+/* Values we may expect to find in the 'magic' field */
+#define JFFS2_OLD_MAGIC_BITMASK 0x1984
+#define JFFS2_MAGIC_BITMASK 0x1985
+#define KSAMTIB_CIGAM_2SFFJ 0x8519 /* For detecting wrong-endian fs */
+#define JFFS2_EMPTY_BITMASK 0xffff
+#define JFFS2_DIRTY_BITMASK 0x0000
+
+/* Summary node MAGIC marker */
+#define JFFS2_SUM_MAGIC 0x02851885
+
+/* We only allow a single char for length, and 0xFF is empty flash so
+ we don't want it confused with a real length. Hence max 254.
+*/
+#define JFFS2_MAX_NAME_LEN 254
+
+/* How small can we sensibly write nodes? */
+#define JFFS2_MIN_DATA_LEN 128
+
+#define JFFS2_COMPR_NONE 0x00
+#define JFFS2_COMPR_ZERO 0x01
+#define JFFS2_COMPR_RTIME 0x02
+#define JFFS2_COMPR_RUBINMIPS 0x03
+#define JFFS2_COMPR_COPY 0x04
+#define JFFS2_COMPR_DYNRUBIN 0x05
+#define JFFS2_COMPR_ZLIB 0x06
+/* Compatibility flags. */
+#define JFFS2_COMPAT_MASK 0xc000 /* What do to if an unknown nodetype is found */
+#define JFFS2_NODE_ACCURATE 0x2000
+/* INCOMPAT: Fail to mount the filesystem */
+#define JFFS2_FEATURE_INCOMPAT 0xc000
+/* ROCOMPAT: Mount read-only */
+#define JFFS2_FEATURE_ROCOMPAT 0x8000
+/* RWCOMPAT_COPY: Mount read/write, and copy the node when it's GC'd */
+#define JFFS2_FEATURE_RWCOMPAT_COPY 0x4000
+/* RWCOMPAT_DELETE: Mount read/write, and delete the node when it's GC'd */
+#define JFFS2_FEATURE_RWCOMPAT_DELETE 0x0000
+
+#define JFFS2_NODETYPE_DIRENT (JFFS2_FEATURE_INCOMPAT | JFFS2_NODE_ACCURATE | 1)
+#define JFFS2_NODETYPE_INODE (JFFS2_FEATURE_INCOMPAT | JFFS2_NODE_ACCURATE | 2)
+#define JFFS2_NODETYPE_CLEANMARKER (JFFS2_FEATURE_RWCOMPAT_DELETE | JFFS2_NODE_ACCURATE | 3)
+#define JFFS2_NODETYPE_PADDING (JFFS2_FEATURE_RWCOMPAT_DELETE | JFFS2_NODE_ACCURATE | 4)
+
+#define JFFS2_NODETYPE_SUMMARY (JFFS2_FEATURE_RWCOMPAT_DELETE | JFFS2_NODE_ACCURATE | 6)
+
+#define JFFS2_NODETYPE_XATTR (JFFS2_FEATURE_INCOMPAT | JFFS2_NODE_ACCURATE | 8)
+#define JFFS2_NODETYPE_XREF (JFFS2_FEATURE_INCOMPAT | JFFS2_NODE_ACCURATE | 9)
+
+/* XATTR Related */
+#define JFFS2_XPREFIX_USER 1 /* for "user." */
+#define JFFS2_XPREFIX_SECURITY 2 /* for "security." */
+#define JFFS2_XPREFIX_ACL_ACCESS 3 /* for "system.posix_acl_access" */
+#define JFFS2_XPREFIX_ACL_DEFAULT 4 /* for "system.posix_acl_default" */
+#define JFFS2_XPREFIX_TRUSTED 5 /* for "trusted.*" */
+
+#define JFFS2_ACL_VERSION 0x0001
+
+// Maybe later...
+//#define JFFS2_NODETYPE_CHECKPOINT (JFFS2_FEATURE_RWCOMPAT_DELETE | JFFS2_NODE_ACCURATE | 3)
+//#define JFFS2_NODETYPE_OPTIONS (JFFS2_FEATURE_RWCOMPAT_COPY | JFFS2_NODE_ACCURATE | 4)
+
+
+#define JFFS2_INO_FLAG_PREREAD 1 /* Do read_inode() for this one at
+ mount time, don't wait for it to
+ happen later */
+#define JFFS2_INO_FLAG_USERCOMPR 2 /* User has requested a specific
+ compression type */
+
+
+/* These can go once we've made sure we've caught all uses without
+ byteswapping */
+
+typedef uint32_t jint32_t;
+
+typedef uint32_t jmode_t;
+
+typedef uint16_t jint16_t;
+
+struct jffs2_unknown_node
+{
+ /* All start like this */
+ jint16_t magic;
+ jint16_t nodetype;
+ jint32_t totlen; /* So we can skip over nodes we don't grok */
+ jint32_t hdr_crc;
+};
+
+struct jffs2_raw_dirent
+{
+ jint16_t magic;
+ jint16_t nodetype; /* == JFFS2_NODETYPE_DIRENT */
+ jint32_t totlen;
+ jint32_t hdr_crc;
+ jint32_t pino;
+ jint32_t version;
+ jint32_t ino; /* == zero for unlink */
+ jint32_t mctime;
+ uint8_t nsize;
+ uint8_t type;
+ uint8_t unused[2];
+ jint32_t node_crc;
+ jint32_t name_crc;
+ uint8_t name[0];
+};
+
+/* The JFFS2 raw inode structure: Used for storage on physical media. */
+/* The uid, gid, atime, mtime and ctime members could be longer, but
+ are left like this for space efficiency. If and when people decide
+ they really need them extended, it's simple enough to add support for
+ a new type of raw node.
+*/
+struct jffs2_raw_inode
+{
+ jint16_t magic; /* A constant magic number. */
+ jint16_t nodetype; /* == JFFS2_NODETYPE_INODE */
+ jint32_t totlen; /* Total length of this node (inc data, etc.) */
+ jint32_t hdr_crc;
+ jint32_t ino; /* Inode number. */
+ jint32_t version; /* Version number. */
+ jmode_t mode; /* The file's type or mode. */
+ jint16_t uid; /* The file's owner. */
+ jint16_t gid; /* The file's group. */
+ jint32_t isize; /* Total resultant size of this inode (used for truncations) */
+ jint32_t atime; /* Last access time. */
+ jint32_t mtime; /* Last modification time. */
+ jint32_t ctime; /* Change time. */
+ jint32_t offset; /* Where to begin to write. */
+ jint32_t csize; /* (Compressed) data size */
+ jint32_t dsize; /* Size of the node's data. (after decompression) */
+ uint8_t compr; /* Compression algorithm used */
+ uint8_t usercompr; /* Compression algorithm requested by the user */
+ jint16_t flags; /* See JFFS2_INO_FLAG_* */
+ jint32_t data_crc; /* CRC for the (compressed) data. */
+ jint32_t node_crc; /* CRC for the raw inode (excluding data) */
+ uint8_t data[0];
+};
+
+struct jffs2_raw_xattr {
+ jint16_t magic;
+ jint16_t nodetype; /* = JFFS2_NODETYPE_XATTR */
+ jint32_t totlen;
+ jint32_t hdr_crc;
+ jint32_t xid; /* XATTR identifier number */
+ jint32_t version;
+ uint8_t xprefix;
+ uint8_t name_len;
+ jint16_t value_len;
+ jint32_t data_crc;
+ jint32_t node_crc;
+ uint8_t data[0];
+} __attribute__((packed));
+
+struct jffs2_raw_xref
+{
+ jint16_t magic;
+ jint16_t nodetype; /* = JFFS2_NODETYPE_XREF */
+ jint32_t totlen;
+ jint32_t hdr_crc;
+ jint32_t ino; /* inode number */
+ jint32_t xid; /* XATTR identifier number */
+ jint32_t xseqno; /* xref sequencial number */
+ jint32_t node_crc;
+} __attribute__((packed));
+
+struct jffs2_raw_summary
+{
+ jint16_t magic;
+ jint16_t nodetype; /* = JFFS2_NODETYPE_SUMMARY */
+ jint32_t totlen;
+ jint32_t hdr_crc;
+ jint32_t sum_num; /* number of sum entries*/
+ jint32_t cln_mkr; /* clean marker size, 0 = no cleanmarker */
+ jint32_t padded; /* sum of the size of padding nodes */
+ jint32_t sum_crc; /* summary information crc */
+ jint32_t node_crc; /* node crc */
+ jint32_t sum[0]; /* inode summary info */
+};
+
+union jffs2_node_union
+{
+ struct jffs2_raw_inode i;
+ struct jffs2_raw_dirent d;
+ struct jffs2_raw_xattr x;
+ struct jffs2_raw_xref r;
+ struct jffs2_raw_summary s;
+ struct jffs2_unknown_node u;
+};
+
+/* Data payload for device nodes. */
+union jffs2_device_node {
+ jint16_t old;
+ jint32_t new;
+};
+
+#endif /* __LINUX_JFFS2_H__ */
diff --git a/package/mtd/src/.svn/text-base/md5.c.svn-base b/package/mtd/src/.svn/text-base/md5.c.svn-base
new file mode 100644
index 0000000..2039760
--- /dev/null
+++ b/package/mtd/src/.svn/text-base/md5.c.svn-base
@@ -0,0 +1,307 @@
+
+
+/*
+ ***********************************************************************
+ ** md5.c -- the source code for MD5 routines **
+ ** RSA Data Security, Inc. MD5 Message-Digest Algorithm **
+ ** Created: 2/17/90 RLR **
+ ** Revised: 1/91 SRD,AJ,BSK,JT Reference C ver., 7/10 constant corr. **
+ ***********************************************************************
+ */
+
+/*
+ ***********************************************************************
+ ** Copyright (C) 1990, RSA Data Security, Inc. All rights reserved. **
+ ** **
+ ** License to copy and use this software is granted provided that **
+ ** it is identified as the "RSA Data Security, Inc. MD5 Message- **
+ ** Digest Algorithm" in all material mentioning or referencing this **
+ ** software or this function. **
+ ** **
+ ** License is also granted to make and use derivative works **
+ ** provided that such works are identified as "derived from the RSA **
+ ** Data Security, Inc. MD5 Message-Digest Algorithm" in all **
+ ** material mentioning or referencing the derived work. **
+ ** **
+ ** RSA Data Security, Inc. makes no representations concerning **
+ ** either the merchantability of this software or the suitability **
+ ** of this software for any particular purpose. It is provided "as **
+ ** is" without express or implied warranty of any kind. **
+ ** **
+ ** These notices must be retained in any copies of any part of this **
+ ** documentation and/or software. **
+ ***********************************************************************
+ */
+
+#include <string.h>
+#include "md5.h"
+
+/*
+ ***********************************************************************
+ ** Message-digest routines: **
+ ** To form the message digest for a message M **
+ ** (1) Initialize a context buffer mdContext using MD5_Init **
+ ** (2) Call MD5_Update on mdContext and M **
+ ** (3) Call MD5_Final on mdContext **
+ ** The message digest is now in mdContext->digest[0...15] **
+ ***********************************************************************
+ */
+
+/* forward declaration */
+static void Transform ();
+
+static unsigned char PADDING[64] = {
+ 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+/* F, G, H and I are basic MD5 functions */
+#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
+#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
+#define H(x, y, z) ((x) ^ (y) ^ (z))
+#define I(x, y, z) ((y) ^ ((x) | (~z)))
+
+/* ROTATE_LEFT rotates x left n bits */
+#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
+
+/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4 */
+/* Rotation is separate from addition to prevent recomputation */
+#define FF(a, b, c, d, x, s, ac) \
+ {(a) += F ((b), (c), (d)) + (x) + (UINT4)(ac); \
+ (a) = ROTATE_LEFT ((a), (s)); \
+ (a) += (b); \
+ }
+#define GG(a, b, c, d, x, s, ac) \
+ {(a) += G ((b), (c), (d)) + (x) + (UINT4)(ac); \
+ (a) = ROTATE_LEFT ((a), (s)); \
+ (a) += (b); \
+ }
+#define HH(a, b, c, d, x, s, ac) \
+ {(a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); \
+ (a) = ROTATE_LEFT ((a), (s)); \
+ (a) += (b); \
+ }
+#define II(a, b, c, d, x, s, ac) \
+ {(a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \
+ (a) = ROTATE_LEFT ((a), (s)); \
+ (a) += (b); \
+ }
+
+#ifdef __STDC__
+#define UL(x) x##U
+#else
+#define UL(x) x
+#endif
+
+/* The routine MD5_Init initializes the message-digest context
+ mdContext. All fields are set to zero.
+ */
+void MD5_Init (mdContext)
+MD5_CTX *mdContext;
+{
+ mdContext->i[0] = mdContext->i[1] = (UINT4)0;
+
+ /* Load magic initialization constants.
+ */
+ mdContext->buf[0] = (UINT4)0x67452301;
+ mdContext->buf[1] = (UINT4)0xefcdab89;
+ mdContext->buf[2] = (UINT4)0x98badcfe;
+ mdContext->buf[3] = (UINT4)0x10325476;
+}
+
+/* The routine MD5Update updates the message-digest context to
+ account for the presence of each of the characters inBuf[0..inLen-1]
+ in the message whose digest is being computed.
+ */
+void MD5_Update (mdContext, inBuf, inLen)
+MD5_CTX *mdContext;
+unsigned char *inBuf;
+unsigned int inLen;
+{
+ UINT4 in[16];
+ int mdi;
+ unsigned int i, ii;
+
+ /* compute number of bytes mod 64 */
+ mdi = (int)((mdContext->i[0] >> 3) & 0x3F);
+
+ /* update number of bits */
+ if ((mdContext->i[0] + ((UINT4)inLen << 3)) < mdContext->i[0])
+ mdContext->i[1]++;
+ mdContext->i[0] += ((UINT4)inLen << 3);
+ mdContext->i[1] += ((UINT4)inLen >> 29);
+
+ while (inLen--) {
+ /* add new character to buffer, increment mdi */
+ mdContext->in[mdi++] = *inBuf++;
+
+ /* transform if necessary */
+ if (mdi == 0x40) {
+ for (i = 0, ii = 0; i < 16; i++, ii += 4)
+ in[i] = (((UINT4)mdContext->in[ii+3]) << 24) |
+ (((UINT4)mdContext->in[ii+2]) << 16) |
+ (((UINT4)mdContext->in[ii+1]) << 8) |
+ ((UINT4)mdContext->in[ii]);
+ Transform (mdContext->buf, in);
+ mdi = 0;
+ }
+ }
+}
+
+/* The routine MD5Final terminates the message-digest computation and
+ ends with the desired message digest in mdContext->digest[0...15].
+ */
+void MD5_Final (hash, mdContext)
+unsigned char hash[];
+MD5_CTX *mdContext;
+{
+ UINT4 in[16];
+ int mdi;
+ unsigned int i, ii;
+ unsigned int padLen;
+
+ /* save number of bits */
+ in[14] = mdContext->i[0];
+ in[15] = mdContext->i[1];
+
+ /* compute number of bytes mod 64 */
+ mdi = (int)((mdContext->i[0] >> 3) & 0x3F);
+
+ /* pad out to 56 mod 64 */
+ padLen = (mdi < 56) ? (56 - mdi) : (120 - mdi);
+ MD5_Update (mdContext, PADDING, padLen);
+
+ /* append length in bits and transform */
+ for (i = 0, ii = 0; i < 14; i++, ii += 4)
+ in[i] = (((UINT4)mdContext->in[ii+3]) << 24) |
+ (((UINT4)mdContext->in[ii+2]) << 16) |
+ (((UINT4)mdContext->in[ii+1]) << 8) |
+ ((UINT4)mdContext->in[ii]);
+ Transform (mdContext->buf, in);
+
+ /* store buffer in digest */
+ for (i = 0, ii = 0; i < 4; i++, ii += 4) {
+ mdContext->digest[ii] = (unsigned char)(mdContext->buf[i] & 0xFF);
+ mdContext->digest[ii+1] =
+ (unsigned char)((mdContext->buf[i] >> 8) & 0xFF);
+ mdContext->digest[ii+2] =
+ (unsigned char)((mdContext->buf[i] >> 16) & 0xFF);
+ mdContext->digest[ii+3] =
+ (unsigned char)((mdContext->buf[i] >> 24) & 0xFF);
+ }
+ memcpy(hash, mdContext->digest, 16);
+}
+
+/* Basic MD5 step. Transforms buf based on in.
+ */
+static void Transform (buf, in)
+UINT4 *buf;
+UINT4 *in;
+{
+ UINT4 a = buf[0], b = buf[1], c = buf[2], d = buf[3];
+
+ /* Round 1 */
+#define S11 7
+#define S12 12
+#define S13 17
+#define S14 22
+ FF ( a, b, c, d, in[ 0], S11, UL(3614090360)); /* 1 */
+ FF ( d, a, b, c, in[ 1], S12, UL(3905402710)); /* 2 */
+ FF ( c, d, a, b, in[ 2], S13, UL( 606105819)); /* 3 */
+ FF ( b, c, d, a, in[ 3], S14, UL(3250441966)); /* 4 */
+ FF ( a, b, c, d, in[ 4], S11, UL(4118548399)); /* 5 */
+ FF ( d, a, b, c, in[ 5], S12, UL(1200080426)); /* 6 */
+ FF ( c, d, a, b, in[ 6], S13, UL(2821735955)); /* 7 */
+ FF ( b, c, d, a, in[ 7], S14, UL(4249261313)); /* 8 */
+ FF ( a, b, c, d, in[ 8], S11, UL(1770035416)); /* 9 */
+ FF ( d, a, b, c, in[ 9], S12, UL(2336552879)); /* 10 */
+ FF ( c, d, a, b, in[10], S13, UL(4294925233)); /* 11 */
+ FF ( b, c, d, a, in[11], S14, UL(2304563134)); /* 12 */
+ FF ( a, b, c, d, in[12], S11, UL(1804603682)); /* 13 */
+ FF ( d, a, b, c, in[13], S12, UL(4254626195)); /* 14 */
+ FF ( c, d, a, b, in[14], S13, UL(2792965006)); /* 15 */
+ FF ( b, c, d, a, in[15], S14, UL(1236535329)); /* 16 */
+
+ /* Round 2 */
+#define S21 5
+#define S22 9
+#define S23 14
+#define S24 20
+ GG ( a, b, c, d, in[ 1], S21, UL(4129170786)); /* 17 */
+ GG ( d, a, b, c, in[ 6], S22, UL(3225465664)); /* 18 */
+ GG ( c, d, a, b, in[11], S23, UL( 643717713)); /* 19 */
+ GG ( b, c, d, a, in[ 0], S24, UL(3921069994)); /* 20 */
+ GG ( a, b, c, d, in[ 5], S21, UL(3593408605)); /* 21 */
+ GG ( d, a, b, c, in[10], S22, UL( 38016083)); /* 22 */
+ GG ( c, d, a, b, in[15], S23, UL(3634488961)); /* 23 */
+ GG ( b, c, d, a, in[ 4], S24, UL(3889429448)); /* 24 */
+ GG ( a, b, c, d, in[ 9], S21, UL( 568446438)); /* 25 */
+ GG ( d, a, b, c, in[14], S22, UL(3275163606)); /* 26 */
+ GG ( c, d, a, b, in[ 3], S23, UL(4107603335)); /* 27 */
+ GG ( b, c, d, a, in[ 8], S24, UL(1163531501)); /* 28 */
+ GG ( a, b, c, d, in[13], S21, UL(2850285829)); /* 29 */
+ GG ( d, a, b, c, in[ 2], S22, UL(4243563512)); /* 30 */
+ GG ( c, d, a, b, in[ 7], S23, UL(1735328473)); /* 31 */
+ GG ( b, c, d, a, in[12], S24, UL(2368359562)); /* 32 */
+
+ /* Round 3 */
+#define S31 4
+#define S32 11
+#define S33 16
+#define S34 23
+ HH ( a, b, c, d, in[ 5], S31, UL(4294588738)); /* 33 */
+ HH ( d, a, b, c, in[ 8], S32, UL(2272392833)); /* 34 */
+ HH ( c, d, a, b, in[11], S33, UL(1839030562)); /* 35 */
+ HH ( b, c, d, a, in[14], S34, UL(4259657740)); /* 36 */
+ HH ( a, b, c, d, in[ 1], S31, UL(2763975236)); /* 37 */
+ HH ( d, a, b, c, in[ 4], S32, UL(1272893353)); /* 38 */
+ HH ( c, d, a, b, in[ 7], S33, UL(4139469664)); /* 39 */
+ HH ( b, c, d, a, in[10], S34, UL(3200236656)); /* 40 */
+ HH ( a, b, c, d, in[13], S31, UL( 681279174)); /* 41 */
+ HH ( d, a, b, c, in[ 0], S32, UL(3936430074)); /* 42 */
+ HH ( c, d, a, b, in[ 3], S33, UL(3572445317)); /* 43 */
+ HH ( b, c, d, a, in[ 6], S34, UL( 76029189)); /* 44 */
+ HH ( a, b, c, d, in[ 9], S31, UL(3654602809)); /* 45 */
+ HH ( d, a, b, c, in[12], S32, UL(3873151461)); /* 46 */
+ HH ( c, d, a, b, in[15], S33, UL( 530742520)); /* 47 */
+ HH ( b, c, d, a, in[ 2], S34, UL(3299628645)); /* 48 */
+
+ /* Round 4 */
+#define S41 6
+#define S42 10
+#define S43 15
+#define S44 21
+ II ( a, b, c, d, in[ 0], S41, UL(4096336452)); /* 49 */
+ II ( d, a, b, c, in[ 7], S42, UL(1126891415)); /* 50 */
+ II ( c, d, a, b, in[14], S43, UL(2878612391)); /* 51 */
+ II ( b, c, d, a, in[ 5], S44, UL(4237533241)); /* 52 */
+ II ( a, b, c, d, in[12], S41, UL(1700485571)); /* 53 */
+ II ( d, a, b, c, in[ 3], S42, UL(2399980690)); /* 54 */
+ II ( c, d, a, b, in[10], S43, UL(4293915773)); /* 55 */
+ II ( b, c, d, a, in[ 1], S44, UL(2240044497)); /* 56 */
+ II ( a, b, c, d, in[ 8], S41, UL(1873313359)); /* 57 */
+ II ( d, a, b, c, in[15], S42, UL(4264355552)); /* 58 */
+ II ( c, d, a, b, in[ 6], S43, UL(2734768916)); /* 59 */
+ II ( b, c, d, a, in[13], S44, UL(1309151649)); /* 60 */
+ II ( a, b, c, d, in[ 4], S41, UL(4149444226)); /* 61 */
+ II ( d, a, b, c, in[11], S42, UL(3174756917)); /* 62 */
+ II ( c, d, a, b, in[ 2], S43, UL( 718787259)); /* 63 */
+ II ( b, c, d, a, in[ 9], S44, UL(3951481745)); /* 64 */
+
+ buf[0] += a;
+ buf[1] += b;
+ buf[2] += c;
+ buf[3] += d;
+}
+
+/*
+ ***********************************************************************
+ ** End of md5.c **
+ ******************************** (cut) ********************************
+ */
diff --git a/package/mtd/src/.svn/text-base/md5.h.svn-base b/package/mtd/src/.svn/text-base/md5.h.svn-base
new file mode 100644
index 0000000..f7a0c96
--- /dev/null
+++ b/package/mtd/src/.svn/text-base/md5.h.svn-base
@@ -0,0 +1,65 @@
+/*
+ ***********************************************************************
+ ** md5.h -- header file for implementation of MD5 **
+ ** RSA Data Security, Inc. MD5 Message-Digest Algorithm **
+ ** Created: 2/17/90 RLR **
+ ** Revised: 12/27/90 SRD,AJ,BSK,JT Reference C version **
+ ** Revised (for MD5): RLR 4/27/91 **
+ ** -- G modified to have y&~z instead of y&z **
+ ** -- FF, GG, HH modified to add in last register done **
+ ** -- Access pattern: round 2 works mod 5, round 3 works mod 3 **
+ ** -- distinct additive constant for each step **
+ ** -- round 4 added, working mod 7 **
+ ***********************************************************************
+ */
+
+/*
+ ***********************************************************************
+ ** Copyright (C) 1990, RSA Data Security, Inc. All rights reserved. **
+ ** **
+ ** License to copy and use this software is granted provided that **
+ ** it is identified as the "RSA Data Security, Inc. MD5 Message- **
+ ** Digest Algorithm" in all material mentioning or referencing this **
+ ** software or this function. **
+ ** **
+ ** License is also granted to make and use derivative works **
+ ** provided that such works are identified as "derived from the RSA **
+ ** Data Security, Inc. MD5 Message-Digest Algorithm" in all **
+ ** material mentioning or referencing the derived work. **
+ ** **
+ ** RSA Data Security, Inc. makes no representations concerning **
+ ** either the merchantability of this software or the suitability **
+ ** of this software for any particular purpose. It is provided "as **
+ ** is" without express or implied warranty of any kind. **
+ ** **
+ ** These notices must be retained in any copies of any part of this **
+ ** documentation and/or software. **
+ ***********************************************************************
+ */
+
+#ifndef __MD5_INCLUDE__
+
+/* typedef a 32-bit type */
+#ifdef _LP64
+typedef unsigned int UINT4;
+typedef int INT4;
+#else
+typedef unsigned long UINT4;
+typedef long INT4;
+#endif
+#define _UINT4_T
+
+/* Data structure for MD5 (Message-Digest) computation */
+typedef struct {
+ UINT4 i[2]; /* number of _bits_ handled mod 2^64 */
+ UINT4 buf[4]; /* scratch buffer */
+ unsigned char in[64]; /* input buffer */
+ unsigned char digest[16]; /* actual digest after MD5Final call */
+} MD5_CTX;
+
+void MD5_Init ();
+void MD5_Update ();
+void MD5_Final ();
+
+#define __MD5_INCLUDE__
+#endif /* __MD5_INCLUDE__ */
diff --git a/package/mtd/src/.svn/text-base/mtd.c.svn-base b/package/mtd/src/.svn/text-base/mtd.c.svn-base
new file mode 100644
index 0000000..bdbaab5
--- /dev/null
+++ b/package/mtd/src/.svn/text-base/mtd.c.svn-base
@@ -0,0 +1,761 @@
+/*
+ * mtd - simple memory technology device manipulation tool
+ *
+ * Copyright (C) 2005 Waldemar Brodkorb <wbx@dass-it.de>,
+ * Copyright (C) 2005-2009 Felix Fietkau <nbd@openwrt.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License v2
+ * as published by the Free Software Foundation.
+ *
+ * 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ *
+ * The code is based on the linux-mtd examples.
+ */
+
+#include <limits.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <signal.h>
+#include <sys/ioctl.h>
+#include <sys/syscall.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <time.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/mount.h>
+#include <sys/stat.h>
+#include <sys/reboot.h>
+#include <linux/reboot.h>
+#include <mtd/mtd-user.h>
+#include "fis.h"
+#include "mtd.h"
+
+#ifndef MTDREFRESH
+#define MTDREFRESH _IO('M', 50)
+#endif
+
+#define MAX_ARGS 8
+#define JFFS2_DEFAULT_DIR "" /* directory name without /, empty means root dir */
+
+static char *buf = NULL;
+static char *imagefile = NULL;
+static char *jffs2file = NULL, *jffs2dir = JFFS2_DEFAULT_DIR;
+static int buflen = 0;
+int quiet;
+int no_erase;
+int mtdsize = 0;
+int erasesize = 0;
+
+int mtd_open(const char *mtd, bool block)
+{
+ FILE *fp;
+ char dev[PATH_MAX];
+ int i;
+ int ret;
+ int flags = O_RDWR | O_SYNC;
+
+ if ((fp = fopen("/proc/mtd", "r"))) {
+ while (fgets(dev, sizeof(dev), fp)) {
+ if (sscanf(dev, "mtd%d:", &i) && strstr(dev, mtd)) {
+ snprintf(dev, sizeof(dev), "/dev/mtd%s/%d", (block ? "block" : ""), i);
+ if ((ret=open(dev, flags))<0) {
+ snprintf(dev, sizeof(dev), "/dev/mtd%s%d", (block ? "block" : ""), i);
+ ret=open(dev, flags);
+ }
+ fclose(fp);
+ return ret;
+ }
+ }
+ fclose(fp);
+ }
+
+ return open(mtd, flags);
+}
+
+int mtd_check_open(const char *mtd)
+{
+ struct mtd_info_user mtdInfo;
+ int fd;
+
+ fd = mtd_open(mtd, false);
+ if(fd < 0) {
+ fprintf(stderr, "Could not open mtd device: %s\n", mtd);
+ return -1;
+ }
+
+ if(ioctl(fd, MEMGETINFO, &mtdInfo)) {
+ fprintf(stderr, "Could not get MTD device info from %s\n", mtd);
+ close(fd);
+ return -1;
+ }
+ mtdsize = mtdInfo.size;
+ erasesize = mtdInfo.erasesize;
+
+ return fd;
+}
+
+int mtd_erase_block(int fd, int offset)
+{
+ struct erase_info_user mtdEraseInfo;
+
+ mtdEraseInfo.start = offset;
+ mtdEraseInfo.length = erasesize;
+ ioctl(fd, MEMUNLOCK, &mtdEraseInfo);
+ if (ioctl (fd, MEMERASE, &mtdEraseInfo) < 0)
+ return -1;
+
+ return 0;
+}
+
+int mtd_write_buffer(int fd, const char *buf, int offset, int length)
+{
+ lseek(fd, offset, SEEK_SET);
+ write(fd, buf, length);
+ return 0;
+}
+
+
+static int
+image_check(int imagefd, const char *mtd)
+{
+ int ret = 1;
+ if (trx_check) {
+ ret = trx_check(imagefd, mtd, buf, &buflen);
+ }
+
+ return ret;
+}
+
+static int mtd_check(const char *mtd)
+{
+ char *next = NULL;
+ char *str = NULL;
+ int fd;
+
+ if (strchr(mtd, ':')) {
+ str = strdup(mtd);
+ mtd = str;
+ }
+
+ do {
+ next = strchr(mtd, ':');
+ if (next) {
+ *next = 0;
+ next++;
+ }
+
+ fd = mtd_check_open(mtd);
+ if (fd < 0)
+ return 0;
+
+ if (!buf)
+ buf = malloc(erasesize);
+
+ close(fd);
+ mtd = next;
+ } while (next);
+
+ if (str)
+ free(str);
+
+ return 1;
+}
+
+static int
+mtd_unlock(const char *mtd)
+{
+ struct erase_info_user mtdLockInfo;
+ char *next = NULL;
+ char *str = NULL;
+ int fd;
+
+ if (strchr(mtd, ':')) {
+ str = strdup(mtd);
+ mtd = str;
+ }
+
+ do {
+ next = strchr(mtd, ':');
+ if (next) {
+ *next = 0;
+ next++;
+ }
+
+ fd = mtd_check_open(mtd);
+ if(fd < 0) {
+ fprintf(stderr, "Could not open mtd device: %s\n", mtd);
+ exit(1);
+ }
+
+ if (quiet < 2)
+ fprintf(stderr, "Unlocking %s ...\n", mtd);
+
+ mtdLockInfo.start = 0;
+ mtdLockInfo.length = mtdsize;
+ ioctl(fd, MEMUNLOCK, &mtdLockInfo);
+ close(fd);
+ mtd = next;
+ } while (next);
+
+ if (str)
+ free(str);
+
+ return 0;
+}
+
+static int
+mtd_erase(const char *mtd)
+{
+ int fd;
+ struct erase_info_user mtdEraseInfo;
+
+ if (quiet < 2)
+ fprintf(stderr, "Erasing %s ...\n", mtd);
+
+ fd = mtd_check_open(mtd);
+ if(fd < 0) {
+ fprintf(stderr, "Could not open mtd device: %s\n", mtd);
+ exit(1);
+ }
+
+ mtdEraseInfo.length = erasesize;
+
+ for (mtdEraseInfo.start = 0;
+ mtdEraseInfo.start < mtdsize;
+ mtdEraseInfo.start += erasesize) {
+
+ ioctl(fd, MEMUNLOCK, &mtdEraseInfo);
+ if(ioctl(fd, MEMERASE, &mtdEraseInfo))
+ fprintf(stderr, "Failed to erase block on %s at 0x%x\n", mtd, mtdEraseInfo.start);
+ }
+
+ close(fd);
+ return 0;
+
+}
+
+static int
+mtd_refresh(const char *mtd)
+{
+ int fd;
+
+ if (quiet < 2)
+ fprintf(stderr, "Refreshing mtd partition %s ... ", mtd);
+
+ fd = mtd_check_open(mtd);
+ if(fd < 0) {
+ fprintf(stderr, "Could not open mtd device: %s\n", mtd);
+ exit(1);
+ }
+
+ if (ioctl(fd, MTDREFRESH, NULL)) {
+ fprintf(stderr, "Failed to refresh the MTD device\n");
+ close(fd);
+ exit(1);
+ }
+ close(fd);
+
+ if (quiet < 2)
+ fprintf(stderr, "\n");
+
+ return 0;
+}
+
+static void
+indicate_writing(const char *mtd)
+{
+ if (quiet < 2)
+ fprintf(stderr, "\nWriting from %s to %s ... ", imagefile, mtd);
+
+ if (!quiet)
+ fprintf(stderr, " [ ]");
+}
+
+static int
+mtd_write(int imagefd, const char *mtd, char *fis_layout, size_t part_offset)
+{
+ char *next = NULL;
+ char *str = NULL;
+ int fd, result;
+ ssize_t r, w, e;
+ ssize_t skip = 0;
+ uint32_t offset = 0;
+ int jffs2_replaced = 0;
+
+#ifdef FIS_SUPPORT
+ static struct fis_part new_parts[MAX_ARGS];
+ static struct fis_part old_parts[MAX_ARGS];
+ int n_new = 0, n_old = 0;
+
+ if (fis_layout) {
+ const char *tmp = mtd;
+ char *word, *brkt;
+ int ret;
+
+ memset(&old_parts, 0, sizeof(old_parts));
+ memset(&new_parts, 0, sizeof(new_parts));
+
+ do {
+ next = strchr(tmp, ':');
+ if (!next)
+ next = (char *) tmp + strlen(tmp);
+
+ memcpy(old_parts[n_old].name, tmp, next - tmp);
+
+ n_old++;
+ tmp = next + 1;
+ } while(*next);
+
+ for (word = strtok_r(fis_layout, ",", &brkt);
+ word;
+ word = strtok_r(NULL, ",", &brkt)) {
+
+ tmp = strtok(word, ":");
+ strncpy((char *) new_parts[n_new].name, tmp, sizeof(new_parts[n_new].name) - 1);
+
+ tmp = strtok(NULL, ":");
+ if (!tmp)
+ goto next;
+
+ new_parts[n_new].size = strtoul(tmp, NULL, 0);
+
+ tmp = strtok(NULL, ":");
+ if (!tmp)
+ goto next;
+
+ new_parts[n_new].loadaddr = strtoul(tmp, NULL, 16);
+next:
+ n_new++;
+ }
+ ret = fis_validate(old_parts, n_old, new_parts, n_new);
+ if (ret < 0) {
+ fprintf(stderr, "Failed to validate the new FIS partition table\n");
+ exit(1);
+ }
+ if (ret == 0)
+ fis_layout = NULL;
+ }
+#endif
+
+ if (strchr(mtd, ':')) {
+ str = strdup(mtd);
+ mtd = str;
+ }
+
+ r = 0;
+
+resume:
+ next = strchr(mtd, ':');
+ if (next) {
+ *next = 0;
+ next++;
+ }
+
+ fd = mtd_check_open(mtd);
+ if(fd < 0) {
+ fprintf(stderr, "Could not open mtd device: %s\n", mtd);
+ exit(1);
+ }
+
+ if (part_offset > 0) {
+ fprintf(stderr, "Seeking on mtd device '%s' to: %u\n", mtd, part_offset);
+ lseek(fd, part_offset, SEEK_SET);
+ }
+
+ indicate_writing(mtd);
+
+ w = e = 0;
+ for (;;) {
+ /* buffer may contain data already (from trx check or last mtd partition write attempt) */
+ while (buflen < erasesize) {
+ r = read(imagefd, buf + buflen, erasesize - buflen);
+ if (r < 0) {
+ if ((errno == EINTR) || (errno == EAGAIN))
+ continue;
+ else {
+ perror("read");
+ break;
+ }
+ }
+
+ if (r == 0)
+ break;
+
+ buflen += r;
+ }
+
+ if (buflen == 0)
+ break;
+
+ if (skip > 0) {
+ skip -= buflen;
+ buflen = 0;
+ if (skip <= 0)
+ indicate_writing(mtd);
+
+ continue;
+ }
+
+ if (jffs2file) {
+ if (memcmp(buf, JFFS2_EOF, sizeof(JFFS2_EOF) - 1) == 0) {
+ if (!quiet)
+ fprintf(stderr, "\b\b\b ");
+ if (quiet < 2)
+ fprintf(stderr, "\nAppending jffs2 data from %s to %s...", jffs2file, mtd);
+ /* got an EOF marker - this is the place to add some jffs2 data */
+ skip = mtd_replace_jffs2(mtd, fd, e, jffs2file);
+ jffs2_replaced = 1;
+
+ /* don't add it again */
+ jffs2file = NULL;
+
+ w += skip;
+ e += skip;
+ skip -= buflen;
+ buflen = 0;
+ offset = 0;
+ continue;
+ }
+ /* no EOF marker, make sure we figure out the last inode number
+ * before appending some data */
+ mtd_parse_jffs2data(buf, jffs2dir);
+ }
+
+ /* need to erase the next block before writing data to it */
+ if(!no_erase)
+ {
+ while (w + buflen > e) {
+ if (!quiet)
+ fprintf(stderr, "\b\b\b[e]");
+
+
+ if (mtd_erase_block(fd, e) < 0) {
+ if (next) {
+ if (w < e) {
+ write(fd, buf + offset, e - w);
+ offset = e - w;
+ }
+ w = 0;
+ e = 0;
+ close(fd);
+ mtd = next;
+ fprintf(stderr, "\b\b\b \n");
+ goto resume;
+ } else {
+ fprintf(stderr, "Failed to erase block\n");
+ exit(1);
+ }
+ }
+
+ /* erase the chunk */
+ e += erasesize;
+ }
+ }
+
+ if (!quiet)
+ fprintf(stderr, "\b\b\b[w]");
+
+ if ((result = write(fd, buf + offset, buflen)) < buflen) {
+ if (result < 0) {
+ fprintf(stderr, "Error writing image.\n");
+ exit(1);
+ } else {
+ fprintf(stderr, "Insufficient space.\n");
+ exit(1);
+ }
+ }
+ w += buflen;
+
+ buflen = 0;
+ offset = 0;
+ }
+
+ if (jffs2_replaced && trx_fixup) {
+ trx_fixup(fd, mtd);
+ }
+
+ if (!quiet)
+ fprintf(stderr, "\b\b\b\b ");
+
+done:
+ if (quiet < 2)
+ fprintf(stderr, "\n");
+
+#ifdef FIS_SUPPORT
+ if (fis_layout) {
+ if (fis_remap(old_parts, n_old, new_parts, n_new) < 0)
+ fprintf(stderr, "Failed to update the FIS partition table\n");
+ }
+#endif
+
+ close(fd);
+ return 0;
+}
+
+static void usage(void)
+{
+ fprintf(stderr, "Usage: mtd [<options> ...] <command> [<arguments> ...] <device>[:<device>...]\n\n"
+ "The device is in the format of mtdX (eg: mtd4) or its label.\n"
+ "mtd recognizes these commands:\n"
+ " unlock unlock the device\n"
+ " refresh refresh mtd partition\n"
+ " erase erase all data on device\n"
+ " write <imagefile>|- write <imagefile> (use - for stdin) to device\n"
+ " jffs2write <file> append <file> to the jffs2 partition on the device\n");
+ if (mtd_fixtrx) {
+ fprintf(stderr,
+ " fixtrx fix the checksum in a trx header on first boot\n");
+ }
+ if (mtd_fixseama) {
+ fprintf(stderr,
+ " fixseama fix the checksum in a seama header on first boot\n");
+ }
+ fprintf(stderr,
+ "Following options are available:\n"
+ " -q quiet mode (once: no [w] on writing,\n"
+ " twice: no status messages)\n"
+ " -n write without first erasing the blocks\n"
+ " -r reboot after successful command\n"
+ " -f force write without trx checks\n"
+ " -e <device> erase <device> before executing the command\n"
+ " -d <name> directory for jffs2write, defaults to \"tmp\"\n"
+ " -j <name> integrate <file> into jffs2 data when writing an image\n"
+ " -p write beginning at partition offset\n");
+ if (mtd_fixtrx) {
+ fprintf(stderr,
+ " -o offset offset of the image header in the partition(for fixtrx)\n");
+ }
+ fprintf(stderr,
+#ifdef FIS_SUPPORT
+ " -F <part>[:<size>[:<entrypoint>]][,<part>...]\n"
+ " alter the fis partition table to create new partitions replacing\n"
+ " the partitions provided as argument to the write command\n"
+ " (only valid together with the write command)\n"
+#endif
+ "\n"
+ "Example: To write linux.trx to mtd4 labeled as linux and reboot afterwards\n"
+ " mtd -r write linux.trx linux\n\n");
+ exit(1);
+}
+
+static void do_reboot(void)
+{
+ fprintf(stderr, "Rebooting ...\n");
+ fflush(stderr);
+
+ /* try regular reboot method first */
+ system("/sbin/reboot");
+ sleep(2);
+
+ /* if we're still alive at this point, force the kernel to reboot */
+ syscall(SYS_reboot,LINUX_REBOOT_MAGIC1,LINUX_REBOOT_MAGIC2,LINUX_REBOOT_CMD_RESTART,NULL);
+}
+
+int main (int argc, char **argv)
+{
+ int ch, i, boot, imagefd = 0, force, unlocked;
+ char *erase[MAX_ARGS], *device = NULL;
+ char *fis_layout = NULL;
+ size_t offset = 0, part_offset = 0;
+ enum {
+ CMD_ERASE,
+ CMD_WRITE,
+ CMD_UNLOCK,
+ CMD_REFRESH,
+ CMD_JFFS2WRITE,
+ CMD_FIXTRX,
+ CMD_FIXSEAMA,
+ } cmd = -1;
+
+ erase[0] = NULL;
+ boot = 0;
+ force = 0;
+ buflen = 0;
+ quiet = 0;
+ no_erase = 0;
+
+ while ((ch = getopt(argc, argv,
+#ifdef FIS_SUPPORT
+ "F:"
+#endif
+ "frnqe:d:j:p:o:")) != -1)
+ switch (ch) {
+ case 'f':
+ force = 1;
+ break;
+ case 'r':
+ boot = 1;
+ break;
+ case 'n':
+ no_erase = 1;
+ break;
+ case 'j':
+ jffs2file = optarg;
+ break;
+ case 'q':
+ quiet++;
+ break;
+ case 'e':
+ i = 0;
+ while ((erase[i] != NULL) && ((i + 1) < MAX_ARGS))
+ i++;
+
+ erase[i++] = optarg;
+ erase[i] = NULL;
+ break;
+ case 'd':
+ jffs2dir = optarg;
+ break;
+ case 'p':
+ errno = 0;
+ part_offset = strtoul(optarg, 0, 0);
+ if (errno) {
+ fprintf(stderr, "-p: illegal numeric string\n");
+ usage();
+ }
+ break;
+ case 'o':
+ if (!mtd_fixtrx) {
+ fprintf(stderr, "-o: is not available on this platform\n");
+ usage();
+ }
+ errno = 0;
+ offset = strtoul(optarg, 0, 0);
+ if (errno) {
+ fprintf(stderr, "-o: illegal numeric string\n");
+ usage();
+ }
+ break;
+#ifdef FIS_SUPPORT
+ case 'F':
+ fis_layout = optarg;
+ break;
+#endif
+ case '?':
+ default:
+ usage();
+ }
+ argc -= optind;
+ argv += optind;
+
+ if (argc < 2)
+ usage();
+
+ if ((strcmp(argv[0], "unlock") == 0) && (argc == 2)) {
+ cmd = CMD_UNLOCK;
+ device = argv[1];
+ } else if ((strcmp(argv[0], "refresh") == 0) && (argc == 2)) {
+ cmd = CMD_REFRESH;
+ device = argv[1];
+ } else if ((strcmp(argv[0], "erase") == 0) && (argc == 2)) {
+ cmd = CMD_ERASE;
+ device = argv[1];
+ } else if (((strcmp(argv[0], "fixtrx") == 0) && (argc == 2)) && mtd_fixtrx) {
+ cmd = CMD_FIXTRX;
+ device = argv[1];
+ } else if (((strcmp(argv[0], "fixseama") == 0) && (argc == 2)) && mtd_fixseama) {
+ cmd = CMD_FIXSEAMA;
+ device = argv[1];
+ } else if ((strcmp(argv[0], "write") == 0) && (argc == 3)) {
+ cmd = CMD_WRITE;
+ device = argv[2];
+
+ if (strcmp(argv[1], "-") == 0) {
+ imagefile = "<stdin>";
+ imagefd = 0;
+ } else {
+ imagefile = argv[1];
+ if ((imagefd = open(argv[1], O_RDONLY)) < 0) {
+ fprintf(stderr, "Couldn't open image file: %s!\n", imagefile);
+ exit(1);
+ }
+ }
+
+ if (!mtd_check(device)) {
+ fprintf(stderr, "Can't open device for writing!\n");
+ exit(1);
+ }
+ /* check trx file before erasing or writing anything */
+ if (!image_check(imagefd, device) && !force) {
+ fprintf(stderr, "Image check failed.\n");
+ exit(1);
+ }
+ } else if ((strcmp(argv[0], "jffs2write") == 0) && (argc == 3)) {
+ cmd = CMD_JFFS2WRITE;
+ device = argv[2];
+
+ imagefile = argv[1];
+ if (!mtd_check(device)) {
+ fprintf(stderr, "Can't open device for writing!\n");
+ exit(1);
+ }
+ } else {
+ usage();
+ }
+
+ sync();
+
+ i = 0;
+ unlocked = 0;
+ while (erase[i] != NULL) {
+ mtd_unlock(erase[i]);
+ mtd_erase(erase[i]);
+ if (strcmp(erase[i], device) == 0)
+ unlocked = 1;
+ i++;
+ }
+
+ switch (cmd) {
+ case CMD_UNLOCK:
+ if (!unlocked)
+ mtd_unlock(device);
+ break;
+ case CMD_ERASE:
+ if (!unlocked)
+ mtd_unlock(device);
+ mtd_erase(device);
+ break;
+ case CMD_WRITE:
+ if (!unlocked)
+ mtd_unlock(device);
+ mtd_write(imagefd, device, fis_layout, part_offset);
+ break;
+ case CMD_JFFS2WRITE:
+ if (!unlocked)
+ mtd_unlock(device);
+ mtd_write_jffs2(device, imagefile, jffs2dir);
+ break;
+ case CMD_REFRESH:
+ mtd_refresh(device);
+ break;
+ case CMD_FIXTRX:
+ if (mtd_fixtrx) {
+ mtd_fixtrx(device, offset);
+ }
+ case CMD_FIXSEAMA:
+ if (mtd_fixseama)
+ mtd_fixseama(device, 0);
+ break;
+ }
+
+ sync();
+
+ if (boot)
+ do_reboot();
+
+ return 0;
+}
diff --git a/package/mtd/src/.svn/text-base/mtd.h.svn-base b/package/mtd/src/.svn/text-base/mtd.h.svn-base
new file mode 100644
index 0000000..c2133fc
--- /dev/null
+++ b/package/mtd/src/.svn/text-base/mtd.h.svn-base
@@ -0,0 +1,29 @@
+#ifndef __mtd_h
+#define __mtd_h
+
+#include <stdbool.h>
+
+#ifdef target_brcm47xx
+#define target_brcm 1
+#endif
+
+#define JFFS2_EOF "\xde\xad\xc0\xde"
+
+extern int quiet;
+extern int mtdsize;
+extern int erasesize;
+
+extern int mtd_open(const char *mtd, bool block);
+extern int mtd_check_open(const char *mtd);
+extern int mtd_erase_block(int fd, int offset);
+extern int mtd_write_buffer(int fd, const char *buf, int offset, int length);
+extern int mtd_write_jffs2(const char *mtd, const char *filename, const char *dir);
+extern int mtd_replace_jffs2(const char *mtd, int fd, int ofs, const char *filename);
+extern void mtd_parse_jffs2data(const char *buf, const char *dir);
+
+/* target specific functions */
+extern int trx_fixup(int fd, const char *name) __attribute__ ((weak));
+extern int trx_check(int imagefd, const char *mtd, char *buf, int *len) __attribute__ ((weak));
+extern int mtd_fixtrx(const char *mtd, size_t offset) __attribute__ ((weak));
+extern int mtd_fixseama(const char *mtd, size_t offset) __attribute__ ((weak));
+#endif /* __mtd_h */
diff --git a/package/mtd/src/.svn/text-base/seama.c.svn-base b/package/mtd/src/.svn/text-base/seama.c.svn-base
new file mode 100644
index 0000000..b0c8bf3
--- /dev/null
+++ b/package/mtd/src/.svn/text-base/seama.c.svn-base
@@ -0,0 +1,179 @@
+/*
+ * seama.c
+ *
+ * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
+ *
+ * Based on the trx fixup code:
+ * Copyright (C) 2005 Mike Baker
+ * Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
+ *
+ * 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
+ * of the License, 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stddef.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <string.h>
+#include <errno.h>
+#include <arpa/inet.h>
+
+#include <sys/ioctl.h>
+#include <mtd/mtd-user.h>
+#include "mtd.h"
+#include "seama.h"
+#include "md5.h"
+
+#if __BYTE_ORDER == __BIG_ENDIAN
+#define STORE32_LE(X) ((((X) & 0x000000FF) << 24) | (((X) & 0x0000FF00) << 8) | (((X) & 0x00FF0000) >> 8) | (((X) & 0xFF000000) >> 24))
+#elif __BYTE_ORDER == __LITTLE_ENDIAN
+#define STORE32_LE(X) (X)
+#else
+#error unknown endianness!
+#endif
+
+ssize_t pread(int fd, void *buf, size_t count, off_t offset);
+ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset);
+
+int
+seama_fix_md5(char *buf, size_t len)
+{
+ struct seama_hdr *shdr;
+ char *data;
+ size_t msize;
+ size_t isize;
+ MD5_CTX ctx;
+ unsigned char digest[16];
+ int i;
+
+ if (len < sizeof(struct seama_hdr))
+ return -1;
+
+ shdr = (struct seama_hdr *) buf;
+ if (shdr->magic != htonl(SEAMA_MAGIC)) {
+ fprintf(stderr, "no SEAMA header found\n");
+ return -1;
+ }
+
+ isize = ntohl(shdr->size);
+ msize = ntohs(shdr->metasize);
+ if (isize == 0) {
+ /* the image contains no checksum */
+ return -1;
+ }
+
+ len -= sizeof(struct seama_hdr) + sizeof(digest) + msize;
+ if (isize > len)
+ isize = len;
+
+ data = buf + sizeof(struct seama_hdr) + sizeof(digest) + msize;
+
+ MD5_Init(&ctx);
+ MD5_Update(&ctx, data, isize);
+ MD5_Final(digest, &ctx);
+
+ if (!memcmp(digest, &buf[sizeof(struct seama_hdr)], sizeof(digest))) {
+ if (quiet < 2)
+ fprintf(stderr, "the header is fixed already\n");
+ return -1;
+ }
+
+ if (quiet < 2) {
+ fprintf(stderr, "new size:%u, new MD5: ", isize);
+ for (i = 0; i < sizeof(digest); i++)
+ fprintf(stderr, "%02x", digest[i]);
+
+ fprintf(stderr, "\n");
+ }
+
+ /* update the size in the image */
+ shdr->size = htonl(isize);
+
+ /* update the checksum in the image */
+ for (i = 0; i < sizeof(digest); i++)
+ buf[sizeof(struct seama_hdr) + i] = digest[i];
+
+ return 0;
+}
+
+int
+mtd_fixseama(const char *mtd, size_t offset)
+{
+ int fd;
+ char *buf;
+ ssize_t res;
+ size_t block_offset;
+
+ if (quiet < 2)
+ fprintf(stderr, "Trying to fix SEAMA header in %s at 0x%x...\n",
+ mtd, offset);
+
+ block_offset = offset & ~(erasesize - 1);
+ offset -= block_offset;
+
+ fd = mtd_check_open(mtd);
+ if(fd < 0) {
+ fprintf(stderr, "Could not open mtd device: %s\n", mtd);
+ exit(1);
+ }
+
+ if (block_offset + erasesize > mtdsize) {
+ fprintf(stderr, "Offset too large, device size 0x%x\n",
+ mtdsize);
+ exit(1);
+ }
+
+ buf = malloc(mtdsize);
+ if (!buf) {
+ perror("malloc");
+ exit(1);
+ }
+
+ res = pread(fd, buf, mtdsize, block_offset);
+ if (res != mtdsize) {
+ perror("pread");
+ exit(1);
+ }
+
+ if (seama_fix_md5(buf, mtdsize))
+ goto out;
+
+ if (mtd_erase_block(fd, block_offset)) {
+ fprintf(stderr, "Can't erease block at 0x%x (%s)\n",
+ block_offset, strerror(errno));
+ exit(1);
+ }
+
+ if (quiet < 2)
+ fprintf(stderr, "Rewriting block at 0x%x\n", block_offset);
+
+ if (pwrite(fd, buf, erasesize, block_offset) != erasesize) {
+ fprintf(stderr, "Error writing block (%s)\n", strerror(errno));
+ exit(1);
+ }
+
+ if (quiet < 2)
+ fprintf(stderr, "Done.\n");
+
+out:
+ close (fd);
+ sync();
+
+ return 0;
+}
+
diff --git a/package/mtd/src/.svn/text-base/seama.h.svn-base b/package/mtd/src/.svn/text-base/seama.h.svn-base
new file mode 100644
index 0000000..02683b6
--- /dev/null
+++ b/package/mtd/src/.svn/text-base/seama.h.svn-base
@@ -0,0 +1,108 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * (SEA)ttle i(MA)ge is the image which used in project seattle.
+ *
+ * Created by David Hsieh <david_hsieh@alphanetworks.com>
+ * Copyright (C) 2008-2009 Alpha Networks, Inc.
+ *
+ * This file is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either'
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * The GNU C Library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the GNU C Library; if not, write to the Free
+ * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ * 02111-1307 USA.
+ */
+
+#ifndef __SEAMA_HEADER_FILE__
+#define __SEAMA_HEADER_FILE__
+
+#include <stdint.h>
+
+#define SEAMA_MAGIC 0x5EA3A417
+
+/*
+ * SEAMA looks like the following map.
+ * All the data of the header should be in network byte order.
+ *
+ * +-------------+-------------+------------
+ * | SEAMA magic | ^
+ * +-------------+-------------+ |
+ * | reserved | meta size | |
+ * +-------------+-------------+ header
+ * | image size (0 bytes) | |
+ * +-------------+-------------+ |
+ * ~ Meta data ~ v
+ * +-------------+-------------+------------
+ * | SEAMA magic | ^ ^
+ * +-------------+-------------+ | |
+ * | reserved | meta size | | |
+ * +-------------+-------------+ | |
+ * | image size | | |
+ * +-------------+-------------+ header |
+ * | | | |
+ * | 16 bytes of MD5 digest | | |
+ * | | | |
+ * | | | |
+ * +-------------+-------------+ | |
+ * ~ Meta data ~ v |
+ * +-------------+-------------+------- |
+ * | | |
+ * | Image of the 1st entity | |
+ * ~ ~ 1st entity
+ * | | |
+ * | | v
+ * +-------------+-------------+-------------
+ * | SEAMA magic | ^ ^
+ * +-------------+-------------+ | |
+ * | reserved | meta size | | |
+ * +-------------+-------------+ | |
+ * | image size | | |
+ * +-------------+-------------+ header |
+ * | | | |
+ * | 16 bytes of MD5 digest | | |
+ * | | | |
+ * | | | |
+ * +-------------+-------------+ | |
+ * ~ Meta data ~ v |
+ * +-------------+-------------+------- |
+ * | | |
+ * | Image of the 2nd entity | |
+ * ~ ~ 2nd entity
+ * | | |
+ * | | v
+ * +-------------+-------------+-------------
+ */
+
+
+/*
+ * SEAMA header
+ *
+ * |<-------- 32 bits -------->|
+ * +-------------+-------------+
+ * | SEAMA magic |
+ * +-------------+-------------+
+ * | reserved | meta size |
+ * +-------------+-------------+
+ * | image size |
+ * +-------------+-------------+
+ */
+/* seama header */
+typedef struct seama_hdr seamahdr_t;
+struct seama_hdr
+{
+ uint32_t magic; /* should always be SEAMA_MAGIC. */
+ uint16_t reserved; /* reserved for */
+ uint16_t metasize; /* size of the META data */
+ uint32_t size; /* size of the image */
+} __attribute__ ((packed));
+
+
+#endif
diff --git a/package/mtd/src/.svn/text-base/trx.c.svn-base b/package/mtd/src/.svn/text-base/trx.c.svn-base
new file mode 100644
index 0000000..65c2440
--- /dev/null
+++ b/package/mtd/src/.svn/text-base/trx.c.svn-base
@@ -0,0 +1,220 @@
+/*
+ * trx.c
+ *
+ * Copyright (C) 2005 Mike Baker
+ * Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
+ *
+ * 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
+ * of the License, 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stddef.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <string.h>
+#include <errno.h>
+
+#include <sys/ioctl.h>
+#include <mtd/mtd-user.h>
+#include "mtd.h"
+#include "crc32.h"
+
+#define TRX_MAGIC 0x30524448 /* "HDR0" */
+struct trx_header {
+ uint32_t magic; /* "HDR0" */
+ uint32_t len; /* Length of file including header */
+ uint32_t crc32; /* 32-bit CRC from flag_version to end of file */
+ uint32_t flag_version; /* 0:15 flags, 16:31 version */
+ uint32_t offsets[3]; /* Offsets of partitions from start of header */
+};
+
+#if __BYTE_ORDER == __BIG_ENDIAN
+#define STORE32_LE(X) ((((X) & 0x000000FF) << 24) | (((X) & 0x0000FF00) << 8) | (((X) & 0x00FF0000) >> 8) | (((X) & 0xFF000000) >> 24))
+#elif __BYTE_ORDER == __LITTLE_ENDIAN
+#define STORE32_LE(X) (X)
+#else
+#error unknown endianness!
+#endif
+
+ssize_t pread(int fd, void *buf, size_t count, off_t offset);
+ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset);
+
+int
+trx_fixup(int fd, const char *name)
+{
+ struct mtd_info_user mtdInfo;
+ unsigned long len;
+ struct trx_header *trx;
+ void *ptr, *scan;
+ int bfd;
+
+ if (ioctl(fd, MEMGETINFO, &mtdInfo) < 0) {
+ fprintf(stderr, "Failed to get mtd info\n");
+ goto err;
+ }
+
+ len = mtdInfo.size;
+ if (mtdInfo.size <= 0) {
+ fprintf(stderr, "Invalid MTD device size\n");
+ goto err;
+ }
+
+ bfd = mtd_open(name, true);
+ ptr = mmap(NULL, len, PROT_READ|PROT_WRITE, MAP_SHARED, bfd, 0);
+ if (!ptr || (ptr == (void *) -1)) {
+ perror("mmap");
+ goto err1;
+ }
+
+ trx = ptr;
+ if (trx->magic != TRX_MAGIC) {
+ fprintf(stderr, "TRX header not found\n");
+ goto err;
+ }
+
+ scan = ptr + offsetof(struct trx_header, flag_version);
+ trx->crc32 = crc32buf(scan, trx->len - (scan - ptr));
+ msync(ptr, sizeof(struct trx_header), MS_SYNC|MS_INVALIDATE);
+ munmap(ptr, len);
+ close(bfd);
+ return 0;
+
+err1:
+ close(bfd);
+err:
+ fprintf(stderr, "Error fixing up TRX header\n");
+ return -1;
+}
+
+int
+trx_check(int imagefd, const char *mtd, char *buf, int *len)
+{
+ const struct trx_header *trx = (const struct trx_header *) buf;
+ int fd;
+
+ if (strcmp(mtd, "linux") != 0)
+ return 1;
+
+ *len = read(imagefd, buf, 32);
+ if (*len < 32) {
+ fprintf(stdout, "Could not get image header, file too small (%d bytes)\n", *len);
+ return 0;
+ }
+
+ if (trx->magic != TRX_MAGIC || trx->len < sizeof(struct trx_header)) {
+ if (quiet < 2) {
+ fprintf(stderr, "Bad trx header\n");
+ fprintf(stderr, "This is not the correct file format; refusing to flash.\n"
+ "Please specify the correct file or use -f to force.\n");
+ }
+ return 0;
+ }
+
+ /* check if image fits to mtd device */
+ fd = mtd_check_open(mtd);
+ if(fd < 0) {
+ fprintf(stderr, "Could not open mtd device: %s\n", mtd);
+ exit(1);
+ }
+
+ if(mtdsize < trx->len) {
+ fprintf(stderr, "Image too big for partition: %s\n", mtd);
+ close(fd);
+ return 0;
+ }
+
+ close(fd);
+ return 1;
+}
+
+int
+mtd_fixtrx(const char *mtd, size_t offset)
+{
+ int fd;
+ struct trx_header *trx;
+ char *buf;
+ ssize_t res;
+ size_t block_offset;
+
+ if (quiet < 2)
+ fprintf(stderr, "Trying to fix trx header in %s at 0x%x...\n", mtd, offset);
+
+ fd = mtd_check_open(mtd);
+ if(fd < 0) {
+ fprintf(stderr, "Could not open mtd device: %s\n", mtd);
+ exit(1);
+ }
+
+ block_offset = offset & ~(erasesize - 1);
+ offset -= block_offset;
+
+ if (block_offset + erasesize > mtdsize) {
+ fprintf(stderr, "Offset too large, device size 0x%x\n", mtdsize);
+ exit(1);
+ }
+
+ buf = malloc(erasesize);
+ if (!buf) {
+ perror("malloc");
+ exit(1);
+ }
+
+ res = pread(fd, buf, erasesize, block_offset);
+ if (res != erasesize) {
+ perror("pread");
+ exit(1);
+ }
+
+ trx = (struct trx_header *) (buf + offset);
+ if (trx->magic != STORE32_LE(0x30524448)) {
+ fprintf(stderr, "No trx magic found\n");
+ exit(1);
+ }
+
+ if (trx->len == STORE32_LE(erasesize - offset)) {
+ if (quiet < 2)
+ fprintf(stderr, "Header already fixed, exiting\n");
+ close(fd);
+ return 0;
+ }
+
+ trx->len = STORE32_LE(erasesize - offset);
+
+ trx->crc32 = STORE32_LE(crc32buf((char*) &trx->flag_version, erasesize - offset - 3*4));
+ if (mtd_erase_block(fd, block_offset)) {
+ fprintf(stderr, "Can't erease block at 0x%x (%s)\n", block_offset, strerror(errno));
+ exit(1);
+ }
+
+ if (quiet < 2)
+ fprintf(stderr, "New crc32: 0x%x, rewriting block\n", trx->crc32);
+
+ if (pwrite(fd, buf, erasesize, block_offset) != erasesize) {
+ fprintf(stderr, "Error writing block (%s)\n", strerror(errno));
+ exit(1);
+ }
+
+ if (quiet < 2)
+ fprintf(stderr, "Done.\n");
+
+ close (fd);
+ sync();
+ return 0;
+
+}
+
diff --git a/package/mtd/src/Makefile b/package/mtd/src/Makefile
new file mode 100644
index 0000000..4e6aee8
--- /dev/null
+++ b/package/mtd/src/Makefile
@@ -0,0 +1,18 @@
+CC = gcc
+CFLAGS += -Wall
+
+obj = mtd.o jffs2.o crc32.o
+obj.seama = seama.o md5.o
+obj.ar71xx = trx.o
+obj.brcm = trx.o
+obj.brcm47xx = $(obj.brcm)
+obj.brcm63xx = imagetag.o
+obj.ramips = $(obj.seama)
+
+ifdef FIS_SUPPORT
+ obj += fis.o
+endif
+
+mtd: $(obj) $(obj.$(TARGET))
+clean:
+ rm -f *.o jffs2
diff --git a/package/mtd/src/crc32.c b/package/mtd/src/crc32.c
new file mode 100644
index 0000000..6b1e50c
--- /dev/null
+++ b/package/mtd/src/crc32.c
@@ -0,0 +1,95 @@
+/*
+ * COPYRIGHT (C) 1986 Gary S. Brown. You may use this program, or
+ * code or tables extracted from it, as desired without restriction.
+ *
+ * First, the polynomial itself and its table of feedback terms. The
+ * polynomial is
+ * X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0
+ *
+ * Note that we take it "backwards" and put the highest-order term in
+ * the lowest-order bit. The X^32 term is "implied"; the LSB is the
+ * X^31 term, etc. The X^0 term (usually shown as "+1") results in
+ * the MSB being 1
+ *
+ * Note that the usual hardware shift register implementation, which
+ * is what we're using (we're merely optimizing it by doing eight-bit
+ * chunks at a time) shifts bits into the lowest-order term. In our
+ * implementation, that means shifting towards the right. Why do we
+ * do it this way? Because the calculated CRC must be transmitted in
+ * order from highest-order term to lowest-order term. UARTs transmit
+ * characters in order from LSB to MSB. By storing the CRC this way
+ * we hand it to the UART in the order low-byte to high-byte; the UART
+ * sends each low-bit to hight-bit; and the result is transmission bit
+ * by bit from highest- to lowest-order term without requiring any bit
+ * shuffling on our part. Reception works similarly
+ *
+ * The feedback terms table consists of 256, 32-bit entries. Notes
+ *
+ * The table can be generated at runtime if desired; code to do so
+ * is shown later. It might not be obvious, but the feedback
+ * terms simply represent the results of eight shift/xor opera
+ * tions for all combinations of data and CRC register values
+ *
+ * The values must be right-shifted by eight bits by the "updcrc
+ * logic; the shift must be unsigned (bring in zeroes). On some
+ * hardware you could probably optimize the shift in assembler by
+ * using byte-swap instructions
+ * polynomial $edb88320
+ */
+
+#include <stdint.h>
+
+const uint32_t crc32_table[256] = {
+ 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
+ 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
+ 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
+ 0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL,
+ 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L,
+ 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L,
+ 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L,
+ 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,
+ 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L,
+ 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL,
+ 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L,
+ 0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L,
+ 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L,
+ 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL,
+ 0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL,
+ 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,
+ 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL,
+ 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L,
+ 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L,
+ 0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L,
+ 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL,
+ 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L,
+ 0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L,
+ 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,
+ 0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L,
+ 0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L,
+ 0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L,
+ 0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L,
+ 0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L,
+ 0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL,
+ 0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL,
+ 0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,
+ 0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L,
+ 0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL,
+ 0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL,
+ 0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L,
+ 0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL,
+ 0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L,
+ 0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL,
+ 0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,
+ 0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL,
+ 0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L,
+ 0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L,
+ 0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL,
+ 0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L,
+ 0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L,
+ 0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L,
+ 0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,
+ 0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L,
+ 0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L,
+ 0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL,
+ 0x2d02ef8dL
+};
diff --git a/package/mtd/src/crc32.h b/package/mtd/src/crc32.h
new file mode 100644
index 0000000..68f8ee4
--- /dev/null
+++ b/package/mtd/src/crc32.h
@@ -0,0 +1,26 @@
+#ifndef CRC32_H
+#define CRC32_H
+
+#include <stdint.h>
+
+extern const uint32_t crc32_table[256];
+
+/* Return a 32-bit CRC of the contents of the buffer. */
+
+static inline uint32_t
+crc32(uint32_t val, const void *ss, int len)
+{
+ const unsigned char *s = ss;
+ while (--len >= 0)
+ val = crc32_table[(val ^ *s++) & 0xff] ^ (val >> 8);
+ return val;
+}
+
+static inline unsigned int crc32buf(char *buf, size_t len)
+{
+ return crc32(0xFFFFFFFF, buf, len);
+}
+
+
+
+#endif
diff --git a/package/mtd/src/fis.c b/package/mtd/src/fis.c
new file mode 100644
index 0000000..f825f59
--- /dev/null
+++ b/package/mtd/src/fis.c
@@ -0,0 +1,262 @@
+/*
+ * FIS table updating code for mtd
+ *
+ * Copyright (C) 2009 Felix Fietkau <nbd@openwrt.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License v2
+ * as published by the Free Software Foundation.
+ *
+ * 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.
+ */
+#include <sys/mman.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <stdio.h>
+#include "crc32.h"
+#include "mtd.h"
+#include "fis.h"
+
+struct fis_image_hdr {
+ unsigned char name[16];
+ uint32_t flash_base;
+ uint32_t mem_base;
+ uint32_t size;
+ uint32_t entry_point;
+ uint32_t data_length;
+} __attribute__((packed));
+
+struct fis_image_crc {
+ uint32_t desc;
+ uint32_t file;
+} __attribute__((packed));
+
+struct fis_image_desc {
+ struct fis_image_hdr hdr;
+ char _pad[256 - sizeof(struct fis_image_hdr) - sizeof(struct fis_image_crc)];
+ struct fis_image_crc crc;
+} __attribute__((packed));
+
+static int fis_fd = -1;
+static struct fis_image_desc *fis_desc;
+static int fis_erasesize = 0;
+
+static void
+fis_close(void)
+{
+ if (fis_desc)
+ munmap(fis_desc, fis_erasesize);
+
+ if (fis_fd >= 0)
+ close(fis_fd);
+
+ fis_fd = -1;
+ fis_desc = NULL;
+}
+
+static struct fis_image_desc *
+fis_open(void)
+{
+ struct fis_image_desc *desc;
+
+ if (fis_fd >= 0)
+ fis_close();
+
+ fis_fd = mtd_check_open("FIS directory");
+ if (fis_fd < 0)
+ goto error;
+
+ close(fis_fd);
+ fis_fd = mtd_open("FIS directory", true);
+ if (fis_fd < 0)
+ goto error;
+
+ fis_erasesize = erasesize;
+ desc = mmap(NULL, erasesize, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_LOCKED, fis_fd, 0);
+ if (desc == MAP_FAILED)
+ goto error;
+
+ fis_desc = desc;
+ return desc;
+
+error:
+ fis_close();
+ return NULL;
+}
+
+int
+fis_validate(struct fis_part *old, int n_old, struct fis_part *new, int n_new)
+{
+ struct fis_image_desc *desc;
+ void *end;
+ int found = 0;
+ int i;
+
+ desc = fis_open();
+ if (!desc)
+ return -1;
+
+ for (i = 0; i < n_new - 1; i++) {
+ if (!new[i].size) {
+ fprintf(stderr, "FIS error: only the last partition can detect the size automatically\n");
+ i = -1;
+ goto done;
+ }
+ }
+
+ end = desc;
+ end = (char *) end + fis_erasesize;
+ while ((void *) desc < end) {
+ if (!desc->hdr.name[0] || (desc->hdr.name[0] == 0xff))
+ break;
+
+ for (i = 0; i < n_old; i++) {
+ if (!strncmp((char *) desc->hdr.name, (char *) old[i].name, sizeof(desc->hdr.name))) {
+ found++;
+ goto next;
+ }
+ }
+next:
+ desc++;
+ continue;
+ }
+
+ if (found == n_old)
+ i = 1;
+ else
+ i = -1;
+
+done:
+ fis_close();
+ return i;
+}
+
+int
+fis_remap(struct fis_part *old, int n_old, struct fis_part *new, int n_new)
+{
+ struct fis_image_desc *fisdir = NULL;
+ struct fis_image_desc *redboot = NULL;
+ struct fis_image_desc *first = NULL;
+ struct fis_image_desc *last = NULL;
+ struct fis_image_desc *first_fb = NULL;
+ struct fis_image_desc *last_fb = NULL;
+ struct fis_image_desc *desc;
+ struct fis_part *part;
+ uint32_t offset = 0, size = 0;
+ char *start, *end, *tmp;
+ int i;
+
+ desc = fis_open();
+ if (!desc)
+ return -1;
+
+ if (!quiet)
+ fprintf(stderr, "Updating FIS table... \n");
+
+ start = (char *) desc;
+ end = (char *) desc + fis_erasesize;
+ while ((char *) desc < end) {
+ if (!desc->hdr.name[0] || (desc->hdr.name[0] == 0xff))
+ break;
+
+ if (!strcmp((char *) desc->hdr.name, "FIS directory"))
+ fisdir = desc;
+
+ if (!strcmp((char *) desc->hdr.name, "RedBoot"))
+ redboot = desc;
+
+ /* update max offset */
+ if (offset < desc->hdr.flash_base)
+ offset = desc->hdr.flash_base;
+
+ for (i = 0; i < n_old; i++) {
+ if (!strncmp((char *) desc->hdr.name, (char *) old[i].name, sizeof(desc->hdr.name))) {
+ last = desc;
+ if (!first)
+ first = desc;
+ break;
+ }
+ }
+ desc++;
+ }
+ desc--;
+
+ first_fb = first;
+ last_fb = last;
+
+ if (first_fb->hdr.flash_base > last_fb->hdr.flash_base) {
+ first_fb = last;
+ last_fb = first;
+ }
+
+ /* determine size of available space */
+ desc = (struct fis_image_desc *) start;
+ while ((char *) desc < end) {
+ if (!desc->hdr.name[0] || (desc->hdr.name[0] == 0xff))
+ break;
+
+ if (desc->hdr.flash_base > last_fb->hdr.flash_base &&
+ desc->hdr.flash_base < offset)
+ offset = desc->hdr.flash_base;
+
+ desc++;
+ }
+ desc--;
+
+ size = offset - first_fb->hdr.flash_base;
+
+#ifdef notyet
+ desc = first - 1;
+ if (redboot && (desc >= redboot)) {
+ if (first->hdr.flash_base - desc->hdr.size > desc->hdr.flash_base) {
+ int delta = first->hdr.flash_base - desc->hdr.size - desc->hdr.flash_base;
+
+ offset -= delta;
+ size += delta;
+ }
+ }
+#endif
+
+ last++;
+ desc = first + n_new;
+ offset = first_fb->hdr.flash_base;
+
+ if (desc != last) {
+ if (desc > last)
+ tmp = (char *) desc;
+ else
+ tmp = (char *) last;
+
+ memmove(desc, last, end - tmp);
+ if (desc < last) {
+ tmp = end - (last - desc) * sizeof(struct fis_image_desc);
+ memset(tmp, 0xff, tmp - end);
+ }
+ }
+
+ for (part = new, desc = first; desc < first + n_new; desc++, part++) {
+ memset(desc, 0, sizeof(struct fis_image_desc));
+ memcpy(desc->hdr.name, part->name, sizeof(desc->hdr.name));
+ desc->crc.desc = 0;
+ desc->crc.file = 0;
+
+ desc->hdr.flash_base = offset;
+ desc->hdr.mem_base = part->loadaddr;
+ desc->hdr.entry_point = part->loadaddr;
+ desc->hdr.size = (part->size > 0) ? part->size : size;
+ desc->hdr.data_length = desc->hdr.size;
+
+ offset += desc->hdr.size;
+ size -= desc->hdr.size;
+ }
+
+ msync(fis_desc, fis_erasesize, MS_SYNC|MS_INVALIDATE);
+ fis_close();
+
+ return 0;
+}
diff --git a/package/mtd/src/fis.h b/package/mtd/src/fis.h
new file mode 100644
index 0000000..bdf1103
--- /dev/null
+++ b/package/mtd/src/fis.h
@@ -0,0 +1,14 @@
+#ifndef __FIS_H
+#define __FIS_H
+
+struct fis_part {
+ unsigned char name[16];
+ uint32_t offset;
+ uint32_t loadaddr;
+ uint32_t size;
+};
+
+int fis_validate(struct fis_part *old, int n_old, struct fis_part *new, int n_new);
+int fis_remap(struct fis_part *old, int n_old, struct fis_part *new, int n_new);
+
+#endif
diff --git a/package/mtd/src/imagetag.c b/package/mtd/src/imagetag.c
new file mode 100644
index 0000000..a53c17a
--- /dev/null
+++ b/package/mtd/src/imagetag.c
@@ -0,0 +1,316 @@
+/*
+ * imagetag.c
+ *
+ * Copyright (C) 2005 Mike Baker
+ * Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
+ * Copyrigth (C) 2010 Daniel Dickinson <openwrt@cshore.neomailbox.net>
+ *
+ * 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
+ * of the License, 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stddef.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <string.h>
+#include <errno.h>
+
+#include <sys/ioctl.h>
+#include <mtd/mtd-user.h>
+#include <linux/bcm963xx_tag.h>
+
+#include "mtd.h"
+#include "crc32.h"
+
+ssize_t pread(int fd, void *buf, size_t count, off_t offset);
+ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset);
+
+#define CRC_START 0xFFFFFFFF
+
+static uint32_t strntoul(char *str, char **endptr, int base, size_t len) {
+ char *newstr;
+ uint32_t res = 0;
+
+ newstr = calloc(len + 1, sizeof(char));
+ if (newstr) {
+ strncpy(newstr, str, len);
+ res = strtoul(newstr, endptr, base);
+ free(newstr);
+ }
+ return res;
+}
+
+uint32_t compute_crc32(uint32_t crc, off_t start, size_t compute_len, int fd)
+{
+ uint8_t readbuf[1024];
+ ssize_t res;
+ off_t offset = start;
+
+ /* Read a buffer's worth of bytes */
+ while (fd && (compute_len >= sizeof(readbuf))) {
+ res = pread(fd, readbuf, sizeof(readbuf), offset);
+ crc = crc32(crc, readbuf, res);
+ compute_len = compute_len - res;
+ offset += res;
+ }
+
+ /* Less than buffer-size bytes remains, read compute_len bytes */
+ if (fd && (compute_len > 0)) {
+ res = pread(fd, readbuf, compute_len, offset);
+ crc = crc32(crc, readbuf, res);
+ }
+
+ return crc;
+}
+
+int
+trx_fixup(int fd, const char *name)
+{
+ struct mtd_info_user mtdInfo;
+ unsigned long len;
+ void *ptr, *scan;
+ int bfd;
+ struct bcm_tag *tag;
+ ssize_t res;
+ uint32_t cfelen, imagelen, imagestart, rootfslen;
+ uint32_t imagecrc, rootfscrc, headercrc;
+ uint32_t offset = 0;
+ cfelen = imagelen = imagestart = imagecrc = rootfscrc = headercrc = rootfslen = 0;
+
+
+ if (ioctl(fd, MEMGETINFO, &mtdInfo) < 0) {
+ fprintf(stderr, "Failed to get mtd info\n");
+ goto err;
+ }
+
+ len = mtdInfo.size;
+ if (mtdInfo.size <= 0) {
+ fprintf(stderr, "Invalid MTD device size\n");
+ goto err;
+ }
+
+ bfd = mtd_open(name, true);
+ ptr = mmap(NULL, len, PROT_READ|PROT_WRITE, MAP_SHARED, bfd, 0);
+ if (!ptr || (ptr == (void *) -1)) {
+ perror("mmap");
+ goto err1;
+ }
+
+ tag = (struct bcm_tag *) (ptr);
+
+ cfelen = strntoul(&tag->cfe_length[0], NULL, 10, IMAGE_LEN);
+ if (cfelen) {
+ fprintf(stderr, "Non-zero CFE length. This is currently unsupported.\n");
+ exit(1);
+ }
+
+ headercrc = compute_crc32(CRC_START, offset, offsetof(struct bcm_tag, header_crc), fd);
+ if (headercrc != *(uint32_t *)(&tag->header_crc)) {
+ fprintf(stderr, "Tag verify failed. This may not be a valid image.\n");
+ exit(1);
+ }
+
+ sprintf(&tag->root_length[0], "%u", 0);
+ strncpy(&tag->total_length[0], &tag->kernel_length[0], IMAGE_LEN);
+
+ imagestart = sizeof(tag);
+ memcpy(&tag->image_crc, &tag->kernel_crc, sizeof(uint32_t));
+ memcpy(&tag->fskernel_crc, &tag->kernel_crc, sizeof(uint32_t));
+ rootfscrc = CRC_START;
+ memcpy(&tag->rootfs_crc, &rootfscrc, sizeof(uint32_t));
+ headercrc = crc32(CRC_START, tag, offsetof(struct bcm_tag, header_crc));
+ memcpy(&tag->header_crc, &headercrc, sizeof(uint32_t));
+
+ msync(ptr, sizeof(struct bcm_tag), MS_SYNC|MS_INVALIDATE);
+ munmap(ptr, len);
+ close(bfd);
+ return 0;
+
+err1:
+ close(bfd);
+err:
+ fprintf(stderr, "Error fixing up imagetag header\n");
+ return -1;
+}
+
+
+int
+trx_check(int imagefd, const char *mtd, char *buf, int *len)
+{
+ struct bcm_tag *tag = (const struct bcm_tag *) buf;
+ int fd;
+ uint32_t headerCRC;
+ uint32_t imageLen;
+
+ if (strcmp(mtd, "linux") != 0)
+ return 1;
+
+ *len = read(imagefd, buf, sizeof(struct bcm_tag));
+ if (*len < sizeof(struct bcm_tag)) {
+ fprintf(stdout, "Could not get image header, file too small (%d bytes)\n", *len);
+ return 0;
+ }
+ headerCRC = crc32buf(buf, offsetof(struct bcm_tag, header_crc));
+ if (*(uint32_t *)(&tag->header_crc) != headerCRC) {
+
+ if (quiet < 2) {
+ fprintf(stderr, "Bad header CRC got %08x, calculated %08x\n",
+ *(uint32_t *)(&tag->header_crc), headerCRC);
+ fprintf(stderr, "This is not the correct file format; refusing to flash.\n"
+ "Please specify the correct file or use -f to force.\n");
+ }
+ return 0;
+ }
+
+ /* check if image fits to mtd device */
+ fd = mtd_check_open(mtd);
+ if(fd < 0) {
+ fprintf(stderr, "Could not open mtd device: %s\n", mtd);
+ exit(1);
+ }
+
+ imageLen = strntoul(&tag->total_length[0], NULL, 10, IMAGE_LEN);
+
+ if(mtdsize < imageLen) {
+ fprintf(stderr, "Image too big for partition: %s\n", mtd);
+ close(fd);
+ return 0;
+ }
+
+ close(fd);
+ return 1;
+}
+
+int
+mtd_fixtrx(const char *mtd, size_t offset)
+{
+ int fd;
+ struct bcm_tag *tag;
+ char *buf;
+ ssize_t res;
+ size_t block_offset;
+ uint32_t cfelen, imagelen, imagestart, rootfslen;
+ uint32_t imagecrc, rootfscrc, headercrc;
+ cfelen = imagelen = imagestart = imagecrc = rootfscrc = headercrc = rootfslen = 0;
+
+ if (quiet < 2)
+ fprintf(stderr, "Trying to fix trx header in %s at 0x%x...\n", mtd, offset);
+
+ block_offset = offset & ~(erasesize - 1);
+ offset -= block_offset;
+
+ fd = mtd_check_open(mtd);
+ if(fd < 0) {
+ fprintf(stderr, "Could not open mtd device: %s\n", mtd);
+ exit(1);
+ }
+
+ if (block_offset + erasesize > mtdsize) {
+ fprintf(stderr, "Offset too large, device size 0x%x\n", mtdsize);
+ exit(1);
+ }
+
+ buf = malloc(erasesize);
+ if (!buf) {
+ perror("malloc");
+ exit(1);
+ }
+
+ res = pread(fd, buf, erasesize, block_offset);
+ if (res != erasesize) {
+ perror("pread");
+ exit(1);
+ }
+
+ tag = (struct bcm_tag *) (buf + offset);
+
+ cfelen = strntoul(tag->cfe_length, NULL, 10, IMAGE_LEN);
+ if (cfelen) {
+ fprintf(stderr, "Non-zero CFE length. This is currently unsupported.\n");
+ exit(1);
+ }
+
+ if (quiet < 2) {
+ fprintf(stderr, "Verifying we actually have an imagetag.\n");
+ }
+
+ headercrc = compute_crc32(CRC_START, offset, offsetof(struct bcm_tag, header_crc), fd);
+ if (headercrc != *(uint32_t *)(&tag->header_crc)) {
+ fprintf(stderr, "Tag verify failed. This may not be a valid image.\n");
+ exit(1);
+ }
+
+ if (quiet < 2) {
+ fprintf(stderr, "Checking current fixed status.\n");
+ }
+
+ rootfslen = strntoul(&tag->root_length[0], NULL, 10, IMAGE_LEN);
+ if (rootfslen == 0) {
+ if (quiet < 2)
+ fprintf(stderr, "Header already fixed, exiting\n");
+ close(fd);
+ return 0;
+ }
+
+ if (quiet < 2) {
+ fprintf(stderr, "Setting root length to 0.\n");
+ }
+
+ sprintf(&tag->root_length[0], "%u", 0);
+ strncpy(&tag->total_length[0], &tag->kernel_length[0], IMAGE_LEN);
+
+ if (quiet < 2) {
+ fprintf(stderr, "Recalculating CRCs.\n");
+ }
+
+ imagestart = sizeof(tag);
+ memcpy(&tag->image_crc, &tag->kernel_crc, sizeof(uint32_t));
+ memcpy(&tag->fskernel_crc, &tag->kernel_crc, sizeof(uint32_t));
+ rootfscrc = CRC_START;
+ memcpy(&tag->rootfs_crc, &rootfscrc, sizeof(uint32_t));
+ headercrc = crc32(CRC_START, tag, offsetof(struct bcm_tag, header_crc));
+ memcpy(&tag->header_crc, &headercrc, sizeof(uint32_t));
+
+ if (quiet < 2) {
+ fprintf(stderr, "Erasing imagetag block\n");
+ }
+
+ if (mtd_erase_block(fd, block_offset)) {
+ fprintf(stderr, "Can't erase block at 0x%x (%s)\n", block_offset, strerror(errno));
+ exit(1);
+ }
+
+ if (quiet < 2) {
+ fprintf(stderr, "New image crc32: 0x%x, rewriting block\n",
+ *(uint32_t *)(&tag->image_crc));
+ fprintf(stderr, "New header crc32: 0x%x, rewriting block\n", headercrc);
+ }
+
+ if (pwrite(fd, buf, erasesize, block_offset) != erasesize) {
+ fprintf(stderr, "Error writing block (%s)\n", strerror(errno));
+ exit(1);
+ }
+
+ if (quiet < 2)
+ fprintf(stderr, "Done.\n");
+
+ close (fd);
+ sync();
+ return 0;
+
+}
diff --git a/package/mtd/src/jffs2.c b/package/mtd/src/jffs2.c
new file mode 100644
index 0000000..2a83bd4
--- /dev/null
+++ b/package/mtd/src/jffs2.c
@@ -0,0 +1,357 @@
+/*
+ * jffs2 on-disk structure generator for mtd
+ *
+ * Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License v2
+ * as published by the Free Software Foundation.
+ *
+ * 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.
+ * Based on:
+ * JFFS2 -- Journalling Flash File System, Version 2.
+ * Copyright © 2001-2007 Red Hat, Inc.
+ * Created by David Woodhouse <dwmw2@infradead.org>
+ */
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <string.h>
+#include <dirent.h>
+#include <unistd.h>
+#include <endian.h>
+#include "jffs2.h"
+#include "crc32.h"
+#include "mtd.h"
+
+#define PAD(x) (((x)+3)&~3)
+
+#if BYTE_ORDER == BIG_ENDIAN
+# define CLEANMARKER "\x19\x85\x20\x03\x00\x00\x00\x0c\xf0\x60\xdc\x98"
+#else
+# define CLEANMARKER "\x85\x19\x03\x20\x0c\x00\x00\x00\xb1\xb0\x1e\xe4"
+#endif
+
+static int last_ino = 0;
+static int last_version = 0;
+static char *buf = NULL;
+static int ofs = 0;
+static int outfd = -1;
+static int mtdofs = 0;
+static int target_ino = 0;
+
+static void prep_eraseblock(void);
+
+static void pad(int size)
+{
+ if ((ofs % size == 0) && (ofs < erasesize))
+ return;
+
+ if (ofs < erasesize) {
+ memset(buf + ofs, 0xff, (size - (ofs % size)));
+ ofs += (size - (ofs % size));
+ }
+ ofs = ofs % erasesize;
+ if (ofs == 0) {
+ mtd_erase_block(outfd, mtdofs);
+ write(outfd, buf, erasesize);
+ mtdofs += erasesize;
+ }
+}
+
+static inline int rbytes(void)
+{
+ return erasesize - (ofs % erasesize);
+}
+
+static inline void add_data(char *ptr, int len)
+{
+ if (ofs + len > erasesize) {
+ pad(erasesize);
+ prep_eraseblock();
+ }
+ memcpy(buf + ofs, ptr, len);
+ ofs += len;
+}
+
+static void prep_eraseblock(void)
+{
+ if (ofs > 0)
+ return;
+
+ add_data(CLEANMARKER, sizeof(CLEANMARKER) - 1);
+}
+
+static int add_dirent(const char *name, const char type, int parent)
+{
+ struct jffs2_raw_dirent *de;
+
+ if (ofs - erasesize < sizeof(struct jffs2_raw_dirent) + strlen(name))
+ pad(erasesize);
+
+ prep_eraseblock();
+ last_ino++;
+ memset(buf + ofs, 0, sizeof(struct jffs2_raw_dirent));
+ de = (struct jffs2_raw_dirent *) (buf + ofs);
+
+ de->magic = JFFS2_MAGIC_BITMASK;
+ de->nodetype = JFFS2_NODETYPE_DIRENT;
+ de->type = type;
+ de->name_crc = crc32(0, name, strlen(name));
+ de->ino = last_ino++;
+ de->pino = parent;
+ de->totlen = sizeof(*de) + strlen(name);
+ de->hdr_crc = crc32(0, (void *) de, sizeof(struct jffs2_unknown_node) - 4);
+ de->version = last_version++;
+ de->mctime = 0;
+ de->nsize = strlen(name);
+ de->node_crc = crc32(0, (void *) de, sizeof(*de) - 8);
+ memcpy(de->name, name, strlen(name));
+
+ ofs += sizeof(struct jffs2_raw_dirent) + de->nsize;
+ pad(4);
+
+ return de->ino;
+}
+
+static int add_dir(const char *name, int parent)
+{
+ struct jffs2_raw_inode ri;
+ int inode;
+
+ inode = add_dirent(name, IFTODT(S_IFDIR), parent);
+
+ if (rbytes() < sizeof(ri))
+ pad(erasesize);
+ prep_eraseblock();
+
+ memset(&ri, 0, sizeof(ri));
+ ri.magic = JFFS2_MAGIC_BITMASK;
+ ri.nodetype = JFFS2_NODETYPE_INODE;
+ ri.totlen = sizeof(ri);
+ ri.hdr_crc = crc32(0, &ri, sizeof(struct jffs2_unknown_node) - 4);
+
+ ri.ino = inode;
+ ri.mode = S_IFDIR | 0755;
+ ri.uid = ri.gid = 0;
+ ri.atime = ri.ctime = ri.mtime = 0;
+ ri.isize = ri.csize = ri.dsize = 0;
+ ri.version = 1;
+ ri.node_crc = crc32(0, &ri, sizeof(ri) - 8);
+ ri.data_crc = 0;
+
+ add_data((char *) &ri, sizeof(ri));
+ pad(4);
+ return inode;
+}
+
+static void add_file(const char *name, int parent)
+{
+ int inode, f_offset = 0, fd;
+ struct jffs2_raw_inode ri;
+ struct stat st;
+ char wbuf[4096];
+ const char *fname;
+
+ if (stat(name, &st)) {
+ fprintf(stderr, "File %s does not exist\n", name);
+ return;
+ }
+
+ fname = strrchr(name, '/');
+ if (fname)
+ fname++;
+ else
+ fname = name;
+
+ inode = add_dirent(fname, IFTODT(S_IFREG), parent);
+ memset(&ri, 0, sizeof(ri));
+ ri.magic = JFFS2_MAGIC_BITMASK;
+ ri.nodetype = JFFS2_NODETYPE_INODE;
+
+ ri.ino = inode;
+ ri.mode = st.st_mode;
+ ri.uid = ri.gid = 0;
+ ri.atime = st.st_atime;
+ ri.ctime = st.st_ctime;
+ ri.mtime = st.st_mtime;
+ ri.isize = st.st_size;
+ ri.compr = 0;
+ ri.usercompr = 0;
+
+ fd = open(name, 0);
+ if (fd < 0) {
+ fprintf(stderr, "File %s does not exist\n", name);
+ return;
+ }
+
+ for (;;) {
+ int len = 0;
+
+ for (;;) {
+ len = rbytes() - sizeof(ri);
+ if (len > 128)
+ break;
+
+ pad(erasesize);
+ prep_eraseblock();
+ }
+
+ if (len > sizeof(wbuf))
+ len = sizeof(wbuf);
+
+ len = read(fd, wbuf, len);
+ if (len <= 0)
+ break;
+
+ ri.totlen = sizeof(ri) + len;
+ ri.hdr_crc = crc32(0, &ri, sizeof(struct jffs2_unknown_node) - 4);
+ ri.version = ++last_version;
+ ri.offset = f_offset;
+ ri.csize = ri.dsize = len;
+ ri.node_crc = crc32(0, &ri, sizeof(ri) - 8);
+ ri.data_crc = crc32(0, wbuf, len);
+ f_offset += len;
+ add_data((char *) &ri, sizeof(ri));
+ add_data(wbuf, len);
+ pad(4);
+ prep_eraseblock();
+ }
+
+ close(fd);
+}
+
+int mtd_replace_jffs2(const char *mtd, int fd, int ofs, const char *filename)
+{
+ outfd = fd;
+ mtdofs = ofs;
+
+ buf = malloc(erasesize);
+ target_ino = 1;
+ if (!last_ino)
+ last_ino = 1;
+ add_file(filename, target_ino);
+ pad(erasesize);
+
+ /* add eof marker, pad to eraseblock size and write the data */
+ add_data(JFFS2_EOF, sizeof(JFFS2_EOF) - 1);
+ pad(erasesize);
+ free(buf);
+
+ return (mtdofs - ofs);
+}
+
+void mtd_parse_jffs2data(const char *buf, const char *dir)
+{
+ struct jffs2_unknown_node *node = (struct jffs2_unknown_node *) buf;
+ unsigned int ofs = 0;
+
+ while (ofs < erasesize) {
+ node = (struct jffs2_unknown_node *) (buf + ofs);
+ if (node->magic != 0x1985)
+ break;
+
+ ofs += PAD(node->totlen);
+ if (node->nodetype == JFFS2_NODETYPE_DIRENT) {
+ struct jffs2_raw_dirent *de = (struct jffs2_raw_dirent *) node;
+
+ /* is this the right directory name and is it a subdirectory of / */
+ if (*dir && (de->pino == 1) && !strncmp((char *) de->name, dir, de->nsize))
+ target_ino = de->ino;
+
+ /* store the last inode and version numbers for adding extra files */
+ if (last_ino < de->ino)
+ last_ino = de->ino;
+ if (last_version < de->version)
+ last_version = de->version;
+ }
+ }
+}
+
+int mtd_write_jffs2(const char *mtd, const char *filename, const char *dir)
+{
+ int err = -1, fdeof = 0;
+
+ outfd = mtd_check_open(mtd);
+ if (outfd < 0)
+ return -1;
+
+ if (quiet < 2)
+ fprintf(stderr, "Appending %s to jffs2 partition %s\n", filename, mtd);
+
+ buf = malloc(erasesize);
+ if (!buf) {
+ fprintf(stderr, "Out of memory!\n");
+ goto done;
+ }
+
+ if (!*dir)
+ target_ino = 1;
+
+ /* parse the structure of the jffs2 first
+ * locate the directory that the file is going to be placed in */
+ for(;;) {
+ struct jffs2_unknown_node *node = (struct jffs2_unknown_node *) buf;
+
+ if (read(outfd, buf, erasesize) != erasesize) {
+ fdeof = 1;
+ break;
+ }
+ mtdofs += erasesize;
+
+ if (node->magic == 0x8519) {
+ fprintf(stderr, "Error: wrong endianness filesystem\n");
+ goto done;
+ }
+
+ /* assume no magic == end of filesystem
+ * the filesystem will probably end with be32(0xdeadc0de) */
+ if (node->magic != 0x1985)
+ break;
+
+ mtd_parse_jffs2data(buf, dir);
+ }
+
+ if (fdeof) {
+ fprintf(stderr, "Error: No room for additional data\n");
+ goto done;
+ }
+
+ /* jump back one eraseblock */
+ mtdofs -= erasesize;
+ lseek(outfd, mtdofs, SEEK_SET);
+
+ ofs = 0;
+
+ if (!last_ino)
+ last_ino = 1;
+
+ if (!target_ino)
+ target_ino = add_dir(dir, 1);
+
+ add_file(filename, target_ino);
+ pad(erasesize);
+
+ /* add eof marker, pad to eraseblock size and write the data */
+ add_data(JFFS2_EOF, sizeof(JFFS2_EOF) - 1);
+ pad(erasesize);
+
+ err = 0;
+
+ if (trx_fixup) {
+ trx_fixup(outfd, mtd);
+ }
+
+done:
+ close(outfd);
+ if (buf)
+ free(buf);
+
+ return err;
+}
diff --git a/package/mtd/src/jffs2.h b/package/mtd/src/jffs2.h
new file mode 100644
index 0000000..858e77a
--- /dev/null
+++ b/package/mtd/src/jffs2.h
@@ -0,0 +1,216 @@
+/*
+ * JFFS2 -- Journalling Flash File System, Version 2.
+ *
+ * Copyright (C) 2001-2003 Red Hat, Inc.
+ *
+ * Created by David Woodhouse <dwmw2@infradead.org>
+ *
+ * For licensing information, see the file 'LICENCE' in the
+ * jffs2 directory.
+ *
+ *
+ */
+
+#ifndef __LINUX_JFFS2_H__
+#define __LINUX_JFFS2_H__
+
+#define JFFS2_SUPER_MAGIC 0x72b6
+
+/* You must include something which defines the C99 uintXX_t types.
+ We don't do it from here because this file is used in too many
+ different environments. */
+
+/* Values we may expect to find in the 'magic' field */
+#define JFFS2_OLD_MAGIC_BITMASK 0x1984
+#define JFFS2_MAGIC_BITMASK 0x1985
+#define KSAMTIB_CIGAM_2SFFJ 0x8519 /* For detecting wrong-endian fs */
+#define JFFS2_EMPTY_BITMASK 0xffff
+#define JFFS2_DIRTY_BITMASK 0x0000
+
+/* Summary node MAGIC marker */
+#define JFFS2_SUM_MAGIC 0x02851885
+
+/* We only allow a single char for length, and 0xFF is empty flash so
+ we don't want it confused with a real length. Hence max 254.
+*/
+#define JFFS2_MAX_NAME_LEN 254
+
+/* How small can we sensibly write nodes? */
+#define JFFS2_MIN_DATA_LEN 128
+
+#define JFFS2_COMPR_NONE 0x00
+#define JFFS2_COMPR_ZERO 0x01
+#define JFFS2_COMPR_RTIME 0x02
+#define JFFS2_COMPR_RUBINMIPS 0x03
+#define JFFS2_COMPR_COPY 0x04
+#define JFFS2_COMPR_DYNRUBIN 0x05
+#define JFFS2_COMPR_ZLIB 0x06
+/* Compatibility flags. */
+#define JFFS2_COMPAT_MASK 0xc000 /* What do to if an unknown nodetype is found */
+#define JFFS2_NODE_ACCURATE 0x2000
+/* INCOMPAT: Fail to mount the filesystem */
+#define JFFS2_FEATURE_INCOMPAT 0xc000
+/* ROCOMPAT: Mount read-only */
+#define JFFS2_FEATURE_ROCOMPAT 0x8000
+/* RWCOMPAT_COPY: Mount read/write, and copy the node when it's GC'd */
+#define JFFS2_FEATURE_RWCOMPAT_COPY 0x4000
+/* RWCOMPAT_DELETE: Mount read/write, and delete the node when it's GC'd */
+#define JFFS2_FEATURE_RWCOMPAT_DELETE 0x0000
+
+#define JFFS2_NODETYPE_DIRENT (JFFS2_FEATURE_INCOMPAT | JFFS2_NODE_ACCURATE | 1)
+#define JFFS2_NODETYPE_INODE (JFFS2_FEATURE_INCOMPAT | JFFS2_NODE_ACCURATE | 2)
+#define JFFS2_NODETYPE_CLEANMARKER (JFFS2_FEATURE_RWCOMPAT_DELETE | JFFS2_NODE_ACCURATE | 3)
+#define JFFS2_NODETYPE_PADDING (JFFS2_FEATURE_RWCOMPAT_DELETE | JFFS2_NODE_ACCURATE | 4)
+
+#define JFFS2_NODETYPE_SUMMARY (JFFS2_FEATURE_RWCOMPAT_DELETE | JFFS2_NODE_ACCURATE | 6)
+
+#define JFFS2_NODETYPE_XATTR (JFFS2_FEATURE_INCOMPAT | JFFS2_NODE_ACCURATE | 8)
+#define JFFS2_NODETYPE_XREF (JFFS2_FEATURE_INCOMPAT | JFFS2_NODE_ACCURATE | 9)
+
+/* XATTR Related */
+#define JFFS2_XPREFIX_USER 1 /* for "user." */
+#define JFFS2_XPREFIX_SECURITY 2 /* for "security." */
+#define JFFS2_XPREFIX_ACL_ACCESS 3 /* for "system.posix_acl_access" */
+#define JFFS2_XPREFIX_ACL_DEFAULT 4 /* for "system.posix_acl_default" */
+#define JFFS2_XPREFIX_TRUSTED 5 /* for "trusted.*" */
+
+#define JFFS2_ACL_VERSION 0x0001
+
+// Maybe later...
+//#define JFFS2_NODETYPE_CHECKPOINT (JFFS2_FEATURE_RWCOMPAT_DELETE | JFFS2_NODE_ACCURATE | 3)
+//#define JFFS2_NODETYPE_OPTIONS (JFFS2_FEATURE_RWCOMPAT_COPY | JFFS2_NODE_ACCURATE | 4)
+
+
+#define JFFS2_INO_FLAG_PREREAD 1 /* Do read_inode() for this one at
+ mount time, don't wait for it to
+ happen later */
+#define JFFS2_INO_FLAG_USERCOMPR 2 /* User has requested a specific
+ compression type */
+
+
+/* These can go once we've made sure we've caught all uses without
+ byteswapping */
+
+typedef uint32_t jint32_t;
+
+typedef uint32_t jmode_t;
+
+typedef uint16_t jint16_t;
+
+struct jffs2_unknown_node
+{
+ /* All start like this */
+ jint16_t magic;
+ jint16_t nodetype;
+ jint32_t totlen; /* So we can skip over nodes we don't grok */
+ jint32_t hdr_crc;
+};
+
+struct jffs2_raw_dirent
+{
+ jint16_t magic;
+ jint16_t nodetype; /* == JFFS2_NODETYPE_DIRENT */
+ jint32_t totlen;
+ jint32_t hdr_crc;
+ jint32_t pino;
+ jint32_t version;
+ jint32_t ino; /* == zero for unlink */
+ jint32_t mctime;
+ uint8_t nsize;
+ uint8_t type;
+ uint8_t unused[2];
+ jint32_t node_crc;
+ jint32_t name_crc;
+ uint8_t name[0];
+};
+
+/* The JFFS2 raw inode structure: Used for storage on physical media. */
+/* The uid, gid, atime, mtime and ctime members could be longer, but
+ are left like this for space efficiency. If and when people decide
+ they really need them extended, it's simple enough to add support for
+ a new type of raw node.
+*/
+struct jffs2_raw_inode
+{
+ jint16_t magic; /* A constant magic number. */
+ jint16_t nodetype; /* == JFFS2_NODETYPE_INODE */
+ jint32_t totlen; /* Total length of this node (inc data, etc.) */
+ jint32_t hdr_crc;
+ jint32_t ino; /* Inode number. */
+ jint32_t version; /* Version number. */
+ jmode_t mode; /* The file's type or mode. */
+ jint16_t uid; /* The file's owner. */
+ jint16_t gid; /* The file's group. */
+ jint32_t isize; /* Total resultant size of this inode (used for truncations) */
+ jint32_t atime; /* Last access time. */
+ jint32_t mtime; /* Last modification time. */
+ jint32_t ctime; /* Change time. */
+ jint32_t offset; /* Where to begin to write. */
+ jint32_t csize; /* (Compressed) data size */
+ jint32_t dsize; /* Size of the node's data. (after decompression) */
+ uint8_t compr; /* Compression algorithm used */
+ uint8_t usercompr; /* Compression algorithm requested by the user */
+ jint16_t flags; /* See JFFS2_INO_FLAG_* */
+ jint32_t data_crc; /* CRC for the (compressed) data. */
+ jint32_t node_crc; /* CRC for the raw inode (excluding data) */
+ uint8_t data[0];
+};
+
+struct jffs2_raw_xattr {
+ jint16_t magic;
+ jint16_t nodetype; /* = JFFS2_NODETYPE_XATTR */
+ jint32_t totlen;
+ jint32_t hdr_crc;
+ jint32_t xid; /* XATTR identifier number */
+ jint32_t version;
+ uint8_t xprefix;
+ uint8_t name_len;
+ jint16_t value_len;
+ jint32_t data_crc;
+ jint32_t node_crc;
+ uint8_t data[0];
+} __attribute__((packed));
+
+struct jffs2_raw_xref
+{
+ jint16_t magic;
+ jint16_t nodetype; /* = JFFS2_NODETYPE_XREF */
+ jint32_t totlen;
+ jint32_t hdr_crc;
+ jint32_t ino; /* inode number */
+ jint32_t xid; /* XATTR identifier number */
+ jint32_t xseqno; /* xref sequencial number */
+ jint32_t node_crc;
+} __attribute__((packed));
+
+struct jffs2_raw_summary
+{
+ jint16_t magic;
+ jint16_t nodetype; /* = JFFS2_NODETYPE_SUMMARY */
+ jint32_t totlen;
+ jint32_t hdr_crc;
+ jint32_t sum_num; /* number of sum entries*/
+ jint32_t cln_mkr; /* clean marker size, 0 = no cleanmarker */
+ jint32_t padded; /* sum of the size of padding nodes */
+ jint32_t sum_crc; /* summary information crc */
+ jint32_t node_crc; /* node crc */
+ jint32_t sum[0]; /* inode summary info */
+};
+
+union jffs2_node_union
+{
+ struct jffs2_raw_inode i;
+ struct jffs2_raw_dirent d;
+ struct jffs2_raw_xattr x;
+ struct jffs2_raw_xref r;
+ struct jffs2_raw_summary s;
+ struct jffs2_unknown_node u;
+};
+
+/* Data payload for device nodes. */
+union jffs2_device_node {
+ jint16_t old;
+ jint32_t new;
+};
+
+#endif /* __LINUX_JFFS2_H__ */
diff --git a/package/mtd/src/md5.c b/package/mtd/src/md5.c
new file mode 100644
index 0000000..2039760
--- /dev/null
+++ b/package/mtd/src/md5.c
@@ -0,0 +1,307 @@
+
+
+/*
+ ***********************************************************************
+ ** md5.c -- the source code for MD5 routines **
+ ** RSA Data Security, Inc. MD5 Message-Digest Algorithm **
+ ** Created: 2/17/90 RLR **
+ ** Revised: 1/91 SRD,AJ,BSK,JT Reference C ver., 7/10 constant corr. **
+ ***********************************************************************
+ */
+
+/*
+ ***********************************************************************
+ ** Copyright (C) 1990, RSA Data Security, Inc. All rights reserved. **
+ ** **
+ ** License to copy and use this software is granted provided that **
+ ** it is identified as the "RSA Data Security, Inc. MD5 Message- **
+ ** Digest Algorithm" in all material mentioning or referencing this **
+ ** software or this function. **
+ ** **
+ ** License is also granted to make and use derivative works **
+ ** provided that such works are identified as "derived from the RSA **
+ ** Data Security, Inc. MD5 Message-Digest Algorithm" in all **
+ ** material mentioning or referencing the derived work. **
+ ** **
+ ** RSA Data Security, Inc. makes no representations concerning **
+ ** either the merchantability of this software or the suitability **
+ ** of this software for any particular purpose. It is provided "as **
+ ** is" without express or implied warranty of any kind. **
+ ** **
+ ** These notices must be retained in any copies of any part of this **
+ ** documentation and/or software. **
+ ***********************************************************************
+ */
+
+#include <string.h>
+#include "md5.h"
+
+/*
+ ***********************************************************************
+ ** Message-digest routines: **
+ ** To form the message digest for a message M **
+ ** (1) Initialize a context buffer mdContext using MD5_Init **
+ ** (2) Call MD5_Update on mdContext and M **
+ ** (3) Call MD5_Final on mdContext **
+ ** The message digest is now in mdContext->digest[0...15] **
+ ***********************************************************************
+ */
+
+/* forward declaration */
+static void Transform ();
+
+static unsigned char PADDING[64] = {
+ 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+/* F, G, H and I are basic MD5 functions */
+#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
+#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
+#define H(x, y, z) ((x) ^ (y) ^ (z))
+#define I(x, y, z) ((y) ^ ((x) | (~z)))
+
+/* ROTATE_LEFT rotates x left n bits */
+#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
+
+/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4 */
+/* Rotation is separate from addition to prevent recomputation */
+#define FF(a, b, c, d, x, s, ac) \
+ {(a) += F ((b), (c), (d)) + (x) + (UINT4)(ac); \
+ (a) = ROTATE_LEFT ((a), (s)); \
+ (a) += (b); \
+ }
+#define GG(a, b, c, d, x, s, ac) \
+ {(a) += G ((b), (c), (d)) + (x) + (UINT4)(ac); \
+ (a) = ROTATE_LEFT ((a), (s)); \
+ (a) += (b); \
+ }
+#define HH(a, b, c, d, x, s, ac) \
+ {(a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); \
+ (a) = ROTATE_LEFT ((a), (s)); \
+ (a) += (b); \
+ }
+#define II(a, b, c, d, x, s, ac) \
+ {(a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \
+ (a) = ROTATE_LEFT ((a), (s)); \
+ (a) += (b); \
+ }
+
+#ifdef __STDC__
+#define UL(x) x##U
+#else
+#define UL(x) x
+#endif
+
+/* The routine MD5_Init initializes the message-digest context
+ mdContext. All fields are set to zero.
+ */
+void MD5_Init (mdContext)
+MD5_CTX *mdContext;
+{
+ mdContext->i[0] = mdContext->i[1] = (UINT4)0;
+
+ /* Load magic initialization constants.
+ */
+ mdContext->buf[0] = (UINT4)0x67452301;
+ mdContext->buf[1] = (UINT4)0xefcdab89;
+ mdContext->buf[2] = (UINT4)0x98badcfe;
+ mdContext->buf[3] = (UINT4)0x10325476;
+}
+
+/* The routine MD5Update updates the message-digest context to
+ account for the presence of each of the characters inBuf[0..inLen-1]
+ in the message whose digest is being computed.
+ */
+void MD5_Update (mdContext, inBuf, inLen)
+MD5_CTX *mdContext;
+unsigned char *inBuf;
+unsigned int inLen;
+{
+ UINT4 in[16];
+ int mdi;
+ unsigned int i, ii;
+
+ /* compute number of bytes mod 64 */
+ mdi = (int)((mdContext->i[0] >> 3) & 0x3F);
+
+ /* update number of bits */
+ if ((mdContext->i[0] + ((UINT4)inLen << 3)) < mdContext->i[0])
+ mdContext->i[1]++;
+ mdContext->i[0] += ((UINT4)inLen << 3);
+ mdContext->i[1] += ((UINT4)inLen >> 29);
+
+ while (inLen--) {
+ /* add new character to buffer, increment mdi */
+ mdContext->in[mdi++] = *inBuf++;
+
+ /* transform if necessary */
+ if (mdi == 0x40) {
+ for (i = 0, ii = 0; i < 16; i++, ii += 4)
+ in[i] = (((UINT4)mdContext->in[ii+3]) << 24) |
+ (((UINT4)mdContext->in[ii+2]) << 16) |
+ (((UINT4)mdContext->in[ii+1]) << 8) |
+ ((UINT4)mdContext->in[ii]);
+ Transform (mdContext->buf, in);
+ mdi = 0;
+ }
+ }
+}
+
+/* The routine MD5Final terminates the message-digest computation and
+ ends with the desired message digest in mdContext->digest[0...15].
+ */
+void MD5_Final (hash, mdContext)
+unsigned char hash[];
+MD5_CTX *mdContext;
+{
+ UINT4 in[16];
+ int mdi;
+ unsigned int i, ii;
+ unsigned int padLen;
+
+ /* save number of bits */
+ in[14] = mdContext->i[0];
+ in[15] = mdContext->i[1];
+
+ /* compute number of bytes mod 64 */
+ mdi = (int)((mdContext->i[0] >> 3) & 0x3F);
+
+ /* pad out to 56 mod 64 */
+ padLen = (mdi < 56) ? (56 - mdi) : (120 - mdi);
+ MD5_Update (mdContext, PADDING, padLen);
+
+ /* append length in bits and transform */
+ for (i = 0, ii = 0; i < 14; i++, ii += 4)
+ in[i] = (((UINT4)mdContext->in[ii+3]) << 24) |
+ (((UINT4)mdContext->in[ii+2]) << 16) |
+ (((UINT4)mdContext->in[ii+1]) << 8) |
+ ((UINT4)mdContext->in[ii]);
+ Transform (mdContext->buf, in);
+
+ /* store buffer in digest */
+ for (i = 0, ii = 0; i < 4; i++, ii += 4) {
+ mdContext->digest[ii] = (unsigned char)(mdContext->buf[i] & 0xFF);
+ mdContext->digest[ii+1] =
+ (unsigned char)((mdContext->buf[i] >> 8) & 0xFF);
+ mdContext->digest[ii+2] =
+ (unsigned char)((mdContext->buf[i] >> 16) & 0xFF);
+ mdContext->digest[ii+3] =
+ (unsigned char)((mdContext->buf[i] >> 24) & 0xFF);
+ }
+ memcpy(hash, mdContext->digest, 16);
+}
+
+/* Basic MD5 step. Transforms buf based on in.
+ */
+static void Transform (buf, in)
+UINT4 *buf;
+UINT4 *in;
+{
+ UINT4 a = buf[0], b = buf[1], c = buf[2], d = buf[3];
+
+ /* Round 1 */
+#define S11 7
+#define S12 12
+#define S13 17
+#define S14 22
+ FF ( a, b, c, d, in[ 0], S11, UL(3614090360)); /* 1 */
+ FF ( d, a, b, c, in[ 1], S12, UL(3905402710)); /* 2 */
+ FF ( c, d, a, b, in[ 2], S13, UL( 606105819)); /* 3 */
+ FF ( b, c, d, a, in[ 3], S14, UL(3250441966)); /* 4 */
+ FF ( a, b, c, d, in[ 4], S11, UL(4118548399)); /* 5 */
+ FF ( d, a, b, c, in[ 5], S12, UL(1200080426)); /* 6 */
+ FF ( c, d, a, b, in[ 6], S13, UL(2821735955)); /* 7 */
+ FF ( b, c, d, a, in[ 7], S14, UL(4249261313)); /* 8 */
+ FF ( a, b, c, d, in[ 8], S11, UL(1770035416)); /* 9 */
+ FF ( d, a, b, c, in[ 9], S12, UL(2336552879)); /* 10 */
+ FF ( c, d, a, b, in[10], S13, UL(4294925233)); /* 11 */
+ FF ( b, c, d, a, in[11], S14, UL(2304563134)); /* 12 */
+ FF ( a, b, c, d, in[12], S11, UL(1804603682)); /* 13 */
+ FF ( d, a, b, c, in[13], S12, UL(4254626195)); /* 14 */
+ FF ( c, d, a, b, in[14], S13, UL(2792965006)); /* 15 */
+ FF ( b, c, d, a, in[15], S14, UL(1236535329)); /* 16 */
+
+ /* Round 2 */
+#define S21 5
+#define S22 9
+#define S23 14
+#define S24 20
+ GG ( a, b, c, d, in[ 1], S21, UL(4129170786)); /* 17 */
+ GG ( d, a, b, c, in[ 6], S22, UL(3225465664)); /* 18 */
+ GG ( c, d, a, b, in[11], S23, UL( 643717713)); /* 19 */
+ GG ( b, c, d, a, in[ 0], S24, UL(3921069994)); /* 20 */
+ GG ( a, b, c, d, in[ 5], S21, UL(3593408605)); /* 21 */
+ GG ( d, a, b, c, in[10], S22, UL( 38016083)); /* 22 */
+ GG ( c, d, a, b, in[15], S23, UL(3634488961)); /* 23 */
+ GG ( b, c, d, a, in[ 4], S24, UL(3889429448)); /* 24 */
+ GG ( a, b, c, d, in[ 9], S21, UL( 568446438)); /* 25 */
+ GG ( d, a, b, c, in[14], S22, UL(3275163606)); /* 26 */
+ GG ( c, d, a, b, in[ 3], S23, UL(4107603335)); /* 27 */
+ GG ( b, c, d, a, in[ 8], S24, UL(1163531501)); /* 28 */
+ GG ( a, b, c, d, in[13], S21, UL(2850285829)); /* 29 */
+ GG ( d, a, b, c, in[ 2], S22, UL(4243563512)); /* 30 */
+ GG ( c, d, a, b, in[ 7], S23, UL(1735328473)); /* 31 */
+ GG ( b, c, d, a, in[12], S24, UL(2368359562)); /* 32 */
+
+ /* Round 3 */
+#define S31 4
+#define S32 11
+#define S33 16
+#define S34 23
+ HH ( a, b, c, d, in[ 5], S31, UL(4294588738)); /* 33 */
+ HH ( d, a, b, c, in[ 8], S32, UL(2272392833)); /* 34 */
+ HH ( c, d, a, b, in[11], S33, UL(1839030562)); /* 35 */
+ HH ( b, c, d, a, in[14], S34, UL(4259657740)); /* 36 */
+ HH ( a, b, c, d, in[ 1], S31, UL(2763975236)); /* 37 */
+ HH ( d, a, b, c, in[ 4], S32, UL(1272893353)); /* 38 */
+ HH ( c, d, a, b, in[ 7], S33, UL(4139469664)); /* 39 */
+ HH ( b, c, d, a, in[10], S34, UL(3200236656)); /* 40 */
+ HH ( a, b, c, d, in[13], S31, UL( 681279174)); /* 41 */
+ HH ( d, a, b, c, in[ 0], S32, UL(3936430074)); /* 42 */
+ HH ( c, d, a, b, in[ 3], S33, UL(3572445317)); /* 43 */
+ HH ( b, c, d, a, in[ 6], S34, UL( 76029189)); /* 44 */
+ HH ( a, b, c, d, in[ 9], S31, UL(3654602809)); /* 45 */
+ HH ( d, a, b, c, in[12], S32, UL(3873151461)); /* 46 */
+ HH ( c, d, a, b, in[15], S33, UL( 530742520)); /* 47 */
+ HH ( b, c, d, a, in[ 2], S34, UL(3299628645)); /* 48 */
+
+ /* Round 4 */
+#define S41 6
+#define S42 10
+#define S43 15
+#define S44 21
+ II ( a, b, c, d, in[ 0], S41, UL(4096336452)); /* 49 */
+ II ( d, a, b, c, in[ 7], S42, UL(1126891415)); /* 50 */
+ II ( c, d, a, b, in[14], S43, UL(2878612391)); /* 51 */
+ II ( b, c, d, a, in[ 5], S44, UL(4237533241)); /* 52 */
+ II ( a, b, c, d, in[12], S41, UL(1700485571)); /* 53 */
+ II ( d, a, b, c, in[ 3], S42, UL(2399980690)); /* 54 */
+ II ( c, d, a, b, in[10], S43, UL(4293915773)); /* 55 */
+ II ( b, c, d, a, in[ 1], S44, UL(2240044497)); /* 56 */
+ II ( a, b, c, d, in[ 8], S41, UL(1873313359)); /* 57 */
+ II ( d, a, b, c, in[15], S42, UL(4264355552)); /* 58 */
+ II ( c, d, a, b, in[ 6], S43, UL(2734768916)); /* 59 */
+ II ( b, c, d, a, in[13], S44, UL(1309151649)); /* 60 */
+ II ( a, b, c, d, in[ 4], S41, UL(4149444226)); /* 61 */
+ II ( d, a, b, c, in[11], S42, UL(3174756917)); /* 62 */
+ II ( c, d, a, b, in[ 2], S43, UL( 718787259)); /* 63 */
+ II ( b, c, d, a, in[ 9], S44, UL(3951481745)); /* 64 */
+
+ buf[0] += a;
+ buf[1] += b;
+ buf[2] += c;
+ buf[3] += d;
+}
+
+/*
+ ***********************************************************************
+ ** End of md5.c **
+ ******************************** (cut) ********************************
+ */
diff --git a/package/mtd/src/md5.h b/package/mtd/src/md5.h
new file mode 100644
index 0000000..f7a0c96
--- /dev/null
+++ b/package/mtd/src/md5.h
@@ -0,0 +1,65 @@
+/*
+ ***********************************************************************
+ ** md5.h -- header file for implementation of MD5 **
+ ** RSA Data Security, Inc. MD5 Message-Digest Algorithm **
+ ** Created: 2/17/90 RLR **
+ ** Revised: 12/27/90 SRD,AJ,BSK,JT Reference C version **
+ ** Revised (for MD5): RLR 4/27/91 **
+ ** -- G modified to have y&~z instead of y&z **
+ ** -- FF, GG, HH modified to add in last register done **
+ ** -- Access pattern: round 2 works mod 5, round 3 works mod 3 **
+ ** -- distinct additive constant for each step **
+ ** -- round 4 added, working mod 7 **
+ ***********************************************************************
+ */
+
+/*
+ ***********************************************************************
+ ** Copyright (C) 1990, RSA Data Security, Inc. All rights reserved. **
+ ** **
+ ** License to copy and use this software is granted provided that **
+ ** it is identified as the "RSA Data Security, Inc. MD5 Message- **
+ ** Digest Algorithm" in all material mentioning or referencing this **
+ ** software or this function. **
+ ** **
+ ** License is also granted to make and use derivative works **
+ ** provided that such works are identified as "derived from the RSA **
+ ** Data Security, Inc. MD5 Message-Digest Algorithm" in all **
+ ** material mentioning or referencing the derived work. **
+ ** **
+ ** RSA Data Security, Inc. makes no representations concerning **
+ ** either the merchantability of this software or the suitability **
+ ** of this software for any particular purpose. It is provided "as **
+ ** is" without express or implied warranty of any kind. **
+ ** **
+ ** These notices must be retained in any copies of any part of this **
+ ** documentation and/or software. **
+ ***********************************************************************
+ */
+
+#ifndef __MD5_INCLUDE__
+
+/* typedef a 32-bit type */
+#ifdef _LP64
+typedef unsigned int UINT4;
+typedef int INT4;
+#else
+typedef unsigned long UINT4;
+typedef long INT4;
+#endif
+#define _UINT4_T
+
+/* Data structure for MD5 (Message-Digest) computation */
+typedef struct {
+ UINT4 i[2]; /* number of _bits_ handled mod 2^64 */
+ UINT4 buf[4]; /* scratch buffer */
+ unsigned char in[64]; /* input buffer */
+ unsigned char digest[16]; /* actual digest after MD5Final call */
+} MD5_CTX;
+
+void MD5_Init ();
+void MD5_Update ();
+void MD5_Final ();
+
+#define __MD5_INCLUDE__
+#endif /* __MD5_INCLUDE__ */
diff --git a/package/mtd/src/mtd.c b/package/mtd/src/mtd.c
new file mode 100644
index 0000000..bdbaab5
--- /dev/null
+++ b/package/mtd/src/mtd.c
@@ -0,0 +1,761 @@
+/*
+ * mtd - simple memory technology device manipulation tool
+ *
+ * Copyright (C) 2005 Waldemar Brodkorb <wbx@dass-it.de>,
+ * Copyright (C) 2005-2009 Felix Fietkau <nbd@openwrt.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License v2
+ * as published by the Free Software Foundation.
+ *
+ * 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ *
+ * The code is based on the linux-mtd examples.
+ */
+
+#include <limits.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <signal.h>
+#include <sys/ioctl.h>
+#include <sys/syscall.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <time.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/mount.h>
+#include <sys/stat.h>
+#include <sys/reboot.h>
+#include <linux/reboot.h>
+#include <mtd/mtd-user.h>
+#include "fis.h"
+#include "mtd.h"
+
+#ifndef MTDREFRESH
+#define MTDREFRESH _IO('M', 50)
+#endif
+
+#define MAX_ARGS 8
+#define JFFS2_DEFAULT_DIR "" /* directory name without /, empty means root dir */
+
+static char *buf = NULL;
+static char *imagefile = NULL;
+static char *jffs2file = NULL, *jffs2dir = JFFS2_DEFAULT_DIR;
+static int buflen = 0;
+int quiet;
+int no_erase;
+int mtdsize = 0;
+int erasesize = 0;
+
+int mtd_open(const char *mtd, bool block)
+{
+ FILE *fp;
+ char dev[PATH_MAX];
+ int i;
+ int ret;
+ int flags = O_RDWR | O_SYNC;
+
+ if ((fp = fopen("/proc/mtd", "r"))) {
+ while (fgets(dev, sizeof(dev), fp)) {
+ if (sscanf(dev, "mtd%d:", &i) && strstr(dev, mtd)) {
+ snprintf(dev, sizeof(dev), "/dev/mtd%s/%d", (block ? "block" : ""), i);
+ if ((ret=open(dev, flags))<0) {
+ snprintf(dev, sizeof(dev), "/dev/mtd%s%d", (block ? "block" : ""), i);
+ ret=open(dev, flags);
+ }
+ fclose(fp);
+ return ret;
+ }
+ }
+ fclose(fp);
+ }
+
+ return open(mtd, flags);
+}
+
+int mtd_check_open(const char *mtd)
+{
+ struct mtd_info_user mtdInfo;
+ int fd;
+
+ fd = mtd_open(mtd, false);
+ if(fd < 0) {
+ fprintf(stderr, "Could not open mtd device: %s\n", mtd);
+ return -1;
+ }
+
+ if(ioctl(fd, MEMGETINFO, &mtdInfo)) {
+ fprintf(stderr, "Could not get MTD device info from %s\n", mtd);
+ close(fd);
+ return -1;
+ }
+ mtdsize = mtdInfo.size;
+ erasesize = mtdInfo.erasesize;
+
+ return fd;
+}
+
+int mtd_erase_block(int fd, int offset)
+{
+ struct erase_info_user mtdEraseInfo;
+
+ mtdEraseInfo.start = offset;
+ mtdEraseInfo.length = erasesize;
+ ioctl(fd, MEMUNLOCK, &mtdEraseInfo);
+ if (ioctl (fd, MEMERASE, &mtdEraseInfo) < 0)
+ return -1;
+
+ return 0;
+}
+
+int mtd_write_buffer(int fd, const char *buf, int offset, int length)
+{
+ lseek(fd, offset, SEEK_SET);
+ write(fd, buf, length);
+ return 0;
+}
+
+
+static int
+image_check(int imagefd, const char *mtd)
+{
+ int ret = 1;
+ if (trx_check) {
+ ret = trx_check(imagefd, mtd, buf, &buflen);
+ }
+
+ return ret;
+}
+
+static int mtd_check(const char *mtd)
+{
+ char *next = NULL;
+ char *str = NULL;
+ int fd;
+
+ if (strchr(mtd, ':')) {
+ str = strdup(mtd);
+ mtd = str;
+ }
+
+ do {
+ next = strchr(mtd, ':');
+ if (next) {
+ *next = 0;
+ next++;
+ }
+
+ fd = mtd_check_open(mtd);
+ if (fd < 0)
+ return 0;
+
+ if (!buf)
+ buf = malloc(erasesize);
+
+ close(fd);
+ mtd = next;
+ } while (next);
+
+ if (str)
+ free(str);
+
+ return 1;
+}
+
+static int
+mtd_unlock(const char *mtd)
+{
+ struct erase_info_user mtdLockInfo;
+ char *next = NULL;
+ char *str = NULL;
+ int fd;
+
+ if (strchr(mtd, ':')) {
+ str = strdup(mtd);
+ mtd = str;
+ }
+
+ do {
+ next = strchr(mtd, ':');
+ if (next) {
+ *next = 0;
+ next++;
+ }
+
+ fd = mtd_check_open(mtd);
+ if(fd < 0) {
+ fprintf(stderr, "Could not open mtd device: %s\n", mtd);
+ exit(1);
+ }
+
+ if (quiet < 2)
+ fprintf(stderr, "Unlocking %s ...\n", mtd);
+
+ mtdLockInfo.start = 0;
+ mtdLockInfo.length = mtdsize;
+ ioctl(fd, MEMUNLOCK, &mtdLockInfo);
+ close(fd);
+ mtd = next;
+ } while (next);
+
+ if (str)
+ free(str);
+
+ return 0;
+}
+
+static int
+mtd_erase(const char *mtd)
+{
+ int fd;
+ struct erase_info_user mtdEraseInfo;
+
+ if (quiet < 2)
+ fprintf(stderr, "Erasing %s ...\n", mtd);
+
+ fd = mtd_check_open(mtd);
+ if(fd < 0) {
+ fprintf(stderr, "Could not open mtd device: %s\n", mtd);
+ exit(1);
+ }
+
+ mtdEraseInfo.length = erasesize;
+
+ for (mtdEraseInfo.start = 0;
+ mtdEraseInfo.start < mtdsize;
+ mtdEraseInfo.start += erasesize) {
+
+ ioctl(fd, MEMUNLOCK, &mtdEraseInfo);
+ if(ioctl(fd, MEMERASE, &mtdEraseInfo))
+ fprintf(stderr, "Failed to erase block on %s at 0x%x\n", mtd, mtdEraseInfo.start);
+ }
+
+ close(fd);
+ return 0;
+
+}
+
+static int
+mtd_refresh(const char *mtd)
+{
+ int fd;
+
+ if (quiet < 2)
+ fprintf(stderr, "Refreshing mtd partition %s ... ", mtd);
+
+ fd = mtd_check_open(mtd);
+ if(fd < 0) {
+ fprintf(stderr, "Could not open mtd device: %s\n", mtd);
+ exit(1);
+ }
+
+ if (ioctl(fd, MTDREFRESH, NULL)) {
+ fprintf(stderr, "Failed to refresh the MTD device\n");
+ close(fd);
+ exit(1);
+ }
+ close(fd);
+
+ if (quiet < 2)
+ fprintf(stderr, "\n");
+
+ return 0;
+}
+
+static void
+indicate_writing(const char *mtd)
+{
+ if (quiet < 2)
+ fprintf(stderr, "\nWriting from %s to %s ... ", imagefile, mtd);
+
+ if (!quiet)
+ fprintf(stderr, " [ ]");
+}
+
+static int
+mtd_write(int imagefd, const char *mtd, char *fis_layout, size_t part_offset)
+{
+ char *next = NULL;
+ char *str = NULL;
+ int fd, result;
+ ssize_t r, w, e;
+ ssize_t skip = 0;
+ uint32_t offset = 0;
+ int jffs2_replaced = 0;
+
+#ifdef FIS_SUPPORT
+ static struct fis_part new_parts[MAX_ARGS];
+ static struct fis_part old_parts[MAX_ARGS];
+ int n_new = 0, n_old = 0;
+
+ if (fis_layout) {
+ const char *tmp = mtd;
+ char *word, *brkt;
+ int ret;
+
+ memset(&old_parts, 0, sizeof(old_parts));
+ memset(&new_parts, 0, sizeof(new_parts));
+
+ do {
+ next = strchr(tmp, ':');
+ if (!next)
+ next = (char *) tmp + strlen(tmp);
+
+ memcpy(old_parts[n_old].name, tmp, next - tmp);
+
+ n_old++;
+ tmp = next + 1;
+ } while(*next);
+
+ for (word = strtok_r(fis_layout, ",", &brkt);
+ word;
+ word = strtok_r(NULL, ",", &brkt)) {
+
+ tmp = strtok(word, ":");
+ strncpy((char *) new_parts[n_new].name, tmp, sizeof(new_parts[n_new].name) - 1);
+
+ tmp = strtok(NULL, ":");
+ if (!tmp)
+ goto next;
+
+ new_parts[n_new].size = strtoul(tmp, NULL, 0);
+
+ tmp = strtok(NULL, ":");
+ if (!tmp)
+ goto next;
+
+ new_parts[n_new].loadaddr = strtoul(tmp, NULL, 16);
+next:
+ n_new++;
+ }
+ ret = fis_validate(old_parts, n_old, new_parts, n_new);
+ if (ret < 0) {
+ fprintf(stderr, "Failed to validate the new FIS partition table\n");
+ exit(1);
+ }
+ if (ret == 0)
+ fis_layout = NULL;
+ }
+#endif
+
+ if (strchr(mtd, ':')) {
+ str = strdup(mtd);
+ mtd = str;
+ }
+
+ r = 0;
+
+resume:
+ next = strchr(mtd, ':');
+ if (next) {
+ *next = 0;
+ next++;
+ }
+
+ fd = mtd_check_open(mtd);
+ if(fd < 0) {
+ fprintf(stderr, "Could not open mtd device: %s\n", mtd);
+ exit(1);
+ }
+
+ if (part_offset > 0) {
+ fprintf(stderr, "Seeking on mtd device '%s' to: %u\n", mtd, part_offset);
+ lseek(fd, part_offset, SEEK_SET);
+ }
+
+ indicate_writing(mtd);
+
+ w = e = 0;
+ for (;;) {
+ /* buffer may contain data already (from trx check or last mtd partition write attempt) */
+ while (buflen < erasesize) {
+ r = read(imagefd, buf + buflen, erasesize - buflen);
+ if (r < 0) {
+ if ((errno == EINTR) || (errno == EAGAIN))
+ continue;
+ else {
+ perror("read");
+ break;
+ }
+ }
+
+ if (r == 0)
+ break;
+
+ buflen += r;
+ }
+
+ if (buflen == 0)
+ break;
+
+ if (skip > 0) {
+ skip -= buflen;
+ buflen = 0;
+ if (skip <= 0)
+ indicate_writing(mtd);
+
+ continue;
+ }
+
+ if (jffs2file) {
+ if (memcmp(buf, JFFS2_EOF, sizeof(JFFS2_EOF) - 1) == 0) {
+ if (!quiet)
+ fprintf(stderr, "\b\b\b ");
+ if (quiet < 2)
+ fprintf(stderr, "\nAppending jffs2 data from %s to %s...", jffs2file, mtd);
+ /* got an EOF marker - this is the place to add some jffs2 data */
+ skip = mtd_replace_jffs2(mtd, fd, e, jffs2file);
+ jffs2_replaced = 1;
+
+ /* don't add it again */
+ jffs2file = NULL;
+
+ w += skip;
+ e += skip;
+ skip -= buflen;
+ buflen = 0;
+ offset = 0;
+ continue;
+ }
+ /* no EOF marker, make sure we figure out the last inode number
+ * before appending some data */
+ mtd_parse_jffs2data(buf, jffs2dir);
+ }
+
+ /* need to erase the next block before writing data to it */
+ if(!no_erase)
+ {
+ while (w + buflen > e) {
+ if (!quiet)
+ fprintf(stderr, "\b\b\b[e]");
+
+
+ if (mtd_erase_block(fd, e) < 0) {
+ if (next) {
+ if (w < e) {
+ write(fd, buf + offset, e - w);
+ offset = e - w;
+ }
+ w = 0;
+ e = 0;
+ close(fd);
+ mtd = next;
+ fprintf(stderr, "\b\b\b \n");
+ goto resume;
+ } else {
+ fprintf(stderr, "Failed to erase block\n");
+ exit(1);
+ }
+ }
+
+ /* erase the chunk */
+ e += erasesize;
+ }
+ }
+
+ if (!quiet)
+ fprintf(stderr, "\b\b\b[w]");
+
+ if ((result = write(fd, buf + offset, buflen)) < buflen) {
+ if (result < 0) {
+ fprintf(stderr, "Error writing image.\n");
+ exit(1);
+ } else {
+ fprintf(stderr, "Insufficient space.\n");
+ exit(1);
+ }
+ }
+ w += buflen;
+
+ buflen = 0;
+ offset = 0;
+ }
+
+ if (jffs2_replaced && trx_fixup) {
+ trx_fixup(fd, mtd);
+ }
+
+ if (!quiet)
+ fprintf(stderr, "\b\b\b\b ");
+
+done:
+ if (quiet < 2)
+ fprintf(stderr, "\n");
+
+#ifdef FIS_SUPPORT
+ if (fis_layout) {
+ if (fis_remap(old_parts, n_old, new_parts, n_new) < 0)
+ fprintf(stderr, "Failed to update the FIS partition table\n");
+ }
+#endif
+
+ close(fd);
+ return 0;
+}
+
+static void usage(void)
+{
+ fprintf(stderr, "Usage: mtd [<options> ...] <command> [<arguments> ...] <device>[:<device>...]\n\n"
+ "The device is in the format of mtdX (eg: mtd4) or its label.\n"
+ "mtd recognizes these commands:\n"
+ " unlock unlock the device\n"
+ " refresh refresh mtd partition\n"
+ " erase erase all data on device\n"
+ " write <imagefile>|- write <imagefile> (use - for stdin) to device\n"
+ " jffs2write <file> append <file> to the jffs2 partition on the device\n");
+ if (mtd_fixtrx) {
+ fprintf(stderr,
+ " fixtrx fix the checksum in a trx header on first boot\n");
+ }
+ if (mtd_fixseama) {
+ fprintf(stderr,
+ " fixseama fix the checksum in a seama header on first boot\n");
+ }
+ fprintf(stderr,
+ "Following options are available:\n"
+ " -q quiet mode (once: no [w] on writing,\n"
+ " twice: no status messages)\n"
+ " -n write without first erasing the blocks\n"
+ " -r reboot after successful command\n"
+ " -f force write without trx checks\n"
+ " -e <device> erase <device> before executing the command\n"
+ " -d <name> directory for jffs2write, defaults to \"tmp\"\n"
+ " -j <name> integrate <file> into jffs2 data when writing an image\n"
+ " -p write beginning at partition offset\n");
+ if (mtd_fixtrx) {
+ fprintf(stderr,
+ " -o offset offset of the image header in the partition(for fixtrx)\n");
+ }
+ fprintf(stderr,
+#ifdef FIS_SUPPORT
+ " -F <part>[:<size>[:<entrypoint>]][,<part>...]\n"
+ " alter the fis partition table to create new partitions replacing\n"
+ " the partitions provided as argument to the write command\n"
+ " (only valid together with the write command)\n"
+#endif
+ "\n"
+ "Example: To write linux.trx to mtd4 labeled as linux and reboot afterwards\n"
+ " mtd -r write linux.trx linux\n\n");
+ exit(1);
+}
+
+static void do_reboot(void)
+{
+ fprintf(stderr, "Rebooting ...\n");
+ fflush(stderr);
+
+ /* try regular reboot method first */
+ system("/sbin/reboot");
+ sleep(2);
+
+ /* if we're still alive at this point, force the kernel to reboot */
+ syscall(SYS_reboot,LINUX_REBOOT_MAGIC1,LINUX_REBOOT_MAGIC2,LINUX_REBOOT_CMD_RESTART,NULL);
+}
+
+int main (int argc, char **argv)
+{
+ int ch, i, boot, imagefd = 0, force, unlocked;
+ char *erase[MAX_ARGS], *device = NULL;
+ char *fis_layout = NULL;
+ size_t offset = 0, part_offset = 0;
+ enum {
+ CMD_ERASE,
+ CMD_WRITE,
+ CMD_UNLOCK,
+ CMD_REFRESH,
+ CMD_JFFS2WRITE,
+ CMD_FIXTRX,
+ CMD_FIXSEAMA,
+ } cmd = -1;
+
+ erase[0] = NULL;
+ boot = 0;
+ force = 0;
+ buflen = 0;
+ quiet = 0;
+ no_erase = 0;
+
+ while ((ch = getopt(argc, argv,
+#ifdef FIS_SUPPORT
+ "F:"
+#endif
+ "frnqe:d:j:p:o:")) != -1)
+ switch (ch) {
+ case 'f':
+ force = 1;
+ break;
+ case 'r':
+ boot = 1;
+ break;
+ case 'n':
+ no_erase = 1;
+ break;
+ case 'j':
+ jffs2file = optarg;
+ break;
+ case 'q':
+ quiet++;
+ break;
+ case 'e':
+ i = 0;
+ while ((erase[i] != NULL) && ((i + 1) < MAX_ARGS))
+ i++;
+
+ erase[i++] = optarg;
+ erase[i] = NULL;
+ break;
+ case 'd':
+ jffs2dir = optarg;
+ break;
+ case 'p':
+ errno = 0;
+ part_offset = strtoul(optarg, 0, 0);
+ if (errno) {
+ fprintf(stderr, "-p: illegal numeric string\n");
+ usage();
+ }
+ break;
+ case 'o':
+ if (!mtd_fixtrx) {
+ fprintf(stderr, "-o: is not available on this platform\n");
+ usage();
+ }
+ errno = 0;
+ offset = strtoul(optarg, 0, 0);
+ if (errno) {
+ fprintf(stderr, "-o: illegal numeric string\n");
+ usage();
+ }
+ break;
+#ifdef FIS_SUPPORT
+ case 'F':
+ fis_layout = optarg;
+ break;
+#endif
+ case '?':
+ default:
+ usage();
+ }
+ argc -= optind;
+ argv += optind;
+
+ if (argc < 2)
+ usage();
+
+ if ((strcmp(argv[0], "unlock") == 0) && (argc == 2)) {
+ cmd = CMD_UNLOCK;
+ device = argv[1];
+ } else if ((strcmp(argv[0], "refresh") == 0) && (argc == 2)) {
+ cmd = CMD_REFRESH;
+ device = argv[1];
+ } else if ((strcmp(argv[0], "erase") == 0) && (argc == 2)) {
+ cmd = CMD_ERASE;
+ device = argv[1];
+ } else if (((strcmp(argv[0], "fixtrx") == 0) && (argc == 2)) && mtd_fixtrx) {
+ cmd = CMD_FIXTRX;
+ device = argv[1];
+ } else if (((strcmp(argv[0], "fixseama") == 0) && (argc == 2)) && mtd_fixseama) {
+ cmd = CMD_FIXSEAMA;
+ device = argv[1];
+ } else if ((strcmp(argv[0], "write") == 0) && (argc == 3)) {
+ cmd = CMD_WRITE;
+ device = argv[2];
+
+ if (strcmp(argv[1], "-") == 0) {
+ imagefile = "<stdin>";
+ imagefd = 0;
+ } else {
+ imagefile = argv[1];
+ if ((imagefd = open(argv[1], O_RDONLY)) < 0) {
+ fprintf(stderr, "Couldn't open image file: %s!\n", imagefile);
+ exit(1);
+ }
+ }
+
+ if (!mtd_check(device)) {
+ fprintf(stderr, "Can't open device for writing!\n");
+ exit(1);
+ }
+ /* check trx file before erasing or writing anything */
+ if (!image_check(imagefd, device) && !force) {
+ fprintf(stderr, "Image check failed.\n");
+ exit(1);
+ }
+ } else if ((strcmp(argv[0], "jffs2write") == 0) && (argc == 3)) {
+ cmd = CMD_JFFS2WRITE;
+ device = argv[2];
+
+ imagefile = argv[1];
+ if (!mtd_check(device)) {
+ fprintf(stderr, "Can't open device for writing!\n");
+ exit(1);
+ }
+ } else {
+ usage();
+ }
+
+ sync();
+
+ i = 0;
+ unlocked = 0;
+ while (erase[i] != NULL) {
+ mtd_unlock(erase[i]);
+ mtd_erase(erase[i]);
+ if (strcmp(erase[i], device) == 0)
+ unlocked = 1;
+ i++;
+ }
+
+ switch (cmd) {
+ case CMD_UNLOCK:
+ if (!unlocked)
+ mtd_unlock(device);
+ break;
+ case CMD_ERASE:
+ if (!unlocked)
+ mtd_unlock(device);
+ mtd_erase(device);
+ break;
+ case CMD_WRITE:
+ if (!unlocked)
+ mtd_unlock(device);
+ mtd_write(imagefd, device, fis_layout, part_offset);
+ break;
+ case CMD_JFFS2WRITE:
+ if (!unlocked)
+ mtd_unlock(device);
+ mtd_write_jffs2(device, imagefile, jffs2dir);
+ break;
+ case CMD_REFRESH:
+ mtd_refresh(device);
+ break;
+ case CMD_FIXTRX:
+ if (mtd_fixtrx) {
+ mtd_fixtrx(device, offset);
+ }
+ case CMD_FIXSEAMA:
+ if (mtd_fixseama)
+ mtd_fixseama(device, 0);
+ break;
+ }
+
+ sync();
+
+ if (boot)
+ do_reboot();
+
+ return 0;
+}
diff --git a/package/mtd/src/mtd.h b/package/mtd/src/mtd.h
new file mode 100644
index 0000000..c2133fc
--- /dev/null
+++ b/package/mtd/src/mtd.h
@@ -0,0 +1,29 @@
+#ifndef __mtd_h
+#define __mtd_h
+
+#include <stdbool.h>
+
+#ifdef target_brcm47xx
+#define target_brcm 1
+#endif
+
+#define JFFS2_EOF "\xde\xad\xc0\xde"
+
+extern int quiet;
+extern int mtdsize;
+extern int erasesize;
+
+extern int mtd_open(const char *mtd, bool block);
+extern int mtd_check_open(const char *mtd);
+extern int mtd_erase_block(int fd, int offset);
+extern int mtd_write_buffer(int fd, const char *buf, int offset, int length);
+extern int mtd_write_jffs2(const char *mtd, const char *filename, const char *dir);
+extern int mtd_replace_jffs2(const char *mtd, int fd, int ofs, const char *filename);
+extern void mtd_parse_jffs2data(const char *buf, const char *dir);
+
+/* target specific functions */
+extern int trx_fixup(int fd, const char *name) __attribute__ ((weak));
+extern int trx_check(int imagefd, const char *mtd, char *buf, int *len) __attribute__ ((weak));
+extern int mtd_fixtrx(const char *mtd, size_t offset) __attribute__ ((weak));
+extern int mtd_fixseama(const char *mtd, size_t offset) __attribute__ ((weak));
+#endif /* __mtd_h */
diff --git a/package/mtd/src/seama.c b/package/mtd/src/seama.c
new file mode 100644
index 0000000..b0c8bf3
--- /dev/null
+++ b/package/mtd/src/seama.c
@@ -0,0 +1,179 @@
+/*
+ * seama.c
+ *
+ * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
+ *
+ * Based on the trx fixup code:
+ * Copyright (C) 2005 Mike Baker
+ * Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
+ *
+ * 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
+ * of the License, 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stddef.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <string.h>
+#include <errno.h>
+#include <arpa/inet.h>
+
+#include <sys/ioctl.h>
+#include <mtd/mtd-user.h>
+#include "mtd.h"
+#include "seama.h"
+#include "md5.h"
+
+#if __BYTE_ORDER == __BIG_ENDIAN
+#define STORE32_LE(X) ((((X) & 0x000000FF) << 24) | (((X) & 0x0000FF00) << 8) | (((X) & 0x00FF0000) >> 8) | (((X) & 0xFF000000) >> 24))
+#elif __BYTE_ORDER == __LITTLE_ENDIAN
+#define STORE32_LE(X) (X)
+#else
+#error unknown endianness!
+#endif
+
+ssize_t pread(int fd, void *buf, size_t count, off_t offset);
+ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset);
+
+int
+seama_fix_md5(char *buf, size_t len)
+{
+ struct seama_hdr *shdr;
+ char *data;
+ size_t msize;
+ size_t isize;
+ MD5_CTX ctx;
+ unsigned char digest[16];
+ int i;
+
+ if (len < sizeof(struct seama_hdr))
+ return -1;
+
+ shdr = (struct seama_hdr *) buf;
+ if (shdr->magic != htonl(SEAMA_MAGIC)) {
+ fprintf(stderr, "no SEAMA header found\n");
+ return -1;
+ }
+
+ isize = ntohl(shdr->size);
+ msize = ntohs(shdr->metasize);
+ if (isize == 0) {
+ /* the image contains no checksum */
+ return -1;
+ }
+
+ len -= sizeof(struct seama_hdr) + sizeof(digest) + msize;
+ if (isize > len)
+ isize = len;
+
+ data = buf + sizeof(struct seama_hdr) + sizeof(digest) + msize;
+
+ MD5_Init(&ctx);
+ MD5_Update(&ctx, data, isize);
+ MD5_Final(digest, &ctx);
+
+ if (!memcmp(digest, &buf[sizeof(struct seama_hdr)], sizeof(digest))) {
+ if (quiet < 2)
+ fprintf(stderr, "the header is fixed already\n");
+ return -1;
+ }
+
+ if (quiet < 2) {
+ fprintf(stderr, "new size:%u, new MD5: ", isize);
+ for (i = 0; i < sizeof(digest); i++)
+ fprintf(stderr, "%02x", digest[i]);
+
+ fprintf(stderr, "\n");
+ }
+
+ /* update the size in the image */
+ shdr->size = htonl(isize);
+
+ /* update the checksum in the image */
+ for (i = 0; i < sizeof(digest); i++)
+ buf[sizeof(struct seama_hdr) + i] = digest[i];
+
+ return 0;
+}
+
+int
+mtd_fixseama(const char *mtd, size_t offset)
+{
+ int fd;
+ char *buf;
+ ssize_t res;
+ size_t block_offset;
+
+ if (quiet < 2)
+ fprintf(stderr, "Trying to fix SEAMA header in %s at 0x%x...\n",
+ mtd, offset);
+
+ block_offset = offset & ~(erasesize - 1);
+ offset -= block_offset;
+
+ fd = mtd_check_open(mtd);
+ if(fd < 0) {
+ fprintf(stderr, "Could not open mtd device: %s\n", mtd);
+ exit(1);
+ }
+
+ if (block_offset + erasesize > mtdsize) {
+ fprintf(stderr, "Offset too large, device size 0x%x\n",
+ mtdsize);
+ exit(1);
+ }
+
+ buf = malloc(mtdsize);
+ if (!buf) {
+ perror("malloc");
+ exit(1);
+ }
+
+ res = pread(fd, buf, mtdsize, block_offset);
+ if (res != mtdsize) {
+ perror("pread");
+ exit(1);
+ }
+
+ if (seama_fix_md5(buf, mtdsize))
+ goto out;
+
+ if (mtd_erase_block(fd, block_offset)) {
+ fprintf(stderr, "Can't erease block at 0x%x (%s)\n",
+ block_offset, strerror(errno));
+ exit(1);
+ }
+
+ if (quiet < 2)
+ fprintf(stderr, "Rewriting block at 0x%x\n", block_offset);
+
+ if (pwrite(fd, buf, erasesize, block_offset) != erasesize) {
+ fprintf(stderr, "Error writing block (%s)\n", strerror(errno));
+ exit(1);
+ }
+
+ if (quiet < 2)
+ fprintf(stderr, "Done.\n");
+
+out:
+ close (fd);
+ sync();
+
+ return 0;
+}
+
diff --git a/package/mtd/src/seama.h b/package/mtd/src/seama.h
new file mode 100644
index 0000000..02683b6
--- /dev/null
+++ b/package/mtd/src/seama.h
@@ -0,0 +1,108 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * (SEA)ttle i(MA)ge is the image which used in project seattle.
+ *
+ * Created by David Hsieh <david_hsieh@alphanetworks.com>
+ * Copyright (C) 2008-2009 Alpha Networks, Inc.
+ *
+ * This file is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either'
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * The GNU C Library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the GNU C Library; if not, write to the Free
+ * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ * 02111-1307 USA.
+ */
+
+#ifndef __SEAMA_HEADER_FILE__
+#define __SEAMA_HEADER_FILE__
+
+#include <stdint.h>
+
+#define SEAMA_MAGIC 0x5EA3A417
+
+/*
+ * SEAMA looks like the following map.
+ * All the data of the header should be in network byte order.
+ *
+ * +-------------+-------------+------------
+ * | SEAMA magic | ^
+ * +-------------+-------------+ |
+ * | reserved | meta size | |
+ * +-------------+-------------+ header
+ * | image size (0 bytes) | |
+ * +-------------+-------------+ |
+ * ~ Meta data ~ v
+ * +-------------+-------------+------------
+ * | SEAMA magic | ^ ^
+ * +-------------+-------------+ | |
+ * | reserved | meta size | | |
+ * +-------------+-------------+ | |
+ * | image size | | |
+ * +-------------+-------------+ header |
+ * | | | |
+ * | 16 bytes of MD5 digest | | |
+ * | | | |
+ * | | | |
+ * +-------------+-------------+ | |
+ * ~ Meta data ~ v |
+ * +-------------+-------------+------- |
+ * | | |
+ * | Image of the 1st entity | |
+ * ~ ~ 1st entity
+ * | | |
+ * | | v
+ * +-------------+-------------+-------------
+ * | SEAMA magic | ^ ^
+ * +-------------+-------------+ | |
+ * | reserved | meta size | | |
+ * +-------------+-------------+ | |
+ * | image size | | |
+ * +-------------+-------------+ header |
+ * | | | |
+ * | 16 bytes of MD5 digest | | |
+ * | | | |
+ * | | | |
+ * +-------------+-------------+ | |
+ * ~ Meta data ~ v |
+ * +-------------+-------------+------- |
+ * | | |
+ * | Image of the 2nd entity | |
+ * ~ ~ 2nd entity
+ * | | |
+ * | | v
+ * +-------------+-------------+-------------
+ */
+
+
+/*
+ * SEAMA header
+ *
+ * |<-------- 32 bits -------->|
+ * +-------------+-------------+
+ * | SEAMA magic |
+ * +-------------+-------------+
+ * | reserved | meta size |
+ * +-------------+-------------+
+ * | image size |
+ * +-------------+-------------+
+ */
+/* seama header */
+typedef struct seama_hdr seamahdr_t;
+struct seama_hdr
+{
+ uint32_t magic; /* should always be SEAMA_MAGIC. */
+ uint16_t reserved; /* reserved for */
+ uint16_t metasize; /* size of the META data */
+ uint32_t size; /* size of the image */
+} __attribute__ ((packed));
+
+
+#endif
diff --git a/package/mtd/src/trx.c b/package/mtd/src/trx.c
new file mode 100644
index 0000000..65c2440
--- /dev/null
+++ b/package/mtd/src/trx.c
@@ -0,0 +1,220 @@
+/*
+ * trx.c
+ *
+ * Copyright (C) 2005 Mike Baker
+ * Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
+ *
+ * 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
+ * of the License, 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stddef.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <string.h>
+#include <errno.h>
+
+#include <sys/ioctl.h>
+#include <mtd/mtd-user.h>
+#include "mtd.h"
+#include "crc32.h"
+
+#define TRX_MAGIC 0x30524448 /* "HDR0" */
+struct trx_header {
+ uint32_t magic; /* "HDR0" */
+ uint32_t len; /* Length of file including header */
+ uint32_t crc32; /* 32-bit CRC from flag_version to end of file */
+ uint32_t flag_version; /* 0:15 flags, 16:31 version */
+ uint32_t offsets[3]; /* Offsets of partitions from start of header */
+};
+
+#if __BYTE_ORDER == __BIG_ENDIAN
+#define STORE32_LE(X) ((((X) & 0x000000FF) << 24) | (((X) & 0x0000FF00) << 8) | (((X) & 0x00FF0000) >> 8) | (((X) & 0xFF000000) >> 24))
+#elif __BYTE_ORDER == __LITTLE_ENDIAN
+#define STORE32_LE(X) (X)
+#else
+#error unknown endianness!
+#endif
+
+ssize_t pread(int fd, void *buf, size_t count, off_t offset);
+ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset);
+
+int
+trx_fixup(int fd, const char *name)
+{
+ struct mtd_info_user mtdInfo;
+ unsigned long len;
+ struct trx_header *trx;
+ void *ptr, *scan;
+ int bfd;
+
+ if (ioctl(fd, MEMGETINFO, &mtdInfo) < 0) {
+ fprintf(stderr, "Failed to get mtd info\n");
+ goto err;
+ }
+
+ len = mtdInfo.size;
+ if (mtdInfo.size <= 0) {
+ fprintf(stderr, "Invalid MTD device size\n");
+ goto err;
+ }
+
+ bfd = mtd_open(name, true);
+ ptr = mmap(NULL, len, PROT_READ|PROT_WRITE, MAP_SHARED, bfd, 0);
+ if (!ptr || (ptr == (void *) -1)) {
+ perror("mmap");
+ goto err1;
+ }
+
+ trx = ptr;
+ if (trx->magic != TRX_MAGIC) {
+ fprintf(stderr, "TRX header not found\n");
+ goto err;
+ }
+
+ scan = ptr + offsetof(struct trx_header, flag_version);
+ trx->crc32 = crc32buf(scan, trx->len - (scan - ptr));
+ msync(ptr, sizeof(struct trx_header), MS_SYNC|MS_INVALIDATE);
+ munmap(ptr, len);
+ close(bfd);
+ return 0;
+
+err1:
+ close(bfd);
+err:
+ fprintf(stderr, "Error fixing up TRX header\n");
+ return -1;
+}
+
+int
+trx_check(int imagefd, const char *mtd, char *buf, int *len)
+{
+ const struct trx_header *trx = (const struct trx_header *) buf;
+ int fd;
+
+ if (strcmp(mtd, "linux") != 0)
+ return 1;
+
+ *len = read(imagefd, buf, 32);
+ if (*len < 32) {
+ fprintf(stdout, "Could not get image header, file too small (%d bytes)\n", *len);
+ return 0;
+ }
+
+ if (trx->magic != TRX_MAGIC || trx->len < sizeof(struct trx_header)) {
+ if (quiet < 2) {
+ fprintf(stderr, "Bad trx header\n");
+ fprintf(stderr, "This is not the correct file format; refusing to flash.\n"
+ "Please specify the correct file or use -f to force.\n");
+ }
+ return 0;
+ }
+
+ /* check if image fits to mtd device */
+ fd = mtd_check_open(mtd);
+ if(fd < 0) {
+ fprintf(stderr, "Could not open mtd device: %s\n", mtd);
+ exit(1);
+ }
+
+ if(mtdsize < trx->len) {
+ fprintf(stderr, "Image too big for partition: %s\n", mtd);
+ close(fd);
+ return 0;
+ }
+
+ close(fd);
+ return 1;
+}
+
+int
+mtd_fixtrx(const char *mtd, size_t offset)
+{
+ int fd;
+ struct trx_header *trx;
+ char *buf;
+ ssize_t res;
+ size_t block_offset;
+
+ if (quiet < 2)
+ fprintf(stderr, "Trying to fix trx header in %s at 0x%x...\n", mtd, offset);
+
+ fd = mtd_check_open(mtd);
+ if(fd < 0) {
+ fprintf(stderr, "Could not open mtd device: %s\n", mtd);
+ exit(1);
+ }
+
+ block_offset = offset & ~(erasesize - 1);
+ offset -= block_offset;
+
+ if (block_offset + erasesize > mtdsize) {
+ fprintf(stderr, "Offset too large, device size 0x%x\n", mtdsize);
+ exit(1);
+ }
+
+ buf = malloc(erasesize);
+ if (!buf) {
+ perror("malloc");
+ exit(1);
+ }
+
+ res = pread(fd, buf, erasesize, block_offset);
+ if (res != erasesize) {
+ perror("pread");
+ exit(1);
+ }
+
+ trx = (struct trx_header *) (buf + offset);
+ if (trx->magic != STORE32_LE(0x30524448)) {
+ fprintf(stderr, "No trx magic found\n");
+ exit(1);
+ }
+
+ if (trx->len == STORE32_LE(erasesize - offset)) {
+ if (quiet < 2)
+ fprintf(stderr, "Header already fixed, exiting\n");
+ close(fd);
+ return 0;
+ }
+
+ trx->len = STORE32_LE(erasesize - offset);
+
+ trx->crc32 = STORE32_LE(crc32buf((char*) &trx->flag_version, erasesize - offset - 3*4));
+ if (mtd_erase_block(fd, block_offset)) {
+ fprintf(stderr, "Can't erease block at 0x%x (%s)\n", block_offset, strerror(errno));
+ exit(1);
+ }
+
+ if (quiet < 2)
+ fprintf(stderr, "New crc32: 0x%x, rewriting block\n", trx->crc32);
+
+ if (pwrite(fd, buf, erasesize, block_offset) != erasesize) {
+ fprintf(stderr, "Error writing block (%s)\n", strerror(errno));
+ exit(1);
+ }
+
+ if (quiet < 2)
+ fprintf(stderr, "Done.\n");
+
+ close (fd);
+ sync();
+ return 0;
+
+}
+
diff --git a/package/network/.svn/entries b/package/network/.svn/entries
new file mode 100644
index 0000000..d019d4e
--- /dev/null
+++ b/package/network/.svn/entries
@@ -0,0 +1,40 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-15T13:43:55.120823Z
+36034
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+utils
+dir
+
+services
+dir
+
+ipv6
+dir
+
+config
+dir
+
diff --git a/package/network/config/.svn/entries b/package/network/config/.svn/entries
new file mode 100644
index 0000000..d67b0a3
--- /dev/null
+++ b/package/network/config/.svn/entries
@@ -0,0 +1,49 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/config
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-14T15:29:43.028686Z
+36009
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+swconfig
+dir
+
+firewall
+dir
+
+qos-scripts
+dir
+
+soloscli
+dir
+
+firewall3
+dir
+
+netifd
+dir
+
+ltq-dsl-app
+dir
+
diff --git a/package/network/config/firewall/.svn/entries b/package/network/config/firewall/.svn/entries
new file mode 100644
index 0000000..71ff12e
--- /dev/null
+++ b/package/network/config/firewall/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/config/firewall
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-02-22T13:45:20.660376Z
+35745
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+files
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+9c007669af2d2b8ab109dc5c431df790
+2013-02-22T13:45:20.660376Z
+35745
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1568
+
diff --git a/package/network/config/firewall/.svn/text-base/Makefile.svn-base b/package/network/config/firewall/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..998b274
--- /dev/null
+++ b/package/network/config/firewall/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,58 @@
+#
+# Copyright (C) 2008-2013 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=firewall
+
+PKG_VERSION:=2
+PKG_RELEASE:=59
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/firewall
+ SECTION:=net
+ CATEGORY:=Base system
+ URL:=http://openwrt.org/
+ TITLE:=OpenWrt firewall
+ MAINTAINER:=Jo-Philipp Wich <xm@subsignal.org>
+ DEPENDS:=+iptables +kmod-ipt-conntrack +kmod-ipt-nat
+ PKGARCH:=all
+endef
+
+define Package/firewall/description
+ UCI based firewall for OpenWrt
+endef
+
+define Build/Compile
+ true
+endef
+
+define Package/firewall/conffiles
+/etc/config/firewall
+/etc/firewall.user
+endef
+
+define Package/firewall/install
+ $(INSTALL_DIR) $(1)/lib/firewall
+ $(INSTALL_DATA) ./files/lib/*.sh $(1)/lib/firewall
+ $(INSTALL_DIR) $(1)/sbin
+ $(INSTALL_BIN) ./files/bin/fw $(1)/sbin
+ $(INSTALL_DIR) $(1)/etc/config
+ $(INSTALL_DATA) ./files/firewall.config $(1)/etc/config/firewall
+ $(INSTALL_DIR) $(1)/etc/init.d/
+ $(INSTALL_BIN) ./files/firewall.init $(1)/etc/init.d/firewall
+ $(INSTALL_DIR) $(1)/etc/hotplug.d/iface
+ $(INSTALL_DATA) ./files/firewall.hotplug $(1)/etc/hotplug.d/iface/20-firewall
+ $(INSTALL_DIR) $(1)/etc/hotplug.d/firewall
+ $(INSTALL_DATA) ./files/reflection.hotplug $(1)/etc/hotplug.d/firewall/10-nat-reflection
+ $(INSTALL_DIR) $(1)/etc
+ $(INSTALL_DATA) ./files/firewall.user $(1)/etc
+ $(INSTALL_DIR) $(1)/lib/upgrade/keep.d
+ $(INSTALL_DATA) ./files/firewall.upgrade $(1)/lib/upgrade/keep.d/firewall
+endef
+
+$(eval $(call BuildPackage,firewall))
diff --git a/package/network/config/firewall/Makefile b/package/network/config/firewall/Makefile
new file mode 100644
index 0000000..998b274
--- /dev/null
+++ b/package/network/config/firewall/Makefile
@@ -0,0 +1,58 @@
+#
+# Copyright (C) 2008-2013 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=firewall
+
+PKG_VERSION:=2
+PKG_RELEASE:=59
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/firewall
+ SECTION:=net
+ CATEGORY:=Base system
+ URL:=http://openwrt.org/
+ TITLE:=OpenWrt firewall
+ MAINTAINER:=Jo-Philipp Wich <xm@subsignal.org>
+ DEPENDS:=+iptables +kmod-ipt-conntrack +kmod-ipt-nat
+ PKGARCH:=all
+endef
+
+define Package/firewall/description
+ UCI based firewall for OpenWrt
+endef
+
+define Build/Compile
+ true
+endef
+
+define Package/firewall/conffiles
+/etc/config/firewall
+/etc/firewall.user
+endef
+
+define Package/firewall/install
+ $(INSTALL_DIR) $(1)/lib/firewall
+ $(INSTALL_DATA) ./files/lib/*.sh $(1)/lib/firewall
+ $(INSTALL_DIR) $(1)/sbin
+ $(INSTALL_BIN) ./files/bin/fw $(1)/sbin
+ $(INSTALL_DIR) $(1)/etc/config
+ $(INSTALL_DATA) ./files/firewall.config $(1)/etc/config/firewall
+ $(INSTALL_DIR) $(1)/etc/init.d/
+ $(INSTALL_BIN) ./files/firewall.init $(1)/etc/init.d/firewall
+ $(INSTALL_DIR) $(1)/etc/hotplug.d/iface
+ $(INSTALL_DATA) ./files/firewall.hotplug $(1)/etc/hotplug.d/iface/20-firewall
+ $(INSTALL_DIR) $(1)/etc/hotplug.d/firewall
+ $(INSTALL_DATA) ./files/reflection.hotplug $(1)/etc/hotplug.d/firewall/10-nat-reflection
+ $(INSTALL_DIR) $(1)/etc
+ $(INSTALL_DATA) ./files/firewall.user $(1)/etc
+ $(INSTALL_DIR) $(1)/lib/upgrade/keep.d
+ $(INSTALL_DATA) ./files/firewall.upgrade $(1)/lib/upgrade/keep.d/firewall
+endef
+
+$(eval $(call BuildPackage,firewall))
diff --git a/package/network/config/firewall/files/.svn/entries b/package/network/config/firewall/files/.svn/entries
new file mode 100644
index 0000000..a284479
--- /dev/null
+++ b/package/network/config/firewall/files/.svn/entries
@@ -0,0 +1,238 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/config/firewall/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-02-22T13:45:20.660376Z
+35745
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+firewall.user
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+43e25ef73306f7ea73813d648990b181
+2009-04-12T22:38:34.928337Z
+15221
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+139
+
+lib
+dir
+
+firewall.hotplug
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+3e4ca650dcd8df46170f1bd1957af5e2
+2012-06-05T16:04:23.055438Z
+32062
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+537
+
+firewall.init
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+b16182f0af632fe00a9a703f7e18acb1
+2010-05-19T00:50:14.834146Z
+21502
+jow
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+233
+
+bin
+dir
+
+firewall.config
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+f952253dc6cb85d189857c3fead88362
+2013-01-04T15:59:28.919139Z
+35012
+cyrus
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4244
+
+firewall.upgrade
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+701504dad753d669d9667c04214bd28c
+2011-03-20T00:57:47.962557Z
+26241
+thepeople
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+19
+
+reflection.hotplug
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+0f2936ae3cb153db2a8a85a395d7257f
+2012-12-07T13:08:28.401778Z
+34569
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3935
+
diff --git a/package/network/config/firewall/files/.svn/prop-base/firewall.config.svn-base b/package/network/config/firewall/files/.svn/prop-base/firewall.config.svn-base
new file mode 100644
index 0000000..3160658
--- /dev/null
+++ b/package/network/config/firewall/files/.svn/prop-base/firewall.config.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:mergeinfo
+V 0
+
+END
diff --git a/package/network/config/firewall/files/.svn/prop-base/firewall.init.svn-base b/package/network/config/firewall/files/.svn/prop-base/firewall.init.svn-base
new file mode 100644
index 0000000..8d28d86
--- /dev/null
+++ b/package/network/config/firewall/files/.svn/prop-base/firewall.init.svn-base
@@ -0,0 +1,9 @@
+K 14
+svn:executable
+V 1
+*
+K 13
+svn:mergeinfo
+V 0
+
+END
diff --git a/package/network/config/firewall/files/.svn/text-base/firewall.config.svn-base b/package/network/config/firewall/files/.svn/text-base/firewall.config.svn-base
new file mode 100644
index 0000000..6acfe1e
--- /dev/null
+++ b/package/network/config/firewall/files/.svn/text-base/firewall.config.svn-base
@@ -0,0 +1,195 @@
+config defaults
+ option syn_flood 1
+ option input ACCEPT
+ option output ACCEPT
+ option forward REJECT
+# Uncomment this line to disable ipv6 rules
+# option disable_ipv6 1
+
+config zone
+ option name lan
+ option network 'lan'
+ option input ACCEPT
+ option output ACCEPT
+ option forward REJECT
+
+config zone
+ option name wan
+ option network 'wan'
+ option input REJECT
+ option output ACCEPT
+ option forward REJECT
+ option masq 1
+ option mtu_fix 1
+
+config forwarding
+ option src lan
+ option dest wan
+
+# We need to accept udp packets on port 68,
+# see https://dev.openwrt.org/ticket/4108
+config rule
+ option name Allow-DHCP-Renew
+ option src wan
+ option proto udp
+ option dest_port 68
+ option target ACCEPT
+ option family ipv4
+
+# Allow IPv4 ping
+config rule
+ option name Allow-Ping
+ option src wan
+ option proto icmp
+ option icmp_type echo-request
+ option family ipv4
+ option target ACCEPT
+
+# Allow DHCPv6 replies
+# see https://dev.openwrt.org/ticket/10381
+config rule
+ option name Allow-DHCPv6
+ option src wan
+ option proto udp
+ option src_ip fe80::/10
+ option src_port 547
+ option dest_ip fe80::/10
+ option dest_port 546
+ option family ipv6
+ option target ACCEPT
+
+# Allow essential incoming IPv6 ICMP traffic
+config rule
+ option name Allow-ICMPv6-Input
+ option src wan
+ option proto icmp
+ list icmp_type echo-request
+ list icmp_type echo-reply
+ list icmp_type destination-unreachable
+ list icmp_type packet-too-big
+ list icmp_type time-exceeded
+ list icmp_type bad-header
+ list icmp_type unknown-header-type
+ list icmp_type router-solicitation
+ list icmp_type neighbour-solicitation
+ list icmp_type router-advertisement
+ list icmp_type neighbour-advertisement
+ option limit 1000/sec
+ option family ipv6
+ option target ACCEPT
+
+# Allow essential forwarded IPv6 ICMP traffic
+config rule
+ option name Allow-ICMPv6-Forward
+ option src wan
+ option dest *
+ option proto icmp
+ list icmp_type echo-request
+ list icmp_type echo-reply
+ list icmp_type destination-unreachable
+ list icmp_type packet-too-big
+ list icmp_type time-exceeded
+ list icmp_type bad-header
+ list icmp_type unknown-header-type
+ option limit 1000/sec
+ option family ipv6
+ option target ACCEPT
+
+# Block ULA-traffic from leaking out
+config rule
+ option name Enforce-ULA-Border-Src
+ option src *
+ option dest wan
+ option proto all
+ option src_ip fc00::/7
+ option family ipv6
+ option target REJECT
+
+config rule
+ option name Enforce-ULA-Border-Dest
+ option src *
+ option dest wan
+ option proto all
+ option dest_ip fc00::/7
+ option family ipv6
+ option target REJECT
+
+# include a file with users custom iptables rules
+config include
+ option path /etc/firewall.user
+
+
+### EXAMPLE CONFIG SECTIONS
+# do not allow a specific ip to access wan
+#config rule
+# option src lan
+# option src_ip 192.168.45.2
+# option dest wan
+# option proto tcp
+# option target REJECT
+
+# block a specific mac on wan
+#config rule
+# option dest wan
+# option src_mac 00:11:22:33:44:66
+# option target REJECT
+
+# block incoming ICMP traffic on a zone
+#config rule
+# option src lan
+# option proto ICMP
+# option target DROP
+
+# port redirect port coming in on wan to lan
+#config redirect
+# option src wan
+# option src_dport 80
+# option dest lan
+# option dest_ip 192.168.16.235
+# option dest_port 80
+# option proto tcp
+
+# port redirect of remapped ssh port (22001) on wan
+#config redirect
+# option src wan
+# option src_dport 22001
+# option dest lan
+# option dest_port 22
+# option proto tcp
+
+# allow IPsec/ESP and ISAKMP passthrough
+#config rule
+# option src wan
+# option dest lan
+# option protocol esp
+# option target ACCEPT
+
+#config rule
+# option src wan
+# option dest lan
+# option src_port 500
+# option dest_port 500
+# option proto udp
+# option target ACCEPT
+
+### FULL CONFIG SECTIONS
+#config rule
+# option src lan
+# option src_ip 192.168.45.2
+# option src_mac 00:11:22:33:44:55
+# option src_port 80
+# option dest wan
+# option dest_ip 194.25.2.129
+# option dest_port 120
+# option proto tcp
+# option target REJECT
+
+#config redirect
+# option src lan
+# option src_ip 192.168.45.2
+# option src_mac 00:11:22:33:44:55
+# option src_port 1024
+# option src_dport 80
+# option dest_ip 194.25.2.129
+# option dest_port 120
+# option proto tcp
diff --git a/package/network/config/firewall/files/.svn/text-base/firewall.hotplug.svn-base b/package/network/config/firewall/files/.svn/text-base/firewall.hotplug.svn-base
new file mode 100644
index 0000000..52e7798
--- /dev/null
+++ b/package/network/config/firewall/files/.svn/text-base/firewall.hotplug.svn-base
@@ -0,0 +1,22 @@
+#!/bin/sh
+# This script is executed as part of the hotplug event with
+# HOTPLUG_TYPE=iface, triggered by various scripts when an interface
+# is configured (ACTION=ifup) or deconfigured (ACTION=ifdown). The
+# interface is available as INTERFACE, the real device as DEVICE.
+
+[ "$DEVICE" == "lo" ] && exit 0
+
+. /lib/functions.sh
+. /lib/firewall/core.sh
+
+fw_init
+fw_is_loaded || exit 0
+
+case "$ACTION" in
+ ifup)
+ fw_configure_interface "$INTERFACE" add "$DEVICE" &
+ ;;
+ ifdown)
+ fw_configure_interface "$INTERFACE" del "$DEVICE"
+ ;;
+esac
diff --git a/package/network/config/firewall/files/.svn/text-base/firewall.init.svn-base b/package/network/config/firewall/files/.svn/text-base/firewall.init.svn-base
new file mode 100644
index 0000000..a2fd0a0
--- /dev/null
+++ b/package/network/config/firewall/files/.svn/text-base/firewall.init.svn-base
@@ -0,0 +1,27 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2008-2010 OpenWrt.org
+
+START=45
+
+FW_LIBDIR=/lib/firewall
+
+fw() {
+ . $FW_LIBDIR/core.sh
+ fw_$1
+}
+
+start() {
+ fw start
+}
+
+stop() {
+ fw stop
+}
+
+restart() {
+ fw restart
+}
+
+reload() {
+ fw reload
+}
diff --git a/package/network/config/firewall/files/.svn/text-base/firewall.upgrade.svn-base b/package/network/config/firewall/files/.svn/text-base/firewall.upgrade.svn-base
new file mode 100644
index 0000000..64f63eb
--- /dev/null
+++ b/package/network/config/firewall/files/.svn/text-base/firewall.upgrade.svn-base
@@ -0,0 +1 @@
+/etc/firewall.user
diff --git a/package/network/config/firewall/files/.svn/text-base/firewall.user.svn-base b/package/network/config/firewall/files/.svn/text-base/firewall.user.svn-base
new file mode 100644
index 0000000..1ccbd01
--- /dev/null
+++ b/package/network/config/firewall/files/.svn/text-base/firewall.user.svn-base
@@ -0,0 +1,4 @@
+# This file is interpreted as shell script.
+# Put your custom iptables rules here, they will
+# be executed with each firewall (re-)start.
+
diff --git a/package/network/config/firewall/files/.svn/text-base/reflection.hotplug.svn-base b/package/network/config/firewall/files/.svn/text-base/reflection.hotplug.svn-base
new file mode 100644
index 0000000..129a922
--- /dev/null
+++ b/package/network/config/firewall/files/.svn/text-base/reflection.hotplug.svn-base
@@ -0,0 +1,169 @@
+#!/bin/sh
+
+. /lib/functions.sh
+. /lib/functions/network.sh
+
+if [ "$ACTION" = "remove" ]; then
+
+ delete_rules_by_comment() {
+ local table="$1"
+ local chain="$2"
+ local comment="$3"
+
+ iptables -t "$table" --line-numbers -nL "$chain" 2>/dev/null | \
+ sed -e '
+ 1d;
+ 1! {
+ \#^[0-9]\+ .* /\* '"$comment"' \*/.*$# {
+ s/ .*$//;
+ G; h;
+ }
+ };
+ $!d;
+ ' | xargs -n1 iptables -t "$table" -D "$chain" 2>/dev/null
+ }
+
+ delete_rules_by_comment nat nat_reflection_in "$INTERFACE"
+ delete_rules_by_comment nat nat_reflection_out "$INTERFACE"
+ delete_rules_by_comment filter nat_reflection_fwd "$INTERFACE"
+
+elif [ "$ACTION" = "add" ]; then
+
+ prepare_chains() {
+ iptables -t nat -N nat_reflection_in 2>/dev/null && {
+ iptables -t nat -A prerouting_rule -j nat_reflection_in
+ }
+
+ iptables -t nat -N nat_reflection_out 2>/dev/null && {
+ iptables -t nat -A postrouting_rule -j nat_reflection_out
+ }
+
+ iptables -t filter -N nat_reflection_fwd 2>/dev/null && {
+ iptables -t filter -A forwarding_rule -j nat_reflection_fwd
+ }
+ }
+
+ find_networks() {
+ find_networks_cb() {
+ local cfg="$1"
+ local zone="$2"
+ local need_masq="${3:-0}"
+
+ local name
+ config_get name "$cfg" name
+
+ local masq
+ config_get_bool masq "$cfg" masq 0
+
+ [ "$name" = "$zone" ] && [ "$masq" -ge "$need_masq" ] && {
+ local network
+ config_get network "$cfg" network
+
+ echo ${network:-$zone}
+ return 1
+ }
+ }
+
+ config_foreach find_networks_cb zone "$@"
+ }
+
+ setup_fwd() {
+ local cfg="$1"
+
+ local reflection
+ config_get_bool reflection "$cfg" reflection 1
+ [ "$reflection" == 1 ] || return
+
+ local src
+ config_get src "$cfg" src
+ [ "$src" == "$ZONE" ] || return
+
+ local dest
+ config_get dest "$cfg" dest
+ [ "$dest" != "*" ] || return
+
+ local target
+ config_get target "$cfg" target DNAT
+ [ "$target" = DNAT ] || return
+
+ prepare_chains
+
+ local net
+ for net in $(find_networks "$dest" 0); do
+ local intnet
+ network_get_subnet intnet "$net" || continue
+
+ local proto
+ config_get proto "$cfg" proto
+
+ local epmin epmax extport
+ config_get extport "$cfg" src_dport "1-65535"
+ [ -n "$extport" ] || return
+
+ epmin="${extport%[-:]*}"; epmax="${extport#*[-:]}"
+ [ "${epmin#!}" != "$epmax" ] || epmax=""
+
+ local ipmin ipmax intport
+ config_get intport "$cfg" dest_port "$extport"
+
+ ipmin="${intport%[-:]*}"; ipmax="${intport#*[-:]}"
+ [ "${ipmin#!}" != "$ipmax" ] || ipmax=""
+
+ local exthost
+ config_get exthost "$cfg" src_dip "$extip"
+
+ local inthost
+ config_get inthost "$cfg" dest_ip
+ [ -n "$inthost" ] || return
+
+ [ "$proto" = all ] && proto="tcp udp"
+ [ "$proto" = tcpudp ] && proto="tcp udp"
+
+ [ "${inthost#!}" = "$inthost" ] || return 0
+ [ "${exthost#!}" = "$exthost" ] || return 0
+
+ [ "${epmin#!}" != "$epmin" ] && \
+ extport="! --dport ${epmin#!}${epmax:+:$epmax}" || \
+ extport="--dport $epmin${epmax:+:$epmax}"
+
+ [ "${ipmin#!}" != "$ipmin" ] && \
+ intport="! --dport ${ipmin#!}${ipmax:+:$ipmax}" || \
+ intport="--dport $ipmin${ipmax:+:$ipmax}"
+
+ local p
+ for p in ${proto:-tcp udp}; do
+ case "$p" in
+ tcp|udp|6|17)
+ iptables -t nat -A nat_reflection_in \
+ -s $intnet -d $exthost \
+ -p $p $extport \
+ -m comment --comment "$INTERFACE" \
+ -j DNAT --to $inthost:${ipmin#!}${ipmax:+-$ipmax}
+
+ iptables -t nat -A nat_reflection_out \
+ -s $intnet -d $inthost \
+ -p $p $intport \
+ -m comment --comment "$INTERFACE" \
+ -j SNAT --to-source ${intnet%%/*}
+
+ iptables -t filter -A nat_reflection_fwd \
+ -s $intnet -d $inthost \
+ -p $p $intport \
+ -m comment --comment "$INTERFACE" \
+ -j ACCEPT
+ ;;
+ esac
+ done
+ done
+ }
+
+ config_load firewall
+
+ local is_masq_zone="$(find_networks "$ZONE" 1)"
+ [ -n "$is_masq_zone" ] || exit 0
+
+ local extip
+ network_get_ipaddr extip "$INTERFACE" || exit 0
+
+ config_foreach setup_fwd redirect
+fi
diff --git a/package/network/config/firewall/files/bin/.svn/entries b/package/network/config/firewall/files/bin/.svn/entries
new file mode 100644
index 0000000..b14d6a7
--- /dev/null
+++ b/package/network/config/firewall/files/bin/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/config/firewall/files/bin
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-06-05T16:04:23.055438Z
+32062
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+fw
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+8f07dbd215ae0a8554a76305c508d304
+2012-06-05T16:04:23.055438Z
+32062
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+686
+
diff --git a/package/network/config/firewall/files/bin/.svn/text-base/fw.svn-base b/package/network/config/firewall/files/bin/.svn/text-base/fw.svn-base
new file mode 100644
index 0000000..5d20cc8
--- /dev/null
+++ b/package/network/config/firewall/files/bin/.svn/text-base/fw.svn-base
@@ -0,0 +1,49 @@
+#!/bin/sh
+FW_LIBDIR=/lib/firewall
+
+. /lib/functions.sh
+. ${FW_LIBDIR}/fw.sh
+
+case "$(type fw)" in
+ *function) ;;
+ *) exit 255;;
+esac
+
+usage() {
+ echo $0 "<command>" "<family>" "<table>" "<chain>" "<target>" "{" "<rules>" "}"
+ exit 0
+}
+
+cmd=$1
+shift
+case "$cmd" in
+ --help|help) usage ;;
+ start|stop|reload|restart)
+ . ${FW_LIBDIR}/core.sh
+ fw_$cmd
+ exit $?
+ ;;
+esac
+
+fam=$1
+shift
+case "$fam" in
+ ip)
+ fam=i
+ if [ $# -gt 2 ]; then
+ for p in $(seq 2 $(($# - 1))); do
+ if eval "[ \$$p == '}' ]"; then
+ fam=I
+ break
+ fi
+ done
+ fi ;;
+ ip4) fam=4 ;;
+ ip6) fam=6 ;;
+ arp) fam=a ;;
+ eth) fam=e ;;
+ -*) exec $0 $cmd ${fam##*-} "$@" ;;
+esac
+
+fw "$cmd" "$fam" "$@"
+exit $?
diff --git a/package/network/config/firewall/files/bin/fw b/package/network/config/firewall/files/bin/fw
new file mode 100644
index 0000000..5d20cc8
--- /dev/null
+++ b/package/network/config/firewall/files/bin/fw
@@ -0,0 +1,49 @@
+#!/bin/sh
+FW_LIBDIR=/lib/firewall
+
+. /lib/functions.sh
+. ${FW_LIBDIR}/fw.sh
+
+case "$(type fw)" in
+ *function) ;;
+ *) exit 255;;
+esac
+
+usage() {
+ echo $0 "<command>" "<family>" "<table>" "<chain>" "<target>" "{" "<rules>" "}"
+ exit 0
+}
+
+cmd=$1
+shift
+case "$cmd" in
+ --help|help) usage ;;
+ start|stop|reload|restart)
+ . ${FW_LIBDIR}/core.sh
+ fw_$cmd
+ exit $?
+ ;;
+esac
+
+fam=$1
+shift
+case "$fam" in
+ ip)
+ fam=i
+ if [ $# -gt 2 ]; then
+ for p in $(seq 2 $(($# - 1))); do
+ if eval "[ \$$p == '}' ]"; then
+ fam=I
+ break
+ fi
+ done
+ fi ;;
+ ip4) fam=4 ;;
+ ip6) fam=6 ;;
+ arp) fam=a ;;
+ eth) fam=e ;;
+ -*) exec $0 $cmd ${fam##*-} "$@" ;;
+esac
+
+fw "$cmd" "$fam" "$@"
+exit $?
diff --git a/package/network/config/firewall/files/firewall.config b/package/network/config/firewall/files/firewall.config
new file mode 100644
index 0000000..6acfe1e
--- /dev/null
+++ b/package/network/config/firewall/files/firewall.config
@@ -0,0 +1,195 @@
+config defaults
+ option syn_flood 1
+ option input ACCEPT
+ option output ACCEPT
+ option forward REJECT
+# Uncomment this line to disable ipv6 rules
+# option disable_ipv6 1
+
+config zone
+ option name lan
+ option network 'lan'
+ option input ACCEPT
+ option output ACCEPT
+ option forward REJECT
+
+config zone
+ option name wan
+ option network 'wan'
+ option input REJECT
+ option output ACCEPT
+ option forward REJECT
+ option masq 1
+ option mtu_fix 1
+
+config forwarding
+ option src lan
+ option dest wan
+
+# We need to accept udp packets on port 68,
+# see https://dev.openwrt.org/ticket/4108
+config rule
+ option name Allow-DHCP-Renew
+ option src wan
+ option proto udp
+ option dest_port 68
+ option target ACCEPT
+ option family ipv4
+
+# Allow IPv4 ping
+config rule
+ option name Allow-Ping
+ option src wan
+ option proto icmp
+ option icmp_type echo-request
+ option family ipv4
+ option target ACCEPT
+
+# Allow DHCPv6 replies
+# see https://dev.openwrt.org/ticket/10381
+config rule
+ option name Allow-DHCPv6
+ option src wan
+ option proto udp
+ option src_ip fe80::/10
+ option src_port 547
+ option dest_ip fe80::/10
+ option dest_port 546
+ option family ipv6
+ option target ACCEPT
+
+# Allow essential incoming IPv6 ICMP traffic
+config rule
+ option name Allow-ICMPv6-Input
+ option src wan
+ option proto icmp
+ list icmp_type echo-request
+ list icmp_type echo-reply
+ list icmp_type destination-unreachable
+ list icmp_type packet-too-big
+ list icmp_type time-exceeded
+ list icmp_type bad-header
+ list icmp_type unknown-header-type
+ list icmp_type router-solicitation
+ list icmp_type neighbour-solicitation
+ list icmp_type router-advertisement
+ list icmp_type neighbour-advertisement
+ option limit 1000/sec
+ option family ipv6
+ option target ACCEPT
+
+# Allow essential forwarded IPv6 ICMP traffic
+config rule
+ option name Allow-ICMPv6-Forward
+ option src wan
+ option dest *
+ option proto icmp
+ list icmp_type echo-request
+ list icmp_type echo-reply
+ list icmp_type destination-unreachable
+ list icmp_type packet-too-big
+ list icmp_type time-exceeded
+ list icmp_type bad-header
+ list icmp_type unknown-header-type
+ option limit 1000/sec
+ option family ipv6
+ option target ACCEPT
+
+# Block ULA-traffic from leaking out
+config rule
+ option name Enforce-ULA-Border-Src
+ option src *
+ option dest wan
+ option proto all
+ option src_ip fc00::/7
+ option family ipv6
+ option target REJECT
+
+config rule
+ option name Enforce-ULA-Border-Dest
+ option src *
+ option dest wan
+ option proto all
+ option dest_ip fc00::/7
+ option family ipv6
+ option target REJECT
+
+# include a file with users custom iptables rules
+config include
+ option path /etc/firewall.user
+
+
+### EXAMPLE CONFIG SECTIONS
+# do not allow a specific ip to access wan
+#config rule
+# option src lan
+# option src_ip 192.168.45.2
+# option dest wan
+# option proto tcp
+# option target REJECT
+
+# block a specific mac on wan
+#config rule
+# option dest wan
+# option src_mac 00:11:22:33:44:66
+# option target REJECT
+
+# block incoming ICMP traffic on a zone
+#config rule
+# option src lan
+# option proto ICMP
+# option target DROP
+
+# port redirect port coming in on wan to lan
+#config redirect
+# option src wan
+# option src_dport 80
+# option dest lan
+# option dest_ip 192.168.16.235
+# option dest_port 80
+# option proto tcp
+
+# port redirect of remapped ssh port (22001) on wan
+#config redirect
+# option src wan
+# option src_dport 22001
+# option dest lan
+# option dest_port 22
+# option proto tcp
+
+# allow IPsec/ESP and ISAKMP passthrough
+#config rule
+# option src wan
+# option dest lan
+# option protocol esp
+# option target ACCEPT
+
+#config rule
+# option src wan
+# option dest lan
+# option src_port 500
+# option dest_port 500
+# option proto udp
+# option target ACCEPT
+
+### FULL CONFIG SECTIONS
+#config rule
+# option src lan
+# option src_ip 192.168.45.2
+# option src_mac 00:11:22:33:44:55
+# option src_port 80
+# option dest wan
+# option dest_ip 194.25.2.129
+# option dest_port 120
+# option proto tcp
+# option target REJECT
+
+#config redirect
+# option src lan
+# option src_ip 192.168.45.2
+# option src_mac 00:11:22:33:44:55
+# option src_port 1024
+# option src_dport 80
+# option dest_ip 194.25.2.129
+# option dest_port 120
+# option proto tcp
diff --git a/package/network/config/firewall/files/firewall.hotplug b/package/network/config/firewall/files/firewall.hotplug
new file mode 100644
index 0000000..52e7798
--- /dev/null
+++ b/package/network/config/firewall/files/firewall.hotplug
@@ -0,0 +1,22 @@
+#!/bin/sh
+# This script is executed as part of the hotplug event with
+# HOTPLUG_TYPE=iface, triggered by various scripts when an interface
+# is configured (ACTION=ifup) or deconfigured (ACTION=ifdown). The
+# interface is available as INTERFACE, the real device as DEVICE.
+
+[ "$DEVICE" == "lo" ] && exit 0
+
+. /lib/functions.sh
+. /lib/firewall/core.sh
+
+fw_init
+fw_is_loaded || exit 0
+
+case "$ACTION" in
+ ifup)
+ fw_configure_interface "$INTERFACE" add "$DEVICE" &
+ ;;
+ ifdown)
+ fw_configure_interface "$INTERFACE" del "$DEVICE"
+ ;;
+esac
diff --git a/package/network/config/firewall/files/firewall.init b/package/network/config/firewall/files/firewall.init
new file mode 100755
index 0000000..a2fd0a0
--- /dev/null
+++ b/package/network/config/firewall/files/firewall.init
@@ -0,0 +1,27 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2008-2010 OpenWrt.org
+
+START=45
+
+FW_LIBDIR=/lib/firewall
+
+fw() {
+ . $FW_LIBDIR/core.sh
+ fw_$1
+}
+
+start() {
+ fw start
+}
+
+stop() {
+ fw stop
+}
+
+restart() {
+ fw restart
+}
+
+reload() {
+ fw reload
+}
diff --git a/package/network/config/firewall/files/firewall.upgrade b/package/network/config/firewall/files/firewall.upgrade
new file mode 100644
index 0000000..64f63eb
--- /dev/null
+++ b/package/network/config/firewall/files/firewall.upgrade
@@ -0,0 +1 @@
+/etc/firewall.user
diff --git a/package/network/config/firewall/files/firewall.user b/package/network/config/firewall/files/firewall.user
new file mode 100644
index 0000000..1ccbd01
--- /dev/null
+++ b/package/network/config/firewall/files/firewall.user
@@ -0,0 +1,4 @@
+# This file is interpreted as shell script.
+# Put your custom iptables rules here, they will
+# be executed with each firewall (re-)start.
+
diff --git a/package/network/config/firewall/files/lib/.svn/entries b/package/network/config/firewall/files/lib/.svn/entries
new file mode 100644
index 0000000..1b64086
--- /dev/null
+++ b/package/network/config/firewall/files/lib/.svn/entries
@@ -0,0 +1,334 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/config/firewall/files/lib
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-02-22T13:45:20.660376Z
+35745
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+core.sh
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+57cde5df70cac74fcf1c491189ab28f2
+2012-03-18T23:34:06.984635Z
+31014
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2765
+
+core_interface.sh
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+4039e9bc29cadde4210e901e197e9509
+2013-02-04T14:38:33.835622Z
+35484
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+6351
+
+core_redirect.sh
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+7e4a93fc56d528edacc9dcebbf18b5dd
+2013-02-04T14:38:33.835622Z
+35484
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4006
+
+core_forwarding.sh
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+f835e6555c82efbdf000ce091b824fad
+2013-02-04T14:38:33.835622Z
+35484
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1087
+
+core_init.sh
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+d9e95ae46c439896e622c8d019ad71f7
+2013-02-22T13:45:20.660376Z
+35745
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+8941
+
+fw.sh
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+aada254fdb297fc3bdd44a97272a9f8b
+2013-02-04T14:38:33.835622Z
+35484
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+6991
+
+core_rule.sh
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+eabaaff4f9126ce46d9a67eb278a9bef
+2013-02-04T14:38:33.835622Z
+35484
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2887
+
+config.sh
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+472688de7ea0aabacfc30480a4b4eef9
+2011-12-20T01:10:15.660680Z
+29577
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2296
+
+uci_firewall.sh
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+068ecea3916f58dccb235d0d26d7fc43
+2010-05-01T18:22:01.443052Z
+21286
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+172
+
diff --git a/package/network/config/firewall/files/lib/.svn/text-base/config.sh.svn-base b/package/network/config/firewall/files/lib/.svn/text-base/config.sh.svn-base
new file mode 100644
index 0000000..8b2399f
--- /dev/null
+++ b/package/network/config/firewall/files/lib/.svn/text-base/config.sh.svn-base
@@ -0,0 +1,101 @@
+# Copyright (C) 2009-2010 OpenWrt.org
+# Copyright (C) 2009 Malte S. Stretz <http://msquadrat.de>
+#
+# This is a temporary file, I hope to have some of this stuff merged into
+# /lib/functions.sh (without the fw_ prefix of course) one day.
+
+fw_config_append() { # <package>
+ CONFIG_APPEND=1 config_load "$@"
+ unset CONFIG_APPEND
+}
+
+fw_config_once() { # <function> <type>
+ local func=$1
+ local type=$2
+ shift 2
+
+ local config=cfg00nil
+ fw_config__once() {
+ config=$1
+ }
+ config_foreach fw_config__once "$type"
+
+ $func $config "$@"
+}
+
+fw_config_get_section() { # <config> <prefix> <type> <name> <default> ...
+ local config=$1
+ local prefix=$2
+ shift 2
+
+ [ -n "$config" ] || return 1
+ [ -n "$prefix" ] && {
+ prefix="${prefix}_"
+ export ${NO_EXPORT:+-n} -- "${prefix}NAME"="${config}"
+ config_get "${prefix}TYPE" "$config" TYPE
+ }
+
+ local enabled
+ config_get_bool enabled "$config" enabled 1
+ [ $enabled -eq 1 ] || return 1
+
+ [ "$1" == '{' ] && shift
+ while [ $# -ge 3 ]; do
+ local type=$1
+ local name=$2
+ local dflt=$3
+ shift 3
+ # TODO: Move handling of defaults to /lib/functions.sh
+ # and get replace the case block with the following
+ # two lines:
+ # type=${type#string}
+ # config_get${type:+_${type}} "${prefix}${name}" "$config" "$name" "$dflt" || return
+ case "$type" in
+ string)
+ local tmp
+ config_get tmp "$config" "$name" || return
+ [ -z "$tmp" ] && tmp=$dflt
+ export ${NO_EXPORT:+-n} -- "${prefix}${name}=${tmp}"
+ continue
+ ;;
+ boolean)
+ type=bool
+ ;;
+ esac;
+
+ local cmd=${prefix}config_get_${type}
+ type $cmd > /dev/null || {
+ cmd=config_get_${type}
+ }
+ type $cmd > /dev/null || {
+ echo "config type $type (for $name) not supported" >&2
+ return 1
+ }
+ $cmd "${prefix}${name}" "$config" "$name" "$dflt" || return
+ done
+}
+
+config_get_ipaddr() {
+ local varn=$1
+ local conf=$2
+ local name=$3
+ local dflt=$4
+
+ local addr
+ config_get addr "$conf" "$name" || return
+ [ -n "$addr" ] || addr=$dflt
+
+ local mask=${addr#*/}
+ [ "$mask" != "$addr" ] || mask=
+ addr=${addr%/*}
+
+ local vers=
+ case "$addr" in
+ *:*) vers=6; mask="${mask:-128}" ;;
+ *.*) vers=4; mask="${mask:-32}" ;;
+ esac
+
+ export ${NO_EXPORT:+-n} -- "${varn}=${addr}"
+ export ${NO_EXPORT:+-n} -- "${varn}_prefixlen=${mask}"
+ export ${NO_EXPORT:+-n} -- "${varn}_version=${vers}"
+}
diff --git a/package/network/config/firewall/files/lib/.svn/text-base/core.sh.svn-base b/package/network/config/firewall/files/lib/.svn/text-base/core.sh.svn-base
new file mode 100644
index 0000000..93d4d2e
--- /dev/null
+++ b/package/network/config/firewall/files/lib/.svn/text-base/core.sh.svn-base
@@ -0,0 +1,159 @@
+# Copyright (C) 2009-2010 OpenWrt.org
+
+FW_LIBDIR=${FW_LIBDIR:-/lib/firewall}
+
+. $FW_LIBDIR/fw.sh
+include /lib/network
+
+fw_start() {
+ fw_init
+
+ FW_DEFAULTS_APPLIED=
+
+ fw_is_loaded && {
+ echo "firewall already loaded" >&2
+ exit 1
+ }
+
+ uci_set_state firewall core "" firewall_state
+
+ fw_clear DROP
+
+ fw_callback pre core
+
+ echo "Loading defaults"
+ fw_config_once fw_load_defaults defaults
+
+ echo "Loading zones"
+ config_foreach fw_load_zone zone
+
+ echo "Loading forwardings"
+ config_foreach fw_load_forwarding forwarding
+
+ echo "Loading rules"
+ config_foreach fw_load_rule rule
+
+ echo "Loading redirects"
+ config_foreach fw_load_redirect redirect
+
+ echo "Loading includes"
+ config_foreach fw_load_include include
+
+ [ -z "$FW_NOTRACK_DISABLED" ] && {
+ echo "Optimizing conntrack"
+ config_foreach fw_load_notrack_zone zone
+ }
+
+ echo "Loading interfaces"
+ config_foreach fw_configure_interface interface add
+
+ fw_callback post core
+
+ uci_set_state firewall core zones "$FW_ZONES"
+ uci_set_state firewall core loaded 1
+}
+
+fw_stop() {
+ fw_init
+
+ fw_callback pre stop
+
+ local z n i
+ config_get z core zones
+ for z in $z; do
+ config_get n core "${z}_networks"
+ for n in $n; do
+ config_get i core "${n}_ifname"
+ [ -n "$i" ] && env -i ACTION=remove ZONE="$z" \
+ INTERFACE="$n" DEVICE="$i" /sbin/hotplug-call firewall
+ done
+
+ config_get i core "${z}_tcpmss"
+ [ "$i" == 1 ] && {
+ fw del i m FORWARD zone_${z}_MSSFIX
+ fw del i m zone_${z}_MSSFIX
+ }
+ done
+
+ fw_clear ACCEPT
+
+ fw_callback post stop
+
+ uci_revert_state firewall
+ config_clear
+
+ local h
+ for h in $FW_HOOKS; do unset $h; done
+
+ unset FW_HOOKS
+ unset FW_INITIALIZED
+}
+
+fw_restart() {
+ fw_stop
+ fw_start
+}
+
+fw_reload() {
+ fw_restart
+}
+
+fw_is_loaded() {
+ local bool=$(uci_get_state firewall.core.loaded)
+ return $((! ${bool:-0}))
+}
+
+
+fw_die() {
+ echo "Error:" "$@" >&2
+ fw_log error "$@"
+ fw_stop
+ exit 1
+}
+
+fw_log() {
+ local level="$1"
+ [ -n "$2" ] && shift || level=notice
+ [ "$level" != error ] || echo "Error: $@" >&2
+ logger -t firewall -p user.$level "$@"
+}
+
+
+fw_init() {
+ [ -z "$FW_INITIALIZED" ] || return 0
+
+ . $FW_LIBDIR/config.sh
+
+ scan_interfaces
+ fw_config_append firewall
+
+ local hooks="core stop defaults zone notrack synflood"
+ local file lib hk pp
+ for file in $FW_LIBDIR/core_*.sh; do
+ . $file
+ hk=$(basename $file .sh)
+ hk=${hk#core_}
+ append hooks $hk
+ done
+ for file in $FW_LIBDIR/*.sh; do
+ lib=$(basename $file .sh)
+ lib=${lib##[0-9][0-9]_}
+ case $lib in
+ core*|fw|config|uci_firewall) continue ;;
+ esac
+ . $file
+ for hk in $hooks; do
+ for pp in pre post; do
+ type ${lib}_${pp}_${hk}_cb >/dev/null && {
+ append FW_CB_${pp}_${hk} ${lib}
+ append FW_HOOKS FW_CB_${pp}_${hk}
+ }
+ done
+ done
+ done
+
+ fw_callback post init
+
+ FW_INITIALIZED=1
+ return 0
+}
diff --git a/package/network/config/firewall/files/lib/.svn/text-base/core_forwarding.sh.svn-base b/package/network/config/firewall/files/lib/.svn/text-base/core_forwarding.sh.svn-base
new file mode 100644
index 0000000..2ea03f0
--- /dev/null
+++ b/package/network/config/firewall/files/lib/.svn/text-base/core_forwarding.sh.svn-base
@@ -0,0 +1,44 @@
+# Copyright (C) 2009-2010 OpenWrt.org
+
+fw_config_get_forwarding() {
+ [ "${forwarding_NAME}" != "$1" ] || return
+ fw_config_get_section "$1" forwarding { \
+ string _name "$1" \
+ string name "" \
+ string src "" \
+ string dest "" \
+ string family "" \
+ } || return
+ [ -n "$forwarding_name" ] || forwarding_name=$forwarding__name
+}
+
+fw_load_forwarding() {
+ fw_config_get_forwarding "$1"
+
+ fw_callback pre forwarding
+
+ local chain=delegate_forward
+ [ -n "$forwarding_src" ] && {
+ chain=zone_${forwarding_src}_forward
+ }
+
+ local target=ACCEPT
+ [ -n "$forwarding_dest" ] && {
+ target=zone_${forwarding_dest}_dest_ACCEPT
+ }
+
+ local mode
+ fw_get_family_mode mode ${forwarding_family:-x} ${forwarding_dest:-${forwarding_src:--}} i
+
+ fw add $mode f $chain $target ^
+
+ # propagate masq zone flag
+ [ -n "$forwarding_src" ] && list_contains FW_CONNTRACK_ZONES $forwarding_src && {
+ append FW_CONNTRACK_ZONES $forwarding_dest
+ }
+ [ -n "$forwarding_dest" ] && list_contains FW_CONNTRACK_ZONES $forwarding_dest && {
+ append FW_CONNTRACK_ZONES $forwarding_src
+ }
+
+ fw_callback post forwarding
+}
diff --git a/package/network/config/firewall/files/lib/.svn/text-base/core_init.sh.svn-base b/package/network/config/firewall/files/lib/.svn/text-base/core_init.sh.svn-base
new file mode 100644
index 0000000..404a836
--- /dev/null
+++ b/package/network/config/firewall/files/lib/.svn/text-base/core_init.sh.svn-base
@@ -0,0 +1,361 @@
+# Copyright (C) 2009-2011 OpenWrt.org
+# Copyright (C) 2008 John Crispin <blogic@openwrt.org>
+
+FW_INITIALIZED=
+
+FW_ZONES=
+FW_ZONES4=
+FW_ZONES6=
+FW_CONNTRACK_ZONES=
+FW_NOTRACK_DISABLED=
+
+FW_DEFAULTS_APPLIED=
+FW_ADD_CUSTOM_CHAINS=
+FW_ACCEPT_REDIRECTS=
+FW_ACCEPT_SRC_ROUTE=
+
+FW_DEFAULT_INPUT_POLICY=REJECT
+FW_DEFAULT_OUTPUT_POLICY=REJECT
+FW_DEFAULT_FORWARD_POLICY=REJECT
+
+FW_DISABLE_IPV4=0
+FW_DISABLE_IPV6=0
+
+
+fw_load_defaults() {
+ fw_config_get_section "$1" defaults { \
+ string input $FW_DEFAULT_INPUT_POLICY \
+ string output $FW_DEFAULT_OUTPUT_POLICY \
+ string forward $FW_DEFAULT_FORWARD_POLICY \
+ boolean drop_invalid 0 \
+ boolean syn_flood 0 \
+ boolean synflood_protect 0 \
+ string synflood_rate 25 \
+ string synflood_burst 50 \
+ boolean tcp_syncookies 1 \
+ boolean tcp_ecn 0 \
+ boolean tcp_westwood 0 \
+ boolean tcp_window_scaling 1 \
+ boolean accept_redirects 0 \
+ boolean accept_source_route 0 \
+ boolean custom_chains 1 \
+ boolean disable_ipv6 0 \
+ } || return
+ [ -n "$FW_DEFAULTS_APPLIED" ] && {
+ fw_log error "duplicate defaults section detected, skipping"
+ return 1
+ }
+ FW_DEFAULTS_APPLIED=1
+
+ FW_DEFAULT_INPUT_POLICY=$defaults_input
+ FW_DEFAULT_OUTPUT_POLICY=$defaults_output
+ FW_DEFAULT_FORWARD_POLICY=$defaults_forward
+
+ FW_ADD_CUSTOM_CHAINS=$defaults_custom_chains
+
+ FW_ACCEPT_REDIRECTS=$defaults_accept_redirects
+ FW_ACCEPT_SRC_ROUTE=$defaults_accept_source_route
+
+ FW_DISABLE_IPV6=$defaults_disable_ipv6
+
+ fw_callback pre defaults
+
+ # Seems like there are only one sysctl for both IP versions.
+ for s in syncookies ecn westwood window_scaling; do
+ eval "sysctl -e -w net.ipv4.tcp_${s}=\$defaults_tcp_${s}" >/dev/null
+ done
+ fw_sysctl_interface all
+
+ fw add i f INPUT ACCEPT { -m conntrack --ctstate RELATED,ESTABLISHED }
+ fw add i f OUTPUT ACCEPT { -m conntrack --ctstate RELATED,ESTABLISHED }
+ fw add i f FORWARD ACCEPT { -m conntrack --ctstate RELATED,ESTABLISHED }
+
+ [ $defaults_drop_invalid == 1 ] && {
+ fw add i f INPUT DROP { -m conntrack --ctstate INVALID }
+ fw add i f OUTPUT DROP { -m conntrack --ctstate INVALID }
+ fw add i f FORWARD DROP { -m conntrack --ctstate INVALID }
+ FW_NOTRACK_DISABLED=1
+ }
+
+ fw add i f INPUT ACCEPT { -i lo }
+ fw add i f OUTPUT ACCEPT { -o lo }
+
+ # Compatibility to old 'syn_flood' parameter
+ [ $defaults_syn_flood == 1 ] && \
+ defaults_synflood_protect=1
+
+ [ "${defaults_synflood_rate%/*}" == "$defaults_synflood_rate" ] && \
+ defaults_synflood_rate="$defaults_synflood_rate/second"
+
+ [ $defaults_synflood_protect == 1 ] && {
+ echo "Loading synflood protection"
+ fw_callback pre synflood
+ fw add i f syn_flood
+ fw add i f syn_flood RETURN { \
+ -p tcp --syn \
+ -m limit --limit "${defaults_synflood_rate}" --limit-burst "${defaults_synflood_burst}" \
+ }
+ fw add i f syn_flood DROP
+ fw add i f INPUT syn_flood { -p tcp --syn }
+ fw_callback post synflood
+ }
+
+ [ $defaults_custom_chains == 1 ] && {
+ echo "Adding custom chains"
+ fw add i f input_rule
+ fw add i f output_rule
+ fw add i f forwarding_rule
+ fw add i n prerouting_rule
+ fw add i n postrouting_rule
+
+ fw add i f INPUT input_rule
+ fw add i f OUTPUT output_rule
+ fw add i f FORWARD forwarding_rule
+ fw add i n PREROUTING prerouting_rule
+ fw add i n POSTROUTING postrouting_rule
+ }
+
+ fw add i f delegate_input
+ fw add i f delegate_output
+ fw add i f delegate_forward
+
+ fw add i f INPUT delegate_input
+ fw add i f OUTPUT delegate_output
+ fw add i f FORWARD delegate_forward
+
+ fw add i f reject
+ fw add i f reject REJECT { --reject-with tcp-reset -p tcp }
+ fw add i f reject REJECT { --reject-with port-unreach }
+
+ fw_set_filter_policy
+
+ fw_callback post defaults
+}
+
+
+fw_config_get_zone() {
+ [ "${zone_NAME}" != "$1" ] || return
+ fw_config_get_section "$1" zone { \
+ string name "$1" \
+ string network "" \
+ string device "" \
+ string subnet "" \
+ string input "$FW_DEFAULT_INPUT_POLICY" \
+ string output "$FW_DEFAULT_OUTPUT_POLICY" \
+ string forward "$FW_DEFAULT_FORWARD_POLICY" \
+ boolean masq 0 \
+ string masq_src "" \
+ string masq_dest "" \
+ string extra "" \
+ string extra_src "" \
+ string extra_dest "" \
+ boolean conntrack 0 \
+ boolean mtu_fix 0 \
+ boolean custom_chains 0 \
+ boolean log 0 \
+ string log_limit 10 \
+ string family "" \
+ } || return
+ [ -n "$zone_name" ] || zone_name=$zone_NAME
+ [ -n "$zone_extra_src" ] || zone_extra_src="$zone_extra"
+ [ -n "$zone_extra_dest" ] || zone_extra_dest="$zone_extra"
+ [ -n "$zone_network$zone_subnet$zone_device$zone_extra_src$zone_extra_dest" ] || zone_network=$zone_name
+}
+
+fw_load_zone() {
+ fw_config_get_zone "$1"
+
+ list_contains FW_ZONES $zone_name && {
+ fw_log error "zone ${zone_name}: duplicated zone, skipping"
+ return 0
+ }
+ append FW_ZONES $zone_name
+
+ fw_callback pre zone
+
+ [ $zone_conntrack = 1 -o $zone_masq = 1 ] && \
+ append FW_CONNTRACK_ZONES "$zone_name"
+
+ local mode
+ case "$zone_family" in
+ *4)
+ mode=4
+ append FW_ZONES4 $zone_name
+ uci_set_state firewall core ${zone_name}_ipv4 1
+ ;;
+ *6)
+ mode=6
+ append FW_ZONES6 $zone_name
+ uci_set_state firewall core ${zone_name}_ipv6 1
+ ;;
+ *)
+ mode=i
+ append FW_ZONES4 $zone_name
+ append FW_ZONES6 $zone_name
+ uci_set_state firewall core ${zone_name}_ipv4 1
+ uci_set_state firewall core ${zone_name}_ipv6 1
+ ;;
+ esac
+
+ local chain=zone_${zone_name}
+
+ fw add $mode f ${chain}_src_ACCEPT
+ fw add $mode f ${chain}_src_DROP
+ fw add $mode f ${chain}_src_REJECT
+
+ fw add $mode f ${chain}_dest_ACCEPT
+ fw add $mode f ${chain}_dest_DROP
+ fw add $mode f ${chain}_dest_REJECT
+
+ fw add $mode f ${chain}_input
+ fw add $mode f ${chain}_input ${chain}_src_${zone_input} $
+
+ fw add $mode f ${chain}_forward
+ fw add $mode f ${chain}_forward ${chain}_dest_${zone_forward} $
+
+ fw add $mode f ${chain}_output
+ fw add $mode f ${chain}_output ${chain}_dest_${zone_output} $
+
+ # TODO: Rename to ${chain}_MASQUERADE
+ fw add $mode n ${chain}_nat
+ fw add $mode n ${chain}_prerouting
+
+ fw add $mode r ${chain}_notrack
+
+ [ $zone_mtu_fix == 1 ] && {
+ fw add $mode m ${chain}_MSSFIX
+ fw add $mode m FORWARD ${chain}_MSSFIX ^
+ uci_set_state firewall core ${zone_name}_tcpmss 1
+ }
+
+ [ $zone_custom_chains == 1 ] && {
+ [ $FW_ADD_CUSTOM_CHAINS == 1 ] || \
+ fw_die "zone ${zone_name}: custom_chains globally disabled"
+
+ fw add $mode f input_${zone_name}
+ fw add $mode f ${chain}_input input_${zone_name} ^
+
+ fw add $mode f forwarding_${zone_name}
+ fw add $mode f ${chain}_forward forwarding_${zone_name} ^
+
+ fw add $mode n prerouting_${zone_name}
+ fw add $mode n ${chain}_prerouting prerouting_${zone_name} ^
+ }
+
+ [ "$zone_log" == 1 ] && {
+ [ "${zone_log_limit%/*}" == "$zone_log_limit" ] && \
+ zone_log_limit="$zone_log_limit/minute"
+
+ local t
+ for t in REJECT DROP; do
+ local d
+ for d in src dest; do
+ fw add $mode f ${chain}_${d}_${t} LOG ^ \
+ { -m limit --limit $zone_log_limit --log-prefix "$t($d:$zone_name): " }
+ done
+ done
+
+ [ $zone_mtu_fix == 1 ] && \
+ fw add $mode m ${chain}_MSSFIX LOG ^ \
+ { -p tcp --tcp-flags SYN,RST SYN -m limit --limit $zone_log_limit --log-prefix "MSSFIX($zone_name): " }
+ }
+
+ # NB: if MASQUERADING for IPv6 becomes available we'll need a family check here
+ if [ "$zone_masq" == 1 ]; then
+ local msrc mdst
+ for msrc in ${zone_masq_src:-0.0.0.0/0}; do
+ case "$msrc" in
+ *.*) fw_get_negation msrc '-s' "$msrc" ;;
+ *) fw_get_subnet4 msrc '-s' "$msrc" || break ;;
+ esac
+
+ for mdst in ${zone_masq_dest:-0.0.0.0/0}; do
+ case "$mdst" in
+ *.*) fw_get_negation mdst '-d' "$mdst" ;;
+ *) fw_get_subnet4 mdst '-d' "$mdst" || break ;;
+ esac
+
+ fw add $mode n ${chain}_nat MASQUERADE $ { $msrc $mdst }
+ done
+ done
+ fi
+
+ local dev
+ for dev in ${zone_device:-""}; do
+ local net
+ for net in ${zone_subnet:-""}; do
+ [ -n "$dev" ] || [ -n "$net" ] || continue
+ fw_do_interface_rules add "${zone_name}" "$dev" "$net" \
+ "${zone_extra_src}" "${zone_extra_dest}"
+ done
+ done
+
+ fw_callback post zone
+}
+
+fw_load_notrack_zone() {
+ fw_config_get_zone "$1"
+ list_contains FW_CONNTRACK_ZONES "${zone_name}" && return
+
+ fw_callback pre notrack
+
+ fw add i r zone_${zone_name}_notrack NOTRACK $
+
+ fw_callback post notrack
+}
+
+
+fw_load_include() {
+ local name="$1"
+
+ local path
+ config_get path ${name} path
+
+ [ -e $path ] && (
+ config() {
+ fw_log error "You cannot use UCI in firewall includes!" >&2
+ exit 1
+ }
+ . $path
+ )
+}
+
+
+fw_clear() {
+ local policy=$1
+
+ fw_set_filter_policy $policy
+
+ local tab
+ for tab in f n r; do
+ fw del i $tab
+ done
+}
+
+fw_set_filter_policy() {
+ local policy=$1
+
+ local chn tgt
+ for chn in INPUT OUTPUT FORWARD; do
+ eval "tgt=\${policy:-\${FW_DEFAULT_${chn}_POLICY}}"
+ [ $tgt == "REJECT" ] && tgt=reject
+ [ $tgt == "ACCEPT" -o $tgt == "DROP" ] || {
+ fw add i f $chn $tgt $
+ tgt=DROP
+ }
+ fw policy i f $chn $tgt
+ done
+}
+
+
+fw_callback() {
+ local pp=$1
+ local hk=$2
+
+ local libs lib
+ eval "libs=\$FW_CB_${pp}_${hk}"
+ [ -n "$libs" ] || return
+ for lib in $libs; do
+ ${lib}_${pp}_${hk}_cb
+ done
+}
diff --git a/package/network/config/firewall/files/lib/.svn/text-base/core_interface.sh.svn-base b/package/network/config/firewall/files/lib/.svn/text-base/core_interface.sh.svn-base
new file mode 100644
index 0000000..9138cbf
--- /dev/null
+++ b/package/network/config/firewall/files/lib/.svn/text-base/core_interface.sh.svn-base
@@ -0,0 +1,214 @@
+# Copyright (C) 2009-2013 OpenWrt.org
+
+fw__uci_state_add() {
+ local var="$1"
+ local item="$2"
+
+ local val="$(uci_get_state firewall core $var)"
+ local e1; for e1 in $item; do
+ local e2; for e2 in $val; do
+ [ "$e1" = "$e2" ] && e1=""
+ done
+ val="${val:+$val${e1:+ }}$e1"
+ done
+
+ uci_toggle_state firewall core $var "$val"
+}
+
+fw__uci_state_del() {
+ local var="$1"
+ local item="$2"
+
+ local rest=""
+ local val="$(uci_get_state firewall core $var)"
+ local e1; for e1 in $val; do
+ local e2; for e2 in $item; do
+ [ "$e1" = "$e2" ] && e1=""
+ done
+ rest="${rest:+$rest${e1:+ }}$e1"
+ done
+
+ uci_toggle_state firewall core $var "$rest"
+}
+
+fw_do_interface_rules() {
+ local action=$1
+ local zone=$2
+ local chain=zone_${zone}
+ local ifname=$3
+ local subnet=$4
+ local extra_src="$5"
+ local extra_dest="$6"
+
+ local idev odev inet onet mode
+ fw_get_family_mode mode x $zone i
+
+ fw_get_negation idev '-i' "$ifname"
+ fw_get_negation odev '-o' "$ifname"
+
+ case "$mode/$subnet" in
+ # Zone supports v6 only or dual, need v6
+ G6/*:*|i/*:*)
+ fw_get_negation inet '-s' "$subnet"
+ fw_get_negation onet '-d' "$subnet"
+ mode=6
+ ;;
+
+ # Zone supports v4 only or dual, need v4
+ G4/*.*.*.*|i/*.*.*.*)
+ fw_get_negation inet '-s' "$subnet"
+ fw_get_negation onet '-d' "$subnet"
+ mode=4
+ ;;
+
+ # Need v6 while zone is v4
+ */*:*) fw_log info "zone $zone does not support IPv6 address family, skipping"; return ;;
+
+ # Need v4 while zone is v6
+ */*.*) fw_log info "zone $zone does not support IPv4 address family, skipping"; return ;;
+
+ # Strip prefix
+ *) mode="${mode#G}" ;;
+ esac
+
+ lock /var/run/firewall-interface.lock
+
+ fw $action $mode f ${chain}_dest_ACCEPT ACCEPT $ { $odev $onet $extra_dest }
+ fw $action $mode f ${chain}_src_ACCEPT ACCEPT $ { $idev $inet $extra_src }
+ fw $action $mode f ${chain}_dest_DROP DROP $ { $odev $onet $extra_dest }
+ fw $action $mode f ${chain}_src_DROP DROP $ { $idev $inet $extra_src }
+ fw $action $mode f ${chain}_dest_REJECT reject $ { $odev $onet $extra_dest }
+ fw $action $mode f ${chain}_src_REJECT reject $ { $idev $inet $extra_src }
+
+ [ "$(uci_get_state firewall core "${zone}_tcpmss")" == 1 ] && \
+ fw $action $mode m ${chain}_MSSFIX TCPMSS $ \
+ { $odev -p tcp --tcp-flags SYN,RST SYN --clamp-mss-to-pmtu $onet $extra_dest }
+
+ fw $action $mode f delegate_input ${chain}_input $ { $idev $inet $extra_src }
+ fw $action $mode f delegate_forward ${chain}_forward $ { $idev $inet $extra_src }
+ fw $action $mode f delegate_output ${chain}_output $ { $odev $onet $extra_dest }
+
+ fw $action $mode n PREROUTING ${chain}_prerouting $ { $idev $inet $extra_src }
+ fw $action $mode r PREROUTING ${chain}_notrack $ { $idev $inet $extra_src }
+ fw $action $mode n POSTROUTING ${chain}_nat $ { $odev $onet $extra_dest }
+
+ # Flush conntrack table
+ echo f >/proc/net/nf_conntrack 2>/dev/null
+
+ lock -u /var/run/firewall-interface.lock
+}
+
+fw_configure_interface() {
+ local iface=$1
+ local action=$2
+ local ifname=$3
+ local aliasnet=$4
+
+ [ "$action" == "add" ] && {
+ local status=$(uci_get_state network "$iface" up 0)
+ [ "$status" == 1 ] || [ -n "$aliasnet" ] || return 0
+ }
+
+ [ -n "$ifname" ] || {
+ ifname=$(uci_get_state network "$iface" ifname)
+ ifname="${ifname%%:*}"
+ [ -z "$ifname" ] && return 0
+ }
+
+ [ "$ifname" == "lo" ] && return 0
+
+ fw_callback pre interface
+
+ local old_zones old_ifname old_subnets
+ config_get old_zones core "${iface}_zone"
+ [ -n "$old_zones" ] && {
+ config_get old_ifname core "${iface}_ifname"
+ config_get old_subnets core "${iface}_subnets"
+
+ local z
+ for z in $old_zones; do
+ local n
+ for n in ${old_subnets:-""}; do
+ fw_log info "removing $iface ($old_ifname${n:+ alias $n}) from zone $z"
+ fw_do_interface_rules del $z $old_ifname $n
+ done
+
+ [ -n "$old_subnets" ] || {
+ fw__uci_state_del "${z}_networks" "$iface"
+ env -i ACTION=remove ZONE="$z" INTERFACE="$iface" DEVICE="$ifname" /sbin/hotplug-call firewall
+ }
+ done
+
+ local old_aliases
+ config_get old_aliases core "${iface}_aliases"
+
+ local a
+ for a in $old_aliases; do
+ fw_configure_interface "$a" del "$old_ifname"
+ done
+
+ uci_revert_state firewall core "${iface}_zone"
+ uci_revert_state firewall core "${iface}_ifname"
+ uci_revert_state firewall core "${iface}_subnets"
+ uci_revert_state firewall core "${iface}_aliases"
+ }
+
+ [ "$action" == del ] && return
+
+ [ -z "$aliasnet" ] && {
+ local aliases
+ config_get aliases "$iface" aliases
+
+ local a
+ for a in $aliases; do
+ local ipaddr netmask ip6addr
+ config_get ipaddr "$a" ipaddr
+ config_get netmask "$a" netmask
+ config_get ip6addr "$a" ip6addr
+
+ [ -n "$ipaddr" ] && fw_configure_interface "$a" add "" "$ipaddr${netmask:+/$netmask}"
+ [ -n "$ip6addr" ] && fw_configure_interface "$a" add "" "$ip6addr"
+ done
+
+ fw_sysctl_interface $ifname
+ fw_callback post interface
+
+ uci_toggle_state firewall core "${iface}_aliases" "$aliases"
+ } || {
+ local subnets=
+ config_get subnets core "${iface}_subnets"
+ append subnets "$aliasnet"
+
+ config_set core "${iface}_subnets" "$subnets"
+ uci_toggle_state firewall core "${iface}_subnets" "$subnets"
+ }
+
+ local new_zones=
+ load_zone() {
+ fw_config_get_zone "$1"
+ list_contains zone_network "$iface" || return
+
+ fw_log info "adding $iface ($ifname${aliasnet:+ alias $aliasnet}) to zone $zone_name"
+ fw_do_interface_rules add ${zone_name} "$ifname" "$aliasnet"
+ append new_zones $zone_name
+
+ [ -n "$aliasnet" ] || {
+ fw__uci_state_add "${zone_name}_networks" "${zone_network}"
+ env -i ACTION=add ZONE="$zone_name" INTERFACE="$iface" DEVICE="$ifname" /sbin/hotplug-call firewall
+ }
+ }
+ config_foreach load_zone zone
+
+ uci_toggle_state firewall core "${iface}_zone" "$new_zones"
+ uci_toggle_state firewall core "${iface}_ifname" "$ifname"
+}
+
+fw_sysctl_interface() {
+ local ifname=$1
+ {
+ sysctl -w net.ipv4.conf.${ifname}.accept_redirects=$FW_ACCEPT_REDIRECTS
+ sysctl -w net.ipv6.conf.${ifname}.accept_redirects=$FW_ACCEPT_REDIRECTS
+ sysctl -w net.ipv4.conf.${ifname}.accept_source_route=$FW_ACCEPT_SRC_ROUTE
+ sysctl -w net.ipv6.conf.${ifname}.accept_source_route=$FW_ACCEPT_SRC_ROUTE
+ } >/dev/null 2>/dev/null
+}
diff --git a/package/network/config/firewall/files/lib/.svn/text-base/core_redirect.sh.svn-base b/package/network/config/firewall/files/lib/.svn/text-base/core_redirect.sh.svn-base
new file mode 100644
index 0000000..9493bc6
--- /dev/null
+++ b/package/network/config/firewall/files/lib/.svn/text-base/core_redirect.sh.svn-base
@@ -0,0 +1,130 @@
+# Copyright (C) 2009-2010 OpenWrt.org
+
+fw_config_get_redirect() {
+ [ "${redirect_NAME}" != "$1" ] || return
+ fw_config_get_section "$1" redirect { \
+ string _name "$1" \
+ string name "" \
+ string src "" \
+ ipaddr src_ip "" \
+ ipaddr src_dip "" \
+ string src_mac "" \
+ string src_port "" \
+ string src_dport "" \
+ string dest "" \
+ ipaddr dest_ip "" \
+ string dest_port "" \
+ string proto "tcpudp" \
+ string family "" \
+ string target "DNAT" \
+ string extra "" \
+ } || return
+ [ -n "$redirect_name" ] || redirect_name=$redirect__name
+}
+
+fw_load_redirect() {
+ fw_config_get_redirect "$1"
+
+ fw_callback pre redirect
+
+ local fwdchain natchain natopt nataddr natports srcdaddr srcdports
+ if [ "$redirect_target" == "DNAT" ]; then
+ [ -n "${redirect_src#*}" -a -n "$redirect_dest_ip$redirect_dest_port" ] || {
+ fw_log error "DNAT redirect ${redirect_name}: needs src and dest_ip or dest_port, skipping"
+ return 0
+ }
+
+ fwdopt=""
+ fwdchain=""
+
+ # Check whether only ports are given or whether the given dest ip is local,
+ # in this case match only DNATed traffic and allow it on input, not forward
+ if [ -z "$redirect_dest_ip" ] || /sbin/ifconfig | grep -qE "addr:${redirect_dest_ip//./\\.}\b"; then
+ fwdopt="-m conntrack --ctstate DNAT"
+ fwdchain="zone_${redirect_src}_input"
+ else
+ fwdchain="zone_${redirect_src}_forward"
+ fi
+
+ natopt="--to-destination"
+ natchain="zone_${redirect_src}_prerouting"
+ nataddr="$redirect_dest_ip"
+ fw_get_port_range natports "${redirect_dest_port#!}" "-"
+
+ fw_get_negation srcdaddr '-d' "${redirect_src_dip:+$redirect_src_dip/$redirect_src_dip_prefixlen}"
+ fw_get_port_range srcdports "$redirect_src_dport" ":"
+ fw_get_negation srcdports '--dport' "$srcdports"
+
+ list_contains FW_CONNTRACK_ZONES $redirect_src || \
+ append FW_CONNTRACK_ZONES $redirect_src
+
+ elif [ "$redirect_target" == "SNAT" ]; then
+ [ -n "${redirect_dest#*}" -a -n "$redirect_src_dip" ] || {
+ fw_log error "SNAT redirect ${redirect_name}: needs dest and src_dip, skipping"
+ return 0
+ }
+
+ fwdchain="${redirect_src:+zone_${redirect_src}_forward}"
+
+ natopt="--to-source"
+ natchain="zone_${redirect_dest}_nat"
+ nataddr="$redirect_src_dip"
+ fw_get_port_range natports "${redirect_src_dport#!}" "-"
+
+ fw_get_negation srcdaddr '-d' "${redirect_dest_ip:+$redirect_dest_ip/$redirect_dest_ip_prefixlen}"
+ fw_get_port_range srcdports "$redirect_dest_port" ":"
+ fw_get_negation srcdports '--dport' "$srcdports"
+
+ list_contains FW_CONNTRACK_ZONES $redirect_dest || \
+ append FW_CONNTRACK_ZONES $redirect_dest
+
+ else
+ fw_log error "redirect ${redirect_name}: target must be either DNAT or SNAT, skipping"
+ return 0
+ fi
+
+ local mode
+ fw_get_family_mode mode ${redirect_family:-x} ${redirect_src:-$redirect_dest} I
+
+ local srcaddr
+ fw_get_negation srcaddr '-s' "${redirect_src_ip:+$redirect_src_ip/$redirect_src_ip_prefixlen}"
+
+ local srcports
+ fw_get_port_range srcports "$redirect_src_port" ":"
+ fw_get_negation srcports '--sport' "$srcports"
+
+ local destaddr
+ fw_get_negation destaddr '-d' "${redirect_dest_ip:+$redirect_dest_ip/$redirect_dest_ip_prefixlen}"
+
+ local destports
+ fw_get_port_range destports "${redirect_dest_port:-$redirect_src_dport}" ":"
+ fw_get_negation destports '--dport' "$destports"
+
+ [ "$redirect_proto" == "tcpudp" ] && redirect_proto="tcp udp"
+ local pr; for pr in $redirect_proto; do
+ fw_get_negation pr '-p' "$pr"
+ local sm; for sm in ${redirect_src_mac:-""}; do
+ fw_get_negation sm '--mac-source' "$sm"
+ fw add $mode n $natchain $redirect_target + \
+ { $redirect_src_ip $redirect_dest_ip } { \
+ $srcaddr $srcdaddr $pr \
+ $srcports $srcdports \
+ ${sm:+-m mac $sm} \
+ $natopt $nataddr${natports:+:$natports} \
+ $redirect_options \
+ }
+
+ fw add $mode f ${fwdchain:-delegate_forward} ACCEPT + \
+ { $redirect_src_ip $redirect_dest_ip } { \
+ $srcaddr $destaddr \
+ $pr \
+ $srcports $destports \
+ ${sm:+-m mac $sm} \
+ $fwdopt \
+ $redirect_extra \
+ }
+ done
+ done
+
+ fw_callback post redirect
+}
diff --git a/package/network/config/firewall/files/lib/.svn/text-base/core_rule.sh.svn-base b/package/network/config/firewall/files/lib/.svn/text-base/core_rule.sh.svn-base
new file mode 100644
index 0000000..0ce2122
--- /dev/null
+++ b/package/network/config/firewall/files/lib/.svn/text-base/core_rule.sh.svn-base
@@ -0,0 +1,117 @@
+# Copyright (C) 2009-2010 OpenWrt.org
+
+fw_config_get_rule() {
+ [ "${rule_NAME}" != "$1" ] || return
+ fw_config_get_section "$1" rule { \
+ string _name "$1" \
+ string name "" \
+ string src "" \
+ ipaddr src_ip "" \
+ string src_mac "" \
+ string src_port "" \
+ string dest "" \
+ ipaddr dest_ip "" \
+ string dest_port "" \
+ string icmp_type "" \
+ string proto "tcpudp" \
+ string target "" \
+ string family "" \
+ string limit "" \
+ string limit_burst "" \
+ string extra "" \
+ } || return
+ [ -n "$rule_name" ] || rule_name=$rule__name
+}
+
+fw_load_rule() {
+ fw_config_get_rule "$1"
+
+ [ "$rule_target" != "NOTRACK" ] || [ -n "$rule_src" ] || [ "$rule_src" != "*" ] || {
+ fw_log error "NOTRACK rule ${rule_name}: needs src, skipping"
+ return 0
+ }
+
+ fw_callback pre rule
+
+ local table=f
+ local chain=delegate_output
+ local target="${rule_target:-REJECT}"
+ if [ "$target" == "NOTRACK" ]; then
+ table=r
+ chain="zone_${rule_src}_notrack"
+ else
+ if [ -n "$rule_src" ]; then
+ if [ "$rule_src" != "*" ]; then
+ if [ -n "$rule_dest" ]; then
+ chain="zone_${rule_src}_forward"
+ else
+ chain="zone_${rule_src}_input"
+ fi
+ else
+ chain="${rule_dest:+delegate_forward}"
+ chain="${chain:-delegate_input}"
+ fi
+ fi
+
+ if [ -n "$rule_dest" ]; then
+ if [ "$rule_dest" != "*" ]; then
+ target="zone_${rule_dest}_dest_${target}"
+ if [ -z "$rule_src" ]; then
+ chain="zone_${rule_dest}_output"
+ fi
+ elif [ "$target" = REJECT ]; then
+ target=reject
+ fi
+ fi
+ fi
+
+ local mode
+ fw_get_family_mode mode ${rule_family:-x} "$rule_src" I
+
+ local src_spec dest_spec
+ fw_get_negation src_spec '-s' "${rule_src_ip:+$rule_src_ip/$rule_src_ip_prefixlen}"
+ fw_get_negation dest_spec '-d' "${rule_dest_ip:+$rule_dest_ip/$rule_dest_ip_prefixlen}"
+
+ [ "$rule_proto" == "tcpudp" ] && rule_proto="tcp udp"
+ local pr; for pr in $rule_proto; do
+ local sports dports itypes
+ case "$pr" in
+ icmp|icmpv6|1|58)
+ sports=""; dports=""
+ itypes="$rule_icmp_type"
+ ;;
+ *)
+ sports="$rule_src_port"
+ dports="$rule_dest_port"
+ itypes=""
+ ;;
+ esac
+
+ fw_get_negation pr '-p' "$pr"
+ local sp; for sp in ${sports:-""}; do
+ fw_get_port_range sp $sp
+ fw_get_negation sp '--sport' "$sp"
+ local dp; for dp in ${dports:-""}; do
+ fw_get_port_range dp $dp
+ fw_get_negation dp '--dport' "$dp"
+ local sm; for sm in ${rule_src_mac:-""}; do
+ fw_get_negation sm '--mac-source' "$sm"
+ local it; for it in ${itypes:-""}; do
+ fw_get_negation it '--icmp-type' "$it"
+ fw add $mode $table $chain $target + \
+ { $rule_src_ip $rule_dest_ip } { \
+ $src_spec $dest_spec \
+ $pr $sp $dp $it \
+ ${sm:+-m mac $sm} \
+ ${rule_limit:+-m limit --limit $rule_limit \
+ ${rule_limit_burst:+--limit-burst $rule_limit_burst}} \
+ $rule_extra \
+ }
+ done
+ done
+ done
+ done
+ done
+
+ fw_callback post rule
+}
diff --git a/package/network/config/firewall/files/lib/.svn/text-base/fw.sh.svn-base b/package/network/config/firewall/files/lib/.svn/text-base/fw.sh.svn-base
new file mode 100644
index 0000000..ca851e8
--- /dev/null
+++ b/package/network/config/firewall/files/lib/.svn/text-base/fw.sh.svn-base
@@ -0,0 +1,324 @@
+# Copyright (C) 2009-2010 OpenWrt.org
+# Copyright (C) 2009 Malte S. Stretz
+
+export FW_4_ERROR=0
+export FW_6_ERROR=0
+export FW_i_ERROR=0
+export FW_e_ERROR=0
+export FW_a_ERROR=0
+
+#TODO: remove this
+[ "${-#*x}" == "$-" ] && {
+ fw() {
+ fw__exec "$@"
+ }
+} || {
+ fw() {
+ local os=$-
+ set +x
+ fw__exec "$@"
+ local rc=$?
+ set -$os
+ return $rc
+ }
+}
+
+fw__exec() { # <action> <family> <table> <chain> <target> <position> { <rules> }
+ local cmd fam tab chn tgt pos
+ local i
+ for i in cmd fam tab chn tgt pos; do
+ if [ "$1" -a "$1" != '{' ]; then
+ eval "$i='$1'"
+ shift
+ else
+ eval "$i=-"
+ fi
+ done
+
+ fw__rc() {
+ export FW_${fam#G}_ERROR=$1
+ return $1
+ }
+
+ fw__dualip() {
+ fw $cmd 4 $tab $chn $tgt $pos "$@"
+ fw $cmd 6 $tab $chn $tgt $pos "$@"
+ fw__rc $((FW_4_ERROR | FW_6_ERROR))
+ }
+
+ fw__autoip() {
+ local ip4 ip6
+ shift
+ while [ "$1" != '}' ]; do
+ case "$1" in
+ *:*) ip6=1 ;;
+ *.*.*.*) ip4=1 ;;
+ esac
+ shift
+ done
+ shift
+ if [ "${ip4:-4}" == "${ip6:-6}" ]; then
+ echo "fw: can't mix ip4 and ip6" >&2
+ return 1
+ fi
+ local ver=${ip4:+4}${ip6:+6}
+ fam=i
+ fw $cmd ${ver:-i} $tab $chn $tgt $pos "$@"
+ fw__rc $?
+ }
+
+ fw__has() {
+ local tab=${1:-$tab}
+ if [ $tab == '-' ]; then
+ type $app > /dev/null 2> /dev/null
+ fw__rc $(($? & 1))
+ return
+ fi
+ [ "$app" != ip6tables ] || [ "$tab" != nat ]
+ fw__rc $?
+ }
+
+ fw__err() {
+ local err
+ eval "err=\$FW_${fam}_ERROR"
+ fw__rc $err
+ }
+
+ local app=
+ local pol=
+ case "$fam" in
+ *4) [ $FW_DISABLE_IPV4 == 0 ] && app=iptables || return ;;
+ *6) [ $FW_DISABLE_IPV6 == 0 ] && app=ip6tables || return ;;
+ i) fw__dualip "$@"; return ;;
+ I) fw__autoip "$@"; return ;;
+ e) app=ebtables ;;
+ a) app=arptables ;;
+ -) fw $cmd i $tab $chn $tgt $pos "$@"; return ;;
+ *) return 254 ;;
+ esac
+ case "$tab" in
+ f) tab=filter ;;
+ m) tab=mangle ;;
+ n) tab=nat ;;
+ r) tab=raw ;;
+ -) tab=filter ;;
+ esac
+ case "$cmd:$chn:$tgt:$pos" in
+ add:*:-:*) cmd=new-chain ;;
+ add:*:*:-) cmd=append ;;
+ add:*:*:$) cmd=append ;;
+ add:*:*:*) cmd=insert ;;
+ del:-:*:*) cmd=delete-chain; fw flush $fam $tab ;;
+ del:*:-:*) cmd=delete-chain; fw flush $fam $tab $chn ;;
+ del:*:*:*) cmd=delete ;;
+ flush:*) ;;
+ policy:*) pol=$tgt; tgt=- ;;
+ has:*) fw__has; return ;;
+ err:*) fw__err; return ;;
+ list:*) cmd="numeric --verbose --$cmd" ;;
+ *) return 254 ;;
+ esac
+ case "$chn" in
+ -) chn= ;;
+ esac
+ case "$tgt" in
+ -) tgt= ;;
+ esac
+
+ local rule_offset
+ case "$pos" in
+ ^) pos=1 ;;
+ $) pos= ;;
+ -) pos= ;;
+ +) eval "rule_offset=\${FW__RULE_OFS_${app}_${tab}_${chn}:-1}" ;;
+ esac
+
+ if ! fw__has - family || ! fw__has $tab ; then
+ export FW_${fam}_ERROR=0
+ return 0
+ fi
+
+ case "$fam" in
+ G*) shift; while [ $# -gt 0 ] && [ "$1" != "{" ]; do shift; done ;;
+ esac
+
+ if [ $# -gt 0 ]; then
+ shift
+ if [ $cmd == delete ]; then
+ pos=
+ fi
+ fi
+
+ local cmdline="$app --table ${tab} --${cmd} ${chn} ${pol} ${rule_offset:-${pos}} ${tgt:+--jump "$tgt"}"
+ while [ $# -gt 1 ]; do
+ # special parameter handling
+ case "$1:$2" in
+ -p:icmp*|-p:1|-p:58|--protocol:icmp*|--protocol:1|--protocol:58)
+ [ "$app" = ip6tables ] && \
+ cmdline="$cmdline -p icmpv6" || \
+ cmdline="$cmdline -p icmp"
+ shift
+ ;;
+ --icmp-type:*|--icmpv6-type:*)
+ local icmp_type
+ if [ "$app" = ip6tables ] && fw_check_icmptype6 icmp_type "$2"; then
+ cmdline="$cmdline $icmp_type"
+ elif [ "$app" = iptables ] && fw_check_icmptype4 icmp_type "$2"; then
+ cmdline="$cmdline $icmp_type"
+ else
+ local fam=IPv4; [ "$app" = ip6tables ] && fam=IPv6
+ fw_log info "ICMP type '$2' is not valid for $fam address family, skipping rule"
+ return 1
+ fi
+ shift
+ ;;
+ *) cmdline="$cmdline $1" ;;
+ esac
+ shift
+ done
+
+ [ -n "$FW_TRACE" ] && echo $cmdline >&2
+
+ $cmdline
+
+ local rv=$?
+ [ $rv -eq 0 ] && [ -n "$rule_offset" ] && \
+ export -- "FW__RULE_OFS_${app}_${tab}_${chn}=$(($rule_offset + 1))"
+ fw__rc $rv
+}
+
+fw_get_port_range() {
+ local _var=$1
+ local _ports=$2
+ local _delim=${3:-:}
+ if [ "$4" ]; then
+ fw_get_port_range $_var "${_ports}-${4}" $_delim
+ return
+ fi
+
+ local _first=${_ports%-*}
+ local _last=${_ports#*-}
+ if [ "${_first#!}" != "${_last#!}" ]; then
+ export -- "$_var=$_first$_delim${_last#!}"
+ else
+ export -- "$_var=$_first"
+ fi
+}
+
+fw_get_family_mode() {
+ local _var="$1"
+ local _hint="$2"
+ local _zone="$3"
+ local _mode="$4"
+
+ local _ipv4 _ipv6
+ [ "$_zone" != "*" ] && {
+ [ -n "$FW_ZONES4$FW_ZONES6" ] && {
+ list_contains FW_ZONES4 "$_zone" && _ipv4=1 || _ipv4=0
+ list_contains FW_ZONES6 "$_zone" && _ipv6=1 || _ipv6=0
+ } || {
+ _ipv4=$(uci_get_state firewall core "${_zone}_ipv4" 0)
+ _ipv6=$(uci_get_state firewall core "${_zone}_ipv6" 0)
+ }
+ } || {
+ _ipv4=1
+ _ipv6=1
+ }
+
+ case "$_hint:$_ipv4:$_ipv6" in
+ *4:1:*|*:1:0) export -n -- "$_var=G4" ;;
+ *6:*:1|*:0:1) export -n -- "$_var=G6" ;;
+ *) export -n -- "$_var=$_mode" ;;
+ esac
+}
+
+fw_get_negation() {
+ local _var="$1"
+ local _flag="$2"
+ local _value="$3"
+
+ [ "${_value#!}" != "$_value" ] && \
+ export -n -- "$_var=! $_flag ${_value#!}" || \
+ export -n -- "$_var=${_value:+$_flag $_value}"
+}
+
+fw_get_subnet4() {
+ local _var="$1"
+ local _flag="$2"
+ local _name="$3"
+
+ local _ipaddr="$(uci_get_state network "${_name#!}" ipaddr)"
+ local _netmask="$(uci_get_state network "${_name#!}" netmask)"
+
+ case "$_ipaddr" in
+ *.*.*.*)
+ [ "${_name#!}" != "$_name" ] && \
+ export -n -- "$_var=! $_flag $_ipaddr/${_netmask:-255.255.255.255}" || \
+ export -n -- "$_var=$_flag $_ipaddr/${_netmask:-255.255.255.255}"
+ return 0
+ ;;
+ esac
+
+ export -n -- "$_var="
+ return 1
+}
+
+fw_check_icmptype4() {
+ local _var="$1"
+ local _type="$2"
+ case "$_type" in
+ ![0-9]*) export -n -- "$_var=! --icmp-type ${_type#!}"; return 0 ;;
+ [0-9]*) export -n -- "$_var=--icmp-type $_type"; return 0 ;;
+ esac
+
+ [ -z "$FW_ICMP4_TYPES" ] && \
+ export FW_ICMP4_TYPES=$(
+ iptables -p icmp -h 2>/dev/null | \
+ sed -n -e '/^Valid ICMP Types:/ {
+ n; :r; s/[()]/ /g; s/[[:space:]]\+/\n/g; p; n; b r
+ }' | sort -u
+ )
+
+ local _check
+ for _check in $FW_ICMP4_TYPES; do
+ if [ "$_check" = "${_type#!}" ]; then
+ [ "${_type#!}" != "$_type" ] && \
+ export -n -- "$_var=! --icmp-type ${_type#!}" || \
+ export -n -- "$_var=--icmp-type $_type"
+ return 0
+ fi
+ done
+
+ export -n -- "$_var="
+ return 1
+}
+
+fw_check_icmptype6() {
+ local _var="$1"
+ local _type="$2"
+ case "$_type" in
+ ![0-9]*) export -n -- "$_var=! --icmpv6-type ${_type#!}"; return 0 ;;
+ [0-9]*) export -n -- "$_var=--icmpv6-type $_type"; return 0 ;;
+ esac
+
+ [ -z "$FW_ICMP6_TYPES" ] && \
+ export FW_ICMP6_TYPES=$(
+ ip6tables -p icmpv6 -h 2>/dev/null | \
+ sed -n -e '/^Valid ICMPv6 Types:/ {
+ n; :r; s/[()]/ /g; s/[[:space:]]\+/\n/g; p; n; b r
+ }' | sort -u
+ )
+
+ local _check
+ for _check in $FW_ICMP6_TYPES; do
+ if [ "$_check" = "${_type#!}" ]; then
+ [ "${_type#!}" != "$_type" ] && \
+ export -n -- "$_var=! --icmpv6-type ${_type#!}" || \
+ export -n -- "$_var=--icmpv6-type $_type"
+ return 0
+ fi
+ done
+
+ export -n -- "$_var="
+ return 1
+}
diff --git a/package/network/config/firewall/files/lib/.svn/text-base/uci_firewall.sh.svn-base b/package/network/config/firewall/files/lib/.svn/text-base/uci_firewall.sh.svn-base
new file mode 100644
index 0000000..7c95a7a
--- /dev/null
+++ b/package/network/config/firewall/files/lib/.svn/text-base/uci_firewall.sh.svn-base
@@ -0,0 +1,5 @@
+# This file is here for backwards compatibility and to override the
+# uci_firewall.sh from an earlier version.
+type fw_is_loaded >/dev/null || {
+ . /lib/firewall/core.sh
+}
diff --git a/package/network/config/firewall/files/lib/config.sh b/package/network/config/firewall/files/lib/config.sh
new file mode 100644
index 0000000..8b2399f
--- /dev/null
+++ b/package/network/config/firewall/files/lib/config.sh
@@ -0,0 +1,101 @@
+# Copyright (C) 2009-2010 OpenWrt.org
+# Copyright (C) 2009 Malte S. Stretz <http://msquadrat.de>
+#
+# This is a temporary file, I hope to have some of this stuff merged into
+# /lib/functions.sh (without the fw_ prefix of course) one day.
+
+fw_config_append() { # <package>
+ CONFIG_APPEND=1 config_load "$@"
+ unset CONFIG_APPEND
+}
+
+fw_config_once() { # <function> <type>
+ local func=$1
+ local type=$2
+ shift 2
+
+ local config=cfg00nil
+ fw_config__once() {
+ config=$1
+ }
+ config_foreach fw_config__once "$type"
+
+ $func $config "$@"
+}
+
+fw_config_get_section() { # <config> <prefix> <type> <name> <default> ...
+ local config=$1
+ local prefix=$2
+ shift 2
+
+ [ -n "$config" ] || return 1
+ [ -n "$prefix" ] && {
+ prefix="${prefix}_"
+ export ${NO_EXPORT:+-n} -- "${prefix}NAME"="${config}"
+ config_get "${prefix}TYPE" "$config" TYPE
+ }
+
+ local enabled
+ config_get_bool enabled "$config" enabled 1
+ [ $enabled -eq 1 ] || return 1
+
+ [ "$1" == '{' ] && shift
+ while [ $# -ge 3 ]; do
+ local type=$1
+ local name=$2
+ local dflt=$3
+ shift 3
+ # TODO: Move handling of defaults to /lib/functions.sh
+ # and get replace the case block with the following
+ # two lines:
+ # type=${type#string}
+ # config_get${type:+_${type}} "${prefix}${name}" "$config" "$name" "$dflt" || return
+ case "$type" in
+ string)
+ local tmp
+ config_get tmp "$config" "$name" || return
+ [ -z "$tmp" ] && tmp=$dflt
+ export ${NO_EXPORT:+-n} -- "${prefix}${name}=${tmp}"
+ continue
+ ;;
+ boolean)
+ type=bool
+ ;;
+ esac;
+
+ local cmd=${prefix}config_get_${type}
+ type $cmd > /dev/null || {
+ cmd=config_get_${type}
+ }
+ type $cmd > /dev/null || {
+ echo "config type $type (for $name) not supported" >&2
+ return 1
+ }
+ $cmd "${prefix}${name}" "$config" "$name" "$dflt" || return
+ done
+}
+
+config_get_ipaddr() {
+ local varn=$1
+ local conf=$2
+ local name=$3
+ local dflt=$4
+
+ local addr
+ config_get addr "$conf" "$name" || return
+ [ -n "$addr" ] || addr=$dflt
+
+ local mask=${addr#*/}
+ [ "$mask" != "$addr" ] || mask=
+ addr=${addr%/*}
+
+ local vers=
+ case "$addr" in
+ *:*) vers=6; mask="${mask:-128}" ;;
+ *.*) vers=4; mask="${mask:-32}" ;;
+ esac
+
+ export ${NO_EXPORT:+-n} -- "${varn}=${addr}"
+ export ${NO_EXPORT:+-n} -- "${varn}_prefixlen=${mask}"
+ export ${NO_EXPORT:+-n} -- "${varn}_version=${vers}"
+}
diff --git a/package/network/config/firewall/files/lib/core.sh b/package/network/config/firewall/files/lib/core.sh
new file mode 100644
index 0000000..93d4d2e
--- /dev/null
+++ b/package/network/config/firewall/files/lib/core.sh
@@ -0,0 +1,159 @@
+# Copyright (C) 2009-2010 OpenWrt.org
+
+FW_LIBDIR=${FW_LIBDIR:-/lib/firewall}
+
+. $FW_LIBDIR/fw.sh
+include /lib/network
+
+fw_start() {
+ fw_init
+
+ FW_DEFAULTS_APPLIED=
+
+ fw_is_loaded && {
+ echo "firewall already loaded" >&2
+ exit 1
+ }
+
+ uci_set_state firewall core "" firewall_state
+
+ fw_clear DROP
+
+ fw_callback pre core
+
+ echo "Loading defaults"
+ fw_config_once fw_load_defaults defaults
+
+ echo "Loading zones"
+ config_foreach fw_load_zone zone
+
+ echo "Loading forwardings"
+ config_foreach fw_load_forwarding forwarding
+
+ echo "Loading rules"
+ config_foreach fw_load_rule rule
+
+ echo "Loading redirects"
+ config_foreach fw_load_redirect redirect
+
+ echo "Loading includes"
+ config_foreach fw_load_include include
+
+ [ -z "$FW_NOTRACK_DISABLED" ] && {
+ echo "Optimizing conntrack"
+ config_foreach fw_load_notrack_zone zone
+ }
+
+ echo "Loading interfaces"
+ config_foreach fw_configure_interface interface add
+
+ fw_callback post core
+
+ uci_set_state firewall core zones "$FW_ZONES"
+ uci_set_state firewall core loaded 1
+}
+
+fw_stop() {
+ fw_init
+
+ fw_callback pre stop
+
+ local z n i
+ config_get z core zones
+ for z in $z; do
+ config_get n core "${z}_networks"
+ for n in $n; do
+ config_get i core "${n}_ifname"
+ [ -n "$i" ] && env -i ACTION=remove ZONE="$z" \
+ INTERFACE="$n" DEVICE="$i" /sbin/hotplug-call firewall
+ done
+
+ config_get i core "${z}_tcpmss"
+ [ "$i" == 1 ] && {
+ fw del i m FORWARD zone_${z}_MSSFIX
+ fw del i m zone_${z}_MSSFIX
+ }
+ done
+
+ fw_clear ACCEPT
+
+ fw_callback post stop
+
+ uci_revert_state firewall
+ config_clear
+
+ local h
+ for h in $FW_HOOKS; do unset $h; done
+
+ unset FW_HOOKS
+ unset FW_INITIALIZED
+}
+
+fw_restart() {
+ fw_stop
+ fw_start
+}
+
+fw_reload() {
+ fw_restart
+}
+
+fw_is_loaded() {
+ local bool=$(uci_get_state firewall.core.loaded)
+ return $((! ${bool:-0}))
+}
+
+
+fw_die() {
+ echo "Error:" "$@" >&2
+ fw_log error "$@"
+ fw_stop
+ exit 1
+}
+
+fw_log() {
+ local level="$1"
+ [ -n "$2" ] && shift || level=notice
+ [ "$level" != error ] || echo "Error: $@" >&2
+ logger -t firewall -p user.$level "$@"
+}
+
+
+fw_init() {
+ [ -z "$FW_INITIALIZED" ] || return 0
+
+ . $FW_LIBDIR/config.sh
+
+ scan_interfaces
+ fw_config_append firewall
+
+ local hooks="core stop defaults zone notrack synflood"
+ local file lib hk pp
+ for file in $FW_LIBDIR/core_*.sh; do
+ . $file
+ hk=$(basename $file .sh)
+ hk=${hk#core_}
+ append hooks $hk
+ done
+ for file in $FW_LIBDIR/*.sh; do
+ lib=$(basename $file .sh)
+ lib=${lib##[0-9][0-9]_}
+ case $lib in
+ core*|fw|config|uci_firewall) continue ;;
+ esac
+ . $file
+ for hk in $hooks; do
+ for pp in pre post; do
+ type ${lib}_${pp}_${hk}_cb >/dev/null && {
+ append FW_CB_${pp}_${hk} ${lib}
+ append FW_HOOKS FW_CB_${pp}_${hk}
+ }
+ done
+ done
+ done
+
+ fw_callback post init
+
+ FW_INITIALIZED=1
+ return 0
+}
diff --git a/package/network/config/firewall/files/lib/core_forwarding.sh b/package/network/config/firewall/files/lib/core_forwarding.sh
new file mode 100644
index 0000000..2ea03f0
--- /dev/null
+++ b/package/network/config/firewall/files/lib/core_forwarding.sh
@@ -0,0 +1,44 @@
+# Copyright (C) 2009-2010 OpenWrt.org
+
+fw_config_get_forwarding() {
+ [ "${forwarding_NAME}" != "$1" ] || return
+ fw_config_get_section "$1" forwarding { \
+ string _name "$1" \
+ string name "" \
+ string src "" \
+ string dest "" \
+ string family "" \
+ } || return
+ [ -n "$forwarding_name" ] || forwarding_name=$forwarding__name
+}
+
+fw_load_forwarding() {
+ fw_config_get_forwarding "$1"
+
+ fw_callback pre forwarding
+
+ local chain=delegate_forward
+ [ -n "$forwarding_src" ] && {
+ chain=zone_${forwarding_src}_forward
+ }
+
+ local target=ACCEPT
+ [ -n "$forwarding_dest" ] && {
+ target=zone_${forwarding_dest}_dest_ACCEPT
+ }
+
+ local mode
+ fw_get_family_mode mode ${forwarding_family:-x} ${forwarding_dest:-${forwarding_src:--}} i
+
+ fw add $mode f $chain $target ^
+
+ # propagate masq zone flag
+ [ -n "$forwarding_src" ] && list_contains FW_CONNTRACK_ZONES $forwarding_src && {
+ append FW_CONNTRACK_ZONES $forwarding_dest
+ }
+ [ -n "$forwarding_dest" ] && list_contains FW_CONNTRACK_ZONES $forwarding_dest && {
+ append FW_CONNTRACK_ZONES $forwarding_src
+ }
+
+ fw_callback post forwarding
+}
diff --git a/package/network/config/firewall/files/lib/core_init.sh b/package/network/config/firewall/files/lib/core_init.sh
new file mode 100644
index 0000000..404a836
--- /dev/null
+++ b/package/network/config/firewall/files/lib/core_init.sh
@@ -0,0 +1,361 @@
+# Copyright (C) 2009-2011 OpenWrt.org
+# Copyright (C) 2008 John Crispin <blogic@openwrt.org>
+
+FW_INITIALIZED=
+
+FW_ZONES=
+FW_ZONES4=
+FW_ZONES6=
+FW_CONNTRACK_ZONES=
+FW_NOTRACK_DISABLED=
+
+FW_DEFAULTS_APPLIED=
+FW_ADD_CUSTOM_CHAINS=
+FW_ACCEPT_REDIRECTS=
+FW_ACCEPT_SRC_ROUTE=
+
+FW_DEFAULT_INPUT_POLICY=REJECT
+FW_DEFAULT_OUTPUT_POLICY=REJECT
+FW_DEFAULT_FORWARD_POLICY=REJECT
+
+FW_DISABLE_IPV4=0
+FW_DISABLE_IPV6=0
+
+
+fw_load_defaults() {
+ fw_config_get_section "$1" defaults { \
+ string input $FW_DEFAULT_INPUT_POLICY \
+ string output $FW_DEFAULT_OUTPUT_POLICY \
+ string forward $FW_DEFAULT_FORWARD_POLICY \
+ boolean drop_invalid 0 \
+ boolean syn_flood 0 \
+ boolean synflood_protect 0 \
+ string synflood_rate 25 \
+ string synflood_burst 50 \
+ boolean tcp_syncookies 1 \
+ boolean tcp_ecn 0 \
+ boolean tcp_westwood 0 \
+ boolean tcp_window_scaling 1 \
+ boolean accept_redirects 0 \
+ boolean accept_source_route 0 \
+ boolean custom_chains 1 \
+ boolean disable_ipv6 0 \
+ } || return
+ [ -n "$FW_DEFAULTS_APPLIED" ] && {
+ fw_log error "duplicate defaults section detected, skipping"
+ return 1
+ }
+ FW_DEFAULTS_APPLIED=1
+
+ FW_DEFAULT_INPUT_POLICY=$defaults_input
+ FW_DEFAULT_OUTPUT_POLICY=$defaults_output
+ FW_DEFAULT_FORWARD_POLICY=$defaults_forward
+
+ FW_ADD_CUSTOM_CHAINS=$defaults_custom_chains
+
+ FW_ACCEPT_REDIRECTS=$defaults_accept_redirects
+ FW_ACCEPT_SRC_ROUTE=$defaults_accept_source_route
+
+ FW_DISABLE_IPV6=$defaults_disable_ipv6
+
+ fw_callback pre defaults
+
+ # Seems like there are only one sysctl for both IP versions.
+ for s in syncookies ecn westwood window_scaling; do
+ eval "sysctl -e -w net.ipv4.tcp_${s}=\$defaults_tcp_${s}" >/dev/null
+ done
+ fw_sysctl_interface all
+
+ fw add i f INPUT ACCEPT { -m conntrack --ctstate RELATED,ESTABLISHED }
+ fw add i f OUTPUT ACCEPT { -m conntrack --ctstate RELATED,ESTABLISHED }
+ fw add i f FORWARD ACCEPT { -m conntrack --ctstate RELATED,ESTABLISHED }
+
+ [ $defaults_drop_invalid == 1 ] && {
+ fw add i f INPUT DROP { -m conntrack --ctstate INVALID }
+ fw add i f OUTPUT DROP { -m conntrack --ctstate INVALID }
+ fw add i f FORWARD DROP { -m conntrack --ctstate INVALID }
+ FW_NOTRACK_DISABLED=1
+ }
+
+ fw add i f INPUT ACCEPT { -i lo }
+ fw add i f OUTPUT ACCEPT { -o lo }
+
+ # Compatibility to old 'syn_flood' parameter
+ [ $defaults_syn_flood == 1 ] && \
+ defaults_synflood_protect=1
+
+ [ "${defaults_synflood_rate%/*}" == "$defaults_synflood_rate" ] && \
+ defaults_synflood_rate="$defaults_synflood_rate/second"
+
+ [ $defaults_synflood_protect == 1 ] && {
+ echo "Loading synflood protection"
+ fw_callback pre synflood
+ fw add i f syn_flood
+ fw add i f syn_flood RETURN { \
+ -p tcp --syn \
+ -m limit --limit "${defaults_synflood_rate}" --limit-burst "${defaults_synflood_burst}" \
+ }
+ fw add i f syn_flood DROP
+ fw add i f INPUT syn_flood { -p tcp --syn }
+ fw_callback post synflood
+ }
+
+ [ $defaults_custom_chains == 1 ] && {
+ echo "Adding custom chains"
+ fw add i f input_rule
+ fw add i f output_rule
+ fw add i f forwarding_rule
+ fw add i n prerouting_rule
+ fw add i n postrouting_rule
+
+ fw add i f INPUT input_rule
+ fw add i f OUTPUT output_rule
+ fw add i f FORWARD forwarding_rule
+ fw add i n PREROUTING prerouting_rule
+ fw add i n POSTROUTING postrouting_rule
+ }
+
+ fw add i f delegate_input
+ fw add i f delegate_output
+ fw add i f delegate_forward
+
+ fw add i f INPUT delegate_input
+ fw add i f OUTPUT delegate_output
+ fw add i f FORWARD delegate_forward
+
+ fw add i f reject
+ fw add i f reject REJECT { --reject-with tcp-reset -p tcp }
+ fw add i f reject REJECT { --reject-with port-unreach }
+
+ fw_set_filter_policy
+
+ fw_callback post defaults
+}
+
+
+fw_config_get_zone() {
+ [ "${zone_NAME}" != "$1" ] || return
+ fw_config_get_section "$1" zone { \
+ string name "$1" \
+ string network "" \
+ string device "" \
+ string subnet "" \
+ string input "$FW_DEFAULT_INPUT_POLICY" \
+ string output "$FW_DEFAULT_OUTPUT_POLICY" \
+ string forward "$FW_DEFAULT_FORWARD_POLICY" \
+ boolean masq 0 \
+ string masq_src "" \
+ string masq_dest "" \
+ string extra "" \
+ string extra_src "" \
+ string extra_dest "" \
+ boolean conntrack 0 \
+ boolean mtu_fix 0 \
+ boolean custom_chains 0 \
+ boolean log 0 \
+ string log_limit 10 \
+ string family "" \
+ } || return
+ [ -n "$zone_name" ] || zone_name=$zone_NAME
+ [ -n "$zone_extra_src" ] || zone_extra_src="$zone_extra"
+ [ -n "$zone_extra_dest" ] || zone_extra_dest="$zone_extra"
+ [ -n "$zone_network$zone_subnet$zone_device$zone_extra_src$zone_extra_dest" ] || zone_network=$zone_name
+}
+
+fw_load_zone() {
+ fw_config_get_zone "$1"
+
+ list_contains FW_ZONES $zone_name && {
+ fw_log error "zone ${zone_name}: duplicated zone, skipping"
+ return 0
+ }
+ append FW_ZONES $zone_name
+
+ fw_callback pre zone
+
+ [ $zone_conntrack = 1 -o $zone_masq = 1 ] && \
+ append FW_CONNTRACK_ZONES "$zone_name"
+
+ local mode
+ case "$zone_family" in
+ *4)
+ mode=4
+ append FW_ZONES4 $zone_name
+ uci_set_state firewall core ${zone_name}_ipv4 1
+ ;;
+ *6)
+ mode=6
+ append FW_ZONES6 $zone_name
+ uci_set_state firewall core ${zone_name}_ipv6 1
+ ;;
+ *)
+ mode=i
+ append FW_ZONES4 $zone_name
+ append FW_ZONES6 $zone_name
+ uci_set_state firewall core ${zone_name}_ipv4 1
+ uci_set_state firewall core ${zone_name}_ipv6 1
+ ;;
+ esac
+
+ local chain=zone_${zone_name}
+
+ fw add $mode f ${chain}_src_ACCEPT
+ fw add $mode f ${chain}_src_DROP
+ fw add $mode f ${chain}_src_REJECT
+
+ fw add $mode f ${chain}_dest_ACCEPT
+ fw add $mode f ${chain}_dest_DROP
+ fw add $mode f ${chain}_dest_REJECT
+
+ fw add $mode f ${chain}_input
+ fw add $mode f ${chain}_input ${chain}_src_${zone_input} $
+
+ fw add $mode f ${chain}_forward
+ fw add $mode f ${chain}_forward ${chain}_dest_${zone_forward} $
+
+ fw add $mode f ${chain}_output
+ fw add $mode f ${chain}_output ${chain}_dest_${zone_output} $
+
+ # TODO: Rename to ${chain}_MASQUERADE
+ fw add $mode n ${chain}_nat
+ fw add $mode n ${chain}_prerouting
+
+ fw add $mode r ${chain}_notrack
+
+ [ $zone_mtu_fix == 1 ] && {
+ fw add $mode m ${chain}_MSSFIX
+ fw add $mode m FORWARD ${chain}_MSSFIX ^
+ uci_set_state firewall core ${zone_name}_tcpmss 1
+ }
+
+ [ $zone_custom_chains == 1 ] && {
+ [ $FW_ADD_CUSTOM_CHAINS == 1 ] || \
+ fw_die "zone ${zone_name}: custom_chains globally disabled"
+
+ fw add $mode f input_${zone_name}
+ fw add $mode f ${chain}_input input_${zone_name} ^
+
+ fw add $mode f forwarding_${zone_name}
+ fw add $mode f ${chain}_forward forwarding_${zone_name} ^
+
+ fw add $mode n prerouting_${zone_name}
+ fw add $mode n ${chain}_prerouting prerouting_${zone_name} ^
+ }
+
+ [ "$zone_log" == 1 ] && {
+ [ "${zone_log_limit%/*}" == "$zone_log_limit" ] && \
+ zone_log_limit="$zone_log_limit/minute"
+
+ local t
+ for t in REJECT DROP; do
+ local d
+ for d in src dest; do
+ fw add $mode f ${chain}_${d}_${t} LOG ^ \
+ { -m limit --limit $zone_log_limit --log-prefix "$t($d:$zone_name): " }
+ done
+ done
+
+ [ $zone_mtu_fix == 1 ] && \
+ fw add $mode m ${chain}_MSSFIX LOG ^ \
+ { -p tcp --tcp-flags SYN,RST SYN -m limit --limit $zone_log_limit --log-prefix "MSSFIX($zone_name): " }
+ }
+
+ # NB: if MASQUERADING for IPv6 becomes available we'll need a family check here
+ if [ "$zone_masq" == 1 ]; then
+ local msrc mdst
+ for msrc in ${zone_masq_src:-0.0.0.0/0}; do
+ case "$msrc" in
+ *.*) fw_get_negation msrc '-s' "$msrc" ;;
+ *) fw_get_subnet4 msrc '-s' "$msrc" || break ;;
+ esac
+
+ for mdst in ${zone_masq_dest:-0.0.0.0/0}; do
+ case "$mdst" in
+ *.*) fw_get_negation mdst '-d' "$mdst" ;;
+ *) fw_get_subnet4 mdst '-d' "$mdst" || break ;;
+ esac
+
+ fw add $mode n ${chain}_nat MASQUERADE $ { $msrc $mdst }
+ done
+ done
+ fi
+
+ local dev
+ for dev in ${zone_device:-""}; do
+ local net
+ for net in ${zone_subnet:-""}; do
+ [ -n "$dev" ] || [ -n "$net" ] || continue
+ fw_do_interface_rules add "${zone_name}" "$dev" "$net" \
+ "${zone_extra_src}" "${zone_extra_dest}"
+ done
+ done
+
+ fw_callback post zone
+}
+
+fw_load_notrack_zone() {
+ fw_config_get_zone "$1"
+ list_contains FW_CONNTRACK_ZONES "${zone_name}" && return
+
+ fw_callback pre notrack
+
+ fw add i r zone_${zone_name}_notrack NOTRACK $
+
+ fw_callback post notrack
+}
+
+
+fw_load_include() {
+ local name="$1"
+
+ local path
+ config_get path ${name} path
+
+ [ -e $path ] && (
+ config() {
+ fw_log error "You cannot use UCI in firewall includes!" >&2
+ exit 1
+ }
+ . $path
+ )
+}
+
+
+fw_clear() {
+ local policy=$1
+
+ fw_set_filter_policy $policy
+
+ local tab
+ for tab in f n r; do
+ fw del i $tab
+ done
+}
+
+fw_set_filter_policy() {
+ local policy=$1
+
+ local chn tgt
+ for chn in INPUT OUTPUT FORWARD; do
+ eval "tgt=\${policy:-\${FW_DEFAULT_${chn}_POLICY}}"
+ [ $tgt == "REJECT" ] && tgt=reject
+ [ $tgt == "ACCEPT" -o $tgt == "DROP" ] || {
+ fw add i f $chn $tgt $
+ tgt=DROP
+ }
+ fw policy i f $chn $tgt
+ done
+}
+
+
+fw_callback() {
+ local pp=$1
+ local hk=$2
+
+ local libs lib
+ eval "libs=\$FW_CB_${pp}_${hk}"
+ [ -n "$libs" ] || return
+ for lib in $libs; do
+ ${lib}_${pp}_${hk}_cb
+ done
+}
diff --git a/package/network/config/firewall/files/lib/core_interface.sh b/package/network/config/firewall/files/lib/core_interface.sh
new file mode 100644
index 0000000..9138cbf
--- /dev/null
+++ b/package/network/config/firewall/files/lib/core_interface.sh
@@ -0,0 +1,214 @@
+# Copyright (C) 2009-2013 OpenWrt.org
+
+fw__uci_state_add() {
+ local var="$1"
+ local item="$2"
+
+ local val="$(uci_get_state firewall core $var)"
+ local e1; for e1 in $item; do
+ local e2; for e2 in $val; do
+ [ "$e1" = "$e2" ] && e1=""
+ done
+ val="${val:+$val${e1:+ }}$e1"
+ done
+
+ uci_toggle_state firewall core $var "$val"
+}
+
+fw__uci_state_del() {
+ local var="$1"
+ local item="$2"
+
+ local rest=""
+ local val="$(uci_get_state firewall core $var)"
+ local e1; for e1 in $val; do
+ local e2; for e2 in $item; do
+ [ "$e1" = "$e2" ] && e1=""
+ done
+ rest="${rest:+$rest${e1:+ }}$e1"
+ done
+
+ uci_toggle_state firewall core $var "$rest"
+}
+
+fw_do_interface_rules() {
+ local action=$1
+ local zone=$2
+ local chain=zone_${zone}
+ local ifname=$3
+ local subnet=$4
+ local extra_src="$5"
+ local extra_dest="$6"
+
+ local idev odev inet onet mode
+ fw_get_family_mode mode x $zone i
+
+ fw_get_negation idev '-i' "$ifname"
+ fw_get_negation odev '-o' "$ifname"
+
+ case "$mode/$subnet" in
+ # Zone supports v6 only or dual, need v6
+ G6/*:*|i/*:*)
+ fw_get_negation inet '-s' "$subnet"
+ fw_get_negation onet '-d' "$subnet"
+ mode=6
+ ;;
+
+ # Zone supports v4 only or dual, need v4
+ G4/*.*.*.*|i/*.*.*.*)
+ fw_get_negation inet '-s' "$subnet"
+ fw_get_negation onet '-d' "$subnet"
+ mode=4
+ ;;
+
+ # Need v6 while zone is v4
+ */*:*) fw_log info "zone $zone does not support IPv6 address family, skipping"; return ;;
+
+ # Need v4 while zone is v6
+ */*.*) fw_log info "zone $zone does not support IPv4 address family, skipping"; return ;;
+
+ # Strip prefix
+ *) mode="${mode#G}" ;;
+ esac
+
+ lock /var/run/firewall-interface.lock
+
+ fw $action $mode f ${chain}_dest_ACCEPT ACCEPT $ { $odev $onet $extra_dest }
+ fw $action $mode f ${chain}_src_ACCEPT ACCEPT $ { $idev $inet $extra_src }
+ fw $action $mode f ${chain}_dest_DROP DROP $ { $odev $onet $extra_dest }
+ fw $action $mode f ${chain}_src_DROP DROP $ { $idev $inet $extra_src }
+ fw $action $mode f ${chain}_dest_REJECT reject $ { $odev $onet $extra_dest }
+ fw $action $mode f ${chain}_src_REJECT reject $ { $idev $inet $extra_src }
+
+ [ "$(uci_get_state firewall core "${zone}_tcpmss")" == 1 ] && \
+ fw $action $mode m ${chain}_MSSFIX TCPMSS $ \
+ { $odev -p tcp --tcp-flags SYN,RST SYN --clamp-mss-to-pmtu $onet $extra_dest }
+
+ fw $action $mode f delegate_input ${chain}_input $ { $idev $inet $extra_src }
+ fw $action $mode f delegate_forward ${chain}_forward $ { $idev $inet $extra_src }
+ fw $action $mode f delegate_output ${chain}_output $ { $odev $onet $extra_dest }
+
+ fw $action $mode n PREROUTING ${chain}_prerouting $ { $idev $inet $extra_src }
+ fw $action $mode r PREROUTING ${chain}_notrack $ { $idev $inet $extra_src }
+ fw $action $mode n POSTROUTING ${chain}_nat $ { $odev $onet $extra_dest }
+
+ # Flush conntrack table
+ echo f >/proc/net/nf_conntrack 2>/dev/null
+
+ lock -u /var/run/firewall-interface.lock
+}
+
+fw_configure_interface() {
+ local iface=$1
+ local action=$2
+ local ifname=$3
+ local aliasnet=$4
+
+ [ "$action" == "add" ] && {
+ local status=$(uci_get_state network "$iface" up 0)
+ [ "$status" == 1 ] || [ -n "$aliasnet" ] || return 0
+ }
+
+ [ -n "$ifname" ] || {
+ ifname=$(uci_get_state network "$iface" ifname)
+ ifname="${ifname%%:*}"
+ [ -z "$ifname" ] && return 0
+ }
+
+ [ "$ifname" == "lo" ] && return 0
+
+ fw_callback pre interface
+
+ local old_zones old_ifname old_subnets
+ config_get old_zones core "${iface}_zone"
+ [ -n "$old_zones" ] && {
+ config_get old_ifname core "${iface}_ifname"
+ config_get old_subnets core "${iface}_subnets"
+
+ local z
+ for z in $old_zones; do
+ local n
+ for n in ${old_subnets:-""}; do
+ fw_log info "removing $iface ($old_ifname${n:+ alias $n}) from zone $z"
+ fw_do_interface_rules del $z $old_ifname $n
+ done
+
+ [ -n "$old_subnets" ] || {
+ fw__uci_state_del "${z}_networks" "$iface"
+ env -i ACTION=remove ZONE="$z" INTERFACE="$iface" DEVICE="$ifname" /sbin/hotplug-call firewall
+ }
+ done
+
+ local old_aliases
+ config_get old_aliases core "${iface}_aliases"
+
+ local a
+ for a in $old_aliases; do
+ fw_configure_interface "$a" del "$old_ifname"
+ done
+
+ uci_revert_state firewall core "${iface}_zone"
+ uci_revert_state firewall core "${iface}_ifname"
+ uci_revert_state firewall core "${iface}_subnets"
+ uci_revert_state firewall core "${iface}_aliases"
+ }
+
+ [ "$action" == del ] && return
+
+ [ -z "$aliasnet" ] && {
+ local aliases
+ config_get aliases "$iface" aliases
+
+ local a
+ for a in $aliases; do
+ local ipaddr netmask ip6addr
+ config_get ipaddr "$a" ipaddr
+ config_get netmask "$a" netmask
+ config_get ip6addr "$a" ip6addr
+
+ [ -n "$ipaddr" ] && fw_configure_interface "$a" add "" "$ipaddr${netmask:+/$netmask}"
+ [ -n "$ip6addr" ] && fw_configure_interface "$a" add "" "$ip6addr"
+ done
+
+ fw_sysctl_interface $ifname
+ fw_callback post interface
+
+ uci_toggle_state firewall core "${iface}_aliases" "$aliases"
+ } || {
+ local subnets=
+ config_get subnets core "${iface}_subnets"
+ append subnets "$aliasnet"
+
+ config_set core "${iface}_subnets" "$subnets"
+ uci_toggle_state firewall core "${iface}_subnets" "$subnets"
+ }
+
+ local new_zones=
+ load_zone() {
+ fw_config_get_zone "$1"
+ list_contains zone_network "$iface" || return
+
+ fw_log info "adding $iface ($ifname${aliasnet:+ alias $aliasnet}) to zone $zone_name"
+ fw_do_interface_rules add ${zone_name} "$ifname" "$aliasnet"
+ append new_zones $zone_name
+
+ [ -n "$aliasnet" ] || {
+ fw__uci_state_add "${zone_name}_networks" "${zone_network}"
+ env -i ACTION=add ZONE="$zone_name" INTERFACE="$iface" DEVICE="$ifname" /sbin/hotplug-call firewall
+ }
+ }
+ config_foreach load_zone zone
+
+ uci_toggle_state firewall core "${iface}_zone" "$new_zones"
+ uci_toggle_state firewall core "${iface}_ifname" "$ifname"
+}
+
+fw_sysctl_interface() {
+ local ifname=$1
+ {
+ sysctl -w net.ipv4.conf.${ifname}.accept_redirects=$FW_ACCEPT_REDIRECTS
+ sysctl -w net.ipv6.conf.${ifname}.accept_redirects=$FW_ACCEPT_REDIRECTS
+ sysctl -w net.ipv4.conf.${ifname}.accept_source_route=$FW_ACCEPT_SRC_ROUTE
+ sysctl -w net.ipv6.conf.${ifname}.accept_source_route=$FW_ACCEPT_SRC_ROUTE
+ } >/dev/null 2>/dev/null
+}
diff --git a/package/network/config/firewall/files/lib/core_redirect.sh b/package/network/config/firewall/files/lib/core_redirect.sh
new file mode 100644
index 0000000..9493bc6
--- /dev/null
+++ b/package/network/config/firewall/files/lib/core_redirect.sh
@@ -0,0 +1,130 @@
+# Copyright (C) 2009-2010 OpenWrt.org
+
+fw_config_get_redirect() {
+ [ "${redirect_NAME}" != "$1" ] || return
+ fw_config_get_section "$1" redirect { \
+ string _name "$1" \
+ string name "" \
+ string src "" \
+ ipaddr src_ip "" \
+ ipaddr src_dip "" \
+ string src_mac "" \
+ string src_port "" \
+ string src_dport "" \
+ string dest "" \
+ ipaddr dest_ip "" \
+ string dest_port "" \
+ string proto "tcpudp" \
+ string family "" \
+ string target "DNAT" \
+ string extra "" \
+ } || return
+ [ -n "$redirect_name" ] || redirect_name=$redirect__name
+}
+
+fw_load_redirect() {
+ fw_config_get_redirect "$1"
+
+ fw_callback pre redirect
+
+ local fwdchain natchain natopt nataddr natports srcdaddr srcdports
+ if [ "$redirect_target" == "DNAT" ]; then
+ [ -n "${redirect_src#*}" -a -n "$redirect_dest_ip$redirect_dest_port" ] || {
+ fw_log error "DNAT redirect ${redirect_name}: needs src and dest_ip or dest_port, skipping"
+ return 0
+ }
+
+ fwdopt=""
+ fwdchain=""
+
+ # Check whether only ports are given or whether the given dest ip is local,
+ # in this case match only DNATed traffic and allow it on input, not forward
+ if [ -z "$redirect_dest_ip" ] || /sbin/ifconfig | grep -qE "addr:${redirect_dest_ip//./\\.}\b"; then
+ fwdopt="-m conntrack --ctstate DNAT"
+ fwdchain="zone_${redirect_src}_input"
+ else
+ fwdchain="zone_${redirect_src}_forward"
+ fi
+
+ natopt="--to-destination"
+ natchain="zone_${redirect_src}_prerouting"
+ nataddr="$redirect_dest_ip"
+ fw_get_port_range natports "${redirect_dest_port#!}" "-"
+
+ fw_get_negation srcdaddr '-d' "${redirect_src_dip:+$redirect_src_dip/$redirect_src_dip_prefixlen}"
+ fw_get_port_range srcdports "$redirect_src_dport" ":"
+ fw_get_negation srcdports '--dport' "$srcdports"
+
+ list_contains FW_CONNTRACK_ZONES $redirect_src || \
+ append FW_CONNTRACK_ZONES $redirect_src
+
+ elif [ "$redirect_target" == "SNAT" ]; then
+ [ -n "${redirect_dest#*}" -a -n "$redirect_src_dip" ] || {
+ fw_log error "SNAT redirect ${redirect_name}: needs dest and src_dip, skipping"
+ return 0
+ }
+
+ fwdchain="${redirect_src:+zone_${redirect_src}_forward}"
+
+ natopt="--to-source"
+ natchain="zone_${redirect_dest}_nat"
+ nataddr="$redirect_src_dip"
+ fw_get_port_range natports "${redirect_src_dport#!}" "-"
+
+ fw_get_negation srcdaddr '-d' "${redirect_dest_ip:+$redirect_dest_ip/$redirect_dest_ip_prefixlen}"
+ fw_get_port_range srcdports "$redirect_dest_port" ":"
+ fw_get_negation srcdports '--dport' "$srcdports"
+
+ list_contains FW_CONNTRACK_ZONES $redirect_dest || \
+ append FW_CONNTRACK_ZONES $redirect_dest
+
+ else
+ fw_log error "redirect ${redirect_name}: target must be either DNAT or SNAT, skipping"
+ return 0
+ fi
+
+ local mode
+ fw_get_family_mode mode ${redirect_family:-x} ${redirect_src:-$redirect_dest} I
+
+ local srcaddr
+ fw_get_negation srcaddr '-s' "${redirect_src_ip:+$redirect_src_ip/$redirect_src_ip_prefixlen}"
+
+ local srcports
+ fw_get_port_range srcports "$redirect_src_port" ":"
+ fw_get_negation srcports '--sport' "$srcports"
+
+ local destaddr
+ fw_get_negation destaddr '-d' "${redirect_dest_ip:+$redirect_dest_ip/$redirect_dest_ip_prefixlen}"
+
+ local destports
+ fw_get_port_range destports "${redirect_dest_port:-$redirect_src_dport}" ":"
+ fw_get_negation destports '--dport' "$destports"
+
+ [ "$redirect_proto" == "tcpudp" ] && redirect_proto="tcp udp"
+ local pr; for pr in $redirect_proto; do
+ fw_get_negation pr '-p' "$pr"
+ local sm; for sm in ${redirect_src_mac:-""}; do
+ fw_get_negation sm '--mac-source' "$sm"
+ fw add $mode n $natchain $redirect_target + \
+ { $redirect_src_ip $redirect_dest_ip } { \
+ $srcaddr $srcdaddr $pr \
+ $srcports $srcdports \
+ ${sm:+-m mac $sm} \
+ $natopt $nataddr${natports:+:$natports} \
+ $redirect_options \
+ }
+
+ fw add $mode f ${fwdchain:-delegate_forward} ACCEPT + \
+ { $redirect_src_ip $redirect_dest_ip } { \
+ $srcaddr $destaddr \
+ $pr \
+ $srcports $destports \
+ ${sm:+-m mac $sm} \
+ $fwdopt \
+ $redirect_extra \
+ }
+ done
+ done
+
+ fw_callback post redirect
+}
diff --git a/package/network/config/firewall/files/lib/core_rule.sh b/package/network/config/firewall/files/lib/core_rule.sh
new file mode 100644
index 0000000..0ce2122
--- /dev/null
+++ b/package/network/config/firewall/files/lib/core_rule.sh
@@ -0,0 +1,117 @@
+# Copyright (C) 2009-2010 OpenWrt.org
+
+fw_config_get_rule() {
+ [ "${rule_NAME}" != "$1" ] || return
+ fw_config_get_section "$1" rule { \
+ string _name "$1" \
+ string name "" \
+ string src "" \
+ ipaddr src_ip "" \
+ string src_mac "" \
+ string src_port "" \
+ string dest "" \
+ ipaddr dest_ip "" \
+ string dest_port "" \
+ string icmp_type "" \
+ string proto "tcpudp" \
+ string target "" \
+ string family "" \
+ string limit "" \
+ string limit_burst "" \
+ string extra "" \
+ } || return
+ [ -n "$rule_name" ] || rule_name=$rule__name
+}
+
+fw_load_rule() {
+ fw_config_get_rule "$1"
+
+ [ "$rule_target" != "NOTRACK" ] || [ -n "$rule_src" ] || [ "$rule_src" != "*" ] || {
+ fw_log error "NOTRACK rule ${rule_name}: needs src, skipping"
+ return 0
+ }
+
+ fw_callback pre rule
+
+ local table=f
+ local chain=delegate_output
+ local target="${rule_target:-REJECT}"
+ if [ "$target" == "NOTRACK" ]; then
+ table=r
+ chain="zone_${rule_src}_notrack"
+ else
+ if [ -n "$rule_src" ]; then
+ if [ "$rule_src" != "*" ]; then
+ if [ -n "$rule_dest" ]; then
+ chain="zone_${rule_src}_forward"
+ else
+ chain="zone_${rule_src}_input"
+ fi
+ else
+ chain="${rule_dest:+delegate_forward}"
+ chain="${chain:-delegate_input}"
+ fi
+ fi
+
+ if [ -n "$rule_dest" ]; then
+ if [ "$rule_dest" != "*" ]; then
+ target="zone_${rule_dest}_dest_${target}"
+ if [ -z "$rule_src" ]; then
+ chain="zone_${rule_dest}_output"
+ fi
+ elif [ "$target" = REJECT ]; then
+ target=reject
+ fi
+ fi
+ fi
+
+ local mode
+ fw_get_family_mode mode ${rule_family:-x} "$rule_src" I
+
+ local src_spec dest_spec
+ fw_get_negation src_spec '-s' "${rule_src_ip:+$rule_src_ip/$rule_src_ip_prefixlen}"
+ fw_get_negation dest_spec '-d' "${rule_dest_ip:+$rule_dest_ip/$rule_dest_ip_prefixlen}"
+
+ [ "$rule_proto" == "tcpudp" ] && rule_proto="tcp udp"
+ local pr; for pr in $rule_proto; do
+ local sports dports itypes
+ case "$pr" in
+ icmp|icmpv6|1|58)
+ sports=""; dports=""
+ itypes="$rule_icmp_type"
+ ;;
+ *)
+ sports="$rule_src_port"
+ dports="$rule_dest_port"
+ itypes=""
+ ;;
+ esac
+
+ fw_get_negation pr '-p' "$pr"
+ local sp; for sp in ${sports:-""}; do
+ fw_get_port_range sp $sp
+ fw_get_negation sp '--sport' "$sp"
+ local dp; for dp in ${dports:-""}; do
+ fw_get_port_range dp $dp
+ fw_get_negation dp '--dport' "$dp"
+ local sm; for sm in ${rule_src_mac:-""}; do
+ fw_get_negation sm '--mac-source' "$sm"
+ local it; for it in ${itypes:-""}; do
+ fw_get_negation it '--icmp-type' "$it"
+ fw add $mode $table $chain $target + \
+ { $rule_src_ip $rule_dest_ip } { \
+ $src_spec $dest_spec \
+ $pr $sp $dp $it \
+ ${sm:+-m mac $sm} \
+ ${rule_limit:+-m limit --limit $rule_limit \
+ ${rule_limit_burst:+--limit-burst $rule_limit_burst}} \
+ $rule_extra \
+ }
+ done
+ done
+ done
+ done
+ done
+
+ fw_callback post rule
+}
diff --git a/package/network/config/firewall/files/lib/fw.sh b/package/network/config/firewall/files/lib/fw.sh
new file mode 100644
index 0000000..ca851e8
--- /dev/null
+++ b/package/network/config/firewall/files/lib/fw.sh
@@ -0,0 +1,324 @@
+# Copyright (C) 2009-2010 OpenWrt.org
+# Copyright (C) 2009 Malte S. Stretz
+
+export FW_4_ERROR=0
+export FW_6_ERROR=0
+export FW_i_ERROR=0
+export FW_e_ERROR=0
+export FW_a_ERROR=0
+
+#TODO: remove this
+[ "${-#*x}" == "$-" ] && {
+ fw() {
+ fw__exec "$@"
+ }
+} || {
+ fw() {
+ local os=$-
+ set +x
+ fw__exec "$@"
+ local rc=$?
+ set -$os
+ return $rc
+ }
+}
+
+fw__exec() { # <action> <family> <table> <chain> <target> <position> { <rules> }
+ local cmd fam tab chn tgt pos
+ local i
+ for i in cmd fam tab chn tgt pos; do
+ if [ "$1" -a "$1" != '{' ]; then
+ eval "$i='$1'"
+ shift
+ else
+ eval "$i=-"
+ fi
+ done
+
+ fw__rc() {
+ export FW_${fam#G}_ERROR=$1
+ return $1
+ }
+
+ fw__dualip() {
+ fw $cmd 4 $tab $chn $tgt $pos "$@"
+ fw $cmd 6 $tab $chn $tgt $pos "$@"
+ fw__rc $((FW_4_ERROR | FW_6_ERROR))
+ }
+
+ fw__autoip() {
+ local ip4 ip6
+ shift
+ while [ "$1" != '}' ]; do
+ case "$1" in
+ *:*) ip6=1 ;;
+ *.*.*.*) ip4=1 ;;
+ esac
+ shift
+ done
+ shift
+ if [ "${ip4:-4}" == "${ip6:-6}" ]; then
+ echo "fw: can't mix ip4 and ip6" >&2
+ return 1
+ fi
+ local ver=${ip4:+4}${ip6:+6}
+ fam=i
+ fw $cmd ${ver:-i} $tab $chn $tgt $pos "$@"
+ fw__rc $?
+ }
+
+ fw__has() {
+ local tab=${1:-$tab}
+ if [ $tab == '-' ]; then
+ type $app > /dev/null 2> /dev/null
+ fw__rc $(($? & 1))
+ return
+ fi
+ [ "$app" != ip6tables ] || [ "$tab" != nat ]
+ fw__rc $?
+ }
+
+ fw__err() {
+ local err
+ eval "err=\$FW_${fam}_ERROR"
+ fw__rc $err
+ }
+
+ local app=
+ local pol=
+ case "$fam" in
+ *4) [ $FW_DISABLE_IPV4 == 0 ] && app=iptables || return ;;
+ *6) [ $FW_DISABLE_IPV6 == 0 ] && app=ip6tables || return ;;
+ i) fw__dualip "$@"; return ;;
+ I) fw__autoip "$@"; return ;;
+ e) app=ebtables ;;
+ a) app=arptables ;;
+ -) fw $cmd i $tab $chn $tgt $pos "$@"; return ;;
+ *) return 254 ;;
+ esac
+ case "$tab" in
+ f) tab=filter ;;
+ m) tab=mangle ;;
+ n) tab=nat ;;
+ r) tab=raw ;;
+ -) tab=filter ;;
+ esac
+ case "$cmd:$chn:$tgt:$pos" in
+ add:*:-:*) cmd=new-chain ;;
+ add:*:*:-) cmd=append ;;
+ add:*:*:$) cmd=append ;;
+ add:*:*:*) cmd=insert ;;
+ del:-:*:*) cmd=delete-chain; fw flush $fam $tab ;;
+ del:*:-:*) cmd=delete-chain; fw flush $fam $tab $chn ;;
+ del:*:*:*) cmd=delete ;;
+ flush:*) ;;
+ policy:*) pol=$tgt; tgt=- ;;
+ has:*) fw__has; return ;;
+ err:*) fw__err; return ;;
+ list:*) cmd="numeric --verbose --$cmd" ;;
+ *) return 254 ;;
+ esac
+ case "$chn" in
+ -) chn= ;;
+ esac
+ case "$tgt" in
+ -) tgt= ;;
+ esac
+
+ local rule_offset
+ case "$pos" in
+ ^) pos=1 ;;
+ $) pos= ;;
+ -) pos= ;;
+ +) eval "rule_offset=\${FW__RULE_OFS_${app}_${tab}_${chn}:-1}" ;;
+ esac
+
+ if ! fw__has - family || ! fw__has $tab ; then
+ export FW_${fam}_ERROR=0
+ return 0
+ fi
+
+ case "$fam" in
+ G*) shift; while [ $# -gt 0 ] && [ "$1" != "{" ]; do shift; done ;;
+ esac
+
+ if [ $# -gt 0 ]; then
+ shift
+ if [ $cmd == delete ]; then
+ pos=
+ fi
+ fi
+
+ local cmdline="$app --table ${tab} --${cmd} ${chn} ${pol} ${rule_offset:-${pos}} ${tgt:+--jump "$tgt"}"
+ while [ $# -gt 1 ]; do
+ # special parameter handling
+ case "$1:$2" in
+ -p:icmp*|-p:1|-p:58|--protocol:icmp*|--protocol:1|--protocol:58)
+ [ "$app" = ip6tables ] && \
+ cmdline="$cmdline -p icmpv6" || \
+ cmdline="$cmdline -p icmp"
+ shift
+ ;;
+ --icmp-type:*|--icmpv6-type:*)
+ local icmp_type
+ if [ "$app" = ip6tables ] && fw_check_icmptype6 icmp_type "$2"; then
+ cmdline="$cmdline $icmp_type"
+ elif [ "$app" = iptables ] && fw_check_icmptype4 icmp_type "$2"; then
+ cmdline="$cmdline $icmp_type"
+ else
+ local fam=IPv4; [ "$app" = ip6tables ] && fam=IPv6
+ fw_log info "ICMP type '$2' is not valid for $fam address family, skipping rule"
+ return 1
+ fi
+ shift
+ ;;
+ *) cmdline="$cmdline $1" ;;
+ esac
+ shift
+ done
+
+ [ -n "$FW_TRACE" ] && echo $cmdline >&2
+
+ $cmdline
+
+ local rv=$?
+ [ $rv -eq 0 ] && [ -n "$rule_offset" ] && \
+ export -- "FW__RULE_OFS_${app}_${tab}_${chn}=$(($rule_offset + 1))"
+ fw__rc $rv
+}
+
+fw_get_port_range() {
+ local _var=$1
+ local _ports=$2
+ local _delim=${3:-:}
+ if [ "$4" ]; then
+ fw_get_port_range $_var "${_ports}-${4}" $_delim
+ return
+ fi
+
+ local _first=${_ports%-*}
+ local _last=${_ports#*-}
+ if [ "${_first#!}" != "${_last#!}" ]; then
+ export -- "$_var=$_first$_delim${_last#!}"
+ else
+ export -- "$_var=$_first"
+ fi
+}
+
+fw_get_family_mode() {
+ local _var="$1"
+ local _hint="$2"
+ local _zone="$3"
+ local _mode="$4"
+
+ local _ipv4 _ipv6
+ [ "$_zone" != "*" ] && {
+ [ -n "$FW_ZONES4$FW_ZONES6" ] && {
+ list_contains FW_ZONES4 "$_zone" && _ipv4=1 || _ipv4=0
+ list_contains FW_ZONES6 "$_zone" && _ipv6=1 || _ipv6=0
+ } || {
+ _ipv4=$(uci_get_state firewall core "${_zone}_ipv4" 0)
+ _ipv6=$(uci_get_state firewall core "${_zone}_ipv6" 0)
+ }
+ } || {
+ _ipv4=1
+ _ipv6=1
+ }
+
+ case "$_hint:$_ipv4:$_ipv6" in
+ *4:1:*|*:1:0) export -n -- "$_var=G4" ;;
+ *6:*:1|*:0:1) export -n -- "$_var=G6" ;;
+ *) export -n -- "$_var=$_mode" ;;
+ esac
+}
+
+fw_get_negation() {
+ local _var="$1"
+ local _flag="$2"
+ local _value="$3"
+
+ [ "${_value#!}" != "$_value" ] && \
+ export -n -- "$_var=! $_flag ${_value#!}" || \
+ export -n -- "$_var=${_value:+$_flag $_value}"
+}
+
+fw_get_subnet4() {
+ local _var="$1"
+ local _flag="$2"
+ local _name="$3"
+
+ local _ipaddr="$(uci_get_state network "${_name#!}" ipaddr)"
+ local _netmask="$(uci_get_state network "${_name#!}" netmask)"
+
+ case "$_ipaddr" in
+ *.*.*.*)
+ [ "${_name#!}" != "$_name" ] && \
+ export -n -- "$_var=! $_flag $_ipaddr/${_netmask:-255.255.255.255}" || \
+ export -n -- "$_var=$_flag $_ipaddr/${_netmask:-255.255.255.255}"
+ return 0
+ ;;
+ esac
+
+ export -n -- "$_var="
+ return 1
+}
+
+fw_check_icmptype4() {
+ local _var="$1"
+ local _type="$2"
+ case "$_type" in
+ ![0-9]*) export -n -- "$_var=! --icmp-type ${_type#!}"; return 0 ;;
+ [0-9]*) export -n -- "$_var=--icmp-type $_type"; return 0 ;;
+ esac
+
+ [ -z "$FW_ICMP4_TYPES" ] && \
+ export FW_ICMP4_TYPES=$(
+ iptables -p icmp -h 2>/dev/null | \
+ sed -n -e '/^Valid ICMP Types:/ {
+ n; :r; s/[()]/ /g; s/[[:space:]]\+/\n/g; p; n; b r
+ }' | sort -u
+ )
+
+ local _check
+ for _check in $FW_ICMP4_TYPES; do
+ if [ "$_check" = "${_type#!}" ]; then
+ [ "${_type#!}" != "$_type" ] && \
+ export -n -- "$_var=! --icmp-type ${_type#!}" || \
+ export -n -- "$_var=--icmp-type $_type"
+ return 0
+ fi
+ done
+
+ export -n -- "$_var="
+ return 1
+}
+
+fw_check_icmptype6() {
+ local _var="$1"
+ local _type="$2"
+ case "$_type" in
+ ![0-9]*) export -n -- "$_var=! --icmpv6-type ${_type#!}"; return 0 ;;
+ [0-9]*) export -n -- "$_var=--icmpv6-type $_type"; return 0 ;;
+ esac
+
+ [ -z "$FW_ICMP6_TYPES" ] && \
+ export FW_ICMP6_TYPES=$(
+ ip6tables -p icmpv6 -h 2>/dev/null | \
+ sed -n -e '/^Valid ICMPv6 Types:/ {
+ n; :r; s/[()]/ /g; s/[[:space:]]\+/\n/g; p; n; b r
+ }' | sort -u
+ )
+
+ local _check
+ for _check in $FW_ICMP6_TYPES; do
+ if [ "$_check" = "${_type#!}" ]; then
+ [ "${_type#!}" != "$_type" ] && \
+ export -n -- "$_var=! --icmpv6-type ${_type#!}" || \
+ export -n -- "$_var=--icmpv6-type $_type"
+ return 0
+ fi
+ done
+
+ export -n -- "$_var="
+ return 1
+}
diff --git a/package/network/config/firewall/files/lib/uci_firewall.sh b/package/network/config/firewall/files/lib/uci_firewall.sh
new file mode 100644
index 0000000..7c95a7a
--- /dev/null
+++ b/package/network/config/firewall/files/lib/uci_firewall.sh
@@ -0,0 +1,5 @@
+# This file is here for backwards compatibility and to override the
+# uci_firewall.sh from an earlier version.
+type fw_is_loaded >/dev/null || {
+ . /lib/firewall/core.sh
+}
diff --git a/package/network/config/firewall/files/reflection.hotplug b/package/network/config/firewall/files/reflection.hotplug
new file mode 100644
index 0000000..129a922
--- /dev/null
+++ b/package/network/config/firewall/files/reflection.hotplug
@@ -0,0 +1,169 @@
+#!/bin/sh
+
+. /lib/functions.sh
+. /lib/functions/network.sh
+
+if [ "$ACTION" = "remove" ]; then
+
+ delete_rules_by_comment() {
+ local table="$1"
+ local chain="$2"
+ local comment="$3"
+
+ iptables -t "$table" --line-numbers -nL "$chain" 2>/dev/null | \
+ sed -e '
+ 1d;
+ 1! {
+ \#^[0-9]\+ .* /\* '"$comment"' \*/.*$# {
+ s/ .*$//;
+ G; h;
+ }
+ };
+ $!d;
+ ' | xargs -n1 iptables -t "$table" -D "$chain" 2>/dev/null
+ }
+
+ delete_rules_by_comment nat nat_reflection_in "$INTERFACE"
+ delete_rules_by_comment nat nat_reflection_out "$INTERFACE"
+ delete_rules_by_comment filter nat_reflection_fwd "$INTERFACE"
+
+elif [ "$ACTION" = "add" ]; then
+
+ prepare_chains() {
+ iptables -t nat -N nat_reflection_in 2>/dev/null && {
+ iptables -t nat -A prerouting_rule -j nat_reflection_in
+ }
+
+ iptables -t nat -N nat_reflection_out 2>/dev/null && {
+ iptables -t nat -A postrouting_rule -j nat_reflection_out
+ }
+
+ iptables -t filter -N nat_reflection_fwd 2>/dev/null && {
+ iptables -t filter -A forwarding_rule -j nat_reflection_fwd
+ }
+ }
+
+ find_networks() {
+ find_networks_cb() {
+ local cfg="$1"
+ local zone="$2"
+ local need_masq="${3:-0}"
+
+ local name
+ config_get name "$cfg" name
+
+ local masq
+ config_get_bool masq "$cfg" masq 0
+
+ [ "$name" = "$zone" ] && [ "$masq" -ge "$need_masq" ] && {
+ local network
+ config_get network "$cfg" network
+
+ echo ${network:-$zone}
+ return 1
+ }
+ }
+
+ config_foreach find_networks_cb zone "$@"
+ }
+
+ setup_fwd() {
+ local cfg="$1"
+
+ local reflection
+ config_get_bool reflection "$cfg" reflection 1
+ [ "$reflection" == 1 ] || return
+
+ local src
+ config_get src "$cfg" src
+ [ "$src" == "$ZONE" ] || return
+
+ local dest
+ config_get dest "$cfg" dest
+ [ "$dest" != "*" ] || return
+
+ local target
+ config_get target "$cfg" target DNAT
+ [ "$target" = DNAT ] || return
+
+ prepare_chains
+
+ local net
+ for net in $(find_networks "$dest" 0); do
+ local intnet
+ network_get_subnet intnet "$net" || continue
+
+ local proto
+ config_get proto "$cfg" proto
+
+ local epmin epmax extport
+ config_get extport "$cfg" src_dport "1-65535"
+ [ -n "$extport" ] || return
+
+ epmin="${extport%[-:]*}"; epmax="${extport#*[-:]}"
+ [ "${epmin#!}" != "$epmax" ] || epmax=""
+
+ local ipmin ipmax intport
+ config_get intport "$cfg" dest_port "$extport"
+
+ ipmin="${intport%[-:]*}"; ipmax="${intport#*[-:]}"
+ [ "${ipmin#!}" != "$ipmax" ] || ipmax=""
+
+ local exthost
+ config_get exthost "$cfg" src_dip "$extip"
+
+ local inthost
+ config_get inthost "$cfg" dest_ip
+ [ -n "$inthost" ] || return
+
+ [ "$proto" = all ] && proto="tcp udp"
+ [ "$proto" = tcpudp ] && proto="tcp udp"
+
+ [ "${inthost#!}" = "$inthost" ] || return 0
+ [ "${exthost#!}" = "$exthost" ] || return 0
+
+ [ "${epmin#!}" != "$epmin" ] && \
+ extport="! --dport ${epmin#!}${epmax:+:$epmax}" || \
+ extport="--dport $epmin${epmax:+:$epmax}"
+
+ [ "${ipmin#!}" != "$ipmin" ] && \
+ intport="! --dport ${ipmin#!}${ipmax:+:$ipmax}" || \
+ intport="--dport $ipmin${ipmax:+:$ipmax}"
+
+ local p
+ for p in ${proto:-tcp udp}; do
+ case "$p" in
+ tcp|udp|6|17)
+ iptables -t nat -A nat_reflection_in \
+ -s $intnet -d $exthost \
+ -p $p $extport \
+ -m comment --comment "$INTERFACE" \
+ -j DNAT --to $inthost:${ipmin#!}${ipmax:+-$ipmax}
+
+ iptables -t nat -A nat_reflection_out \
+ -s $intnet -d $inthost \
+ -p $p $intport \
+ -m comment --comment "$INTERFACE" \
+ -j SNAT --to-source ${intnet%%/*}
+
+ iptables -t filter -A nat_reflection_fwd \
+ -s $intnet -d $inthost \
+ -p $p $intport \
+ -m comment --comment "$INTERFACE" \
+ -j ACCEPT
+ ;;
+ esac
+ done
+ done
+ }
+
+ config_load firewall
+
+ local is_masq_zone="$(find_networks "$ZONE" 1)"
+ [ -n "$is_masq_zone" ] || exit 0
+
+ local extip
+ network_get_ipaddr extip "$INTERFACE" || exit 0
+
+ config_foreach setup_fwd redirect
+fi
diff --git a/package/network/config/firewall3/.svn/entries b/package/network/config/firewall3/.svn/entries
new file mode 100644
index 0000000..3f60200
--- /dev/null
+++ b/package/network/config/firewall3/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/config/firewall3
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-14T15:29:43.028686Z
+36009
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+files
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+d20f1407354143adf7bb3998da00ee47
+2013-03-14T15:29:43.028686Z
+36009
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1520
+
diff --git a/package/network/config/firewall3/.svn/text-base/Makefile.svn-base b/package/network/config/firewall3/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..6bd768c
--- /dev/null
+++ b/package/network/config/firewall3/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,54 @@
+#
+# Copyright (C) 2013 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=firewall3
+PKG_VERSION:=2013-03-14
+PKG_RELEASE:=$(PKG_SOURCE_VERSION)
+
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL:=git://nbd.name/firewall3.git
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE_VERSION:=ab591095d650bc3e997bad12aa7662e49d5cd9d5
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
+PKG_MAINTAINER:=Jo-Philipp Wich <jow@openwrt.org>
+
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/cmake.mk
+
+define Package/firewall3
+ SECTION:=net
+ CATEGORY:=Network
+ TITLE:=UCI C Firewall
+ DEPENDS:=+libubox +libubus +libuci
+endef
+
+define Package/firewall3/description
+ This package provides a config-compatible C implementation of the UCI firewall.
+endef
+
+define Package/firewall3/conffiles
+/etc/config/firewall
+/etc/firewall.user
+endef
+
+define Package/firewall3/install
+ $(INSTALL_DIR) $(1)/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/firewall3 $(1)/sbin/fw3
+ $(INSTALL_DIR) $(1)/etc/init.d
+ $(INSTALL_BIN) ./files/firewall.init $(1)/etc/init.d/firewall
+ $(INSTALL_DIR) $(1)/etc/hotplug.d/iface
+ $(INSTALL_DATA) ./files/firewall.hotplug $(1)/etc/hotplug.d/iface/20-firewall
+ $(INSTALL_DIR) $(1)/etc/config/
+ $(INSTALL_DATA) ./files/firewall.config $(1)/etc/config/firewall
+ $(INSTALL_DIR) $(1)/etc/
+ $(INSTALL_DATA) ./files/firewall.user $(1)/etc/firewall.user
+endef
+
+$(eval $(call BuildPackage,firewall3))
diff --git a/package/network/config/firewall3/Makefile b/package/network/config/firewall3/Makefile
new file mode 100644
index 0000000..6bd768c
--- /dev/null
+++ b/package/network/config/firewall3/Makefile
@@ -0,0 +1,54 @@
+#
+# Copyright (C) 2013 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=firewall3
+PKG_VERSION:=2013-03-14
+PKG_RELEASE:=$(PKG_SOURCE_VERSION)
+
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL:=git://nbd.name/firewall3.git
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE_VERSION:=ab591095d650bc3e997bad12aa7662e49d5cd9d5
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
+PKG_MAINTAINER:=Jo-Philipp Wich <jow@openwrt.org>
+
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/cmake.mk
+
+define Package/firewall3
+ SECTION:=net
+ CATEGORY:=Network
+ TITLE:=UCI C Firewall
+ DEPENDS:=+libubox +libubus +libuci
+endef
+
+define Package/firewall3/description
+ This package provides a config-compatible C implementation of the UCI firewall.
+endef
+
+define Package/firewall3/conffiles
+/etc/config/firewall
+/etc/firewall.user
+endef
+
+define Package/firewall3/install
+ $(INSTALL_DIR) $(1)/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/firewall3 $(1)/sbin/fw3
+ $(INSTALL_DIR) $(1)/etc/init.d
+ $(INSTALL_BIN) ./files/firewall.init $(1)/etc/init.d/firewall
+ $(INSTALL_DIR) $(1)/etc/hotplug.d/iface
+ $(INSTALL_DATA) ./files/firewall.hotplug $(1)/etc/hotplug.d/iface/20-firewall
+ $(INSTALL_DIR) $(1)/etc/config/
+ $(INSTALL_DATA) ./files/firewall.config $(1)/etc/config/firewall
+ $(INSTALL_DIR) $(1)/etc/
+ $(INSTALL_DATA) ./files/firewall.user $(1)/etc/firewall.user
+endef
+
+$(eval $(call BuildPackage,firewall3))
diff --git a/package/network/config/firewall3/files/.svn/entries b/package/network/config/firewall3/files/.svn/entries
new file mode 100644
index 0000000..9baf8d9
--- /dev/null
+++ b/package/network/config/firewall3/files/.svn/entries
@@ -0,0 +1,164 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/config/firewall3/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-13T15:46:30.571192Z
+35998
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+firewall.user
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+f482960e5c24821f077e601d9a7f3068
+2013-03-11T20:52:20.179524Z
+35969
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+352
+
+firewall.hotplug
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+8d17f1b0dbce5fe0f59a693af482f2c5
+2013-03-13T15:46:30.571192Z
+35998
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+223
+
+firewall.init
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+2c5f74740c6b69a390dfaf075f2e72a6
+2013-03-13T15:46:30.571192Z
+35998
+jow
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+262
+
+firewall.config
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+f952253dc6cb85d189857c3fead88362
+2013-03-05T13:45:09.488580Z
+35889
+jow
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4244
+
diff --git a/package/network/config/firewall3/files/.svn/prop-base/firewall.config.svn-base b/package/network/config/firewall3/files/.svn/prop-base/firewall.config.svn-base
new file mode 100644
index 0000000..3160658
--- /dev/null
+++ b/package/network/config/firewall3/files/.svn/prop-base/firewall.config.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:mergeinfo
+V 0
+
+END
diff --git a/package/network/config/firewall3/files/.svn/prop-base/firewall.init.svn-base b/package/network/config/firewall3/files/.svn/prop-base/firewall.init.svn-base
new file mode 100644
index 0000000..869ac71
--- /dev/null
+++ b/package/network/config/firewall3/files/.svn/prop-base/firewall.init.svn-base
@@ -0,0 +1,5 @@
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/network/config/firewall3/files/.svn/text-base/firewall.config.svn-base b/package/network/config/firewall3/files/.svn/text-base/firewall.config.svn-base
new file mode 100644
index 0000000..6acfe1e
--- /dev/null
+++ b/package/network/config/firewall3/files/.svn/text-base/firewall.config.svn-base
@@ -0,0 +1,195 @@
+config defaults
+ option syn_flood 1
+ option input ACCEPT
+ option output ACCEPT
+ option forward REJECT
+# Uncomment this line to disable ipv6 rules
+# option disable_ipv6 1
+
+config zone
+ option name lan
+ option network 'lan'
+ option input ACCEPT
+ option output ACCEPT
+ option forward REJECT
+
+config zone
+ option name wan
+ option network 'wan'
+ option input REJECT
+ option output ACCEPT
+ option forward REJECT
+ option masq 1
+ option mtu_fix 1
+
+config forwarding
+ option src lan
+ option dest wan
+
+# We need to accept udp packets on port 68,
+# see https://dev.openwrt.org/ticket/4108
+config rule
+ option name Allow-DHCP-Renew
+ option src wan
+ option proto udp
+ option dest_port 68
+ option target ACCEPT
+ option family ipv4
+
+# Allow IPv4 ping
+config rule
+ option name Allow-Ping
+ option src wan
+ option proto icmp
+ option icmp_type echo-request
+ option family ipv4
+ option target ACCEPT
+
+# Allow DHCPv6 replies
+# see https://dev.openwrt.org/ticket/10381
+config rule
+ option name Allow-DHCPv6
+ option src wan
+ option proto udp
+ option src_ip fe80::/10
+ option src_port 547
+ option dest_ip fe80::/10
+ option dest_port 546
+ option family ipv6
+ option target ACCEPT
+
+# Allow essential incoming IPv6 ICMP traffic
+config rule
+ option name Allow-ICMPv6-Input
+ option src wan
+ option proto icmp
+ list icmp_type echo-request
+ list icmp_type echo-reply
+ list icmp_type destination-unreachable
+ list icmp_type packet-too-big
+ list icmp_type time-exceeded
+ list icmp_type bad-header
+ list icmp_type unknown-header-type
+ list icmp_type router-solicitation
+ list icmp_type neighbour-solicitation
+ list icmp_type router-advertisement
+ list icmp_type neighbour-advertisement
+ option limit 1000/sec
+ option family ipv6
+ option target ACCEPT
+
+# Allow essential forwarded IPv6 ICMP traffic
+config rule
+ option name Allow-ICMPv6-Forward
+ option src wan
+ option dest *
+ option proto icmp
+ list icmp_type echo-request
+ list icmp_type echo-reply
+ list icmp_type destination-unreachable
+ list icmp_type packet-too-big
+ list icmp_type time-exceeded
+ list icmp_type bad-header
+ list icmp_type unknown-header-type
+ option limit 1000/sec
+ option family ipv6
+ option target ACCEPT
+
+# Block ULA-traffic from leaking out
+config rule
+ option name Enforce-ULA-Border-Src
+ option src *
+ option dest wan
+ option proto all
+ option src_ip fc00::/7
+ option family ipv6
+ option target REJECT
+
+config rule
+ option name Enforce-ULA-Border-Dest
+ option src *
+ option dest wan
+ option proto all
+ option dest_ip fc00::/7
+ option family ipv6
+ option target REJECT
+
+# include a file with users custom iptables rules
+config include
+ option path /etc/firewall.user
+
+
+### EXAMPLE CONFIG SECTIONS
+# do not allow a specific ip to access wan
+#config rule
+# option src lan
+# option src_ip 192.168.45.2
+# option dest wan
+# option proto tcp
+# option target REJECT
+
+# block a specific mac on wan
+#config rule
+# option dest wan
+# option src_mac 00:11:22:33:44:66
+# option target REJECT
+
+# block incoming ICMP traffic on a zone
+#config rule
+# option src lan
+# option proto ICMP
+# option target DROP
+
+# port redirect port coming in on wan to lan
+#config redirect
+# option src wan
+# option src_dport 80
+# option dest lan
+# option dest_ip 192.168.16.235
+# option dest_port 80
+# option proto tcp
+
+# port redirect of remapped ssh port (22001) on wan
+#config redirect
+# option src wan
+# option src_dport 22001
+# option dest lan
+# option dest_port 22
+# option proto tcp
+
+# allow IPsec/ESP and ISAKMP passthrough
+#config rule
+# option src wan
+# option dest lan
+# option protocol esp
+# option target ACCEPT
+
+#config rule
+# option src wan
+# option dest lan
+# option src_port 500
+# option dest_port 500
+# option proto udp
+# option target ACCEPT
+
+### FULL CONFIG SECTIONS
+#config rule
+# option src lan
+# option src_ip 192.168.45.2
+# option src_mac 00:11:22:33:44:55
+# option src_port 80
+# option dest wan
+# option dest_ip 194.25.2.129
+# option dest_port 120
+# option proto tcp
+# option target REJECT
+
+#config redirect
+# option src lan
+# option src_ip 192.168.45.2
+# option src_mac 00:11:22:33:44:55
+# option src_port 1024
+# option src_dport 80
+# option dest_ip 194.25.2.129
+# option dest_port 120
+# option proto tcp
diff --git a/package/network/config/firewall3/files/.svn/text-base/firewall.hotplug.svn-base b/package/network/config/firewall3/files/.svn/text-base/firewall.hotplug.svn-base
new file mode 100644
index 0000000..34f3afe
--- /dev/null
+++ b/package/network/config/firewall3/files/.svn/text-base/firewall.hotplug.svn-base
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+[ "$ACTION" = ifup ] || exit 0
+
+/etc/init.d/firewall enabled || exit 0
+
+fw3 -q network "$INTERFACE" >/dev/null || exit 0
+
+logger -t firewall "Reloading firewall due to ifup of $INTERFACE ($DEVICE)"
+fw3 -q reload
diff --git a/package/network/config/firewall3/files/.svn/text-base/firewall.init.svn-base b/package/network/config/firewall3/files/.svn/text-base/firewall.init.svn-base
new file mode 100644
index 0000000..64e3a8c
--- /dev/null
+++ b/package/network/config/firewall3/files/.svn/text-base/firewall.init.svn-base
@@ -0,0 +1,25 @@
+#!/bin/sh /etc/rc.common
+
+START=19
+
+boot() {
+ # Be silent on boot, firewall might be started by hotplug already,
+ # so don't complain in syslog.
+ fw3 -q start
+}
+
+start() {
+ fw3 start
+}
+
+stop() {
+ fw3 flush
+}
+
+restart() {
+ fw3 restart
+}
+
+reload() {
+ fw3 reload
+}
diff --git a/package/network/config/firewall3/files/.svn/text-base/firewall.user.svn-base b/package/network/config/firewall3/files/.svn/text-base/firewall.user.svn-base
new file mode 100644
index 0000000..6f79906
--- /dev/null
+++ b/package/network/config/firewall3/files/.svn/text-base/firewall.user.svn-base
@@ -0,0 +1,7 @@
+# This file is interpreted as shell script.
+# Put your custom iptables rules here, they will
+# be executed with each firewall (re-)start.
+
+# Internal uci firewall chains are flushed and recreated on reload, so
+# put custom rules into the root chains e.g. INPUT or FORWARD or into the
+# special user chains, e.g. input_wan_rule or postrouting_lan_rule.
diff --git a/package/network/config/firewall3/files/firewall.config b/package/network/config/firewall3/files/firewall.config
new file mode 100644
index 0000000..6acfe1e
--- /dev/null
+++ b/package/network/config/firewall3/files/firewall.config
@@ -0,0 +1,195 @@
+config defaults
+ option syn_flood 1
+ option input ACCEPT
+ option output ACCEPT
+ option forward REJECT
+# Uncomment this line to disable ipv6 rules
+# option disable_ipv6 1
+
+config zone
+ option name lan
+ option network 'lan'
+ option input ACCEPT
+ option output ACCEPT
+ option forward REJECT
+
+config zone
+ option name wan
+ option network 'wan'
+ option input REJECT
+ option output ACCEPT
+ option forward REJECT
+ option masq 1
+ option mtu_fix 1
+
+config forwarding
+ option src lan
+ option dest wan
+
+# We need to accept udp packets on port 68,
+# see https://dev.openwrt.org/ticket/4108
+config rule
+ option name Allow-DHCP-Renew
+ option src wan
+ option proto udp
+ option dest_port 68
+ option target ACCEPT
+ option family ipv4
+
+# Allow IPv4 ping
+config rule
+ option name Allow-Ping
+ option src wan
+ option proto icmp
+ option icmp_type echo-request
+ option family ipv4
+ option target ACCEPT
+
+# Allow DHCPv6 replies
+# see https://dev.openwrt.org/ticket/10381
+config rule
+ option name Allow-DHCPv6
+ option src wan
+ option proto udp
+ option src_ip fe80::/10
+ option src_port 547
+ option dest_ip fe80::/10
+ option dest_port 546
+ option family ipv6
+ option target ACCEPT
+
+# Allow essential incoming IPv6 ICMP traffic
+config rule
+ option name Allow-ICMPv6-Input
+ option src wan
+ option proto icmp
+ list icmp_type echo-request
+ list icmp_type echo-reply
+ list icmp_type destination-unreachable
+ list icmp_type packet-too-big
+ list icmp_type time-exceeded
+ list icmp_type bad-header
+ list icmp_type unknown-header-type
+ list icmp_type router-solicitation
+ list icmp_type neighbour-solicitation
+ list icmp_type router-advertisement
+ list icmp_type neighbour-advertisement
+ option limit 1000/sec
+ option family ipv6
+ option target ACCEPT
+
+# Allow essential forwarded IPv6 ICMP traffic
+config rule
+ option name Allow-ICMPv6-Forward
+ option src wan
+ option dest *
+ option proto icmp
+ list icmp_type echo-request
+ list icmp_type echo-reply
+ list icmp_type destination-unreachable
+ list icmp_type packet-too-big
+ list icmp_type time-exceeded
+ list icmp_type bad-header
+ list icmp_type unknown-header-type
+ option limit 1000/sec
+ option family ipv6
+ option target ACCEPT
+
+# Block ULA-traffic from leaking out
+config rule
+ option name Enforce-ULA-Border-Src
+ option src *
+ option dest wan
+ option proto all
+ option src_ip fc00::/7
+ option family ipv6
+ option target REJECT
+
+config rule
+ option name Enforce-ULA-Border-Dest
+ option src *
+ option dest wan
+ option proto all
+ option dest_ip fc00::/7
+ option family ipv6
+ option target REJECT
+
+# include a file with users custom iptables rules
+config include
+ option path /etc/firewall.user
+
+
+### EXAMPLE CONFIG SECTIONS
+# do not allow a specific ip to access wan
+#config rule
+# option src lan
+# option src_ip 192.168.45.2
+# option dest wan
+# option proto tcp
+# option target REJECT
+
+# block a specific mac on wan
+#config rule
+# option dest wan
+# option src_mac 00:11:22:33:44:66
+# option target REJECT
+
+# block incoming ICMP traffic on a zone
+#config rule
+# option src lan
+# option proto ICMP
+# option target DROP
+
+# port redirect port coming in on wan to lan
+#config redirect
+# option src wan
+# option src_dport 80
+# option dest lan
+# option dest_ip 192.168.16.235
+# option dest_port 80
+# option proto tcp
+
+# port redirect of remapped ssh port (22001) on wan
+#config redirect
+# option src wan
+# option src_dport 22001
+# option dest lan
+# option dest_port 22
+# option proto tcp
+
+# allow IPsec/ESP and ISAKMP passthrough
+#config rule
+# option src wan
+# option dest lan
+# option protocol esp
+# option target ACCEPT
+
+#config rule
+# option src wan
+# option dest lan
+# option src_port 500
+# option dest_port 500
+# option proto udp
+# option target ACCEPT
+
+### FULL CONFIG SECTIONS
+#config rule
+# option src lan
+# option src_ip 192.168.45.2
+# option src_mac 00:11:22:33:44:55
+# option src_port 80
+# option dest wan
+# option dest_ip 194.25.2.129
+# option dest_port 120
+# option proto tcp
+# option target REJECT
+
+#config redirect
+# option src lan
+# option src_ip 192.168.45.2
+# option src_mac 00:11:22:33:44:55
+# option src_port 1024
+# option src_dport 80
+# option dest_ip 194.25.2.129
+# option dest_port 120
+# option proto tcp
diff --git a/package/network/config/firewall3/files/firewall.hotplug b/package/network/config/firewall3/files/firewall.hotplug
new file mode 100644
index 0000000..34f3afe
--- /dev/null
+++ b/package/network/config/firewall3/files/firewall.hotplug
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+[ "$ACTION" = ifup ] || exit 0
+
+/etc/init.d/firewall enabled || exit 0
+
+fw3 -q network "$INTERFACE" >/dev/null || exit 0
+
+logger -t firewall "Reloading firewall due to ifup of $INTERFACE ($DEVICE)"
+fw3 -q reload
diff --git a/package/network/config/firewall3/files/firewall.init b/package/network/config/firewall3/files/firewall.init
new file mode 100755
index 0000000..64e3a8c
--- /dev/null
+++ b/package/network/config/firewall3/files/firewall.init
@@ -0,0 +1,25 @@
+#!/bin/sh /etc/rc.common
+
+START=19
+
+boot() {
+ # Be silent on boot, firewall might be started by hotplug already,
+ # so don't complain in syslog.
+ fw3 -q start
+}
+
+start() {
+ fw3 start
+}
+
+stop() {
+ fw3 flush
+}
+
+restart() {
+ fw3 restart
+}
+
+reload() {
+ fw3 reload
+}
diff --git a/package/network/config/firewall3/files/firewall.user b/package/network/config/firewall3/files/firewall.user
new file mode 100644
index 0000000..6f79906
--- /dev/null
+++ b/package/network/config/firewall3/files/firewall.user
@@ -0,0 +1,7 @@
+# This file is interpreted as shell script.
+# Put your custom iptables rules here, they will
+# be executed with each firewall (re-)start.
+
+# Internal uci firewall chains are flushed and recreated on reload, so
+# put custom rules into the root chains e.g. INPUT or FORWARD or into the
+# special user chains, e.g. input_wan_rule or postrouting_lan_rule.
diff --git a/package/network/config/ltq-dsl-app/.svn/entries b/package/network/config/ltq-dsl-app/.svn/entries
new file mode 100644
index 0000000..54817f2
--- /dev/null
+++ b/package/network/config/ltq-dsl-app/.svn/entries
@@ -0,0 +1,31 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/config/ltq-dsl-app
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-12-15T02:00:39.596852Z
+34694
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+patches
+dir
+
diff --git a/package/network/config/ltq-dsl-app/patches/.svn/entries b/package/network/config/ltq-dsl-app/patches/.svn/entries
new file mode 100644
index 0000000..0809305
--- /dev/null
+++ b/package/network/config/ltq-dsl-app/patches/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/config/ltq-dsl-app/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-12-03T12:46:57.108169Z
+34468
+mirko
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+010-eglibc_compile_fix.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+a5157ed81f90d27e4225ef82914554ae
+2012-12-03T12:46:57.108169Z
+34468
+mirko
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+647
+
diff --git a/package/network/config/ltq-dsl-app/patches/.svn/text-base/010-eglibc_compile_fix.patch.svn-base b/package/network/config/ltq-dsl-app/patches/.svn/text-base/010-eglibc_compile_fix.patch.svn-base
new file mode 100644
index 0000000..268f868
--- /dev/null
+++ b/package/network/config/ltq-dsl-app/patches/.svn/text-base/010-eglibc_compile_fix.patch.svn-base
@@ -0,0 +1,23 @@
+--- a/configure.in
++++ b/configure.in
+@@ -29,6 +29,8 @@ AC_C_VOLATILE
+ #AC_FUNC_STRTOD
+ #AC_CHECK_FUNCS([ftime gethostbyname gettimeofday localtime_r memset select socket strchr strerror strstr strtoull])
+
++AC_SEARCH_LIBS([clock_gettime],[rt])
++
+ #
+ # save the configure arguments
+ #
+--- a/src/dsl_cpe_linux.h
++++ b/src/dsl_cpe_linux.h
+@@ -45,7 +45,8 @@
+ #include <arpa/inet.h>
+ #include <sys/socket.h> /* socket */
+ #include <sys/sem.h> /* semget */
+-#include <semaphore.h> /* sem_t */
++#include <semaphore.h> /* sem_t */
++#include <limits.h>
+
+ #ifdef DSL_DEBUG_TOOL_INTERFACE
+ #include <sys/socket.h>
diff --git a/package/network/config/ltq-dsl-app/patches/010-eglibc_compile_fix.patch b/package/network/config/ltq-dsl-app/patches/010-eglibc_compile_fix.patch
new file mode 100644
index 0000000..268f868
--- /dev/null
+++ b/package/network/config/ltq-dsl-app/patches/010-eglibc_compile_fix.patch
@@ -0,0 +1,23 @@
+--- a/configure.in
++++ b/configure.in
+@@ -29,6 +29,8 @@ AC_C_VOLATILE
+ #AC_FUNC_STRTOD
+ #AC_CHECK_FUNCS([ftime gethostbyname gettimeofday localtime_r memset select socket strchr strerror strstr strtoull])
+
++AC_SEARCH_LIBS([clock_gettime],[rt])
++
+ #
+ # save the configure arguments
+ #
+--- a/src/dsl_cpe_linux.h
++++ b/src/dsl_cpe_linux.h
+@@ -45,7 +45,8 @@
+ #include <arpa/inet.h>
+ #include <sys/socket.h> /* socket */
+ #include <sys/sem.h> /* semget */
+-#include <semaphore.h> /* sem_t */
++#include <semaphore.h> /* sem_t */
++#include <limits.h>
+
+ #ifdef DSL_DEBUG_TOOL_INTERFACE
+ #include <sys/socket.h>
diff --git a/package/network/config/netifd/.svn/entries b/package/network/config/netifd/.svn/entries
new file mode 100644
index 0000000..4ebc152
--- /dev/null
+++ b/package/network/config/netifd/.svn/entries
@@ -0,0 +1,68 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/config/netifd
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-02-22T08:56:29.298787Z
+35743
+cyrus
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+files
+dir
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+e416eb8345976b288affaabbe8ad909e
+2013-02-22T08:56:29.298787Z
+35743
+cyrus
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1139
+
diff --git a/package/network/config/netifd/.svn/text-base/Makefile.svn-base b/package/network/config/netifd/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..ad27e2c
--- /dev/null
+++ b/package/network/config/netifd/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,46 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=netifd
+PKG_VERSION:=2013-02-19
+PKG_RELEASE=$(PKG_SOURCE_VERSION)
+
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL:=git://nbd.name/luci2/netifd.git
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE_VERSION:=486aa750a164d41905beb61afec89268e3eb7f48
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+# PKG_MIRROR_MD5SUM:=
+# CMAKE_INSTALL:=1
+
+PKG_LICENSE:=GPLv2
+PKG_LICENSE_FILES:=
+
+PKG_BUILD_PARALLEL:=1
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/cmake.mk
+
+define Package/netifd
+ SECTION:=base
+ CATEGORY:=Base system
+ DEPENDS:=+libuci +libnl-tiny +libubus +ubus +ubusd +jshn
+ TITLE:=OpenWrt Network Interface Configuration Daemon
+endef
+
+TARGET_CFLAGS += \
+ -I$(STAGING_DIR)/usr/include/libnl-tiny \
+ -I$(STAGING_DIR)/usr/include
+
+CMAKE_OPTIONS += \
+ -DLIBNL_LIBS=-lnl-tiny \
+ -DDEBUG=1
+
+define Package/netifd/install
+ $(INSTALL_DIR) $(1)/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/netifd $(1)/sbin/
+ $(CP) ./files/* $(1)/
+ $(CP) $(PKG_BUILD_DIR)/dummy/netifd-proto.sh $(1)/lib/netifd/
+endef
+
+$(eval $(call BuildPackage,netifd))
diff --git a/package/network/config/netifd/Makefile b/package/network/config/netifd/Makefile
new file mode 100644
index 0000000..ad27e2c
--- /dev/null
+++ b/package/network/config/netifd/Makefile
@@ -0,0 +1,46 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=netifd
+PKG_VERSION:=2013-02-19
+PKG_RELEASE=$(PKG_SOURCE_VERSION)
+
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL:=git://nbd.name/luci2/netifd.git
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE_VERSION:=486aa750a164d41905beb61afec89268e3eb7f48
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+# PKG_MIRROR_MD5SUM:=
+# CMAKE_INSTALL:=1
+
+PKG_LICENSE:=GPLv2
+PKG_LICENSE_FILES:=
+
+PKG_BUILD_PARALLEL:=1
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/cmake.mk
+
+define Package/netifd
+ SECTION:=base
+ CATEGORY:=Base system
+ DEPENDS:=+libuci +libnl-tiny +libubus +ubus +ubusd +jshn
+ TITLE:=OpenWrt Network Interface Configuration Daemon
+endef
+
+TARGET_CFLAGS += \
+ -I$(STAGING_DIR)/usr/include/libnl-tiny \
+ -I$(STAGING_DIR)/usr/include
+
+CMAKE_OPTIONS += \
+ -DLIBNL_LIBS=-lnl-tiny \
+ -DDEBUG=1
+
+define Package/netifd/install
+ $(INSTALL_DIR) $(1)/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/netifd $(1)/sbin/
+ $(CP) ./files/* $(1)/
+ $(CP) $(PKG_BUILD_DIR)/dummy/netifd-proto.sh $(1)/lib/netifd/
+endef
+
+$(eval $(call BuildPackage,netifd))
diff --git a/package/network/config/netifd/files/.svn/entries b/package/network/config/netifd/files/.svn/entries
new file mode 100644
index 0000000..1e86684
--- /dev/null
+++ b/package/network/config/netifd/files/.svn/entries
@@ -0,0 +1,40 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/config/netifd/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-29T14:40:04.101944Z
+35383
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+lib
+dir
+
+usr
+dir
+
+etc
+dir
+
+sbin
+dir
+
diff --git a/package/network/config/netifd/files/etc/.svn/entries b/package/network/config/netifd/files/etc/.svn/entries
new file mode 100644
index 0000000..8be2c35
--- /dev/null
+++ b/package/network/config/netifd/files/etc/.svn/entries
@@ -0,0 +1,34 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/config/netifd/files/etc
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-29T10:13:39.572932Z
+35369
+cyrus
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+hotplug.d
+dir
+
+init.d
+dir
+
diff --git a/package/network/config/netifd/files/etc/hotplug.d/.svn/entries b/package/network/config/netifd/files/etc/hotplug.d/.svn/entries
new file mode 100644
index 0000000..22338da
--- /dev/null
+++ b/package/network/config/netifd/files/etc/hotplug.d/.svn/entries
@@ -0,0 +1,31 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/config/netifd/files/etc/hotplug.d
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-29T10:13:39.572932Z
+35369
+cyrus
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+iface
+dir
+
diff --git a/package/network/config/netifd/files/etc/hotplug.d/iface/.svn/entries b/package/network/config/netifd/files/etc/hotplug.d/iface/.svn/entries
new file mode 100644
index 0000000..5810f6a
--- /dev/null
+++ b/package/network/config/netifd/files/etc/hotplug.d/iface/.svn/entries
@@ -0,0 +1,96 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/config/netifd/files/etc/hotplug.d/iface
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-29T10:13:39.572932Z
+35369
+cyrus
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+00-netstate
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+07e4cbee0469ae27ace1efa977b04eae
+2012-02-03T10:17:30.884717Z
+30008
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+337
+
+10-ipv6-static
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+97591c010e5989d4f29cb5bc616f9e73
+2013-01-29T10:13:39.572932Z
+35369
+cyrus
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+487
+
diff --git a/package/network/config/netifd/files/etc/hotplug.d/iface/.svn/text-base/00-netstate.svn-base b/package/network/config/netifd/files/etc/hotplug.d/iface/.svn/text-base/00-netstate.svn-base
new file mode 100644
index 0000000..c50cda6
--- /dev/null
+++ b/package/network/config/netifd/files/etc/hotplug.d/iface/.svn/text-base/00-netstate.svn-base
@@ -0,0 +1,8 @@
+[ ifup = "$ACTION" ] && {
+ uci_toggle_state network "$INTERFACE" up 1
+ uci_toggle_state network "$INTERFACE" connect_time $(sed -ne 's![^0-9].*$!!p' /proc/uptime)
+ [ -n "$DEVICE" ] && {
+ uci_toggle_state network "$INTERFACE" device "$(uci -q get network.$INTERFACE.ifname)"
+ uci_toggle_state network "$INTERFACE" ifname "$DEVICE"
+ }
+}
diff --git a/package/network/config/netifd/files/etc/hotplug.d/iface/.svn/text-base/10-ipv6-static.svn-base b/package/network/config/netifd/files/etc/hotplug.d/iface/.svn/text-base/10-ipv6-static.svn-base
new file mode 100644
index 0000000..d724894
--- /dev/null
+++ b/package/network/config/netifd/files/etc/hotplug.d/iface/.svn/text-base/10-ipv6-static.svn-base
@@ -0,0 +1,19 @@
+case "$ACTION" in
+ ifup)
+ . /lib/functions.sh
+
+ local proto ip6slaac
+ config_load network
+ config_get proto "$INTERFACE" proto
+ config_get_bool ip6slaac "$INTERFACE" ip6slaac
+
+ if [ "$proto" = "static" -a "$ip6slaac" = "1" ]; then
+ echo 2 > "/proc/sys/net/ipv6/conf/$DEVICE/accept_ra"
+
+ # Though this should be save here, it is not recommended
+ echo 1 > "/proc/sys/net/ipv6/conf/$DEVICE/disable_ipv6"
+ echo 0 > "/proc/sys/net/ipv6/conf/$DEVICE/disable_ipv6"
+ fi
+ ;;
+esac
+
diff --git a/package/network/config/netifd/files/etc/hotplug.d/iface/00-netstate b/package/network/config/netifd/files/etc/hotplug.d/iface/00-netstate
new file mode 100644
index 0000000..c50cda6
--- /dev/null
+++ b/package/network/config/netifd/files/etc/hotplug.d/iface/00-netstate
@@ -0,0 +1,8 @@
+[ ifup = "$ACTION" ] && {
+ uci_toggle_state network "$INTERFACE" up 1
+ uci_toggle_state network "$INTERFACE" connect_time $(sed -ne 's![^0-9].*$!!p' /proc/uptime)
+ [ -n "$DEVICE" ] && {
+ uci_toggle_state network "$INTERFACE" device "$(uci -q get network.$INTERFACE.ifname)"
+ uci_toggle_state network "$INTERFACE" ifname "$DEVICE"
+ }
+}
diff --git a/package/network/config/netifd/files/etc/hotplug.d/iface/10-ipv6-static b/package/network/config/netifd/files/etc/hotplug.d/iface/10-ipv6-static
new file mode 100644
index 0000000..d724894
--- /dev/null
+++ b/package/network/config/netifd/files/etc/hotplug.d/iface/10-ipv6-static
@@ -0,0 +1,19 @@
+case "$ACTION" in
+ ifup)
+ . /lib/functions.sh
+
+ local proto ip6slaac
+ config_load network
+ config_get proto "$INTERFACE" proto
+ config_get_bool ip6slaac "$INTERFACE" ip6slaac
+
+ if [ "$proto" = "static" -a "$ip6slaac" = "1" ]; then
+ echo 2 > "/proc/sys/net/ipv6/conf/$DEVICE/accept_ra"
+
+ # Though this should be save here, it is not recommended
+ echo 1 > "/proc/sys/net/ipv6/conf/$DEVICE/disable_ipv6"
+ echo 0 > "/proc/sys/net/ipv6/conf/$DEVICE/disable_ipv6"
+ fi
+ ;;
+esac
+
diff --git a/package/network/config/netifd/files/etc/init.d/.svn/entries b/package/network/config/netifd/files/etc/init.d/.svn/entries
new file mode 100644
index 0000000..2520cee
--- /dev/null
+++ b/package/network/config/netifd/files/etc/init.d/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/config/netifd/files/etc/init.d
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-19T10:13:14.536731Z
+35240
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+network
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+f013880fead70c81159a0bc5c2096c31
+2013-01-19T10:13:14.536731Z
+35240
+jow
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+559
+
diff --git a/package/network/config/netifd/files/etc/init.d/.svn/prop-base/network.svn-base b/package/network/config/netifd/files/etc/init.d/.svn/prop-base/network.svn-base
new file mode 100644
index 0000000..869ac71
--- /dev/null
+++ b/package/network/config/netifd/files/etc/init.d/.svn/prop-base/network.svn-base
@@ -0,0 +1,5 @@
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/network/config/netifd/files/etc/init.d/.svn/text-base/network.svn-base b/package/network/config/netifd/files/etc/init.d/.svn/text-base/network.svn-base
new file mode 100644
index 0000000..429f33d
--- /dev/null
+++ b/package/network/config/netifd/files/etc/init.d/.svn/text-base/network.svn-base
@@ -0,0 +1,47 @@
+#!/bin/sh /etc/rc.common
+
+START=20
+STOP=90
+
+SERVICE_DAEMONIZE=1
+SERVICE_WRITE_PID=1
+
+start() {
+ stop
+ [ -e /proc/sys/kernel/core_pattern ] && {
+ ulimit -c unlimited
+ echo '/tmp/%e.%p.%s.%t.core' > /proc/sys/kernel/core_pattern
+ }
+ service_start /sbin/netifd
+
+ setup_switch() { return 0; }
+
+ include /lib/network
+ setup_switch
+
+ sleep 5
+
+ /sbin/wifi down
+ /sbin/wifi up
+}
+
+restart() {
+ ifdown -a
+ sleep 1
+ start
+}
+
+shutdown() {
+ ifdown -a
+ stop
+}
+
+stop() {
+ service_stop /sbin/netifd
+}
+
+reload() {
+ ubus call network reload
+ /sbin/wifi down
+ /sbin/wifi up
+}
diff --git a/package/network/config/netifd/files/etc/init.d/network b/package/network/config/netifd/files/etc/init.d/network
new file mode 100755
index 0000000..429f33d
--- /dev/null
+++ b/package/network/config/netifd/files/etc/init.d/network
@@ -0,0 +1,47 @@
+#!/bin/sh /etc/rc.common
+
+START=20
+STOP=90
+
+SERVICE_DAEMONIZE=1
+SERVICE_WRITE_PID=1
+
+start() {
+ stop
+ [ -e /proc/sys/kernel/core_pattern ] && {
+ ulimit -c unlimited
+ echo '/tmp/%e.%p.%s.%t.core' > /proc/sys/kernel/core_pattern
+ }
+ service_start /sbin/netifd
+
+ setup_switch() { return 0; }
+
+ include /lib/network
+ setup_switch
+
+ sleep 5
+
+ /sbin/wifi down
+ /sbin/wifi up
+}
+
+restart() {
+ ifdown -a
+ sleep 1
+ start
+}
+
+shutdown() {
+ ifdown -a
+ stop
+}
+
+stop() {
+ service_stop /sbin/netifd
+}
+
+reload() {
+ ubus call network reload
+ /sbin/wifi down
+ /sbin/wifi up
+}
diff --git a/package/network/config/netifd/files/lib/.svn/entries b/package/network/config/netifd/files/lib/.svn/entries
new file mode 100644
index 0000000..72f9274
--- /dev/null
+++ b/package/network/config/netifd/files/lib/.svn/entries
@@ -0,0 +1,34 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/config/netifd/files/lib
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-12-15T17:19:24.809183Z
+34704
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+netifd
+dir
+
+network
+dir
+
diff --git a/package/network/config/netifd/files/lib/netifd/.svn/entries b/package/network/config/netifd/files/lib/netifd/.svn/entries
new file mode 100644
index 0000000..96910c4
--- /dev/null
+++ b/package/network/config/netifd/files/lib/netifd/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/config/netifd/files/lib/netifd
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-12-15T17:19:24.809183Z
+34704
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+dhcp.script
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+1693935249ca21d6ee4b449e363eab81
+2012-12-15T17:19:24.809183Z
+34704
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1392
+
+proto
+dir
+
diff --git a/package/network/config/netifd/files/lib/netifd/.svn/prop-base/dhcp.script.svn-base b/package/network/config/netifd/files/lib/netifd/.svn/prop-base/dhcp.script.svn-base
new file mode 100644
index 0000000..869ac71
--- /dev/null
+++ b/package/network/config/netifd/files/lib/netifd/.svn/prop-base/dhcp.script.svn-base
@@ -0,0 +1,5 @@
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/network/config/netifd/files/lib/netifd/.svn/text-base/dhcp.script.svn-base b/package/network/config/netifd/files/lib/netifd/.svn/text-base/dhcp.script.svn-base
new file mode 100644
index 0000000..d26db0f
--- /dev/null
+++ b/package/network/config/netifd/files/lib/netifd/.svn/text-base/dhcp.script.svn-base
@@ -0,0 +1,62 @@
+#!/bin/sh
+[ -z "$1" ] && echo "Error: should be run by udhcpc" && exit 1
+
+. /lib/functions.sh
+. /lib/netifd/netifd-proto.sh
+
+set_classless_routes() {
+ local max=128
+ local type
+ while [ -n "$1" -a -n "$2" -a $max -gt 0 ]; do
+ proto_add_ipv4_route "${1%%/*}" "${1##*/}" "$2"
+ max=$(($max-1))
+ shift 2
+ done
+}
+
+setup_interface () {
+ proto_init_update "*" 1
+ proto_add_ipv4_address "$ip" "${subnet:-255.255.255.0}"
+ # TODO: apply $broadcast
+
+ for i in $router; do
+ proto_add_ipv4_route 0.0.0.0 0 "$i"
+ done
+
+ # CIDR STATIC ROUTES (rfc3442)
+ [ -n "$staticroutes" ] && set_classless_routes $staticroutes
+ [ -n "$msstaticroutes" ] && set_classless_routes $msstaticroutes
+
+ for dns in $dns; do
+ proto_add_dns_server "$dns"
+ done
+ for domain in $domain; do
+ proto_add_dns_search "$domain"
+ done
+ proto_send_update "$INTERFACE"
+
+ # TODO
+ # [ -n "$ntpsrv" ] && change_state network "$ifc" lease_ntpsrv "$ntpsrv"
+ # [ -n "$timesvr" ] && change_state network "$ifc" lease_timesrv "$timesvr"
+ # [ -n "$hostname" ] && change_state network "$ifc" lease_hostname "$hostname"
+ # [ -n "$timezone" ] && change_state network "$ifc" lease_timezone "$timezone"
+}
+
+deconfig_interface() {
+ proto_init_update "*" 0
+ proto_send_update "$INTERFACE"
+}
+
+case "$1" in
+ deconfig)
+ deconfig_interface
+ ;;
+ renew|bound)
+ setup_interface
+ ;;
+esac
+
+# user rules
+[ -f /etc/udhcpc.user ] && . /etc/udhcpc.user
+
+exit 0
diff --git a/package/network/config/netifd/files/lib/netifd/dhcp.script b/package/network/config/netifd/files/lib/netifd/dhcp.script
new file mode 100755
index 0000000..d26db0f
--- /dev/null
+++ b/package/network/config/netifd/files/lib/netifd/dhcp.script
@@ -0,0 +1,62 @@
+#!/bin/sh
+[ -z "$1" ] && echo "Error: should be run by udhcpc" && exit 1
+
+. /lib/functions.sh
+. /lib/netifd/netifd-proto.sh
+
+set_classless_routes() {
+ local max=128
+ local type
+ while [ -n "$1" -a -n "$2" -a $max -gt 0 ]; do
+ proto_add_ipv4_route "${1%%/*}" "${1##*/}" "$2"
+ max=$(($max-1))
+ shift 2
+ done
+}
+
+setup_interface () {
+ proto_init_update "*" 1
+ proto_add_ipv4_address "$ip" "${subnet:-255.255.255.0}"
+ # TODO: apply $broadcast
+
+ for i in $router; do
+ proto_add_ipv4_route 0.0.0.0 0 "$i"
+ done
+
+ # CIDR STATIC ROUTES (rfc3442)
+ [ -n "$staticroutes" ] && set_classless_routes $staticroutes
+ [ -n "$msstaticroutes" ] && set_classless_routes $msstaticroutes
+
+ for dns in $dns; do
+ proto_add_dns_server "$dns"
+ done
+ for domain in $domain; do
+ proto_add_dns_search "$domain"
+ done
+ proto_send_update "$INTERFACE"
+
+ # TODO
+ # [ -n "$ntpsrv" ] && change_state network "$ifc" lease_ntpsrv "$ntpsrv"
+ # [ -n "$timesvr" ] && change_state network "$ifc" lease_timesrv "$timesvr"
+ # [ -n "$hostname" ] && change_state network "$ifc" lease_hostname "$hostname"
+ # [ -n "$timezone" ] && change_state network "$ifc" lease_timezone "$timezone"
+}
+
+deconfig_interface() {
+ proto_init_update "*" 0
+ proto_send_update "$INTERFACE"
+}
+
+case "$1" in
+ deconfig)
+ deconfig_interface
+ ;;
+ renew|bound)
+ setup_interface
+ ;;
+esac
+
+# user rules
+[ -f /etc/udhcpc.user ] && . /etc/udhcpc.user
+
+exit 0
diff --git a/package/network/config/netifd/files/lib/netifd/proto/.svn/entries b/package/network/config/netifd/files/lib/netifd/proto/.svn/entries
new file mode 100644
index 0000000..627c4de
--- /dev/null
+++ b/package/network/config/netifd/files/lib/netifd/proto/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/config/netifd/files/lib/netifd/proto
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-11-05T19:28:24.248597Z
+34089
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+dhcp.sh
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+53542ed23c9805277cc02e3d7dc0a307
+2012-11-05T19:28:24.248597Z
+34089
+jow
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1129
+
diff --git a/package/network/config/netifd/files/lib/netifd/proto/.svn/prop-base/dhcp.sh.svn-base b/package/network/config/netifd/files/lib/netifd/proto/.svn/prop-base/dhcp.sh.svn-base
new file mode 100644
index 0000000..869ac71
--- /dev/null
+++ b/package/network/config/netifd/files/lib/netifd/proto/.svn/prop-base/dhcp.sh.svn-base
@@ -0,0 +1,5 @@
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/network/config/netifd/files/lib/netifd/proto/.svn/text-base/dhcp.sh.svn-base b/package/network/config/netifd/files/lib/netifd/proto/.svn/text-base/dhcp.sh.svn-base
new file mode 100644
index 0000000..3830878
--- /dev/null
+++ b/package/network/config/netifd/files/lib/netifd/proto/.svn/text-base/dhcp.sh.svn-base
@@ -0,0 +1,49 @@
+#!/bin/sh
+
+. /lib/functions.sh
+. ../netifd-proto.sh
+init_proto "$@"
+
+proto_dhcp_init_config() {
+ proto_config_add_string "ipaddr"
+ proto_config_add_string "netmask"
+ proto_config_add_string "hostname"
+ proto_config_add_string "clientid"
+ proto_config_add_string "vendorid"
+ proto_config_add_boolean "broadcast"
+ proto_config_add_string "reqopts"
+}
+
+proto_dhcp_setup() {
+ local config="$1"
+ local iface="$2"
+
+ local ipaddr hostname clientid vendorid broadcast reqopts
+ json_get_vars ipaddr hostname clientid vendorid broadcast reqopts
+
+ local opt dhcpopts
+ for opt in $reqopts; do
+ append dhcpopts "-O $opt"
+ done
+
+ [ "$broadcast" = 1 ] && broadcast="-B" || broadcast=
+ [ -n "$clientid" ] && clientid="-x 0x3d:${clientid//:/}" || clientid="-C"
+
+ proto_export "INTERFACE=$config"
+ proto_run_command "$config" udhcpc \
+ -p /var/run/udhcpc-$iface.pid \
+ -s /lib/netifd/dhcp.script \
+ -f -t 0 -i "$iface" \
+ ${ipaddr:+-r $ipaddr} \
+ ${hostname:+-H $hostname} \
+ ${vendorid:+-V $vendorid} \
+ $clientid $broadcast $dhcpopts
+}
+
+proto_dhcp_teardown() {
+ local interface="$1"
+ proto_kill_command "$interface"
+}
+
+add_protocol dhcp
+
diff --git a/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh b/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh
new file mode 100755
index 0000000..3830878
--- /dev/null
+++ b/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh
@@ -0,0 +1,49 @@
+#!/bin/sh
+
+. /lib/functions.sh
+. ../netifd-proto.sh
+init_proto "$@"
+
+proto_dhcp_init_config() {
+ proto_config_add_string "ipaddr"
+ proto_config_add_string "netmask"
+ proto_config_add_string "hostname"
+ proto_config_add_string "clientid"
+ proto_config_add_string "vendorid"
+ proto_config_add_boolean "broadcast"
+ proto_config_add_string "reqopts"
+}
+
+proto_dhcp_setup() {
+ local config="$1"
+ local iface="$2"
+
+ local ipaddr hostname clientid vendorid broadcast reqopts
+ json_get_vars ipaddr hostname clientid vendorid broadcast reqopts
+
+ local opt dhcpopts
+ for opt in $reqopts; do
+ append dhcpopts "-O $opt"
+ done
+
+ [ "$broadcast" = 1 ] && broadcast="-B" || broadcast=
+ [ -n "$clientid" ] && clientid="-x 0x3d:${clientid//:/}" || clientid="-C"
+
+ proto_export "INTERFACE=$config"
+ proto_run_command "$config" udhcpc \
+ -p /var/run/udhcpc-$iface.pid \
+ -s /lib/netifd/dhcp.script \
+ -f -t 0 -i "$iface" \
+ ${ipaddr:+-r $ipaddr} \
+ ${hostname:+-H $hostname} \
+ ${vendorid:+-V $vendorid} \
+ $clientid $broadcast $dhcpopts
+}
+
+proto_dhcp_teardown() {
+ local interface="$1"
+ proto_kill_command "$interface"
+}
+
+add_protocol dhcp
+
diff --git a/package/network/config/netifd/files/lib/network/.svn/entries b/package/network/config/netifd/files/lib/network/.svn/entries
new file mode 100644
index 0000000..249cb3c
--- /dev/null
+++ b/package/network/config/netifd/files/lib/network/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/config/netifd/files/lib/network
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-06-11T13:25:58.910765Z
+32192
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+config.sh
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+12ee7e8a4599ad1948c9bf50e5bb0532
+2012-06-11T13:25:58.910765Z
+32192
+jow
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1607
+
diff --git a/package/network/config/netifd/files/lib/network/.svn/prop-base/config.sh.svn-base b/package/network/config/netifd/files/lib/network/.svn/prop-base/config.sh.svn-base
new file mode 100644
index 0000000..869ac71
--- /dev/null
+++ b/package/network/config/netifd/files/lib/network/.svn/prop-base/config.sh.svn-base
@@ -0,0 +1,5 @@
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/network/config/netifd/files/lib/network/.svn/text-base/config.sh.svn-base b/package/network/config/netifd/files/lib/network/.svn/text-base/config.sh.svn-base
new file mode 100644
index 0000000..9128971
--- /dev/null
+++ b/package/network/config/netifd/files/lib/network/.svn/text-base/config.sh.svn-base
@@ -0,0 +1,79 @@
+#!/bin/sh
+# Copyright (C) 2011 OpenWrt.org
+
+. /usr/share/libubox/jshn.sh
+
+find_config() {
+ local device="$1"
+ local ifdev ifl3dev ifobj
+ for ifobj in `ubus list network.interface.\*`; do
+ interface="${ifobj##network.interface.}"
+ (
+ json_load "$(ifstatus $interface)"
+ json_get_var ifdev device
+ json_get_var ifl3dev l3_device
+ if [[ "$device" = "$ifdev" ]] || [[ "$device" = "$ifl3dev" ]]; then
+ echo "$interface"
+ exit 0
+ else
+ exit 1
+ fi
+ ) && return
+ done
+}
+
+unbridge() {
+ return
+}
+
+ubus_call() {
+ json_init
+ local _data="$(ubus -S call "$1" "$2")"
+ [ -z "$_data" ] && return 1
+ json_load "$_data"
+ return 0
+}
+
+
+fixup_interface() {
+ local config="$1"
+ local ifname type device l3dev
+
+ config_get type "$config" type
+ config_get ifname "$config" ifname
+ config_get device "$config" device "$ifname"
+ [ "bridge" = "$type" ] && ifname="br-$config"
+ config_set "$config" device "$ifname"
+ ubus_call "network.interface.$config" status || return 0
+ json_get_var l3dev l3_device
+ [ -n "$l3dev" ] && ifname="$l3dev"
+ json_init
+ config_set "$config" ifname "$ifname"
+ config_set "$config" device "$device"
+}
+
+scan_interfaces() {
+ config_load network
+ config_foreach fixup_interface interface
+}
+
+prepare_interface_bridge() {
+ local config="$1"
+
+ [ -n "$config" ] || return 0
+ ubus call network.interface."$config" prepare
+}
+
+setup_interface() {
+ local iface="$1"
+ local config="$2"
+
+ [ -n "$config" ] || return 0
+ ubus call network.interface."$config" add_device "{ \"name\": \"$iface\" }"
+}
+
+do_sysctl() {
+ [ -n "$2" ] && \
+ sysctl -n -e -w "$1=$2" >/dev/null || \
+ sysctl -n -e "$1"
+}
diff --git a/package/network/config/netifd/files/lib/network/config.sh b/package/network/config/netifd/files/lib/network/config.sh
new file mode 100755
index 0000000..9128971
--- /dev/null
+++ b/package/network/config/netifd/files/lib/network/config.sh
@@ -0,0 +1,79 @@
+#!/bin/sh
+# Copyright (C) 2011 OpenWrt.org
+
+. /usr/share/libubox/jshn.sh
+
+find_config() {
+ local device="$1"
+ local ifdev ifl3dev ifobj
+ for ifobj in `ubus list network.interface.\*`; do
+ interface="${ifobj##network.interface.}"
+ (
+ json_load "$(ifstatus $interface)"
+ json_get_var ifdev device
+ json_get_var ifl3dev l3_device
+ if [[ "$device" = "$ifdev" ]] || [[ "$device" = "$ifl3dev" ]]; then
+ echo "$interface"
+ exit 0
+ else
+ exit 1
+ fi
+ ) && return
+ done
+}
+
+unbridge() {
+ return
+}
+
+ubus_call() {
+ json_init
+ local _data="$(ubus -S call "$1" "$2")"
+ [ -z "$_data" ] && return 1
+ json_load "$_data"
+ return 0
+}
+
+
+fixup_interface() {
+ local config="$1"
+ local ifname type device l3dev
+
+ config_get type "$config" type
+ config_get ifname "$config" ifname
+ config_get device "$config" device "$ifname"
+ [ "bridge" = "$type" ] && ifname="br-$config"
+ config_set "$config" device "$ifname"
+ ubus_call "network.interface.$config" status || return 0
+ json_get_var l3dev l3_device
+ [ -n "$l3dev" ] && ifname="$l3dev"
+ json_init
+ config_set "$config" ifname "$ifname"
+ config_set "$config" device "$device"
+}
+
+scan_interfaces() {
+ config_load network
+ config_foreach fixup_interface interface
+}
+
+prepare_interface_bridge() {
+ local config="$1"
+
+ [ -n "$config" ] || return 0
+ ubus call network.interface."$config" prepare
+}
+
+setup_interface() {
+ local iface="$1"
+ local config="$2"
+
+ [ -n "$config" ] || return 0
+ ubus call network.interface."$config" add_device "{ \"name\": \"$iface\" }"
+}
+
+do_sysctl() {
+ [ -n "$2" ] && \
+ sysctl -n -e -w "$1=$2" >/dev/null || \
+ sysctl -n -e "$1"
+}
diff --git a/package/network/config/netifd/files/sbin/.svn/entries b/package/network/config/netifd/files/sbin/.svn/entries
new file mode 100644
index 0000000..b8927cc
--- /dev/null
+++ b/package/network/config/netifd/files/sbin/.svn/entries
@@ -0,0 +1,164 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/config/netifd/files/sbin
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-29T14:40:04.101944Z
+35383
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+devstatus
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+97e78aed908f5b22479f2482492aee86
+2011-10-23T17:22:14.121936Z
+28545
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+200
+
+ifstatus
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+31a12bb1ab197fdc24f7d4a0288ab681
+2013-01-29T14:40:04.101944Z
+35383
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+273
+
+ifup
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+1d80dbe8b2dd7b5fb6b8de73a2881e85
+2013-01-29T14:40:04.101944Z
+35383
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1320
+
+ifdown
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+7da3b21f78698f9c8d1fd0ed92022a46
+2011-10-21T01:47:49.907205Z
+28499
+nbd
+has-props
+
+
+svn:special
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4
+
diff --git a/package/network/config/netifd/files/sbin/.svn/prop-base/devstatus.svn-base b/package/network/config/netifd/files/sbin/.svn/prop-base/devstatus.svn-base
new file mode 100644
index 0000000..869ac71
--- /dev/null
+++ b/package/network/config/netifd/files/sbin/.svn/prop-base/devstatus.svn-base
@@ -0,0 +1,5 @@
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/network/config/netifd/files/sbin/.svn/prop-base/ifdown.svn-base b/package/network/config/netifd/files/sbin/.svn/prop-base/ifdown.svn-base
new file mode 100644
index 0000000..d222469
--- /dev/null
+++ b/package/network/config/netifd/files/sbin/.svn/prop-base/ifdown.svn-base
@@ -0,0 +1,5 @@
+K 11
+svn:special
+V 1
+*
+END
diff --git a/package/network/config/netifd/files/sbin/.svn/prop-base/ifstatus.svn-base b/package/network/config/netifd/files/sbin/.svn/prop-base/ifstatus.svn-base
new file mode 100644
index 0000000..869ac71
--- /dev/null
+++ b/package/network/config/netifd/files/sbin/.svn/prop-base/ifstatus.svn-base
@@ -0,0 +1,5 @@
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/network/config/netifd/files/sbin/.svn/prop-base/ifup.svn-base b/package/network/config/netifd/files/sbin/.svn/prop-base/ifup.svn-base
new file mode 100644
index 0000000..869ac71
--- /dev/null
+++ b/package/network/config/netifd/files/sbin/.svn/prop-base/ifup.svn-base
@@ -0,0 +1,5 @@
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/network/config/netifd/files/sbin/.svn/text-base/devstatus.svn-base b/package/network/config/netifd/files/sbin/.svn/text-base/devstatus.svn-base
new file mode 100644
index 0000000..3c35b26
--- /dev/null
+++ b/package/network/config/netifd/files/sbin/.svn/text-base/devstatus.svn-base
@@ -0,0 +1,12 @@
+#!/bin/sh
+. /usr/share/libubox/jshn.sh
+DEVICE="$1"
+
+[ -n "$DEVICE" ] || {
+ echo "Usage: $0 <device>"
+ exit 1
+}
+
+json_init
+json_add_string name "$DEVICE"
+ubus call network.device status "$(json_dump)"
diff --git a/package/network/config/netifd/files/sbin/.svn/text-base/ifdown.svn-base b/package/network/config/netifd/files/sbin/.svn/text-base/ifdown.svn-base
new file mode 100644
index 0000000..a687b74
--- /dev/null
+++ b/package/network/config/netifd/files/sbin/.svn/text-base/ifdown.svn-base
@@ -0,0 +1 @@
+link ifup \ No newline at end of file
diff --git a/package/network/config/netifd/files/sbin/.svn/text-base/ifstatus.svn-base b/package/network/config/netifd/files/sbin/.svn/text-base/ifstatus.svn-base
new file mode 100644
index 0000000..8a951e6
--- /dev/null
+++ b/package/network/config/netifd/files/sbin/.svn/text-base/ifstatus.svn-base
@@ -0,0 +1,13 @@
+#!/bin/sh
+INTERFACE="$1"
+
+[ -n "$INTERFACE" ] || {
+ echo "Usage: $0 <interface>"
+ exit 1
+}
+
+ubus -S list "network.interface.$INTERFACE" >/dev/null || {
+ echo "Interface $INTERFACE not found"
+ exit 1
+}
+ubus call network.interface status "{ \"interface\" : \"$INTERFACE\" }"
diff --git a/package/network/config/netifd/files/sbin/.svn/text-base/ifup.svn-base b/package/network/config/netifd/files/sbin/.svn/text-base/ifup.svn-base
new file mode 100644
index 0000000..af3aaa8
--- /dev/null
+++ b/package/network/config/netifd/files/sbin/.svn/text-base/ifup.svn-base
@@ -0,0 +1,79 @@
+#!/bin/sh
+
+ifup_all=
+setup_wifi=
+
+if_call() {
+ local interface="$1"
+ for mode in $modes; do
+ ubus call network.interface $mode "{ \"interface\" : \"$interface\" }"
+ done
+}
+
+case "$0" in
+ *ifdown) modes=down;;
+ *ifup)
+ modes="down up"
+ setup_wifi=1
+ ;;
+ *) echo "Invalid command: $0";;
+esac
+
+while :; do
+ case "$1" in
+ -a)
+ ifup_all=1
+ shift
+ ;;
+ -w)
+ setup_wifi=
+ shift
+ ;;
+ *)
+ break
+ ;;
+ esac
+done
+
+[ "$modes" = "down up" ] && ubus call network reload
+if [ -n "$ifup_all" ]; then
+ for interface in `ubus -S list 'network.interface.*'`; do
+ if_call "${interface##network.interface.}"
+ done
+ [ -n "$setup_wifi" ] && /sbin/wifi up
+ exit
+else
+ ubus -S list "network.interface.$1" > /dev/null || {
+ echo "Interface $1 not found"
+ exit
+ }
+ if_call "$1"
+fi
+
+if [ -n "$setup_wifi" ] && grep -sq config /etc/config/wireless; then
+ . /lib/functions.sh
+
+ find_related_radios() {
+ local wdev wnet
+ config_get wdev "$1" device
+ config_get wnet "$1" network
+
+ if [ -n "$wdev" ]; then
+ for wnet in $wnet; do
+ if [ "$wnet" = "$network" ]; then
+ append radio_devs "$wdev" "$N"
+ fi
+ done
+ fi
+ }
+
+ local radio_devs
+ local network="$1"
+ config_load wireless
+ config_foreach find_related_radios wifi-iface
+
+ local dev
+ for dev in $(echo "$radio_devs" | sort -u); do
+ /sbin/wifi up "$dev"
+ done
+fi
diff --git a/package/network/config/netifd/files/sbin/devstatus b/package/network/config/netifd/files/sbin/devstatus
new file mode 100755
index 0000000..3c35b26
--- /dev/null
+++ b/package/network/config/netifd/files/sbin/devstatus
@@ -0,0 +1,12 @@
+#!/bin/sh
+. /usr/share/libubox/jshn.sh
+DEVICE="$1"
+
+[ -n "$DEVICE" ] || {
+ echo "Usage: $0 <device>"
+ exit 1
+}
+
+json_init
+json_add_string name "$DEVICE"
+ubus call network.device status "$(json_dump)"
diff --git a/package/network/config/netifd/files/sbin/ifdown b/package/network/config/netifd/files/sbin/ifdown
new file mode 120000
index 0000000..a0e5c17
--- /dev/null
+++ b/package/network/config/netifd/files/sbin/ifdown
@@ -0,0 +1 @@
+ifup \ No newline at end of file
diff --git a/package/network/config/netifd/files/sbin/ifstatus b/package/network/config/netifd/files/sbin/ifstatus
new file mode 100755
index 0000000..8a951e6
--- /dev/null
+++ b/package/network/config/netifd/files/sbin/ifstatus
@@ -0,0 +1,13 @@
+#!/bin/sh
+INTERFACE="$1"
+
+[ -n "$INTERFACE" ] || {
+ echo "Usage: $0 <interface>"
+ exit 1
+}
+
+ubus -S list "network.interface.$INTERFACE" >/dev/null || {
+ echo "Interface $INTERFACE not found"
+ exit 1
+}
+ubus call network.interface status "{ \"interface\" : \"$INTERFACE\" }"
diff --git a/package/network/config/netifd/files/sbin/ifup b/package/network/config/netifd/files/sbin/ifup
new file mode 100755
index 0000000..af3aaa8
--- /dev/null
+++ b/package/network/config/netifd/files/sbin/ifup
@@ -0,0 +1,79 @@
+#!/bin/sh
+
+ifup_all=
+setup_wifi=
+
+if_call() {
+ local interface="$1"
+ for mode in $modes; do
+ ubus call network.interface $mode "{ \"interface\" : \"$interface\" }"
+ done
+}
+
+case "$0" in
+ *ifdown) modes=down;;
+ *ifup)
+ modes="down up"
+ setup_wifi=1
+ ;;
+ *) echo "Invalid command: $0";;
+esac
+
+while :; do
+ case "$1" in
+ -a)
+ ifup_all=1
+ shift
+ ;;
+ -w)
+ setup_wifi=
+ shift
+ ;;
+ *)
+ break
+ ;;
+ esac
+done
+
+[ "$modes" = "down up" ] && ubus call network reload
+if [ -n "$ifup_all" ]; then
+ for interface in `ubus -S list 'network.interface.*'`; do
+ if_call "${interface##network.interface.}"
+ done
+ [ -n "$setup_wifi" ] && /sbin/wifi up
+ exit
+else
+ ubus -S list "network.interface.$1" > /dev/null || {
+ echo "Interface $1 not found"
+ exit
+ }
+ if_call "$1"
+fi
+
+if [ -n "$setup_wifi" ] && grep -sq config /etc/config/wireless; then
+ . /lib/functions.sh
+
+ find_related_radios() {
+ local wdev wnet
+ config_get wdev "$1" device
+ config_get wnet "$1" network
+
+ if [ -n "$wdev" ]; then
+ for wnet in $wnet; do
+ if [ "$wnet" = "$network" ]; then
+ append radio_devs "$wdev" "$N"
+ fi
+ done
+ fi
+ }
+
+ local radio_devs
+ local network="$1"
+ config_load wireless
+ config_foreach find_related_radios wifi-iface
+
+ local dev
+ for dev in $(echo "$radio_devs" | sort -u); do
+ /sbin/wifi up "$dev"
+ done
+fi
diff --git a/package/network/config/netifd/files/usr/.svn/entries b/package/network/config/netifd/files/usr/.svn/entries
new file mode 100644
index 0000000..1f099cf
--- /dev/null
+++ b/package/network/config/netifd/files/usr/.svn/entries
@@ -0,0 +1,31 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/config/netifd/files/usr
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-02-27T16:23:39.874148Z
+30741
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+share
+dir
+
diff --git a/package/network/config/netifd/files/usr/share/.svn/entries b/package/network/config/netifd/files/usr/share/.svn/entries
new file mode 100644
index 0000000..b436dab
--- /dev/null
+++ b/package/network/config/netifd/files/usr/share/.svn/entries
@@ -0,0 +1,31 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/config/netifd/files/usr/share
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-02-27T16:23:39.874148Z
+30741
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+udhcpc
+dir
+
diff --git a/package/network/config/netifd/files/usr/share/udhcpc/.svn/entries b/package/network/config/netifd/files/usr/share/udhcpc/.svn/entries
new file mode 100644
index 0000000..602e48d
--- /dev/null
+++ b/package/network/config/netifd/files/usr/share/udhcpc/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/config/netifd/files/usr/share/udhcpc
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-02-27T16:23:39.874148Z
+30741
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+default.script
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+021bccd0bcd3a0f5f6166fccc54ef30d
+2012-02-27T16:23:39.874148Z
+30741
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1346
+
diff --git a/package/network/config/netifd/files/usr/share/udhcpc/.svn/prop-base/default.script.svn-base b/package/network/config/netifd/files/usr/share/udhcpc/.svn/prop-base/default.script.svn-base
new file mode 100644
index 0000000..869ac71
--- /dev/null
+++ b/package/network/config/netifd/files/usr/share/udhcpc/.svn/prop-base/default.script.svn-base
@@ -0,0 +1,5 @@
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/network/config/netifd/files/usr/share/udhcpc/.svn/text-base/default.script.svn-base b/package/network/config/netifd/files/usr/share/udhcpc/.svn/text-base/default.script.svn-base
new file mode 100644
index 0000000..ac765a6
--- /dev/null
+++ b/package/network/config/netifd/files/usr/share/udhcpc/.svn/text-base/default.script.svn-base
@@ -0,0 +1,57 @@
+#!/bin/sh
+[ -z "$1" ] && echo "Error: should be run by udhcpc" && exit 1
+
+set_classless_routes() {
+ local max=128
+ local type
+ while [ -n "$1" -a -n "$2" -a $max -gt 0 ]; do
+ [ ${1##*/} -eq 32 ] && type=host || type=net
+ echo "udhcpc: adding route for $type $1 via $2"
+ route add -$type "$1" gw "$2" dev "$interface"
+ max=$(($max-1))
+ shift 2
+ done
+}
+
+setup_interface() {
+ echo "udhcpc: ifconfig $interface $ip netmask ${subnet:-255.255.255.0} broadcast ${broadcast:-+}"
+ ifconfig $interface $ip netmask ${subnet:-255.255.255.0} broadcast ${broadcast:-+}
+
+ [ -n "$router" ] && [ "$router" != "0.0.0.0" ] && [ "$router" != "255.255.255.255" ] && {
+ echo "udhcpc: setting default routers: $router"
+
+ local valid_gw=""
+ for i in $router ; do
+ route add default gw $i dev $interface
+ valid_gw="${valid_gw:+$valid_gw|}$i"
+ done
+
+ eval $(route -n | awk '
+ /^0.0.0.0\W{9}('$valid_gw')\W/ {next}
+ /^0.0.0.0/ {print "route del -net "$1" gw "$2";"}
+ ')
+ }
+
+ # CIDR STATIC ROUTES (rfc3442)
+ [ -n "$staticroutes" ] && set_classless_routes $staticroutes
+ [ -n "$msstaticroutes" ] && set_classless_routes $msstaticroutes
+}
+
+
+applied=
+case "$1" in
+ deconfig)
+ ifconfig "$interface" 0.0.0.0
+ ;;
+ renew)
+ setup_interface update
+ ;;
+ bound)
+ setup_interface ifup
+ ;;
+esac
+
+# user rules
+[ -f /etc/udhcpc.user ] && . /etc/udhcpc.user
+
+exit 0
diff --git a/package/network/config/netifd/files/usr/share/udhcpc/default.script b/package/network/config/netifd/files/usr/share/udhcpc/default.script
new file mode 100755
index 0000000..ac765a6
--- /dev/null
+++ b/package/network/config/netifd/files/usr/share/udhcpc/default.script
@@ -0,0 +1,57 @@
+#!/bin/sh
+[ -z "$1" ] && echo "Error: should be run by udhcpc" && exit 1
+
+set_classless_routes() {
+ local max=128
+ local type
+ while [ -n "$1" -a -n "$2" -a $max -gt 0 ]; do
+ [ ${1##*/} -eq 32 ] && type=host || type=net
+ echo "udhcpc: adding route for $type $1 via $2"
+ route add -$type "$1" gw "$2" dev "$interface"
+ max=$(($max-1))
+ shift 2
+ done
+}
+
+setup_interface() {
+ echo "udhcpc: ifconfig $interface $ip netmask ${subnet:-255.255.255.0} broadcast ${broadcast:-+}"
+ ifconfig $interface $ip netmask ${subnet:-255.255.255.0} broadcast ${broadcast:-+}
+
+ [ -n "$router" ] && [ "$router" != "0.0.0.0" ] && [ "$router" != "255.255.255.255" ] && {
+ echo "udhcpc: setting default routers: $router"
+
+ local valid_gw=""
+ for i in $router ; do
+ route add default gw $i dev $interface
+ valid_gw="${valid_gw:+$valid_gw|}$i"
+ done
+
+ eval $(route -n | awk '
+ /^0.0.0.0\W{9}('$valid_gw')\W/ {next}
+ /^0.0.0.0/ {print "route del -net "$1" gw "$2";"}
+ ')
+ }
+
+ # CIDR STATIC ROUTES (rfc3442)
+ [ -n "$staticroutes" ] && set_classless_routes $staticroutes
+ [ -n "$msstaticroutes" ] && set_classless_routes $msstaticroutes
+}
+
+
+applied=
+case "$1" in
+ deconfig)
+ ifconfig "$interface" 0.0.0.0
+ ;;
+ renew)
+ setup_interface update
+ ;;
+ bound)
+ setup_interface ifup
+ ;;
+esac
+
+# user rules
+[ -f /etc/udhcpc.user ] && . /etc/udhcpc.user
+
+exit 0
diff --git a/package/network/config/netifd/patches/.svn/entries b/package/network/config/netifd/patches/.svn/entries
new file mode 100644
index 0000000..bddbcdf
--- /dev/null
+++ b/package/network/config/netifd/patches/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/config/netifd/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-11-23T20:02:10.520862Z
+34310
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+001-musl_af_inet_include.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+ef2db5f9cbc33fb642df085540830c2b
+2012-11-23T20:02:10.520862Z
+34310
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+369
+
diff --git a/package/network/config/netifd/patches/.svn/text-base/001-musl_af_inet_include.patch.svn-base b/package/network/config/netifd/patches/.svn/text-base/001-musl_af_inet_include.patch.svn-base
new file mode 100644
index 0000000..510ee05
--- /dev/null
+++ b/package/network/config/netifd/patches/.svn/text-base/001-musl_af_inet_include.patch.svn-base
@@ -0,0 +1,11 @@
+diff -urN netifd-2012-10-29/utils.c netifd-2012-10-29.new/utils.c
+--- netifd-2012-10-29/utils.c 2012-11-23 17:15:39.000000000 +0100
++++ netifd-2012-10-29.new/utils.c 2012-11-23 17:16:53.409244361 +0100
+@@ -17,6 +17,7 @@
+
+ #include <arpa/inet.h>
+ #include <netinet/in.h>
++#include <sys/socket.h>
+
+ void
+ __vlist_simple_init(struct vlist_simple_tree *tree, int offset)
diff --git a/package/network/config/netifd/patches/001-musl_af_inet_include.patch b/package/network/config/netifd/patches/001-musl_af_inet_include.patch
new file mode 100644
index 0000000..510ee05
--- /dev/null
+++ b/package/network/config/netifd/patches/001-musl_af_inet_include.patch
@@ -0,0 +1,11 @@
+diff -urN netifd-2012-10-29/utils.c netifd-2012-10-29.new/utils.c
+--- netifd-2012-10-29/utils.c 2012-11-23 17:15:39.000000000 +0100
++++ netifd-2012-10-29.new/utils.c 2012-11-23 17:16:53.409244361 +0100
+@@ -17,6 +17,7 @@
+
+ #include <arpa/inet.h>
+ #include <netinet/in.h>
++#include <sys/socket.h>
+
+ void
+ __vlist_simple_init(struct vlist_simple_tree *tree, int offset)
diff --git a/package/network/config/qos-scripts/.svn/entries b/package/network/config/qos-scripts/.svn/entries
new file mode 100644
index 0000000..d29257b
--- /dev/null
+++ b/package/network/config/qos-scripts/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/config/qos-scripts
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-10T12:49:37.020840Z
+33693
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+files
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+0a6610a4956deecf01760c0452296a6d
+2012-10-10T12:49:37.020840Z
+33693
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1090
+
diff --git a/package/network/config/qos-scripts/.svn/prop-base/Makefile.svn-base b/package/network/config/qos-scripts/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..8e522ae
--- /dev/null
+++ b/package/network/config/qos-scripts/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:copyright
+V 30
+Copyright (C) 2006 OpenWrt.org
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/config/qos-scripts/.svn/text-base/Makefile.svn-base b/package/network/config/qos-scripts/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..a6690a1
--- /dev/null
+++ b/package/network/config/qos-scripts/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,52 @@
+#
+# Copyright (C) 2006-2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=qos-scripts
+PKG_VERSION:=1.2.1
+PKG_RELEASE:=6
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+
+PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/qos-scripts
+ SECTION:=utils
+ CATEGORY:=Base system
+ DEPENDS:=+tc +kmod-sched-core +kmod-sched-connmark +kmod-ifb +iptables +iptables-mod-filter +iptables-mod-ipopt +iptables-mod-conntrack-extra
+ TITLE:=QoS scripts
+ PKGARCH:=all
+endef
+
+define Package/qos-scripts/description
+ A set of scripts that abstract QoS configuration into a simple
+ configuration file supporting stanzas that specify any number of QoS
+ entries.
+endef
+
+define Package/qos-scripts/conffiles
+/etc/config/qos
+endef
+
+define Build/Prepare
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+endef
+
+define Package/qos-scripts/install
+ $(INSTALL_DIR) $(1)
+ $(CP) ./files/* $(1)/
+endef
+
+$(eval $(call BuildPackage,qos-scripts))
diff --git a/package/network/config/qos-scripts/Makefile b/package/network/config/qos-scripts/Makefile
new file mode 100644
index 0000000..a6690a1
--- /dev/null
+++ b/package/network/config/qos-scripts/Makefile
@@ -0,0 +1,52 @@
+#
+# Copyright (C) 2006-2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=qos-scripts
+PKG_VERSION:=1.2.1
+PKG_RELEASE:=6
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+
+PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/qos-scripts
+ SECTION:=utils
+ CATEGORY:=Base system
+ DEPENDS:=+tc +kmod-sched-core +kmod-sched-connmark +kmod-ifb +iptables +iptables-mod-filter +iptables-mod-ipopt +iptables-mod-conntrack-extra
+ TITLE:=QoS scripts
+ PKGARCH:=all
+endef
+
+define Package/qos-scripts/description
+ A set of scripts that abstract QoS configuration into a simple
+ configuration file supporting stanzas that specify any number of QoS
+ entries.
+endef
+
+define Package/qos-scripts/conffiles
+/etc/config/qos
+endef
+
+define Build/Prepare
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+endef
+
+define Package/qos-scripts/install
+ $(INSTALL_DIR) $(1)
+ $(CP) ./files/* $(1)/
+endef
+
+$(eval $(call BuildPackage,qos-scripts))
diff --git a/package/network/config/qos-scripts/files/.svn/entries b/package/network/config/qos-scripts/files/.svn/entries
new file mode 100644
index 0000000..1ea9077
--- /dev/null
+++ b/package/network/config/qos-scripts/files/.svn/entries
@@ -0,0 +1,34 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/config/qos-scripts/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-06-05T16:04:23.055438Z
+32062
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+usr
+dir
+
+etc
+dir
+
diff --git a/package/network/config/qos-scripts/files/etc/.svn/entries b/package/network/config/qos-scripts/files/etc/.svn/entries
new file mode 100644
index 0000000..2a1a6ef
--- /dev/null
+++ b/package/network/config/qos-scripts/files/etc/.svn/entries
@@ -0,0 +1,37 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/config/qos-scripts/files/etc
+svn://svn.openwrt.org/openwrt
+
+
+
+2011-07-29T16:32:55.150774Z
+27832
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+hotplug.d
+dir
+
+config
+dir
+
+init.d
+dir
+
diff --git a/package/network/config/qos-scripts/files/etc/config/.svn/entries b/package/network/config/qos-scripts/files/etc/config/.svn/entries
new file mode 100644
index 0000000..3d715dd
--- /dev/null
+++ b/package/network/config/qos-scripts/files/etc/config/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/config/qos-scripts/files/etc/config
+svn://svn.openwrt.org/openwrt
+
+
+
+2011-07-29T16:32:55.150774Z
+27832
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+qos
+file
+
+
+
+
+2013-03-17T12:13:20.000000Z
+c67dad39ee194bbdb1a2b7952a436617
+2011-07-29T16:32:55.150774Z
+27832
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1773
+
diff --git a/package/network/config/qos-scripts/files/etc/config/.svn/prop-base/qos.svn-base b/package/network/config/qos-scripts/files/etc/config/.svn/prop-base/qos.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/network/config/qos-scripts/files/etc/config/.svn/prop-base/qos.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/config/qos-scripts/files/etc/config/.svn/text-base/qos.svn-base b/package/network/config/qos-scripts/files/etc/config/.svn/text-base/qos.svn-base
new file mode 100644
index 0000000..8faff18
--- /dev/null
+++ b/package/network/config/qos-scripts/files/etc/config/.svn/text-base/qos.svn-base
@@ -0,0 +1,79 @@
+# QoS configuration for OpenWrt
+
+# INTERFACES:
+config interface wan
+ option classgroup "Default"
+ option enabled 0
+ option upload 128
+ option download 1024
+
+# RULES:
+config classify
+ option target "Priority"
+ option ports "22,53"
+config classify
+ option target "Normal"
+ option proto "tcp"
+ option ports "20,21,25,80,110,443,993,995"
+config classify
+ option target "Express"
+ option ports "5190"
+config default
+ option target "Express"
+ option proto "udp"
+ option pktsize "-500"
+config reclassify
+ option target "Priority"
+ option proto "icmp"
+config default
+ option target "Bulk"
+ option portrange "1024-65535"
+config reclassify
+ option target "Priority"
+ option proto "tcp"
+ option pktsize "-128"
+ option mark "!Bulk"
+ option tcpflags "SYN"
+config reclassify
+ option target "Priority"
+ option proto "tcp"
+ option pktsize "-128"
+ option mark "!Bulk"
+ option tcpflags "ACK"
+
+
+# Don't change the stuff below unless you
+# really know what it means :)
+
+config classgroup "Default"
+ option classes "Priority Express Normal Bulk"
+ option default "Normal"
+
+
+config class "Priority"
+ option packetsize 400
+ option maxsize 400
+ option avgrate 10
+ option priority 20
+config class "Priority_down"
+ option packetsize 1000
+ option avgrate 10
+
+
+config class "Express"
+ option packetsize 1000
+ option maxsize 800
+ option avgrate 50
+ option priority 10
+
+config class "Normal"
+ option packetsize 1500
+ option packetdelay 100
+ option avgrate 10
+ option priority 5
+config class "Normal_down"
+ option avgrate 20
+
+config class "Bulk"
+ option avgrate 1
+ option packetdelay 200
diff --git a/package/network/config/qos-scripts/files/etc/config/qos b/package/network/config/qos-scripts/files/etc/config/qos
new file mode 100644
index 0000000..8faff18
--- /dev/null
+++ b/package/network/config/qos-scripts/files/etc/config/qos
@@ -0,0 +1,79 @@
+# QoS configuration for OpenWrt
+
+# INTERFACES:
+config interface wan
+ option classgroup "Default"
+ option enabled 0
+ option upload 128
+ option download 1024
+
+# RULES:
+config classify
+ option target "Priority"
+ option ports "22,53"
+config classify
+ option target "Normal"
+ option proto "tcp"
+ option ports "20,21,25,80,110,443,993,995"
+config classify
+ option target "Express"
+ option ports "5190"
+config default
+ option target "Express"
+ option proto "udp"
+ option pktsize "-500"
+config reclassify
+ option target "Priority"
+ option proto "icmp"
+config default
+ option target "Bulk"
+ option portrange "1024-65535"
+config reclassify
+ option target "Priority"
+ option proto "tcp"
+ option pktsize "-128"
+ option mark "!Bulk"
+ option tcpflags "SYN"
+config reclassify
+ option target "Priority"
+ option proto "tcp"
+ option pktsize "-128"
+ option mark "!Bulk"
+ option tcpflags "ACK"
+
+
+# Don't change the stuff below unless you
+# really know what it means :)
+
+config classgroup "Default"
+ option classes "Priority Express Normal Bulk"
+ option default "Normal"
+
+
+config class "Priority"
+ option packetsize 400
+ option maxsize 400
+ option avgrate 10
+ option priority 20
+config class "Priority_down"
+ option packetsize 1000
+ option avgrate 10
+
+
+config class "Express"
+ option packetsize 1000
+ option maxsize 800
+ option avgrate 50
+ option priority 10
+
+config class "Normal"
+ option packetsize 1500
+ option packetdelay 100
+ option avgrate 10
+ option priority 5
+config class "Normal_down"
+ option avgrate 20
+
+config class "Bulk"
+ option avgrate 1
+ option packetdelay 200
diff --git a/package/network/config/qos-scripts/files/etc/hotplug.d/.svn/entries b/package/network/config/qos-scripts/files/etc/hotplug.d/.svn/entries
new file mode 100644
index 0000000..06c8595
--- /dev/null
+++ b/package/network/config/qos-scripts/files/etc/hotplug.d/.svn/entries
@@ -0,0 +1,31 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/config/qos-scripts/files/etc/hotplug.d
+svn://svn.openwrt.org/openwrt
+
+
+
+2007-09-27T14:06:07.234823Z
+9046
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+iface
+dir
+
diff --git a/package/network/config/qos-scripts/files/etc/hotplug.d/iface/.svn/entries b/package/network/config/qos-scripts/files/etc/hotplug.d/iface/.svn/entries
new file mode 100644
index 0000000..97d17a2
--- /dev/null
+++ b/package/network/config/qos-scripts/files/etc/hotplug.d/iface/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/config/qos-scripts/files/etc/hotplug.d/iface
+svn://svn.openwrt.org/openwrt
+
+
+
+2007-09-27T14:06:07.234823Z
+9046
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+10-qos
+file
+
+
+
+
+2013-03-17T12:13:20.000000Z
+19424796e16c97fce7a4dd2b01abf796
+2007-09-27T14:06:07.234823Z
+9046
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+114
+
diff --git a/package/network/config/qos-scripts/files/etc/hotplug.d/iface/.svn/prop-base/10-qos.svn-base b/package/network/config/qos-scripts/files/etc/hotplug.d/iface/.svn/prop-base/10-qos.svn-base
new file mode 100644
index 0000000..03b5bfa
--- /dev/null
+++ b/package/network/config/qos-scripts/files/etc/hotplug.d/iface/.svn/prop-base/10-qos.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:eol-style
+V 6
+native
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/network/config/qos-scripts/files/etc/hotplug.d/iface/.svn/text-base/10-qos.svn-base b/package/network/config/qos-scripts/files/etc/hotplug.d/iface/.svn/text-base/10-qos.svn-base
new file mode 100644
index 0000000..0ced29a
--- /dev/null
+++ b/package/network/config/qos-scripts/files/etc/hotplug.d/iface/.svn/text-base/10-qos.svn-base
@@ -0,0 +1,2 @@
+#!/bin/sh
+[ "$ACTION" = ifup ] && /etc/init.d/qos enabled && /usr/lib/qos/generate.sh interface "$INTERFACE" | sh
diff --git a/package/network/config/qos-scripts/files/etc/hotplug.d/iface/10-qos b/package/network/config/qos-scripts/files/etc/hotplug.d/iface/10-qos
new file mode 100755
index 0000000..0ced29a
--- /dev/null
+++ b/package/network/config/qos-scripts/files/etc/hotplug.d/iface/10-qos
@@ -0,0 +1,2 @@
+#!/bin/sh
+[ "$ACTION" = ifup ] && /etc/init.d/qos enabled && /usr/lib/qos/generate.sh interface "$INTERFACE" | sh
diff --git a/package/network/config/qos-scripts/files/etc/init.d/.svn/entries b/package/network/config/qos-scripts/files/etc/init.d/.svn/entries
new file mode 100644
index 0000000..d7af9db
--- /dev/null
+++ b/package/network/config/qos-scripts/files/etc/init.d/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/config/qos-scripts/files/etc/init.d
+svn://svn.openwrt.org/openwrt
+
+
+
+2007-04-06T16:59:56.568018Z
+6875
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+qos
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+da7c53be1fa334d195f786760d1dac3f
+2007-04-06T16:59:56.568018Z
+6875
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+166
+
diff --git a/package/network/config/qos-scripts/files/etc/init.d/.svn/prop-base/qos.svn-base b/package/network/config/qos-scripts/files/etc/init.d/.svn/prop-base/qos.svn-base
new file mode 100644
index 0000000..03b5bfa
--- /dev/null
+++ b/package/network/config/qos-scripts/files/etc/init.d/.svn/prop-base/qos.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:eol-style
+V 6
+native
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/network/config/qos-scripts/files/etc/init.d/.svn/text-base/qos.svn-base b/package/network/config/qos-scripts/files/etc/init.d/.svn/text-base/qos.svn-base
new file mode 100644
index 0000000..3f71115
--- /dev/null
+++ b/package/network/config/qos-scripts/files/etc/init.d/.svn/text-base/qos.svn-base
@@ -0,0 +1,16 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2006 OpenWrt.org
+
+START=50
+
+boot() {
+ /usr/lib/qos/generate.sh firewall | sh
+}
+
+start() {
+ qos-start
+}
+
+stop() {
+ qos-stop
+}
diff --git a/package/network/config/qos-scripts/files/etc/init.d/qos b/package/network/config/qos-scripts/files/etc/init.d/qos
new file mode 100755
index 0000000..3f71115
--- /dev/null
+++ b/package/network/config/qos-scripts/files/etc/init.d/qos
@@ -0,0 +1,16 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2006 OpenWrt.org
+
+START=50
+
+boot() {
+ /usr/lib/qos/generate.sh firewall | sh
+}
+
+start() {
+ qos-start
+}
+
+stop() {
+ qos-stop
+}
diff --git a/package/network/config/qos-scripts/files/usr/.svn/entries b/package/network/config/qos-scripts/files/usr/.svn/entries
new file mode 100644
index 0000000..c2f08c5
--- /dev/null
+++ b/package/network/config/qos-scripts/files/usr/.svn/entries
@@ -0,0 +1,34 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/config/qos-scripts/files/usr
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-06-05T16:04:23.055438Z
+32062
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+lib
+dir
+
+bin
+dir
+
diff --git a/package/network/config/qos-scripts/files/usr/bin/.svn/entries b/package/network/config/qos-scripts/files/usr/bin/.svn/entries
new file mode 100644
index 0000000..fa60ae7
--- /dev/null
+++ b/package/network/config/qos-scripts/files/usr/bin/.svn/entries
@@ -0,0 +1,130 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/config/qos-scripts/files/usr/bin
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-06-05T16:04:23.055438Z
+32062
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+qos-stop
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+d0c4c982503c87ad4984bccf1f8396ec
+2011-10-27T12:39:19.714355Z
+28623
+jow
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+224
+
+qos-stat
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+8698b43c858ec4bc03de0270308c4c79
+2012-06-05T16:04:23.055438Z
+32062
+jow
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1568
+
+qos-start
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+9418edd146e30aead985459b915b568e
+2007-04-06T16:59:56.568018Z
+6875
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+55
+
diff --git a/package/network/config/qos-scripts/files/usr/bin/.svn/prop-base/qos-start.svn-base b/package/network/config/qos-scripts/files/usr/bin/.svn/prop-base/qos-start.svn-base
new file mode 100644
index 0000000..03b5bfa
--- /dev/null
+++ b/package/network/config/qos-scripts/files/usr/bin/.svn/prop-base/qos-start.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:eol-style
+V 6
+native
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/network/config/qos-scripts/files/usr/bin/.svn/prop-base/qos-stat.svn-base b/package/network/config/qos-scripts/files/usr/bin/.svn/prop-base/qos-stat.svn-base
new file mode 100644
index 0000000..03b5bfa
--- /dev/null
+++ b/package/network/config/qos-scripts/files/usr/bin/.svn/prop-base/qos-stat.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:eol-style
+V 6
+native
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/network/config/qos-scripts/files/usr/bin/.svn/prop-base/qos-stop.svn-base b/package/network/config/qos-scripts/files/usr/bin/.svn/prop-base/qos-stop.svn-base
new file mode 100644
index 0000000..03b5bfa
--- /dev/null
+++ b/package/network/config/qos-scripts/files/usr/bin/.svn/prop-base/qos-stop.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:eol-style
+V 6
+native
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/network/config/qos-scripts/files/usr/bin/.svn/text-base/qos-start.svn-base b/package/network/config/qos-scripts/files/usr/bin/.svn/text-base/qos-start.svn-base
new file mode 100644
index 0000000..261ffb4
--- /dev/null
+++ b/package/network/config/qos-scripts/files/usr/bin/.svn/text-base/qos-start.svn-base
@@ -0,0 +1,4 @@
+#!/bin/sh
+qos-stop
+/usr/lib/qos/generate.sh all | sh
+
diff --git a/package/network/config/qos-scripts/files/usr/bin/.svn/text-base/qos-stat.svn-base b/package/network/config/qos-scripts/files/usr/bin/.svn/text-base/qos-stat.svn-base
new file mode 100644
index 0000000..78d1638
--- /dev/null
+++ b/package/network/config/qos-scripts/files/usr/bin/.svn/text-base/qos-stat.svn-base
@@ -0,0 +1,67 @@
+#!/bin/sh
+# Copyright (C) 2011 OpenWrt.org
+
+. /lib/functions.sh
+
+include /lib/network
+
+get_ifname() {
+ local interface="$1"
+ local cfgt
+
+ scan_interfaces
+ config_get cfgt "$interface" TYPE
+ [ "$cfgt" == "interface" ] && config_get "$interface" ifname
+}
+
+config_cb() {
+ config_get TYPE "$CONFIG_SECTION" TYPE
+ [ "interface" == "$TYPE" ] && {
+ config_get device "$CONFIG_SECTION" ifname
+ [ -z "$device" ] && device="$(get_ifname ${CONFIG_SECTION})"
+ config_set "$CONFIG_SECTION" device "$device"
+ }
+}
+
+config_load qos
+
+print_comments() {
+ echo ''
+ echo '# Interface: '"$1"
+ echo '# Direction: '"$2"
+ echo '# Stats: '"$3"
+ echo ''
+}
+
+get_device() {
+ ( config_load network; scan_interfaces; config_get "$1" ifname )
+}
+
+interface_stats() {
+ local interface="$1"
+ local device
+
+ device="$(get_device "$interface")"
+ [ -z "$device" ] && config_get device "$interface" device
+ config_get_bool enabled "$interface" enabled 1
+ [ -z "$device" -o 1 -ne "$enabled" ] && {
+ return 1
+ }
+ config_get_bool halfduplex "$interface" halfduplex 0
+
+ if [ 1 -ne "$halfduplex" ]; then
+ unset halfduplex
+ print_comments "$interface" "Egress" "Start"
+ tc -s class show dev "$device"
+ print_comments "$interface" "Egress" "End"
+ id="root"
+ else
+ id=""
+ fi
+
+ print_comments "$interface" "Ingress${halfduplex:+/Egress}" "Start"
+ tc -s class show dev "$(tc filter show dev $device $id | grep mirred | sed -e 's,.*\(ifb.*\)).*,\1,')"
+ print_comments "$interface" "Ingress${halfduplex:+/Egress}" "End"
+}
+
+[ -z "$1" ] && config_foreach interface_stats interface || interface_stats "$1"
diff --git a/package/network/config/qos-scripts/files/usr/bin/.svn/text-base/qos-stop.svn-base b/package/network/config/qos-scripts/files/usr/bin/.svn/text-base/qos-stop.svn-base
new file mode 100644
index 0000000..7f654d8
--- /dev/null
+++ b/package/network/config/qos-scripts/files/usr/bin/.svn/text-base/qos-stop.svn-base
@@ -0,0 +1,6 @@
+#!/bin/sh
+for iface in $(tc qdisc show | grep -E '(hfsc|ingress)' | awk '{print $5}'); do
+ tc qdisc del dev "$iface" ingress 2>&- >&-
+ tc qdisc del dev "$iface" root 2>&- >&-
+done
+/usr/lib/qos/generate.sh firewall stop | sh
diff --git a/package/network/config/qos-scripts/files/usr/bin/qos-start b/package/network/config/qos-scripts/files/usr/bin/qos-start
new file mode 100755
index 0000000..261ffb4
--- /dev/null
+++ b/package/network/config/qos-scripts/files/usr/bin/qos-start
@@ -0,0 +1,4 @@
+#!/bin/sh
+qos-stop
+/usr/lib/qos/generate.sh all | sh
+
diff --git a/package/network/config/qos-scripts/files/usr/bin/qos-stat b/package/network/config/qos-scripts/files/usr/bin/qos-stat
new file mode 100755
index 0000000..78d1638
--- /dev/null
+++ b/package/network/config/qos-scripts/files/usr/bin/qos-stat
@@ -0,0 +1,67 @@
+#!/bin/sh
+# Copyright (C) 2011 OpenWrt.org
+
+. /lib/functions.sh
+
+include /lib/network
+
+get_ifname() {
+ local interface="$1"
+ local cfgt
+
+ scan_interfaces
+ config_get cfgt "$interface" TYPE
+ [ "$cfgt" == "interface" ] && config_get "$interface" ifname
+}
+
+config_cb() {
+ config_get TYPE "$CONFIG_SECTION" TYPE
+ [ "interface" == "$TYPE" ] && {
+ config_get device "$CONFIG_SECTION" ifname
+ [ -z "$device" ] && device="$(get_ifname ${CONFIG_SECTION})"
+ config_set "$CONFIG_SECTION" device "$device"
+ }
+}
+
+config_load qos
+
+print_comments() {
+ echo ''
+ echo '# Interface: '"$1"
+ echo '# Direction: '"$2"
+ echo '# Stats: '"$3"
+ echo ''
+}
+
+get_device() {
+ ( config_load network; scan_interfaces; config_get "$1" ifname )
+}
+
+interface_stats() {
+ local interface="$1"
+ local device
+
+ device="$(get_device "$interface")"
+ [ -z "$device" ] && config_get device "$interface" device
+ config_get_bool enabled "$interface" enabled 1
+ [ -z "$device" -o 1 -ne "$enabled" ] && {
+ return 1
+ }
+ config_get_bool halfduplex "$interface" halfduplex 0
+
+ if [ 1 -ne "$halfduplex" ]; then
+ unset halfduplex
+ print_comments "$interface" "Egress" "Start"
+ tc -s class show dev "$device"
+ print_comments "$interface" "Egress" "End"
+ id="root"
+ else
+ id=""
+ fi
+
+ print_comments "$interface" "Ingress${halfduplex:+/Egress}" "Start"
+ tc -s class show dev "$(tc filter show dev $device $id | grep mirred | sed -e 's,.*\(ifb.*\)).*,\1,')"
+ print_comments "$interface" "Ingress${halfduplex:+/Egress}" "End"
+}
+
+[ -z "$1" ] && config_foreach interface_stats interface || interface_stats "$1"
diff --git a/package/network/config/qos-scripts/files/usr/bin/qos-stop b/package/network/config/qos-scripts/files/usr/bin/qos-stop
new file mode 100755
index 0000000..7f654d8
--- /dev/null
+++ b/package/network/config/qos-scripts/files/usr/bin/qos-stop
@@ -0,0 +1,6 @@
+#!/bin/sh
+for iface in $(tc qdisc show | grep -E '(hfsc|ingress)' | awk '{print $5}'); do
+ tc qdisc del dev "$iface" ingress 2>&- >&-
+ tc qdisc del dev "$iface" root 2>&- >&-
+done
+/usr/lib/qos/generate.sh firewall stop | sh
diff --git a/package/network/config/qos-scripts/files/usr/lib/.svn/entries b/package/network/config/qos-scripts/files/usr/lib/.svn/entries
new file mode 100644
index 0000000..5b8d750
--- /dev/null
+++ b/package/network/config/qos-scripts/files/usr/lib/.svn/entries
@@ -0,0 +1,31 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/config/qos-scripts/files/usr/lib
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-06-05T16:04:23.055438Z
+32062
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+qos
+dir
+
diff --git a/package/network/config/qos-scripts/files/usr/lib/qos/.svn/entries b/package/network/config/qos-scripts/files/usr/lib/qos/.svn/entries
new file mode 100644
index 0000000..3fb7b83
--- /dev/null
+++ b/package/network/config/qos-scripts/files/usr/lib/qos/.svn/entries
@@ -0,0 +1,96 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/config/qos-scripts/files/usr/lib/qos
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-06-05T16:04:23.055438Z
+32062
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+tcrules.awk
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+82d952dc6351afe17daf1a4b70d3d283
+2012-05-16T15:23:16.119139Z
+31759
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2081
+
+generate.sh
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+dc4f29f95d07a2ad931ae0d5d4c8b7f9
+2012-06-05T16:04:23.055438Z
+32062
+jow
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+13106
+
diff --git a/package/network/config/qos-scripts/files/usr/lib/qos/.svn/prop-base/generate.sh.svn-base b/package/network/config/qos-scripts/files/usr/lib/qos/.svn/prop-base/generate.sh.svn-base
new file mode 100644
index 0000000..03b5bfa
--- /dev/null
+++ b/package/network/config/qos-scripts/files/usr/lib/qos/.svn/prop-base/generate.sh.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:eol-style
+V 6
+native
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/network/config/qos-scripts/files/usr/lib/qos/.svn/text-base/generate.sh.svn-base b/package/network/config/qos-scripts/files/usr/lib/qos/.svn/text-base/generate.sh.svn-base
new file mode 100644
index 0000000..440b43f
--- /dev/null
+++ b/package/network/config/qos-scripts/files/usr/lib/qos/.svn/text-base/generate.sh.svn-base
@@ -0,0 +1,497 @@
+#!/bin/sh
+[ -e /lib/functions.sh ] && . /lib/functions.sh || . ./functions.sh
+[ -x /sbin/modprobe ] && {
+ insmod="modprobe"
+ rmmod="$insmod -r"
+} || {
+ insmod="insmod"
+ rmmod="rmmod"
+}
+
+add_insmod() {
+ eval "export isset=\${insmod_$1}"
+ case "$isset" in
+ 1) ;;
+ *) {
+ [ "$2" ] && append INSMOD "$rmmod $1 >&- 2>&-" "$N"
+ append INSMOD "$insmod $* >&- 2>&-" "$N"; export insmod_$1=1
+ };;
+ esac
+}
+
+[ -e /etc/config/network ] && {
+ # only try to parse network config on openwrt
+
+ find_ifname() {(
+ reset_cb
+ include /lib/network
+ scan_interfaces
+ config_get "$1" ifname
+ )}
+} || {
+ find_ifname() {
+ echo "Interface not found."
+ exit 1
+ }
+}
+
+parse_matching_rule() {
+ local var="$1"
+ local section="$2"
+ local options="$3"
+ local prefix="$4"
+ local suffix="$5"
+ local proto="$6"
+ local mport=""
+ local ports=""
+
+ append "$var" "$prefix" "$N"
+ for option in $options; do
+ case "$option" in
+ proto) config_get value "$section" proto; proto="${proto:-$value}";;
+ esac
+ done
+ config_get type "$section" TYPE
+ case "$type" in
+ classify) unset pkt; append "$var" "-m mark --mark 0/0xff";;
+ default) pkt=1; append "$var" "-m mark --mark 0/0xff";;
+ reclassify) pkt=1;;
+ esac
+ append "$var" "${proto:+-p $proto}"
+ for option in $options; do
+ config_get value "$section" "$option"
+
+ case "$pkt:$option" in
+ *:srchost)
+ append "$var" "-s $value"
+ ;;
+ *:dsthost)
+ append "$var" "-d $value"
+ ;;
+ *:layer7)
+ add_insmod ipt_layer7
+ add_insmod xt_layer7
+ append "$var" "-m layer7 --l7proto $value${pkt:+ --l7pkt}"
+ ;;
+ *:ports|*:srcports|*:dstports)
+ value="$(echo "$value" | sed -e 's,-,:,g')"
+ lproto=${lproto:-tcp}
+ case "$proto" in
+ ""|tcp|udp) append "$var" "-m ${proto:-tcp -p tcp} -m multiport";;
+ *) unset "$var"; return 0;;
+ esac
+ case "$option" in
+ ports)
+ config_set "$section" srcports ""
+ config_set "$section" dstports ""
+ config_set "$section" portrange ""
+ append "$var" "--ports $value"
+ ;;
+ srcports)
+ config_set "$section" ports ""
+ config_set "$section" dstports ""
+ config_set "$section" portrange ""
+ append "$var" "--sports $value"
+ ;;
+ dstports)
+ config_set "$section" ports ""
+ config_set "$section" srcports ""
+ config_set "$section" portrange ""
+ append "$var" "--dports $value"
+ ;;
+ esac
+ ports=1
+ ;;
+ *:portrange)
+ config_set "$section" ports ""
+ config_set "$section" srcports ""
+ config_set "$section" dstports ""
+ value="$(echo "$value" | sed -e 's,-,:,g')"
+ case "$proto" in
+ ""|tcp|udp) append "$var" "-m ${proto:-tcp -p tcp} --sport $value --dport $value";;
+ *) unset "$var"; return 0;;
+ esac
+ ports=1
+ ;;
+ *:connbytes)
+ value="$(echo "$value" | sed -e 's,-,:,g')"
+ add_insmod ipt_connbytes
+ append "$var" "-m connbytes --connbytes $value --connbytes-dir both --connbytes-mode bytes"
+ ;;
+ *:tos)
+ add_insmod ipt_tos
+ case "$value" in
+ !*) append "$var" "-m tos ! --tos $value";;
+ *) append "$var" "-m tos --tos $value"
+ esac
+ ;;
+ *:dscp)
+ add_insmod ipt_dscp
+ dscp_option="--dscp"
+ [ -z "${value%%[EBCA]*}" ] && dscp_option="--dscp-class"
+ case "$value" in
+ !*) append "$var" "-m dscp ! $dscp_option $value";;
+ *) append "$var" "-m dscp $dscp_option $value"
+ esac
+ ;;
+ *:direction)
+ value="$(echo "$value" | sed -e 's,-,:,g')"
+ if [ "$value" = "out" ]; then
+ append "$var" "-o $device"
+ elif [ "$value" = "in" ]; then
+ append "$var" "-i $device"
+ fi
+ ;;
+ 1:pktsize)
+ value="$(echo "$value" | sed -e 's,-,:,g')"
+ add_insmod ipt_length
+ append "$var" "-m length --length $value"
+ ;;
+ 1:limit)
+ add_insmod ipt_limit
+ append "$var" "-m limit --limit $value"
+ ;;
+ 1:tcpflags)
+ case "$proto" in
+ tcp) append "$var" "-m tcp --tcp-flags ALL $value";;
+ *) unset $var; return 0;;
+ esac
+ ;;
+ 1:mark)
+ config_get class "${value##!}" classnr
+ [ -z "$class" ] && continue;
+ case "$value" in
+ !*) append "$var" "-m mark ! --mark $class/0xff";;
+ *) append "$var" "-m mark --mark $class/0xff";;
+ esac
+ ;;
+ 1:TOS)
+ add_insmod ipt_TOS
+ config_get TOS "$rule" 'TOS'
+ suffix="-j TOS --set-tos "${TOS:-"Normal-Service"}
+ ;;
+ 1:DSCP)
+ add_insmod ipt_DSCP
+ config_get DSCP "$rule" 'DSCP'
+ [ -z "${DSCP%%[EBCA]*}" ] && set_value="--set-dscp-class $DSCP" \
+ || set_value="--set-dscp $DSCP"
+ suffix="-j DSCP $set_value"
+ ;;
+ esac
+ done
+ append "$var" "$suffix"
+ case "$ports:$proto" in
+ 1:) parse_matching_rule "$var" "$section" "$options" "$prefix" "$suffix" "udp";;
+ esac
+}
+
+config_cb() {
+ option_cb() {
+ return 0
+ }
+
+ # Section start
+ case "$1" in
+ interface)
+ config_set "$2" "classgroup" "Default"
+ config_set "$2" "upload" "128"
+ ;;
+ classify|default|reclassify)
+ option_cb() {
+ append options "$1"
+ }
+ ;;
+ esac
+
+ # Section end
+ config_get TYPE "$CONFIG_SECTION" TYPE
+ case "$TYPE" in
+ interface)
+ config_get_bool enabled "$CONFIG_SECTION" enabled 1
+ [ 1 -eq "$enabled" ] || return 0
+ config_get classgroup "$CONFIG_SECTION" classgroup
+ config_set "$CONFIG_SECTION" ifbdev "$C"
+ C=$(($C+1))
+ append INTERFACES "$CONFIG_SECTION"
+ config_set "$classgroup" enabled 1
+ config_get device "$CONFIG_SECTION" device
+ [ -z "$device" ] && {
+ device="$(find_ifname ${CONFIG_SECTION})"
+ config_set "$CONFIG_SECTION" device "${device:-eth0}"
+ }
+ ;;
+ classgroup) append CG "$CONFIG_SECTION";;
+ classify|default|reclassify)
+ case "$TYPE" in
+ classify) var="ctrules";;
+ *) var="rules";;
+ esac
+ config_get target "$CONFIG_SECTION" target
+ config_set "$CONFIG_SECTION" options "$options"
+ append "$var" "$CONFIG_SECTION"
+ unset options
+ ;;
+ esac
+}
+
+
+enum_classes() {
+ local c="0"
+ config_get classes "$1" classes
+ config_get default "$1" default
+ for class in $classes; do
+ c="$(($c + 1))"
+ config_set "${class}" classnr $c
+ case "$class" in
+ $default) class_default=$c;;
+ esac
+ done
+ class_default="${class_default:-$c}"
+}
+
+cls_var() {
+ local varname="$1"
+ local class="$2"
+ local name="$3"
+ local type="$4"
+ local default="$5"
+ local tmp tmp1 tmp2
+ config_get tmp1 "$class" "$name"
+ config_get tmp2 "${class}_${type}" "$name"
+ tmp="${tmp2:-$tmp1}"
+ tmp="${tmp:-$tmp2}"
+ export ${varname}="${tmp:-$default}"
+}
+
+tcrules() {
+ dir=/usr/lib/qos
+ [ -e $dir/tcrules.awk ] || dir=.
+ echo "$cstr" | awk \
+ -v device="$dev" \
+ -v linespeed="$rate" \
+ -f $dir/tcrules.awk
+}
+
+start_interface() {
+ local iface="$1"
+ local num_ifb="$2"
+ config_get device "$iface" device
+ config_get_bool enabled "$iface" enabled 1
+ [ -z "$device" -o 1 -ne "$enabled" ] && {
+ return 1
+ }
+ config_get upload "$iface" upload
+ config_get_bool halfduplex "$iface" halfduplex
+ config_get download "$iface" download
+ config_get classgroup "$iface" classgroup
+ config_get_bool overhead "$iface" overhead 0
+
+ download="${download:-${halfduplex:+$upload}}"
+ enum_classes "$classgroup"
+ for dir in ${halfduplex:-up} ${download:+down}; do
+ case "$dir" in
+ up)
+ [ "$overhead" = 1 ] && upload=$(($upload * 98 / 100 - (15 * 128 / $upload)))
+ dev="$device"
+ rate="$upload"
+ dl_mode=""
+ prefix="cls"
+ ;;
+ down)
+ [ "$(ls -d /proc/sys/net/ipv4/conf/ifb* 2>&- | wc -l)" -ne "$num_ifb" ] && add_insmod ifb numifbs="$num_ifb"
+ config_get ifbdev "$iface" ifbdev
+ [ "$overhead" = 1 ] && download=$(($download * 98 / 100 - (80 * 1024 / $download)))
+ dev="ifb$ifbdev"
+ rate="$download"
+ dl_mode=1
+ prefix="d_cls"
+ ;;
+ *) continue;;
+ esac
+ cstr=
+ for class in $classes; do
+ cls_var pktsize "$class" packetsize $dir 1500
+ cls_var pktdelay "$class" packetdelay $dir 0
+ cls_var maxrate "$class" limitrate $dir 100
+ cls_var prio "$class" priority $dir 1
+ cls_var avgrate "$class" avgrate $dir 0
+ cls_var qdisc "$class" qdisc $dir ""
+ cls_var filter "$class" filter $dir ""
+ config_get classnr "$class" classnr
+ append cstr "$classnr:$prio:$avgrate:$pktsize:$pktdelay:$maxrate:$qdisc:$filter" "$N"
+ done
+ append ${prefix}q "$(tcrules)" "$N"
+ export dev_${dir}="ifconfig $dev up txqueuelen 5 >&- 2>&-
+tc qdisc del dev $dev root >&- 2>&-
+tc qdisc add dev $dev root handle 1: hfsc default ${class_default}0
+tc class add dev $dev parent 1: classid 1:1 hfsc sc rate ${rate}kbit ul rate ${rate}kbit"
+ done
+ [ -n "$download" ] && {
+ add_insmod cls_u32
+ add_insmod em_u32
+ add_insmod act_connmark
+ add_insmod act_mirred
+ add_insmod sch_ingress
+ }
+ if [ -n "$halfduplex" ]; then
+ export dev_up="tc qdisc del dev $device root >&- 2>&-
+tc qdisc add dev $device root handle 1: hfsc
+tc filter add dev $device parent 1: protocol ip prio 10 u32 match u32 0 0 flowid 1:1 action mirred egress redirect dev ifb$ifbdev"
+ elif [ -n "$download" ]; then
+ append dev_${dir} "tc qdisc del dev $device ingress >&- 2>&-
+tc qdisc add dev $device ingress
+tc filter add dev $device parent ffff: protocol ip prio 1 u32 match u32 0 0 flowid 1:1 action connmark action mirred egress redirect dev ifb$ifbdev" "$N"
+ fi
+ add_insmod cls_fw
+ add_insmod sch_hfsc
+ add_insmod sch_fq_codel
+
+ cat <<EOF
+${INSMOD:+$INSMOD$N}${dev_up:+$dev_up
+$clsq
+}${ifbdev:+$dev_down
+$d_clsq
+$d_clsl
+$d_clsf
+}
+EOF
+ unset INSMOD clsq clsf clsl d_clsq d_clsl d_clsf dev_up dev_down
+}
+
+start_interfaces() {
+ local C="$1"
+ for iface in $INTERFACES; do
+ start_interface "$iface" "$C"
+ done
+}
+
+add_rules() {
+ local var="$1"
+ local rules="$2"
+ local prefix="$3"
+
+ for rule in $rules; do
+ unset iptrule
+ config_get target "$rule" target
+ config_get target "$target" classnr
+ config_get options "$rule" options
+
+ ## If we want to override the TOS field, let's clear the DSCP field first.
+ [ ! -z "$(echo $options | grep 'TOS')" ] && {
+ s_options=${options%%TOS}
+ add_insmod ipt_DSCP
+ parse_matching_rule iptrule "$rule" "$s_options" "$prefix" "-j DSCP --set-dscp 0"
+ append "$var" "$iptrule" "$N"
+ unset iptrule
+ }
+
+ parse_matching_rule iptrule "$rule" "$options" "$prefix" "-j MARK --set-mark $target/0xff"
+ append "$var" "$iptrule" "$N"
+ done
+}
+
+start_cg() {
+ local cg="$1"
+ local iptrules
+ local pktrules
+ local sizerules
+ enum_classes "$cg"
+ add_rules iptrules "$ctrules" "iptables -t mangle -A qos_${cg}_ct"
+ config_get classes "$cg" classes
+ for class in $classes; do
+ config_get mark "$class" classnr
+ config_get maxsize "$class" maxsize
+ [ -z "$maxsize" -o -z "$mark" ] || {
+ add_insmod ipt_length
+ append pktrules "iptables -t mangle -A qos_${cg} -m mark --mark $mark/0xff -m length --length $maxsize: -j MARK --set-mark 0/0xff" "$N"
+ }
+ done
+ add_rules pktrules "$rules" "iptables -t mangle -A qos_${cg}"
+ for iface in $INTERFACES; do
+ config_get classgroup "$iface" classgroup
+ config_get device "$iface" device
+ config_get ifbdev "$iface" ifbdev
+ config_get upload "$iface" upload
+ config_get download "$iface" download
+ config_get halfduplex "$iface" halfduplex
+ download="${download:-${halfduplex:+$upload}}"
+ append up "iptables -t mangle -A OUTPUT -o $device -j qos_${cg}" "$N"
+ append up "iptables -t mangle -A FORWARD -o $device -j qos_${cg}" "$N"
+ done
+ cat <<EOF
+$INSMOD
+iptables -t mangle -N qos_${cg} >&- 2>&-
+iptables -t mangle -N qos_${cg}_ct >&- 2>&-
+${iptrules:+${iptrules}${N}iptables -t mangle -A qos_${cg}_ct -j CONNMARK --save-mark --mask 0xff}
+iptables -t mangle -A qos_${cg} -j CONNMARK --restore-mark --mask 0xff
+iptables -t mangle -A qos_${cg} -m mark --mark 0/0xff -j qos_${cg}_ct
+$pktrules
+$up$N${down:+${down}$N}
+EOF
+ unset INSMOD
+}
+
+start_firewall() {
+ add_insmod ipt_multiport
+ add_insmod ipt_CONNMARK
+ stop_firewall
+ for group in $CG; do
+ start_cg $group
+ done
+}
+
+stop_firewall() {
+ # Builds up a list of iptables commands to flush the qos_* chains,
+ # remove rules referring to them, then delete them
+
+ # Print rules in the mangle table, like iptables-save
+ iptables -t mangle -S |
+ # Find rules for the qos_* chains
+ grep '^-N qos_\|-j qos_' |
+ # Exclude rules in qos_* chains (inter-qos_* refs)
+ grep -v '^-A qos_' |
+ # Replace -N with -X and hold, with -F and print
+ # Replace -A with -D
+ # Print held lines at the end (note leading newline)
+ sed -e '/^-N/{s/^-N/-X/;H;s/^-X/-F/}' \
+ -e 's/^-A/-D/' \
+ -e '${p;g}' |
+ # Make into proper iptables calls
+ # Note: awkward in previous call due to hold space usage
+ sed -n -e 's/^./iptables -t mangle &/p'
+}
+
+C="0"
+INTERFACES=""
+[ -e ./qos.conf ] && {
+ . ./qos.conf
+ config_cb
+} || config_load qos
+
+C="0"
+for iface in $INTERFACES; do
+ export C="$(($C + 1))"
+done
+
+case "$1" in
+ all)
+ start_interfaces "$C"
+ start_firewall
+ ;;
+ interface)
+ start_interface "$2" "$C"
+ ;;
+ interfaces)
+ start_interfaces
+ ;;
+ firewall)
+ case "$2" in
+ stop)
+ stop_firewall
+ ;;
+ start|"")
+ start_firewall
+ ;;
+ esac
+ ;;
+esac
diff --git a/package/network/config/qos-scripts/files/usr/lib/qos/.svn/text-base/tcrules.awk.svn-base b/package/network/config/qos-scripts/files/usr/lib/qos/.svn/text-base/tcrules.awk.svn-base
new file mode 100644
index 0000000..a19b651
--- /dev/null
+++ b/package/network/config/qos-scripts/files/usr/lib/qos/.svn/text-base/tcrules.awk.svn-base
@@ -0,0 +1,95 @@
+BEGIN {
+ dmax=100
+ if (!(linespeed > 0)) linespeed = 128
+ FS=":"
+ n = 0
+}
+
+($1 != "") {
+ n++
+ class[n] = $1
+ prio[n] = $2
+ avgrate[n] = ($3 * linespeed / 100)
+ pktsize[n] = $4
+ delay[n] = $5
+ maxrate[n] = ($6 * linespeed / 100)
+ qdisc[n] = $7
+ filter[n] = $8
+}
+
+END {
+ allocated = 0
+ maxdelay = 0
+
+ for (i = 1; i <= n; i++) {
+ # set defaults
+ if (!(pktsize[i] > 0)) pktsize[i] = 1500
+ if (!(prio[i] > 0)) prio[i] = 1
+
+ allocated += avgrate[i]
+ sum_prio += prio[i]
+ if ((avgrate[i] > 0) && !(delay[i] > 0)) {
+ sum_rtprio += prio[i]
+ }
+ }
+
+ # allocation of m1 in rt classes:
+ # sum(d * m1) must not exceed dmax * (linespeed - allocated)
+ dmax = 0
+ for (i = 1; i <= n; i++) {
+ if (avgrate[i] > 0) {
+ rtm2[i] = avgrate[i]
+ if (delay[i] > 0) {
+ d[i] = delay[i]
+ } else {
+ d[i] = 2 * pktsize[i] * 1000 / (linespeed * 1024)
+ if (d[i] > dmax) dmax = d[i]
+ }
+ }
+ }
+
+ ds_avail = dmax * (linespeed - allocated)
+ for (i = 1; i <= n; i++) {
+ lsm1[i] = 0
+ rtm1[i] = 0
+ lsm2[i] = linespeed * prio[i] / sum_prio
+ if ((avgrate[i] > 0) && (d[i] > 0)) {
+ if (!(delay[i] > 0)) {
+ ds = ds_avail * prio[i] / sum_rtprio
+ ds_avail -= ds
+ rtm1[i] = rtm2[i] + ds/d[i]
+ }
+ lsm1[i] = rtm1[i]
+ }
+ else {
+ d[i] = 0
+ }
+ }
+
+ # main qdisc
+ for (i = 1; i <= n; i++) {
+ printf "tc class add dev "device" parent 1:1 classid 1:"class[i]"0 hfsc"
+ if (rtm1[i] > 0) {
+ printf " rt m1 " int(rtm1[i]) "kbit d " int(d[i] * 1000) "us m2 " int(rtm2[i])"kbit"
+ }
+ printf " ls m1 " int(lsm1[i]) "kbit d " int(d[i] * 1000) "us m2 " int(lsm2[i]) "kbit"
+ print " ul rate " int(maxrate[i]) "kbit"
+ }
+
+ # leaf qdisc
+ avpkt = 1200
+ for (i = 1; i <= n; i++) {
+ print "tc qdisc add dev "device" parent 1:"class[i]"0 handle "class[i]"00: fq_codel"
+ }
+
+ # filter rule
+ for (i = 1; i <= n; i++) {
+ print "tc filter add dev "device" parent 1: prio "class[i]" protocol ip handle "class[i]"/0xff fw flowid 1:"class[i] "0"
+ filterc=1
+ if (filter[i] != "") {
+ print " tc filter add dev "device" parent "class[i]"00: handle "filterc"0 "filter[i]
+ filterc=filterc+1
+ }
+ }
+}
+
diff --git a/package/network/config/qos-scripts/files/usr/lib/qos/generate.sh b/package/network/config/qos-scripts/files/usr/lib/qos/generate.sh
new file mode 100755
index 0000000..440b43f
--- /dev/null
+++ b/package/network/config/qos-scripts/files/usr/lib/qos/generate.sh
@@ -0,0 +1,497 @@
+#!/bin/sh
+[ -e /lib/functions.sh ] && . /lib/functions.sh || . ./functions.sh
+[ -x /sbin/modprobe ] && {
+ insmod="modprobe"
+ rmmod="$insmod -r"
+} || {
+ insmod="insmod"
+ rmmod="rmmod"
+}
+
+add_insmod() {
+ eval "export isset=\${insmod_$1}"
+ case "$isset" in
+ 1) ;;
+ *) {
+ [ "$2" ] && append INSMOD "$rmmod $1 >&- 2>&-" "$N"
+ append INSMOD "$insmod $* >&- 2>&-" "$N"; export insmod_$1=1
+ };;
+ esac
+}
+
+[ -e /etc/config/network ] && {
+ # only try to parse network config on openwrt
+
+ find_ifname() {(
+ reset_cb
+ include /lib/network
+ scan_interfaces
+ config_get "$1" ifname
+ )}
+} || {
+ find_ifname() {
+ echo "Interface not found."
+ exit 1
+ }
+}
+
+parse_matching_rule() {
+ local var="$1"
+ local section="$2"
+ local options="$3"
+ local prefix="$4"
+ local suffix="$5"
+ local proto="$6"
+ local mport=""
+ local ports=""
+
+ append "$var" "$prefix" "$N"
+ for option in $options; do
+ case "$option" in
+ proto) config_get value "$section" proto; proto="${proto:-$value}";;
+ esac
+ done
+ config_get type "$section" TYPE
+ case "$type" in
+ classify) unset pkt; append "$var" "-m mark --mark 0/0xff";;
+ default) pkt=1; append "$var" "-m mark --mark 0/0xff";;
+ reclassify) pkt=1;;
+ esac
+ append "$var" "${proto:+-p $proto}"
+ for option in $options; do
+ config_get value "$section" "$option"
+
+ case "$pkt:$option" in
+ *:srchost)
+ append "$var" "-s $value"
+ ;;
+ *:dsthost)
+ append "$var" "-d $value"
+ ;;
+ *:layer7)
+ add_insmod ipt_layer7
+ add_insmod xt_layer7
+ append "$var" "-m layer7 --l7proto $value${pkt:+ --l7pkt}"
+ ;;
+ *:ports|*:srcports|*:dstports)
+ value="$(echo "$value" | sed -e 's,-,:,g')"
+ lproto=${lproto:-tcp}
+ case "$proto" in
+ ""|tcp|udp) append "$var" "-m ${proto:-tcp -p tcp} -m multiport";;
+ *) unset "$var"; return 0;;
+ esac
+ case "$option" in
+ ports)
+ config_set "$section" srcports ""
+ config_set "$section" dstports ""
+ config_set "$section" portrange ""
+ append "$var" "--ports $value"
+ ;;
+ srcports)
+ config_set "$section" ports ""
+ config_set "$section" dstports ""
+ config_set "$section" portrange ""
+ append "$var" "--sports $value"
+ ;;
+ dstports)
+ config_set "$section" ports ""
+ config_set "$section" srcports ""
+ config_set "$section" portrange ""
+ append "$var" "--dports $value"
+ ;;
+ esac
+ ports=1
+ ;;
+ *:portrange)
+ config_set "$section" ports ""
+ config_set "$section" srcports ""
+ config_set "$section" dstports ""
+ value="$(echo "$value" | sed -e 's,-,:,g')"
+ case "$proto" in
+ ""|tcp|udp) append "$var" "-m ${proto:-tcp -p tcp} --sport $value --dport $value";;
+ *) unset "$var"; return 0;;
+ esac
+ ports=1
+ ;;
+ *:connbytes)
+ value="$(echo "$value" | sed -e 's,-,:,g')"
+ add_insmod ipt_connbytes
+ append "$var" "-m connbytes --connbytes $value --connbytes-dir both --connbytes-mode bytes"
+ ;;
+ *:tos)
+ add_insmod ipt_tos
+ case "$value" in
+ !*) append "$var" "-m tos ! --tos $value";;
+ *) append "$var" "-m tos --tos $value"
+ esac
+ ;;
+ *:dscp)
+ add_insmod ipt_dscp
+ dscp_option="--dscp"
+ [ -z "${value%%[EBCA]*}" ] && dscp_option="--dscp-class"
+ case "$value" in
+ !*) append "$var" "-m dscp ! $dscp_option $value";;
+ *) append "$var" "-m dscp $dscp_option $value"
+ esac
+ ;;
+ *:direction)
+ value="$(echo "$value" | sed -e 's,-,:,g')"
+ if [ "$value" = "out" ]; then
+ append "$var" "-o $device"
+ elif [ "$value" = "in" ]; then
+ append "$var" "-i $device"
+ fi
+ ;;
+ 1:pktsize)
+ value="$(echo "$value" | sed -e 's,-,:,g')"
+ add_insmod ipt_length
+ append "$var" "-m length --length $value"
+ ;;
+ 1:limit)
+ add_insmod ipt_limit
+ append "$var" "-m limit --limit $value"
+ ;;
+ 1:tcpflags)
+ case "$proto" in
+ tcp) append "$var" "-m tcp --tcp-flags ALL $value";;
+ *) unset $var; return 0;;
+ esac
+ ;;
+ 1:mark)
+ config_get class "${value##!}" classnr
+ [ -z "$class" ] && continue;
+ case "$value" in
+ !*) append "$var" "-m mark ! --mark $class/0xff";;
+ *) append "$var" "-m mark --mark $class/0xff";;
+ esac
+ ;;
+ 1:TOS)
+ add_insmod ipt_TOS
+ config_get TOS "$rule" 'TOS'
+ suffix="-j TOS --set-tos "${TOS:-"Normal-Service"}
+ ;;
+ 1:DSCP)
+ add_insmod ipt_DSCP
+ config_get DSCP "$rule" 'DSCP'
+ [ -z "${DSCP%%[EBCA]*}" ] && set_value="--set-dscp-class $DSCP" \
+ || set_value="--set-dscp $DSCP"
+ suffix="-j DSCP $set_value"
+ ;;
+ esac
+ done
+ append "$var" "$suffix"
+ case "$ports:$proto" in
+ 1:) parse_matching_rule "$var" "$section" "$options" "$prefix" "$suffix" "udp";;
+ esac
+}
+
+config_cb() {
+ option_cb() {
+ return 0
+ }
+
+ # Section start
+ case "$1" in
+ interface)
+ config_set "$2" "classgroup" "Default"
+ config_set "$2" "upload" "128"
+ ;;
+ classify|default|reclassify)
+ option_cb() {
+ append options "$1"
+ }
+ ;;
+ esac
+
+ # Section end
+ config_get TYPE "$CONFIG_SECTION" TYPE
+ case "$TYPE" in
+ interface)
+ config_get_bool enabled "$CONFIG_SECTION" enabled 1
+ [ 1 -eq "$enabled" ] || return 0
+ config_get classgroup "$CONFIG_SECTION" classgroup
+ config_set "$CONFIG_SECTION" ifbdev "$C"
+ C=$(($C+1))
+ append INTERFACES "$CONFIG_SECTION"
+ config_set "$classgroup" enabled 1
+ config_get device "$CONFIG_SECTION" device
+ [ -z "$device" ] && {
+ device="$(find_ifname ${CONFIG_SECTION})"
+ config_set "$CONFIG_SECTION" device "${device:-eth0}"
+ }
+ ;;
+ classgroup) append CG "$CONFIG_SECTION";;
+ classify|default|reclassify)
+ case "$TYPE" in
+ classify) var="ctrules";;
+ *) var="rules";;
+ esac
+ config_get target "$CONFIG_SECTION" target
+ config_set "$CONFIG_SECTION" options "$options"
+ append "$var" "$CONFIG_SECTION"
+ unset options
+ ;;
+ esac
+}
+
+
+enum_classes() {
+ local c="0"
+ config_get classes "$1" classes
+ config_get default "$1" default
+ for class in $classes; do
+ c="$(($c + 1))"
+ config_set "${class}" classnr $c
+ case "$class" in
+ $default) class_default=$c;;
+ esac
+ done
+ class_default="${class_default:-$c}"
+}
+
+cls_var() {
+ local varname="$1"
+ local class="$2"
+ local name="$3"
+ local type="$4"
+ local default="$5"
+ local tmp tmp1 tmp2
+ config_get tmp1 "$class" "$name"
+ config_get tmp2 "${class}_${type}" "$name"
+ tmp="${tmp2:-$tmp1}"
+ tmp="${tmp:-$tmp2}"
+ export ${varname}="${tmp:-$default}"
+}
+
+tcrules() {
+ dir=/usr/lib/qos
+ [ -e $dir/tcrules.awk ] || dir=.
+ echo "$cstr" | awk \
+ -v device="$dev" \
+ -v linespeed="$rate" \
+ -f $dir/tcrules.awk
+}
+
+start_interface() {
+ local iface="$1"
+ local num_ifb="$2"
+ config_get device "$iface" device
+ config_get_bool enabled "$iface" enabled 1
+ [ -z "$device" -o 1 -ne "$enabled" ] && {
+ return 1
+ }
+ config_get upload "$iface" upload
+ config_get_bool halfduplex "$iface" halfduplex
+ config_get download "$iface" download
+ config_get classgroup "$iface" classgroup
+ config_get_bool overhead "$iface" overhead 0
+
+ download="${download:-${halfduplex:+$upload}}"
+ enum_classes "$classgroup"
+ for dir in ${halfduplex:-up} ${download:+down}; do
+ case "$dir" in
+ up)
+ [ "$overhead" = 1 ] && upload=$(($upload * 98 / 100 - (15 * 128 / $upload)))
+ dev="$device"
+ rate="$upload"
+ dl_mode=""
+ prefix="cls"
+ ;;
+ down)
+ [ "$(ls -d /proc/sys/net/ipv4/conf/ifb* 2>&- | wc -l)" -ne "$num_ifb" ] && add_insmod ifb numifbs="$num_ifb"
+ config_get ifbdev "$iface" ifbdev
+ [ "$overhead" = 1 ] && download=$(($download * 98 / 100 - (80 * 1024 / $download)))
+ dev="ifb$ifbdev"
+ rate="$download"
+ dl_mode=1
+ prefix="d_cls"
+ ;;
+ *) continue;;
+ esac
+ cstr=
+ for class in $classes; do
+ cls_var pktsize "$class" packetsize $dir 1500
+ cls_var pktdelay "$class" packetdelay $dir 0
+ cls_var maxrate "$class" limitrate $dir 100
+ cls_var prio "$class" priority $dir 1
+ cls_var avgrate "$class" avgrate $dir 0
+ cls_var qdisc "$class" qdisc $dir ""
+ cls_var filter "$class" filter $dir ""
+ config_get classnr "$class" classnr
+ append cstr "$classnr:$prio:$avgrate:$pktsize:$pktdelay:$maxrate:$qdisc:$filter" "$N"
+ done
+ append ${prefix}q "$(tcrules)" "$N"
+ export dev_${dir}="ifconfig $dev up txqueuelen 5 >&- 2>&-
+tc qdisc del dev $dev root >&- 2>&-
+tc qdisc add dev $dev root handle 1: hfsc default ${class_default}0
+tc class add dev $dev parent 1: classid 1:1 hfsc sc rate ${rate}kbit ul rate ${rate}kbit"
+ done
+ [ -n "$download" ] && {
+ add_insmod cls_u32
+ add_insmod em_u32
+ add_insmod act_connmark
+ add_insmod act_mirred
+ add_insmod sch_ingress
+ }
+ if [ -n "$halfduplex" ]; then
+ export dev_up="tc qdisc del dev $device root >&- 2>&-
+tc qdisc add dev $device root handle 1: hfsc
+tc filter add dev $device parent 1: protocol ip prio 10 u32 match u32 0 0 flowid 1:1 action mirred egress redirect dev ifb$ifbdev"
+ elif [ -n "$download" ]; then
+ append dev_${dir} "tc qdisc del dev $device ingress >&- 2>&-
+tc qdisc add dev $device ingress
+tc filter add dev $device parent ffff: protocol ip prio 1 u32 match u32 0 0 flowid 1:1 action connmark action mirred egress redirect dev ifb$ifbdev" "$N"
+ fi
+ add_insmod cls_fw
+ add_insmod sch_hfsc
+ add_insmod sch_fq_codel
+
+ cat <<EOF
+${INSMOD:+$INSMOD$N}${dev_up:+$dev_up
+$clsq
+}${ifbdev:+$dev_down
+$d_clsq
+$d_clsl
+$d_clsf
+}
+EOF
+ unset INSMOD clsq clsf clsl d_clsq d_clsl d_clsf dev_up dev_down
+}
+
+start_interfaces() {
+ local C="$1"
+ for iface in $INTERFACES; do
+ start_interface "$iface" "$C"
+ done
+}
+
+add_rules() {
+ local var="$1"
+ local rules="$2"
+ local prefix="$3"
+
+ for rule in $rules; do
+ unset iptrule
+ config_get target "$rule" target
+ config_get target "$target" classnr
+ config_get options "$rule" options
+
+ ## If we want to override the TOS field, let's clear the DSCP field first.
+ [ ! -z "$(echo $options | grep 'TOS')" ] && {
+ s_options=${options%%TOS}
+ add_insmod ipt_DSCP
+ parse_matching_rule iptrule "$rule" "$s_options" "$prefix" "-j DSCP --set-dscp 0"
+ append "$var" "$iptrule" "$N"
+ unset iptrule
+ }
+
+ parse_matching_rule iptrule "$rule" "$options" "$prefix" "-j MARK --set-mark $target/0xff"
+ append "$var" "$iptrule" "$N"
+ done
+}
+
+start_cg() {
+ local cg="$1"
+ local iptrules
+ local pktrules
+ local sizerules
+ enum_classes "$cg"
+ add_rules iptrules "$ctrules" "iptables -t mangle -A qos_${cg}_ct"
+ config_get classes "$cg" classes
+ for class in $classes; do
+ config_get mark "$class" classnr
+ config_get maxsize "$class" maxsize
+ [ -z "$maxsize" -o -z "$mark" ] || {
+ add_insmod ipt_length
+ append pktrules "iptables -t mangle -A qos_${cg} -m mark --mark $mark/0xff -m length --length $maxsize: -j MARK --set-mark 0/0xff" "$N"
+ }
+ done
+ add_rules pktrules "$rules" "iptables -t mangle -A qos_${cg}"
+ for iface in $INTERFACES; do
+ config_get classgroup "$iface" classgroup
+ config_get device "$iface" device
+ config_get ifbdev "$iface" ifbdev
+ config_get upload "$iface" upload
+ config_get download "$iface" download
+ config_get halfduplex "$iface" halfduplex
+ download="${download:-${halfduplex:+$upload}}"
+ append up "iptables -t mangle -A OUTPUT -o $device -j qos_${cg}" "$N"
+ append up "iptables -t mangle -A FORWARD -o $device -j qos_${cg}" "$N"
+ done
+ cat <<EOF
+$INSMOD
+iptables -t mangle -N qos_${cg} >&- 2>&-
+iptables -t mangle -N qos_${cg}_ct >&- 2>&-
+${iptrules:+${iptrules}${N}iptables -t mangle -A qos_${cg}_ct -j CONNMARK --save-mark --mask 0xff}
+iptables -t mangle -A qos_${cg} -j CONNMARK --restore-mark --mask 0xff
+iptables -t mangle -A qos_${cg} -m mark --mark 0/0xff -j qos_${cg}_ct
+$pktrules
+$up$N${down:+${down}$N}
+EOF
+ unset INSMOD
+}
+
+start_firewall() {
+ add_insmod ipt_multiport
+ add_insmod ipt_CONNMARK
+ stop_firewall
+ for group in $CG; do
+ start_cg $group
+ done
+}
+
+stop_firewall() {
+ # Builds up a list of iptables commands to flush the qos_* chains,
+ # remove rules referring to them, then delete them
+
+ # Print rules in the mangle table, like iptables-save
+ iptables -t mangle -S |
+ # Find rules for the qos_* chains
+ grep '^-N qos_\|-j qos_' |
+ # Exclude rules in qos_* chains (inter-qos_* refs)
+ grep -v '^-A qos_' |
+ # Replace -N with -X and hold, with -F and print
+ # Replace -A with -D
+ # Print held lines at the end (note leading newline)
+ sed -e '/^-N/{s/^-N/-X/;H;s/^-X/-F/}' \
+ -e 's/^-A/-D/' \
+ -e '${p;g}' |
+ # Make into proper iptables calls
+ # Note: awkward in previous call due to hold space usage
+ sed -n -e 's/^./iptables -t mangle &/p'
+}
+
+C="0"
+INTERFACES=""
+[ -e ./qos.conf ] && {
+ . ./qos.conf
+ config_cb
+} || config_load qos
+
+C="0"
+for iface in $INTERFACES; do
+ export C="$(($C + 1))"
+done
+
+case "$1" in
+ all)
+ start_interfaces "$C"
+ start_firewall
+ ;;
+ interface)
+ start_interface "$2" "$C"
+ ;;
+ interfaces)
+ start_interfaces
+ ;;
+ firewall)
+ case "$2" in
+ stop)
+ stop_firewall
+ ;;
+ start|"")
+ start_firewall
+ ;;
+ esac
+ ;;
+esac
diff --git a/package/network/config/qos-scripts/files/usr/lib/qos/tcrules.awk b/package/network/config/qos-scripts/files/usr/lib/qos/tcrules.awk
new file mode 100644
index 0000000..a19b651
--- /dev/null
+++ b/package/network/config/qos-scripts/files/usr/lib/qos/tcrules.awk
@@ -0,0 +1,95 @@
+BEGIN {
+ dmax=100
+ if (!(linespeed > 0)) linespeed = 128
+ FS=":"
+ n = 0
+}
+
+($1 != "") {
+ n++
+ class[n] = $1
+ prio[n] = $2
+ avgrate[n] = ($3 * linespeed / 100)
+ pktsize[n] = $4
+ delay[n] = $5
+ maxrate[n] = ($6 * linespeed / 100)
+ qdisc[n] = $7
+ filter[n] = $8
+}
+
+END {
+ allocated = 0
+ maxdelay = 0
+
+ for (i = 1; i <= n; i++) {
+ # set defaults
+ if (!(pktsize[i] > 0)) pktsize[i] = 1500
+ if (!(prio[i] > 0)) prio[i] = 1
+
+ allocated += avgrate[i]
+ sum_prio += prio[i]
+ if ((avgrate[i] > 0) && !(delay[i] > 0)) {
+ sum_rtprio += prio[i]
+ }
+ }
+
+ # allocation of m1 in rt classes:
+ # sum(d * m1) must not exceed dmax * (linespeed - allocated)
+ dmax = 0
+ for (i = 1; i <= n; i++) {
+ if (avgrate[i] > 0) {
+ rtm2[i] = avgrate[i]
+ if (delay[i] > 0) {
+ d[i] = delay[i]
+ } else {
+ d[i] = 2 * pktsize[i] * 1000 / (linespeed * 1024)
+ if (d[i] > dmax) dmax = d[i]
+ }
+ }
+ }
+
+ ds_avail = dmax * (linespeed - allocated)
+ for (i = 1; i <= n; i++) {
+ lsm1[i] = 0
+ rtm1[i] = 0
+ lsm2[i] = linespeed * prio[i] / sum_prio
+ if ((avgrate[i] > 0) && (d[i] > 0)) {
+ if (!(delay[i] > 0)) {
+ ds = ds_avail * prio[i] / sum_rtprio
+ ds_avail -= ds
+ rtm1[i] = rtm2[i] + ds/d[i]
+ }
+ lsm1[i] = rtm1[i]
+ }
+ else {
+ d[i] = 0
+ }
+ }
+
+ # main qdisc
+ for (i = 1; i <= n; i++) {
+ printf "tc class add dev "device" parent 1:1 classid 1:"class[i]"0 hfsc"
+ if (rtm1[i] > 0) {
+ printf " rt m1 " int(rtm1[i]) "kbit d " int(d[i] * 1000) "us m2 " int(rtm2[i])"kbit"
+ }
+ printf " ls m1 " int(lsm1[i]) "kbit d " int(d[i] * 1000) "us m2 " int(lsm2[i]) "kbit"
+ print " ul rate " int(maxrate[i]) "kbit"
+ }
+
+ # leaf qdisc
+ avpkt = 1200
+ for (i = 1; i <= n; i++) {
+ print "tc qdisc add dev "device" parent 1:"class[i]"0 handle "class[i]"00: fq_codel"
+ }
+
+ # filter rule
+ for (i = 1; i <= n; i++) {
+ print "tc filter add dev "device" parent 1: prio "class[i]" protocol ip handle "class[i]"/0xff fw flowid 1:"class[i] "0"
+ filterc=1
+ if (filter[i] != "") {
+ print " tc filter add dev "device" parent "class[i]"00: handle "filterc"0 "filter[i]
+ filterc=filterc+1
+ }
+ }
+}
+
diff --git a/package/network/config/soloscli/.svn/entries b/package/network/config/soloscli/.svn/entries
new file mode 100644
index 0000000..a0a97d4
--- /dev/null
+++ b/package/network/config/soloscli/.svn/entries
@@ -0,0 +1,68 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/config/soloscli
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+files
+dir
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+9f83905a4b148adefe46725583d2257e
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1155
+
diff --git a/package/network/config/soloscli/.svn/text-base/Makefile.svn-base b/package/network/config/soloscli/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..9a7cd89
--- /dev/null
+++ b/package/network/config/soloscli/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,45 @@
+#
+# Copyright (C) 2006-2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=soloscli
+PKG_VERSION:=0.11
+PKG_RELEASE:=3
+
+PKG_SOURCE:=solos-pci-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=@SF/openadsl
+PKG_MD5SUM:=ab3f3fa654ef7c3a402980eca094e690
+
+PKG_INSTALL:=1
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/solos-pci-$(PKG_VERSION)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/soloscli
+ SECTION:=net
+ CATEGORY:=Network
+ TITLE:=Configuration utility for Solos ADSL2+ modems
+ DEPENDS:=+kmod-solos-pci
+ URL:=http://sourceforge.net/projects/openadsl
+endef
+
+define Package/soloscli/description
+ This package contains the soloscli utility
+ for interrogating Traverse Technologies' Solos ADSL2+ modems.
+endef
+
+define Package/soloscli/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/soloscli/soloscli $(1)/usr/bin/
+ $(INSTALL_BIN) ./files/solos-log-stats $(1)/usr/bin/
+ $(INSTALL_DIR) $(1)/etc/hotplug.d/atm
+ $(INSTALL_DATA) ./files/etc/hotplug.d/atm/15-solos-init $(1)/etc/hotplug.d/atm/
+endef
+
+$(eval $(call BuildPackage,soloscli))
diff --git a/package/network/config/soloscli/Makefile b/package/network/config/soloscli/Makefile
new file mode 100644
index 0000000..9a7cd89
--- /dev/null
+++ b/package/network/config/soloscli/Makefile
@@ -0,0 +1,45 @@
+#
+# Copyright (C) 2006-2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=soloscli
+PKG_VERSION:=0.11
+PKG_RELEASE:=3
+
+PKG_SOURCE:=solos-pci-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=@SF/openadsl
+PKG_MD5SUM:=ab3f3fa654ef7c3a402980eca094e690
+
+PKG_INSTALL:=1
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/solos-pci-$(PKG_VERSION)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/soloscli
+ SECTION:=net
+ CATEGORY:=Network
+ TITLE:=Configuration utility for Solos ADSL2+ modems
+ DEPENDS:=+kmod-solos-pci
+ URL:=http://sourceforge.net/projects/openadsl
+endef
+
+define Package/soloscli/description
+ This package contains the soloscli utility
+ for interrogating Traverse Technologies' Solos ADSL2+ modems.
+endef
+
+define Package/soloscli/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/soloscli/soloscli $(1)/usr/bin/
+ $(INSTALL_BIN) ./files/solos-log-stats $(1)/usr/bin/
+ $(INSTALL_DIR) $(1)/etc/hotplug.d/atm
+ $(INSTALL_DATA) ./files/etc/hotplug.d/atm/15-solos-init $(1)/etc/hotplug.d/atm/
+endef
+
+$(eval $(call BuildPackage,soloscli))
diff --git a/package/network/config/soloscli/files/.svn/entries b/package/network/config/soloscli/files/.svn/entries
new file mode 100644
index 0000000..c4ee455
--- /dev/null
+++ b/package/network/config/soloscli/files/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/config/soloscli/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+solos-log-stats
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+8d361d780cc0529ec18113bbf657b51f
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+606
+
+etc
+dir
+
diff --git a/package/network/config/soloscli/files/.svn/text-base/solos-log-stats.svn-base b/package/network/config/soloscli/files/.svn/text-base/solos-log-stats.svn-base
new file mode 100644
index 0000000..2b75ee3
--- /dev/null
+++ b/package/network/config/soloscli/files/.svn/text-base/solos-log-stats.svn-base
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+cd /sys/class/atm/ || exit 1
+
+for PORT in solos-pci* ; do
+
+ RXRATE=`cat $PORT/parameters/RxBitRate`
+ TXRATE=`cat $PORT/parameters/TxBitRate`
+ RXSNR=`cat $PORT/parameters/LocalSNRMargin | sed "s/ dB//"`
+ TXSNR=`cat $PORT/parameters/RemoteSNRMargin | sed "s/ dB//"`
+ RXERR=`cat $PORT/parameters/RSUnCorrectedErrorsDn`
+ TXERR=`cat $PORT/parameters/RSUnCorrectedErrorsUp`
+ RXFEC=`cat $PORT/parameters/RSCorrectedErrorsDn`
+ TXFEC=`cat $PORT/parameters/RSCorrectedErrorsUp`
+
+ echo "$RXRATE $RXSNR $RXERR $RXFEC / $TXRATE $TXSNR $TXERR $TXFEC" |
+ logger -t $PORT
+done
+
diff --git a/package/network/config/soloscli/files/etc/.svn/entries b/package/network/config/soloscli/files/etc/.svn/entries
new file mode 100644
index 0000000..32d58cf
--- /dev/null
+++ b/package/network/config/soloscli/files/etc/.svn/entries
@@ -0,0 +1,34 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/config/soloscli/files/etc
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+uci-default
+dir
+
+hotplug.d
+dir
+
diff --git a/package/network/config/soloscli/files/etc/hotplug.d/.svn/entries b/package/network/config/soloscli/files/etc/hotplug.d/.svn/entries
new file mode 100644
index 0000000..7bf0858
--- /dev/null
+++ b/package/network/config/soloscli/files/etc/hotplug.d/.svn/entries
@@ -0,0 +1,31 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/config/soloscli/files/etc/hotplug.d
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+atm
+dir
+
diff --git a/package/network/config/soloscli/files/etc/hotplug.d/atm/.svn/entries b/package/network/config/soloscli/files/etc/hotplug.d/atm/.svn/entries
new file mode 100644
index 0000000..74fbce0
--- /dev/null
+++ b/package/network/config/soloscli/files/etc/hotplug.d/atm/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/config/soloscli/files/etc/hotplug.d/atm
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+15-solos-init
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+08421ddd0319f1c50cbdbad55e77de72
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+483
+
diff --git a/package/network/config/soloscli/files/etc/hotplug.d/atm/.svn/text-base/15-solos-init.svn-base b/package/network/config/soloscli/files/etc/hotplug.d/atm/.svn/text-base/15-solos-init.svn-base
new file mode 100644
index 0000000..36d13ea
--- /dev/null
+++ b/package/network/config/soloscli/files/etc/hotplug.d/atm/.svn/text-base/15-solos-init.svn-base
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+dialog() {
+ local tag="$(echo "$1" | cut -d= -f1)"
+ local value="$(echo "$1" | cut -d= -f2-)"
+ local response
+
+ response="$(soloscli -s "$port" "$tag" "$value")"
+ [ $? -ne 0 ] && {
+ logger "soloscli($port): $tag '$value' returns $response"
+ }
+}
+
+if [ "$ACTION" = "add" ]; then
+ include /lib/network
+ scan_interfaces
+
+ case $DEVICENAME in
+ solos-pci[0-3])
+ port="${DEVICENAME#solos-pci}"
+ device="solos${port}"
+
+ config_list_foreach wan "$device" dialog
+ ;;
+ esac
+fi
diff --git a/package/network/config/soloscli/files/etc/hotplug.d/atm/15-solos-init b/package/network/config/soloscli/files/etc/hotplug.d/atm/15-solos-init
new file mode 100644
index 0000000..36d13ea
--- /dev/null
+++ b/package/network/config/soloscli/files/etc/hotplug.d/atm/15-solos-init
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+dialog() {
+ local tag="$(echo "$1" | cut -d= -f1)"
+ local value="$(echo "$1" | cut -d= -f2-)"
+ local response
+
+ response="$(soloscli -s "$port" "$tag" "$value")"
+ [ $? -ne 0 ] && {
+ logger "soloscli($port): $tag '$value' returns $response"
+ }
+}
+
+if [ "$ACTION" = "add" ]; then
+ include /lib/network
+ scan_interfaces
+
+ case $DEVICENAME in
+ solos-pci[0-3])
+ port="${DEVICENAME#solos-pci}"
+ device="solos${port}"
+
+ config_list_foreach wan "$device" dialog
+ ;;
+ esac
+fi
diff --git a/package/network/config/soloscli/files/etc/uci-default/.svn/entries b/package/network/config/soloscli/files/etc/uci-default/.svn/entries
new file mode 100644
index 0000000..a19d58d
--- /dev/null
+++ b/package/network/config/soloscli/files/etc/uci-default/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/config/soloscli/files/etc/uci-default
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+solos
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+ca2ddd654342ee71329652f4344aa397
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+384
+
diff --git a/package/network/config/soloscli/files/etc/uci-default/.svn/text-base/solos.svn-base b/package/network/config/soloscli/files/etc/uci-default/.svn/text-base/solos.svn-base
new file mode 100644
index 0000000..7f69da6
--- /dev/null
+++ b/package/network/config/soloscli/files/etc/uci-default/.svn/text-base/solos.svn-base
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+uci batch <<__EOF__
+
+delete network.wan.solos0
+
+add_list network.wan.solos0="ActivateLine=Abort"
+add_list network.wan.solos0="Retrain=EnableAll"
+add_list network.wan.solos0="DetectNoise=Enable"
+add_list network.wan.solos0="BisMCapability=Disable"
+add_list network.wan.solos0="BisACapability=Disable"
+add_list network.wan.solos0="ActivateLine=Start"
+
+commit network
+__EOF__
diff --git a/package/network/config/soloscli/files/etc/uci-default/solos b/package/network/config/soloscli/files/etc/uci-default/solos
new file mode 100644
index 0000000..7f69da6
--- /dev/null
+++ b/package/network/config/soloscli/files/etc/uci-default/solos
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+uci batch <<__EOF__
+
+delete network.wan.solos0
+
+add_list network.wan.solos0="ActivateLine=Abort"
+add_list network.wan.solos0="Retrain=EnableAll"
+add_list network.wan.solos0="DetectNoise=Enable"
+add_list network.wan.solos0="BisMCapability=Disable"
+add_list network.wan.solos0="BisACapability=Disable"
+add_list network.wan.solos0="ActivateLine=Start"
+
+commit network
+__EOF__
diff --git a/package/network/config/soloscli/files/solos-log-stats b/package/network/config/soloscli/files/solos-log-stats
new file mode 100644
index 0000000..2b75ee3
--- /dev/null
+++ b/package/network/config/soloscli/files/solos-log-stats
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+cd /sys/class/atm/ || exit 1
+
+for PORT in solos-pci* ; do
+
+ RXRATE=`cat $PORT/parameters/RxBitRate`
+ TXRATE=`cat $PORT/parameters/TxBitRate`
+ RXSNR=`cat $PORT/parameters/LocalSNRMargin | sed "s/ dB//"`
+ TXSNR=`cat $PORT/parameters/RemoteSNRMargin | sed "s/ dB//"`
+ RXERR=`cat $PORT/parameters/RSUnCorrectedErrorsDn`
+ TXERR=`cat $PORT/parameters/RSUnCorrectedErrorsUp`
+ RXFEC=`cat $PORT/parameters/RSCorrectedErrorsDn`
+ TXFEC=`cat $PORT/parameters/RSCorrectedErrorsUp`
+
+ echo "$RXRATE $RXSNR $RXERR $RXFEC / $TXRATE $TXSNR $TXERR $TXFEC" |
+ logger -t $PORT
+done
+
diff --git a/package/network/config/soloscli/patches/.svn/entries b/package/network/config/soloscli/patches/.svn/entries
new file mode 100644
index 0000000..0d1d9d9
--- /dev/null
+++ b/package/network/config/soloscli/patches/.svn/entries
@@ -0,0 +1,96 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/config/soloscli/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+000-Makefile.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+7c037e1d94d88b05963028db355c379f
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+429
+
+001-newline.patch
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+8e93d05cb136c095354595245f252f0c
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+327
+
diff --git a/package/network/config/soloscli/patches/.svn/text-base/000-Makefile.patch.svn-base b/package/network/config/soloscli/patches/.svn/text-base/000-Makefile.patch.svn-base
new file mode 100644
index 0000000..914d6d8
--- /dev/null
+++ b/package/network/config/soloscli/patches/.svn/text-base/000-Makefile.patch.svn-base
@@ -0,0 +1,21 @@
+--- a/Makefile 2010-06-14 14:17:11.000000000 +1000
++++ b/Makefile 2010-06-14 14:17:54.000000000 +1000
+@@ -13,6 +13,11 @@
+ KDIR ?= /lib/modules/$(shell uname -r)/build
+ PWD := $(shell pwd)
+
++soloscli/soloscli:
++ $(MAKE) -C soloscli
++
++install:
++
+ default:
+ $(MAKE) -C $(KDIR) M=$(PWD) modules
+
+@@ -20,5 +25,6 @@
+ rm -f *.o *.ko *.mod.c .*.cmd
+ rm -rf .tmp_versions
+ rm -f Module.symvers
++ $(MAKE) -C soloscli clean
+
+ endif
diff --git a/package/network/config/soloscli/patches/.svn/text-base/001-newline.patch.svn-base b/package/network/config/soloscli/patches/.svn/text-base/001-newline.patch.svn-base
new file mode 100644
index 0000000..4b663e8
--- /dev/null
+++ b/package/network/config/soloscli/patches/.svn/text-base/001-newline.patch.svn-base
@@ -0,0 +1,15 @@
+--- a/soloscli/soloscli.c
++++ b/soloscli/soloscli.c
+@@ -238,7 +238,11 @@
+ }
+ if (strcmp(buf,pid) == 0) {
+ /* printf("Sequence matches.\n"); */
+- printf("%s",bufp);
++ if(buf[(len-1)] == '\n'){
++ printf("%s",bufp);
++ } else {
++ printf("%s\n",bufp);
++ }
+ } else {
+ printf("Sequence incorrect.\n");
+ buf[i] = '\n';
diff --git a/package/network/config/soloscli/patches/000-Makefile.patch b/package/network/config/soloscli/patches/000-Makefile.patch
new file mode 100644
index 0000000..914d6d8
--- /dev/null
+++ b/package/network/config/soloscli/patches/000-Makefile.patch
@@ -0,0 +1,21 @@
+--- a/Makefile 2010-06-14 14:17:11.000000000 +1000
++++ b/Makefile 2010-06-14 14:17:54.000000000 +1000
+@@ -13,6 +13,11 @@
+ KDIR ?= /lib/modules/$(shell uname -r)/build
+ PWD := $(shell pwd)
+
++soloscli/soloscli:
++ $(MAKE) -C soloscli
++
++install:
++
+ default:
+ $(MAKE) -C $(KDIR) M=$(PWD) modules
+
+@@ -20,5 +25,6 @@
+ rm -f *.o *.ko *.mod.c .*.cmd
+ rm -rf .tmp_versions
+ rm -f Module.symvers
++ $(MAKE) -C soloscli clean
+
+ endif
diff --git a/package/network/config/soloscli/patches/001-newline.patch b/package/network/config/soloscli/patches/001-newline.patch
new file mode 100644
index 0000000..4b663e8
--- /dev/null
+++ b/package/network/config/soloscli/patches/001-newline.patch
@@ -0,0 +1,15 @@
+--- a/soloscli/soloscli.c
++++ b/soloscli/soloscli.c
+@@ -238,7 +238,11 @@
+ }
+ if (strcmp(buf,pid) == 0) {
+ /* printf("Sequence matches.\n"); */
+- printf("%s",bufp);
++ if(buf[(len-1)] == '\n'){
++ printf("%s",bufp);
++ } else {
++ printf("%s\n",bufp);
++ }
+ } else {
+ printf("Sequence incorrect.\n");
+ buf[i] = '\n';
diff --git a/package/network/config/swconfig/.svn/entries b/package/network/config/swconfig/.svn/entries
new file mode 100644
index 0000000..4cc868a
--- /dev/null
+++ b/package/network/config/swconfig/.svn/entries
@@ -0,0 +1,68 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/config/swconfig
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-12-14T12:11:50.852722Z
+34679
+juhosg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+files
+dir
+
+src
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+c11bf221290c35e4f3c8a321b186137b
+2012-12-14T12:11:50.852722Z
+34679
+juhosg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1125
+
diff --git a/package/network/config/swconfig/.svn/text-base/Makefile.svn-base b/package/network/config/swconfig/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..76817f0
--- /dev/null
+++ b/package/network/config/swconfig/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,49 @@
+#
+# Copyright (C) 2008-2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=swconfig
+PKG_RELEASE:=10
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+define Package/swconfig
+ SECTION:=base
+ CATEGORY:=Base system
+ DEPENDS:=@!TARGET_brcm47xx +libuci +libnl-tiny
+ TITLE:=Switch configuration utility
+endef
+
+TARGET_CPPFLAGS := \
+ -D_GNU_SOURCE \
+ -I$(STAGING_DIR)/usr/include/libnl-tiny \
+ -I$(PKG_BUILD_DIR) \
+ $(TARGET_CPPFLAGS)
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+define Build/Compile
+ CFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" \
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ $(TARGET_CONFIGURE_OPTS) \
+ LIBS="$(TARGET_LDFLAGS) -lnl-tiny -lm -luci"
+endef
+
+define Package/swconfig/install
+ $(INSTALL_DIR) $(1)/sbin $(1)/lib/network
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/swconfig $(1)/sbin/swconfig
+ $(INSTALL_DATA) ./files/switch.sh $(1)/lib/network/
+endef
+
+$(eval $(call BuildPackage,swconfig))
diff --git a/package/network/config/swconfig/Makefile b/package/network/config/swconfig/Makefile
new file mode 100644
index 0000000..76817f0
--- /dev/null
+++ b/package/network/config/swconfig/Makefile
@@ -0,0 +1,49 @@
+#
+# Copyright (C) 2008-2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=swconfig
+PKG_RELEASE:=10
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+define Package/swconfig
+ SECTION:=base
+ CATEGORY:=Base system
+ DEPENDS:=@!TARGET_brcm47xx +libuci +libnl-tiny
+ TITLE:=Switch configuration utility
+endef
+
+TARGET_CPPFLAGS := \
+ -D_GNU_SOURCE \
+ -I$(STAGING_DIR)/usr/include/libnl-tiny \
+ -I$(PKG_BUILD_DIR) \
+ $(TARGET_CPPFLAGS)
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+define Build/Compile
+ CFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" \
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ $(TARGET_CONFIGURE_OPTS) \
+ LIBS="$(TARGET_LDFLAGS) -lnl-tiny -lm -luci"
+endef
+
+define Package/swconfig/install
+ $(INSTALL_DIR) $(1)/sbin $(1)/lib/network
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/swconfig $(1)/sbin/swconfig
+ $(INSTALL_DATA) ./files/switch.sh $(1)/lib/network/
+endef
+
+$(eval $(call BuildPackage,swconfig))
diff --git a/package/network/config/swconfig/files/.svn/entries b/package/network/config/swconfig/files/.svn/entries
new file mode 100644
index 0000000..348abda
--- /dev/null
+++ b/package/network/config/swconfig/files/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/config/swconfig/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+switch.sh
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+b244d1648b8c524d8945430721f1e61f
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+284
+
diff --git a/package/network/config/swconfig/files/.svn/text-base/switch.sh.svn-base b/package/network/config/swconfig/files/.svn/text-base/switch.sh.svn-base
new file mode 100644
index 0000000..18d5fbd
--- /dev/null
+++ b/package/network/config/swconfig/files/.svn/text-base/switch.sh.svn-base
@@ -0,0 +1,14 @@
+#!/bin/sh
+# Copyright (C) 2009 OpenWrt.org
+
+setup_switch_dev() {
+ config_get name "$1" name
+ name="${name:-$1}"
+ [ -d "/sys/class/net/$name" ] && ifconfig "$name" up
+ swconfig dev "$name" load network
+}
+
+setup_switch() {
+ config_load network
+ config_foreach setup_switch_dev switch
+}
diff --git a/package/network/config/swconfig/files/switch.sh b/package/network/config/swconfig/files/switch.sh
new file mode 100644
index 0000000..18d5fbd
--- /dev/null
+++ b/package/network/config/swconfig/files/switch.sh
@@ -0,0 +1,14 @@
+#!/bin/sh
+# Copyright (C) 2009 OpenWrt.org
+
+setup_switch_dev() {
+ config_get name "$1" name
+ name="${name:-$1}"
+ [ -d "/sys/class/net/$name" ] && ifconfig "$name" up
+ swconfig dev "$name" load network
+}
+
+setup_switch() {
+ config_load network
+ config_foreach setup_switch_dev switch
+}
diff --git a/package/network/config/swconfig/src/.svn/entries b/package/network/config/swconfig/src/.svn/entries
new file mode 100644
index 0000000..e4c62fe
--- /dev/null
+++ b/package/network/config/swconfig/src/.svn/entries
@@ -0,0 +1,198 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/config/swconfig/src
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+swlib.c
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+f330c4f9a949bca067af5461f44ad641
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+13642
+
+uci.c
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+25ab718228809f280e76d88db3413909
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5625
+
+swlib.h
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+df4c8993cd40723d9b4b8368a2fa9a0e
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+6327
+
+cli.c
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+3846fc5eac83531d6e9a778e3ff99f06
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+6861
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+ce9e6e4c852401621f773c0249b6bfb9
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+186
+
diff --git a/package/network/config/swconfig/src/.svn/text-base/Makefile.svn-base b/package/network/config/swconfig/src/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..0d56f43
--- /dev/null
+++ b/package/network/config/swconfig/src/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,12 @@
+ifndef CFLAGS
+CFLAGS = -O2 -g -I ../src
+endif
+LIBS=-lnl -lnl-genl
+
+all: swconfig
+
+%.o: %.c
+ $(CC) $(CFLAGS) -c -o $@ $^
+
+swconfig: cli.o swlib.o uci.o
+ $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
diff --git a/package/network/config/swconfig/src/.svn/text-base/cli.c.svn-base b/package/network/config/swconfig/src/.svn/text-base/cli.c.svn-base
new file mode 100644
index 0000000..9cd16ab
--- /dev/null
+++ b/package/network/config/swconfig/src/.svn/text-base/cli.c.svn-base
@@ -0,0 +1,340 @@
+/*
+ * swconfig.c: Switch configuration utility
+ *
+ * Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
+ * Copyright (C) 2010 Martin Mares <mj@ucw.cz>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundatio.
+ *
+ * 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.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <inttypes.h>
+#include <errno.h>
+#include <stdint.h>
+#include <getopt.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <uci.h>
+
+#include <linux/types.h>
+#include <linux/netlink.h>
+#include <linux/genetlink.h>
+#include <netlink/netlink.h>
+#include <netlink/genl/genl.h>
+#include <netlink/genl/ctrl.h>
+#include <linux/switch.h>
+#include "swlib.h"
+
+enum {
+ CMD_NONE,
+ CMD_GET,
+ CMD_SET,
+ CMD_LOAD,
+ CMD_HELP,
+ CMD_SHOW,
+};
+
+static void
+print_attrs(const struct switch_attr *attr)
+{
+ int i = 0;
+ while (attr) {
+ const char *type;
+ switch(attr->type) {
+ case SWITCH_TYPE_INT:
+ type = "int";
+ break;
+ case SWITCH_TYPE_STRING:
+ type = "string";
+ break;
+ case SWITCH_TYPE_PORTS:
+ type = "ports";
+ break;
+ case SWITCH_TYPE_NOVAL:
+ type = "none";
+ break;
+ default:
+ type = "unknown";
+ break;
+ }
+ printf("\tAttribute %d (%s): %s (%s)\n", ++i, type, attr->name, attr->description);
+ attr = attr->next;
+ }
+}
+
+static void
+list_attributes(struct switch_dev *dev)
+{
+ printf("%s: %s(%s), ports: %d (cpu @ %d), vlans: %d\n", dev->dev_name, dev->alias, dev->name, dev->ports, dev->cpu_port, dev->vlans);
+ printf(" --switch\n");
+ print_attrs(dev->ops);
+ printf(" --vlan\n");
+ print_attrs(dev->vlan_ops);
+ printf(" --port\n");
+ print_attrs(dev->port_ops);
+}
+
+static void
+print_attr_val(const struct switch_attr *attr, const struct switch_val *val)
+{
+ int i;
+
+ switch (attr->type) {
+ case SWITCH_TYPE_INT:
+ printf("%d", val->value.i);
+ break;
+ case SWITCH_TYPE_STRING:
+ printf("%s", val->value.s);
+ break;
+ case SWITCH_TYPE_PORTS:
+ for(i = 0; i < val->len; i++) {
+ printf("%d%s ",
+ val->value.ports[i].id,
+ (val->value.ports[i].flags &
+ SWLIB_PORT_FLAG_TAGGED) ? "t" : "");
+ }
+ break;
+ default:
+ printf("?unknown-type?");
+ }
+}
+
+static void
+show_attrs(struct switch_dev *dev, struct switch_attr *attr, struct switch_val *val)
+{
+ while (attr) {
+ if (attr->type != SWITCH_TYPE_NOVAL) {
+ printf("\t%s: ", attr->name);
+ if (swlib_get_attr(dev, attr, val) < 0)
+ printf("???");
+ else
+ print_attr_val(attr, val);
+ putchar('\n');
+ }
+ attr = attr->next;
+ }
+}
+
+static void
+show_global(struct switch_dev *dev)
+{
+ struct switch_val val;
+
+ printf("Global attributes:\n");
+ show_attrs(dev, dev->ops, &val);
+}
+
+static void
+show_port(struct switch_dev *dev, int port)
+{
+ struct switch_val val;
+
+ printf("Port %d:\n", port);
+ val.port_vlan = port;
+ show_attrs(dev, dev->port_ops, &val);
+}
+
+static void
+show_vlan(struct switch_dev *dev, int vlan, bool all)
+{
+ struct switch_val val;
+ struct switch_attr *attr;
+
+ val.port_vlan = vlan;
+
+ if (all) {
+ attr = swlib_lookup_attr(dev, SWLIB_ATTR_GROUP_VLAN, "ports");
+ if (swlib_get_attr(dev, attr, &val) < 0)
+ return;
+
+ if (!val.len)
+ return;
+ }
+
+ printf("VLAN %d:\n", vlan);
+ show_attrs(dev, dev->vlan_ops, &val);
+}
+
+static void
+print_usage(void)
+{
+ printf("swconfig dev <dev> [port <port>|vlan <vlan>] (help|set <key> <value>|get <key>|load <config>|show)\n");
+ exit(1);
+}
+
+static void
+swconfig_load_uci(struct switch_dev *dev, const char *name)
+{
+ struct uci_context *ctx;
+ struct uci_package *p = NULL;
+ struct uci_element *e;
+ int ret = -1;
+
+ ctx = uci_alloc_context();
+ if (!ctx)
+ return;
+
+ uci_load(ctx, name, &p);
+ if (!p) {
+ uci_perror(ctx, "Failed to load config file: ");
+ goto out;
+ }
+
+ ret = swlib_apply_from_uci(dev, p);
+ if (ret < 0)
+ fprintf(stderr, "Failed to apply configuration for switch '%s'\n", dev->dev_name);
+
+out:
+ uci_free_context(ctx);
+ exit(ret);
+}
+
+int main(int argc, char **argv)
+{
+ int retval = 0;
+ struct switch_dev *dev;
+ struct switch_attr *a;
+ struct switch_val val;
+ int err;
+ int i;
+
+ int cmd = CMD_NONE;
+ char *cdev = NULL;
+ int cport = -1;
+ int cvlan = -1;
+ char *ckey = NULL;
+ char *cvalue = NULL;
+
+ if(argc < 4)
+ print_usage();
+
+ if(strcmp(argv[1], "dev"))
+ print_usage();
+
+ cdev = argv[2];
+
+ for(i = 3; i < argc; i++)
+ {
+ char *arg = argv[i];
+ if (cmd != CMD_NONE) {
+ print_usage();
+ } else if (!strcmp(arg, "port") && i+1 < argc) {
+ cport = atoi(argv[++i]);
+ } else if (!strcmp(arg, "vlan") && i+1 < argc) {
+ cvlan = atoi(argv[++i]);
+ } else if (!strcmp(arg, "help")) {
+ cmd = CMD_HELP;
+ } else if (!strcmp(arg, "set") && i+1 < argc) {
+ cmd = CMD_SET;
+ ckey = argv[++i];
+ if (i+1 < argc)
+ cvalue = argv[++i];
+ } else if (!strcmp(arg, "get") && i+1 < argc) {
+ cmd = CMD_GET;
+ ckey = argv[++i];
+ } else if (!strcmp(arg, "load") && i+1 < argc) {
+ if ((cport >= 0) || (cvlan >= 0))
+ print_usage();
+ cmd = CMD_LOAD;
+ ckey = argv[++i];
+ } else if (!strcmp(arg, "show")) {
+ cmd = CMD_SHOW;
+ } else {
+ print_usage();
+ }
+ }
+
+ if (cmd == CMD_NONE)
+ print_usage();
+ if (cport > -1 && cvlan > -1)
+ print_usage();
+
+ dev = swlib_connect(cdev);
+ if (!dev) {
+ fprintf(stderr, "Failed to connect to the switch\n");
+ return 1;
+ }
+
+ swlib_scan(dev);
+
+ if (cmd == CMD_GET || cmd == CMD_SET) {
+ if(cport > -1)
+ a = swlib_lookup_attr(dev, SWLIB_ATTR_GROUP_PORT, ckey);
+ else if(cvlan > -1)
+ a = swlib_lookup_attr(dev, SWLIB_ATTR_GROUP_VLAN, ckey);
+ else
+ a = swlib_lookup_attr(dev, SWLIB_ATTR_GROUP_GLOBAL, ckey);
+
+ if(!a)
+ {
+ fprintf(stderr, "Unknown attribute \"%s\"\n", ckey);
+ goto out;
+ }
+ }
+
+ switch(cmd)
+ {
+ case CMD_SET:
+ if ((a->type != SWITCH_TYPE_NOVAL) &&
+ (cvalue == NULL))
+ print_usage();
+
+ if(cvlan > -1)
+ cport = cvlan;
+
+ if(swlib_set_attr_string(dev, a, cport, cvalue) < 0)
+ {
+ fprintf(stderr, "failed\n");
+ retval = -1;
+ goto out;
+ }
+ break;
+ case CMD_GET:
+ if(cvlan > -1)
+ val.port_vlan = cvlan;
+ if(cport > -1)
+ val.port_vlan = cport;
+ if(swlib_get_attr(dev, a, &val) < 0)
+ {
+ fprintf(stderr, "failed\n");
+ retval = -1;
+ goto out;
+ }
+ print_attr_val(a, &val);
+ putchar('\n');
+ break;
+ case CMD_LOAD:
+ swconfig_load_uci(dev, ckey);
+ break;
+ case CMD_HELP:
+ list_attributes(dev);
+ break;
+ case CMD_SHOW:
+ if (cport >= 0 || cvlan >= 0) {
+ if (cport >= 0)
+ show_port(dev, cport);
+ else
+ show_vlan(dev, cvlan, false);
+ } else {
+ show_global(dev);
+ for (i=0; i < dev->ports; i++)
+ show_port(dev, i);
+ for (i=0; i < dev->vlans; i++)
+ show_vlan(dev, i, true);
+ }
+ break;
+ }
+
+out:
+ swlib_free_all(dev);
+ return 0;
+}
diff --git a/package/network/config/swconfig/src/.svn/text-base/swlib.c.svn-base b/package/network/config/swconfig/src/.svn/text-base/swlib.c.svn-base
new file mode 100644
index 0000000..de08717
--- /dev/null
+++ b/package/network/config/swconfig/src/.svn/text-base/swlib.c.svn-base
@@ -0,0 +1,686 @@
+/*
+ * swlib.c: Switch configuration API (user space part)
+ *
+ * Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * 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.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <inttypes.h>
+#include <errno.h>
+#include <stdint.h>
+#include <getopt.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <linux/switch.h>
+#include "swlib.h"
+#include <netlink/netlink.h>
+#include <netlink/genl/genl.h>
+#include <netlink/genl/family.h>
+
+//#define DEBUG 1
+#ifdef DEBUG
+#define DPRINTF(fmt, ...) fprintf(stderr, "%s(%d): " fmt, __func__, __LINE__, ##__VA_ARGS__)
+#else
+#define DPRINTF(fmt, ...) do {} while (0)
+#endif
+
+static struct nl_sock *handle;
+static struct nl_cache *cache;
+static struct genl_family *family;
+static struct nlattr *tb[SWITCH_ATTR_MAX + 1];
+static int refcount = 0;
+
+static struct nla_policy port_policy[] = {
+ [SWITCH_PORT_ID] = { .type = NLA_U32 },
+ [SWITCH_PORT_FLAG_TAGGED] = { .type = NLA_FLAG },
+};
+
+static inline void *
+swlib_alloc(size_t size)
+{
+ void *ptr;
+
+ ptr = malloc(size);
+ if (!ptr)
+ goto done;
+ memset(ptr, 0, size);
+
+done:
+ return ptr;
+}
+
+static int
+wait_handler(struct nl_msg *msg, void *arg)
+{
+ int *finished = arg;
+
+ *finished = 1;
+ return NL_STOP;
+}
+
+/* helper function for performing netlink requests */
+static int
+swlib_call(int cmd, int (*call)(struct nl_msg *, void *),
+ int (*data)(struct nl_msg *, void *), void *arg)
+{
+ struct nl_msg *msg;
+ struct nl_cb *cb = NULL;
+ int finished;
+ int flags = 0;
+ int err;
+
+ msg = nlmsg_alloc();
+ if (!msg) {
+ fprintf(stderr, "Out of memory!\n");
+ exit(1);
+ }
+
+ if (!data)
+ flags |= NLM_F_DUMP;
+
+ genlmsg_put(msg, NL_AUTO_PID, NL_AUTO_SEQ, genl_family_get_id(family), 0, flags, cmd, 0);
+ if (data) {
+ if (data(msg, arg) < 0)
+ goto nla_put_failure;
+ }
+
+ cb = nl_cb_alloc(NL_CB_CUSTOM);
+ if (!cb) {
+ fprintf(stderr, "nl_cb_alloc failed.\n");
+ exit(1);
+ }
+
+ err = nl_send_auto_complete(handle, msg);
+ if (err < 0) {
+ fprintf(stderr, "nl_send_auto_complete failed: %d\n", err);
+ goto out;
+ }
+
+ finished = 0;
+
+ if (call)
+ nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, call, arg);
+
+ if (data)
+ nl_cb_set(cb, NL_CB_ACK, NL_CB_CUSTOM, wait_handler, &finished);
+ else
+ nl_cb_set(cb, NL_CB_FINISH, NL_CB_CUSTOM, wait_handler, &finished);
+
+ err = nl_recvmsgs(handle, cb);
+ if (err < 0) {
+ goto out;
+ }
+
+ if (!finished)
+ err = nl_wait_for_ack(handle);
+
+out:
+ if (cb)
+ nl_cb_put(cb);
+nla_put_failure:
+ nlmsg_free(msg);
+ return err;
+}
+
+static int
+send_attr(struct nl_msg *msg, void *arg)
+{
+ struct switch_val *val = arg;
+ struct switch_attr *attr = val->attr;
+
+ NLA_PUT_U32(msg, SWITCH_ATTR_ID, attr->dev->id);
+ NLA_PUT_U32(msg, SWITCH_ATTR_OP_ID, attr->id);
+ switch(attr->atype) {
+ case SWLIB_ATTR_GROUP_PORT:
+ NLA_PUT_U32(msg, SWITCH_ATTR_OP_PORT, val->port_vlan);
+ break;
+ case SWLIB_ATTR_GROUP_VLAN:
+ NLA_PUT_U32(msg, SWITCH_ATTR_OP_VLAN, val->port_vlan);
+ break;
+ default:
+ break;
+ }
+
+ return 0;
+
+nla_put_failure:
+ return -1;
+}
+
+static int
+store_port_val(struct nl_msg *msg, struct nlattr *nla, struct switch_val *val)
+{
+ struct nlattr *p;
+ int ports = val->attr->dev->ports;
+ int err = 0;
+ int remaining;
+
+ if (!val->value.ports)
+ val->value.ports = malloc(sizeof(struct switch_port) * ports);
+
+ nla_for_each_nested(p, nla, remaining) {
+ struct nlattr *tb[SWITCH_PORT_ATTR_MAX+1];
+ struct switch_port *port;
+
+ if (val->len >= ports)
+ break;
+
+ err = nla_parse_nested(tb, SWITCH_PORT_ATTR_MAX, p, port_policy);
+ if (err < 0)
+ goto out;
+
+ if (!tb[SWITCH_PORT_ID])
+ continue;
+
+ port = &val->value.ports[val->len];
+ port->id = nla_get_u32(tb[SWITCH_PORT_ID]);
+ port->flags = 0;
+ if (tb[SWITCH_PORT_FLAG_TAGGED])
+ port->flags |= SWLIB_PORT_FLAG_TAGGED;
+
+ val->len++;
+ }
+
+out:
+ return err;
+}
+
+static int
+store_val(struct nl_msg *msg, void *arg)
+{
+ struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
+ struct switch_val *val = arg;
+ struct switch_attr *attr = val->attr;
+
+ if (!val)
+ goto error;
+
+ if (nla_parse(tb, SWITCH_ATTR_MAX - 1, genlmsg_attrdata(gnlh, 0),
+ genlmsg_attrlen(gnlh, 0), NULL) < 0) {
+ goto error;
+ }
+
+ if (tb[SWITCH_ATTR_OP_VALUE_INT])
+ val->value.i = nla_get_u32(tb[SWITCH_ATTR_OP_VALUE_INT]);
+ else if (tb[SWITCH_ATTR_OP_VALUE_STR])
+ val->value.s = strdup(nla_get_string(tb[SWITCH_ATTR_OP_VALUE_STR]));
+ else if (tb[SWITCH_ATTR_OP_VALUE_PORTS])
+ val->err = store_port_val(msg, tb[SWITCH_ATTR_OP_VALUE_PORTS], val);
+
+ val->err = 0;
+ return 0;
+
+error:
+ return NL_SKIP;
+}
+
+int
+swlib_get_attr(struct switch_dev *dev, struct switch_attr *attr, struct switch_val *val)
+{
+ int cmd;
+ int err;
+
+ switch(attr->atype) {
+ case SWLIB_ATTR_GROUP_GLOBAL:
+ cmd = SWITCH_CMD_GET_GLOBAL;
+ break;
+ case SWLIB_ATTR_GROUP_PORT:
+ cmd = SWITCH_CMD_GET_PORT;
+ break;
+ case SWLIB_ATTR_GROUP_VLAN:
+ cmd = SWITCH_CMD_GET_VLAN;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ memset(&val->value, 0, sizeof(val->value));
+ val->len = 0;
+ val->attr = attr;
+ val->err = -EINVAL;
+ err = swlib_call(cmd, store_val, send_attr, val);
+ if (!err)
+ err = val->err;
+
+ return err;
+}
+
+static int
+send_attr_ports(struct nl_msg *msg, struct switch_val *val)
+{
+ struct nlattr *n;
+ int i;
+
+ /* TODO implement multipart? */
+ if (val->len == 0)
+ goto done;
+ n = nla_nest_start(msg, SWITCH_ATTR_OP_VALUE_PORTS);
+ if (!n)
+ goto nla_put_failure;
+ for (i = 0; i < val->len; i++) {
+ struct switch_port *port = &val->value.ports[i];
+ struct nlattr *np;
+
+ np = nla_nest_start(msg, SWITCH_ATTR_PORT);
+ if (!np)
+ goto nla_put_failure;
+
+ NLA_PUT_U32(msg, SWITCH_PORT_ID, port->id);
+ if (port->flags & SWLIB_PORT_FLAG_TAGGED)
+ NLA_PUT_FLAG(msg, SWITCH_PORT_FLAG_TAGGED);
+
+ nla_nest_end(msg, np);
+ }
+ nla_nest_end(msg, n);
+done:
+ return 0;
+
+nla_put_failure:
+ return -1;
+}
+
+static int
+send_attr_val(struct nl_msg *msg, void *arg)
+{
+ struct switch_val *val = arg;
+ struct switch_attr *attr = val->attr;
+
+ if (send_attr(msg, arg))
+ goto nla_put_failure;
+
+ switch(attr->type) {
+ case SWITCH_TYPE_NOVAL:
+ break;
+ case SWITCH_TYPE_INT:
+ NLA_PUT_U32(msg, SWITCH_ATTR_OP_VALUE_INT, val->value.i);
+ break;
+ case SWITCH_TYPE_STRING:
+ if (!val->value.s)
+ goto nla_put_failure;
+ NLA_PUT_STRING(msg, SWITCH_ATTR_OP_VALUE_STR, val->value.s);
+ break;
+ case SWITCH_TYPE_PORTS:
+ if (send_attr_ports(msg, val) < 0)
+ goto nla_put_failure;
+ break;
+ default:
+ goto nla_put_failure;
+ }
+ return 0;
+
+nla_put_failure:
+ return -1;
+}
+
+int
+swlib_set_attr(struct switch_dev *dev, struct switch_attr *attr, struct switch_val *val)
+{
+ int cmd;
+
+ switch(attr->atype) {
+ case SWLIB_ATTR_GROUP_GLOBAL:
+ cmd = SWITCH_CMD_SET_GLOBAL;
+ break;
+ case SWLIB_ATTR_GROUP_PORT:
+ cmd = SWITCH_CMD_SET_PORT;
+ break;
+ case SWLIB_ATTR_GROUP_VLAN:
+ cmd = SWITCH_CMD_SET_VLAN;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ val->attr = attr;
+ return swlib_call(cmd, NULL, send_attr_val, val);
+}
+
+int swlib_set_attr_string(struct switch_dev *dev, struct switch_attr *a, int port_vlan, const char *str)
+{
+ struct switch_port *ports;
+ struct switch_val val;
+ char *ptr;
+
+ memset(&val, 0, sizeof(val));
+ val.port_vlan = port_vlan;
+ switch(a->type) {
+ case SWITCH_TYPE_INT:
+ val.value.i = atoi(str);
+ break;
+ case SWITCH_TYPE_STRING:
+ val.value.s = str;
+ break;
+ case SWITCH_TYPE_PORTS:
+ ports = alloca(sizeof(struct switch_port) * dev->ports);
+ memset(ports, 0, sizeof(struct switch_port) * dev->ports);
+ val.len = 0;
+ ptr = (char *)str;
+ while(ptr && *ptr)
+ {
+ while(*ptr && isspace(*ptr))
+ ptr++;
+
+ if (!*ptr)
+ break;
+
+ if (!isdigit(*ptr))
+ return -1;
+
+ if (val.len >= dev->ports)
+ return -1;
+
+ ports[val.len].flags = 0;
+ ports[val.len].id = strtoul(ptr, &ptr, 10);
+ while(*ptr && !isspace(*ptr)) {
+ if (*ptr == 't')
+ ports[val.len].flags |= SWLIB_PORT_FLAG_TAGGED;
+ else
+ return -1;
+
+ ptr++;
+ }
+ if (*ptr)
+ ptr++;
+ val.len++;
+ }
+ val.value.ports = ports;
+ break;
+ case SWITCH_TYPE_NOVAL:
+ if (str && !strcmp(str, "0"))
+ return 0;
+
+ break;
+ default:
+ return -1;
+ }
+ return swlib_set_attr(dev, a, &val);
+}
+
+
+struct attrlist_arg {
+ int id;
+ int atype;
+ struct switch_dev *dev;
+ struct switch_attr *prev;
+ struct switch_attr **head;
+};
+
+static int
+add_id(struct nl_msg *msg, void *arg)
+{
+ struct attrlist_arg *l = arg;
+
+ NLA_PUT_U32(msg, SWITCH_ATTR_ID, l->id);
+
+ return 0;
+nla_put_failure:
+ return -1;
+}
+
+static int
+add_attr(struct nl_msg *msg, void *ptr)
+{
+ struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
+ struct attrlist_arg *arg = ptr;
+ struct switch_attr *new;
+
+ if (nla_parse(tb, SWITCH_ATTR_MAX - 1, genlmsg_attrdata(gnlh, 0),
+ genlmsg_attrlen(gnlh, 0), NULL) < 0)
+ goto done;
+
+ new = swlib_alloc(sizeof(struct switch_attr));
+ if (!new)
+ goto done;
+
+ new->dev = arg->dev;
+ new->atype = arg->atype;
+ if (arg->prev) {
+ arg->prev->next = new;
+ } else {
+ arg->prev = *arg->head;
+ }
+ *arg->head = new;
+ arg->head = &new->next;
+
+ if (tb[SWITCH_ATTR_OP_ID])
+ new->id = nla_get_u32(tb[SWITCH_ATTR_OP_ID]);
+ if (tb[SWITCH_ATTR_OP_TYPE])
+ new->type = nla_get_u32(tb[SWITCH_ATTR_OP_TYPE]);
+ if (tb[SWITCH_ATTR_OP_NAME])
+ new->name = strdup(nla_get_string(tb[SWITCH_ATTR_OP_NAME]));
+ if (tb[SWITCH_ATTR_OP_DESCRIPTION])
+ new->description = strdup(nla_get_string(tb[SWITCH_ATTR_OP_DESCRIPTION]));
+
+done:
+ return NL_SKIP;
+}
+
+int
+swlib_scan(struct switch_dev *dev)
+{
+ struct attrlist_arg arg;
+
+ if (dev->ops || dev->port_ops || dev->vlan_ops)
+ return 0;
+
+ arg.atype = SWLIB_ATTR_GROUP_GLOBAL;
+ arg.dev = dev;
+ arg.id = dev->id;
+ arg.prev = NULL;
+ arg.head = &dev->ops;
+ swlib_call(SWITCH_CMD_LIST_GLOBAL, add_attr, add_id, &arg);
+
+ arg.atype = SWLIB_ATTR_GROUP_PORT;
+ arg.prev = NULL;
+ arg.head = &dev->port_ops;
+ swlib_call(SWITCH_CMD_LIST_PORT, add_attr, add_id, &arg);
+
+ arg.atype = SWLIB_ATTR_GROUP_VLAN;
+ arg.prev = NULL;
+ arg.head = &dev->vlan_ops;
+ swlib_call(SWITCH_CMD_LIST_VLAN, add_attr, add_id, &arg);
+
+ return 0;
+}
+
+struct switch_attr *swlib_lookup_attr(struct switch_dev *dev,
+ enum swlib_attr_group atype, const char *name)
+{
+ struct switch_attr *head;
+
+ if (!name || !dev)
+ return NULL;
+
+ switch(atype) {
+ case SWLIB_ATTR_GROUP_GLOBAL:
+ head = dev->ops;
+ break;
+ case SWLIB_ATTR_GROUP_PORT:
+ head = dev->port_ops;
+ break;
+ case SWLIB_ATTR_GROUP_VLAN:
+ head = dev->vlan_ops;
+ break;
+ }
+ while(head) {
+ if (!strcmp(name, head->name))
+ return head;
+ head = head->next;
+ }
+
+ return NULL;
+}
+
+static void
+swlib_priv_free(void)
+{
+ if (cache)
+ nl_cache_free(cache);
+ if (handle)
+ nl_socket_free(handle);
+ handle = NULL;
+ cache = NULL;
+}
+
+static int
+swlib_priv_init(void)
+{
+ int ret;
+
+ handle = nl_socket_alloc();
+ if (!handle) {
+ DPRINTF("Failed to create handle\n");
+ goto err;
+ }
+
+ if (genl_connect(handle)) {
+ DPRINTF("Failed to connect to generic netlink\n");
+ goto err;
+ }
+
+ ret = genl_ctrl_alloc_cache(handle, &cache);
+ if (ret < 0) {
+ DPRINTF("Failed to allocate netlink cache\n");
+ goto err;
+ }
+
+ family = genl_ctrl_search_by_name(cache, "switch");
+ if (!family) {
+ DPRINTF("Switch API not present\n");
+ goto err;
+ }
+ return 0;
+
+err:
+ swlib_priv_free();
+ return -EINVAL;
+}
+
+struct swlib_scan_arg {
+ const char *name;
+ struct switch_dev *head;
+ struct switch_dev *ptr;
+};
+
+static int
+add_switch(struct nl_msg *msg, void *arg)
+{
+ struct swlib_scan_arg *sa = arg;
+ struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
+ struct switch_dev *dev;
+ const char *name;
+ const char *alias;
+
+ if (nla_parse(tb, SWITCH_ATTR_MAX, genlmsg_attrdata(gnlh, 0), genlmsg_attrlen(gnlh, 0), NULL) < 0)
+ goto done;
+
+ if (!tb[SWITCH_ATTR_DEV_NAME])
+ goto done;
+
+ name = nla_get_string(tb[SWITCH_ATTR_DEV_NAME]);
+ alias = nla_get_string(tb[SWITCH_ATTR_ALIAS]);
+
+ if (sa->name && (strcmp(name, sa->name) != 0) && (strcmp(alias, sa->name) != 0))
+ goto done;
+
+ dev = swlib_alloc(sizeof(struct switch_dev));
+ if (!dev)
+ goto done;
+
+ strncpy(dev->dev_name, name, IFNAMSIZ - 1);
+ dev->alias = strdup(alias);
+ if (tb[SWITCH_ATTR_ID])
+ dev->id = nla_get_u32(tb[SWITCH_ATTR_ID]);
+ if (tb[SWITCH_ATTR_NAME])
+ dev->name = strdup(nla_get_string(tb[SWITCH_ATTR_NAME]));
+ if (tb[SWITCH_ATTR_PORTS])
+ dev->ports = nla_get_u32(tb[SWITCH_ATTR_PORTS]);
+ if (tb[SWITCH_ATTR_VLANS])
+ dev->vlans = nla_get_u32(tb[SWITCH_ATTR_VLANS]);
+ if (tb[SWITCH_ATTR_CPU_PORT])
+ dev->cpu_port = nla_get_u32(tb[SWITCH_ATTR_CPU_PORT]);
+
+ if (!sa->head) {
+ sa->head = dev;
+ sa->ptr = dev;
+ } else {
+ sa->ptr->next = dev;
+ sa->ptr = dev;
+ }
+
+ refcount++;
+done:
+ return NL_SKIP;
+}
+
+
+struct switch_dev *
+swlib_connect(const char *name)
+{
+ struct swlib_scan_arg arg;
+ int err;
+
+ if (!refcount) {
+ if (swlib_priv_init() < 0)
+ return NULL;
+ };
+
+ arg.head = NULL;
+ arg.ptr = NULL;
+ arg.name = name;
+ swlib_call(SWITCH_CMD_GET_SWITCH, add_switch, NULL, &arg);
+
+ if (!refcount)
+ swlib_priv_free();
+
+ return arg.head;
+}
+
+static void
+swlib_free_attributes(struct switch_attr **head)
+{
+ struct switch_attr *a = *head;
+ struct switch_attr *next;
+
+ while (a) {
+ next = a->next;
+ free(a);
+ a = next;
+ }
+ *head = NULL;
+}
+
+void
+swlib_free(struct switch_dev *dev)
+{
+ swlib_free_attributes(&dev->ops);
+ swlib_free_attributes(&dev->port_ops);
+ swlib_free_attributes(&dev->vlan_ops);
+ free(dev);
+
+ if (--refcount == 0)
+ swlib_priv_free();
+}
+
+void
+swlib_free_all(struct switch_dev *dev)
+{
+ struct switch_dev *p;
+
+ while (dev) {
+ p = dev->next;
+ swlib_free(dev);
+ dev = p;
+ }
+}
diff --git a/package/network/config/swconfig/src/.svn/text-base/swlib.h.svn-base b/package/network/config/swconfig/src/.svn/text-base/swlib.h.svn-base
new file mode 100644
index 0000000..ff73969
--- /dev/null
+++ b/package/network/config/swconfig/src/.svn/text-base/swlib.h.svn-base
@@ -0,0 +1,234 @@
+/*
+ * swlib.h: Switch configuration API (user space part)
+ *
+ * Copyright (C) 2008-2009 Felix Fietkau <nbd@openwrt.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * 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.
+ *
+
+Usage of the library functions:
+
+ The main datastructure for a switch is the struct switch_device
+ To get started, you first need to use switch_connect() to probe
+ for switches and allocate an instance of this struct.
+
+ There are two possible usage modes:
+ dev = switch_connect("eth0");
+ - this call will look for a switch registered for the linux device
+ "eth0" and only allocate a switch_device for this particular switch.
+
+ dev = switch_connect(NULL)
+ - this will return one switch_device struct for each available
+ switch. The switch_device structs are chained with by ->next pointer
+
+ Then to query a switch for all available attributes, use:
+ swlib_scan(dev);
+
+ All allocated datastructures for the switch_device struct can be freed with
+ swlib_free(dev);
+ or
+ swlib_free_all(dev);
+
+ The latter traverses a whole chain of switch_device structs and frees them all
+
+ Switch attributes (struct switch_attr) are divided into three groups:
+ dev->ops:
+ - global settings
+ dev->port_ops:
+ - per-port settings
+ dev->vlan_ops:
+ - per-vlan settings
+
+ switch_lookup_attr() is a small helper function to locate attributes
+ by name.
+
+ switch_set_attr() and switch_get_attr() can alter or request the values
+ of attributes.
+
+Usage of the switch_attr struct:
+
+ ->atype: attribute group, one of:
+ - SWLIB_ATTR_GROUP_GLOBAL
+ - SWLIB_ATTR_GROUP_VLAN
+ - SWLIB_ATTR_GROUP_PORT
+
+ ->id: identifier for the attribute
+
+ ->type: data type, one of:
+ - SWITCH_TYPE_INT
+ - SWITCH_TYPE_STRING
+ - SWITCH_TYPE_PORT
+
+ ->name: short name of the attribute
+ ->description: longer description
+ ->next: pointer to the next attribute of the current group
+
+
+Usage of the switch_val struct:
+
+ When setting attributes, following members of the struct switch_val need
+ to be set up:
+
+ ->len (for attr->type == SWITCH_TYPE_PORT)
+ ->port_vlan:
+ - port number (for attr->atype == SWLIB_ATTR_GROUP_PORT), or:
+ - vlan number (for attr->atype == SWLIB_ATTR_GROUP_VLAN)
+ ->value.i (for attr->type == SWITCH_TYPE_INT)
+ ->value.s (for attr->type == SWITCH_TYPE_STRING)
+ - owned by the caller, not stored in the library internally
+ ->value.ports (for attr->type == SWITCH_TYPE_PORT)
+ - must point to an array of at lest val->len * sizeof(struct switch_port)
+
+ When getting string attributes, val->value.s must be freed by the caller
+ When getting port list attributes, an internal static buffer is used,
+ which changes from call to call.
+
+ */
+
+#ifndef __SWLIB_H
+#define __SWLIB_H
+
+enum swlib_attr_group {
+ SWLIB_ATTR_GROUP_GLOBAL,
+ SWLIB_ATTR_GROUP_VLAN,
+ SWLIB_ATTR_GROUP_PORT,
+};
+
+enum swlib_port_flags {
+ SWLIB_PORT_FLAG_TAGGED = (1 << 0),
+};
+
+
+struct switch_dev;
+struct switch_attr;
+struct switch_port;
+struct switch_val;
+struct uci_package;
+
+struct switch_dev {
+ int id;
+ char dev_name[IFNAMSIZ];
+ const char *name;
+ const char *alias;
+ int ports;
+ int vlans;
+ int cpu_port;
+ struct switch_attr *ops;
+ struct switch_attr *port_ops;
+ struct switch_attr *vlan_ops;
+ struct switch_dev *next;
+ void *priv;
+};
+
+struct switch_val {
+ struct switch_attr *attr;
+ int len;
+ int err;
+ int port_vlan;
+ union {
+ const char *s;
+ int i;
+ struct switch_port *ports;
+ } value;
+};
+
+struct switch_attr {
+ struct switch_dev *dev;
+ int atype;
+ int id;
+ int type;
+ const char *name;
+ const char *description;
+ struct switch_attr *next;
+};
+
+struct switch_port {
+ unsigned int id;
+ unsigned int flags;
+};
+
+/**
+ * swlib_connect: connect to the switch through netlink
+ * @name: name of the ethernet interface,
+ *
+ * if name is NULL, it connect and builds a chain of all switches
+ */
+struct switch_dev *swlib_connect(const char *name);
+
+/**
+ * swlib_free: free all dynamically allocated data for the switch connection
+ * @dev: switch device struct
+ *
+ * all members of a switch device chain (generated by swlib_connect(NULL))
+ * must be freed individually
+ */
+void swlib_free(struct switch_dev *dev);
+
+/**
+ * swlib_free_all: run swlib_free on all devices in the chain
+ * @dev: switch device struct
+ */
+void swlib_free_all(struct switch_dev *dev);
+
+/**
+ * swlib_scan: probe the switch driver for available commands/attributes
+ * @dev: switch device struct
+ */
+int swlib_scan(struct switch_dev *dev);
+
+/**
+ * swlib_lookup_attr: look up a switch attribute
+ * @dev: switch device struct
+ * @type: global, port or vlan
+ * @name: name of the attribute
+ */
+struct switch_attr *swlib_lookup_attr(struct switch_dev *dev,
+ enum swlib_attr_group atype, const char *name);
+
+/**
+ * swlib_set_attr: set the value for an attribute
+ * @dev: switch device struct
+ * @attr: switch attribute struct
+ * @val: attribute value pointer
+ * returns 0 on success
+ */
+int swlib_set_attr(struct switch_dev *dev, struct switch_attr *attr,
+ struct switch_val *val);
+
+/**
+ * swlib_set_attr_string: set the value for an attribute with type conversion
+ * @dev: switch device struct
+ * @attr: switch attribute struct
+ * @port_vlan: port or vlan (if applicable)
+ * @str: string value
+ * returns 0 on success
+ */
+int swlib_set_attr_string(struct switch_dev *dev, struct switch_attr *attr,
+ int port_vlan, const char *str);
+
+/**
+ * swlib_get_attr: get the value for an attribute
+ * @dev: switch device struct
+ * @attr: switch attribute struct
+ * @val: attribute value pointer
+ * returns 0 on success
+ * for string attributes, the result string must be freed by the caller
+ */
+int swlib_get_attr(struct switch_dev *dev, struct switch_attr *attr,
+ struct switch_val *val);
+
+/**
+ * swlib_apply_from_uci: set up the switch from a uci configuration
+ * @dev: switch device struct
+ * @p: uci package which contains the desired global config
+ */
+int swlib_apply_from_uci(struct switch_dev *dev, struct uci_package *p);
+
+#endif
diff --git a/package/network/config/swconfig/src/.svn/text-base/uci.c.svn-base b/package/network/config/swconfig/src/.svn/text-base/uci.c.svn-base
new file mode 100644
index 0000000..893e3d1
--- /dev/null
+++ b/package/network/config/swconfig/src/.svn/text-base/uci.c.svn-base
@@ -0,0 +1,248 @@
+/*
+ * uci.c: UCI binding for the switch configuration utility
+ *
+ * Copyright (C) 2009 Felix Fietkau <nbd@openwrt.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundatio.
+ *
+ * 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.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <inttypes.h>
+#include <errno.h>
+#include <stdint.h>
+#include <getopt.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <uci.h>
+
+#include <linux/types.h>
+#include <linux/netlink.h>
+#include <linux/genetlink.h>
+#include <netlink/netlink.h>
+#include <netlink/genl/genl.h>
+#include <netlink/genl/ctrl.h>
+#include <linux/switch.h>
+#include "swlib.h"
+
+#ifndef ARRAY_SIZE
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
+#endif
+
+struct swlib_setting {
+ struct switch_attr *attr;
+ const char *name;
+ int port_vlan;
+ const char *val;
+ struct swlib_setting *next;
+};
+
+struct swlib_setting early_settings[] = {
+ { .name = "reset", .val = "1" },
+ { .name = "enable_vlan", .val = "1" },
+};
+
+static struct swlib_setting *settings;
+static struct swlib_setting **head;
+
+static bool swlib_match_name(struct switch_dev *dev, const char *name)
+{
+ return (strcmp(name, dev->dev_name) == 0 ||
+ strcmp(name, dev->alias) == 0);
+}
+
+static int
+swlib_map_settings(struct switch_dev *dev, int type, int port_vlan, struct uci_section *s)
+{
+ struct swlib_setting *setting;
+ struct switch_attr *attr;
+ struct uci_element *e;
+ struct uci_option *o;
+ int i;
+
+ uci_foreach_element(&s->options, e) {
+ o = uci_to_option(e);
+
+ if (o->type != UCI_TYPE_STRING)
+ continue;
+
+ if (!strcmp(e->name, "device"))
+ continue;
+
+ /* map early settings */
+ if (type == SWLIB_ATTR_GROUP_GLOBAL) {
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(early_settings); i++) {
+ if (strcmp(e->name, early_settings[i].name) != 0)
+ continue;
+
+ early_settings[i].val = o->v.string;
+ goto skip;
+ }
+ }
+
+ attr = swlib_lookup_attr(dev, type, e->name);
+ if (!attr)
+ continue;
+
+ setting = malloc(sizeof(struct swlib_setting));
+ memset(setting, 0, sizeof(struct swlib_setting));
+ setting->attr = attr;
+ setting->port_vlan = port_vlan;
+ setting->val = o->v.string;
+ *head = setting;
+ head = &setting->next;
+skip:
+ continue;
+ }
+}
+
+int swlib_apply_from_uci(struct switch_dev *dev, struct uci_package *p)
+{
+ struct switch_attr *attr;
+ struct uci_context *ctx = p->ctx;
+ struct uci_element *e;
+ struct uci_section *s;
+ struct uci_option *o;
+ struct uci_ptr ptr;
+ struct switch_val val;
+ int i;
+
+ settings = NULL;
+ head = &settings;
+
+ uci_foreach_element(&p->sections, e) {
+ struct uci_element *n;
+
+ s = uci_to_section(e);
+
+ if (strcmp(s->type, "switch") != 0)
+ continue;
+
+ uci_foreach_element(&s->options, n) {
+ struct uci_option *o = uci_to_option(n);
+
+ if (strcmp(n->name, "name") != 0)
+ continue;
+
+ if (o->type != UCI_TYPE_STRING)
+ continue;
+
+ if (swlib_match_name(dev, o->v.string))
+ goto found;
+
+ break;
+ }
+
+ if (!swlib_match_name(dev, e->name))
+ continue;
+
+ goto found;
+ }
+
+ /* not found */
+ return -1;
+
+found:
+ /* look up available early options, which need to be taken care
+ * of in the correct order */
+ for (i = 0; i < ARRAY_SIZE(early_settings); i++) {
+ early_settings[i].attr = swlib_lookup_attr(dev,
+ SWLIB_ATTR_GROUP_GLOBAL, early_settings[i].name);
+ }
+ swlib_map_settings(dev, SWLIB_ATTR_GROUP_GLOBAL, 0, s);
+
+ /* look for port or vlan sections */
+ uci_foreach_element(&p->sections, e) {
+ struct uci_element *os;
+ s = uci_to_section(e);
+
+ if (!strcmp(s->type, "switch_port")) {
+ char *devn, *port, *port_err = NULL;
+ int port_n;
+
+ uci_foreach_element(&s->options, os) {
+ o = uci_to_option(os);
+ if (o->type != UCI_TYPE_STRING)
+ continue;
+
+ if (!strcmp(os->name, "device")) {
+ devn = o->v.string;
+ if (!swlib_match_name(dev, devn))
+ devn = NULL;
+ } else if (!strcmp(os->name, "port")) {
+ port = o->v.string;
+ }
+ }
+ if (!devn || !port || !port[0])
+ continue;
+
+ port_n = strtoul(port, &port_err, 0);
+ if (port_err && port_err[0])
+ continue;
+
+ swlib_map_settings(dev, SWLIB_ATTR_GROUP_PORT, port_n, s);
+ } else if (!strcmp(s->type, "switch_vlan")) {
+ char *devn, *vlan, *vlan_err = NULL;
+ int vlan_n;
+
+ uci_foreach_element(&s->options, os) {
+ o = uci_to_option(os);
+ if (o->type != UCI_TYPE_STRING)
+ continue;
+
+ if (!strcmp(os->name, "device")) {
+ devn = o->v.string;
+ if (!swlib_match_name(dev, devn))
+ devn = NULL;
+ } else if (!strcmp(os->name, "vlan")) {
+ vlan = o->v.string;
+ }
+ }
+ if (!devn || !vlan || !vlan[0])
+ continue;
+
+ vlan_n = strtoul(vlan, &vlan_err, 0);
+ if (vlan_err && vlan_err[0])
+ continue;
+
+ swlib_map_settings(dev, SWLIB_ATTR_GROUP_VLAN, vlan_n, s);
+ }
+ }
+
+ for (i = 0; i < ARRAY_SIZE(early_settings); i++) {
+ struct swlib_setting *st = &early_settings[i];
+ if (!st->attr || !st->val)
+ continue;
+ swlib_set_attr_string(dev, st->attr, st->port_vlan, st->val);
+
+ }
+
+ while (settings) {
+ struct swlib_setting *st = settings;
+
+ swlib_set_attr_string(dev, st->attr, st->port_vlan, st->val);
+ st = st->next;
+ free(settings);
+ settings = st;
+ }
+
+ /* Apply the config */
+ attr = swlib_lookup_attr(dev, SWLIB_ATTR_GROUP_GLOBAL, "apply");
+ if (!attr)
+ return 0;
+
+ memset(&val, 0, sizeof(val));
+ swlib_set_attr(dev, attr, &val);
+
+ return 0;
+}
diff --git a/package/network/config/swconfig/src/Makefile b/package/network/config/swconfig/src/Makefile
new file mode 100644
index 0000000..0d56f43
--- /dev/null
+++ b/package/network/config/swconfig/src/Makefile
@@ -0,0 +1,12 @@
+ifndef CFLAGS
+CFLAGS = -O2 -g -I ../src
+endif
+LIBS=-lnl -lnl-genl
+
+all: swconfig
+
+%.o: %.c
+ $(CC) $(CFLAGS) -c -o $@ $^
+
+swconfig: cli.o swlib.o uci.o
+ $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
diff --git a/package/network/config/swconfig/src/cli.c b/package/network/config/swconfig/src/cli.c
new file mode 100644
index 0000000..9cd16ab
--- /dev/null
+++ b/package/network/config/swconfig/src/cli.c
@@ -0,0 +1,340 @@
+/*
+ * swconfig.c: Switch configuration utility
+ *
+ * Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
+ * Copyright (C) 2010 Martin Mares <mj@ucw.cz>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundatio.
+ *
+ * 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.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <inttypes.h>
+#include <errno.h>
+#include <stdint.h>
+#include <getopt.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <uci.h>
+
+#include <linux/types.h>
+#include <linux/netlink.h>
+#include <linux/genetlink.h>
+#include <netlink/netlink.h>
+#include <netlink/genl/genl.h>
+#include <netlink/genl/ctrl.h>
+#include <linux/switch.h>
+#include "swlib.h"
+
+enum {
+ CMD_NONE,
+ CMD_GET,
+ CMD_SET,
+ CMD_LOAD,
+ CMD_HELP,
+ CMD_SHOW,
+};
+
+static void
+print_attrs(const struct switch_attr *attr)
+{
+ int i = 0;
+ while (attr) {
+ const char *type;
+ switch(attr->type) {
+ case SWITCH_TYPE_INT:
+ type = "int";
+ break;
+ case SWITCH_TYPE_STRING:
+ type = "string";
+ break;
+ case SWITCH_TYPE_PORTS:
+ type = "ports";
+ break;
+ case SWITCH_TYPE_NOVAL:
+ type = "none";
+ break;
+ default:
+ type = "unknown";
+ break;
+ }
+ printf("\tAttribute %d (%s): %s (%s)\n", ++i, type, attr->name, attr->description);
+ attr = attr->next;
+ }
+}
+
+static void
+list_attributes(struct switch_dev *dev)
+{
+ printf("%s: %s(%s), ports: %d (cpu @ %d), vlans: %d\n", dev->dev_name, dev->alias, dev->name, dev->ports, dev->cpu_port, dev->vlans);
+ printf(" --switch\n");
+ print_attrs(dev->ops);
+ printf(" --vlan\n");
+ print_attrs(dev->vlan_ops);
+ printf(" --port\n");
+ print_attrs(dev->port_ops);
+}
+
+static void
+print_attr_val(const struct switch_attr *attr, const struct switch_val *val)
+{
+ int i;
+
+ switch (attr->type) {
+ case SWITCH_TYPE_INT:
+ printf("%d", val->value.i);
+ break;
+ case SWITCH_TYPE_STRING:
+ printf("%s", val->value.s);
+ break;
+ case SWITCH_TYPE_PORTS:
+ for(i = 0; i < val->len; i++) {
+ printf("%d%s ",
+ val->value.ports[i].id,
+ (val->value.ports[i].flags &
+ SWLIB_PORT_FLAG_TAGGED) ? "t" : "");
+ }
+ break;
+ default:
+ printf("?unknown-type?");
+ }
+}
+
+static void
+show_attrs(struct switch_dev *dev, struct switch_attr *attr, struct switch_val *val)
+{
+ while (attr) {
+ if (attr->type != SWITCH_TYPE_NOVAL) {
+ printf("\t%s: ", attr->name);
+ if (swlib_get_attr(dev, attr, val) < 0)
+ printf("???");
+ else
+ print_attr_val(attr, val);
+ putchar('\n');
+ }
+ attr = attr->next;
+ }
+}
+
+static void
+show_global(struct switch_dev *dev)
+{
+ struct switch_val val;
+
+ printf("Global attributes:\n");
+ show_attrs(dev, dev->ops, &val);
+}
+
+static void
+show_port(struct switch_dev *dev, int port)
+{
+ struct switch_val val;
+
+ printf("Port %d:\n", port);
+ val.port_vlan = port;
+ show_attrs(dev, dev->port_ops, &val);
+}
+
+static void
+show_vlan(struct switch_dev *dev, int vlan, bool all)
+{
+ struct switch_val val;
+ struct switch_attr *attr;
+
+ val.port_vlan = vlan;
+
+ if (all) {
+ attr = swlib_lookup_attr(dev, SWLIB_ATTR_GROUP_VLAN, "ports");
+ if (swlib_get_attr(dev, attr, &val) < 0)
+ return;
+
+ if (!val.len)
+ return;
+ }
+
+ printf("VLAN %d:\n", vlan);
+ show_attrs(dev, dev->vlan_ops, &val);
+}
+
+static void
+print_usage(void)
+{
+ printf("swconfig dev <dev> [port <port>|vlan <vlan>] (help|set <key> <value>|get <key>|load <config>|show)\n");
+ exit(1);
+}
+
+static void
+swconfig_load_uci(struct switch_dev *dev, const char *name)
+{
+ struct uci_context *ctx;
+ struct uci_package *p = NULL;
+ struct uci_element *e;
+ int ret = -1;
+
+ ctx = uci_alloc_context();
+ if (!ctx)
+ return;
+
+ uci_load(ctx, name, &p);
+ if (!p) {
+ uci_perror(ctx, "Failed to load config file: ");
+ goto out;
+ }
+
+ ret = swlib_apply_from_uci(dev, p);
+ if (ret < 0)
+ fprintf(stderr, "Failed to apply configuration for switch '%s'\n", dev->dev_name);
+
+out:
+ uci_free_context(ctx);
+ exit(ret);
+}
+
+int main(int argc, char **argv)
+{
+ int retval = 0;
+ struct switch_dev *dev;
+ struct switch_attr *a;
+ struct switch_val val;
+ int err;
+ int i;
+
+ int cmd = CMD_NONE;
+ char *cdev = NULL;
+ int cport = -1;
+ int cvlan = -1;
+ char *ckey = NULL;
+ char *cvalue = NULL;
+
+ if(argc < 4)
+ print_usage();
+
+ if(strcmp(argv[1], "dev"))
+ print_usage();
+
+ cdev = argv[2];
+
+ for(i = 3; i < argc; i++)
+ {
+ char *arg = argv[i];
+ if (cmd != CMD_NONE) {
+ print_usage();
+ } else if (!strcmp(arg, "port") && i+1 < argc) {
+ cport = atoi(argv[++i]);
+ } else if (!strcmp(arg, "vlan") && i+1 < argc) {
+ cvlan = atoi(argv[++i]);
+ } else if (!strcmp(arg, "help")) {
+ cmd = CMD_HELP;
+ } else if (!strcmp(arg, "set") && i+1 < argc) {
+ cmd = CMD_SET;
+ ckey = argv[++i];
+ if (i+1 < argc)
+ cvalue = argv[++i];
+ } else if (!strcmp(arg, "get") && i+1 < argc) {
+ cmd = CMD_GET;
+ ckey = argv[++i];
+ } else if (!strcmp(arg, "load") && i+1 < argc) {
+ if ((cport >= 0) || (cvlan >= 0))
+ print_usage();
+ cmd = CMD_LOAD;
+ ckey = argv[++i];
+ } else if (!strcmp(arg, "show")) {
+ cmd = CMD_SHOW;
+ } else {
+ print_usage();
+ }
+ }
+
+ if (cmd == CMD_NONE)
+ print_usage();
+ if (cport > -1 && cvlan > -1)
+ print_usage();
+
+ dev = swlib_connect(cdev);
+ if (!dev) {
+ fprintf(stderr, "Failed to connect to the switch\n");
+ return 1;
+ }
+
+ swlib_scan(dev);
+
+ if (cmd == CMD_GET || cmd == CMD_SET) {
+ if(cport > -1)
+ a = swlib_lookup_attr(dev, SWLIB_ATTR_GROUP_PORT, ckey);
+ else if(cvlan > -1)
+ a = swlib_lookup_attr(dev, SWLIB_ATTR_GROUP_VLAN, ckey);
+ else
+ a = swlib_lookup_attr(dev, SWLIB_ATTR_GROUP_GLOBAL, ckey);
+
+ if(!a)
+ {
+ fprintf(stderr, "Unknown attribute \"%s\"\n", ckey);
+ goto out;
+ }
+ }
+
+ switch(cmd)
+ {
+ case CMD_SET:
+ if ((a->type != SWITCH_TYPE_NOVAL) &&
+ (cvalue == NULL))
+ print_usage();
+
+ if(cvlan > -1)
+ cport = cvlan;
+
+ if(swlib_set_attr_string(dev, a, cport, cvalue) < 0)
+ {
+ fprintf(stderr, "failed\n");
+ retval = -1;
+ goto out;
+ }
+ break;
+ case CMD_GET:
+ if(cvlan > -1)
+ val.port_vlan = cvlan;
+ if(cport > -1)
+ val.port_vlan = cport;
+ if(swlib_get_attr(dev, a, &val) < 0)
+ {
+ fprintf(stderr, "failed\n");
+ retval = -1;
+ goto out;
+ }
+ print_attr_val(a, &val);
+ putchar('\n');
+ break;
+ case CMD_LOAD:
+ swconfig_load_uci(dev, ckey);
+ break;
+ case CMD_HELP:
+ list_attributes(dev);
+ break;
+ case CMD_SHOW:
+ if (cport >= 0 || cvlan >= 0) {
+ if (cport >= 0)
+ show_port(dev, cport);
+ else
+ show_vlan(dev, cvlan, false);
+ } else {
+ show_global(dev);
+ for (i=0; i < dev->ports; i++)
+ show_port(dev, i);
+ for (i=0; i < dev->vlans; i++)
+ show_vlan(dev, i, true);
+ }
+ break;
+ }
+
+out:
+ swlib_free_all(dev);
+ return 0;
+}
diff --git a/package/network/config/swconfig/src/swlib.c b/package/network/config/swconfig/src/swlib.c
new file mode 100644
index 0000000..de08717
--- /dev/null
+++ b/package/network/config/swconfig/src/swlib.c
@@ -0,0 +1,686 @@
+/*
+ * swlib.c: Switch configuration API (user space part)
+ *
+ * Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * 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.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <inttypes.h>
+#include <errno.h>
+#include <stdint.h>
+#include <getopt.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <linux/switch.h>
+#include "swlib.h"
+#include <netlink/netlink.h>
+#include <netlink/genl/genl.h>
+#include <netlink/genl/family.h>
+
+//#define DEBUG 1
+#ifdef DEBUG
+#define DPRINTF(fmt, ...) fprintf(stderr, "%s(%d): " fmt, __func__, __LINE__, ##__VA_ARGS__)
+#else
+#define DPRINTF(fmt, ...) do {} while (0)
+#endif
+
+static struct nl_sock *handle;
+static struct nl_cache *cache;
+static struct genl_family *family;
+static struct nlattr *tb[SWITCH_ATTR_MAX + 1];
+static int refcount = 0;
+
+static struct nla_policy port_policy[] = {
+ [SWITCH_PORT_ID] = { .type = NLA_U32 },
+ [SWITCH_PORT_FLAG_TAGGED] = { .type = NLA_FLAG },
+};
+
+static inline void *
+swlib_alloc(size_t size)
+{
+ void *ptr;
+
+ ptr = malloc(size);
+ if (!ptr)
+ goto done;
+ memset(ptr, 0, size);
+
+done:
+ return ptr;
+}
+
+static int
+wait_handler(struct nl_msg *msg, void *arg)
+{
+ int *finished = arg;
+
+ *finished = 1;
+ return NL_STOP;
+}
+
+/* helper function for performing netlink requests */
+static int
+swlib_call(int cmd, int (*call)(struct nl_msg *, void *),
+ int (*data)(struct nl_msg *, void *), void *arg)
+{
+ struct nl_msg *msg;
+ struct nl_cb *cb = NULL;
+ int finished;
+ int flags = 0;
+ int err;
+
+ msg = nlmsg_alloc();
+ if (!msg) {
+ fprintf(stderr, "Out of memory!\n");
+ exit(1);
+ }
+
+ if (!data)
+ flags |= NLM_F_DUMP;
+
+ genlmsg_put(msg, NL_AUTO_PID, NL_AUTO_SEQ, genl_family_get_id(family), 0, flags, cmd, 0);
+ if (data) {
+ if (data(msg, arg) < 0)
+ goto nla_put_failure;
+ }
+
+ cb = nl_cb_alloc(NL_CB_CUSTOM);
+ if (!cb) {
+ fprintf(stderr, "nl_cb_alloc failed.\n");
+ exit(1);
+ }
+
+ err = nl_send_auto_complete(handle, msg);
+ if (err < 0) {
+ fprintf(stderr, "nl_send_auto_complete failed: %d\n", err);
+ goto out;
+ }
+
+ finished = 0;
+
+ if (call)
+ nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, call, arg);
+
+ if (data)
+ nl_cb_set(cb, NL_CB_ACK, NL_CB_CUSTOM, wait_handler, &finished);
+ else
+ nl_cb_set(cb, NL_CB_FINISH, NL_CB_CUSTOM, wait_handler, &finished);
+
+ err = nl_recvmsgs(handle, cb);
+ if (err < 0) {
+ goto out;
+ }
+
+ if (!finished)
+ err = nl_wait_for_ack(handle);
+
+out:
+ if (cb)
+ nl_cb_put(cb);
+nla_put_failure:
+ nlmsg_free(msg);
+ return err;
+}
+
+static int
+send_attr(struct nl_msg *msg, void *arg)
+{
+ struct switch_val *val = arg;
+ struct switch_attr *attr = val->attr;
+
+ NLA_PUT_U32(msg, SWITCH_ATTR_ID, attr->dev->id);
+ NLA_PUT_U32(msg, SWITCH_ATTR_OP_ID, attr->id);
+ switch(attr->atype) {
+ case SWLIB_ATTR_GROUP_PORT:
+ NLA_PUT_U32(msg, SWITCH_ATTR_OP_PORT, val->port_vlan);
+ break;
+ case SWLIB_ATTR_GROUP_VLAN:
+ NLA_PUT_U32(msg, SWITCH_ATTR_OP_VLAN, val->port_vlan);
+ break;
+ default:
+ break;
+ }
+
+ return 0;
+
+nla_put_failure:
+ return -1;
+}
+
+static int
+store_port_val(struct nl_msg *msg, struct nlattr *nla, struct switch_val *val)
+{
+ struct nlattr *p;
+ int ports = val->attr->dev->ports;
+ int err = 0;
+ int remaining;
+
+ if (!val->value.ports)
+ val->value.ports = malloc(sizeof(struct switch_port) * ports);
+
+ nla_for_each_nested(p, nla, remaining) {
+ struct nlattr *tb[SWITCH_PORT_ATTR_MAX+1];
+ struct switch_port *port;
+
+ if (val->len >= ports)
+ break;
+
+ err = nla_parse_nested(tb, SWITCH_PORT_ATTR_MAX, p, port_policy);
+ if (err < 0)
+ goto out;
+
+ if (!tb[SWITCH_PORT_ID])
+ continue;
+
+ port = &val->value.ports[val->len];
+ port->id = nla_get_u32(tb[SWITCH_PORT_ID]);
+ port->flags = 0;
+ if (tb[SWITCH_PORT_FLAG_TAGGED])
+ port->flags |= SWLIB_PORT_FLAG_TAGGED;
+
+ val->len++;
+ }
+
+out:
+ return err;
+}
+
+static int
+store_val(struct nl_msg *msg, void *arg)
+{
+ struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
+ struct switch_val *val = arg;
+ struct switch_attr *attr = val->attr;
+
+ if (!val)
+ goto error;
+
+ if (nla_parse(tb, SWITCH_ATTR_MAX - 1, genlmsg_attrdata(gnlh, 0),
+ genlmsg_attrlen(gnlh, 0), NULL) < 0) {
+ goto error;
+ }
+
+ if (tb[SWITCH_ATTR_OP_VALUE_INT])
+ val->value.i = nla_get_u32(tb[SWITCH_ATTR_OP_VALUE_INT]);
+ else if (tb[SWITCH_ATTR_OP_VALUE_STR])
+ val->value.s = strdup(nla_get_string(tb[SWITCH_ATTR_OP_VALUE_STR]));
+ else if (tb[SWITCH_ATTR_OP_VALUE_PORTS])
+ val->err = store_port_val(msg, tb[SWITCH_ATTR_OP_VALUE_PORTS], val);
+
+ val->err = 0;
+ return 0;
+
+error:
+ return NL_SKIP;
+}
+
+int
+swlib_get_attr(struct switch_dev *dev, struct switch_attr *attr, struct switch_val *val)
+{
+ int cmd;
+ int err;
+
+ switch(attr->atype) {
+ case SWLIB_ATTR_GROUP_GLOBAL:
+ cmd = SWITCH_CMD_GET_GLOBAL;
+ break;
+ case SWLIB_ATTR_GROUP_PORT:
+ cmd = SWITCH_CMD_GET_PORT;
+ break;
+ case SWLIB_ATTR_GROUP_VLAN:
+ cmd = SWITCH_CMD_GET_VLAN;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ memset(&val->value, 0, sizeof(val->value));
+ val->len = 0;
+ val->attr = attr;
+ val->err = -EINVAL;
+ err = swlib_call(cmd, store_val, send_attr, val);
+ if (!err)
+ err = val->err;
+
+ return err;
+}
+
+static int
+send_attr_ports(struct nl_msg *msg, struct switch_val *val)
+{
+ struct nlattr *n;
+ int i;
+
+ /* TODO implement multipart? */
+ if (val->len == 0)
+ goto done;
+ n = nla_nest_start(msg, SWITCH_ATTR_OP_VALUE_PORTS);
+ if (!n)
+ goto nla_put_failure;
+ for (i = 0; i < val->len; i++) {
+ struct switch_port *port = &val->value.ports[i];
+ struct nlattr *np;
+
+ np = nla_nest_start(msg, SWITCH_ATTR_PORT);
+ if (!np)
+ goto nla_put_failure;
+
+ NLA_PUT_U32(msg, SWITCH_PORT_ID, port->id);
+ if (port->flags & SWLIB_PORT_FLAG_TAGGED)
+ NLA_PUT_FLAG(msg, SWITCH_PORT_FLAG_TAGGED);
+
+ nla_nest_end(msg, np);
+ }
+ nla_nest_end(msg, n);
+done:
+ return 0;
+
+nla_put_failure:
+ return -1;
+}
+
+static int
+send_attr_val(struct nl_msg *msg, void *arg)
+{
+ struct switch_val *val = arg;
+ struct switch_attr *attr = val->attr;
+
+ if (send_attr(msg, arg))
+ goto nla_put_failure;
+
+ switch(attr->type) {
+ case SWITCH_TYPE_NOVAL:
+ break;
+ case SWITCH_TYPE_INT:
+ NLA_PUT_U32(msg, SWITCH_ATTR_OP_VALUE_INT, val->value.i);
+ break;
+ case SWITCH_TYPE_STRING:
+ if (!val->value.s)
+ goto nla_put_failure;
+ NLA_PUT_STRING(msg, SWITCH_ATTR_OP_VALUE_STR, val->value.s);
+ break;
+ case SWITCH_TYPE_PORTS:
+ if (send_attr_ports(msg, val) < 0)
+ goto nla_put_failure;
+ break;
+ default:
+ goto nla_put_failure;
+ }
+ return 0;
+
+nla_put_failure:
+ return -1;
+}
+
+int
+swlib_set_attr(struct switch_dev *dev, struct switch_attr *attr, struct switch_val *val)
+{
+ int cmd;
+
+ switch(attr->atype) {
+ case SWLIB_ATTR_GROUP_GLOBAL:
+ cmd = SWITCH_CMD_SET_GLOBAL;
+ break;
+ case SWLIB_ATTR_GROUP_PORT:
+ cmd = SWITCH_CMD_SET_PORT;
+ break;
+ case SWLIB_ATTR_GROUP_VLAN:
+ cmd = SWITCH_CMD_SET_VLAN;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ val->attr = attr;
+ return swlib_call(cmd, NULL, send_attr_val, val);
+}
+
+int swlib_set_attr_string(struct switch_dev *dev, struct switch_attr *a, int port_vlan, const char *str)
+{
+ struct switch_port *ports;
+ struct switch_val val;
+ char *ptr;
+
+ memset(&val, 0, sizeof(val));
+ val.port_vlan = port_vlan;
+ switch(a->type) {
+ case SWITCH_TYPE_INT:
+ val.value.i = atoi(str);
+ break;
+ case SWITCH_TYPE_STRING:
+ val.value.s = str;
+ break;
+ case SWITCH_TYPE_PORTS:
+ ports = alloca(sizeof(struct switch_port) * dev->ports);
+ memset(ports, 0, sizeof(struct switch_port) * dev->ports);
+ val.len = 0;
+ ptr = (char *)str;
+ while(ptr && *ptr)
+ {
+ while(*ptr && isspace(*ptr))
+ ptr++;
+
+ if (!*ptr)
+ break;
+
+ if (!isdigit(*ptr))
+ return -1;
+
+ if (val.len >= dev->ports)
+ return -1;
+
+ ports[val.len].flags = 0;
+ ports[val.len].id = strtoul(ptr, &ptr, 10);
+ while(*ptr && !isspace(*ptr)) {
+ if (*ptr == 't')
+ ports[val.len].flags |= SWLIB_PORT_FLAG_TAGGED;
+ else
+ return -1;
+
+ ptr++;
+ }
+ if (*ptr)
+ ptr++;
+ val.len++;
+ }
+ val.value.ports = ports;
+ break;
+ case SWITCH_TYPE_NOVAL:
+ if (str && !strcmp(str, "0"))
+ return 0;
+
+ break;
+ default:
+ return -1;
+ }
+ return swlib_set_attr(dev, a, &val);
+}
+
+
+struct attrlist_arg {
+ int id;
+ int atype;
+ struct switch_dev *dev;
+ struct switch_attr *prev;
+ struct switch_attr **head;
+};
+
+static int
+add_id(struct nl_msg *msg, void *arg)
+{
+ struct attrlist_arg *l = arg;
+
+ NLA_PUT_U32(msg, SWITCH_ATTR_ID, l->id);
+
+ return 0;
+nla_put_failure:
+ return -1;
+}
+
+static int
+add_attr(struct nl_msg *msg, void *ptr)
+{
+ struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
+ struct attrlist_arg *arg = ptr;
+ struct switch_attr *new;
+
+ if (nla_parse(tb, SWITCH_ATTR_MAX - 1, genlmsg_attrdata(gnlh, 0),
+ genlmsg_attrlen(gnlh, 0), NULL) < 0)
+ goto done;
+
+ new = swlib_alloc(sizeof(struct switch_attr));
+ if (!new)
+ goto done;
+
+ new->dev = arg->dev;
+ new->atype = arg->atype;
+ if (arg->prev) {
+ arg->prev->next = new;
+ } else {
+ arg->prev = *arg->head;
+ }
+ *arg->head = new;
+ arg->head = &new->next;
+
+ if (tb[SWITCH_ATTR_OP_ID])
+ new->id = nla_get_u32(tb[SWITCH_ATTR_OP_ID]);
+ if (tb[SWITCH_ATTR_OP_TYPE])
+ new->type = nla_get_u32(tb[SWITCH_ATTR_OP_TYPE]);
+ if (tb[SWITCH_ATTR_OP_NAME])
+ new->name = strdup(nla_get_string(tb[SWITCH_ATTR_OP_NAME]));
+ if (tb[SWITCH_ATTR_OP_DESCRIPTION])
+ new->description = strdup(nla_get_string(tb[SWITCH_ATTR_OP_DESCRIPTION]));
+
+done:
+ return NL_SKIP;
+}
+
+int
+swlib_scan(struct switch_dev *dev)
+{
+ struct attrlist_arg arg;
+
+ if (dev->ops || dev->port_ops || dev->vlan_ops)
+ return 0;
+
+ arg.atype = SWLIB_ATTR_GROUP_GLOBAL;
+ arg.dev = dev;
+ arg.id = dev->id;
+ arg.prev = NULL;
+ arg.head = &dev->ops;
+ swlib_call(SWITCH_CMD_LIST_GLOBAL, add_attr, add_id, &arg);
+
+ arg.atype = SWLIB_ATTR_GROUP_PORT;
+ arg.prev = NULL;
+ arg.head = &dev->port_ops;
+ swlib_call(SWITCH_CMD_LIST_PORT, add_attr, add_id, &arg);
+
+ arg.atype = SWLIB_ATTR_GROUP_VLAN;
+ arg.prev = NULL;
+ arg.head = &dev->vlan_ops;
+ swlib_call(SWITCH_CMD_LIST_VLAN, add_attr, add_id, &arg);
+
+ return 0;
+}
+
+struct switch_attr *swlib_lookup_attr(struct switch_dev *dev,
+ enum swlib_attr_group atype, const char *name)
+{
+ struct switch_attr *head;
+
+ if (!name || !dev)
+ return NULL;
+
+ switch(atype) {
+ case SWLIB_ATTR_GROUP_GLOBAL:
+ head = dev->ops;
+ break;
+ case SWLIB_ATTR_GROUP_PORT:
+ head = dev->port_ops;
+ break;
+ case SWLIB_ATTR_GROUP_VLAN:
+ head = dev->vlan_ops;
+ break;
+ }
+ while(head) {
+ if (!strcmp(name, head->name))
+ return head;
+ head = head->next;
+ }
+
+ return NULL;
+}
+
+static void
+swlib_priv_free(void)
+{
+ if (cache)
+ nl_cache_free(cache);
+ if (handle)
+ nl_socket_free(handle);
+ handle = NULL;
+ cache = NULL;
+}
+
+static int
+swlib_priv_init(void)
+{
+ int ret;
+
+ handle = nl_socket_alloc();
+ if (!handle) {
+ DPRINTF("Failed to create handle\n");
+ goto err;
+ }
+
+ if (genl_connect(handle)) {
+ DPRINTF("Failed to connect to generic netlink\n");
+ goto err;
+ }
+
+ ret = genl_ctrl_alloc_cache(handle, &cache);
+ if (ret < 0) {
+ DPRINTF("Failed to allocate netlink cache\n");
+ goto err;
+ }
+
+ family = genl_ctrl_search_by_name(cache, "switch");
+ if (!family) {
+ DPRINTF("Switch API not present\n");
+ goto err;
+ }
+ return 0;
+
+err:
+ swlib_priv_free();
+ return -EINVAL;
+}
+
+struct swlib_scan_arg {
+ const char *name;
+ struct switch_dev *head;
+ struct switch_dev *ptr;
+};
+
+static int
+add_switch(struct nl_msg *msg, void *arg)
+{
+ struct swlib_scan_arg *sa = arg;
+ struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
+ struct switch_dev *dev;
+ const char *name;
+ const char *alias;
+
+ if (nla_parse(tb, SWITCH_ATTR_MAX, genlmsg_attrdata(gnlh, 0), genlmsg_attrlen(gnlh, 0), NULL) < 0)
+ goto done;
+
+ if (!tb[SWITCH_ATTR_DEV_NAME])
+ goto done;
+
+ name = nla_get_string(tb[SWITCH_ATTR_DEV_NAME]);
+ alias = nla_get_string(tb[SWITCH_ATTR_ALIAS]);
+
+ if (sa->name && (strcmp(name, sa->name) != 0) && (strcmp(alias, sa->name) != 0))
+ goto done;
+
+ dev = swlib_alloc(sizeof(struct switch_dev));
+ if (!dev)
+ goto done;
+
+ strncpy(dev->dev_name, name, IFNAMSIZ - 1);
+ dev->alias = strdup(alias);
+ if (tb[SWITCH_ATTR_ID])
+ dev->id = nla_get_u32(tb[SWITCH_ATTR_ID]);
+ if (tb[SWITCH_ATTR_NAME])
+ dev->name = strdup(nla_get_string(tb[SWITCH_ATTR_NAME]));
+ if (tb[SWITCH_ATTR_PORTS])
+ dev->ports = nla_get_u32(tb[SWITCH_ATTR_PORTS]);
+ if (tb[SWITCH_ATTR_VLANS])
+ dev->vlans = nla_get_u32(tb[SWITCH_ATTR_VLANS]);
+ if (tb[SWITCH_ATTR_CPU_PORT])
+ dev->cpu_port = nla_get_u32(tb[SWITCH_ATTR_CPU_PORT]);
+
+ if (!sa->head) {
+ sa->head = dev;
+ sa->ptr = dev;
+ } else {
+ sa->ptr->next = dev;
+ sa->ptr = dev;
+ }
+
+ refcount++;
+done:
+ return NL_SKIP;
+}
+
+
+struct switch_dev *
+swlib_connect(const char *name)
+{
+ struct swlib_scan_arg arg;
+ int err;
+
+ if (!refcount) {
+ if (swlib_priv_init() < 0)
+ return NULL;
+ };
+
+ arg.head = NULL;
+ arg.ptr = NULL;
+ arg.name = name;
+ swlib_call(SWITCH_CMD_GET_SWITCH, add_switch, NULL, &arg);
+
+ if (!refcount)
+ swlib_priv_free();
+
+ return arg.head;
+}
+
+static void
+swlib_free_attributes(struct switch_attr **head)
+{
+ struct switch_attr *a = *head;
+ struct switch_attr *next;
+
+ while (a) {
+ next = a->next;
+ free(a);
+ a = next;
+ }
+ *head = NULL;
+}
+
+void
+swlib_free(struct switch_dev *dev)
+{
+ swlib_free_attributes(&dev->ops);
+ swlib_free_attributes(&dev->port_ops);
+ swlib_free_attributes(&dev->vlan_ops);
+ free(dev);
+
+ if (--refcount == 0)
+ swlib_priv_free();
+}
+
+void
+swlib_free_all(struct switch_dev *dev)
+{
+ struct switch_dev *p;
+
+ while (dev) {
+ p = dev->next;
+ swlib_free(dev);
+ dev = p;
+ }
+}
diff --git a/package/network/config/swconfig/src/swlib.h b/package/network/config/swconfig/src/swlib.h
new file mode 100644
index 0000000..ff73969
--- /dev/null
+++ b/package/network/config/swconfig/src/swlib.h
@@ -0,0 +1,234 @@
+/*
+ * swlib.h: Switch configuration API (user space part)
+ *
+ * Copyright (C) 2008-2009 Felix Fietkau <nbd@openwrt.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * 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.
+ *
+
+Usage of the library functions:
+
+ The main datastructure for a switch is the struct switch_device
+ To get started, you first need to use switch_connect() to probe
+ for switches and allocate an instance of this struct.
+
+ There are two possible usage modes:
+ dev = switch_connect("eth0");
+ - this call will look for a switch registered for the linux device
+ "eth0" and only allocate a switch_device for this particular switch.
+
+ dev = switch_connect(NULL)
+ - this will return one switch_device struct for each available
+ switch. The switch_device structs are chained with by ->next pointer
+
+ Then to query a switch for all available attributes, use:
+ swlib_scan(dev);
+
+ All allocated datastructures for the switch_device struct can be freed with
+ swlib_free(dev);
+ or
+ swlib_free_all(dev);
+
+ The latter traverses a whole chain of switch_device structs and frees them all
+
+ Switch attributes (struct switch_attr) are divided into three groups:
+ dev->ops:
+ - global settings
+ dev->port_ops:
+ - per-port settings
+ dev->vlan_ops:
+ - per-vlan settings
+
+ switch_lookup_attr() is a small helper function to locate attributes
+ by name.
+
+ switch_set_attr() and switch_get_attr() can alter or request the values
+ of attributes.
+
+Usage of the switch_attr struct:
+
+ ->atype: attribute group, one of:
+ - SWLIB_ATTR_GROUP_GLOBAL
+ - SWLIB_ATTR_GROUP_VLAN
+ - SWLIB_ATTR_GROUP_PORT
+
+ ->id: identifier for the attribute
+
+ ->type: data type, one of:
+ - SWITCH_TYPE_INT
+ - SWITCH_TYPE_STRING
+ - SWITCH_TYPE_PORT
+
+ ->name: short name of the attribute
+ ->description: longer description
+ ->next: pointer to the next attribute of the current group
+
+
+Usage of the switch_val struct:
+
+ When setting attributes, following members of the struct switch_val need
+ to be set up:
+
+ ->len (for attr->type == SWITCH_TYPE_PORT)
+ ->port_vlan:
+ - port number (for attr->atype == SWLIB_ATTR_GROUP_PORT), or:
+ - vlan number (for attr->atype == SWLIB_ATTR_GROUP_VLAN)
+ ->value.i (for attr->type == SWITCH_TYPE_INT)
+ ->value.s (for attr->type == SWITCH_TYPE_STRING)
+ - owned by the caller, not stored in the library internally
+ ->value.ports (for attr->type == SWITCH_TYPE_PORT)
+ - must point to an array of at lest val->len * sizeof(struct switch_port)
+
+ When getting string attributes, val->value.s must be freed by the caller
+ When getting port list attributes, an internal static buffer is used,
+ which changes from call to call.
+
+ */
+
+#ifndef __SWLIB_H
+#define __SWLIB_H
+
+enum swlib_attr_group {
+ SWLIB_ATTR_GROUP_GLOBAL,
+ SWLIB_ATTR_GROUP_VLAN,
+ SWLIB_ATTR_GROUP_PORT,
+};
+
+enum swlib_port_flags {
+ SWLIB_PORT_FLAG_TAGGED = (1 << 0),
+};
+
+
+struct switch_dev;
+struct switch_attr;
+struct switch_port;
+struct switch_val;
+struct uci_package;
+
+struct switch_dev {
+ int id;
+ char dev_name[IFNAMSIZ];
+ const char *name;
+ const char *alias;
+ int ports;
+ int vlans;
+ int cpu_port;
+ struct switch_attr *ops;
+ struct switch_attr *port_ops;
+ struct switch_attr *vlan_ops;
+ struct switch_dev *next;
+ void *priv;
+};
+
+struct switch_val {
+ struct switch_attr *attr;
+ int len;
+ int err;
+ int port_vlan;
+ union {
+ const char *s;
+ int i;
+ struct switch_port *ports;
+ } value;
+};
+
+struct switch_attr {
+ struct switch_dev *dev;
+ int atype;
+ int id;
+ int type;
+ const char *name;
+ const char *description;
+ struct switch_attr *next;
+};
+
+struct switch_port {
+ unsigned int id;
+ unsigned int flags;
+};
+
+/**
+ * swlib_connect: connect to the switch through netlink
+ * @name: name of the ethernet interface,
+ *
+ * if name is NULL, it connect and builds a chain of all switches
+ */
+struct switch_dev *swlib_connect(const char *name);
+
+/**
+ * swlib_free: free all dynamically allocated data for the switch connection
+ * @dev: switch device struct
+ *
+ * all members of a switch device chain (generated by swlib_connect(NULL))
+ * must be freed individually
+ */
+void swlib_free(struct switch_dev *dev);
+
+/**
+ * swlib_free_all: run swlib_free on all devices in the chain
+ * @dev: switch device struct
+ */
+void swlib_free_all(struct switch_dev *dev);
+
+/**
+ * swlib_scan: probe the switch driver for available commands/attributes
+ * @dev: switch device struct
+ */
+int swlib_scan(struct switch_dev *dev);
+
+/**
+ * swlib_lookup_attr: look up a switch attribute
+ * @dev: switch device struct
+ * @type: global, port or vlan
+ * @name: name of the attribute
+ */
+struct switch_attr *swlib_lookup_attr(struct switch_dev *dev,
+ enum swlib_attr_group atype, const char *name);
+
+/**
+ * swlib_set_attr: set the value for an attribute
+ * @dev: switch device struct
+ * @attr: switch attribute struct
+ * @val: attribute value pointer
+ * returns 0 on success
+ */
+int swlib_set_attr(struct switch_dev *dev, struct switch_attr *attr,
+ struct switch_val *val);
+
+/**
+ * swlib_set_attr_string: set the value for an attribute with type conversion
+ * @dev: switch device struct
+ * @attr: switch attribute struct
+ * @port_vlan: port or vlan (if applicable)
+ * @str: string value
+ * returns 0 on success
+ */
+int swlib_set_attr_string(struct switch_dev *dev, struct switch_attr *attr,
+ int port_vlan, const char *str);
+
+/**
+ * swlib_get_attr: get the value for an attribute
+ * @dev: switch device struct
+ * @attr: switch attribute struct
+ * @val: attribute value pointer
+ * returns 0 on success
+ * for string attributes, the result string must be freed by the caller
+ */
+int swlib_get_attr(struct switch_dev *dev, struct switch_attr *attr,
+ struct switch_val *val);
+
+/**
+ * swlib_apply_from_uci: set up the switch from a uci configuration
+ * @dev: switch device struct
+ * @p: uci package which contains the desired global config
+ */
+int swlib_apply_from_uci(struct switch_dev *dev, struct uci_package *p);
+
+#endif
diff --git a/package/network/config/swconfig/src/uci.c b/package/network/config/swconfig/src/uci.c
new file mode 100644
index 0000000..893e3d1
--- /dev/null
+++ b/package/network/config/swconfig/src/uci.c
@@ -0,0 +1,248 @@
+/*
+ * uci.c: UCI binding for the switch configuration utility
+ *
+ * Copyright (C) 2009 Felix Fietkau <nbd@openwrt.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundatio.
+ *
+ * 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.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <inttypes.h>
+#include <errno.h>
+#include <stdint.h>
+#include <getopt.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <uci.h>
+
+#include <linux/types.h>
+#include <linux/netlink.h>
+#include <linux/genetlink.h>
+#include <netlink/netlink.h>
+#include <netlink/genl/genl.h>
+#include <netlink/genl/ctrl.h>
+#include <linux/switch.h>
+#include "swlib.h"
+
+#ifndef ARRAY_SIZE
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
+#endif
+
+struct swlib_setting {
+ struct switch_attr *attr;
+ const char *name;
+ int port_vlan;
+ const char *val;
+ struct swlib_setting *next;
+};
+
+struct swlib_setting early_settings[] = {
+ { .name = "reset", .val = "1" },
+ { .name = "enable_vlan", .val = "1" },
+};
+
+static struct swlib_setting *settings;
+static struct swlib_setting **head;
+
+static bool swlib_match_name(struct switch_dev *dev, const char *name)
+{
+ return (strcmp(name, dev->dev_name) == 0 ||
+ strcmp(name, dev->alias) == 0);
+}
+
+static int
+swlib_map_settings(struct switch_dev *dev, int type, int port_vlan, struct uci_section *s)
+{
+ struct swlib_setting *setting;
+ struct switch_attr *attr;
+ struct uci_element *e;
+ struct uci_option *o;
+ int i;
+
+ uci_foreach_element(&s->options, e) {
+ o = uci_to_option(e);
+
+ if (o->type != UCI_TYPE_STRING)
+ continue;
+
+ if (!strcmp(e->name, "device"))
+ continue;
+
+ /* map early settings */
+ if (type == SWLIB_ATTR_GROUP_GLOBAL) {
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(early_settings); i++) {
+ if (strcmp(e->name, early_settings[i].name) != 0)
+ continue;
+
+ early_settings[i].val = o->v.string;
+ goto skip;
+ }
+ }
+
+ attr = swlib_lookup_attr(dev, type, e->name);
+ if (!attr)
+ continue;
+
+ setting = malloc(sizeof(struct swlib_setting));
+ memset(setting, 0, sizeof(struct swlib_setting));
+ setting->attr = attr;
+ setting->port_vlan = port_vlan;
+ setting->val = o->v.string;
+ *head = setting;
+ head = &setting->next;
+skip:
+ continue;
+ }
+}
+
+int swlib_apply_from_uci(struct switch_dev *dev, struct uci_package *p)
+{
+ struct switch_attr *attr;
+ struct uci_context *ctx = p->ctx;
+ struct uci_element *e;
+ struct uci_section *s;
+ struct uci_option *o;
+ struct uci_ptr ptr;
+ struct switch_val val;
+ int i;
+
+ settings = NULL;
+ head = &settings;
+
+ uci_foreach_element(&p->sections, e) {
+ struct uci_element *n;
+
+ s = uci_to_section(e);
+
+ if (strcmp(s->type, "switch") != 0)
+ continue;
+
+ uci_foreach_element(&s->options, n) {
+ struct uci_option *o = uci_to_option(n);
+
+ if (strcmp(n->name, "name") != 0)
+ continue;
+
+ if (o->type != UCI_TYPE_STRING)
+ continue;
+
+ if (swlib_match_name(dev, o->v.string))
+ goto found;
+
+ break;
+ }
+
+ if (!swlib_match_name(dev, e->name))
+ continue;
+
+ goto found;
+ }
+
+ /* not found */
+ return -1;
+
+found:
+ /* look up available early options, which need to be taken care
+ * of in the correct order */
+ for (i = 0; i < ARRAY_SIZE(early_settings); i++) {
+ early_settings[i].attr = swlib_lookup_attr(dev,
+ SWLIB_ATTR_GROUP_GLOBAL, early_settings[i].name);
+ }
+ swlib_map_settings(dev, SWLIB_ATTR_GROUP_GLOBAL, 0, s);
+
+ /* look for port or vlan sections */
+ uci_foreach_element(&p->sections, e) {
+ struct uci_element *os;
+ s = uci_to_section(e);
+
+ if (!strcmp(s->type, "switch_port")) {
+ char *devn, *port, *port_err = NULL;
+ int port_n;
+
+ uci_foreach_element(&s->options, os) {
+ o = uci_to_option(os);
+ if (o->type != UCI_TYPE_STRING)
+ continue;
+
+ if (!strcmp(os->name, "device")) {
+ devn = o->v.string;
+ if (!swlib_match_name(dev, devn))
+ devn = NULL;
+ } else if (!strcmp(os->name, "port")) {
+ port = o->v.string;
+ }
+ }
+ if (!devn || !port || !port[0])
+ continue;
+
+ port_n = strtoul(port, &port_err, 0);
+ if (port_err && port_err[0])
+ continue;
+
+ swlib_map_settings(dev, SWLIB_ATTR_GROUP_PORT, port_n, s);
+ } else if (!strcmp(s->type, "switch_vlan")) {
+ char *devn, *vlan, *vlan_err = NULL;
+ int vlan_n;
+
+ uci_foreach_element(&s->options, os) {
+ o = uci_to_option(os);
+ if (o->type != UCI_TYPE_STRING)
+ continue;
+
+ if (!strcmp(os->name, "device")) {
+ devn = o->v.string;
+ if (!swlib_match_name(dev, devn))
+ devn = NULL;
+ } else if (!strcmp(os->name, "vlan")) {
+ vlan = o->v.string;
+ }
+ }
+ if (!devn || !vlan || !vlan[0])
+ continue;
+
+ vlan_n = strtoul(vlan, &vlan_err, 0);
+ if (vlan_err && vlan_err[0])
+ continue;
+
+ swlib_map_settings(dev, SWLIB_ATTR_GROUP_VLAN, vlan_n, s);
+ }
+ }
+
+ for (i = 0; i < ARRAY_SIZE(early_settings); i++) {
+ struct swlib_setting *st = &early_settings[i];
+ if (!st->attr || !st->val)
+ continue;
+ swlib_set_attr_string(dev, st->attr, st->port_vlan, st->val);
+
+ }
+
+ while (settings) {
+ struct swlib_setting *st = settings;
+
+ swlib_set_attr_string(dev, st->attr, st->port_vlan, st->val);
+ st = st->next;
+ free(settings);
+ settings = st;
+ }
+
+ /* Apply the config */
+ attr = swlib_lookup_attr(dev, SWLIB_ATTR_GROUP_GLOBAL, "apply");
+ if (!attr)
+ return 0;
+
+ memset(&val, 0, sizeof(val));
+ swlib_set_attr(dev, attr, &val);
+
+ return 0;
+}
diff --git a/package/network/ipv6/.svn/entries b/package/network/ipv6/.svn/entries
new file mode 100644
index 0000000..d048ac0
--- /dev/null
+++ b/package/network/ipv6/.svn/entries
@@ -0,0 +1,49 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/ipv6
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-08T07:04:38.512412Z
+35902
+cyrus
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+6in4
+dir
+
+thc-ipv6
+dir
+
+6relayd
+dir
+
+odhcp6c
+dir
+
+6rd
+dir
+
+6to4
+dir
+
+ipv6-support
+dir
+
diff --git a/package/network/ipv6/6in4/.svn/entries b/package/network/ipv6/6in4/.svn/entries
new file mode 100644
index 0000000..7a482c8
--- /dev/null
+++ b/package/network/ipv6/6in4/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/ipv6/6in4
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-30T09:07:23.635655Z
+35409
+cyrus
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+files
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+d3b2dddfdfc31b48422d9e6d7e3646e5
+2013-01-30T09:05:53.592950Z
+35408
+cyrus
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+867
+
diff --git a/package/network/ipv6/6in4/.svn/text-base/Makefile.svn-base b/package/network/ipv6/6in4/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..7090234
--- /dev/null
+++ b/package/network/ipv6/6in4/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,42 @@
+#
+# Copyright (C) 2010-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=6in4
+PKG_VERSION:=14
+PKG_RELEASE:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/6in4
+ SECTION:=ipv6
+ CATEGORY:=IPv6
+ DEPENDS:=+kmod-ipv6 +kmod-sit
+ TITLE:=IPv6-in-IPv4 configuration support
+ MAINTAINER:=Jo-Philipp Wich <xm@subsignal.org>
+ PKGARCH:=all
+endef
+
+define Package/6in4/description
+Provides support for 6in4 tunnels in /etc/config/network.
+Refer to http://wiki.openwrt.org/doc/uci/network for
+configuration details.
+endef
+
+define Build/Compile
+endef
+
+define Build/Configure
+endef
+
+define Package/6in4/install
+ $(INSTALL_DIR) $(1)/lib/netifd/proto
+ $(INSTALL_BIN) ./files/6in4.sh $(1)/lib/netifd/proto/6in4.sh
+endef
+
+$(eval $(call BuildPackage,6in4))
diff --git a/package/network/ipv6/6in4/Makefile b/package/network/ipv6/6in4/Makefile
new file mode 100644
index 0000000..7090234
--- /dev/null
+++ b/package/network/ipv6/6in4/Makefile
@@ -0,0 +1,42 @@
+#
+# Copyright (C) 2010-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=6in4
+PKG_VERSION:=14
+PKG_RELEASE:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/6in4
+ SECTION:=ipv6
+ CATEGORY:=IPv6
+ DEPENDS:=+kmod-ipv6 +kmod-sit
+ TITLE:=IPv6-in-IPv4 configuration support
+ MAINTAINER:=Jo-Philipp Wich <xm@subsignal.org>
+ PKGARCH:=all
+endef
+
+define Package/6in4/description
+Provides support for 6in4 tunnels in /etc/config/network.
+Refer to http://wiki.openwrt.org/doc/uci/network for
+configuration details.
+endef
+
+define Build/Compile
+endef
+
+define Build/Configure
+endef
+
+define Package/6in4/install
+ $(INSTALL_DIR) $(1)/lib/netifd/proto
+ $(INSTALL_BIN) ./files/6in4.sh $(1)/lib/netifd/proto/6in4.sh
+endef
+
+$(eval $(call BuildPackage,6in4))
diff --git a/package/network/ipv6/6in4/files/.svn/entries b/package/network/ipv6/6in4/files/.svn/entries
new file mode 100644
index 0000000..01a84d1
--- /dev/null
+++ b/package/network/ipv6/6in4/files/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/ipv6/6in4/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-30T09:07:23.635655Z
+35409
+cyrus
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+6in4.sh
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+752b06366af2826d4be405b5e38ee151
+2013-01-30T09:07:23.635655Z
+35409
+cyrus
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2294
+
diff --git a/package/network/ipv6/6in4/files/.svn/prop-base/6in4.sh.svn-base b/package/network/ipv6/6in4/files/.svn/prop-base/6in4.sh.svn-base
new file mode 100644
index 0000000..869ac71
--- /dev/null
+++ b/package/network/ipv6/6in4/files/.svn/prop-base/6in4.sh.svn-base
@@ -0,0 +1,5 @@
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/network/ipv6/6in4/files/.svn/text-base/6in4.sh.svn-base b/package/network/ipv6/6in4/files/.svn/text-base/6in4.sh.svn-base
new file mode 100644
index 0000000..647a2f8
--- /dev/null
+++ b/package/network/ipv6/6in4/files/.svn/text-base/6in4.sh.svn-base
@@ -0,0 +1,97 @@
+#!/bin/sh
+# 6in4.sh - IPv6-in-IPv4 tunnel backend
+# Copyright (c) 2010-2012 OpenWrt.org
+
+[ -n "$INCLUDE_ONLY" ] || {
+ . /lib/functions.sh
+ . /lib/functions/network.sh
+ . ../netifd-proto.sh
+ init_proto "$@"
+}
+
+proto_6in4_setup() {
+ local cfg="$1"
+ local iface="$2"
+ local link="6in4-$cfg"
+
+ local mtu ttl ipaddr peeraddr ip6addr ip6prefix tunnelid username password
+ json_get_vars mtu ttl ipaddr peeraddr ip6addr ip6prefix tunnelid username password
+
+ [ -z "$peeraddr" ] && {
+ proto_notify_error "$cfg" "MISSING_ADDRESS"
+ proto_block_restart "$cfg"
+ return
+ }
+
+ ( proto_add_host_dependency "$cfg" 0.0.0.0 )
+
+ [ -z "$ipaddr" ] && {
+ local wanif
+ if ! network_find_wan wanif || ! network_get_ipaddr ipaddr "$wanif"; then
+ proto_notify_error "$cfg" "NO_WAN_LINK"
+ return
+ fi
+ }
+
+ proto_init_update "$link" 1
+ proto_add_ipv6_route "::" 0
+
+ [ -n "$ip6addr" ] && {
+ local local6="${ip6addr%%/*}"
+ local mask6="${ip6addr##*/}"
+ [[ "$local6" = "$mask6" ]] && mask6=
+ proto_add_ipv6_address "$local6" "$mask6"
+ }
+
+ [ -n "$ip6prefix" ] && proto_add_ipv6_prefix "$ip6prefix"
+
+ proto_add_tunnel
+ json_add_string mode sit
+ json_add_int mtu "${mtu:-1280}"
+ json_add_int ttl "${ttl:-64}"
+ json_add_string local "$ipaddr"
+ json_add_string remote "$peeraddr"
+ proto_close_tunnel
+
+ proto_send_update "$cfg"
+
+ [ -n "$tunnelid" -a -n "$username" -a -n "$password" ] && {
+ [ "${#password}" == 32 -a -z "${password//[a-fA-F0-9]/}" ] || {
+ password="$(echo -n "$password" | md5sum)"; password="${password%% *}"
+ }
+
+ local url="http://ipv4.tunnelbroker.net/ipv4_end.php?ip=AUTO&apikey=$username&pass=$password&tid=$tunnelid"
+ local try=0
+ local max=3
+
+ while [ $((++try)) -le $max ]; do
+ ( exec wget -qO/dev/null "$url" 2>/dev/null ) &
+ local pid=$!
+ ( sleep 5; kill $pid 2>/dev/null ) &
+ wait $pid && break
+ done
+ }
+}
+
+proto_6in4_teardown() {
+ local cfg="$1"
+}
+
+proto_6in4_init_config() {
+ no_device=1
+ available=1
+
+ proto_config_add_string "ipaddr"
+ proto_config_add_string "ip6addr"
+ proto_config_add_string "ip6prefix"
+ proto_config_add_string "peeraddr"
+ proto_config_add_string "tunnelid"
+ proto_config_add_string "username"
+ proto_config_add_string "password"
+ proto_config_add_int "mtu"
+ proto_config_add_int "ttl"
+}
+
+[ -n "$INCLUDE_ONLY" ] || {
+ add_protocol 6in4
+}
diff --git a/package/network/ipv6/6in4/files/6in4.sh b/package/network/ipv6/6in4/files/6in4.sh
new file mode 100755
index 0000000..647a2f8
--- /dev/null
+++ b/package/network/ipv6/6in4/files/6in4.sh
@@ -0,0 +1,97 @@
+#!/bin/sh
+# 6in4.sh - IPv6-in-IPv4 tunnel backend
+# Copyright (c) 2010-2012 OpenWrt.org
+
+[ -n "$INCLUDE_ONLY" ] || {
+ . /lib/functions.sh
+ . /lib/functions/network.sh
+ . ../netifd-proto.sh
+ init_proto "$@"
+}
+
+proto_6in4_setup() {
+ local cfg="$1"
+ local iface="$2"
+ local link="6in4-$cfg"
+
+ local mtu ttl ipaddr peeraddr ip6addr ip6prefix tunnelid username password
+ json_get_vars mtu ttl ipaddr peeraddr ip6addr ip6prefix tunnelid username password
+
+ [ -z "$peeraddr" ] && {
+ proto_notify_error "$cfg" "MISSING_ADDRESS"
+ proto_block_restart "$cfg"
+ return
+ }
+
+ ( proto_add_host_dependency "$cfg" 0.0.0.0 )
+
+ [ -z "$ipaddr" ] && {
+ local wanif
+ if ! network_find_wan wanif || ! network_get_ipaddr ipaddr "$wanif"; then
+ proto_notify_error "$cfg" "NO_WAN_LINK"
+ return
+ fi
+ }
+
+ proto_init_update "$link" 1
+ proto_add_ipv6_route "::" 0
+
+ [ -n "$ip6addr" ] && {
+ local local6="${ip6addr%%/*}"
+ local mask6="${ip6addr##*/}"
+ [[ "$local6" = "$mask6" ]] && mask6=
+ proto_add_ipv6_address "$local6" "$mask6"
+ }
+
+ [ -n "$ip6prefix" ] && proto_add_ipv6_prefix "$ip6prefix"
+
+ proto_add_tunnel
+ json_add_string mode sit
+ json_add_int mtu "${mtu:-1280}"
+ json_add_int ttl "${ttl:-64}"
+ json_add_string local "$ipaddr"
+ json_add_string remote "$peeraddr"
+ proto_close_tunnel
+
+ proto_send_update "$cfg"
+
+ [ -n "$tunnelid" -a -n "$username" -a -n "$password" ] && {
+ [ "${#password}" == 32 -a -z "${password//[a-fA-F0-9]/}" ] || {
+ password="$(echo -n "$password" | md5sum)"; password="${password%% *}"
+ }
+
+ local url="http://ipv4.tunnelbroker.net/ipv4_end.php?ip=AUTO&apikey=$username&pass=$password&tid=$tunnelid"
+ local try=0
+ local max=3
+
+ while [ $((++try)) -le $max ]; do
+ ( exec wget -qO/dev/null "$url" 2>/dev/null ) &
+ local pid=$!
+ ( sleep 5; kill $pid 2>/dev/null ) &
+ wait $pid && break
+ done
+ }
+}
+
+proto_6in4_teardown() {
+ local cfg="$1"
+}
+
+proto_6in4_init_config() {
+ no_device=1
+ available=1
+
+ proto_config_add_string "ipaddr"
+ proto_config_add_string "ip6addr"
+ proto_config_add_string "ip6prefix"
+ proto_config_add_string "peeraddr"
+ proto_config_add_string "tunnelid"
+ proto_config_add_string "username"
+ proto_config_add_string "password"
+ proto_config_add_int "mtu"
+ proto_config_add_int "ttl"
+}
+
+[ -n "$INCLUDE_ONLY" ] || {
+ add_protocol 6in4
+}
diff --git a/package/network/ipv6/6rd/.svn/entries b/package/network/ipv6/6rd/.svn/entries
new file mode 100644
index 0000000..7454b8e
--- /dev/null
+++ b/package/network/ipv6/6rd/.svn/entries
@@ -0,0 +1,68 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/ipv6/6rd
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-15T13:08:14.524192Z
+35173
+cyrus
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+files
+dir
+
+src
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+1ed988f895276b36ca94509d7b34d884
+2013-01-15T13:08:14.524192Z
+35173
+cyrus
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1143
+
diff --git a/package/network/ipv6/6rd/.svn/text-base/Makefile.svn-base b/package/network/ipv6/6rd/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..f64cab3
--- /dev/null
+++ b/package/network/ipv6/6rd/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,53 @@
+#
+# Copyright (C) 2010-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=6rd
+PKG_VERSION:=3
+PKG_RELEASE:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/6rd
+ SECTION:=ipv6
+ CATEGORY:=IPv6
+ DEPENDS:=+kmod-ipv6 +kmod-sit
+ TITLE:=6rd configuration support
+ MAINTAINER:=Stéphan Kochen <stephan@kochen.nl>
+ PKGARCH:=all
+endef
+
+define Package/6rd/description
+Provides support for 6rd tunnels in /etc/config/network.
+Refer to http://wiki.openwrt.org/doc/uci/network for
+configuration details.
+endef
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ CC="$(TARGET_CC)" \
+ CFLAGS="$(TARGET_CFLAGS) -Wall" \
+ LDFLAGS="$(TARGET_LDFLAGS)"
+endef
+
+define Package/6rd/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/6rdcalc $(1)/usr/sbin/
+ $(INSTALL_DIR) $(1)/lib/netifd/proto
+ $(INSTALL_BIN) ./files/6rd.sh $(1)/lib/netifd/proto/6rd.sh
+endef
+
+$(eval $(call BuildPackage,6rd))
diff --git a/package/network/ipv6/6rd/Makefile b/package/network/ipv6/6rd/Makefile
new file mode 100644
index 0000000..f64cab3
--- /dev/null
+++ b/package/network/ipv6/6rd/Makefile
@@ -0,0 +1,53 @@
+#
+# Copyright (C) 2010-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=6rd
+PKG_VERSION:=3
+PKG_RELEASE:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/6rd
+ SECTION:=ipv6
+ CATEGORY:=IPv6
+ DEPENDS:=+kmod-ipv6 +kmod-sit
+ TITLE:=6rd configuration support
+ MAINTAINER:=Stéphan Kochen <stephan@kochen.nl>
+ PKGARCH:=all
+endef
+
+define Package/6rd/description
+Provides support for 6rd tunnels in /etc/config/network.
+Refer to http://wiki.openwrt.org/doc/uci/network for
+configuration details.
+endef
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ CC="$(TARGET_CC)" \
+ CFLAGS="$(TARGET_CFLAGS) -Wall" \
+ LDFLAGS="$(TARGET_LDFLAGS)"
+endef
+
+define Package/6rd/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/6rdcalc $(1)/usr/sbin/
+ $(INSTALL_DIR) $(1)/lib/netifd/proto
+ $(INSTALL_BIN) ./files/6rd.sh $(1)/lib/netifd/proto/6rd.sh
+endef
+
+$(eval $(call BuildPackage,6rd))
diff --git a/package/network/ipv6/6rd/files/.svn/entries b/package/network/ipv6/6rd/files/.svn/entries
new file mode 100644
index 0000000..178384a
--- /dev/null
+++ b/package/network/ipv6/6rd/files/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/ipv6/6rd/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-15T13:08:14.524192Z
+35173
+cyrus
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+6rd.sh
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+5abd0f2cf32c18ad7a5c9b6ff29d3de3
+2013-01-15T13:08:14.524192Z
+35173
+cyrus
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2071
+
diff --git a/package/network/ipv6/6rd/files/.svn/text-base/6rd.sh.svn-base b/package/network/ipv6/6rd/files/.svn/text-base/6rd.sh.svn-base
new file mode 100644
index 0000000..b681f2b
--- /dev/null
+++ b/package/network/ipv6/6rd/files/.svn/text-base/6rd.sh.svn-base
@@ -0,0 +1,84 @@
+#!/bin/sh
+# 6rd.sh - IPv6-in-IPv4 tunnel backend
+# Copyright (c) 2010-2012 OpenWrt.org
+
+[ -n "$INCLUDE_ONLY" ] || {
+ . /lib/functions.sh
+ . /lib/functions/network.sh
+ . ../netifd-proto.sh
+ init_proto "$@"
+}
+
+proto_6rd_setup() {
+ local cfg="$1"
+ local iface="$2"
+ local link="6rd-$cfg"
+
+ local mtu ttl ipaddr peeraddr ip6prefix ip6prefixlen ip4prefixlen
+ json_get_vars mtu ttl ipaddr peeraddr ip6prefix ip6prefixlen ip4prefixlen
+
+ [ -z "$ip6prefix" -o -z "$peeraddr" ] && {
+ proto_notify_error "$cfg" "MISSING_ADDRESS"
+ proto_block_restart "$cfg"
+ return
+ }
+
+ ( proto_add_host_dependency "$cfg" 0.0.0.0 )
+
+ [ -z "$ipaddr" ] && {
+ local wanif
+ if ! network_find_wan wanif || ! network_get_ipaddr ipaddr "$wanif"; then
+ proto_notify_error "$cfg" "NO_WAN_LINK"
+ return
+ fi
+ }
+
+ # Determine the relay prefix.
+ local ip4prefixlen="${ip4prefixlen:-0}"
+ local ip4prefix=$(ipcalc.sh "$ipaddr/$ip4prefixlen" | grep NETWORK)
+ ip4prefix="${ip4prefix#NETWORK=}"
+
+ # Determine our IPv6 address.
+ local ip6subnet=$(6rdcalc "$ip6prefix/$ip6prefixlen" "$ipaddr/$ip4prefixlen")
+ local ip6addr="${ip6subnet%%::*}::1"
+
+ # Determine the IPv6 prefix
+ local ip6lanprefix="$ip6subnet/$(($ip6prefixlen + 32 - $ip4prefixlen))"
+
+ proto_init_update "$link" 1
+ proto_add_ipv6_address "$ip6addr" "$ip6prefixlen"
+ proto_add_ipv6_prefix "$ip6lanprefix"
+ proto_add_ipv6_route "::" 0 "::$peeraddr"
+
+ proto_add_tunnel
+ json_add_string mode sit
+ json_add_int mtu "${mtu:-1280}"
+ json_add_int ttl "${ttl:-64}"
+ json_add_string local "$ipaddr"
+ json_add_string 6rd-prefix "$ip6prefix/$ip6prefixlen"
+ json_add_string 6rd-relay-prefix "$ip4prefix/$ip4prefixlen"
+ proto_close_tunnel
+
+ proto_send_update "$cfg"
+}
+
+proto_6rd_teardown() {
+ local cfg="$1"
+}
+
+proto_6rd_init_config() {
+ no_device=1
+ available=1
+
+ proto_config_add_int "mtu"
+ proto_config_add_int "ttl"
+ proto_config_add_string "ipaddr"
+ proto_config_add_string "peeraddr"
+ proto_config_add_string "ip6prefix"
+ proto_config_add_string "ip6prefixlen"
+ proto_config_add_string "ip4prefixlen"
+}
+
+[ -n "$INCLUDE_ONLY" ] || {
+ add_protocol 6rd
+}
diff --git a/package/network/ipv6/6rd/files/6rd.sh b/package/network/ipv6/6rd/files/6rd.sh
new file mode 100644
index 0000000..b681f2b
--- /dev/null
+++ b/package/network/ipv6/6rd/files/6rd.sh
@@ -0,0 +1,84 @@
+#!/bin/sh
+# 6rd.sh - IPv6-in-IPv4 tunnel backend
+# Copyright (c) 2010-2012 OpenWrt.org
+
+[ -n "$INCLUDE_ONLY" ] || {
+ . /lib/functions.sh
+ . /lib/functions/network.sh
+ . ../netifd-proto.sh
+ init_proto "$@"
+}
+
+proto_6rd_setup() {
+ local cfg="$1"
+ local iface="$2"
+ local link="6rd-$cfg"
+
+ local mtu ttl ipaddr peeraddr ip6prefix ip6prefixlen ip4prefixlen
+ json_get_vars mtu ttl ipaddr peeraddr ip6prefix ip6prefixlen ip4prefixlen
+
+ [ -z "$ip6prefix" -o -z "$peeraddr" ] && {
+ proto_notify_error "$cfg" "MISSING_ADDRESS"
+ proto_block_restart "$cfg"
+ return
+ }
+
+ ( proto_add_host_dependency "$cfg" 0.0.0.0 )
+
+ [ -z "$ipaddr" ] && {
+ local wanif
+ if ! network_find_wan wanif || ! network_get_ipaddr ipaddr "$wanif"; then
+ proto_notify_error "$cfg" "NO_WAN_LINK"
+ return
+ fi
+ }
+
+ # Determine the relay prefix.
+ local ip4prefixlen="${ip4prefixlen:-0}"
+ local ip4prefix=$(ipcalc.sh "$ipaddr/$ip4prefixlen" | grep NETWORK)
+ ip4prefix="${ip4prefix#NETWORK=}"
+
+ # Determine our IPv6 address.
+ local ip6subnet=$(6rdcalc "$ip6prefix/$ip6prefixlen" "$ipaddr/$ip4prefixlen")
+ local ip6addr="${ip6subnet%%::*}::1"
+
+ # Determine the IPv6 prefix
+ local ip6lanprefix="$ip6subnet/$(($ip6prefixlen + 32 - $ip4prefixlen))"
+
+ proto_init_update "$link" 1
+ proto_add_ipv6_address "$ip6addr" "$ip6prefixlen"
+ proto_add_ipv6_prefix "$ip6lanprefix"
+ proto_add_ipv6_route "::" 0 "::$peeraddr"
+
+ proto_add_tunnel
+ json_add_string mode sit
+ json_add_int mtu "${mtu:-1280}"
+ json_add_int ttl "${ttl:-64}"
+ json_add_string local "$ipaddr"
+ json_add_string 6rd-prefix "$ip6prefix/$ip6prefixlen"
+ json_add_string 6rd-relay-prefix "$ip4prefix/$ip4prefixlen"
+ proto_close_tunnel
+
+ proto_send_update "$cfg"
+}
+
+proto_6rd_teardown() {
+ local cfg="$1"
+}
+
+proto_6rd_init_config() {
+ no_device=1
+ available=1
+
+ proto_config_add_int "mtu"
+ proto_config_add_int "ttl"
+ proto_config_add_string "ipaddr"
+ proto_config_add_string "peeraddr"
+ proto_config_add_string "ip6prefix"
+ proto_config_add_string "ip6prefixlen"
+ proto_config_add_string "ip4prefixlen"
+}
+
+[ -n "$INCLUDE_ONLY" ] || {
+ add_protocol 6rd
+}
diff --git a/package/network/ipv6/6rd/src/.svn/entries b/package/network/ipv6/6rd/src/.svn/entries
new file mode 100644
index 0000000..878d022
--- /dev/null
+++ b/package/network/ipv6/6rd/src/.svn/entries
@@ -0,0 +1,96 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/ipv6/6rd/src
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-06-18T23:08:18.797281Z
+32431
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+6rdcalc.c
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+99f5d2b1c3aa4af8d44adef1a3b1f4cc
+2012-06-18T23:08:18.797281Z
+32431
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3114
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+2f9f4272c2d29bfb72744767524b93eb
+2012-06-18T23:08:18.797281Z
+32431
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+93
+
diff --git a/package/network/ipv6/6rd/src/.svn/text-base/6rdcalc.c.svn-base b/package/network/ipv6/6rd/src/.svn/text-base/6rdcalc.c.svn-base
new file mode 100644
index 0000000..56e07d2
--- /dev/null
+++ b/package/network/ipv6/6rd/src/.svn/text-base/6rdcalc.c.svn-base
@@ -0,0 +1,126 @@
+/*
+ * Utility used to calculate the 6rd subnet.
+ *
+ * Copyright 2012, Stéphan Kochen <stephan@kochen.nl>
+ *
+ * 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
+ * of the License, 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/errno.h>
+#include <arpa/inet.h>
+#include <netinet/in.h>
+
+#define INET_PREFIXSTRLEN (INET_ADDRSTRLEN+3)
+#define INET6_PREFIXSTRLEN (INET6_ADDRSTRLEN+4)
+
+static void print_usage()
+{
+ fprintf(stderr, "Usage: 6rdcalc <v6 prefix>/<mask> <v4 address>/<mask>\n");
+ exit(1);
+}
+
+static void print_error()
+{
+ fprintf(stderr, "%s", strerror(errno));
+ exit(1);
+}
+
+static void parse_str(int af, char *str, void *addr, unsigned long *mask)
+{
+ int ret;
+ char *slash;
+
+ /* Split the address at the slash. */
+ if ((slash = strchr(str, '/')) == NULL)
+ print_usage();
+ *slash = '\0';
+
+ /* Parse the address. */
+ if ((ret = inet_pton(af, str, addr)) != 1) {
+ if (ret == 0)
+ print_usage();
+ else
+ print_error();
+ }
+
+ /* Parse the mask. */
+ *mask = strtoul(slash+1, NULL, 10);
+ if ((af == AF_INET && *mask > 32) ||
+ (af == AF_INET6 && *mask > 128))
+ print_usage();
+}
+
+int main(int argc, const char **argv)
+{
+ char v6str[INET6_PREFIXSTRLEN], v4str[INET_PREFIXSTRLEN];
+ struct in6_addr v6;
+ struct in_addr v4;
+ unsigned long v6it, v4it, mask;
+ unsigned char *byte4, *byte6;
+ unsigned char bit4, bit6;
+
+ /* Check parameters. */
+ if (argc != 3)
+ print_usage();
+
+ /* Parse the v6 address. */
+ strncpy(v6str, argv[1], INET6_PREFIXSTRLEN);
+ v6str[INET6_PREFIXSTRLEN-1] = '\0';
+ parse_str(AF_INET6, v6str, &v6, &v6it);
+
+ /* Parse the v4 address */
+ strncpy(v4str, argv[2], INET_PREFIXSTRLEN);
+ v6str[INET_PREFIXSTRLEN-1] = '\0';
+ parse_str(AF_INET, v4str, &v4, &v4it);
+
+ /* Check if the combined mask is within bounds. */
+ mask = (32 - v4it) + v6it;
+ if (mask > 128)
+ print_usage();
+
+ /* Combine the addresses. */
+ while (v4it < 32) {
+ byte6 = (unsigned char *)(&v6.s6_addr) + (v6it >> 3);
+ byte4 = (unsigned char *)(&v4.s_addr) + (v4it >> 3);
+ bit6 = 128 >> (v6it & 0x07);
+ bit4 = 128 >> (v4it & 0x07);
+
+ if (*byte4 & bit4)
+ *byte6 |= bit6;
+ else
+ *byte6 &= ~bit6;
+
+ v4it++; v6it++;
+ }
+
+ /* Clear remaining bits. */
+ while (v6it < 128) {
+ byte6 = (unsigned char *)(&v6.s6_addr) + (v6it >> 2);
+ bit6 = 128 >> (v6it & 0x07);
+
+ *byte6 &= ~bit6;
+
+ v6it++;
+ }
+
+ /* Print the subnet prefix. */
+ if (inet_ntop(AF_INET6, &v6, v6str, sizeof(v6str)) == NULL)
+ print_error();
+ printf("%s/%lu\n", v6str, mask);
+ return 0;
+}
diff --git a/package/network/ipv6/6rd/src/.svn/text-base/Makefile.svn-base b/package/network/ipv6/6rd/src/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..2881d43
--- /dev/null
+++ b/package/network/ipv6/6rd/src/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,7 @@
+all: 6rdcalc
+
+6rdcalc: 6rdcalc.c
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $<
+
+clean:
+ rm -f 6rdcalc
diff --git a/package/network/ipv6/6rd/src/6rdcalc.c b/package/network/ipv6/6rd/src/6rdcalc.c
new file mode 100644
index 0000000..56e07d2
--- /dev/null
+++ b/package/network/ipv6/6rd/src/6rdcalc.c
@@ -0,0 +1,126 @@
+/*
+ * Utility used to calculate the 6rd subnet.
+ *
+ * Copyright 2012, Stéphan Kochen <stephan@kochen.nl>
+ *
+ * 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
+ * of the License, 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/errno.h>
+#include <arpa/inet.h>
+#include <netinet/in.h>
+
+#define INET_PREFIXSTRLEN (INET_ADDRSTRLEN+3)
+#define INET6_PREFIXSTRLEN (INET6_ADDRSTRLEN+4)
+
+static void print_usage()
+{
+ fprintf(stderr, "Usage: 6rdcalc <v6 prefix>/<mask> <v4 address>/<mask>\n");
+ exit(1);
+}
+
+static void print_error()
+{
+ fprintf(stderr, "%s", strerror(errno));
+ exit(1);
+}
+
+static void parse_str(int af, char *str, void *addr, unsigned long *mask)
+{
+ int ret;
+ char *slash;
+
+ /* Split the address at the slash. */
+ if ((slash = strchr(str, '/')) == NULL)
+ print_usage();
+ *slash = '\0';
+
+ /* Parse the address. */
+ if ((ret = inet_pton(af, str, addr)) != 1) {
+ if (ret == 0)
+ print_usage();
+ else
+ print_error();
+ }
+
+ /* Parse the mask. */
+ *mask = strtoul(slash+1, NULL, 10);
+ if ((af == AF_INET && *mask > 32) ||
+ (af == AF_INET6 && *mask > 128))
+ print_usage();
+}
+
+int main(int argc, const char **argv)
+{
+ char v6str[INET6_PREFIXSTRLEN], v4str[INET_PREFIXSTRLEN];
+ struct in6_addr v6;
+ struct in_addr v4;
+ unsigned long v6it, v4it, mask;
+ unsigned char *byte4, *byte6;
+ unsigned char bit4, bit6;
+
+ /* Check parameters. */
+ if (argc != 3)
+ print_usage();
+
+ /* Parse the v6 address. */
+ strncpy(v6str, argv[1], INET6_PREFIXSTRLEN);
+ v6str[INET6_PREFIXSTRLEN-1] = '\0';
+ parse_str(AF_INET6, v6str, &v6, &v6it);
+
+ /* Parse the v4 address */
+ strncpy(v4str, argv[2], INET_PREFIXSTRLEN);
+ v6str[INET_PREFIXSTRLEN-1] = '\0';
+ parse_str(AF_INET, v4str, &v4, &v4it);
+
+ /* Check if the combined mask is within bounds. */
+ mask = (32 - v4it) + v6it;
+ if (mask > 128)
+ print_usage();
+
+ /* Combine the addresses. */
+ while (v4it < 32) {
+ byte6 = (unsigned char *)(&v6.s6_addr) + (v6it >> 3);
+ byte4 = (unsigned char *)(&v4.s_addr) + (v4it >> 3);
+ bit6 = 128 >> (v6it & 0x07);
+ bit4 = 128 >> (v4it & 0x07);
+
+ if (*byte4 & bit4)
+ *byte6 |= bit6;
+ else
+ *byte6 &= ~bit6;
+
+ v4it++; v6it++;
+ }
+
+ /* Clear remaining bits. */
+ while (v6it < 128) {
+ byte6 = (unsigned char *)(&v6.s6_addr) + (v6it >> 2);
+ bit6 = 128 >> (v6it & 0x07);
+
+ *byte6 &= ~bit6;
+
+ v6it++;
+ }
+
+ /* Print the subnet prefix. */
+ if (inet_ntop(AF_INET6, &v6, v6str, sizeof(v6str)) == NULL)
+ print_error();
+ printf("%s/%lu\n", v6str, mask);
+ return 0;
+}
diff --git a/package/network/ipv6/6rd/src/Makefile b/package/network/ipv6/6rd/src/Makefile
new file mode 100644
index 0000000..2881d43
--- /dev/null
+++ b/package/network/ipv6/6rd/src/Makefile
@@ -0,0 +1,7 @@
+all: 6rdcalc
+
+6rdcalc: 6rdcalc.c
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $<
+
+clean:
+ rm -f 6rdcalc
diff --git a/package/network/ipv6/6relayd/.svn/entries b/package/network/ipv6/6relayd/.svn/entries
new file mode 100644
index 0000000..f0c85b4
--- /dev/null
+++ b/package/network/ipv6/6relayd/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/ipv6/6relayd
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-02-28T16:37:20.110304Z
+35836
+cyrus
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+files
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+f5afb33903e6de931a3cb199b6df4d25
+2013-02-28T16:37:20.110304Z
+35836
+cyrus
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1747
+
diff --git a/package/network/ipv6/6relayd/.svn/text-base/Makefile.svn-base b/package/network/ipv6/6relayd/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..1747a0c
--- /dev/null
+++ b/package/network/ipv6/6relayd/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,57 @@
+#
+# Copyright (C) 2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=6relayd
+PKG_VERSION:=2013-02-28.1
+PKG_RELEASE=$(PKG_SOURCE_VERSION)
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE_URL:=git://github.com/sbyx/6relayd.git
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_VERSION:=be18c9722e8fa76ca96de16fb927b85bfe3197bc
+
+PKG_MAINTAINER:=Steven Barth <steven@midlink.org>
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/cmake.mk
+
+define Package/6relayd
+ SECTION:=ipv6
+ CATEGORY:=IPv6
+ TITLE:=IPv6-Relay and Server (RD-, DHCPv6- & NDP-Proxy)
+ DEPENDS:=+kmod-ipv6
+endef
+
+define Package/6relayd/description
+ 6relayd is an IPv6-tool that relays IPv6-management protocols like router
+ discovery, neighbor discovery and DHCPv6 so that clients on routed (non-
+ bridged) interfaces can use the public address prefix, DHCPv6 and DNS-service
+ of a master interface. This is useful to avoid NAT in chained IPv6-routers.
+
+ It can also be used as a lightweight router advertisement daemon and provide
+ stateless DHCPv6 service where size matters.
+endef
+
+define Package/6relayd/conffiles
+/etc/config/6relayd
+endef
+
+define Package/6relayd/install
+ $(INSTALL_DIR) $(1)/usr/sbin/
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/6relayd $(1)/usr/sbin/
+ $(INSTALL_DIR) $(1)/etc/hotplug.d/iface
+ $(INSTALL_DATA) ./files/6relayd.hotplug $(1)/etc/hotplug.d/iface/30-6relay
+ $(INSTALL_DIR) $(1)/etc/config
+ $(INSTALL_DATA) ./files/6relayd.config $(1)/etc/config/6relayd
+ $(INSTALL_DIR) $(1)/etc/init.d
+ $(INSTALL_BIN) ./files/6relayd.init $(1)/etc/init.d/6relayd
+endef
+
+$(eval $(call BuildPackage,6relayd))
diff --git a/package/network/ipv6/6relayd/Makefile b/package/network/ipv6/6relayd/Makefile
new file mode 100644
index 0000000..1747a0c
--- /dev/null
+++ b/package/network/ipv6/6relayd/Makefile
@@ -0,0 +1,57 @@
+#
+# Copyright (C) 2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=6relayd
+PKG_VERSION:=2013-02-28.1
+PKG_RELEASE=$(PKG_SOURCE_VERSION)
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE_URL:=git://github.com/sbyx/6relayd.git
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_VERSION:=be18c9722e8fa76ca96de16fb927b85bfe3197bc
+
+PKG_MAINTAINER:=Steven Barth <steven@midlink.org>
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/cmake.mk
+
+define Package/6relayd
+ SECTION:=ipv6
+ CATEGORY:=IPv6
+ TITLE:=IPv6-Relay and Server (RD-, DHCPv6- & NDP-Proxy)
+ DEPENDS:=+kmod-ipv6
+endef
+
+define Package/6relayd/description
+ 6relayd is an IPv6-tool that relays IPv6-management protocols like router
+ discovery, neighbor discovery and DHCPv6 so that clients on routed (non-
+ bridged) interfaces can use the public address prefix, DHCPv6 and DNS-service
+ of a master interface. This is useful to avoid NAT in chained IPv6-routers.
+
+ It can also be used as a lightweight router advertisement daemon and provide
+ stateless DHCPv6 service where size matters.
+endef
+
+define Package/6relayd/conffiles
+/etc/config/6relayd
+endef
+
+define Package/6relayd/install
+ $(INSTALL_DIR) $(1)/usr/sbin/
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/6relayd $(1)/usr/sbin/
+ $(INSTALL_DIR) $(1)/etc/hotplug.d/iface
+ $(INSTALL_DATA) ./files/6relayd.hotplug $(1)/etc/hotplug.d/iface/30-6relay
+ $(INSTALL_DIR) $(1)/etc/config
+ $(INSTALL_DATA) ./files/6relayd.config $(1)/etc/config/6relayd
+ $(INSTALL_DIR) $(1)/etc/init.d
+ $(INSTALL_BIN) ./files/6relayd.init $(1)/etc/init.d/6relayd
+endef
+
+$(eval $(call BuildPackage,6relayd))
diff --git a/package/network/ipv6/6relayd/files/.svn/entries b/package/network/ipv6/6relayd/files/.svn/entries
new file mode 100644
index 0000000..02e80a3
--- /dev/null
+++ b/package/network/ipv6/6relayd/files/.svn/entries
@@ -0,0 +1,130 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/ipv6/6relayd/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-02-26T12:50:52.933860Z
+35804
+cyrus
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+6relayd.hotplug
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+bd1477ea6cb06081071bc688a0843f8f
+2013-01-13T17:25:38.265787Z
+35133
+cyrus
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+131
+
+6relayd.init
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+74a289472660a10ee22b6b98c6e0b0d7
+2013-02-26T12:50:52.933860Z
+35804
+cyrus
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3388
+
+6relayd.config
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+784924a6963693b36d249277c24374ac
+2013-02-26T12:42:53.360009Z
+35803
+cyrus
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+681
+
diff --git a/package/network/ipv6/6relayd/files/.svn/text-base/6relayd.config.svn-base b/package/network/ipv6/6relayd/files/.svn/text-base/6relayd.config.svn-base
new file mode 100644
index 0000000..a4376c0
--- /dev/null
+++ b/package/network/ipv6/6relayd/files/.svn/text-base/6relayd.config.svn-base
@@ -0,0 +1,28 @@
+config server default
+ option master wan6
+ list network lan
+ option rd server
+ option dhcpv6 server
+ option fallback_relay 'rd dhcpv6 ndp'
+ option compat_ula 1
+
+
+# Example #1: Create a relay for several networks in proxy mode
+# This can be used to proxy Router Discovery, DHCPv6 and NDP.
+
+#config server examplerelay
+# option master 'wan'
+# option network 'lan'
+# option rd 'relay'
+# option dhcpv6 'relay'
+# option ndp 'relay'
+
+
+# Example #2: Provide Router Discovery and stateless DHCPv6 in server mode
+# This can be used as a small radvd and stateless DHCPv6-server replacement.
+
+#config server exampleserver
+# option network 'lan'
+# option rd 'server'
+# option dhcpv6 'server'
+
diff --git a/package/network/ipv6/6relayd/files/.svn/text-base/6relayd.hotplug.svn-base b/package/network/ipv6/6relayd/files/.svn/text-base/6relayd.hotplug.svn-base
new file mode 100644
index 0000000..7905282
--- /dev/null
+++ b/package/network/ipv6/6relayd/files/.svn/text-base/6relayd.hotplug.svn-base
@@ -0,0 +1,6 @@
+#!/bin/sh
+/etc/init.d/6relayd enabled || exit 0
+[ -n "$INTERFACE" ] || exit 0
+
+. /etc/init.d/6relayd
+restart_affected "$INTERFACE"
diff --git a/package/network/ipv6/6relayd/files/.svn/text-base/6relayd.init.svn-base b/package/network/ipv6/6relayd/files/.svn/text-base/6relayd.init.svn-base
new file mode 100644
index 0000000..ef0c711
--- /dev/null
+++ b/package/network/ipv6/6relayd/files/.svn/text-base/6relayd.init.svn-base
@@ -0,0 +1,135 @@
+#!/bin/sh /etc/rc.common
+# Copyright (c) 2011-2012 OpenWrt.org
+START=80
+
+start_6relayd() {
+ local cfg="$1"
+ local mode="$2"
+ local args=""
+
+ SERVICE_DAEMONIZE=1
+ SERVICE_WRITE_PID=1
+ SERVICE_PID_FILE="/var/run/6relayd-$cfg.pid"
+ [ -f "$SERVICE_PID_FILE" ] && {
+ if grep -q 6relayd "/proc/$(cat $SERVICE_PID_FILE)/cmdline"; then
+ return 0
+ else
+ rm -f "$SERVICE_PID_FILE"
+ fi
+ }
+
+ # Detect master interface
+ local master masterif
+ config_get masterif "$cfg" master
+ network_get_device master "$masterif"
+ [ -z "$master" ] && master="."
+
+ # Detect slave interfaces
+ local slaves=""
+ local slaveifs
+ config_get slaveifs "$cfg" network
+ for slaveif in $slaveifs; do
+ local slave
+ network_get_device slave "$slaveif"
+ # Compatibility with old config format
+ if [ "$mode" = "relay" -a "$master" = "." ]; then
+ [ -z "$slave" ] && return 0
+ master="$slave"
+ else
+ [ -n "$slave" ] && append slaves "$slave"
+ fi
+ done
+
+ # Bail if no slaves are active
+ [ -z "$slaves" ] && return 0
+
+ # Configure services
+ local rd dhcpv6 ndp
+ config_get rd "$cfg" rd
+ config_get dhcpv6 "$cfg" dhcpv6
+ config_get ndp "$cfg" ndp
+
+ # Test for fallback mode
+ local fallback fallback_relay
+ config_get fallback_relay "$cfg" fallback_relay
+
+ if [ -n "$fallback_relay" -a "$master" != "." ]; then
+ local prefix
+ network_get_prefix6 prefix "$masterif"
+ [ -z "$prefix" ] && fallback=1
+ fi
+
+ if [ -n "$fallback" ]; then
+ for service in $fallback_relay; do
+ eval "$service=relay"
+ done
+ fi
+
+ # Configure feature options
+ local always_rewrite_dns rewrite_dns_addr
+ config_get_bool always_rewrite_dns "$cfg" always_rewrite_dns 0
+ config_get rewrite_dns_addr "$cfg" rewrite_dns_addr
+ [ "$always_rewrite_dns" -eq 1 -o -n "$rewrite_dns_addr" ] && append args "-n$rewrite_dns_addr"
+
+ local always_assume_default
+ config_get_bool always_assume_default "$cfg" always_assume_default 0
+ [ "$always_assume_default" -eq 1 ] && append args "-u"
+
+ local compat_ula
+ config_get_bool compat_ula "$cfg" compat_ula 0
+ [ "$compat_ula" -eq 1 ] && append args "-c"
+
+ [ "$ndp" = "relay" ] && append args "-N -s -l"
+ [ "$rd" = "relay" ] && append args "-Rrelay"
+ [ "$rd" = "server" ] && append args "-Rserver"
+ [ "$dhcpv6" = "relay" ] && append args "-Drelay"
+ [ "$dhcpv6" = "server" ] && append args "-Dserver"
+ [ "$ndp" != "relay" -a "$rd" != "relay" -a "$dhcpv6" != "relay" ] && master="."
+
+ service_start /usr/sbin/6relayd $args $master $slaves
+}
+
+restart_affected_6relayd() {
+ local cfg="$1"
+ local net="$2"
+ local mode="$3"
+
+ local master slaves
+ config_get master "$cfg" master
+ config_get slaves "$cfg" network
+
+ for iface in $master $slaves; do
+ if [ "$iface" = "$net" ]; then
+ SERVICE_PID_FILE="/var/run/6relayd-$cfg.pid"
+ service_stop /usr/sbin/6relayd
+ rm -f "$SERVICE_PID_FILE"
+ start_6relayd "$cfg" "$mode"
+ fi
+ done
+}
+
+restart_affected() {
+ . /lib/functions/service.sh
+ . /lib/functions/network.sh
+ local net="$1"
+ config_load 6relayd
+ config_foreach restart_affected_6relayd server "$net"
+ config_foreach restart_affected_6relayd relay "$net" "relay"
+}
+
+stop() {
+ . /lib/functions/service.sh
+ for pid in /var/run/6relayd-*.pid; do
+ SERVICE_PID_FILE="$pid"
+ service_stop /usr/sbin/6relayd
+ rm -f "$SERVICE_PID_FILE"
+ done
+}
+
+start() {
+ . /lib/functions/service.sh
+ . /lib/functions/network.sh
+ config_load 6relayd
+ config_foreach start_6relayd server
+ config_foreach start_6relayd relay relay
+}
diff --git a/package/network/ipv6/6relayd/files/6relayd.config b/package/network/ipv6/6relayd/files/6relayd.config
new file mode 100644
index 0000000..a4376c0
--- /dev/null
+++ b/package/network/ipv6/6relayd/files/6relayd.config
@@ -0,0 +1,28 @@
+config server default
+ option master wan6
+ list network lan
+ option rd server
+ option dhcpv6 server
+ option fallback_relay 'rd dhcpv6 ndp'
+ option compat_ula 1
+
+
+# Example #1: Create a relay for several networks in proxy mode
+# This can be used to proxy Router Discovery, DHCPv6 and NDP.
+
+#config server examplerelay
+# option master 'wan'
+# option network 'lan'
+# option rd 'relay'
+# option dhcpv6 'relay'
+# option ndp 'relay'
+
+
+# Example #2: Provide Router Discovery and stateless DHCPv6 in server mode
+# This can be used as a small radvd and stateless DHCPv6-server replacement.
+
+#config server exampleserver
+# option network 'lan'
+# option rd 'server'
+# option dhcpv6 'server'
+
diff --git a/package/network/ipv6/6relayd/files/6relayd.hotplug b/package/network/ipv6/6relayd/files/6relayd.hotplug
new file mode 100644
index 0000000..7905282
--- /dev/null
+++ b/package/network/ipv6/6relayd/files/6relayd.hotplug
@@ -0,0 +1,6 @@
+#!/bin/sh
+/etc/init.d/6relayd enabled || exit 0
+[ -n "$INTERFACE" ] || exit 0
+
+. /etc/init.d/6relayd
+restart_affected "$INTERFACE"
diff --git a/package/network/ipv6/6relayd/files/6relayd.init b/package/network/ipv6/6relayd/files/6relayd.init
new file mode 100644
index 0000000..ef0c711
--- /dev/null
+++ b/package/network/ipv6/6relayd/files/6relayd.init
@@ -0,0 +1,135 @@
+#!/bin/sh /etc/rc.common
+# Copyright (c) 2011-2012 OpenWrt.org
+START=80
+
+start_6relayd() {
+ local cfg="$1"
+ local mode="$2"
+ local args=""
+
+ SERVICE_DAEMONIZE=1
+ SERVICE_WRITE_PID=1
+ SERVICE_PID_FILE="/var/run/6relayd-$cfg.pid"
+ [ -f "$SERVICE_PID_FILE" ] && {
+ if grep -q 6relayd "/proc/$(cat $SERVICE_PID_FILE)/cmdline"; then
+ return 0
+ else
+ rm -f "$SERVICE_PID_FILE"
+ fi
+ }
+
+ # Detect master interface
+ local master masterif
+ config_get masterif "$cfg" master
+ network_get_device master "$masterif"
+ [ -z "$master" ] && master="."
+
+ # Detect slave interfaces
+ local slaves=""
+ local slaveifs
+ config_get slaveifs "$cfg" network
+ for slaveif in $slaveifs; do
+ local slave
+ network_get_device slave "$slaveif"
+ # Compatibility with old config format
+ if [ "$mode" = "relay" -a "$master" = "." ]; then
+ [ -z "$slave" ] && return 0
+ master="$slave"
+ else
+ [ -n "$slave" ] && append slaves "$slave"
+ fi
+ done
+
+ # Bail if no slaves are active
+ [ -z "$slaves" ] && return 0
+
+ # Configure services
+ local rd dhcpv6 ndp
+ config_get rd "$cfg" rd
+ config_get dhcpv6 "$cfg" dhcpv6
+ config_get ndp "$cfg" ndp
+
+ # Test for fallback mode
+ local fallback fallback_relay
+ config_get fallback_relay "$cfg" fallback_relay
+
+ if [ -n "$fallback_relay" -a "$master" != "." ]; then
+ local prefix
+ network_get_prefix6 prefix "$masterif"
+ [ -z "$prefix" ] && fallback=1
+ fi
+
+ if [ -n "$fallback" ]; then
+ for service in $fallback_relay; do
+ eval "$service=relay"
+ done
+ fi
+
+ # Configure feature options
+ local always_rewrite_dns rewrite_dns_addr
+ config_get_bool always_rewrite_dns "$cfg" always_rewrite_dns 0
+ config_get rewrite_dns_addr "$cfg" rewrite_dns_addr
+ [ "$always_rewrite_dns" -eq 1 -o -n "$rewrite_dns_addr" ] && append args "-n$rewrite_dns_addr"
+
+ local always_assume_default
+ config_get_bool always_assume_default "$cfg" always_assume_default 0
+ [ "$always_assume_default" -eq 1 ] && append args "-u"
+
+ local compat_ula
+ config_get_bool compat_ula "$cfg" compat_ula 0
+ [ "$compat_ula" -eq 1 ] && append args "-c"
+
+ [ "$ndp" = "relay" ] && append args "-N -s -l"
+ [ "$rd" = "relay" ] && append args "-Rrelay"
+ [ "$rd" = "server" ] && append args "-Rserver"
+ [ "$dhcpv6" = "relay" ] && append args "-Drelay"
+ [ "$dhcpv6" = "server" ] && append args "-Dserver"
+ [ "$ndp" != "relay" -a "$rd" != "relay" -a "$dhcpv6" != "relay" ] && master="."
+
+ service_start /usr/sbin/6relayd $args $master $slaves
+}
+
+restart_affected_6relayd() {
+ local cfg="$1"
+ local net="$2"
+ local mode="$3"
+
+ local master slaves
+ config_get master "$cfg" master
+ config_get slaves "$cfg" network
+
+ for iface in $master $slaves; do
+ if [ "$iface" = "$net" ]; then
+ SERVICE_PID_FILE="/var/run/6relayd-$cfg.pid"
+ service_stop /usr/sbin/6relayd
+ rm -f "$SERVICE_PID_FILE"
+ start_6relayd "$cfg" "$mode"
+ fi
+ done
+}
+
+restart_affected() {
+ . /lib/functions/service.sh
+ . /lib/functions/network.sh
+ local net="$1"
+ config_load 6relayd
+ config_foreach restart_affected_6relayd server "$net"
+ config_foreach restart_affected_6relayd relay "$net" "relay"
+}
+
+stop() {
+ . /lib/functions/service.sh
+ for pid in /var/run/6relayd-*.pid; do
+ SERVICE_PID_FILE="$pid"
+ service_stop /usr/sbin/6relayd
+ rm -f "$SERVICE_PID_FILE"
+ done
+}
+
+start() {
+ . /lib/functions/service.sh
+ . /lib/functions/network.sh
+ config_load 6relayd
+ config_foreach start_6relayd server
+ config_foreach start_6relayd relay relay
+}
diff --git a/package/network/ipv6/6to4/.svn/entries b/package/network/ipv6/6to4/.svn/entries
new file mode 100644
index 0000000..bfbf976
--- /dev/null
+++ b/package/network/ipv6/6to4/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/ipv6/6to4
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-15T13:08:10.006426Z
+35172
+cyrus
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+files
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+8a7e3024fccac4d28a34f17581091319
+2013-01-15T13:08:10.006426Z
+35172
+cyrus
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+867
+
diff --git a/package/network/ipv6/6to4/.svn/text-base/Makefile.svn-base b/package/network/ipv6/6to4/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..72906fb
--- /dev/null
+++ b/package/network/ipv6/6to4/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,42 @@
+#
+# Copyright (C) 2010-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=6to4
+PKG_VERSION:=12
+PKG_RELEASE:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/6to4
+ SECTION:=ipv6
+ CATEGORY:=IPv6
+ DEPENDS:=+kmod-ipv6 +kmod-sit
+ TITLE:=IPv6-to-IPv4 configuration support
+ MAINTAINER:=Jo-Philipp Wich <xm@subsignal.org>
+ PKGARCH:=all
+endef
+
+define Package/6to4/description
+Provides support for 6to4 tunnels in /etc/config/network.
+Refer to http://wiki.openwrt.org/doc/uci/network for
+configuration details.
+endef
+
+define Build/Compile
+endef
+
+define Build/Configure
+endef
+
+define Package/6to4/install
+ $(INSTALL_DIR) $(1)/lib/netifd/proto
+ $(INSTALL_BIN) ./files/6to4.sh $(1)/lib/netifd/proto/6to4.sh
+endef
+
+$(eval $(call BuildPackage,6to4))
diff --git a/package/network/ipv6/6to4/Makefile b/package/network/ipv6/6to4/Makefile
new file mode 100644
index 0000000..72906fb
--- /dev/null
+++ b/package/network/ipv6/6to4/Makefile
@@ -0,0 +1,42 @@
+#
+# Copyright (C) 2010-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=6to4
+PKG_VERSION:=12
+PKG_RELEASE:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/6to4
+ SECTION:=ipv6
+ CATEGORY:=IPv6
+ DEPENDS:=+kmod-ipv6 +kmod-sit
+ TITLE:=IPv6-to-IPv4 configuration support
+ MAINTAINER:=Jo-Philipp Wich <xm@subsignal.org>
+ PKGARCH:=all
+endef
+
+define Package/6to4/description
+Provides support for 6to4 tunnels in /etc/config/network.
+Refer to http://wiki.openwrt.org/doc/uci/network for
+configuration details.
+endef
+
+define Build/Compile
+endef
+
+define Build/Configure
+endef
+
+define Package/6to4/install
+ $(INSTALL_DIR) $(1)/lib/netifd/proto
+ $(INSTALL_BIN) ./files/6to4.sh $(1)/lib/netifd/proto/6to4.sh
+endef
+
+$(eval $(call BuildPackage,6to4))
diff --git a/package/network/ipv6/6to4/files/.svn/entries b/package/network/ipv6/6to4/files/.svn/entries
new file mode 100644
index 0000000..025ec07
--- /dev/null
+++ b/package/network/ipv6/6to4/files/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/ipv6/6to4/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-15T13:08:10.006426Z
+35172
+cyrus
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+6to4.sh
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+4a28c5c1df028f23d81f88924d2b5cda
+2013-01-15T13:08:10.006426Z
+35172
+cyrus
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1853
+
diff --git a/package/network/ipv6/6to4/files/.svn/prop-base/6to4.sh.svn-base b/package/network/ipv6/6to4/files/.svn/prop-base/6to4.sh.svn-base
new file mode 100644
index 0000000..869ac71
--- /dev/null
+++ b/package/network/ipv6/6to4/files/.svn/prop-base/6to4.sh.svn-base
@@ -0,0 +1,5 @@
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/network/ipv6/6to4/files/.svn/text-base/6to4.sh.svn-base b/package/network/ipv6/6to4/files/.svn/text-base/6to4.sh.svn-base
new file mode 100644
index 0000000..6f2fbd8
--- /dev/null
+++ b/package/network/ipv6/6to4/files/.svn/text-base/6to4.sh.svn-base
@@ -0,0 +1,94 @@
+#!/bin/sh
+# 6to4.sh - IPv6-in-IPv4 tunnel backend
+# Copyright (c) 2010-2012 OpenWrt.org
+
+[ -n "$INCLUDE_ONLY" ] || {
+ . /lib/functions.sh
+ . /lib/functions/network.sh
+ . ../netifd-proto.sh
+ init_proto "$@"
+}
+
+find_6to4_prefix() {
+ local ip4="$1"
+ local oIFS="$IFS"; IFS="."; set -- $ip4; IFS="$oIFS"
+
+ printf "2002:%02x%02x:%02x%02x\n" $1 $2 $3 $4
+}
+
+test_6to4_rfc1918()
+{
+ local oIFS="$IFS"; IFS="."; set -- $1; IFS="$oIFS"
+ [ $1 -eq 10 ] && return 0
+ [ $1 -eq 192 ] && [ $2 -eq 168 ] && return 0
+ [ $1 -eq 172 ] && [ $2 -ge 16 ] && [ $2 -le 31 ] && return 0
+
+ # RFC 6598
+ [ $1 -eq 100 ] && [ $2 -ge 64 ] && [ $2 -le 127 ] && return 0
+
+ return 1
+}
+
+proto_6to4_setup() {
+ local cfg="$1"
+ local iface="$2"
+ local link="6to4-$cfg"
+
+ local mtu ttl ipaddr
+ json_get_vars mtu ttl ipaddr
+
+ ( proto_add_host_dependency "$cfg" 0.0.0.0 )
+
+ local wanif
+ if ! network_find_wan wanif; then
+ proto_notify_error "$cfg" "NO_WAN_LINK"
+ return
+ fi
+
+ [ -z "$ipaddr" ] && {
+ if ! network_get_ipaddr ipaddr "$wanif"; then
+ proto_notify_error "$cfg" "NO_WAN_ADDRESS"
+ return
+ fi
+ }
+
+ test_6to4_rfc1918 "$ipaddr" && {
+ proto_notify_error "$cfg" "INVALID_LOCAL_ADDRESS"
+ return
+ }
+
+ # find our local prefix
+ local prefix6=$(find_6to4_prefix "$ipaddr")
+ local local6="$prefix6::1"
+
+ proto_init_update "$link" 1
+ proto_add_ipv6_address "$local6" 16
+ proto_add_ipv6_prefix "$prefix6::/48"
+ proto_add_ipv6_route "::" 0 "::192.88.99.1"
+
+ proto_add_tunnel
+ json_add_string mode sit
+ json_add_int mtu "${mtu:-1280}"
+ json_add_int ttl "${ttl:-64}"
+ json_add_string local "$ipaddr"
+ proto_close_tunnel
+
+ proto_send_update "$cfg"
+}
+
+proto_6to4_teardown() {
+ local cfg="$1"
+}
+
+proto_6to4_init_config() {
+ no_device=1
+ available=1
+
+ proto_config_add_string "ipaddr"
+ proto_config_add_int "mtu"
+ proto_config_add_int "ttl"
+}
+
+[ -n "$INCLUDE_ONLY" ] || {
+ add_protocol 6to4
+}
diff --git a/package/network/ipv6/6to4/files/6to4.sh b/package/network/ipv6/6to4/files/6to4.sh
new file mode 100755
index 0000000..6f2fbd8
--- /dev/null
+++ b/package/network/ipv6/6to4/files/6to4.sh
@@ -0,0 +1,94 @@
+#!/bin/sh
+# 6to4.sh - IPv6-in-IPv4 tunnel backend
+# Copyright (c) 2010-2012 OpenWrt.org
+
+[ -n "$INCLUDE_ONLY" ] || {
+ . /lib/functions.sh
+ . /lib/functions/network.sh
+ . ../netifd-proto.sh
+ init_proto "$@"
+}
+
+find_6to4_prefix() {
+ local ip4="$1"
+ local oIFS="$IFS"; IFS="."; set -- $ip4; IFS="$oIFS"
+
+ printf "2002:%02x%02x:%02x%02x\n" $1 $2 $3 $4
+}
+
+test_6to4_rfc1918()
+{
+ local oIFS="$IFS"; IFS="."; set -- $1; IFS="$oIFS"
+ [ $1 -eq 10 ] && return 0
+ [ $1 -eq 192 ] && [ $2 -eq 168 ] && return 0
+ [ $1 -eq 172 ] && [ $2 -ge 16 ] && [ $2 -le 31 ] && return 0
+
+ # RFC 6598
+ [ $1 -eq 100 ] && [ $2 -ge 64 ] && [ $2 -le 127 ] && return 0
+
+ return 1
+}
+
+proto_6to4_setup() {
+ local cfg="$1"
+ local iface="$2"
+ local link="6to4-$cfg"
+
+ local mtu ttl ipaddr
+ json_get_vars mtu ttl ipaddr
+
+ ( proto_add_host_dependency "$cfg" 0.0.0.0 )
+
+ local wanif
+ if ! network_find_wan wanif; then
+ proto_notify_error "$cfg" "NO_WAN_LINK"
+ return
+ fi
+
+ [ -z "$ipaddr" ] && {
+ if ! network_get_ipaddr ipaddr "$wanif"; then
+ proto_notify_error "$cfg" "NO_WAN_ADDRESS"
+ return
+ fi
+ }
+
+ test_6to4_rfc1918 "$ipaddr" && {
+ proto_notify_error "$cfg" "INVALID_LOCAL_ADDRESS"
+ return
+ }
+
+ # find our local prefix
+ local prefix6=$(find_6to4_prefix "$ipaddr")
+ local local6="$prefix6::1"
+
+ proto_init_update "$link" 1
+ proto_add_ipv6_address "$local6" 16
+ proto_add_ipv6_prefix "$prefix6::/48"
+ proto_add_ipv6_route "::" 0 "::192.88.99.1"
+
+ proto_add_tunnel
+ json_add_string mode sit
+ json_add_int mtu "${mtu:-1280}"
+ json_add_int ttl "${ttl:-64}"
+ json_add_string local "$ipaddr"
+ proto_close_tunnel
+
+ proto_send_update "$cfg"
+}
+
+proto_6to4_teardown() {
+ local cfg="$1"
+}
+
+proto_6to4_init_config() {
+ no_device=1
+ available=1
+
+ proto_config_add_string "ipaddr"
+ proto_config_add_int "mtu"
+ proto_config_add_int "ttl"
+}
+
+[ -n "$INCLUDE_ONLY" ] || {
+ add_protocol 6to4
+}
diff --git a/package/network/ipv6/ipv6-support/.svn/entries b/package/network/ipv6/ipv6-support/.svn/entries
new file mode 100644
index 0000000..bf569ea
--- /dev/null
+++ b/package/network/ipv6/ipv6-support/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/ipv6/ipv6-support
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-23T08:15:09.884089Z
+35302
+cyrus
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+files
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+9718fb88ca6a0a8205862cb406c6eac4
+2013-01-23T08:15:09.884089Z
+35302
+cyrus
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+976
+
diff --git a/package/network/ipv6/ipv6-support/.svn/text-base/Makefile.svn-base b/package/network/ipv6/ipv6-support/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..5ad52f8
--- /dev/null
+++ b/package/network/ipv6/ipv6-support/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,41 @@
+#
+# Copyright (C) 2010-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=ipv6-support
+PKG_VERSION:=2013-01-23
+PKG_RELEASE:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/ipv6-support
+ SECTION:=ipv6
+ CATEGORY:=IPv6
+ DEPENDS:=+kmod-ipv6 +6relayd +odhcp6c +ip6tables
+ TITLE:=Basic IPv6-support for Customer Edge Routers
+ MAINTAINER:=Steven Barth <steven@midlink.org>
+ PKGARCH:=all
+endef
+
+define Package/ipv6-support/description
+This package provides basic IPv6 support including Router Discovery,
+DHCPv6 (client & server), prefix delegation and distribution.
+endef
+
+define Build/Compile
+endef
+
+define Build/Configure
+endef
+
+define Package/ipv6-support/install
+ $(INSTALL_DIR) $(1)/etc/uci-defaults
+ $(INSTALL_BIN) ./files/network-enable-ipv6.defaults $(1)/etc/uci-defaults/10_network-enable-ipv6
+endef
+
+$(eval $(call BuildPackage,ipv6-support))
diff --git a/package/network/ipv6/ipv6-support/Makefile b/package/network/ipv6/ipv6-support/Makefile
new file mode 100644
index 0000000..5ad52f8
--- /dev/null
+++ b/package/network/ipv6/ipv6-support/Makefile
@@ -0,0 +1,41 @@
+#
+# Copyright (C) 2010-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=ipv6-support
+PKG_VERSION:=2013-01-23
+PKG_RELEASE:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/ipv6-support
+ SECTION:=ipv6
+ CATEGORY:=IPv6
+ DEPENDS:=+kmod-ipv6 +6relayd +odhcp6c +ip6tables
+ TITLE:=Basic IPv6-support for Customer Edge Routers
+ MAINTAINER:=Steven Barth <steven@midlink.org>
+ PKGARCH:=all
+endef
+
+define Package/ipv6-support/description
+This package provides basic IPv6 support including Router Discovery,
+DHCPv6 (client & server), prefix delegation and distribution.
+endef
+
+define Build/Compile
+endef
+
+define Build/Configure
+endef
+
+define Package/ipv6-support/install
+ $(INSTALL_DIR) $(1)/etc/uci-defaults
+ $(INSTALL_BIN) ./files/network-enable-ipv6.defaults $(1)/etc/uci-defaults/10_network-enable-ipv6
+endef
+
+$(eval $(call BuildPackage,ipv6-support))
diff --git a/package/network/ipv6/ipv6-support/files/.svn/entries b/package/network/ipv6/ipv6-support/files/.svn/entries
new file mode 100644
index 0000000..b83bd5e
--- /dev/null
+++ b/package/network/ipv6/ipv6-support/files/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/ipv6/ipv6-support/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-23T08:15:09.884089Z
+35302
+cyrus
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+network-enable-ipv6.defaults
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+4c1917685a599be500f2b52c82c50c89
+2013-01-23T08:15:09.884089Z
+35302
+cyrus
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+340
+
diff --git a/package/network/ipv6/ipv6-support/files/.svn/text-base/network-enable-ipv6.defaults.svn-base b/package/network/ipv6/ipv6-support/files/.svn/text-base/network-enable-ipv6.defaults.svn-base
new file mode 100644
index 0000000..3da74b1
--- /dev/null
+++ b/package/network/ipv6/ipv6-support/files/.svn/text-base/network-enable-ipv6.defaults.svn-base
@@ -0,0 +1,14 @@
+#!/bin/sh
+# Don't override existing settings
+uci get network.globals && exit 0
+
+uci -q batch <<-EOF >/dev/null
+ set network.globals=globals
+ set network.globals.ula_prefix=auto
+ set network.wan6=interface
+ set network.wan6.proto=dhcpv6
+ set network.wan6.ifname=@wan
+ set network.lan.ip6assign=64
+ set network.wan.ipv6=1
+ commit network
+EOF
diff --git a/package/network/ipv6/ipv6-support/files/network-enable-ipv6.defaults b/package/network/ipv6/ipv6-support/files/network-enable-ipv6.defaults
new file mode 100644
index 0000000..3da74b1
--- /dev/null
+++ b/package/network/ipv6/ipv6-support/files/network-enable-ipv6.defaults
@@ -0,0 +1,14 @@
+#!/bin/sh
+# Don't override existing settings
+uci get network.globals && exit 0
+
+uci -q batch <<-EOF >/dev/null
+ set network.globals=globals
+ set network.globals.ula_prefix=auto
+ set network.wan6=interface
+ set network.wan6.proto=dhcpv6
+ set network.wan6.ifname=@wan
+ set network.lan.ip6assign=64
+ set network.wan.ipv6=1
+ commit network
+EOF
diff --git a/package/network/ipv6/odhcp6c/.svn/entries b/package/network/ipv6/odhcp6c/.svn/entries
new file mode 100644
index 0000000..a3e7ce9
--- /dev/null
+++ b/package/network/ipv6/odhcp6c/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/ipv6/odhcp6c
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-08T07:04:38.512412Z
+35902
+cyrus
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+files
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+b68e611d0879b02a6c3bdccacc091507
+2013-03-08T07:04:38.512412Z
+35902
+cyrus
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1051
+
diff --git a/package/network/ipv6/odhcp6c/.svn/text-base/Makefile.svn-base b/package/network/ipv6/odhcp6c/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..f1509f7
--- /dev/null
+++ b/package/network/ipv6/odhcp6c/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,39 @@
+#
+# Copyright (C) 2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=odhcp6c
+PKG_VERSION:=2013-03-08
+PKG_RELEASE=$(PKG_SOURCE_VERSION)
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE_URL:=git://github.com/sbyx/odhcp6c.git
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_VERSION:=e8b07f018cbdf8f2a08f93af46904e7ffb9eb123
+PKG_MAINTAINER:=Steven Barth <steven@midlink.org>
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/cmake.mk
+
+define Package/odhcp6c
+ SECTION:=ipv6
+ CATEGORY:=IPv6
+ TITLE:=Embedded DHCPv6-client for OpenWrt
+ DEPENDS:=+kmod-ipv6
+endef
+
+define Package/odhcp6c/install
+ $(INSTALL_DIR) $(1)/usr/sbin/
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/odhcp6c $(1)/usr/sbin/
+ $(INSTALL_DIR) $(1)/lib/netifd/proto
+ $(INSTALL_BIN) ./files/dhcpv6.sh $(1)/lib/netifd/proto/dhcpv6.sh
+ $(INSTALL_BIN) ./files/dhcpv6.script $(1)/lib/netifd/
+endef
+
+$(eval $(call BuildPackage,odhcp6c))
diff --git a/package/network/ipv6/odhcp6c/Makefile b/package/network/ipv6/odhcp6c/Makefile
new file mode 100644
index 0000000..f1509f7
--- /dev/null
+++ b/package/network/ipv6/odhcp6c/Makefile
@@ -0,0 +1,39 @@
+#
+# Copyright (C) 2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=odhcp6c
+PKG_VERSION:=2013-03-08
+PKG_RELEASE=$(PKG_SOURCE_VERSION)
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE_URL:=git://github.com/sbyx/odhcp6c.git
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_VERSION:=e8b07f018cbdf8f2a08f93af46904e7ffb9eb123
+PKG_MAINTAINER:=Steven Barth <steven@midlink.org>
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/cmake.mk
+
+define Package/odhcp6c
+ SECTION:=ipv6
+ CATEGORY:=IPv6
+ TITLE:=Embedded DHCPv6-client for OpenWrt
+ DEPENDS:=+kmod-ipv6
+endef
+
+define Package/odhcp6c/install
+ $(INSTALL_DIR) $(1)/usr/sbin/
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/odhcp6c $(1)/usr/sbin/
+ $(INSTALL_DIR) $(1)/lib/netifd/proto
+ $(INSTALL_BIN) ./files/dhcpv6.sh $(1)/lib/netifd/proto/dhcpv6.sh
+ $(INSTALL_BIN) ./files/dhcpv6.script $(1)/lib/netifd/
+endef
+
+$(eval $(call BuildPackage,odhcp6c))
diff --git a/package/network/ipv6/odhcp6c/files/.svn/entries b/package/network/ipv6/odhcp6c/files/.svn/entries
new file mode 100644
index 0000000..9f8b8b4
--- /dev/null
+++ b/package/network/ipv6/odhcp6c/files/.svn/entries
@@ -0,0 +1,96 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/ipv6/odhcp6c/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-08T07:04:38.512412Z
+35902
+cyrus
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+dhcpv6.sh
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+d1079bcf1d652c45a8ed50ec66c645b0
+2013-03-08T07:04:38.512412Z
+35902
+cyrus
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1273
+
+dhcpv6.script
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+da23dd6bd1f991b29d86582d16d817b5
+2013-02-12T08:23:54.096583Z
+35570
+cyrus
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1913
+
diff --git a/package/network/ipv6/odhcp6c/files/.svn/prop-base/dhcpv6.script.svn-base b/package/network/ipv6/odhcp6c/files/.svn/prop-base/dhcpv6.script.svn-base
new file mode 100644
index 0000000..869ac71
--- /dev/null
+++ b/package/network/ipv6/odhcp6c/files/.svn/prop-base/dhcpv6.script.svn-base
@@ -0,0 +1,5 @@
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/network/ipv6/odhcp6c/files/.svn/prop-base/dhcpv6.sh.svn-base b/package/network/ipv6/odhcp6c/files/.svn/prop-base/dhcpv6.sh.svn-base
new file mode 100644
index 0000000..869ac71
--- /dev/null
+++ b/package/network/ipv6/odhcp6c/files/.svn/prop-base/dhcpv6.sh.svn-base
@@ -0,0 +1,5 @@
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/network/ipv6/odhcp6c/files/.svn/text-base/dhcpv6.script.svn-base b/package/network/ipv6/odhcp6c/files/.svn/text-base/dhcpv6.script.svn-base
new file mode 100644
index 0000000..56f8c39
--- /dev/null
+++ b/package/network/ipv6/odhcp6c/files/.svn/text-base/dhcpv6.script.svn-base
@@ -0,0 +1,92 @@
+#!/bin/sh
+[ -z "$2" ] && echo "Error: should be run by odhcpc6c" && exit 1
+. /lib/functions.sh
+. /lib/netifd/netifd-proto.sh
+
+setup_interface () {
+ local device="$1"
+ proto_init_update "*" 1
+
+ # Merge RA-DNS
+ for radns in $RA_DNS; do
+ local duplicate=0
+ for dns in $RDNSS; do
+ [ "$radns" = "$dns" ] && duplicate=1
+ done
+ [ "$duplicate" = 0 ] && RDNSS="$RDNSS $radns"
+ done
+
+ for dns in $RDNSS; do
+ proto_add_dns_server "$dns"
+ done
+
+ for domain in $DOMAINS; do
+ proto_add_dns_search "$domain"
+ done
+
+ for prefix in $PREFIXES; do
+ proto_add_ipv6_prefix "$prefix"
+ done
+
+ [ -n "$USERPREFIX" ] && proto_add_ipv6_prefix "$USERPREFIX"
+
+ # Merge addresses
+ for entry in $RA_ADDRESSES; do
+ local duplicate=0
+ local addr="${entry%%/*}"
+ for dentry in $ADDRESSES; do
+ local daddr="${dentry%%/*}"
+ [ "$addr" = "$daddr" ] && duplicate=1
+ done
+ [ "$duplicate" = "0" ] && ADDRESSES="$ADDRESSES $entry"
+ done
+
+ for entry in $ADDRESSES; do
+ local addr="${entry%%/*}"
+ entry="${entry#*/}"
+ local mask="${entry%%,*}"
+ entry="${entry#*,}"
+ local preferred="${entry%%,*}"
+ entry="${entry#*,}"
+ local valid="${entry%%,*}"
+
+ proto_add_ipv6_address "$addr" "$mask" "$preferred" "$valid" 1
+ done
+
+ for entry in $RA_ROUTES; do
+ local addr="${entry%%/*}"
+ entry="${entry#*/}"
+ local mask="${entry%%,*}"
+ entry="${entry#*,}"
+ local gw="${entry%%,*}"
+ entry="${entry#*,}"
+ local valid="${entry%%,*}"
+ entry="${entry#*,}"
+ local metric="${entry%%,*}"
+
+ proto_add_ipv6_route "$addr" "$mask" "$gw" "$metric" "$valid"
+ done
+
+ proto_send_update "$INTERFACE"
+
+ # TODO: $SNTP_IP $SIP_IP $SNTP_FQDN $SIP_DOMAIN
+}
+
+teardown_interface() {
+ proto_init_update "*" 0
+ proto_send_update "$INTERFACE"
+}
+
+case "$2" in
+ informed|bound|updated|rebound|ra-updated)
+ setup_interface "$1"
+ ;;
+ started|stopped|unbound)
+ teardown_interface "$1"
+ ;;
+esac
+
+# user rules
+[ -f /etc/odhcp6c.user ] && . /etc/odhcp6c.user
+
+exit 0
diff --git a/package/network/ipv6/odhcp6c/files/.svn/text-base/dhcpv6.sh.svn-base b/package/network/ipv6/odhcp6c/files/.svn/text-base/dhcpv6.sh.svn-base
new file mode 100644
index 0000000..6cf7521
--- /dev/null
+++ b/package/network/ipv6/odhcp6c/files/.svn/text-base/dhcpv6.sh.svn-base
@@ -0,0 +1,56 @@
+#!/bin/sh
+
+. /lib/functions.sh
+. ../netifd-proto.sh
+init_proto "$@"
+
+proto_dhcpv6_init_config() {
+ proto_config_add_string "reqaddress"
+ proto_config_add_string "reqprefix"
+ proto_config_add_string "clientid"
+ proto_config_add_string "reqopts"
+ proto_config_add_string "noslaaconly"
+ proto_config_add_string "norelease"
+ proto_config_add_string "ip6prefix"
+}
+
+proto_dhcpv6_setup() {
+ local config="$1"
+ local iface="$2"
+
+ local reqaddress reqprefix clientid reqopts noslaaconly norelease ip6prefix
+ json_get_vars reqaddress reqprefix clientid reqopts noslaaconly norelease ip6prefix
+
+
+ # Configure
+ local opts=""
+ [ -n "$reqaddress" ] && append opts "-N$reqaddress"
+
+ [ -z "$reqprefix" -o "$reqprefix" = "auto" ] && reqprefix=0
+ [ "$reqprefix" != "no" ] && append opts "-P$reqprefix"
+
+ [ -n "$clientid" ] && append opts "-c$clientid"
+
+ [ "$noslaaconly" = "1" ] && append opts "-S"
+
+ [ "$norelease" = "1" ] && append opts "-k"
+
+ for opt in $reqopts; do
+ append opts "-r$opt"
+ done
+
+ [ -n "$ip6prefix" ] && proto_export "USERPREFIX=$ip6prefix"
+
+ proto_export "INTERFACE=$config"
+ proto_run_command "$config" odhcp6c \
+ -s /lib/netifd/dhcpv6.script \
+ $opts $iface
+}
+
+proto_dhcpv6_teardown() {
+ local interface="$1"
+ proto_kill_command "$interface"
+}
+
+add_protocol dhcpv6
+
diff --git a/package/network/ipv6/odhcp6c/files/dhcpv6.script b/package/network/ipv6/odhcp6c/files/dhcpv6.script
new file mode 100755
index 0000000..56f8c39
--- /dev/null
+++ b/package/network/ipv6/odhcp6c/files/dhcpv6.script
@@ -0,0 +1,92 @@
+#!/bin/sh
+[ -z "$2" ] && echo "Error: should be run by odhcpc6c" && exit 1
+. /lib/functions.sh
+. /lib/netifd/netifd-proto.sh
+
+setup_interface () {
+ local device="$1"
+ proto_init_update "*" 1
+
+ # Merge RA-DNS
+ for radns in $RA_DNS; do
+ local duplicate=0
+ for dns in $RDNSS; do
+ [ "$radns" = "$dns" ] && duplicate=1
+ done
+ [ "$duplicate" = 0 ] && RDNSS="$RDNSS $radns"
+ done
+
+ for dns in $RDNSS; do
+ proto_add_dns_server "$dns"
+ done
+
+ for domain in $DOMAINS; do
+ proto_add_dns_search "$domain"
+ done
+
+ for prefix in $PREFIXES; do
+ proto_add_ipv6_prefix "$prefix"
+ done
+
+ [ -n "$USERPREFIX" ] && proto_add_ipv6_prefix "$USERPREFIX"
+
+ # Merge addresses
+ for entry in $RA_ADDRESSES; do
+ local duplicate=0
+ local addr="${entry%%/*}"
+ for dentry in $ADDRESSES; do
+ local daddr="${dentry%%/*}"
+ [ "$addr" = "$daddr" ] && duplicate=1
+ done
+ [ "$duplicate" = "0" ] && ADDRESSES="$ADDRESSES $entry"
+ done
+
+ for entry in $ADDRESSES; do
+ local addr="${entry%%/*}"
+ entry="${entry#*/}"
+ local mask="${entry%%,*}"
+ entry="${entry#*,}"
+ local preferred="${entry%%,*}"
+ entry="${entry#*,}"
+ local valid="${entry%%,*}"
+
+ proto_add_ipv6_address "$addr" "$mask" "$preferred" "$valid" 1
+ done
+
+ for entry in $RA_ROUTES; do
+ local addr="${entry%%/*}"
+ entry="${entry#*/}"
+ local mask="${entry%%,*}"
+ entry="${entry#*,}"
+ local gw="${entry%%,*}"
+ entry="${entry#*,}"
+ local valid="${entry%%,*}"
+ entry="${entry#*,}"
+ local metric="${entry%%,*}"
+
+ proto_add_ipv6_route "$addr" "$mask" "$gw" "$metric" "$valid"
+ done
+
+ proto_send_update "$INTERFACE"
+
+ # TODO: $SNTP_IP $SIP_IP $SNTP_FQDN $SIP_DOMAIN
+}
+
+teardown_interface() {
+ proto_init_update "*" 0
+ proto_send_update "$INTERFACE"
+}
+
+case "$2" in
+ informed|bound|updated|rebound|ra-updated)
+ setup_interface "$1"
+ ;;
+ started|stopped|unbound)
+ teardown_interface "$1"
+ ;;
+esac
+
+# user rules
+[ -f /etc/odhcp6c.user ] && . /etc/odhcp6c.user
+
+exit 0
diff --git a/package/network/ipv6/odhcp6c/files/dhcpv6.sh b/package/network/ipv6/odhcp6c/files/dhcpv6.sh
new file mode 100755
index 0000000..6cf7521
--- /dev/null
+++ b/package/network/ipv6/odhcp6c/files/dhcpv6.sh
@@ -0,0 +1,56 @@
+#!/bin/sh
+
+. /lib/functions.sh
+. ../netifd-proto.sh
+init_proto "$@"
+
+proto_dhcpv6_init_config() {
+ proto_config_add_string "reqaddress"
+ proto_config_add_string "reqprefix"
+ proto_config_add_string "clientid"
+ proto_config_add_string "reqopts"
+ proto_config_add_string "noslaaconly"
+ proto_config_add_string "norelease"
+ proto_config_add_string "ip6prefix"
+}
+
+proto_dhcpv6_setup() {
+ local config="$1"
+ local iface="$2"
+
+ local reqaddress reqprefix clientid reqopts noslaaconly norelease ip6prefix
+ json_get_vars reqaddress reqprefix clientid reqopts noslaaconly norelease ip6prefix
+
+
+ # Configure
+ local opts=""
+ [ -n "$reqaddress" ] && append opts "-N$reqaddress"
+
+ [ -z "$reqprefix" -o "$reqprefix" = "auto" ] && reqprefix=0
+ [ "$reqprefix" != "no" ] && append opts "-P$reqprefix"
+
+ [ -n "$clientid" ] && append opts "-c$clientid"
+
+ [ "$noslaaconly" = "1" ] && append opts "-S"
+
+ [ "$norelease" = "1" ] && append opts "-k"
+
+ for opt in $reqopts; do
+ append opts "-r$opt"
+ done
+
+ [ -n "$ip6prefix" ] && proto_export "USERPREFIX=$ip6prefix"
+
+ proto_export "INTERFACE=$config"
+ proto_run_command "$config" odhcp6c \
+ -s /lib/netifd/dhcpv6.script \
+ $opts $iface
+}
+
+proto_dhcpv6_teardown() {
+ local interface="$1"
+ proto_kill_command "$interface"
+}
+
+add_protocol dhcpv6
+
diff --git a/package/network/ipv6/thc-ipv6/.svn/entries b/package/network/ipv6/thc-ipv6/.svn/entries
new file mode 100644
index 0000000..07a4929
--- /dev/null
+++ b/package/network/ipv6/thc-ipv6/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/ipv6/thc-ipv6
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-11T21:57:56.970004Z
+33728
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+311e62358a8e54684e10d17581ca399e
+2012-10-11T21:57:56.970004Z
+33728
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1955
+
diff --git a/package/network/ipv6/thc-ipv6/.svn/text-base/Makefile.svn-base b/package/network/ipv6/thc-ipv6/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..c5bbe61
--- /dev/null
+++ b/package/network/ipv6/thc-ipv6/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,59 @@
+#
+# Copyright (C) 2009-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=thc-ipv6
+PKG_VERSION:=2.0
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://freeworld.thc.org/releases/
+PKG_MD5SUM:=5c9be9ad38ac15c368bb5140d031c051
+
+PKG_MAINTAINER:=Jo-Philipp Wich <jow@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+
+THC_APPLETS := \
+ address6 alive6 covert_send6 covert_send6d denial6 detect-new-ip6 \
+ detect_sniffer6 dnsdict6 dnsrevenum6 dos-new-ip6 \
+ dump_router6 exploit6 fake_advertise6 fake_dhcps6 fake_dns6d \
+ fake_dnsupdate6 fake_mipv6 fake_mld26 fake_mld6 fake_mldrouter6 \
+ fake_router26 fake_router6 fake_solicitate6 flood_advertise6 \
+ flood_dhcpc6 flood_mld26 flood_mld6 flood_mldrouter6 flood_router26 \
+ flood_router6 flood_solicitate6 fragmentation6 fuzz_ip6 \
+ implementation6 implementation6d inverse_lookup6 kill_router6 \
+ ndpexhaust6 node_query6 parasite6 passive_discovery6 randicmp6 \
+ redir6 rsmurf6 sendpees6 sendpeesmp6 smurf6 thcping6 toobig6 trace6
+
+THC_DEPENDS_dnsdict6 := +libpthread
+THC_DEPENDS_thcping6 := +librt
+
+define BuildTool
+ define Package/thc-ipv6-$(subst _,-,$(1))
+ TITLE:=THC-IPv6 $(1) utility
+ SECTION:=ipv6
+ CATEGORY:=IPv6
+ DEPENDS:=+libpcap $(THC_DEPENDS_$(1))
+ URL:=http://freeworld.thc.org/
+ SUBMENU:=THC-IPv6 attack and analyzing toolkit
+ endef
+
+ define Package/thc-ipv6-$(subst _,-,$(1))/description
+ This package contains the $(1) utility of the THC-IPv6 toolkit.
+ endef
+
+ define Package/thc-ipv6-$(subst _,-,$(1))/install
+ $(INSTALL_DIR) $$(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/$(1) $$(1)/usr/sbin/$(1)
+ endef
+
+ $$(eval $$(call BuildPackage,thc-ipv6-$(subst _,-,$(1))))
+endef
+
+$(foreach a,$(THC_APPLETS),$(eval $(call BuildTool,$(a))))
diff --git a/package/network/ipv6/thc-ipv6/Makefile b/package/network/ipv6/thc-ipv6/Makefile
new file mode 100644
index 0000000..c5bbe61
--- /dev/null
+++ b/package/network/ipv6/thc-ipv6/Makefile
@@ -0,0 +1,59 @@
+#
+# Copyright (C) 2009-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=thc-ipv6
+PKG_VERSION:=2.0
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://freeworld.thc.org/releases/
+PKG_MD5SUM:=5c9be9ad38ac15c368bb5140d031c051
+
+PKG_MAINTAINER:=Jo-Philipp Wich <jow@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+
+THC_APPLETS := \
+ address6 alive6 covert_send6 covert_send6d denial6 detect-new-ip6 \
+ detect_sniffer6 dnsdict6 dnsrevenum6 dos-new-ip6 \
+ dump_router6 exploit6 fake_advertise6 fake_dhcps6 fake_dns6d \
+ fake_dnsupdate6 fake_mipv6 fake_mld26 fake_mld6 fake_mldrouter6 \
+ fake_router26 fake_router6 fake_solicitate6 flood_advertise6 \
+ flood_dhcpc6 flood_mld26 flood_mld6 flood_mldrouter6 flood_router26 \
+ flood_router6 flood_solicitate6 fragmentation6 fuzz_ip6 \
+ implementation6 implementation6d inverse_lookup6 kill_router6 \
+ ndpexhaust6 node_query6 parasite6 passive_discovery6 randicmp6 \
+ redir6 rsmurf6 sendpees6 sendpeesmp6 smurf6 thcping6 toobig6 trace6
+
+THC_DEPENDS_dnsdict6 := +libpthread
+THC_DEPENDS_thcping6 := +librt
+
+define BuildTool
+ define Package/thc-ipv6-$(subst _,-,$(1))
+ TITLE:=THC-IPv6 $(1) utility
+ SECTION:=ipv6
+ CATEGORY:=IPv6
+ DEPENDS:=+libpcap $(THC_DEPENDS_$(1))
+ URL:=http://freeworld.thc.org/
+ SUBMENU:=THC-IPv6 attack and analyzing toolkit
+ endef
+
+ define Package/thc-ipv6-$(subst _,-,$(1))/description
+ This package contains the $(1) utility of the THC-IPv6 toolkit.
+ endef
+
+ define Package/thc-ipv6-$(subst _,-,$(1))/install
+ $(INSTALL_DIR) $$(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/$(1) $$(1)/usr/sbin/$(1)
+ endef
+
+ $$(eval $$(call BuildPackage,thc-ipv6-$(subst _,-,$(1))))
+endef
+
+$(foreach a,$(THC_APPLETS),$(eval $(call BuildTool,$(a))))
diff --git a/package/network/ipv6/thc-ipv6/patches/.svn/entries b/package/network/ipv6/thc-ipv6/patches/.svn/entries
new file mode 100644
index 0000000..28e4e12
--- /dev/null
+++ b/package/network/ipv6/thc-ipv6/patches/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/ipv6/thc-ipv6/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-11T21:57:56.970004Z
+33728
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+100-no-ssl.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+5c5c337b521c2bbb9ccdac35c5519e0e
+2012-10-11T21:57:56.970004Z
+33728
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+780
+
diff --git a/package/network/ipv6/thc-ipv6/patches/.svn/text-base/100-no-ssl.patch.svn-base b/package/network/ipv6/thc-ipv6/patches/.svn/text-base/100-no-ssl.patch.svn-base
new file mode 100644
index 0000000..5f87bcd
--- /dev/null
+++ b/package/network/ipv6/thc-ipv6/patches/.svn/text-base/100-no-ssl.patch.svn-base
@@ -0,0 +1,11 @@
+--- a/Makefile
++++ b/Makefile
+@@ -1,7 +1,7 @@
+ CC=gcc
+ #CFLAGS?=-Wall -ggdb
+ CFLAGS?=-O2
+-LDFLAGS+=-lpcap -lssl -lcrypto
++LDFLAGS+=-lpcap
+ PROGRAMS=parasite6 dos-new-ip6 detect-new-ip6 fake_router6 fake_advertise6 fake_solicitate6 fake_mld6 fake_mld26 fake_mldrouter6 flood_mldrouter6 fake_mipv6 redir6 smurf6 alive6 toobig6 rsmurf6 implementation6 implementation6d sendpees6 sendpeesmp6 randicmp6 fuzz_ip6 flood_mld6 flood_mld26 flood_router6 flood_router26 flood_advertise6 flood_solicitate6 trace6 exploit6 denial6 fake_dhcps6 flood_dhcpc6 fake_dns6d fragmentation6 kill_router6 fake_dnsupdate6 ndpexhaust6 detect_sniffer6 dump_router6 fake_router26 passive_discovery6 dnsrevenum6 inverse_lookup6 node_query6 address6 thcping6 covert_send6 covert_send6d
+ LIBS=thc-ipv6-lib.o
+
diff --git a/package/network/ipv6/thc-ipv6/patches/100-no-ssl.patch b/package/network/ipv6/thc-ipv6/patches/100-no-ssl.patch
new file mode 100644
index 0000000..5f87bcd
--- /dev/null
+++ b/package/network/ipv6/thc-ipv6/patches/100-no-ssl.patch
@@ -0,0 +1,11 @@
+--- a/Makefile
++++ b/Makefile
+@@ -1,7 +1,7 @@
+ CC=gcc
+ #CFLAGS?=-Wall -ggdb
+ CFLAGS?=-O2
+-LDFLAGS+=-lpcap -lssl -lcrypto
++LDFLAGS+=-lpcap
+ PROGRAMS=parasite6 dos-new-ip6 detect-new-ip6 fake_router6 fake_advertise6 fake_solicitate6 fake_mld6 fake_mld26 fake_mldrouter6 flood_mldrouter6 fake_mipv6 redir6 smurf6 alive6 toobig6 rsmurf6 implementation6 implementation6d sendpees6 sendpeesmp6 randicmp6 fuzz_ip6 flood_mld6 flood_mld26 flood_router6 flood_router26 flood_advertise6 flood_solicitate6 trace6 exploit6 denial6 fake_dhcps6 flood_dhcpc6 fake_dns6d fragmentation6 kill_router6 fake_dnsupdate6 ndpexhaust6 detect_sniffer6 dump_router6 fake_router26 passive_discovery6 dnsrevenum6 inverse_lookup6 node_query6 address6 thcping6 covert_send6 covert_send6d
+ LIBS=thc-ipv6-lib.o
+
diff --git a/package/network/services/.svn/entries b/package/network/services/.svn/entries
new file mode 100644
index 0000000..c3cd7e4
--- /dev/null
+++ b/package/network/services/.svn/entries
@@ -0,0 +1,61 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/services
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-15T13:43:55.120823Z
+36034
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+lldpd
+dir
+
+ppp
+dir
+
+relayd
+dir
+
+hostapd
+dir
+
+openvpn
+dir
+
+dnsmasq
+dir
+
+openvpn-easy-rsa
+dir
+
+uhttpd
+dir
+
+ead
+dir
+
+samba36
+dir
+
+dropbear
+dir
+
diff --git a/package/network/services/dnsmasq/.svn/entries b/package/network/services/dnsmasq/.svn/entries
new file mode 100644
index 0000000..e5c3003
--- /dev/null
+++ b/package/network/services/dnsmasq/.svn/entries
@@ -0,0 +1,68 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/services/dnsmasq
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-02T15:14:19.332457Z
+34971
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+files
+dir
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+ae81cc17ba15bd190a87443b68667b0b
+2013-01-02T15:14:19.332457Z
+34971
+jow
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2142
+
diff --git a/package/network/services/dnsmasq/.svn/prop-base/Makefile.svn-base b/package/network/services/dnsmasq/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..8e522ae
--- /dev/null
+++ b/package/network/services/dnsmasq/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:copyright
+V 30
+Copyright (C) 2006 OpenWrt.org
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/services/dnsmasq/.svn/text-base/Makefile.svn-base b/package/network/services/dnsmasq/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..26670e5
--- /dev/null
+++ b/package/network/services/dnsmasq/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,91 @@
+#
+# Copyright (C) 2006-2013 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=dnsmasq
+PKG_VERSION:=2.62
+PKG_RELEASE:=3
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://thekelleys.org.uk/dnsmasq
+PKG_MD5SUM:=f47e5cb8f5bac6343f24b2dbe317ab40
+
+PKG_LICENSE:=GPLv2
+PKG_LICENSE_FILES:=COPYING
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
+
+PKG_INSTALL:=1
+PKG_BUILD_PARALLEL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/dnsmasq/Default
+ SECTION:=net
+ CATEGORY:=Base system
+ TITLE:=A lightweight DNS and DHCP server
+ URL:=http://www.thekelleys.org.uk/dnsmasq/
+endef
+
+define Package/dnsmasq
+$(call Package/dnsmasq/Default)
+ VARIANT:=nodhcpv6
+endef
+
+define Package/dnsmasq-dhcpv6
+$(call Package/dnsmasq/Default)
+ TITLE += (with DHCPv6 support)
+ DEPENDS:=@IPV6 +kmod-ipv6
+ VARIANT:=dhcpv6
+endef
+
+define Package/dnsmasq/description
+ It is intended to provide coupled DNS and DHCP service to a LAN.
+endef
+
+define Package/dnsmasq-dhcpv6/description
+$(call Package/dnsmasq/description)
+
+This is a variant with DHCPv6 support
+endef
+
+define Package/dnsmasq/conffiles
+/etc/config/dhcp
+/etc/dnsmasq.conf
+endef
+
+Package/dnsmasq-dhcpv6/conffiles = $(Package/dnsmasq/conffiles)
+
+TARGET_CFLAGS += \
+ -ffunction-sections -fdata-sections \
+ $(if $(CONFIG_IPV6),,-DNO_IPV6)
+
+ifeq ($(BUILD_VARIANT),nodhcpv6)
+ TARGET_CFLAGS += -DNO_DHCP6
+endif
+
+MAKE_FLAGS := \
+ $(TARGET_CONFIGURE_OPTS) \
+ CFLAGS="$(TARGET_CFLAGS)" \
+ LDFLAGS="-Wl,--gc-sections" \
+ PREFIX="/usr"
+
+define Package/dnsmasq/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(CP) $(PKG_INSTALL_DIR)/usr/sbin/dnsmasq $(1)/usr/sbin/
+ $(INSTALL_DIR) $(1)/etc/config
+ $(INSTALL_DATA) ./files/dhcp.conf $(1)/etc/config/dhcp
+ $(INSTALL_DATA) ./files/dnsmasq.conf $(1)/etc/dnsmasq.conf
+ $(INSTALL_DIR) $(1)/etc/init.d
+ $(INSTALL_BIN) ./files/dnsmasq.init $(1)/etc/init.d/dnsmasq
+endef
+
+Package/dnsmasq-dhcpv6/install = $(Package/dnsmasq/install)
+
+$(eval $(call BuildPackage,dnsmasq))
+$(eval $(call BuildPackage,dnsmasq-dhcpv6))
diff --git a/package/network/services/dnsmasq/Makefile b/package/network/services/dnsmasq/Makefile
new file mode 100644
index 0000000..26670e5
--- /dev/null
+++ b/package/network/services/dnsmasq/Makefile
@@ -0,0 +1,91 @@
+#
+# Copyright (C) 2006-2013 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=dnsmasq
+PKG_VERSION:=2.62
+PKG_RELEASE:=3
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://thekelleys.org.uk/dnsmasq
+PKG_MD5SUM:=f47e5cb8f5bac6343f24b2dbe317ab40
+
+PKG_LICENSE:=GPLv2
+PKG_LICENSE_FILES:=COPYING
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
+
+PKG_INSTALL:=1
+PKG_BUILD_PARALLEL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/dnsmasq/Default
+ SECTION:=net
+ CATEGORY:=Base system
+ TITLE:=A lightweight DNS and DHCP server
+ URL:=http://www.thekelleys.org.uk/dnsmasq/
+endef
+
+define Package/dnsmasq
+$(call Package/dnsmasq/Default)
+ VARIANT:=nodhcpv6
+endef
+
+define Package/dnsmasq-dhcpv6
+$(call Package/dnsmasq/Default)
+ TITLE += (with DHCPv6 support)
+ DEPENDS:=@IPV6 +kmod-ipv6
+ VARIANT:=dhcpv6
+endef
+
+define Package/dnsmasq/description
+ It is intended to provide coupled DNS and DHCP service to a LAN.
+endef
+
+define Package/dnsmasq-dhcpv6/description
+$(call Package/dnsmasq/description)
+
+This is a variant with DHCPv6 support
+endef
+
+define Package/dnsmasq/conffiles
+/etc/config/dhcp
+/etc/dnsmasq.conf
+endef
+
+Package/dnsmasq-dhcpv6/conffiles = $(Package/dnsmasq/conffiles)
+
+TARGET_CFLAGS += \
+ -ffunction-sections -fdata-sections \
+ $(if $(CONFIG_IPV6),,-DNO_IPV6)
+
+ifeq ($(BUILD_VARIANT),nodhcpv6)
+ TARGET_CFLAGS += -DNO_DHCP6
+endif
+
+MAKE_FLAGS := \
+ $(TARGET_CONFIGURE_OPTS) \
+ CFLAGS="$(TARGET_CFLAGS)" \
+ LDFLAGS="-Wl,--gc-sections" \
+ PREFIX="/usr"
+
+define Package/dnsmasq/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(CP) $(PKG_INSTALL_DIR)/usr/sbin/dnsmasq $(1)/usr/sbin/
+ $(INSTALL_DIR) $(1)/etc/config
+ $(INSTALL_DATA) ./files/dhcp.conf $(1)/etc/config/dhcp
+ $(INSTALL_DATA) ./files/dnsmasq.conf $(1)/etc/dnsmasq.conf
+ $(INSTALL_DIR) $(1)/etc/init.d
+ $(INSTALL_BIN) ./files/dnsmasq.init $(1)/etc/init.d/dnsmasq
+endef
+
+Package/dnsmasq-dhcpv6/install = $(Package/dnsmasq/install)
+
+$(eval $(call BuildPackage,dnsmasq))
+$(eval $(call BuildPackage,dnsmasq-dhcpv6))
diff --git a/package/network/services/dnsmasq/files/.svn/entries b/package/network/services/dnsmasq/files/.svn/entries
new file mode 100644
index 0000000..44ab802
--- /dev/null
+++ b/package/network/services/dnsmasq/files/.svn/entries
@@ -0,0 +1,130 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/services/dnsmasq/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-02T15:14:19.332457Z
+34971
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+dhcp.conf
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+326e2116bd9bc3ecc5be4f75cd1e7647
+2010-10-06T13:10:15.331143Z
+23270
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+885
+
+dnsmasq.init
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+e9135fe0f0ae1a3d71de6d4d9f4f0561
+2013-01-02T15:14:19.332457Z
+34971
+jow
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+12517
+
+dnsmasq.conf
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+7cf378e58d3fe5db31f4116a16c15c61
+2009-09-21T13:25:11.362945Z
+17663
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1368
+
diff --git a/package/network/services/dnsmasq/files/.svn/prop-base/dnsmasq.init.svn-base b/package/network/services/dnsmasq/files/.svn/prop-base/dnsmasq.init.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/network/services/dnsmasq/files/.svn/prop-base/dnsmasq.init.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/services/dnsmasq/files/.svn/text-base/dhcp.conf.svn-base b/package/network/services/dnsmasq/files/.svn/text-base/dhcp.conf.svn-base
new file mode 100644
index 0000000..660b06a
--- /dev/null
+++ b/package/network/services/dnsmasq/files/.svn/text-base/dhcp.conf.svn-base
@@ -0,0 +1,31 @@
+config dnsmasq
+ option domainneeded 1
+ option boguspriv 1
+ option filterwin2k 0 # enable for dial on demand
+ option localise_queries 1
+ option rebind_protection 1 # disable if upstream must serve RFC1918 addresses
+ option rebind_localhost 1 # enable for RBL checking and similar services
+ #list rebind_domain example.lan # whitelist RFC1918 responses for domains
+ option local '/lan/'
+ option domain 'lan'
+ option expandhosts 1
+ option nonegcache 0
+ option authoritative 1
+ option readethers 1
+ option leasefile '/tmp/dhcp.leases'
+ option resolvfile '/tmp/resolv.conf.auto'
+ #list server '/mycompany.local/1.2.3.4'
+ #option nonwildcard 1
+ #list interface br-lan
+ #list notinterface lo
+ #list bogusnxdomain '64.94.110.11'
+
+config dhcp lan
+ option interface lan
+ option start 100
+ option limit 150
+ option leasetime 12h
+
+config dhcp wan
+ option interface wan
+ option ignore 1
diff --git a/package/network/services/dnsmasq/files/.svn/text-base/dnsmasq.conf.svn-base b/package/network/services/dnsmasq/files/.svn/text-base/dnsmasq.conf.svn-base
new file mode 100644
index 0000000..bf5816b
--- /dev/null
+++ b/package/network/services/dnsmasq/files/.svn/text-base/dnsmasq.conf.svn-base
@@ -0,0 +1,37 @@
+# Change the following lines if you want dnsmasq to serve SRV
+# records.
+# You may add multiple srv-host lines.
+# The fields are <name>,<target>,<port>,<priority>,<weight>
+
+# A SRV record sending LDAP for the example.com domain to
+# ldapserver.example.com port 289
+#srv-host=_ldap._tcp.example.com,ldapserver.example.com,389
+
+# Two SRV records for LDAP, each with different priorities
+#srv-host=_ldap._tcp.example.com,ldapserver.example.com,389,1
+#srv-host=_ldap._tcp.example.com,ldapserver.example.com,389,2
+
+# A SRV record indicating that there is no LDAP server for the domain
+# example.com
+#srv-host=_ldap._tcp.example.com
+
+# The following line shows how to make dnsmasq serve an arbitrary PTR
+# record. This is useful for DNS-SD.
+# The fields are <name>,<target>
+#ptr-record=_http._tcp.dns-sd-services,"New Employee Page._http._tcp.dns-sd-services"
+
+# Change the following lines to enable dnsmasq to serve TXT records.
+# These are used for things like SPF and zeroconf.
+# The fields are <name>,<text>,<text>...
+
+#Example SPF.
+#txt-record=example.com,"v=spf1 a -all"
+
+#Example zeroconf
+#txt-record=_http._tcp.example.com,name=value,paper=A4
+
+# Provide an alias for a "local" DNS name. Note that this _only_ works
+# for targets which are names from DHCP or /etc/hosts. Give host
+# "bert" another name, bertrand
+# The fields are <cname>,<target>
+#cname=bertand,bert
diff --git a/package/network/services/dnsmasq/files/.svn/text-base/dnsmasq.init.svn-base b/package/network/services/dnsmasq/files/.svn/text-base/dnsmasq.init.svn-base
new file mode 100644
index 0000000..f2e111b
--- /dev/null
+++ b/package/network/services/dnsmasq/files/.svn/text-base/dnsmasq.init.svn-base
@@ -0,0 +1,534 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2007-2012 OpenWrt.org
+
+START=60
+
+SERVICE_USE_PID=1
+
+DNS_SERVERS=""
+DOMAIN=""
+
+ADD_LOCAL_DOMAIN=1
+ADD_LOCAL_HOSTNAME=1
+
+CONFIGFILE="/var/etc/dnsmasq.conf"
+
+xappend() {
+ local value="$1"
+
+ echo "${value#--}" >> $CONFIGFILE
+}
+
+dhcp_calc() {
+ local ip="$1"
+ local res=0
+
+ while [ -n "$ip" ]; do
+ part="${ip%%.*}"
+ res="$(($res * 256))"
+ res="$(($res + $part))"
+ [ "${ip%.*}" != "$ip" ] && ip="${ip#*.}" || ip=
+ done
+ echo "$res"
+}
+
+append_bool() {
+ local section="$1"
+ local option="$2"
+ local value="$3"
+ local _loctmp
+ config_get_bool _loctmp "$section" "$option" 0
+ [ $_loctmp -gt 0 ] && xappend "$value"
+}
+
+append_parm() {
+ local section="$1"
+ local option="$2"
+ local switch="$3"
+ local _loctmp
+ config_get _loctmp "$section" "$option"
+ [ -z "$_loctmp" ] && return 0
+ xappend "$switch=$_loctmp"
+}
+
+append_server() {
+ xappend "--server=$1"
+}
+
+append_address() {
+ xappend "--address=$1"
+}
+
+append_interface() {
+ local ifname=$(uci_get_state network "$1" ifname "$1")
+ xappend "--interface=$ifname"
+}
+
+append_notinterface() {
+ local ifname=$(uci_get_state network "$1" ifname "$1")
+ xappend "--except-interface=$ifname"
+}
+
+append_addnhosts() {
+ xappend "--addn-hosts=$1"
+}
+
+append_bogusnxdomain() {
+ xappend "--bogus-nxdomain=$1"
+}
+
+dnsmasq() {
+ local cfg="$1"
+ append_bool "$cfg" authoritative "--dhcp-authoritative"
+ append_bool "$cfg" nodaemon "--no-daemon"
+ append_bool "$cfg" domainneeded "--domain-needed"
+ append_bool "$cfg" filterwin2k "--filterwin2k"
+ append_bool "$cfg" nohosts "--no-hosts"
+ append_bool "$cfg" nonegcache "--no-negcache"
+ append_bool "$cfg" strictorder "--strict-order"
+ append_bool "$cfg" logqueries "--log-queries"
+ append_bool "$cfg" noresolv "--no-resolv"
+ append_bool "$cfg" localise_queries "--localise-queries"
+ append_bool "$cfg" readethers "--read-ethers"
+ append_bool "$cfg" dbus "--enable-dbus"
+ append_bool "$cfg" boguspriv "--bogus-priv"
+ append_bool "$cfg" expandhosts "--expand-hosts"
+ append_bool "$cfg" enable_tftp "--enable-tftp"
+ append_bool "$cfg" nonwildcard "--bind-interfaces"
+ append_bool "$cfg" fqdn "--dhcp-fqdn"
+
+ append_parm "$cfg" dhcpscript "--dhcp-script"
+ append_parm "$cfg" cachesize "--cache-size"
+ append_parm "$cfg" dnsforwardmax "--dns-forward-max"
+ append_parm "$cfg" port "--port"
+ append_parm "$cfg" ednspacket_max "--edns-packet-max"
+ append_parm "$cfg" dhcpleasemax "--dhcp-lease-max"
+ append_parm "$cfg" "queryport" "--query-port"
+ append_parm "$cfg" "domain" "--domain"
+ append_parm "$cfg" "local" "--server"
+ config_list_foreach "$cfg" "server" append_server
+ config_list_foreach "$cfg" "address" append_address
+ config_list_foreach "$cfg" "interface" append_interface
+ config_list_foreach "$cfg" "notinterface" append_notinterface
+ config_list_foreach "$cfg" "addnhosts" append_addnhosts
+ config_list_foreach "$cfg" "bogusnxdomain" append_bogusnxdomain
+ append_parm "$cfg" "leasefile" "--dhcp-leasefile"
+ append_parm "$cfg" "resolvfile" "--resolv-file"
+ append_parm "$cfg" "tftp_root" "--tftp-root"
+ append_parm "$cfg" "dhcp_boot" "--dhcp-boot"
+ append_parm "$cfg" "local_ttl" "--local-ttl"
+
+ config_get DOMAIN "$cfg" domain
+
+ config_get_bool ADD_LOCAL_DOMAIN "$cfg" add_local_domain 1
+ config_get_bool ADD_LOCAL_HOSTNAME "$cfg" add_local_hostname 1
+
+ config_get_bool readethers "$cfg" readethers
+ [ "$readethers" = "1" -a \! -e "/etc/ethers" ] && touch /etc/ethers
+
+ config_get leasefile $cfg leasefile
+ [ -n "$leasefile" -a \! -e "$leasefile" ] && touch "$leasefile"
+ config_get_bool cachelocal "$cfg" cachelocal 1
+
+ config_get hostsfile "$cfg" dhcphostsfile
+ [ -e "$hostsfile" ] && xappend "--dhcp-hostsfile=$hostsfile"
+
+ local rebind
+ config_get_bool rebind "$cfg" rebind_protection 1
+ [ $rebind -gt 0 ] && {
+ logger -t dnsmasq \
+ "DNS rebinding protection is active," \
+ "will discard upstream RFC1918 responses!"
+ xappend "--stop-dns-rebind"
+
+ local rebind_localhost
+ config_get_bool rebind_localhost "$cfg" rebind_localhost 0
+ [ $rebind_localhost -gt 0 ] && {
+ logger -t dnsmasq "Allowing 127.0.0.0/8 responses"
+ xappend "--rebind-localhost-ok"
+ }
+
+ append_rebind_domain() {
+ logger -t dnsmasq "Allowing RFC1918 responses for domain $1"
+ xappend "--rebind-domain-ok=$1"
+ }
+
+ config_list_foreach "$cfg" rebind_domain append_rebind_domain
+ }
+
+ dhcp_option_add "$cfg" "" 0
+
+ echo >> $CONFIGFILE
+}
+
+dhcp_subscrid_add() {
+ local cfg="$1"
+
+ config_get networkid "$cfg" networkid
+ [ -n "$networkid" ] || return 0
+
+ config_get subscriberid "$cfg" subscriberid
+ [ -n "$subscriberid" ] || return 0
+
+ xappend "--dhcp-subscrid=$networkid,$subscriberid"
+
+ config_get_bool force "$cfg" force 0
+
+ dhcp_option_add "$cfg" "$networkid" "$force"
+}
+
+dhcp_remoteid_add() {
+ local cfg="$1"
+
+ config_get networkid "$cfg" networkid
+ [ -n "$networkid" ] || return 0
+
+ config_get remoteid "$cfg" remoteid
+ [ -n "$remoteid" ] || return 0
+
+ xappend "--dhcp-remoteid=$networkid,$remoteid"
+
+ config_get_bool force "$cfg" force 0
+
+ dhcp_option_add "$cfg" "$networkid" "$force"
+}
+
+dhcp_circuitid_add() {
+ local cfg="$1"
+
+ config_get networkid "$cfg" networkid
+ [ -n "$networkid" ] || return 0
+
+ config_get circuitid "$cfg" circuitid
+ [ -n "$circuitid" ] || return 0
+
+ xappend "--dhcp-circuitid=$networkid,$circuitid"
+
+ config_get_bool force "$cfg" force 0
+
+ dhcp_option_add "$cfg" "$networkid" "$force"
+}
+
+dhcp_userclass_add() {
+ local cfg="$1"
+
+ config_get networkid "$cfg" networkid
+ [ -n "$networkid" ] || return 0
+
+ config_get userclass "$cfg" userclass
+ [ -n "$userclass" ] || return 0
+
+ xappend "--dhcp-userclass=$networkid,$userclass"
+
+ config_get_bool force "$cfg" force 0
+
+ dhcp_option_add "$cfg" "$networkid" "$force"
+}
+
+dhcp_vendorclass_add() {
+ local cfg="$1"
+
+ config_get networkid "$cfg" networkid
+ [ -n "$networkid" ] || return 0
+
+ config_get vendorclass "$cfg" vendorclass
+ [ -n "$vendorclass" ] || return 0
+
+ xappend "--dhcp-vendorclass=$networkid,$vendorclass"
+
+ config_get_bool force "$cfg" force 0
+
+ dhcp_option_add "$cfg" "$networkid" "$force"
+}
+
+dhcp_host_add() {
+ local cfg="$1"
+
+ config_get_bool force "$cfg" force 0
+
+ config_get networkid "$cfg" networkid
+ [ -n "$networkid" ] && dhcp_option_add "$cfg" "$networkid" "$force"
+
+ config_get name "$cfg" name
+ config_get ip "$cfg" ip
+ [ -n "$ip" -o -n "$name" ] || return 0
+
+ config_get mac "$cfg" mac
+ [ -z "$mac" ] && {
+ [ -n "$name" ] || return 0
+ mac="$name"
+ name=""
+ }
+
+ macs=""
+ for m in $mac; do append macs "$m" ","; done
+
+ config_get tag "$cfg" tag
+
+ xappend "--dhcp-host=$macs${networkid:+,net:$networkid}${tag:+,set:$tag}${ip:+,$ip}${name:+,$name}"
+}
+
+dhcp_tag_add() {
+ local cfg="$1"
+
+ tag="$cfg"
+
+ [ -n "$tag" ] || return 0
+
+ config_get_bool force "$cfg" force 0
+ [ "$force" = "0" ] && force=
+
+ config_get option "$cfg" dhcp_option
+ for o in $option; do
+ xappend "--dhcp-option${force:+-force}=tag:$tag,$o"
+ done
+}
+
+dhcp_mac_add() {
+ local cfg="$1"
+
+ config_get networkid "$cfg" networkid
+ [ -n "$networkid" ] || return 0
+
+ config_get mac "$cfg" mac
+ [ -n "$mac" ] || return 0
+
+ xappend "--dhcp-mac=$networkid,$mac"
+
+ dhcp_option_add "$cfg" "$networkid"
+}
+
+dhcp_boot_add() {
+ local cfg="$1"
+
+ config_get networkid "$cfg" networkid
+
+ config_get filename "$cfg" filename
+ [ -n "$filename" ] || return 0
+
+ config_get servername "$cfg" servername
+ [ -n "$servername" ] || return 0
+
+ config_get serveraddress "$cfg" serveraddress
+ [ -n "$serveraddress" ] || return 0
+
+ xappend "--dhcp-boot=${networkid:+net:$networkid,}$filename,$servername,$serveraddress"
+
+ config_get_bool force "$cfg" force 0
+
+ dhcp_option_add "$cfg" "$networkid" "$force"
+}
+
+
+dhcp_add() {
+ local cfg="$1"
+ config_get net "$cfg" interface
+ [ -n "$net" ] || return 0
+
+ config_get networkid "$cfg" networkid
+ [ -n "$networkid" ] || networkid="$net"
+
+ config_get ifname "$net" ifname
+ [ -n "$ifname" ] || return 0
+
+ config_get dnsserver "$net" dns
+ [ "$cachelocal" = "0" -a -n "$dnsserver" ] && {
+ DNS_SERVERS="$DNS_SERVERS $dnsserver"
+ }
+
+ append_bool "$cfg" ignore "--no-dhcp-interface=$ifname" && return 0
+
+ config_get proto "$net" proto
+ [ static = "$proto" ] || return 0
+
+ config_get ipaddr "$net" ipaddr
+ config_get netmask "$cfg" netmask
+ [ -n "$netmask" ] || config_get netmask "$net" netmask
+
+ #check for an already active dhcp server on the interface, unless 'force' is set
+ config_get_bool force "$cfg" force 0
+ [ $force -gt 0 ] || {
+ udhcpc -n -q -s /bin/true -t 1 -i $ifname >&- && {
+ logger -t dnsmasq \
+ "found already running DHCP-server on interface '$ifname'" \
+ "refusing to start, use 'option force 1' to override"
+ return 0
+ }
+ }
+
+ config_get start "$cfg" start
+ config_get limit "$cfg" limit
+ config_get leasetime "$cfg" leasetime
+ config_get options "$cfg" options
+ config_get_bool dynamicdhcp "$cfg" dynamicdhcp 1
+
+ leasetime="${leasetime:-12h}"
+ start="$(dhcp_calc "${start:-100}")"
+ limit="${limit:-150}"
+ [ "$limit" -gt 0 ] && limit=$((limit-1))
+ eval "$(ipcalc.sh $ipaddr $netmask $start $limit)"
+ if [ "$dynamicdhcp" = "0" ]; then END="static"; fi
+ xappend "--dhcp-range=$networkid,$START,$END,$NETMASK,$leasetime${options:+ $options}"
+
+ dhcp_option_add "$cfg" "$networkid"
+}
+
+dhcp_option_add() {
+ local cfg="$1"
+ local networkid="$2"
+ local force="$3"
+
+ [ "$force" = "0" ] && force=
+
+ config_get dhcp_option "$cfg" dhcp_option
+ for o in $dhcp_option; do
+ xappend "--dhcp-option${force:+-force}=${networkid:+$networkid,}$o"
+ done
+
+}
+
+dhcp_domain_add() {
+ local cfg="$1"
+ local ip name names
+
+ config_get names "$cfg" name "$2"
+ [ -n "$names" ] || return 0
+
+ config_get ip "$cfg" ip "$3"
+ [ -n "$ip" ] || return 0
+
+ local oIFS="$IFS"; IFS="."; set -- $ip; IFS="$oIFS"
+ local raddr="${4:+$4.$3.$2.$1.in-addr.arpa}"
+
+ for name in $names; do
+ local fqdn="$name"
+
+ [ "${fqdn%.*}" == "$fqdn" ] && \
+ fqdn="$fqdn${DOMAIN:+.$DOMAIN}"
+
+ xappend "--address=/$fqdn/$ip"
+
+ [ -n "$raddr" ] && {
+ xappend "--ptr-record=$raddr,$fqdn"
+ raddr=""
+ }
+ done
+}
+
+dhcp_srv_add() {
+ local cfg="$1"
+
+ config_get srv "$cfg" srv
+ [ -n "$srv" ] || return 0
+
+ config_get target "$cfg" target
+ [ -n "$target" ] || return 0
+
+ config_get port "$cfg" port
+ [ -n "$port" ] || return 0
+
+ config_get class "$cfg" class
+ config_get weight "$cfg" weight
+
+ local service="$srv,$target,$port${class:+,$class${weight:+,$weight}}"
+
+ xappend "--srv-host=$service"
+}
+
+dhcp_mx_add() {
+ local cfg="$1"
+ local domain relay pref
+
+ config_get domain "$cfg" domain
+ [ -n "$domain" ] || return 0
+
+ config_get relay "$cfg" relay
+ [ -n "$relay" ] || return 0
+
+ config_get pref "$cfg" pref 0
+
+ local service="$domain,$relay,$pref"
+
+ xappend "--mx-host=$service"
+}
+
+dhcp_cname_add() {
+ local cfg="$1"
+ local cname target
+
+ config_get cname "$cfg" cname
+ [ -n "$cname" ] || return 0
+
+ config_get target "$cfg" target
+ [ -n "$target" ] || return 0
+
+ xappend "--cname=${cname},${target}"
+}
+
+start() {
+ include /lib/network
+ scan_interfaces
+
+ local lanaddr
+ config_get lanaddr "lan" ipaddr
+
+ config_load dhcp
+
+ # before we can call xappend
+ mkdir -p $(dirname $CONFIGFILE)
+
+ echo "# auto-generated config file from /etc/config/dhcp" > $CONFIGFILE
+
+ # if we did this last, we could override auto-generated config
+ [ -f /etc/dnsmasq.conf ] && {
+ xappend "--conf-file=/etc/dnsmasq.conf"
+ }
+
+ args=""
+ config_foreach dnsmasq dnsmasq
+ config_foreach dhcp_host_add host
+ echo >> $CONFIGFILE
+ config_foreach dhcp_boot_add boot
+ config_foreach dhcp_mac_add mac
+ config_foreach dhcp_tag_add tag
+ config_foreach dhcp_vendorclass_add vendorclass
+ config_foreach dhcp_userclass_add userclass
+ config_foreach dhcp_circuitid_add circuitid
+ config_foreach dhcp_remoteid_add remoteid
+ config_foreach dhcp_subscrid_add subscrid
+ config_foreach dhcp_domain_add domain
+ echo >> $CONFIGFILE
+ config_foreach dhcp_srv_add srvhost
+ config_foreach dhcp_mx_add mxhost
+ echo >> $CONFIGFILE
+ config_foreach dhcp_add dhcp
+ echo >> $CONFIGFILE
+ config_foreach dhcp_cname_add cname
+ echo >> $CONFIGFILE
+
+ # add own hostname
+ [ $ADD_LOCAL_HOSTNAME -eq 1 ] && [ -n "$lanaddr" ] && {
+ local hostname="$(uci_get system.@system[0].hostname)"
+ dhcp_domain_add "" "${hostname:-OpenWrt}" "$lanaddr"
+ }
+
+ service_start /usr/sbin/dnsmasq -C $CONFIGFILE && {
+ rm -f /tmp/resolv.conf
+ [ $ADD_LOCAL_DOMAIN -eq 1 ] && [ -n "$DOMAIN" ] && {
+ echo "search $DOMAIN" >> /tmp/resolv.conf
+ }
+ DNS_SERVERS="$DNS_SERVERS 127.0.0.1"
+ for DNS_SERVER in $DNS_SERVERS ; do
+ echo "nameserver $DNS_SERVER" >> /tmp/resolv.conf
+ done
+ }
+}
+
+stop() {
+ service_stop /usr/sbin/dnsmasq && {
+ [ -f /tmp/resolv.conf ] && {
+ rm -f /tmp/resolv.conf
+ ln -s /tmp/resolv.conf.auto /tmp/resolv.conf
+ }
+ }
+}
diff --git a/package/network/services/dnsmasq/files/dhcp.conf b/package/network/services/dnsmasq/files/dhcp.conf
new file mode 100644
index 0000000..660b06a
--- /dev/null
+++ b/package/network/services/dnsmasq/files/dhcp.conf
@@ -0,0 +1,31 @@
+config dnsmasq
+ option domainneeded 1
+ option boguspriv 1
+ option filterwin2k 0 # enable for dial on demand
+ option localise_queries 1
+ option rebind_protection 1 # disable if upstream must serve RFC1918 addresses
+ option rebind_localhost 1 # enable for RBL checking and similar services
+ #list rebind_domain example.lan # whitelist RFC1918 responses for domains
+ option local '/lan/'
+ option domain 'lan'
+ option expandhosts 1
+ option nonegcache 0
+ option authoritative 1
+ option readethers 1
+ option leasefile '/tmp/dhcp.leases'
+ option resolvfile '/tmp/resolv.conf.auto'
+ #list server '/mycompany.local/1.2.3.4'
+ #option nonwildcard 1
+ #list interface br-lan
+ #list notinterface lo
+ #list bogusnxdomain '64.94.110.11'
+
+config dhcp lan
+ option interface lan
+ option start 100
+ option limit 150
+ option leasetime 12h
+
+config dhcp wan
+ option interface wan
+ option ignore 1
diff --git a/package/network/services/dnsmasq/files/dnsmasq.conf b/package/network/services/dnsmasq/files/dnsmasq.conf
new file mode 100644
index 0000000..bf5816b
--- /dev/null
+++ b/package/network/services/dnsmasq/files/dnsmasq.conf
@@ -0,0 +1,37 @@
+# Change the following lines if you want dnsmasq to serve SRV
+# records.
+# You may add multiple srv-host lines.
+# The fields are <name>,<target>,<port>,<priority>,<weight>
+
+# A SRV record sending LDAP for the example.com domain to
+# ldapserver.example.com port 289
+#srv-host=_ldap._tcp.example.com,ldapserver.example.com,389
+
+# Two SRV records for LDAP, each with different priorities
+#srv-host=_ldap._tcp.example.com,ldapserver.example.com,389,1
+#srv-host=_ldap._tcp.example.com,ldapserver.example.com,389,2
+
+# A SRV record indicating that there is no LDAP server for the domain
+# example.com
+#srv-host=_ldap._tcp.example.com
+
+# The following line shows how to make dnsmasq serve an arbitrary PTR
+# record. This is useful for DNS-SD.
+# The fields are <name>,<target>
+#ptr-record=_http._tcp.dns-sd-services,"New Employee Page._http._tcp.dns-sd-services"
+
+# Change the following lines to enable dnsmasq to serve TXT records.
+# These are used for things like SPF and zeroconf.
+# The fields are <name>,<text>,<text>...
+
+#Example SPF.
+#txt-record=example.com,"v=spf1 a -all"
+
+#Example zeroconf
+#txt-record=_http._tcp.example.com,name=value,paper=A4
+
+# Provide an alias for a "local" DNS name. Note that this _only_ works
+# for targets which are names from DHCP or /etc/hosts. Give host
+# "bert" another name, bertrand
+# The fields are <cname>,<target>
+#cname=bertand,bert
diff --git a/package/network/services/dnsmasq/files/dnsmasq.init b/package/network/services/dnsmasq/files/dnsmasq.init
new file mode 100644
index 0000000..f2e111b
--- /dev/null
+++ b/package/network/services/dnsmasq/files/dnsmasq.init
@@ -0,0 +1,534 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2007-2012 OpenWrt.org
+
+START=60
+
+SERVICE_USE_PID=1
+
+DNS_SERVERS=""
+DOMAIN=""
+
+ADD_LOCAL_DOMAIN=1
+ADD_LOCAL_HOSTNAME=1
+
+CONFIGFILE="/var/etc/dnsmasq.conf"
+
+xappend() {
+ local value="$1"
+
+ echo "${value#--}" >> $CONFIGFILE
+}
+
+dhcp_calc() {
+ local ip="$1"
+ local res=0
+
+ while [ -n "$ip" ]; do
+ part="${ip%%.*}"
+ res="$(($res * 256))"
+ res="$(($res + $part))"
+ [ "${ip%.*}" != "$ip" ] && ip="${ip#*.}" || ip=
+ done
+ echo "$res"
+}
+
+append_bool() {
+ local section="$1"
+ local option="$2"
+ local value="$3"
+ local _loctmp
+ config_get_bool _loctmp "$section" "$option" 0
+ [ $_loctmp -gt 0 ] && xappend "$value"
+}
+
+append_parm() {
+ local section="$1"
+ local option="$2"
+ local switch="$3"
+ local _loctmp
+ config_get _loctmp "$section" "$option"
+ [ -z "$_loctmp" ] && return 0
+ xappend "$switch=$_loctmp"
+}
+
+append_server() {
+ xappend "--server=$1"
+}
+
+append_address() {
+ xappend "--address=$1"
+}
+
+append_interface() {
+ local ifname=$(uci_get_state network "$1" ifname "$1")
+ xappend "--interface=$ifname"
+}
+
+append_notinterface() {
+ local ifname=$(uci_get_state network "$1" ifname "$1")
+ xappend "--except-interface=$ifname"
+}
+
+append_addnhosts() {
+ xappend "--addn-hosts=$1"
+}
+
+append_bogusnxdomain() {
+ xappend "--bogus-nxdomain=$1"
+}
+
+dnsmasq() {
+ local cfg="$1"
+ append_bool "$cfg" authoritative "--dhcp-authoritative"
+ append_bool "$cfg" nodaemon "--no-daemon"
+ append_bool "$cfg" domainneeded "--domain-needed"
+ append_bool "$cfg" filterwin2k "--filterwin2k"
+ append_bool "$cfg" nohosts "--no-hosts"
+ append_bool "$cfg" nonegcache "--no-negcache"
+ append_bool "$cfg" strictorder "--strict-order"
+ append_bool "$cfg" logqueries "--log-queries"
+ append_bool "$cfg" noresolv "--no-resolv"
+ append_bool "$cfg" localise_queries "--localise-queries"
+ append_bool "$cfg" readethers "--read-ethers"
+ append_bool "$cfg" dbus "--enable-dbus"
+ append_bool "$cfg" boguspriv "--bogus-priv"
+ append_bool "$cfg" expandhosts "--expand-hosts"
+ append_bool "$cfg" enable_tftp "--enable-tftp"
+ append_bool "$cfg" nonwildcard "--bind-interfaces"
+ append_bool "$cfg" fqdn "--dhcp-fqdn"
+
+ append_parm "$cfg" dhcpscript "--dhcp-script"
+ append_parm "$cfg" cachesize "--cache-size"
+ append_parm "$cfg" dnsforwardmax "--dns-forward-max"
+ append_parm "$cfg" port "--port"
+ append_parm "$cfg" ednspacket_max "--edns-packet-max"
+ append_parm "$cfg" dhcpleasemax "--dhcp-lease-max"
+ append_parm "$cfg" "queryport" "--query-port"
+ append_parm "$cfg" "domain" "--domain"
+ append_parm "$cfg" "local" "--server"
+ config_list_foreach "$cfg" "server" append_server
+ config_list_foreach "$cfg" "address" append_address
+ config_list_foreach "$cfg" "interface" append_interface
+ config_list_foreach "$cfg" "notinterface" append_notinterface
+ config_list_foreach "$cfg" "addnhosts" append_addnhosts
+ config_list_foreach "$cfg" "bogusnxdomain" append_bogusnxdomain
+ append_parm "$cfg" "leasefile" "--dhcp-leasefile"
+ append_parm "$cfg" "resolvfile" "--resolv-file"
+ append_parm "$cfg" "tftp_root" "--tftp-root"
+ append_parm "$cfg" "dhcp_boot" "--dhcp-boot"
+ append_parm "$cfg" "local_ttl" "--local-ttl"
+
+ config_get DOMAIN "$cfg" domain
+
+ config_get_bool ADD_LOCAL_DOMAIN "$cfg" add_local_domain 1
+ config_get_bool ADD_LOCAL_HOSTNAME "$cfg" add_local_hostname 1
+
+ config_get_bool readethers "$cfg" readethers
+ [ "$readethers" = "1" -a \! -e "/etc/ethers" ] && touch /etc/ethers
+
+ config_get leasefile $cfg leasefile
+ [ -n "$leasefile" -a \! -e "$leasefile" ] && touch "$leasefile"
+ config_get_bool cachelocal "$cfg" cachelocal 1
+
+ config_get hostsfile "$cfg" dhcphostsfile
+ [ -e "$hostsfile" ] && xappend "--dhcp-hostsfile=$hostsfile"
+
+ local rebind
+ config_get_bool rebind "$cfg" rebind_protection 1
+ [ $rebind -gt 0 ] && {
+ logger -t dnsmasq \
+ "DNS rebinding protection is active," \
+ "will discard upstream RFC1918 responses!"
+ xappend "--stop-dns-rebind"
+
+ local rebind_localhost
+ config_get_bool rebind_localhost "$cfg" rebind_localhost 0
+ [ $rebind_localhost -gt 0 ] && {
+ logger -t dnsmasq "Allowing 127.0.0.0/8 responses"
+ xappend "--rebind-localhost-ok"
+ }
+
+ append_rebind_domain() {
+ logger -t dnsmasq "Allowing RFC1918 responses for domain $1"
+ xappend "--rebind-domain-ok=$1"
+ }
+
+ config_list_foreach "$cfg" rebind_domain append_rebind_domain
+ }
+
+ dhcp_option_add "$cfg" "" 0
+
+ echo >> $CONFIGFILE
+}
+
+dhcp_subscrid_add() {
+ local cfg="$1"
+
+ config_get networkid "$cfg" networkid
+ [ -n "$networkid" ] || return 0
+
+ config_get subscriberid "$cfg" subscriberid
+ [ -n "$subscriberid" ] || return 0
+
+ xappend "--dhcp-subscrid=$networkid,$subscriberid"
+
+ config_get_bool force "$cfg" force 0
+
+ dhcp_option_add "$cfg" "$networkid" "$force"
+}
+
+dhcp_remoteid_add() {
+ local cfg="$1"
+
+ config_get networkid "$cfg" networkid
+ [ -n "$networkid" ] || return 0
+
+ config_get remoteid "$cfg" remoteid
+ [ -n "$remoteid" ] || return 0
+
+ xappend "--dhcp-remoteid=$networkid,$remoteid"
+
+ config_get_bool force "$cfg" force 0
+
+ dhcp_option_add "$cfg" "$networkid" "$force"
+}
+
+dhcp_circuitid_add() {
+ local cfg="$1"
+
+ config_get networkid "$cfg" networkid
+ [ -n "$networkid" ] || return 0
+
+ config_get circuitid "$cfg" circuitid
+ [ -n "$circuitid" ] || return 0
+
+ xappend "--dhcp-circuitid=$networkid,$circuitid"
+
+ config_get_bool force "$cfg" force 0
+
+ dhcp_option_add "$cfg" "$networkid" "$force"
+}
+
+dhcp_userclass_add() {
+ local cfg="$1"
+
+ config_get networkid "$cfg" networkid
+ [ -n "$networkid" ] || return 0
+
+ config_get userclass "$cfg" userclass
+ [ -n "$userclass" ] || return 0
+
+ xappend "--dhcp-userclass=$networkid,$userclass"
+
+ config_get_bool force "$cfg" force 0
+
+ dhcp_option_add "$cfg" "$networkid" "$force"
+}
+
+dhcp_vendorclass_add() {
+ local cfg="$1"
+
+ config_get networkid "$cfg" networkid
+ [ -n "$networkid" ] || return 0
+
+ config_get vendorclass "$cfg" vendorclass
+ [ -n "$vendorclass" ] || return 0
+
+ xappend "--dhcp-vendorclass=$networkid,$vendorclass"
+
+ config_get_bool force "$cfg" force 0
+
+ dhcp_option_add "$cfg" "$networkid" "$force"
+}
+
+dhcp_host_add() {
+ local cfg="$1"
+
+ config_get_bool force "$cfg" force 0
+
+ config_get networkid "$cfg" networkid
+ [ -n "$networkid" ] && dhcp_option_add "$cfg" "$networkid" "$force"
+
+ config_get name "$cfg" name
+ config_get ip "$cfg" ip
+ [ -n "$ip" -o -n "$name" ] || return 0
+
+ config_get mac "$cfg" mac
+ [ -z "$mac" ] && {
+ [ -n "$name" ] || return 0
+ mac="$name"
+ name=""
+ }
+
+ macs=""
+ for m in $mac; do append macs "$m" ","; done
+
+ config_get tag "$cfg" tag
+
+ xappend "--dhcp-host=$macs${networkid:+,net:$networkid}${tag:+,set:$tag}${ip:+,$ip}${name:+,$name}"
+}
+
+dhcp_tag_add() {
+ local cfg="$1"
+
+ tag="$cfg"
+
+ [ -n "$tag" ] || return 0
+
+ config_get_bool force "$cfg" force 0
+ [ "$force" = "0" ] && force=
+
+ config_get option "$cfg" dhcp_option
+ for o in $option; do
+ xappend "--dhcp-option${force:+-force}=tag:$tag,$o"
+ done
+}
+
+dhcp_mac_add() {
+ local cfg="$1"
+
+ config_get networkid "$cfg" networkid
+ [ -n "$networkid" ] || return 0
+
+ config_get mac "$cfg" mac
+ [ -n "$mac" ] || return 0
+
+ xappend "--dhcp-mac=$networkid,$mac"
+
+ dhcp_option_add "$cfg" "$networkid"
+}
+
+dhcp_boot_add() {
+ local cfg="$1"
+
+ config_get networkid "$cfg" networkid
+
+ config_get filename "$cfg" filename
+ [ -n "$filename" ] || return 0
+
+ config_get servername "$cfg" servername
+ [ -n "$servername" ] || return 0
+
+ config_get serveraddress "$cfg" serveraddress
+ [ -n "$serveraddress" ] || return 0
+
+ xappend "--dhcp-boot=${networkid:+net:$networkid,}$filename,$servername,$serveraddress"
+
+ config_get_bool force "$cfg" force 0
+
+ dhcp_option_add "$cfg" "$networkid" "$force"
+}
+
+
+dhcp_add() {
+ local cfg="$1"
+ config_get net "$cfg" interface
+ [ -n "$net" ] || return 0
+
+ config_get networkid "$cfg" networkid
+ [ -n "$networkid" ] || networkid="$net"
+
+ config_get ifname "$net" ifname
+ [ -n "$ifname" ] || return 0
+
+ config_get dnsserver "$net" dns
+ [ "$cachelocal" = "0" -a -n "$dnsserver" ] && {
+ DNS_SERVERS="$DNS_SERVERS $dnsserver"
+ }
+
+ append_bool "$cfg" ignore "--no-dhcp-interface=$ifname" && return 0
+
+ config_get proto "$net" proto
+ [ static = "$proto" ] || return 0
+
+ config_get ipaddr "$net" ipaddr
+ config_get netmask "$cfg" netmask
+ [ -n "$netmask" ] || config_get netmask "$net" netmask
+
+ #check for an already active dhcp server on the interface, unless 'force' is set
+ config_get_bool force "$cfg" force 0
+ [ $force -gt 0 ] || {
+ udhcpc -n -q -s /bin/true -t 1 -i $ifname >&- && {
+ logger -t dnsmasq \
+ "found already running DHCP-server on interface '$ifname'" \
+ "refusing to start, use 'option force 1' to override"
+ return 0
+ }
+ }
+
+ config_get start "$cfg" start
+ config_get limit "$cfg" limit
+ config_get leasetime "$cfg" leasetime
+ config_get options "$cfg" options
+ config_get_bool dynamicdhcp "$cfg" dynamicdhcp 1
+
+ leasetime="${leasetime:-12h}"
+ start="$(dhcp_calc "${start:-100}")"
+ limit="${limit:-150}"
+ [ "$limit" -gt 0 ] && limit=$((limit-1))
+ eval "$(ipcalc.sh $ipaddr $netmask $start $limit)"
+ if [ "$dynamicdhcp" = "0" ]; then END="static"; fi
+ xappend "--dhcp-range=$networkid,$START,$END,$NETMASK,$leasetime${options:+ $options}"
+
+ dhcp_option_add "$cfg" "$networkid"
+}
+
+dhcp_option_add() {
+ local cfg="$1"
+ local networkid="$2"
+ local force="$3"
+
+ [ "$force" = "0" ] && force=
+
+ config_get dhcp_option "$cfg" dhcp_option
+ for o in $dhcp_option; do
+ xappend "--dhcp-option${force:+-force}=${networkid:+$networkid,}$o"
+ done
+
+}
+
+dhcp_domain_add() {
+ local cfg="$1"
+ local ip name names
+
+ config_get names "$cfg" name "$2"
+ [ -n "$names" ] || return 0
+
+ config_get ip "$cfg" ip "$3"
+ [ -n "$ip" ] || return 0
+
+ local oIFS="$IFS"; IFS="."; set -- $ip; IFS="$oIFS"
+ local raddr="${4:+$4.$3.$2.$1.in-addr.arpa}"
+
+ for name in $names; do
+ local fqdn="$name"
+
+ [ "${fqdn%.*}" == "$fqdn" ] && \
+ fqdn="$fqdn${DOMAIN:+.$DOMAIN}"
+
+ xappend "--address=/$fqdn/$ip"
+
+ [ -n "$raddr" ] && {
+ xappend "--ptr-record=$raddr,$fqdn"
+ raddr=""
+ }
+ done
+}
+
+dhcp_srv_add() {
+ local cfg="$1"
+
+ config_get srv "$cfg" srv
+ [ -n "$srv" ] || return 0
+
+ config_get target "$cfg" target
+ [ -n "$target" ] || return 0
+
+ config_get port "$cfg" port
+ [ -n "$port" ] || return 0
+
+ config_get class "$cfg" class
+ config_get weight "$cfg" weight
+
+ local service="$srv,$target,$port${class:+,$class${weight:+,$weight}}"
+
+ xappend "--srv-host=$service"
+}
+
+dhcp_mx_add() {
+ local cfg="$1"
+ local domain relay pref
+
+ config_get domain "$cfg" domain
+ [ -n "$domain" ] || return 0
+
+ config_get relay "$cfg" relay
+ [ -n "$relay" ] || return 0
+
+ config_get pref "$cfg" pref 0
+
+ local service="$domain,$relay,$pref"
+
+ xappend "--mx-host=$service"
+}
+
+dhcp_cname_add() {
+ local cfg="$1"
+ local cname target
+
+ config_get cname "$cfg" cname
+ [ -n "$cname" ] || return 0
+
+ config_get target "$cfg" target
+ [ -n "$target" ] || return 0
+
+ xappend "--cname=${cname},${target}"
+}
+
+start() {
+ include /lib/network
+ scan_interfaces
+
+ local lanaddr
+ config_get lanaddr "lan" ipaddr
+
+ config_load dhcp
+
+ # before we can call xappend
+ mkdir -p $(dirname $CONFIGFILE)
+
+ echo "# auto-generated config file from /etc/config/dhcp" > $CONFIGFILE
+
+ # if we did this last, we could override auto-generated config
+ [ -f /etc/dnsmasq.conf ] && {
+ xappend "--conf-file=/etc/dnsmasq.conf"
+ }
+
+ args=""
+ config_foreach dnsmasq dnsmasq
+ config_foreach dhcp_host_add host
+ echo >> $CONFIGFILE
+ config_foreach dhcp_boot_add boot
+ config_foreach dhcp_mac_add mac
+ config_foreach dhcp_tag_add tag
+ config_foreach dhcp_vendorclass_add vendorclass
+ config_foreach dhcp_userclass_add userclass
+ config_foreach dhcp_circuitid_add circuitid
+ config_foreach dhcp_remoteid_add remoteid
+ config_foreach dhcp_subscrid_add subscrid
+ config_foreach dhcp_domain_add domain
+ echo >> $CONFIGFILE
+ config_foreach dhcp_srv_add srvhost
+ config_foreach dhcp_mx_add mxhost
+ echo >> $CONFIGFILE
+ config_foreach dhcp_add dhcp
+ echo >> $CONFIGFILE
+ config_foreach dhcp_cname_add cname
+ echo >> $CONFIGFILE
+
+ # add own hostname
+ [ $ADD_LOCAL_HOSTNAME -eq 1 ] && [ -n "$lanaddr" ] && {
+ local hostname="$(uci_get system.@system[0].hostname)"
+ dhcp_domain_add "" "${hostname:-OpenWrt}" "$lanaddr"
+ }
+
+ service_start /usr/sbin/dnsmasq -C $CONFIGFILE && {
+ rm -f /tmp/resolv.conf
+ [ $ADD_LOCAL_DOMAIN -eq 1 ] && [ -n "$DOMAIN" ] && {
+ echo "search $DOMAIN" >> /tmp/resolv.conf
+ }
+ DNS_SERVERS="$DNS_SERVERS 127.0.0.1"
+ for DNS_SERVER in $DNS_SERVERS ; do
+ echo "nameserver $DNS_SERVER" >> /tmp/resolv.conf
+ done
+ }
+}
+
+stop() {
+ service_stop /usr/sbin/dnsmasq && {
+ [ -f /tmp/resolv.conf ] && {
+ rm -f /tmp/resolv.conf
+ ln -s /tmp/resolv.conf.auto /tmp/resolv.conf
+ }
+ }
+}
diff --git a/package/network/services/dnsmasq/patches/.svn/entries b/package/network/services/dnsmasq/patches/.svn/entries
new file mode 100644
index 0000000..76333aa
--- /dev/null
+++ b/package/network/services/dnsmasq/patches/.svn/entries
@@ -0,0 +1,96 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/services/dnsmasq/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-08-22T09:14:42.535502Z
+33216
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+0001-Set-prefix-on-link-bit-in-RAs.patch
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+9d3b09a16078a121d9c2a6058621271c
+2012-08-22T09:14:42.535502Z
+33216
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1330
+
+100-fix-dhcp-no-address-warning.patch
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+191241f8b3adbfadfc9614492f73182e
+2012-07-19T19:12:54.732401Z
+32781
+acinonyx
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1748
+
diff --git a/package/network/services/dnsmasq/patches/.svn/text-base/0001-Set-prefix-on-link-bit-in-RAs.patch.svn-base b/package/network/services/dnsmasq/patches/.svn/text-base/0001-Set-prefix-on-link-bit-in-RAs.patch.svn-base
new file mode 100644
index 0000000..8ead9af
--- /dev/null
+++ b/package/network/services/dnsmasq/patches/.svn/text-base/0001-Set-prefix-on-link-bit-in-RAs.patch.svn-base
@@ -0,0 +1,42 @@
+From fd05f127909bbf4f6983a4de2dcb611947488dee Mon Sep 17 00:00:00 2001
+From: Simon Kelley <simon@thekelleys.org.uk>
+Date: Sun, 12 Aug 2012 17:48:50 +0100
+Subject: [PATCH] Set prefix on-link bit in RAs
+
+---
+ CHANGELOG | 3 +++
+ src/radv.c | 4 ++--
+ 2 files changed, 5 insertions(+), 2 deletions(-)
+
+diff --git a/CHANGELOG b/CHANGELOG
+index 8828694..e1daeef 100644
+--- a/CHANGELOG
++++ b/CHANGELOG
+@@ -45,6 +45,9 @@ version 2.63
+ uk.org.thekelleys.dnsmasq. Thanks to Mathieu
+ Trudel-Lapierre for the patch.
+
++ Set the "prefix on-link" bit in Router
++ Advertisements. Thanks to Gui Iribarren for the patch.
++
+
+ version 2.62
+ Update German translation. Thanks to Conrad Kostecki.
+diff --git a/src/radv.c b/src/radv.c
+index a3e691a..d1f5268 100644
+--- a/src/radv.c
++++ b/src/radv.c
+@@ -412,8 +412,8 @@ static int add_prefixes(struct in6_addr *local, int prefix,
+ opt->type = ICMP6_OPT_PREFIX;
+ opt->len = 4;
+ opt->prefix_len = prefix;
+- /* autonomous only if we're not doing dhcp */
+- opt->flags = do_slaac ? 0x40 : 0x00;
++ /* autonomous only if we're not doing dhcp, always set "on-link" */
++ opt->flags = do_slaac ? 0xC0 : 0x80;
+ opt->valid_lifetime = htonl(time);
+ opt->preferred_lifetime = htonl(deprecate ? 0 : time);
+ opt->reserved = 0;
+--
+1.7.10.GIT
+
diff --git a/package/network/services/dnsmasq/patches/.svn/text-base/100-fix-dhcp-no-address-warning.patch.svn-base b/package/network/services/dnsmasq/patches/.svn/text-base/100-fix-dhcp-no-address-warning.patch.svn-base
new file mode 100644
index 0000000..d108a7d
--- /dev/null
+++ b/package/network/services/dnsmasq/patches/.svn/text-base/100-fix-dhcp-no-address-warning.patch.svn-base
@@ -0,0 +1,49 @@
+--- a/src/dhcp.c
++++ b/src/dhcp.c
+@@ -134,7 +134,7 @@ void dhcp_packet(time_t now, int pxe_fd)
+ struct iovec iov;
+ ssize_t sz;
+ int iface_index = 0, unicast_dest = 0, is_inform = 0;
+- struct in_addr iface_addr;
++ struct in_addr iface_addr, *addrp = NULL;
+ struct iface_param parm;
+ #ifdef HAVE_LINUX_NETWORK
+ struct arpreq arp_req;
+@@ -246,11 +246,9 @@ void dhcp_packet(time_t now, int pxe_fd)
+
+ ifr.ifr_addr.sa_family = AF_INET;
+ if (ioctl(daemon->dhcpfd, SIOCGIFADDR, &ifr) != -1 )
+- iface_addr = ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr;
+- else
+ {
+- my_syslog(MS_DHCP | LOG_WARNING, _("DHCP packet received on %s which has no address"), ifr.ifr_name);
+- return;
++ addrp = &iface_addr;
++ iface_addr = ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr;
+ }
+
+ for (tmp = daemon->dhcp_except; tmp; tmp = tmp->next)
+@@ -272,7 +270,7 @@ void dhcp_packet(time_t now, int pxe_fd)
+ parm.current = NULL;
+ parm.ind = iface_index;
+
+- if (!iface_check(AF_INET, (struct all_addr *)&iface_addr, ifr.ifr_name))
++ if (!iface_check(AF_INET, (struct all_addr *)addrp, ifr.ifr_name))
+ {
+ /* If we failed to match the primary address of the interface, see if we've got a --listen-address
+ for a secondary */
+@@ -291,7 +289,13 @@ void dhcp_packet(time_t now, int pxe_fd)
+ there is more than one address on the interface in the same subnet */
+ complete_context(match.addr, iface_index, match.netmask, match.broadcast, &parm);
+ }
+-
++
++ if (!addrp)
++ {
++ my_syslog(MS_DHCP | LOG_WARNING, _("DHCP packet received on %s which has no address"), ifr.ifr_name);
++ return;
++ }
++
+ if (!iface_enumerate(AF_INET, &parm, complete_context))
+ return;
+
diff --git a/package/network/services/dnsmasq/patches/0001-Set-prefix-on-link-bit-in-RAs.patch b/package/network/services/dnsmasq/patches/0001-Set-prefix-on-link-bit-in-RAs.patch
new file mode 100644
index 0000000..8ead9af
--- /dev/null
+++ b/package/network/services/dnsmasq/patches/0001-Set-prefix-on-link-bit-in-RAs.patch
@@ -0,0 +1,42 @@
+From fd05f127909bbf4f6983a4de2dcb611947488dee Mon Sep 17 00:00:00 2001
+From: Simon Kelley <simon@thekelleys.org.uk>
+Date: Sun, 12 Aug 2012 17:48:50 +0100
+Subject: [PATCH] Set prefix on-link bit in RAs
+
+---
+ CHANGELOG | 3 +++
+ src/radv.c | 4 ++--
+ 2 files changed, 5 insertions(+), 2 deletions(-)
+
+diff --git a/CHANGELOG b/CHANGELOG
+index 8828694..e1daeef 100644
+--- a/CHANGELOG
++++ b/CHANGELOG
+@@ -45,6 +45,9 @@ version 2.63
+ uk.org.thekelleys.dnsmasq. Thanks to Mathieu
+ Trudel-Lapierre for the patch.
+
++ Set the "prefix on-link" bit in Router
++ Advertisements. Thanks to Gui Iribarren for the patch.
++
+
+ version 2.62
+ Update German translation. Thanks to Conrad Kostecki.
+diff --git a/src/radv.c b/src/radv.c
+index a3e691a..d1f5268 100644
+--- a/src/radv.c
++++ b/src/radv.c
+@@ -412,8 +412,8 @@ static int add_prefixes(struct in6_addr *local, int prefix,
+ opt->type = ICMP6_OPT_PREFIX;
+ opt->len = 4;
+ opt->prefix_len = prefix;
+- /* autonomous only if we're not doing dhcp */
+- opt->flags = do_slaac ? 0x40 : 0x00;
++ /* autonomous only if we're not doing dhcp, always set "on-link" */
++ opt->flags = do_slaac ? 0xC0 : 0x80;
+ opt->valid_lifetime = htonl(time);
+ opt->preferred_lifetime = htonl(deprecate ? 0 : time);
+ opt->reserved = 0;
+--
+1.7.10.GIT
+
diff --git a/package/network/services/dnsmasq/patches/100-fix-dhcp-no-address-warning.patch b/package/network/services/dnsmasq/patches/100-fix-dhcp-no-address-warning.patch
new file mode 100644
index 0000000..d108a7d
--- /dev/null
+++ b/package/network/services/dnsmasq/patches/100-fix-dhcp-no-address-warning.patch
@@ -0,0 +1,49 @@
+--- a/src/dhcp.c
++++ b/src/dhcp.c
+@@ -134,7 +134,7 @@ void dhcp_packet(time_t now, int pxe_fd)
+ struct iovec iov;
+ ssize_t sz;
+ int iface_index = 0, unicast_dest = 0, is_inform = 0;
+- struct in_addr iface_addr;
++ struct in_addr iface_addr, *addrp = NULL;
+ struct iface_param parm;
+ #ifdef HAVE_LINUX_NETWORK
+ struct arpreq arp_req;
+@@ -246,11 +246,9 @@ void dhcp_packet(time_t now, int pxe_fd)
+
+ ifr.ifr_addr.sa_family = AF_INET;
+ if (ioctl(daemon->dhcpfd, SIOCGIFADDR, &ifr) != -1 )
+- iface_addr = ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr;
+- else
+ {
+- my_syslog(MS_DHCP | LOG_WARNING, _("DHCP packet received on %s which has no address"), ifr.ifr_name);
+- return;
++ addrp = &iface_addr;
++ iface_addr = ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr;
+ }
+
+ for (tmp = daemon->dhcp_except; tmp; tmp = tmp->next)
+@@ -272,7 +270,7 @@ void dhcp_packet(time_t now, int pxe_fd)
+ parm.current = NULL;
+ parm.ind = iface_index;
+
+- if (!iface_check(AF_INET, (struct all_addr *)&iface_addr, ifr.ifr_name))
++ if (!iface_check(AF_INET, (struct all_addr *)addrp, ifr.ifr_name))
+ {
+ /* If we failed to match the primary address of the interface, see if we've got a --listen-address
+ for a secondary */
+@@ -291,7 +289,13 @@ void dhcp_packet(time_t now, int pxe_fd)
+ there is more than one address on the interface in the same subnet */
+ complete_context(match.addr, iface_index, match.netmask, match.broadcast, &parm);
+ }
+-
++
++ if (!addrp)
++ {
++ my_syslog(MS_DHCP | LOG_WARNING, _("DHCP packet received on %s which has no address"), ifr.ifr_name);
++ return;
++ }
++
+ if (!iface_enumerate(AF_INET, &parm, complete_context))
+ return;
+
diff --git a/package/network/services/dropbear/.svn/entries b/package/network/services/dropbear/.svn/entries
new file mode 100644
index 0000000..e3f2362
--- /dev/null
+++ b/package/network/services/dropbear/.svn/entries
@@ -0,0 +1,68 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/services/dropbear
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-12-22T18:56:13.427662Z
+34867
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+files
+dir
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+89a8ed8bbc66e59523f7a3e140097543
+2012-12-04T16:40:17.503431Z
+34496
+florian
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2913
+
diff --git a/package/network/services/dropbear/.svn/prop-base/Makefile.svn-base b/package/network/services/dropbear/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..8e522ae
--- /dev/null
+++ b/package/network/services/dropbear/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:copyright
+V 30
+Copyright (C) 2006 OpenWrt.org
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/services/dropbear/.svn/text-base/Makefile.svn-base b/package/network/services/dropbear/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..b7708b1
--- /dev/null
+++ b/package/network/services/dropbear/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,109 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=dropbear
+PKG_VERSION:=2012.55
+PKG_RELEASE:=2
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:= \
+ http://matt.ucc.asn.au/dropbear/releases/ \
+ http://www.mirrors.wiretapped.net/security/cryptography/apps/ssh/dropbear/
+PKG_MD5SUM:=8c784baec3054cdb1bb4bfa792c87812
+
+PKG_LICENSE:=MIT
+PKG_LICENSE_FILES:=LICENSE libtomcrypt/LICENSE libtommath/LICENSE
+
+PKG_BUILD_PARALLEL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/dropbear/Default
+ URL:=http://matt.ucc.asn.au/dropbear/
+endef
+
+define Package/dropbear
+ $(call Package/dropbear/Default)
+ SECTION:=net
+ CATEGORY:=Base system
+ TITLE:=Small SSH2 client/server
+endef
+
+define Package/dropbear/description
+ A small SSH2 server/client designed for small memory environments.
+endef
+
+define Package/dropbear/conffiles
+/etc/dropbear/dropbear_rsa_host_key
+/etc/dropbear/dropbear_dss_host_key
+/etc/config/dropbear
+endef
+
+define Package/dropbearconvert
+ $(call Package/dropbear/Default)
+ SECTION:=utils
+ CATEGORY:=Utilities
+ TITLE:=Utility for converting SSH keys
+endef
+
+CONFIGURE_ARGS += \
+ --with-shared \
+ --disable-pam \
+ --enable-openpty \
+ --enable-syslog \
+ $(if $(CONFIG_SHADOW_PASSWORDS),,--disable-shadow) \
+ --disable-lastlog \
+ --disable-utmp \
+ --disable-utmpx \
+ --disable-wtmp \
+ --disable-wtmpx \
+ --disable-loginfunc \
+ --disable-pututline \
+ --disable-pututxline \
+ --disable-zlib \
+ --enable-bundled-libtom
+
+TARGET_CFLAGS += -DARGTYPE=3 -ffunction-sections -fdata-sections
+TARGET_LDFLAGS += -Wl,--gc-sections
+
+define Build/Compile
+ +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
+ $(TARGET_CONFIGURE_OPTS) \
+ PROGRAMS="dropbear dbclient dropbearkey scp" \
+ MULTI=1 SCPPROGRESS=1
+ +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
+ $(TARGET_CONFIGURE_OPTS) \
+ PROGRAMS="dropbearconvert"
+endef
+
+define Package/dropbear/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/dropbearmulti $(1)/usr/sbin/dropbear
+ $(INSTALL_DIR) $(1)/usr/bin
+ ln -sf ../sbin/dropbear $(1)/usr/bin/scp
+ ln -sf ../sbin/dropbear $(1)/usr/bin/ssh
+ ln -sf ../sbin/dropbear $(1)/usr/bin/dbclient
+ ln -sf ../sbin/dropbear $(1)/usr/bin/dropbearkey
+ $(INSTALL_DIR) $(1)/etc/config
+ $(INSTALL_DATA) ./files/dropbear.config $(1)/etc/config/dropbear
+ $(INSTALL_DIR) $(1)/etc/init.d
+ $(INSTALL_BIN) ./files/dropbear.init $(1)/etc/init.d/dropbear
+ $(INSTALL_DIR) $(1)/usr/lib/opkg/info
+ $(INSTALL_DIR) $(1)/etc/dropbear
+ touch $(1)/etc/dropbear/dropbear_rsa_host_key
+ touch $(1)/etc/dropbear/dropbear_dss_host_key
+endef
+
+define Package/dropbearconvert/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/dropbearconvert $(1)/usr/bin/dropbearconvert
+endef
+
+$(eval $(call BuildPackage,dropbear))
+$(eval $(call BuildPackage,dropbearconvert))
diff --git a/package/network/services/dropbear/Makefile b/package/network/services/dropbear/Makefile
new file mode 100644
index 0000000..b7708b1
--- /dev/null
+++ b/package/network/services/dropbear/Makefile
@@ -0,0 +1,109 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=dropbear
+PKG_VERSION:=2012.55
+PKG_RELEASE:=2
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:= \
+ http://matt.ucc.asn.au/dropbear/releases/ \
+ http://www.mirrors.wiretapped.net/security/cryptography/apps/ssh/dropbear/
+PKG_MD5SUM:=8c784baec3054cdb1bb4bfa792c87812
+
+PKG_LICENSE:=MIT
+PKG_LICENSE_FILES:=LICENSE libtomcrypt/LICENSE libtommath/LICENSE
+
+PKG_BUILD_PARALLEL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/dropbear/Default
+ URL:=http://matt.ucc.asn.au/dropbear/
+endef
+
+define Package/dropbear
+ $(call Package/dropbear/Default)
+ SECTION:=net
+ CATEGORY:=Base system
+ TITLE:=Small SSH2 client/server
+endef
+
+define Package/dropbear/description
+ A small SSH2 server/client designed for small memory environments.
+endef
+
+define Package/dropbear/conffiles
+/etc/dropbear/dropbear_rsa_host_key
+/etc/dropbear/dropbear_dss_host_key
+/etc/config/dropbear
+endef
+
+define Package/dropbearconvert
+ $(call Package/dropbear/Default)
+ SECTION:=utils
+ CATEGORY:=Utilities
+ TITLE:=Utility for converting SSH keys
+endef
+
+CONFIGURE_ARGS += \
+ --with-shared \
+ --disable-pam \
+ --enable-openpty \
+ --enable-syslog \
+ $(if $(CONFIG_SHADOW_PASSWORDS),,--disable-shadow) \
+ --disable-lastlog \
+ --disable-utmp \
+ --disable-utmpx \
+ --disable-wtmp \
+ --disable-wtmpx \
+ --disable-loginfunc \
+ --disable-pututline \
+ --disable-pututxline \
+ --disable-zlib \
+ --enable-bundled-libtom
+
+TARGET_CFLAGS += -DARGTYPE=3 -ffunction-sections -fdata-sections
+TARGET_LDFLAGS += -Wl,--gc-sections
+
+define Build/Compile
+ +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
+ $(TARGET_CONFIGURE_OPTS) \
+ PROGRAMS="dropbear dbclient dropbearkey scp" \
+ MULTI=1 SCPPROGRESS=1
+ +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
+ $(TARGET_CONFIGURE_OPTS) \
+ PROGRAMS="dropbearconvert"
+endef
+
+define Package/dropbear/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/dropbearmulti $(1)/usr/sbin/dropbear
+ $(INSTALL_DIR) $(1)/usr/bin
+ ln -sf ../sbin/dropbear $(1)/usr/bin/scp
+ ln -sf ../sbin/dropbear $(1)/usr/bin/ssh
+ ln -sf ../sbin/dropbear $(1)/usr/bin/dbclient
+ ln -sf ../sbin/dropbear $(1)/usr/bin/dropbearkey
+ $(INSTALL_DIR) $(1)/etc/config
+ $(INSTALL_DATA) ./files/dropbear.config $(1)/etc/config/dropbear
+ $(INSTALL_DIR) $(1)/etc/init.d
+ $(INSTALL_BIN) ./files/dropbear.init $(1)/etc/init.d/dropbear
+ $(INSTALL_DIR) $(1)/usr/lib/opkg/info
+ $(INSTALL_DIR) $(1)/etc/dropbear
+ touch $(1)/etc/dropbear/dropbear_rsa_host_key
+ touch $(1)/etc/dropbear/dropbear_dss_host_key
+endef
+
+define Package/dropbearconvert/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/dropbearconvert $(1)/usr/bin/dropbearconvert
+endef
+
+$(eval $(call BuildPackage,dropbear))
+$(eval $(call BuildPackage,dropbearconvert))
diff --git a/package/network/services/dropbear/files/.svn/entries b/package/network/services/dropbear/files/.svn/entries
new file mode 100644
index 0000000..e6f6c66
--- /dev/null
+++ b/package/network/services/dropbear/files/.svn/entries
@@ -0,0 +1,96 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/services/dropbear/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-12-22T18:56:13.427662Z
+34867
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+dropbear.init
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+2d44624a881b1c20cc18e6ff8d3a5cec
+2012-12-22T18:56:13.427662Z
+34867
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4061
+
+dropbear.config
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+4ff9c827d4f95ca5082a5520c03e1419
+2010-07-27T03:36:27.330805Z
+22394
+cshore
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+134
+
diff --git a/package/network/services/dropbear/files/.svn/prop-base/dropbear.config.svn-base b/package/network/services/dropbear/files/.svn/prop-base/dropbear.config.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/network/services/dropbear/files/.svn/prop-base/dropbear.config.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/services/dropbear/files/.svn/prop-base/dropbear.init.svn-base b/package/network/services/dropbear/files/.svn/prop-base/dropbear.init.svn-base
new file mode 100644
index 0000000..03b5bfa
--- /dev/null
+++ b/package/network/services/dropbear/files/.svn/prop-base/dropbear.init.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:eol-style
+V 6
+native
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/network/services/dropbear/files/.svn/text-base/dropbear.config.svn-base b/package/network/services/dropbear/files/.svn/text-base/dropbear.config.svn-base
new file mode 100644
index 0000000..2139ba0
--- /dev/null
+++ b/package/network/services/dropbear/files/.svn/text-base/dropbear.config.svn-base
@@ -0,0 +1,5 @@
+config dropbear
+ option PasswordAuth 'on'
+ option RootPasswordAuth 'on'
+ option Port '22'
+# option BannerFile '/etc/banner'
diff --git a/package/network/services/dropbear/files/.svn/text-base/dropbear.init.svn-base b/package/network/services/dropbear/files/.svn/text-base/dropbear.init.svn-base
new file mode 100644
index 0000000..66ed8b9
--- /dev/null
+++ b/package/network/services/dropbear/files/.svn/text-base/dropbear.init.svn-base
@@ -0,0 +1,176 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2006 Carlos Sobrinho
+
+START=50
+STOP=50
+
+USE_PROCD=1
+
+NAME=dropbear
+PROG=/usr/sbin/dropbear
+PIDCOUNT=0
+EXTRA_COMMANDS="killclients"
+EXTRA_HELP=" killclients Kill ${NAME} processes except servers and yourself"
+
+dropbear_instance()
+{
+ append_ports()
+ {
+ local ifname="$1"
+ local port="$2"
+
+ grep -qs "^ *$ifname:" /proc/net/dev || {
+ procd_append_param command -p "$port"
+ return
+ }
+
+ for addr in $(
+ ifconfig "$ifname" | sed -ne '
+ /addr: *fe[89ab][0-9a-f]:/d
+ s/.* addr: *\([0-9a-f:\.]*\).*/\1/p
+ '
+ ); do
+ procd_append_param command -p "$addr:$port"
+ done
+ }
+
+
+ local section="$1"
+
+ # check if section is enabled (default)
+ local enabled
+ config_get_bool enabled "${section}" enable 1
+ [ "${enabled}" -eq 0 ] && return 1
+
+ # increase pid file count to handle multiple instances correctly
+ PIDCOUNT="$(( ${PIDCOUNT} + 1))"
+
+ local pid_file="/var/run/${NAME}.${PIDCOUNT}.pid"
+
+ procd_open_instance
+ procd_set_param command "$PROG" -F -P "$pid_file"
+
+ # prepare parameters (initialise with pid file)
+ local val
+
+ # A) password authentication
+ config_get_bool val "${section}" PasswordAuth 1
+ [ "${val}" -eq 0 ] && procd_append_param command -s
+
+ # B) listen interface and port
+ local port
+ local interface
+ config_get interface "${section}" Interface
+ [ -n "$interface" ] && network_get_device interface "$interface"
+ config_get port "${section}" Port 22
+ append_ports "$interface" "$port"
+ # C) banner file
+ config_get val "${section}" BannerFile
+ [ -f "${val}" ] && procd_append_param command -b "${val}"
+ # D) gatewayports
+ config_get_bool val "${section}" GatewayPorts 0
+ [ "${val}" -eq 1 ] && procd_append_param command -a
+ # E) root password authentication
+ config_get_bool val "${section}" RootPasswordAuth 1
+ [ "${val}" -eq 0 ] && procd_append_param command -g
+ # F) root login
+ config_get_bool val "${section}" RootLogin 1
+ [ "${val}" -eq 0 ] && procd_append_param command -w
+ # G) host keys
+ config_get val "${section}" rsakeyfile
+ [ -f "${val}" ] && procd_append_param command -r "${val}"
+ config_get val "${section}" dsskeyfile
+ [ -f "${val}" ] && procd_append_param command -d "${val}"
+
+ procd_close_instance
+}
+
+keygen()
+{
+ for keytype in rsa dss; do
+ # check for keys
+ key=dropbear/dropbear_${keytype}_host_key
+ [ -f /tmp/$key -o -s /etc/$key ] || {
+ # generate missing keys
+ mkdir -p /tmp/dropbear
+ [ -x /usr/bin/dropbearkey ] && {
+ /usr/bin/dropbearkey -t $keytype -f /tmp/$key 2>&- >&- && exec /etc/rc.common "$initscript" start
+ } &
+ exit 0
+ }
+ done
+
+ lock /tmp/.switch2jffs
+ mkdir -p /etc/dropbear
+ mv /tmp/dropbear/dropbear_* /etc/dropbear/
+ lock -u /tmp/.switch2jffs
+ chown root /etc/dropbear
+ chmod 0700 /etc/dropbear
+}
+
+start_service()
+{
+ [ -s /etc/dropbear/dropbear_rsa_host_key -a \
+ -s /etc/dropbear/dropbear_dss_host_key ] || keygen
+
+ . /lib/functions.sh
+ . /lib/functions/network.sh
+
+ config_load "${NAME}"
+ config_foreach dropbear_instance dropbear
+}
+
+killclients()
+{
+ local ignore=''
+ local server
+ local pid
+
+ # if this script is run from inside a client session, then ignore that session
+ pid="$$"
+ while [ "${pid}" -ne 0 ]
+ do
+ # get parent process id
+ pid=`cut -d ' ' -f 4 "/proc/${pid}/stat"`
+ [ "${pid}" -eq 0 ] && break
+
+ # check if client connection
+ grep -F -q -e "${PROG}" "/proc/${pid}/cmdline" && {
+ append ignore "${pid}"
+ break
+ }
+ done
+
+ # get all server pids that should be ignored
+ for server in `cat /var/run/${NAME}.*.pid`
+ do
+ append ignore "${server}"
+ done
+
+ # get all running pids and kill client connections
+ local skip
+ for pid in `pidof "${NAME}"`
+ do
+ # check if correct program, otherwise process next pid
+ grep -F -q -e "${PROG}" "/proc/${pid}/cmdline" || {
+ continue
+ }
+
+ # check if pid should be ignored (servers, ourself)
+ skip=0
+ for server in ${ignore}
+ do
+ if [ "${pid}" == "${server}" ]
+ then
+ skip=1
+ break
+ fi
+ done
+ [ "${skip}" -ne 0 ] && continue
+
+ # kill process
+ echo "${initscript}: Killing ${pid}..."
+ kill -KILL ${pid}
+ done
+}
diff --git a/package/network/services/dropbear/files/dropbear.config b/package/network/services/dropbear/files/dropbear.config
new file mode 100644
index 0000000..2139ba0
--- /dev/null
+++ b/package/network/services/dropbear/files/dropbear.config
@@ -0,0 +1,5 @@
+config dropbear
+ option PasswordAuth 'on'
+ option RootPasswordAuth 'on'
+ option Port '22'
+# option BannerFile '/etc/banner'
diff --git a/package/network/services/dropbear/files/dropbear.init b/package/network/services/dropbear/files/dropbear.init
new file mode 100755
index 0000000..66ed8b9
--- /dev/null
+++ b/package/network/services/dropbear/files/dropbear.init
@@ -0,0 +1,176 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2006 Carlos Sobrinho
+
+START=50
+STOP=50
+
+USE_PROCD=1
+
+NAME=dropbear
+PROG=/usr/sbin/dropbear
+PIDCOUNT=0
+EXTRA_COMMANDS="killclients"
+EXTRA_HELP=" killclients Kill ${NAME} processes except servers and yourself"
+
+dropbear_instance()
+{
+ append_ports()
+ {
+ local ifname="$1"
+ local port="$2"
+
+ grep -qs "^ *$ifname:" /proc/net/dev || {
+ procd_append_param command -p "$port"
+ return
+ }
+
+ for addr in $(
+ ifconfig "$ifname" | sed -ne '
+ /addr: *fe[89ab][0-9a-f]:/d
+ s/.* addr: *\([0-9a-f:\.]*\).*/\1/p
+ '
+ ); do
+ procd_append_param command -p "$addr:$port"
+ done
+ }
+
+
+ local section="$1"
+
+ # check if section is enabled (default)
+ local enabled
+ config_get_bool enabled "${section}" enable 1
+ [ "${enabled}" -eq 0 ] && return 1
+
+ # increase pid file count to handle multiple instances correctly
+ PIDCOUNT="$(( ${PIDCOUNT} + 1))"
+
+ local pid_file="/var/run/${NAME}.${PIDCOUNT}.pid"
+
+ procd_open_instance
+ procd_set_param command "$PROG" -F -P "$pid_file"
+
+ # prepare parameters (initialise with pid file)
+ local val
+
+ # A) password authentication
+ config_get_bool val "${section}" PasswordAuth 1
+ [ "${val}" -eq 0 ] && procd_append_param command -s
+
+ # B) listen interface and port
+ local port
+ local interface
+ config_get interface "${section}" Interface
+ [ -n "$interface" ] && network_get_device interface "$interface"
+ config_get port "${section}" Port 22
+ append_ports "$interface" "$port"
+ # C) banner file
+ config_get val "${section}" BannerFile
+ [ -f "${val}" ] && procd_append_param command -b "${val}"
+ # D) gatewayports
+ config_get_bool val "${section}" GatewayPorts 0
+ [ "${val}" -eq 1 ] && procd_append_param command -a
+ # E) root password authentication
+ config_get_bool val "${section}" RootPasswordAuth 1
+ [ "${val}" -eq 0 ] && procd_append_param command -g
+ # F) root login
+ config_get_bool val "${section}" RootLogin 1
+ [ "${val}" -eq 0 ] && procd_append_param command -w
+ # G) host keys
+ config_get val "${section}" rsakeyfile
+ [ -f "${val}" ] && procd_append_param command -r "${val}"
+ config_get val "${section}" dsskeyfile
+ [ -f "${val}" ] && procd_append_param command -d "${val}"
+
+ procd_close_instance
+}
+
+keygen()
+{
+ for keytype in rsa dss; do
+ # check for keys
+ key=dropbear/dropbear_${keytype}_host_key
+ [ -f /tmp/$key -o -s /etc/$key ] || {
+ # generate missing keys
+ mkdir -p /tmp/dropbear
+ [ -x /usr/bin/dropbearkey ] && {
+ /usr/bin/dropbearkey -t $keytype -f /tmp/$key 2>&- >&- && exec /etc/rc.common "$initscript" start
+ } &
+ exit 0
+ }
+ done
+
+ lock /tmp/.switch2jffs
+ mkdir -p /etc/dropbear
+ mv /tmp/dropbear/dropbear_* /etc/dropbear/
+ lock -u /tmp/.switch2jffs
+ chown root /etc/dropbear
+ chmod 0700 /etc/dropbear
+}
+
+start_service()
+{
+ [ -s /etc/dropbear/dropbear_rsa_host_key -a \
+ -s /etc/dropbear/dropbear_dss_host_key ] || keygen
+
+ . /lib/functions.sh
+ . /lib/functions/network.sh
+
+ config_load "${NAME}"
+ config_foreach dropbear_instance dropbear
+}
+
+killclients()
+{
+ local ignore=''
+ local server
+ local pid
+
+ # if this script is run from inside a client session, then ignore that session
+ pid="$$"
+ while [ "${pid}" -ne 0 ]
+ do
+ # get parent process id
+ pid=`cut -d ' ' -f 4 "/proc/${pid}/stat"`
+ [ "${pid}" -eq 0 ] && break
+
+ # check if client connection
+ grep -F -q -e "${PROG}" "/proc/${pid}/cmdline" && {
+ append ignore "${pid}"
+ break
+ }
+ done
+
+ # get all server pids that should be ignored
+ for server in `cat /var/run/${NAME}.*.pid`
+ do
+ append ignore "${server}"
+ done
+
+ # get all running pids and kill client connections
+ local skip
+ for pid in `pidof "${NAME}"`
+ do
+ # check if correct program, otherwise process next pid
+ grep -F -q -e "${PROG}" "/proc/${pid}/cmdline" || {
+ continue
+ }
+
+ # check if pid should be ignored (servers, ourself)
+ skip=0
+ for server in ${ignore}
+ do
+ if [ "${pid}" == "${server}" ]
+ then
+ skip=1
+ break
+ fi
+ done
+ [ "${skip}" -ne 0 ] && continue
+
+ # kill process
+ echo "${initscript}: Killing ${pid}..."
+ kill -KILL ${pid}
+ done
+}
diff --git a/package/network/services/dropbear/patches/.svn/entries b/package/network/services/dropbear/patches/.svn/entries
new file mode 100644
index 0000000..4ed7e24
--- /dev/null
+++ b/package/network/services/dropbear/patches/.svn/entries
@@ -0,0 +1,334 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/services/dropbear/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-12-04T16:40:17.503431Z
+34496
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+150-dbconvert_standalone.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+490bc116a67cb88d34a52e7c001d0d5b
+2010-03-26T14:28:14.286264Z
+20460
+juhosg
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+428
+
+110-change_user.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+548064938765048619a9b2dc51e528f2
+2012-12-04T16:40:17.503431Z
+34496
+florian
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+650
+
+130-ssh_ignore_o_and_x_args.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+d2d006c283731c07f60a744fec073059
+2011-03-02T14:20:51.200331Z
+25830
+kaloz
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+436
+
+140-disable_assert.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+b3f0c44716e9012c0ee2dcdb77398cb2
+2012-12-04T16:40:17.503431Z
+34496
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+492
+
+100-pubkey_path.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+2801ed1078c9b1e4cc3125dc59d46b80
+2010-03-26T14:28:14.286264Z
+20460
+juhosg
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2688
+
+120-openwrt_options.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+509184b0f5878fe1126e47181606aec8
+2012-12-04T16:40:17.503431Z
+34496
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2625
+
+500-set-default-path.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+4af5dda35dadf543cc6eac9e13900c83
+2012-07-05T16:44:05.821154Z
+32620
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+381
+
+200-lcrypt_bsdfix.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+247abfb50081f54104be13a60c8bf83d
+2011-11-27T05:30:40.263917Z
+29340
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1001
+
+300-ipv6_addr_port_split.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+adb6edd1738c0e03f247ab1d08feda24
+2011-07-31T12:05:54.493748Z
+27843
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+425
+
diff --git a/package/network/services/dropbear/patches/.svn/prop-base/100-pubkey_path.patch.svn-base b/package/network/services/dropbear/patches/.svn/prop-base/100-pubkey_path.patch.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/network/services/dropbear/patches/.svn/prop-base/100-pubkey_path.patch.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/services/dropbear/patches/.svn/prop-base/110-change_user.patch.svn-base b/package/network/services/dropbear/patches/.svn/prop-base/110-change_user.patch.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/network/services/dropbear/patches/.svn/prop-base/110-change_user.patch.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/services/dropbear/patches/.svn/prop-base/130-ssh_ignore_o_and_x_args.patch.svn-base b/package/network/services/dropbear/patches/.svn/prop-base/130-ssh_ignore_o_and_x_args.patch.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/network/services/dropbear/patches/.svn/prop-base/130-ssh_ignore_o_and_x_args.patch.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/services/dropbear/patches/.svn/prop-base/150-dbconvert_standalone.patch.svn-base b/package/network/services/dropbear/patches/.svn/prop-base/150-dbconvert_standalone.patch.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/network/services/dropbear/patches/.svn/prop-base/150-dbconvert_standalone.patch.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/services/dropbear/patches/.svn/text-base/100-pubkey_path.patch.svn-base b/package/network/services/dropbear/patches/.svn/text-base/100-pubkey_path.patch.svn-base
new file mode 100644
index 0000000..c1802f5
--- /dev/null
+++ b/package/network/services/dropbear/patches/.svn/text-base/100-pubkey_path.patch.svn-base
@@ -0,0 +1,91 @@
+--- a/svr-authpubkey.c
++++ b/svr-authpubkey.c
+@@ -209,17 +209,21 @@ static int checkpubkey(unsigned char* al
+ goto out;
+ }
+
+- /* we don't need to check pw and pw_dir for validity, since
+- * its been done in checkpubkeyperms. */
+- len = strlen(ses.authstate.pw_dir);
+- /* allocate max required pathname storage,
+- * = path + "/.ssh/authorized_keys" + '\0' = pathlen + 22 */
+- filename = m_malloc(len + 22);
+- snprintf(filename, len + 22, "%s/.ssh/authorized_keys",
+- ses.authstate.pw_dir);
+-
+- /* open the file */
+- authfile = fopen(filename, "r");
++ if (ses.authstate.pw_uid != 0) {
++ /* we don't need to check pw and pw_dir for validity, since
++ * its been done in checkpubkeyperms. */
++ len = strlen(ses.authstate.pw_dir);
++ /* allocate max required pathname storage,
++ * = path + "/.ssh/authorized_keys" + '\0' = pathlen + 22 */
++ filename = m_malloc(len + 22);
++ snprintf(filename, len + 22, "%s/.ssh/authorized_keys",
++ ses.authstate.pw_dir);
++
++ /* open the file */
++ authfile = fopen(filename, "r");
++ } else {
++ authfile = fopen("/etc/dropbear/authorized_keys","r");
++ }
+ if (authfile == NULL) {
+ goto out;
+ }
+@@ -372,26 +376,35 @@ static int checkpubkeyperms() {
+ goto out;
+ }
+
+- /* allocate max required pathname storage,
+- * = path + "/.ssh/authorized_keys" + '\0' = pathlen + 22 */
+- filename = m_malloc(len + 22);
+- strncpy(filename, ses.authstate.pw_dir, len+1);
+-
+- /* check ~ */
+- if (checkfileperm(filename) != DROPBEAR_SUCCESS) {
+- goto out;
+- }
+-
+- /* check ~/.ssh */
+- strncat(filename, "/.ssh", 5); /* strlen("/.ssh") == 5 */
+- if (checkfileperm(filename) != DROPBEAR_SUCCESS) {
+- goto out;
+- }
+-
+- /* now check ~/.ssh/authorized_keys */
+- strncat(filename, "/authorized_keys", 16);
+- if (checkfileperm(filename) != DROPBEAR_SUCCESS) {
+- goto out;
++ if (ses.authstate.pw_uid == 0) {
++ if (checkfileperm("/etc/dropbear") != DROPBEAR_SUCCESS) {
++ goto out;
++ }
++ if (checkfileperm("/etc/dropbear/authorized_keys") != DROPBEAR_SUCCESS) {
++ goto out;
++ }
++ } else {
++ /* allocate max required pathname storage,
++ * = path + "/.ssh/authorized_keys" + '\0' = pathlen + 22 */
++ filename = m_malloc(len + 22);
++ strncpy(filename, ses.authstate.pw_dir, len+1);
++
++ /* check ~ */
++ if (checkfileperm(filename) != DROPBEAR_SUCCESS) {
++ goto out;
++ }
++
++ /* check ~/.ssh */
++ strncat(filename, "/.ssh", 5); /* strlen("/.ssh") == 5 */
++ if (checkfileperm(filename) != DROPBEAR_SUCCESS) {
++ goto out;
++ }
++
++ /* now check ~/.ssh/authorized_keys */
++ strncat(filename, "/authorized_keys", 16);
++ if (checkfileperm(filename) != DROPBEAR_SUCCESS) {
++ goto out;
++ }
+ }
+
+ /* file looks ok, return success */
diff --git a/package/network/services/dropbear/patches/.svn/text-base/110-change_user.patch.svn-base b/package/network/services/dropbear/patches/.svn/text-base/110-change_user.patch.svn-base
new file mode 100644
index 0000000..a354eda
--- /dev/null
+++ b/package/network/services/dropbear/patches/.svn/text-base/110-change_user.patch.svn-base
@@ -0,0 +1,18 @@
+--- a/svr-chansession.c
++++ b/svr-chansession.c
+@@ -891,12 +891,12 @@ static void execchild(void *user_data) {
+ /* We can only change uid/gid as root ... */
+ if (getuid() == 0) {
+
+- if ((setgid(ses.authstate.pw_gid) < 0) ||
++ if ((ses.authstate.pw_gid != 0) && ((setgid(ses.authstate.pw_gid) < 0) ||
+ (initgroups(ses.authstate.pw_name,
+- ses.authstate.pw_gid) < 0)) {
++ ses.authstate.pw_gid) < 0))) {
+ dropbear_exit("Error changing user group");
+ }
+- if (setuid(ses.authstate.pw_uid) < 0) {
++ if ((ses.authstate.pw_uid != 0) && (setuid(ses.authstate.pw_uid) < 0)) {
+ dropbear_exit("Error changing user");
+ }
+ } else {
diff --git a/package/network/services/dropbear/patches/.svn/text-base/120-openwrt_options.patch.svn-base b/package/network/services/dropbear/patches/.svn/text-base/120-openwrt_options.patch.svn-base
new file mode 100644
index 0000000..977f631
--- /dev/null
+++ b/package/network/services/dropbear/patches/.svn/text-base/120-openwrt_options.patch.svn-base
@@ -0,0 +1,72 @@
+--- a/options.h
++++ b/options.h
+@@ -38,7 +38,7 @@
+ * Both of these flags can be defined at once, don't compile without at least
+ * one of them. */
+ #define NON_INETD_MODE
+-#define INETD_MODE
++/*#define INETD_MODE*/
+
+ /* Setting this disables the fast exptmod bignum code. It saves ~5kB, but is
+ * perhaps 20% slower for pubkey operations (it is probably worth experimenting
+@@ -49,7 +49,7 @@
+ several kB in binary size however will make the symmetrical ciphers and hashes
+ slower, perhaps by 50%. Recommended for small systems that aren't doing
+ much traffic. */
+-/*#define DROPBEAR_SMALL_CODE*/
++#define DROPBEAR_SMALL_CODE
+
+ /* Enable X11 Forwarding - server only */
+ #define ENABLE_X11FWD
+@@ -78,7 +78,7 @@ much traffic. */
+
+ /* Enable "Netcat mode" option. This will forward standard input/output
+ * to a remote TCP-forwarded connection */
+-#define ENABLE_CLI_NETCAT
++/*#define ENABLE_CLI_NETCAT*/
+
+ /* Encryption - at least one required.
+ * Protocol RFC requires 3DES and recommends AES128 for interoperability.
+@@ -89,8 +89,8 @@ much traffic. */
+ #define DROPBEAR_AES256
+ /* Compiling in Blowfish will add ~6kB to runtime heap memory usage */
+ /*#define DROPBEAR_BLOWFISH*/
+-#define DROPBEAR_TWOFISH256
+-#define DROPBEAR_TWOFISH128
++/*#define DROPBEAR_TWOFISH256
++#define DROPBEAR_TWOFISH128*/
+
+ /* Enable "Counter Mode" for ciphers. This is more secure than normal
+ * CBC mode against certain attacks. This adds around 1kB to binary
+@@ -110,7 +110,7 @@ much traffic. */
+ * If you disable MD5, Dropbear will fall back to SHA1 fingerprints,
+ * which are not the standard form. */
+ #define DROPBEAR_SHA1_HMAC
+-#define DROPBEAR_SHA1_96_HMAC
++/*#define DROPBEAR_SHA1_96_HMAC*/
+ #define DROPBEAR_MD5_HMAC
+
+ /* Hostkey/public key algorithms - at least one required, these are used
+@@ -144,11 +144,11 @@ much traffic. */
+ #endif
+
+ /* Whether to do reverse DNS lookups. */
+-#define DO_HOST_LOOKUP
++/*#define DO_HOST_LOOKUP*/
+
+ /* Whether to print the message of the day (MOTD). This doesn't add much code
+ * size */
+-#define DO_MOTD
++/*#define DO_MOTD*/
+
+ /* The MOTD file path */
+ #ifndef MOTD_FILENAME
+@@ -192,7 +192,7 @@ much traffic. */
+ * note that it will be provided for all "hidden" client-interactive
+ * style prompts - if you want something more sophisticated, use
+ * SSH_ASKPASS instead. Comment out this var to remove this functionality.*/
+-#define DROPBEAR_PASSWORD_ENV "DROPBEAR_PASSWORD"
++/*#define DROPBEAR_PASSWORD_ENV "DROPBEAR_PASSWORD"*/
+
+ /* Define this (as well as ENABLE_CLI_PASSWORD_AUTH) to allow the use of
+ * a helper program for the ssh client. The helper program should be
diff --git a/package/network/services/dropbear/patches/.svn/text-base/130-ssh_ignore_o_and_x_args.patch.svn-base b/package/network/services/dropbear/patches/.svn/text-base/130-ssh_ignore_o_and_x_args.patch.svn-base
new file mode 100644
index 0000000..93647a9
--- /dev/null
+++ b/package/network/services/dropbear/patches/.svn/text-base/130-ssh_ignore_o_and_x_args.patch.svn-base
@@ -0,0 +1,21 @@
+--- a/cli-runopts.c
++++ b/cli-runopts.c
+@@ -287,6 +287,10 @@ void cli_getopts(int argc, char ** argv)
+ debug_trace = 1;
+ break;
+ #endif
++ case 'o':
++ next = &dummy;
++ case 'x':
++ break;
+ case 'F':
+ case 'e':
+ case 'c':
+@@ -298,7 +302,6 @@ void cli_getopts(int argc, char ** argv)
+ #ifndef ENABLE_CLI_LOCALTCPFWD
+ case 'L':
+ #endif
+- case 'o':
+ case 'b':
+ next = &dummy;
+ default:
diff --git a/package/network/services/dropbear/patches/.svn/text-base/140-disable_assert.patch.svn-base b/package/network/services/dropbear/patches/.svn/text-base/140-disable_assert.patch.svn-base
new file mode 100644
index 0000000..e00184a
--- /dev/null
+++ b/package/network/services/dropbear/patches/.svn/text-base/140-disable_assert.patch.svn-base
@@ -0,0 +1,14 @@
+--- a/dbutil.h
++++ b/dbutil.h
+@@ -93,6 +93,10 @@ int m_str_to_uint(const char* str, unsig
+ #define DEF_MP_INT(X) mp_int X = {0, 0, 0, NULL}
+
+ /* Dropbear assertion */
+-#define dropbear_assert(X) do { if (!(X)) { fail_assert(#X, __FILE__, __LINE__); } } while (0)
++#ifndef DROPBEAR_ASSERT_ENABLED
++#define DROPBEAR_ASSERT_ENABLED 0
++#endif
++
++#define dropbear_assert(X) do { if (DROPBEAR_ASSERT_ENABLED && !(X)) { fail_assert(#X, __FILE__, __LINE__); } } while (0)
+
+ #endif /* _DBUTIL_H_ */
diff --git a/package/network/services/dropbear/patches/.svn/text-base/150-dbconvert_standalone.patch.svn-base b/package/network/services/dropbear/patches/.svn/text-base/150-dbconvert_standalone.patch.svn-base
new file mode 100644
index 0000000..3e0b008
--- /dev/null
+++ b/package/network/services/dropbear/patches/.svn/text-base/150-dbconvert_standalone.patch.svn-base
@@ -0,0 +1,14 @@
+--- a/options.h
++++ b/options.h
+@@ -5,6 +5,11 @@
+ #ifndef _OPTIONS_H_
+ #define _OPTIONS_H_
+
++#if !defined(DROPBEAR_CLIENT) && !defined(DROPBEAR_SERVER)
++#define DROPBEAR_SERVER
++#define DROPBEAR_CLIENT
++#endif
++
+ /******************************************************************
+ * Define compile-time options below - the "#ifndef DROPBEAR_XXX .... #endif"
+ * parts are to allow for commandline -DDROPBEAR_XXX options etc.
diff --git a/package/network/services/dropbear/patches/.svn/text-base/200-lcrypt_bsdfix.patch.svn-base b/package/network/services/dropbear/patches/.svn/text-base/200-lcrypt_bsdfix.patch.svn-base
new file mode 100644
index 0000000..57eb967
--- /dev/null
+++ b/package/network/services/dropbear/patches/.svn/text-base/200-lcrypt_bsdfix.patch.svn-base
@@ -0,0 +1,29 @@
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -56,7 +56,7 @@ HEADERS=options.h dbutil.h session.h pac
+ loginrec.h atomicio.h x11fwd.h agentfwd.h tcpfwd.h compat.h \
+ listener.h fake-rfc2553.h
+
+-dropbearobjs=$(COMMONOBJS) $(CLISVROBJS) $(SVROBJS) @CRYPTLIB@
++dropbearobjs=$(COMMONOBJS) $(CLISVROBJS) $(SVROBJS)
+ dbclientobjs=$(COMMONOBJS) $(CLISVROBJS) $(CLIOBJS)
+ dropbearkeyobjs=$(COMMONOBJS) $(KEYOBJS)
+ dropbearconvertobjs=$(COMMONOBJS) $(CONVERTOBJS)
+@@ -77,7 +77,7 @@ STRIP=@STRIP@
+ INSTALL=@INSTALL@
+ CPPFLAGS=@CPPFLAGS@
+ CFLAGS+=-I. -I$(srcdir) $(CPPFLAGS) @CFLAGS@
+-LIBS+=@LIBS@
++LIBS+=@CRYPTLIB@ @LIBS@
+ LDFLAGS=@LDFLAGS@
+
+ EXEEXT=@EXEEXT@
+@@ -169,7 +169,7 @@ scp: $(SCPOBJS) $(HEADERS) Makefile
+ # multi-binary compilation.
+ MULTIOBJS=
+ ifeq ($(MULTI),1)
+- MULTIOBJS=dbmulti.o $(sort $(foreach prog, $(PROGRAMS), $($(prog)objs))) @CRYPTLIB@
++ MULTIOBJS=dbmulti.o $(sort $(foreach prog, $(PROGRAMS), $($(prog)objs)))
+ CFLAGS+=$(addprefix -DDBMULTI_, $(PROGRAMS)) -DDROPBEAR_MULTI
+ endif
+
diff --git a/package/network/services/dropbear/patches/.svn/text-base/300-ipv6_addr_port_split.patch.svn-base b/package/network/services/dropbear/patches/.svn/text-base/300-ipv6_addr_port_split.patch.svn-base
new file mode 100644
index 0000000..7da435a
--- /dev/null
+++ b/package/network/services/dropbear/patches/.svn/text-base/300-ipv6_addr_port_split.patch.svn-base
@@ -0,0 +1,11 @@
+--- a/svr-runopts.c
++++ b/svr-runopts.c
+@@ -325,7 +325,7 @@ static void addportandaddress(char* spec
+ myspec = m_strdup(spec);
+
+ /* search for ':', that separates address and port */
+- svr_opts.ports[svr_opts.portcount] = strchr(myspec, ':');
++ svr_opts.ports[svr_opts.portcount] = strrchr(myspec, ':');
+
+ if (svr_opts.ports[svr_opts.portcount] == NULL) {
+ /* no ':' -> the whole string specifies just a port */
diff --git a/package/network/services/dropbear/patches/.svn/text-base/500-set-default-path.patch.svn-base b/package/network/services/dropbear/patches/.svn/text-base/500-set-default-path.patch.svn-base
new file mode 100644
index 0000000..0bd3ffc
--- /dev/null
+++ b/package/network/services/dropbear/patches/.svn/text-base/500-set-default-path.patch.svn-base
@@ -0,0 +1,11 @@
+--- a/options.h
++++ b/options.h
+@@ -297,7 +297,7 @@ be overridden at runtime with -I. 0 disa
+ #define DEFAULT_IDLE_TIMEOUT 0
+
+ /* The default path. This will often get replaced by the shell */
+-#define DEFAULT_PATH "/usr/bin:/bin"
++#define DEFAULT_PATH "/bin:/sbin:/usr/bin:/usr/sbin"
+
+ /* Some other defines (that mostly should be left alone) are defined
+ * in sysoptions.h */
diff --git a/package/network/services/dropbear/patches/100-pubkey_path.patch b/package/network/services/dropbear/patches/100-pubkey_path.patch
new file mode 100644
index 0000000..c1802f5
--- /dev/null
+++ b/package/network/services/dropbear/patches/100-pubkey_path.patch
@@ -0,0 +1,91 @@
+--- a/svr-authpubkey.c
++++ b/svr-authpubkey.c
+@@ -209,17 +209,21 @@ static int checkpubkey(unsigned char* al
+ goto out;
+ }
+
+- /* we don't need to check pw and pw_dir for validity, since
+- * its been done in checkpubkeyperms. */
+- len = strlen(ses.authstate.pw_dir);
+- /* allocate max required pathname storage,
+- * = path + "/.ssh/authorized_keys" + '\0' = pathlen + 22 */
+- filename = m_malloc(len + 22);
+- snprintf(filename, len + 22, "%s/.ssh/authorized_keys",
+- ses.authstate.pw_dir);
+-
+- /* open the file */
+- authfile = fopen(filename, "r");
++ if (ses.authstate.pw_uid != 0) {
++ /* we don't need to check pw and pw_dir for validity, since
++ * its been done in checkpubkeyperms. */
++ len = strlen(ses.authstate.pw_dir);
++ /* allocate max required pathname storage,
++ * = path + "/.ssh/authorized_keys" + '\0' = pathlen + 22 */
++ filename = m_malloc(len + 22);
++ snprintf(filename, len + 22, "%s/.ssh/authorized_keys",
++ ses.authstate.pw_dir);
++
++ /* open the file */
++ authfile = fopen(filename, "r");
++ } else {
++ authfile = fopen("/etc/dropbear/authorized_keys","r");
++ }
+ if (authfile == NULL) {
+ goto out;
+ }
+@@ -372,26 +376,35 @@ static int checkpubkeyperms() {
+ goto out;
+ }
+
+- /* allocate max required pathname storage,
+- * = path + "/.ssh/authorized_keys" + '\0' = pathlen + 22 */
+- filename = m_malloc(len + 22);
+- strncpy(filename, ses.authstate.pw_dir, len+1);
+-
+- /* check ~ */
+- if (checkfileperm(filename) != DROPBEAR_SUCCESS) {
+- goto out;
+- }
+-
+- /* check ~/.ssh */
+- strncat(filename, "/.ssh", 5); /* strlen("/.ssh") == 5 */
+- if (checkfileperm(filename) != DROPBEAR_SUCCESS) {
+- goto out;
+- }
+-
+- /* now check ~/.ssh/authorized_keys */
+- strncat(filename, "/authorized_keys", 16);
+- if (checkfileperm(filename) != DROPBEAR_SUCCESS) {
+- goto out;
++ if (ses.authstate.pw_uid == 0) {
++ if (checkfileperm("/etc/dropbear") != DROPBEAR_SUCCESS) {
++ goto out;
++ }
++ if (checkfileperm("/etc/dropbear/authorized_keys") != DROPBEAR_SUCCESS) {
++ goto out;
++ }
++ } else {
++ /* allocate max required pathname storage,
++ * = path + "/.ssh/authorized_keys" + '\0' = pathlen + 22 */
++ filename = m_malloc(len + 22);
++ strncpy(filename, ses.authstate.pw_dir, len+1);
++
++ /* check ~ */
++ if (checkfileperm(filename) != DROPBEAR_SUCCESS) {
++ goto out;
++ }
++
++ /* check ~/.ssh */
++ strncat(filename, "/.ssh", 5); /* strlen("/.ssh") == 5 */
++ if (checkfileperm(filename) != DROPBEAR_SUCCESS) {
++ goto out;
++ }
++
++ /* now check ~/.ssh/authorized_keys */
++ strncat(filename, "/authorized_keys", 16);
++ if (checkfileperm(filename) != DROPBEAR_SUCCESS) {
++ goto out;
++ }
+ }
+
+ /* file looks ok, return success */
diff --git a/package/network/services/dropbear/patches/110-change_user.patch b/package/network/services/dropbear/patches/110-change_user.patch
new file mode 100644
index 0000000..a354eda
--- /dev/null
+++ b/package/network/services/dropbear/patches/110-change_user.patch
@@ -0,0 +1,18 @@
+--- a/svr-chansession.c
++++ b/svr-chansession.c
+@@ -891,12 +891,12 @@ static void execchild(void *user_data) {
+ /* We can only change uid/gid as root ... */
+ if (getuid() == 0) {
+
+- if ((setgid(ses.authstate.pw_gid) < 0) ||
++ if ((ses.authstate.pw_gid != 0) && ((setgid(ses.authstate.pw_gid) < 0) ||
+ (initgroups(ses.authstate.pw_name,
+- ses.authstate.pw_gid) < 0)) {
++ ses.authstate.pw_gid) < 0))) {
+ dropbear_exit("Error changing user group");
+ }
+- if (setuid(ses.authstate.pw_uid) < 0) {
++ if ((ses.authstate.pw_uid != 0) && (setuid(ses.authstate.pw_uid) < 0)) {
+ dropbear_exit("Error changing user");
+ }
+ } else {
diff --git a/package/network/services/dropbear/patches/120-openwrt_options.patch b/package/network/services/dropbear/patches/120-openwrt_options.patch
new file mode 100644
index 0000000..977f631
--- /dev/null
+++ b/package/network/services/dropbear/patches/120-openwrt_options.patch
@@ -0,0 +1,72 @@
+--- a/options.h
++++ b/options.h
+@@ -38,7 +38,7 @@
+ * Both of these flags can be defined at once, don't compile without at least
+ * one of them. */
+ #define NON_INETD_MODE
+-#define INETD_MODE
++/*#define INETD_MODE*/
+
+ /* Setting this disables the fast exptmod bignum code. It saves ~5kB, but is
+ * perhaps 20% slower for pubkey operations (it is probably worth experimenting
+@@ -49,7 +49,7 @@
+ several kB in binary size however will make the symmetrical ciphers and hashes
+ slower, perhaps by 50%. Recommended for small systems that aren't doing
+ much traffic. */
+-/*#define DROPBEAR_SMALL_CODE*/
++#define DROPBEAR_SMALL_CODE
+
+ /* Enable X11 Forwarding - server only */
+ #define ENABLE_X11FWD
+@@ -78,7 +78,7 @@ much traffic. */
+
+ /* Enable "Netcat mode" option. This will forward standard input/output
+ * to a remote TCP-forwarded connection */
+-#define ENABLE_CLI_NETCAT
++/*#define ENABLE_CLI_NETCAT*/
+
+ /* Encryption - at least one required.
+ * Protocol RFC requires 3DES and recommends AES128 for interoperability.
+@@ -89,8 +89,8 @@ much traffic. */
+ #define DROPBEAR_AES256
+ /* Compiling in Blowfish will add ~6kB to runtime heap memory usage */
+ /*#define DROPBEAR_BLOWFISH*/
+-#define DROPBEAR_TWOFISH256
+-#define DROPBEAR_TWOFISH128
++/*#define DROPBEAR_TWOFISH256
++#define DROPBEAR_TWOFISH128*/
+
+ /* Enable "Counter Mode" for ciphers. This is more secure than normal
+ * CBC mode against certain attacks. This adds around 1kB to binary
+@@ -110,7 +110,7 @@ much traffic. */
+ * If you disable MD5, Dropbear will fall back to SHA1 fingerprints,
+ * which are not the standard form. */
+ #define DROPBEAR_SHA1_HMAC
+-#define DROPBEAR_SHA1_96_HMAC
++/*#define DROPBEAR_SHA1_96_HMAC*/
+ #define DROPBEAR_MD5_HMAC
+
+ /* Hostkey/public key algorithms - at least one required, these are used
+@@ -144,11 +144,11 @@ much traffic. */
+ #endif
+
+ /* Whether to do reverse DNS lookups. */
+-#define DO_HOST_LOOKUP
++/*#define DO_HOST_LOOKUP*/
+
+ /* Whether to print the message of the day (MOTD). This doesn't add much code
+ * size */
+-#define DO_MOTD
++/*#define DO_MOTD*/
+
+ /* The MOTD file path */
+ #ifndef MOTD_FILENAME
+@@ -192,7 +192,7 @@ much traffic. */
+ * note that it will be provided for all "hidden" client-interactive
+ * style prompts - if you want something more sophisticated, use
+ * SSH_ASKPASS instead. Comment out this var to remove this functionality.*/
+-#define DROPBEAR_PASSWORD_ENV "DROPBEAR_PASSWORD"
++/*#define DROPBEAR_PASSWORD_ENV "DROPBEAR_PASSWORD"*/
+
+ /* Define this (as well as ENABLE_CLI_PASSWORD_AUTH) to allow the use of
+ * a helper program for the ssh client. The helper program should be
diff --git a/package/network/services/dropbear/patches/130-ssh_ignore_o_and_x_args.patch b/package/network/services/dropbear/patches/130-ssh_ignore_o_and_x_args.patch
new file mode 100644
index 0000000..93647a9
--- /dev/null
+++ b/package/network/services/dropbear/patches/130-ssh_ignore_o_and_x_args.patch
@@ -0,0 +1,21 @@
+--- a/cli-runopts.c
++++ b/cli-runopts.c
+@@ -287,6 +287,10 @@ void cli_getopts(int argc, char ** argv)
+ debug_trace = 1;
+ break;
+ #endif
++ case 'o':
++ next = &dummy;
++ case 'x':
++ break;
+ case 'F':
+ case 'e':
+ case 'c':
+@@ -298,7 +302,6 @@ void cli_getopts(int argc, char ** argv)
+ #ifndef ENABLE_CLI_LOCALTCPFWD
+ case 'L':
+ #endif
+- case 'o':
+ case 'b':
+ next = &dummy;
+ default:
diff --git a/package/network/services/dropbear/patches/140-disable_assert.patch b/package/network/services/dropbear/patches/140-disable_assert.patch
new file mode 100644
index 0000000..e00184a
--- /dev/null
+++ b/package/network/services/dropbear/patches/140-disable_assert.patch
@@ -0,0 +1,14 @@
+--- a/dbutil.h
++++ b/dbutil.h
+@@ -93,6 +93,10 @@ int m_str_to_uint(const char* str, unsig
+ #define DEF_MP_INT(X) mp_int X = {0, 0, 0, NULL}
+
+ /* Dropbear assertion */
+-#define dropbear_assert(X) do { if (!(X)) { fail_assert(#X, __FILE__, __LINE__); } } while (0)
++#ifndef DROPBEAR_ASSERT_ENABLED
++#define DROPBEAR_ASSERT_ENABLED 0
++#endif
++
++#define dropbear_assert(X) do { if (DROPBEAR_ASSERT_ENABLED && !(X)) { fail_assert(#X, __FILE__, __LINE__); } } while (0)
+
+ #endif /* _DBUTIL_H_ */
diff --git a/package/network/services/dropbear/patches/150-dbconvert_standalone.patch b/package/network/services/dropbear/patches/150-dbconvert_standalone.patch
new file mode 100644
index 0000000..3e0b008
--- /dev/null
+++ b/package/network/services/dropbear/patches/150-dbconvert_standalone.patch
@@ -0,0 +1,14 @@
+--- a/options.h
++++ b/options.h
+@@ -5,6 +5,11 @@
+ #ifndef _OPTIONS_H_
+ #define _OPTIONS_H_
+
++#if !defined(DROPBEAR_CLIENT) && !defined(DROPBEAR_SERVER)
++#define DROPBEAR_SERVER
++#define DROPBEAR_CLIENT
++#endif
++
+ /******************************************************************
+ * Define compile-time options below - the "#ifndef DROPBEAR_XXX .... #endif"
+ * parts are to allow for commandline -DDROPBEAR_XXX options etc.
diff --git a/package/network/services/dropbear/patches/200-lcrypt_bsdfix.patch b/package/network/services/dropbear/patches/200-lcrypt_bsdfix.patch
new file mode 100644
index 0000000..57eb967
--- /dev/null
+++ b/package/network/services/dropbear/patches/200-lcrypt_bsdfix.patch
@@ -0,0 +1,29 @@
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -56,7 +56,7 @@ HEADERS=options.h dbutil.h session.h pac
+ loginrec.h atomicio.h x11fwd.h agentfwd.h tcpfwd.h compat.h \
+ listener.h fake-rfc2553.h
+
+-dropbearobjs=$(COMMONOBJS) $(CLISVROBJS) $(SVROBJS) @CRYPTLIB@
++dropbearobjs=$(COMMONOBJS) $(CLISVROBJS) $(SVROBJS)
+ dbclientobjs=$(COMMONOBJS) $(CLISVROBJS) $(CLIOBJS)
+ dropbearkeyobjs=$(COMMONOBJS) $(KEYOBJS)
+ dropbearconvertobjs=$(COMMONOBJS) $(CONVERTOBJS)
+@@ -77,7 +77,7 @@ STRIP=@STRIP@
+ INSTALL=@INSTALL@
+ CPPFLAGS=@CPPFLAGS@
+ CFLAGS+=-I. -I$(srcdir) $(CPPFLAGS) @CFLAGS@
+-LIBS+=@LIBS@
++LIBS+=@CRYPTLIB@ @LIBS@
+ LDFLAGS=@LDFLAGS@
+
+ EXEEXT=@EXEEXT@
+@@ -169,7 +169,7 @@ scp: $(SCPOBJS) $(HEADERS) Makefile
+ # multi-binary compilation.
+ MULTIOBJS=
+ ifeq ($(MULTI),1)
+- MULTIOBJS=dbmulti.o $(sort $(foreach prog, $(PROGRAMS), $($(prog)objs))) @CRYPTLIB@
++ MULTIOBJS=dbmulti.o $(sort $(foreach prog, $(PROGRAMS), $($(prog)objs)))
+ CFLAGS+=$(addprefix -DDBMULTI_, $(PROGRAMS)) -DDROPBEAR_MULTI
+ endif
+
diff --git a/package/network/services/dropbear/patches/300-ipv6_addr_port_split.patch b/package/network/services/dropbear/patches/300-ipv6_addr_port_split.patch
new file mode 100644
index 0000000..7da435a
--- /dev/null
+++ b/package/network/services/dropbear/patches/300-ipv6_addr_port_split.patch
@@ -0,0 +1,11 @@
+--- a/svr-runopts.c
++++ b/svr-runopts.c
+@@ -325,7 +325,7 @@ static void addportandaddress(char* spec
+ myspec = m_strdup(spec);
+
+ /* search for ':', that separates address and port */
+- svr_opts.ports[svr_opts.portcount] = strchr(myspec, ':');
++ svr_opts.ports[svr_opts.portcount] = strrchr(myspec, ':');
+
+ if (svr_opts.ports[svr_opts.portcount] == NULL) {
+ /* no ':' -> the whole string specifies just a port */
diff --git a/package/network/services/dropbear/patches/500-set-default-path.patch b/package/network/services/dropbear/patches/500-set-default-path.patch
new file mode 100644
index 0000000..0bd3ffc
--- /dev/null
+++ b/package/network/services/dropbear/patches/500-set-default-path.patch
@@ -0,0 +1,11 @@
+--- a/options.h
++++ b/options.h
+@@ -297,7 +297,7 @@ be overridden at runtime with -I. 0 disa
+ #define DEFAULT_IDLE_TIMEOUT 0
+
+ /* The default path. This will often get replaced by the shell */
+-#define DEFAULT_PATH "/usr/bin:/bin"
++#define DEFAULT_PATH "/bin:/sbin:/usr/bin:/usr/sbin"
+
+ /* Some other defines (that mostly should be left alone) are defined
+ * in sysoptions.h */
diff --git a/package/network/services/ead/.svn/entries b/package/network/services/ead/.svn/entries
new file mode 100644
index 0000000..f06c373
--- /dev/null
+++ b/package/network/services/ead/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/services/ead
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-10T12:32:29.935169Z
+33688
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+src
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+b837a16d1633943a9f80d01908ba89c5
+2012-10-08T11:41:02.214093Z
+33660
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1266
+
diff --git a/package/network/services/ead/.svn/text-base/Makefile.svn-base b/package/network/services/ead/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..5633a31
--- /dev/null
+++ b/package/network/services/ead/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,57 @@
+#
+# Copyright (C) 2006-2008 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=ead
+PKG_RELEASE:=1
+
+PKG_BUILD_DEPENDS:=libpcap
+PKG_BUILD_DIR:=$(BUILD_DIR)/ead
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+define Package/ead
+ SECTION:=net
+ CATEGORY:=Base system
+ TITLE:=Emergency Access Daemon
+ URL:=http://bridge.sourceforge.net/
+endef
+
+define Package/ead/description
+ Provides remote access to your device even if IP and firewall
+ configuration settings are defunct
+endef
+
+CONFIGURE_PATH = tinysrp
+
+TARGET_CFLAGS += \
+ -I$(LINUX_DIR)/include \
+ -I$(PKG_BUILD_DIR) \
+ -I$(PKG_BUILD_DIR)/tinysrp \
+ $(TARGET_CPPFLAGS)
+
+MAKE_FLAGS += \
+ CONFIGURE_ARGS="$(CONFIGURE_ARGS)" \
+ LIBS_EADCLIENT="$(PKG_BUILD_DIR)/tinysrp/libtinysrp.a" \
+ LIBS_EAD="$(PKG_BUILD_DIR)/tinysrp/libtinysrp.a $(STAGING_DIR)/usr/lib/libpcap.a" \
+ CFLAGS="$(TARGET_CFLAGS)"
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+define Package/ead/install
+ $(INSTALL_DIR) $(1)/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/ead $(1)/sbin/
+endef
+
+$(eval $(call BuildPackage,ead))
diff --git a/package/network/services/ead/Makefile b/package/network/services/ead/Makefile
new file mode 100644
index 0000000..5633a31
--- /dev/null
+++ b/package/network/services/ead/Makefile
@@ -0,0 +1,57 @@
+#
+# Copyright (C) 2006-2008 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=ead
+PKG_RELEASE:=1
+
+PKG_BUILD_DEPENDS:=libpcap
+PKG_BUILD_DIR:=$(BUILD_DIR)/ead
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+define Package/ead
+ SECTION:=net
+ CATEGORY:=Base system
+ TITLE:=Emergency Access Daemon
+ URL:=http://bridge.sourceforge.net/
+endef
+
+define Package/ead/description
+ Provides remote access to your device even if IP and firewall
+ configuration settings are defunct
+endef
+
+CONFIGURE_PATH = tinysrp
+
+TARGET_CFLAGS += \
+ -I$(LINUX_DIR)/include \
+ -I$(PKG_BUILD_DIR) \
+ -I$(PKG_BUILD_DIR)/tinysrp \
+ $(TARGET_CPPFLAGS)
+
+MAKE_FLAGS += \
+ CONFIGURE_ARGS="$(CONFIGURE_ARGS)" \
+ LIBS_EADCLIENT="$(PKG_BUILD_DIR)/tinysrp/libtinysrp.a" \
+ LIBS_EAD="$(PKG_BUILD_DIR)/tinysrp/libtinysrp.a $(STAGING_DIR)/usr/lib/libpcap.a" \
+ CFLAGS="$(TARGET_CFLAGS)"
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+define Package/ead/install
+ $(INSTALL_DIR) $(1)/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/ead $(1)/sbin/
+endef
+
+$(eval $(call BuildPackage,ead))
diff --git a/package/network/services/ead/src/.svn/entries b/package/network/services/ead/src/.svn/entries
new file mode 100644
index 0000000..f5e80d9
--- /dev/null
+++ b/package/network/services/ead/src/.svn/entries
@@ -0,0 +1,609 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/services/ead/src
+svn://svn.openwrt.org/openwrt
+
+
+
+2010-12-13T01:47:35.463502Z
+24535
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+ead.h
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+4178e510a00b0221b965d4721dac00cc
+2009-01-06T22:19:55.682869Z
+13905
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2727
+
+pw_encrypt_md5.c
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+40f11fe30b3737626b67d1442c0e7ebc
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+18626
+
+ead-client.c
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+c1eb4795ace103b69ab8869a4f26e6c5
+2009-01-06T22:20:26.937999Z
+13907
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+9161
+
+libbridge_init.c
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+068735c68f81ce4c9600cd059deb9fc0
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4697
+
+pfc.c
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+6c5d38350951ce4b0f7d56b0538b4260
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1451
+
+aes.c
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+df9da0c42f6c941f96e9405ed5dadcec
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+48626
+
+ead-pcap.h
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+2f9f2754b24661be3941c9a6b9a3c2c5
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2259
+
+passwd
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+ce8eb11b8f6ddc6d284113f1346fe354
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+152
+
+list.h
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+12b1a3507429e23c084534c8009edbb8
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+17644
+
+libbridge_private.h
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+31ce9fa468f10671c7f6bb1ae785c5ec
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1064
+
+filter.c
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+3139f8fa0e1f3f89b63c32e66864d88c
+2009-01-04T01:24:00.718602Z
+13849
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1183
+
+tinysrp
+dir
+
+ead-crypt.c
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+5b92c434966be799b780e690d40ee116
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4146
+
+libbridge.h
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+b81e1e8d3a5c3893a6711565b5ee1811
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2299
+
+ead.c
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+e0263d978fde1eb38e89be729aea5b28
+2009-04-25T03:30:20.149967Z
+15400
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+20338
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+b8c8072b1ec7dcb183fa39a444553704
+2009-06-03T13:53:15.580813Z
+16309
+acinonyx
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+751
+
+sha1.c
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+0f9259ea021b03f9954a84566e718ea8
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2633
+
+ead-crypt.h
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+28298d88b4b7d6a6d6cb71e380832efa
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+724
+
diff --git a/package/network/services/ead/src/.svn/text-base/Makefile.svn-base b/package/network/services/ead/src/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..faef3b7
--- /dev/null
+++ b/package/network/services/ead/src/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,33 @@
+CC = gcc
+CPPFLAGS = -I. -Itinysrp
+CFLAGS = -Os -Wall
+LDFLAGS =
+LIBS_EADCLIENT = tinysrp/libtinysrp.a
+LIBS_EAD = tinysrp/libtinysrp.a -lpcap
+CONFIGURE_ARGS =
+
+all: ead ead-client
+
+obj = ead-crypt.o
+
+tinysrp/Makefile:
+ cd tinysrp; ./configure $(CONFIGURE_ARGS)
+
+tinysrp/libtinysrp.a: tinysrp/Makefile
+ -$(MAKE) -C tinysrp CFLAGS="$(CFLAGS)"
+
+%.o: %.c $(wildcard *.h) tinysrp/libtinysrp.a
+ $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
+
+ead.o: filter.c
+ead-crypt.o: aes.c sha1.c
+
+ead: ead.o $(obj) tinysrp/libtinysrp.a
+ $(CC) -o $@ $< $(obj) $(LDFLAGS) $(LIBS_EAD)
+
+ead-client: ead-client.o $(obj)
+ $(CC) -o $@ $< $(obj) $(LDFLAGS) $(LIBS_EADCLIENT)
+
+clean:
+ rm -f *.o ead ead-client
+ if [ -f tinysrp/Makefile ]; then $(MAKE) -C tinysrp distclean; fi
diff --git a/package/network/services/ead/src/.svn/text-base/aes.c.svn-base b/package/network/services/ead/src/.svn/text-base/aes.c.svn-base
new file mode 100644
index 0000000..6f9db34
--- /dev/null
+++ b/package/network/services/ead/src/.svn/text-base/aes.c.svn-base
@@ -0,0 +1,1061 @@
+/*
+ * AES (Rijndael) cipher
+ *
+ * Modifications to public domain implementation:
+ * - support only 128-bit keys
+ * - cleanup
+ * - use C pre-processor to make it easier to change S table access
+ * - added option (AES_SMALL_TABLES) for reducing code size by about 8 kB at
+ * cost of reduced throughput (quite small difference on Pentium 4,
+ * 10-25% when using -O1 or -O2 optimization)
+ *
+ * Copyright (c) 2003-2005, Jouni Malinen <j@w1.fi>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Alternatively, this software may be distributed under the terms of BSD
+ * license.
+ *
+ * See README and COPYING for more details.
+ */
+
+/*
+ * rijndael-alg-fst.c
+ *
+ * @version 3.0 (December 2000)
+ *
+ * Optimised ANSI C code for the Rijndael cipher (now AES)
+ *
+ * @author Vincent Rijmen <vincent.rijmen@esat.kuleuven.ac.be>
+ * @author Antoon Bosselaers <antoon.bosselaers@esat.kuleuven.ac.be>
+ * @author Paulo Barreto <paulo.barreto@terra.com.br>
+ *
+ * This code is hereby placed in the public domain.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* #define FULL_UNROLL */
+#define AES_SMALL_TABLES
+
+typedef uint8_t u8;
+typedef uint16_t u16;
+typedef uint32_t u32;
+
+/*
+Te0[x] = S [x].[02, 01, 01, 03];
+Te1[x] = S [x].[03, 02, 01, 01];
+Te2[x] = S [x].[01, 03, 02, 01];
+Te3[x] = S [x].[01, 01, 03, 02];
+Te4[x] = S [x].[01, 01, 01, 01];
+
+Td0[x] = Si[x].[0e, 09, 0d, 0b];
+Td1[x] = Si[x].[0b, 0e, 09, 0d];
+Td2[x] = Si[x].[0d, 0b, 0e, 09];
+Td3[x] = Si[x].[09, 0d, 0b, 0e];
+Td4[x] = Si[x].[01, 01, 01, 01];
+*/
+
+static const u32 Te0[256] = {
+ 0xc66363a5U, 0xf87c7c84U, 0xee777799U, 0xf67b7b8dU,
+ 0xfff2f20dU, 0xd66b6bbdU, 0xde6f6fb1U, 0x91c5c554U,
+ 0x60303050U, 0x02010103U, 0xce6767a9U, 0x562b2b7dU,
+ 0xe7fefe19U, 0xb5d7d762U, 0x4dababe6U, 0xec76769aU,
+ 0x8fcaca45U, 0x1f82829dU, 0x89c9c940U, 0xfa7d7d87U,
+ 0xeffafa15U, 0xb25959ebU, 0x8e4747c9U, 0xfbf0f00bU,
+ 0x41adadecU, 0xb3d4d467U, 0x5fa2a2fdU, 0x45afafeaU,
+ 0x239c9cbfU, 0x53a4a4f7U, 0xe4727296U, 0x9bc0c05bU,
+ 0x75b7b7c2U, 0xe1fdfd1cU, 0x3d9393aeU, 0x4c26266aU,
+ 0x6c36365aU, 0x7e3f3f41U, 0xf5f7f702U, 0x83cccc4fU,
+ 0x6834345cU, 0x51a5a5f4U, 0xd1e5e534U, 0xf9f1f108U,
+ 0xe2717193U, 0xabd8d873U, 0x62313153U, 0x2a15153fU,
+ 0x0804040cU, 0x95c7c752U, 0x46232365U, 0x9dc3c35eU,
+ 0x30181828U, 0x379696a1U, 0x0a05050fU, 0x2f9a9ab5U,
+ 0x0e070709U, 0x24121236U, 0x1b80809bU, 0xdfe2e23dU,
+ 0xcdebeb26U, 0x4e272769U, 0x7fb2b2cdU, 0xea75759fU,
+ 0x1209091bU, 0x1d83839eU, 0x582c2c74U, 0x341a1a2eU,
+ 0x361b1b2dU, 0xdc6e6eb2U, 0xb45a5aeeU, 0x5ba0a0fbU,
+ 0xa45252f6U, 0x763b3b4dU, 0xb7d6d661U, 0x7db3b3ceU,
+ 0x5229297bU, 0xdde3e33eU, 0x5e2f2f71U, 0x13848497U,
+ 0xa65353f5U, 0xb9d1d168U, 0x00000000U, 0xc1eded2cU,
+ 0x40202060U, 0xe3fcfc1fU, 0x79b1b1c8U, 0xb65b5bedU,
+ 0xd46a6abeU, 0x8dcbcb46U, 0x67bebed9U, 0x7239394bU,
+ 0x944a4adeU, 0x984c4cd4U, 0xb05858e8U, 0x85cfcf4aU,
+ 0xbbd0d06bU, 0xc5efef2aU, 0x4faaaae5U, 0xedfbfb16U,
+ 0x864343c5U, 0x9a4d4dd7U, 0x66333355U, 0x11858594U,
+ 0x8a4545cfU, 0xe9f9f910U, 0x04020206U, 0xfe7f7f81U,
+ 0xa05050f0U, 0x783c3c44U, 0x259f9fbaU, 0x4ba8a8e3U,
+ 0xa25151f3U, 0x5da3a3feU, 0x804040c0U, 0x058f8f8aU,
+ 0x3f9292adU, 0x219d9dbcU, 0x70383848U, 0xf1f5f504U,
+ 0x63bcbcdfU, 0x77b6b6c1U, 0xafdada75U, 0x42212163U,
+ 0x20101030U, 0xe5ffff1aU, 0xfdf3f30eU, 0xbfd2d26dU,
+ 0x81cdcd4cU, 0x180c0c14U, 0x26131335U, 0xc3ecec2fU,
+ 0xbe5f5fe1U, 0x359797a2U, 0x884444ccU, 0x2e171739U,
+ 0x93c4c457U, 0x55a7a7f2U, 0xfc7e7e82U, 0x7a3d3d47U,
+ 0xc86464acU, 0xba5d5de7U, 0x3219192bU, 0xe6737395U,
+ 0xc06060a0U, 0x19818198U, 0x9e4f4fd1U, 0xa3dcdc7fU,
+ 0x44222266U, 0x542a2a7eU, 0x3b9090abU, 0x0b888883U,
+ 0x8c4646caU, 0xc7eeee29U, 0x6bb8b8d3U, 0x2814143cU,
+ 0xa7dede79U, 0xbc5e5ee2U, 0x160b0b1dU, 0xaddbdb76U,
+ 0xdbe0e03bU, 0x64323256U, 0x743a3a4eU, 0x140a0a1eU,
+ 0x924949dbU, 0x0c06060aU, 0x4824246cU, 0xb85c5ce4U,
+ 0x9fc2c25dU, 0xbdd3d36eU, 0x43acacefU, 0xc46262a6U,
+ 0x399191a8U, 0x319595a4U, 0xd3e4e437U, 0xf279798bU,
+ 0xd5e7e732U, 0x8bc8c843U, 0x6e373759U, 0xda6d6db7U,
+ 0x018d8d8cU, 0xb1d5d564U, 0x9c4e4ed2U, 0x49a9a9e0U,
+ 0xd86c6cb4U, 0xac5656faU, 0xf3f4f407U, 0xcfeaea25U,
+ 0xca6565afU, 0xf47a7a8eU, 0x47aeaee9U, 0x10080818U,
+ 0x6fbabad5U, 0xf0787888U, 0x4a25256fU, 0x5c2e2e72U,
+ 0x381c1c24U, 0x57a6a6f1U, 0x73b4b4c7U, 0x97c6c651U,
+ 0xcbe8e823U, 0xa1dddd7cU, 0xe874749cU, 0x3e1f1f21U,
+ 0x964b4bddU, 0x61bdbddcU, 0x0d8b8b86U, 0x0f8a8a85U,
+ 0xe0707090U, 0x7c3e3e42U, 0x71b5b5c4U, 0xcc6666aaU,
+ 0x904848d8U, 0x06030305U, 0xf7f6f601U, 0x1c0e0e12U,
+ 0xc26161a3U, 0x6a35355fU, 0xae5757f9U, 0x69b9b9d0U,
+ 0x17868691U, 0x99c1c158U, 0x3a1d1d27U, 0x279e9eb9U,
+ 0xd9e1e138U, 0xebf8f813U, 0x2b9898b3U, 0x22111133U,
+ 0xd26969bbU, 0xa9d9d970U, 0x078e8e89U, 0x339494a7U,
+ 0x2d9b9bb6U, 0x3c1e1e22U, 0x15878792U, 0xc9e9e920U,
+ 0x87cece49U, 0xaa5555ffU, 0x50282878U, 0xa5dfdf7aU,
+ 0x038c8c8fU, 0x59a1a1f8U, 0x09898980U, 0x1a0d0d17U,
+ 0x65bfbfdaU, 0xd7e6e631U, 0x844242c6U, 0xd06868b8U,
+ 0x824141c3U, 0x299999b0U, 0x5a2d2d77U, 0x1e0f0f11U,
+ 0x7bb0b0cbU, 0xa85454fcU, 0x6dbbbbd6U, 0x2c16163aU,
+};
+#ifndef AES_SMALL_TABLES
+static const u32 Te1[256] = {
+ 0xa5c66363U, 0x84f87c7cU, 0x99ee7777U, 0x8df67b7bU,
+ 0x0dfff2f2U, 0xbdd66b6bU, 0xb1de6f6fU, 0x5491c5c5U,
+ 0x50603030U, 0x03020101U, 0xa9ce6767U, 0x7d562b2bU,
+ 0x19e7fefeU, 0x62b5d7d7U, 0xe64dababU, 0x9aec7676U,
+ 0x458fcacaU, 0x9d1f8282U, 0x4089c9c9U, 0x87fa7d7dU,
+ 0x15effafaU, 0xebb25959U, 0xc98e4747U, 0x0bfbf0f0U,
+ 0xec41adadU, 0x67b3d4d4U, 0xfd5fa2a2U, 0xea45afafU,
+ 0xbf239c9cU, 0xf753a4a4U, 0x96e47272U, 0x5b9bc0c0U,
+ 0xc275b7b7U, 0x1ce1fdfdU, 0xae3d9393U, 0x6a4c2626U,
+ 0x5a6c3636U, 0x417e3f3fU, 0x02f5f7f7U, 0x4f83ccccU,
+ 0x5c683434U, 0xf451a5a5U, 0x34d1e5e5U, 0x08f9f1f1U,
+ 0x93e27171U, 0x73abd8d8U, 0x53623131U, 0x3f2a1515U,
+ 0x0c080404U, 0x5295c7c7U, 0x65462323U, 0x5e9dc3c3U,
+ 0x28301818U, 0xa1379696U, 0x0f0a0505U, 0xb52f9a9aU,
+ 0x090e0707U, 0x36241212U, 0x9b1b8080U, 0x3ddfe2e2U,
+ 0x26cdebebU, 0x694e2727U, 0xcd7fb2b2U, 0x9fea7575U,
+ 0x1b120909U, 0x9e1d8383U, 0x74582c2cU, 0x2e341a1aU,
+ 0x2d361b1bU, 0xb2dc6e6eU, 0xeeb45a5aU, 0xfb5ba0a0U,
+ 0xf6a45252U, 0x4d763b3bU, 0x61b7d6d6U, 0xce7db3b3U,
+ 0x7b522929U, 0x3edde3e3U, 0x715e2f2fU, 0x97138484U,
+ 0xf5a65353U, 0x68b9d1d1U, 0x00000000U, 0x2cc1ededU,
+ 0x60402020U, 0x1fe3fcfcU, 0xc879b1b1U, 0xedb65b5bU,
+ 0xbed46a6aU, 0x468dcbcbU, 0xd967bebeU, 0x4b723939U,
+ 0xde944a4aU, 0xd4984c4cU, 0xe8b05858U, 0x4a85cfcfU,
+ 0x6bbbd0d0U, 0x2ac5efefU, 0xe54faaaaU, 0x16edfbfbU,
+ 0xc5864343U, 0xd79a4d4dU, 0x55663333U, 0x94118585U,
+ 0xcf8a4545U, 0x10e9f9f9U, 0x06040202U, 0x81fe7f7fU,
+ 0xf0a05050U, 0x44783c3cU, 0xba259f9fU, 0xe34ba8a8U,
+ 0xf3a25151U, 0xfe5da3a3U, 0xc0804040U, 0x8a058f8fU,
+ 0xad3f9292U, 0xbc219d9dU, 0x48703838U, 0x04f1f5f5U,
+ 0xdf63bcbcU, 0xc177b6b6U, 0x75afdadaU, 0x63422121U,
+ 0x30201010U, 0x1ae5ffffU, 0x0efdf3f3U, 0x6dbfd2d2U,
+ 0x4c81cdcdU, 0x14180c0cU, 0x35261313U, 0x2fc3ececU,
+ 0xe1be5f5fU, 0xa2359797U, 0xcc884444U, 0x392e1717U,
+ 0x5793c4c4U, 0xf255a7a7U, 0x82fc7e7eU, 0x477a3d3dU,
+ 0xacc86464U, 0xe7ba5d5dU, 0x2b321919U, 0x95e67373U,
+ 0xa0c06060U, 0x98198181U, 0xd19e4f4fU, 0x7fa3dcdcU,
+ 0x66442222U, 0x7e542a2aU, 0xab3b9090U, 0x830b8888U,
+ 0xca8c4646U, 0x29c7eeeeU, 0xd36bb8b8U, 0x3c281414U,
+ 0x79a7dedeU, 0xe2bc5e5eU, 0x1d160b0bU, 0x76addbdbU,
+ 0x3bdbe0e0U, 0x56643232U, 0x4e743a3aU, 0x1e140a0aU,
+ 0xdb924949U, 0x0a0c0606U, 0x6c482424U, 0xe4b85c5cU,
+ 0x5d9fc2c2U, 0x6ebdd3d3U, 0xef43acacU, 0xa6c46262U,
+ 0xa8399191U, 0xa4319595U, 0x37d3e4e4U, 0x8bf27979U,
+ 0x32d5e7e7U, 0x438bc8c8U, 0x596e3737U, 0xb7da6d6dU,
+ 0x8c018d8dU, 0x64b1d5d5U, 0xd29c4e4eU, 0xe049a9a9U,
+ 0xb4d86c6cU, 0xfaac5656U, 0x07f3f4f4U, 0x25cfeaeaU,
+ 0xafca6565U, 0x8ef47a7aU, 0xe947aeaeU, 0x18100808U,
+ 0xd56fbabaU, 0x88f07878U, 0x6f4a2525U, 0x725c2e2eU,
+ 0x24381c1cU, 0xf157a6a6U, 0xc773b4b4U, 0x5197c6c6U,
+ 0x23cbe8e8U, 0x7ca1ddddU, 0x9ce87474U, 0x213e1f1fU,
+ 0xdd964b4bU, 0xdc61bdbdU, 0x860d8b8bU, 0x850f8a8aU,
+ 0x90e07070U, 0x427c3e3eU, 0xc471b5b5U, 0xaacc6666U,
+ 0xd8904848U, 0x05060303U, 0x01f7f6f6U, 0x121c0e0eU,
+ 0xa3c26161U, 0x5f6a3535U, 0xf9ae5757U, 0xd069b9b9U,
+ 0x91178686U, 0x5899c1c1U, 0x273a1d1dU, 0xb9279e9eU,
+ 0x38d9e1e1U, 0x13ebf8f8U, 0xb32b9898U, 0x33221111U,
+ 0xbbd26969U, 0x70a9d9d9U, 0x89078e8eU, 0xa7339494U,
+ 0xb62d9b9bU, 0x223c1e1eU, 0x92158787U, 0x20c9e9e9U,
+ 0x4987ceceU, 0xffaa5555U, 0x78502828U, 0x7aa5dfdfU,
+ 0x8f038c8cU, 0xf859a1a1U, 0x80098989U, 0x171a0d0dU,
+ 0xda65bfbfU, 0x31d7e6e6U, 0xc6844242U, 0xb8d06868U,
+ 0xc3824141U, 0xb0299999U, 0x775a2d2dU, 0x111e0f0fU,
+ 0xcb7bb0b0U, 0xfca85454U, 0xd66dbbbbU, 0x3a2c1616U,
+};
+static const u32 Te2[256] = {
+ 0x63a5c663U, 0x7c84f87cU, 0x7799ee77U, 0x7b8df67bU,
+ 0xf20dfff2U, 0x6bbdd66bU, 0x6fb1de6fU, 0xc55491c5U,
+ 0x30506030U, 0x01030201U, 0x67a9ce67U, 0x2b7d562bU,
+ 0xfe19e7feU, 0xd762b5d7U, 0xabe64dabU, 0x769aec76U,
+ 0xca458fcaU, 0x829d1f82U, 0xc94089c9U, 0x7d87fa7dU,
+ 0xfa15effaU, 0x59ebb259U, 0x47c98e47U, 0xf00bfbf0U,
+ 0xadec41adU, 0xd467b3d4U, 0xa2fd5fa2U, 0xafea45afU,
+ 0x9cbf239cU, 0xa4f753a4U, 0x7296e472U, 0xc05b9bc0U,
+ 0xb7c275b7U, 0xfd1ce1fdU, 0x93ae3d93U, 0x266a4c26U,
+ 0x365a6c36U, 0x3f417e3fU, 0xf702f5f7U, 0xcc4f83ccU,
+ 0x345c6834U, 0xa5f451a5U, 0xe534d1e5U, 0xf108f9f1U,
+ 0x7193e271U, 0xd873abd8U, 0x31536231U, 0x153f2a15U,
+ 0x040c0804U, 0xc75295c7U, 0x23654623U, 0xc35e9dc3U,
+ 0x18283018U, 0x96a13796U, 0x050f0a05U, 0x9ab52f9aU,
+ 0x07090e07U, 0x12362412U, 0x809b1b80U, 0xe23ddfe2U,
+ 0xeb26cdebU, 0x27694e27U, 0xb2cd7fb2U, 0x759fea75U,
+ 0x091b1209U, 0x839e1d83U, 0x2c74582cU, 0x1a2e341aU,
+ 0x1b2d361bU, 0x6eb2dc6eU, 0x5aeeb45aU, 0xa0fb5ba0U,
+ 0x52f6a452U, 0x3b4d763bU, 0xd661b7d6U, 0xb3ce7db3U,
+ 0x297b5229U, 0xe33edde3U, 0x2f715e2fU, 0x84971384U,
+ 0x53f5a653U, 0xd168b9d1U, 0x00000000U, 0xed2cc1edU,
+ 0x20604020U, 0xfc1fe3fcU, 0xb1c879b1U, 0x5bedb65bU,
+ 0x6abed46aU, 0xcb468dcbU, 0xbed967beU, 0x394b7239U,
+ 0x4ade944aU, 0x4cd4984cU, 0x58e8b058U, 0xcf4a85cfU,
+ 0xd06bbbd0U, 0xef2ac5efU, 0xaae54faaU, 0xfb16edfbU,
+ 0x43c58643U, 0x4dd79a4dU, 0x33556633U, 0x85941185U,
+ 0x45cf8a45U, 0xf910e9f9U, 0x02060402U, 0x7f81fe7fU,
+ 0x50f0a050U, 0x3c44783cU, 0x9fba259fU, 0xa8e34ba8U,
+ 0x51f3a251U, 0xa3fe5da3U, 0x40c08040U, 0x8f8a058fU,
+ 0x92ad3f92U, 0x9dbc219dU, 0x38487038U, 0xf504f1f5U,
+ 0xbcdf63bcU, 0xb6c177b6U, 0xda75afdaU, 0x21634221U,
+ 0x10302010U, 0xff1ae5ffU, 0xf30efdf3U, 0xd26dbfd2U,
+ 0xcd4c81cdU, 0x0c14180cU, 0x13352613U, 0xec2fc3ecU,
+ 0x5fe1be5fU, 0x97a23597U, 0x44cc8844U, 0x17392e17U,
+ 0xc45793c4U, 0xa7f255a7U, 0x7e82fc7eU, 0x3d477a3dU,
+ 0x64acc864U, 0x5de7ba5dU, 0x192b3219U, 0x7395e673U,
+ 0x60a0c060U, 0x81981981U, 0x4fd19e4fU, 0xdc7fa3dcU,
+ 0x22664422U, 0x2a7e542aU, 0x90ab3b90U, 0x88830b88U,
+ 0x46ca8c46U, 0xee29c7eeU, 0xb8d36bb8U, 0x143c2814U,
+ 0xde79a7deU, 0x5ee2bc5eU, 0x0b1d160bU, 0xdb76addbU,
+ 0xe03bdbe0U, 0x32566432U, 0x3a4e743aU, 0x0a1e140aU,
+ 0x49db9249U, 0x060a0c06U, 0x246c4824U, 0x5ce4b85cU,
+ 0xc25d9fc2U, 0xd36ebdd3U, 0xacef43acU, 0x62a6c462U,
+ 0x91a83991U, 0x95a43195U, 0xe437d3e4U, 0x798bf279U,
+ 0xe732d5e7U, 0xc8438bc8U, 0x37596e37U, 0x6db7da6dU,
+ 0x8d8c018dU, 0xd564b1d5U, 0x4ed29c4eU, 0xa9e049a9U,
+ 0x6cb4d86cU, 0x56faac56U, 0xf407f3f4U, 0xea25cfeaU,
+ 0x65afca65U, 0x7a8ef47aU, 0xaee947aeU, 0x08181008U,
+ 0xbad56fbaU, 0x7888f078U, 0x256f4a25U, 0x2e725c2eU,
+ 0x1c24381cU, 0xa6f157a6U, 0xb4c773b4U, 0xc65197c6U,
+ 0xe823cbe8U, 0xdd7ca1ddU, 0x749ce874U, 0x1f213e1fU,
+ 0x4bdd964bU, 0xbddc61bdU, 0x8b860d8bU, 0x8a850f8aU,
+ 0x7090e070U, 0x3e427c3eU, 0xb5c471b5U, 0x66aacc66U,
+ 0x48d89048U, 0x03050603U, 0xf601f7f6U, 0x0e121c0eU,
+ 0x61a3c261U, 0x355f6a35U, 0x57f9ae57U, 0xb9d069b9U,
+ 0x86911786U, 0xc15899c1U, 0x1d273a1dU, 0x9eb9279eU,
+ 0xe138d9e1U, 0xf813ebf8U, 0x98b32b98U, 0x11332211U,
+ 0x69bbd269U, 0xd970a9d9U, 0x8e89078eU, 0x94a73394U,
+ 0x9bb62d9bU, 0x1e223c1eU, 0x87921587U, 0xe920c9e9U,
+ 0xce4987ceU, 0x55ffaa55U, 0x28785028U, 0xdf7aa5dfU,
+ 0x8c8f038cU, 0xa1f859a1U, 0x89800989U, 0x0d171a0dU,
+ 0xbfda65bfU, 0xe631d7e6U, 0x42c68442U, 0x68b8d068U,
+ 0x41c38241U, 0x99b02999U, 0x2d775a2dU, 0x0f111e0fU,
+ 0xb0cb7bb0U, 0x54fca854U, 0xbbd66dbbU, 0x163a2c16U,
+};
+static const u32 Te3[256] = {
+
+ 0x6363a5c6U, 0x7c7c84f8U, 0x777799eeU, 0x7b7b8df6U,
+ 0xf2f20dffU, 0x6b6bbdd6U, 0x6f6fb1deU, 0xc5c55491U,
+ 0x30305060U, 0x01010302U, 0x6767a9ceU, 0x2b2b7d56U,
+ 0xfefe19e7U, 0xd7d762b5U, 0xababe64dU, 0x76769aecU,
+ 0xcaca458fU, 0x82829d1fU, 0xc9c94089U, 0x7d7d87faU,
+ 0xfafa15efU, 0x5959ebb2U, 0x4747c98eU, 0xf0f00bfbU,
+ 0xadadec41U, 0xd4d467b3U, 0xa2a2fd5fU, 0xafafea45U,
+ 0x9c9cbf23U, 0xa4a4f753U, 0x727296e4U, 0xc0c05b9bU,
+ 0xb7b7c275U, 0xfdfd1ce1U, 0x9393ae3dU, 0x26266a4cU,
+ 0x36365a6cU, 0x3f3f417eU, 0xf7f702f5U, 0xcccc4f83U,
+ 0x34345c68U, 0xa5a5f451U, 0xe5e534d1U, 0xf1f108f9U,
+ 0x717193e2U, 0xd8d873abU, 0x31315362U, 0x15153f2aU,
+ 0x04040c08U, 0xc7c75295U, 0x23236546U, 0xc3c35e9dU,
+ 0x18182830U, 0x9696a137U, 0x05050f0aU, 0x9a9ab52fU,
+ 0x0707090eU, 0x12123624U, 0x80809b1bU, 0xe2e23ddfU,
+ 0xebeb26cdU, 0x2727694eU, 0xb2b2cd7fU, 0x75759feaU,
+ 0x09091b12U, 0x83839e1dU, 0x2c2c7458U, 0x1a1a2e34U,
+ 0x1b1b2d36U, 0x6e6eb2dcU, 0x5a5aeeb4U, 0xa0a0fb5bU,
+ 0x5252f6a4U, 0x3b3b4d76U, 0xd6d661b7U, 0xb3b3ce7dU,
+ 0x29297b52U, 0xe3e33eddU, 0x2f2f715eU, 0x84849713U,
+ 0x5353f5a6U, 0xd1d168b9U, 0x00000000U, 0xeded2cc1U,
+ 0x20206040U, 0xfcfc1fe3U, 0xb1b1c879U, 0x5b5bedb6U,
+ 0x6a6abed4U, 0xcbcb468dU, 0xbebed967U, 0x39394b72U,
+ 0x4a4ade94U, 0x4c4cd498U, 0x5858e8b0U, 0xcfcf4a85U,
+ 0xd0d06bbbU, 0xefef2ac5U, 0xaaaae54fU, 0xfbfb16edU,
+ 0x4343c586U, 0x4d4dd79aU, 0x33335566U, 0x85859411U,
+ 0x4545cf8aU, 0xf9f910e9U, 0x02020604U, 0x7f7f81feU,
+ 0x5050f0a0U, 0x3c3c4478U, 0x9f9fba25U, 0xa8a8e34bU,
+ 0x5151f3a2U, 0xa3a3fe5dU, 0x4040c080U, 0x8f8f8a05U,
+ 0x9292ad3fU, 0x9d9dbc21U, 0x38384870U, 0xf5f504f1U,
+ 0xbcbcdf63U, 0xb6b6c177U, 0xdada75afU, 0x21216342U,
+ 0x10103020U, 0xffff1ae5U, 0xf3f30efdU, 0xd2d26dbfU,
+ 0xcdcd4c81U, 0x0c0c1418U, 0x13133526U, 0xecec2fc3U,
+ 0x5f5fe1beU, 0x9797a235U, 0x4444cc88U, 0x1717392eU,
+ 0xc4c45793U, 0xa7a7f255U, 0x7e7e82fcU, 0x3d3d477aU,
+ 0x6464acc8U, 0x5d5de7baU, 0x19192b32U, 0x737395e6U,
+ 0x6060a0c0U, 0x81819819U, 0x4f4fd19eU, 0xdcdc7fa3U,
+ 0x22226644U, 0x2a2a7e54U, 0x9090ab3bU, 0x8888830bU,
+ 0x4646ca8cU, 0xeeee29c7U, 0xb8b8d36bU, 0x14143c28U,
+ 0xdede79a7U, 0x5e5ee2bcU, 0x0b0b1d16U, 0xdbdb76adU,
+ 0xe0e03bdbU, 0x32325664U, 0x3a3a4e74U, 0x0a0a1e14U,
+ 0x4949db92U, 0x06060a0cU, 0x24246c48U, 0x5c5ce4b8U,
+ 0xc2c25d9fU, 0xd3d36ebdU, 0xacacef43U, 0x6262a6c4U,
+ 0x9191a839U, 0x9595a431U, 0xe4e437d3U, 0x79798bf2U,
+ 0xe7e732d5U, 0xc8c8438bU, 0x3737596eU, 0x6d6db7daU,
+ 0x8d8d8c01U, 0xd5d564b1U, 0x4e4ed29cU, 0xa9a9e049U,
+ 0x6c6cb4d8U, 0x5656faacU, 0xf4f407f3U, 0xeaea25cfU,
+ 0x6565afcaU, 0x7a7a8ef4U, 0xaeaee947U, 0x08081810U,
+ 0xbabad56fU, 0x787888f0U, 0x25256f4aU, 0x2e2e725cU,
+ 0x1c1c2438U, 0xa6a6f157U, 0xb4b4c773U, 0xc6c65197U,
+ 0xe8e823cbU, 0xdddd7ca1U, 0x74749ce8U, 0x1f1f213eU,
+ 0x4b4bdd96U, 0xbdbddc61U, 0x8b8b860dU, 0x8a8a850fU,
+ 0x707090e0U, 0x3e3e427cU, 0xb5b5c471U, 0x6666aaccU,
+ 0x4848d890U, 0x03030506U, 0xf6f601f7U, 0x0e0e121cU,
+ 0x6161a3c2U, 0x35355f6aU, 0x5757f9aeU, 0xb9b9d069U,
+ 0x86869117U, 0xc1c15899U, 0x1d1d273aU, 0x9e9eb927U,
+ 0xe1e138d9U, 0xf8f813ebU, 0x9898b32bU, 0x11113322U,
+ 0x6969bbd2U, 0xd9d970a9U, 0x8e8e8907U, 0x9494a733U,
+ 0x9b9bb62dU, 0x1e1e223cU, 0x87879215U, 0xe9e920c9U,
+ 0xcece4987U, 0x5555ffaaU, 0x28287850U, 0xdfdf7aa5U,
+ 0x8c8c8f03U, 0xa1a1f859U, 0x89898009U, 0x0d0d171aU,
+ 0xbfbfda65U, 0xe6e631d7U, 0x4242c684U, 0x6868b8d0U,
+ 0x4141c382U, 0x9999b029U, 0x2d2d775aU, 0x0f0f111eU,
+ 0xb0b0cb7bU, 0x5454fca8U, 0xbbbbd66dU, 0x16163a2cU,
+};
+static const u32 Te4[256] = {
+ 0x63636363U, 0x7c7c7c7cU, 0x77777777U, 0x7b7b7b7bU,
+ 0xf2f2f2f2U, 0x6b6b6b6bU, 0x6f6f6f6fU, 0xc5c5c5c5U,
+ 0x30303030U, 0x01010101U, 0x67676767U, 0x2b2b2b2bU,
+ 0xfefefefeU, 0xd7d7d7d7U, 0xababababU, 0x76767676U,
+ 0xcacacacaU, 0x82828282U, 0xc9c9c9c9U, 0x7d7d7d7dU,
+ 0xfafafafaU, 0x59595959U, 0x47474747U, 0xf0f0f0f0U,
+ 0xadadadadU, 0xd4d4d4d4U, 0xa2a2a2a2U, 0xafafafafU,
+ 0x9c9c9c9cU, 0xa4a4a4a4U, 0x72727272U, 0xc0c0c0c0U,
+ 0xb7b7b7b7U, 0xfdfdfdfdU, 0x93939393U, 0x26262626U,
+ 0x36363636U, 0x3f3f3f3fU, 0xf7f7f7f7U, 0xccccccccU,
+ 0x34343434U, 0xa5a5a5a5U, 0xe5e5e5e5U, 0xf1f1f1f1U,
+ 0x71717171U, 0xd8d8d8d8U, 0x31313131U, 0x15151515U,
+ 0x04040404U, 0xc7c7c7c7U, 0x23232323U, 0xc3c3c3c3U,
+ 0x18181818U, 0x96969696U, 0x05050505U, 0x9a9a9a9aU,
+ 0x07070707U, 0x12121212U, 0x80808080U, 0xe2e2e2e2U,
+ 0xebebebebU, 0x27272727U, 0xb2b2b2b2U, 0x75757575U,
+ 0x09090909U, 0x83838383U, 0x2c2c2c2cU, 0x1a1a1a1aU,
+ 0x1b1b1b1bU, 0x6e6e6e6eU, 0x5a5a5a5aU, 0xa0a0a0a0U,
+ 0x52525252U, 0x3b3b3b3bU, 0xd6d6d6d6U, 0xb3b3b3b3U,
+ 0x29292929U, 0xe3e3e3e3U, 0x2f2f2f2fU, 0x84848484U,
+ 0x53535353U, 0xd1d1d1d1U, 0x00000000U, 0xededededU,
+ 0x20202020U, 0xfcfcfcfcU, 0xb1b1b1b1U, 0x5b5b5b5bU,
+ 0x6a6a6a6aU, 0xcbcbcbcbU, 0xbebebebeU, 0x39393939U,
+ 0x4a4a4a4aU, 0x4c4c4c4cU, 0x58585858U, 0xcfcfcfcfU,
+ 0xd0d0d0d0U, 0xefefefefU, 0xaaaaaaaaU, 0xfbfbfbfbU,
+ 0x43434343U, 0x4d4d4d4dU, 0x33333333U, 0x85858585U,
+ 0x45454545U, 0xf9f9f9f9U, 0x02020202U, 0x7f7f7f7fU,
+ 0x50505050U, 0x3c3c3c3cU, 0x9f9f9f9fU, 0xa8a8a8a8U,
+ 0x51515151U, 0xa3a3a3a3U, 0x40404040U, 0x8f8f8f8fU,
+ 0x92929292U, 0x9d9d9d9dU, 0x38383838U, 0xf5f5f5f5U,
+ 0xbcbcbcbcU, 0xb6b6b6b6U, 0xdadadadaU, 0x21212121U,
+ 0x10101010U, 0xffffffffU, 0xf3f3f3f3U, 0xd2d2d2d2U,
+ 0xcdcdcdcdU, 0x0c0c0c0cU, 0x13131313U, 0xececececU,
+ 0x5f5f5f5fU, 0x97979797U, 0x44444444U, 0x17171717U,
+ 0xc4c4c4c4U, 0xa7a7a7a7U, 0x7e7e7e7eU, 0x3d3d3d3dU,
+ 0x64646464U, 0x5d5d5d5dU, 0x19191919U, 0x73737373U,
+ 0x60606060U, 0x81818181U, 0x4f4f4f4fU, 0xdcdcdcdcU,
+ 0x22222222U, 0x2a2a2a2aU, 0x90909090U, 0x88888888U,
+ 0x46464646U, 0xeeeeeeeeU, 0xb8b8b8b8U, 0x14141414U,
+ 0xdedededeU, 0x5e5e5e5eU, 0x0b0b0b0bU, 0xdbdbdbdbU,
+ 0xe0e0e0e0U, 0x32323232U, 0x3a3a3a3aU, 0x0a0a0a0aU,
+ 0x49494949U, 0x06060606U, 0x24242424U, 0x5c5c5c5cU,
+ 0xc2c2c2c2U, 0xd3d3d3d3U, 0xacacacacU, 0x62626262U,
+ 0x91919191U, 0x95959595U, 0xe4e4e4e4U, 0x79797979U,
+ 0xe7e7e7e7U, 0xc8c8c8c8U, 0x37373737U, 0x6d6d6d6dU,
+ 0x8d8d8d8dU, 0xd5d5d5d5U, 0x4e4e4e4eU, 0xa9a9a9a9U,
+ 0x6c6c6c6cU, 0x56565656U, 0xf4f4f4f4U, 0xeaeaeaeaU,
+ 0x65656565U, 0x7a7a7a7aU, 0xaeaeaeaeU, 0x08080808U,
+ 0xbabababaU, 0x78787878U, 0x25252525U, 0x2e2e2e2eU,
+ 0x1c1c1c1cU, 0xa6a6a6a6U, 0xb4b4b4b4U, 0xc6c6c6c6U,
+ 0xe8e8e8e8U, 0xddddddddU, 0x74747474U, 0x1f1f1f1fU,
+ 0x4b4b4b4bU, 0xbdbdbdbdU, 0x8b8b8b8bU, 0x8a8a8a8aU,
+ 0x70707070U, 0x3e3e3e3eU, 0xb5b5b5b5U, 0x66666666U,
+ 0x48484848U, 0x03030303U, 0xf6f6f6f6U, 0x0e0e0e0eU,
+ 0x61616161U, 0x35353535U, 0x57575757U, 0xb9b9b9b9U,
+ 0x86868686U, 0xc1c1c1c1U, 0x1d1d1d1dU, 0x9e9e9e9eU,
+ 0xe1e1e1e1U, 0xf8f8f8f8U, 0x98989898U, 0x11111111U,
+ 0x69696969U, 0xd9d9d9d9U, 0x8e8e8e8eU, 0x94949494U,
+ 0x9b9b9b9bU, 0x1e1e1e1eU, 0x87878787U, 0xe9e9e9e9U,
+ 0xcecececeU, 0x55555555U, 0x28282828U, 0xdfdfdfdfU,
+ 0x8c8c8c8cU, 0xa1a1a1a1U, 0x89898989U, 0x0d0d0d0dU,
+ 0xbfbfbfbfU, 0xe6e6e6e6U, 0x42424242U, 0x68686868U,
+ 0x41414141U, 0x99999999U, 0x2d2d2d2dU, 0x0f0f0f0fU,
+ 0xb0b0b0b0U, 0x54545454U, 0xbbbbbbbbU, 0x16161616U,
+};
+#endif /* AES_SMALL_TABLES */
+static const u32 Td0[256] = {
+ 0x51f4a750U, 0x7e416553U, 0x1a17a4c3U, 0x3a275e96U,
+ 0x3bab6bcbU, 0x1f9d45f1U, 0xacfa58abU, 0x4be30393U,
+ 0x2030fa55U, 0xad766df6U, 0x88cc7691U, 0xf5024c25U,
+ 0x4fe5d7fcU, 0xc52acbd7U, 0x26354480U, 0xb562a38fU,
+ 0xdeb15a49U, 0x25ba1b67U, 0x45ea0e98U, 0x5dfec0e1U,
+ 0xc32f7502U, 0x814cf012U, 0x8d4697a3U, 0x6bd3f9c6U,
+ 0x038f5fe7U, 0x15929c95U, 0xbf6d7aebU, 0x955259daU,
+ 0xd4be832dU, 0x587421d3U, 0x49e06929U, 0x8ec9c844U,
+ 0x75c2896aU, 0xf48e7978U, 0x99583e6bU, 0x27b971ddU,
+ 0xbee14fb6U, 0xf088ad17U, 0xc920ac66U, 0x7dce3ab4U,
+ 0x63df4a18U, 0xe51a3182U, 0x97513360U, 0x62537f45U,
+ 0xb16477e0U, 0xbb6bae84U, 0xfe81a01cU, 0xf9082b94U,
+ 0x70486858U, 0x8f45fd19U, 0x94de6c87U, 0x527bf8b7U,
+ 0xab73d323U, 0x724b02e2U, 0xe31f8f57U, 0x6655ab2aU,
+ 0xb2eb2807U, 0x2fb5c203U, 0x86c57b9aU, 0xd33708a5U,
+ 0x302887f2U, 0x23bfa5b2U, 0x02036abaU, 0xed16825cU,
+ 0x8acf1c2bU, 0xa779b492U, 0xf307f2f0U, 0x4e69e2a1U,
+ 0x65daf4cdU, 0x0605bed5U, 0xd134621fU, 0xc4a6fe8aU,
+ 0x342e539dU, 0xa2f355a0U, 0x058ae132U, 0xa4f6eb75U,
+ 0x0b83ec39U, 0x4060efaaU, 0x5e719f06U, 0xbd6e1051U,
+ 0x3e218af9U, 0x96dd063dU, 0xdd3e05aeU, 0x4de6bd46U,
+ 0x91548db5U, 0x71c45d05U, 0x0406d46fU, 0x605015ffU,
+ 0x1998fb24U, 0xd6bde997U, 0x894043ccU, 0x67d99e77U,
+ 0xb0e842bdU, 0x07898b88U, 0xe7195b38U, 0x79c8eedbU,
+ 0xa17c0a47U, 0x7c420fe9U, 0xf8841ec9U, 0x00000000U,
+ 0x09808683U, 0x322bed48U, 0x1e1170acU, 0x6c5a724eU,
+ 0xfd0efffbU, 0x0f853856U, 0x3daed51eU, 0x362d3927U,
+ 0x0a0fd964U, 0x685ca621U, 0x9b5b54d1U, 0x24362e3aU,
+ 0x0c0a67b1U, 0x9357e70fU, 0xb4ee96d2U, 0x1b9b919eU,
+ 0x80c0c54fU, 0x61dc20a2U, 0x5a774b69U, 0x1c121a16U,
+ 0xe293ba0aU, 0xc0a02ae5U, 0x3c22e043U, 0x121b171dU,
+ 0x0e090d0bU, 0xf28bc7adU, 0x2db6a8b9U, 0x141ea9c8U,
+ 0x57f11985U, 0xaf75074cU, 0xee99ddbbU, 0xa37f60fdU,
+ 0xf701269fU, 0x5c72f5bcU, 0x44663bc5U, 0x5bfb7e34U,
+ 0x8b432976U, 0xcb23c6dcU, 0xb6edfc68U, 0xb8e4f163U,
+ 0xd731dccaU, 0x42638510U, 0x13972240U, 0x84c61120U,
+ 0x854a247dU, 0xd2bb3df8U, 0xaef93211U, 0xc729a16dU,
+ 0x1d9e2f4bU, 0xdcb230f3U, 0x0d8652ecU, 0x77c1e3d0U,
+ 0x2bb3166cU, 0xa970b999U, 0x119448faU, 0x47e96422U,
+ 0xa8fc8cc4U, 0xa0f03f1aU, 0x567d2cd8U, 0x223390efU,
+ 0x87494ec7U, 0xd938d1c1U, 0x8ccaa2feU, 0x98d40b36U,
+ 0xa6f581cfU, 0xa57ade28U, 0xdab78e26U, 0x3fadbfa4U,
+ 0x2c3a9de4U, 0x5078920dU, 0x6a5fcc9bU, 0x547e4662U,
+ 0xf68d13c2U, 0x90d8b8e8U, 0x2e39f75eU, 0x82c3aff5U,
+ 0x9f5d80beU, 0x69d0937cU, 0x6fd52da9U, 0xcf2512b3U,
+ 0xc8ac993bU, 0x10187da7U, 0xe89c636eU, 0xdb3bbb7bU,
+ 0xcd267809U, 0x6e5918f4U, 0xec9ab701U, 0x834f9aa8U,
+ 0xe6956e65U, 0xaaffe67eU, 0x21bccf08U, 0xef15e8e6U,
+ 0xbae79bd9U, 0x4a6f36ceU, 0xea9f09d4U, 0x29b07cd6U,
+ 0x31a4b2afU, 0x2a3f2331U, 0xc6a59430U, 0x35a266c0U,
+ 0x744ebc37U, 0xfc82caa6U, 0xe090d0b0U, 0x33a7d815U,
+ 0xf104984aU, 0x41ecdaf7U, 0x7fcd500eU, 0x1791f62fU,
+ 0x764dd68dU, 0x43efb04dU, 0xccaa4d54U, 0xe49604dfU,
+ 0x9ed1b5e3U, 0x4c6a881bU, 0xc12c1fb8U, 0x4665517fU,
+ 0x9d5eea04U, 0x018c355dU, 0xfa877473U, 0xfb0b412eU,
+ 0xb3671d5aU, 0x92dbd252U, 0xe9105633U, 0x6dd64713U,
+ 0x9ad7618cU, 0x37a10c7aU, 0x59f8148eU, 0xeb133c89U,
+ 0xcea927eeU, 0xb761c935U, 0xe11ce5edU, 0x7a47b13cU,
+ 0x9cd2df59U, 0x55f2733fU, 0x1814ce79U, 0x73c737bfU,
+ 0x53f7cdeaU, 0x5ffdaa5bU, 0xdf3d6f14U, 0x7844db86U,
+ 0xcaaff381U, 0xb968c43eU, 0x3824342cU, 0xc2a3405fU,
+ 0x161dc372U, 0xbce2250cU, 0x283c498bU, 0xff0d9541U,
+ 0x39a80171U, 0x080cb3deU, 0xd8b4e49cU, 0x6456c190U,
+ 0x7bcb8461U, 0xd532b670U, 0x486c5c74U, 0xd0b85742U,
+};
+#ifndef AES_SMALL_TABLES
+static const u32 Td1[256] = {
+ 0x5051f4a7U, 0x537e4165U, 0xc31a17a4U, 0x963a275eU,
+ 0xcb3bab6bU, 0xf11f9d45U, 0xabacfa58U, 0x934be303U,
+ 0x552030faU, 0xf6ad766dU, 0x9188cc76U, 0x25f5024cU,
+ 0xfc4fe5d7U, 0xd7c52acbU, 0x80263544U, 0x8fb562a3U,
+ 0x49deb15aU, 0x6725ba1bU, 0x9845ea0eU, 0xe15dfec0U,
+ 0x02c32f75U, 0x12814cf0U, 0xa38d4697U, 0xc66bd3f9U,
+ 0xe7038f5fU, 0x9515929cU, 0xebbf6d7aU, 0xda955259U,
+ 0x2dd4be83U, 0xd3587421U, 0x2949e069U, 0x448ec9c8U,
+ 0x6a75c289U, 0x78f48e79U, 0x6b99583eU, 0xdd27b971U,
+ 0xb6bee14fU, 0x17f088adU, 0x66c920acU, 0xb47dce3aU,
+ 0x1863df4aU, 0x82e51a31U, 0x60975133U, 0x4562537fU,
+ 0xe0b16477U, 0x84bb6baeU, 0x1cfe81a0U, 0x94f9082bU,
+ 0x58704868U, 0x198f45fdU, 0x8794de6cU, 0xb7527bf8U,
+ 0x23ab73d3U, 0xe2724b02U, 0x57e31f8fU, 0x2a6655abU,
+ 0x07b2eb28U, 0x032fb5c2U, 0x9a86c57bU, 0xa5d33708U,
+ 0xf2302887U, 0xb223bfa5U, 0xba02036aU, 0x5ced1682U,
+ 0x2b8acf1cU, 0x92a779b4U, 0xf0f307f2U, 0xa14e69e2U,
+ 0xcd65daf4U, 0xd50605beU, 0x1fd13462U, 0x8ac4a6feU,
+ 0x9d342e53U, 0xa0a2f355U, 0x32058ae1U, 0x75a4f6ebU,
+ 0x390b83ecU, 0xaa4060efU, 0x065e719fU, 0x51bd6e10U,
+ 0xf93e218aU, 0x3d96dd06U, 0xaedd3e05U, 0x464de6bdU,
+ 0xb591548dU, 0x0571c45dU, 0x6f0406d4U, 0xff605015U,
+ 0x241998fbU, 0x97d6bde9U, 0xcc894043U, 0x7767d99eU,
+ 0xbdb0e842U, 0x8807898bU, 0x38e7195bU, 0xdb79c8eeU,
+ 0x47a17c0aU, 0xe97c420fU, 0xc9f8841eU, 0x00000000U,
+ 0x83098086U, 0x48322bedU, 0xac1e1170U, 0x4e6c5a72U,
+ 0xfbfd0effU, 0x560f8538U, 0x1e3daed5U, 0x27362d39U,
+ 0x640a0fd9U, 0x21685ca6U, 0xd19b5b54U, 0x3a24362eU,
+ 0xb10c0a67U, 0x0f9357e7U, 0xd2b4ee96U, 0x9e1b9b91U,
+ 0x4f80c0c5U, 0xa261dc20U, 0x695a774bU, 0x161c121aU,
+ 0x0ae293baU, 0xe5c0a02aU, 0x433c22e0U, 0x1d121b17U,
+ 0x0b0e090dU, 0xadf28bc7U, 0xb92db6a8U, 0xc8141ea9U,
+ 0x8557f119U, 0x4caf7507U, 0xbbee99ddU, 0xfda37f60U,
+ 0x9ff70126U, 0xbc5c72f5U, 0xc544663bU, 0x345bfb7eU,
+ 0x768b4329U, 0xdccb23c6U, 0x68b6edfcU, 0x63b8e4f1U,
+ 0xcad731dcU, 0x10426385U, 0x40139722U, 0x2084c611U,
+ 0x7d854a24U, 0xf8d2bb3dU, 0x11aef932U, 0x6dc729a1U,
+ 0x4b1d9e2fU, 0xf3dcb230U, 0xec0d8652U, 0xd077c1e3U,
+ 0x6c2bb316U, 0x99a970b9U, 0xfa119448U, 0x2247e964U,
+ 0xc4a8fc8cU, 0x1aa0f03fU, 0xd8567d2cU, 0xef223390U,
+ 0xc787494eU, 0xc1d938d1U, 0xfe8ccaa2U, 0x3698d40bU,
+ 0xcfa6f581U, 0x28a57adeU, 0x26dab78eU, 0xa43fadbfU,
+ 0xe42c3a9dU, 0x0d507892U, 0x9b6a5fccU, 0x62547e46U,
+ 0xc2f68d13U, 0xe890d8b8U, 0x5e2e39f7U, 0xf582c3afU,
+ 0xbe9f5d80U, 0x7c69d093U, 0xa96fd52dU, 0xb3cf2512U,
+ 0x3bc8ac99U, 0xa710187dU, 0x6ee89c63U, 0x7bdb3bbbU,
+ 0x09cd2678U, 0xf46e5918U, 0x01ec9ab7U, 0xa8834f9aU,
+ 0x65e6956eU, 0x7eaaffe6U, 0x0821bccfU, 0xe6ef15e8U,
+ 0xd9bae79bU, 0xce4a6f36U, 0xd4ea9f09U, 0xd629b07cU,
+ 0xaf31a4b2U, 0x312a3f23U, 0x30c6a594U, 0xc035a266U,
+ 0x37744ebcU, 0xa6fc82caU, 0xb0e090d0U, 0x1533a7d8U,
+ 0x4af10498U, 0xf741ecdaU, 0x0e7fcd50U, 0x2f1791f6U,
+ 0x8d764dd6U, 0x4d43efb0U, 0x54ccaa4dU, 0xdfe49604U,
+ 0xe39ed1b5U, 0x1b4c6a88U, 0xb8c12c1fU, 0x7f466551U,
+ 0x049d5eeaU, 0x5d018c35U, 0x73fa8774U, 0x2efb0b41U,
+ 0x5ab3671dU, 0x5292dbd2U, 0x33e91056U, 0x136dd647U,
+ 0x8c9ad761U, 0x7a37a10cU, 0x8e59f814U, 0x89eb133cU,
+ 0xeecea927U, 0x35b761c9U, 0xede11ce5U, 0x3c7a47b1U,
+ 0x599cd2dfU, 0x3f55f273U, 0x791814ceU, 0xbf73c737U,
+ 0xea53f7cdU, 0x5b5ffdaaU, 0x14df3d6fU, 0x867844dbU,
+ 0x81caaff3U, 0x3eb968c4U, 0x2c382434U, 0x5fc2a340U,
+ 0x72161dc3U, 0x0cbce225U, 0x8b283c49U, 0x41ff0d95U,
+ 0x7139a801U, 0xde080cb3U, 0x9cd8b4e4U, 0x906456c1U,
+ 0x617bcb84U, 0x70d532b6U, 0x74486c5cU, 0x42d0b857U,
+};
+static const u32 Td2[256] = {
+ 0xa75051f4U, 0x65537e41U, 0xa4c31a17U, 0x5e963a27U,
+ 0x6bcb3babU, 0x45f11f9dU, 0x58abacfaU, 0x03934be3U,
+ 0xfa552030U, 0x6df6ad76U, 0x769188ccU, 0x4c25f502U,
+ 0xd7fc4fe5U, 0xcbd7c52aU, 0x44802635U, 0xa38fb562U,
+ 0x5a49deb1U, 0x1b6725baU, 0x0e9845eaU, 0xc0e15dfeU,
+ 0x7502c32fU, 0xf012814cU, 0x97a38d46U, 0xf9c66bd3U,
+ 0x5fe7038fU, 0x9c951592U, 0x7aebbf6dU, 0x59da9552U,
+ 0x832dd4beU, 0x21d35874U, 0x692949e0U, 0xc8448ec9U,
+ 0x896a75c2U, 0x7978f48eU, 0x3e6b9958U, 0x71dd27b9U,
+ 0x4fb6bee1U, 0xad17f088U, 0xac66c920U, 0x3ab47dceU,
+ 0x4a1863dfU, 0x3182e51aU, 0x33609751U, 0x7f456253U,
+ 0x77e0b164U, 0xae84bb6bU, 0xa01cfe81U, 0x2b94f908U,
+ 0x68587048U, 0xfd198f45U, 0x6c8794deU, 0xf8b7527bU,
+ 0xd323ab73U, 0x02e2724bU, 0x8f57e31fU, 0xab2a6655U,
+ 0x2807b2ebU, 0xc2032fb5U, 0x7b9a86c5U, 0x08a5d337U,
+ 0x87f23028U, 0xa5b223bfU, 0x6aba0203U, 0x825ced16U,
+ 0x1c2b8acfU, 0xb492a779U, 0xf2f0f307U, 0xe2a14e69U,
+ 0xf4cd65daU, 0xbed50605U, 0x621fd134U, 0xfe8ac4a6U,
+ 0x539d342eU, 0x55a0a2f3U, 0xe132058aU, 0xeb75a4f6U,
+ 0xec390b83U, 0xefaa4060U, 0x9f065e71U, 0x1051bd6eU,
+
+ 0x8af93e21U, 0x063d96ddU, 0x05aedd3eU, 0xbd464de6U,
+ 0x8db59154U, 0x5d0571c4U, 0xd46f0406U, 0x15ff6050U,
+ 0xfb241998U, 0xe997d6bdU, 0x43cc8940U, 0x9e7767d9U,
+ 0x42bdb0e8U, 0x8b880789U, 0x5b38e719U, 0xeedb79c8U,
+ 0x0a47a17cU, 0x0fe97c42U, 0x1ec9f884U, 0x00000000U,
+ 0x86830980U, 0xed48322bU, 0x70ac1e11U, 0x724e6c5aU,
+ 0xfffbfd0eU, 0x38560f85U, 0xd51e3daeU, 0x3927362dU,
+ 0xd9640a0fU, 0xa621685cU, 0x54d19b5bU, 0x2e3a2436U,
+ 0x67b10c0aU, 0xe70f9357U, 0x96d2b4eeU, 0x919e1b9bU,
+ 0xc54f80c0U, 0x20a261dcU, 0x4b695a77U, 0x1a161c12U,
+ 0xba0ae293U, 0x2ae5c0a0U, 0xe0433c22U, 0x171d121bU,
+ 0x0d0b0e09U, 0xc7adf28bU, 0xa8b92db6U, 0xa9c8141eU,
+ 0x198557f1U, 0x074caf75U, 0xddbbee99U, 0x60fda37fU,
+ 0x269ff701U, 0xf5bc5c72U, 0x3bc54466U, 0x7e345bfbU,
+ 0x29768b43U, 0xc6dccb23U, 0xfc68b6edU, 0xf163b8e4U,
+ 0xdccad731U, 0x85104263U, 0x22401397U, 0x112084c6U,
+ 0x247d854aU, 0x3df8d2bbU, 0x3211aef9U, 0xa16dc729U,
+ 0x2f4b1d9eU, 0x30f3dcb2U, 0x52ec0d86U, 0xe3d077c1U,
+ 0x166c2bb3U, 0xb999a970U, 0x48fa1194U, 0x642247e9U,
+ 0x8cc4a8fcU, 0x3f1aa0f0U, 0x2cd8567dU, 0x90ef2233U,
+ 0x4ec78749U, 0xd1c1d938U, 0xa2fe8ccaU, 0x0b3698d4U,
+ 0x81cfa6f5U, 0xde28a57aU, 0x8e26dab7U, 0xbfa43fadU,
+ 0x9de42c3aU, 0x920d5078U, 0xcc9b6a5fU, 0x4662547eU,
+ 0x13c2f68dU, 0xb8e890d8U, 0xf75e2e39U, 0xaff582c3U,
+ 0x80be9f5dU, 0x937c69d0U, 0x2da96fd5U, 0x12b3cf25U,
+ 0x993bc8acU, 0x7da71018U, 0x636ee89cU, 0xbb7bdb3bU,
+ 0x7809cd26U, 0x18f46e59U, 0xb701ec9aU, 0x9aa8834fU,
+ 0x6e65e695U, 0xe67eaaffU, 0xcf0821bcU, 0xe8e6ef15U,
+ 0x9bd9bae7U, 0x36ce4a6fU, 0x09d4ea9fU, 0x7cd629b0U,
+ 0xb2af31a4U, 0x23312a3fU, 0x9430c6a5U, 0x66c035a2U,
+ 0xbc37744eU, 0xcaa6fc82U, 0xd0b0e090U, 0xd81533a7U,
+ 0x984af104U, 0xdaf741ecU, 0x500e7fcdU, 0xf62f1791U,
+ 0xd68d764dU, 0xb04d43efU, 0x4d54ccaaU, 0x04dfe496U,
+ 0xb5e39ed1U, 0x881b4c6aU, 0x1fb8c12cU, 0x517f4665U,
+ 0xea049d5eU, 0x355d018cU, 0x7473fa87U, 0x412efb0bU,
+ 0x1d5ab367U, 0xd25292dbU, 0x5633e910U, 0x47136dd6U,
+ 0x618c9ad7U, 0x0c7a37a1U, 0x148e59f8U, 0x3c89eb13U,
+ 0x27eecea9U, 0xc935b761U, 0xe5ede11cU, 0xb13c7a47U,
+ 0xdf599cd2U, 0x733f55f2U, 0xce791814U, 0x37bf73c7U,
+ 0xcdea53f7U, 0xaa5b5ffdU, 0x6f14df3dU, 0xdb867844U,
+ 0xf381caafU, 0xc43eb968U, 0x342c3824U, 0x405fc2a3U,
+ 0xc372161dU, 0x250cbce2U, 0x498b283cU, 0x9541ff0dU,
+ 0x017139a8U, 0xb3de080cU, 0xe49cd8b4U, 0xc1906456U,
+ 0x84617bcbU, 0xb670d532U, 0x5c74486cU, 0x5742d0b8U,
+};
+static const u32 Td3[256] = {
+ 0xf4a75051U, 0x4165537eU, 0x17a4c31aU, 0x275e963aU,
+ 0xab6bcb3bU, 0x9d45f11fU, 0xfa58abacU, 0xe303934bU,
+ 0x30fa5520U, 0x766df6adU, 0xcc769188U, 0x024c25f5U,
+ 0xe5d7fc4fU, 0x2acbd7c5U, 0x35448026U, 0x62a38fb5U,
+ 0xb15a49deU, 0xba1b6725U, 0xea0e9845U, 0xfec0e15dU,
+ 0x2f7502c3U, 0x4cf01281U, 0x4697a38dU, 0xd3f9c66bU,
+ 0x8f5fe703U, 0x929c9515U, 0x6d7aebbfU, 0x5259da95U,
+ 0xbe832dd4U, 0x7421d358U, 0xe0692949U, 0xc9c8448eU,
+ 0xc2896a75U, 0x8e7978f4U, 0x583e6b99U, 0xb971dd27U,
+ 0xe14fb6beU, 0x88ad17f0U, 0x20ac66c9U, 0xce3ab47dU,
+ 0xdf4a1863U, 0x1a3182e5U, 0x51336097U, 0x537f4562U,
+ 0x6477e0b1U, 0x6bae84bbU, 0x81a01cfeU, 0x082b94f9U,
+ 0x48685870U, 0x45fd198fU, 0xde6c8794U, 0x7bf8b752U,
+ 0x73d323abU, 0x4b02e272U, 0x1f8f57e3U, 0x55ab2a66U,
+ 0xeb2807b2U, 0xb5c2032fU, 0xc57b9a86U, 0x3708a5d3U,
+ 0x2887f230U, 0xbfa5b223U, 0x036aba02U, 0x16825cedU,
+ 0xcf1c2b8aU, 0x79b492a7U, 0x07f2f0f3U, 0x69e2a14eU,
+ 0xdaf4cd65U, 0x05bed506U, 0x34621fd1U, 0xa6fe8ac4U,
+ 0x2e539d34U, 0xf355a0a2U, 0x8ae13205U, 0xf6eb75a4U,
+ 0x83ec390bU, 0x60efaa40U, 0x719f065eU, 0x6e1051bdU,
+ 0x218af93eU, 0xdd063d96U, 0x3e05aeddU, 0xe6bd464dU,
+ 0x548db591U, 0xc45d0571U, 0x06d46f04U, 0x5015ff60U,
+ 0x98fb2419U, 0xbde997d6U, 0x4043cc89U, 0xd99e7767U,
+ 0xe842bdb0U, 0x898b8807U, 0x195b38e7U, 0xc8eedb79U,
+ 0x7c0a47a1U, 0x420fe97cU, 0x841ec9f8U, 0x00000000U,
+ 0x80868309U, 0x2bed4832U, 0x1170ac1eU, 0x5a724e6cU,
+ 0x0efffbfdU, 0x8538560fU, 0xaed51e3dU, 0x2d392736U,
+ 0x0fd9640aU, 0x5ca62168U, 0x5b54d19bU, 0x362e3a24U,
+ 0x0a67b10cU, 0x57e70f93U, 0xee96d2b4U, 0x9b919e1bU,
+ 0xc0c54f80U, 0xdc20a261U, 0x774b695aU, 0x121a161cU,
+ 0x93ba0ae2U, 0xa02ae5c0U, 0x22e0433cU, 0x1b171d12U,
+ 0x090d0b0eU, 0x8bc7adf2U, 0xb6a8b92dU, 0x1ea9c814U,
+ 0xf1198557U, 0x75074cafU, 0x99ddbbeeU, 0x7f60fda3U,
+ 0x01269ff7U, 0x72f5bc5cU, 0x663bc544U, 0xfb7e345bU,
+ 0x4329768bU, 0x23c6dccbU, 0xedfc68b6U, 0xe4f163b8U,
+ 0x31dccad7U, 0x63851042U, 0x97224013U, 0xc6112084U,
+ 0x4a247d85U, 0xbb3df8d2U, 0xf93211aeU, 0x29a16dc7U,
+ 0x9e2f4b1dU, 0xb230f3dcU, 0x8652ec0dU, 0xc1e3d077U,
+ 0xb3166c2bU, 0x70b999a9U, 0x9448fa11U, 0xe9642247U,
+ 0xfc8cc4a8U, 0xf03f1aa0U, 0x7d2cd856U, 0x3390ef22U,
+ 0x494ec787U, 0x38d1c1d9U, 0xcaa2fe8cU, 0xd40b3698U,
+ 0xf581cfa6U, 0x7ade28a5U, 0xb78e26daU, 0xadbfa43fU,
+ 0x3a9de42cU, 0x78920d50U, 0x5fcc9b6aU, 0x7e466254U,
+ 0x8d13c2f6U, 0xd8b8e890U, 0x39f75e2eU, 0xc3aff582U,
+ 0x5d80be9fU, 0xd0937c69U, 0xd52da96fU, 0x2512b3cfU,
+ 0xac993bc8U, 0x187da710U, 0x9c636ee8U, 0x3bbb7bdbU,
+ 0x267809cdU, 0x5918f46eU, 0x9ab701ecU, 0x4f9aa883U,
+ 0x956e65e6U, 0xffe67eaaU, 0xbccf0821U, 0x15e8e6efU,
+ 0xe79bd9baU, 0x6f36ce4aU, 0x9f09d4eaU, 0xb07cd629U,
+ 0xa4b2af31U, 0x3f23312aU, 0xa59430c6U, 0xa266c035U,
+ 0x4ebc3774U, 0x82caa6fcU, 0x90d0b0e0U, 0xa7d81533U,
+ 0x04984af1U, 0xecdaf741U, 0xcd500e7fU, 0x91f62f17U,
+ 0x4dd68d76U, 0xefb04d43U, 0xaa4d54ccU, 0x9604dfe4U,
+ 0xd1b5e39eU, 0x6a881b4cU, 0x2c1fb8c1U, 0x65517f46U,
+ 0x5eea049dU, 0x8c355d01U, 0x877473faU, 0x0b412efbU,
+ 0x671d5ab3U, 0xdbd25292U, 0x105633e9U, 0xd647136dU,
+ 0xd7618c9aU, 0xa10c7a37U, 0xf8148e59U, 0x133c89ebU,
+ 0xa927eeceU, 0x61c935b7U, 0x1ce5ede1U, 0x47b13c7aU,
+ 0xd2df599cU, 0xf2733f55U, 0x14ce7918U, 0xc737bf73U,
+ 0xf7cdea53U, 0xfdaa5b5fU, 0x3d6f14dfU, 0x44db8678U,
+ 0xaff381caU, 0x68c43eb9U, 0x24342c38U, 0xa3405fc2U,
+ 0x1dc37216U, 0xe2250cbcU, 0x3c498b28U, 0x0d9541ffU,
+ 0xa8017139U, 0x0cb3de08U, 0xb4e49cd8U, 0x56c19064U,
+ 0xcb84617bU, 0x32b670d5U, 0x6c5c7448U, 0xb85742d0U,
+};
+static const u32 Td4[256] = {
+ 0x52525252U, 0x09090909U, 0x6a6a6a6aU, 0xd5d5d5d5U,
+ 0x30303030U, 0x36363636U, 0xa5a5a5a5U, 0x38383838U,
+ 0xbfbfbfbfU, 0x40404040U, 0xa3a3a3a3U, 0x9e9e9e9eU,
+ 0x81818181U, 0xf3f3f3f3U, 0xd7d7d7d7U, 0xfbfbfbfbU,
+ 0x7c7c7c7cU, 0xe3e3e3e3U, 0x39393939U, 0x82828282U,
+ 0x9b9b9b9bU, 0x2f2f2f2fU, 0xffffffffU, 0x87878787U,
+ 0x34343434U, 0x8e8e8e8eU, 0x43434343U, 0x44444444U,
+ 0xc4c4c4c4U, 0xdedededeU, 0xe9e9e9e9U, 0xcbcbcbcbU,
+ 0x54545454U, 0x7b7b7b7bU, 0x94949494U, 0x32323232U,
+ 0xa6a6a6a6U, 0xc2c2c2c2U, 0x23232323U, 0x3d3d3d3dU,
+ 0xeeeeeeeeU, 0x4c4c4c4cU, 0x95959595U, 0x0b0b0b0bU,
+ 0x42424242U, 0xfafafafaU, 0xc3c3c3c3U, 0x4e4e4e4eU,
+ 0x08080808U, 0x2e2e2e2eU, 0xa1a1a1a1U, 0x66666666U,
+ 0x28282828U, 0xd9d9d9d9U, 0x24242424U, 0xb2b2b2b2U,
+ 0x76767676U, 0x5b5b5b5bU, 0xa2a2a2a2U, 0x49494949U,
+ 0x6d6d6d6dU, 0x8b8b8b8bU, 0xd1d1d1d1U, 0x25252525U,
+ 0x72727272U, 0xf8f8f8f8U, 0xf6f6f6f6U, 0x64646464U,
+ 0x86868686U, 0x68686868U, 0x98989898U, 0x16161616U,
+ 0xd4d4d4d4U, 0xa4a4a4a4U, 0x5c5c5c5cU, 0xccccccccU,
+ 0x5d5d5d5dU, 0x65656565U, 0xb6b6b6b6U, 0x92929292U,
+ 0x6c6c6c6cU, 0x70707070U, 0x48484848U, 0x50505050U,
+ 0xfdfdfdfdU, 0xededededU, 0xb9b9b9b9U, 0xdadadadaU,
+ 0x5e5e5e5eU, 0x15151515U, 0x46464646U, 0x57575757U,
+ 0xa7a7a7a7U, 0x8d8d8d8dU, 0x9d9d9d9dU, 0x84848484U,
+ 0x90909090U, 0xd8d8d8d8U, 0xababababU, 0x00000000U,
+ 0x8c8c8c8cU, 0xbcbcbcbcU, 0xd3d3d3d3U, 0x0a0a0a0aU,
+ 0xf7f7f7f7U, 0xe4e4e4e4U, 0x58585858U, 0x05050505U,
+ 0xb8b8b8b8U, 0xb3b3b3b3U, 0x45454545U, 0x06060606U,
+ 0xd0d0d0d0U, 0x2c2c2c2cU, 0x1e1e1e1eU, 0x8f8f8f8fU,
+ 0xcacacacaU, 0x3f3f3f3fU, 0x0f0f0f0fU, 0x02020202U,
+ 0xc1c1c1c1U, 0xafafafafU, 0xbdbdbdbdU, 0x03030303U,
+ 0x01010101U, 0x13131313U, 0x8a8a8a8aU, 0x6b6b6b6bU,
+ 0x3a3a3a3aU, 0x91919191U, 0x11111111U, 0x41414141U,
+ 0x4f4f4f4fU, 0x67676767U, 0xdcdcdcdcU, 0xeaeaeaeaU,
+ 0x97979797U, 0xf2f2f2f2U, 0xcfcfcfcfU, 0xcecececeU,
+ 0xf0f0f0f0U, 0xb4b4b4b4U, 0xe6e6e6e6U, 0x73737373U,
+ 0x96969696U, 0xacacacacU, 0x74747474U, 0x22222222U,
+ 0xe7e7e7e7U, 0xadadadadU, 0x35353535U, 0x85858585U,
+ 0xe2e2e2e2U, 0xf9f9f9f9U, 0x37373737U, 0xe8e8e8e8U,
+ 0x1c1c1c1cU, 0x75757575U, 0xdfdfdfdfU, 0x6e6e6e6eU,
+ 0x47474747U, 0xf1f1f1f1U, 0x1a1a1a1aU, 0x71717171U,
+ 0x1d1d1d1dU, 0x29292929U, 0xc5c5c5c5U, 0x89898989U,
+ 0x6f6f6f6fU, 0xb7b7b7b7U, 0x62626262U, 0x0e0e0e0eU,
+ 0xaaaaaaaaU, 0x18181818U, 0xbebebebeU, 0x1b1b1b1bU,
+ 0xfcfcfcfcU, 0x56565656U, 0x3e3e3e3eU, 0x4b4b4b4bU,
+ 0xc6c6c6c6U, 0xd2d2d2d2U, 0x79797979U, 0x20202020U,
+ 0x9a9a9a9aU, 0xdbdbdbdbU, 0xc0c0c0c0U, 0xfefefefeU,
+ 0x78787878U, 0xcdcdcdcdU, 0x5a5a5a5aU, 0xf4f4f4f4U,
+ 0x1f1f1f1fU, 0xddddddddU, 0xa8a8a8a8U, 0x33333333U,
+ 0x88888888U, 0x07070707U, 0xc7c7c7c7U, 0x31313131U,
+ 0xb1b1b1b1U, 0x12121212U, 0x10101010U, 0x59595959U,
+ 0x27272727U, 0x80808080U, 0xececececU, 0x5f5f5f5fU,
+ 0x60606060U, 0x51515151U, 0x7f7f7f7fU, 0xa9a9a9a9U,
+ 0x19191919U, 0xb5b5b5b5U, 0x4a4a4a4aU, 0x0d0d0d0dU,
+ 0x2d2d2d2dU, 0xe5e5e5e5U, 0x7a7a7a7aU, 0x9f9f9f9fU,
+ 0x93939393U, 0xc9c9c9c9U, 0x9c9c9c9cU, 0xefefefefU,
+ 0xa0a0a0a0U, 0xe0e0e0e0U, 0x3b3b3b3bU, 0x4d4d4d4dU,
+ 0xaeaeaeaeU, 0x2a2a2a2aU, 0xf5f5f5f5U, 0xb0b0b0b0U,
+ 0xc8c8c8c8U, 0xebebebebU, 0xbbbbbbbbU, 0x3c3c3c3cU,
+ 0x83838383U, 0x53535353U, 0x99999999U, 0x61616161U,
+ 0x17171717U, 0x2b2b2b2bU, 0x04040404U, 0x7e7e7e7eU,
+ 0xbabababaU, 0x77777777U, 0xd6d6d6d6U, 0x26262626U,
+ 0xe1e1e1e1U, 0x69696969U, 0x14141414U, 0x63636363U,
+ 0x55555555U, 0x21212121U, 0x0c0c0c0cU, 0x7d7d7d7dU,
+};
+static const u32 rcon[] = {
+ 0x01000000, 0x02000000, 0x04000000, 0x08000000,
+ 0x10000000, 0x20000000, 0x40000000, 0x80000000,
+ 0x1B000000, 0x36000000, /* for 128-bit blocks, Rijndael never uses more than 10 rcon values */
+};
+#else /* AES_SMALL_TABLES */
+static const u8 Td4s[256] = {
+ 0x52U, 0x09U, 0x6aU, 0xd5U, 0x30U, 0x36U, 0xa5U, 0x38U,
+ 0xbfU, 0x40U, 0xa3U, 0x9eU, 0x81U, 0xf3U, 0xd7U, 0xfbU,
+ 0x7cU, 0xe3U, 0x39U, 0x82U, 0x9bU, 0x2fU, 0xffU, 0x87U,
+ 0x34U, 0x8eU, 0x43U, 0x44U, 0xc4U, 0xdeU, 0xe9U, 0xcbU,
+ 0x54U, 0x7bU, 0x94U, 0x32U, 0xa6U, 0xc2U, 0x23U, 0x3dU,
+ 0xeeU, 0x4cU, 0x95U, 0x0bU, 0x42U, 0xfaU, 0xc3U, 0x4eU,
+ 0x08U, 0x2eU, 0xa1U, 0x66U, 0x28U, 0xd9U, 0x24U, 0xb2U,
+ 0x76U, 0x5bU, 0xa2U, 0x49U, 0x6dU, 0x8bU, 0xd1U, 0x25U,
+ 0x72U, 0xf8U, 0xf6U, 0x64U, 0x86U, 0x68U, 0x98U, 0x16U,
+ 0xd4U, 0xa4U, 0x5cU, 0xccU, 0x5dU, 0x65U, 0xb6U, 0x92U,
+ 0x6cU, 0x70U, 0x48U, 0x50U, 0xfdU, 0xedU, 0xb9U, 0xdaU,
+ 0x5eU, 0x15U, 0x46U, 0x57U, 0xa7U, 0x8dU, 0x9dU, 0x84U,
+ 0x90U, 0xd8U, 0xabU, 0x00U, 0x8cU, 0xbcU, 0xd3U, 0x0aU,
+ 0xf7U, 0xe4U, 0x58U, 0x05U, 0xb8U, 0xb3U, 0x45U, 0x06U,
+ 0xd0U, 0x2cU, 0x1eU, 0x8fU, 0xcaU, 0x3fU, 0x0fU, 0x02U,
+ 0xc1U, 0xafU, 0xbdU, 0x03U, 0x01U, 0x13U, 0x8aU, 0x6bU,
+ 0x3aU, 0x91U, 0x11U, 0x41U, 0x4fU, 0x67U, 0xdcU, 0xeaU,
+ 0x97U, 0xf2U, 0xcfU, 0xceU, 0xf0U, 0xb4U, 0xe6U, 0x73U,
+ 0x96U, 0xacU, 0x74U, 0x22U, 0xe7U, 0xadU, 0x35U, 0x85U,
+ 0xe2U, 0xf9U, 0x37U, 0xe8U, 0x1cU, 0x75U, 0xdfU, 0x6eU,
+ 0x47U, 0xf1U, 0x1aU, 0x71U, 0x1dU, 0x29U, 0xc5U, 0x89U,
+ 0x6fU, 0xb7U, 0x62U, 0x0eU, 0xaaU, 0x18U, 0xbeU, 0x1bU,
+ 0xfcU, 0x56U, 0x3eU, 0x4bU, 0xc6U, 0xd2U, 0x79U, 0x20U,
+ 0x9aU, 0xdbU, 0xc0U, 0xfeU, 0x78U, 0xcdU, 0x5aU, 0xf4U,
+ 0x1fU, 0xddU, 0xa8U, 0x33U, 0x88U, 0x07U, 0xc7U, 0x31U,
+ 0xb1U, 0x12U, 0x10U, 0x59U, 0x27U, 0x80U, 0xecU, 0x5fU,
+ 0x60U, 0x51U, 0x7fU, 0xa9U, 0x19U, 0xb5U, 0x4aU, 0x0dU,
+ 0x2dU, 0xe5U, 0x7aU, 0x9fU, 0x93U, 0xc9U, 0x9cU, 0xefU,
+ 0xa0U, 0xe0U, 0x3bU, 0x4dU, 0xaeU, 0x2aU, 0xf5U, 0xb0U,
+ 0xc8U, 0xebU, 0xbbU, 0x3cU, 0x83U, 0x53U, 0x99U, 0x61U,
+ 0x17U, 0x2bU, 0x04U, 0x7eU, 0xbaU, 0x77U, 0xd6U, 0x26U,
+ 0xe1U, 0x69U, 0x14U, 0x63U, 0x55U, 0x21U, 0x0cU, 0x7dU,
+};
+static const u8 rcons[] = {
+ 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1B, 0x36
+ /* for 128-bit blocks, Rijndael never uses more than 10 rcon values */
+};
+#endif /* AES_SMALL_TABLES */
+
+
+#ifndef AES_SMALL_TABLES
+
+#define RCON(i) rcon[(i)]
+
+#define TE0(i) Te0[((i) >> 24) & 0xff]
+#define TE1(i) Te1[((i) >> 16) & 0xff]
+#define TE2(i) Te2[((i) >> 8) & 0xff]
+#define TE3(i) Te3[(i) & 0xff]
+#define TE41(i) (Te4[((i) >> 24) & 0xff] & 0xff000000)
+#define TE42(i) (Te4[((i) >> 16) & 0xff] & 0x00ff0000)
+#define TE43(i) (Te4[((i) >> 8) & 0xff] & 0x0000ff00)
+#define TE44(i) (Te4[(i) & 0xff] & 0x000000ff)
+#define TE421(i) (Te4[((i) >> 16) & 0xff] & 0xff000000)
+#define TE432(i) (Te4[((i) >> 8) & 0xff] & 0x00ff0000)
+#define TE443(i) (Te4[(i) & 0xff] & 0x0000ff00)
+#define TE414(i) (Te4[((i) >> 24) & 0xff] & 0x000000ff)
+#define TE4(i) (Te4[(i)] & 0x000000ff)
+
+#define TD0(i) Td0[((i) >> 24) & 0xff]
+#define TD1(i) Td1[((i) >> 16) & 0xff]
+#define TD2(i) Td2[((i) >> 8) & 0xff]
+#define TD3(i) Td3[(i) & 0xff]
+#define TD41(i) (Td4[((i) >> 24) & 0xff] & 0xff000000)
+#define TD42(i) (Td4[((i) >> 16) & 0xff] & 0x00ff0000)
+#define TD43(i) (Td4[((i) >> 8) & 0xff] & 0x0000ff00)
+#define TD44(i) (Td4[(i) & 0xff] & 0x000000ff)
+#define TD0_(i) Td0[(i) & 0xff]
+#define TD1_(i) Td1[(i) & 0xff]
+#define TD2_(i) Td2[(i) & 0xff]
+#define TD3_(i) Td3[(i) & 0xff]
+
+#else /* AES_SMALL_TABLES */
+
+#define RCON(i) (rcons[(i)] << 24)
+
+static inline u32 rotr(u32 val, int bits)
+{
+ return (val >> bits) | (val << (32 - bits));
+}
+
+#define TE0(i) Te0[((i) >> 24) & 0xff]
+#define TE1(i) rotr(Te0[((i) >> 16) & 0xff], 8)
+#define TE2(i) rotr(Te0[((i) >> 8) & 0xff], 16)
+#define TE3(i) rotr(Te0[(i) & 0xff], 24)
+#define TE41(i) ((Te0[((i) >> 24) & 0xff] << 8) & 0xff000000)
+#define TE42(i) (Te0[((i) >> 16) & 0xff] & 0x00ff0000)
+#define TE43(i) (Te0[((i) >> 8) & 0xff] & 0x0000ff00)
+#define TE44(i) ((Te0[(i) & 0xff] >> 8) & 0x000000ff)
+#define TE421(i) ((Te0[((i) >> 16) & 0xff] << 8) & 0xff000000)
+#define TE432(i) (Te0[((i) >> 8) & 0xff] & 0x00ff0000)
+#define TE443(i) (Te0[(i) & 0xff] & 0x0000ff00)
+#define TE414(i) ((Te0[((i) >> 24) & 0xff] >> 8) & 0x000000ff)
+#define TE4(i) ((Te0[(i)] >> 8) & 0x000000ff)
+
+#define TD0(i) Td0[((i) >> 24) & 0xff]
+#define TD1(i) rotr(Td0[((i) >> 16) & 0xff], 8)
+#define TD2(i) rotr(Td0[((i) >> 8) & 0xff], 16)
+#define TD3(i) rotr(Td0[(i) & 0xff], 24)
+#define TD41(i) (Td4s[((i) >> 24) & 0xff] << 24)
+#define TD42(i) (Td4s[((i) >> 16) & 0xff] << 16)
+#define TD43(i) (Td4s[((i) >> 8) & 0xff] << 8)
+#define TD44(i) (Td4s[(i) & 0xff])
+#define TD0_(i) Td0[(i) & 0xff]
+#define TD1_(i) rotr(Td0[(i) & 0xff], 8)
+#define TD2_(i) rotr(Td0[(i) & 0xff], 16)
+#define TD3_(i) rotr(Td0[(i) & 0xff], 24)
+
+#endif /* AES_SMALL_TABLES */
+
+#define SWAP(x) (_lrotl(x, 8) & 0x00ff00ff | _lrotr(x, 8) & 0xff00ff00)
+
+#ifdef _MSC_VER
+#define GETU32(p) SWAP(*((u32 *)(p)))
+#define PUTU32(ct, st) { *((u32 *)(ct)) = SWAP((st)); }
+#else
+#define GETU32(pt) (((u32)(pt)[0] << 24) ^ ((u32)(pt)[1] << 16) ^ \
+((u32)(pt)[2] << 8) ^ ((u32)(pt)[3]))
+#define PUTU32(ct, st) { \
+(ct)[0] = (u8)((st) >> 24); (ct)[1] = (u8)((st) >> 16); \
+(ct)[2] = (u8)((st) >> 8); (ct)[3] = (u8)(st); }
+#endif
+
+/**
+ * Expand the cipher key into the encryption key schedule.
+ *
+ * @return the number of rounds for the given cipher key size.
+ */
+static void rijndaelKeySetupEnc(u32 rk[/*44*/], const u8 cipherKey[])
+{
+ int i;
+ u32 temp;
+
+ rk[0] = GETU32(cipherKey );
+ rk[1] = GETU32(cipherKey + 4);
+ rk[2] = GETU32(cipherKey + 8);
+ rk[3] = GETU32(cipherKey + 12);
+ for (i = 0; i < 10; i++) {
+ temp = rk[3];
+ rk[4] = rk[0] ^
+ TE421(temp) ^ TE432(temp) ^ TE443(temp) ^ TE414(temp) ^
+ RCON(i);
+ rk[5] = rk[1] ^ rk[4];
+ rk[6] = rk[2] ^ rk[5];
+ rk[7] = rk[3] ^ rk[6];
+ rk += 4;
+ }
+}
+
+#ifndef CONFIG_NO_AES_DECRYPT
+/**
+ * Expand the cipher key into the decryption key schedule.
+ *
+ * @return the number of rounds for the given cipher key size.
+ */
+static void rijndaelKeySetupDec(u32 rk[/*44*/], const u8 cipherKey[])
+{
+ int Nr = 10, i, j;
+ u32 temp;
+
+ /* expand the cipher key: */
+ rijndaelKeySetupEnc(rk, cipherKey);
+ /* invert the order of the round keys: */
+ for (i = 0, j = 4*Nr; i < j; i += 4, j -= 4) {
+ temp = rk[i ]; rk[i ] = rk[j ]; rk[j ] = temp;
+ temp = rk[i + 1]; rk[i + 1] = rk[j + 1]; rk[j + 1] = temp;
+ temp = rk[i + 2]; rk[i + 2] = rk[j + 2]; rk[j + 2] = temp;
+ temp = rk[i + 3]; rk[i + 3] = rk[j + 3]; rk[j + 3] = temp;
+ }
+ /* apply the inverse MixColumn transform to all round keys but the
+ * first and the last: */
+ for (i = 1; i < Nr; i++) {
+ rk += 4;
+ for (j = 0; j < 4; j++) {
+ rk[j] = TD0_(TE4((rk[j] >> 24) )) ^
+ TD1_(TE4((rk[j] >> 16) & 0xff)) ^
+ TD2_(TE4((rk[j] >> 8) & 0xff)) ^
+ TD3_(TE4((rk[j] ) & 0xff));
+ }
+ }
+}
+#endif /* CONFIG_NO_AES_DECRYPT */
+
+#ifndef CONFIG_NO_AES_ENCRYPT
+static void rijndaelEncrypt(const u32 rk[/*44*/], const u8 pt[16], u8 ct[16])
+{
+ u32 s0, s1, s2, s3, t0, t1, t2, t3;
+ const int Nr = 10;
+#ifndef FULL_UNROLL
+ int r;
+#endif /* ?FULL_UNROLL */
+
+ /*
+ * map byte array block to cipher state
+ * and add initial round key:
+ */
+ s0 = GETU32(pt ) ^ rk[0];
+ s1 = GETU32(pt + 4) ^ rk[1];
+ s2 = GETU32(pt + 8) ^ rk[2];
+ s3 = GETU32(pt + 12) ^ rk[3];
+
+#define ROUND(i,d,s) \
+d##0 = TE0(s##0) ^ TE1(s##1) ^ TE2(s##2) ^ TE3(s##3) ^ rk[4 * i]; \
+d##1 = TE0(s##1) ^ TE1(s##2) ^ TE2(s##3) ^ TE3(s##0) ^ rk[4 * i + 1]; \
+d##2 = TE0(s##2) ^ TE1(s##3) ^ TE2(s##0) ^ TE3(s##1) ^ rk[4 * i + 2]; \
+d##3 = TE0(s##3) ^ TE1(s##0) ^ TE2(s##1) ^ TE3(s##2) ^ rk[4 * i + 3]
+
+#ifdef FULL_UNROLL
+
+ ROUND(1,t,s);
+ ROUND(2,s,t);
+ ROUND(3,t,s);
+ ROUND(4,s,t);
+ ROUND(5,t,s);
+ ROUND(6,s,t);
+ ROUND(7,t,s);
+ ROUND(8,s,t);
+ ROUND(9,t,s);
+
+ rk += Nr << 2;
+
+#else /* !FULL_UNROLL */
+
+ /* Nr - 1 full rounds: */
+ r = Nr >> 1;
+ for (;;) {
+ ROUND(1,t,s);
+ rk += 8;
+ if (--r == 0)
+ break;
+ ROUND(0,s,t);
+ }
+
+#endif /* ?FULL_UNROLL */
+
+#undef ROUND
+
+ /*
+ * apply last round and
+ * map cipher state to byte array block:
+ */
+ s0 = TE41(t0) ^ TE42(t1) ^ TE43(t2) ^ TE44(t3) ^ rk[0];
+ PUTU32(ct , s0);
+ s1 = TE41(t1) ^ TE42(t2) ^ TE43(t3) ^ TE44(t0) ^ rk[1];
+ PUTU32(ct + 4, s1);
+ s2 = TE41(t2) ^ TE42(t3) ^ TE43(t0) ^ TE44(t1) ^ rk[2];
+ PUTU32(ct + 8, s2);
+ s3 = TE41(t3) ^ TE42(t0) ^ TE43(t1) ^ TE44(t2) ^ rk[3];
+ PUTU32(ct + 12, s3);
+}
+#endif /* CONFIG_NO_AES_ENCRYPT */
+
+static void rijndaelDecrypt(const u32 rk[/*44*/], const u8 ct[16], u8 pt[16])
+{
+ u32 s0, s1, s2, s3, t0, t1, t2, t3;
+ const int Nr = 10;
+#ifndef FULL_UNROLL
+ int r;
+#endif /* ?FULL_UNROLL */
+
+ /*
+ * map byte array block to cipher state
+ * and add initial round key:
+ */
+ s0 = GETU32(ct ) ^ rk[0];
+ s1 = GETU32(ct + 4) ^ rk[1];
+ s2 = GETU32(ct + 8) ^ rk[2];
+ s3 = GETU32(ct + 12) ^ rk[3];
+
+#define ROUND(i,d,s) \
+d##0 = TD0(s##0) ^ TD1(s##3) ^ TD2(s##2) ^ TD3(s##1) ^ rk[4 * i]; \
+d##1 = TD0(s##1) ^ TD1(s##0) ^ TD2(s##3) ^ TD3(s##2) ^ rk[4 * i + 1]; \
+d##2 = TD0(s##2) ^ TD1(s##1) ^ TD2(s##0) ^ TD3(s##3) ^ rk[4 * i + 2]; \
+d##3 = TD0(s##3) ^ TD1(s##2) ^ TD2(s##1) ^ TD3(s##0) ^ rk[4 * i + 3]
+
+#ifdef FULL_UNROLL
+
+ ROUND(1,t,s);
+ ROUND(2,s,t);
+ ROUND(3,t,s);
+ ROUND(4,s,t);
+ ROUND(5,t,s);
+ ROUND(6,s,t);
+ ROUND(7,t,s);
+ ROUND(8,s,t);
+ ROUND(9,t,s);
+
+ rk += Nr << 2;
+
+#else /* !FULL_UNROLL */
+
+ /* Nr - 1 full rounds: */
+ r = Nr >> 1;
+ for (;;) {
+ ROUND(1,t,s);
+ rk += 8;
+ if (--r == 0)
+ break;
+ ROUND(0,s,t);
+ }
+
+#endif /* ?FULL_UNROLL */
+
+#undef ROUND
+
+ /*
+ * apply last round and
+ * map cipher state to byte array block:
+ */
+ s0 = TD41(t0) ^ TD42(t3) ^ TD43(t2) ^ TD44(t1) ^ rk[0];
+ PUTU32(pt , s0);
+ s1 = TD41(t1) ^ TD42(t0) ^ TD43(t3) ^ TD44(t2) ^ rk[1];
+ PUTU32(pt + 4, s1);
+ s2 = TD41(t2) ^ TD42(t1) ^ TD43(t0) ^ TD44(t3) ^ rk[2];
+ PUTU32(pt + 8, s2);
+ s3 = TD41(t3) ^ TD42(t2) ^ TD43(t1) ^ TD44(t0) ^ rk[3];
+ PUTU32(pt + 12, s3);
+}
+
+#define AES_PRIV_SIZE 44
diff --git a/package/network/services/ead/src/.svn/text-base/ead-client.c.svn-base b/package/network/services/ead/src/.svn/text-base/ead-client.c.svn-base
new file mode 100644
index 0000000..54d8b13
--- /dev/null
+++ b/package/network/services/ead/src/.svn/text-base/ead-client.c.svn-base
@@ -0,0 +1,433 @@
+/*
+ * Client for the Emergency Access Daemon
+ * Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation
+ *
+ * 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.
+ */
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <stdio.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <string.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <t_pwd.h>
+#include <t_read.h>
+#include <t_sha.h>
+#include <t_defines.h>
+#include <t_client.h>
+#include "ead.h"
+#include "ead-crypt.h"
+
+#include "pw_encrypt_md5.c"
+
+#define EAD_TIMEOUT 400
+#define EAD_TIMEOUT_LONG 2000
+
+static char msgbuf[1500];
+static struct ead_msg *msg = (struct ead_msg *) msgbuf;
+static uint16_t nid = 0xffff;
+struct sockaddr_in local, remote;
+static int s = 0;
+static int sockflags;
+static struct in_addr serverip = {
+ .s_addr = 0x01010101 /* dummy */
+};
+
+static unsigned char *skey = NULL;
+static unsigned char bbuf[MAXPARAMLEN];
+static unsigned char saltbuf[MAXSALTLEN];
+static char *username = NULL;
+static char password[MAXPARAMLEN] = "";
+static char pw_md5[MD5_OUT_BUFSIZE];
+static char pw_salt[MAXSALTLEN];
+
+static struct t_client *tc = NULL;
+static struct t_num salt = { .data = saltbuf };
+static struct t_num *A, B;
+static struct t_preconf *tcp;
+static int auth_type = EAD_AUTH_DEFAULT;
+static int timeout = EAD_TIMEOUT;
+static uint16_t sid = 0;
+
+static void
+set_nonblock(int enable)
+{
+ if (enable == !!(sockflags & O_NONBLOCK));
+ return;
+
+ sockflags ^= O_NONBLOCK;
+ fcntl(s, F_SETFL, sockflags);
+}
+
+static int
+send_packet(int type, bool (*handler)(void), unsigned int max)
+{
+ struct timeval tv;
+ fd_set fds;
+ int nfds;
+ int len;
+ int res = 0;
+
+ type = htonl(type);
+ memcpy(&msg->ip, &serverip.s_addr, sizeof(msg->ip));
+ set_nonblock(0);
+ sendto(s, msgbuf, sizeof(struct ead_msg) + ntohl(msg->len), 0, (struct sockaddr *) &remote, sizeof(remote));
+ set_nonblock(1);
+
+ tv.tv_sec = timeout / 1000;
+ tv.tv_usec = (timeout % 1000) * 1000;
+
+ FD_ZERO(&fds);
+ do {
+ FD_SET(s, &fds);
+ nfds = select(s + 1, &fds, NULL, NULL, &tv);
+
+ if (nfds <= 0)
+ break;
+
+ if (!FD_ISSET(s, &fds))
+ break;
+
+ len = read(s, msgbuf, sizeof(msgbuf));
+ if (len < 0)
+ break;
+
+ if (len < sizeof(struct ead_msg))
+ continue;
+
+ if (len < sizeof(struct ead_msg) + ntohl(msg->len))
+ continue;
+
+ if (msg->magic != htonl(EAD_MAGIC))
+ continue;
+
+ if ((nid != 0xffff) && (ntohs(msg->nid) != nid))
+ continue;
+
+ if (msg->type != type)
+ continue;
+
+ if (handler())
+ res++;
+
+ if ((max > 0) && (res >= max))
+ break;
+ } while (1);
+
+ return res;
+}
+
+static void
+prepare_password(void)
+{
+ switch(auth_type) {
+ case EAD_AUTH_DEFAULT:
+ break;
+ case EAD_AUTH_MD5:
+ md5_crypt(pw_md5, (unsigned char *) password, (unsigned char *) pw_salt);
+ strncpy(password, pw_md5, sizeof(password));
+ break;
+ }
+}
+
+static bool
+handle_pong(void)
+{
+ struct ead_msg_pong *pong = EAD_DATA(msg, pong);
+ int len = ntohl(msg->len) - sizeof(struct ead_msg_pong);
+
+ if (len <= 0)
+ return false;
+
+ pong->name[len] = 0;
+ auth_type = ntohs(pong->auth_type);
+ if (nid == 0xffff)
+ printf("%04x: %s\n", ntohs(msg->nid), pong->name);
+ sid = msg->sid;
+ return true;
+}
+
+static bool
+handle_prime(void)
+{
+ struct ead_msg_salt *sb = EAD_DATA(msg, salt);
+
+ salt.len = sb->len;
+ memcpy(salt.data, sb->salt, salt.len);
+
+ if (auth_type == EAD_AUTH_MD5) {
+ memcpy(pw_salt, sb->ext_salt, MAXSALTLEN);
+ pw_salt[MAXSALTLEN - 1] = 0;
+ }
+
+ tcp = t_getpreparam(sb->prime);
+ tc = t_clientopen(username, &tcp->modulus, &tcp->generator, &salt);
+ if (!tc) {
+ fprintf(stderr, "Client open failed\n");
+ return false;
+ }
+
+ return true;
+}
+
+static bool
+handle_b(void)
+{
+ struct ead_msg_number *num = EAD_DATA(msg, number);
+ int len = ntohl(msg->len) - sizeof(struct ead_msg_number);
+
+ B.data = bbuf;
+ B.len = len;
+ memcpy(bbuf, num->data, len);
+ return true;
+}
+
+static bool
+handle_none(void)
+{
+ return true;
+}
+
+static bool
+handle_done_auth(void)
+{
+ struct ead_msg_auth *auth = EAD_DATA(msg, auth);
+ if (t_clientverify(tc, auth->data) != 0) {
+ fprintf(stderr, "Client auth verify failed\n");
+ return false;
+ }
+ return true;
+}
+
+static bool
+handle_cmd_data(void)
+{
+ struct ead_msg_cmd_data *cmd = EAD_ENC_DATA(msg, cmd_data);
+ int datalen = ead_decrypt_message(msg) - sizeof(struct ead_msg_cmd_data);
+
+ if (datalen < 0)
+ return false;
+
+ if (datalen > 0) {
+ write(1, cmd->data, datalen);
+ }
+
+ return !!cmd->done;
+}
+static int
+send_ping(void)
+{
+ msg->type = htonl(EAD_TYPE_PING);
+ msg->len = 0;
+ return send_packet(EAD_TYPE_PONG, handle_pong, (nid == 0xffff ? 0 : 1));
+}
+
+static int
+send_username(void)
+{
+ msg->type = htonl(EAD_TYPE_SET_USERNAME);
+ msg->len = htonl(sizeof(struct ead_msg_user));
+ strcpy(EAD_DATA(msg, user)->username, username);
+ return send_packet(EAD_TYPE_ACK_USERNAME, handle_none, 1);
+}
+
+static int
+get_prime(void)
+{
+ msg->type = htonl(EAD_TYPE_GET_PRIME);
+ msg->len = 0;
+ return send_packet(EAD_TYPE_PRIME, handle_prime, 1);
+}
+
+static int
+send_a(void)
+{
+ struct ead_msg_number *num = EAD_DATA(msg, number);
+ A = t_clientgenexp(tc);
+ msg->type = htonl(EAD_TYPE_SEND_A);
+ msg->len = htonl(sizeof(struct ead_msg_number) + A->len);
+ memcpy(num->data, A->data, A->len);
+ return send_packet(EAD_TYPE_SEND_B, handle_b, 1);
+}
+
+static int
+send_auth(void)
+{
+ struct ead_msg_auth *auth = EAD_DATA(msg, auth);
+
+ prepare_password();
+ t_clientpasswd(tc, password);
+ skey = t_clientgetkey(tc, &B);
+ if (!skey)
+ return 0;
+
+ ead_set_key(skey);
+ msg->type = htonl(EAD_TYPE_SEND_AUTH);
+ msg->len = htonl(sizeof(struct ead_msg_auth));
+ memcpy(auth->data, t_clientresponse(tc), sizeof(auth->data));
+ return send_packet(EAD_TYPE_DONE_AUTH, handle_done_auth, 1);
+}
+
+static int
+send_command(const char *command)
+{
+ struct ead_msg_cmd *cmd = EAD_ENC_DATA(msg, cmd);
+
+ msg->type = htonl(EAD_TYPE_SEND_CMD);
+ cmd->type = htons(EAD_CMD_NORMAL);
+ cmd->timeout = htons(10);
+ strncpy((char *)cmd->data, command, 1024);
+ ead_encrypt_message(msg, sizeof(struct ead_msg_cmd) + strlen(command) + 1);
+ return send_packet(EAD_TYPE_RESULT_CMD, handle_cmd_data, 1);
+}
+
+
+static int
+usage(const char *prog)
+{
+ fprintf(stderr, "Usage: %s [-s <addr>] [-b <addr>] <node> <username>[:<password>] <command>\n"
+ "\n"
+ "\t-s <addr>: Set the server's source address to <addr>\n"
+ "\t-b <addr>: Set the broadcast address to <addr>\n"
+ "\t<node>: Node ID (4 digits hex)\n"
+ "\t<username>: Username to authenticate with\n"
+ "\n"
+ "\tPassing no arguments shows a list of active nodes on the network\n"
+ "\n", prog);
+ return -1;
+}
+
+
+int main(int argc, char **argv)
+{
+ int val = 1;
+ char *st = NULL;
+ const char *command = NULL;
+ const char *prog = argv[0];
+ int ch;
+
+ msg->magic = htonl(EAD_MAGIC);
+ msg->sid = 0;
+
+ memset(&local, 0, sizeof(local));
+ memset(&remote, 0, sizeof(remote));
+
+ remote.sin_family = AF_INET;
+ remote.sin_addr.s_addr = 0xffffffff;
+ remote.sin_port = htons(EAD_PORT);
+
+ local.sin_family = AF_INET;
+ local.sin_addr.s_addr = INADDR_ANY;
+ local.sin_port = 0;
+
+ while ((ch = getopt(argc, argv, "b:s:h")) != -1) {
+ switch(ch) {
+ case 's':
+ inet_aton(optarg, &serverip);
+ break;
+ case 'b':
+ inet_aton(optarg, &remote.sin_addr);
+ break;
+ case 'h':
+ return usage(prog);
+ }
+ }
+ argv += optind;
+ argc -= optind;
+
+ switch(argc) {
+ case 3:
+ command = argv[2];
+ /* fall through */
+ case 2:
+ username = argv[1];
+ st = strchr(username, ':');
+ if (st) {
+ *st = 0;
+ st++;
+ strncpy(password, st, sizeof(password));
+ password[sizeof(password) - 1] = 0;
+ /* hide command line password */
+ memset(st, 0, strlen(st));
+ }
+ /* fall through */
+ case 1:
+ nid = strtoul(argv[0], &st, 16);
+ if (st && st[0] != 0)
+ return usage(prog);
+ /* fall through */
+ case 0:
+ break;
+ default:
+ return usage(prog);
+ }
+
+ msg->nid = htons(nid);
+ s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
+ if (s < 0) {
+ perror("socket");
+ return -1;
+ }
+
+ setsockopt(s, SOL_SOCKET, SO_BROADCAST, &val, sizeof(val));
+
+ if (bind(s, (struct sockaddr *)&local, sizeof(local)) < 0) {
+ perror("bind");
+ return -1;
+ }
+ sockflags = fcntl(s, F_GETFL);
+
+ if (!send_ping()) {
+ fprintf(stderr, "No devices found\n");
+ return 1;
+ }
+
+ if (nid == 0xffff)
+ return 0;
+
+ if (!username || !password[0])
+ return 0;
+
+ if (!send_username()) {
+ fprintf(stderr, "Device did not accept user name\n");
+ return 1;
+ }
+ timeout = EAD_TIMEOUT_LONG;
+ if (!get_prime()) {
+ fprintf(stderr, "Failed to get user password info\n");
+ return 1;
+ }
+ if (!send_a()) {
+ fprintf(stderr, "Failed to send local authentication data\n");
+ return 1;
+ }
+ if (!send_auth()) {
+ fprintf(stderr, "Authentication failed\n");
+ return 1;
+ }
+ if (!command) {
+ fprintf(stderr, "Authentication succesful\n");
+ return 0;
+ }
+ if (!send_command(command)) {
+ fprintf(stderr, "Command failed\n");
+ return 1;
+ }
+
+ return 0;
+}
diff --git a/package/network/services/ead/src/.svn/text-base/ead-crypt.c.svn-base b/package/network/services/ead/src/.svn/text-base/ead-crypt.c.svn-base
new file mode 100644
index 0000000..0372172
--- /dev/null
+++ b/package/network/services/ead/src/.svn/text-base/ead-crypt.c.svn-base
@@ -0,0 +1,179 @@
+/*
+ * Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation
+ *
+ * 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.
+ */
+
+#include <stddef.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <string.h>
+#include <unistd.h>
+#include <stdio.h>
+#include "ead.h"
+
+#include "sha1.c"
+#include "aes.c"
+
+#if EAD_DEBUGLEVEL >= 1
+#define DEBUG(n, format, ...) do { \
+ if (EAD_DEBUGLEVEL >= n) \
+ fprintf(stderr, format, ##__VA_ARGS__); \
+} while (0);
+
+#else
+#define DEBUG(n, format, ...) do {} while(0)
+#endif
+
+
+static uint32_t aes_enc_ctx[AES_PRIV_SIZE];
+static uint32_t aes_dec_ctx[AES_PRIV_SIZE];
+static uint32_t ead_rx_iv;
+static uint32_t ead_tx_iv;
+static uint32_t ivofs_vec;
+static unsigned int ivofs_idx = 0;
+static uint32_t W[80]; /* work space for sha1 */
+
+#define EAD_ENC_PAD 64
+
+void
+ead_set_key(unsigned char *skey)
+{
+ uint32_t *ivp = (uint32_t *)skey;
+
+ memset(aes_enc_ctx, 0, sizeof(aes_enc_ctx));
+ memset(aes_dec_ctx, 0, sizeof(aes_dec_ctx));
+
+ /* first 32 bytes of skey are used as aes key for
+ * encryption and decryption */
+ rijndaelKeySetupEnc(aes_enc_ctx, skey);
+ rijndaelKeySetupDec(aes_dec_ctx, skey);
+
+ /* the following bytes are used as initialization vector for messages
+ * (highest byte cleared to avoid overflow) */
+ ivp += 8;
+ ead_rx_iv = ntohl(*ivp) & 0x00ffffff;
+ ead_tx_iv = ead_rx_iv;
+
+ /* the last bytes are used to feed the random iv increment */
+ ivp++;
+ ivofs_vec = *ivp;
+}
+
+
+static bool
+ead_check_rx_iv(uint32_t iv)
+{
+ if (iv <= ead_rx_iv)
+ return false;
+
+ if (iv > ead_rx_iv + EAD_MAX_IV_INCR)
+ return false;
+
+ ead_rx_iv = iv;
+ return true;
+}
+
+
+static uint32_t
+ead_get_tx_iv(void)
+{
+ unsigned int ofs;
+
+ ofs = 1 + ((ivofs_vec >> 2 * ivofs_idx) & 0x3);
+ ivofs_idx = (ivofs_idx + 1) % 16;
+ ead_tx_iv += ofs;
+
+ return ead_tx_iv;
+}
+
+static void
+ead_hash_message(struct ead_msg_encrypted *enc, uint32_t *hash, int len)
+{
+ unsigned char *data = (unsigned char *) enc;
+
+ /* hash the packet with the stored hash part initialized to zero */
+ sha_init(hash);
+ memset(enc->hash, 0, sizeof(enc->hash));
+ while (len > 0) {
+ sha_transform(hash, data, W);
+ len -= 64;
+ data += 64;
+ }
+}
+
+void
+ead_encrypt_message(struct ead_msg *msg, unsigned int len)
+{
+ struct ead_msg_encrypted *enc = EAD_DATA(msg, enc);
+ unsigned char *data = (unsigned char *) enc;
+ uint32_t hash[5];
+ int enclen, i;
+
+ len += sizeof(struct ead_msg_encrypted);
+ enc->pad = (EAD_ENC_PAD - (len % EAD_ENC_PAD)) % EAD_ENC_PAD;
+ enclen = len + enc->pad;
+ msg->len = htonl(enclen);
+ enc->iv = htonl(ead_get_tx_iv());
+
+ ead_hash_message(enc, hash, enclen);
+ for (i = 0; i < 5; i++)
+ enc->hash[i] = htonl(hash[i]);
+ DEBUG(2, "SHA1 generate (0x%08x), len=%d\n", enc->hash[0], enclen);
+
+ while (enclen > 0) {
+ rijndaelEncrypt(aes_enc_ctx, data, data);
+ data += 16;
+ enclen -= 16;
+ }
+}
+
+int
+ead_decrypt_message(struct ead_msg *msg)
+{
+ struct ead_msg_encrypted *enc = EAD_DATA(msg, enc);
+ unsigned char *data = (unsigned char *) enc;
+ uint32_t hash_old[5], hash_new[5];
+ int len = ntohl(msg->len);
+ int i, enclen = len;
+
+ if (!len || (len % EAD_ENC_PAD > 0))
+ return 0;
+
+ while (len > 0) {
+ rijndaelDecrypt(aes_dec_ctx, data, data);
+ data += 16;
+ len -= 16;
+ }
+
+ data = (unsigned char *) enc;
+
+ if (enc->pad >= EAD_ENC_PAD) {
+ DEBUG(2, "Invalid padding length\n");
+ return 0;
+ }
+
+ if (!ead_check_rx_iv(ntohl(enc->iv))) {
+ DEBUG(2, "RX IV mismatch (0x%08x <> 0x%08x)\n", ead_rx_iv, ntohl(enc->iv));
+ return 0;
+ }
+
+ for (i = 0; i < 5; i++)
+ hash_old[i] = ntohl(enc->hash[i]);
+ ead_hash_message(enc, hash_new, enclen);
+ if (memcmp(hash_old, hash_new, sizeof(hash_old)) != 0) {
+ DEBUG(2, "SHA1 mismatch (0x%08x != 0x%08x), len=%d\n", hash_old[0], hash_new[0], enclen);
+ return 0;
+ }
+
+ enclen -= enc->pad + sizeof(struct ead_msg_encrypted);
+ return enclen;
+}
diff --git a/package/network/services/ead/src/.svn/text-base/ead-crypt.h.svn-base b/package/network/services/ead/src/.svn/text-base/ead-crypt.h.svn-base
new file mode 100644
index 0000000..831ec8a
--- /dev/null
+++ b/package/network/services/ead/src/.svn/text-base/ead-crypt.h.svn-base
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation
+ *
+ * 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.
+ */
+
+#ifndef __EAD_CRYPT_H
+#define __EAD_CRYPT_H
+
+extern void ead_set_key(unsigned char *skey);
+extern void ead_encrypt_message(struct ead_msg *msg, unsigned int len);
+extern int ead_decrypt_message(struct ead_msg *msg);
+
+#endif
diff --git a/package/network/services/ead/src/.svn/text-base/ead-pcap.h.svn-base b/package/network/services/ead/src/.svn/text-base/ead-pcap.h.svn-base
new file mode 100644
index 0000000..0652ab4
--- /dev/null
+++ b/package/network/services/ead/src/.svn/text-base/ead-pcap.h.svn-base
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2001-2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file was part of the uIP TCP/IP stack.
+ *
+ */
+#ifndef __EAD_PCAP_H
+#define __EAD_PCAP_H
+
+#include <net/ethernet.h>
+#include <stdint.h>
+#include "ead.h"
+
+typedef uint8_t u8_t;
+typedef uint16_t u16_t;
+
+/* The UDP and IP headers. */
+struct ead_packet {
+ struct ether_header eh;
+ /* IP header. */
+ u8_t vhl,
+ tos,
+ len[2],
+ ipid[2],
+ ipoffset[2],
+ ttl,
+ proto;
+ u16_t ipchksum;
+ u16_t srcipaddr[2],
+ destipaddr[2];
+
+ /* UDP header. */
+ u16_t srcport,
+ destport;
+ u16_t udplen;
+ u16_t udpchksum;
+
+ struct ead_msg msg;
+} __attribute__((packed));
+
+#define UIP_PROTO_UDP 17
+#define UIP_IPH_LEN 20 /* Size of IP header */
+#define UIP_UDPH_LEN 8 /* Size of UDP header */
+#define UIP_IPUDPH_LEN (UIP_UDPH_LEN + UIP_IPH_LEN)
+
+#endif
diff --git a/package/network/services/ead/src/.svn/text-base/ead.c.svn-base b/package/network/services/ead/src/.svn/text-base/ead.c.svn-base
new file mode 100644
index 0000000..3623520
--- /dev/null
+++ b/package/network/services/ead/src/.svn/text-base/ead.c.svn-base
@@ -0,0 +1,991 @@
+/*
+ * Emergency Access Daemon
+ * Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation
+ *
+ * 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.
+ */
+
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/select.h>
+#include <stdio.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <stdbool.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <pcap.h>
+#include <pcap-bpf.h>
+#include <t_pwd.h>
+#include <t_read.h>
+#include <t_sha.h>
+#include <t_defines.h>
+#include <t_server.h>
+
+#include "list.h"
+#include "ead.h"
+#include "ead-pcap.h"
+#include "ead-crypt.h"
+
+#include "filter.c"
+
+#ifdef linux
+#include "libbridge_init.c"
+#endif
+
+#ifdef linux
+#include <linux/if_packet.h>
+#endif
+
+#define PASSWD_FILE "/etc/passwd"
+
+#ifndef DEFAULT_IFNAME
+#define DEFAULT_IFNAME "eth0"
+#endif
+
+#ifndef DEFAULT_DEVNAME
+#define DEFAULT_DEVNAME "Unknown"
+#endif
+
+#define PCAP_MRU 1600
+#define PCAP_TIMEOUT 200
+
+#if EAD_DEBUGLEVEL >= 1
+#define DEBUG(n, format, ...) do { \
+ if (EAD_DEBUGLEVEL >= n) \
+ fprintf(stderr, format, ##__VA_ARGS__); \
+} while (0);
+
+#else
+#define DEBUG(n, format, ...) do {} while(0)
+#endif
+
+struct ead_instance {
+ struct list_head list;
+ char ifname[16];
+ int pid;
+ char id;
+#ifdef linux
+ char bridge[16];
+ bool br_check;
+#endif
+};
+
+static char ethmac[6] = "\x00\x13\x37\x00\x00\x00"; /* last 3 bytes will be randomized */
+static pcap_t *pcap_fp = NULL;
+static pcap_t *pcap_fp_rx = NULL;
+static char pktbuf_b[PCAP_MRU];
+static struct ead_packet *pktbuf = (struct ead_packet *)pktbuf_b;
+static u16_t nid = 0xffff; /* node id */
+static char username[32] = "";
+static int state = EAD_TYPE_SET_USERNAME;
+static const char *passwd_file = PASSWD_FILE;
+static const char password[MAXPARAMLEN];
+static bool child_pending = false;
+
+static unsigned char abuf[MAXPARAMLEN + 1];
+static unsigned char pwbuf[MAXPARAMLEN];
+static unsigned char saltbuf[MAXSALTLEN];
+static unsigned char pw_saltbuf[MAXSALTLEN];
+static struct list_head instances;
+static const char *dev_name = DEFAULT_DEVNAME;
+static bool nonfork = false;
+static struct ead_instance *instance = NULL;
+
+static struct t_pwent tpe = {
+ .name = username,
+ .index = 1,
+ .password.data = pwbuf,
+ .password.len = 0,
+ .salt.data = saltbuf,
+ .salt.len = 0,
+};
+struct t_confent *tce = NULL;
+static struct t_server *ts = NULL;
+static struct t_num A, *B = NULL;
+unsigned char *skey;
+
+static void
+set_recv_type(pcap_t *p, bool rx)
+{
+#ifdef PACKET_RECV_TYPE
+ struct sockaddr_ll sll;
+ struct ifreq ifr;
+ int ifindex, mask;
+ int fd, ret;
+
+ fd = pcap_get_selectable_fd(p);
+ if (fd < 0)
+ return;
+
+ if (rx)
+ mask = 1 << PACKET_BROADCAST;
+ else
+ mask = 0;
+
+ ret = setsockopt(fd, SOL_PACKET, PACKET_RECV_TYPE, &mask, sizeof(mask));
+#endif
+}
+
+
+static pcap_t *
+ead_open_pcap(const char *ifname, char *errbuf, bool rx)
+{
+ pcap_t *p;
+
+ p = pcap_create(ifname, errbuf);
+ if (p == NULL)
+ goto out;
+
+ pcap_set_snaplen(p, PCAP_MRU);
+ pcap_set_promisc(p, rx);
+ pcap_set_timeout(p, PCAP_TIMEOUT);
+#ifdef HAS_PROTO_EXTENSION
+ pcap_set_protocol(p, (rx ? htons(ETH_P_IP) : 0));
+#endif
+ pcap_set_buffer_size(p, (rx ? 10 : 1) * PCAP_MRU);
+ pcap_activate(p);
+ set_recv_type(p, rx);
+out:
+ return p;
+}
+
+static void
+get_random_bytes(void *ptr, int len)
+{
+ int fd;
+
+ fd = open("/dev/urandom", O_RDONLY);
+ if (fd < 0) {
+ perror("open");
+ exit(1);
+ }
+ read(fd, ptr, len);
+ close(fd);
+}
+
+static bool
+prepare_password(void)
+{
+ static char lbuf[1024];
+ unsigned char dig[SHA_DIGESTSIZE];
+ BigInteger x, v, n, g;
+ SHA1_CTX ctxt;
+ int ulen = strlen(username);
+ FILE *f;
+
+ lbuf[sizeof(lbuf) - 1] = 0;
+
+ f = fopen(passwd_file, "r");
+ if (!f)
+ return false;
+
+ while (fgets(lbuf, sizeof(lbuf) - 1, f) != NULL) {
+ char *str, *s2;
+
+ if (strncmp(lbuf, username, ulen) != 0)
+ continue;
+
+ if (lbuf[ulen] != ':')
+ continue;
+
+ str = &lbuf[ulen + 1];
+
+ if (strncmp(str, "$1$", 3) != 0)
+ continue;
+
+ s2 = strchr(str + 3, '$');
+ if (!s2)
+ continue;
+
+ if (s2 - str >= MAXSALTLEN)
+ continue;
+
+ strncpy((char *) pw_saltbuf, str, s2 - str);
+ pw_saltbuf[s2 - str] = 0;
+
+ s2 = strchr(s2, ':');
+ if (!s2)
+ continue;
+
+ *s2 = 0;
+ if (s2 - str >= MAXPARAMLEN)
+ continue;
+
+ strncpy((char *)password, str, MAXPARAMLEN);
+ fclose(f);
+ goto hash_password;
+ }
+
+ /* not found */
+ fclose(f);
+ return false;
+
+hash_password:
+ tce = gettcid(tpe.index);
+ do {
+ t_random(tpe.password.data, SALTLEN);
+ } while (memcmp(saltbuf, (char *)dig, sizeof(saltbuf)) == 0);
+ if (saltbuf[0] == 0)
+ saltbuf[0] = 0xff;
+
+ n = BigIntegerFromBytes(tce->modulus.data, tce->modulus.len);
+ g = BigIntegerFromBytes(tce->generator.data, tce->generator.len);
+ v = BigIntegerFromInt(0);
+
+ SHA1Init(&ctxt);
+ SHA1Update(&ctxt, (unsigned char *) username, strlen(username));
+ SHA1Update(&ctxt, (unsigned char *) ":", 1);
+ SHA1Update(&ctxt, (unsigned char *) password, strlen(password));
+ SHA1Final(dig, &ctxt);
+
+ SHA1Init(&ctxt);
+ SHA1Update(&ctxt, saltbuf, tpe.salt.len);
+ SHA1Update(&ctxt, dig, sizeof(dig));
+ SHA1Final(dig, &ctxt);
+
+ /* x = H(s, H(u, ':', p)) */
+ x = BigIntegerFromBytes(dig, sizeof(dig));
+
+ BigIntegerModExp(v, g, x, n);
+ tpe.password.len = BigIntegerToBytes(v, (unsigned char *)pwbuf);
+
+ BigIntegerFree(v);
+ BigIntegerFree(x);
+ BigIntegerFree(g);
+ BigIntegerFree(n);
+ return true;
+}
+
+static u16_t
+chksum(u16_t sum, const u8_t *data, u16_t len)
+{
+ u16_t t;
+ const u8_t *dataptr;
+ const u8_t *last_byte;
+
+ dataptr = data;
+ last_byte = data + len - 1;
+
+ while(dataptr < last_byte) { /* At least two more bytes */
+ t = (dataptr[0] << 8) + dataptr[1];
+ sum += t;
+ if(sum < t) {
+ sum++; /* carry */
+ }
+ dataptr += 2;
+ }
+
+ if(dataptr == last_byte) {
+ t = (dataptr[0] << 8) + 0;
+ sum += t;
+ if(sum < t) {
+ sum++; /* carry */
+ }
+ }
+
+ /* Return sum in host byte order. */
+ return sum;
+}
+
+static void
+ead_send_packet_clone(struct ead_packet *pkt)
+{
+ u16_t len, sum;
+
+ memcpy(pktbuf, pkt, offsetof(struct ead_packet, msg));
+ memcpy(pktbuf->eh.ether_shost, ethmac, 6);
+ memcpy(pktbuf->eh.ether_dhost, pkt->eh.ether_shost, 6);
+
+ /* ip header */
+ len = sizeof(struct ead_packet) - sizeof(struct ether_header) + ntohl(pktbuf->msg.len);
+ pktbuf->len[0] = len >> 8;
+ pktbuf->len[1] = len & 0xff;
+ memcpy(pktbuf->srcipaddr, &pkt->msg.ip, 4);
+ memcpy(pktbuf->destipaddr, pkt->srcipaddr, 4);
+
+ /* ip checksum */
+ pktbuf->ipchksum = 0;
+ sum = chksum(0, (void *) &pktbuf->vhl, UIP_IPH_LEN);
+ if (sum == 0)
+ sum = 0xffff;
+ pktbuf->ipchksum = htons(~sum);
+
+ /* udp header */
+ pktbuf->srcport = pkt->destport;
+ pktbuf->destport = pkt->srcport;
+
+ /* udp checksum */
+ len -= UIP_IPH_LEN;
+ pktbuf->udplen = htons(len);
+ pktbuf->udpchksum = 0;
+ sum = len + UIP_PROTO_UDP;
+ sum = chksum(sum, (void *) &pktbuf->srcipaddr[0], 8); /* src, dest ip */
+ sum = chksum(sum, (void *) &pktbuf->srcport, len);
+ if (sum == 0)
+ sum = 0xffff;
+ pktbuf->udpchksum = htons(~sum);
+ pcap_sendpacket(pcap_fp, (void *) pktbuf, sizeof(struct ead_packet) + ntohl(pktbuf->msg.len));
+}
+
+static void
+set_state(int nstate)
+{
+ if (state == nstate)
+ return;
+
+ if (nstate < state) {
+ if ((nstate < EAD_TYPE_GET_PRIME) &&
+ (state >= EAD_TYPE_GET_PRIME)) {
+ t_serverclose(ts);
+ ts = NULL;
+ }
+ goto done;
+ }
+
+ switch(state) {
+ case EAD_TYPE_SET_USERNAME:
+ if (!prepare_password())
+ goto error;
+ ts = t_serveropenraw(&tpe, tce);
+ if (!ts)
+ goto error;
+ break;
+ case EAD_TYPE_GET_PRIME:
+ B = t_servergenexp(ts);
+ break;
+ case EAD_TYPE_SEND_A:
+ skey = t_servergetkey(ts, &A);
+ if (!skey)
+ goto error;
+
+ ead_set_key(skey);
+ break;
+ }
+done:
+ state = nstate;
+error:
+ return;
+}
+
+static bool
+handle_ping(struct ead_packet *pkt, int len, int *nstate)
+{
+ struct ead_msg *msg = &pktbuf->msg;
+ struct ead_msg_pong *pong = EAD_DATA(msg, pong);
+ int slen;
+
+ slen = strlen(dev_name);
+ if (slen > 1024)
+ slen = 1024;
+
+ msg->len = htonl(sizeof(struct ead_msg_pong) + slen);
+ strncpy(pong->name, dev_name, slen);
+ pong->name[slen] = 0;
+ pong->auth_type = htons(EAD_AUTH_MD5);
+
+ return true;
+}
+
+static bool
+handle_set_username(struct ead_packet *pkt, int len, int *nstate)
+{
+ struct ead_msg *msg = &pkt->msg;
+ struct ead_msg_user *user = EAD_DATA(msg, user);
+
+ set_state(EAD_TYPE_SET_USERNAME); /* clear old state */
+ strncpy(username, user->username, sizeof(username));
+ username[sizeof(username) - 1] = 0;
+
+ msg = &pktbuf->msg;
+ msg->len = 0;
+
+ *nstate = EAD_TYPE_GET_PRIME;
+ return true;
+}
+
+static bool
+handle_get_prime(struct ead_packet *pkt, int len, int *nstate)
+{
+ struct ead_msg *msg = &pktbuf->msg;
+ struct ead_msg_salt *salt = EAD_DATA(msg, salt);
+
+ msg->len = htonl(sizeof(struct ead_msg_salt));
+ salt->prime = tce->index - 1;
+ salt->len = ts->s.len;
+ memcpy(salt->salt, ts->s.data, ts->s.len);
+ memcpy(salt->ext_salt, pw_saltbuf, MAXSALTLEN);
+
+ *nstate = EAD_TYPE_SEND_A;
+ return true;
+}
+
+static bool
+handle_send_a(struct ead_packet *pkt, int len, int *nstate)
+{
+ struct ead_msg *msg = &pkt->msg;
+ struct ead_msg_number *number = EAD_DATA(msg, number);
+ len = ntohl(msg->len) - sizeof(struct ead_msg_number);
+
+ if (len > MAXPARAMLEN + 1)
+ return false;
+
+ A.len = len;
+ A.data = abuf;
+ memcpy(A.data, number->data, len);
+
+ msg = &pktbuf->msg;
+ number = EAD_DATA(msg, number);
+ msg->len = htonl(sizeof(struct ead_msg_number) + B->len);
+ memcpy(number->data, B->data, B->len);
+
+ *nstate = EAD_TYPE_SEND_AUTH;
+ return true;
+}
+
+static bool
+handle_send_auth(struct ead_packet *pkt, int len, int *nstate)
+{
+ struct ead_msg *msg = &pkt->msg;
+ struct ead_msg_auth *auth = EAD_DATA(msg, auth);
+
+ if (t_serververify(ts, auth->data) != 0) {
+ DEBUG(2, "Client authentication failed\n");
+ *nstate = EAD_TYPE_SET_USERNAME;
+ return false;
+ }
+
+ msg = &pktbuf->msg;
+ auth = EAD_DATA(msg, auth);
+ msg->len = htonl(sizeof(struct ead_msg_auth));
+
+ DEBUG(2, "Client authentication successful\n");
+ memcpy(auth->data, t_serverresponse(ts), sizeof(auth->data));
+
+ *nstate = EAD_TYPE_SEND_CMD;
+ return true;
+}
+
+static bool
+handle_send_cmd(struct ead_packet *pkt, int len, int *nstate)
+{
+ struct ead_msg *msg = &pkt->msg;
+ struct ead_msg_cmd *cmd = EAD_ENC_DATA(msg, cmd);
+ struct ead_msg_cmd_data *cmddata;
+ struct timeval tv, to, tn;
+ int pfd[2], fd;
+ fd_set fds;
+ pid_t pid;
+ bool stream = false;
+ int timeout;
+ int type;
+ int datalen;
+
+ datalen = ead_decrypt_message(msg) - sizeof(struct ead_msg_cmd);
+ if (datalen <= 0)
+ return false;
+
+ type = ntohs(cmd->type);
+ timeout = ntohs(cmd->timeout);
+
+ FD_ZERO(&fds);
+ cmd->data[datalen] = 0;
+ switch(type) {
+ case EAD_CMD_NORMAL:
+ if (pipe(pfd) < 0)
+ return false;
+
+ fcntl(pfd[0], F_SETFL, O_NONBLOCK | fcntl(pfd[0], F_GETFL));
+ child_pending = true;
+ pid = fork();
+ if (pid == 0) {
+ close(pfd[0]);
+ fd = open("/dev/null", O_RDWR);
+ if (fd > 0) {
+ dup2(fd, 0);
+ dup2(pfd[1], 1);
+ dup2(pfd[1], 2);
+ }
+ system((char *)cmd->data);
+ exit(0);
+ } else if (pid > 0) {
+ close(pfd[1]);
+ if (!timeout)
+ timeout = EAD_CMD_TIMEOUT;
+
+ stream = true;
+ break;
+ }
+ return false;
+ case EAD_CMD_BACKGROUND:
+ pid = fork();
+ if (pid == 0) {
+ /* close stdin, stdout, stderr, replace with fd to /dev/null */
+ fd = open("/dev/null", O_RDWR);
+ if (fd > 0) {
+ dup2(fd, 0);
+ dup2(fd, 1);
+ dup2(fd, 2);
+ }
+ system((char *)cmd->data);
+ exit(0);
+ } else if (pid > 0) {
+ break;
+ }
+ return false;
+ default:
+ return false;
+ }
+
+ msg = &pktbuf->msg;
+ cmddata = EAD_ENC_DATA(msg, cmd_data);
+
+ if (stream) {
+ int nfds, bytes;
+
+ /* send keepalive packets every 200 ms so that the client doesn't timeout */
+ gettimeofday(&to, NULL);
+ memcpy(&tn, &to, sizeof(tn));
+ tv.tv_usec = PCAP_TIMEOUT * 1000;
+ tv.tv_sec = 0;
+ do {
+ cmddata->done = 0;
+ FD_SET(pfd[0], &fds);
+ nfds = select(pfd[0] + 1, &fds, NULL, NULL, &tv);
+ bytes = 0;
+ if (nfds > 0) {
+ bytes = read(pfd[0], cmddata->data, 1024);
+ if (bytes < 0)
+ bytes = 0;
+ }
+ if (!bytes && !child_pending)
+ break;
+ DEBUG(3, "Sending %d bytes of console data, type=%d, timeout=%d\n", bytes, ntohl(msg->type), timeout);
+ ead_encrypt_message(msg, sizeof(struct ead_msg_cmd_data) + bytes);
+ ead_send_packet_clone(pkt);
+ gettimeofday(&tn, NULL);
+ } while (tn.tv_sec < to.tv_sec + timeout);
+ if (child_pending) {
+ kill(pid, SIGKILL);
+ return false;
+ }
+ }
+ cmddata->done = 1;
+ ead_encrypt_message(msg, sizeof(struct ead_msg_cmd_data));
+
+ return true;
+}
+
+
+
+static void
+parse_message(struct ead_packet *pkt, int len)
+{
+ bool (*handler)(struct ead_packet *pkt, int len, int *nstate);
+ int min_len = sizeof(struct ead_packet);
+ int nstate = state;
+ int type = ntohl(pkt->msg.type);
+
+ if ((type >= EAD_TYPE_GET_PRIME) &&
+ (state != type))
+ return;
+
+ if ((type != EAD_TYPE_PING) &&
+ ((ntohs(pkt->msg.sid) & EAD_INSTANCE_MASK) >>
+ EAD_INSTANCE_SHIFT) != instance->id)
+ return;
+
+ switch(type) {
+ case EAD_TYPE_PING:
+ handler = handle_ping;
+ break;
+ case EAD_TYPE_SET_USERNAME:
+ handler = handle_set_username;
+ min_len += sizeof(struct ead_msg_user);
+ break;
+ case EAD_TYPE_GET_PRIME:
+ handler = handle_get_prime;
+ break;
+ case EAD_TYPE_SEND_A:
+ handler = handle_send_a;
+ min_len += sizeof(struct ead_msg_number);
+ break;
+ case EAD_TYPE_SEND_AUTH:
+ handler = handle_send_auth;
+ min_len += sizeof(struct ead_msg_auth);
+ break;
+ case EAD_TYPE_SEND_CMD:
+ handler = handle_send_cmd;
+ min_len += sizeof(struct ead_msg_cmd) + sizeof(struct ead_msg_encrypted);
+ break;
+ default:
+ return;
+ }
+
+ if (len < min_len) {
+ DEBUG(2, "discarding packet: message too small\n");
+ return;
+ }
+
+ pktbuf->msg.magic = htonl(EAD_MAGIC);
+ pktbuf->msg.type = htonl(type + 1);
+ pktbuf->msg.nid = htons(nid);
+ pktbuf->msg.sid = pkt->msg.sid;
+ pktbuf->msg.len = 0;
+
+ if (handler(pkt, len, &nstate)) {
+ DEBUG(2, "sending response to packet type %d: %d\n", type + 1, ntohl(pktbuf->msg.len));
+ /* format response packet */
+ ead_send_packet_clone(pkt);
+ }
+ set_state(nstate);
+}
+
+static void
+handle_packet(u_char *user, const struct pcap_pkthdr *h, const u_char *bytes)
+{
+ struct ead_packet *pkt = (struct ead_packet *) bytes;
+
+ if (h->len < sizeof(struct ead_packet))
+ return;
+
+ if (pkt->eh.ether_type != htons(ETHERTYPE_IP))
+ return;
+
+ if (memcmp(pkt->eh.ether_dhost, "\xff\xff\xff\xff\xff\xff", 6) != 0)
+ return;
+
+ if (pkt->proto != UIP_PROTO_UDP)
+ return;
+
+ if (pkt->destport != htons(EAD_PORT))
+ return;
+
+ if (pkt->msg.magic != htonl(EAD_MAGIC))
+ return;
+
+ if (h->len < sizeof(struct ead_packet) + ntohl(pkt->msg.len))
+ return;
+
+ if ((pkt->msg.nid != 0xffff) &&
+ (pkt->msg.nid != htons(nid)))
+ return;
+
+ parse_message(pkt, h->len);
+}
+
+static void
+ead_pcap_reopen(bool first)
+{
+ static char errbuf[PCAP_ERRBUF_SIZE] = "";
+
+ if (pcap_fp_rx && (pcap_fp_rx != pcap_fp))
+ pcap_close(pcap_fp_rx);
+
+ if (pcap_fp)
+ pcap_close(pcap_fp);
+
+ pcap_fp_rx = NULL;
+ do {
+#ifdef linux
+ if (instance->bridge[0]) {
+ pcap_fp_rx = ead_open_pcap(instance->bridge, errbuf, 1);
+ pcap_fp = ead_open_pcap(instance->ifname, errbuf, 0);
+ } else
+#endif
+ {
+ pcap_fp = ead_open_pcap(instance->ifname, errbuf, 1);
+ }
+
+ if (!pcap_fp_rx)
+ pcap_fp_rx = pcap_fp;
+ if (first && !pcap_fp) {
+ DEBUG(1, "WARNING: unable to open interface '%s'\n", instance->ifname);
+ first = false;
+ }
+ if (!pcap_fp)
+ sleep(1);
+ } while (!pcap_fp);
+ pcap_setfilter(pcap_fp_rx, &pktfilter);
+}
+
+
+static void
+ead_pktloop(void)
+{
+ while (1) {
+ if (pcap_dispatch(pcap_fp_rx, 1, handle_packet, NULL) < 0) {
+ ead_pcap_reopen(false);
+ continue;
+ }
+ }
+}
+
+
+static int
+usage(const char *prog)
+{
+ fprintf(stderr, "Usage: %s [<options>]\n"
+ "Options:\n"
+ "\t-B Run in background mode\n"
+ "\t-d <device> Set the device to listen on\n"
+ "\t-D <name> Set the name of the device visible to clients\n"
+ "\t-p <file> Set the password file for authenticating\n"
+ "\t-P <file> Write a pidfile\n"
+ "\n", prog);
+ return -1;
+}
+
+static void
+server_handle_sigchld(int sig)
+{
+ struct ead_instance *in;
+ struct list_head *p;
+ int pid = 0;
+ wait(&pid);
+
+ list_for_each(p, &instances) {
+ in = list_entry(p, struct ead_instance, list);
+ if (pid != in->pid)
+ continue;
+
+ in->pid = 0;
+ break;
+ }
+}
+
+static void
+instance_handle_sigchld(int sig)
+{
+ int pid = 0;
+ wait(&pid);
+ child_pending = false;
+}
+
+static void
+start_server(struct ead_instance *i)
+{
+ if (!nonfork) {
+ i->pid = fork();
+ if (i->pid != 0) {
+ if (i->pid < 0)
+ i->pid = 0;
+ return;
+ }
+ }
+
+ instance = i;
+ signal(SIGCHLD, instance_handle_sigchld);
+ ead_pcap_reopen(true);
+ ead_pktloop();
+ pcap_close(pcap_fp);
+ if (pcap_fp_rx != pcap_fp)
+ pcap_close(pcap_fp_rx);
+
+ exit(0);
+}
+
+
+static void
+start_servers(bool restart)
+{
+ struct ead_instance *in;
+ struct list_head *p;
+
+ list_for_each(p, &instances) {
+ in = list_entry(p, struct ead_instance, list);
+ if (in->pid > 0)
+ continue;
+
+ sleep(1);
+ start_server(in);
+ }
+}
+
+static void
+stop_server(struct ead_instance *in, bool do_free)
+{
+ if (in->pid > 0)
+ kill(in->pid, SIGKILL);
+ in->pid = 0;
+ if (do_free) {
+ list_del(&in->list);
+ free(in);
+ }
+}
+
+static void
+server_handle_sigint(int sig)
+{
+ struct ead_instance *in;
+ struct list_head *p, *tmp;
+
+ list_for_each_safe(p, tmp, &instances) {
+ in = list_entry(p, struct ead_instance, list);
+ stop_server(in, true);
+ }
+ exit(1);
+}
+
+#ifdef linux
+static int
+check_bridge_port(const char *br, const char *port, void *arg)
+{
+ struct ead_instance *in;
+ struct list_head *p, *tmp;
+
+ list_for_each(p, &instances) {
+ in = list_entry(p, struct ead_instance, list);
+
+ if (strcmp(in->ifname, port) != 0)
+ continue;
+
+ in->br_check = true;
+ if (strcmp(in->bridge, br) == 0)
+ break;
+
+ strncpy(in->bridge, br, sizeof(in->bridge));
+ DEBUG(2, "assigning port %s to bridge %s\n", in->ifname, in->bridge);
+ stop_server(in, false);
+ }
+ return 0;
+}
+
+static int
+check_bridge(const char *name, void *arg)
+{
+ br_foreach_port(name, check_bridge_port, arg);
+ return 0;
+}
+#endif
+
+static void
+check_all_interfaces(void)
+{
+#ifdef linux
+ struct ead_instance *in;
+ struct list_head *p, *tmp;
+
+ br_foreach_bridge(check_bridge, NULL);
+
+ /* look for interfaces that are no longer part of a bridge */
+ list_for_each(p, &instances) {
+ in = list_entry(p, struct ead_instance, list);
+
+ if (in->br_check) {
+ in->br_check = false;
+ } else if (in->bridge[0]) {
+ DEBUG(2, "removing port %s from bridge %s\n", in->ifname, in->bridge);
+ in->bridge[0] = 0;
+ stop_server(in, false);
+ }
+ }
+#endif
+}
+
+
+int main(int argc, char **argv)
+{
+ struct ead_instance *in;
+ struct timeval tv;
+ const char *pidfile = NULL;
+ bool background = false;
+ int n_iface = 0;
+ int fd, ch;
+
+ if (argc == 1)
+ return usage(argv[0]);
+
+ INIT_LIST_HEAD(&instances);
+ while ((ch = getopt(argc, argv, "Bd:D:fhp:P:")) != -1) {
+ switch(ch) {
+ case 'B':
+ background = true;
+ break;
+ case 'f':
+ nonfork = true;
+ break;
+ case 'h':
+ return usage(argv[0]);
+ case 'd':
+ in = malloc(sizeof(struct ead_instance));
+ memset(in, 0, sizeof(struct ead_instance));
+ INIT_LIST_HEAD(&in->list);
+ strncpy(in->ifname, optarg, sizeof(in->ifname) - 1);
+ list_add(&in->list, &instances);
+ in->id = n_iface++;
+ break;
+ case 'D':
+ dev_name = optarg;
+ break;
+ case 'p':
+ passwd_file = optarg;
+ break;
+ case 'P':
+ pidfile = optarg;
+ break;
+ }
+ }
+ signal(SIGCHLD, server_handle_sigchld);
+ signal(SIGINT, server_handle_sigint);
+ signal(SIGTERM, server_handle_sigint);
+ signal(SIGKILL, server_handle_sigint);
+
+ if (!n_iface) {
+ fprintf(stderr, "Error: ead needs at least one interface\n");
+ return -1;
+ }
+
+ if (background) {
+ if (fork() > 0)
+ exit(0);
+
+ fd = open("/dev/null", O_RDWR);
+ dup2(fd, 0);
+ dup2(fd, 1);
+ dup2(fd, 2);
+ }
+
+ if (pidfile) {
+ char pid[8];
+ int len;
+
+ unlink(pidfile);
+ fd = open(pidfile, O_CREAT|O_WRONLY|O_EXCL, 0644);
+ if (fd > 0) {
+ len = sprintf(pid, "%d\n", getpid());
+ write(fd, pid, len);
+ close(fd);
+ }
+ }
+
+ /* randomize the mac address */
+ get_random_bytes(ethmac + 3, 3);
+ nid = *(((u16_t *) ethmac) + 2);
+
+ start_servers(false);
+#ifdef linux
+ br_init();
+#endif
+ tv.tv_sec = 1;
+ tv.tv_usec = 0;
+ while (1) {
+ check_all_interfaces();
+ start_servers(true);
+ sleep(1);
+ }
+#ifdef linux
+ br_shutdown();
+#endif
+
+ return 0;
+}
diff --git a/package/network/services/ead/src/.svn/text-base/ead.h.svn-base b/package/network/services/ead/src/.svn/text-base/ead.h.svn-base
new file mode 100644
index 0000000..54505ce
--- /dev/null
+++ b/package/network/services/ead/src/.svn/text-base/ead.h.svn-base
@@ -0,0 +1,139 @@
+/*
+ * Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation
+ *
+ * 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.
+ */
+
+#ifndef __EAD_H
+#define __EAD_H
+
+#define EAD_DEBUGLEVEL 1
+
+#include <stdint.h>
+#include <stddef.h>
+
+#ifndef MAXSALTLEN
+#define MAXSALTLEN 32
+#endif
+
+#define EAD_PORT 56026UL
+#define EAD_MAGIC 3671771902UL
+#define EAD_CMD_TIMEOUT 10
+
+#define EAD_MAX_IV_INCR 128
+
+/* request/response types */
+/* response id == request id + 1 */
+enum ead_type {
+ EAD_TYPE_PING,
+ EAD_TYPE_PONG,
+
+ EAD_TYPE_SET_USERNAME,
+ EAD_TYPE_ACK_USERNAME,
+
+ EAD_TYPE_GET_PRIME,
+ EAD_TYPE_PRIME,
+
+ EAD_TYPE_SEND_A,
+ EAD_TYPE_SEND_B,
+
+ EAD_TYPE_SEND_AUTH,
+ EAD_TYPE_DONE_AUTH,
+
+ EAD_TYPE_SEND_CMD,
+ EAD_TYPE_RESULT_CMD,
+
+ EAD_TYPE_LAST
+};
+
+enum ead_auth_type {
+ EAD_AUTH_DEFAULT,
+ EAD_AUTH_MD5
+};
+
+enum ead_cmd_type {
+ EAD_CMD_NORMAL,
+ EAD_CMD_BACKGROUND,
+ EAD_CMD_LAST
+};
+
+struct ead_msg_pong {
+ uint16_t auth_type;
+ char name[];
+} __attribute__((packed));
+
+struct ead_msg_number {
+ uint8_t id;
+ unsigned char data[];
+} __attribute__((packed));
+
+struct ead_msg_salt {
+ uint8_t prime;
+ uint8_t len;
+ unsigned char salt[MAXSALTLEN];
+ unsigned char ext_salt[MAXSALTLEN];
+} __attribute__((packed));
+
+struct ead_msg_user {
+ char username[32];
+} __attribute__((packed));
+
+struct ead_msg_auth {
+ unsigned char data[20];
+} __attribute__((packed));
+
+struct ead_msg_cmd {
+ uint8_t type;
+ uint16_t timeout;
+ unsigned char data[];
+} __attribute__((packed));
+
+struct ead_msg_cmd_data {
+ uint8_t done;
+ unsigned char data[];
+} __attribute__((packed));
+
+struct ead_msg_encrypted {
+ uint32_t hash[5];
+ uint32_t iv;
+ uint8_t pad;
+ union {
+ struct ead_msg_cmd cmd;
+ struct ead_msg_cmd_data cmd_data;
+ } data[];
+} __attribute__((packed));
+
+
+#define EAD_DATA(_msg, _type) (&((_msg)->data[0]._type))
+#define EAD_ENC_DATA(_msg, _type) (&((_msg)->data[0].enc.data[0]._type))
+
+/* for ead_msg::sid */
+#define EAD_INSTANCE_MASK 0xf000
+#define EAD_INSTANCE_SHIFT 12
+
+struct ead_msg {
+ uint32_t magic;
+ uint32_t len;
+ uint32_t type;
+ uint16_t nid; /* node id */
+ uint16_t sid; /* session id */
+ uint32_t ip; /* source ip for responses from the server */
+ union {
+ struct ead_msg_pong pong;
+ struct ead_msg_user user;
+ struct ead_msg_number number;
+ struct ead_msg_auth auth;
+ struct ead_msg_salt salt;
+ struct ead_msg_encrypted enc;
+ } data[];
+} __attribute__((packed));
+
+
+#endif
diff --git a/package/network/services/ead/src/.svn/text-base/filter.c.svn-base b/package/network/services/ead/src/.svn/text-base/filter.c.svn-base
new file mode 100644
index 0000000..0759dc3
--- /dev/null
+++ b/package/network/services/ead/src/.svn/text-base/filter.c.svn-base
@@ -0,0 +1,25 @@
+/* precompiled expression: udp and dst port 56026 */
+
+static struct bpf_insn pktfilter_insns[] = {
+ { .code = 0x0028, .jt = 0x00, .jf = 0x00, .k = 0x0000000c },
+ { .code = 0x0015, .jt = 0x00, .jf = 0x04, .k = 0x000086dd },
+ { .code = 0x0030, .jt = 0x00, .jf = 0x00, .k = 0x00000014 },
+ { .code = 0x0015, .jt = 0x00, .jf = 0x0b, .k = 0x00000011 },
+ { .code = 0x0028, .jt = 0x00, .jf = 0x00, .k = 0x00000038 },
+ { .code = 0x0015, .jt = 0x08, .jf = 0x09, .k = 0x0000dada },
+ { .code = 0x0015, .jt = 0x00, .jf = 0x08, .k = 0x00000800 },
+ { .code = 0x0030, .jt = 0x00, .jf = 0x00, .k = 0x00000017 },
+ { .code = 0x0015, .jt = 0x00, .jf = 0x06, .k = 0x00000011 },
+ { .code = 0x0028, .jt = 0x00, .jf = 0x00, .k = 0x00000014 },
+ { .code = 0x0045, .jt = 0x04, .jf = 0x00, .k = 0x00001fff },
+ { .code = 0x00b1, .jt = 0x00, .jf = 0x00, .k = 0x0000000e },
+ { .code = 0x0048, .jt = 0x00, .jf = 0x00, .k = 0x00000010 },
+ { .code = 0x0015, .jt = 0x00, .jf = 0x01, .k = 0x0000dada },
+ { .code = 0x0006, .jt = 0x00, .jf = 0x00, .k = 0x000005dc },
+ { .code = 0x0006, .jt = 0x00, .jf = 0x00, .k = 0x00000000 },
+};
+
+static struct bpf_program pktfilter = {
+ .bf_len = 16,
+ .bf_insns = pktfilter_insns,
+};
diff --git a/package/network/services/ead/src/.svn/text-base/libbridge.h.svn-base b/package/network/services/ead/src/.svn/text-base/libbridge.h.svn-base
new file mode 100644
index 0000000..6b70e46
--- /dev/null
+++ b/package/network/services/ead/src/.svn/text-base/libbridge.h.svn-base
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2000 Lennert Buytenhek
+ *
+ * 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 of the
+ * License, 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; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef _LIBBRIDGE_H
+#define _LIBBRIDGE_H
+
+#include <sys/socket.h>
+#include <linux/if.h>
+#include <linux/if_bridge.h>
+
+/* defined in net/if.h but that conflicts with linux/if.h... */
+extern unsigned int if_nametoindex (const char *__ifname);
+extern char *if_indextoname (unsigned int __ifindex, char *__ifname);
+
+struct bridge_id
+{
+ unsigned char prio[2];
+ unsigned char addr[6];
+};
+
+struct bridge_info
+{
+ struct bridge_id designated_root;
+ struct bridge_id bridge_id;
+ unsigned root_path_cost;
+ struct timeval max_age;
+ struct timeval hello_time;
+ struct timeval forward_delay;
+ struct timeval bridge_max_age;
+ struct timeval bridge_hello_time;
+ struct timeval bridge_forward_delay;
+ u_int16_t root_port;
+ unsigned char stp_enabled;
+ unsigned char topology_change;
+ unsigned char topology_change_detected;
+ struct timeval ageing_time;
+ struct timeval hello_timer_value;
+ struct timeval tcn_timer_value;
+ struct timeval topology_change_timer_value;
+ struct timeval gc_timer_value;
+};
+
+struct fdb_entry
+{
+ u_int8_t mac_addr[6];
+ u_int16_t port_no;
+ unsigned char is_local;
+ struct timeval ageing_timer_value;
+};
+
+struct port_info
+{
+ unsigned port_no;
+ struct bridge_id designated_root;
+ struct bridge_id designated_bridge;
+ u_int16_t port_id;
+ u_int16_t designated_port;
+ u_int8_t priority;
+ unsigned char top_change_ack;
+ unsigned char config_pending;
+ unsigned char state;
+ unsigned path_cost;
+ unsigned designated_cost;
+ struct timeval message_age_timer_value;
+ struct timeval forward_delay_timer_value;
+ struct timeval hold_timer_value;
+};
+
+#endif
diff --git a/package/network/services/ead/src/.svn/text-base/libbridge_init.c.svn-base b/package/network/services/ead/src/.svn/text-base/libbridge_init.c.svn-base
new file mode 100644
index 0000000..36d0eb9
--- /dev/null
+++ b/package/network/services/ead/src/.svn/text-base/libbridge_init.c.svn-base
@@ -0,0 +1,208 @@
+/*
+ * Copyright (C) 2000 Lennert Buytenhek
+ *
+ * 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 of the
+ * License, 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; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+#include <string.h>
+#include <dirent.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include "libbridge.h"
+#include "libbridge_private.h"
+
+int br_socket_fd = -1;
+
+static int br_init(void)
+{
+ if ((br_socket_fd = socket(AF_LOCAL, SOCK_STREAM, 0)) < 0)
+ return errno;
+ return 0;
+}
+
+static void br_shutdown(void)
+{
+ close(br_socket_fd);
+ br_socket_fd = -1;
+}
+
+/* If /sys/class/net/XXX/bridge exists then it must be a bridge */
+static int isbridge(const struct dirent *entry)
+{
+ char path[SYSFS_PATH_MAX];
+ struct stat st;
+
+ snprintf(path, SYSFS_PATH_MAX, SYSFS_CLASS_NET "%s/bridge", entry->d_name);
+ return stat(path, &st) == 0 && S_ISDIR(st.st_mode);
+}
+
+/*
+ * New interface uses sysfs to find bridges
+ */
+static int new_foreach_bridge(int (*iterator)(const char *name, void *),
+ void *arg)
+{
+ struct dirent **namelist;
+ int i, count = 0;
+
+ count = scandir(SYSFS_CLASS_NET, &namelist, isbridge, alphasort);
+ if (count < 0)
+ return -1;
+
+ for (i = 0; i < count; i++) {
+ if (iterator(namelist[i]->d_name, arg))
+ break;
+ }
+
+ for (i = 0; i < count; i++)
+ free(namelist[i]);
+ free(namelist);
+
+ return count;
+}
+
+/*
+ * Old interface uses ioctl
+ */
+static int old_foreach_bridge(int (*iterator)(const char *, void *),
+ void *iarg)
+{
+ int i, ret=0, num;
+ char ifname[IFNAMSIZ];
+ int ifindices[MAX_BRIDGES];
+ unsigned long args[3] = { BRCTL_GET_BRIDGES,
+ (unsigned long)ifindices, MAX_BRIDGES };
+
+ num = ioctl(br_socket_fd, SIOCGIFBR, args);
+ if (num < 0) {
+ dprintf("Get bridge indices failed: %s\n",
+ strerror(errno));
+ return -errno;
+ }
+
+ for (i = 0; i < num; i++) {
+ if (!if_indextoname(ifindices[i], ifname)) {
+ dprintf("get find name for ifindex %d\n",
+ ifindices[i]);
+ return -errno;
+ }
+
+ ++ret;
+ if(iterator(ifname, iarg))
+ break;
+ }
+
+ return ret;
+
+}
+
+/*
+ * Go over all bridges and call iterator function.
+ * if iterator returns non-zero then stop.
+ */
+static int br_foreach_bridge(int (*iterator)(const char *, void *),
+ void *arg)
+{
+ int ret;
+
+ ret = new_foreach_bridge(iterator, arg);
+ if (ret <= 0)
+ ret = old_foreach_bridge(iterator, arg);
+
+ return ret;
+}
+
+/*
+ * Only used if sysfs is not available.
+ */
+static int old_foreach_port(const char *brname,
+ int (*iterator)(const char *br, const char *port,
+ void *arg),
+ void *arg)
+{
+ int i, err, count;
+ struct ifreq ifr;
+ char ifname[IFNAMSIZ];
+ int ifindices[MAX_PORTS];
+ unsigned long args[4] = { BRCTL_GET_PORT_LIST,
+ (unsigned long)ifindices, MAX_PORTS, 0 };
+
+ memset(ifindices, 0, sizeof(ifindices));
+ strncpy(ifr.ifr_name, brname, IFNAMSIZ);
+ ifr.ifr_data = (char *) &args;
+
+ err = ioctl(br_socket_fd, SIOCDEVPRIVATE, &ifr);
+ if (err < 0) {
+ dprintf("list ports for bridge:'%s' failed: %s\n",
+ brname, strerror(errno));
+ return -errno;
+ }
+
+ count = 0;
+ for (i = 0; i < MAX_PORTS; i++) {
+ if (!ifindices[i])
+ continue;
+
+ if (!if_indextoname(ifindices[i], ifname)) {
+ dprintf("can't find name for ifindex:%d\n",
+ ifindices[i]);
+ continue;
+ }
+
+ ++count;
+ if (iterator(brname, ifname, arg))
+ break;
+ }
+
+ return count;
+}
+
+/*
+ * Iterate over all ports in bridge (using sysfs).
+ */
+static int br_foreach_port(const char *brname,
+ int (*iterator)(const char *br, const char *port, void *arg),
+ void *arg)
+{
+ int i, count;
+ struct dirent **namelist;
+ char path[SYSFS_PATH_MAX];
+
+ snprintf(path, SYSFS_PATH_MAX, SYSFS_CLASS_NET "%s/brif", brname);
+ count = scandir(path, &namelist, 0, alphasort);
+ if (count < 0)
+ return old_foreach_port(brname, iterator, arg);
+
+ for (i = 0; i < count; i++) {
+ if (namelist[i]->d_name[0] == '.'
+ && (namelist[i]->d_name[1] == '\0'
+ || (namelist[i]->d_name[1] == '.'
+ && namelist[i]->d_name[2] == '\0')))
+ continue;
+
+ if (iterator(brname, namelist[i]->d_name, arg))
+ break;
+ }
+ for (i = 0; i < count; i++)
+ free(namelist[i]);
+ free(namelist);
+
+ return count;
+}
diff --git a/package/network/services/ead/src/.svn/text-base/libbridge_private.h.svn-base b/package/network/services/ead/src/.svn/text-base/libbridge_private.h.svn-base
new file mode 100644
index 0000000..38fd60e
--- /dev/null
+++ b/package/network/services/ead/src/.svn/text-base/libbridge_private.h.svn-base
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2000 Lennert Buytenhek
+ *
+ * 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 of the
+ * License, 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; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef _LIBBRIDGE_PRIVATE_H
+#define _LIBBRIDGE_PRIVATE_H
+
+#include <linux/sockios.h>
+#include <sys/time.h>
+#include <sys/ioctl.h>
+#include <linux/if_bridge.h>
+
+#define MAX_BRIDGES 1024
+#define MAX_PORTS 1024
+
+#define SYSFS_CLASS_NET "/sys/class/net/"
+#define SYSFS_PATH_MAX 256
+
+#define dprintf(fmt,arg...)
+
+#endif
diff --git a/package/network/services/ead/src/.svn/text-base/list.h.svn-base b/package/network/services/ead/src/.svn/text-base/list.h.svn-base
new file mode 100644
index 0000000..ac429c8
--- /dev/null
+++ b/package/network/services/ead/src/.svn/text-base/list.h.svn-base
@@ -0,0 +1,602 @@
+/* GPL v2, adapted from the Linux kernel */
+#ifndef _LINUX_LIST_H
+#define _LINUX_LIST_H
+
+#include <stddef.h>
+/**
+ * container_of - cast a member of a structure out to the containing structure
+ * @ptr: the pointer to the member.
+ * @type: the type of the container struct this is embedded in.
+ * @member: the name of the member within the struct.
+ *
+ */
+#ifndef container_of
+#define container_of(ptr, type, member) ( \
+ (type *)( (char *)ptr - offsetof(type,member) ))
+#endif
+
+
+/*
+ * Simple doubly linked list implementation.
+ *
+ * Some of the internal functions ("__xxx") are useful when
+ * manipulating whole lists rather than single entries, as
+ * sometimes we already know the next/prev entries and we can
+ * generate better code by using them directly rather than
+ * using the generic single-entry routines.
+ */
+
+struct list_head {
+ struct list_head *next, *prev;
+};
+
+#define LIST_HEAD_INIT(name) { &(name), &(name) }
+
+#define LIST_HEAD(name) \
+ struct list_head name = LIST_HEAD_INIT(name)
+
+static inline void INIT_LIST_HEAD(struct list_head *list)
+{
+ list->next = list;
+ list->prev = list;
+}
+
+/*
+ * Insert a new entry between two known consecutive entries.
+ *
+ * This is only for internal list manipulation where we know
+ * the prev/next entries already!
+ */
+static inline void __list_add(struct list_head *new,
+ struct list_head *prev,
+ struct list_head *next)
+{
+ next->prev = new;
+ new->next = next;
+ new->prev = prev;
+ prev->next = new;
+}
+
+/**
+ * list_add - add a new entry
+ * @new: new entry to be added
+ * @head: list head to add it after
+ *
+ * Insert a new entry after the specified head.
+ * This is good for implementing stacks.
+ */
+static inline void list_add(struct list_head *new, struct list_head *head)
+{
+ __list_add(new, head, head->next);
+}
+
+
+/**
+ * list_add_tail - add a new entry
+ * @new: new entry to be added
+ * @head: list head to add it before
+ *
+ * Insert a new entry before the specified head.
+ * This is useful for implementing queues.
+ */
+static inline void list_add_tail(struct list_head *new, struct list_head *head)
+{
+ __list_add(new, head->prev, head);
+}
+
+
+/*
+ * Delete a list entry by making the prev/next entries
+ * point to each other.
+ *
+ * This is only for internal list manipulation where we know
+ * the prev/next entries already!
+ */
+static inline void __list_del(struct list_head * prev, struct list_head * next)
+{
+ next->prev = prev;
+ prev->next = next;
+}
+
+/**
+ * list_del - deletes entry from list.
+ * @entry: the element to delete from the list.
+ * Note: list_empty() on entry does not return true after this, the entry is
+ * in an undefined state.
+ */
+static inline void list_del(struct list_head *entry)
+{
+ __list_del(entry->prev, entry->next);
+ entry->next = NULL;
+ entry->prev = NULL;
+}
+
+/**
+ * list_replace - replace old entry by new one
+ * @old : the element to be replaced
+ * @new : the new element to insert
+ *
+ * If @old was empty, it will be overwritten.
+ */
+static inline void list_replace(struct list_head *old,
+ struct list_head *new)
+{
+ new->next = old->next;
+ new->next->prev = new;
+ new->prev = old->prev;
+ new->prev->next = new;
+}
+
+static inline void list_replace_init(struct list_head *old,
+ struct list_head *new)
+{
+ list_replace(old, new);
+ INIT_LIST_HEAD(old);
+}
+
+/**
+ * list_del_init - deletes entry from list and reinitialize it.
+ * @entry: the element to delete from the list.
+ */
+static inline void list_del_init(struct list_head *entry)
+{
+ __list_del(entry->prev, entry->next);
+ INIT_LIST_HEAD(entry);
+}
+
+/**
+ * list_move - delete from one list and add as another's head
+ * @list: the entry to move
+ * @head: the head that will precede our entry
+ */
+static inline void list_move(struct list_head *list, struct list_head *head)
+{
+ __list_del(list->prev, list->next);
+ list_add(list, head);
+}
+
+/**
+ * list_move_tail - delete from one list and add as another's tail
+ * @list: the entry to move
+ * @head: the head that will follow our entry
+ */
+static inline void list_move_tail(struct list_head *list,
+ struct list_head *head)
+{
+ __list_del(list->prev, list->next);
+ list_add_tail(list, head);
+}
+
+/**
+ * list_is_last - tests whether @list is the last entry in list @head
+ * @list: the entry to test
+ * @head: the head of the list
+ */
+static inline int list_is_last(const struct list_head *list,
+ const struct list_head *head)
+{
+ return list->next == head;
+}
+
+/**
+ * list_empty - tests whether a list is empty
+ * @head: the list to test.
+ */
+static inline int list_empty(const struct list_head *head)
+{
+ return head->next == head;
+}
+
+/**
+ * list_empty_careful - tests whether a list is empty and not being modified
+ * @head: the list to test
+ *
+ * Description:
+ * tests whether a list is empty _and_ checks that no other CPU might be
+ * in the process of modifying either member (next or prev)
+ *
+ * NOTE: using list_empty_careful() without synchronization
+ * can only be safe if the only activity that can happen
+ * to the list entry is list_del_init(). Eg. it cannot be used
+ * if another CPU could re-list_add() it.
+ */
+static inline int list_empty_careful(const struct list_head *head)
+{
+ struct list_head *next = head->next;
+ return (next == head) && (next == head->prev);
+}
+
+static inline void __list_splice(struct list_head *list,
+ struct list_head *head)
+{
+ struct list_head *first = list->next;
+ struct list_head *last = list->prev;
+ struct list_head *at = head->next;
+
+ first->prev = head;
+ head->next = first;
+
+ last->next = at;
+ at->prev = last;
+}
+
+/**
+ * list_splice - join two lists
+ * @list: the new list to add.
+ * @head: the place to add it in the first list.
+ */
+static inline void list_splice(struct list_head *list, struct list_head *head)
+{
+ if (!list_empty(list))
+ __list_splice(list, head);
+}
+
+/**
+ * list_splice_init - join two lists and reinitialise the emptied list.
+ * @list: the new list to add.
+ * @head: the place to add it in the first list.
+ *
+ * The list at @list is reinitialised
+ */
+static inline void list_splice_init(struct list_head *list,
+ struct list_head *head)
+{
+ if (!list_empty(list)) {
+ __list_splice(list, head);
+ INIT_LIST_HEAD(list);
+ }
+}
+
+/**
+ * list_entry - get the struct for this entry
+ * @ptr: the &struct list_head pointer.
+ * @type: the type of the struct this is embedded in.
+ * @member: the name of the list_struct within the struct.
+ */
+#define list_entry(ptr, type, member) \
+ container_of(ptr, type, member)
+
+/**
+ * list_first_entry - get the first element from a list
+ * @ptr: the list head to take the element from.
+ * @type: the type of the struct this is embedded in.
+ * @member: the name of the list_struct within the struct.
+ *
+ * Note, that list is expected to be not empty.
+ */
+#define list_first_entry(ptr, type, member) \
+ list_entry((ptr)->next, type, member)
+
+/**
+ * list_for_each - iterate over a list
+ * @pos: the &struct list_head to use as a loop cursor.
+ * @head: the head for your list.
+ */
+#define list_for_each(pos, head) \
+ for (pos = (head)->next; pos != (head); \
+ pos = pos->next)
+
+/**
+ * __list_for_each - iterate over a list
+ * @pos: the &struct list_head to use as a loop cursor.
+ * @head: the head for your list.
+ *
+ * This variant differs from list_for_each() in that it's the
+ * simplest possible list iteration code, no prefetching is done.
+ * Use this for code that knows the list to be very short (empty
+ * or 1 entry) most of the time.
+ */
+#define __list_for_each(pos, head) \
+ for (pos = (head)->next; pos != (head); pos = pos->next)
+
+/**
+ * list_for_each_prev - iterate over a list backwards
+ * @pos: the &struct list_head to use as a loop cursor.
+ * @head: the head for your list.
+ */
+#define list_for_each_prev(pos, head) \
+ for (pos = (head)->prev; pos != (head); \
+ pos = pos->prev)
+
+/**
+ * list_for_each_safe - iterate over a list safe against removal of list entry
+ * @pos: the &struct list_head to use as a loop cursor.
+ * @n: another &struct list_head to use as temporary storage
+ * @head: the head for your list.
+ */
+#define list_for_each_safe(pos, n, head) \
+ for (pos = (head)->next, n = pos->next; pos != (head); \
+ pos = n, n = pos->next)
+
+/**
+ * list_for_each_prev_safe - iterate over a list backwards safe against removal of list entry
+ * @pos: the &struct list_head to use as a loop cursor.
+ * @n: another &struct list_head to use as temporary storage
+ * @head: the head for your list.
+ */
+#define list_for_each_prev_safe(pos, n, head) \
+ for (pos = (head)->prev, n = pos->prev; \
+ pos != (head); \
+ pos = n, n = pos->prev)
+
+/**
+ * list_for_each_entry - iterate over list of given type
+ * @pos: the type * to use as a loop cursor.
+ * @head: the head for your list.
+ * @member: the name of the list_struct within the struct.
+ */
+#define list_for_each_entry(pos, head, member) \
+ for (pos = list_entry((head)->next, typeof(*pos), member); \
+ &pos->member != (head); \
+ pos = list_entry(pos->member.next, typeof(*pos), member))
+
+/**
+ * list_for_each_entry_reverse - iterate backwards over list of given type.
+ * @pos: the type * to use as a loop cursor.
+ * @head: the head for your list.
+ * @member: the name of the list_struct within the struct.
+ */
+#define list_for_each_entry_reverse(pos, head, member) \
+ for (pos = list_entry((head)->prev, typeof(*pos), member); \
+ &pos->member != (head); \
+ pos = list_entry(pos->member.prev, typeof(*pos), member))
+
+/**
+ * list_prepare_entry - prepare a pos entry for use in list_for_each_entry_continue()
+ * @pos: the type * to use as a start point
+ * @head: the head of the list
+ * @member: the name of the list_struct within the struct.
+ *
+ * Prepares a pos entry for use as a start point in list_for_each_entry_continue().
+ */
+#define list_prepare_entry(pos, head, member) \
+ ((pos) ? : list_entry(head, typeof(*pos), member))
+
+/**
+ * list_for_each_entry_continue - continue iteration over list of given type
+ * @pos: the type * to use as a loop cursor.
+ * @head: the head for your list.
+ * @member: the name of the list_struct within the struct.
+ *
+ * Continue to iterate over list of given type, continuing after
+ * the current position.
+ */
+#define list_for_each_entry_continue(pos, head, member) \
+ for (pos = list_entry(pos->member.next, typeof(*pos), member); \
+ &pos->member != (head); \
+ pos = list_entry(pos->member.next, typeof(*pos), member))
+
+/**
+ * list_for_each_entry_continue_reverse - iterate backwards from the given point
+ * @pos: the type * to use as a loop cursor.
+ * @head: the head for your list.
+ * @member: the name of the list_struct within the struct.
+ *
+ * Start to iterate over list of given type backwards, continuing after
+ * the current position.
+ */
+#define list_for_each_entry_continue_reverse(pos, head, member) \
+ for (pos = list_entry(pos->member.prev, typeof(*pos), member); \
+ &pos->member != (head); \
+ pos = list_entry(pos->member.prev, typeof(*pos), member))
+
+/**
+ * list_for_each_entry_from - iterate over list of given type from the current point
+ * @pos: the type * to use as a loop cursor.
+ * @head: the head for your list.
+ * @member: the name of the list_struct within the struct.
+ *
+ * Iterate over list of given type, continuing from current position.
+ */
+#define list_for_each_entry_from(pos, head, member) \
+ for (; &pos->member != (head); \
+ pos = list_entry(pos->member.next, typeof(*pos), member))
+
+/**
+ * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
+ * @pos: the type * to use as a loop cursor.
+ * @n: another type * to use as temporary storage
+ * @head: the head for your list.
+ * @member: the name of the list_struct within the struct.
+ */
+#define list_for_each_entry_safe(pos, n, head, member) \
+ for (pos = list_entry((head)->next, typeof(*pos), member), \
+ n = list_entry(pos->member.next, typeof(*pos), member); \
+ &pos->member != (head); \
+ pos = n, n = list_entry(n->member.next, typeof(*n), member))
+
+/**
+ * list_for_each_entry_safe_continue
+ * @pos: the type * to use as a loop cursor.
+ * @n: another type * to use as temporary storage
+ * @head: the head for your list.
+ * @member: the name of the list_struct within the struct.
+ *
+ * Iterate over list of given type, continuing after current point,
+ * safe against removal of list entry.
+ */
+#define list_for_each_entry_safe_continue(pos, n, head, member) \
+ for (pos = list_entry(pos->member.next, typeof(*pos), member), \
+ n = list_entry(pos->member.next, typeof(*pos), member); \
+ &pos->member != (head); \
+ pos = n, n = list_entry(n->member.next, typeof(*n), member))
+
+/**
+ * list_for_each_entry_safe_from
+ * @pos: the type * to use as a loop cursor.
+ * @n: another type * to use as temporary storage
+ * @head: the head for your list.
+ * @member: the name of the list_struct within the struct.
+ *
+ * Iterate over list of given type from current point, safe against
+ * removal of list entry.
+ */
+#define list_for_each_entry_safe_from(pos, n, head, member) \
+ for (n = list_entry(pos->member.next, typeof(*pos), member); \
+ &pos->member != (head); \
+ pos = n, n = list_entry(n->member.next, typeof(*n), member))
+
+/**
+ * list_for_each_entry_safe_reverse
+ * @pos: the type * to use as a loop cursor.
+ * @n: another type * to use as temporary storage
+ * @head: the head for your list.
+ * @member: the name of the list_struct within the struct.
+ *
+ * Iterate backwards over list of given type, safe against removal
+ * of list entry.
+ */
+#define list_for_each_entry_safe_reverse(pos, n, head, member) \
+ for (pos = list_entry((head)->prev, typeof(*pos), member), \
+ n = list_entry(pos->member.prev, typeof(*pos), member); \
+ &pos->member != (head); \
+ pos = n, n = list_entry(n->member.prev, typeof(*n), member))
+
+/*
+ * Double linked lists with a single pointer list head.
+ * Mostly useful for hash tables where the two pointer list head is
+ * too wasteful.
+ * You lose the ability to access the tail in O(1).
+ */
+
+struct hlist_head {
+ struct hlist_node *first;
+};
+
+struct hlist_node {
+ struct hlist_node *next, **pprev;
+};
+
+#define HLIST_HEAD_INIT { .first = NULL }
+#define HLIST_HEAD(name) struct hlist_head name = { .first = NULL }
+#define INIT_HLIST_HEAD(ptr) ((ptr)->first = NULL)
+static inline void INIT_HLIST_NODE(struct hlist_node *h)
+{
+ h->next = NULL;
+ h->pprev = NULL;
+}
+
+static inline int hlist_unhashed(const struct hlist_node *h)
+{
+ return !h->pprev;
+}
+
+static inline int hlist_empty(const struct hlist_head *h)
+{
+ return !h->first;
+}
+
+static inline void __hlist_del(struct hlist_node *n)
+{
+ struct hlist_node *next = n->next;
+ struct hlist_node **pprev = n->pprev;
+ *pprev = next;
+ if (next)
+ next->pprev = pprev;
+}
+
+static inline void hlist_del(struct hlist_node *n)
+{
+ __hlist_del(n);
+ n->next = NULL;
+ n->pprev = NULL;
+}
+
+static inline void hlist_del_init(struct hlist_node *n)
+{
+ if (!hlist_unhashed(n)) {
+ __hlist_del(n);
+ INIT_HLIST_NODE(n);
+ }
+}
+
+
+static inline void hlist_add_head(struct hlist_node *n, struct hlist_head *h)
+{
+ struct hlist_node *first = h->first;
+ n->next = first;
+ if (first)
+ first->pprev = &n->next;
+ h->first = n;
+ n->pprev = &h->first;
+}
+
+
+/* next must be != NULL */
+static inline void hlist_add_before(struct hlist_node *n,
+ struct hlist_node *next)
+{
+ n->pprev = next->pprev;
+ n->next = next;
+ next->pprev = &n->next;
+ *(n->pprev) = n;
+}
+
+static inline void hlist_add_after(struct hlist_node *n,
+ struct hlist_node *next)
+{
+ next->next = n->next;
+ n->next = next;
+ next->pprev = &n->next;
+
+ if(next->next)
+ next->next->pprev = &next->next;
+}
+
+#define hlist_entry(ptr, type, member) container_of(ptr,type,member)
+
+#define hlist_for_each(pos, head) \
+ for (pos = (head)->first; pos; pos = pos->next)
+
+#define hlist_for_each_safe(pos, n, head) \
+ for (pos = (head)->first; pos; pos = n)
+
+/**
+ * hlist_for_each_entry - iterate over list of given type
+ * @tpos: the type * to use as a loop cursor.
+ * @pos: the &struct hlist_node to use as a loop cursor.
+ * @head: the head for your list.
+ * @member: the name of the hlist_node within the struct.
+ */
+#define hlist_for_each_entry(tpos, pos, head, member) \
+ for (pos = (head)->first; pos && \
+ ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
+ pos = pos->next)
+
+/**
+ * hlist_for_each_entry_continue - iterate over a hlist continuing after current point
+ * @tpos: the type * to use as a loop cursor.
+ * @pos: the &struct hlist_node to use as a loop cursor.
+ * @member: the name of the hlist_node within the struct.
+ */
+#define hlist_for_each_entry_continue(tpos, pos, member) \
+ for (pos = (pos)->next; pos && \
+ ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
+ pos = pos->next)
+
+/**
+ * hlist_for_each_entry_from - iterate over a hlist continuing from current point
+ * @tpos: the type * to use as a loop cursor.
+ * @pos: the &struct hlist_node to use as a loop cursor.
+ * @member: the name of the hlist_node within the struct.
+ */
+#define hlist_for_each_entry_from(tpos, pos, member) \
+ for (; pos && \
+ ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
+ pos = pos->next)
+
+/**
+ * hlist_for_each_entry_safe - iterate over list of given type safe against removal of list entry
+ * @tpos: the type * to use as a loop cursor.
+ * @pos: the &struct hlist_node to use as a loop cursor.
+ * @n: another &struct hlist_node to use as temporary storage
+ * @head: the head for your list.
+ * @member: the name of the hlist_node within the struct.
+ */
+#define hlist_for_each_entry_safe(tpos, pos, n, head, member) \
+ for (pos = (head)->first; \
+ pos && ({ n = pos->next; 1; }) && \
+ ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
+ pos = n)
+
+#endif
diff --git a/package/network/services/ead/src/.svn/text-base/passwd.svn-base b/package/network/services/ead/src/.svn/text-base/passwd.svn-base
new file mode 100644
index 0000000..eee7a89
--- /dev/null
+++ b/package/network/services/ead/src/.svn/text-base/passwd.svn-base
@@ -0,0 +1,3 @@
+root:$1$MCGAgYw.$Ip1GcyeUliId3wzVcKR/e/:0:0:root:/root:/bin/ash
+nobody:*:65534:65534:nobody:/var:/bin/false
+daemon:*:65534:65534:daemon:/var:/bin/false
diff --git a/package/network/services/ead/src/.svn/text-base/pfc.c.svn-base b/package/network/services/ead/src/.svn/text-base/pfc.c.svn-base
new file mode 100644
index 0000000..402e37f
--- /dev/null
+++ b/package/network/services/ead/src/.svn/text-base/pfc.c.svn-base
@@ -0,0 +1,54 @@
+/*
+ * Small pcap precompiler
+ * Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation
+ *
+ * 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.
+ */
+
+#include <sys/types.h>
+#include <sys/time.h>
+#include <string.h>
+#include <stdlib.h>
+#include <pcap.h>
+
+int main (int argc, char ** argv)
+{
+ struct bpf_program filter;
+ pcap_t *pc;
+ int i;
+
+ if (argc != 2)
+ {
+ printf ("Usage: %s <expression>\n", argv[0]);
+ return 1;
+ }
+
+ pc = pcap_open_dead(DLT_EN10MB, 1500);
+ if (pcap_compile(pc, &filter, argv[1], 1, 0) != 0) {
+ printf("error in active-filter expression: %s\n", pcap_geterr(pc));
+ return 1;
+ }
+
+ printf("/* precompiled expression: %s */\n\n"
+ "static struct bpf_insn pktfilter_insns[] = {\n",
+ argv[1]);
+
+ for (i = 0; i < filter.bf_len; i++) {
+ struct bpf_insn *in = &filter.bf_insns[i];
+ printf("\t{ .code = 0x%04x, .jt = 0x%02x, .jf = 0x%02x, .k = 0x%08x },\n", in->code, in->jt, in->jf, in->k);
+ }
+ printf("};\n\n"
+ "static struct bpf_program pktfilter = {\n"
+ "\t.bf_len = %d,\n"
+ "\t.bf_insns = pktfilter_insns,\n"
+ "};\n", filter.bf_len);
+ return 0;
+
+}
diff --git a/package/network/services/ead/src/.svn/text-base/pw_encrypt_md5.c.svn-base b/package/network/services/ead/src/.svn/text-base/pw_encrypt_md5.c.svn-base
new file mode 100644
index 0000000..bc9f249
--- /dev/null
+++ b/package/network/services/ead/src/.svn/text-base/pw_encrypt_md5.c.svn-base
@@ -0,0 +1,646 @@
+/*
+ * MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm
+ *
+ * Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
+ * rights reserved.
+ *
+ * License to copy and use this software is granted provided that it
+ * is identified as the "RSA Data Security, Inc. MD5 Message-Digest
+ * Algorithm" in all material mentioning or referencing this software
+ * or this function.
+ *
+ * License is also granted to make and use derivative works provided
+ * that such works are identified as "derived from the RSA Data
+ * Security, Inc. MD5 Message-Digest Algorithm" in all material
+ * mentioning or referencing the derived work.
+ *
+ * RSA Data Security, Inc. makes no representations concerning either
+ * the merchantability of this software or the suitability of this
+ * software for any particular purpose. It is provided "as is"
+ * without express or implied warranty of any kind.
+ *
+ * These notices must be retained in any copies of any part of this
+ * documentation and/or software.
+ *
+ * $FreeBSD: src/lib/libmd/md5c.c,v 1.9.2.1 1999/08/29 14:57:12 peter Exp $
+ *
+ * This code is the same as the code published by RSA Inc. It has been
+ * edited for clarity and style only.
+ *
+ * ----------------------------------------------------------------------------
+ * The md5_crypt() function was taken from freeBSD's libcrypt and contains
+ * this license:
+ * "THE BEER-WARE LICENSE" (Revision 42):
+ * <phk@login.dknet.dk> wrote this file. As long as you retain this notice you
+ * can do whatever you want with this stuff. If we meet some day, and you think
+ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
+ *
+ * $FreeBSD: src/lib/libcrypt/crypt.c,v 1.7.2.1 1999/08/29 14:56:33 peter Exp $
+ *
+ * ----------------------------------------------------------------------------
+ * On April 19th, 2001 md5_crypt() was modified to make it reentrant
+ * by Erik Andersen <andersen@uclibc.org>
+ *
+ *
+ * June 28, 2001 Manuel Novoa III
+ *
+ * "Un-inlined" code using loops and static const tables in order to
+ * reduce generated code size (on i386 from approx 4k to approx 2.5k).
+ *
+ * June 29, 2001 Manuel Novoa III
+ *
+ * Completely removed static PADDING array.
+ *
+ * Reintroduced the loop unrolling in MD5_Transform and added the
+ * MD5_SIZE_OVER_SPEED option for configurability. Define below as:
+ * 0 fully unrolled loops
+ * 1 partially unrolled (4 ops per loop)
+ * 2 no unrolling -- introduces the need to swap 4 variables (slow)
+ * 3 no unrolling and all 4 loops merged into one with switch
+ * in each loop (glacial)
+ * On i386, sizes are roughly (-Os -fno-builtin):
+ * 0: 3k 1: 2.5k 2: 2.2k 3: 2k
+ *
+ *
+ * Since SuSv3 does not require crypt_r, modified again August 7, 2002
+ * by Erik Andersen to remove reentrance stuff...
+ */
+
+static const uint8_t ascii64[] = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+
+/*
+ * Valid values are 1 (fastest/largest) to 3 (smallest/slowest).
+ */
+#define MD5_SIZE_OVER_SPEED 3
+
+/**********************************************************************/
+
+/* MD5 context. */
+struct MD5Context {
+ uint32_t state[4]; /* state (ABCD) */
+ uint32_t count[2]; /* number of bits, modulo 2^64 (lsb first) */
+ unsigned char buffer[64]; /* input buffer */
+};
+
+static void __md5_Init(struct MD5Context *);
+static void __md5_Update(struct MD5Context *, const unsigned char *, unsigned int);
+static void __md5_Pad(struct MD5Context *);
+static void __md5_Final(unsigned char [16], struct MD5Context *);
+static void __md5_Transform(uint32_t [4], const unsigned char [64]);
+
+
+#define MD5_MAGIC_STR "$1$"
+#define MD5_MAGIC_LEN (sizeof(MD5_MAGIC_STR) - 1)
+static const unsigned char __md5__magic[] = MD5_MAGIC_STR;
+
+
+#ifdef i386
+#define __md5_Encode memcpy
+#define __md5_Decode memcpy
+#else /* i386 */
+
+/*
+ * __md5_Encodes input (uint32_t) into output (unsigned char). Assumes len is
+ * a multiple of 4.
+ */
+static void
+__md5_Encode(unsigned char *output, uint32_t *input, unsigned int len)
+{
+ unsigned int i, j;
+
+ for (i = 0, j = 0; j < len; i++, j += 4) {
+ output[j] = input[i];
+ output[j+1] = (input[i] >> 8);
+ output[j+2] = (input[i] >> 16);
+ output[j+3] = (input[i] >> 24);
+ }
+}
+
+/*
+ * __md5_Decodes input (unsigned char) into output (uint32_t). Assumes len is
+ * a multiple of 4.
+ */
+static void
+__md5_Decode(uint32_t *output, const unsigned char *input, unsigned int len)
+{
+ unsigned int i, j;
+
+ for (i = 0, j = 0; j < len; i++, j += 4)
+ output[i] = ((uint32_t)input[j]) | (((uint32_t)input[j+1]) << 8) |
+ (((uint32_t)input[j+2]) << 16) | (((uint32_t)input[j+3]) << 24);
+}
+#endif /* i386 */
+
+/* F, G, H and I are basic MD5 functions. */
+#define F(x, y, z) (((x) & (y)) | (~(x) & (z)))
+#define G(x, y, z) (((x) & (z)) | ((y) & ~(z)))
+#define H(x, y, z) ((x) ^ (y) ^ (z))
+#define I(x, y, z) ((y) ^ ((x) | ~(z)))
+
+/* ROTATE_LEFT rotates x left n bits. */
+#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
+
+/*
+ * FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
+ * Rotation is separate from addition to prevent recomputation.
+ */
+#define FF(a, b, c, d, x, s, ac) { \
+ (a) += F ((b), (c), (d)) + (x) + (uint32_t)(ac); \
+ (a) = ROTATE_LEFT((a), (s)); \
+ (a) += (b); \
+ }
+#define GG(a, b, c, d, x, s, ac) { \
+ (a) += G ((b), (c), (d)) + (x) + (uint32_t)(ac); \
+ (a) = ROTATE_LEFT((a), (s)); \
+ (a) += (b); \
+ }
+#define HH(a, b, c, d, x, s, ac) { \
+ (a) += H ((b), (c), (d)) + (x) + (uint32_t)(ac); \
+ (a) = ROTATE_LEFT((a), (s)); \
+ (a) += (b); \
+ }
+#define II(a, b, c, d, x, s, ac) { \
+ (a) += I ((b), (c), (d)) + (x) + (uint32_t)(ac); \
+ (a) = ROTATE_LEFT((a), (s)); \
+ (a) += (b); \
+ }
+
+/* MD5 initialization. Begins an MD5 operation, writing a new context. */
+static void __md5_Init(struct MD5Context *context)
+{
+ context->count[0] = context->count[1] = 0;
+
+ /* Load magic initialization constants. */
+ context->state[0] = 0x67452301;
+ context->state[1] = 0xefcdab89;
+ context->state[2] = 0x98badcfe;
+ context->state[3] = 0x10325476;
+}
+
+/*
+ * MD5 block update operation. Continues an MD5 message-digest
+ * operation, processing another message block, and updating the
+ * context.
+ */
+static void __md5_Update(struct MD5Context *context, const unsigned char *input, unsigned int inputLen)
+{
+ unsigned int i, idx, partLen;
+
+ /* Compute number of bytes mod 64 */
+ idx = (context->count[0] >> 3) & 0x3F;
+
+ /* Update number of bits */
+ context->count[0] += (inputLen << 3);
+ if (context->count[0] < (inputLen << 3))
+ context->count[1]++;
+ context->count[1] += (inputLen >> 29);
+
+ partLen = 64 - idx;
+
+ /* Transform as many times as possible. */
+ if (inputLen >= partLen) {
+ memcpy(&context->buffer[idx], input, partLen);
+ __md5_Transform(context->state, context->buffer);
+
+ for (i = partLen; i + 63 < inputLen; i += 64)
+ __md5_Transform(context->state, &input[i]);
+
+ idx = 0;
+ } else
+ i = 0;
+
+ /* Buffer remaining input */
+ memcpy(&context->buffer[idx], &input[i], inputLen - i);
+}
+
+/*
+ * MD5 padding. Adds padding followed by original length.
+ */
+static void __md5_Pad(struct MD5Context *context)
+{
+ unsigned char bits[8];
+ unsigned int idx, padLen;
+ unsigned char PADDING[64];
+
+ memset(PADDING, 0, sizeof(PADDING));
+ PADDING[0] = 0x80;
+
+ /* Save number of bits */
+ __md5_Encode(bits, context->count, 8);
+
+ /* Pad out to 56 mod 64. */
+ idx = (context->count[0] >> 3) & 0x3f;
+ padLen = (idx < 56) ? (56 - idx) : (120 - idx);
+ __md5_Update(context, PADDING, padLen);
+
+ /* Append length (before padding) */
+ __md5_Update(context, bits, 8);
+}
+
+/*
+ * MD5 finalization. Ends an MD5 message-digest operation, writing the
+ * the message digest and zeroizing the context.
+ */
+static void __md5_Final(unsigned char digest[16], struct MD5Context *context)
+{
+ /* Do padding. */
+ __md5_Pad(context);
+
+ /* Store state in digest */
+ __md5_Encode(digest, context->state, 16);
+
+ /* Zeroize sensitive information. */
+ memset(context, 0, sizeof(*context));
+}
+
+/* MD5 basic transformation. Transforms state based on block. */
+static void __md5_Transform(uint32_t state[4], const unsigned char block[64])
+{
+ uint32_t a, b, c, d, x[16];
+#if MD5_SIZE_OVER_SPEED > 1
+ uint32_t temp;
+ const unsigned char *ps;
+
+ static const unsigned char S[] = {
+ 7, 12, 17, 22,
+ 5, 9, 14, 20,
+ 4, 11, 16, 23,
+ 6, 10, 15, 21
+ };
+#endif /* MD5_SIZE_OVER_SPEED > 1 */
+
+#if MD5_SIZE_OVER_SPEED > 0
+ const uint32_t *pc;
+ const unsigned char *pp;
+ int i;
+
+ static const uint32_t C[] = {
+ /* round 1 */
+ 0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee,
+ 0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501,
+ 0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be,
+ 0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821,
+ /* round 2 */
+ 0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa,
+ 0xd62f105d, 0x2441453, 0xd8a1e681, 0xe7d3fbc8,
+ 0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed,
+ 0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a,
+ /* round 3 */
+ 0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c,
+ 0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70,
+ 0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x4881d05,
+ 0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665,
+ /* round 4 */
+ 0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039,
+ 0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1,
+ 0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1,
+ 0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391
+ };
+
+ static const unsigned char P[] = {
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, /* 1 */
+ 1, 6, 11, 0, 5, 10, 15, 4, 9, 14, 3, 8, 13, 2, 7, 12, /* 2 */
+ 5, 8, 11, 14, 1, 4, 7, 10, 13, 0, 3, 6, 9, 12, 15, 2, /* 3 */
+ 0, 7, 14, 5, 12, 3, 10, 1, 8, 15, 6, 13, 4, 11, 2, 9 /* 4 */
+ };
+
+#endif /* MD5_SIZE_OVER_SPEED > 0 */
+
+ __md5_Decode(x, block, 64);
+
+ a = state[0]; b = state[1]; c = state[2]; d = state[3];
+
+#if MD5_SIZE_OVER_SPEED > 2
+ pc = C; pp = P; ps = S - 4;
+
+ for (i = 0; i < 64; i++) {
+ if ((i & 0x0f) == 0) ps += 4;
+ temp = a;
+ switch (i>>4) {
+ case 0:
+ temp += F(b, c, d);
+ break;
+ case 1:
+ temp += G(b, c, d);
+ break;
+ case 2:
+ temp += H(b, c, d);
+ break;
+ case 3:
+ temp += I(b, c, d);
+ break;
+ }
+ temp += x[*pp++] + *pc++;
+ temp = ROTATE_LEFT(temp, ps[i & 3]);
+ temp += b;
+ a = d; d = c; c = b; b = temp;
+ }
+#elif MD5_SIZE_OVER_SPEED > 1
+ pc = C; pp = P; ps = S;
+
+ /* Round 1 */
+ for (i = 0; i < 16; i++) {
+ FF(a, b, c, d, x[*pp], ps[i & 0x3], *pc); pp++; pc++;
+ temp = d; d = c; c = b; b = a; a = temp;
+ }
+
+ /* Round 2 */
+ ps += 4;
+ for (; i < 32; i++) {
+ GG(a, b, c, d, x[*pp], ps[i & 0x3], *pc); pp++; pc++;
+ temp = d; d = c; c = b; b = a; a = temp;
+ }
+ /* Round 3 */
+ ps += 4;
+ for (; i < 48; i++) {
+ HH(a, b, c, d, x[*pp], ps[i & 0x3], *pc); pp++; pc++;
+ temp = d; d = c; c = b; b = a; a = temp;
+ }
+
+ /* Round 4 */
+ ps += 4;
+ for (; i < 64; i++) {
+ II(a, b, c, d, x[*pp], ps[i & 0x3], *pc); pp++; pc++;
+ temp = d; d = c; c = b; b = a; a = temp;
+ }
+#elif MD5_SIZE_OVER_SPEED > 0
+ pc = C; pp = P;
+
+ /* Round 1 */
+ for (i = 0; i < 4; i++) {
+ FF(a, b, c, d, x[*pp], 7, *pc); pp++; pc++;
+ FF(d, a, b, c, x[*pp], 12, *pc); pp++; pc++;
+ FF(c, d, a, b, x[*pp], 17, *pc); pp++; pc++;
+ FF(b, c, d, a, x[*pp], 22, *pc); pp++; pc++;
+ }
+
+ /* Round 2 */
+ for (i = 0; i < 4; i++) {
+ GG(a, b, c, d, x[*pp], 5, *pc); pp++; pc++;
+ GG(d, a, b, c, x[*pp], 9, *pc); pp++; pc++;
+ GG(c, d, a, b, x[*pp], 14, *pc); pp++; pc++;
+ GG(b, c, d, a, x[*pp], 20, *pc); pp++; pc++;
+ }
+ /* Round 3 */
+ for (i = 0; i < 4; i++) {
+ HH(a, b, c, d, x[*pp], 4, *pc); pp++; pc++;
+ HH(d, a, b, c, x[*pp], 11, *pc); pp++; pc++;
+ HH(c, d, a, b, x[*pp], 16, *pc); pp++; pc++;
+ HH(b, c, d, a, x[*pp], 23, *pc); pp++; pc++;
+ }
+
+ /* Round 4 */
+ for (i = 0; i < 4; i++) {
+ II(a, b, c, d, x[*pp], 6, *pc); pp++; pc++;
+ II(d, a, b, c, x[*pp], 10, *pc); pp++; pc++;
+ II(c, d, a, b, x[*pp], 15, *pc); pp++; pc++;
+ II(b, c, d, a, x[*pp], 21, *pc); pp++; pc++;
+ }
+#else
+ /* Round 1 */
+#define S11 7
+#define S12 12
+#define S13 17
+#define S14 22
+ FF(a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */
+ FF(d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */
+ FF(c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */
+ FF(b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */
+ FF(a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */
+ FF(d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */
+ FF(c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */
+ FF(b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */
+ FF(a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */
+ FF(d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */
+ FF(c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
+ FF(b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
+ FF(a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
+ FF(d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
+ FF(c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
+ FF(b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
+
+ /* Round 2 */
+#define S21 5
+#define S22 9
+#define S23 14
+#define S24 20
+ GG(a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */
+ GG(d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */
+ GG(c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
+ GG(b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */
+ GG(a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */
+ GG(d, a, b, c, x[10], S22, 0x2441453); /* 22 */
+ GG(c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
+ GG(b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */
+ GG(a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */
+ GG(d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
+ GG(c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */
+ GG(b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */
+ GG(a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
+ GG(d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */
+ GG(c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */
+ GG(b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
+
+ /* Round 3 */
+#define S31 4
+#define S32 11
+#define S33 16
+#define S34 23
+ HH(a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */
+ HH(d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */
+ HH(c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
+ HH(b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
+ HH(a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */
+ HH(d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */
+ HH(c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */
+ HH(b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
+ HH(a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
+ HH(d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */
+ HH(c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */
+ HH(b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */
+ HH(a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */
+ HH(d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
+ HH(c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
+ HH(b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */
+
+ /* Round 4 */
+#define S41 6
+#define S42 10
+#define S43 15
+#define S44 21
+ II(a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */
+ II(d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */
+ II(c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
+ II(b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */
+ II(a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
+ II(d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */
+ II(c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
+ II(b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */
+ II(a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */
+ II(d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
+ II(c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */
+ II(b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
+ II(a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */
+ II(d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
+ II(c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */
+ II(b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */
+#endif
+
+ state[0] += a;
+ state[1] += b;
+ state[2] += c;
+ state[3] += d;
+
+ /* Zeroize sensitive information. */
+ memset(x, 0, sizeof(x));
+}
+
+
+static char*
+__md5_to64(char *s, unsigned v, int n)
+{
+ while (--n >= 0) {
+ *s++ = ascii64[v & 0x3f];
+ v >>= 6;
+ }
+ return s;
+}
+
+/*
+ * UNIX password
+ *
+ * Use MD5 for what it is best at...
+ */
+#define MD5_OUT_BUFSIZE 36
+static char *
+md5_crypt(char passwd[MD5_OUT_BUFSIZE], const unsigned char *pw, const unsigned char *salt)
+{
+ const unsigned char *sp, *ep;
+ char *p;
+ unsigned char final[17]; /* final[16] exists only to aid in looping */
+ int sl, pl, i, pw_len;
+ struct MD5Context ctx, ctx1;
+
+ /* Refine the Salt first */
+ sp = salt;
+
+ sp += MD5_MAGIC_LEN;
+
+ /* It stops at the first '$', max 8 chars */
+ for (ep = sp; *ep && *ep != '$' && ep < (sp+8); ep++)
+ continue;
+
+ /* get the length of the true salt */
+ sl = ep - sp;
+
+ __md5_Init(&ctx);
+
+ /* The password first, since that is what is most unknown */
+ pw_len = strlen((char*)pw);
+ __md5_Update(&ctx, pw, pw_len);
+
+ /* Then our magic string */
+ __md5_Update(&ctx, __md5__magic, MD5_MAGIC_LEN);
+
+ /* Then the raw salt */
+ __md5_Update(&ctx, sp, sl);
+
+ /* Then just as many characters of the MD5(pw, salt, pw) */
+ __md5_Init(&ctx1);
+ __md5_Update(&ctx1, pw, pw_len);
+ __md5_Update(&ctx1, sp, sl);
+ __md5_Update(&ctx1, pw, pw_len);
+ __md5_Final(final, &ctx1);
+ for (pl = pw_len; pl > 0; pl -= 16)
+ __md5_Update(&ctx, final, pl > 16 ? 16 : pl);
+
+ /* Don't leave anything around in vm they could use. */
+//TODO: the above comment seems to be wrong. final is used later.
+ memset(final, 0, sizeof(final));
+
+ /* Then something really weird... */
+ for (i = pw_len; i; i >>= 1) {
+ __md5_Update(&ctx, ((i & 1) ? final : (const unsigned char *) pw), 1);
+ }
+
+ /* Now make the output string */
+ passwd[0] = '$';
+ passwd[1] = '1';
+ passwd[2] = '$';
+ strncpy(passwd + 3, (char*)sp, sl);
+ passwd[sl + 3] = '$';
+
+ __md5_Final(final, &ctx);
+
+ /*
+ * and now, just to make sure things don't run too fast
+ * On a 60 Mhz Pentium this takes 34 msec, so you would
+ * need 30 seconds to build a 1000 entry dictionary...
+ */
+ for (i = 0; i < 1000; i++) {
+ __md5_Init(&ctx1);
+ if (i & 1)
+ __md5_Update(&ctx1, pw, pw_len);
+ else
+ __md5_Update(&ctx1, final, 16);
+
+ if (i % 3)
+ __md5_Update(&ctx1, sp, sl);
+
+ if (i % 7)
+ __md5_Update(&ctx1, pw, pw_len);
+
+ if (i & 1)
+ __md5_Update(&ctx1, final, 16);
+ else
+ __md5_Update(&ctx1, pw, pw_len);
+ __md5_Final(final, &ctx1);
+ }
+
+ p = passwd + sl + 4; /* 12 bytes max (sl is up to 8 bytes) */
+
+ /* Add 5*4+2 = 22 bytes of hash, + NUL byte. */
+ final[16] = final[5];
+ for (i = 0; i < 5; i++) {
+ unsigned l = (final[i] << 16) | (final[i+6] << 8) | final[i+12];
+ p = __md5_to64(p, l, 4);
+ }
+ p = __md5_to64(p, final[11], 2);
+ *p = '\0';
+
+ /* Don't leave anything around in vm they could use. */
+ memset(final, 0, sizeof(final));
+
+ return passwd;
+}
+
+#undef MD5_SIZE_OVER_SPEED
+#undef MD5_MAGIC_STR
+#undef MD5_MAGIC_LEN
+#undef __md5_Encode
+#undef __md5_Decode
+#undef F
+#undef G
+#undef H
+#undef I
+#undef ROTATE_LEFT
+#undef FF
+#undef GG
+#undef HH
+#undef II
+#undef S11
+#undef S12
+#undef S13
+#undef S14
+#undef S21
+#undef S22
+#undef S23
+#undef S24
+#undef S31
+#undef S32
+#undef S33
+#undef S34
+#undef S41
+#undef S42
+#undef S43
+#undef S44
diff --git a/package/network/services/ead/src/.svn/text-base/sha1.c.svn-base b/package/network/services/ead/src/.svn/text-base/sha1.c.svn-base
new file mode 100644
index 0000000..3683a7d
--- /dev/null
+++ b/package/network/services/ead/src/.svn/text-base/sha1.c.svn-base
@@ -0,0 +1,104 @@
+/*
+ * SHA transform algorithm, originally taken from code written by
+ * Peter Gutmann, and placed in the public domain.
+ */
+
+static uint32_t
+rol32(uint32_t word, int shift)
+{
+ return (word << shift) | (word >> (32 - shift));
+}
+
+/* The SHA f()-functions. */
+
+#define f1(x,y,z) (z ^ (x & (y ^ z))) /* x ? y : z */
+#define f2(x,y,z) (x ^ y ^ z) /* XOR */
+#define f3(x,y,z) ((x & y) + (z & (x ^ y))) /* majority */
+
+/* The SHA Mysterious Constants */
+
+#define K1 0x5A827999L /* Rounds 0-19: sqrt(2) * 2^30 */
+#define K2 0x6ED9EBA1L /* Rounds 20-39: sqrt(3) * 2^30 */
+#define K3 0x8F1BBCDCL /* Rounds 40-59: sqrt(5) * 2^30 */
+#define K4 0xCA62C1D6L /* Rounds 60-79: sqrt(10) * 2^30 */
+
+/**
+ * sha_transform - single block SHA1 transform
+ *
+ * @digest: 160 bit digest to update
+ * @data: 512 bits of data to hash
+ * @W: 80 words of workspace (see note)
+ *
+ * This function generates a SHA1 digest for a single 512-bit block.
+ * Be warned, it does not handle padding and message digest, do not
+ * confuse it with the full FIPS 180-1 digest algorithm for variable
+ * length messages.
+ *
+ * Note: If the hash is security sensitive, the caller should be sure
+ * to clear the workspace. This is left to the caller to avoid
+ * unnecessary clears between chained hashing operations.
+ */
+static void sha_transform(uint32_t *digest, const unsigned char *in, uint32_t *W)
+{
+ uint32_t a, b, c, d, e, t, i;
+
+ for (i = 0; i < 16; i++) {
+ int ofs = 4 * i;
+
+ /* word load/store may be unaligned here, so use bytes instead */
+ W[i] =
+ (in[ofs+0] << 24) |
+ (in[ofs+1] << 16) |
+ (in[ofs+2] << 8) |
+ in[ofs+3];
+ }
+
+ for (i = 0; i < 64; i++)
+ W[i+16] = rol32(W[i+13] ^ W[i+8] ^ W[i+2] ^ W[i], 1);
+
+ a = digest[0];
+ b = digest[1];
+ c = digest[2];
+ d = digest[3];
+ e = digest[4];
+
+ for (i = 0; i < 20; i++) {
+ t = f1(b, c, d) + K1 + rol32(a, 5) + e + W[i];
+ e = d; d = c; c = rol32(b, 30); b = a; a = t;
+ }
+
+ for (; i < 40; i ++) {
+ t = f2(b, c, d) + K2 + rol32(a, 5) + e + W[i];
+ e = d; d = c; c = rol32(b, 30); b = a; a = t;
+ }
+
+ for (; i < 60; i ++) {
+ t = f3(b, c, d) + K3 + rol32(a, 5) + e + W[i];
+ e = d; d = c; c = rol32(b, 30); b = a; a = t;
+ }
+
+ for (; i < 80; i ++) {
+ t = f2(b, c, d) + K4 + rol32(a, 5) + e + W[i];
+ e = d; d = c; c = rol32(b, 30); b = a; a = t;
+ }
+
+ digest[0] += a;
+ digest[1] += b;
+ digest[2] += c;
+ digest[3] += d;
+ digest[4] += e;
+}
+
+/**
+ * sha_init - initialize the vectors for a SHA1 digest
+ * @buf: vector to initialize
+ */
+static void sha_init(uint32_t *buf)
+{
+ buf[0] = 0x67452301;
+ buf[1] = 0xefcdab89;
+ buf[2] = 0x98badcfe;
+ buf[3] = 0x10325476;
+ buf[4] = 0xc3d2e1f0;
+}
+
diff --git a/package/network/services/ead/src/Makefile b/package/network/services/ead/src/Makefile
new file mode 100644
index 0000000..faef3b7
--- /dev/null
+++ b/package/network/services/ead/src/Makefile
@@ -0,0 +1,33 @@
+CC = gcc
+CPPFLAGS = -I. -Itinysrp
+CFLAGS = -Os -Wall
+LDFLAGS =
+LIBS_EADCLIENT = tinysrp/libtinysrp.a
+LIBS_EAD = tinysrp/libtinysrp.a -lpcap
+CONFIGURE_ARGS =
+
+all: ead ead-client
+
+obj = ead-crypt.o
+
+tinysrp/Makefile:
+ cd tinysrp; ./configure $(CONFIGURE_ARGS)
+
+tinysrp/libtinysrp.a: tinysrp/Makefile
+ -$(MAKE) -C tinysrp CFLAGS="$(CFLAGS)"
+
+%.o: %.c $(wildcard *.h) tinysrp/libtinysrp.a
+ $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
+
+ead.o: filter.c
+ead-crypt.o: aes.c sha1.c
+
+ead: ead.o $(obj) tinysrp/libtinysrp.a
+ $(CC) -o $@ $< $(obj) $(LDFLAGS) $(LIBS_EAD)
+
+ead-client: ead-client.o $(obj)
+ $(CC) -o $@ $< $(obj) $(LDFLAGS) $(LIBS_EADCLIENT)
+
+clean:
+ rm -f *.o ead ead-client
+ if [ -f tinysrp/Makefile ]; then $(MAKE) -C tinysrp distclean; fi
diff --git a/package/network/services/ead/src/aes.c b/package/network/services/ead/src/aes.c
new file mode 100644
index 0000000..6f9db34
--- /dev/null
+++ b/package/network/services/ead/src/aes.c
@@ -0,0 +1,1061 @@
+/*
+ * AES (Rijndael) cipher
+ *
+ * Modifications to public domain implementation:
+ * - support only 128-bit keys
+ * - cleanup
+ * - use C pre-processor to make it easier to change S table access
+ * - added option (AES_SMALL_TABLES) for reducing code size by about 8 kB at
+ * cost of reduced throughput (quite small difference on Pentium 4,
+ * 10-25% when using -O1 or -O2 optimization)
+ *
+ * Copyright (c) 2003-2005, Jouni Malinen <j@w1.fi>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Alternatively, this software may be distributed under the terms of BSD
+ * license.
+ *
+ * See README and COPYING for more details.
+ */
+
+/*
+ * rijndael-alg-fst.c
+ *
+ * @version 3.0 (December 2000)
+ *
+ * Optimised ANSI C code for the Rijndael cipher (now AES)
+ *
+ * @author Vincent Rijmen <vincent.rijmen@esat.kuleuven.ac.be>
+ * @author Antoon Bosselaers <antoon.bosselaers@esat.kuleuven.ac.be>
+ * @author Paulo Barreto <paulo.barreto@terra.com.br>
+ *
+ * This code is hereby placed in the public domain.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* #define FULL_UNROLL */
+#define AES_SMALL_TABLES
+
+typedef uint8_t u8;
+typedef uint16_t u16;
+typedef uint32_t u32;
+
+/*
+Te0[x] = S [x].[02, 01, 01, 03];
+Te1[x] = S [x].[03, 02, 01, 01];
+Te2[x] = S [x].[01, 03, 02, 01];
+Te3[x] = S [x].[01, 01, 03, 02];
+Te4[x] = S [x].[01, 01, 01, 01];
+
+Td0[x] = Si[x].[0e, 09, 0d, 0b];
+Td1[x] = Si[x].[0b, 0e, 09, 0d];
+Td2[x] = Si[x].[0d, 0b, 0e, 09];
+Td3[x] = Si[x].[09, 0d, 0b, 0e];
+Td4[x] = Si[x].[01, 01, 01, 01];
+*/
+
+static const u32 Te0[256] = {
+ 0xc66363a5U, 0xf87c7c84U, 0xee777799U, 0xf67b7b8dU,
+ 0xfff2f20dU, 0xd66b6bbdU, 0xde6f6fb1U, 0x91c5c554U,
+ 0x60303050U, 0x02010103U, 0xce6767a9U, 0x562b2b7dU,
+ 0xe7fefe19U, 0xb5d7d762U, 0x4dababe6U, 0xec76769aU,
+ 0x8fcaca45U, 0x1f82829dU, 0x89c9c940U, 0xfa7d7d87U,
+ 0xeffafa15U, 0xb25959ebU, 0x8e4747c9U, 0xfbf0f00bU,
+ 0x41adadecU, 0xb3d4d467U, 0x5fa2a2fdU, 0x45afafeaU,
+ 0x239c9cbfU, 0x53a4a4f7U, 0xe4727296U, 0x9bc0c05bU,
+ 0x75b7b7c2U, 0xe1fdfd1cU, 0x3d9393aeU, 0x4c26266aU,
+ 0x6c36365aU, 0x7e3f3f41U, 0xf5f7f702U, 0x83cccc4fU,
+ 0x6834345cU, 0x51a5a5f4U, 0xd1e5e534U, 0xf9f1f108U,
+ 0xe2717193U, 0xabd8d873U, 0x62313153U, 0x2a15153fU,
+ 0x0804040cU, 0x95c7c752U, 0x46232365U, 0x9dc3c35eU,
+ 0x30181828U, 0x379696a1U, 0x0a05050fU, 0x2f9a9ab5U,
+ 0x0e070709U, 0x24121236U, 0x1b80809bU, 0xdfe2e23dU,
+ 0xcdebeb26U, 0x4e272769U, 0x7fb2b2cdU, 0xea75759fU,
+ 0x1209091bU, 0x1d83839eU, 0x582c2c74U, 0x341a1a2eU,
+ 0x361b1b2dU, 0xdc6e6eb2U, 0xb45a5aeeU, 0x5ba0a0fbU,
+ 0xa45252f6U, 0x763b3b4dU, 0xb7d6d661U, 0x7db3b3ceU,
+ 0x5229297bU, 0xdde3e33eU, 0x5e2f2f71U, 0x13848497U,
+ 0xa65353f5U, 0xb9d1d168U, 0x00000000U, 0xc1eded2cU,
+ 0x40202060U, 0xe3fcfc1fU, 0x79b1b1c8U, 0xb65b5bedU,
+ 0xd46a6abeU, 0x8dcbcb46U, 0x67bebed9U, 0x7239394bU,
+ 0x944a4adeU, 0x984c4cd4U, 0xb05858e8U, 0x85cfcf4aU,
+ 0xbbd0d06bU, 0xc5efef2aU, 0x4faaaae5U, 0xedfbfb16U,
+ 0x864343c5U, 0x9a4d4dd7U, 0x66333355U, 0x11858594U,
+ 0x8a4545cfU, 0xe9f9f910U, 0x04020206U, 0xfe7f7f81U,
+ 0xa05050f0U, 0x783c3c44U, 0x259f9fbaU, 0x4ba8a8e3U,
+ 0xa25151f3U, 0x5da3a3feU, 0x804040c0U, 0x058f8f8aU,
+ 0x3f9292adU, 0x219d9dbcU, 0x70383848U, 0xf1f5f504U,
+ 0x63bcbcdfU, 0x77b6b6c1U, 0xafdada75U, 0x42212163U,
+ 0x20101030U, 0xe5ffff1aU, 0xfdf3f30eU, 0xbfd2d26dU,
+ 0x81cdcd4cU, 0x180c0c14U, 0x26131335U, 0xc3ecec2fU,
+ 0xbe5f5fe1U, 0x359797a2U, 0x884444ccU, 0x2e171739U,
+ 0x93c4c457U, 0x55a7a7f2U, 0xfc7e7e82U, 0x7a3d3d47U,
+ 0xc86464acU, 0xba5d5de7U, 0x3219192bU, 0xe6737395U,
+ 0xc06060a0U, 0x19818198U, 0x9e4f4fd1U, 0xa3dcdc7fU,
+ 0x44222266U, 0x542a2a7eU, 0x3b9090abU, 0x0b888883U,
+ 0x8c4646caU, 0xc7eeee29U, 0x6bb8b8d3U, 0x2814143cU,
+ 0xa7dede79U, 0xbc5e5ee2U, 0x160b0b1dU, 0xaddbdb76U,
+ 0xdbe0e03bU, 0x64323256U, 0x743a3a4eU, 0x140a0a1eU,
+ 0x924949dbU, 0x0c06060aU, 0x4824246cU, 0xb85c5ce4U,
+ 0x9fc2c25dU, 0xbdd3d36eU, 0x43acacefU, 0xc46262a6U,
+ 0x399191a8U, 0x319595a4U, 0xd3e4e437U, 0xf279798bU,
+ 0xd5e7e732U, 0x8bc8c843U, 0x6e373759U, 0xda6d6db7U,
+ 0x018d8d8cU, 0xb1d5d564U, 0x9c4e4ed2U, 0x49a9a9e0U,
+ 0xd86c6cb4U, 0xac5656faU, 0xf3f4f407U, 0xcfeaea25U,
+ 0xca6565afU, 0xf47a7a8eU, 0x47aeaee9U, 0x10080818U,
+ 0x6fbabad5U, 0xf0787888U, 0x4a25256fU, 0x5c2e2e72U,
+ 0x381c1c24U, 0x57a6a6f1U, 0x73b4b4c7U, 0x97c6c651U,
+ 0xcbe8e823U, 0xa1dddd7cU, 0xe874749cU, 0x3e1f1f21U,
+ 0x964b4bddU, 0x61bdbddcU, 0x0d8b8b86U, 0x0f8a8a85U,
+ 0xe0707090U, 0x7c3e3e42U, 0x71b5b5c4U, 0xcc6666aaU,
+ 0x904848d8U, 0x06030305U, 0xf7f6f601U, 0x1c0e0e12U,
+ 0xc26161a3U, 0x6a35355fU, 0xae5757f9U, 0x69b9b9d0U,
+ 0x17868691U, 0x99c1c158U, 0x3a1d1d27U, 0x279e9eb9U,
+ 0xd9e1e138U, 0xebf8f813U, 0x2b9898b3U, 0x22111133U,
+ 0xd26969bbU, 0xa9d9d970U, 0x078e8e89U, 0x339494a7U,
+ 0x2d9b9bb6U, 0x3c1e1e22U, 0x15878792U, 0xc9e9e920U,
+ 0x87cece49U, 0xaa5555ffU, 0x50282878U, 0xa5dfdf7aU,
+ 0x038c8c8fU, 0x59a1a1f8U, 0x09898980U, 0x1a0d0d17U,
+ 0x65bfbfdaU, 0xd7e6e631U, 0x844242c6U, 0xd06868b8U,
+ 0x824141c3U, 0x299999b0U, 0x5a2d2d77U, 0x1e0f0f11U,
+ 0x7bb0b0cbU, 0xa85454fcU, 0x6dbbbbd6U, 0x2c16163aU,
+};
+#ifndef AES_SMALL_TABLES
+static const u32 Te1[256] = {
+ 0xa5c66363U, 0x84f87c7cU, 0x99ee7777U, 0x8df67b7bU,
+ 0x0dfff2f2U, 0xbdd66b6bU, 0xb1de6f6fU, 0x5491c5c5U,
+ 0x50603030U, 0x03020101U, 0xa9ce6767U, 0x7d562b2bU,
+ 0x19e7fefeU, 0x62b5d7d7U, 0xe64dababU, 0x9aec7676U,
+ 0x458fcacaU, 0x9d1f8282U, 0x4089c9c9U, 0x87fa7d7dU,
+ 0x15effafaU, 0xebb25959U, 0xc98e4747U, 0x0bfbf0f0U,
+ 0xec41adadU, 0x67b3d4d4U, 0xfd5fa2a2U, 0xea45afafU,
+ 0xbf239c9cU, 0xf753a4a4U, 0x96e47272U, 0x5b9bc0c0U,
+ 0xc275b7b7U, 0x1ce1fdfdU, 0xae3d9393U, 0x6a4c2626U,
+ 0x5a6c3636U, 0x417e3f3fU, 0x02f5f7f7U, 0x4f83ccccU,
+ 0x5c683434U, 0xf451a5a5U, 0x34d1e5e5U, 0x08f9f1f1U,
+ 0x93e27171U, 0x73abd8d8U, 0x53623131U, 0x3f2a1515U,
+ 0x0c080404U, 0x5295c7c7U, 0x65462323U, 0x5e9dc3c3U,
+ 0x28301818U, 0xa1379696U, 0x0f0a0505U, 0xb52f9a9aU,
+ 0x090e0707U, 0x36241212U, 0x9b1b8080U, 0x3ddfe2e2U,
+ 0x26cdebebU, 0x694e2727U, 0xcd7fb2b2U, 0x9fea7575U,
+ 0x1b120909U, 0x9e1d8383U, 0x74582c2cU, 0x2e341a1aU,
+ 0x2d361b1bU, 0xb2dc6e6eU, 0xeeb45a5aU, 0xfb5ba0a0U,
+ 0xf6a45252U, 0x4d763b3bU, 0x61b7d6d6U, 0xce7db3b3U,
+ 0x7b522929U, 0x3edde3e3U, 0x715e2f2fU, 0x97138484U,
+ 0xf5a65353U, 0x68b9d1d1U, 0x00000000U, 0x2cc1ededU,
+ 0x60402020U, 0x1fe3fcfcU, 0xc879b1b1U, 0xedb65b5bU,
+ 0xbed46a6aU, 0x468dcbcbU, 0xd967bebeU, 0x4b723939U,
+ 0xde944a4aU, 0xd4984c4cU, 0xe8b05858U, 0x4a85cfcfU,
+ 0x6bbbd0d0U, 0x2ac5efefU, 0xe54faaaaU, 0x16edfbfbU,
+ 0xc5864343U, 0xd79a4d4dU, 0x55663333U, 0x94118585U,
+ 0xcf8a4545U, 0x10e9f9f9U, 0x06040202U, 0x81fe7f7fU,
+ 0xf0a05050U, 0x44783c3cU, 0xba259f9fU, 0xe34ba8a8U,
+ 0xf3a25151U, 0xfe5da3a3U, 0xc0804040U, 0x8a058f8fU,
+ 0xad3f9292U, 0xbc219d9dU, 0x48703838U, 0x04f1f5f5U,
+ 0xdf63bcbcU, 0xc177b6b6U, 0x75afdadaU, 0x63422121U,
+ 0x30201010U, 0x1ae5ffffU, 0x0efdf3f3U, 0x6dbfd2d2U,
+ 0x4c81cdcdU, 0x14180c0cU, 0x35261313U, 0x2fc3ececU,
+ 0xe1be5f5fU, 0xa2359797U, 0xcc884444U, 0x392e1717U,
+ 0x5793c4c4U, 0xf255a7a7U, 0x82fc7e7eU, 0x477a3d3dU,
+ 0xacc86464U, 0xe7ba5d5dU, 0x2b321919U, 0x95e67373U,
+ 0xa0c06060U, 0x98198181U, 0xd19e4f4fU, 0x7fa3dcdcU,
+ 0x66442222U, 0x7e542a2aU, 0xab3b9090U, 0x830b8888U,
+ 0xca8c4646U, 0x29c7eeeeU, 0xd36bb8b8U, 0x3c281414U,
+ 0x79a7dedeU, 0xe2bc5e5eU, 0x1d160b0bU, 0x76addbdbU,
+ 0x3bdbe0e0U, 0x56643232U, 0x4e743a3aU, 0x1e140a0aU,
+ 0xdb924949U, 0x0a0c0606U, 0x6c482424U, 0xe4b85c5cU,
+ 0x5d9fc2c2U, 0x6ebdd3d3U, 0xef43acacU, 0xa6c46262U,
+ 0xa8399191U, 0xa4319595U, 0x37d3e4e4U, 0x8bf27979U,
+ 0x32d5e7e7U, 0x438bc8c8U, 0x596e3737U, 0xb7da6d6dU,
+ 0x8c018d8dU, 0x64b1d5d5U, 0xd29c4e4eU, 0xe049a9a9U,
+ 0xb4d86c6cU, 0xfaac5656U, 0x07f3f4f4U, 0x25cfeaeaU,
+ 0xafca6565U, 0x8ef47a7aU, 0xe947aeaeU, 0x18100808U,
+ 0xd56fbabaU, 0x88f07878U, 0x6f4a2525U, 0x725c2e2eU,
+ 0x24381c1cU, 0xf157a6a6U, 0xc773b4b4U, 0x5197c6c6U,
+ 0x23cbe8e8U, 0x7ca1ddddU, 0x9ce87474U, 0x213e1f1fU,
+ 0xdd964b4bU, 0xdc61bdbdU, 0x860d8b8bU, 0x850f8a8aU,
+ 0x90e07070U, 0x427c3e3eU, 0xc471b5b5U, 0xaacc6666U,
+ 0xd8904848U, 0x05060303U, 0x01f7f6f6U, 0x121c0e0eU,
+ 0xa3c26161U, 0x5f6a3535U, 0xf9ae5757U, 0xd069b9b9U,
+ 0x91178686U, 0x5899c1c1U, 0x273a1d1dU, 0xb9279e9eU,
+ 0x38d9e1e1U, 0x13ebf8f8U, 0xb32b9898U, 0x33221111U,
+ 0xbbd26969U, 0x70a9d9d9U, 0x89078e8eU, 0xa7339494U,
+ 0xb62d9b9bU, 0x223c1e1eU, 0x92158787U, 0x20c9e9e9U,
+ 0x4987ceceU, 0xffaa5555U, 0x78502828U, 0x7aa5dfdfU,
+ 0x8f038c8cU, 0xf859a1a1U, 0x80098989U, 0x171a0d0dU,
+ 0xda65bfbfU, 0x31d7e6e6U, 0xc6844242U, 0xb8d06868U,
+ 0xc3824141U, 0xb0299999U, 0x775a2d2dU, 0x111e0f0fU,
+ 0xcb7bb0b0U, 0xfca85454U, 0xd66dbbbbU, 0x3a2c1616U,
+};
+static const u32 Te2[256] = {
+ 0x63a5c663U, 0x7c84f87cU, 0x7799ee77U, 0x7b8df67bU,
+ 0xf20dfff2U, 0x6bbdd66bU, 0x6fb1de6fU, 0xc55491c5U,
+ 0x30506030U, 0x01030201U, 0x67a9ce67U, 0x2b7d562bU,
+ 0xfe19e7feU, 0xd762b5d7U, 0xabe64dabU, 0x769aec76U,
+ 0xca458fcaU, 0x829d1f82U, 0xc94089c9U, 0x7d87fa7dU,
+ 0xfa15effaU, 0x59ebb259U, 0x47c98e47U, 0xf00bfbf0U,
+ 0xadec41adU, 0xd467b3d4U, 0xa2fd5fa2U, 0xafea45afU,
+ 0x9cbf239cU, 0xa4f753a4U, 0x7296e472U, 0xc05b9bc0U,
+ 0xb7c275b7U, 0xfd1ce1fdU, 0x93ae3d93U, 0x266a4c26U,
+ 0x365a6c36U, 0x3f417e3fU, 0xf702f5f7U, 0xcc4f83ccU,
+ 0x345c6834U, 0xa5f451a5U, 0xe534d1e5U, 0xf108f9f1U,
+ 0x7193e271U, 0xd873abd8U, 0x31536231U, 0x153f2a15U,
+ 0x040c0804U, 0xc75295c7U, 0x23654623U, 0xc35e9dc3U,
+ 0x18283018U, 0x96a13796U, 0x050f0a05U, 0x9ab52f9aU,
+ 0x07090e07U, 0x12362412U, 0x809b1b80U, 0xe23ddfe2U,
+ 0xeb26cdebU, 0x27694e27U, 0xb2cd7fb2U, 0x759fea75U,
+ 0x091b1209U, 0x839e1d83U, 0x2c74582cU, 0x1a2e341aU,
+ 0x1b2d361bU, 0x6eb2dc6eU, 0x5aeeb45aU, 0xa0fb5ba0U,
+ 0x52f6a452U, 0x3b4d763bU, 0xd661b7d6U, 0xb3ce7db3U,
+ 0x297b5229U, 0xe33edde3U, 0x2f715e2fU, 0x84971384U,
+ 0x53f5a653U, 0xd168b9d1U, 0x00000000U, 0xed2cc1edU,
+ 0x20604020U, 0xfc1fe3fcU, 0xb1c879b1U, 0x5bedb65bU,
+ 0x6abed46aU, 0xcb468dcbU, 0xbed967beU, 0x394b7239U,
+ 0x4ade944aU, 0x4cd4984cU, 0x58e8b058U, 0xcf4a85cfU,
+ 0xd06bbbd0U, 0xef2ac5efU, 0xaae54faaU, 0xfb16edfbU,
+ 0x43c58643U, 0x4dd79a4dU, 0x33556633U, 0x85941185U,
+ 0x45cf8a45U, 0xf910e9f9U, 0x02060402U, 0x7f81fe7fU,
+ 0x50f0a050U, 0x3c44783cU, 0x9fba259fU, 0xa8e34ba8U,
+ 0x51f3a251U, 0xa3fe5da3U, 0x40c08040U, 0x8f8a058fU,
+ 0x92ad3f92U, 0x9dbc219dU, 0x38487038U, 0xf504f1f5U,
+ 0xbcdf63bcU, 0xb6c177b6U, 0xda75afdaU, 0x21634221U,
+ 0x10302010U, 0xff1ae5ffU, 0xf30efdf3U, 0xd26dbfd2U,
+ 0xcd4c81cdU, 0x0c14180cU, 0x13352613U, 0xec2fc3ecU,
+ 0x5fe1be5fU, 0x97a23597U, 0x44cc8844U, 0x17392e17U,
+ 0xc45793c4U, 0xa7f255a7U, 0x7e82fc7eU, 0x3d477a3dU,
+ 0x64acc864U, 0x5de7ba5dU, 0x192b3219U, 0x7395e673U,
+ 0x60a0c060U, 0x81981981U, 0x4fd19e4fU, 0xdc7fa3dcU,
+ 0x22664422U, 0x2a7e542aU, 0x90ab3b90U, 0x88830b88U,
+ 0x46ca8c46U, 0xee29c7eeU, 0xb8d36bb8U, 0x143c2814U,
+ 0xde79a7deU, 0x5ee2bc5eU, 0x0b1d160bU, 0xdb76addbU,
+ 0xe03bdbe0U, 0x32566432U, 0x3a4e743aU, 0x0a1e140aU,
+ 0x49db9249U, 0x060a0c06U, 0x246c4824U, 0x5ce4b85cU,
+ 0xc25d9fc2U, 0xd36ebdd3U, 0xacef43acU, 0x62a6c462U,
+ 0x91a83991U, 0x95a43195U, 0xe437d3e4U, 0x798bf279U,
+ 0xe732d5e7U, 0xc8438bc8U, 0x37596e37U, 0x6db7da6dU,
+ 0x8d8c018dU, 0xd564b1d5U, 0x4ed29c4eU, 0xa9e049a9U,
+ 0x6cb4d86cU, 0x56faac56U, 0xf407f3f4U, 0xea25cfeaU,
+ 0x65afca65U, 0x7a8ef47aU, 0xaee947aeU, 0x08181008U,
+ 0xbad56fbaU, 0x7888f078U, 0x256f4a25U, 0x2e725c2eU,
+ 0x1c24381cU, 0xa6f157a6U, 0xb4c773b4U, 0xc65197c6U,
+ 0xe823cbe8U, 0xdd7ca1ddU, 0x749ce874U, 0x1f213e1fU,
+ 0x4bdd964bU, 0xbddc61bdU, 0x8b860d8bU, 0x8a850f8aU,
+ 0x7090e070U, 0x3e427c3eU, 0xb5c471b5U, 0x66aacc66U,
+ 0x48d89048U, 0x03050603U, 0xf601f7f6U, 0x0e121c0eU,
+ 0x61a3c261U, 0x355f6a35U, 0x57f9ae57U, 0xb9d069b9U,
+ 0x86911786U, 0xc15899c1U, 0x1d273a1dU, 0x9eb9279eU,
+ 0xe138d9e1U, 0xf813ebf8U, 0x98b32b98U, 0x11332211U,
+ 0x69bbd269U, 0xd970a9d9U, 0x8e89078eU, 0x94a73394U,
+ 0x9bb62d9bU, 0x1e223c1eU, 0x87921587U, 0xe920c9e9U,
+ 0xce4987ceU, 0x55ffaa55U, 0x28785028U, 0xdf7aa5dfU,
+ 0x8c8f038cU, 0xa1f859a1U, 0x89800989U, 0x0d171a0dU,
+ 0xbfda65bfU, 0xe631d7e6U, 0x42c68442U, 0x68b8d068U,
+ 0x41c38241U, 0x99b02999U, 0x2d775a2dU, 0x0f111e0fU,
+ 0xb0cb7bb0U, 0x54fca854U, 0xbbd66dbbU, 0x163a2c16U,
+};
+static const u32 Te3[256] = {
+
+ 0x6363a5c6U, 0x7c7c84f8U, 0x777799eeU, 0x7b7b8df6U,
+ 0xf2f20dffU, 0x6b6bbdd6U, 0x6f6fb1deU, 0xc5c55491U,
+ 0x30305060U, 0x01010302U, 0x6767a9ceU, 0x2b2b7d56U,
+ 0xfefe19e7U, 0xd7d762b5U, 0xababe64dU, 0x76769aecU,
+ 0xcaca458fU, 0x82829d1fU, 0xc9c94089U, 0x7d7d87faU,
+ 0xfafa15efU, 0x5959ebb2U, 0x4747c98eU, 0xf0f00bfbU,
+ 0xadadec41U, 0xd4d467b3U, 0xa2a2fd5fU, 0xafafea45U,
+ 0x9c9cbf23U, 0xa4a4f753U, 0x727296e4U, 0xc0c05b9bU,
+ 0xb7b7c275U, 0xfdfd1ce1U, 0x9393ae3dU, 0x26266a4cU,
+ 0x36365a6cU, 0x3f3f417eU, 0xf7f702f5U, 0xcccc4f83U,
+ 0x34345c68U, 0xa5a5f451U, 0xe5e534d1U, 0xf1f108f9U,
+ 0x717193e2U, 0xd8d873abU, 0x31315362U, 0x15153f2aU,
+ 0x04040c08U, 0xc7c75295U, 0x23236546U, 0xc3c35e9dU,
+ 0x18182830U, 0x9696a137U, 0x05050f0aU, 0x9a9ab52fU,
+ 0x0707090eU, 0x12123624U, 0x80809b1bU, 0xe2e23ddfU,
+ 0xebeb26cdU, 0x2727694eU, 0xb2b2cd7fU, 0x75759feaU,
+ 0x09091b12U, 0x83839e1dU, 0x2c2c7458U, 0x1a1a2e34U,
+ 0x1b1b2d36U, 0x6e6eb2dcU, 0x5a5aeeb4U, 0xa0a0fb5bU,
+ 0x5252f6a4U, 0x3b3b4d76U, 0xd6d661b7U, 0xb3b3ce7dU,
+ 0x29297b52U, 0xe3e33eddU, 0x2f2f715eU, 0x84849713U,
+ 0x5353f5a6U, 0xd1d168b9U, 0x00000000U, 0xeded2cc1U,
+ 0x20206040U, 0xfcfc1fe3U, 0xb1b1c879U, 0x5b5bedb6U,
+ 0x6a6abed4U, 0xcbcb468dU, 0xbebed967U, 0x39394b72U,
+ 0x4a4ade94U, 0x4c4cd498U, 0x5858e8b0U, 0xcfcf4a85U,
+ 0xd0d06bbbU, 0xefef2ac5U, 0xaaaae54fU, 0xfbfb16edU,
+ 0x4343c586U, 0x4d4dd79aU, 0x33335566U, 0x85859411U,
+ 0x4545cf8aU, 0xf9f910e9U, 0x02020604U, 0x7f7f81feU,
+ 0x5050f0a0U, 0x3c3c4478U, 0x9f9fba25U, 0xa8a8e34bU,
+ 0x5151f3a2U, 0xa3a3fe5dU, 0x4040c080U, 0x8f8f8a05U,
+ 0x9292ad3fU, 0x9d9dbc21U, 0x38384870U, 0xf5f504f1U,
+ 0xbcbcdf63U, 0xb6b6c177U, 0xdada75afU, 0x21216342U,
+ 0x10103020U, 0xffff1ae5U, 0xf3f30efdU, 0xd2d26dbfU,
+ 0xcdcd4c81U, 0x0c0c1418U, 0x13133526U, 0xecec2fc3U,
+ 0x5f5fe1beU, 0x9797a235U, 0x4444cc88U, 0x1717392eU,
+ 0xc4c45793U, 0xa7a7f255U, 0x7e7e82fcU, 0x3d3d477aU,
+ 0x6464acc8U, 0x5d5de7baU, 0x19192b32U, 0x737395e6U,
+ 0x6060a0c0U, 0x81819819U, 0x4f4fd19eU, 0xdcdc7fa3U,
+ 0x22226644U, 0x2a2a7e54U, 0x9090ab3bU, 0x8888830bU,
+ 0x4646ca8cU, 0xeeee29c7U, 0xb8b8d36bU, 0x14143c28U,
+ 0xdede79a7U, 0x5e5ee2bcU, 0x0b0b1d16U, 0xdbdb76adU,
+ 0xe0e03bdbU, 0x32325664U, 0x3a3a4e74U, 0x0a0a1e14U,
+ 0x4949db92U, 0x06060a0cU, 0x24246c48U, 0x5c5ce4b8U,
+ 0xc2c25d9fU, 0xd3d36ebdU, 0xacacef43U, 0x6262a6c4U,
+ 0x9191a839U, 0x9595a431U, 0xe4e437d3U, 0x79798bf2U,
+ 0xe7e732d5U, 0xc8c8438bU, 0x3737596eU, 0x6d6db7daU,
+ 0x8d8d8c01U, 0xd5d564b1U, 0x4e4ed29cU, 0xa9a9e049U,
+ 0x6c6cb4d8U, 0x5656faacU, 0xf4f407f3U, 0xeaea25cfU,
+ 0x6565afcaU, 0x7a7a8ef4U, 0xaeaee947U, 0x08081810U,
+ 0xbabad56fU, 0x787888f0U, 0x25256f4aU, 0x2e2e725cU,
+ 0x1c1c2438U, 0xa6a6f157U, 0xb4b4c773U, 0xc6c65197U,
+ 0xe8e823cbU, 0xdddd7ca1U, 0x74749ce8U, 0x1f1f213eU,
+ 0x4b4bdd96U, 0xbdbddc61U, 0x8b8b860dU, 0x8a8a850fU,
+ 0x707090e0U, 0x3e3e427cU, 0xb5b5c471U, 0x6666aaccU,
+ 0x4848d890U, 0x03030506U, 0xf6f601f7U, 0x0e0e121cU,
+ 0x6161a3c2U, 0x35355f6aU, 0x5757f9aeU, 0xb9b9d069U,
+ 0x86869117U, 0xc1c15899U, 0x1d1d273aU, 0x9e9eb927U,
+ 0xe1e138d9U, 0xf8f813ebU, 0x9898b32bU, 0x11113322U,
+ 0x6969bbd2U, 0xd9d970a9U, 0x8e8e8907U, 0x9494a733U,
+ 0x9b9bb62dU, 0x1e1e223cU, 0x87879215U, 0xe9e920c9U,
+ 0xcece4987U, 0x5555ffaaU, 0x28287850U, 0xdfdf7aa5U,
+ 0x8c8c8f03U, 0xa1a1f859U, 0x89898009U, 0x0d0d171aU,
+ 0xbfbfda65U, 0xe6e631d7U, 0x4242c684U, 0x6868b8d0U,
+ 0x4141c382U, 0x9999b029U, 0x2d2d775aU, 0x0f0f111eU,
+ 0xb0b0cb7bU, 0x5454fca8U, 0xbbbbd66dU, 0x16163a2cU,
+};
+static const u32 Te4[256] = {
+ 0x63636363U, 0x7c7c7c7cU, 0x77777777U, 0x7b7b7b7bU,
+ 0xf2f2f2f2U, 0x6b6b6b6bU, 0x6f6f6f6fU, 0xc5c5c5c5U,
+ 0x30303030U, 0x01010101U, 0x67676767U, 0x2b2b2b2bU,
+ 0xfefefefeU, 0xd7d7d7d7U, 0xababababU, 0x76767676U,
+ 0xcacacacaU, 0x82828282U, 0xc9c9c9c9U, 0x7d7d7d7dU,
+ 0xfafafafaU, 0x59595959U, 0x47474747U, 0xf0f0f0f0U,
+ 0xadadadadU, 0xd4d4d4d4U, 0xa2a2a2a2U, 0xafafafafU,
+ 0x9c9c9c9cU, 0xa4a4a4a4U, 0x72727272U, 0xc0c0c0c0U,
+ 0xb7b7b7b7U, 0xfdfdfdfdU, 0x93939393U, 0x26262626U,
+ 0x36363636U, 0x3f3f3f3fU, 0xf7f7f7f7U, 0xccccccccU,
+ 0x34343434U, 0xa5a5a5a5U, 0xe5e5e5e5U, 0xf1f1f1f1U,
+ 0x71717171U, 0xd8d8d8d8U, 0x31313131U, 0x15151515U,
+ 0x04040404U, 0xc7c7c7c7U, 0x23232323U, 0xc3c3c3c3U,
+ 0x18181818U, 0x96969696U, 0x05050505U, 0x9a9a9a9aU,
+ 0x07070707U, 0x12121212U, 0x80808080U, 0xe2e2e2e2U,
+ 0xebebebebU, 0x27272727U, 0xb2b2b2b2U, 0x75757575U,
+ 0x09090909U, 0x83838383U, 0x2c2c2c2cU, 0x1a1a1a1aU,
+ 0x1b1b1b1bU, 0x6e6e6e6eU, 0x5a5a5a5aU, 0xa0a0a0a0U,
+ 0x52525252U, 0x3b3b3b3bU, 0xd6d6d6d6U, 0xb3b3b3b3U,
+ 0x29292929U, 0xe3e3e3e3U, 0x2f2f2f2fU, 0x84848484U,
+ 0x53535353U, 0xd1d1d1d1U, 0x00000000U, 0xededededU,
+ 0x20202020U, 0xfcfcfcfcU, 0xb1b1b1b1U, 0x5b5b5b5bU,
+ 0x6a6a6a6aU, 0xcbcbcbcbU, 0xbebebebeU, 0x39393939U,
+ 0x4a4a4a4aU, 0x4c4c4c4cU, 0x58585858U, 0xcfcfcfcfU,
+ 0xd0d0d0d0U, 0xefefefefU, 0xaaaaaaaaU, 0xfbfbfbfbU,
+ 0x43434343U, 0x4d4d4d4dU, 0x33333333U, 0x85858585U,
+ 0x45454545U, 0xf9f9f9f9U, 0x02020202U, 0x7f7f7f7fU,
+ 0x50505050U, 0x3c3c3c3cU, 0x9f9f9f9fU, 0xa8a8a8a8U,
+ 0x51515151U, 0xa3a3a3a3U, 0x40404040U, 0x8f8f8f8fU,
+ 0x92929292U, 0x9d9d9d9dU, 0x38383838U, 0xf5f5f5f5U,
+ 0xbcbcbcbcU, 0xb6b6b6b6U, 0xdadadadaU, 0x21212121U,
+ 0x10101010U, 0xffffffffU, 0xf3f3f3f3U, 0xd2d2d2d2U,
+ 0xcdcdcdcdU, 0x0c0c0c0cU, 0x13131313U, 0xececececU,
+ 0x5f5f5f5fU, 0x97979797U, 0x44444444U, 0x17171717U,
+ 0xc4c4c4c4U, 0xa7a7a7a7U, 0x7e7e7e7eU, 0x3d3d3d3dU,
+ 0x64646464U, 0x5d5d5d5dU, 0x19191919U, 0x73737373U,
+ 0x60606060U, 0x81818181U, 0x4f4f4f4fU, 0xdcdcdcdcU,
+ 0x22222222U, 0x2a2a2a2aU, 0x90909090U, 0x88888888U,
+ 0x46464646U, 0xeeeeeeeeU, 0xb8b8b8b8U, 0x14141414U,
+ 0xdedededeU, 0x5e5e5e5eU, 0x0b0b0b0bU, 0xdbdbdbdbU,
+ 0xe0e0e0e0U, 0x32323232U, 0x3a3a3a3aU, 0x0a0a0a0aU,
+ 0x49494949U, 0x06060606U, 0x24242424U, 0x5c5c5c5cU,
+ 0xc2c2c2c2U, 0xd3d3d3d3U, 0xacacacacU, 0x62626262U,
+ 0x91919191U, 0x95959595U, 0xe4e4e4e4U, 0x79797979U,
+ 0xe7e7e7e7U, 0xc8c8c8c8U, 0x37373737U, 0x6d6d6d6dU,
+ 0x8d8d8d8dU, 0xd5d5d5d5U, 0x4e4e4e4eU, 0xa9a9a9a9U,
+ 0x6c6c6c6cU, 0x56565656U, 0xf4f4f4f4U, 0xeaeaeaeaU,
+ 0x65656565U, 0x7a7a7a7aU, 0xaeaeaeaeU, 0x08080808U,
+ 0xbabababaU, 0x78787878U, 0x25252525U, 0x2e2e2e2eU,
+ 0x1c1c1c1cU, 0xa6a6a6a6U, 0xb4b4b4b4U, 0xc6c6c6c6U,
+ 0xe8e8e8e8U, 0xddddddddU, 0x74747474U, 0x1f1f1f1fU,
+ 0x4b4b4b4bU, 0xbdbdbdbdU, 0x8b8b8b8bU, 0x8a8a8a8aU,
+ 0x70707070U, 0x3e3e3e3eU, 0xb5b5b5b5U, 0x66666666U,
+ 0x48484848U, 0x03030303U, 0xf6f6f6f6U, 0x0e0e0e0eU,
+ 0x61616161U, 0x35353535U, 0x57575757U, 0xb9b9b9b9U,
+ 0x86868686U, 0xc1c1c1c1U, 0x1d1d1d1dU, 0x9e9e9e9eU,
+ 0xe1e1e1e1U, 0xf8f8f8f8U, 0x98989898U, 0x11111111U,
+ 0x69696969U, 0xd9d9d9d9U, 0x8e8e8e8eU, 0x94949494U,
+ 0x9b9b9b9bU, 0x1e1e1e1eU, 0x87878787U, 0xe9e9e9e9U,
+ 0xcecececeU, 0x55555555U, 0x28282828U, 0xdfdfdfdfU,
+ 0x8c8c8c8cU, 0xa1a1a1a1U, 0x89898989U, 0x0d0d0d0dU,
+ 0xbfbfbfbfU, 0xe6e6e6e6U, 0x42424242U, 0x68686868U,
+ 0x41414141U, 0x99999999U, 0x2d2d2d2dU, 0x0f0f0f0fU,
+ 0xb0b0b0b0U, 0x54545454U, 0xbbbbbbbbU, 0x16161616U,
+};
+#endif /* AES_SMALL_TABLES */
+static const u32 Td0[256] = {
+ 0x51f4a750U, 0x7e416553U, 0x1a17a4c3U, 0x3a275e96U,
+ 0x3bab6bcbU, 0x1f9d45f1U, 0xacfa58abU, 0x4be30393U,
+ 0x2030fa55U, 0xad766df6U, 0x88cc7691U, 0xf5024c25U,
+ 0x4fe5d7fcU, 0xc52acbd7U, 0x26354480U, 0xb562a38fU,
+ 0xdeb15a49U, 0x25ba1b67U, 0x45ea0e98U, 0x5dfec0e1U,
+ 0xc32f7502U, 0x814cf012U, 0x8d4697a3U, 0x6bd3f9c6U,
+ 0x038f5fe7U, 0x15929c95U, 0xbf6d7aebU, 0x955259daU,
+ 0xd4be832dU, 0x587421d3U, 0x49e06929U, 0x8ec9c844U,
+ 0x75c2896aU, 0xf48e7978U, 0x99583e6bU, 0x27b971ddU,
+ 0xbee14fb6U, 0xf088ad17U, 0xc920ac66U, 0x7dce3ab4U,
+ 0x63df4a18U, 0xe51a3182U, 0x97513360U, 0x62537f45U,
+ 0xb16477e0U, 0xbb6bae84U, 0xfe81a01cU, 0xf9082b94U,
+ 0x70486858U, 0x8f45fd19U, 0x94de6c87U, 0x527bf8b7U,
+ 0xab73d323U, 0x724b02e2U, 0xe31f8f57U, 0x6655ab2aU,
+ 0xb2eb2807U, 0x2fb5c203U, 0x86c57b9aU, 0xd33708a5U,
+ 0x302887f2U, 0x23bfa5b2U, 0x02036abaU, 0xed16825cU,
+ 0x8acf1c2bU, 0xa779b492U, 0xf307f2f0U, 0x4e69e2a1U,
+ 0x65daf4cdU, 0x0605bed5U, 0xd134621fU, 0xc4a6fe8aU,
+ 0x342e539dU, 0xa2f355a0U, 0x058ae132U, 0xa4f6eb75U,
+ 0x0b83ec39U, 0x4060efaaU, 0x5e719f06U, 0xbd6e1051U,
+ 0x3e218af9U, 0x96dd063dU, 0xdd3e05aeU, 0x4de6bd46U,
+ 0x91548db5U, 0x71c45d05U, 0x0406d46fU, 0x605015ffU,
+ 0x1998fb24U, 0xd6bde997U, 0x894043ccU, 0x67d99e77U,
+ 0xb0e842bdU, 0x07898b88U, 0xe7195b38U, 0x79c8eedbU,
+ 0xa17c0a47U, 0x7c420fe9U, 0xf8841ec9U, 0x00000000U,
+ 0x09808683U, 0x322bed48U, 0x1e1170acU, 0x6c5a724eU,
+ 0xfd0efffbU, 0x0f853856U, 0x3daed51eU, 0x362d3927U,
+ 0x0a0fd964U, 0x685ca621U, 0x9b5b54d1U, 0x24362e3aU,
+ 0x0c0a67b1U, 0x9357e70fU, 0xb4ee96d2U, 0x1b9b919eU,
+ 0x80c0c54fU, 0x61dc20a2U, 0x5a774b69U, 0x1c121a16U,
+ 0xe293ba0aU, 0xc0a02ae5U, 0x3c22e043U, 0x121b171dU,
+ 0x0e090d0bU, 0xf28bc7adU, 0x2db6a8b9U, 0x141ea9c8U,
+ 0x57f11985U, 0xaf75074cU, 0xee99ddbbU, 0xa37f60fdU,
+ 0xf701269fU, 0x5c72f5bcU, 0x44663bc5U, 0x5bfb7e34U,
+ 0x8b432976U, 0xcb23c6dcU, 0xb6edfc68U, 0xb8e4f163U,
+ 0xd731dccaU, 0x42638510U, 0x13972240U, 0x84c61120U,
+ 0x854a247dU, 0xd2bb3df8U, 0xaef93211U, 0xc729a16dU,
+ 0x1d9e2f4bU, 0xdcb230f3U, 0x0d8652ecU, 0x77c1e3d0U,
+ 0x2bb3166cU, 0xa970b999U, 0x119448faU, 0x47e96422U,
+ 0xa8fc8cc4U, 0xa0f03f1aU, 0x567d2cd8U, 0x223390efU,
+ 0x87494ec7U, 0xd938d1c1U, 0x8ccaa2feU, 0x98d40b36U,
+ 0xa6f581cfU, 0xa57ade28U, 0xdab78e26U, 0x3fadbfa4U,
+ 0x2c3a9de4U, 0x5078920dU, 0x6a5fcc9bU, 0x547e4662U,
+ 0xf68d13c2U, 0x90d8b8e8U, 0x2e39f75eU, 0x82c3aff5U,
+ 0x9f5d80beU, 0x69d0937cU, 0x6fd52da9U, 0xcf2512b3U,
+ 0xc8ac993bU, 0x10187da7U, 0xe89c636eU, 0xdb3bbb7bU,
+ 0xcd267809U, 0x6e5918f4U, 0xec9ab701U, 0x834f9aa8U,
+ 0xe6956e65U, 0xaaffe67eU, 0x21bccf08U, 0xef15e8e6U,
+ 0xbae79bd9U, 0x4a6f36ceU, 0xea9f09d4U, 0x29b07cd6U,
+ 0x31a4b2afU, 0x2a3f2331U, 0xc6a59430U, 0x35a266c0U,
+ 0x744ebc37U, 0xfc82caa6U, 0xe090d0b0U, 0x33a7d815U,
+ 0xf104984aU, 0x41ecdaf7U, 0x7fcd500eU, 0x1791f62fU,
+ 0x764dd68dU, 0x43efb04dU, 0xccaa4d54U, 0xe49604dfU,
+ 0x9ed1b5e3U, 0x4c6a881bU, 0xc12c1fb8U, 0x4665517fU,
+ 0x9d5eea04U, 0x018c355dU, 0xfa877473U, 0xfb0b412eU,
+ 0xb3671d5aU, 0x92dbd252U, 0xe9105633U, 0x6dd64713U,
+ 0x9ad7618cU, 0x37a10c7aU, 0x59f8148eU, 0xeb133c89U,
+ 0xcea927eeU, 0xb761c935U, 0xe11ce5edU, 0x7a47b13cU,
+ 0x9cd2df59U, 0x55f2733fU, 0x1814ce79U, 0x73c737bfU,
+ 0x53f7cdeaU, 0x5ffdaa5bU, 0xdf3d6f14U, 0x7844db86U,
+ 0xcaaff381U, 0xb968c43eU, 0x3824342cU, 0xc2a3405fU,
+ 0x161dc372U, 0xbce2250cU, 0x283c498bU, 0xff0d9541U,
+ 0x39a80171U, 0x080cb3deU, 0xd8b4e49cU, 0x6456c190U,
+ 0x7bcb8461U, 0xd532b670U, 0x486c5c74U, 0xd0b85742U,
+};
+#ifndef AES_SMALL_TABLES
+static const u32 Td1[256] = {
+ 0x5051f4a7U, 0x537e4165U, 0xc31a17a4U, 0x963a275eU,
+ 0xcb3bab6bU, 0xf11f9d45U, 0xabacfa58U, 0x934be303U,
+ 0x552030faU, 0xf6ad766dU, 0x9188cc76U, 0x25f5024cU,
+ 0xfc4fe5d7U, 0xd7c52acbU, 0x80263544U, 0x8fb562a3U,
+ 0x49deb15aU, 0x6725ba1bU, 0x9845ea0eU, 0xe15dfec0U,
+ 0x02c32f75U, 0x12814cf0U, 0xa38d4697U, 0xc66bd3f9U,
+ 0xe7038f5fU, 0x9515929cU, 0xebbf6d7aU, 0xda955259U,
+ 0x2dd4be83U, 0xd3587421U, 0x2949e069U, 0x448ec9c8U,
+ 0x6a75c289U, 0x78f48e79U, 0x6b99583eU, 0xdd27b971U,
+ 0xb6bee14fU, 0x17f088adU, 0x66c920acU, 0xb47dce3aU,
+ 0x1863df4aU, 0x82e51a31U, 0x60975133U, 0x4562537fU,
+ 0xe0b16477U, 0x84bb6baeU, 0x1cfe81a0U, 0x94f9082bU,
+ 0x58704868U, 0x198f45fdU, 0x8794de6cU, 0xb7527bf8U,
+ 0x23ab73d3U, 0xe2724b02U, 0x57e31f8fU, 0x2a6655abU,
+ 0x07b2eb28U, 0x032fb5c2U, 0x9a86c57bU, 0xa5d33708U,
+ 0xf2302887U, 0xb223bfa5U, 0xba02036aU, 0x5ced1682U,
+ 0x2b8acf1cU, 0x92a779b4U, 0xf0f307f2U, 0xa14e69e2U,
+ 0xcd65daf4U, 0xd50605beU, 0x1fd13462U, 0x8ac4a6feU,
+ 0x9d342e53U, 0xa0a2f355U, 0x32058ae1U, 0x75a4f6ebU,
+ 0x390b83ecU, 0xaa4060efU, 0x065e719fU, 0x51bd6e10U,
+ 0xf93e218aU, 0x3d96dd06U, 0xaedd3e05U, 0x464de6bdU,
+ 0xb591548dU, 0x0571c45dU, 0x6f0406d4U, 0xff605015U,
+ 0x241998fbU, 0x97d6bde9U, 0xcc894043U, 0x7767d99eU,
+ 0xbdb0e842U, 0x8807898bU, 0x38e7195bU, 0xdb79c8eeU,
+ 0x47a17c0aU, 0xe97c420fU, 0xc9f8841eU, 0x00000000U,
+ 0x83098086U, 0x48322bedU, 0xac1e1170U, 0x4e6c5a72U,
+ 0xfbfd0effU, 0x560f8538U, 0x1e3daed5U, 0x27362d39U,
+ 0x640a0fd9U, 0x21685ca6U, 0xd19b5b54U, 0x3a24362eU,
+ 0xb10c0a67U, 0x0f9357e7U, 0xd2b4ee96U, 0x9e1b9b91U,
+ 0x4f80c0c5U, 0xa261dc20U, 0x695a774bU, 0x161c121aU,
+ 0x0ae293baU, 0xe5c0a02aU, 0x433c22e0U, 0x1d121b17U,
+ 0x0b0e090dU, 0xadf28bc7U, 0xb92db6a8U, 0xc8141ea9U,
+ 0x8557f119U, 0x4caf7507U, 0xbbee99ddU, 0xfda37f60U,
+ 0x9ff70126U, 0xbc5c72f5U, 0xc544663bU, 0x345bfb7eU,
+ 0x768b4329U, 0xdccb23c6U, 0x68b6edfcU, 0x63b8e4f1U,
+ 0xcad731dcU, 0x10426385U, 0x40139722U, 0x2084c611U,
+ 0x7d854a24U, 0xf8d2bb3dU, 0x11aef932U, 0x6dc729a1U,
+ 0x4b1d9e2fU, 0xf3dcb230U, 0xec0d8652U, 0xd077c1e3U,
+ 0x6c2bb316U, 0x99a970b9U, 0xfa119448U, 0x2247e964U,
+ 0xc4a8fc8cU, 0x1aa0f03fU, 0xd8567d2cU, 0xef223390U,
+ 0xc787494eU, 0xc1d938d1U, 0xfe8ccaa2U, 0x3698d40bU,
+ 0xcfa6f581U, 0x28a57adeU, 0x26dab78eU, 0xa43fadbfU,
+ 0xe42c3a9dU, 0x0d507892U, 0x9b6a5fccU, 0x62547e46U,
+ 0xc2f68d13U, 0xe890d8b8U, 0x5e2e39f7U, 0xf582c3afU,
+ 0xbe9f5d80U, 0x7c69d093U, 0xa96fd52dU, 0xb3cf2512U,
+ 0x3bc8ac99U, 0xa710187dU, 0x6ee89c63U, 0x7bdb3bbbU,
+ 0x09cd2678U, 0xf46e5918U, 0x01ec9ab7U, 0xa8834f9aU,
+ 0x65e6956eU, 0x7eaaffe6U, 0x0821bccfU, 0xe6ef15e8U,
+ 0xd9bae79bU, 0xce4a6f36U, 0xd4ea9f09U, 0xd629b07cU,
+ 0xaf31a4b2U, 0x312a3f23U, 0x30c6a594U, 0xc035a266U,
+ 0x37744ebcU, 0xa6fc82caU, 0xb0e090d0U, 0x1533a7d8U,
+ 0x4af10498U, 0xf741ecdaU, 0x0e7fcd50U, 0x2f1791f6U,
+ 0x8d764dd6U, 0x4d43efb0U, 0x54ccaa4dU, 0xdfe49604U,
+ 0xe39ed1b5U, 0x1b4c6a88U, 0xb8c12c1fU, 0x7f466551U,
+ 0x049d5eeaU, 0x5d018c35U, 0x73fa8774U, 0x2efb0b41U,
+ 0x5ab3671dU, 0x5292dbd2U, 0x33e91056U, 0x136dd647U,
+ 0x8c9ad761U, 0x7a37a10cU, 0x8e59f814U, 0x89eb133cU,
+ 0xeecea927U, 0x35b761c9U, 0xede11ce5U, 0x3c7a47b1U,
+ 0x599cd2dfU, 0x3f55f273U, 0x791814ceU, 0xbf73c737U,
+ 0xea53f7cdU, 0x5b5ffdaaU, 0x14df3d6fU, 0x867844dbU,
+ 0x81caaff3U, 0x3eb968c4U, 0x2c382434U, 0x5fc2a340U,
+ 0x72161dc3U, 0x0cbce225U, 0x8b283c49U, 0x41ff0d95U,
+ 0x7139a801U, 0xde080cb3U, 0x9cd8b4e4U, 0x906456c1U,
+ 0x617bcb84U, 0x70d532b6U, 0x74486c5cU, 0x42d0b857U,
+};
+static const u32 Td2[256] = {
+ 0xa75051f4U, 0x65537e41U, 0xa4c31a17U, 0x5e963a27U,
+ 0x6bcb3babU, 0x45f11f9dU, 0x58abacfaU, 0x03934be3U,
+ 0xfa552030U, 0x6df6ad76U, 0x769188ccU, 0x4c25f502U,
+ 0xd7fc4fe5U, 0xcbd7c52aU, 0x44802635U, 0xa38fb562U,
+ 0x5a49deb1U, 0x1b6725baU, 0x0e9845eaU, 0xc0e15dfeU,
+ 0x7502c32fU, 0xf012814cU, 0x97a38d46U, 0xf9c66bd3U,
+ 0x5fe7038fU, 0x9c951592U, 0x7aebbf6dU, 0x59da9552U,
+ 0x832dd4beU, 0x21d35874U, 0x692949e0U, 0xc8448ec9U,
+ 0x896a75c2U, 0x7978f48eU, 0x3e6b9958U, 0x71dd27b9U,
+ 0x4fb6bee1U, 0xad17f088U, 0xac66c920U, 0x3ab47dceU,
+ 0x4a1863dfU, 0x3182e51aU, 0x33609751U, 0x7f456253U,
+ 0x77e0b164U, 0xae84bb6bU, 0xa01cfe81U, 0x2b94f908U,
+ 0x68587048U, 0xfd198f45U, 0x6c8794deU, 0xf8b7527bU,
+ 0xd323ab73U, 0x02e2724bU, 0x8f57e31fU, 0xab2a6655U,
+ 0x2807b2ebU, 0xc2032fb5U, 0x7b9a86c5U, 0x08a5d337U,
+ 0x87f23028U, 0xa5b223bfU, 0x6aba0203U, 0x825ced16U,
+ 0x1c2b8acfU, 0xb492a779U, 0xf2f0f307U, 0xe2a14e69U,
+ 0xf4cd65daU, 0xbed50605U, 0x621fd134U, 0xfe8ac4a6U,
+ 0x539d342eU, 0x55a0a2f3U, 0xe132058aU, 0xeb75a4f6U,
+ 0xec390b83U, 0xefaa4060U, 0x9f065e71U, 0x1051bd6eU,
+
+ 0x8af93e21U, 0x063d96ddU, 0x05aedd3eU, 0xbd464de6U,
+ 0x8db59154U, 0x5d0571c4U, 0xd46f0406U, 0x15ff6050U,
+ 0xfb241998U, 0xe997d6bdU, 0x43cc8940U, 0x9e7767d9U,
+ 0x42bdb0e8U, 0x8b880789U, 0x5b38e719U, 0xeedb79c8U,
+ 0x0a47a17cU, 0x0fe97c42U, 0x1ec9f884U, 0x00000000U,
+ 0x86830980U, 0xed48322bU, 0x70ac1e11U, 0x724e6c5aU,
+ 0xfffbfd0eU, 0x38560f85U, 0xd51e3daeU, 0x3927362dU,
+ 0xd9640a0fU, 0xa621685cU, 0x54d19b5bU, 0x2e3a2436U,
+ 0x67b10c0aU, 0xe70f9357U, 0x96d2b4eeU, 0x919e1b9bU,
+ 0xc54f80c0U, 0x20a261dcU, 0x4b695a77U, 0x1a161c12U,
+ 0xba0ae293U, 0x2ae5c0a0U, 0xe0433c22U, 0x171d121bU,
+ 0x0d0b0e09U, 0xc7adf28bU, 0xa8b92db6U, 0xa9c8141eU,
+ 0x198557f1U, 0x074caf75U, 0xddbbee99U, 0x60fda37fU,
+ 0x269ff701U, 0xf5bc5c72U, 0x3bc54466U, 0x7e345bfbU,
+ 0x29768b43U, 0xc6dccb23U, 0xfc68b6edU, 0xf163b8e4U,
+ 0xdccad731U, 0x85104263U, 0x22401397U, 0x112084c6U,
+ 0x247d854aU, 0x3df8d2bbU, 0x3211aef9U, 0xa16dc729U,
+ 0x2f4b1d9eU, 0x30f3dcb2U, 0x52ec0d86U, 0xe3d077c1U,
+ 0x166c2bb3U, 0xb999a970U, 0x48fa1194U, 0x642247e9U,
+ 0x8cc4a8fcU, 0x3f1aa0f0U, 0x2cd8567dU, 0x90ef2233U,
+ 0x4ec78749U, 0xd1c1d938U, 0xa2fe8ccaU, 0x0b3698d4U,
+ 0x81cfa6f5U, 0xde28a57aU, 0x8e26dab7U, 0xbfa43fadU,
+ 0x9de42c3aU, 0x920d5078U, 0xcc9b6a5fU, 0x4662547eU,
+ 0x13c2f68dU, 0xb8e890d8U, 0xf75e2e39U, 0xaff582c3U,
+ 0x80be9f5dU, 0x937c69d0U, 0x2da96fd5U, 0x12b3cf25U,
+ 0x993bc8acU, 0x7da71018U, 0x636ee89cU, 0xbb7bdb3bU,
+ 0x7809cd26U, 0x18f46e59U, 0xb701ec9aU, 0x9aa8834fU,
+ 0x6e65e695U, 0xe67eaaffU, 0xcf0821bcU, 0xe8e6ef15U,
+ 0x9bd9bae7U, 0x36ce4a6fU, 0x09d4ea9fU, 0x7cd629b0U,
+ 0xb2af31a4U, 0x23312a3fU, 0x9430c6a5U, 0x66c035a2U,
+ 0xbc37744eU, 0xcaa6fc82U, 0xd0b0e090U, 0xd81533a7U,
+ 0x984af104U, 0xdaf741ecU, 0x500e7fcdU, 0xf62f1791U,
+ 0xd68d764dU, 0xb04d43efU, 0x4d54ccaaU, 0x04dfe496U,
+ 0xb5e39ed1U, 0x881b4c6aU, 0x1fb8c12cU, 0x517f4665U,
+ 0xea049d5eU, 0x355d018cU, 0x7473fa87U, 0x412efb0bU,
+ 0x1d5ab367U, 0xd25292dbU, 0x5633e910U, 0x47136dd6U,
+ 0x618c9ad7U, 0x0c7a37a1U, 0x148e59f8U, 0x3c89eb13U,
+ 0x27eecea9U, 0xc935b761U, 0xe5ede11cU, 0xb13c7a47U,
+ 0xdf599cd2U, 0x733f55f2U, 0xce791814U, 0x37bf73c7U,
+ 0xcdea53f7U, 0xaa5b5ffdU, 0x6f14df3dU, 0xdb867844U,
+ 0xf381caafU, 0xc43eb968U, 0x342c3824U, 0x405fc2a3U,
+ 0xc372161dU, 0x250cbce2U, 0x498b283cU, 0x9541ff0dU,
+ 0x017139a8U, 0xb3de080cU, 0xe49cd8b4U, 0xc1906456U,
+ 0x84617bcbU, 0xb670d532U, 0x5c74486cU, 0x5742d0b8U,
+};
+static const u32 Td3[256] = {
+ 0xf4a75051U, 0x4165537eU, 0x17a4c31aU, 0x275e963aU,
+ 0xab6bcb3bU, 0x9d45f11fU, 0xfa58abacU, 0xe303934bU,
+ 0x30fa5520U, 0x766df6adU, 0xcc769188U, 0x024c25f5U,
+ 0xe5d7fc4fU, 0x2acbd7c5U, 0x35448026U, 0x62a38fb5U,
+ 0xb15a49deU, 0xba1b6725U, 0xea0e9845U, 0xfec0e15dU,
+ 0x2f7502c3U, 0x4cf01281U, 0x4697a38dU, 0xd3f9c66bU,
+ 0x8f5fe703U, 0x929c9515U, 0x6d7aebbfU, 0x5259da95U,
+ 0xbe832dd4U, 0x7421d358U, 0xe0692949U, 0xc9c8448eU,
+ 0xc2896a75U, 0x8e7978f4U, 0x583e6b99U, 0xb971dd27U,
+ 0xe14fb6beU, 0x88ad17f0U, 0x20ac66c9U, 0xce3ab47dU,
+ 0xdf4a1863U, 0x1a3182e5U, 0x51336097U, 0x537f4562U,
+ 0x6477e0b1U, 0x6bae84bbU, 0x81a01cfeU, 0x082b94f9U,
+ 0x48685870U, 0x45fd198fU, 0xde6c8794U, 0x7bf8b752U,
+ 0x73d323abU, 0x4b02e272U, 0x1f8f57e3U, 0x55ab2a66U,
+ 0xeb2807b2U, 0xb5c2032fU, 0xc57b9a86U, 0x3708a5d3U,
+ 0x2887f230U, 0xbfa5b223U, 0x036aba02U, 0x16825cedU,
+ 0xcf1c2b8aU, 0x79b492a7U, 0x07f2f0f3U, 0x69e2a14eU,
+ 0xdaf4cd65U, 0x05bed506U, 0x34621fd1U, 0xa6fe8ac4U,
+ 0x2e539d34U, 0xf355a0a2U, 0x8ae13205U, 0xf6eb75a4U,
+ 0x83ec390bU, 0x60efaa40U, 0x719f065eU, 0x6e1051bdU,
+ 0x218af93eU, 0xdd063d96U, 0x3e05aeddU, 0xe6bd464dU,
+ 0x548db591U, 0xc45d0571U, 0x06d46f04U, 0x5015ff60U,
+ 0x98fb2419U, 0xbde997d6U, 0x4043cc89U, 0xd99e7767U,
+ 0xe842bdb0U, 0x898b8807U, 0x195b38e7U, 0xc8eedb79U,
+ 0x7c0a47a1U, 0x420fe97cU, 0x841ec9f8U, 0x00000000U,
+ 0x80868309U, 0x2bed4832U, 0x1170ac1eU, 0x5a724e6cU,
+ 0x0efffbfdU, 0x8538560fU, 0xaed51e3dU, 0x2d392736U,
+ 0x0fd9640aU, 0x5ca62168U, 0x5b54d19bU, 0x362e3a24U,
+ 0x0a67b10cU, 0x57e70f93U, 0xee96d2b4U, 0x9b919e1bU,
+ 0xc0c54f80U, 0xdc20a261U, 0x774b695aU, 0x121a161cU,
+ 0x93ba0ae2U, 0xa02ae5c0U, 0x22e0433cU, 0x1b171d12U,
+ 0x090d0b0eU, 0x8bc7adf2U, 0xb6a8b92dU, 0x1ea9c814U,
+ 0xf1198557U, 0x75074cafU, 0x99ddbbeeU, 0x7f60fda3U,
+ 0x01269ff7U, 0x72f5bc5cU, 0x663bc544U, 0xfb7e345bU,
+ 0x4329768bU, 0x23c6dccbU, 0xedfc68b6U, 0xe4f163b8U,
+ 0x31dccad7U, 0x63851042U, 0x97224013U, 0xc6112084U,
+ 0x4a247d85U, 0xbb3df8d2U, 0xf93211aeU, 0x29a16dc7U,
+ 0x9e2f4b1dU, 0xb230f3dcU, 0x8652ec0dU, 0xc1e3d077U,
+ 0xb3166c2bU, 0x70b999a9U, 0x9448fa11U, 0xe9642247U,
+ 0xfc8cc4a8U, 0xf03f1aa0U, 0x7d2cd856U, 0x3390ef22U,
+ 0x494ec787U, 0x38d1c1d9U, 0xcaa2fe8cU, 0xd40b3698U,
+ 0xf581cfa6U, 0x7ade28a5U, 0xb78e26daU, 0xadbfa43fU,
+ 0x3a9de42cU, 0x78920d50U, 0x5fcc9b6aU, 0x7e466254U,
+ 0x8d13c2f6U, 0xd8b8e890U, 0x39f75e2eU, 0xc3aff582U,
+ 0x5d80be9fU, 0xd0937c69U, 0xd52da96fU, 0x2512b3cfU,
+ 0xac993bc8U, 0x187da710U, 0x9c636ee8U, 0x3bbb7bdbU,
+ 0x267809cdU, 0x5918f46eU, 0x9ab701ecU, 0x4f9aa883U,
+ 0x956e65e6U, 0xffe67eaaU, 0xbccf0821U, 0x15e8e6efU,
+ 0xe79bd9baU, 0x6f36ce4aU, 0x9f09d4eaU, 0xb07cd629U,
+ 0xa4b2af31U, 0x3f23312aU, 0xa59430c6U, 0xa266c035U,
+ 0x4ebc3774U, 0x82caa6fcU, 0x90d0b0e0U, 0xa7d81533U,
+ 0x04984af1U, 0xecdaf741U, 0xcd500e7fU, 0x91f62f17U,
+ 0x4dd68d76U, 0xefb04d43U, 0xaa4d54ccU, 0x9604dfe4U,
+ 0xd1b5e39eU, 0x6a881b4cU, 0x2c1fb8c1U, 0x65517f46U,
+ 0x5eea049dU, 0x8c355d01U, 0x877473faU, 0x0b412efbU,
+ 0x671d5ab3U, 0xdbd25292U, 0x105633e9U, 0xd647136dU,
+ 0xd7618c9aU, 0xa10c7a37U, 0xf8148e59U, 0x133c89ebU,
+ 0xa927eeceU, 0x61c935b7U, 0x1ce5ede1U, 0x47b13c7aU,
+ 0xd2df599cU, 0xf2733f55U, 0x14ce7918U, 0xc737bf73U,
+ 0xf7cdea53U, 0xfdaa5b5fU, 0x3d6f14dfU, 0x44db8678U,
+ 0xaff381caU, 0x68c43eb9U, 0x24342c38U, 0xa3405fc2U,
+ 0x1dc37216U, 0xe2250cbcU, 0x3c498b28U, 0x0d9541ffU,
+ 0xa8017139U, 0x0cb3de08U, 0xb4e49cd8U, 0x56c19064U,
+ 0xcb84617bU, 0x32b670d5U, 0x6c5c7448U, 0xb85742d0U,
+};
+static const u32 Td4[256] = {
+ 0x52525252U, 0x09090909U, 0x6a6a6a6aU, 0xd5d5d5d5U,
+ 0x30303030U, 0x36363636U, 0xa5a5a5a5U, 0x38383838U,
+ 0xbfbfbfbfU, 0x40404040U, 0xa3a3a3a3U, 0x9e9e9e9eU,
+ 0x81818181U, 0xf3f3f3f3U, 0xd7d7d7d7U, 0xfbfbfbfbU,
+ 0x7c7c7c7cU, 0xe3e3e3e3U, 0x39393939U, 0x82828282U,
+ 0x9b9b9b9bU, 0x2f2f2f2fU, 0xffffffffU, 0x87878787U,
+ 0x34343434U, 0x8e8e8e8eU, 0x43434343U, 0x44444444U,
+ 0xc4c4c4c4U, 0xdedededeU, 0xe9e9e9e9U, 0xcbcbcbcbU,
+ 0x54545454U, 0x7b7b7b7bU, 0x94949494U, 0x32323232U,
+ 0xa6a6a6a6U, 0xc2c2c2c2U, 0x23232323U, 0x3d3d3d3dU,
+ 0xeeeeeeeeU, 0x4c4c4c4cU, 0x95959595U, 0x0b0b0b0bU,
+ 0x42424242U, 0xfafafafaU, 0xc3c3c3c3U, 0x4e4e4e4eU,
+ 0x08080808U, 0x2e2e2e2eU, 0xa1a1a1a1U, 0x66666666U,
+ 0x28282828U, 0xd9d9d9d9U, 0x24242424U, 0xb2b2b2b2U,
+ 0x76767676U, 0x5b5b5b5bU, 0xa2a2a2a2U, 0x49494949U,
+ 0x6d6d6d6dU, 0x8b8b8b8bU, 0xd1d1d1d1U, 0x25252525U,
+ 0x72727272U, 0xf8f8f8f8U, 0xf6f6f6f6U, 0x64646464U,
+ 0x86868686U, 0x68686868U, 0x98989898U, 0x16161616U,
+ 0xd4d4d4d4U, 0xa4a4a4a4U, 0x5c5c5c5cU, 0xccccccccU,
+ 0x5d5d5d5dU, 0x65656565U, 0xb6b6b6b6U, 0x92929292U,
+ 0x6c6c6c6cU, 0x70707070U, 0x48484848U, 0x50505050U,
+ 0xfdfdfdfdU, 0xededededU, 0xb9b9b9b9U, 0xdadadadaU,
+ 0x5e5e5e5eU, 0x15151515U, 0x46464646U, 0x57575757U,
+ 0xa7a7a7a7U, 0x8d8d8d8dU, 0x9d9d9d9dU, 0x84848484U,
+ 0x90909090U, 0xd8d8d8d8U, 0xababababU, 0x00000000U,
+ 0x8c8c8c8cU, 0xbcbcbcbcU, 0xd3d3d3d3U, 0x0a0a0a0aU,
+ 0xf7f7f7f7U, 0xe4e4e4e4U, 0x58585858U, 0x05050505U,
+ 0xb8b8b8b8U, 0xb3b3b3b3U, 0x45454545U, 0x06060606U,
+ 0xd0d0d0d0U, 0x2c2c2c2cU, 0x1e1e1e1eU, 0x8f8f8f8fU,
+ 0xcacacacaU, 0x3f3f3f3fU, 0x0f0f0f0fU, 0x02020202U,
+ 0xc1c1c1c1U, 0xafafafafU, 0xbdbdbdbdU, 0x03030303U,
+ 0x01010101U, 0x13131313U, 0x8a8a8a8aU, 0x6b6b6b6bU,
+ 0x3a3a3a3aU, 0x91919191U, 0x11111111U, 0x41414141U,
+ 0x4f4f4f4fU, 0x67676767U, 0xdcdcdcdcU, 0xeaeaeaeaU,
+ 0x97979797U, 0xf2f2f2f2U, 0xcfcfcfcfU, 0xcecececeU,
+ 0xf0f0f0f0U, 0xb4b4b4b4U, 0xe6e6e6e6U, 0x73737373U,
+ 0x96969696U, 0xacacacacU, 0x74747474U, 0x22222222U,
+ 0xe7e7e7e7U, 0xadadadadU, 0x35353535U, 0x85858585U,
+ 0xe2e2e2e2U, 0xf9f9f9f9U, 0x37373737U, 0xe8e8e8e8U,
+ 0x1c1c1c1cU, 0x75757575U, 0xdfdfdfdfU, 0x6e6e6e6eU,
+ 0x47474747U, 0xf1f1f1f1U, 0x1a1a1a1aU, 0x71717171U,
+ 0x1d1d1d1dU, 0x29292929U, 0xc5c5c5c5U, 0x89898989U,
+ 0x6f6f6f6fU, 0xb7b7b7b7U, 0x62626262U, 0x0e0e0e0eU,
+ 0xaaaaaaaaU, 0x18181818U, 0xbebebebeU, 0x1b1b1b1bU,
+ 0xfcfcfcfcU, 0x56565656U, 0x3e3e3e3eU, 0x4b4b4b4bU,
+ 0xc6c6c6c6U, 0xd2d2d2d2U, 0x79797979U, 0x20202020U,
+ 0x9a9a9a9aU, 0xdbdbdbdbU, 0xc0c0c0c0U, 0xfefefefeU,
+ 0x78787878U, 0xcdcdcdcdU, 0x5a5a5a5aU, 0xf4f4f4f4U,
+ 0x1f1f1f1fU, 0xddddddddU, 0xa8a8a8a8U, 0x33333333U,
+ 0x88888888U, 0x07070707U, 0xc7c7c7c7U, 0x31313131U,
+ 0xb1b1b1b1U, 0x12121212U, 0x10101010U, 0x59595959U,
+ 0x27272727U, 0x80808080U, 0xececececU, 0x5f5f5f5fU,
+ 0x60606060U, 0x51515151U, 0x7f7f7f7fU, 0xa9a9a9a9U,
+ 0x19191919U, 0xb5b5b5b5U, 0x4a4a4a4aU, 0x0d0d0d0dU,
+ 0x2d2d2d2dU, 0xe5e5e5e5U, 0x7a7a7a7aU, 0x9f9f9f9fU,
+ 0x93939393U, 0xc9c9c9c9U, 0x9c9c9c9cU, 0xefefefefU,
+ 0xa0a0a0a0U, 0xe0e0e0e0U, 0x3b3b3b3bU, 0x4d4d4d4dU,
+ 0xaeaeaeaeU, 0x2a2a2a2aU, 0xf5f5f5f5U, 0xb0b0b0b0U,
+ 0xc8c8c8c8U, 0xebebebebU, 0xbbbbbbbbU, 0x3c3c3c3cU,
+ 0x83838383U, 0x53535353U, 0x99999999U, 0x61616161U,
+ 0x17171717U, 0x2b2b2b2bU, 0x04040404U, 0x7e7e7e7eU,
+ 0xbabababaU, 0x77777777U, 0xd6d6d6d6U, 0x26262626U,
+ 0xe1e1e1e1U, 0x69696969U, 0x14141414U, 0x63636363U,
+ 0x55555555U, 0x21212121U, 0x0c0c0c0cU, 0x7d7d7d7dU,
+};
+static const u32 rcon[] = {
+ 0x01000000, 0x02000000, 0x04000000, 0x08000000,
+ 0x10000000, 0x20000000, 0x40000000, 0x80000000,
+ 0x1B000000, 0x36000000, /* for 128-bit blocks, Rijndael never uses more than 10 rcon values */
+};
+#else /* AES_SMALL_TABLES */
+static const u8 Td4s[256] = {
+ 0x52U, 0x09U, 0x6aU, 0xd5U, 0x30U, 0x36U, 0xa5U, 0x38U,
+ 0xbfU, 0x40U, 0xa3U, 0x9eU, 0x81U, 0xf3U, 0xd7U, 0xfbU,
+ 0x7cU, 0xe3U, 0x39U, 0x82U, 0x9bU, 0x2fU, 0xffU, 0x87U,
+ 0x34U, 0x8eU, 0x43U, 0x44U, 0xc4U, 0xdeU, 0xe9U, 0xcbU,
+ 0x54U, 0x7bU, 0x94U, 0x32U, 0xa6U, 0xc2U, 0x23U, 0x3dU,
+ 0xeeU, 0x4cU, 0x95U, 0x0bU, 0x42U, 0xfaU, 0xc3U, 0x4eU,
+ 0x08U, 0x2eU, 0xa1U, 0x66U, 0x28U, 0xd9U, 0x24U, 0xb2U,
+ 0x76U, 0x5bU, 0xa2U, 0x49U, 0x6dU, 0x8bU, 0xd1U, 0x25U,
+ 0x72U, 0xf8U, 0xf6U, 0x64U, 0x86U, 0x68U, 0x98U, 0x16U,
+ 0xd4U, 0xa4U, 0x5cU, 0xccU, 0x5dU, 0x65U, 0xb6U, 0x92U,
+ 0x6cU, 0x70U, 0x48U, 0x50U, 0xfdU, 0xedU, 0xb9U, 0xdaU,
+ 0x5eU, 0x15U, 0x46U, 0x57U, 0xa7U, 0x8dU, 0x9dU, 0x84U,
+ 0x90U, 0xd8U, 0xabU, 0x00U, 0x8cU, 0xbcU, 0xd3U, 0x0aU,
+ 0xf7U, 0xe4U, 0x58U, 0x05U, 0xb8U, 0xb3U, 0x45U, 0x06U,
+ 0xd0U, 0x2cU, 0x1eU, 0x8fU, 0xcaU, 0x3fU, 0x0fU, 0x02U,
+ 0xc1U, 0xafU, 0xbdU, 0x03U, 0x01U, 0x13U, 0x8aU, 0x6bU,
+ 0x3aU, 0x91U, 0x11U, 0x41U, 0x4fU, 0x67U, 0xdcU, 0xeaU,
+ 0x97U, 0xf2U, 0xcfU, 0xceU, 0xf0U, 0xb4U, 0xe6U, 0x73U,
+ 0x96U, 0xacU, 0x74U, 0x22U, 0xe7U, 0xadU, 0x35U, 0x85U,
+ 0xe2U, 0xf9U, 0x37U, 0xe8U, 0x1cU, 0x75U, 0xdfU, 0x6eU,
+ 0x47U, 0xf1U, 0x1aU, 0x71U, 0x1dU, 0x29U, 0xc5U, 0x89U,
+ 0x6fU, 0xb7U, 0x62U, 0x0eU, 0xaaU, 0x18U, 0xbeU, 0x1bU,
+ 0xfcU, 0x56U, 0x3eU, 0x4bU, 0xc6U, 0xd2U, 0x79U, 0x20U,
+ 0x9aU, 0xdbU, 0xc0U, 0xfeU, 0x78U, 0xcdU, 0x5aU, 0xf4U,
+ 0x1fU, 0xddU, 0xa8U, 0x33U, 0x88U, 0x07U, 0xc7U, 0x31U,
+ 0xb1U, 0x12U, 0x10U, 0x59U, 0x27U, 0x80U, 0xecU, 0x5fU,
+ 0x60U, 0x51U, 0x7fU, 0xa9U, 0x19U, 0xb5U, 0x4aU, 0x0dU,
+ 0x2dU, 0xe5U, 0x7aU, 0x9fU, 0x93U, 0xc9U, 0x9cU, 0xefU,
+ 0xa0U, 0xe0U, 0x3bU, 0x4dU, 0xaeU, 0x2aU, 0xf5U, 0xb0U,
+ 0xc8U, 0xebU, 0xbbU, 0x3cU, 0x83U, 0x53U, 0x99U, 0x61U,
+ 0x17U, 0x2bU, 0x04U, 0x7eU, 0xbaU, 0x77U, 0xd6U, 0x26U,
+ 0xe1U, 0x69U, 0x14U, 0x63U, 0x55U, 0x21U, 0x0cU, 0x7dU,
+};
+static const u8 rcons[] = {
+ 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1B, 0x36
+ /* for 128-bit blocks, Rijndael never uses more than 10 rcon values */
+};
+#endif /* AES_SMALL_TABLES */
+
+
+#ifndef AES_SMALL_TABLES
+
+#define RCON(i) rcon[(i)]
+
+#define TE0(i) Te0[((i) >> 24) & 0xff]
+#define TE1(i) Te1[((i) >> 16) & 0xff]
+#define TE2(i) Te2[((i) >> 8) & 0xff]
+#define TE3(i) Te3[(i) & 0xff]
+#define TE41(i) (Te4[((i) >> 24) & 0xff] & 0xff000000)
+#define TE42(i) (Te4[((i) >> 16) & 0xff] & 0x00ff0000)
+#define TE43(i) (Te4[((i) >> 8) & 0xff] & 0x0000ff00)
+#define TE44(i) (Te4[(i) & 0xff] & 0x000000ff)
+#define TE421(i) (Te4[((i) >> 16) & 0xff] & 0xff000000)
+#define TE432(i) (Te4[((i) >> 8) & 0xff] & 0x00ff0000)
+#define TE443(i) (Te4[(i) & 0xff] & 0x0000ff00)
+#define TE414(i) (Te4[((i) >> 24) & 0xff] & 0x000000ff)
+#define TE4(i) (Te4[(i)] & 0x000000ff)
+
+#define TD0(i) Td0[((i) >> 24) & 0xff]
+#define TD1(i) Td1[((i) >> 16) & 0xff]
+#define TD2(i) Td2[((i) >> 8) & 0xff]
+#define TD3(i) Td3[(i) & 0xff]
+#define TD41(i) (Td4[((i) >> 24) & 0xff] & 0xff000000)
+#define TD42(i) (Td4[((i) >> 16) & 0xff] & 0x00ff0000)
+#define TD43(i) (Td4[((i) >> 8) & 0xff] & 0x0000ff00)
+#define TD44(i) (Td4[(i) & 0xff] & 0x000000ff)
+#define TD0_(i) Td0[(i) & 0xff]
+#define TD1_(i) Td1[(i) & 0xff]
+#define TD2_(i) Td2[(i) & 0xff]
+#define TD3_(i) Td3[(i) & 0xff]
+
+#else /* AES_SMALL_TABLES */
+
+#define RCON(i) (rcons[(i)] << 24)
+
+static inline u32 rotr(u32 val, int bits)
+{
+ return (val >> bits) | (val << (32 - bits));
+}
+
+#define TE0(i) Te0[((i) >> 24) & 0xff]
+#define TE1(i) rotr(Te0[((i) >> 16) & 0xff], 8)
+#define TE2(i) rotr(Te0[((i) >> 8) & 0xff], 16)
+#define TE3(i) rotr(Te0[(i) & 0xff], 24)
+#define TE41(i) ((Te0[((i) >> 24) & 0xff] << 8) & 0xff000000)
+#define TE42(i) (Te0[((i) >> 16) & 0xff] & 0x00ff0000)
+#define TE43(i) (Te0[((i) >> 8) & 0xff] & 0x0000ff00)
+#define TE44(i) ((Te0[(i) & 0xff] >> 8) & 0x000000ff)
+#define TE421(i) ((Te0[((i) >> 16) & 0xff] << 8) & 0xff000000)
+#define TE432(i) (Te0[((i) >> 8) & 0xff] & 0x00ff0000)
+#define TE443(i) (Te0[(i) & 0xff] & 0x0000ff00)
+#define TE414(i) ((Te0[((i) >> 24) & 0xff] >> 8) & 0x000000ff)
+#define TE4(i) ((Te0[(i)] >> 8) & 0x000000ff)
+
+#define TD0(i) Td0[((i) >> 24) & 0xff]
+#define TD1(i) rotr(Td0[((i) >> 16) & 0xff], 8)
+#define TD2(i) rotr(Td0[((i) >> 8) & 0xff], 16)
+#define TD3(i) rotr(Td0[(i) & 0xff], 24)
+#define TD41(i) (Td4s[((i) >> 24) & 0xff] << 24)
+#define TD42(i) (Td4s[((i) >> 16) & 0xff] << 16)
+#define TD43(i) (Td4s[((i) >> 8) & 0xff] << 8)
+#define TD44(i) (Td4s[(i) & 0xff])
+#define TD0_(i) Td0[(i) & 0xff]
+#define TD1_(i) rotr(Td0[(i) & 0xff], 8)
+#define TD2_(i) rotr(Td0[(i) & 0xff], 16)
+#define TD3_(i) rotr(Td0[(i) & 0xff], 24)
+
+#endif /* AES_SMALL_TABLES */
+
+#define SWAP(x) (_lrotl(x, 8) & 0x00ff00ff | _lrotr(x, 8) & 0xff00ff00)
+
+#ifdef _MSC_VER
+#define GETU32(p) SWAP(*((u32 *)(p)))
+#define PUTU32(ct, st) { *((u32 *)(ct)) = SWAP((st)); }
+#else
+#define GETU32(pt) (((u32)(pt)[0] << 24) ^ ((u32)(pt)[1] << 16) ^ \
+((u32)(pt)[2] << 8) ^ ((u32)(pt)[3]))
+#define PUTU32(ct, st) { \
+(ct)[0] = (u8)((st) >> 24); (ct)[1] = (u8)((st) >> 16); \
+(ct)[2] = (u8)((st) >> 8); (ct)[3] = (u8)(st); }
+#endif
+
+/**
+ * Expand the cipher key into the encryption key schedule.
+ *
+ * @return the number of rounds for the given cipher key size.
+ */
+static void rijndaelKeySetupEnc(u32 rk[/*44*/], const u8 cipherKey[])
+{
+ int i;
+ u32 temp;
+
+ rk[0] = GETU32(cipherKey );
+ rk[1] = GETU32(cipherKey + 4);
+ rk[2] = GETU32(cipherKey + 8);
+ rk[3] = GETU32(cipherKey + 12);
+ for (i = 0; i < 10; i++) {
+ temp = rk[3];
+ rk[4] = rk[0] ^
+ TE421(temp) ^ TE432(temp) ^ TE443(temp) ^ TE414(temp) ^
+ RCON(i);
+ rk[5] = rk[1] ^ rk[4];
+ rk[6] = rk[2] ^ rk[5];
+ rk[7] = rk[3] ^ rk[6];
+ rk += 4;
+ }
+}
+
+#ifndef CONFIG_NO_AES_DECRYPT
+/**
+ * Expand the cipher key into the decryption key schedule.
+ *
+ * @return the number of rounds for the given cipher key size.
+ */
+static void rijndaelKeySetupDec(u32 rk[/*44*/], const u8 cipherKey[])
+{
+ int Nr = 10, i, j;
+ u32 temp;
+
+ /* expand the cipher key: */
+ rijndaelKeySetupEnc(rk, cipherKey);
+ /* invert the order of the round keys: */
+ for (i = 0, j = 4*Nr; i < j; i += 4, j -= 4) {
+ temp = rk[i ]; rk[i ] = rk[j ]; rk[j ] = temp;
+ temp = rk[i + 1]; rk[i + 1] = rk[j + 1]; rk[j + 1] = temp;
+ temp = rk[i + 2]; rk[i + 2] = rk[j + 2]; rk[j + 2] = temp;
+ temp = rk[i + 3]; rk[i + 3] = rk[j + 3]; rk[j + 3] = temp;
+ }
+ /* apply the inverse MixColumn transform to all round keys but the
+ * first and the last: */
+ for (i = 1; i < Nr; i++) {
+ rk += 4;
+ for (j = 0; j < 4; j++) {
+ rk[j] = TD0_(TE4((rk[j] >> 24) )) ^
+ TD1_(TE4((rk[j] >> 16) & 0xff)) ^
+ TD2_(TE4((rk[j] >> 8) & 0xff)) ^
+ TD3_(TE4((rk[j] ) & 0xff));
+ }
+ }
+}
+#endif /* CONFIG_NO_AES_DECRYPT */
+
+#ifndef CONFIG_NO_AES_ENCRYPT
+static void rijndaelEncrypt(const u32 rk[/*44*/], const u8 pt[16], u8 ct[16])
+{
+ u32 s0, s1, s2, s3, t0, t1, t2, t3;
+ const int Nr = 10;
+#ifndef FULL_UNROLL
+ int r;
+#endif /* ?FULL_UNROLL */
+
+ /*
+ * map byte array block to cipher state
+ * and add initial round key:
+ */
+ s0 = GETU32(pt ) ^ rk[0];
+ s1 = GETU32(pt + 4) ^ rk[1];
+ s2 = GETU32(pt + 8) ^ rk[2];
+ s3 = GETU32(pt + 12) ^ rk[3];
+
+#define ROUND(i,d,s) \
+d##0 = TE0(s##0) ^ TE1(s##1) ^ TE2(s##2) ^ TE3(s##3) ^ rk[4 * i]; \
+d##1 = TE0(s##1) ^ TE1(s##2) ^ TE2(s##3) ^ TE3(s##0) ^ rk[4 * i + 1]; \
+d##2 = TE0(s##2) ^ TE1(s##3) ^ TE2(s##0) ^ TE3(s##1) ^ rk[4 * i + 2]; \
+d##3 = TE0(s##3) ^ TE1(s##0) ^ TE2(s##1) ^ TE3(s##2) ^ rk[4 * i + 3]
+
+#ifdef FULL_UNROLL
+
+ ROUND(1,t,s);
+ ROUND(2,s,t);
+ ROUND(3,t,s);
+ ROUND(4,s,t);
+ ROUND(5,t,s);
+ ROUND(6,s,t);
+ ROUND(7,t,s);
+ ROUND(8,s,t);
+ ROUND(9,t,s);
+
+ rk += Nr << 2;
+
+#else /* !FULL_UNROLL */
+
+ /* Nr - 1 full rounds: */
+ r = Nr >> 1;
+ for (;;) {
+ ROUND(1,t,s);
+ rk += 8;
+ if (--r == 0)
+ break;
+ ROUND(0,s,t);
+ }
+
+#endif /* ?FULL_UNROLL */
+
+#undef ROUND
+
+ /*
+ * apply last round and
+ * map cipher state to byte array block:
+ */
+ s0 = TE41(t0) ^ TE42(t1) ^ TE43(t2) ^ TE44(t3) ^ rk[0];
+ PUTU32(ct , s0);
+ s1 = TE41(t1) ^ TE42(t2) ^ TE43(t3) ^ TE44(t0) ^ rk[1];
+ PUTU32(ct + 4, s1);
+ s2 = TE41(t2) ^ TE42(t3) ^ TE43(t0) ^ TE44(t1) ^ rk[2];
+ PUTU32(ct + 8, s2);
+ s3 = TE41(t3) ^ TE42(t0) ^ TE43(t1) ^ TE44(t2) ^ rk[3];
+ PUTU32(ct + 12, s3);
+}
+#endif /* CONFIG_NO_AES_ENCRYPT */
+
+static void rijndaelDecrypt(const u32 rk[/*44*/], const u8 ct[16], u8 pt[16])
+{
+ u32 s0, s1, s2, s3, t0, t1, t2, t3;
+ const int Nr = 10;
+#ifndef FULL_UNROLL
+ int r;
+#endif /* ?FULL_UNROLL */
+
+ /*
+ * map byte array block to cipher state
+ * and add initial round key:
+ */
+ s0 = GETU32(ct ) ^ rk[0];
+ s1 = GETU32(ct + 4) ^ rk[1];
+ s2 = GETU32(ct + 8) ^ rk[2];
+ s3 = GETU32(ct + 12) ^ rk[3];
+
+#define ROUND(i,d,s) \
+d##0 = TD0(s##0) ^ TD1(s##3) ^ TD2(s##2) ^ TD3(s##1) ^ rk[4 * i]; \
+d##1 = TD0(s##1) ^ TD1(s##0) ^ TD2(s##3) ^ TD3(s##2) ^ rk[4 * i + 1]; \
+d##2 = TD0(s##2) ^ TD1(s##1) ^ TD2(s##0) ^ TD3(s##3) ^ rk[4 * i + 2]; \
+d##3 = TD0(s##3) ^ TD1(s##2) ^ TD2(s##1) ^ TD3(s##0) ^ rk[4 * i + 3]
+
+#ifdef FULL_UNROLL
+
+ ROUND(1,t,s);
+ ROUND(2,s,t);
+ ROUND(3,t,s);
+ ROUND(4,s,t);
+ ROUND(5,t,s);
+ ROUND(6,s,t);
+ ROUND(7,t,s);
+ ROUND(8,s,t);
+ ROUND(9,t,s);
+
+ rk += Nr << 2;
+
+#else /* !FULL_UNROLL */
+
+ /* Nr - 1 full rounds: */
+ r = Nr >> 1;
+ for (;;) {
+ ROUND(1,t,s);
+ rk += 8;
+ if (--r == 0)
+ break;
+ ROUND(0,s,t);
+ }
+
+#endif /* ?FULL_UNROLL */
+
+#undef ROUND
+
+ /*
+ * apply last round and
+ * map cipher state to byte array block:
+ */
+ s0 = TD41(t0) ^ TD42(t3) ^ TD43(t2) ^ TD44(t1) ^ rk[0];
+ PUTU32(pt , s0);
+ s1 = TD41(t1) ^ TD42(t0) ^ TD43(t3) ^ TD44(t2) ^ rk[1];
+ PUTU32(pt + 4, s1);
+ s2 = TD41(t2) ^ TD42(t1) ^ TD43(t0) ^ TD44(t3) ^ rk[2];
+ PUTU32(pt + 8, s2);
+ s3 = TD41(t3) ^ TD42(t2) ^ TD43(t1) ^ TD44(t0) ^ rk[3];
+ PUTU32(pt + 12, s3);
+}
+
+#define AES_PRIV_SIZE 44
diff --git a/package/network/services/ead/src/ead-client.c b/package/network/services/ead/src/ead-client.c
new file mode 100644
index 0000000..54d8b13
--- /dev/null
+++ b/package/network/services/ead/src/ead-client.c
@@ -0,0 +1,433 @@
+/*
+ * Client for the Emergency Access Daemon
+ * Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation
+ *
+ * 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.
+ */
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <stdio.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <string.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <t_pwd.h>
+#include <t_read.h>
+#include <t_sha.h>
+#include <t_defines.h>
+#include <t_client.h>
+#include "ead.h"
+#include "ead-crypt.h"
+
+#include "pw_encrypt_md5.c"
+
+#define EAD_TIMEOUT 400
+#define EAD_TIMEOUT_LONG 2000
+
+static char msgbuf[1500];
+static struct ead_msg *msg = (struct ead_msg *) msgbuf;
+static uint16_t nid = 0xffff;
+struct sockaddr_in local, remote;
+static int s = 0;
+static int sockflags;
+static struct in_addr serverip = {
+ .s_addr = 0x01010101 /* dummy */
+};
+
+static unsigned char *skey = NULL;
+static unsigned char bbuf[MAXPARAMLEN];
+static unsigned char saltbuf[MAXSALTLEN];
+static char *username = NULL;
+static char password[MAXPARAMLEN] = "";
+static char pw_md5[MD5_OUT_BUFSIZE];
+static char pw_salt[MAXSALTLEN];
+
+static struct t_client *tc = NULL;
+static struct t_num salt = { .data = saltbuf };
+static struct t_num *A, B;
+static struct t_preconf *tcp;
+static int auth_type = EAD_AUTH_DEFAULT;
+static int timeout = EAD_TIMEOUT;
+static uint16_t sid = 0;
+
+static void
+set_nonblock(int enable)
+{
+ if (enable == !!(sockflags & O_NONBLOCK));
+ return;
+
+ sockflags ^= O_NONBLOCK;
+ fcntl(s, F_SETFL, sockflags);
+}
+
+static int
+send_packet(int type, bool (*handler)(void), unsigned int max)
+{
+ struct timeval tv;
+ fd_set fds;
+ int nfds;
+ int len;
+ int res = 0;
+
+ type = htonl(type);
+ memcpy(&msg->ip, &serverip.s_addr, sizeof(msg->ip));
+ set_nonblock(0);
+ sendto(s, msgbuf, sizeof(struct ead_msg) + ntohl(msg->len), 0, (struct sockaddr *) &remote, sizeof(remote));
+ set_nonblock(1);
+
+ tv.tv_sec = timeout / 1000;
+ tv.tv_usec = (timeout % 1000) * 1000;
+
+ FD_ZERO(&fds);
+ do {
+ FD_SET(s, &fds);
+ nfds = select(s + 1, &fds, NULL, NULL, &tv);
+
+ if (nfds <= 0)
+ break;
+
+ if (!FD_ISSET(s, &fds))
+ break;
+
+ len = read(s, msgbuf, sizeof(msgbuf));
+ if (len < 0)
+ break;
+
+ if (len < sizeof(struct ead_msg))
+ continue;
+
+ if (len < sizeof(struct ead_msg) + ntohl(msg->len))
+ continue;
+
+ if (msg->magic != htonl(EAD_MAGIC))
+ continue;
+
+ if ((nid != 0xffff) && (ntohs(msg->nid) != nid))
+ continue;
+
+ if (msg->type != type)
+ continue;
+
+ if (handler())
+ res++;
+
+ if ((max > 0) && (res >= max))
+ break;
+ } while (1);
+
+ return res;
+}
+
+static void
+prepare_password(void)
+{
+ switch(auth_type) {
+ case EAD_AUTH_DEFAULT:
+ break;
+ case EAD_AUTH_MD5:
+ md5_crypt(pw_md5, (unsigned char *) password, (unsigned char *) pw_salt);
+ strncpy(password, pw_md5, sizeof(password));
+ break;
+ }
+}
+
+static bool
+handle_pong(void)
+{
+ struct ead_msg_pong *pong = EAD_DATA(msg, pong);
+ int len = ntohl(msg->len) - sizeof(struct ead_msg_pong);
+
+ if (len <= 0)
+ return false;
+
+ pong->name[len] = 0;
+ auth_type = ntohs(pong->auth_type);
+ if (nid == 0xffff)
+ printf("%04x: %s\n", ntohs(msg->nid), pong->name);
+ sid = msg->sid;
+ return true;
+}
+
+static bool
+handle_prime(void)
+{
+ struct ead_msg_salt *sb = EAD_DATA(msg, salt);
+
+ salt.len = sb->len;
+ memcpy(salt.data, sb->salt, salt.len);
+
+ if (auth_type == EAD_AUTH_MD5) {
+ memcpy(pw_salt, sb->ext_salt, MAXSALTLEN);
+ pw_salt[MAXSALTLEN - 1] = 0;
+ }
+
+ tcp = t_getpreparam(sb->prime);
+ tc = t_clientopen(username, &tcp->modulus, &tcp->generator, &salt);
+ if (!tc) {
+ fprintf(stderr, "Client open failed\n");
+ return false;
+ }
+
+ return true;
+}
+
+static bool
+handle_b(void)
+{
+ struct ead_msg_number *num = EAD_DATA(msg, number);
+ int len = ntohl(msg->len) - sizeof(struct ead_msg_number);
+
+ B.data = bbuf;
+ B.len = len;
+ memcpy(bbuf, num->data, len);
+ return true;
+}
+
+static bool
+handle_none(void)
+{
+ return true;
+}
+
+static bool
+handle_done_auth(void)
+{
+ struct ead_msg_auth *auth = EAD_DATA(msg, auth);
+ if (t_clientverify(tc, auth->data) != 0) {
+ fprintf(stderr, "Client auth verify failed\n");
+ return false;
+ }
+ return true;
+}
+
+static bool
+handle_cmd_data(void)
+{
+ struct ead_msg_cmd_data *cmd = EAD_ENC_DATA(msg, cmd_data);
+ int datalen = ead_decrypt_message(msg) - sizeof(struct ead_msg_cmd_data);
+
+ if (datalen < 0)
+ return false;
+
+ if (datalen > 0) {
+ write(1, cmd->data, datalen);
+ }
+
+ return !!cmd->done;
+}
+static int
+send_ping(void)
+{
+ msg->type = htonl(EAD_TYPE_PING);
+ msg->len = 0;
+ return send_packet(EAD_TYPE_PONG, handle_pong, (nid == 0xffff ? 0 : 1));
+}
+
+static int
+send_username(void)
+{
+ msg->type = htonl(EAD_TYPE_SET_USERNAME);
+ msg->len = htonl(sizeof(struct ead_msg_user));
+ strcpy(EAD_DATA(msg, user)->username, username);
+ return send_packet(EAD_TYPE_ACK_USERNAME, handle_none, 1);
+}
+
+static int
+get_prime(void)
+{
+ msg->type = htonl(EAD_TYPE_GET_PRIME);
+ msg->len = 0;
+ return send_packet(EAD_TYPE_PRIME, handle_prime, 1);
+}
+
+static int
+send_a(void)
+{
+ struct ead_msg_number *num = EAD_DATA(msg, number);
+ A = t_clientgenexp(tc);
+ msg->type = htonl(EAD_TYPE_SEND_A);
+ msg->len = htonl(sizeof(struct ead_msg_number) + A->len);
+ memcpy(num->data, A->data, A->len);
+ return send_packet(EAD_TYPE_SEND_B, handle_b, 1);
+}
+
+static int
+send_auth(void)
+{
+ struct ead_msg_auth *auth = EAD_DATA(msg, auth);
+
+ prepare_password();
+ t_clientpasswd(tc, password);
+ skey = t_clientgetkey(tc, &B);
+ if (!skey)
+ return 0;
+
+ ead_set_key(skey);
+ msg->type = htonl(EAD_TYPE_SEND_AUTH);
+ msg->len = htonl(sizeof(struct ead_msg_auth));
+ memcpy(auth->data, t_clientresponse(tc), sizeof(auth->data));
+ return send_packet(EAD_TYPE_DONE_AUTH, handle_done_auth, 1);
+}
+
+static int
+send_command(const char *command)
+{
+ struct ead_msg_cmd *cmd = EAD_ENC_DATA(msg, cmd);
+
+ msg->type = htonl(EAD_TYPE_SEND_CMD);
+ cmd->type = htons(EAD_CMD_NORMAL);
+ cmd->timeout = htons(10);
+ strncpy((char *)cmd->data, command, 1024);
+ ead_encrypt_message(msg, sizeof(struct ead_msg_cmd) + strlen(command) + 1);
+ return send_packet(EAD_TYPE_RESULT_CMD, handle_cmd_data, 1);
+}
+
+
+static int
+usage(const char *prog)
+{
+ fprintf(stderr, "Usage: %s [-s <addr>] [-b <addr>] <node> <username>[:<password>] <command>\n"
+ "\n"
+ "\t-s <addr>: Set the server's source address to <addr>\n"
+ "\t-b <addr>: Set the broadcast address to <addr>\n"
+ "\t<node>: Node ID (4 digits hex)\n"
+ "\t<username>: Username to authenticate with\n"
+ "\n"
+ "\tPassing no arguments shows a list of active nodes on the network\n"
+ "\n", prog);
+ return -1;
+}
+
+
+int main(int argc, char **argv)
+{
+ int val = 1;
+ char *st = NULL;
+ const char *command = NULL;
+ const char *prog = argv[0];
+ int ch;
+
+ msg->magic = htonl(EAD_MAGIC);
+ msg->sid = 0;
+
+ memset(&local, 0, sizeof(local));
+ memset(&remote, 0, sizeof(remote));
+
+ remote.sin_family = AF_INET;
+ remote.sin_addr.s_addr = 0xffffffff;
+ remote.sin_port = htons(EAD_PORT);
+
+ local.sin_family = AF_INET;
+ local.sin_addr.s_addr = INADDR_ANY;
+ local.sin_port = 0;
+
+ while ((ch = getopt(argc, argv, "b:s:h")) != -1) {
+ switch(ch) {
+ case 's':
+ inet_aton(optarg, &serverip);
+ break;
+ case 'b':
+ inet_aton(optarg, &remote.sin_addr);
+ break;
+ case 'h':
+ return usage(prog);
+ }
+ }
+ argv += optind;
+ argc -= optind;
+
+ switch(argc) {
+ case 3:
+ command = argv[2];
+ /* fall through */
+ case 2:
+ username = argv[1];
+ st = strchr(username, ':');
+ if (st) {
+ *st = 0;
+ st++;
+ strncpy(password, st, sizeof(password));
+ password[sizeof(password) - 1] = 0;
+ /* hide command line password */
+ memset(st, 0, strlen(st));
+ }
+ /* fall through */
+ case 1:
+ nid = strtoul(argv[0], &st, 16);
+ if (st && st[0] != 0)
+ return usage(prog);
+ /* fall through */
+ case 0:
+ break;
+ default:
+ return usage(prog);
+ }
+
+ msg->nid = htons(nid);
+ s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
+ if (s < 0) {
+ perror("socket");
+ return -1;
+ }
+
+ setsockopt(s, SOL_SOCKET, SO_BROADCAST, &val, sizeof(val));
+
+ if (bind(s, (struct sockaddr *)&local, sizeof(local)) < 0) {
+ perror("bind");
+ return -1;
+ }
+ sockflags = fcntl(s, F_GETFL);
+
+ if (!send_ping()) {
+ fprintf(stderr, "No devices found\n");
+ return 1;
+ }
+
+ if (nid == 0xffff)
+ return 0;
+
+ if (!username || !password[0])
+ return 0;
+
+ if (!send_username()) {
+ fprintf(stderr, "Device did not accept user name\n");
+ return 1;
+ }
+ timeout = EAD_TIMEOUT_LONG;
+ if (!get_prime()) {
+ fprintf(stderr, "Failed to get user password info\n");
+ return 1;
+ }
+ if (!send_a()) {
+ fprintf(stderr, "Failed to send local authentication data\n");
+ return 1;
+ }
+ if (!send_auth()) {
+ fprintf(stderr, "Authentication failed\n");
+ return 1;
+ }
+ if (!command) {
+ fprintf(stderr, "Authentication succesful\n");
+ return 0;
+ }
+ if (!send_command(command)) {
+ fprintf(stderr, "Command failed\n");
+ return 1;
+ }
+
+ return 0;
+}
diff --git a/package/network/services/ead/src/ead-crypt.c b/package/network/services/ead/src/ead-crypt.c
new file mode 100644
index 0000000..0372172
--- /dev/null
+++ b/package/network/services/ead/src/ead-crypt.c
@@ -0,0 +1,179 @@
+/*
+ * Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation
+ *
+ * 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.
+ */
+
+#include <stddef.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <string.h>
+#include <unistd.h>
+#include <stdio.h>
+#include "ead.h"
+
+#include "sha1.c"
+#include "aes.c"
+
+#if EAD_DEBUGLEVEL >= 1
+#define DEBUG(n, format, ...) do { \
+ if (EAD_DEBUGLEVEL >= n) \
+ fprintf(stderr, format, ##__VA_ARGS__); \
+} while (0);
+
+#else
+#define DEBUG(n, format, ...) do {} while(0)
+#endif
+
+
+static uint32_t aes_enc_ctx[AES_PRIV_SIZE];
+static uint32_t aes_dec_ctx[AES_PRIV_SIZE];
+static uint32_t ead_rx_iv;
+static uint32_t ead_tx_iv;
+static uint32_t ivofs_vec;
+static unsigned int ivofs_idx = 0;
+static uint32_t W[80]; /* work space for sha1 */
+
+#define EAD_ENC_PAD 64
+
+void
+ead_set_key(unsigned char *skey)
+{
+ uint32_t *ivp = (uint32_t *)skey;
+
+ memset(aes_enc_ctx, 0, sizeof(aes_enc_ctx));
+ memset(aes_dec_ctx, 0, sizeof(aes_dec_ctx));
+
+ /* first 32 bytes of skey are used as aes key for
+ * encryption and decryption */
+ rijndaelKeySetupEnc(aes_enc_ctx, skey);
+ rijndaelKeySetupDec(aes_dec_ctx, skey);
+
+ /* the following bytes are used as initialization vector for messages
+ * (highest byte cleared to avoid overflow) */
+ ivp += 8;
+ ead_rx_iv = ntohl(*ivp) & 0x00ffffff;
+ ead_tx_iv = ead_rx_iv;
+
+ /* the last bytes are used to feed the random iv increment */
+ ivp++;
+ ivofs_vec = *ivp;
+}
+
+
+static bool
+ead_check_rx_iv(uint32_t iv)
+{
+ if (iv <= ead_rx_iv)
+ return false;
+
+ if (iv > ead_rx_iv + EAD_MAX_IV_INCR)
+ return false;
+
+ ead_rx_iv = iv;
+ return true;
+}
+
+
+static uint32_t
+ead_get_tx_iv(void)
+{
+ unsigned int ofs;
+
+ ofs = 1 + ((ivofs_vec >> 2 * ivofs_idx) & 0x3);
+ ivofs_idx = (ivofs_idx + 1) % 16;
+ ead_tx_iv += ofs;
+
+ return ead_tx_iv;
+}
+
+static void
+ead_hash_message(struct ead_msg_encrypted *enc, uint32_t *hash, int len)
+{
+ unsigned char *data = (unsigned char *) enc;
+
+ /* hash the packet with the stored hash part initialized to zero */
+ sha_init(hash);
+ memset(enc->hash, 0, sizeof(enc->hash));
+ while (len > 0) {
+ sha_transform(hash, data, W);
+ len -= 64;
+ data += 64;
+ }
+}
+
+void
+ead_encrypt_message(struct ead_msg *msg, unsigned int len)
+{
+ struct ead_msg_encrypted *enc = EAD_DATA(msg, enc);
+ unsigned char *data = (unsigned char *) enc;
+ uint32_t hash[5];
+ int enclen, i;
+
+ len += sizeof(struct ead_msg_encrypted);
+ enc->pad = (EAD_ENC_PAD - (len % EAD_ENC_PAD)) % EAD_ENC_PAD;
+ enclen = len + enc->pad;
+ msg->len = htonl(enclen);
+ enc->iv = htonl(ead_get_tx_iv());
+
+ ead_hash_message(enc, hash, enclen);
+ for (i = 0; i < 5; i++)
+ enc->hash[i] = htonl(hash[i]);
+ DEBUG(2, "SHA1 generate (0x%08x), len=%d\n", enc->hash[0], enclen);
+
+ while (enclen > 0) {
+ rijndaelEncrypt(aes_enc_ctx, data, data);
+ data += 16;
+ enclen -= 16;
+ }
+}
+
+int
+ead_decrypt_message(struct ead_msg *msg)
+{
+ struct ead_msg_encrypted *enc = EAD_DATA(msg, enc);
+ unsigned char *data = (unsigned char *) enc;
+ uint32_t hash_old[5], hash_new[5];
+ int len = ntohl(msg->len);
+ int i, enclen = len;
+
+ if (!len || (len % EAD_ENC_PAD > 0))
+ return 0;
+
+ while (len > 0) {
+ rijndaelDecrypt(aes_dec_ctx, data, data);
+ data += 16;
+ len -= 16;
+ }
+
+ data = (unsigned char *) enc;
+
+ if (enc->pad >= EAD_ENC_PAD) {
+ DEBUG(2, "Invalid padding length\n");
+ return 0;
+ }
+
+ if (!ead_check_rx_iv(ntohl(enc->iv))) {
+ DEBUG(2, "RX IV mismatch (0x%08x <> 0x%08x)\n", ead_rx_iv, ntohl(enc->iv));
+ return 0;
+ }
+
+ for (i = 0; i < 5; i++)
+ hash_old[i] = ntohl(enc->hash[i]);
+ ead_hash_message(enc, hash_new, enclen);
+ if (memcmp(hash_old, hash_new, sizeof(hash_old)) != 0) {
+ DEBUG(2, "SHA1 mismatch (0x%08x != 0x%08x), len=%d\n", hash_old[0], hash_new[0], enclen);
+ return 0;
+ }
+
+ enclen -= enc->pad + sizeof(struct ead_msg_encrypted);
+ return enclen;
+}
diff --git a/package/network/services/ead/src/ead-crypt.h b/package/network/services/ead/src/ead-crypt.h
new file mode 100644
index 0000000..831ec8a
--- /dev/null
+++ b/package/network/services/ead/src/ead-crypt.h
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation
+ *
+ * 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.
+ */
+
+#ifndef __EAD_CRYPT_H
+#define __EAD_CRYPT_H
+
+extern void ead_set_key(unsigned char *skey);
+extern void ead_encrypt_message(struct ead_msg *msg, unsigned int len);
+extern int ead_decrypt_message(struct ead_msg *msg);
+
+#endif
diff --git a/package/network/services/ead/src/ead-pcap.h b/package/network/services/ead/src/ead-pcap.h
new file mode 100644
index 0000000..0652ab4
--- /dev/null
+++ b/package/network/services/ead/src/ead-pcap.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2001-2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file was part of the uIP TCP/IP stack.
+ *
+ */
+#ifndef __EAD_PCAP_H
+#define __EAD_PCAP_H
+
+#include <net/ethernet.h>
+#include <stdint.h>
+#include "ead.h"
+
+typedef uint8_t u8_t;
+typedef uint16_t u16_t;
+
+/* The UDP and IP headers. */
+struct ead_packet {
+ struct ether_header eh;
+ /* IP header. */
+ u8_t vhl,
+ tos,
+ len[2],
+ ipid[2],
+ ipoffset[2],
+ ttl,
+ proto;
+ u16_t ipchksum;
+ u16_t srcipaddr[2],
+ destipaddr[2];
+
+ /* UDP header. */
+ u16_t srcport,
+ destport;
+ u16_t udplen;
+ u16_t udpchksum;
+
+ struct ead_msg msg;
+} __attribute__((packed));
+
+#define UIP_PROTO_UDP 17
+#define UIP_IPH_LEN 20 /* Size of IP header */
+#define UIP_UDPH_LEN 8 /* Size of UDP header */
+#define UIP_IPUDPH_LEN (UIP_UDPH_LEN + UIP_IPH_LEN)
+
+#endif
diff --git a/package/network/services/ead/src/ead.c b/package/network/services/ead/src/ead.c
new file mode 100644
index 0000000..3623520
--- /dev/null
+++ b/package/network/services/ead/src/ead.c
@@ -0,0 +1,991 @@
+/*
+ * Emergency Access Daemon
+ * Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation
+ *
+ * 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.
+ */
+
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/select.h>
+#include <stdio.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <stdbool.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <pcap.h>
+#include <pcap-bpf.h>
+#include <t_pwd.h>
+#include <t_read.h>
+#include <t_sha.h>
+#include <t_defines.h>
+#include <t_server.h>
+
+#include "list.h"
+#include "ead.h"
+#include "ead-pcap.h"
+#include "ead-crypt.h"
+
+#include "filter.c"
+
+#ifdef linux
+#include "libbridge_init.c"
+#endif
+
+#ifdef linux
+#include <linux/if_packet.h>
+#endif
+
+#define PASSWD_FILE "/etc/passwd"
+
+#ifndef DEFAULT_IFNAME
+#define DEFAULT_IFNAME "eth0"
+#endif
+
+#ifndef DEFAULT_DEVNAME
+#define DEFAULT_DEVNAME "Unknown"
+#endif
+
+#define PCAP_MRU 1600
+#define PCAP_TIMEOUT 200
+
+#if EAD_DEBUGLEVEL >= 1
+#define DEBUG(n, format, ...) do { \
+ if (EAD_DEBUGLEVEL >= n) \
+ fprintf(stderr, format, ##__VA_ARGS__); \
+} while (0);
+
+#else
+#define DEBUG(n, format, ...) do {} while(0)
+#endif
+
+struct ead_instance {
+ struct list_head list;
+ char ifname[16];
+ int pid;
+ char id;
+#ifdef linux
+ char bridge[16];
+ bool br_check;
+#endif
+};
+
+static char ethmac[6] = "\x00\x13\x37\x00\x00\x00"; /* last 3 bytes will be randomized */
+static pcap_t *pcap_fp = NULL;
+static pcap_t *pcap_fp_rx = NULL;
+static char pktbuf_b[PCAP_MRU];
+static struct ead_packet *pktbuf = (struct ead_packet *)pktbuf_b;
+static u16_t nid = 0xffff; /* node id */
+static char username[32] = "";
+static int state = EAD_TYPE_SET_USERNAME;
+static const char *passwd_file = PASSWD_FILE;
+static const char password[MAXPARAMLEN];
+static bool child_pending = false;
+
+static unsigned char abuf[MAXPARAMLEN + 1];
+static unsigned char pwbuf[MAXPARAMLEN];
+static unsigned char saltbuf[MAXSALTLEN];
+static unsigned char pw_saltbuf[MAXSALTLEN];
+static struct list_head instances;
+static const char *dev_name = DEFAULT_DEVNAME;
+static bool nonfork = false;
+static struct ead_instance *instance = NULL;
+
+static struct t_pwent tpe = {
+ .name = username,
+ .index = 1,
+ .password.data = pwbuf,
+ .password.len = 0,
+ .salt.data = saltbuf,
+ .salt.len = 0,
+};
+struct t_confent *tce = NULL;
+static struct t_server *ts = NULL;
+static struct t_num A, *B = NULL;
+unsigned char *skey;
+
+static void
+set_recv_type(pcap_t *p, bool rx)
+{
+#ifdef PACKET_RECV_TYPE
+ struct sockaddr_ll sll;
+ struct ifreq ifr;
+ int ifindex, mask;
+ int fd, ret;
+
+ fd = pcap_get_selectable_fd(p);
+ if (fd < 0)
+ return;
+
+ if (rx)
+ mask = 1 << PACKET_BROADCAST;
+ else
+ mask = 0;
+
+ ret = setsockopt(fd, SOL_PACKET, PACKET_RECV_TYPE, &mask, sizeof(mask));
+#endif
+}
+
+
+static pcap_t *
+ead_open_pcap(const char *ifname, char *errbuf, bool rx)
+{
+ pcap_t *p;
+
+ p = pcap_create(ifname, errbuf);
+ if (p == NULL)
+ goto out;
+
+ pcap_set_snaplen(p, PCAP_MRU);
+ pcap_set_promisc(p, rx);
+ pcap_set_timeout(p, PCAP_TIMEOUT);
+#ifdef HAS_PROTO_EXTENSION
+ pcap_set_protocol(p, (rx ? htons(ETH_P_IP) : 0));
+#endif
+ pcap_set_buffer_size(p, (rx ? 10 : 1) * PCAP_MRU);
+ pcap_activate(p);
+ set_recv_type(p, rx);
+out:
+ return p;
+}
+
+static void
+get_random_bytes(void *ptr, int len)
+{
+ int fd;
+
+ fd = open("/dev/urandom", O_RDONLY);
+ if (fd < 0) {
+ perror("open");
+ exit(1);
+ }
+ read(fd, ptr, len);
+ close(fd);
+}
+
+static bool
+prepare_password(void)
+{
+ static char lbuf[1024];
+ unsigned char dig[SHA_DIGESTSIZE];
+ BigInteger x, v, n, g;
+ SHA1_CTX ctxt;
+ int ulen = strlen(username);
+ FILE *f;
+
+ lbuf[sizeof(lbuf) - 1] = 0;
+
+ f = fopen(passwd_file, "r");
+ if (!f)
+ return false;
+
+ while (fgets(lbuf, sizeof(lbuf) - 1, f) != NULL) {
+ char *str, *s2;
+
+ if (strncmp(lbuf, username, ulen) != 0)
+ continue;
+
+ if (lbuf[ulen] != ':')
+ continue;
+
+ str = &lbuf[ulen + 1];
+
+ if (strncmp(str, "$1$", 3) != 0)
+ continue;
+
+ s2 = strchr(str + 3, '$');
+ if (!s2)
+ continue;
+
+ if (s2 - str >= MAXSALTLEN)
+ continue;
+
+ strncpy((char *) pw_saltbuf, str, s2 - str);
+ pw_saltbuf[s2 - str] = 0;
+
+ s2 = strchr(s2, ':');
+ if (!s2)
+ continue;
+
+ *s2 = 0;
+ if (s2 - str >= MAXPARAMLEN)
+ continue;
+
+ strncpy((char *)password, str, MAXPARAMLEN);
+ fclose(f);
+ goto hash_password;
+ }
+
+ /* not found */
+ fclose(f);
+ return false;
+
+hash_password:
+ tce = gettcid(tpe.index);
+ do {
+ t_random(tpe.password.data, SALTLEN);
+ } while (memcmp(saltbuf, (char *)dig, sizeof(saltbuf)) == 0);
+ if (saltbuf[0] == 0)
+ saltbuf[0] = 0xff;
+
+ n = BigIntegerFromBytes(tce->modulus.data, tce->modulus.len);
+ g = BigIntegerFromBytes(tce->generator.data, tce->generator.len);
+ v = BigIntegerFromInt(0);
+
+ SHA1Init(&ctxt);
+ SHA1Update(&ctxt, (unsigned char *) username, strlen(username));
+ SHA1Update(&ctxt, (unsigned char *) ":", 1);
+ SHA1Update(&ctxt, (unsigned char *) password, strlen(password));
+ SHA1Final(dig, &ctxt);
+
+ SHA1Init(&ctxt);
+ SHA1Update(&ctxt, saltbuf, tpe.salt.len);
+ SHA1Update(&ctxt, dig, sizeof(dig));
+ SHA1Final(dig, &ctxt);
+
+ /* x = H(s, H(u, ':', p)) */
+ x = BigIntegerFromBytes(dig, sizeof(dig));
+
+ BigIntegerModExp(v, g, x, n);
+ tpe.password.len = BigIntegerToBytes(v, (unsigned char *)pwbuf);
+
+ BigIntegerFree(v);
+ BigIntegerFree(x);
+ BigIntegerFree(g);
+ BigIntegerFree(n);
+ return true;
+}
+
+static u16_t
+chksum(u16_t sum, const u8_t *data, u16_t len)
+{
+ u16_t t;
+ const u8_t *dataptr;
+ const u8_t *last_byte;
+
+ dataptr = data;
+ last_byte = data + len - 1;
+
+ while(dataptr < last_byte) { /* At least two more bytes */
+ t = (dataptr[0] << 8) + dataptr[1];
+ sum += t;
+ if(sum < t) {
+ sum++; /* carry */
+ }
+ dataptr += 2;
+ }
+
+ if(dataptr == last_byte) {
+ t = (dataptr[0] << 8) + 0;
+ sum += t;
+ if(sum < t) {
+ sum++; /* carry */
+ }
+ }
+
+ /* Return sum in host byte order. */
+ return sum;
+}
+
+static void
+ead_send_packet_clone(struct ead_packet *pkt)
+{
+ u16_t len, sum;
+
+ memcpy(pktbuf, pkt, offsetof(struct ead_packet, msg));
+ memcpy(pktbuf->eh.ether_shost, ethmac, 6);
+ memcpy(pktbuf->eh.ether_dhost, pkt->eh.ether_shost, 6);
+
+ /* ip header */
+ len = sizeof(struct ead_packet) - sizeof(struct ether_header) + ntohl(pktbuf->msg.len);
+ pktbuf->len[0] = len >> 8;
+ pktbuf->len[1] = len & 0xff;
+ memcpy(pktbuf->srcipaddr, &pkt->msg.ip, 4);
+ memcpy(pktbuf->destipaddr, pkt->srcipaddr, 4);
+
+ /* ip checksum */
+ pktbuf->ipchksum = 0;
+ sum = chksum(0, (void *) &pktbuf->vhl, UIP_IPH_LEN);
+ if (sum == 0)
+ sum = 0xffff;
+ pktbuf->ipchksum = htons(~sum);
+
+ /* udp header */
+ pktbuf->srcport = pkt->destport;
+ pktbuf->destport = pkt->srcport;
+
+ /* udp checksum */
+ len -= UIP_IPH_LEN;
+ pktbuf->udplen = htons(len);
+ pktbuf->udpchksum = 0;
+ sum = len + UIP_PROTO_UDP;
+ sum = chksum(sum, (void *) &pktbuf->srcipaddr[0], 8); /* src, dest ip */
+ sum = chksum(sum, (void *) &pktbuf->srcport, len);
+ if (sum == 0)
+ sum = 0xffff;
+ pktbuf->udpchksum = htons(~sum);
+ pcap_sendpacket(pcap_fp, (void *) pktbuf, sizeof(struct ead_packet) + ntohl(pktbuf->msg.len));
+}
+
+static void
+set_state(int nstate)
+{
+ if (state == nstate)
+ return;
+
+ if (nstate < state) {
+ if ((nstate < EAD_TYPE_GET_PRIME) &&
+ (state >= EAD_TYPE_GET_PRIME)) {
+ t_serverclose(ts);
+ ts = NULL;
+ }
+ goto done;
+ }
+
+ switch(state) {
+ case EAD_TYPE_SET_USERNAME:
+ if (!prepare_password())
+ goto error;
+ ts = t_serveropenraw(&tpe, tce);
+ if (!ts)
+ goto error;
+ break;
+ case EAD_TYPE_GET_PRIME:
+ B = t_servergenexp(ts);
+ break;
+ case EAD_TYPE_SEND_A:
+ skey = t_servergetkey(ts, &A);
+ if (!skey)
+ goto error;
+
+ ead_set_key(skey);
+ break;
+ }
+done:
+ state = nstate;
+error:
+ return;
+}
+
+static bool
+handle_ping(struct ead_packet *pkt, int len, int *nstate)
+{
+ struct ead_msg *msg = &pktbuf->msg;
+ struct ead_msg_pong *pong = EAD_DATA(msg, pong);
+ int slen;
+
+ slen = strlen(dev_name);
+ if (slen > 1024)
+ slen = 1024;
+
+ msg->len = htonl(sizeof(struct ead_msg_pong) + slen);
+ strncpy(pong->name, dev_name, slen);
+ pong->name[slen] = 0;
+ pong->auth_type = htons(EAD_AUTH_MD5);
+
+ return true;
+}
+
+static bool
+handle_set_username(struct ead_packet *pkt, int len, int *nstate)
+{
+ struct ead_msg *msg = &pkt->msg;
+ struct ead_msg_user *user = EAD_DATA(msg, user);
+
+ set_state(EAD_TYPE_SET_USERNAME); /* clear old state */
+ strncpy(username, user->username, sizeof(username));
+ username[sizeof(username) - 1] = 0;
+
+ msg = &pktbuf->msg;
+ msg->len = 0;
+
+ *nstate = EAD_TYPE_GET_PRIME;
+ return true;
+}
+
+static bool
+handle_get_prime(struct ead_packet *pkt, int len, int *nstate)
+{
+ struct ead_msg *msg = &pktbuf->msg;
+ struct ead_msg_salt *salt = EAD_DATA(msg, salt);
+
+ msg->len = htonl(sizeof(struct ead_msg_salt));
+ salt->prime = tce->index - 1;
+ salt->len = ts->s.len;
+ memcpy(salt->salt, ts->s.data, ts->s.len);
+ memcpy(salt->ext_salt, pw_saltbuf, MAXSALTLEN);
+
+ *nstate = EAD_TYPE_SEND_A;
+ return true;
+}
+
+static bool
+handle_send_a(struct ead_packet *pkt, int len, int *nstate)
+{
+ struct ead_msg *msg = &pkt->msg;
+ struct ead_msg_number *number = EAD_DATA(msg, number);
+ len = ntohl(msg->len) - sizeof(struct ead_msg_number);
+
+ if (len > MAXPARAMLEN + 1)
+ return false;
+
+ A.len = len;
+ A.data = abuf;
+ memcpy(A.data, number->data, len);
+
+ msg = &pktbuf->msg;
+ number = EAD_DATA(msg, number);
+ msg->len = htonl(sizeof(struct ead_msg_number) + B->len);
+ memcpy(number->data, B->data, B->len);
+
+ *nstate = EAD_TYPE_SEND_AUTH;
+ return true;
+}
+
+static bool
+handle_send_auth(struct ead_packet *pkt, int len, int *nstate)
+{
+ struct ead_msg *msg = &pkt->msg;
+ struct ead_msg_auth *auth = EAD_DATA(msg, auth);
+
+ if (t_serververify(ts, auth->data) != 0) {
+ DEBUG(2, "Client authentication failed\n");
+ *nstate = EAD_TYPE_SET_USERNAME;
+ return false;
+ }
+
+ msg = &pktbuf->msg;
+ auth = EAD_DATA(msg, auth);
+ msg->len = htonl(sizeof(struct ead_msg_auth));
+
+ DEBUG(2, "Client authentication successful\n");
+ memcpy(auth->data, t_serverresponse(ts), sizeof(auth->data));
+
+ *nstate = EAD_TYPE_SEND_CMD;
+ return true;
+}
+
+static bool
+handle_send_cmd(struct ead_packet *pkt, int len, int *nstate)
+{
+ struct ead_msg *msg = &pkt->msg;
+ struct ead_msg_cmd *cmd = EAD_ENC_DATA(msg, cmd);
+ struct ead_msg_cmd_data *cmddata;
+ struct timeval tv, to, tn;
+ int pfd[2], fd;
+ fd_set fds;
+ pid_t pid;
+ bool stream = false;
+ int timeout;
+ int type;
+ int datalen;
+
+ datalen = ead_decrypt_message(msg) - sizeof(struct ead_msg_cmd);
+ if (datalen <= 0)
+ return false;
+
+ type = ntohs(cmd->type);
+ timeout = ntohs(cmd->timeout);
+
+ FD_ZERO(&fds);
+ cmd->data[datalen] = 0;
+ switch(type) {
+ case EAD_CMD_NORMAL:
+ if (pipe(pfd) < 0)
+ return false;
+
+ fcntl(pfd[0], F_SETFL, O_NONBLOCK | fcntl(pfd[0], F_GETFL));
+ child_pending = true;
+ pid = fork();
+ if (pid == 0) {
+ close(pfd[0]);
+ fd = open("/dev/null", O_RDWR);
+ if (fd > 0) {
+ dup2(fd, 0);
+ dup2(pfd[1], 1);
+ dup2(pfd[1], 2);
+ }
+ system((char *)cmd->data);
+ exit(0);
+ } else if (pid > 0) {
+ close(pfd[1]);
+ if (!timeout)
+ timeout = EAD_CMD_TIMEOUT;
+
+ stream = true;
+ break;
+ }
+ return false;
+ case EAD_CMD_BACKGROUND:
+ pid = fork();
+ if (pid == 0) {
+ /* close stdin, stdout, stderr, replace with fd to /dev/null */
+ fd = open("/dev/null", O_RDWR);
+ if (fd > 0) {
+ dup2(fd, 0);
+ dup2(fd, 1);
+ dup2(fd, 2);
+ }
+ system((char *)cmd->data);
+ exit(0);
+ } else if (pid > 0) {
+ break;
+ }
+ return false;
+ default:
+ return false;
+ }
+
+ msg = &pktbuf->msg;
+ cmddata = EAD_ENC_DATA(msg, cmd_data);
+
+ if (stream) {
+ int nfds, bytes;
+
+ /* send keepalive packets every 200 ms so that the client doesn't timeout */
+ gettimeofday(&to, NULL);
+ memcpy(&tn, &to, sizeof(tn));
+ tv.tv_usec = PCAP_TIMEOUT * 1000;
+ tv.tv_sec = 0;
+ do {
+ cmddata->done = 0;
+ FD_SET(pfd[0], &fds);
+ nfds = select(pfd[0] + 1, &fds, NULL, NULL, &tv);
+ bytes = 0;
+ if (nfds > 0) {
+ bytes = read(pfd[0], cmddata->data, 1024);
+ if (bytes < 0)
+ bytes = 0;
+ }
+ if (!bytes && !child_pending)
+ break;
+ DEBUG(3, "Sending %d bytes of console data, type=%d, timeout=%d\n", bytes, ntohl(msg->type), timeout);
+ ead_encrypt_message(msg, sizeof(struct ead_msg_cmd_data) + bytes);
+ ead_send_packet_clone(pkt);
+ gettimeofday(&tn, NULL);
+ } while (tn.tv_sec < to.tv_sec + timeout);
+ if (child_pending) {
+ kill(pid, SIGKILL);
+ return false;
+ }
+ }
+ cmddata->done = 1;
+ ead_encrypt_message(msg, sizeof(struct ead_msg_cmd_data));
+
+ return true;
+}
+
+
+
+static void
+parse_message(struct ead_packet *pkt, int len)
+{
+ bool (*handler)(struct ead_packet *pkt, int len, int *nstate);
+ int min_len = sizeof(struct ead_packet);
+ int nstate = state;
+ int type = ntohl(pkt->msg.type);
+
+ if ((type >= EAD_TYPE_GET_PRIME) &&
+ (state != type))
+ return;
+
+ if ((type != EAD_TYPE_PING) &&
+ ((ntohs(pkt->msg.sid) & EAD_INSTANCE_MASK) >>
+ EAD_INSTANCE_SHIFT) != instance->id)
+ return;
+
+ switch(type) {
+ case EAD_TYPE_PING:
+ handler = handle_ping;
+ break;
+ case EAD_TYPE_SET_USERNAME:
+ handler = handle_set_username;
+ min_len += sizeof(struct ead_msg_user);
+ break;
+ case EAD_TYPE_GET_PRIME:
+ handler = handle_get_prime;
+ break;
+ case EAD_TYPE_SEND_A:
+ handler = handle_send_a;
+ min_len += sizeof(struct ead_msg_number);
+ break;
+ case EAD_TYPE_SEND_AUTH:
+ handler = handle_send_auth;
+ min_len += sizeof(struct ead_msg_auth);
+ break;
+ case EAD_TYPE_SEND_CMD:
+ handler = handle_send_cmd;
+ min_len += sizeof(struct ead_msg_cmd) + sizeof(struct ead_msg_encrypted);
+ break;
+ default:
+ return;
+ }
+
+ if (len < min_len) {
+ DEBUG(2, "discarding packet: message too small\n");
+ return;
+ }
+
+ pktbuf->msg.magic = htonl(EAD_MAGIC);
+ pktbuf->msg.type = htonl(type + 1);
+ pktbuf->msg.nid = htons(nid);
+ pktbuf->msg.sid = pkt->msg.sid;
+ pktbuf->msg.len = 0;
+
+ if (handler(pkt, len, &nstate)) {
+ DEBUG(2, "sending response to packet type %d: %d\n", type + 1, ntohl(pktbuf->msg.len));
+ /* format response packet */
+ ead_send_packet_clone(pkt);
+ }
+ set_state(nstate);
+}
+
+static void
+handle_packet(u_char *user, const struct pcap_pkthdr *h, const u_char *bytes)
+{
+ struct ead_packet *pkt = (struct ead_packet *) bytes;
+
+ if (h->len < sizeof(struct ead_packet))
+ return;
+
+ if (pkt->eh.ether_type != htons(ETHERTYPE_IP))
+ return;
+
+ if (memcmp(pkt->eh.ether_dhost, "\xff\xff\xff\xff\xff\xff", 6) != 0)
+ return;
+
+ if (pkt->proto != UIP_PROTO_UDP)
+ return;
+
+ if (pkt->destport != htons(EAD_PORT))
+ return;
+
+ if (pkt->msg.magic != htonl(EAD_MAGIC))
+ return;
+
+ if (h->len < sizeof(struct ead_packet) + ntohl(pkt->msg.len))
+ return;
+
+ if ((pkt->msg.nid != 0xffff) &&
+ (pkt->msg.nid != htons(nid)))
+ return;
+
+ parse_message(pkt, h->len);
+}
+
+static void
+ead_pcap_reopen(bool first)
+{
+ static char errbuf[PCAP_ERRBUF_SIZE] = "";
+
+ if (pcap_fp_rx && (pcap_fp_rx != pcap_fp))
+ pcap_close(pcap_fp_rx);
+
+ if (pcap_fp)
+ pcap_close(pcap_fp);
+
+ pcap_fp_rx = NULL;
+ do {
+#ifdef linux
+ if (instance->bridge[0]) {
+ pcap_fp_rx = ead_open_pcap(instance->bridge, errbuf, 1);
+ pcap_fp = ead_open_pcap(instance->ifname, errbuf, 0);
+ } else
+#endif
+ {
+ pcap_fp = ead_open_pcap(instance->ifname, errbuf, 1);
+ }
+
+ if (!pcap_fp_rx)
+ pcap_fp_rx = pcap_fp;
+ if (first && !pcap_fp) {
+ DEBUG(1, "WARNING: unable to open interface '%s'\n", instance->ifname);
+ first = false;
+ }
+ if (!pcap_fp)
+ sleep(1);
+ } while (!pcap_fp);
+ pcap_setfilter(pcap_fp_rx, &pktfilter);
+}
+
+
+static void
+ead_pktloop(void)
+{
+ while (1) {
+ if (pcap_dispatch(pcap_fp_rx, 1, handle_packet, NULL) < 0) {
+ ead_pcap_reopen(false);
+ continue;
+ }
+ }
+}
+
+
+static int
+usage(const char *prog)
+{
+ fprintf(stderr, "Usage: %s [<options>]\n"
+ "Options:\n"
+ "\t-B Run in background mode\n"
+ "\t-d <device> Set the device to listen on\n"
+ "\t-D <name> Set the name of the device visible to clients\n"
+ "\t-p <file> Set the password file for authenticating\n"
+ "\t-P <file> Write a pidfile\n"
+ "\n", prog);
+ return -1;
+}
+
+static void
+server_handle_sigchld(int sig)
+{
+ struct ead_instance *in;
+ struct list_head *p;
+ int pid = 0;
+ wait(&pid);
+
+ list_for_each(p, &instances) {
+ in = list_entry(p, struct ead_instance, list);
+ if (pid != in->pid)
+ continue;
+
+ in->pid = 0;
+ break;
+ }
+}
+
+static void
+instance_handle_sigchld(int sig)
+{
+ int pid = 0;
+ wait(&pid);
+ child_pending = false;
+}
+
+static void
+start_server(struct ead_instance *i)
+{
+ if (!nonfork) {
+ i->pid = fork();
+ if (i->pid != 0) {
+ if (i->pid < 0)
+ i->pid = 0;
+ return;
+ }
+ }
+
+ instance = i;
+ signal(SIGCHLD, instance_handle_sigchld);
+ ead_pcap_reopen(true);
+ ead_pktloop();
+ pcap_close(pcap_fp);
+ if (pcap_fp_rx != pcap_fp)
+ pcap_close(pcap_fp_rx);
+
+ exit(0);
+}
+
+
+static void
+start_servers(bool restart)
+{
+ struct ead_instance *in;
+ struct list_head *p;
+
+ list_for_each(p, &instances) {
+ in = list_entry(p, struct ead_instance, list);
+ if (in->pid > 0)
+ continue;
+
+ sleep(1);
+ start_server(in);
+ }
+}
+
+static void
+stop_server(struct ead_instance *in, bool do_free)
+{
+ if (in->pid > 0)
+ kill(in->pid, SIGKILL);
+ in->pid = 0;
+ if (do_free) {
+ list_del(&in->list);
+ free(in);
+ }
+}
+
+static void
+server_handle_sigint(int sig)
+{
+ struct ead_instance *in;
+ struct list_head *p, *tmp;
+
+ list_for_each_safe(p, tmp, &instances) {
+ in = list_entry(p, struct ead_instance, list);
+ stop_server(in, true);
+ }
+ exit(1);
+}
+
+#ifdef linux
+static int
+check_bridge_port(const char *br, const char *port, void *arg)
+{
+ struct ead_instance *in;
+ struct list_head *p, *tmp;
+
+ list_for_each(p, &instances) {
+ in = list_entry(p, struct ead_instance, list);
+
+ if (strcmp(in->ifname, port) != 0)
+ continue;
+
+ in->br_check = true;
+ if (strcmp(in->bridge, br) == 0)
+ break;
+
+ strncpy(in->bridge, br, sizeof(in->bridge));
+ DEBUG(2, "assigning port %s to bridge %s\n", in->ifname, in->bridge);
+ stop_server(in, false);
+ }
+ return 0;
+}
+
+static int
+check_bridge(const char *name, void *arg)
+{
+ br_foreach_port(name, check_bridge_port, arg);
+ return 0;
+}
+#endif
+
+static void
+check_all_interfaces(void)
+{
+#ifdef linux
+ struct ead_instance *in;
+ struct list_head *p, *tmp;
+
+ br_foreach_bridge(check_bridge, NULL);
+
+ /* look for interfaces that are no longer part of a bridge */
+ list_for_each(p, &instances) {
+ in = list_entry(p, struct ead_instance, list);
+
+ if (in->br_check) {
+ in->br_check = false;
+ } else if (in->bridge[0]) {
+ DEBUG(2, "removing port %s from bridge %s\n", in->ifname, in->bridge);
+ in->bridge[0] = 0;
+ stop_server(in, false);
+ }
+ }
+#endif
+}
+
+
+int main(int argc, char **argv)
+{
+ struct ead_instance *in;
+ struct timeval tv;
+ const char *pidfile = NULL;
+ bool background = false;
+ int n_iface = 0;
+ int fd, ch;
+
+ if (argc == 1)
+ return usage(argv[0]);
+
+ INIT_LIST_HEAD(&instances);
+ while ((ch = getopt(argc, argv, "Bd:D:fhp:P:")) != -1) {
+ switch(ch) {
+ case 'B':
+ background = true;
+ break;
+ case 'f':
+ nonfork = true;
+ break;
+ case 'h':
+ return usage(argv[0]);
+ case 'd':
+ in = malloc(sizeof(struct ead_instance));
+ memset(in, 0, sizeof(struct ead_instance));
+ INIT_LIST_HEAD(&in->list);
+ strncpy(in->ifname, optarg, sizeof(in->ifname) - 1);
+ list_add(&in->list, &instances);
+ in->id = n_iface++;
+ break;
+ case 'D':
+ dev_name = optarg;
+ break;
+ case 'p':
+ passwd_file = optarg;
+ break;
+ case 'P':
+ pidfile = optarg;
+ break;
+ }
+ }
+ signal(SIGCHLD, server_handle_sigchld);
+ signal(SIGINT, server_handle_sigint);
+ signal(SIGTERM, server_handle_sigint);
+ signal(SIGKILL, server_handle_sigint);
+
+ if (!n_iface) {
+ fprintf(stderr, "Error: ead needs at least one interface\n");
+ return -1;
+ }
+
+ if (background) {
+ if (fork() > 0)
+ exit(0);
+
+ fd = open("/dev/null", O_RDWR);
+ dup2(fd, 0);
+ dup2(fd, 1);
+ dup2(fd, 2);
+ }
+
+ if (pidfile) {
+ char pid[8];
+ int len;
+
+ unlink(pidfile);
+ fd = open(pidfile, O_CREAT|O_WRONLY|O_EXCL, 0644);
+ if (fd > 0) {
+ len = sprintf(pid, "%d\n", getpid());
+ write(fd, pid, len);
+ close(fd);
+ }
+ }
+
+ /* randomize the mac address */
+ get_random_bytes(ethmac + 3, 3);
+ nid = *(((u16_t *) ethmac) + 2);
+
+ start_servers(false);
+#ifdef linux
+ br_init();
+#endif
+ tv.tv_sec = 1;
+ tv.tv_usec = 0;
+ while (1) {
+ check_all_interfaces();
+ start_servers(true);
+ sleep(1);
+ }
+#ifdef linux
+ br_shutdown();
+#endif
+
+ return 0;
+}
diff --git a/package/network/services/ead/src/ead.h b/package/network/services/ead/src/ead.h
new file mode 100644
index 0000000..54505ce
--- /dev/null
+++ b/package/network/services/ead/src/ead.h
@@ -0,0 +1,139 @@
+/*
+ * Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation
+ *
+ * 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.
+ */
+
+#ifndef __EAD_H
+#define __EAD_H
+
+#define EAD_DEBUGLEVEL 1
+
+#include <stdint.h>
+#include <stddef.h>
+
+#ifndef MAXSALTLEN
+#define MAXSALTLEN 32
+#endif
+
+#define EAD_PORT 56026UL
+#define EAD_MAGIC 3671771902UL
+#define EAD_CMD_TIMEOUT 10
+
+#define EAD_MAX_IV_INCR 128
+
+/* request/response types */
+/* response id == request id + 1 */
+enum ead_type {
+ EAD_TYPE_PING,
+ EAD_TYPE_PONG,
+
+ EAD_TYPE_SET_USERNAME,
+ EAD_TYPE_ACK_USERNAME,
+
+ EAD_TYPE_GET_PRIME,
+ EAD_TYPE_PRIME,
+
+ EAD_TYPE_SEND_A,
+ EAD_TYPE_SEND_B,
+
+ EAD_TYPE_SEND_AUTH,
+ EAD_TYPE_DONE_AUTH,
+
+ EAD_TYPE_SEND_CMD,
+ EAD_TYPE_RESULT_CMD,
+
+ EAD_TYPE_LAST
+};
+
+enum ead_auth_type {
+ EAD_AUTH_DEFAULT,
+ EAD_AUTH_MD5
+};
+
+enum ead_cmd_type {
+ EAD_CMD_NORMAL,
+ EAD_CMD_BACKGROUND,
+ EAD_CMD_LAST
+};
+
+struct ead_msg_pong {
+ uint16_t auth_type;
+ char name[];
+} __attribute__((packed));
+
+struct ead_msg_number {
+ uint8_t id;
+ unsigned char data[];
+} __attribute__((packed));
+
+struct ead_msg_salt {
+ uint8_t prime;
+ uint8_t len;
+ unsigned char salt[MAXSALTLEN];
+ unsigned char ext_salt[MAXSALTLEN];
+} __attribute__((packed));
+
+struct ead_msg_user {
+ char username[32];
+} __attribute__((packed));
+
+struct ead_msg_auth {
+ unsigned char data[20];
+} __attribute__((packed));
+
+struct ead_msg_cmd {
+ uint8_t type;
+ uint16_t timeout;
+ unsigned char data[];
+} __attribute__((packed));
+
+struct ead_msg_cmd_data {
+ uint8_t done;
+ unsigned char data[];
+} __attribute__((packed));
+
+struct ead_msg_encrypted {
+ uint32_t hash[5];
+ uint32_t iv;
+ uint8_t pad;
+ union {
+ struct ead_msg_cmd cmd;
+ struct ead_msg_cmd_data cmd_data;
+ } data[];
+} __attribute__((packed));
+
+
+#define EAD_DATA(_msg, _type) (&((_msg)->data[0]._type))
+#define EAD_ENC_DATA(_msg, _type) (&((_msg)->data[0].enc.data[0]._type))
+
+/* for ead_msg::sid */
+#define EAD_INSTANCE_MASK 0xf000
+#define EAD_INSTANCE_SHIFT 12
+
+struct ead_msg {
+ uint32_t magic;
+ uint32_t len;
+ uint32_t type;
+ uint16_t nid; /* node id */
+ uint16_t sid; /* session id */
+ uint32_t ip; /* source ip for responses from the server */
+ union {
+ struct ead_msg_pong pong;
+ struct ead_msg_user user;
+ struct ead_msg_number number;
+ struct ead_msg_auth auth;
+ struct ead_msg_salt salt;
+ struct ead_msg_encrypted enc;
+ } data[];
+} __attribute__((packed));
+
+
+#endif
diff --git a/package/network/services/ead/src/filter.c b/package/network/services/ead/src/filter.c
new file mode 100644
index 0000000..0759dc3
--- /dev/null
+++ b/package/network/services/ead/src/filter.c
@@ -0,0 +1,25 @@
+/* precompiled expression: udp and dst port 56026 */
+
+static struct bpf_insn pktfilter_insns[] = {
+ { .code = 0x0028, .jt = 0x00, .jf = 0x00, .k = 0x0000000c },
+ { .code = 0x0015, .jt = 0x00, .jf = 0x04, .k = 0x000086dd },
+ { .code = 0x0030, .jt = 0x00, .jf = 0x00, .k = 0x00000014 },
+ { .code = 0x0015, .jt = 0x00, .jf = 0x0b, .k = 0x00000011 },
+ { .code = 0x0028, .jt = 0x00, .jf = 0x00, .k = 0x00000038 },
+ { .code = 0x0015, .jt = 0x08, .jf = 0x09, .k = 0x0000dada },
+ { .code = 0x0015, .jt = 0x00, .jf = 0x08, .k = 0x00000800 },
+ { .code = 0x0030, .jt = 0x00, .jf = 0x00, .k = 0x00000017 },
+ { .code = 0x0015, .jt = 0x00, .jf = 0x06, .k = 0x00000011 },
+ { .code = 0x0028, .jt = 0x00, .jf = 0x00, .k = 0x00000014 },
+ { .code = 0x0045, .jt = 0x04, .jf = 0x00, .k = 0x00001fff },
+ { .code = 0x00b1, .jt = 0x00, .jf = 0x00, .k = 0x0000000e },
+ { .code = 0x0048, .jt = 0x00, .jf = 0x00, .k = 0x00000010 },
+ { .code = 0x0015, .jt = 0x00, .jf = 0x01, .k = 0x0000dada },
+ { .code = 0x0006, .jt = 0x00, .jf = 0x00, .k = 0x000005dc },
+ { .code = 0x0006, .jt = 0x00, .jf = 0x00, .k = 0x00000000 },
+};
+
+static struct bpf_program pktfilter = {
+ .bf_len = 16,
+ .bf_insns = pktfilter_insns,
+};
diff --git a/package/network/services/ead/src/libbridge.h b/package/network/services/ead/src/libbridge.h
new file mode 100644
index 0000000..6b70e46
--- /dev/null
+++ b/package/network/services/ead/src/libbridge.h
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2000 Lennert Buytenhek
+ *
+ * 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 of the
+ * License, 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; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef _LIBBRIDGE_H
+#define _LIBBRIDGE_H
+
+#include <sys/socket.h>
+#include <linux/if.h>
+#include <linux/if_bridge.h>
+
+/* defined in net/if.h but that conflicts with linux/if.h... */
+extern unsigned int if_nametoindex (const char *__ifname);
+extern char *if_indextoname (unsigned int __ifindex, char *__ifname);
+
+struct bridge_id
+{
+ unsigned char prio[2];
+ unsigned char addr[6];
+};
+
+struct bridge_info
+{
+ struct bridge_id designated_root;
+ struct bridge_id bridge_id;
+ unsigned root_path_cost;
+ struct timeval max_age;
+ struct timeval hello_time;
+ struct timeval forward_delay;
+ struct timeval bridge_max_age;
+ struct timeval bridge_hello_time;
+ struct timeval bridge_forward_delay;
+ u_int16_t root_port;
+ unsigned char stp_enabled;
+ unsigned char topology_change;
+ unsigned char topology_change_detected;
+ struct timeval ageing_time;
+ struct timeval hello_timer_value;
+ struct timeval tcn_timer_value;
+ struct timeval topology_change_timer_value;
+ struct timeval gc_timer_value;
+};
+
+struct fdb_entry
+{
+ u_int8_t mac_addr[6];
+ u_int16_t port_no;
+ unsigned char is_local;
+ struct timeval ageing_timer_value;
+};
+
+struct port_info
+{
+ unsigned port_no;
+ struct bridge_id designated_root;
+ struct bridge_id designated_bridge;
+ u_int16_t port_id;
+ u_int16_t designated_port;
+ u_int8_t priority;
+ unsigned char top_change_ack;
+ unsigned char config_pending;
+ unsigned char state;
+ unsigned path_cost;
+ unsigned designated_cost;
+ struct timeval message_age_timer_value;
+ struct timeval forward_delay_timer_value;
+ struct timeval hold_timer_value;
+};
+
+#endif
diff --git a/package/network/services/ead/src/libbridge_init.c b/package/network/services/ead/src/libbridge_init.c
new file mode 100644
index 0000000..36d0eb9
--- /dev/null
+++ b/package/network/services/ead/src/libbridge_init.c
@@ -0,0 +1,208 @@
+/*
+ * Copyright (C) 2000 Lennert Buytenhek
+ *
+ * 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 of the
+ * License, 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; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+#include <string.h>
+#include <dirent.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include "libbridge.h"
+#include "libbridge_private.h"
+
+int br_socket_fd = -1;
+
+static int br_init(void)
+{
+ if ((br_socket_fd = socket(AF_LOCAL, SOCK_STREAM, 0)) < 0)
+ return errno;
+ return 0;
+}
+
+static void br_shutdown(void)
+{
+ close(br_socket_fd);
+ br_socket_fd = -1;
+}
+
+/* If /sys/class/net/XXX/bridge exists then it must be a bridge */
+static int isbridge(const struct dirent *entry)
+{
+ char path[SYSFS_PATH_MAX];
+ struct stat st;
+
+ snprintf(path, SYSFS_PATH_MAX, SYSFS_CLASS_NET "%s/bridge", entry->d_name);
+ return stat(path, &st) == 0 && S_ISDIR(st.st_mode);
+}
+
+/*
+ * New interface uses sysfs to find bridges
+ */
+static int new_foreach_bridge(int (*iterator)(const char *name, void *),
+ void *arg)
+{
+ struct dirent **namelist;
+ int i, count = 0;
+
+ count = scandir(SYSFS_CLASS_NET, &namelist, isbridge, alphasort);
+ if (count < 0)
+ return -1;
+
+ for (i = 0; i < count; i++) {
+ if (iterator(namelist[i]->d_name, arg))
+ break;
+ }
+
+ for (i = 0; i < count; i++)
+ free(namelist[i]);
+ free(namelist);
+
+ return count;
+}
+
+/*
+ * Old interface uses ioctl
+ */
+static int old_foreach_bridge(int (*iterator)(const char *, void *),
+ void *iarg)
+{
+ int i, ret=0, num;
+ char ifname[IFNAMSIZ];
+ int ifindices[MAX_BRIDGES];
+ unsigned long args[3] = { BRCTL_GET_BRIDGES,
+ (unsigned long)ifindices, MAX_BRIDGES };
+
+ num = ioctl(br_socket_fd, SIOCGIFBR, args);
+ if (num < 0) {
+ dprintf("Get bridge indices failed: %s\n",
+ strerror(errno));
+ return -errno;
+ }
+
+ for (i = 0; i < num; i++) {
+ if (!if_indextoname(ifindices[i], ifname)) {
+ dprintf("get find name for ifindex %d\n",
+ ifindices[i]);
+ return -errno;
+ }
+
+ ++ret;
+ if(iterator(ifname, iarg))
+ break;
+ }
+
+ return ret;
+
+}
+
+/*
+ * Go over all bridges and call iterator function.
+ * if iterator returns non-zero then stop.
+ */
+static int br_foreach_bridge(int (*iterator)(const char *, void *),
+ void *arg)
+{
+ int ret;
+
+ ret = new_foreach_bridge(iterator, arg);
+ if (ret <= 0)
+ ret = old_foreach_bridge(iterator, arg);
+
+ return ret;
+}
+
+/*
+ * Only used if sysfs is not available.
+ */
+static int old_foreach_port(const char *brname,
+ int (*iterator)(const char *br, const char *port,
+ void *arg),
+ void *arg)
+{
+ int i, err, count;
+ struct ifreq ifr;
+ char ifname[IFNAMSIZ];
+ int ifindices[MAX_PORTS];
+ unsigned long args[4] = { BRCTL_GET_PORT_LIST,
+ (unsigned long)ifindices, MAX_PORTS, 0 };
+
+ memset(ifindices, 0, sizeof(ifindices));
+ strncpy(ifr.ifr_name, brname, IFNAMSIZ);
+ ifr.ifr_data = (char *) &args;
+
+ err = ioctl(br_socket_fd, SIOCDEVPRIVATE, &ifr);
+ if (err < 0) {
+ dprintf("list ports for bridge:'%s' failed: %s\n",
+ brname, strerror(errno));
+ return -errno;
+ }
+
+ count = 0;
+ for (i = 0; i < MAX_PORTS; i++) {
+ if (!ifindices[i])
+ continue;
+
+ if (!if_indextoname(ifindices[i], ifname)) {
+ dprintf("can't find name for ifindex:%d\n",
+ ifindices[i]);
+ continue;
+ }
+
+ ++count;
+ if (iterator(brname, ifname, arg))
+ break;
+ }
+
+ return count;
+}
+
+/*
+ * Iterate over all ports in bridge (using sysfs).
+ */
+static int br_foreach_port(const char *brname,
+ int (*iterator)(const char *br, const char *port, void *arg),
+ void *arg)
+{
+ int i, count;
+ struct dirent **namelist;
+ char path[SYSFS_PATH_MAX];
+
+ snprintf(path, SYSFS_PATH_MAX, SYSFS_CLASS_NET "%s/brif", brname);
+ count = scandir(path, &namelist, 0, alphasort);
+ if (count < 0)
+ return old_foreach_port(brname, iterator, arg);
+
+ for (i = 0; i < count; i++) {
+ if (namelist[i]->d_name[0] == '.'
+ && (namelist[i]->d_name[1] == '\0'
+ || (namelist[i]->d_name[1] == '.'
+ && namelist[i]->d_name[2] == '\0')))
+ continue;
+
+ if (iterator(brname, namelist[i]->d_name, arg))
+ break;
+ }
+ for (i = 0; i < count; i++)
+ free(namelist[i]);
+ free(namelist);
+
+ return count;
+}
diff --git a/package/network/services/ead/src/libbridge_private.h b/package/network/services/ead/src/libbridge_private.h
new file mode 100644
index 0000000..38fd60e
--- /dev/null
+++ b/package/network/services/ead/src/libbridge_private.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2000 Lennert Buytenhek
+ *
+ * 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 of the
+ * License, 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; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef _LIBBRIDGE_PRIVATE_H
+#define _LIBBRIDGE_PRIVATE_H
+
+#include <linux/sockios.h>
+#include <sys/time.h>
+#include <sys/ioctl.h>
+#include <linux/if_bridge.h>
+
+#define MAX_BRIDGES 1024
+#define MAX_PORTS 1024
+
+#define SYSFS_CLASS_NET "/sys/class/net/"
+#define SYSFS_PATH_MAX 256
+
+#define dprintf(fmt,arg...)
+
+#endif
diff --git a/package/network/services/ead/src/list.h b/package/network/services/ead/src/list.h
new file mode 100644
index 0000000..ac429c8
--- /dev/null
+++ b/package/network/services/ead/src/list.h
@@ -0,0 +1,602 @@
+/* GPL v2, adapted from the Linux kernel */
+#ifndef _LINUX_LIST_H
+#define _LINUX_LIST_H
+
+#include <stddef.h>
+/**
+ * container_of - cast a member of a structure out to the containing structure
+ * @ptr: the pointer to the member.
+ * @type: the type of the container struct this is embedded in.
+ * @member: the name of the member within the struct.
+ *
+ */
+#ifndef container_of
+#define container_of(ptr, type, member) ( \
+ (type *)( (char *)ptr - offsetof(type,member) ))
+#endif
+
+
+/*
+ * Simple doubly linked list implementation.
+ *
+ * Some of the internal functions ("__xxx") are useful when
+ * manipulating whole lists rather than single entries, as
+ * sometimes we already know the next/prev entries and we can
+ * generate better code by using them directly rather than
+ * using the generic single-entry routines.
+ */
+
+struct list_head {
+ struct list_head *next, *prev;
+};
+
+#define LIST_HEAD_INIT(name) { &(name), &(name) }
+
+#define LIST_HEAD(name) \
+ struct list_head name = LIST_HEAD_INIT(name)
+
+static inline void INIT_LIST_HEAD(struct list_head *list)
+{
+ list->next = list;
+ list->prev = list;
+}
+
+/*
+ * Insert a new entry between two known consecutive entries.
+ *
+ * This is only for internal list manipulation where we know
+ * the prev/next entries already!
+ */
+static inline void __list_add(struct list_head *new,
+ struct list_head *prev,
+ struct list_head *next)
+{
+ next->prev = new;
+ new->next = next;
+ new->prev = prev;
+ prev->next = new;
+}
+
+/**
+ * list_add - add a new entry
+ * @new: new entry to be added
+ * @head: list head to add it after
+ *
+ * Insert a new entry after the specified head.
+ * This is good for implementing stacks.
+ */
+static inline void list_add(struct list_head *new, struct list_head *head)
+{
+ __list_add(new, head, head->next);
+}
+
+
+/**
+ * list_add_tail - add a new entry
+ * @new: new entry to be added
+ * @head: list head to add it before
+ *
+ * Insert a new entry before the specified head.
+ * This is useful for implementing queues.
+ */
+static inline void list_add_tail(struct list_head *new, struct list_head *head)
+{
+ __list_add(new, head->prev, head);
+}
+
+
+/*
+ * Delete a list entry by making the prev/next entries
+ * point to each other.
+ *
+ * This is only for internal list manipulation where we know
+ * the prev/next entries already!
+ */
+static inline void __list_del(struct list_head * prev, struct list_head * next)
+{
+ next->prev = prev;
+ prev->next = next;
+}
+
+/**
+ * list_del - deletes entry from list.
+ * @entry: the element to delete from the list.
+ * Note: list_empty() on entry does not return true after this, the entry is
+ * in an undefined state.
+ */
+static inline void list_del(struct list_head *entry)
+{
+ __list_del(entry->prev, entry->next);
+ entry->next = NULL;
+ entry->prev = NULL;
+}
+
+/**
+ * list_replace - replace old entry by new one
+ * @old : the element to be replaced
+ * @new : the new element to insert
+ *
+ * If @old was empty, it will be overwritten.
+ */
+static inline void list_replace(struct list_head *old,
+ struct list_head *new)
+{
+ new->next = old->next;
+ new->next->prev = new;
+ new->prev = old->prev;
+ new->prev->next = new;
+}
+
+static inline void list_replace_init(struct list_head *old,
+ struct list_head *new)
+{
+ list_replace(old, new);
+ INIT_LIST_HEAD(old);
+}
+
+/**
+ * list_del_init - deletes entry from list and reinitialize it.
+ * @entry: the element to delete from the list.
+ */
+static inline void list_del_init(struct list_head *entry)
+{
+ __list_del(entry->prev, entry->next);
+ INIT_LIST_HEAD(entry);
+}
+
+/**
+ * list_move - delete from one list and add as another's head
+ * @list: the entry to move
+ * @head: the head that will precede our entry
+ */
+static inline void list_move(struct list_head *list, struct list_head *head)
+{
+ __list_del(list->prev, list->next);
+ list_add(list, head);
+}
+
+/**
+ * list_move_tail - delete from one list and add as another's tail
+ * @list: the entry to move
+ * @head: the head that will follow our entry
+ */
+static inline void list_move_tail(struct list_head *list,
+ struct list_head *head)
+{
+ __list_del(list->prev, list->next);
+ list_add_tail(list, head);
+}
+
+/**
+ * list_is_last - tests whether @list is the last entry in list @head
+ * @list: the entry to test
+ * @head: the head of the list
+ */
+static inline int list_is_last(const struct list_head *list,
+ const struct list_head *head)
+{
+ return list->next == head;
+}
+
+/**
+ * list_empty - tests whether a list is empty
+ * @head: the list to test.
+ */
+static inline int list_empty(const struct list_head *head)
+{
+ return head->next == head;
+}
+
+/**
+ * list_empty_careful - tests whether a list is empty and not being modified
+ * @head: the list to test
+ *
+ * Description:
+ * tests whether a list is empty _and_ checks that no other CPU might be
+ * in the process of modifying either member (next or prev)
+ *
+ * NOTE: using list_empty_careful() without synchronization
+ * can only be safe if the only activity that can happen
+ * to the list entry is list_del_init(). Eg. it cannot be used
+ * if another CPU could re-list_add() it.
+ */
+static inline int list_empty_careful(const struct list_head *head)
+{
+ struct list_head *next = head->next;
+ return (next == head) && (next == head->prev);
+}
+
+static inline void __list_splice(struct list_head *list,
+ struct list_head *head)
+{
+ struct list_head *first = list->next;
+ struct list_head *last = list->prev;
+ struct list_head *at = head->next;
+
+ first->prev = head;
+ head->next = first;
+
+ last->next = at;
+ at->prev = last;
+}
+
+/**
+ * list_splice - join two lists
+ * @list: the new list to add.
+ * @head: the place to add it in the first list.
+ */
+static inline void list_splice(struct list_head *list, struct list_head *head)
+{
+ if (!list_empty(list))
+ __list_splice(list, head);
+}
+
+/**
+ * list_splice_init - join two lists and reinitialise the emptied list.
+ * @list: the new list to add.
+ * @head: the place to add it in the first list.
+ *
+ * The list at @list is reinitialised
+ */
+static inline void list_splice_init(struct list_head *list,
+ struct list_head *head)
+{
+ if (!list_empty(list)) {
+ __list_splice(list, head);
+ INIT_LIST_HEAD(list);
+ }
+}
+
+/**
+ * list_entry - get the struct for this entry
+ * @ptr: the &struct list_head pointer.
+ * @type: the type of the struct this is embedded in.
+ * @member: the name of the list_struct within the struct.
+ */
+#define list_entry(ptr, type, member) \
+ container_of(ptr, type, member)
+
+/**
+ * list_first_entry - get the first element from a list
+ * @ptr: the list head to take the element from.
+ * @type: the type of the struct this is embedded in.
+ * @member: the name of the list_struct within the struct.
+ *
+ * Note, that list is expected to be not empty.
+ */
+#define list_first_entry(ptr, type, member) \
+ list_entry((ptr)->next, type, member)
+
+/**
+ * list_for_each - iterate over a list
+ * @pos: the &struct list_head to use as a loop cursor.
+ * @head: the head for your list.
+ */
+#define list_for_each(pos, head) \
+ for (pos = (head)->next; pos != (head); \
+ pos = pos->next)
+
+/**
+ * __list_for_each - iterate over a list
+ * @pos: the &struct list_head to use as a loop cursor.
+ * @head: the head for your list.
+ *
+ * This variant differs from list_for_each() in that it's the
+ * simplest possible list iteration code, no prefetching is done.
+ * Use this for code that knows the list to be very short (empty
+ * or 1 entry) most of the time.
+ */
+#define __list_for_each(pos, head) \
+ for (pos = (head)->next; pos != (head); pos = pos->next)
+
+/**
+ * list_for_each_prev - iterate over a list backwards
+ * @pos: the &struct list_head to use as a loop cursor.
+ * @head: the head for your list.
+ */
+#define list_for_each_prev(pos, head) \
+ for (pos = (head)->prev; pos != (head); \
+ pos = pos->prev)
+
+/**
+ * list_for_each_safe - iterate over a list safe against removal of list entry
+ * @pos: the &struct list_head to use as a loop cursor.
+ * @n: another &struct list_head to use as temporary storage
+ * @head: the head for your list.
+ */
+#define list_for_each_safe(pos, n, head) \
+ for (pos = (head)->next, n = pos->next; pos != (head); \
+ pos = n, n = pos->next)
+
+/**
+ * list_for_each_prev_safe - iterate over a list backwards safe against removal of list entry
+ * @pos: the &struct list_head to use as a loop cursor.
+ * @n: another &struct list_head to use as temporary storage
+ * @head: the head for your list.
+ */
+#define list_for_each_prev_safe(pos, n, head) \
+ for (pos = (head)->prev, n = pos->prev; \
+ pos != (head); \
+ pos = n, n = pos->prev)
+
+/**
+ * list_for_each_entry - iterate over list of given type
+ * @pos: the type * to use as a loop cursor.
+ * @head: the head for your list.
+ * @member: the name of the list_struct within the struct.
+ */
+#define list_for_each_entry(pos, head, member) \
+ for (pos = list_entry((head)->next, typeof(*pos), member); \
+ &pos->member != (head); \
+ pos = list_entry(pos->member.next, typeof(*pos), member))
+
+/**
+ * list_for_each_entry_reverse - iterate backwards over list of given type.
+ * @pos: the type * to use as a loop cursor.
+ * @head: the head for your list.
+ * @member: the name of the list_struct within the struct.
+ */
+#define list_for_each_entry_reverse(pos, head, member) \
+ for (pos = list_entry((head)->prev, typeof(*pos), member); \
+ &pos->member != (head); \
+ pos = list_entry(pos->member.prev, typeof(*pos), member))
+
+/**
+ * list_prepare_entry - prepare a pos entry for use in list_for_each_entry_continue()
+ * @pos: the type * to use as a start point
+ * @head: the head of the list
+ * @member: the name of the list_struct within the struct.
+ *
+ * Prepares a pos entry for use as a start point in list_for_each_entry_continue().
+ */
+#define list_prepare_entry(pos, head, member) \
+ ((pos) ? : list_entry(head, typeof(*pos), member))
+
+/**
+ * list_for_each_entry_continue - continue iteration over list of given type
+ * @pos: the type * to use as a loop cursor.
+ * @head: the head for your list.
+ * @member: the name of the list_struct within the struct.
+ *
+ * Continue to iterate over list of given type, continuing after
+ * the current position.
+ */
+#define list_for_each_entry_continue(pos, head, member) \
+ for (pos = list_entry(pos->member.next, typeof(*pos), member); \
+ &pos->member != (head); \
+ pos = list_entry(pos->member.next, typeof(*pos), member))
+
+/**
+ * list_for_each_entry_continue_reverse - iterate backwards from the given point
+ * @pos: the type * to use as a loop cursor.
+ * @head: the head for your list.
+ * @member: the name of the list_struct within the struct.
+ *
+ * Start to iterate over list of given type backwards, continuing after
+ * the current position.
+ */
+#define list_for_each_entry_continue_reverse(pos, head, member) \
+ for (pos = list_entry(pos->member.prev, typeof(*pos), member); \
+ &pos->member != (head); \
+ pos = list_entry(pos->member.prev, typeof(*pos), member))
+
+/**
+ * list_for_each_entry_from - iterate over list of given type from the current point
+ * @pos: the type * to use as a loop cursor.
+ * @head: the head for your list.
+ * @member: the name of the list_struct within the struct.
+ *
+ * Iterate over list of given type, continuing from current position.
+ */
+#define list_for_each_entry_from(pos, head, member) \
+ for (; &pos->member != (head); \
+ pos = list_entry(pos->member.next, typeof(*pos), member))
+
+/**
+ * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
+ * @pos: the type * to use as a loop cursor.
+ * @n: another type * to use as temporary storage
+ * @head: the head for your list.
+ * @member: the name of the list_struct within the struct.
+ */
+#define list_for_each_entry_safe(pos, n, head, member) \
+ for (pos = list_entry((head)->next, typeof(*pos), member), \
+ n = list_entry(pos->member.next, typeof(*pos), member); \
+ &pos->member != (head); \
+ pos = n, n = list_entry(n->member.next, typeof(*n), member))
+
+/**
+ * list_for_each_entry_safe_continue
+ * @pos: the type * to use as a loop cursor.
+ * @n: another type * to use as temporary storage
+ * @head: the head for your list.
+ * @member: the name of the list_struct within the struct.
+ *
+ * Iterate over list of given type, continuing after current point,
+ * safe against removal of list entry.
+ */
+#define list_for_each_entry_safe_continue(pos, n, head, member) \
+ for (pos = list_entry(pos->member.next, typeof(*pos), member), \
+ n = list_entry(pos->member.next, typeof(*pos), member); \
+ &pos->member != (head); \
+ pos = n, n = list_entry(n->member.next, typeof(*n), member))
+
+/**
+ * list_for_each_entry_safe_from
+ * @pos: the type * to use as a loop cursor.
+ * @n: another type * to use as temporary storage
+ * @head: the head for your list.
+ * @member: the name of the list_struct within the struct.
+ *
+ * Iterate over list of given type from current point, safe against
+ * removal of list entry.
+ */
+#define list_for_each_entry_safe_from(pos, n, head, member) \
+ for (n = list_entry(pos->member.next, typeof(*pos), member); \
+ &pos->member != (head); \
+ pos = n, n = list_entry(n->member.next, typeof(*n), member))
+
+/**
+ * list_for_each_entry_safe_reverse
+ * @pos: the type * to use as a loop cursor.
+ * @n: another type * to use as temporary storage
+ * @head: the head for your list.
+ * @member: the name of the list_struct within the struct.
+ *
+ * Iterate backwards over list of given type, safe against removal
+ * of list entry.
+ */
+#define list_for_each_entry_safe_reverse(pos, n, head, member) \
+ for (pos = list_entry((head)->prev, typeof(*pos), member), \
+ n = list_entry(pos->member.prev, typeof(*pos), member); \
+ &pos->member != (head); \
+ pos = n, n = list_entry(n->member.prev, typeof(*n), member))
+
+/*
+ * Double linked lists with a single pointer list head.
+ * Mostly useful for hash tables where the two pointer list head is
+ * too wasteful.
+ * You lose the ability to access the tail in O(1).
+ */
+
+struct hlist_head {
+ struct hlist_node *first;
+};
+
+struct hlist_node {
+ struct hlist_node *next, **pprev;
+};
+
+#define HLIST_HEAD_INIT { .first = NULL }
+#define HLIST_HEAD(name) struct hlist_head name = { .first = NULL }
+#define INIT_HLIST_HEAD(ptr) ((ptr)->first = NULL)
+static inline void INIT_HLIST_NODE(struct hlist_node *h)
+{
+ h->next = NULL;
+ h->pprev = NULL;
+}
+
+static inline int hlist_unhashed(const struct hlist_node *h)
+{
+ return !h->pprev;
+}
+
+static inline int hlist_empty(const struct hlist_head *h)
+{
+ return !h->first;
+}
+
+static inline void __hlist_del(struct hlist_node *n)
+{
+ struct hlist_node *next = n->next;
+ struct hlist_node **pprev = n->pprev;
+ *pprev = next;
+ if (next)
+ next->pprev = pprev;
+}
+
+static inline void hlist_del(struct hlist_node *n)
+{
+ __hlist_del(n);
+ n->next = NULL;
+ n->pprev = NULL;
+}
+
+static inline void hlist_del_init(struct hlist_node *n)
+{
+ if (!hlist_unhashed(n)) {
+ __hlist_del(n);
+ INIT_HLIST_NODE(n);
+ }
+}
+
+
+static inline void hlist_add_head(struct hlist_node *n, struct hlist_head *h)
+{
+ struct hlist_node *first = h->first;
+ n->next = first;
+ if (first)
+ first->pprev = &n->next;
+ h->first = n;
+ n->pprev = &h->first;
+}
+
+
+/* next must be != NULL */
+static inline void hlist_add_before(struct hlist_node *n,
+ struct hlist_node *next)
+{
+ n->pprev = next->pprev;
+ n->next = next;
+ next->pprev = &n->next;
+ *(n->pprev) = n;
+}
+
+static inline void hlist_add_after(struct hlist_node *n,
+ struct hlist_node *next)
+{
+ next->next = n->next;
+ n->next = next;
+ next->pprev = &n->next;
+
+ if(next->next)
+ next->next->pprev = &next->next;
+}
+
+#define hlist_entry(ptr, type, member) container_of(ptr,type,member)
+
+#define hlist_for_each(pos, head) \
+ for (pos = (head)->first; pos; pos = pos->next)
+
+#define hlist_for_each_safe(pos, n, head) \
+ for (pos = (head)->first; pos; pos = n)
+
+/**
+ * hlist_for_each_entry - iterate over list of given type
+ * @tpos: the type * to use as a loop cursor.
+ * @pos: the &struct hlist_node to use as a loop cursor.
+ * @head: the head for your list.
+ * @member: the name of the hlist_node within the struct.
+ */
+#define hlist_for_each_entry(tpos, pos, head, member) \
+ for (pos = (head)->first; pos && \
+ ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
+ pos = pos->next)
+
+/**
+ * hlist_for_each_entry_continue - iterate over a hlist continuing after current point
+ * @tpos: the type * to use as a loop cursor.
+ * @pos: the &struct hlist_node to use as a loop cursor.
+ * @member: the name of the hlist_node within the struct.
+ */
+#define hlist_for_each_entry_continue(tpos, pos, member) \
+ for (pos = (pos)->next; pos && \
+ ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
+ pos = pos->next)
+
+/**
+ * hlist_for_each_entry_from - iterate over a hlist continuing from current point
+ * @tpos: the type * to use as a loop cursor.
+ * @pos: the &struct hlist_node to use as a loop cursor.
+ * @member: the name of the hlist_node within the struct.
+ */
+#define hlist_for_each_entry_from(tpos, pos, member) \
+ for (; pos && \
+ ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
+ pos = pos->next)
+
+/**
+ * hlist_for_each_entry_safe - iterate over list of given type safe against removal of list entry
+ * @tpos: the type * to use as a loop cursor.
+ * @pos: the &struct hlist_node to use as a loop cursor.
+ * @n: another &struct hlist_node to use as temporary storage
+ * @head: the head for your list.
+ * @member: the name of the hlist_node within the struct.
+ */
+#define hlist_for_each_entry_safe(tpos, pos, n, head, member) \
+ for (pos = (head)->first; \
+ pos && ({ n = pos->next; 1; }) && \
+ ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
+ pos = n)
+
+#endif
diff --git a/package/network/services/ead/src/passwd b/package/network/services/ead/src/passwd
new file mode 100644
index 0000000..eee7a89
--- /dev/null
+++ b/package/network/services/ead/src/passwd
@@ -0,0 +1,3 @@
+root:$1$MCGAgYw.$Ip1GcyeUliId3wzVcKR/e/:0:0:root:/root:/bin/ash
+nobody:*:65534:65534:nobody:/var:/bin/false
+daemon:*:65534:65534:daemon:/var:/bin/false
diff --git a/package/network/services/ead/src/pfc.c b/package/network/services/ead/src/pfc.c
new file mode 100644
index 0000000..402e37f
--- /dev/null
+++ b/package/network/services/ead/src/pfc.c
@@ -0,0 +1,54 @@
+/*
+ * Small pcap precompiler
+ * Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation
+ *
+ * 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.
+ */
+
+#include <sys/types.h>
+#include <sys/time.h>
+#include <string.h>
+#include <stdlib.h>
+#include <pcap.h>
+
+int main (int argc, char ** argv)
+{
+ struct bpf_program filter;
+ pcap_t *pc;
+ int i;
+
+ if (argc != 2)
+ {
+ printf ("Usage: %s <expression>\n", argv[0]);
+ return 1;
+ }
+
+ pc = pcap_open_dead(DLT_EN10MB, 1500);
+ if (pcap_compile(pc, &filter, argv[1], 1, 0) != 0) {
+ printf("error in active-filter expression: %s\n", pcap_geterr(pc));
+ return 1;
+ }
+
+ printf("/* precompiled expression: %s */\n\n"
+ "static struct bpf_insn pktfilter_insns[] = {\n",
+ argv[1]);
+
+ for (i = 0; i < filter.bf_len; i++) {
+ struct bpf_insn *in = &filter.bf_insns[i];
+ printf("\t{ .code = 0x%04x, .jt = 0x%02x, .jf = 0x%02x, .k = 0x%08x },\n", in->code, in->jt, in->jf, in->k);
+ }
+ printf("};\n\n"
+ "static struct bpf_program pktfilter = {\n"
+ "\t.bf_len = %d,\n"
+ "\t.bf_insns = pktfilter_insns,\n"
+ "};\n", filter.bf_len);
+ return 0;
+
+}
diff --git a/package/network/services/ead/src/pw_encrypt_md5.c b/package/network/services/ead/src/pw_encrypt_md5.c
new file mode 100644
index 0000000..bc9f249
--- /dev/null
+++ b/package/network/services/ead/src/pw_encrypt_md5.c
@@ -0,0 +1,646 @@
+/*
+ * MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm
+ *
+ * Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
+ * rights reserved.
+ *
+ * License to copy and use this software is granted provided that it
+ * is identified as the "RSA Data Security, Inc. MD5 Message-Digest
+ * Algorithm" in all material mentioning or referencing this software
+ * or this function.
+ *
+ * License is also granted to make and use derivative works provided
+ * that such works are identified as "derived from the RSA Data
+ * Security, Inc. MD5 Message-Digest Algorithm" in all material
+ * mentioning or referencing the derived work.
+ *
+ * RSA Data Security, Inc. makes no representations concerning either
+ * the merchantability of this software or the suitability of this
+ * software for any particular purpose. It is provided "as is"
+ * without express or implied warranty of any kind.
+ *
+ * These notices must be retained in any copies of any part of this
+ * documentation and/or software.
+ *
+ * $FreeBSD: src/lib/libmd/md5c.c,v 1.9.2.1 1999/08/29 14:57:12 peter Exp $
+ *
+ * This code is the same as the code published by RSA Inc. It has been
+ * edited for clarity and style only.
+ *
+ * ----------------------------------------------------------------------------
+ * The md5_crypt() function was taken from freeBSD's libcrypt and contains
+ * this license:
+ * "THE BEER-WARE LICENSE" (Revision 42):
+ * <phk@login.dknet.dk> wrote this file. As long as you retain this notice you
+ * can do whatever you want with this stuff. If we meet some day, and you think
+ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
+ *
+ * $FreeBSD: src/lib/libcrypt/crypt.c,v 1.7.2.1 1999/08/29 14:56:33 peter Exp $
+ *
+ * ----------------------------------------------------------------------------
+ * On April 19th, 2001 md5_crypt() was modified to make it reentrant
+ * by Erik Andersen <andersen@uclibc.org>
+ *
+ *
+ * June 28, 2001 Manuel Novoa III
+ *
+ * "Un-inlined" code using loops and static const tables in order to
+ * reduce generated code size (on i386 from approx 4k to approx 2.5k).
+ *
+ * June 29, 2001 Manuel Novoa III
+ *
+ * Completely removed static PADDING array.
+ *
+ * Reintroduced the loop unrolling in MD5_Transform and added the
+ * MD5_SIZE_OVER_SPEED option for configurability. Define below as:
+ * 0 fully unrolled loops
+ * 1 partially unrolled (4 ops per loop)
+ * 2 no unrolling -- introduces the need to swap 4 variables (slow)
+ * 3 no unrolling and all 4 loops merged into one with switch
+ * in each loop (glacial)
+ * On i386, sizes are roughly (-Os -fno-builtin):
+ * 0: 3k 1: 2.5k 2: 2.2k 3: 2k
+ *
+ *
+ * Since SuSv3 does not require crypt_r, modified again August 7, 2002
+ * by Erik Andersen to remove reentrance stuff...
+ */
+
+static const uint8_t ascii64[] = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+
+/*
+ * Valid values are 1 (fastest/largest) to 3 (smallest/slowest).
+ */
+#define MD5_SIZE_OVER_SPEED 3
+
+/**********************************************************************/
+
+/* MD5 context. */
+struct MD5Context {
+ uint32_t state[4]; /* state (ABCD) */
+ uint32_t count[2]; /* number of bits, modulo 2^64 (lsb first) */
+ unsigned char buffer[64]; /* input buffer */
+};
+
+static void __md5_Init(struct MD5Context *);
+static void __md5_Update(struct MD5Context *, const unsigned char *, unsigned int);
+static void __md5_Pad(struct MD5Context *);
+static void __md5_Final(unsigned char [16], struct MD5Context *);
+static void __md5_Transform(uint32_t [4], const unsigned char [64]);
+
+
+#define MD5_MAGIC_STR "$1$"
+#define MD5_MAGIC_LEN (sizeof(MD5_MAGIC_STR) - 1)
+static const unsigned char __md5__magic[] = MD5_MAGIC_STR;
+
+
+#ifdef i386
+#define __md5_Encode memcpy
+#define __md5_Decode memcpy
+#else /* i386 */
+
+/*
+ * __md5_Encodes input (uint32_t) into output (unsigned char). Assumes len is
+ * a multiple of 4.
+ */
+static void
+__md5_Encode(unsigned char *output, uint32_t *input, unsigned int len)
+{
+ unsigned int i, j;
+
+ for (i = 0, j = 0; j < len; i++, j += 4) {
+ output[j] = input[i];
+ output[j+1] = (input[i] >> 8);
+ output[j+2] = (input[i] >> 16);
+ output[j+3] = (input[i] >> 24);
+ }
+}
+
+/*
+ * __md5_Decodes input (unsigned char) into output (uint32_t). Assumes len is
+ * a multiple of 4.
+ */
+static void
+__md5_Decode(uint32_t *output, const unsigned char *input, unsigned int len)
+{
+ unsigned int i, j;
+
+ for (i = 0, j = 0; j < len; i++, j += 4)
+ output[i] = ((uint32_t)input[j]) | (((uint32_t)input[j+1]) << 8) |
+ (((uint32_t)input[j+2]) << 16) | (((uint32_t)input[j+3]) << 24);
+}
+#endif /* i386 */
+
+/* F, G, H and I are basic MD5 functions. */
+#define F(x, y, z) (((x) & (y)) | (~(x) & (z)))
+#define G(x, y, z) (((x) & (z)) | ((y) & ~(z)))
+#define H(x, y, z) ((x) ^ (y) ^ (z))
+#define I(x, y, z) ((y) ^ ((x) | ~(z)))
+
+/* ROTATE_LEFT rotates x left n bits. */
+#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
+
+/*
+ * FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
+ * Rotation is separate from addition to prevent recomputation.
+ */
+#define FF(a, b, c, d, x, s, ac) { \
+ (a) += F ((b), (c), (d)) + (x) + (uint32_t)(ac); \
+ (a) = ROTATE_LEFT((a), (s)); \
+ (a) += (b); \
+ }
+#define GG(a, b, c, d, x, s, ac) { \
+ (a) += G ((b), (c), (d)) + (x) + (uint32_t)(ac); \
+ (a) = ROTATE_LEFT((a), (s)); \
+ (a) += (b); \
+ }
+#define HH(a, b, c, d, x, s, ac) { \
+ (a) += H ((b), (c), (d)) + (x) + (uint32_t)(ac); \
+ (a) = ROTATE_LEFT((a), (s)); \
+ (a) += (b); \
+ }
+#define II(a, b, c, d, x, s, ac) { \
+ (a) += I ((b), (c), (d)) + (x) + (uint32_t)(ac); \
+ (a) = ROTATE_LEFT((a), (s)); \
+ (a) += (b); \
+ }
+
+/* MD5 initialization. Begins an MD5 operation, writing a new context. */
+static void __md5_Init(struct MD5Context *context)
+{
+ context->count[0] = context->count[1] = 0;
+
+ /* Load magic initialization constants. */
+ context->state[0] = 0x67452301;
+ context->state[1] = 0xefcdab89;
+ context->state[2] = 0x98badcfe;
+ context->state[3] = 0x10325476;
+}
+
+/*
+ * MD5 block update operation. Continues an MD5 message-digest
+ * operation, processing another message block, and updating the
+ * context.
+ */
+static void __md5_Update(struct MD5Context *context, const unsigned char *input, unsigned int inputLen)
+{
+ unsigned int i, idx, partLen;
+
+ /* Compute number of bytes mod 64 */
+ idx = (context->count[0] >> 3) & 0x3F;
+
+ /* Update number of bits */
+ context->count[0] += (inputLen << 3);
+ if (context->count[0] < (inputLen << 3))
+ context->count[1]++;
+ context->count[1] += (inputLen >> 29);
+
+ partLen = 64 - idx;
+
+ /* Transform as many times as possible. */
+ if (inputLen >= partLen) {
+ memcpy(&context->buffer[idx], input, partLen);
+ __md5_Transform(context->state, context->buffer);
+
+ for (i = partLen; i + 63 < inputLen; i += 64)
+ __md5_Transform(context->state, &input[i]);
+
+ idx = 0;
+ } else
+ i = 0;
+
+ /* Buffer remaining input */
+ memcpy(&context->buffer[idx], &input[i], inputLen - i);
+}
+
+/*
+ * MD5 padding. Adds padding followed by original length.
+ */
+static void __md5_Pad(struct MD5Context *context)
+{
+ unsigned char bits[8];
+ unsigned int idx, padLen;
+ unsigned char PADDING[64];
+
+ memset(PADDING, 0, sizeof(PADDING));
+ PADDING[0] = 0x80;
+
+ /* Save number of bits */
+ __md5_Encode(bits, context->count, 8);
+
+ /* Pad out to 56 mod 64. */
+ idx = (context->count[0] >> 3) & 0x3f;
+ padLen = (idx < 56) ? (56 - idx) : (120 - idx);
+ __md5_Update(context, PADDING, padLen);
+
+ /* Append length (before padding) */
+ __md5_Update(context, bits, 8);
+}
+
+/*
+ * MD5 finalization. Ends an MD5 message-digest operation, writing the
+ * the message digest and zeroizing the context.
+ */
+static void __md5_Final(unsigned char digest[16], struct MD5Context *context)
+{
+ /* Do padding. */
+ __md5_Pad(context);
+
+ /* Store state in digest */
+ __md5_Encode(digest, context->state, 16);
+
+ /* Zeroize sensitive information. */
+ memset(context, 0, sizeof(*context));
+}
+
+/* MD5 basic transformation. Transforms state based on block. */
+static void __md5_Transform(uint32_t state[4], const unsigned char block[64])
+{
+ uint32_t a, b, c, d, x[16];
+#if MD5_SIZE_OVER_SPEED > 1
+ uint32_t temp;
+ const unsigned char *ps;
+
+ static const unsigned char S[] = {
+ 7, 12, 17, 22,
+ 5, 9, 14, 20,
+ 4, 11, 16, 23,
+ 6, 10, 15, 21
+ };
+#endif /* MD5_SIZE_OVER_SPEED > 1 */
+
+#if MD5_SIZE_OVER_SPEED > 0
+ const uint32_t *pc;
+ const unsigned char *pp;
+ int i;
+
+ static const uint32_t C[] = {
+ /* round 1 */
+ 0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee,
+ 0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501,
+ 0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be,
+ 0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821,
+ /* round 2 */
+ 0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa,
+ 0xd62f105d, 0x2441453, 0xd8a1e681, 0xe7d3fbc8,
+ 0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed,
+ 0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a,
+ /* round 3 */
+ 0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c,
+ 0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70,
+ 0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x4881d05,
+ 0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665,
+ /* round 4 */
+ 0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039,
+ 0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1,
+ 0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1,
+ 0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391
+ };
+
+ static const unsigned char P[] = {
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, /* 1 */
+ 1, 6, 11, 0, 5, 10, 15, 4, 9, 14, 3, 8, 13, 2, 7, 12, /* 2 */
+ 5, 8, 11, 14, 1, 4, 7, 10, 13, 0, 3, 6, 9, 12, 15, 2, /* 3 */
+ 0, 7, 14, 5, 12, 3, 10, 1, 8, 15, 6, 13, 4, 11, 2, 9 /* 4 */
+ };
+
+#endif /* MD5_SIZE_OVER_SPEED > 0 */
+
+ __md5_Decode(x, block, 64);
+
+ a = state[0]; b = state[1]; c = state[2]; d = state[3];
+
+#if MD5_SIZE_OVER_SPEED > 2
+ pc = C; pp = P; ps = S - 4;
+
+ for (i = 0; i < 64; i++) {
+ if ((i & 0x0f) == 0) ps += 4;
+ temp = a;
+ switch (i>>4) {
+ case 0:
+ temp += F(b, c, d);
+ break;
+ case 1:
+ temp += G(b, c, d);
+ break;
+ case 2:
+ temp += H(b, c, d);
+ break;
+ case 3:
+ temp += I(b, c, d);
+ break;
+ }
+ temp += x[*pp++] + *pc++;
+ temp = ROTATE_LEFT(temp, ps[i & 3]);
+ temp += b;
+ a = d; d = c; c = b; b = temp;
+ }
+#elif MD5_SIZE_OVER_SPEED > 1
+ pc = C; pp = P; ps = S;
+
+ /* Round 1 */
+ for (i = 0; i < 16; i++) {
+ FF(a, b, c, d, x[*pp], ps[i & 0x3], *pc); pp++; pc++;
+ temp = d; d = c; c = b; b = a; a = temp;
+ }
+
+ /* Round 2 */
+ ps += 4;
+ for (; i < 32; i++) {
+ GG(a, b, c, d, x[*pp], ps[i & 0x3], *pc); pp++; pc++;
+ temp = d; d = c; c = b; b = a; a = temp;
+ }
+ /* Round 3 */
+ ps += 4;
+ for (; i < 48; i++) {
+ HH(a, b, c, d, x[*pp], ps[i & 0x3], *pc); pp++; pc++;
+ temp = d; d = c; c = b; b = a; a = temp;
+ }
+
+ /* Round 4 */
+ ps += 4;
+ for (; i < 64; i++) {
+ II(a, b, c, d, x[*pp], ps[i & 0x3], *pc); pp++; pc++;
+ temp = d; d = c; c = b; b = a; a = temp;
+ }
+#elif MD5_SIZE_OVER_SPEED > 0
+ pc = C; pp = P;
+
+ /* Round 1 */
+ for (i = 0; i < 4; i++) {
+ FF(a, b, c, d, x[*pp], 7, *pc); pp++; pc++;
+ FF(d, a, b, c, x[*pp], 12, *pc); pp++; pc++;
+ FF(c, d, a, b, x[*pp], 17, *pc); pp++; pc++;
+ FF(b, c, d, a, x[*pp], 22, *pc); pp++; pc++;
+ }
+
+ /* Round 2 */
+ for (i = 0; i < 4; i++) {
+ GG(a, b, c, d, x[*pp], 5, *pc); pp++; pc++;
+ GG(d, a, b, c, x[*pp], 9, *pc); pp++; pc++;
+ GG(c, d, a, b, x[*pp], 14, *pc); pp++; pc++;
+ GG(b, c, d, a, x[*pp], 20, *pc); pp++; pc++;
+ }
+ /* Round 3 */
+ for (i = 0; i < 4; i++) {
+ HH(a, b, c, d, x[*pp], 4, *pc); pp++; pc++;
+ HH(d, a, b, c, x[*pp], 11, *pc); pp++; pc++;
+ HH(c, d, a, b, x[*pp], 16, *pc); pp++; pc++;
+ HH(b, c, d, a, x[*pp], 23, *pc); pp++; pc++;
+ }
+
+ /* Round 4 */
+ for (i = 0; i < 4; i++) {
+ II(a, b, c, d, x[*pp], 6, *pc); pp++; pc++;
+ II(d, a, b, c, x[*pp], 10, *pc); pp++; pc++;
+ II(c, d, a, b, x[*pp], 15, *pc); pp++; pc++;
+ II(b, c, d, a, x[*pp], 21, *pc); pp++; pc++;
+ }
+#else
+ /* Round 1 */
+#define S11 7
+#define S12 12
+#define S13 17
+#define S14 22
+ FF(a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */
+ FF(d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */
+ FF(c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */
+ FF(b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */
+ FF(a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */
+ FF(d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */
+ FF(c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */
+ FF(b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */
+ FF(a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */
+ FF(d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */
+ FF(c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
+ FF(b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
+ FF(a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
+ FF(d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
+ FF(c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
+ FF(b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
+
+ /* Round 2 */
+#define S21 5
+#define S22 9
+#define S23 14
+#define S24 20
+ GG(a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */
+ GG(d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */
+ GG(c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
+ GG(b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */
+ GG(a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */
+ GG(d, a, b, c, x[10], S22, 0x2441453); /* 22 */
+ GG(c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
+ GG(b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */
+ GG(a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */
+ GG(d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
+ GG(c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */
+ GG(b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */
+ GG(a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
+ GG(d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */
+ GG(c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */
+ GG(b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
+
+ /* Round 3 */
+#define S31 4
+#define S32 11
+#define S33 16
+#define S34 23
+ HH(a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */
+ HH(d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */
+ HH(c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
+ HH(b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
+ HH(a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */
+ HH(d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */
+ HH(c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */
+ HH(b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
+ HH(a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
+ HH(d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */
+ HH(c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */
+ HH(b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */
+ HH(a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */
+ HH(d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
+ HH(c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
+ HH(b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */
+
+ /* Round 4 */
+#define S41 6
+#define S42 10
+#define S43 15
+#define S44 21
+ II(a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */
+ II(d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */
+ II(c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
+ II(b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */
+ II(a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
+ II(d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */
+ II(c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
+ II(b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */
+ II(a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */
+ II(d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
+ II(c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */
+ II(b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
+ II(a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */
+ II(d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
+ II(c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */
+ II(b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */
+#endif
+
+ state[0] += a;
+ state[1] += b;
+ state[2] += c;
+ state[3] += d;
+
+ /* Zeroize sensitive information. */
+ memset(x, 0, sizeof(x));
+}
+
+
+static char*
+__md5_to64(char *s, unsigned v, int n)
+{
+ while (--n >= 0) {
+ *s++ = ascii64[v & 0x3f];
+ v >>= 6;
+ }
+ return s;
+}
+
+/*
+ * UNIX password
+ *
+ * Use MD5 for what it is best at...
+ */
+#define MD5_OUT_BUFSIZE 36
+static char *
+md5_crypt(char passwd[MD5_OUT_BUFSIZE], const unsigned char *pw, const unsigned char *salt)
+{
+ const unsigned char *sp, *ep;
+ char *p;
+ unsigned char final[17]; /* final[16] exists only to aid in looping */
+ int sl, pl, i, pw_len;
+ struct MD5Context ctx, ctx1;
+
+ /* Refine the Salt first */
+ sp = salt;
+
+ sp += MD5_MAGIC_LEN;
+
+ /* It stops at the first '$', max 8 chars */
+ for (ep = sp; *ep && *ep != '$' && ep < (sp+8); ep++)
+ continue;
+
+ /* get the length of the true salt */
+ sl = ep - sp;
+
+ __md5_Init(&ctx);
+
+ /* The password first, since that is what is most unknown */
+ pw_len = strlen((char*)pw);
+ __md5_Update(&ctx, pw, pw_len);
+
+ /* Then our magic string */
+ __md5_Update(&ctx, __md5__magic, MD5_MAGIC_LEN);
+
+ /* Then the raw salt */
+ __md5_Update(&ctx, sp, sl);
+
+ /* Then just as many characters of the MD5(pw, salt, pw) */
+ __md5_Init(&ctx1);
+ __md5_Update(&ctx1, pw, pw_len);
+ __md5_Update(&ctx1, sp, sl);
+ __md5_Update(&ctx1, pw, pw_len);
+ __md5_Final(final, &ctx1);
+ for (pl = pw_len; pl > 0; pl -= 16)
+ __md5_Update(&ctx, final, pl > 16 ? 16 : pl);
+
+ /* Don't leave anything around in vm they could use. */
+//TODO: the above comment seems to be wrong. final is used later.
+ memset(final, 0, sizeof(final));
+
+ /* Then something really weird... */
+ for (i = pw_len; i; i >>= 1) {
+ __md5_Update(&ctx, ((i & 1) ? final : (const unsigned char *) pw), 1);
+ }
+
+ /* Now make the output string */
+ passwd[0] = '$';
+ passwd[1] = '1';
+ passwd[2] = '$';
+ strncpy(passwd + 3, (char*)sp, sl);
+ passwd[sl + 3] = '$';
+
+ __md5_Final(final, &ctx);
+
+ /*
+ * and now, just to make sure things don't run too fast
+ * On a 60 Mhz Pentium this takes 34 msec, so you would
+ * need 30 seconds to build a 1000 entry dictionary...
+ */
+ for (i = 0; i < 1000; i++) {
+ __md5_Init(&ctx1);
+ if (i & 1)
+ __md5_Update(&ctx1, pw, pw_len);
+ else
+ __md5_Update(&ctx1, final, 16);
+
+ if (i % 3)
+ __md5_Update(&ctx1, sp, sl);
+
+ if (i % 7)
+ __md5_Update(&ctx1, pw, pw_len);
+
+ if (i & 1)
+ __md5_Update(&ctx1, final, 16);
+ else
+ __md5_Update(&ctx1, pw, pw_len);
+ __md5_Final(final, &ctx1);
+ }
+
+ p = passwd + sl + 4; /* 12 bytes max (sl is up to 8 bytes) */
+
+ /* Add 5*4+2 = 22 bytes of hash, + NUL byte. */
+ final[16] = final[5];
+ for (i = 0; i < 5; i++) {
+ unsigned l = (final[i] << 16) | (final[i+6] << 8) | final[i+12];
+ p = __md5_to64(p, l, 4);
+ }
+ p = __md5_to64(p, final[11], 2);
+ *p = '\0';
+
+ /* Don't leave anything around in vm they could use. */
+ memset(final, 0, sizeof(final));
+
+ return passwd;
+}
+
+#undef MD5_SIZE_OVER_SPEED
+#undef MD5_MAGIC_STR
+#undef MD5_MAGIC_LEN
+#undef __md5_Encode
+#undef __md5_Decode
+#undef F
+#undef G
+#undef H
+#undef I
+#undef ROTATE_LEFT
+#undef FF
+#undef GG
+#undef HH
+#undef II
+#undef S11
+#undef S12
+#undef S13
+#undef S14
+#undef S21
+#undef S22
+#undef S23
+#undef S24
+#undef S31
+#undef S32
+#undef S33
+#undef S34
+#undef S41
+#undef S42
+#undef S43
+#undef S44
diff --git a/package/network/services/ead/src/sha1.c b/package/network/services/ead/src/sha1.c
new file mode 100644
index 0000000..3683a7d
--- /dev/null
+++ b/package/network/services/ead/src/sha1.c
@@ -0,0 +1,104 @@
+/*
+ * SHA transform algorithm, originally taken from code written by
+ * Peter Gutmann, and placed in the public domain.
+ */
+
+static uint32_t
+rol32(uint32_t word, int shift)
+{
+ return (word << shift) | (word >> (32 - shift));
+}
+
+/* The SHA f()-functions. */
+
+#define f1(x,y,z) (z ^ (x & (y ^ z))) /* x ? y : z */
+#define f2(x,y,z) (x ^ y ^ z) /* XOR */
+#define f3(x,y,z) ((x & y) + (z & (x ^ y))) /* majority */
+
+/* The SHA Mysterious Constants */
+
+#define K1 0x5A827999L /* Rounds 0-19: sqrt(2) * 2^30 */
+#define K2 0x6ED9EBA1L /* Rounds 20-39: sqrt(3) * 2^30 */
+#define K3 0x8F1BBCDCL /* Rounds 40-59: sqrt(5) * 2^30 */
+#define K4 0xCA62C1D6L /* Rounds 60-79: sqrt(10) * 2^30 */
+
+/**
+ * sha_transform - single block SHA1 transform
+ *
+ * @digest: 160 bit digest to update
+ * @data: 512 bits of data to hash
+ * @W: 80 words of workspace (see note)
+ *
+ * This function generates a SHA1 digest for a single 512-bit block.
+ * Be warned, it does not handle padding and message digest, do not
+ * confuse it with the full FIPS 180-1 digest algorithm for variable
+ * length messages.
+ *
+ * Note: If the hash is security sensitive, the caller should be sure
+ * to clear the workspace. This is left to the caller to avoid
+ * unnecessary clears between chained hashing operations.
+ */
+static void sha_transform(uint32_t *digest, const unsigned char *in, uint32_t *W)
+{
+ uint32_t a, b, c, d, e, t, i;
+
+ for (i = 0; i < 16; i++) {
+ int ofs = 4 * i;
+
+ /* word load/store may be unaligned here, so use bytes instead */
+ W[i] =
+ (in[ofs+0] << 24) |
+ (in[ofs+1] << 16) |
+ (in[ofs+2] << 8) |
+ in[ofs+3];
+ }
+
+ for (i = 0; i < 64; i++)
+ W[i+16] = rol32(W[i+13] ^ W[i+8] ^ W[i+2] ^ W[i], 1);
+
+ a = digest[0];
+ b = digest[1];
+ c = digest[2];
+ d = digest[3];
+ e = digest[4];
+
+ for (i = 0; i < 20; i++) {
+ t = f1(b, c, d) + K1 + rol32(a, 5) + e + W[i];
+ e = d; d = c; c = rol32(b, 30); b = a; a = t;
+ }
+
+ for (; i < 40; i ++) {
+ t = f2(b, c, d) + K2 + rol32(a, 5) + e + W[i];
+ e = d; d = c; c = rol32(b, 30); b = a; a = t;
+ }
+
+ for (; i < 60; i ++) {
+ t = f3(b, c, d) + K3 + rol32(a, 5) + e + W[i];
+ e = d; d = c; c = rol32(b, 30); b = a; a = t;
+ }
+
+ for (; i < 80; i ++) {
+ t = f2(b, c, d) + K4 + rol32(a, 5) + e + W[i];
+ e = d; d = c; c = rol32(b, 30); b = a; a = t;
+ }
+
+ digest[0] += a;
+ digest[1] += b;
+ digest[2] += c;
+ digest[3] += d;
+ digest[4] += e;
+}
+
+/**
+ * sha_init - initialize the vectors for a SHA1 digest
+ * @buf: vector to initialize
+ */
+static void sha_init(uint32_t *buf)
+{
+ buf[0] = 0x67452301;
+ buf[1] = 0xefcdab89;
+ buf[2] = 0x98badcfe;
+ buf[3] = 0x10325476;
+ buf[4] = 0xc3d2e1f0;
+}
+
diff --git a/package/network/services/ead/src/tinysrp/.svn/entries b/package/network/services/ead/src/tinysrp/.svn/entries
new file mode 100644
index 0000000..9ede030
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/.svn/entries
@@ -0,0 +1,1762 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/services/ead/src/tinysrp
+svn://svn.openwrt.org/openwrt
+
+
+
+2010-12-13T01:47:35.463502Z
+24535
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+t_sha.c
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+7697cacd6e3f973ca092939e94fac4ae
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5865
+
+t_server.h
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+37da3436d7e050e4c1e14b10b4c017de
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4970
+
+bn_lcl.h
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+6cb3b6a5298ef8889e31af625c39a4be
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+14322
+
+bn_asm.c
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+eb4225c3b590a486a1b466667d23a716
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+8669
+
+configure
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+44e6f053a2697d008677bac4d9828fca
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+73046
+
+bn_div.c
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+ec48a7824e8013338d3105ed345cac83
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+9734
+
+Makefile.in
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+af3f0fe41149471c83ea7acab4bf6f6a
+2009-01-06T22:20:09.747978Z
+13906
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+13819
+
+t_sha.h
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+b653410e1a4a44f4eeccac6117dd1870
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+497
+
+tpasswd
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+9c469c51cbcf7a5ed597ba05406d2691
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+562
+
+t_defines.h
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+667c2ec77b73c74f98385c97d88bdc4a
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5712
+
+bn_add.c
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+46996910a855871e4c2d70ebd1715188
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+6741
+
+Notes
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+8473d316f0debf99c93bd323e9f24845
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5454
+
+t_pw.c
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+56878a7d4db9963bdbaf154b28f44b77
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+6706
+
+tconf.c
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+d6a7fecf546e41517d7d4349406e39aa
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5353
+
+srvtest.c
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+c13df0235ed58b3686bf5df2cb65d5e9
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3730
+
+bn_mul.c
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+b521774a9e244fba98d75a2295d595ba
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5149
+
+t_misc.c
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+b9069ff88a0fe92c089bb6abd3edbe47
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+9608
+
+bn_sqr.c
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+4efb0ec4ce9304ef7efd90f1a43e487e
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4774
+
+bn_word.c
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+27dd8d59afef9a132ae30cfcbc78ca6a
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4099
+
+stamp-h.in
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+1ded054093de910d9786c62bc4fe8cc6
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+10
+
+t_read.c
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+bd888d26e6b4ccae2320afafe2a14705
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2502
+
+mkinstalldirs
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+a1bac214cbbad6bcfc0edcf662d3a1d2
+2009-04-17T14:09:46.037367Z
+15242
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+669
+
+bn_prime.h
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+0978e3f6f869258a686b534893bb9aaa
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+14931
+
+t_client.c
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+29f8fa08670d15a7160b101c19700ee8
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+7673
+
+t_read.h
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+4fcdc2055311401a8c408ddaec9187c7
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2224
+
+bn.h
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+aee613cb3eba0d83c0e7897061fed504
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+17324
+
+configure.in
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+c83c8e0a6f82ac2d59d62c3165654af5
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1046
+
+tphrase.c
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+6a78c60368c490702fabbc8f8d5176a8
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+7571
+
+t_client.h
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+32916b10fae7b470c7a8d3186cc7ce5b
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5190
+
+clitest.c
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+f03fd8417d9f4eceb571a5a5725b8da0
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3762
+
+t_truerand.c
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+f9f218b0b308eb44233aab2e643e4a78
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3961
+
+tinysrp.c
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+164d5e52083865d898186f33b5a90e67
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4695
+
+t_getconf.c
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+3f694ec4f359a84717aa117dc14c2ce5
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4800
+
+t_conf.c
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+8159279265e229a8e41ea25252732b03
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+24343
+
+bn_exp.c
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+7905a80fbe356f97c90abe9570784860
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+11663
+
+t_math.c
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+4972f308d17c7d8851dd0eb3f6877772
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4080
+
+tinysrp.h
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+f43c97289b2f1cb523c3e60a6b314367
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+575
+
+bn_ctx.c
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+9489370b38208c8fbc579269fb82d993
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4247
+
+acconfig.h
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+21b368ba16eb30b4cdfe138df09dd2b7
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+97
+
+config.h.in
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+7beba7714ae9b9dd77bb745ff6fa0be3
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1850
+
+t_pwd.h
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+158e1c0a0dac217cc0f1ddc6c4fd331a
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+10983
+
+acinclude.m4
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+25b025b45036a7b12081c4ee725b9ac1
+2010-12-13T01:47:35.463502Z
+24535
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+732
+
+bn_lib.c
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+f5596bd364191d412ba394256453203f
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+13938
+
+missing
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+d451f0f86247409a65286022cb5eb2b7
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4650
+
+Makefile.am
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+5d91adfc307bc1906e9107e2364ef306
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+716
+
+t_conv.c
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+0bb2ede92b4875a1cf8dcdff1362a120
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5471
+
+t_getpass.c
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+75283ad78efb3c6ce70e7b6205d40b19
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4721
+
+t_server.c
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+6dfce700a7b5adf2e8dfb4d9fe2f6989
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+7216
+
+aclocal.m4
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+6d9327c8a41e9569490a7a5deb8c9565
+2010-12-13T01:47:35.463502Z
+24535
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5222
+
+bn_shift.c
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+15afc09485e8d44740cc1411f01d0910
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4442
+
+install-sh
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+9a98c7b799ad906d61a88d52b5790b1c
+2008-12-24T10:42:12.526048Z
+13738
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5584
+
diff --git a/package/network/services/ead/src/tinysrp/.svn/prop-base/configure.svn-base b/package/network/services/ead/src/tinysrp/.svn/prop-base/configure.svn-base
new file mode 100644
index 0000000..869ac71
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/.svn/prop-base/configure.svn-base
@@ -0,0 +1,5 @@
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/network/services/ead/src/tinysrp/.svn/prop-base/install-sh.svn-base b/package/network/services/ead/src/tinysrp/.svn/prop-base/install-sh.svn-base
new file mode 100644
index 0000000..869ac71
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/.svn/prop-base/install-sh.svn-base
@@ -0,0 +1,5 @@
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/network/services/ead/src/tinysrp/.svn/prop-base/missing.svn-base b/package/network/services/ead/src/tinysrp/.svn/prop-base/missing.svn-base
new file mode 100644
index 0000000..869ac71
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/.svn/prop-base/missing.svn-base
@@ -0,0 +1,5 @@
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/network/services/ead/src/tinysrp/.svn/prop-base/mkinstalldirs.svn-base b/package/network/services/ead/src/tinysrp/.svn/prop-base/mkinstalldirs.svn-base
new file mode 100644
index 0000000..869ac71
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/.svn/prop-base/mkinstalldirs.svn-base
@@ -0,0 +1,5 @@
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/network/services/ead/src/tinysrp/.svn/text-base/Makefile.am.svn-base b/package/network/services/ead/src/tinysrp/.svn/text-base/Makefile.am.svn-base
new file mode 100644
index 0000000..a8f899f
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/.svn/text-base/Makefile.am.svn-base
@@ -0,0 +1,28 @@
+AUTOMAKE_OPTIONS = foreign no-dependencies
+
+noinst_HEADERS = t_client.h t_pwd.h t_server.h t_sha.h \
+ bn.h bn_lcl.h bn_prime.h t_defines.h t_read.h
+
+include_HEADERS = tinysrp.h
+
+lib_LIBRARIES = libtinysrp.a
+
+CFLAGS = -O2 @signed@
+
+libtinysrp_a_SOURCES = \
+ tinysrp.c t_client.c t_getconf.c t_conv.c t_getpass.c t_sha.c t_math.c \
+ t_misc.c t_pw.c t_read.c t_server.c t_truerand.c \
+ bn_add.c bn_ctx.c bn_div.c bn_exp.c bn_mul.c bn_word.c bn_asm.c bn_lib.c \
+ bn_shift.c bn_sqr.c
+
+noinst_PROGRAMS = srvtest clitest
+srvtest_SOURCES = srvtest.c
+clitest_SOURCES = clitest.c
+
+bin_PROGRAMS = tconf tphrase
+tconf_SOURCES = tconf.c t_conf.c
+tphrase_SOURCES = tphrase.c
+
+LDADD = libtinysrp.a
+
+EXTRA_DIST = tpasswd Notes
diff --git a/package/network/services/ead/src/tinysrp/.svn/text-base/Makefile.in.svn-base b/package/network/services/ead/src/tinysrp/.svn/text-base/Makefile.in.svn-base
new file mode 100644
index 0000000..4701cd5
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/.svn/text-base/Makefile.in.svn-base
@@ -0,0 +1,477 @@
+# Makefile.in generated automatically by automake 1.4a from Makefile.am
+
+# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+
+SHELL = @SHELL@
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+
+bindir = @bindir@
+sbindir = @sbindir@
+libexecdir = @libexecdir@
+datadir = @datadir@
+sysconfdir = @sysconfdir@
+sharedstatedir = @sharedstatedir@
+localstatedir = @localstatedir@
+libdir = @libdir@
+infodir = @infodir@
+mandir = @mandir@
+includedir = @includedir@
+oldincludedir = /usr/include
+
+DESTDIR =
+
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+
+top_builddir = .
+
+ACLOCAL = @ACLOCAL@
+AUTOCONF = @AUTOCONF@
+AUTOMAKE = @AUTOMAKE@
+AUTOHEADER = @AUTOHEADER@
+
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_FLAG =
+transform = @program_transform_name@
+
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+CC = @CC@
+LN_S = @LN_S@
+MAKEINFO = @MAKEINFO@
+PACKAGE = @PACKAGE@
+RANLIB = @RANLIB@
+VERSION = @VERSION@
+signed = @signed@
+
+AUTOMAKE_OPTIONS = foreign no-dependencies
+
+noinst_HEADERS = t_client.h t_pwd.h t_server.h t_sha.h bn.h bn_lcl.h bn_prime.h t_defines.h t_read.h
+
+
+include_HEADERS = tinysrp.h
+
+lib_LIBRARIES = libtinysrp.a
+
+CFLAGS = -O2 @signed@
+
+libtinysrp_a_SOURCES = tinysrp.c t_client.c t_getconf.c t_conv.c t_getpass.c t_sha.c t_math.c t_misc.c t_pw.c t_read.c t_server.c t_truerand.c bn_add.c bn_ctx.c bn_div.c bn_exp.c bn_mul.c bn_word.c bn_asm.c bn_lib.c bn_shift.c bn_sqr.c
+
+
+noinst_PROGRAMS = srvtest clitest
+srvtest_SOURCES = srvtest.c
+clitest_SOURCES = clitest.c
+
+bin_PROGRAMS = tconf tphrase
+tconf_SOURCES = tconf.c t_conf.c
+tphrase_SOURCES = tphrase.c
+
+LDADD = libtinysrp.a
+
+EXTRA_DIST = tpasswd Notes
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = config.h
+CONFIG_CLEAN_FILES =
+LIBRARIES = $(lib_LIBRARIES)
+
+
+DEFS = @DEFS@ -I. -I$(srcdir) -I.
+CPPFLAGS = @CPPFLAGS@
+LDFLAGS = @LDFLAGS@
+LIBS = @LIBS@
+libtinysrp_a_LIBADD =
+libtinysrp_a_OBJECTS = tinysrp.o t_client.o t_getconf.o t_conv.o \
+t_getpass.o t_sha.o t_math.o t_misc.o t_pw.o t_read.o t_server.o \
+t_truerand.o bn_add.o bn_ctx.o bn_div.o bn_exp.o bn_mul.o bn_word.o \
+bn_asm.o bn_lib.o bn_shift.o bn_sqr.o
+AR = ar
+PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS)
+
+tconf_OBJECTS = tconf.o t_conf.o
+tconf_LDADD = $(LDADD)
+tconf_DEPENDENCIES = libtinysrp.a
+tconf_LDFLAGS =
+tphrase_OBJECTS = tphrase.o
+tphrase_LDADD = $(LDADD)
+tphrase_DEPENDENCIES = libtinysrp.a
+tphrase_LDFLAGS =
+srvtest_OBJECTS = srvtest.o
+srvtest_LDADD = $(LDADD)
+srvtest_DEPENDENCIES = libtinysrp.a
+srvtest_LDFLAGS =
+clitest_OBJECTS = clitest.o
+clitest_LDADD = $(LDADD)
+clitest_DEPENDENCIES = libtinysrp.a
+clitest_LDFLAGS =
+COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
+HEADERS = $(include_HEADERS) $(noinst_HEADERS)
+
+DIST_COMMON = ./stamp-h.in Makefile.am Makefile.in acconfig.h \
+acinclude.m4 aclocal.m4 config.h.in configure configure.in install-sh \
+missing mkinstalldirs
+
+
+DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
+
+TAR = gtar
+GZIP_ENV = --best
+SOURCES = $(libtinysrp_a_SOURCES) $(tconf_SOURCES) $(tphrase_SOURCES) $(srvtest_SOURCES) $(clitest_SOURCES)
+OBJECTS = $(libtinysrp_a_OBJECTS) $(tconf_OBJECTS) $(tphrase_OBJECTS) $(srvtest_OBJECTS) $(clitest_OBJECTS)
+
+all: all-redirect
+.SUFFIXES:
+.SUFFIXES: .S .c .o .s
+
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ cd $(top_builddir) \
+ && CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status
+
+$(ACLOCAL_M4): configure.in acinclude.m4
+ cd $(srcdir) && $(ACLOCAL)
+
+$(srcdir)/configure: $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES)
+ cd $(srcdir) && $(AUTOCONF)
+
+config.h: stamp-h
+ @if test ! -f $@; then \
+ rm -f stamp-h; \
+ $(MAKE) stamp-h; \
+ else :; fi
+stamp-h: $(srcdir)/config.h.in $(top_builddir)/config.status
+ cd $(top_builddir) \
+ && CONFIG_FILES= CONFIG_HEADERS=config.h \
+ $(SHELL) ./config.status
+ @echo timestamp > stamp-h 2> /dev/null
+$(srcdir)/config.h.in: $(srcdir)/stamp-h.in
+ @if test ! -f $@; then \
+ rm -f $(srcdir)/stamp-h.in; \
+ $(MAKE) $(srcdir)/stamp-h.in; \
+ else :; fi
+$(srcdir)/stamp-h.in: $(top_srcdir)/configure.in $(ACLOCAL_M4) acconfig.h
+ cd $(top_srcdir) && $(AUTOHEADER)
+ @echo timestamp > $(srcdir)/stamp-h.in 2> /dev/null
+
+mostlyclean-hdr:
+
+clean-hdr:
+
+distclean-hdr:
+ -rm -f config.h
+
+maintainer-clean-hdr:
+
+mostlyclean-libLIBRARIES:
+
+clean-libLIBRARIES:
+ -test -z "$(lib_LIBRARIES)" || rm -f $(lib_LIBRARIES)
+
+distclean-libLIBRARIES:
+
+maintainer-clean-libLIBRARIES:
+
+install-libLIBRARIES: $(lib_LIBRARIES)
+ @$(NORMAL_INSTALL)
+ $(mkinstalldirs) $(DESTDIR)$(libdir)
+ @list='$(lib_LIBRARIES)'; for p in $$list; do \
+ if test -f $$p; then \
+ echo " $(INSTALL_DATA) $$p $(DESTDIR)$(libdir)/$$p"; \
+ $(INSTALL_DATA) $$p $(DESTDIR)$(libdir)/$$p; \
+ else :; fi; \
+ done
+ @$(POST_INSTALL)
+ @list='$(lib_LIBRARIES)'; for p in $$list; do \
+ if test -f $$p; then \
+ echo " $(RANLIB) $(DESTDIR)$(libdir)/$$p"; \
+ $(RANLIB) $(DESTDIR)$(libdir)/$$p; \
+ else :; fi; \
+ done
+
+uninstall-libLIBRARIES:
+ @$(NORMAL_UNINSTALL)
+ list='$(lib_LIBRARIES)'; for p in $$list; do \
+ rm -f $(DESTDIR)$(libdir)/$$p; \
+ done
+
+.c.o:
+ $(COMPILE) -c $<
+
+.s.o:
+ $(COMPILE) -c $<
+
+.S.o:
+ $(COMPILE) -c $<
+
+mostlyclean-compile:
+ -rm -f *.o core *.core
+
+clean-compile:
+
+distclean-compile:
+ -rm -f *.tab.c
+
+maintainer-clean-compile:
+
+libtinysrp.a: $(libtinysrp_a_OBJECTS) $(libtinysrp_a_DEPENDENCIES)
+ -rm -f libtinysrp.a
+ $(AR) cru libtinysrp.a $(libtinysrp_a_OBJECTS) $(libtinysrp_a_LIBADD)
+ $(RANLIB) libtinysrp.a
+
+mostlyclean-binPROGRAMS:
+
+clean-binPROGRAMS:
+ -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
+
+distclean-binPROGRAMS:
+
+maintainer-clean-binPROGRAMS:
+
+install-binPROGRAMS: $(bin_PROGRAMS)
+ @$(NORMAL_INSTALL)
+ $(mkinstalldirs) $(DESTDIR)$(bindir)
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ if test -f $$p; then \
+ echo " $(INSTALL_PROGRAM) $(INSTALL_STRIP_FLAG) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \
+ $(INSTALL_PROGRAM) $(INSTALL_STRIP_FLAG) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
+ else :; fi; \
+ done
+
+uninstall-binPROGRAMS:
+ @$(NORMAL_UNINSTALL)
+ list='$(bin_PROGRAMS)'; for p in $$list; do \
+ rm -f $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
+ done
+
+mostlyclean-noinstPROGRAMS:
+
+clean-noinstPROGRAMS:
+ -test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS)
+
+distclean-noinstPROGRAMS:
+
+maintainer-clean-noinstPROGRAMS:
+
+tconf: $(tconf_OBJECTS) $(tconf_DEPENDENCIES)
+ @rm -f tconf
+ $(LINK) $(tconf_LDFLAGS) $(tconf_OBJECTS) $(tconf_LDADD) $(LIBS)
+
+tphrase: $(tphrase_OBJECTS) $(tphrase_DEPENDENCIES)
+ @rm -f tphrase
+ $(LINK) $(tphrase_LDFLAGS) $(tphrase_OBJECTS) $(tphrase_LDADD) $(LIBS)
+
+srvtest: $(srvtest_OBJECTS) $(srvtest_DEPENDENCIES)
+ @rm -f srvtest
+ $(LINK) $(srvtest_LDFLAGS) $(srvtest_OBJECTS) $(srvtest_LDADD) $(LIBS)
+
+clitest: $(clitest_OBJECTS) $(clitest_DEPENDENCIES)
+ @rm -f clitest
+ $(LINK) $(clitest_LDFLAGS) $(clitest_OBJECTS) $(clitest_LDADD) $(LIBS)
+
+install-includeHEADERS: $(include_HEADERS)
+ @$(NORMAL_INSTALL)
+ $(mkinstalldirs) $(DESTDIR)$(includedir)
+ @list='$(include_HEADERS)'; for p in $$list; do \
+ if test -f "$$p"; then d= ; else d="$(srcdir)/"; fi; \
+ echo " $(INSTALL_DATA) $$d$$p $(DESTDIR)$(includedir)/$$p"; \
+ $(INSTALL_DATA) $$d$$p $(DESTDIR)$(includedir)/$$p; \
+ done
+
+uninstall-includeHEADERS:
+ @$(NORMAL_UNINSTALL)
+ list='$(include_HEADERS)'; for p in $$list; do \
+ rm -f $(DESTDIR)$(includedir)/$$p; \
+ done
+
+tags: TAGS
+
+ID: $(HEADERS) $(SOURCES) $(LISP)
+ list='$(SOURCES) $(HEADERS)'; \
+ unique=`for i in $$list; do echo $$i; done | \
+ awk ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ here=`pwd` && cd $(srcdir) \
+ && mkid -f$$here/ID $$unique $(LISP)
+
+TAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS)'; \
+ unique=`for i in $$list; do echo $$i; done | \
+ awk ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ test -z "$(ETAGS_ARGS)config.h.in$$unique$(LISP)$$tags" \
+ || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags config.h.in $$unique $(LISP) -o $$here/TAGS)
+
+mostlyclean-tags:
+
+clean-tags:
+
+distclean-tags:
+ -rm -f TAGS ID
+
+maintainer-clean-tags:
+
+distdir = $(PACKAGE)-$(VERSION)
+top_distdir = $(distdir)
+
+# This target untars the dist file and tries a VPATH configuration. Then
+# it guarantees that the distribution is self-contained by making another
+# tarfile.
+distcheck: dist
+ -rm -rf $(distdir)
+ GZIP=$(GZIP_ENV) $(TAR) zxf $(distdir).tar.gz
+ mkdir $(distdir)/=build
+ mkdir $(distdir)/=inst
+ dc_install_base=`cd $(distdir)/=inst && pwd`; \
+ cd $(distdir)/=build \
+ && ../configure --srcdir=.. --prefix=$$dc_install_base \
+ && $(MAKE) $(AM_MAKEFLAGS) \
+ && $(MAKE) $(AM_MAKEFLAGS) dvi \
+ && $(MAKE) $(AM_MAKEFLAGS) check \
+ && $(MAKE) $(AM_MAKEFLAGS) install \
+ && $(MAKE) $(AM_MAKEFLAGS) installcheck \
+ && $(MAKE) $(AM_MAKEFLAGS) dist
+ -rm -rf $(distdir)
+ @banner="$(distdir).tar.gz is ready for distribution"; \
+ dashes=`echo "$$banner" | sed s/./=/g`; \
+ echo "$$dashes"; \
+ echo "$$banner"; \
+ echo "$$dashes"
+dist: distdir
+ -chmod -R a+r $(distdir)
+ GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir)
+ -rm -rf $(distdir)
+dist-all: distdir
+ -chmod -R a+r $(distdir)
+ GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir)
+ -rm -rf $(distdir)
+distdir: $(DISTFILES)
+ -rm -rf $(distdir)
+ mkdir $(distdir)
+ -chmod 777 $(distdir)
+ @for file in $(DISTFILES); do \
+ d=$(srcdir); \
+ if test -d $$d/$$file; then \
+ cp -pr $$d/$$file $(distdir)/$$file; \
+ else \
+ test -f $(distdir)/$$file \
+ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
+ || cp -p $$d/$$file $(distdir)/$$file || :; \
+ fi; \
+ done
+info-am:
+info: info-am
+dvi-am:
+dvi: dvi-am
+check-am: all-am
+check: check-am
+installcheck-am:
+installcheck: installcheck-am
+all-recursive-am: config.h
+ $(MAKE) $(AM_MAKEFLAGS) all-recursive
+
+install-exec-am: install-libLIBRARIES install-binPROGRAMS
+install-exec: install-exec-am
+
+install-data-am: install-includeHEADERS
+install-data: install-data-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+install: install-am
+uninstall-am: uninstall-libLIBRARIES uninstall-binPROGRAMS \
+ uninstall-includeHEADERS
+uninstall: uninstall-am
+all-am: Makefile $(LIBRARIES) $(PROGRAMS) $(HEADERS) config.h
+all-redirect: all-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install
+installdirs:
+ $(mkinstalldirs) $(DESTDIR)$(libdir) $(DESTDIR)$(bindir) \
+ $(DESTDIR)$(includedir)
+
+
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -rm -f Makefile $(CONFIG_CLEAN_FILES)
+ -rm -f config.cache config.log stamp-h stamp-h[0-9]*
+
+maintainer-clean-generic:
+mostlyclean-am: mostlyclean-hdr mostlyclean-libLIBRARIES \
+ mostlyclean-compile mostlyclean-binPROGRAMS \
+ mostlyclean-noinstPROGRAMS mostlyclean-tags \
+ mostlyclean-generic
+
+mostlyclean: mostlyclean-am
+
+clean-am: clean-hdr clean-libLIBRARIES clean-compile clean-binPROGRAMS \
+ clean-noinstPROGRAMS clean-tags clean-generic \
+ mostlyclean-am
+
+clean: clean-am
+
+distclean-am: distclean-hdr distclean-libLIBRARIES distclean-compile \
+ distclean-binPROGRAMS distclean-noinstPROGRAMS \
+ distclean-tags distclean-generic clean-am
+
+distclean: distclean-am
+ -rm -f config.status
+
+maintainer-clean-am: maintainer-clean-hdr maintainer-clean-libLIBRARIES \
+ maintainer-clean-compile maintainer-clean-binPROGRAMS \
+ maintainer-clean-noinstPROGRAMS maintainer-clean-tags \
+ maintainer-clean-generic distclean-am
+ @echo "This command is intended for maintainers to use;"
+ @echo "it deletes files that may require special tools to rebuild."
+
+maintainer-clean: maintainer-clean-am
+ -rm -f config.status
+
+.PHONY: mostlyclean-hdr distclean-hdr clean-hdr maintainer-clean-hdr \
+mostlyclean-libLIBRARIES distclean-libLIBRARIES clean-libLIBRARIES \
+maintainer-clean-libLIBRARIES uninstall-libLIBRARIES \
+install-libLIBRARIES mostlyclean-compile distclean-compile \
+clean-compile maintainer-clean-compile mostlyclean-binPROGRAMS \
+distclean-binPROGRAMS clean-binPROGRAMS maintainer-clean-binPROGRAMS \
+uninstall-binPROGRAMS install-binPROGRAMS mostlyclean-noinstPROGRAMS \
+distclean-noinstPROGRAMS clean-noinstPROGRAMS \
+maintainer-clean-noinstPROGRAMS uninstall-includeHEADERS \
+install-includeHEADERS tags mostlyclean-tags distclean-tags clean-tags \
+maintainer-clean-tags distdir info-am info dvi-am dvi check check-am \
+installcheck-am installcheck all-recursive-am install-exec-am \
+install-exec install-data-am install-data install-am install \
+uninstall-am uninstall all-redirect all-am all installdirs \
+mostlyclean-generic distclean-generic clean-generic \
+maintainer-clean-generic clean mostlyclean distclean maintainer-clean
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/package/network/services/ead/src/tinysrp/.svn/text-base/Notes.svn-base b/package/network/services/ead/src/tinysrp/.svn/text-base/Notes.svn-base
new file mode 100644
index 0000000..a8620aa
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/.svn/text-base/Notes.svn-base
@@ -0,0 +1,110 @@
+t_* stuff is from the srp 1.7.1 dist
+bn_* stuff is from openssl 0.9.6
+
+(The 7 in libtinysrp's version number reflects the srp version.)
+
+Licensing and copyright for srp and openssl are as indicated in the relevant
+source files. Everything else here is GPL, including the tinysrp protocol.
+
+Changelog since initial release:
+
+0.7.4 more robust terminal modes in t_getpass
+ a potential buffer overflow in tinysrp
+0.7.5 uninitialized pointer bug in tconf
+
+Changes from the base srp and openssl distributions:
+
+I've removed everything that's not needed for client/server operations, and
+all the bn_* stuff that's only used for prime generation has been moved to
+t_conf.c, which isn't part of the library anymore. Also, all the routines
+used for passphrase file maintenance have been moved to tphrase.c.
+
+The library has been optimized (a bit) for space instead of speed. Since
+authentication is usually only done once, this isn't a big problem. Modern
+CPUs are plenty fast for this task, and even 100 MHz CPUs are fine. If you
+really need the speed, get the regular distributions.
+
+Note that if the server sends the client a prime that the client doesn't
+know about, the client MUST test for primality. Since this is pretty
+expensive, and takes 30 seconds on a 100 MHz machine, and uses lots of code,
+I've removed that ability from the client. So only KNOWN primes can be
+used. You can still generate new ones with tconf, but you have to install
+them in the table of known primes (pre_params) in t_getconf.c that's common
+to the client and server, and recompile. The configuration file is gone.
+
+The default prime (the last entry in the table) is 1024 bits; there are
+others with more bits but they will be correspondingly slower.
+
+The default tpasswd file (which is an ascii file that may be editted with a
+regular text editor) contains two users: moo (passphrase "glub glub") and
+"new user" (passphrase "this is a test"). Passphrases may be added or
+changed with tphrase; you can also change the user's prime. To delete a
+user, edit the tpasswd file and remove that line. The tpasswd file's
+default name is DEFAULT_PASSWD in t_pwd.h. Note that you can't change a
+user's username by editting the file: the username is encoded in the
+verifier. If you change a username you must set a new passphrase with
+tphrase.
+
+Here is an example session, using the supplied srvtest and clitest. First,
+start both programs in different windows, and enter the user names. Normally,
+the client would send the username to the server. Server lines are marked
+with S>, client lines with C>.
+
+S> % srvtest
+S> Enter username: moo
+S> index (to client): 5
+S> salt (to client): 19AI0Hc9jEkdFc
+
+C> % clitest
+C> Enter username: moo
+C> Enter index (from server): 5
+C> Enter salt (from server): 19AI0Hc9jEkdFc
+
+The server reports the index and salt values used for that user. They
+are sent over the network to the client. (Simulate this by cutting and
+pasting from one window to the other.)
+
+C> A (to server): 5wCDXRxLIv/zLazYfKupV/OY3BlhTZuJ71wVgI0HcL1kSJEpkMuWF.xEz/BV2wlJl7vk5Eoz9KMS1ccnaatsVP5D6CBm7UA.yVB59EQFN0dNBirvX29NAFdtdMsMppo5tHRy987XjJWrWSLpeibq6emr.gP8nYyX75GQqSiMY1j
+C> Enter password:
+
+S> Enter A (from client): 5wCDXRxLIv/zLazYfKupV/OY3BlhTZuJ71wVgI0HcL1kSJEpkMuWF.xEz/BV2wlJl7vk5Eoz9KMS1ccnaatsVP5D6CBm7UA.yVB59EQFN0dNBirvX29NAFdtdMsMppo5tHRy987XjJWrWSLpeibq6emr.gP8nYyX75GQqSiMY1j
+
+Now the client calculates A and sends it to the server, and while the
+server is munching on that, the client gets the password from the user.
+
+S> B (to client): 9dcCpulxQAbaDXI0NHWY6B.QH6B9fsoXs/x/5SCNBNJm/6H6bYfbVrwNmdquhLZjYMvpcgGc2mBYqL77RNfw1kVQo17//GfsByECBIjRnrAn02ffX9Y/llJcfscAQiii0hyZhJf9PT5wE7pC7WUjIgSqckIZ0JLNDbSr7fJcrgw
+S> Session key: ebbcf3a45c968defdcfff6e144ad8d4f5412167c9716e79cbf7cacfe18257947ad46fa5d6418a1fd
+
+The server now calculates B and sends it to the client. The session key
+is not sent -- it is a shared secret that can be used for encryption.
+
+C> Enter B (from server): 9dcCpulxQAbaDXI0NHWY6B.QH6B9fsoXs/x/5SCNBNJm/6H6bYfbVrwNmdquhLZjYMvpcgGc2mBYqL77RNfw1kVQo17//GfsByECBIjRnrAn02ffX9Y/llJcfscAQiii0hyZhJf9PT5wE7pC7WUjIgSqckIZ0JLNDbSr7fJcrgw
+C> Session key: ebbcf3a45c968defdcfff6e144ad8d4f5412167c9716e79cbf7cacfe18257947ad46fa5d6418a1fd
+C> Response (to server): b9ea99094a176c4be28eb469982066cc7146d180
+
+The client uses the B value to calculate its own copy of the shared secret
+session key, and sends a response to the server proving that it does know
+the correct key.
+
+S> Enter response (from client): b9ea99094a176c4be28eb469982066cc7146d180
+S> Authentication successful.
+S> Response (to client): cd46c839ccad2d0c76f3ca1905ae8ceda8d1c1dc
+
+The server authenticates the client. (You're in!)
+
+C> Enter server response: cd46c839ccad2d0c76f3ca1905ae8ceda8d1c1dc
+C> Server authentication successful.
+
+The client authenticates the server (prevents server spoofing in the case
+where the session key isn't used to encrypt the channel -- a spoofed server
+might just respond with random values and _pretend_ to authenticate the
+client; but the spoofed server won't know the session key and this check
+catches that).
+
+Final note:
+
+Remember that many breaches of security involve buggy software, such as
+servers susceptible to buffer overflow exploits that totally bypass any
+passphrase, secure or not. If an attacker roots your client, or the server,
+no form of authentication will work. Consider MAC-based schemes if this
+worries you.
diff --git a/package/network/services/ead/src/tinysrp/.svn/text-base/acconfig.h.svn-base b/package/network/services/ead/src/tinysrp/.svn/text-base/acconfig.h.svn-base
new file mode 100644
index 0000000..b74aed0
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/.svn/text-base/acconfig.h.svn-base
@@ -0,0 +1,9 @@
+#undef SHA1HANDSOFF
+
+#undef POSIX_TERMIOS
+
+#undef POSIX_SIGTYPE
+
+#undef VERSION
+
+#undef volatile
diff --git a/package/network/services/ead/src/tinysrp/.svn/text-base/acinclude.m4.svn-base b/package/network/services/ead/src/tinysrp/.svn/text-base/acinclude.m4.svn-base
new file mode 100644
index 0000000..e0d0d04
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/.svn/text-base/acinclude.m4.svn-base
@@ -0,0 +1,27 @@
+dnl
+dnl check for signal type
+dnl
+dnl AC_RETSIGTYPE isn't quite right, but almost.
+dnl
+define(TYPE_SIGNAL,[
+AC_MSG_CHECKING([POSIX signal handlers])
+AC_CACHE_VAL(cv_has_posix_signals,
+[AC_TRY_COMPILE(
+[#include <sys/types.h>
+#include <signal.h>
+#ifdef signal
+#undef signal
+#endif
+extern void (*signal ()) ();], [],
+cv_has_posix_signals=yes, cv_has_posix_signals=no)])
+AC_MSG_RESULT($cv_has_posix_signals)
+if test $cv_has_posix_signals = yes; then
+ AC_DEFINE(RETSIGTYPE, void, [Return type is void])
+ AC_DEFINE(POSIX_SIGTYPE, [], [Have POSIX signals])
+else
+ if test $ac_cv_type_signal = void; then
+ AC_DEFINE(RETSIGTYPE, void, [Return type is void])
+ else
+ AC_DEFINE(RETSIGTYPE, int, [Return type is int])
+ fi
+fi])dnl
diff --git a/package/network/services/ead/src/tinysrp/.svn/text-base/aclocal.m4.svn-base b/package/network/services/ead/src/tinysrp/.svn/text-base/aclocal.m4.svn-base
new file mode 100644
index 0000000..703fce4
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/.svn/text-base/aclocal.m4.svn-base
@@ -0,0 +1,157 @@
+dnl aclocal.m4 generated automatically by aclocal 1.4a
+
+dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+dnl PARTICULAR PURPOSE.
+
+dnl
+dnl check for signal type
+dnl
+dnl AC_RETSIGTYPE isn't quite right, but almost.
+dnl
+define(TYPE_SIGNAL,[
+AC_MSG_CHECKING([POSIX signal handlers])
+AC_CACHE_VAL(cv_has_posix_signals,
+[AC_TRY_COMPILE(
+[#include <sys/types.h>
+#include <signal.h>
+#ifdef signal
+#undef signal
+#endif
+extern void (*signal ()) ();], [],
+cv_has_posix_signals=yes, cv_has_posix_signals=no)])
+AC_MSG_RESULT($cv_has_posix_signals)
+if test $cv_has_posix_signals = yes; then
+ AC_DEFINE(RETSIGTYPE, void, [Return type is void])
+ AC_DEFINE(POSIX_SIGTYPE, [], [Have POSIX signals])
+else
+ if test $ac_cv_type_signal = void; then
+ AC_DEFINE(RETSIGTYPE, void, [Return type is void])
+ else
+ AC_DEFINE(RETSIGTYPE, int, [Return type is int])
+ fi
+fi])dnl
+
+# Like AC_CONFIG_HEADER, but automatically create stamp file.
+
+AC_DEFUN(AM_CONFIG_HEADER,
+[AC_PREREQ([2.12])
+AC_CONFIG_HEADER([$1])
+dnl When config.status generates a header, we must update the stamp-h file.
+dnl This file resides in the same directory as the config header
+dnl that is generated. We must strip everything past the first ":",
+dnl and everything past the last "/".
+AC_OUTPUT_COMMANDS(changequote(<<,>>)dnl
+ifelse(patsubst(<<$1>>, <<[^ ]>>, <<>>), <<>>,
+<<test -z "<<$>>CONFIG_HEADERS" || echo timestamp > patsubst(<<$1>>, <<^\([^:]*/\)?.*>>, <<\1>>)stamp-h<<>>dnl>>,
+<<am_indx=1
+for am_file in <<$1>>; do
+ case " <<$>>CONFIG_HEADERS " in
+ *" <<$>>am_file "*<<)>>
+ echo timestamp > `echo <<$>>am_file | sed -e 's%:.*%%' -e 's%[^/]*$%%'`stamp-h$am_indx
+ ;;
+ esac
+ am_indx=`expr "<<$>>am_indx" + 1`
+done<<>>dnl>>)
+changequote([,]))])
+
+# Do all the work for Automake. This macro actually does too much --
+# some checks are only needed if your package does certain things.
+# But this isn't really a big deal.
+
+# serial 1
+
+dnl Usage:
+dnl AM_INIT_AUTOMAKE(package,version, [no-define])
+
+AC_DEFUN(AM_INIT_AUTOMAKE,
+[AC_REQUIRE([AC_PROG_INSTALL])
+dnl We require 2.13 because we rely on SHELL being computed by configure.
+AC_PREREQ([2.13])
+PACKAGE=[$1]
+AC_SUBST(PACKAGE)
+VERSION=[$2]
+AC_SUBST(VERSION)
+dnl test to see if srcdir already configured
+if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
+ AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
+fi
+ifelse([$3],,
+AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
+AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package]))
+AC_REQUIRE([AM_SANITY_CHECK])
+AC_REQUIRE([AC_ARG_PROGRAM])
+dnl FIXME This is truly gross.
+missing_dir=`cd $ac_aux_dir && pwd`
+AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
+AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
+AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
+AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
+AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
+AC_REQUIRE([AC_PROG_MAKE_SET])])
+
+#
+# Check to make sure that the build environment is sane.
+#
+
+AC_DEFUN(AM_SANITY_CHECK,
+[AC_MSG_CHECKING([whether build environment is sane])
+# Just in case
+sleep 1
+echo timestamp > conftestfile
+# Do `set' in a subshell so we don't clobber the current shell's
+# arguments. Must try -L first in case configure is actually a
+# symlink; some systems play weird games with the mod time of symlinks
+# (eg FreeBSD returns the mod time of the symlink's containing
+# directory).
+if (
+ set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null`
+ if test "[$]*" = "X"; then
+ # -L didn't work.
+ set X `ls -t $srcdir/configure conftestfile`
+ fi
+ if test "[$]*" != "X $srcdir/configure conftestfile" \
+ && test "[$]*" != "X conftestfile $srcdir/configure"; then
+
+ # If neither matched, then we have a broken ls. This can happen
+ # if, for instance, CONFIG_SHELL is bash and it inherits a
+ # broken ls alias from the environment. This has actually
+ # happened. Such a system could not be considered "sane".
+ AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken
+alias in your environment])
+ fi
+
+ test "[$]2" = conftestfile
+ )
+then
+ # Ok.
+ :
+else
+ AC_MSG_ERROR([newly created file is older than distributed files!
+Check your system clock])
+fi
+rm -f conftest*
+AC_MSG_RESULT(yes)])
+
+dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY)
+dnl The program must properly implement --version.
+AC_DEFUN(AM_MISSING_PROG,
+[AC_MSG_CHECKING(for working $2)
+# Run test in a subshell; some versions of sh will print an error if
+# an executable is not found, even if stderr is redirected.
+# Redirect stdin to placate older versions of autoconf. Sigh.
+if ($2 --version) < /dev/null > /dev/null 2>&1; then
+ $1=$2
+ AC_MSG_RESULT(found)
+else
+ $1="$3/missing $2"
+ AC_MSG_RESULT(missing)
+fi
+AC_SUBST($1)])
+
diff --git a/package/network/services/ead/src/tinysrp/.svn/text-base/bn.h.svn-base b/package/network/services/ead/src/tinysrp/.svn/text-base/bn.h.svn-base
new file mode 100644
index 0000000..0144dd9
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/.svn/text-base/bn.h.svn-base
@@ -0,0 +1,471 @@
+/* crypto/bn/bn.h */
+/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#ifndef HEADER_BN_H
+#define HEADER_BN_H
+
+#include <stdio.h> /* FILE */
+#include "config.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef VMS
+#undef BN_LLONG /* experimental, so far... */
+#endif
+
+#undef BN_MUL_COMBA
+#undef BN_SQR_COMBA
+#undef BN_RECURSION
+#undef RECP_MUL_MOD
+#undef MONT_MUL_MOD
+
+#if defined(SIZEOF_LONG_LONG) && SIZEOF_LONG_LONG == 8
+# if SIZEOF_LONG == 4
+# define THIRTY_TWO_BIT
+# else
+# define SIXTY_FOUR_BIT_LONG
+# endif
+#else
+# if SIZEOF_LONG == 4
+# define THIRTY_TWO_BIT
+# endif
+#endif
+
+#undef BN_LLONG
+
+/* assuming long is 64bit - this is the DEC Alpha
+ * unsigned long long is only 64 bits :-(, don't define
+ * BN_LLONG for the DEC Alpha */
+#ifdef SIXTY_FOUR_BIT_LONG
+#define BN_ULLONG unsigned long long
+#define BN_ULONG unsigned long
+#define BN_LONG long
+#define BN_BITS 128
+#define BN_BYTES 8
+#define BN_BITS2 64
+#define BN_BITS4 32
+#define BN_MASK (0xffffffffffffffffffffffffffffffffLL)
+#define BN_MASK2 (0xffffffffffffffffL)
+#define BN_MASK2l (0xffffffffL)
+#define BN_MASK2h (0xffffffff00000000L)
+#define BN_MASK2h1 (0xffffffff80000000L)
+#define BN_TBIT (0x8000000000000000L)
+#define BN_DEC_CONV (10000000000000000000UL)
+#define BN_DEC_FMT1 "%lu"
+#define BN_DEC_FMT2 "%019lu"
+#define BN_DEC_NUM 19
+#endif
+
+/* This is where the long long data type is 64 bits, but long is 32.
+ * For machines where there are 64bit registers, this is the mode to use.
+ * IRIX, on R4000 and above should use this mode, along with the relevant
+ * assembler code :-). Do NOT define BN_LLONG.
+ */
+#ifdef SIXTY_FOUR_BIT
+#undef BN_LLONG
+#undef BN_ULLONG
+#define BN_ULONG unsigned long long
+#define BN_LONG long long
+#define BN_BITS 128
+#define BN_BYTES 8
+#define BN_BITS2 64
+#define BN_BITS4 32
+#define BN_MASK2 (0xffffffffffffffffLL)
+#define BN_MASK2l (0xffffffffL)
+#define BN_MASK2h (0xffffffff00000000LL)
+#define BN_MASK2h1 (0xffffffff80000000LL)
+#define BN_TBIT (0x8000000000000000LL)
+#define BN_DEC_CONV (10000000000000000000LL)
+#define BN_DEC_FMT1 "%llu"
+#define BN_DEC_FMT2 "%019llu"
+#define BN_DEC_NUM 19
+#endif
+
+#ifdef THIRTY_TWO_BIT
+#if defined(WIN32) && !defined(__GNUC__)
+#define BN_ULLONG unsigned _int64
+#else
+#define BN_ULLONG unsigned long long
+#endif
+#define BN_ULONG unsigned long
+#define BN_LONG long
+#define BN_BITS 64
+#define BN_BYTES 4
+#define BN_BITS2 32
+#define BN_BITS4 16
+#ifdef WIN32
+/* VC++ doesn't like the LL suffix */
+#define BN_MASK (0xffffffffffffffffL)
+#else
+#define BN_MASK (0xffffffffffffffffLL)
+#endif
+#define BN_MASK2 (0xffffffffL)
+#define BN_MASK2l (0xffff)
+#define BN_MASK2h1 (0xffff8000L)
+#define BN_MASK2h (0xffff0000L)
+#define BN_TBIT (0x80000000L)
+#define BN_DEC_CONV (1000000000L)
+#define BN_DEC_FMT1 "%lu"
+#define BN_DEC_FMT2 "%09lu"
+#define BN_DEC_NUM 9
+#endif
+
+#ifdef SIXTEEN_BIT
+#ifndef BN_DIV2W
+#define BN_DIV2W
+#endif
+#define BN_ULLONG unsigned long
+#define BN_ULONG unsigned short
+#define BN_LONG short
+#define BN_BITS 32
+#define BN_BYTES 2
+#define BN_BITS2 16
+#define BN_BITS4 8
+#define BN_MASK (0xffffffff)
+#define BN_MASK2 (0xffff)
+#define BN_MASK2l (0xff)
+#define BN_MASK2h1 (0xff80)
+#define BN_MASK2h (0xff00)
+#define BN_TBIT (0x8000)
+#define BN_DEC_CONV (100000)
+#define BN_DEC_FMT1 "%u"
+#define BN_DEC_FMT2 "%05u"
+#define BN_DEC_NUM 5
+#endif
+
+#ifdef EIGHT_BIT
+#ifndef BN_DIV2W
+#define BN_DIV2W
+#endif
+#define BN_ULLONG unsigned short
+#define BN_ULONG unsigned char
+#define BN_LONG char
+#define BN_BITS 16
+#define BN_BYTES 1
+#define BN_BITS2 8
+#define BN_BITS4 4
+#define BN_MASK (0xffff)
+#define BN_MASK2 (0xff)
+#define BN_MASK2l (0xf)
+#define BN_MASK2h1 (0xf8)
+#define BN_MASK2h (0xf0)
+#define BN_TBIT (0x80)
+#define BN_DEC_CONV (100)
+#define BN_DEC_FMT1 "%u"
+#define BN_DEC_FMT2 "%02u"
+#define BN_DEC_NUM 2
+#endif
+
+#define BN_DEFAULT_BITS 1280
+
+#ifdef BIGNUM
+#undef BIGNUM
+#endif
+
+#define BN_FLG_MALLOCED 0x01
+#define BN_FLG_STATIC_DATA 0x02
+#define BN_FLG_FREE 0x8000 /* used for debuging */
+#define BN_set_flags(b,n) ((b)->flags|=(n))
+#define BN_get_flags(b,n) ((b)->flags&(n))
+
+typedef struct bignum_st
+ {
+ BN_ULONG *d; /* Pointer to an array of 'BN_BITS2' bit chunks. */
+ int top; /* Index of last used d +1. */
+ /* The next are internal book keeping for bn_expand. */
+ int dmax; /* Size of the d array. */
+ int neg; /* one if the number is negative */
+ int flags;
+ } BIGNUM;
+
+/* Used for temp variables */
+#define BN_CTX_NUM 12
+#define BN_CTX_NUM_POS 12
+typedef struct bignum_ctx
+ {
+ int tos;
+ BIGNUM bn[BN_CTX_NUM];
+ int flags;
+ int depth;
+ int pos[BN_CTX_NUM_POS];
+ int too_many;
+ } BN_CTX;
+
+/* Used for montgomery multiplication */
+typedef struct bn_mont_ctx_st
+ {
+ int ri; /* number of bits in R */
+ BIGNUM RR; /* used to convert to montgomery form */
+ BIGNUM N; /* The modulus */
+ BIGNUM Ni; /* R*(1/R mod N) - N*Ni = 1
+ * (Ni is only stored for bignum algorithm) */
+ BN_ULONG n0; /* least significant word of Ni */
+ int flags;
+ } BN_MONT_CTX;
+
+/* Used for reciprocal division/mod functions
+ * It cannot be shared between threads
+ */
+typedef struct bn_recp_ctx_st
+ {
+ BIGNUM N; /* the divisor */
+ BIGNUM Nr; /* the reciprocal */
+ int num_bits;
+ int shift;
+ int flags;
+ } BN_RECP_CTX;
+
+#define BN_to_montgomery(r,a,mont,ctx) BN_mod_mul_montgomery(\
+ r,a,&((mont)->RR),(mont),ctx)
+
+#define BN_prime_checks 0 /* default: select number of iterations
+ based on the size of the number */
+
+/* number of Miller-Rabin iterations for an error rate of less than 2^-80
+ * for random 'b'-bit input, b >= 100 (taken from table 4.4 in the Handbook
+ * of Applied Cryptography [Menezes, van Oorschot, Vanstone; CRC Press 1996];
+ * original paper: Damgaard, Landrock, Pomerance: Average case error estimates
+ * for the strong probable prime test. -- Math. Comp. 61 (1993) 177-194) */
+#define BN_prime_checks_for_size(b) ((b) >= 1300 ? 2 : \
+ (b) >= 850 ? 3 : \
+ (b) >= 650 ? 4 : \
+ (b) >= 550 ? 5 : \
+ (b) >= 450 ? 6 : \
+ (b) >= 400 ? 7 : \
+ (b) >= 350 ? 8 : \
+ (b) >= 300 ? 9 : \
+ (b) >= 250 ? 12 : \
+ (b) >= 200 ? 15 : \
+ (b) >= 150 ? 18 : \
+ /* b >= 100 */ 27)
+
+#define BN_num_bytes(a) ((BN_num_bits(a)+7)/8)
+#define BN_is_word(a,w) (((a)->top == 1) && ((a)->d[0] == (BN_ULONG)(w)))
+#define BN_is_zero(a) (((a)->top == 0) || BN_is_word(a,0))
+#define BN_is_one(a) (BN_is_word((a),1))
+#define BN_is_odd(a) (((a)->top > 0) && ((a)->d[0] & 1))
+#define BN_one(a) (BN_set_word((a),1))
+#define BN_zero(a) (BN_set_word((a),0))
+
+BIGNUM *BN_value_one(void);
+char * BN_options(void);
+BN_CTX *BN_CTX_new(void);
+void BN_CTX_init(BN_CTX *c);
+void BN_CTX_free(BN_CTX *c);
+void BN_CTX_start(BN_CTX *ctx);
+BIGNUM *BN_CTX_get(BN_CTX *ctx);
+void BN_CTX_end(BN_CTX *ctx);
+int BN_rand(BIGNUM *rnd, int bits, int top,int bottom);
+int BN_pseudo_rand(BIGNUM *rnd, int bits, int top,int bottom);
+int BN_num_bits(const BIGNUM *a);
+int BN_num_bits_word(BN_ULONG);
+BIGNUM *BN_new(void);
+void BN_init(BIGNUM *);
+void BN_clear_free(BIGNUM *a);
+BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b);
+BIGNUM *BN_bin2bn(const unsigned char *s,int len,BIGNUM *ret);
+int BN_bn2bin(const BIGNUM *a, unsigned char *to);
+int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
+int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
+int BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
+int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
+int BN_mod(BIGNUM *rem, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx);
+int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d,
+ BN_CTX *ctx);
+int BN_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx);
+int BN_sqr(BIGNUM *r, BIGNUM *a,BN_CTX *ctx);
+BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w);
+BN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w);
+int BN_mul_word(BIGNUM *a, BN_ULONG w);
+int BN_add_word(BIGNUM *a, BN_ULONG w);
+int BN_sub_word(BIGNUM *a, BN_ULONG w);
+int BN_set_word(BIGNUM *a, BN_ULONG w);
+BN_ULONG BN_get_word(BIGNUM *a);
+int BN_cmp(const BIGNUM *a, const BIGNUM *b);
+void BN_free(BIGNUM *a);
+int BN_is_bit_set(const BIGNUM *a, int n);
+int BN_lshift(BIGNUM *r, const BIGNUM *a, int n);
+int BN_lshift1(BIGNUM *r, BIGNUM *a);
+int BN_exp(BIGNUM *r, BIGNUM *a, BIGNUM *p,BN_CTX *ctx);
+int BN_mod_exp(BIGNUM *r, BIGNUM *a, const BIGNUM *p,
+ const BIGNUM *m,BN_CTX *ctx);
+int BN_mod_exp_mont(BIGNUM *r, BIGNUM *a, const BIGNUM *p,
+ const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
+int BN_mod_exp_mont_word(BIGNUM *r, BN_ULONG a, const BIGNUM *p,
+ const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
+int BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
+ const BIGNUM *m,BN_CTX *ctx);
+int BN_mask_bits(BIGNUM *a,int n);
+int BN_mod_mul(BIGNUM *ret, BIGNUM *a, BIGNUM *b, const BIGNUM *m, BN_CTX *ctx);
+int BN_reciprocal(BIGNUM *r, BIGNUM *m, int len, BN_CTX *ctx);
+int BN_rshift(BIGNUM *r, BIGNUM *a, int n);
+int BN_rshift1(BIGNUM *r, BIGNUM *a);
+void BN_clear(BIGNUM *a);
+BIGNUM *BN_dup(const BIGNUM *a);
+int BN_ucmp(const BIGNUM *a, const BIGNUM *b);
+int BN_set_bit(BIGNUM *a, int n);
+int BN_clear_bit(BIGNUM *a, int n);
+int BN_gcd(BIGNUM *r,BIGNUM *in_a,BIGNUM *in_b,BN_CTX *ctx);
+BIGNUM *BN_mod_inverse(BIGNUM *ret,BIGNUM *a, const BIGNUM *n,BN_CTX *ctx);
+BIGNUM *BN_generate_prime(BIGNUM *ret,int bits,int safe,BIGNUM *add,
+ BIGNUM *rem,void (*callback)(int,int,void *),void *cb_arg);
+int BN_is_prime(const BIGNUM *p,int nchecks,
+ void (*callback)(int,int,void *),
+ BN_CTX *ctx,void *cb_arg);
+int BN_is_prime_fasttest(const BIGNUM *p,int nchecks,
+ void (*callback)(int,int,void *),BN_CTX *ctx,void *cb_arg,
+ int do_trial_division);
+
+BN_MONT_CTX *BN_MONT_CTX_new(void );
+void BN_MONT_CTX_init(BN_MONT_CTX *ctx);
+int BN_mod_mul_montgomery(BIGNUM *r,BIGNUM *a,BIGNUM *b,BN_MONT_CTX *mont,
+ BN_CTX *ctx);
+int BN_from_montgomery(BIGNUM *r,BIGNUM *a,BN_MONT_CTX *mont,BN_CTX *ctx);
+void BN_MONT_CTX_free(BN_MONT_CTX *mont);
+int BN_MONT_CTX_set(BN_MONT_CTX *mont,const BIGNUM *modulus,BN_CTX *ctx);
+BN_MONT_CTX *BN_MONT_CTX_copy(BN_MONT_CTX *to,BN_MONT_CTX *from);
+
+void BN_set_params(int mul,int high,int low,int mont);
+int BN_get_params(int which); /* 0, mul, 1 high, 2 low, 3 mont */
+
+void BN_RECP_CTX_init(BN_RECP_CTX *recp);
+BN_RECP_CTX *BN_RECP_CTX_new(void);
+void BN_RECP_CTX_free(BN_RECP_CTX *recp);
+int BN_RECP_CTX_set(BN_RECP_CTX *recp,const BIGNUM *rdiv,BN_CTX *ctx);
+int BN_mod_mul_reciprocal(BIGNUM *r, BIGNUM *x, BIGNUM *y,
+ BN_RECP_CTX *recp,BN_CTX *ctx);
+int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
+ const BIGNUM *m, BN_CTX *ctx);
+int BN_div_recp(BIGNUM *dv, BIGNUM *rem, BIGNUM *m,
+ BN_RECP_CTX *recp, BN_CTX *ctx);
+
+/* library internal functions */
+
+#define bn_expand(a,bits) ((((((bits+BN_BITS2-1))/BN_BITS2)) <= (a)->dmax)?\
+ (a):bn_expand2((a),(bits)/BN_BITS2+1))
+#define bn_wexpand(a,words) (((words) <= (a)->dmax)?(a):bn_expand2((a),(words)))
+BIGNUM *bn_expand2(BIGNUM *a, int words);
+
+#define bn_fix_top(a) \
+ { \
+ BN_ULONG *ftl; \
+ if ((a)->top > 0) \
+ { \
+ for (ftl= &((a)->d[(a)->top-1]); (a)->top > 0; (a)->top--) \
+ if (*(ftl--)) break; \
+ } \
+ }
+
+BN_ULONG bn_mul_add_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w);
+BN_ULONG bn_mul_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w);
+void bn_sqr_words(BN_ULONG *rp, BN_ULONG *ap, int num);
+BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d);
+BN_ULONG bn_add_words(BN_ULONG *rp, BN_ULONG *ap, BN_ULONG *bp,int num);
+BN_ULONG bn_sub_words(BN_ULONG *rp, BN_ULONG *ap, BN_ULONG *bp,int num);
+
+#ifdef BN_DEBUG
+ void bn_dump1(FILE *o, const char *a, BN_ULONG *b,int n);
+# define bn_print(a) {fprintf(stderr, #a "="); BN_print_fp(stderr,a); \
+ fprintf(stderr,"\n");}
+# define bn_dump(a,n) bn_dump1(stderr,#a,a,n);
+#else
+# define bn_print(a)
+# define bn_dump(a,b)
+#endif
+
+/* BEGIN ERROR CODES */
+/* The following lines are auto generated by the script mkerr.pl. Any changes
+ * made after this point may be overwritten when the script is next run.
+ */
+
+/* Error codes for the BN functions. */
+
+/* Function codes. */
+#define BN_F_BN_CTX_GET 116
+#define BN_F_BN_CTX_NEW 106
+#define BN_F_BN_DIV 107
+#define BN_F_BN_EXPAND2 108
+#define BN_F_BN_MOD_EXP2_MONT 118
+#define BN_F_BN_MOD_EXP_MONT 109
+#define BN_F_BN_MOD_EXP_MONT_WORD 117
+#define BN_F_BN_MOD_INVERSE 110
+#define BN_F_BN_MOD_MUL_RECIPROCAL 111
+#define BN_F_BN_MPI2BN 112
+#define BN_F_BN_NEW 113
+#define BN_F_BN_RAND 114
+#define BN_F_BN_USUB 115
+
+/* Reason codes. */
+#define BN_R_ARG2_LT_ARG3 100
+#define BN_R_BAD_RECIPROCAL 101
+#define BN_R_CALLED_WITH_EVEN_MODULUS 102
+#define BN_R_DIV_BY_ZERO 103
+#define BN_R_ENCODING_ERROR 104
+#define BN_R_EXPAND_ON_STATIC_BIGNUM_DATA 105
+#define BN_R_INVALID_LENGTH 106
+#define BN_R_NOT_INITIALIZED 107
+#define BN_R_NO_INVERSE 108
+#define BN_R_TOO_MANY_TEMPORARY_VARIABLES 109
+
+#ifdef __cplusplus
+}
+#endif
+#endif
+
diff --git a/package/network/services/ead/src/tinysrp/.svn/text-base/bn_add.c.svn-base b/package/network/services/ead/src/tinysrp/.svn/text-base/bn_add.c.svn-base
new file mode 100644
index 0000000..aae4f2b
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/.svn/text-base/bn_add.c.svn-base
@@ -0,0 +1,305 @@
+/* crypto/bn/bn_add.c */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#include <stdio.h>
+#include "bn_lcl.h"
+
+/* r can == a or b */
+int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)
+ {
+ const BIGNUM *tmp;
+
+ bn_check_top(a);
+ bn_check_top(b);
+
+ /* a + b a+b
+ * a + -b a-b
+ * -a + b b-a
+ * -a + -b -(a+b)
+ */
+ if (a->neg ^ b->neg)
+ {
+ /* only one is negative */
+ if (a->neg)
+ { tmp=a; a=b; b=tmp; }
+
+ /* we are now a - b */
+
+ if (BN_ucmp(a,b) < 0)
+ {
+ if (!BN_usub(r,b,a)) return(0);
+ r->neg=1;
+ }
+ else
+ {
+ if (!BN_usub(r,a,b)) return(0);
+ r->neg=0;
+ }
+ return(1);
+ }
+
+ if (a->neg) /* both are neg */
+ r->neg=1;
+ else
+ r->neg=0;
+
+ if (!BN_uadd(r,a,b)) return(0);
+ return(1);
+ }
+
+/* unsigned add of b to a, r must be large enough */
+int BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)
+ {
+ register int i;
+ int max,min;
+ BN_ULONG *ap,*bp,*rp,carry,t1;
+ const BIGNUM *tmp;
+
+ bn_check_top(a);
+ bn_check_top(b);
+
+ if (a->top < b->top)
+ { tmp=a; a=b; b=tmp; }
+ max=a->top;
+ min=b->top;
+
+ if (bn_wexpand(r,max+1) == NULL)
+ return(0);
+
+ r->top=max;
+
+
+ ap=a->d;
+ bp=b->d;
+ rp=r->d;
+ carry=0;
+
+ carry=bn_add_words(rp,ap,bp,min);
+ rp+=min;
+ ap+=min;
+ bp+=min;
+ i=min;
+
+ if (carry)
+ {
+ while (i < max)
+ {
+ i++;
+ t1= *(ap++);
+ if ((*(rp++)=(t1+1)&BN_MASK2) >= t1)
+ {
+ carry=0;
+ break;
+ }
+ }
+ if ((i >= max) && carry)
+ {
+ *(rp++)=1;
+ r->top++;
+ }
+ }
+ if (rp != ap)
+ {
+ for (; i<max; i++)
+ *(rp++)= *(ap++);
+ }
+ /* memcpy(rp,ap,sizeof(*ap)*(max-i));*/
+ return(1);
+ }
+
+/* unsigned subtraction of b from a, a must be larger than b. */
+int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)
+ {
+ int max,min;
+ register BN_ULONG t1,t2,*ap,*bp,*rp;
+ int i,carry;
+#if defined(IRIX_CC_BUG) && !defined(LINT)
+ int dummy;
+#endif
+
+ bn_check_top(a);
+ bn_check_top(b);
+
+ if (a->top < b->top) /* hmm... should not be happening */
+ {
+ return(0);
+ }
+
+ max=a->top;
+ min=b->top;
+ if (bn_wexpand(r,max) == NULL) return(0);
+
+ ap=a->d;
+ bp=b->d;
+ rp=r->d;
+
+#if 1
+ carry=0;
+ for (i=0; i<min; i++)
+ {
+ t1= *(ap++);
+ t2= *(bp++);
+ if (carry)
+ {
+ carry=(t1 <= t2);
+ t1=(t1-t2-1)&BN_MASK2;
+ }
+ else
+ {
+ carry=(t1 < t2);
+ t1=(t1-t2)&BN_MASK2;
+ }
+#if defined(IRIX_CC_BUG) && !defined(LINT)
+ dummy=t1;
+#endif
+ *(rp++)=t1&BN_MASK2;
+ }
+#else
+ carry=bn_sub_words(rp,ap,bp,min);
+ ap+=min;
+ bp+=min;
+ rp+=min;
+ i=min;
+#endif
+ if (carry) /* subtracted */
+ {
+ while (i < max)
+ {
+ i++;
+ t1= *(ap++);
+ t2=(t1-1)&BN_MASK2;
+ *(rp++)=t2;
+ if (t1 > t2) break;
+ }
+ }
+#if 0
+ memcpy(rp,ap,sizeof(*rp)*(max-i));
+#else
+ if (rp != ap)
+ {
+ for (;;)
+ {
+ if (i++ >= max) break;
+ rp[0]=ap[0];
+ if (i++ >= max) break;
+ rp[1]=ap[1];
+ if (i++ >= max) break;
+ rp[2]=ap[2];
+ if (i++ >= max) break;
+ rp[3]=ap[3];
+ rp+=4;
+ ap+=4;
+ }
+ }
+#endif
+
+ r->top=max;
+ bn_fix_top(r);
+ return(1);
+ }
+
+int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)
+ {
+ int max;
+ int add=0,neg=0;
+ const BIGNUM *tmp;
+
+ bn_check_top(a);
+ bn_check_top(b);
+
+ /* a - b a-b
+ * a - -b a+b
+ * -a - b -(a+b)
+ * -a - -b b-a
+ */
+ if (a->neg)
+ {
+ if (b->neg)
+ { tmp=a; a=b; b=tmp; }
+ else
+ { add=1; neg=1; }
+ }
+ else
+ {
+ if (b->neg) { add=1; neg=0; }
+ }
+
+ if (add)
+ {
+ if (!BN_uadd(r,a,b)) return(0);
+ r->neg=neg;
+ return(1);
+ }
+
+ /* We are actually doing a - b :-) */
+
+ max=(a->top > b->top)?a->top:b->top;
+ if (bn_wexpand(r,max) == NULL) return(0);
+ if (BN_ucmp(a,b) < 0)
+ {
+ if (!BN_usub(r,b,a)) return(0);
+ r->neg=1;
+ }
+ else
+ {
+ if (!BN_usub(r,a,b)) return(0);
+ r->neg=0;
+ }
+ return(1);
+ }
+
diff --git a/package/network/services/ead/src/tinysrp/.svn/text-base/bn_asm.c.svn-base b/package/network/services/ead/src/tinysrp/.svn/text-base/bn_asm.c.svn-base
new file mode 100644
index 0000000..b24c9af
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/.svn/text-base/bn_asm.c.svn-base
@@ -0,0 +1,382 @@
+/* crypto/bn/bn_asm.c */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#ifndef BN_DEBUG
+# undef NDEBUG /* avoid conflicting definitions */
+# define NDEBUG
+#endif
+
+#include <stdio.h>
+#include <assert.h>
+#include "bn_lcl.h"
+
+#if defined(BN_LLONG) || defined(BN_UMULT_HIGH)
+
+BN_ULONG bn_mul_add_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w)
+ {
+ BN_ULONG c1=0;
+
+ assert(num >= 0);
+ if (num <= 0) return(c1);
+
+ while (num&~3)
+ {
+ mul_add(rp[0],ap[0],w,c1);
+ mul_add(rp[1],ap[1],w,c1);
+ mul_add(rp[2],ap[2],w,c1);
+ mul_add(rp[3],ap[3],w,c1);
+ ap+=4; rp+=4; num-=4;
+ }
+ if (num)
+ {
+ mul_add(rp[0],ap[0],w,c1); if (--num==0) return c1;
+ mul_add(rp[1],ap[1],w,c1); if (--num==0) return c1;
+ mul_add(rp[2],ap[2],w,c1); return c1;
+ }
+
+ return(c1);
+ }
+
+BN_ULONG bn_mul_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w)
+ {
+ BN_ULONG c1=0;
+
+ assert(num >= 0);
+ if (num <= 0) return(c1);
+
+ while (num&~3)
+ {
+ mul(rp[0],ap[0],w,c1);
+ mul(rp[1],ap[1],w,c1);
+ mul(rp[2],ap[2],w,c1);
+ mul(rp[3],ap[3],w,c1);
+ ap+=4; rp+=4; num-=4;
+ }
+ if (num)
+ {
+ mul(rp[0],ap[0],w,c1); if (--num == 0) return c1;
+ mul(rp[1],ap[1],w,c1); if (--num == 0) return c1;
+ mul(rp[2],ap[2],w,c1);
+ }
+ return(c1);
+ }
+
+void bn_sqr_words(BN_ULONG *r, BN_ULONG *a, int n)
+ {
+ assert(n >= 0);
+ if (n <= 0) return;
+ while (n&~3)
+ {
+ sqr(r[0],r[1],a[0]);
+ sqr(r[2],r[3],a[1]);
+ sqr(r[4],r[5],a[2]);
+ sqr(r[6],r[7],a[3]);
+ a+=4; r+=8; n-=4;
+ }
+ if (n)
+ {
+ sqr(r[0],r[1],a[0]); if (--n == 0) return;
+ sqr(r[2],r[3],a[1]); if (--n == 0) return;
+ sqr(r[4],r[5],a[2]);
+ }
+ }
+
+#else /* !(defined(BN_LLONG) || defined(BN_UMULT_HIGH)) */
+
+BN_ULONG bn_mul_add_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w)
+ {
+ BN_ULONG c=0;
+ BN_ULONG bl,bh;
+
+ assert(num >= 0);
+ if (num <= 0) return((BN_ULONG)0);
+
+ bl=LBITS(w);
+ bh=HBITS(w);
+
+ for (;;)
+ {
+ mul_add(rp[0],ap[0],bl,bh,c);
+ if (--num == 0) break;
+ mul_add(rp[1],ap[1],bl,bh,c);
+ if (--num == 0) break;
+ mul_add(rp[2],ap[2],bl,bh,c);
+ if (--num == 0) break;
+ mul_add(rp[3],ap[3],bl,bh,c);
+ if (--num == 0) break;
+ ap+=4;
+ rp+=4;
+ }
+ return(c);
+ }
+
+BN_ULONG bn_mul_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w)
+ {
+ BN_ULONG carry=0;
+ BN_ULONG bl,bh;
+
+ assert(num >= 0);
+ if (num <= 0) return((BN_ULONG)0);
+
+ bl=LBITS(w);
+ bh=HBITS(w);
+
+ for (;;)
+ {
+ mul(rp[0],ap[0],bl,bh,carry);
+ if (--num == 0) break;
+ mul(rp[1],ap[1],bl,bh,carry);
+ if (--num == 0) break;
+ mul(rp[2],ap[2],bl,bh,carry);
+ if (--num == 0) break;
+ mul(rp[3],ap[3],bl,bh,carry);
+ if (--num == 0) break;
+ ap+=4;
+ rp+=4;
+ }
+ return(carry);
+ }
+
+void bn_sqr_words(BN_ULONG *r, BN_ULONG *a, int n)
+ {
+ assert(n >= 0);
+ if (n <= 0) return;
+ for (;;)
+ {
+ sqr64(r[0],r[1],a[0]);
+ if (--n == 0) break;
+
+ sqr64(r[2],r[3],a[1]);
+ if (--n == 0) break;
+
+ sqr64(r[4],r[5],a[2]);
+ if (--n == 0) break;
+
+ sqr64(r[6],r[7],a[3]);
+ if (--n == 0) break;
+
+ a+=4;
+ r+=8;
+ }
+ }
+
+#endif /* !(defined(BN_LLONG) || defined(BN_UMULT_HIGH)) */
+
+#if defined(BN_LLONG) && defined(BN_DIV2W)
+
+BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d)
+ {
+ return((BN_ULONG)(((((BN_ULLONG)h)<<BN_BITS2)|l)/(BN_ULLONG)d));
+ }
+
+#else
+
+/* Divide h,l by d and return the result. */
+/* I need to test this some more :-( */
+BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d)
+ {
+ BN_ULONG dh,dl,q,ret=0,th,tl,t;
+ int i,count=2;
+
+ if (d == 0) return(BN_MASK2);
+
+ i=BN_num_bits_word(d);
+ assert((i == BN_BITS2) || (h > (BN_ULONG)1<<i));
+
+ i=BN_BITS2-i;
+ if (h >= d) h-=d;
+
+ if (i)
+ {
+ d<<=i;
+ h=(h<<i)|(l>>(BN_BITS2-i));
+ l<<=i;
+ }
+ dh=(d&BN_MASK2h)>>BN_BITS4;
+ dl=(d&BN_MASK2l);
+ for (;;)
+ {
+ if ((h>>BN_BITS4) == dh)
+ q=BN_MASK2l;
+ else
+ q=h/dh;
+
+ th=q*dh;
+ tl=dl*q;
+ for (;;)
+ {
+ t=h-th;
+ if ((t&BN_MASK2h) ||
+ ((tl) <= (
+ (t<<BN_BITS4)|
+ ((l&BN_MASK2h)>>BN_BITS4))))
+ break;
+ q--;
+ th-=dh;
+ tl-=dl;
+ }
+ t=(tl>>BN_BITS4);
+ tl=(tl<<BN_BITS4)&BN_MASK2h;
+ th+=t;
+
+ if (l < tl) th++;
+ l-=tl;
+ if (h < th)
+ {
+ h+=d;
+ q--;
+ }
+ h-=th;
+
+ if (--count == 0) break;
+
+ ret=q<<BN_BITS4;
+ h=((h<<BN_BITS4)|(l>>BN_BITS4))&BN_MASK2;
+ l=(l&BN_MASK2l)<<BN_BITS4;
+ }
+ ret|=q;
+ return(ret);
+ }
+#endif /* !defined(BN_LLONG) && defined(BN_DIV2W) */
+
+#ifdef BN_LLONG
+BN_ULONG bn_add_words(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n)
+ {
+ BN_ULLONG ll=0;
+
+ assert(n >= 0);
+ if (n <= 0) return((BN_ULONG)0);
+
+ for (;;)
+ {
+ ll+=(BN_ULLONG)a[0]+b[0];
+ r[0]=(BN_ULONG)ll&BN_MASK2;
+ ll>>=BN_BITS2;
+ if (--n <= 0) break;
+
+ ll+=(BN_ULLONG)a[1]+b[1];
+ r[1]=(BN_ULONG)ll&BN_MASK2;
+ ll>>=BN_BITS2;
+ if (--n <= 0) break;
+
+ ll+=(BN_ULLONG)a[2]+b[2];
+ r[2]=(BN_ULONG)ll&BN_MASK2;
+ ll>>=BN_BITS2;
+ if (--n <= 0) break;
+
+ ll+=(BN_ULLONG)a[3]+b[3];
+ r[3]=(BN_ULONG)ll&BN_MASK2;
+ ll>>=BN_BITS2;
+ if (--n <= 0) break;
+
+ a+=4;
+ b+=4;
+ r+=4;
+ }
+ return((BN_ULONG)ll);
+ }
+#else /* !BN_LLONG */
+BN_ULONG bn_add_words(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n)
+ {
+ BN_ULONG c,l,t;
+
+ assert(n >= 0);
+ if (n <= 0) return((BN_ULONG)0);
+
+ c=0;
+ for (;;)
+ {
+ t=a[0];
+ t=(t+c)&BN_MASK2;
+ c=(t < c);
+ l=(t+b[0])&BN_MASK2;
+ c+=(l < t);
+ r[0]=l;
+ if (--n <= 0) break;
+
+ t=a[1];
+ t=(t+c)&BN_MASK2;
+ c=(t < c);
+ l=(t+b[1])&BN_MASK2;
+ c+=(l < t);
+ r[1]=l;
+ if (--n <= 0) break;
+
+ t=a[2];
+ t=(t+c)&BN_MASK2;
+ c=(t < c);
+ l=(t+b[2])&BN_MASK2;
+ c+=(l < t);
+ r[2]=l;
+ if (--n <= 0) break;
+
+ t=a[3];
+ t=(t+c)&BN_MASK2;
+ c=(t < c);
+ l=(t+b[3])&BN_MASK2;
+ c+=(l < t);
+ r[3]=l;
+ if (--n <= 0) break;
+
+ a+=4;
+ b+=4;
+ r+=4;
+ }
+ return((BN_ULONG)c);
+ }
+#endif /* !BN_LLONG */
diff --git a/package/network/services/ead/src/tinysrp/.svn/text-base/bn_ctx.c.svn-base b/package/network/services/ead/src/tinysrp/.svn/text-base/bn_ctx.c.svn-base
new file mode 100644
index 0000000..20a6605
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/.svn/text-base/bn_ctx.c.svn-base
@@ -0,0 +1,142 @@
+/* crypto/bn/bn_ctx.c */
+/* Written by Ulf Moeller for the OpenSSL project. */
+/* ====================================================================
+ * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
+ *
+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
+ * endorse or promote products derived from this software without
+ * prior written permission. For written permission, please contact
+ * openssl-core@openssl.org.
+ *
+ * 5. Products derived from this software may not be called "OpenSSL"
+ * nor may "OpenSSL" appear in their names without prior written
+ * permission of the OpenSSL Project.
+ *
+ * 6. Redistributions of any form whatsoever must retain the following
+ * acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
+ * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This product includes cryptographic software written by Eric Young
+ * (eay@cryptsoft.com). This product includes software written by Tim
+ * Hudson (tjh@cryptsoft.com).
+ *
+ */
+
+#ifndef BN_CTX_DEBUG
+# undef NDEBUG /* avoid conflicting definitions */
+# define NDEBUG
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <bn.h>
+
+
+BN_CTX *BN_CTX_new(void)
+ {
+ BN_CTX *ret;
+
+ ret=(BN_CTX *)malloc(sizeof(BN_CTX));
+ if (ret == NULL)
+ {
+ return(NULL);
+ }
+
+ BN_CTX_init(ret);
+ ret->flags=BN_FLG_MALLOCED;
+ return(ret);
+ }
+
+void BN_CTX_init(BN_CTX *ctx)
+ {
+ int i;
+ ctx->tos = 0;
+ ctx->flags = 0;
+ ctx->depth = 0;
+ ctx->too_many = 0;
+ for (i = 0; i < BN_CTX_NUM; i++)
+ BN_init(&(ctx->bn[i]));
+ }
+
+void BN_CTX_free(BN_CTX *ctx)
+ {
+ int i;
+
+ if (ctx == NULL) return;
+ assert(ctx->depth == 0);
+
+ for (i=0; i < BN_CTX_NUM; i++)
+ BN_clear_free(&(ctx->bn[i]));
+ if (ctx->flags & BN_FLG_MALLOCED)
+ free(ctx);
+ }
+
+void BN_CTX_start(BN_CTX *ctx)
+ {
+ if (ctx->depth < BN_CTX_NUM_POS)
+ ctx->pos[ctx->depth] = ctx->tos;
+ ctx->depth++;
+ }
+
+BIGNUM *BN_CTX_get(BN_CTX *ctx)
+ {
+ if (ctx->depth > BN_CTX_NUM_POS || ctx->tos >= BN_CTX_NUM)
+ {
+ if (!ctx->too_many)
+ {
+ /* disable error code until BN_CTX_end is called: */
+ ctx->too_many = 1;
+ }
+ return NULL;
+ }
+ return (&(ctx->bn[ctx->tos++]));
+ }
+
+void BN_CTX_end(BN_CTX *ctx)
+ {
+ if (ctx == NULL) return;
+ assert(ctx->depth > 0);
+ if (ctx->depth == 0)
+ /* should never happen, but we can tolerate it if not in
+ * debug mode (could be a 'goto err' in the calling function
+ * before BN_CTX_start was reached) */
+ BN_CTX_start(ctx);
+
+ ctx->too_many = 0;
+ ctx->depth--;
+ if (ctx->depth < BN_CTX_NUM_POS)
+ ctx->tos = ctx->pos[ctx->depth];
+ }
diff --git a/package/network/services/ead/src/tinysrp/.svn/text-base/bn_div.c.svn-base b/package/network/services/ead/src/tinysrp/.svn/text-base/bn_div.c.svn-base
new file mode 100644
index 0000000..fd21913
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/.svn/text-base/bn_div.c.svn-base
@@ -0,0 +1,378 @@
+/* crypto/bn/bn_div.c */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#include <stdio.h>
+#include "bn_lcl.h"
+
+#define NO_ASM
+
+/* The old slow way */
+#if 0
+int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d,
+ BN_CTX *ctx)
+ {
+ int i,nm,nd;
+ int ret = 0;
+ BIGNUM *D;
+
+ bn_check_top(m);
+ bn_check_top(d);
+ if (BN_is_zero(d))
+ {
+ return(0);
+ }
+
+ if (BN_ucmp(m,d) < 0)
+ {
+ if (rem != NULL)
+ { if (BN_copy(rem,m) == NULL) return(0); }
+ if (dv != NULL) BN_zero(dv);
+ return(1);
+ }
+
+ BN_CTX_start(ctx);
+ D = BN_CTX_get(ctx);
+ if (dv == NULL) dv = BN_CTX_get(ctx);
+ if (rem == NULL) rem = BN_CTX_get(ctx);
+ if (D == NULL || dv == NULL || rem == NULL)
+ goto end;
+
+ nd=BN_num_bits(d);
+ nm=BN_num_bits(m);
+ if (BN_copy(D,d) == NULL) goto end;
+ if (BN_copy(rem,m) == NULL) goto end;
+
+ /* The next 2 are needed so we can do a dv->d[0]|=1 later
+ * since BN_lshift1 will only work once there is a value :-) */
+ BN_zero(dv);
+ bn_wexpand(dv,1);
+ dv->top=1;
+
+ if (!BN_lshift(D,D,nm-nd)) goto end;
+ for (i=nm-nd; i>=0; i--)
+ {
+ if (!BN_lshift1(dv,dv)) goto end;
+ if (BN_ucmp(rem,D) >= 0)
+ {
+ dv->d[0]|=1;
+ if (!BN_usub(rem,rem,D)) goto end;
+ }
+/* CAN IMPROVE (and have now :=) */
+ if (!BN_rshift1(D,D)) goto end;
+ }
+ rem->neg=BN_is_zero(rem)?0:m->neg;
+ dv->neg=m->neg^d->neg;
+ ret = 1;
+ end:
+ BN_CTX_end(ctx);
+ return(ret);
+ }
+
+#else
+
+#if !defined(NO_ASM) && !defined(NO_INLINE_ASM) && !defined(PEDANTIC) && !defined(BN_DIV3W)
+# if defined(__GNUC__) && __GNUC__>=2
+# if defined(__i386)
+ /*
+ * There were two reasons for implementing this template:
+ * - GNU C generates a call to a function (__udivdi3 to be exact)
+ * in reply to ((((BN_ULLONG)n0)<<BN_BITS2)|n1)/d0 (I fail to
+ * understand why...);
+ * - divl doesn't only calculate quotient, but also leaves
+ * remainder in %edx which we can definitely use here:-)
+ *
+ * <appro@fy.chalmers.se>
+ */
+# define bn_div_words(n0,n1,d0) \
+ ({ asm volatile ( \
+ "divl %4" \
+ : "=a"(q), "=d"(rem) \
+ : "a"(n1), "d"(n0), "g"(d0) \
+ : "cc"); \
+ q; \
+ })
+# define REMAINDER_IS_ALREADY_CALCULATED
+# endif /* __<cpu> */
+# endif /* __GNUC__ */
+#endif /* NO_ASM */
+
+int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
+ BN_CTX *ctx)
+ {
+ int norm_shift,i,j,loop;
+ BIGNUM *tmp,wnum,*snum,*sdiv,*res;
+ BN_ULONG *resp,*wnump;
+ BN_ULONG d0,d1;
+ int num_n,div_n;
+
+ bn_check_top(num);
+ bn_check_top(divisor);
+
+ if (BN_is_zero(divisor))
+ {
+ return(0);
+ }
+
+ if (BN_ucmp(num,divisor) < 0)
+ {
+ if (rm != NULL)
+ { if (BN_copy(rm,num) == NULL) return(0); }
+ if (dv != NULL) BN_zero(dv);
+ return(1);
+ }
+
+ BN_CTX_start(ctx);
+ tmp=BN_CTX_get(ctx);
+ tmp->neg=0;
+ snum=BN_CTX_get(ctx);
+ sdiv=BN_CTX_get(ctx);
+ if (dv == NULL)
+ res=BN_CTX_get(ctx);
+ else res=dv;
+ if (res == NULL) goto err;
+
+ /* First we normalise the numbers */
+ norm_shift=BN_BITS2-((BN_num_bits(divisor))%BN_BITS2);
+ BN_lshift(sdiv,divisor,norm_shift);
+ sdiv->neg=0;
+ norm_shift+=BN_BITS2;
+ BN_lshift(snum,num,norm_shift);
+ snum->neg=0;
+ div_n=sdiv->top;
+ num_n=snum->top;
+ loop=num_n-div_n;
+
+ /* Lets setup a 'window' into snum
+ * This is the part that corresponds to the current
+ * 'area' being divided */
+ BN_init(&wnum);
+ wnum.d= &(snum->d[loop]);
+ wnum.top= div_n;
+ wnum.dmax= snum->dmax+1; /* a bit of a lie */
+
+ /* Get the top 2 words of sdiv */
+ /* i=sdiv->top; */
+ d0=sdiv->d[div_n-1];
+ d1=(div_n == 1)?0:sdiv->d[div_n-2];
+
+ /* pointer to the 'top' of snum */
+ wnump= &(snum->d[num_n-1]);
+
+ /* Setup to 'res' */
+ res->neg= (num->neg^divisor->neg);
+ if (!bn_wexpand(res,(loop+1))) goto err;
+ res->top=loop;
+ resp= &(res->d[loop-1]);
+
+ /* space for temp */
+ if (!bn_wexpand(tmp,(div_n+1))) goto err;
+
+ if (BN_ucmp(&wnum,sdiv) >= 0)
+ {
+ if (!BN_usub(&wnum,&wnum,sdiv)) goto err;
+ *resp=1;
+ res->d[res->top-1]=1;
+ }
+ else
+ res->top--;
+ resp--;
+
+ for (i=0; i<loop-1; i++)
+ {
+ BN_ULONG q,l0;
+#ifdef BN_DIV3W
+ q=bn_div_3_words(wnump,d1,d0);
+#else
+ BN_ULONG n0,n1,rem=0;
+
+ n0=wnump[0];
+ n1=wnump[-1];
+ if (n0 == d0)
+ q=BN_MASK2;
+ else /* n0 < d0 */
+ {
+#ifdef BN_LLONG
+ BN_ULLONG t2;
+
+#if defined(BN_LLONG) && defined(BN_DIV2W) && !defined(bn_div_words)
+ q=(BN_ULONG)(((((BN_ULLONG)n0)<<BN_BITS2)|n1)/d0);
+#else
+ q=bn_div_words(n0,n1,d0);
+#endif
+
+#ifndef REMAINDER_IS_ALREADY_CALCULATED
+ /*
+ * rem doesn't have to be BN_ULLONG. The least we
+ * know it's less that d0, isn't it?
+ */
+ rem=(n1-q*d0)&BN_MASK2;
+#endif
+ t2=(BN_ULLONG)d1*q;
+
+ for (;;)
+ {
+ if (t2 <= ((((BN_ULLONG)rem)<<BN_BITS2)|wnump[-2]))
+ break;
+ q--;
+ rem += d0;
+ if (rem < d0) break; /* don't let rem overflow */
+ t2 -= d1;
+ }
+#else /* !BN_LLONG */
+ BN_ULONG t2l,t2h,ql,qh;
+
+ q=bn_div_words(n0,n1,d0);
+#ifndef REMAINDER_IS_ALREADY_CALCULATED
+ rem=(n1-q*d0)&BN_MASK2;
+#endif
+
+#ifdef BN_UMULT_HIGH
+ t2l = d1 * q;
+ t2h = BN_UMULT_HIGH(d1,q);
+#else
+ t2l=LBITS(d1); t2h=HBITS(d1);
+ ql =LBITS(q); qh =HBITS(q);
+ mul64(t2l,t2h,ql,qh); /* t2=(BN_ULLONG)d1*q; */
+#endif
+
+ for (;;)
+ {
+ if ((t2h < rem) ||
+ ((t2h == rem) && (t2l <= wnump[-2])))
+ break;
+ q--;
+ rem += d0;
+ if (rem < d0) break; /* don't let rem overflow */
+ if (t2l < d1) t2h--; t2l -= d1;
+ }
+#endif /* !BN_LLONG */
+ }
+#endif /* !BN_DIV3W */
+
+ l0=bn_mul_words(tmp->d,sdiv->d,div_n,q);
+ wnum.d--; wnum.top++;
+ tmp->d[div_n]=l0;
+ for (j=div_n+1; j>0; j--)
+ if (tmp->d[j-1]) break;
+ tmp->top=j;
+
+ j=wnum.top;
+ BN_sub(&wnum,&wnum,tmp);
+
+ snum->top=snum->top+wnum.top-j;
+
+ if (wnum.neg)
+ {
+ q--;
+ j=wnum.top;
+ BN_add(&wnum,&wnum,sdiv);
+ snum->top+=wnum.top-j;
+ }
+ *(resp--)=q;
+ wnump--;
+ }
+ if (rm != NULL)
+ {
+ BN_rshift(rm,snum,norm_shift);
+ rm->neg=num->neg;
+ }
+ BN_CTX_end(ctx);
+ return(1);
+err:
+ BN_CTX_end(ctx);
+ return(0);
+ }
+
+#endif
+
+/* rem != m */
+int BN_mod(BIGNUM *rem, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx)
+ {
+#if 0 /* The old slow way */
+ int i,nm,nd;
+ BIGNUM *dv;
+
+ if (BN_ucmp(m,d) < 0)
+ return((BN_copy(rem,m) == NULL)?0:1);
+
+ BN_CTX_start(ctx);
+ dv=BN_CTX_get(ctx);
+
+ if (!BN_copy(rem,m)) goto err;
+
+ nm=BN_num_bits(rem);
+ nd=BN_num_bits(d);
+ if (!BN_lshift(dv,d,nm-nd)) goto err;
+ for (i=nm-nd; i>=0; i--)
+ {
+ if (BN_cmp(rem,dv) >= 0)
+ {
+ if (!BN_sub(rem,rem,dv)) goto err;
+ }
+ if (!BN_rshift1(dv,dv)) goto err;
+ }
+ BN_CTX_end(ctx);
+ return(1);
+ err:
+ BN_CTX_end(ctx);
+ return(0);
+#else
+ return(BN_div(NULL,rem,m,d,ctx));
+#endif
+ }
+
diff --git a/package/network/services/ead/src/tinysrp/.svn/text-base/bn_exp.c.svn-base b/package/network/services/ead/src/tinysrp/.svn/text-base/bn_exp.c.svn-base
new file mode 100644
index 0000000..09afb79
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/.svn/text-base/bn_exp.c.svn-base
@@ -0,0 +1,395 @@
+/* crypto/bn/bn_exp.c */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+/* ====================================================================
+ * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
+ *
+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
+ * endorse or promote products derived from this software without
+ * prior written permission. For written permission, please contact
+ * openssl-core@openssl.org.
+ *
+ * 5. Products derived from this software may not be called "OpenSSL"
+ * nor may "OpenSSL" appear in their names without prior written
+ * permission of the OpenSSL Project.
+ *
+ * 6. Redistributions of any form whatsoever must retain the following
+ * acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
+ * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This product includes cryptographic software written by Eric Young
+ * (eay@cryptsoft.com). This product includes software written by Tim
+ * Hudson (tjh@cryptsoft.com).
+ *
+ */
+
+
+#include <stdio.h>
+#include "bn_lcl.h"
+
+#define TABLE_SIZE 32
+
+/* slow but works */
+int BN_mod_mul(BIGNUM *ret, BIGNUM *a, BIGNUM *b, const BIGNUM *m, BN_CTX *ctx)
+ {
+ BIGNUM *t;
+ int r=0;
+
+ bn_check_top(a);
+ bn_check_top(b);
+ bn_check_top(m);
+
+ BN_CTX_start(ctx);
+ if ((t = BN_CTX_get(ctx)) == NULL) goto err;
+ if (a == b)
+ { if (!BN_sqr(t,a,ctx)) goto err; }
+ else
+ { if (!BN_mul(t,a,b,ctx)) goto err; }
+ if (!BN_mod(ret,t,m,ctx)) goto err;
+ r=1;
+err:
+ BN_CTX_end(ctx);
+ return(r);
+ }
+
+int BN_mod_exp(BIGNUM *r, BIGNUM *a, const BIGNUM *p, const BIGNUM *m,
+ BN_CTX *ctx)
+ {
+ int ret;
+
+ bn_check_top(a);
+ bn_check_top(p);
+ bn_check_top(m);
+
+#ifdef MONT_MUL_MOD
+ /* I have finally been able to take out this pre-condition of
+ * the top bit being set. It was caused by an error in BN_div
+ * with negatives. There was also another problem when for a^b%m
+ * a >= m. eay 07-May-97 */
+/* if ((m->d[m->top-1]&BN_TBIT) && BN_is_odd(m)) */
+
+ if (BN_is_odd(m))
+ {
+ if (a->top == 1)
+ {
+ BN_ULONG A = a->d[0];
+ ret=BN_mod_exp_mont_word(r,A,p,m,ctx,NULL);
+ }
+ else
+ ret=BN_mod_exp_mont(r,a,p,m,ctx,NULL);
+ }
+ else
+#endif
+#ifdef RECP_MUL_MOD
+ { ret=BN_mod_exp_recp(r,a,p,m,ctx); }
+#else
+ { ret=BN_mod_exp_simple(r,a,p,m,ctx); }
+#endif
+
+ return(ret);
+ }
+
+
+#ifdef RECP_MUL_MOD
+int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
+ const BIGNUM *m, BN_CTX *ctx)
+ {
+ int i,j,bits,ret=0,wstart,wend,window,wvalue;
+ int start=1,ts=0;
+ BIGNUM *aa;
+ BIGNUM val[TABLE_SIZE];
+ BN_RECP_CTX recp;
+
+ bits=BN_num_bits(p);
+
+ if (bits == 0)
+ {
+ BN_one(r);
+ return(1);
+ }
+
+ BN_CTX_start(ctx);
+ if ((aa = BN_CTX_get(ctx)) == NULL) goto err;
+
+ BN_RECP_CTX_init(&recp);
+ if (BN_RECP_CTX_set(&recp,m,ctx) <= 0) goto err;
+
+ BN_init(&(val[0]));
+ ts=1;
+
+ if (!BN_mod(&(val[0]),a,m,ctx)) goto err; /* 1 */
+
+ window = BN_window_bits_for_exponent_size(bits);
+ if (window > 1)
+ {
+ if (!BN_mod_mul_reciprocal(aa,&(val[0]),&(val[0]),&recp,ctx))
+ goto err; /* 2 */
+ j=1<<(window-1);
+ for (i=1; i<j; i++)
+ {
+ BN_init(&val[i]);
+ if (!BN_mod_mul_reciprocal(&(val[i]),&(val[i-1]),aa,&recp,ctx))
+ goto err;
+ }
+ ts=i;
+ }
+
+ start=1; /* This is used to avoid multiplication etc
+ * when there is only the value '1' in the
+ * buffer. */
+ wvalue=0; /* The 'value' of the window */
+ wstart=bits-1; /* The top bit of the window */
+ wend=0; /* The bottom bit of the window */
+
+ if (!BN_one(r)) goto err;
+
+ for (;;)
+ {
+ if (BN_is_bit_set(p,wstart) == 0)
+ {
+ if (!start)
+ if (!BN_mod_mul_reciprocal(r,r,r,&recp,ctx))
+ goto err;
+ if (wstart == 0) break;
+ wstart--;
+ continue;
+ }
+ /* We now have wstart on a 'set' bit, we now need to work out
+ * how bit a window to do. To do this we need to scan
+ * forward until the last set bit before the end of the
+ * window */
+ j=wstart;
+ wvalue=1;
+ wend=0;
+ for (i=1; i<window; i++)
+ {
+ if (wstart-i < 0) break;
+ if (BN_is_bit_set(p,wstart-i))
+ {
+ wvalue<<=(i-wend);
+ wvalue|=1;
+ wend=i;
+ }
+ }
+
+ /* wend is the size of the current window */
+ j=wend+1;
+ /* add the 'bytes above' */
+ if (!start)
+ for (i=0; i<j; i++)
+ {
+ if (!BN_mod_mul_reciprocal(r,r,r,&recp,ctx))
+ goto err;
+ }
+
+ /* wvalue will be an odd number < 2^window */
+ if (!BN_mod_mul_reciprocal(r,r,&(val[wvalue>>1]),&recp,ctx))
+ goto err;
+
+ /* move the 'window' down further */
+ wstart-=wend+1;
+ wvalue=0;
+ start=0;
+ if (wstart < 0) break;
+ }
+ ret=1;
+err:
+ BN_CTX_end(ctx);
+ for (i=0; i<ts; i++)
+ BN_clear_free(&(val[i]));
+ BN_RECP_CTX_free(&recp);
+ return(ret);
+ }
+#else
+
+/* The old fallback, simple version :-) */
+int BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
+ const BIGNUM *m, BN_CTX *ctx)
+ {
+ int i,j,bits,ret=0,wstart,wend,window,wvalue,ts=0;
+ int start=1;
+ BIGNUM *d;
+ BIGNUM val[TABLE_SIZE];
+
+ bits=BN_num_bits(p);
+
+ if (bits == 0)
+ {
+ BN_one(r);
+ return(1);
+ }
+
+ BN_CTX_start(ctx);
+ if ((d = BN_CTX_get(ctx)) == NULL) goto err;
+
+ BN_init(&(val[0]));
+ ts=1;
+ if (!BN_mod(&(val[0]),a,m,ctx)) goto err; /* 1 */
+
+ window = BN_window_bits_for_exponent_size(bits);
+ if (window > 1)
+ {
+ if (!BN_mod_mul(d,&(val[0]),&(val[0]),m,ctx))
+ goto err; /* 2 */
+ j=1<<(window-1);
+ for (i=1; i<j; i++)
+ {
+ BN_init(&(val[i]));
+ if (!BN_mod_mul(&(val[i]),&(val[i-1]),d,m,ctx))
+ goto err;
+ }
+ ts=i;
+ }
+
+ start=1; /* This is used to avoid multiplication etc
+ * when there is only the value '1' in the
+ * buffer. */
+ wvalue=0; /* The 'value' of the window */
+ wstart=bits-1; /* The top bit of the window */
+ wend=0; /* The bottom bit of the window */
+
+ if (!BN_one(r)) goto err;
+
+ for (;;)
+ {
+ if (BN_is_bit_set(p,wstart) == 0)
+ {
+ if (!start)
+ if (!BN_mod_mul(r,r,r,m,ctx))
+ goto err;
+ if (wstart == 0) break;
+ wstart--;
+ continue;
+ }
+ /* We now have wstart on a 'set' bit, we now need to work out
+ * how bit a window to do. To do this we need to scan
+ * forward until the last set bit before the end of the
+ * window */
+ j=wstart;
+ wvalue=1;
+ wend=0;
+ for (i=1; i<window; i++)
+ {
+ if (wstart-i < 0) break;
+ if (BN_is_bit_set(p,wstart-i))
+ {
+ wvalue<<=(i-wend);
+ wvalue|=1;
+ wend=i;
+ }
+ }
+
+ /* wend is the size of the current window */
+ j=wend+1;
+ /* add the 'bytes above' */
+ if (!start)
+ for (i=0; i<j; i++)
+ {
+ if (!BN_mod_mul(r,r,r,m,ctx))
+ goto err;
+ }
+
+ /* wvalue will be an odd number < 2^window */
+ if (!BN_mod_mul(r,r,&(val[wvalue>>1]),m,ctx))
+ goto err;
+
+ /* move the 'window' down further */
+ wstart-=wend+1;
+ wvalue=0;
+ start=0;
+ if (wstart < 0) break;
+ }
+ ret=1;
+err:
+ BN_CTX_end(ctx);
+ for (i=0; i<ts; i++)
+ BN_clear_free(&(val[i]));
+ return(ret);
+ }
+#endif
diff --git a/package/network/services/ead/src/tinysrp/.svn/text-base/bn_lcl.h.svn-base b/package/network/services/ead/src/tinysrp/.svn/text-base/bn_lcl.h.svn-base
new file mode 100644
index 0000000..129ad65
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/.svn/text-base/bn_lcl.h.svn-base
@@ -0,0 +1,419 @@
+/* crypto/bn/bn_lcl.h */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+/* ====================================================================
+ * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
+ *
+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
+ * endorse or promote products derived from this software without
+ * prior written permission. For written permission, please contact
+ * openssl-core@openssl.org.
+ *
+ * 5. Products derived from this software may not be called "OpenSSL"
+ * nor may "OpenSSL" appear in their names without prior written
+ * permission of the OpenSSL Project.
+ *
+ * 6. Redistributions of any form whatsoever must retain the following
+ * acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
+ * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This product includes cryptographic software written by Eric Young
+ * (eay@cryptsoft.com). This product includes software written by Tim
+ * Hudson (tjh@cryptsoft.com).
+ *
+ */
+
+#ifndef HEADER_BN_LCL_H
+#define HEADER_BN_LCL_H
+
+#include <bn.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/*
+ * BN_window_bits_for_exponent_size -- macro for sliding window mod_exp functions
+ *
+ *
+ * For window size 'w' (w >= 2) and a random 'b' bits exponent,
+ * the number of multiplications is a constant plus on average
+ *
+ * 2^(w-1) + (b-w)/(w+1);
+ *
+ * here 2^(w-1) is for precomputing the table (we actually need
+ * entries only for windows that have the lowest bit set), and
+ * (b-w)/(w+1) is an approximation for the expected number of
+ * w-bit windows, not counting the first one.
+ *
+ * Thus we should use
+ *
+ * w >= 6 if b > 671
+ * w = 5 if 671 > b > 239
+ * w = 4 if 239 > b > 79
+ * w = 3 if 79 > b > 23
+ * w <= 2 if 23 > b
+ *
+ * (with draws in between). Very small exponents are often selected
+ * with low Hamming weight, so we use w = 1 for b <= 23.
+ */
+#if 1
+#define BN_window_bits_for_exponent_size(b) \
+ ((b) > 671 ? 6 : \
+ (b) > 239 ? 5 : \
+ (b) > 79 ? 4 : \
+ (b) > 23 ? 3 : 1)
+#else
+/* Old SSLeay/OpenSSL table.
+ * Maximum window size was 5, so this table differs for b==1024;
+ * but it coincides for other interesting values (b==160, b==512).
+ */
+#define BN_window_bits_for_exponent_size(b) \
+ ((b) > 255 ? 5 : \
+ (b) > 127 ? 4 : \
+ (b) > 17 ? 3 : 1)
+#endif
+
+
+
+/* Pentium pro 16,16,16,32,64 */
+/* Alpha 16,16,16,16.64 */
+#define BN_MULL_SIZE_NORMAL (16) /* 32 */
+#define BN_MUL_RECURSIVE_SIZE_NORMAL (16) /* 32 less than */
+#define BN_SQR_RECURSIVE_SIZE_NORMAL (16) /* 32 */
+#define BN_MUL_LOW_RECURSIVE_SIZE_NORMAL (32) /* 32 */
+#define BN_MONT_CTX_SET_SIZE_WORD (64) /* 32 */
+
+#if !defined(NO_ASM) && !defined(NO_INLINE_ASM) && !defined(PEDANTIC)
+/*
+ * BN_UMULT_HIGH section.
+ *
+ * No, I'm not trying to overwhelm you when stating that the
+ * product of N-bit numbers is 2*N bits wide:-) No, I don't expect
+ * you to be impressed when I say that if the compiler doesn't
+ * support 2*N integer type, then you have to replace every N*N
+ * multiplication with 4 (N/2)*(N/2) accompanied by some shifts
+ * and additions which unavoidably results in severe performance
+ * penalties. Of course provided that the hardware is capable of
+ * producing 2*N result... That's when you normally start
+ * considering assembler implementation. However! It should be
+ * pointed out that some CPUs (most notably Alpha, PowerPC and
+ * upcoming IA-64 family:-) provide *separate* instruction
+ * calculating the upper half of the product placing the result
+ * into a general purpose register. Now *if* the compiler supports
+ * inline assembler, then it's not impossible to implement the
+ * "bignum" routines (and have the compiler optimize 'em)
+ * exhibiting "native" performance in C. That's what BN_UMULT_HIGH
+ * macro is about:-)
+ *
+ * <appro@fy.chalmers.se>
+ */
+# if defined(__alpha) && (defined(SIXTY_FOUR_BIT_LONG) || defined(SIXTY_FOUR_BIT))
+# if defined(__DECC)
+# include <c_asm.h>
+# define BN_UMULT_HIGH(a,b) (BN_ULONG)asm("umulh %a0,%a1,%v0",(a),(b))
+# elif defined(__GNUC__)
+# define BN_UMULT_HIGH(a,b) ({ \
+ register BN_ULONG ret; \
+ asm ("umulh %1,%2,%0" \
+ : "=r"(ret) \
+ : "r"(a), "r"(b)); \
+ ret; })
+# endif /* compiler */
+# elif defined(_ARCH_PPC) && defined(__64BIT__) && defined(SIXTY_FOUR_BIT_LONG)
+# if defined(__GNUC__)
+# define BN_UMULT_HIGH(a,b) ({ \
+ register BN_ULONG ret; \
+ asm ("mulhdu %0,%1,%2" \
+ : "=r"(ret) \
+ : "r"(a), "r"(b)); \
+ ret; })
+# endif /* compiler */
+# endif /* cpu */
+#endif /* NO_ASM */
+
+/*************************************************************
+ * Using the long long type
+ */
+#define Lw(t) (((BN_ULONG)(t))&BN_MASK2)
+#define Hw(t) (((BN_ULONG)((t)>>BN_BITS2))&BN_MASK2)
+
+/* This is used for internal error checking and is not normally used */
+#ifdef BN_DEBUG
+# include <assert.h>
+# define bn_check_top(a) assert ((a)->top >= 0 && (a)->top <= (a)->dmax);
+#else
+# define bn_check_top(a)
+#endif
+
+/* This macro is to add extra stuff for development checking */
+#ifdef BN_DEBUG
+#define bn_set_max(r) ((r)->max=(r)->top,BN_set_flags((r),BN_FLG_STATIC_DATA))
+#else
+#define bn_set_max(r)
+#endif
+
+/* These macros are used to 'take' a section of a bignum for read only use */
+#define bn_set_low(r,a,n) \
+ { \
+ (r)->top=((a)->top > (n))?(n):(a)->top; \
+ (r)->d=(a)->d; \
+ (r)->neg=(a)->neg; \
+ (r)->flags|=BN_FLG_STATIC_DATA; \
+ bn_set_max(r); \
+ }
+
+#define bn_set_high(r,a,n) \
+ { \
+ if ((a)->top > (n)) \
+ { \
+ (r)->top=(a)->top-n; \
+ (r)->d= &((a)->d[n]); \
+ } \
+ else \
+ (r)->top=0; \
+ (r)->neg=(a)->neg; \
+ (r)->flags|=BN_FLG_STATIC_DATA; \
+ bn_set_max(r); \
+ }
+
+#ifdef BN_LLONG
+#define mul_add(r,a,w,c) { \
+ BN_ULLONG t; \
+ t=(BN_ULLONG)w * (a) + (r) + (c); \
+ (r)= Lw(t); \
+ (c)= Hw(t); \
+ }
+
+#define mul(r,a,w,c) { \
+ BN_ULLONG t; \
+ t=(BN_ULLONG)w * (a) + (c); \
+ (r)= Lw(t); \
+ (c)= Hw(t); \
+ }
+
+#define sqr(r0,r1,a) { \
+ BN_ULLONG t; \
+ t=(BN_ULLONG)(a)*(a); \
+ (r0)=Lw(t); \
+ (r1)=Hw(t); \
+ }
+
+#elif defined(BN_UMULT_HIGH)
+#define mul_add(r,a,w,c) { \
+ BN_ULONG high,low,ret,tmp=(a); \
+ ret = (r); \
+ high= BN_UMULT_HIGH(w,tmp); \
+ ret += (c); \
+ low = (w) * tmp; \
+ (c) = (ret<(c))?1:0; \
+ (c) += high; \
+ ret += low; \
+ (c) += (ret<low)?1:0; \
+ (r) = ret; \
+ }
+
+#define mul(r,a,w,c) { \
+ BN_ULONG high,low,ret,ta=(a); \
+ low = (w) * ta; \
+ high= BN_UMULT_HIGH(w,ta); \
+ ret = low + (c); \
+ (c) = high; \
+ (c) += (ret<low)?1:0; \
+ (r) = ret; \
+ }
+
+#define sqr(r0,r1,a) { \
+ BN_ULONG tmp=(a); \
+ (r0) = tmp * tmp; \
+ (r1) = BN_UMULT_HIGH(tmp,tmp); \
+ }
+
+#else
+/*************************************************************
+ * No long long type
+ */
+
+#define LBITS(a) ((a)&BN_MASK2l)
+#define HBITS(a) (((a)>>BN_BITS4)&BN_MASK2l)
+#define L2HBITS(a) ((BN_ULONG)((a)&BN_MASK2l)<<BN_BITS4)
+
+#define LLBITS(a) ((a)&BN_MASKl)
+#define LHBITS(a) (((a)>>BN_BITS2)&BN_MASKl)
+#define LL2HBITS(a) ((BN_ULLONG)((a)&BN_MASKl)<<BN_BITS2)
+
+#define mul64(l,h,bl,bh) \
+ { \
+ BN_ULONG m,m1,lt,ht; \
+ \
+ lt=l; \
+ ht=h; \
+ m =(bh)*(lt); \
+ lt=(bl)*(lt); \
+ m1=(bl)*(ht); \
+ ht =(bh)*(ht); \
+ m=(m+m1)&BN_MASK2; if (m < m1) ht+=L2HBITS(1L); \
+ ht+=HBITS(m); \
+ m1=L2HBITS(m); \
+ lt=(lt+m1)&BN_MASK2; if (lt < m1) ht++; \
+ (l)=lt; \
+ (h)=ht; \
+ }
+
+#define sqr64(lo,ho,in) \
+ { \
+ BN_ULONG l,h,m; \
+ \
+ h=(in); \
+ l=LBITS(h); \
+ h=HBITS(h); \
+ m =(l)*(h); \
+ l*=l; \
+ h*=h; \
+ h+=(m&BN_MASK2h1)>>(BN_BITS4-1); \
+ m =(m&BN_MASK2l)<<(BN_BITS4+1); \
+ l=(l+m)&BN_MASK2; if (l < m) h++; \
+ (lo)=l; \
+ (ho)=h; \
+ }
+
+#define mul_add(r,a,bl,bh,c) { \
+ BN_ULONG l,h; \
+ \
+ h= (a); \
+ l=LBITS(h); \
+ h=HBITS(h); \
+ mul64(l,h,(bl),(bh)); \
+ \
+ /* non-multiply part */ \
+ l=(l+(c))&BN_MASK2; if (l < (c)) h++; \
+ (c)=(r); \
+ l=(l+(c))&BN_MASK2; if (l < (c)) h++; \
+ (c)=h&BN_MASK2; \
+ (r)=l; \
+ }
+
+#define mul(r,a,bl,bh,c) { \
+ BN_ULONG l,h; \
+ \
+ h= (a); \
+ l=LBITS(h); \
+ h=HBITS(h); \
+ mul64(l,h,(bl),(bh)); \
+ \
+ /* non-multiply part */ \
+ l+=(c); if ((l&BN_MASK2) < (c)) h++; \
+ (c)=h&BN_MASK2; \
+ (r)=l&BN_MASK2; \
+ }
+#endif /* !BN_LLONG */
+
+void bn_mul_normal(BN_ULONG *r,BN_ULONG *a,int na,BN_ULONG *b,int nb);
+void bn_mul_comba8(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b);
+void bn_mul_comba4(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b);
+void bn_sqr_normal(BN_ULONG *r, BN_ULONG *a, int n, BN_ULONG *tmp);
+void bn_sqr_comba8(BN_ULONG *r,BN_ULONG *a);
+void bn_sqr_comba4(BN_ULONG *r,BN_ULONG *a);
+int bn_cmp_words(BN_ULONG *a,BN_ULONG *b,int n);
+void bn_mul_recursive(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b,int n2,BN_ULONG *t);
+void bn_mul_part_recursive(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b,
+ int tn, int n,BN_ULONG *t);
+void bn_sqr_recursive(BN_ULONG *r,BN_ULONG *a, int n2, BN_ULONG *t);
+void bn_mul_low_normal(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b, int n);
+void bn_mul_low_recursive(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b,int n2,
+ BN_ULONG *t);
+void bn_mul_high(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b,BN_ULONG *l,int n2,
+ BN_ULONG *t);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/package/network/services/ead/src/tinysrp/.svn/text-base/bn_lib.c.svn-base b/package/network/services/ead/src/tinysrp/.svn/text-base/bn_lib.c.svn-base
new file mode 100644
index 0000000..cfa0d75
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/.svn/text-base/bn_lib.c.svn-base
@@ -0,0 +1,576 @@
+/* crypto/bn/bn_lib.c */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#ifndef BN_DEBUG
+# undef NDEBUG /* avoid conflicting definitions */
+# define NDEBUG
+#endif
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "bn_lcl.h"
+
+const char *BN_version="Big Number";
+
+/* For a 32 bit machine
+ * 2 - 4 == 128
+ * 3 - 8 == 256
+ * 4 - 16 == 512
+ * 5 - 32 == 1024
+ * 6 - 64 == 2048
+ * 7 - 128 == 4096
+ * 8 - 256 == 8192
+ */
+static int bn_limit_bits=0;
+static int bn_limit_num=8; /* (1<<bn_limit_bits) */
+static int bn_limit_bits_low=0;
+static int bn_limit_num_low=8; /* (1<<bn_limit_bits_low) */
+static int bn_limit_bits_high=0;
+static int bn_limit_num_high=8; /* (1<<bn_limit_bits_high) */
+static int bn_limit_bits_mont=0;
+static int bn_limit_num_mont=8; /* (1<<bn_limit_bits_mont) */
+
+int BN_num_bits_word(BN_ULONG l)
+ {
+ static const char bits[256]={
+ 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,
+ 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
+ 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
+ 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
+ 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
+ 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
+ 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
+ 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
+ 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
+ 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
+ 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
+ };
+
+#if defined(SIXTY_FOUR_BIT_LONG)
+ if (l & 0xffffffff00000000L)
+ {
+ if (l & 0xffff000000000000L)
+ {
+ if (l & 0xff00000000000000L)
+ {
+ return(bits[(int)(l>>56)]+56);
+ }
+ else return(bits[(int)(l>>48)]+48);
+ }
+ else
+ {
+ if (l & 0x0000ff0000000000L)
+ {
+ return(bits[(int)(l>>40)]+40);
+ }
+ else return(bits[(int)(l>>32)]+32);
+ }
+ }
+ else
+#else
+#ifdef SIXTY_FOUR_BIT
+ if (l & 0xffffffff00000000LL)
+ {
+ if (l & 0xffff000000000000LL)
+ {
+ if (l & 0xff00000000000000LL)
+ {
+ return(bits[(int)(l>>56)]+56);
+ }
+ else return(bits[(int)(l>>48)]+48);
+ }
+ else
+ {
+ if (l & 0x0000ff0000000000LL)
+ {
+ return(bits[(int)(l>>40)]+40);
+ }
+ else return(bits[(int)(l>>32)]+32);
+ }
+ }
+ else
+#endif
+#endif
+ {
+#if defined(THIRTY_TWO_BIT) || defined(SIXTY_FOUR_BIT) || defined(SIXTY_FOUR_BIT_LONG)
+ if (l & 0xffff0000L)
+ {
+ if (l & 0xff000000L)
+ return(bits[(int)(l>>24L)]+24);
+ else return(bits[(int)(l>>16L)]+16);
+ }
+ else
+#endif
+ {
+#if defined(SIXTEEN_BIT) || defined(THIRTY_TWO_BIT) || defined(SIXTY_FOUR_BIT) || defined(SIXTY_FOUR_BIT_LONG)
+ if (l & 0xff00L)
+ return(bits[(int)(l>>8)]+8);
+ else
+#endif
+ return(bits[(int)(l )] );
+ }
+ }
+ }
+
+int BN_num_bits(const BIGNUM *a)
+ {
+ BN_ULONG l;
+ int i;
+
+ bn_check_top(a);
+
+ if (a->top == 0) return(0);
+ l=a->d[a->top-1];
+ assert(l != 0);
+ i=(a->top-1)*BN_BITS2;
+ return(i+BN_num_bits_word(l));
+ }
+
+void BN_clear_free(BIGNUM *a)
+ {
+ int i;
+
+ if (a == NULL) return;
+ if (a->d != NULL)
+ {
+ memset(a->d,0,a->dmax*sizeof(a->d[0]));
+ if (!(BN_get_flags(a,BN_FLG_STATIC_DATA)))
+ free(a->d);
+ }
+ i=BN_get_flags(a,BN_FLG_MALLOCED);
+ memset(a,0,sizeof(BIGNUM));
+ if (i)
+ free(a);
+ }
+
+void BN_free(BIGNUM *a)
+ {
+ if (a == NULL) return;
+ if ((a->d != NULL) && !(BN_get_flags(a,BN_FLG_STATIC_DATA)))
+ free(a->d);
+ a->flags|=BN_FLG_FREE; /* REMOVE? */
+ if (a->flags & BN_FLG_MALLOCED)
+ free(a);
+ }
+
+void BN_init(BIGNUM *a)
+ {
+ memset(a,0,sizeof(BIGNUM));
+ }
+
+BIGNUM *BN_new(void)
+ {
+ BIGNUM *ret;
+
+ if ((ret=(BIGNUM *)malloc(sizeof(BIGNUM))) == NULL)
+ {
+ return(NULL);
+ }
+ ret->flags=BN_FLG_MALLOCED;
+ ret->top=0;
+ ret->neg=0;
+ ret->dmax=0;
+ ret->d=NULL;
+ return(ret);
+ }
+
+/* This is an internal function that should not be used in applications.
+ * It ensures that 'b' has enough room for a 'words' word number number.
+ * It is mostly used by the various BIGNUM routines. If there is an error,
+ * NULL is returned. If not, 'b' is returned. */
+
+BIGNUM *bn_expand2(BIGNUM *b, int words)
+ {
+ BN_ULONG *A,*a;
+ const BN_ULONG *B;
+ int i;
+
+ bn_check_top(b);
+
+ if (words > b->dmax)
+ {
+ bn_check_top(b);
+ if (BN_get_flags(b,BN_FLG_STATIC_DATA))
+ {
+ return(NULL);
+ }
+ a=A=(BN_ULONG *)malloc(sizeof(BN_ULONG)*(words+1));
+ if (A == NULL)
+ {
+ return(NULL);
+ }
+#if 1
+ B=b->d;
+ /* Check if the previous number needs to be copied */
+ if (B != NULL)
+ {
+#if 0
+ /* This lot is an unrolled loop to copy b->top
+ * BN_ULONGs from B to A
+ */
+/*
+ * I have nothing against unrolling but it's usually done for
+ * several reasons, namely:
+ * - minimize percentage of decision making code, i.e. branches;
+ * - avoid cache trashing;
+ * - make it possible to schedule loads earlier;
+ * Now let's examine the code below. The cornerstone of C is
+ * "programmer is always right" and that's what we love it for:-)
+ * For this very reason C compilers have to be paranoid when it
+ * comes to data aliasing and assume the worst. Yeah, but what
+ * does it mean in real life? This means that loop body below will
+ * be compiled to sequence of loads immediately followed by stores
+ * as compiler assumes the worst, something in A==B+1 style. As a
+ * result CPU pipeline is going to starve for incoming data. Secondly
+ * if A and B happen to share same cache line such code is going to
+ * cause severe cache trashing. Both factors have severe impact on
+ * performance of modern CPUs and this is the reason why this
+ * particular piece of code is #ifdefed away and replaced by more
+ * "friendly" version found in #else section below. This comment
+ * also applies to BN_copy function.
+ *
+ * <appro@fy.chalmers.se>
+ */
+ for (i=b->top&(~7); i>0; i-=8)
+ {
+ A[0]=B[0]; A[1]=B[1]; A[2]=B[2]; A[3]=B[3];
+ A[4]=B[4]; A[5]=B[5]; A[6]=B[6]; A[7]=B[7];
+ A+=8;
+ B+=8;
+ }
+ switch (b->top&7)
+ {
+ case 7:
+ A[6]=B[6];
+ case 6:
+ A[5]=B[5];
+ case 5:
+ A[4]=B[4];
+ case 4:
+ A[3]=B[3];
+ case 3:
+ A[2]=B[2];
+ case 2:
+ A[1]=B[1];
+ case 1:
+ A[0]=B[0];
+ case 0:
+ /* I need the 'case 0' entry for utrix cc.
+ * If the optimizer is turned on, it does the
+ * switch table by doing
+ * a=top&7
+ * a--;
+ * goto jump_table[a];
+ * If top is 0, this makes us jump to 0xffffffc
+ * which is rather bad :-(.
+ * eric 23-Apr-1998
+ */
+ ;
+ }
+#else
+ for (i=b->top>>2; i>0; i--,A+=4,B+=4)
+ {
+ /*
+ * The fact that the loop is unrolled
+ * 4-wise is a tribute to Intel. It's
+ * the one that doesn't have enough
+ * registers to accomodate more data.
+ * I'd unroll it 8-wise otherwise:-)
+ *
+ * <appro@fy.chalmers.se>
+ */
+ BN_ULONG a0,a1,a2,a3;
+ a0=B[0]; a1=B[1]; a2=B[2]; a3=B[3];
+ A[0]=a0; A[1]=a1; A[2]=a2; A[3]=a3;
+ }
+ switch (b->top&3)
+ {
+ case 3: A[2]=B[2];
+ case 2: A[1]=B[1];
+ case 1: A[0]=B[0];
+ case 0: ; /* ultrix cc workaround, see above */
+ }
+#endif
+ free(b->d);
+ }
+
+ b->d=a;
+ b->dmax=words;
+
+ /* Now need to zero any data between b->top and b->max */
+
+ A= &(b->d[b->top]);
+ for (i=(b->dmax - b->top)>>3; i>0; i--,A+=8)
+ {
+ A[0]=0; A[1]=0; A[2]=0; A[3]=0;
+ A[4]=0; A[5]=0; A[6]=0; A[7]=0;
+ }
+ for (i=(b->dmax - b->top)&7; i>0; i--,A++)
+ A[0]=0;
+#else
+ memset(A,0,sizeof(BN_ULONG)*(words+1));
+ memcpy(A,b->d,sizeof(b->d[0])*b->top);
+ b->d=a;
+ b->max=words;
+#endif
+
+/* memset(&(p[b->max]),0,((words+1)-b->max)*sizeof(BN_ULONG)); */
+/* { int i; for (i=b->max; i<words+1; i++) p[i]=i;} */
+
+ }
+ return(b);
+ }
+
+BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b)
+ {
+ int i;
+ BN_ULONG *A;
+ const BN_ULONG *B;
+
+ bn_check_top(b);
+
+ if (a == b) return(a);
+ if (bn_wexpand(a,b->top) == NULL) return(NULL);
+
+#if 1
+ A=a->d;
+ B=b->d;
+ for (i=b->top>>2; i>0; i--,A+=4,B+=4)
+ {
+ BN_ULONG a0,a1,a2,a3;
+ a0=B[0]; a1=B[1]; a2=B[2]; a3=B[3];
+ A[0]=a0; A[1]=a1; A[2]=a2; A[3]=a3;
+ }
+ switch (b->top&3)
+ {
+ case 3: A[2]=B[2];
+ case 2: A[1]=B[1];
+ case 1: A[0]=B[0];
+ case 0: ; /* ultrix cc workaround, see comments in bn_expand2 */
+ }
+#else
+ memcpy(a->d,b->d,sizeof(b->d[0])*b->top);
+#endif
+
+/* memset(&(a->d[b->top]),0,sizeof(a->d[0])*(a->max-b->top));*/
+ a->top=b->top;
+ if ((a->top == 0) && (a->d != NULL))
+ a->d[0]=0;
+ a->neg=b->neg;
+ return(a);
+ }
+
+int BN_set_word(BIGNUM *a, BN_ULONG w)
+ {
+ int i,n;
+ if (bn_expand(a,sizeof(BN_ULONG)*8) == NULL) return(0);
+
+ n=sizeof(BN_ULONG)/BN_BYTES;
+ a->neg=0;
+ a->top=0;
+ a->d[0]=(BN_ULONG)w&BN_MASK2;
+ if (a->d[0] != 0) a->top=1;
+ for (i=1; i<n; i++)
+ {
+ /* the following is done instead of
+ * w>>=BN_BITS2 so compilers don't complain
+ * on builds where sizeof(long) == BN_TYPES */
+#ifndef SIXTY_FOUR_BIT /* the data item > unsigned long */
+ w>>=BN_BITS4;
+ w>>=BN_BITS4;
+#else
+ w=0;
+#endif
+ a->d[i]=(BN_ULONG)w&BN_MASK2;
+ if (a->d[i] != 0) a->top=i+1;
+ }
+ return(1);
+ }
+
+/* ignore negative */
+BIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret)
+ {
+ unsigned int i,m;
+ unsigned int n;
+ BN_ULONG l;
+
+ if (ret == NULL) ret=BN_new();
+ if (ret == NULL) return(NULL);
+ l=0;
+ n=len;
+ if (n == 0)
+ {
+ ret->top=0;
+ return(ret);
+ }
+ if (bn_expand(ret,(int)(n+2)*8) == NULL)
+ return(NULL);
+ i=((n-1)/BN_BYTES)+1;
+ m=((n-1)%(BN_BYTES));
+ ret->top=i;
+ while (n-- > 0)
+ {
+ l=(l<<8L)| *(s++);
+ if (m-- == 0)
+ {
+ ret->d[--i]=l;
+ l=0;
+ m=BN_BYTES-1;
+ }
+ }
+ /* need to call this due to clear byte at top if avoiding
+ * having the top bit set (-ve number) */
+ bn_fix_top(ret);
+ return(ret);
+ }
+
+/* ignore negative */
+int BN_bn2bin(const BIGNUM *a, unsigned char *to)
+ {
+ int n,i;
+ BN_ULONG l;
+
+ n=i=BN_num_bytes(a);
+ while (i-- > 0)
+ {
+ l=a->d[i/BN_BYTES];
+ *(to++)=(unsigned char)(l>>(8*(i%BN_BYTES)))&0xff;
+ }
+ return(n);
+ }
+
+int BN_ucmp(const BIGNUM *a, const BIGNUM *b)
+ {
+ int i;
+ BN_ULONG t1,t2,*ap,*bp;
+
+ bn_check_top(a);
+ bn_check_top(b);
+
+ i=a->top-b->top;
+ if (i != 0) return(i);
+ ap=a->d;
+ bp=b->d;
+ for (i=a->top-1; i>=0; i--)
+ {
+ t1= ap[i];
+ t2= bp[i];
+ if (t1 != t2)
+ return(t1 > t2?1:-1);
+ }
+ return(0);
+ }
+
+int BN_cmp(const BIGNUM *a, const BIGNUM *b)
+ {
+ int i;
+ int gt,lt;
+ BN_ULONG t1,t2;
+
+ if ((a == NULL) || (b == NULL))
+ {
+ if (a != NULL)
+ return(-1);
+ else if (b != NULL)
+ return(1);
+ else
+ return(0);
+ }
+
+ bn_check_top(a);
+ bn_check_top(b);
+
+ if (a->neg != b->neg)
+ {
+ if (a->neg)
+ return(-1);
+ else return(1);
+ }
+ if (a->neg == 0)
+ { gt=1; lt= -1; }
+ else { gt= -1; lt=1; }
+
+ if (a->top > b->top) return(gt);
+ if (a->top < b->top) return(lt);
+ for (i=a->top-1; i>=0; i--)
+ {
+ t1=a->d[i];
+ t2=b->d[i];
+ if (t1 > t2) return(gt);
+ if (t1 < t2) return(lt);
+ }
+ return(0);
+ }
+
+int BN_is_bit_set(const BIGNUM *a, int n)
+ {
+ int i,j;
+
+ if (n < 0) return(0);
+ i=n/BN_BITS2;
+ j=n%BN_BITS2;
+ if (a->top <= i) return(0);
+ return((a->d[i]&(((BN_ULONG)1)<<j))?1:0);
+ }
diff --git a/package/network/services/ead/src/tinysrp/.svn/text-base/bn_mul.c.svn-base b/package/network/services/ead/src/tinysrp/.svn/text-base/bn_mul.c.svn-base
new file mode 100644
index 0000000..d2d9fc5
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/.svn/text-base/bn_mul.c.svn-base
@@ -0,0 +1,176 @@
+/* crypto/bn/bn_mul.c */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include "bn_lcl.h"
+
+int BN_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx)
+ {
+ int top,al,bl;
+ BIGNUM *rr;
+ int ret = 0;
+#if defined(BN_MUL_COMBA) || defined(BN_RECURSION)
+ int i;
+#endif
+#ifdef BN_RECURSION
+ BIGNUM *t;
+ int j,k;
+#endif
+
+#ifdef BN_COUNT
+ printf("BN_mul %d * %d\n",a->top,b->top);
+#endif
+
+ bn_check_top(a);
+ bn_check_top(b);
+ bn_check_top(r);
+
+ al=a->top;
+ bl=b->top;
+
+ if ((al == 0) || (bl == 0))
+ {
+ BN_zero(r);
+ return(1);
+ }
+ top=al+bl;
+
+ BN_CTX_start(ctx);
+ if ((r == a) || (r == b))
+ {
+ if ((rr = BN_CTX_get(ctx)) == NULL) goto err;
+ }
+ else
+ rr = r;
+ rr->neg=a->neg^b->neg;
+
+#if defined(BN_MUL_COMBA) || defined(BN_RECURSION)
+ i = al-bl;
+#endif
+#ifdef BN_MUL_COMBA
+ if (i == 0)
+ {
+# if 0
+ if (al == 4)
+ {
+ if (bn_wexpand(rr,8) == NULL) goto err;
+ rr->top=8;
+ bn_mul_comba4(rr->d,a->d,b->d);
+ goto end;
+ }
+# endif
+ if (al == 8)
+ {
+ if (bn_wexpand(rr,16) == NULL) goto err;
+ rr->top=16;
+ bn_mul_comba8(rr->d,a->d,b->d);
+ goto end;
+ }
+ }
+#endif /* BN_MUL_COMBA */
+ if (bn_wexpand(rr,top) == NULL) goto err;
+ rr->top=top;
+ bn_mul_normal(rr->d,a->d,al,b->d,bl);
+
+#if defined(BN_MUL_COMBA) || defined(BN_RECURSION)
+end:
+#endif
+ bn_fix_top(rr);
+ if (r != rr) BN_copy(r,rr);
+ ret=1;
+err:
+ BN_CTX_end(ctx);
+ return(ret);
+ }
+
+void bn_mul_normal(BN_ULONG *r, BN_ULONG *a, int na, BN_ULONG *b, int nb)
+ {
+ BN_ULONG *rr;
+
+#ifdef BN_COUNT
+ printf(" bn_mul_normal %d * %d\n",na,nb);
+#endif
+
+ if (na < nb)
+ {
+ int itmp;
+ BN_ULONG *ltmp;
+
+ itmp=na; na=nb; nb=itmp;
+ ltmp=a; a=b; b=ltmp;
+
+ }
+ rr= &(r[na]);
+ rr[0]=bn_mul_words(r,a,na,b[0]);
+
+ for (;;)
+ {
+ if (--nb <= 0) return;
+ rr[1]=bn_mul_add_words(&(r[1]),a,na,b[1]);
+ if (--nb <= 0) return;
+ rr[2]=bn_mul_add_words(&(r[2]),a,na,b[2]);
+ if (--nb <= 0) return;
+ rr[3]=bn_mul_add_words(&(r[3]),a,na,b[3]);
+ if (--nb <= 0) return;
+ rr[4]=bn_mul_add_words(&(r[4]),a,na,b[4]);
+ rr+=4;
+ r+=4;
+ b+=4;
+ }
+ }
diff --git a/package/network/services/ead/src/tinysrp/.svn/text-base/bn_prime.h.svn-base b/package/network/services/ead/src/tinysrp/.svn/text-base/bn_prime.h.svn-base
new file mode 100644
index 0000000..b7cf9a9
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/.svn/text-base/bn_prime.h.svn-base
@@ -0,0 +1,325 @@
+/* Auto generated by bn_prime.pl */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#ifndef EIGHT_BIT
+#define NUMPRIMES 2048
+#else
+#define NUMPRIMES 54
+#endif
+static const unsigned int primes[NUMPRIMES]=
+ {
+ 2, 3, 5, 7, 11, 13, 17, 19,
+ 23, 29, 31, 37, 41, 43, 47, 53,
+ 59, 61, 67, 71, 73, 79, 83, 89,
+ 97, 101, 103, 107, 109, 113, 127, 131,
+ 137, 139, 149, 151, 157, 163, 167, 173,
+ 179, 181, 191, 193, 197, 199, 211, 223,
+ 227, 229, 233, 239, 241, 251,
+#ifndef EIGHT_BIT
+ 257, 263,
+ 269, 271, 277, 281, 283, 293, 307, 311,
+ 313, 317, 331, 337, 347, 349, 353, 359,
+ 367, 373, 379, 383, 389, 397, 401, 409,
+ 419, 421, 431, 433, 439, 443, 449, 457,
+ 461, 463, 467, 479, 487, 491, 499, 503,
+ 509, 521, 523, 541, 547, 557, 563, 569,
+ 571, 577, 587, 593, 599, 601, 607, 613,
+ 617, 619, 631, 641, 643, 647, 653, 659,
+ 661, 673, 677, 683, 691, 701, 709, 719,
+ 727, 733, 739, 743, 751, 757, 761, 769,
+ 773, 787, 797, 809, 811, 821, 823, 827,
+ 829, 839, 853, 857, 859, 863, 877, 881,
+ 883, 887, 907, 911, 919, 929, 937, 941,
+ 947, 953, 967, 971, 977, 983, 991, 997,
+ 1009,1013,1019,1021,1031,1033,1039,1049,
+ 1051,1061,1063,1069,1087,1091,1093,1097,
+ 1103,1109,1117,1123,1129,1151,1153,1163,
+ 1171,1181,1187,1193,1201,1213,1217,1223,
+ 1229,1231,1237,1249,1259,1277,1279,1283,
+ 1289,1291,1297,1301,1303,1307,1319,1321,
+ 1327,1361,1367,1373,1381,1399,1409,1423,
+ 1427,1429,1433,1439,1447,1451,1453,1459,
+ 1471,1481,1483,1487,1489,1493,1499,1511,
+ 1523,1531,1543,1549,1553,1559,1567,1571,
+ 1579,1583,1597,1601,1607,1609,1613,1619,
+ 1621,1627,1637,1657,1663,1667,1669,1693,
+ 1697,1699,1709,1721,1723,1733,1741,1747,
+ 1753,1759,1777,1783,1787,1789,1801,1811,
+ 1823,1831,1847,1861,1867,1871,1873,1877,
+ 1879,1889,1901,1907,1913,1931,1933,1949,
+ 1951,1973,1979,1987,1993,1997,1999,2003,
+ 2011,2017,2027,2029,2039,2053,2063,2069,
+ 2081,2083,2087,2089,2099,2111,2113,2129,
+ 2131,2137,2141,2143,2153,2161,2179,2203,
+ 2207,2213,2221,2237,2239,2243,2251,2267,
+ 2269,2273,2281,2287,2293,2297,2309,2311,
+ 2333,2339,2341,2347,2351,2357,2371,2377,
+ 2381,2383,2389,2393,2399,2411,2417,2423,
+ 2437,2441,2447,2459,2467,2473,2477,2503,
+ 2521,2531,2539,2543,2549,2551,2557,2579,
+ 2591,2593,2609,2617,2621,2633,2647,2657,
+ 2659,2663,2671,2677,2683,2687,2689,2693,
+ 2699,2707,2711,2713,2719,2729,2731,2741,
+ 2749,2753,2767,2777,2789,2791,2797,2801,
+ 2803,2819,2833,2837,2843,2851,2857,2861,
+ 2879,2887,2897,2903,2909,2917,2927,2939,
+ 2953,2957,2963,2969,2971,2999,3001,3011,
+ 3019,3023,3037,3041,3049,3061,3067,3079,
+ 3083,3089,3109,3119,3121,3137,3163,3167,
+ 3169,3181,3187,3191,3203,3209,3217,3221,
+ 3229,3251,3253,3257,3259,3271,3299,3301,
+ 3307,3313,3319,3323,3329,3331,3343,3347,
+ 3359,3361,3371,3373,3389,3391,3407,3413,
+ 3433,3449,3457,3461,3463,3467,3469,3491,
+ 3499,3511,3517,3527,3529,3533,3539,3541,
+ 3547,3557,3559,3571,3581,3583,3593,3607,
+ 3613,3617,3623,3631,3637,3643,3659,3671,
+ 3673,3677,3691,3697,3701,3709,3719,3727,
+ 3733,3739,3761,3767,3769,3779,3793,3797,
+ 3803,3821,3823,3833,3847,3851,3853,3863,
+ 3877,3881,3889,3907,3911,3917,3919,3923,
+ 3929,3931,3943,3947,3967,3989,4001,4003,
+ 4007,4013,4019,4021,4027,4049,4051,4057,
+ 4073,4079,4091,4093,4099,4111,4127,4129,
+ 4133,4139,4153,4157,4159,4177,4201,4211,
+ 4217,4219,4229,4231,4241,4243,4253,4259,
+ 4261,4271,4273,4283,4289,4297,4327,4337,
+ 4339,4349,4357,4363,4373,4391,4397,4409,
+ 4421,4423,4441,4447,4451,4457,4463,4481,
+ 4483,4493,4507,4513,4517,4519,4523,4547,
+ 4549,4561,4567,4583,4591,4597,4603,4621,
+ 4637,4639,4643,4649,4651,4657,4663,4673,
+ 4679,4691,4703,4721,4723,4729,4733,4751,
+ 4759,4783,4787,4789,4793,4799,4801,4813,
+ 4817,4831,4861,4871,4877,4889,4903,4909,
+ 4919,4931,4933,4937,4943,4951,4957,4967,
+ 4969,4973,4987,4993,4999,5003,5009,5011,
+ 5021,5023,5039,5051,5059,5077,5081,5087,
+ 5099,5101,5107,5113,5119,5147,5153,5167,
+ 5171,5179,5189,5197,5209,5227,5231,5233,
+ 5237,5261,5273,5279,5281,5297,5303,5309,
+ 5323,5333,5347,5351,5381,5387,5393,5399,
+ 5407,5413,5417,5419,5431,5437,5441,5443,
+ 5449,5471,5477,5479,5483,5501,5503,5507,
+ 5519,5521,5527,5531,5557,5563,5569,5573,
+ 5581,5591,5623,5639,5641,5647,5651,5653,
+ 5657,5659,5669,5683,5689,5693,5701,5711,
+ 5717,5737,5741,5743,5749,5779,5783,5791,
+ 5801,5807,5813,5821,5827,5839,5843,5849,
+ 5851,5857,5861,5867,5869,5879,5881,5897,
+ 5903,5923,5927,5939,5953,5981,5987,6007,
+ 6011,6029,6037,6043,6047,6053,6067,6073,
+ 6079,6089,6091,6101,6113,6121,6131,6133,
+ 6143,6151,6163,6173,6197,6199,6203,6211,
+ 6217,6221,6229,6247,6257,6263,6269,6271,
+ 6277,6287,6299,6301,6311,6317,6323,6329,
+ 6337,6343,6353,6359,6361,6367,6373,6379,
+ 6389,6397,6421,6427,6449,6451,6469,6473,
+ 6481,6491,6521,6529,6547,6551,6553,6563,
+ 6569,6571,6577,6581,6599,6607,6619,6637,
+ 6653,6659,6661,6673,6679,6689,6691,6701,
+ 6703,6709,6719,6733,6737,6761,6763,6779,
+ 6781,6791,6793,6803,6823,6827,6829,6833,
+ 6841,6857,6863,6869,6871,6883,6899,6907,
+ 6911,6917,6947,6949,6959,6961,6967,6971,
+ 6977,6983,6991,6997,7001,7013,7019,7027,
+ 7039,7043,7057,7069,7079,7103,7109,7121,
+ 7127,7129,7151,7159,7177,7187,7193,7207,
+ 7211,7213,7219,7229,7237,7243,7247,7253,
+ 7283,7297,7307,7309,7321,7331,7333,7349,
+ 7351,7369,7393,7411,7417,7433,7451,7457,
+ 7459,7477,7481,7487,7489,7499,7507,7517,
+ 7523,7529,7537,7541,7547,7549,7559,7561,
+ 7573,7577,7583,7589,7591,7603,7607,7621,
+ 7639,7643,7649,7669,7673,7681,7687,7691,
+ 7699,7703,7717,7723,7727,7741,7753,7757,
+ 7759,7789,7793,7817,7823,7829,7841,7853,
+ 7867,7873,7877,7879,7883,7901,7907,7919,
+ 7927,7933,7937,7949,7951,7963,7993,8009,
+ 8011,8017,8039,8053,8059,8069,8081,8087,
+ 8089,8093,8101,8111,8117,8123,8147,8161,
+ 8167,8171,8179,8191,8209,8219,8221,8231,
+ 8233,8237,8243,8263,8269,8273,8287,8291,
+ 8293,8297,8311,8317,8329,8353,8363,8369,
+ 8377,8387,8389,8419,8423,8429,8431,8443,
+ 8447,8461,8467,8501,8513,8521,8527,8537,
+ 8539,8543,8563,8573,8581,8597,8599,8609,
+ 8623,8627,8629,8641,8647,8663,8669,8677,
+ 8681,8689,8693,8699,8707,8713,8719,8731,
+ 8737,8741,8747,8753,8761,8779,8783,8803,
+ 8807,8819,8821,8831,8837,8839,8849,8861,
+ 8863,8867,8887,8893,8923,8929,8933,8941,
+ 8951,8963,8969,8971,8999,9001,9007,9011,
+ 9013,9029,9041,9043,9049,9059,9067,9091,
+ 9103,9109,9127,9133,9137,9151,9157,9161,
+ 9173,9181,9187,9199,9203,9209,9221,9227,
+ 9239,9241,9257,9277,9281,9283,9293,9311,
+ 9319,9323,9337,9341,9343,9349,9371,9377,
+ 9391,9397,9403,9413,9419,9421,9431,9433,
+ 9437,9439,9461,9463,9467,9473,9479,9491,
+ 9497,9511,9521,9533,9539,9547,9551,9587,
+ 9601,9613,9619,9623,9629,9631,9643,9649,
+ 9661,9677,9679,9689,9697,9719,9721,9733,
+ 9739,9743,9749,9767,9769,9781,9787,9791,
+ 9803,9811,9817,9829,9833,9839,9851,9857,
+ 9859,9871,9883,9887,9901,9907,9923,9929,
+ 9931,9941,9949,9967,9973,10007,10009,10037,
+ 10039,10061,10067,10069,10079,10091,10093,10099,
+ 10103,10111,10133,10139,10141,10151,10159,10163,
+ 10169,10177,10181,10193,10211,10223,10243,10247,
+ 10253,10259,10267,10271,10273,10289,10301,10303,
+ 10313,10321,10331,10333,10337,10343,10357,10369,
+ 10391,10399,10427,10429,10433,10453,10457,10459,
+ 10463,10477,10487,10499,10501,10513,10529,10531,
+ 10559,10567,10589,10597,10601,10607,10613,10627,
+ 10631,10639,10651,10657,10663,10667,10687,10691,
+ 10709,10711,10723,10729,10733,10739,10753,10771,
+ 10781,10789,10799,10831,10837,10847,10853,10859,
+ 10861,10867,10883,10889,10891,10903,10909,10937,
+ 10939,10949,10957,10973,10979,10987,10993,11003,
+ 11027,11047,11057,11059,11069,11071,11083,11087,
+ 11093,11113,11117,11119,11131,11149,11159,11161,
+ 11171,11173,11177,11197,11213,11239,11243,11251,
+ 11257,11261,11273,11279,11287,11299,11311,11317,
+ 11321,11329,11351,11353,11369,11383,11393,11399,
+ 11411,11423,11437,11443,11447,11467,11471,11483,
+ 11489,11491,11497,11503,11519,11527,11549,11551,
+ 11579,11587,11593,11597,11617,11621,11633,11657,
+ 11677,11681,11689,11699,11701,11717,11719,11731,
+ 11743,11777,11779,11783,11789,11801,11807,11813,
+ 11821,11827,11831,11833,11839,11863,11867,11887,
+ 11897,11903,11909,11923,11927,11933,11939,11941,
+ 11953,11959,11969,11971,11981,11987,12007,12011,
+ 12037,12041,12043,12049,12071,12073,12097,12101,
+ 12107,12109,12113,12119,12143,12149,12157,12161,
+ 12163,12197,12203,12211,12227,12239,12241,12251,
+ 12253,12263,12269,12277,12281,12289,12301,12323,
+ 12329,12343,12347,12373,12377,12379,12391,12401,
+ 12409,12413,12421,12433,12437,12451,12457,12473,
+ 12479,12487,12491,12497,12503,12511,12517,12527,
+ 12539,12541,12547,12553,12569,12577,12583,12589,
+ 12601,12611,12613,12619,12637,12641,12647,12653,
+ 12659,12671,12689,12697,12703,12713,12721,12739,
+ 12743,12757,12763,12781,12791,12799,12809,12821,
+ 12823,12829,12841,12853,12889,12893,12899,12907,
+ 12911,12917,12919,12923,12941,12953,12959,12967,
+ 12973,12979,12983,13001,13003,13007,13009,13033,
+ 13037,13043,13049,13063,13093,13099,13103,13109,
+ 13121,13127,13147,13151,13159,13163,13171,13177,
+ 13183,13187,13217,13219,13229,13241,13249,13259,
+ 13267,13291,13297,13309,13313,13327,13331,13337,
+ 13339,13367,13381,13397,13399,13411,13417,13421,
+ 13441,13451,13457,13463,13469,13477,13487,13499,
+ 13513,13523,13537,13553,13567,13577,13591,13597,
+ 13613,13619,13627,13633,13649,13669,13679,13681,
+ 13687,13691,13693,13697,13709,13711,13721,13723,
+ 13729,13751,13757,13759,13763,13781,13789,13799,
+ 13807,13829,13831,13841,13859,13873,13877,13879,
+ 13883,13901,13903,13907,13913,13921,13931,13933,
+ 13963,13967,13997,13999,14009,14011,14029,14033,
+ 14051,14057,14071,14081,14083,14087,14107,14143,
+ 14149,14153,14159,14173,14177,14197,14207,14221,
+ 14243,14249,14251,14281,14293,14303,14321,14323,
+ 14327,14341,14347,14369,14387,14389,14401,14407,
+ 14411,14419,14423,14431,14437,14447,14449,14461,
+ 14479,14489,14503,14519,14533,14537,14543,14549,
+ 14551,14557,14561,14563,14591,14593,14621,14627,
+ 14629,14633,14639,14653,14657,14669,14683,14699,
+ 14713,14717,14723,14731,14737,14741,14747,14753,
+ 14759,14767,14771,14779,14783,14797,14813,14821,
+ 14827,14831,14843,14851,14867,14869,14879,14887,
+ 14891,14897,14923,14929,14939,14947,14951,14957,
+ 14969,14983,15013,15017,15031,15053,15061,15073,
+ 15077,15083,15091,15101,15107,15121,15131,15137,
+ 15139,15149,15161,15173,15187,15193,15199,15217,
+ 15227,15233,15241,15259,15263,15269,15271,15277,
+ 15287,15289,15299,15307,15313,15319,15329,15331,
+ 15349,15359,15361,15373,15377,15383,15391,15401,
+ 15413,15427,15439,15443,15451,15461,15467,15473,
+ 15493,15497,15511,15527,15541,15551,15559,15569,
+ 15581,15583,15601,15607,15619,15629,15641,15643,
+ 15647,15649,15661,15667,15671,15679,15683,15727,
+ 15731,15733,15737,15739,15749,15761,15767,15773,
+ 15787,15791,15797,15803,15809,15817,15823,15859,
+ 15877,15881,15887,15889,15901,15907,15913,15919,
+ 15923,15937,15959,15971,15973,15991,16001,16007,
+ 16033,16057,16061,16063,16067,16069,16073,16087,
+ 16091,16097,16103,16111,16127,16139,16141,16183,
+ 16187,16189,16193,16217,16223,16229,16231,16249,
+ 16253,16267,16273,16301,16319,16333,16339,16349,
+ 16361,16363,16369,16381,16411,16417,16421,16427,
+ 16433,16447,16451,16453,16477,16481,16487,16493,
+ 16519,16529,16547,16553,16561,16567,16573,16603,
+ 16607,16619,16631,16633,16649,16651,16657,16661,
+ 16673,16691,16693,16699,16703,16729,16741,16747,
+ 16759,16763,16787,16811,16823,16829,16831,16843,
+ 16871,16879,16883,16889,16901,16903,16921,16927,
+ 16931,16937,16943,16963,16979,16981,16987,16993,
+ 17011,17021,17027,17029,17033,17041,17047,17053,
+ 17077,17093,17099,17107,17117,17123,17137,17159,
+ 17167,17183,17189,17191,17203,17207,17209,17231,
+ 17239,17257,17291,17293,17299,17317,17321,17327,
+ 17333,17341,17351,17359,17377,17383,17387,17389,
+ 17393,17401,17417,17419,17431,17443,17449,17467,
+ 17471,17477,17483,17489,17491,17497,17509,17519,
+ 17539,17551,17569,17573,17579,17581,17597,17599,
+ 17609,17623,17627,17657,17659,17669,17681,17683,
+ 17707,17713,17729,17737,17747,17749,17761,17783,
+ 17789,17791,17807,17827,17837,17839,17851,17863,
+#endif
+ };
diff --git a/package/network/services/ead/src/tinysrp/.svn/text-base/bn_shift.c.svn-base b/package/network/services/ead/src/tinysrp/.svn/text-base/bn_shift.c.svn-base
new file mode 100644
index 0000000..f403720
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/.svn/text-base/bn_shift.c.svn-base
@@ -0,0 +1,139 @@
+/* crypto/bn/bn_shift.c */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include "bn_lcl.h"
+
+int BN_lshift(BIGNUM *r, const BIGNUM *a, int n)
+ {
+ int i,nw,lb,rb;
+ BN_ULONG *t,*f;
+ BN_ULONG l;
+
+ r->neg=a->neg;
+ if (bn_wexpand(r,a->top+(n/BN_BITS2)+1) == NULL) return(0);
+ nw=n/BN_BITS2;
+ lb=n%BN_BITS2;
+ rb=BN_BITS2-lb;
+ f=a->d;
+ t=r->d;
+ t[a->top+nw]=0;
+ if (lb == 0)
+ for (i=a->top-1; i>=0; i--)
+ t[nw+i]=f[i];
+ else
+ for (i=a->top-1; i>=0; i--)
+ {
+ l=f[i];
+ t[nw+i+1]|=(l>>rb)&BN_MASK2;
+ t[nw+i]=(l<<lb)&BN_MASK2;
+ }
+ memset(t,0,nw*sizeof(t[0]));
+/* for (i=0; i<nw; i++)
+ t[i]=0;*/
+ r->top=a->top+nw+1;
+ bn_fix_top(r);
+ return(1);
+ }
+
+int BN_rshift(BIGNUM *r, BIGNUM *a, int n)
+ {
+ int i,j,nw,lb,rb;
+ BN_ULONG *t,*f;
+ BN_ULONG l,tmp;
+
+ nw=n/BN_BITS2;
+ rb=n%BN_BITS2;
+ lb=BN_BITS2-rb;
+ if (nw > a->top || a->top == 0)
+ {
+ BN_zero(r);
+ return(1);
+ }
+ if (r != a)
+ {
+ r->neg=a->neg;
+ if (bn_wexpand(r,a->top-nw+1) == NULL) return(0);
+ }
+
+ f= &(a->d[nw]);
+ t=r->d;
+ j=a->top-nw;
+ r->top=j;
+
+ if (rb == 0)
+ {
+ for (i=j+1; i > 0; i--)
+ *(t++)= *(f++);
+ }
+ else
+ {
+ l= *(f++);
+ for (i=1; i<j; i++)
+ {
+ tmp =(l>>rb)&BN_MASK2;
+ l= *(f++);
+ *(t++) =(tmp|(l<<lb))&BN_MASK2;
+ }
+ *(t++) =(l>>rb)&BN_MASK2;
+ }
+ *t=0;
+ bn_fix_top(r);
+ return(1);
+ }
diff --git a/package/network/services/ead/src/tinysrp/.svn/text-base/bn_sqr.c.svn-base b/package/network/services/ead/src/tinysrp/.svn/text-base/bn_sqr.c.svn-base
new file mode 100644
index 0000000..2d3db70
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/.svn/text-base/bn_sqr.c.svn-base
@@ -0,0 +1,160 @@
+/* crypto/bn/bn_sqr.c */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include "bn_lcl.h"
+
+/* r must not be a */
+/* I've just gone over this and it is now %20 faster on x86 - eay - 27 Jun 96 */
+int BN_sqr(BIGNUM *r, BIGNUM *a, BN_CTX *ctx)
+ {
+ int max,al;
+ int ret = 0;
+ BIGNUM *tmp,*rr;
+
+#ifdef BN_COUNT
+printf("BN_sqr %d * %d\n",a->top,a->top);
+#endif
+ bn_check_top(a);
+
+ al=a->top;
+ if (al <= 0)
+ {
+ r->top=0;
+ return(1);
+ }
+
+ BN_CTX_start(ctx);
+ rr=(a != r) ? r : BN_CTX_get(ctx);
+ tmp=BN_CTX_get(ctx);
+ if (tmp == NULL) goto err;
+
+ max=(al+al);
+ if (bn_wexpand(rr,max+1) == NULL) goto err;
+
+ r->neg=0;
+ if (al == 4)
+ {
+#ifndef BN_SQR_COMBA
+ BN_ULONG t[8];
+ bn_sqr_normal(rr->d,a->d,4,t);
+#else
+ bn_sqr_comba4(rr->d,a->d);
+#endif
+ }
+ else if (al == 8)
+ {
+#ifndef BN_SQR_COMBA
+ BN_ULONG t[16];
+ bn_sqr_normal(rr->d,a->d,8,t);
+#else
+ bn_sqr_comba8(rr->d,a->d);
+#endif
+ }
+ else
+ {
+ if (bn_wexpand(tmp,max) == NULL) goto err;
+ bn_sqr_normal(rr->d,a->d,al,tmp->d);
+ }
+
+ rr->top=max;
+ if ((max > 0) && (rr->d[max-1] == 0)) rr->top--;
+ if (rr != r) BN_copy(r,rr);
+ ret = 1;
+ err:
+ BN_CTX_end(ctx);
+ return(ret);
+ }
+
+/* tmp must have 2*n words */
+void bn_sqr_normal(BN_ULONG *r, BN_ULONG *a, int n, BN_ULONG *tmp)
+ {
+ int i,j,max;
+ BN_ULONG *ap,*rp;
+
+ max=n*2;
+ ap=a;
+ rp=r;
+ rp[0]=rp[max-1]=0;
+ rp++;
+ j=n;
+
+ if (--j > 0)
+ {
+ ap++;
+ rp[j]=bn_mul_words(rp,ap,j,ap[-1]);
+ rp+=2;
+ }
+
+ for (i=n-2; i>0; i--)
+ {
+ j--;
+ ap++;
+ rp[j]=bn_mul_add_words(rp,ap,j,ap[-1]);
+ rp+=2;
+ }
+
+ bn_add_words(r,r,r,max);
+
+ /* There will not be a carry */
+
+ bn_sqr_words(tmp,a,n);
+
+ bn_add_words(r,r,tmp,max);
+ }
diff --git a/package/network/services/ead/src/tinysrp/.svn/text-base/bn_word.c.svn-base b/package/network/services/ead/src/tinysrp/.svn/text-base/bn_word.c.svn-base
new file mode 100644
index 0000000..7820e08
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/.svn/text-base/bn_word.c.svn-base
@@ -0,0 +1,130 @@
+/* crypto/bn/bn_word.c */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#include <stdio.h>
+#include "bn_lcl.h"
+
+int BN_add_word(BIGNUM *a, BN_ULONG w)
+ {
+ BN_ULONG l;
+ int i;
+
+ if (a->neg)
+ {
+ a->neg=0;
+ i=BN_sub_word(a,w);
+ if (!BN_is_zero(a))
+ a->neg=!(a->neg);
+ return(i);
+ }
+ w&=BN_MASK2;
+ if (bn_wexpand(a,a->top+1) == NULL) return(0);
+ i=0;
+ for (;;)
+ {
+ l=(a->d[i]+(BN_ULONG)w)&BN_MASK2;
+ a->d[i]=l;
+ if (w > l)
+ w=1;
+ else
+ break;
+ i++;
+ }
+ if (i >= a->top)
+ a->top++;
+ return(1);
+ }
+
+int BN_sub_word(BIGNUM *a, BN_ULONG w)
+ {
+ int i;
+
+ if (BN_is_zero(a) || a->neg)
+ {
+ a->neg=0;
+ i=BN_add_word(a,w);
+ a->neg=1;
+ return(i);
+ }
+
+ w&=BN_MASK2;
+ if ((a->top == 1) && (a->d[0] < w))
+ {
+ a->d[0]=w-a->d[0];
+ a->neg=1;
+ return(1);
+ }
+ i=0;
+ for (;;)
+ {
+ if (a->d[i] >= w)
+ {
+ a->d[i]-=w;
+ break;
+ }
+ else
+ {
+ a->d[i]=(a->d[i]-w)&BN_MASK2;
+ i++;
+ w=1;
+ }
+ }
+ if ((a->d[i] == 0) && (i == (a->top-1)))
+ a->top--;
+ return(1);
+ }
diff --git a/package/network/services/ead/src/tinysrp/.svn/text-base/clitest.c.svn-base b/package/network/services/ead/src/tinysrp/.svn/text-base/clitest.c.svn-base
new file mode 100644
index 0000000..faaa5dd
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/.svn/text-base/clitest.c.svn-base
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 1997-1999 The Stanford SRP Authentication Project
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF
+ * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * In addition, the following conditions apply:
+ *
+ * 1. Any software that incorporates the SRP authentication technology
+ * must display the following acknowlegment:
+ * "This product uses the 'Secure Remote Password' cryptographic
+ * authentication system developed by Tom Wu (tjw@CS.Stanford.EDU)."
+ *
+ * 2. Any software that incorporates all or part of the SRP distribution
+ * itself must also display the following acknowledgment:
+ * "This product includes software developed by Tom Wu and Eugene
+ * Jhong for the SRP Distribution (http://srp.stanford.edu/srp/)."
+ *
+ * 3. Redistributions in source or binary form must retain an intact copy
+ * of this copyright notice and list of conditions.
+ */
+
+#include <stdio.h>
+#include "t_defines.h"
+#include "t_pwd.h"
+#include "t_client.h"
+
+int
+main()
+{
+ int index;
+ struct t_client * tc;
+ struct t_preconf *tcp;
+ struct t_num n;
+ struct t_num g;
+ struct t_num s;
+ struct t_num B;
+ char username[MAXUSERLEN];
+ char hexbuf[MAXHEXPARAMLEN];
+ char buf1[MAXPARAMLEN], buf2[MAXPARAMLEN], buf3[MAXSALTLEN];
+ unsigned char cbuf[20];
+ struct t_num * A;
+ unsigned char * skey;
+ char pass[128];
+
+ printf("Enter username: ");
+ fgets(username, sizeof(username), stdin);
+ username[strlen(username) - 1] = '\0';
+ printf("Enter index (from server): ");
+ fgets(hexbuf, sizeof(hexbuf), stdin);
+ index = atoi(hexbuf);
+ tcp = t_getpreparam(index - 1);
+ printf("Enter salt (from server): ");
+ fgets(hexbuf, sizeof(hexbuf), stdin);
+ s.data = buf3;
+ s.len = t_fromb64(s.data, hexbuf);
+
+ tc = t_clientopen(username, &tcp->modulus, &tcp->generator, &s);
+ if (tc == 0) {
+ printf("invalid n, g\n");
+ exit(1);
+ }
+
+ A = t_clientgenexp(tc);
+ printf("A (to server): %s\n", t_tob64(hexbuf, A->data, A->len));
+
+ t_getpass(pass, 128, "Enter password:");
+ t_clientpasswd(tc, pass);
+
+ printf("Enter B (from server): ");
+ fgets(hexbuf, sizeof(hexbuf), stdin);
+ B.data = buf1;
+ B.len = t_fromb64(B.data, hexbuf);
+
+ skey = t_clientgetkey(tc, &B);
+ printf("Session key: %s\n", t_tohex(hexbuf, skey, 40));
+ printf("Response (to server): %s\n",
+ t_tohex(hexbuf, t_clientresponse(tc), RESPONSE_LEN));
+
+ printf("Enter server response: ");
+ fgets(hexbuf, sizeof(hexbuf), stdin);
+ hexbuf[strlen(hexbuf) - 1] = '\0';
+ t_fromhex(cbuf, hexbuf);
+
+ if (t_clientverify(tc, cbuf) == 0)
+ printf("Server authentication successful.\n");
+ else
+ printf("Server authentication failed.\n");
+
+ t_clientclose(tc);
+
+ return 0;
+}
diff --git a/package/network/services/ead/src/tinysrp/.svn/text-base/config.h.in.svn-base b/package/network/services/ead/src/tinysrp/.svn/text-base/config.h.in.svn-base
new file mode 100644
index 0000000..a4b50c7
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/.svn/text-base/config.h.in.svn-base
@@ -0,0 +1,79 @@
+/* config.h.in. Generated automatically from configure.in by autoheader. */
+
+/* Define if type char is unsigned and you are not using gcc. */
+#ifndef __CHAR_UNSIGNED__
+#undef __CHAR_UNSIGNED__
+#endif
+
+/* Define to empty if the keyword does not work. */
+#undef const
+
+/* Define as __inline if that's what the C compiler calls it. */
+#undef inline
+
+/* Define as the return type of signal handlers (int or void). */
+#undef RETSIGTYPE
+
+/* Define if you have the ANSI C header files. */
+#undef STDC_HEADERS
+
+/* Define if you can safely include both <sys/time.h> and <time.h>. */
+#undef TIME_WITH_SYS_TIME
+
+/* Define if your processor stores words with the most significant
+ byte first (like Motorola and SPARC, unlike Intel and VAX). */
+#undef WORDS_BIGENDIAN
+
+#undef SHA1HANDSOFF
+
+#undef POSIX_TERMIOS
+
+#undef POSIX_SIGTYPE
+
+#undef volatile
+
+/* The number of bytes in a int. */
+#undef SIZEOF_INT
+
+/* The number of bytes in a long. */
+#undef SIZEOF_LONG
+
+/* The number of bytes in a long long. */
+#undef SIZEOF_LONG_LONG
+
+/* The number of bytes in a short. */
+#undef SIZEOF_SHORT
+
+/* Define if you have the memcpy function. */
+#undef HAVE_MEMCPY
+
+/* Define if you have the sigaction function. */
+#undef HAVE_SIGACTION
+
+/* Define if you have the strchr function. */
+#undef HAVE_STRCHR
+
+/* Define if you have the <sgtty.h> header file. */
+#undef HAVE_SGTTY_H
+
+/* Define if you have the <sys/ioctl.h> header file. */
+#undef HAVE_SYS_IOCTL_H
+
+/* Define if you have the <sys/time.h> header file. */
+#undef HAVE_SYS_TIME_H
+
+/* Define if you have the <termio.h> header file. */
+#undef HAVE_TERMIO_H
+
+/* Define if you have the <termios.h> header file. */
+#undef HAVE_TERMIOS_H
+
+/* Define if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* Name of package */
+#undef PACKAGE
+
+/* Version number of package */
+#undef VERSION
+
diff --git a/package/network/services/ead/src/tinysrp/.svn/text-base/configure.in.svn-base b/package/network/services/ead/src/tinysrp/.svn/text-base/configure.in.svn-base
new file mode 100644
index 0000000..627d15a
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/.svn/text-base/configure.in.svn-base
@@ -0,0 +1,52 @@
+dnl Process this file with autoconf to produce a configure script.
+
+AC_INIT(t_pwd.h)
+AM_CONFIG_HEADER(config.h)
+AM_INIT_AUTOMAKE(libtinysrp, 0.7.5)
+
+test "$CFLAGS" = "" && CFLAGS="-O2"
+
+dnl Checks for programs.
+
+AC_PROG_CC
+AC_PROG_INSTALL
+AC_PROG_LN_S
+AC_PROG_RANLIB
+AC_ARG_PROGRAM
+
+dnl Checks for header files.
+
+AC_HEADER_STDC
+AC_CHECK_HEADERS(sgtty.h sys/ioctl.h sys/time.h termio.h termios.h unistd.h)
+
+dnl Checks for typedefs, structures, and compiler characteristics.
+
+AC_C_CONST
+AC_C_INLINE
+AC_HEADER_TIME
+AC_C_BIGENDIAN
+AC_CHECK_SIZEOF(short)
+AC_CHECK_SIZEOF(int)
+AC_CHECK_SIZEOF(long)
+AC_CHECK_SIZEOF(long long)
+AC_TRY_COMPILE(, [volatile int i;], , AC_DEFINE(volatile, ))
+AC_C_CHAR_UNSIGNED
+
+AC_SUBST(signed)dnl
+if test "$ac_cv_c_char_unsigned" = "yes"; then
+ signed=-signed
+fi
+
+dnl Checks for library functions.
+
+AC_CHECK_FUNCS(sigaction strchr memcpy)
+TYPE_SIGNAL
+AC_HEADER_CHECK(termios.h,AC_FUNC_CHECK(cfsetispeed,AC_DEFINE(POSIX_TERMIOS)))
+
+dnl User options
+
+dnl Some defines for now.
+
+AC_DEFINE(SHA1HANDSOFF)
+
+AC_OUTPUT(Makefile)
diff --git a/package/network/services/ead/src/tinysrp/.svn/text-base/configure.svn-base b/package/network/services/ead/src/tinysrp/.svn/text-base/configure.svn-base
new file mode 100644
index 0000000..6ee76bf
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/.svn/text-base/configure.svn-base
@@ -0,0 +1,2421 @@
+#! /bin/sh
+
+# Guess values for system-dependent variables and create Makefiles.
+# Generated automatically using autoconf version 2.13
+# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
+#
+# This configure script is free software; the Free Software Foundation
+# gives unlimited permission to copy, distribute and modify it.
+
+# Defaults:
+ac_help=
+ac_default_prefix=/usr/local
+# Any additions from configure.in:
+
+# Initialize some variables set by options.
+# The variables have the same names as the options, with
+# dashes changed to underlines.
+build=NONE
+cache_file=./config.cache
+exec_prefix=NONE
+host=NONE
+no_create=
+nonopt=NONE
+no_recursion=
+prefix=NONE
+program_prefix=NONE
+program_suffix=NONE
+program_transform_name=s,x,x,
+silent=
+site=
+srcdir=
+target=NONE
+verbose=
+x_includes=NONE
+x_libraries=NONE
+bindir='${exec_prefix}/bin'
+sbindir='${exec_prefix}/sbin'
+libexecdir='${exec_prefix}/libexec'
+datadir='${prefix}/share'
+sysconfdir='${prefix}/etc'
+sharedstatedir='${prefix}/com'
+localstatedir='${prefix}/var'
+libdir='${exec_prefix}/lib'
+includedir='${prefix}/include'
+oldincludedir='/usr/include'
+infodir='${prefix}/info'
+mandir='${prefix}/man'
+
+# Initialize some other variables.
+subdirs=
+MFLAGS= MAKEFLAGS=
+SHELL=${CONFIG_SHELL-/bin/sh}
+# Maximum number of lines to put in a shell here document.
+ac_max_here_lines=12
+
+ac_prev=
+for ac_option
+do
+
+ # If the previous option needs an argument, assign it.
+ if test -n "$ac_prev"; then
+ eval "$ac_prev=\$ac_option"
+ ac_prev=
+ continue
+ fi
+
+ case "$ac_option" in
+ -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
+ *) ac_optarg= ;;
+ esac
+
+ # Accept the important Cygnus configure options, so we can diagnose typos.
+
+ case "$ac_option" in
+
+ -bindir | --bindir | --bindi | --bind | --bin | --bi)
+ ac_prev=bindir ;;
+ -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
+ bindir="$ac_optarg" ;;
+
+ -build | --build | --buil | --bui | --bu)
+ ac_prev=build ;;
+ -build=* | --build=* | --buil=* | --bui=* | --bu=*)
+ build="$ac_optarg" ;;
+
+ -cache-file | --cache-file | --cache-fil | --cache-fi \
+ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
+ ac_prev=cache_file ;;
+ -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
+ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
+ cache_file="$ac_optarg" ;;
+
+ -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
+ ac_prev=datadir ;;
+ -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
+ | --da=*)
+ datadir="$ac_optarg" ;;
+
+ -disable-* | --disable-*)
+ ac_feature=`echo $ac_option|sed -e 's/-*disable-//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then
+ { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
+ fi
+ ac_feature=`echo $ac_feature| sed 's/-/_/g'`
+ eval "enable_${ac_feature}=no" ;;
+
+ -enable-* | --enable-*)
+ ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then
+ { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
+ fi
+ ac_feature=`echo $ac_feature| sed 's/-/_/g'`
+ case "$ac_option" in
+ *=*) ;;
+ *) ac_optarg=yes ;;
+ esac
+ eval "enable_${ac_feature}='$ac_optarg'" ;;
+
+ -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
+ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
+ | --exec | --exe | --ex)
+ ac_prev=exec_prefix ;;
+ -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
+ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
+ | --exec=* | --exe=* | --ex=*)
+ exec_prefix="$ac_optarg" ;;
+
+ -gas | --gas | --ga | --g)
+ # Obsolete; use --with-gas.
+ with_gas=yes ;;
+
+ -help | --help | --hel | --he)
+ # Omit some internal or obsolete options to make the list less imposing.
+ # This message is too long to be a string in the A/UX 3.1 sh.
+ cat << EOF
+Usage: configure [options] [host]
+Options: [defaults in brackets after descriptions]
+Configuration:
+ --cache-file=FILE cache test results in FILE
+ --help print this message
+ --no-create do not create output files
+ --quiet, --silent do not print \`checking...' messages
+ --version print the version of autoconf that created configure
+Directory and file names:
+ --prefix=PREFIX install architecture-independent files in PREFIX
+ [$ac_default_prefix]
+ --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
+ [same as prefix]
+ --bindir=DIR user executables in DIR [EPREFIX/bin]
+ --sbindir=DIR system admin executables in DIR [EPREFIX/sbin]
+ --libexecdir=DIR program executables in DIR [EPREFIX/libexec]
+ --datadir=DIR read-only architecture-independent data in DIR
+ [PREFIX/share]
+ --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc]
+ --sharedstatedir=DIR modifiable architecture-independent data in DIR
+ [PREFIX/com]
+ --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var]
+ --libdir=DIR object code libraries in DIR [EPREFIX/lib]
+ --includedir=DIR C header files in DIR [PREFIX/include]
+ --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include]
+ --infodir=DIR info documentation in DIR [PREFIX/info]
+ --mandir=DIR man documentation in DIR [PREFIX/man]
+ --srcdir=DIR find the sources in DIR [configure dir or ..]
+ --program-prefix=PREFIX prepend PREFIX to installed program names
+ --program-suffix=SUFFIX append SUFFIX to installed program names
+ --program-transform-name=PROGRAM
+ run sed PROGRAM on installed program names
+EOF
+ cat << EOF
+Host type:
+ --build=BUILD configure for building on BUILD [BUILD=HOST]
+ --host=HOST configure for HOST [guessed]
+ --target=TARGET configure for TARGET [TARGET=HOST]
+Features and packages:
+ --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
+ --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
+ --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
+ --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
+ --x-includes=DIR X include files are in DIR
+ --x-libraries=DIR X library files are in DIR
+EOF
+ if test -n "$ac_help"; then
+ echo "--enable and --with options recognized:$ac_help"
+ fi
+ exit 0 ;;
+
+ -host | --host | --hos | --ho)
+ ac_prev=host ;;
+ -host=* | --host=* | --hos=* | --ho=*)
+ host="$ac_optarg" ;;
+
+ -includedir | --includedir | --includedi | --included | --include \
+ | --includ | --inclu | --incl | --inc)
+ ac_prev=includedir ;;
+ -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
+ | --includ=* | --inclu=* | --incl=* | --inc=*)
+ includedir="$ac_optarg" ;;
+
+ -infodir | --infodir | --infodi | --infod | --info | --inf)
+ ac_prev=infodir ;;
+ -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
+ infodir="$ac_optarg" ;;
+
+ -libdir | --libdir | --libdi | --libd)
+ ac_prev=libdir ;;
+ -libdir=* | --libdir=* | --libdi=* | --libd=*)
+ libdir="$ac_optarg" ;;
+
+ -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
+ | --libexe | --libex | --libe)
+ ac_prev=libexecdir ;;
+ -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
+ | --libexe=* | --libex=* | --libe=*)
+ libexecdir="$ac_optarg" ;;
+
+ -localstatedir | --localstatedir | --localstatedi | --localstated \
+ | --localstate | --localstat | --localsta | --localst \
+ | --locals | --local | --loca | --loc | --lo)
+ ac_prev=localstatedir ;;
+ -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
+ | --localstate=* | --localstat=* | --localsta=* | --localst=* \
+ | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
+ localstatedir="$ac_optarg" ;;
+
+ -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
+ ac_prev=mandir ;;
+ -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
+ mandir="$ac_optarg" ;;
+
+ -nfp | --nfp | --nf)
+ # Obsolete; use --without-fp.
+ with_fp=no ;;
+
+ -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+ | --no-cr | --no-c)
+ no_create=yes ;;
+
+ -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
+ no_recursion=yes ;;
+
+ -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
+ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
+ | --oldin | --oldi | --old | --ol | --o)
+ ac_prev=oldincludedir ;;
+ -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
+ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
+ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
+ oldincludedir="$ac_optarg" ;;
+
+ -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
+ ac_prev=prefix ;;
+ -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
+ prefix="$ac_optarg" ;;
+
+ -program-prefix | --program-prefix | --program-prefi | --program-pref \
+ | --program-pre | --program-pr | --program-p)
+ ac_prev=program_prefix ;;
+ -program-prefix=* | --program-prefix=* | --program-prefi=* \
+ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
+ program_prefix="$ac_optarg" ;;
+
+ -program-suffix | --program-suffix | --program-suffi | --program-suff \
+ | --program-suf | --program-su | --program-s)
+ ac_prev=program_suffix ;;
+ -program-suffix=* | --program-suffix=* | --program-suffi=* \
+ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
+ program_suffix="$ac_optarg" ;;
+
+ -program-transform-name | --program-transform-name \
+ | --program-transform-nam | --program-transform-na \
+ | --program-transform-n | --program-transform- \
+ | --program-transform | --program-transfor \
+ | --program-transfo | --program-transf \
+ | --program-trans | --program-tran \
+ | --progr-tra | --program-tr | --program-t)
+ ac_prev=program_transform_name ;;
+ -program-transform-name=* | --program-transform-name=* \
+ | --program-transform-nam=* | --program-transform-na=* \
+ | --program-transform-n=* | --program-transform-=* \
+ | --program-transform=* | --program-transfor=* \
+ | --program-transfo=* | --program-transf=* \
+ | --program-trans=* | --program-tran=* \
+ | --progr-tra=* | --program-tr=* | --program-t=*)
+ program_transform_name="$ac_optarg" ;;
+
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil)
+ silent=yes ;;
+
+ -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+ ac_prev=sbindir ;;
+ -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+ | --sbi=* | --sb=*)
+ sbindir="$ac_optarg" ;;
+
+ -sharedstatedir | --sharedstatedir | --sharedstatedi \
+ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
+ | --sharedst | --shareds | --shared | --share | --shar \
+ | --sha | --sh)
+ ac_prev=sharedstatedir ;;
+ -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
+ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
+ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
+ | --sha=* | --sh=*)
+ sharedstatedir="$ac_optarg" ;;
+
+ -site | --site | --sit)
+ ac_prev=site ;;
+ -site=* | --site=* | --sit=*)
+ site="$ac_optarg" ;;
+
+ -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
+ ac_prev=srcdir ;;
+ -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
+ srcdir="$ac_optarg" ;;
+
+ -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
+ | --syscon | --sysco | --sysc | --sys | --sy)
+ ac_prev=sysconfdir ;;
+ -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
+ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
+ sysconfdir="$ac_optarg" ;;
+
+ -target | --target | --targe | --targ | --tar | --ta | --t)
+ ac_prev=target ;;
+ -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
+ target="$ac_optarg" ;;
+
+ -v | -verbose | --verbose | --verbos | --verbo | --verb)
+ verbose=yes ;;
+
+ -version | --version | --versio | --versi | --vers)
+ echo "configure generated by autoconf version 2.13"
+ exit 0 ;;
+
+ -with-* | --with-*)
+ ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then
+ { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
+ fi
+ ac_package=`echo $ac_package| sed 's/-/_/g'`
+ case "$ac_option" in
+ *=*) ;;
+ *) ac_optarg=yes ;;
+ esac
+ eval "with_${ac_package}='$ac_optarg'" ;;
+
+ -without-* | --without-*)
+ ac_package=`echo $ac_option|sed -e 's/-*without-//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then
+ { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
+ fi
+ ac_package=`echo $ac_package| sed 's/-/_/g'`
+ eval "with_${ac_package}=no" ;;
+
+ --x)
+ # Obsolete; use --with-x.
+ with_x=yes ;;
+
+ -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
+ | --x-incl | --x-inc | --x-in | --x-i)
+ ac_prev=x_includes ;;
+ -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
+ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
+ x_includes="$ac_optarg" ;;
+
+ -x-libraries | --x-libraries | --x-librarie | --x-librari \
+ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
+ ac_prev=x_libraries ;;
+ -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
+ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
+ x_libraries="$ac_optarg" ;;
+
+ -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; }
+ ;;
+
+ *)
+ if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then
+ echo "configure: warning: $ac_option: invalid host type" 1>&2
+ fi
+ if test "x$nonopt" != xNONE; then
+ { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; }
+ fi
+ nonopt="$ac_option"
+ ;;
+
+ esac
+done
+
+if test -n "$ac_prev"; then
+ { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; }
+fi
+
+trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
+
+# File descriptor usage:
+# 0 standard input
+# 1 file creation
+# 2 errors and warnings
+# 3 some systems may open it to /dev/tty
+# 4 used on the Kubota Titan
+# 6 checking for... messages and results
+# 5 compiler messages saved in config.log
+if test "$silent" = yes; then
+ exec 6>/dev/null
+else
+ exec 6>&1
+fi
+exec 5>./config.log
+
+echo "\
+This file contains any messages produced by compilers while
+running configure, to aid debugging if configure makes a mistake.
+" 1>&5
+
+# Strip out --no-create and --no-recursion so they do not pile up.
+# Also quote any args containing shell metacharacters.
+ac_configure_args=
+for ac_arg
+do
+ case "$ac_arg" in
+ -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+ | --no-cr | --no-c) ;;
+ -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;;
+ *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*)
+ ac_configure_args="$ac_configure_args '$ac_arg'" ;;
+ *) ac_configure_args="$ac_configure_args $ac_arg" ;;
+ esac
+done
+
+# NLS nuisances.
+# Only set these to C if already set. These must not be set unconditionally
+# because not all systems understand e.g. LANG=C (notably SCO).
+# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'!
+# Non-C LC_CTYPE values break the ctype check.
+if test "${LANG+set}" = set; then LANG=C; export LANG; fi
+if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
+if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
+if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi
+
+# confdefs.h avoids OS command line length limits that DEFS can exceed.
+rm -rf conftest* confdefs.h
+# AIX cpp loses on an empty file, so make sure it contains at least a newline.
+echo > confdefs.h
+
+# A filename unique to this package, relative to the directory that
+# configure is in, which we can look for to find out if srcdir is correct.
+ac_unique_file=t_pwd.h
+
+# Find the source files, if location was not specified.
+if test -z "$srcdir"; then
+ ac_srcdir_defaulted=yes
+ # Try the directory containing this script, then its parent.
+ ac_prog=$0
+ ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'`
+ test "x$ac_confdir" = "x$ac_prog" && ac_confdir=.
+ srcdir=$ac_confdir
+ if test ! -r $srcdir/$ac_unique_file; then
+ srcdir=..
+ fi
+else
+ ac_srcdir_defaulted=no
+fi
+if test ! -r $srcdir/$ac_unique_file; then
+ if test "$ac_srcdir_defaulted" = yes; then
+ { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; }
+ else
+ { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; }
+ fi
+fi
+srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'`
+
+# Prefer explicitly selected file to automatically selected ones.
+if test -z "$CONFIG_SITE"; then
+ if test "x$prefix" != xNONE; then
+ CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
+ else
+ CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
+ fi
+fi
+for ac_site_file in $CONFIG_SITE; do
+ if test -r "$ac_site_file"; then
+ echo "loading site script $ac_site_file"
+ . "$ac_site_file"
+ fi
+done
+
+if test -r "$cache_file"; then
+ echo "loading cache $cache_file"
+ . $cache_file
+else
+ echo "creating cache $cache_file"
+ > $cache_file
+fi
+
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
+
+ac_exeext=
+ac_objext=o
+if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
+ # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
+ if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
+ ac_n= ac_c='
+' ac_t=' '
+ else
+ ac_n=-n ac_c= ac_t=
+ fi
+else
+ ac_n= ac_c='\c' ac_t=
+fi
+
+
+
+
+
+ac_aux_dir=
+for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do
+ if test -f $ac_dir/install-sh; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install-sh -c"
+ break
+ elif test -f $ac_dir/install.sh; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install.sh -c"
+ break
+ fi
+done
+if test -z "$ac_aux_dir"; then
+ { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; }
+fi
+ac_config_guess=$ac_aux_dir/config.guess
+ac_config_sub=$ac_aux_dir/config.sub
+ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
+
+# Find a good install program. We prefer a C program (faster),
+# so one script is as good as another. But avoid the broken or
+# incompatible versions:
+# SysV /etc/install, /usr/sbin/install
+# SunOS /usr/etc/install
+# IRIX /sbin/install
+# AIX /bin/install
+# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
+# AFS /usr/afsws/bin/install, which mishandles nonexistent args
+# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
+# ./install, which can be erroneously created by make from ./install.sh.
+echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
+echo "configure:559: checking for a BSD compatible install" >&5
+if test -z "$INSTALL"; then
+if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":"
+ for ac_dir in $PATH; do
+ # Account for people who put trailing slashes in PATH elements.
+ case "$ac_dir/" in
+ /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
+ *)
+ # OSF1 and SCO ODT 3.0 have their own names for install.
+ # Don't use installbsd from OSF since it installs stuff as root
+ # by default.
+ for ac_prog in ginstall scoinst install; do
+ if test -f $ac_dir/$ac_prog; then
+ if test $ac_prog = install &&
+ grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
+ # AIX install. It has an incompatible calling convention.
+ :
+ else
+ ac_cv_path_install="$ac_dir/$ac_prog -c"
+ break 2
+ fi
+ fi
+ done
+ ;;
+ esac
+ done
+ IFS="$ac_save_IFS"
+
+fi
+ if test "${ac_cv_path_install+set}" = set; then
+ INSTALL="$ac_cv_path_install"
+ else
+ # As a last resort, use the slow shell script. We don't cache a
+ # path for INSTALL within a source directory, because that will
+ # break other packages using the cache if that directory is
+ # removed, or if the path is relative.
+ INSTALL="$ac_install_sh"
+ fi
+fi
+echo "$ac_t""$INSTALL" 1>&6
+
+# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
+# It thinks the first close brace ends the variable substitution.
+test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
+
+test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}'
+
+test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
+
+echo $ac_n "checking whether build environment is sane""... $ac_c" 1>&6
+echo "configure:612: checking whether build environment is sane" >&5
+# Just in case
+sleep 1
+echo timestamp > conftestfile
+# Do `set' in a subshell so we don't clobber the current shell's
+# arguments. Must try -L first in case configure is actually a
+# symlink; some systems play weird games with the mod time of symlinks
+# (eg FreeBSD returns the mod time of the symlink's containing
+# directory).
+if (
+ set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null`
+ if test "$*" = "X"; then
+ # -L didn't work.
+ set X `ls -t $srcdir/configure conftestfile`
+ fi
+ if test "$*" != "X $srcdir/configure conftestfile" \
+ && test "$*" != "X conftestfile $srcdir/configure"; then
+
+ # If neither matched, then we have a broken ls. This can happen
+ # if, for instance, CONFIG_SHELL is bash and it inherits a
+ # broken ls alias from the environment. This has actually
+ # happened. Such a system could not be considered "sane".
+ { echo "configure: error: ls -t appears to fail. Make sure there is not a broken
+alias in your environment" 1>&2; exit 1; }
+ fi
+
+ test "$2" = conftestfile
+ )
+then
+ # Ok.
+ :
+else
+ { echo "configure: error: newly created file is older than distributed files!
+Check your system clock" 1>&2; exit 1; }
+fi
+rm -f conftest*
+echo "$ac_t""yes" 1>&6
+if test "$program_transform_name" = s,x,x,; then
+ program_transform_name=
+else
+ # Double any \ or $. echo might interpret backslashes.
+ cat <<\EOF_SED > conftestsed
+s,\\,\\\\,g; s,\$,$$,g
+EOF_SED
+ program_transform_name="`echo $program_transform_name|sed -f conftestsed`"
+ rm -f conftestsed
+fi
+test "$program_prefix" != NONE &&
+ program_transform_name="s,^,${program_prefix},; $program_transform_name"
+# Use a double $ so make ignores it.
+test "$program_suffix" != NONE &&
+ program_transform_name="s,\$\$,${program_suffix},; $program_transform_name"
+
+# sed with no file args requires a program.
+test "$program_transform_name" = "" && program_transform_name="s,x,x,"
+
+echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
+echo "configure:669: checking whether ${MAKE-make} sets \${MAKE}" >&5
+set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftestmake <<\EOF
+all:
+ @echo 'ac_maketemp="${MAKE}"'
+EOF
+# GNU make sometimes prints "make[1]: Entering...", which would confuse us.
+eval `${MAKE-make} -f conftestmake 2>/dev/null | grep temp=`
+if test -n "$ac_maketemp"; then
+ eval ac_cv_prog_make_${ac_make}_set=yes
+else
+ eval ac_cv_prog_make_${ac_make}_set=no
+fi
+rm -f conftestmake
+fi
+if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ SET_MAKE=
+else
+ echo "$ac_t""no" 1>&6
+ SET_MAKE="MAKE=${MAKE-make}"
+fi
+
+
+
+PACKAGE=libtinysrp
+
+VERSION=0.7.5
+
+if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
+ { echo "configure: error: source directory already configured; run "make distclean" there first" 1>&2; exit 1; }
+fi
+cat >> confdefs.h <<EOF
+#define PACKAGE "$PACKAGE"
+EOF
+
+cat >> confdefs.h <<EOF
+#define VERSION "$VERSION"
+EOF
+
+
+
+missing_dir=`cd $ac_aux_dir && pwd`
+echo $ac_n "checking for working aclocal""... $ac_c" 1>&6
+echo "configure:716: checking for working aclocal" >&5
+# Run test in a subshell; some versions of sh will print an error if
+# an executable is not found, even if stderr is redirected.
+# Redirect stdin to placate older versions of autoconf. Sigh.
+if (aclocal --version) < /dev/null > /dev/null 2>&1; then
+ ACLOCAL=aclocal
+ echo "$ac_t""found" 1>&6
+else
+ ACLOCAL="$missing_dir/missing aclocal"
+ echo "$ac_t""missing" 1>&6
+fi
+
+echo $ac_n "checking for working autoconf""... $ac_c" 1>&6
+echo "configure:729: checking for working autoconf" >&5
+# Run test in a subshell; some versions of sh will print an error if
+# an executable is not found, even if stderr is redirected.
+# Redirect stdin to placate older versions of autoconf. Sigh.
+if (autoconf --version) < /dev/null > /dev/null 2>&1; then
+ AUTOCONF=autoconf
+ echo "$ac_t""found" 1>&6
+else
+ AUTOCONF="$missing_dir/missing autoconf"
+ echo "$ac_t""missing" 1>&6
+fi
+
+echo $ac_n "checking for working automake""... $ac_c" 1>&6
+echo "configure:742: checking for working automake" >&5
+# Run test in a subshell; some versions of sh will print an error if
+# an executable is not found, even if stderr is redirected.
+# Redirect stdin to placate older versions of autoconf. Sigh.
+if (automake --version) < /dev/null > /dev/null 2>&1; then
+ AUTOMAKE=automake
+ echo "$ac_t""found" 1>&6
+else
+ AUTOMAKE="$missing_dir/missing automake"
+ echo "$ac_t""missing" 1>&6
+fi
+
+echo $ac_n "checking for working autoheader""... $ac_c" 1>&6
+echo "configure:755: checking for working autoheader" >&5
+# Run test in a subshell; some versions of sh will print an error if
+# an executable is not found, even if stderr is redirected.
+# Redirect stdin to placate older versions of autoconf. Sigh.
+if (autoheader --version) < /dev/null > /dev/null 2>&1; then
+ AUTOHEADER=autoheader
+ echo "$ac_t""found" 1>&6
+else
+ AUTOHEADER="$missing_dir/missing autoheader"
+ echo "$ac_t""missing" 1>&6
+fi
+
+echo $ac_n "checking for working makeinfo""... $ac_c" 1>&6
+echo "configure:768: checking for working makeinfo" >&5
+# Run test in a subshell; some versions of sh will print an error if
+# an executable is not found, even if stderr is redirected.
+# Redirect stdin to placate older versions of autoconf. Sigh.
+if (makeinfo --version) < /dev/null > /dev/null 2>&1; then
+ MAKEINFO=makeinfo
+ echo "$ac_t""found" 1>&6
+else
+ MAKEINFO="$missing_dir/missing makeinfo"
+ echo "$ac_t""missing" 1>&6
+fi
+
+
+
+test "$CFLAGS" = "" && CFLAGS="-O2"
+
+
+# Extract the first word of "gcc", so it can be a program name with args.
+set dummy gcc; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:788: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_CC="gcc"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+ echo "$ac_t""$CC" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+if test -z "$CC"; then
+ # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:818: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_prog_rejected=no
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then
+ ac_prog_rejected=yes
+ continue
+ fi
+ ac_cv_prog_CC="cc"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+if test $ac_prog_rejected = yes; then
+ # We found a bogon in the path, so make sure we never use it.
+ set dummy $ac_cv_prog_CC
+ shift
+ if test $# -gt 0; then
+ # We chose a different compiler from the bogus one.
+ # However, it has the same basename, so the bogon will be chosen
+ # first if we set CC to just the basename; use the full file name.
+ shift
+ set dummy "$ac_dir/$ac_word" "$@"
+ shift
+ ac_cv_prog_CC="$@"
+ fi
+fi
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+ echo "$ac_t""$CC" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+ if test -z "$CC"; then
+ case "`uname -s`" in
+ *win32* | *WIN32*)
+ # Extract the first word of "cl", so it can be a program name with args.
+set dummy cl; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:869: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_CC="cl"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+ echo "$ac_t""$CC" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+ ;;
+ esac
+ fi
+ test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; }
+fi
+
+echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
+echo "configure:901: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
+
+cat > conftest.$ac_ext << EOF
+
+#line 912 "configure"
+#include "confdefs.h"
+
+main(){return(0);}
+EOF
+if { (eval echo configure:917: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ ac_cv_prog_cc_works=yes
+ # If we can't run a trivial program, we are probably using a cross compiler.
+ if (./conftest; exit) 2>/dev/null; then
+ ac_cv_prog_cc_cross=no
+ else
+ ac_cv_prog_cc_cross=yes
+ fi
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ ac_cv_prog_cc_works=no
+fi
+rm -fr conftest*
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
+
+echo "$ac_t""$ac_cv_prog_cc_works" 1>&6
+if test $ac_cv_prog_cc_works = no; then
+ { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
+fi
+echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
+echo "configure:943: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
+cross_compiling=$ac_cv_prog_cc_cross
+
+echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
+echo "configure:948: checking whether we are using GNU C" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.c <<EOF
+#ifdef __GNUC__
+ yes;
+#endif
+EOF
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:957: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+ ac_cv_prog_gcc=yes
+else
+ ac_cv_prog_gcc=no
+fi
+fi
+
+echo "$ac_t""$ac_cv_prog_gcc" 1>&6
+
+if test $ac_cv_prog_gcc = yes; then
+ GCC=yes
+else
+ GCC=
+fi
+
+ac_test_CFLAGS="${CFLAGS+set}"
+ac_save_CFLAGS="$CFLAGS"
+CFLAGS=
+echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
+echo "configure:976: checking whether ${CC-cc} accepts -g" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ echo 'void f(){}' > conftest.c
+if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
+ ac_cv_prog_cc_g=yes
+else
+ ac_cv_prog_cc_g=no
+fi
+rm -f conftest*
+
+fi
+
+echo "$ac_t""$ac_cv_prog_cc_g" 1>&6
+if test "$ac_test_CFLAGS" = set; then
+ CFLAGS="$ac_save_CFLAGS"
+elif test $ac_cv_prog_cc_g = yes; then
+ if test "$GCC" = yes; then
+ CFLAGS="-g -O2"
+ else
+ CFLAGS="-g"
+ fi
+else
+ if test "$GCC" = yes; then
+ CFLAGS="-O2"
+ else
+ CFLAGS=
+ fi
+fi
+
+# Find a good install program. We prefer a C program (faster),
+# so one script is as good as another. But avoid the broken or
+# incompatible versions:
+# SysV /etc/install, /usr/sbin/install
+# SunOS /usr/etc/install
+# IRIX /sbin/install
+# AIX /bin/install
+# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
+# AFS /usr/afsws/bin/install, which mishandles nonexistent args
+# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
+# ./install, which can be erroneously created by make from ./install.sh.
+echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
+echo "configure:1019: checking for a BSD compatible install" >&5
+if test -z "$INSTALL"; then
+if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":"
+ for ac_dir in $PATH; do
+ # Account for people who put trailing slashes in PATH elements.
+ case "$ac_dir/" in
+ /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
+ *)
+ # OSF1 and SCO ODT 3.0 have their own names for install.
+ # Don't use installbsd from OSF since it installs stuff as root
+ # by default.
+ for ac_prog in ginstall scoinst install; do
+ if test -f $ac_dir/$ac_prog; then
+ if test $ac_prog = install &&
+ grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
+ # AIX install. It has an incompatible calling convention.
+ :
+ else
+ ac_cv_path_install="$ac_dir/$ac_prog -c"
+ break 2
+ fi
+ fi
+ done
+ ;;
+ esac
+ done
+ IFS="$ac_save_IFS"
+
+fi
+ if test "${ac_cv_path_install+set}" = set; then
+ INSTALL="$ac_cv_path_install"
+ else
+ # As a last resort, use the slow shell script. We don't cache a
+ # path for INSTALL within a source directory, because that will
+ # break other packages using the cache if that directory is
+ # removed, or if the path is relative.
+ INSTALL="$ac_install_sh"
+ fi
+fi
+echo "$ac_t""$INSTALL" 1>&6
+
+# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
+# It thinks the first close brace ends the variable substitution.
+test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
+
+test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}'
+
+test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
+
+echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6
+echo "configure:1072: checking whether ln -s works" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_LN_S'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ rm -f conftestdata
+if ln -s X conftestdata 2>/dev/null
+then
+ rm -f conftestdata
+ ac_cv_prog_LN_S="ln -s"
+else
+ ac_cv_prog_LN_S=ln
+fi
+fi
+LN_S="$ac_cv_prog_LN_S"
+if test "$ac_cv_prog_LN_S" = "ln -s"; then
+ echo "$ac_t""yes" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+# Extract the first word of "ranlib", so it can be a program name with args.
+set dummy ranlib; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:1095: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$RANLIB"; then
+ ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_RANLIB="ranlib"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+ test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":"
+fi
+fi
+RANLIB="$ac_cv_prog_RANLIB"
+if test -n "$RANLIB"; then
+ echo "$ac_t""$RANLIB" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+if test "$program_transform_name" = s,x,x,; then
+ program_transform_name=
+else
+ # Double any \ or $. echo might interpret backslashes.
+ cat <<\EOF_SED > conftestsed
+s,\\,\\\\,g; s,\$,$$,g
+EOF_SED
+ program_transform_name="`echo $program_transform_name|sed -f conftestsed`"
+ rm -f conftestsed
+fi
+test "$program_prefix" != NONE &&
+ program_transform_name="s,^,${program_prefix},; $program_transform_name"
+# Use a double $ so make ignores it.
+test "$program_suffix" != NONE &&
+ program_transform_name="s,\$\$,${program_suffix},; $program_transform_name"
+
+# sed with no file args requires a program.
+test "$program_transform_name" = "" && program_transform_name="s,x,x,"
+
+
+
+echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
+echo "configure:1144: checking how to run the C preprocessor" >&5
+# On Suns, sometimes $CPP names a directory.
+if test -n "$CPP" && test -d "$CPP"; then
+ CPP=
+fi
+if test -z "$CPP"; then
+if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ # This must be in double quotes, not single quotes, because CPP may get
+ # substituted into the Makefile and "${CC-cc}" will confuse make.
+ CPP="${CC-cc} -E"
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp.
+ cat > conftest.$ac_ext <<EOF
+#line 1159 "configure"
+#include "confdefs.h"
+#include <assert.h>
+Syntax Error
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1165: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ :
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ CPP="${CC-cc} -E -traditional-cpp"
+ cat > conftest.$ac_ext <<EOF
+#line 1176 "configure"
+#include "confdefs.h"
+#include <assert.h>
+Syntax Error
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1182: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ :
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ CPP="${CC-cc} -nologo -E"
+ cat > conftest.$ac_ext <<EOF
+#line 1193 "configure"
+#include "confdefs.h"
+#include <assert.h>
+Syntax Error
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1199: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ :
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ CPP=/lib/cpp
+fi
+rm -f conftest*
+fi
+rm -f conftest*
+fi
+rm -f conftest*
+ ac_cv_prog_CPP="$CPP"
+fi
+ CPP="$ac_cv_prog_CPP"
+else
+ ac_cv_prog_CPP="$CPP"
+fi
+echo "$ac_t""$CPP" 1>&6
+
+echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
+echo "configure:1224: checking for ANSI C header files" >&5
+if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1229 "configure"
+#include "confdefs.h"
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1237: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ ac_cv_header_stdc=yes
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+if test $ac_cv_header_stdc = yes; then
+ # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+cat > conftest.$ac_ext <<EOF
+#line 1254 "configure"
+#include "confdefs.h"
+#include <string.h>
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "memchr" >/dev/null 2>&1; then
+ :
+else
+ rm -rf conftest*
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+cat > conftest.$ac_ext <<EOF
+#line 1272 "configure"
+#include "confdefs.h"
+#include <stdlib.h>
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "free" >/dev/null 2>&1; then
+ :
+else
+ rm -rf conftest*
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+if test "$cross_compiling" = yes; then
+ :
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1293 "configure"
+#include "confdefs.h"
+#include <ctype.h>
+#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int main () { int i; for (i = 0; i < 256; i++)
+if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
+exit (0); }
+
+EOF
+if { (eval echo configure:1304: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+ :
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ ac_cv_header_stdc=no
+fi
+rm -fr conftest*
+fi
+
+fi
+fi
+
+echo "$ac_t""$ac_cv_header_stdc" 1>&6
+if test $ac_cv_header_stdc = yes; then
+ cat >> confdefs.h <<\EOF
+#define STDC_HEADERS 1
+EOF
+
+fi
+
+for ac_hdr in sgtty.h sys/ioctl.h sys/time.h termio.h termios.h unistd.h
+do
+ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+echo "configure:1331: checking for $ac_hdr" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1336 "configure"
+#include "confdefs.h"
+#include <$ac_hdr>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1341: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_hdr 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+
+
+echo $ac_n "checking for working const""... $ac_c" 1>&6
+echo "configure:1370: checking for working const" >&5
+if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1375 "configure"
+#include "confdefs.h"
+
+int main() {
+
+/* Ultrix mips cc rejects this. */
+typedef int charset[2]; const charset x;
+/* SunOS 4.1.1 cc rejects this. */
+char const *const *ccp;
+char **p;
+/* NEC SVR4.0.2 mips cc rejects this. */
+struct point {int x, y;};
+static struct point const zero = {0,0};
+/* AIX XL C 1.02.0.0 rejects this.
+ It does not let you subtract one const X* pointer from another in an arm
+ of an if-expression whose if-part is not a constant expression */
+const char *g = "string";
+ccp = &g + (g ? g-g : 0);
+/* HPUX 7.0 cc rejects these. */
+++ccp;
+p = (char**) ccp;
+ccp = (char const *const *) p;
+{ /* SCO 3.2v4 cc rejects this. */
+ char *t;
+ char const *s = 0 ? (char *) 0 : (char const *) 0;
+
+ *t++ = 0;
+}
+{ /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */
+ int x[] = {25, 17};
+ const int *foo = &x[0];
+ ++foo;
+}
+{ /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
+ typedef const int *iptr;
+ iptr p = 0;
+ ++p;
+}
+{ /* AIX XL C 1.02.0.0 rejects this saying
+ "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
+ struct s { int j; const int *ap[3]; };
+ struct s *b; b->j = 5;
+}
+{ /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
+ const int foo = 10;
+}
+
+; return 0; }
+EOF
+if { (eval echo configure:1424: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ ac_cv_c_const=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_c_const=no
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$ac_cv_c_const" 1>&6
+if test $ac_cv_c_const = no; then
+ cat >> confdefs.h <<\EOF
+#define const
+EOF
+
+fi
+
+echo $ac_n "checking for inline""... $ac_c" 1>&6
+echo "configure:1445: checking for inline" >&5
+if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ ac_cv_c_inline=no
+for ac_kw in inline __inline__ __inline; do
+ cat > conftest.$ac_ext <<EOF
+#line 1452 "configure"
+#include "confdefs.h"
+
+int main() {
+} $ac_kw foo() {
+; return 0; }
+EOF
+if { (eval echo configure:1459: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ ac_cv_c_inline=$ac_kw; break
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+fi
+rm -f conftest*
+done
+
+fi
+
+echo "$ac_t""$ac_cv_c_inline" 1>&6
+case "$ac_cv_c_inline" in
+ inline | yes) ;;
+ no) cat >> confdefs.h <<\EOF
+#define inline
+EOF
+ ;;
+ *) cat >> confdefs.h <<EOF
+#define inline $ac_cv_c_inline
+EOF
+ ;;
+esac
+
+echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
+echo "configure:1485: checking whether time.h and sys/time.h may both be included" >&5
+if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1490 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#include <sys/time.h>
+#include <time.h>
+int main() {
+struct tm *tp;
+; return 0; }
+EOF
+if { (eval echo configure:1499: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ ac_cv_header_time=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_header_time=no
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$ac_cv_header_time" 1>&6
+if test $ac_cv_header_time = yes; then
+ cat >> confdefs.h <<\EOF
+#define TIME_WITH_SYS_TIME 1
+EOF
+
+fi
+
+echo $ac_n "checking whether byte ordering is bigendian""... $ac_c" 1>&6
+echo "configure:1520: checking whether byte ordering is bigendian" >&5
+if eval "test \"`echo '$''{'ac_cv_c_bigendian'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ ac_cv_c_bigendian=unknown
+# See if sys/param.h defines the BYTE_ORDER macro.
+cat > conftest.$ac_ext <<EOF
+#line 1527 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#include <sys/param.h>
+int main() {
+
+#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
+ bogus endian macros
+#endif
+; return 0; }
+EOF
+if { (eval echo configure:1538: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ # It does; now see whether it defined to BIG_ENDIAN or not.
+cat > conftest.$ac_ext <<EOF
+#line 1542 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#include <sys/param.h>
+int main() {
+
+#if BYTE_ORDER != BIG_ENDIAN
+ not big endian
+#endif
+; return 0; }
+EOF
+if { (eval echo configure:1553: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ ac_cv_c_bigendian=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_c_bigendian=no
+fi
+rm -f conftest*
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+fi
+rm -f conftest*
+if test $ac_cv_c_bigendian = unknown; then
+if test "$cross_compiling" = yes; then
+ { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1573 "configure"
+#include "confdefs.h"
+main () {
+ /* Are we little or big endian? From Harbison&Steele. */
+ union
+ {
+ long l;
+ char c[sizeof (long)];
+ } u;
+ u.l = 1;
+ exit (u.c[sizeof (long) - 1] == 1);
+}
+EOF
+if { (eval echo configure:1586: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+ ac_cv_c_bigendian=no
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ ac_cv_c_bigendian=yes
+fi
+rm -fr conftest*
+fi
+
+fi
+fi
+
+echo "$ac_t""$ac_cv_c_bigendian" 1>&6
+if test $ac_cv_c_bigendian = yes; then
+ cat >> confdefs.h <<\EOF
+#define WORDS_BIGENDIAN 1
+EOF
+
+fi
+
+echo $ac_n "checking size of short""... $ac_c" 1>&6
+echo "configure:1610: checking size of short" >&5
+if eval "test \"`echo '$''{'ac_cv_sizeof_short'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test "$cross_compiling" = yes; then
+ { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1618 "configure"
+#include "confdefs.h"
+#include <stdio.h>
+main()
+{
+ FILE *f=fopen("conftestval", "w");
+ if (!f) exit(1);
+ fprintf(f, "%d\n", sizeof(short));
+ exit(0);
+}
+EOF
+if { (eval echo configure:1629: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+ ac_cv_sizeof_short=`cat conftestval`
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ ac_cv_sizeof_short=0
+fi
+rm -fr conftest*
+fi
+
+fi
+echo "$ac_t""$ac_cv_sizeof_short" 1>&6
+cat >> confdefs.h <<EOF
+#define SIZEOF_SHORT $ac_cv_sizeof_short
+EOF
+
+
+echo $ac_n "checking size of int""... $ac_c" 1>&6
+echo "configure:1649: checking size of int" >&5
+if eval "test \"`echo '$''{'ac_cv_sizeof_int'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test "$cross_compiling" = yes; then
+ { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1657 "configure"
+#include "confdefs.h"
+#include <stdio.h>
+main()
+{
+ FILE *f=fopen("conftestval", "w");
+ if (!f) exit(1);
+ fprintf(f, "%d\n", sizeof(int));
+ exit(0);
+}
+EOF
+if { (eval echo configure:1668: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+ ac_cv_sizeof_int=`cat conftestval`
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ ac_cv_sizeof_int=0
+fi
+rm -fr conftest*
+fi
+
+fi
+echo "$ac_t""$ac_cv_sizeof_int" 1>&6
+cat >> confdefs.h <<EOF
+#define SIZEOF_INT $ac_cv_sizeof_int
+EOF
+
+
+echo $ac_n "checking size of long""... $ac_c" 1>&6
+echo "configure:1688: checking size of long" >&5
+if eval "test \"`echo '$''{'ac_cv_sizeof_long'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test "$cross_compiling" = yes; then
+ { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1696 "configure"
+#include "confdefs.h"
+#include <stdio.h>
+main()
+{
+ FILE *f=fopen("conftestval", "w");
+ if (!f) exit(1);
+ fprintf(f, "%d\n", sizeof(long));
+ exit(0);
+}
+EOF
+if { (eval echo configure:1707: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+ ac_cv_sizeof_long=`cat conftestval`
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ ac_cv_sizeof_long=0
+fi
+rm -fr conftest*
+fi
+
+fi
+echo "$ac_t""$ac_cv_sizeof_long" 1>&6
+cat >> confdefs.h <<EOF
+#define SIZEOF_LONG $ac_cv_sizeof_long
+EOF
+
+
+echo $ac_n "checking size of long long""... $ac_c" 1>&6
+echo "configure:1727: checking size of long long" >&5
+if eval "test \"`echo '$''{'ac_cv_sizeof_long_long'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test "$cross_compiling" = yes; then
+ { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1735 "configure"
+#include "confdefs.h"
+#include <stdio.h>
+main()
+{
+ FILE *f=fopen("conftestval", "w");
+ if (!f) exit(1);
+ fprintf(f, "%d\n", sizeof(long long));
+ exit(0);
+}
+EOF
+if { (eval echo configure:1746: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+ ac_cv_sizeof_long_long=`cat conftestval`
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ ac_cv_sizeof_long_long=0
+fi
+rm -fr conftest*
+fi
+
+fi
+echo "$ac_t""$ac_cv_sizeof_long_long" 1>&6
+cat >> confdefs.h <<EOF
+#define SIZEOF_LONG_LONG $ac_cv_sizeof_long_long
+EOF
+
+
+cat > conftest.$ac_ext <<EOF
+#line 1766 "configure"
+#include "confdefs.h"
+
+int main() {
+volatile int i;
+; return 0; }
+EOF
+if { (eval echo configure:1773: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ :
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ cat >> confdefs.h <<\EOF
+#define volatile
+EOF
+
+fi
+rm -f conftest*
+echo $ac_n "checking whether char is unsigned""... $ac_c" 1>&6
+echo "configure:1786: checking whether char is unsigned" >&5
+if eval "test \"`echo '$''{'ac_cv_c_char_unsigned'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test "$GCC" = yes; then
+ # GCC predefines this symbol on systems where it applies.
+cat > conftest.$ac_ext <<EOF
+#line 1793 "configure"
+#include "confdefs.h"
+#ifdef __CHAR_UNSIGNED__
+ yes
+#endif
+
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "yes" >/dev/null 2>&1; then
+ rm -rf conftest*
+ ac_cv_c_char_unsigned=yes
+else
+ rm -rf conftest*
+ ac_cv_c_char_unsigned=no
+fi
+rm -f conftest*
+
+else
+if test "$cross_compiling" = yes; then
+ { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1815 "configure"
+#include "confdefs.h"
+/* volatile prevents gcc2 from optimizing the test away on sparcs. */
+#if !defined(__STDC__) || __STDC__ != 1
+#define volatile
+#endif
+main() {
+ volatile char c = 255; exit(c < 0);
+}
+EOF
+if { (eval echo configure:1825: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+ ac_cv_c_char_unsigned=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ ac_cv_c_char_unsigned=no
+fi
+rm -fr conftest*
+fi
+
+fi
+fi
+
+echo "$ac_t""$ac_cv_c_char_unsigned" 1>&6
+if test $ac_cv_c_char_unsigned = yes && test "$GCC" != yes; then
+ cat >> confdefs.h <<\EOF
+#define __CHAR_UNSIGNED__ 1
+EOF
+
+fi
+
+
+if test "$ac_cv_c_char_unsigned" = "yes"; then
+ signed=-signed
+fi
+
+
+for ac_func in sigaction strchr memcpy
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:1857: checking for $ac_func" >&5
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1862 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:1885: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_func 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+
+echo $ac_n "checking POSIX signal handlers""... $ac_c" 1>&6
+echo "configure:1911: checking POSIX signal handlers" >&5
+if eval "test \"`echo '$''{'ac_cv_has_posix_signals'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1916 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#include <signal.h>
+#ifdef signal
+#undef signal
+#endif
+extern void (*signal ()) ();
+int main() {
+
+; return 0; }
+EOF
+if { (eval echo configure:1928: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ ac_cv_has_posix_signals=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_has_posix_signals=no
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$ac_cv_has_posix_signals" 1>&6
+if test $ac_cv_has_posix_signals = yes; then
+ cat >> confdefs.h <<\EOF
+#define RETSIGTYPE void
+EOF
+ cat >> confdefs.h <<\EOF
+#define POSIX_SIGTYPE 1
+EOF
+
+else
+ if test $ac_cv_type_signal = void; then
+ cat >> confdefs.h <<\EOF
+#define RETSIGTYPE void
+EOF
+
+ else
+ cat >> confdefs.h <<\EOF
+#define RETSIGTYPE int
+EOF
+
+ fi
+fi
+ac_safe=`echo "termios.h" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for termios.h""... $ac_c" 1>&6
+echo "configure:1964: checking for termios.h" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1969 "configure"
+#include "confdefs.h"
+#include <termios.h>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1974: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ echo $ac_n "checking for cfsetispeed""... $ac_c" 1>&6
+echo "configure:1991: checking for cfsetispeed" >&5
+if eval "test \"`echo '$''{'ac_cv_func_cfsetispeed'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1996 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char cfsetispeed(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char cfsetispeed();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_cfsetispeed) || defined (__stub___cfsetispeed)
+choke me
+#else
+cfsetispeed();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:2019: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_func_cfsetispeed=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_func_cfsetispeed=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'cfsetispeed`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ cat >> confdefs.h <<\EOF
+#define POSIX_TERMIOS 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+
+
+
+cat >> confdefs.h <<\EOF
+#define SHA1HANDSOFF 1
+EOF
+
+
+trap '' 1 2 15
+cat > confcache <<\EOF
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs. It is not useful on other systems.
+# If it contains results you don't want to keep, you may remove or edit it.
+#
+# By default, configure uses ./config.cache as the cache file,
+# creating it if it does not exist already. You can give configure
+# the --cache-file=FILE option to use a different cache file; that is
+# what configure does when it calls configure scripts in
+# subdirectories, so they share the cache.
+# Giving --cache-file=/dev/null disables caching, for debugging configure.
+# config.status only pays attention to the cache file if you give it the
+# --recheck option to rerun configure.
+#
+EOF
+# The following way of writing the cache mishandles newlines in values,
+# but we know of no workaround that is simple, portable, and efficient.
+# So, don't put newlines in cache variables' values.
+# Ultrix sh set writes to stderr and can't be redirected directly,
+# and sets the high bit in the cache file unless we assign to the vars.
+(set) 2>&1 |
+ case `(ac_space=' '; set | grep ac_space) 2>&1` in
+ *ac_space=\ *)
+ # `set' does not quote correctly, so add quotes (double-quote substitution
+ # turns \\\\ into \\, and sed turns \\ into \).
+ sed -n \
+ -e "s/'/'\\\\''/g" \
+ -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p"
+ ;;
+ *)
+ # `set' quotes correctly as required by POSIX, so do not add quotes.
+ sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p'
+ ;;
+ esac >> confcache
+if cmp -s $cache_file confcache; then
+ :
+else
+ if test -w $cache_file; then
+ echo "updating cache $cache_file"
+ cat confcache > $cache_file
+ else
+ echo "not updating unwritable cache $cache_file"
+ fi
+fi
+rm -f confcache
+
+trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
+
+test "x$prefix" = xNONE && prefix=$ac_default_prefix
+# Let make expand exec_prefix.
+test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+
+# Any assignment to VPATH causes Sun make to only execute
+# the first set of double-colon rules, so remove it if not needed.
+# If there is a colon in the path, we need to keep it.
+if test "x$srcdir" = x.; then
+ ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d'
+fi
+
+trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15
+
+DEFS=-DHAVE_CONFIG_H
+
+# Without the "./", some shells look in PATH for config.status.
+: ${CONFIG_STATUS=./config.status}
+
+echo creating $CONFIG_STATUS
+rm -f $CONFIG_STATUS
+cat > $CONFIG_STATUS <<EOF
+#! /bin/sh
+# Generated automatically by configure.
+# Run this file to recreate the current configuration.
+# This directory was configured as follows,
+# on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+#
+# $0 $ac_configure_args
+#
+# Compiler output produced by configure, useful for debugging
+# configure, is in ./config.log if it exists.
+
+ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]"
+for ac_option
+do
+ case "\$ac_option" in
+ -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+ echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
+ exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
+ -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
+ echo "$CONFIG_STATUS generated by autoconf version 2.13"
+ exit 0 ;;
+ -help | --help | --hel | --he | --h)
+ echo "\$ac_cs_usage"; exit 0 ;;
+ *) echo "\$ac_cs_usage"; exit 1 ;;
+ esac
+done
+
+ac_given_srcdir=$srcdir
+ac_given_INSTALL="$INSTALL"
+
+trap 'rm -fr `echo "Makefile config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
+EOF
+cat >> $CONFIG_STATUS <<EOF
+
+# Protect against being on the right side of a sed subst in config.status.
+sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g;
+ s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF
+$ac_vpsub
+$extrasub
+s%@SHELL@%$SHELL%g
+s%@CFLAGS@%$CFLAGS%g
+s%@CPPFLAGS@%$CPPFLAGS%g
+s%@CXXFLAGS@%$CXXFLAGS%g
+s%@FFLAGS@%$FFLAGS%g
+s%@DEFS@%$DEFS%g
+s%@LDFLAGS@%$LDFLAGS%g
+s%@LIBS@%$LIBS%g
+s%@exec_prefix@%$exec_prefix%g
+s%@prefix@%$prefix%g
+s%@program_transform_name@%$program_transform_name%g
+s%@bindir@%$bindir%g
+s%@sbindir@%$sbindir%g
+s%@libexecdir@%$libexecdir%g
+s%@datadir@%$datadir%g
+s%@sysconfdir@%$sysconfdir%g
+s%@sharedstatedir@%$sharedstatedir%g
+s%@localstatedir@%$localstatedir%g
+s%@libdir@%$libdir%g
+s%@includedir@%$includedir%g
+s%@oldincludedir@%$oldincludedir%g
+s%@infodir@%$infodir%g
+s%@mandir@%$mandir%g
+s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
+s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g
+s%@INSTALL_DATA@%$INSTALL_DATA%g
+s%@PACKAGE@%$PACKAGE%g
+s%@VERSION@%$VERSION%g
+s%@ACLOCAL@%$ACLOCAL%g
+s%@AUTOCONF@%$AUTOCONF%g
+s%@AUTOMAKE@%$AUTOMAKE%g
+s%@AUTOHEADER@%$AUTOHEADER%g
+s%@MAKEINFO@%$MAKEINFO%g
+s%@SET_MAKE@%$SET_MAKE%g
+s%@CC@%$CC%g
+s%@LN_S@%$LN_S%g
+s%@RANLIB@%$RANLIB%g
+s%@CPP@%$CPP%g
+s%@signed@%$signed%g
+
+CEOF
+EOF
+
+cat >> $CONFIG_STATUS <<\EOF
+
+# Split the substitutions into bite-sized pieces for seds with
+# small command number limits, like on Digital OSF/1 and HP-UX.
+ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script.
+ac_file=1 # Number of current file.
+ac_beg=1 # First line for current file.
+ac_end=$ac_max_sed_cmds # Line after last line for current file.
+ac_more_lines=:
+ac_sed_cmds=""
+while $ac_more_lines; do
+ if test $ac_beg -gt 1; then
+ sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file
+ else
+ sed "${ac_end}q" conftest.subs > conftest.s$ac_file
+ fi
+ if test ! -s conftest.s$ac_file; then
+ ac_more_lines=false
+ rm -f conftest.s$ac_file
+ else
+ if test -z "$ac_sed_cmds"; then
+ ac_sed_cmds="sed -f conftest.s$ac_file"
+ else
+ ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file"
+ fi
+ ac_file=`expr $ac_file + 1`
+ ac_beg=$ac_end
+ ac_end=`expr $ac_end + $ac_max_sed_cmds`
+ fi
+done
+if test -z "$ac_sed_cmds"; then
+ ac_sed_cmds=cat
+fi
+EOF
+
+cat >> $CONFIG_STATUS <<EOF
+
+CONFIG_FILES=\${CONFIG_FILES-"Makefile"}
+EOF
+cat >> $CONFIG_STATUS <<\EOF
+for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
+ # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
+ case "$ac_file" in
+ *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
+ ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
+ *) ac_file_in="${ac_file}.in" ;;
+ esac
+
+ # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories.
+
+ # Remove last slash and all that follows it. Not all systems have dirname.
+ ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
+ if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
+ # The file is in a subdirectory.
+ test ! -d "$ac_dir" && mkdir "$ac_dir"
+ ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`"
+ # A "../" for each directory in $ac_dir_suffix.
+ ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'`
+ else
+ ac_dir_suffix= ac_dots=
+ fi
+
+ case "$ac_given_srcdir" in
+ .) srcdir=.
+ if test -z "$ac_dots"; then top_srcdir=.
+ else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;;
+ /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;;
+ *) # Relative path.
+ srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix"
+ top_srcdir="$ac_dots$ac_given_srcdir" ;;
+ esac
+
+ case "$ac_given_INSTALL" in
+ [/$]*) INSTALL="$ac_given_INSTALL" ;;
+ *) INSTALL="$ac_dots$ac_given_INSTALL" ;;
+ esac
+
+ echo creating "$ac_file"
+ rm -f "$ac_file"
+ configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure."
+ case "$ac_file" in
+ *Makefile*) ac_comsub="1i\\
+# $configure_input" ;;
+ *) ac_comsub= ;;
+ esac
+
+ ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
+ sed -e "$ac_comsub
+s%@configure_input@%$configure_input%g
+s%@srcdir@%$srcdir%g
+s%@top_srcdir@%$top_srcdir%g
+s%@INSTALL@%$INSTALL%g
+" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file
+fi; done
+rm -f conftest.s*
+
+# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where
+# NAME is the cpp macro being defined and VALUE is the value it is being given.
+#
+# ac_d sets the value in "#define NAME VALUE" lines.
+ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)'
+ac_dB='\([ ][ ]*\)[^ ]*%\1#\2'
+ac_dC='\3'
+ac_dD='%g'
+# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE".
+ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
+ac_uB='\([ ]\)%\1#\2define\3'
+ac_uC=' '
+ac_uD='\4%g'
+# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
+ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
+ac_eB='$%\1#\2define\3'
+ac_eC=' '
+ac_eD='%g'
+
+if test "${CONFIG_HEADERS+set}" != set; then
+EOF
+cat >> $CONFIG_STATUS <<EOF
+ CONFIG_HEADERS="config.h"
+EOF
+cat >> $CONFIG_STATUS <<\EOF
+fi
+for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then
+ # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
+ case "$ac_file" in
+ *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
+ ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
+ *) ac_file_in="${ac_file}.in" ;;
+ esac
+
+ echo creating $ac_file
+
+ rm -f conftest.frag conftest.in conftest.out
+ ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
+ cat $ac_file_inputs > conftest.in
+
+EOF
+
+# Transform confdefs.h into a sed script conftest.vals that substitutes
+# the proper values into config.h.in to produce config.h. And first:
+# Protect against being on the right side of a sed subst in config.status.
+# Protect against being in an unquoted here document in config.status.
+rm -f conftest.vals
+cat > conftest.hdr <<\EOF
+s/[\\&%]/\\&/g
+s%[\\$`]%\\&%g
+s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp
+s%ac_d%ac_u%gp
+s%ac_u%ac_e%gp
+EOF
+sed -n -f conftest.hdr confdefs.h > conftest.vals
+rm -f conftest.hdr
+
+# This sed command replaces #undef with comments. This is necessary, for
+# example, in the case of _POSIX_SOURCE, which is predefined and required
+# on some systems where configure will not decide to define it.
+cat >> conftest.vals <<\EOF
+s%^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */%
+EOF
+
+# Break up conftest.vals because some shells have a limit on
+# the size of here documents, and old seds have small limits too.
+
+rm -f conftest.tail
+while :
+do
+ ac_lines=`grep -c . conftest.vals`
+ # grep -c gives empty output for an empty file on some AIX systems.
+ if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi
+ # Write a limited-size here document to conftest.frag.
+ echo ' cat > conftest.frag <<CEOF' >> $CONFIG_STATUS
+ sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS
+ echo 'CEOF
+ sed -f conftest.frag conftest.in > conftest.out
+ rm -f conftest.in
+ mv conftest.out conftest.in
+' >> $CONFIG_STATUS
+ sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail
+ rm -f conftest.vals
+ mv conftest.tail conftest.vals
+done
+rm -f conftest.vals
+
+cat >> $CONFIG_STATUS <<\EOF
+ rm -f conftest.frag conftest.h
+ echo "/* $ac_file. Generated automatically by configure. */" > conftest.h
+ cat conftest.in >> conftest.h
+ rm -f conftest.in
+ if cmp -s $ac_file conftest.h 2>/dev/null; then
+ echo "$ac_file is unchanged"
+ rm -f conftest.h
+ else
+ # Remove last slash and all that follows it. Not all systems have dirname.
+ ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
+ if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
+ # The file is in a subdirectory.
+ test ! -d "$ac_dir" && mkdir "$ac_dir"
+ fi
+ rm -f $ac_file
+ mv conftest.h $ac_file
+ fi
+fi; done
+
+EOF
+cat >> $CONFIG_STATUS <<EOF
+
+
+EOF
+cat >> $CONFIG_STATUS <<\EOF
+test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h
+
+exit 0
+EOF
+chmod +x $CONFIG_STATUS
+rm -fr confdefs* $ac_clean_files
+test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1
+
diff --git a/package/network/services/ead/src/tinysrp/.svn/text-base/install-sh.svn-base b/package/network/services/ead/src/tinysrp/.svn/text-base/install-sh.svn-base
new file mode 100644
index 0000000..e843669
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/.svn/text-base/install-sh.svn-base
@@ -0,0 +1,250 @@
+#!/bin/sh
+#
+# install - install a program, script, or datafile
+# This comes from X11R5 (mit/util/scripts/install.sh).
+#
+# Copyright 1991 by the Massachusetts Institute of Technology
+#
+# Permission to use, copy, modify, distribute, and sell this software and its
+# documentation for any purpose is hereby granted without fee, provided that
+# the above copyright notice appear in all copies and that both that
+# copyright notice and this permission notice appear in supporting
+# documentation, and that the name of M.I.T. not be used in advertising or
+# publicity pertaining to distribution of the software without specific,
+# written prior permission. M.I.T. makes no representations about the
+# suitability of this software for any purpose. It is provided "as is"
+# without express or implied warranty.
+#
+# Calling this script install-sh is preferred over install.sh, to prevent
+# `make' implicit rules from creating a file called install from it
+# when there is no Makefile.
+#
+# This script is compatible with the BSD install script, but was written
+# from scratch. It can only install one file at a time, a restriction
+# shared with many OS's install programs.
+
+
+# set DOITPROG to echo to test this script
+
+# Don't use :- since 4.3BSD and earlier shells don't like it.
+doit="${DOITPROG-}"
+
+
+# put in absolute paths if you don't have them in your path; or use env. vars.
+
+mvprog="${MVPROG-mv}"
+cpprog="${CPPROG-cp}"
+chmodprog="${CHMODPROG-chmod}"
+chownprog="${CHOWNPROG-chown}"
+chgrpprog="${CHGRPPROG-chgrp}"
+stripprog="${STRIPPROG-strip}"
+rmprog="${RMPROG-rm}"
+mkdirprog="${MKDIRPROG-mkdir}"
+
+transformbasename=""
+transform_arg=""
+instcmd="$mvprog"
+chmodcmd="$chmodprog 0755"
+chowncmd=""
+chgrpcmd=""
+stripcmd=""
+rmcmd="$rmprog -f"
+mvcmd="$mvprog"
+src=""
+dst=""
+dir_arg=""
+
+while [ x"$1" != x ]; do
+ case $1 in
+ -c) instcmd="$cpprog"
+ shift
+ continue;;
+
+ -d) dir_arg=true
+ shift
+ continue;;
+
+ -m) chmodcmd="$chmodprog $2"
+ shift
+ shift
+ continue;;
+
+ -o) chowncmd="$chownprog $2"
+ shift
+ shift
+ continue;;
+
+ -g) chgrpcmd="$chgrpprog $2"
+ shift
+ shift
+ continue;;
+
+ -s) stripcmd="$stripprog"
+ shift
+ continue;;
+
+ -t=*) transformarg=`echo $1 | sed 's/-t=//'`
+ shift
+ continue;;
+
+ -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
+ shift
+ continue;;
+
+ *) if [ x"$src" = x ]
+ then
+ src=$1
+ else
+ # this colon is to work around a 386BSD /bin/sh bug
+ :
+ dst=$1
+ fi
+ shift
+ continue;;
+ esac
+done
+
+if [ x"$src" = x ]
+then
+ echo "install: no input file specified"
+ exit 1
+else
+ true
+fi
+
+if [ x"$dir_arg" != x ]; then
+ dst=$src
+ src=""
+
+ if [ -d $dst ]; then
+ instcmd=:
+ else
+ instcmd=mkdir
+ fi
+else
+
+# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
+# might cause directories to be created, which would be especially bad
+# if $src (and thus $dsttmp) contains '*'.
+
+ if [ -f $src -o -d $src ]
+ then
+ true
+ else
+ echo "install: $src does not exist"
+ exit 1
+ fi
+
+ if [ x"$dst" = x ]
+ then
+ echo "install: no destination specified"
+ exit 1
+ else
+ true
+ fi
+
+# If destination is a directory, append the input filename; if your system
+# does not like double slashes in filenames, you may need to add some logic
+
+ if [ -d $dst ]
+ then
+ dst="$dst"/`basename $src`
+ else
+ true
+ fi
+fi
+
+## this sed command emulates the dirname command
+dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
+
+# Make sure that the destination directory exists.
+# this part is taken from Noah Friedman's mkinstalldirs script
+
+# Skip lots of stat calls in the usual case.
+if [ ! -d "$dstdir" ]; then
+defaultIFS='
+'
+IFS="${IFS-${defaultIFS}}"
+
+oIFS="${IFS}"
+# Some sh's can't handle IFS=/ for some reason.
+IFS='%'
+set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
+IFS="${oIFS}"
+
+pathcomp=''
+
+while [ $# -ne 0 ] ; do
+ pathcomp="${pathcomp}${1}"
+ shift
+
+ if [ ! -d "${pathcomp}" ] ;
+ then
+ $mkdirprog "${pathcomp}"
+ else
+ true
+ fi
+
+ pathcomp="${pathcomp}/"
+done
+fi
+
+if [ x"$dir_arg" != x ]
+then
+ $doit $instcmd $dst &&
+
+ if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
+ if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
+ if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
+ if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
+else
+
+# If we're going to rename the final executable, determine the name now.
+
+ if [ x"$transformarg" = x ]
+ then
+ dstfile=`basename $dst`
+ else
+ dstfile=`basename $dst $transformbasename |
+ sed $transformarg`$transformbasename
+ fi
+
+# don't allow the sed command to completely eliminate the filename
+
+ if [ x"$dstfile" = x ]
+ then
+ dstfile=`basename $dst`
+ else
+ true
+ fi
+
+# Make a temp file name in the proper directory.
+
+ dsttmp=$dstdir/#inst.$$#
+
+# Move or copy the file name to the temp name
+
+ $doit $instcmd $src $dsttmp &&
+
+ trap "rm -f ${dsttmp}" 0 &&
+
+# and set any options; do chmod last to preserve setuid bits
+
+# If any of these fail, we abort the whole thing. If we want to
+# ignore errors from any of these, just make sure not to ignore
+# errors from the above "$doit $instcmd $src $dsttmp" command.
+
+ if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
+ if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
+ if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
+ if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
+
+# Now rename the file to the real destination.
+
+ $doit $rmcmd -f $dstdir/$dstfile &&
+ $doit $mvcmd $dsttmp $dstdir/$dstfile
+
+fi &&
+
+
+exit 0
diff --git a/package/network/services/ead/src/tinysrp/.svn/text-base/missing.svn-base b/package/network/services/ead/src/tinysrp/.svn/text-base/missing.svn-base
new file mode 100644
index 0000000..a6abd06
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/.svn/text-base/missing.svn-base
@@ -0,0 +1,134 @@
+#! /bin/sh
+# Common stub for a few missing GNU programs while installing.
+# Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+# Franc,ois Pinard <pinard@iro.umontreal.ca>, 1996.
+
+# 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; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+if test $# -eq 0; then
+ echo 1>&2 "Try \`$0 --help' for more information"
+ exit 1
+fi
+
+case "$1" in
+
+ -h|--h|--he|--hel|--help)
+ echo "\
+$0 [OPTION]... PROGRAM [ARGUMENT]...
+
+Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
+error status if there is no known handling for PROGRAM.
+
+Options:
+ -h, --help display this help and exit
+ -v, --version output version information and exit
+
+Supported PROGRAM values:
+ aclocal touch file \`aclocal.m4'
+ autoconf touch file \`configure'
+ autoheader touch file \`config.h.in'
+ automake touch all \`Makefile.in' files
+ bison touch file \`y.tab.c'
+ makeinfo touch the output file
+ yacc touch file \`y.tab.c'"
+ ;;
+
+ -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
+ echo "missing - GNU libit 0.0"
+ ;;
+
+ -*)
+ echo 1>&2 "$0: Unknown \`$1' option"
+ echo 1>&2 "Try \`$0 --help' for more information"
+ exit 1
+ ;;
+
+ aclocal)
+ echo 1>&2 "\
+WARNING: \`$1' is missing on your system. You should only need it if
+ you modified \`acinclude.m4' or \`configure.in'. You might want
+ to install the \`Automake' and \`Perl' packages. Grab them from
+ any GNU archive site."
+ touch aclocal.m4
+ ;;
+
+ autoconf)
+ echo 1>&2 "\
+WARNING: \`$1' is missing on your system. You should only need it if
+ you modified \`configure.in'. You might want to install the
+ \`Autoconf' and \`GNU m4' packages. Grab them from any GNU
+ archive site."
+ touch configure
+ ;;
+
+ autoheader)
+ echo 1>&2 "\
+WARNING: \`$1' is missing on your system. You should only need it if
+ you modified \`acconfig.h' or \`configure.in'. You might want
+ to install the \`Autoconf' and \`GNU m4' packages. Grab them
+ from any GNU archive site."
+ touch config.h.in
+ ;;
+
+ automake)
+ echo 1>&2 "\
+WARNING: \`$1' is missing on your system. You should only need it if
+ you modified \`Makefile.am', \`acinclude.m4' or \`configure.in'.
+ You might want to install the \`Automake' and \`Perl' packages.
+ Grab them from any GNU archive site."
+ find . -type f -name Makefile.am -print \
+ | sed 's/^\(.*\).am$/touch \1.in/' \
+ | sh
+ ;;
+
+ bison|yacc)
+ echo 1>&2 "\
+WARNING: \`$1' is missing on your system. You should only need it if
+ you modified a \`.y' file. You may need the \`Bison' package
+ in order for those modifications to take effect. You can get
+ \`Bison' from any GNU archive site."
+ touch y.tab.c
+ ;;
+
+ makeinfo)
+ echo 1>&2 "\
+WARNING: \`$1' is missing on your system. You should only need it if
+ you modified a \`.texi' or \`.texinfo' file, or any other file
+ indirectly affecting the aspect of the manual. The spurious
+ call might also be the consequence of using a buggy \`make' (AIX,
+ DU, IRIX). You might want to install the \`Texinfo' package or
+ the \`GNU make' package. Grab either from any GNU archive site."
+ file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
+ if test -z "$file"; then
+ file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
+ file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
+ fi
+ touch $file
+ ;;
+
+ *)
+ echo 1>&2 "\
+WARNING: \`$1' is needed, and you do not seem to have it handy on your
+ system. You might have modified some files without having the
+ proper tools for further handling them. Check the \`README' file,
+ it often tells you about the needed prerequirements for installing
+ this package. You may also peek at any GNU archive site, in case
+ some other package would contain this missing \`$1' program."
+ exit 1
+ ;;
+esac
+
+exit 0
diff --git a/package/network/services/ead/src/tinysrp/.svn/text-base/mkinstalldirs.svn-base b/package/network/services/ead/src/tinysrp/.svn/text-base/mkinstalldirs.svn-base
new file mode 100644
index 0000000..3bc1836
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/.svn/text-base/mkinstalldirs.svn-base
@@ -0,0 +1,39 @@
+#! /bin/sh
+# mkinstalldirs --- make directory hierarchy
+# Author: Noah Friedman <friedman@prep.ai.mit.edu>
+# Created: 1993-05-16
+# Public domain
+
+
+errstatus=0
+
+for file
+do
+ set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
+ shift
+
+ pathcomp=
+ for d
+ do
+ pathcomp="$pathcomp$d"
+ case "$pathcomp" in
+ -* ) pathcomp=./$pathcomp ;;
+ esac
+
+ if test ! -d "$pathcomp"; then
+ echo "mkdir $pathcomp" 1>&2
+
+ mkdir "$pathcomp" || lasterr=$?
+
+ if test ! -d "$pathcomp"; then
+ errstatus=$lasterr
+ fi
+ fi
+
+ pathcomp="$pathcomp/"
+ done
+done
+
+exit $errstatus
+
+# mkinstalldirs ends here
diff --git a/package/network/services/ead/src/tinysrp/.svn/text-base/srvtest.c.svn-base b/package/network/services/ead/src/tinysrp/.svn/text-base/srvtest.c.svn-base
new file mode 100644
index 0000000..e09d501
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/.svn/text-base/srvtest.c.svn-base
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 1997-1999 The Stanford SRP Authentication Project
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF
+ * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * In addition, the following conditions apply:
+ *
+ * 1. Any software that incorporates the SRP authentication technology
+ * must display the following acknowlegment:
+ * "This product uses the 'Secure Remote Password' cryptographic
+ * authentication system developed by Tom Wu (tjw@CS.Stanford.EDU)."
+ *
+ * 2. Any software that incorporates all or part of the SRP distribution
+ * itself must also display the following acknowledgment:
+ * "This product includes software developed by Tom Wu and Eugene
+ * Jhong for the SRP Distribution (http://srp.stanford.edu/srp/)."
+ *
+ * 3. Redistributions in source or binary form must retain an intact copy
+ * of this copyright notice and list of conditions.
+ */
+
+#include <stdio.h>
+#include "t_defines.h"
+#include "t_pwd.h"
+#include "t_server.h"
+
+int
+main(argc, argv)
+ int argc;
+ char * argv[];
+{
+ struct t_server * ts;
+ struct t_pw * tpw;
+ struct t_conf * tcnf;
+ struct t_num * B;
+ char username[MAXUSERLEN];
+ char hexbuf[MAXHEXPARAMLEN];
+ char buf[MAXPARAMLEN];
+ struct t_num A;
+ unsigned char * skey;
+ unsigned char cbuf[20];
+ FILE * fp;
+ FILE * fp2;
+ char confname[256];
+
+ printf("Enter username: ");
+ fgets(username, sizeof(username), stdin);
+ username[strlen(username) - 1] = '\0';
+ ts = t_serveropen(username);
+
+ if(ts == NULL) {
+ fprintf(stderr, "User %s not found\n", username);
+ exit(1);
+ }
+
+#if 0
+ printf("n: %s\n", t_tob64(hexbuf, ts->n.data, ts->n.len));
+ printf("g: %s\n", t_tob64(hexbuf, ts->g.data, ts->g.len));
+#endif
+ printf("index (to client): %d\n", ts->index);
+ printf("salt (to client): %s\n", t_tob64(hexbuf, ts->s.data, ts->s.len));
+
+ B = t_servergenexp(ts);
+ printf("Enter A (from client): ");
+ fgets(hexbuf, sizeof(hexbuf), stdin);
+ A.data = buf;
+ A.len = t_fromb64(A.data, hexbuf);
+
+ printf("B (to client): %s\n", t_tob64(hexbuf, B->data, B->len));
+
+ skey = t_servergetkey(ts, &A);
+ printf("Session key: %s\n", t_tohex(hexbuf, skey, 40));
+
+ /* printf("[Expected response: %s]\n", t_tohex(hexbuf, cbuf, 16)); */
+
+ printf("Enter response (from client): ");
+ fgets(hexbuf, sizeof(hexbuf), stdin);
+ hexbuf[strlen(hexbuf) - 1] = '\0';
+ t_fromhex(cbuf, hexbuf);
+
+ if(t_serververify(ts, cbuf) == 0) {
+ printf("Authentication successful.\n");
+ printf("Response (to client): %s\n",
+ t_tohex(hexbuf, t_serverresponse(ts), RESPONSE_LEN));
+ } else
+ printf("Authentication failed.\n");
+
+ t_serverclose(ts);
+
+ return 0;
+}
diff --git a/package/network/services/ead/src/tinysrp/.svn/text-base/stamp-h.in.svn-base b/package/network/services/ead/src/tinysrp/.svn/text-base/stamp-h.in.svn-base
new file mode 100644
index 0000000..9788f70
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/.svn/text-base/stamp-h.in.svn-base
@@ -0,0 +1 @@
+timestamp
diff --git a/package/network/services/ead/src/tinysrp/.svn/text-base/t_client.c.svn-base b/package/network/services/ead/src/tinysrp/.svn/text-base/t_client.c.svn-base
new file mode 100644
index 0000000..ebdd203
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/.svn/text-base/t_client.c.svn-base
@@ -0,0 +1,287 @@
+/*
+ * Copyright (c) 1997-1999 The Stanford SRP Authentication Project
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF
+ * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * In addition, the following conditions apply:
+ *
+ * 1. Any software that incorporates the SRP authentication technology
+ * must display the following acknowlegment:
+ * "This product uses the 'Secure Remote Password' cryptographic
+ * authentication system developed by Tom Wu (tjw@CS.Stanford.EDU)."
+ *
+ * 2. Any software that incorporates all or part of the SRP distribution
+ * itself must also display the following acknowledgment:
+ * "This product includes software developed by Tom Wu and Eugene
+ * Jhong for the SRP Distribution (http://srp.stanford.edu/srp/)."
+ *
+ * 3. Redistributions in source or binary form must retain an intact copy
+ * of this copyright notice and list of conditions.
+ */
+
+#include <stdio.h>
+#include "t_defines.h"
+#include "t_pwd.h"
+#include "t_client.h"
+#include "t_sha.h"
+
+_TYPE( struct t_client * )
+t_clientopen(u, n, g, s)
+ const char * u;
+ struct t_num * n;
+ struct t_num * g;
+ struct t_num * s;
+{
+ struct t_client * tc;
+ unsigned char buf1[SHA_DIGESTSIZE], buf2[SHA_DIGESTSIZE];
+ SHA1_CTX ctxt;
+ int i, validated;
+ struct t_preconf * tpc;
+
+ BigInteger nn, gg, n12, r;
+
+ validated = 0;
+ if(n->len < MIN_MOD_BYTES)
+ return 0;
+ for(i = 0; i < t_getprecount(); ++i) {
+ tpc = t_getpreparam(i);
+ if(tpc->modulus.len == n->len && tpc->generator.len == g->len &&
+ memcmp(tpc->modulus.data, n->data, n->len) == 0 &&
+ memcmp(tpc->generator.data, g->data, g->len) == 0) {
+ validated = 1; /* Match found, done */
+ break;
+ }
+ }
+
+ if(validated == 0)
+ return 0;
+
+ if((tc = malloc(sizeof(struct t_client))) == 0)
+ return 0;
+
+ strncpy(tc->username, u, MAXUSERLEN);
+
+ SHA1Init(&tc->hash);
+
+ tc->n.len = n->len;
+ tc->n.data = tc->nbuf;
+ memcpy(tc->n.data, n->data, tc->n.len);
+
+ SHA1Init(&ctxt);
+ SHA1Update(&ctxt, tc->n.data, tc->n.len);
+ SHA1Final(buf1, &ctxt);
+
+ tc->g.len = g->len;
+ tc->g.data = tc->gbuf;
+ memcpy(tc->g.data, g->data, tc->g.len);
+
+ SHA1Init(&ctxt);
+ SHA1Update(&ctxt, tc->g.data, tc->g.len);
+ SHA1Final(buf2, &ctxt);
+
+ for(i = 0; i < sizeof(buf1); ++i)
+ buf1[i] ^= buf2[i];
+
+ SHA1Update(&tc->hash, buf1, sizeof(buf1));
+
+ SHA1Init(&ctxt);
+ SHA1Update(&ctxt, tc->username, strlen(tc->username));
+ SHA1Final(buf1, &ctxt);
+
+ SHA1Update(&tc->hash, buf1, sizeof(buf1));
+
+ tc->s.len = s->len;
+ tc->s.data = tc->sbuf;
+ memcpy(tc->s.data, s->data, tc->s.len);
+
+ SHA1Update(&tc->hash, tc->s.data, tc->s.len);
+
+ tc->a.data = tc->abuf;
+ tc->A.data = tc->Abuf;
+ tc->p.data = tc->pbuf;
+ tc->v.data = tc->vbuf;
+
+ SHA1Init(&tc->ckhash);
+
+ return tc;
+}
+
+_TYPE( struct t_num * )
+t_clientgenexp(tc)
+ struct t_client * tc;
+{
+ BigInteger a, A, n, g;
+
+ if(tc->n.len < ALEN)
+ tc->a.len = tc->n.len;
+ else
+ tc->a.len = ALEN;
+
+ t_random(tc->a.data, tc->a.len);
+ a = BigIntegerFromBytes(tc->a.data, tc->a.len);
+ n = BigIntegerFromBytes(tc->n.data, tc->n.len);
+ g = BigIntegerFromBytes(tc->g.data, tc->g.len);
+ A = BigIntegerFromInt(0);
+ BigIntegerModExp(A, g, a, n);
+ tc->A.len = BigIntegerToBytes(A, tc->A.data);
+
+ BigIntegerFree(A);
+ BigIntegerFree(a);
+ BigIntegerFree(g);
+ BigIntegerFree(n);
+
+ SHA1Update(&tc->hash, tc->A.data, tc->A.len);
+ SHA1Update(&tc->ckhash, tc->A.data, tc->A.len);
+
+ return &tc->A;
+}
+
+_TYPE( void )
+t_clientpasswd(tc, password)
+ struct t_client * tc;
+ char * password;
+{
+ BigInteger n, g, p, v;
+ SHA1_CTX ctxt;
+ unsigned char dig[SHA_DIGESTSIZE];
+
+ n = BigIntegerFromBytes(tc->n.data, tc->n.len);
+ g = BigIntegerFromBytes(tc->g.data, tc->g.len);
+
+ SHA1Init(&ctxt);
+ SHA1Update(&ctxt, tc->username, strlen(tc->username));
+ SHA1Update(&ctxt, ":", 1);
+ SHA1Update(&ctxt, password, strlen(password));
+ SHA1Final(dig, &ctxt);
+
+ SHA1Init(&ctxt);
+ SHA1Update(&ctxt, tc->s.data, tc->s.len);
+ SHA1Update(&ctxt, dig, sizeof(dig));
+ SHA1Final(dig, &ctxt);
+
+ p = BigIntegerFromBytes(dig, sizeof(dig));
+
+ v = BigIntegerFromInt(0);
+ BigIntegerModExp(v, g, p, n);
+
+ tc->p.len = BigIntegerToBytes(p, tc->p.data);
+ BigIntegerFree(p);
+
+ tc->v.len = BigIntegerToBytes(v, tc->v.data);
+ BigIntegerFree(v);
+}
+
+_TYPE( unsigned char * )
+t_clientgetkey(tc, serverval)
+ struct t_client * tc;
+ struct t_num * serverval;
+{
+ BigInteger n, B, v, p, a, sum, S;
+ unsigned char sbuf[MAXPARAMLEN];
+ unsigned char dig[SHA_DIGESTSIZE];
+ unsigned slen;
+ unsigned int u;
+ SHA1_CTX ctxt;
+
+ SHA1Init(&ctxt);
+ SHA1Update(&ctxt, serverval->data, serverval->len);
+ SHA1Final(dig, &ctxt);
+ u = (dig[0] << 24) | (dig[1] << 16) | (dig[2] << 8) | dig[3];
+ if(u == 0)
+ return NULL;
+
+ SHA1Update(&tc->hash, serverval->data, serverval->len);
+
+ B = BigIntegerFromBytes(serverval->data, serverval->len);
+ n = BigIntegerFromBytes(tc->n.data, tc->n.len);
+
+ if(BigIntegerCmp(B, n) >= 0 || BigIntegerCmpInt(B, 0) == 0) {
+ BigIntegerFree(B);
+ BigIntegerFree(n);
+ return NULL;
+ }
+ v = BigIntegerFromBytes(tc->v.data, tc->v.len);
+ if(BigIntegerCmp(B, v) < 0)
+ BigIntegerAdd(B, B, n);
+ BigIntegerSub(B, B, v);
+ BigIntegerFree(v);
+
+ a = BigIntegerFromBytes(tc->a.data, tc->a.len);
+ p = BigIntegerFromBytes(tc->p.data, tc->p.len);
+
+ sum = BigIntegerFromInt(0);
+ BigIntegerMulInt(sum, p, u);
+ BigIntegerAdd(sum, sum, a);
+
+ BigIntegerFree(p);
+ BigIntegerFree(a);
+
+ S = BigIntegerFromInt(0);
+ BigIntegerModExp(S, B, sum, n);
+ slen = BigIntegerToBytes(S, sbuf);
+
+ BigIntegerFree(S);
+ BigIntegerFree(sum);
+ BigIntegerFree(B);
+ BigIntegerFree(n);
+
+ t_sessionkey(tc->session_key, sbuf, slen);
+ memset(sbuf, 0, slen);
+
+ SHA1Update(&tc->hash, tc->session_key, sizeof(tc->session_key));
+
+ SHA1Final(tc->session_response, &tc->hash);
+ SHA1Update(&tc->ckhash, tc->session_response, sizeof(tc->session_response));
+ SHA1Update(&tc->ckhash, tc->session_key, sizeof(tc->session_key));
+
+ return tc->session_key;
+}
+
+_TYPE( int )
+t_clientverify(tc, resp)
+ struct t_client * tc;
+ unsigned char * resp;
+{
+ unsigned char expected[SHA_DIGESTSIZE];
+
+ SHA1Final(expected, &tc->ckhash);
+ return memcmp(expected, resp, sizeof(expected));
+}
+
+_TYPE( unsigned char * )
+t_clientresponse(tc)
+ struct t_client * tc;
+{
+ return tc->session_response;
+}
+
+_TYPE( void )
+t_clientclose(tc)
+ struct t_client * tc;
+{
+ memset(tc->abuf, 0, sizeof(tc->abuf));
+ memset(tc->pbuf, 0, sizeof(tc->pbuf));
+ memset(tc->vbuf, 0, sizeof(tc->vbuf));
+ memset(tc->session_key, 0, sizeof(tc->session_key));
+ free(tc);
+}
diff --git a/package/network/services/ead/src/tinysrp/.svn/text-base/t_client.h.svn-base b/package/network/services/ead/src/tinysrp/.svn/text-base/t_client.h.svn-base
new file mode 100644
index 0000000..42922af
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/.svn/text-base/t_client.h.svn-base
@@ -0,0 +1,148 @@
+/*
+ * Copyright (c) 1997-1999 The Stanford SRP Authentication Project
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF
+ * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * In addition, the following conditions apply:
+ *
+ * 1. Any software that incorporates the SRP authentication technology
+ * must display the following acknowlegment:
+ * "This product uses the 'Secure Remote Password' cryptographic
+ * authentication system developed by Tom Wu (tjw@CS.Stanford.EDU)."
+ *
+ * 2. Any software that incorporates all or part of the SRP distribution
+ * itself must also display the following acknowledgment:
+ * "This product includes software developed by Tom Wu and Eugene
+ * Jhong for the SRP Distribution (http://srp.stanford.edu/srp/)."
+ *
+ * 3. Redistributions in source or binary form must retain an intact copy
+ * of this copyright notice and list of conditions.
+ */
+
+#ifndef T_CLIENT_H
+#define T_CLIENT_H
+
+#include "t_sha.h"
+
+#if !defined(P)
+#ifdef __STDC__
+#define P(x) x
+#else
+#define P(x) ()
+#endif
+#endif
+
+/* For building dynamic link libraries under windows, windows NT
+ * using MSVC1.5 or MSVC2.0
+ */
+
+#ifndef _DLLDECL
+#define _DLLDECL
+
+#ifdef MSVC15 /* MSVC1.5 support for 16 bit apps */
+#define _MSVC15EXPORT _export
+#define _MSVC20EXPORT
+#define _DLLAPI _export _pascal
+#define _TYPE(a) a _MSVC15EXPORT
+#define DLLEXPORT 1
+
+#elif MSVC20
+#define _MSVC15EXPORT
+#define _MSVC20EXPORT _declspec(dllexport)
+#define _DLLAPI
+#define _TYPE(a) _MSVC20EXPORT a
+#define DLLEXPORT 1
+
+#else /* Default, non-dll. Use this for Unix or DOS */
+#define _MSVC15DEXPORT
+#define _MSVC20EXPORT
+#define _DLLAPI
+#define _TYPE(a) a
+#endif
+#endif
+
+#define ALEN 32
+#define MIN_MOD_BYTES 64 /* 512 bits */
+
+struct t_client {
+ struct t_num n;
+ struct t_num g;
+ struct t_num s;
+
+ struct t_num a;
+ struct t_num A;
+
+ struct t_num p;
+ struct t_num v;
+
+ SHA1_CTX hash, ckhash;
+
+ char username[MAXUSERLEN];
+ unsigned char session_key[SESSION_KEY_LEN];
+ unsigned char session_response[RESPONSE_LEN];
+
+ unsigned char nbuf[MAXPARAMLEN], gbuf[MAXPARAMLEN], sbuf[MAXSALTLEN];
+ unsigned char pbuf[MAXPARAMLEN], vbuf[MAXPARAMLEN];
+ unsigned char abuf[ALEN], Abuf[MAXPARAMLEN];
+};
+
+/*
+ * SRP client-side negotiation
+ *
+ * This code negotiates the client side of an SRP exchange.
+ * "t_clientopen" accepts a username, and N, g, and s parameters,
+ * which are usually sent by the server in the first round.
+ * The client should then call...
+ * "t_clientgenexp" will generate a random 256-bit exponent and
+ * raise g to that power, returning the result. This result
+ * should be sent to the server as w(p).
+ * "t_clientpasswd" accepts the user's password, which should be
+ * entered locally and updates the client's state.
+ * "t_clientgetkey" accepts the exponential y(p), which should
+ * be sent by the server in the next round and computes the
+ * 256-bit session key. This data should be saved before the
+ * session is closed.
+ * "t_clientresponse" computes the session key proof as SHA(y(p), K).
+ * "t_clientclose" closes the session and frees its memory.
+ *
+ * Note that authentication is not performed per se; it is up
+ * to either/both sides of the protocol to now verify securely
+ * that their session keys agree in order to establish authenticity.
+ * One possible way is through "oracle hashing"; one side sends
+ * r, the other replies with H(r,K), where H() is a hash function.
+ *
+ * t_clientresponse and t_clientverify now implement a version of
+ * the session-key verification described above.
+ */
+_TYPE( struct t_client * )
+ t_clientopen P((const char *, struct t_num *, struct t_num *,
+ struct t_num *));
+_TYPE( struct t_num * ) t_clientgenexp P((struct t_client *));
+_TYPE( void ) t_clientpasswd P((struct t_client *, char *));
+_TYPE( unsigned char * )
+ t_clientgetkey P((struct t_client *, struct t_num *));
+_TYPE( int ) t_clientverify P((struct t_client *, unsigned char *));
+_TYPE( unsigned char * ) t_clientresponse P((struct t_client *));
+_TYPE( void ) t_clientclose P((struct t_client *));
+
+#endif
diff --git a/package/network/services/ead/src/tinysrp/.svn/text-base/t_conf.c.svn-base b/package/network/services/ead/src/tinysrp/.svn/text-base/t_conf.c.svn-base
new file mode 100644
index 0000000..fbe6f41
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/.svn/text-base/t_conf.c.svn-base
@@ -0,0 +1,1080 @@
+/*
+ * Copyright (c) 1997-1999 The Stanford SRP Authentication Project
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF
+ * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * In addition, the following conditions apply:
+ *
+ * 1. Any software that incorporates the SRP authentication technology
+ * must display the following acknowlegment:
+ * "This product uses the 'Secure Remote Password' cryptographic
+ * authentication system developed by Tom Wu (tjw@CS.Stanford.EDU)."
+ *
+ * 2. Any software that incorporates all or part of the SRP distribution
+ * itself must also display the following acknowledgment:
+ * "This product includes software developed by Tom Wu and Eugene
+ * Jhong for the SRP Distribution (http://srp.stanford.edu/srp/)."
+ *
+ * 3. Redistributions in source or binary form must retain an intact copy
+ * of this copyright notice and list of conditions.
+ */
+
+#include <stdio.h>
+
+#include "t_defines.h"
+#include "t_pwd.h"
+#include "t_read.h"
+#include "bn.h"
+#include "bn_lcl.h"
+#include "bn_prime.h"
+
+#define TABLE_SIZE 32
+
+static int witness(BIGNUM *w, const BIGNUM *a, const BIGNUM *a1,
+ const BIGNUM *a1_odd, int k, BN_CTX *ctx, BN_MONT_CTX *mont);
+
+/*
+ * This is the safe prime generation logic.
+ * To generate a safe prime p (where p = 2q+1 and q is prime), we start
+ * with a random odd q that is one bit shorter than the desired length
+ * of p. We use a simple 30-element sieve to filter the values of q
+ * and consider only those that are 11, 23, or 29 (mod 30). (If q were
+ * anything else, either q or p would be divisible by 2, 3, or 5).
+ * For the values of q that are left, we apply the following tests in
+ * this order:
+ *
+ * trial divide q
+ * let p = 2q + 1
+ * trial divide p
+ * apply Fermat test to q (2^q == 2 (mod q))
+ * apply Fermat test to p (2^p == 2 (mod p))
+ * apply real probablistic primality test to q
+ * apply real probablistic primality test to p
+ *
+ * A number that passes all these tests is considered a safe prime for
+ * our purposes. The tests are ordered this way for efficiency; the
+ * slower tests are run rarely if ever at all.
+ */
+
+static int
+trialdiv(x)
+ const BigInteger x;
+{
+ static int primes[] = { /* All odd primes < 256 */
+ 3, 5, 7, 11, 13, 17, 19, 23, 29,
+ 31, 37, 41, 43, 47, 53, 59, 61, 67,
+ 71, 73, 79, 83, 89, 97, 101, 103,
+ 107, 109, 113, 127, 131, 137, 139, 149, 151,
+ 157, 163, 167, 173, 179, 181, 191, 193, 197,
+ 199, 211, 223, 227, 229, 233, 239, 241, 251
+ };
+ static int nprimes = sizeof(primes) / sizeof(int);
+ int i;
+
+ for(i = 0; i < nprimes; ++i) {
+ if(BigIntegerModInt(x, primes[i]) == 0)
+ return primes[i];
+ }
+ return 1;
+}
+
+/* x + sieve30[x%30] == 11, 23, or 29 (mod 30) */
+
+static int sieve30[] =
+{ 11, 10, 9, 8, 7, 6, 5, 4, 3, 2,
+ 1, 12, 11, 10, 9, 8, 7, 6, 5, 4,
+ 3, 2, 1, 6, 5, 4, 3, 2, 1, 12
+};
+
+/* Find a Sophie-Germain prime between "lo" and "hi". NOTE: this is not
+ a "safe prime", but the smaller prime. Take 2q+1 to get the safe prime. */
+
+static void
+sophie_germain(q, lo, hi)
+ BigInteger q; /* assumed initialized */
+ const BigInteger lo;
+ const BigInteger hi;
+{
+ BigInteger m, p, r;
+ char parambuf[MAXPARAMLEN];
+ int foundprime = 0;
+ int i, mod30;
+
+ m = BigIntegerFromInt(0);
+ BigIntegerSub(m, hi, lo);
+ i = (BigIntegerBitLen(m) + 7) / 8;
+ t_random(parambuf, i);
+ r = BigIntegerFromBytes(parambuf, i);
+ BigIntegerMod(r, r, m);
+
+ BigIntegerAdd(q, r, lo);
+ if(BigIntegerModInt(q, 2) == 0)
+ BigIntegerAddInt(q, q, 1); /* make q odd */
+
+ mod30 = BigIntegerModInt(q, 30); /* mod30 = q % 30 */
+
+ BigIntegerFree(m);
+ m = BigIntegerFromInt(2); /* m = 2 */
+ p = BigIntegerFromInt(0);
+
+ while(BigIntegerCmp(q, hi) < 0) {
+ if(trialdiv(q) < 2) {
+ BigIntegerMulInt(p, q, 2); /* p = 2 * q */
+ BigIntegerAddInt(p, p, 1); /* p += 1 */
+ if(trialdiv(p) < 2) {
+ BigIntegerModExp(r, m, q, q); /* r = 2^q % q */
+ if(BigIntegerCmpInt(r, 2) == 0) { /* if(r == 2) */
+ BigIntegerModExp(r, m, p, p); /* r = 2^p % p */
+ if(BigIntegerCmpInt(r, 2) == 0) { /* if(r == 2) */
+ if(BigIntegerCheckPrime(q) && BigIntegerCheckPrime(p)) {
+ ++foundprime;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ i = sieve30[mod30];
+ BigIntegerAddInt(q, q, i); /* q += i */
+ mod30 = (mod30 + i) % 30;
+ }
+
+ /* should wrap around on failure */
+ if(!foundprime) {
+ fprintf(stderr, "Prime generation failed!\n");
+ exit(1);
+ }
+
+ BigIntegerFree(r);
+ BigIntegerFree(m);
+ BigIntegerFree(p);
+}
+
+_TYPE( struct t_confent * )
+t_makeconfent(tc, nsize)
+ struct t_conf * tc;
+ int nsize;
+{
+ BigInteger n, g, q, t, u;
+
+ t = BigIntegerFromInt(0);
+ u = BigIntegerFromInt(1); /* u = 1 */
+ BigIntegerLShift(t, u, nsize - 2); /* t = 2^(nsize-2) */
+ BigIntegerMulInt(u, t, 2); /* u = 2^(nsize-1) */
+
+ q = BigIntegerFromInt(0);
+ sophie_germain(q, t, u);
+
+ n = BigIntegerFromInt(0);
+ BigIntegerMulInt(n, q, 2);
+ BigIntegerAddInt(n, n, 1);
+
+ /* Look for a generator mod n */
+ g = BigIntegerFromInt(2);
+ while(1) {
+ BigIntegerModExp(t, g, q, n); /* t = g^q % n */
+ if(BigIntegerCmpInt(t, 1) == 0) /* if(t == 1) */
+ BigIntegerAddInt(g, g, 1); /* ++g */
+ else
+ break;
+ }
+ BigIntegerFree(t);
+ BigIntegerFree(u);
+ BigIntegerFree(q);
+
+ tc->tcbuf.modulus.data = tc->modbuf;
+ tc->tcbuf.modulus.len = BigIntegerToBytes(n, tc->tcbuf.modulus.data);
+ BigIntegerFree(n);
+
+ tc->tcbuf.generator.data = tc->genbuf;
+ tc->tcbuf.generator.len = BigIntegerToBytes(g, tc->tcbuf.generator.data);
+ BigIntegerFree(g);
+
+ tc->tcbuf.index = 1;
+ return &tc->tcbuf;
+}
+
+_TYPE( struct t_confent * )
+t_makeconfent_c(tc, nsize)
+ struct t_conf * tc;
+ int nsize;
+{
+ BigInteger g, n, p, q, j, k, t, u;
+ int psize, qsize;
+
+ psize = nsize / 2;
+ qsize = nsize - psize;
+
+ t = BigIntegerFromInt(1); /* t = 1 */
+ u = BigIntegerFromInt(0);
+ BigIntegerLShift(u, t, psize - 3); /* u = t*2^(psize-3) = 2^(psize-3) */
+ BigIntegerMulInt(t, u, 3); /* t = 3*u = 1.5*2^(psize-2) */
+ BigIntegerAdd(u, u, t); /* u += t [u = 2^(psize-1)] */
+ j = BigIntegerFromInt(0);
+ sophie_germain(j, t, u);
+
+ k = BigIntegerFromInt(0);
+ if(qsize != psize) {
+ BigIntegerFree(t);
+ t = BigIntegerFromInt(1); /* t = 1 */
+ BigIntegerLShift(u, t, qsize - 3); /* u = t*2^(qsize-3) = 2^(qsize-3) */
+ BigIntegerMulInt(t, u, 3); /* t = 3*u = 1.5*2^(qsize-2) */
+ BigIntegerAdd(u, u, t); /* u += t [u = 2^(qsize-1)] */
+ }
+ sophie_germain(k, t, u);
+
+ p = BigIntegerFromInt(0);
+ BigIntegerMulInt(p, j, 2); /* p = 2 * j */
+ BigIntegerAddInt(p, p, 1); /* p += 1 */
+
+ q = BigIntegerFromInt(0);
+ BigIntegerMulInt(q, k, 2); /* q = 2 * k */
+ BigIntegerAddInt(q, q, 1); /* q += 1 */
+
+ n = BigIntegerFromInt(0);
+ BigIntegerMul(n, p, q); /* n = p * q */
+ BigIntegerMul(u, j, k); /* u = j * k */
+
+ BigIntegerFree(p);
+ BigIntegerFree(q);
+ BigIntegerFree(j);
+ BigIntegerFree(k);
+
+ g = BigIntegerFromInt(2); /* g = 2 */
+
+ /* Look for a generator mod n */
+ while(1) {
+ BigIntegerModExp(t, g, u, n); /* t = g^u % n */
+ if(BigIntegerCmpInt(t, 1) == 0)
+ BigIntegerAddInt(g, g, 1); /* ++g */
+ else
+ break;
+ }
+
+ BigIntegerFree(u);
+ BigIntegerFree(t);
+
+ tc->tcbuf.modulus.data = tc->modbuf;
+ tc->tcbuf.modulus.len = BigIntegerToBytes(n, tc->tcbuf.modulus.data);
+ BigIntegerFree(n);
+
+ tc->tcbuf.generator.data = tc->genbuf;
+ tc->tcbuf.generator.len = BigIntegerToBytes(g, tc->tcbuf.generator.data);
+ BigIntegerFree(g);
+
+ tc->tcbuf.index = 1;
+ return &tc->tcbuf;
+}
+
+_TYPE( struct t_confent * )
+t_newconfent(tc)
+ struct t_conf * tc;
+{
+ tc->tcbuf.index = 0;
+ tc->tcbuf.modulus.data = tc->modbuf;
+ tc->tcbuf.modulus.len = 0;
+ tc->tcbuf.generator.data = tc->genbuf;
+ tc->tcbuf.generator.len = 0;
+ return &tc->tcbuf;
+}
+
+_TYPE( void )
+t_putconfent(ent, fp)
+ const struct t_confent * ent;
+ FILE * fp;
+{
+ char strbuf[MAXB64PARAMLEN];
+
+ fprintf(fp, "%d:%s:", ent->index,
+ t_tob64(strbuf, ent->modulus.data, ent->modulus.len));
+ fprintf(fp, "%s\n",
+ t_tob64(strbuf, ent->generator.data, ent->generator.len));
+}
+
+int
+BigIntegerBitLen(b)
+ BigInteger b;
+{
+ return BN_num_bits(b);
+}
+
+int
+BigIntegerCheckPrime(n)
+ BigInteger n;
+{
+ BN_CTX * ctx = BN_CTX_new();
+ int rv = BN_is_prime(n, 25, NULL, ctx, NULL);
+ BN_CTX_free(ctx);
+ return rv;
+}
+
+unsigned int
+BigIntegerModInt(d, m)
+ BigInteger d;
+ unsigned int m;
+{
+ return BN_mod_word(d, m);
+}
+
+void
+BigIntegerMod(result, d, m)
+ BigInteger result, d, m;
+{
+ BN_CTX * ctx = BN_CTX_new();
+ BN_mod(result, d, m, ctx);
+ BN_CTX_free(ctx);
+}
+
+void
+BigIntegerMul(result, m1, m2)
+ BigInteger result, m1, m2;
+{
+ BN_CTX * ctx = BN_CTX_new();
+ BN_mul(result, m1, m2, ctx);
+ BN_CTX_free(ctx);
+}
+
+void
+BigIntegerLShift(result, x, bits)
+ BigInteger result, x;
+ unsigned int bits;
+{
+ BN_lshift(result, x, bits);
+}
+
+int BN_is_prime(const BIGNUM *a, int checks, void (*callback)(int,int,void *),
+ BN_CTX *ctx_passed, void *cb_arg)
+ {
+ return BN_is_prime_fasttest(a, checks, callback, ctx_passed, cb_arg, 0);
+ }
+
+int BN_is_prime_fasttest(const BIGNUM *a, int checks,
+ void (*callback)(int,int,void *),
+ BN_CTX *ctx_passed, void *cb_arg,
+ int do_trial_division)
+ {
+ int i, j, ret = -1;
+ int k;
+ BN_CTX *ctx = NULL;
+ BIGNUM *A1, *A1_odd, *check; /* taken from ctx */
+ BN_MONT_CTX *mont = NULL;
+ const BIGNUM *A = NULL;
+
+ if (checks == BN_prime_checks)
+ checks = BN_prime_checks_for_size(BN_num_bits(a));
+
+ /* first look for small factors */
+ if (!BN_is_odd(a))
+ return(0);
+ if (do_trial_division)
+ {
+ for (i = 1; i < NUMPRIMES; i++)
+ if (BN_mod_word(a, primes[i]) == 0)
+ return 0;
+ if (callback != NULL) callback(1, -1, cb_arg);
+ }
+
+ if (ctx_passed != NULL)
+ ctx = ctx_passed;
+ else
+ if ((ctx=BN_CTX_new()) == NULL)
+ goto err;
+ BN_CTX_start(ctx);
+
+ /* A := abs(a) */
+ if (a->neg)
+ {
+ BIGNUM *t;
+ if ((t = BN_CTX_get(ctx)) == NULL) goto err;
+ BN_copy(t, a);
+ t->neg = 0;
+ A = t;
+ }
+ else
+ A = a;
+ A1 = BN_CTX_get(ctx);
+ A1_odd = BN_CTX_get(ctx);
+ check = BN_CTX_get(ctx);
+ if (check == NULL) goto err;
+
+ /* compute A1 := A - 1 */
+ if (!BN_copy(A1, A))
+ goto err;
+ if (!BN_sub_word(A1, 1))
+ goto err;
+ if (BN_is_zero(A1))
+ {
+ ret = 0;
+ goto err;
+ }
+
+ /* write A1 as A1_odd * 2^k */
+ k = 1;
+ while (!BN_is_bit_set(A1, k))
+ k++;
+ if (!BN_rshift(A1_odd, A1, k))
+ goto err;
+
+ /* Montgomery setup for computations mod A */
+ mont = BN_MONT_CTX_new();
+ if (mont == NULL)
+ goto err;
+ if (!BN_MONT_CTX_set(mont, A, ctx))
+ goto err;
+
+ for (i = 0; i < checks; i++)
+ {
+ if (!BN_pseudo_rand(check, BN_num_bits(A1), 0, 0))
+ goto err;
+ if (BN_cmp(check, A1) >= 0)
+ if (!BN_sub(check, check, A1))
+ goto err;
+ if (!BN_add_word(check, 1))
+ goto err;
+ /* now 1 <= check < A */
+
+ j = witness(check, A, A1, A1_odd, k, ctx, mont);
+ if (j == -1) goto err;
+ if (j)
+ {
+ ret=0;
+ goto err;
+ }
+ if (callback != NULL) callback(1,i,cb_arg);
+ }
+ ret=1;
+err:
+ if (ctx != NULL)
+ {
+ BN_CTX_end(ctx);
+ if (ctx_passed == NULL)
+ BN_CTX_free(ctx);
+ }
+ if (mont != NULL)
+ BN_MONT_CTX_free(mont);
+
+ return(ret);
+ }
+
+static int witness(BIGNUM *w, const BIGNUM *a, const BIGNUM *a1,
+ const BIGNUM *a1_odd, int k, BN_CTX *ctx, BN_MONT_CTX *mont)
+ {
+ if (!BN_mod_exp_mont(w, w, a1_odd, a, ctx, mont)) /* w := w^a1_odd mod a */
+ return -1;
+ if (BN_is_one(w))
+ return 0; /* probably prime */
+ if (BN_cmp(w, a1) == 0)
+ return 0; /* w == -1 (mod a), 'a' is probably prime */
+ while (--k)
+ {
+ if (!BN_mod_mul(w, w, w, a, ctx)) /* w := w^2 mod a */
+ return -1;
+ if (BN_is_one(w))
+ return 1; /* 'a' is composite, otherwise a previous 'w' would
+ * have been == -1 (mod 'a') */
+ if (BN_cmp(w, a1) == 0)
+ return 0; /* w == -1 (mod a), 'a' is probably prime */
+ }
+ /* If we get here, 'w' is the (a-1)/2-th power of the original 'w',
+ * and it is neither -1 nor +1 -- so 'a' cannot be prime */
+ return 1;
+ }
+
+int BN_mod_exp_mont(BIGNUM *rr, BIGNUM *a, const BIGNUM *p,
+ const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont)
+ {
+ int i,j,bits,ret=0,wstart,wend,window,wvalue;
+ int start=1,ts=0;
+ BIGNUM *d,*r;
+ BIGNUM *aa;
+ BIGNUM val[TABLE_SIZE];
+ BN_MONT_CTX *mont=NULL;
+
+ bn_check_top(a);
+ bn_check_top(p);
+ bn_check_top(m);
+
+ if (!(m->d[0] & 1))
+ {
+ return(0);
+ }
+ bits=BN_num_bits(p);
+ if (bits == 0)
+ {
+ BN_one(rr);
+ return(1);
+ }
+ BN_CTX_start(ctx);
+ d = BN_CTX_get(ctx);
+ r = BN_CTX_get(ctx);
+ if (d == NULL || r == NULL) goto err;
+
+ /* If this is not done, things will break in the montgomery
+ * part */
+
+ if (in_mont != NULL)
+ mont=in_mont;
+ else
+ {
+ if ((mont=BN_MONT_CTX_new()) == NULL) goto err;
+ if (!BN_MONT_CTX_set(mont,m,ctx)) goto err;
+ }
+
+ BN_init(&val[0]);
+ ts=1;
+ if (BN_ucmp(a,m) >= 0)
+ {
+ if (!BN_mod(&(val[0]),a,m,ctx))
+ goto err;
+ aa= &(val[0]);
+ }
+ else
+ aa=a;
+ if (!BN_to_montgomery(&(val[0]),aa,mont,ctx)) goto err; /* 1 */
+
+ window = BN_window_bits_for_exponent_size(bits);
+ if (window > 1)
+ {
+ if (!BN_mod_mul_montgomery(d,&(val[0]),&(val[0]),mont,ctx)) goto err; /* 2 */
+ j=1<<(window-1);
+ for (i=1; i<j; i++)
+ {
+ BN_init(&(val[i]));
+ if (!BN_mod_mul_montgomery(&(val[i]),&(val[i-1]),d,mont,ctx))
+ goto err;
+ }
+ ts=i;
+ }
+
+ start=1; /* This is used to avoid multiplication etc
+ * when there is only the value '1' in the
+ * buffer. */
+ wvalue=0; /* The 'value' of the window */
+ wstart=bits-1; /* The top bit of the window */
+ wend=0; /* The bottom bit of the window */
+
+ if (!BN_to_montgomery(r,BN_value_one(),mont,ctx)) goto err;
+ for (;;)
+ {
+ if (BN_is_bit_set(p,wstart) == 0)
+ {
+ if (!start)
+ {
+ if (!BN_mod_mul_montgomery(r,r,r,mont,ctx))
+ goto err;
+ }
+ if (wstart == 0) break;
+ wstart--;
+ continue;
+ }
+ /* We now have wstart on a 'set' bit, we now need to work out
+ * how bit a window to do. To do this we need to scan
+ * forward until the last set bit before the end of the
+ * window */
+ j=wstart;
+ wvalue=1;
+ wend=0;
+ for (i=1; i<window; i++)
+ {
+ if (wstart-i < 0) break;
+ if (BN_is_bit_set(p,wstart-i))
+ {
+ wvalue<<=(i-wend);
+ wvalue|=1;
+ wend=i;
+ }
+ }
+
+ /* wend is the size of the current window */
+ j=wend+1;
+ /* add the 'bytes above' */
+ if (!start)
+ for (i=0; i<j; i++)
+ {
+ if (!BN_mod_mul_montgomery(r,r,r,mont,ctx))
+ goto err;
+ }
+
+ /* wvalue will be an odd number < 2^window */
+ if (!BN_mod_mul_montgomery(r,r,&(val[wvalue>>1]),mont,ctx))
+ goto err;
+
+ /* move the 'window' down further */
+ wstart-=wend+1;
+ wvalue=0;
+ start=0;
+ if (wstart < 0) break;
+ }
+ if (!BN_from_montgomery(rr,r,mont,ctx)) goto err;
+ ret=1;
+err:
+ if ((in_mont == NULL) && (mont != NULL)) BN_MONT_CTX_free(mont);
+ BN_CTX_end(ctx);
+ for (i=0; i<ts; i++)
+ BN_clear_free(&(val[i]));
+ return(ret);
+ }
+
+BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w)
+ {
+#ifndef BN_LLONG
+ BN_ULONG ret=0;
+#else
+ BN_ULLONG ret=0;
+#endif
+ int i;
+
+ w&=BN_MASK2;
+ for (i=a->top-1; i>=0; i--)
+ {
+#ifndef BN_LLONG
+ ret=((ret<<BN_BITS4)|((a->d[i]>>BN_BITS4)&BN_MASK2l))%w;
+ ret=((ret<<BN_BITS4)|(a->d[i]&BN_MASK2l))%w;
+#else
+ ret=(BN_ULLONG)(((ret<<(BN_ULLONG)BN_BITS2)|a->d[i])%
+ (BN_ULLONG)w);
+#endif
+ }
+ return((BN_ULONG)ret);
+ }
+
+static int bnrand(int pseudorand, BIGNUM *rnd, int bits, int top, int bottom)
+ {
+ unsigned char *buf=NULL;
+ int ret=0,bit,bytes,mask;
+
+ if (bits == 0)
+ {
+ BN_zero(rnd);
+ return 1;
+ }
+
+ bytes=(bits+7)/8;
+ bit=(bits-1)%8;
+ mask=0xff<<bit;
+
+ buf=(unsigned char *)malloc(bytes);
+ if (buf == NULL)
+ {
+ goto err;
+ }
+
+ /* make a random number and set the top and bottom bits */
+ /* this ignores the pseudorand flag */
+
+ t_random(buf, bytes);
+
+ if (top)
+ {
+ if (bit == 0)
+ {
+ buf[0]=1;
+ buf[1]|=0x80;
+ }
+ else
+ {
+ buf[0]|=(3<<(bit-1));
+ buf[0]&= ~(mask<<1);
+ }
+ }
+ else
+ {
+ buf[0]|=(1<<bit);
+ buf[0]&= ~(mask<<1);
+ }
+ if (bottom) /* set bottom bits to whatever odd is */
+ buf[bytes-1]|=1;
+ if (!BN_bin2bn(buf,bytes,rnd)) goto err;
+ ret=1;
+err:
+ if (buf != NULL)
+ {
+ memset(buf,0,bytes);
+ free(buf);
+ }
+ return(ret);
+ }
+
+/* BN_pseudo_rand is the same as BN_rand, now. */
+
+int BN_pseudo_rand(BIGNUM *rnd, int bits, int top, int bottom)
+ {
+ return bnrand(1, rnd, bits, top, bottom);
+ }
+
+#define MONT_WORD /* use the faster word-based algorithm */
+
+int BN_mod_mul_montgomery(BIGNUM *r, BIGNUM *a, BIGNUM *b,
+ BN_MONT_CTX *mont, BN_CTX *ctx)
+ {
+ BIGNUM *tmp,*tmp2;
+ int ret=0;
+
+ BN_CTX_start(ctx);
+ tmp = BN_CTX_get(ctx);
+ tmp2 = BN_CTX_get(ctx);
+ if (tmp == NULL || tmp2 == NULL) goto err;
+
+ bn_check_top(tmp);
+ bn_check_top(tmp2);
+
+ if (a == b)
+ {
+ if (!BN_sqr(tmp,a,ctx)) goto err;
+ }
+ else
+ {
+ if (!BN_mul(tmp,a,b,ctx)) goto err;
+ }
+ /* reduce from aRR to aR */
+ if (!BN_from_montgomery(r,tmp,mont,ctx)) goto err;
+ ret=1;
+err:
+ BN_CTX_end(ctx);
+ return(ret);
+ }
+
+int BN_from_montgomery(BIGNUM *ret, BIGNUM *a, BN_MONT_CTX *mont,
+ BN_CTX *ctx)
+ {
+ int retn=0;
+
+#ifdef MONT_WORD
+ BIGNUM *n,*r;
+ BN_ULONG *ap,*np,*rp,n0,v,*nrp;
+ int al,nl,max,i,x,ri;
+
+ BN_CTX_start(ctx);
+ if ((r = BN_CTX_get(ctx)) == NULL) goto err;
+
+ if (!BN_copy(r,a)) goto err;
+ n= &(mont->N);
+
+ ap=a->d;
+ /* mont->ri is the size of mont->N in bits (rounded up
+ to the word size) */
+ al=ri=mont->ri/BN_BITS2;
+
+ nl=n->top;
+ if ((al == 0) || (nl == 0)) { r->top=0; return(1); }
+
+ max=(nl+al+1); /* allow for overflow (no?) XXX */
+ if (bn_wexpand(r,max) == NULL) goto err;
+ if (bn_wexpand(ret,max) == NULL) goto err;
+
+ r->neg=a->neg^n->neg;
+ np=n->d;
+ rp=r->d;
+ nrp= &(r->d[nl]);
+
+ /* clear the top words of T */
+#if 1
+ for (i=r->top; i<max; i++) /* memset? XXX */
+ r->d[i]=0;
+#else
+ memset(&(r->d[r->top]),0,(max-r->top)*sizeof(BN_ULONG));
+#endif
+
+ r->top=max;
+ n0=mont->n0;
+
+#ifdef BN_COUNT
+ printf("word BN_from_montgomery %d * %d\n",nl,nl);
+#endif
+ for (i=0; i<nl; i++)
+ {
+#ifdef __TANDEM
+ {
+ long long t1;
+ long long t2;
+ long long t3;
+ t1 = rp[0] * (n0 & 0177777);
+ t2 = 037777600000l;
+ t2 = n0 & t2;
+ t3 = rp[0] & 0177777;
+ t2 = (t3 * t2) & BN_MASK2;
+ t1 = t1 + t2;
+ v=bn_mul_add_words(rp,np,nl,(BN_ULONG) t1);
+ }
+#else
+ v=bn_mul_add_words(rp,np,nl,(rp[0]*n0)&BN_MASK2);
+#endif
+ nrp++;
+ rp++;
+ if (((nrp[-1]+=v)&BN_MASK2) >= v)
+ continue;
+ else
+ {
+ if (((++nrp[0])&BN_MASK2) != 0) continue;
+ if (((++nrp[1])&BN_MASK2) != 0) continue;
+ for (x=2; (((++nrp[x])&BN_MASK2) == 0); x++) ;
+ }
+ }
+ bn_fix_top(r);
+
+ /* mont->ri will be a multiple of the word size */
+#if 0
+ BN_rshift(ret,r,mont->ri);
+#else
+ ret->neg = r->neg;
+ x=ri;
+ rp=ret->d;
+ ap= &(r->d[x]);
+ if (r->top < x)
+ al=0;
+ else
+ al=r->top-x;
+ ret->top=al;
+ al-=4;
+ for (i=0; i<al; i+=4)
+ {
+ BN_ULONG t1,t2,t3,t4;
+
+ t1=ap[i+0];
+ t2=ap[i+1];
+ t3=ap[i+2];
+ t4=ap[i+3];
+ rp[i+0]=t1;
+ rp[i+1]=t2;
+ rp[i+2]=t3;
+ rp[i+3]=t4;
+ }
+ al+=4;
+ for (; i<al; i++)
+ rp[i]=ap[i];
+#endif
+#else /* !MONT_WORD */
+ BIGNUM *t1,*t2;
+
+ BN_CTX_start(ctx);
+ t1 = BN_CTX_get(ctx);
+ t2 = BN_CTX_get(ctx);
+ if (t1 == NULL || t2 == NULL) goto err;
+
+ if (!BN_copy(t1,a)) goto err;
+ BN_mask_bits(t1,mont->ri);
+
+ if (!BN_mul(t2,t1,&mont->Ni,ctx)) goto err;
+ BN_mask_bits(t2,mont->ri);
+
+ if (!BN_mul(t1,t2,&mont->N,ctx)) goto err;
+ if (!BN_add(t2,a,t1)) goto err;
+ BN_rshift(ret,t2,mont->ri);
+#endif /* MONT_WORD */
+
+ if (BN_ucmp(ret, &(mont->N)) >= 0)
+ {
+ BN_usub(ret,ret,&(mont->N));
+ }
+ retn=1;
+ err:
+ BN_CTX_end(ctx);
+ return(retn);
+ }
+
+void BN_MONT_CTX_init(BN_MONT_CTX *ctx)
+ {
+ ctx->ri=0;
+ BN_init(&(ctx->RR));
+ BN_init(&(ctx->N));
+ BN_init(&(ctx->Ni));
+ ctx->flags=0;
+ }
+
+BN_MONT_CTX *BN_MONT_CTX_new(void)
+ {
+ BN_MONT_CTX *ret;
+
+ if ((ret=(BN_MONT_CTX *)malloc(sizeof(BN_MONT_CTX))) == NULL)
+ return(NULL);
+
+ BN_MONT_CTX_init(ret);
+ ret->flags=BN_FLG_MALLOCED;
+ return(ret);
+ }
+
+void BN_MONT_CTX_free(BN_MONT_CTX *mont)
+ {
+ if(mont == NULL)
+ return;
+
+ BN_free(&(mont->RR));
+ BN_free(&(mont->N));
+ BN_free(&(mont->Ni));
+ if (mont->flags & BN_FLG_MALLOCED)
+ free(mont);
+ }
+
+int BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx)
+ {
+ BIGNUM Ri,*R;
+
+ BN_init(&Ri);
+ R= &(mont->RR); /* grab RR as a temp */
+ BN_copy(&(mont->N),mod); /* Set N */
+
+#ifdef MONT_WORD
+ {
+ BIGNUM tmod;
+ BN_ULONG buf[2];
+
+ mont->ri=(BN_num_bits(mod)+(BN_BITS2-1))/BN_BITS2*BN_BITS2;
+ BN_zero(R);
+ BN_set_bit(R,BN_BITS2); /* R */
+
+ buf[0]=mod->d[0]; /* tmod = N mod word size */
+ buf[1]=0;
+ tmod.d=buf;
+ tmod.top=1;
+ tmod.dmax=2;
+ tmod.neg=mod->neg;
+ /* Ri = R^-1 mod N*/
+ if ((BN_mod_inverse(&Ri,R,&tmod,ctx)) == NULL)
+ goto err;
+ BN_lshift(&Ri,&Ri,BN_BITS2); /* R*Ri */
+ if (!BN_is_zero(&Ri))
+ BN_sub_word(&Ri,1);
+ else /* if N mod word size == 1 */
+ BN_set_word(&Ri,BN_MASK2); /* Ri-- (mod word size) */
+ BN_div(&Ri,NULL,&Ri,&tmod,ctx); /* Ni = (R*Ri-1)/N,
+ * keep only least significant word: */
+ mont->n0=Ri.d[0];
+ BN_free(&Ri);
+ }
+#else /* !MONT_WORD */
+ { /* bignum version */
+ mont->ri=BN_num_bits(mod);
+ BN_zero(R);
+ BN_set_bit(R,mont->ri); /* R = 2^ri */
+ /* Ri = R^-1 mod N*/
+ if ((BN_mod_inverse(&Ri,R,mod,ctx)) == NULL)
+ goto err;
+ BN_lshift(&Ri,&Ri,mont->ri); /* R*Ri */
+ BN_sub_word(&Ri,1);
+ /* Ni = (R*Ri-1) / N */
+ BN_div(&(mont->Ni),NULL,&Ri,mod,ctx);
+ BN_free(&Ri);
+ }
+#endif
+
+ /* setup RR for conversions */
+ BN_zero(&(mont->RR));
+ BN_set_bit(&(mont->RR),mont->ri*2);
+ BN_mod(&(mont->RR),&(mont->RR),&(mont->N),ctx);
+
+ return(1);
+err:
+ return(0);
+ }
+
+BIGNUM *BN_value_one(void)
+ {
+ static BN_ULONG data_one=1L;
+ static BIGNUM const_one={&data_one,1,1,0};
+
+ return(&const_one);
+ }
+
+/* solves ax == 1 (mod n) */
+BIGNUM *BN_mod_inverse(BIGNUM *in, BIGNUM *a, const BIGNUM *n, BN_CTX *ctx)
+ {
+ BIGNUM *A,*B,*X,*Y,*M,*D,*R=NULL;
+ BIGNUM *T,*ret=NULL;
+ int sign;
+
+ bn_check_top(a);
+ bn_check_top(n);
+
+ BN_CTX_start(ctx);
+ A = BN_CTX_get(ctx);
+ B = BN_CTX_get(ctx);
+ X = BN_CTX_get(ctx);
+ D = BN_CTX_get(ctx);
+ M = BN_CTX_get(ctx);
+ Y = BN_CTX_get(ctx);
+ if (Y == NULL) goto err;
+
+ if (in == NULL)
+ R=BN_new();
+ else
+ R=in;
+ if (R == NULL) goto err;
+
+ BN_zero(X);
+ BN_one(Y);
+ if (BN_copy(A,a) == NULL) goto err;
+ if (BN_copy(B,n) == NULL) goto err;
+ sign=1;
+
+ while (!BN_is_zero(B))
+ {
+ if (!BN_div(D,M,A,B,ctx)) goto err;
+ T=A;
+ A=B;
+ B=M;
+ /* T has a struct, M does not */
+
+ if (!BN_mul(T,D,X,ctx)) goto err;
+ if (!BN_add(T,T,Y)) goto err;
+ M=Y;
+ Y=X;
+ X=T;
+ sign= -sign;
+ }
+ if (sign < 0)
+ {
+ if (!BN_sub(Y,n,Y)) goto err;
+ }
+
+ if (BN_is_one(A))
+ { if (!BN_mod(R,Y,n,ctx)) goto err; }
+ else
+ {
+ goto err;
+ }
+ ret=R;
+err:
+ if ((ret == NULL) && (in == NULL)) BN_free(R);
+ BN_CTX_end(ctx);
+ return(ret);
+ }
+
+int BN_set_bit(BIGNUM *a, int n)
+ {
+ int i,j,k;
+
+ i=n/BN_BITS2;
+ j=n%BN_BITS2;
+ if (a->top <= i)
+ {
+ if (bn_wexpand(a,i+1) == NULL) return(0);
+ for(k=a->top; k<i+1; k++)
+ a->d[k]=0;
+ a->top=i+1;
+ }
+
+ a->d[i]|=(((BN_ULONG)1)<<j);
+ return(1);
+ }
+
diff --git a/package/network/services/ead/src/tinysrp/.svn/text-base/t_conv.c.svn-base b/package/network/services/ead/src/tinysrp/.svn/text-base/t_conv.c.svn-base
new file mode 100644
index 0000000..d3fe246
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/.svn/text-base/t_conv.c.svn-base
@@ -0,0 +1,226 @@
+/*
+ * Copyright (c) 1997-1999 The Stanford SRP Authentication Project
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF
+ * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * In addition, the following conditions apply:
+ *
+ * 1. Any software that incorporates the SRP authentication technology
+ * must display the following acknowlegment:
+ * "This product uses the 'Secure Remote Password' cryptographic
+ * authentication system developed by Tom Wu (tjw@CS.Stanford.EDU)."
+ *
+ * 2. Any software that incorporates all or part of the SRP distribution
+ * itself must also display the following acknowledgment:
+ * "This product includes software developed by Tom Wu and Eugene
+ * Jhong for the SRP Distribution (http://srp.stanford.edu/srp/)."
+ *
+ * 3. Redistributions in source or binary form must retain an intact copy
+ * of this copyright notice and list of conditions.
+ */
+
+/*#define _POSIX_SOURCE*/
+#include <stdio.h>
+#include "t_defines.h"
+
+static int
+hexDigitToInt(c)
+ char c;
+{
+ if(c >= '0' && c <= '9')
+ return c - '0';
+ else if(c >= 'a' && c <= 'f')
+ return c - 'a' + 10;
+ else if(c >= 'A' && c <= 'F')
+ return c - 'A' + 10;
+ else
+ return 0;
+}
+
+/*
+ * Convert a hex string to a string of bytes; return size of dst
+ */
+_TYPE( int )
+t_fromhex(dst, src)
+ register char *dst, *src;
+{
+ register char *chp = dst;
+ register unsigned size = strlen(src);
+
+ /* FIXME: handle whitespace and non-hex digits by setting size and src
+ appropriately. */
+
+ if(size % 2 == 1) {
+ *chp++ = hexDigitToInt(*src++);
+ --size;
+ }
+ while(size > 0) {
+ *chp++ = (hexDigitToInt(*src) << 4) | hexDigitToInt(*(src + 1));
+ src += 2;
+ size -= 2;
+ }
+ return chp - dst;
+}
+
+/*
+ * Convert a string of bytes to their hex representation
+ */
+_TYPE( char * )
+t_tohex(dst, src, size)
+ register char *dst, *src;
+ register unsigned size;
+{
+ int notleading = 0;
+
+ register char *chp = dst;
+ if (size != 0) do {
+ if(notleading || *src != '\0') {
+ notleading = 1;
+ sprintf(chp, "%.2x", * (unsigned char *) src);
+ chp += 2;
+ }
+ ++src;
+ } while (--size != 0);
+ return dst;
+}
+
+static char b64table[] =
+ "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz./";
+
+/*
+ * Convert a base64 string into raw byte array representation.
+ */
+_TYPE( int )
+t_fromb64(dst, src)
+ register char *dst, *src;
+{
+ unsigned char *a;
+ char *loc;
+ int i, j;
+ unsigned int size;
+
+ while(*src && (*src == ' ' || *src == '\t' || *src == '\n'))
+ ++src;
+ size = strlen(src);
+
+ a = malloc((size + 1) * sizeof(unsigned char));
+ if(a == (unsigned char *) 0)
+ return -1;
+
+ i = 0;
+ while(i < size) {
+ loc = strchr(b64table, src[i]);
+ if(loc == (char *) 0)
+ break;
+ else
+ a[i] = loc - b64table;
+ ++i;
+ }
+ size = i;
+
+ i = size - 1;
+ j = size;
+ while(1) {
+ a[j] = a[i];
+ if(--i < 0)
+ break;
+ a[j] |= (a[i] & 3) << 6;
+ --j;
+ a[j] = (unsigned char) ((a[i] & 0x3c) >> 2);
+ if(--i < 0)
+ break;
+ a[j] |= (a[i] & 0xf) << 4;
+ --j;
+ a[j] = (unsigned char) ((a[i] & 0x30) >> 4);
+ if(--i < 0)
+ break;
+ a[j] |= (a[i] << 2);
+
+ a[--j] = 0;
+ if(--i < 0)
+ break;
+ }
+
+ while(a[j] == 0 && j <= size)
+ ++j;
+
+ memcpy(dst, a + j, size - j + 1);
+ free(a);
+ return size - j + 1;
+}
+
+/*
+ * Convert a raw byte string into a null-terminated base64 ASCII string.
+ */
+_TYPE( char * )
+t_tob64(dst, src, size)
+ register char *dst, *src;
+ register unsigned size;
+{
+ int c, pos = size % 3;
+ unsigned char b0 = 0, b1 = 0, b2 = 0, notleading = 0;
+ char *olddst = dst;
+
+ switch(pos) {
+ case 1:
+ b2 = src[0];
+ break;
+ case 2:
+ b1 = src[0];
+ b2 = src[1];
+ break;
+ }
+
+ while(1) {
+ c = (b0 & 0xfc) >> 2;
+ if(notleading || c != 0) {
+ *dst++ = b64table[c];
+ notleading = 1;
+ }
+ c = ((b0 & 3) << 4) | ((b1 & 0xf0) >> 4);
+ if(notleading || c != 0) {
+ *dst++ = b64table[c];
+ notleading = 1;
+ }
+ c = ((b1 & 0xf) << 2) | ((b2 & 0xc0) >> 6);
+ if(notleading || c != 0) {
+ *dst++ = b64table[c];
+ notleading = 1;
+ }
+ c = b2 & 0x3f;
+ if(notleading || c != 0) {
+ *dst++ = b64table[c];
+ notleading = 1;
+ }
+ if(pos >= size)
+ break;
+ else {
+ b0 = src[pos++];
+ b1 = src[pos++];
+ b2 = src[pos++];
+ }
+ }
+
+ *dst++ = '\0';
+ return olddst;
+}
diff --git a/package/network/services/ead/src/tinysrp/.svn/text-base/t_defines.h.svn-base b/package/network/services/ead/src/tinysrp/.svn/text-base/t_defines.h.svn-base
new file mode 100644
index 0000000..4128093
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/.svn/text-base/t_defines.h.svn-base
@@ -0,0 +1,169 @@
+/*
+ * Copyright (c) 1997-1999 The Stanford SRP Authentication Project
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF
+ * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * In addition, the following conditions apply:
+ *
+ * 1. Any software that incorporates the SRP authentication technology
+ * must display the following acknowlegment:
+ * "This product uses the 'Secure Remote Password' cryptographic
+ * authentication system developed by Tom Wu (tjw@CS.Stanford.EDU)."
+ *
+ * 2. Any software that incorporates all or part of the SRP distribution
+ * itself must also display the following acknowledgment:
+ * "This product includes software developed by Tom Wu and Eugene
+ * Jhong for the SRP Distribution (http://srp.stanford.edu/srp/)."
+ *
+ * 3. Redistributions in source or binary form must retain an intact copy
+ * of this copyright notice and list of conditions.
+ */
+
+#ifndef T_DEFINES_H
+#define T_DEFINES_H
+
+#ifndef P
+#if defined(__STDC__) || defined(__cplusplus)
+#define P(x) x
+#else
+#define P(x) ()
+#endif
+#endif
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#ifndef _DLLDECL
+#define _DLLDECL
+
+#ifdef MSVC15 /* MSVC1.5 support for 16 bit apps */
+#define _MSVC15EXPORT _export
+#define _MSVC20EXPORT
+#define _DLLAPI _export _pascal
+#define _TYPE(a) a _MSVC15EXPORT
+#define DLLEXPORT 1
+
+#elif MSVC20
+#define _MSVC15EXPORT
+#define _MSVC20EXPORT _declspec(dllexport)
+#define _DLLAPI
+#define _TYPE(a) _MSVC20EXPORT a
+#define DLLEXPORT 1
+
+#else /* Default, non-dll. Use this for Unix or DOS */
+#define _MSVC15DEXPORT
+#define _MSVC20EXPORT
+#define _DLLAPI
+#define _TYPE(a) a
+#endif
+#endif
+
+#if STDC_HEADERS
+#include <stdlib.h>
+#include <string.h>
+#else /* not STDC_HEADERS */
+#ifndef HAVE_STRCHR
+#define strchr index
+#define strrchr rindex
+#endif
+char *strchr(), *strrchr(), *strtok();
+#ifndef HAVE_MEMCPY
+#define memcpy(d, s, n) bcopy((s), (d), (n))
+#endif
+#endif /* not STDC_HEADERS */
+
+#include <sys/types.h>
+
+#if TIME_WITH_SYS_TIME
+#include <sys/time.h>
+#include <time.h>
+#else /* not TIME_WITH_SYS_TIME */
+#if HAVE_SYS_TIME_H
+#include <sys/time.h>
+#else
+#include <time.h>
+#endif
+#endif /* not TIME_WITH_SYS_TIME */
+
+#if HAVE_TERMIOS_H
+#include <termios.h>
+#define STTY(fd, termio) tcsetattr(fd, TCSANOW, termio)
+#define GTTY(fd, termio) tcgetattr(fd, termio)
+#define TERMIO struct termios
+#define USE_TERMIOS
+#elif HAVE_TERMIO_H
+#include <sys/ioctl.h>
+#include <termio.h>
+#define STTY(fd, termio) ioctl(fd, TCSETA, termio)
+#define GTTY(fd, termio) ioctl(fd, TCGETA, termio)
+#define TEMRIO struct termio
+#define USE_TERMIO
+#elif HAVE_SGTTY_H
+#include <sgtty.h>
+#define STTY(fd, termio) stty(fd, termio)
+#define GTTY(fd, termio) gtty(fd, termio)
+#define TERMIO struct sgttyb
+#define USE_SGTTY
+#endif
+
+#ifdef USE_FTIME
+#include <sys/timeb.h>
+#endif
+
+#ifndef MATH_PRIV
+typedef void * BigInteger;
+#endif
+
+_TYPE( BigInteger ) BigIntegerFromInt P((unsigned int number));
+_TYPE( BigInteger ) BigIntegerFromBytes P((unsigned char * bytes, int length));
+_TYPE( int ) BigIntegerToBytes P((BigInteger src, unsigned char * dest));
+_TYPE( int ) BigIntegerBitLen P((BigInteger b));
+_TYPE( int ) BigIntegerCmp P((BigInteger c1, BigInteger c2));
+_TYPE( int ) BigIntegerCmpInt P((BigInteger c1, unsigned int c2));
+_TYPE( void ) BigIntegerLShift P((BigInteger result, BigInteger x,
+ unsigned int bits));
+_TYPE( void ) BigIntegerAdd P((BigInteger result, BigInteger a1, BigInteger a2));
+_TYPE( void ) BigIntegerAddInt P((BigInteger result,
+ BigInteger a1, unsigned int a2));
+_TYPE( void ) BigIntegerSub P((BigInteger result, BigInteger s1, BigInteger s2));
+_TYPE( void ) BigIntegerSubInt P((BigInteger result,
+ BigInteger s1, unsigned int s2));
+/* For BigIntegerMul{,Int}: result != m1, m2 */
+_TYPE( void ) BigIntegerMul P((BigInteger result, BigInteger m1, BigInteger m2));
+_TYPE( void ) BigIntegerMulInt P((BigInteger result,
+ BigInteger m1, unsigned int m2));
+_TYPE( void ) BigIntegerDivInt P((BigInteger result,
+ BigInteger d, unsigned int m));
+_TYPE( void ) BigIntegerMod P((BigInteger result, BigInteger d, BigInteger m));
+_TYPE( unsigned int ) BigIntegerModInt P((BigInteger d, unsigned int m));
+_TYPE( void ) BigIntegerModMul P((BigInteger result,
+ BigInteger m1, BigInteger m2, BigInteger m));
+_TYPE( void ) BigIntegerModExp P((BigInteger result, BigInteger base,
+ BigInteger expt, BigInteger modulus));
+_TYPE( void ) BigIntegerModExpInt P((BigInteger result, BigInteger base,
+ unsigned int expt, BigInteger modulus));
+_TYPE( int ) BigIntegerCheckPrime P((BigInteger n));
+_TYPE( void ) BigIntegerFree P((BigInteger b));
+
+#endif
diff --git a/package/network/services/ead/src/tinysrp/.svn/text-base/t_getconf.c.svn-base b/package/network/services/ead/src/tinysrp/.svn/text-base/t_getconf.c.svn-base
new file mode 100644
index 0000000..db6de61
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/.svn/text-base/t_getconf.c.svn-base
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 1997-1999 The Stanford SRP Authentication Project
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF
+ * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * In addition, the following conditions apply:
+ *
+ * 1. Any software that incorporates the SRP authentication technology
+ * must display the following acknowlegment:
+ * "This product uses the 'Secure Remote Password' cryptographic
+ * authentication system developed by Tom Wu (tjw@CS.Stanford.EDU)."
+ *
+ * 2. Any software that incorporates all or part of the SRP distribution
+ * itself must also display the following acknowledgment:
+ * "This product includes software developed by Tom Wu and Eugene
+ * Jhong for the SRP Distribution (http://srp.stanford.edu/srp/)."
+ *
+ * 3. Redistributions in source or binary form must retain an intact copy
+ * of this copyright notice and list of conditions.
+ */
+
+#include <stdio.h>
+
+#include "t_defines.h"
+#include "t_pwd.h"
+#include "t_read.h"
+
+/* Master builtin parameter storage object. The default that tphrase
+uses is the last one. */
+
+static struct pre_struct {
+ struct t_preconf preconf;
+ int state; /* 0 == uninitialized/first time */
+ unsigned char modbuf[MAXPARAMLEN];
+ unsigned char genbuf[MAXPARAMLEN];
+} pre_params[] = {
+ { { "2iQzj1CagQc/5ctbuJYLWlhtAsPHc7xWVyCPAKFRLWKADpASkqe9djWPFWTNTdeJtL8nAhImCn3Sr/IAdQ1FrGw0WvQUstPx3FO9KNcXOwisOQ1VlL.gheAHYfbYyBaxXL.NcJx9TUwgWDT0hRzFzqSrdGGTN3FgSTA1v4QnHtEygNj3eZ.u0MThqWUaDiP87nqha7XnT66bkTCkQ8.7T8L4KZjIImrNrUftedTTBi.WCi.zlrBxDuOM0da0JbUkQlXqvp0yvJAPpC11nxmmZOAbQOywZGmu9nhZNuwTlxjfIro0FOdthaDTuZRL9VL7MRPUDo/DQEyW.d4H.UIlzp",
+ "2",
+ NULL }, 0 },
+ { { "dUyyhxav9tgnyIg65wHxkzkb7VIPh4o0lkwfOKiPp4rVJrzLRYVBtb76gKlaO7ef5LYGEw3G.4E0jbMxcYBetDy2YdpiP/3GWJInoBbvYHIRO9uBuxgsFKTKWu7RnR7yTau/IrFTdQ4LY/q.AvoCzMxV0PKvD9Odso/LFIItn8PbTov3VMn/ZEH2SqhtpBUkWtmcIkEflhX/YY/fkBKfBbe27/zUaKUUZEUYZ2H2nlCL60.JIPeZJSzsu/xHDVcx",
+ "2",
+ NULL }, 0 },
+ { { "3NUKQ2Re4P5BEK0TLg2dX3gETNNNECPoe92h4OVMaDn3Xo/0QdjgG/EvM.hiVV1BdIGklSI14HA38Mpe5k04juR5/EXMU0r1WtsLhNXwKBlf2zEfoOh0zVmDvqInpU695f29Iy7sNW3U5RIogcs740oUp2Kdv5wuITwnIx84cnO.e467/IV1lPnvMCr0pd1dgS0a.RV5eBJr03Q65Xy61R",
+ "2",
+ NULL }, 0 },
+ { { "F//////////oG/QeY5emZJ4ncABWDmSqIa2JWYAPynq0Wk.fZiJco9HIWXvZZG4tU.L6RFDEaCRC2iARV9V53TFuJLjRL72HUI5jNPYNdx6z4n2wQOtxMiB/rosz0QtxUuuQ/jQYP.bhfya4NnB7.P9A6PHxEPJWV//////////",
+ "5",
+ "oakley prime 2" }, 0 },
+ { { "Ewl2hcjiutMd3Fu2lgFnUXWSc67TVyy2vwYCKoS9MLsrdJVT9RgWTCuEqWJrfB6uE3LsE9GkOlaZabS7M29sj5TnzUqOLJMjiwEzArfiLr9WbMRANlF68N5AVLcPWvNx6Zjl3m5Scp0BzJBz9TkgfhzKJZ.WtP3Mv/67I/0wmRZ",
+ "2",
+ NULL }, 0 },
+};
+
+_TYPE( int )
+t_getprecount()
+{
+ return (sizeof(pre_params) / sizeof(struct pre_struct));
+}
+
+static struct t_confent sysconf;
+
+/* id is index origin 1 */
+
+_TYPE( struct t_confent * )
+gettcid
+(id)
+ int id;
+{
+ struct t_preconf *tcp;
+
+ if (id <= 0 || id > t_getprecount()) {
+ return NULL;
+ }
+ tcp = t_getpreparam(id - 1);
+ sysconf.index = id;
+ sysconf.modulus = tcp->modulus;
+ sysconf.generator = tcp->generator;
+
+ return &sysconf;
+}
+
+_TYPE( struct t_preconf * )
+t_getpreparam(idx)
+ int idx;
+{
+ if(pre_params[idx].state == 0) {
+ /* Wire up storage */
+ pre_params[idx].preconf.modulus.data = pre_params[idx].modbuf;
+ pre_params[idx].preconf.generator.data = pre_params[idx].genbuf;
+
+ /* Convert from b64 to t_num */
+ pre_params[idx].preconf.modulus.len = t_fromb64(pre_params[idx].preconf.modulus.data, pre_params[idx].preconf.mod_b64);
+ pre_params[idx].preconf.generator.len = t_fromb64(pre_params[idx].preconf.generator.data, pre_params[idx].preconf.gen_b64);
+
+ pre_params[idx].state = 1;
+ }
+ return &(pre_params[idx].preconf);
+}
diff --git a/package/network/services/ead/src/tinysrp/.svn/text-base/t_getpass.c.svn-base b/package/network/services/ead/src/tinysrp/.svn/text-base/t_getpass.c.svn-base
new file mode 100644
index 0000000..6ae7fca
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/.svn/text-base/t_getpass.c.svn-base
@@ -0,0 +1,191 @@
+/*
+ * Copyright 1990 - 1995, Julianne Frances Haugh
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Julianne F. Haugh nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JULIE HAUGH AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL JULIE HAUGH OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "t_defines.h"
+#ifdef _WIN32
+#include <windows.h>
+#include <io.h>
+#endif /* _WIN32 */
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif /* HAVE_UNISTD_H */
+#include <signal.h>
+#include <stdio.h>
+
+static int sig_caught;
+#ifdef HAVE_SIGACTION
+static struct sigaction sigact;
+#endif
+
+/*ARGSUSED*/
+static RETSIGTYPE
+sig_catch (sig)
+int sig;
+{
+ sig_caught = 1;
+}
+
+_TYPE( int )
+t_getpass (buf, maxlen, prompt)
+ char *buf;
+ unsigned maxlen;
+ const char *prompt;
+{
+ char *cp;
+#ifdef _WIN32
+ HANDLE handle = (HANDLE) _get_osfhandle(_fileno(stdin));
+ DWORD mode;
+
+ GetConsoleMode( handle, &mode );
+ SetConsoleMode( handle, mode & ~ENABLE_ECHO_INPUT );
+
+ if(fputs(prompt, stdout) == EOF ||
+ fgets(buf, maxlen, stdin) == NULL) {
+ SetConsoleMode(handle,mode);
+ return -1;
+ }
+ cp = buf + strlen(buf) - 1;
+ if ( *cp == 0x0a )
+ *cp = '\0';
+ printf("\n");
+ SetConsoleMode(handle,mode);
+#else
+ FILE *fp;
+ int tty_opened = 0;
+
+#ifdef HAVE_SIGACTION
+ struct sigaction old_sigact;
+#else
+ RETSIGTYPE (*old_signal)();
+#endif
+ TERMIO new_modes;
+ TERMIO old_modes;
+
+ /*
+ * set a flag so the SIGINT signal can be re-sent if it
+ * is caught
+ */
+
+ sig_caught = 0;
+
+ /*
+ * if /dev/tty can't be opened, getpass() needs to read
+ * from stdin instead.
+ */
+
+ if ((fp = fopen ("/dev/tty", "r")) == 0) {
+ fp = stdin;
+ setbuf (fp, (char *) 0);
+ } else {
+ tty_opened = 1;
+ }
+
+ /*
+ * the current tty modes must be saved so they can be
+ * restored later on. echo will be turned off, except
+ * for the newline character (BSD has to punt on this)
+ */
+
+ if (GTTY (fileno (fp), &new_modes))
+ return -1;
+
+ old_modes = new_modes;
+
+#ifdef HAVE_SIGACTION
+ sigact.sa_handler = sig_catch;
+ (void) sigaction (SIGINT, &sigact, &old_sigact);
+#else
+ old_signal = signal (SIGINT, sig_catch);
+#endif
+
+#ifdef USE_SGTTY
+ new_modes.sg_flags &= ~ECHO;
+#else
+ new_modes.c_iflag &= ~IGNCR;
+ new_modes.c_iflag |= ICRNL;
+ new_modes.c_oflag |= OPOST|ONLCR;
+ new_modes.c_lflag &= ~(ECHO|ECHOE|ECHOK);
+ new_modes.c_lflag |= ICANON|ECHONL;
+#endif
+
+ if (STTY (fileno (fp), &new_modes))
+ goto out;
+
+ /*
+ * the prompt is output, and the response read without
+ * echoing. the trailing newline must be removed. if
+ * the fgets() returns an error, a NULL pointer is
+ * returned.
+ */
+
+ if (fputs (prompt, stdout) == EOF)
+ goto out;
+
+ (void) fflush (stdout);
+
+ if (fgets (buf, maxlen, fp) == buf) {
+ if ((cp = strchr (buf, '\n')))
+ *cp = '\0';
+ else
+ buf[maxlen - 1] = '\0';
+
+#ifdef USE_SGTTY
+ putc ('\n', stdout);
+#endif
+ }
+ else buf[0] = '\0';
+out:
+ /*
+ * the old SIGINT handler is restored after the tty
+ * modes. then /dev/tty is closed if it was opened in
+ * the beginning. finally, if a signal was caught it
+ * is sent to this process for normal processing.
+ */
+
+ if (STTY (fileno (fp), &old_modes))
+ { memset (buf, 0, maxlen); return -1; }
+
+#ifdef HAVE_SIGACTION
+ (void) sigaction (SIGINT, &old_sigact, NULL);
+#else
+ (void) signal (SIGINT, old_signal);
+#endif
+
+ if (tty_opened)
+ (void) fclose (fp);
+
+ if (sig_caught) {
+ kill (getpid (), SIGINT);
+ memset (buf, 0, maxlen);
+ return -1;
+ }
+#endif
+
+ return 0;
+}
diff --git a/package/network/services/ead/src/tinysrp/.svn/text-base/t_math.c.svn-base b/package/network/services/ead/src/tinysrp/.svn/text-base/t_math.c.svn-base
new file mode 100644
index 0000000..20161a0
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/.svn/text-base/t_math.c.svn-base
@@ -0,0 +1,177 @@
+/*
+ * Copyright (c) 1997-1999 The Stanford SRP Authentication Project
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF
+ * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * In addition, the following conditions apply:
+ *
+ * 1. Any software that incorporates the SRP authentication technology
+ * must display the following acknowlegment:
+ * "This product uses the 'Secure Remote Password' cryptographic
+ * authentication system developed by Tom Wu (tjw@CS.Stanford.EDU)."
+ *
+ * 2. Any software that incorporates all or part of the SRP distribution
+ * itself must also display the following acknowledgment:
+ * "This product includes software developed by Tom Wu and Eugene
+ * Jhong for the SRP Distribution (http://srp.stanford.edu/srp/)."
+ *
+ * 3. Redistributions in source or binary form must retain an intact copy
+ * of this copyright notice and list of conditions.
+ */
+
+#include <stdio.h>
+#include <sys/types.h>
+
+#include "config.h"
+
+#include "bn.h"
+typedef BIGNUM * BigInteger;
+#define MATH_PRIV
+
+#include "t_defines.h"
+#include "t_pwd.h"
+
+/* Math library interface stubs */
+
+BigInteger
+BigIntegerFromInt(n)
+ unsigned int n;
+{
+ BIGNUM * a = BN_new();
+ BN_set_word(a, n);
+ return a;
+}
+
+BigInteger
+BigIntegerFromBytes(bytes, length)
+ unsigned char * bytes;
+ int length;
+{
+ BIGNUM * a = BN_new();
+ BN_bin2bn(bytes, length, a);
+ return a;
+}
+
+int
+BigIntegerToBytes(src, dest)
+ BigInteger src;
+ unsigned char * dest;
+{
+ return BN_bn2bin(src, dest);
+}
+
+int
+BigIntegerCmp(c1, c2)
+ BigInteger c1, c2;
+{
+ return BN_cmp(c1, c2);
+}
+
+int
+BigIntegerCmpInt(c1, c2)
+ BigInteger c1;
+ unsigned int c2;
+{
+ BIGNUM * a = BN_new();
+ int rv;
+ BN_set_word(a, c2);
+ rv = BN_cmp(c1, a);
+ BN_free(a);
+ return rv;
+}
+
+void
+BigIntegerAdd(result, a1, a2)
+ BigInteger result, a1, a2;
+{
+ BN_add(result, a1, a2);
+}
+
+void
+BigIntegerAddInt(result, a1, a2)
+ BigInteger result, a1;
+ unsigned int a2;
+{
+ BIGNUM * a = BN_new();
+ BN_set_word(a, a2);
+ BN_add(result, a1, a);
+ BN_free(a);
+}
+
+void
+BigIntegerSub(result, s1, s2)
+ BigInteger result, s1, s2;
+{
+ BN_sub(result, s1, s2);
+}
+
+void
+BigIntegerMulInt(result, m1, m2)
+ BigInteger result, m1;
+ unsigned int m2;
+{
+ BN_CTX * ctx = BN_CTX_new();
+ BIGNUM * m = BN_new();
+ BN_set_word(m, m2);
+ BN_mul(result, m1, m, ctx);
+ BN_CTX_free(ctx);
+}
+
+void
+BigIntegerModMul(r, m1, m2, modulus)
+ BigInteger r, m1, m2, modulus;
+{
+ BN_CTX * ctx = BN_CTX_new();
+ BN_mod_mul(r, m1, m2, modulus, ctx);
+ BN_CTX_free(ctx);
+}
+
+void
+BigIntegerModExp(r, b, e, m)
+ BigInteger r, b, e, m;
+{
+ BN_CTX * ctx = BN_CTX_new();
+ BN_mod_exp(r, b, e, m, ctx);
+ BN_CTX_free(ctx);
+}
+
+void
+BigIntegerModExpInt(r, b, e, m)
+ BigInteger r, b;
+ unsigned int e;
+ BigInteger m;
+{
+ BN_CTX * ctx = BN_CTX_new();
+ BIGNUM * p = BN_new();
+ BN_set_word(p, e);
+ BN_mod_exp(r, b, p, m, ctx);
+ BN_free(p);
+ BN_CTX_free(ctx);
+}
+
+void
+BigIntegerFree(b)
+ BigInteger b;
+{
+ BN_free(b);
+}
diff --git a/package/network/services/ead/src/tinysrp/.svn/text-base/t_misc.c.svn-base b/package/network/services/ead/src/tinysrp/.svn/text-base/t_misc.c.svn-base
new file mode 100644
index 0000000..a23986f
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/.svn/text-base/t_misc.c.svn-base
@@ -0,0 +1,338 @@
+/*
+ * Copyright (c) 1997-1999 The Stanford SRP Authentication Project
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF
+ * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * In addition, the following conditions apply:
+ *
+ * 1. Any software that incorporates the SRP authentication technology
+ * must display the following acknowlegment:
+ * "This product uses the 'Secure Remote Password' cryptographic
+ * authentication system developed by Tom Wu (tjw@CS.Stanford.EDU)."
+ *
+ * 2. Any software that incorporates all or part of the SRP distribution
+ * itself must also display the following acknowledgment:
+ * "This product includes software developed by Tom Wu and Eugene
+ * Jhong for the SRP Distribution (http://srp.stanford.edu/srp/)."
+ *
+ * 3. Redistributions in source or binary form must retain an intact copy
+ * of this copyright notice and list of conditions.
+ */
+
+#include "t_defines.h"
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif /* HAVE_UNISTD_H */
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#include "t_sha.h"
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+static unsigned char randpool[SHA_DIGESTSIZE], randout[SHA_DIGESTSIZE];
+static unsigned long randcnt = 0;
+static unsigned int outpos = 0;
+SHA1_CTX randctxt;
+
+/*
+ * t_envhash - Generate a 160-bit SHA hash of the environment
+ *
+ * This routine performs an SHA hash of all the "name=value" pairs
+ * in the environment concatenated together and dumps them in the
+ * output. While it is true that anyone on the system can see
+ * your environment, someone not on the system will have a very
+ * difficult time guessing it, especially since some systems play
+ * tricks with variable ordering and sometimes define quirky
+ * environment variables like $WINDOWID or $_.
+ */
+extern char ** environ;
+
+static void
+t_envhash(out)
+ unsigned char * out;
+{
+ char ** ptr;
+ char ebuf[256];
+ SHA1_CTX ctxt;
+
+ SHA1Init(&ctxt);
+ for(ptr = environ; *ptr; ++ptr) {
+ strncpy(ebuf, *ptr, 255);
+ ebuf[255] = '\0';
+ SHA1Update(&ctxt, ebuf, strlen(ebuf));
+ }
+ SHA1Final(out, &ctxt);
+}
+
+/*
+ * t_fshash - Generate a 160-bit SHA hash from the file system
+ *
+ * This routine climbs up the directory tree from the current
+ * directory, running stat() on each directory until it hits the
+ * root directory. This information is sensitive to the last
+ * access/modification times of all the directories above you,
+ * so someone who lists one of those directories injects some
+ * entropy into the system. Obviously, this hash is very sensitive
+ * to your current directory when the program is run.
+ *
+ * For good measure, it also performs an fstat on the standard input,
+ * usually your tty, throws that into the buffer, creates a file in
+ * /tmp (the inode is unpredictable on a busy system), and runs stat()
+ * on that before deleting it.
+ *
+ * The entire buffer is run once through SHA to obtain the final result.
+ */
+static void
+t_fshash(out)
+ unsigned char * out;
+{
+ char dotpath[128];
+ struct stat st;
+ SHA1_CTX ctxt;
+ int i, pinode;
+ dev_t pdev;
+
+ SHA1Init(&ctxt);
+ if(stat(".", &st) >= 0) {
+ SHA1Update(&ctxt, (unsigned char *) &st, sizeof(st));
+ pinode = st.st_ino;
+ pdev = st.st_dev;
+ strcpy(dotpath, "..");
+ for(i = 0; i < 40; ++i) {
+ if(stat(dotpath, &st) < 0)
+ break;
+ if(st.st_ino == pinode && st.st_dev == pdev)
+ break;
+ SHA1Update(&ctxt, (unsigned char *) &st, sizeof(st));
+ pinode = st.st_ino;
+ pdev = st.st_dev;
+ strcat(dotpath, "/..");
+ }
+ }
+
+ if(fstat(0, &st) >= 0)
+ SHA1Update(&ctxt, (unsigned char *) &st, sizeof(st));
+
+ sprintf(dotpath, "/tmp/rnd.%d", getpid());
+ if(creat(dotpath, 0600) >= 0 && stat(dotpath, &st) >= 0)
+ SHA1Update(&ctxt, (unsigned char *) &st, sizeof(st));
+ unlink(dotpath);
+
+ SHA1Final(out, &ctxt);
+}
+
+/*
+ * Generate a high-entropy seed for the strong random number generator.
+ * This uses a wide variety of quickly gathered and somewhat unpredictable
+ * system information. The 'preseed' structure is assembled from:
+ *
+ * The system time in seconds
+ * The system time in microseconds
+ * The current process ID
+ * The parent process ID
+ * A hash of the user's environment
+ * A hash gathered from the file system
+ * Input from a random device, if available
+ * Timings of system interrupts
+ *
+ * The entire structure (60 bytes on most systems) is fed to SHA to produce
+ * a 160-bit seed for the strong random number generator. It is believed
+ * that in the worst case (on a quiet system with no random device versus
+ * an attacker who has access to the system already), the seed contains at
+ * least about 80 bits of entropy. Versus an attacker who does not have
+ * access to the system, the entropy should be slightly over 128 bits.
+ */
+static char initialized = 0;
+
+static struct {
+ unsigned int trand1;
+ time_t sec;
+ time_t usec;
+ short pid;
+ short ppid;
+ unsigned char envh[SHA_DIGESTSIZE];
+ unsigned char fsh[SHA_DIGESTSIZE];
+ unsigned char devrand[20];
+ unsigned int trand2;
+} preseed;
+
+unsigned long raw_truerand();
+
+void
+t_initrand()
+{
+ SHA1_CTX ctxt;
+#ifdef USE_FTIME
+ struct timeb t;
+#else
+ struct timeval t;
+#endif
+ int i, r=0;
+
+ if(initialized)
+ return;
+
+ initialized = 1;
+
+ i = open("/dev/urandom", O_RDONLY);
+ if(i > 0) {
+ r += read(i, preseed.devrand, sizeof(preseed.devrand));
+ close(i);
+ }
+
+ /* Resort to truerand only if desperate for some Real entropy */
+ if(r == 0)
+ preseed.trand1 = raw_truerand();
+
+#ifdef USE_FTIME
+ ftime(&t);
+#else
+ gettimeofday(&t, NULL);
+#endif
+
+#ifdef USE_FTIME
+ preseed.sec = t.time;
+ preseed.usec = t.millitm;
+#else
+ preseed.sec = t.tv_sec;
+ preseed.usec = t.tv_usec;
+#endif
+ preseed.pid = getpid();
+ preseed.ppid = getppid();
+ t_envhash(preseed.envh);
+ t_fshash(preseed.fsh);
+
+ if(r == 0)
+ preseed.trand2 = raw_truerand();
+
+ SHA1Init(&ctxt);
+ SHA1Update(&ctxt, (unsigned char *) &preseed, sizeof(preseed));
+ SHA1Final(randpool, &ctxt);
+ outpos = 0;
+ memset((unsigned char *) &preseed, 0, sizeof(preseed));
+ memset((unsigned char *) &ctxt, 0, sizeof(ctxt));
+}
+
+#define NUM_RANDOMS 12
+
+/*
+ * The strong random number generator. This uses a 160-bit seed
+ * and uses SHA-1 in a feedback configuration to generate successive
+ * outputs. If S[0] is set to the initial seed, then:
+ *
+ * S[i+1] = SHA-1(i || S[i])
+ * A[i] = SHA-1(S[i])
+ *
+ * where the A[i] are the output blocks starting with i=0.
+ * Each cycle generates 20 bytes of new output.
+ */
+_TYPE( void )
+t_random(data, size)
+ unsigned char * data;
+ unsigned size;
+{
+ if(!initialized)
+ t_initrand();
+
+ if(size <= 0) /* t_random(NULL, 0) forces seed initialization */
+ return;
+
+ while(size > outpos) {
+ if(outpos > 0) {
+ memcpy(data, randout + (sizeof(randout) - outpos), outpos);
+ data += outpos;
+ size -= outpos;
+ }
+
+ /* Recycle */
+ SHA1Init(&randctxt);
+ SHA1Update(&randctxt, randpool, sizeof(randpool));
+ SHA1Final(randout, &randctxt);
+ SHA1Init(&randctxt);
+ SHA1Update(&randctxt, (unsigned char *) &randcnt, sizeof(randcnt));
+ SHA1Update(&randctxt, randpool, sizeof(randpool));
+ SHA1Final(randpool, &randctxt);
+ ++randcnt;
+ outpos = sizeof(randout);
+ }
+
+ if(size > 0) {
+ memcpy(data, randout + (sizeof(randout) - outpos), size);
+ outpos -= size;
+ }
+}
+
+/*
+ * The interleaved session-key hash. This separates the even and the odd
+ * bytes of the input (ignoring the first byte if the input length is odd),
+ * hashes them separately, and re-interleaves the two outputs to form a
+ * single 320-bit value.
+ */
+_TYPE( unsigned char * )
+t_sessionkey(key, sk, sklen)
+ unsigned char * key;
+ unsigned char * sk;
+ unsigned sklen;
+{
+ unsigned i, klen;
+ unsigned char * hbuf;
+ unsigned char hout[SHA_DIGESTSIZE];
+ SHA1_CTX ctxt;
+
+ while(sklen > 0 && *sk == 0) { /* Skip leading 0's */
+ --sklen;
+ ++sk;
+ }
+
+ klen = sklen / 2;
+ if((hbuf = malloc(klen * sizeof(char))) == 0)
+ return 0;
+
+ for(i = 0; i < klen; ++i)
+ hbuf[i] = sk[sklen - 2 * i - 1];
+ SHA1Init(&ctxt);
+ SHA1Update(&ctxt, hbuf, klen);
+ SHA1Final(hout, &ctxt);
+ for(i = 0; i < sizeof(hout); ++i)
+ key[2 * i] = hout[i];
+
+ for(i = 0; i < klen; ++i)
+ hbuf[i] = sk[sklen - 2 * i - 2];
+ SHA1Init(&ctxt);
+ SHA1Update(&ctxt, hbuf, klen);
+ SHA1Final(hout, &ctxt);
+ for(i = 0; i < sizeof(hout); ++i)
+ key[2 * i + 1] = hout[i];
+
+ memset(hout, 0, sizeof(hout));
+ memset(hbuf, 0, klen);
+ free(hbuf);
+ return key;
+}
diff --git a/package/network/services/ead/src/tinysrp/.svn/text-base/t_pw.c.svn-base b/package/network/services/ead/src/tinysrp/.svn/text-base/t_pw.c.svn-base
new file mode 100644
index 0000000..18e929b
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/.svn/text-base/t_pw.c.svn-base
@@ -0,0 +1,262 @@
+/*
+ * Copyright (c) 1997-2000 The Stanford SRP Authentication Project
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF
+ * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * In addition, the following conditions apply:
+ *
+ * 1. Any software that incorporates the SRP authentication technology
+ * must display the following acknowlegment:
+ * "This product uses the 'Secure Remote Password' cryptographic
+ * authentication system developed by Tom Wu (tjw@CS.Stanford.EDU)."
+ *
+ * 2. Any software that incorporates all or part of the SRP distribution
+ * itself must also display the following acknowledgment:
+ * "This product includes software developed by Tom Wu and Eugene
+ * Jhong for the SRP Distribution (http://srp.stanford.edu/srp/)."
+ *
+ * 3. Redistributions in source or binary form must retain an intact copy
+ * of this copyright notice and list of conditions.
+ */
+
+#include "t_defines.h"
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif /* HAVE_UNISTD_H */
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#ifdef USE_HOMEDIR
+#include <pwd.h>
+#endif
+#ifdef WIN32
+#include <io.h>
+#endif
+
+#include "t_pwd.h"
+#include "t_read.h"
+#include "t_sha.h"
+#include "t_server.h"
+
+static struct t_pw * syspw = NULL;
+static struct t_passwd tpass;
+
+_TYPE( struct t_server * )
+t_serveropen(username)
+ const char * username;
+{
+ struct t_passwd * p;
+ p = gettpnam(username);
+ if(p == NULL) {
+ return NULL;
+ } else {
+ return t_serveropenraw(&p->tp, &p->tc);
+ }
+}
+
+
+/* t_openpw(NULL) is deprecated - use settpent()/gettpnam() instead */
+
+_TYPE( struct t_pw * )
+t_openpw(fp)
+ FILE * fp;
+{
+ struct t_pw * tpw;
+ char close_flag = 0;
+
+ if(fp == NULL) { /* Deprecated */
+ if((fp = fopen(DEFAULT_PASSWD, "r")) == NULL)
+ return NULL;
+ close_flag = 1;
+ }
+ else
+ close_flag = 0;
+
+ if((tpw = malloc(sizeof(struct t_pw))) == NULL)
+ return NULL;
+ tpw->instream = fp;
+ tpw->close_on_exit = close_flag;
+ tpw->state = FILE_ONLY;
+
+ return tpw;
+}
+
+_TYPE( struct t_pw * )
+t_openpwbyname(pwname)
+ const char * pwname;
+{
+ FILE * fp;
+ struct t_pw * t;
+
+ if(pwname == NULL) /* Deprecated */
+ return t_openpw(NULL);
+
+ if((fp = fopen(pwname, "r")) == NULL)
+ return NULL;
+
+ t = t_openpw(fp);
+ t->close_on_exit = 1;
+ return t;
+}
+
+_TYPE( void )
+t_closepw(tpw)
+ struct t_pw * tpw;
+{
+ if(tpw->close_on_exit)
+ fclose(tpw->instream);
+ free(tpw);
+}
+
+_TYPE( void )
+t_rewindpw(tpw)
+ struct t_pw * tpw;
+{
+#ifdef ENABLE_YP
+ if(tpw->state == IN_NIS)
+ tpw->state = FILE_NIS;
+#endif
+ rewind(tpw->instream);
+}
+
+#ifdef ENABLE_YP
+static void
+savepwent(tpw, pwent)
+ struct t_pw * tpw;
+ struct t_pwent *pwent;
+{
+ tpw->pebuf.name = tpw->userbuf;
+ tpw->pebuf.password.data = tpw->pwbuf;
+ tpw->pebuf.salt.data = tpw->saltbuf;
+ strcpy(tpw->pebuf.name, pwent->name);
+ tpw->pebuf.password.len = pwent->password.len;
+ memcpy(tpw->pebuf.password.data, pwent->password.data, pwent->password.len);
+ tpw->pebuf.salt.len = pwent->salt.len;
+ memcpy(tpw->pebuf.salt.data, pwent->salt.data, pwent->salt.len);
+ tpw->pebuf.index = pwent->index;
+}
+#endif /* ENABLE_YP */
+
+_TYPE( struct t_pwent * )
+t_getpwbyname(tpw, user)
+ struct t_pw * tpw;
+ const char * user;
+{
+ char indexbuf[16];
+ char passbuf[MAXB64PARAMLEN];
+ char saltstr[MAXB64SALTLEN];
+ char username[MAXUSERLEN];
+#ifdef ENABLE_YP
+ struct t_passwd * nisent;
+#endif
+
+ t_rewindpw(tpw);
+
+ while(t_nextfield(tpw->instream, username, MAXUSERLEN) > 0) {
+#ifdef ENABLE_YP
+ if(tpw->state == FILE_NIS && *username == '+') {
+ if(strlen(username) == 1 || strcmp(user, username+1) == 0) {
+ nisent = _yp_gettpnam(user); /* Entry is +username or + */
+ if(nisent != NULL) {
+ savepwent(tpw, &nisent->tp);
+ return &tpw->pebuf;
+ }
+ }
+ }
+#endif
+ if(strcmp(user, username) == 0)
+ if(t_nextfield(tpw->instream, passbuf, MAXB64PARAMLEN) > 0 &&
+ (tpw->pebuf.password.len = t_fromb64(tpw->pwbuf, passbuf)) > 0 &&
+ t_nextfield(tpw->instream, saltstr, MAXB64SALTLEN) > 0 &&
+ (tpw->pebuf.salt.len = t_fromb64(tpw->saltbuf, saltstr)) > 0 &&
+ t_nextfield(tpw->instream, indexbuf, 16) > 0 &&
+ (tpw->pebuf.index = atoi(indexbuf)) > 0) {
+ strcpy(tpw->userbuf, username);
+ tpw->pebuf.name = tpw->userbuf;
+ tpw->pebuf.password.data = tpw->pwbuf;
+ tpw->pebuf.salt.data = tpw->saltbuf;
+ t_nextline(tpw->instream);
+ return &tpw->pebuf;
+ }
+ if(t_nextline(tpw->instream) < 0)
+ return NULL;
+ }
+ return NULL;
+}
+
+/* System password file accessors */
+
+static int
+pwinit()
+{
+ if(syspw == NULL) {
+ if((syspw = t_openpwbyname(DEFAULT_PASSWD)) == NULL)
+ return -1;
+ syspw->state = FILE_NIS;
+ }
+ return 0;
+}
+
+static void
+pwsetup(out, tpwd, tcnf)
+ struct t_passwd * out;
+ struct t_pwent * tpwd;
+ struct t_confent * tcnf;
+{
+ out->tp.name = tpwd->name;
+ out->tp.password.len = tpwd->password.len;
+ out->tp.password.data = tpwd->password.data;
+ out->tp.salt.len = tpwd->salt.len;
+ out->tp.salt.data = tpwd->salt.data;
+ out->tp.index = tpwd->index;
+
+ out->tc.index = tcnf->index;
+ out->tc.modulus.len = tcnf->modulus.len;
+ out->tc.modulus.data = tcnf->modulus.data;
+ out->tc.generator.len = tcnf->generator.len;
+ out->tc.generator.data = tcnf->generator.data;
+}
+
+_TYPE( struct t_passwd * )
+gettpnam
+(user)
+ const char * user;
+{
+ struct t_pwent * tpptr;
+ struct t_confent * tcptr;
+
+ if(pwinit() < 0)
+ return NULL;
+ tpptr = t_getpwbyname(syspw, user);
+ if(tpptr == NULL)
+ return NULL;
+ tcptr =
+ gettcid
+ (tpptr->index);
+ if(tcptr == NULL)
+ return NULL;
+ pwsetup(&tpass, tpptr, tcptr);
+ return &tpass;
+}
diff --git a/package/network/services/ead/src/tinysrp/.svn/text-base/t_pwd.h.svn-base b/package/network/services/ead/src/tinysrp/.svn/text-base/t_pwd.h.svn-base
new file mode 100644
index 0000000..73697be
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/.svn/text-base/t_pwd.h.svn-base
@@ -0,0 +1,310 @@
+/*
+ * Copyright (c) 1997-1999 The Stanford SRP Authentication Project
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF
+ * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * In addition, the following conditions apply:
+ *
+ * 1. Any software that incorporates the SRP authentication technology
+ * must display the following acknowlegment:
+ * "This product uses the 'Secure Remote Password' cryptographic
+ * authentication system developed by Tom Wu (tjw@CS.Stanford.EDU)."
+ *
+ * 2. Any software that incorporates all or part of the SRP distribution
+ * itself must also display the following acknowledgment:
+ * "This product includes software developed by Tom Wu and Eugene
+ * Jhong for the SRP Distribution (http://srp.stanford.edu/srp/)."
+ *
+ * 3. Redistributions in source or binary form must retain an intact copy
+ * of this copyright notice and list of conditions.
+ */
+
+#ifndef T_PWD_H
+#define T_PWD_H
+
+#ifndef P
+#if defined (__STDC__) || defined (__cplusplus)
+#define P(x) x
+#else
+#define P(x) ()
+#endif
+#endif
+
+/* For building dynamic link libraries under windows, windows NT
+ * using MSVC1.5 or MSVC2.0
+ */
+
+#ifndef _DLLDECL
+#define _DLLDECL
+
+#ifdef MSVC15 /* MSVC1.5 support for 16 bit apps */
+#define _MSVC15EXPORT _export
+#define _MSVC20EXPORT
+#define _DLLAPI _export _pascal
+#define _TYPE(a) a _MSVC15EXPORT
+#define DLLEXPORT 1
+
+#elif MSVC20
+#define _MSVC15EXPORT
+#define _MSVC20EXPORT _declspec(dllexport)
+#define _DLLAPI
+#define _TYPE(a) _MSVC20EXPORT a
+#define DLLEXPORT 1
+
+#else /* Default, non-dll. Use this for Unix or DOS */
+#define _MSVC15DEXPORT
+#define _MSVC20EXPORT
+#define _DLLAPI
+#define _TYPE(a) a
+#endif
+#endif
+
+#define MAXPARAMBITS 2048
+#define MAXPARAMLEN ((MAXPARAMBITS + 7) / 8)
+#define MAXB64PARAMLEN ((MAXPARAMBITS + 5) / 6 + 1)
+#define MAXHEXPARAMLEN ((MAXPARAMBITS + 3) / 4 + 1)
+#define MAXOCTPARAMLEN ((MAXPARAMBITS + 2) / 3 + 1)
+
+#define MAXUSERLEN 32
+#define MAXSALTLEN 32
+#define MAXB64SALTLEN 44 /* 256 bits in b64 + null */
+#define SALTLEN 10 /* Normally 80 bits */
+
+#define RESPONSE_LEN 20 /* 160-bit proof hashes */
+#define SESSION_KEY_LEN (2 * RESPONSE_LEN) /* 320-bit session key */
+
+#define DEFAULT_PASSWD "tpasswd"
+
+struct t_num { /* Standard byte-oriented integer representation */
+ int len;
+ unsigned char * data;
+};
+
+struct t_preconf { /* Structure returned by t_getpreparam() */
+ char * mod_b64;
+ char * gen_b64;
+ char * comment;
+
+ struct t_num modulus;
+ struct t_num generator;
+};
+
+/*
+ * The built-in (known good) parameters access routines
+ *
+ * "t_getprecount" returns the number of precompiled parameter sets.
+ * "t_getpreparam" returns the indicated parameter set.
+ * Memory is statically allocated - callers need not perform any memory mgmt.
+ */
+_TYPE( int ) t_getprecount();
+_TYPE( struct t_preconf * ) t_getpreparam P((int));
+
+struct t_confent { /* One configuration file entry (index, N, g) */
+ int index;
+ struct t_num modulus;
+ struct t_num generator;
+};
+
+struct t_conf { /* An open configuration file */
+ FILE * instream;
+ char close_on_exit;
+ unsigned char modbuf[MAXPARAMLEN];
+ unsigned char genbuf[MAXPARAMLEN];
+ struct t_confent tcbuf;
+};
+
+/*
+ * The configuration file routines are designed along the lines of the
+ * "getpw" functions in the standard C library.
+ *
+ * "t_openconf" accepts a stdio stream and interprets it as a config file.
+ * "t_openconfbyname" accepts a filename and does the same thing.
+ * "t_closeconf" closes the config file.
+ * "t_getconfent" fetches the next sequential configuration entry.
+ * "t_getconfbyindex" fetches the configuration entry whose index
+ * matches the one supplied, or NULL if one can't be found.
+ * "t_getconflast" fetches the last configuration entry in the file.
+ * "t_makeconfent" generates a set of configuration entry parameters
+ * randomly.
+ * "t_newconfent" returns an empty configuration entry.
+ * "t_cmpconfent" compares two configuration entries a la strcmp.
+ * "t_checkconfent" verifies that a set of configuration parameters
+ * are suitable. N must be prime and should be a safe prime.
+ * "t_putconfent" writes a configuration entry to a stream.
+ */
+_TYPE( struct t_conf * ) t_openconf P((FILE *));
+_TYPE( struct t_conf * ) t_openconfbyname P((const char *));
+_TYPE( void ) t_closeconf P((struct t_conf *));
+_TYPE( void ) t_rewindconf P((struct t_conf *));
+_TYPE( struct t_confent * ) t_getconfent P((struct t_conf *));
+_TYPE( struct t_confent * ) t_getconfbyindex P((struct t_conf *, int));
+_TYPE( struct t_confent * ) t_getconflast P((struct t_conf *));
+_TYPE( struct t_confent * ) t_makeconfent P((struct t_conf *, int));
+_TYPE( struct t_confent * ) t_makeconfent_c P((struct t_conf *, int));
+_TYPE( struct t_confent * ) t_newconfent P((struct t_conf *));
+_TYPE( int ) t_cmpconfent P((const struct t_confent *, const struct t_confent *));
+_TYPE( int ) t_checkconfent P((const struct t_confent *));
+_TYPE( void ) t_putconfent P((const struct t_confent *, FILE *));
+
+/* libc-style system conf file access */
+_TYPE( struct t_confent *) gettcent();
+_TYPE( struct t_confent *) gettcid P((int));
+_TYPE( void ) settcent();
+_TYPE( void ) endtcent();
+
+#ifdef ENABLE_NSW
+extern struct t_confent * _gettcent();
+extern struct t_confent * _gettcid P((int));
+extern void _settcent();
+extern void _endtcent();
+#endif
+
+/* A hack to support '+'-style entries in the passwd file */
+
+typedef enum fstate {
+ FILE_ONLY, /* Ordinary file, don't consult NIS ever */
+ FILE_NIS, /* Currently accessing file, use NIS if encountered */
+ IN_NIS, /* Currently in a '+' entry; use NIS for getXXent */
+} FILE_STATE;
+
+struct t_pwent { /* A single password file entry */
+ char * name;
+ struct t_num password;
+ struct t_num salt;
+ int index;
+};
+
+struct t_pw { /* An open password file */
+ FILE * instream;
+ char close_on_exit;
+ FILE_STATE state;
+ char userbuf[MAXUSERLEN];
+ unsigned char pwbuf[MAXPARAMLEN];
+ unsigned char saltbuf[SALTLEN];
+ struct t_pwent pebuf;
+};
+
+/*
+ * The password manipulation routines are patterned after the getpw*
+ * standard C library function calls.
+ *
+ * "t_openpw" reads a stream as if it were a password file.
+ * "t_openpwbyname" opens the named file as a password file.
+ * "t_closepw" closes an open password file.
+ * "t_rewindpw" starts the internal file pointer from the beginning
+ * of the password file.
+ * "t_getpwent" retrieves the next sequential password entry.
+ * "t_getpwbyname" looks up the password entry corresponding to the
+ * specified user.
+ * "t_makepwent" constructs a password entry from a username, password,
+ * numeric salt, and configuration entry.
+ * "t_putpwent" writes a password entry to a stream.
+ */
+_TYPE( struct t_pw * ) t_openpw P((FILE *));
+_TYPE( struct t_pw * ) t_openpwbyname P((const char *));
+_TYPE( void ) t_closepw P((struct t_pw *));
+_TYPE( void ) t_rewindpw P((struct t_pw *));
+_TYPE( struct t_pwent * ) t_getpwent P((struct t_pw *));
+_TYPE( struct t_pwent * ) t_getpwbyname P((struct t_pw *, const char *));
+_TYPE( struct t_pwent * ) t_makepwent P((struct t_pw *, const char *,
+ const char *, const struct t_num *,
+ const struct t_confent *));
+_TYPE( void ) t_putpwent P((const struct t_pwent *, FILE *));
+
+struct t_passwd {
+ struct t_pwent tp;
+ struct t_confent tc;
+};
+
+/* libc-style system password file access */
+_TYPE( struct t_passwd * ) gettpent();
+_TYPE( struct t_passwd * ) gettpnam P((const char *));
+_TYPE( void ) settpent();
+_TYPE( void ) endtpent();
+
+#ifdef ENABLE_NSW
+extern struct t_passwd * _gettpent();
+extern struct t_passwd * _gettpnam P((const char *));
+extern void _settpent();
+extern void _endtpent();
+#endif
+
+/*
+ * Utility functions
+ *
+ * "t_verifypw" accepts a username and password, and checks against the
+ * system password file to see if the password for that user is correct.
+ * Returns > 0 if it is correct, 0 if not, and -1 if some error occurred
+ * (i.e. the user doesn't exist on the system). This is intended ONLY
+ * for local authentication; for remote authentication, look at the
+ * t_client and t_server source. (That's the whole point of SRP!)
+ * "t_changepw" modifies the specified file, substituting the given password
+ * entry for the one already in the file. If no matching entry is found,
+ * the new entry is simply appended to the file.
+ * "t_deletepw" removes the specified user from the specified file.
+ */
+_TYPE( int ) t_verifypw P((const char *, const char *));
+_TYPE( int ) t_changepw P((const char *, const struct t_pwent *));
+_TYPE( int ) t_deletepw P((const char *, const char *));
+
+/* Conversion utilities */
+
+/*
+ * All these calls accept output as the first parameter. In the case of
+ * t_tohex and t_tob64, the last argument is the length of the byte-string
+ * input.
+ */
+_TYPE( char * t_tohex ) P((char *, char *, unsigned));
+_TYPE( int ) t_fromhex P((char *, char *));
+_TYPE( char * ) t_tob64 P((char *, char *, unsigned));
+_TYPE( int ) t_fromb64 P((char *, char *));
+
+/* Miscellaneous utilities */
+
+/*
+ * "t_random" is a cryptographic random number generator, which is seeded
+ * from various high-entropy sources and uses a one-way hash function
+ * in a feedback configuration.
+ * "t_sessionkey" is the interleaved hash used to generate session keys
+ * from a large integer.
+ * "t_getpass" reads a password from the terminal without echoing.
+ */
+_TYPE( void ) t_random P((unsigned char *, unsigned));
+_TYPE( void ) t_stronginitrand();
+_TYPE( unsigned char * )
+ t_sessionkey P((unsigned char *, unsigned char *, unsigned));
+_TYPE( int ) t_getpass P((char *, unsigned, const char *));
+
+/*
+ * Return value of t_checkprime:
+ * < 0 : not prime
+ * = 0 : prime, but not safe
+ * > 0 : safe
+ */
+#define NUM_NOTPRIME -1
+#define NUM_NOTSAFE 0
+#define NUM_SAFE 1
+
+_TYPE( int ) t_checkprime P((const struct t_num *));
+
+#endif
diff --git a/package/network/services/ead/src/tinysrp/.svn/text-base/t_read.c.svn-base b/package/network/services/ead/src/tinysrp/.svn/text-base/t_read.c.svn-base
new file mode 100644
index 0000000..087b7d5
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/.svn/text-base/t_read.c.svn-base
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 1997-1999 The Stanford SRP Authentication Project
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF
+ * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * In addition, the following conditions apply:
+ *
+ * 1. Any software that incorporates the SRP authentication technology
+ * must display the following acknowlegment:
+ * "This product uses the 'Secure Remote Password' cryptographic
+ * authentication system developed by Tom Wu (tjw@CS.Stanford.EDU)."
+ *
+ * 2. Any software that incorporates all or part of the SRP distribution
+ * itself must also display the following acknowledgment:
+ * "This product includes software developed by Tom Wu and Eugene
+ * Jhong for the SRP Distribution (http://srp.stanford.edu/srp/)."
+ *
+ * 3. Redistributions in source or binary form must retain an intact copy
+ * of this copyright notice and list of conditions.
+ */
+
+#include <stdio.h>
+#include "config.h"
+
+#define FSEPARATOR ':'
+
+int
+t_nextfield(fp, s, max)
+FILE * fp;
+char * s;
+unsigned max;
+{
+ int c, count = 0;
+
+ while((c = getc(fp)) != EOF) {
+ if(c == '\n') {
+ ungetc(c, fp);
+ break;
+ }
+ else if(c == FSEPARATOR)
+ break;
+ if(count < max - 1) {
+ *s++ = c;
+ ++count;
+ }
+ }
+ *s++ = '\0';
+ return count;
+}
+
+int
+t_nextline(fp)
+FILE * fp;
+{
+ int c;
+
+ while((c = getc(fp)) != '\n')
+ if(c == EOF)
+ return -1;
+ return 0;
+}
diff --git a/package/network/services/ead/src/tinysrp/.svn/text-base/t_read.h.svn-base b/package/network/services/ead/src/tinysrp/.svn/text-base/t_read.h.svn-base
new file mode 100644
index 0000000..e621f79
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/.svn/text-base/t_read.h.svn-base
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 1997-1999 The Stanford SRP Authentication Project
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF
+ * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * In addition, the following conditions apply:
+ *
+ * 1. Any software that incorporates the SRP authentication technology
+ * must display the following acknowlegment:
+ * "This product uses the 'Secure Remote Password' cryptographic
+ * authentication system developed by Tom Wu (tjw@CS.Stanford.EDU)."
+ *
+ * 2. Any software that incorporates all or part of the SRP distribution
+ * itself must also display the following acknowledgment:
+ * "This product includes software developed by Tom Wu and Eugene
+ * Jhong for the SRP Distribution (http://srp.stanford.edu/srp/)."
+ *
+ * 3. Redistributions in source or binary form must retain an intact copy
+ * of this copyright notice and list of conditions.
+ */
+
+#ifndef _T_READ_H_
+#define _T_READ_H_
+
+#if !defined(P)
+#ifdef __STDC__
+#define P(x) x
+#else
+#define P(x) ()
+#endif
+#endif
+
+extern int t_nextfield P((FILE *, char *, unsigned));
+extern int t_nextline P((FILE *));
+#endif
diff --git a/package/network/services/ead/src/tinysrp/.svn/text-base/t_server.c.svn-base b/package/network/services/ead/src/tinysrp/.svn/text-base/t_server.c.svn-base
new file mode 100644
index 0000000..6ab501b
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/.svn/text-base/t_server.c.svn-base
@@ -0,0 +1,259 @@
+/*
+ * Copyright (c) 1997-1999 The Stanford SRP Authentication Project
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF
+ * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * In addition, the following conditions apply:
+ *
+ * 1. Any software that incorporates the SRP authentication technology
+ * must display the following acknowlegment:
+ * "This product uses the 'Secure Remote Password' cryptographic
+ * authentication system developed by Tom Wu (tjw@CS.Stanford.EDU)."
+ *
+ * 2. Any software that incorporates all or part of the SRP distribution
+ * itself must also display the following acknowledgment:
+ * "This product includes software developed by Tom Wu and Eugene
+ * Jhong for the SRP Distribution (http://srp.stanford.edu/srp/)."
+ *
+ * 3. Redistributions in source or binary form must retain an intact copy
+ * of this copyright notice and list of conditions.
+ */
+
+#include <stdio.h>
+#include "t_defines.h"
+#include "t_pwd.h"
+#include "t_server.h"
+
+_TYPE( struct t_server * )
+t_serveropenraw(ent, tce)
+ struct t_pwent * ent;
+ struct t_confent * tce;
+{
+ struct t_server * ts;
+ unsigned char buf1[SHA_DIGESTSIZE], buf2[SHA_DIGESTSIZE];
+ SHA1_CTX ctxt;
+ int i;
+
+ if((ts = malloc(sizeof(struct t_server))) == 0)
+ return 0;
+
+ SHA1Init(&ts->ckhash);
+
+ ts->index = ent->index;
+ ts->n.len = tce->modulus.len;
+ ts->n.data = ts->nbuf;
+ memcpy(ts->n.data, tce->modulus.data, ts->n.len);
+
+ SHA1Init(&ctxt);
+ SHA1Update(&ctxt, ts->n.data, ts->n.len);
+ SHA1Final(buf1, &ctxt);
+
+ ts->g.len = tce->generator.len;
+ ts->g.data = ts->gbuf;
+ memcpy(ts->g.data, tce->generator.data, ts->g.len);
+
+ SHA1Init(&ctxt);
+ SHA1Update(&ctxt, ts->g.data, ts->g.len);
+ SHA1Final(buf2, &ctxt);
+
+ for(i = 0; i < sizeof(buf1); ++i)
+ buf1[i] ^= buf2[i];
+
+ SHA1Update(&ts->ckhash, buf1, sizeof(buf1));
+
+ SHA1Init(&ctxt);
+ SHA1Update(&ctxt, ent->name, strlen(ent->name));
+ SHA1Final(buf1, &ctxt);
+
+ SHA1Update(&ts->ckhash, buf1, sizeof(buf1));
+
+ ts->v.len = ent->password.len;
+ ts->v.data = ts->vbuf;
+ memcpy(ts->v.data, ent->password.data, ts->v.len);
+
+ ts->s.len = ent->salt.len;
+ ts->s.data = ts->saltbuf;
+ memcpy(ts->s.data, ent->salt.data, ts->s.len);
+
+ SHA1Update(&ts->ckhash, ts->s.data, ts->s.len);
+
+ ts->b.data = ts->bbuf;
+ ts->B.data = ts->Bbuf;
+
+ SHA1Init(&ts->hash);
+ SHA1Init(&ts->oldhash);
+ SHA1Init(&ts->oldckhash);
+
+ return ts;
+}
+
+_TYPE( struct t_num * )
+t_servergenexp(ts)
+ struct t_server * ts;
+{
+ BigInteger b, B, v, n, g;
+
+ if(ts->n.len < BLEN)
+ ts->b.len = ts->n.len;
+ else
+ ts->b.len = BLEN;
+
+ t_random(ts->b.data, ts->b.len);
+ b = BigIntegerFromBytes(ts->b.data, ts->b.len);
+ n = BigIntegerFromBytes(ts->n.data, ts->n.len);
+ g = BigIntegerFromBytes(ts->g.data, ts->g.len);
+ B = BigIntegerFromInt(0);
+ BigIntegerModExp(B, g, b, n);
+
+ v = BigIntegerFromBytes(ts->v.data, ts->v.len);
+ BigIntegerAdd(B, B, v);
+ if(BigIntegerCmp(B, n) > 0)
+ BigIntegerSub(B, B, n);
+
+ ts->B.len = BigIntegerToBytes(B, ts->B.data);
+
+ BigIntegerFree(v);
+ BigIntegerFree(B);
+ BigIntegerFree(b);
+ BigIntegerFree(g);
+ BigIntegerFree(n);
+
+ SHA1Update(&ts->oldckhash, ts->B.data, ts->B.len);
+
+ return &ts->B;
+}
+
+_TYPE( unsigned char * )
+t_servergetkey(ts, clientval)
+ struct t_server * ts;
+ struct t_num * clientval;
+{
+ BigInteger n, v, A, b, prod, res, S;
+ SHA1_CTX ctxt;
+ unsigned char sbuf[MAXPARAMLEN];
+ unsigned char dig[SHA_DIGESTSIZE];
+ unsigned slen;
+ unsigned int u;
+
+ SHA1Update(&ts->ckhash, clientval->data, clientval->len);
+ SHA1Update(&ts->ckhash, ts->B.data, ts->B.len);
+
+ SHA1Init(&ctxt);
+ SHA1Update(&ctxt, ts->B.data, ts->B.len);
+ SHA1Final(dig, &ctxt);
+ u = (dig[0] << 24) | (dig[1] << 16) | (dig[2] << 8) | dig[3];
+
+ SHA1Update(&ts->oldhash, clientval->data, clientval->len);
+ SHA1Update(&ts->hash, clientval->data, clientval->len);
+
+ n = BigIntegerFromBytes(ts->n.data, ts->n.len);
+ b = BigIntegerFromBytes(ts->b.data, ts->b.len);
+ v = BigIntegerFromBytes(ts->v.data, ts->v.len);
+ A = BigIntegerFromBytes(clientval->data, clientval->len);
+
+ prod = BigIntegerFromInt(0);
+ BigIntegerModExpInt(prod, v, u, n);
+ res = BigIntegerFromInt(0);
+ BigIntegerModMul(res, prod, A, n);
+
+ BigIntegerFree(A);
+ BigIntegerFree(v);
+ BigIntegerFree(prod);
+
+ if(BigIntegerCmpInt(res, 1) <= 0) { /* Check for Av^u == 1 (mod n) */
+ BigIntegerFree(res);
+ BigIntegerFree(b);
+ BigIntegerFree(n);
+ return NULL;
+ }
+
+ S = BigIntegerFromInt(0);
+
+ BigIntegerAddInt(S, res, 1);
+ if(BigIntegerCmp(S, n) == 0) { /* Check for Av^u == -1 (mod n) */
+ BigIntegerFree(res);
+ BigIntegerFree(b);
+ BigIntegerFree(n);
+ BigIntegerFree(S);
+ return NULL;
+ }
+
+ BigIntegerModExp(S, res, b, n);
+ slen = BigIntegerToBytes(S, sbuf);
+
+ BigIntegerFree(S);
+ BigIntegerFree(res);
+ BigIntegerFree(b);
+ BigIntegerFree(n);
+
+ t_sessionkey(ts->session_key, sbuf, slen);
+ memset(sbuf, 0, slen);
+
+ SHA1Update(&ts->oldhash, ts->session_key, sizeof(ts->session_key));
+ SHA1Update(&ts->oldckhash, ts->session_key, sizeof(ts->session_key));
+ SHA1Update(&ts->ckhash, ts->session_key, sizeof(ts->session_key));
+
+ return ts->session_key;
+}
+
+_TYPE( int )
+t_serververify(ts, resp)
+ struct t_server * ts;
+ unsigned char * resp;
+{
+ unsigned char expected[SHA_DIGESTSIZE];
+ int i;
+
+ SHA1Final(expected, &ts->oldckhash);
+ i = memcmp(expected, resp, sizeof(expected));
+ if(i == 0) {
+ SHA1Final(ts->session_response, &ts->oldhash);
+ return 0;
+ }
+ SHA1Final(expected, &ts->ckhash);
+ i = memcmp(expected, resp, sizeof(expected));
+ if(i == 0) {
+ SHA1Update(&ts->hash, expected, sizeof(expected));
+ SHA1Update(&ts->hash, ts->session_key, sizeof(ts->session_key));
+ SHA1Final(ts->session_response, &ts->hash);
+ }
+ return i;
+}
+
+_TYPE( unsigned char * )
+t_serverresponse(ts)
+ struct t_server * ts;
+{
+ return ts->session_response;
+}
+
+_TYPE( void )
+t_serverclose(ts)
+ struct t_server * ts;
+{
+ memset(ts->bbuf, 0, sizeof(ts->bbuf));
+ memset(ts->vbuf, 0, sizeof(ts->vbuf));
+ memset(ts->saltbuf, 0, sizeof(ts->saltbuf));
+ memset(ts->session_key, 0, sizeof(ts->session_key));
+ free(ts);
+}
diff --git a/package/network/services/ead/src/tinysrp/.svn/text-base/t_server.h.svn-base b/package/network/services/ead/src/tinysrp/.svn/text-base/t_server.h.svn-base
new file mode 100644
index 0000000..20970ff
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/.svn/text-base/t_server.h.svn-base
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 1997-1999 The Stanford SRP Authentication Project
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF
+ * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * In addition, the following conditions apply:
+ *
+ * 1. Any software that incorporates the SRP authentication technology
+ * must display the following acknowlegment:
+ * "This product uses the 'Secure Remote Password' cryptographic
+ * authentication system developed by Tom Wu (tjw@CS.Stanford.EDU)."
+ *
+ * 2. Any software that incorporates all or part of the SRP distribution
+ * itself must also display the following acknowledgment:
+ * "This product includes software developed by Tom Wu and Eugene
+ * Jhong for the SRP Distribution (http://srp.stanford.edu/srp/)."
+ *
+ * 3. Redistributions in source or binary form must retain an intact copy
+ * of this copyright notice and list of conditions.
+ */
+
+#ifndef T_SERVER_H
+#define T_SERVER_H
+
+#include "t_sha.h"
+
+#if !defined(P)
+#ifdef __STDC__
+#define P(x) x
+#else
+#define P(x) ()
+#endif
+#endif
+
+#ifndef _DLLDECL
+#define _DLLDECL
+
+#ifdef MSVC15 /* MSVC1.5 support for 16 bit apps */
+#define _MSVC15EXPORT _export
+#define _MSVC20EXPORT
+#define _DLLAPI _export _pascal
+#define _TYPE(a) a _MSVC15EXPORT
+#define DLLEXPORT 1
+
+#elif MSVC20
+#define _MSVC15EXPORT
+#define _MSVC20EXPORT _declspec(dllexport)
+#define _DLLAPI
+#define _TYPE(a) _MSVC20EXPORT a
+#define DLLEXPORT 1
+
+#else /* Default, non-dll. Use this for Unix or DOS */
+#define _MSVC15DEXPORT
+#define _MSVC20EXPORT
+#define _DLLAPI
+#define _TYPE(a) a
+#endif
+#endif
+
+#define BLEN 32
+
+struct t_server {
+ int index;
+ struct t_num n;
+ struct t_num g;
+ struct t_num v;
+ struct t_num s;
+
+ struct t_num b;
+ struct t_num B;
+
+ SHA1_CTX oldhash, hash, oldckhash, ckhash;
+
+ unsigned char session_key[SESSION_KEY_LEN];
+ unsigned char session_response[RESPONSE_LEN];
+
+ unsigned char nbuf[MAXPARAMLEN], gbuf[MAXPARAMLEN], vbuf[MAXPARAMLEN];
+ unsigned char saltbuf[MAXSALTLEN], bbuf[BLEN], Bbuf[MAXPARAMLEN];
+};
+
+/*
+ * SRP server-side negotiation
+ *
+ * This code negotiates the server side of an SRP exchange.
+ * "t_serveropen" accepts a username (sent by the client), a pointer
+ * to an open password file, and a pointer to an open configuration
+ * file. The server should then call...
+ * "t_servergenexp" will generate a random 256-bit exponent and
+ * raise g (from the configuration file) to that power, returning
+ * the result. This result should be sent to the client as y(p).
+ * "t_servergetkey" accepts the exponential w(p), which should be
+ * sent by the client, and computes the 256-bit session key.
+ * This data should be saved before the session is closed.
+ * "t_serverresponse" computes the session key proof as SHA(w(p), K).
+ * "t_serverclose" closes the session and frees its memory.
+ *
+ * Note that authentication is not performed per se; it is up
+ * to either/both sides of the protocol to now verify securely
+ * that their session keys agree in order to establish authenticity.
+ * One possible way is through "oracle hashing"; one side sends
+ * r, the other replies with H(r,K), where H() is a hash function.
+ *
+ * t_serverresponse and t_serververify now implement a version of
+ * the session-key verification described above.
+ */
+_TYPE( struct t_server * )
+ t_serveropen P((const char *));
+_TYPE( struct t_server * )
+ t_serveropenfromfiles P((const char *, struct t_pw *, struct t_conf *));
+_TYPE( struct t_server * )
+ t_serveropenraw P((struct t_pwent *, struct t_confent *));
+_TYPE( struct t_num * ) t_servergenexp P((struct t_server *));
+_TYPE( unsigned char * ) t_servergetkey P((struct t_server *, struct t_num *));
+_TYPE( int ) t_serververify P((struct t_server *, unsigned char *));
+_TYPE( unsigned char * ) t_serverresponse P((struct t_server *));
+_TYPE( void ) t_serverclose P((struct t_server *));
+
+#endif
diff --git a/package/network/services/ead/src/tinysrp/.svn/text-base/t_sha.c.svn-base b/package/network/services/ead/src/tinysrp/.svn/text-base/t_sha.c.svn-base
new file mode 100644
index 0000000..cc41d64
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/.svn/text-base/t_sha.c.svn-base
@@ -0,0 +1,166 @@
+#include "t_defines.h"
+#include "t_sha.h"
+
+/*
+SHA-1 in C
+By Steve Reid <steve@edmweb.com>
+100% Public Domain
+
+Test Vectors (from FIPS PUB 180-1)
+"abc"
+ A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D
+"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
+ 84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1
+A million repetitions of "a"
+ 34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F
+*/
+
+/* #define WORDS_BIGENDIAN * This should be #define'd if true. */
+/* #define SHA1HANDSOFF * Copies data before messing with it. */
+
+#include <stdio.h>
+#include <string.h>
+
+static void SHA1Transform(uint32 state[5], const unsigned char buffer[64]);
+
+#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
+
+/* blk0() and blk() perform the initial expand. */
+/* I got the idea of expanding during the round function from SSLeay */
+#ifndef WORDS_BIGENDIAN
+#define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \
+ |(rol(block->l[i],8)&0x00FF00FF))
+#else
+#define blk0(i) block->l[i]
+#endif
+#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
+ ^block->l[(i+2)&15]^block->l[i&15],1))
+
+/* (R0+R1), R2, R3, R4 are the different operations used in SHA1 */
+#define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
+#define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30);
+#define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
+#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
+#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
+
+/* Hash a single 512-bit block. This is the core of the algorithm. */
+
+static void SHA1Transform(uint32 state[5], const unsigned char buffer[64])
+{
+uint32 a, b, c, d, e;
+typedef union {
+ unsigned char c[64];
+ uint32 l[16];
+} CHAR64LONG16;
+CHAR64LONG16* block;
+#ifdef SHA1HANDSOFF
+static unsigned char workspace[64];
+ block = (CHAR64LONG16*)workspace;
+ memcpy(block, buffer, 64);
+#else
+ block = (CHAR64LONG16*)buffer;
+#endif
+ /* Copy context->state[] to working vars */
+ a = state[0];
+ b = state[1];
+ c = state[2];
+ d = state[3];
+ e = state[4];
+ /* 4 rounds of 20 operations each. Loop unrolled. */
+ R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3);
+ R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7);
+ R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11);
+ R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15);
+ R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19);
+ R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23);
+ R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27);
+ R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31);
+ R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35);
+ R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39);
+ R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43);
+ R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47);
+ R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51);
+ R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55);
+ R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59);
+ R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63);
+ R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67);
+ R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71);
+ R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75);
+ R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79);
+ /* Add the working vars back into context.state[] */
+ state[0] += a;
+ state[1] += b;
+ state[2] += c;
+ state[3] += d;
+ state[4] += e;
+ /* Wipe variables */
+ a = b = c = d = e = 0;
+}
+
+
+/* SHA1Init - Initialize new context */
+
+void SHA1Init(SHA1_CTX* context)
+{
+ /* SHA1 initialization constants */
+ context->state[0] = 0x67452301;
+ context->state[1] = 0xEFCDAB89;
+ context->state[2] = 0x98BADCFE;
+ context->state[3] = 0x10325476;
+ context->state[4] = 0xC3D2E1F0;
+ context->count[0] = context->count[1] = 0;
+}
+
+
+/* Run your data through this. */
+
+void SHA1Update(SHA1_CTX* context, const unsigned char* data, unsigned int len)
+{
+unsigned int i, j;
+
+ j = (context->count[0] >> 3) & 63;
+ if ((context->count[0] += len << 3) < (len << 3)) context->count[1]++;
+ context->count[1] += (len >> 29);
+ if ((j + len) > 63) {
+ memcpy(&context->buffer[j], data, (i = 64-j));
+ SHA1Transform(context->state, context->buffer);
+ for ( ; i + 63 < len; i += 64) {
+ SHA1Transform(context->state, &data[i]);
+ }
+ j = 0;
+ }
+ else i = 0;
+ memcpy(&context->buffer[j], &data[i], len - i);
+}
+
+
+/* Add padding and return the message digest. */
+
+void SHA1Final(unsigned char digest[20], SHA1_CTX* context)
+{
+uint32 i, j;
+unsigned char finalcount[8];
+
+ for (i = 0; i < 8; i++) {
+ finalcount[i] = (unsigned char)((context->count[(i >= 4 ? 0 : 1)]
+ >> ((3-(i & 3)) * 8) ) & 255); /* Endian independent */
+ }
+ SHA1Update(context, (unsigned char *)"\200", 1);
+ while ((context->count[0] & 504) != 448) {
+ SHA1Update(context, (unsigned char *)"\0", 1);
+ }
+ SHA1Update(context, finalcount, 8); /* Should cause a SHA1Transform() */
+ for (i = 0; i < 20; i++) {
+ digest[i] = (unsigned char)
+ ((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255);
+ }
+ /* Wipe variables */
+ i = j = 0;
+ memset(context->buffer, 0, 64);
+ memset(context->state, 0, 20);
+ memset(context->count, 0, 8);
+ memset(&finalcount, 0, 8);
+#ifdef SHA1HANDSOFF /* make SHA1Transform overwrite its own static vars */
+ SHA1Transform(context->state, context->buffer);
+#endif
+}
diff --git a/package/network/services/ead/src/tinysrp/.svn/text-base/t_sha.h.svn-base b/package/network/services/ead/src/tinysrp/.svn/text-base/t_sha.h.svn-base
new file mode 100644
index 0000000..d10115e
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/.svn/text-base/t_sha.h.svn-base
@@ -0,0 +1,26 @@
+#ifndef T_SHA_H
+#define T_SHA_H
+
+#if !defined(P)
+#ifdef __STDC__
+#define P(x) x
+#else
+#define P(x) ()
+#endif
+#endif
+
+#define SHA_DIGESTSIZE 20
+
+typedef unsigned int uint32;
+
+typedef struct {
+ uint32 state[5];
+ uint32 count[2];
+ unsigned char buffer[64];
+} SHA1_CTX;
+
+void SHA1Init P((SHA1_CTX* context));
+void SHA1Update P((SHA1_CTX* context, const unsigned char* data, unsigned int len));
+void SHA1Final P((unsigned char digest[20], SHA1_CTX* context));
+
+#endif /* T_SHA_H */
diff --git a/package/network/services/ead/src/tinysrp/.svn/text-base/t_truerand.c.svn-base b/package/network/services/ead/src/tinysrp/.svn/text-base/t_truerand.c.svn-base
new file mode 100644
index 0000000..fa0d6ce
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/.svn/text-base/t_truerand.c.svn-base
@@ -0,0 +1,151 @@
+/*
+ * Physically random numbers (very nearly uniform)
+ * D. P. Mitchell
+ * Modified by Matt Blaze 7/95
+ */
+/*
+ * The authors of this software are Don Mitchell and Matt Blaze.
+ * Copyright (c) 1995 by AT&T.
+ * Permission to use, copy, and modify this software without fee
+ * is hereby granted, provided that this entire notice is included in
+ * all copies of any software which is or includes a copy or
+ * modification of this software and in all copies of the supporting
+ * documentation for such software.
+ *
+ * This software may be subject to United States export controls.
+ *
+ * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR AT&T MAKE ANY
+ * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
+ * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
+ */
+
+/*
+ * WARNING: depending on the particular platform, raw_truerand()
+ * output may be biased or correlated. In general, you can expect
+ * about 16 bits of "pseudo-entropy" out of each 32 bit word returned
+ * by truerand(), but it may not be uniformly diffused. You should
+ * raw_therefore run the output through some post-whitening function
+ * (like MD5 or DES or whatever) before using it to generate key
+ * material. (RSAREF's random package does this for you when you feed
+ * raw_truerand() bits to the seed input function.)
+ *
+ * The application interface, for 8, 16, and 32 bit properly "whitened"
+ * random numbers, can be found in trand8(), trand16(), and trand32().
+ * Use those instead of calling raw_truerand() directly.
+ *
+ * The basic idea here is that between clock "skew" and various
+ * hard-to-predict OS event arrivals, counting a tight loop will yield
+ * a little (maybe a third of a bit or so) of "good" randomness per
+ * interval clock tick. This seems to work well even on unloaded
+ * machines. If there is a human operator at the machine, you should
+ * augment truerand with other measure, like keyboard event timing.
+ * On server machines (e.g., when you need to generate a
+ * Diffie-Hellman secret) truerand alone may be good enough.
+ *
+ * Test these assumptions on your own platform before fielding a
+ * system based on this software or these techniques.
+ *
+ * This software seems to work well (at 10 or so bits per
+ * raw_truerand() call) on a Sun Sparc-20 under SunOS 4.1.3 and on a
+ * P100 under BSDI 2.0. You're on your own elsewhere.
+ *
+ */
+
+#include "t_defines.h"
+
+#include <signal.h>
+#include <setjmp.h>
+#include <sys/time.h>
+#include <math.h>
+#include <stdio.h>
+
+#ifdef OLD_TRUERAND
+static jmp_buf env;
+#endif
+static unsigned volatile count
+#ifndef OLD_TRUERAND
+ , done = 0
+#endif
+;
+
+static unsigned ocount;
+static unsigned buffer;
+
+static void
+tick()
+{
+ struct itimerval it, oit;
+
+ it.it_interval.tv_sec = 0;
+ it.it_interval.tv_usec = 0;
+ it.it_value.tv_sec = 0;
+ it.it_value.tv_usec = 16665;
+ if (setitimer(ITIMER_REAL, &it, &oit) < 0)
+ perror("tick");
+}
+
+static void
+interrupt()
+{
+ if (count) {
+#ifdef OLD_TRUERAND
+ longjmp(env, 1);
+#else
+ ++done;
+ return;
+#endif
+ }
+
+ (void) signal(SIGALRM, interrupt);
+ tick();
+}
+
+static unsigned long
+roulette()
+{
+#ifdef OLD_TRUERAND
+ if (setjmp(env)) {
+ count ^= (count>>3) ^ (count>>6) ^ ocount;
+ count &= 0x7;
+ ocount=count;
+ buffer = (buffer<<3) ^ count;
+ return buffer;
+ }
+#else
+ done = 0;
+#endif
+ (void) signal(SIGALRM, interrupt);
+ count = 0;
+ tick();
+#ifdef OLD_TRUERAND
+ for (;;)
+#else
+ while(done == 0)
+#endif
+ count++; /* about 1 MHz on VAX 11/780 */
+#ifndef OLD_TRUERAND
+ count ^= (count>>3) ^ (count>>6) ^ ocount;
+ count &= 0x7;
+ ocount=count;
+ buffer = (buffer<<3) ^ count;
+ return buffer;
+#endif
+}
+
+unsigned long
+raw_truerand()
+{
+ count=0;
+ (void) roulette();
+ (void) roulette();
+ (void) roulette();
+ (void) roulette();
+ (void) roulette();
+ (void) roulette();
+ (void) roulette();
+ (void) roulette();
+ (void) roulette();
+ (void) roulette();
+ return roulette();
+}
diff --git a/package/network/services/ead/src/tinysrp/.svn/text-base/tconf.c.svn-base b/package/network/services/ead/src/tinysrp/.svn/text-base/tconf.c.svn-base
new file mode 100644
index 0000000..ad77f4c
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/.svn/text-base/tconf.c.svn-base
@@ -0,0 +1,157 @@
+/*
+ * Copyright (c) 1997-2000 The Stanford SRP Authentication Project
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF
+ * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * In addition, the following conditions apply:
+ *
+ * 1. Any software that incorporates the SRP authentication technology
+ * must display the following acknowlegment:
+ * "This product uses the 'Secure Remote Password' cryptographic
+ * authentication system developed by Tom Wu (tjw@CS.Stanford.EDU)."
+ *
+ * 2. Any software that incorporates all or part of the SRP distribution
+ * itself must also display the following acknowledgment:
+ * "This product includes software developed by Tom Wu and Eugene
+ * Jhong for the SRP Distribution (http://srp.stanford.edu/srp/)."
+ *
+ * 3. Redistributions in source or binary form must retain an intact copy
+ * of this copyright notice and list of conditions.
+ */
+
+#include <unistd.h> /* close getlogin */
+#include <stdlib.h> /* atexit exit */
+#include <stdio.h>
+#include <string.h>
+
+#include "t_pwd.h"
+
+#define MIN_BASIS_BITS 512
+#define BASIS_BITS 2048
+
+extern int optind;
+extern char *optarg;
+
+extern int errno;
+
+char *progName;
+
+int debug = 0;
+int verbose = 0;
+int composite = 0;
+
+int main(argc, argv)
+ int argc;
+ char *argv[];
+{
+ char *chp;
+ char *configFile = NULL;
+ char cbuf[256];
+ char b64buf[MAXB64PARAMLEN];
+ int c, ch, i, lastidx, keylen, yesno, fsize, status, nparams;
+ FILE *efp;
+
+ struct t_preconf * tpc;
+ struct t_conf tcs;
+ struct t_conf * tc = &tcs;
+ struct t_confent * tcent;
+
+ progName = *argv;
+ if ((chp = strrchr(progName, '/')) != (char *) 0) progName = chp + 1;
+
+ while ((ch = getopt(argc, argv, "dv2c:")) != EOF)
+ switch(ch) {
+ case 'c':
+ configFile = optarg;
+ break;
+ case 'v':
+ verbose++;
+ break;
+ case 'd':
+ debug++;
+ break;
+ case '2':
+ composite++;
+ break;
+ default:
+ fprintf(stderr, "usage: %s [-dv2] [-c configfile]\n", progName);
+ exit(1);
+ }
+
+ argc -= optind;
+ argv += optind;
+
+ lastidx = 0;
+ keylen = 0;
+
+ tcent = t_newconfent(tc);
+
+ printf("\nThis program will generate a set of parameters for the EPS\n");
+ printf("password file. The size of these parameters, measured in bits,\n");
+ printf("determines the level of security offered by SRP, and is related\n");
+ printf("to the security of similarly-sized RSA or Diffie-Hellman keys.\n");
+ printf("Choosing a predefined field is generally preferable to generating\n");
+ printf("a new field because clients can avoid costly parameter verification.\n");
+ printf("Either way, the values generated by this program are public and\n");
+ printf("can even shared between systems.\n");
+
+ printf("\nEnter the new field size, in bits. Suggested sizes:\n\n");
+ printf(" 512 (fast, minimally secure)\n");
+ printf(" 768 (moderate security)\n");
+ printf("1024 (most popular default)\n");
+ printf("1536 (additional security, possibly slow)\n");
+ printf("2048 (maximum supported security level)\n");
+ printf("\nField size (%d to %d): ", MIN_BASIS_BITS, BASIS_BITS);
+
+ fgets(cbuf, sizeof(cbuf), stdin);
+ fsize = atoi(cbuf);
+ if(fsize < MIN_BASIS_BITS || fsize > BASIS_BITS) {
+ fprintf(stderr, "%s: field size must be between %d and %d\n",
+ progName, MIN_BASIS_BITS, BASIS_BITS);
+ exit(1);
+ }
+
+ if(fsize <= keylen)
+ fprintf(stderr, "Warning: new field size is not larger than old field size\n");
+
+ printf("\nInitializing random number generator...");
+ fflush(stdout);
+ t_initrand();
+
+ if(composite)
+ printf("done.\n\nGenerating a %d-bit composite with safe prime factors. This may take a while.\n", fsize);
+ else
+ printf("done.\n\nGenerating a %d-bit safe prime. This may take a while.\n", fsize);
+
+ while((tcent = (composite ? t_makeconfent_c(tc, fsize) :
+ t_makeconfent(tc, fsize))) == NULL)
+ printf("Parameter generation failed, retrying...\n");
+ tcent->index = lastidx + 1;
+
+ printf("\nParameters successfully generated.\n");
+ printf("N = [%s]\n", t_tob64(b64buf,
+ tcent->modulus.data, tcent->modulus.len));
+ printf("g = [%s]\n", t_tob64(b64buf,
+ tcent->generator.data, tcent->generator.len));
+ printf("\nYou must update the pre_params array in t_getconf.c\n");
+}
diff --git a/package/network/services/ead/src/tinysrp/.svn/text-base/tinysrp.c.svn-base b/package/network/services/ead/src/tinysrp/.svn/text-base/tinysrp.c.svn-base
new file mode 100644
index 0000000..fc01055
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/.svn/text-base/tinysrp.c.svn-base
@@ -0,0 +1,235 @@
+/* This bit implements a simple API for using the SRP library over sockets. */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include "t_defines.h"
+#include "t_pwd.h"
+#include "t_server.h"
+#include "t_client.h"
+#include "tinysrp.h"
+
+#ifndef MSG_WAITALL
+#ifdef linux
+#define MSG_WAITALL 0x100 /* somehow not defined on my box */
+#endif
+#endif
+
+/* This is called by the client with a connected socket, username, and
+passphrase. pass can be NULL in which case the user is queried. */
+
+int tsrp_client_authenticate(int s, char *user, char *pass, TSRP_SESSION *tsrp)
+{
+ int i, index;
+ unsigned char username[MAXUSERLEN + 1], sbuf[MAXSALTLEN];
+ unsigned char msgbuf[MAXPARAMLEN + 1], bbuf[MAXPARAMLEN];
+ unsigned char passbuf[128], *skey;
+ struct t_client *tc;
+ struct t_preconf *tcp; /* @@@ should go away */
+ struct t_num salt, *A, B;
+
+ /* Send the username. */
+
+ i = strlen(user);
+ if (i > MAXUSERLEN) {
+ i = MAXUSERLEN;
+ }
+ msgbuf[0] = i;
+ memcpy(msgbuf + 1, user, i);
+ if (send(s, msgbuf, i + 1, 0) < 0) {
+ return 0;
+ }
+ memcpy(username, user, i);
+ username[i] = '\0';
+
+ /* Get the prime index and salt. */
+
+ i = recv(s, msgbuf, 2, MSG_WAITALL);
+ if (i <= 0) {
+ return 0;
+ }
+ index = msgbuf[0];
+ if (index <= 0 || index > t_getprecount()) {
+ return 0;
+ }
+ tcp = t_getpreparam(index - 1);
+ salt.len = msgbuf[1];
+ if (salt.len > MAXSALTLEN) {
+ return 0;
+ }
+ salt.data = sbuf;
+ i = recv(s, sbuf, salt.len, MSG_WAITALL);
+ if (i <= 0) {
+ return 0;
+ }
+
+ /* @@@ t_clientopen() needs a variant that takes the index */
+
+ tc = t_clientopen(username, &tcp->modulus, &tcp->generator, &salt);
+ if (tc == NULL) {
+ return 0;
+ }
+
+ /* Calculate A and send it to the server. */
+
+ A = t_clientgenexp(tc);
+ msgbuf[0] = A->len - 1; /* len is max 256 */
+ memcpy(msgbuf + 1, A->data, A->len);
+ if (send(s, msgbuf, A->len + 1, 0) < 0) {
+ return 0;
+ }
+
+ /* Ask the user for the passphrase. */
+
+ if (pass == NULL) {
+ t_getpass(passbuf, sizeof(passbuf), "Enter password:");
+ pass = passbuf;
+ }
+ t_clientpasswd(tc, pass);
+
+ /* Get B from the server. */
+
+ i = recv(s, msgbuf, 1, 0);
+ if (i <= 0) {
+ return 0;
+ }
+ B.len = msgbuf[0] + 1;
+ B.data = bbuf;
+ i = recv(s, bbuf, B.len, MSG_WAITALL);
+ if (i <= 0) {
+ return 0;
+ }
+
+ /* Compute the session key. */
+
+ skey = t_clientgetkey(tc, &B);
+ if (skey == NULL) {
+ return 0;
+ }
+
+ /* Send the response. */
+
+ if (send(s, t_clientresponse(tc), RESPONSE_LEN, 0) < 0) {
+ return 0;
+ }
+
+ /* Get the server's response. */
+
+ i = recv(s, msgbuf, RESPONSE_LEN, MSG_WAITALL);
+ if (i <= 0) {
+ return 0;
+ }
+ if (t_clientverify(tc, msgbuf) != 0) {
+ return 0;
+ }
+
+ /* All done. Now copy the key and clean up. */
+
+ if (tsrp) {
+ memcpy(tsrp->username, username, strlen(username) + 1);
+ memcpy(tsrp->key, skey, SESSION_KEY_LEN);
+ }
+ t_clientclose(tc);
+
+ return 1;
+}
+
+/* This is called by the server with a connected socket. */
+
+int tsrp_server_authenticate(int s, TSRP_SESSION *tsrp)
+{
+ int i, j;
+ unsigned char username[MAXUSERLEN], *skey;
+ unsigned char msgbuf[MAXPARAMLEN + 1], abuf[MAXPARAMLEN];
+ struct t_server *ts;
+ struct t_num A, *B;
+
+ /* Get the username. */
+
+ i = recv(s, msgbuf, 1, 0);
+ if (i <= 0) {
+ return 0;
+ }
+ j = msgbuf[0];
+ i = recv(s, username, j, MSG_WAITALL);
+ if (i <= 0) {
+ return 0;
+ }
+ username[j] = '\0';
+
+ ts = t_serveropen(username);
+ if (ts == NULL) {
+ return 0;
+ }
+
+ /* Send the prime index and the salt. */
+
+ msgbuf[0] = ts->index; /* max 256 primes... */
+ i = ts->s.len;
+ msgbuf[1] = i;
+ memcpy(msgbuf + 2, ts->s.data, i);
+ if (send(s, msgbuf, i + 2, 0) < 0) {
+ return 0;
+ }
+
+ /* Calculate B while we're waiting. */
+
+ B = t_servergenexp(ts);
+
+ /* Get A from the client. */
+
+ i = recv(s, msgbuf, 1, 0);
+ if (i <= 0) {
+ return 0;
+ }
+ A.len = msgbuf[0] + 1;
+ A.data = abuf;
+ i = recv(s, abuf, A.len, MSG_WAITALL);
+ if (i <= 0) {
+ return 0;
+ }
+
+ /* Now send B. */
+
+ msgbuf[0] = B->len - 1;
+ memcpy(msgbuf + 1, B->data, B->len);
+ if (send(s, msgbuf, B->len + 1, 0) < 0) {
+ return 0;
+ }
+
+ /* Calculate the session key while we're waiting. */
+
+ skey = t_servergetkey(ts, &A);
+ if (skey == NULL) {
+ return 0;
+ }
+
+ /* Get the response from the client. */
+
+ i = recv(s, msgbuf, RESPONSE_LEN, MSG_WAITALL);
+ if (i <= 0) {
+ return 0;
+ }
+ if (t_serververify(ts, msgbuf) != 0) {
+ return 0;
+ }
+
+ /* Client authenticated. Now authenticate ourselves to the client. */
+
+ if (send(s, t_serverresponse(ts), RESPONSE_LEN, 0) < 0) {
+ return 0;
+ }
+
+ /* Copy the key and clean up. */
+
+ if (tsrp) {
+ memcpy(tsrp->username, username, strlen(username) + 1);
+ memcpy(tsrp->key, skey, SESSION_KEY_LEN);
+ }
+ t_serverclose(ts);
+
+ return 1;
+}
diff --git a/package/network/services/ead/src/tinysrp/.svn/text-base/tinysrp.h.svn-base b/package/network/services/ead/src/tinysrp/.svn/text-base/tinysrp.h.svn-base
new file mode 100644
index 0000000..4420a19
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/.svn/text-base/tinysrp.h.svn-base
@@ -0,0 +1,18 @@
+/* Simple API for the tinysrp library. */
+
+#ifndef T_PWD_H
+#define MAXUSERLEN 32
+#define SESSION_KEY_LEN 40 /* 320-bit session key */
+#endif
+
+typedef struct {
+ char username[MAXUSERLEN + 1];
+ unsigned char key[SESSION_KEY_LEN];
+} TSRP_SESSION;
+
+/* These functions are passed a connected socket, and return true for a
+successful authentication. If tsrp is not NULL, the username and key
+fields are filled in. */
+
+extern int tsrp_server_authenticate(int s, TSRP_SESSION *tsrp);
+extern int tsrp_client_authenticate(int s, char *user, char *pass, TSRP_SESSION *tsrp);
diff --git a/package/network/services/ead/src/tinysrp/.svn/text-base/tpasswd.svn-base b/package/network/services/ead/src/tinysrp/.svn/text-base/tpasswd.svn-base
new file mode 100644
index 0000000..2ac7e2a
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/.svn/text-base/tpasswd.svn-base
@@ -0,0 +1,2 @@
+moo:A9lHvOGAMJvw1m3vcDsQRUFovh6/QUmLDKqwhv.drKQzbE9nS7HrOZLUPx2MmS6ewwybN8RHqpWqnUJRCMFT14FMbYXR7kYNUUQNx43A7F.xrVOU7tlFq5NjoK9sfFtp6PMdbIOP5wzWmipiNFlCOu4sjlSZb.o7C1chLzTKU.0:19AI0Hc9jEkdFc:5
+new user:1FsanML2fbTOEsa072bLjyRD1LEqoRD2GwElfN0VmHeR.FAg5A.2.G5bTjIHmMmHL60kgoAHJZhRrgopalYmujlyAuQoKiHJb98SHm1oJaQ9nl/DrZCvfyw5LpVMqg.CupdiWz6OtmOz8fwC96ItExFnNDt6SmsVDIOn4HqXG6C0lLaqEvcqlN3gFDlJXyP2yldM.LJ1TkHTHmA3DjRkmWEUL3mWEgzkEHyPcRB3Jd5ncDT7jaNbJTTLRoOtgRsaqE7OXuPADoK8MGBcUquYBRrGwyU4Y/wW4gLc3QmV793zxkk.P3.dxkLSjro/Kk94D7kC6fx3K9tadLJyzd94rr:3v/KRlxT0.oYF1:1
diff --git a/package/network/services/ead/src/tinysrp/.svn/text-base/tphrase.c.svn-base b/package/network/services/ead/src/tinysrp/.svn/text-base/tphrase.c.svn-base
new file mode 100644
index 0000000..1aede0c
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/.svn/text-base/tphrase.c.svn-base
@@ -0,0 +1,348 @@
+/* Add passphrases to the tpasswd file. Use the last entry in the config
+file by default or a particular one specified by index. */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include "config.h"
+#include "t_pwd.h"
+#include "t_read.h"
+#include "t_sha.h"
+#include "t_defines.h"
+
+char *Progname;
+char Usage[] = "usage: %s [-n configindex] [-p passfile] user\n";
+#define USAGE() fprintf(stderr, Usage, Progname)
+
+void doit(char *);
+
+int Configindex = -1;
+char *Passfile = DEFAULT_PASSWD;
+
+int main(int argc, char **argv)
+{
+ int c;
+
+ Progname = *argv;
+
+ /* Parse option arguments. */
+
+ while ((c = getopt(argc, argv, "n:p:")) != EOF) {
+ switch (c) {
+
+ case 'n':
+ Configindex = atoi(optarg);
+ break;
+
+ case 'p':
+ Passfile = optarg;
+ break;
+
+ default:
+ USAGE();
+ exit(1);
+ }
+ }
+ argc -= optind;
+ argv += optind;
+
+ if (argc != 1) {
+ USAGE();
+ exit(1);
+ }
+ doit(argv[0]);
+
+ return 0;
+}
+
+void doit(char *name)
+{
+ char passphrase[128], passphrase1[128];
+ FILE *f;
+ struct t_conf *tc;
+ struct t_confent *tcent;
+ struct t_pw eps_passwd;
+
+ /* Get the config entry. */
+
+ if (Configindex <= 0) {
+ Configindex = t_getprecount();
+ }
+ tcent = gettcid(Configindex);
+ if (tcent == NULL) {
+ fprintf(stderr, "Invalid configuration file entry.\n");
+ exit(1);
+ }
+
+ /* Ask for the passphrase twice. */
+
+ printf("Setting passphrase for %s\n", name);
+
+ if (t_getpass(passphrase, sizeof(passphrase), "Enter passphrase: ") < 0) {
+ exit(1);
+ }
+ if (t_getpass(passphrase1, sizeof(passphrase1), "Verify: ") < 0) {
+ exit(1);
+ }
+ if (strcmp(passphrase, passphrase1) != 0) {
+ fprintf(stderr, "mismatch\n");
+ exit(1);
+ }
+
+ /* Create the passphrase verifier. */
+
+ t_makepwent(&eps_passwd, name, passphrase, NULL, tcent);
+
+ /* Don't need these anymore. */
+
+ memset(passphrase, 0, sizeof(passphrase));
+ memset(passphrase1, 0, sizeof(passphrase1));
+
+ /* See if the passphrase file is there; create it if not. */
+
+ if ((f = fopen(Passfile, "r+")) == NULL) {
+ creat(Passfile, 0400);
+ } else {
+ fclose(f);
+ }
+
+ /* Change the passphrase. */
+
+ if (t_changepw(Passfile, &eps_passwd.pebuf) < 0) {
+ fprintf(stderr, "Error changing passphrase\n");
+ exit(1);
+ }
+}
+
+/* TODO: Implement a more general method to handle delete/change */
+
+_TYPE( int )
+t_changepw(pwname, diff)
+ const char * pwname;
+ const struct t_pwent * diff;
+{
+ char * bakfile;
+ char * bakfile2;
+ struct stat st;
+ FILE * passfp;
+ FILE * bakfp;
+
+ if(pwname == NULL)
+ pwname = DEFAULT_PASSWD;
+
+ if((passfp = fopen(pwname, "rb")) == NULL || fstat(fileno(passfp), &st) < 0)
+ return -1;
+
+ if((bakfile = malloc(strlen(pwname) + 5)) == NULL) {
+ fclose(passfp);
+ return -1;
+ }
+ else if((bakfile2 = malloc(strlen(pwname) + 5)) == NULL) {
+ fclose(passfp);
+ free(bakfile);
+ return -1;
+ }
+
+ sprintf(bakfile, "%s.bak", pwname);
+ sprintf(bakfile2, "%s.sav", pwname);
+
+ if((bakfp = fopen(bakfile2, "wb")) == NULL &&
+ (unlink(bakfile2) < 0 || (bakfp = fopen(bakfile2, "wb")) == NULL)) {
+ fclose(passfp);
+ fclose(bakfp);
+ return -1;
+ }
+
+#ifdef NO_FCHMOD
+ chmod(bakfile2, st.st_mode & 0777);
+#else
+ fchmod(fileno(bakfp), st.st_mode & 0777);
+#endif
+
+ t_pwcopy(bakfp, passfp, diff);
+
+ fclose(bakfp);
+ fclose(passfp);
+
+#ifdef USE_RENAME
+ unlink(bakfile);
+ if(rename(pwname, bakfile) < 0)
+ return -1;
+ if(rename(bakfile2, pwname) < 0)
+ return -1;
+#else
+ unlink(bakfile);
+ link(pwname, bakfile);
+ unlink(pwname);
+ link(bakfile2, pwname);
+ unlink(bakfile2);
+#endif
+ free(bakfile);
+ free(bakfile2);
+
+ return 0;
+}
+
+_TYPE( struct t_pwent * )
+t_makepwent(tpw, user, pass, salt, confent)
+ struct t_pw * tpw;
+ const char * user;
+ const char * pass;
+ const struct t_num * salt;
+ const struct t_confent * confent;
+{
+ BigInteger x, v, n, g;
+ unsigned char dig[SHA_DIGESTSIZE];
+ SHA1_CTX ctxt;
+
+ tpw->pebuf.name = tpw->userbuf;
+ tpw->pebuf.password.data = tpw->pwbuf;
+ tpw->pebuf.salt.data = tpw->saltbuf;
+
+ strncpy(tpw->pebuf.name, user, MAXUSERLEN);
+ tpw->pebuf.index = confent->index;
+
+ if(salt) {
+ tpw->pebuf.salt.len = salt->len;
+ memcpy(tpw->pebuf.salt.data, salt->data, salt->len);
+ }
+ else {
+ memset(dig, 0, SALTLEN); /* salt is 80 bits */
+ tpw->pebuf.salt.len = SALTLEN;
+ do {
+ t_random(tpw->pebuf.salt.data, SALTLEN);
+ } while(memcmp(tpw->pebuf.salt.data, dig, SALTLEN) == 0);
+ if(tpw->pebuf.salt.data[0] == 0)
+ tpw->pebuf.salt.data[0] = 0xff;
+ }
+
+ n = BigIntegerFromBytes(confent->modulus.data, confent->modulus.len);
+ g = BigIntegerFromBytes(confent->generator.data, confent->generator.len);
+ v = BigIntegerFromInt(0);
+
+ SHA1Init(&ctxt);
+ SHA1Update(&ctxt, user, strlen(user));
+ SHA1Update(&ctxt, ":", 1);
+ SHA1Update(&ctxt, pass, strlen(pass));
+ SHA1Final(dig, &ctxt);
+
+ SHA1Init(&ctxt);
+ SHA1Update(&ctxt, tpw->pebuf.salt.data, tpw->pebuf.salt.len);
+ SHA1Update(&ctxt, dig, sizeof(dig));
+ SHA1Final(dig, &ctxt);
+
+ /* x = H(s, H(u, ':', p)) */
+ x = BigIntegerFromBytes(dig, sizeof(dig));
+
+ BigIntegerModExp(v, g, x, n);
+ tpw->pebuf.password.len = BigIntegerToBytes(v, tpw->pebuf.password.data);
+
+ BigIntegerFree(v);
+ BigIntegerFree(x);
+ BigIntegerFree(g);
+ BigIntegerFree(n);
+
+ return &tpw->pebuf;
+}
+
+int
+t_pwcopy(pwdest, pwsrc, diff)
+ FILE * pwdest;
+ FILE * pwsrc;
+ struct t_pwent * diff;
+{
+ struct t_pw * src;
+ struct t_pwent * ent;
+
+ if((src = t_openpw(pwsrc)) == NULL)
+ return -1;
+
+ while((ent = t_getpwent(src)) != NULL)
+ if(diff && strcmp(diff->name, ent->name) == 0) {
+ t_putpwent(diff, pwdest);
+ diff = NULL;
+ }
+ else
+ t_putpwent(ent, pwdest);
+
+ if(diff)
+ t_putpwent(diff, pwdest);
+
+ return 0;
+}
+
+_TYPE( struct t_pwent * )
+t_getpwent(tpw)
+ struct t_pw * tpw;
+{
+ char indexbuf[16];
+ char passbuf[MAXB64PARAMLEN];
+ char saltstr[MAXB64SALTLEN];
+
+#ifdef ENABLE_YP
+ struct t_passwd * nisent;
+ /* FIXME: should tell caller to get conf entry from NIS also */
+
+ if(tpw->state == IN_NIS) {
+ nisent = _yp_gettpent();
+ if(nisent != NULL) {
+ savepwent(tpw, &nisent->tp);
+ return &tpw->pebuf;
+ }
+ tpw->state = FILE_NIS;
+ }
+#endif
+
+ while(1) {
+ if(t_nextfield(tpw->instream, tpw->userbuf, MAXUSERLEN) > 0) {
+#ifdef ENABLE_YP
+ if(tpw->state == FILE_NIS && *tpw->userbuf == '+') {
+ t_nextline(tpw->instream);
+ if(strlen(tpw->userbuf) > 1) { /* +name:... */
+ nisent = _yp_gettpnam(tpw->userbuf + 1);
+ if(nisent != NULL) {
+ savepwent(tpw, nisent);
+ return &tpw->pebuf;
+ }
+ }
+ else { /* +:... */
+ tpw->state = IN_NIS;
+ _yp_settpent();
+ return t_getpwent(tpw);
+ }
+ }
+#endif
+ if(t_nextfield(tpw->instream, passbuf, MAXB64PARAMLEN) > 0 &&
+ (tpw->pebuf.password.len = t_fromb64(tpw->pwbuf, passbuf)) > 0 &&
+ t_nextfield(tpw->instream, saltstr, MAXB64SALTLEN) > 0 &&
+ (tpw->pebuf.salt.len = t_fromb64(tpw->saltbuf, saltstr)) > 0 &&
+ t_nextfield(tpw->instream, indexbuf, 16) > 0 &&
+ (tpw->pebuf.index = atoi(indexbuf)) > 0) {
+ tpw->pebuf.name = tpw->userbuf;
+ tpw->pebuf.password.data = tpw->pwbuf;
+ tpw->pebuf.salt.data = tpw->saltbuf;
+ t_nextline(tpw->instream);
+ return &tpw->pebuf;
+ }
+ }
+ if(t_nextline(tpw->instream) < 0)
+ return NULL;
+ }
+}
+
+_TYPE( void )
+t_putpwent(ent, fp)
+ const struct t_pwent * ent;
+ FILE * fp;
+{
+ char strbuf[MAXB64PARAMLEN];
+ char saltbuf[MAXB64SALTLEN];
+
+ fprintf(fp, "%s:%s:%s:%d\n", ent->name,
+ t_tob64(strbuf, ent->password.data, ent->password.len),
+ t_tob64(saltbuf, ent->salt.data, ent->salt.len), ent->index);
+}
+
diff --git a/package/network/services/ead/src/tinysrp/Makefile.am b/package/network/services/ead/src/tinysrp/Makefile.am
new file mode 100644
index 0000000..a8f899f
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/Makefile.am
@@ -0,0 +1,28 @@
+AUTOMAKE_OPTIONS = foreign no-dependencies
+
+noinst_HEADERS = t_client.h t_pwd.h t_server.h t_sha.h \
+ bn.h bn_lcl.h bn_prime.h t_defines.h t_read.h
+
+include_HEADERS = tinysrp.h
+
+lib_LIBRARIES = libtinysrp.a
+
+CFLAGS = -O2 @signed@
+
+libtinysrp_a_SOURCES = \
+ tinysrp.c t_client.c t_getconf.c t_conv.c t_getpass.c t_sha.c t_math.c \
+ t_misc.c t_pw.c t_read.c t_server.c t_truerand.c \
+ bn_add.c bn_ctx.c bn_div.c bn_exp.c bn_mul.c bn_word.c bn_asm.c bn_lib.c \
+ bn_shift.c bn_sqr.c
+
+noinst_PROGRAMS = srvtest clitest
+srvtest_SOURCES = srvtest.c
+clitest_SOURCES = clitest.c
+
+bin_PROGRAMS = tconf tphrase
+tconf_SOURCES = tconf.c t_conf.c
+tphrase_SOURCES = tphrase.c
+
+LDADD = libtinysrp.a
+
+EXTRA_DIST = tpasswd Notes
diff --git a/package/network/services/ead/src/tinysrp/Makefile.in b/package/network/services/ead/src/tinysrp/Makefile.in
new file mode 100644
index 0000000..4701cd5
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/Makefile.in
@@ -0,0 +1,477 @@
+# Makefile.in generated automatically by automake 1.4a from Makefile.am
+
+# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+
+SHELL = @SHELL@
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+
+bindir = @bindir@
+sbindir = @sbindir@
+libexecdir = @libexecdir@
+datadir = @datadir@
+sysconfdir = @sysconfdir@
+sharedstatedir = @sharedstatedir@
+localstatedir = @localstatedir@
+libdir = @libdir@
+infodir = @infodir@
+mandir = @mandir@
+includedir = @includedir@
+oldincludedir = /usr/include
+
+DESTDIR =
+
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+
+top_builddir = .
+
+ACLOCAL = @ACLOCAL@
+AUTOCONF = @AUTOCONF@
+AUTOMAKE = @AUTOMAKE@
+AUTOHEADER = @AUTOHEADER@
+
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_FLAG =
+transform = @program_transform_name@
+
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+CC = @CC@
+LN_S = @LN_S@
+MAKEINFO = @MAKEINFO@
+PACKAGE = @PACKAGE@
+RANLIB = @RANLIB@
+VERSION = @VERSION@
+signed = @signed@
+
+AUTOMAKE_OPTIONS = foreign no-dependencies
+
+noinst_HEADERS = t_client.h t_pwd.h t_server.h t_sha.h bn.h bn_lcl.h bn_prime.h t_defines.h t_read.h
+
+
+include_HEADERS = tinysrp.h
+
+lib_LIBRARIES = libtinysrp.a
+
+CFLAGS = -O2 @signed@
+
+libtinysrp_a_SOURCES = tinysrp.c t_client.c t_getconf.c t_conv.c t_getpass.c t_sha.c t_math.c t_misc.c t_pw.c t_read.c t_server.c t_truerand.c bn_add.c bn_ctx.c bn_div.c bn_exp.c bn_mul.c bn_word.c bn_asm.c bn_lib.c bn_shift.c bn_sqr.c
+
+
+noinst_PROGRAMS = srvtest clitest
+srvtest_SOURCES = srvtest.c
+clitest_SOURCES = clitest.c
+
+bin_PROGRAMS = tconf tphrase
+tconf_SOURCES = tconf.c t_conf.c
+tphrase_SOURCES = tphrase.c
+
+LDADD = libtinysrp.a
+
+EXTRA_DIST = tpasswd Notes
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = config.h
+CONFIG_CLEAN_FILES =
+LIBRARIES = $(lib_LIBRARIES)
+
+
+DEFS = @DEFS@ -I. -I$(srcdir) -I.
+CPPFLAGS = @CPPFLAGS@
+LDFLAGS = @LDFLAGS@
+LIBS = @LIBS@
+libtinysrp_a_LIBADD =
+libtinysrp_a_OBJECTS = tinysrp.o t_client.o t_getconf.o t_conv.o \
+t_getpass.o t_sha.o t_math.o t_misc.o t_pw.o t_read.o t_server.o \
+t_truerand.o bn_add.o bn_ctx.o bn_div.o bn_exp.o bn_mul.o bn_word.o \
+bn_asm.o bn_lib.o bn_shift.o bn_sqr.o
+AR = ar
+PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS)
+
+tconf_OBJECTS = tconf.o t_conf.o
+tconf_LDADD = $(LDADD)
+tconf_DEPENDENCIES = libtinysrp.a
+tconf_LDFLAGS =
+tphrase_OBJECTS = tphrase.o
+tphrase_LDADD = $(LDADD)
+tphrase_DEPENDENCIES = libtinysrp.a
+tphrase_LDFLAGS =
+srvtest_OBJECTS = srvtest.o
+srvtest_LDADD = $(LDADD)
+srvtest_DEPENDENCIES = libtinysrp.a
+srvtest_LDFLAGS =
+clitest_OBJECTS = clitest.o
+clitest_LDADD = $(LDADD)
+clitest_DEPENDENCIES = libtinysrp.a
+clitest_LDFLAGS =
+COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
+HEADERS = $(include_HEADERS) $(noinst_HEADERS)
+
+DIST_COMMON = ./stamp-h.in Makefile.am Makefile.in acconfig.h \
+acinclude.m4 aclocal.m4 config.h.in configure configure.in install-sh \
+missing mkinstalldirs
+
+
+DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
+
+TAR = gtar
+GZIP_ENV = --best
+SOURCES = $(libtinysrp_a_SOURCES) $(tconf_SOURCES) $(tphrase_SOURCES) $(srvtest_SOURCES) $(clitest_SOURCES)
+OBJECTS = $(libtinysrp_a_OBJECTS) $(tconf_OBJECTS) $(tphrase_OBJECTS) $(srvtest_OBJECTS) $(clitest_OBJECTS)
+
+all: all-redirect
+.SUFFIXES:
+.SUFFIXES: .S .c .o .s
+
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ cd $(top_builddir) \
+ && CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status
+
+$(ACLOCAL_M4): configure.in acinclude.m4
+ cd $(srcdir) && $(ACLOCAL)
+
+$(srcdir)/configure: $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES)
+ cd $(srcdir) && $(AUTOCONF)
+
+config.h: stamp-h
+ @if test ! -f $@; then \
+ rm -f stamp-h; \
+ $(MAKE) stamp-h; \
+ else :; fi
+stamp-h: $(srcdir)/config.h.in $(top_builddir)/config.status
+ cd $(top_builddir) \
+ && CONFIG_FILES= CONFIG_HEADERS=config.h \
+ $(SHELL) ./config.status
+ @echo timestamp > stamp-h 2> /dev/null
+$(srcdir)/config.h.in: $(srcdir)/stamp-h.in
+ @if test ! -f $@; then \
+ rm -f $(srcdir)/stamp-h.in; \
+ $(MAKE) $(srcdir)/stamp-h.in; \
+ else :; fi
+$(srcdir)/stamp-h.in: $(top_srcdir)/configure.in $(ACLOCAL_M4) acconfig.h
+ cd $(top_srcdir) && $(AUTOHEADER)
+ @echo timestamp > $(srcdir)/stamp-h.in 2> /dev/null
+
+mostlyclean-hdr:
+
+clean-hdr:
+
+distclean-hdr:
+ -rm -f config.h
+
+maintainer-clean-hdr:
+
+mostlyclean-libLIBRARIES:
+
+clean-libLIBRARIES:
+ -test -z "$(lib_LIBRARIES)" || rm -f $(lib_LIBRARIES)
+
+distclean-libLIBRARIES:
+
+maintainer-clean-libLIBRARIES:
+
+install-libLIBRARIES: $(lib_LIBRARIES)
+ @$(NORMAL_INSTALL)
+ $(mkinstalldirs) $(DESTDIR)$(libdir)
+ @list='$(lib_LIBRARIES)'; for p in $$list; do \
+ if test -f $$p; then \
+ echo " $(INSTALL_DATA) $$p $(DESTDIR)$(libdir)/$$p"; \
+ $(INSTALL_DATA) $$p $(DESTDIR)$(libdir)/$$p; \
+ else :; fi; \
+ done
+ @$(POST_INSTALL)
+ @list='$(lib_LIBRARIES)'; for p in $$list; do \
+ if test -f $$p; then \
+ echo " $(RANLIB) $(DESTDIR)$(libdir)/$$p"; \
+ $(RANLIB) $(DESTDIR)$(libdir)/$$p; \
+ else :; fi; \
+ done
+
+uninstall-libLIBRARIES:
+ @$(NORMAL_UNINSTALL)
+ list='$(lib_LIBRARIES)'; for p in $$list; do \
+ rm -f $(DESTDIR)$(libdir)/$$p; \
+ done
+
+.c.o:
+ $(COMPILE) -c $<
+
+.s.o:
+ $(COMPILE) -c $<
+
+.S.o:
+ $(COMPILE) -c $<
+
+mostlyclean-compile:
+ -rm -f *.o core *.core
+
+clean-compile:
+
+distclean-compile:
+ -rm -f *.tab.c
+
+maintainer-clean-compile:
+
+libtinysrp.a: $(libtinysrp_a_OBJECTS) $(libtinysrp_a_DEPENDENCIES)
+ -rm -f libtinysrp.a
+ $(AR) cru libtinysrp.a $(libtinysrp_a_OBJECTS) $(libtinysrp_a_LIBADD)
+ $(RANLIB) libtinysrp.a
+
+mostlyclean-binPROGRAMS:
+
+clean-binPROGRAMS:
+ -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
+
+distclean-binPROGRAMS:
+
+maintainer-clean-binPROGRAMS:
+
+install-binPROGRAMS: $(bin_PROGRAMS)
+ @$(NORMAL_INSTALL)
+ $(mkinstalldirs) $(DESTDIR)$(bindir)
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ if test -f $$p; then \
+ echo " $(INSTALL_PROGRAM) $(INSTALL_STRIP_FLAG) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \
+ $(INSTALL_PROGRAM) $(INSTALL_STRIP_FLAG) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
+ else :; fi; \
+ done
+
+uninstall-binPROGRAMS:
+ @$(NORMAL_UNINSTALL)
+ list='$(bin_PROGRAMS)'; for p in $$list; do \
+ rm -f $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
+ done
+
+mostlyclean-noinstPROGRAMS:
+
+clean-noinstPROGRAMS:
+ -test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS)
+
+distclean-noinstPROGRAMS:
+
+maintainer-clean-noinstPROGRAMS:
+
+tconf: $(tconf_OBJECTS) $(tconf_DEPENDENCIES)
+ @rm -f tconf
+ $(LINK) $(tconf_LDFLAGS) $(tconf_OBJECTS) $(tconf_LDADD) $(LIBS)
+
+tphrase: $(tphrase_OBJECTS) $(tphrase_DEPENDENCIES)
+ @rm -f tphrase
+ $(LINK) $(tphrase_LDFLAGS) $(tphrase_OBJECTS) $(tphrase_LDADD) $(LIBS)
+
+srvtest: $(srvtest_OBJECTS) $(srvtest_DEPENDENCIES)
+ @rm -f srvtest
+ $(LINK) $(srvtest_LDFLAGS) $(srvtest_OBJECTS) $(srvtest_LDADD) $(LIBS)
+
+clitest: $(clitest_OBJECTS) $(clitest_DEPENDENCIES)
+ @rm -f clitest
+ $(LINK) $(clitest_LDFLAGS) $(clitest_OBJECTS) $(clitest_LDADD) $(LIBS)
+
+install-includeHEADERS: $(include_HEADERS)
+ @$(NORMAL_INSTALL)
+ $(mkinstalldirs) $(DESTDIR)$(includedir)
+ @list='$(include_HEADERS)'; for p in $$list; do \
+ if test -f "$$p"; then d= ; else d="$(srcdir)/"; fi; \
+ echo " $(INSTALL_DATA) $$d$$p $(DESTDIR)$(includedir)/$$p"; \
+ $(INSTALL_DATA) $$d$$p $(DESTDIR)$(includedir)/$$p; \
+ done
+
+uninstall-includeHEADERS:
+ @$(NORMAL_UNINSTALL)
+ list='$(include_HEADERS)'; for p in $$list; do \
+ rm -f $(DESTDIR)$(includedir)/$$p; \
+ done
+
+tags: TAGS
+
+ID: $(HEADERS) $(SOURCES) $(LISP)
+ list='$(SOURCES) $(HEADERS)'; \
+ unique=`for i in $$list; do echo $$i; done | \
+ awk ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ here=`pwd` && cd $(srcdir) \
+ && mkid -f$$here/ID $$unique $(LISP)
+
+TAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS)'; \
+ unique=`for i in $$list; do echo $$i; done | \
+ awk ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ test -z "$(ETAGS_ARGS)config.h.in$$unique$(LISP)$$tags" \
+ || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags config.h.in $$unique $(LISP) -o $$here/TAGS)
+
+mostlyclean-tags:
+
+clean-tags:
+
+distclean-tags:
+ -rm -f TAGS ID
+
+maintainer-clean-tags:
+
+distdir = $(PACKAGE)-$(VERSION)
+top_distdir = $(distdir)
+
+# This target untars the dist file and tries a VPATH configuration. Then
+# it guarantees that the distribution is self-contained by making another
+# tarfile.
+distcheck: dist
+ -rm -rf $(distdir)
+ GZIP=$(GZIP_ENV) $(TAR) zxf $(distdir).tar.gz
+ mkdir $(distdir)/=build
+ mkdir $(distdir)/=inst
+ dc_install_base=`cd $(distdir)/=inst && pwd`; \
+ cd $(distdir)/=build \
+ && ../configure --srcdir=.. --prefix=$$dc_install_base \
+ && $(MAKE) $(AM_MAKEFLAGS) \
+ && $(MAKE) $(AM_MAKEFLAGS) dvi \
+ && $(MAKE) $(AM_MAKEFLAGS) check \
+ && $(MAKE) $(AM_MAKEFLAGS) install \
+ && $(MAKE) $(AM_MAKEFLAGS) installcheck \
+ && $(MAKE) $(AM_MAKEFLAGS) dist
+ -rm -rf $(distdir)
+ @banner="$(distdir).tar.gz is ready for distribution"; \
+ dashes=`echo "$$banner" | sed s/./=/g`; \
+ echo "$$dashes"; \
+ echo "$$banner"; \
+ echo "$$dashes"
+dist: distdir
+ -chmod -R a+r $(distdir)
+ GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir)
+ -rm -rf $(distdir)
+dist-all: distdir
+ -chmod -R a+r $(distdir)
+ GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir)
+ -rm -rf $(distdir)
+distdir: $(DISTFILES)
+ -rm -rf $(distdir)
+ mkdir $(distdir)
+ -chmod 777 $(distdir)
+ @for file in $(DISTFILES); do \
+ d=$(srcdir); \
+ if test -d $$d/$$file; then \
+ cp -pr $$d/$$file $(distdir)/$$file; \
+ else \
+ test -f $(distdir)/$$file \
+ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
+ || cp -p $$d/$$file $(distdir)/$$file || :; \
+ fi; \
+ done
+info-am:
+info: info-am
+dvi-am:
+dvi: dvi-am
+check-am: all-am
+check: check-am
+installcheck-am:
+installcheck: installcheck-am
+all-recursive-am: config.h
+ $(MAKE) $(AM_MAKEFLAGS) all-recursive
+
+install-exec-am: install-libLIBRARIES install-binPROGRAMS
+install-exec: install-exec-am
+
+install-data-am: install-includeHEADERS
+install-data: install-data-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+install: install-am
+uninstall-am: uninstall-libLIBRARIES uninstall-binPROGRAMS \
+ uninstall-includeHEADERS
+uninstall: uninstall-am
+all-am: Makefile $(LIBRARIES) $(PROGRAMS) $(HEADERS) config.h
+all-redirect: all-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install
+installdirs:
+ $(mkinstalldirs) $(DESTDIR)$(libdir) $(DESTDIR)$(bindir) \
+ $(DESTDIR)$(includedir)
+
+
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -rm -f Makefile $(CONFIG_CLEAN_FILES)
+ -rm -f config.cache config.log stamp-h stamp-h[0-9]*
+
+maintainer-clean-generic:
+mostlyclean-am: mostlyclean-hdr mostlyclean-libLIBRARIES \
+ mostlyclean-compile mostlyclean-binPROGRAMS \
+ mostlyclean-noinstPROGRAMS mostlyclean-tags \
+ mostlyclean-generic
+
+mostlyclean: mostlyclean-am
+
+clean-am: clean-hdr clean-libLIBRARIES clean-compile clean-binPROGRAMS \
+ clean-noinstPROGRAMS clean-tags clean-generic \
+ mostlyclean-am
+
+clean: clean-am
+
+distclean-am: distclean-hdr distclean-libLIBRARIES distclean-compile \
+ distclean-binPROGRAMS distclean-noinstPROGRAMS \
+ distclean-tags distclean-generic clean-am
+
+distclean: distclean-am
+ -rm -f config.status
+
+maintainer-clean-am: maintainer-clean-hdr maintainer-clean-libLIBRARIES \
+ maintainer-clean-compile maintainer-clean-binPROGRAMS \
+ maintainer-clean-noinstPROGRAMS maintainer-clean-tags \
+ maintainer-clean-generic distclean-am
+ @echo "This command is intended for maintainers to use;"
+ @echo "it deletes files that may require special tools to rebuild."
+
+maintainer-clean: maintainer-clean-am
+ -rm -f config.status
+
+.PHONY: mostlyclean-hdr distclean-hdr clean-hdr maintainer-clean-hdr \
+mostlyclean-libLIBRARIES distclean-libLIBRARIES clean-libLIBRARIES \
+maintainer-clean-libLIBRARIES uninstall-libLIBRARIES \
+install-libLIBRARIES mostlyclean-compile distclean-compile \
+clean-compile maintainer-clean-compile mostlyclean-binPROGRAMS \
+distclean-binPROGRAMS clean-binPROGRAMS maintainer-clean-binPROGRAMS \
+uninstall-binPROGRAMS install-binPROGRAMS mostlyclean-noinstPROGRAMS \
+distclean-noinstPROGRAMS clean-noinstPROGRAMS \
+maintainer-clean-noinstPROGRAMS uninstall-includeHEADERS \
+install-includeHEADERS tags mostlyclean-tags distclean-tags clean-tags \
+maintainer-clean-tags distdir info-am info dvi-am dvi check check-am \
+installcheck-am installcheck all-recursive-am install-exec-am \
+install-exec install-data-am install-data install-am install \
+uninstall-am uninstall all-redirect all-am all installdirs \
+mostlyclean-generic distclean-generic clean-generic \
+maintainer-clean-generic clean mostlyclean distclean maintainer-clean
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/package/network/services/ead/src/tinysrp/Notes b/package/network/services/ead/src/tinysrp/Notes
new file mode 100644
index 0000000..a8620aa
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/Notes
@@ -0,0 +1,110 @@
+t_* stuff is from the srp 1.7.1 dist
+bn_* stuff is from openssl 0.9.6
+
+(The 7 in libtinysrp's version number reflects the srp version.)
+
+Licensing and copyright for srp and openssl are as indicated in the relevant
+source files. Everything else here is GPL, including the tinysrp protocol.
+
+Changelog since initial release:
+
+0.7.4 more robust terminal modes in t_getpass
+ a potential buffer overflow in tinysrp
+0.7.5 uninitialized pointer bug in tconf
+
+Changes from the base srp and openssl distributions:
+
+I've removed everything that's not needed for client/server operations, and
+all the bn_* stuff that's only used for prime generation has been moved to
+t_conf.c, which isn't part of the library anymore. Also, all the routines
+used for passphrase file maintenance have been moved to tphrase.c.
+
+The library has been optimized (a bit) for space instead of speed. Since
+authentication is usually only done once, this isn't a big problem. Modern
+CPUs are plenty fast for this task, and even 100 MHz CPUs are fine. If you
+really need the speed, get the regular distributions.
+
+Note that if the server sends the client a prime that the client doesn't
+know about, the client MUST test for primality. Since this is pretty
+expensive, and takes 30 seconds on a 100 MHz machine, and uses lots of code,
+I've removed that ability from the client. So only KNOWN primes can be
+used. You can still generate new ones with tconf, but you have to install
+them in the table of known primes (pre_params) in t_getconf.c that's common
+to the client and server, and recompile. The configuration file is gone.
+
+The default prime (the last entry in the table) is 1024 bits; there are
+others with more bits but they will be correspondingly slower.
+
+The default tpasswd file (which is an ascii file that may be editted with a
+regular text editor) contains two users: moo (passphrase "glub glub") and
+"new user" (passphrase "this is a test"). Passphrases may be added or
+changed with tphrase; you can also change the user's prime. To delete a
+user, edit the tpasswd file and remove that line. The tpasswd file's
+default name is DEFAULT_PASSWD in t_pwd.h. Note that you can't change a
+user's username by editting the file: the username is encoded in the
+verifier. If you change a username you must set a new passphrase with
+tphrase.
+
+Here is an example session, using the supplied srvtest and clitest. First,
+start both programs in different windows, and enter the user names. Normally,
+the client would send the username to the server. Server lines are marked
+with S>, client lines with C>.
+
+S> % srvtest
+S> Enter username: moo
+S> index (to client): 5
+S> salt (to client): 19AI0Hc9jEkdFc
+
+C> % clitest
+C> Enter username: moo
+C> Enter index (from server): 5
+C> Enter salt (from server): 19AI0Hc9jEkdFc
+
+The server reports the index and salt values used for that user. They
+are sent over the network to the client. (Simulate this by cutting and
+pasting from one window to the other.)
+
+C> A (to server): 5wCDXRxLIv/zLazYfKupV/OY3BlhTZuJ71wVgI0HcL1kSJEpkMuWF.xEz/BV2wlJl7vk5Eoz9KMS1ccnaatsVP5D6CBm7UA.yVB59EQFN0dNBirvX29NAFdtdMsMppo5tHRy987XjJWrWSLpeibq6emr.gP8nYyX75GQqSiMY1j
+C> Enter password:
+
+S> Enter A (from client): 5wCDXRxLIv/zLazYfKupV/OY3BlhTZuJ71wVgI0HcL1kSJEpkMuWF.xEz/BV2wlJl7vk5Eoz9KMS1ccnaatsVP5D6CBm7UA.yVB59EQFN0dNBirvX29NAFdtdMsMppo5tHRy987XjJWrWSLpeibq6emr.gP8nYyX75GQqSiMY1j
+
+Now the client calculates A and sends it to the server, and while the
+server is munching on that, the client gets the password from the user.
+
+S> B (to client): 9dcCpulxQAbaDXI0NHWY6B.QH6B9fsoXs/x/5SCNBNJm/6H6bYfbVrwNmdquhLZjYMvpcgGc2mBYqL77RNfw1kVQo17//GfsByECBIjRnrAn02ffX9Y/llJcfscAQiii0hyZhJf9PT5wE7pC7WUjIgSqckIZ0JLNDbSr7fJcrgw
+S> Session key: ebbcf3a45c968defdcfff6e144ad8d4f5412167c9716e79cbf7cacfe18257947ad46fa5d6418a1fd
+
+The server now calculates B and sends it to the client. The session key
+is not sent -- it is a shared secret that can be used for encryption.
+
+C> Enter B (from server): 9dcCpulxQAbaDXI0NHWY6B.QH6B9fsoXs/x/5SCNBNJm/6H6bYfbVrwNmdquhLZjYMvpcgGc2mBYqL77RNfw1kVQo17//GfsByECBIjRnrAn02ffX9Y/llJcfscAQiii0hyZhJf9PT5wE7pC7WUjIgSqckIZ0JLNDbSr7fJcrgw
+C> Session key: ebbcf3a45c968defdcfff6e144ad8d4f5412167c9716e79cbf7cacfe18257947ad46fa5d6418a1fd
+C> Response (to server): b9ea99094a176c4be28eb469982066cc7146d180
+
+The client uses the B value to calculate its own copy of the shared secret
+session key, and sends a response to the server proving that it does know
+the correct key.
+
+S> Enter response (from client): b9ea99094a176c4be28eb469982066cc7146d180
+S> Authentication successful.
+S> Response (to client): cd46c839ccad2d0c76f3ca1905ae8ceda8d1c1dc
+
+The server authenticates the client. (You're in!)
+
+C> Enter server response: cd46c839ccad2d0c76f3ca1905ae8ceda8d1c1dc
+C> Server authentication successful.
+
+The client authenticates the server (prevents server spoofing in the case
+where the session key isn't used to encrypt the channel -- a spoofed server
+might just respond with random values and _pretend_ to authenticate the
+client; but the spoofed server won't know the session key and this check
+catches that).
+
+Final note:
+
+Remember that many breaches of security involve buggy software, such as
+servers susceptible to buffer overflow exploits that totally bypass any
+passphrase, secure or not. If an attacker roots your client, or the server,
+no form of authentication will work. Consider MAC-based schemes if this
+worries you.
diff --git a/package/network/services/ead/src/tinysrp/acconfig.h b/package/network/services/ead/src/tinysrp/acconfig.h
new file mode 100644
index 0000000..b74aed0
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/acconfig.h
@@ -0,0 +1,9 @@
+#undef SHA1HANDSOFF
+
+#undef POSIX_TERMIOS
+
+#undef POSIX_SIGTYPE
+
+#undef VERSION
+
+#undef volatile
diff --git a/package/network/services/ead/src/tinysrp/acinclude.m4 b/package/network/services/ead/src/tinysrp/acinclude.m4
new file mode 100644
index 0000000..e0d0d04
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/acinclude.m4
@@ -0,0 +1,27 @@
+dnl
+dnl check for signal type
+dnl
+dnl AC_RETSIGTYPE isn't quite right, but almost.
+dnl
+define(TYPE_SIGNAL,[
+AC_MSG_CHECKING([POSIX signal handlers])
+AC_CACHE_VAL(cv_has_posix_signals,
+[AC_TRY_COMPILE(
+[#include <sys/types.h>
+#include <signal.h>
+#ifdef signal
+#undef signal
+#endif
+extern void (*signal ()) ();], [],
+cv_has_posix_signals=yes, cv_has_posix_signals=no)])
+AC_MSG_RESULT($cv_has_posix_signals)
+if test $cv_has_posix_signals = yes; then
+ AC_DEFINE(RETSIGTYPE, void, [Return type is void])
+ AC_DEFINE(POSIX_SIGTYPE, [], [Have POSIX signals])
+else
+ if test $ac_cv_type_signal = void; then
+ AC_DEFINE(RETSIGTYPE, void, [Return type is void])
+ else
+ AC_DEFINE(RETSIGTYPE, int, [Return type is int])
+ fi
+fi])dnl
diff --git a/package/network/services/ead/src/tinysrp/aclocal.m4 b/package/network/services/ead/src/tinysrp/aclocal.m4
new file mode 100644
index 0000000..703fce4
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/aclocal.m4
@@ -0,0 +1,157 @@
+dnl aclocal.m4 generated automatically by aclocal 1.4a
+
+dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+dnl PARTICULAR PURPOSE.
+
+dnl
+dnl check for signal type
+dnl
+dnl AC_RETSIGTYPE isn't quite right, but almost.
+dnl
+define(TYPE_SIGNAL,[
+AC_MSG_CHECKING([POSIX signal handlers])
+AC_CACHE_VAL(cv_has_posix_signals,
+[AC_TRY_COMPILE(
+[#include <sys/types.h>
+#include <signal.h>
+#ifdef signal
+#undef signal
+#endif
+extern void (*signal ()) ();], [],
+cv_has_posix_signals=yes, cv_has_posix_signals=no)])
+AC_MSG_RESULT($cv_has_posix_signals)
+if test $cv_has_posix_signals = yes; then
+ AC_DEFINE(RETSIGTYPE, void, [Return type is void])
+ AC_DEFINE(POSIX_SIGTYPE, [], [Have POSIX signals])
+else
+ if test $ac_cv_type_signal = void; then
+ AC_DEFINE(RETSIGTYPE, void, [Return type is void])
+ else
+ AC_DEFINE(RETSIGTYPE, int, [Return type is int])
+ fi
+fi])dnl
+
+# Like AC_CONFIG_HEADER, but automatically create stamp file.
+
+AC_DEFUN(AM_CONFIG_HEADER,
+[AC_PREREQ([2.12])
+AC_CONFIG_HEADER([$1])
+dnl When config.status generates a header, we must update the stamp-h file.
+dnl This file resides in the same directory as the config header
+dnl that is generated. We must strip everything past the first ":",
+dnl and everything past the last "/".
+AC_OUTPUT_COMMANDS(changequote(<<,>>)dnl
+ifelse(patsubst(<<$1>>, <<[^ ]>>, <<>>), <<>>,
+<<test -z "<<$>>CONFIG_HEADERS" || echo timestamp > patsubst(<<$1>>, <<^\([^:]*/\)?.*>>, <<\1>>)stamp-h<<>>dnl>>,
+<<am_indx=1
+for am_file in <<$1>>; do
+ case " <<$>>CONFIG_HEADERS " in
+ *" <<$>>am_file "*<<)>>
+ echo timestamp > `echo <<$>>am_file | sed -e 's%:.*%%' -e 's%[^/]*$%%'`stamp-h$am_indx
+ ;;
+ esac
+ am_indx=`expr "<<$>>am_indx" + 1`
+done<<>>dnl>>)
+changequote([,]))])
+
+# Do all the work for Automake. This macro actually does too much --
+# some checks are only needed if your package does certain things.
+# But this isn't really a big deal.
+
+# serial 1
+
+dnl Usage:
+dnl AM_INIT_AUTOMAKE(package,version, [no-define])
+
+AC_DEFUN(AM_INIT_AUTOMAKE,
+[AC_REQUIRE([AC_PROG_INSTALL])
+dnl We require 2.13 because we rely on SHELL being computed by configure.
+AC_PREREQ([2.13])
+PACKAGE=[$1]
+AC_SUBST(PACKAGE)
+VERSION=[$2]
+AC_SUBST(VERSION)
+dnl test to see if srcdir already configured
+if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
+ AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
+fi
+ifelse([$3],,
+AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
+AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package]))
+AC_REQUIRE([AM_SANITY_CHECK])
+AC_REQUIRE([AC_ARG_PROGRAM])
+dnl FIXME This is truly gross.
+missing_dir=`cd $ac_aux_dir && pwd`
+AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
+AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
+AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
+AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
+AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
+AC_REQUIRE([AC_PROG_MAKE_SET])])
+
+#
+# Check to make sure that the build environment is sane.
+#
+
+AC_DEFUN(AM_SANITY_CHECK,
+[AC_MSG_CHECKING([whether build environment is sane])
+# Just in case
+sleep 1
+echo timestamp > conftestfile
+# Do `set' in a subshell so we don't clobber the current shell's
+# arguments. Must try -L first in case configure is actually a
+# symlink; some systems play weird games with the mod time of symlinks
+# (eg FreeBSD returns the mod time of the symlink's containing
+# directory).
+if (
+ set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null`
+ if test "[$]*" = "X"; then
+ # -L didn't work.
+ set X `ls -t $srcdir/configure conftestfile`
+ fi
+ if test "[$]*" != "X $srcdir/configure conftestfile" \
+ && test "[$]*" != "X conftestfile $srcdir/configure"; then
+
+ # If neither matched, then we have a broken ls. This can happen
+ # if, for instance, CONFIG_SHELL is bash and it inherits a
+ # broken ls alias from the environment. This has actually
+ # happened. Such a system could not be considered "sane".
+ AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken
+alias in your environment])
+ fi
+
+ test "[$]2" = conftestfile
+ )
+then
+ # Ok.
+ :
+else
+ AC_MSG_ERROR([newly created file is older than distributed files!
+Check your system clock])
+fi
+rm -f conftest*
+AC_MSG_RESULT(yes)])
+
+dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY)
+dnl The program must properly implement --version.
+AC_DEFUN(AM_MISSING_PROG,
+[AC_MSG_CHECKING(for working $2)
+# Run test in a subshell; some versions of sh will print an error if
+# an executable is not found, even if stderr is redirected.
+# Redirect stdin to placate older versions of autoconf. Sigh.
+if ($2 --version) < /dev/null > /dev/null 2>&1; then
+ $1=$2
+ AC_MSG_RESULT(found)
+else
+ $1="$3/missing $2"
+ AC_MSG_RESULT(missing)
+fi
+AC_SUBST($1)])
+
diff --git a/package/network/services/ead/src/tinysrp/bn.h b/package/network/services/ead/src/tinysrp/bn.h
new file mode 100644
index 0000000..0144dd9
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/bn.h
@@ -0,0 +1,471 @@
+/* crypto/bn/bn.h */
+/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#ifndef HEADER_BN_H
+#define HEADER_BN_H
+
+#include <stdio.h> /* FILE */
+#include "config.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef VMS
+#undef BN_LLONG /* experimental, so far... */
+#endif
+
+#undef BN_MUL_COMBA
+#undef BN_SQR_COMBA
+#undef BN_RECURSION
+#undef RECP_MUL_MOD
+#undef MONT_MUL_MOD
+
+#if defined(SIZEOF_LONG_LONG) && SIZEOF_LONG_LONG == 8
+# if SIZEOF_LONG == 4
+# define THIRTY_TWO_BIT
+# else
+# define SIXTY_FOUR_BIT_LONG
+# endif
+#else
+# if SIZEOF_LONG == 4
+# define THIRTY_TWO_BIT
+# endif
+#endif
+
+#undef BN_LLONG
+
+/* assuming long is 64bit - this is the DEC Alpha
+ * unsigned long long is only 64 bits :-(, don't define
+ * BN_LLONG for the DEC Alpha */
+#ifdef SIXTY_FOUR_BIT_LONG
+#define BN_ULLONG unsigned long long
+#define BN_ULONG unsigned long
+#define BN_LONG long
+#define BN_BITS 128
+#define BN_BYTES 8
+#define BN_BITS2 64
+#define BN_BITS4 32
+#define BN_MASK (0xffffffffffffffffffffffffffffffffLL)
+#define BN_MASK2 (0xffffffffffffffffL)
+#define BN_MASK2l (0xffffffffL)
+#define BN_MASK2h (0xffffffff00000000L)
+#define BN_MASK2h1 (0xffffffff80000000L)
+#define BN_TBIT (0x8000000000000000L)
+#define BN_DEC_CONV (10000000000000000000UL)
+#define BN_DEC_FMT1 "%lu"
+#define BN_DEC_FMT2 "%019lu"
+#define BN_DEC_NUM 19
+#endif
+
+/* This is where the long long data type is 64 bits, but long is 32.
+ * For machines where there are 64bit registers, this is the mode to use.
+ * IRIX, on R4000 and above should use this mode, along with the relevant
+ * assembler code :-). Do NOT define BN_LLONG.
+ */
+#ifdef SIXTY_FOUR_BIT
+#undef BN_LLONG
+#undef BN_ULLONG
+#define BN_ULONG unsigned long long
+#define BN_LONG long long
+#define BN_BITS 128
+#define BN_BYTES 8
+#define BN_BITS2 64
+#define BN_BITS4 32
+#define BN_MASK2 (0xffffffffffffffffLL)
+#define BN_MASK2l (0xffffffffL)
+#define BN_MASK2h (0xffffffff00000000LL)
+#define BN_MASK2h1 (0xffffffff80000000LL)
+#define BN_TBIT (0x8000000000000000LL)
+#define BN_DEC_CONV (10000000000000000000LL)
+#define BN_DEC_FMT1 "%llu"
+#define BN_DEC_FMT2 "%019llu"
+#define BN_DEC_NUM 19
+#endif
+
+#ifdef THIRTY_TWO_BIT
+#if defined(WIN32) && !defined(__GNUC__)
+#define BN_ULLONG unsigned _int64
+#else
+#define BN_ULLONG unsigned long long
+#endif
+#define BN_ULONG unsigned long
+#define BN_LONG long
+#define BN_BITS 64
+#define BN_BYTES 4
+#define BN_BITS2 32
+#define BN_BITS4 16
+#ifdef WIN32
+/* VC++ doesn't like the LL suffix */
+#define BN_MASK (0xffffffffffffffffL)
+#else
+#define BN_MASK (0xffffffffffffffffLL)
+#endif
+#define BN_MASK2 (0xffffffffL)
+#define BN_MASK2l (0xffff)
+#define BN_MASK2h1 (0xffff8000L)
+#define BN_MASK2h (0xffff0000L)
+#define BN_TBIT (0x80000000L)
+#define BN_DEC_CONV (1000000000L)
+#define BN_DEC_FMT1 "%lu"
+#define BN_DEC_FMT2 "%09lu"
+#define BN_DEC_NUM 9
+#endif
+
+#ifdef SIXTEEN_BIT
+#ifndef BN_DIV2W
+#define BN_DIV2W
+#endif
+#define BN_ULLONG unsigned long
+#define BN_ULONG unsigned short
+#define BN_LONG short
+#define BN_BITS 32
+#define BN_BYTES 2
+#define BN_BITS2 16
+#define BN_BITS4 8
+#define BN_MASK (0xffffffff)
+#define BN_MASK2 (0xffff)
+#define BN_MASK2l (0xff)
+#define BN_MASK2h1 (0xff80)
+#define BN_MASK2h (0xff00)
+#define BN_TBIT (0x8000)
+#define BN_DEC_CONV (100000)
+#define BN_DEC_FMT1 "%u"
+#define BN_DEC_FMT2 "%05u"
+#define BN_DEC_NUM 5
+#endif
+
+#ifdef EIGHT_BIT
+#ifndef BN_DIV2W
+#define BN_DIV2W
+#endif
+#define BN_ULLONG unsigned short
+#define BN_ULONG unsigned char
+#define BN_LONG char
+#define BN_BITS 16
+#define BN_BYTES 1
+#define BN_BITS2 8
+#define BN_BITS4 4
+#define BN_MASK (0xffff)
+#define BN_MASK2 (0xff)
+#define BN_MASK2l (0xf)
+#define BN_MASK2h1 (0xf8)
+#define BN_MASK2h (0xf0)
+#define BN_TBIT (0x80)
+#define BN_DEC_CONV (100)
+#define BN_DEC_FMT1 "%u"
+#define BN_DEC_FMT2 "%02u"
+#define BN_DEC_NUM 2
+#endif
+
+#define BN_DEFAULT_BITS 1280
+
+#ifdef BIGNUM
+#undef BIGNUM
+#endif
+
+#define BN_FLG_MALLOCED 0x01
+#define BN_FLG_STATIC_DATA 0x02
+#define BN_FLG_FREE 0x8000 /* used for debuging */
+#define BN_set_flags(b,n) ((b)->flags|=(n))
+#define BN_get_flags(b,n) ((b)->flags&(n))
+
+typedef struct bignum_st
+ {
+ BN_ULONG *d; /* Pointer to an array of 'BN_BITS2' bit chunks. */
+ int top; /* Index of last used d +1. */
+ /* The next are internal book keeping for bn_expand. */
+ int dmax; /* Size of the d array. */
+ int neg; /* one if the number is negative */
+ int flags;
+ } BIGNUM;
+
+/* Used for temp variables */
+#define BN_CTX_NUM 12
+#define BN_CTX_NUM_POS 12
+typedef struct bignum_ctx
+ {
+ int tos;
+ BIGNUM bn[BN_CTX_NUM];
+ int flags;
+ int depth;
+ int pos[BN_CTX_NUM_POS];
+ int too_many;
+ } BN_CTX;
+
+/* Used for montgomery multiplication */
+typedef struct bn_mont_ctx_st
+ {
+ int ri; /* number of bits in R */
+ BIGNUM RR; /* used to convert to montgomery form */
+ BIGNUM N; /* The modulus */
+ BIGNUM Ni; /* R*(1/R mod N) - N*Ni = 1
+ * (Ni is only stored for bignum algorithm) */
+ BN_ULONG n0; /* least significant word of Ni */
+ int flags;
+ } BN_MONT_CTX;
+
+/* Used for reciprocal division/mod functions
+ * It cannot be shared between threads
+ */
+typedef struct bn_recp_ctx_st
+ {
+ BIGNUM N; /* the divisor */
+ BIGNUM Nr; /* the reciprocal */
+ int num_bits;
+ int shift;
+ int flags;
+ } BN_RECP_CTX;
+
+#define BN_to_montgomery(r,a,mont,ctx) BN_mod_mul_montgomery(\
+ r,a,&((mont)->RR),(mont),ctx)
+
+#define BN_prime_checks 0 /* default: select number of iterations
+ based on the size of the number */
+
+/* number of Miller-Rabin iterations for an error rate of less than 2^-80
+ * for random 'b'-bit input, b >= 100 (taken from table 4.4 in the Handbook
+ * of Applied Cryptography [Menezes, van Oorschot, Vanstone; CRC Press 1996];
+ * original paper: Damgaard, Landrock, Pomerance: Average case error estimates
+ * for the strong probable prime test. -- Math. Comp. 61 (1993) 177-194) */
+#define BN_prime_checks_for_size(b) ((b) >= 1300 ? 2 : \
+ (b) >= 850 ? 3 : \
+ (b) >= 650 ? 4 : \
+ (b) >= 550 ? 5 : \
+ (b) >= 450 ? 6 : \
+ (b) >= 400 ? 7 : \
+ (b) >= 350 ? 8 : \
+ (b) >= 300 ? 9 : \
+ (b) >= 250 ? 12 : \
+ (b) >= 200 ? 15 : \
+ (b) >= 150 ? 18 : \
+ /* b >= 100 */ 27)
+
+#define BN_num_bytes(a) ((BN_num_bits(a)+7)/8)
+#define BN_is_word(a,w) (((a)->top == 1) && ((a)->d[0] == (BN_ULONG)(w)))
+#define BN_is_zero(a) (((a)->top == 0) || BN_is_word(a,0))
+#define BN_is_one(a) (BN_is_word((a),1))
+#define BN_is_odd(a) (((a)->top > 0) && ((a)->d[0] & 1))
+#define BN_one(a) (BN_set_word((a),1))
+#define BN_zero(a) (BN_set_word((a),0))
+
+BIGNUM *BN_value_one(void);
+char * BN_options(void);
+BN_CTX *BN_CTX_new(void);
+void BN_CTX_init(BN_CTX *c);
+void BN_CTX_free(BN_CTX *c);
+void BN_CTX_start(BN_CTX *ctx);
+BIGNUM *BN_CTX_get(BN_CTX *ctx);
+void BN_CTX_end(BN_CTX *ctx);
+int BN_rand(BIGNUM *rnd, int bits, int top,int bottom);
+int BN_pseudo_rand(BIGNUM *rnd, int bits, int top,int bottom);
+int BN_num_bits(const BIGNUM *a);
+int BN_num_bits_word(BN_ULONG);
+BIGNUM *BN_new(void);
+void BN_init(BIGNUM *);
+void BN_clear_free(BIGNUM *a);
+BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b);
+BIGNUM *BN_bin2bn(const unsigned char *s,int len,BIGNUM *ret);
+int BN_bn2bin(const BIGNUM *a, unsigned char *to);
+int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
+int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
+int BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
+int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
+int BN_mod(BIGNUM *rem, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx);
+int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d,
+ BN_CTX *ctx);
+int BN_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx);
+int BN_sqr(BIGNUM *r, BIGNUM *a,BN_CTX *ctx);
+BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w);
+BN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w);
+int BN_mul_word(BIGNUM *a, BN_ULONG w);
+int BN_add_word(BIGNUM *a, BN_ULONG w);
+int BN_sub_word(BIGNUM *a, BN_ULONG w);
+int BN_set_word(BIGNUM *a, BN_ULONG w);
+BN_ULONG BN_get_word(BIGNUM *a);
+int BN_cmp(const BIGNUM *a, const BIGNUM *b);
+void BN_free(BIGNUM *a);
+int BN_is_bit_set(const BIGNUM *a, int n);
+int BN_lshift(BIGNUM *r, const BIGNUM *a, int n);
+int BN_lshift1(BIGNUM *r, BIGNUM *a);
+int BN_exp(BIGNUM *r, BIGNUM *a, BIGNUM *p,BN_CTX *ctx);
+int BN_mod_exp(BIGNUM *r, BIGNUM *a, const BIGNUM *p,
+ const BIGNUM *m,BN_CTX *ctx);
+int BN_mod_exp_mont(BIGNUM *r, BIGNUM *a, const BIGNUM *p,
+ const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
+int BN_mod_exp_mont_word(BIGNUM *r, BN_ULONG a, const BIGNUM *p,
+ const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
+int BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
+ const BIGNUM *m,BN_CTX *ctx);
+int BN_mask_bits(BIGNUM *a,int n);
+int BN_mod_mul(BIGNUM *ret, BIGNUM *a, BIGNUM *b, const BIGNUM *m, BN_CTX *ctx);
+int BN_reciprocal(BIGNUM *r, BIGNUM *m, int len, BN_CTX *ctx);
+int BN_rshift(BIGNUM *r, BIGNUM *a, int n);
+int BN_rshift1(BIGNUM *r, BIGNUM *a);
+void BN_clear(BIGNUM *a);
+BIGNUM *BN_dup(const BIGNUM *a);
+int BN_ucmp(const BIGNUM *a, const BIGNUM *b);
+int BN_set_bit(BIGNUM *a, int n);
+int BN_clear_bit(BIGNUM *a, int n);
+int BN_gcd(BIGNUM *r,BIGNUM *in_a,BIGNUM *in_b,BN_CTX *ctx);
+BIGNUM *BN_mod_inverse(BIGNUM *ret,BIGNUM *a, const BIGNUM *n,BN_CTX *ctx);
+BIGNUM *BN_generate_prime(BIGNUM *ret,int bits,int safe,BIGNUM *add,
+ BIGNUM *rem,void (*callback)(int,int,void *),void *cb_arg);
+int BN_is_prime(const BIGNUM *p,int nchecks,
+ void (*callback)(int,int,void *),
+ BN_CTX *ctx,void *cb_arg);
+int BN_is_prime_fasttest(const BIGNUM *p,int nchecks,
+ void (*callback)(int,int,void *),BN_CTX *ctx,void *cb_arg,
+ int do_trial_division);
+
+BN_MONT_CTX *BN_MONT_CTX_new(void );
+void BN_MONT_CTX_init(BN_MONT_CTX *ctx);
+int BN_mod_mul_montgomery(BIGNUM *r,BIGNUM *a,BIGNUM *b,BN_MONT_CTX *mont,
+ BN_CTX *ctx);
+int BN_from_montgomery(BIGNUM *r,BIGNUM *a,BN_MONT_CTX *mont,BN_CTX *ctx);
+void BN_MONT_CTX_free(BN_MONT_CTX *mont);
+int BN_MONT_CTX_set(BN_MONT_CTX *mont,const BIGNUM *modulus,BN_CTX *ctx);
+BN_MONT_CTX *BN_MONT_CTX_copy(BN_MONT_CTX *to,BN_MONT_CTX *from);
+
+void BN_set_params(int mul,int high,int low,int mont);
+int BN_get_params(int which); /* 0, mul, 1 high, 2 low, 3 mont */
+
+void BN_RECP_CTX_init(BN_RECP_CTX *recp);
+BN_RECP_CTX *BN_RECP_CTX_new(void);
+void BN_RECP_CTX_free(BN_RECP_CTX *recp);
+int BN_RECP_CTX_set(BN_RECP_CTX *recp,const BIGNUM *rdiv,BN_CTX *ctx);
+int BN_mod_mul_reciprocal(BIGNUM *r, BIGNUM *x, BIGNUM *y,
+ BN_RECP_CTX *recp,BN_CTX *ctx);
+int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
+ const BIGNUM *m, BN_CTX *ctx);
+int BN_div_recp(BIGNUM *dv, BIGNUM *rem, BIGNUM *m,
+ BN_RECP_CTX *recp, BN_CTX *ctx);
+
+/* library internal functions */
+
+#define bn_expand(a,bits) ((((((bits+BN_BITS2-1))/BN_BITS2)) <= (a)->dmax)?\
+ (a):bn_expand2((a),(bits)/BN_BITS2+1))
+#define bn_wexpand(a,words) (((words) <= (a)->dmax)?(a):bn_expand2((a),(words)))
+BIGNUM *bn_expand2(BIGNUM *a, int words);
+
+#define bn_fix_top(a) \
+ { \
+ BN_ULONG *ftl; \
+ if ((a)->top > 0) \
+ { \
+ for (ftl= &((a)->d[(a)->top-1]); (a)->top > 0; (a)->top--) \
+ if (*(ftl--)) break; \
+ } \
+ }
+
+BN_ULONG bn_mul_add_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w);
+BN_ULONG bn_mul_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w);
+void bn_sqr_words(BN_ULONG *rp, BN_ULONG *ap, int num);
+BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d);
+BN_ULONG bn_add_words(BN_ULONG *rp, BN_ULONG *ap, BN_ULONG *bp,int num);
+BN_ULONG bn_sub_words(BN_ULONG *rp, BN_ULONG *ap, BN_ULONG *bp,int num);
+
+#ifdef BN_DEBUG
+ void bn_dump1(FILE *o, const char *a, BN_ULONG *b,int n);
+# define bn_print(a) {fprintf(stderr, #a "="); BN_print_fp(stderr,a); \
+ fprintf(stderr,"\n");}
+# define bn_dump(a,n) bn_dump1(stderr,#a,a,n);
+#else
+# define bn_print(a)
+# define bn_dump(a,b)
+#endif
+
+/* BEGIN ERROR CODES */
+/* The following lines are auto generated by the script mkerr.pl. Any changes
+ * made after this point may be overwritten when the script is next run.
+ */
+
+/* Error codes for the BN functions. */
+
+/* Function codes. */
+#define BN_F_BN_CTX_GET 116
+#define BN_F_BN_CTX_NEW 106
+#define BN_F_BN_DIV 107
+#define BN_F_BN_EXPAND2 108
+#define BN_F_BN_MOD_EXP2_MONT 118
+#define BN_F_BN_MOD_EXP_MONT 109
+#define BN_F_BN_MOD_EXP_MONT_WORD 117
+#define BN_F_BN_MOD_INVERSE 110
+#define BN_F_BN_MOD_MUL_RECIPROCAL 111
+#define BN_F_BN_MPI2BN 112
+#define BN_F_BN_NEW 113
+#define BN_F_BN_RAND 114
+#define BN_F_BN_USUB 115
+
+/* Reason codes. */
+#define BN_R_ARG2_LT_ARG3 100
+#define BN_R_BAD_RECIPROCAL 101
+#define BN_R_CALLED_WITH_EVEN_MODULUS 102
+#define BN_R_DIV_BY_ZERO 103
+#define BN_R_ENCODING_ERROR 104
+#define BN_R_EXPAND_ON_STATIC_BIGNUM_DATA 105
+#define BN_R_INVALID_LENGTH 106
+#define BN_R_NOT_INITIALIZED 107
+#define BN_R_NO_INVERSE 108
+#define BN_R_TOO_MANY_TEMPORARY_VARIABLES 109
+
+#ifdef __cplusplus
+}
+#endif
+#endif
+
diff --git a/package/network/services/ead/src/tinysrp/bn_add.c b/package/network/services/ead/src/tinysrp/bn_add.c
new file mode 100644
index 0000000..aae4f2b
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/bn_add.c
@@ -0,0 +1,305 @@
+/* crypto/bn/bn_add.c */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#include <stdio.h>
+#include "bn_lcl.h"
+
+/* r can == a or b */
+int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)
+ {
+ const BIGNUM *tmp;
+
+ bn_check_top(a);
+ bn_check_top(b);
+
+ /* a + b a+b
+ * a + -b a-b
+ * -a + b b-a
+ * -a + -b -(a+b)
+ */
+ if (a->neg ^ b->neg)
+ {
+ /* only one is negative */
+ if (a->neg)
+ { tmp=a; a=b; b=tmp; }
+
+ /* we are now a - b */
+
+ if (BN_ucmp(a,b) < 0)
+ {
+ if (!BN_usub(r,b,a)) return(0);
+ r->neg=1;
+ }
+ else
+ {
+ if (!BN_usub(r,a,b)) return(0);
+ r->neg=0;
+ }
+ return(1);
+ }
+
+ if (a->neg) /* both are neg */
+ r->neg=1;
+ else
+ r->neg=0;
+
+ if (!BN_uadd(r,a,b)) return(0);
+ return(1);
+ }
+
+/* unsigned add of b to a, r must be large enough */
+int BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)
+ {
+ register int i;
+ int max,min;
+ BN_ULONG *ap,*bp,*rp,carry,t1;
+ const BIGNUM *tmp;
+
+ bn_check_top(a);
+ bn_check_top(b);
+
+ if (a->top < b->top)
+ { tmp=a; a=b; b=tmp; }
+ max=a->top;
+ min=b->top;
+
+ if (bn_wexpand(r,max+1) == NULL)
+ return(0);
+
+ r->top=max;
+
+
+ ap=a->d;
+ bp=b->d;
+ rp=r->d;
+ carry=0;
+
+ carry=bn_add_words(rp,ap,bp,min);
+ rp+=min;
+ ap+=min;
+ bp+=min;
+ i=min;
+
+ if (carry)
+ {
+ while (i < max)
+ {
+ i++;
+ t1= *(ap++);
+ if ((*(rp++)=(t1+1)&BN_MASK2) >= t1)
+ {
+ carry=0;
+ break;
+ }
+ }
+ if ((i >= max) && carry)
+ {
+ *(rp++)=1;
+ r->top++;
+ }
+ }
+ if (rp != ap)
+ {
+ for (; i<max; i++)
+ *(rp++)= *(ap++);
+ }
+ /* memcpy(rp,ap,sizeof(*ap)*(max-i));*/
+ return(1);
+ }
+
+/* unsigned subtraction of b from a, a must be larger than b. */
+int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)
+ {
+ int max,min;
+ register BN_ULONG t1,t2,*ap,*bp,*rp;
+ int i,carry;
+#if defined(IRIX_CC_BUG) && !defined(LINT)
+ int dummy;
+#endif
+
+ bn_check_top(a);
+ bn_check_top(b);
+
+ if (a->top < b->top) /* hmm... should not be happening */
+ {
+ return(0);
+ }
+
+ max=a->top;
+ min=b->top;
+ if (bn_wexpand(r,max) == NULL) return(0);
+
+ ap=a->d;
+ bp=b->d;
+ rp=r->d;
+
+#if 1
+ carry=0;
+ for (i=0; i<min; i++)
+ {
+ t1= *(ap++);
+ t2= *(bp++);
+ if (carry)
+ {
+ carry=(t1 <= t2);
+ t1=(t1-t2-1)&BN_MASK2;
+ }
+ else
+ {
+ carry=(t1 < t2);
+ t1=(t1-t2)&BN_MASK2;
+ }
+#if defined(IRIX_CC_BUG) && !defined(LINT)
+ dummy=t1;
+#endif
+ *(rp++)=t1&BN_MASK2;
+ }
+#else
+ carry=bn_sub_words(rp,ap,bp,min);
+ ap+=min;
+ bp+=min;
+ rp+=min;
+ i=min;
+#endif
+ if (carry) /* subtracted */
+ {
+ while (i < max)
+ {
+ i++;
+ t1= *(ap++);
+ t2=(t1-1)&BN_MASK2;
+ *(rp++)=t2;
+ if (t1 > t2) break;
+ }
+ }
+#if 0
+ memcpy(rp,ap,sizeof(*rp)*(max-i));
+#else
+ if (rp != ap)
+ {
+ for (;;)
+ {
+ if (i++ >= max) break;
+ rp[0]=ap[0];
+ if (i++ >= max) break;
+ rp[1]=ap[1];
+ if (i++ >= max) break;
+ rp[2]=ap[2];
+ if (i++ >= max) break;
+ rp[3]=ap[3];
+ rp+=4;
+ ap+=4;
+ }
+ }
+#endif
+
+ r->top=max;
+ bn_fix_top(r);
+ return(1);
+ }
+
+int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)
+ {
+ int max;
+ int add=0,neg=0;
+ const BIGNUM *tmp;
+
+ bn_check_top(a);
+ bn_check_top(b);
+
+ /* a - b a-b
+ * a - -b a+b
+ * -a - b -(a+b)
+ * -a - -b b-a
+ */
+ if (a->neg)
+ {
+ if (b->neg)
+ { tmp=a; a=b; b=tmp; }
+ else
+ { add=1; neg=1; }
+ }
+ else
+ {
+ if (b->neg) { add=1; neg=0; }
+ }
+
+ if (add)
+ {
+ if (!BN_uadd(r,a,b)) return(0);
+ r->neg=neg;
+ return(1);
+ }
+
+ /* We are actually doing a - b :-) */
+
+ max=(a->top > b->top)?a->top:b->top;
+ if (bn_wexpand(r,max) == NULL) return(0);
+ if (BN_ucmp(a,b) < 0)
+ {
+ if (!BN_usub(r,b,a)) return(0);
+ r->neg=1;
+ }
+ else
+ {
+ if (!BN_usub(r,a,b)) return(0);
+ r->neg=0;
+ }
+ return(1);
+ }
+
diff --git a/package/network/services/ead/src/tinysrp/bn_asm.c b/package/network/services/ead/src/tinysrp/bn_asm.c
new file mode 100644
index 0000000..b24c9af
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/bn_asm.c
@@ -0,0 +1,382 @@
+/* crypto/bn/bn_asm.c */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#ifndef BN_DEBUG
+# undef NDEBUG /* avoid conflicting definitions */
+# define NDEBUG
+#endif
+
+#include <stdio.h>
+#include <assert.h>
+#include "bn_lcl.h"
+
+#if defined(BN_LLONG) || defined(BN_UMULT_HIGH)
+
+BN_ULONG bn_mul_add_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w)
+ {
+ BN_ULONG c1=0;
+
+ assert(num >= 0);
+ if (num <= 0) return(c1);
+
+ while (num&~3)
+ {
+ mul_add(rp[0],ap[0],w,c1);
+ mul_add(rp[1],ap[1],w,c1);
+ mul_add(rp[2],ap[2],w,c1);
+ mul_add(rp[3],ap[3],w,c1);
+ ap+=4; rp+=4; num-=4;
+ }
+ if (num)
+ {
+ mul_add(rp[0],ap[0],w,c1); if (--num==0) return c1;
+ mul_add(rp[1],ap[1],w,c1); if (--num==0) return c1;
+ mul_add(rp[2],ap[2],w,c1); return c1;
+ }
+
+ return(c1);
+ }
+
+BN_ULONG bn_mul_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w)
+ {
+ BN_ULONG c1=0;
+
+ assert(num >= 0);
+ if (num <= 0) return(c1);
+
+ while (num&~3)
+ {
+ mul(rp[0],ap[0],w,c1);
+ mul(rp[1],ap[1],w,c1);
+ mul(rp[2],ap[2],w,c1);
+ mul(rp[3],ap[3],w,c1);
+ ap+=4; rp+=4; num-=4;
+ }
+ if (num)
+ {
+ mul(rp[0],ap[0],w,c1); if (--num == 0) return c1;
+ mul(rp[1],ap[1],w,c1); if (--num == 0) return c1;
+ mul(rp[2],ap[2],w,c1);
+ }
+ return(c1);
+ }
+
+void bn_sqr_words(BN_ULONG *r, BN_ULONG *a, int n)
+ {
+ assert(n >= 0);
+ if (n <= 0) return;
+ while (n&~3)
+ {
+ sqr(r[0],r[1],a[0]);
+ sqr(r[2],r[3],a[1]);
+ sqr(r[4],r[5],a[2]);
+ sqr(r[6],r[7],a[3]);
+ a+=4; r+=8; n-=4;
+ }
+ if (n)
+ {
+ sqr(r[0],r[1],a[0]); if (--n == 0) return;
+ sqr(r[2],r[3],a[1]); if (--n == 0) return;
+ sqr(r[4],r[5],a[2]);
+ }
+ }
+
+#else /* !(defined(BN_LLONG) || defined(BN_UMULT_HIGH)) */
+
+BN_ULONG bn_mul_add_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w)
+ {
+ BN_ULONG c=0;
+ BN_ULONG bl,bh;
+
+ assert(num >= 0);
+ if (num <= 0) return((BN_ULONG)0);
+
+ bl=LBITS(w);
+ bh=HBITS(w);
+
+ for (;;)
+ {
+ mul_add(rp[0],ap[0],bl,bh,c);
+ if (--num == 0) break;
+ mul_add(rp[1],ap[1],bl,bh,c);
+ if (--num == 0) break;
+ mul_add(rp[2],ap[2],bl,bh,c);
+ if (--num == 0) break;
+ mul_add(rp[3],ap[3],bl,bh,c);
+ if (--num == 0) break;
+ ap+=4;
+ rp+=4;
+ }
+ return(c);
+ }
+
+BN_ULONG bn_mul_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w)
+ {
+ BN_ULONG carry=0;
+ BN_ULONG bl,bh;
+
+ assert(num >= 0);
+ if (num <= 0) return((BN_ULONG)0);
+
+ bl=LBITS(w);
+ bh=HBITS(w);
+
+ for (;;)
+ {
+ mul(rp[0],ap[0],bl,bh,carry);
+ if (--num == 0) break;
+ mul(rp[1],ap[1],bl,bh,carry);
+ if (--num == 0) break;
+ mul(rp[2],ap[2],bl,bh,carry);
+ if (--num == 0) break;
+ mul(rp[3],ap[3],bl,bh,carry);
+ if (--num == 0) break;
+ ap+=4;
+ rp+=4;
+ }
+ return(carry);
+ }
+
+void bn_sqr_words(BN_ULONG *r, BN_ULONG *a, int n)
+ {
+ assert(n >= 0);
+ if (n <= 0) return;
+ for (;;)
+ {
+ sqr64(r[0],r[1],a[0]);
+ if (--n == 0) break;
+
+ sqr64(r[2],r[3],a[1]);
+ if (--n == 0) break;
+
+ sqr64(r[4],r[5],a[2]);
+ if (--n == 0) break;
+
+ sqr64(r[6],r[7],a[3]);
+ if (--n == 0) break;
+
+ a+=4;
+ r+=8;
+ }
+ }
+
+#endif /* !(defined(BN_LLONG) || defined(BN_UMULT_HIGH)) */
+
+#if defined(BN_LLONG) && defined(BN_DIV2W)
+
+BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d)
+ {
+ return((BN_ULONG)(((((BN_ULLONG)h)<<BN_BITS2)|l)/(BN_ULLONG)d));
+ }
+
+#else
+
+/* Divide h,l by d and return the result. */
+/* I need to test this some more :-( */
+BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d)
+ {
+ BN_ULONG dh,dl,q,ret=0,th,tl,t;
+ int i,count=2;
+
+ if (d == 0) return(BN_MASK2);
+
+ i=BN_num_bits_word(d);
+ assert((i == BN_BITS2) || (h > (BN_ULONG)1<<i));
+
+ i=BN_BITS2-i;
+ if (h >= d) h-=d;
+
+ if (i)
+ {
+ d<<=i;
+ h=(h<<i)|(l>>(BN_BITS2-i));
+ l<<=i;
+ }
+ dh=(d&BN_MASK2h)>>BN_BITS4;
+ dl=(d&BN_MASK2l);
+ for (;;)
+ {
+ if ((h>>BN_BITS4) == dh)
+ q=BN_MASK2l;
+ else
+ q=h/dh;
+
+ th=q*dh;
+ tl=dl*q;
+ for (;;)
+ {
+ t=h-th;
+ if ((t&BN_MASK2h) ||
+ ((tl) <= (
+ (t<<BN_BITS4)|
+ ((l&BN_MASK2h)>>BN_BITS4))))
+ break;
+ q--;
+ th-=dh;
+ tl-=dl;
+ }
+ t=(tl>>BN_BITS4);
+ tl=(tl<<BN_BITS4)&BN_MASK2h;
+ th+=t;
+
+ if (l < tl) th++;
+ l-=tl;
+ if (h < th)
+ {
+ h+=d;
+ q--;
+ }
+ h-=th;
+
+ if (--count == 0) break;
+
+ ret=q<<BN_BITS4;
+ h=((h<<BN_BITS4)|(l>>BN_BITS4))&BN_MASK2;
+ l=(l&BN_MASK2l)<<BN_BITS4;
+ }
+ ret|=q;
+ return(ret);
+ }
+#endif /* !defined(BN_LLONG) && defined(BN_DIV2W) */
+
+#ifdef BN_LLONG
+BN_ULONG bn_add_words(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n)
+ {
+ BN_ULLONG ll=0;
+
+ assert(n >= 0);
+ if (n <= 0) return((BN_ULONG)0);
+
+ for (;;)
+ {
+ ll+=(BN_ULLONG)a[0]+b[0];
+ r[0]=(BN_ULONG)ll&BN_MASK2;
+ ll>>=BN_BITS2;
+ if (--n <= 0) break;
+
+ ll+=(BN_ULLONG)a[1]+b[1];
+ r[1]=(BN_ULONG)ll&BN_MASK2;
+ ll>>=BN_BITS2;
+ if (--n <= 0) break;
+
+ ll+=(BN_ULLONG)a[2]+b[2];
+ r[2]=(BN_ULONG)ll&BN_MASK2;
+ ll>>=BN_BITS2;
+ if (--n <= 0) break;
+
+ ll+=(BN_ULLONG)a[3]+b[3];
+ r[3]=(BN_ULONG)ll&BN_MASK2;
+ ll>>=BN_BITS2;
+ if (--n <= 0) break;
+
+ a+=4;
+ b+=4;
+ r+=4;
+ }
+ return((BN_ULONG)ll);
+ }
+#else /* !BN_LLONG */
+BN_ULONG bn_add_words(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n)
+ {
+ BN_ULONG c,l,t;
+
+ assert(n >= 0);
+ if (n <= 0) return((BN_ULONG)0);
+
+ c=0;
+ for (;;)
+ {
+ t=a[0];
+ t=(t+c)&BN_MASK2;
+ c=(t < c);
+ l=(t+b[0])&BN_MASK2;
+ c+=(l < t);
+ r[0]=l;
+ if (--n <= 0) break;
+
+ t=a[1];
+ t=(t+c)&BN_MASK2;
+ c=(t < c);
+ l=(t+b[1])&BN_MASK2;
+ c+=(l < t);
+ r[1]=l;
+ if (--n <= 0) break;
+
+ t=a[2];
+ t=(t+c)&BN_MASK2;
+ c=(t < c);
+ l=(t+b[2])&BN_MASK2;
+ c+=(l < t);
+ r[2]=l;
+ if (--n <= 0) break;
+
+ t=a[3];
+ t=(t+c)&BN_MASK2;
+ c=(t < c);
+ l=(t+b[3])&BN_MASK2;
+ c+=(l < t);
+ r[3]=l;
+ if (--n <= 0) break;
+
+ a+=4;
+ b+=4;
+ r+=4;
+ }
+ return((BN_ULONG)c);
+ }
+#endif /* !BN_LLONG */
diff --git a/package/network/services/ead/src/tinysrp/bn_ctx.c b/package/network/services/ead/src/tinysrp/bn_ctx.c
new file mode 100644
index 0000000..20a6605
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/bn_ctx.c
@@ -0,0 +1,142 @@
+/* crypto/bn/bn_ctx.c */
+/* Written by Ulf Moeller for the OpenSSL project. */
+/* ====================================================================
+ * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
+ *
+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
+ * endorse or promote products derived from this software without
+ * prior written permission. For written permission, please contact
+ * openssl-core@openssl.org.
+ *
+ * 5. Products derived from this software may not be called "OpenSSL"
+ * nor may "OpenSSL" appear in their names without prior written
+ * permission of the OpenSSL Project.
+ *
+ * 6. Redistributions of any form whatsoever must retain the following
+ * acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
+ * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This product includes cryptographic software written by Eric Young
+ * (eay@cryptsoft.com). This product includes software written by Tim
+ * Hudson (tjh@cryptsoft.com).
+ *
+ */
+
+#ifndef BN_CTX_DEBUG
+# undef NDEBUG /* avoid conflicting definitions */
+# define NDEBUG
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <bn.h>
+
+
+BN_CTX *BN_CTX_new(void)
+ {
+ BN_CTX *ret;
+
+ ret=(BN_CTX *)malloc(sizeof(BN_CTX));
+ if (ret == NULL)
+ {
+ return(NULL);
+ }
+
+ BN_CTX_init(ret);
+ ret->flags=BN_FLG_MALLOCED;
+ return(ret);
+ }
+
+void BN_CTX_init(BN_CTX *ctx)
+ {
+ int i;
+ ctx->tos = 0;
+ ctx->flags = 0;
+ ctx->depth = 0;
+ ctx->too_many = 0;
+ for (i = 0; i < BN_CTX_NUM; i++)
+ BN_init(&(ctx->bn[i]));
+ }
+
+void BN_CTX_free(BN_CTX *ctx)
+ {
+ int i;
+
+ if (ctx == NULL) return;
+ assert(ctx->depth == 0);
+
+ for (i=0; i < BN_CTX_NUM; i++)
+ BN_clear_free(&(ctx->bn[i]));
+ if (ctx->flags & BN_FLG_MALLOCED)
+ free(ctx);
+ }
+
+void BN_CTX_start(BN_CTX *ctx)
+ {
+ if (ctx->depth < BN_CTX_NUM_POS)
+ ctx->pos[ctx->depth] = ctx->tos;
+ ctx->depth++;
+ }
+
+BIGNUM *BN_CTX_get(BN_CTX *ctx)
+ {
+ if (ctx->depth > BN_CTX_NUM_POS || ctx->tos >= BN_CTX_NUM)
+ {
+ if (!ctx->too_many)
+ {
+ /* disable error code until BN_CTX_end is called: */
+ ctx->too_many = 1;
+ }
+ return NULL;
+ }
+ return (&(ctx->bn[ctx->tos++]));
+ }
+
+void BN_CTX_end(BN_CTX *ctx)
+ {
+ if (ctx == NULL) return;
+ assert(ctx->depth > 0);
+ if (ctx->depth == 0)
+ /* should never happen, but we can tolerate it if not in
+ * debug mode (could be a 'goto err' in the calling function
+ * before BN_CTX_start was reached) */
+ BN_CTX_start(ctx);
+
+ ctx->too_many = 0;
+ ctx->depth--;
+ if (ctx->depth < BN_CTX_NUM_POS)
+ ctx->tos = ctx->pos[ctx->depth];
+ }
diff --git a/package/network/services/ead/src/tinysrp/bn_div.c b/package/network/services/ead/src/tinysrp/bn_div.c
new file mode 100644
index 0000000..fd21913
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/bn_div.c
@@ -0,0 +1,378 @@
+/* crypto/bn/bn_div.c */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#include <stdio.h>
+#include "bn_lcl.h"
+
+#define NO_ASM
+
+/* The old slow way */
+#if 0
+int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d,
+ BN_CTX *ctx)
+ {
+ int i,nm,nd;
+ int ret = 0;
+ BIGNUM *D;
+
+ bn_check_top(m);
+ bn_check_top(d);
+ if (BN_is_zero(d))
+ {
+ return(0);
+ }
+
+ if (BN_ucmp(m,d) < 0)
+ {
+ if (rem != NULL)
+ { if (BN_copy(rem,m) == NULL) return(0); }
+ if (dv != NULL) BN_zero(dv);
+ return(1);
+ }
+
+ BN_CTX_start(ctx);
+ D = BN_CTX_get(ctx);
+ if (dv == NULL) dv = BN_CTX_get(ctx);
+ if (rem == NULL) rem = BN_CTX_get(ctx);
+ if (D == NULL || dv == NULL || rem == NULL)
+ goto end;
+
+ nd=BN_num_bits(d);
+ nm=BN_num_bits(m);
+ if (BN_copy(D,d) == NULL) goto end;
+ if (BN_copy(rem,m) == NULL) goto end;
+
+ /* The next 2 are needed so we can do a dv->d[0]|=1 later
+ * since BN_lshift1 will only work once there is a value :-) */
+ BN_zero(dv);
+ bn_wexpand(dv,1);
+ dv->top=1;
+
+ if (!BN_lshift(D,D,nm-nd)) goto end;
+ for (i=nm-nd; i>=0; i--)
+ {
+ if (!BN_lshift1(dv,dv)) goto end;
+ if (BN_ucmp(rem,D) >= 0)
+ {
+ dv->d[0]|=1;
+ if (!BN_usub(rem,rem,D)) goto end;
+ }
+/* CAN IMPROVE (and have now :=) */
+ if (!BN_rshift1(D,D)) goto end;
+ }
+ rem->neg=BN_is_zero(rem)?0:m->neg;
+ dv->neg=m->neg^d->neg;
+ ret = 1;
+ end:
+ BN_CTX_end(ctx);
+ return(ret);
+ }
+
+#else
+
+#if !defined(NO_ASM) && !defined(NO_INLINE_ASM) && !defined(PEDANTIC) && !defined(BN_DIV3W)
+# if defined(__GNUC__) && __GNUC__>=2
+# if defined(__i386)
+ /*
+ * There were two reasons for implementing this template:
+ * - GNU C generates a call to a function (__udivdi3 to be exact)
+ * in reply to ((((BN_ULLONG)n0)<<BN_BITS2)|n1)/d0 (I fail to
+ * understand why...);
+ * - divl doesn't only calculate quotient, but also leaves
+ * remainder in %edx which we can definitely use here:-)
+ *
+ * <appro@fy.chalmers.se>
+ */
+# define bn_div_words(n0,n1,d0) \
+ ({ asm volatile ( \
+ "divl %4" \
+ : "=a"(q), "=d"(rem) \
+ : "a"(n1), "d"(n0), "g"(d0) \
+ : "cc"); \
+ q; \
+ })
+# define REMAINDER_IS_ALREADY_CALCULATED
+# endif /* __<cpu> */
+# endif /* __GNUC__ */
+#endif /* NO_ASM */
+
+int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
+ BN_CTX *ctx)
+ {
+ int norm_shift,i,j,loop;
+ BIGNUM *tmp,wnum,*snum,*sdiv,*res;
+ BN_ULONG *resp,*wnump;
+ BN_ULONG d0,d1;
+ int num_n,div_n;
+
+ bn_check_top(num);
+ bn_check_top(divisor);
+
+ if (BN_is_zero(divisor))
+ {
+ return(0);
+ }
+
+ if (BN_ucmp(num,divisor) < 0)
+ {
+ if (rm != NULL)
+ { if (BN_copy(rm,num) == NULL) return(0); }
+ if (dv != NULL) BN_zero(dv);
+ return(1);
+ }
+
+ BN_CTX_start(ctx);
+ tmp=BN_CTX_get(ctx);
+ tmp->neg=0;
+ snum=BN_CTX_get(ctx);
+ sdiv=BN_CTX_get(ctx);
+ if (dv == NULL)
+ res=BN_CTX_get(ctx);
+ else res=dv;
+ if (res == NULL) goto err;
+
+ /* First we normalise the numbers */
+ norm_shift=BN_BITS2-((BN_num_bits(divisor))%BN_BITS2);
+ BN_lshift(sdiv,divisor,norm_shift);
+ sdiv->neg=0;
+ norm_shift+=BN_BITS2;
+ BN_lshift(snum,num,norm_shift);
+ snum->neg=0;
+ div_n=sdiv->top;
+ num_n=snum->top;
+ loop=num_n-div_n;
+
+ /* Lets setup a 'window' into snum
+ * This is the part that corresponds to the current
+ * 'area' being divided */
+ BN_init(&wnum);
+ wnum.d= &(snum->d[loop]);
+ wnum.top= div_n;
+ wnum.dmax= snum->dmax+1; /* a bit of a lie */
+
+ /* Get the top 2 words of sdiv */
+ /* i=sdiv->top; */
+ d0=sdiv->d[div_n-1];
+ d1=(div_n == 1)?0:sdiv->d[div_n-2];
+
+ /* pointer to the 'top' of snum */
+ wnump= &(snum->d[num_n-1]);
+
+ /* Setup to 'res' */
+ res->neg= (num->neg^divisor->neg);
+ if (!bn_wexpand(res,(loop+1))) goto err;
+ res->top=loop;
+ resp= &(res->d[loop-1]);
+
+ /* space for temp */
+ if (!bn_wexpand(tmp,(div_n+1))) goto err;
+
+ if (BN_ucmp(&wnum,sdiv) >= 0)
+ {
+ if (!BN_usub(&wnum,&wnum,sdiv)) goto err;
+ *resp=1;
+ res->d[res->top-1]=1;
+ }
+ else
+ res->top--;
+ resp--;
+
+ for (i=0; i<loop-1; i++)
+ {
+ BN_ULONG q,l0;
+#ifdef BN_DIV3W
+ q=bn_div_3_words(wnump,d1,d0);
+#else
+ BN_ULONG n0,n1,rem=0;
+
+ n0=wnump[0];
+ n1=wnump[-1];
+ if (n0 == d0)
+ q=BN_MASK2;
+ else /* n0 < d0 */
+ {
+#ifdef BN_LLONG
+ BN_ULLONG t2;
+
+#if defined(BN_LLONG) && defined(BN_DIV2W) && !defined(bn_div_words)
+ q=(BN_ULONG)(((((BN_ULLONG)n0)<<BN_BITS2)|n1)/d0);
+#else
+ q=bn_div_words(n0,n1,d0);
+#endif
+
+#ifndef REMAINDER_IS_ALREADY_CALCULATED
+ /*
+ * rem doesn't have to be BN_ULLONG. The least we
+ * know it's less that d0, isn't it?
+ */
+ rem=(n1-q*d0)&BN_MASK2;
+#endif
+ t2=(BN_ULLONG)d1*q;
+
+ for (;;)
+ {
+ if (t2 <= ((((BN_ULLONG)rem)<<BN_BITS2)|wnump[-2]))
+ break;
+ q--;
+ rem += d0;
+ if (rem < d0) break; /* don't let rem overflow */
+ t2 -= d1;
+ }
+#else /* !BN_LLONG */
+ BN_ULONG t2l,t2h,ql,qh;
+
+ q=bn_div_words(n0,n1,d0);
+#ifndef REMAINDER_IS_ALREADY_CALCULATED
+ rem=(n1-q*d0)&BN_MASK2;
+#endif
+
+#ifdef BN_UMULT_HIGH
+ t2l = d1 * q;
+ t2h = BN_UMULT_HIGH(d1,q);
+#else
+ t2l=LBITS(d1); t2h=HBITS(d1);
+ ql =LBITS(q); qh =HBITS(q);
+ mul64(t2l,t2h,ql,qh); /* t2=(BN_ULLONG)d1*q; */
+#endif
+
+ for (;;)
+ {
+ if ((t2h < rem) ||
+ ((t2h == rem) && (t2l <= wnump[-2])))
+ break;
+ q--;
+ rem += d0;
+ if (rem < d0) break; /* don't let rem overflow */
+ if (t2l < d1) t2h--; t2l -= d1;
+ }
+#endif /* !BN_LLONG */
+ }
+#endif /* !BN_DIV3W */
+
+ l0=bn_mul_words(tmp->d,sdiv->d,div_n,q);
+ wnum.d--; wnum.top++;
+ tmp->d[div_n]=l0;
+ for (j=div_n+1; j>0; j--)
+ if (tmp->d[j-1]) break;
+ tmp->top=j;
+
+ j=wnum.top;
+ BN_sub(&wnum,&wnum,tmp);
+
+ snum->top=snum->top+wnum.top-j;
+
+ if (wnum.neg)
+ {
+ q--;
+ j=wnum.top;
+ BN_add(&wnum,&wnum,sdiv);
+ snum->top+=wnum.top-j;
+ }
+ *(resp--)=q;
+ wnump--;
+ }
+ if (rm != NULL)
+ {
+ BN_rshift(rm,snum,norm_shift);
+ rm->neg=num->neg;
+ }
+ BN_CTX_end(ctx);
+ return(1);
+err:
+ BN_CTX_end(ctx);
+ return(0);
+ }
+
+#endif
+
+/* rem != m */
+int BN_mod(BIGNUM *rem, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx)
+ {
+#if 0 /* The old slow way */
+ int i,nm,nd;
+ BIGNUM *dv;
+
+ if (BN_ucmp(m,d) < 0)
+ return((BN_copy(rem,m) == NULL)?0:1);
+
+ BN_CTX_start(ctx);
+ dv=BN_CTX_get(ctx);
+
+ if (!BN_copy(rem,m)) goto err;
+
+ nm=BN_num_bits(rem);
+ nd=BN_num_bits(d);
+ if (!BN_lshift(dv,d,nm-nd)) goto err;
+ for (i=nm-nd; i>=0; i--)
+ {
+ if (BN_cmp(rem,dv) >= 0)
+ {
+ if (!BN_sub(rem,rem,dv)) goto err;
+ }
+ if (!BN_rshift1(dv,dv)) goto err;
+ }
+ BN_CTX_end(ctx);
+ return(1);
+ err:
+ BN_CTX_end(ctx);
+ return(0);
+#else
+ return(BN_div(NULL,rem,m,d,ctx));
+#endif
+ }
+
diff --git a/package/network/services/ead/src/tinysrp/bn_exp.c b/package/network/services/ead/src/tinysrp/bn_exp.c
new file mode 100644
index 0000000..09afb79
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/bn_exp.c
@@ -0,0 +1,395 @@
+/* crypto/bn/bn_exp.c */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+/* ====================================================================
+ * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
+ *
+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
+ * endorse or promote products derived from this software without
+ * prior written permission. For written permission, please contact
+ * openssl-core@openssl.org.
+ *
+ * 5. Products derived from this software may not be called "OpenSSL"
+ * nor may "OpenSSL" appear in their names without prior written
+ * permission of the OpenSSL Project.
+ *
+ * 6. Redistributions of any form whatsoever must retain the following
+ * acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
+ * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This product includes cryptographic software written by Eric Young
+ * (eay@cryptsoft.com). This product includes software written by Tim
+ * Hudson (tjh@cryptsoft.com).
+ *
+ */
+
+
+#include <stdio.h>
+#include "bn_lcl.h"
+
+#define TABLE_SIZE 32
+
+/* slow but works */
+int BN_mod_mul(BIGNUM *ret, BIGNUM *a, BIGNUM *b, const BIGNUM *m, BN_CTX *ctx)
+ {
+ BIGNUM *t;
+ int r=0;
+
+ bn_check_top(a);
+ bn_check_top(b);
+ bn_check_top(m);
+
+ BN_CTX_start(ctx);
+ if ((t = BN_CTX_get(ctx)) == NULL) goto err;
+ if (a == b)
+ { if (!BN_sqr(t,a,ctx)) goto err; }
+ else
+ { if (!BN_mul(t,a,b,ctx)) goto err; }
+ if (!BN_mod(ret,t,m,ctx)) goto err;
+ r=1;
+err:
+ BN_CTX_end(ctx);
+ return(r);
+ }
+
+int BN_mod_exp(BIGNUM *r, BIGNUM *a, const BIGNUM *p, const BIGNUM *m,
+ BN_CTX *ctx)
+ {
+ int ret;
+
+ bn_check_top(a);
+ bn_check_top(p);
+ bn_check_top(m);
+
+#ifdef MONT_MUL_MOD
+ /* I have finally been able to take out this pre-condition of
+ * the top bit being set. It was caused by an error in BN_div
+ * with negatives. There was also another problem when for a^b%m
+ * a >= m. eay 07-May-97 */
+/* if ((m->d[m->top-1]&BN_TBIT) && BN_is_odd(m)) */
+
+ if (BN_is_odd(m))
+ {
+ if (a->top == 1)
+ {
+ BN_ULONG A = a->d[0];
+ ret=BN_mod_exp_mont_word(r,A,p,m,ctx,NULL);
+ }
+ else
+ ret=BN_mod_exp_mont(r,a,p,m,ctx,NULL);
+ }
+ else
+#endif
+#ifdef RECP_MUL_MOD
+ { ret=BN_mod_exp_recp(r,a,p,m,ctx); }
+#else
+ { ret=BN_mod_exp_simple(r,a,p,m,ctx); }
+#endif
+
+ return(ret);
+ }
+
+
+#ifdef RECP_MUL_MOD
+int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
+ const BIGNUM *m, BN_CTX *ctx)
+ {
+ int i,j,bits,ret=0,wstart,wend,window,wvalue;
+ int start=1,ts=0;
+ BIGNUM *aa;
+ BIGNUM val[TABLE_SIZE];
+ BN_RECP_CTX recp;
+
+ bits=BN_num_bits(p);
+
+ if (bits == 0)
+ {
+ BN_one(r);
+ return(1);
+ }
+
+ BN_CTX_start(ctx);
+ if ((aa = BN_CTX_get(ctx)) == NULL) goto err;
+
+ BN_RECP_CTX_init(&recp);
+ if (BN_RECP_CTX_set(&recp,m,ctx) <= 0) goto err;
+
+ BN_init(&(val[0]));
+ ts=1;
+
+ if (!BN_mod(&(val[0]),a,m,ctx)) goto err; /* 1 */
+
+ window = BN_window_bits_for_exponent_size(bits);
+ if (window > 1)
+ {
+ if (!BN_mod_mul_reciprocal(aa,&(val[0]),&(val[0]),&recp,ctx))
+ goto err; /* 2 */
+ j=1<<(window-1);
+ for (i=1; i<j; i++)
+ {
+ BN_init(&val[i]);
+ if (!BN_mod_mul_reciprocal(&(val[i]),&(val[i-1]),aa,&recp,ctx))
+ goto err;
+ }
+ ts=i;
+ }
+
+ start=1; /* This is used to avoid multiplication etc
+ * when there is only the value '1' in the
+ * buffer. */
+ wvalue=0; /* The 'value' of the window */
+ wstart=bits-1; /* The top bit of the window */
+ wend=0; /* The bottom bit of the window */
+
+ if (!BN_one(r)) goto err;
+
+ for (;;)
+ {
+ if (BN_is_bit_set(p,wstart) == 0)
+ {
+ if (!start)
+ if (!BN_mod_mul_reciprocal(r,r,r,&recp,ctx))
+ goto err;
+ if (wstart == 0) break;
+ wstart--;
+ continue;
+ }
+ /* We now have wstart on a 'set' bit, we now need to work out
+ * how bit a window to do. To do this we need to scan
+ * forward until the last set bit before the end of the
+ * window */
+ j=wstart;
+ wvalue=1;
+ wend=0;
+ for (i=1; i<window; i++)
+ {
+ if (wstart-i < 0) break;
+ if (BN_is_bit_set(p,wstart-i))
+ {
+ wvalue<<=(i-wend);
+ wvalue|=1;
+ wend=i;
+ }
+ }
+
+ /* wend is the size of the current window */
+ j=wend+1;
+ /* add the 'bytes above' */
+ if (!start)
+ for (i=0; i<j; i++)
+ {
+ if (!BN_mod_mul_reciprocal(r,r,r,&recp,ctx))
+ goto err;
+ }
+
+ /* wvalue will be an odd number < 2^window */
+ if (!BN_mod_mul_reciprocal(r,r,&(val[wvalue>>1]),&recp,ctx))
+ goto err;
+
+ /* move the 'window' down further */
+ wstart-=wend+1;
+ wvalue=0;
+ start=0;
+ if (wstart < 0) break;
+ }
+ ret=1;
+err:
+ BN_CTX_end(ctx);
+ for (i=0; i<ts; i++)
+ BN_clear_free(&(val[i]));
+ BN_RECP_CTX_free(&recp);
+ return(ret);
+ }
+#else
+
+/* The old fallback, simple version :-) */
+int BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
+ const BIGNUM *m, BN_CTX *ctx)
+ {
+ int i,j,bits,ret=0,wstart,wend,window,wvalue,ts=0;
+ int start=1;
+ BIGNUM *d;
+ BIGNUM val[TABLE_SIZE];
+
+ bits=BN_num_bits(p);
+
+ if (bits == 0)
+ {
+ BN_one(r);
+ return(1);
+ }
+
+ BN_CTX_start(ctx);
+ if ((d = BN_CTX_get(ctx)) == NULL) goto err;
+
+ BN_init(&(val[0]));
+ ts=1;
+ if (!BN_mod(&(val[0]),a,m,ctx)) goto err; /* 1 */
+
+ window = BN_window_bits_for_exponent_size(bits);
+ if (window > 1)
+ {
+ if (!BN_mod_mul(d,&(val[0]),&(val[0]),m,ctx))
+ goto err; /* 2 */
+ j=1<<(window-1);
+ for (i=1; i<j; i++)
+ {
+ BN_init(&(val[i]));
+ if (!BN_mod_mul(&(val[i]),&(val[i-1]),d,m,ctx))
+ goto err;
+ }
+ ts=i;
+ }
+
+ start=1; /* This is used to avoid multiplication etc
+ * when there is only the value '1' in the
+ * buffer. */
+ wvalue=0; /* The 'value' of the window */
+ wstart=bits-1; /* The top bit of the window */
+ wend=0; /* The bottom bit of the window */
+
+ if (!BN_one(r)) goto err;
+
+ for (;;)
+ {
+ if (BN_is_bit_set(p,wstart) == 0)
+ {
+ if (!start)
+ if (!BN_mod_mul(r,r,r,m,ctx))
+ goto err;
+ if (wstart == 0) break;
+ wstart--;
+ continue;
+ }
+ /* We now have wstart on a 'set' bit, we now need to work out
+ * how bit a window to do. To do this we need to scan
+ * forward until the last set bit before the end of the
+ * window */
+ j=wstart;
+ wvalue=1;
+ wend=0;
+ for (i=1; i<window; i++)
+ {
+ if (wstart-i < 0) break;
+ if (BN_is_bit_set(p,wstart-i))
+ {
+ wvalue<<=(i-wend);
+ wvalue|=1;
+ wend=i;
+ }
+ }
+
+ /* wend is the size of the current window */
+ j=wend+1;
+ /* add the 'bytes above' */
+ if (!start)
+ for (i=0; i<j; i++)
+ {
+ if (!BN_mod_mul(r,r,r,m,ctx))
+ goto err;
+ }
+
+ /* wvalue will be an odd number < 2^window */
+ if (!BN_mod_mul(r,r,&(val[wvalue>>1]),m,ctx))
+ goto err;
+
+ /* move the 'window' down further */
+ wstart-=wend+1;
+ wvalue=0;
+ start=0;
+ if (wstart < 0) break;
+ }
+ ret=1;
+err:
+ BN_CTX_end(ctx);
+ for (i=0; i<ts; i++)
+ BN_clear_free(&(val[i]));
+ return(ret);
+ }
+#endif
diff --git a/package/network/services/ead/src/tinysrp/bn_lcl.h b/package/network/services/ead/src/tinysrp/bn_lcl.h
new file mode 100644
index 0000000..129ad65
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/bn_lcl.h
@@ -0,0 +1,419 @@
+/* crypto/bn/bn_lcl.h */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+/* ====================================================================
+ * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
+ *
+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
+ * endorse or promote products derived from this software without
+ * prior written permission. For written permission, please contact
+ * openssl-core@openssl.org.
+ *
+ * 5. Products derived from this software may not be called "OpenSSL"
+ * nor may "OpenSSL" appear in their names without prior written
+ * permission of the OpenSSL Project.
+ *
+ * 6. Redistributions of any form whatsoever must retain the following
+ * acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
+ * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This product includes cryptographic software written by Eric Young
+ * (eay@cryptsoft.com). This product includes software written by Tim
+ * Hudson (tjh@cryptsoft.com).
+ *
+ */
+
+#ifndef HEADER_BN_LCL_H
+#define HEADER_BN_LCL_H
+
+#include <bn.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/*
+ * BN_window_bits_for_exponent_size -- macro for sliding window mod_exp functions
+ *
+ *
+ * For window size 'w' (w >= 2) and a random 'b' bits exponent,
+ * the number of multiplications is a constant plus on average
+ *
+ * 2^(w-1) + (b-w)/(w+1);
+ *
+ * here 2^(w-1) is for precomputing the table (we actually need
+ * entries only for windows that have the lowest bit set), and
+ * (b-w)/(w+1) is an approximation for the expected number of
+ * w-bit windows, not counting the first one.
+ *
+ * Thus we should use
+ *
+ * w >= 6 if b > 671
+ * w = 5 if 671 > b > 239
+ * w = 4 if 239 > b > 79
+ * w = 3 if 79 > b > 23
+ * w <= 2 if 23 > b
+ *
+ * (with draws in between). Very small exponents are often selected
+ * with low Hamming weight, so we use w = 1 for b <= 23.
+ */
+#if 1
+#define BN_window_bits_for_exponent_size(b) \
+ ((b) > 671 ? 6 : \
+ (b) > 239 ? 5 : \
+ (b) > 79 ? 4 : \
+ (b) > 23 ? 3 : 1)
+#else
+/* Old SSLeay/OpenSSL table.
+ * Maximum window size was 5, so this table differs for b==1024;
+ * but it coincides for other interesting values (b==160, b==512).
+ */
+#define BN_window_bits_for_exponent_size(b) \
+ ((b) > 255 ? 5 : \
+ (b) > 127 ? 4 : \
+ (b) > 17 ? 3 : 1)
+#endif
+
+
+
+/* Pentium pro 16,16,16,32,64 */
+/* Alpha 16,16,16,16.64 */
+#define BN_MULL_SIZE_NORMAL (16) /* 32 */
+#define BN_MUL_RECURSIVE_SIZE_NORMAL (16) /* 32 less than */
+#define BN_SQR_RECURSIVE_SIZE_NORMAL (16) /* 32 */
+#define BN_MUL_LOW_RECURSIVE_SIZE_NORMAL (32) /* 32 */
+#define BN_MONT_CTX_SET_SIZE_WORD (64) /* 32 */
+
+#if !defined(NO_ASM) && !defined(NO_INLINE_ASM) && !defined(PEDANTIC)
+/*
+ * BN_UMULT_HIGH section.
+ *
+ * No, I'm not trying to overwhelm you when stating that the
+ * product of N-bit numbers is 2*N bits wide:-) No, I don't expect
+ * you to be impressed when I say that if the compiler doesn't
+ * support 2*N integer type, then you have to replace every N*N
+ * multiplication with 4 (N/2)*(N/2) accompanied by some shifts
+ * and additions which unavoidably results in severe performance
+ * penalties. Of course provided that the hardware is capable of
+ * producing 2*N result... That's when you normally start
+ * considering assembler implementation. However! It should be
+ * pointed out that some CPUs (most notably Alpha, PowerPC and
+ * upcoming IA-64 family:-) provide *separate* instruction
+ * calculating the upper half of the product placing the result
+ * into a general purpose register. Now *if* the compiler supports
+ * inline assembler, then it's not impossible to implement the
+ * "bignum" routines (and have the compiler optimize 'em)
+ * exhibiting "native" performance in C. That's what BN_UMULT_HIGH
+ * macro is about:-)
+ *
+ * <appro@fy.chalmers.se>
+ */
+# if defined(__alpha) && (defined(SIXTY_FOUR_BIT_LONG) || defined(SIXTY_FOUR_BIT))
+# if defined(__DECC)
+# include <c_asm.h>
+# define BN_UMULT_HIGH(a,b) (BN_ULONG)asm("umulh %a0,%a1,%v0",(a),(b))
+# elif defined(__GNUC__)
+# define BN_UMULT_HIGH(a,b) ({ \
+ register BN_ULONG ret; \
+ asm ("umulh %1,%2,%0" \
+ : "=r"(ret) \
+ : "r"(a), "r"(b)); \
+ ret; })
+# endif /* compiler */
+# elif defined(_ARCH_PPC) && defined(__64BIT__) && defined(SIXTY_FOUR_BIT_LONG)
+# if defined(__GNUC__)
+# define BN_UMULT_HIGH(a,b) ({ \
+ register BN_ULONG ret; \
+ asm ("mulhdu %0,%1,%2" \
+ : "=r"(ret) \
+ : "r"(a), "r"(b)); \
+ ret; })
+# endif /* compiler */
+# endif /* cpu */
+#endif /* NO_ASM */
+
+/*************************************************************
+ * Using the long long type
+ */
+#define Lw(t) (((BN_ULONG)(t))&BN_MASK2)
+#define Hw(t) (((BN_ULONG)((t)>>BN_BITS2))&BN_MASK2)
+
+/* This is used for internal error checking and is not normally used */
+#ifdef BN_DEBUG
+# include <assert.h>
+# define bn_check_top(a) assert ((a)->top >= 0 && (a)->top <= (a)->dmax);
+#else
+# define bn_check_top(a)
+#endif
+
+/* This macro is to add extra stuff for development checking */
+#ifdef BN_DEBUG
+#define bn_set_max(r) ((r)->max=(r)->top,BN_set_flags((r),BN_FLG_STATIC_DATA))
+#else
+#define bn_set_max(r)
+#endif
+
+/* These macros are used to 'take' a section of a bignum for read only use */
+#define bn_set_low(r,a,n) \
+ { \
+ (r)->top=((a)->top > (n))?(n):(a)->top; \
+ (r)->d=(a)->d; \
+ (r)->neg=(a)->neg; \
+ (r)->flags|=BN_FLG_STATIC_DATA; \
+ bn_set_max(r); \
+ }
+
+#define bn_set_high(r,a,n) \
+ { \
+ if ((a)->top > (n)) \
+ { \
+ (r)->top=(a)->top-n; \
+ (r)->d= &((a)->d[n]); \
+ } \
+ else \
+ (r)->top=0; \
+ (r)->neg=(a)->neg; \
+ (r)->flags|=BN_FLG_STATIC_DATA; \
+ bn_set_max(r); \
+ }
+
+#ifdef BN_LLONG
+#define mul_add(r,a,w,c) { \
+ BN_ULLONG t; \
+ t=(BN_ULLONG)w * (a) + (r) + (c); \
+ (r)= Lw(t); \
+ (c)= Hw(t); \
+ }
+
+#define mul(r,a,w,c) { \
+ BN_ULLONG t; \
+ t=(BN_ULLONG)w * (a) + (c); \
+ (r)= Lw(t); \
+ (c)= Hw(t); \
+ }
+
+#define sqr(r0,r1,a) { \
+ BN_ULLONG t; \
+ t=(BN_ULLONG)(a)*(a); \
+ (r0)=Lw(t); \
+ (r1)=Hw(t); \
+ }
+
+#elif defined(BN_UMULT_HIGH)
+#define mul_add(r,a,w,c) { \
+ BN_ULONG high,low,ret,tmp=(a); \
+ ret = (r); \
+ high= BN_UMULT_HIGH(w,tmp); \
+ ret += (c); \
+ low = (w) * tmp; \
+ (c) = (ret<(c))?1:0; \
+ (c) += high; \
+ ret += low; \
+ (c) += (ret<low)?1:0; \
+ (r) = ret; \
+ }
+
+#define mul(r,a,w,c) { \
+ BN_ULONG high,low,ret,ta=(a); \
+ low = (w) * ta; \
+ high= BN_UMULT_HIGH(w,ta); \
+ ret = low + (c); \
+ (c) = high; \
+ (c) += (ret<low)?1:0; \
+ (r) = ret; \
+ }
+
+#define sqr(r0,r1,a) { \
+ BN_ULONG tmp=(a); \
+ (r0) = tmp * tmp; \
+ (r1) = BN_UMULT_HIGH(tmp,tmp); \
+ }
+
+#else
+/*************************************************************
+ * No long long type
+ */
+
+#define LBITS(a) ((a)&BN_MASK2l)
+#define HBITS(a) (((a)>>BN_BITS4)&BN_MASK2l)
+#define L2HBITS(a) ((BN_ULONG)((a)&BN_MASK2l)<<BN_BITS4)
+
+#define LLBITS(a) ((a)&BN_MASKl)
+#define LHBITS(a) (((a)>>BN_BITS2)&BN_MASKl)
+#define LL2HBITS(a) ((BN_ULLONG)((a)&BN_MASKl)<<BN_BITS2)
+
+#define mul64(l,h,bl,bh) \
+ { \
+ BN_ULONG m,m1,lt,ht; \
+ \
+ lt=l; \
+ ht=h; \
+ m =(bh)*(lt); \
+ lt=(bl)*(lt); \
+ m1=(bl)*(ht); \
+ ht =(bh)*(ht); \
+ m=(m+m1)&BN_MASK2; if (m < m1) ht+=L2HBITS(1L); \
+ ht+=HBITS(m); \
+ m1=L2HBITS(m); \
+ lt=(lt+m1)&BN_MASK2; if (lt < m1) ht++; \
+ (l)=lt; \
+ (h)=ht; \
+ }
+
+#define sqr64(lo,ho,in) \
+ { \
+ BN_ULONG l,h,m; \
+ \
+ h=(in); \
+ l=LBITS(h); \
+ h=HBITS(h); \
+ m =(l)*(h); \
+ l*=l; \
+ h*=h; \
+ h+=(m&BN_MASK2h1)>>(BN_BITS4-1); \
+ m =(m&BN_MASK2l)<<(BN_BITS4+1); \
+ l=(l+m)&BN_MASK2; if (l < m) h++; \
+ (lo)=l; \
+ (ho)=h; \
+ }
+
+#define mul_add(r,a,bl,bh,c) { \
+ BN_ULONG l,h; \
+ \
+ h= (a); \
+ l=LBITS(h); \
+ h=HBITS(h); \
+ mul64(l,h,(bl),(bh)); \
+ \
+ /* non-multiply part */ \
+ l=(l+(c))&BN_MASK2; if (l < (c)) h++; \
+ (c)=(r); \
+ l=(l+(c))&BN_MASK2; if (l < (c)) h++; \
+ (c)=h&BN_MASK2; \
+ (r)=l; \
+ }
+
+#define mul(r,a,bl,bh,c) { \
+ BN_ULONG l,h; \
+ \
+ h= (a); \
+ l=LBITS(h); \
+ h=HBITS(h); \
+ mul64(l,h,(bl),(bh)); \
+ \
+ /* non-multiply part */ \
+ l+=(c); if ((l&BN_MASK2) < (c)) h++; \
+ (c)=h&BN_MASK2; \
+ (r)=l&BN_MASK2; \
+ }
+#endif /* !BN_LLONG */
+
+void bn_mul_normal(BN_ULONG *r,BN_ULONG *a,int na,BN_ULONG *b,int nb);
+void bn_mul_comba8(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b);
+void bn_mul_comba4(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b);
+void bn_sqr_normal(BN_ULONG *r, BN_ULONG *a, int n, BN_ULONG *tmp);
+void bn_sqr_comba8(BN_ULONG *r,BN_ULONG *a);
+void bn_sqr_comba4(BN_ULONG *r,BN_ULONG *a);
+int bn_cmp_words(BN_ULONG *a,BN_ULONG *b,int n);
+void bn_mul_recursive(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b,int n2,BN_ULONG *t);
+void bn_mul_part_recursive(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b,
+ int tn, int n,BN_ULONG *t);
+void bn_sqr_recursive(BN_ULONG *r,BN_ULONG *a, int n2, BN_ULONG *t);
+void bn_mul_low_normal(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b, int n);
+void bn_mul_low_recursive(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b,int n2,
+ BN_ULONG *t);
+void bn_mul_high(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b,BN_ULONG *l,int n2,
+ BN_ULONG *t);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/package/network/services/ead/src/tinysrp/bn_lib.c b/package/network/services/ead/src/tinysrp/bn_lib.c
new file mode 100644
index 0000000..cfa0d75
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/bn_lib.c
@@ -0,0 +1,576 @@
+/* crypto/bn/bn_lib.c */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#ifndef BN_DEBUG
+# undef NDEBUG /* avoid conflicting definitions */
+# define NDEBUG
+#endif
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "bn_lcl.h"
+
+const char *BN_version="Big Number";
+
+/* For a 32 bit machine
+ * 2 - 4 == 128
+ * 3 - 8 == 256
+ * 4 - 16 == 512
+ * 5 - 32 == 1024
+ * 6 - 64 == 2048
+ * 7 - 128 == 4096
+ * 8 - 256 == 8192
+ */
+static int bn_limit_bits=0;
+static int bn_limit_num=8; /* (1<<bn_limit_bits) */
+static int bn_limit_bits_low=0;
+static int bn_limit_num_low=8; /* (1<<bn_limit_bits_low) */
+static int bn_limit_bits_high=0;
+static int bn_limit_num_high=8; /* (1<<bn_limit_bits_high) */
+static int bn_limit_bits_mont=0;
+static int bn_limit_num_mont=8; /* (1<<bn_limit_bits_mont) */
+
+int BN_num_bits_word(BN_ULONG l)
+ {
+ static const char bits[256]={
+ 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,
+ 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
+ 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
+ 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
+ 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
+ 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
+ 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
+ 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
+ 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
+ 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
+ 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
+ };
+
+#if defined(SIXTY_FOUR_BIT_LONG)
+ if (l & 0xffffffff00000000L)
+ {
+ if (l & 0xffff000000000000L)
+ {
+ if (l & 0xff00000000000000L)
+ {
+ return(bits[(int)(l>>56)]+56);
+ }
+ else return(bits[(int)(l>>48)]+48);
+ }
+ else
+ {
+ if (l & 0x0000ff0000000000L)
+ {
+ return(bits[(int)(l>>40)]+40);
+ }
+ else return(bits[(int)(l>>32)]+32);
+ }
+ }
+ else
+#else
+#ifdef SIXTY_FOUR_BIT
+ if (l & 0xffffffff00000000LL)
+ {
+ if (l & 0xffff000000000000LL)
+ {
+ if (l & 0xff00000000000000LL)
+ {
+ return(bits[(int)(l>>56)]+56);
+ }
+ else return(bits[(int)(l>>48)]+48);
+ }
+ else
+ {
+ if (l & 0x0000ff0000000000LL)
+ {
+ return(bits[(int)(l>>40)]+40);
+ }
+ else return(bits[(int)(l>>32)]+32);
+ }
+ }
+ else
+#endif
+#endif
+ {
+#if defined(THIRTY_TWO_BIT) || defined(SIXTY_FOUR_BIT) || defined(SIXTY_FOUR_BIT_LONG)
+ if (l & 0xffff0000L)
+ {
+ if (l & 0xff000000L)
+ return(bits[(int)(l>>24L)]+24);
+ else return(bits[(int)(l>>16L)]+16);
+ }
+ else
+#endif
+ {
+#if defined(SIXTEEN_BIT) || defined(THIRTY_TWO_BIT) || defined(SIXTY_FOUR_BIT) || defined(SIXTY_FOUR_BIT_LONG)
+ if (l & 0xff00L)
+ return(bits[(int)(l>>8)]+8);
+ else
+#endif
+ return(bits[(int)(l )] );
+ }
+ }
+ }
+
+int BN_num_bits(const BIGNUM *a)
+ {
+ BN_ULONG l;
+ int i;
+
+ bn_check_top(a);
+
+ if (a->top == 0) return(0);
+ l=a->d[a->top-1];
+ assert(l != 0);
+ i=(a->top-1)*BN_BITS2;
+ return(i+BN_num_bits_word(l));
+ }
+
+void BN_clear_free(BIGNUM *a)
+ {
+ int i;
+
+ if (a == NULL) return;
+ if (a->d != NULL)
+ {
+ memset(a->d,0,a->dmax*sizeof(a->d[0]));
+ if (!(BN_get_flags(a,BN_FLG_STATIC_DATA)))
+ free(a->d);
+ }
+ i=BN_get_flags(a,BN_FLG_MALLOCED);
+ memset(a,0,sizeof(BIGNUM));
+ if (i)
+ free(a);
+ }
+
+void BN_free(BIGNUM *a)
+ {
+ if (a == NULL) return;
+ if ((a->d != NULL) && !(BN_get_flags(a,BN_FLG_STATIC_DATA)))
+ free(a->d);
+ a->flags|=BN_FLG_FREE; /* REMOVE? */
+ if (a->flags & BN_FLG_MALLOCED)
+ free(a);
+ }
+
+void BN_init(BIGNUM *a)
+ {
+ memset(a,0,sizeof(BIGNUM));
+ }
+
+BIGNUM *BN_new(void)
+ {
+ BIGNUM *ret;
+
+ if ((ret=(BIGNUM *)malloc(sizeof(BIGNUM))) == NULL)
+ {
+ return(NULL);
+ }
+ ret->flags=BN_FLG_MALLOCED;
+ ret->top=0;
+ ret->neg=0;
+ ret->dmax=0;
+ ret->d=NULL;
+ return(ret);
+ }
+
+/* This is an internal function that should not be used in applications.
+ * It ensures that 'b' has enough room for a 'words' word number number.
+ * It is mostly used by the various BIGNUM routines. If there is an error,
+ * NULL is returned. If not, 'b' is returned. */
+
+BIGNUM *bn_expand2(BIGNUM *b, int words)
+ {
+ BN_ULONG *A,*a;
+ const BN_ULONG *B;
+ int i;
+
+ bn_check_top(b);
+
+ if (words > b->dmax)
+ {
+ bn_check_top(b);
+ if (BN_get_flags(b,BN_FLG_STATIC_DATA))
+ {
+ return(NULL);
+ }
+ a=A=(BN_ULONG *)malloc(sizeof(BN_ULONG)*(words+1));
+ if (A == NULL)
+ {
+ return(NULL);
+ }
+#if 1
+ B=b->d;
+ /* Check if the previous number needs to be copied */
+ if (B != NULL)
+ {
+#if 0
+ /* This lot is an unrolled loop to copy b->top
+ * BN_ULONGs from B to A
+ */
+/*
+ * I have nothing against unrolling but it's usually done for
+ * several reasons, namely:
+ * - minimize percentage of decision making code, i.e. branches;
+ * - avoid cache trashing;
+ * - make it possible to schedule loads earlier;
+ * Now let's examine the code below. The cornerstone of C is
+ * "programmer is always right" and that's what we love it for:-)
+ * For this very reason C compilers have to be paranoid when it
+ * comes to data aliasing and assume the worst. Yeah, but what
+ * does it mean in real life? This means that loop body below will
+ * be compiled to sequence of loads immediately followed by stores
+ * as compiler assumes the worst, something in A==B+1 style. As a
+ * result CPU pipeline is going to starve for incoming data. Secondly
+ * if A and B happen to share same cache line such code is going to
+ * cause severe cache trashing. Both factors have severe impact on
+ * performance of modern CPUs and this is the reason why this
+ * particular piece of code is #ifdefed away and replaced by more
+ * "friendly" version found in #else section below. This comment
+ * also applies to BN_copy function.
+ *
+ * <appro@fy.chalmers.se>
+ */
+ for (i=b->top&(~7); i>0; i-=8)
+ {
+ A[0]=B[0]; A[1]=B[1]; A[2]=B[2]; A[3]=B[3];
+ A[4]=B[4]; A[5]=B[5]; A[6]=B[6]; A[7]=B[7];
+ A+=8;
+ B+=8;
+ }
+ switch (b->top&7)
+ {
+ case 7:
+ A[6]=B[6];
+ case 6:
+ A[5]=B[5];
+ case 5:
+ A[4]=B[4];
+ case 4:
+ A[3]=B[3];
+ case 3:
+ A[2]=B[2];
+ case 2:
+ A[1]=B[1];
+ case 1:
+ A[0]=B[0];
+ case 0:
+ /* I need the 'case 0' entry for utrix cc.
+ * If the optimizer is turned on, it does the
+ * switch table by doing
+ * a=top&7
+ * a--;
+ * goto jump_table[a];
+ * If top is 0, this makes us jump to 0xffffffc
+ * which is rather bad :-(.
+ * eric 23-Apr-1998
+ */
+ ;
+ }
+#else
+ for (i=b->top>>2; i>0; i--,A+=4,B+=4)
+ {
+ /*
+ * The fact that the loop is unrolled
+ * 4-wise is a tribute to Intel. It's
+ * the one that doesn't have enough
+ * registers to accomodate more data.
+ * I'd unroll it 8-wise otherwise:-)
+ *
+ * <appro@fy.chalmers.se>
+ */
+ BN_ULONG a0,a1,a2,a3;
+ a0=B[0]; a1=B[1]; a2=B[2]; a3=B[3];
+ A[0]=a0; A[1]=a1; A[2]=a2; A[3]=a3;
+ }
+ switch (b->top&3)
+ {
+ case 3: A[2]=B[2];
+ case 2: A[1]=B[1];
+ case 1: A[0]=B[0];
+ case 0: ; /* ultrix cc workaround, see above */
+ }
+#endif
+ free(b->d);
+ }
+
+ b->d=a;
+ b->dmax=words;
+
+ /* Now need to zero any data between b->top and b->max */
+
+ A= &(b->d[b->top]);
+ for (i=(b->dmax - b->top)>>3; i>0; i--,A+=8)
+ {
+ A[0]=0; A[1]=0; A[2]=0; A[3]=0;
+ A[4]=0; A[5]=0; A[6]=0; A[7]=0;
+ }
+ for (i=(b->dmax - b->top)&7; i>0; i--,A++)
+ A[0]=0;
+#else
+ memset(A,0,sizeof(BN_ULONG)*(words+1));
+ memcpy(A,b->d,sizeof(b->d[0])*b->top);
+ b->d=a;
+ b->max=words;
+#endif
+
+/* memset(&(p[b->max]),0,((words+1)-b->max)*sizeof(BN_ULONG)); */
+/* { int i; for (i=b->max; i<words+1; i++) p[i]=i;} */
+
+ }
+ return(b);
+ }
+
+BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b)
+ {
+ int i;
+ BN_ULONG *A;
+ const BN_ULONG *B;
+
+ bn_check_top(b);
+
+ if (a == b) return(a);
+ if (bn_wexpand(a,b->top) == NULL) return(NULL);
+
+#if 1
+ A=a->d;
+ B=b->d;
+ for (i=b->top>>2; i>0; i--,A+=4,B+=4)
+ {
+ BN_ULONG a0,a1,a2,a3;
+ a0=B[0]; a1=B[1]; a2=B[2]; a3=B[3];
+ A[0]=a0; A[1]=a1; A[2]=a2; A[3]=a3;
+ }
+ switch (b->top&3)
+ {
+ case 3: A[2]=B[2];
+ case 2: A[1]=B[1];
+ case 1: A[0]=B[0];
+ case 0: ; /* ultrix cc workaround, see comments in bn_expand2 */
+ }
+#else
+ memcpy(a->d,b->d,sizeof(b->d[0])*b->top);
+#endif
+
+/* memset(&(a->d[b->top]),0,sizeof(a->d[0])*(a->max-b->top));*/
+ a->top=b->top;
+ if ((a->top == 0) && (a->d != NULL))
+ a->d[0]=0;
+ a->neg=b->neg;
+ return(a);
+ }
+
+int BN_set_word(BIGNUM *a, BN_ULONG w)
+ {
+ int i,n;
+ if (bn_expand(a,sizeof(BN_ULONG)*8) == NULL) return(0);
+
+ n=sizeof(BN_ULONG)/BN_BYTES;
+ a->neg=0;
+ a->top=0;
+ a->d[0]=(BN_ULONG)w&BN_MASK2;
+ if (a->d[0] != 0) a->top=1;
+ for (i=1; i<n; i++)
+ {
+ /* the following is done instead of
+ * w>>=BN_BITS2 so compilers don't complain
+ * on builds where sizeof(long) == BN_TYPES */
+#ifndef SIXTY_FOUR_BIT /* the data item > unsigned long */
+ w>>=BN_BITS4;
+ w>>=BN_BITS4;
+#else
+ w=0;
+#endif
+ a->d[i]=(BN_ULONG)w&BN_MASK2;
+ if (a->d[i] != 0) a->top=i+1;
+ }
+ return(1);
+ }
+
+/* ignore negative */
+BIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret)
+ {
+ unsigned int i,m;
+ unsigned int n;
+ BN_ULONG l;
+
+ if (ret == NULL) ret=BN_new();
+ if (ret == NULL) return(NULL);
+ l=0;
+ n=len;
+ if (n == 0)
+ {
+ ret->top=0;
+ return(ret);
+ }
+ if (bn_expand(ret,(int)(n+2)*8) == NULL)
+ return(NULL);
+ i=((n-1)/BN_BYTES)+1;
+ m=((n-1)%(BN_BYTES));
+ ret->top=i;
+ while (n-- > 0)
+ {
+ l=(l<<8L)| *(s++);
+ if (m-- == 0)
+ {
+ ret->d[--i]=l;
+ l=0;
+ m=BN_BYTES-1;
+ }
+ }
+ /* need to call this due to clear byte at top if avoiding
+ * having the top bit set (-ve number) */
+ bn_fix_top(ret);
+ return(ret);
+ }
+
+/* ignore negative */
+int BN_bn2bin(const BIGNUM *a, unsigned char *to)
+ {
+ int n,i;
+ BN_ULONG l;
+
+ n=i=BN_num_bytes(a);
+ while (i-- > 0)
+ {
+ l=a->d[i/BN_BYTES];
+ *(to++)=(unsigned char)(l>>(8*(i%BN_BYTES)))&0xff;
+ }
+ return(n);
+ }
+
+int BN_ucmp(const BIGNUM *a, const BIGNUM *b)
+ {
+ int i;
+ BN_ULONG t1,t2,*ap,*bp;
+
+ bn_check_top(a);
+ bn_check_top(b);
+
+ i=a->top-b->top;
+ if (i != 0) return(i);
+ ap=a->d;
+ bp=b->d;
+ for (i=a->top-1; i>=0; i--)
+ {
+ t1= ap[i];
+ t2= bp[i];
+ if (t1 != t2)
+ return(t1 > t2?1:-1);
+ }
+ return(0);
+ }
+
+int BN_cmp(const BIGNUM *a, const BIGNUM *b)
+ {
+ int i;
+ int gt,lt;
+ BN_ULONG t1,t2;
+
+ if ((a == NULL) || (b == NULL))
+ {
+ if (a != NULL)
+ return(-1);
+ else if (b != NULL)
+ return(1);
+ else
+ return(0);
+ }
+
+ bn_check_top(a);
+ bn_check_top(b);
+
+ if (a->neg != b->neg)
+ {
+ if (a->neg)
+ return(-1);
+ else return(1);
+ }
+ if (a->neg == 0)
+ { gt=1; lt= -1; }
+ else { gt= -1; lt=1; }
+
+ if (a->top > b->top) return(gt);
+ if (a->top < b->top) return(lt);
+ for (i=a->top-1; i>=0; i--)
+ {
+ t1=a->d[i];
+ t2=b->d[i];
+ if (t1 > t2) return(gt);
+ if (t1 < t2) return(lt);
+ }
+ return(0);
+ }
+
+int BN_is_bit_set(const BIGNUM *a, int n)
+ {
+ int i,j;
+
+ if (n < 0) return(0);
+ i=n/BN_BITS2;
+ j=n%BN_BITS2;
+ if (a->top <= i) return(0);
+ return((a->d[i]&(((BN_ULONG)1)<<j))?1:0);
+ }
diff --git a/package/network/services/ead/src/tinysrp/bn_mul.c b/package/network/services/ead/src/tinysrp/bn_mul.c
new file mode 100644
index 0000000..d2d9fc5
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/bn_mul.c
@@ -0,0 +1,176 @@
+/* crypto/bn/bn_mul.c */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include "bn_lcl.h"
+
+int BN_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx)
+ {
+ int top,al,bl;
+ BIGNUM *rr;
+ int ret = 0;
+#if defined(BN_MUL_COMBA) || defined(BN_RECURSION)
+ int i;
+#endif
+#ifdef BN_RECURSION
+ BIGNUM *t;
+ int j,k;
+#endif
+
+#ifdef BN_COUNT
+ printf("BN_mul %d * %d\n",a->top,b->top);
+#endif
+
+ bn_check_top(a);
+ bn_check_top(b);
+ bn_check_top(r);
+
+ al=a->top;
+ bl=b->top;
+
+ if ((al == 0) || (bl == 0))
+ {
+ BN_zero(r);
+ return(1);
+ }
+ top=al+bl;
+
+ BN_CTX_start(ctx);
+ if ((r == a) || (r == b))
+ {
+ if ((rr = BN_CTX_get(ctx)) == NULL) goto err;
+ }
+ else
+ rr = r;
+ rr->neg=a->neg^b->neg;
+
+#if defined(BN_MUL_COMBA) || defined(BN_RECURSION)
+ i = al-bl;
+#endif
+#ifdef BN_MUL_COMBA
+ if (i == 0)
+ {
+# if 0
+ if (al == 4)
+ {
+ if (bn_wexpand(rr,8) == NULL) goto err;
+ rr->top=8;
+ bn_mul_comba4(rr->d,a->d,b->d);
+ goto end;
+ }
+# endif
+ if (al == 8)
+ {
+ if (bn_wexpand(rr,16) == NULL) goto err;
+ rr->top=16;
+ bn_mul_comba8(rr->d,a->d,b->d);
+ goto end;
+ }
+ }
+#endif /* BN_MUL_COMBA */
+ if (bn_wexpand(rr,top) == NULL) goto err;
+ rr->top=top;
+ bn_mul_normal(rr->d,a->d,al,b->d,bl);
+
+#if defined(BN_MUL_COMBA) || defined(BN_RECURSION)
+end:
+#endif
+ bn_fix_top(rr);
+ if (r != rr) BN_copy(r,rr);
+ ret=1;
+err:
+ BN_CTX_end(ctx);
+ return(ret);
+ }
+
+void bn_mul_normal(BN_ULONG *r, BN_ULONG *a, int na, BN_ULONG *b, int nb)
+ {
+ BN_ULONG *rr;
+
+#ifdef BN_COUNT
+ printf(" bn_mul_normal %d * %d\n",na,nb);
+#endif
+
+ if (na < nb)
+ {
+ int itmp;
+ BN_ULONG *ltmp;
+
+ itmp=na; na=nb; nb=itmp;
+ ltmp=a; a=b; b=ltmp;
+
+ }
+ rr= &(r[na]);
+ rr[0]=bn_mul_words(r,a,na,b[0]);
+
+ for (;;)
+ {
+ if (--nb <= 0) return;
+ rr[1]=bn_mul_add_words(&(r[1]),a,na,b[1]);
+ if (--nb <= 0) return;
+ rr[2]=bn_mul_add_words(&(r[2]),a,na,b[2]);
+ if (--nb <= 0) return;
+ rr[3]=bn_mul_add_words(&(r[3]),a,na,b[3]);
+ if (--nb <= 0) return;
+ rr[4]=bn_mul_add_words(&(r[4]),a,na,b[4]);
+ rr+=4;
+ r+=4;
+ b+=4;
+ }
+ }
diff --git a/package/network/services/ead/src/tinysrp/bn_prime.h b/package/network/services/ead/src/tinysrp/bn_prime.h
new file mode 100644
index 0000000..b7cf9a9
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/bn_prime.h
@@ -0,0 +1,325 @@
+/* Auto generated by bn_prime.pl */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#ifndef EIGHT_BIT
+#define NUMPRIMES 2048
+#else
+#define NUMPRIMES 54
+#endif
+static const unsigned int primes[NUMPRIMES]=
+ {
+ 2, 3, 5, 7, 11, 13, 17, 19,
+ 23, 29, 31, 37, 41, 43, 47, 53,
+ 59, 61, 67, 71, 73, 79, 83, 89,
+ 97, 101, 103, 107, 109, 113, 127, 131,
+ 137, 139, 149, 151, 157, 163, 167, 173,
+ 179, 181, 191, 193, 197, 199, 211, 223,
+ 227, 229, 233, 239, 241, 251,
+#ifndef EIGHT_BIT
+ 257, 263,
+ 269, 271, 277, 281, 283, 293, 307, 311,
+ 313, 317, 331, 337, 347, 349, 353, 359,
+ 367, 373, 379, 383, 389, 397, 401, 409,
+ 419, 421, 431, 433, 439, 443, 449, 457,
+ 461, 463, 467, 479, 487, 491, 499, 503,
+ 509, 521, 523, 541, 547, 557, 563, 569,
+ 571, 577, 587, 593, 599, 601, 607, 613,
+ 617, 619, 631, 641, 643, 647, 653, 659,
+ 661, 673, 677, 683, 691, 701, 709, 719,
+ 727, 733, 739, 743, 751, 757, 761, 769,
+ 773, 787, 797, 809, 811, 821, 823, 827,
+ 829, 839, 853, 857, 859, 863, 877, 881,
+ 883, 887, 907, 911, 919, 929, 937, 941,
+ 947, 953, 967, 971, 977, 983, 991, 997,
+ 1009,1013,1019,1021,1031,1033,1039,1049,
+ 1051,1061,1063,1069,1087,1091,1093,1097,
+ 1103,1109,1117,1123,1129,1151,1153,1163,
+ 1171,1181,1187,1193,1201,1213,1217,1223,
+ 1229,1231,1237,1249,1259,1277,1279,1283,
+ 1289,1291,1297,1301,1303,1307,1319,1321,
+ 1327,1361,1367,1373,1381,1399,1409,1423,
+ 1427,1429,1433,1439,1447,1451,1453,1459,
+ 1471,1481,1483,1487,1489,1493,1499,1511,
+ 1523,1531,1543,1549,1553,1559,1567,1571,
+ 1579,1583,1597,1601,1607,1609,1613,1619,
+ 1621,1627,1637,1657,1663,1667,1669,1693,
+ 1697,1699,1709,1721,1723,1733,1741,1747,
+ 1753,1759,1777,1783,1787,1789,1801,1811,
+ 1823,1831,1847,1861,1867,1871,1873,1877,
+ 1879,1889,1901,1907,1913,1931,1933,1949,
+ 1951,1973,1979,1987,1993,1997,1999,2003,
+ 2011,2017,2027,2029,2039,2053,2063,2069,
+ 2081,2083,2087,2089,2099,2111,2113,2129,
+ 2131,2137,2141,2143,2153,2161,2179,2203,
+ 2207,2213,2221,2237,2239,2243,2251,2267,
+ 2269,2273,2281,2287,2293,2297,2309,2311,
+ 2333,2339,2341,2347,2351,2357,2371,2377,
+ 2381,2383,2389,2393,2399,2411,2417,2423,
+ 2437,2441,2447,2459,2467,2473,2477,2503,
+ 2521,2531,2539,2543,2549,2551,2557,2579,
+ 2591,2593,2609,2617,2621,2633,2647,2657,
+ 2659,2663,2671,2677,2683,2687,2689,2693,
+ 2699,2707,2711,2713,2719,2729,2731,2741,
+ 2749,2753,2767,2777,2789,2791,2797,2801,
+ 2803,2819,2833,2837,2843,2851,2857,2861,
+ 2879,2887,2897,2903,2909,2917,2927,2939,
+ 2953,2957,2963,2969,2971,2999,3001,3011,
+ 3019,3023,3037,3041,3049,3061,3067,3079,
+ 3083,3089,3109,3119,3121,3137,3163,3167,
+ 3169,3181,3187,3191,3203,3209,3217,3221,
+ 3229,3251,3253,3257,3259,3271,3299,3301,
+ 3307,3313,3319,3323,3329,3331,3343,3347,
+ 3359,3361,3371,3373,3389,3391,3407,3413,
+ 3433,3449,3457,3461,3463,3467,3469,3491,
+ 3499,3511,3517,3527,3529,3533,3539,3541,
+ 3547,3557,3559,3571,3581,3583,3593,3607,
+ 3613,3617,3623,3631,3637,3643,3659,3671,
+ 3673,3677,3691,3697,3701,3709,3719,3727,
+ 3733,3739,3761,3767,3769,3779,3793,3797,
+ 3803,3821,3823,3833,3847,3851,3853,3863,
+ 3877,3881,3889,3907,3911,3917,3919,3923,
+ 3929,3931,3943,3947,3967,3989,4001,4003,
+ 4007,4013,4019,4021,4027,4049,4051,4057,
+ 4073,4079,4091,4093,4099,4111,4127,4129,
+ 4133,4139,4153,4157,4159,4177,4201,4211,
+ 4217,4219,4229,4231,4241,4243,4253,4259,
+ 4261,4271,4273,4283,4289,4297,4327,4337,
+ 4339,4349,4357,4363,4373,4391,4397,4409,
+ 4421,4423,4441,4447,4451,4457,4463,4481,
+ 4483,4493,4507,4513,4517,4519,4523,4547,
+ 4549,4561,4567,4583,4591,4597,4603,4621,
+ 4637,4639,4643,4649,4651,4657,4663,4673,
+ 4679,4691,4703,4721,4723,4729,4733,4751,
+ 4759,4783,4787,4789,4793,4799,4801,4813,
+ 4817,4831,4861,4871,4877,4889,4903,4909,
+ 4919,4931,4933,4937,4943,4951,4957,4967,
+ 4969,4973,4987,4993,4999,5003,5009,5011,
+ 5021,5023,5039,5051,5059,5077,5081,5087,
+ 5099,5101,5107,5113,5119,5147,5153,5167,
+ 5171,5179,5189,5197,5209,5227,5231,5233,
+ 5237,5261,5273,5279,5281,5297,5303,5309,
+ 5323,5333,5347,5351,5381,5387,5393,5399,
+ 5407,5413,5417,5419,5431,5437,5441,5443,
+ 5449,5471,5477,5479,5483,5501,5503,5507,
+ 5519,5521,5527,5531,5557,5563,5569,5573,
+ 5581,5591,5623,5639,5641,5647,5651,5653,
+ 5657,5659,5669,5683,5689,5693,5701,5711,
+ 5717,5737,5741,5743,5749,5779,5783,5791,
+ 5801,5807,5813,5821,5827,5839,5843,5849,
+ 5851,5857,5861,5867,5869,5879,5881,5897,
+ 5903,5923,5927,5939,5953,5981,5987,6007,
+ 6011,6029,6037,6043,6047,6053,6067,6073,
+ 6079,6089,6091,6101,6113,6121,6131,6133,
+ 6143,6151,6163,6173,6197,6199,6203,6211,
+ 6217,6221,6229,6247,6257,6263,6269,6271,
+ 6277,6287,6299,6301,6311,6317,6323,6329,
+ 6337,6343,6353,6359,6361,6367,6373,6379,
+ 6389,6397,6421,6427,6449,6451,6469,6473,
+ 6481,6491,6521,6529,6547,6551,6553,6563,
+ 6569,6571,6577,6581,6599,6607,6619,6637,
+ 6653,6659,6661,6673,6679,6689,6691,6701,
+ 6703,6709,6719,6733,6737,6761,6763,6779,
+ 6781,6791,6793,6803,6823,6827,6829,6833,
+ 6841,6857,6863,6869,6871,6883,6899,6907,
+ 6911,6917,6947,6949,6959,6961,6967,6971,
+ 6977,6983,6991,6997,7001,7013,7019,7027,
+ 7039,7043,7057,7069,7079,7103,7109,7121,
+ 7127,7129,7151,7159,7177,7187,7193,7207,
+ 7211,7213,7219,7229,7237,7243,7247,7253,
+ 7283,7297,7307,7309,7321,7331,7333,7349,
+ 7351,7369,7393,7411,7417,7433,7451,7457,
+ 7459,7477,7481,7487,7489,7499,7507,7517,
+ 7523,7529,7537,7541,7547,7549,7559,7561,
+ 7573,7577,7583,7589,7591,7603,7607,7621,
+ 7639,7643,7649,7669,7673,7681,7687,7691,
+ 7699,7703,7717,7723,7727,7741,7753,7757,
+ 7759,7789,7793,7817,7823,7829,7841,7853,
+ 7867,7873,7877,7879,7883,7901,7907,7919,
+ 7927,7933,7937,7949,7951,7963,7993,8009,
+ 8011,8017,8039,8053,8059,8069,8081,8087,
+ 8089,8093,8101,8111,8117,8123,8147,8161,
+ 8167,8171,8179,8191,8209,8219,8221,8231,
+ 8233,8237,8243,8263,8269,8273,8287,8291,
+ 8293,8297,8311,8317,8329,8353,8363,8369,
+ 8377,8387,8389,8419,8423,8429,8431,8443,
+ 8447,8461,8467,8501,8513,8521,8527,8537,
+ 8539,8543,8563,8573,8581,8597,8599,8609,
+ 8623,8627,8629,8641,8647,8663,8669,8677,
+ 8681,8689,8693,8699,8707,8713,8719,8731,
+ 8737,8741,8747,8753,8761,8779,8783,8803,
+ 8807,8819,8821,8831,8837,8839,8849,8861,
+ 8863,8867,8887,8893,8923,8929,8933,8941,
+ 8951,8963,8969,8971,8999,9001,9007,9011,
+ 9013,9029,9041,9043,9049,9059,9067,9091,
+ 9103,9109,9127,9133,9137,9151,9157,9161,
+ 9173,9181,9187,9199,9203,9209,9221,9227,
+ 9239,9241,9257,9277,9281,9283,9293,9311,
+ 9319,9323,9337,9341,9343,9349,9371,9377,
+ 9391,9397,9403,9413,9419,9421,9431,9433,
+ 9437,9439,9461,9463,9467,9473,9479,9491,
+ 9497,9511,9521,9533,9539,9547,9551,9587,
+ 9601,9613,9619,9623,9629,9631,9643,9649,
+ 9661,9677,9679,9689,9697,9719,9721,9733,
+ 9739,9743,9749,9767,9769,9781,9787,9791,
+ 9803,9811,9817,9829,9833,9839,9851,9857,
+ 9859,9871,9883,9887,9901,9907,9923,9929,
+ 9931,9941,9949,9967,9973,10007,10009,10037,
+ 10039,10061,10067,10069,10079,10091,10093,10099,
+ 10103,10111,10133,10139,10141,10151,10159,10163,
+ 10169,10177,10181,10193,10211,10223,10243,10247,
+ 10253,10259,10267,10271,10273,10289,10301,10303,
+ 10313,10321,10331,10333,10337,10343,10357,10369,
+ 10391,10399,10427,10429,10433,10453,10457,10459,
+ 10463,10477,10487,10499,10501,10513,10529,10531,
+ 10559,10567,10589,10597,10601,10607,10613,10627,
+ 10631,10639,10651,10657,10663,10667,10687,10691,
+ 10709,10711,10723,10729,10733,10739,10753,10771,
+ 10781,10789,10799,10831,10837,10847,10853,10859,
+ 10861,10867,10883,10889,10891,10903,10909,10937,
+ 10939,10949,10957,10973,10979,10987,10993,11003,
+ 11027,11047,11057,11059,11069,11071,11083,11087,
+ 11093,11113,11117,11119,11131,11149,11159,11161,
+ 11171,11173,11177,11197,11213,11239,11243,11251,
+ 11257,11261,11273,11279,11287,11299,11311,11317,
+ 11321,11329,11351,11353,11369,11383,11393,11399,
+ 11411,11423,11437,11443,11447,11467,11471,11483,
+ 11489,11491,11497,11503,11519,11527,11549,11551,
+ 11579,11587,11593,11597,11617,11621,11633,11657,
+ 11677,11681,11689,11699,11701,11717,11719,11731,
+ 11743,11777,11779,11783,11789,11801,11807,11813,
+ 11821,11827,11831,11833,11839,11863,11867,11887,
+ 11897,11903,11909,11923,11927,11933,11939,11941,
+ 11953,11959,11969,11971,11981,11987,12007,12011,
+ 12037,12041,12043,12049,12071,12073,12097,12101,
+ 12107,12109,12113,12119,12143,12149,12157,12161,
+ 12163,12197,12203,12211,12227,12239,12241,12251,
+ 12253,12263,12269,12277,12281,12289,12301,12323,
+ 12329,12343,12347,12373,12377,12379,12391,12401,
+ 12409,12413,12421,12433,12437,12451,12457,12473,
+ 12479,12487,12491,12497,12503,12511,12517,12527,
+ 12539,12541,12547,12553,12569,12577,12583,12589,
+ 12601,12611,12613,12619,12637,12641,12647,12653,
+ 12659,12671,12689,12697,12703,12713,12721,12739,
+ 12743,12757,12763,12781,12791,12799,12809,12821,
+ 12823,12829,12841,12853,12889,12893,12899,12907,
+ 12911,12917,12919,12923,12941,12953,12959,12967,
+ 12973,12979,12983,13001,13003,13007,13009,13033,
+ 13037,13043,13049,13063,13093,13099,13103,13109,
+ 13121,13127,13147,13151,13159,13163,13171,13177,
+ 13183,13187,13217,13219,13229,13241,13249,13259,
+ 13267,13291,13297,13309,13313,13327,13331,13337,
+ 13339,13367,13381,13397,13399,13411,13417,13421,
+ 13441,13451,13457,13463,13469,13477,13487,13499,
+ 13513,13523,13537,13553,13567,13577,13591,13597,
+ 13613,13619,13627,13633,13649,13669,13679,13681,
+ 13687,13691,13693,13697,13709,13711,13721,13723,
+ 13729,13751,13757,13759,13763,13781,13789,13799,
+ 13807,13829,13831,13841,13859,13873,13877,13879,
+ 13883,13901,13903,13907,13913,13921,13931,13933,
+ 13963,13967,13997,13999,14009,14011,14029,14033,
+ 14051,14057,14071,14081,14083,14087,14107,14143,
+ 14149,14153,14159,14173,14177,14197,14207,14221,
+ 14243,14249,14251,14281,14293,14303,14321,14323,
+ 14327,14341,14347,14369,14387,14389,14401,14407,
+ 14411,14419,14423,14431,14437,14447,14449,14461,
+ 14479,14489,14503,14519,14533,14537,14543,14549,
+ 14551,14557,14561,14563,14591,14593,14621,14627,
+ 14629,14633,14639,14653,14657,14669,14683,14699,
+ 14713,14717,14723,14731,14737,14741,14747,14753,
+ 14759,14767,14771,14779,14783,14797,14813,14821,
+ 14827,14831,14843,14851,14867,14869,14879,14887,
+ 14891,14897,14923,14929,14939,14947,14951,14957,
+ 14969,14983,15013,15017,15031,15053,15061,15073,
+ 15077,15083,15091,15101,15107,15121,15131,15137,
+ 15139,15149,15161,15173,15187,15193,15199,15217,
+ 15227,15233,15241,15259,15263,15269,15271,15277,
+ 15287,15289,15299,15307,15313,15319,15329,15331,
+ 15349,15359,15361,15373,15377,15383,15391,15401,
+ 15413,15427,15439,15443,15451,15461,15467,15473,
+ 15493,15497,15511,15527,15541,15551,15559,15569,
+ 15581,15583,15601,15607,15619,15629,15641,15643,
+ 15647,15649,15661,15667,15671,15679,15683,15727,
+ 15731,15733,15737,15739,15749,15761,15767,15773,
+ 15787,15791,15797,15803,15809,15817,15823,15859,
+ 15877,15881,15887,15889,15901,15907,15913,15919,
+ 15923,15937,15959,15971,15973,15991,16001,16007,
+ 16033,16057,16061,16063,16067,16069,16073,16087,
+ 16091,16097,16103,16111,16127,16139,16141,16183,
+ 16187,16189,16193,16217,16223,16229,16231,16249,
+ 16253,16267,16273,16301,16319,16333,16339,16349,
+ 16361,16363,16369,16381,16411,16417,16421,16427,
+ 16433,16447,16451,16453,16477,16481,16487,16493,
+ 16519,16529,16547,16553,16561,16567,16573,16603,
+ 16607,16619,16631,16633,16649,16651,16657,16661,
+ 16673,16691,16693,16699,16703,16729,16741,16747,
+ 16759,16763,16787,16811,16823,16829,16831,16843,
+ 16871,16879,16883,16889,16901,16903,16921,16927,
+ 16931,16937,16943,16963,16979,16981,16987,16993,
+ 17011,17021,17027,17029,17033,17041,17047,17053,
+ 17077,17093,17099,17107,17117,17123,17137,17159,
+ 17167,17183,17189,17191,17203,17207,17209,17231,
+ 17239,17257,17291,17293,17299,17317,17321,17327,
+ 17333,17341,17351,17359,17377,17383,17387,17389,
+ 17393,17401,17417,17419,17431,17443,17449,17467,
+ 17471,17477,17483,17489,17491,17497,17509,17519,
+ 17539,17551,17569,17573,17579,17581,17597,17599,
+ 17609,17623,17627,17657,17659,17669,17681,17683,
+ 17707,17713,17729,17737,17747,17749,17761,17783,
+ 17789,17791,17807,17827,17837,17839,17851,17863,
+#endif
+ };
diff --git a/package/network/services/ead/src/tinysrp/bn_shift.c b/package/network/services/ead/src/tinysrp/bn_shift.c
new file mode 100644
index 0000000..f403720
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/bn_shift.c
@@ -0,0 +1,139 @@
+/* crypto/bn/bn_shift.c */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include "bn_lcl.h"
+
+int BN_lshift(BIGNUM *r, const BIGNUM *a, int n)
+ {
+ int i,nw,lb,rb;
+ BN_ULONG *t,*f;
+ BN_ULONG l;
+
+ r->neg=a->neg;
+ if (bn_wexpand(r,a->top+(n/BN_BITS2)+1) == NULL) return(0);
+ nw=n/BN_BITS2;
+ lb=n%BN_BITS2;
+ rb=BN_BITS2-lb;
+ f=a->d;
+ t=r->d;
+ t[a->top+nw]=0;
+ if (lb == 0)
+ for (i=a->top-1; i>=0; i--)
+ t[nw+i]=f[i];
+ else
+ for (i=a->top-1; i>=0; i--)
+ {
+ l=f[i];
+ t[nw+i+1]|=(l>>rb)&BN_MASK2;
+ t[nw+i]=(l<<lb)&BN_MASK2;
+ }
+ memset(t,0,nw*sizeof(t[0]));
+/* for (i=0; i<nw; i++)
+ t[i]=0;*/
+ r->top=a->top+nw+1;
+ bn_fix_top(r);
+ return(1);
+ }
+
+int BN_rshift(BIGNUM *r, BIGNUM *a, int n)
+ {
+ int i,j,nw,lb,rb;
+ BN_ULONG *t,*f;
+ BN_ULONG l,tmp;
+
+ nw=n/BN_BITS2;
+ rb=n%BN_BITS2;
+ lb=BN_BITS2-rb;
+ if (nw > a->top || a->top == 0)
+ {
+ BN_zero(r);
+ return(1);
+ }
+ if (r != a)
+ {
+ r->neg=a->neg;
+ if (bn_wexpand(r,a->top-nw+1) == NULL) return(0);
+ }
+
+ f= &(a->d[nw]);
+ t=r->d;
+ j=a->top-nw;
+ r->top=j;
+
+ if (rb == 0)
+ {
+ for (i=j+1; i > 0; i--)
+ *(t++)= *(f++);
+ }
+ else
+ {
+ l= *(f++);
+ for (i=1; i<j; i++)
+ {
+ tmp =(l>>rb)&BN_MASK2;
+ l= *(f++);
+ *(t++) =(tmp|(l<<lb))&BN_MASK2;
+ }
+ *(t++) =(l>>rb)&BN_MASK2;
+ }
+ *t=0;
+ bn_fix_top(r);
+ return(1);
+ }
diff --git a/package/network/services/ead/src/tinysrp/bn_sqr.c b/package/network/services/ead/src/tinysrp/bn_sqr.c
new file mode 100644
index 0000000..2d3db70
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/bn_sqr.c
@@ -0,0 +1,160 @@
+/* crypto/bn/bn_sqr.c */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include "bn_lcl.h"
+
+/* r must not be a */
+/* I've just gone over this and it is now %20 faster on x86 - eay - 27 Jun 96 */
+int BN_sqr(BIGNUM *r, BIGNUM *a, BN_CTX *ctx)
+ {
+ int max,al;
+ int ret = 0;
+ BIGNUM *tmp,*rr;
+
+#ifdef BN_COUNT
+printf("BN_sqr %d * %d\n",a->top,a->top);
+#endif
+ bn_check_top(a);
+
+ al=a->top;
+ if (al <= 0)
+ {
+ r->top=0;
+ return(1);
+ }
+
+ BN_CTX_start(ctx);
+ rr=(a != r) ? r : BN_CTX_get(ctx);
+ tmp=BN_CTX_get(ctx);
+ if (tmp == NULL) goto err;
+
+ max=(al+al);
+ if (bn_wexpand(rr,max+1) == NULL) goto err;
+
+ r->neg=0;
+ if (al == 4)
+ {
+#ifndef BN_SQR_COMBA
+ BN_ULONG t[8];
+ bn_sqr_normal(rr->d,a->d,4,t);
+#else
+ bn_sqr_comba4(rr->d,a->d);
+#endif
+ }
+ else if (al == 8)
+ {
+#ifndef BN_SQR_COMBA
+ BN_ULONG t[16];
+ bn_sqr_normal(rr->d,a->d,8,t);
+#else
+ bn_sqr_comba8(rr->d,a->d);
+#endif
+ }
+ else
+ {
+ if (bn_wexpand(tmp,max) == NULL) goto err;
+ bn_sqr_normal(rr->d,a->d,al,tmp->d);
+ }
+
+ rr->top=max;
+ if ((max > 0) && (rr->d[max-1] == 0)) rr->top--;
+ if (rr != r) BN_copy(r,rr);
+ ret = 1;
+ err:
+ BN_CTX_end(ctx);
+ return(ret);
+ }
+
+/* tmp must have 2*n words */
+void bn_sqr_normal(BN_ULONG *r, BN_ULONG *a, int n, BN_ULONG *tmp)
+ {
+ int i,j,max;
+ BN_ULONG *ap,*rp;
+
+ max=n*2;
+ ap=a;
+ rp=r;
+ rp[0]=rp[max-1]=0;
+ rp++;
+ j=n;
+
+ if (--j > 0)
+ {
+ ap++;
+ rp[j]=bn_mul_words(rp,ap,j,ap[-1]);
+ rp+=2;
+ }
+
+ for (i=n-2; i>0; i--)
+ {
+ j--;
+ ap++;
+ rp[j]=bn_mul_add_words(rp,ap,j,ap[-1]);
+ rp+=2;
+ }
+
+ bn_add_words(r,r,r,max);
+
+ /* There will not be a carry */
+
+ bn_sqr_words(tmp,a,n);
+
+ bn_add_words(r,r,tmp,max);
+ }
diff --git a/package/network/services/ead/src/tinysrp/bn_word.c b/package/network/services/ead/src/tinysrp/bn_word.c
new file mode 100644
index 0000000..7820e08
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/bn_word.c
@@ -0,0 +1,130 @@
+/* crypto/bn/bn_word.c */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#include <stdio.h>
+#include "bn_lcl.h"
+
+int BN_add_word(BIGNUM *a, BN_ULONG w)
+ {
+ BN_ULONG l;
+ int i;
+
+ if (a->neg)
+ {
+ a->neg=0;
+ i=BN_sub_word(a,w);
+ if (!BN_is_zero(a))
+ a->neg=!(a->neg);
+ return(i);
+ }
+ w&=BN_MASK2;
+ if (bn_wexpand(a,a->top+1) == NULL) return(0);
+ i=0;
+ for (;;)
+ {
+ l=(a->d[i]+(BN_ULONG)w)&BN_MASK2;
+ a->d[i]=l;
+ if (w > l)
+ w=1;
+ else
+ break;
+ i++;
+ }
+ if (i >= a->top)
+ a->top++;
+ return(1);
+ }
+
+int BN_sub_word(BIGNUM *a, BN_ULONG w)
+ {
+ int i;
+
+ if (BN_is_zero(a) || a->neg)
+ {
+ a->neg=0;
+ i=BN_add_word(a,w);
+ a->neg=1;
+ return(i);
+ }
+
+ w&=BN_MASK2;
+ if ((a->top == 1) && (a->d[0] < w))
+ {
+ a->d[0]=w-a->d[0];
+ a->neg=1;
+ return(1);
+ }
+ i=0;
+ for (;;)
+ {
+ if (a->d[i] >= w)
+ {
+ a->d[i]-=w;
+ break;
+ }
+ else
+ {
+ a->d[i]=(a->d[i]-w)&BN_MASK2;
+ i++;
+ w=1;
+ }
+ }
+ if ((a->d[i] == 0) && (i == (a->top-1)))
+ a->top--;
+ return(1);
+ }
diff --git a/package/network/services/ead/src/tinysrp/clitest.c b/package/network/services/ead/src/tinysrp/clitest.c
new file mode 100644
index 0000000..faaa5dd
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/clitest.c
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 1997-1999 The Stanford SRP Authentication Project
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF
+ * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * In addition, the following conditions apply:
+ *
+ * 1. Any software that incorporates the SRP authentication technology
+ * must display the following acknowlegment:
+ * "This product uses the 'Secure Remote Password' cryptographic
+ * authentication system developed by Tom Wu (tjw@CS.Stanford.EDU)."
+ *
+ * 2. Any software that incorporates all or part of the SRP distribution
+ * itself must also display the following acknowledgment:
+ * "This product includes software developed by Tom Wu and Eugene
+ * Jhong for the SRP Distribution (http://srp.stanford.edu/srp/)."
+ *
+ * 3. Redistributions in source or binary form must retain an intact copy
+ * of this copyright notice and list of conditions.
+ */
+
+#include <stdio.h>
+#include "t_defines.h"
+#include "t_pwd.h"
+#include "t_client.h"
+
+int
+main()
+{
+ int index;
+ struct t_client * tc;
+ struct t_preconf *tcp;
+ struct t_num n;
+ struct t_num g;
+ struct t_num s;
+ struct t_num B;
+ char username[MAXUSERLEN];
+ char hexbuf[MAXHEXPARAMLEN];
+ char buf1[MAXPARAMLEN], buf2[MAXPARAMLEN], buf3[MAXSALTLEN];
+ unsigned char cbuf[20];
+ struct t_num * A;
+ unsigned char * skey;
+ char pass[128];
+
+ printf("Enter username: ");
+ fgets(username, sizeof(username), stdin);
+ username[strlen(username) - 1] = '\0';
+ printf("Enter index (from server): ");
+ fgets(hexbuf, sizeof(hexbuf), stdin);
+ index = atoi(hexbuf);
+ tcp = t_getpreparam(index - 1);
+ printf("Enter salt (from server): ");
+ fgets(hexbuf, sizeof(hexbuf), stdin);
+ s.data = buf3;
+ s.len = t_fromb64(s.data, hexbuf);
+
+ tc = t_clientopen(username, &tcp->modulus, &tcp->generator, &s);
+ if (tc == 0) {
+ printf("invalid n, g\n");
+ exit(1);
+ }
+
+ A = t_clientgenexp(tc);
+ printf("A (to server): %s\n", t_tob64(hexbuf, A->data, A->len));
+
+ t_getpass(pass, 128, "Enter password:");
+ t_clientpasswd(tc, pass);
+
+ printf("Enter B (from server): ");
+ fgets(hexbuf, sizeof(hexbuf), stdin);
+ B.data = buf1;
+ B.len = t_fromb64(B.data, hexbuf);
+
+ skey = t_clientgetkey(tc, &B);
+ printf("Session key: %s\n", t_tohex(hexbuf, skey, 40));
+ printf("Response (to server): %s\n",
+ t_tohex(hexbuf, t_clientresponse(tc), RESPONSE_LEN));
+
+ printf("Enter server response: ");
+ fgets(hexbuf, sizeof(hexbuf), stdin);
+ hexbuf[strlen(hexbuf) - 1] = '\0';
+ t_fromhex(cbuf, hexbuf);
+
+ if (t_clientverify(tc, cbuf) == 0)
+ printf("Server authentication successful.\n");
+ else
+ printf("Server authentication failed.\n");
+
+ t_clientclose(tc);
+
+ return 0;
+}
diff --git a/package/network/services/ead/src/tinysrp/config.h.in b/package/network/services/ead/src/tinysrp/config.h.in
new file mode 100644
index 0000000..a4b50c7
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/config.h.in
@@ -0,0 +1,79 @@
+/* config.h.in. Generated automatically from configure.in by autoheader. */
+
+/* Define if type char is unsigned and you are not using gcc. */
+#ifndef __CHAR_UNSIGNED__
+#undef __CHAR_UNSIGNED__
+#endif
+
+/* Define to empty if the keyword does not work. */
+#undef const
+
+/* Define as __inline if that's what the C compiler calls it. */
+#undef inline
+
+/* Define as the return type of signal handlers (int or void). */
+#undef RETSIGTYPE
+
+/* Define if you have the ANSI C header files. */
+#undef STDC_HEADERS
+
+/* Define if you can safely include both <sys/time.h> and <time.h>. */
+#undef TIME_WITH_SYS_TIME
+
+/* Define if your processor stores words with the most significant
+ byte first (like Motorola and SPARC, unlike Intel and VAX). */
+#undef WORDS_BIGENDIAN
+
+#undef SHA1HANDSOFF
+
+#undef POSIX_TERMIOS
+
+#undef POSIX_SIGTYPE
+
+#undef volatile
+
+/* The number of bytes in a int. */
+#undef SIZEOF_INT
+
+/* The number of bytes in a long. */
+#undef SIZEOF_LONG
+
+/* The number of bytes in a long long. */
+#undef SIZEOF_LONG_LONG
+
+/* The number of bytes in a short. */
+#undef SIZEOF_SHORT
+
+/* Define if you have the memcpy function. */
+#undef HAVE_MEMCPY
+
+/* Define if you have the sigaction function. */
+#undef HAVE_SIGACTION
+
+/* Define if you have the strchr function. */
+#undef HAVE_STRCHR
+
+/* Define if you have the <sgtty.h> header file. */
+#undef HAVE_SGTTY_H
+
+/* Define if you have the <sys/ioctl.h> header file. */
+#undef HAVE_SYS_IOCTL_H
+
+/* Define if you have the <sys/time.h> header file. */
+#undef HAVE_SYS_TIME_H
+
+/* Define if you have the <termio.h> header file. */
+#undef HAVE_TERMIO_H
+
+/* Define if you have the <termios.h> header file. */
+#undef HAVE_TERMIOS_H
+
+/* Define if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* Name of package */
+#undef PACKAGE
+
+/* Version number of package */
+#undef VERSION
+
diff --git a/package/network/services/ead/src/tinysrp/configure b/package/network/services/ead/src/tinysrp/configure
new file mode 100755
index 0000000..6ee76bf
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/configure
@@ -0,0 +1,2421 @@
+#! /bin/sh
+
+# Guess values for system-dependent variables and create Makefiles.
+# Generated automatically using autoconf version 2.13
+# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
+#
+# This configure script is free software; the Free Software Foundation
+# gives unlimited permission to copy, distribute and modify it.
+
+# Defaults:
+ac_help=
+ac_default_prefix=/usr/local
+# Any additions from configure.in:
+
+# Initialize some variables set by options.
+# The variables have the same names as the options, with
+# dashes changed to underlines.
+build=NONE
+cache_file=./config.cache
+exec_prefix=NONE
+host=NONE
+no_create=
+nonopt=NONE
+no_recursion=
+prefix=NONE
+program_prefix=NONE
+program_suffix=NONE
+program_transform_name=s,x,x,
+silent=
+site=
+srcdir=
+target=NONE
+verbose=
+x_includes=NONE
+x_libraries=NONE
+bindir='${exec_prefix}/bin'
+sbindir='${exec_prefix}/sbin'
+libexecdir='${exec_prefix}/libexec'
+datadir='${prefix}/share'
+sysconfdir='${prefix}/etc'
+sharedstatedir='${prefix}/com'
+localstatedir='${prefix}/var'
+libdir='${exec_prefix}/lib'
+includedir='${prefix}/include'
+oldincludedir='/usr/include'
+infodir='${prefix}/info'
+mandir='${prefix}/man'
+
+# Initialize some other variables.
+subdirs=
+MFLAGS= MAKEFLAGS=
+SHELL=${CONFIG_SHELL-/bin/sh}
+# Maximum number of lines to put in a shell here document.
+ac_max_here_lines=12
+
+ac_prev=
+for ac_option
+do
+
+ # If the previous option needs an argument, assign it.
+ if test -n "$ac_prev"; then
+ eval "$ac_prev=\$ac_option"
+ ac_prev=
+ continue
+ fi
+
+ case "$ac_option" in
+ -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
+ *) ac_optarg= ;;
+ esac
+
+ # Accept the important Cygnus configure options, so we can diagnose typos.
+
+ case "$ac_option" in
+
+ -bindir | --bindir | --bindi | --bind | --bin | --bi)
+ ac_prev=bindir ;;
+ -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
+ bindir="$ac_optarg" ;;
+
+ -build | --build | --buil | --bui | --bu)
+ ac_prev=build ;;
+ -build=* | --build=* | --buil=* | --bui=* | --bu=*)
+ build="$ac_optarg" ;;
+
+ -cache-file | --cache-file | --cache-fil | --cache-fi \
+ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
+ ac_prev=cache_file ;;
+ -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
+ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
+ cache_file="$ac_optarg" ;;
+
+ -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
+ ac_prev=datadir ;;
+ -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
+ | --da=*)
+ datadir="$ac_optarg" ;;
+
+ -disable-* | --disable-*)
+ ac_feature=`echo $ac_option|sed -e 's/-*disable-//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then
+ { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
+ fi
+ ac_feature=`echo $ac_feature| sed 's/-/_/g'`
+ eval "enable_${ac_feature}=no" ;;
+
+ -enable-* | --enable-*)
+ ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then
+ { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
+ fi
+ ac_feature=`echo $ac_feature| sed 's/-/_/g'`
+ case "$ac_option" in
+ *=*) ;;
+ *) ac_optarg=yes ;;
+ esac
+ eval "enable_${ac_feature}='$ac_optarg'" ;;
+
+ -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
+ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
+ | --exec | --exe | --ex)
+ ac_prev=exec_prefix ;;
+ -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
+ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
+ | --exec=* | --exe=* | --ex=*)
+ exec_prefix="$ac_optarg" ;;
+
+ -gas | --gas | --ga | --g)
+ # Obsolete; use --with-gas.
+ with_gas=yes ;;
+
+ -help | --help | --hel | --he)
+ # Omit some internal or obsolete options to make the list less imposing.
+ # This message is too long to be a string in the A/UX 3.1 sh.
+ cat << EOF
+Usage: configure [options] [host]
+Options: [defaults in brackets after descriptions]
+Configuration:
+ --cache-file=FILE cache test results in FILE
+ --help print this message
+ --no-create do not create output files
+ --quiet, --silent do not print \`checking...' messages
+ --version print the version of autoconf that created configure
+Directory and file names:
+ --prefix=PREFIX install architecture-independent files in PREFIX
+ [$ac_default_prefix]
+ --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
+ [same as prefix]
+ --bindir=DIR user executables in DIR [EPREFIX/bin]
+ --sbindir=DIR system admin executables in DIR [EPREFIX/sbin]
+ --libexecdir=DIR program executables in DIR [EPREFIX/libexec]
+ --datadir=DIR read-only architecture-independent data in DIR
+ [PREFIX/share]
+ --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc]
+ --sharedstatedir=DIR modifiable architecture-independent data in DIR
+ [PREFIX/com]
+ --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var]
+ --libdir=DIR object code libraries in DIR [EPREFIX/lib]
+ --includedir=DIR C header files in DIR [PREFIX/include]
+ --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include]
+ --infodir=DIR info documentation in DIR [PREFIX/info]
+ --mandir=DIR man documentation in DIR [PREFIX/man]
+ --srcdir=DIR find the sources in DIR [configure dir or ..]
+ --program-prefix=PREFIX prepend PREFIX to installed program names
+ --program-suffix=SUFFIX append SUFFIX to installed program names
+ --program-transform-name=PROGRAM
+ run sed PROGRAM on installed program names
+EOF
+ cat << EOF
+Host type:
+ --build=BUILD configure for building on BUILD [BUILD=HOST]
+ --host=HOST configure for HOST [guessed]
+ --target=TARGET configure for TARGET [TARGET=HOST]
+Features and packages:
+ --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
+ --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
+ --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
+ --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
+ --x-includes=DIR X include files are in DIR
+ --x-libraries=DIR X library files are in DIR
+EOF
+ if test -n "$ac_help"; then
+ echo "--enable and --with options recognized:$ac_help"
+ fi
+ exit 0 ;;
+
+ -host | --host | --hos | --ho)
+ ac_prev=host ;;
+ -host=* | --host=* | --hos=* | --ho=*)
+ host="$ac_optarg" ;;
+
+ -includedir | --includedir | --includedi | --included | --include \
+ | --includ | --inclu | --incl | --inc)
+ ac_prev=includedir ;;
+ -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
+ | --includ=* | --inclu=* | --incl=* | --inc=*)
+ includedir="$ac_optarg" ;;
+
+ -infodir | --infodir | --infodi | --infod | --info | --inf)
+ ac_prev=infodir ;;
+ -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
+ infodir="$ac_optarg" ;;
+
+ -libdir | --libdir | --libdi | --libd)
+ ac_prev=libdir ;;
+ -libdir=* | --libdir=* | --libdi=* | --libd=*)
+ libdir="$ac_optarg" ;;
+
+ -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
+ | --libexe | --libex | --libe)
+ ac_prev=libexecdir ;;
+ -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
+ | --libexe=* | --libex=* | --libe=*)
+ libexecdir="$ac_optarg" ;;
+
+ -localstatedir | --localstatedir | --localstatedi | --localstated \
+ | --localstate | --localstat | --localsta | --localst \
+ | --locals | --local | --loca | --loc | --lo)
+ ac_prev=localstatedir ;;
+ -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
+ | --localstate=* | --localstat=* | --localsta=* | --localst=* \
+ | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
+ localstatedir="$ac_optarg" ;;
+
+ -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
+ ac_prev=mandir ;;
+ -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
+ mandir="$ac_optarg" ;;
+
+ -nfp | --nfp | --nf)
+ # Obsolete; use --without-fp.
+ with_fp=no ;;
+
+ -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+ | --no-cr | --no-c)
+ no_create=yes ;;
+
+ -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
+ no_recursion=yes ;;
+
+ -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
+ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
+ | --oldin | --oldi | --old | --ol | --o)
+ ac_prev=oldincludedir ;;
+ -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
+ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
+ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
+ oldincludedir="$ac_optarg" ;;
+
+ -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
+ ac_prev=prefix ;;
+ -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
+ prefix="$ac_optarg" ;;
+
+ -program-prefix | --program-prefix | --program-prefi | --program-pref \
+ | --program-pre | --program-pr | --program-p)
+ ac_prev=program_prefix ;;
+ -program-prefix=* | --program-prefix=* | --program-prefi=* \
+ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
+ program_prefix="$ac_optarg" ;;
+
+ -program-suffix | --program-suffix | --program-suffi | --program-suff \
+ | --program-suf | --program-su | --program-s)
+ ac_prev=program_suffix ;;
+ -program-suffix=* | --program-suffix=* | --program-suffi=* \
+ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
+ program_suffix="$ac_optarg" ;;
+
+ -program-transform-name | --program-transform-name \
+ | --program-transform-nam | --program-transform-na \
+ | --program-transform-n | --program-transform- \
+ | --program-transform | --program-transfor \
+ | --program-transfo | --program-transf \
+ | --program-trans | --program-tran \
+ | --progr-tra | --program-tr | --program-t)
+ ac_prev=program_transform_name ;;
+ -program-transform-name=* | --program-transform-name=* \
+ | --program-transform-nam=* | --program-transform-na=* \
+ | --program-transform-n=* | --program-transform-=* \
+ | --program-transform=* | --program-transfor=* \
+ | --program-transfo=* | --program-transf=* \
+ | --program-trans=* | --program-tran=* \
+ | --progr-tra=* | --program-tr=* | --program-t=*)
+ program_transform_name="$ac_optarg" ;;
+
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil)
+ silent=yes ;;
+
+ -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+ ac_prev=sbindir ;;
+ -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+ | --sbi=* | --sb=*)
+ sbindir="$ac_optarg" ;;
+
+ -sharedstatedir | --sharedstatedir | --sharedstatedi \
+ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
+ | --sharedst | --shareds | --shared | --share | --shar \
+ | --sha | --sh)
+ ac_prev=sharedstatedir ;;
+ -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
+ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
+ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
+ | --sha=* | --sh=*)
+ sharedstatedir="$ac_optarg" ;;
+
+ -site | --site | --sit)
+ ac_prev=site ;;
+ -site=* | --site=* | --sit=*)
+ site="$ac_optarg" ;;
+
+ -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
+ ac_prev=srcdir ;;
+ -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
+ srcdir="$ac_optarg" ;;
+
+ -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
+ | --syscon | --sysco | --sysc | --sys | --sy)
+ ac_prev=sysconfdir ;;
+ -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
+ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
+ sysconfdir="$ac_optarg" ;;
+
+ -target | --target | --targe | --targ | --tar | --ta | --t)
+ ac_prev=target ;;
+ -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
+ target="$ac_optarg" ;;
+
+ -v | -verbose | --verbose | --verbos | --verbo | --verb)
+ verbose=yes ;;
+
+ -version | --version | --versio | --versi | --vers)
+ echo "configure generated by autoconf version 2.13"
+ exit 0 ;;
+
+ -with-* | --with-*)
+ ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then
+ { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
+ fi
+ ac_package=`echo $ac_package| sed 's/-/_/g'`
+ case "$ac_option" in
+ *=*) ;;
+ *) ac_optarg=yes ;;
+ esac
+ eval "with_${ac_package}='$ac_optarg'" ;;
+
+ -without-* | --without-*)
+ ac_package=`echo $ac_option|sed -e 's/-*without-//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then
+ { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
+ fi
+ ac_package=`echo $ac_package| sed 's/-/_/g'`
+ eval "with_${ac_package}=no" ;;
+
+ --x)
+ # Obsolete; use --with-x.
+ with_x=yes ;;
+
+ -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
+ | --x-incl | --x-inc | --x-in | --x-i)
+ ac_prev=x_includes ;;
+ -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
+ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
+ x_includes="$ac_optarg" ;;
+
+ -x-libraries | --x-libraries | --x-librarie | --x-librari \
+ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
+ ac_prev=x_libraries ;;
+ -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
+ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
+ x_libraries="$ac_optarg" ;;
+
+ -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; }
+ ;;
+
+ *)
+ if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then
+ echo "configure: warning: $ac_option: invalid host type" 1>&2
+ fi
+ if test "x$nonopt" != xNONE; then
+ { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; }
+ fi
+ nonopt="$ac_option"
+ ;;
+
+ esac
+done
+
+if test -n "$ac_prev"; then
+ { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; }
+fi
+
+trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
+
+# File descriptor usage:
+# 0 standard input
+# 1 file creation
+# 2 errors and warnings
+# 3 some systems may open it to /dev/tty
+# 4 used on the Kubota Titan
+# 6 checking for... messages and results
+# 5 compiler messages saved in config.log
+if test "$silent" = yes; then
+ exec 6>/dev/null
+else
+ exec 6>&1
+fi
+exec 5>./config.log
+
+echo "\
+This file contains any messages produced by compilers while
+running configure, to aid debugging if configure makes a mistake.
+" 1>&5
+
+# Strip out --no-create and --no-recursion so they do not pile up.
+# Also quote any args containing shell metacharacters.
+ac_configure_args=
+for ac_arg
+do
+ case "$ac_arg" in
+ -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+ | --no-cr | --no-c) ;;
+ -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;;
+ *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*)
+ ac_configure_args="$ac_configure_args '$ac_arg'" ;;
+ *) ac_configure_args="$ac_configure_args $ac_arg" ;;
+ esac
+done
+
+# NLS nuisances.
+# Only set these to C if already set. These must not be set unconditionally
+# because not all systems understand e.g. LANG=C (notably SCO).
+# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'!
+# Non-C LC_CTYPE values break the ctype check.
+if test "${LANG+set}" = set; then LANG=C; export LANG; fi
+if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
+if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
+if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi
+
+# confdefs.h avoids OS command line length limits that DEFS can exceed.
+rm -rf conftest* confdefs.h
+# AIX cpp loses on an empty file, so make sure it contains at least a newline.
+echo > confdefs.h
+
+# A filename unique to this package, relative to the directory that
+# configure is in, which we can look for to find out if srcdir is correct.
+ac_unique_file=t_pwd.h
+
+# Find the source files, if location was not specified.
+if test -z "$srcdir"; then
+ ac_srcdir_defaulted=yes
+ # Try the directory containing this script, then its parent.
+ ac_prog=$0
+ ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'`
+ test "x$ac_confdir" = "x$ac_prog" && ac_confdir=.
+ srcdir=$ac_confdir
+ if test ! -r $srcdir/$ac_unique_file; then
+ srcdir=..
+ fi
+else
+ ac_srcdir_defaulted=no
+fi
+if test ! -r $srcdir/$ac_unique_file; then
+ if test "$ac_srcdir_defaulted" = yes; then
+ { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; }
+ else
+ { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; }
+ fi
+fi
+srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'`
+
+# Prefer explicitly selected file to automatically selected ones.
+if test -z "$CONFIG_SITE"; then
+ if test "x$prefix" != xNONE; then
+ CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
+ else
+ CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
+ fi
+fi
+for ac_site_file in $CONFIG_SITE; do
+ if test -r "$ac_site_file"; then
+ echo "loading site script $ac_site_file"
+ . "$ac_site_file"
+ fi
+done
+
+if test -r "$cache_file"; then
+ echo "loading cache $cache_file"
+ . $cache_file
+else
+ echo "creating cache $cache_file"
+ > $cache_file
+fi
+
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
+
+ac_exeext=
+ac_objext=o
+if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
+ # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
+ if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
+ ac_n= ac_c='
+' ac_t=' '
+ else
+ ac_n=-n ac_c= ac_t=
+ fi
+else
+ ac_n= ac_c='\c' ac_t=
+fi
+
+
+
+
+
+ac_aux_dir=
+for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do
+ if test -f $ac_dir/install-sh; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install-sh -c"
+ break
+ elif test -f $ac_dir/install.sh; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install.sh -c"
+ break
+ fi
+done
+if test -z "$ac_aux_dir"; then
+ { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; }
+fi
+ac_config_guess=$ac_aux_dir/config.guess
+ac_config_sub=$ac_aux_dir/config.sub
+ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
+
+# Find a good install program. We prefer a C program (faster),
+# so one script is as good as another. But avoid the broken or
+# incompatible versions:
+# SysV /etc/install, /usr/sbin/install
+# SunOS /usr/etc/install
+# IRIX /sbin/install
+# AIX /bin/install
+# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
+# AFS /usr/afsws/bin/install, which mishandles nonexistent args
+# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
+# ./install, which can be erroneously created by make from ./install.sh.
+echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
+echo "configure:559: checking for a BSD compatible install" >&5
+if test -z "$INSTALL"; then
+if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":"
+ for ac_dir in $PATH; do
+ # Account for people who put trailing slashes in PATH elements.
+ case "$ac_dir/" in
+ /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
+ *)
+ # OSF1 and SCO ODT 3.0 have their own names for install.
+ # Don't use installbsd from OSF since it installs stuff as root
+ # by default.
+ for ac_prog in ginstall scoinst install; do
+ if test -f $ac_dir/$ac_prog; then
+ if test $ac_prog = install &&
+ grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
+ # AIX install. It has an incompatible calling convention.
+ :
+ else
+ ac_cv_path_install="$ac_dir/$ac_prog -c"
+ break 2
+ fi
+ fi
+ done
+ ;;
+ esac
+ done
+ IFS="$ac_save_IFS"
+
+fi
+ if test "${ac_cv_path_install+set}" = set; then
+ INSTALL="$ac_cv_path_install"
+ else
+ # As a last resort, use the slow shell script. We don't cache a
+ # path for INSTALL within a source directory, because that will
+ # break other packages using the cache if that directory is
+ # removed, or if the path is relative.
+ INSTALL="$ac_install_sh"
+ fi
+fi
+echo "$ac_t""$INSTALL" 1>&6
+
+# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
+# It thinks the first close brace ends the variable substitution.
+test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
+
+test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}'
+
+test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
+
+echo $ac_n "checking whether build environment is sane""... $ac_c" 1>&6
+echo "configure:612: checking whether build environment is sane" >&5
+# Just in case
+sleep 1
+echo timestamp > conftestfile
+# Do `set' in a subshell so we don't clobber the current shell's
+# arguments. Must try -L first in case configure is actually a
+# symlink; some systems play weird games with the mod time of symlinks
+# (eg FreeBSD returns the mod time of the symlink's containing
+# directory).
+if (
+ set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null`
+ if test "$*" = "X"; then
+ # -L didn't work.
+ set X `ls -t $srcdir/configure conftestfile`
+ fi
+ if test "$*" != "X $srcdir/configure conftestfile" \
+ && test "$*" != "X conftestfile $srcdir/configure"; then
+
+ # If neither matched, then we have a broken ls. This can happen
+ # if, for instance, CONFIG_SHELL is bash and it inherits a
+ # broken ls alias from the environment. This has actually
+ # happened. Such a system could not be considered "sane".
+ { echo "configure: error: ls -t appears to fail. Make sure there is not a broken
+alias in your environment" 1>&2; exit 1; }
+ fi
+
+ test "$2" = conftestfile
+ )
+then
+ # Ok.
+ :
+else
+ { echo "configure: error: newly created file is older than distributed files!
+Check your system clock" 1>&2; exit 1; }
+fi
+rm -f conftest*
+echo "$ac_t""yes" 1>&6
+if test "$program_transform_name" = s,x,x,; then
+ program_transform_name=
+else
+ # Double any \ or $. echo might interpret backslashes.
+ cat <<\EOF_SED > conftestsed
+s,\\,\\\\,g; s,\$,$$,g
+EOF_SED
+ program_transform_name="`echo $program_transform_name|sed -f conftestsed`"
+ rm -f conftestsed
+fi
+test "$program_prefix" != NONE &&
+ program_transform_name="s,^,${program_prefix},; $program_transform_name"
+# Use a double $ so make ignores it.
+test "$program_suffix" != NONE &&
+ program_transform_name="s,\$\$,${program_suffix},; $program_transform_name"
+
+# sed with no file args requires a program.
+test "$program_transform_name" = "" && program_transform_name="s,x,x,"
+
+echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
+echo "configure:669: checking whether ${MAKE-make} sets \${MAKE}" >&5
+set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftestmake <<\EOF
+all:
+ @echo 'ac_maketemp="${MAKE}"'
+EOF
+# GNU make sometimes prints "make[1]: Entering...", which would confuse us.
+eval `${MAKE-make} -f conftestmake 2>/dev/null | grep temp=`
+if test -n "$ac_maketemp"; then
+ eval ac_cv_prog_make_${ac_make}_set=yes
+else
+ eval ac_cv_prog_make_${ac_make}_set=no
+fi
+rm -f conftestmake
+fi
+if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ SET_MAKE=
+else
+ echo "$ac_t""no" 1>&6
+ SET_MAKE="MAKE=${MAKE-make}"
+fi
+
+
+
+PACKAGE=libtinysrp
+
+VERSION=0.7.5
+
+if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
+ { echo "configure: error: source directory already configured; run "make distclean" there first" 1>&2; exit 1; }
+fi
+cat >> confdefs.h <<EOF
+#define PACKAGE "$PACKAGE"
+EOF
+
+cat >> confdefs.h <<EOF
+#define VERSION "$VERSION"
+EOF
+
+
+
+missing_dir=`cd $ac_aux_dir && pwd`
+echo $ac_n "checking for working aclocal""... $ac_c" 1>&6
+echo "configure:716: checking for working aclocal" >&5
+# Run test in a subshell; some versions of sh will print an error if
+# an executable is not found, even if stderr is redirected.
+# Redirect stdin to placate older versions of autoconf. Sigh.
+if (aclocal --version) < /dev/null > /dev/null 2>&1; then
+ ACLOCAL=aclocal
+ echo "$ac_t""found" 1>&6
+else
+ ACLOCAL="$missing_dir/missing aclocal"
+ echo "$ac_t""missing" 1>&6
+fi
+
+echo $ac_n "checking for working autoconf""... $ac_c" 1>&6
+echo "configure:729: checking for working autoconf" >&5
+# Run test in a subshell; some versions of sh will print an error if
+# an executable is not found, even if stderr is redirected.
+# Redirect stdin to placate older versions of autoconf. Sigh.
+if (autoconf --version) < /dev/null > /dev/null 2>&1; then
+ AUTOCONF=autoconf
+ echo "$ac_t""found" 1>&6
+else
+ AUTOCONF="$missing_dir/missing autoconf"
+ echo "$ac_t""missing" 1>&6
+fi
+
+echo $ac_n "checking for working automake""... $ac_c" 1>&6
+echo "configure:742: checking for working automake" >&5
+# Run test in a subshell; some versions of sh will print an error if
+# an executable is not found, even if stderr is redirected.
+# Redirect stdin to placate older versions of autoconf. Sigh.
+if (automake --version) < /dev/null > /dev/null 2>&1; then
+ AUTOMAKE=automake
+ echo "$ac_t""found" 1>&6
+else
+ AUTOMAKE="$missing_dir/missing automake"
+ echo "$ac_t""missing" 1>&6
+fi
+
+echo $ac_n "checking for working autoheader""... $ac_c" 1>&6
+echo "configure:755: checking for working autoheader" >&5
+# Run test in a subshell; some versions of sh will print an error if
+# an executable is not found, even if stderr is redirected.
+# Redirect stdin to placate older versions of autoconf. Sigh.
+if (autoheader --version) < /dev/null > /dev/null 2>&1; then
+ AUTOHEADER=autoheader
+ echo "$ac_t""found" 1>&6
+else
+ AUTOHEADER="$missing_dir/missing autoheader"
+ echo "$ac_t""missing" 1>&6
+fi
+
+echo $ac_n "checking for working makeinfo""... $ac_c" 1>&6
+echo "configure:768: checking for working makeinfo" >&5
+# Run test in a subshell; some versions of sh will print an error if
+# an executable is not found, even if stderr is redirected.
+# Redirect stdin to placate older versions of autoconf. Sigh.
+if (makeinfo --version) < /dev/null > /dev/null 2>&1; then
+ MAKEINFO=makeinfo
+ echo "$ac_t""found" 1>&6
+else
+ MAKEINFO="$missing_dir/missing makeinfo"
+ echo "$ac_t""missing" 1>&6
+fi
+
+
+
+test "$CFLAGS" = "" && CFLAGS="-O2"
+
+
+# Extract the first word of "gcc", so it can be a program name with args.
+set dummy gcc; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:788: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_CC="gcc"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+ echo "$ac_t""$CC" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+if test -z "$CC"; then
+ # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:818: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_prog_rejected=no
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then
+ ac_prog_rejected=yes
+ continue
+ fi
+ ac_cv_prog_CC="cc"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+if test $ac_prog_rejected = yes; then
+ # We found a bogon in the path, so make sure we never use it.
+ set dummy $ac_cv_prog_CC
+ shift
+ if test $# -gt 0; then
+ # We chose a different compiler from the bogus one.
+ # However, it has the same basename, so the bogon will be chosen
+ # first if we set CC to just the basename; use the full file name.
+ shift
+ set dummy "$ac_dir/$ac_word" "$@"
+ shift
+ ac_cv_prog_CC="$@"
+ fi
+fi
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+ echo "$ac_t""$CC" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+ if test -z "$CC"; then
+ case "`uname -s`" in
+ *win32* | *WIN32*)
+ # Extract the first word of "cl", so it can be a program name with args.
+set dummy cl; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:869: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_CC="cl"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+ echo "$ac_t""$CC" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+ ;;
+ esac
+ fi
+ test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; }
+fi
+
+echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
+echo "configure:901: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
+
+cat > conftest.$ac_ext << EOF
+
+#line 912 "configure"
+#include "confdefs.h"
+
+main(){return(0);}
+EOF
+if { (eval echo configure:917: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ ac_cv_prog_cc_works=yes
+ # If we can't run a trivial program, we are probably using a cross compiler.
+ if (./conftest; exit) 2>/dev/null; then
+ ac_cv_prog_cc_cross=no
+ else
+ ac_cv_prog_cc_cross=yes
+ fi
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ ac_cv_prog_cc_works=no
+fi
+rm -fr conftest*
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
+
+echo "$ac_t""$ac_cv_prog_cc_works" 1>&6
+if test $ac_cv_prog_cc_works = no; then
+ { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
+fi
+echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
+echo "configure:943: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
+cross_compiling=$ac_cv_prog_cc_cross
+
+echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
+echo "configure:948: checking whether we are using GNU C" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.c <<EOF
+#ifdef __GNUC__
+ yes;
+#endif
+EOF
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:957: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+ ac_cv_prog_gcc=yes
+else
+ ac_cv_prog_gcc=no
+fi
+fi
+
+echo "$ac_t""$ac_cv_prog_gcc" 1>&6
+
+if test $ac_cv_prog_gcc = yes; then
+ GCC=yes
+else
+ GCC=
+fi
+
+ac_test_CFLAGS="${CFLAGS+set}"
+ac_save_CFLAGS="$CFLAGS"
+CFLAGS=
+echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
+echo "configure:976: checking whether ${CC-cc} accepts -g" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ echo 'void f(){}' > conftest.c
+if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
+ ac_cv_prog_cc_g=yes
+else
+ ac_cv_prog_cc_g=no
+fi
+rm -f conftest*
+
+fi
+
+echo "$ac_t""$ac_cv_prog_cc_g" 1>&6
+if test "$ac_test_CFLAGS" = set; then
+ CFLAGS="$ac_save_CFLAGS"
+elif test $ac_cv_prog_cc_g = yes; then
+ if test "$GCC" = yes; then
+ CFLAGS="-g -O2"
+ else
+ CFLAGS="-g"
+ fi
+else
+ if test "$GCC" = yes; then
+ CFLAGS="-O2"
+ else
+ CFLAGS=
+ fi
+fi
+
+# Find a good install program. We prefer a C program (faster),
+# so one script is as good as another. But avoid the broken or
+# incompatible versions:
+# SysV /etc/install, /usr/sbin/install
+# SunOS /usr/etc/install
+# IRIX /sbin/install
+# AIX /bin/install
+# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
+# AFS /usr/afsws/bin/install, which mishandles nonexistent args
+# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
+# ./install, which can be erroneously created by make from ./install.sh.
+echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
+echo "configure:1019: checking for a BSD compatible install" >&5
+if test -z "$INSTALL"; then
+if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":"
+ for ac_dir in $PATH; do
+ # Account for people who put trailing slashes in PATH elements.
+ case "$ac_dir/" in
+ /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
+ *)
+ # OSF1 and SCO ODT 3.0 have their own names for install.
+ # Don't use installbsd from OSF since it installs stuff as root
+ # by default.
+ for ac_prog in ginstall scoinst install; do
+ if test -f $ac_dir/$ac_prog; then
+ if test $ac_prog = install &&
+ grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
+ # AIX install. It has an incompatible calling convention.
+ :
+ else
+ ac_cv_path_install="$ac_dir/$ac_prog -c"
+ break 2
+ fi
+ fi
+ done
+ ;;
+ esac
+ done
+ IFS="$ac_save_IFS"
+
+fi
+ if test "${ac_cv_path_install+set}" = set; then
+ INSTALL="$ac_cv_path_install"
+ else
+ # As a last resort, use the slow shell script. We don't cache a
+ # path for INSTALL within a source directory, because that will
+ # break other packages using the cache if that directory is
+ # removed, or if the path is relative.
+ INSTALL="$ac_install_sh"
+ fi
+fi
+echo "$ac_t""$INSTALL" 1>&6
+
+# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
+# It thinks the first close brace ends the variable substitution.
+test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
+
+test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}'
+
+test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
+
+echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6
+echo "configure:1072: checking whether ln -s works" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_LN_S'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ rm -f conftestdata
+if ln -s X conftestdata 2>/dev/null
+then
+ rm -f conftestdata
+ ac_cv_prog_LN_S="ln -s"
+else
+ ac_cv_prog_LN_S=ln
+fi
+fi
+LN_S="$ac_cv_prog_LN_S"
+if test "$ac_cv_prog_LN_S" = "ln -s"; then
+ echo "$ac_t""yes" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+# Extract the first word of "ranlib", so it can be a program name with args.
+set dummy ranlib; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:1095: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$RANLIB"; then
+ ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_RANLIB="ranlib"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+ test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":"
+fi
+fi
+RANLIB="$ac_cv_prog_RANLIB"
+if test -n "$RANLIB"; then
+ echo "$ac_t""$RANLIB" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+if test "$program_transform_name" = s,x,x,; then
+ program_transform_name=
+else
+ # Double any \ or $. echo might interpret backslashes.
+ cat <<\EOF_SED > conftestsed
+s,\\,\\\\,g; s,\$,$$,g
+EOF_SED
+ program_transform_name="`echo $program_transform_name|sed -f conftestsed`"
+ rm -f conftestsed
+fi
+test "$program_prefix" != NONE &&
+ program_transform_name="s,^,${program_prefix},; $program_transform_name"
+# Use a double $ so make ignores it.
+test "$program_suffix" != NONE &&
+ program_transform_name="s,\$\$,${program_suffix},; $program_transform_name"
+
+# sed with no file args requires a program.
+test "$program_transform_name" = "" && program_transform_name="s,x,x,"
+
+
+
+echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
+echo "configure:1144: checking how to run the C preprocessor" >&5
+# On Suns, sometimes $CPP names a directory.
+if test -n "$CPP" && test -d "$CPP"; then
+ CPP=
+fi
+if test -z "$CPP"; then
+if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ # This must be in double quotes, not single quotes, because CPP may get
+ # substituted into the Makefile and "${CC-cc}" will confuse make.
+ CPP="${CC-cc} -E"
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp.
+ cat > conftest.$ac_ext <<EOF
+#line 1159 "configure"
+#include "confdefs.h"
+#include <assert.h>
+Syntax Error
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1165: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ :
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ CPP="${CC-cc} -E -traditional-cpp"
+ cat > conftest.$ac_ext <<EOF
+#line 1176 "configure"
+#include "confdefs.h"
+#include <assert.h>
+Syntax Error
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1182: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ :
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ CPP="${CC-cc} -nologo -E"
+ cat > conftest.$ac_ext <<EOF
+#line 1193 "configure"
+#include "confdefs.h"
+#include <assert.h>
+Syntax Error
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1199: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ :
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ CPP=/lib/cpp
+fi
+rm -f conftest*
+fi
+rm -f conftest*
+fi
+rm -f conftest*
+ ac_cv_prog_CPP="$CPP"
+fi
+ CPP="$ac_cv_prog_CPP"
+else
+ ac_cv_prog_CPP="$CPP"
+fi
+echo "$ac_t""$CPP" 1>&6
+
+echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
+echo "configure:1224: checking for ANSI C header files" >&5
+if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1229 "configure"
+#include "confdefs.h"
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1237: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ ac_cv_header_stdc=yes
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+if test $ac_cv_header_stdc = yes; then
+ # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+cat > conftest.$ac_ext <<EOF
+#line 1254 "configure"
+#include "confdefs.h"
+#include <string.h>
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "memchr" >/dev/null 2>&1; then
+ :
+else
+ rm -rf conftest*
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+cat > conftest.$ac_ext <<EOF
+#line 1272 "configure"
+#include "confdefs.h"
+#include <stdlib.h>
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "free" >/dev/null 2>&1; then
+ :
+else
+ rm -rf conftest*
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+if test "$cross_compiling" = yes; then
+ :
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1293 "configure"
+#include "confdefs.h"
+#include <ctype.h>
+#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int main () { int i; for (i = 0; i < 256; i++)
+if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
+exit (0); }
+
+EOF
+if { (eval echo configure:1304: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+ :
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ ac_cv_header_stdc=no
+fi
+rm -fr conftest*
+fi
+
+fi
+fi
+
+echo "$ac_t""$ac_cv_header_stdc" 1>&6
+if test $ac_cv_header_stdc = yes; then
+ cat >> confdefs.h <<\EOF
+#define STDC_HEADERS 1
+EOF
+
+fi
+
+for ac_hdr in sgtty.h sys/ioctl.h sys/time.h termio.h termios.h unistd.h
+do
+ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+echo "configure:1331: checking for $ac_hdr" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1336 "configure"
+#include "confdefs.h"
+#include <$ac_hdr>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1341: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_hdr 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+
+
+echo $ac_n "checking for working const""... $ac_c" 1>&6
+echo "configure:1370: checking for working const" >&5
+if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1375 "configure"
+#include "confdefs.h"
+
+int main() {
+
+/* Ultrix mips cc rejects this. */
+typedef int charset[2]; const charset x;
+/* SunOS 4.1.1 cc rejects this. */
+char const *const *ccp;
+char **p;
+/* NEC SVR4.0.2 mips cc rejects this. */
+struct point {int x, y;};
+static struct point const zero = {0,0};
+/* AIX XL C 1.02.0.0 rejects this.
+ It does not let you subtract one const X* pointer from another in an arm
+ of an if-expression whose if-part is not a constant expression */
+const char *g = "string";
+ccp = &g + (g ? g-g : 0);
+/* HPUX 7.0 cc rejects these. */
+++ccp;
+p = (char**) ccp;
+ccp = (char const *const *) p;
+{ /* SCO 3.2v4 cc rejects this. */
+ char *t;
+ char const *s = 0 ? (char *) 0 : (char const *) 0;
+
+ *t++ = 0;
+}
+{ /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */
+ int x[] = {25, 17};
+ const int *foo = &x[0];
+ ++foo;
+}
+{ /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
+ typedef const int *iptr;
+ iptr p = 0;
+ ++p;
+}
+{ /* AIX XL C 1.02.0.0 rejects this saying
+ "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
+ struct s { int j; const int *ap[3]; };
+ struct s *b; b->j = 5;
+}
+{ /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
+ const int foo = 10;
+}
+
+; return 0; }
+EOF
+if { (eval echo configure:1424: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ ac_cv_c_const=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_c_const=no
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$ac_cv_c_const" 1>&6
+if test $ac_cv_c_const = no; then
+ cat >> confdefs.h <<\EOF
+#define const
+EOF
+
+fi
+
+echo $ac_n "checking for inline""... $ac_c" 1>&6
+echo "configure:1445: checking for inline" >&5
+if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ ac_cv_c_inline=no
+for ac_kw in inline __inline__ __inline; do
+ cat > conftest.$ac_ext <<EOF
+#line 1452 "configure"
+#include "confdefs.h"
+
+int main() {
+} $ac_kw foo() {
+; return 0; }
+EOF
+if { (eval echo configure:1459: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ ac_cv_c_inline=$ac_kw; break
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+fi
+rm -f conftest*
+done
+
+fi
+
+echo "$ac_t""$ac_cv_c_inline" 1>&6
+case "$ac_cv_c_inline" in
+ inline | yes) ;;
+ no) cat >> confdefs.h <<\EOF
+#define inline
+EOF
+ ;;
+ *) cat >> confdefs.h <<EOF
+#define inline $ac_cv_c_inline
+EOF
+ ;;
+esac
+
+echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
+echo "configure:1485: checking whether time.h and sys/time.h may both be included" >&5
+if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1490 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#include <sys/time.h>
+#include <time.h>
+int main() {
+struct tm *tp;
+; return 0; }
+EOF
+if { (eval echo configure:1499: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ ac_cv_header_time=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_header_time=no
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$ac_cv_header_time" 1>&6
+if test $ac_cv_header_time = yes; then
+ cat >> confdefs.h <<\EOF
+#define TIME_WITH_SYS_TIME 1
+EOF
+
+fi
+
+echo $ac_n "checking whether byte ordering is bigendian""... $ac_c" 1>&6
+echo "configure:1520: checking whether byte ordering is bigendian" >&5
+if eval "test \"`echo '$''{'ac_cv_c_bigendian'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ ac_cv_c_bigendian=unknown
+# See if sys/param.h defines the BYTE_ORDER macro.
+cat > conftest.$ac_ext <<EOF
+#line 1527 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#include <sys/param.h>
+int main() {
+
+#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
+ bogus endian macros
+#endif
+; return 0; }
+EOF
+if { (eval echo configure:1538: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ # It does; now see whether it defined to BIG_ENDIAN or not.
+cat > conftest.$ac_ext <<EOF
+#line 1542 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#include <sys/param.h>
+int main() {
+
+#if BYTE_ORDER != BIG_ENDIAN
+ not big endian
+#endif
+; return 0; }
+EOF
+if { (eval echo configure:1553: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ ac_cv_c_bigendian=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_c_bigendian=no
+fi
+rm -f conftest*
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+fi
+rm -f conftest*
+if test $ac_cv_c_bigendian = unknown; then
+if test "$cross_compiling" = yes; then
+ { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1573 "configure"
+#include "confdefs.h"
+main () {
+ /* Are we little or big endian? From Harbison&Steele. */
+ union
+ {
+ long l;
+ char c[sizeof (long)];
+ } u;
+ u.l = 1;
+ exit (u.c[sizeof (long) - 1] == 1);
+}
+EOF
+if { (eval echo configure:1586: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+ ac_cv_c_bigendian=no
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ ac_cv_c_bigendian=yes
+fi
+rm -fr conftest*
+fi
+
+fi
+fi
+
+echo "$ac_t""$ac_cv_c_bigendian" 1>&6
+if test $ac_cv_c_bigendian = yes; then
+ cat >> confdefs.h <<\EOF
+#define WORDS_BIGENDIAN 1
+EOF
+
+fi
+
+echo $ac_n "checking size of short""... $ac_c" 1>&6
+echo "configure:1610: checking size of short" >&5
+if eval "test \"`echo '$''{'ac_cv_sizeof_short'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test "$cross_compiling" = yes; then
+ { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1618 "configure"
+#include "confdefs.h"
+#include <stdio.h>
+main()
+{
+ FILE *f=fopen("conftestval", "w");
+ if (!f) exit(1);
+ fprintf(f, "%d\n", sizeof(short));
+ exit(0);
+}
+EOF
+if { (eval echo configure:1629: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+ ac_cv_sizeof_short=`cat conftestval`
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ ac_cv_sizeof_short=0
+fi
+rm -fr conftest*
+fi
+
+fi
+echo "$ac_t""$ac_cv_sizeof_short" 1>&6
+cat >> confdefs.h <<EOF
+#define SIZEOF_SHORT $ac_cv_sizeof_short
+EOF
+
+
+echo $ac_n "checking size of int""... $ac_c" 1>&6
+echo "configure:1649: checking size of int" >&5
+if eval "test \"`echo '$''{'ac_cv_sizeof_int'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test "$cross_compiling" = yes; then
+ { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1657 "configure"
+#include "confdefs.h"
+#include <stdio.h>
+main()
+{
+ FILE *f=fopen("conftestval", "w");
+ if (!f) exit(1);
+ fprintf(f, "%d\n", sizeof(int));
+ exit(0);
+}
+EOF
+if { (eval echo configure:1668: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+ ac_cv_sizeof_int=`cat conftestval`
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ ac_cv_sizeof_int=0
+fi
+rm -fr conftest*
+fi
+
+fi
+echo "$ac_t""$ac_cv_sizeof_int" 1>&6
+cat >> confdefs.h <<EOF
+#define SIZEOF_INT $ac_cv_sizeof_int
+EOF
+
+
+echo $ac_n "checking size of long""... $ac_c" 1>&6
+echo "configure:1688: checking size of long" >&5
+if eval "test \"`echo '$''{'ac_cv_sizeof_long'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test "$cross_compiling" = yes; then
+ { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1696 "configure"
+#include "confdefs.h"
+#include <stdio.h>
+main()
+{
+ FILE *f=fopen("conftestval", "w");
+ if (!f) exit(1);
+ fprintf(f, "%d\n", sizeof(long));
+ exit(0);
+}
+EOF
+if { (eval echo configure:1707: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+ ac_cv_sizeof_long=`cat conftestval`
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ ac_cv_sizeof_long=0
+fi
+rm -fr conftest*
+fi
+
+fi
+echo "$ac_t""$ac_cv_sizeof_long" 1>&6
+cat >> confdefs.h <<EOF
+#define SIZEOF_LONG $ac_cv_sizeof_long
+EOF
+
+
+echo $ac_n "checking size of long long""... $ac_c" 1>&6
+echo "configure:1727: checking size of long long" >&5
+if eval "test \"`echo '$''{'ac_cv_sizeof_long_long'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test "$cross_compiling" = yes; then
+ { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1735 "configure"
+#include "confdefs.h"
+#include <stdio.h>
+main()
+{
+ FILE *f=fopen("conftestval", "w");
+ if (!f) exit(1);
+ fprintf(f, "%d\n", sizeof(long long));
+ exit(0);
+}
+EOF
+if { (eval echo configure:1746: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+ ac_cv_sizeof_long_long=`cat conftestval`
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ ac_cv_sizeof_long_long=0
+fi
+rm -fr conftest*
+fi
+
+fi
+echo "$ac_t""$ac_cv_sizeof_long_long" 1>&6
+cat >> confdefs.h <<EOF
+#define SIZEOF_LONG_LONG $ac_cv_sizeof_long_long
+EOF
+
+
+cat > conftest.$ac_ext <<EOF
+#line 1766 "configure"
+#include "confdefs.h"
+
+int main() {
+volatile int i;
+; return 0; }
+EOF
+if { (eval echo configure:1773: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ :
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ cat >> confdefs.h <<\EOF
+#define volatile
+EOF
+
+fi
+rm -f conftest*
+echo $ac_n "checking whether char is unsigned""... $ac_c" 1>&6
+echo "configure:1786: checking whether char is unsigned" >&5
+if eval "test \"`echo '$''{'ac_cv_c_char_unsigned'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test "$GCC" = yes; then
+ # GCC predefines this symbol on systems where it applies.
+cat > conftest.$ac_ext <<EOF
+#line 1793 "configure"
+#include "confdefs.h"
+#ifdef __CHAR_UNSIGNED__
+ yes
+#endif
+
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "yes" >/dev/null 2>&1; then
+ rm -rf conftest*
+ ac_cv_c_char_unsigned=yes
+else
+ rm -rf conftest*
+ ac_cv_c_char_unsigned=no
+fi
+rm -f conftest*
+
+else
+if test "$cross_compiling" = yes; then
+ { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1815 "configure"
+#include "confdefs.h"
+/* volatile prevents gcc2 from optimizing the test away on sparcs. */
+#if !defined(__STDC__) || __STDC__ != 1
+#define volatile
+#endif
+main() {
+ volatile char c = 255; exit(c < 0);
+}
+EOF
+if { (eval echo configure:1825: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+ ac_cv_c_char_unsigned=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ ac_cv_c_char_unsigned=no
+fi
+rm -fr conftest*
+fi
+
+fi
+fi
+
+echo "$ac_t""$ac_cv_c_char_unsigned" 1>&6
+if test $ac_cv_c_char_unsigned = yes && test "$GCC" != yes; then
+ cat >> confdefs.h <<\EOF
+#define __CHAR_UNSIGNED__ 1
+EOF
+
+fi
+
+
+if test "$ac_cv_c_char_unsigned" = "yes"; then
+ signed=-signed
+fi
+
+
+for ac_func in sigaction strchr memcpy
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:1857: checking for $ac_func" >&5
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1862 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:1885: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_func 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+
+echo $ac_n "checking POSIX signal handlers""... $ac_c" 1>&6
+echo "configure:1911: checking POSIX signal handlers" >&5
+if eval "test \"`echo '$''{'ac_cv_has_posix_signals'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1916 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#include <signal.h>
+#ifdef signal
+#undef signal
+#endif
+extern void (*signal ()) ();
+int main() {
+
+; return 0; }
+EOF
+if { (eval echo configure:1928: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ ac_cv_has_posix_signals=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_has_posix_signals=no
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$ac_cv_has_posix_signals" 1>&6
+if test $ac_cv_has_posix_signals = yes; then
+ cat >> confdefs.h <<\EOF
+#define RETSIGTYPE void
+EOF
+ cat >> confdefs.h <<\EOF
+#define POSIX_SIGTYPE 1
+EOF
+
+else
+ if test $ac_cv_type_signal = void; then
+ cat >> confdefs.h <<\EOF
+#define RETSIGTYPE void
+EOF
+
+ else
+ cat >> confdefs.h <<\EOF
+#define RETSIGTYPE int
+EOF
+
+ fi
+fi
+ac_safe=`echo "termios.h" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for termios.h""... $ac_c" 1>&6
+echo "configure:1964: checking for termios.h" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1969 "configure"
+#include "confdefs.h"
+#include <termios.h>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1974: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ echo $ac_n "checking for cfsetispeed""... $ac_c" 1>&6
+echo "configure:1991: checking for cfsetispeed" >&5
+if eval "test \"`echo '$''{'ac_cv_func_cfsetispeed'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1996 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char cfsetispeed(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char cfsetispeed();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_cfsetispeed) || defined (__stub___cfsetispeed)
+choke me
+#else
+cfsetispeed();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:2019: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_func_cfsetispeed=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_func_cfsetispeed=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'cfsetispeed`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ cat >> confdefs.h <<\EOF
+#define POSIX_TERMIOS 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+
+
+
+cat >> confdefs.h <<\EOF
+#define SHA1HANDSOFF 1
+EOF
+
+
+trap '' 1 2 15
+cat > confcache <<\EOF
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs. It is not useful on other systems.
+# If it contains results you don't want to keep, you may remove or edit it.
+#
+# By default, configure uses ./config.cache as the cache file,
+# creating it if it does not exist already. You can give configure
+# the --cache-file=FILE option to use a different cache file; that is
+# what configure does when it calls configure scripts in
+# subdirectories, so they share the cache.
+# Giving --cache-file=/dev/null disables caching, for debugging configure.
+# config.status only pays attention to the cache file if you give it the
+# --recheck option to rerun configure.
+#
+EOF
+# The following way of writing the cache mishandles newlines in values,
+# but we know of no workaround that is simple, portable, and efficient.
+# So, don't put newlines in cache variables' values.
+# Ultrix sh set writes to stderr and can't be redirected directly,
+# and sets the high bit in the cache file unless we assign to the vars.
+(set) 2>&1 |
+ case `(ac_space=' '; set | grep ac_space) 2>&1` in
+ *ac_space=\ *)
+ # `set' does not quote correctly, so add quotes (double-quote substitution
+ # turns \\\\ into \\, and sed turns \\ into \).
+ sed -n \
+ -e "s/'/'\\\\''/g" \
+ -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p"
+ ;;
+ *)
+ # `set' quotes correctly as required by POSIX, so do not add quotes.
+ sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p'
+ ;;
+ esac >> confcache
+if cmp -s $cache_file confcache; then
+ :
+else
+ if test -w $cache_file; then
+ echo "updating cache $cache_file"
+ cat confcache > $cache_file
+ else
+ echo "not updating unwritable cache $cache_file"
+ fi
+fi
+rm -f confcache
+
+trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
+
+test "x$prefix" = xNONE && prefix=$ac_default_prefix
+# Let make expand exec_prefix.
+test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+
+# Any assignment to VPATH causes Sun make to only execute
+# the first set of double-colon rules, so remove it if not needed.
+# If there is a colon in the path, we need to keep it.
+if test "x$srcdir" = x.; then
+ ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d'
+fi
+
+trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15
+
+DEFS=-DHAVE_CONFIG_H
+
+# Without the "./", some shells look in PATH for config.status.
+: ${CONFIG_STATUS=./config.status}
+
+echo creating $CONFIG_STATUS
+rm -f $CONFIG_STATUS
+cat > $CONFIG_STATUS <<EOF
+#! /bin/sh
+# Generated automatically by configure.
+# Run this file to recreate the current configuration.
+# This directory was configured as follows,
+# on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+#
+# $0 $ac_configure_args
+#
+# Compiler output produced by configure, useful for debugging
+# configure, is in ./config.log if it exists.
+
+ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]"
+for ac_option
+do
+ case "\$ac_option" in
+ -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+ echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
+ exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
+ -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
+ echo "$CONFIG_STATUS generated by autoconf version 2.13"
+ exit 0 ;;
+ -help | --help | --hel | --he | --h)
+ echo "\$ac_cs_usage"; exit 0 ;;
+ *) echo "\$ac_cs_usage"; exit 1 ;;
+ esac
+done
+
+ac_given_srcdir=$srcdir
+ac_given_INSTALL="$INSTALL"
+
+trap 'rm -fr `echo "Makefile config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
+EOF
+cat >> $CONFIG_STATUS <<EOF
+
+# Protect against being on the right side of a sed subst in config.status.
+sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g;
+ s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF
+$ac_vpsub
+$extrasub
+s%@SHELL@%$SHELL%g
+s%@CFLAGS@%$CFLAGS%g
+s%@CPPFLAGS@%$CPPFLAGS%g
+s%@CXXFLAGS@%$CXXFLAGS%g
+s%@FFLAGS@%$FFLAGS%g
+s%@DEFS@%$DEFS%g
+s%@LDFLAGS@%$LDFLAGS%g
+s%@LIBS@%$LIBS%g
+s%@exec_prefix@%$exec_prefix%g
+s%@prefix@%$prefix%g
+s%@program_transform_name@%$program_transform_name%g
+s%@bindir@%$bindir%g
+s%@sbindir@%$sbindir%g
+s%@libexecdir@%$libexecdir%g
+s%@datadir@%$datadir%g
+s%@sysconfdir@%$sysconfdir%g
+s%@sharedstatedir@%$sharedstatedir%g
+s%@localstatedir@%$localstatedir%g
+s%@libdir@%$libdir%g
+s%@includedir@%$includedir%g
+s%@oldincludedir@%$oldincludedir%g
+s%@infodir@%$infodir%g
+s%@mandir@%$mandir%g
+s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
+s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g
+s%@INSTALL_DATA@%$INSTALL_DATA%g
+s%@PACKAGE@%$PACKAGE%g
+s%@VERSION@%$VERSION%g
+s%@ACLOCAL@%$ACLOCAL%g
+s%@AUTOCONF@%$AUTOCONF%g
+s%@AUTOMAKE@%$AUTOMAKE%g
+s%@AUTOHEADER@%$AUTOHEADER%g
+s%@MAKEINFO@%$MAKEINFO%g
+s%@SET_MAKE@%$SET_MAKE%g
+s%@CC@%$CC%g
+s%@LN_S@%$LN_S%g
+s%@RANLIB@%$RANLIB%g
+s%@CPP@%$CPP%g
+s%@signed@%$signed%g
+
+CEOF
+EOF
+
+cat >> $CONFIG_STATUS <<\EOF
+
+# Split the substitutions into bite-sized pieces for seds with
+# small command number limits, like on Digital OSF/1 and HP-UX.
+ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script.
+ac_file=1 # Number of current file.
+ac_beg=1 # First line for current file.
+ac_end=$ac_max_sed_cmds # Line after last line for current file.
+ac_more_lines=:
+ac_sed_cmds=""
+while $ac_more_lines; do
+ if test $ac_beg -gt 1; then
+ sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file
+ else
+ sed "${ac_end}q" conftest.subs > conftest.s$ac_file
+ fi
+ if test ! -s conftest.s$ac_file; then
+ ac_more_lines=false
+ rm -f conftest.s$ac_file
+ else
+ if test -z "$ac_sed_cmds"; then
+ ac_sed_cmds="sed -f conftest.s$ac_file"
+ else
+ ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file"
+ fi
+ ac_file=`expr $ac_file + 1`
+ ac_beg=$ac_end
+ ac_end=`expr $ac_end + $ac_max_sed_cmds`
+ fi
+done
+if test -z "$ac_sed_cmds"; then
+ ac_sed_cmds=cat
+fi
+EOF
+
+cat >> $CONFIG_STATUS <<EOF
+
+CONFIG_FILES=\${CONFIG_FILES-"Makefile"}
+EOF
+cat >> $CONFIG_STATUS <<\EOF
+for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
+ # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
+ case "$ac_file" in
+ *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
+ ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
+ *) ac_file_in="${ac_file}.in" ;;
+ esac
+
+ # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories.
+
+ # Remove last slash and all that follows it. Not all systems have dirname.
+ ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
+ if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
+ # The file is in a subdirectory.
+ test ! -d "$ac_dir" && mkdir "$ac_dir"
+ ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`"
+ # A "../" for each directory in $ac_dir_suffix.
+ ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'`
+ else
+ ac_dir_suffix= ac_dots=
+ fi
+
+ case "$ac_given_srcdir" in
+ .) srcdir=.
+ if test -z "$ac_dots"; then top_srcdir=.
+ else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;;
+ /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;;
+ *) # Relative path.
+ srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix"
+ top_srcdir="$ac_dots$ac_given_srcdir" ;;
+ esac
+
+ case "$ac_given_INSTALL" in
+ [/$]*) INSTALL="$ac_given_INSTALL" ;;
+ *) INSTALL="$ac_dots$ac_given_INSTALL" ;;
+ esac
+
+ echo creating "$ac_file"
+ rm -f "$ac_file"
+ configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure."
+ case "$ac_file" in
+ *Makefile*) ac_comsub="1i\\
+# $configure_input" ;;
+ *) ac_comsub= ;;
+ esac
+
+ ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
+ sed -e "$ac_comsub
+s%@configure_input@%$configure_input%g
+s%@srcdir@%$srcdir%g
+s%@top_srcdir@%$top_srcdir%g
+s%@INSTALL@%$INSTALL%g
+" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file
+fi; done
+rm -f conftest.s*
+
+# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where
+# NAME is the cpp macro being defined and VALUE is the value it is being given.
+#
+# ac_d sets the value in "#define NAME VALUE" lines.
+ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)'
+ac_dB='\([ ][ ]*\)[^ ]*%\1#\2'
+ac_dC='\3'
+ac_dD='%g'
+# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE".
+ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
+ac_uB='\([ ]\)%\1#\2define\3'
+ac_uC=' '
+ac_uD='\4%g'
+# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
+ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
+ac_eB='$%\1#\2define\3'
+ac_eC=' '
+ac_eD='%g'
+
+if test "${CONFIG_HEADERS+set}" != set; then
+EOF
+cat >> $CONFIG_STATUS <<EOF
+ CONFIG_HEADERS="config.h"
+EOF
+cat >> $CONFIG_STATUS <<\EOF
+fi
+for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then
+ # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
+ case "$ac_file" in
+ *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
+ ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
+ *) ac_file_in="${ac_file}.in" ;;
+ esac
+
+ echo creating $ac_file
+
+ rm -f conftest.frag conftest.in conftest.out
+ ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
+ cat $ac_file_inputs > conftest.in
+
+EOF
+
+# Transform confdefs.h into a sed script conftest.vals that substitutes
+# the proper values into config.h.in to produce config.h. And first:
+# Protect against being on the right side of a sed subst in config.status.
+# Protect against being in an unquoted here document in config.status.
+rm -f conftest.vals
+cat > conftest.hdr <<\EOF
+s/[\\&%]/\\&/g
+s%[\\$`]%\\&%g
+s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp
+s%ac_d%ac_u%gp
+s%ac_u%ac_e%gp
+EOF
+sed -n -f conftest.hdr confdefs.h > conftest.vals
+rm -f conftest.hdr
+
+# This sed command replaces #undef with comments. This is necessary, for
+# example, in the case of _POSIX_SOURCE, which is predefined and required
+# on some systems where configure will not decide to define it.
+cat >> conftest.vals <<\EOF
+s%^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */%
+EOF
+
+# Break up conftest.vals because some shells have a limit on
+# the size of here documents, and old seds have small limits too.
+
+rm -f conftest.tail
+while :
+do
+ ac_lines=`grep -c . conftest.vals`
+ # grep -c gives empty output for an empty file on some AIX systems.
+ if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi
+ # Write a limited-size here document to conftest.frag.
+ echo ' cat > conftest.frag <<CEOF' >> $CONFIG_STATUS
+ sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS
+ echo 'CEOF
+ sed -f conftest.frag conftest.in > conftest.out
+ rm -f conftest.in
+ mv conftest.out conftest.in
+' >> $CONFIG_STATUS
+ sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail
+ rm -f conftest.vals
+ mv conftest.tail conftest.vals
+done
+rm -f conftest.vals
+
+cat >> $CONFIG_STATUS <<\EOF
+ rm -f conftest.frag conftest.h
+ echo "/* $ac_file. Generated automatically by configure. */" > conftest.h
+ cat conftest.in >> conftest.h
+ rm -f conftest.in
+ if cmp -s $ac_file conftest.h 2>/dev/null; then
+ echo "$ac_file is unchanged"
+ rm -f conftest.h
+ else
+ # Remove last slash and all that follows it. Not all systems have dirname.
+ ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
+ if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
+ # The file is in a subdirectory.
+ test ! -d "$ac_dir" && mkdir "$ac_dir"
+ fi
+ rm -f $ac_file
+ mv conftest.h $ac_file
+ fi
+fi; done
+
+EOF
+cat >> $CONFIG_STATUS <<EOF
+
+
+EOF
+cat >> $CONFIG_STATUS <<\EOF
+test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h
+
+exit 0
+EOF
+chmod +x $CONFIG_STATUS
+rm -fr confdefs* $ac_clean_files
+test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1
+
diff --git a/package/network/services/ead/src/tinysrp/configure.in b/package/network/services/ead/src/tinysrp/configure.in
new file mode 100644
index 0000000..627d15a
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/configure.in
@@ -0,0 +1,52 @@
+dnl Process this file with autoconf to produce a configure script.
+
+AC_INIT(t_pwd.h)
+AM_CONFIG_HEADER(config.h)
+AM_INIT_AUTOMAKE(libtinysrp, 0.7.5)
+
+test "$CFLAGS" = "" && CFLAGS="-O2"
+
+dnl Checks for programs.
+
+AC_PROG_CC
+AC_PROG_INSTALL
+AC_PROG_LN_S
+AC_PROG_RANLIB
+AC_ARG_PROGRAM
+
+dnl Checks for header files.
+
+AC_HEADER_STDC
+AC_CHECK_HEADERS(sgtty.h sys/ioctl.h sys/time.h termio.h termios.h unistd.h)
+
+dnl Checks for typedefs, structures, and compiler characteristics.
+
+AC_C_CONST
+AC_C_INLINE
+AC_HEADER_TIME
+AC_C_BIGENDIAN
+AC_CHECK_SIZEOF(short)
+AC_CHECK_SIZEOF(int)
+AC_CHECK_SIZEOF(long)
+AC_CHECK_SIZEOF(long long)
+AC_TRY_COMPILE(, [volatile int i;], , AC_DEFINE(volatile, ))
+AC_C_CHAR_UNSIGNED
+
+AC_SUBST(signed)dnl
+if test "$ac_cv_c_char_unsigned" = "yes"; then
+ signed=-signed
+fi
+
+dnl Checks for library functions.
+
+AC_CHECK_FUNCS(sigaction strchr memcpy)
+TYPE_SIGNAL
+AC_HEADER_CHECK(termios.h,AC_FUNC_CHECK(cfsetispeed,AC_DEFINE(POSIX_TERMIOS)))
+
+dnl User options
+
+dnl Some defines for now.
+
+AC_DEFINE(SHA1HANDSOFF)
+
+AC_OUTPUT(Makefile)
diff --git a/package/network/services/ead/src/tinysrp/install-sh b/package/network/services/ead/src/tinysrp/install-sh
new file mode 100755
index 0000000..e843669
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/install-sh
@@ -0,0 +1,250 @@
+#!/bin/sh
+#
+# install - install a program, script, or datafile
+# This comes from X11R5 (mit/util/scripts/install.sh).
+#
+# Copyright 1991 by the Massachusetts Institute of Technology
+#
+# Permission to use, copy, modify, distribute, and sell this software and its
+# documentation for any purpose is hereby granted without fee, provided that
+# the above copyright notice appear in all copies and that both that
+# copyright notice and this permission notice appear in supporting
+# documentation, and that the name of M.I.T. not be used in advertising or
+# publicity pertaining to distribution of the software without specific,
+# written prior permission. M.I.T. makes no representations about the
+# suitability of this software for any purpose. It is provided "as is"
+# without express or implied warranty.
+#
+# Calling this script install-sh is preferred over install.sh, to prevent
+# `make' implicit rules from creating a file called install from it
+# when there is no Makefile.
+#
+# This script is compatible with the BSD install script, but was written
+# from scratch. It can only install one file at a time, a restriction
+# shared with many OS's install programs.
+
+
+# set DOITPROG to echo to test this script
+
+# Don't use :- since 4.3BSD and earlier shells don't like it.
+doit="${DOITPROG-}"
+
+
+# put in absolute paths if you don't have them in your path; or use env. vars.
+
+mvprog="${MVPROG-mv}"
+cpprog="${CPPROG-cp}"
+chmodprog="${CHMODPROG-chmod}"
+chownprog="${CHOWNPROG-chown}"
+chgrpprog="${CHGRPPROG-chgrp}"
+stripprog="${STRIPPROG-strip}"
+rmprog="${RMPROG-rm}"
+mkdirprog="${MKDIRPROG-mkdir}"
+
+transformbasename=""
+transform_arg=""
+instcmd="$mvprog"
+chmodcmd="$chmodprog 0755"
+chowncmd=""
+chgrpcmd=""
+stripcmd=""
+rmcmd="$rmprog -f"
+mvcmd="$mvprog"
+src=""
+dst=""
+dir_arg=""
+
+while [ x"$1" != x ]; do
+ case $1 in
+ -c) instcmd="$cpprog"
+ shift
+ continue;;
+
+ -d) dir_arg=true
+ shift
+ continue;;
+
+ -m) chmodcmd="$chmodprog $2"
+ shift
+ shift
+ continue;;
+
+ -o) chowncmd="$chownprog $2"
+ shift
+ shift
+ continue;;
+
+ -g) chgrpcmd="$chgrpprog $2"
+ shift
+ shift
+ continue;;
+
+ -s) stripcmd="$stripprog"
+ shift
+ continue;;
+
+ -t=*) transformarg=`echo $1 | sed 's/-t=//'`
+ shift
+ continue;;
+
+ -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
+ shift
+ continue;;
+
+ *) if [ x"$src" = x ]
+ then
+ src=$1
+ else
+ # this colon is to work around a 386BSD /bin/sh bug
+ :
+ dst=$1
+ fi
+ shift
+ continue;;
+ esac
+done
+
+if [ x"$src" = x ]
+then
+ echo "install: no input file specified"
+ exit 1
+else
+ true
+fi
+
+if [ x"$dir_arg" != x ]; then
+ dst=$src
+ src=""
+
+ if [ -d $dst ]; then
+ instcmd=:
+ else
+ instcmd=mkdir
+ fi
+else
+
+# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
+# might cause directories to be created, which would be especially bad
+# if $src (and thus $dsttmp) contains '*'.
+
+ if [ -f $src -o -d $src ]
+ then
+ true
+ else
+ echo "install: $src does not exist"
+ exit 1
+ fi
+
+ if [ x"$dst" = x ]
+ then
+ echo "install: no destination specified"
+ exit 1
+ else
+ true
+ fi
+
+# If destination is a directory, append the input filename; if your system
+# does not like double slashes in filenames, you may need to add some logic
+
+ if [ -d $dst ]
+ then
+ dst="$dst"/`basename $src`
+ else
+ true
+ fi
+fi
+
+## this sed command emulates the dirname command
+dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
+
+# Make sure that the destination directory exists.
+# this part is taken from Noah Friedman's mkinstalldirs script
+
+# Skip lots of stat calls in the usual case.
+if [ ! -d "$dstdir" ]; then
+defaultIFS='
+'
+IFS="${IFS-${defaultIFS}}"
+
+oIFS="${IFS}"
+# Some sh's can't handle IFS=/ for some reason.
+IFS='%'
+set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
+IFS="${oIFS}"
+
+pathcomp=''
+
+while [ $# -ne 0 ] ; do
+ pathcomp="${pathcomp}${1}"
+ shift
+
+ if [ ! -d "${pathcomp}" ] ;
+ then
+ $mkdirprog "${pathcomp}"
+ else
+ true
+ fi
+
+ pathcomp="${pathcomp}/"
+done
+fi
+
+if [ x"$dir_arg" != x ]
+then
+ $doit $instcmd $dst &&
+
+ if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
+ if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
+ if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
+ if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
+else
+
+# If we're going to rename the final executable, determine the name now.
+
+ if [ x"$transformarg" = x ]
+ then
+ dstfile=`basename $dst`
+ else
+ dstfile=`basename $dst $transformbasename |
+ sed $transformarg`$transformbasename
+ fi
+
+# don't allow the sed command to completely eliminate the filename
+
+ if [ x"$dstfile" = x ]
+ then
+ dstfile=`basename $dst`
+ else
+ true
+ fi
+
+# Make a temp file name in the proper directory.
+
+ dsttmp=$dstdir/#inst.$$#
+
+# Move or copy the file name to the temp name
+
+ $doit $instcmd $src $dsttmp &&
+
+ trap "rm -f ${dsttmp}" 0 &&
+
+# and set any options; do chmod last to preserve setuid bits
+
+# If any of these fail, we abort the whole thing. If we want to
+# ignore errors from any of these, just make sure not to ignore
+# errors from the above "$doit $instcmd $src $dsttmp" command.
+
+ if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
+ if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
+ if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
+ if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
+
+# Now rename the file to the real destination.
+
+ $doit $rmcmd -f $dstdir/$dstfile &&
+ $doit $mvcmd $dsttmp $dstdir/$dstfile
+
+fi &&
+
+
+exit 0
diff --git a/package/network/services/ead/src/tinysrp/missing b/package/network/services/ead/src/tinysrp/missing
new file mode 100755
index 0000000..a6abd06
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/missing
@@ -0,0 +1,134 @@
+#! /bin/sh
+# Common stub for a few missing GNU programs while installing.
+# Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+# Franc,ois Pinard <pinard@iro.umontreal.ca>, 1996.
+
+# 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; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+if test $# -eq 0; then
+ echo 1>&2 "Try \`$0 --help' for more information"
+ exit 1
+fi
+
+case "$1" in
+
+ -h|--h|--he|--hel|--help)
+ echo "\
+$0 [OPTION]... PROGRAM [ARGUMENT]...
+
+Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
+error status if there is no known handling for PROGRAM.
+
+Options:
+ -h, --help display this help and exit
+ -v, --version output version information and exit
+
+Supported PROGRAM values:
+ aclocal touch file \`aclocal.m4'
+ autoconf touch file \`configure'
+ autoheader touch file \`config.h.in'
+ automake touch all \`Makefile.in' files
+ bison touch file \`y.tab.c'
+ makeinfo touch the output file
+ yacc touch file \`y.tab.c'"
+ ;;
+
+ -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
+ echo "missing - GNU libit 0.0"
+ ;;
+
+ -*)
+ echo 1>&2 "$0: Unknown \`$1' option"
+ echo 1>&2 "Try \`$0 --help' for more information"
+ exit 1
+ ;;
+
+ aclocal)
+ echo 1>&2 "\
+WARNING: \`$1' is missing on your system. You should only need it if
+ you modified \`acinclude.m4' or \`configure.in'. You might want
+ to install the \`Automake' and \`Perl' packages. Grab them from
+ any GNU archive site."
+ touch aclocal.m4
+ ;;
+
+ autoconf)
+ echo 1>&2 "\
+WARNING: \`$1' is missing on your system. You should only need it if
+ you modified \`configure.in'. You might want to install the
+ \`Autoconf' and \`GNU m4' packages. Grab them from any GNU
+ archive site."
+ touch configure
+ ;;
+
+ autoheader)
+ echo 1>&2 "\
+WARNING: \`$1' is missing on your system. You should only need it if
+ you modified \`acconfig.h' or \`configure.in'. You might want
+ to install the \`Autoconf' and \`GNU m4' packages. Grab them
+ from any GNU archive site."
+ touch config.h.in
+ ;;
+
+ automake)
+ echo 1>&2 "\
+WARNING: \`$1' is missing on your system. You should only need it if
+ you modified \`Makefile.am', \`acinclude.m4' or \`configure.in'.
+ You might want to install the \`Automake' and \`Perl' packages.
+ Grab them from any GNU archive site."
+ find . -type f -name Makefile.am -print \
+ | sed 's/^\(.*\).am$/touch \1.in/' \
+ | sh
+ ;;
+
+ bison|yacc)
+ echo 1>&2 "\
+WARNING: \`$1' is missing on your system. You should only need it if
+ you modified a \`.y' file. You may need the \`Bison' package
+ in order for those modifications to take effect. You can get
+ \`Bison' from any GNU archive site."
+ touch y.tab.c
+ ;;
+
+ makeinfo)
+ echo 1>&2 "\
+WARNING: \`$1' is missing on your system. You should only need it if
+ you modified a \`.texi' or \`.texinfo' file, or any other file
+ indirectly affecting the aspect of the manual. The spurious
+ call might also be the consequence of using a buggy \`make' (AIX,
+ DU, IRIX). You might want to install the \`Texinfo' package or
+ the \`GNU make' package. Grab either from any GNU archive site."
+ file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
+ if test -z "$file"; then
+ file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
+ file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
+ fi
+ touch $file
+ ;;
+
+ *)
+ echo 1>&2 "\
+WARNING: \`$1' is needed, and you do not seem to have it handy on your
+ system. You might have modified some files without having the
+ proper tools for further handling them. Check the \`README' file,
+ it often tells you about the needed prerequirements for installing
+ this package. You may also peek at any GNU archive site, in case
+ some other package would contain this missing \`$1' program."
+ exit 1
+ ;;
+esac
+
+exit 0
diff --git a/package/network/services/ead/src/tinysrp/mkinstalldirs b/package/network/services/ead/src/tinysrp/mkinstalldirs
new file mode 100755
index 0000000..3bc1836
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/mkinstalldirs
@@ -0,0 +1,39 @@
+#! /bin/sh
+# mkinstalldirs --- make directory hierarchy
+# Author: Noah Friedman <friedman@prep.ai.mit.edu>
+# Created: 1993-05-16
+# Public domain
+
+
+errstatus=0
+
+for file
+do
+ set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
+ shift
+
+ pathcomp=
+ for d
+ do
+ pathcomp="$pathcomp$d"
+ case "$pathcomp" in
+ -* ) pathcomp=./$pathcomp ;;
+ esac
+
+ if test ! -d "$pathcomp"; then
+ echo "mkdir $pathcomp" 1>&2
+
+ mkdir "$pathcomp" || lasterr=$?
+
+ if test ! -d "$pathcomp"; then
+ errstatus=$lasterr
+ fi
+ fi
+
+ pathcomp="$pathcomp/"
+ done
+done
+
+exit $errstatus
+
+# mkinstalldirs ends here
diff --git a/package/network/services/ead/src/tinysrp/srvtest.c b/package/network/services/ead/src/tinysrp/srvtest.c
new file mode 100644
index 0000000..e09d501
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/srvtest.c
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 1997-1999 The Stanford SRP Authentication Project
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF
+ * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * In addition, the following conditions apply:
+ *
+ * 1. Any software that incorporates the SRP authentication technology
+ * must display the following acknowlegment:
+ * "This product uses the 'Secure Remote Password' cryptographic
+ * authentication system developed by Tom Wu (tjw@CS.Stanford.EDU)."
+ *
+ * 2. Any software that incorporates all or part of the SRP distribution
+ * itself must also display the following acknowledgment:
+ * "This product includes software developed by Tom Wu and Eugene
+ * Jhong for the SRP Distribution (http://srp.stanford.edu/srp/)."
+ *
+ * 3. Redistributions in source or binary form must retain an intact copy
+ * of this copyright notice and list of conditions.
+ */
+
+#include <stdio.h>
+#include "t_defines.h"
+#include "t_pwd.h"
+#include "t_server.h"
+
+int
+main(argc, argv)
+ int argc;
+ char * argv[];
+{
+ struct t_server * ts;
+ struct t_pw * tpw;
+ struct t_conf * tcnf;
+ struct t_num * B;
+ char username[MAXUSERLEN];
+ char hexbuf[MAXHEXPARAMLEN];
+ char buf[MAXPARAMLEN];
+ struct t_num A;
+ unsigned char * skey;
+ unsigned char cbuf[20];
+ FILE * fp;
+ FILE * fp2;
+ char confname[256];
+
+ printf("Enter username: ");
+ fgets(username, sizeof(username), stdin);
+ username[strlen(username) - 1] = '\0';
+ ts = t_serveropen(username);
+
+ if(ts == NULL) {
+ fprintf(stderr, "User %s not found\n", username);
+ exit(1);
+ }
+
+#if 0
+ printf("n: %s\n", t_tob64(hexbuf, ts->n.data, ts->n.len));
+ printf("g: %s\n", t_tob64(hexbuf, ts->g.data, ts->g.len));
+#endif
+ printf("index (to client): %d\n", ts->index);
+ printf("salt (to client): %s\n", t_tob64(hexbuf, ts->s.data, ts->s.len));
+
+ B = t_servergenexp(ts);
+ printf("Enter A (from client): ");
+ fgets(hexbuf, sizeof(hexbuf), stdin);
+ A.data = buf;
+ A.len = t_fromb64(A.data, hexbuf);
+
+ printf("B (to client): %s\n", t_tob64(hexbuf, B->data, B->len));
+
+ skey = t_servergetkey(ts, &A);
+ printf("Session key: %s\n", t_tohex(hexbuf, skey, 40));
+
+ /* printf("[Expected response: %s]\n", t_tohex(hexbuf, cbuf, 16)); */
+
+ printf("Enter response (from client): ");
+ fgets(hexbuf, sizeof(hexbuf), stdin);
+ hexbuf[strlen(hexbuf) - 1] = '\0';
+ t_fromhex(cbuf, hexbuf);
+
+ if(t_serververify(ts, cbuf) == 0) {
+ printf("Authentication successful.\n");
+ printf("Response (to client): %s\n",
+ t_tohex(hexbuf, t_serverresponse(ts), RESPONSE_LEN));
+ } else
+ printf("Authentication failed.\n");
+
+ t_serverclose(ts);
+
+ return 0;
+}
diff --git a/package/network/services/ead/src/tinysrp/stamp-h.in b/package/network/services/ead/src/tinysrp/stamp-h.in
new file mode 100644
index 0000000..9788f70
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/stamp-h.in
@@ -0,0 +1 @@
+timestamp
diff --git a/package/network/services/ead/src/tinysrp/t_client.c b/package/network/services/ead/src/tinysrp/t_client.c
new file mode 100644
index 0000000..ebdd203
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/t_client.c
@@ -0,0 +1,287 @@
+/*
+ * Copyright (c) 1997-1999 The Stanford SRP Authentication Project
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF
+ * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * In addition, the following conditions apply:
+ *
+ * 1. Any software that incorporates the SRP authentication technology
+ * must display the following acknowlegment:
+ * "This product uses the 'Secure Remote Password' cryptographic
+ * authentication system developed by Tom Wu (tjw@CS.Stanford.EDU)."
+ *
+ * 2. Any software that incorporates all or part of the SRP distribution
+ * itself must also display the following acknowledgment:
+ * "This product includes software developed by Tom Wu and Eugene
+ * Jhong for the SRP Distribution (http://srp.stanford.edu/srp/)."
+ *
+ * 3. Redistributions in source or binary form must retain an intact copy
+ * of this copyright notice and list of conditions.
+ */
+
+#include <stdio.h>
+#include "t_defines.h"
+#include "t_pwd.h"
+#include "t_client.h"
+#include "t_sha.h"
+
+_TYPE( struct t_client * )
+t_clientopen(u, n, g, s)
+ const char * u;
+ struct t_num * n;
+ struct t_num * g;
+ struct t_num * s;
+{
+ struct t_client * tc;
+ unsigned char buf1[SHA_DIGESTSIZE], buf2[SHA_DIGESTSIZE];
+ SHA1_CTX ctxt;
+ int i, validated;
+ struct t_preconf * tpc;
+
+ BigInteger nn, gg, n12, r;
+
+ validated = 0;
+ if(n->len < MIN_MOD_BYTES)
+ return 0;
+ for(i = 0; i < t_getprecount(); ++i) {
+ tpc = t_getpreparam(i);
+ if(tpc->modulus.len == n->len && tpc->generator.len == g->len &&
+ memcmp(tpc->modulus.data, n->data, n->len) == 0 &&
+ memcmp(tpc->generator.data, g->data, g->len) == 0) {
+ validated = 1; /* Match found, done */
+ break;
+ }
+ }
+
+ if(validated == 0)
+ return 0;
+
+ if((tc = malloc(sizeof(struct t_client))) == 0)
+ return 0;
+
+ strncpy(tc->username, u, MAXUSERLEN);
+
+ SHA1Init(&tc->hash);
+
+ tc->n.len = n->len;
+ tc->n.data = tc->nbuf;
+ memcpy(tc->n.data, n->data, tc->n.len);
+
+ SHA1Init(&ctxt);
+ SHA1Update(&ctxt, tc->n.data, tc->n.len);
+ SHA1Final(buf1, &ctxt);
+
+ tc->g.len = g->len;
+ tc->g.data = tc->gbuf;
+ memcpy(tc->g.data, g->data, tc->g.len);
+
+ SHA1Init(&ctxt);
+ SHA1Update(&ctxt, tc->g.data, tc->g.len);
+ SHA1Final(buf2, &ctxt);
+
+ for(i = 0; i < sizeof(buf1); ++i)
+ buf1[i] ^= buf2[i];
+
+ SHA1Update(&tc->hash, buf1, sizeof(buf1));
+
+ SHA1Init(&ctxt);
+ SHA1Update(&ctxt, tc->username, strlen(tc->username));
+ SHA1Final(buf1, &ctxt);
+
+ SHA1Update(&tc->hash, buf1, sizeof(buf1));
+
+ tc->s.len = s->len;
+ tc->s.data = tc->sbuf;
+ memcpy(tc->s.data, s->data, tc->s.len);
+
+ SHA1Update(&tc->hash, tc->s.data, tc->s.len);
+
+ tc->a.data = tc->abuf;
+ tc->A.data = tc->Abuf;
+ tc->p.data = tc->pbuf;
+ tc->v.data = tc->vbuf;
+
+ SHA1Init(&tc->ckhash);
+
+ return tc;
+}
+
+_TYPE( struct t_num * )
+t_clientgenexp(tc)
+ struct t_client * tc;
+{
+ BigInteger a, A, n, g;
+
+ if(tc->n.len < ALEN)
+ tc->a.len = tc->n.len;
+ else
+ tc->a.len = ALEN;
+
+ t_random(tc->a.data, tc->a.len);
+ a = BigIntegerFromBytes(tc->a.data, tc->a.len);
+ n = BigIntegerFromBytes(tc->n.data, tc->n.len);
+ g = BigIntegerFromBytes(tc->g.data, tc->g.len);
+ A = BigIntegerFromInt(0);
+ BigIntegerModExp(A, g, a, n);
+ tc->A.len = BigIntegerToBytes(A, tc->A.data);
+
+ BigIntegerFree(A);
+ BigIntegerFree(a);
+ BigIntegerFree(g);
+ BigIntegerFree(n);
+
+ SHA1Update(&tc->hash, tc->A.data, tc->A.len);
+ SHA1Update(&tc->ckhash, tc->A.data, tc->A.len);
+
+ return &tc->A;
+}
+
+_TYPE( void )
+t_clientpasswd(tc, password)
+ struct t_client * tc;
+ char * password;
+{
+ BigInteger n, g, p, v;
+ SHA1_CTX ctxt;
+ unsigned char dig[SHA_DIGESTSIZE];
+
+ n = BigIntegerFromBytes(tc->n.data, tc->n.len);
+ g = BigIntegerFromBytes(tc->g.data, tc->g.len);
+
+ SHA1Init(&ctxt);
+ SHA1Update(&ctxt, tc->username, strlen(tc->username));
+ SHA1Update(&ctxt, ":", 1);
+ SHA1Update(&ctxt, password, strlen(password));
+ SHA1Final(dig, &ctxt);
+
+ SHA1Init(&ctxt);
+ SHA1Update(&ctxt, tc->s.data, tc->s.len);
+ SHA1Update(&ctxt, dig, sizeof(dig));
+ SHA1Final(dig, &ctxt);
+
+ p = BigIntegerFromBytes(dig, sizeof(dig));
+
+ v = BigIntegerFromInt(0);
+ BigIntegerModExp(v, g, p, n);
+
+ tc->p.len = BigIntegerToBytes(p, tc->p.data);
+ BigIntegerFree(p);
+
+ tc->v.len = BigIntegerToBytes(v, tc->v.data);
+ BigIntegerFree(v);
+}
+
+_TYPE( unsigned char * )
+t_clientgetkey(tc, serverval)
+ struct t_client * tc;
+ struct t_num * serverval;
+{
+ BigInteger n, B, v, p, a, sum, S;
+ unsigned char sbuf[MAXPARAMLEN];
+ unsigned char dig[SHA_DIGESTSIZE];
+ unsigned slen;
+ unsigned int u;
+ SHA1_CTX ctxt;
+
+ SHA1Init(&ctxt);
+ SHA1Update(&ctxt, serverval->data, serverval->len);
+ SHA1Final(dig, &ctxt);
+ u = (dig[0] << 24) | (dig[1] << 16) | (dig[2] << 8) | dig[3];
+ if(u == 0)
+ return NULL;
+
+ SHA1Update(&tc->hash, serverval->data, serverval->len);
+
+ B = BigIntegerFromBytes(serverval->data, serverval->len);
+ n = BigIntegerFromBytes(tc->n.data, tc->n.len);
+
+ if(BigIntegerCmp(B, n) >= 0 || BigIntegerCmpInt(B, 0) == 0) {
+ BigIntegerFree(B);
+ BigIntegerFree(n);
+ return NULL;
+ }
+ v = BigIntegerFromBytes(tc->v.data, tc->v.len);
+ if(BigIntegerCmp(B, v) < 0)
+ BigIntegerAdd(B, B, n);
+ BigIntegerSub(B, B, v);
+ BigIntegerFree(v);
+
+ a = BigIntegerFromBytes(tc->a.data, tc->a.len);
+ p = BigIntegerFromBytes(tc->p.data, tc->p.len);
+
+ sum = BigIntegerFromInt(0);
+ BigIntegerMulInt(sum, p, u);
+ BigIntegerAdd(sum, sum, a);
+
+ BigIntegerFree(p);
+ BigIntegerFree(a);
+
+ S = BigIntegerFromInt(0);
+ BigIntegerModExp(S, B, sum, n);
+ slen = BigIntegerToBytes(S, sbuf);
+
+ BigIntegerFree(S);
+ BigIntegerFree(sum);
+ BigIntegerFree(B);
+ BigIntegerFree(n);
+
+ t_sessionkey(tc->session_key, sbuf, slen);
+ memset(sbuf, 0, slen);
+
+ SHA1Update(&tc->hash, tc->session_key, sizeof(tc->session_key));
+
+ SHA1Final(tc->session_response, &tc->hash);
+ SHA1Update(&tc->ckhash, tc->session_response, sizeof(tc->session_response));
+ SHA1Update(&tc->ckhash, tc->session_key, sizeof(tc->session_key));
+
+ return tc->session_key;
+}
+
+_TYPE( int )
+t_clientverify(tc, resp)
+ struct t_client * tc;
+ unsigned char * resp;
+{
+ unsigned char expected[SHA_DIGESTSIZE];
+
+ SHA1Final(expected, &tc->ckhash);
+ return memcmp(expected, resp, sizeof(expected));
+}
+
+_TYPE( unsigned char * )
+t_clientresponse(tc)
+ struct t_client * tc;
+{
+ return tc->session_response;
+}
+
+_TYPE( void )
+t_clientclose(tc)
+ struct t_client * tc;
+{
+ memset(tc->abuf, 0, sizeof(tc->abuf));
+ memset(tc->pbuf, 0, sizeof(tc->pbuf));
+ memset(tc->vbuf, 0, sizeof(tc->vbuf));
+ memset(tc->session_key, 0, sizeof(tc->session_key));
+ free(tc);
+}
diff --git a/package/network/services/ead/src/tinysrp/t_client.h b/package/network/services/ead/src/tinysrp/t_client.h
new file mode 100644
index 0000000..42922af
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/t_client.h
@@ -0,0 +1,148 @@
+/*
+ * Copyright (c) 1997-1999 The Stanford SRP Authentication Project
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF
+ * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * In addition, the following conditions apply:
+ *
+ * 1. Any software that incorporates the SRP authentication technology
+ * must display the following acknowlegment:
+ * "This product uses the 'Secure Remote Password' cryptographic
+ * authentication system developed by Tom Wu (tjw@CS.Stanford.EDU)."
+ *
+ * 2. Any software that incorporates all or part of the SRP distribution
+ * itself must also display the following acknowledgment:
+ * "This product includes software developed by Tom Wu and Eugene
+ * Jhong for the SRP Distribution (http://srp.stanford.edu/srp/)."
+ *
+ * 3. Redistributions in source or binary form must retain an intact copy
+ * of this copyright notice and list of conditions.
+ */
+
+#ifndef T_CLIENT_H
+#define T_CLIENT_H
+
+#include "t_sha.h"
+
+#if !defined(P)
+#ifdef __STDC__
+#define P(x) x
+#else
+#define P(x) ()
+#endif
+#endif
+
+/* For building dynamic link libraries under windows, windows NT
+ * using MSVC1.5 or MSVC2.0
+ */
+
+#ifndef _DLLDECL
+#define _DLLDECL
+
+#ifdef MSVC15 /* MSVC1.5 support for 16 bit apps */
+#define _MSVC15EXPORT _export
+#define _MSVC20EXPORT
+#define _DLLAPI _export _pascal
+#define _TYPE(a) a _MSVC15EXPORT
+#define DLLEXPORT 1
+
+#elif MSVC20
+#define _MSVC15EXPORT
+#define _MSVC20EXPORT _declspec(dllexport)
+#define _DLLAPI
+#define _TYPE(a) _MSVC20EXPORT a
+#define DLLEXPORT 1
+
+#else /* Default, non-dll. Use this for Unix or DOS */
+#define _MSVC15DEXPORT
+#define _MSVC20EXPORT
+#define _DLLAPI
+#define _TYPE(a) a
+#endif
+#endif
+
+#define ALEN 32
+#define MIN_MOD_BYTES 64 /* 512 bits */
+
+struct t_client {
+ struct t_num n;
+ struct t_num g;
+ struct t_num s;
+
+ struct t_num a;
+ struct t_num A;
+
+ struct t_num p;
+ struct t_num v;
+
+ SHA1_CTX hash, ckhash;
+
+ char username[MAXUSERLEN];
+ unsigned char session_key[SESSION_KEY_LEN];
+ unsigned char session_response[RESPONSE_LEN];
+
+ unsigned char nbuf[MAXPARAMLEN], gbuf[MAXPARAMLEN], sbuf[MAXSALTLEN];
+ unsigned char pbuf[MAXPARAMLEN], vbuf[MAXPARAMLEN];
+ unsigned char abuf[ALEN], Abuf[MAXPARAMLEN];
+};
+
+/*
+ * SRP client-side negotiation
+ *
+ * This code negotiates the client side of an SRP exchange.
+ * "t_clientopen" accepts a username, and N, g, and s parameters,
+ * which are usually sent by the server in the first round.
+ * The client should then call...
+ * "t_clientgenexp" will generate a random 256-bit exponent and
+ * raise g to that power, returning the result. This result
+ * should be sent to the server as w(p).
+ * "t_clientpasswd" accepts the user's password, which should be
+ * entered locally and updates the client's state.
+ * "t_clientgetkey" accepts the exponential y(p), which should
+ * be sent by the server in the next round and computes the
+ * 256-bit session key. This data should be saved before the
+ * session is closed.
+ * "t_clientresponse" computes the session key proof as SHA(y(p), K).
+ * "t_clientclose" closes the session and frees its memory.
+ *
+ * Note that authentication is not performed per se; it is up
+ * to either/both sides of the protocol to now verify securely
+ * that their session keys agree in order to establish authenticity.
+ * One possible way is through "oracle hashing"; one side sends
+ * r, the other replies with H(r,K), where H() is a hash function.
+ *
+ * t_clientresponse and t_clientverify now implement a version of
+ * the session-key verification described above.
+ */
+_TYPE( struct t_client * )
+ t_clientopen P((const char *, struct t_num *, struct t_num *,
+ struct t_num *));
+_TYPE( struct t_num * ) t_clientgenexp P((struct t_client *));
+_TYPE( void ) t_clientpasswd P((struct t_client *, char *));
+_TYPE( unsigned char * )
+ t_clientgetkey P((struct t_client *, struct t_num *));
+_TYPE( int ) t_clientverify P((struct t_client *, unsigned char *));
+_TYPE( unsigned char * ) t_clientresponse P((struct t_client *));
+_TYPE( void ) t_clientclose P((struct t_client *));
+
+#endif
diff --git a/package/network/services/ead/src/tinysrp/t_conf.c b/package/network/services/ead/src/tinysrp/t_conf.c
new file mode 100644
index 0000000..fbe6f41
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/t_conf.c
@@ -0,0 +1,1080 @@
+/*
+ * Copyright (c) 1997-1999 The Stanford SRP Authentication Project
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF
+ * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * In addition, the following conditions apply:
+ *
+ * 1. Any software that incorporates the SRP authentication technology
+ * must display the following acknowlegment:
+ * "This product uses the 'Secure Remote Password' cryptographic
+ * authentication system developed by Tom Wu (tjw@CS.Stanford.EDU)."
+ *
+ * 2. Any software that incorporates all or part of the SRP distribution
+ * itself must also display the following acknowledgment:
+ * "This product includes software developed by Tom Wu and Eugene
+ * Jhong for the SRP Distribution (http://srp.stanford.edu/srp/)."
+ *
+ * 3. Redistributions in source or binary form must retain an intact copy
+ * of this copyright notice and list of conditions.
+ */
+
+#include <stdio.h>
+
+#include "t_defines.h"
+#include "t_pwd.h"
+#include "t_read.h"
+#include "bn.h"
+#include "bn_lcl.h"
+#include "bn_prime.h"
+
+#define TABLE_SIZE 32
+
+static int witness(BIGNUM *w, const BIGNUM *a, const BIGNUM *a1,
+ const BIGNUM *a1_odd, int k, BN_CTX *ctx, BN_MONT_CTX *mont);
+
+/*
+ * This is the safe prime generation logic.
+ * To generate a safe prime p (where p = 2q+1 and q is prime), we start
+ * with a random odd q that is one bit shorter than the desired length
+ * of p. We use a simple 30-element sieve to filter the values of q
+ * and consider only those that are 11, 23, or 29 (mod 30). (If q were
+ * anything else, either q or p would be divisible by 2, 3, or 5).
+ * For the values of q that are left, we apply the following tests in
+ * this order:
+ *
+ * trial divide q
+ * let p = 2q + 1
+ * trial divide p
+ * apply Fermat test to q (2^q == 2 (mod q))
+ * apply Fermat test to p (2^p == 2 (mod p))
+ * apply real probablistic primality test to q
+ * apply real probablistic primality test to p
+ *
+ * A number that passes all these tests is considered a safe prime for
+ * our purposes. The tests are ordered this way for efficiency; the
+ * slower tests are run rarely if ever at all.
+ */
+
+static int
+trialdiv(x)
+ const BigInteger x;
+{
+ static int primes[] = { /* All odd primes < 256 */
+ 3, 5, 7, 11, 13, 17, 19, 23, 29,
+ 31, 37, 41, 43, 47, 53, 59, 61, 67,
+ 71, 73, 79, 83, 89, 97, 101, 103,
+ 107, 109, 113, 127, 131, 137, 139, 149, 151,
+ 157, 163, 167, 173, 179, 181, 191, 193, 197,
+ 199, 211, 223, 227, 229, 233, 239, 241, 251
+ };
+ static int nprimes = sizeof(primes) / sizeof(int);
+ int i;
+
+ for(i = 0; i < nprimes; ++i) {
+ if(BigIntegerModInt(x, primes[i]) == 0)
+ return primes[i];
+ }
+ return 1;
+}
+
+/* x + sieve30[x%30] == 11, 23, or 29 (mod 30) */
+
+static int sieve30[] =
+{ 11, 10, 9, 8, 7, 6, 5, 4, 3, 2,
+ 1, 12, 11, 10, 9, 8, 7, 6, 5, 4,
+ 3, 2, 1, 6, 5, 4, 3, 2, 1, 12
+};
+
+/* Find a Sophie-Germain prime between "lo" and "hi". NOTE: this is not
+ a "safe prime", but the smaller prime. Take 2q+1 to get the safe prime. */
+
+static void
+sophie_germain(q, lo, hi)
+ BigInteger q; /* assumed initialized */
+ const BigInteger lo;
+ const BigInteger hi;
+{
+ BigInteger m, p, r;
+ char parambuf[MAXPARAMLEN];
+ int foundprime = 0;
+ int i, mod30;
+
+ m = BigIntegerFromInt(0);
+ BigIntegerSub(m, hi, lo);
+ i = (BigIntegerBitLen(m) + 7) / 8;
+ t_random(parambuf, i);
+ r = BigIntegerFromBytes(parambuf, i);
+ BigIntegerMod(r, r, m);
+
+ BigIntegerAdd(q, r, lo);
+ if(BigIntegerModInt(q, 2) == 0)
+ BigIntegerAddInt(q, q, 1); /* make q odd */
+
+ mod30 = BigIntegerModInt(q, 30); /* mod30 = q % 30 */
+
+ BigIntegerFree(m);
+ m = BigIntegerFromInt(2); /* m = 2 */
+ p = BigIntegerFromInt(0);
+
+ while(BigIntegerCmp(q, hi) < 0) {
+ if(trialdiv(q) < 2) {
+ BigIntegerMulInt(p, q, 2); /* p = 2 * q */
+ BigIntegerAddInt(p, p, 1); /* p += 1 */
+ if(trialdiv(p) < 2) {
+ BigIntegerModExp(r, m, q, q); /* r = 2^q % q */
+ if(BigIntegerCmpInt(r, 2) == 0) { /* if(r == 2) */
+ BigIntegerModExp(r, m, p, p); /* r = 2^p % p */
+ if(BigIntegerCmpInt(r, 2) == 0) { /* if(r == 2) */
+ if(BigIntegerCheckPrime(q) && BigIntegerCheckPrime(p)) {
+ ++foundprime;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ i = sieve30[mod30];
+ BigIntegerAddInt(q, q, i); /* q += i */
+ mod30 = (mod30 + i) % 30;
+ }
+
+ /* should wrap around on failure */
+ if(!foundprime) {
+ fprintf(stderr, "Prime generation failed!\n");
+ exit(1);
+ }
+
+ BigIntegerFree(r);
+ BigIntegerFree(m);
+ BigIntegerFree(p);
+}
+
+_TYPE( struct t_confent * )
+t_makeconfent(tc, nsize)
+ struct t_conf * tc;
+ int nsize;
+{
+ BigInteger n, g, q, t, u;
+
+ t = BigIntegerFromInt(0);
+ u = BigIntegerFromInt(1); /* u = 1 */
+ BigIntegerLShift(t, u, nsize - 2); /* t = 2^(nsize-2) */
+ BigIntegerMulInt(u, t, 2); /* u = 2^(nsize-1) */
+
+ q = BigIntegerFromInt(0);
+ sophie_germain(q, t, u);
+
+ n = BigIntegerFromInt(0);
+ BigIntegerMulInt(n, q, 2);
+ BigIntegerAddInt(n, n, 1);
+
+ /* Look for a generator mod n */
+ g = BigIntegerFromInt(2);
+ while(1) {
+ BigIntegerModExp(t, g, q, n); /* t = g^q % n */
+ if(BigIntegerCmpInt(t, 1) == 0) /* if(t == 1) */
+ BigIntegerAddInt(g, g, 1); /* ++g */
+ else
+ break;
+ }
+ BigIntegerFree(t);
+ BigIntegerFree(u);
+ BigIntegerFree(q);
+
+ tc->tcbuf.modulus.data = tc->modbuf;
+ tc->tcbuf.modulus.len = BigIntegerToBytes(n, tc->tcbuf.modulus.data);
+ BigIntegerFree(n);
+
+ tc->tcbuf.generator.data = tc->genbuf;
+ tc->tcbuf.generator.len = BigIntegerToBytes(g, tc->tcbuf.generator.data);
+ BigIntegerFree(g);
+
+ tc->tcbuf.index = 1;
+ return &tc->tcbuf;
+}
+
+_TYPE( struct t_confent * )
+t_makeconfent_c(tc, nsize)
+ struct t_conf * tc;
+ int nsize;
+{
+ BigInteger g, n, p, q, j, k, t, u;
+ int psize, qsize;
+
+ psize = nsize / 2;
+ qsize = nsize - psize;
+
+ t = BigIntegerFromInt(1); /* t = 1 */
+ u = BigIntegerFromInt(0);
+ BigIntegerLShift(u, t, psize - 3); /* u = t*2^(psize-3) = 2^(psize-3) */
+ BigIntegerMulInt(t, u, 3); /* t = 3*u = 1.5*2^(psize-2) */
+ BigIntegerAdd(u, u, t); /* u += t [u = 2^(psize-1)] */
+ j = BigIntegerFromInt(0);
+ sophie_germain(j, t, u);
+
+ k = BigIntegerFromInt(0);
+ if(qsize != psize) {
+ BigIntegerFree(t);
+ t = BigIntegerFromInt(1); /* t = 1 */
+ BigIntegerLShift(u, t, qsize - 3); /* u = t*2^(qsize-3) = 2^(qsize-3) */
+ BigIntegerMulInt(t, u, 3); /* t = 3*u = 1.5*2^(qsize-2) */
+ BigIntegerAdd(u, u, t); /* u += t [u = 2^(qsize-1)] */
+ }
+ sophie_germain(k, t, u);
+
+ p = BigIntegerFromInt(0);
+ BigIntegerMulInt(p, j, 2); /* p = 2 * j */
+ BigIntegerAddInt(p, p, 1); /* p += 1 */
+
+ q = BigIntegerFromInt(0);
+ BigIntegerMulInt(q, k, 2); /* q = 2 * k */
+ BigIntegerAddInt(q, q, 1); /* q += 1 */
+
+ n = BigIntegerFromInt(0);
+ BigIntegerMul(n, p, q); /* n = p * q */
+ BigIntegerMul(u, j, k); /* u = j * k */
+
+ BigIntegerFree(p);
+ BigIntegerFree(q);
+ BigIntegerFree(j);
+ BigIntegerFree(k);
+
+ g = BigIntegerFromInt(2); /* g = 2 */
+
+ /* Look for a generator mod n */
+ while(1) {
+ BigIntegerModExp(t, g, u, n); /* t = g^u % n */
+ if(BigIntegerCmpInt(t, 1) == 0)
+ BigIntegerAddInt(g, g, 1); /* ++g */
+ else
+ break;
+ }
+
+ BigIntegerFree(u);
+ BigIntegerFree(t);
+
+ tc->tcbuf.modulus.data = tc->modbuf;
+ tc->tcbuf.modulus.len = BigIntegerToBytes(n, tc->tcbuf.modulus.data);
+ BigIntegerFree(n);
+
+ tc->tcbuf.generator.data = tc->genbuf;
+ tc->tcbuf.generator.len = BigIntegerToBytes(g, tc->tcbuf.generator.data);
+ BigIntegerFree(g);
+
+ tc->tcbuf.index = 1;
+ return &tc->tcbuf;
+}
+
+_TYPE( struct t_confent * )
+t_newconfent(tc)
+ struct t_conf * tc;
+{
+ tc->tcbuf.index = 0;
+ tc->tcbuf.modulus.data = tc->modbuf;
+ tc->tcbuf.modulus.len = 0;
+ tc->tcbuf.generator.data = tc->genbuf;
+ tc->tcbuf.generator.len = 0;
+ return &tc->tcbuf;
+}
+
+_TYPE( void )
+t_putconfent(ent, fp)
+ const struct t_confent * ent;
+ FILE * fp;
+{
+ char strbuf[MAXB64PARAMLEN];
+
+ fprintf(fp, "%d:%s:", ent->index,
+ t_tob64(strbuf, ent->modulus.data, ent->modulus.len));
+ fprintf(fp, "%s\n",
+ t_tob64(strbuf, ent->generator.data, ent->generator.len));
+}
+
+int
+BigIntegerBitLen(b)
+ BigInteger b;
+{
+ return BN_num_bits(b);
+}
+
+int
+BigIntegerCheckPrime(n)
+ BigInteger n;
+{
+ BN_CTX * ctx = BN_CTX_new();
+ int rv = BN_is_prime(n, 25, NULL, ctx, NULL);
+ BN_CTX_free(ctx);
+ return rv;
+}
+
+unsigned int
+BigIntegerModInt(d, m)
+ BigInteger d;
+ unsigned int m;
+{
+ return BN_mod_word(d, m);
+}
+
+void
+BigIntegerMod(result, d, m)
+ BigInteger result, d, m;
+{
+ BN_CTX * ctx = BN_CTX_new();
+ BN_mod(result, d, m, ctx);
+ BN_CTX_free(ctx);
+}
+
+void
+BigIntegerMul(result, m1, m2)
+ BigInteger result, m1, m2;
+{
+ BN_CTX * ctx = BN_CTX_new();
+ BN_mul(result, m1, m2, ctx);
+ BN_CTX_free(ctx);
+}
+
+void
+BigIntegerLShift(result, x, bits)
+ BigInteger result, x;
+ unsigned int bits;
+{
+ BN_lshift(result, x, bits);
+}
+
+int BN_is_prime(const BIGNUM *a, int checks, void (*callback)(int,int,void *),
+ BN_CTX *ctx_passed, void *cb_arg)
+ {
+ return BN_is_prime_fasttest(a, checks, callback, ctx_passed, cb_arg, 0);
+ }
+
+int BN_is_prime_fasttest(const BIGNUM *a, int checks,
+ void (*callback)(int,int,void *),
+ BN_CTX *ctx_passed, void *cb_arg,
+ int do_trial_division)
+ {
+ int i, j, ret = -1;
+ int k;
+ BN_CTX *ctx = NULL;
+ BIGNUM *A1, *A1_odd, *check; /* taken from ctx */
+ BN_MONT_CTX *mont = NULL;
+ const BIGNUM *A = NULL;
+
+ if (checks == BN_prime_checks)
+ checks = BN_prime_checks_for_size(BN_num_bits(a));
+
+ /* first look for small factors */
+ if (!BN_is_odd(a))
+ return(0);
+ if (do_trial_division)
+ {
+ for (i = 1; i < NUMPRIMES; i++)
+ if (BN_mod_word(a, primes[i]) == 0)
+ return 0;
+ if (callback != NULL) callback(1, -1, cb_arg);
+ }
+
+ if (ctx_passed != NULL)
+ ctx = ctx_passed;
+ else
+ if ((ctx=BN_CTX_new()) == NULL)
+ goto err;
+ BN_CTX_start(ctx);
+
+ /* A := abs(a) */
+ if (a->neg)
+ {
+ BIGNUM *t;
+ if ((t = BN_CTX_get(ctx)) == NULL) goto err;
+ BN_copy(t, a);
+ t->neg = 0;
+ A = t;
+ }
+ else
+ A = a;
+ A1 = BN_CTX_get(ctx);
+ A1_odd = BN_CTX_get(ctx);
+ check = BN_CTX_get(ctx);
+ if (check == NULL) goto err;
+
+ /* compute A1 := A - 1 */
+ if (!BN_copy(A1, A))
+ goto err;
+ if (!BN_sub_word(A1, 1))
+ goto err;
+ if (BN_is_zero(A1))
+ {
+ ret = 0;
+ goto err;
+ }
+
+ /* write A1 as A1_odd * 2^k */
+ k = 1;
+ while (!BN_is_bit_set(A1, k))
+ k++;
+ if (!BN_rshift(A1_odd, A1, k))
+ goto err;
+
+ /* Montgomery setup for computations mod A */
+ mont = BN_MONT_CTX_new();
+ if (mont == NULL)
+ goto err;
+ if (!BN_MONT_CTX_set(mont, A, ctx))
+ goto err;
+
+ for (i = 0; i < checks; i++)
+ {
+ if (!BN_pseudo_rand(check, BN_num_bits(A1), 0, 0))
+ goto err;
+ if (BN_cmp(check, A1) >= 0)
+ if (!BN_sub(check, check, A1))
+ goto err;
+ if (!BN_add_word(check, 1))
+ goto err;
+ /* now 1 <= check < A */
+
+ j = witness(check, A, A1, A1_odd, k, ctx, mont);
+ if (j == -1) goto err;
+ if (j)
+ {
+ ret=0;
+ goto err;
+ }
+ if (callback != NULL) callback(1,i,cb_arg);
+ }
+ ret=1;
+err:
+ if (ctx != NULL)
+ {
+ BN_CTX_end(ctx);
+ if (ctx_passed == NULL)
+ BN_CTX_free(ctx);
+ }
+ if (mont != NULL)
+ BN_MONT_CTX_free(mont);
+
+ return(ret);
+ }
+
+static int witness(BIGNUM *w, const BIGNUM *a, const BIGNUM *a1,
+ const BIGNUM *a1_odd, int k, BN_CTX *ctx, BN_MONT_CTX *mont)
+ {
+ if (!BN_mod_exp_mont(w, w, a1_odd, a, ctx, mont)) /* w := w^a1_odd mod a */
+ return -1;
+ if (BN_is_one(w))
+ return 0; /* probably prime */
+ if (BN_cmp(w, a1) == 0)
+ return 0; /* w == -1 (mod a), 'a' is probably prime */
+ while (--k)
+ {
+ if (!BN_mod_mul(w, w, w, a, ctx)) /* w := w^2 mod a */
+ return -1;
+ if (BN_is_one(w))
+ return 1; /* 'a' is composite, otherwise a previous 'w' would
+ * have been == -1 (mod 'a') */
+ if (BN_cmp(w, a1) == 0)
+ return 0; /* w == -1 (mod a), 'a' is probably prime */
+ }
+ /* If we get here, 'w' is the (a-1)/2-th power of the original 'w',
+ * and it is neither -1 nor +1 -- so 'a' cannot be prime */
+ return 1;
+ }
+
+int BN_mod_exp_mont(BIGNUM *rr, BIGNUM *a, const BIGNUM *p,
+ const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont)
+ {
+ int i,j,bits,ret=0,wstart,wend,window,wvalue;
+ int start=1,ts=0;
+ BIGNUM *d,*r;
+ BIGNUM *aa;
+ BIGNUM val[TABLE_SIZE];
+ BN_MONT_CTX *mont=NULL;
+
+ bn_check_top(a);
+ bn_check_top(p);
+ bn_check_top(m);
+
+ if (!(m->d[0] & 1))
+ {
+ return(0);
+ }
+ bits=BN_num_bits(p);
+ if (bits == 0)
+ {
+ BN_one(rr);
+ return(1);
+ }
+ BN_CTX_start(ctx);
+ d = BN_CTX_get(ctx);
+ r = BN_CTX_get(ctx);
+ if (d == NULL || r == NULL) goto err;
+
+ /* If this is not done, things will break in the montgomery
+ * part */
+
+ if (in_mont != NULL)
+ mont=in_mont;
+ else
+ {
+ if ((mont=BN_MONT_CTX_new()) == NULL) goto err;
+ if (!BN_MONT_CTX_set(mont,m,ctx)) goto err;
+ }
+
+ BN_init(&val[0]);
+ ts=1;
+ if (BN_ucmp(a,m) >= 0)
+ {
+ if (!BN_mod(&(val[0]),a,m,ctx))
+ goto err;
+ aa= &(val[0]);
+ }
+ else
+ aa=a;
+ if (!BN_to_montgomery(&(val[0]),aa,mont,ctx)) goto err; /* 1 */
+
+ window = BN_window_bits_for_exponent_size(bits);
+ if (window > 1)
+ {
+ if (!BN_mod_mul_montgomery(d,&(val[0]),&(val[0]),mont,ctx)) goto err; /* 2 */
+ j=1<<(window-1);
+ for (i=1; i<j; i++)
+ {
+ BN_init(&(val[i]));
+ if (!BN_mod_mul_montgomery(&(val[i]),&(val[i-1]),d,mont,ctx))
+ goto err;
+ }
+ ts=i;
+ }
+
+ start=1; /* This is used to avoid multiplication etc
+ * when there is only the value '1' in the
+ * buffer. */
+ wvalue=0; /* The 'value' of the window */
+ wstart=bits-1; /* The top bit of the window */
+ wend=0; /* The bottom bit of the window */
+
+ if (!BN_to_montgomery(r,BN_value_one(),mont,ctx)) goto err;
+ for (;;)
+ {
+ if (BN_is_bit_set(p,wstart) == 0)
+ {
+ if (!start)
+ {
+ if (!BN_mod_mul_montgomery(r,r,r,mont,ctx))
+ goto err;
+ }
+ if (wstart == 0) break;
+ wstart--;
+ continue;
+ }
+ /* We now have wstart on a 'set' bit, we now need to work out
+ * how bit a window to do. To do this we need to scan
+ * forward until the last set bit before the end of the
+ * window */
+ j=wstart;
+ wvalue=1;
+ wend=0;
+ for (i=1; i<window; i++)
+ {
+ if (wstart-i < 0) break;
+ if (BN_is_bit_set(p,wstart-i))
+ {
+ wvalue<<=(i-wend);
+ wvalue|=1;
+ wend=i;
+ }
+ }
+
+ /* wend is the size of the current window */
+ j=wend+1;
+ /* add the 'bytes above' */
+ if (!start)
+ for (i=0; i<j; i++)
+ {
+ if (!BN_mod_mul_montgomery(r,r,r,mont,ctx))
+ goto err;
+ }
+
+ /* wvalue will be an odd number < 2^window */
+ if (!BN_mod_mul_montgomery(r,r,&(val[wvalue>>1]),mont,ctx))
+ goto err;
+
+ /* move the 'window' down further */
+ wstart-=wend+1;
+ wvalue=0;
+ start=0;
+ if (wstart < 0) break;
+ }
+ if (!BN_from_montgomery(rr,r,mont,ctx)) goto err;
+ ret=1;
+err:
+ if ((in_mont == NULL) && (mont != NULL)) BN_MONT_CTX_free(mont);
+ BN_CTX_end(ctx);
+ for (i=0; i<ts; i++)
+ BN_clear_free(&(val[i]));
+ return(ret);
+ }
+
+BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w)
+ {
+#ifndef BN_LLONG
+ BN_ULONG ret=0;
+#else
+ BN_ULLONG ret=0;
+#endif
+ int i;
+
+ w&=BN_MASK2;
+ for (i=a->top-1; i>=0; i--)
+ {
+#ifndef BN_LLONG
+ ret=((ret<<BN_BITS4)|((a->d[i]>>BN_BITS4)&BN_MASK2l))%w;
+ ret=((ret<<BN_BITS4)|(a->d[i]&BN_MASK2l))%w;
+#else
+ ret=(BN_ULLONG)(((ret<<(BN_ULLONG)BN_BITS2)|a->d[i])%
+ (BN_ULLONG)w);
+#endif
+ }
+ return((BN_ULONG)ret);
+ }
+
+static int bnrand(int pseudorand, BIGNUM *rnd, int bits, int top, int bottom)
+ {
+ unsigned char *buf=NULL;
+ int ret=0,bit,bytes,mask;
+
+ if (bits == 0)
+ {
+ BN_zero(rnd);
+ return 1;
+ }
+
+ bytes=(bits+7)/8;
+ bit=(bits-1)%8;
+ mask=0xff<<bit;
+
+ buf=(unsigned char *)malloc(bytes);
+ if (buf == NULL)
+ {
+ goto err;
+ }
+
+ /* make a random number and set the top and bottom bits */
+ /* this ignores the pseudorand flag */
+
+ t_random(buf, bytes);
+
+ if (top)
+ {
+ if (bit == 0)
+ {
+ buf[0]=1;
+ buf[1]|=0x80;
+ }
+ else
+ {
+ buf[0]|=(3<<(bit-1));
+ buf[0]&= ~(mask<<1);
+ }
+ }
+ else
+ {
+ buf[0]|=(1<<bit);
+ buf[0]&= ~(mask<<1);
+ }
+ if (bottom) /* set bottom bits to whatever odd is */
+ buf[bytes-1]|=1;
+ if (!BN_bin2bn(buf,bytes,rnd)) goto err;
+ ret=1;
+err:
+ if (buf != NULL)
+ {
+ memset(buf,0,bytes);
+ free(buf);
+ }
+ return(ret);
+ }
+
+/* BN_pseudo_rand is the same as BN_rand, now. */
+
+int BN_pseudo_rand(BIGNUM *rnd, int bits, int top, int bottom)
+ {
+ return bnrand(1, rnd, bits, top, bottom);
+ }
+
+#define MONT_WORD /* use the faster word-based algorithm */
+
+int BN_mod_mul_montgomery(BIGNUM *r, BIGNUM *a, BIGNUM *b,
+ BN_MONT_CTX *mont, BN_CTX *ctx)
+ {
+ BIGNUM *tmp,*tmp2;
+ int ret=0;
+
+ BN_CTX_start(ctx);
+ tmp = BN_CTX_get(ctx);
+ tmp2 = BN_CTX_get(ctx);
+ if (tmp == NULL || tmp2 == NULL) goto err;
+
+ bn_check_top(tmp);
+ bn_check_top(tmp2);
+
+ if (a == b)
+ {
+ if (!BN_sqr(tmp,a,ctx)) goto err;
+ }
+ else
+ {
+ if (!BN_mul(tmp,a,b,ctx)) goto err;
+ }
+ /* reduce from aRR to aR */
+ if (!BN_from_montgomery(r,tmp,mont,ctx)) goto err;
+ ret=1;
+err:
+ BN_CTX_end(ctx);
+ return(ret);
+ }
+
+int BN_from_montgomery(BIGNUM *ret, BIGNUM *a, BN_MONT_CTX *mont,
+ BN_CTX *ctx)
+ {
+ int retn=0;
+
+#ifdef MONT_WORD
+ BIGNUM *n,*r;
+ BN_ULONG *ap,*np,*rp,n0,v,*nrp;
+ int al,nl,max,i,x,ri;
+
+ BN_CTX_start(ctx);
+ if ((r = BN_CTX_get(ctx)) == NULL) goto err;
+
+ if (!BN_copy(r,a)) goto err;
+ n= &(mont->N);
+
+ ap=a->d;
+ /* mont->ri is the size of mont->N in bits (rounded up
+ to the word size) */
+ al=ri=mont->ri/BN_BITS2;
+
+ nl=n->top;
+ if ((al == 0) || (nl == 0)) { r->top=0; return(1); }
+
+ max=(nl+al+1); /* allow for overflow (no?) XXX */
+ if (bn_wexpand(r,max) == NULL) goto err;
+ if (bn_wexpand(ret,max) == NULL) goto err;
+
+ r->neg=a->neg^n->neg;
+ np=n->d;
+ rp=r->d;
+ nrp= &(r->d[nl]);
+
+ /* clear the top words of T */
+#if 1
+ for (i=r->top; i<max; i++) /* memset? XXX */
+ r->d[i]=0;
+#else
+ memset(&(r->d[r->top]),0,(max-r->top)*sizeof(BN_ULONG));
+#endif
+
+ r->top=max;
+ n0=mont->n0;
+
+#ifdef BN_COUNT
+ printf("word BN_from_montgomery %d * %d\n",nl,nl);
+#endif
+ for (i=0; i<nl; i++)
+ {
+#ifdef __TANDEM
+ {
+ long long t1;
+ long long t2;
+ long long t3;
+ t1 = rp[0] * (n0 & 0177777);
+ t2 = 037777600000l;
+ t2 = n0 & t2;
+ t3 = rp[0] & 0177777;
+ t2 = (t3 * t2) & BN_MASK2;
+ t1 = t1 + t2;
+ v=bn_mul_add_words(rp,np,nl,(BN_ULONG) t1);
+ }
+#else
+ v=bn_mul_add_words(rp,np,nl,(rp[0]*n0)&BN_MASK2);
+#endif
+ nrp++;
+ rp++;
+ if (((nrp[-1]+=v)&BN_MASK2) >= v)
+ continue;
+ else
+ {
+ if (((++nrp[0])&BN_MASK2) != 0) continue;
+ if (((++nrp[1])&BN_MASK2) != 0) continue;
+ for (x=2; (((++nrp[x])&BN_MASK2) == 0); x++) ;
+ }
+ }
+ bn_fix_top(r);
+
+ /* mont->ri will be a multiple of the word size */
+#if 0
+ BN_rshift(ret,r,mont->ri);
+#else
+ ret->neg = r->neg;
+ x=ri;
+ rp=ret->d;
+ ap= &(r->d[x]);
+ if (r->top < x)
+ al=0;
+ else
+ al=r->top-x;
+ ret->top=al;
+ al-=4;
+ for (i=0; i<al; i+=4)
+ {
+ BN_ULONG t1,t2,t3,t4;
+
+ t1=ap[i+0];
+ t2=ap[i+1];
+ t3=ap[i+2];
+ t4=ap[i+3];
+ rp[i+0]=t1;
+ rp[i+1]=t2;
+ rp[i+2]=t3;
+ rp[i+3]=t4;
+ }
+ al+=4;
+ for (; i<al; i++)
+ rp[i]=ap[i];
+#endif
+#else /* !MONT_WORD */
+ BIGNUM *t1,*t2;
+
+ BN_CTX_start(ctx);
+ t1 = BN_CTX_get(ctx);
+ t2 = BN_CTX_get(ctx);
+ if (t1 == NULL || t2 == NULL) goto err;
+
+ if (!BN_copy(t1,a)) goto err;
+ BN_mask_bits(t1,mont->ri);
+
+ if (!BN_mul(t2,t1,&mont->Ni,ctx)) goto err;
+ BN_mask_bits(t2,mont->ri);
+
+ if (!BN_mul(t1,t2,&mont->N,ctx)) goto err;
+ if (!BN_add(t2,a,t1)) goto err;
+ BN_rshift(ret,t2,mont->ri);
+#endif /* MONT_WORD */
+
+ if (BN_ucmp(ret, &(mont->N)) >= 0)
+ {
+ BN_usub(ret,ret,&(mont->N));
+ }
+ retn=1;
+ err:
+ BN_CTX_end(ctx);
+ return(retn);
+ }
+
+void BN_MONT_CTX_init(BN_MONT_CTX *ctx)
+ {
+ ctx->ri=0;
+ BN_init(&(ctx->RR));
+ BN_init(&(ctx->N));
+ BN_init(&(ctx->Ni));
+ ctx->flags=0;
+ }
+
+BN_MONT_CTX *BN_MONT_CTX_new(void)
+ {
+ BN_MONT_CTX *ret;
+
+ if ((ret=(BN_MONT_CTX *)malloc(sizeof(BN_MONT_CTX))) == NULL)
+ return(NULL);
+
+ BN_MONT_CTX_init(ret);
+ ret->flags=BN_FLG_MALLOCED;
+ return(ret);
+ }
+
+void BN_MONT_CTX_free(BN_MONT_CTX *mont)
+ {
+ if(mont == NULL)
+ return;
+
+ BN_free(&(mont->RR));
+ BN_free(&(mont->N));
+ BN_free(&(mont->Ni));
+ if (mont->flags & BN_FLG_MALLOCED)
+ free(mont);
+ }
+
+int BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx)
+ {
+ BIGNUM Ri,*R;
+
+ BN_init(&Ri);
+ R= &(mont->RR); /* grab RR as a temp */
+ BN_copy(&(mont->N),mod); /* Set N */
+
+#ifdef MONT_WORD
+ {
+ BIGNUM tmod;
+ BN_ULONG buf[2];
+
+ mont->ri=(BN_num_bits(mod)+(BN_BITS2-1))/BN_BITS2*BN_BITS2;
+ BN_zero(R);
+ BN_set_bit(R,BN_BITS2); /* R */
+
+ buf[0]=mod->d[0]; /* tmod = N mod word size */
+ buf[1]=0;
+ tmod.d=buf;
+ tmod.top=1;
+ tmod.dmax=2;
+ tmod.neg=mod->neg;
+ /* Ri = R^-1 mod N*/
+ if ((BN_mod_inverse(&Ri,R,&tmod,ctx)) == NULL)
+ goto err;
+ BN_lshift(&Ri,&Ri,BN_BITS2); /* R*Ri */
+ if (!BN_is_zero(&Ri))
+ BN_sub_word(&Ri,1);
+ else /* if N mod word size == 1 */
+ BN_set_word(&Ri,BN_MASK2); /* Ri-- (mod word size) */
+ BN_div(&Ri,NULL,&Ri,&tmod,ctx); /* Ni = (R*Ri-1)/N,
+ * keep only least significant word: */
+ mont->n0=Ri.d[0];
+ BN_free(&Ri);
+ }
+#else /* !MONT_WORD */
+ { /* bignum version */
+ mont->ri=BN_num_bits(mod);
+ BN_zero(R);
+ BN_set_bit(R,mont->ri); /* R = 2^ri */
+ /* Ri = R^-1 mod N*/
+ if ((BN_mod_inverse(&Ri,R,mod,ctx)) == NULL)
+ goto err;
+ BN_lshift(&Ri,&Ri,mont->ri); /* R*Ri */
+ BN_sub_word(&Ri,1);
+ /* Ni = (R*Ri-1) / N */
+ BN_div(&(mont->Ni),NULL,&Ri,mod,ctx);
+ BN_free(&Ri);
+ }
+#endif
+
+ /* setup RR for conversions */
+ BN_zero(&(mont->RR));
+ BN_set_bit(&(mont->RR),mont->ri*2);
+ BN_mod(&(mont->RR),&(mont->RR),&(mont->N),ctx);
+
+ return(1);
+err:
+ return(0);
+ }
+
+BIGNUM *BN_value_one(void)
+ {
+ static BN_ULONG data_one=1L;
+ static BIGNUM const_one={&data_one,1,1,0};
+
+ return(&const_one);
+ }
+
+/* solves ax == 1 (mod n) */
+BIGNUM *BN_mod_inverse(BIGNUM *in, BIGNUM *a, const BIGNUM *n, BN_CTX *ctx)
+ {
+ BIGNUM *A,*B,*X,*Y,*M,*D,*R=NULL;
+ BIGNUM *T,*ret=NULL;
+ int sign;
+
+ bn_check_top(a);
+ bn_check_top(n);
+
+ BN_CTX_start(ctx);
+ A = BN_CTX_get(ctx);
+ B = BN_CTX_get(ctx);
+ X = BN_CTX_get(ctx);
+ D = BN_CTX_get(ctx);
+ M = BN_CTX_get(ctx);
+ Y = BN_CTX_get(ctx);
+ if (Y == NULL) goto err;
+
+ if (in == NULL)
+ R=BN_new();
+ else
+ R=in;
+ if (R == NULL) goto err;
+
+ BN_zero(X);
+ BN_one(Y);
+ if (BN_copy(A,a) == NULL) goto err;
+ if (BN_copy(B,n) == NULL) goto err;
+ sign=1;
+
+ while (!BN_is_zero(B))
+ {
+ if (!BN_div(D,M,A,B,ctx)) goto err;
+ T=A;
+ A=B;
+ B=M;
+ /* T has a struct, M does not */
+
+ if (!BN_mul(T,D,X,ctx)) goto err;
+ if (!BN_add(T,T,Y)) goto err;
+ M=Y;
+ Y=X;
+ X=T;
+ sign= -sign;
+ }
+ if (sign < 0)
+ {
+ if (!BN_sub(Y,n,Y)) goto err;
+ }
+
+ if (BN_is_one(A))
+ { if (!BN_mod(R,Y,n,ctx)) goto err; }
+ else
+ {
+ goto err;
+ }
+ ret=R;
+err:
+ if ((ret == NULL) && (in == NULL)) BN_free(R);
+ BN_CTX_end(ctx);
+ return(ret);
+ }
+
+int BN_set_bit(BIGNUM *a, int n)
+ {
+ int i,j,k;
+
+ i=n/BN_BITS2;
+ j=n%BN_BITS2;
+ if (a->top <= i)
+ {
+ if (bn_wexpand(a,i+1) == NULL) return(0);
+ for(k=a->top; k<i+1; k++)
+ a->d[k]=0;
+ a->top=i+1;
+ }
+
+ a->d[i]|=(((BN_ULONG)1)<<j);
+ return(1);
+ }
+
diff --git a/package/network/services/ead/src/tinysrp/t_conv.c b/package/network/services/ead/src/tinysrp/t_conv.c
new file mode 100644
index 0000000..d3fe246
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/t_conv.c
@@ -0,0 +1,226 @@
+/*
+ * Copyright (c) 1997-1999 The Stanford SRP Authentication Project
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF
+ * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * In addition, the following conditions apply:
+ *
+ * 1. Any software that incorporates the SRP authentication technology
+ * must display the following acknowlegment:
+ * "This product uses the 'Secure Remote Password' cryptographic
+ * authentication system developed by Tom Wu (tjw@CS.Stanford.EDU)."
+ *
+ * 2. Any software that incorporates all or part of the SRP distribution
+ * itself must also display the following acknowledgment:
+ * "This product includes software developed by Tom Wu and Eugene
+ * Jhong for the SRP Distribution (http://srp.stanford.edu/srp/)."
+ *
+ * 3. Redistributions in source or binary form must retain an intact copy
+ * of this copyright notice and list of conditions.
+ */
+
+/*#define _POSIX_SOURCE*/
+#include <stdio.h>
+#include "t_defines.h"
+
+static int
+hexDigitToInt(c)
+ char c;
+{
+ if(c >= '0' && c <= '9')
+ return c - '0';
+ else if(c >= 'a' && c <= 'f')
+ return c - 'a' + 10;
+ else if(c >= 'A' && c <= 'F')
+ return c - 'A' + 10;
+ else
+ return 0;
+}
+
+/*
+ * Convert a hex string to a string of bytes; return size of dst
+ */
+_TYPE( int )
+t_fromhex(dst, src)
+ register char *dst, *src;
+{
+ register char *chp = dst;
+ register unsigned size = strlen(src);
+
+ /* FIXME: handle whitespace and non-hex digits by setting size and src
+ appropriately. */
+
+ if(size % 2 == 1) {
+ *chp++ = hexDigitToInt(*src++);
+ --size;
+ }
+ while(size > 0) {
+ *chp++ = (hexDigitToInt(*src) << 4) | hexDigitToInt(*(src + 1));
+ src += 2;
+ size -= 2;
+ }
+ return chp - dst;
+}
+
+/*
+ * Convert a string of bytes to their hex representation
+ */
+_TYPE( char * )
+t_tohex(dst, src, size)
+ register char *dst, *src;
+ register unsigned size;
+{
+ int notleading = 0;
+
+ register char *chp = dst;
+ if (size != 0) do {
+ if(notleading || *src != '\0') {
+ notleading = 1;
+ sprintf(chp, "%.2x", * (unsigned char *) src);
+ chp += 2;
+ }
+ ++src;
+ } while (--size != 0);
+ return dst;
+}
+
+static char b64table[] =
+ "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz./";
+
+/*
+ * Convert a base64 string into raw byte array representation.
+ */
+_TYPE( int )
+t_fromb64(dst, src)
+ register char *dst, *src;
+{
+ unsigned char *a;
+ char *loc;
+ int i, j;
+ unsigned int size;
+
+ while(*src && (*src == ' ' || *src == '\t' || *src == '\n'))
+ ++src;
+ size = strlen(src);
+
+ a = malloc((size + 1) * sizeof(unsigned char));
+ if(a == (unsigned char *) 0)
+ return -1;
+
+ i = 0;
+ while(i < size) {
+ loc = strchr(b64table, src[i]);
+ if(loc == (char *) 0)
+ break;
+ else
+ a[i] = loc - b64table;
+ ++i;
+ }
+ size = i;
+
+ i = size - 1;
+ j = size;
+ while(1) {
+ a[j] = a[i];
+ if(--i < 0)
+ break;
+ a[j] |= (a[i] & 3) << 6;
+ --j;
+ a[j] = (unsigned char) ((a[i] & 0x3c) >> 2);
+ if(--i < 0)
+ break;
+ a[j] |= (a[i] & 0xf) << 4;
+ --j;
+ a[j] = (unsigned char) ((a[i] & 0x30) >> 4);
+ if(--i < 0)
+ break;
+ a[j] |= (a[i] << 2);
+
+ a[--j] = 0;
+ if(--i < 0)
+ break;
+ }
+
+ while(a[j] == 0 && j <= size)
+ ++j;
+
+ memcpy(dst, a + j, size - j + 1);
+ free(a);
+ return size - j + 1;
+}
+
+/*
+ * Convert a raw byte string into a null-terminated base64 ASCII string.
+ */
+_TYPE( char * )
+t_tob64(dst, src, size)
+ register char *dst, *src;
+ register unsigned size;
+{
+ int c, pos = size % 3;
+ unsigned char b0 = 0, b1 = 0, b2 = 0, notleading = 0;
+ char *olddst = dst;
+
+ switch(pos) {
+ case 1:
+ b2 = src[0];
+ break;
+ case 2:
+ b1 = src[0];
+ b2 = src[1];
+ break;
+ }
+
+ while(1) {
+ c = (b0 & 0xfc) >> 2;
+ if(notleading || c != 0) {
+ *dst++ = b64table[c];
+ notleading = 1;
+ }
+ c = ((b0 & 3) << 4) | ((b1 & 0xf0) >> 4);
+ if(notleading || c != 0) {
+ *dst++ = b64table[c];
+ notleading = 1;
+ }
+ c = ((b1 & 0xf) << 2) | ((b2 & 0xc0) >> 6);
+ if(notleading || c != 0) {
+ *dst++ = b64table[c];
+ notleading = 1;
+ }
+ c = b2 & 0x3f;
+ if(notleading || c != 0) {
+ *dst++ = b64table[c];
+ notleading = 1;
+ }
+ if(pos >= size)
+ break;
+ else {
+ b0 = src[pos++];
+ b1 = src[pos++];
+ b2 = src[pos++];
+ }
+ }
+
+ *dst++ = '\0';
+ return olddst;
+}
diff --git a/package/network/services/ead/src/tinysrp/t_defines.h b/package/network/services/ead/src/tinysrp/t_defines.h
new file mode 100644
index 0000000..4128093
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/t_defines.h
@@ -0,0 +1,169 @@
+/*
+ * Copyright (c) 1997-1999 The Stanford SRP Authentication Project
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF
+ * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * In addition, the following conditions apply:
+ *
+ * 1. Any software that incorporates the SRP authentication technology
+ * must display the following acknowlegment:
+ * "This product uses the 'Secure Remote Password' cryptographic
+ * authentication system developed by Tom Wu (tjw@CS.Stanford.EDU)."
+ *
+ * 2. Any software that incorporates all or part of the SRP distribution
+ * itself must also display the following acknowledgment:
+ * "This product includes software developed by Tom Wu and Eugene
+ * Jhong for the SRP Distribution (http://srp.stanford.edu/srp/)."
+ *
+ * 3. Redistributions in source or binary form must retain an intact copy
+ * of this copyright notice and list of conditions.
+ */
+
+#ifndef T_DEFINES_H
+#define T_DEFINES_H
+
+#ifndef P
+#if defined(__STDC__) || defined(__cplusplus)
+#define P(x) x
+#else
+#define P(x) ()
+#endif
+#endif
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#ifndef _DLLDECL
+#define _DLLDECL
+
+#ifdef MSVC15 /* MSVC1.5 support for 16 bit apps */
+#define _MSVC15EXPORT _export
+#define _MSVC20EXPORT
+#define _DLLAPI _export _pascal
+#define _TYPE(a) a _MSVC15EXPORT
+#define DLLEXPORT 1
+
+#elif MSVC20
+#define _MSVC15EXPORT
+#define _MSVC20EXPORT _declspec(dllexport)
+#define _DLLAPI
+#define _TYPE(a) _MSVC20EXPORT a
+#define DLLEXPORT 1
+
+#else /* Default, non-dll. Use this for Unix or DOS */
+#define _MSVC15DEXPORT
+#define _MSVC20EXPORT
+#define _DLLAPI
+#define _TYPE(a) a
+#endif
+#endif
+
+#if STDC_HEADERS
+#include <stdlib.h>
+#include <string.h>
+#else /* not STDC_HEADERS */
+#ifndef HAVE_STRCHR
+#define strchr index
+#define strrchr rindex
+#endif
+char *strchr(), *strrchr(), *strtok();
+#ifndef HAVE_MEMCPY
+#define memcpy(d, s, n) bcopy((s), (d), (n))
+#endif
+#endif /* not STDC_HEADERS */
+
+#include <sys/types.h>
+
+#if TIME_WITH_SYS_TIME
+#include <sys/time.h>
+#include <time.h>
+#else /* not TIME_WITH_SYS_TIME */
+#if HAVE_SYS_TIME_H
+#include <sys/time.h>
+#else
+#include <time.h>
+#endif
+#endif /* not TIME_WITH_SYS_TIME */
+
+#if HAVE_TERMIOS_H
+#include <termios.h>
+#define STTY(fd, termio) tcsetattr(fd, TCSANOW, termio)
+#define GTTY(fd, termio) tcgetattr(fd, termio)
+#define TERMIO struct termios
+#define USE_TERMIOS
+#elif HAVE_TERMIO_H
+#include <sys/ioctl.h>
+#include <termio.h>
+#define STTY(fd, termio) ioctl(fd, TCSETA, termio)
+#define GTTY(fd, termio) ioctl(fd, TCGETA, termio)
+#define TEMRIO struct termio
+#define USE_TERMIO
+#elif HAVE_SGTTY_H
+#include <sgtty.h>
+#define STTY(fd, termio) stty(fd, termio)
+#define GTTY(fd, termio) gtty(fd, termio)
+#define TERMIO struct sgttyb
+#define USE_SGTTY
+#endif
+
+#ifdef USE_FTIME
+#include <sys/timeb.h>
+#endif
+
+#ifndef MATH_PRIV
+typedef void * BigInteger;
+#endif
+
+_TYPE( BigInteger ) BigIntegerFromInt P((unsigned int number));
+_TYPE( BigInteger ) BigIntegerFromBytes P((unsigned char * bytes, int length));
+_TYPE( int ) BigIntegerToBytes P((BigInteger src, unsigned char * dest));
+_TYPE( int ) BigIntegerBitLen P((BigInteger b));
+_TYPE( int ) BigIntegerCmp P((BigInteger c1, BigInteger c2));
+_TYPE( int ) BigIntegerCmpInt P((BigInteger c1, unsigned int c2));
+_TYPE( void ) BigIntegerLShift P((BigInteger result, BigInteger x,
+ unsigned int bits));
+_TYPE( void ) BigIntegerAdd P((BigInteger result, BigInteger a1, BigInteger a2));
+_TYPE( void ) BigIntegerAddInt P((BigInteger result,
+ BigInteger a1, unsigned int a2));
+_TYPE( void ) BigIntegerSub P((BigInteger result, BigInteger s1, BigInteger s2));
+_TYPE( void ) BigIntegerSubInt P((BigInteger result,
+ BigInteger s1, unsigned int s2));
+/* For BigIntegerMul{,Int}: result != m1, m2 */
+_TYPE( void ) BigIntegerMul P((BigInteger result, BigInteger m1, BigInteger m2));
+_TYPE( void ) BigIntegerMulInt P((BigInteger result,
+ BigInteger m1, unsigned int m2));
+_TYPE( void ) BigIntegerDivInt P((BigInteger result,
+ BigInteger d, unsigned int m));
+_TYPE( void ) BigIntegerMod P((BigInteger result, BigInteger d, BigInteger m));
+_TYPE( unsigned int ) BigIntegerModInt P((BigInteger d, unsigned int m));
+_TYPE( void ) BigIntegerModMul P((BigInteger result,
+ BigInteger m1, BigInteger m2, BigInteger m));
+_TYPE( void ) BigIntegerModExp P((BigInteger result, BigInteger base,
+ BigInteger expt, BigInteger modulus));
+_TYPE( void ) BigIntegerModExpInt P((BigInteger result, BigInteger base,
+ unsigned int expt, BigInteger modulus));
+_TYPE( int ) BigIntegerCheckPrime P((BigInteger n));
+_TYPE( void ) BigIntegerFree P((BigInteger b));
+
+#endif
diff --git a/package/network/services/ead/src/tinysrp/t_getconf.c b/package/network/services/ead/src/tinysrp/t_getconf.c
new file mode 100644
index 0000000..db6de61
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/t_getconf.c
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 1997-1999 The Stanford SRP Authentication Project
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF
+ * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * In addition, the following conditions apply:
+ *
+ * 1. Any software that incorporates the SRP authentication technology
+ * must display the following acknowlegment:
+ * "This product uses the 'Secure Remote Password' cryptographic
+ * authentication system developed by Tom Wu (tjw@CS.Stanford.EDU)."
+ *
+ * 2. Any software that incorporates all or part of the SRP distribution
+ * itself must also display the following acknowledgment:
+ * "This product includes software developed by Tom Wu and Eugene
+ * Jhong for the SRP Distribution (http://srp.stanford.edu/srp/)."
+ *
+ * 3. Redistributions in source or binary form must retain an intact copy
+ * of this copyright notice and list of conditions.
+ */
+
+#include <stdio.h>
+
+#include "t_defines.h"
+#include "t_pwd.h"
+#include "t_read.h"
+
+/* Master builtin parameter storage object. The default that tphrase
+uses is the last one. */
+
+static struct pre_struct {
+ struct t_preconf preconf;
+ int state; /* 0 == uninitialized/first time */
+ unsigned char modbuf[MAXPARAMLEN];
+ unsigned char genbuf[MAXPARAMLEN];
+} pre_params[] = {
+ { { "2iQzj1CagQc/5ctbuJYLWlhtAsPHc7xWVyCPAKFRLWKADpASkqe9djWPFWTNTdeJtL8nAhImCn3Sr/IAdQ1FrGw0WvQUstPx3FO9KNcXOwisOQ1VlL.gheAHYfbYyBaxXL.NcJx9TUwgWDT0hRzFzqSrdGGTN3FgSTA1v4QnHtEygNj3eZ.u0MThqWUaDiP87nqha7XnT66bkTCkQ8.7T8L4KZjIImrNrUftedTTBi.WCi.zlrBxDuOM0da0JbUkQlXqvp0yvJAPpC11nxmmZOAbQOywZGmu9nhZNuwTlxjfIro0FOdthaDTuZRL9VL7MRPUDo/DQEyW.d4H.UIlzp",
+ "2",
+ NULL }, 0 },
+ { { "dUyyhxav9tgnyIg65wHxkzkb7VIPh4o0lkwfOKiPp4rVJrzLRYVBtb76gKlaO7ef5LYGEw3G.4E0jbMxcYBetDy2YdpiP/3GWJInoBbvYHIRO9uBuxgsFKTKWu7RnR7yTau/IrFTdQ4LY/q.AvoCzMxV0PKvD9Odso/LFIItn8PbTov3VMn/ZEH2SqhtpBUkWtmcIkEflhX/YY/fkBKfBbe27/zUaKUUZEUYZ2H2nlCL60.JIPeZJSzsu/xHDVcx",
+ "2",
+ NULL }, 0 },
+ { { "3NUKQ2Re4P5BEK0TLg2dX3gETNNNECPoe92h4OVMaDn3Xo/0QdjgG/EvM.hiVV1BdIGklSI14HA38Mpe5k04juR5/EXMU0r1WtsLhNXwKBlf2zEfoOh0zVmDvqInpU695f29Iy7sNW3U5RIogcs740oUp2Kdv5wuITwnIx84cnO.e467/IV1lPnvMCr0pd1dgS0a.RV5eBJr03Q65Xy61R",
+ "2",
+ NULL }, 0 },
+ { { "F//////////oG/QeY5emZJ4ncABWDmSqIa2JWYAPynq0Wk.fZiJco9HIWXvZZG4tU.L6RFDEaCRC2iARV9V53TFuJLjRL72HUI5jNPYNdx6z4n2wQOtxMiB/rosz0QtxUuuQ/jQYP.bhfya4NnB7.P9A6PHxEPJWV//////////",
+ "5",
+ "oakley prime 2" }, 0 },
+ { { "Ewl2hcjiutMd3Fu2lgFnUXWSc67TVyy2vwYCKoS9MLsrdJVT9RgWTCuEqWJrfB6uE3LsE9GkOlaZabS7M29sj5TnzUqOLJMjiwEzArfiLr9WbMRANlF68N5AVLcPWvNx6Zjl3m5Scp0BzJBz9TkgfhzKJZ.WtP3Mv/67I/0wmRZ",
+ "2",
+ NULL }, 0 },
+};
+
+_TYPE( int )
+t_getprecount()
+{
+ return (sizeof(pre_params) / sizeof(struct pre_struct));
+}
+
+static struct t_confent sysconf;
+
+/* id is index origin 1 */
+
+_TYPE( struct t_confent * )
+gettcid
+(id)
+ int id;
+{
+ struct t_preconf *tcp;
+
+ if (id <= 0 || id > t_getprecount()) {
+ return NULL;
+ }
+ tcp = t_getpreparam(id - 1);
+ sysconf.index = id;
+ sysconf.modulus = tcp->modulus;
+ sysconf.generator = tcp->generator;
+
+ return &sysconf;
+}
+
+_TYPE( struct t_preconf * )
+t_getpreparam(idx)
+ int idx;
+{
+ if(pre_params[idx].state == 0) {
+ /* Wire up storage */
+ pre_params[idx].preconf.modulus.data = pre_params[idx].modbuf;
+ pre_params[idx].preconf.generator.data = pre_params[idx].genbuf;
+
+ /* Convert from b64 to t_num */
+ pre_params[idx].preconf.modulus.len = t_fromb64(pre_params[idx].preconf.modulus.data, pre_params[idx].preconf.mod_b64);
+ pre_params[idx].preconf.generator.len = t_fromb64(pre_params[idx].preconf.generator.data, pre_params[idx].preconf.gen_b64);
+
+ pre_params[idx].state = 1;
+ }
+ return &(pre_params[idx].preconf);
+}
diff --git a/package/network/services/ead/src/tinysrp/t_getpass.c b/package/network/services/ead/src/tinysrp/t_getpass.c
new file mode 100644
index 0000000..6ae7fca
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/t_getpass.c
@@ -0,0 +1,191 @@
+/*
+ * Copyright 1990 - 1995, Julianne Frances Haugh
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Julianne F. Haugh nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JULIE HAUGH AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL JULIE HAUGH OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "t_defines.h"
+#ifdef _WIN32
+#include <windows.h>
+#include <io.h>
+#endif /* _WIN32 */
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif /* HAVE_UNISTD_H */
+#include <signal.h>
+#include <stdio.h>
+
+static int sig_caught;
+#ifdef HAVE_SIGACTION
+static struct sigaction sigact;
+#endif
+
+/*ARGSUSED*/
+static RETSIGTYPE
+sig_catch (sig)
+int sig;
+{
+ sig_caught = 1;
+}
+
+_TYPE( int )
+t_getpass (buf, maxlen, prompt)
+ char *buf;
+ unsigned maxlen;
+ const char *prompt;
+{
+ char *cp;
+#ifdef _WIN32
+ HANDLE handle = (HANDLE) _get_osfhandle(_fileno(stdin));
+ DWORD mode;
+
+ GetConsoleMode( handle, &mode );
+ SetConsoleMode( handle, mode & ~ENABLE_ECHO_INPUT );
+
+ if(fputs(prompt, stdout) == EOF ||
+ fgets(buf, maxlen, stdin) == NULL) {
+ SetConsoleMode(handle,mode);
+ return -1;
+ }
+ cp = buf + strlen(buf) - 1;
+ if ( *cp == 0x0a )
+ *cp = '\0';
+ printf("\n");
+ SetConsoleMode(handle,mode);
+#else
+ FILE *fp;
+ int tty_opened = 0;
+
+#ifdef HAVE_SIGACTION
+ struct sigaction old_sigact;
+#else
+ RETSIGTYPE (*old_signal)();
+#endif
+ TERMIO new_modes;
+ TERMIO old_modes;
+
+ /*
+ * set a flag so the SIGINT signal can be re-sent if it
+ * is caught
+ */
+
+ sig_caught = 0;
+
+ /*
+ * if /dev/tty can't be opened, getpass() needs to read
+ * from stdin instead.
+ */
+
+ if ((fp = fopen ("/dev/tty", "r")) == 0) {
+ fp = stdin;
+ setbuf (fp, (char *) 0);
+ } else {
+ tty_opened = 1;
+ }
+
+ /*
+ * the current tty modes must be saved so they can be
+ * restored later on. echo will be turned off, except
+ * for the newline character (BSD has to punt on this)
+ */
+
+ if (GTTY (fileno (fp), &new_modes))
+ return -1;
+
+ old_modes = new_modes;
+
+#ifdef HAVE_SIGACTION
+ sigact.sa_handler = sig_catch;
+ (void) sigaction (SIGINT, &sigact, &old_sigact);
+#else
+ old_signal = signal (SIGINT, sig_catch);
+#endif
+
+#ifdef USE_SGTTY
+ new_modes.sg_flags &= ~ECHO;
+#else
+ new_modes.c_iflag &= ~IGNCR;
+ new_modes.c_iflag |= ICRNL;
+ new_modes.c_oflag |= OPOST|ONLCR;
+ new_modes.c_lflag &= ~(ECHO|ECHOE|ECHOK);
+ new_modes.c_lflag |= ICANON|ECHONL;
+#endif
+
+ if (STTY (fileno (fp), &new_modes))
+ goto out;
+
+ /*
+ * the prompt is output, and the response read without
+ * echoing. the trailing newline must be removed. if
+ * the fgets() returns an error, a NULL pointer is
+ * returned.
+ */
+
+ if (fputs (prompt, stdout) == EOF)
+ goto out;
+
+ (void) fflush (stdout);
+
+ if (fgets (buf, maxlen, fp) == buf) {
+ if ((cp = strchr (buf, '\n')))
+ *cp = '\0';
+ else
+ buf[maxlen - 1] = '\0';
+
+#ifdef USE_SGTTY
+ putc ('\n', stdout);
+#endif
+ }
+ else buf[0] = '\0';
+out:
+ /*
+ * the old SIGINT handler is restored after the tty
+ * modes. then /dev/tty is closed if it was opened in
+ * the beginning. finally, if a signal was caught it
+ * is sent to this process for normal processing.
+ */
+
+ if (STTY (fileno (fp), &old_modes))
+ { memset (buf, 0, maxlen); return -1; }
+
+#ifdef HAVE_SIGACTION
+ (void) sigaction (SIGINT, &old_sigact, NULL);
+#else
+ (void) signal (SIGINT, old_signal);
+#endif
+
+ if (tty_opened)
+ (void) fclose (fp);
+
+ if (sig_caught) {
+ kill (getpid (), SIGINT);
+ memset (buf, 0, maxlen);
+ return -1;
+ }
+#endif
+
+ return 0;
+}
diff --git a/package/network/services/ead/src/tinysrp/t_math.c b/package/network/services/ead/src/tinysrp/t_math.c
new file mode 100644
index 0000000..20161a0
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/t_math.c
@@ -0,0 +1,177 @@
+/*
+ * Copyright (c) 1997-1999 The Stanford SRP Authentication Project
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF
+ * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * In addition, the following conditions apply:
+ *
+ * 1. Any software that incorporates the SRP authentication technology
+ * must display the following acknowlegment:
+ * "This product uses the 'Secure Remote Password' cryptographic
+ * authentication system developed by Tom Wu (tjw@CS.Stanford.EDU)."
+ *
+ * 2. Any software that incorporates all or part of the SRP distribution
+ * itself must also display the following acknowledgment:
+ * "This product includes software developed by Tom Wu and Eugene
+ * Jhong for the SRP Distribution (http://srp.stanford.edu/srp/)."
+ *
+ * 3. Redistributions in source or binary form must retain an intact copy
+ * of this copyright notice and list of conditions.
+ */
+
+#include <stdio.h>
+#include <sys/types.h>
+
+#include "config.h"
+
+#include "bn.h"
+typedef BIGNUM * BigInteger;
+#define MATH_PRIV
+
+#include "t_defines.h"
+#include "t_pwd.h"
+
+/* Math library interface stubs */
+
+BigInteger
+BigIntegerFromInt(n)
+ unsigned int n;
+{
+ BIGNUM * a = BN_new();
+ BN_set_word(a, n);
+ return a;
+}
+
+BigInteger
+BigIntegerFromBytes(bytes, length)
+ unsigned char * bytes;
+ int length;
+{
+ BIGNUM * a = BN_new();
+ BN_bin2bn(bytes, length, a);
+ return a;
+}
+
+int
+BigIntegerToBytes(src, dest)
+ BigInteger src;
+ unsigned char * dest;
+{
+ return BN_bn2bin(src, dest);
+}
+
+int
+BigIntegerCmp(c1, c2)
+ BigInteger c1, c2;
+{
+ return BN_cmp(c1, c2);
+}
+
+int
+BigIntegerCmpInt(c1, c2)
+ BigInteger c1;
+ unsigned int c2;
+{
+ BIGNUM * a = BN_new();
+ int rv;
+ BN_set_word(a, c2);
+ rv = BN_cmp(c1, a);
+ BN_free(a);
+ return rv;
+}
+
+void
+BigIntegerAdd(result, a1, a2)
+ BigInteger result, a1, a2;
+{
+ BN_add(result, a1, a2);
+}
+
+void
+BigIntegerAddInt(result, a1, a2)
+ BigInteger result, a1;
+ unsigned int a2;
+{
+ BIGNUM * a = BN_new();
+ BN_set_word(a, a2);
+ BN_add(result, a1, a);
+ BN_free(a);
+}
+
+void
+BigIntegerSub(result, s1, s2)
+ BigInteger result, s1, s2;
+{
+ BN_sub(result, s1, s2);
+}
+
+void
+BigIntegerMulInt(result, m1, m2)
+ BigInteger result, m1;
+ unsigned int m2;
+{
+ BN_CTX * ctx = BN_CTX_new();
+ BIGNUM * m = BN_new();
+ BN_set_word(m, m2);
+ BN_mul(result, m1, m, ctx);
+ BN_CTX_free(ctx);
+}
+
+void
+BigIntegerModMul(r, m1, m2, modulus)
+ BigInteger r, m1, m2, modulus;
+{
+ BN_CTX * ctx = BN_CTX_new();
+ BN_mod_mul(r, m1, m2, modulus, ctx);
+ BN_CTX_free(ctx);
+}
+
+void
+BigIntegerModExp(r, b, e, m)
+ BigInteger r, b, e, m;
+{
+ BN_CTX * ctx = BN_CTX_new();
+ BN_mod_exp(r, b, e, m, ctx);
+ BN_CTX_free(ctx);
+}
+
+void
+BigIntegerModExpInt(r, b, e, m)
+ BigInteger r, b;
+ unsigned int e;
+ BigInteger m;
+{
+ BN_CTX * ctx = BN_CTX_new();
+ BIGNUM * p = BN_new();
+ BN_set_word(p, e);
+ BN_mod_exp(r, b, p, m, ctx);
+ BN_free(p);
+ BN_CTX_free(ctx);
+}
+
+void
+BigIntegerFree(b)
+ BigInteger b;
+{
+ BN_free(b);
+}
diff --git a/package/network/services/ead/src/tinysrp/t_misc.c b/package/network/services/ead/src/tinysrp/t_misc.c
new file mode 100644
index 0000000..a23986f
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/t_misc.c
@@ -0,0 +1,338 @@
+/*
+ * Copyright (c) 1997-1999 The Stanford SRP Authentication Project
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF
+ * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * In addition, the following conditions apply:
+ *
+ * 1. Any software that incorporates the SRP authentication technology
+ * must display the following acknowlegment:
+ * "This product uses the 'Secure Remote Password' cryptographic
+ * authentication system developed by Tom Wu (tjw@CS.Stanford.EDU)."
+ *
+ * 2. Any software that incorporates all or part of the SRP distribution
+ * itself must also display the following acknowledgment:
+ * "This product includes software developed by Tom Wu and Eugene
+ * Jhong for the SRP Distribution (http://srp.stanford.edu/srp/)."
+ *
+ * 3. Redistributions in source or binary form must retain an intact copy
+ * of this copyright notice and list of conditions.
+ */
+
+#include "t_defines.h"
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif /* HAVE_UNISTD_H */
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#include "t_sha.h"
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+static unsigned char randpool[SHA_DIGESTSIZE], randout[SHA_DIGESTSIZE];
+static unsigned long randcnt = 0;
+static unsigned int outpos = 0;
+SHA1_CTX randctxt;
+
+/*
+ * t_envhash - Generate a 160-bit SHA hash of the environment
+ *
+ * This routine performs an SHA hash of all the "name=value" pairs
+ * in the environment concatenated together and dumps them in the
+ * output. While it is true that anyone on the system can see
+ * your environment, someone not on the system will have a very
+ * difficult time guessing it, especially since some systems play
+ * tricks with variable ordering and sometimes define quirky
+ * environment variables like $WINDOWID or $_.
+ */
+extern char ** environ;
+
+static void
+t_envhash(out)
+ unsigned char * out;
+{
+ char ** ptr;
+ char ebuf[256];
+ SHA1_CTX ctxt;
+
+ SHA1Init(&ctxt);
+ for(ptr = environ; *ptr; ++ptr) {
+ strncpy(ebuf, *ptr, 255);
+ ebuf[255] = '\0';
+ SHA1Update(&ctxt, ebuf, strlen(ebuf));
+ }
+ SHA1Final(out, &ctxt);
+}
+
+/*
+ * t_fshash - Generate a 160-bit SHA hash from the file system
+ *
+ * This routine climbs up the directory tree from the current
+ * directory, running stat() on each directory until it hits the
+ * root directory. This information is sensitive to the last
+ * access/modification times of all the directories above you,
+ * so someone who lists one of those directories injects some
+ * entropy into the system. Obviously, this hash is very sensitive
+ * to your current directory when the program is run.
+ *
+ * For good measure, it also performs an fstat on the standard input,
+ * usually your tty, throws that into the buffer, creates a file in
+ * /tmp (the inode is unpredictable on a busy system), and runs stat()
+ * on that before deleting it.
+ *
+ * The entire buffer is run once through SHA to obtain the final result.
+ */
+static void
+t_fshash(out)
+ unsigned char * out;
+{
+ char dotpath[128];
+ struct stat st;
+ SHA1_CTX ctxt;
+ int i, pinode;
+ dev_t pdev;
+
+ SHA1Init(&ctxt);
+ if(stat(".", &st) >= 0) {
+ SHA1Update(&ctxt, (unsigned char *) &st, sizeof(st));
+ pinode = st.st_ino;
+ pdev = st.st_dev;
+ strcpy(dotpath, "..");
+ for(i = 0; i < 40; ++i) {
+ if(stat(dotpath, &st) < 0)
+ break;
+ if(st.st_ino == pinode && st.st_dev == pdev)
+ break;
+ SHA1Update(&ctxt, (unsigned char *) &st, sizeof(st));
+ pinode = st.st_ino;
+ pdev = st.st_dev;
+ strcat(dotpath, "/..");
+ }
+ }
+
+ if(fstat(0, &st) >= 0)
+ SHA1Update(&ctxt, (unsigned char *) &st, sizeof(st));
+
+ sprintf(dotpath, "/tmp/rnd.%d", getpid());
+ if(creat(dotpath, 0600) >= 0 && stat(dotpath, &st) >= 0)
+ SHA1Update(&ctxt, (unsigned char *) &st, sizeof(st));
+ unlink(dotpath);
+
+ SHA1Final(out, &ctxt);
+}
+
+/*
+ * Generate a high-entropy seed for the strong random number generator.
+ * This uses a wide variety of quickly gathered and somewhat unpredictable
+ * system information. The 'preseed' structure is assembled from:
+ *
+ * The system time in seconds
+ * The system time in microseconds
+ * The current process ID
+ * The parent process ID
+ * A hash of the user's environment
+ * A hash gathered from the file system
+ * Input from a random device, if available
+ * Timings of system interrupts
+ *
+ * The entire structure (60 bytes on most systems) is fed to SHA to produce
+ * a 160-bit seed for the strong random number generator. It is believed
+ * that in the worst case (on a quiet system with no random device versus
+ * an attacker who has access to the system already), the seed contains at
+ * least about 80 bits of entropy. Versus an attacker who does not have
+ * access to the system, the entropy should be slightly over 128 bits.
+ */
+static char initialized = 0;
+
+static struct {
+ unsigned int trand1;
+ time_t sec;
+ time_t usec;
+ short pid;
+ short ppid;
+ unsigned char envh[SHA_DIGESTSIZE];
+ unsigned char fsh[SHA_DIGESTSIZE];
+ unsigned char devrand[20];
+ unsigned int trand2;
+} preseed;
+
+unsigned long raw_truerand();
+
+void
+t_initrand()
+{
+ SHA1_CTX ctxt;
+#ifdef USE_FTIME
+ struct timeb t;
+#else
+ struct timeval t;
+#endif
+ int i, r=0;
+
+ if(initialized)
+ return;
+
+ initialized = 1;
+
+ i = open("/dev/urandom", O_RDONLY);
+ if(i > 0) {
+ r += read(i, preseed.devrand, sizeof(preseed.devrand));
+ close(i);
+ }
+
+ /* Resort to truerand only if desperate for some Real entropy */
+ if(r == 0)
+ preseed.trand1 = raw_truerand();
+
+#ifdef USE_FTIME
+ ftime(&t);
+#else
+ gettimeofday(&t, NULL);
+#endif
+
+#ifdef USE_FTIME
+ preseed.sec = t.time;
+ preseed.usec = t.millitm;
+#else
+ preseed.sec = t.tv_sec;
+ preseed.usec = t.tv_usec;
+#endif
+ preseed.pid = getpid();
+ preseed.ppid = getppid();
+ t_envhash(preseed.envh);
+ t_fshash(preseed.fsh);
+
+ if(r == 0)
+ preseed.trand2 = raw_truerand();
+
+ SHA1Init(&ctxt);
+ SHA1Update(&ctxt, (unsigned char *) &preseed, sizeof(preseed));
+ SHA1Final(randpool, &ctxt);
+ outpos = 0;
+ memset((unsigned char *) &preseed, 0, sizeof(preseed));
+ memset((unsigned char *) &ctxt, 0, sizeof(ctxt));
+}
+
+#define NUM_RANDOMS 12
+
+/*
+ * The strong random number generator. This uses a 160-bit seed
+ * and uses SHA-1 in a feedback configuration to generate successive
+ * outputs. If S[0] is set to the initial seed, then:
+ *
+ * S[i+1] = SHA-1(i || S[i])
+ * A[i] = SHA-1(S[i])
+ *
+ * where the A[i] are the output blocks starting with i=0.
+ * Each cycle generates 20 bytes of new output.
+ */
+_TYPE( void )
+t_random(data, size)
+ unsigned char * data;
+ unsigned size;
+{
+ if(!initialized)
+ t_initrand();
+
+ if(size <= 0) /* t_random(NULL, 0) forces seed initialization */
+ return;
+
+ while(size > outpos) {
+ if(outpos > 0) {
+ memcpy(data, randout + (sizeof(randout) - outpos), outpos);
+ data += outpos;
+ size -= outpos;
+ }
+
+ /* Recycle */
+ SHA1Init(&randctxt);
+ SHA1Update(&randctxt, randpool, sizeof(randpool));
+ SHA1Final(randout, &randctxt);
+ SHA1Init(&randctxt);
+ SHA1Update(&randctxt, (unsigned char *) &randcnt, sizeof(randcnt));
+ SHA1Update(&randctxt, randpool, sizeof(randpool));
+ SHA1Final(randpool, &randctxt);
+ ++randcnt;
+ outpos = sizeof(randout);
+ }
+
+ if(size > 0) {
+ memcpy(data, randout + (sizeof(randout) - outpos), size);
+ outpos -= size;
+ }
+}
+
+/*
+ * The interleaved session-key hash. This separates the even and the odd
+ * bytes of the input (ignoring the first byte if the input length is odd),
+ * hashes them separately, and re-interleaves the two outputs to form a
+ * single 320-bit value.
+ */
+_TYPE( unsigned char * )
+t_sessionkey(key, sk, sklen)
+ unsigned char * key;
+ unsigned char * sk;
+ unsigned sklen;
+{
+ unsigned i, klen;
+ unsigned char * hbuf;
+ unsigned char hout[SHA_DIGESTSIZE];
+ SHA1_CTX ctxt;
+
+ while(sklen > 0 && *sk == 0) { /* Skip leading 0's */
+ --sklen;
+ ++sk;
+ }
+
+ klen = sklen / 2;
+ if((hbuf = malloc(klen * sizeof(char))) == 0)
+ return 0;
+
+ for(i = 0; i < klen; ++i)
+ hbuf[i] = sk[sklen - 2 * i - 1];
+ SHA1Init(&ctxt);
+ SHA1Update(&ctxt, hbuf, klen);
+ SHA1Final(hout, &ctxt);
+ for(i = 0; i < sizeof(hout); ++i)
+ key[2 * i] = hout[i];
+
+ for(i = 0; i < klen; ++i)
+ hbuf[i] = sk[sklen - 2 * i - 2];
+ SHA1Init(&ctxt);
+ SHA1Update(&ctxt, hbuf, klen);
+ SHA1Final(hout, &ctxt);
+ for(i = 0; i < sizeof(hout); ++i)
+ key[2 * i + 1] = hout[i];
+
+ memset(hout, 0, sizeof(hout));
+ memset(hbuf, 0, klen);
+ free(hbuf);
+ return key;
+}
diff --git a/package/network/services/ead/src/tinysrp/t_pw.c b/package/network/services/ead/src/tinysrp/t_pw.c
new file mode 100644
index 0000000..18e929b
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/t_pw.c
@@ -0,0 +1,262 @@
+/*
+ * Copyright (c) 1997-2000 The Stanford SRP Authentication Project
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF
+ * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * In addition, the following conditions apply:
+ *
+ * 1. Any software that incorporates the SRP authentication technology
+ * must display the following acknowlegment:
+ * "This product uses the 'Secure Remote Password' cryptographic
+ * authentication system developed by Tom Wu (tjw@CS.Stanford.EDU)."
+ *
+ * 2. Any software that incorporates all or part of the SRP distribution
+ * itself must also display the following acknowledgment:
+ * "This product includes software developed by Tom Wu and Eugene
+ * Jhong for the SRP Distribution (http://srp.stanford.edu/srp/)."
+ *
+ * 3. Redistributions in source or binary form must retain an intact copy
+ * of this copyright notice and list of conditions.
+ */
+
+#include "t_defines.h"
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif /* HAVE_UNISTD_H */
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#ifdef USE_HOMEDIR
+#include <pwd.h>
+#endif
+#ifdef WIN32
+#include <io.h>
+#endif
+
+#include "t_pwd.h"
+#include "t_read.h"
+#include "t_sha.h"
+#include "t_server.h"
+
+static struct t_pw * syspw = NULL;
+static struct t_passwd tpass;
+
+_TYPE( struct t_server * )
+t_serveropen(username)
+ const char * username;
+{
+ struct t_passwd * p;
+ p = gettpnam(username);
+ if(p == NULL) {
+ return NULL;
+ } else {
+ return t_serveropenraw(&p->tp, &p->tc);
+ }
+}
+
+
+/* t_openpw(NULL) is deprecated - use settpent()/gettpnam() instead */
+
+_TYPE( struct t_pw * )
+t_openpw(fp)
+ FILE * fp;
+{
+ struct t_pw * tpw;
+ char close_flag = 0;
+
+ if(fp == NULL) { /* Deprecated */
+ if((fp = fopen(DEFAULT_PASSWD, "r")) == NULL)
+ return NULL;
+ close_flag = 1;
+ }
+ else
+ close_flag = 0;
+
+ if((tpw = malloc(sizeof(struct t_pw))) == NULL)
+ return NULL;
+ tpw->instream = fp;
+ tpw->close_on_exit = close_flag;
+ tpw->state = FILE_ONLY;
+
+ return tpw;
+}
+
+_TYPE( struct t_pw * )
+t_openpwbyname(pwname)
+ const char * pwname;
+{
+ FILE * fp;
+ struct t_pw * t;
+
+ if(pwname == NULL) /* Deprecated */
+ return t_openpw(NULL);
+
+ if((fp = fopen(pwname, "r")) == NULL)
+ return NULL;
+
+ t = t_openpw(fp);
+ t->close_on_exit = 1;
+ return t;
+}
+
+_TYPE( void )
+t_closepw(tpw)
+ struct t_pw * tpw;
+{
+ if(tpw->close_on_exit)
+ fclose(tpw->instream);
+ free(tpw);
+}
+
+_TYPE( void )
+t_rewindpw(tpw)
+ struct t_pw * tpw;
+{
+#ifdef ENABLE_YP
+ if(tpw->state == IN_NIS)
+ tpw->state = FILE_NIS;
+#endif
+ rewind(tpw->instream);
+}
+
+#ifdef ENABLE_YP
+static void
+savepwent(tpw, pwent)
+ struct t_pw * tpw;
+ struct t_pwent *pwent;
+{
+ tpw->pebuf.name = tpw->userbuf;
+ tpw->pebuf.password.data = tpw->pwbuf;
+ tpw->pebuf.salt.data = tpw->saltbuf;
+ strcpy(tpw->pebuf.name, pwent->name);
+ tpw->pebuf.password.len = pwent->password.len;
+ memcpy(tpw->pebuf.password.data, pwent->password.data, pwent->password.len);
+ tpw->pebuf.salt.len = pwent->salt.len;
+ memcpy(tpw->pebuf.salt.data, pwent->salt.data, pwent->salt.len);
+ tpw->pebuf.index = pwent->index;
+}
+#endif /* ENABLE_YP */
+
+_TYPE( struct t_pwent * )
+t_getpwbyname(tpw, user)
+ struct t_pw * tpw;
+ const char * user;
+{
+ char indexbuf[16];
+ char passbuf[MAXB64PARAMLEN];
+ char saltstr[MAXB64SALTLEN];
+ char username[MAXUSERLEN];
+#ifdef ENABLE_YP
+ struct t_passwd * nisent;
+#endif
+
+ t_rewindpw(tpw);
+
+ while(t_nextfield(tpw->instream, username, MAXUSERLEN) > 0) {
+#ifdef ENABLE_YP
+ if(tpw->state == FILE_NIS && *username == '+') {
+ if(strlen(username) == 1 || strcmp(user, username+1) == 0) {
+ nisent = _yp_gettpnam(user); /* Entry is +username or + */
+ if(nisent != NULL) {
+ savepwent(tpw, &nisent->tp);
+ return &tpw->pebuf;
+ }
+ }
+ }
+#endif
+ if(strcmp(user, username) == 0)
+ if(t_nextfield(tpw->instream, passbuf, MAXB64PARAMLEN) > 0 &&
+ (tpw->pebuf.password.len = t_fromb64(tpw->pwbuf, passbuf)) > 0 &&
+ t_nextfield(tpw->instream, saltstr, MAXB64SALTLEN) > 0 &&
+ (tpw->pebuf.salt.len = t_fromb64(tpw->saltbuf, saltstr)) > 0 &&
+ t_nextfield(tpw->instream, indexbuf, 16) > 0 &&
+ (tpw->pebuf.index = atoi(indexbuf)) > 0) {
+ strcpy(tpw->userbuf, username);
+ tpw->pebuf.name = tpw->userbuf;
+ tpw->pebuf.password.data = tpw->pwbuf;
+ tpw->pebuf.salt.data = tpw->saltbuf;
+ t_nextline(tpw->instream);
+ return &tpw->pebuf;
+ }
+ if(t_nextline(tpw->instream) < 0)
+ return NULL;
+ }
+ return NULL;
+}
+
+/* System password file accessors */
+
+static int
+pwinit()
+{
+ if(syspw == NULL) {
+ if((syspw = t_openpwbyname(DEFAULT_PASSWD)) == NULL)
+ return -1;
+ syspw->state = FILE_NIS;
+ }
+ return 0;
+}
+
+static void
+pwsetup(out, tpwd, tcnf)
+ struct t_passwd * out;
+ struct t_pwent * tpwd;
+ struct t_confent * tcnf;
+{
+ out->tp.name = tpwd->name;
+ out->tp.password.len = tpwd->password.len;
+ out->tp.password.data = tpwd->password.data;
+ out->tp.salt.len = tpwd->salt.len;
+ out->tp.salt.data = tpwd->salt.data;
+ out->tp.index = tpwd->index;
+
+ out->tc.index = tcnf->index;
+ out->tc.modulus.len = tcnf->modulus.len;
+ out->tc.modulus.data = tcnf->modulus.data;
+ out->tc.generator.len = tcnf->generator.len;
+ out->tc.generator.data = tcnf->generator.data;
+}
+
+_TYPE( struct t_passwd * )
+gettpnam
+(user)
+ const char * user;
+{
+ struct t_pwent * tpptr;
+ struct t_confent * tcptr;
+
+ if(pwinit() < 0)
+ return NULL;
+ tpptr = t_getpwbyname(syspw, user);
+ if(tpptr == NULL)
+ return NULL;
+ tcptr =
+ gettcid
+ (tpptr->index);
+ if(tcptr == NULL)
+ return NULL;
+ pwsetup(&tpass, tpptr, tcptr);
+ return &tpass;
+}
diff --git a/package/network/services/ead/src/tinysrp/t_pwd.h b/package/network/services/ead/src/tinysrp/t_pwd.h
new file mode 100644
index 0000000..73697be
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/t_pwd.h
@@ -0,0 +1,310 @@
+/*
+ * Copyright (c) 1997-1999 The Stanford SRP Authentication Project
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF
+ * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * In addition, the following conditions apply:
+ *
+ * 1. Any software that incorporates the SRP authentication technology
+ * must display the following acknowlegment:
+ * "This product uses the 'Secure Remote Password' cryptographic
+ * authentication system developed by Tom Wu (tjw@CS.Stanford.EDU)."
+ *
+ * 2. Any software that incorporates all or part of the SRP distribution
+ * itself must also display the following acknowledgment:
+ * "This product includes software developed by Tom Wu and Eugene
+ * Jhong for the SRP Distribution (http://srp.stanford.edu/srp/)."
+ *
+ * 3. Redistributions in source or binary form must retain an intact copy
+ * of this copyright notice and list of conditions.
+ */
+
+#ifndef T_PWD_H
+#define T_PWD_H
+
+#ifndef P
+#if defined (__STDC__) || defined (__cplusplus)
+#define P(x) x
+#else
+#define P(x) ()
+#endif
+#endif
+
+/* For building dynamic link libraries under windows, windows NT
+ * using MSVC1.5 or MSVC2.0
+ */
+
+#ifndef _DLLDECL
+#define _DLLDECL
+
+#ifdef MSVC15 /* MSVC1.5 support for 16 bit apps */
+#define _MSVC15EXPORT _export
+#define _MSVC20EXPORT
+#define _DLLAPI _export _pascal
+#define _TYPE(a) a _MSVC15EXPORT
+#define DLLEXPORT 1
+
+#elif MSVC20
+#define _MSVC15EXPORT
+#define _MSVC20EXPORT _declspec(dllexport)
+#define _DLLAPI
+#define _TYPE(a) _MSVC20EXPORT a
+#define DLLEXPORT 1
+
+#else /* Default, non-dll. Use this for Unix or DOS */
+#define _MSVC15DEXPORT
+#define _MSVC20EXPORT
+#define _DLLAPI
+#define _TYPE(a) a
+#endif
+#endif
+
+#define MAXPARAMBITS 2048
+#define MAXPARAMLEN ((MAXPARAMBITS + 7) / 8)
+#define MAXB64PARAMLEN ((MAXPARAMBITS + 5) / 6 + 1)
+#define MAXHEXPARAMLEN ((MAXPARAMBITS + 3) / 4 + 1)
+#define MAXOCTPARAMLEN ((MAXPARAMBITS + 2) / 3 + 1)
+
+#define MAXUSERLEN 32
+#define MAXSALTLEN 32
+#define MAXB64SALTLEN 44 /* 256 bits in b64 + null */
+#define SALTLEN 10 /* Normally 80 bits */
+
+#define RESPONSE_LEN 20 /* 160-bit proof hashes */
+#define SESSION_KEY_LEN (2 * RESPONSE_LEN) /* 320-bit session key */
+
+#define DEFAULT_PASSWD "tpasswd"
+
+struct t_num { /* Standard byte-oriented integer representation */
+ int len;
+ unsigned char * data;
+};
+
+struct t_preconf { /* Structure returned by t_getpreparam() */
+ char * mod_b64;
+ char * gen_b64;
+ char * comment;
+
+ struct t_num modulus;
+ struct t_num generator;
+};
+
+/*
+ * The built-in (known good) parameters access routines
+ *
+ * "t_getprecount" returns the number of precompiled parameter sets.
+ * "t_getpreparam" returns the indicated parameter set.
+ * Memory is statically allocated - callers need not perform any memory mgmt.
+ */
+_TYPE( int ) t_getprecount();
+_TYPE( struct t_preconf * ) t_getpreparam P((int));
+
+struct t_confent { /* One configuration file entry (index, N, g) */
+ int index;
+ struct t_num modulus;
+ struct t_num generator;
+};
+
+struct t_conf { /* An open configuration file */
+ FILE * instream;
+ char close_on_exit;
+ unsigned char modbuf[MAXPARAMLEN];
+ unsigned char genbuf[MAXPARAMLEN];
+ struct t_confent tcbuf;
+};
+
+/*
+ * The configuration file routines are designed along the lines of the
+ * "getpw" functions in the standard C library.
+ *
+ * "t_openconf" accepts a stdio stream and interprets it as a config file.
+ * "t_openconfbyname" accepts a filename and does the same thing.
+ * "t_closeconf" closes the config file.
+ * "t_getconfent" fetches the next sequential configuration entry.
+ * "t_getconfbyindex" fetches the configuration entry whose index
+ * matches the one supplied, or NULL if one can't be found.
+ * "t_getconflast" fetches the last configuration entry in the file.
+ * "t_makeconfent" generates a set of configuration entry parameters
+ * randomly.
+ * "t_newconfent" returns an empty configuration entry.
+ * "t_cmpconfent" compares two configuration entries a la strcmp.
+ * "t_checkconfent" verifies that a set of configuration parameters
+ * are suitable. N must be prime and should be a safe prime.
+ * "t_putconfent" writes a configuration entry to a stream.
+ */
+_TYPE( struct t_conf * ) t_openconf P((FILE *));
+_TYPE( struct t_conf * ) t_openconfbyname P((const char *));
+_TYPE( void ) t_closeconf P((struct t_conf *));
+_TYPE( void ) t_rewindconf P((struct t_conf *));
+_TYPE( struct t_confent * ) t_getconfent P((struct t_conf *));
+_TYPE( struct t_confent * ) t_getconfbyindex P((struct t_conf *, int));
+_TYPE( struct t_confent * ) t_getconflast P((struct t_conf *));
+_TYPE( struct t_confent * ) t_makeconfent P((struct t_conf *, int));
+_TYPE( struct t_confent * ) t_makeconfent_c P((struct t_conf *, int));
+_TYPE( struct t_confent * ) t_newconfent P((struct t_conf *));
+_TYPE( int ) t_cmpconfent P((const struct t_confent *, const struct t_confent *));
+_TYPE( int ) t_checkconfent P((const struct t_confent *));
+_TYPE( void ) t_putconfent P((const struct t_confent *, FILE *));
+
+/* libc-style system conf file access */
+_TYPE( struct t_confent *) gettcent();
+_TYPE( struct t_confent *) gettcid P((int));
+_TYPE( void ) settcent();
+_TYPE( void ) endtcent();
+
+#ifdef ENABLE_NSW
+extern struct t_confent * _gettcent();
+extern struct t_confent * _gettcid P((int));
+extern void _settcent();
+extern void _endtcent();
+#endif
+
+/* A hack to support '+'-style entries in the passwd file */
+
+typedef enum fstate {
+ FILE_ONLY, /* Ordinary file, don't consult NIS ever */
+ FILE_NIS, /* Currently accessing file, use NIS if encountered */
+ IN_NIS, /* Currently in a '+' entry; use NIS for getXXent */
+} FILE_STATE;
+
+struct t_pwent { /* A single password file entry */
+ char * name;
+ struct t_num password;
+ struct t_num salt;
+ int index;
+};
+
+struct t_pw { /* An open password file */
+ FILE * instream;
+ char close_on_exit;
+ FILE_STATE state;
+ char userbuf[MAXUSERLEN];
+ unsigned char pwbuf[MAXPARAMLEN];
+ unsigned char saltbuf[SALTLEN];
+ struct t_pwent pebuf;
+};
+
+/*
+ * The password manipulation routines are patterned after the getpw*
+ * standard C library function calls.
+ *
+ * "t_openpw" reads a stream as if it were a password file.
+ * "t_openpwbyname" opens the named file as a password file.
+ * "t_closepw" closes an open password file.
+ * "t_rewindpw" starts the internal file pointer from the beginning
+ * of the password file.
+ * "t_getpwent" retrieves the next sequential password entry.
+ * "t_getpwbyname" looks up the password entry corresponding to the
+ * specified user.
+ * "t_makepwent" constructs a password entry from a username, password,
+ * numeric salt, and configuration entry.
+ * "t_putpwent" writes a password entry to a stream.
+ */
+_TYPE( struct t_pw * ) t_openpw P((FILE *));
+_TYPE( struct t_pw * ) t_openpwbyname P((const char *));
+_TYPE( void ) t_closepw P((struct t_pw *));
+_TYPE( void ) t_rewindpw P((struct t_pw *));
+_TYPE( struct t_pwent * ) t_getpwent P((struct t_pw *));
+_TYPE( struct t_pwent * ) t_getpwbyname P((struct t_pw *, const char *));
+_TYPE( struct t_pwent * ) t_makepwent P((struct t_pw *, const char *,
+ const char *, const struct t_num *,
+ const struct t_confent *));
+_TYPE( void ) t_putpwent P((const struct t_pwent *, FILE *));
+
+struct t_passwd {
+ struct t_pwent tp;
+ struct t_confent tc;
+};
+
+/* libc-style system password file access */
+_TYPE( struct t_passwd * ) gettpent();
+_TYPE( struct t_passwd * ) gettpnam P((const char *));
+_TYPE( void ) settpent();
+_TYPE( void ) endtpent();
+
+#ifdef ENABLE_NSW
+extern struct t_passwd * _gettpent();
+extern struct t_passwd * _gettpnam P((const char *));
+extern void _settpent();
+extern void _endtpent();
+#endif
+
+/*
+ * Utility functions
+ *
+ * "t_verifypw" accepts a username and password, and checks against the
+ * system password file to see if the password for that user is correct.
+ * Returns > 0 if it is correct, 0 if not, and -1 if some error occurred
+ * (i.e. the user doesn't exist on the system). This is intended ONLY
+ * for local authentication; for remote authentication, look at the
+ * t_client and t_server source. (That's the whole point of SRP!)
+ * "t_changepw" modifies the specified file, substituting the given password
+ * entry for the one already in the file. If no matching entry is found,
+ * the new entry is simply appended to the file.
+ * "t_deletepw" removes the specified user from the specified file.
+ */
+_TYPE( int ) t_verifypw P((const char *, const char *));
+_TYPE( int ) t_changepw P((const char *, const struct t_pwent *));
+_TYPE( int ) t_deletepw P((const char *, const char *));
+
+/* Conversion utilities */
+
+/*
+ * All these calls accept output as the first parameter. In the case of
+ * t_tohex and t_tob64, the last argument is the length of the byte-string
+ * input.
+ */
+_TYPE( char * t_tohex ) P((char *, char *, unsigned));
+_TYPE( int ) t_fromhex P((char *, char *));
+_TYPE( char * ) t_tob64 P((char *, char *, unsigned));
+_TYPE( int ) t_fromb64 P((char *, char *));
+
+/* Miscellaneous utilities */
+
+/*
+ * "t_random" is a cryptographic random number generator, which is seeded
+ * from various high-entropy sources and uses a one-way hash function
+ * in a feedback configuration.
+ * "t_sessionkey" is the interleaved hash used to generate session keys
+ * from a large integer.
+ * "t_getpass" reads a password from the terminal without echoing.
+ */
+_TYPE( void ) t_random P((unsigned char *, unsigned));
+_TYPE( void ) t_stronginitrand();
+_TYPE( unsigned char * )
+ t_sessionkey P((unsigned char *, unsigned char *, unsigned));
+_TYPE( int ) t_getpass P((char *, unsigned, const char *));
+
+/*
+ * Return value of t_checkprime:
+ * < 0 : not prime
+ * = 0 : prime, but not safe
+ * > 0 : safe
+ */
+#define NUM_NOTPRIME -1
+#define NUM_NOTSAFE 0
+#define NUM_SAFE 1
+
+_TYPE( int ) t_checkprime P((const struct t_num *));
+
+#endif
diff --git a/package/network/services/ead/src/tinysrp/t_read.c b/package/network/services/ead/src/tinysrp/t_read.c
new file mode 100644
index 0000000..087b7d5
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/t_read.c
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 1997-1999 The Stanford SRP Authentication Project
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF
+ * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * In addition, the following conditions apply:
+ *
+ * 1. Any software that incorporates the SRP authentication technology
+ * must display the following acknowlegment:
+ * "This product uses the 'Secure Remote Password' cryptographic
+ * authentication system developed by Tom Wu (tjw@CS.Stanford.EDU)."
+ *
+ * 2. Any software that incorporates all or part of the SRP distribution
+ * itself must also display the following acknowledgment:
+ * "This product includes software developed by Tom Wu and Eugene
+ * Jhong for the SRP Distribution (http://srp.stanford.edu/srp/)."
+ *
+ * 3. Redistributions in source or binary form must retain an intact copy
+ * of this copyright notice and list of conditions.
+ */
+
+#include <stdio.h>
+#include "config.h"
+
+#define FSEPARATOR ':'
+
+int
+t_nextfield(fp, s, max)
+FILE * fp;
+char * s;
+unsigned max;
+{
+ int c, count = 0;
+
+ while((c = getc(fp)) != EOF) {
+ if(c == '\n') {
+ ungetc(c, fp);
+ break;
+ }
+ else if(c == FSEPARATOR)
+ break;
+ if(count < max - 1) {
+ *s++ = c;
+ ++count;
+ }
+ }
+ *s++ = '\0';
+ return count;
+}
+
+int
+t_nextline(fp)
+FILE * fp;
+{
+ int c;
+
+ while((c = getc(fp)) != '\n')
+ if(c == EOF)
+ return -1;
+ return 0;
+}
diff --git a/package/network/services/ead/src/tinysrp/t_read.h b/package/network/services/ead/src/tinysrp/t_read.h
new file mode 100644
index 0000000..e621f79
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/t_read.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 1997-1999 The Stanford SRP Authentication Project
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF
+ * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * In addition, the following conditions apply:
+ *
+ * 1. Any software that incorporates the SRP authentication technology
+ * must display the following acknowlegment:
+ * "This product uses the 'Secure Remote Password' cryptographic
+ * authentication system developed by Tom Wu (tjw@CS.Stanford.EDU)."
+ *
+ * 2. Any software that incorporates all or part of the SRP distribution
+ * itself must also display the following acknowledgment:
+ * "This product includes software developed by Tom Wu and Eugene
+ * Jhong for the SRP Distribution (http://srp.stanford.edu/srp/)."
+ *
+ * 3. Redistributions in source or binary form must retain an intact copy
+ * of this copyright notice and list of conditions.
+ */
+
+#ifndef _T_READ_H_
+#define _T_READ_H_
+
+#if !defined(P)
+#ifdef __STDC__
+#define P(x) x
+#else
+#define P(x) ()
+#endif
+#endif
+
+extern int t_nextfield P((FILE *, char *, unsigned));
+extern int t_nextline P((FILE *));
+#endif
diff --git a/package/network/services/ead/src/tinysrp/t_server.c b/package/network/services/ead/src/tinysrp/t_server.c
new file mode 100644
index 0000000..6ab501b
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/t_server.c
@@ -0,0 +1,259 @@
+/*
+ * Copyright (c) 1997-1999 The Stanford SRP Authentication Project
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF
+ * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * In addition, the following conditions apply:
+ *
+ * 1. Any software that incorporates the SRP authentication technology
+ * must display the following acknowlegment:
+ * "This product uses the 'Secure Remote Password' cryptographic
+ * authentication system developed by Tom Wu (tjw@CS.Stanford.EDU)."
+ *
+ * 2. Any software that incorporates all or part of the SRP distribution
+ * itself must also display the following acknowledgment:
+ * "This product includes software developed by Tom Wu and Eugene
+ * Jhong for the SRP Distribution (http://srp.stanford.edu/srp/)."
+ *
+ * 3. Redistributions in source or binary form must retain an intact copy
+ * of this copyright notice and list of conditions.
+ */
+
+#include <stdio.h>
+#include "t_defines.h"
+#include "t_pwd.h"
+#include "t_server.h"
+
+_TYPE( struct t_server * )
+t_serveropenraw(ent, tce)
+ struct t_pwent * ent;
+ struct t_confent * tce;
+{
+ struct t_server * ts;
+ unsigned char buf1[SHA_DIGESTSIZE], buf2[SHA_DIGESTSIZE];
+ SHA1_CTX ctxt;
+ int i;
+
+ if((ts = malloc(sizeof(struct t_server))) == 0)
+ return 0;
+
+ SHA1Init(&ts->ckhash);
+
+ ts->index = ent->index;
+ ts->n.len = tce->modulus.len;
+ ts->n.data = ts->nbuf;
+ memcpy(ts->n.data, tce->modulus.data, ts->n.len);
+
+ SHA1Init(&ctxt);
+ SHA1Update(&ctxt, ts->n.data, ts->n.len);
+ SHA1Final(buf1, &ctxt);
+
+ ts->g.len = tce->generator.len;
+ ts->g.data = ts->gbuf;
+ memcpy(ts->g.data, tce->generator.data, ts->g.len);
+
+ SHA1Init(&ctxt);
+ SHA1Update(&ctxt, ts->g.data, ts->g.len);
+ SHA1Final(buf2, &ctxt);
+
+ for(i = 0; i < sizeof(buf1); ++i)
+ buf1[i] ^= buf2[i];
+
+ SHA1Update(&ts->ckhash, buf1, sizeof(buf1));
+
+ SHA1Init(&ctxt);
+ SHA1Update(&ctxt, ent->name, strlen(ent->name));
+ SHA1Final(buf1, &ctxt);
+
+ SHA1Update(&ts->ckhash, buf1, sizeof(buf1));
+
+ ts->v.len = ent->password.len;
+ ts->v.data = ts->vbuf;
+ memcpy(ts->v.data, ent->password.data, ts->v.len);
+
+ ts->s.len = ent->salt.len;
+ ts->s.data = ts->saltbuf;
+ memcpy(ts->s.data, ent->salt.data, ts->s.len);
+
+ SHA1Update(&ts->ckhash, ts->s.data, ts->s.len);
+
+ ts->b.data = ts->bbuf;
+ ts->B.data = ts->Bbuf;
+
+ SHA1Init(&ts->hash);
+ SHA1Init(&ts->oldhash);
+ SHA1Init(&ts->oldckhash);
+
+ return ts;
+}
+
+_TYPE( struct t_num * )
+t_servergenexp(ts)
+ struct t_server * ts;
+{
+ BigInteger b, B, v, n, g;
+
+ if(ts->n.len < BLEN)
+ ts->b.len = ts->n.len;
+ else
+ ts->b.len = BLEN;
+
+ t_random(ts->b.data, ts->b.len);
+ b = BigIntegerFromBytes(ts->b.data, ts->b.len);
+ n = BigIntegerFromBytes(ts->n.data, ts->n.len);
+ g = BigIntegerFromBytes(ts->g.data, ts->g.len);
+ B = BigIntegerFromInt(0);
+ BigIntegerModExp(B, g, b, n);
+
+ v = BigIntegerFromBytes(ts->v.data, ts->v.len);
+ BigIntegerAdd(B, B, v);
+ if(BigIntegerCmp(B, n) > 0)
+ BigIntegerSub(B, B, n);
+
+ ts->B.len = BigIntegerToBytes(B, ts->B.data);
+
+ BigIntegerFree(v);
+ BigIntegerFree(B);
+ BigIntegerFree(b);
+ BigIntegerFree(g);
+ BigIntegerFree(n);
+
+ SHA1Update(&ts->oldckhash, ts->B.data, ts->B.len);
+
+ return &ts->B;
+}
+
+_TYPE( unsigned char * )
+t_servergetkey(ts, clientval)
+ struct t_server * ts;
+ struct t_num * clientval;
+{
+ BigInteger n, v, A, b, prod, res, S;
+ SHA1_CTX ctxt;
+ unsigned char sbuf[MAXPARAMLEN];
+ unsigned char dig[SHA_DIGESTSIZE];
+ unsigned slen;
+ unsigned int u;
+
+ SHA1Update(&ts->ckhash, clientval->data, clientval->len);
+ SHA1Update(&ts->ckhash, ts->B.data, ts->B.len);
+
+ SHA1Init(&ctxt);
+ SHA1Update(&ctxt, ts->B.data, ts->B.len);
+ SHA1Final(dig, &ctxt);
+ u = (dig[0] << 24) | (dig[1] << 16) | (dig[2] << 8) | dig[3];
+
+ SHA1Update(&ts->oldhash, clientval->data, clientval->len);
+ SHA1Update(&ts->hash, clientval->data, clientval->len);
+
+ n = BigIntegerFromBytes(ts->n.data, ts->n.len);
+ b = BigIntegerFromBytes(ts->b.data, ts->b.len);
+ v = BigIntegerFromBytes(ts->v.data, ts->v.len);
+ A = BigIntegerFromBytes(clientval->data, clientval->len);
+
+ prod = BigIntegerFromInt(0);
+ BigIntegerModExpInt(prod, v, u, n);
+ res = BigIntegerFromInt(0);
+ BigIntegerModMul(res, prod, A, n);
+
+ BigIntegerFree(A);
+ BigIntegerFree(v);
+ BigIntegerFree(prod);
+
+ if(BigIntegerCmpInt(res, 1) <= 0) { /* Check for Av^u == 1 (mod n) */
+ BigIntegerFree(res);
+ BigIntegerFree(b);
+ BigIntegerFree(n);
+ return NULL;
+ }
+
+ S = BigIntegerFromInt(0);
+
+ BigIntegerAddInt(S, res, 1);
+ if(BigIntegerCmp(S, n) == 0) { /* Check for Av^u == -1 (mod n) */
+ BigIntegerFree(res);
+ BigIntegerFree(b);
+ BigIntegerFree(n);
+ BigIntegerFree(S);
+ return NULL;
+ }
+
+ BigIntegerModExp(S, res, b, n);
+ slen = BigIntegerToBytes(S, sbuf);
+
+ BigIntegerFree(S);
+ BigIntegerFree(res);
+ BigIntegerFree(b);
+ BigIntegerFree(n);
+
+ t_sessionkey(ts->session_key, sbuf, slen);
+ memset(sbuf, 0, slen);
+
+ SHA1Update(&ts->oldhash, ts->session_key, sizeof(ts->session_key));
+ SHA1Update(&ts->oldckhash, ts->session_key, sizeof(ts->session_key));
+ SHA1Update(&ts->ckhash, ts->session_key, sizeof(ts->session_key));
+
+ return ts->session_key;
+}
+
+_TYPE( int )
+t_serververify(ts, resp)
+ struct t_server * ts;
+ unsigned char * resp;
+{
+ unsigned char expected[SHA_DIGESTSIZE];
+ int i;
+
+ SHA1Final(expected, &ts->oldckhash);
+ i = memcmp(expected, resp, sizeof(expected));
+ if(i == 0) {
+ SHA1Final(ts->session_response, &ts->oldhash);
+ return 0;
+ }
+ SHA1Final(expected, &ts->ckhash);
+ i = memcmp(expected, resp, sizeof(expected));
+ if(i == 0) {
+ SHA1Update(&ts->hash, expected, sizeof(expected));
+ SHA1Update(&ts->hash, ts->session_key, sizeof(ts->session_key));
+ SHA1Final(ts->session_response, &ts->hash);
+ }
+ return i;
+}
+
+_TYPE( unsigned char * )
+t_serverresponse(ts)
+ struct t_server * ts;
+{
+ return ts->session_response;
+}
+
+_TYPE( void )
+t_serverclose(ts)
+ struct t_server * ts;
+{
+ memset(ts->bbuf, 0, sizeof(ts->bbuf));
+ memset(ts->vbuf, 0, sizeof(ts->vbuf));
+ memset(ts->saltbuf, 0, sizeof(ts->saltbuf));
+ memset(ts->session_key, 0, sizeof(ts->session_key));
+ free(ts);
+}
diff --git a/package/network/services/ead/src/tinysrp/t_server.h b/package/network/services/ead/src/tinysrp/t_server.h
new file mode 100644
index 0000000..20970ff
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/t_server.h
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 1997-1999 The Stanford SRP Authentication Project
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF
+ * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * In addition, the following conditions apply:
+ *
+ * 1. Any software that incorporates the SRP authentication technology
+ * must display the following acknowlegment:
+ * "This product uses the 'Secure Remote Password' cryptographic
+ * authentication system developed by Tom Wu (tjw@CS.Stanford.EDU)."
+ *
+ * 2. Any software that incorporates all or part of the SRP distribution
+ * itself must also display the following acknowledgment:
+ * "This product includes software developed by Tom Wu and Eugene
+ * Jhong for the SRP Distribution (http://srp.stanford.edu/srp/)."
+ *
+ * 3. Redistributions in source or binary form must retain an intact copy
+ * of this copyright notice and list of conditions.
+ */
+
+#ifndef T_SERVER_H
+#define T_SERVER_H
+
+#include "t_sha.h"
+
+#if !defined(P)
+#ifdef __STDC__
+#define P(x) x
+#else
+#define P(x) ()
+#endif
+#endif
+
+#ifndef _DLLDECL
+#define _DLLDECL
+
+#ifdef MSVC15 /* MSVC1.5 support for 16 bit apps */
+#define _MSVC15EXPORT _export
+#define _MSVC20EXPORT
+#define _DLLAPI _export _pascal
+#define _TYPE(a) a _MSVC15EXPORT
+#define DLLEXPORT 1
+
+#elif MSVC20
+#define _MSVC15EXPORT
+#define _MSVC20EXPORT _declspec(dllexport)
+#define _DLLAPI
+#define _TYPE(a) _MSVC20EXPORT a
+#define DLLEXPORT 1
+
+#else /* Default, non-dll. Use this for Unix or DOS */
+#define _MSVC15DEXPORT
+#define _MSVC20EXPORT
+#define _DLLAPI
+#define _TYPE(a) a
+#endif
+#endif
+
+#define BLEN 32
+
+struct t_server {
+ int index;
+ struct t_num n;
+ struct t_num g;
+ struct t_num v;
+ struct t_num s;
+
+ struct t_num b;
+ struct t_num B;
+
+ SHA1_CTX oldhash, hash, oldckhash, ckhash;
+
+ unsigned char session_key[SESSION_KEY_LEN];
+ unsigned char session_response[RESPONSE_LEN];
+
+ unsigned char nbuf[MAXPARAMLEN], gbuf[MAXPARAMLEN], vbuf[MAXPARAMLEN];
+ unsigned char saltbuf[MAXSALTLEN], bbuf[BLEN], Bbuf[MAXPARAMLEN];
+};
+
+/*
+ * SRP server-side negotiation
+ *
+ * This code negotiates the server side of an SRP exchange.
+ * "t_serveropen" accepts a username (sent by the client), a pointer
+ * to an open password file, and a pointer to an open configuration
+ * file. The server should then call...
+ * "t_servergenexp" will generate a random 256-bit exponent and
+ * raise g (from the configuration file) to that power, returning
+ * the result. This result should be sent to the client as y(p).
+ * "t_servergetkey" accepts the exponential w(p), which should be
+ * sent by the client, and computes the 256-bit session key.
+ * This data should be saved before the session is closed.
+ * "t_serverresponse" computes the session key proof as SHA(w(p), K).
+ * "t_serverclose" closes the session and frees its memory.
+ *
+ * Note that authentication is not performed per se; it is up
+ * to either/both sides of the protocol to now verify securely
+ * that their session keys agree in order to establish authenticity.
+ * One possible way is through "oracle hashing"; one side sends
+ * r, the other replies with H(r,K), where H() is a hash function.
+ *
+ * t_serverresponse and t_serververify now implement a version of
+ * the session-key verification described above.
+ */
+_TYPE( struct t_server * )
+ t_serveropen P((const char *));
+_TYPE( struct t_server * )
+ t_serveropenfromfiles P((const char *, struct t_pw *, struct t_conf *));
+_TYPE( struct t_server * )
+ t_serveropenraw P((struct t_pwent *, struct t_confent *));
+_TYPE( struct t_num * ) t_servergenexp P((struct t_server *));
+_TYPE( unsigned char * ) t_servergetkey P((struct t_server *, struct t_num *));
+_TYPE( int ) t_serververify P((struct t_server *, unsigned char *));
+_TYPE( unsigned char * ) t_serverresponse P((struct t_server *));
+_TYPE( void ) t_serverclose P((struct t_server *));
+
+#endif
diff --git a/package/network/services/ead/src/tinysrp/t_sha.c b/package/network/services/ead/src/tinysrp/t_sha.c
new file mode 100644
index 0000000..cc41d64
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/t_sha.c
@@ -0,0 +1,166 @@
+#include "t_defines.h"
+#include "t_sha.h"
+
+/*
+SHA-1 in C
+By Steve Reid <steve@edmweb.com>
+100% Public Domain
+
+Test Vectors (from FIPS PUB 180-1)
+"abc"
+ A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D
+"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
+ 84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1
+A million repetitions of "a"
+ 34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F
+*/
+
+/* #define WORDS_BIGENDIAN * This should be #define'd if true. */
+/* #define SHA1HANDSOFF * Copies data before messing with it. */
+
+#include <stdio.h>
+#include <string.h>
+
+static void SHA1Transform(uint32 state[5], const unsigned char buffer[64]);
+
+#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
+
+/* blk0() and blk() perform the initial expand. */
+/* I got the idea of expanding during the round function from SSLeay */
+#ifndef WORDS_BIGENDIAN
+#define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \
+ |(rol(block->l[i],8)&0x00FF00FF))
+#else
+#define blk0(i) block->l[i]
+#endif
+#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
+ ^block->l[(i+2)&15]^block->l[i&15],1))
+
+/* (R0+R1), R2, R3, R4 are the different operations used in SHA1 */
+#define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
+#define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30);
+#define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
+#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
+#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
+
+/* Hash a single 512-bit block. This is the core of the algorithm. */
+
+static void SHA1Transform(uint32 state[5], const unsigned char buffer[64])
+{
+uint32 a, b, c, d, e;
+typedef union {
+ unsigned char c[64];
+ uint32 l[16];
+} CHAR64LONG16;
+CHAR64LONG16* block;
+#ifdef SHA1HANDSOFF
+static unsigned char workspace[64];
+ block = (CHAR64LONG16*)workspace;
+ memcpy(block, buffer, 64);
+#else
+ block = (CHAR64LONG16*)buffer;
+#endif
+ /* Copy context->state[] to working vars */
+ a = state[0];
+ b = state[1];
+ c = state[2];
+ d = state[3];
+ e = state[4];
+ /* 4 rounds of 20 operations each. Loop unrolled. */
+ R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3);
+ R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7);
+ R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11);
+ R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15);
+ R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19);
+ R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23);
+ R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27);
+ R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31);
+ R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35);
+ R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39);
+ R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43);
+ R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47);
+ R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51);
+ R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55);
+ R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59);
+ R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63);
+ R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67);
+ R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71);
+ R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75);
+ R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79);
+ /* Add the working vars back into context.state[] */
+ state[0] += a;
+ state[1] += b;
+ state[2] += c;
+ state[3] += d;
+ state[4] += e;
+ /* Wipe variables */
+ a = b = c = d = e = 0;
+}
+
+
+/* SHA1Init - Initialize new context */
+
+void SHA1Init(SHA1_CTX* context)
+{
+ /* SHA1 initialization constants */
+ context->state[0] = 0x67452301;
+ context->state[1] = 0xEFCDAB89;
+ context->state[2] = 0x98BADCFE;
+ context->state[3] = 0x10325476;
+ context->state[4] = 0xC3D2E1F0;
+ context->count[0] = context->count[1] = 0;
+}
+
+
+/* Run your data through this. */
+
+void SHA1Update(SHA1_CTX* context, const unsigned char* data, unsigned int len)
+{
+unsigned int i, j;
+
+ j = (context->count[0] >> 3) & 63;
+ if ((context->count[0] += len << 3) < (len << 3)) context->count[1]++;
+ context->count[1] += (len >> 29);
+ if ((j + len) > 63) {
+ memcpy(&context->buffer[j], data, (i = 64-j));
+ SHA1Transform(context->state, context->buffer);
+ for ( ; i + 63 < len; i += 64) {
+ SHA1Transform(context->state, &data[i]);
+ }
+ j = 0;
+ }
+ else i = 0;
+ memcpy(&context->buffer[j], &data[i], len - i);
+}
+
+
+/* Add padding and return the message digest. */
+
+void SHA1Final(unsigned char digest[20], SHA1_CTX* context)
+{
+uint32 i, j;
+unsigned char finalcount[8];
+
+ for (i = 0; i < 8; i++) {
+ finalcount[i] = (unsigned char)((context->count[(i >= 4 ? 0 : 1)]
+ >> ((3-(i & 3)) * 8) ) & 255); /* Endian independent */
+ }
+ SHA1Update(context, (unsigned char *)"\200", 1);
+ while ((context->count[0] & 504) != 448) {
+ SHA1Update(context, (unsigned char *)"\0", 1);
+ }
+ SHA1Update(context, finalcount, 8); /* Should cause a SHA1Transform() */
+ for (i = 0; i < 20; i++) {
+ digest[i] = (unsigned char)
+ ((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255);
+ }
+ /* Wipe variables */
+ i = j = 0;
+ memset(context->buffer, 0, 64);
+ memset(context->state, 0, 20);
+ memset(context->count, 0, 8);
+ memset(&finalcount, 0, 8);
+#ifdef SHA1HANDSOFF /* make SHA1Transform overwrite its own static vars */
+ SHA1Transform(context->state, context->buffer);
+#endif
+}
diff --git a/package/network/services/ead/src/tinysrp/t_sha.h b/package/network/services/ead/src/tinysrp/t_sha.h
new file mode 100644
index 0000000..d10115e
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/t_sha.h
@@ -0,0 +1,26 @@
+#ifndef T_SHA_H
+#define T_SHA_H
+
+#if !defined(P)
+#ifdef __STDC__
+#define P(x) x
+#else
+#define P(x) ()
+#endif
+#endif
+
+#define SHA_DIGESTSIZE 20
+
+typedef unsigned int uint32;
+
+typedef struct {
+ uint32 state[5];
+ uint32 count[2];
+ unsigned char buffer[64];
+} SHA1_CTX;
+
+void SHA1Init P((SHA1_CTX* context));
+void SHA1Update P((SHA1_CTX* context, const unsigned char* data, unsigned int len));
+void SHA1Final P((unsigned char digest[20], SHA1_CTX* context));
+
+#endif /* T_SHA_H */
diff --git a/package/network/services/ead/src/tinysrp/t_truerand.c b/package/network/services/ead/src/tinysrp/t_truerand.c
new file mode 100644
index 0000000..fa0d6ce
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/t_truerand.c
@@ -0,0 +1,151 @@
+/*
+ * Physically random numbers (very nearly uniform)
+ * D. P. Mitchell
+ * Modified by Matt Blaze 7/95
+ */
+/*
+ * The authors of this software are Don Mitchell and Matt Blaze.
+ * Copyright (c) 1995 by AT&T.
+ * Permission to use, copy, and modify this software without fee
+ * is hereby granted, provided that this entire notice is included in
+ * all copies of any software which is or includes a copy or
+ * modification of this software and in all copies of the supporting
+ * documentation for such software.
+ *
+ * This software may be subject to United States export controls.
+ *
+ * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR AT&T MAKE ANY
+ * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
+ * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
+ */
+
+/*
+ * WARNING: depending on the particular platform, raw_truerand()
+ * output may be biased or correlated. In general, you can expect
+ * about 16 bits of "pseudo-entropy" out of each 32 bit word returned
+ * by truerand(), but it may not be uniformly diffused. You should
+ * raw_therefore run the output through some post-whitening function
+ * (like MD5 or DES or whatever) before using it to generate key
+ * material. (RSAREF's random package does this for you when you feed
+ * raw_truerand() bits to the seed input function.)
+ *
+ * The application interface, for 8, 16, and 32 bit properly "whitened"
+ * random numbers, can be found in trand8(), trand16(), and trand32().
+ * Use those instead of calling raw_truerand() directly.
+ *
+ * The basic idea here is that between clock "skew" and various
+ * hard-to-predict OS event arrivals, counting a tight loop will yield
+ * a little (maybe a third of a bit or so) of "good" randomness per
+ * interval clock tick. This seems to work well even on unloaded
+ * machines. If there is a human operator at the machine, you should
+ * augment truerand with other measure, like keyboard event timing.
+ * On server machines (e.g., when you need to generate a
+ * Diffie-Hellman secret) truerand alone may be good enough.
+ *
+ * Test these assumptions on your own platform before fielding a
+ * system based on this software or these techniques.
+ *
+ * This software seems to work well (at 10 or so bits per
+ * raw_truerand() call) on a Sun Sparc-20 under SunOS 4.1.3 and on a
+ * P100 under BSDI 2.0. You're on your own elsewhere.
+ *
+ */
+
+#include "t_defines.h"
+
+#include <signal.h>
+#include <setjmp.h>
+#include <sys/time.h>
+#include <math.h>
+#include <stdio.h>
+
+#ifdef OLD_TRUERAND
+static jmp_buf env;
+#endif
+static unsigned volatile count
+#ifndef OLD_TRUERAND
+ , done = 0
+#endif
+;
+
+static unsigned ocount;
+static unsigned buffer;
+
+static void
+tick()
+{
+ struct itimerval it, oit;
+
+ it.it_interval.tv_sec = 0;
+ it.it_interval.tv_usec = 0;
+ it.it_value.tv_sec = 0;
+ it.it_value.tv_usec = 16665;
+ if (setitimer(ITIMER_REAL, &it, &oit) < 0)
+ perror("tick");
+}
+
+static void
+interrupt()
+{
+ if (count) {
+#ifdef OLD_TRUERAND
+ longjmp(env, 1);
+#else
+ ++done;
+ return;
+#endif
+ }
+
+ (void) signal(SIGALRM, interrupt);
+ tick();
+}
+
+static unsigned long
+roulette()
+{
+#ifdef OLD_TRUERAND
+ if (setjmp(env)) {
+ count ^= (count>>3) ^ (count>>6) ^ ocount;
+ count &= 0x7;
+ ocount=count;
+ buffer = (buffer<<3) ^ count;
+ return buffer;
+ }
+#else
+ done = 0;
+#endif
+ (void) signal(SIGALRM, interrupt);
+ count = 0;
+ tick();
+#ifdef OLD_TRUERAND
+ for (;;)
+#else
+ while(done == 0)
+#endif
+ count++; /* about 1 MHz on VAX 11/780 */
+#ifndef OLD_TRUERAND
+ count ^= (count>>3) ^ (count>>6) ^ ocount;
+ count &= 0x7;
+ ocount=count;
+ buffer = (buffer<<3) ^ count;
+ return buffer;
+#endif
+}
+
+unsigned long
+raw_truerand()
+{
+ count=0;
+ (void) roulette();
+ (void) roulette();
+ (void) roulette();
+ (void) roulette();
+ (void) roulette();
+ (void) roulette();
+ (void) roulette();
+ (void) roulette();
+ (void) roulette();
+ (void) roulette();
+ return roulette();
+}
diff --git a/package/network/services/ead/src/tinysrp/tconf.c b/package/network/services/ead/src/tinysrp/tconf.c
new file mode 100644
index 0000000..ad77f4c
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/tconf.c
@@ -0,0 +1,157 @@
+/*
+ * Copyright (c) 1997-2000 The Stanford SRP Authentication Project
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF
+ * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * In addition, the following conditions apply:
+ *
+ * 1. Any software that incorporates the SRP authentication technology
+ * must display the following acknowlegment:
+ * "This product uses the 'Secure Remote Password' cryptographic
+ * authentication system developed by Tom Wu (tjw@CS.Stanford.EDU)."
+ *
+ * 2. Any software that incorporates all or part of the SRP distribution
+ * itself must also display the following acknowledgment:
+ * "This product includes software developed by Tom Wu and Eugene
+ * Jhong for the SRP Distribution (http://srp.stanford.edu/srp/)."
+ *
+ * 3. Redistributions in source or binary form must retain an intact copy
+ * of this copyright notice and list of conditions.
+ */
+
+#include <unistd.h> /* close getlogin */
+#include <stdlib.h> /* atexit exit */
+#include <stdio.h>
+#include <string.h>
+
+#include "t_pwd.h"
+
+#define MIN_BASIS_BITS 512
+#define BASIS_BITS 2048
+
+extern int optind;
+extern char *optarg;
+
+extern int errno;
+
+char *progName;
+
+int debug = 0;
+int verbose = 0;
+int composite = 0;
+
+int main(argc, argv)
+ int argc;
+ char *argv[];
+{
+ char *chp;
+ char *configFile = NULL;
+ char cbuf[256];
+ char b64buf[MAXB64PARAMLEN];
+ int c, ch, i, lastidx, keylen, yesno, fsize, status, nparams;
+ FILE *efp;
+
+ struct t_preconf * tpc;
+ struct t_conf tcs;
+ struct t_conf * tc = &tcs;
+ struct t_confent * tcent;
+
+ progName = *argv;
+ if ((chp = strrchr(progName, '/')) != (char *) 0) progName = chp + 1;
+
+ while ((ch = getopt(argc, argv, "dv2c:")) != EOF)
+ switch(ch) {
+ case 'c':
+ configFile = optarg;
+ break;
+ case 'v':
+ verbose++;
+ break;
+ case 'd':
+ debug++;
+ break;
+ case '2':
+ composite++;
+ break;
+ default:
+ fprintf(stderr, "usage: %s [-dv2] [-c configfile]\n", progName);
+ exit(1);
+ }
+
+ argc -= optind;
+ argv += optind;
+
+ lastidx = 0;
+ keylen = 0;
+
+ tcent = t_newconfent(tc);
+
+ printf("\nThis program will generate a set of parameters for the EPS\n");
+ printf("password file. The size of these parameters, measured in bits,\n");
+ printf("determines the level of security offered by SRP, and is related\n");
+ printf("to the security of similarly-sized RSA or Diffie-Hellman keys.\n");
+ printf("Choosing a predefined field is generally preferable to generating\n");
+ printf("a new field because clients can avoid costly parameter verification.\n");
+ printf("Either way, the values generated by this program are public and\n");
+ printf("can even shared between systems.\n");
+
+ printf("\nEnter the new field size, in bits. Suggested sizes:\n\n");
+ printf(" 512 (fast, minimally secure)\n");
+ printf(" 768 (moderate security)\n");
+ printf("1024 (most popular default)\n");
+ printf("1536 (additional security, possibly slow)\n");
+ printf("2048 (maximum supported security level)\n");
+ printf("\nField size (%d to %d): ", MIN_BASIS_BITS, BASIS_BITS);
+
+ fgets(cbuf, sizeof(cbuf), stdin);
+ fsize = atoi(cbuf);
+ if(fsize < MIN_BASIS_BITS || fsize > BASIS_BITS) {
+ fprintf(stderr, "%s: field size must be between %d and %d\n",
+ progName, MIN_BASIS_BITS, BASIS_BITS);
+ exit(1);
+ }
+
+ if(fsize <= keylen)
+ fprintf(stderr, "Warning: new field size is not larger than old field size\n");
+
+ printf("\nInitializing random number generator...");
+ fflush(stdout);
+ t_initrand();
+
+ if(composite)
+ printf("done.\n\nGenerating a %d-bit composite with safe prime factors. This may take a while.\n", fsize);
+ else
+ printf("done.\n\nGenerating a %d-bit safe prime. This may take a while.\n", fsize);
+
+ while((tcent = (composite ? t_makeconfent_c(tc, fsize) :
+ t_makeconfent(tc, fsize))) == NULL)
+ printf("Parameter generation failed, retrying...\n");
+ tcent->index = lastidx + 1;
+
+ printf("\nParameters successfully generated.\n");
+ printf("N = [%s]\n", t_tob64(b64buf,
+ tcent->modulus.data, tcent->modulus.len));
+ printf("g = [%s]\n", t_tob64(b64buf,
+ tcent->generator.data, tcent->generator.len));
+ printf("\nYou must update the pre_params array in t_getconf.c\n");
+}
diff --git a/package/network/services/ead/src/tinysrp/tinysrp.c b/package/network/services/ead/src/tinysrp/tinysrp.c
new file mode 100644
index 0000000..fc01055
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/tinysrp.c
@@ -0,0 +1,235 @@
+/* This bit implements a simple API for using the SRP library over sockets. */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include "t_defines.h"
+#include "t_pwd.h"
+#include "t_server.h"
+#include "t_client.h"
+#include "tinysrp.h"
+
+#ifndef MSG_WAITALL
+#ifdef linux
+#define MSG_WAITALL 0x100 /* somehow not defined on my box */
+#endif
+#endif
+
+/* This is called by the client with a connected socket, username, and
+passphrase. pass can be NULL in which case the user is queried. */
+
+int tsrp_client_authenticate(int s, char *user, char *pass, TSRP_SESSION *tsrp)
+{
+ int i, index;
+ unsigned char username[MAXUSERLEN + 1], sbuf[MAXSALTLEN];
+ unsigned char msgbuf[MAXPARAMLEN + 1], bbuf[MAXPARAMLEN];
+ unsigned char passbuf[128], *skey;
+ struct t_client *tc;
+ struct t_preconf *tcp; /* @@@ should go away */
+ struct t_num salt, *A, B;
+
+ /* Send the username. */
+
+ i = strlen(user);
+ if (i > MAXUSERLEN) {
+ i = MAXUSERLEN;
+ }
+ msgbuf[0] = i;
+ memcpy(msgbuf + 1, user, i);
+ if (send(s, msgbuf, i + 1, 0) < 0) {
+ return 0;
+ }
+ memcpy(username, user, i);
+ username[i] = '\0';
+
+ /* Get the prime index and salt. */
+
+ i = recv(s, msgbuf, 2, MSG_WAITALL);
+ if (i <= 0) {
+ return 0;
+ }
+ index = msgbuf[0];
+ if (index <= 0 || index > t_getprecount()) {
+ return 0;
+ }
+ tcp = t_getpreparam(index - 1);
+ salt.len = msgbuf[1];
+ if (salt.len > MAXSALTLEN) {
+ return 0;
+ }
+ salt.data = sbuf;
+ i = recv(s, sbuf, salt.len, MSG_WAITALL);
+ if (i <= 0) {
+ return 0;
+ }
+
+ /* @@@ t_clientopen() needs a variant that takes the index */
+
+ tc = t_clientopen(username, &tcp->modulus, &tcp->generator, &salt);
+ if (tc == NULL) {
+ return 0;
+ }
+
+ /* Calculate A and send it to the server. */
+
+ A = t_clientgenexp(tc);
+ msgbuf[0] = A->len - 1; /* len is max 256 */
+ memcpy(msgbuf + 1, A->data, A->len);
+ if (send(s, msgbuf, A->len + 1, 0) < 0) {
+ return 0;
+ }
+
+ /* Ask the user for the passphrase. */
+
+ if (pass == NULL) {
+ t_getpass(passbuf, sizeof(passbuf), "Enter password:");
+ pass = passbuf;
+ }
+ t_clientpasswd(tc, pass);
+
+ /* Get B from the server. */
+
+ i = recv(s, msgbuf, 1, 0);
+ if (i <= 0) {
+ return 0;
+ }
+ B.len = msgbuf[0] + 1;
+ B.data = bbuf;
+ i = recv(s, bbuf, B.len, MSG_WAITALL);
+ if (i <= 0) {
+ return 0;
+ }
+
+ /* Compute the session key. */
+
+ skey = t_clientgetkey(tc, &B);
+ if (skey == NULL) {
+ return 0;
+ }
+
+ /* Send the response. */
+
+ if (send(s, t_clientresponse(tc), RESPONSE_LEN, 0) < 0) {
+ return 0;
+ }
+
+ /* Get the server's response. */
+
+ i = recv(s, msgbuf, RESPONSE_LEN, MSG_WAITALL);
+ if (i <= 0) {
+ return 0;
+ }
+ if (t_clientverify(tc, msgbuf) != 0) {
+ return 0;
+ }
+
+ /* All done. Now copy the key and clean up. */
+
+ if (tsrp) {
+ memcpy(tsrp->username, username, strlen(username) + 1);
+ memcpy(tsrp->key, skey, SESSION_KEY_LEN);
+ }
+ t_clientclose(tc);
+
+ return 1;
+}
+
+/* This is called by the server with a connected socket. */
+
+int tsrp_server_authenticate(int s, TSRP_SESSION *tsrp)
+{
+ int i, j;
+ unsigned char username[MAXUSERLEN], *skey;
+ unsigned char msgbuf[MAXPARAMLEN + 1], abuf[MAXPARAMLEN];
+ struct t_server *ts;
+ struct t_num A, *B;
+
+ /* Get the username. */
+
+ i = recv(s, msgbuf, 1, 0);
+ if (i <= 0) {
+ return 0;
+ }
+ j = msgbuf[0];
+ i = recv(s, username, j, MSG_WAITALL);
+ if (i <= 0) {
+ return 0;
+ }
+ username[j] = '\0';
+
+ ts = t_serveropen(username);
+ if (ts == NULL) {
+ return 0;
+ }
+
+ /* Send the prime index and the salt. */
+
+ msgbuf[0] = ts->index; /* max 256 primes... */
+ i = ts->s.len;
+ msgbuf[1] = i;
+ memcpy(msgbuf + 2, ts->s.data, i);
+ if (send(s, msgbuf, i + 2, 0) < 0) {
+ return 0;
+ }
+
+ /* Calculate B while we're waiting. */
+
+ B = t_servergenexp(ts);
+
+ /* Get A from the client. */
+
+ i = recv(s, msgbuf, 1, 0);
+ if (i <= 0) {
+ return 0;
+ }
+ A.len = msgbuf[0] + 1;
+ A.data = abuf;
+ i = recv(s, abuf, A.len, MSG_WAITALL);
+ if (i <= 0) {
+ return 0;
+ }
+
+ /* Now send B. */
+
+ msgbuf[0] = B->len - 1;
+ memcpy(msgbuf + 1, B->data, B->len);
+ if (send(s, msgbuf, B->len + 1, 0) < 0) {
+ return 0;
+ }
+
+ /* Calculate the session key while we're waiting. */
+
+ skey = t_servergetkey(ts, &A);
+ if (skey == NULL) {
+ return 0;
+ }
+
+ /* Get the response from the client. */
+
+ i = recv(s, msgbuf, RESPONSE_LEN, MSG_WAITALL);
+ if (i <= 0) {
+ return 0;
+ }
+ if (t_serververify(ts, msgbuf) != 0) {
+ return 0;
+ }
+
+ /* Client authenticated. Now authenticate ourselves to the client. */
+
+ if (send(s, t_serverresponse(ts), RESPONSE_LEN, 0) < 0) {
+ return 0;
+ }
+
+ /* Copy the key and clean up. */
+
+ if (tsrp) {
+ memcpy(tsrp->username, username, strlen(username) + 1);
+ memcpy(tsrp->key, skey, SESSION_KEY_LEN);
+ }
+ t_serverclose(ts);
+
+ return 1;
+}
diff --git a/package/network/services/ead/src/tinysrp/tinysrp.h b/package/network/services/ead/src/tinysrp/tinysrp.h
new file mode 100644
index 0000000..4420a19
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/tinysrp.h
@@ -0,0 +1,18 @@
+/* Simple API for the tinysrp library. */
+
+#ifndef T_PWD_H
+#define MAXUSERLEN 32
+#define SESSION_KEY_LEN 40 /* 320-bit session key */
+#endif
+
+typedef struct {
+ char username[MAXUSERLEN + 1];
+ unsigned char key[SESSION_KEY_LEN];
+} TSRP_SESSION;
+
+/* These functions are passed a connected socket, and return true for a
+successful authentication. If tsrp is not NULL, the username and key
+fields are filled in. */
+
+extern int tsrp_server_authenticate(int s, TSRP_SESSION *tsrp);
+extern int tsrp_client_authenticate(int s, char *user, char *pass, TSRP_SESSION *tsrp);
diff --git a/package/network/services/ead/src/tinysrp/tpasswd b/package/network/services/ead/src/tinysrp/tpasswd
new file mode 100644
index 0000000..2ac7e2a
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/tpasswd
@@ -0,0 +1,2 @@
+moo:A9lHvOGAMJvw1m3vcDsQRUFovh6/QUmLDKqwhv.drKQzbE9nS7HrOZLUPx2MmS6ewwybN8RHqpWqnUJRCMFT14FMbYXR7kYNUUQNx43A7F.xrVOU7tlFq5NjoK9sfFtp6PMdbIOP5wzWmipiNFlCOu4sjlSZb.o7C1chLzTKU.0:19AI0Hc9jEkdFc:5
+new user:1FsanML2fbTOEsa072bLjyRD1LEqoRD2GwElfN0VmHeR.FAg5A.2.G5bTjIHmMmHL60kgoAHJZhRrgopalYmujlyAuQoKiHJb98SHm1oJaQ9nl/DrZCvfyw5LpVMqg.CupdiWz6OtmOz8fwC96ItExFnNDt6SmsVDIOn4HqXG6C0lLaqEvcqlN3gFDlJXyP2yldM.LJ1TkHTHmA3DjRkmWEUL3mWEgzkEHyPcRB3Jd5ncDT7jaNbJTTLRoOtgRsaqE7OXuPADoK8MGBcUquYBRrGwyU4Y/wW4gLc3QmV793zxkk.P3.dxkLSjro/Kk94D7kC6fx3K9tadLJyzd94rr:3v/KRlxT0.oYF1:1
diff --git a/package/network/services/ead/src/tinysrp/tphrase.c b/package/network/services/ead/src/tinysrp/tphrase.c
new file mode 100644
index 0000000..1aede0c
--- /dev/null
+++ b/package/network/services/ead/src/tinysrp/tphrase.c
@@ -0,0 +1,348 @@
+/* Add passphrases to the tpasswd file. Use the last entry in the config
+file by default or a particular one specified by index. */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include "config.h"
+#include "t_pwd.h"
+#include "t_read.h"
+#include "t_sha.h"
+#include "t_defines.h"
+
+char *Progname;
+char Usage[] = "usage: %s [-n configindex] [-p passfile] user\n";
+#define USAGE() fprintf(stderr, Usage, Progname)
+
+void doit(char *);
+
+int Configindex = -1;
+char *Passfile = DEFAULT_PASSWD;
+
+int main(int argc, char **argv)
+{
+ int c;
+
+ Progname = *argv;
+
+ /* Parse option arguments. */
+
+ while ((c = getopt(argc, argv, "n:p:")) != EOF) {
+ switch (c) {
+
+ case 'n':
+ Configindex = atoi(optarg);
+ break;
+
+ case 'p':
+ Passfile = optarg;
+ break;
+
+ default:
+ USAGE();
+ exit(1);
+ }
+ }
+ argc -= optind;
+ argv += optind;
+
+ if (argc != 1) {
+ USAGE();
+ exit(1);
+ }
+ doit(argv[0]);
+
+ return 0;
+}
+
+void doit(char *name)
+{
+ char passphrase[128], passphrase1[128];
+ FILE *f;
+ struct t_conf *tc;
+ struct t_confent *tcent;
+ struct t_pw eps_passwd;
+
+ /* Get the config entry. */
+
+ if (Configindex <= 0) {
+ Configindex = t_getprecount();
+ }
+ tcent = gettcid(Configindex);
+ if (tcent == NULL) {
+ fprintf(stderr, "Invalid configuration file entry.\n");
+ exit(1);
+ }
+
+ /* Ask for the passphrase twice. */
+
+ printf("Setting passphrase for %s\n", name);
+
+ if (t_getpass(passphrase, sizeof(passphrase), "Enter passphrase: ") < 0) {
+ exit(1);
+ }
+ if (t_getpass(passphrase1, sizeof(passphrase1), "Verify: ") < 0) {
+ exit(1);
+ }
+ if (strcmp(passphrase, passphrase1) != 0) {
+ fprintf(stderr, "mismatch\n");
+ exit(1);
+ }
+
+ /* Create the passphrase verifier. */
+
+ t_makepwent(&eps_passwd, name, passphrase, NULL, tcent);
+
+ /* Don't need these anymore. */
+
+ memset(passphrase, 0, sizeof(passphrase));
+ memset(passphrase1, 0, sizeof(passphrase1));
+
+ /* See if the passphrase file is there; create it if not. */
+
+ if ((f = fopen(Passfile, "r+")) == NULL) {
+ creat(Passfile, 0400);
+ } else {
+ fclose(f);
+ }
+
+ /* Change the passphrase. */
+
+ if (t_changepw(Passfile, &eps_passwd.pebuf) < 0) {
+ fprintf(stderr, "Error changing passphrase\n");
+ exit(1);
+ }
+}
+
+/* TODO: Implement a more general method to handle delete/change */
+
+_TYPE( int )
+t_changepw(pwname, diff)
+ const char * pwname;
+ const struct t_pwent * diff;
+{
+ char * bakfile;
+ char * bakfile2;
+ struct stat st;
+ FILE * passfp;
+ FILE * bakfp;
+
+ if(pwname == NULL)
+ pwname = DEFAULT_PASSWD;
+
+ if((passfp = fopen(pwname, "rb")) == NULL || fstat(fileno(passfp), &st) < 0)
+ return -1;
+
+ if((bakfile = malloc(strlen(pwname) + 5)) == NULL) {
+ fclose(passfp);
+ return -1;
+ }
+ else if((bakfile2 = malloc(strlen(pwname) + 5)) == NULL) {
+ fclose(passfp);
+ free(bakfile);
+ return -1;
+ }
+
+ sprintf(bakfile, "%s.bak", pwname);
+ sprintf(bakfile2, "%s.sav", pwname);
+
+ if((bakfp = fopen(bakfile2, "wb")) == NULL &&
+ (unlink(bakfile2) < 0 || (bakfp = fopen(bakfile2, "wb")) == NULL)) {
+ fclose(passfp);
+ fclose(bakfp);
+ return -1;
+ }
+
+#ifdef NO_FCHMOD
+ chmod(bakfile2, st.st_mode & 0777);
+#else
+ fchmod(fileno(bakfp), st.st_mode & 0777);
+#endif
+
+ t_pwcopy(bakfp, passfp, diff);
+
+ fclose(bakfp);
+ fclose(passfp);
+
+#ifdef USE_RENAME
+ unlink(bakfile);
+ if(rename(pwname, bakfile) < 0)
+ return -1;
+ if(rename(bakfile2, pwname) < 0)
+ return -1;
+#else
+ unlink(bakfile);
+ link(pwname, bakfile);
+ unlink(pwname);
+ link(bakfile2, pwname);
+ unlink(bakfile2);
+#endif
+ free(bakfile);
+ free(bakfile2);
+
+ return 0;
+}
+
+_TYPE( struct t_pwent * )
+t_makepwent(tpw, user, pass, salt, confent)
+ struct t_pw * tpw;
+ const char * user;
+ const char * pass;
+ const struct t_num * salt;
+ const struct t_confent * confent;
+{
+ BigInteger x, v, n, g;
+ unsigned char dig[SHA_DIGESTSIZE];
+ SHA1_CTX ctxt;
+
+ tpw->pebuf.name = tpw->userbuf;
+ tpw->pebuf.password.data = tpw->pwbuf;
+ tpw->pebuf.salt.data = tpw->saltbuf;
+
+ strncpy(tpw->pebuf.name, user, MAXUSERLEN);
+ tpw->pebuf.index = confent->index;
+
+ if(salt) {
+ tpw->pebuf.salt.len = salt->len;
+ memcpy(tpw->pebuf.salt.data, salt->data, salt->len);
+ }
+ else {
+ memset(dig, 0, SALTLEN); /* salt is 80 bits */
+ tpw->pebuf.salt.len = SALTLEN;
+ do {
+ t_random(tpw->pebuf.salt.data, SALTLEN);
+ } while(memcmp(tpw->pebuf.salt.data, dig, SALTLEN) == 0);
+ if(tpw->pebuf.salt.data[0] == 0)
+ tpw->pebuf.salt.data[0] = 0xff;
+ }
+
+ n = BigIntegerFromBytes(confent->modulus.data, confent->modulus.len);
+ g = BigIntegerFromBytes(confent->generator.data, confent->generator.len);
+ v = BigIntegerFromInt(0);
+
+ SHA1Init(&ctxt);
+ SHA1Update(&ctxt, user, strlen(user));
+ SHA1Update(&ctxt, ":", 1);
+ SHA1Update(&ctxt, pass, strlen(pass));
+ SHA1Final(dig, &ctxt);
+
+ SHA1Init(&ctxt);
+ SHA1Update(&ctxt, tpw->pebuf.salt.data, tpw->pebuf.salt.len);
+ SHA1Update(&ctxt, dig, sizeof(dig));
+ SHA1Final(dig, &ctxt);
+
+ /* x = H(s, H(u, ':', p)) */
+ x = BigIntegerFromBytes(dig, sizeof(dig));
+
+ BigIntegerModExp(v, g, x, n);
+ tpw->pebuf.password.len = BigIntegerToBytes(v, tpw->pebuf.password.data);
+
+ BigIntegerFree(v);
+ BigIntegerFree(x);
+ BigIntegerFree(g);
+ BigIntegerFree(n);
+
+ return &tpw->pebuf;
+}
+
+int
+t_pwcopy(pwdest, pwsrc, diff)
+ FILE * pwdest;
+ FILE * pwsrc;
+ struct t_pwent * diff;
+{
+ struct t_pw * src;
+ struct t_pwent * ent;
+
+ if((src = t_openpw(pwsrc)) == NULL)
+ return -1;
+
+ while((ent = t_getpwent(src)) != NULL)
+ if(diff && strcmp(diff->name, ent->name) == 0) {
+ t_putpwent(diff, pwdest);
+ diff = NULL;
+ }
+ else
+ t_putpwent(ent, pwdest);
+
+ if(diff)
+ t_putpwent(diff, pwdest);
+
+ return 0;
+}
+
+_TYPE( struct t_pwent * )
+t_getpwent(tpw)
+ struct t_pw * tpw;
+{
+ char indexbuf[16];
+ char passbuf[MAXB64PARAMLEN];
+ char saltstr[MAXB64SALTLEN];
+
+#ifdef ENABLE_YP
+ struct t_passwd * nisent;
+ /* FIXME: should tell caller to get conf entry from NIS also */
+
+ if(tpw->state == IN_NIS) {
+ nisent = _yp_gettpent();
+ if(nisent != NULL) {
+ savepwent(tpw, &nisent->tp);
+ return &tpw->pebuf;
+ }
+ tpw->state = FILE_NIS;
+ }
+#endif
+
+ while(1) {
+ if(t_nextfield(tpw->instream, tpw->userbuf, MAXUSERLEN) > 0) {
+#ifdef ENABLE_YP
+ if(tpw->state == FILE_NIS && *tpw->userbuf == '+') {
+ t_nextline(tpw->instream);
+ if(strlen(tpw->userbuf) > 1) { /* +name:... */
+ nisent = _yp_gettpnam(tpw->userbuf + 1);
+ if(nisent != NULL) {
+ savepwent(tpw, nisent);
+ return &tpw->pebuf;
+ }
+ }
+ else { /* +:... */
+ tpw->state = IN_NIS;
+ _yp_settpent();
+ return t_getpwent(tpw);
+ }
+ }
+#endif
+ if(t_nextfield(tpw->instream, passbuf, MAXB64PARAMLEN) > 0 &&
+ (tpw->pebuf.password.len = t_fromb64(tpw->pwbuf, passbuf)) > 0 &&
+ t_nextfield(tpw->instream, saltstr, MAXB64SALTLEN) > 0 &&
+ (tpw->pebuf.salt.len = t_fromb64(tpw->saltbuf, saltstr)) > 0 &&
+ t_nextfield(tpw->instream, indexbuf, 16) > 0 &&
+ (tpw->pebuf.index = atoi(indexbuf)) > 0) {
+ tpw->pebuf.name = tpw->userbuf;
+ tpw->pebuf.password.data = tpw->pwbuf;
+ tpw->pebuf.salt.data = tpw->saltbuf;
+ t_nextline(tpw->instream);
+ return &tpw->pebuf;
+ }
+ }
+ if(t_nextline(tpw->instream) < 0)
+ return NULL;
+ }
+}
+
+_TYPE( void )
+t_putpwent(ent, fp)
+ const struct t_pwent * ent;
+ FILE * fp;
+{
+ char strbuf[MAXB64PARAMLEN];
+ char saltbuf[MAXB64SALTLEN];
+
+ fprintf(fp, "%s:%s:%s:%d\n", ent->name,
+ t_tob64(strbuf, ent->password.data, ent->password.len),
+ t_tob64(saltbuf, ent->salt.data, ent->salt.len), ent->index);
+}
+
diff --git a/package/network/services/hostapd/.svn/entries b/package/network/services/hostapd/.svn/entries
new file mode 100644
index 0000000..58af596
--- /dev/null
+++ b/package/network/services/hostapd/.svn/entries
@@ -0,0 +1,105 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/services/hostapd
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-13T18:11:25.711122Z
+36004
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+madwifi
+dir
+
+files
+dir
+
+patches
+dir
+
+Config.in
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+40420a59a1426f30cb98a7acffec16a3
+2012-02-20T23:41:52.562188Z
+30666
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1101
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+6d8101d4dcce1beb9444eddc0cfc7b1e
+2013-03-13T18:11:25.711122Z
+36004
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+9342
+
diff --git a/package/network/services/hostapd/.svn/prop-base/Makefile.svn-base b/package/network/services/hostapd/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..8e522ae
--- /dev/null
+++ b/package/network/services/hostapd/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:copyright
+V 30
+Copyright (C) 2006 OpenWrt.org
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/services/hostapd/.svn/text-base/Config.in.svn-base b/package/network/services/hostapd/.svn/text-base/Config.in.svn-base
new file mode 100644
index 0000000..810c5a0
--- /dev/null
+++ b/package/network/services/hostapd/.svn/text-base/Config.in.svn-base
@@ -0,0 +1,47 @@
+# wpa_supplicant config
+config WPA_SUPPLICANT_NO_TIMESTAMP_CHECK
+ bool "Disable timestamp check"
+ depends PACKAGE_wpa-supplicant || PACKAGE_wpa-supplicant-mini || PACKAGE_wpad || PACKAGE_wpad-mini
+ default n
+ help
+ This disables the timestamp check for certificates in wpa_supplicant
+ Useful for devices without RTC that cannot reliably get the real date/time
+
+choice
+ prompt "Choose TLS provider"
+ default WPA_SUPPLICANT_INTERNAL
+ depends PACKAGE_wpa-supplicant || PACKAGE_wpad
+
+config WPA_SUPPLICANT_INTERNAL
+ bool "internal"
+
+config WPA_SUPPLICANT_OPENSSL
+ bool "openssl"
+ select PACKAGE_libopenssl
+
+endchoice
+
+config WPA_RFKILL_SUPPORT
+ bool "Add rfkill support"
+ depends PACKAGE_wpa-supplicant || PACKAGE_wpa-supplicant-mini || PACKAGE_wpad || PACKAGE_wpad-mini
+ default n
+
+config WPA_MSG_MIN_PRIORITY
+ int "Minimum debug message priority"
+ default 3
+ help
+ Useful values are:
+ 0 = all messages
+ 1 = raw message dumps
+ 2 = most debugging messages
+ 3 = info messages
+ 4 = warnings
+ 5 = errors
+
+config DRIVER_WEXT_SUPPORT
+ bool
+ default n
+
+config DRIVER_11N_SUPPORT
+ bool
+ default n
diff --git a/package/network/services/hostapd/.svn/text-base/Makefile.svn-base b/package/network/services/hostapd/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..16db2d8
--- /dev/null
+++ b/package/network/services/hostapd/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,343 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=hostapd
+PKG_VERSION:=20130302
+PKG_RELEASE:=1
+PKG_REV:=a311c61dd664db7c1d16dd3395adf07bea6c141d
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=git://w1.fi/srv/git/hostap.git
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE_VERSION:=$(PKG_REV)
+PKG_SOURCE_PROTO:=git
+PKG_MIRROR_MD5SUM:=d81d1b073521df0c608f42e2cedec60c
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+
+PKG_BUILD_PARALLEL:=1
+
+PKG_BUILD_DEPENDS:= \
+ PACKAGE_kmod-madwifi:madwifi \
+
+PKG_CONFIG_DEPENDS:= \
+ CONFIG_WPA_SUPPLICANT_NO_TIMESTAMP_CHECK \
+ CONFIG_PACKAGE_kmod-ath9k \
+ CONFIG_PACKAGE_kmod-mac80211 \
+ CONFIG_PACKAGE_kmod-madwifi \
+ CONFIG_PACKAGE_hostapd \
+ CONFIG_PACKAGE_hostapd-mini \
+ CONFIG_PACKAGE_kmod-hostap \
+ CONFIG_WPA_RFKILL_SUPPORT \
+ CONFIG_DRIVER_WEXT_SUPPORT \
+ CONFIG_DRIVER_11N_SUPPORT
+
+LOCAL_TYPE=$(strip \
+ $(if $(findstring wpad,$(BUILD_VARIANT)),wpad, \
+ $(if $(findstring supplicant,$(BUILD_VARIANT)),supplicant, \
+ hostapd \
+ )))
+LOCAL_VARIANT=$(patsubst wpad-%,%,$(patsubst supplicant-%,%,$(BUILD_VARIANT)))
+
+ifeq ($(LOCAL_TYPE),supplicant)
+ ifeq ($(LOCAL_VARIANT),full)
+ PKG_CONFIG_DEPENDS += \
+ CONFIG_WPA_SUPPLICANT_INTERNAL \
+ CONFIG_WPA_SUPPLICANT_OPENSSL
+ endif
+endif
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
+
+include $(INCLUDE_DIR)/package.mk
+
+STAMP_CONFIGURED:=$(STAMP_CONFIGURED)_$(CONFIG_WPA_MSG_MIN_PRIORITY)
+
+ifneq ($(CONFIG_DRIVER_11N_SUPPORT),)
+ HOSTAPD_IEEE80211N:=y
+endif
+
+DRIVER_MAKEOPTS= \
+ CONFIG_DRIVER_NL80211=$(CONFIG_PACKAGE_kmod-mac80211) \
+ CONFIG_DRIVER_MADWIFI=$(CONFIG_PACKAGE_kmod-madwifi) \
+ CONFIG_DRIVER_HOSTAP=$(CONFIG_PACKAGE_kmod-hostap) \
+ CONFIG_IEEE80211N=$(HOSTAPD_IEEE80211N) \
+ CONFIG_IEEE80211W=$(CONFIG_PACKAGE_kmod-ath9k) \
+ CONFIG_DRIVER_WEXT=$(CONFIG_DRIVER_WEXT_SUPPORT) \
+ $(if $(CONFIG_WPA_RFKILL_SUPPORT),NEED_RFKILL=y)
+
+ifneq ($(LOCAL_TYPE),hostapd)
+ ifdef CONFIG_WPA_SUPPLICANT_OPENSSL
+ ifeq ($(LOCAL_VARIANT),full)
+ DRIVER_MAKEOPTS += CONFIG_TLS=openssl
+ TARGET_LDFLAGS += -lcrypto -lssl
+ endif
+ endif
+ ifdef CONFIG_WPA_SUPPLICANT_NO_TIMESTAMP_CHECK
+ TARGET_CFLAGS += -DNO_TIMESTAMP_CHECK
+ endif
+ DRIVER_MAKEOPTS += \
+ CONFIG_DRIVER_ROBOSWITCH=$(CONFIG_PACKAGE_kmod-switch)
+endif
+
+DRV_DEPENDS:=+PACKAGE_kmod-mac80211:libnl-tiny @(!TARGET_avr32||BROKEN)
+
+define Package/hostapd/Default
+ SECTION:=net
+ CATEGORY:=Network
+ TITLE:=IEEE 802.1x Authenticator
+ URL:=http://hostap.epitest.fi/
+ DEPENDS:=$(DRV_DEPENDS)
+endef
+
+define Package/hostapd
+$(call Package/hostapd/Default)
+ TITLE+= (full)
+ VARIANT:=full
+endef
+
+define Package/hostapd/description
+ This package contains a full featured IEEE 802.1x/WPA/EAP/RADIUS
+ Authenticator.
+endef
+
+define Package/hostapd-mini
+$(call Package/hostapd/Default)
+ TITLE+= (WPA-PSK only)
+ VARIANT:=mini
+endef
+
+define Package/hostapd-mini/description
+ This package contains a minimal IEEE 802.1x/WPA Authenticator (WPA-PSK only).
+endef
+
+define Package/hostapd-utils
+ $(call Package/hostapd/Default)
+ TITLE+= (utils)
+ DEPENDS:=@PACKAGE_hostapd||PACKAGE_hostapd-mini||PACKAGE_wpad||PACKAGE_wpad-mini
+endef
+
+define Package/hostapd-utils/description
+ This package contains a command line utility to control the
+ IEEE 802.1x/WPA/EAP/RADIUS Authenticator.
+endef
+
+define Package/wpad/Default
+ SECTION:=net
+ CATEGORY:=Network
+ TITLE:=IEEE 802.1x Authenticator/Supplicant
+ URL:=http://hostap.epitest.fi/
+endef
+
+define Package/wpad
+$(call Package/wpad/Default)
+ TITLE+= (full)
+ DEPENDS:=$(DRV_DEPENDS) +WPA_SUPPLICANT_OPENSSL:libopenssl
+ VARIANT:=wpad-full
+endef
+
+define Package/wpad/description
+ This package contains a full featured IEEE 802.1x/WPA/EAP/RADIUS
+ Authenticator and Supplicant
+endef
+
+define Package/wpad-mini
+$(call Package/wpad/Default)
+ TITLE+= (WPA-PSK only)
+ DEPENDS:=$(DRV_DEPENDS)
+ VARIANT:=wpad-mini
+endef
+
+define Package/wpad-mini/description
+ This package contains a minimal IEEE 802.1x/WPA Authenticator and Supplicant (WPA-PSK only).
+endef
+
+define Package/wpa-supplicant
+ SECTION:=net
+ CATEGORY:=Network
+ TITLE:=WPA Supplicant
+ URL:=http://hostap.epitest.fi/wpa_supplicant/
+ DEPENDS:=$(DRV_DEPENDS) +WPA_SUPPLICANT_OPENSSL:libopenssl
+ VARIANT:=supplicant-full
+endef
+
+define Package/wpa-supplicant/Description
+ WPA Supplicant
+endef
+
+define Package/wpa-supplicant/config
+ source "$(SOURCE)/Config.in"
+endef
+
+define Package/wpa-supplicant-mini
+ $(Package/wpa-supplicant)
+ TITLE:=WPA Supplicant (minimal version)
+ DEPENDS:=$(DRV_DEPENDS)
+ VARIANT:=supplicant-mini
+endef
+
+define Package/wpa-supplicant-mini/Description
+ WPA Supplicant (minimal version)
+endef
+
+define Package/wpa-cli
+ SECTION:=net
+ CATEGORY:=Network
+ DEPENDS:=@PACKAGE_wpa-supplicant||PACKAGE_wpad-mini||PACKAGE_wpad
+ TITLE:=WPA Supplicant command line interface
+endef
+
+define Package/wpa-cli/Description
+ WPA Supplicant control utility
+endef
+
+
+ifneq ($(wildcard $(PKG_BUILD_DIR)/.config_*),$(subst .configured_,.config_,$(STAMP_CONFIGURED)))
+ define Build/Configure/rebuild
+ $(FIND) $(PKG_BUILD_DIR) -name \*.o -or -name \*.a | $(XARGS) rm -f
+ rm -f $(PKG_BUILD_DIR)/hostapd/hostapd
+ rm -f $(PKG_BUILD_DIR)/wpa_supplicant/wpa_supplicant
+ rm -f $(PKG_BUILD_DIR)/.config_*
+ touch $(subst .configured_,.config_,$(STAMP_CONFIGURED))
+ endef
+endif
+
+define Build/Configure
+ $(Build/Configure/rebuild)
+ $(CP) ./files/hostapd-$(LOCAL_VARIANT).config $(PKG_BUILD_DIR)/hostapd/.config
+ $(CP) ./files/wpa_supplicant-$(LOCAL_VARIANT).config $(PKG_BUILD_DIR)/wpa_supplicant/.config
+endef
+
+TARGET_CPPFLAGS := \
+ -I$(STAGING_DIR)/usr/include/libnl-tiny \
+ -I$(PKG_BUILD_DIR)/src/crypto \
+ $(TARGET_CPPFLAGS) \
+ -I$(CURDIR)/madwifi \
+ -DCONFIG_LIBNL20 \
+ -D_GNU_SOURCE \
+ $(if $(CONFIG_WPA_MSG_MIN_PRIORITY),-DCONFIG_MSG_MIN_PRIORITY=$(CONFIG_WPA_MSG_MIN_PRIORITY))
+
+TARGET_CFLAGS += -ffunction-sections -fdata-sections
+TARGET_LDFLAGS += -Wl,--gc-sections
+
+ifdef CONFIG_PACKAGE_kmod-mac80211
+ TARGET_LDFLAGS += -lm -lnl-tiny
+endif
+
+define Build/RunMake
+ CFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" \
+ $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR)/$(1) \
+ $(TARGET_CONFIGURE_OPTS) \
+ $(DRIVER_MAKEOPTS) \
+ LIBS="$(TARGET_LDFLAGS)" \
+ BCHECK= \
+ $(2)
+endef
+
+define Build/Compile/wpad
+ echo ` \
+ $(call Build/RunMake,hostapd,-s MULTICALL=1 dump_cflags); \
+ $(call Build/RunMake,wpa_supplicant,-s MULTICALL=1 dump_cflags) | \
+ sed -e 's,-n ,,g' -e 's,$(TARGET_CFLAGS),,' \
+ ` > $(PKG_BUILD_DIR)/.cflags
+ +$(call Build/RunMake,hostapd, \
+ CFLAGS="$$$$(cat $(PKG_BUILD_DIR)/.cflags)" \
+ MULTICALL=1 \
+ hostapd_cli hostapd_multi.a \
+ )
+ +$(call Build/RunMake,wpa_supplicant, \
+ CFLAGS="$$$$(cat $(PKG_BUILD_DIR)/.cflags)" \
+ MULTICALL=1 \
+ wpa_cli wpa_supplicant_multi.a \
+ )
+ $(TARGET_CC) -o $(PKG_BUILD_DIR)/wpad \
+ $(TARGET_CFLAGS) \
+ ./files/multicall.c \
+ $(PKG_BUILD_DIR)/hostapd/hostapd_multi.a \
+ $(PKG_BUILD_DIR)/wpa_supplicant/wpa_supplicant_multi.a \
+ $(TARGET_LDFLAGS)
+endef
+
+define Build/Compile/hostapd
+ $(call Build/RunMake,hostapd, \
+ hostapd hostapd_cli \
+ )
+endef
+
+define Build/Compile/supplicant
+ $(call Build/RunMake,wpa_supplicant, \
+ wpa_cli wpa_supplicant \
+ )
+endef
+
+define Build/Compile
+ $(Build/Compile/$(LOCAL_TYPE))
+endef
+
+define Install/hostapd
+ $(INSTALL_DIR) $(1)/lib/wifi
+ $(INSTALL_DATA) ./files/hostapd.sh $(1)/lib/wifi/hostapd.sh
+ $(INSTALL_DIR) $(1)/usr/sbin
+endef
+
+define Install/supplicant
+ $(INSTALL_DIR) $(1)/lib/wifi
+ $(INSTALL_DATA) ./files/wpa_supplicant.sh $(1)/lib/wifi/wpa_supplicant.sh
+ $(INSTALL_DIR) $(1)/usr/sbin
+endef
+
+define Package/hostapd/install
+ $(call Install/hostapd,$(1))
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/hostapd/hostapd $(1)/usr/sbin/
+endef
+Package/hostapd-mini/install = $(Package/hostapd/install)
+
+ifneq ($(LOCAL_TYPE),supplicant)
+ define Package/hostapd-utils/install
+ $(INSTALL_DIR) $(1)/usr/sbin $(1)/etc/hotplug.d/button
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/hostapd/hostapd_cli $(1)/usr/sbin/
+ $(INSTALL_DATA) ./files/wps-hotplug.sh $(1)/etc/hotplug.d/button/50-wps
+ $(if $(CONFIG_PROCD_INIT),
+ $(INSTALL_DIR) $(1)/etc/rc.button/
+ $(INSTALL_BIN) ./files/wps-hotplug.sh $(1)/etc/rc.button/wps,
+ $(INSTALL_DATA) ./files/wps-hotplug.sh $(1)/etc/hotplug.d/button/50-wps
+ )
+ endef
+endif
+
+define Package/wpad/install
+ $(call Install/hostapd,$(1))
+ $(call Install/supplicant,$(1))
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/wpad $(1)/usr/sbin/
+ ln -sf wpad $(1)/usr/sbin/hostapd
+ ln -sf wpad $(1)/usr/sbin/wpa_supplicant
+endef
+Package/wpad-mini/install = $(Package/wpad/install)
+
+define Package/wpa-supplicant/install
+ $(call Install/supplicant,$(1))
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/wpa_supplicant/wpa_supplicant $(1)/usr/sbin/
+endef
+Package/wpa-supplicant-mini/install = $(Package/wpa-supplicant/install)
+
+ifneq ($(LOCAL_TYPE),hostapd)
+ define Package/wpa-cli/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(CP) $(PKG_BUILD_DIR)/wpa_supplicant/wpa_cli $(1)/usr/sbin/
+ endef
+endif
+
+$(eval $(call BuildPackage,hostapd))
+$(eval $(call BuildPackage,hostapd-mini))
+$(eval $(call BuildPackage,wpad))
+$(eval $(call BuildPackage,wpad-mini))
+$(eval $(call BuildPackage,wpa-supplicant))
+$(eval $(call BuildPackage,wpa-supplicant-mini))
+$(eval $(call BuildPackage,wpa-cli))
+$(eval $(call BuildPackage,hostapd-utils))
diff --git a/package/network/services/hostapd/Config.in b/package/network/services/hostapd/Config.in
new file mode 100644
index 0000000..810c5a0
--- /dev/null
+++ b/package/network/services/hostapd/Config.in
@@ -0,0 +1,47 @@
+# wpa_supplicant config
+config WPA_SUPPLICANT_NO_TIMESTAMP_CHECK
+ bool "Disable timestamp check"
+ depends PACKAGE_wpa-supplicant || PACKAGE_wpa-supplicant-mini || PACKAGE_wpad || PACKAGE_wpad-mini
+ default n
+ help
+ This disables the timestamp check for certificates in wpa_supplicant
+ Useful for devices without RTC that cannot reliably get the real date/time
+
+choice
+ prompt "Choose TLS provider"
+ default WPA_SUPPLICANT_INTERNAL
+ depends PACKAGE_wpa-supplicant || PACKAGE_wpad
+
+config WPA_SUPPLICANT_INTERNAL
+ bool "internal"
+
+config WPA_SUPPLICANT_OPENSSL
+ bool "openssl"
+ select PACKAGE_libopenssl
+
+endchoice
+
+config WPA_RFKILL_SUPPORT
+ bool "Add rfkill support"
+ depends PACKAGE_wpa-supplicant || PACKAGE_wpa-supplicant-mini || PACKAGE_wpad || PACKAGE_wpad-mini
+ default n
+
+config WPA_MSG_MIN_PRIORITY
+ int "Minimum debug message priority"
+ default 3
+ help
+ Useful values are:
+ 0 = all messages
+ 1 = raw message dumps
+ 2 = most debugging messages
+ 3 = info messages
+ 4 = warnings
+ 5 = errors
+
+config DRIVER_WEXT_SUPPORT
+ bool
+ default n
+
+config DRIVER_11N_SUPPORT
+ bool
+ default n
diff --git a/package/network/services/hostapd/Makefile b/package/network/services/hostapd/Makefile
new file mode 100644
index 0000000..16db2d8
--- /dev/null
+++ b/package/network/services/hostapd/Makefile
@@ -0,0 +1,343 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=hostapd
+PKG_VERSION:=20130302
+PKG_RELEASE:=1
+PKG_REV:=a311c61dd664db7c1d16dd3395adf07bea6c141d
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=git://w1.fi/srv/git/hostap.git
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE_VERSION:=$(PKG_REV)
+PKG_SOURCE_PROTO:=git
+PKG_MIRROR_MD5SUM:=d81d1b073521df0c608f42e2cedec60c
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+
+PKG_BUILD_PARALLEL:=1
+
+PKG_BUILD_DEPENDS:= \
+ PACKAGE_kmod-madwifi:madwifi \
+
+PKG_CONFIG_DEPENDS:= \
+ CONFIG_WPA_SUPPLICANT_NO_TIMESTAMP_CHECK \
+ CONFIG_PACKAGE_kmod-ath9k \
+ CONFIG_PACKAGE_kmod-mac80211 \
+ CONFIG_PACKAGE_kmod-madwifi \
+ CONFIG_PACKAGE_hostapd \
+ CONFIG_PACKAGE_hostapd-mini \
+ CONFIG_PACKAGE_kmod-hostap \
+ CONFIG_WPA_RFKILL_SUPPORT \
+ CONFIG_DRIVER_WEXT_SUPPORT \
+ CONFIG_DRIVER_11N_SUPPORT
+
+LOCAL_TYPE=$(strip \
+ $(if $(findstring wpad,$(BUILD_VARIANT)),wpad, \
+ $(if $(findstring supplicant,$(BUILD_VARIANT)),supplicant, \
+ hostapd \
+ )))
+LOCAL_VARIANT=$(patsubst wpad-%,%,$(patsubst supplicant-%,%,$(BUILD_VARIANT)))
+
+ifeq ($(LOCAL_TYPE),supplicant)
+ ifeq ($(LOCAL_VARIANT),full)
+ PKG_CONFIG_DEPENDS += \
+ CONFIG_WPA_SUPPLICANT_INTERNAL \
+ CONFIG_WPA_SUPPLICANT_OPENSSL
+ endif
+endif
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
+
+include $(INCLUDE_DIR)/package.mk
+
+STAMP_CONFIGURED:=$(STAMP_CONFIGURED)_$(CONFIG_WPA_MSG_MIN_PRIORITY)
+
+ifneq ($(CONFIG_DRIVER_11N_SUPPORT),)
+ HOSTAPD_IEEE80211N:=y
+endif
+
+DRIVER_MAKEOPTS= \
+ CONFIG_DRIVER_NL80211=$(CONFIG_PACKAGE_kmod-mac80211) \
+ CONFIG_DRIVER_MADWIFI=$(CONFIG_PACKAGE_kmod-madwifi) \
+ CONFIG_DRIVER_HOSTAP=$(CONFIG_PACKAGE_kmod-hostap) \
+ CONFIG_IEEE80211N=$(HOSTAPD_IEEE80211N) \
+ CONFIG_IEEE80211W=$(CONFIG_PACKAGE_kmod-ath9k) \
+ CONFIG_DRIVER_WEXT=$(CONFIG_DRIVER_WEXT_SUPPORT) \
+ $(if $(CONFIG_WPA_RFKILL_SUPPORT),NEED_RFKILL=y)
+
+ifneq ($(LOCAL_TYPE),hostapd)
+ ifdef CONFIG_WPA_SUPPLICANT_OPENSSL
+ ifeq ($(LOCAL_VARIANT),full)
+ DRIVER_MAKEOPTS += CONFIG_TLS=openssl
+ TARGET_LDFLAGS += -lcrypto -lssl
+ endif
+ endif
+ ifdef CONFIG_WPA_SUPPLICANT_NO_TIMESTAMP_CHECK
+ TARGET_CFLAGS += -DNO_TIMESTAMP_CHECK
+ endif
+ DRIVER_MAKEOPTS += \
+ CONFIG_DRIVER_ROBOSWITCH=$(CONFIG_PACKAGE_kmod-switch)
+endif
+
+DRV_DEPENDS:=+PACKAGE_kmod-mac80211:libnl-tiny @(!TARGET_avr32||BROKEN)
+
+define Package/hostapd/Default
+ SECTION:=net
+ CATEGORY:=Network
+ TITLE:=IEEE 802.1x Authenticator
+ URL:=http://hostap.epitest.fi/
+ DEPENDS:=$(DRV_DEPENDS)
+endef
+
+define Package/hostapd
+$(call Package/hostapd/Default)
+ TITLE+= (full)
+ VARIANT:=full
+endef
+
+define Package/hostapd/description
+ This package contains a full featured IEEE 802.1x/WPA/EAP/RADIUS
+ Authenticator.
+endef
+
+define Package/hostapd-mini
+$(call Package/hostapd/Default)
+ TITLE+= (WPA-PSK only)
+ VARIANT:=mini
+endef
+
+define Package/hostapd-mini/description
+ This package contains a minimal IEEE 802.1x/WPA Authenticator (WPA-PSK only).
+endef
+
+define Package/hostapd-utils
+ $(call Package/hostapd/Default)
+ TITLE+= (utils)
+ DEPENDS:=@PACKAGE_hostapd||PACKAGE_hostapd-mini||PACKAGE_wpad||PACKAGE_wpad-mini
+endef
+
+define Package/hostapd-utils/description
+ This package contains a command line utility to control the
+ IEEE 802.1x/WPA/EAP/RADIUS Authenticator.
+endef
+
+define Package/wpad/Default
+ SECTION:=net
+ CATEGORY:=Network
+ TITLE:=IEEE 802.1x Authenticator/Supplicant
+ URL:=http://hostap.epitest.fi/
+endef
+
+define Package/wpad
+$(call Package/wpad/Default)
+ TITLE+= (full)
+ DEPENDS:=$(DRV_DEPENDS) +WPA_SUPPLICANT_OPENSSL:libopenssl
+ VARIANT:=wpad-full
+endef
+
+define Package/wpad/description
+ This package contains a full featured IEEE 802.1x/WPA/EAP/RADIUS
+ Authenticator and Supplicant
+endef
+
+define Package/wpad-mini
+$(call Package/wpad/Default)
+ TITLE+= (WPA-PSK only)
+ DEPENDS:=$(DRV_DEPENDS)
+ VARIANT:=wpad-mini
+endef
+
+define Package/wpad-mini/description
+ This package contains a minimal IEEE 802.1x/WPA Authenticator and Supplicant (WPA-PSK only).
+endef
+
+define Package/wpa-supplicant
+ SECTION:=net
+ CATEGORY:=Network
+ TITLE:=WPA Supplicant
+ URL:=http://hostap.epitest.fi/wpa_supplicant/
+ DEPENDS:=$(DRV_DEPENDS) +WPA_SUPPLICANT_OPENSSL:libopenssl
+ VARIANT:=supplicant-full
+endef
+
+define Package/wpa-supplicant/Description
+ WPA Supplicant
+endef
+
+define Package/wpa-supplicant/config
+ source "$(SOURCE)/Config.in"
+endef
+
+define Package/wpa-supplicant-mini
+ $(Package/wpa-supplicant)
+ TITLE:=WPA Supplicant (minimal version)
+ DEPENDS:=$(DRV_DEPENDS)
+ VARIANT:=supplicant-mini
+endef
+
+define Package/wpa-supplicant-mini/Description
+ WPA Supplicant (minimal version)
+endef
+
+define Package/wpa-cli
+ SECTION:=net
+ CATEGORY:=Network
+ DEPENDS:=@PACKAGE_wpa-supplicant||PACKAGE_wpad-mini||PACKAGE_wpad
+ TITLE:=WPA Supplicant command line interface
+endef
+
+define Package/wpa-cli/Description
+ WPA Supplicant control utility
+endef
+
+
+ifneq ($(wildcard $(PKG_BUILD_DIR)/.config_*),$(subst .configured_,.config_,$(STAMP_CONFIGURED)))
+ define Build/Configure/rebuild
+ $(FIND) $(PKG_BUILD_DIR) -name \*.o -or -name \*.a | $(XARGS) rm -f
+ rm -f $(PKG_BUILD_DIR)/hostapd/hostapd
+ rm -f $(PKG_BUILD_DIR)/wpa_supplicant/wpa_supplicant
+ rm -f $(PKG_BUILD_DIR)/.config_*
+ touch $(subst .configured_,.config_,$(STAMP_CONFIGURED))
+ endef
+endif
+
+define Build/Configure
+ $(Build/Configure/rebuild)
+ $(CP) ./files/hostapd-$(LOCAL_VARIANT).config $(PKG_BUILD_DIR)/hostapd/.config
+ $(CP) ./files/wpa_supplicant-$(LOCAL_VARIANT).config $(PKG_BUILD_DIR)/wpa_supplicant/.config
+endef
+
+TARGET_CPPFLAGS := \
+ -I$(STAGING_DIR)/usr/include/libnl-tiny \
+ -I$(PKG_BUILD_DIR)/src/crypto \
+ $(TARGET_CPPFLAGS) \
+ -I$(CURDIR)/madwifi \
+ -DCONFIG_LIBNL20 \
+ -D_GNU_SOURCE \
+ $(if $(CONFIG_WPA_MSG_MIN_PRIORITY),-DCONFIG_MSG_MIN_PRIORITY=$(CONFIG_WPA_MSG_MIN_PRIORITY))
+
+TARGET_CFLAGS += -ffunction-sections -fdata-sections
+TARGET_LDFLAGS += -Wl,--gc-sections
+
+ifdef CONFIG_PACKAGE_kmod-mac80211
+ TARGET_LDFLAGS += -lm -lnl-tiny
+endif
+
+define Build/RunMake
+ CFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" \
+ $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR)/$(1) \
+ $(TARGET_CONFIGURE_OPTS) \
+ $(DRIVER_MAKEOPTS) \
+ LIBS="$(TARGET_LDFLAGS)" \
+ BCHECK= \
+ $(2)
+endef
+
+define Build/Compile/wpad
+ echo ` \
+ $(call Build/RunMake,hostapd,-s MULTICALL=1 dump_cflags); \
+ $(call Build/RunMake,wpa_supplicant,-s MULTICALL=1 dump_cflags) | \
+ sed -e 's,-n ,,g' -e 's,$(TARGET_CFLAGS),,' \
+ ` > $(PKG_BUILD_DIR)/.cflags
+ +$(call Build/RunMake,hostapd, \
+ CFLAGS="$$$$(cat $(PKG_BUILD_DIR)/.cflags)" \
+ MULTICALL=1 \
+ hostapd_cli hostapd_multi.a \
+ )
+ +$(call Build/RunMake,wpa_supplicant, \
+ CFLAGS="$$$$(cat $(PKG_BUILD_DIR)/.cflags)" \
+ MULTICALL=1 \
+ wpa_cli wpa_supplicant_multi.a \
+ )
+ $(TARGET_CC) -o $(PKG_BUILD_DIR)/wpad \
+ $(TARGET_CFLAGS) \
+ ./files/multicall.c \
+ $(PKG_BUILD_DIR)/hostapd/hostapd_multi.a \
+ $(PKG_BUILD_DIR)/wpa_supplicant/wpa_supplicant_multi.a \
+ $(TARGET_LDFLAGS)
+endef
+
+define Build/Compile/hostapd
+ $(call Build/RunMake,hostapd, \
+ hostapd hostapd_cli \
+ )
+endef
+
+define Build/Compile/supplicant
+ $(call Build/RunMake,wpa_supplicant, \
+ wpa_cli wpa_supplicant \
+ )
+endef
+
+define Build/Compile
+ $(Build/Compile/$(LOCAL_TYPE))
+endef
+
+define Install/hostapd
+ $(INSTALL_DIR) $(1)/lib/wifi
+ $(INSTALL_DATA) ./files/hostapd.sh $(1)/lib/wifi/hostapd.sh
+ $(INSTALL_DIR) $(1)/usr/sbin
+endef
+
+define Install/supplicant
+ $(INSTALL_DIR) $(1)/lib/wifi
+ $(INSTALL_DATA) ./files/wpa_supplicant.sh $(1)/lib/wifi/wpa_supplicant.sh
+ $(INSTALL_DIR) $(1)/usr/sbin
+endef
+
+define Package/hostapd/install
+ $(call Install/hostapd,$(1))
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/hostapd/hostapd $(1)/usr/sbin/
+endef
+Package/hostapd-mini/install = $(Package/hostapd/install)
+
+ifneq ($(LOCAL_TYPE),supplicant)
+ define Package/hostapd-utils/install
+ $(INSTALL_DIR) $(1)/usr/sbin $(1)/etc/hotplug.d/button
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/hostapd/hostapd_cli $(1)/usr/sbin/
+ $(INSTALL_DATA) ./files/wps-hotplug.sh $(1)/etc/hotplug.d/button/50-wps
+ $(if $(CONFIG_PROCD_INIT),
+ $(INSTALL_DIR) $(1)/etc/rc.button/
+ $(INSTALL_BIN) ./files/wps-hotplug.sh $(1)/etc/rc.button/wps,
+ $(INSTALL_DATA) ./files/wps-hotplug.sh $(1)/etc/hotplug.d/button/50-wps
+ )
+ endef
+endif
+
+define Package/wpad/install
+ $(call Install/hostapd,$(1))
+ $(call Install/supplicant,$(1))
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/wpad $(1)/usr/sbin/
+ ln -sf wpad $(1)/usr/sbin/hostapd
+ ln -sf wpad $(1)/usr/sbin/wpa_supplicant
+endef
+Package/wpad-mini/install = $(Package/wpad/install)
+
+define Package/wpa-supplicant/install
+ $(call Install/supplicant,$(1))
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/wpa_supplicant/wpa_supplicant $(1)/usr/sbin/
+endef
+Package/wpa-supplicant-mini/install = $(Package/wpa-supplicant/install)
+
+ifneq ($(LOCAL_TYPE),hostapd)
+ define Package/wpa-cli/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(CP) $(PKG_BUILD_DIR)/wpa_supplicant/wpa_cli $(1)/usr/sbin/
+ endef
+endif
+
+$(eval $(call BuildPackage,hostapd))
+$(eval $(call BuildPackage,hostapd-mini))
+$(eval $(call BuildPackage,wpad))
+$(eval $(call BuildPackage,wpad-mini))
+$(eval $(call BuildPackage,wpa-supplicant))
+$(eval $(call BuildPackage,wpa-supplicant-mini))
+$(eval $(call BuildPackage,wpa-cli))
+$(eval $(call BuildPackage,hostapd-utils))
diff --git a/package/network/services/hostapd/files/.svn/entries b/package/network/services/hostapd/files/.svn/entries
new file mode 100644
index 0000000..2379042
--- /dev/null
+++ b/package/network/services/hostapd/files/.svn/entries
@@ -0,0 +1,300 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/services/hostapd/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-13T18:11:25.711122Z
+36004
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+hostapd-mini.config
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+7afd7689be08ef6d8e5f481991e86564
+2012-02-21T00:27:28.490963Z
+30667
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4507
+
+wpa_supplicant.sh
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+be04aedbeea5a0f71527fb0895084cac
+2013-01-28T18:05:33.823598Z
+35358
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4640
+
+wps-hotplug.sh
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+c12705fdbbe493771b74af40b0ab3945
+2013-03-13T18:11:25.711122Z
+36004
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+171
+
+hostapd-full.config
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+7d24cf315a8106daa1d93b4c801da682
+2012-02-21T00:27:28.490963Z
+30667
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4606
+
+multicall.c
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+4696f03d81ab622bddee906614b96d96
+2010-01-23T08:28:26.207535Z
+19286
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+613
+
+wpa_supplicant-mini.config
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+d59ba6a0b07ebfe258bc5dfdc5c09e81
+2011-04-26T19:16:25.342419Z
+26764
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+14403
+
+hostapd.sh
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+4d78f04b2c24ebdba8a4f3543a15fb70
+2013-02-11T18:59:10.904078Z
+35565
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+9448
+
+wpa_supplicant-full.config
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+eb723ab3ad7d5c87efe219ccb15b7659
+2012-03-27T13:29:51.353654Z
+31086
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+14394
+
diff --git a/package/network/services/hostapd/files/.svn/prop-base/hostapd-full.config.svn-base b/package/network/services/hostapd/files/.svn/prop-base/hostapd-full.config.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/network/services/hostapd/files/.svn/prop-base/hostapd-full.config.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/services/hostapd/files/.svn/prop-base/hostapd-mini.config.svn-base b/package/network/services/hostapd/files/.svn/prop-base/hostapd-mini.config.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/network/services/hostapd/files/.svn/prop-base/hostapd-mini.config.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/services/hostapd/files/.svn/prop-base/hostapd.sh.svn-base b/package/network/services/hostapd/files/.svn/prop-base/hostapd.sh.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/network/services/hostapd/files/.svn/prop-base/hostapd.sh.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/services/hostapd/files/.svn/prop-base/wpa_supplicant-mini.config.svn-base b/package/network/services/hostapd/files/.svn/prop-base/wpa_supplicant-mini.config.svn-base
new file mode 100644
index 0000000..3160658
--- /dev/null
+++ b/package/network/services/hostapd/files/.svn/prop-base/wpa_supplicant-mini.config.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:mergeinfo
+V 0
+
+END
diff --git a/package/network/services/hostapd/files/.svn/text-base/hostapd-full.config.svn-base b/package/network/services/hostapd/files/.svn/text-base/hostapd-full.config.svn-base
new file mode 100644
index 0000000..3a0ce12
--- /dev/null
+++ b/package/network/services/hostapd/files/.svn/text-base/hostapd-full.config.svn-base
@@ -0,0 +1,164 @@
+# Example hostapd build time configuration
+#
+# This file lists the configuration options that are used when building the
+# hostapd binary. All lines starting with # are ignored. Configuration option
+# lines must be commented out complete, if they are not to be included, i.e.,
+# just setting VARIABLE=n is not disabling that variable.
+#
+# This file is included in Makefile, so variables like CFLAGS and LIBS can also
+# be modified from here. In most cass, these lines should use += in order not
+# to override previous values of the variables.
+
+# Driver interface for Host AP driver
+CONFIG_DRIVER_HOSTAP=y
+
+# Driver interface for wired authenticator
+CONFIG_DRIVER_WIRED=y
+
+# Driver interface for madwifi driver
+CONFIG_DRIVER_MADWIFI=y
+#CFLAGS += -I../../madwifi # change to the madwifi source directory
+
+# Driver interface for Prism54 driver
+#CONFIG_DRIVER_PRISM54=y
+
+# Driver interface for drivers using the nl80211 kernel interface
+CONFIG_DRIVER_NL80211=y
+# driver_nl80211.c requires a rather new libnl (version 1.1) which may not be
+# shipped with your distribution yet. If that is the case, you need to build
+# newer libnl version and point the hostapd build to use it.
+#LIBNL=/usr/src/libnl
+#CFLAGS += -I$(LIBNL)/include
+#LIBS += -L$(LIBNL)/lib
+
+# Driver interface for FreeBSD net80211 layer (e.g., Atheros driver)
+#CONFIG_DRIVER_BSD=y
+#CFLAGS += -I/usr/local/include
+#LIBS += -L/usr/local/lib
+
+# Driver interface for no driver (e.g., RADIUS server only)
+#CONFIG_DRIVER_NONE=y
+
+# IEEE 802.11F/IAPP
+CONFIG_IAPP=y
+
+# WPA2/IEEE 802.11i RSN pre-authentication
+CONFIG_RSN_PREAUTH=y
+
+# PeerKey handshake for Station to Station Link (IEEE 802.11e DLS)
+CONFIG_PEERKEY=y
+
+# IEEE 802.11w (management frame protection)
+# This version is an experimental implementation based on IEEE 802.11w/D1.0
+# draft and is subject to change since the standard has not yet been finalized.
+# Driver support is also needed for IEEE 802.11w.
+#CONFIG_IEEE80211W=y
+
+# Integrated EAP server
+CONFIG_EAP=y
+
+# EAP-MD5 for the integrated EAP server
+CONFIG_EAP_MD5=y
+
+# EAP-TLS for the integrated EAP server
+CONFIG_EAP_TLS=y
+
+# EAP-MSCHAPv2 for the integrated EAP server
+CONFIG_EAP_MSCHAPV2=y
+
+# EAP-PEAP for the integrated EAP server
+CONFIG_EAP_PEAP=y
+
+# EAP-GTC for the integrated EAP server
+CONFIG_EAP_GTC=y
+
+# EAP-TTLS for the integrated EAP server
+CONFIG_EAP_TTLS=y
+
+# EAP-SIM for the integrated EAP server
+#CONFIG_EAP_SIM=y
+
+# EAP-AKA for the integrated EAP server
+#CONFIG_EAP_AKA=y
+
+# EAP-AKA' for the integrated EAP server
+# This requires CONFIG_EAP_AKA to be enabled, too.
+#CONFIG_EAP_AKA_PRIME=y
+
+# EAP-PAX for the integrated EAP server
+#CONFIG_EAP_PAX=y
+
+# EAP-PSK for the integrated EAP server (this is _not_ needed for WPA-PSK)
+#CONFIG_EAP_PSK=y
+
+# EAP-SAKE for the integrated EAP server
+#CONFIG_EAP_SAKE=y
+
+# EAP-GPSK for the integrated EAP server
+#CONFIG_EAP_GPSK=y
+# Include support for optional SHA256 cipher suite in EAP-GPSK
+#CONFIG_EAP_GPSK_SHA256=y
+
+# EAP-FAST for the integrated EAP server
+# Note: Default OpenSSL package does not include support for all the
+# functionality needed for EAP-FAST. If EAP-FAST is enabled with OpenSSL,
+# the OpenSSL library must be patched (openssl-0.9.9-session-ticket.patch)
+# to add the needed functions.
+#CONFIG_EAP_FAST=y
+
+# Wi-Fi Protected Setup (WPS)
+#CONFIG_WPS=y
+# Enable UPnP support for external WPS Registrars
+#CONFIG_WPS_UPNP=y
+
+# EAP-IKEv2
+#CONFIG_EAP_IKEV2=y
+
+# Trusted Network Connect (EAP-TNC)
+#CONFIG_EAP_TNC=y
+
+# PKCS#12 (PFX) support (used to read private key and certificate file from
+# a file that usually has extension .p12 or .pfx)
+CONFIG_PKCS12=y
+
+# RADIUS authentication server. This provides access to the integrated EAP
+# server from external hosts using RADIUS.
+#CONFIG_RADIUS_SERVER=y
+
+# Build IPv6 support for RADIUS operations
+CONFIG_IPV6=y
+
+# IEEE Std 802.11r-2008 (Fast BSS Transition)
+#CONFIG_IEEE80211R=y
+
+# Use the hostapd's IEEE 802.11 authentication (ACL), but without
+# the IEEE 802.11 Management capability (e.g., madwifi or FreeBSD/net80211)
+#CONFIG_DRIVER_RADIUS_ACL=y
+
+# IEEE 802.11n (High Throughput) support
+CONFIG_IEEE80211N=y
+
+# Remove debugging code that is printing out debug messages to stdout.
+# This can be used to reduce the size of the hostapd considerably if debugging
+# code is not needed.
+#CONFIG_NO_STDOUT_DEBUG=y
+
+# Remove support for RADIUS accounting
+#CONFIG_NO_ACCOUNTING=y
+
+# Remove support for RADIUS
+#CONFIG_NO_RADIUS=y
+
+# Remove support for VLANs
+#CONFIG_NO_VLAN=y
+
+CONFIG_TLS=internal
+CONFIG_INTERNAL_LIBTOMMATH=y
+CONFIG_INTERNAL_AES=y
+NEED_AES_DEC=y
+
+CONFIG_NO_DUMP_STATE=y
+
+CONFIG_WPS=y
+CONFIG_FULL_DYNAMIC_VLAN=y
+
diff --git a/package/network/services/hostapd/files/.svn/text-base/hostapd-mini.config.svn-base b/package/network/services/hostapd/files/.svn/text-base/hostapd-mini.config.svn-base
new file mode 100644
index 0000000..3e94a64
--- /dev/null
+++ b/package/network/services/hostapd/files/.svn/text-base/hostapd-mini.config.svn-base
@@ -0,0 +1,157 @@
+# Example hostapd build time configuration
+#
+# This file lists the configuration options that are used when building the
+# hostapd binary. All lines starting with # are ignored. Configuration option
+# lines must be commented out complete, if they are not to be included, i.e.,
+# just setting VARIABLE=n is not disabling that variable.
+#
+# This file is included in Makefile, so variables like CFLAGS and LIBS can also
+# be modified from here. In most cass, these lines should use += in order not
+# to override previous values of the variables.
+
+# Driver interface for Host AP driver
+CONFIG_DRIVER_HOSTAP=y
+
+# Driver interface for wired authenticator
+CONFIG_DRIVER_WIRED=y
+
+# Driver interface for madwifi driver
+CONFIG_DRIVER_MADWIFI=y
+#CFLAGS += -I../../madwifi # change to the madwifi source directory
+
+# Driver interface for Prism54 driver
+#CONFIG_DRIVER_PRISM54=y
+
+# Driver interface for drivers using the nl80211 kernel interface
+CONFIG_DRIVER_NL80211=y
+# driver_nl80211.c requires a rather new libnl (version 1.1) which may not be
+# shipped with your distribution yet. If that is the case, you need to build
+# newer libnl version and point the hostapd build to use it.
+#LIBNL=/usr/src/libnl
+#CFLAGS += -I$(LIBNL)/include
+#LIBS += -L$(LIBNL)/lib
+
+# Driver interface for FreeBSD net80211 layer (e.g., Atheros driver)
+#CONFIG_DRIVER_BSD=y
+#CFLAGS += -I/usr/local/include
+#LIBS += -L/usr/local/lib
+
+# Driver interface for no driver (e.g., RADIUS server only)
+#CONFIG_DRIVER_NONE=y
+
+# IEEE 802.11F/IAPP
+# CONFIG_IAPP=y
+
+# WPA2/IEEE 802.11i RSN pre-authentication
+CONFIG_RSN_PREAUTH=y
+
+# PeerKey handshake for Station to Station Link (IEEE 802.11e DLS)
+CONFIG_PEERKEY=y
+
+# IEEE 802.11w (management frame protection)
+# This version is an experimental implementation based on IEEE 802.11w/D1.0
+# draft and is subject to change since the standard has not yet been finalized.
+# Driver support is also needed for IEEE 802.11w.
+#CONFIG_IEEE80211W=y
+
+# Integrated EAP server
+#CONFIG_EAP=y
+
+# EAP-MD5 for the integrated EAP server
+#CONFIG_EAP_MD5=y
+
+# EAP-TLS for the integrated EAP server
+#CONFIG_EAP_TLS=y
+
+# EAP-MSCHAPv2 for the integrated EAP server
+#CONFIG_EAP_MSCHAPV2=y
+
+# EAP-PEAP for the integrated EAP server
+#CONFIG_EAP_PEAP=y
+
+# EAP-GTC for the integrated EAP server
+#CONFIG_EAP_GTC=y
+
+# EAP-TTLS for the integrated EAP server
+#CONFIG_EAP_TTLS=y
+
+# EAP-SIM for the integrated EAP server
+#CONFIG_EAP_SIM=y
+
+# EAP-AKA for the integrated EAP server
+#CONFIG_EAP_AKA=y
+
+# EAP-AKA' for the integrated EAP server
+# This requires CONFIG_EAP_AKA to be enabled, too.
+#CONFIG_EAP_AKA_PRIME=y
+
+# EAP-PAX for the integrated EAP server
+#CONFIG_EAP_PAX=y
+
+# EAP-PSK for the integrated EAP server (this is _not_ needed for WPA-PSK)
+#CONFIG_EAP_PSK=y
+
+# EAP-SAKE for the integrated EAP server
+#CONFIG_EAP_SAKE=y
+
+# EAP-GPSK for the integrated EAP server
+#CONFIG_EAP_GPSK=y
+# Include support for optional SHA256 cipher suite in EAP-GPSK
+#CONFIG_EAP_GPSK_SHA256=y
+
+# EAP-FAST for the integrated EAP server
+# Note: Default OpenSSL package does not include support for all the
+# functionality needed for EAP-FAST. If EAP-FAST is enabled with OpenSSL,
+# the OpenSSL library must be patched (openssl-0.9.9-session-ticket.patch)
+# to add the needed functions.
+#CONFIG_EAP_FAST=y
+
+# Wi-Fi Protected Setup (WPS)
+#CONFIG_WPS=y
+# Enable UPnP support for external WPS Registrars
+#CONFIG_WPS_UPNP=y
+
+# EAP-IKEv2
+#CONFIG_EAP_IKEV2=y
+
+# Trusted Network Connect (EAP-TNC)
+#CONFIG_EAP_TNC=y
+
+# PKCS#12 (PFX) support (used to read private key and certificate file from
+# a file that usually has extension .p12 or .pfx)
+#CONFIG_PKCS12=y
+
+# RADIUS authentication server. This provides access to the integrated EAP
+# server from external hosts using RADIUS.
+#CONFIG_RADIUS_SERVER=y
+
+# Build IPv6 support for RADIUS operations
+#CONFIG_IPV6=y
+
+# IEEE Std 802.11r-2008 (Fast BSS Transition)
+#CONFIG_IEEE80211R=y
+
+# Use the hostapd's IEEE 802.11 authentication (ACL), but without
+# the IEEE 802.11 Management capability (e.g., madwifi or FreeBSD/net80211)
+#CONFIG_DRIVER_RADIUS_ACL=y
+
+# IEEE 802.11n (High Throughput) support
+CONFIG_IEEE80211N=y
+
+# Remove debugging code that is printing out debug messages to stdout.
+# This can be used to reduce the size of the hostapd considerably if debugging
+# code is not needed.
+#CONFIG_NO_STDOUT_DEBUG=y
+
+# Remove support for RADIUS accounting
+CONFIG_NO_ACCOUNTING=y
+
+# Remove support for RADIUS
+CONFIG_NO_RADIUS=y
+
+# Remove support for VLANs
+#CONFIG_NO_VLAN=y
+
+CONFIG_TLS=internal
+
+CONFIG_NO_DUMP_STATE=y
diff --git a/package/network/services/hostapd/files/.svn/text-base/hostapd.sh.svn-base b/package/network/services/hostapd/files/.svn/text-base/hostapd.sh.svn-base
new file mode 100644
index 0000000..00c6a09
--- /dev/null
+++ b/package/network/services/hostapd/files/.svn/text-base/hostapd.sh.svn-base
@@ -0,0 +1,301 @@
+hostapd_set_bss_options() {
+ local var="$1"
+ local vif="$2"
+ local enc wep_rekey wpa_group_rekey wpa_pair_rekey wpa_master_rekey wps_possible
+
+ config_get enc "$vif" encryption
+ config_get wep_rekey "$vif" wep_rekey # 300
+ config_get wpa_group_rekey "$vif" wpa_group_rekey # 300
+ config_get wpa_pair_rekey "$vif" wpa_pair_rekey # 300
+ config_get wpa_master_rekey "$vif" wpa_master_rekey # 640
+ config_get_bool ap_isolate "$vif" isolate 0
+ config_get_bool disassoc_low_ack "$vif" disassoc_low_ack 1
+ config_get max_num_sta "$vif" max_num_sta 0
+ config_get max_inactivity "$vif" max_inactivity 0
+ config_get_bool preamble "$vif" short_preamble 1
+
+ config_get device "$vif" device
+ config_get hwmode "$device" hwmode
+ config_get phy "$device" phy
+
+ append "$var" "ctrl_interface=/var/run/hostapd-$phy" "$N"
+
+ if [ "$ap_isolate" -gt 0 ]; then
+ append "$var" "ap_isolate=$ap_isolate" "$N"
+ fi
+ if [ "$max_num_sta" -gt 0 ]; then
+ append "$var" "max_num_sta=$max_num_sta" "$N"
+ fi
+ if [ "$max_inactivity" -gt 0 ]; then
+ append "$var" "ap_max_inactivity=$max_inactivity" "$N"
+ fi
+ append "$var" "disassoc_low_ack=$disassoc_low_ack" "$N"
+ if [ "$preamble" -gt 0 ]; then
+ append "$var" "preamble=$preamble" "$N"
+ fi
+
+ # Examples:
+ # psk-mixed/tkip => WPA1+2 PSK, TKIP
+ # wpa-psk2/tkip+aes => WPA2 PSK, CCMP+TKIP
+ # wpa2/tkip+aes => WPA2 RADIUS, CCMP+TKIP
+ # ...
+
+ # TODO: move this parsing function somewhere generic, so that
+ # later it can be reused by drivers that don't use hostapd
+
+ # crypto defaults: WPA2 vs WPA1
+ case "$enc" in
+ wpa2*|*psk2*)
+ wpa=2
+ crypto="CCMP"
+ ;;
+ *mixed*)
+ wpa=3
+ crypto="CCMP TKIP"
+ ;;
+ *)
+ wpa=1
+ crypto="TKIP"
+ ;;
+ esac
+
+ # explicit override for crypto setting
+ case "$enc" in
+ *tkip+aes|*tkip+ccmp|*aes+tkip|*ccmp+tkip) crypto="CCMP TKIP";;
+ *aes|*ccmp) crypto="CCMP";;
+ *tkip) crypto="TKIP";;
+ esac
+
+ # enforce CCMP for 11ng and 11na
+ case "$hwmode:$crypto" in
+ *ng:TKIP|*na:TKIP) crypto="CCMP TKIP";;
+ esac
+
+ # use crypto/auth settings for building the hostapd config
+ case "$enc" in
+ *psk*)
+ config_get psk "$vif" key
+ if [ ${#psk} -eq 64 ]; then
+ append "$var" "wpa_psk=$psk" "$N"
+ else
+ append "$var" "wpa_passphrase=$psk" "$N"
+ fi
+ wps_possible=1
+ [ -n "$wpa_group_rekey" ] && append "$var" "wpa_group_rekey=$wpa_group_rekey" "$N"
+ [ -n "$wpa_pair_rekey" ] && append "$var" "wpa_ptk_rekey=$wpa_pair_rekey" "$N"
+ [ -n "$wpa_master_rekey" ] && append "$var" "wpa_gmk_rekey=$wpa_master_rekey" "$N"
+ ;;
+ *wpa*)
+ # required fields? formats?
+ # hostapd is particular, maybe a default configuration for failures
+ config_get auth_server "$vif" auth_server
+ [ -z "$auth_server" ] && config_get auth_server "$vif" server
+ append "$var" "auth_server_addr=$auth_server" "$N"
+ config_get auth_port "$vif" auth_port
+ [ -z "$auth_port" ] && config_get auth_port "$vif" port
+ auth_port=${auth_port:-1812}
+ append "$var" "auth_server_port=$auth_port" "$N"
+ config_get auth_secret "$vif" auth_secret
+ [ -z "$auth_secret" ] && config_get auth_secret "$vif" key
+ append "$var" "auth_server_shared_secret=$auth_secret" "$N"
+ config_get_bool auth_cache "$vif" auth_cache 0
+ [ "$auth_cache" -gt 0 ] || append "$var" "disable_pmksa_caching=1" "$N"
+ [ "$auth_cache" -gt 0 ] || append "$var" "okc=0" "$N"
+ config_get acct_server "$vif" acct_server
+ [ -n "$acct_server" ] && append "$var" "acct_server_addr=$acct_server" "$N"
+ config_get acct_port "$vif" acct_port
+ [ -n "$acct_port" ] && acct_port=${acct_port:-1813}
+ [ -n "$acct_port" ] && append "$var" "acct_server_port=$acct_port" "$N"
+ config_get acct_secret "$vif" acct_secret
+ [ -n "$acct_secret" ] && append "$var" "acct_server_shared_secret=$acct_secret" "$N"
+ config_get nasid "$vif" nasid
+ append "$var" "nas_identifier=$nasid" "$N"
+ append "$var" "eapol_key_index_workaround=1" "$N"
+ append "$var" "ieee8021x=1" "$N"
+ append "$var" "wpa_key_mgmt=WPA-EAP" "$N"
+ [ -n "$wpa_group_rekey" ] && append "$var" "wpa_group_rekey=$wpa_group_rekey" "$N"
+ [ -n "$wpa_pair_rekey" ] && append "$var" "wpa_ptk_rekey=$wpa_pair_rekey" "$N"
+ [ -n "$wpa_master_rekey" ] && append "$var" "wpa_gmk_rekey=$wpa_master_rekey" "$N"
+ ;;
+ *wep*)
+ config_get key "$vif" key
+ key="${key:-1}"
+ case "$key" in
+ [1234])
+ for idx in 1 2 3 4; do
+ local zidx
+ zidx=$(($idx - 1))
+ config_get ckey "$vif" "key${idx}"
+ [ -n "$ckey" ] && \
+ append "$var" "wep_key${zidx}=$(prepare_key_wep "$ckey")" "$N"
+ done
+ append "$var" "wep_default_key=$((key - 1))" "$N"
+ ;;
+ *)
+ append "$var" "wep_key0=$(prepare_key_wep "$key")" "$N"
+ append "$var" "wep_default_key=0" "$N"
+ [ -n "$wep_rekey" ] && append "$var" "wep_rekey_period=$wep_rekey" "$N"
+ ;;
+ esac
+ case "$enc" in
+ *shared*)
+ auth_algs=2
+ ;;
+ *mixed*)
+ auth_algs=3
+ ;;
+ esac
+ wpa=0
+ crypto=
+ ;;
+ *)
+ wpa=0
+ crypto=
+ ;;
+ esac
+ append "$var" "auth_algs=${auth_algs:-1}" "$N"
+ append "$var" "wpa=$wpa" "$N"
+ [ -n "$crypto" ] && append "$var" "wpa_pairwise=$crypto" "$N"
+ [ -n "$wpa_group_rekey" ] && append "$var" "wpa_group_rekey=$wpa_group_rekey" "$N"
+
+ config_get ssid "$vif" ssid
+ config_get bridge "$vif" bridge
+ config_get ieee80211d "$vif" ieee80211d
+ config_get iapp_interface "$vif" iapp_interface
+
+ config_get_bool wps_pbc "$vif" wps_pushbutton 0
+ config_get_bool wps_label "$vif" wps_label 0
+
+ config_get config_methods "$vif" wps_config
+ [ "$wps_pbc" -gt 0 ] && append config_methods push_button
+
+ [ -n "$wps_possible" -a -n "$config_methods" ] && {
+ config_get device_type "$vif" wps_device_type "6-0050F204-1"
+ config_get device_name "$vif" wps_device_name "OpenWrt AP"
+ config_get manufacturer "$vif" wps_manufacturer "openwrt.org"
+
+ append "$var" "eap_server=1" "$N"
+ append "$var" "wps_state=2" "$N"
+ append "$var" "ap_setup_locked=1" "$N"
+ append "$var" "device_type=$device_type" "$N"
+ append "$var" "device_name=$device_name" "$N"
+ append "$var" "manufacturer=$manufacturer" "$N"
+ append "$var" "config_methods=$config_methods" "$N"
+ }
+
+ append "$var" "ssid=$ssid" "$N"
+ [ -n "$bridge" ] && append "$var" "bridge=$bridge" "$N"
+ [ -n "$ieee80211d" ] && append "$var" "ieee80211d=$ieee80211d" "$N"
+ [ -n "$iapp_interface" ] && append "$var" iapp_interface=$(uci_get_state network "$iapp_interface" ifname "$iapp_interface") "$N"
+
+ if [ "$wpa" -ge "2" ]
+ then
+ # RSN -> allow preauthentication
+ config_get_bool rsn_preauth "$vif" rsn_preauth "$auth_cache"
+ if [ -n "$bridge" -a "$rsn_preauth" = 1 ]
+ then
+ append "$var" "rsn_preauth=1" "$N"
+ append "$var" "rsn_preauth_interfaces=$bridge" "$N"
+ fi
+
+ # RSN -> allow management frame protection
+ config_get ieee80211w "$vif" ieee80211w
+ case "$ieee80211w" in
+ [012])
+ append "$var" "ieee80211w=$ieee80211w" "$N"
+ [ "$ieee80211w" -gt "0" ] && {
+ config_get ieee80211w_max_timeout "$vif" ieee80211w_max_timeout
+ config_get ieee80211w_retry_timeout "$vif" ieee80211w_retry_timeout
+ [ -n "$ieee80211w_max_timeout" ] && \
+ append "$var" "assoc_sa_query_max_timeout=$ieee80211w_max_timeout" "$N"
+ [ -n "$ieee80211w_retry_timeout" ] && \
+ append "$var" "assoc_sa_query_retry_timeout=$ieee80211w_retry_timeout" "$N"
+ }
+ ;;
+ esac
+ fi
+
+ config_get macfilter "$vif" macfilter
+ macfile="/var/run/hostapd-$ifname.maclist"
+ [ -e "$macfile" ] && rm -f "$macfile"
+
+ case "$macfilter" in
+ allow)
+ append "$var" "macaddr_acl=1" "$N"
+ append "$var" "accept_mac_file=$macfile" "$N"
+ ;;
+ deny)
+ append "$var" "macaddr_acl=0" "$N"
+ append "$var" "deny_mac_file=$macfile" "$N"
+ ;;
+ esac
+ config_get maclist "$vif" maclist
+ [ -n "$maclist" ] && {
+ for mac in $maclist; do
+ echo "$mac" >> $macfile
+ done
+ }
+}
+
+hostapd_set_log_options() {
+ local var="$1"
+ local cfg="$2"
+ local log_level log_80211 log_8021x log_radius log_wpa log_driver log_iapp log_mlme
+
+ config_get log_level "$cfg" log_level 2
+
+ config_get_bool log_80211 "$cfg" log_80211 1
+ config_get_bool log_8021x "$cfg" log_8021x 1
+ config_get_bool log_radius "$cfg" log_radius 1
+ config_get_bool log_wpa "$cfg" log_wpa 1
+ config_get_bool log_driver "$cfg" log_driver 1
+ config_get_bool log_iapp "$cfg" log_iapp 1
+ config_get_bool log_mlme "$cfg" log_mlme 1
+
+ local log_mask=$(( \
+ ($log_80211 << 0) | \
+ ($log_8021x << 1) | \
+ ($log_radius << 2) | \
+ ($log_wpa << 3) | \
+ ($log_driver << 4) | \
+ ($log_iapp << 5) | \
+ ($log_mlme << 6) \
+ ))
+
+ append "$var" "logger_syslog=$log_mask" "$N"
+ append "$var" "logger_syslog_level=$log_level" "$N"
+ append "$var" "logger_stdout=$log_mask" "$N"
+ append "$var" "logger_stdout_level=$log_level" "$N"
+}
+
+hostapd_setup_vif() {
+ local vif="$1"
+ local driver="$2"
+ local ifname device channel hwmode
+
+ hostapd_cfg=
+
+ config_get ifname "$vif" ifname
+ config_get device "$vif" device
+ config_get channel "$device" channel
+ config_get hwmode "$device" hwmode
+
+ hostapd_set_log_options hostapd_cfg "$device"
+ hostapd_set_bss_options hostapd_cfg "$vif"
+
+ case "$hwmode" in
+ *bg|*gdt|*gst|*fh) hwmode=g;;
+ *adt|*ast) hwmode=a;;
+ esac
+ [ "$channel" = auto ] && channel=
+ [ -n "$channel" -a -z "$hwmode" ] && wifi_fixup_hwmode "$device"
+ cat > /var/run/hostapd-$ifname.conf <<EOF
+driver=$driver
+interface=$ifname
+${hwmode:+hw_mode=${hwmode#11}}
+${channel:+channel=$channel}
+$hostapd_cfg
+EOF
+ hostapd -P /var/run/wifi-$ifname.pid -B /var/run/hostapd-$ifname.conf
+}
+
diff --git a/package/network/services/hostapd/files/.svn/text-base/multicall.c.svn-base b/package/network/services/hostapd/files/.svn/text-base/multicall.c.svn-base
new file mode 100644
index 0000000..c8e814b
--- /dev/null
+++ b/package/network/services/hostapd/files/.svn/text-base/multicall.c.svn-base
@@ -0,0 +1,28 @@
+#include <stdio.h>
+#include <string.h>
+#include <stdbool.h>
+
+extern int hostapd_main(int argc, char **argv);
+extern int wpa_supplicant_main(int argc, char **argv);
+
+int main(int argc, char **argv)
+{
+ bool restart = false;
+ const char *prog = argv[0];
+
+restart:
+ if (strstr(argv[0], "hostapd"))
+ return hostapd_main(argc, argv);
+ else if (strstr(argv[0], "wpa_supplicant"))
+ return wpa_supplicant_main(argc, argv);
+
+ if (!restart && argc > 1) {
+ argv++;
+ argc--;
+ restart = true;
+ goto restart;
+ }
+
+ fprintf(stderr, "Invalid command.\nUsage: %s wpa_supplicant|hostapd [<arguments>]\n", prog);
+ return 255;
+}
diff --git a/package/network/services/hostapd/files/.svn/text-base/wpa_supplicant-full.config.svn-base b/package/network/services/hostapd/files/.svn/text-base/wpa_supplicant-full.config.svn-base
new file mode 100644
index 0000000..f5abbad
--- /dev/null
+++ b/package/network/services/hostapd/files/.svn/text-base/wpa_supplicant-full.config.svn-base
@@ -0,0 +1,408 @@
+# Example wpa_supplicant build time configuration
+#
+# This file lists the configuration options that are used when building the
+# hostapd binary. All lines starting with # are ignored. Configuration option
+# lines must be commented out complete, if they are not to be included, i.e.,
+# just setting VARIABLE=n is not disabling that variable.
+#
+# This file is included in Makefile, so variables like CFLAGS and LIBS can also
+# be modified from here. In most cases, these lines should use += in order not
+# to override previous values of the variables.
+
+
+# Uncomment following two lines and fix the paths if you have installed OpenSSL
+# or GnuTLS in non-default location
+#CFLAGS += -I/usr/local/openssl/include
+#LIBS += -L/usr/local/openssl/lib
+
+# Some Red Hat versions seem to include kerberos header files from OpenSSL, but
+# the kerberos files are not in the default include path. Following line can be
+# used to fix build issues on such systems (krb5.h not found).
+#CFLAGS += -I/usr/include/kerberos
+
+# Example configuration for various cross-compilation platforms
+
+#### sveasoft (e.g., for Linksys WRT54G) ######################################
+#CC=mipsel-uclibc-gcc
+#CC=/opt/brcm/hndtools-mipsel-uclibc/bin/mipsel-uclibc-gcc
+#CFLAGS += -Os
+#CPPFLAGS += -I../src/include -I../../src/router/openssl/include
+#LIBS += -L/opt/brcm/hndtools-mipsel-uclibc-0.9.19/lib -lssl
+###############################################################################
+
+#### openwrt (e.g., for Linksys WRT54G) #######################################
+#CC=mipsel-uclibc-gcc
+#CC=/opt/brcm/hndtools-mipsel-uclibc/bin/mipsel-uclibc-gcc
+#CFLAGS += -Os
+#CPPFLAGS=-I../src/include -I../openssl-0.9.7d/include \
+# -I../WRT54GS/release/src/include
+#LIBS = -lssl
+###############################################################################
+
+
+# Driver interface for Host AP driver
+CONFIG_DRIVER_HOSTAP=y
+
+# Driver interface for Agere driver
+#CONFIG_DRIVER_HERMES=y
+# Change include directories to match with the local setup
+#CFLAGS += -I../../hcf -I../../include -I../../include/hcf
+#CFLAGS += -I../../include/wireless
+
+# Driver interface for madwifi driver
+# Deprecated; use CONFIG_DRIVER_WEXT=y instead.
+#CONFIG_DRIVER_MADWIFI=y
+# Set include directory to the madwifi source tree
+#CFLAGS += -I../../madwifi
+
+# Driver interface for ndiswrapper
+# Deprecated; use CONFIG_DRIVER_WEXT=y instead.
+#CONFIG_DRIVER_NDISWRAPPER=y
+
+# Driver interface for Atmel driver
+# CONFIG_DRIVER_ATMEL=y
+
+# Driver interface for old Broadcom driver
+# Please note that the newer Broadcom driver ("hybrid Linux driver") supports
+# Linux wireless extensions and does not need (or even work) with the old
+# driver wrapper. Use CONFIG_DRIVER_WEXT=y with that driver.
+#CONFIG_DRIVER_BROADCOM=y
+# Example path for wlioctl.h; change to match your configuration
+#CFLAGS += -I/opt/WRT54GS/release/src/include
+
+# Driver interface for Intel ipw2100/2200 driver
+# Deprecated; use CONFIG_DRIVER_WEXT=y instead.
+#CONFIG_DRIVER_IPW=y
+
+# Driver interface for Ralink driver
+#CONFIG_DRIVER_RALINK=y
+
+# Driver interface for generic Linux wireless extensions
+CONFIG_DRIVER_WEXT=y
+
+# Driver interface for Linux drivers using the nl80211 kernel interface
+CONFIG_DRIVER_NL80211=y
+
+# Driver interface for FreeBSD net80211 layer (e.g., Atheros driver)
+#CONFIG_DRIVER_BSD=y
+#CFLAGS += -I/usr/local/include
+#LIBS += -L/usr/local/lib
+#LIBS_p += -L/usr/local/lib
+#LIBS_c += -L/usr/local/lib
+
+# Driver interface for Windows NDIS
+#CONFIG_DRIVER_NDIS=y
+#CFLAGS += -I/usr/include/w32api/ddk
+#LIBS += -L/usr/local/lib
+# For native build using mingw
+#CONFIG_NATIVE_WINDOWS=y
+# Additional directories for cross-compilation on Linux host for mingw target
+#CFLAGS += -I/opt/mingw/mingw32/include/ddk
+#LIBS += -L/opt/mingw/mingw32/lib
+#CC=mingw32-gcc
+# By default, driver_ndis uses WinPcap for low-level operations. This can be
+# replaced with the following option which replaces WinPcap calls with NDISUIO.
+# However, this requires that WZC is disabled (net stop wzcsvc) before starting
+# wpa_supplicant.
+# CONFIG_USE_NDISUIO=y
+
+# Driver interface for development testing
+#CONFIG_DRIVER_TEST=y
+
+# Include client MLME (management frame processing) for test driver
+# This can be used to test MLME operations in hostapd with the test interface.
+# space.
+#CONFIG_CLIENT_MLME=y
+
+# Driver interface for wired Ethernet drivers
+CONFIG_DRIVER_WIRED=y
+
+# Driver interface for the Broadcom RoboSwitch family
+#CONFIG_DRIVER_ROBOSWITCH=y
+
+# Driver interface for no driver (e.g., WPS ER only)
+#CONFIG_DRIVER_NONE=y
+
+# Enable IEEE 802.1X Supplicant (automatically included if any EAP method is
+# included)
+CONFIG_IEEE8021X_EAPOL=y
+
+# EAP-MD5
+CONFIG_EAP_MD5=y
+
+# EAP-MSCHAPv2
+CONFIG_EAP_MSCHAPV2=y
+
+# EAP-TLS
+CONFIG_EAP_TLS=y
+
+# EAL-PEAP
+CONFIG_EAP_PEAP=y
+
+# EAP-TTLS
+CONFIG_EAP_TTLS=y
+
+# EAP-FAST
+# Note: Default OpenSSL package does not include support for all the
+# functionality needed for EAP-FAST. If EAP-FAST is enabled with OpenSSL,
+# the OpenSSL library must be patched (openssl-0.9.8d-tls-extensions.patch)
+# to add the needed functions.
+#CONFIG_EAP_FAST=y
+
+# EAP-GTC
+CONFIG_EAP_GTC=y
+
+# EAP-OTP
+CONFIG_EAP_OTP=y
+
+# EAP-SIM (enable CONFIG_PCSC, if EAP-SIM is used)
+#CONFIG_EAP_SIM=y
+
+# EAP-PSK (experimental; this is _not_ needed for WPA-PSK)
+#CONFIG_EAP_PSK=y
+
+# EAP-PAX
+#CONFIG_EAP_PAX=y
+
+# LEAP
+CONFIG_EAP_LEAP=y
+
+# EAP-AKA (enable CONFIG_PCSC, if EAP-AKA is used)
+#CONFIG_EAP_AKA=y
+
+# EAP-AKA' (enable CONFIG_PCSC, if EAP-AKA' is used).
+# This requires CONFIG_EAP_AKA to be enabled, too.
+#CONFIG_EAP_AKA_PRIME=y
+
+# Enable USIM simulator (Milenage) for EAP-AKA
+#CONFIG_USIM_SIMULATOR=y
+
+# EAP-SAKE
+#CONFIG_EAP_SAKE=y
+
+# EAP-GPSK
+#CONFIG_EAP_GPSK=y
+# Include support for optional SHA256 cipher suite in EAP-GPSK
+#CONFIG_EAP_GPSK_SHA256=y
+
+# EAP-TNC and related Trusted Network Connect support (experimental)
+#CONFIG_EAP_TNC=y
+
+# Wi-Fi Protected Setup (WPS)
+CONFIG_WPS=y
+
+# EAP-IKEv2
+#CONFIG_EAP_IKEV2=y
+
+# PKCS#12 (PFX) support (used to read private key and certificate file from
+# a file that usually has extension .p12 or .pfx)
+CONFIG_PKCS12=y
+
+# Smartcard support (i.e., private key on a smartcard), e.g., with openssl
+# engine.
+CONFIG_SMARTCARD=y
+
+# PC/SC interface for smartcards (USIM, GSM SIM)
+# Enable this if EAP-SIM or EAP-AKA is included
+#CONFIG_PCSC=y
+
+# Development testing
+#CONFIG_EAPOL_TEST=y
+
+# Select control interface backend for external programs, e.g, wpa_cli:
+# unix = UNIX domain sockets (default for Linux/*BSD)
+# udp = UDP sockets using localhost (127.0.0.1)
+# named_pipe = Windows Named Pipe (default for Windows)
+# y = use default (backwards compatibility)
+# If this option is commented out, control interface is not included in the
+# build.
+CONFIG_CTRL_IFACE=y
+
+# Include support for GNU Readline and History Libraries in wpa_cli.
+# When building a wpa_cli binary for distribution, please note that these
+# libraries are licensed under GPL and as such, BSD license may not apply for
+# the resulting binary.
+#CONFIG_READLINE=y
+
+# Remove debugging code that is printing out debug message to stdout.
+# This can be used to reduce the size of the wpa_supplicant considerably
+# if debugging code is not needed. The size reduction can be around 35%
+# (e.g., 90 kB).
+#CONFIG_NO_STDOUT_DEBUG=y
+
+# Remove WPA support, e.g., for wired-only IEEE 802.1X supplicant, to save
+# 35-50 kB in code size.
+#CONFIG_NO_WPA=y
+
+# Remove WPA2 support. This allows WPA to be used, but removes WPA2 code to
+# save about 1 kB in code size when building only WPA-Personal (no EAP support)
+# or 6 kB if building for WPA-Enterprise.
+#CONFIG_NO_WPA2=y
+
+# Remove IEEE 802.11i/WPA-Personal ASCII passphrase support
+# This option can be used to reduce code size by removing support for
+# converting ASCII passphrases into PSK. If this functionality is removed, the
+# PSK can only be configured as the 64-octet hexstring (e.g., from
+# wpa_passphrase). This saves about 0.5 kB in code size.
+#CONFIG_NO_WPA_PASSPHRASE=y
+
+# Disable scan result processing (ap_mode=1) to save code size by about 1 kB.
+# This can be used if ap_scan=1 mode is never enabled.
+#CONFIG_NO_SCAN_PROCESSING=y
+
+# Select configuration backend:
+# file = text file (e.g., wpa_supplicant.conf; note: the configuration file
+# path is given on command line, not here; this option is just used to
+# select the backend that allows configuration files to be used)
+# winreg = Windows registry (see win_example.reg for an example)
+CONFIG_BACKEND=file
+
+# Remove configuration write functionality (i.e., to allow the configuration
+# file to be updated based on runtime configuration changes). The runtime
+# configuration can still be changed, the changes are just not going to be
+# persistent over restarts. This option can be used to reduce code size by
+# about 3.5 kB.
+#CONFIG_NO_CONFIG_WRITE=y
+
+# Remove support for configuration blobs to reduce code size by about 1.5 kB.
+#CONFIG_NO_CONFIG_BLOBS=y
+
+# Select program entry point implementation:
+# main = UNIX/POSIX like main() function (default)
+# main_winsvc = Windows service (read parameters from registry)
+# main_none = Very basic example (development use only)
+#CONFIG_MAIN=main
+
+# Select wrapper for operatins system and C library specific functions
+# unix = UNIX/POSIX like systems (default)
+# win32 = Windows systems
+# none = Empty template
+#CONFIG_OS=unix
+
+# Select event loop implementation
+# eloop = select() loop (default)
+# eloop_win = Windows events and WaitForMultipleObject() loop
+# eloop_none = Empty template
+#CONFIG_ELOOP=eloop
+
+# Select layer 2 packet implementation
+# linux = Linux packet socket (default)
+# pcap = libpcap/libdnet/WinPcap
+# freebsd = FreeBSD libpcap
+# winpcap = WinPcap with receive thread
+# ndis = Windows NDISUIO (note: requires CONFIG_USE_NDISUIO=y)
+# none = Empty template
+#CONFIG_L2_PACKET=linux
+
+# PeerKey handshake for Station to Station Link (IEEE 802.11e DLS)
+CONFIG_PEERKEY=y
+
+# IEEE 802.11w (management frame protection)
+# This version is an experimental implementation based on IEEE 802.11w/D1.0
+# draft and is subject to change since the standard has not yet been finalized.
+# Driver support is also needed for IEEE 802.11w.
+CONFIG_IEEE80211W=y
+
+# Select TLS implementation
+# openssl = OpenSSL (default)
+# gnutls = GnuTLS (needed for TLS/IA, see also CONFIG_GNUTLS_EXTRA)
+# internal = Internal TLSv1 implementation (experimental)
+# none = Empty template
+CONFIG_TLS=internal
+
+# Whether to enable TLS/IA support, which is required for EAP-TTLSv1.
+# You need CONFIG_TLS=gnutls for this to have any effect. Please note that
+# even though the core GnuTLS library is released under LGPL, this extra
+# library uses GPL and as such, the terms of GPL apply to the combination
+# of wpa_supplicant and GnuTLS if this option is enabled. BSD license may not
+# apply for distribution of the resulting binary.
+#CONFIG_GNUTLS_EXTRA=y
+
+# If CONFIG_TLS=internal is used, additional library and include paths are
+# needed for LibTomMath. Alternatively, an integrated, minimal version of
+# LibTomMath can be used. See beginning of libtommath.c for details on benefits
+# and drawbacks of this option.
+CONFIG_INTERNAL_LIBTOMMATH=y
+#ifndef CONFIG_INTERNAL_LIBTOMMATH
+#LTM_PATH=/usr/src/libtommath-0.39
+#CFLAGS += -I$(LTM_PATH)
+#LIBS += -L$(LTM_PATH)
+#LIBS_p += -L$(LTM_PATH)
+#endif
+# At the cost of about 4 kB of additional binary size, the internal LibTomMath
+# can be configured to include faster routines for exptmod, sqr, and div to
+# speed up DH and RSA calculation considerably
+CONFIG_INTERNAL_LIBTOMMATH_FAST=y
+
+# Include NDIS event processing through WMI into wpa_supplicant/wpasvc.
+# This is only for Windows builds and requires WMI-related header files and
+# WbemUuid.Lib from Platform SDK even when building with MinGW.
+#CONFIG_NDIS_EVENTS_INTEGRATED=y
+#PLATFORMSDKLIB="/opt/Program Files/Microsoft Platform SDK/Lib"
+
+# Add support for old DBus control interface
+# (fi.epitest.hostap.WPASupplicant)
+#CONFIG_CTRL_IFACE_DBUS=y
+
+# Add support for new DBus control interface
+# (fi.w1.hostap.wpa_supplicant1)
+#CONFIG_CTRL_IFACE_DBUS_NEW=y
+
+# Add introspection support for new DBus control interface
+#CONFIG_CTRL_IFACE_DBUS_INTRO=y
+
+# Add support for loading EAP methods dynamically as shared libraries.
+# When this option is enabled, each EAP method can be either included
+# statically (CONFIG_EAP_<method>=y) or dynamically (CONFIG_EAP_<method>=dyn).
+# Dynamic EAP methods are build as shared objects (eap_*.so) and they need to
+# be loaded in the beginning of the wpa_supplicant configuration file
+# (see load_dynamic_eap parameter in the example file) before being used in
+# the network blocks.
+#
+# Note that some shared parts of EAP methods are included in the main program
+# and in order to be able to use dynamic EAP methods using these parts, the
+# main program must have been build with the EAP method enabled (=y or =dyn).
+# This means that EAP-TLS/PEAP/TTLS/FAST cannot be added as dynamic libraries
+# unless at least one of them was included in the main build to force inclusion
+# of the shared code. Similarly, at least one of EAP-SIM/AKA must be included
+# in the main build to be able to load these methods dynamically.
+#
+# Please also note that using dynamic libraries will increase the total binary
+# size. Thus, it may not be the best option for targets that have limited
+# amount of memory/flash.
+#CONFIG_DYNAMIC_EAP_METHODS=y
+
+# IEEE Std 802.11r-2008 (Fast BSS Transition)
+#CONFIG_IEEE80211R=y
+
+# Add support for writing debug log to a file (/tmp/wpa_supplicant-log-#.txt)
+#CONFIG_DEBUG_FILE=y
+
+# Enable privilege separation (see README 'Privilege separation' for details)
+#CONFIG_PRIVSEP=y
+
+# Enable mitigation against certain attacks against TKIP by delaying Michael
+# MIC error reports by a random amount of time between 0 and 60 seconds
+#CONFIG_DELAYED_MIC_ERROR_REPORT=y
+
+# Enable tracing code for developer debugging
+# This tracks use of memory allocations and other registrations and reports
+# incorrect use with a backtrace of call (or allocation) location.
+#CONFIG_WPA_TRACE=y
+# For BSD, comment out these.
+#LIBS += -lexecinfo
+#LIBS_p += -lexecinfo
+#LIBS_c += -lexecinfo
+
+# Use libbfd to get more details for developer debugging
+# This enables use of libbfd to get more detailed symbols for the backtraces
+# generated by CONFIG_WPA_TRACE=y.
+#CONFIG_WPA_TRACE_BFD=y
+# For BSD, comment out these.
+#LIBS += -lbfd -liberty -lz
+#LIBS_p += -lbfd -liberty -lz
+#LIBS_c += -lbfd -liberty -lz
+
+NEED_80211_COMMON=y
+
+CONFIG_IBSS_RSN=y
diff --git a/package/network/services/hostapd/files/.svn/text-base/wpa_supplicant-mini.config.svn-base b/package/network/services/hostapd/files/.svn/text-base/wpa_supplicant-mini.config.svn-base
new file mode 100644
index 0000000..772e1d9
--- /dev/null
+++ b/package/network/services/hostapd/files/.svn/text-base/wpa_supplicant-mini.config.svn-base
@@ -0,0 +1,406 @@
+# Example wpa_supplicant build time configuration
+#
+# This file lists the configuration options that are used when building the
+# hostapd binary. All lines starting with # are ignored. Configuration option
+# lines must be commented out complete, if they are not to be included, i.e.,
+# just setting VARIABLE=n is not disabling that variable.
+#
+# This file is included in Makefile, so variables like CFLAGS and LIBS can also
+# be modified from here. In most cases, these lines should use += in order not
+# to override previous values of the variables.
+
+
+# Uncomment following two lines and fix the paths if you have installed OpenSSL
+# or GnuTLS in non-default location
+#CFLAGS += -I/usr/local/openssl/include
+#LIBS += -L/usr/local/openssl/lib
+
+# Some Red Hat versions seem to include kerberos header files from OpenSSL, but
+# the kerberos files are not in the default include path. Following line can be
+# used to fix build issues on such systems (krb5.h not found).
+#CFLAGS += -I/usr/include/kerberos
+
+# Example configuration for various cross-compilation platforms
+
+#### sveasoft (e.g., for Linksys WRT54G) ######################################
+#CC=mipsel-uclibc-gcc
+#CC=/opt/brcm/hndtools-mipsel-uclibc/bin/mipsel-uclibc-gcc
+#CFLAGS += -Os
+#CPPFLAGS += -I../src/include -I../../src/router/openssl/include
+#LIBS += -L/opt/brcm/hndtools-mipsel-uclibc-0.9.19/lib -lssl
+###############################################################################
+
+#### openwrt (e.g., for Linksys WRT54G) #######################################
+#CC=mipsel-uclibc-gcc
+#CC=/opt/brcm/hndtools-mipsel-uclibc/bin/mipsel-uclibc-gcc
+#CFLAGS += -Os
+#CPPFLAGS=-I../src/include -I../openssl-0.9.7d/include \
+# -I../WRT54GS/release/src/include
+#LIBS = -lssl
+###############################################################################
+
+
+# Driver interface for Host AP driver
+CONFIG_DRIVER_HOSTAP=y
+
+# Driver interface for Agere driver
+#CONFIG_DRIVER_HERMES=y
+# Change include directories to match with the local setup
+#CFLAGS += -I../../hcf -I../../include -I../../include/hcf
+#CFLAGS += -I../../include/wireless
+
+# Driver interface for madwifi driver
+# Deprecated; use CONFIG_DRIVER_WEXT=y instead.
+#CONFIG_DRIVER_MADWIFI=y
+# Set include directory to the madwifi source tree
+#CFLAGS += -I../../madwifi
+
+# Driver interface for ndiswrapper
+# Deprecated; use CONFIG_DRIVER_WEXT=y instead.
+#CONFIG_DRIVER_NDISWRAPPER=y
+
+# Driver interface for Atmel driver
+# CONFIG_DRIVER_ATMEL=y
+
+# Driver interface for old Broadcom driver
+# Please note that the newer Broadcom driver ("hybrid Linux driver") supports
+# Linux wireless extensions and does not need (or even work) with the old
+# driver wrapper. Use CONFIG_DRIVER_WEXT=y with that driver.
+#CONFIG_DRIVER_BROADCOM=y
+# Example path for wlioctl.h; change to match your configuration
+#CFLAGS += -I/opt/WRT54GS/release/src/include
+
+# Driver interface for Intel ipw2100/2200 driver
+# Deprecated; use CONFIG_DRIVER_WEXT=y instead.
+#CONFIG_DRIVER_IPW=y
+
+# Driver interface for Ralink driver
+#CONFIG_DRIVER_RALINK=y
+
+# Driver interface for generic Linux wireless extensions
+CONFIG_DRIVER_WEXT=y
+
+# Driver interface for Linux drivers using the nl80211 kernel interface
+CONFIG_DRIVER_NL80211=y
+
+# Driver interface for FreeBSD net80211 layer (e.g., Atheros driver)
+#CONFIG_DRIVER_BSD=y
+#CFLAGS += -I/usr/local/include
+#LIBS += -L/usr/local/lib
+#LIBS_p += -L/usr/local/lib
+#LIBS_c += -L/usr/local/lib
+
+# Driver interface for Windows NDIS
+#CONFIG_DRIVER_NDIS=y
+#CFLAGS += -I/usr/include/w32api/ddk
+#LIBS += -L/usr/local/lib
+# For native build using mingw
+#CONFIG_NATIVE_WINDOWS=y
+# Additional directories for cross-compilation on Linux host for mingw target
+#CFLAGS += -I/opt/mingw/mingw32/include/ddk
+#LIBS += -L/opt/mingw/mingw32/lib
+#CC=mingw32-gcc
+# By default, driver_ndis uses WinPcap for low-level operations. This can be
+# replaced with the following option which replaces WinPcap calls with NDISUIO.
+# However, this requires that WZC is disabled (net stop wzcsvc) before starting
+# wpa_supplicant.
+# CONFIG_USE_NDISUIO=y
+
+# Driver interface for development testing
+#CONFIG_DRIVER_TEST=y
+
+# Include client MLME (management frame processing) for test driver
+# This can be used to test MLME operations in hostapd with the test interface.
+# space.
+#CONFIG_CLIENT_MLME=y
+
+# Driver interface for wired Ethernet drivers
+CONFIG_DRIVER_WIRED=y
+
+# Driver interface for the Broadcom RoboSwitch family
+#CONFIG_DRIVER_ROBOSWITCH=y
+
+# Driver interface for no driver (e.g., WPS ER only)
+#CONFIG_DRIVER_NONE=y
+
+# Enable IEEE 802.1X Supplicant (automatically included if any EAP method is
+# included)
+# CONFIG_IEEE8021X_EAPOL=y
+
+# EAP-MD5
+# CONFIG_EAP_MD5=y
+
+# EAP-MSCHAPv2
+# CONFIG_EAP_MSCHAPV2=y
+
+# EAP-TLS
+# CONFIG_EAP_TLS=y
+
+# EAL-PEAP
+# CONFIG_EAP_PEAP=y
+
+# EAP-TTLS
+# CONFIG_EAP_TTLS=y
+
+# EAP-FAST
+# Note: Default OpenSSL package does not include support for all the
+# functionality needed for EAP-FAST. If EAP-FAST is enabled with OpenSSL,
+# the OpenSSL library must be patched (openssl-0.9.8d-tls-extensions.patch)
+# to add the needed functions.
+#CONFIG_EAP_FAST=y
+
+# EAP-GTC
+# CONFIG_EAP_GTC=y
+
+# EAP-OTP
+# CONFIG_EAP_OTP=y
+
+# EAP-SIM (enable CONFIG_PCSC, if EAP-SIM is used)
+#CONFIG_EAP_SIM=y
+
+# EAP-PSK (experimental; this is _not_ needed for WPA-PSK)
+#CONFIG_EAP_PSK=y
+
+# EAP-PAX
+#CONFIG_EAP_PAX=y
+
+# LEAP
+# CONFIG_EAP_LEAP=y
+
+# EAP-AKA (enable CONFIG_PCSC, if EAP-AKA is used)
+#CONFIG_EAP_AKA=y
+
+# EAP-AKA' (enable CONFIG_PCSC, if EAP-AKA' is used).
+# This requires CONFIG_EAP_AKA to be enabled, too.
+#CONFIG_EAP_AKA_PRIME=y
+
+# Enable USIM simulator (Milenage) for EAP-AKA
+#CONFIG_USIM_SIMULATOR=y
+
+# EAP-SAKE
+#CONFIG_EAP_SAKE=y
+
+# EAP-GPSK
+#CONFIG_EAP_GPSK=y
+# Include support for optional SHA256 cipher suite in EAP-GPSK
+#CONFIG_EAP_GPSK_SHA256=y
+
+# EAP-TNC and related Trusted Network Connect support (experimental)
+#CONFIG_EAP_TNC=y
+
+# Wi-Fi Protected Setup (WPS)
+#CONFIG_WPS=y
+
+# EAP-IKEv2
+#CONFIG_EAP_IKEV2=y
+
+# PKCS#12 (PFX) support (used to read private key and certificate file from
+# a file that usually has extension .p12 or .pfx)
+# CONFIG_PKCS12=y
+
+# Smartcard support (i.e., private key on a smartcard), e.g., with openssl
+# engine.
+# CONFIG_SMARTCARD=y
+
+# PC/SC interface for smartcards (USIM, GSM SIM)
+# Enable this if EAP-SIM or EAP-AKA is included
+#CONFIG_PCSC=y
+
+# Development testing
+#CONFIG_EAPOL_TEST=y
+
+# Select control interface backend for external programs, e.g, wpa_cli:
+# unix = UNIX domain sockets (default for Linux/*BSD)
+# udp = UDP sockets using localhost (127.0.0.1)
+# named_pipe = Windows Named Pipe (default for Windows)
+# y = use default (backwards compatibility)
+# If this option is commented out, control interface is not included in the
+# build.
+CONFIG_CTRL_IFACE=y
+
+# Include support for GNU Readline and History Libraries in wpa_cli.
+# When building a wpa_cli binary for distribution, please note that these
+# libraries are licensed under GPL and as such, BSD license may not apply for
+# the resulting binary.
+#CONFIG_READLINE=y
+
+# Remove debugging code that is printing out debug message to stdout.
+# This can be used to reduce the size of the wpa_supplicant considerably
+# if debugging code is not needed. The size reduction can be around 35%
+# (e.g., 90 kB).
+#CONFIG_NO_STDOUT_DEBUG=y
+
+# Remove WPA support, e.g., for wired-only IEEE 802.1X supplicant, to save
+# 35-50 kB in code size.
+#CONFIG_NO_WPA=y
+
+# Remove WPA2 support. This allows WPA to be used, but removes WPA2 code to
+# save about 1 kB in code size when building only WPA-Personal (no EAP support)
+# or 6 kB if building for WPA-Enterprise.
+#CONFIG_NO_WPA2=y
+
+# Remove IEEE 802.11i/WPA-Personal ASCII passphrase support
+# This option can be used to reduce code size by removing support for
+# converting ASCII passphrases into PSK. If this functionality is removed, the
+# PSK can only be configured as the 64-octet hexstring (e.g., from
+# wpa_passphrase). This saves about 0.5 kB in code size.
+#CONFIG_NO_WPA_PASSPHRASE=y
+
+# Disable scan result processing (ap_mode=1) to save code size by about 1 kB.
+# This can be used if ap_scan=1 mode is never enabled.
+#CONFIG_NO_SCAN_PROCESSING=y
+
+# Select configuration backend:
+# file = text file (e.g., wpa_supplicant.conf; note: the configuration file
+# path is given on command line, not here; this option is just used to
+# select the backend that allows configuration files to be used)
+# winreg = Windows registry (see win_example.reg for an example)
+CONFIG_BACKEND=file
+
+# Remove configuration write functionality (i.e., to allow the configuration
+# file to be updated based on runtime configuration changes). The runtime
+# configuration can still be changed, the changes are just not going to be
+# persistent over restarts. This option can be used to reduce code size by
+# about 3.5 kB.
+#CONFIG_NO_CONFIG_WRITE=y
+
+# Remove support for configuration blobs to reduce code size by about 1.5 kB.
+#CONFIG_NO_CONFIG_BLOBS=y
+
+# Select program entry point implementation:
+# main = UNIX/POSIX like main() function (default)
+# main_winsvc = Windows service (read parameters from registry)
+# main_none = Very basic example (development use only)
+#CONFIG_MAIN=main
+
+# Select wrapper for operatins system and C library specific functions
+# unix = UNIX/POSIX like systems (default)
+# win32 = Windows systems
+# none = Empty template
+#CONFIG_OS=unix
+
+# Select event loop implementation
+# eloop = select() loop (default)
+# eloop_win = Windows events and WaitForMultipleObject() loop
+# eloop_none = Empty template
+#CONFIG_ELOOP=eloop
+
+# Select layer 2 packet implementation
+# linux = Linux packet socket (default)
+# pcap = libpcap/libdnet/WinPcap
+# freebsd = FreeBSD libpcap
+# winpcap = WinPcap with receive thread
+# ndis = Windows NDISUIO (note: requires CONFIG_USE_NDISUIO=y)
+# none = Empty template
+#CONFIG_L2_PACKET=linux
+
+# PeerKey handshake for Station to Station Link (IEEE 802.11e DLS)
+# CONFIG_PEERKEY=y
+
+# IEEE 802.11w (management frame protection)
+# This version is an experimental implementation based on IEEE 802.11w/D1.0
+# draft and is subject to change since the standard has not yet been finalized.
+# Driver support is also needed for IEEE 802.11w.
+#CONFIG_IEEE80211W=y
+
+# Select TLS implementation
+# openssl = OpenSSL (default)
+# gnutls = GnuTLS (needed for TLS/IA, see also CONFIG_GNUTLS_EXTRA)
+# internal = Internal TLSv1 implementation (experimental)
+# none = Empty template
+CONFIG_TLS=internal
+
+# Whether to enable TLS/IA support, which is required for EAP-TTLSv1.
+# You need CONFIG_TLS=gnutls for this to have any effect. Please note that
+# even though the core GnuTLS library is released under LGPL, this extra
+# library uses GPL and as such, the terms of GPL apply to the combination
+# of wpa_supplicant and GnuTLS if this option is enabled. BSD license may not
+# apply for distribution of the resulting binary.
+#CONFIG_GNUTLS_EXTRA=y
+
+# If CONFIG_TLS=internal is used, additional library and include paths are
+# needed for LibTomMath. Alternatively, an integrated, minimal version of
+# LibTomMath can be used. See beginning of libtommath.c for details on benefits
+# and drawbacks of this option.
+#CONFIG_INTERNAL_LIBTOMMATH=y
+#ifndef CONFIG_INTERNAL_LIBTOMMATH
+#LTM_PATH=/usr/src/libtommath-0.39
+#CFLAGS += -I$(LTM_PATH)
+#LIBS += -L$(LTM_PATH)
+#LIBS_p += -L$(LTM_PATH)
+#endif
+# At the cost of about 4 kB of additional binary size, the internal LibTomMath
+# can be configured to include faster routines for exptmod, sqr, and div to
+# speed up DH and RSA calculation considerably
+#CONFIG_INTERNAL_LIBTOMMATH_FAST=y
+
+# Include NDIS event processing through WMI into wpa_supplicant/wpasvc.
+# This is only for Windows builds and requires WMI-related header files and
+# WbemUuid.Lib from Platform SDK even when building with MinGW.
+#CONFIG_NDIS_EVENTS_INTEGRATED=y
+#PLATFORMSDKLIB="/opt/Program Files/Microsoft Platform SDK/Lib"
+
+# Add support for old DBus control interface
+# (fi.epitest.hostap.WPASupplicant)
+#CONFIG_CTRL_IFACE_DBUS=y
+
+# Add support for new DBus control interface
+# (fi.w1.hostap.wpa_supplicant1)
+#CONFIG_CTRL_IFACE_DBUS_NEW=y
+
+# Add introspection support for new DBus control interface
+#CONFIG_CTRL_IFACE_DBUS_INTRO=y
+
+# Add support for loading EAP methods dynamically as shared libraries.
+# When this option is enabled, each EAP method can be either included
+# statically (CONFIG_EAP_<method>=y) or dynamically (CONFIG_EAP_<method>=dyn).
+# Dynamic EAP methods are build as shared objects (eap_*.so) and they need to
+# be loaded in the beginning of the wpa_supplicant configuration file
+# (see load_dynamic_eap parameter in the example file) before being used in
+# the network blocks.
+#
+# Note that some shared parts of EAP methods are included in the main program
+# and in order to be able to use dynamic EAP methods using these parts, the
+# main program must have been build with the EAP method enabled (=y or =dyn).
+# This means that EAP-TLS/PEAP/TTLS/FAST cannot be added as dynamic libraries
+# unless at least one of them was included in the main build to force inclusion
+# of the shared code. Similarly, at least one of EAP-SIM/AKA must be included
+# in the main build to be able to load these methods dynamically.
+#
+# Please also note that using dynamic libraries will increase the total binary
+# size. Thus, it may not be the best option for targets that have limited
+# amount of memory/flash.
+#CONFIG_DYNAMIC_EAP_METHODS=y
+
+# IEEE Std 802.11r-2008 (Fast BSS Transition)
+#CONFIG_IEEE80211R=y
+
+# Add support for writing debug log to a file (/tmp/wpa_supplicant-log-#.txt)
+#CONFIG_DEBUG_FILE=y
+
+# Enable privilege separation (see README 'Privilege separation' for details)
+#CONFIG_PRIVSEP=y
+
+# Enable mitigation against certain attacks against TKIP by delaying Michael
+# MIC error reports by a random amount of time between 0 and 60 seconds
+#CONFIG_DELAYED_MIC_ERROR_REPORT=y
+
+# Enable tracing code for developer debugging
+# This tracks use of memory allocations and other registrations and reports
+# incorrect use with a backtrace of call (or allocation) location.
+#CONFIG_WPA_TRACE=y
+# For BSD, comment out these.
+#LIBS += -lexecinfo
+#LIBS_p += -lexecinfo
+#LIBS_c += -lexecinfo
+
+# Use libbfd to get more details for developer debugging
+# This enables use of libbfd to get more detailed symbols for the backtraces
+# generated by CONFIG_WPA_TRACE=y.
+#CONFIG_WPA_TRACE_BFD=y
+# For BSD, comment out these.
+#LIBS += -lbfd -liberty -lz
+#LIBS_p += -lbfd -liberty -lz
+#LIBS_c += -lbfd -liberty -lz
+
+NEED_80211_COMMON=y
diff --git a/package/network/services/hostapd/files/.svn/text-base/wpa_supplicant.sh.svn-base b/package/network/services/hostapd/files/.svn/text-base/wpa_supplicant.sh.svn-base
new file mode 100644
index 0000000..0b5e1d3
--- /dev/null
+++ b/package/network/services/hostapd/files/.svn/text-base/wpa_supplicant.sh.svn-base
@@ -0,0 +1,194 @@
+wpa_supplicant_setup_vif() {
+ local vif="$1"
+ local driver="$2"
+ local key="$key"
+ local options="$3"
+ local freq=""
+ local ht="$5"
+ local ap_scan=""
+ local scan_ssid="1"
+ [ -n "$4" ] && freq="frequency=$4"
+
+ config_get enc "$vif" encryption
+ config_get key "$vif" key
+
+ local net_cfg bridge
+ config_get bridge "$vif" bridge
+ [ -z "$bridge" ] && {
+ net_cfg="$(find_net_config "$vif")"
+ [ -z "$net_cfg" ] || bridge="$(bridge_interface "$net_cfg")"
+ config_set "$vif" bridge "$bridge"
+ }
+
+ local mode ifname wds modestr=""
+ config_get mode "$vif" mode
+ config_get ifname "$vif" ifname
+ config_get_bool wds "$vif" wds 0
+ [ -z "$bridge" ] || [ "$mode" = ap ] || [ "$mode" = sta -a $wds -eq 1 ] || {
+ echo "wpa_supplicant_setup_vif($ifname): Refusing to bridge $mode mode interface"
+ return 1
+ }
+ [ "$mode" = "adhoc" ] && {
+ modestr="mode=1"
+ scan_ssid="0"
+ ap_scan="ap_scan=2"
+ }
+
+ key_mgmt='NONE'
+ case "$enc" in
+ *none*) ;;
+ *wep*)
+ config_get key "$vif" key
+ key="${key:-1}"
+ case "$key" in
+ [1234])
+ for idx in 1 2 3 4; do
+ local zidx
+ zidx=$(($idx - 1))
+ config_get ckey "$vif" "key${idx}"
+ [ -n "$ckey" ] && \
+ append "wep_key${zidx}" "wep_key${zidx}=$(prepare_key_wep "$ckey")"
+ done
+ wep_tx_keyidx="wep_tx_keyidx=$((key - 1))"
+ ;;
+ *)
+ wep_key0="wep_key0=$(prepare_key_wep "$key")"
+ wep_tx_keyidx="wep_tx_keyidx=0"
+ ;;
+ esac
+ ;;
+ *psk*)
+ key_mgmt='WPA-PSK'
+ # if you want to use PSK with a non-nl80211 driver you
+ # have to use WPA-NONE and wext driver for wpa_s
+ [ "$mode" = "adhoc" -a "$driver" != "nl80211" ] && {
+ key_mgmt='WPA-NONE'
+ driver='wext'
+ }
+ if [ ${#key} -eq 64 ]; then
+ passphrase="psk=${key}"
+ else
+ passphrase="psk=\"${key}\""
+ fi
+ case "$enc" in
+ *psk2*)
+ proto='proto=RSN'
+ config_get ieee80211w "$vif" ieee80211w
+ ;;
+ *psk*)
+ proto='proto=WPA'
+ ;;
+ esac
+ ;;
+ *wpa*|*8021x*)
+ proto='proto=WPA2'
+ key_mgmt='WPA-EAP'
+ config_get ieee80211w "$vif" ieee80211w
+ config_get ca_cert "$vif" ca_cert
+ config_get eap_type "$vif" eap_type
+ ca_cert=${ca_cert:+"ca_cert=\"$ca_cert\""}
+ case "$eap_type" in
+ tls)
+ pairwise='pairwise=CCMP'
+ group='group=CCMP'
+ config_get identity "$vif" identity
+ config_get client_cert "$vif" client_cert
+ config_get priv_key "$vif" priv_key
+ config_get priv_key_pwd "$vif" priv_key_pwd
+ identity="identity=\"$identity\""
+ client_cert="client_cert=\"$client_cert\""
+ priv_key="private_key=\"$priv_key\""
+ priv_key_pwd="private_key_passwd=\"$priv_key_pwd\""
+ ;;
+ peap|ttls)
+ config_get auth "$vif" auth
+ config_get identity "$vif" identity
+ config_get password "$vif" password
+ phase2="phase2=\"auth=${auth:-MSCHAPV2}\""
+ identity="identity=\"$identity\""
+ password="${password:+password=\"$password\"}"
+ ;;
+ esac
+ eap_type="eap=$(echo $eap_type | tr 'a-z' 'A-Z')"
+ ;;
+ esac
+
+ case "$ieee80211w" in
+ [012])
+ ieee80211w="ieee80211w=$ieee80211w"
+ ;;
+ esac
+
+ local fixed_freq bssid1 beacon_interval brates mrate
+ config_get ifname "$vif" ifname
+ config_get bridge "$vif" bridge
+ config_get ssid "$vif" ssid
+ config_get bssid "$vif" bssid
+ bssid1=${bssid:+"bssid=$bssid"}
+ beacon_interval=${beacon_int:+"beacon_interval=$beacon_int"}
+
+ local br brval brsub brstr
+ [ -n "$basic_rate_list" ] && {
+ for br in $basic_rate_list; do
+ brval="$(($br / 1000))"
+ brsub="$((($br / 100) % 10))"
+ [ "$brsub" -gt 0 ] && brval="$brval.$brsub"
+ [ -n "$brstr" ] && brstr="$brstr,"
+ brstr="$brstr$brval"
+ done
+ brates=${basic_rate_list:+"rates=$brstr"}
+ }
+
+ local mcval=""
+ [ -n "$mcast_rate" ] && {
+ mcval="$(($mcast_rate / 1000))"
+ mcsub="$(( ($mcast_rate / 100) % 10 ))"
+ [ "$mcsub" -gt 0 ] && mcval="$mcval.$mcsub"
+ mrate=${mcast_rate:+"mcast_rate=$mcval"}
+ }
+
+ local ht_str
+ [ -n "$ht" ] && ht_str="htmode=$ht"
+
+ rm -rf /var/run/wpa_supplicant-$ifname
+ cat > /var/run/wpa_supplicant-$ifname.conf <<EOF
+ctrl_interface=/var/run/wpa_supplicant-$ifname
+$ap_scan
+network={
+ $modestr
+ scan_ssid=$scan_ssid
+ ssid="$ssid"
+ $bssid1
+ key_mgmt=$key_mgmt
+ $proto
+ $freq
+ ${fixed:+"fixed_freq=1"}
+ $beacon_interval
+ $brates
+ $mrate
+ $ht_str
+ $ieee80211w
+ $passphrase
+ $pairwise
+ $group
+ $eap_type
+ $ca_cert
+ $client_cert
+ $priv_key
+ $priv_key_pwd
+ $phase2
+ $identity
+ $password
+ $wep_key0
+ $wep_key1
+ $wep_key2
+ $wep_key3
+ $wep_tx_keyidx
+}
+EOF
+ if [ -n "$proto" -o "$key_mgmt" == "NONE" ]; then
+ wpa_supplicant ${bridge:+ -b $bridge} -B -P "/var/run/wifi-${ifname}.pid" -D ${driver:-wext} -i "$ifname" -c /var/run/wpa_supplicant-$ifname.conf $options
+ else
+ return 0
+ fi
+}
diff --git a/package/network/services/hostapd/files/.svn/text-base/wps-hotplug.sh.svn-base b/package/network/services/hostapd/files/.svn/text-base/wps-hotplug.sh.svn-base
new file mode 100644
index 0000000..ffd3cf9
--- /dev/null
+++ b/package/network/services/hostapd/files/.svn/text-base/wps-hotplug.sh.svn-base
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+if [ "$ACTION" = "pressed" -a "$BUTTON" = "wps" ]; then
+ for dir in /var/run/hostapd-*; do
+ [ -d "$dir" ] || continue
+ hostapd_cli -p "$dir" wps_pbc
+ done
+fi
diff --git a/package/network/services/hostapd/files/hostapd-full.config b/package/network/services/hostapd/files/hostapd-full.config
new file mode 100644
index 0000000..3a0ce12
--- /dev/null
+++ b/package/network/services/hostapd/files/hostapd-full.config
@@ -0,0 +1,164 @@
+# Example hostapd build time configuration
+#
+# This file lists the configuration options that are used when building the
+# hostapd binary. All lines starting with # are ignored. Configuration option
+# lines must be commented out complete, if they are not to be included, i.e.,
+# just setting VARIABLE=n is not disabling that variable.
+#
+# This file is included in Makefile, so variables like CFLAGS and LIBS can also
+# be modified from here. In most cass, these lines should use += in order not
+# to override previous values of the variables.
+
+# Driver interface for Host AP driver
+CONFIG_DRIVER_HOSTAP=y
+
+# Driver interface for wired authenticator
+CONFIG_DRIVER_WIRED=y
+
+# Driver interface for madwifi driver
+CONFIG_DRIVER_MADWIFI=y
+#CFLAGS += -I../../madwifi # change to the madwifi source directory
+
+# Driver interface for Prism54 driver
+#CONFIG_DRIVER_PRISM54=y
+
+# Driver interface for drivers using the nl80211 kernel interface
+CONFIG_DRIVER_NL80211=y
+# driver_nl80211.c requires a rather new libnl (version 1.1) which may not be
+# shipped with your distribution yet. If that is the case, you need to build
+# newer libnl version and point the hostapd build to use it.
+#LIBNL=/usr/src/libnl
+#CFLAGS += -I$(LIBNL)/include
+#LIBS += -L$(LIBNL)/lib
+
+# Driver interface for FreeBSD net80211 layer (e.g., Atheros driver)
+#CONFIG_DRIVER_BSD=y
+#CFLAGS += -I/usr/local/include
+#LIBS += -L/usr/local/lib
+
+# Driver interface for no driver (e.g., RADIUS server only)
+#CONFIG_DRIVER_NONE=y
+
+# IEEE 802.11F/IAPP
+CONFIG_IAPP=y
+
+# WPA2/IEEE 802.11i RSN pre-authentication
+CONFIG_RSN_PREAUTH=y
+
+# PeerKey handshake for Station to Station Link (IEEE 802.11e DLS)
+CONFIG_PEERKEY=y
+
+# IEEE 802.11w (management frame protection)
+# This version is an experimental implementation based on IEEE 802.11w/D1.0
+# draft and is subject to change since the standard has not yet been finalized.
+# Driver support is also needed for IEEE 802.11w.
+#CONFIG_IEEE80211W=y
+
+# Integrated EAP server
+CONFIG_EAP=y
+
+# EAP-MD5 for the integrated EAP server
+CONFIG_EAP_MD5=y
+
+# EAP-TLS for the integrated EAP server
+CONFIG_EAP_TLS=y
+
+# EAP-MSCHAPv2 for the integrated EAP server
+CONFIG_EAP_MSCHAPV2=y
+
+# EAP-PEAP for the integrated EAP server
+CONFIG_EAP_PEAP=y
+
+# EAP-GTC for the integrated EAP server
+CONFIG_EAP_GTC=y
+
+# EAP-TTLS for the integrated EAP server
+CONFIG_EAP_TTLS=y
+
+# EAP-SIM for the integrated EAP server
+#CONFIG_EAP_SIM=y
+
+# EAP-AKA for the integrated EAP server
+#CONFIG_EAP_AKA=y
+
+# EAP-AKA' for the integrated EAP server
+# This requires CONFIG_EAP_AKA to be enabled, too.
+#CONFIG_EAP_AKA_PRIME=y
+
+# EAP-PAX for the integrated EAP server
+#CONFIG_EAP_PAX=y
+
+# EAP-PSK for the integrated EAP server (this is _not_ needed for WPA-PSK)
+#CONFIG_EAP_PSK=y
+
+# EAP-SAKE for the integrated EAP server
+#CONFIG_EAP_SAKE=y
+
+# EAP-GPSK for the integrated EAP server
+#CONFIG_EAP_GPSK=y
+# Include support for optional SHA256 cipher suite in EAP-GPSK
+#CONFIG_EAP_GPSK_SHA256=y
+
+# EAP-FAST for the integrated EAP server
+# Note: Default OpenSSL package does not include support for all the
+# functionality needed for EAP-FAST. If EAP-FAST is enabled with OpenSSL,
+# the OpenSSL library must be patched (openssl-0.9.9-session-ticket.patch)
+# to add the needed functions.
+#CONFIG_EAP_FAST=y
+
+# Wi-Fi Protected Setup (WPS)
+#CONFIG_WPS=y
+# Enable UPnP support for external WPS Registrars
+#CONFIG_WPS_UPNP=y
+
+# EAP-IKEv2
+#CONFIG_EAP_IKEV2=y
+
+# Trusted Network Connect (EAP-TNC)
+#CONFIG_EAP_TNC=y
+
+# PKCS#12 (PFX) support (used to read private key and certificate file from
+# a file that usually has extension .p12 or .pfx)
+CONFIG_PKCS12=y
+
+# RADIUS authentication server. This provides access to the integrated EAP
+# server from external hosts using RADIUS.
+#CONFIG_RADIUS_SERVER=y
+
+# Build IPv6 support for RADIUS operations
+CONFIG_IPV6=y
+
+# IEEE Std 802.11r-2008 (Fast BSS Transition)
+#CONFIG_IEEE80211R=y
+
+# Use the hostapd's IEEE 802.11 authentication (ACL), but without
+# the IEEE 802.11 Management capability (e.g., madwifi or FreeBSD/net80211)
+#CONFIG_DRIVER_RADIUS_ACL=y
+
+# IEEE 802.11n (High Throughput) support
+CONFIG_IEEE80211N=y
+
+# Remove debugging code that is printing out debug messages to stdout.
+# This can be used to reduce the size of the hostapd considerably if debugging
+# code is not needed.
+#CONFIG_NO_STDOUT_DEBUG=y
+
+# Remove support for RADIUS accounting
+#CONFIG_NO_ACCOUNTING=y
+
+# Remove support for RADIUS
+#CONFIG_NO_RADIUS=y
+
+# Remove support for VLANs
+#CONFIG_NO_VLAN=y
+
+CONFIG_TLS=internal
+CONFIG_INTERNAL_LIBTOMMATH=y
+CONFIG_INTERNAL_AES=y
+NEED_AES_DEC=y
+
+CONFIG_NO_DUMP_STATE=y
+
+CONFIG_WPS=y
+CONFIG_FULL_DYNAMIC_VLAN=y
+
diff --git a/package/network/services/hostapd/files/hostapd-mini.config b/package/network/services/hostapd/files/hostapd-mini.config
new file mode 100644
index 0000000..3e94a64
--- /dev/null
+++ b/package/network/services/hostapd/files/hostapd-mini.config
@@ -0,0 +1,157 @@
+# Example hostapd build time configuration
+#
+# This file lists the configuration options that are used when building the
+# hostapd binary. All lines starting with # are ignored. Configuration option
+# lines must be commented out complete, if they are not to be included, i.e.,
+# just setting VARIABLE=n is not disabling that variable.
+#
+# This file is included in Makefile, so variables like CFLAGS and LIBS can also
+# be modified from here. In most cass, these lines should use += in order not
+# to override previous values of the variables.
+
+# Driver interface for Host AP driver
+CONFIG_DRIVER_HOSTAP=y
+
+# Driver interface for wired authenticator
+CONFIG_DRIVER_WIRED=y
+
+# Driver interface for madwifi driver
+CONFIG_DRIVER_MADWIFI=y
+#CFLAGS += -I../../madwifi # change to the madwifi source directory
+
+# Driver interface for Prism54 driver
+#CONFIG_DRIVER_PRISM54=y
+
+# Driver interface for drivers using the nl80211 kernel interface
+CONFIG_DRIVER_NL80211=y
+# driver_nl80211.c requires a rather new libnl (version 1.1) which may not be
+# shipped with your distribution yet. If that is the case, you need to build
+# newer libnl version and point the hostapd build to use it.
+#LIBNL=/usr/src/libnl
+#CFLAGS += -I$(LIBNL)/include
+#LIBS += -L$(LIBNL)/lib
+
+# Driver interface for FreeBSD net80211 layer (e.g., Atheros driver)
+#CONFIG_DRIVER_BSD=y
+#CFLAGS += -I/usr/local/include
+#LIBS += -L/usr/local/lib
+
+# Driver interface for no driver (e.g., RADIUS server only)
+#CONFIG_DRIVER_NONE=y
+
+# IEEE 802.11F/IAPP
+# CONFIG_IAPP=y
+
+# WPA2/IEEE 802.11i RSN pre-authentication
+CONFIG_RSN_PREAUTH=y
+
+# PeerKey handshake for Station to Station Link (IEEE 802.11e DLS)
+CONFIG_PEERKEY=y
+
+# IEEE 802.11w (management frame protection)
+# This version is an experimental implementation based on IEEE 802.11w/D1.0
+# draft and is subject to change since the standard has not yet been finalized.
+# Driver support is also needed for IEEE 802.11w.
+#CONFIG_IEEE80211W=y
+
+# Integrated EAP server
+#CONFIG_EAP=y
+
+# EAP-MD5 for the integrated EAP server
+#CONFIG_EAP_MD5=y
+
+# EAP-TLS for the integrated EAP server
+#CONFIG_EAP_TLS=y
+
+# EAP-MSCHAPv2 for the integrated EAP server
+#CONFIG_EAP_MSCHAPV2=y
+
+# EAP-PEAP for the integrated EAP server
+#CONFIG_EAP_PEAP=y
+
+# EAP-GTC for the integrated EAP server
+#CONFIG_EAP_GTC=y
+
+# EAP-TTLS for the integrated EAP server
+#CONFIG_EAP_TTLS=y
+
+# EAP-SIM for the integrated EAP server
+#CONFIG_EAP_SIM=y
+
+# EAP-AKA for the integrated EAP server
+#CONFIG_EAP_AKA=y
+
+# EAP-AKA' for the integrated EAP server
+# This requires CONFIG_EAP_AKA to be enabled, too.
+#CONFIG_EAP_AKA_PRIME=y
+
+# EAP-PAX for the integrated EAP server
+#CONFIG_EAP_PAX=y
+
+# EAP-PSK for the integrated EAP server (this is _not_ needed for WPA-PSK)
+#CONFIG_EAP_PSK=y
+
+# EAP-SAKE for the integrated EAP server
+#CONFIG_EAP_SAKE=y
+
+# EAP-GPSK for the integrated EAP server
+#CONFIG_EAP_GPSK=y
+# Include support for optional SHA256 cipher suite in EAP-GPSK
+#CONFIG_EAP_GPSK_SHA256=y
+
+# EAP-FAST for the integrated EAP server
+# Note: Default OpenSSL package does not include support for all the
+# functionality needed for EAP-FAST. If EAP-FAST is enabled with OpenSSL,
+# the OpenSSL library must be patched (openssl-0.9.9-session-ticket.patch)
+# to add the needed functions.
+#CONFIG_EAP_FAST=y
+
+# Wi-Fi Protected Setup (WPS)
+#CONFIG_WPS=y
+# Enable UPnP support for external WPS Registrars
+#CONFIG_WPS_UPNP=y
+
+# EAP-IKEv2
+#CONFIG_EAP_IKEV2=y
+
+# Trusted Network Connect (EAP-TNC)
+#CONFIG_EAP_TNC=y
+
+# PKCS#12 (PFX) support (used to read private key and certificate file from
+# a file that usually has extension .p12 or .pfx)
+#CONFIG_PKCS12=y
+
+# RADIUS authentication server. This provides access to the integrated EAP
+# server from external hosts using RADIUS.
+#CONFIG_RADIUS_SERVER=y
+
+# Build IPv6 support for RADIUS operations
+#CONFIG_IPV6=y
+
+# IEEE Std 802.11r-2008 (Fast BSS Transition)
+#CONFIG_IEEE80211R=y
+
+# Use the hostapd's IEEE 802.11 authentication (ACL), but without
+# the IEEE 802.11 Management capability (e.g., madwifi or FreeBSD/net80211)
+#CONFIG_DRIVER_RADIUS_ACL=y
+
+# IEEE 802.11n (High Throughput) support
+CONFIG_IEEE80211N=y
+
+# Remove debugging code that is printing out debug messages to stdout.
+# This can be used to reduce the size of the hostapd considerably if debugging
+# code is not needed.
+#CONFIG_NO_STDOUT_DEBUG=y
+
+# Remove support for RADIUS accounting
+CONFIG_NO_ACCOUNTING=y
+
+# Remove support for RADIUS
+CONFIG_NO_RADIUS=y
+
+# Remove support for VLANs
+#CONFIG_NO_VLAN=y
+
+CONFIG_TLS=internal
+
+CONFIG_NO_DUMP_STATE=y
diff --git a/package/network/services/hostapd/files/hostapd.sh b/package/network/services/hostapd/files/hostapd.sh
new file mode 100644
index 0000000..00c6a09
--- /dev/null
+++ b/package/network/services/hostapd/files/hostapd.sh
@@ -0,0 +1,301 @@
+hostapd_set_bss_options() {
+ local var="$1"
+ local vif="$2"
+ local enc wep_rekey wpa_group_rekey wpa_pair_rekey wpa_master_rekey wps_possible
+
+ config_get enc "$vif" encryption
+ config_get wep_rekey "$vif" wep_rekey # 300
+ config_get wpa_group_rekey "$vif" wpa_group_rekey # 300
+ config_get wpa_pair_rekey "$vif" wpa_pair_rekey # 300
+ config_get wpa_master_rekey "$vif" wpa_master_rekey # 640
+ config_get_bool ap_isolate "$vif" isolate 0
+ config_get_bool disassoc_low_ack "$vif" disassoc_low_ack 1
+ config_get max_num_sta "$vif" max_num_sta 0
+ config_get max_inactivity "$vif" max_inactivity 0
+ config_get_bool preamble "$vif" short_preamble 1
+
+ config_get device "$vif" device
+ config_get hwmode "$device" hwmode
+ config_get phy "$device" phy
+
+ append "$var" "ctrl_interface=/var/run/hostapd-$phy" "$N"
+
+ if [ "$ap_isolate" -gt 0 ]; then
+ append "$var" "ap_isolate=$ap_isolate" "$N"
+ fi
+ if [ "$max_num_sta" -gt 0 ]; then
+ append "$var" "max_num_sta=$max_num_sta" "$N"
+ fi
+ if [ "$max_inactivity" -gt 0 ]; then
+ append "$var" "ap_max_inactivity=$max_inactivity" "$N"
+ fi
+ append "$var" "disassoc_low_ack=$disassoc_low_ack" "$N"
+ if [ "$preamble" -gt 0 ]; then
+ append "$var" "preamble=$preamble" "$N"
+ fi
+
+ # Examples:
+ # psk-mixed/tkip => WPA1+2 PSK, TKIP
+ # wpa-psk2/tkip+aes => WPA2 PSK, CCMP+TKIP
+ # wpa2/tkip+aes => WPA2 RADIUS, CCMP+TKIP
+ # ...
+
+ # TODO: move this parsing function somewhere generic, so that
+ # later it can be reused by drivers that don't use hostapd
+
+ # crypto defaults: WPA2 vs WPA1
+ case "$enc" in
+ wpa2*|*psk2*)
+ wpa=2
+ crypto="CCMP"
+ ;;
+ *mixed*)
+ wpa=3
+ crypto="CCMP TKIP"
+ ;;
+ *)
+ wpa=1
+ crypto="TKIP"
+ ;;
+ esac
+
+ # explicit override for crypto setting
+ case "$enc" in
+ *tkip+aes|*tkip+ccmp|*aes+tkip|*ccmp+tkip) crypto="CCMP TKIP";;
+ *aes|*ccmp) crypto="CCMP";;
+ *tkip) crypto="TKIP";;
+ esac
+
+ # enforce CCMP for 11ng and 11na
+ case "$hwmode:$crypto" in
+ *ng:TKIP|*na:TKIP) crypto="CCMP TKIP";;
+ esac
+
+ # use crypto/auth settings for building the hostapd config
+ case "$enc" in
+ *psk*)
+ config_get psk "$vif" key
+ if [ ${#psk} -eq 64 ]; then
+ append "$var" "wpa_psk=$psk" "$N"
+ else
+ append "$var" "wpa_passphrase=$psk" "$N"
+ fi
+ wps_possible=1
+ [ -n "$wpa_group_rekey" ] && append "$var" "wpa_group_rekey=$wpa_group_rekey" "$N"
+ [ -n "$wpa_pair_rekey" ] && append "$var" "wpa_ptk_rekey=$wpa_pair_rekey" "$N"
+ [ -n "$wpa_master_rekey" ] && append "$var" "wpa_gmk_rekey=$wpa_master_rekey" "$N"
+ ;;
+ *wpa*)
+ # required fields? formats?
+ # hostapd is particular, maybe a default configuration for failures
+ config_get auth_server "$vif" auth_server
+ [ -z "$auth_server" ] && config_get auth_server "$vif" server
+ append "$var" "auth_server_addr=$auth_server" "$N"
+ config_get auth_port "$vif" auth_port
+ [ -z "$auth_port" ] && config_get auth_port "$vif" port
+ auth_port=${auth_port:-1812}
+ append "$var" "auth_server_port=$auth_port" "$N"
+ config_get auth_secret "$vif" auth_secret
+ [ -z "$auth_secret" ] && config_get auth_secret "$vif" key
+ append "$var" "auth_server_shared_secret=$auth_secret" "$N"
+ config_get_bool auth_cache "$vif" auth_cache 0
+ [ "$auth_cache" -gt 0 ] || append "$var" "disable_pmksa_caching=1" "$N"
+ [ "$auth_cache" -gt 0 ] || append "$var" "okc=0" "$N"
+ config_get acct_server "$vif" acct_server
+ [ -n "$acct_server" ] && append "$var" "acct_server_addr=$acct_server" "$N"
+ config_get acct_port "$vif" acct_port
+ [ -n "$acct_port" ] && acct_port=${acct_port:-1813}
+ [ -n "$acct_port" ] && append "$var" "acct_server_port=$acct_port" "$N"
+ config_get acct_secret "$vif" acct_secret
+ [ -n "$acct_secret" ] && append "$var" "acct_server_shared_secret=$acct_secret" "$N"
+ config_get nasid "$vif" nasid
+ append "$var" "nas_identifier=$nasid" "$N"
+ append "$var" "eapol_key_index_workaround=1" "$N"
+ append "$var" "ieee8021x=1" "$N"
+ append "$var" "wpa_key_mgmt=WPA-EAP" "$N"
+ [ -n "$wpa_group_rekey" ] && append "$var" "wpa_group_rekey=$wpa_group_rekey" "$N"
+ [ -n "$wpa_pair_rekey" ] && append "$var" "wpa_ptk_rekey=$wpa_pair_rekey" "$N"
+ [ -n "$wpa_master_rekey" ] && append "$var" "wpa_gmk_rekey=$wpa_master_rekey" "$N"
+ ;;
+ *wep*)
+ config_get key "$vif" key
+ key="${key:-1}"
+ case "$key" in
+ [1234])
+ for idx in 1 2 3 4; do
+ local zidx
+ zidx=$(($idx - 1))
+ config_get ckey "$vif" "key${idx}"
+ [ -n "$ckey" ] && \
+ append "$var" "wep_key${zidx}=$(prepare_key_wep "$ckey")" "$N"
+ done
+ append "$var" "wep_default_key=$((key - 1))" "$N"
+ ;;
+ *)
+ append "$var" "wep_key0=$(prepare_key_wep "$key")" "$N"
+ append "$var" "wep_default_key=0" "$N"
+ [ -n "$wep_rekey" ] && append "$var" "wep_rekey_period=$wep_rekey" "$N"
+ ;;
+ esac
+ case "$enc" in
+ *shared*)
+ auth_algs=2
+ ;;
+ *mixed*)
+ auth_algs=3
+ ;;
+ esac
+ wpa=0
+ crypto=
+ ;;
+ *)
+ wpa=0
+ crypto=
+ ;;
+ esac
+ append "$var" "auth_algs=${auth_algs:-1}" "$N"
+ append "$var" "wpa=$wpa" "$N"
+ [ -n "$crypto" ] && append "$var" "wpa_pairwise=$crypto" "$N"
+ [ -n "$wpa_group_rekey" ] && append "$var" "wpa_group_rekey=$wpa_group_rekey" "$N"
+
+ config_get ssid "$vif" ssid
+ config_get bridge "$vif" bridge
+ config_get ieee80211d "$vif" ieee80211d
+ config_get iapp_interface "$vif" iapp_interface
+
+ config_get_bool wps_pbc "$vif" wps_pushbutton 0
+ config_get_bool wps_label "$vif" wps_label 0
+
+ config_get config_methods "$vif" wps_config
+ [ "$wps_pbc" -gt 0 ] && append config_methods push_button
+
+ [ -n "$wps_possible" -a -n "$config_methods" ] && {
+ config_get device_type "$vif" wps_device_type "6-0050F204-1"
+ config_get device_name "$vif" wps_device_name "OpenWrt AP"
+ config_get manufacturer "$vif" wps_manufacturer "openwrt.org"
+
+ append "$var" "eap_server=1" "$N"
+ append "$var" "wps_state=2" "$N"
+ append "$var" "ap_setup_locked=1" "$N"
+ append "$var" "device_type=$device_type" "$N"
+ append "$var" "device_name=$device_name" "$N"
+ append "$var" "manufacturer=$manufacturer" "$N"
+ append "$var" "config_methods=$config_methods" "$N"
+ }
+
+ append "$var" "ssid=$ssid" "$N"
+ [ -n "$bridge" ] && append "$var" "bridge=$bridge" "$N"
+ [ -n "$ieee80211d" ] && append "$var" "ieee80211d=$ieee80211d" "$N"
+ [ -n "$iapp_interface" ] && append "$var" iapp_interface=$(uci_get_state network "$iapp_interface" ifname "$iapp_interface") "$N"
+
+ if [ "$wpa" -ge "2" ]
+ then
+ # RSN -> allow preauthentication
+ config_get_bool rsn_preauth "$vif" rsn_preauth "$auth_cache"
+ if [ -n "$bridge" -a "$rsn_preauth" = 1 ]
+ then
+ append "$var" "rsn_preauth=1" "$N"
+ append "$var" "rsn_preauth_interfaces=$bridge" "$N"
+ fi
+
+ # RSN -> allow management frame protection
+ config_get ieee80211w "$vif" ieee80211w
+ case "$ieee80211w" in
+ [012])
+ append "$var" "ieee80211w=$ieee80211w" "$N"
+ [ "$ieee80211w" -gt "0" ] && {
+ config_get ieee80211w_max_timeout "$vif" ieee80211w_max_timeout
+ config_get ieee80211w_retry_timeout "$vif" ieee80211w_retry_timeout
+ [ -n "$ieee80211w_max_timeout" ] && \
+ append "$var" "assoc_sa_query_max_timeout=$ieee80211w_max_timeout" "$N"
+ [ -n "$ieee80211w_retry_timeout" ] && \
+ append "$var" "assoc_sa_query_retry_timeout=$ieee80211w_retry_timeout" "$N"
+ }
+ ;;
+ esac
+ fi
+
+ config_get macfilter "$vif" macfilter
+ macfile="/var/run/hostapd-$ifname.maclist"
+ [ -e "$macfile" ] && rm -f "$macfile"
+
+ case "$macfilter" in
+ allow)
+ append "$var" "macaddr_acl=1" "$N"
+ append "$var" "accept_mac_file=$macfile" "$N"
+ ;;
+ deny)
+ append "$var" "macaddr_acl=0" "$N"
+ append "$var" "deny_mac_file=$macfile" "$N"
+ ;;
+ esac
+ config_get maclist "$vif" maclist
+ [ -n "$maclist" ] && {
+ for mac in $maclist; do
+ echo "$mac" >> $macfile
+ done
+ }
+}
+
+hostapd_set_log_options() {
+ local var="$1"
+ local cfg="$2"
+ local log_level log_80211 log_8021x log_radius log_wpa log_driver log_iapp log_mlme
+
+ config_get log_level "$cfg" log_level 2
+
+ config_get_bool log_80211 "$cfg" log_80211 1
+ config_get_bool log_8021x "$cfg" log_8021x 1
+ config_get_bool log_radius "$cfg" log_radius 1
+ config_get_bool log_wpa "$cfg" log_wpa 1
+ config_get_bool log_driver "$cfg" log_driver 1
+ config_get_bool log_iapp "$cfg" log_iapp 1
+ config_get_bool log_mlme "$cfg" log_mlme 1
+
+ local log_mask=$(( \
+ ($log_80211 << 0) | \
+ ($log_8021x << 1) | \
+ ($log_radius << 2) | \
+ ($log_wpa << 3) | \
+ ($log_driver << 4) | \
+ ($log_iapp << 5) | \
+ ($log_mlme << 6) \
+ ))
+
+ append "$var" "logger_syslog=$log_mask" "$N"
+ append "$var" "logger_syslog_level=$log_level" "$N"
+ append "$var" "logger_stdout=$log_mask" "$N"
+ append "$var" "logger_stdout_level=$log_level" "$N"
+}
+
+hostapd_setup_vif() {
+ local vif="$1"
+ local driver="$2"
+ local ifname device channel hwmode
+
+ hostapd_cfg=
+
+ config_get ifname "$vif" ifname
+ config_get device "$vif" device
+ config_get channel "$device" channel
+ config_get hwmode "$device" hwmode
+
+ hostapd_set_log_options hostapd_cfg "$device"
+ hostapd_set_bss_options hostapd_cfg "$vif"
+
+ case "$hwmode" in
+ *bg|*gdt|*gst|*fh) hwmode=g;;
+ *adt|*ast) hwmode=a;;
+ esac
+ [ "$channel" = auto ] && channel=
+ [ -n "$channel" -a -z "$hwmode" ] && wifi_fixup_hwmode "$device"
+ cat > /var/run/hostapd-$ifname.conf <<EOF
+driver=$driver
+interface=$ifname
+${hwmode:+hw_mode=${hwmode#11}}
+${channel:+channel=$channel}
+$hostapd_cfg
+EOF
+ hostapd -P /var/run/wifi-$ifname.pid -B /var/run/hostapd-$ifname.conf
+}
+
diff --git a/package/network/services/hostapd/files/multicall.c b/package/network/services/hostapd/files/multicall.c
new file mode 100644
index 0000000..c8e814b
--- /dev/null
+++ b/package/network/services/hostapd/files/multicall.c
@@ -0,0 +1,28 @@
+#include <stdio.h>
+#include <string.h>
+#include <stdbool.h>
+
+extern int hostapd_main(int argc, char **argv);
+extern int wpa_supplicant_main(int argc, char **argv);
+
+int main(int argc, char **argv)
+{
+ bool restart = false;
+ const char *prog = argv[0];
+
+restart:
+ if (strstr(argv[0], "hostapd"))
+ return hostapd_main(argc, argv);
+ else if (strstr(argv[0], "wpa_supplicant"))
+ return wpa_supplicant_main(argc, argv);
+
+ if (!restart && argc > 1) {
+ argv++;
+ argc--;
+ restart = true;
+ goto restart;
+ }
+
+ fprintf(stderr, "Invalid command.\nUsage: %s wpa_supplicant|hostapd [<arguments>]\n", prog);
+ return 255;
+}
diff --git a/package/network/services/hostapd/files/wpa_supplicant-full.config b/package/network/services/hostapd/files/wpa_supplicant-full.config
new file mode 100644
index 0000000..f5abbad
--- /dev/null
+++ b/package/network/services/hostapd/files/wpa_supplicant-full.config
@@ -0,0 +1,408 @@
+# Example wpa_supplicant build time configuration
+#
+# This file lists the configuration options that are used when building the
+# hostapd binary. All lines starting with # are ignored. Configuration option
+# lines must be commented out complete, if they are not to be included, i.e.,
+# just setting VARIABLE=n is not disabling that variable.
+#
+# This file is included in Makefile, so variables like CFLAGS and LIBS can also
+# be modified from here. In most cases, these lines should use += in order not
+# to override previous values of the variables.
+
+
+# Uncomment following two lines and fix the paths if you have installed OpenSSL
+# or GnuTLS in non-default location
+#CFLAGS += -I/usr/local/openssl/include
+#LIBS += -L/usr/local/openssl/lib
+
+# Some Red Hat versions seem to include kerberos header files from OpenSSL, but
+# the kerberos files are not in the default include path. Following line can be
+# used to fix build issues on such systems (krb5.h not found).
+#CFLAGS += -I/usr/include/kerberos
+
+# Example configuration for various cross-compilation platforms
+
+#### sveasoft (e.g., for Linksys WRT54G) ######################################
+#CC=mipsel-uclibc-gcc
+#CC=/opt/brcm/hndtools-mipsel-uclibc/bin/mipsel-uclibc-gcc
+#CFLAGS += -Os
+#CPPFLAGS += -I../src/include -I../../src/router/openssl/include
+#LIBS += -L/opt/brcm/hndtools-mipsel-uclibc-0.9.19/lib -lssl
+###############################################################################
+
+#### openwrt (e.g., for Linksys WRT54G) #######################################
+#CC=mipsel-uclibc-gcc
+#CC=/opt/brcm/hndtools-mipsel-uclibc/bin/mipsel-uclibc-gcc
+#CFLAGS += -Os
+#CPPFLAGS=-I../src/include -I../openssl-0.9.7d/include \
+# -I../WRT54GS/release/src/include
+#LIBS = -lssl
+###############################################################################
+
+
+# Driver interface for Host AP driver
+CONFIG_DRIVER_HOSTAP=y
+
+# Driver interface for Agere driver
+#CONFIG_DRIVER_HERMES=y
+# Change include directories to match with the local setup
+#CFLAGS += -I../../hcf -I../../include -I../../include/hcf
+#CFLAGS += -I../../include/wireless
+
+# Driver interface for madwifi driver
+# Deprecated; use CONFIG_DRIVER_WEXT=y instead.
+#CONFIG_DRIVER_MADWIFI=y
+# Set include directory to the madwifi source tree
+#CFLAGS += -I../../madwifi
+
+# Driver interface for ndiswrapper
+# Deprecated; use CONFIG_DRIVER_WEXT=y instead.
+#CONFIG_DRIVER_NDISWRAPPER=y
+
+# Driver interface for Atmel driver
+# CONFIG_DRIVER_ATMEL=y
+
+# Driver interface for old Broadcom driver
+# Please note that the newer Broadcom driver ("hybrid Linux driver") supports
+# Linux wireless extensions and does not need (or even work) with the old
+# driver wrapper. Use CONFIG_DRIVER_WEXT=y with that driver.
+#CONFIG_DRIVER_BROADCOM=y
+# Example path for wlioctl.h; change to match your configuration
+#CFLAGS += -I/opt/WRT54GS/release/src/include
+
+# Driver interface for Intel ipw2100/2200 driver
+# Deprecated; use CONFIG_DRIVER_WEXT=y instead.
+#CONFIG_DRIVER_IPW=y
+
+# Driver interface for Ralink driver
+#CONFIG_DRIVER_RALINK=y
+
+# Driver interface for generic Linux wireless extensions
+CONFIG_DRIVER_WEXT=y
+
+# Driver interface for Linux drivers using the nl80211 kernel interface
+CONFIG_DRIVER_NL80211=y
+
+# Driver interface for FreeBSD net80211 layer (e.g., Atheros driver)
+#CONFIG_DRIVER_BSD=y
+#CFLAGS += -I/usr/local/include
+#LIBS += -L/usr/local/lib
+#LIBS_p += -L/usr/local/lib
+#LIBS_c += -L/usr/local/lib
+
+# Driver interface for Windows NDIS
+#CONFIG_DRIVER_NDIS=y
+#CFLAGS += -I/usr/include/w32api/ddk
+#LIBS += -L/usr/local/lib
+# For native build using mingw
+#CONFIG_NATIVE_WINDOWS=y
+# Additional directories for cross-compilation on Linux host for mingw target
+#CFLAGS += -I/opt/mingw/mingw32/include/ddk
+#LIBS += -L/opt/mingw/mingw32/lib
+#CC=mingw32-gcc
+# By default, driver_ndis uses WinPcap for low-level operations. This can be
+# replaced with the following option which replaces WinPcap calls with NDISUIO.
+# However, this requires that WZC is disabled (net stop wzcsvc) before starting
+# wpa_supplicant.
+# CONFIG_USE_NDISUIO=y
+
+# Driver interface for development testing
+#CONFIG_DRIVER_TEST=y
+
+# Include client MLME (management frame processing) for test driver
+# This can be used to test MLME operations in hostapd with the test interface.
+# space.
+#CONFIG_CLIENT_MLME=y
+
+# Driver interface for wired Ethernet drivers
+CONFIG_DRIVER_WIRED=y
+
+# Driver interface for the Broadcom RoboSwitch family
+#CONFIG_DRIVER_ROBOSWITCH=y
+
+# Driver interface for no driver (e.g., WPS ER only)
+#CONFIG_DRIVER_NONE=y
+
+# Enable IEEE 802.1X Supplicant (automatically included if any EAP method is
+# included)
+CONFIG_IEEE8021X_EAPOL=y
+
+# EAP-MD5
+CONFIG_EAP_MD5=y
+
+# EAP-MSCHAPv2
+CONFIG_EAP_MSCHAPV2=y
+
+# EAP-TLS
+CONFIG_EAP_TLS=y
+
+# EAL-PEAP
+CONFIG_EAP_PEAP=y
+
+# EAP-TTLS
+CONFIG_EAP_TTLS=y
+
+# EAP-FAST
+# Note: Default OpenSSL package does not include support for all the
+# functionality needed for EAP-FAST. If EAP-FAST is enabled with OpenSSL,
+# the OpenSSL library must be patched (openssl-0.9.8d-tls-extensions.patch)
+# to add the needed functions.
+#CONFIG_EAP_FAST=y
+
+# EAP-GTC
+CONFIG_EAP_GTC=y
+
+# EAP-OTP
+CONFIG_EAP_OTP=y
+
+# EAP-SIM (enable CONFIG_PCSC, if EAP-SIM is used)
+#CONFIG_EAP_SIM=y
+
+# EAP-PSK (experimental; this is _not_ needed for WPA-PSK)
+#CONFIG_EAP_PSK=y
+
+# EAP-PAX
+#CONFIG_EAP_PAX=y
+
+# LEAP
+CONFIG_EAP_LEAP=y
+
+# EAP-AKA (enable CONFIG_PCSC, if EAP-AKA is used)
+#CONFIG_EAP_AKA=y
+
+# EAP-AKA' (enable CONFIG_PCSC, if EAP-AKA' is used).
+# This requires CONFIG_EAP_AKA to be enabled, too.
+#CONFIG_EAP_AKA_PRIME=y
+
+# Enable USIM simulator (Milenage) for EAP-AKA
+#CONFIG_USIM_SIMULATOR=y
+
+# EAP-SAKE
+#CONFIG_EAP_SAKE=y
+
+# EAP-GPSK
+#CONFIG_EAP_GPSK=y
+# Include support for optional SHA256 cipher suite in EAP-GPSK
+#CONFIG_EAP_GPSK_SHA256=y
+
+# EAP-TNC and related Trusted Network Connect support (experimental)
+#CONFIG_EAP_TNC=y
+
+# Wi-Fi Protected Setup (WPS)
+CONFIG_WPS=y
+
+# EAP-IKEv2
+#CONFIG_EAP_IKEV2=y
+
+# PKCS#12 (PFX) support (used to read private key and certificate file from
+# a file that usually has extension .p12 or .pfx)
+CONFIG_PKCS12=y
+
+# Smartcard support (i.e., private key on a smartcard), e.g., with openssl
+# engine.
+CONFIG_SMARTCARD=y
+
+# PC/SC interface for smartcards (USIM, GSM SIM)
+# Enable this if EAP-SIM or EAP-AKA is included
+#CONFIG_PCSC=y
+
+# Development testing
+#CONFIG_EAPOL_TEST=y
+
+# Select control interface backend for external programs, e.g, wpa_cli:
+# unix = UNIX domain sockets (default for Linux/*BSD)
+# udp = UDP sockets using localhost (127.0.0.1)
+# named_pipe = Windows Named Pipe (default for Windows)
+# y = use default (backwards compatibility)
+# If this option is commented out, control interface is not included in the
+# build.
+CONFIG_CTRL_IFACE=y
+
+# Include support for GNU Readline and History Libraries in wpa_cli.
+# When building a wpa_cli binary for distribution, please note that these
+# libraries are licensed under GPL and as such, BSD license may not apply for
+# the resulting binary.
+#CONFIG_READLINE=y
+
+# Remove debugging code that is printing out debug message to stdout.
+# This can be used to reduce the size of the wpa_supplicant considerably
+# if debugging code is not needed. The size reduction can be around 35%
+# (e.g., 90 kB).
+#CONFIG_NO_STDOUT_DEBUG=y
+
+# Remove WPA support, e.g., for wired-only IEEE 802.1X supplicant, to save
+# 35-50 kB in code size.
+#CONFIG_NO_WPA=y
+
+# Remove WPA2 support. This allows WPA to be used, but removes WPA2 code to
+# save about 1 kB in code size when building only WPA-Personal (no EAP support)
+# or 6 kB if building for WPA-Enterprise.
+#CONFIG_NO_WPA2=y
+
+# Remove IEEE 802.11i/WPA-Personal ASCII passphrase support
+# This option can be used to reduce code size by removing support for
+# converting ASCII passphrases into PSK. If this functionality is removed, the
+# PSK can only be configured as the 64-octet hexstring (e.g., from
+# wpa_passphrase). This saves about 0.5 kB in code size.
+#CONFIG_NO_WPA_PASSPHRASE=y
+
+# Disable scan result processing (ap_mode=1) to save code size by about 1 kB.
+# This can be used if ap_scan=1 mode is never enabled.
+#CONFIG_NO_SCAN_PROCESSING=y
+
+# Select configuration backend:
+# file = text file (e.g., wpa_supplicant.conf; note: the configuration file
+# path is given on command line, not here; this option is just used to
+# select the backend that allows configuration files to be used)
+# winreg = Windows registry (see win_example.reg for an example)
+CONFIG_BACKEND=file
+
+# Remove configuration write functionality (i.e., to allow the configuration
+# file to be updated based on runtime configuration changes). The runtime
+# configuration can still be changed, the changes are just not going to be
+# persistent over restarts. This option can be used to reduce code size by
+# about 3.5 kB.
+#CONFIG_NO_CONFIG_WRITE=y
+
+# Remove support for configuration blobs to reduce code size by about 1.5 kB.
+#CONFIG_NO_CONFIG_BLOBS=y
+
+# Select program entry point implementation:
+# main = UNIX/POSIX like main() function (default)
+# main_winsvc = Windows service (read parameters from registry)
+# main_none = Very basic example (development use only)
+#CONFIG_MAIN=main
+
+# Select wrapper for operatins system and C library specific functions
+# unix = UNIX/POSIX like systems (default)
+# win32 = Windows systems
+# none = Empty template
+#CONFIG_OS=unix
+
+# Select event loop implementation
+# eloop = select() loop (default)
+# eloop_win = Windows events and WaitForMultipleObject() loop
+# eloop_none = Empty template
+#CONFIG_ELOOP=eloop
+
+# Select layer 2 packet implementation
+# linux = Linux packet socket (default)
+# pcap = libpcap/libdnet/WinPcap
+# freebsd = FreeBSD libpcap
+# winpcap = WinPcap with receive thread
+# ndis = Windows NDISUIO (note: requires CONFIG_USE_NDISUIO=y)
+# none = Empty template
+#CONFIG_L2_PACKET=linux
+
+# PeerKey handshake for Station to Station Link (IEEE 802.11e DLS)
+CONFIG_PEERKEY=y
+
+# IEEE 802.11w (management frame protection)
+# This version is an experimental implementation based on IEEE 802.11w/D1.0
+# draft and is subject to change since the standard has not yet been finalized.
+# Driver support is also needed for IEEE 802.11w.
+CONFIG_IEEE80211W=y
+
+# Select TLS implementation
+# openssl = OpenSSL (default)
+# gnutls = GnuTLS (needed for TLS/IA, see also CONFIG_GNUTLS_EXTRA)
+# internal = Internal TLSv1 implementation (experimental)
+# none = Empty template
+CONFIG_TLS=internal
+
+# Whether to enable TLS/IA support, which is required for EAP-TTLSv1.
+# You need CONFIG_TLS=gnutls for this to have any effect. Please note that
+# even though the core GnuTLS library is released under LGPL, this extra
+# library uses GPL and as such, the terms of GPL apply to the combination
+# of wpa_supplicant and GnuTLS if this option is enabled. BSD license may not
+# apply for distribution of the resulting binary.
+#CONFIG_GNUTLS_EXTRA=y
+
+# If CONFIG_TLS=internal is used, additional library and include paths are
+# needed for LibTomMath. Alternatively, an integrated, minimal version of
+# LibTomMath can be used. See beginning of libtommath.c for details on benefits
+# and drawbacks of this option.
+CONFIG_INTERNAL_LIBTOMMATH=y
+#ifndef CONFIG_INTERNAL_LIBTOMMATH
+#LTM_PATH=/usr/src/libtommath-0.39
+#CFLAGS += -I$(LTM_PATH)
+#LIBS += -L$(LTM_PATH)
+#LIBS_p += -L$(LTM_PATH)
+#endif
+# At the cost of about 4 kB of additional binary size, the internal LibTomMath
+# can be configured to include faster routines for exptmod, sqr, and div to
+# speed up DH and RSA calculation considerably
+CONFIG_INTERNAL_LIBTOMMATH_FAST=y
+
+# Include NDIS event processing through WMI into wpa_supplicant/wpasvc.
+# This is only for Windows builds and requires WMI-related header files and
+# WbemUuid.Lib from Platform SDK even when building with MinGW.
+#CONFIG_NDIS_EVENTS_INTEGRATED=y
+#PLATFORMSDKLIB="/opt/Program Files/Microsoft Platform SDK/Lib"
+
+# Add support for old DBus control interface
+# (fi.epitest.hostap.WPASupplicant)
+#CONFIG_CTRL_IFACE_DBUS=y
+
+# Add support for new DBus control interface
+# (fi.w1.hostap.wpa_supplicant1)
+#CONFIG_CTRL_IFACE_DBUS_NEW=y
+
+# Add introspection support for new DBus control interface
+#CONFIG_CTRL_IFACE_DBUS_INTRO=y
+
+# Add support for loading EAP methods dynamically as shared libraries.
+# When this option is enabled, each EAP method can be either included
+# statically (CONFIG_EAP_<method>=y) or dynamically (CONFIG_EAP_<method>=dyn).
+# Dynamic EAP methods are build as shared objects (eap_*.so) and they need to
+# be loaded in the beginning of the wpa_supplicant configuration file
+# (see load_dynamic_eap parameter in the example file) before being used in
+# the network blocks.
+#
+# Note that some shared parts of EAP methods are included in the main program
+# and in order to be able to use dynamic EAP methods using these parts, the
+# main program must have been build with the EAP method enabled (=y or =dyn).
+# This means that EAP-TLS/PEAP/TTLS/FAST cannot be added as dynamic libraries
+# unless at least one of them was included in the main build to force inclusion
+# of the shared code. Similarly, at least one of EAP-SIM/AKA must be included
+# in the main build to be able to load these methods dynamically.
+#
+# Please also note that using dynamic libraries will increase the total binary
+# size. Thus, it may not be the best option for targets that have limited
+# amount of memory/flash.
+#CONFIG_DYNAMIC_EAP_METHODS=y
+
+# IEEE Std 802.11r-2008 (Fast BSS Transition)
+#CONFIG_IEEE80211R=y
+
+# Add support for writing debug log to a file (/tmp/wpa_supplicant-log-#.txt)
+#CONFIG_DEBUG_FILE=y
+
+# Enable privilege separation (see README 'Privilege separation' for details)
+#CONFIG_PRIVSEP=y
+
+# Enable mitigation against certain attacks against TKIP by delaying Michael
+# MIC error reports by a random amount of time between 0 and 60 seconds
+#CONFIG_DELAYED_MIC_ERROR_REPORT=y
+
+# Enable tracing code for developer debugging
+# This tracks use of memory allocations and other registrations and reports
+# incorrect use with a backtrace of call (or allocation) location.
+#CONFIG_WPA_TRACE=y
+# For BSD, comment out these.
+#LIBS += -lexecinfo
+#LIBS_p += -lexecinfo
+#LIBS_c += -lexecinfo
+
+# Use libbfd to get more details for developer debugging
+# This enables use of libbfd to get more detailed symbols for the backtraces
+# generated by CONFIG_WPA_TRACE=y.
+#CONFIG_WPA_TRACE_BFD=y
+# For BSD, comment out these.
+#LIBS += -lbfd -liberty -lz
+#LIBS_p += -lbfd -liberty -lz
+#LIBS_c += -lbfd -liberty -lz
+
+NEED_80211_COMMON=y
+
+CONFIG_IBSS_RSN=y
diff --git a/package/network/services/hostapd/files/wpa_supplicant-mini.config b/package/network/services/hostapd/files/wpa_supplicant-mini.config
new file mode 100644
index 0000000..772e1d9
--- /dev/null
+++ b/package/network/services/hostapd/files/wpa_supplicant-mini.config
@@ -0,0 +1,406 @@
+# Example wpa_supplicant build time configuration
+#
+# This file lists the configuration options that are used when building the
+# hostapd binary. All lines starting with # are ignored. Configuration option
+# lines must be commented out complete, if they are not to be included, i.e.,
+# just setting VARIABLE=n is not disabling that variable.
+#
+# This file is included in Makefile, so variables like CFLAGS and LIBS can also
+# be modified from here. In most cases, these lines should use += in order not
+# to override previous values of the variables.
+
+
+# Uncomment following two lines and fix the paths if you have installed OpenSSL
+# or GnuTLS in non-default location
+#CFLAGS += -I/usr/local/openssl/include
+#LIBS += -L/usr/local/openssl/lib
+
+# Some Red Hat versions seem to include kerberos header files from OpenSSL, but
+# the kerberos files are not in the default include path. Following line can be
+# used to fix build issues on such systems (krb5.h not found).
+#CFLAGS += -I/usr/include/kerberos
+
+# Example configuration for various cross-compilation platforms
+
+#### sveasoft (e.g., for Linksys WRT54G) ######################################
+#CC=mipsel-uclibc-gcc
+#CC=/opt/brcm/hndtools-mipsel-uclibc/bin/mipsel-uclibc-gcc
+#CFLAGS += -Os
+#CPPFLAGS += -I../src/include -I../../src/router/openssl/include
+#LIBS += -L/opt/brcm/hndtools-mipsel-uclibc-0.9.19/lib -lssl
+###############################################################################
+
+#### openwrt (e.g., for Linksys WRT54G) #######################################
+#CC=mipsel-uclibc-gcc
+#CC=/opt/brcm/hndtools-mipsel-uclibc/bin/mipsel-uclibc-gcc
+#CFLAGS += -Os
+#CPPFLAGS=-I../src/include -I../openssl-0.9.7d/include \
+# -I../WRT54GS/release/src/include
+#LIBS = -lssl
+###############################################################################
+
+
+# Driver interface for Host AP driver
+CONFIG_DRIVER_HOSTAP=y
+
+# Driver interface for Agere driver
+#CONFIG_DRIVER_HERMES=y
+# Change include directories to match with the local setup
+#CFLAGS += -I../../hcf -I../../include -I../../include/hcf
+#CFLAGS += -I../../include/wireless
+
+# Driver interface for madwifi driver
+# Deprecated; use CONFIG_DRIVER_WEXT=y instead.
+#CONFIG_DRIVER_MADWIFI=y
+# Set include directory to the madwifi source tree
+#CFLAGS += -I../../madwifi
+
+# Driver interface for ndiswrapper
+# Deprecated; use CONFIG_DRIVER_WEXT=y instead.
+#CONFIG_DRIVER_NDISWRAPPER=y
+
+# Driver interface for Atmel driver
+# CONFIG_DRIVER_ATMEL=y
+
+# Driver interface for old Broadcom driver
+# Please note that the newer Broadcom driver ("hybrid Linux driver") supports
+# Linux wireless extensions and does not need (or even work) with the old
+# driver wrapper. Use CONFIG_DRIVER_WEXT=y with that driver.
+#CONFIG_DRIVER_BROADCOM=y
+# Example path for wlioctl.h; change to match your configuration
+#CFLAGS += -I/opt/WRT54GS/release/src/include
+
+# Driver interface for Intel ipw2100/2200 driver
+# Deprecated; use CONFIG_DRIVER_WEXT=y instead.
+#CONFIG_DRIVER_IPW=y
+
+# Driver interface for Ralink driver
+#CONFIG_DRIVER_RALINK=y
+
+# Driver interface for generic Linux wireless extensions
+CONFIG_DRIVER_WEXT=y
+
+# Driver interface for Linux drivers using the nl80211 kernel interface
+CONFIG_DRIVER_NL80211=y
+
+# Driver interface for FreeBSD net80211 layer (e.g., Atheros driver)
+#CONFIG_DRIVER_BSD=y
+#CFLAGS += -I/usr/local/include
+#LIBS += -L/usr/local/lib
+#LIBS_p += -L/usr/local/lib
+#LIBS_c += -L/usr/local/lib
+
+# Driver interface for Windows NDIS
+#CONFIG_DRIVER_NDIS=y
+#CFLAGS += -I/usr/include/w32api/ddk
+#LIBS += -L/usr/local/lib
+# For native build using mingw
+#CONFIG_NATIVE_WINDOWS=y
+# Additional directories for cross-compilation on Linux host for mingw target
+#CFLAGS += -I/opt/mingw/mingw32/include/ddk
+#LIBS += -L/opt/mingw/mingw32/lib
+#CC=mingw32-gcc
+# By default, driver_ndis uses WinPcap for low-level operations. This can be
+# replaced with the following option which replaces WinPcap calls with NDISUIO.
+# However, this requires that WZC is disabled (net stop wzcsvc) before starting
+# wpa_supplicant.
+# CONFIG_USE_NDISUIO=y
+
+# Driver interface for development testing
+#CONFIG_DRIVER_TEST=y
+
+# Include client MLME (management frame processing) for test driver
+# This can be used to test MLME operations in hostapd with the test interface.
+# space.
+#CONFIG_CLIENT_MLME=y
+
+# Driver interface for wired Ethernet drivers
+CONFIG_DRIVER_WIRED=y
+
+# Driver interface for the Broadcom RoboSwitch family
+#CONFIG_DRIVER_ROBOSWITCH=y
+
+# Driver interface for no driver (e.g., WPS ER only)
+#CONFIG_DRIVER_NONE=y
+
+# Enable IEEE 802.1X Supplicant (automatically included if any EAP method is
+# included)
+# CONFIG_IEEE8021X_EAPOL=y
+
+# EAP-MD5
+# CONFIG_EAP_MD5=y
+
+# EAP-MSCHAPv2
+# CONFIG_EAP_MSCHAPV2=y
+
+# EAP-TLS
+# CONFIG_EAP_TLS=y
+
+# EAL-PEAP
+# CONFIG_EAP_PEAP=y
+
+# EAP-TTLS
+# CONFIG_EAP_TTLS=y
+
+# EAP-FAST
+# Note: Default OpenSSL package does not include support for all the
+# functionality needed for EAP-FAST. If EAP-FAST is enabled with OpenSSL,
+# the OpenSSL library must be patched (openssl-0.9.8d-tls-extensions.patch)
+# to add the needed functions.
+#CONFIG_EAP_FAST=y
+
+# EAP-GTC
+# CONFIG_EAP_GTC=y
+
+# EAP-OTP
+# CONFIG_EAP_OTP=y
+
+# EAP-SIM (enable CONFIG_PCSC, if EAP-SIM is used)
+#CONFIG_EAP_SIM=y
+
+# EAP-PSK (experimental; this is _not_ needed for WPA-PSK)
+#CONFIG_EAP_PSK=y
+
+# EAP-PAX
+#CONFIG_EAP_PAX=y
+
+# LEAP
+# CONFIG_EAP_LEAP=y
+
+# EAP-AKA (enable CONFIG_PCSC, if EAP-AKA is used)
+#CONFIG_EAP_AKA=y
+
+# EAP-AKA' (enable CONFIG_PCSC, if EAP-AKA' is used).
+# This requires CONFIG_EAP_AKA to be enabled, too.
+#CONFIG_EAP_AKA_PRIME=y
+
+# Enable USIM simulator (Milenage) for EAP-AKA
+#CONFIG_USIM_SIMULATOR=y
+
+# EAP-SAKE
+#CONFIG_EAP_SAKE=y
+
+# EAP-GPSK
+#CONFIG_EAP_GPSK=y
+# Include support for optional SHA256 cipher suite in EAP-GPSK
+#CONFIG_EAP_GPSK_SHA256=y
+
+# EAP-TNC and related Trusted Network Connect support (experimental)
+#CONFIG_EAP_TNC=y
+
+# Wi-Fi Protected Setup (WPS)
+#CONFIG_WPS=y
+
+# EAP-IKEv2
+#CONFIG_EAP_IKEV2=y
+
+# PKCS#12 (PFX) support (used to read private key and certificate file from
+# a file that usually has extension .p12 or .pfx)
+# CONFIG_PKCS12=y
+
+# Smartcard support (i.e., private key on a smartcard), e.g., with openssl
+# engine.
+# CONFIG_SMARTCARD=y
+
+# PC/SC interface for smartcards (USIM, GSM SIM)
+# Enable this if EAP-SIM or EAP-AKA is included
+#CONFIG_PCSC=y
+
+# Development testing
+#CONFIG_EAPOL_TEST=y
+
+# Select control interface backend for external programs, e.g, wpa_cli:
+# unix = UNIX domain sockets (default for Linux/*BSD)
+# udp = UDP sockets using localhost (127.0.0.1)
+# named_pipe = Windows Named Pipe (default for Windows)
+# y = use default (backwards compatibility)
+# If this option is commented out, control interface is not included in the
+# build.
+CONFIG_CTRL_IFACE=y
+
+# Include support for GNU Readline and History Libraries in wpa_cli.
+# When building a wpa_cli binary for distribution, please note that these
+# libraries are licensed under GPL and as such, BSD license may not apply for
+# the resulting binary.
+#CONFIG_READLINE=y
+
+# Remove debugging code that is printing out debug message to stdout.
+# This can be used to reduce the size of the wpa_supplicant considerably
+# if debugging code is not needed. The size reduction can be around 35%
+# (e.g., 90 kB).
+#CONFIG_NO_STDOUT_DEBUG=y
+
+# Remove WPA support, e.g., for wired-only IEEE 802.1X supplicant, to save
+# 35-50 kB in code size.
+#CONFIG_NO_WPA=y
+
+# Remove WPA2 support. This allows WPA to be used, but removes WPA2 code to
+# save about 1 kB in code size when building only WPA-Personal (no EAP support)
+# or 6 kB if building for WPA-Enterprise.
+#CONFIG_NO_WPA2=y
+
+# Remove IEEE 802.11i/WPA-Personal ASCII passphrase support
+# This option can be used to reduce code size by removing support for
+# converting ASCII passphrases into PSK. If this functionality is removed, the
+# PSK can only be configured as the 64-octet hexstring (e.g., from
+# wpa_passphrase). This saves about 0.5 kB in code size.
+#CONFIG_NO_WPA_PASSPHRASE=y
+
+# Disable scan result processing (ap_mode=1) to save code size by about 1 kB.
+# This can be used if ap_scan=1 mode is never enabled.
+#CONFIG_NO_SCAN_PROCESSING=y
+
+# Select configuration backend:
+# file = text file (e.g., wpa_supplicant.conf; note: the configuration file
+# path is given on command line, not here; this option is just used to
+# select the backend that allows configuration files to be used)
+# winreg = Windows registry (see win_example.reg for an example)
+CONFIG_BACKEND=file
+
+# Remove configuration write functionality (i.e., to allow the configuration
+# file to be updated based on runtime configuration changes). The runtime
+# configuration can still be changed, the changes are just not going to be
+# persistent over restarts. This option can be used to reduce code size by
+# about 3.5 kB.
+#CONFIG_NO_CONFIG_WRITE=y
+
+# Remove support for configuration blobs to reduce code size by about 1.5 kB.
+#CONFIG_NO_CONFIG_BLOBS=y
+
+# Select program entry point implementation:
+# main = UNIX/POSIX like main() function (default)
+# main_winsvc = Windows service (read parameters from registry)
+# main_none = Very basic example (development use only)
+#CONFIG_MAIN=main
+
+# Select wrapper for operatins system and C library specific functions
+# unix = UNIX/POSIX like systems (default)
+# win32 = Windows systems
+# none = Empty template
+#CONFIG_OS=unix
+
+# Select event loop implementation
+# eloop = select() loop (default)
+# eloop_win = Windows events and WaitForMultipleObject() loop
+# eloop_none = Empty template
+#CONFIG_ELOOP=eloop
+
+# Select layer 2 packet implementation
+# linux = Linux packet socket (default)
+# pcap = libpcap/libdnet/WinPcap
+# freebsd = FreeBSD libpcap
+# winpcap = WinPcap with receive thread
+# ndis = Windows NDISUIO (note: requires CONFIG_USE_NDISUIO=y)
+# none = Empty template
+#CONFIG_L2_PACKET=linux
+
+# PeerKey handshake for Station to Station Link (IEEE 802.11e DLS)
+# CONFIG_PEERKEY=y
+
+# IEEE 802.11w (management frame protection)
+# This version is an experimental implementation based on IEEE 802.11w/D1.0
+# draft and is subject to change since the standard has not yet been finalized.
+# Driver support is also needed for IEEE 802.11w.
+#CONFIG_IEEE80211W=y
+
+# Select TLS implementation
+# openssl = OpenSSL (default)
+# gnutls = GnuTLS (needed for TLS/IA, see also CONFIG_GNUTLS_EXTRA)
+# internal = Internal TLSv1 implementation (experimental)
+# none = Empty template
+CONFIG_TLS=internal
+
+# Whether to enable TLS/IA support, which is required for EAP-TTLSv1.
+# You need CONFIG_TLS=gnutls for this to have any effect. Please note that
+# even though the core GnuTLS library is released under LGPL, this extra
+# library uses GPL and as such, the terms of GPL apply to the combination
+# of wpa_supplicant and GnuTLS if this option is enabled. BSD license may not
+# apply for distribution of the resulting binary.
+#CONFIG_GNUTLS_EXTRA=y
+
+# If CONFIG_TLS=internal is used, additional library and include paths are
+# needed for LibTomMath. Alternatively, an integrated, minimal version of
+# LibTomMath can be used. See beginning of libtommath.c for details on benefits
+# and drawbacks of this option.
+#CONFIG_INTERNAL_LIBTOMMATH=y
+#ifndef CONFIG_INTERNAL_LIBTOMMATH
+#LTM_PATH=/usr/src/libtommath-0.39
+#CFLAGS += -I$(LTM_PATH)
+#LIBS += -L$(LTM_PATH)
+#LIBS_p += -L$(LTM_PATH)
+#endif
+# At the cost of about 4 kB of additional binary size, the internal LibTomMath
+# can be configured to include faster routines for exptmod, sqr, and div to
+# speed up DH and RSA calculation considerably
+#CONFIG_INTERNAL_LIBTOMMATH_FAST=y
+
+# Include NDIS event processing through WMI into wpa_supplicant/wpasvc.
+# This is only for Windows builds and requires WMI-related header files and
+# WbemUuid.Lib from Platform SDK even when building with MinGW.
+#CONFIG_NDIS_EVENTS_INTEGRATED=y
+#PLATFORMSDKLIB="/opt/Program Files/Microsoft Platform SDK/Lib"
+
+# Add support for old DBus control interface
+# (fi.epitest.hostap.WPASupplicant)
+#CONFIG_CTRL_IFACE_DBUS=y
+
+# Add support for new DBus control interface
+# (fi.w1.hostap.wpa_supplicant1)
+#CONFIG_CTRL_IFACE_DBUS_NEW=y
+
+# Add introspection support for new DBus control interface
+#CONFIG_CTRL_IFACE_DBUS_INTRO=y
+
+# Add support for loading EAP methods dynamically as shared libraries.
+# When this option is enabled, each EAP method can be either included
+# statically (CONFIG_EAP_<method>=y) or dynamically (CONFIG_EAP_<method>=dyn).
+# Dynamic EAP methods are build as shared objects (eap_*.so) and they need to
+# be loaded in the beginning of the wpa_supplicant configuration file
+# (see load_dynamic_eap parameter in the example file) before being used in
+# the network blocks.
+#
+# Note that some shared parts of EAP methods are included in the main program
+# and in order to be able to use dynamic EAP methods using these parts, the
+# main program must have been build with the EAP method enabled (=y or =dyn).
+# This means that EAP-TLS/PEAP/TTLS/FAST cannot be added as dynamic libraries
+# unless at least one of them was included in the main build to force inclusion
+# of the shared code. Similarly, at least one of EAP-SIM/AKA must be included
+# in the main build to be able to load these methods dynamically.
+#
+# Please also note that using dynamic libraries will increase the total binary
+# size. Thus, it may not be the best option for targets that have limited
+# amount of memory/flash.
+#CONFIG_DYNAMIC_EAP_METHODS=y
+
+# IEEE Std 802.11r-2008 (Fast BSS Transition)
+#CONFIG_IEEE80211R=y
+
+# Add support for writing debug log to a file (/tmp/wpa_supplicant-log-#.txt)
+#CONFIG_DEBUG_FILE=y
+
+# Enable privilege separation (see README 'Privilege separation' for details)
+#CONFIG_PRIVSEP=y
+
+# Enable mitigation against certain attacks against TKIP by delaying Michael
+# MIC error reports by a random amount of time between 0 and 60 seconds
+#CONFIG_DELAYED_MIC_ERROR_REPORT=y
+
+# Enable tracing code for developer debugging
+# This tracks use of memory allocations and other registrations and reports
+# incorrect use with a backtrace of call (or allocation) location.
+#CONFIG_WPA_TRACE=y
+# For BSD, comment out these.
+#LIBS += -lexecinfo
+#LIBS_p += -lexecinfo
+#LIBS_c += -lexecinfo
+
+# Use libbfd to get more details for developer debugging
+# This enables use of libbfd to get more detailed symbols for the backtraces
+# generated by CONFIG_WPA_TRACE=y.
+#CONFIG_WPA_TRACE_BFD=y
+# For BSD, comment out these.
+#LIBS += -lbfd -liberty -lz
+#LIBS_p += -lbfd -liberty -lz
+#LIBS_c += -lbfd -liberty -lz
+
+NEED_80211_COMMON=y
diff --git a/package/network/services/hostapd/files/wpa_supplicant.sh b/package/network/services/hostapd/files/wpa_supplicant.sh
new file mode 100644
index 0000000..0b5e1d3
--- /dev/null
+++ b/package/network/services/hostapd/files/wpa_supplicant.sh
@@ -0,0 +1,194 @@
+wpa_supplicant_setup_vif() {
+ local vif="$1"
+ local driver="$2"
+ local key="$key"
+ local options="$3"
+ local freq=""
+ local ht="$5"
+ local ap_scan=""
+ local scan_ssid="1"
+ [ -n "$4" ] && freq="frequency=$4"
+
+ config_get enc "$vif" encryption
+ config_get key "$vif" key
+
+ local net_cfg bridge
+ config_get bridge "$vif" bridge
+ [ -z "$bridge" ] && {
+ net_cfg="$(find_net_config "$vif")"
+ [ -z "$net_cfg" ] || bridge="$(bridge_interface "$net_cfg")"
+ config_set "$vif" bridge "$bridge"
+ }
+
+ local mode ifname wds modestr=""
+ config_get mode "$vif" mode
+ config_get ifname "$vif" ifname
+ config_get_bool wds "$vif" wds 0
+ [ -z "$bridge" ] || [ "$mode" = ap ] || [ "$mode" = sta -a $wds -eq 1 ] || {
+ echo "wpa_supplicant_setup_vif($ifname): Refusing to bridge $mode mode interface"
+ return 1
+ }
+ [ "$mode" = "adhoc" ] && {
+ modestr="mode=1"
+ scan_ssid="0"
+ ap_scan="ap_scan=2"
+ }
+
+ key_mgmt='NONE'
+ case "$enc" in
+ *none*) ;;
+ *wep*)
+ config_get key "$vif" key
+ key="${key:-1}"
+ case "$key" in
+ [1234])
+ for idx in 1 2 3 4; do
+ local zidx
+ zidx=$(($idx - 1))
+ config_get ckey "$vif" "key${idx}"
+ [ -n "$ckey" ] && \
+ append "wep_key${zidx}" "wep_key${zidx}=$(prepare_key_wep "$ckey")"
+ done
+ wep_tx_keyidx="wep_tx_keyidx=$((key - 1))"
+ ;;
+ *)
+ wep_key0="wep_key0=$(prepare_key_wep "$key")"
+ wep_tx_keyidx="wep_tx_keyidx=0"
+ ;;
+ esac
+ ;;
+ *psk*)
+ key_mgmt='WPA-PSK'
+ # if you want to use PSK with a non-nl80211 driver you
+ # have to use WPA-NONE and wext driver for wpa_s
+ [ "$mode" = "adhoc" -a "$driver" != "nl80211" ] && {
+ key_mgmt='WPA-NONE'
+ driver='wext'
+ }
+ if [ ${#key} -eq 64 ]; then
+ passphrase="psk=${key}"
+ else
+ passphrase="psk=\"${key}\""
+ fi
+ case "$enc" in
+ *psk2*)
+ proto='proto=RSN'
+ config_get ieee80211w "$vif" ieee80211w
+ ;;
+ *psk*)
+ proto='proto=WPA'
+ ;;
+ esac
+ ;;
+ *wpa*|*8021x*)
+ proto='proto=WPA2'
+ key_mgmt='WPA-EAP'
+ config_get ieee80211w "$vif" ieee80211w
+ config_get ca_cert "$vif" ca_cert
+ config_get eap_type "$vif" eap_type
+ ca_cert=${ca_cert:+"ca_cert=\"$ca_cert\""}
+ case "$eap_type" in
+ tls)
+ pairwise='pairwise=CCMP'
+ group='group=CCMP'
+ config_get identity "$vif" identity
+ config_get client_cert "$vif" client_cert
+ config_get priv_key "$vif" priv_key
+ config_get priv_key_pwd "$vif" priv_key_pwd
+ identity="identity=\"$identity\""
+ client_cert="client_cert=\"$client_cert\""
+ priv_key="private_key=\"$priv_key\""
+ priv_key_pwd="private_key_passwd=\"$priv_key_pwd\""
+ ;;
+ peap|ttls)
+ config_get auth "$vif" auth
+ config_get identity "$vif" identity
+ config_get password "$vif" password
+ phase2="phase2=\"auth=${auth:-MSCHAPV2}\""
+ identity="identity=\"$identity\""
+ password="${password:+password=\"$password\"}"
+ ;;
+ esac
+ eap_type="eap=$(echo $eap_type | tr 'a-z' 'A-Z')"
+ ;;
+ esac
+
+ case "$ieee80211w" in
+ [012])
+ ieee80211w="ieee80211w=$ieee80211w"
+ ;;
+ esac
+
+ local fixed_freq bssid1 beacon_interval brates mrate
+ config_get ifname "$vif" ifname
+ config_get bridge "$vif" bridge
+ config_get ssid "$vif" ssid
+ config_get bssid "$vif" bssid
+ bssid1=${bssid:+"bssid=$bssid"}
+ beacon_interval=${beacon_int:+"beacon_interval=$beacon_int"}
+
+ local br brval brsub brstr
+ [ -n "$basic_rate_list" ] && {
+ for br in $basic_rate_list; do
+ brval="$(($br / 1000))"
+ brsub="$((($br / 100) % 10))"
+ [ "$brsub" -gt 0 ] && brval="$brval.$brsub"
+ [ -n "$brstr" ] && brstr="$brstr,"
+ brstr="$brstr$brval"
+ done
+ brates=${basic_rate_list:+"rates=$brstr"}
+ }
+
+ local mcval=""
+ [ -n "$mcast_rate" ] && {
+ mcval="$(($mcast_rate / 1000))"
+ mcsub="$(( ($mcast_rate / 100) % 10 ))"
+ [ "$mcsub" -gt 0 ] && mcval="$mcval.$mcsub"
+ mrate=${mcast_rate:+"mcast_rate=$mcval"}
+ }
+
+ local ht_str
+ [ -n "$ht" ] && ht_str="htmode=$ht"
+
+ rm -rf /var/run/wpa_supplicant-$ifname
+ cat > /var/run/wpa_supplicant-$ifname.conf <<EOF
+ctrl_interface=/var/run/wpa_supplicant-$ifname
+$ap_scan
+network={
+ $modestr
+ scan_ssid=$scan_ssid
+ ssid="$ssid"
+ $bssid1
+ key_mgmt=$key_mgmt
+ $proto
+ $freq
+ ${fixed:+"fixed_freq=1"}
+ $beacon_interval
+ $brates
+ $mrate
+ $ht_str
+ $ieee80211w
+ $passphrase
+ $pairwise
+ $group
+ $eap_type
+ $ca_cert
+ $client_cert
+ $priv_key
+ $priv_key_pwd
+ $phase2
+ $identity
+ $password
+ $wep_key0
+ $wep_key1
+ $wep_key2
+ $wep_key3
+ $wep_tx_keyidx
+}
+EOF
+ if [ -n "$proto" -o "$key_mgmt" == "NONE" ]; then
+ wpa_supplicant ${bridge:+ -b $bridge} -B -P "/var/run/wifi-${ifname}.pid" -D ${driver:-wext} -i "$ifname" -c /var/run/wpa_supplicant-$ifname.conf $options
+ else
+ return 0
+ fi
+}
diff --git a/package/network/services/hostapd/files/wps-hotplug.sh b/package/network/services/hostapd/files/wps-hotplug.sh
new file mode 100644
index 0000000..ffd3cf9
--- /dev/null
+++ b/package/network/services/hostapd/files/wps-hotplug.sh
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+if [ "$ACTION" = "pressed" -a "$BUTTON" = "wps" ]; then
+ for dir in /var/run/hostapd-*; do
+ [ -d "$dir" ] || continue
+ hostapd_cli -p "$dir" wps_pbc
+ done
+fi
diff --git a/package/network/services/hostapd/madwifi/.svn/entries b/package/network/services/hostapd/madwifi/.svn/entries
new file mode 100644
index 0000000..0e6f30f
--- /dev/null
+++ b/package/network/services/hostapd/madwifi/.svn/entries
@@ -0,0 +1,34 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/services/hostapd/madwifi
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-05T22:06:30.166484Z
+35893
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+net80211
+dir
+
+include
+dir
+
diff --git a/package/network/services/hostapd/madwifi/include/.svn/entries b/package/network/services/hostapd/madwifi/include/.svn/entries
new file mode 100644
index 0000000..a7a8d6d
--- /dev/null
+++ b/package/network/services/hostapd/madwifi/include/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/services/hostapd/madwifi/include
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-05T22:06:30.166484Z
+35893
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+compat.h
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+e4dcff728d11a3623ab23a7a463f51b7
+2013-03-05T22:06:30.166484Z
+35893
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+6338
+
diff --git a/package/network/services/hostapd/madwifi/include/.svn/text-base/compat.h.svn-base b/package/network/services/hostapd/madwifi/include/.svn/text-base/compat.h.svn-base
new file mode 100644
index 0000000..09e6397
--- /dev/null
+++ b/package/network/services/hostapd/madwifi/include/.svn/text-base/compat.h.svn-base
@@ -0,0 +1,209 @@
+/*-
+ * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer,
+ * without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
+ * redistribution must be conditioned upon including a substantially
+ * similar Disclaimer requirement for further binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ * of any contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ * $Id: compat.h 3310 2008-01-30 20:23:49Z mentor $
+ */
+#ifndef _ATH_COMPAT_H_
+#define _ATH_COMPAT_H_
+
+/* Compatibility with older Linux kernels */
+#ifdef __KERNEL__
+#include <linux/types.h>
+#include <linux/time.h>
+#include <linux/netdevice.h>
+#endif
+
+#if !defined(__KERNEL__) || !defined (__bitwise)
+#define __le16 u_int16_t
+#define __le32 u_int32_t
+#define __le64 u_int64_t
+#define __be16 u_int16_t
+#define __be32 u_int32_t
+#define __be64 u_int64_t
+#define __force
+#endif
+
+#ifndef container_of
+#define container_of(ptr, type, member) ({ \
+ const typeof( ((type *)0)->member ) *__mptr = (ptr); \
+ (type *)( (char *)__mptr - offsetof(type,member) );})
+#endif
+
+#ifndef list_for_each_entry_reverse
+#define list_for_each_entry_reverse(pos, head, member) \
+ for (pos = list_entry((head)->prev, typeof(*pos), member); \
+ prefetch(pos->member.prev), &pos->member != (head); \
+ pos = list_entry(pos->member.prev, typeof(*pos), member))
+#endif
+
+#ifndef NETDEV_TX_OK
+#define NETDEV_TX_OK 0
+#define NETDEV_TX_BUSY 1
+#endif
+
+/*
+ * BSD/Linux compatibility shims. These are used mainly to
+ * minimize differences when importing necesary BSD code.
+ */
+#define NBBY 8 /* number of bits/byte */
+
+/* roundup() appears in Linux 2.6.18 */
+#include <linux/kernel.h>
+#ifndef roundup
+#define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) /* to any y */
+#endif
+
+#define howmany(x, y) (((x)+((y)-1))/(y))
+
+/* Bit map related macros. */
+#define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY))
+#define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
+#define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY)))
+#define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
+
+#ifndef __packed
+#define __packed __attribute__((__packed__))
+#endif
+
+#define __offsetof(t,m) offsetof(t,m)
+
+#ifndef ALIGNED_POINTER
+/*
+ * ALIGNED_POINTER is a boolean macro that checks whether an address
+ * is valid to fetch data elements of type t from on this architecture.
+ * This does not reflect the optimal alignment, just the possibility
+ * (within reasonable limits).
+ *
+ */
+#define ALIGNED_POINTER(p,t) 1
+#endif
+
+#ifdef __KERNEL__
+#define KASSERT(exp, msg) do { \
+ if (unlikely(!(exp))) { \
+ printk msg; \
+ BUG(); \
+ } \
+} while (0)
+#endif /* __KERNEL__ */
+
+/*
+ * NetBSD/FreeBSD defines for file version.
+ */
+#define __FBSDID(_s)
+#define __KERNEL_RCSID(_n,_s)
+
+/*
+ * Fixes for Linux API changes
+ */
+#ifdef __KERNEL__
+
+#include <linux/version.h>
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)
+#define AUTOCONF_INCLUDED 1
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)
+#define ATH_REGISTER_SYSCTL_TABLE(t) register_sysctl_table(t, 1)
+#else
+#define ATH_REGISTER_SYSCTL_TABLE(t) register_sysctl_table(t)
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9)
+#define __user
+#define __kernel
+#define __iomem
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)
+typedef int gfp_t;
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16)
+static inline int timeval_compare(struct timeval *lhs, struct timeval *rhs)
+{
+ if (lhs->tv_sec < rhs->tv_sec)
+ return -1;
+ if (lhs->tv_sec > rhs->tv_sec)
+ return 1;
+ return lhs->tv_usec - rhs->tv_usec;
+}
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
+#define IRQF_SHARED SA_SHIRQ
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,27)
+#define netdev_priv(_netdev) ((_netdev)->priv)
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
+#define skb_end_pointer(_skb) ((_skb)->end)
+#define skb_tail_pointer(_skb) ((_skb)->tail)
+#define skb_set_network_header(_skb, _offset) \
+ do { (_skb)->nh.raw = (_skb)->data + (_offset); } while(0)
+#define skb_reset_network_header(_skb) \
+ do { (_skb)->nh.raw = (_skb)->data; } while(0)
+#define skb_mac_header(_skb) ((_skb)->mac.raw)
+#define skb_reset_mac_header(_skb) \
+ do { (_skb)->mac.raw = (_skb)->data; } while(0)
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
+#define CTL_AUTO -2
+#define DEV_ATH 9
+#else
+#define CTL_AUTO CTL_UNNUMBERED
+#define DEV_ATH CTL_UNNUMBERED
+#endif
+
+/* __skb_append got a third parameter in 2.6.14 */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)
+#define __skb_queue_after(_list, _old, _new) __skb_append(_old, _new)
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)
+#define __skb_queue_after(_list, _old, _new) __skb_append(_old, _new, _list)
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
+#define CTLNAME(x) .ctl_name = x,
+#else
+#define CTLNAME(x)
+#endif
+
+#endif /* __KERNEL__ */
+
+#endif /* _ATH_COMPAT_H_ */
diff --git a/package/network/services/hostapd/madwifi/include/compat.h b/package/network/services/hostapd/madwifi/include/compat.h
new file mode 100644
index 0000000..09e6397
--- /dev/null
+++ b/package/network/services/hostapd/madwifi/include/compat.h
@@ -0,0 +1,209 @@
+/*-
+ * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer,
+ * without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
+ * redistribution must be conditioned upon including a substantially
+ * similar Disclaimer requirement for further binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ * of any contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ * $Id: compat.h 3310 2008-01-30 20:23:49Z mentor $
+ */
+#ifndef _ATH_COMPAT_H_
+#define _ATH_COMPAT_H_
+
+/* Compatibility with older Linux kernels */
+#ifdef __KERNEL__
+#include <linux/types.h>
+#include <linux/time.h>
+#include <linux/netdevice.h>
+#endif
+
+#if !defined(__KERNEL__) || !defined (__bitwise)
+#define __le16 u_int16_t
+#define __le32 u_int32_t
+#define __le64 u_int64_t
+#define __be16 u_int16_t
+#define __be32 u_int32_t
+#define __be64 u_int64_t
+#define __force
+#endif
+
+#ifndef container_of
+#define container_of(ptr, type, member) ({ \
+ const typeof( ((type *)0)->member ) *__mptr = (ptr); \
+ (type *)( (char *)__mptr - offsetof(type,member) );})
+#endif
+
+#ifndef list_for_each_entry_reverse
+#define list_for_each_entry_reverse(pos, head, member) \
+ for (pos = list_entry((head)->prev, typeof(*pos), member); \
+ prefetch(pos->member.prev), &pos->member != (head); \
+ pos = list_entry(pos->member.prev, typeof(*pos), member))
+#endif
+
+#ifndef NETDEV_TX_OK
+#define NETDEV_TX_OK 0
+#define NETDEV_TX_BUSY 1
+#endif
+
+/*
+ * BSD/Linux compatibility shims. These are used mainly to
+ * minimize differences when importing necesary BSD code.
+ */
+#define NBBY 8 /* number of bits/byte */
+
+/* roundup() appears in Linux 2.6.18 */
+#include <linux/kernel.h>
+#ifndef roundup
+#define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) /* to any y */
+#endif
+
+#define howmany(x, y) (((x)+((y)-1))/(y))
+
+/* Bit map related macros. */
+#define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY))
+#define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
+#define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY)))
+#define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
+
+#ifndef __packed
+#define __packed __attribute__((__packed__))
+#endif
+
+#define __offsetof(t,m) offsetof(t,m)
+
+#ifndef ALIGNED_POINTER
+/*
+ * ALIGNED_POINTER is a boolean macro that checks whether an address
+ * is valid to fetch data elements of type t from on this architecture.
+ * This does not reflect the optimal alignment, just the possibility
+ * (within reasonable limits).
+ *
+ */
+#define ALIGNED_POINTER(p,t) 1
+#endif
+
+#ifdef __KERNEL__
+#define KASSERT(exp, msg) do { \
+ if (unlikely(!(exp))) { \
+ printk msg; \
+ BUG(); \
+ } \
+} while (0)
+#endif /* __KERNEL__ */
+
+/*
+ * NetBSD/FreeBSD defines for file version.
+ */
+#define __FBSDID(_s)
+#define __KERNEL_RCSID(_n,_s)
+
+/*
+ * Fixes for Linux API changes
+ */
+#ifdef __KERNEL__
+
+#include <linux/version.h>
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)
+#define AUTOCONF_INCLUDED 1
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)
+#define ATH_REGISTER_SYSCTL_TABLE(t) register_sysctl_table(t, 1)
+#else
+#define ATH_REGISTER_SYSCTL_TABLE(t) register_sysctl_table(t)
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9)
+#define __user
+#define __kernel
+#define __iomem
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)
+typedef int gfp_t;
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16)
+static inline int timeval_compare(struct timeval *lhs, struct timeval *rhs)
+{
+ if (lhs->tv_sec < rhs->tv_sec)
+ return -1;
+ if (lhs->tv_sec > rhs->tv_sec)
+ return 1;
+ return lhs->tv_usec - rhs->tv_usec;
+}
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
+#define IRQF_SHARED SA_SHIRQ
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,27)
+#define netdev_priv(_netdev) ((_netdev)->priv)
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
+#define skb_end_pointer(_skb) ((_skb)->end)
+#define skb_tail_pointer(_skb) ((_skb)->tail)
+#define skb_set_network_header(_skb, _offset) \
+ do { (_skb)->nh.raw = (_skb)->data + (_offset); } while(0)
+#define skb_reset_network_header(_skb) \
+ do { (_skb)->nh.raw = (_skb)->data; } while(0)
+#define skb_mac_header(_skb) ((_skb)->mac.raw)
+#define skb_reset_mac_header(_skb) \
+ do { (_skb)->mac.raw = (_skb)->data; } while(0)
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
+#define CTL_AUTO -2
+#define DEV_ATH 9
+#else
+#define CTL_AUTO CTL_UNNUMBERED
+#define DEV_ATH CTL_UNNUMBERED
+#endif
+
+/* __skb_append got a third parameter in 2.6.14 */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)
+#define __skb_queue_after(_list, _old, _new) __skb_append(_old, _new)
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)
+#define __skb_queue_after(_list, _old, _new) __skb_append(_old, _new, _list)
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
+#define CTLNAME(x) .ctl_name = x,
+#else
+#define CTLNAME(x)
+#endif
+
+#endif /* __KERNEL__ */
+
+#endif /* _ATH_COMPAT_H_ */
diff --git a/package/network/services/hostapd/madwifi/net80211/.svn/entries b/package/network/services/hostapd/madwifi/net80211/.svn/entries
new file mode 100644
index 0000000..969938f
--- /dev/null
+++ b/package/network/services/hostapd/madwifi/net80211/.svn/entries
@@ -0,0 +1,164 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/services/hostapd/madwifi/net80211
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-05T22:06:30.166484Z
+35893
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+ieee80211_ioctl.h
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+e9bc766242fe473eafdec4188d7b8b86
+2013-03-05T22:06:30.166484Z
+35893
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+31508
+
+_ieee80211.h
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+a45495712993b760fcaa6f942c6e6474
+2013-03-05T22:06:30.166484Z
+35893
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+12571
+
+ieee80211.h
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+e7cbda12358380f8ccc7ca89ec7bdb85
+2013-03-05T22:06:30.166484Z
+35893
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+32652
+
+ieee80211_crypto.h
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+8aa323d676ab5ae738041224d216cb1d
+2013-03-05T22:06:30.166484Z
+35893
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+8253
+
diff --git a/package/network/services/hostapd/madwifi/net80211/.svn/text-base/_ieee80211.h.svn-base b/package/network/services/hostapd/madwifi/net80211/.svn/text-base/_ieee80211.h.svn-base
new file mode 100644
index 0000000..2d2a06f
--- /dev/null
+++ b/package/network/services/hostapd/madwifi/net80211/.svn/text-base/_ieee80211.h.svn-base
@@ -0,0 +1,325 @@
+/*-
+ * Copyright (c) 2001 Atsushi Onoe
+ * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $Id: _ieee80211.h 3207 2008-01-18 21:25:05Z mtaylor $
+ */
+#ifndef _NET80211__IEEE80211_H_
+#define _NET80211__IEEE80211_H_
+
+enum ieee80211_phytype {
+ IEEE80211_T_DS, /* direct sequence spread spectrum */
+ IEEE80211_T_FH, /* frequency hopping */
+ IEEE80211_T_OFDM, /* frequency division multiplexing */
+ IEEE80211_T_TURBO, /* high rate OFDM, aka turbo mode */
+};
+#define IEEE80211_T_CCK IEEE80211_T_DS /* more common nomenclature */
+
+/* XXX: not really a mode; there are really multiple PHYs */
+enum ieee80211_phymode {
+ IEEE80211_MODE_AUTO = 0, /* autoselect */
+ IEEE80211_MODE_11A = 1, /* 5GHz, OFDM */
+ IEEE80211_MODE_11B = 2, /* 2GHz, CCK */
+ IEEE80211_MODE_11G = 3, /* 2GHz, OFDM */
+ IEEE80211_MODE_FH = 4, /* 2GHz, GFSK */
+ IEEE80211_MODE_TURBO_A = 5, /* 5GHz, OFDM, 2x clock dynamic turbo */
+ IEEE80211_MODE_TURBO_G = 6, /* 2GHz, OFDM, 2x clock dynamic turbo*/
+};
+#define IEEE80211_MODE_MAX (IEEE80211_MODE_TURBO_G+1)
+
+enum ieee80211_opmode {
+ IEEE80211_M_STA = 1, /* infrastructure station */
+ IEEE80211_M_IBSS = 0, /* IBSS (adhoc) station */
+ IEEE80211_M_AHDEMO = 3, /* Old lucent compatible adhoc demo */
+ IEEE80211_M_HOSTAP = 6, /* Software Access Point */
+ IEEE80211_M_MONITOR = 8, /* Monitor mode */
+ IEEE80211_M_WDS = 2 /* WDS link */
+};
+
+/*
+ * True if this mode will send beacon on a regular interval, like AP
+ * or IBSS
+ */
+#define IEEE80211_IS_MODE_BEACON(_opmode) \
+ ((_opmode == IEEE80211_M_IBSS) || \
+ (_opmode == IEEE80211_M_HOSTAP))
+
+/*
+ * True if this mode must behave like a DFS master, ie do Channel
+ * Check Availability and In Service Monitoring. We need to make sure
+ * that all modes cannot send data without being authorized. Such
+ * enforcement is not done in monitor mode however.
+ */
+
+#define IEEE80211_IS_MODE_DFS_MASTER(_opmode) \
+ ((_opmode == IEEE80211_M_IBSS) || \
+ (_opmode == IEEE80211_M_AHDEMO) || \
+ (_opmode == IEEE80211_M_HOSTAP) || \
+ (_opmode == IEEE80211_M_WDS))
+
+/*
+ * 802.11g protection mode.
+ */
+enum ieee80211_protmode {
+ IEEE80211_PROT_NONE = 0, /* no protection */
+ IEEE80211_PROT_CTSONLY = 1, /* CTS to self */
+ IEEE80211_PROT_RTSCTS = 2, /* RTS-CTS */
+};
+
+/*
+ * Authentication mode.
+ */
+enum ieee80211_authmode {
+ IEEE80211_AUTH_NONE = 0,
+ IEEE80211_AUTH_OPEN = 1, /* open */
+ IEEE80211_AUTH_SHARED = 2, /* shared-key */
+ IEEE80211_AUTH_8021X = 3, /* 802.1x */
+ IEEE80211_AUTH_AUTO = 4, /* auto-select/accept */
+ /* NB: these are used only for ioctls */
+ IEEE80211_AUTH_WPA = 5, /* WPA/RSN w/ 802.1x/PSK */
+};
+
+/*
+ * Roaming mode is effectively who controls the operation
+ * of the 802.11 state machine when operating as a station.
+ * State transitions are controlled either by the driver
+ * (typically when management frames are processed by the
+ * hardware/firmware), the host (auto/normal operation of
+ * the 802.11 layer), or explicitly through ioctl requests
+ * when applications like wpa_supplicant want control.
+ */
+enum ieee80211_roamingmode {
+ IEEE80211_ROAMING_DEVICE= 0, /* driver/hardware control */
+ IEEE80211_ROAMING_AUTO = 1, /* 802.11 layer control */
+ IEEE80211_ROAMING_MANUAL= 2, /* application control */
+};
+
+/*
+ * Scanning mode controls station scanning work; this is
+ * used only when roaming mode permits the host to select
+ * the bss to join/channel to use.
+ */
+enum ieee80211_scanmode {
+ IEEE80211_SCAN_DEVICE = 0, /* driver/hardware control */
+ IEEE80211_SCAN_BEST = 1, /* 802.11 layer selects best */
+ IEEE80211_SCAN_FIRST = 2, /* take first suitable candidate */
+};
+
+enum ieee80211_scanflags {
+ IEEE80211_NOSCAN_DEFAULT = (1 << 0),
+ IEEE80211_NOSCAN_SET = (1 << 1),
+};
+
+/*
+ * Channels are specified by frequency and attributes.
+ */
+struct ieee80211_channel {
+ u_int16_t ic_freq; /* setting in MHz */
+ u_int16_t ic_flags; /* see below */
+ u_int8_t ic_ieee; /* IEEE channel number */
+ int8_t ic_maxregpower; /* maximum regulatory tx power in dBm */
+ int8_t ic_maxpower; /* maximum tx power in dBm */
+ int8_t ic_minpower; /* minimum tx power in dBm */
+ u_int8_t ic_scanflags;
+ u_int8_t ic_idletime; /* phy idle time in % */
+};
+
+#define IEEE80211_CHAN_MAX 255
+#define IEEE80211_CHAN_BYTES 32 /* howmany(IEEE80211_CHAN_MAX, NBBY) */
+#define IEEE80211_CHAN_ANY 0xffff /* token for ``any channel'' */
+#define IEEE80211_CHAN_ANYC ((struct ieee80211_channel *) IEEE80211_CHAN_ANY)
+
+#define IEEE80211_RADAR_CHANCHANGE_TBTT_COUNT 0
+#define IEEE80211_DEFAULT_CHANCHANGE_TBTT_COUNT 3
+
+#define IEEE80211_RADAR_TEST_MUTE_CHAN 36 /* Move to channel 36 for mute test */
+
+/* bits 0-3 are for private use by drivers */
+/* channel attributes */
+#define IEEE80211_CHAN_TURBO 0x0010 /* Turbo channel */
+#define IEEE80211_CHAN_CCK 0x0020 /* CCK channel */
+#define IEEE80211_CHAN_OFDM 0x0040 /* OFDM channel */
+#define IEEE80211_CHAN_2GHZ 0x0080 /* 2 GHz spectrum channel. */
+#define IEEE80211_CHAN_5GHZ 0x0100 /* 5 GHz spectrum channel */
+#define IEEE80211_CHAN_PASSIVE 0x0200 /* Only passive scan allowed */
+#define IEEE80211_CHAN_DYN 0x0400 /* Dynamic CCK-OFDM channel */
+#define IEEE80211_CHAN_GFSK 0x0800 /* GFSK channel (FHSS PHY) */
+#define IEEE80211_CHAN_RADAR 0x1000 /* Radar found on channel */
+#define IEEE80211_CHAN_STURBO 0x2000 /* 11a static turbo channel only */
+#define IEEE80211_CHAN_HALF 0x4000 /* Half rate channel */
+#define IEEE80211_CHAN_QUARTER 0x8000 /* Quarter rate channel */
+
+/*
+ * Useful combinations of channel characteristics.
+ */
+#define IEEE80211_CHAN_FHSS \
+ (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_GFSK)
+#define IEEE80211_CHAN_A \
+ (IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM)
+#define IEEE80211_CHAN_B \
+ (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_CCK)
+#define IEEE80211_CHAN_PUREG \
+ (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_OFDM)
+#define IEEE80211_CHAN_G \
+ (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_DYN)
+#define IEEE80211_CHAN_108A \
+ (IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM | IEEE80211_CHAN_TURBO)
+#define IEEE80211_CHAN_108G \
+ (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_OFDM | IEEE80211_CHAN_TURBO)
+#define IEEE80211_CHAN_ST \
+ (IEEE80211_CHAN_108A | IEEE80211_CHAN_STURBO)
+
+#define IEEE80211_CHAN_ALL \
+ (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_GFSK | \
+ IEEE80211_CHAN_CCK | IEEE80211_CHAN_OFDM | IEEE80211_CHAN_DYN)
+#define IEEE80211_CHAN_ALLTURBO \
+ (IEEE80211_CHAN_ALL | IEEE80211_CHAN_TURBO | IEEE80211_CHAN_STURBO)
+
+#define IEEE80211_IS_CHAN_FHSS(_c) \
+ (((_c)->ic_flags & IEEE80211_CHAN_FHSS) == IEEE80211_CHAN_FHSS)
+#define IEEE80211_IS_CHAN_A(_c) \
+ (((_c)->ic_flags & IEEE80211_CHAN_A) == IEEE80211_CHAN_A)
+#define IEEE80211_IS_CHAN_B(_c) \
+ (((_c)->ic_flags & IEEE80211_CHAN_B) == IEEE80211_CHAN_B)
+#define IEEE80211_IS_CHAN_PUREG(_c) \
+ (((_c)->ic_flags & IEEE80211_CHAN_PUREG) == IEEE80211_CHAN_PUREG)
+#define IEEE80211_IS_CHAN_G(_c) \
+ (((_c)->ic_flags & IEEE80211_CHAN_G) == IEEE80211_CHAN_G)
+#define IEEE80211_IS_CHAN_ANYG(_c) \
+ (IEEE80211_IS_CHAN_PUREG(_c) || IEEE80211_IS_CHAN_G(_c))
+#define IEEE80211_IS_CHAN_ST(_c) \
+ (((_c)->ic_flags & IEEE80211_CHAN_ST) == IEEE80211_CHAN_ST)
+#define IEEE80211_IS_CHAN_108A(_c) \
+ (((_c)->ic_flags & IEEE80211_CHAN_108A) == IEEE80211_CHAN_108A)
+#define IEEE80211_IS_CHAN_108G(_c) \
+ (((_c)->ic_flags & IEEE80211_CHAN_108G) == IEEE80211_CHAN_108G)
+
+#define IEEE80211_IS_CHAN_2GHZ(_c) \
+ (((_c)->ic_flags & IEEE80211_CHAN_2GHZ) != 0)
+#define IEEE80211_IS_CHAN_5GHZ(_c) \
+ (((_c)->ic_flags & IEEE80211_CHAN_5GHZ) != 0)
+#define IEEE80211_IS_CHAN_OFDM(_c) \
+ (((_c)->ic_flags & IEEE80211_CHAN_OFDM) != 0)
+#define IEEE80211_IS_CHAN_CCK(_c) \
+ (((_c)->ic_flags & IEEE80211_CHAN_CCK) != 0)
+#define IEEE80211_IS_CHAN_GFSK(_c) \
+ (((_c)->ic_flags & IEEE80211_CHAN_GFSK) != 0)
+#define IEEE80211_IS_CHAN_TURBO(_c) \
+ (((_c)->ic_flags & IEEE80211_CHAN_TURBO) != 0)
+#define IEEE80211_IS_CHAN_STURBO(_c) \
+ (((_c)->ic_flags & IEEE80211_CHAN_STURBO) != 0)
+#define IEEE80211_IS_CHAN_DTURBO(_c) \
+ (((_c)->ic_flags & \
+ (IEEE80211_CHAN_TURBO | IEEE80211_CHAN_STURBO)) == IEEE80211_CHAN_TURBO)
+#define IEEE80211_IS_CHAN_HALF(_c) \
+ (((_c)->ic_flags & IEEE80211_CHAN_HALF) != 0)
+#define IEEE80211_IS_CHAN_QUARTER(_c) \
+ (((_c)->ic_flags & IEEE80211_CHAN_QUARTER) != 0)
+
+#define IEEE80211_IS_CHAN_RADAR(_c) \
+ (((_c)->ic_flags & IEEE80211_CHAN_RADAR) != 0)
+#define IEEE80211_IS_CHAN_PASSIVE(_c) \
+ (((_c)->ic_flags & IEEE80211_CHAN_PASSIVE) != 0)
+#define IEEE80211_ARE_CHANS_SAME_MODE(_a, _b) \
+ (((_a)->ic_flags & IEEE80211_CHAN_ALLTURBO) == ((_b)->ic_flags & IEEE80211_CHAN_ALLTURBO))
+
+/* ni_chan encoding for FH phy */
+#define IEEE80211_FH_CHANMOD 80
+#define IEEE80211_FH_CHAN(set,pat) (((set) - 1) * IEEE80211_FH_CHANMOD + (pat))
+#define IEEE80211_FH_CHANSET(chan) ((chan) / IEEE80211_FH_CHANMOD + 1)
+#define IEEE80211_FH_CHANPAT(chan) ((chan) % IEEE80211_FH_CHANMOD)
+
+/*
+ * Spectrum Management (IEEE 802.11h-2003)
+ */
+
+/* algorithm for (re)association based on supported channels
+ * (the one mentioned in 11.6.1 as out of scope of .11h) */
+enum ieee80211_sc_algorithm {
+ IEEE80211_SC_NONE,
+ /*
+ * Do not disallow anyone from associating. When needed, channel will
+ * be switched to the most suitable channel, no matter client stations
+ * support it or not.
+ */
+
+ IEEE80211_SC_LOOSE,
+ /*
+ * Do not disallow anyone from associating. When needed, channel will
+ * be switched to a suitable channel, which will be chosen taking
+ * ni->ni_suppchans and ic->ic_sc_sldg under consideration.
+ */
+
+ IEEE80211_SC_TIGHT,
+ /*
+ * Allow to associate if there are at least ic->ic_mincom channels
+ * common to the associating station and all of the already associated
+ * stations. If the number of new common channels is less than
+ * required, consider disassociating some other STAs. Such a
+ * disassociation will be performed if (and only if) the association we
+ * are currently considering would be then possible and the count of
+ * the resultant set of common channels (ic_chan_nodes[i] ==
+ * ic_cn_total) would increase by some amount. Whether the number of
+ * the new channels that could be gained is enough to sacrifice a
+ * number of STAs is determined by the ic->ic_slcg parameter.
+ */
+
+ IEEE80211_SC_STRICT
+ /*
+ * Basically the same behavior as IEEE80211_SC_TIGHT, except that if a
+ * station does not specify Supported Channels, then it is denied to
+ * associate.
+ */
+};
+
+/*
+ * 802.11 rate set.
+ */
+#define IEEE80211_RATE_SIZE 8 /* 802.11 standard */
+#define IEEE80211_RATE_MAXSIZE 15 /* max rates we'll handle */
+#define IEEE80211_SANITISE_RATESIZE(_rsz) \
+ ((_rsz > IEEE80211_RATE_MAXSIZE) ? IEEE80211_RATE_MAXSIZE : _rsz)
+
+struct ieee80211_rateset {
+ u_int8_t rs_nrates;
+ u_int8_t rs_rates[IEEE80211_RATE_MAXSIZE];
+};
+
+struct ieee80211_roam {
+ int8_t rssi11a; /* rssi thresh for 11a bss */
+ int8_t rssi11b; /* for 11g sta in 11b bss */
+ int8_t rssi11bOnly; /* for 11b sta */
+ u_int8_t pad1;
+ u_int8_t rate11a; /* rate thresh for 11a bss */
+ u_int8_t rate11b; /* for 11g sta in 11b bss */
+ u_int8_t rate11bOnly; /* for 11b sta */
+ u_int8_t pad2;
+};
+#endif /* _NET80211__IEEE80211_H_ */
diff --git a/package/network/services/hostapd/madwifi/net80211/.svn/text-base/ieee80211.h.svn-base b/package/network/services/hostapd/madwifi/net80211/.svn/text-base/ieee80211.h.svn-base
new file mode 100644
index 0000000..a39d4b9
--- /dev/null
+++ b/package/network/services/hostapd/madwifi/net80211/.svn/text-base/ieee80211.h.svn-base
@@ -0,0 +1,997 @@
+/*-
+ * Copyright (c) 2001 Atsushi Onoe
+ * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $Id: ieee80211.h 3268 2008-01-26 20:48:11Z mtaylor $
+ */
+#ifndef _NET80211_IEEE80211_H_
+#define _NET80211_IEEE80211_H_
+
+/*
+ * 802.11 protocol definitions.
+ */
+
+#define IEEE80211_ADDR_LEN 6 /* size of 802.11 address */
+/* is 802.11 address multicast/broadcast? */
+#define IEEE80211_IS_MULTICAST(_a) (*(_a) & 0x01)
+
+/* IEEE 802.11 PLCP header */
+struct ieee80211_plcp_hdr {
+ u_int16_t i_sfd;
+ u_int8_t i_signal;
+ u_int8_t i_service;
+ u_int16_t i_length;
+ u_int16_t i_crc;
+} __packed;
+
+#define IEEE80211_PLCP_SFD 0xF3A0
+#define IEEE80211_PLCP_SERVICE 0x00
+
+/*
+ * generic definitions for IEEE 802.11 frames
+ */
+struct ieee80211_frame {
+ u_int8_t i_fc[2];
+ __le16 i_dur;
+ u_int8_t i_addr1[IEEE80211_ADDR_LEN];
+ u_int8_t i_addr2[IEEE80211_ADDR_LEN];
+ u_int8_t i_addr3[IEEE80211_ADDR_LEN];
+ u_int8_t i_seq[2];
+ /* possibly followed by addr4[IEEE80211_ADDR_LEN]; */
+ /* see below */
+} __packed;
+
+struct ieee80211_qosframe {
+ u_int8_t i_fc[2];
+ __le16 i_dur;
+ u_int8_t i_addr1[IEEE80211_ADDR_LEN];
+ u_int8_t i_addr2[IEEE80211_ADDR_LEN];
+ u_int8_t i_addr3[IEEE80211_ADDR_LEN];
+ u_int8_t i_seq[2];
+ u_int8_t i_qos[2];
+ /* possibly followed by addr4[IEEE80211_ADDR_LEN]; */
+ /* see below */
+} __packed;
+
+struct ieee80211_qoscntl {
+ u_int8_t i_qos[2];
+};
+
+struct ieee80211_frame_addr4 {
+ u_int8_t i_fc[2];
+ __le16 i_dur;
+ u_int8_t i_addr1[IEEE80211_ADDR_LEN];
+ u_int8_t i_addr2[IEEE80211_ADDR_LEN];
+ u_int8_t i_addr3[IEEE80211_ADDR_LEN];
+ u_int8_t i_seq[2];
+ u_int8_t i_addr4[IEEE80211_ADDR_LEN];
+} __packed;
+
+
+struct ieee80211_qosframe_addr4 {
+ u_int8_t i_fc[2];
+ __le16 i_dur;
+ u_int8_t i_addr1[IEEE80211_ADDR_LEN];
+ u_int8_t i_addr2[IEEE80211_ADDR_LEN];
+ u_int8_t i_addr3[IEEE80211_ADDR_LEN];
+ u_int8_t i_seq[2];
+ u_int8_t i_addr4[IEEE80211_ADDR_LEN];
+ u_int8_t i_qos[2];
+} __packed;
+
+struct ieee80211_ctlframe_addr2 {
+ u_int8_t i_fc[2];
+ __le16 i_aidordur; /* AID or duration */
+ u_int8_t i_addr1[IEEE80211_ADDR_LEN];
+ u_int8_t i_addr2[IEEE80211_ADDR_LEN];
+} __packed;
+
+#define IEEE80211_FC0_VERSION_MASK 0x03
+#define IEEE80211_FC0_VERSION_SHIFT 0
+#define IEEE80211_FC0_VERSION_0 0x00
+#define IEEE80211_FC0_TYPE_MASK 0x0c
+#define IEEE80211_FC0_TYPE_SHIFT 2
+#define IEEE80211_FC0_TYPE_MGT 0x00
+#define IEEE80211_FC0_TYPE_CTL 0x04
+#define IEEE80211_FC0_TYPE_DATA 0x08
+
+#define IEEE80211_FC0_SUBTYPE_MASK 0xf0
+#define IEEE80211_FC0_SUBTYPE_SHIFT 4
+/* for TYPE_MGT */
+#define IEEE80211_FC0_SUBTYPE_ASSOC_REQ 0x00
+#define IEEE80211_FC0_SUBTYPE_ASSOC_RESP 0x10
+#define IEEE80211_FC0_SUBTYPE_REASSOC_REQ 0x20
+#define IEEE80211_FC0_SUBTYPE_REASSOC_RESP 0x30
+#define IEEE80211_FC0_SUBTYPE_PROBE_REQ 0x40
+#define IEEE80211_FC0_SUBTYPE_PROBE_RESP 0x50
+#define IEEE80211_FC0_SUBTYPE_BEACON 0x80
+#define IEEE80211_FC0_SUBTYPE_ATIM 0x90
+#define IEEE80211_FC0_SUBTYPE_DISASSOC 0xa0
+#define IEEE80211_FC0_SUBTYPE_AUTH 0xb0
+#define IEEE80211_FC0_SUBTYPE_DEAUTH 0xc0
+#define IEEE80211_FC0_SUBTYPE_ACTION 0xd0
+/* for TYPE_CTL */
+#define IEEE80211_FC0_SUBTYPE_PS_POLL 0xa0
+#define IEEE80211_FC0_SUBTYPE_RTS 0xb0
+#define IEEE80211_FC0_SUBTYPE_CTS 0xc0
+#define IEEE80211_FC0_SUBTYPE_ACK 0xd0
+#define IEEE80211_FC0_SUBTYPE_CF_END 0xe0
+#define IEEE80211_FC0_SUBTYPE_CF_END_ACK 0xf0
+/* for TYPE_DATA (bit combination) */
+#define IEEE80211_FC0_SUBTYPE_DATA 0x00
+#define IEEE80211_FC0_SUBTYPE_CF_ACK 0x10
+#define IEEE80211_FC0_SUBTYPE_CF_POLL 0x20
+#define IEEE80211_FC0_SUBTYPE_CF_ACPL 0x30
+#define IEEE80211_FC0_SUBTYPE_NODATA 0x40
+#define IEEE80211_FC0_SUBTYPE_CFACK 0x50
+#define IEEE80211_FC0_SUBTYPE_CFPOLL 0x60
+#define IEEE80211_FC0_SUBTYPE_CF_ACK_CF_ACK 0x70
+#define IEEE80211_FC0_SUBTYPE_QOS 0x80
+#define IEEE80211_FC0_SUBTYPE_QOS_NULL 0xc0
+
+#define IEEE80211_FC1_DIR_MASK 0x03
+#define IEEE80211_FC1_DIR_NODS 0x00 /* STA->STA */
+#define IEEE80211_FC1_DIR_TODS 0x01 /* STA->AP */
+#define IEEE80211_FC1_DIR_FROMDS 0x02 /* AP ->STA */
+#define IEEE80211_FC1_DIR_DSTODS 0x03 /* AP ->AP */
+
+#define IEEE80211_FC1_MORE_FRAG 0x04
+#define IEEE80211_FC1_RETRY 0x08
+#define IEEE80211_FC1_PWR_MGT 0x10
+#define IEEE80211_FC1_MORE_DATA 0x20
+#define IEEE80211_FC1_PROT 0x40
+#define IEEE80211_FC1_ORDER 0x80
+
+#define IEEE80211_SEQ_FRAG_MASK 0x000f
+#define IEEE80211_SEQ_FRAG_SHIFT 0
+#define IEEE80211_SEQ_SEQ_MASK 0xfff0
+#define IEEE80211_SEQ_SEQ_SHIFT 4
+
+#define IEEE80211_NWID_LEN 32
+
+#define IEEE80211_QOS_TXOP 0x00ff
+/* bit 8 is reserved */
+#define IEEE80211_QOS_ACKPOLICY 0x60
+#define IEEE80211_QOS_ACKPOLICY_S 5
+#define IEEE80211_QOS_EOSP 0x10
+#define IEEE80211_QOS_EOSP_S 4
+#define IEEE80211_QOS_TID 0x0f
+
+#define IEEE80211_FRM_HAS_BODY(_wh) \
+ (((_wh)->i_fc[0] & IEEE80211_FC0_TYPE_MASK) != \
+ IEEE80211_FC0_TYPE_CTL)
+
+/*
+ * Country/Region Codes from MS WINNLS.H
+ * Numbering from ISO 3166
+ * XXX belongs elsewhere
+ */
+enum CountryCode {
+ CTRY_ALBANIA = 8, /* Albania */
+ CTRY_ALGERIA = 12, /* Algeria */
+ CTRY_ARGENTINA = 32, /* Argentina */
+ CTRY_ARMENIA = 51, /* Armenia */
+ CTRY_AUSTRALIA = 36, /* Australia */
+ CTRY_AUSTRIA = 40, /* Austria */
+ CTRY_AZERBAIJAN = 31, /* Azerbaijan */
+ CTRY_BAHRAIN = 48, /* Bahrain */
+ CTRY_BELARUS = 112, /* Belarus */
+ CTRY_BELGIUM = 56, /* Belgium */
+ CTRY_BELIZE = 84, /* Belize */
+ CTRY_BOLIVIA = 68, /* Bolivia */
+ CTRY_BRAZIL = 76, /* Brazil */
+ CTRY_BRUNEI_DARUSSALAM = 96, /* Brunei Darussalam */
+ CTRY_BULGARIA = 100, /* Bulgaria */
+ CTRY_CANADA = 124, /* Canada */
+ CTRY_CHILE = 152, /* Chile */
+ CTRY_CHINA = 156, /* People's Republic of China */
+ CTRY_COLOMBIA = 170, /* Colombia */
+ CTRY_COSTA_RICA = 188, /* Costa Rica */
+ CTRY_CROATIA = 191, /* Croatia */
+ CTRY_CYPRUS = 196,
+ CTRY_CZECH = 203, /* Czech Republic */
+ CTRY_DENMARK = 208, /* Denmark */
+ CTRY_DOMINICAN_REPUBLIC = 214, /* Dominican Republic */
+ CTRY_ECUADOR = 218, /* Ecuador */
+ CTRY_EGYPT = 818, /* Egypt */
+ CTRY_EL_SALVADOR = 222, /* El Salvador */
+ CTRY_ESTONIA = 233, /* Estonia */
+ CTRY_FAEROE_ISLANDS = 234, /* Faeroe Islands */
+ CTRY_FINLAND = 246, /* Finland */
+ CTRY_FRANCE = 250, /* France */
+ CTRY_FRANCE2 = 255, /* France2 */
+ CTRY_GEORGIA = 268, /* Georgia */
+ CTRY_GERMANY = 276, /* Germany */
+ CTRY_GREECE = 300, /* Greece */
+ CTRY_GUATEMALA = 320, /* Guatemala */
+ CTRY_HONDURAS = 340, /* Honduras */
+ CTRY_HONG_KONG = 344, /* Hong Kong S.A.R., P.R.C. */
+ CTRY_HUNGARY = 348, /* Hungary */
+ CTRY_ICELAND = 352, /* Iceland */
+ CTRY_INDIA = 356, /* India */
+ CTRY_INDONESIA = 360, /* Indonesia */
+ CTRY_IRAN = 364, /* Iran */
+ CTRY_IRAQ = 368, /* Iraq */
+ CTRY_IRELAND = 372, /* Ireland */
+ CTRY_ISRAEL = 376, /* Israel */
+ CTRY_ITALY = 380, /* Italy */
+ CTRY_JAMAICA = 388, /* Jamaica */
+ CTRY_JAPAN = 392, /* Japan */
+ CTRY_JAPAN1 = 393, /* Japan (JP1) */
+ CTRY_JAPAN2 = 394, /* Japan (JP0) */
+ CTRY_JAPAN3 = 395, /* Japan (JP1-1) */
+ CTRY_JAPAN4 = 396, /* Japan (JE1) */
+ CTRY_JAPAN5 = 397, /* Japan (JE2) */
+ CTRY_JAPAN6 = 399, /* Japan (JP6) */
+ CTRY_JAPAN7 = 900, /* Japan */
+ CTRY_JAPAN8 = 901, /* Japan */
+ CTRY_JAPAN9 = 902, /* Japan */
+ CTRY_JAPAN10 = 903, /* Japan */
+ CTRY_JAPAN11 = 904, /* Japan */
+ CTRY_JAPAN12 = 905, /* Japan */
+ CTRY_JAPAN13 = 906, /* Japan */
+ CTRY_JAPAN14 = 907, /* Japan */
+ CTRY_JAPAN15 = 908, /* Japan */
+ CTRY_JAPAN16 = 909, /* Japan */
+ CTRY_JAPAN17 = 910, /* Japan */
+ CTRY_JAPAN18 = 911, /* Japan */
+ CTRY_JAPAN19 = 912, /* Japan */
+ CTRY_JAPAN20 = 913, /* Japan */
+ CTRY_JAPAN21 = 914, /* Japan */
+ CTRY_JAPAN22 = 915, /* Japan */
+ CTRY_JAPAN23 = 916, /* Japan */
+ CTRY_JAPAN24 = 917, /* Japan */
+ CTRY_JAPAN25 = 918, /* Japan */
+ CTRY_JAPAN26 = 919, /* Japan */
+ CTRY_JAPAN27 = 920, /* Japan */
+ CTRY_JAPAN28 = 921, /* Japan */
+ CTRY_JAPAN29 = 922, /* Japan */
+ CTRY_JAPAN30 = 923, /* Japan */
+ CTRY_JAPAN31 = 924, /* Japan */
+ CTRY_JAPAN32 = 925, /* Japan */
+ CTRY_JAPAN33 = 926, /* Japan */
+ CTRY_JAPAN34 = 927, /* Japan */
+ CTRY_JAPAN35 = 928, /* Japan */
+ CTRY_JAPAN36 = 929, /* Japan */
+ CTRY_JAPAN37 = 930, /* Japan */
+ CTRY_JAPAN38 = 931, /* Japan */
+ CTRY_JAPAN39 = 932, /* Japan */
+ CTRY_JAPAN40 = 933, /* Japan */
+ CTRY_JAPAN41 = 934, /* Japan */
+ CTRY_JAPAN42 = 935, /* Japan */
+ CTRY_JAPAN43 = 936, /* Japan */
+ CTRY_JAPAN44 = 937, /* Japan */
+ CTRY_JAPAN45 = 938, /* Japan */
+ CTRY_JAPAN46 = 939, /* Japan */
+ CTRY_JAPAN47 = 940, /* Japan */
+ CTRY_JAPAN48 = 941, /* Japan */
+ CTRY_JORDAN = 400, /* Jordan */
+ CTRY_KAZAKHSTAN = 398, /* Kazakhstan */
+ CTRY_KENYA = 404, /* Kenya */
+ CTRY_KOREA_NORTH = 408, /* North Korea */
+ CTRY_KOREA_ROC = 410, /* South Korea */
+ CTRY_KOREA_ROC2 = 411, /* South Korea */
+ CTRY_KUWAIT = 414, /* Kuwait */
+ CTRY_LATVIA = 428, /* Latvia */
+ CTRY_LEBANON = 422, /* Lebanon */
+ CTRY_LIBYA = 434, /* Libya */
+ CTRY_LIECHTENSTEIN = 438, /* Liechtenstein */
+ CTRY_LITHUANIA = 440, /* Lithuania */
+ CTRY_LUXEMBOURG = 442, /* Luxembourg */
+ CTRY_MACAU = 446, /* Macau */
+ CTRY_MACEDONIA = 807, /* the Former Yugoslav Republic of Macedonia */
+ CTRY_MALAYSIA = 458, /* Malaysia */
+ CTRY_MEXICO = 484, /* Mexico */
+ CTRY_MONACO = 492, /* Principality of Monaco */
+ CTRY_MOROCCO = 504, /* Morocco */
+ CTRY_NETHERLANDS = 528, /* Netherlands */
+ CTRY_NEW_ZEALAND = 554, /* New Zealand */
+ CTRY_NICARAGUA = 558, /* Nicaragua */
+ CTRY_NORWAY = 578, /* Norway */
+ CTRY_OMAN = 512, /* Oman */
+ CTRY_PAKISTAN = 586, /* Islamic Republic of Pakistan */
+ CTRY_PANAMA = 591, /* Panama */
+ CTRY_PARAGUAY = 600, /* Paraguay */
+ CTRY_PERU = 604, /* Peru */
+ CTRY_PHILIPPINES = 608, /* Republic of the Philippines */
+ CTRY_POLAND = 616, /* Poland */
+ CTRY_PORTUGAL = 620, /* Portugal */
+ CTRY_PUERTO_RICO = 630, /* Puerto Rico */
+ CTRY_QATAR = 634, /* Qatar */
+ CTRY_ROMANIA = 642, /* Romania */
+ CTRY_RUSSIA = 643, /* Russia */
+ CTRY_SAUDI_ARABIA = 682, /* Saudi Arabia */
+ CTRY_SINGAPORE = 702, /* Singapore */
+ CTRY_SLOVAKIA = 703, /* Slovak Republic */
+ CTRY_SLOVENIA = 705, /* Slovenia */
+ CTRY_SOUTH_AFRICA = 710, /* South Africa */
+ CTRY_SPAIN = 724, /* Spain */
+ CTRY_SWEDEN = 752, /* Sweden */
+ CTRY_SWITZERLAND = 756, /* Switzerland */
+ CTRY_SYRIA = 760, /* Syria */
+ CTRY_TAIWAN = 158, /* Taiwan */
+ CTRY_THAILAND = 764, /* Thailand */
+ CTRY_TRINIDAD_Y_TOBAGO = 780, /* Trinidad y Tobago */
+ CTRY_TUNISIA = 788, /* Tunisia */
+ CTRY_TURKEY = 792, /* Turkey */
+ CTRY_UAE = 784, /* U.A.E. */
+ CTRY_UKRAINE = 804, /* Ukraine */
+ CTRY_UNITED_KINGDOM = 826, /* United Kingdom */
+ CTRY_UNITED_STATES = 840, /* United States */
+ CTRY_UNITED_STATES_FCC49 = 842, /* United States (Public Safety)*/
+ CTRY_URUGUAY = 858, /* Uruguay */
+ CTRY_UZBEKISTAN = 860, /* Uzbekistan */
+ CTRY_VENEZUELA = 862, /* Venezuela */
+ CTRY_VIET_NAM = 704, /* Viet Nam */
+ CTRY_YEMEN = 887, /* Yemen */
+ CTRY_ZIMBABWE = 716 /* Zimbabwe */
+};
+
+/*
+ * Generic information element
+ */
+struct ieee80211_ie {
+ u_int8_t id;
+ u_int8_t len;
+ u_int8_t info[0];
+} __packed;
+
+/*
+ * Country information element.
+ */
+#define IEEE80211_COUNTRY_MAX_TRIPLETS (83)
+struct ieee80211_ie_country {
+ u_int8_t country_id;
+ u_int8_t country_len;
+ u_int8_t country_str[3];
+ u_int8_t country_triplet[IEEE80211_COUNTRY_MAX_TRIPLETS * 3];
+} __packed;
+
+/*
+ * Power Constraint information element.
+ */
+struct ieee80211_ie_pwrcnstr {
+ u_int8_t pc_id; /* IEEE80211_ELEMID_PWRCNSTR */
+ u_int8_t pc_len; /* == 2 */
+ u_int8_t pc_lpc; /* Local Power Constraint [dB] */
+} __packed;
+
+/*
+ * Power Capability information element.
+ */
+struct ieee80211_ie_pwrcap {
+ u_int8_t pc_id; /* IEEE80211_ELEMID_PWRCAP */
+ u_int8_t pc_len; /* == 2 */
+ int8_t pc_mintxpow; /* Minimum Transmit Power Capability [dBm] */
+ int8_t pc_maxtxpow; /* Maximum Transmit Power Capability [dBm] */
+} __packed;
+
+/*
+ * Supported Channels information element.
+ */
+#define IEEE80211_SUPPCHAN_MAX_PAIRS (127)
+struct ieee80211_ie_sc {
+ u_int8_t sc_id; /* IEEE80211_ELEMID_SUPPCHAN */
+ u_int8_t sc_len; /* == 2 * number of sc_subband elements */
+ struct {
+ u_int8_t sc_first; /* First Channel Number */
+ u_int8_t sc_number; /* Number of Channels */
+ } __packed sc_subband[IEEE80211_SUPPCHAN_MAX_PAIRS];
+} __packed;
+
+/*
+ * Channel Switch Announcement information element.
+ */
+struct ieee80211_ie_csa {
+ u_int8_t csa_id; /* IEEE80211_ELEMID_CHANSWITCHANN */
+ u_int8_t csa_len; /* == 3 */
+ u_int8_t csa_mode; /* Channel Switch Mode: 1 == stop transmission until CS */
+ u_int8_t csa_chan; /* New Channel Number */
+ u_int8_t csa_count; /* TBTTs until Channel Switch happens */
+} __packed;
+
+/* minimal Channel Switch Count in the initial announcement */
+#define IEEE80211_CSA_PROTECTION_PERIOD 3
+
+/* maximum allowed deviance of measurement of intervals between CSA in Beacons */
+#define IEEE80211_CSA_SANITY_THRESHOLD 100
+
+
+/* does frame have QoS sequence control data */
+#define IEEE80211_QOS_HAS_SEQ(wh) \
+ (((wh)->i_fc[0] & \
+ (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_QOS)) == \
+ (IEEE80211_FC0_TYPE_DATA | IEEE80211_FC0_SUBTYPE_QOS))
+
+#define WME_QOSINFO_COUNT 0x0f /* Mask for Param Set Count field */
+/*
+ * WME/802.11e information element.
+ */
+struct ieee80211_ie_wme {
+ u_int8_t wme_id; /* IEEE80211_ELEMID_VENDOR */
+ u_int8_t wme_len; /* length in bytes */
+ u_int8_t wme_oui[3]; /* 0x00, 0x50, 0xf2 */
+ u_int8_t wme_type; /* OUI type */
+ u_int8_t wme_subtype; /* OUI subtype */
+ u_int8_t wme_version; /* spec revision */
+ u_int8_t wme_info; /* QoS info */
+} __packed;
+
+/*
+ * WME/802.11e Tspec Element
+ */
+struct ieee80211_wme_tspec {
+ u_int8_t ts_id;
+ u_int8_t ts_len;
+ u_int8_t ts_oui[3];
+ u_int8_t ts_oui_type;
+ u_int8_t ts_oui_subtype;
+ u_int8_t ts_version;
+ u_int8_t ts_tsinfo[3];
+ u_int8_t ts_nom_msdu[2];
+ u_int8_t ts_max_msdu[2];
+ u_int8_t ts_min_svc[4];
+ u_int8_t ts_max_svc[4];
+ u_int8_t ts_inactv_intv[4];
+ u_int8_t ts_susp_intv[4];
+ u_int8_t ts_start_svc[4];
+ u_int8_t ts_min_rate[4];
+ u_int8_t ts_mean_rate[4];
+ u_int8_t ts_max_burst[4];
+ u_int8_t ts_min_phy[4];
+ u_int8_t ts_peak_rate[4];
+ u_int8_t ts_delay[4];
+ u_int8_t ts_surplus[2];
+ u_int8_t ts_medium_time[2];
+} __packed;
+
+/*
+ * WME AC parameter field
+ */
+
+struct ieee80211_wme_acparams {
+ u_int8_t acp_aci_aifsn;
+ u_int8_t acp_logcwminmax;
+ u_int16_t acp_txop;
+} __packed;
+
+#define IEEE80211_WME_PARAM_LEN 24
+#define WME_NUM_AC 4 /* 4 AC categories */
+
+#define WME_PARAM_ACI 0x60 /* Mask for ACI field */
+#define WME_PARAM_ACI_S 5 /* Shift for ACI field */
+#define WME_PARAM_ACM 0x10 /* Mask for ACM bit */
+#define WME_PARAM_ACM_S 4 /* Shift for ACM bit */
+#define WME_PARAM_AIFSN 0x0f /* Mask for aifsn field */
+#define WME_PARAM_AIFSN_S 0 /* Shift for aifsn field */
+#define WME_PARAM_LOGCWMIN 0x0f /* Mask for CwMin field (in log) */
+#define WME_PARAM_LOGCWMIN_S 0 /* Shift for CwMin field */
+#define WME_PARAM_LOGCWMAX 0xf0 /* Mask for CwMax field (in log) */
+#define WME_PARAM_LOGCWMAX_S 4 /* Shift for CwMax field */
+
+#define WME_AC_TO_TID(_ac) ( \
+ ((_ac) == WME_AC_VO) ? 6 : \
+ ((_ac) == WME_AC_VI) ? 5 : \
+ ((_ac) == WME_AC_BK) ? 1 : \
+ 0)
+
+#define TID_TO_WME_AC(_tid) ( \
+ ((_tid) < 1) ? WME_AC_BE : \
+ ((_tid) < 3) ? WME_AC_BK : \
+ ((_tid) < 6) ? WME_AC_VI : \
+ WME_AC_VO)
+
+/*
+ * WME Parameter Element
+ */
+
+struct ieee80211_wme_param {
+ u_int8_t param_id;
+ u_int8_t param_len;
+ u_int8_t param_oui[3];
+ u_int8_t param_oui_type;
+ u_int8_t param_oui_sybtype;
+ u_int8_t param_version;
+ u_int8_t param_qosInfo;
+ u_int8_t param_reserved;
+ struct ieee80211_wme_acparams params_acParams[WME_NUM_AC];
+} __packed;
+
+/*
+ * WME U-APSD qos info field defines
+ */
+#define WME_CAPINFO_UAPSD_EN 0x00000080
+#define WME_CAPINFO_UAPSD_VO 0x00000001
+#define WME_CAPINFO_UAPSD_VI 0x00000002
+#define WME_CAPINFO_UAPSD_BK 0x00000004
+#define WME_CAPINFO_UAPSD_BE 0x00000008
+#define WME_CAPINFO_UAPSD_ACFLAGS_SHIFT 0
+#define WME_CAPINFO_UAPSD_ACFLAGS_MASK 0xF
+#define WME_CAPINFO_UAPSD_MAXSP_SHIFT 5
+#define WME_CAPINFO_UAPSD_MAXSP_MASK 0x3
+#define WME_CAPINFO_IE_OFFSET 8
+#define WME_UAPSD_MAXSP(_qosinfo) \
+ (((_qosinfo) >> WME_CAPINFO_UAPSD_MAXSP_SHIFT) & \
+ WME_CAPINFO_UAPSD_MAXSP_MASK)
+#define WME_UAPSD_AC_ENABLED(_ac, _qosinfo) \
+ ((1 << (3 - (_ac))) & ( \
+ ((_qosinfo) >> WME_CAPINFO_UAPSD_ACFLAGS_SHIFT) & \
+ WME_CAPINFO_UAPSD_ACFLAGS_MASK))
+
+/*
+ * Atheros Advanced Capability information element.
+ */
+struct ieee80211_ie_athAdvCap {
+ u_int8_t athAdvCap_id; /* IEEE80211_ELEMID_VENDOR */
+ u_int8_t athAdvCap_len; /* length in bytes */
+ u_int8_t athAdvCap_oui[3]; /* 0x00, 0x03, 0x7f */
+ u_int8_t athAdvCap_type; /* OUI type */
+ u_int8_t athAdvCap_subtype; /* OUI subtype */
+ u_int8_t athAdvCap_version; /* spec revision */
+ u_int8_t athAdvCap_capability; /* Capability info */
+ u_int16_t athAdvCap_defKeyIndex;
+} __packed;
+
+/*
+ * Atheros XR information element.
+ */
+struct ieee80211_xr_param {
+ u_int8_t param_id;
+ u_int8_t param_len;
+ u_int8_t param_oui[3];
+ u_int8_t param_oui_type;
+ u_int8_t param_oui_sybtype;
+ u_int8_t param_version;
+ u_int8_t param_Info;
+ u_int8_t param_base_bssid[IEEE80211_ADDR_LEN];
+ u_int8_t param_xr_bssid[IEEE80211_ADDR_LEN];
+ u_int16_t param_xr_beacon_interval;
+ u_int8_t param_base_ath_capability;
+ u_int8_t param_xr_ath_capability;
+} __packed;
+
+/* Atheros capabilities */
+#define IEEE80211_ATHC_TURBOP 0x0001 /* Turbo Prime */
+#define IEEE80211_ATHC_COMP 0x0002 /* Compression */
+#define IEEE80211_ATHC_FF 0x0004 /* Fast Frames */
+#define IEEE80211_ATHC_XR 0x0008 /* Xtended Range support */
+#define IEEE80211_ATHC_AR 0x0010 /* Advanced Radar support */
+#define IEEE80211_ATHC_BURST 0x0020 /* Bursting - not negotiated */
+#define IEEE80211_ATHC_WME 0x0040 /* CWMin tuning */
+#define IEEE80211_ATHC_BOOST 0x0080 /* Boost */
+
+/*
+ * Management Notification Frame
+ */
+struct ieee80211_mnf {
+ u_int8_t mnf_category;
+ u_int8_t mnf_action;
+ u_int8_t mnf_dialog;
+ u_int8_t mnf_status;
+} __packed;
+#define MNF_SETUP_REQ 0
+#define MNF_SETUP_RESP 1
+#define MNF_TEARDOWN 2
+
+/*
+ * Control frames.
+ */
+struct ieee80211_frame_min {
+ u_int8_t i_fc[2];
+ __le16 i_dur;
+ u_int8_t i_addr1[IEEE80211_ADDR_LEN];
+ u_int8_t i_addr2[IEEE80211_ADDR_LEN];
+ /* FCS */
+} __packed;
+
+struct ieee80211_frame_rts {
+ u_int8_t i_fc[2];
+ __le16 i_dur;
+ u_int8_t i_ra[IEEE80211_ADDR_LEN];
+ u_int8_t i_ta[IEEE80211_ADDR_LEN];
+ /* FCS */
+} __packed;
+
+struct ieee80211_frame_cts {
+ u_int8_t i_fc[2];
+ __le16 i_dur;
+ u_int8_t i_ra[IEEE80211_ADDR_LEN];
+ /* FCS */
+} __packed;
+
+struct ieee80211_frame_ack {
+ u_int8_t i_fc[2];
+ __le16 i_dur;
+ u_int8_t i_ra[IEEE80211_ADDR_LEN];
+ /* FCS */
+} __packed;
+
+struct ieee80211_frame_pspoll {
+ u_int8_t i_fc[2];
+ u_int8_t i_aid[2];
+ u_int8_t i_bssid[IEEE80211_ADDR_LEN];
+ u_int8_t i_ta[IEEE80211_ADDR_LEN];
+ /* FCS */
+} __packed;
+
+struct ieee80211_frame_cfend { /* NB: also CF-End+CF-Ack */
+ u_int8_t i_fc[2];
+ __le16 i_dur; /* should be zero */
+ u_int8_t i_ra[IEEE80211_ADDR_LEN];
+ u_int8_t i_bssid[IEEE80211_ADDR_LEN];
+ /* FCS */
+} __packed;
+
+/*
+ * BEACON management packets
+ *
+ * octet timestamp[8]
+ * octet beacon interval[2]
+ * octet capability information[2]
+ * information element
+ * octet elemid
+ * octet length
+ * octet information[length]
+ */
+
+typedef u_int8_t *ieee80211_mgt_beacon_t;
+
+#define IEEE80211_BEACON_INTERVAL(beacon) \
+ ((beacon)[8] | ((beacon)[9] << 8))
+#define IEEE80211_BEACON_CAPABILITY(beacon) \
+ ((beacon)[10] | ((beacon)[11] << 8))
+
+#define IEEE80211_CAPINFO_ESS 0x0001
+#define IEEE80211_CAPINFO_IBSS 0x0002
+#define IEEE80211_CAPINFO_CF_POLLABLE 0x0004
+#define IEEE80211_CAPINFO_CF_POLLREQ 0x0008
+#define IEEE80211_CAPINFO_PRIVACY 0x0010
+#define IEEE80211_CAPINFO_SHORT_PREAMBLE 0x0020
+#define IEEE80211_CAPINFO_PBCC 0x0040
+#define IEEE80211_CAPINFO_CHNL_AGILITY 0x0080
+/* bits 8-9 are reserved (8 now for spectrum management) */
+#define IEEE80211_CAPINFO_SPECTRUM_MGMT 0x0100
+#define IEEE80211_CAPINFO_SHORT_SLOTTIME 0x0400
+#define IEEE80211_CAPINFO_RSN 0x0800
+/* bit 12 is reserved */
+#define IEEE80211_CAPINFO_DSSSOFDM 0x2000
+/* bits 14-15 are reserved */
+
+/*
+ * 802.11i/WPA information element (maximally sized).
+ */
+struct ieee80211_ie_wpa {
+ u_int8_t wpa_id; /* IEEE80211_ELEMID_VENDOR */
+ u_int8_t wpa_len; /* length in bytes */
+ u_int8_t wpa_oui[3]; /* 0x00, 0x50, 0xf2 */
+ u_int8_t wpa_type; /* OUI type */
+ u_int16_t wpa_version; /* spec revision */
+ u_int32_t wpa_mcipher[1]; /* multicast/group key cipher */
+ u_int16_t wpa_uciphercnt; /* # pairwise key ciphers */
+ u_int32_t wpa_uciphers[8]; /* ciphers */
+ u_int16_t wpa_authselcnt; /* authentication selector cnt*/
+ u_int32_t wpa_authsels[8]; /* selectors */
+ u_int16_t wpa_caps; /* 802.11i capabilities */
+ u_int16_t wpa_pmkidcnt; /* 802.11i pmkid count */
+ u_int16_t wpa_pmkids[8]; /* 802.11i pmkids */
+} __packed;
+
+/*
+ * Management information element payloads.
+ */
+
+enum {
+ IEEE80211_ELEMID_SSID = 0,
+ IEEE80211_ELEMID_RATES = 1,
+ IEEE80211_ELEMID_FHPARMS = 2,
+ IEEE80211_ELEMID_DSPARMS = 3,
+ IEEE80211_ELEMID_CFPARMS = 4,
+ IEEE80211_ELEMID_TIM = 5,
+ IEEE80211_ELEMID_IBSSPARMS = 6,
+ IEEE80211_ELEMID_COUNTRY = 7,
+ IEEE80211_ELEMID_HOPPATRNPARMS = 8,
+ IEEE80211_ELEMID_HOPPATRNTABLE = 9,
+ IEEE80211_ELEMID_REQINFO = 10,
+ IEEE80211_ELEMID_QBSSLOAD = 11,
+ IEEE80211_ELEMID_EDCAPARAM = 12,
+ IEEE80211_ELEMID_TSPEC = 13,
+ IEEE80211_ELEMID_TRAFCLASS = 14,
+ IEEE80211_ELEMID_SCHEDULE = 15,
+ IEEE80211_ELEMID_CHALLENGE = 16,
+ /* 17-31 reserved for challenge text extension */
+ IEEE80211_ELEMID_PWRCNSTR = 32,
+ IEEE80211_ELEMID_PWRCAP = 33,
+ IEEE80211_ELEMID_TPCREQ = 34,
+ IEEE80211_ELEMID_TPCREP = 35,
+ IEEE80211_ELEMID_SUPPCHAN = 36,
+ IEEE80211_ELEMID_CHANSWITCHANN = 37,
+ IEEE80211_ELEMID_MEASREQ = 38,
+ IEEE80211_ELEMID_MEASREP = 39,
+ IEEE80211_ELEMID_QUIET = 40,
+ IEEE80211_ELEMID_IBSSDFS = 41,
+ IEEE80211_ELEMID_ERP = 42,
+ IEEE80211_ELEMID_TSDELAY = 43,
+ IEEE80211_ELEMID_TCLASSPROC = 44,
+ IEEE80211_ELEMID_QOS = 46,
+ IEEE80211_ELEMID_RSN = 48,
+ /* 49 reserved */
+ IEEE80211_ELEMID_XRATES = 50,
+ /* 128-129 proprietary elements used by Agere chipsets */
+ IEEE80211_ELEMID_AGERE1 = 128,
+ IEEE80211_ELEMID_AGERE2 = 129,
+ IEEE80211_ELEMID_TPC = 150,
+ IEEE80211_ELEMID_CCKM = 156,
+ IEEE80211_ELEMID_VENDOR = 221, /* vendor private */
+};
+
+#define IEEE80211_CHANSWITCHANN_BYTES 5
+#define BITCTL_BUFD_MCAST 1
+#define BITCTL_BUFD_UCAST_AID_MASK ((u_int8_t)~(BITCTL_BUFD_MCAST))
+#define BITCTL_BUFD_UCAST_AID_SHIFT 1
+
+struct ieee80211_tim_ie {
+ u_int8_t tim_ie; /* IEEE80211_ELEMID_TIM */
+ u_int8_t tim_len;
+ u_int8_t tim_count; /* DTIM count */
+ u_int8_t tim_period; /* DTIM period */
+ u_int8_t tim_bitctl; /* bitmap control */
+ u_int8_t tim_bitmap[1]; /* variable-length bitmap */
+} __packed;
+
+struct ieee80211_country_ie {
+ u_int8_t ie; /* IEEE80211_ELEMID_COUNTRY */
+ u_int8_t len;
+ u_int8_t cc[3]; /* ISO CC+(I)ndoor/(O)utdoor */
+ struct {
+ u_int8_t schan; /* starting channel */
+ u_int8_t nchan; /* number channels */
+ u_int8_t maxtxpwr; /* tx power cap */
+ } __packed band[4]; /* up to 4 sub bands */
+} __packed;
+
+#define IEEE80211_CHALLENGE_LEN 128
+
+#define IEEE80211_SUPPCHAN_LEN 26
+
+#define IEEE80211_RATE_BASIC 0x80
+#define IEEE80211_RATE_VAL 0x7f
+
+/* EPR information element flags */
+#define IEEE80211_ERP_NON_ERP_PRESENT 0x01
+#define IEEE80211_ERP_USE_PROTECTION 0x02
+#define IEEE80211_ERP_LONG_PREAMBLE 0x04
+
+/* Atheros private advanced capabilities info */
+#define ATHEROS_CAP_TURBO_PRIME 0x01
+#define ATHEROS_CAP_COMPRESSION 0x02
+#define ATHEROS_CAP_FAST_FRAME 0x04
+/* bits 3-6 reserved */
+#define ATHEROS_CAP_BOOST 0x80
+
+#define ATH_OUI 0x7f0300 /* Atheros OUI */
+#define ATH_OUI_TYPE 0x01
+#define ATH_OUI_SUBTYPE 0x01
+#define ATH_OUI_VERSION 0x00
+#define ATH_OUI_TYPE_XR 0x03
+#define ATH_OUI_SUBTYPE_XR 0x01
+#define ATH_OUI_VER_XR 0x00
+
+#define WPA_OUI 0xf25000
+#define WPA_OUI_TYPE 0x01
+#define WPA_VERSION 1 /* current supported version */
+
+#define WPA_CSE_NULL 0x00
+#define WPA_CSE_WEP40 0x01
+#define WPA_CSE_TKIP 0x02
+#define WPA_CSE_CCMP 0x04
+#define WPA_CSE_WEP104 0x05
+
+#define WPA_ASE_NONE 0x00
+#define WPA_ASE_8021X_UNSPEC 0x01
+#define WPA_ASE_8021X_PSK 0x02
+
+#define RSN_OUI 0xac0f00
+#define RSN_VERSION 1 /* current supported version */
+
+#define RSN_CSE_NULL 0x00
+#define RSN_CSE_WEP40 0x01
+#define RSN_CSE_TKIP 0x02
+#define RSN_CSE_WRAP 0x03
+#define RSN_CSE_CCMP 0x04
+#define RSN_CSE_WEP104 0x05
+
+#define RSN_ASE_NONE 0x00
+#define RSN_ASE_8021X_UNSPEC 0x01
+#define RSN_ASE_8021X_PSK 0x02
+
+#define RSN_CAP_PREAUTH 0x01
+
+#define WME_OUI 0xf25000
+#define WME_OUI_TYPE 0x02
+#define WME_INFO_OUI_SUBTYPE 0x00
+#define WME_PARAM_OUI_SUBTYPE 0x01
+#define WME_VERSION 1
+
+/* WME stream classes */
+#define WME_AC_BE 0 /* best effort */
+#define WME_AC_BK 1 /* background */
+#define WME_AC_VI 2 /* video */
+#define WME_AC_VO 3 /* voice */
+
+/*
+ * AUTH management packets
+ *
+ * octet algo[2]
+ * octet seq[2]
+ * octet status[2]
+ * octet chal.id
+ * octet chal.length
+ * octet chal.text[253]
+ */
+
+typedef u_int8_t *ieee80211_mgt_auth_t;
+
+#define IEEE80211_AUTH_ALGORITHM(auth) \
+ ((auth)[0] | ((auth)[1] << 8))
+#define IEEE80211_AUTH_TRANSACTION(auth) \
+ ((auth)[2] | ((auth)[3] << 8))
+#define IEEE80211_AUTH_STATUS(auth) \
+ ((auth)[4] | ((auth)[5] << 8))
+
+#define IEEE80211_AUTH_ALG_OPEN 0x0000
+#define IEEE80211_AUTH_ALG_SHARED 0x0001
+#define IEEE80211_AUTH_ALG_LEAP 0x0080
+
+enum {
+ IEEE80211_AUTH_OPEN_REQUEST = 1,
+ IEEE80211_AUTH_OPEN_RESPONSE = 2,
+};
+
+enum {
+ IEEE80211_AUTH_SHARED_REQUEST = 1,
+ IEEE80211_AUTH_SHARED_CHALLENGE = 2,
+ IEEE80211_AUTH_SHARED_RESPONSE = 3,
+ IEEE80211_AUTH_SHARED_PASS = 4,
+};
+
+/*
+ * Reason codes
+ *
+ * Unlisted codes are reserved
+ */
+
+enum {
+ IEEE80211_REASON_UNSPECIFIED = 1,
+ IEEE80211_REASON_AUTH_EXPIRE = 2,
+ IEEE80211_REASON_AUTH_LEAVE = 3,
+ IEEE80211_REASON_ASSOC_EXPIRE = 4,
+ IEEE80211_REASON_ASSOC_TOOMANY = 5,
+ IEEE80211_REASON_NOT_AUTHED = 6,
+ IEEE80211_REASON_NOT_ASSOCED = 7,
+ IEEE80211_REASON_ASSOC_LEAVE = 8,
+ IEEE80211_REASON_ASSOC_NOT_AUTHED = 9,
+
+ IEEE80211_REASON_PWRCAP_UNACCEPTABLE = 10,
+ IEEE80211_REASON_SUPPCHAN_UNACCEPTABLE = 11,
+ IEEE80211_REASON_RSN_REQUIRED = 11,
+ IEEE80211_REASON_RSN_INCONSISTENT = 12,
+ IEEE80211_REASON_IE_INVALID = 13,
+ IEEE80211_REASON_MIC_FAILURE = 14,
+
+ IEEE80211_STATUS_SUCCESS = 0,
+ IEEE80211_STATUS_UNSPECIFIED = 1,
+ IEEE80211_STATUS_CAPINFO = 10,
+ IEEE80211_STATUS_NOT_ASSOCED = 11,
+ IEEE80211_STATUS_OTHER = 12,
+ IEEE80211_STATUS_ALG = 13,
+ IEEE80211_STATUS_SEQUENCE = 14,
+ IEEE80211_STATUS_CHALLENGE = 15,
+ IEEE80211_STATUS_TIMEOUT = 16,
+ IEEE80211_STATUS_TOOMANY = 17,
+ IEEE80211_STATUS_BASIC_RATE = 18,
+ IEEE80211_STATUS_SP_REQUIRED = 19,
+ IEEE80211_STATUS_PBCC_REQUIRED = 20,
+ IEEE80211_STATUS_CA_REQUIRED = 21,
+ IEEE80211_STATUS_SM_REQUIRED = 22,
+ IEEE80211_STATUS_PWRCAP_UNACCEPTABLE = 23,
+ IEEE80211_STATUS_SUPPCHAN_UNACCEPTABLE = 24,
+ IEEE80211_STATUS_TOO_MANY_STATIONS = 22,
+ IEEE80211_STATUS_RATES = 23,
+ IEEE80211_STATUS_SHORTSLOT_REQUIRED = 25,
+ IEEE80211_STATUS_DSSSOFDM_REQUIRED = 26,
+};
+
+#define IEEE80211_WEP_KEYLEN 5 /* 40bit */
+#define IEEE80211_WEP_IVLEN 3 /* 24bit */
+#define IEEE80211_WEP_KIDLEN 1 /* 1 octet */
+#define IEEE80211_WEP_CRCLEN 4 /* CRC-32 */
+#define IEEE80211_WEP_NKID 4 /* number of key ids */
+
+/*
+ * 802.11i defines an extended IV for use with non-WEP ciphers.
+ * When the EXTIV bit is set in the key id byte an additional
+ * 4 bytes immediately follow the IV for TKIP. For CCMP the
+ * EXTIV bit is likewise set but the 8 bytes represent the
+ * CCMP header rather than IV+extended-IV.
+ */
+#define IEEE80211_WEP_EXTIV 0x20
+#define IEEE80211_WEP_EXTIVLEN 4 /* extended IV length */
+#define IEEE80211_WEP_MICLEN 8 /* trailing MIC */
+
+#define IEEE80211_CRC_LEN 4
+
+/*
+ * Maximum acceptable MTU is:
+ * IEEE80211_MAX_LEN - WEP overhead - CRC -
+ * QoS overhead - RSN/WPA overhead
+ * Min is arbitrarily chosen > IEEE80211_MIN_LEN. The default
+ * mtu is Ethernet-compatible; it's set by ether_ifattach.
+ */
+#define IEEE80211_MTU_MAX 2290
+#define IEEE80211_MTU_MIN 32
+
+#define IEEE80211_MAX_LEN (2300 + IEEE80211_CRC_LEN + \
+ (IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN + IEEE80211_WEP_CRCLEN))
+#define IEEE80211_ACK_LEN \
+ (sizeof(struct ieee80211_frame_ack) + IEEE80211_CRC_LEN)
+#define IEEE80211_MIN_LEN \
+ (sizeof(struct ieee80211_frame_min) + IEEE80211_CRC_LEN)
+
+/*
+ * The 802.11 spec says at most 2007 stations may be
+ * associated at once. For most APs this is way more
+ * than is feasible so we use a default of 128. This
+ * number may be overridden by the driver and/or by
+ * user configuration.
+ */
+#define IEEE80211_AID_MAX 2007
+#define IEEE80211_AID_DEF 128
+
+#define IEEE80211_AID(b) ((b) &~ 0xc000)
+
+/*
+ * RTS frame length parameters. The default is specified in
+ * the 802.11 spec. The max may be wrong for jumbo frames.
+ */
+#define IEEE80211_RTS_DEFAULT 512
+#define IEEE80211_RTS_MIN 1
+#define IEEE80211_RTS_MAX 2346
+
+/*
+ * Regulatory extension identifier for country IE.
+ */
+#define IEEE80211_REG_EXT_ID 201
+
+/*
+ * IEEE 802.11 timer synchronization function (TSF) timestamp length
+ */
+#define IEEE80211_TSF_LEN 8
+
+#endif /* _NET80211_IEEE80211_H_ */
diff --git a/package/network/services/hostapd/madwifi/net80211/.svn/text-base/ieee80211_crypto.h.svn-base b/package/network/services/hostapd/madwifi/net80211/.svn/text-base/ieee80211_crypto.h.svn-base
new file mode 100644
index 0000000..b34f359
--- /dev/null
+++ b/package/network/services/hostapd/madwifi/net80211/.svn/text-base/ieee80211_crypto.h.svn-base
@@ -0,0 +1,207 @@
+/*-
+ * Copyright (c) 2001 Atsushi Onoe
+ * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $Id: ieee80211_crypto.h 3068 2007-12-21 17:46:02Z mentor $
+ */
+#ifndef _NET80211_IEEE80211_CRYPTO_H_
+#define _NET80211_IEEE80211_CRYPTO_H_
+
+/*
+ * 802.11 protocol crypto-related definitions.
+ */
+#define IEEE80211_KEYBUF_SIZE 16
+#define IEEE80211_MICBUF_SIZE (8 + 8) /* space for both TX & RX keys */
+#define IEEE80211_TID_SIZE 17 /* total number of TIDs */
+
+/*
+ * Old WEP-style key. Deprecated.
+ */
+struct ieee80211_wepkey {
+ u_int wk_len; /* key length in bytes */
+ u_int8_t wk_key[IEEE80211_KEYBUF_SIZE];
+};
+
+struct ieee80211_cipher;
+
+/*
+ * Crypto key state. There is sufficient room for all supported
+ * ciphers (see below). The underlying ciphers are handled
+ * separately through loadable cipher modules that register with
+ * the generic crypto support. A key has a reference to an instance
+ * of the cipher; any per-key state is hung off wk_private by the
+ * cipher when it is attached. Ciphers are automatically called
+ * to detach and cleanup any such state when the key is deleted.
+ *
+ * The generic crypto support handles encap/decap of cipher-related
+ * frame contents for both hardware- and software-based implementations.
+ * A key requiring software crypto support is automatically flagged and
+ * the cipher is expected to honor this and do the necessary work.
+ * Ciphers such as TKIP may also support mixed hardware/software
+ * encrypt/decrypt and MIC processing.
+ */
+
+typedef u_int16_t ieee80211_keyix_t;
+
+/* XXX pack better? */
+/* XXX 48-bit rsc/tsc */
+struct ieee80211_key {
+ u_int8_t wk_keylen; /* key length in bytes */
+ u_int8_t wk_flags;
+#define IEEE80211_KEY_XMIT 0x01 /* key used for xmit */
+#define IEEE80211_KEY_RECV 0x02 /* key used for recv */
+#define IEEE80211_KEY_GROUP 0x04 /* key used for WPA group operation */
+#define IEEE80211_KEY_SWCRYPT 0x10 /* host-based encrypt/decrypt */
+#define IEEE80211_KEY_SWMIC 0x20 /* host-based enmic/demic */
+ ieee80211_keyix_t wk_keyix; /* key index */
+ u_int8_t wk_key[IEEE80211_KEYBUF_SIZE+IEEE80211_MICBUF_SIZE];
+#define wk_txmic wk_key+IEEE80211_KEYBUF_SIZE+0 /* XXX can't () right */
+#define wk_rxmic wk_key+IEEE80211_KEYBUF_SIZE+8 /* XXX can't () right */
+ u_int64_t wk_keyrsc[IEEE80211_TID_SIZE]; /* key receive sequence counter */
+ u_int64_t wk_keytsc; /* key transmit sequence counter */
+ const struct ieee80211_cipher *wk_cipher;
+ void *wk_private; /* private cipher state */
+};
+#define IEEE80211_KEY_COMMON /* common flags passed in by apps */\
+ (IEEE80211_KEY_XMIT | IEEE80211_KEY_RECV | IEEE80211_KEY_GROUP)
+
+/*
+ * NB: these values are ordered carefully; there are lots of
+ * of implications in any reordering. In particular beware
+ * that 4 is not used to avoid conflicting with IEEE80211_F_PRIVACY.
+ */
+#define IEEE80211_CIPHER_WEP 0
+#define IEEE80211_CIPHER_TKIP 1
+#define IEEE80211_CIPHER_AES_OCB 2
+#define IEEE80211_CIPHER_AES_CCM 3
+#define IEEE80211_CIPHER_CKIP 5
+#define IEEE80211_CIPHER_NONE 6 /* pseudo value */
+
+#define IEEE80211_CIPHER_MAX (IEEE80211_CIPHER_NONE + 1)
+
+#define IEEE80211_KEYIX_NONE ((ieee80211_keyix_t)-1)
+
+#if defined(__KERNEL__) || defined(_KERNEL)
+
+struct ieee80211com;
+struct ieee80211vap;
+struct ieee80211_node;
+struct sk_buff;
+
+void ieee80211_crypto_attach(struct ieee80211com *);
+void ieee80211_crypto_detach(struct ieee80211com *);
+void ieee80211_crypto_vattach(struct ieee80211vap *);
+void ieee80211_crypto_vdetach(struct ieee80211vap *);
+int ieee80211_crypto_newkey(struct ieee80211vap *, int, int,
+ struct ieee80211_key *);
+int ieee80211_crypto_delkey(struct ieee80211vap *, struct ieee80211_key *,
+ struct ieee80211_node *);
+int ieee80211_crypto_setkey(struct ieee80211vap *, struct ieee80211_key *,
+ const u_int8_t macaddr[IEEE80211_ADDR_LEN], struct ieee80211_node *);
+void ieee80211_crypto_delglobalkeys(struct ieee80211vap *);
+
+/*
+ * Template for a supported cipher. Ciphers register with the
+ * crypto code and are typically loaded as separate modules
+ * (the null cipher is always present).
+ * XXX may need refcnts
+ */
+struct ieee80211_cipher {
+ const char *ic_name; /* printable name */
+ u_int ic_cipher; /* IEEE80211_CIPHER_* */
+ u_int ic_header; /* size of privacy header (bytes) */
+ u_int ic_trailer; /* size of privacy trailer (bytes) */
+ u_int ic_miclen; /* size of mic trailer (bytes) */
+ void *(*ic_attach)(struct ieee80211vap *, struct ieee80211_key *);
+ void (*ic_detach)(struct ieee80211_key *);
+ int (*ic_setkey)(struct ieee80211_key *);
+ int (*ic_encap)(struct ieee80211_key *, struct sk_buff *, u_int8_t);
+ int (*ic_decap)(struct ieee80211_key *, struct sk_buff *, int);
+ int (*ic_enmic)(struct ieee80211_key *, struct sk_buff *, int);
+ int (*ic_demic)(struct ieee80211_key *, struct sk_buff *, int, int);
+};
+extern const struct ieee80211_cipher ieee80211_cipher_none;
+
+void ieee80211_crypto_register(const struct ieee80211_cipher *);
+void ieee80211_crypto_unregister(const struct ieee80211_cipher *);
+int ieee80211_crypto_available(struct ieee80211vap*, u_int);
+
+struct ieee80211_key *ieee80211_crypto_encap(struct ieee80211_node *,
+ struct sk_buff *);
+struct ieee80211_key *ieee80211_crypto_decap(struct ieee80211_node *,
+ struct sk_buff *, int);
+
+/*
+ * Check and remove any MIC.
+ */
+static __inline int
+ieee80211_crypto_demic(struct ieee80211vap *vap, struct ieee80211_key *k,
+ struct sk_buff *skb, int hdrlen, int force)
+{
+ const struct ieee80211_cipher *cip = k->wk_cipher;
+ return (cip->ic_miclen > 0 ? cip->ic_demic(k, skb, hdrlen, force) : 1);
+}
+
+/*
+ * Add any MIC.
+ */
+static __inline int
+ieee80211_crypto_enmic(struct ieee80211vap *vap, struct ieee80211_key *k,
+ struct sk_buff *skb, int force)
+{
+ const struct ieee80211_cipher *cip = k->wk_cipher;
+ return (cip->ic_miclen > 0 ? cip->ic_enmic(k, skb, force) : 1);
+}
+
+/*
+ * Reset key state to an unused state. The crypto
+ * key allocation mechanism ensures other state (e.g.
+ * key data) is properly setup before a key is used.
+ */
+static __inline void
+ieee80211_crypto_resetkey(struct ieee80211vap *vap, struct ieee80211_key *k,
+ ieee80211_keyix_t ix)
+{
+ k->wk_cipher = &ieee80211_cipher_none;;
+ k->wk_private = k->wk_cipher->ic_attach(vap, k);
+ k->wk_keyix = ix;
+ k->wk_flags = IEEE80211_KEY_XMIT | IEEE80211_KEY_RECV;
+}
+
+/*
+ * Crypto-related notification methods.
+ */
+void ieee80211_notify_replay_failure(struct ieee80211vap *,
+ const struct ieee80211_frame *, const struct ieee80211_key *,
+ u_int64_t rsc);
+void ieee80211_notify_michael_failure(struct ieee80211vap *,
+ const struct ieee80211_frame *, ieee80211_keyix_t keyix);
+#endif /* defined(__KERNEL__) || defined(_KERNEL) */
+#endif /* _NET80211_IEEE80211_CRYPTO_H_ */
diff --git a/package/network/services/hostapd/madwifi/net80211/.svn/text-base/ieee80211_ioctl.h.svn-base b/package/network/services/hostapd/madwifi/net80211/.svn/text-base/ieee80211_ioctl.h.svn-base
new file mode 100644
index 0000000..204303b
--- /dev/null
+++ b/package/network/services/hostapd/madwifi/net80211/.svn/text-base/ieee80211_ioctl.h.svn-base
@@ -0,0 +1,715 @@
+/*-
+ * Copyright (c) 2001 Atsushi Onoe
+ * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $Id: ieee80211_ioctl.h 3314 2008-01-30 23:50:16Z mtaylor $
+ */
+#ifndef _NET80211_IEEE80211_IOCTL_H_
+#define _NET80211_IEEE80211_IOCTL_H_
+
+/*
+ * IEEE 802.11 ioctls.
+ */
+#include <net80211/_ieee80211.h>
+#include <net80211/ieee80211.h>
+#include <net80211/ieee80211_crypto.h>
+
+/*
+ * Per/node (station) statistics available when operating as an AP.
+ */
+struct ieee80211_nodestats {
+ u_int32_t ns_rx_data; /* rx data frames */
+ u_int32_t ns_rx_mgmt; /* rx management frames */
+ u_int32_t ns_rx_ctrl; /* rx control frames */
+ u_int32_t ns_rx_ucast; /* rx unicast frames */
+ u_int32_t ns_rx_mcast; /* rx multi/broadcast frames */
+ u_int64_t ns_rx_bytes; /* rx data count (bytes) */
+ u_int64_t ns_rx_beacons; /* rx beacon frames */
+ u_int32_t ns_rx_proberesp; /* rx probe response frames */
+
+ u_int32_t ns_rx_dup; /* rx discard because it's a dup */
+ u_int32_t ns_rx_noprivacy; /* rx w/ wep but privacy off */
+ u_int32_t ns_rx_wepfail; /* rx wep processing failed */
+ u_int32_t ns_rx_demicfail; /* rx demic failed */
+ u_int32_t ns_rx_decap; /* rx decapsulation failed */
+ u_int32_t ns_rx_defrag; /* rx defragmentation failed */
+ u_int32_t ns_rx_disassoc; /* rx disassociation */
+ u_int32_t ns_rx_deauth; /* rx deauthentication */
+ u_int32_t ns_rx_decryptcrc; /* rx decrypt failed on crc */
+ u_int32_t ns_rx_unauth; /* rx on unauthorized port */
+ u_int32_t ns_rx_unencrypted; /* rx unecrypted w/ privacy */
+
+ u_int32_t ns_tx_data; /* tx data frames */
+ u_int32_t ns_tx_mgmt; /* tx management frames */
+ u_int32_t ns_tx_ucast; /* tx unicast frames */
+ u_int32_t ns_tx_mcast; /* tx multi/broadcast frames */
+ u_int64_t ns_tx_bytes; /* tx data count (bytes) */
+ u_int32_t ns_tx_probereq; /* tx probe request frames */
+ u_int32_t ns_tx_uapsd; /* tx on uapsd queue */
+
+ u_int32_t ns_tx_novlantag; /* tx discard due to no tag */
+ u_int32_t ns_tx_vlanmismatch; /* tx discard due to of bad tag */
+
+ u_int32_t ns_tx_eosplost; /* uapsd EOSP retried out */
+
+ u_int32_t ns_ps_discard; /* ps discard due to of age */
+
+ u_int32_t ns_uapsd_triggers; /* uapsd triggers */
+
+ /* MIB-related state */
+ u_int32_t ns_tx_assoc; /* [re]associations */
+ u_int32_t ns_tx_assoc_fail; /* [re]association failures */
+ u_int32_t ns_tx_auth; /* [re]authentications */
+ u_int32_t ns_tx_auth_fail; /* [re]authentication failures*/
+ u_int32_t ns_tx_deauth; /* deauthentications */
+ u_int32_t ns_tx_deauth_code; /* last deauth reason */
+ u_int32_t ns_tx_disassoc; /* disassociations */
+ u_int32_t ns_tx_disassoc_code; /* last disassociation reason */
+ u_int32_t ns_psq_drops; /* power save queue drops */
+};
+
+/*
+ * Summary statistics.
+ */
+struct ieee80211_stats {
+ u_int32_t is_rx_badversion; /* rx frame with bad version */
+ u_int32_t is_rx_tooshort; /* rx frame too short */
+ u_int32_t is_rx_wrongbss; /* rx from wrong bssid */
+ u_int32_t is_rx_dup; /* rx discard due to it's a dup */
+ u_int32_t is_rx_wrongdir; /* rx w/ wrong direction */
+ u_int32_t is_rx_mcastecho; /* rx discard due to of mcast echo */
+ u_int32_t is_rx_mcastdisabled; /* rx discard due to of mcast disabled */
+ u_int32_t is_rx_notassoc; /* rx discard due to sta !assoc */
+ u_int32_t is_rx_noprivacy; /* rx w/ wep but privacy off */
+ u_int32_t is_rx_unencrypted; /* rx w/o wep and privacy on */
+ u_int32_t is_rx_wepfail; /* rx wep processing failed */
+ u_int32_t is_rx_decap; /* rx decapsulation failed */
+ u_int32_t is_rx_mgtdiscard; /* rx discard mgt frames */
+ u_int32_t is_rx_ctl; /* rx discard ctrl frames */
+ u_int32_t is_rx_beacon; /* rx beacon frames */
+ u_int32_t is_rx_rstoobig; /* rx rate set truncated */
+ u_int32_t is_rx_elem_missing; /* rx required element missing*/
+ u_int32_t is_rx_elem_toobig; /* rx element too big */
+ u_int32_t is_rx_elem_toosmall; /* rx element too small */
+ u_int32_t is_rx_elem_unknown; /* rx element unknown */
+ u_int32_t is_rx_badchan; /* rx frame w/ invalid chan */
+ u_int32_t is_rx_chanmismatch; /* rx frame chan mismatch */
+ u_int32_t is_rx_nodealloc; /* rx frame dropped */
+ u_int32_t is_rx_ssidmismatch; /* rx frame ssid mismatch */
+ u_int32_t is_rx_auth_unsupported;/* rx w/ unsupported auth alg */
+ u_int32_t is_rx_auth_fail; /* rx sta auth failure */
+ u_int32_t is_rx_auth_countermeasures;/* rx auth discard due to CM */
+ u_int32_t is_rx_assoc_bss; /* rx assoc from wrong bssid */
+ u_int32_t is_rx_assoc_notauth; /* rx assoc w/o auth */
+ u_int32_t is_rx_assoc_capmismatch;/* rx assoc w/ cap mismatch */
+ u_int32_t is_rx_assoc_norate; /* rx assoc w/ no rate match */
+ u_int32_t is_rx_assoc_badwpaie; /* rx assoc w/ bad WPA IE */
+ u_int32_t is_rx_assoc_badscie; /* rx assoc w/ bad SC IE */
+ u_int32_t is_rx_deauth; /* rx deauthentication */
+ u_int32_t is_rx_disassoc; /* rx disassociation */
+ u_int32_t is_rx_badsubtype; /* rx frame w/ unknown subtype*/
+ u_int32_t is_rx_nobuf; /* rx failed for lack of buf */
+ u_int32_t is_rx_decryptcrc; /* rx decrypt failed on crc */
+ u_int32_t is_rx_ahdemo_mgt; /* rx discard ahdemo mgt frame*/
+ u_int32_t is_rx_bad_auth; /* rx bad auth request */
+ u_int32_t is_rx_unauth; /* rx on unauthorized port */
+ u_int32_t is_rx_badkeyid; /* rx w/ incorrect keyid */
+ u_int32_t is_rx_ccmpreplay; /* rx seq# violation (CCMP) */
+ u_int32_t is_rx_ccmpformat; /* rx format bad (CCMP) */
+ u_int32_t is_rx_ccmpmic; /* rx MIC check failed (CCMP) */
+ u_int32_t is_rx_tkipreplay; /* rx seq# violation (TKIP) */
+ u_int32_t is_rx_tkipformat; /* rx format bad (TKIP) */
+ u_int32_t is_rx_tkipmic; /* rx MIC check failed (TKIP) */
+ u_int32_t is_rx_tkipicv; /* rx ICV check failed (TKIP) */
+ u_int32_t is_rx_badcipher; /* rx failed due to of key type */
+ u_int32_t is_rx_nocipherctx; /* rx failed due to key !setup */
+ u_int32_t is_rx_acl; /* rx discard due to of acl policy */
+ u_int32_t is_rx_ffcnt; /* rx fast frames */
+ u_int32_t is_rx_badathtnl; /* driver key alloc failed */
+ u_int32_t is_tx_nobuf; /* tx failed for lack of buf */
+ u_int32_t is_tx_nonode; /* tx failed for no node */
+ u_int32_t is_tx_unknownmgt; /* tx of unknown mgt frame */
+ u_int32_t is_tx_badcipher; /* tx failed due to of key type */
+ u_int32_t is_tx_nodefkey; /* tx failed due to no defkey */
+ u_int32_t is_tx_noheadroom; /* tx failed due to no space */
+ u_int32_t is_tx_ffokcnt; /* tx fast frames sent success */
+ u_int32_t is_tx_fferrcnt; /* tx fast frames sent success */
+ u_int32_t is_scan_active; /* active scans started */
+ u_int32_t is_scan_passive; /* passive scans started */
+ u_int32_t is_node_timeout; /* nodes timed out inactivity */
+ u_int32_t is_node_fdisassoc; /* forced node disassociation */
+ u_int32_t is_crypto_nomem; /* no memory for crypto ctx */
+ u_int32_t is_crypto_tkip; /* tkip crypto done in s/w */
+ u_int32_t is_crypto_tkipenmic; /* tkip en-MIC done in s/w */
+ u_int32_t is_crypto_tkipdemic; /* tkip de-MIC done in s/w */
+ u_int32_t is_crypto_tkipcm; /* tkip counter measures */
+ u_int32_t is_crypto_ccmp; /* ccmp crypto done in s/w */
+ u_int32_t is_crypto_wep; /* wep crypto done in s/w */
+ u_int32_t is_crypto_setkey_cipher;/* cipher rejected key */
+ u_int32_t is_crypto_setkey_nokey;/* no key index for setkey */
+ u_int32_t is_crypto_delkey; /* driver key delete failed */
+ u_int32_t is_crypto_badcipher; /* unknown cipher */
+ u_int32_t is_crypto_nocipher; /* cipher not available */
+ u_int32_t is_crypto_attachfail; /* cipher attach failed */
+ u_int32_t is_crypto_swfallback; /* cipher fallback to s/w */
+ u_int32_t is_crypto_keyfail; /* driver key alloc failed */
+ u_int32_t is_crypto_enmicfail; /* en-MIC failed */
+ u_int32_t is_ibss_capmismatch; /* merge failed-cap mismatch */
+ u_int32_t is_ibss_norate; /* merge failed-rate mismatch */
+ u_int32_t is_ps_unassoc; /* ps-poll for unassoc. sta */
+ u_int32_t is_ps_badaid; /* ps-poll w/ incorrect aid */
+ u_int32_t is_ps_qempty; /* ps-poll w/ nothing to send */
+};
+
+/*
+ * Max size of optional information elements. We artificially
+ * constrain this; it's limited only by the max frame size (and
+ * the max parameter size of the wireless extensions).
+ */
+#define IEEE80211_MAX_OPT_IE 256
+
+/*
+ * WPA/RSN get/set key request. Specify the key/cipher
+ * type and whether the key is to be used for sending and/or
+ * receiving. The key index should be set only when working
+ * with global keys (use IEEE80211_KEYIX_NONE for ``no index'').
+ * Otherwise a unicast/pairwise key is specified by the bssid
+ * (on a station) or mac address (on an ap). They key length
+ * must include any MIC key data; otherwise it should be no
+ more than IEEE80211_KEYBUF_SIZE.
+ */
+struct ieee80211req_key {
+ u_int8_t ik_type; /* key/cipher type */
+ u_int8_t ik_pad;
+ ieee80211_keyix_t ik_keyix; /* key index */
+ u_int8_t ik_keylen; /* key length in bytes */
+ u_int8_t ik_flags;
+/* NB: IEEE80211_KEY_XMIT and IEEE80211_KEY_RECV defined elsewhere */
+#define IEEE80211_KEY_DEFAULT 0x80 /* default xmit key */
+ u_int8_t ik_macaddr[IEEE80211_ADDR_LEN];
+ u_int64_t ik_keyrsc; /* key receive sequence counter */
+ u_int64_t ik_keytsc; /* key transmit sequence counter */
+ u_int8_t ik_keydata[IEEE80211_KEYBUF_SIZE+IEEE80211_MICBUF_SIZE];
+};
+
+/*
+ * Delete a key either by index or address. Set the index
+ * to IEEE80211_KEYIX_NONE when deleting a unicast key.
+ */
+struct ieee80211req_del_key {
+ /* NB: This is different to ieee80211_keyix_t, but this is OK as
+ * values are unique over the low order bits. */
+ u_int8_t idk_keyix; /* key index */
+ u_int8_t idk_macaddr[IEEE80211_ADDR_LEN];
+};
+
+/*
+ * MLME state manipulation request. IEEE80211_MLME_ASSOC
+ * only makes sense when operating as a station. The other
+ * requests can be used when operating as a station or an
+ * ap (to effect a station).
+ */
+struct ieee80211req_mlme {
+ u_int8_t im_op; /* operation to perform */
+#define IEEE80211_MLME_ASSOC 1 /* associate station */
+#define IEEE80211_MLME_DISASSOC 2 /* disassociate station */
+#define IEEE80211_MLME_DEAUTH 3 /* deauthenticate station */
+#define IEEE80211_MLME_AUTHORIZE 4 /* authorize station */
+#define IEEE80211_MLME_UNAUTHORIZE 5 /* unauthorize station */
+#define IEEE80211_MLME_CLEAR_STATS 6 /* clear station statistic */
+ u_int8_t im_ssid_len; /* length of optional ssid */
+ u_int16_t im_reason; /* 802.11 reason code */
+ u_int8_t im_macaddr[IEEE80211_ADDR_LEN];
+ u_int8_t im_ssid[IEEE80211_NWID_LEN];
+};
+
+/*
+ * MAC ACL operations.
+ */
+enum {
+ IEEE80211_MACCMD_POLICY_OPEN = 0, /* set policy: no ACLs */
+ IEEE80211_MACCMD_POLICY_ALLOW = 1, /* set policy: allow traffic */
+ IEEE80211_MACCMD_POLICY_DENY = 2, /* set policy: deny traffic */
+ IEEE80211_MACCMD_FLUSH = 3, /* flush ACL database */
+ IEEE80211_MACCMD_DETACH = 4, /* detach ACL policy */
+};
+
+/*
+ * Set the active channel list. Note this list is
+ * intersected with the available channel list in
+ * calculating the set of channels actually used in
+ * scanning.
+ */
+struct ieee80211req_chanlist {
+ u_int8_t ic_channels[IEEE80211_CHAN_BYTES];
+};
+
+/*
+ * Get the active channel list info.
+ */
+struct ieee80211req_chaninfo {
+ u_int ic_nchans;
+ struct ieee80211_channel ic_chans[IEEE80211_CHAN_MAX];
+};
+
+/*
+ * Retrieve the WPA/RSN information element for an associated station.
+ */
+struct ieee80211req_wpaie {
+ u_int8_t wpa_macaddr[IEEE80211_ADDR_LEN];
+ u_int8_t wpa_ie[IEEE80211_MAX_OPT_IE];
+ u_int8_t rsn_ie[IEEE80211_MAX_OPT_IE];
+};
+
+/*
+ * Retrieve per-node statistics.
+ */
+struct ieee80211req_sta_stats {
+ union {
+ /* NB: explicitly force 64-bit alignment */
+ u_int8_t macaddr[IEEE80211_ADDR_LEN];
+ u_int64_t pad;
+ } is_u;
+ struct ieee80211_nodestats is_stats;
+};
+
+/*
+ * Station information block; the mac address is used
+ * to retrieve other data like stats, unicast key, etc.
+ */
+struct ieee80211req_sta_info {
+ u_int16_t isi_len; /* length (mult of 4) */
+ u_int16_t isi_freq; /* MHz */
+ u_int16_t isi_flags; /* channel flags */
+ u_int16_t isi_state; /* state flags */
+ u_int8_t isi_authmode; /* authentication algorithm */
+ u_int8_t isi_rssi;
+ int8_t isi_noise;
+ u_int16_t isi_capinfo; /* capabilities */
+ u_int8_t isi_athflags; /* Atheros capabilities */
+ u_int8_t isi_erp; /* ERP element */
+ u_int8_t isi_macaddr[IEEE80211_ADDR_LEN];
+ u_int8_t isi_nrates; /* negotiated rates */
+ u_int8_t isi_rates[IEEE80211_RATE_MAXSIZE];
+ u_int8_t isi_txrate; /* index to isi_rates[] */
+ u_int16_t isi_ie_len; /* IE length */
+ u_int16_t isi_associd; /* assoc response */
+ u_int16_t isi_txpower; /* current tx power */
+ u_int16_t isi_vlan; /* vlan tag */
+ u_int16_t isi_txseqs[17]; /* seq to be transmitted */
+ u_int16_t isi_rxseqs[17]; /* seq previous for qos frames*/
+ u_int16_t isi_inact; /* inactivity timer */
+ u_int8_t isi_uapsd; /* UAPSD queues */
+ u_int8_t isi_opmode; /* sta operating mode */
+
+ /* XXX frag state? */
+ /* variable length IE data */
+};
+
+enum {
+ IEEE80211_STA_OPMODE_NORMAL,
+ IEEE80211_STA_OPMODE_XR
+};
+
+/*
+ * Retrieve per-station information; to retrieve all
+ * specify a mac address of ff:ff:ff:ff:ff:ff.
+ */
+struct ieee80211req_sta_req {
+ union {
+ /* NB: explicitly force 64-bit alignment */
+ u_int8_t macaddr[IEEE80211_ADDR_LEN];
+ u_int64_t pad;
+ } is_u;
+ struct ieee80211req_sta_info info[1]; /* variable length */
+};
+
+/*
+ * Get/set per-station tx power cap.
+ */
+struct ieee80211req_sta_txpow {
+ u_int8_t it_macaddr[IEEE80211_ADDR_LEN];
+ u_int8_t it_txpow;
+};
+
+/*
+ * WME parameters are set and return using i_val and i_len.
+ * i_val holds the value itself. i_len specifies the AC
+ * and, as appropriate, then high bit specifies whether the
+ * operation is to be applied to the BSS or ourself.
+ */
+#define IEEE80211_WMEPARAM_SELF 0x0000 /* parameter applies to self */
+#define IEEE80211_WMEPARAM_BSS 0x8000 /* parameter applies to BSS */
+#define IEEE80211_WMEPARAM_VAL 0x7fff /* parameter value */
+
+/*
+ * Scan result data returned for IEEE80211_IOC_SCAN_RESULTS.
+ */
+struct ieee80211req_scan_result {
+ u_int16_t isr_len; /* length (mult of 4) */
+ u_int16_t isr_freq; /* MHz */
+ u_int16_t isr_flags; /* channel flags */
+ u_int8_t isr_noise;
+ u_int8_t isr_rssi;
+ u_int8_t isr_intval; /* beacon interval */
+ u_int16_t isr_capinfo; /* capabilities */
+ u_int8_t isr_erp; /* ERP element */
+ u_int8_t isr_bssid[IEEE80211_ADDR_LEN];
+ u_int8_t isr_nrates;
+ u_int8_t isr_rates[IEEE80211_RATE_MAXSIZE];
+ u_int8_t isr_ssid_len; /* SSID length */
+ u_int8_t isr_ie_len; /* IE length */
+ u_int8_t isr_pad[5];
+ /* variable length SSID followed by IE data */
+};
+
+#ifdef __FreeBSD__
+/*
+ * FreeBSD-style ioctls.
+ */
+/* the first member must be matched with struct ifreq */
+struct ieee80211req {
+ char i_name[IFNAMSIZ]; /* if_name, e.g. "wi0" */
+ u_int16_t i_type; /* req type */
+ int16_t i_val; /* Index or simple value */
+ int16_t i_len; /* Index or simple value */
+ void *i_data; /* Extra data */
+};
+#define SIOCS80211 _IOW('i', 234, struct ieee80211req)
+#define SIOCG80211 _IOWR('i', 235, struct ieee80211req)
+#define SIOCG80211STATS _IOWR('i', 236, struct ifreq)
+#define SIOC80211IFCREATE _IOWR('i', 237, struct ifreq)
+#define SIOC80211IFDESTROY _IOW('i', 238, struct ifreq)
+
+#define IEEE80211_IOC_SSID 1
+#define IEEE80211_IOC_NUMSSIDS 2
+#define IEEE80211_IOC_WEP 3
+#define IEEE80211_WEP_NOSUP -1
+#define IEEE80211_WEP_OFF 0
+#define IEEE80211_WEP_ON 1
+#define IEEE80211_WEP_MIXED 2
+#define IEEE80211_IOC_WEPKEY 4
+#define IEEE80211_IOC_NUMWEPKEYS 5
+#define IEEE80211_IOC_WEPTXKEY 6
+#define IEEE80211_IOC_AUTHMODE 7
+#define IEEE80211_IOC_STATIONNAME 8
+#define IEEE80211_IOC_CHANNEL 9
+#define IEEE80211_IOC_POWERSAVE 10
+#define IEEE80211_POWERSAVE_NOSUP -1
+#define IEEE80211_POWERSAVE_OFF 0
+#define IEEE80211_POWERSAVE_CAM 1
+#define IEEE80211_POWERSAVE_PSP 2
+#define IEEE80211_POWERSAVE_PSP_CAM 3
+#define IEEE80211_POWERSAVE_ON IEEE80211_POWERSAVE_CAM
+#define IEEE80211_IOC_POWERSAVESLEEP 11
+#define IEEE80211_IOC_RTSTHRESHOLD 12
+#define IEEE80211_IOC_PROTMODE 13
+#define IEEE80211_PROTMODE_OFF 0
+#define IEEE80211_PROTMODE_CTS 1
+#define IEEE80211_PROTMODE_RTSCTS 2
+#define IEEE80211_IOC_TXPOWER 14 /* global tx power limit */
+#define IEEE80211_IOC_BSSID 15
+#define IEEE80211_IOC_ROAMING 16 /* roaming mode */
+#define IEEE80211_IOC_PRIVACY 17 /* privacy invoked */
+#define IEEE80211_IOC_DROPUNENCRYPTED 18 /* discard unencrypted frames */
+#define IEEE80211_IOC_WPAKEY 19
+#define IEEE80211_IOC_DELKEY 20
+#define IEEE80211_IOC_MLME 21
+#define IEEE80211_IOC_OPTIE 22 /* optional info. element */
+#define IEEE80211_IOC_SCAN_REQ 23
+#define IEEE80211_IOC_SCAN_RESULTS 24
+#define IEEE80211_IOC_COUNTERMEASURES 25 /* WPA/TKIP countermeasures */
+#define IEEE80211_IOC_WPA 26 /* WPA mode (0,1,2) */
+#define IEEE80211_IOC_CHANLIST 27 /* channel list */
+#define IEEE80211_IOC_WME 28 /* WME mode (on, off) */
+#define IEEE80211_IOC_HIDESSID 29 /* hide SSID mode (on, off) */
+#define IEEE80211_IOC_APBRIDGE 30 /* AP inter-sta bridging */
+#define IEEE80211_IOC_MCASTCIPHER 31 /* multicast/default cipher */
+#define IEEE80211_IOC_MCASTKEYLEN 32 /* multicast key length */
+#define IEEE80211_IOC_UCASTCIPHERS 33 /* unicast cipher suites */
+#define IEEE80211_IOC_UCASTCIPHER 34 /* unicast cipher */
+#define IEEE80211_IOC_UCASTKEYLEN 35 /* unicast key length */
+#define IEEE80211_IOC_DRIVER_CAPS 36 /* driver capabilities */
+#define IEEE80211_IOC_KEYMGTALGS 37 /* key management algorithms */
+#define IEEE80211_IOC_RSNCAPS 38 /* RSN capabilities */
+#define IEEE80211_IOC_WPAIE 39 /* WPA information element */
+#define IEEE80211_IOC_STA_STATS 40 /* per-station statistics */
+#define IEEE80211_IOC_MACCMD 41 /* MAC ACL operation */
+#define IEEE80211_IOC_TXPOWMAX 43 /* max tx power for channel */
+#define IEEE80211_IOC_STA_TXPOW 44 /* per-station tx power limit */
+#define IEEE80211_IOC_STA_INFO 45 /* station/neighbor info */
+#define IEEE80211_IOC_WME_CWMIN 46 /* WME: ECWmin */
+#define IEEE80211_IOC_WME_CWMAX 47 /* WME: ECWmax */
+#define IEEE80211_IOC_WME_AIFS 48 /* WME: AIFSN */
+#define IEEE80211_IOC_WME_TXOPLIMIT 49 /* WME: txops limit */
+#define IEEE80211_IOC_WME_ACM 50 /* WME: ACM (bss only) */
+#define IEEE80211_IOC_WME_ACKPOLICY 51 /* WME: ACK policy (!bss only)*/
+#define IEEE80211_IOC_DTIM_PERIOD 52 /* DTIM period (beacons) */
+#define IEEE80211_IOC_BEACON_INTERVAL 53 /* beacon interval (ms) */
+#define IEEE80211_IOC_ADDMAC 54 /* add sta to MAC ACL table */
+#define IEEE80211_IOC_SETMAC 55 /* set interface wds mac addr */
+#define IEEE80211_IOC_FF 56 /* ATH fast frames (on, off) */
+#define IEEE80211_IOC_TURBOP 57 /* ATH turbo' (on, off) */
+#define IEEE80211_IOC_APPIEBUF 58 /* IE in the management frame */
+#define IEEE80211_IOC_FILTERFRAME 59 /* management frame filter */
+
+/*
+ * Scan result data returned for IEEE80211_IOC_SCAN_RESULTS.
+ */
+struct ieee80211req_scan_result {
+ u_int16_t isr_len; /* length (mult of 4) */
+ u_int16_t isr_freq; /* MHz */
+ u_int16_t isr_flags; /* channel flags */
+ u_int8_t isr_noise;
+ u_int8_t isr_rssi;
+ u_int8_t isr_intval; /* beacon interval */
+ u_int16_t isr_capinfo; /* capabilities */
+ u_int8_t isr_erp; /* ERP element */
+ u_int8_t isr_bssid[IEEE80211_ADDR_LEN];
+ u_int8_t isr_nrates;
+ u_int8_t isr_rates[IEEE80211_RATE_MAXSIZE];
+ u_int8_t isr_ssid_len; /* SSID length */
+ u_int8_t isr_ie_len; /* IE length */
+ u_int8_t isr_pad[5];
+ /* variable length SSID followed by IE data */
+};
+
+#endif /* __FreeBSD__ */
+
+#ifdef __linux__
+/*
+ * Wireless Extensions API, private ioctl interfaces.
+ *
+ * NB: Even-numbered ioctl numbers have set semantics and are privileged!
+ * (regardless of the incorrect comment in wireless.h!)
+ */
+#ifdef __KERNEL__
+#include <linux/if.h>
+#endif
+/* The maximum size of a iwpriv structure is IW_PRIV_SIZE_MASK, which was
+ * exceeded for some time by chaninfo ioctl. These macros change the size
+ * encoding for anything larger than IW_PRIV_SIZE_MASK from bytes to 4-byte
+ * multiples so that the padded size fits under IW_PRIV_SIZE_MASK. */
+#define IW_PRIV_BLOB_LENGTH_ENCODING(_SIZE) \
+ (((_SIZE) == ((_SIZE) & IW_PRIV_SIZE_MASK)) ? \
+ (_SIZE) : \
+ (((_SIZE) / sizeof(uint32_t)) + \
+ (((_SIZE) == (((_SIZE) / sizeof(uint32_t)) * sizeof(int))) ? \
+ 0 : 1)))
+#define IW_PRIV_BLOB_TYPE_ENCODING(_SIZE) \
+ (((_SIZE) == ((_SIZE) & IW_PRIV_SIZE_MASK)) ? \
+ (IW_PRIV_TYPE_BYTE | (_SIZE)) : \
+ (IW_PRIV_TYPE_INT | IW_PRIV_BLOB_LENGTH_ENCODING((_SIZE))))
+
+#define IEEE80211_IOCTL_SETPARAM (SIOCIWFIRSTPRIV+0)
+#define IEEE80211_IOCTL_GETPARAM (SIOCIWFIRSTPRIV+1)
+#define IEEE80211_IOCTL_SETMODE (SIOCIWFIRSTPRIV+2)
+#define IEEE80211_IOCTL_GETMODE (SIOCIWFIRSTPRIV+3)
+#define IEEE80211_IOCTL_SETWMMPARAMS (SIOCIWFIRSTPRIV+4)
+#define IEEE80211_IOCTL_GETWMMPARAMS (SIOCIWFIRSTPRIV+5)
+#define IEEE80211_IOCTL_SETCHANLIST (SIOCIWFIRSTPRIV+6)
+#define IEEE80211_IOCTL_GETCHANLIST (SIOCIWFIRSTPRIV+7)
+#define IEEE80211_IOCTL_CHANSWITCH (SIOCIWFIRSTPRIV+8)
+#define IEEE80211_IOCTL_GET_APPIEBUF (SIOCIWFIRSTPRIV+9)
+#define IEEE80211_IOCTL_SET_APPIEBUF (SIOCIWFIRSTPRIV+10)
+#define IEEE80211_IOCTL_READREG (SIOCIWFIRSTPRIV+11)
+#define IEEE80211_IOCTL_FILTERFRAME (SIOCIWFIRSTPRIV+12)
+#define IEEE80211_IOCTL_GETCHANINFO (SIOCIWFIRSTPRIV+13)
+#define IEEE80211_IOCTL_SETOPTIE (SIOCIWFIRSTPRIV+14)
+#define IEEE80211_IOCTL_GETOPTIE (SIOCIWFIRSTPRIV+15)
+#define IEEE80211_IOCTL_SETMLME (SIOCIWFIRSTPRIV+16)
+#define IEEE80211_IOCTL_RADAR (SIOCIWFIRSTPRIV+17)
+#define IEEE80211_IOCTL_SETKEY (SIOCIWFIRSTPRIV+18)
+#define IEEE80211_IOCTL_WRITEREG (SIOCIWFIRSTPRIV+19)
+#define IEEE80211_IOCTL_DELKEY (SIOCIWFIRSTPRIV+20)
+#define IEEE80211_IOCTL_HALMAP (SIOCIWFIRSTPRIV+21)
+#define IEEE80211_IOCTL_ADDMAC (SIOCIWFIRSTPRIV+22)
+#define IEEE80211_IOCTL_DELMAC (SIOCIWFIRSTPRIV+24)
+#define IEEE80211_IOCTL_WDSADDMAC (SIOCIWFIRSTPRIV+25)
+#define IEEE80211_IOCTL_WDSSETMAC (SIOCIWFIRSTPRIV+26)
+#define IEEE80211_IOCTL_KICKMAC (SIOCIWFIRSTPRIV+30)
+#define IEEE80211_IOCTL_SETSCANLIST (SIOCIWFIRSTPRIV+31)
+
+enum {
+ IEEE80211_WMMPARAMS_CWMIN = 1,
+ IEEE80211_WMMPARAMS_CWMAX = 2,
+ IEEE80211_WMMPARAMS_AIFS = 3,
+ IEEE80211_WMMPARAMS_TXOPLIMIT = 4,
+ IEEE80211_WMMPARAMS_ACM = 5,
+ IEEE80211_WMMPARAMS_NOACKPOLICY = 6,
+};
+enum {
+ IEEE80211_PARAM_TURBO = 1, /* turbo mode */
+ IEEE80211_PARAM_MODE = 2, /* phy mode (11a, 11b, etc.) */
+ IEEE80211_PARAM_AUTHMODE = 3, /* authentication mode */
+ IEEE80211_PARAM_PROTMODE = 4, /* 802.11g protection */
+ IEEE80211_PARAM_MCASTCIPHER = 5, /* multicast/default cipher */
+ IEEE80211_PARAM_MCASTKEYLEN = 6, /* multicast key length */
+ IEEE80211_PARAM_UCASTCIPHERS = 7, /* unicast cipher suites */
+ IEEE80211_PARAM_UCASTCIPHER = 8, /* unicast cipher */
+ IEEE80211_PARAM_UCASTKEYLEN = 9, /* unicast key length */
+ IEEE80211_PARAM_WPA = 10, /* WPA mode (0,1,2) */
+ IEEE80211_PARAM_ROAMING = 12, /* roaming mode */
+ IEEE80211_PARAM_PRIVACY = 13, /* privacy invoked */
+ IEEE80211_PARAM_COUNTERMEASURES = 14, /* WPA/TKIP countermeasures */
+ IEEE80211_PARAM_DROPUNENCRYPTED = 15, /* discard unencrypted frames */
+ IEEE80211_PARAM_DRIVER_CAPS = 16, /* driver capabilities */
+ IEEE80211_PARAM_MACCMD = 17, /* MAC ACL operation */
+ IEEE80211_PARAM_WMM = 18, /* WMM mode (on, off) */
+ IEEE80211_PARAM_HIDESSID = 19, /* hide SSID mode (on, off) */
+ IEEE80211_PARAM_APBRIDGE = 20, /* AP inter-sta bridging */
+ IEEE80211_PARAM_KEYMGTALGS = 21, /* key management algorithms */
+ IEEE80211_PARAM_RSNCAPS = 22, /* RSN capabilities */
+ IEEE80211_PARAM_INACT = 23, /* station inactivity timeout */
+ IEEE80211_PARAM_INACT_AUTH = 24, /* station auth inact timeout */
+ IEEE80211_PARAM_INACT_INIT = 25, /* station init inact timeout */
+ IEEE80211_PARAM_ABOLT = 26, /* Atheros Adv. Capabilities */
+ IEEE80211_PARAM_INACT_TICK = 27, /* station inactivity timer tick (seconds) */
+ IEEE80211_PARAM_DTIM_PERIOD = 28, /* DTIM period (beacons) */
+ IEEE80211_PARAM_BEACON_INTERVAL = 29, /* beacon interval (ms) */
+ IEEE80211_PARAM_DOTH = 30, /* 11.h is on/off */
+ IEEE80211_PARAM_PWRTARGET = 31, /* Current Channel Pwr Constraint */
+ IEEE80211_PARAM_GENREASSOC = 32, /* Generate a reassociation request */
+ IEEE80211_PARAM_COMPRESSION = 33, /* compression */
+ IEEE80211_PARAM_FF = 34, /* fast frames support */
+ IEEE80211_PARAM_XR = 35, /* XR support */
+ IEEE80211_PARAM_BURST = 36, /* burst mode */
+ IEEE80211_PARAM_PUREG = 37, /* pure 11g (no 11b stations) */
+ IEEE80211_PARAM_AR = 38, /* AR support */
+ IEEE80211_PARAM_WDS = 39, /* Enable 4 address processing */
+ IEEE80211_PARAM_BGSCAN = 40, /* bg scanning (on, off) */
+ IEEE80211_PARAM_BGSCAN_IDLE = 41, /* bg scan idle threshold */
+ IEEE80211_PARAM_BGSCAN_INTERVAL = 42, /* bg scan interval */
+ IEEE80211_PARAM_MCAST_RATE = 43, /* Multicast Tx Rate */
+ IEEE80211_PARAM_COVERAGE_CLASS = 44, /* coverage class */
+ IEEE80211_PARAM_COUNTRY_IE = 45, /* enable country IE */
+ IEEE80211_PARAM_SCANVALID = 46, /* scan cache valid threshold */
+ IEEE80211_PARAM_ROAM_RSSI_11A = 47, /* rssi threshold in 11a */
+ IEEE80211_PARAM_ROAM_RSSI_11B = 48, /* rssi threshold in 11b */
+ IEEE80211_PARAM_ROAM_RSSI_11G = 49, /* rssi threshold in 11g */
+ IEEE80211_PARAM_ROAM_RATE_11A = 50, /* tx rate threshold in 11a */
+ IEEE80211_PARAM_ROAM_RATE_11B = 51, /* tx rate threshold in 11b */
+ IEEE80211_PARAM_ROAM_RATE_11G = 52, /* tx rate threshold in 11g */
+ IEEE80211_PARAM_UAPSDINFO = 53, /* value for qos info field */
+ IEEE80211_PARAM_SLEEP = 54, /* force sleep/wake */
+ IEEE80211_PARAM_QOSNULL = 55, /* force sleep/wake */
+ IEEE80211_PARAM_PSPOLL = 56, /* force ps-poll generation (sta only) */
+ IEEE80211_PARAM_EOSPDROP = 57, /* force uapsd EOSP drop (ap only) */
+ IEEE80211_PARAM_MARKDFS = 58, /* mark a dfs interference channel when found */
+ IEEE80211_PARAM_REGCLASS = 59, /* enable regclass ids in country IE */
+ IEEE80211_PARAM_DROPUNENC_EAPOL = 60, /* drop unencrypted eapol frames */
+ IEEE80211_PARAM_SHPREAMBLE = 61, /* Short Preamble */
+ IEEE80211_PARAM_DUMPREGS = 62, /* Pretty printed dump of Atheros hardware registers */
+ IEEE80211_PARAM_DOTH_ALGORITHM = 63, /* spectrum management algorithm */
+ IEEE80211_PARAM_DOTH_MINCOM = 64, /* minimum number of common channels */
+ IEEE80211_PARAM_DOTH_SLCG = 65, /* permil of Stations Lost per Channel Gained */
+ IEEE80211_PARAM_DOTH_SLDG = 66, /* permil of Stations Lost per rssi Db Gained */
+ IEEE80211_PARAM_TXCONT = 67, /* continuous transmit mode (boolean) */
+ IEEE80211_PARAM_TXCONT_RATE = 68, /* continuous transmit mode data rate (in mbit/sec) - will use closest match from current rate table */
+ IEEE80211_PARAM_TXCONT_POWER = 69, /* power level in units of 0.5dBm */
+ IEEE80211_PARAM_DFS_TESTMODE = 70, /* do not perform DFS actions (i.e. markng DFS and channel change on interference), just report them via debug. */
+ IEEE80211_PARAM_DFS_CACTIME = 71, /* how long do we wait for chan availability
+ scans ?
+ FCC requires 60s, so that is the default. */
+ IEEE80211_PARAM_DFS_EXCLPERIOD = 72, /* DFS no-occupancy limit - how long do we stay
+ off a channel once radar is detected?
+ FCC requires 30m, so that is the default. */
+ IEEE80211_PARAM_BEACON_MISS_THRESH = 73, /* Beacon miss threshold (in beacons) */
+ IEEE80211_PARAM_BEACON_MISS_THRESH_MS = 74, /* Beacon miss threshold (in ms) */
+ IEEE80211_PARAM_MAXRATE = 75, /* Maximum rate (by table index) */
+ IEEE80211_PARAM_MINRATE = 76, /* Minimum rate (by table index) */
+ IEEE80211_PARAM_PROTMODE_RSSI = 77, /* RSSI Threshold for enabling protection mode */
+ IEEE80211_PARAM_PROTMODE_TIMEOUT = 78, /* Timeout for expiring protection mode */
+ IEEE80211_PARAM_BGSCAN_THRESH = 79, /* bg scan rssi threshold */
+ IEEE80211_PARAM_RSSI_DIS_THR = 80, /* rssi threshold for disconnection */
+ IEEE80211_PARAM_RSSI_DIS_COUNT = 81, /* counter for rssi threshold */
+ IEEE80211_PARAM_WDS_SEP = 82, /* move wds stations into separate interfaces */
+ IEEE80211_PARAM_MAXASSOC = 83, /* maximum associated stations */
+ IEEE80211_PARAM_PROBEREQ = 84, /* enable handling of probe requests */
+ IEEE80211_PARAM_BEACON_TXP = 85, /* set beacon tx power */
+};
+
+#define SIOCG80211STATS (SIOCDEVPRIVATE+2)
+/* NB: require in+out parameters so cannot use wireless extensions, yech */
+#define IEEE80211_IOCTL_GETKEY (SIOCDEVPRIVATE+3)
+#define IEEE80211_IOCTL_GETWPAIE (SIOCDEVPRIVATE+4)
+#define IEEE80211_IOCTL_STA_STATS (SIOCDEVPRIVATE+5)
+#define IEEE80211_IOCTL_STA_INFO (SIOCDEVPRIVATE+6)
+#define SIOC80211IFCREATE (SIOCDEVPRIVATE+7)
+#define SIOC80211IFDESTROY (SIOCDEVPRIVATE+8)
+#define IEEE80211_IOCTL_SCAN_RESULTS (SIOCDEVPRIVATE+9)
+
+struct ieee80211_clone_params {
+ char icp_name[IFNAMSIZ]; /* device name */
+ u_int16_t icp_opmode; /* operating mode */
+ u_int16_t icp_flags; /* see below */
+#define IEEE80211_CLONE_BSSID 0x0001 /* allocate unique mac/bssid */
+#define IEEE80211_NO_STABEACONS 0x0002 /* Do not setup the station beacon timers */
+};
+
+/* APPIEBUF related definitions */
+
+/* Management frame type to which application IE is added */
+enum {
+ IEEE80211_APPIE_FRAME_BEACON = 0,
+ IEEE80211_APPIE_FRAME_PROBE_REQ = 1,
+ IEEE80211_APPIE_FRAME_PROBE_RESP = 2,
+ IEEE80211_APPIE_FRAME_ASSOC_REQ = 3,
+ IEEE80211_APPIE_FRAME_ASSOC_RESP = 4,
+ IEEE80211_APPIE_NUM_OF_FRAME = 5
+};
+
+struct ieee80211req_getset_appiebuf {
+ u_int32_t app_frmtype; /* management frame type for which buffer is added */
+ u_int32_t app_buflen; /* application-supplied buffer length */
+ u_int8_t app_buf[0]; /* application-supplied IE(s) */
+};
+
+/* Flags ORed by application to set filter for receiving management frames */
+enum {
+ IEEE80211_FILTER_TYPE_BEACON = 1<<0,
+ IEEE80211_FILTER_TYPE_PROBE_REQ = 1<<1,
+ IEEE80211_FILTER_TYPE_PROBE_RESP = 1<<2,
+ IEEE80211_FILTER_TYPE_ASSOC_REQ = 1<<3,
+ IEEE80211_FILTER_TYPE_ASSOC_RESP = 1<<4,
+ IEEE80211_FILTER_TYPE_AUTH = 1<<5,
+ IEEE80211_FILTER_TYPE_DEAUTH = 1<<6,
+ IEEE80211_FILTER_TYPE_DISASSOC = 1<<7,
+ IEEE80211_FILTER_TYPE_ALL = 0xFF /* used to check the valid filter bits */
+};
+
+struct ieee80211req_set_filter {
+ u_int32_t app_filterype; /* management frame filter type */
+};
+
+
+#endif /* __linux__ */
+
+#endif /* _NET80211_IEEE80211_IOCTL_H_ */
diff --git a/package/network/services/hostapd/madwifi/net80211/_ieee80211.h b/package/network/services/hostapd/madwifi/net80211/_ieee80211.h
new file mode 100644
index 0000000..2d2a06f
--- /dev/null
+++ b/package/network/services/hostapd/madwifi/net80211/_ieee80211.h
@@ -0,0 +1,325 @@
+/*-
+ * Copyright (c) 2001 Atsushi Onoe
+ * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $Id: _ieee80211.h 3207 2008-01-18 21:25:05Z mtaylor $
+ */
+#ifndef _NET80211__IEEE80211_H_
+#define _NET80211__IEEE80211_H_
+
+enum ieee80211_phytype {
+ IEEE80211_T_DS, /* direct sequence spread spectrum */
+ IEEE80211_T_FH, /* frequency hopping */
+ IEEE80211_T_OFDM, /* frequency division multiplexing */
+ IEEE80211_T_TURBO, /* high rate OFDM, aka turbo mode */
+};
+#define IEEE80211_T_CCK IEEE80211_T_DS /* more common nomenclature */
+
+/* XXX: not really a mode; there are really multiple PHYs */
+enum ieee80211_phymode {
+ IEEE80211_MODE_AUTO = 0, /* autoselect */
+ IEEE80211_MODE_11A = 1, /* 5GHz, OFDM */
+ IEEE80211_MODE_11B = 2, /* 2GHz, CCK */
+ IEEE80211_MODE_11G = 3, /* 2GHz, OFDM */
+ IEEE80211_MODE_FH = 4, /* 2GHz, GFSK */
+ IEEE80211_MODE_TURBO_A = 5, /* 5GHz, OFDM, 2x clock dynamic turbo */
+ IEEE80211_MODE_TURBO_G = 6, /* 2GHz, OFDM, 2x clock dynamic turbo*/
+};
+#define IEEE80211_MODE_MAX (IEEE80211_MODE_TURBO_G+1)
+
+enum ieee80211_opmode {
+ IEEE80211_M_STA = 1, /* infrastructure station */
+ IEEE80211_M_IBSS = 0, /* IBSS (adhoc) station */
+ IEEE80211_M_AHDEMO = 3, /* Old lucent compatible adhoc demo */
+ IEEE80211_M_HOSTAP = 6, /* Software Access Point */
+ IEEE80211_M_MONITOR = 8, /* Monitor mode */
+ IEEE80211_M_WDS = 2 /* WDS link */
+};
+
+/*
+ * True if this mode will send beacon on a regular interval, like AP
+ * or IBSS
+ */
+#define IEEE80211_IS_MODE_BEACON(_opmode) \
+ ((_opmode == IEEE80211_M_IBSS) || \
+ (_opmode == IEEE80211_M_HOSTAP))
+
+/*
+ * True if this mode must behave like a DFS master, ie do Channel
+ * Check Availability and In Service Monitoring. We need to make sure
+ * that all modes cannot send data without being authorized. Such
+ * enforcement is not done in monitor mode however.
+ */
+
+#define IEEE80211_IS_MODE_DFS_MASTER(_opmode) \
+ ((_opmode == IEEE80211_M_IBSS) || \
+ (_opmode == IEEE80211_M_AHDEMO) || \
+ (_opmode == IEEE80211_M_HOSTAP) || \
+ (_opmode == IEEE80211_M_WDS))
+
+/*
+ * 802.11g protection mode.
+ */
+enum ieee80211_protmode {
+ IEEE80211_PROT_NONE = 0, /* no protection */
+ IEEE80211_PROT_CTSONLY = 1, /* CTS to self */
+ IEEE80211_PROT_RTSCTS = 2, /* RTS-CTS */
+};
+
+/*
+ * Authentication mode.
+ */
+enum ieee80211_authmode {
+ IEEE80211_AUTH_NONE = 0,
+ IEEE80211_AUTH_OPEN = 1, /* open */
+ IEEE80211_AUTH_SHARED = 2, /* shared-key */
+ IEEE80211_AUTH_8021X = 3, /* 802.1x */
+ IEEE80211_AUTH_AUTO = 4, /* auto-select/accept */
+ /* NB: these are used only for ioctls */
+ IEEE80211_AUTH_WPA = 5, /* WPA/RSN w/ 802.1x/PSK */
+};
+
+/*
+ * Roaming mode is effectively who controls the operation
+ * of the 802.11 state machine when operating as a station.
+ * State transitions are controlled either by the driver
+ * (typically when management frames are processed by the
+ * hardware/firmware), the host (auto/normal operation of
+ * the 802.11 layer), or explicitly through ioctl requests
+ * when applications like wpa_supplicant want control.
+ */
+enum ieee80211_roamingmode {
+ IEEE80211_ROAMING_DEVICE= 0, /* driver/hardware control */
+ IEEE80211_ROAMING_AUTO = 1, /* 802.11 layer control */
+ IEEE80211_ROAMING_MANUAL= 2, /* application control */
+};
+
+/*
+ * Scanning mode controls station scanning work; this is
+ * used only when roaming mode permits the host to select
+ * the bss to join/channel to use.
+ */
+enum ieee80211_scanmode {
+ IEEE80211_SCAN_DEVICE = 0, /* driver/hardware control */
+ IEEE80211_SCAN_BEST = 1, /* 802.11 layer selects best */
+ IEEE80211_SCAN_FIRST = 2, /* take first suitable candidate */
+};
+
+enum ieee80211_scanflags {
+ IEEE80211_NOSCAN_DEFAULT = (1 << 0),
+ IEEE80211_NOSCAN_SET = (1 << 1),
+};
+
+/*
+ * Channels are specified by frequency and attributes.
+ */
+struct ieee80211_channel {
+ u_int16_t ic_freq; /* setting in MHz */
+ u_int16_t ic_flags; /* see below */
+ u_int8_t ic_ieee; /* IEEE channel number */
+ int8_t ic_maxregpower; /* maximum regulatory tx power in dBm */
+ int8_t ic_maxpower; /* maximum tx power in dBm */
+ int8_t ic_minpower; /* minimum tx power in dBm */
+ u_int8_t ic_scanflags;
+ u_int8_t ic_idletime; /* phy idle time in % */
+};
+
+#define IEEE80211_CHAN_MAX 255
+#define IEEE80211_CHAN_BYTES 32 /* howmany(IEEE80211_CHAN_MAX, NBBY) */
+#define IEEE80211_CHAN_ANY 0xffff /* token for ``any channel'' */
+#define IEEE80211_CHAN_ANYC ((struct ieee80211_channel *) IEEE80211_CHAN_ANY)
+
+#define IEEE80211_RADAR_CHANCHANGE_TBTT_COUNT 0
+#define IEEE80211_DEFAULT_CHANCHANGE_TBTT_COUNT 3
+
+#define IEEE80211_RADAR_TEST_MUTE_CHAN 36 /* Move to channel 36 for mute test */
+
+/* bits 0-3 are for private use by drivers */
+/* channel attributes */
+#define IEEE80211_CHAN_TURBO 0x0010 /* Turbo channel */
+#define IEEE80211_CHAN_CCK 0x0020 /* CCK channel */
+#define IEEE80211_CHAN_OFDM 0x0040 /* OFDM channel */
+#define IEEE80211_CHAN_2GHZ 0x0080 /* 2 GHz spectrum channel. */
+#define IEEE80211_CHAN_5GHZ 0x0100 /* 5 GHz spectrum channel */
+#define IEEE80211_CHAN_PASSIVE 0x0200 /* Only passive scan allowed */
+#define IEEE80211_CHAN_DYN 0x0400 /* Dynamic CCK-OFDM channel */
+#define IEEE80211_CHAN_GFSK 0x0800 /* GFSK channel (FHSS PHY) */
+#define IEEE80211_CHAN_RADAR 0x1000 /* Radar found on channel */
+#define IEEE80211_CHAN_STURBO 0x2000 /* 11a static turbo channel only */
+#define IEEE80211_CHAN_HALF 0x4000 /* Half rate channel */
+#define IEEE80211_CHAN_QUARTER 0x8000 /* Quarter rate channel */
+
+/*
+ * Useful combinations of channel characteristics.
+ */
+#define IEEE80211_CHAN_FHSS \
+ (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_GFSK)
+#define IEEE80211_CHAN_A \
+ (IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM)
+#define IEEE80211_CHAN_B \
+ (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_CCK)
+#define IEEE80211_CHAN_PUREG \
+ (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_OFDM)
+#define IEEE80211_CHAN_G \
+ (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_DYN)
+#define IEEE80211_CHAN_108A \
+ (IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM | IEEE80211_CHAN_TURBO)
+#define IEEE80211_CHAN_108G \
+ (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_OFDM | IEEE80211_CHAN_TURBO)
+#define IEEE80211_CHAN_ST \
+ (IEEE80211_CHAN_108A | IEEE80211_CHAN_STURBO)
+
+#define IEEE80211_CHAN_ALL \
+ (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_GFSK | \
+ IEEE80211_CHAN_CCK | IEEE80211_CHAN_OFDM | IEEE80211_CHAN_DYN)
+#define IEEE80211_CHAN_ALLTURBO \
+ (IEEE80211_CHAN_ALL | IEEE80211_CHAN_TURBO | IEEE80211_CHAN_STURBO)
+
+#define IEEE80211_IS_CHAN_FHSS(_c) \
+ (((_c)->ic_flags & IEEE80211_CHAN_FHSS) == IEEE80211_CHAN_FHSS)
+#define IEEE80211_IS_CHAN_A(_c) \
+ (((_c)->ic_flags & IEEE80211_CHAN_A) == IEEE80211_CHAN_A)
+#define IEEE80211_IS_CHAN_B(_c) \
+ (((_c)->ic_flags & IEEE80211_CHAN_B) == IEEE80211_CHAN_B)
+#define IEEE80211_IS_CHAN_PUREG(_c) \
+ (((_c)->ic_flags & IEEE80211_CHAN_PUREG) == IEEE80211_CHAN_PUREG)
+#define IEEE80211_IS_CHAN_G(_c) \
+ (((_c)->ic_flags & IEEE80211_CHAN_G) == IEEE80211_CHAN_G)
+#define IEEE80211_IS_CHAN_ANYG(_c) \
+ (IEEE80211_IS_CHAN_PUREG(_c) || IEEE80211_IS_CHAN_G(_c))
+#define IEEE80211_IS_CHAN_ST(_c) \
+ (((_c)->ic_flags & IEEE80211_CHAN_ST) == IEEE80211_CHAN_ST)
+#define IEEE80211_IS_CHAN_108A(_c) \
+ (((_c)->ic_flags & IEEE80211_CHAN_108A) == IEEE80211_CHAN_108A)
+#define IEEE80211_IS_CHAN_108G(_c) \
+ (((_c)->ic_flags & IEEE80211_CHAN_108G) == IEEE80211_CHAN_108G)
+
+#define IEEE80211_IS_CHAN_2GHZ(_c) \
+ (((_c)->ic_flags & IEEE80211_CHAN_2GHZ) != 0)
+#define IEEE80211_IS_CHAN_5GHZ(_c) \
+ (((_c)->ic_flags & IEEE80211_CHAN_5GHZ) != 0)
+#define IEEE80211_IS_CHAN_OFDM(_c) \
+ (((_c)->ic_flags & IEEE80211_CHAN_OFDM) != 0)
+#define IEEE80211_IS_CHAN_CCK(_c) \
+ (((_c)->ic_flags & IEEE80211_CHAN_CCK) != 0)
+#define IEEE80211_IS_CHAN_GFSK(_c) \
+ (((_c)->ic_flags & IEEE80211_CHAN_GFSK) != 0)
+#define IEEE80211_IS_CHAN_TURBO(_c) \
+ (((_c)->ic_flags & IEEE80211_CHAN_TURBO) != 0)
+#define IEEE80211_IS_CHAN_STURBO(_c) \
+ (((_c)->ic_flags & IEEE80211_CHAN_STURBO) != 0)
+#define IEEE80211_IS_CHAN_DTURBO(_c) \
+ (((_c)->ic_flags & \
+ (IEEE80211_CHAN_TURBO | IEEE80211_CHAN_STURBO)) == IEEE80211_CHAN_TURBO)
+#define IEEE80211_IS_CHAN_HALF(_c) \
+ (((_c)->ic_flags & IEEE80211_CHAN_HALF) != 0)
+#define IEEE80211_IS_CHAN_QUARTER(_c) \
+ (((_c)->ic_flags & IEEE80211_CHAN_QUARTER) != 0)
+
+#define IEEE80211_IS_CHAN_RADAR(_c) \
+ (((_c)->ic_flags & IEEE80211_CHAN_RADAR) != 0)
+#define IEEE80211_IS_CHAN_PASSIVE(_c) \
+ (((_c)->ic_flags & IEEE80211_CHAN_PASSIVE) != 0)
+#define IEEE80211_ARE_CHANS_SAME_MODE(_a, _b) \
+ (((_a)->ic_flags & IEEE80211_CHAN_ALLTURBO) == ((_b)->ic_flags & IEEE80211_CHAN_ALLTURBO))
+
+/* ni_chan encoding for FH phy */
+#define IEEE80211_FH_CHANMOD 80
+#define IEEE80211_FH_CHAN(set,pat) (((set) - 1) * IEEE80211_FH_CHANMOD + (pat))
+#define IEEE80211_FH_CHANSET(chan) ((chan) / IEEE80211_FH_CHANMOD + 1)
+#define IEEE80211_FH_CHANPAT(chan) ((chan) % IEEE80211_FH_CHANMOD)
+
+/*
+ * Spectrum Management (IEEE 802.11h-2003)
+ */
+
+/* algorithm for (re)association based on supported channels
+ * (the one mentioned in 11.6.1 as out of scope of .11h) */
+enum ieee80211_sc_algorithm {
+ IEEE80211_SC_NONE,
+ /*
+ * Do not disallow anyone from associating. When needed, channel will
+ * be switched to the most suitable channel, no matter client stations
+ * support it or not.
+ */
+
+ IEEE80211_SC_LOOSE,
+ /*
+ * Do not disallow anyone from associating. When needed, channel will
+ * be switched to a suitable channel, which will be chosen taking
+ * ni->ni_suppchans and ic->ic_sc_sldg under consideration.
+ */
+
+ IEEE80211_SC_TIGHT,
+ /*
+ * Allow to associate if there are at least ic->ic_mincom channels
+ * common to the associating station and all of the already associated
+ * stations. If the number of new common channels is less than
+ * required, consider disassociating some other STAs. Such a
+ * disassociation will be performed if (and only if) the association we
+ * are currently considering would be then possible and the count of
+ * the resultant set of common channels (ic_chan_nodes[i] ==
+ * ic_cn_total) would increase by some amount. Whether the number of
+ * the new channels that could be gained is enough to sacrifice a
+ * number of STAs is determined by the ic->ic_slcg parameter.
+ */
+
+ IEEE80211_SC_STRICT
+ /*
+ * Basically the same behavior as IEEE80211_SC_TIGHT, except that if a
+ * station does not specify Supported Channels, then it is denied to
+ * associate.
+ */
+};
+
+/*
+ * 802.11 rate set.
+ */
+#define IEEE80211_RATE_SIZE 8 /* 802.11 standard */
+#define IEEE80211_RATE_MAXSIZE 15 /* max rates we'll handle */
+#define IEEE80211_SANITISE_RATESIZE(_rsz) \
+ ((_rsz > IEEE80211_RATE_MAXSIZE) ? IEEE80211_RATE_MAXSIZE : _rsz)
+
+struct ieee80211_rateset {
+ u_int8_t rs_nrates;
+ u_int8_t rs_rates[IEEE80211_RATE_MAXSIZE];
+};
+
+struct ieee80211_roam {
+ int8_t rssi11a; /* rssi thresh for 11a bss */
+ int8_t rssi11b; /* for 11g sta in 11b bss */
+ int8_t rssi11bOnly; /* for 11b sta */
+ u_int8_t pad1;
+ u_int8_t rate11a; /* rate thresh for 11a bss */
+ u_int8_t rate11b; /* for 11g sta in 11b bss */
+ u_int8_t rate11bOnly; /* for 11b sta */
+ u_int8_t pad2;
+};
+#endif /* _NET80211__IEEE80211_H_ */
diff --git a/package/network/services/hostapd/madwifi/net80211/ieee80211.h b/package/network/services/hostapd/madwifi/net80211/ieee80211.h
new file mode 100644
index 0000000..a39d4b9
--- /dev/null
+++ b/package/network/services/hostapd/madwifi/net80211/ieee80211.h
@@ -0,0 +1,997 @@
+/*-
+ * Copyright (c) 2001 Atsushi Onoe
+ * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $Id: ieee80211.h 3268 2008-01-26 20:48:11Z mtaylor $
+ */
+#ifndef _NET80211_IEEE80211_H_
+#define _NET80211_IEEE80211_H_
+
+/*
+ * 802.11 protocol definitions.
+ */
+
+#define IEEE80211_ADDR_LEN 6 /* size of 802.11 address */
+/* is 802.11 address multicast/broadcast? */
+#define IEEE80211_IS_MULTICAST(_a) (*(_a) & 0x01)
+
+/* IEEE 802.11 PLCP header */
+struct ieee80211_plcp_hdr {
+ u_int16_t i_sfd;
+ u_int8_t i_signal;
+ u_int8_t i_service;
+ u_int16_t i_length;
+ u_int16_t i_crc;
+} __packed;
+
+#define IEEE80211_PLCP_SFD 0xF3A0
+#define IEEE80211_PLCP_SERVICE 0x00
+
+/*
+ * generic definitions for IEEE 802.11 frames
+ */
+struct ieee80211_frame {
+ u_int8_t i_fc[2];
+ __le16 i_dur;
+ u_int8_t i_addr1[IEEE80211_ADDR_LEN];
+ u_int8_t i_addr2[IEEE80211_ADDR_LEN];
+ u_int8_t i_addr3[IEEE80211_ADDR_LEN];
+ u_int8_t i_seq[2];
+ /* possibly followed by addr4[IEEE80211_ADDR_LEN]; */
+ /* see below */
+} __packed;
+
+struct ieee80211_qosframe {
+ u_int8_t i_fc[2];
+ __le16 i_dur;
+ u_int8_t i_addr1[IEEE80211_ADDR_LEN];
+ u_int8_t i_addr2[IEEE80211_ADDR_LEN];
+ u_int8_t i_addr3[IEEE80211_ADDR_LEN];
+ u_int8_t i_seq[2];
+ u_int8_t i_qos[2];
+ /* possibly followed by addr4[IEEE80211_ADDR_LEN]; */
+ /* see below */
+} __packed;
+
+struct ieee80211_qoscntl {
+ u_int8_t i_qos[2];
+};
+
+struct ieee80211_frame_addr4 {
+ u_int8_t i_fc[2];
+ __le16 i_dur;
+ u_int8_t i_addr1[IEEE80211_ADDR_LEN];
+ u_int8_t i_addr2[IEEE80211_ADDR_LEN];
+ u_int8_t i_addr3[IEEE80211_ADDR_LEN];
+ u_int8_t i_seq[2];
+ u_int8_t i_addr4[IEEE80211_ADDR_LEN];
+} __packed;
+
+
+struct ieee80211_qosframe_addr4 {
+ u_int8_t i_fc[2];
+ __le16 i_dur;
+ u_int8_t i_addr1[IEEE80211_ADDR_LEN];
+ u_int8_t i_addr2[IEEE80211_ADDR_LEN];
+ u_int8_t i_addr3[IEEE80211_ADDR_LEN];
+ u_int8_t i_seq[2];
+ u_int8_t i_addr4[IEEE80211_ADDR_LEN];
+ u_int8_t i_qos[2];
+} __packed;
+
+struct ieee80211_ctlframe_addr2 {
+ u_int8_t i_fc[2];
+ __le16 i_aidordur; /* AID or duration */
+ u_int8_t i_addr1[IEEE80211_ADDR_LEN];
+ u_int8_t i_addr2[IEEE80211_ADDR_LEN];
+} __packed;
+
+#define IEEE80211_FC0_VERSION_MASK 0x03
+#define IEEE80211_FC0_VERSION_SHIFT 0
+#define IEEE80211_FC0_VERSION_0 0x00
+#define IEEE80211_FC0_TYPE_MASK 0x0c
+#define IEEE80211_FC0_TYPE_SHIFT 2
+#define IEEE80211_FC0_TYPE_MGT 0x00
+#define IEEE80211_FC0_TYPE_CTL 0x04
+#define IEEE80211_FC0_TYPE_DATA 0x08
+
+#define IEEE80211_FC0_SUBTYPE_MASK 0xf0
+#define IEEE80211_FC0_SUBTYPE_SHIFT 4
+/* for TYPE_MGT */
+#define IEEE80211_FC0_SUBTYPE_ASSOC_REQ 0x00
+#define IEEE80211_FC0_SUBTYPE_ASSOC_RESP 0x10
+#define IEEE80211_FC0_SUBTYPE_REASSOC_REQ 0x20
+#define IEEE80211_FC0_SUBTYPE_REASSOC_RESP 0x30
+#define IEEE80211_FC0_SUBTYPE_PROBE_REQ 0x40
+#define IEEE80211_FC0_SUBTYPE_PROBE_RESP 0x50
+#define IEEE80211_FC0_SUBTYPE_BEACON 0x80
+#define IEEE80211_FC0_SUBTYPE_ATIM 0x90
+#define IEEE80211_FC0_SUBTYPE_DISASSOC 0xa0
+#define IEEE80211_FC0_SUBTYPE_AUTH 0xb0
+#define IEEE80211_FC0_SUBTYPE_DEAUTH 0xc0
+#define IEEE80211_FC0_SUBTYPE_ACTION 0xd0
+/* for TYPE_CTL */
+#define IEEE80211_FC0_SUBTYPE_PS_POLL 0xa0
+#define IEEE80211_FC0_SUBTYPE_RTS 0xb0
+#define IEEE80211_FC0_SUBTYPE_CTS 0xc0
+#define IEEE80211_FC0_SUBTYPE_ACK 0xd0
+#define IEEE80211_FC0_SUBTYPE_CF_END 0xe0
+#define IEEE80211_FC0_SUBTYPE_CF_END_ACK 0xf0
+/* for TYPE_DATA (bit combination) */
+#define IEEE80211_FC0_SUBTYPE_DATA 0x00
+#define IEEE80211_FC0_SUBTYPE_CF_ACK 0x10
+#define IEEE80211_FC0_SUBTYPE_CF_POLL 0x20
+#define IEEE80211_FC0_SUBTYPE_CF_ACPL 0x30
+#define IEEE80211_FC0_SUBTYPE_NODATA 0x40
+#define IEEE80211_FC0_SUBTYPE_CFACK 0x50
+#define IEEE80211_FC0_SUBTYPE_CFPOLL 0x60
+#define IEEE80211_FC0_SUBTYPE_CF_ACK_CF_ACK 0x70
+#define IEEE80211_FC0_SUBTYPE_QOS 0x80
+#define IEEE80211_FC0_SUBTYPE_QOS_NULL 0xc0
+
+#define IEEE80211_FC1_DIR_MASK 0x03
+#define IEEE80211_FC1_DIR_NODS 0x00 /* STA->STA */
+#define IEEE80211_FC1_DIR_TODS 0x01 /* STA->AP */
+#define IEEE80211_FC1_DIR_FROMDS 0x02 /* AP ->STA */
+#define IEEE80211_FC1_DIR_DSTODS 0x03 /* AP ->AP */
+
+#define IEEE80211_FC1_MORE_FRAG 0x04
+#define IEEE80211_FC1_RETRY 0x08
+#define IEEE80211_FC1_PWR_MGT 0x10
+#define IEEE80211_FC1_MORE_DATA 0x20
+#define IEEE80211_FC1_PROT 0x40
+#define IEEE80211_FC1_ORDER 0x80
+
+#define IEEE80211_SEQ_FRAG_MASK 0x000f
+#define IEEE80211_SEQ_FRAG_SHIFT 0
+#define IEEE80211_SEQ_SEQ_MASK 0xfff0
+#define IEEE80211_SEQ_SEQ_SHIFT 4
+
+#define IEEE80211_NWID_LEN 32
+
+#define IEEE80211_QOS_TXOP 0x00ff
+/* bit 8 is reserved */
+#define IEEE80211_QOS_ACKPOLICY 0x60
+#define IEEE80211_QOS_ACKPOLICY_S 5
+#define IEEE80211_QOS_EOSP 0x10
+#define IEEE80211_QOS_EOSP_S 4
+#define IEEE80211_QOS_TID 0x0f
+
+#define IEEE80211_FRM_HAS_BODY(_wh) \
+ (((_wh)->i_fc[0] & IEEE80211_FC0_TYPE_MASK) != \
+ IEEE80211_FC0_TYPE_CTL)
+
+/*
+ * Country/Region Codes from MS WINNLS.H
+ * Numbering from ISO 3166
+ * XXX belongs elsewhere
+ */
+enum CountryCode {
+ CTRY_ALBANIA = 8, /* Albania */
+ CTRY_ALGERIA = 12, /* Algeria */
+ CTRY_ARGENTINA = 32, /* Argentina */
+ CTRY_ARMENIA = 51, /* Armenia */
+ CTRY_AUSTRALIA = 36, /* Australia */
+ CTRY_AUSTRIA = 40, /* Austria */
+ CTRY_AZERBAIJAN = 31, /* Azerbaijan */
+ CTRY_BAHRAIN = 48, /* Bahrain */
+ CTRY_BELARUS = 112, /* Belarus */
+ CTRY_BELGIUM = 56, /* Belgium */
+ CTRY_BELIZE = 84, /* Belize */
+ CTRY_BOLIVIA = 68, /* Bolivia */
+ CTRY_BRAZIL = 76, /* Brazil */
+ CTRY_BRUNEI_DARUSSALAM = 96, /* Brunei Darussalam */
+ CTRY_BULGARIA = 100, /* Bulgaria */
+ CTRY_CANADA = 124, /* Canada */
+ CTRY_CHILE = 152, /* Chile */
+ CTRY_CHINA = 156, /* People's Republic of China */
+ CTRY_COLOMBIA = 170, /* Colombia */
+ CTRY_COSTA_RICA = 188, /* Costa Rica */
+ CTRY_CROATIA = 191, /* Croatia */
+ CTRY_CYPRUS = 196,
+ CTRY_CZECH = 203, /* Czech Republic */
+ CTRY_DENMARK = 208, /* Denmark */
+ CTRY_DOMINICAN_REPUBLIC = 214, /* Dominican Republic */
+ CTRY_ECUADOR = 218, /* Ecuador */
+ CTRY_EGYPT = 818, /* Egypt */
+ CTRY_EL_SALVADOR = 222, /* El Salvador */
+ CTRY_ESTONIA = 233, /* Estonia */
+ CTRY_FAEROE_ISLANDS = 234, /* Faeroe Islands */
+ CTRY_FINLAND = 246, /* Finland */
+ CTRY_FRANCE = 250, /* France */
+ CTRY_FRANCE2 = 255, /* France2 */
+ CTRY_GEORGIA = 268, /* Georgia */
+ CTRY_GERMANY = 276, /* Germany */
+ CTRY_GREECE = 300, /* Greece */
+ CTRY_GUATEMALA = 320, /* Guatemala */
+ CTRY_HONDURAS = 340, /* Honduras */
+ CTRY_HONG_KONG = 344, /* Hong Kong S.A.R., P.R.C. */
+ CTRY_HUNGARY = 348, /* Hungary */
+ CTRY_ICELAND = 352, /* Iceland */
+ CTRY_INDIA = 356, /* India */
+ CTRY_INDONESIA = 360, /* Indonesia */
+ CTRY_IRAN = 364, /* Iran */
+ CTRY_IRAQ = 368, /* Iraq */
+ CTRY_IRELAND = 372, /* Ireland */
+ CTRY_ISRAEL = 376, /* Israel */
+ CTRY_ITALY = 380, /* Italy */
+ CTRY_JAMAICA = 388, /* Jamaica */
+ CTRY_JAPAN = 392, /* Japan */
+ CTRY_JAPAN1 = 393, /* Japan (JP1) */
+ CTRY_JAPAN2 = 394, /* Japan (JP0) */
+ CTRY_JAPAN3 = 395, /* Japan (JP1-1) */
+ CTRY_JAPAN4 = 396, /* Japan (JE1) */
+ CTRY_JAPAN5 = 397, /* Japan (JE2) */
+ CTRY_JAPAN6 = 399, /* Japan (JP6) */
+ CTRY_JAPAN7 = 900, /* Japan */
+ CTRY_JAPAN8 = 901, /* Japan */
+ CTRY_JAPAN9 = 902, /* Japan */
+ CTRY_JAPAN10 = 903, /* Japan */
+ CTRY_JAPAN11 = 904, /* Japan */
+ CTRY_JAPAN12 = 905, /* Japan */
+ CTRY_JAPAN13 = 906, /* Japan */
+ CTRY_JAPAN14 = 907, /* Japan */
+ CTRY_JAPAN15 = 908, /* Japan */
+ CTRY_JAPAN16 = 909, /* Japan */
+ CTRY_JAPAN17 = 910, /* Japan */
+ CTRY_JAPAN18 = 911, /* Japan */
+ CTRY_JAPAN19 = 912, /* Japan */
+ CTRY_JAPAN20 = 913, /* Japan */
+ CTRY_JAPAN21 = 914, /* Japan */
+ CTRY_JAPAN22 = 915, /* Japan */
+ CTRY_JAPAN23 = 916, /* Japan */
+ CTRY_JAPAN24 = 917, /* Japan */
+ CTRY_JAPAN25 = 918, /* Japan */
+ CTRY_JAPAN26 = 919, /* Japan */
+ CTRY_JAPAN27 = 920, /* Japan */
+ CTRY_JAPAN28 = 921, /* Japan */
+ CTRY_JAPAN29 = 922, /* Japan */
+ CTRY_JAPAN30 = 923, /* Japan */
+ CTRY_JAPAN31 = 924, /* Japan */
+ CTRY_JAPAN32 = 925, /* Japan */
+ CTRY_JAPAN33 = 926, /* Japan */
+ CTRY_JAPAN34 = 927, /* Japan */
+ CTRY_JAPAN35 = 928, /* Japan */
+ CTRY_JAPAN36 = 929, /* Japan */
+ CTRY_JAPAN37 = 930, /* Japan */
+ CTRY_JAPAN38 = 931, /* Japan */
+ CTRY_JAPAN39 = 932, /* Japan */
+ CTRY_JAPAN40 = 933, /* Japan */
+ CTRY_JAPAN41 = 934, /* Japan */
+ CTRY_JAPAN42 = 935, /* Japan */
+ CTRY_JAPAN43 = 936, /* Japan */
+ CTRY_JAPAN44 = 937, /* Japan */
+ CTRY_JAPAN45 = 938, /* Japan */
+ CTRY_JAPAN46 = 939, /* Japan */
+ CTRY_JAPAN47 = 940, /* Japan */
+ CTRY_JAPAN48 = 941, /* Japan */
+ CTRY_JORDAN = 400, /* Jordan */
+ CTRY_KAZAKHSTAN = 398, /* Kazakhstan */
+ CTRY_KENYA = 404, /* Kenya */
+ CTRY_KOREA_NORTH = 408, /* North Korea */
+ CTRY_KOREA_ROC = 410, /* South Korea */
+ CTRY_KOREA_ROC2 = 411, /* South Korea */
+ CTRY_KUWAIT = 414, /* Kuwait */
+ CTRY_LATVIA = 428, /* Latvia */
+ CTRY_LEBANON = 422, /* Lebanon */
+ CTRY_LIBYA = 434, /* Libya */
+ CTRY_LIECHTENSTEIN = 438, /* Liechtenstein */
+ CTRY_LITHUANIA = 440, /* Lithuania */
+ CTRY_LUXEMBOURG = 442, /* Luxembourg */
+ CTRY_MACAU = 446, /* Macau */
+ CTRY_MACEDONIA = 807, /* the Former Yugoslav Republic of Macedonia */
+ CTRY_MALAYSIA = 458, /* Malaysia */
+ CTRY_MEXICO = 484, /* Mexico */
+ CTRY_MONACO = 492, /* Principality of Monaco */
+ CTRY_MOROCCO = 504, /* Morocco */
+ CTRY_NETHERLANDS = 528, /* Netherlands */
+ CTRY_NEW_ZEALAND = 554, /* New Zealand */
+ CTRY_NICARAGUA = 558, /* Nicaragua */
+ CTRY_NORWAY = 578, /* Norway */
+ CTRY_OMAN = 512, /* Oman */
+ CTRY_PAKISTAN = 586, /* Islamic Republic of Pakistan */
+ CTRY_PANAMA = 591, /* Panama */
+ CTRY_PARAGUAY = 600, /* Paraguay */
+ CTRY_PERU = 604, /* Peru */
+ CTRY_PHILIPPINES = 608, /* Republic of the Philippines */
+ CTRY_POLAND = 616, /* Poland */
+ CTRY_PORTUGAL = 620, /* Portugal */
+ CTRY_PUERTO_RICO = 630, /* Puerto Rico */
+ CTRY_QATAR = 634, /* Qatar */
+ CTRY_ROMANIA = 642, /* Romania */
+ CTRY_RUSSIA = 643, /* Russia */
+ CTRY_SAUDI_ARABIA = 682, /* Saudi Arabia */
+ CTRY_SINGAPORE = 702, /* Singapore */
+ CTRY_SLOVAKIA = 703, /* Slovak Republic */
+ CTRY_SLOVENIA = 705, /* Slovenia */
+ CTRY_SOUTH_AFRICA = 710, /* South Africa */
+ CTRY_SPAIN = 724, /* Spain */
+ CTRY_SWEDEN = 752, /* Sweden */
+ CTRY_SWITZERLAND = 756, /* Switzerland */
+ CTRY_SYRIA = 760, /* Syria */
+ CTRY_TAIWAN = 158, /* Taiwan */
+ CTRY_THAILAND = 764, /* Thailand */
+ CTRY_TRINIDAD_Y_TOBAGO = 780, /* Trinidad y Tobago */
+ CTRY_TUNISIA = 788, /* Tunisia */
+ CTRY_TURKEY = 792, /* Turkey */
+ CTRY_UAE = 784, /* U.A.E. */
+ CTRY_UKRAINE = 804, /* Ukraine */
+ CTRY_UNITED_KINGDOM = 826, /* United Kingdom */
+ CTRY_UNITED_STATES = 840, /* United States */
+ CTRY_UNITED_STATES_FCC49 = 842, /* United States (Public Safety)*/
+ CTRY_URUGUAY = 858, /* Uruguay */
+ CTRY_UZBEKISTAN = 860, /* Uzbekistan */
+ CTRY_VENEZUELA = 862, /* Venezuela */
+ CTRY_VIET_NAM = 704, /* Viet Nam */
+ CTRY_YEMEN = 887, /* Yemen */
+ CTRY_ZIMBABWE = 716 /* Zimbabwe */
+};
+
+/*
+ * Generic information element
+ */
+struct ieee80211_ie {
+ u_int8_t id;
+ u_int8_t len;
+ u_int8_t info[0];
+} __packed;
+
+/*
+ * Country information element.
+ */
+#define IEEE80211_COUNTRY_MAX_TRIPLETS (83)
+struct ieee80211_ie_country {
+ u_int8_t country_id;
+ u_int8_t country_len;
+ u_int8_t country_str[3];
+ u_int8_t country_triplet[IEEE80211_COUNTRY_MAX_TRIPLETS * 3];
+} __packed;
+
+/*
+ * Power Constraint information element.
+ */
+struct ieee80211_ie_pwrcnstr {
+ u_int8_t pc_id; /* IEEE80211_ELEMID_PWRCNSTR */
+ u_int8_t pc_len; /* == 2 */
+ u_int8_t pc_lpc; /* Local Power Constraint [dB] */
+} __packed;
+
+/*
+ * Power Capability information element.
+ */
+struct ieee80211_ie_pwrcap {
+ u_int8_t pc_id; /* IEEE80211_ELEMID_PWRCAP */
+ u_int8_t pc_len; /* == 2 */
+ int8_t pc_mintxpow; /* Minimum Transmit Power Capability [dBm] */
+ int8_t pc_maxtxpow; /* Maximum Transmit Power Capability [dBm] */
+} __packed;
+
+/*
+ * Supported Channels information element.
+ */
+#define IEEE80211_SUPPCHAN_MAX_PAIRS (127)
+struct ieee80211_ie_sc {
+ u_int8_t sc_id; /* IEEE80211_ELEMID_SUPPCHAN */
+ u_int8_t sc_len; /* == 2 * number of sc_subband elements */
+ struct {
+ u_int8_t sc_first; /* First Channel Number */
+ u_int8_t sc_number; /* Number of Channels */
+ } __packed sc_subband[IEEE80211_SUPPCHAN_MAX_PAIRS];
+} __packed;
+
+/*
+ * Channel Switch Announcement information element.
+ */
+struct ieee80211_ie_csa {
+ u_int8_t csa_id; /* IEEE80211_ELEMID_CHANSWITCHANN */
+ u_int8_t csa_len; /* == 3 */
+ u_int8_t csa_mode; /* Channel Switch Mode: 1 == stop transmission until CS */
+ u_int8_t csa_chan; /* New Channel Number */
+ u_int8_t csa_count; /* TBTTs until Channel Switch happens */
+} __packed;
+
+/* minimal Channel Switch Count in the initial announcement */
+#define IEEE80211_CSA_PROTECTION_PERIOD 3
+
+/* maximum allowed deviance of measurement of intervals between CSA in Beacons */
+#define IEEE80211_CSA_SANITY_THRESHOLD 100
+
+
+/* does frame have QoS sequence control data */
+#define IEEE80211_QOS_HAS_SEQ(wh) \
+ (((wh)->i_fc[0] & \
+ (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_QOS)) == \
+ (IEEE80211_FC0_TYPE_DATA | IEEE80211_FC0_SUBTYPE_QOS))
+
+#define WME_QOSINFO_COUNT 0x0f /* Mask for Param Set Count field */
+/*
+ * WME/802.11e information element.
+ */
+struct ieee80211_ie_wme {
+ u_int8_t wme_id; /* IEEE80211_ELEMID_VENDOR */
+ u_int8_t wme_len; /* length in bytes */
+ u_int8_t wme_oui[3]; /* 0x00, 0x50, 0xf2 */
+ u_int8_t wme_type; /* OUI type */
+ u_int8_t wme_subtype; /* OUI subtype */
+ u_int8_t wme_version; /* spec revision */
+ u_int8_t wme_info; /* QoS info */
+} __packed;
+
+/*
+ * WME/802.11e Tspec Element
+ */
+struct ieee80211_wme_tspec {
+ u_int8_t ts_id;
+ u_int8_t ts_len;
+ u_int8_t ts_oui[3];
+ u_int8_t ts_oui_type;
+ u_int8_t ts_oui_subtype;
+ u_int8_t ts_version;
+ u_int8_t ts_tsinfo[3];
+ u_int8_t ts_nom_msdu[2];
+ u_int8_t ts_max_msdu[2];
+ u_int8_t ts_min_svc[4];
+ u_int8_t ts_max_svc[4];
+ u_int8_t ts_inactv_intv[4];
+ u_int8_t ts_susp_intv[4];
+ u_int8_t ts_start_svc[4];
+ u_int8_t ts_min_rate[4];
+ u_int8_t ts_mean_rate[4];
+ u_int8_t ts_max_burst[4];
+ u_int8_t ts_min_phy[4];
+ u_int8_t ts_peak_rate[4];
+ u_int8_t ts_delay[4];
+ u_int8_t ts_surplus[2];
+ u_int8_t ts_medium_time[2];
+} __packed;
+
+/*
+ * WME AC parameter field
+ */
+
+struct ieee80211_wme_acparams {
+ u_int8_t acp_aci_aifsn;
+ u_int8_t acp_logcwminmax;
+ u_int16_t acp_txop;
+} __packed;
+
+#define IEEE80211_WME_PARAM_LEN 24
+#define WME_NUM_AC 4 /* 4 AC categories */
+
+#define WME_PARAM_ACI 0x60 /* Mask for ACI field */
+#define WME_PARAM_ACI_S 5 /* Shift for ACI field */
+#define WME_PARAM_ACM 0x10 /* Mask for ACM bit */
+#define WME_PARAM_ACM_S 4 /* Shift for ACM bit */
+#define WME_PARAM_AIFSN 0x0f /* Mask for aifsn field */
+#define WME_PARAM_AIFSN_S 0 /* Shift for aifsn field */
+#define WME_PARAM_LOGCWMIN 0x0f /* Mask for CwMin field (in log) */
+#define WME_PARAM_LOGCWMIN_S 0 /* Shift for CwMin field */
+#define WME_PARAM_LOGCWMAX 0xf0 /* Mask for CwMax field (in log) */
+#define WME_PARAM_LOGCWMAX_S 4 /* Shift for CwMax field */
+
+#define WME_AC_TO_TID(_ac) ( \
+ ((_ac) == WME_AC_VO) ? 6 : \
+ ((_ac) == WME_AC_VI) ? 5 : \
+ ((_ac) == WME_AC_BK) ? 1 : \
+ 0)
+
+#define TID_TO_WME_AC(_tid) ( \
+ ((_tid) < 1) ? WME_AC_BE : \
+ ((_tid) < 3) ? WME_AC_BK : \
+ ((_tid) < 6) ? WME_AC_VI : \
+ WME_AC_VO)
+
+/*
+ * WME Parameter Element
+ */
+
+struct ieee80211_wme_param {
+ u_int8_t param_id;
+ u_int8_t param_len;
+ u_int8_t param_oui[3];
+ u_int8_t param_oui_type;
+ u_int8_t param_oui_sybtype;
+ u_int8_t param_version;
+ u_int8_t param_qosInfo;
+ u_int8_t param_reserved;
+ struct ieee80211_wme_acparams params_acParams[WME_NUM_AC];
+} __packed;
+
+/*
+ * WME U-APSD qos info field defines
+ */
+#define WME_CAPINFO_UAPSD_EN 0x00000080
+#define WME_CAPINFO_UAPSD_VO 0x00000001
+#define WME_CAPINFO_UAPSD_VI 0x00000002
+#define WME_CAPINFO_UAPSD_BK 0x00000004
+#define WME_CAPINFO_UAPSD_BE 0x00000008
+#define WME_CAPINFO_UAPSD_ACFLAGS_SHIFT 0
+#define WME_CAPINFO_UAPSD_ACFLAGS_MASK 0xF
+#define WME_CAPINFO_UAPSD_MAXSP_SHIFT 5
+#define WME_CAPINFO_UAPSD_MAXSP_MASK 0x3
+#define WME_CAPINFO_IE_OFFSET 8
+#define WME_UAPSD_MAXSP(_qosinfo) \
+ (((_qosinfo) >> WME_CAPINFO_UAPSD_MAXSP_SHIFT) & \
+ WME_CAPINFO_UAPSD_MAXSP_MASK)
+#define WME_UAPSD_AC_ENABLED(_ac, _qosinfo) \
+ ((1 << (3 - (_ac))) & ( \
+ ((_qosinfo) >> WME_CAPINFO_UAPSD_ACFLAGS_SHIFT) & \
+ WME_CAPINFO_UAPSD_ACFLAGS_MASK))
+
+/*
+ * Atheros Advanced Capability information element.
+ */
+struct ieee80211_ie_athAdvCap {
+ u_int8_t athAdvCap_id; /* IEEE80211_ELEMID_VENDOR */
+ u_int8_t athAdvCap_len; /* length in bytes */
+ u_int8_t athAdvCap_oui[3]; /* 0x00, 0x03, 0x7f */
+ u_int8_t athAdvCap_type; /* OUI type */
+ u_int8_t athAdvCap_subtype; /* OUI subtype */
+ u_int8_t athAdvCap_version; /* spec revision */
+ u_int8_t athAdvCap_capability; /* Capability info */
+ u_int16_t athAdvCap_defKeyIndex;
+} __packed;
+
+/*
+ * Atheros XR information element.
+ */
+struct ieee80211_xr_param {
+ u_int8_t param_id;
+ u_int8_t param_len;
+ u_int8_t param_oui[3];
+ u_int8_t param_oui_type;
+ u_int8_t param_oui_sybtype;
+ u_int8_t param_version;
+ u_int8_t param_Info;
+ u_int8_t param_base_bssid[IEEE80211_ADDR_LEN];
+ u_int8_t param_xr_bssid[IEEE80211_ADDR_LEN];
+ u_int16_t param_xr_beacon_interval;
+ u_int8_t param_base_ath_capability;
+ u_int8_t param_xr_ath_capability;
+} __packed;
+
+/* Atheros capabilities */
+#define IEEE80211_ATHC_TURBOP 0x0001 /* Turbo Prime */
+#define IEEE80211_ATHC_COMP 0x0002 /* Compression */
+#define IEEE80211_ATHC_FF 0x0004 /* Fast Frames */
+#define IEEE80211_ATHC_XR 0x0008 /* Xtended Range support */
+#define IEEE80211_ATHC_AR 0x0010 /* Advanced Radar support */
+#define IEEE80211_ATHC_BURST 0x0020 /* Bursting - not negotiated */
+#define IEEE80211_ATHC_WME 0x0040 /* CWMin tuning */
+#define IEEE80211_ATHC_BOOST 0x0080 /* Boost */
+
+/*
+ * Management Notification Frame
+ */
+struct ieee80211_mnf {
+ u_int8_t mnf_category;
+ u_int8_t mnf_action;
+ u_int8_t mnf_dialog;
+ u_int8_t mnf_status;
+} __packed;
+#define MNF_SETUP_REQ 0
+#define MNF_SETUP_RESP 1
+#define MNF_TEARDOWN 2
+
+/*
+ * Control frames.
+ */
+struct ieee80211_frame_min {
+ u_int8_t i_fc[2];
+ __le16 i_dur;
+ u_int8_t i_addr1[IEEE80211_ADDR_LEN];
+ u_int8_t i_addr2[IEEE80211_ADDR_LEN];
+ /* FCS */
+} __packed;
+
+struct ieee80211_frame_rts {
+ u_int8_t i_fc[2];
+ __le16 i_dur;
+ u_int8_t i_ra[IEEE80211_ADDR_LEN];
+ u_int8_t i_ta[IEEE80211_ADDR_LEN];
+ /* FCS */
+} __packed;
+
+struct ieee80211_frame_cts {
+ u_int8_t i_fc[2];
+ __le16 i_dur;
+ u_int8_t i_ra[IEEE80211_ADDR_LEN];
+ /* FCS */
+} __packed;
+
+struct ieee80211_frame_ack {
+ u_int8_t i_fc[2];
+ __le16 i_dur;
+ u_int8_t i_ra[IEEE80211_ADDR_LEN];
+ /* FCS */
+} __packed;
+
+struct ieee80211_frame_pspoll {
+ u_int8_t i_fc[2];
+ u_int8_t i_aid[2];
+ u_int8_t i_bssid[IEEE80211_ADDR_LEN];
+ u_int8_t i_ta[IEEE80211_ADDR_LEN];
+ /* FCS */
+} __packed;
+
+struct ieee80211_frame_cfend { /* NB: also CF-End+CF-Ack */
+ u_int8_t i_fc[2];
+ __le16 i_dur; /* should be zero */
+ u_int8_t i_ra[IEEE80211_ADDR_LEN];
+ u_int8_t i_bssid[IEEE80211_ADDR_LEN];
+ /* FCS */
+} __packed;
+
+/*
+ * BEACON management packets
+ *
+ * octet timestamp[8]
+ * octet beacon interval[2]
+ * octet capability information[2]
+ * information element
+ * octet elemid
+ * octet length
+ * octet information[length]
+ */
+
+typedef u_int8_t *ieee80211_mgt_beacon_t;
+
+#define IEEE80211_BEACON_INTERVAL(beacon) \
+ ((beacon)[8] | ((beacon)[9] << 8))
+#define IEEE80211_BEACON_CAPABILITY(beacon) \
+ ((beacon)[10] | ((beacon)[11] << 8))
+
+#define IEEE80211_CAPINFO_ESS 0x0001
+#define IEEE80211_CAPINFO_IBSS 0x0002
+#define IEEE80211_CAPINFO_CF_POLLABLE 0x0004
+#define IEEE80211_CAPINFO_CF_POLLREQ 0x0008
+#define IEEE80211_CAPINFO_PRIVACY 0x0010
+#define IEEE80211_CAPINFO_SHORT_PREAMBLE 0x0020
+#define IEEE80211_CAPINFO_PBCC 0x0040
+#define IEEE80211_CAPINFO_CHNL_AGILITY 0x0080
+/* bits 8-9 are reserved (8 now for spectrum management) */
+#define IEEE80211_CAPINFO_SPECTRUM_MGMT 0x0100
+#define IEEE80211_CAPINFO_SHORT_SLOTTIME 0x0400
+#define IEEE80211_CAPINFO_RSN 0x0800
+/* bit 12 is reserved */
+#define IEEE80211_CAPINFO_DSSSOFDM 0x2000
+/* bits 14-15 are reserved */
+
+/*
+ * 802.11i/WPA information element (maximally sized).
+ */
+struct ieee80211_ie_wpa {
+ u_int8_t wpa_id; /* IEEE80211_ELEMID_VENDOR */
+ u_int8_t wpa_len; /* length in bytes */
+ u_int8_t wpa_oui[3]; /* 0x00, 0x50, 0xf2 */
+ u_int8_t wpa_type; /* OUI type */
+ u_int16_t wpa_version; /* spec revision */
+ u_int32_t wpa_mcipher[1]; /* multicast/group key cipher */
+ u_int16_t wpa_uciphercnt; /* # pairwise key ciphers */
+ u_int32_t wpa_uciphers[8]; /* ciphers */
+ u_int16_t wpa_authselcnt; /* authentication selector cnt*/
+ u_int32_t wpa_authsels[8]; /* selectors */
+ u_int16_t wpa_caps; /* 802.11i capabilities */
+ u_int16_t wpa_pmkidcnt; /* 802.11i pmkid count */
+ u_int16_t wpa_pmkids[8]; /* 802.11i pmkids */
+} __packed;
+
+/*
+ * Management information element payloads.
+ */
+
+enum {
+ IEEE80211_ELEMID_SSID = 0,
+ IEEE80211_ELEMID_RATES = 1,
+ IEEE80211_ELEMID_FHPARMS = 2,
+ IEEE80211_ELEMID_DSPARMS = 3,
+ IEEE80211_ELEMID_CFPARMS = 4,
+ IEEE80211_ELEMID_TIM = 5,
+ IEEE80211_ELEMID_IBSSPARMS = 6,
+ IEEE80211_ELEMID_COUNTRY = 7,
+ IEEE80211_ELEMID_HOPPATRNPARMS = 8,
+ IEEE80211_ELEMID_HOPPATRNTABLE = 9,
+ IEEE80211_ELEMID_REQINFO = 10,
+ IEEE80211_ELEMID_QBSSLOAD = 11,
+ IEEE80211_ELEMID_EDCAPARAM = 12,
+ IEEE80211_ELEMID_TSPEC = 13,
+ IEEE80211_ELEMID_TRAFCLASS = 14,
+ IEEE80211_ELEMID_SCHEDULE = 15,
+ IEEE80211_ELEMID_CHALLENGE = 16,
+ /* 17-31 reserved for challenge text extension */
+ IEEE80211_ELEMID_PWRCNSTR = 32,
+ IEEE80211_ELEMID_PWRCAP = 33,
+ IEEE80211_ELEMID_TPCREQ = 34,
+ IEEE80211_ELEMID_TPCREP = 35,
+ IEEE80211_ELEMID_SUPPCHAN = 36,
+ IEEE80211_ELEMID_CHANSWITCHANN = 37,
+ IEEE80211_ELEMID_MEASREQ = 38,
+ IEEE80211_ELEMID_MEASREP = 39,
+ IEEE80211_ELEMID_QUIET = 40,
+ IEEE80211_ELEMID_IBSSDFS = 41,
+ IEEE80211_ELEMID_ERP = 42,
+ IEEE80211_ELEMID_TSDELAY = 43,
+ IEEE80211_ELEMID_TCLASSPROC = 44,
+ IEEE80211_ELEMID_QOS = 46,
+ IEEE80211_ELEMID_RSN = 48,
+ /* 49 reserved */
+ IEEE80211_ELEMID_XRATES = 50,
+ /* 128-129 proprietary elements used by Agere chipsets */
+ IEEE80211_ELEMID_AGERE1 = 128,
+ IEEE80211_ELEMID_AGERE2 = 129,
+ IEEE80211_ELEMID_TPC = 150,
+ IEEE80211_ELEMID_CCKM = 156,
+ IEEE80211_ELEMID_VENDOR = 221, /* vendor private */
+};
+
+#define IEEE80211_CHANSWITCHANN_BYTES 5
+#define BITCTL_BUFD_MCAST 1
+#define BITCTL_BUFD_UCAST_AID_MASK ((u_int8_t)~(BITCTL_BUFD_MCAST))
+#define BITCTL_BUFD_UCAST_AID_SHIFT 1
+
+struct ieee80211_tim_ie {
+ u_int8_t tim_ie; /* IEEE80211_ELEMID_TIM */
+ u_int8_t tim_len;
+ u_int8_t tim_count; /* DTIM count */
+ u_int8_t tim_period; /* DTIM period */
+ u_int8_t tim_bitctl; /* bitmap control */
+ u_int8_t tim_bitmap[1]; /* variable-length bitmap */
+} __packed;
+
+struct ieee80211_country_ie {
+ u_int8_t ie; /* IEEE80211_ELEMID_COUNTRY */
+ u_int8_t len;
+ u_int8_t cc[3]; /* ISO CC+(I)ndoor/(O)utdoor */
+ struct {
+ u_int8_t schan; /* starting channel */
+ u_int8_t nchan; /* number channels */
+ u_int8_t maxtxpwr; /* tx power cap */
+ } __packed band[4]; /* up to 4 sub bands */
+} __packed;
+
+#define IEEE80211_CHALLENGE_LEN 128
+
+#define IEEE80211_SUPPCHAN_LEN 26
+
+#define IEEE80211_RATE_BASIC 0x80
+#define IEEE80211_RATE_VAL 0x7f
+
+/* EPR information element flags */
+#define IEEE80211_ERP_NON_ERP_PRESENT 0x01
+#define IEEE80211_ERP_USE_PROTECTION 0x02
+#define IEEE80211_ERP_LONG_PREAMBLE 0x04
+
+/* Atheros private advanced capabilities info */
+#define ATHEROS_CAP_TURBO_PRIME 0x01
+#define ATHEROS_CAP_COMPRESSION 0x02
+#define ATHEROS_CAP_FAST_FRAME 0x04
+/* bits 3-6 reserved */
+#define ATHEROS_CAP_BOOST 0x80
+
+#define ATH_OUI 0x7f0300 /* Atheros OUI */
+#define ATH_OUI_TYPE 0x01
+#define ATH_OUI_SUBTYPE 0x01
+#define ATH_OUI_VERSION 0x00
+#define ATH_OUI_TYPE_XR 0x03
+#define ATH_OUI_SUBTYPE_XR 0x01
+#define ATH_OUI_VER_XR 0x00
+
+#define WPA_OUI 0xf25000
+#define WPA_OUI_TYPE 0x01
+#define WPA_VERSION 1 /* current supported version */
+
+#define WPA_CSE_NULL 0x00
+#define WPA_CSE_WEP40 0x01
+#define WPA_CSE_TKIP 0x02
+#define WPA_CSE_CCMP 0x04
+#define WPA_CSE_WEP104 0x05
+
+#define WPA_ASE_NONE 0x00
+#define WPA_ASE_8021X_UNSPEC 0x01
+#define WPA_ASE_8021X_PSK 0x02
+
+#define RSN_OUI 0xac0f00
+#define RSN_VERSION 1 /* current supported version */
+
+#define RSN_CSE_NULL 0x00
+#define RSN_CSE_WEP40 0x01
+#define RSN_CSE_TKIP 0x02
+#define RSN_CSE_WRAP 0x03
+#define RSN_CSE_CCMP 0x04
+#define RSN_CSE_WEP104 0x05
+
+#define RSN_ASE_NONE 0x00
+#define RSN_ASE_8021X_UNSPEC 0x01
+#define RSN_ASE_8021X_PSK 0x02
+
+#define RSN_CAP_PREAUTH 0x01
+
+#define WME_OUI 0xf25000
+#define WME_OUI_TYPE 0x02
+#define WME_INFO_OUI_SUBTYPE 0x00
+#define WME_PARAM_OUI_SUBTYPE 0x01
+#define WME_VERSION 1
+
+/* WME stream classes */
+#define WME_AC_BE 0 /* best effort */
+#define WME_AC_BK 1 /* background */
+#define WME_AC_VI 2 /* video */
+#define WME_AC_VO 3 /* voice */
+
+/*
+ * AUTH management packets
+ *
+ * octet algo[2]
+ * octet seq[2]
+ * octet status[2]
+ * octet chal.id
+ * octet chal.length
+ * octet chal.text[253]
+ */
+
+typedef u_int8_t *ieee80211_mgt_auth_t;
+
+#define IEEE80211_AUTH_ALGORITHM(auth) \
+ ((auth)[0] | ((auth)[1] << 8))
+#define IEEE80211_AUTH_TRANSACTION(auth) \
+ ((auth)[2] | ((auth)[3] << 8))
+#define IEEE80211_AUTH_STATUS(auth) \
+ ((auth)[4] | ((auth)[5] << 8))
+
+#define IEEE80211_AUTH_ALG_OPEN 0x0000
+#define IEEE80211_AUTH_ALG_SHARED 0x0001
+#define IEEE80211_AUTH_ALG_LEAP 0x0080
+
+enum {
+ IEEE80211_AUTH_OPEN_REQUEST = 1,
+ IEEE80211_AUTH_OPEN_RESPONSE = 2,
+};
+
+enum {
+ IEEE80211_AUTH_SHARED_REQUEST = 1,
+ IEEE80211_AUTH_SHARED_CHALLENGE = 2,
+ IEEE80211_AUTH_SHARED_RESPONSE = 3,
+ IEEE80211_AUTH_SHARED_PASS = 4,
+};
+
+/*
+ * Reason codes
+ *
+ * Unlisted codes are reserved
+ */
+
+enum {
+ IEEE80211_REASON_UNSPECIFIED = 1,
+ IEEE80211_REASON_AUTH_EXPIRE = 2,
+ IEEE80211_REASON_AUTH_LEAVE = 3,
+ IEEE80211_REASON_ASSOC_EXPIRE = 4,
+ IEEE80211_REASON_ASSOC_TOOMANY = 5,
+ IEEE80211_REASON_NOT_AUTHED = 6,
+ IEEE80211_REASON_NOT_ASSOCED = 7,
+ IEEE80211_REASON_ASSOC_LEAVE = 8,
+ IEEE80211_REASON_ASSOC_NOT_AUTHED = 9,
+
+ IEEE80211_REASON_PWRCAP_UNACCEPTABLE = 10,
+ IEEE80211_REASON_SUPPCHAN_UNACCEPTABLE = 11,
+ IEEE80211_REASON_RSN_REQUIRED = 11,
+ IEEE80211_REASON_RSN_INCONSISTENT = 12,
+ IEEE80211_REASON_IE_INVALID = 13,
+ IEEE80211_REASON_MIC_FAILURE = 14,
+
+ IEEE80211_STATUS_SUCCESS = 0,
+ IEEE80211_STATUS_UNSPECIFIED = 1,
+ IEEE80211_STATUS_CAPINFO = 10,
+ IEEE80211_STATUS_NOT_ASSOCED = 11,
+ IEEE80211_STATUS_OTHER = 12,
+ IEEE80211_STATUS_ALG = 13,
+ IEEE80211_STATUS_SEQUENCE = 14,
+ IEEE80211_STATUS_CHALLENGE = 15,
+ IEEE80211_STATUS_TIMEOUT = 16,
+ IEEE80211_STATUS_TOOMANY = 17,
+ IEEE80211_STATUS_BASIC_RATE = 18,
+ IEEE80211_STATUS_SP_REQUIRED = 19,
+ IEEE80211_STATUS_PBCC_REQUIRED = 20,
+ IEEE80211_STATUS_CA_REQUIRED = 21,
+ IEEE80211_STATUS_SM_REQUIRED = 22,
+ IEEE80211_STATUS_PWRCAP_UNACCEPTABLE = 23,
+ IEEE80211_STATUS_SUPPCHAN_UNACCEPTABLE = 24,
+ IEEE80211_STATUS_TOO_MANY_STATIONS = 22,
+ IEEE80211_STATUS_RATES = 23,
+ IEEE80211_STATUS_SHORTSLOT_REQUIRED = 25,
+ IEEE80211_STATUS_DSSSOFDM_REQUIRED = 26,
+};
+
+#define IEEE80211_WEP_KEYLEN 5 /* 40bit */
+#define IEEE80211_WEP_IVLEN 3 /* 24bit */
+#define IEEE80211_WEP_KIDLEN 1 /* 1 octet */
+#define IEEE80211_WEP_CRCLEN 4 /* CRC-32 */
+#define IEEE80211_WEP_NKID 4 /* number of key ids */
+
+/*
+ * 802.11i defines an extended IV for use with non-WEP ciphers.
+ * When the EXTIV bit is set in the key id byte an additional
+ * 4 bytes immediately follow the IV for TKIP. For CCMP the
+ * EXTIV bit is likewise set but the 8 bytes represent the
+ * CCMP header rather than IV+extended-IV.
+ */
+#define IEEE80211_WEP_EXTIV 0x20
+#define IEEE80211_WEP_EXTIVLEN 4 /* extended IV length */
+#define IEEE80211_WEP_MICLEN 8 /* trailing MIC */
+
+#define IEEE80211_CRC_LEN 4
+
+/*
+ * Maximum acceptable MTU is:
+ * IEEE80211_MAX_LEN - WEP overhead - CRC -
+ * QoS overhead - RSN/WPA overhead
+ * Min is arbitrarily chosen > IEEE80211_MIN_LEN. The default
+ * mtu is Ethernet-compatible; it's set by ether_ifattach.
+ */
+#define IEEE80211_MTU_MAX 2290
+#define IEEE80211_MTU_MIN 32
+
+#define IEEE80211_MAX_LEN (2300 + IEEE80211_CRC_LEN + \
+ (IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN + IEEE80211_WEP_CRCLEN))
+#define IEEE80211_ACK_LEN \
+ (sizeof(struct ieee80211_frame_ack) + IEEE80211_CRC_LEN)
+#define IEEE80211_MIN_LEN \
+ (sizeof(struct ieee80211_frame_min) + IEEE80211_CRC_LEN)
+
+/*
+ * The 802.11 spec says at most 2007 stations may be
+ * associated at once. For most APs this is way more
+ * than is feasible so we use a default of 128. This
+ * number may be overridden by the driver and/or by
+ * user configuration.
+ */
+#define IEEE80211_AID_MAX 2007
+#define IEEE80211_AID_DEF 128
+
+#define IEEE80211_AID(b) ((b) &~ 0xc000)
+
+/*
+ * RTS frame length parameters. The default is specified in
+ * the 802.11 spec. The max may be wrong for jumbo frames.
+ */
+#define IEEE80211_RTS_DEFAULT 512
+#define IEEE80211_RTS_MIN 1
+#define IEEE80211_RTS_MAX 2346
+
+/*
+ * Regulatory extension identifier for country IE.
+ */
+#define IEEE80211_REG_EXT_ID 201
+
+/*
+ * IEEE 802.11 timer synchronization function (TSF) timestamp length
+ */
+#define IEEE80211_TSF_LEN 8
+
+#endif /* _NET80211_IEEE80211_H_ */
diff --git a/package/network/services/hostapd/madwifi/net80211/ieee80211_crypto.h b/package/network/services/hostapd/madwifi/net80211/ieee80211_crypto.h
new file mode 100644
index 0000000..b34f359
--- /dev/null
+++ b/package/network/services/hostapd/madwifi/net80211/ieee80211_crypto.h
@@ -0,0 +1,207 @@
+/*-
+ * Copyright (c) 2001 Atsushi Onoe
+ * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $Id: ieee80211_crypto.h 3068 2007-12-21 17:46:02Z mentor $
+ */
+#ifndef _NET80211_IEEE80211_CRYPTO_H_
+#define _NET80211_IEEE80211_CRYPTO_H_
+
+/*
+ * 802.11 protocol crypto-related definitions.
+ */
+#define IEEE80211_KEYBUF_SIZE 16
+#define IEEE80211_MICBUF_SIZE (8 + 8) /* space for both TX & RX keys */
+#define IEEE80211_TID_SIZE 17 /* total number of TIDs */
+
+/*
+ * Old WEP-style key. Deprecated.
+ */
+struct ieee80211_wepkey {
+ u_int wk_len; /* key length in bytes */
+ u_int8_t wk_key[IEEE80211_KEYBUF_SIZE];
+};
+
+struct ieee80211_cipher;
+
+/*
+ * Crypto key state. There is sufficient room for all supported
+ * ciphers (see below). The underlying ciphers are handled
+ * separately through loadable cipher modules that register with
+ * the generic crypto support. A key has a reference to an instance
+ * of the cipher; any per-key state is hung off wk_private by the
+ * cipher when it is attached. Ciphers are automatically called
+ * to detach and cleanup any such state when the key is deleted.
+ *
+ * The generic crypto support handles encap/decap of cipher-related
+ * frame contents for both hardware- and software-based implementations.
+ * A key requiring software crypto support is automatically flagged and
+ * the cipher is expected to honor this and do the necessary work.
+ * Ciphers such as TKIP may also support mixed hardware/software
+ * encrypt/decrypt and MIC processing.
+ */
+
+typedef u_int16_t ieee80211_keyix_t;
+
+/* XXX pack better? */
+/* XXX 48-bit rsc/tsc */
+struct ieee80211_key {
+ u_int8_t wk_keylen; /* key length in bytes */
+ u_int8_t wk_flags;
+#define IEEE80211_KEY_XMIT 0x01 /* key used for xmit */
+#define IEEE80211_KEY_RECV 0x02 /* key used for recv */
+#define IEEE80211_KEY_GROUP 0x04 /* key used for WPA group operation */
+#define IEEE80211_KEY_SWCRYPT 0x10 /* host-based encrypt/decrypt */
+#define IEEE80211_KEY_SWMIC 0x20 /* host-based enmic/demic */
+ ieee80211_keyix_t wk_keyix; /* key index */
+ u_int8_t wk_key[IEEE80211_KEYBUF_SIZE+IEEE80211_MICBUF_SIZE];
+#define wk_txmic wk_key+IEEE80211_KEYBUF_SIZE+0 /* XXX can't () right */
+#define wk_rxmic wk_key+IEEE80211_KEYBUF_SIZE+8 /* XXX can't () right */
+ u_int64_t wk_keyrsc[IEEE80211_TID_SIZE]; /* key receive sequence counter */
+ u_int64_t wk_keytsc; /* key transmit sequence counter */
+ const struct ieee80211_cipher *wk_cipher;
+ void *wk_private; /* private cipher state */
+};
+#define IEEE80211_KEY_COMMON /* common flags passed in by apps */\
+ (IEEE80211_KEY_XMIT | IEEE80211_KEY_RECV | IEEE80211_KEY_GROUP)
+
+/*
+ * NB: these values are ordered carefully; there are lots of
+ * of implications in any reordering. In particular beware
+ * that 4 is not used to avoid conflicting with IEEE80211_F_PRIVACY.
+ */
+#define IEEE80211_CIPHER_WEP 0
+#define IEEE80211_CIPHER_TKIP 1
+#define IEEE80211_CIPHER_AES_OCB 2
+#define IEEE80211_CIPHER_AES_CCM 3
+#define IEEE80211_CIPHER_CKIP 5
+#define IEEE80211_CIPHER_NONE 6 /* pseudo value */
+
+#define IEEE80211_CIPHER_MAX (IEEE80211_CIPHER_NONE + 1)
+
+#define IEEE80211_KEYIX_NONE ((ieee80211_keyix_t)-1)
+
+#if defined(__KERNEL__) || defined(_KERNEL)
+
+struct ieee80211com;
+struct ieee80211vap;
+struct ieee80211_node;
+struct sk_buff;
+
+void ieee80211_crypto_attach(struct ieee80211com *);
+void ieee80211_crypto_detach(struct ieee80211com *);
+void ieee80211_crypto_vattach(struct ieee80211vap *);
+void ieee80211_crypto_vdetach(struct ieee80211vap *);
+int ieee80211_crypto_newkey(struct ieee80211vap *, int, int,
+ struct ieee80211_key *);
+int ieee80211_crypto_delkey(struct ieee80211vap *, struct ieee80211_key *,
+ struct ieee80211_node *);
+int ieee80211_crypto_setkey(struct ieee80211vap *, struct ieee80211_key *,
+ const u_int8_t macaddr[IEEE80211_ADDR_LEN], struct ieee80211_node *);
+void ieee80211_crypto_delglobalkeys(struct ieee80211vap *);
+
+/*
+ * Template for a supported cipher. Ciphers register with the
+ * crypto code and are typically loaded as separate modules
+ * (the null cipher is always present).
+ * XXX may need refcnts
+ */
+struct ieee80211_cipher {
+ const char *ic_name; /* printable name */
+ u_int ic_cipher; /* IEEE80211_CIPHER_* */
+ u_int ic_header; /* size of privacy header (bytes) */
+ u_int ic_trailer; /* size of privacy trailer (bytes) */
+ u_int ic_miclen; /* size of mic trailer (bytes) */
+ void *(*ic_attach)(struct ieee80211vap *, struct ieee80211_key *);
+ void (*ic_detach)(struct ieee80211_key *);
+ int (*ic_setkey)(struct ieee80211_key *);
+ int (*ic_encap)(struct ieee80211_key *, struct sk_buff *, u_int8_t);
+ int (*ic_decap)(struct ieee80211_key *, struct sk_buff *, int);
+ int (*ic_enmic)(struct ieee80211_key *, struct sk_buff *, int);
+ int (*ic_demic)(struct ieee80211_key *, struct sk_buff *, int, int);
+};
+extern const struct ieee80211_cipher ieee80211_cipher_none;
+
+void ieee80211_crypto_register(const struct ieee80211_cipher *);
+void ieee80211_crypto_unregister(const struct ieee80211_cipher *);
+int ieee80211_crypto_available(struct ieee80211vap*, u_int);
+
+struct ieee80211_key *ieee80211_crypto_encap(struct ieee80211_node *,
+ struct sk_buff *);
+struct ieee80211_key *ieee80211_crypto_decap(struct ieee80211_node *,
+ struct sk_buff *, int);
+
+/*
+ * Check and remove any MIC.
+ */
+static __inline int
+ieee80211_crypto_demic(struct ieee80211vap *vap, struct ieee80211_key *k,
+ struct sk_buff *skb, int hdrlen, int force)
+{
+ const struct ieee80211_cipher *cip = k->wk_cipher;
+ return (cip->ic_miclen > 0 ? cip->ic_demic(k, skb, hdrlen, force) : 1);
+}
+
+/*
+ * Add any MIC.
+ */
+static __inline int
+ieee80211_crypto_enmic(struct ieee80211vap *vap, struct ieee80211_key *k,
+ struct sk_buff *skb, int force)
+{
+ const struct ieee80211_cipher *cip = k->wk_cipher;
+ return (cip->ic_miclen > 0 ? cip->ic_enmic(k, skb, force) : 1);
+}
+
+/*
+ * Reset key state to an unused state. The crypto
+ * key allocation mechanism ensures other state (e.g.
+ * key data) is properly setup before a key is used.
+ */
+static __inline void
+ieee80211_crypto_resetkey(struct ieee80211vap *vap, struct ieee80211_key *k,
+ ieee80211_keyix_t ix)
+{
+ k->wk_cipher = &ieee80211_cipher_none;;
+ k->wk_private = k->wk_cipher->ic_attach(vap, k);
+ k->wk_keyix = ix;
+ k->wk_flags = IEEE80211_KEY_XMIT | IEEE80211_KEY_RECV;
+}
+
+/*
+ * Crypto-related notification methods.
+ */
+void ieee80211_notify_replay_failure(struct ieee80211vap *,
+ const struct ieee80211_frame *, const struct ieee80211_key *,
+ u_int64_t rsc);
+void ieee80211_notify_michael_failure(struct ieee80211vap *,
+ const struct ieee80211_frame *, ieee80211_keyix_t keyix);
+#endif /* defined(__KERNEL__) || defined(_KERNEL) */
+#endif /* _NET80211_IEEE80211_CRYPTO_H_ */
diff --git a/package/network/services/hostapd/madwifi/net80211/ieee80211_ioctl.h b/package/network/services/hostapd/madwifi/net80211/ieee80211_ioctl.h
new file mode 100644
index 0000000..204303b
--- /dev/null
+++ b/package/network/services/hostapd/madwifi/net80211/ieee80211_ioctl.h
@@ -0,0 +1,715 @@
+/*-
+ * Copyright (c) 2001 Atsushi Onoe
+ * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $Id: ieee80211_ioctl.h 3314 2008-01-30 23:50:16Z mtaylor $
+ */
+#ifndef _NET80211_IEEE80211_IOCTL_H_
+#define _NET80211_IEEE80211_IOCTL_H_
+
+/*
+ * IEEE 802.11 ioctls.
+ */
+#include <net80211/_ieee80211.h>
+#include <net80211/ieee80211.h>
+#include <net80211/ieee80211_crypto.h>
+
+/*
+ * Per/node (station) statistics available when operating as an AP.
+ */
+struct ieee80211_nodestats {
+ u_int32_t ns_rx_data; /* rx data frames */
+ u_int32_t ns_rx_mgmt; /* rx management frames */
+ u_int32_t ns_rx_ctrl; /* rx control frames */
+ u_int32_t ns_rx_ucast; /* rx unicast frames */
+ u_int32_t ns_rx_mcast; /* rx multi/broadcast frames */
+ u_int64_t ns_rx_bytes; /* rx data count (bytes) */
+ u_int64_t ns_rx_beacons; /* rx beacon frames */
+ u_int32_t ns_rx_proberesp; /* rx probe response frames */
+
+ u_int32_t ns_rx_dup; /* rx discard because it's a dup */
+ u_int32_t ns_rx_noprivacy; /* rx w/ wep but privacy off */
+ u_int32_t ns_rx_wepfail; /* rx wep processing failed */
+ u_int32_t ns_rx_demicfail; /* rx demic failed */
+ u_int32_t ns_rx_decap; /* rx decapsulation failed */
+ u_int32_t ns_rx_defrag; /* rx defragmentation failed */
+ u_int32_t ns_rx_disassoc; /* rx disassociation */
+ u_int32_t ns_rx_deauth; /* rx deauthentication */
+ u_int32_t ns_rx_decryptcrc; /* rx decrypt failed on crc */
+ u_int32_t ns_rx_unauth; /* rx on unauthorized port */
+ u_int32_t ns_rx_unencrypted; /* rx unecrypted w/ privacy */
+
+ u_int32_t ns_tx_data; /* tx data frames */
+ u_int32_t ns_tx_mgmt; /* tx management frames */
+ u_int32_t ns_tx_ucast; /* tx unicast frames */
+ u_int32_t ns_tx_mcast; /* tx multi/broadcast frames */
+ u_int64_t ns_tx_bytes; /* tx data count (bytes) */
+ u_int32_t ns_tx_probereq; /* tx probe request frames */
+ u_int32_t ns_tx_uapsd; /* tx on uapsd queue */
+
+ u_int32_t ns_tx_novlantag; /* tx discard due to no tag */
+ u_int32_t ns_tx_vlanmismatch; /* tx discard due to of bad tag */
+
+ u_int32_t ns_tx_eosplost; /* uapsd EOSP retried out */
+
+ u_int32_t ns_ps_discard; /* ps discard due to of age */
+
+ u_int32_t ns_uapsd_triggers; /* uapsd triggers */
+
+ /* MIB-related state */
+ u_int32_t ns_tx_assoc; /* [re]associations */
+ u_int32_t ns_tx_assoc_fail; /* [re]association failures */
+ u_int32_t ns_tx_auth; /* [re]authentications */
+ u_int32_t ns_tx_auth_fail; /* [re]authentication failures*/
+ u_int32_t ns_tx_deauth; /* deauthentications */
+ u_int32_t ns_tx_deauth_code; /* last deauth reason */
+ u_int32_t ns_tx_disassoc; /* disassociations */
+ u_int32_t ns_tx_disassoc_code; /* last disassociation reason */
+ u_int32_t ns_psq_drops; /* power save queue drops */
+};
+
+/*
+ * Summary statistics.
+ */
+struct ieee80211_stats {
+ u_int32_t is_rx_badversion; /* rx frame with bad version */
+ u_int32_t is_rx_tooshort; /* rx frame too short */
+ u_int32_t is_rx_wrongbss; /* rx from wrong bssid */
+ u_int32_t is_rx_dup; /* rx discard due to it's a dup */
+ u_int32_t is_rx_wrongdir; /* rx w/ wrong direction */
+ u_int32_t is_rx_mcastecho; /* rx discard due to of mcast echo */
+ u_int32_t is_rx_mcastdisabled; /* rx discard due to of mcast disabled */
+ u_int32_t is_rx_notassoc; /* rx discard due to sta !assoc */
+ u_int32_t is_rx_noprivacy; /* rx w/ wep but privacy off */
+ u_int32_t is_rx_unencrypted; /* rx w/o wep and privacy on */
+ u_int32_t is_rx_wepfail; /* rx wep processing failed */
+ u_int32_t is_rx_decap; /* rx decapsulation failed */
+ u_int32_t is_rx_mgtdiscard; /* rx discard mgt frames */
+ u_int32_t is_rx_ctl; /* rx discard ctrl frames */
+ u_int32_t is_rx_beacon; /* rx beacon frames */
+ u_int32_t is_rx_rstoobig; /* rx rate set truncated */
+ u_int32_t is_rx_elem_missing; /* rx required element missing*/
+ u_int32_t is_rx_elem_toobig; /* rx element too big */
+ u_int32_t is_rx_elem_toosmall; /* rx element too small */
+ u_int32_t is_rx_elem_unknown; /* rx element unknown */
+ u_int32_t is_rx_badchan; /* rx frame w/ invalid chan */
+ u_int32_t is_rx_chanmismatch; /* rx frame chan mismatch */
+ u_int32_t is_rx_nodealloc; /* rx frame dropped */
+ u_int32_t is_rx_ssidmismatch; /* rx frame ssid mismatch */
+ u_int32_t is_rx_auth_unsupported;/* rx w/ unsupported auth alg */
+ u_int32_t is_rx_auth_fail; /* rx sta auth failure */
+ u_int32_t is_rx_auth_countermeasures;/* rx auth discard due to CM */
+ u_int32_t is_rx_assoc_bss; /* rx assoc from wrong bssid */
+ u_int32_t is_rx_assoc_notauth; /* rx assoc w/o auth */
+ u_int32_t is_rx_assoc_capmismatch;/* rx assoc w/ cap mismatch */
+ u_int32_t is_rx_assoc_norate; /* rx assoc w/ no rate match */
+ u_int32_t is_rx_assoc_badwpaie; /* rx assoc w/ bad WPA IE */
+ u_int32_t is_rx_assoc_badscie; /* rx assoc w/ bad SC IE */
+ u_int32_t is_rx_deauth; /* rx deauthentication */
+ u_int32_t is_rx_disassoc; /* rx disassociation */
+ u_int32_t is_rx_badsubtype; /* rx frame w/ unknown subtype*/
+ u_int32_t is_rx_nobuf; /* rx failed for lack of buf */
+ u_int32_t is_rx_decryptcrc; /* rx decrypt failed on crc */
+ u_int32_t is_rx_ahdemo_mgt; /* rx discard ahdemo mgt frame*/
+ u_int32_t is_rx_bad_auth; /* rx bad auth request */
+ u_int32_t is_rx_unauth; /* rx on unauthorized port */
+ u_int32_t is_rx_badkeyid; /* rx w/ incorrect keyid */
+ u_int32_t is_rx_ccmpreplay; /* rx seq# violation (CCMP) */
+ u_int32_t is_rx_ccmpformat; /* rx format bad (CCMP) */
+ u_int32_t is_rx_ccmpmic; /* rx MIC check failed (CCMP) */
+ u_int32_t is_rx_tkipreplay; /* rx seq# violation (TKIP) */
+ u_int32_t is_rx_tkipformat; /* rx format bad (TKIP) */
+ u_int32_t is_rx_tkipmic; /* rx MIC check failed (TKIP) */
+ u_int32_t is_rx_tkipicv; /* rx ICV check failed (TKIP) */
+ u_int32_t is_rx_badcipher; /* rx failed due to of key type */
+ u_int32_t is_rx_nocipherctx; /* rx failed due to key !setup */
+ u_int32_t is_rx_acl; /* rx discard due to of acl policy */
+ u_int32_t is_rx_ffcnt; /* rx fast frames */
+ u_int32_t is_rx_badathtnl; /* driver key alloc failed */
+ u_int32_t is_tx_nobuf; /* tx failed for lack of buf */
+ u_int32_t is_tx_nonode; /* tx failed for no node */
+ u_int32_t is_tx_unknownmgt; /* tx of unknown mgt frame */
+ u_int32_t is_tx_badcipher; /* tx failed due to of key type */
+ u_int32_t is_tx_nodefkey; /* tx failed due to no defkey */
+ u_int32_t is_tx_noheadroom; /* tx failed due to no space */
+ u_int32_t is_tx_ffokcnt; /* tx fast frames sent success */
+ u_int32_t is_tx_fferrcnt; /* tx fast frames sent success */
+ u_int32_t is_scan_active; /* active scans started */
+ u_int32_t is_scan_passive; /* passive scans started */
+ u_int32_t is_node_timeout; /* nodes timed out inactivity */
+ u_int32_t is_node_fdisassoc; /* forced node disassociation */
+ u_int32_t is_crypto_nomem; /* no memory for crypto ctx */
+ u_int32_t is_crypto_tkip; /* tkip crypto done in s/w */
+ u_int32_t is_crypto_tkipenmic; /* tkip en-MIC done in s/w */
+ u_int32_t is_crypto_tkipdemic; /* tkip de-MIC done in s/w */
+ u_int32_t is_crypto_tkipcm; /* tkip counter measures */
+ u_int32_t is_crypto_ccmp; /* ccmp crypto done in s/w */
+ u_int32_t is_crypto_wep; /* wep crypto done in s/w */
+ u_int32_t is_crypto_setkey_cipher;/* cipher rejected key */
+ u_int32_t is_crypto_setkey_nokey;/* no key index for setkey */
+ u_int32_t is_crypto_delkey; /* driver key delete failed */
+ u_int32_t is_crypto_badcipher; /* unknown cipher */
+ u_int32_t is_crypto_nocipher; /* cipher not available */
+ u_int32_t is_crypto_attachfail; /* cipher attach failed */
+ u_int32_t is_crypto_swfallback; /* cipher fallback to s/w */
+ u_int32_t is_crypto_keyfail; /* driver key alloc failed */
+ u_int32_t is_crypto_enmicfail; /* en-MIC failed */
+ u_int32_t is_ibss_capmismatch; /* merge failed-cap mismatch */
+ u_int32_t is_ibss_norate; /* merge failed-rate mismatch */
+ u_int32_t is_ps_unassoc; /* ps-poll for unassoc. sta */
+ u_int32_t is_ps_badaid; /* ps-poll w/ incorrect aid */
+ u_int32_t is_ps_qempty; /* ps-poll w/ nothing to send */
+};
+
+/*
+ * Max size of optional information elements. We artificially
+ * constrain this; it's limited only by the max frame size (and
+ * the max parameter size of the wireless extensions).
+ */
+#define IEEE80211_MAX_OPT_IE 256
+
+/*
+ * WPA/RSN get/set key request. Specify the key/cipher
+ * type and whether the key is to be used for sending and/or
+ * receiving. The key index should be set only when working
+ * with global keys (use IEEE80211_KEYIX_NONE for ``no index'').
+ * Otherwise a unicast/pairwise key is specified by the bssid
+ * (on a station) or mac address (on an ap). They key length
+ * must include any MIC key data; otherwise it should be no
+ more than IEEE80211_KEYBUF_SIZE.
+ */
+struct ieee80211req_key {
+ u_int8_t ik_type; /* key/cipher type */
+ u_int8_t ik_pad;
+ ieee80211_keyix_t ik_keyix; /* key index */
+ u_int8_t ik_keylen; /* key length in bytes */
+ u_int8_t ik_flags;
+/* NB: IEEE80211_KEY_XMIT and IEEE80211_KEY_RECV defined elsewhere */
+#define IEEE80211_KEY_DEFAULT 0x80 /* default xmit key */
+ u_int8_t ik_macaddr[IEEE80211_ADDR_LEN];
+ u_int64_t ik_keyrsc; /* key receive sequence counter */
+ u_int64_t ik_keytsc; /* key transmit sequence counter */
+ u_int8_t ik_keydata[IEEE80211_KEYBUF_SIZE+IEEE80211_MICBUF_SIZE];
+};
+
+/*
+ * Delete a key either by index or address. Set the index
+ * to IEEE80211_KEYIX_NONE when deleting a unicast key.
+ */
+struct ieee80211req_del_key {
+ /* NB: This is different to ieee80211_keyix_t, but this is OK as
+ * values are unique over the low order bits. */
+ u_int8_t idk_keyix; /* key index */
+ u_int8_t idk_macaddr[IEEE80211_ADDR_LEN];
+};
+
+/*
+ * MLME state manipulation request. IEEE80211_MLME_ASSOC
+ * only makes sense when operating as a station. The other
+ * requests can be used when operating as a station or an
+ * ap (to effect a station).
+ */
+struct ieee80211req_mlme {
+ u_int8_t im_op; /* operation to perform */
+#define IEEE80211_MLME_ASSOC 1 /* associate station */
+#define IEEE80211_MLME_DISASSOC 2 /* disassociate station */
+#define IEEE80211_MLME_DEAUTH 3 /* deauthenticate station */
+#define IEEE80211_MLME_AUTHORIZE 4 /* authorize station */
+#define IEEE80211_MLME_UNAUTHORIZE 5 /* unauthorize station */
+#define IEEE80211_MLME_CLEAR_STATS 6 /* clear station statistic */
+ u_int8_t im_ssid_len; /* length of optional ssid */
+ u_int16_t im_reason; /* 802.11 reason code */
+ u_int8_t im_macaddr[IEEE80211_ADDR_LEN];
+ u_int8_t im_ssid[IEEE80211_NWID_LEN];
+};
+
+/*
+ * MAC ACL operations.
+ */
+enum {
+ IEEE80211_MACCMD_POLICY_OPEN = 0, /* set policy: no ACLs */
+ IEEE80211_MACCMD_POLICY_ALLOW = 1, /* set policy: allow traffic */
+ IEEE80211_MACCMD_POLICY_DENY = 2, /* set policy: deny traffic */
+ IEEE80211_MACCMD_FLUSH = 3, /* flush ACL database */
+ IEEE80211_MACCMD_DETACH = 4, /* detach ACL policy */
+};
+
+/*
+ * Set the active channel list. Note this list is
+ * intersected with the available channel list in
+ * calculating the set of channels actually used in
+ * scanning.
+ */
+struct ieee80211req_chanlist {
+ u_int8_t ic_channels[IEEE80211_CHAN_BYTES];
+};
+
+/*
+ * Get the active channel list info.
+ */
+struct ieee80211req_chaninfo {
+ u_int ic_nchans;
+ struct ieee80211_channel ic_chans[IEEE80211_CHAN_MAX];
+};
+
+/*
+ * Retrieve the WPA/RSN information element for an associated station.
+ */
+struct ieee80211req_wpaie {
+ u_int8_t wpa_macaddr[IEEE80211_ADDR_LEN];
+ u_int8_t wpa_ie[IEEE80211_MAX_OPT_IE];
+ u_int8_t rsn_ie[IEEE80211_MAX_OPT_IE];
+};
+
+/*
+ * Retrieve per-node statistics.
+ */
+struct ieee80211req_sta_stats {
+ union {
+ /* NB: explicitly force 64-bit alignment */
+ u_int8_t macaddr[IEEE80211_ADDR_LEN];
+ u_int64_t pad;
+ } is_u;
+ struct ieee80211_nodestats is_stats;
+};
+
+/*
+ * Station information block; the mac address is used
+ * to retrieve other data like stats, unicast key, etc.
+ */
+struct ieee80211req_sta_info {
+ u_int16_t isi_len; /* length (mult of 4) */
+ u_int16_t isi_freq; /* MHz */
+ u_int16_t isi_flags; /* channel flags */
+ u_int16_t isi_state; /* state flags */
+ u_int8_t isi_authmode; /* authentication algorithm */
+ u_int8_t isi_rssi;
+ int8_t isi_noise;
+ u_int16_t isi_capinfo; /* capabilities */
+ u_int8_t isi_athflags; /* Atheros capabilities */
+ u_int8_t isi_erp; /* ERP element */
+ u_int8_t isi_macaddr[IEEE80211_ADDR_LEN];
+ u_int8_t isi_nrates; /* negotiated rates */
+ u_int8_t isi_rates[IEEE80211_RATE_MAXSIZE];
+ u_int8_t isi_txrate; /* index to isi_rates[] */
+ u_int16_t isi_ie_len; /* IE length */
+ u_int16_t isi_associd; /* assoc response */
+ u_int16_t isi_txpower; /* current tx power */
+ u_int16_t isi_vlan; /* vlan tag */
+ u_int16_t isi_txseqs[17]; /* seq to be transmitted */
+ u_int16_t isi_rxseqs[17]; /* seq previous for qos frames*/
+ u_int16_t isi_inact; /* inactivity timer */
+ u_int8_t isi_uapsd; /* UAPSD queues */
+ u_int8_t isi_opmode; /* sta operating mode */
+
+ /* XXX frag state? */
+ /* variable length IE data */
+};
+
+enum {
+ IEEE80211_STA_OPMODE_NORMAL,
+ IEEE80211_STA_OPMODE_XR
+};
+
+/*
+ * Retrieve per-station information; to retrieve all
+ * specify a mac address of ff:ff:ff:ff:ff:ff.
+ */
+struct ieee80211req_sta_req {
+ union {
+ /* NB: explicitly force 64-bit alignment */
+ u_int8_t macaddr[IEEE80211_ADDR_LEN];
+ u_int64_t pad;
+ } is_u;
+ struct ieee80211req_sta_info info[1]; /* variable length */
+};
+
+/*
+ * Get/set per-station tx power cap.
+ */
+struct ieee80211req_sta_txpow {
+ u_int8_t it_macaddr[IEEE80211_ADDR_LEN];
+ u_int8_t it_txpow;
+};
+
+/*
+ * WME parameters are set and return using i_val and i_len.
+ * i_val holds the value itself. i_len specifies the AC
+ * and, as appropriate, then high bit specifies whether the
+ * operation is to be applied to the BSS or ourself.
+ */
+#define IEEE80211_WMEPARAM_SELF 0x0000 /* parameter applies to self */
+#define IEEE80211_WMEPARAM_BSS 0x8000 /* parameter applies to BSS */
+#define IEEE80211_WMEPARAM_VAL 0x7fff /* parameter value */
+
+/*
+ * Scan result data returned for IEEE80211_IOC_SCAN_RESULTS.
+ */
+struct ieee80211req_scan_result {
+ u_int16_t isr_len; /* length (mult of 4) */
+ u_int16_t isr_freq; /* MHz */
+ u_int16_t isr_flags; /* channel flags */
+ u_int8_t isr_noise;
+ u_int8_t isr_rssi;
+ u_int8_t isr_intval; /* beacon interval */
+ u_int16_t isr_capinfo; /* capabilities */
+ u_int8_t isr_erp; /* ERP element */
+ u_int8_t isr_bssid[IEEE80211_ADDR_LEN];
+ u_int8_t isr_nrates;
+ u_int8_t isr_rates[IEEE80211_RATE_MAXSIZE];
+ u_int8_t isr_ssid_len; /* SSID length */
+ u_int8_t isr_ie_len; /* IE length */
+ u_int8_t isr_pad[5];
+ /* variable length SSID followed by IE data */
+};
+
+#ifdef __FreeBSD__
+/*
+ * FreeBSD-style ioctls.
+ */
+/* the first member must be matched with struct ifreq */
+struct ieee80211req {
+ char i_name[IFNAMSIZ]; /* if_name, e.g. "wi0" */
+ u_int16_t i_type; /* req type */
+ int16_t i_val; /* Index or simple value */
+ int16_t i_len; /* Index or simple value */
+ void *i_data; /* Extra data */
+};
+#define SIOCS80211 _IOW('i', 234, struct ieee80211req)
+#define SIOCG80211 _IOWR('i', 235, struct ieee80211req)
+#define SIOCG80211STATS _IOWR('i', 236, struct ifreq)
+#define SIOC80211IFCREATE _IOWR('i', 237, struct ifreq)
+#define SIOC80211IFDESTROY _IOW('i', 238, struct ifreq)
+
+#define IEEE80211_IOC_SSID 1
+#define IEEE80211_IOC_NUMSSIDS 2
+#define IEEE80211_IOC_WEP 3
+#define IEEE80211_WEP_NOSUP -1
+#define IEEE80211_WEP_OFF 0
+#define IEEE80211_WEP_ON 1
+#define IEEE80211_WEP_MIXED 2
+#define IEEE80211_IOC_WEPKEY 4
+#define IEEE80211_IOC_NUMWEPKEYS 5
+#define IEEE80211_IOC_WEPTXKEY 6
+#define IEEE80211_IOC_AUTHMODE 7
+#define IEEE80211_IOC_STATIONNAME 8
+#define IEEE80211_IOC_CHANNEL 9
+#define IEEE80211_IOC_POWERSAVE 10
+#define IEEE80211_POWERSAVE_NOSUP -1
+#define IEEE80211_POWERSAVE_OFF 0
+#define IEEE80211_POWERSAVE_CAM 1
+#define IEEE80211_POWERSAVE_PSP 2
+#define IEEE80211_POWERSAVE_PSP_CAM 3
+#define IEEE80211_POWERSAVE_ON IEEE80211_POWERSAVE_CAM
+#define IEEE80211_IOC_POWERSAVESLEEP 11
+#define IEEE80211_IOC_RTSTHRESHOLD 12
+#define IEEE80211_IOC_PROTMODE 13
+#define IEEE80211_PROTMODE_OFF 0
+#define IEEE80211_PROTMODE_CTS 1
+#define IEEE80211_PROTMODE_RTSCTS 2
+#define IEEE80211_IOC_TXPOWER 14 /* global tx power limit */
+#define IEEE80211_IOC_BSSID 15
+#define IEEE80211_IOC_ROAMING 16 /* roaming mode */
+#define IEEE80211_IOC_PRIVACY 17 /* privacy invoked */
+#define IEEE80211_IOC_DROPUNENCRYPTED 18 /* discard unencrypted frames */
+#define IEEE80211_IOC_WPAKEY 19
+#define IEEE80211_IOC_DELKEY 20
+#define IEEE80211_IOC_MLME 21
+#define IEEE80211_IOC_OPTIE 22 /* optional info. element */
+#define IEEE80211_IOC_SCAN_REQ 23
+#define IEEE80211_IOC_SCAN_RESULTS 24
+#define IEEE80211_IOC_COUNTERMEASURES 25 /* WPA/TKIP countermeasures */
+#define IEEE80211_IOC_WPA 26 /* WPA mode (0,1,2) */
+#define IEEE80211_IOC_CHANLIST 27 /* channel list */
+#define IEEE80211_IOC_WME 28 /* WME mode (on, off) */
+#define IEEE80211_IOC_HIDESSID 29 /* hide SSID mode (on, off) */
+#define IEEE80211_IOC_APBRIDGE 30 /* AP inter-sta bridging */
+#define IEEE80211_IOC_MCASTCIPHER 31 /* multicast/default cipher */
+#define IEEE80211_IOC_MCASTKEYLEN 32 /* multicast key length */
+#define IEEE80211_IOC_UCASTCIPHERS 33 /* unicast cipher suites */
+#define IEEE80211_IOC_UCASTCIPHER 34 /* unicast cipher */
+#define IEEE80211_IOC_UCASTKEYLEN 35 /* unicast key length */
+#define IEEE80211_IOC_DRIVER_CAPS 36 /* driver capabilities */
+#define IEEE80211_IOC_KEYMGTALGS 37 /* key management algorithms */
+#define IEEE80211_IOC_RSNCAPS 38 /* RSN capabilities */
+#define IEEE80211_IOC_WPAIE 39 /* WPA information element */
+#define IEEE80211_IOC_STA_STATS 40 /* per-station statistics */
+#define IEEE80211_IOC_MACCMD 41 /* MAC ACL operation */
+#define IEEE80211_IOC_TXPOWMAX 43 /* max tx power for channel */
+#define IEEE80211_IOC_STA_TXPOW 44 /* per-station tx power limit */
+#define IEEE80211_IOC_STA_INFO 45 /* station/neighbor info */
+#define IEEE80211_IOC_WME_CWMIN 46 /* WME: ECWmin */
+#define IEEE80211_IOC_WME_CWMAX 47 /* WME: ECWmax */
+#define IEEE80211_IOC_WME_AIFS 48 /* WME: AIFSN */
+#define IEEE80211_IOC_WME_TXOPLIMIT 49 /* WME: txops limit */
+#define IEEE80211_IOC_WME_ACM 50 /* WME: ACM (bss only) */
+#define IEEE80211_IOC_WME_ACKPOLICY 51 /* WME: ACK policy (!bss only)*/
+#define IEEE80211_IOC_DTIM_PERIOD 52 /* DTIM period (beacons) */
+#define IEEE80211_IOC_BEACON_INTERVAL 53 /* beacon interval (ms) */
+#define IEEE80211_IOC_ADDMAC 54 /* add sta to MAC ACL table */
+#define IEEE80211_IOC_SETMAC 55 /* set interface wds mac addr */
+#define IEEE80211_IOC_FF 56 /* ATH fast frames (on, off) */
+#define IEEE80211_IOC_TURBOP 57 /* ATH turbo' (on, off) */
+#define IEEE80211_IOC_APPIEBUF 58 /* IE in the management frame */
+#define IEEE80211_IOC_FILTERFRAME 59 /* management frame filter */
+
+/*
+ * Scan result data returned for IEEE80211_IOC_SCAN_RESULTS.
+ */
+struct ieee80211req_scan_result {
+ u_int16_t isr_len; /* length (mult of 4) */
+ u_int16_t isr_freq; /* MHz */
+ u_int16_t isr_flags; /* channel flags */
+ u_int8_t isr_noise;
+ u_int8_t isr_rssi;
+ u_int8_t isr_intval; /* beacon interval */
+ u_int16_t isr_capinfo; /* capabilities */
+ u_int8_t isr_erp; /* ERP element */
+ u_int8_t isr_bssid[IEEE80211_ADDR_LEN];
+ u_int8_t isr_nrates;
+ u_int8_t isr_rates[IEEE80211_RATE_MAXSIZE];
+ u_int8_t isr_ssid_len; /* SSID length */
+ u_int8_t isr_ie_len; /* IE length */
+ u_int8_t isr_pad[5];
+ /* variable length SSID followed by IE data */
+};
+
+#endif /* __FreeBSD__ */
+
+#ifdef __linux__
+/*
+ * Wireless Extensions API, private ioctl interfaces.
+ *
+ * NB: Even-numbered ioctl numbers have set semantics and are privileged!
+ * (regardless of the incorrect comment in wireless.h!)
+ */
+#ifdef __KERNEL__
+#include <linux/if.h>
+#endif
+/* The maximum size of a iwpriv structure is IW_PRIV_SIZE_MASK, which was
+ * exceeded for some time by chaninfo ioctl. These macros change the size
+ * encoding for anything larger than IW_PRIV_SIZE_MASK from bytes to 4-byte
+ * multiples so that the padded size fits under IW_PRIV_SIZE_MASK. */
+#define IW_PRIV_BLOB_LENGTH_ENCODING(_SIZE) \
+ (((_SIZE) == ((_SIZE) & IW_PRIV_SIZE_MASK)) ? \
+ (_SIZE) : \
+ (((_SIZE) / sizeof(uint32_t)) + \
+ (((_SIZE) == (((_SIZE) / sizeof(uint32_t)) * sizeof(int))) ? \
+ 0 : 1)))
+#define IW_PRIV_BLOB_TYPE_ENCODING(_SIZE) \
+ (((_SIZE) == ((_SIZE) & IW_PRIV_SIZE_MASK)) ? \
+ (IW_PRIV_TYPE_BYTE | (_SIZE)) : \
+ (IW_PRIV_TYPE_INT | IW_PRIV_BLOB_LENGTH_ENCODING((_SIZE))))
+
+#define IEEE80211_IOCTL_SETPARAM (SIOCIWFIRSTPRIV+0)
+#define IEEE80211_IOCTL_GETPARAM (SIOCIWFIRSTPRIV+1)
+#define IEEE80211_IOCTL_SETMODE (SIOCIWFIRSTPRIV+2)
+#define IEEE80211_IOCTL_GETMODE (SIOCIWFIRSTPRIV+3)
+#define IEEE80211_IOCTL_SETWMMPARAMS (SIOCIWFIRSTPRIV+4)
+#define IEEE80211_IOCTL_GETWMMPARAMS (SIOCIWFIRSTPRIV+5)
+#define IEEE80211_IOCTL_SETCHANLIST (SIOCIWFIRSTPRIV+6)
+#define IEEE80211_IOCTL_GETCHANLIST (SIOCIWFIRSTPRIV+7)
+#define IEEE80211_IOCTL_CHANSWITCH (SIOCIWFIRSTPRIV+8)
+#define IEEE80211_IOCTL_GET_APPIEBUF (SIOCIWFIRSTPRIV+9)
+#define IEEE80211_IOCTL_SET_APPIEBUF (SIOCIWFIRSTPRIV+10)
+#define IEEE80211_IOCTL_READREG (SIOCIWFIRSTPRIV+11)
+#define IEEE80211_IOCTL_FILTERFRAME (SIOCIWFIRSTPRIV+12)
+#define IEEE80211_IOCTL_GETCHANINFO (SIOCIWFIRSTPRIV+13)
+#define IEEE80211_IOCTL_SETOPTIE (SIOCIWFIRSTPRIV+14)
+#define IEEE80211_IOCTL_GETOPTIE (SIOCIWFIRSTPRIV+15)
+#define IEEE80211_IOCTL_SETMLME (SIOCIWFIRSTPRIV+16)
+#define IEEE80211_IOCTL_RADAR (SIOCIWFIRSTPRIV+17)
+#define IEEE80211_IOCTL_SETKEY (SIOCIWFIRSTPRIV+18)
+#define IEEE80211_IOCTL_WRITEREG (SIOCIWFIRSTPRIV+19)
+#define IEEE80211_IOCTL_DELKEY (SIOCIWFIRSTPRIV+20)
+#define IEEE80211_IOCTL_HALMAP (SIOCIWFIRSTPRIV+21)
+#define IEEE80211_IOCTL_ADDMAC (SIOCIWFIRSTPRIV+22)
+#define IEEE80211_IOCTL_DELMAC (SIOCIWFIRSTPRIV+24)
+#define IEEE80211_IOCTL_WDSADDMAC (SIOCIWFIRSTPRIV+25)
+#define IEEE80211_IOCTL_WDSSETMAC (SIOCIWFIRSTPRIV+26)
+#define IEEE80211_IOCTL_KICKMAC (SIOCIWFIRSTPRIV+30)
+#define IEEE80211_IOCTL_SETSCANLIST (SIOCIWFIRSTPRIV+31)
+
+enum {
+ IEEE80211_WMMPARAMS_CWMIN = 1,
+ IEEE80211_WMMPARAMS_CWMAX = 2,
+ IEEE80211_WMMPARAMS_AIFS = 3,
+ IEEE80211_WMMPARAMS_TXOPLIMIT = 4,
+ IEEE80211_WMMPARAMS_ACM = 5,
+ IEEE80211_WMMPARAMS_NOACKPOLICY = 6,
+};
+enum {
+ IEEE80211_PARAM_TURBO = 1, /* turbo mode */
+ IEEE80211_PARAM_MODE = 2, /* phy mode (11a, 11b, etc.) */
+ IEEE80211_PARAM_AUTHMODE = 3, /* authentication mode */
+ IEEE80211_PARAM_PROTMODE = 4, /* 802.11g protection */
+ IEEE80211_PARAM_MCASTCIPHER = 5, /* multicast/default cipher */
+ IEEE80211_PARAM_MCASTKEYLEN = 6, /* multicast key length */
+ IEEE80211_PARAM_UCASTCIPHERS = 7, /* unicast cipher suites */
+ IEEE80211_PARAM_UCASTCIPHER = 8, /* unicast cipher */
+ IEEE80211_PARAM_UCASTKEYLEN = 9, /* unicast key length */
+ IEEE80211_PARAM_WPA = 10, /* WPA mode (0,1,2) */
+ IEEE80211_PARAM_ROAMING = 12, /* roaming mode */
+ IEEE80211_PARAM_PRIVACY = 13, /* privacy invoked */
+ IEEE80211_PARAM_COUNTERMEASURES = 14, /* WPA/TKIP countermeasures */
+ IEEE80211_PARAM_DROPUNENCRYPTED = 15, /* discard unencrypted frames */
+ IEEE80211_PARAM_DRIVER_CAPS = 16, /* driver capabilities */
+ IEEE80211_PARAM_MACCMD = 17, /* MAC ACL operation */
+ IEEE80211_PARAM_WMM = 18, /* WMM mode (on, off) */
+ IEEE80211_PARAM_HIDESSID = 19, /* hide SSID mode (on, off) */
+ IEEE80211_PARAM_APBRIDGE = 20, /* AP inter-sta bridging */
+ IEEE80211_PARAM_KEYMGTALGS = 21, /* key management algorithms */
+ IEEE80211_PARAM_RSNCAPS = 22, /* RSN capabilities */
+ IEEE80211_PARAM_INACT = 23, /* station inactivity timeout */
+ IEEE80211_PARAM_INACT_AUTH = 24, /* station auth inact timeout */
+ IEEE80211_PARAM_INACT_INIT = 25, /* station init inact timeout */
+ IEEE80211_PARAM_ABOLT = 26, /* Atheros Adv. Capabilities */
+ IEEE80211_PARAM_INACT_TICK = 27, /* station inactivity timer tick (seconds) */
+ IEEE80211_PARAM_DTIM_PERIOD = 28, /* DTIM period (beacons) */
+ IEEE80211_PARAM_BEACON_INTERVAL = 29, /* beacon interval (ms) */
+ IEEE80211_PARAM_DOTH = 30, /* 11.h is on/off */
+ IEEE80211_PARAM_PWRTARGET = 31, /* Current Channel Pwr Constraint */
+ IEEE80211_PARAM_GENREASSOC = 32, /* Generate a reassociation request */
+ IEEE80211_PARAM_COMPRESSION = 33, /* compression */
+ IEEE80211_PARAM_FF = 34, /* fast frames support */
+ IEEE80211_PARAM_XR = 35, /* XR support */
+ IEEE80211_PARAM_BURST = 36, /* burst mode */
+ IEEE80211_PARAM_PUREG = 37, /* pure 11g (no 11b stations) */
+ IEEE80211_PARAM_AR = 38, /* AR support */
+ IEEE80211_PARAM_WDS = 39, /* Enable 4 address processing */
+ IEEE80211_PARAM_BGSCAN = 40, /* bg scanning (on, off) */
+ IEEE80211_PARAM_BGSCAN_IDLE = 41, /* bg scan idle threshold */
+ IEEE80211_PARAM_BGSCAN_INTERVAL = 42, /* bg scan interval */
+ IEEE80211_PARAM_MCAST_RATE = 43, /* Multicast Tx Rate */
+ IEEE80211_PARAM_COVERAGE_CLASS = 44, /* coverage class */
+ IEEE80211_PARAM_COUNTRY_IE = 45, /* enable country IE */
+ IEEE80211_PARAM_SCANVALID = 46, /* scan cache valid threshold */
+ IEEE80211_PARAM_ROAM_RSSI_11A = 47, /* rssi threshold in 11a */
+ IEEE80211_PARAM_ROAM_RSSI_11B = 48, /* rssi threshold in 11b */
+ IEEE80211_PARAM_ROAM_RSSI_11G = 49, /* rssi threshold in 11g */
+ IEEE80211_PARAM_ROAM_RATE_11A = 50, /* tx rate threshold in 11a */
+ IEEE80211_PARAM_ROAM_RATE_11B = 51, /* tx rate threshold in 11b */
+ IEEE80211_PARAM_ROAM_RATE_11G = 52, /* tx rate threshold in 11g */
+ IEEE80211_PARAM_UAPSDINFO = 53, /* value for qos info field */
+ IEEE80211_PARAM_SLEEP = 54, /* force sleep/wake */
+ IEEE80211_PARAM_QOSNULL = 55, /* force sleep/wake */
+ IEEE80211_PARAM_PSPOLL = 56, /* force ps-poll generation (sta only) */
+ IEEE80211_PARAM_EOSPDROP = 57, /* force uapsd EOSP drop (ap only) */
+ IEEE80211_PARAM_MARKDFS = 58, /* mark a dfs interference channel when found */
+ IEEE80211_PARAM_REGCLASS = 59, /* enable regclass ids in country IE */
+ IEEE80211_PARAM_DROPUNENC_EAPOL = 60, /* drop unencrypted eapol frames */
+ IEEE80211_PARAM_SHPREAMBLE = 61, /* Short Preamble */
+ IEEE80211_PARAM_DUMPREGS = 62, /* Pretty printed dump of Atheros hardware registers */
+ IEEE80211_PARAM_DOTH_ALGORITHM = 63, /* spectrum management algorithm */
+ IEEE80211_PARAM_DOTH_MINCOM = 64, /* minimum number of common channels */
+ IEEE80211_PARAM_DOTH_SLCG = 65, /* permil of Stations Lost per Channel Gained */
+ IEEE80211_PARAM_DOTH_SLDG = 66, /* permil of Stations Lost per rssi Db Gained */
+ IEEE80211_PARAM_TXCONT = 67, /* continuous transmit mode (boolean) */
+ IEEE80211_PARAM_TXCONT_RATE = 68, /* continuous transmit mode data rate (in mbit/sec) - will use closest match from current rate table */
+ IEEE80211_PARAM_TXCONT_POWER = 69, /* power level in units of 0.5dBm */
+ IEEE80211_PARAM_DFS_TESTMODE = 70, /* do not perform DFS actions (i.e. markng DFS and channel change on interference), just report them via debug. */
+ IEEE80211_PARAM_DFS_CACTIME = 71, /* how long do we wait for chan availability
+ scans ?
+ FCC requires 60s, so that is the default. */
+ IEEE80211_PARAM_DFS_EXCLPERIOD = 72, /* DFS no-occupancy limit - how long do we stay
+ off a channel once radar is detected?
+ FCC requires 30m, so that is the default. */
+ IEEE80211_PARAM_BEACON_MISS_THRESH = 73, /* Beacon miss threshold (in beacons) */
+ IEEE80211_PARAM_BEACON_MISS_THRESH_MS = 74, /* Beacon miss threshold (in ms) */
+ IEEE80211_PARAM_MAXRATE = 75, /* Maximum rate (by table index) */
+ IEEE80211_PARAM_MINRATE = 76, /* Minimum rate (by table index) */
+ IEEE80211_PARAM_PROTMODE_RSSI = 77, /* RSSI Threshold for enabling protection mode */
+ IEEE80211_PARAM_PROTMODE_TIMEOUT = 78, /* Timeout for expiring protection mode */
+ IEEE80211_PARAM_BGSCAN_THRESH = 79, /* bg scan rssi threshold */
+ IEEE80211_PARAM_RSSI_DIS_THR = 80, /* rssi threshold for disconnection */
+ IEEE80211_PARAM_RSSI_DIS_COUNT = 81, /* counter for rssi threshold */
+ IEEE80211_PARAM_WDS_SEP = 82, /* move wds stations into separate interfaces */
+ IEEE80211_PARAM_MAXASSOC = 83, /* maximum associated stations */
+ IEEE80211_PARAM_PROBEREQ = 84, /* enable handling of probe requests */
+ IEEE80211_PARAM_BEACON_TXP = 85, /* set beacon tx power */
+};
+
+#define SIOCG80211STATS (SIOCDEVPRIVATE+2)
+/* NB: require in+out parameters so cannot use wireless extensions, yech */
+#define IEEE80211_IOCTL_GETKEY (SIOCDEVPRIVATE+3)
+#define IEEE80211_IOCTL_GETWPAIE (SIOCDEVPRIVATE+4)
+#define IEEE80211_IOCTL_STA_STATS (SIOCDEVPRIVATE+5)
+#define IEEE80211_IOCTL_STA_INFO (SIOCDEVPRIVATE+6)
+#define SIOC80211IFCREATE (SIOCDEVPRIVATE+7)
+#define SIOC80211IFDESTROY (SIOCDEVPRIVATE+8)
+#define IEEE80211_IOCTL_SCAN_RESULTS (SIOCDEVPRIVATE+9)
+
+struct ieee80211_clone_params {
+ char icp_name[IFNAMSIZ]; /* device name */
+ u_int16_t icp_opmode; /* operating mode */
+ u_int16_t icp_flags; /* see below */
+#define IEEE80211_CLONE_BSSID 0x0001 /* allocate unique mac/bssid */
+#define IEEE80211_NO_STABEACONS 0x0002 /* Do not setup the station beacon timers */
+};
+
+/* APPIEBUF related definitions */
+
+/* Management frame type to which application IE is added */
+enum {
+ IEEE80211_APPIE_FRAME_BEACON = 0,
+ IEEE80211_APPIE_FRAME_PROBE_REQ = 1,
+ IEEE80211_APPIE_FRAME_PROBE_RESP = 2,
+ IEEE80211_APPIE_FRAME_ASSOC_REQ = 3,
+ IEEE80211_APPIE_FRAME_ASSOC_RESP = 4,
+ IEEE80211_APPIE_NUM_OF_FRAME = 5
+};
+
+struct ieee80211req_getset_appiebuf {
+ u_int32_t app_frmtype; /* management frame type for which buffer is added */
+ u_int32_t app_buflen; /* application-supplied buffer length */
+ u_int8_t app_buf[0]; /* application-supplied IE(s) */
+};
+
+/* Flags ORed by application to set filter for receiving management frames */
+enum {
+ IEEE80211_FILTER_TYPE_BEACON = 1<<0,
+ IEEE80211_FILTER_TYPE_PROBE_REQ = 1<<1,
+ IEEE80211_FILTER_TYPE_PROBE_RESP = 1<<2,
+ IEEE80211_FILTER_TYPE_ASSOC_REQ = 1<<3,
+ IEEE80211_FILTER_TYPE_ASSOC_RESP = 1<<4,
+ IEEE80211_FILTER_TYPE_AUTH = 1<<5,
+ IEEE80211_FILTER_TYPE_DEAUTH = 1<<6,
+ IEEE80211_FILTER_TYPE_DISASSOC = 1<<7,
+ IEEE80211_FILTER_TYPE_ALL = 0xFF /* used to check the valid filter bits */
+};
+
+struct ieee80211req_set_filter {
+ u_int32_t app_filterype; /* management frame filter type */
+};
+
+
+#endif /* __linux__ */
+
+#endif /* _NET80211_IEEE80211_IOCTL_H_ */
diff --git a/package/network/services/hostapd/patches/.svn/entries b/package/network/services/hostapd/patches/.svn/entries
new file mode 100644
index 0000000..a3f9e44
--- /dev/null
+++ b/package/network/services/hostapd/patches/.svn/entries
@@ -0,0 +1,1048 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/services/hostapd/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-12T00:19:25.327611Z
+35973
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+550-limit_debug_messages.patch
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+846aaceecb1a4441ca08cddbae9079a7
+2013-03-04T17:16:38.282232Z
+35887
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+6683
+
+400-noscan.patch
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+ca9feb69b8c4ae35c901adc2782d515d
+2013-03-04T17:16:38.282232Z
+35887
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+973
+
+500-random_pool_add_kernel.patch
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+e58c139846d64119492d5a460045c484
+2013-03-04T17:16:38.282232Z
+35887
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4182
+
+480-terminate_on_setup_failure.patch
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+255021f60d278e726d769ed95bb2cf5f
+2013-03-04T17:16:38.282232Z
+35887
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2104
+
+530-wps_single_auth_enc_type.patch
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+08bdf9b12055b84a08eb6e3146cf0ffb
+2013-03-04T17:16:38.282232Z
+35887
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+838
+
+602-driver_nl80211-use-new-parameters-during-ibss-join.patch
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+a31ce9254e7e13a58fe772f91eac0288
+2013-03-04T17:16:38.282232Z
+35887
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1833
+
+320-madwifi_key_fixes.patch
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+df1de63c44720c6d7669485e7eadf206
+2012-09-13T12:38:51.674444Z
+33392
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1101
+
+410-multicall.patch
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+6e90a6b2a2ee45abd9c47aea55ae824d
+2013-03-04T17:16:38.282232Z
+35887
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+6765
+
+452-ctrl_iface_reload.patch
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+4d9cd821b5304195291eb6bcb45902e9
+2013-03-04T17:16:38.282232Z
+35887
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2548
+
+440-optional_rfkill.patch
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+35b9b794a8647831f9fd76f6cf925f38
+2013-03-04T17:16:38.282232Z
+35887
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+6615
+
+450-reload_freq_change.patch
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+a55078553ea18916cea5830eb8f1c00a
+2013-03-04T17:16:38.282232Z
+35887
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+836
+
+590-hostapd_cli_ifdef.patch
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+6dfbd82739a9f0637a39af5d85009d17
+2013-03-04T17:16:38.282232Z
+35887
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1959
+
+430-rescan_immediately.patch
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+4f0287fbec25e7d3a1319f21a5cd77b0
+2013-03-04T17:16:38.282232Z
+35887
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+353
+
+420-timestamp_check.patch
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+fd1a0035891785a99b43e4c5e0862e23
+2012-03-27T10:42:47.716426Z
+31080
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+319
+
+560-indicate-features.patch
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+0d5a1285efcf6d39ef12312eb6b1bae9
+2012-09-13T12:38:51.674444Z
+33392
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1841
+
+610-max_num_sta_probe.patch
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+c25dc1b191f25ebe24a75cb5e3aaa6b2
+2013-03-04T17:16:38.282232Z
+35887
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+438
+
+604-wpa_s-support-htmode-param.patch
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+566994ae8077101d8f8f3f76ec85b00e
+2013-03-04T17:16:38.282232Z
+35887
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3996
+
+601-wpa_supplicant-add-new-config-params-to-be-used-with.patch
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+0310dce5e3e6786385ef952fda79372d
+2013-03-04T17:16:38.282232Z
+35887
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5286
+
+520-fix_wps_pin_crash.patch
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+ea48499636810e0510d2fe1e7b1ca238
+2013-03-04T17:16:38.282232Z
+35887
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+245
+
+300-nl80211_multicall_fixes.patch
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+f6a65ca97e0c5b47ef00118aa19191f4
+2013-03-04T17:16:38.282232Z
+35887
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1927
+
+310-multicall_bridge_fix.patch
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+bb0a7cd8ab1268c659a004905cda4eb8
+2013-03-04T17:16:38.282232Z
+35887
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1396
+
+470-wpa_ie_cap_workaround.patch
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+78e4f69c0a2d027bc8c333f89a4e373a
+2013-03-04T17:16:38.282232Z
+35887
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1449
+
+510-bring_down_interface.patch
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+7fe0dcf068d8b9eaf3fe0d1842bd7137
+2013-03-04T17:16:38.282232Z
+35887
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+604
+
+540-dynamic_20_40_mhz.patch
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+0d5434aaf008d34249440b389f4898ce
+2013-03-04T17:16:38.282232Z
+35887
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5739
+
+453-ap_sta_support.patch
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+4149b0a0ce6dfbbc9ddb2ad77dcff5e3
+2013-03-04T17:16:38.282232Z
+35887
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+6302
+
+460-disable_ctrl_iface_mib.patch
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+b797f933fad4d561f7679ae964883443
+2013-03-04T17:16:38.282232Z
+35887
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4961
+
+620-scan_wait.patch
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+cd4bbc1ada03b6961919e176550c7f29
+2013-02-16T19:00:34.153225Z
+35630
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1453
+
+570-genl_connect_debug.patch
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+b802be892f0fa2ba7008373674eba021
+2012-09-13T12:38:51.674444Z
+33392
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+379
+
+330-fix_reassoc_after_ack_failure.patch
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+ed653341660fe8836f000bc6e35d364a
+2013-03-12T00:19:25.327611Z
+35973
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+445
+
+451-nl80211_del_beacon_bss.patch
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+94c041ac9c687e43a90315b3eb212cae
+2013-03-04T17:16:38.282232Z
+35887
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1697
+
diff --git a/package/network/services/hostapd/patches/.svn/text-base/300-nl80211_multicall_fixes.patch.svn-base b/package/network/services/hostapd/patches/.svn/text-base/300-nl80211_multicall_fixes.patch.svn-base
new file mode 100644
index 0000000..6c4f46f
--- /dev/null
+++ b/package/network/services/hostapd/patches/.svn/text-base/300-nl80211_multicall_fixes.patch.svn-base
@@ -0,0 +1,60 @@
+--- a/src/drivers/driver_nl80211.c
++++ b/src/drivers/driver_nl80211.c
+@@ -3129,6 +3129,7 @@ static void * wpa_driver_nl80211_init(vo
+ drv->monitor_sock = -1;
+ drv->eapol_tx_sock = -1;
+ drv->ap_scan_as_station = NL80211_IFTYPE_UNSPECIFIED;
++ drv->nlmode = NL80211_IFTYPE_STATION;
+
+ if (wpa_driver_nl80211_init_nl(drv)) {
+ os_free(drv);
+@@ -3446,17 +3447,12 @@ static void wpa_driver_nl80211_send_rfki
+ wpa_supplicant_event(timeout_ctx, EVENT_INTERFACE_DISABLED, NULL);
+ }
+
+-
+ static int
+-wpa_driver_nl80211_finish_drv_init(struct wpa_driver_nl80211_data *drv)
++wpa_driver_nl80211_finish_drv_init_sta(struct wpa_driver_nl80211_data *drv,
++ int *send_rfkill_event)
+ {
+ struct i802_bss *bss = &drv->first_bss;
+- int send_rfkill_event = 0;
+
+- drv->ifindex = if_nametoindex(bss->ifname);
+- drv->first_bss.ifindex = drv->ifindex;
+-
+-#ifndef HOSTAPD
+ /*
+ * Make sure the interface starts up in station mode unless this is a
+ * dynamically added interface (e.g., P2P) that was already configured
+@@ -3475,7 +3471,7 @@ wpa_driver_nl80211_finish_drv_init(struc
+ "interface '%s' due to rfkill",
+ bss->ifname);
+ drv->if_disabled = 1;
+- send_rfkill_event = 1;
++ *send_rfkill_event = 1;
+ } else {
+ wpa_printf(MSG_ERROR, "nl80211: Could not set "
+ "interface '%s' UP", bss->ifname);
+@@ -3485,7 +3481,19 @@ wpa_driver_nl80211_finish_drv_init(struc
+
+ netlink_send_oper_ifla(drv->global->netlink, drv->ifindex,
+ 1, IF_OPER_DORMANT);
+-#endif /* HOSTAPD */
++}
++
++static int
++wpa_driver_nl80211_finish_drv_init(struct wpa_driver_nl80211_data *drv)
++{
++ struct i802_bss *bss = &drv->first_bss;
++ int send_rfkill_event = 0;
++
++ drv->ifindex = if_nametoindex(bss->ifname);
++ drv->first_bss.ifindex = drv->ifindex;
++
++ if (drv->nlmode == NL80211_IFTYPE_STATION)
++ wpa_driver_nl80211_finish_drv_init_sta(drv, &send_rfkill_event);
+
+ if (wpa_driver_nl80211_capa(drv))
+ return -1;
diff --git a/package/network/services/hostapd/patches/.svn/text-base/310-multicall_bridge_fix.patch.svn-base b/package/network/services/hostapd/patches/.svn/text-base/310-multicall_bridge_fix.patch.svn-base
new file mode 100644
index 0000000..e167ba7
--- /dev/null
+++ b/package/network/services/hostapd/patches/.svn/text-base/310-multicall_bridge_fix.patch.svn-base
@@ -0,0 +1,45 @@
+--- a/src/drivers/driver_nl80211.c
++++ b/src/drivers/driver_nl80211.c
+@@ -897,6 +897,10 @@ static void wpa_driver_nl80211_event_rtm
+ return;
+ }
+
++ if (ifi->ifi_family == AF_BRIDGE &&
++ drv->nlmode != NL80211_IFTYPE_AP)
++ return;
++
+ wpa_printf(MSG_DEBUG, "RTM_NEWLINK: operstate=%d ifi_flags=0x%x "
+ "(%s%s%s%s)",
+ drv->operstate, ifi->ifi_flags,
+@@ -1004,6 +1008,10 @@ static void wpa_driver_nl80211_event_rtm
+ attrlen = len;
+ attr = (struct rtattr *) buf;
+
++ if (ifi->ifi_family == AF_BRIDGE &&
++ drv->nlmode != NL80211_IFTYPE_AP)
++ return;
++
+ rta_len = RTA_ALIGN(sizeof(struct rtattr));
+ while (RTA_OK(attr, attrlen)) {
+ if (attr->rta_type == IFLA_IFNAME) {
+@@ -3131,6 +3139,11 @@ static void * wpa_driver_nl80211_init(vo
+ drv->ap_scan_as_station = NL80211_IFTYPE_UNSPECIFIED;
+ drv->nlmode = NL80211_IFTYPE_STATION;
+
++#ifdef HOSTAPD
++ drv->num_if_indices = sizeof(drv->default_if_indices) / sizeof(int);
++ drv->if_indices = drv->default_if_indices;
++#endif
++
+ if (wpa_driver_nl80211_init_nl(drv)) {
+ os_free(drv);
+ return NULL;
+@@ -8021,8 +8034,6 @@ static void *i802_init(struct hostapd_da
+ br_ifindex = 0;
+ }
+
+- drv->num_if_indices = sizeof(drv->default_if_indices) / sizeof(int);
+- drv->if_indices = drv->default_if_indices;
+ for (i = 0; i < params->num_bridge; i++) {
+ if (params->bridge[i]) {
+ ifindex = if_nametoindex(params->bridge[i]);
diff --git a/package/network/services/hostapd/patches/.svn/text-base/320-madwifi_key_fixes.patch.svn-base b/package/network/services/hostapd/patches/.svn/text-base/320-madwifi_key_fixes.patch.svn-base
new file mode 100644
index 0000000..45a7ac6
--- /dev/null
+++ b/package/network/services/hostapd/patches/.svn/text-base/320-madwifi_key_fixes.patch.svn-base
@@ -0,0 +1,34 @@
+--- a/src/drivers/driver_madwifi.c
++++ b/src/drivers/driver_madwifi.c
+@@ -453,7 +453,9 @@ wpa_driver_madwifi_set_key(const char *i
+
+ memset(&wk, 0, sizeof(wk));
+ wk.ik_type = cipher;
+- wk.ik_flags = IEEE80211_KEY_RECV | IEEE80211_KEY_XMIT;
++ wk.ik_flags = IEEE80211_KEY_RECV;
++ if (set_tx)
++ wk.ik_flags |= IEEE80211_KEY_XMIT;
+ if (addr == NULL || is_broadcast_ether_addr(addr)) {
+ memset(wk.ik_macaddr, 0xff, IEEE80211_ADDR_LEN);
+ wk.ik_keyix = key_idx;
+@@ -465,6 +467,20 @@ wpa_driver_madwifi_set_key(const char *i
+ wk.ik_keylen = key_len;
+ memcpy(wk.ik_keydata, key, key_len);
+
++#ifdef WORDS_BIGENDIAN
++#define WPA_KEY_RSC_LEN 8
++ {
++ size_t i;
++ u8 tmp[WPA_KEY_RSC_LEN];
++ os_memset(tmp, 0, sizeof(tmp));
++ for (i = 0; i < seq_len; i++)
++ tmp[WPA_KEY_RSC_LEN - i - 1] = seq[i];
++ os_memcpy(&wk.ik_keyrsc, tmp, WPA_KEY_RSC_LEN);
++ }
++#else /* WORDS_BIGENDIAN */
++ os_memcpy(&wk.ik_keyrsc, seq, seq_len);
++#endif /* WORDS_BIGENDIAN */
++
+ ret = set80211priv(drv, IEEE80211_IOCTL_SETKEY, &wk, sizeof(wk));
+ if (ret < 0) {
+ wpa_printf(MSG_DEBUG, "%s: Failed to set key (addr %s"
diff --git a/package/network/services/hostapd/patches/.svn/text-base/330-fix_reassoc_after_ack_failure.patch.svn-base b/package/network/services/hostapd/patches/.svn/text-base/330-fix_reassoc_after_ack_failure.patch.svn-base
new file mode 100644
index 0000000..a91e4ae
--- /dev/null
+++ b/package/network/services/hostapd/patches/.svn/text-base/330-fix_reassoc_after_ack_failure.patch.svn-base
@@ -0,0 +1,11 @@
+--- a/src/ap/sta_info.c
++++ b/src/ap/sta_info.c
+@@ -576,7 +576,7 @@ void ap_sta_disassociate(struct hostapd_
+ {
+ wpa_printf(MSG_DEBUG, "%s: disassociate STA " MACSTR,
+ hapd->conf->iface, MAC2STR(sta->addr));
+- sta->flags &= ~WLAN_STA_ASSOC;
++ sta->flags &= ~(WLAN_STA_ASSOC | WLAN_STA_ASSOC_REQ_OK);
+ ap_sta_set_authorized(hapd, sta, 0);
+ sta->timeout_next = STA_DEAUTH;
+ wpa_printf(MSG_DEBUG, "%s: reschedule ap_handle_timer timeout "
diff --git a/package/network/services/hostapd/patches/.svn/text-base/400-noscan.patch.svn-base b/package/network/services/hostapd/patches/.svn/text-base/400-noscan.patch.svn-base
new file mode 100644
index 0000000..b1b25ff
--- /dev/null
+++ b/package/network/services/hostapd/patches/.svn/text-base/400-noscan.patch.svn-base
@@ -0,0 +1,32 @@
+--- a/hostapd/config_file.c
++++ b/hostapd/config_file.c
+@@ -2464,6 +2464,8 @@ static int hostapd_config_fill(struct ho
+ }
+ #endif /* CONFIG_IEEE80211W */
+ #ifdef CONFIG_IEEE80211N
++ } else if (os_strcmp(buf, "noscan") == 0) {
++ conf->noscan = atoi(pos);
+ } else if (os_strcmp(buf, "ieee80211n") == 0) {
+ conf->ieee80211n = atoi(pos);
+ } else if (os_strcmp(buf, "ht_capab") == 0) {
+--- a/src/ap/ap_config.h
++++ b/src/ap/ap_config.h
+@@ -510,6 +510,7 @@ struct hostapd_config {
+
+ int ht_op_mode_fixed;
+ u16 ht_capab;
++ int noscan;
+ int ieee80211n;
+ int secondary_channel;
+ int require_ht;
+--- a/src/ap/hw_features.c
++++ b/src/ap/hw_features.c
+@@ -494,7 +494,7 @@ static int ieee80211n_check_40mhz(struct
+ {
+ struct wpa_driver_scan_params params;
+
+- if (!iface->conf->secondary_channel)
++ if (!iface->conf->secondary_channel || iface->conf->noscan)
+ return 0; /* HT40 not used */
+
+ wpa_printf(MSG_DEBUG, "Scan for neighboring BSSes prior to enabling "
diff --git a/package/network/services/hostapd/patches/.svn/text-base/410-multicall.patch.svn-base b/package/network/services/hostapd/patches/.svn/text-base/410-multicall.patch.svn-base
new file mode 100644
index 0000000..4c6f8c9
--- /dev/null
+++ b/package/network/services/hostapd/patches/.svn/text-base/410-multicall.patch.svn-base
@@ -0,0 +1,246 @@
+--- a/hostapd/Makefile
++++ b/hostapd/Makefile
+@@ -14,6 +14,7 @@ CFLAGS += -I../src/utils
+ # CFLAGS += -DUSE_KERNEL_HEADERS -I/usr/src/linux/include
+
+ -include .config
++-include $(if $(MULTICALL), ../wpa_supplicant/.config)
+
+ ifndef CONFIG_OS
+ ifdef CONFIG_NATIVE_WINDOWS
+@@ -192,10 +193,14 @@ ifdef CONFIG_IEEE80211AC
+ CFLAGS += -DCONFIG_IEEE80211AC
+ endif
+
++ifndef MULTICALL
++CFLAGS += -DNO_SUPPLICANT
++endif
++
+ include ../src/drivers/drivers.mak
+-OBJS += $(DRV_AP_OBJS)
+-CFLAGS += $(DRV_AP_CFLAGS)
+-LDFLAGS += $(DRV_AP_LDFLAGS)
++OBJS += $(sort $(DRV_AP_OBJS) $(if $(MULTICALL),$(DRV_WPA_OBJS)))
++CFLAGS += $(DRV_AP_CFLAGS) $(if $(MULTICALL),$(DRV_WPA_CFLAGS))
++LDFLAGS += $(DRV_AP_LDFLAGS) $(if $(MULTICALL),$(DRV_WPA_LDFLAGS))
+ LIBS += $(DRV_AP_LIBS)
+
+ ifdef CONFIG_L2_PACKET
+@@ -860,6 +865,12 @@ install: all
+
+ BCHECK=../src/drivers/build.hostapd
+
++hostapd_multi.a: $(BCHECK) $(OBJS)
++ $(Q)$(CC) -c -o hostapd_multi.o -Dmain=hostapd_main $(CFLAGS) main.c
++ @$(E) " CC " $<
++ @rm -f $@
++ @$(AR) cr $@ hostapd_multi.o $(OBJS)
++
+ hostapd: $(BCHECK) $(OBJS)
+ $(Q)$(CC) $(LDFLAGS) -o hostapd $(OBJS) $(LIBS)
+ @$(E) " LD " $@
+@@ -898,6 +909,12 @@ HOBJS += ../src/crypto/aes-internal.o
+ HOBJS += ../src/crypto/aes-internal-enc.o
+ endif
+
++dump_cflags:
++ @echo -n $(CFLAGS) " "
++
++dump_ldflags:
++ @echo -n $(LDFLAGS) $(LIBS) $(EXTRALIBS) " "
++
+ nt_password_hash: $(NOBJS)
+ $(Q)$(CC) $(LDFLAGS) -o nt_password_hash $(NOBJS) $(LIBS_n)
+ @$(E) " LD " $@
+--- a/wpa_supplicant/Makefile
++++ b/wpa_supplicant/Makefile
+@@ -14,6 +14,7 @@ CFLAGS += -I../src
+ CFLAGS += -I../src/utils
+
+ -include .config
++-include $(if $(MULTICALL),../hostapd/.config)
+
+ BINALL=wpa_supplicant wpa_cli
+
+@@ -704,6 +705,10 @@ ifdef CONFIG_DYNAMIC_EAP_METHODS
+ CFLAGS += -DCONFIG_DYNAMIC_EAP_METHODS
+ LIBS += -ldl -rdynamic
+ endif
++else
++ ifdef MULTICALL
++ OBJS += ../src/eap_common/eap_common.o
++ endif
+ endif
+
+ ifdef CONFIG_AP
+@@ -712,9 +717,11 @@ NEED_EAP_COMMON=y
+ NEED_RSN_AUTHENTICATOR=y
+ CFLAGS += -DCONFIG_AP
+ OBJS += ap.o
++ifndef MULTICALL
+ CFLAGS += -DCONFIG_NO_RADIUS
+ CFLAGS += -DCONFIG_NO_ACCOUNTING
+ CFLAGS += -DCONFIG_NO_VLAN
++endif
+ OBJS += ../src/ap/hostapd.o
+ OBJS += ../src/ap/wpa_auth_glue.o
+ OBJS += ../src/ap/utils.o
+@@ -769,10 +776,18 @@ endif
+ ifdef CONFIG_HS20
+ OBJS += ../src/ap/hs20.o
+ endif
++else
++ ifdef MULTICALL
++ OBJS += ../src/eap_server/eap_server.o
++ OBJS += ../src/eap_server/eap_server_identity.o
++ OBJS += ../src/eap_server/eap_server_methods.o
++ endif
+ endif
+
+ ifdef NEED_RSN_AUTHENTICATOR
++ifndef MULTICALL
+ CFLAGS += -DCONFIG_NO_RADIUS
++endif
+ NEED_AES_WRAP=y
+ OBJS += ../src/ap/wpa_auth.o
+ OBJS += ../src/ap/wpa_auth_ie.o
+@@ -1521,6 +1536,12 @@ wpa_priv: $(BCHECK) $(OBJS_priv)
+
+ $(OBJS_c) $(OBJS_t) $(OBJS_t2) $(OBJS) $(BCHECK) $(EXTRA_progs): .config
+
++wpa_supplicant_multi.a: .config $(BCHECK) $(OBJS) $(EXTRA_progs)
++ $(Q)$(CC) -c -o wpa_supplicant_multi.o -Dmain=wpa_supplicant_main $(CFLAGS) main.c
++ @$(E) " CC " $<
++ @rm -f $@
++ @$(AR) cr $@ wpa_supplicant_multi.o $(OBJS)
++
+ wpa_supplicant: $(BCHECK) $(OBJS) $(EXTRA_progs)
+ $(Q)$(LDO) $(LDFLAGS) -o wpa_supplicant $(OBJS) $(LIBS) $(EXTRALIBS)
+ @$(E) " LD " $@
+@@ -1591,6 +1612,12 @@ eap_ikev2.so: ../src/eap_peer/eap_ikev2.
+ %@.service: %.service.arg.in
+ sed -e 's|\@BINDIR\@|$(BINDIR)|g' $< >$@
+
++dump_cflags:
++ @echo -n $(CFLAGS) " "
++
++dump_ldflags:
++ @echo -n $(LDFLAGS) $(LIBS) $(EXTRALIBS) " "
++
+ wpa_supplicant.exe: wpa_supplicant
+ mv -f $< $@
+ wpa_cli.exe: wpa_cli
+--- a/src/drivers/driver.h
++++ b/src/drivers/driver.h
+@@ -3726,8 +3726,8 @@ union wpa_event_data {
+ * Driver wrapper code should call this function whenever an event is received
+ * from the driver.
+ */
+-void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
+- union wpa_event_data *data);
++extern void (*wpa_supplicant_event)(void *ctx, enum wpa_event_type event,
++ union wpa_event_data *data);
+
+
+ /*
+--- a/src/ap/drv_callbacks.c
++++ b/src/ap/drv_callbacks.c
+@@ -714,8 +714,8 @@ static void hostapd_event_eapol_rx(struc
+ }
+
+
+-void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
+- union wpa_event_data *data)
++void hostapd_wpa_event(void *ctx, enum wpa_event_type event,
++ union wpa_event_data *data)
+ {
+ struct hostapd_data *hapd = ctx;
+ #ifndef CONFIG_NO_STDOUT_DEBUG
+--- a/wpa_supplicant/wpa_priv.c
++++ b/wpa_supplicant/wpa_priv.c
+@@ -819,8 +819,8 @@ static void wpa_priv_send_ft_response(st
+ }
+
+
+-void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
+- union wpa_event_data *data)
++static void supplicant_event(void *ctx, enum wpa_event_type event,
++ union wpa_event_data *data)
+ {
+ struct wpa_priv_interface *iface = ctx;
+
+@@ -962,6 +962,7 @@ int main(int argc, char *argv[])
+ if (os_program_init())
+ return -1;
+
++ wpa_supplicant_event = supplicant_event;
+ wpa_priv_fd_workaround();
+
+ for (;;) {
+--- a/wpa_supplicant/events.c
++++ b/wpa_supplicant/events.c
+@@ -2333,8 +2333,8 @@ static void wpa_supplicant_event_unprot_
+ }
+
+
+-void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
+- union wpa_event_data *data)
++void supplicant_event(void *ctx, enum wpa_event_type event,
++ union wpa_event_data *data)
+ {
+ struct wpa_supplicant *wpa_s = ctx;
+ u16 reason_code = 0;
+--- a/wpa_supplicant/wpa_supplicant.c
++++ b/wpa_supplicant/wpa_supplicant.c
+@@ -2972,6 +2972,9 @@ static void wpa_supplicant_deinit_iface(
+ }
+ }
+
++extern void supplicant_event(void *ctx, enum wpa_event_type event,
++ union wpa_event_data *data);
++
+
+ /**
+ * wpa_supplicant_add_iface - Add a new network interface
+@@ -3164,6 +3167,7 @@ struct wpa_global * wpa_supplicant_init(
+ wpa_msg_register_ifname_cb(wpa_supplicant_msg_ifname_cb);
+ #endif /* CONFIG_NO_WPA_MSG */
+
++ wpa_supplicant_event = supplicant_event;
+ wpa_debug_open_file(params->wpa_debug_file_path);
+ if (params->wpa_debug_syslog)
+ wpa_debug_open_syslog();
+--- a/hostapd/main.c
++++ b/hostapd/main.c
+@@ -530,6 +530,9 @@ static int hostapd_get_global_ctrl_iface
+ return 0;
+ }
+
++void hostapd_wpa_event(void *ctx, enum wpa_event_type event,
++ union wpa_event_data *data);
++
+
+ int main(int argc, char *argv[])
+ {
+@@ -555,6 +558,7 @@ int main(int argc, char *argv[])
+ interfaces.global_iface_name = NULL;
+ interfaces.global_ctrl_sock = -1;
+
++ wpa_supplicant_event = hostapd_wpa_event;
+ for (;;) {
+ c = getopt(argc, argv, "Bde:f:hKP:tvg:");
+ if (c < 0)
+--- a/src/drivers/drivers.c
++++ b/src/drivers/drivers.c
+@@ -7,7 +7,11 @@
+ */
+
+ #include "includes.h"
++#include "common.h"
++#include "driver.h"
+
++void (*wpa_supplicant_event)(void *ctx, enum wpa_event_type event,
++ union wpa_event_data *data);
+
+ #ifdef CONFIG_DRIVER_WEXT
+ extern struct wpa_driver_ops wpa_driver_wext_ops; /* driver_wext.c */
diff --git a/package/network/services/hostapd/patches/.svn/text-base/420-timestamp_check.patch.svn-base b/package/network/services/hostapd/patches/.svn/text-base/420-timestamp_check.patch.svn-base
new file mode 100644
index 0000000..b2d4a05
--- /dev/null
+++ b/package/network/services/hostapd/patches/.svn/text-base/420-timestamp_check.patch.svn-base
@@ -0,0 +1,12 @@
+--- a/src/tls/x509v3.c
++++ b/src/tls/x509v3.c
+@@ -1848,6 +1848,9 @@ int x509_certificate_chain_validate(stru
+ if (chain_trusted)
+ continue;
+
++#ifdef NO_TIMESTAMP_CHECK
++ disable_time_checks = 1;
++#endif
+ if (!disable_time_checks &&
+ ((unsigned long) now.sec <
+ (unsigned long) cert->not_before ||
diff --git a/package/network/services/hostapd/patches/.svn/text-base/430-rescan_immediately.patch.svn-base b/package/network/services/hostapd/patches/.svn/text-base/430-rescan_immediately.patch.svn-base
new file mode 100644
index 0000000..082344a
--- /dev/null
+++ b/package/network/services/hostapd/patches/.svn/text-base/430-rescan_immediately.patch.svn-base
@@ -0,0 +1,11 @@
+--- a/wpa_supplicant/wpa_supplicant.c
++++ b/wpa_supplicant/wpa_supplicant.c
+@@ -2416,7 +2416,7 @@ static struct wpa_supplicant * wpa_suppl
+ if (wpa_s == NULL)
+ return NULL;
+ wpa_s->scan_req = INITIAL_SCAN_REQ;
+- wpa_s->scan_interval = 5;
++ wpa_s->scan_interval = 1;
+ wpa_s->new_connection = 1;
+ wpa_s->parent = wpa_s;
+ wpa_s->sched_scanning = 0;
diff --git a/package/network/services/hostapd/patches/.svn/text-base/440-optional_rfkill.patch.svn-base b/package/network/services/hostapd/patches/.svn/text-base/440-optional_rfkill.patch.svn-base
new file mode 100644
index 0000000..8ed4d99
--- /dev/null
+++ b/package/network/services/hostapd/patches/.svn/text-base/440-optional_rfkill.patch.svn-base
@@ -0,0 +1,261 @@
+--- a/src/drivers/driver_nl80211.c
++++ b/src/drivers/driver_nl80211.c
+@@ -218,7 +218,9 @@ struct wpa_driver_nl80211_data {
+ int if_removed;
+ int if_disabled;
+ int ignore_if_down_event;
++#ifdef CONFIG_RFKILL
+ struct rfkill_data *rfkill;
++#endif
+ struct wpa_driver_capa capa;
+ int has_capability;
+
+@@ -2967,7 +2969,7 @@ static int wpa_driver_nl80211_init_nl(st
+ return 0;
+ }
+
+-
++#ifdef CONFIG_RFKILL
+ static void wpa_driver_nl80211_rfkill_blocked(void *ctx)
+ {
+ wpa_printf(MSG_DEBUG, "nl80211: RFKILL blocked");
+@@ -2990,6 +2992,7 @@ static void wpa_driver_nl80211_rfkill_un
+ }
+ /* rtnetlink ifup handler will report interface as enabled */
+ }
++#endif /* CONFIG_RFKILL */
+
+
+ static void nl80211_get_phy_name(struct wpa_driver_nl80211_data *drv)
+@@ -3118,7 +3121,9 @@ static void * wpa_driver_nl80211_init(vo
+ void *global_priv)
+ {
+ struct wpa_driver_nl80211_data *drv;
++#ifdef CONFIG_RFKILL
+ struct rfkill_config *rcfg;
++#endif
+ struct i802_bss *bss;
+
+ if (global_priv == NULL)
+@@ -3154,6 +3159,7 @@ static void * wpa_driver_nl80211_init(vo
+
+ nl80211_get_phy_name(drv);
+
++#ifdef CONFIG_RFKILL
+ rcfg = os_zalloc(sizeof(*rcfg));
+ if (rcfg == NULL)
+ goto failed;
+@@ -3166,6 +3172,7 @@ static void * wpa_driver_nl80211_init(vo
+ wpa_printf(MSG_DEBUG, "nl80211: RFKILL status not available");
+ os_free(rcfg);
+ }
++#endif /* CONFIG_RFKILL */
+
+ if (wpa_driver_nl80211_finish_drv_init(drv))
+ goto failed;
+@@ -3455,10 +3462,12 @@ static void nl80211_mgmt_unsubscribe(str
+ }
+
+
++#ifdef CONFIG_RFKILL
+ static void wpa_driver_nl80211_send_rfkill(void *eloop_ctx, void *timeout_ctx)
+ {
+ wpa_supplicant_event(timeout_ctx, EVENT_INTERFACE_DISABLED, NULL);
+ }
++#endif /* CONFIG_RFKILL */
+
+ static int
+ wpa_driver_nl80211_finish_drv_init_sta(struct wpa_driver_nl80211_data *drv,
+@@ -3479,13 +3488,16 @@ wpa_driver_nl80211_finish_drv_init_sta(s
+ }
+
+ if (linux_set_iface_flags(drv->global->ioctl_sock, bss->ifname, 1)) {
++#ifdef CONFIG_RFKILL
+ if (rfkill_is_blocked(drv->rfkill)) {
+ wpa_printf(MSG_DEBUG, "nl80211: Could not yet enable "
+ "interface '%s' due to rfkill",
+ bss->ifname);
+ drv->if_disabled = 1;
+ *send_rfkill_event = 1;
+- } else {
++ } else
++#endif
++ {
+ wpa_printf(MSG_ERROR, "nl80211: Could not set "
+ "interface '%s' UP", bss->ifname);
+ return -1;
+@@ -3516,8 +3528,10 @@ wpa_driver_nl80211_finish_drv_init(struc
+ return -1;
+
+ if (send_rfkill_event) {
++#ifdef CONFIG_RFKILL
+ eloop_register_timeout(0, 0, wpa_driver_nl80211_send_rfkill,
+ drv, drv->ctx);
++#endif
+ }
+
+ return 0;
+@@ -3603,7 +3617,9 @@ static void wpa_driver_nl80211_deinit(st
+
+ netlink_send_oper_ifla(drv->global->netlink, drv->ifindex, 0,
+ IF_OPER_UP);
++#ifdef CONFIG_RFKILL
+ rfkill_deinit(drv->rfkill);
++#endif
+
+ eloop_cancel_timeout(wpa_driver_nl80211_scan_timeout, drv, drv->ctx);
+
+--- a/src/drivers/driver_wext.c
++++ b/src/drivers/driver_wext.c
+@@ -742,7 +742,7 @@ static void wpa_driver_wext_event_rtm_de
+ }
+ }
+
+-
++#ifdef CONFIG_RFKILL
+ static void wpa_driver_wext_rfkill_blocked(void *ctx)
+ {
+ wpa_printf(MSG_DEBUG, "WEXT: RFKILL blocked");
+@@ -764,7 +764,7 @@ static void wpa_driver_wext_rfkill_unblo
+ }
+ /* rtnetlink ifup handler will report interface as enabled */
+ }
+-
++#endif /* CONFIG_RFKILL */
+
+ static void wext_get_phy_name(struct wpa_driver_wext_data *drv)
+ {
+@@ -810,7 +810,9 @@ void * wpa_driver_wext_init(void *ctx, c
+ {
+ struct wpa_driver_wext_data *drv;
+ struct netlink_config *cfg;
++#ifdef CONFIG_RFKILL
+ struct rfkill_config *rcfg;
++#endif
+ char path[128];
+ struct stat buf;
+
+@@ -845,6 +847,7 @@ void * wpa_driver_wext_init(void *ctx, c
+ goto err2;
+ }
+
++#ifdef CONFIG_RFKILL
+ rcfg = os_zalloc(sizeof(*rcfg));
+ if (rcfg == NULL)
+ goto err3;
+@@ -857,6 +860,7 @@ void * wpa_driver_wext_init(void *ctx, c
+ wpa_printf(MSG_DEBUG, "WEXT: RFKILL status not available");
+ os_free(rcfg);
+ }
++#endif /* CONFIG_RFKILL */
+
+ drv->mlme_sock = -1;
+
+@@ -874,7 +878,9 @@ void * wpa_driver_wext_init(void *ctx, c
+ return drv;
+
+ err3:
++#ifdef CONFIG_RFKILL
+ rfkill_deinit(drv->rfkill);
++#endif
+ netlink_deinit(drv->netlink);
+ err2:
+ close(drv->ioctl_sock);
+@@ -884,10 +890,12 @@ err1:
+ }
+
+
++#ifdef CONFIG_RFKILL
+ static void wpa_driver_wext_send_rfkill(void *eloop_ctx, void *timeout_ctx)
+ {
+ wpa_supplicant_event(timeout_ctx, EVENT_INTERFACE_DISABLED, NULL);
+ }
++#endif /* CONFIG_RFKILL */
+
+
+ static int wpa_driver_wext_finish_drv_init(struct wpa_driver_wext_data *drv)
+@@ -895,13 +903,16 @@ static int wpa_driver_wext_finish_drv_in
+ int send_rfkill_event = 0;
+
+ if (linux_set_iface_flags(drv->ioctl_sock, drv->ifname, 1) < 0) {
++#ifdef CONFIG_RFKILL
+ if (rfkill_is_blocked(drv->rfkill)) {
+ wpa_printf(MSG_DEBUG, "WEXT: Could not yet enable "
+ "interface '%s' due to rfkill",
+ drv->ifname);
+ drv->if_disabled = 1;
+ send_rfkill_event = 1;
+- } else {
++ } else
++#endif
++ {
+ wpa_printf(MSG_ERROR, "WEXT: Could not set "
+ "interface '%s' UP", drv->ifname);
+ return -1;
+@@ -949,8 +960,10 @@ static int wpa_driver_wext_finish_drv_in
+ 1, IF_OPER_DORMANT);
+
+ if (send_rfkill_event) {
++#ifdef CONFIG_RFKILL
+ eloop_register_timeout(0, 0, wpa_driver_wext_send_rfkill,
+ drv, drv->ctx);
++#endif
+ }
+
+ return 0;
+@@ -980,7 +993,9 @@ void wpa_driver_wext_deinit(void *priv)
+
+ netlink_send_oper_ifla(drv->netlink, drv->ifindex, 0, IF_OPER_UP);
+ netlink_deinit(drv->netlink);
++#ifdef CONFIG_RFKILL
+ rfkill_deinit(drv->rfkill);
++#endif
+
+ if (drv->mlme_sock >= 0)
+ eloop_unregister_read_sock(drv->mlme_sock);
+--- a/src/drivers/drivers.mak
++++ b/src/drivers/drivers.mak
+@@ -25,7 +25,6 @@ NEED_SME=y
+ NEED_AP_MLME=y
+ NEED_NETLINK=y
+ NEED_LINUX_IOCTL=y
+-NEED_RFKILL=y
+
+ ifdef CONFIG_LIBNL32
+ DRV_LIBS += -lnl-3
+@@ -109,7 +108,6 @@ DRV_WPA_CFLAGS += -DCONFIG_DRIVER_WEXT
+ CONFIG_WIRELESS_EXTENSION=y
+ NEED_NETLINK=y
+ NEED_LINUX_IOCTL=y
+-NEED_RFKILL=y
+ endif
+
+ ifdef CONFIG_DRIVER_NDIS
+@@ -135,7 +133,6 @@ endif
+ ifdef CONFIG_WIRELESS_EXTENSION
+ DRV_WPA_CFLAGS += -DCONFIG_WIRELESS_EXTENSION
+ DRV_WPA_OBJS += ../src/drivers/driver_wext.o
+-NEED_RFKILL=y
+ endif
+
+ ifdef NEED_NETLINK
+@@ -148,6 +145,7 @@ endif
+
+ ifdef NEED_RFKILL
+ DRV_OBJS += ../src/drivers/rfkill.o
++DRV_WPA_CFLAGS += -DCONFIG_RFKILL
+ endif
+
+ ifdef CONFIG_VLAN_NETLINK
+--- a/src/drivers/driver_wext.h
++++ b/src/drivers/driver_wext.h
+@@ -22,7 +22,9 @@ struct wpa_driver_wext_data {
+ int ifindex2;
+ int if_removed;
+ int if_disabled;
++#ifdef CONFIG_RFKILL
+ struct rfkill_data *rfkill;
++#endif
+ u8 *assoc_req_ies;
+ size_t assoc_req_ies_len;
+ u8 *assoc_resp_ies;
diff --git a/package/network/services/hostapd/patches/.svn/text-base/450-reload_freq_change.patch.svn-base b/package/network/services/hostapd/patches/.svn/text-base/450-reload_freq_change.patch.svn-base
new file mode 100644
index 0000000..bf48fe4
--- /dev/null
+++ b/package/network/services/hostapd/patches/.svn/text-base/450-reload_freq_change.patch.svn-base
@@ -0,0 +1,27 @@
+--- a/src/ap/hostapd.c
++++ b/src/ap/hostapd.c
+@@ -140,6 +140,24 @@ int hostapd_reload_config(struct hostapd
+ oldconf = hapd->iconf;
+ iface->conf = newconf;
+
++ hostapd_select_hw_mode(iface);
++ iface->freq = hostapd_hw_get_freq(hapd, newconf->channel);
++
++ if (hostapd_set_freq(hapd, newconf->hw_mode, iface->freq,
++ newconf->channel,
++ newconf->ieee80211n,
++ newconf->ieee80211ac,
++ newconf->secondary_channel,
++ newconf->vht_oper_chwidth,
++ newconf->vht_oper_centr_freq_seg0_idx,
++ newconf->vht_oper_centr_freq_seg1_idx)) {
++ wpa_printf(MSG_ERROR, "Could not set channel for "
++ "kernel driver");
++ }
++
++ if (iface->current_mode)
++ hostapd_prepare_rates(iface, iface->current_mode);
++
+ for (j = 0; j < iface->num_bss; j++) {
+ hapd = iface->bss[j];
+ hapd->iconf = newconf;
diff --git a/package/network/services/hostapd/patches/.svn/text-base/451-nl80211_del_beacon_bss.patch.svn-base b/package/network/services/hostapd/patches/.svn/text-base/451-nl80211_del_beacon_bss.patch.svn-base
new file mode 100644
index 0000000..2eaa5dc
--- /dev/null
+++ b/package/network/services/hostapd/patches/.svn/text-base/451-nl80211_del_beacon_bss.patch.svn-base
@@ -0,0 +1,63 @@
+--- a/src/drivers/driver_nl80211.c
++++ b/src/drivers/driver_nl80211.c
+@@ -3538,16 +3538,18 @@ wpa_driver_nl80211_finish_drv_init(struc
+ }
+
+
+-static int wpa_driver_nl80211_del_beacon(struct wpa_driver_nl80211_data *drv)
++static int wpa_driver_nl80211_del_bss_beacon(struct i802_bss *bss)
+ {
++ struct wpa_driver_nl80211_data *drv = bss->drv;
+ struct nl_msg *msg;
+
++ bss->beacon_set = 0;
+ msg = nlmsg_alloc();
+ if (!msg)
+ return -ENOMEM;
+
+ nl80211_cmd(drv, msg, 0, NL80211_CMD_DEL_BEACON);
+- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, drv->ifindex);
++ NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, bss->ifindex);
+
+ return send_and_recv_msgs(drv, msg, NULL, NULL);
+ nla_put_failure:
+@@ -3555,6 +3557,21 @@ static int wpa_driver_nl80211_del_beacon
+ return -ENOBUFS;
+ }
+
++static int wpa_driver_nl80211_del_beacon(struct wpa_driver_nl80211_data *drv)
++{
++ struct i802_bss *bss;
++
++ for (bss = &drv->first_bss; bss; bss = bss->next)
++ wpa_driver_nl80211_del_bss_beacon(bss);
++
++ return 0;
++}
++
++static int wpa_driver_nl80211_stop_ap(void *priv)
++{
++ struct i802_bss *bss = priv;
++ return wpa_driver_nl80211_del_beacon(bss->drv);
++}
+
+ /**
+ * wpa_driver_nl80211_deinit - Deinitialize nl80211 driver interface
+@@ -9547,4 +9564,5 @@ const struct wpa_driver_ops wpa_driver_n
+ .send_tdls_mgmt = nl80211_send_tdls_mgmt,
+ .tdls_oper = nl80211_tdls_oper,
+ #endif /* CONFIG_TDLS */
++ .stop_ap = wpa_driver_nl80211_stop_ap,
+ };
+--- a/src/drivers/driver.h
++++ b/src/drivers/driver.h
+@@ -2071,6 +2071,9 @@ struct wpa_driver_ops {
+ */
+ int (*probe_req_report)(void *priv, int report);
+
++
++ int (*stop_ap)(void *priv);
++
+ /**
+ * deinit_ap - Deinitialize AP mode
+ * @priv: Private driver interface data
diff --git a/package/network/services/hostapd/patches/.svn/text-base/452-ctrl_iface_reload.patch.svn-base b/package/network/services/hostapd/patches/.svn/text-base/452-ctrl_iface_reload.patch.svn-base
new file mode 100644
index 0000000..85e871f
--- /dev/null
+++ b/package/network/services/hostapd/patches/.svn/text-base/452-ctrl_iface_reload.patch.svn-base
@@ -0,0 +1,98 @@
+--- a/hostapd/ctrl_iface.c
++++ b/hostapd/ctrl_iface.c
+@@ -33,6 +33,7 @@
+ #include "wps/wps.h"
+ #include "config_file.h"
+ #include "ctrl_iface.h"
++#include "config_file.h"
+
+
+ struct wpa_ctrl_dst {
+@@ -43,6 +44,7 @@ struct wpa_ctrl_dst {
+ int errors;
+ };
+
++static char *reload_opts = NULL;
+
+ static void hostapd_ctrl_iface_send(struct hostapd_data *hapd, int level,
+ const char *buf, size_t len);
+@@ -152,6 +154,68 @@ static int hostapd_ctrl_iface_new_sta(st
+ return 0;
+ }
+
++static int hostapd_ctrl_iface_set_down(struct hostapd_data *hapd)
++{
++ if (hapd->driver->stop_ap)
++ hapd->driver->stop_ap(hapd->drv_priv);
++ return 0;
++}
++
++static char *get_option(char *opt, char *str)
++{
++ int len = strlen(str);
++
++ if (!strncmp(opt, str, len))
++ return opt + len;
++ else
++ return NULL;
++}
++
++static struct hostapd_config *hostapd_ctrl_iface_config_read(const char *fname)
++{
++ struct hostapd_config *conf;
++ char *opt, *val;
++
++ conf = hostapd_config_read(fname);
++ if (!conf)
++ return NULL;
++
++ for (opt = strtok(reload_opts, " ");
++ opt;
++ opt = strtok(NULL, " ")) {
++
++ if ((val = get_option(opt, "channel=")))
++ conf->channel = atoi(val);
++ else if ((val = get_option(opt, "ht_capab=")))
++ conf->ht_capab = atoi(val);
++ else if ((val = get_option(opt, "ht_capab_mask=")))
++ conf->ht_capab &= atoi(val);
++ else if ((val = get_option(opt, "sec_chan=")))
++ conf->secondary_channel = atoi(val);
++ else if ((val = get_option(opt, "hw_mode=")))
++ conf->hw_mode = atoi(val);
++ else if ((val = get_option(opt, "ieee80211n=")))
++ conf->ieee80211n = atoi(val);
++ else
++ break;
++ }
++
++ return conf;
++}
++
++static int hostapd_ctrl_iface_update(struct hostapd_data *hapd, char *txt)
++{
++ struct hostapd_config * (*config_read_cb)(const char *config_fname);
++ struct hostapd_iface *iface = hapd->iface;
++
++ config_read_cb = iface->interfaces->config_read_cb;
++ iface->interfaces->config_read_cb = hostapd_ctrl_iface_config_read;
++ reload_opts = txt;
++
++ hostapd_reload_config(iface);
++
++ iface->interfaces->config_read_cb = config_read_cb;
++}
+
+ #ifdef CONFIG_IEEE80211W
+ #ifdef NEED_AP_MLME
+@@ -902,6 +966,10 @@ static void hostapd_ctrl_iface_receive(i
+ reply_len += res;
+ }
+ #endif /* CONFIG_NO_RADIUS */
++ } else if (os_strcmp(buf, "DOWN") == 0) {
++ hostapd_ctrl_iface_set_down(hapd);
++ } else if (os_strncmp(buf, "UPDATE ", 7) == 0) {
++ hostapd_ctrl_iface_update(hapd, buf + 7);
+ } else if (os_strcmp(buf, "STA-FIRST") == 0) {
+ reply_len = hostapd_ctrl_iface_sta_first(hapd, reply,
+ reply_size);
diff --git a/package/network/services/hostapd/patches/.svn/text-base/453-ap_sta_support.patch.svn-base b/package/network/services/hostapd/patches/.svn/text-base/453-ap_sta_support.patch.svn-base
new file mode 100644
index 0000000..df04d3d
--- /dev/null
+++ b/package/network/services/hostapd/patches/.svn/text-base/453-ap_sta_support.patch.svn-base
@@ -0,0 +1,222 @@
+--- a/wpa_supplicant/wpa_supplicant_i.h
++++ b/wpa_supplicant/wpa_supplicant_i.h
+@@ -96,6 +96,8 @@ struct wpa_interface {
+ * receiving of EAPOL frames from an additional interface.
+ */
+ const char *bridge_ifname;
++
++ const char *hostapd_ctrl;
+ };
+
+ /**
+@@ -305,6 +307,8 @@ struct wpa_supplicant {
+ #endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
+ char bridge_ifname[16];
+
++ struct wpa_ctrl *hostapd;
++
+ char *confname;
+ struct wpa_config *conf;
+ int countermeasures;
+--- a/wpa_supplicant/Makefile
++++ b/wpa_supplicant/Makefile
+@@ -13,6 +13,10 @@ PKG_CONFIG ?= pkg-config
+ CFLAGS += -I../src
+ CFLAGS += -I../src/utils
+
++ifdef MULTICALL
++CFLAGS += -DMULTICALL
++endif
++
+ -include .config
+ -include $(if $(MULTICALL),../hostapd/.config)
+
+@@ -76,6 +80,10 @@ OBJS_c = wpa_cli.o ../src/common/wpa_ctr
+ OBJS_c += ../src/utils/wpa_debug.o
+ OBJS_c += ../src/utils/common.o
+
++ifdef MULTICALL
++OBJS += ../src/common/wpa_ctrl.o
++endif
++
+ ifndef CONFIG_OS
+ ifdef CONFIG_NATIVE_WINDOWS
+ CONFIG_OS=win32
+--- a/wpa_supplicant/wpa_supplicant.c
++++ b/wpa_supplicant/wpa_supplicant.c
+@@ -107,6 +107,55 @@ extern int wpa_debug_show_keys;
+ extern int wpa_debug_timestamp;
+ extern struct wpa_driver_ops *wpa_drivers[];
+
++#ifdef MULTICALL
++static int hostapd_stop(struct wpa_supplicant *wpa_s)
++{
++ const char *cmd = "DOWN";
++ char buf[256];
++ int len = sizeof(buf);
++
++ if (wpa_ctrl_request(wpa_s->hostapd, cmd, os_strlen(cmd), buf, &len, NULL) < 0) {
++ wpa_printf(MSG_ERROR, "\nFailed to stop hostapd AP interfaces\n");
++ return -1;
++ }
++ return 0;
++}
++
++static int hostapd_reload(struct wpa_supplicant *wpa_s, struct wpa_bss *bss)
++{
++ char *cmd = NULL;
++ char buf[256];
++ int len = sizeof(buf);
++ int channel, hw_mode;
++ int ret;
++
++ if (!bss)
++ return;
++
++ if (bss->freq < 4000) {
++ hw_mode = HOSTAPD_MODE_IEEE80211G;
++ channel = (bss->freq - 2407) / 5;
++ } else {
++ hw_mode = HOSTAPD_MODE_IEEE80211A;
++ channel = (bss->freq - 5000) / 5;
++ }
++
++ if (asprintf(&cmd, "UPDATE channel=%d sec_chan=0 hw_mode=%d ieee80211n=%d",
++ channel, hw_mode, !!bss->ht_capab) < 0) {
++ return -1;
++ }
++
++ ret = wpa_ctrl_request(wpa_s->hostapd, cmd, os_strlen(cmd), buf, &len, NULL);
++ free(cmd);
++
++ if (ret < 0) {
++ wpa_printf(MSG_ERROR, "\nFailed to reload hostapd AP interfaces\n");
++ return -1;
++ }
++ return 0;
++}
++#endif
++
+ /* Configure default/group WEP keys for static WEP */
+ int wpa_set_wep_keys(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid)
+ {
+@@ -676,8 +725,16 @@ void wpa_supplicant_set_state(struct wpa
+ #endif /* CONFIG_P2P */
+
+ sme_sched_obss_scan(wpa_s, 1);
++#ifdef MULTICALL
++ if (wpa_s->hostapd)
++ hostapd_reload(wpa_s, wpa_s->current_bss);
++#endif
+ } else if (state == WPA_DISCONNECTED || state == WPA_ASSOCIATING ||
+ state == WPA_ASSOCIATED) {
++#ifdef MULTICALL
++ if (wpa_s->hostapd)
++ hostapd_stop(wpa_s);
++#endif
+ wpa_s->new_connection = 1;
+ wpa_drv_set_operstate(wpa_s, 0);
+ #ifndef IEEE8021X_EAPOL
+@@ -2778,6 +2835,21 @@ static int wpa_supplicant_init_iface(str
+ os_strlcpy(wpa_s->bridge_ifname, iface->bridge_ifname,
+ sizeof(wpa_s->bridge_ifname));
+ }
++#ifdef MULTICALL
++ if (iface->hostapd_ctrl) {
++ char *cmd = "DOWN";
++ char buf[256];
++ int len = sizeof(buf);
++
++ wpa_s->hostapd = wpa_ctrl_open(iface->hostapd_ctrl);
++ if (!wpa_s->hostapd) {
++ wpa_printf(MSG_ERROR, "\nFailed to connect to hostapd\n");
++ return -1;
++ }
++ if (hostapd_stop(wpa_s) < 0)
++ return -1;
++ }
++#endif
+
+ /* RSNA Supplicant Key Management - INITIALIZE */
+ eapol_sm_notify_portEnabled(wpa_s->eapol, FALSE);
+--- a/wpa_supplicant/bss.c
++++ b/wpa_supplicant/bss.c
+@@ -11,6 +11,7 @@
+ #include "utils/common.h"
+ #include "utils/eloop.h"
+ #include "common/ieee802_11_defs.h"
++#include "common/ieee802_11_common.h"
+ #include "drivers/driver.h"
+ #include "wpa_supplicant_i.h"
+ #include "config.h"
+@@ -227,6 +228,8 @@ struct wpa_bss * wpa_bss_get(struct wpa_
+ static void wpa_bss_copy_res(struct wpa_bss *dst, struct wpa_scan_res *src,
+ struct os_time *fetch_time)
+ {
++ struct ieee80211_ht_capabilities *capab;
++ struct ieee802_11_elems elems;
+ os_time_t usec;
+
+ dst->flags = src->flags;
+@@ -239,6 +242,12 @@ static void wpa_bss_copy_res(struct wpa_
+ dst->level = src->level;
+ dst->tsf = src->tsf;
+
++ memset(&elems, 0, sizeof(elems));
++ ieee802_11_parse_elems((u8 *) (src + 1), src->ie_len, &elems, 0);
++ capab = (struct ieee80211_ht_capabilities *) elems.ht_capabilities;
++ if (capab)
++ dst->ht_capab = le_to_host16(capab->ht_capabilities_info);
++
+ dst->last_update.sec = fetch_time->sec;
+ dst->last_update.usec = fetch_time->usec;
+ dst->last_update.sec -= src->age / 1000;
+--- a/wpa_supplicant/main.c
++++ b/wpa_supplicant/main.c
+@@ -25,7 +25,7 @@ static void usage(void)
+ "usage:\n"
+ " wpa_supplicant [-BddhKLqqstuvW] [-P<pid file>] "
+ "[-g<global ctrl>] \\\n"
+- " -i<ifname> -c<config file> [-C<ctrl>] [-D<driver>] "
++ " -i<ifname> -c<config file> [-C<ctrl>] [-D<driver>] [-H<hostapd path>]"
+ "[-p<driver_param>] \\\n"
+ " [-b<br_ifname>] [-f<debug file>] [-e<entropy file>] "
+ "\\\n"
+@@ -67,6 +67,7 @@ static void usage(void)
+ #endif /* CONFIG_DEBUG_LINUX_TRACING */
+ printf(" -t = include timestamp in debug messages\n"
+ " -h = show this help text\n"
++ " -H = connect to a hostapd instance to manage state changes\n"
+ " -L = show license (BSD)\n"
+ " -o = override driver parameter for new interfaces\n"
+ " -O = override ctrl_interface parameter for new interfaces\n"
+@@ -155,7 +156,7 @@ int main(int argc, char *argv[])
+
+ for (;;) {
+ c = getopt(argc, argv,
+- "b:Bc:C:D:de:f:g:hi:KLNo:O:p:P:qsTtuvW");
++ "b:Bc:C:D:de:f:g:hH:i:KLNo:O:p:P:qsTtuvW");
+ if (c < 0)
+ break;
+ switch (c) {
+@@ -199,6 +200,9 @@ int main(int argc, char *argv[])
+ usage();
+ exitcode = 0;
+ goto out;
++ case 'H':
++ iface->hostapd_ctrl = optarg;
++ break;
+ case 'i':
+ iface->ifname = optarg;
+ break;
+--- a/wpa_supplicant/bss.h
++++ b/wpa_supplicant/bss.h
+@@ -69,6 +69,8 @@ struct wpa_bss {
+ u8 ssid[32];
+ /** Length of SSID */
+ size_t ssid_len;
++ /** HT caapbilities */
++ u16 ht_capab;
+ /** Frequency of the channel in MHz (e.g., 2412 = channel 1) */
+ int freq;
+ /** Beacon interval in TUs (host byte order) */
diff --git a/package/network/services/hostapd/patches/.svn/text-base/460-disable_ctrl_iface_mib.patch.svn-base b/package/network/services/hostapd/patches/.svn/text-base/460-disable_ctrl_iface_mib.patch.svn-base
new file mode 100644
index 0000000..e5db6b4
--- /dev/null
+++ b/package/network/services/hostapd/patches/.svn/text-base/460-disable_ctrl_iface_mib.patch.svn-base
@@ -0,0 +1,168 @@
+--- a/hostapd/Makefile
++++ b/hostapd/Makefile
+@@ -136,6 +136,9 @@ endif
+ ifdef CONFIG_NO_CTRL_IFACE
+ CFLAGS += -DCONFIG_NO_CTRL_IFACE
+ else
++ifdef CONFIG_CTRL_IFACE_MIB
++CFLAGS += -DCONFIG_CTRL_IFACE_MIB
++endif
+ OBJS += ctrl_iface.o
+ OBJS += ../src/ap/ctrl_iface_ap.o
+ endif
+--- a/hostapd/ctrl_iface.c
++++ b/hostapd/ctrl_iface.c
+@@ -937,6 +937,7 @@ static void hostapd_ctrl_iface_receive(i
+ } else if (os_strncmp(buf, "RELOG", 5) == 0) {
+ if (wpa_debug_reopen_file() < 0)
+ reply_len = -1;
++#ifdef CONFIG_CTRL_IFACE_MIB
+ } else if (os_strcmp(buf, "MIB") == 0) {
+ reply_len = ieee802_11_get_mib(hapd, reply, reply_size);
+ if (reply_len >= 0) {
+@@ -966,10 +967,12 @@ static void hostapd_ctrl_iface_receive(i
+ reply_len += res;
+ }
+ #endif /* CONFIG_NO_RADIUS */
++#endif
+ } else if (os_strcmp(buf, "DOWN") == 0) {
+ hostapd_ctrl_iface_set_down(hapd);
+ } else if (os_strncmp(buf, "UPDATE ", 7) == 0) {
+ hostapd_ctrl_iface_update(hapd, buf + 7);
++#ifdef CONFIG_CTRL_IFACE_MIB
+ } else if (os_strcmp(buf, "STA-FIRST") == 0) {
+ reply_len = hostapd_ctrl_iface_sta_first(hapd, reply,
+ reply_size);
+@@ -979,6 +982,7 @@ static void hostapd_ctrl_iface_receive(i
+ } else if (os_strncmp(buf, "STA-NEXT ", 9) == 0) {
+ reply_len = hostapd_ctrl_iface_sta_next(hapd, buf + 9, reply,
+ reply_size);
++#endif
+ } else if (os_strcmp(buf, "ATTACH") == 0) {
+ if (hostapd_ctrl_iface_attach(hapd, &from, fromlen))
+ reply_len = -1;
+--- a/wpa_supplicant/Makefile
++++ b/wpa_supplicant/Makefile
+@@ -754,6 +754,9 @@ ifdef CONFIG_WNM
+ OBJS += ../src/ap/wnm_ap.o
+ endif
+ ifdef CONFIG_CTRL_IFACE
++ifdef CONFIG_CTRL_IFACE_MIB
++CFLAGS += -DCONFIG_CTRL_IFACE_MIB
++endif
+ OBJS += ../src/ap/ctrl_iface_ap.o
+ endif
+
+--- a/wpa_supplicant/ctrl_iface.c
++++ b/wpa_supplicant/ctrl_iface.c
+@@ -4933,6 +4933,7 @@ char * wpa_supplicant_ctrl_iface_process
+ reply_len = -1;
+ } else if (os_strncmp(buf, "NOTE ", 5) == 0) {
+ wpa_printf(MSG_INFO, "NOTE: %s", buf + 5);
++#ifdef CONFIG_CTRL_IFACE_MIB
+ } else if (os_strcmp(buf, "MIB") == 0) {
+ reply_len = wpa_sm_get_mib(wpa_s->wpa, reply, reply_size);
+ if (reply_len >= 0) {
+@@ -4944,6 +4945,7 @@ char * wpa_supplicant_ctrl_iface_process
+ else
+ reply_len += res;
+ }
++#endif
+ } else if (os_strncmp(buf, "STATUS", 6) == 0) {
+ reply_len = wpa_supplicant_ctrl_iface_status(
+ wpa_s, buf + 6, reply, reply_size);
+@@ -5350,6 +5352,7 @@ char * wpa_supplicant_ctrl_iface_process
+ reply_len = wpa_supplicant_ctrl_iface_bss(
+ wpa_s, buf + 4, reply, reply_size);
+ #ifdef CONFIG_AP
++#ifdef CONFIG_CTRL_IFACE_MIB
+ } else if (os_strcmp(buf, "STA-FIRST") == 0) {
+ reply_len = ap_ctrl_iface_sta_first(wpa_s, reply, reply_size);
+ } else if (os_strncmp(buf, "STA ", 4) == 0) {
+@@ -5358,6 +5361,7 @@ char * wpa_supplicant_ctrl_iface_process
+ } else if (os_strncmp(buf, "STA-NEXT ", 9) == 0) {
+ reply_len = ap_ctrl_iface_sta_next(wpa_s, buf + 9, reply,
+ reply_size);
++#endif
+ } else if (os_strncmp(buf, "DEAUTHENTICATE ", 15) == 0) {
+ if (ap_ctrl_iface_sta_deauthenticate(wpa_s, buf + 15))
+ reply_len = -1;
+--- a/src/ap/ctrl_iface_ap.c
++++ b/src/ap/ctrl_iface_ap.c
+@@ -20,6 +20,7 @@
+ #include "ctrl_iface_ap.h"
+ #include "ap_drv_ops.h"
+
++#ifdef CONFIG_CTRL_IFACE_MIB
+
+ static int hostapd_get_sta_conn_time(struct sta_info *sta,
+ char *buf, size_t buflen)
+@@ -129,6 +130,7 @@ int hostapd_ctrl_iface_sta_next(struct h
+ return hostapd_ctrl_iface_sta_mib(hapd, sta->next, buf, buflen);
+ }
+
++#endif
+
+ #ifdef CONFIG_P2P_MANAGER
+ static int p2p_manager_disconnect(struct hostapd_data *hapd, u16 stype,
+@@ -303,3 +305,4 @@ int hostapd_ctrl_iface_disassociate(stru
+
+ return 0;
+ }
++
+--- a/src/ap/ieee802_1x.c
++++ b/src/ap/ieee802_1x.c
+@@ -2048,6 +2048,7 @@ static const char * bool_txt(Boolean boo
+ return bool ? "TRUE" : "FALSE";
+ }
+
++#ifdef CONFIG_CTRL_IFACE_MIB
+
+ int ieee802_1x_get_mib(struct hostapd_data *hapd, char *buf, size_t buflen)
+ {
+@@ -2200,6 +2201,7 @@ int ieee802_1x_get_mib_sta(struct hostap
+ return len;
+ }
+
++#endif
+
+ static void ieee802_1x_finished(struct hostapd_data *hapd,
+ struct sta_info *sta, int success)
+--- a/src/ap/wpa_auth.c
++++ b/src/ap/wpa_auth.c
+@@ -2687,6 +2687,7 @@ static const char * wpa_bool_txt(int boo
+ return bool ? "TRUE" : "FALSE";
+ }
+
++#ifdef CONFIG_CTRL_IFACE_MIB
+
+ #define RSN_SUITE "%02x-%02x-%02x-%d"
+ #define RSN_SUITE_ARG(s) \
+@@ -2831,7 +2832,7 @@ int wpa_get_mib_sta(struct wpa_state_mac
+
+ return len;
+ }
+-
++#endif
+
+ void wpa_auth_countermeasures_start(struct wpa_authenticator *wpa_auth)
+ {
+--- a/src/rsn_supp/wpa.c
++++ b/src/rsn_supp/wpa.c
+@@ -1848,6 +1848,8 @@ static u32 wpa_key_mgmt_suite(struct wpa
+ }
+
+
++#ifdef CONFIG_CTRL_IFACE_MIB
++
+ #define RSN_SUITE "%02x-%02x-%02x-%d"
+ #define RSN_SUITE_ARG(s) \
+ ((s) >> 24) & 0xff, ((s) >> 16) & 0xff, ((s) >> 8) & 0xff, (s) & 0xff
+@@ -1931,6 +1933,7 @@ int wpa_sm_get_mib(struct wpa_sm *sm, ch
+
+ return (int) len;
+ }
++#endif
+ #endif /* CONFIG_CTRL_IFACE */
+
+
diff --git a/package/network/services/hostapd/patches/.svn/text-base/470-wpa_ie_cap_workaround.patch.svn-base b/package/network/services/hostapd/patches/.svn/text-base/470-wpa_ie_cap_workaround.patch.svn-base
new file mode 100644
index 0000000..974ec3d
--- /dev/null
+++ b/package/network/services/hostapd/patches/.svn/text-base/470-wpa_ie_cap_workaround.patch.svn-base
@@ -0,0 +1,56 @@
+--- a/src/common/wpa_common.c
++++ b/src/common/wpa_common.c
+@@ -965,6 +965,31 @@ const char * wpa_key_mgmt_txt(int key_mg
+ }
+
+
++static void wpa_fixup_wpa_ie_rsn(u8 *assoc_ie, const u8 *wpa_msg_ie,
++ size_t rsn_ie_len)
++{
++ int pos, count;
++
++ pos = sizeof(struct rsn_ie_hdr) + RSN_SELECTOR_LEN;
++ if (rsn_ie_len < pos + 2)
++ return;
++
++ count = WPA_GET_LE16(wpa_msg_ie + pos);
++ pos += 2 + count * RSN_SELECTOR_LEN;
++ if (rsn_ie_len < pos + 2)
++ return;
++
++ count = WPA_GET_LE16(wpa_msg_ie + pos);
++ pos += 2 + count * RSN_SELECTOR_LEN;
++ if (rsn_ie_len < pos + 2)
++ return;
++
++ if (!assoc_ie[pos] && !assoc_ie[pos + 1] &&
++ (wpa_msg_ie[pos] || wpa_msg_ie[pos + 1]))
++ memcpy(&assoc_ie[pos], &wpa_msg_ie[pos], 2);
++}
++
++
+ int wpa_compare_rsn_ie(int ft_initial_assoc,
+ const u8 *ie1, size_t ie1len,
+ const u8 *ie2, size_t ie2len)
+@@ -972,8 +997,19 @@ int wpa_compare_rsn_ie(int ft_initial_as
+ if (ie1 == NULL || ie2 == NULL)
+ return -1;
+
+- if (ie1len == ie2len && os_memcmp(ie1, ie2, ie1len) == 0)
+- return 0; /* identical IEs */
++ if (ie1len == ie2len) {
++ u8 *ie_tmp;
++
++ if (os_memcmp(ie1, ie2, ie1len) == 0)
++ return 0; /* identical IEs */
++
++ ie_tmp = alloca(ie1len);
++ memcpy(ie_tmp, ie1, ie1len);
++ wpa_fixup_wpa_ie_rsn(ie_tmp, ie2, ie1len);
++
++ if (os_memcmp(ie_tmp, ie2, ie1len) == 0)
++ return 0; /* only mismatch in RSN capabilties */
++ }
+
+ #ifdef CONFIG_IEEE80211R
+ if (ft_initial_assoc) {
diff --git a/package/network/services/hostapd/patches/.svn/text-base/480-terminate_on_setup_failure.patch.svn-base b/package/network/services/hostapd/patches/.svn/text-base/480-terminate_on_setup_failure.patch.svn-base
new file mode 100644
index 0000000..f9d7425
--- /dev/null
+++ b/package/network/services/hostapd/patches/.svn/text-base/480-terminate_on_setup_failure.patch.svn-base
@@ -0,0 +1,81 @@
+--- a/src/ap/hostapd.c
++++ b/src/ap/hostapd.c
+@@ -895,11 +895,8 @@ int hostapd_setup_interface_complete(str
+ size_t j;
+ u8 *prev_addr;
+
+- if (err) {
+- wpa_printf(MSG_ERROR, "Interface initialization failed");
+- eloop_terminate();
+- return -1;
+- }
++ if (err)
++ goto error;
+
+ wpa_printf(MSG_DEBUG, "Completing interface initialization");
+ if (hapd->iconf->channel) {
+@@ -919,7 +916,7 @@ int hostapd_setup_interface_complete(str
+ hapd->iconf->vht_oper_centr_freq_seg1_idx)) {
+ wpa_printf(MSG_ERROR, "Could not set channel for "
+ "kernel driver");
+- return -1;
++ goto error;
+ }
+ }
+
+@@ -930,7 +927,7 @@ int hostapd_setup_interface_complete(str
+ hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE80211,
+ HOSTAPD_LEVEL_WARNING,
+ "Failed to prepare rates table.");
+- return -1;
++ goto error;
+ }
+ }
+
+@@ -938,14 +935,14 @@ int hostapd_setup_interface_complete(str
+ hostapd_set_rts(hapd, hapd->iconf->rts_threshold)) {
+ wpa_printf(MSG_ERROR, "Could not set RTS threshold for "
+ "kernel driver");
+- return -1;
++ goto error;
+ }
+
+ if (hapd->iconf->fragm_threshold > -1 &&
+ hostapd_set_frag(hapd, hapd->iconf->fragm_threshold)) {
+ wpa_printf(MSG_ERROR, "Could not set fragmentation threshold "
+ "for kernel driver");
+- return -1;
++ goto error;
+ }
+
+ prev_addr = hapd->own_addr;
+@@ -955,7 +952,7 @@ int hostapd_setup_interface_complete(str
+ if (j)
+ os_memcpy(hapd->own_addr, prev_addr, ETH_ALEN);
+ if (hostapd_setup_bss(hapd, j == 0))
+- return -1;
++ goto error;
+ if (hostapd_mac_comp_empty(hapd->conf->bssid) == 0)
+ prev_addr = hapd->own_addr;
+ }
+@@ -967,7 +964,7 @@ int hostapd_setup_interface_complete(str
+ if (hostapd_driver_commit(hapd) < 0) {
+ wpa_printf(MSG_ERROR, "%s: Failed to commit driver "
+ "configuration", __func__);
+- return -1;
++ goto error;
+ }
+
+ /*
+@@ -988,6 +985,11 @@ int hostapd_setup_interface_complete(str
+ iface->bss[0]->conf->iface);
+
+ return 0;
++
++error:
++ wpa_printf(MSG_ERROR, "Interface initialization failed");
++ eloop_terminate();
++ return -1;
+ }
+
+
diff --git a/package/network/services/hostapd/patches/.svn/text-base/500-random_pool_add_kernel.patch.svn-base b/package/network/services/hostapd/patches/.svn/text-base/500-random_pool_add_kernel.patch.svn-base
new file mode 100644
index 0000000..2280537
--- /dev/null
+++ b/package/network/services/hostapd/patches/.svn/text-base/500-random_pool_add_kernel.patch.svn-base
@@ -0,0 +1,176 @@
+--- a/src/crypto/random.c
++++ b/src/crypto/random.c
+@@ -25,6 +25,7 @@
+ #include "utils/includes.h"
+ #ifdef __linux__
+ #include <fcntl.h>
++#include <sys/stat.h>
+ #endif /* __linux__ */
+
+ #include "utils/common.h"
+@@ -33,6 +34,8 @@
+ #include "sha1.h"
+ #include "random.h"
+
++#define RANDOM_STAMPFILE "/var/run/.random_available"
++
+ #define POOL_WORDS 32
+ #define POOL_WORDS_MASK (POOL_WORDS - 1)
+ #define POOL_TAP1 26
+@@ -43,6 +46,8 @@
+ #define EXTRACT_LEN 16
+ #define MIN_READY_MARK 2
+
++#ifndef CONFIG_NO_RANDOM_POOL
++
+ static u32 pool[POOL_WORDS];
+ static unsigned int input_rotate = 0;
+ static unsigned int pool_pos = 0;
+@@ -123,7 +128,7 @@ static void random_extract(u8 *out)
+ }
+
+
+-void random_add_randomness(const void *buf, size_t len)
++static void random_pool_add_randomness(const void *buf, size_t len)
+ {
+ struct os_time t;
+ static unsigned int count = 0;
+@@ -213,16 +218,22 @@ int random_get_bytes(void *buf, size_t l
+ int random_pool_ready(void)
+ {
+ #ifdef __linux__
++ struct stat st;
+ int fd;
+ ssize_t res;
+
++ if (stat(RANDOM_STAMPFILE, &st) == 0)
++ return 1;
++
+ /*
+ * Make sure that there is reasonable entropy available before allowing
+ * some key derivation operations to proceed.
+ */
+
+- if (dummy_key_avail == sizeof(dummy_key))
++ if (dummy_key_avail == sizeof(dummy_key)) {
++ random_mark_pool_ready();
+ return 1; /* Already initialized - good to continue */
++ }
+
+ /*
+ * Try to fetch some more data from the kernel high quality
+@@ -257,6 +268,7 @@ int random_pool_ready(void)
+ if (dummy_key_avail == sizeof(dummy_key)) {
+ if (own_pool_ready < MIN_READY_MARK)
+ own_pool_ready = MIN_READY_MARK;
++ random_mark_pool_ready();
+ random_write_entropy();
+ return 1;
+ }
+@@ -269,6 +281,7 @@ int random_pool_ready(void)
+ total_collected + 10 * own_pool_ready > MIN_COLLECT_ENTROPY) {
+ wpa_printf(MSG_INFO, "random: Allow operation to proceed "
+ "based on internal entropy");
++ random_mark_pool_ready();
+ return 1;
+ }
+
+@@ -284,10 +297,16 @@ int random_pool_ready(void)
+
+ void random_mark_pool_ready(void)
+ {
++ int fd;
++
+ own_pool_ready++;
+ wpa_printf(MSG_DEBUG, "random: Mark internal entropy pool to be "
+ "ready (count=%u/%u)", own_pool_ready, MIN_READY_MARK);
+ random_write_entropy();
++
++ fd = open(RANDOM_STAMPFILE, O_CREAT | O_WRONLY | O_EXCL | O_NOFOLLOW, 0600);
++ if (fd >= 0)
++ close(fd);
+ }
+
+
+@@ -444,3 +463,22 @@ void random_deinit(void)
+ os_free(random_entropy_file);
+ random_entropy_file = NULL;
+ }
++
++#endif /* CONFIG_NO_RANDOM_POOL */
++
++
++void random_add_randomness(const void *buf, size_t len)
++{
++#ifdef __linux__
++ int fd;
++
++ fd = open("/dev/random", O_RDWR);
++ if (fd >= 0) {
++ write(fd, buf, len);
++ close(fd);
++ }
++#endif
++#ifndef CONFIG_NO_RANDOM_POOL
++ random_pool_add_randomness(buf, len);
++#endif
++}
+--- a/wpa_supplicant/Makefile
++++ b/wpa_supplicant/Makefile
+@@ -1222,9 +1222,8 @@ endif
+
+ ifdef CONFIG_NO_RANDOM_POOL
+ CFLAGS += -DCONFIG_NO_RANDOM_POOL
+-else
+-OBJS += ../src/crypto/random.o
+ endif
++OBJS += ../src/crypto/random.o
+
+ ifdef CONFIG_CTRL_IFACE
+ ifeq ($(CONFIG_CTRL_IFACE), y)
+--- a/wpa_supplicant/Android.mk
++++ b/wpa_supplicant/Android.mk
+@@ -1162,9 +1162,8 @@ endif
+
+ ifdef CONFIG_NO_RANDOM_POOL
+ L_CFLAGS += -DCONFIG_NO_RANDOM_POOL
+-else
+-OBJS += src/crypto/random.c
+ endif
++OBJS += src/crypto/random.c
+
+ ifdef CONFIG_CTRL_IFACE
+ ifeq ($(CONFIG_CTRL_IFACE), y)
+--- a/hostapd/Android.mk
++++ b/hostapd/Android.mk
+@@ -745,11 +745,11 @@ endif
+ ifdef CONFIG_NO_RANDOM_POOL
+ L_CFLAGS += -DCONFIG_NO_RANDOM_POOL
+ else
+-OBJS += src/crypto/random.c
+-HOBJS += src/crypto/random.c
+ HOBJS += $(SHA1OBJS)
+ HOBJS += src/crypto/md5.c
+ endif
++OBJS += src/crypto/random.c
++HOBJS += src/crypto/random.c
+
+ ifdef CONFIG_RADIUS_SERVER
+ L_CFLAGS += -DRADIUS_SERVER
+--- a/hostapd/Makefile
++++ b/hostapd/Makefile
+@@ -748,12 +748,12 @@ endif
+ ifdef CONFIG_NO_RANDOM_POOL
+ CFLAGS += -DCONFIG_NO_RANDOM_POOL
+ else
+-OBJS += ../src/crypto/random.o
+-HOBJS += ../src/crypto/random.o
+ HOBJS += ../src/utils/eloop.o
+ HOBJS += $(SHA1OBJS)
+ HOBJS += ../src/crypto/md5.o
+ endif
++OBJS += ../src/crypto/random.o
++HOBJS += ../src/crypto/random.o
+
+ ifdef CONFIG_RADIUS_SERVER
+ CFLAGS += -DRADIUS_SERVER
diff --git a/package/network/services/hostapd/patches/.svn/text-base/510-bring_down_interface.patch.svn-base b/package/network/services/hostapd/patches/.svn/text-base/510-bring_down_interface.patch.svn-base
new file mode 100644
index 0000000..1288e9e
--- /dev/null
+++ b/package/network/services/hostapd/patches/.svn/text-base/510-bring_down_interface.patch.svn-base
@@ -0,0 +1,19 @@
+--- a/src/drivers/driver_nl80211.c
++++ b/src/drivers/driver_nl80211.c
+@@ -7346,8 +7346,6 @@ static int wpa_driver_nl80211_set_mode(s
+ ret = nl80211_set_mode(drv, drv->ifindex, nlmode);
+ if (ret == -EACCES)
+ break;
+- res = linux_set_iface_flags(drv->global->ioctl_sock,
+- bss->ifname, 1);
+ if (res && !ret)
+ ret = -1;
+ else if (ret != -EBUSY)
+@@ -7363,6 +7361,7 @@ static int wpa_driver_nl80211_set_mode(s
+ "interface is down");
+ drv->nlmode = nlmode;
+ drv->ignore_if_down_event = 1;
++ linux_set_iface_flags(drv->global->ioctl_sock, bss->ifname, 1);
+ }
+
+ done:
diff --git a/package/network/services/hostapd/patches/.svn/text-base/520-fix_wps_pin_crash.patch.svn-base b/package/network/services/hostapd/patches/.svn/text-base/520-fix_wps_pin_crash.patch.svn-base
new file mode 100644
index 0000000..80d562c
--- /dev/null
+++ b/package/network/services/hostapd/patches/.svn/text-base/520-fix_wps_pin_crash.patch.svn-base
@@ -0,0 +1,12 @@
+--- a/hostapd/ctrl_iface.c
++++ b/hostapd/ctrl_iface.c
+@@ -479,6 +479,9 @@ static int hostapd_ctrl_iface_wps_ap_pin
+ char *pos;
+ const char *pin_txt;
+
++ if (!hapd->wps)
++ return -1;
++
+ pos = os_strchr(txt, ' ');
+ if (pos)
+ *pos++ = '\0';
diff --git a/package/network/services/hostapd/patches/.svn/text-base/530-wps_single_auth_enc_type.patch.svn-base b/package/network/services/hostapd/patches/.svn/text-base/530-wps_single_auth_enc_type.patch.svn-base
new file mode 100644
index 0000000..51c7669
--- /dev/null
+++ b/package/network/services/hostapd/patches/.svn/text-base/530-wps_single_auth_enc_type.patch.svn-base
@@ -0,0 +1,25 @@
+--- a/src/ap/wps_hostapd.c
++++ b/src/ap/wps_hostapd.c
+@@ -871,11 +871,9 @@ int hostapd_init_wps(struct hostapd_data
+
+ if (conf->rsn_pairwise & WPA_CIPHER_CCMP)
+ wps->encr_types |= WPS_ENCR_AES;
+- if (conf->rsn_pairwise & WPA_CIPHER_TKIP)
++ else if (conf->rsn_pairwise & WPA_CIPHER_TKIP)
+ wps->encr_types |= WPS_ENCR_TKIP;
+- }
+-
+- if (conf->wpa & WPA_PROTO_WPA) {
++ } else if (conf->wpa & WPA_PROTO_WPA) {
+ if (conf->wpa_key_mgmt & WPA_KEY_MGMT_PSK)
+ wps->auth_types |= WPS_AUTH_WPAPSK;
+ if (conf->wpa_key_mgmt & WPA_KEY_MGMT_IEEE8021X)
+@@ -883,7 +881,7 @@ int hostapd_init_wps(struct hostapd_data
+
+ if (conf->wpa_pairwise & WPA_CIPHER_CCMP)
+ wps->encr_types |= WPS_ENCR_AES;
+- if (conf->wpa_pairwise & WPA_CIPHER_TKIP)
++ else if (conf->wpa_pairwise & WPA_CIPHER_TKIP)
+ wps->encr_types |= WPS_ENCR_TKIP;
+ }
+
diff --git a/package/network/services/hostapd/patches/.svn/text-base/540-dynamic_20_40_mhz.patch.svn-base b/package/network/services/hostapd/patches/.svn/text-base/540-dynamic_20_40_mhz.patch.svn-base
new file mode 100644
index 0000000..ce2a339
--- /dev/null
+++ b/package/network/services/hostapd/patches/.svn/text-base/540-dynamic_20_40_mhz.patch.svn-base
@@ -0,0 +1,206 @@
+--- a/hostapd/config_file.c
++++ b/hostapd/config_file.c
+@@ -2474,6 +2474,10 @@ static int hostapd_config_fill(struct ho
+ "ht_capab", line);
+ errors++;
+ }
++ } else if (os_strcmp(buf, "dynamic_ht40") == 0) {
++ conf->dynamic_ht40 = atoi(pos);
++ if (conf->dynamic_ht40 == 1)
++ conf->dynamic_ht40 = 1500;
+ } else if (os_strcmp(buf, "require_ht") == 0) {
+ conf->require_ht = atoi(pos);
+ #endif /* CONFIG_IEEE80211N */
+--- a/src/ap/ap_config.h
++++ b/src/ap/ap_config.h
+@@ -514,6 +514,7 @@ struct hostapd_config {
+ int ieee80211n;
+ int secondary_channel;
+ int require_ht;
++ int dynamic_ht40;
+ u32 vht_capab;
+ int ieee80211ac;
+ int require_vht;
+--- a/src/ap/hostapd.c
++++ b/src/ap/hostapd.c
+@@ -22,6 +22,7 @@
+ #include "beacon.h"
+ #include "iapp.h"
+ #include "ieee802_1x.h"
++#include "ieee802_11.h"
+ #include "ieee802_11_auth.h"
+ #include "vlan_init.h"
+ #include "wpa_auth.h"
+@@ -332,6 +333,7 @@ static void hostapd_cleanup_iface_pre(st
+
+ static void hostapd_cleanup_iface_partial(struct hostapd_iface *iface)
+ {
++ hostapd_deinit_ht(iface);
+ hostapd_free_hw_features(iface->hw_features, iface->num_hw_features);
+ iface->hw_features = NULL;
+ os_free(iface->current_rates);
+--- a/src/ap/hostapd.h
++++ b/src/ap/hostapd.h
+@@ -265,6 +265,9 @@ struct hostapd_iface {
+ /* Overlapping BSS information */
+ int olbc_ht;
+
++ int force_20mhz;
++ struct os_time last_20mhz_trigger;
++
+ u16 ht_op_mode;
+ void (*scan_cb)(struct hostapd_iface *iface);
+ };
+--- a/src/ap/ieee802_11.c
++++ b/src/ap/ieee802_11.c
+@@ -1484,6 +1484,9 @@ static void handle_beacon(struct hostapd
+ sizeof(mgmt->u.beacon)), &elems,
+ 0);
+
++ if (!elems.ht_capabilities)
++ hostapd_trigger_20mhz(hapd->iface);
++
+ ap_list_process_beacon(hapd->iface, mgmt, &elems, fi);
+ }
+
+--- a/src/ap/ieee802_11.h
++++ b/src/ap/ieee802_11.h
+@@ -81,4 +81,17 @@ int hostapd_update_time_adv(struct hosta
+ void hostapd_client_poll_ok(struct hostapd_data *hapd, const u8 *addr);
+ u8 * hostapd_eid_bss_max_idle_period(struct hostapd_data *hapd, u8 *eid);
+
++#ifdef CONFIG_IEEE80211N
++void hostapd_trigger_20mhz(struct hostapd_iface *iface);
++void hostapd_deinit_ht(struct hostapd_iface *iface);
++
++#else
++static inline void hostapd_deinit_ht(struct hostapd_iface *iface)
++{
++}
++static inline void hostapd_trigger_20mhz(struct hostapd_iface *iface)
++{
++}
++#endif /* CONFIG_IEEE80211N */
++
+ #endif /* IEEE802_11_H */
+--- a/src/ap/ieee802_11_ht.c
++++ b/src/ap/ieee802_11_ht.c
+@@ -20,9 +20,11 @@
+ #include "drivers/driver.h"
+ #include "hostapd.h"
+ #include "ap_config.h"
++#include "ap_drv_ops.h"
+ #include "sta_info.h"
+ #include "beacon.h"
+ #include "ieee802_11.h"
++#include "utils/eloop.h"
+
+
+ u8 * hostapd_eid_ht_capabilities(struct hostapd_data *hapd, u8 *eid)
+@@ -70,12 +72,15 @@ u8 * hostapd_eid_ht_operation(struct hos
+
+ oper->control_chan = hapd->iconf->channel;
+ oper->operation_mode = host_to_le16(hapd->iface->ht_op_mode);
+- if (hapd->iconf->secondary_channel == 1)
+- oper->ht_param |= HT_INFO_HT_PARAM_SECONDARY_CHNL_ABOVE |
+- HT_INFO_HT_PARAM_REC_TRANS_CHNL_WIDTH;
+- if (hapd->iconf->secondary_channel == -1)
+- oper->ht_param |= HT_INFO_HT_PARAM_SECONDARY_CHNL_BELOW |
+- HT_INFO_HT_PARAM_REC_TRANS_CHNL_WIDTH;
++
++ if (!hapd->iface->force_20mhz) {
++ if (hapd->iconf->secondary_channel == 1)
++ oper->ht_param |= HT_INFO_HT_PARAM_SECONDARY_CHNL_ABOVE |
++ HT_INFO_HT_PARAM_REC_TRANS_CHNL_WIDTH;
++ if (hapd->iconf->secondary_channel == -1)
++ oper->ht_param |= HT_INFO_HT_PARAM_SECONDARY_CHNL_BELOW |
++ HT_INFO_HT_PARAM_REC_TRANS_CHNL_WIDTH;
++ }
+
+ pos += sizeof(*oper);
+
+@@ -270,3 +275,84 @@ void hostapd_get_ht_capab(struct hostapd
+
+ neg_ht_cap->ht_capabilities_info = host_to_le16(cap);
+ }
++
++static void hostapd_set_force_20mhz(struct hostapd_iface *iface);
++
++static void hostapd_restore_40mhz(void *eloop_data, void *user_ctx)
++{
++ struct hostapd_iface *iface = eloop_data;
++ struct os_time time;
++ int timeout;
++
++ if (!iface->last_20mhz_trigger.sec)
++ return;
++
++ os_get_time(&time);
++ timeout = iface->last_20mhz_trigger.sec + iface->conf->dynamic_ht40 -
++ time.sec;
++
++ if (timeout > 0) {
++ eloop_register_timeout(timeout, 0, hostapd_restore_40mhz,
++ iface, NULL);
++ return;
++ }
++
++ iface->last_20mhz_trigger.sec = 0;
++ iface->last_20mhz_trigger.usec = 0;
++
++ iface->force_20mhz = 0;
++ hostapd_set_force_20mhz(iface);
++}
++
++static void hostapd_set_force_20mhz(struct hostapd_iface *iface)
++{
++ int secondary_channel;
++ int i;
++
++ ieee802_11_set_beacons(iface);
++
++ for (i = 0; i < iface->num_bss; i++) {
++ struct hostapd_data *hapd = iface->bss[i];
++
++ if (iface->force_20mhz)
++ secondary_channel = 0;
++ else
++ secondary_channel = hapd->iconf->secondary_channel;
++
++ if (hostapd_set_freq(hapd, hapd->iconf->hw_mode, iface->freq,
++ hapd->iconf->channel,
++ hapd->iconf->ieee80211n,
++ hapd->iconf->ieee80211ac,
++ secondary_channel,
++ hapd->iconf->vht_oper_chwidth,
++ hapd->iconf->vht_oper_centr_freq_seg0_idx,
++ hapd->iconf->vht_oper_centr_freq_seg1_idx)) {
++ wpa_printf(MSG_ERROR, "Could not set channel for "
++ "kernel driver");
++ }
++ }
++}
++
++void hostapd_deinit_ht(struct hostapd_iface *iface)
++{
++ eloop_cancel_timeout(hostapd_restore_40mhz, iface, NULL);
++}
++
++void hostapd_trigger_20mhz(struct hostapd_iface *iface)
++{
++ if (!iface->conf->dynamic_ht40)
++ return;
++
++ if (!iface->force_20mhz) {
++ iface->force_20mhz = 1;
++ hostapd_set_force_20mhz(iface);
++ }
++
++ if (!iface->last_20mhz_trigger.sec) {
++ eloop_cancel_timeout(hostapd_restore_40mhz, iface, NULL);
++ eloop_register_timeout(iface->conf->dynamic_ht40, 0,
++ hostapd_restore_40mhz, iface, NULL);
++ }
++
++ os_get_time(&iface->last_20mhz_trigger);
++}
diff --git a/package/network/services/hostapd/patches/.svn/text-base/550-limit_debug_messages.patch.svn-base b/package/network/services/hostapd/patches/.svn/text-base/550-limit_debug_messages.patch.svn-base
new file mode 100644
index 0000000..659e980
--- /dev/null
+++ b/package/network/services/hostapd/patches/.svn/text-base/550-limit_debug_messages.patch.svn-base
@@ -0,0 +1,213 @@
+--- a/src/utils/wpa_debug.c
++++ b/src/utils/wpa_debug.c
+@@ -201,7 +201,7 @@ void wpa_debug_close_linux_tracing(void)
+ *
+ * Note: New line '\n' is added to the end of the text when printing to stdout.
+ */
+-void wpa_printf(int level, const char *fmt, ...)
++void _wpa_printf(int level, const char *fmt, ...)
+ {
+ va_list ap;
+
+@@ -248,8 +248,8 @@ void wpa_printf(int level, const char *f
+ }
+
+
+-static void _wpa_hexdump(int level, const char *title, const u8 *buf,
+- size_t len, int show)
++void _wpa_hexdump(int level, const char *title, const u8 *buf,
++ size_t len, int show)
+ {
+ size_t i;
+
+@@ -375,20 +375,9 @@ static void _wpa_hexdump(int level, cons
+ #endif /* CONFIG_ANDROID_LOG */
+ }
+
+-void wpa_hexdump(int level, const char *title, const u8 *buf, size_t len)
+-{
+- _wpa_hexdump(level, title, buf, len, 1);
+-}
+-
+-
+-void wpa_hexdump_key(int level, const char *title, const u8 *buf, size_t len)
+-{
+- _wpa_hexdump(level, title, buf, len, wpa_debug_show_keys);
+-}
+
+-
+-static void _wpa_hexdump_ascii(int level, const char *title, const u8 *buf,
+- size_t len, int show)
++void _wpa_hexdump_ascii(int level, const char *title, const u8 *buf,
++ size_t len, int show)
+ {
+ size_t i, llen;
+ const u8 *pos = buf;
+@@ -495,19 +484,6 @@ static void _wpa_hexdump_ascii(int level
+ }
+
+
+-void wpa_hexdump_ascii(int level, const char *title, const u8 *buf, size_t len)
+-{
+- _wpa_hexdump_ascii(level, title, buf, len, 1);
+-}
+-
+-
+-void wpa_hexdump_ascii_key(int level, const char *title, const u8 *buf,
+- size_t len)
+-{
+- _wpa_hexdump_ascii(level, title, buf, len, wpa_debug_show_keys);
+-}
+-
+-
+ #ifdef CONFIG_DEBUG_FILE
+ static char *last_path = NULL;
+ #endif /* CONFIG_DEBUG_FILE */
+@@ -591,7 +567,7 @@ void wpa_msg_register_ifname_cb(wpa_msg_
+ }
+
+
+-void wpa_msg(void *ctx, int level, const char *fmt, ...)
++void _wpa_msg(void *ctx, int level, const char *fmt, ...)
+ {
+ va_list ap;
+ char *buf;
+@@ -625,7 +601,7 @@ void wpa_msg(void *ctx, int level, const
+ }
+
+
+-void wpa_msg_ctrl(void *ctx, int level, const char *fmt, ...)
++void _wpa_msg_ctrl(void *ctx, int level, const char *fmt, ...)
+ {
+ va_list ap;
+ char *buf;
+--- a/src/utils/wpa_debug.h
++++ b/src/utils/wpa_debug.h
+@@ -43,6 +43,17 @@ int wpa_debug_open_file(const char *path
+ int wpa_debug_reopen_file(void);
+ void wpa_debug_close_file(void);
+
++/* internal */
++void _wpa_hexdump(int level, const char *title, const u8 *buf,
++ size_t len, int show);
++void _wpa_hexdump_ascii(int level, const char *title, const u8 *buf,
++ size_t len, int show);
++extern int wpa_debug_show_keys;
++
++#ifndef CONFIG_MSG_MIN_PRIORITY
++#define CONFIG_MSG_MIN_PRIORITY 0
++#endif
++
+ /**
+ * wpa_debug_printf_timestamp - Print timestamp for debug output
+ *
+@@ -63,9 +74,15 @@ void wpa_debug_print_timestamp(void);
+ *
+ * Note: New line '\n' is added to the end of the text when printing to stdout.
+ */
+-void wpa_printf(int level, const char *fmt, ...)
++void _wpa_printf(int level, const char *fmt, ...)
+ PRINTF_FORMAT(2, 3);
+
++#define wpa_printf(level, ...) \
++ do { \
++ if (level >= CONFIG_MSG_MIN_PRIORITY) \
++ _wpa_printf(level, __VA_ARGS__); \
++ } while(0)
++
+ /**
+ * wpa_hexdump - conditional hex dump
+ * @level: priority level (MSG_*) of the message
+@@ -77,7 +94,13 @@ PRINTF_FORMAT(2, 3);
+ * output may be directed to stdout, stderr, and/or syslog based on
+ * configuration. The contents of buf is printed out has hex dump.
+ */
+-void wpa_hexdump(int level, const char *title, const u8 *buf, size_t len);
++static inline void wpa_hexdump(int level, const char *title, const u8 *buf, size_t len)
++{
++ if (level < CONFIG_MSG_MIN_PRIORITY)
++ return;
++
++ _wpa_hexdump(level, title, buf, len, 1);
++}
+
+ static inline void wpa_hexdump_buf(int level, const char *title,
+ const struct wpabuf *buf)
+@@ -99,7 +122,13 @@ static inline void wpa_hexdump_buf(int l
+ * like wpa_hexdump(), but by default, does not include secret keys (passwords,
+ * etc.) in debug output.
+ */
+-void wpa_hexdump_key(int level, const char *title, const u8 *buf, size_t len);
++static inline void wpa_hexdump_key(int level, const char *title, const u8 *buf, size_t len)
++{
++ if (level < CONFIG_MSG_MIN_PRIORITY)
++ return;
++
++ _wpa_hexdump(level, title, buf, len, wpa_debug_show_keys);
++}
+
+ static inline void wpa_hexdump_buf_key(int level, const char *title,
+ const struct wpabuf *buf)
+@@ -121,8 +150,14 @@ static inline void wpa_hexdump_buf_key(i
+ * the hex numbers and ASCII characters (for printable range) are shown. 16
+ * bytes per line will be shown.
+ */
+-void wpa_hexdump_ascii(int level, const char *title, const u8 *buf,
+- size_t len);
++static inline void wpa_hexdump_ascii(int level, const char *title,
++ const u8 *buf, size_t len)
++{
++ if (level < CONFIG_MSG_MIN_PRIORITY)
++ return;
++
++ _wpa_hexdump_ascii(level, title, buf, len, 1);
++}
+
+ /**
+ * wpa_hexdump_ascii_key - conditional hex dump, hide keys
+@@ -138,8 +173,14 @@ void wpa_hexdump_ascii(int level, const
+ * bytes per line will be shown. This works like wpa_hexdump_ascii(), but by
+ * default, does not include secret keys (passwords, etc.) in debug output.
+ */
+-void wpa_hexdump_ascii_key(int level, const char *title, const u8 *buf,
+- size_t len);
++static inline void wpa_hexdump_ascii_key(int level, const char *title,
++ const u8 *buf, size_t len)
++{
++ if (level < CONFIG_MSG_MIN_PRIORITY)
++ return;
++
++ _wpa_hexdump_ascii(level, title, buf, len, wpa_debug_show_keys);
++}
+
+ /*
+ * wpa_dbg() behaves like wpa_msg(), but it can be removed from build to reduce
+@@ -172,7 +213,12 @@ void wpa_hexdump_ascii_key(int level, co
+ *
+ * Note: New line '\n' is added to the end of the text when printing to stdout.
+ */
+-void wpa_msg(void *ctx, int level, const char *fmt, ...) PRINTF_FORMAT(3, 4);
++void _wpa_msg(void *ctx, int level, const char *fmt, ...) PRINTF_FORMAT(3, 4);
++#define wpa_msg(ctx, level, ...) \
++ do { \
++ if (level >= CONFIG_MSG_MIN_PRIORITY) \
++ _wpa_msg(ctx, level, __VA_ARGS__); \
++ } while(0)
+
+ /**
+ * wpa_msg_ctrl - Conditional printf for ctrl_iface monitors
+@@ -186,8 +232,13 @@ void wpa_msg(void *ctx, int level, const
+ * attached ctrl_iface monitors. In other words, it can be used for frequent
+ * events that do not need to be sent to syslog.
+ */
+-void wpa_msg_ctrl(void *ctx, int level, const char *fmt, ...)
++void _wpa_msg_ctrl(void *ctx, int level, const char *fmt, ...)
+ PRINTF_FORMAT(3, 4);
++#define wpa_msg_ctrl(ctx, level, ...) \
++ do { \
++ if (level >= CONFIG_MSG_MIN_PRIORITY) \
++ _wpa_msg_ctrl(ctx, level, __VA_ARGS__); \
++ } while(0)
+
+ typedef void (*wpa_msg_cb_func)(void *ctx, int level, const char *txt,
+ size_t len);
diff --git a/package/network/services/hostapd/patches/.svn/text-base/560-indicate-features.patch.svn-base b/package/network/services/hostapd/patches/.svn/text-base/560-indicate-features.patch.svn-base
new file mode 100644
index 0000000..d01e18b
--- /dev/null
+++ b/package/network/services/hostapd/patches/.svn/text-base/560-indicate-features.patch.svn-base
@@ -0,0 +1,82 @@
+--- a/hostapd/main.c
++++ b/hostapd/main.c
+@@ -13,6 +13,7 @@
+
+ #include "utils/common.h"
+ #include "utils/eloop.h"
++#include "utils/build_features.h"
+ #include "crypto/random.h"
+ #include "crypto/tls.h"
+ #include "common/version.h"
+@@ -560,7 +561,7 @@ int main(int argc, char *argv[])
+
+ wpa_supplicant_event = hostapd_wpa_event;
+ for (;;) {
+- c = getopt(argc, argv, "Bde:f:hKP:tvg:");
++ c = getopt(argc, argv, "Bde:f:hKP:tg:v::");
+ if (c < 0)
+ break;
+ switch (c) {
+@@ -592,6 +593,8 @@ int main(int argc, char *argv[])
+ wpa_debug_timestamp++;
+ break;
+ case 'v':
++ if (optarg)
++ exit(!has_feature(optarg));
+ show_version();
+ exit(1);
+ break;
+--- a/wpa_supplicant/main.c
++++ b/wpa_supplicant/main.c
+@@ -12,6 +12,7 @@
+ #endif /* __linux__ */
+
+ #include "common.h"
++#include "build_features.h"
+ #include "wpa_supplicant_i.h"
+ #include "driver_i.h"
+
+@@ -156,7 +157,7 @@ int main(int argc, char *argv[])
+
+ for (;;) {
+ c = getopt(argc, argv,
+- "b:Bc:C:D:de:f:g:hH:i:KLNo:O:p:P:qsTtuvW");
++ "b:Bc:C:D:de:f:g:hH:i:KLNo:O:p:P:qsTtuv::W");
+ if (c < 0)
+ break;
+ switch (c) {
+@@ -248,8 +249,12 @@ int main(int argc, char *argv[])
+ break;
+ #endif /* CONFIG_DBUS */
+ case 'v':
+- printf("%s\n", wpa_supplicant_version);
+- exitcode = 0;
++ if (optarg) {
++ exitcode = !has_feature(optarg);
++ } else {
++ printf("%s\n", wpa_supplicant_version);
++ exitcode = 0;
++ }
+ goto out;
+ case 'W':
+ params.wait_for_monitor++;
+--- /dev/null
++++ b/src/utils/build_features.h
+@@ -0,0 +1,17 @@
++#ifndef BUILD_FEATURES_H
++#define BUILD_FEATURES_H
++
++static inline int has_feature(const char *feat)
++{
++#ifdef IEEE8021X_EAPOL
++ if (!strcmp(feat, "eap"))
++ return 1;
++#endif
++#ifdef IEEE80211N
++ if (!strcmp(feat, "11n"))
++ return 1;
++#endif
++ return 0;
++}
++
++#endif /* BUILD_FEATURES_H */
diff --git a/package/network/services/hostapd/patches/.svn/text-base/570-genl_connect_debug.patch.svn-base b/package/network/services/hostapd/patches/.svn/text-base/570-genl_connect_debug.patch.svn-base
new file mode 100644
index 0000000..5f14048
--- /dev/null
+++ b/package/network/services/hostapd/patches/.svn/text-base/570-genl_connect_debug.patch.svn-base
@@ -0,0 +1,11 @@
+--- a/src/drivers/driver_nl80211.c
++++ b/src/drivers/driver_nl80211.c
+@@ -127,7 +127,7 @@ static struct nl_handle * nl_create_hand
+ }
+
+ if (genl_connect(handle)) {
+- wpa_printf(MSG_ERROR, "nl80211: Failed to connect to generic "
++ wpa_printf(MSG_DEBUG, "nl80211: Failed to connect to generic "
+ "netlink (%s)", dbg);
+ nl80211_handle_destroy(handle);
+ return NULL;
diff --git a/package/network/services/hostapd/patches/.svn/text-base/590-hostapd_cli_ifdef.patch.svn-base b/package/network/services/hostapd/patches/.svn/text-base/590-hostapd_cli_ifdef.patch.svn-base
new file mode 100644
index 0000000..cbf1e48
--- /dev/null
+++ b/package/network/services/hostapd/patches/.svn/text-base/590-hostapd_cli_ifdef.patch.svn-base
@@ -0,0 +1,50 @@
+--- a/hostapd/hostapd_cli.c
++++ b/hostapd/hostapd_cli.c
+@@ -67,7 +67,6 @@ static const char *commands_help =
+ #ifdef CONFIG_IEEE80211W
+ " sa_query <addr> send SA Query to a station\n"
+ #endif /* CONFIG_IEEE80211W */
+-#ifdef CONFIG_WPS
+ " wps_pin <uuid> <pin> [timeout] [addr] add WPS Enrollee PIN\n"
+ " wps_check_pin <PIN> verify PIN checksum\n"
+ " wps_pbc indicate button pushed to initiate PBC\n"
+@@ -79,7 +78,6 @@ static const char *commands_help =
+ #endif /* CONFIG_WPS_NFC */
+ " wps_ap_pin <cmd> [params..] enable/disable AP PIN\n"
+ " wps_config <SSID> <auth> <encr> <key> configure AP\n"
+-#endif /* CONFIG_WPS */
+ " get_config show current configuration\n"
+ " help show this usage help\n"
+ " interface [ifname] show interfaces/select interface\n"
+@@ -340,7 +338,6 @@ static int hostapd_cli_cmd_sa_query(stru
+ #endif /* CONFIG_IEEE80211W */
+
+
+-#ifdef CONFIG_WPS
+ static int hostapd_cli_cmd_wps_pin(struct wpa_ctrl *ctrl, int argc,
+ char *argv[])
+ {
+@@ -559,7 +556,6 @@ static int hostapd_cli_cmd_wps_config(st
+ ssid_hex, argv[1]);
+ return wpa_ctrl_command(ctrl, buf);
+ }
+-#endif /* CONFIG_WPS */
+
+
+ static int hostapd_cli_cmd_disassoc_imminent(struct wpa_ctrl *ctrl, int argc,
+@@ -805,7 +801,6 @@ static struct hostapd_cli_cmd hostapd_cl
+ #ifdef CONFIG_IEEE80211W
+ { "sa_query", hostapd_cli_cmd_sa_query },
+ #endif /* CONFIG_IEEE80211W */
+-#ifdef CONFIG_WPS
+ { "wps_pin", hostapd_cli_cmd_wps_pin },
+ { "wps_check_pin", hostapd_cli_cmd_wps_check_pin },
+ { "wps_pbc", hostapd_cli_cmd_wps_pbc },
+@@ -818,7 +813,6 @@ static struct hostapd_cli_cmd hostapd_cl
+ #endif /* CONFIG_WPS_NFC */
+ { "wps_ap_pin", hostapd_cli_cmd_wps_ap_pin },
+ { "wps_config", hostapd_cli_cmd_wps_config },
+-#endif /* CONFIG_WPS */
+ { "disassoc_imminent", hostapd_cli_cmd_disassoc_imminent },
+ { "ess_disassoc", hostapd_cli_cmd_ess_disassoc },
+ { "get_config", hostapd_cli_cmd_get_config },
diff --git a/package/network/services/hostapd/patches/.svn/text-base/601-wpa_supplicant-add-new-config-params-to-be-used-with.patch.svn-base b/package/network/services/hostapd/patches/.svn/text-base/601-wpa_supplicant-add-new-config-params-to-be-used-with.patch.svn-base
new file mode 100644
index 0000000..977bce4
--- /dev/null
+++ b/package/network/services/hostapd/patches/.svn/text-base/601-wpa_supplicant-add-new-config-params-to-be-used-with.patch.svn-base
@@ -0,0 +1,209 @@
+From 4bb69d15477e0f2b00e166845341dc933de47c58 Mon Sep 17 00:00:00 2001
+From: Antonio Quartulli <ordex@autistici.org>
+Date: Sun, 3 Jun 2012 18:22:56 +0200
+Subject: [PATCHv2 601/602] wpa_supplicant: add new config params to be used
+ with the ibss join command
+
+Signed-hostap: Antonio Quartulli <ordex@autistici.org>
+---
+ src/drivers/driver.h | 6 +++
+ wpa_supplicant/config.c | 96 +++++++++++++++++++++++++++++++++++++++
+ wpa_supplicant/config_ssid.h | 6 +++
+ wpa_supplicant/wpa_supplicant.c | 23 +++++++---
+ 4 files changed, 124 insertions(+), 7 deletions(-)
+
+--- a/src/drivers/driver.h
++++ b/src/drivers/driver.h
+@@ -19,6 +19,7 @@
+
+ #define WPA_SUPPLICANT_DRIVER_VERSION 4
+
++#include "drivers/nl80211_copy.h"
+ #include "common/defs.h"
+
+ #define HOSTAPD_CHAN_DISABLED 0x00000001
+@@ -363,6 +364,11 @@ struct wpa_driver_associate_params {
+ */
+ int freq;
+
++ int beacon_interval;
++ int fixed_freq;
++ unsigned char rates[NL80211_MAX_SUPP_RATES];
++ int mcast_rate;
++
+ /**
+ * bg_scan_period - Background scan period in seconds, 0 to disable
+ * background scan, or -1 to indicate no change to default driver
+--- a/wpa_supplicant/config.c
++++ b/wpa_supplicant/config.c
+@@ -14,6 +14,7 @@
+ #include "rsn_supp/wpa.h"
+ #include "eap_peer/eap.h"
+ #include "p2p/p2p.h"
++#include "drivers/nl80211_copy.h"
+ #include "config.h"
+
+
+@@ -1369,6 +1370,97 @@ static char * wpa_config_write_p2p_clien
+
+ #endif /* CONFIG_P2P */
+
++static int wpa_config_parse_mcast_rate(const struct parse_data *data,
++ struct wpa_ssid *ssid, int line,
++ const char *value)
++{
++ ssid->mcast_rate = (int)(strtod(value, NULL) * 10);
++
++ return 0;
++}
++
++#ifndef NO_CONFIG_WRITE
++static char * wpa_config_write_mcast_rate(const struct parse_data *data,
++ struct wpa_ssid *ssid)
++{
++ char *value;
++ int res;
++
++ if (!ssid->mcast_rate == 0)
++ return NULL;
++
++ value = os_malloc(6); /* longest: 300.0 */
++ if (value == NULL)
++ return NULL;
++ res = os_snprintf(value, 5, "%.1f", (double)ssid->mcast_rate / 10);
++ if (res < 0) {
++ os_free(value);
++ return NULL;
++ }
++ return value;
++}
++#endif /* NO_CONFIG_WRITE */
++
++static int wpa_config_parse_rates(const struct parse_data *data,
++ struct wpa_ssid *ssid, int line,
++ const char *value)
++{
++ int i;
++ char *pos, *r, *sptr, *end;
++ double rate;
++
++ pos = (char *)value;
++ r = strtok_r(pos, ",", &sptr);
++ i = 0;
++ while (pos && i < NL80211_MAX_SUPP_RATES) {
++ rate = 0.0;
++ if (r)
++ rate = strtod(r, &end);
++ ssid->rates[i] = rate * 2;
++ if (*end != '\0' || rate * 2 != ssid->rates[i])
++ return 1;
++
++ i++;
++ r = strtok_r(NULL, ",", &sptr);
++ }
++
++ return 0;
++}
++
++#ifndef NO_CONFIG_WRITE
++static char * wpa_config_write_rates(const struct parse_data *data,
++ struct wpa_ssid *ssid)
++{
++ char *value, *pos;
++ int res, i;
++
++ if (ssid->rates[0] <= 0)
++ return NULL;
++
++ value = os_malloc(6 * NL80211_MAX_SUPP_RATES + 1);
++ if (value == NULL)
++ return NULL;
++ pos = value;
++ for (i = 0; i < NL80211_MAX_SUPP_RATES - 1; i++) {
++ res = os_snprintf(pos, 6, "%.1f,", (double)ssid->rates[i] / 2);
++ if (res < 0) {
++ os_free(value);
++ return NULL;
++ }
++ pos += res;
++ }
++ res = os_snprintf(pos, 6, "%.1f",
++ (double)ssid->rates[NL80211_MAX_SUPP_RATES - 1] / 2);
++ if (res < 0) {
++ os_free(value);
++ return NULL;
++ }
++
++ value[6 * NL80211_MAX_SUPP_RATES] = '\0';
++ return value;
++}
++#endif /* NO_CONFIG_WRITE */
++
+ /* Helper macros for network block parser */
+
+ #ifdef OFFSET
+@@ -1546,6 +1638,9 @@ static const struct parse_data ssid_fiel
+ { INT(ap_max_inactivity) },
+ { INT(dtim_period) },
+ { INT(beacon_int) },
++ { INT_RANGE(fixed_freq, 0, 1) },
++ { FUNC(rates) },
++ { FUNC(mcast_rate) },
+ };
+
+ #undef OFFSET
+--- a/wpa_supplicant/config_ssid.h
++++ b/wpa_supplicant/config_ssid.h
+@@ -11,6 +11,7 @@
+
+ #include "common/defs.h"
+ #include "eap_peer/eap_config.h"
++#include "drivers/nl80211_copy.h"
+
+ #define MAX_SSID_LEN 32
+
+@@ -571,6 +572,10 @@ struct wpa_ssid {
+ * dereferences since it may not be updated in all cases.
+ */
+ void *parent_cred;
++
++ int fixed_freq;
++ unsigned char rates[NL80211_MAX_SUPP_RATES];
++ double mcast_rate;
+ };
+
+ #endif /* CONFIG_SSID_H */
+--- a/wpa_supplicant/wpa_supplicant.c
++++ b/wpa_supplicant/wpa_supplicant.c
+@@ -1570,15 +1570,24 @@ void wpa_supplicant_associate(struct wpa
+ params.ssid_len = ssid->ssid_len;
+ }
+
+- if (ssid->mode == WPAS_MODE_IBSS && ssid->bssid_set &&
+- wpa_s->conf->ap_scan == 2) {
+- params.bssid = ssid->bssid;
+- params.fixed_bssid = 1;
++ if (ssid->mode == WPAS_MODE_IBSS) {
++ if (ssid->bssid_set && wpa_s->conf->ap_scan == 2) {
++ params.bssid = ssid->bssid;
++ params.fixed_bssid = 1;
++ }
++ if (ssid->frequency > 0 && params.freq == 0)
++ /* Initial channel for IBSS */
++ params.freq = ssid->frequency;
++ params.fixed_freq = ssid->fixed_freq;
++ params.beacon_interval = ssid->beacon_int;
++ i = 0;
++ while (i < NL80211_MAX_SUPP_RATES) {
++ params.rates[i] = ssid->rates[i];
++ i++;
++ }
++ params.mcast_rate = ssid->mcast_rate;
+ }
+
+- if (ssid->mode == WPAS_MODE_IBSS && ssid->frequency > 0 &&
+- params.freq == 0)
+- params.freq = ssid->frequency; /* Initial channel for IBSS */
+ params.wpa_ie = wpa_ie;
+ params.wpa_ie_len = wpa_ie_len;
+ params.pairwise_suite = cipher_pairwise;
diff --git a/package/network/services/hostapd/patches/.svn/text-base/602-driver_nl80211-use-new-parameters-during-ibss-join.patch.svn-base b/package/network/services/hostapd/patches/.svn/text-base/602-driver_nl80211-use-new-parameters-during-ibss-join.patch.svn-base
new file mode 100644
index 0000000..bf80185
--- /dev/null
+++ b/package/network/services/hostapd/patches/.svn/text-base/602-driver_nl80211-use-new-parameters-during-ibss-join.patch.svn-base
@@ -0,0 +1,59 @@
+From ffc4445958a3ed4064f2e1bf73fa478a61c5cf7b Mon Sep 17 00:00:00 2001
+From: Antonio Quartulli <ordex@autistici.org>
+Date: Sun, 3 Jun 2012 18:42:25 +0200
+Subject: [PATCHv2 602/602] driver_nl80211: use new parameters during ibss join
+
+Signed-hostap: Antonio Quartulli <ordex@autistici.org>
+---
+ src/drivers/driver_nl80211.c | 33 ++++++++++++++++++++++++++++++++-
+ 1 file changed, 32 insertions(+), 1 deletion(-)
+
+--- a/src/drivers/driver_nl80211.c
++++ b/src/drivers/driver_nl80211.c
+@@ -6806,7 +6806,7 @@ static int wpa_driver_nl80211_ibss(struc
+ struct wpa_driver_associate_params *params)
+ {
+ struct nl_msg *msg;
+- int ret = -1;
++ int ret = -1, i;
+ int count = 0;
+
+ wpa_printf(MSG_DEBUG, "nl80211: Join IBSS (ifindex=%d)", drv->ifindex);
+@@ -6839,6 +6839,37 @@ retry:
+ wpa_printf(MSG_DEBUG, " * freq=%d", params->freq);
+ NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FREQ, params->freq);
+
++ if (params->fixed_freq) {
++ wpa_printf(MSG_DEBUG, " * fixed_freq");
++ NLA_PUT_FLAG(msg, NL80211_ATTR_FREQ_FIXED);
++ }
++
++ if (params->beacon_interval > 0) {
++ wpa_printf(MSG_DEBUG, " * beacon_interval=%d",
++ params->beacon_interval);
++ NLA_PUT_U32(msg, NL80211_ATTR_BEACON_INTERVAL,
++ params->beacon_interval);
++ }
++
++ if (params->rates[0] > 0) {
++ wpa_printf(MSG_DEBUG, " * basic_rates:");
++ i = 0;
++ while (i < NL80211_MAX_SUPP_RATES &&
++ params->rates[i] > 0) {
++ wpa_printf(MSG_DEBUG, " %.1f",
++ (double)params->rates[i] / 2);
++ i++;
++ }
++ NLA_PUT(msg, NL80211_ATTR_BSS_BASIC_RATES, i,
++ params->rates);
++ }
++
++ if (params->mcast_rate > 0) {
++ wpa_printf(MSG_DEBUG, " * mcast_rates=%.1f",
++ (double)params->mcast_rate / 10);
++ NLA_PUT_U32(msg, NL80211_ATTR_MCAST_RATE, params->mcast_rate);
++ }
++
+ ret = nl80211_set_conn_keys(params, msg);
+ if (ret)
+ goto nla_put_failure;
diff --git a/package/network/services/hostapd/patches/.svn/text-base/604-wpa_s-support-htmode-param.patch.svn-base b/package/network/services/hostapd/patches/.svn/text-base/604-wpa_s-support-htmode-param.patch.svn-base
new file mode 100644
index 0000000..00272a5
--- /dev/null
+++ b/package/network/services/hostapd/patches/.svn/text-base/604-wpa_s-support-htmode-param.patch.svn-base
@@ -0,0 +1,156 @@
+From b9329c5dfeed7d5c55d2117d8dfe326fc40c8fb1 Mon Sep 17 00:00:00 2001
+From: Antonio Quartulli <ordex@autistici.org>
+Date: Tue, 3 Jul 2012 00:36:24 +0200
+Subject: [PATCH] wpa_s: support htmode param
+
+possible values are HT20, HT40-, HT40+ and NOHT
+
+Signed-off-by: Antonio Quartulli <ordex@autistici.org>
+---
+ src/drivers/driver.h | 2 ++
+ src/drivers/driver_nl80211.c | 16 ++++++++++
+ wpa_supplicant/config.c | 66 +++++++++++++++++++++++++++++++++++++++
+ wpa_supplicant/config_ssid.h | 2 ++
+ wpa_supplicant/wpa_supplicant.c | 2 ++
+ 5 files changed, 88 insertions(+)
+
+--- a/src/drivers/driver.h
++++ b/src/drivers/driver.h
+@@ -368,6 +368,8 @@ struct wpa_driver_associate_params {
+ int fixed_freq;
+ unsigned char rates[NL80211_MAX_SUPP_RATES];
+ int mcast_rate;
++ int ht_set;
++ unsigned int htmode;
+
+ /**
+ * bg_scan_period - Background scan period in seconds, 0 to disable
+--- a/src/drivers/driver_nl80211.c
++++ b/src/drivers/driver_nl80211.c
+@@ -6870,6 +6870,22 @@ retry:
+ NLA_PUT_U32(msg, NL80211_ATTR_MCAST_RATE, params->mcast_rate);
+ }
+
++ if (params->ht_set) {
++ switch(params->htmode) {
++ case NL80211_CHAN_HT20:
++ wpa_printf(MSG_DEBUG, " * ht=HT20");
++ break;
++ case NL80211_CHAN_HT40PLUS:
++ wpa_printf(MSG_DEBUG, " * ht=HT40+");
++ break;
++ case NL80211_CHAN_HT40MINUS:
++ wpa_printf(MSG_DEBUG, " * ht=HT40-");
++ break;
++ }
++ NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE,
++ params->htmode);
++ }
++
+ ret = nl80211_set_conn_keys(params, msg);
+ if (ret)
+ goto nla_put_failure;
+--- a/wpa_supplicant/config.c
++++ b/wpa_supplicant/config.c
+@@ -1401,6 +1401,71 @@ static char * wpa_config_write_mcast_rat
+ }
+ #endif /* NO_CONFIG_WRITE */
+
++static int wpa_config_parse_htmode(const struct parse_data *data,
++ struct wpa_ssid *ssid, int line,
++ const char *value)
++{
++ int i;
++ static const struct {
++ const char *name;
++ unsigned int val;
++ } htmap[] = {
++ { .name = "HT20", .val = NL80211_CHAN_HT20, },
++ { .name = "HT40+", .val = NL80211_CHAN_HT40PLUS, },
++ { .name = "HT40-", .val = NL80211_CHAN_HT40MINUS, },
++ { .name = "NOHT", .val = NL80211_CHAN_NO_HT, },
++ };
++ ssid->ht_set = 0;;
++ for (i = 0; i < 4; i++) {
++ if (strcasecmp(htmap[i].name, value) == 0) {
++ ssid->htmode = htmap[i].val;
++ ssid->ht_set = 1;
++ break;
++ }
++ }
++
++ return 0;
++}
++
++#ifndef NO_CONFIG_WRITE
++static char * wpa_config_write_htmode(const struct parse_data *data,
++ struct wpa_ssid *ssid)
++{
++ char *value;
++ int res;
++
++ value = os_malloc(6); /* longest: HT40+ */
++ if (value == NULL)
++ return NULL;
++
++ switch(ssid->htmode) {
++ case NL80211_CHAN_HT20:
++ res = os_snprintf(value, 4, "HT20");
++ break;
++ case NL80211_CHAN_HT40PLUS:
++ res = os_snprintf(value, 5, "HT40+");
++ break;
++ case NL80211_CHAN_HT40MINUS:
++ res = os_snprintf(value, 5, "HT40-");
++ break;
++ case NL80211_CHAN_NO_HT:
++ res = os_snprintf(value, 4, "NOHT");
++ break;
++ default:
++ os_free(value);
++ return NULL;
++ }
++
++ if (res < 0) {
++ os_free(value);
++ return NULL;
++ }
++
++ return value;
++}
++#endif /* NO_CONFIG_WRITE */
++
++
+ static int wpa_config_parse_rates(const struct parse_data *data,
+ struct wpa_ssid *ssid, int line,
+ const char *value)
+@@ -1641,6 +1706,7 @@ static const struct parse_data ssid_fiel
+ { INT_RANGE(fixed_freq, 0, 1) },
+ { FUNC(rates) },
+ { FUNC(mcast_rate) },
++ { FUNC(htmode) },
+ };
+
+ #undef OFFSET
+--- a/wpa_supplicant/config_ssid.h
++++ b/wpa_supplicant/config_ssid.h
+@@ -576,6 +576,8 @@ struct wpa_ssid {
+ int fixed_freq;
+ unsigned char rates[NL80211_MAX_SUPP_RATES];
+ double mcast_rate;
++ int ht_set;
++ unsigned int htmode;
+ };
+
+ #endif /* CONFIG_SSID_H */
+--- a/wpa_supplicant/wpa_supplicant.c
++++ b/wpa_supplicant/wpa_supplicant.c
+@@ -1586,6 +1586,8 @@ void wpa_supplicant_associate(struct wpa
+ i++;
+ }
+ params.mcast_rate = ssid->mcast_rate;
++ params.ht_set = ssid->ht_set;
++ params.htmode = ssid->htmode;
+ }
+
+ params.wpa_ie = wpa_ie;
diff --git a/package/network/services/hostapd/patches/.svn/text-base/610-max_num_sta_probe.patch.svn-base b/package/network/services/hostapd/patches/.svn/text-base/610-max_num_sta_probe.patch.svn-base
new file mode 100644
index 0000000..141eb5b
--- /dev/null
+++ b/package/network/services/hostapd/patches/.svn/text-base/610-max_num_sta_probe.patch.svn-base
@@ -0,0 +1,13 @@
+--- a/src/ap/beacon.c
++++ b/src/ap/beacon.c
+@@ -455,6 +455,10 @@ void handle_probe_req(struct hostapd_dat
+ return;
+ }
+
++ if (!sta && hapd->num_sta >= hapd->conf->max_num_sta)
++ wpa_printf(MSG_MSGDUMP, "Probe Request from " MACSTR " ignored,"
++ " too many connected stations.", MAC2STR(mgmt->sa));
++
+ #ifdef CONFIG_INTERWORKING
+ if (elems.interworking && elems.interworking_len >= 1) {
+ u8 ant = elems.interworking[0] & 0x0f;
diff --git a/package/network/services/hostapd/patches/.svn/text-base/620-scan_wait.patch.svn-base b/package/network/services/hostapd/patches/.svn/text-base/620-scan_wait.patch.svn-base
new file mode 100644
index 0000000..d9c7f30
--- /dev/null
+++ b/package/network/services/hostapd/patches/.svn/text-base/620-scan_wait.patch.svn-base
@@ -0,0 +1,65 @@
+--- a/hostapd/main.c
++++ b/hostapd/main.c
+@@ -32,6 +32,8 @@
+ extern int wpa_debug_level;
+ extern int wpa_debug_show_keys;
+ extern int wpa_debug_timestamp;
++static int daemonize = 0;
++static char *pid_file = NULL;
+
+ extern struct wpa_driver_ops *wpa_drivers[];
+
+@@ -146,6 +148,14 @@ static void hostapd_logger_cb(void *ctx,
+ }
+ #endif /* CONFIG_NO_HOSTAPD_LOGGER */
+
++static void hostapd_setup_complete_cb(void *ctx)
++{
++ if (daemonize && os_daemonize(pid_file)) {
++ perror("daemon");
++ return;
++ }
++ daemonize = 0;
++}
+
+ /**
+ * hostapd_init - Allocate and initialize per-interface data
+@@ -189,6 +199,7 @@ static struct hostapd_iface * hostapd_in
+ if (hapd == NULL)
+ goto fail;
+ hapd->msg_ctx = hapd;
++ hapd->setup_complete_cb = hostapd_setup_complete_cb;
+ }
+
+ return hapd_iface;
+@@ -425,8 +436,6 @@ static void hostapd_global_deinit(const
+ #endif /* CONFIG_NATIVE_WINDOWS */
+
+ eap_server_unregister_methods();
+-
+- os_daemonize_terminate(pid_file);
+ }
+
+
+@@ -452,11 +461,6 @@ static int hostapd_global_run(struct hap
+ }
+ #endif /* EAP_SERVER_TNC */
+
+- if (daemonize && os_daemonize(pid_file)) {
+- perror("daemon");
+- return -1;
+- }
+-
+ eloop_run();
+
+ return 0;
+@@ -540,8 +544,7 @@ int main(int argc, char *argv[])
+ struct hapd_interfaces interfaces;
+ int ret = 1;
+ size_t i;
+- int c, debug = 0, daemonize = 0;
+- char *pid_file = NULL;
++ int c, debug = 0;
+ const char *log_file = NULL;
+ const char *entropy_file = NULL;
+
diff --git a/package/network/services/hostapd/patches/300-nl80211_multicall_fixes.patch b/package/network/services/hostapd/patches/300-nl80211_multicall_fixes.patch
new file mode 100644
index 0000000..6c4f46f
--- /dev/null
+++ b/package/network/services/hostapd/patches/300-nl80211_multicall_fixes.patch
@@ -0,0 +1,60 @@
+--- a/src/drivers/driver_nl80211.c
++++ b/src/drivers/driver_nl80211.c
+@@ -3129,6 +3129,7 @@ static void * wpa_driver_nl80211_init(vo
+ drv->monitor_sock = -1;
+ drv->eapol_tx_sock = -1;
+ drv->ap_scan_as_station = NL80211_IFTYPE_UNSPECIFIED;
++ drv->nlmode = NL80211_IFTYPE_STATION;
+
+ if (wpa_driver_nl80211_init_nl(drv)) {
+ os_free(drv);
+@@ -3446,17 +3447,12 @@ static void wpa_driver_nl80211_send_rfki
+ wpa_supplicant_event(timeout_ctx, EVENT_INTERFACE_DISABLED, NULL);
+ }
+
+-
+ static int
+-wpa_driver_nl80211_finish_drv_init(struct wpa_driver_nl80211_data *drv)
++wpa_driver_nl80211_finish_drv_init_sta(struct wpa_driver_nl80211_data *drv,
++ int *send_rfkill_event)
+ {
+ struct i802_bss *bss = &drv->first_bss;
+- int send_rfkill_event = 0;
+
+- drv->ifindex = if_nametoindex(bss->ifname);
+- drv->first_bss.ifindex = drv->ifindex;
+-
+-#ifndef HOSTAPD
+ /*
+ * Make sure the interface starts up in station mode unless this is a
+ * dynamically added interface (e.g., P2P) that was already configured
+@@ -3475,7 +3471,7 @@ wpa_driver_nl80211_finish_drv_init(struc
+ "interface '%s' due to rfkill",
+ bss->ifname);
+ drv->if_disabled = 1;
+- send_rfkill_event = 1;
++ *send_rfkill_event = 1;
+ } else {
+ wpa_printf(MSG_ERROR, "nl80211: Could not set "
+ "interface '%s' UP", bss->ifname);
+@@ -3485,7 +3481,19 @@ wpa_driver_nl80211_finish_drv_init(struc
+
+ netlink_send_oper_ifla(drv->global->netlink, drv->ifindex,
+ 1, IF_OPER_DORMANT);
+-#endif /* HOSTAPD */
++}
++
++static int
++wpa_driver_nl80211_finish_drv_init(struct wpa_driver_nl80211_data *drv)
++{
++ struct i802_bss *bss = &drv->first_bss;
++ int send_rfkill_event = 0;
++
++ drv->ifindex = if_nametoindex(bss->ifname);
++ drv->first_bss.ifindex = drv->ifindex;
++
++ if (drv->nlmode == NL80211_IFTYPE_STATION)
++ wpa_driver_nl80211_finish_drv_init_sta(drv, &send_rfkill_event);
+
+ if (wpa_driver_nl80211_capa(drv))
+ return -1;
diff --git a/package/network/services/hostapd/patches/310-multicall_bridge_fix.patch b/package/network/services/hostapd/patches/310-multicall_bridge_fix.patch
new file mode 100644
index 0000000..e167ba7
--- /dev/null
+++ b/package/network/services/hostapd/patches/310-multicall_bridge_fix.patch
@@ -0,0 +1,45 @@
+--- a/src/drivers/driver_nl80211.c
++++ b/src/drivers/driver_nl80211.c
+@@ -897,6 +897,10 @@ static void wpa_driver_nl80211_event_rtm
+ return;
+ }
+
++ if (ifi->ifi_family == AF_BRIDGE &&
++ drv->nlmode != NL80211_IFTYPE_AP)
++ return;
++
+ wpa_printf(MSG_DEBUG, "RTM_NEWLINK: operstate=%d ifi_flags=0x%x "
+ "(%s%s%s%s)",
+ drv->operstate, ifi->ifi_flags,
+@@ -1004,6 +1008,10 @@ static void wpa_driver_nl80211_event_rtm
+ attrlen = len;
+ attr = (struct rtattr *) buf;
+
++ if (ifi->ifi_family == AF_BRIDGE &&
++ drv->nlmode != NL80211_IFTYPE_AP)
++ return;
++
+ rta_len = RTA_ALIGN(sizeof(struct rtattr));
+ while (RTA_OK(attr, attrlen)) {
+ if (attr->rta_type == IFLA_IFNAME) {
+@@ -3131,6 +3139,11 @@ static void * wpa_driver_nl80211_init(vo
+ drv->ap_scan_as_station = NL80211_IFTYPE_UNSPECIFIED;
+ drv->nlmode = NL80211_IFTYPE_STATION;
+
++#ifdef HOSTAPD
++ drv->num_if_indices = sizeof(drv->default_if_indices) / sizeof(int);
++ drv->if_indices = drv->default_if_indices;
++#endif
++
+ if (wpa_driver_nl80211_init_nl(drv)) {
+ os_free(drv);
+ return NULL;
+@@ -8021,8 +8034,6 @@ static void *i802_init(struct hostapd_da
+ br_ifindex = 0;
+ }
+
+- drv->num_if_indices = sizeof(drv->default_if_indices) / sizeof(int);
+- drv->if_indices = drv->default_if_indices;
+ for (i = 0; i < params->num_bridge; i++) {
+ if (params->bridge[i]) {
+ ifindex = if_nametoindex(params->bridge[i]);
diff --git a/package/network/services/hostapd/patches/320-madwifi_key_fixes.patch b/package/network/services/hostapd/patches/320-madwifi_key_fixes.patch
new file mode 100644
index 0000000..45a7ac6
--- /dev/null
+++ b/package/network/services/hostapd/patches/320-madwifi_key_fixes.patch
@@ -0,0 +1,34 @@
+--- a/src/drivers/driver_madwifi.c
++++ b/src/drivers/driver_madwifi.c
+@@ -453,7 +453,9 @@ wpa_driver_madwifi_set_key(const char *i
+
+ memset(&wk, 0, sizeof(wk));
+ wk.ik_type = cipher;
+- wk.ik_flags = IEEE80211_KEY_RECV | IEEE80211_KEY_XMIT;
++ wk.ik_flags = IEEE80211_KEY_RECV;
++ if (set_tx)
++ wk.ik_flags |= IEEE80211_KEY_XMIT;
+ if (addr == NULL || is_broadcast_ether_addr(addr)) {
+ memset(wk.ik_macaddr, 0xff, IEEE80211_ADDR_LEN);
+ wk.ik_keyix = key_idx;
+@@ -465,6 +467,20 @@ wpa_driver_madwifi_set_key(const char *i
+ wk.ik_keylen = key_len;
+ memcpy(wk.ik_keydata, key, key_len);
+
++#ifdef WORDS_BIGENDIAN
++#define WPA_KEY_RSC_LEN 8
++ {
++ size_t i;
++ u8 tmp[WPA_KEY_RSC_LEN];
++ os_memset(tmp, 0, sizeof(tmp));
++ for (i = 0; i < seq_len; i++)
++ tmp[WPA_KEY_RSC_LEN - i - 1] = seq[i];
++ os_memcpy(&wk.ik_keyrsc, tmp, WPA_KEY_RSC_LEN);
++ }
++#else /* WORDS_BIGENDIAN */
++ os_memcpy(&wk.ik_keyrsc, seq, seq_len);
++#endif /* WORDS_BIGENDIAN */
++
+ ret = set80211priv(drv, IEEE80211_IOCTL_SETKEY, &wk, sizeof(wk));
+ if (ret < 0) {
+ wpa_printf(MSG_DEBUG, "%s: Failed to set key (addr %s"
diff --git a/package/network/services/hostapd/patches/330-fix_reassoc_after_ack_failure.patch b/package/network/services/hostapd/patches/330-fix_reassoc_after_ack_failure.patch
new file mode 100644
index 0000000..a91e4ae
--- /dev/null
+++ b/package/network/services/hostapd/patches/330-fix_reassoc_after_ack_failure.patch
@@ -0,0 +1,11 @@
+--- a/src/ap/sta_info.c
++++ b/src/ap/sta_info.c
+@@ -576,7 +576,7 @@ void ap_sta_disassociate(struct hostapd_
+ {
+ wpa_printf(MSG_DEBUG, "%s: disassociate STA " MACSTR,
+ hapd->conf->iface, MAC2STR(sta->addr));
+- sta->flags &= ~WLAN_STA_ASSOC;
++ sta->flags &= ~(WLAN_STA_ASSOC | WLAN_STA_ASSOC_REQ_OK);
+ ap_sta_set_authorized(hapd, sta, 0);
+ sta->timeout_next = STA_DEAUTH;
+ wpa_printf(MSG_DEBUG, "%s: reschedule ap_handle_timer timeout "
diff --git a/package/network/services/hostapd/patches/400-noscan.patch b/package/network/services/hostapd/patches/400-noscan.patch
new file mode 100644
index 0000000..b1b25ff
--- /dev/null
+++ b/package/network/services/hostapd/patches/400-noscan.patch
@@ -0,0 +1,32 @@
+--- a/hostapd/config_file.c
++++ b/hostapd/config_file.c
+@@ -2464,6 +2464,8 @@ static int hostapd_config_fill(struct ho
+ }
+ #endif /* CONFIG_IEEE80211W */
+ #ifdef CONFIG_IEEE80211N
++ } else if (os_strcmp(buf, "noscan") == 0) {
++ conf->noscan = atoi(pos);
+ } else if (os_strcmp(buf, "ieee80211n") == 0) {
+ conf->ieee80211n = atoi(pos);
+ } else if (os_strcmp(buf, "ht_capab") == 0) {
+--- a/src/ap/ap_config.h
++++ b/src/ap/ap_config.h
+@@ -510,6 +510,7 @@ struct hostapd_config {
+
+ int ht_op_mode_fixed;
+ u16 ht_capab;
++ int noscan;
+ int ieee80211n;
+ int secondary_channel;
+ int require_ht;
+--- a/src/ap/hw_features.c
++++ b/src/ap/hw_features.c
+@@ -494,7 +494,7 @@ static int ieee80211n_check_40mhz(struct
+ {
+ struct wpa_driver_scan_params params;
+
+- if (!iface->conf->secondary_channel)
++ if (!iface->conf->secondary_channel || iface->conf->noscan)
+ return 0; /* HT40 not used */
+
+ wpa_printf(MSG_DEBUG, "Scan for neighboring BSSes prior to enabling "
diff --git a/package/network/services/hostapd/patches/410-multicall.patch b/package/network/services/hostapd/patches/410-multicall.patch
new file mode 100644
index 0000000..4c6f8c9
--- /dev/null
+++ b/package/network/services/hostapd/patches/410-multicall.patch
@@ -0,0 +1,246 @@
+--- a/hostapd/Makefile
++++ b/hostapd/Makefile
+@@ -14,6 +14,7 @@ CFLAGS += -I../src/utils
+ # CFLAGS += -DUSE_KERNEL_HEADERS -I/usr/src/linux/include
+
+ -include .config
++-include $(if $(MULTICALL), ../wpa_supplicant/.config)
+
+ ifndef CONFIG_OS
+ ifdef CONFIG_NATIVE_WINDOWS
+@@ -192,10 +193,14 @@ ifdef CONFIG_IEEE80211AC
+ CFLAGS += -DCONFIG_IEEE80211AC
+ endif
+
++ifndef MULTICALL
++CFLAGS += -DNO_SUPPLICANT
++endif
++
+ include ../src/drivers/drivers.mak
+-OBJS += $(DRV_AP_OBJS)
+-CFLAGS += $(DRV_AP_CFLAGS)
+-LDFLAGS += $(DRV_AP_LDFLAGS)
++OBJS += $(sort $(DRV_AP_OBJS) $(if $(MULTICALL),$(DRV_WPA_OBJS)))
++CFLAGS += $(DRV_AP_CFLAGS) $(if $(MULTICALL),$(DRV_WPA_CFLAGS))
++LDFLAGS += $(DRV_AP_LDFLAGS) $(if $(MULTICALL),$(DRV_WPA_LDFLAGS))
+ LIBS += $(DRV_AP_LIBS)
+
+ ifdef CONFIG_L2_PACKET
+@@ -860,6 +865,12 @@ install: all
+
+ BCHECK=../src/drivers/build.hostapd
+
++hostapd_multi.a: $(BCHECK) $(OBJS)
++ $(Q)$(CC) -c -o hostapd_multi.o -Dmain=hostapd_main $(CFLAGS) main.c
++ @$(E) " CC " $<
++ @rm -f $@
++ @$(AR) cr $@ hostapd_multi.o $(OBJS)
++
+ hostapd: $(BCHECK) $(OBJS)
+ $(Q)$(CC) $(LDFLAGS) -o hostapd $(OBJS) $(LIBS)
+ @$(E) " LD " $@
+@@ -898,6 +909,12 @@ HOBJS += ../src/crypto/aes-internal.o
+ HOBJS += ../src/crypto/aes-internal-enc.o
+ endif
+
++dump_cflags:
++ @echo -n $(CFLAGS) " "
++
++dump_ldflags:
++ @echo -n $(LDFLAGS) $(LIBS) $(EXTRALIBS) " "
++
+ nt_password_hash: $(NOBJS)
+ $(Q)$(CC) $(LDFLAGS) -o nt_password_hash $(NOBJS) $(LIBS_n)
+ @$(E) " LD " $@
+--- a/wpa_supplicant/Makefile
++++ b/wpa_supplicant/Makefile
+@@ -14,6 +14,7 @@ CFLAGS += -I../src
+ CFLAGS += -I../src/utils
+
+ -include .config
++-include $(if $(MULTICALL),../hostapd/.config)
+
+ BINALL=wpa_supplicant wpa_cli
+
+@@ -704,6 +705,10 @@ ifdef CONFIG_DYNAMIC_EAP_METHODS
+ CFLAGS += -DCONFIG_DYNAMIC_EAP_METHODS
+ LIBS += -ldl -rdynamic
+ endif
++else
++ ifdef MULTICALL
++ OBJS += ../src/eap_common/eap_common.o
++ endif
+ endif
+
+ ifdef CONFIG_AP
+@@ -712,9 +717,11 @@ NEED_EAP_COMMON=y
+ NEED_RSN_AUTHENTICATOR=y
+ CFLAGS += -DCONFIG_AP
+ OBJS += ap.o
++ifndef MULTICALL
+ CFLAGS += -DCONFIG_NO_RADIUS
+ CFLAGS += -DCONFIG_NO_ACCOUNTING
+ CFLAGS += -DCONFIG_NO_VLAN
++endif
+ OBJS += ../src/ap/hostapd.o
+ OBJS += ../src/ap/wpa_auth_glue.o
+ OBJS += ../src/ap/utils.o
+@@ -769,10 +776,18 @@ endif
+ ifdef CONFIG_HS20
+ OBJS += ../src/ap/hs20.o
+ endif
++else
++ ifdef MULTICALL
++ OBJS += ../src/eap_server/eap_server.o
++ OBJS += ../src/eap_server/eap_server_identity.o
++ OBJS += ../src/eap_server/eap_server_methods.o
++ endif
+ endif
+
+ ifdef NEED_RSN_AUTHENTICATOR
++ifndef MULTICALL
+ CFLAGS += -DCONFIG_NO_RADIUS
++endif
+ NEED_AES_WRAP=y
+ OBJS += ../src/ap/wpa_auth.o
+ OBJS += ../src/ap/wpa_auth_ie.o
+@@ -1521,6 +1536,12 @@ wpa_priv: $(BCHECK) $(OBJS_priv)
+
+ $(OBJS_c) $(OBJS_t) $(OBJS_t2) $(OBJS) $(BCHECK) $(EXTRA_progs): .config
+
++wpa_supplicant_multi.a: .config $(BCHECK) $(OBJS) $(EXTRA_progs)
++ $(Q)$(CC) -c -o wpa_supplicant_multi.o -Dmain=wpa_supplicant_main $(CFLAGS) main.c
++ @$(E) " CC " $<
++ @rm -f $@
++ @$(AR) cr $@ wpa_supplicant_multi.o $(OBJS)
++
+ wpa_supplicant: $(BCHECK) $(OBJS) $(EXTRA_progs)
+ $(Q)$(LDO) $(LDFLAGS) -o wpa_supplicant $(OBJS) $(LIBS) $(EXTRALIBS)
+ @$(E) " LD " $@
+@@ -1591,6 +1612,12 @@ eap_ikev2.so: ../src/eap_peer/eap_ikev2.
+ %@.service: %.service.arg.in
+ sed -e 's|\@BINDIR\@|$(BINDIR)|g' $< >$@
+
++dump_cflags:
++ @echo -n $(CFLAGS) " "
++
++dump_ldflags:
++ @echo -n $(LDFLAGS) $(LIBS) $(EXTRALIBS) " "
++
+ wpa_supplicant.exe: wpa_supplicant
+ mv -f $< $@
+ wpa_cli.exe: wpa_cli
+--- a/src/drivers/driver.h
++++ b/src/drivers/driver.h
+@@ -3726,8 +3726,8 @@ union wpa_event_data {
+ * Driver wrapper code should call this function whenever an event is received
+ * from the driver.
+ */
+-void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
+- union wpa_event_data *data);
++extern void (*wpa_supplicant_event)(void *ctx, enum wpa_event_type event,
++ union wpa_event_data *data);
+
+
+ /*
+--- a/src/ap/drv_callbacks.c
++++ b/src/ap/drv_callbacks.c
+@@ -714,8 +714,8 @@ static void hostapd_event_eapol_rx(struc
+ }
+
+
+-void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
+- union wpa_event_data *data)
++void hostapd_wpa_event(void *ctx, enum wpa_event_type event,
++ union wpa_event_data *data)
+ {
+ struct hostapd_data *hapd = ctx;
+ #ifndef CONFIG_NO_STDOUT_DEBUG
+--- a/wpa_supplicant/wpa_priv.c
++++ b/wpa_supplicant/wpa_priv.c
+@@ -819,8 +819,8 @@ static void wpa_priv_send_ft_response(st
+ }
+
+
+-void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
+- union wpa_event_data *data)
++static void supplicant_event(void *ctx, enum wpa_event_type event,
++ union wpa_event_data *data)
+ {
+ struct wpa_priv_interface *iface = ctx;
+
+@@ -962,6 +962,7 @@ int main(int argc, char *argv[])
+ if (os_program_init())
+ return -1;
+
++ wpa_supplicant_event = supplicant_event;
+ wpa_priv_fd_workaround();
+
+ for (;;) {
+--- a/wpa_supplicant/events.c
++++ b/wpa_supplicant/events.c
+@@ -2333,8 +2333,8 @@ static void wpa_supplicant_event_unprot_
+ }
+
+
+-void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
+- union wpa_event_data *data)
++void supplicant_event(void *ctx, enum wpa_event_type event,
++ union wpa_event_data *data)
+ {
+ struct wpa_supplicant *wpa_s = ctx;
+ u16 reason_code = 0;
+--- a/wpa_supplicant/wpa_supplicant.c
++++ b/wpa_supplicant/wpa_supplicant.c
+@@ -2972,6 +2972,9 @@ static void wpa_supplicant_deinit_iface(
+ }
+ }
+
++extern void supplicant_event(void *ctx, enum wpa_event_type event,
++ union wpa_event_data *data);
++
+
+ /**
+ * wpa_supplicant_add_iface - Add a new network interface
+@@ -3164,6 +3167,7 @@ struct wpa_global * wpa_supplicant_init(
+ wpa_msg_register_ifname_cb(wpa_supplicant_msg_ifname_cb);
+ #endif /* CONFIG_NO_WPA_MSG */
+
++ wpa_supplicant_event = supplicant_event;
+ wpa_debug_open_file(params->wpa_debug_file_path);
+ if (params->wpa_debug_syslog)
+ wpa_debug_open_syslog();
+--- a/hostapd/main.c
++++ b/hostapd/main.c
+@@ -530,6 +530,9 @@ static int hostapd_get_global_ctrl_iface
+ return 0;
+ }
+
++void hostapd_wpa_event(void *ctx, enum wpa_event_type event,
++ union wpa_event_data *data);
++
+
+ int main(int argc, char *argv[])
+ {
+@@ -555,6 +558,7 @@ int main(int argc, char *argv[])
+ interfaces.global_iface_name = NULL;
+ interfaces.global_ctrl_sock = -1;
+
++ wpa_supplicant_event = hostapd_wpa_event;
+ for (;;) {
+ c = getopt(argc, argv, "Bde:f:hKP:tvg:");
+ if (c < 0)
+--- a/src/drivers/drivers.c
++++ b/src/drivers/drivers.c
+@@ -7,7 +7,11 @@
+ */
+
+ #include "includes.h"
++#include "common.h"
++#include "driver.h"
+
++void (*wpa_supplicant_event)(void *ctx, enum wpa_event_type event,
++ union wpa_event_data *data);
+
+ #ifdef CONFIG_DRIVER_WEXT
+ extern struct wpa_driver_ops wpa_driver_wext_ops; /* driver_wext.c */
diff --git a/package/network/services/hostapd/patches/420-timestamp_check.patch b/package/network/services/hostapd/patches/420-timestamp_check.patch
new file mode 100644
index 0000000..b2d4a05
--- /dev/null
+++ b/package/network/services/hostapd/patches/420-timestamp_check.patch
@@ -0,0 +1,12 @@
+--- a/src/tls/x509v3.c
++++ b/src/tls/x509v3.c
+@@ -1848,6 +1848,9 @@ int x509_certificate_chain_validate(stru
+ if (chain_trusted)
+ continue;
+
++#ifdef NO_TIMESTAMP_CHECK
++ disable_time_checks = 1;
++#endif
+ if (!disable_time_checks &&
+ ((unsigned long) now.sec <
+ (unsigned long) cert->not_before ||
diff --git a/package/network/services/hostapd/patches/430-rescan_immediately.patch b/package/network/services/hostapd/patches/430-rescan_immediately.patch
new file mode 100644
index 0000000..082344a
--- /dev/null
+++ b/package/network/services/hostapd/patches/430-rescan_immediately.patch
@@ -0,0 +1,11 @@
+--- a/wpa_supplicant/wpa_supplicant.c
++++ b/wpa_supplicant/wpa_supplicant.c
+@@ -2416,7 +2416,7 @@ static struct wpa_supplicant * wpa_suppl
+ if (wpa_s == NULL)
+ return NULL;
+ wpa_s->scan_req = INITIAL_SCAN_REQ;
+- wpa_s->scan_interval = 5;
++ wpa_s->scan_interval = 1;
+ wpa_s->new_connection = 1;
+ wpa_s->parent = wpa_s;
+ wpa_s->sched_scanning = 0;
diff --git a/package/network/services/hostapd/patches/440-optional_rfkill.patch b/package/network/services/hostapd/patches/440-optional_rfkill.patch
new file mode 100644
index 0000000..8ed4d99
--- /dev/null
+++ b/package/network/services/hostapd/patches/440-optional_rfkill.patch
@@ -0,0 +1,261 @@
+--- a/src/drivers/driver_nl80211.c
++++ b/src/drivers/driver_nl80211.c
+@@ -218,7 +218,9 @@ struct wpa_driver_nl80211_data {
+ int if_removed;
+ int if_disabled;
+ int ignore_if_down_event;
++#ifdef CONFIG_RFKILL
+ struct rfkill_data *rfkill;
++#endif
+ struct wpa_driver_capa capa;
+ int has_capability;
+
+@@ -2967,7 +2969,7 @@ static int wpa_driver_nl80211_init_nl(st
+ return 0;
+ }
+
+-
++#ifdef CONFIG_RFKILL
+ static void wpa_driver_nl80211_rfkill_blocked(void *ctx)
+ {
+ wpa_printf(MSG_DEBUG, "nl80211: RFKILL blocked");
+@@ -2990,6 +2992,7 @@ static void wpa_driver_nl80211_rfkill_un
+ }
+ /* rtnetlink ifup handler will report interface as enabled */
+ }
++#endif /* CONFIG_RFKILL */
+
+
+ static void nl80211_get_phy_name(struct wpa_driver_nl80211_data *drv)
+@@ -3118,7 +3121,9 @@ static void * wpa_driver_nl80211_init(vo
+ void *global_priv)
+ {
+ struct wpa_driver_nl80211_data *drv;
++#ifdef CONFIG_RFKILL
+ struct rfkill_config *rcfg;
++#endif
+ struct i802_bss *bss;
+
+ if (global_priv == NULL)
+@@ -3154,6 +3159,7 @@ static void * wpa_driver_nl80211_init(vo
+
+ nl80211_get_phy_name(drv);
+
++#ifdef CONFIG_RFKILL
+ rcfg = os_zalloc(sizeof(*rcfg));
+ if (rcfg == NULL)
+ goto failed;
+@@ -3166,6 +3172,7 @@ static void * wpa_driver_nl80211_init(vo
+ wpa_printf(MSG_DEBUG, "nl80211: RFKILL status not available");
+ os_free(rcfg);
+ }
++#endif /* CONFIG_RFKILL */
+
+ if (wpa_driver_nl80211_finish_drv_init(drv))
+ goto failed;
+@@ -3455,10 +3462,12 @@ static void nl80211_mgmt_unsubscribe(str
+ }
+
+
++#ifdef CONFIG_RFKILL
+ static void wpa_driver_nl80211_send_rfkill(void *eloop_ctx, void *timeout_ctx)
+ {
+ wpa_supplicant_event(timeout_ctx, EVENT_INTERFACE_DISABLED, NULL);
+ }
++#endif /* CONFIG_RFKILL */
+
+ static int
+ wpa_driver_nl80211_finish_drv_init_sta(struct wpa_driver_nl80211_data *drv,
+@@ -3479,13 +3488,16 @@ wpa_driver_nl80211_finish_drv_init_sta(s
+ }
+
+ if (linux_set_iface_flags(drv->global->ioctl_sock, bss->ifname, 1)) {
++#ifdef CONFIG_RFKILL
+ if (rfkill_is_blocked(drv->rfkill)) {
+ wpa_printf(MSG_DEBUG, "nl80211: Could not yet enable "
+ "interface '%s' due to rfkill",
+ bss->ifname);
+ drv->if_disabled = 1;
+ *send_rfkill_event = 1;
+- } else {
++ } else
++#endif
++ {
+ wpa_printf(MSG_ERROR, "nl80211: Could not set "
+ "interface '%s' UP", bss->ifname);
+ return -1;
+@@ -3516,8 +3528,10 @@ wpa_driver_nl80211_finish_drv_init(struc
+ return -1;
+
+ if (send_rfkill_event) {
++#ifdef CONFIG_RFKILL
+ eloop_register_timeout(0, 0, wpa_driver_nl80211_send_rfkill,
+ drv, drv->ctx);
++#endif
+ }
+
+ return 0;
+@@ -3603,7 +3617,9 @@ static void wpa_driver_nl80211_deinit(st
+
+ netlink_send_oper_ifla(drv->global->netlink, drv->ifindex, 0,
+ IF_OPER_UP);
++#ifdef CONFIG_RFKILL
+ rfkill_deinit(drv->rfkill);
++#endif
+
+ eloop_cancel_timeout(wpa_driver_nl80211_scan_timeout, drv, drv->ctx);
+
+--- a/src/drivers/driver_wext.c
++++ b/src/drivers/driver_wext.c
+@@ -742,7 +742,7 @@ static void wpa_driver_wext_event_rtm_de
+ }
+ }
+
+-
++#ifdef CONFIG_RFKILL
+ static void wpa_driver_wext_rfkill_blocked(void *ctx)
+ {
+ wpa_printf(MSG_DEBUG, "WEXT: RFKILL blocked");
+@@ -764,7 +764,7 @@ static void wpa_driver_wext_rfkill_unblo
+ }
+ /* rtnetlink ifup handler will report interface as enabled */
+ }
+-
++#endif /* CONFIG_RFKILL */
+
+ static void wext_get_phy_name(struct wpa_driver_wext_data *drv)
+ {
+@@ -810,7 +810,9 @@ void * wpa_driver_wext_init(void *ctx, c
+ {
+ struct wpa_driver_wext_data *drv;
+ struct netlink_config *cfg;
++#ifdef CONFIG_RFKILL
+ struct rfkill_config *rcfg;
++#endif
+ char path[128];
+ struct stat buf;
+
+@@ -845,6 +847,7 @@ void * wpa_driver_wext_init(void *ctx, c
+ goto err2;
+ }
+
++#ifdef CONFIG_RFKILL
+ rcfg = os_zalloc(sizeof(*rcfg));
+ if (rcfg == NULL)
+ goto err3;
+@@ -857,6 +860,7 @@ void * wpa_driver_wext_init(void *ctx, c
+ wpa_printf(MSG_DEBUG, "WEXT: RFKILL status not available");
+ os_free(rcfg);
+ }
++#endif /* CONFIG_RFKILL */
+
+ drv->mlme_sock = -1;
+
+@@ -874,7 +878,9 @@ void * wpa_driver_wext_init(void *ctx, c
+ return drv;
+
+ err3:
++#ifdef CONFIG_RFKILL
+ rfkill_deinit(drv->rfkill);
++#endif
+ netlink_deinit(drv->netlink);
+ err2:
+ close(drv->ioctl_sock);
+@@ -884,10 +890,12 @@ err1:
+ }
+
+
++#ifdef CONFIG_RFKILL
+ static void wpa_driver_wext_send_rfkill(void *eloop_ctx, void *timeout_ctx)
+ {
+ wpa_supplicant_event(timeout_ctx, EVENT_INTERFACE_DISABLED, NULL);
+ }
++#endif /* CONFIG_RFKILL */
+
+
+ static int wpa_driver_wext_finish_drv_init(struct wpa_driver_wext_data *drv)
+@@ -895,13 +903,16 @@ static int wpa_driver_wext_finish_drv_in
+ int send_rfkill_event = 0;
+
+ if (linux_set_iface_flags(drv->ioctl_sock, drv->ifname, 1) < 0) {
++#ifdef CONFIG_RFKILL
+ if (rfkill_is_blocked(drv->rfkill)) {
+ wpa_printf(MSG_DEBUG, "WEXT: Could not yet enable "
+ "interface '%s' due to rfkill",
+ drv->ifname);
+ drv->if_disabled = 1;
+ send_rfkill_event = 1;
+- } else {
++ } else
++#endif
++ {
+ wpa_printf(MSG_ERROR, "WEXT: Could not set "
+ "interface '%s' UP", drv->ifname);
+ return -1;
+@@ -949,8 +960,10 @@ static int wpa_driver_wext_finish_drv_in
+ 1, IF_OPER_DORMANT);
+
+ if (send_rfkill_event) {
++#ifdef CONFIG_RFKILL
+ eloop_register_timeout(0, 0, wpa_driver_wext_send_rfkill,
+ drv, drv->ctx);
++#endif
+ }
+
+ return 0;
+@@ -980,7 +993,9 @@ void wpa_driver_wext_deinit(void *priv)
+
+ netlink_send_oper_ifla(drv->netlink, drv->ifindex, 0, IF_OPER_UP);
+ netlink_deinit(drv->netlink);
++#ifdef CONFIG_RFKILL
+ rfkill_deinit(drv->rfkill);
++#endif
+
+ if (drv->mlme_sock >= 0)
+ eloop_unregister_read_sock(drv->mlme_sock);
+--- a/src/drivers/drivers.mak
++++ b/src/drivers/drivers.mak
+@@ -25,7 +25,6 @@ NEED_SME=y
+ NEED_AP_MLME=y
+ NEED_NETLINK=y
+ NEED_LINUX_IOCTL=y
+-NEED_RFKILL=y
+
+ ifdef CONFIG_LIBNL32
+ DRV_LIBS += -lnl-3
+@@ -109,7 +108,6 @@ DRV_WPA_CFLAGS += -DCONFIG_DRIVER_WEXT
+ CONFIG_WIRELESS_EXTENSION=y
+ NEED_NETLINK=y
+ NEED_LINUX_IOCTL=y
+-NEED_RFKILL=y
+ endif
+
+ ifdef CONFIG_DRIVER_NDIS
+@@ -135,7 +133,6 @@ endif
+ ifdef CONFIG_WIRELESS_EXTENSION
+ DRV_WPA_CFLAGS += -DCONFIG_WIRELESS_EXTENSION
+ DRV_WPA_OBJS += ../src/drivers/driver_wext.o
+-NEED_RFKILL=y
+ endif
+
+ ifdef NEED_NETLINK
+@@ -148,6 +145,7 @@ endif
+
+ ifdef NEED_RFKILL
+ DRV_OBJS += ../src/drivers/rfkill.o
++DRV_WPA_CFLAGS += -DCONFIG_RFKILL
+ endif
+
+ ifdef CONFIG_VLAN_NETLINK
+--- a/src/drivers/driver_wext.h
++++ b/src/drivers/driver_wext.h
+@@ -22,7 +22,9 @@ struct wpa_driver_wext_data {
+ int ifindex2;
+ int if_removed;
+ int if_disabled;
++#ifdef CONFIG_RFKILL
+ struct rfkill_data *rfkill;
++#endif
+ u8 *assoc_req_ies;
+ size_t assoc_req_ies_len;
+ u8 *assoc_resp_ies;
diff --git a/package/network/services/hostapd/patches/450-reload_freq_change.patch b/package/network/services/hostapd/patches/450-reload_freq_change.patch
new file mode 100644
index 0000000..bf48fe4
--- /dev/null
+++ b/package/network/services/hostapd/patches/450-reload_freq_change.patch
@@ -0,0 +1,27 @@
+--- a/src/ap/hostapd.c
++++ b/src/ap/hostapd.c
+@@ -140,6 +140,24 @@ int hostapd_reload_config(struct hostapd
+ oldconf = hapd->iconf;
+ iface->conf = newconf;
+
++ hostapd_select_hw_mode(iface);
++ iface->freq = hostapd_hw_get_freq(hapd, newconf->channel);
++
++ if (hostapd_set_freq(hapd, newconf->hw_mode, iface->freq,
++ newconf->channel,
++ newconf->ieee80211n,
++ newconf->ieee80211ac,
++ newconf->secondary_channel,
++ newconf->vht_oper_chwidth,
++ newconf->vht_oper_centr_freq_seg0_idx,
++ newconf->vht_oper_centr_freq_seg1_idx)) {
++ wpa_printf(MSG_ERROR, "Could not set channel for "
++ "kernel driver");
++ }
++
++ if (iface->current_mode)
++ hostapd_prepare_rates(iface, iface->current_mode);
++
+ for (j = 0; j < iface->num_bss; j++) {
+ hapd = iface->bss[j];
+ hapd->iconf = newconf;
diff --git a/package/network/services/hostapd/patches/451-nl80211_del_beacon_bss.patch b/package/network/services/hostapd/patches/451-nl80211_del_beacon_bss.patch
new file mode 100644
index 0000000..2eaa5dc
--- /dev/null
+++ b/package/network/services/hostapd/patches/451-nl80211_del_beacon_bss.patch
@@ -0,0 +1,63 @@
+--- a/src/drivers/driver_nl80211.c
++++ b/src/drivers/driver_nl80211.c
+@@ -3538,16 +3538,18 @@ wpa_driver_nl80211_finish_drv_init(struc
+ }
+
+
+-static int wpa_driver_nl80211_del_beacon(struct wpa_driver_nl80211_data *drv)
++static int wpa_driver_nl80211_del_bss_beacon(struct i802_bss *bss)
+ {
++ struct wpa_driver_nl80211_data *drv = bss->drv;
+ struct nl_msg *msg;
+
++ bss->beacon_set = 0;
+ msg = nlmsg_alloc();
+ if (!msg)
+ return -ENOMEM;
+
+ nl80211_cmd(drv, msg, 0, NL80211_CMD_DEL_BEACON);
+- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, drv->ifindex);
++ NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, bss->ifindex);
+
+ return send_and_recv_msgs(drv, msg, NULL, NULL);
+ nla_put_failure:
+@@ -3555,6 +3557,21 @@ static int wpa_driver_nl80211_del_beacon
+ return -ENOBUFS;
+ }
+
++static int wpa_driver_nl80211_del_beacon(struct wpa_driver_nl80211_data *drv)
++{
++ struct i802_bss *bss;
++
++ for (bss = &drv->first_bss; bss; bss = bss->next)
++ wpa_driver_nl80211_del_bss_beacon(bss);
++
++ return 0;
++}
++
++static int wpa_driver_nl80211_stop_ap(void *priv)
++{
++ struct i802_bss *bss = priv;
++ return wpa_driver_nl80211_del_beacon(bss->drv);
++}
+
+ /**
+ * wpa_driver_nl80211_deinit - Deinitialize nl80211 driver interface
+@@ -9547,4 +9564,5 @@ const struct wpa_driver_ops wpa_driver_n
+ .send_tdls_mgmt = nl80211_send_tdls_mgmt,
+ .tdls_oper = nl80211_tdls_oper,
+ #endif /* CONFIG_TDLS */
++ .stop_ap = wpa_driver_nl80211_stop_ap,
+ };
+--- a/src/drivers/driver.h
++++ b/src/drivers/driver.h
+@@ -2071,6 +2071,9 @@ struct wpa_driver_ops {
+ */
+ int (*probe_req_report)(void *priv, int report);
+
++
++ int (*stop_ap)(void *priv);
++
+ /**
+ * deinit_ap - Deinitialize AP mode
+ * @priv: Private driver interface data
diff --git a/package/network/services/hostapd/patches/452-ctrl_iface_reload.patch b/package/network/services/hostapd/patches/452-ctrl_iface_reload.patch
new file mode 100644
index 0000000..85e871f
--- /dev/null
+++ b/package/network/services/hostapd/patches/452-ctrl_iface_reload.patch
@@ -0,0 +1,98 @@
+--- a/hostapd/ctrl_iface.c
++++ b/hostapd/ctrl_iface.c
+@@ -33,6 +33,7 @@
+ #include "wps/wps.h"
+ #include "config_file.h"
+ #include "ctrl_iface.h"
++#include "config_file.h"
+
+
+ struct wpa_ctrl_dst {
+@@ -43,6 +44,7 @@ struct wpa_ctrl_dst {
+ int errors;
+ };
+
++static char *reload_opts = NULL;
+
+ static void hostapd_ctrl_iface_send(struct hostapd_data *hapd, int level,
+ const char *buf, size_t len);
+@@ -152,6 +154,68 @@ static int hostapd_ctrl_iface_new_sta(st
+ return 0;
+ }
+
++static int hostapd_ctrl_iface_set_down(struct hostapd_data *hapd)
++{
++ if (hapd->driver->stop_ap)
++ hapd->driver->stop_ap(hapd->drv_priv);
++ return 0;
++}
++
++static char *get_option(char *opt, char *str)
++{
++ int len = strlen(str);
++
++ if (!strncmp(opt, str, len))
++ return opt + len;
++ else
++ return NULL;
++}
++
++static struct hostapd_config *hostapd_ctrl_iface_config_read(const char *fname)
++{
++ struct hostapd_config *conf;
++ char *opt, *val;
++
++ conf = hostapd_config_read(fname);
++ if (!conf)
++ return NULL;
++
++ for (opt = strtok(reload_opts, " ");
++ opt;
++ opt = strtok(NULL, " ")) {
++
++ if ((val = get_option(opt, "channel=")))
++ conf->channel = atoi(val);
++ else if ((val = get_option(opt, "ht_capab=")))
++ conf->ht_capab = atoi(val);
++ else if ((val = get_option(opt, "ht_capab_mask=")))
++ conf->ht_capab &= atoi(val);
++ else if ((val = get_option(opt, "sec_chan=")))
++ conf->secondary_channel = atoi(val);
++ else if ((val = get_option(opt, "hw_mode=")))
++ conf->hw_mode = atoi(val);
++ else if ((val = get_option(opt, "ieee80211n=")))
++ conf->ieee80211n = atoi(val);
++ else
++ break;
++ }
++
++ return conf;
++}
++
++static int hostapd_ctrl_iface_update(struct hostapd_data *hapd, char *txt)
++{
++ struct hostapd_config * (*config_read_cb)(const char *config_fname);
++ struct hostapd_iface *iface = hapd->iface;
++
++ config_read_cb = iface->interfaces->config_read_cb;
++ iface->interfaces->config_read_cb = hostapd_ctrl_iface_config_read;
++ reload_opts = txt;
++
++ hostapd_reload_config(iface);
++
++ iface->interfaces->config_read_cb = config_read_cb;
++}
+
+ #ifdef CONFIG_IEEE80211W
+ #ifdef NEED_AP_MLME
+@@ -902,6 +966,10 @@ static void hostapd_ctrl_iface_receive(i
+ reply_len += res;
+ }
+ #endif /* CONFIG_NO_RADIUS */
++ } else if (os_strcmp(buf, "DOWN") == 0) {
++ hostapd_ctrl_iface_set_down(hapd);
++ } else if (os_strncmp(buf, "UPDATE ", 7) == 0) {
++ hostapd_ctrl_iface_update(hapd, buf + 7);
+ } else if (os_strcmp(buf, "STA-FIRST") == 0) {
+ reply_len = hostapd_ctrl_iface_sta_first(hapd, reply,
+ reply_size);
diff --git a/package/network/services/hostapd/patches/453-ap_sta_support.patch b/package/network/services/hostapd/patches/453-ap_sta_support.patch
new file mode 100644
index 0000000..df04d3d
--- /dev/null
+++ b/package/network/services/hostapd/patches/453-ap_sta_support.patch
@@ -0,0 +1,222 @@
+--- a/wpa_supplicant/wpa_supplicant_i.h
++++ b/wpa_supplicant/wpa_supplicant_i.h
+@@ -96,6 +96,8 @@ struct wpa_interface {
+ * receiving of EAPOL frames from an additional interface.
+ */
+ const char *bridge_ifname;
++
++ const char *hostapd_ctrl;
+ };
+
+ /**
+@@ -305,6 +307,8 @@ struct wpa_supplicant {
+ #endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
+ char bridge_ifname[16];
+
++ struct wpa_ctrl *hostapd;
++
+ char *confname;
+ struct wpa_config *conf;
+ int countermeasures;
+--- a/wpa_supplicant/Makefile
++++ b/wpa_supplicant/Makefile
+@@ -13,6 +13,10 @@ PKG_CONFIG ?= pkg-config
+ CFLAGS += -I../src
+ CFLAGS += -I../src/utils
+
++ifdef MULTICALL
++CFLAGS += -DMULTICALL
++endif
++
+ -include .config
+ -include $(if $(MULTICALL),../hostapd/.config)
+
+@@ -76,6 +80,10 @@ OBJS_c = wpa_cli.o ../src/common/wpa_ctr
+ OBJS_c += ../src/utils/wpa_debug.o
+ OBJS_c += ../src/utils/common.o
+
++ifdef MULTICALL
++OBJS += ../src/common/wpa_ctrl.o
++endif
++
+ ifndef CONFIG_OS
+ ifdef CONFIG_NATIVE_WINDOWS
+ CONFIG_OS=win32
+--- a/wpa_supplicant/wpa_supplicant.c
++++ b/wpa_supplicant/wpa_supplicant.c
+@@ -107,6 +107,55 @@ extern int wpa_debug_show_keys;
+ extern int wpa_debug_timestamp;
+ extern struct wpa_driver_ops *wpa_drivers[];
+
++#ifdef MULTICALL
++static int hostapd_stop(struct wpa_supplicant *wpa_s)
++{
++ const char *cmd = "DOWN";
++ char buf[256];
++ int len = sizeof(buf);
++
++ if (wpa_ctrl_request(wpa_s->hostapd, cmd, os_strlen(cmd), buf, &len, NULL) < 0) {
++ wpa_printf(MSG_ERROR, "\nFailed to stop hostapd AP interfaces\n");
++ return -1;
++ }
++ return 0;
++}
++
++static int hostapd_reload(struct wpa_supplicant *wpa_s, struct wpa_bss *bss)
++{
++ char *cmd = NULL;
++ char buf[256];
++ int len = sizeof(buf);
++ int channel, hw_mode;
++ int ret;
++
++ if (!bss)
++ return;
++
++ if (bss->freq < 4000) {
++ hw_mode = HOSTAPD_MODE_IEEE80211G;
++ channel = (bss->freq - 2407) / 5;
++ } else {
++ hw_mode = HOSTAPD_MODE_IEEE80211A;
++ channel = (bss->freq - 5000) / 5;
++ }
++
++ if (asprintf(&cmd, "UPDATE channel=%d sec_chan=0 hw_mode=%d ieee80211n=%d",
++ channel, hw_mode, !!bss->ht_capab) < 0) {
++ return -1;
++ }
++
++ ret = wpa_ctrl_request(wpa_s->hostapd, cmd, os_strlen(cmd), buf, &len, NULL);
++ free(cmd);
++
++ if (ret < 0) {
++ wpa_printf(MSG_ERROR, "\nFailed to reload hostapd AP interfaces\n");
++ return -1;
++ }
++ return 0;
++}
++#endif
++
+ /* Configure default/group WEP keys for static WEP */
+ int wpa_set_wep_keys(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid)
+ {
+@@ -676,8 +725,16 @@ void wpa_supplicant_set_state(struct wpa
+ #endif /* CONFIG_P2P */
+
+ sme_sched_obss_scan(wpa_s, 1);
++#ifdef MULTICALL
++ if (wpa_s->hostapd)
++ hostapd_reload(wpa_s, wpa_s->current_bss);
++#endif
+ } else if (state == WPA_DISCONNECTED || state == WPA_ASSOCIATING ||
+ state == WPA_ASSOCIATED) {
++#ifdef MULTICALL
++ if (wpa_s->hostapd)
++ hostapd_stop(wpa_s);
++#endif
+ wpa_s->new_connection = 1;
+ wpa_drv_set_operstate(wpa_s, 0);
+ #ifndef IEEE8021X_EAPOL
+@@ -2778,6 +2835,21 @@ static int wpa_supplicant_init_iface(str
+ os_strlcpy(wpa_s->bridge_ifname, iface->bridge_ifname,
+ sizeof(wpa_s->bridge_ifname));
+ }
++#ifdef MULTICALL
++ if (iface->hostapd_ctrl) {
++ char *cmd = "DOWN";
++ char buf[256];
++ int len = sizeof(buf);
++
++ wpa_s->hostapd = wpa_ctrl_open(iface->hostapd_ctrl);
++ if (!wpa_s->hostapd) {
++ wpa_printf(MSG_ERROR, "\nFailed to connect to hostapd\n");
++ return -1;
++ }
++ if (hostapd_stop(wpa_s) < 0)
++ return -1;
++ }
++#endif
+
+ /* RSNA Supplicant Key Management - INITIALIZE */
+ eapol_sm_notify_portEnabled(wpa_s->eapol, FALSE);
+--- a/wpa_supplicant/bss.c
++++ b/wpa_supplicant/bss.c
+@@ -11,6 +11,7 @@
+ #include "utils/common.h"
+ #include "utils/eloop.h"
+ #include "common/ieee802_11_defs.h"
++#include "common/ieee802_11_common.h"
+ #include "drivers/driver.h"
+ #include "wpa_supplicant_i.h"
+ #include "config.h"
+@@ -227,6 +228,8 @@ struct wpa_bss * wpa_bss_get(struct wpa_
+ static void wpa_bss_copy_res(struct wpa_bss *dst, struct wpa_scan_res *src,
+ struct os_time *fetch_time)
+ {
++ struct ieee80211_ht_capabilities *capab;
++ struct ieee802_11_elems elems;
+ os_time_t usec;
+
+ dst->flags = src->flags;
+@@ -239,6 +242,12 @@ static void wpa_bss_copy_res(struct wpa_
+ dst->level = src->level;
+ dst->tsf = src->tsf;
+
++ memset(&elems, 0, sizeof(elems));
++ ieee802_11_parse_elems((u8 *) (src + 1), src->ie_len, &elems, 0);
++ capab = (struct ieee80211_ht_capabilities *) elems.ht_capabilities;
++ if (capab)
++ dst->ht_capab = le_to_host16(capab->ht_capabilities_info);
++
+ dst->last_update.sec = fetch_time->sec;
+ dst->last_update.usec = fetch_time->usec;
+ dst->last_update.sec -= src->age / 1000;
+--- a/wpa_supplicant/main.c
++++ b/wpa_supplicant/main.c
+@@ -25,7 +25,7 @@ static void usage(void)
+ "usage:\n"
+ " wpa_supplicant [-BddhKLqqstuvW] [-P<pid file>] "
+ "[-g<global ctrl>] \\\n"
+- " -i<ifname> -c<config file> [-C<ctrl>] [-D<driver>] "
++ " -i<ifname> -c<config file> [-C<ctrl>] [-D<driver>] [-H<hostapd path>]"
+ "[-p<driver_param>] \\\n"
+ " [-b<br_ifname>] [-f<debug file>] [-e<entropy file>] "
+ "\\\n"
+@@ -67,6 +67,7 @@ static void usage(void)
+ #endif /* CONFIG_DEBUG_LINUX_TRACING */
+ printf(" -t = include timestamp in debug messages\n"
+ " -h = show this help text\n"
++ " -H = connect to a hostapd instance to manage state changes\n"
+ " -L = show license (BSD)\n"
+ " -o = override driver parameter for new interfaces\n"
+ " -O = override ctrl_interface parameter for new interfaces\n"
+@@ -155,7 +156,7 @@ int main(int argc, char *argv[])
+
+ for (;;) {
+ c = getopt(argc, argv,
+- "b:Bc:C:D:de:f:g:hi:KLNo:O:p:P:qsTtuvW");
++ "b:Bc:C:D:de:f:g:hH:i:KLNo:O:p:P:qsTtuvW");
+ if (c < 0)
+ break;
+ switch (c) {
+@@ -199,6 +200,9 @@ int main(int argc, char *argv[])
+ usage();
+ exitcode = 0;
+ goto out;
++ case 'H':
++ iface->hostapd_ctrl = optarg;
++ break;
+ case 'i':
+ iface->ifname = optarg;
+ break;
+--- a/wpa_supplicant/bss.h
++++ b/wpa_supplicant/bss.h
+@@ -69,6 +69,8 @@ struct wpa_bss {
+ u8 ssid[32];
+ /** Length of SSID */
+ size_t ssid_len;
++ /** HT caapbilities */
++ u16 ht_capab;
+ /** Frequency of the channel in MHz (e.g., 2412 = channel 1) */
+ int freq;
+ /** Beacon interval in TUs (host byte order) */
diff --git a/package/network/services/hostapd/patches/460-disable_ctrl_iface_mib.patch b/package/network/services/hostapd/patches/460-disable_ctrl_iface_mib.patch
new file mode 100644
index 0000000..e5db6b4
--- /dev/null
+++ b/package/network/services/hostapd/patches/460-disable_ctrl_iface_mib.patch
@@ -0,0 +1,168 @@
+--- a/hostapd/Makefile
++++ b/hostapd/Makefile
+@@ -136,6 +136,9 @@ endif
+ ifdef CONFIG_NO_CTRL_IFACE
+ CFLAGS += -DCONFIG_NO_CTRL_IFACE
+ else
++ifdef CONFIG_CTRL_IFACE_MIB
++CFLAGS += -DCONFIG_CTRL_IFACE_MIB
++endif
+ OBJS += ctrl_iface.o
+ OBJS += ../src/ap/ctrl_iface_ap.o
+ endif
+--- a/hostapd/ctrl_iface.c
++++ b/hostapd/ctrl_iface.c
+@@ -937,6 +937,7 @@ static void hostapd_ctrl_iface_receive(i
+ } else if (os_strncmp(buf, "RELOG", 5) == 0) {
+ if (wpa_debug_reopen_file() < 0)
+ reply_len = -1;
++#ifdef CONFIG_CTRL_IFACE_MIB
+ } else if (os_strcmp(buf, "MIB") == 0) {
+ reply_len = ieee802_11_get_mib(hapd, reply, reply_size);
+ if (reply_len >= 0) {
+@@ -966,10 +967,12 @@ static void hostapd_ctrl_iface_receive(i
+ reply_len += res;
+ }
+ #endif /* CONFIG_NO_RADIUS */
++#endif
+ } else if (os_strcmp(buf, "DOWN") == 0) {
+ hostapd_ctrl_iface_set_down(hapd);
+ } else if (os_strncmp(buf, "UPDATE ", 7) == 0) {
+ hostapd_ctrl_iface_update(hapd, buf + 7);
++#ifdef CONFIG_CTRL_IFACE_MIB
+ } else if (os_strcmp(buf, "STA-FIRST") == 0) {
+ reply_len = hostapd_ctrl_iface_sta_first(hapd, reply,
+ reply_size);
+@@ -979,6 +982,7 @@ static void hostapd_ctrl_iface_receive(i
+ } else if (os_strncmp(buf, "STA-NEXT ", 9) == 0) {
+ reply_len = hostapd_ctrl_iface_sta_next(hapd, buf + 9, reply,
+ reply_size);
++#endif
+ } else if (os_strcmp(buf, "ATTACH") == 0) {
+ if (hostapd_ctrl_iface_attach(hapd, &from, fromlen))
+ reply_len = -1;
+--- a/wpa_supplicant/Makefile
++++ b/wpa_supplicant/Makefile
+@@ -754,6 +754,9 @@ ifdef CONFIG_WNM
+ OBJS += ../src/ap/wnm_ap.o
+ endif
+ ifdef CONFIG_CTRL_IFACE
++ifdef CONFIG_CTRL_IFACE_MIB
++CFLAGS += -DCONFIG_CTRL_IFACE_MIB
++endif
+ OBJS += ../src/ap/ctrl_iface_ap.o
+ endif
+
+--- a/wpa_supplicant/ctrl_iface.c
++++ b/wpa_supplicant/ctrl_iface.c
+@@ -4933,6 +4933,7 @@ char * wpa_supplicant_ctrl_iface_process
+ reply_len = -1;
+ } else if (os_strncmp(buf, "NOTE ", 5) == 0) {
+ wpa_printf(MSG_INFO, "NOTE: %s", buf + 5);
++#ifdef CONFIG_CTRL_IFACE_MIB
+ } else if (os_strcmp(buf, "MIB") == 0) {
+ reply_len = wpa_sm_get_mib(wpa_s->wpa, reply, reply_size);
+ if (reply_len >= 0) {
+@@ -4944,6 +4945,7 @@ char * wpa_supplicant_ctrl_iface_process
+ else
+ reply_len += res;
+ }
++#endif
+ } else if (os_strncmp(buf, "STATUS", 6) == 0) {
+ reply_len = wpa_supplicant_ctrl_iface_status(
+ wpa_s, buf + 6, reply, reply_size);
+@@ -5350,6 +5352,7 @@ char * wpa_supplicant_ctrl_iface_process
+ reply_len = wpa_supplicant_ctrl_iface_bss(
+ wpa_s, buf + 4, reply, reply_size);
+ #ifdef CONFIG_AP
++#ifdef CONFIG_CTRL_IFACE_MIB
+ } else if (os_strcmp(buf, "STA-FIRST") == 0) {
+ reply_len = ap_ctrl_iface_sta_first(wpa_s, reply, reply_size);
+ } else if (os_strncmp(buf, "STA ", 4) == 0) {
+@@ -5358,6 +5361,7 @@ char * wpa_supplicant_ctrl_iface_process
+ } else if (os_strncmp(buf, "STA-NEXT ", 9) == 0) {
+ reply_len = ap_ctrl_iface_sta_next(wpa_s, buf + 9, reply,
+ reply_size);
++#endif
+ } else if (os_strncmp(buf, "DEAUTHENTICATE ", 15) == 0) {
+ if (ap_ctrl_iface_sta_deauthenticate(wpa_s, buf + 15))
+ reply_len = -1;
+--- a/src/ap/ctrl_iface_ap.c
++++ b/src/ap/ctrl_iface_ap.c
+@@ -20,6 +20,7 @@
+ #include "ctrl_iface_ap.h"
+ #include "ap_drv_ops.h"
+
++#ifdef CONFIG_CTRL_IFACE_MIB
+
+ static int hostapd_get_sta_conn_time(struct sta_info *sta,
+ char *buf, size_t buflen)
+@@ -129,6 +130,7 @@ int hostapd_ctrl_iface_sta_next(struct h
+ return hostapd_ctrl_iface_sta_mib(hapd, sta->next, buf, buflen);
+ }
+
++#endif
+
+ #ifdef CONFIG_P2P_MANAGER
+ static int p2p_manager_disconnect(struct hostapd_data *hapd, u16 stype,
+@@ -303,3 +305,4 @@ int hostapd_ctrl_iface_disassociate(stru
+
+ return 0;
+ }
++
+--- a/src/ap/ieee802_1x.c
++++ b/src/ap/ieee802_1x.c
+@@ -2048,6 +2048,7 @@ static const char * bool_txt(Boolean boo
+ return bool ? "TRUE" : "FALSE";
+ }
+
++#ifdef CONFIG_CTRL_IFACE_MIB
+
+ int ieee802_1x_get_mib(struct hostapd_data *hapd, char *buf, size_t buflen)
+ {
+@@ -2200,6 +2201,7 @@ int ieee802_1x_get_mib_sta(struct hostap
+ return len;
+ }
+
++#endif
+
+ static void ieee802_1x_finished(struct hostapd_data *hapd,
+ struct sta_info *sta, int success)
+--- a/src/ap/wpa_auth.c
++++ b/src/ap/wpa_auth.c
+@@ -2687,6 +2687,7 @@ static const char * wpa_bool_txt(int boo
+ return bool ? "TRUE" : "FALSE";
+ }
+
++#ifdef CONFIG_CTRL_IFACE_MIB
+
+ #define RSN_SUITE "%02x-%02x-%02x-%d"
+ #define RSN_SUITE_ARG(s) \
+@@ -2831,7 +2832,7 @@ int wpa_get_mib_sta(struct wpa_state_mac
+
+ return len;
+ }
+-
++#endif
+
+ void wpa_auth_countermeasures_start(struct wpa_authenticator *wpa_auth)
+ {
+--- a/src/rsn_supp/wpa.c
++++ b/src/rsn_supp/wpa.c
+@@ -1848,6 +1848,8 @@ static u32 wpa_key_mgmt_suite(struct wpa
+ }
+
+
++#ifdef CONFIG_CTRL_IFACE_MIB
++
+ #define RSN_SUITE "%02x-%02x-%02x-%d"
+ #define RSN_SUITE_ARG(s) \
+ ((s) >> 24) & 0xff, ((s) >> 16) & 0xff, ((s) >> 8) & 0xff, (s) & 0xff
+@@ -1931,6 +1933,7 @@ int wpa_sm_get_mib(struct wpa_sm *sm, ch
+
+ return (int) len;
+ }
++#endif
+ #endif /* CONFIG_CTRL_IFACE */
+
+
diff --git a/package/network/services/hostapd/patches/470-wpa_ie_cap_workaround.patch b/package/network/services/hostapd/patches/470-wpa_ie_cap_workaround.patch
new file mode 100644
index 0000000..974ec3d
--- /dev/null
+++ b/package/network/services/hostapd/patches/470-wpa_ie_cap_workaround.patch
@@ -0,0 +1,56 @@
+--- a/src/common/wpa_common.c
++++ b/src/common/wpa_common.c
+@@ -965,6 +965,31 @@ const char * wpa_key_mgmt_txt(int key_mg
+ }
+
+
++static void wpa_fixup_wpa_ie_rsn(u8 *assoc_ie, const u8 *wpa_msg_ie,
++ size_t rsn_ie_len)
++{
++ int pos, count;
++
++ pos = sizeof(struct rsn_ie_hdr) + RSN_SELECTOR_LEN;
++ if (rsn_ie_len < pos + 2)
++ return;
++
++ count = WPA_GET_LE16(wpa_msg_ie + pos);
++ pos += 2 + count * RSN_SELECTOR_LEN;
++ if (rsn_ie_len < pos + 2)
++ return;
++
++ count = WPA_GET_LE16(wpa_msg_ie + pos);
++ pos += 2 + count * RSN_SELECTOR_LEN;
++ if (rsn_ie_len < pos + 2)
++ return;
++
++ if (!assoc_ie[pos] && !assoc_ie[pos + 1] &&
++ (wpa_msg_ie[pos] || wpa_msg_ie[pos + 1]))
++ memcpy(&assoc_ie[pos], &wpa_msg_ie[pos], 2);
++}
++
++
+ int wpa_compare_rsn_ie(int ft_initial_assoc,
+ const u8 *ie1, size_t ie1len,
+ const u8 *ie2, size_t ie2len)
+@@ -972,8 +997,19 @@ int wpa_compare_rsn_ie(int ft_initial_as
+ if (ie1 == NULL || ie2 == NULL)
+ return -1;
+
+- if (ie1len == ie2len && os_memcmp(ie1, ie2, ie1len) == 0)
+- return 0; /* identical IEs */
++ if (ie1len == ie2len) {
++ u8 *ie_tmp;
++
++ if (os_memcmp(ie1, ie2, ie1len) == 0)
++ return 0; /* identical IEs */
++
++ ie_tmp = alloca(ie1len);
++ memcpy(ie_tmp, ie1, ie1len);
++ wpa_fixup_wpa_ie_rsn(ie_tmp, ie2, ie1len);
++
++ if (os_memcmp(ie_tmp, ie2, ie1len) == 0)
++ return 0; /* only mismatch in RSN capabilties */
++ }
+
+ #ifdef CONFIG_IEEE80211R
+ if (ft_initial_assoc) {
diff --git a/package/network/services/hostapd/patches/480-terminate_on_setup_failure.patch b/package/network/services/hostapd/patches/480-terminate_on_setup_failure.patch
new file mode 100644
index 0000000..f9d7425
--- /dev/null
+++ b/package/network/services/hostapd/patches/480-terminate_on_setup_failure.patch
@@ -0,0 +1,81 @@
+--- a/src/ap/hostapd.c
++++ b/src/ap/hostapd.c
+@@ -895,11 +895,8 @@ int hostapd_setup_interface_complete(str
+ size_t j;
+ u8 *prev_addr;
+
+- if (err) {
+- wpa_printf(MSG_ERROR, "Interface initialization failed");
+- eloop_terminate();
+- return -1;
+- }
++ if (err)
++ goto error;
+
+ wpa_printf(MSG_DEBUG, "Completing interface initialization");
+ if (hapd->iconf->channel) {
+@@ -919,7 +916,7 @@ int hostapd_setup_interface_complete(str
+ hapd->iconf->vht_oper_centr_freq_seg1_idx)) {
+ wpa_printf(MSG_ERROR, "Could not set channel for "
+ "kernel driver");
+- return -1;
++ goto error;
+ }
+ }
+
+@@ -930,7 +927,7 @@ int hostapd_setup_interface_complete(str
+ hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE80211,
+ HOSTAPD_LEVEL_WARNING,
+ "Failed to prepare rates table.");
+- return -1;
++ goto error;
+ }
+ }
+
+@@ -938,14 +935,14 @@ int hostapd_setup_interface_complete(str
+ hostapd_set_rts(hapd, hapd->iconf->rts_threshold)) {
+ wpa_printf(MSG_ERROR, "Could not set RTS threshold for "
+ "kernel driver");
+- return -1;
++ goto error;
+ }
+
+ if (hapd->iconf->fragm_threshold > -1 &&
+ hostapd_set_frag(hapd, hapd->iconf->fragm_threshold)) {
+ wpa_printf(MSG_ERROR, "Could not set fragmentation threshold "
+ "for kernel driver");
+- return -1;
++ goto error;
+ }
+
+ prev_addr = hapd->own_addr;
+@@ -955,7 +952,7 @@ int hostapd_setup_interface_complete(str
+ if (j)
+ os_memcpy(hapd->own_addr, prev_addr, ETH_ALEN);
+ if (hostapd_setup_bss(hapd, j == 0))
+- return -1;
++ goto error;
+ if (hostapd_mac_comp_empty(hapd->conf->bssid) == 0)
+ prev_addr = hapd->own_addr;
+ }
+@@ -967,7 +964,7 @@ int hostapd_setup_interface_complete(str
+ if (hostapd_driver_commit(hapd) < 0) {
+ wpa_printf(MSG_ERROR, "%s: Failed to commit driver "
+ "configuration", __func__);
+- return -1;
++ goto error;
+ }
+
+ /*
+@@ -988,6 +985,11 @@ int hostapd_setup_interface_complete(str
+ iface->bss[0]->conf->iface);
+
+ return 0;
++
++error:
++ wpa_printf(MSG_ERROR, "Interface initialization failed");
++ eloop_terminate();
++ return -1;
+ }
+
+
diff --git a/package/network/services/hostapd/patches/500-random_pool_add_kernel.patch b/package/network/services/hostapd/patches/500-random_pool_add_kernel.patch
new file mode 100644
index 0000000..2280537
--- /dev/null
+++ b/package/network/services/hostapd/patches/500-random_pool_add_kernel.patch
@@ -0,0 +1,176 @@
+--- a/src/crypto/random.c
++++ b/src/crypto/random.c
+@@ -25,6 +25,7 @@
+ #include "utils/includes.h"
+ #ifdef __linux__
+ #include <fcntl.h>
++#include <sys/stat.h>
+ #endif /* __linux__ */
+
+ #include "utils/common.h"
+@@ -33,6 +34,8 @@
+ #include "sha1.h"
+ #include "random.h"
+
++#define RANDOM_STAMPFILE "/var/run/.random_available"
++
+ #define POOL_WORDS 32
+ #define POOL_WORDS_MASK (POOL_WORDS - 1)
+ #define POOL_TAP1 26
+@@ -43,6 +46,8 @@
+ #define EXTRACT_LEN 16
+ #define MIN_READY_MARK 2
+
++#ifndef CONFIG_NO_RANDOM_POOL
++
+ static u32 pool[POOL_WORDS];
+ static unsigned int input_rotate = 0;
+ static unsigned int pool_pos = 0;
+@@ -123,7 +128,7 @@ static void random_extract(u8 *out)
+ }
+
+
+-void random_add_randomness(const void *buf, size_t len)
++static void random_pool_add_randomness(const void *buf, size_t len)
+ {
+ struct os_time t;
+ static unsigned int count = 0;
+@@ -213,16 +218,22 @@ int random_get_bytes(void *buf, size_t l
+ int random_pool_ready(void)
+ {
+ #ifdef __linux__
++ struct stat st;
+ int fd;
+ ssize_t res;
+
++ if (stat(RANDOM_STAMPFILE, &st) == 0)
++ return 1;
++
+ /*
+ * Make sure that there is reasonable entropy available before allowing
+ * some key derivation operations to proceed.
+ */
+
+- if (dummy_key_avail == sizeof(dummy_key))
++ if (dummy_key_avail == sizeof(dummy_key)) {
++ random_mark_pool_ready();
+ return 1; /* Already initialized - good to continue */
++ }
+
+ /*
+ * Try to fetch some more data from the kernel high quality
+@@ -257,6 +268,7 @@ int random_pool_ready(void)
+ if (dummy_key_avail == sizeof(dummy_key)) {
+ if (own_pool_ready < MIN_READY_MARK)
+ own_pool_ready = MIN_READY_MARK;
++ random_mark_pool_ready();
+ random_write_entropy();
+ return 1;
+ }
+@@ -269,6 +281,7 @@ int random_pool_ready(void)
+ total_collected + 10 * own_pool_ready > MIN_COLLECT_ENTROPY) {
+ wpa_printf(MSG_INFO, "random: Allow operation to proceed "
+ "based on internal entropy");
++ random_mark_pool_ready();
+ return 1;
+ }
+
+@@ -284,10 +297,16 @@ int random_pool_ready(void)
+
+ void random_mark_pool_ready(void)
+ {
++ int fd;
++
+ own_pool_ready++;
+ wpa_printf(MSG_DEBUG, "random: Mark internal entropy pool to be "
+ "ready (count=%u/%u)", own_pool_ready, MIN_READY_MARK);
+ random_write_entropy();
++
++ fd = open(RANDOM_STAMPFILE, O_CREAT | O_WRONLY | O_EXCL | O_NOFOLLOW, 0600);
++ if (fd >= 0)
++ close(fd);
+ }
+
+
+@@ -444,3 +463,22 @@ void random_deinit(void)
+ os_free(random_entropy_file);
+ random_entropy_file = NULL;
+ }
++
++#endif /* CONFIG_NO_RANDOM_POOL */
++
++
++void random_add_randomness(const void *buf, size_t len)
++{
++#ifdef __linux__
++ int fd;
++
++ fd = open("/dev/random", O_RDWR);
++ if (fd >= 0) {
++ write(fd, buf, len);
++ close(fd);
++ }
++#endif
++#ifndef CONFIG_NO_RANDOM_POOL
++ random_pool_add_randomness(buf, len);
++#endif
++}
+--- a/wpa_supplicant/Makefile
++++ b/wpa_supplicant/Makefile
+@@ -1222,9 +1222,8 @@ endif
+
+ ifdef CONFIG_NO_RANDOM_POOL
+ CFLAGS += -DCONFIG_NO_RANDOM_POOL
+-else
+-OBJS += ../src/crypto/random.o
+ endif
++OBJS += ../src/crypto/random.o
+
+ ifdef CONFIG_CTRL_IFACE
+ ifeq ($(CONFIG_CTRL_IFACE), y)
+--- a/wpa_supplicant/Android.mk
++++ b/wpa_supplicant/Android.mk
+@@ -1162,9 +1162,8 @@ endif
+
+ ifdef CONFIG_NO_RANDOM_POOL
+ L_CFLAGS += -DCONFIG_NO_RANDOM_POOL
+-else
+-OBJS += src/crypto/random.c
+ endif
++OBJS += src/crypto/random.c
+
+ ifdef CONFIG_CTRL_IFACE
+ ifeq ($(CONFIG_CTRL_IFACE), y)
+--- a/hostapd/Android.mk
++++ b/hostapd/Android.mk
+@@ -745,11 +745,11 @@ endif
+ ifdef CONFIG_NO_RANDOM_POOL
+ L_CFLAGS += -DCONFIG_NO_RANDOM_POOL
+ else
+-OBJS += src/crypto/random.c
+-HOBJS += src/crypto/random.c
+ HOBJS += $(SHA1OBJS)
+ HOBJS += src/crypto/md5.c
+ endif
++OBJS += src/crypto/random.c
++HOBJS += src/crypto/random.c
+
+ ifdef CONFIG_RADIUS_SERVER
+ L_CFLAGS += -DRADIUS_SERVER
+--- a/hostapd/Makefile
++++ b/hostapd/Makefile
+@@ -748,12 +748,12 @@ endif
+ ifdef CONFIG_NO_RANDOM_POOL
+ CFLAGS += -DCONFIG_NO_RANDOM_POOL
+ else
+-OBJS += ../src/crypto/random.o
+-HOBJS += ../src/crypto/random.o
+ HOBJS += ../src/utils/eloop.o
+ HOBJS += $(SHA1OBJS)
+ HOBJS += ../src/crypto/md5.o
+ endif
++OBJS += ../src/crypto/random.o
++HOBJS += ../src/crypto/random.o
+
+ ifdef CONFIG_RADIUS_SERVER
+ CFLAGS += -DRADIUS_SERVER
diff --git a/package/network/services/hostapd/patches/510-bring_down_interface.patch b/package/network/services/hostapd/patches/510-bring_down_interface.patch
new file mode 100644
index 0000000..1288e9e
--- /dev/null
+++ b/package/network/services/hostapd/patches/510-bring_down_interface.patch
@@ -0,0 +1,19 @@
+--- a/src/drivers/driver_nl80211.c
++++ b/src/drivers/driver_nl80211.c
+@@ -7346,8 +7346,6 @@ static int wpa_driver_nl80211_set_mode(s
+ ret = nl80211_set_mode(drv, drv->ifindex, nlmode);
+ if (ret == -EACCES)
+ break;
+- res = linux_set_iface_flags(drv->global->ioctl_sock,
+- bss->ifname, 1);
+ if (res && !ret)
+ ret = -1;
+ else if (ret != -EBUSY)
+@@ -7363,6 +7361,7 @@ static int wpa_driver_nl80211_set_mode(s
+ "interface is down");
+ drv->nlmode = nlmode;
+ drv->ignore_if_down_event = 1;
++ linux_set_iface_flags(drv->global->ioctl_sock, bss->ifname, 1);
+ }
+
+ done:
diff --git a/package/network/services/hostapd/patches/520-fix_wps_pin_crash.patch b/package/network/services/hostapd/patches/520-fix_wps_pin_crash.patch
new file mode 100644
index 0000000..80d562c
--- /dev/null
+++ b/package/network/services/hostapd/patches/520-fix_wps_pin_crash.patch
@@ -0,0 +1,12 @@
+--- a/hostapd/ctrl_iface.c
++++ b/hostapd/ctrl_iface.c
+@@ -479,6 +479,9 @@ static int hostapd_ctrl_iface_wps_ap_pin
+ char *pos;
+ const char *pin_txt;
+
++ if (!hapd->wps)
++ return -1;
++
+ pos = os_strchr(txt, ' ');
+ if (pos)
+ *pos++ = '\0';
diff --git a/package/network/services/hostapd/patches/530-wps_single_auth_enc_type.patch b/package/network/services/hostapd/patches/530-wps_single_auth_enc_type.patch
new file mode 100644
index 0000000..51c7669
--- /dev/null
+++ b/package/network/services/hostapd/patches/530-wps_single_auth_enc_type.patch
@@ -0,0 +1,25 @@
+--- a/src/ap/wps_hostapd.c
++++ b/src/ap/wps_hostapd.c
+@@ -871,11 +871,9 @@ int hostapd_init_wps(struct hostapd_data
+
+ if (conf->rsn_pairwise & WPA_CIPHER_CCMP)
+ wps->encr_types |= WPS_ENCR_AES;
+- if (conf->rsn_pairwise & WPA_CIPHER_TKIP)
++ else if (conf->rsn_pairwise & WPA_CIPHER_TKIP)
+ wps->encr_types |= WPS_ENCR_TKIP;
+- }
+-
+- if (conf->wpa & WPA_PROTO_WPA) {
++ } else if (conf->wpa & WPA_PROTO_WPA) {
+ if (conf->wpa_key_mgmt & WPA_KEY_MGMT_PSK)
+ wps->auth_types |= WPS_AUTH_WPAPSK;
+ if (conf->wpa_key_mgmt & WPA_KEY_MGMT_IEEE8021X)
+@@ -883,7 +881,7 @@ int hostapd_init_wps(struct hostapd_data
+
+ if (conf->wpa_pairwise & WPA_CIPHER_CCMP)
+ wps->encr_types |= WPS_ENCR_AES;
+- if (conf->wpa_pairwise & WPA_CIPHER_TKIP)
++ else if (conf->wpa_pairwise & WPA_CIPHER_TKIP)
+ wps->encr_types |= WPS_ENCR_TKIP;
+ }
+
diff --git a/package/network/services/hostapd/patches/540-dynamic_20_40_mhz.patch b/package/network/services/hostapd/patches/540-dynamic_20_40_mhz.patch
new file mode 100644
index 0000000..ce2a339
--- /dev/null
+++ b/package/network/services/hostapd/patches/540-dynamic_20_40_mhz.patch
@@ -0,0 +1,206 @@
+--- a/hostapd/config_file.c
++++ b/hostapd/config_file.c
+@@ -2474,6 +2474,10 @@ static int hostapd_config_fill(struct ho
+ "ht_capab", line);
+ errors++;
+ }
++ } else if (os_strcmp(buf, "dynamic_ht40") == 0) {
++ conf->dynamic_ht40 = atoi(pos);
++ if (conf->dynamic_ht40 == 1)
++ conf->dynamic_ht40 = 1500;
+ } else if (os_strcmp(buf, "require_ht") == 0) {
+ conf->require_ht = atoi(pos);
+ #endif /* CONFIG_IEEE80211N */
+--- a/src/ap/ap_config.h
++++ b/src/ap/ap_config.h
+@@ -514,6 +514,7 @@ struct hostapd_config {
+ int ieee80211n;
+ int secondary_channel;
+ int require_ht;
++ int dynamic_ht40;
+ u32 vht_capab;
+ int ieee80211ac;
+ int require_vht;
+--- a/src/ap/hostapd.c
++++ b/src/ap/hostapd.c
+@@ -22,6 +22,7 @@
+ #include "beacon.h"
+ #include "iapp.h"
+ #include "ieee802_1x.h"
++#include "ieee802_11.h"
+ #include "ieee802_11_auth.h"
+ #include "vlan_init.h"
+ #include "wpa_auth.h"
+@@ -332,6 +333,7 @@ static void hostapd_cleanup_iface_pre(st
+
+ static void hostapd_cleanup_iface_partial(struct hostapd_iface *iface)
+ {
++ hostapd_deinit_ht(iface);
+ hostapd_free_hw_features(iface->hw_features, iface->num_hw_features);
+ iface->hw_features = NULL;
+ os_free(iface->current_rates);
+--- a/src/ap/hostapd.h
++++ b/src/ap/hostapd.h
+@@ -265,6 +265,9 @@ struct hostapd_iface {
+ /* Overlapping BSS information */
+ int olbc_ht;
+
++ int force_20mhz;
++ struct os_time last_20mhz_trigger;
++
+ u16 ht_op_mode;
+ void (*scan_cb)(struct hostapd_iface *iface);
+ };
+--- a/src/ap/ieee802_11.c
++++ b/src/ap/ieee802_11.c
+@@ -1484,6 +1484,9 @@ static void handle_beacon(struct hostapd
+ sizeof(mgmt->u.beacon)), &elems,
+ 0);
+
++ if (!elems.ht_capabilities)
++ hostapd_trigger_20mhz(hapd->iface);
++
+ ap_list_process_beacon(hapd->iface, mgmt, &elems, fi);
+ }
+
+--- a/src/ap/ieee802_11.h
++++ b/src/ap/ieee802_11.h
+@@ -81,4 +81,17 @@ int hostapd_update_time_adv(struct hosta
+ void hostapd_client_poll_ok(struct hostapd_data *hapd, const u8 *addr);
+ u8 * hostapd_eid_bss_max_idle_period(struct hostapd_data *hapd, u8 *eid);
+
++#ifdef CONFIG_IEEE80211N
++void hostapd_trigger_20mhz(struct hostapd_iface *iface);
++void hostapd_deinit_ht(struct hostapd_iface *iface);
++
++#else
++static inline void hostapd_deinit_ht(struct hostapd_iface *iface)
++{
++}
++static inline void hostapd_trigger_20mhz(struct hostapd_iface *iface)
++{
++}
++#endif /* CONFIG_IEEE80211N */
++
+ #endif /* IEEE802_11_H */
+--- a/src/ap/ieee802_11_ht.c
++++ b/src/ap/ieee802_11_ht.c
+@@ -20,9 +20,11 @@
+ #include "drivers/driver.h"
+ #include "hostapd.h"
+ #include "ap_config.h"
++#include "ap_drv_ops.h"
+ #include "sta_info.h"
+ #include "beacon.h"
+ #include "ieee802_11.h"
++#include "utils/eloop.h"
+
+
+ u8 * hostapd_eid_ht_capabilities(struct hostapd_data *hapd, u8 *eid)
+@@ -70,12 +72,15 @@ u8 * hostapd_eid_ht_operation(struct hos
+
+ oper->control_chan = hapd->iconf->channel;
+ oper->operation_mode = host_to_le16(hapd->iface->ht_op_mode);
+- if (hapd->iconf->secondary_channel == 1)
+- oper->ht_param |= HT_INFO_HT_PARAM_SECONDARY_CHNL_ABOVE |
+- HT_INFO_HT_PARAM_REC_TRANS_CHNL_WIDTH;
+- if (hapd->iconf->secondary_channel == -1)
+- oper->ht_param |= HT_INFO_HT_PARAM_SECONDARY_CHNL_BELOW |
+- HT_INFO_HT_PARAM_REC_TRANS_CHNL_WIDTH;
++
++ if (!hapd->iface->force_20mhz) {
++ if (hapd->iconf->secondary_channel == 1)
++ oper->ht_param |= HT_INFO_HT_PARAM_SECONDARY_CHNL_ABOVE |
++ HT_INFO_HT_PARAM_REC_TRANS_CHNL_WIDTH;
++ if (hapd->iconf->secondary_channel == -1)
++ oper->ht_param |= HT_INFO_HT_PARAM_SECONDARY_CHNL_BELOW |
++ HT_INFO_HT_PARAM_REC_TRANS_CHNL_WIDTH;
++ }
+
+ pos += sizeof(*oper);
+
+@@ -270,3 +275,84 @@ void hostapd_get_ht_capab(struct hostapd
+
+ neg_ht_cap->ht_capabilities_info = host_to_le16(cap);
+ }
++
++static void hostapd_set_force_20mhz(struct hostapd_iface *iface);
++
++static void hostapd_restore_40mhz(void *eloop_data, void *user_ctx)
++{
++ struct hostapd_iface *iface = eloop_data;
++ struct os_time time;
++ int timeout;
++
++ if (!iface->last_20mhz_trigger.sec)
++ return;
++
++ os_get_time(&time);
++ timeout = iface->last_20mhz_trigger.sec + iface->conf->dynamic_ht40 -
++ time.sec;
++
++ if (timeout > 0) {
++ eloop_register_timeout(timeout, 0, hostapd_restore_40mhz,
++ iface, NULL);
++ return;
++ }
++
++ iface->last_20mhz_trigger.sec = 0;
++ iface->last_20mhz_trigger.usec = 0;
++
++ iface->force_20mhz = 0;
++ hostapd_set_force_20mhz(iface);
++}
++
++static void hostapd_set_force_20mhz(struct hostapd_iface *iface)
++{
++ int secondary_channel;
++ int i;
++
++ ieee802_11_set_beacons(iface);
++
++ for (i = 0; i < iface->num_bss; i++) {
++ struct hostapd_data *hapd = iface->bss[i];
++
++ if (iface->force_20mhz)
++ secondary_channel = 0;
++ else
++ secondary_channel = hapd->iconf->secondary_channel;
++
++ if (hostapd_set_freq(hapd, hapd->iconf->hw_mode, iface->freq,
++ hapd->iconf->channel,
++ hapd->iconf->ieee80211n,
++ hapd->iconf->ieee80211ac,
++ secondary_channel,
++ hapd->iconf->vht_oper_chwidth,
++ hapd->iconf->vht_oper_centr_freq_seg0_idx,
++ hapd->iconf->vht_oper_centr_freq_seg1_idx)) {
++ wpa_printf(MSG_ERROR, "Could not set channel for "
++ "kernel driver");
++ }
++ }
++}
++
++void hostapd_deinit_ht(struct hostapd_iface *iface)
++{
++ eloop_cancel_timeout(hostapd_restore_40mhz, iface, NULL);
++}
++
++void hostapd_trigger_20mhz(struct hostapd_iface *iface)
++{
++ if (!iface->conf->dynamic_ht40)
++ return;
++
++ if (!iface->force_20mhz) {
++ iface->force_20mhz = 1;
++ hostapd_set_force_20mhz(iface);
++ }
++
++ if (!iface->last_20mhz_trigger.sec) {
++ eloop_cancel_timeout(hostapd_restore_40mhz, iface, NULL);
++ eloop_register_timeout(iface->conf->dynamic_ht40, 0,
++ hostapd_restore_40mhz, iface, NULL);
++ }
++
++ os_get_time(&iface->last_20mhz_trigger);
++}
diff --git a/package/network/services/hostapd/patches/550-limit_debug_messages.patch b/package/network/services/hostapd/patches/550-limit_debug_messages.patch
new file mode 100644
index 0000000..659e980
--- /dev/null
+++ b/package/network/services/hostapd/patches/550-limit_debug_messages.patch
@@ -0,0 +1,213 @@
+--- a/src/utils/wpa_debug.c
++++ b/src/utils/wpa_debug.c
+@@ -201,7 +201,7 @@ void wpa_debug_close_linux_tracing(void)
+ *
+ * Note: New line '\n' is added to the end of the text when printing to stdout.
+ */
+-void wpa_printf(int level, const char *fmt, ...)
++void _wpa_printf(int level, const char *fmt, ...)
+ {
+ va_list ap;
+
+@@ -248,8 +248,8 @@ void wpa_printf(int level, const char *f
+ }
+
+
+-static void _wpa_hexdump(int level, const char *title, const u8 *buf,
+- size_t len, int show)
++void _wpa_hexdump(int level, const char *title, const u8 *buf,
++ size_t len, int show)
+ {
+ size_t i;
+
+@@ -375,20 +375,9 @@ static void _wpa_hexdump(int level, cons
+ #endif /* CONFIG_ANDROID_LOG */
+ }
+
+-void wpa_hexdump(int level, const char *title, const u8 *buf, size_t len)
+-{
+- _wpa_hexdump(level, title, buf, len, 1);
+-}
+-
+-
+-void wpa_hexdump_key(int level, const char *title, const u8 *buf, size_t len)
+-{
+- _wpa_hexdump(level, title, buf, len, wpa_debug_show_keys);
+-}
+
+-
+-static void _wpa_hexdump_ascii(int level, const char *title, const u8 *buf,
+- size_t len, int show)
++void _wpa_hexdump_ascii(int level, const char *title, const u8 *buf,
++ size_t len, int show)
+ {
+ size_t i, llen;
+ const u8 *pos = buf;
+@@ -495,19 +484,6 @@ static void _wpa_hexdump_ascii(int level
+ }
+
+
+-void wpa_hexdump_ascii(int level, const char *title, const u8 *buf, size_t len)
+-{
+- _wpa_hexdump_ascii(level, title, buf, len, 1);
+-}
+-
+-
+-void wpa_hexdump_ascii_key(int level, const char *title, const u8 *buf,
+- size_t len)
+-{
+- _wpa_hexdump_ascii(level, title, buf, len, wpa_debug_show_keys);
+-}
+-
+-
+ #ifdef CONFIG_DEBUG_FILE
+ static char *last_path = NULL;
+ #endif /* CONFIG_DEBUG_FILE */
+@@ -591,7 +567,7 @@ void wpa_msg_register_ifname_cb(wpa_msg_
+ }
+
+
+-void wpa_msg(void *ctx, int level, const char *fmt, ...)
++void _wpa_msg(void *ctx, int level, const char *fmt, ...)
+ {
+ va_list ap;
+ char *buf;
+@@ -625,7 +601,7 @@ void wpa_msg(void *ctx, int level, const
+ }
+
+
+-void wpa_msg_ctrl(void *ctx, int level, const char *fmt, ...)
++void _wpa_msg_ctrl(void *ctx, int level, const char *fmt, ...)
+ {
+ va_list ap;
+ char *buf;
+--- a/src/utils/wpa_debug.h
++++ b/src/utils/wpa_debug.h
+@@ -43,6 +43,17 @@ int wpa_debug_open_file(const char *path
+ int wpa_debug_reopen_file(void);
+ void wpa_debug_close_file(void);
+
++/* internal */
++void _wpa_hexdump(int level, const char *title, const u8 *buf,
++ size_t len, int show);
++void _wpa_hexdump_ascii(int level, const char *title, const u8 *buf,
++ size_t len, int show);
++extern int wpa_debug_show_keys;
++
++#ifndef CONFIG_MSG_MIN_PRIORITY
++#define CONFIG_MSG_MIN_PRIORITY 0
++#endif
++
+ /**
+ * wpa_debug_printf_timestamp - Print timestamp for debug output
+ *
+@@ -63,9 +74,15 @@ void wpa_debug_print_timestamp(void);
+ *
+ * Note: New line '\n' is added to the end of the text when printing to stdout.
+ */
+-void wpa_printf(int level, const char *fmt, ...)
++void _wpa_printf(int level, const char *fmt, ...)
+ PRINTF_FORMAT(2, 3);
+
++#define wpa_printf(level, ...) \
++ do { \
++ if (level >= CONFIG_MSG_MIN_PRIORITY) \
++ _wpa_printf(level, __VA_ARGS__); \
++ } while(0)
++
+ /**
+ * wpa_hexdump - conditional hex dump
+ * @level: priority level (MSG_*) of the message
+@@ -77,7 +94,13 @@ PRINTF_FORMAT(2, 3);
+ * output may be directed to stdout, stderr, and/or syslog based on
+ * configuration. The contents of buf is printed out has hex dump.
+ */
+-void wpa_hexdump(int level, const char *title, const u8 *buf, size_t len);
++static inline void wpa_hexdump(int level, const char *title, const u8 *buf, size_t len)
++{
++ if (level < CONFIG_MSG_MIN_PRIORITY)
++ return;
++
++ _wpa_hexdump(level, title, buf, len, 1);
++}
+
+ static inline void wpa_hexdump_buf(int level, const char *title,
+ const struct wpabuf *buf)
+@@ -99,7 +122,13 @@ static inline void wpa_hexdump_buf(int l
+ * like wpa_hexdump(), but by default, does not include secret keys (passwords,
+ * etc.) in debug output.
+ */
+-void wpa_hexdump_key(int level, const char *title, const u8 *buf, size_t len);
++static inline void wpa_hexdump_key(int level, const char *title, const u8 *buf, size_t len)
++{
++ if (level < CONFIG_MSG_MIN_PRIORITY)
++ return;
++
++ _wpa_hexdump(level, title, buf, len, wpa_debug_show_keys);
++}
+
+ static inline void wpa_hexdump_buf_key(int level, const char *title,
+ const struct wpabuf *buf)
+@@ -121,8 +150,14 @@ static inline void wpa_hexdump_buf_key(i
+ * the hex numbers and ASCII characters (for printable range) are shown. 16
+ * bytes per line will be shown.
+ */
+-void wpa_hexdump_ascii(int level, const char *title, const u8 *buf,
+- size_t len);
++static inline void wpa_hexdump_ascii(int level, const char *title,
++ const u8 *buf, size_t len)
++{
++ if (level < CONFIG_MSG_MIN_PRIORITY)
++ return;
++
++ _wpa_hexdump_ascii(level, title, buf, len, 1);
++}
+
+ /**
+ * wpa_hexdump_ascii_key - conditional hex dump, hide keys
+@@ -138,8 +173,14 @@ void wpa_hexdump_ascii(int level, const
+ * bytes per line will be shown. This works like wpa_hexdump_ascii(), but by
+ * default, does not include secret keys (passwords, etc.) in debug output.
+ */
+-void wpa_hexdump_ascii_key(int level, const char *title, const u8 *buf,
+- size_t len);
++static inline void wpa_hexdump_ascii_key(int level, const char *title,
++ const u8 *buf, size_t len)
++{
++ if (level < CONFIG_MSG_MIN_PRIORITY)
++ return;
++
++ _wpa_hexdump_ascii(level, title, buf, len, wpa_debug_show_keys);
++}
+
+ /*
+ * wpa_dbg() behaves like wpa_msg(), but it can be removed from build to reduce
+@@ -172,7 +213,12 @@ void wpa_hexdump_ascii_key(int level, co
+ *
+ * Note: New line '\n' is added to the end of the text when printing to stdout.
+ */
+-void wpa_msg(void *ctx, int level, const char *fmt, ...) PRINTF_FORMAT(3, 4);
++void _wpa_msg(void *ctx, int level, const char *fmt, ...) PRINTF_FORMAT(3, 4);
++#define wpa_msg(ctx, level, ...) \
++ do { \
++ if (level >= CONFIG_MSG_MIN_PRIORITY) \
++ _wpa_msg(ctx, level, __VA_ARGS__); \
++ } while(0)
+
+ /**
+ * wpa_msg_ctrl - Conditional printf for ctrl_iface monitors
+@@ -186,8 +232,13 @@ void wpa_msg(void *ctx, int level, const
+ * attached ctrl_iface monitors. In other words, it can be used for frequent
+ * events that do not need to be sent to syslog.
+ */
+-void wpa_msg_ctrl(void *ctx, int level, const char *fmt, ...)
++void _wpa_msg_ctrl(void *ctx, int level, const char *fmt, ...)
+ PRINTF_FORMAT(3, 4);
++#define wpa_msg_ctrl(ctx, level, ...) \
++ do { \
++ if (level >= CONFIG_MSG_MIN_PRIORITY) \
++ _wpa_msg_ctrl(ctx, level, __VA_ARGS__); \
++ } while(0)
+
+ typedef void (*wpa_msg_cb_func)(void *ctx, int level, const char *txt,
+ size_t len);
diff --git a/package/network/services/hostapd/patches/560-indicate-features.patch b/package/network/services/hostapd/patches/560-indicate-features.patch
new file mode 100644
index 0000000..d01e18b
--- /dev/null
+++ b/package/network/services/hostapd/patches/560-indicate-features.patch
@@ -0,0 +1,82 @@
+--- a/hostapd/main.c
++++ b/hostapd/main.c
+@@ -13,6 +13,7 @@
+
+ #include "utils/common.h"
+ #include "utils/eloop.h"
++#include "utils/build_features.h"
+ #include "crypto/random.h"
+ #include "crypto/tls.h"
+ #include "common/version.h"
+@@ -560,7 +561,7 @@ int main(int argc, char *argv[])
+
+ wpa_supplicant_event = hostapd_wpa_event;
+ for (;;) {
+- c = getopt(argc, argv, "Bde:f:hKP:tvg:");
++ c = getopt(argc, argv, "Bde:f:hKP:tg:v::");
+ if (c < 0)
+ break;
+ switch (c) {
+@@ -592,6 +593,8 @@ int main(int argc, char *argv[])
+ wpa_debug_timestamp++;
+ break;
+ case 'v':
++ if (optarg)
++ exit(!has_feature(optarg));
+ show_version();
+ exit(1);
+ break;
+--- a/wpa_supplicant/main.c
++++ b/wpa_supplicant/main.c
+@@ -12,6 +12,7 @@
+ #endif /* __linux__ */
+
+ #include "common.h"
++#include "build_features.h"
+ #include "wpa_supplicant_i.h"
+ #include "driver_i.h"
+
+@@ -156,7 +157,7 @@ int main(int argc, char *argv[])
+
+ for (;;) {
+ c = getopt(argc, argv,
+- "b:Bc:C:D:de:f:g:hH:i:KLNo:O:p:P:qsTtuvW");
++ "b:Bc:C:D:de:f:g:hH:i:KLNo:O:p:P:qsTtuv::W");
+ if (c < 0)
+ break;
+ switch (c) {
+@@ -248,8 +249,12 @@ int main(int argc, char *argv[])
+ break;
+ #endif /* CONFIG_DBUS */
+ case 'v':
+- printf("%s\n", wpa_supplicant_version);
+- exitcode = 0;
++ if (optarg) {
++ exitcode = !has_feature(optarg);
++ } else {
++ printf("%s\n", wpa_supplicant_version);
++ exitcode = 0;
++ }
+ goto out;
+ case 'W':
+ params.wait_for_monitor++;
+--- /dev/null
++++ b/src/utils/build_features.h
+@@ -0,0 +1,17 @@
++#ifndef BUILD_FEATURES_H
++#define BUILD_FEATURES_H
++
++static inline int has_feature(const char *feat)
++{
++#ifdef IEEE8021X_EAPOL
++ if (!strcmp(feat, "eap"))
++ return 1;
++#endif
++#ifdef IEEE80211N
++ if (!strcmp(feat, "11n"))
++ return 1;
++#endif
++ return 0;
++}
++
++#endif /* BUILD_FEATURES_H */
diff --git a/package/network/services/hostapd/patches/570-genl_connect_debug.patch b/package/network/services/hostapd/patches/570-genl_connect_debug.patch
new file mode 100644
index 0000000..5f14048
--- /dev/null
+++ b/package/network/services/hostapd/patches/570-genl_connect_debug.patch
@@ -0,0 +1,11 @@
+--- a/src/drivers/driver_nl80211.c
++++ b/src/drivers/driver_nl80211.c
+@@ -127,7 +127,7 @@ static struct nl_handle * nl_create_hand
+ }
+
+ if (genl_connect(handle)) {
+- wpa_printf(MSG_ERROR, "nl80211: Failed to connect to generic "
++ wpa_printf(MSG_DEBUG, "nl80211: Failed to connect to generic "
+ "netlink (%s)", dbg);
+ nl80211_handle_destroy(handle);
+ return NULL;
diff --git a/package/network/services/hostapd/patches/590-hostapd_cli_ifdef.patch b/package/network/services/hostapd/patches/590-hostapd_cli_ifdef.patch
new file mode 100644
index 0000000..cbf1e48
--- /dev/null
+++ b/package/network/services/hostapd/patches/590-hostapd_cli_ifdef.patch
@@ -0,0 +1,50 @@
+--- a/hostapd/hostapd_cli.c
++++ b/hostapd/hostapd_cli.c
+@@ -67,7 +67,6 @@ static const char *commands_help =
+ #ifdef CONFIG_IEEE80211W
+ " sa_query <addr> send SA Query to a station\n"
+ #endif /* CONFIG_IEEE80211W */
+-#ifdef CONFIG_WPS
+ " wps_pin <uuid> <pin> [timeout] [addr] add WPS Enrollee PIN\n"
+ " wps_check_pin <PIN> verify PIN checksum\n"
+ " wps_pbc indicate button pushed to initiate PBC\n"
+@@ -79,7 +78,6 @@ static const char *commands_help =
+ #endif /* CONFIG_WPS_NFC */
+ " wps_ap_pin <cmd> [params..] enable/disable AP PIN\n"
+ " wps_config <SSID> <auth> <encr> <key> configure AP\n"
+-#endif /* CONFIG_WPS */
+ " get_config show current configuration\n"
+ " help show this usage help\n"
+ " interface [ifname] show interfaces/select interface\n"
+@@ -340,7 +338,6 @@ static int hostapd_cli_cmd_sa_query(stru
+ #endif /* CONFIG_IEEE80211W */
+
+
+-#ifdef CONFIG_WPS
+ static int hostapd_cli_cmd_wps_pin(struct wpa_ctrl *ctrl, int argc,
+ char *argv[])
+ {
+@@ -559,7 +556,6 @@ static int hostapd_cli_cmd_wps_config(st
+ ssid_hex, argv[1]);
+ return wpa_ctrl_command(ctrl, buf);
+ }
+-#endif /* CONFIG_WPS */
+
+
+ static int hostapd_cli_cmd_disassoc_imminent(struct wpa_ctrl *ctrl, int argc,
+@@ -805,7 +801,6 @@ static struct hostapd_cli_cmd hostapd_cl
+ #ifdef CONFIG_IEEE80211W
+ { "sa_query", hostapd_cli_cmd_sa_query },
+ #endif /* CONFIG_IEEE80211W */
+-#ifdef CONFIG_WPS
+ { "wps_pin", hostapd_cli_cmd_wps_pin },
+ { "wps_check_pin", hostapd_cli_cmd_wps_check_pin },
+ { "wps_pbc", hostapd_cli_cmd_wps_pbc },
+@@ -818,7 +813,6 @@ static struct hostapd_cli_cmd hostapd_cl
+ #endif /* CONFIG_WPS_NFC */
+ { "wps_ap_pin", hostapd_cli_cmd_wps_ap_pin },
+ { "wps_config", hostapd_cli_cmd_wps_config },
+-#endif /* CONFIG_WPS */
+ { "disassoc_imminent", hostapd_cli_cmd_disassoc_imminent },
+ { "ess_disassoc", hostapd_cli_cmd_ess_disassoc },
+ { "get_config", hostapd_cli_cmd_get_config },
diff --git a/package/network/services/hostapd/patches/601-wpa_supplicant-add-new-config-params-to-be-used-with.patch b/package/network/services/hostapd/patches/601-wpa_supplicant-add-new-config-params-to-be-used-with.patch
new file mode 100644
index 0000000..977bce4
--- /dev/null
+++ b/package/network/services/hostapd/patches/601-wpa_supplicant-add-new-config-params-to-be-used-with.patch
@@ -0,0 +1,209 @@
+From 4bb69d15477e0f2b00e166845341dc933de47c58 Mon Sep 17 00:00:00 2001
+From: Antonio Quartulli <ordex@autistici.org>
+Date: Sun, 3 Jun 2012 18:22:56 +0200
+Subject: [PATCHv2 601/602] wpa_supplicant: add new config params to be used
+ with the ibss join command
+
+Signed-hostap: Antonio Quartulli <ordex@autistici.org>
+---
+ src/drivers/driver.h | 6 +++
+ wpa_supplicant/config.c | 96 +++++++++++++++++++++++++++++++++++++++
+ wpa_supplicant/config_ssid.h | 6 +++
+ wpa_supplicant/wpa_supplicant.c | 23 +++++++---
+ 4 files changed, 124 insertions(+), 7 deletions(-)
+
+--- a/src/drivers/driver.h
++++ b/src/drivers/driver.h
+@@ -19,6 +19,7 @@
+
+ #define WPA_SUPPLICANT_DRIVER_VERSION 4
+
++#include "drivers/nl80211_copy.h"
+ #include "common/defs.h"
+
+ #define HOSTAPD_CHAN_DISABLED 0x00000001
+@@ -363,6 +364,11 @@ struct wpa_driver_associate_params {
+ */
+ int freq;
+
++ int beacon_interval;
++ int fixed_freq;
++ unsigned char rates[NL80211_MAX_SUPP_RATES];
++ int mcast_rate;
++
+ /**
+ * bg_scan_period - Background scan period in seconds, 0 to disable
+ * background scan, or -1 to indicate no change to default driver
+--- a/wpa_supplicant/config.c
++++ b/wpa_supplicant/config.c
+@@ -14,6 +14,7 @@
+ #include "rsn_supp/wpa.h"
+ #include "eap_peer/eap.h"
+ #include "p2p/p2p.h"
++#include "drivers/nl80211_copy.h"
+ #include "config.h"
+
+
+@@ -1369,6 +1370,97 @@ static char * wpa_config_write_p2p_clien
+
+ #endif /* CONFIG_P2P */
+
++static int wpa_config_parse_mcast_rate(const struct parse_data *data,
++ struct wpa_ssid *ssid, int line,
++ const char *value)
++{
++ ssid->mcast_rate = (int)(strtod(value, NULL) * 10);
++
++ return 0;
++}
++
++#ifndef NO_CONFIG_WRITE
++static char * wpa_config_write_mcast_rate(const struct parse_data *data,
++ struct wpa_ssid *ssid)
++{
++ char *value;
++ int res;
++
++ if (!ssid->mcast_rate == 0)
++ return NULL;
++
++ value = os_malloc(6); /* longest: 300.0 */
++ if (value == NULL)
++ return NULL;
++ res = os_snprintf(value, 5, "%.1f", (double)ssid->mcast_rate / 10);
++ if (res < 0) {
++ os_free(value);
++ return NULL;
++ }
++ return value;
++}
++#endif /* NO_CONFIG_WRITE */
++
++static int wpa_config_parse_rates(const struct parse_data *data,
++ struct wpa_ssid *ssid, int line,
++ const char *value)
++{
++ int i;
++ char *pos, *r, *sptr, *end;
++ double rate;
++
++ pos = (char *)value;
++ r = strtok_r(pos, ",", &sptr);
++ i = 0;
++ while (pos && i < NL80211_MAX_SUPP_RATES) {
++ rate = 0.0;
++ if (r)
++ rate = strtod(r, &end);
++ ssid->rates[i] = rate * 2;
++ if (*end != '\0' || rate * 2 != ssid->rates[i])
++ return 1;
++
++ i++;
++ r = strtok_r(NULL, ",", &sptr);
++ }
++
++ return 0;
++}
++
++#ifndef NO_CONFIG_WRITE
++static char * wpa_config_write_rates(const struct parse_data *data,
++ struct wpa_ssid *ssid)
++{
++ char *value, *pos;
++ int res, i;
++
++ if (ssid->rates[0] <= 0)
++ return NULL;
++
++ value = os_malloc(6 * NL80211_MAX_SUPP_RATES + 1);
++ if (value == NULL)
++ return NULL;
++ pos = value;
++ for (i = 0; i < NL80211_MAX_SUPP_RATES - 1; i++) {
++ res = os_snprintf(pos, 6, "%.1f,", (double)ssid->rates[i] / 2);
++ if (res < 0) {
++ os_free(value);
++ return NULL;
++ }
++ pos += res;
++ }
++ res = os_snprintf(pos, 6, "%.1f",
++ (double)ssid->rates[NL80211_MAX_SUPP_RATES - 1] / 2);
++ if (res < 0) {
++ os_free(value);
++ return NULL;
++ }
++
++ value[6 * NL80211_MAX_SUPP_RATES] = '\0';
++ return value;
++}
++#endif /* NO_CONFIG_WRITE */
++
+ /* Helper macros for network block parser */
+
+ #ifdef OFFSET
+@@ -1546,6 +1638,9 @@ static const struct parse_data ssid_fiel
+ { INT(ap_max_inactivity) },
+ { INT(dtim_period) },
+ { INT(beacon_int) },
++ { INT_RANGE(fixed_freq, 0, 1) },
++ { FUNC(rates) },
++ { FUNC(mcast_rate) },
+ };
+
+ #undef OFFSET
+--- a/wpa_supplicant/config_ssid.h
++++ b/wpa_supplicant/config_ssid.h
+@@ -11,6 +11,7 @@
+
+ #include "common/defs.h"
+ #include "eap_peer/eap_config.h"
++#include "drivers/nl80211_copy.h"
+
+ #define MAX_SSID_LEN 32
+
+@@ -571,6 +572,10 @@ struct wpa_ssid {
+ * dereferences since it may not be updated in all cases.
+ */
+ void *parent_cred;
++
++ int fixed_freq;
++ unsigned char rates[NL80211_MAX_SUPP_RATES];
++ double mcast_rate;
+ };
+
+ #endif /* CONFIG_SSID_H */
+--- a/wpa_supplicant/wpa_supplicant.c
++++ b/wpa_supplicant/wpa_supplicant.c
+@@ -1570,15 +1570,24 @@ void wpa_supplicant_associate(struct wpa
+ params.ssid_len = ssid->ssid_len;
+ }
+
+- if (ssid->mode == WPAS_MODE_IBSS && ssid->bssid_set &&
+- wpa_s->conf->ap_scan == 2) {
+- params.bssid = ssid->bssid;
+- params.fixed_bssid = 1;
++ if (ssid->mode == WPAS_MODE_IBSS) {
++ if (ssid->bssid_set && wpa_s->conf->ap_scan == 2) {
++ params.bssid = ssid->bssid;
++ params.fixed_bssid = 1;
++ }
++ if (ssid->frequency > 0 && params.freq == 0)
++ /* Initial channel for IBSS */
++ params.freq = ssid->frequency;
++ params.fixed_freq = ssid->fixed_freq;
++ params.beacon_interval = ssid->beacon_int;
++ i = 0;
++ while (i < NL80211_MAX_SUPP_RATES) {
++ params.rates[i] = ssid->rates[i];
++ i++;
++ }
++ params.mcast_rate = ssid->mcast_rate;
+ }
+
+- if (ssid->mode == WPAS_MODE_IBSS && ssid->frequency > 0 &&
+- params.freq == 0)
+- params.freq = ssid->frequency; /* Initial channel for IBSS */
+ params.wpa_ie = wpa_ie;
+ params.wpa_ie_len = wpa_ie_len;
+ params.pairwise_suite = cipher_pairwise;
diff --git a/package/network/services/hostapd/patches/602-driver_nl80211-use-new-parameters-during-ibss-join.patch b/package/network/services/hostapd/patches/602-driver_nl80211-use-new-parameters-during-ibss-join.patch
new file mode 100644
index 0000000..bf80185
--- /dev/null
+++ b/package/network/services/hostapd/patches/602-driver_nl80211-use-new-parameters-during-ibss-join.patch
@@ -0,0 +1,59 @@
+From ffc4445958a3ed4064f2e1bf73fa478a61c5cf7b Mon Sep 17 00:00:00 2001
+From: Antonio Quartulli <ordex@autistici.org>
+Date: Sun, 3 Jun 2012 18:42:25 +0200
+Subject: [PATCHv2 602/602] driver_nl80211: use new parameters during ibss join
+
+Signed-hostap: Antonio Quartulli <ordex@autistici.org>
+---
+ src/drivers/driver_nl80211.c | 33 ++++++++++++++++++++++++++++++++-
+ 1 file changed, 32 insertions(+), 1 deletion(-)
+
+--- a/src/drivers/driver_nl80211.c
++++ b/src/drivers/driver_nl80211.c
+@@ -6806,7 +6806,7 @@ static int wpa_driver_nl80211_ibss(struc
+ struct wpa_driver_associate_params *params)
+ {
+ struct nl_msg *msg;
+- int ret = -1;
++ int ret = -1, i;
+ int count = 0;
+
+ wpa_printf(MSG_DEBUG, "nl80211: Join IBSS (ifindex=%d)", drv->ifindex);
+@@ -6839,6 +6839,37 @@ retry:
+ wpa_printf(MSG_DEBUG, " * freq=%d", params->freq);
+ NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FREQ, params->freq);
+
++ if (params->fixed_freq) {
++ wpa_printf(MSG_DEBUG, " * fixed_freq");
++ NLA_PUT_FLAG(msg, NL80211_ATTR_FREQ_FIXED);
++ }
++
++ if (params->beacon_interval > 0) {
++ wpa_printf(MSG_DEBUG, " * beacon_interval=%d",
++ params->beacon_interval);
++ NLA_PUT_U32(msg, NL80211_ATTR_BEACON_INTERVAL,
++ params->beacon_interval);
++ }
++
++ if (params->rates[0] > 0) {
++ wpa_printf(MSG_DEBUG, " * basic_rates:");
++ i = 0;
++ while (i < NL80211_MAX_SUPP_RATES &&
++ params->rates[i] > 0) {
++ wpa_printf(MSG_DEBUG, " %.1f",
++ (double)params->rates[i] / 2);
++ i++;
++ }
++ NLA_PUT(msg, NL80211_ATTR_BSS_BASIC_RATES, i,
++ params->rates);
++ }
++
++ if (params->mcast_rate > 0) {
++ wpa_printf(MSG_DEBUG, " * mcast_rates=%.1f",
++ (double)params->mcast_rate / 10);
++ NLA_PUT_U32(msg, NL80211_ATTR_MCAST_RATE, params->mcast_rate);
++ }
++
+ ret = nl80211_set_conn_keys(params, msg);
+ if (ret)
+ goto nla_put_failure;
diff --git a/package/network/services/hostapd/patches/604-wpa_s-support-htmode-param.patch b/package/network/services/hostapd/patches/604-wpa_s-support-htmode-param.patch
new file mode 100644
index 0000000..00272a5
--- /dev/null
+++ b/package/network/services/hostapd/patches/604-wpa_s-support-htmode-param.patch
@@ -0,0 +1,156 @@
+From b9329c5dfeed7d5c55d2117d8dfe326fc40c8fb1 Mon Sep 17 00:00:00 2001
+From: Antonio Quartulli <ordex@autistici.org>
+Date: Tue, 3 Jul 2012 00:36:24 +0200
+Subject: [PATCH] wpa_s: support htmode param
+
+possible values are HT20, HT40-, HT40+ and NOHT
+
+Signed-off-by: Antonio Quartulli <ordex@autistici.org>
+---
+ src/drivers/driver.h | 2 ++
+ src/drivers/driver_nl80211.c | 16 ++++++++++
+ wpa_supplicant/config.c | 66 +++++++++++++++++++++++++++++++++++++++
+ wpa_supplicant/config_ssid.h | 2 ++
+ wpa_supplicant/wpa_supplicant.c | 2 ++
+ 5 files changed, 88 insertions(+)
+
+--- a/src/drivers/driver.h
++++ b/src/drivers/driver.h
+@@ -368,6 +368,8 @@ struct wpa_driver_associate_params {
+ int fixed_freq;
+ unsigned char rates[NL80211_MAX_SUPP_RATES];
+ int mcast_rate;
++ int ht_set;
++ unsigned int htmode;
+
+ /**
+ * bg_scan_period - Background scan period in seconds, 0 to disable
+--- a/src/drivers/driver_nl80211.c
++++ b/src/drivers/driver_nl80211.c
+@@ -6870,6 +6870,22 @@ retry:
+ NLA_PUT_U32(msg, NL80211_ATTR_MCAST_RATE, params->mcast_rate);
+ }
+
++ if (params->ht_set) {
++ switch(params->htmode) {
++ case NL80211_CHAN_HT20:
++ wpa_printf(MSG_DEBUG, " * ht=HT20");
++ break;
++ case NL80211_CHAN_HT40PLUS:
++ wpa_printf(MSG_DEBUG, " * ht=HT40+");
++ break;
++ case NL80211_CHAN_HT40MINUS:
++ wpa_printf(MSG_DEBUG, " * ht=HT40-");
++ break;
++ }
++ NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE,
++ params->htmode);
++ }
++
+ ret = nl80211_set_conn_keys(params, msg);
+ if (ret)
+ goto nla_put_failure;
+--- a/wpa_supplicant/config.c
++++ b/wpa_supplicant/config.c
+@@ -1401,6 +1401,71 @@ static char * wpa_config_write_mcast_rat
+ }
+ #endif /* NO_CONFIG_WRITE */
+
++static int wpa_config_parse_htmode(const struct parse_data *data,
++ struct wpa_ssid *ssid, int line,
++ const char *value)
++{
++ int i;
++ static const struct {
++ const char *name;
++ unsigned int val;
++ } htmap[] = {
++ { .name = "HT20", .val = NL80211_CHAN_HT20, },
++ { .name = "HT40+", .val = NL80211_CHAN_HT40PLUS, },
++ { .name = "HT40-", .val = NL80211_CHAN_HT40MINUS, },
++ { .name = "NOHT", .val = NL80211_CHAN_NO_HT, },
++ };
++ ssid->ht_set = 0;;
++ for (i = 0; i < 4; i++) {
++ if (strcasecmp(htmap[i].name, value) == 0) {
++ ssid->htmode = htmap[i].val;
++ ssid->ht_set = 1;
++ break;
++ }
++ }
++
++ return 0;
++}
++
++#ifndef NO_CONFIG_WRITE
++static char * wpa_config_write_htmode(const struct parse_data *data,
++ struct wpa_ssid *ssid)
++{
++ char *value;
++ int res;
++
++ value = os_malloc(6); /* longest: HT40+ */
++ if (value == NULL)
++ return NULL;
++
++ switch(ssid->htmode) {
++ case NL80211_CHAN_HT20:
++ res = os_snprintf(value, 4, "HT20");
++ break;
++ case NL80211_CHAN_HT40PLUS:
++ res = os_snprintf(value, 5, "HT40+");
++ break;
++ case NL80211_CHAN_HT40MINUS:
++ res = os_snprintf(value, 5, "HT40-");
++ break;
++ case NL80211_CHAN_NO_HT:
++ res = os_snprintf(value, 4, "NOHT");
++ break;
++ default:
++ os_free(value);
++ return NULL;
++ }
++
++ if (res < 0) {
++ os_free(value);
++ return NULL;
++ }
++
++ return value;
++}
++#endif /* NO_CONFIG_WRITE */
++
++
+ static int wpa_config_parse_rates(const struct parse_data *data,
+ struct wpa_ssid *ssid, int line,
+ const char *value)
+@@ -1641,6 +1706,7 @@ static const struct parse_data ssid_fiel
+ { INT_RANGE(fixed_freq, 0, 1) },
+ { FUNC(rates) },
+ { FUNC(mcast_rate) },
++ { FUNC(htmode) },
+ };
+
+ #undef OFFSET
+--- a/wpa_supplicant/config_ssid.h
++++ b/wpa_supplicant/config_ssid.h
+@@ -576,6 +576,8 @@ struct wpa_ssid {
+ int fixed_freq;
+ unsigned char rates[NL80211_MAX_SUPP_RATES];
+ double mcast_rate;
++ int ht_set;
++ unsigned int htmode;
+ };
+
+ #endif /* CONFIG_SSID_H */
+--- a/wpa_supplicant/wpa_supplicant.c
++++ b/wpa_supplicant/wpa_supplicant.c
+@@ -1586,6 +1586,8 @@ void wpa_supplicant_associate(struct wpa
+ i++;
+ }
+ params.mcast_rate = ssid->mcast_rate;
++ params.ht_set = ssid->ht_set;
++ params.htmode = ssid->htmode;
+ }
+
+ params.wpa_ie = wpa_ie;
diff --git a/package/network/services/hostapd/patches/610-max_num_sta_probe.patch b/package/network/services/hostapd/patches/610-max_num_sta_probe.patch
new file mode 100644
index 0000000..141eb5b
--- /dev/null
+++ b/package/network/services/hostapd/patches/610-max_num_sta_probe.patch
@@ -0,0 +1,13 @@
+--- a/src/ap/beacon.c
++++ b/src/ap/beacon.c
+@@ -455,6 +455,10 @@ void handle_probe_req(struct hostapd_dat
+ return;
+ }
+
++ if (!sta && hapd->num_sta >= hapd->conf->max_num_sta)
++ wpa_printf(MSG_MSGDUMP, "Probe Request from " MACSTR " ignored,"
++ " too many connected stations.", MAC2STR(mgmt->sa));
++
+ #ifdef CONFIG_INTERWORKING
+ if (elems.interworking && elems.interworking_len >= 1) {
+ u8 ant = elems.interworking[0] & 0x0f;
diff --git a/package/network/services/hostapd/patches/620-scan_wait.patch b/package/network/services/hostapd/patches/620-scan_wait.patch
new file mode 100644
index 0000000..d9c7f30
--- /dev/null
+++ b/package/network/services/hostapd/patches/620-scan_wait.patch
@@ -0,0 +1,65 @@
+--- a/hostapd/main.c
++++ b/hostapd/main.c
+@@ -32,6 +32,8 @@
+ extern int wpa_debug_level;
+ extern int wpa_debug_show_keys;
+ extern int wpa_debug_timestamp;
++static int daemonize = 0;
++static char *pid_file = NULL;
+
+ extern struct wpa_driver_ops *wpa_drivers[];
+
+@@ -146,6 +148,14 @@ static void hostapd_logger_cb(void *ctx,
+ }
+ #endif /* CONFIG_NO_HOSTAPD_LOGGER */
+
++static void hostapd_setup_complete_cb(void *ctx)
++{
++ if (daemonize && os_daemonize(pid_file)) {
++ perror("daemon");
++ return;
++ }
++ daemonize = 0;
++}
+
+ /**
+ * hostapd_init - Allocate and initialize per-interface data
+@@ -189,6 +199,7 @@ static struct hostapd_iface * hostapd_in
+ if (hapd == NULL)
+ goto fail;
+ hapd->msg_ctx = hapd;
++ hapd->setup_complete_cb = hostapd_setup_complete_cb;
+ }
+
+ return hapd_iface;
+@@ -425,8 +436,6 @@ static void hostapd_global_deinit(const
+ #endif /* CONFIG_NATIVE_WINDOWS */
+
+ eap_server_unregister_methods();
+-
+- os_daemonize_terminate(pid_file);
+ }
+
+
+@@ -452,11 +461,6 @@ static int hostapd_global_run(struct hap
+ }
+ #endif /* EAP_SERVER_TNC */
+
+- if (daemonize && os_daemonize(pid_file)) {
+- perror("daemon");
+- return -1;
+- }
+-
+ eloop_run();
+
+ return 0;
+@@ -540,8 +544,7 @@ int main(int argc, char *argv[])
+ struct hapd_interfaces interfaces;
+ int ret = 1;
+ size_t i;
+- int c, debug = 0, daemonize = 0;
+- char *pid_file = NULL;
++ int c, debug = 0;
+ const char *log_file = NULL;
+ const char *entropy_file = NULL;
+
diff --git a/package/network/services/lldpd/.svn/entries b/package/network/services/lldpd/.svn/entries
new file mode 100644
index 0000000..17155ad
--- /dev/null
+++ b/package/network/services/lldpd/.svn/entries
@@ -0,0 +1,68 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/services/lldpd
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-02T14:35:43.615288Z
+34970
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+files
+dir
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+55090a14c621d8bafd253db9995ccfc5
+2013-01-02T14:35:43.615288Z
+34970
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1700
+
diff --git a/package/network/services/lldpd/.svn/text-base/Makefile.svn-base b/package/network/services/lldpd/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..f0983f7
--- /dev/null
+++ b/package/network/services/lldpd/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,62 @@
+#
+# Copyright (C) 2008-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=lldpd
+PKG_VERSION:=0.6.1
+PKG_RELEASE:=2
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://media.luffy.cx/files/lldpd
+PKG_MD5SUM:=d2f9ae67e0bcce0206a3a501a81d0738
+
+PKG_MAINTAINER:=Jo-Philipp Wich <jow@openwrt.org>
+
+PKG_FIXUP:=autoreconf
+PKG_INSTALL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/lldpd
+ SECTION:=net
+ CATEGORY:=Network
+ SUBMENU:=Routing and Redirection
+ TITLE:=Link Layer Discovery Protocol daemon
+ URL:=https://github.com/vincentbernat/lldpd/wiki
+ DEPENDS:=+libevent2
+endef
+
+define Package/lldpd/description
+ LLDP (Link Layer Discovery Protocol) is an industry standard protocol designed
+ to supplant proprietary Link-Layer protocols such as
+ Extreme's EDP (Extreme Discovery Protocol) and
+ CDP (Cisco Discovery Protocol).
+ The goal of LLDP is to provide an inter-vendor compatible mechanism to deliver
+ Link-Layer notifications to adjacent network devices.
+endef
+
+define Package/lldpd/install
+ $(INSTALL_DIR) $(1)/etc/init.d
+ $(INSTALL_DIR) $(1)/etc/config
+ $(INSTALL_DIR) $(1)/usr/lib $(1)/usr/sbin
+ $(CP) $(PKG_INSTALL_DIR)/usr/sbin/lldp{ctl,d} $(1)/usr/sbin/
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/liblldpctl.so* $(1)/usr/lib/
+ $(INSTALL_BIN) ./files/lldpd.init $(1)/etc/init.d/lldpd
+ $(INSTALL_DATA) ./files/lldpd.config $(1)/etc/config/lldpd
+endef
+
+define Package/lldpd/conffiles
+/etc/config/lldpd
+endef
+
+CONFIGURE_ARGS += \
+ --with-privsep-user=lldp \
+ --with-privsep-group=lldp \
+ --with-privsep-chroot=/var/run/lldp
+
+$(eval $(call BuildPackage,lldpd))
diff --git a/package/network/services/lldpd/Makefile b/package/network/services/lldpd/Makefile
new file mode 100644
index 0000000..f0983f7
--- /dev/null
+++ b/package/network/services/lldpd/Makefile
@@ -0,0 +1,62 @@
+#
+# Copyright (C) 2008-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=lldpd
+PKG_VERSION:=0.6.1
+PKG_RELEASE:=2
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://media.luffy.cx/files/lldpd
+PKG_MD5SUM:=d2f9ae67e0bcce0206a3a501a81d0738
+
+PKG_MAINTAINER:=Jo-Philipp Wich <jow@openwrt.org>
+
+PKG_FIXUP:=autoreconf
+PKG_INSTALL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/lldpd
+ SECTION:=net
+ CATEGORY:=Network
+ SUBMENU:=Routing and Redirection
+ TITLE:=Link Layer Discovery Protocol daemon
+ URL:=https://github.com/vincentbernat/lldpd/wiki
+ DEPENDS:=+libevent2
+endef
+
+define Package/lldpd/description
+ LLDP (Link Layer Discovery Protocol) is an industry standard protocol designed
+ to supplant proprietary Link-Layer protocols such as
+ Extreme's EDP (Extreme Discovery Protocol) and
+ CDP (Cisco Discovery Protocol).
+ The goal of LLDP is to provide an inter-vendor compatible mechanism to deliver
+ Link-Layer notifications to adjacent network devices.
+endef
+
+define Package/lldpd/install
+ $(INSTALL_DIR) $(1)/etc/init.d
+ $(INSTALL_DIR) $(1)/etc/config
+ $(INSTALL_DIR) $(1)/usr/lib $(1)/usr/sbin
+ $(CP) $(PKG_INSTALL_DIR)/usr/sbin/lldp{ctl,d} $(1)/usr/sbin/
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/liblldpctl.so* $(1)/usr/lib/
+ $(INSTALL_BIN) ./files/lldpd.init $(1)/etc/init.d/lldpd
+ $(INSTALL_DATA) ./files/lldpd.config $(1)/etc/config/lldpd
+endef
+
+define Package/lldpd/conffiles
+/etc/config/lldpd
+endef
+
+CONFIGURE_ARGS += \
+ --with-privsep-user=lldp \
+ --with-privsep-group=lldp \
+ --with-privsep-chroot=/var/run/lldp
+
+$(eval $(call BuildPackage,lldpd))
diff --git a/package/network/services/lldpd/files/.svn/entries b/package/network/services/lldpd/files/.svn/entries
new file mode 100644
index 0000000..e2b4e69
--- /dev/null
+++ b/package/network/services/lldpd/files/.svn/entries
@@ -0,0 +1,96 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/services/lldpd/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-02T14:35:43.615288Z
+34970
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+lldpd.init
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+aeefcca799b8ff00558af620766797c3
+2013-01-02T14:35:43.615288Z
+34970
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1854
+
+lldpd.config
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+0b6222785562db13bf3570bcdb741234
+2013-01-02T14:35:43.615288Z
+34970
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+362
+
diff --git a/package/network/services/lldpd/files/.svn/text-base/lldpd.config.svn-base b/package/network/services/lldpd/files/.svn/text-base/lldpd.config.svn-base
new file mode 100644
index 0000000..48728e0
--- /dev/null
+++ b/package/network/services/lldpd/files/.svn/text-base/lldpd.config.svn-base
@@ -0,0 +1,15 @@
+config lldpd config
+ option enable_cdp 1
+ option enable_fdp 1
+ option enable_sonmp 1
+ option enable_edp 1
+
+ option lldp_class 4
+ option lldp_location "2:FR:6:Commercial Rd:3:Roseville:19:4"
+
+ # if empty, the distribution description is sent
+ #option lldp_description "OpenWrt System"
+
+ # interfaces to listen on
+ list interface "loopback"
+ list interface "lan"
diff --git a/package/network/services/lldpd/files/.svn/text-base/lldpd.init.svn-base b/package/network/services/lldpd/files/.svn/text-base/lldpd.init.svn-base
new file mode 100644
index 0000000..3599950
--- /dev/null
+++ b/package/network/services/lldpd/files/.svn/text-base/lldpd.init.svn-base
@@ -0,0 +1,72 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2008-2012 OpenWrt.org
+
+START=90
+
+SERVICE_USE_PID=1
+
+find_release_info()
+{
+ [ -s /etc/openwrt_release ] && . /etc/openwrt_release
+ [ -z "$DISTRIB_DESCRIPTION" ] && [ -s /etc/openwrt_version ] && \
+ DISTRIB_DESCRIPTION="$(cat /etc/openwrt_version)"
+
+ echo "${DISTRIB_DESCRIPTION:-Unknown OpenWrt release} @ $(cat /proc/sys/kernel/hostname)"
+}
+
+start() {
+ . /lib/functions/network.sh
+
+ local enable_cdp
+ local enable_fdp
+ local enable_sonmp
+ local enable_edp
+ local lldp_class
+ local lldp_location
+ local lldp_description
+
+ config_load 'lldpd'
+ config_get_bool enable_cdp 'config' 'enable_cdp' 0
+ config_get_bool enable_fdp 'config' 'enable_fdp' 0
+ config_get_bool enable_sonmp 'config' 'enable_sonmp' 0
+ config_get_bool enable_edp 'config' 'enable_edp' 0
+ config_get lldp_class 'config' 'lldp_class'
+ config_get lldp_location 'config' 'lldp_location'
+ config_get lldp_description 'config' 'lldp_description' "$(find_release_info)"
+
+ local ifaces
+ config_get ifaces 'config' 'interface'
+
+ local iface
+ for iface in $ifaces; do
+ local ifname=""
+ if network_get_device ifname "$iface" || [ -e "/sys/class/net/$iface" ]; then
+ append args "-I ${ifname:-$iface}"
+ fi
+ done
+
+ [ $enable_cdp -gt 0 ] && append args '-c'
+ [ $enable_fdp -gt 0 ] && append args '-f'
+ [ $enable_sonmp -gt 0 ] && append args '-s'
+ [ $enable_edp -gt 0 ] && append args '-e'
+
+ user_exists lldp 121 || user_add lldp 121 129
+ group_exists lldp 129 || group_add lldp 129
+
+ mkdir -p /var/run/lldp
+ chown lldp:lldp /var/run/lldp
+
+ service_start /usr/sbin/lldpd $args \
+ ${lldp_class:+ -M $lldp_class} \
+ ${lldp_description:+ -S "$lldp_description"}
+
+ [ -n "$lldp_location" ] && {
+ sleep 1
+ /usr/sbin/lldpctl -L "$lldp_location" > /dev/null 2>&1
+ }
+}
+
+stop() {
+ service_stop /usr/sbin/lldpd
+ rm -f /var/run/lldpd.socket /var/run/lldpd.pid
+}
diff --git a/package/network/services/lldpd/files/lldpd.config b/package/network/services/lldpd/files/lldpd.config
new file mode 100644
index 0000000..48728e0
--- /dev/null
+++ b/package/network/services/lldpd/files/lldpd.config
@@ -0,0 +1,15 @@
+config lldpd config
+ option enable_cdp 1
+ option enable_fdp 1
+ option enable_sonmp 1
+ option enable_edp 1
+
+ option lldp_class 4
+ option lldp_location "2:FR:6:Commercial Rd:3:Roseville:19:4"
+
+ # if empty, the distribution description is sent
+ #option lldp_description "OpenWrt System"
+
+ # interfaces to listen on
+ list interface "loopback"
+ list interface "lan"
diff --git a/package/network/services/lldpd/files/lldpd.init b/package/network/services/lldpd/files/lldpd.init
new file mode 100644
index 0000000..3599950
--- /dev/null
+++ b/package/network/services/lldpd/files/lldpd.init
@@ -0,0 +1,72 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2008-2012 OpenWrt.org
+
+START=90
+
+SERVICE_USE_PID=1
+
+find_release_info()
+{
+ [ -s /etc/openwrt_release ] && . /etc/openwrt_release
+ [ -z "$DISTRIB_DESCRIPTION" ] && [ -s /etc/openwrt_version ] && \
+ DISTRIB_DESCRIPTION="$(cat /etc/openwrt_version)"
+
+ echo "${DISTRIB_DESCRIPTION:-Unknown OpenWrt release} @ $(cat /proc/sys/kernel/hostname)"
+}
+
+start() {
+ . /lib/functions/network.sh
+
+ local enable_cdp
+ local enable_fdp
+ local enable_sonmp
+ local enable_edp
+ local lldp_class
+ local lldp_location
+ local lldp_description
+
+ config_load 'lldpd'
+ config_get_bool enable_cdp 'config' 'enable_cdp' 0
+ config_get_bool enable_fdp 'config' 'enable_fdp' 0
+ config_get_bool enable_sonmp 'config' 'enable_sonmp' 0
+ config_get_bool enable_edp 'config' 'enable_edp' 0
+ config_get lldp_class 'config' 'lldp_class'
+ config_get lldp_location 'config' 'lldp_location'
+ config_get lldp_description 'config' 'lldp_description' "$(find_release_info)"
+
+ local ifaces
+ config_get ifaces 'config' 'interface'
+
+ local iface
+ for iface in $ifaces; do
+ local ifname=""
+ if network_get_device ifname "$iface" || [ -e "/sys/class/net/$iface" ]; then
+ append args "-I ${ifname:-$iface}"
+ fi
+ done
+
+ [ $enable_cdp -gt 0 ] && append args '-c'
+ [ $enable_fdp -gt 0 ] && append args '-f'
+ [ $enable_sonmp -gt 0 ] && append args '-s'
+ [ $enable_edp -gt 0 ] && append args '-e'
+
+ user_exists lldp 121 || user_add lldp 121 129
+ group_exists lldp 129 || group_add lldp 129
+
+ mkdir -p /var/run/lldp
+ chown lldp:lldp /var/run/lldp
+
+ service_start /usr/sbin/lldpd $args \
+ ${lldp_class:+ -M $lldp_class} \
+ ${lldp_description:+ -S "$lldp_description"}
+
+ [ -n "$lldp_location" ] && {
+ sleep 1
+ /usr/sbin/lldpctl -L "$lldp_location" > /dev/null 2>&1
+ }
+}
+
+stop() {
+ service_stop /usr/sbin/lldpd
+ rm -f /var/run/lldpd.socket /var/run/lldpd.pid
+}
diff --git a/package/network/services/lldpd/patches/.svn/entries b/package/network/services/lldpd/patches/.svn/entries
new file mode 100644
index 0000000..4d3739c
--- /dev/null
+++ b/package/network/services/lldpd/patches/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/services/lldpd/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-12T11:58:19.209594Z
+33729
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+002-no-stack-protector.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+8e86a48475025e3667815b3be7fae1fa
+2012-10-12T11:58:19.209594Z
+33729
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+394
+
diff --git a/package/network/services/lldpd/patches/.svn/text-base/002-no-stack-protector.patch.svn-base b/package/network/services/lldpd/patches/.svn/text-base/002-no-stack-protector.patch.svn-base
new file mode 100644
index 0000000..dc861ba
--- /dev/null
+++ b/package/network/services/lldpd/patches/.svn/text-base/002-no-stack-protector.patch.svn-base
@@ -0,0 +1,10 @@
+--- a/configure.ac
++++ b/configure.ac
+@@ -62,7 +62,6 @@ AX_CFLAGS_GCC_OPTION([-Wformat])
+ AX_CFLAGS_GCC_OPTION([-Wformat-security])
+ AX_CFLAGS_GCC_OPTION([-Wcast-align])
+ AX_CFLAGS_GCC_OPTION([-Winline])
+-AX_CFLAGS_GCC_OPTION([-fstack-protector])
+ AX_CFLAGS_GCC_OPTION([-D_FORTIFY_SOURCE=2])
+ AX_CFLAGS_GCC_OPTION([-Wdeclaration-after-statement])
+ AX_CFLAGS_GCC_OPTION([-Wno-unused-parameter])
diff --git a/package/network/services/lldpd/patches/002-no-stack-protector.patch b/package/network/services/lldpd/patches/002-no-stack-protector.patch
new file mode 100644
index 0000000..dc861ba
--- /dev/null
+++ b/package/network/services/lldpd/patches/002-no-stack-protector.patch
@@ -0,0 +1,10 @@
+--- a/configure.ac
++++ b/configure.ac
+@@ -62,7 +62,6 @@ AX_CFLAGS_GCC_OPTION([-Wformat])
+ AX_CFLAGS_GCC_OPTION([-Wformat-security])
+ AX_CFLAGS_GCC_OPTION([-Wcast-align])
+ AX_CFLAGS_GCC_OPTION([-Winline])
+-AX_CFLAGS_GCC_OPTION([-fstack-protector])
+ AX_CFLAGS_GCC_OPTION([-D_FORTIFY_SOURCE=2])
+ AX_CFLAGS_GCC_OPTION([-Wdeclaration-after-statement])
+ AX_CFLAGS_GCC_OPTION([-Wno-unused-parameter])
diff --git a/package/network/services/openvpn-easy-rsa/.svn/entries b/package/network/services/openvpn-easy-rsa/.svn/entries
new file mode 100644
index 0000000..166bcc9
--- /dev/null
+++ b/package/network/services/openvpn-easy-rsa/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/services/openvpn-easy-rsa
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-02-06T22:17:11.802086Z
+35508
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+files
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+136f3b401cc21f798fb5ae06479b3b2e
+2013-02-06T22:17:11.802086Z
+35508
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1668
+
diff --git a/package/network/services/openvpn-easy-rsa/.svn/text-base/Makefile.svn-base b/package/network/services/openvpn-easy-rsa/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..8847d9b
--- /dev/null
+++ b/package/network/services/openvpn-easy-rsa/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,60 @@
+#
+# Copyright (C) 2010-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=openvpn-easy-rsa
+
+PKG_REV:=ff5bfd1dd8e548cb24d302742af3894f893ef92f
+PKG_VERSION:=2013-01-30
+PKG_RELEASE=1
+
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL:=https://github.com/OpenVPN/easy-rsa.git
+PKG_SOURCE_VERSION:=$(PKG_REV)
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_REV).tar.gz
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_SOURCE_SUBDIR)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/openvpn-easy-rsa
+ TITLE:=Simple shell scripts to manage a Certificate Authority
+ SECTION:=net
+ CATEGORY:=Network
+ URL:=http://openvpn.net
+ SUBMENU:=VPN
+ DEPENDS:=+openssl-util
+endef
+
+define Package/openvpn-easy-rsa/conffiles
+/etc/easy-rsa/keys/serial
+/etc/easy-rsa/keys/index.txt
+/etc/easy-rsa/vars
+endef
+
+define Build/Configure
+
+endef
+
+define Build/Compile
+
+endef
+
+define Package/openvpn-easy-rsa/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(CP) $(PKG_BUILD_DIR)/easy-rsa/2.0/{build-*,clean-all,inherit-inter,list-crl,pkitool,revoke-full,sign-req,whichopensslcnf} $(1)/usr/sbin/
+ $(INSTALL_DIR) $(1)/etc/easy-rsa
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/easy-rsa/2.0/openssl-1.0.0.cnf $(1)/etc/easy-rsa/openssl-1.0.0.cnf
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/easy-rsa/2.0/vars $(1)/etc/easy-rsa/vars
+ $(INSTALL_DIR) $(1)/etc/easy-rsa/keys
+ $(INSTALL_DATA) files/easy-rsa.index $(1)/etc/easy-rsa/keys/index.txt
+ $(INSTALL_DATA) files/easy-rsa.serial $(1)/etc/easy-rsa/keys/serial
+endef
+
+$(eval $(call BuildPackage,openvpn-easy-rsa))
diff --git a/package/network/services/openvpn-easy-rsa/Makefile b/package/network/services/openvpn-easy-rsa/Makefile
new file mode 100644
index 0000000..8847d9b
--- /dev/null
+++ b/package/network/services/openvpn-easy-rsa/Makefile
@@ -0,0 +1,60 @@
+#
+# Copyright (C) 2010-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=openvpn-easy-rsa
+
+PKG_REV:=ff5bfd1dd8e548cb24d302742af3894f893ef92f
+PKG_VERSION:=2013-01-30
+PKG_RELEASE=1
+
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL:=https://github.com/OpenVPN/easy-rsa.git
+PKG_SOURCE_VERSION:=$(PKG_REV)
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_REV).tar.gz
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_SOURCE_SUBDIR)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/openvpn-easy-rsa
+ TITLE:=Simple shell scripts to manage a Certificate Authority
+ SECTION:=net
+ CATEGORY:=Network
+ URL:=http://openvpn.net
+ SUBMENU:=VPN
+ DEPENDS:=+openssl-util
+endef
+
+define Package/openvpn-easy-rsa/conffiles
+/etc/easy-rsa/keys/serial
+/etc/easy-rsa/keys/index.txt
+/etc/easy-rsa/vars
+endef
+
+define Build/Configure
+
+endef
+
+define Build/Compile
+
+endef
+
+define Package/openvpn-easy-rsa/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(CP) $(PKG_BUILD_DIR)/easy-rsa/2.0/{build-*,clean-all,inherit-inter,list-crl,pkitool,revoke-full,sign-req,whichopensslcnf} $(1)/usr/sbin/
+ $(INSTALL_DIR) $(1)/etc/easy-rsa
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/easy-rsa/2.0/openssl-1.0.0.cnf $(1)/etc/easy-rsa/openssl-1.0.0.cnf
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/easy-rsa/2.0/vars $(1)/etc/easy-rsa/vars
+ $(INSTALL_DIR) $(1)/etc/easy-rsa/keys
+ $(INSTALL_DATA) files/easy-rsa.index $(1)/etc/easy-rsa/keys/index.txt
+ $(INSTALL_DATA) files/easy-rsa.serial $(1)/etc/easy-rsa/keys/serial
+endef
+
+$(eval $(call BuildPackage,openvpn-easy-rsa))
diff --git a/package/network/services/openvpn-easy-rsa/files/.svn/entries b/package/network/services/openvpn-easy-rsa/files/.svn/entries
new file mode 100644
index 0000000..5d7ae56
--- /dev/null
+++ b/package/network/services/openvpn-easy-rsa/files/.svn/entries
@@ -0,0 +1,96 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/services/openvpn-easy-rsa/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-02-05T10:40:13.957819Z
+35498
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+easy-rsa.serial
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+0ade138937c4b9cb36a28e2edb6485fc
+2013-02-05T10:40:13.957819Z
+35498
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3
+
+easy-rsa.index
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+d41d8cd98f00b204e9800998ecf8427e
+2013-02-05T10:40:13.957819Z
+35498
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+0
+
diff --git a/package/network/services/openvpn-easy-rsa/files/.svn/text-base/easy-rsa.index.svn-base b/package/network/services/openvpn-easy-rsa/files/.svn/text-base/easy-rsa.index.svn-base
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/package/network/services/openvpn-easy-rsa/files/.svn/text-base/easy-rsa.index.svn-base
diff --git a/package/network/services/openvpn-easy-rsa/files/.svn/text-base/easy-rsa.serial.svn-base b/package/network/services/openvpn-easy-rsa/files/.svn/text-base/easy-rsa.serial.svn-base
new file mode 100644
index 0000000..8a0f05e
--- /dev/null
+++ b/package/network/services/openvpn-easy-rsa/files/.svn/text-base/easy-rsa.serial.svn-base
@@ -0,0 +1 @@
+01
diff --git a/package/network/services/openvpn-easy-rsa/files/easy-rsa.index b/package/network/services/openvpn-easy-rsa/files/easy-rsa.index
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/package/network/services/openvpn-easy-rsa/files/easy-rsa.index
diff --git a/package/network/services/openvpn-easy-rsa/files/easy-rsa.serial b/package/network/services/openvpn-easy-rsa/files/easy-rsa.serial
new file mode 100644
index 0000000..8a0f05e
--- /dev/null
+++ b/package/network/services/openvpn-easy-rsa/files/easy-rsa.serial
@@ -0,0 +1 @@
+01
diff --git a/package/network/services/openvpn/.svn/entries b/package/network/services/openvpn/.svn/entries
new file mode 100644
index 0000000..44f4ad8
--- /dev/null
+++ b/package/network/services/openvpn/.svn/entries
@@ -0,0 +1,170 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/services/openvpn
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-02-05T10:40:19.707377Z
+35499
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+files
+dir
+
+Config-nossl.in
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+eac836e10db1d33e63c0d96ed7014095
+2013-01-30T20:07:15.369663Z
+35412
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1067
+
+patches
+dir
+
+Config-polarssl.in
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+3d932270366d954a1737e9cd57fca266
+2013-01-30T20:07:15.369663Z
+35412
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1399
+
+Config-openssl.in
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+2fad724b554a1324782987faad799103
+2013-01-30T20:07:15.369663Z
+35412
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1384
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+9d99b1e40d6821af684590bd12bd6812
+2013-02-05T10:40:19.707377Z
+35499
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3809
+
diff --git a/package/network/services/openvpn/.svn/text-base/Config-nossl.in.svn-base b/package/network/services/openvpn/.svn/text-base/Config-nossl.in.svn-base
new file mode 100644
index 0000000..98cba25
--- /dev/null
+++ b/package/network/services/openvpn/.svn/text-base/Config-nossl.in.svn-base
@@ -0,0 +1,47 @@
+if PACKAGE_openvpn-nossl
+
+config OPENVPN_nossl_ENABLE_LZO
+ bool "Enable LZO compression support"
+ default y
+
+config OPENVPN_nossl_ENABLE_SERVER
+ bool "Enable server support (otherwise only client mode is support)"
+ default y
+
+config OPENVPN_nossl_ENABLE_MANAGEMENT
+ bool "Enable management server support"
+ default n
+
+config OPENVPN_nossl_ENABLE_HTTP
+ bool "Enable HTTP proxy support"
+ default y
+
+config OPENVPN_nossl_ENABLE_SOCKS
+ bool "Enable SOCKS proxy support"
+ default y
+
+config OPENVPN_nossl_ENABLE_FRAGMENT
+ bool "Enable internal fragmentation support (--fragment)"
+ default y
+
+config OPENVPN_nossl_ENABLE_MULTIHOME
+ bool "Enable multi-homed UDP server support (--multihome)"
+ default y
+
+config OPENVPN_nossl_ENABLE_PORT_SHARE
+ bool "Enable TCP server port-share support (--port-share)"
+ default y
+
+config OPENVPN_nossl_ENABLE_DEF_AUTH
+ bool "Enable deferred authentication"
+ default y
+
+config OPENVPN_nossl_ENABLE_PF
+ bool "Enable internal packet filter"
+ default y
+
+config OPENVPN_nossl_ENABLE_IPROUTE2
+ bool "Enable support for iproute2"
+ default n
+
+endif
diff --git a/package/network/services/openvpn/.svn/text-base/Config-openssl.in.svn-base b/package/network/services/openvpn/.svn/text-base/Config-openssl.in.svn-base
new file mode 100644
index 0000000..6686121
--- /dev/null
+++ b/package/network/services/openvpn/.svn/text-base/Config-openssl.in.svn-base
@@ -0,0 +1,59 @@
+if PACKAGE_openvpn-openssl
+
+config OPENVPN_openssl_ENABLE_LZO
+ bool "Enable LZO compression support"
+ default y
+
+config OPENVPN_openssl_ENABLE_X509_ALT_USERNAME
+ bool "Enable the --x509-username-field feature"
+ default n
+
+config OPENVPN_openssl_ENABLE_SERVER
+ bool "Enable server support (otherwise only client mode is support)"
+ default y
+
+#config OPENVPN_openssl_ENABLE_EUREPHIA
+# bool "Enable support for the eurephia plug-in"
+# default n
+
+config OPENVPN_openssl_ENABLE_MANAGEMENT
+ bool "Enable management server support"
+ default n
+
+#config OPENVPN_openssl_ENABLE_PKCS11
+# bool "Enable pkcs11 support"
+# default n
+
+config OPENVPN_openssl_ENABLE_HTTP
+ bool "Enable HTTP proxy support"
+ default y
+
+config OPENVPN_openssl_ENABLE_SOCKS
+ bool "Enable SOCKS proxy support"
+ default y
+
+config OPENVPN_openssl_ENABLE_FRAGMENT
+ bool "Enable internal fragmentation support (--fragment)"
+ default y
+
+config OPENVPN_openssl_ENABLE_MULTIHOME
+ bool "Enable multi-homed UDP server support (--multihome)"
+ default y
+
+config OPENVPN_openssl_ENABLE_PORT_SHARE
+ bool "Enable TCP server port-share support (--port-share)"
+ default y
+
+config OPENVPN_openssl_ENABLE_DEF_AUTH
+ bool "Enable deferred authentication"
+ default y
+
+config OPENVPN_openssl_ENABLE_PF
+ bool "Enable internal packet filter"
+ default y
+
+config OPENVPN_openssl_ENABLE_IPROUTE2
+ bool "Enable support for iproute2"
+ default n
+
+endif
diff --git a/package/network/services/openvpn/.svn/text-base/Config-polarssl.in.svn-base b/package/network/services/openvpn/.svn/text-base/Config-polarssl.in.svn-base
new file mode 100644
index 0000000..64c4497
--- /dev/null
+++ b/package/network/services/openvpn/.svn/text-base/Config-polarssl.in.svn-base
@@ -0,0 +1,59 @@
+if PACKAGE_openvpn-polarssl
+
+config OPENVPN_polarssl_ENABLE_LZO
+ bool "Enable LZO compression support"
+ default y
+
+config OPENVPN_polarssl_ENABLE_X509_ALT_USERNAME
+ bool "Enable the --x509-username-field feature"
+ default n
+
+config OPENVPN_polarssl_ENABLE_SERVER
+ bool "Enable server support (otherwise only client mode is support)"
+ default y
+
+#config OPENVPN_polarssl_ENABLE_EUREPHIA
+# bool "Enable support for the eurephia plug-in"
+# default n
+
+config OPENVPN_polarssl_ENABLE_MANAGEMENT
+ bool "Enable management server support"
+ default n
+
+#config OPENVPN_polarssl_ENABLE_PKCS11
+# bool "Enable pkcs11 support"
+# default n
+
+config OPENVPN_polarssl_ENABLE_HTTP
+ bool "Enable HTTP proxy support"
+ default y
+
+config OPENVPN_polarssl_ENABLE_SOCKS
+ bool "Enable SOCKS proxy support"
+ default y
+
+config OPENVPN_polarssl_ENABLE_FRAGMENT
+ bool "Enable internal fragmentation support (--fragment)"
+ default y
+
+config OPENVPN_polarssl_ENABLE_MULTIHOME
+ bool "Enable multi-homed UDP server support (--multihome)"
+ default y
+
+config OPENVPN_polarssl_ENABLE_PORT_SHARE
+ bool "Enable TCP server port-share support (--port-share)"
+ default y
+
+config OPENVPN_polarssl_ENABLE_DEF_AUTH
+ bool "Enable deferred authentication"
+ default y
+
+config OPENVPN_polarssl_ENABLE_PF
+ bool "Enable internal packet filter"
+ default y
+
+config OPENVPN_polarssl_ENABLE_IPROUTE2
+ bool "Enable support for iproute2"
+ default n
+
+endif
diff --git a/package/network/services/openvpn/.svn/text-base/Makefile.svn-base b/package/network/services/openvpn/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..d0ba233
--- /dev/null
+++ b/package/network/services/openvpn/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,122 @@
+#
+# Copyright (C) 2010-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=openvpn
+
+PKG_VERSION:=2.3.0
+PKG_RELEASE=1
+
+PKG_SOURCE_URL:=http://swupdate.openvpn.net/community/releases
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
+
+PKG_INSTALL:=1
+PKG_FIXUP:=autoreconf
+PKG_BUILD_PARALLEL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/openvpn/Default
+ TITLE:=Open source VPN solution using $(2)
+ SECTION:=net
+ CATEGORY:=Network
+ URL:=http://openvpn.net
+ SUBMENU:=VPN
+ MENU:=1
+ DEPENDS:=+kmod-tun +OPENVPN_$(1)_ENABLE_LZO:liblzo +OPENVPN_$(1)_ENABLE_IPROUTE2:ip $(3)
+ VARIANT:=$(1)
+ MAINTAINER:=Mirko Vogt <mirko@openwrt.org>
+endef
+
+Package/openvpn-openssl=$(call Package/openvpn/Default,openssl,OpenSSL,+libopenssl)
+Package/openvpn-polarssl=$(call Package/openvpn/Default,polarssl,PolarSSL,+libpolarssl)
+Package/openvpn-nossl=$(call Package/openvpn/Default,nossl,plaintext (no SSL))
+
+define Package/openvpn/config/Default
+ source "$(SOURCE)/Config-$(1).in"
+endef
+
+Package/openvpn-openssl/config=$(call Package/openvpn/config/Default,openssl)
+Package/openvpn-polarssl/config=$(call Package/openvpn/config/Default,polarssl)
+Package/openvpn-nossl/config=$(call Package/openvpn/config/Default,nossl)
+
+ifeq ($(BUILD_VARIANT),polarssl)
+CONFIG_OPENVPN_POLARSSL:=y
+endif
+ifeq ($(BUILD_VARIANT),openssl)
+CONFIG_OPENVPN_OPENSSL:=y
+endif
+ifeq ($(BUILD_VARIANT),nossl)
+CONFIG_OPENVPN_NOSSL:=y
+endif
+
+CONFIGURE_VARS += \
+ IFCONFIG=/sbin/ifconfig \
+ ROUTE=/sbin/route \
+ IPROUTE=/usr/sbin/ip \
+ NETSTAT=/sbin/netstat
+
+define Build/Configure
+ $(call Build/Configure/Default, \
+ --enable-small \
+ --disable-selinux \
+ --disable-systemd \
+ --disable-plugins \
+ --disable-debug \
+ --disable-eurephia \
+ --disable-pkcs11 \
+ $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_LZO),--enable,--disable)-lzo \
+ $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_X509_ALT_USERNAME),enable,disable-x509-alt-username)-ssl \
+ $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_SERVER),--enable,--disable)-server \
+ $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_MANAGEMENT),--enable,--disable)-management \
+ $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_SOCKS),--enable,--disable)-socks \
+ $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_HTTP),--enable,--disable)-http \
+ $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_FRAGMENT),--enable,--disable)-fragment \
+ $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_MULTIHOME),--enable,--disable)-multihome \
+ $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_IPROUTE2),--enable,--disable)-iproute2 \
+ $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_DEF_AUTH),--enable,--disable)-def-auth \
+ $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_PF),--enable,--disable)-pf \
+ $(if $(CONFIG_OPENVPN_NOSSL),--disable-ssl --disable-crypto,--enable-ssl --enable-crypto) \
+ $(if $(CONFIG_OPENVPN_OPENSSL),--with-crypto-library=openssl) \
+ $(if $(CONFIG_OPENVPN_POLARSSL),--with-crypto-library=polarssl) \
+ )
+endef
+
+define Package/openvpn-$(BUILD_VARIANT)/conffiles
+/etc/config/openvpn
+endef
+
+define Package/openvpn-$(BUILD_VARIANT)/install
+ $(INSTALL_DIR) \
+ $(1)/usr/sbin \
+ $(1)/etc/init.d \
+ $(1)/etc/config \
+ $(1)/etc/openvpn \
+ $(1)/lib/upgrade/keep.d
+
+ $(INSTALL_BIN) \
+ $(PKG_INSTALL_DIR)/usr/sbin/openvpn \
+ $(1)/usr/sbin/
+
+ $(INSTALL_BIN) \
+ files/openvpn.init \
+ $(1)/etc/init.d/openvpn
+
+ $(INSTALL_CONF) files/openvpn.config \
+ $(1)/etc/config/openvpn
+
+ $(INSTALL_DATA) \
+ files/openvpn.upgrade \
+ $(1)/lib/upgrade/keep.d/openvpn
+endef
+
+$(eval $(call BuildPackage,openvpn-openssl))
+$(eval $(call BuildPackage,openvpn-polarssl))
+$(eval $(call BuildPackage,openvpn-nossl))
diff --git a/package/network/services/openvpn/Config-nossl.in b/package/network/services/openvpn/Config-nossl.in
new file mode 100644
index 0000000..98cba25
--- /dev/null
+++ b/package/network/services/openvpn/Config-nossl.in
@@ -0,0 +1,47 @@
+if PACKAGE_openvpn-nossl
+
+config OPENVPN_nossl_ENABLE_LZO
+ bool "Enable LZO compression support"
+ default y
+
+config OPENVPN_nossl_ENABLE_SERVER
+ bool "Enable server support (otherwise only client mode is support)"
+ default y
+
+config OPENVPN_nossl_ENABLE_MANAGEMENT
+ bool "Enable management server support"
+ default n
+
+config OPENVPN_nossl_ENABLE_HTTP
+ bool "Enable HTTP proxy support"
+ default y
+
+config OPENVPN_nossl_ENABLE_SOCKS
+ bool "Enable SOCKS proxy support"
+ default y
+
+config OPENVPN_nossl_ENABLE_FRAGMENT
+ bool "Enable internal fragmentation support (--fragment)"
+ default y
+
+config OPENVPN_nossl_ENABLE_MULTIHOME
+ bool "Enable multi-homed UDP server support (--multihome)"
+ default y
+
+config OPENVPN_nossl_ENABLE_PORT_SHARE
+ bool "Enable TCP server port-share support (--port-share)"
+ default y
+
+config OPENVPN_nossl_ENABLE_DEF_AUTH
+ bool "Enable deferred authentication"
+ default y
+
+config OPENVPN_nossl_ENABLE_PF
+ bool "Enable internal packet filter"
+ default y
+
+config OPENVPN_nossl_ENABLE_IPROUTE2
+ bool "Enable support for iproute2"
+ default n
+
+endif
diff --git a/package/network/services/openvpn/Config-openssl.in b/package/network/services/openvpn/Config-openssl.in
new file mode 100644
index 0000000..6686121
--- /dev/null
+++ b/package/network/services/openvpn/Config-openssl.in
@@ -0,0 +1,59 @@
+if PACKAGE_openvpn-openssl
+
+config OPENVPN_openssl_ENABLE_LZO
+ bool "Enable LZO compression support"
+ default y
+
+config OPENVPN_openssl_ENABLE_X509_ALT_USERNAME
+ bool "Enable the --x509-username-field feature"
+ default n
+
+config OPENVPN_openssl_ENABLE_SERVER
+ bool "Enable server support (otherwise only client mode is support)"
+ default y
+
+#config OPENVPN_openssl_ENABLE_EUREPHIA
+# bool "Enable support for the eurephia plug-in"
+# default n
+
+config OPENVPN_openssl_ENABLE_MANAGEMENT
+ bool "Enable management server support"
+ default n
+
+#config OPENVPN_openssl_ENABLE_PKCS11
+# bool "Enable pkcs11 support"
+# default n
+
+config OPENVPN_openssl_ENABLE_HTTP
+ bool "Enable HTTP proxy support"
+ default y
+
+config OPENVPN_openssl_ENABLE_SOCKS
+ bool "Enable SOCKS proxy support"
+ default y
+
+config OPENVPN_openssl_ENABLE_FRAGMENT
+ bool "Enable internal fragmentation support (--fragment)"
+ default y
+
+config OPENVPN_openssl_ENABLE_MULTIHOME
+ bool "Enable multi-homed UDP server support (--multihome)"
+ default y
+
+config OPENVPN_openssl_ENABLE_PORT_SHARE
+ bool "Enable TCP server port-share support (--port-share)"
+ default y
+
+config OPENVPN_openssl_ENABLE_DEF_AUTH
+ bool "Enable deferred authentication"
+ default y
+
+config OPENVPN_openssl_ENABLE_PF
+ bool "Enable internal packet filter"
+ default y
+
+config OPENVPN_openssl_ENABLE_IPROUTE2
+ bool "Enable support for iproute2"
+ default n
+
+endif
diff --git a/package/network/services/openvpn/Config-polarssl.in b/package/network/services/openvpn/Config-polarssl.in
new file mode 100644
index 0000000..64c4497
--- /dev/null
+++ b/package/network/services/openvpn/Config-polarssl.in
@@ -0,0 +1,59 @@
+if PACKAGE_openvpn-polarssl
+
+config OPENVPN_polarssl_ENABLE_LZO
+ bool "Enable LZO compression support"
+ default y
+
+config OPENVPN_polarssl_ENABLE_X509_ALT_USERNAME
+ bool "Enable the --x509-username-field feature"
+ default n
+
+config OPENVPN_polarssl_ENABLE_SERVER
+ bool "Enable server support (otherwise only client mode is support)"
+ default y
+
+#config OPENVPN_polarssl_ENABLE_EUREPHIA
+# bool "Enable support for the eurephia plug-in"
+# default n
+
+config OPENVPN_polarssl_ENABLE_MANAGEMENT
+ bool "Enable management server support"
+ default n
+
+#config OPENVPN_polarssl_ENABLE_PKCS11
+# bool "Enable pkcs11 support"
+# default n
+
+config OPENVPN_polarssl_ENABLE_HTTP
+ bool "Enable HTTP proxy support"
+ default y
+
+config OPENVPN_polarssl_ENABLE_SOCKS
+ bool "Enable SOCKS proxy support"
+ default y
+
+config OPENVPN_polarssl_ENABLE_FRAGMENT
+ bool "Enable internal fragmentation support (--fragment)"
+ default y
+
+config OPENVPN_polarssl_ENABLE_MULTIHOME
+ bool "Enable multi-homed UDP server support (--multihome)"
+ default y
+
+config OPENVPN_polarssl_ENABLE_PORT_SHARE
+ bool "Enable TCP server port-share support (--port-share)"
+ default y
+
+config OPENVPN_polarssl_ENABLE_DEF_AUTH
+ bool "Enable deferred authentication"
+ default y
+
+config OPENVPN_polarssl_ENABLE_PF
+ bool "Enable internal packet filter"
+ default y
+
+config OPENVPN_polarssl_ENABLE_IPROUTE2
+ bool "Enable support for iproute2"
+ default n
+
+endif
diff --git a/package/network/services/openvpn/Makefile b/package/network/services/openvpn/Makefile
new file mode 100644
index 0000000..d0ba233
--- /dev/null
+++ b/package/network/services/openvpn/Makefile
@@ -0,0 +1,122 @@
+#
+# Copyright (C) 2010-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=openvpn
+
+PKG_VERSION:=2.3.0
+PKG_RELEASE=1
+
+PKG_SOURCE_URL:=http://swupdate.openvpn.net/community/releases
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
+
+PKG_INSTALL:=1
+PKG_FIXUP:=autoreconf
+PKG_BUILD_PARALLEL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/openvpn/Default
+ TITLE:=Open source VPN solution using $(2)
+ SECTION:=net
+ CATEGORY:=Network
+ URL:=http://openvpn.net
+ SUBMENU:=VPN
+ MENU:=1
+ DEPENDS:=+kmod-tun +OPENVPN_$(1)_ENABLE_LZO:liblzo +OPENVPN_$(1)_ENABLE_IPROUTE2:ip $(3)
+ VARIANT:=$(1)
+ MAINTAINER:=Mirko Vogt <mirko@openwrt.org>
+endef
+
+Package/openvpn-openssl=$(call Package/openvpn/Default,openssl,OpenSSL,+libopenssl)
+Package/openvpn-polarssl=$(call Package/openvpn/Default,polarssl,PolarSSL,+libpolarssl)
+Package/openvpn-nossl=$(call Package/openvpn/Default,nossl,plaintext (no SSL))
+
+define Package/openvpn/config/Default
+ source "$(SOURCE)/Config-$(1).in"
+endef
+
+Package/openvpn-openssl/config=$(call Package/openvpn/config/Default,openssl)
+Package/openvpn-polarssl/config=$(call Package/openvpn/config/Default,polarssl)
+Package/openvpn-nossl/config=$(call Package/openvpn/config/Default,nossl)
+
+ifeq ($(BUILD_VARIANT),polarssl)
+CONFIG_OPENVPN_POLARSSL:=y
+endif
+ifeq ($(BUILD_VARIANT),openssl)
+CONFIG_OPENVPN_OPENSSL:=y
+endif
+ifeq ($(BUILD_VARIANT),nossl)
+CONFIG_OPENVPN_NOSSL:=y
+endif
+
+CONFIGURE_VARS += \
+ IFCONFIG=/sbin/ifconfig \
+ ROUTE=/sbin/route \
+ IPROUTE=/usr/sbin/ip \
+ NETSTAT=/sbin/netstat
+
+define Build/Configure
+ $(call Build/Configure/Default, \
+ --enable-small \
+ --disable-selinux \
+ --disable-systemd \
+ --disable-plugins \
+ --disable-debug \
+ --disable-eurephia \
+ --disable-pkcs11 \
+ $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_LZO),--enable,--disable)-lzo \
+ $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_X509_ALT_USERNAME),enable,disable-x509-alt-username)-ssl \
+ $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_SERVER),--enable,--disable)-server \
+ $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_MANAGEMENT),--enable,--disable)-management \
+ $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_SOCKS),--enable,--disable)-socks \
+ $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_HTTP),--enable,--disable)-http \
+ $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_FRAGMENT),--enable,--disable)-fragment \
+ $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_MULTIHOME),--enable,--disable)-multihome \
+ $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_IPROUTE2),--enable,--disable)-iproute2 \
+ $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_DEF_AUTH),--enable,--disable)-def-auth \
+ $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_PF),--enable,--disable)-pf \
+ $(if $(CONFIG_OPENVPN_NOSSL),--disable-ssl --disable-crypto,--enable-ssl --enable-crypto) \
+ $(if $(CONFIG_OPENVPN_OPENSSL),--with-crypto-library=openssl) \
+ $(if $(CONFIG_OPENVPN_POLARSSL),--with-crypto-library=polarssl) \
+ )
+endef
+
+define Package/openvpn-$(BUILD_VARIANT)/conffiles
+/etc/config/openvpn
+endef
+
+define Package/openvpn-$(BUILD_VARIANT)/install
+ $(INSTALL_DIR) \
+ $(1)/usr/sbin \
+ $(1)/etc/init.d \
+ $(1)/etc/config \
+ $(1)/etc/openvpn \
+ $(1)/lib/upgrade/keep.d
+
+ $(INSTALL_BIN) \
+ $(PKG_INSTALL_DIR)/usr/sbin/openvpn \
+ $(1)/usr/sbin/
+
+ $(INSTALL_BIN) \
+ files/openvpn.init \
+ $(1)/etc/init.d/openvpn
+
+ $(INSTALL_CONF) files/openvpn.config \
+ $(1)/etc/config/openvpn
+
+ $(INSTALL_DATA) \
+ files/openvpn.upgrade \
+ $(1)/lib/upgrade/keep.d/openvpn
+endef
+
+$(eval $(call BuildPackage,openvpn-openssl))
+$(eval $(call BuildPackage,openvpn-polarssl))
+$(eval $(call BuildPackage,openvpn-nossl))
diff --git a/package/network/services/openvpn/files/.svn/entries b/package/network/services/openvpn/files/.svn/entries
new file mode 100644
index 0000000..12da251
--- /dev/null
+++ b/package/network/services/openvpn/files/.svn/entries
@@ -0,0 +1,130 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/services/openvpn/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-02-05T10:40:13.957819Z
+35498
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+openvpn.init
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+227914a428811751ce601ae58511eee2
+2013-01-30T20:07:15.369663Z
+35412
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4369
+
+openvpn.config
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+ed2fcc6cb24a838e99796a965a9ecb07
+2013-01-30T20:07:15.369663Z
+35412
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+13010
+
+openvpn.upgrade
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+e1658ae540a99e9984bd6ac112350596
+2013-01-30T20:07:15.369663Z
+35412
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+14
+
diff --git a/package/network/services/openvpn/files/.svn/text-base/openvpn.config.svn-base b/package/network/services/openvpn/files/.svn/text-base/openvpn.config.svn-base
new file mode 100644
index 0000000..4a1f667
--- /dev/null
+++ b/package/network/services/openvpn/files/.svn/text-base/openvpn.config.svn-base
@@ -0,0 +1,398 @@
+package openvpn
+
+#################################################
+# Sample to include a custom config file. #
+#################################################
+
+config openvpn custom_config
+
+ # Set to 1 to enable this instance:
+ option enabled 0
+
+ # Include OpenVPN configuration
+ option config /etc/openvpn/my-vpn.conf
+
+
+#################################################
+# Sample OpenVPN 2.0 uci config for #
+# multi-client server. #
+#################################################
+
+config openvpn sample_server
+
+ # Set to 1 to enable this instance:
+ option enabled 0
+
+ # Which local IP address should OpenVPN
+ # listen on? (optional)
+# option local 0.0.0.0
+
+ # Which TCP/UDP port should OpenVPN listen on?
+ # If you want to run multiple OpenVPN instances
+ # on the same machine, use a different port
+ # number for each one. You will need to
+ # open up this port on your firewall.
+ option port 1194
+
+ # TCP or UDP server?
+# option proto tcp
+ option proto udp
+
+ # "dev tun" will create a routed IP tunnel,
+ # "dev tap" will create an ethernet tunnel.
+ # Use "dev tap0" if you are ethernet bridging
+ # and have precreated a tap0 virtual interface
+ # and bridged it with your ethernet interface.
+ # If you want to control access policies
+ # over the VPN, you must create firewall
+ # rules for the the TUN/TAP interface.
+ # On non-Windows systems, you can give
+ # an explicit unit number, such as tun0.
+ # On Windows, use "dev-node" for this.
+ # On most systems, the VPN will not function
+ # unless you partially or fully disable
+ # the firewall for the TUN/TAP interface.
+# option dev tap
+ option dev tun
+
+ # SSL/TLS root certificate (ca), certificate
+ # (cert), and private key (key). Each client
+ # and the server must have their own cert and
+ # key file. The server and all clients will
+ # use the same ca file.
+ #
+ # See the "easy-rsa" directory for a series
+ # of scripts for generating RSA certificates
+ # and private keys. Remember to use
+ # a unique Common Name for the server
+ # and each of the client certificates.
+ #
+ # Any X509 key management system can be used.
+ # OpenVPN can also use a PKCS #12 formatted key file
+ # (see "pkcs12" directive in man page).
+ option ca /etc/openvpn/ca.crt
+ option cert /etc/openvpn/server.crt
+ # This file should be kept secret:
+ option key /etc/openvpn/server.key
+
+ # Diffie hellman parameters.
+ # Generate your own with:
+ # openssl dhparam -out dh1024.pem 1024
+ # Substitute 2048 for 1024 if you are using
+ # 2048 bit keys.
+ option dh /etc/openvpn/dh1024.pem
+
+ # Configure server mode and supply a VPN subnet
+ # for OpenVPN to draw client addresses from.
+ # The server will take 10.8.0.1 for itself,
+ # the rest will be made available to clients.
+ # Each client will be able to reach the server
+ # on 10.8.0.1. Comment this line out if you are
+ # ethernet bridging. See the man page for more info.
+ option server "10.8.0.0 255.255.255.0"
+
+ # Maintain a record of client <-> virtual IP address
+ # associations in this file. If OpenVPN goes down or
+ # is restarted, reconnecting clients can be assigned
+ # the same virtual IP address from the pool that was
+ # previously assigned.
+ option ifconfig_pool_persist /tmp/ipp.txt
+
+ # Configure server mode for ethernet bridging.
+ # You must first use your OS's bridging capability
+ # to bridge the TAP interface with the ethernet
+ # NIC interface. Then you must manually set the
+ # IP/netmask on the bridge interface, here we
+ # assume 10.8.0.4/255.255.255.0. Finally we
+ # must set aside an IP range in this subnet
+ # (start=10.8.0.50 end=10.8.0.100) to allocate
+ # to connecting clients. Leave this line commented
+ # out unless you are ethernet bridging.
+# option server_bridge "10.8.0.4 255.255.255.0 10.8.0.50 10.8.0.100"
+
+ # Push routes to the client to allow it
+ # to reach other private subnets behind
+ # the server. Remember that these
+ # private subnets will also need
+ # to know to route the OpenVPN client
+ # address pool (10.8.0.0/255.255.255.0)
+ # back to the OpenVPN server.
+# list push "route 192.168.10.0 255.255.255.0"
+# list push "route 192.168.20.0 255.255.255.0"
+
+ # To assign specific IP addresses to specific
+ # clients or if a connecting client has a private
+ # subnet behind it that should also have VPN access,
+ # use the subdirectory "ccd" for client-specific
+ # configuration files (see man page for more info).
+
+ # EXAMPLE: Suppose the client
+ # having the certificate common name "Thelonious"
+ # also has a small subnet behind his connecting
+ # machine, such as 192.168.40.128/255.255.255.248.
+ # First, uncomment out these lines:
+# option client_config_dir /etc/openvpn/ccd
+# list route "192.168.40.128 255.255.255.248"
+ # Then create a file ccd/Thelonious with this line:
+ # iroute 192.168.40.128 255.255.255.248
+ # This will allow Thelonious' private subnet to
+ # access the VPN. This example will only work
+ # if you are routing, not bridging, i.e. you are
+ # using "dev tun" and "server" directives.
+
+ # EXAMPLE: Suppose you want to give
+ # Thelonious a fixed VPN IP address of 10.9.0.1.
+ # First uncomment out these lines:
+# option client_config_dir /etc/openvpn/ccd
+# list route "10.9.0.0 255.255.255.252"
+# list route "192.168.100.0 255.255.255.0"
+ # Then add this line to ccd/Thelonious:
+ # ifconfig-push "10.9.0.1 10.9.0.2"
+
+ # Suppose that you want to enable different
+ # firewall access policies for different groups
+ # of clients. There are two methods:
+ # (1) Run multiple OpenVPN daemons, one for each
+ # group, and firewall the TUN/TAP interface
+ # for each group/daemon appropriately.
+ # (2) (Advanced) Create a script to dynamically
+ # modify the firewall in response to access
+ # from different clients. See man
+ # page for more info on learn-address script.
+# option learn_address /etc/openvpn/script
+
+ # If enabled, this directive will configure
+ # all clients to redirect their default
+ # network gateway through the VPN, causing
+ # all IP traffic such as web browsing and
+ # and DNS lookups to go through the VPN
+ # (The OpenVPN server machine may need to NAT
+ # the TUN/TAP interface to the internet in
+ # order for this to work properly).
+ # CAVEAT: May break client's network config if
+ # client's local DHCP server packets get routed
+ # through the tunnel. Solution: make sure
+ # client's local DHCP server is reachable via
+ # a more specific route than the default route
+ # of 0.0.0.0/0.0.0.0.
+# list push "redirect-gateway"
+
+ # Certain Windows-specific network settings
+ # can be pushed to clients, such as DNS
+ # or WINS server addresses. CAVEAT:
+ # http://openvpn.net/faq.html#dhcpcaveats
+# list push "dhcp-option DNS 10.8.0.1"
+# list push "dhcp-option WINS 10.8.0.1"
+
+ # Uncomment this directive to allow different
+ # clients to be able to "see" each other.
+ # By default, clients will only see the server.
+ # To force clients to only see the server, you
+ # will also need to appropriately firewall the
+ # server's TUN/TAP interface.
+# option client_to_client 1
+
+ # Uncomment this directive if multiple clients
+ # might connect with the same certificate/key
+ # files or common names. This is recommended
+ # only for testing purposes. For production use,
+ # each client should have its own certificate/key
+ # pair.
+ #
+ # IF YOU HAVE NOT GENERATED INDIVIDUAL
+ # CERTIFICATE/KEY PAIRS FOR EACH CLIENT,
+ # EACH HAVING ITS OWN UNIQUE "COMMON NAME",
+ # UNCOMMENT THIS LINE OUT.
+# option duplicate_cn 1
+
+ # The keepalive directive causes ping-like
+ # messages to be sent back and forth over
+ # the link so that each side knows when
+ # the other side has gone down.
+ # Ping every 10 seconds, assume that remote
+ # peer is down if no ping received during
+ # a 120 second time period.
+ option keepalive "10 120"
+
+ # For extra security beyond that provided
+ # by SSL/TLS, create an "HMAC firewall"
+ # to help block DoS attacks and UDP port flooding.
+ #
+ # Generate with:
+ # openvpn --genkey --secret ta.key
+ #
+ # The server and each client must have
+ # a copy of this key.
+ # The second parameter should be '0'
+ # on the server and '1' on the clients.
+ # This file is secret:
+# option tls_auth "/etc/openvpn/ta.key 0"
+
+ # Select a cryptographic cipher.
+ # This config item must be copied to
+ # the client config file as well.
+ # Blowfish (default):
+# option cipher BF-CBC
+ # AES:
+# option cipher AES-128-CBC
+ # Triple-DES:
+# option cipher DES-EDE3-CBC
+
+ # Enable compression on the VPN link.
+ # If you enable it here, you must also
+ # enable it in the client config file.
+ option comp_lzo 1
+
+ # The maximum number of concurrently connected
+ # clients we want to allow.
+# option max_clients 100
+
+ # The persist options will try to avoid
+ # accessing certain resources on restart
+ # that may no longer be accessible because
+ # of the privilege downgrade.
+ option persist_key 1
+ option persist_tun 1
+
+ # Output a short status file showing
+ # current connections, truncated
+ # and rewritten every minute.
+ option status /tmp/openvpn-status.log
+
+ # By default, log messages will go to the syslog (or
+ # on Windows, if running as a service, they will go to
+ # the "\Program Files\OpenVPN\log" directory).
+ # Use log or log-append to override this default.
+ # "log" will truncate the log file on OpenVPN startup,
+ # while "log-append" will append to it. Use one
+ # or the other (but not both).
+# option log /tmp/openvpn.log
+# option log_append /tmp/openvpn.log
+
+ # Set the appropriate level of log
+ # file verbosity.
+ #
+ # 0 is silent, except for fatal errors
+ # 4 is reasonable for general usage
+ # 5 and 6 can help to debug connection problems
+ # 9 is extremely verbose
+ option verb 3
+
+ # Silence repeating messages. At most 20
+ # sequential messages of the same message
+ # category will be output to the log.
+# option mute 20
+
+
+##############################################
+# Sample client-side OpenVPN 2.0 uci config #
+# for connecting to multi-client server. #
+##############################################
+
+config openvpn sample_client
+
+ # Set to 1 to enable this instance:
+ option enabled 0
+
+ # Specify that we are a client and that we
+ # will be pulling certain config file directives
+ # from the server.
+ option client 1
+
+ # Use the same setting as you are using on
+ # the server.
+ # On most systems, the VPN will not function
+ # unless you partially or fully disable
+ # the firewall for the TUN/TAP interface.
+# option dev tap
+ option dev tun
+
+ # Are we connecting to a TCP or
+ # UDP server? Use the same setting as
+ # on the server.
+# option proto tcp
+ option proto udp
+
+ # The hostname/IP and port of the server.
+ # You can have multiple remote entries
+ # to load balance between the servers.
+ list remote "my_server_1 1194"
+# list remote "my_server_2 1194"
+
+ # Choose a random host from the remote
+ # list for load_balancing. Otherwise
+ # try hosts in the order specified.
+# option remote_random 1
+
+ # Keep trying indefinitely to resolve the
+ # host name of the OpenVPN server. Very useful
+ # on machines which are not permanently connected
+ # to the internet such as laptops.
+ option resolv_retry infinite
+
+ # Most clients don't need to bind to
+ # a specific local port number.
+ option nobind 1
+
+ # Try to preserve some state across restarts.
+ option persist_key 1
+ option persist_tun 1
+
+ # If you are connecting through an
+ # HTTP proxy to reach the actual OpenVPN
+ # server, put the proxy server/IP and
+ # port number here. See the man page
+ # if your proxy server requires
+ # authentication.
+ # retry on connection failures:
+# option http_proxy_retry 1
+ # specify http proxy address and port:
+# option http_proxy "192.168.1.100 8080"
+
+ # Wireless networks often produce a lot
+ # of duplicate packets. Set this flag
+ # to silence duplicate packet warnings.
+# option mute_replay_warnings 1
+
+ # SSL/TLS parms.
+ # See the server config file for more
+ # description. It's best to use
+ # a separate .crt/.key file pair
+ # for each client. A single ca
+ # file can be used for all clients.
+ option ca /etc/openvpn/ca.crt
+ option cert /etc/openvpn/client.crt
+ option key /etc/openvpn/client.key
+
+ # Verify server certificate by checking
+ # that the certicate has the nsCertType
+ # field set to "server". This is an
+ # important precaution to protect against
+ # a potential attack discussed here:
+ # http://openvpn.net/howto.html#mitm
+ #
+ # To use this feature, you will need to generate
+ # your server certificates with the nsCertType
+ # field set to "server". The build_key_server
+ # script in the easy_rsa folder will do this.
+# option ns_cert_type server
+
+ # If a tls_auth key is used on the server
+ # then every client must also have the key.
+# option tls_auth "/etc/openvpn/ta.key 1"
+
+ # Select a cryptographic cipher.
+ # If the cipher option is used on the server
+ # then you must also specify it here.
+# option cipher x
+
+ # Enable compression on the VPN link.
+ # Don't enable this unless it is also
+ # enabled in the server config file.
+ option comp_lzo 1
+
+ # Set log file verbosity.
+ option verb 3
+
+ # Silence repeating messages
+# option mute 20
diff --git a/package/network/services/openvpn/files/.svn/text-base/openvpn.init.svn-base b/package/network/services/openvpn/files/.svn/text-base/openvpn.init.svn-base
new file mode 100644
index 0000000..c58f005
--- /dev/null
+++ b/package/network/services/openvpn/files/.svn/text-base/openvpn.init.svn-base
@@ -0,0 +1,154 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2008-2011 OpenWrt.org
+# Copyright (C) 2008 Jo-Philipp Wich
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+
+START=95
+
+SERVICE_DAEMONIZE=1
+SERVICE_WRITE_PID=1
+
+EXTRA_COMMANDS="up down"
+
+LIST_SEP="
+"
+
+append_param() {
+ local v="$1"
+ case "$v" in
+ *_*_*_*) v=${v%%_*}-${v#*_}; v=${v%%_*}-${v#*_}; v=${v%%_*}-${v#*_} ;;
+ *_*_*) v=${v%%_*}-${v#*_}; v=${v%%_*}-${v#*_} ;;
+ *_*) v=${v%%_*}-${v#*_} ;;
+ esac
+ ARGS="$ARGS --$v"
+ return 0
+}
+
+append_bools() {
+ local p; local v; local s="$1"; shift
+ for p in $*; do
+ config_get_bool v "$s" "$p"
+ [ "$v" == 1 ] && append_param "$p"
+ done
+}
+
+append_params() {
+ local p; local v; local s="$1"; shift
+ for p in $*; do
+ config_get v "$s" "$p"
+ IFS="$LIST_SEP"
+ for v in $v; do
+ [ -n "$v" ] && append_param "$p" && ARGS="$ARGS $v"
+ done
+ unset IFS
+ done
+}
+
+section_enabled() {
+ config_get_bool enable "$1" 'enable' 0
+ config_get_bool enabled "$1" 'enabled' 0
+ [ $enable -gt 0 ] || [ $enabled -gt 0 ]
+}
+
+start_instance() {
+ local s="$1"
+
+ section_enabled "$s" || return 1
+
+ ARGS=""
+
+ # append flags
+ append_bools "$s" \
+ auth_nocache auth_retry auth_user_pass_optional bind ccd_exclusive client client_cert_not_required \
+ client_to_client comp_lzo comp_noadapt disable \
+ disable_occ down_pre duplicate_cn fast_io float http_proxy_retry \
+ ifconfig_noexec ifconfig_nowarn ifconfig_pool_linear management_forget_disconnect management_hold \
+ management_query_passwords management_signal mktun mlock mtu_test multihome mute_replay_warnings \
+ nobind no_iv no_name_remapping no_replay opt_verify passtos persist_key persist_local_ip \
+ persist_remote_ip persist_tun ping_timer_rem pull push_reset \
+ remote_random rmtun route_noexec route_nopull single_session socks_proxy_retry \
+ suppress_timestamps tcp_nodelay test_crypto tls_client tls_exit tls_server \
+ tun_ipv6 up_delay up_restart username_as_common_name
+
+ # append params
+ append_params "$s" \
+ cd askpass auth auth_user_pass auth_user_pass_verify bcast_buffers ca cert \
+ chroot cipher client_config_dir client_connect client_disconnect config connect_freq \
+ connect_retry connect_timeout connect_retry_max crl_verify dev dev_node dev_type dh \
+ echo engine explicit_exit_notify fragment group hand_window hash_size \
+ http_proxy http_proxy_option http_proxy_timeout ifconfig ifconfig_pool \
+ ifconfig_pool_persist ifconfig_push inactive ipchange iroute keepalive \
+ key key_method keysize learn_address link_mtu lladdr local log log_append \
+ lport management management_log_cache max_clients \
+ max_routes_per_client mode mssfix mtu_disc mute nice ns_cert_type ping \
+ ping_exit ping_restart pkcs12 plugin port port_share prng proto rcvbuf \
+ redirect_gateway remap_usr1 remote remote_cert_eku remote_cert_ku remote_cert_tls \
+ reneg_bytes reneg_pkts reneg_sec \
+ replay_persist replay_window resolv_retry route route_delay route_gateway \
+ route_metric route_up rport script_security secret server server_bridge setenv shaper sndbuf \
+ socks_proxy status status_version syslog tcp_queue_limit tls_auth \
+ tls_cipher tls_remote tls_timeout tls_verify tmp_dir topology tran_window \
+ tun_mtu tun_mtu_extra txqueuelen user verb down push up
+
+
+ SERVICE_PID_FILE="/var/run/openvpn-$s.pid"
+ service_start /usr/sbin/openvpn --syslog "openvpn($s)" --writepid "$SERVICE_PID_FILE" $ARGS
+}
+
+stop_instance() {
+ local s="$1"
+
+ section_enabled "$s" || return 1
+
+ SERVICE_PID_FILE="/var/run/openvpn-$s.pid"
+ service_stop /usr/sbin/openvpn
+}
+
+reload_instance() {
+ local s="$1"
+
+ section_enabled "$s" || return 1
+
+ SERVICE_PID_FILE="/var/run/openvpn-$s.pid"
+ service_reload /usr/sbin/openvpn
+}
+
+start() {
+ config_load 'openvpn'
+ config_foreach start_instance 'openvpn'
+}
+
+stop() {
+ config_load 'openvpn'
+ config_foreach stop_instance 'openvpn'
+}
+
+reload() {
+ config_load 'openvpn'
+ config_foreach reload_instance 'openvpn'
+}
+
+up() {
+ local exists
+ local instance
+ config_load 'openvpn'
+ for instance in "$@"; do
+ config_get exists "$instance" 'TYPE'
+ if [ "$exists" == "openvpn" ]; then
+ start_instance "$instance"
+ fi
+ done
+}
+
+down() {
+ local exists
+ local instance
+ config_load 'openvpn'
+ for instance in "$@"; do
+ config_get exists "$instance" 'TYPE'
+ if [ "$exists" == "openvpn" ]; then
+ stop_instance "$instance"
+ fi
+ done
+}
diff --git a/package/network/services/openvpn/files/.svn/text-base/openvpn.upgrade.svn-base b/package/network/services/openvpn/files/.svn/text-base/openvpn.upgrade.svn-base
new file mode 100644
index 0000000..6ae49d2
--- /dev/null
+++ b/package/network/services/openvpn/files/.svn/text-base/openvpn.upgrade.svn-base
@@ -0,0 +1 @@
+/etc/openvpn/
diff --git a/package/network/services/openvpn/files/openvpn.config b/package/network/services/openvpn/files/openvpn.config
new file mode 100644
index 0000000..4a1f667
--- /dev/null
+++ b/package/network/services/openvpn/files/openvpn.config
@@ -0,0 +1,398 @@
+package openvpn
+
+#################################################
+# Sample to include a custom config file. #
+#################################################
+
+config openvpn custom_config
+
+ # Set to 1 to enable this instance:
+ option enabled 0
+
+ # Include OpenVPN configuration
+ option config /etc/openvpn/my-vpn.conf
+
+
+#################################################
+# Sample OpenVPN 2.0 uci config for #
+# multi-client server. #
+#################################################
+
+config openvpn sample_server
+
+ # Set to 1 to enable this instance:
+ option enabled 0
+
+ # Which local IP address should OpenVPN
+ # listen on? (optional)
+# option local 0.0.0.0
+
+ # Which TCP/UDP port should OpenVPN listen on?
+ # If you want to run multiple OpenVPN instances
+ # on the same machine, use a different port
+ # number for each one. You will need to
+ # open up this port on your firewall.
+ option port 1194
+
+ # TCP or UDP server?
+# option proto tcp
+ option proto udp
+
+ # "dev tun" will create a routed IP tunnel,
+ # "dev tap" will create an ethernet tunnel.
+ # Use "dev tap0" if you are ethernet bridging
+ # and have precreated a tap0 virtual interface
+ # and bridged it with your ethernet interface.
+ # If you want to control access policies
+ # over the VPN, you must create firewall
+ # rules for the the TUN/TAP interface.
+ # On non-Windows systems, you can give
+ # an explicit unit number, such as tun0.
+ # On Windows, use "dev-node" for this.
+ # On most systems, the VPN will not function
+ # unless you partially or fully disable
+ # the firewall for the TUN/TAP interface.
+# option dev tap
+ option dev tun
+
+ # SSL/TLS root certificate (ca), certificate
+ # (cert), and private key (key). Each client
+ # and the server must have their own cert and
+ # key file. The server and all clients will
+ # use the same ca file.
+ #
+ # See the "easy-rsa" directory for a series
+ # of scripts for generating RSA certificates
+ # and private keys. Remember to use
+ # a unique Common Name for the server
+ # and each of the client certificates.
+ #
+ # Any X509 key management system can be used.
+ # OpenVPN can also use a PKCS #12 formatted key file
+ # (see "pkcs12" directive in man page).
+ option ca /etc/openvpn/ca.crt
+ option cert /etc/openvpn/server.crt
+ # This file should be kept secret:
+ option key /etc/openvpn/server.key
+
+ # Diffie hellman parameters.
+ # Generate your own with:
+ # openssl dhparam -out dh1024.pem 1024
+ # Substitute 2048 for 1024 if you are using
+ # 2048 bit keys.
+ option dh /etc/openvpn/dh1024.pem
+
+ # Configure server mode and supply a VPN subnet
+ # for OpenVPN to draw client addresses from.
+ # The server will take 10.8.0.1 for itself,
+ # the rest will be made available to clients.
+ # Each client will be able to reach the server
+ # on 10.8.0.1. Comment this line out if you are
+ # ethernet bridging. See the man page for more info.
+ option server "10.8.0.0 255.255.255.0"
+
+ # Maintain a record of client <-> virtual IP address
+ # associations in this file. If OpenVPN goes down or
+ # is restarted, reconnecting clients can be assigned
+ # the same virtual IP address from the pool that was
+ # previously assigned.
+ option ifconfig_pool_persist /tmp/ipp.txt
+
+ # Configure server mode for ethernet bridging.
+ # You must first use your OS's bridging capability
+ # to bridge the TAP interface with the ethernet
+ # NIC interface. Then you must manually set the
+ # IP/netmask on the bridge interface, here we
+ # assume 10.8.0.4/255.255.255.0. Finally we
+ # must set aside an IP range in this subnet
+ # (start=10.8.0.50 end=10.8.0.100) to allocate
+ # to connecting clients. Leave this line commented
+ # out unless you are ethernet bridging.
+# option server_bridge "10.8.0.4 255.255.255.0 10.8.0.50 10.8.0.100"
+
+ # Push routes to the client to allow it
+ # to reach other private subnets behind
+ # the server. Remember that these
+ # private subnets will also need
+ # to know to route the OpenVPN client
+ # address pool (10.8.0.0/255.255.255.0)
+ # back to the OpenVPN server.
+# list push "route 192.168.10.0 255.255.255.0"
+# list push "route 192.168.20.0 255.255.255.0"
+
+ # To assign specific IP addresses to specific
+ # clients or if a connecting client has a private
+ # subnet behind it that should also have VPN access,
+ # use the subdirectory "ccd" for client-specific
+ # configuration files (see man page for more info).
+
+ # EXAMPLE: Suppose the client
+ # having the certificate common name "Thelonious"
+ # also has a small subnet behind his connecting
+ # machine, such as 192.168.40.128/255.255.255.248.
+ # First, uncomment out these lines:
+# option client_config_dir /etc/openvpn/ccd
+# list route "192.168.40.128 255.255.255.248"
+ # Then create a file ccd/Thelonious with this line:
+ # iroute 192.168.40.128 255.255.255.248
+ # This will allow Thelonious' private subnet to
+ # access the VPN. This example will only work
+ # if you are routing, not bridging, i.e. you are
+ # using "dev tun" and "server" directives.
+
+ # EXAMPLE: Suppose you want to give
+ # Thelonious a fixed VPN IP address of 10.9.0.1.
+ # First uncomment out these lines:
+# option client_config_dir /etc/openvpn/ccd
+# list route "10.9.0.0 255.255.255.252"
+# list route "192.168.100.0 255.255.255.0"
+ # Then add this line to ccd/Thelonious:
+ # ifconfig-push "10.9.0.1 10.9.0.2"
+
+ # Suppose that you want to enable different
+ # firewall access policies for different groups
+ # of clients. There are two methods:
+ # (1) Run multiple OpenVPN daemons, one for each
+ # group, and firewall the TUN/TAP interface
+ # for each group/daemon appropriately.
+ # (2) (Advanced) Create a script to dynamically
+ # modify the firewall in response to access
+ # from different clients. See man
+ # page for more info on learn-address script.
+# option learn_address /etc/openvpn/script
+
+ # If enabled, this directive will configure
+ # all clients to redirect their default
+ # network gateway through the VPN, causing
+ # all IP traffic such as web browsing and
+ # and DNS lookups to go through the VPN
+ # (The OpenVPN server machine may need to NAT
+ # the TUN/TAP interface to the internet in
+ # order for this to work properly).
+ # CAVEAT: May break client's network config if
+ # client's local DHCP server packets get routed
+ # through the tunnel. Solution: make sure
+ # client's local DHCP server is reachable via
+ # a more specific route than the default route
+ # of 0.0.0.0/0.0.0.0.
+# list push "redirect-gateway"
+
+ # Certain Windows-specific network settings
+ # can be pushed to clients, such as DNS
+ # or WINS server addresses. CAVEAT:
+ # http://openvpn.net/faq.html#dhcpcaveats
+# list push "dhcp-option DNS 10.8.0.1"
+# list push "dhcp-option WINS 10.8.0.1"
+
+ # Uncomment this directive to allow different
+ # clients to be able to "see" each other.
+ # By default, clients will only see the server.
+ # To force clients to only see the server, you
+ # will also need to appropriately firewall the
+ # server's TUN/TAP interface.
+# option client_to_client 1
+
+ # Uncomment this directive if multiple clients
+ # might connect with the same certificate/key
+ # files or common names. This is recommended
+ # only for testing purposes. For production use,
+ # each client should have its own certificate/key
+ # pair.
+ #
+ # IF YOU HAVE NOT GENERATED INDIVIDUAL
+ # CERTIFICATE/KEY PAIRS FOR EACH CLIENT,
+ # EACH HAVING ITS OWN UNIQUE "COMMON NAME",
+ # UNCOMMENT THIS LINE OUT.
+# option duplicate_cn 1
+
+ # The keepalive directive causes ping-like
+ # messages to be sent back and forth over
+ # the link so that each side knows when
+ # the other side has gone down.
+ # Ping every 10 seconds, assume that remote
+ # peer is down if no ping received during
+ # a 120 second time period.
+ option keepalive "10 120"
+
+ # For extra security beyond that provided
+ # by SSL/TLS, create an "HMAC firewall"
+ # to help block DoS attacks and UDP port flooding.
+ #
+ # Generate with:
+ # openvpn --genkey --secret ta.key
+ #
+ # The server and each client must have
+ # a copy of this key.
+ # The second parameter should be '0'
+ # on the server and '1' on the clients.
+ # This file is secret:
+# option tls_auth "/etc/openvpn/ta.key 0"
+
+ # Select a cryptographic cipher.
+ # This config item must be copied to
+ # the client config file as well.
+ # Blowfish (default):
+# option cipher BF-CBC
+ # AES:
+# option cipher AES-128-CBC
+ # Triple-DES:
+# option cipher DES-EDE3-CBC
+
+ # Enable compression on the VPN link.
+ # If you enable it here, you must also
+ # enable it in the client config file.
+ option comp_lzo 1
+
+ # The maximum number of concurrently connected
+ # clients we want to allow.
+# option max_clients 100
+
+ # The persist options will try to avoid
+ # accessing certain resources on restart
+ # that may no longer be accessible because
+ # of the privilege downgrade.
+ option persist_key 1
+ option persist_tun 1
+
+ # Output a short status file showing
+ # current connections, truncated
+ # and rewritten every minute.
+ option status /tmp/openvpn-status.log
+
+ # By default, log messages will go to the syslog (or
+ # on Windows, if running as a service, they will go to
+ # the "\Program Files\OpenVPN\log" directory).
+ # Use log or log-append to override this default.
+ # "log" will truncate the log file on OpenVPN startup,
+ # while "log-append" will append to it. Use one
+ # or the other (but not both).
+# option log /tmp/openvpn.log
+# option log_append /tmp/openvpn.log
+
+ # Set the appropriate level of log
+ # file verbosity.
+ #
+ # 0 is silent, except for fatal errors
+ # 4 is reasonable for general usage
+ # 5 and 6 can help to debug connection problems
+ # 9 is extremely verbose
+ option verb 3
+
+ # Silence repeating messages. At most 20
+ # sequential messages of the same message
+ # category will be output to the log.
+# option mute 20
+
+
+##############################################
+# Sample client-side OpenVPN 2.0 uci config #
+# for connecting to multi-client server. #
+##############################################
+
+config openvpn sample_client
+
+ # Set to 1 to enable this instance:
+ option enabled 0
+
+ # Specify that we are a client and that we
+ # will be pulling certain config file directives
+ # from the server.
+ option client 1
+
+ # Use the same setting as you are using on
+ # the server.
+ # On most systems, the VPN will not function
+ # unless you partially or fully disable
+ # the firewall for the TUN/TAP interface.
+# option dev tap
+ option dev tun
+
+ # Are we connecting to a TCP or
+ # UDP server? Use the same setting as
+ # on the server.
+# option proto tcp
+ option proto udp
+
+ # The hostname/IP and port of the server.
+ # You can have multiple remote entries
+ # to load balance between the servers.
+ list remote "my_server_1 1194"
+# list remote "my_server_2 1194"
+
+ # Choose a random host from the remote
+ # list for load_balancing. Otherwise
+ # try hosts in the order specified.
+# option remote_random 1
+
+ # Keep trying indefinitely to resolve the
+ # host name of the OpenVPN server. Very useful
+ # on machines which are not permanently connected
+ # to the internet such as laptops.
+ option resolv_retry infinite
+
+ # Most clients don't need to bind to
+ # a specific local port number.
+ option nobind 1
+
+ # Try to preserve some state across restarts.
+ option persist_key 1
+ option persist_tun 1
+
+ # If you are connecting through an
+ # HTTP proxy to reach the actual OpenVPN
+ # server, put the proxy server/IP and
+ # port number here. See the man page
+ # if your proxy server requires
+ # authentication.
+ # retry on connection failures:
+# option http_proxy_retry 1
+ # specify http proxy address and port:
+# option http_proxy "192.168.1.100 8080"
+
+ # Wireless networks often produce a lot
+ # of duplicate packets. Set this flag
+ # to silence duplicate packet warnings.
+# option mute_replay_warnings 1
+
+ # SSL/TLS parms.
+ # See the server config file for more
+ # description. It's best to use
+ # a separate .crt/.key file pair
+ # for each client. A single ca
+ # file can be used for all clients.
+ option ca /etc/openvpn/ca.crt
+ option cert /etc/openvpn/client.crt
+ option key /etc/openvpn/client.key
+
+ # Verify server certificate by checking
+ # that the certicate has the nsCertType
+ # field set to "server". This is an
+ # important precaution to protect against
+ # a potential attack discussed here:
+ # http://openvpn.net/howto.html#mitm
+ #
+ # To use this feature, you will need to generate
+ # your server certificates with the nsCertType
+ # field set to "server". The build_key_server
+ # script in the easy_rsa folder will do this.
+# option ns_cert_type server
+
+ # If a tls_auth key is used on the server
+ # then every client must also have the key.
+# option tls_auth "/etc/openvpn/ta.key 1"
+
+ # Select a cryptographic cipher.
+ # If the cipher option is used on the server
+ # then you must also specify it here.
+# option cipher x
+
+ # Enable compression on the VPN link.
+ # Don't enable this unless it is also
+ # enabled in the server config file.
+ option comp_lzo 1
+
+ # Set log file verbosity.
+ option verb 3
+
+ # Silence repeating messages
+# option mute 20
diff --git a/package/network/services/openvpn/files/openvpn.init b/package/network/services/openvpn/files/openvpn.init
new file mode 100644
index 0000000..c58f005
--- /dev/null
+++ b/package/network/services/openvpn/files/openvpn.init
@@ -0,0 +1,154 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2008-2011 OpenWrt.org
+# Copyright (C) 2008 Jo-Philipp Wich
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+
+START=95
+
+SERVICE_DAEMONIZE=1
+SERVICE_WRITE_PID=1
+
+EXTRA_COMMANDS="up down"
+
+LIST_SEP="
+"
+
+append_param() {
+ local v="$1"
+ case "$v" in
+ *_*_*_*) v=${v%%_*}-${v#*_}; v=${v%%_*}-${v#*_}; v=${v%%_*}-${v#*_} ;;
+ *_*_*) v=${v%%_*}-${v#*_}; v=${v%%_*}-${v#*_} ;;
+ *_*) v=${v%%_*}-${v#*_} ;;
+ esac
+ ARGS="$ARGS --$v"
+ return 0
+}
+
+append_bools() {
+ local p; local v; local s="$1"; shift
+ for p in $*; do
+ config_get_bool v "$s" "$p"
+ [ "$v" == 1 ] && append_param "$p"
+ done
+}
+
+append_params() {
+ local p; local v; local s="$1"; shift
+ for p in $*; do
+ config_get v "$s" "$p"
+ IFS="$LIST_SEP"
+ for v in $v; do
+ [ -n "$v" ] && append_param "$p" && ARGS="$ARGS $v"
+ done
+ unset IFS
+ done
+}
+
+section_enabled() {
+ config_get_bool enable "$1" 'enable' 0
+ config_get_bool enabled "$1" 'enabled' 0
+ [ $enable -gt 0 ] || [ $enabled -gt 0 ]
+}
+
+start_instance() {
+ local s="$1"
+
+ section_enabled "$s" || return 1
+
+ ARGS=""
+
+ # append flags
+ append_bools "$s" \
+ auth_nocache auth_retry auth_user_pass_optional bind ccd_exclusive client client_cert_not_required \
+ client_to_client comp_lzo comp_noadapt disable \
+ disable_occ down_pre duplicate_cn fast_io float http_proxy_retry \
+ ifconfig_noexec ifconfig_nowarn ifconfig_pool_linear management_forget_disconnect management_hold \
+ management_query_passwords management_signal mktun mlock mtu_test multihome mute_replay_warnings \
+ nobind no_iv no_name_remapping no_replay opt_verify passtos persist_key persist_local_ip \
+ persist_remote_ip persist_tun ping_timer_rem pull push_reset \
+ remote_random rmtun route_noexec route_nopull single_session socks_proxy_retry \
+ suppress_timestamps tcp_nodelay test_crypto tls_client tls_exit tls_server \
+ tun_ipv6 up_delay up_restart username_as_common_name
+
+ # append params
+ append_params "$s" \
+ cd askpass auth auth_user_pass auth_user_pass_verify bcast_buffers ca cert \
+ chroot cipher client_config_dir client_connect client_disconnect config connect_freq \
+ connect_retry connect_timeout connect_retry_max crl_verify dev dev_node dev_type dh \
+ echo engine explicit_exit_notify fragment group hand_window hash_size \
+ http_proxy http_proxy_option http_proxy_timeout ifconfig ifconfig_pool \
+ ifconfig_pool_persist ifconfig_push inactive ipchange iroute keepalive \
+ key key_method keysize learn_address link_mtu lladdr local log log_append \
+ lport management management_log_cache max_clients \
+ max_routes_per_client mode mssfix mtu_disc mute nice ns_cert_type ping \
+ ping_exit ping_restart pkcs12 plugin port port_share prng proto rcvbuf \
+ redirect_gateway remap_usr1 remote remote_cert_eku remote_cert_ku remote_cert_tls \
+ reneg_bytes reneg_pkts reneg_sec \
+ replay_persist replay_window resolv_retry route route_delay route_gateway \
+ route_metric route_up rport script_security secret server server_bridge setenv shaper sndbuf \
+ socks_proxy status status_version syslog tcp_queue_limit tls_auth \
+ tls_cipher tls_remote tls_timeout tls_verify tmp_dir topology tran_window \
+ tun_mtu tun_mtu_extra txqueuelen user verb down push up
+
+
+ SERVICE_PID_FILE="/var/run/openvpn-$s.pid"
+ service_start /usr/sbin/openvpn --syslog "openvpn($s)" --writepid "$SERVICE_PID_FILE" $ARGS
+}
+
+stop_instance() {
+ local s="$1"
+
+ section_enabled "$s" || return 1
+
+ SERVICE_PID_FILE="/var/run/openvpn-$s.pid"
+ service_stop /usr/sbin/openvpn
+}
+
+reload_instance() {
+ local s="$1"
+
+ section_enabled "$s" || return 1
+
+ SERVICE_PID_FILE="/var/run/openvpn-$s.pid"
+ service_reload /usr/sbin/openvpn
+}
+
+start() {
+ config_load 'openvpn'
+ config_foreach start_instance 'openvpn'
+}
+
+stop() {
+ config_load 'openvpn'
+ config_foreach stop_instance 'openvpn'
+}
+
+reload() {
+ config_load 'openvpn'
+ config_foreach reload_instance 'openvpn'
+}
+
+up() {
+ local exists
+ local instance
+ config_load 'openvpn'
+ for instance in "$@"; do
+ config_get exists "$instance" 'TYPE'
+ if [ "$exists" == "openvpn" ]; then
+ start_instance "$instance"
+ fi
+ done
+}
+
+down() {
+ local exists
+ local instance
+ config_load 'openvpn'
+ for instance in "$@"; do
+ config_get exists "$instance" 'TYPE'
+ if [ "$exists" == "openvpn" ]; then
+ stop_instance "$instance"
+ fi
+ done
+}
diff --git a/package/network/services/openvpn/files/openvpn.upgrade b/package/network/services/openvpn/files/openvpn.upgrade
new file mode 100644
index 0000000..6ae49d2
--- /dev/null
+++ b/package/network/services/openvpn/files/openvpn.upgrade
@@ -0,0 +1 @@
+/etc/openvpn/
diff --git a/package/network/services/openvpn/patches/.svn/entries b/package/network/services/openvpn/patches/.svn/entries
new file mode 100644
index 0000000..5f7cac3
--- /dev/null
+++ b/package/network/services/openvpn/patches/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/services/openvpn/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-30T20:07:15.369663Z
+35412
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+100-polarssl_update.patch
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+e973ed14f354540c2a511b908fbde793
+2013-01-30T20:07:15.369663Z
+35412
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1903
+
diff --git a/package/network/services/openvpn/patches/.svn/text-base/100-polarssl_update.patch.svn-base b/package/network/services/openvpn/patches/.svn/text-base/100-polarssl_update.patch.svn-base
new file mode 100644
index 0000000..c5c8faf
--- /dev/null
+++ b/package/network/services/openvpn/patches/.svn/text-base/100-polarssl_update.patch.svn-base
@@ -0,0 +1,60 @@
+--- a/src/openvpn/crypto_polarssl.h
++++ b/src/openvpn/crypto_polarssl.h
+@@ -60,7 +60,7 @@ typedef md_context_t hmac_ctx_t;
+ #define OPENVPN_MODE_OFB POLARSSL_MODE_OFB
+
+ /** Cipher is in CFB mode */
+-#define OPENVPN_MODE_CFB POLARSSL_MODE_CFB128
++#define OPENVPN_MODE_CFB POLARSSL_MODE_CFB
+
+ /** Cipher should encrypt */
+ #define OPENVPN_OP_ENCRYPT POLARSSL_ENCRYPT
+--- a/src/openvpn/ssl_polarssl.c
++++ b/src/openvpn/ssl_polarssl.c
+@@ -65,23 +65,6 @@ tls_clear_error()
+ {
+ }
+
+-static int default_ciphersuites[] =
+-{
+- SSL_EDH_RSA_AES_256_SHA,
+- SSL_EDH_RSA_CAMELLIA_256_SHA,
+- SSL_EDH_RSA_AES_128_SHA,
+- SSL_EDH_RSA_CAMELLIA_128_SHA,
+- SSL_EDH_RSA_DES_168_SHA,
+- SSL_RSA_AES_256_SHA,
+- SSL_RSA_CAMELLIA_256_SHA,
+- SSL_RSA_AES_128_SHA,
+- SSL_RSA_CAMELLIA_128_SHA,
+- SSL_RSA_DES_168_SHA,
+- SSL_RSA_RC4_128_SHA,
+- SSL_RSA_RC4_128_MD5,
+- 0
+-};
+-
+ void
+ tls_ctx_server_new(struct tls_root_ctx *ctx)
+ {
+@@ -515,11 +498,11 @@ void key_state_ssl_init(struct key_state
+ ssl_set_rng (ks_ssl->ctx, ctr_drbg_random, rand_ctx_get());
+
+ ALLOC_OBJ_CLEAR (ks_ssl->ssn, ssl_session);
+- ssl_set_session (ks_ssl->ctx, 0, 0, ks_ssl->ssn );
++ ssl_set_session (ks_ssl->ctx, ks_ssl->ssn );
+ if (ssl_ctx->allowed_ciphers)
+ ssl_set_ciphersuites (ks_ssl->ctx, ssl_ctx->allowed_ciphers);
+ else
+- ssl_set_ciphersuites (ks_ssl->ctx, default_ciphersuites);
++ ssl_set_ciphersuites (ks_ssl->ctx, ssl_default_ciphersuites);
+
+ /* Initialise authentication information */
+ if (is_server)
+@@ -828,7 +811,7 @@ print_details (struct key_state_ssl * ks
+ ssl_get_version (ks_ssl->ctx),
+ ssl_get_ciphersuite(ks_ssl->ctx));
+
+- cert = ks_ssl->ctx->peer_cert;
++ cert = ssl_get_peer_cert(ks_ssl->ctx);
+ if (cert != NULL)
+ {
+ openvpn_snprintf (s2, sizeof (s2), ", " counter_format " bit RSA", (counter_type) cert->rsa.len * 8);
diff --git a/package/network/services/openvpn/patches/100-polarssl_update.patch b/package/network/services/openvpn/patches/100-polarssl_update.patch
new file mode 100644
index 0000000..c5c8faf
--- /dev/null
+++ b/package/network/services/openvpn/patches/100-polarssl_update.patch
@@ -0,0 +1,60 @@
+--- a/src/openvpn/crypto_polarssl.h
++++ b/src/openvpn/crypto_polarssl.h
+@@ -60,7 +60,7 @@ typedef md_context_t hmac_ctx_t;
+ #define OPENVPN_MODE_OFB POLARSSL_MODE_OFB
+
+ /** Cipher is in CFB mode */
+-#define OPENVPN_MODE_CFB POLARSSL_MODE_CFB128
++#define OPENVPN_MODE_CFB POLARSSL_MODE_CFB
+
+ /** Cipher should encrypt */
+ #define OPENVPN_OP_ENCRYPT POLARSSL_ENCRYPT
+--- a/src/openvpn/ssl_polarssl.c
++++ b/src/openvpn/ssl_polarssl.c
+@@ -65,23 +65,6 @@ tls_clear_error()
+ {
+ }
+
+-static int default_ciphersuites[] =
+-{
+- SSL_EDH_RSA_AES_256_SHA,
+- SSL_EDH_RSA_CAMELLIA_256_SHA,
+- SSL_EDH_RSA_AES_128_SHA,
+- SSL_EDH_RSA_CAMELLIA_128_SHA,
+- SSL_EDH_RSA_DES_168_SHA,
+- SSL_RSA_AES_256_SHA,
+- SSL_RSA_CAMELLIA_256_SHA,
+- SSL_RSA_AES_128_SHA,
+- SSL_RSA_CAMELLIA_128_SHA,
+- SSL_RSA_DES_168_SHA,
+- SSL_RSA_RC4_128_SHA,
+- SSL_RSA_RC4_128_MD5,
+- 0
+-};
+-
+ void
+ tls_ctx_server_new(struct tls_root_ctx *ctx)
+ {
+@@ -515,11 +498,11 @@ void key_state_ssl_init(struct key_state
+ ssl_set_rng (ks_ssl->ctx, ctr_drbg_random, rand_ctx_get());
+
+ ALLOC_OBJ_CLEAR (ks_ssl->ssn, ssl_session);
+- ssl_set_session (ks_ssl->ctx, 0, 0, ks_ssl->ssn );
++ ssl_set_session (ks_ssl->ctx, ks_ssl->ssn );
+ if (ssl_ctx->allowed_ciphers)
+ ssl_set_ciphersuites (ks_ssl->ctx, ssl_ctx->allowed_ciphers);
+ else
+- ssl_set_ciphersuites (ks_ssl->ctx, default_ciphersuites);
++ ssl_set_ciphersuites (ks_ssl->ctx, ssl_default_ciphersuites);
+
+ /* Initialise authentication information */
+ if (is_server)
+@@ -828,7 +811,7 @@ print_details (struct key_state_ssl * ks
+ ssl_get_version (ks_ssl->ctx),
+ ssl_get_ciphersuite(ks_ssl->ctx));
+
+- cert = ks_ssl->ctx->peer_cert;
++ cert = ssl_get_peer_cert(ks_ssl->ctx);
+ if (cert != NULL)
+ {
+ openvpn_snprintf (s2, sizeof (s2), ", " counter_format " bit RSA", (counter_type) cert->rsa.len * 8);
diff --git a/package/network/services/ppp/.svn/entries b/package/network/services/ppp/.svn/entries
new file mode 100644
index 0000000..58e770a
--- /dev/null
+++ b/package/network/services/ppp/.svn/entries
@@ -0,0 +1,71 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/services/ppp
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-17T08:28:57.760235Z
+35188
+cyrus
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+utils
+dir
+
+files
+dir
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+88d19e93c9a853a316151786ecd2a13f
+2013-01-17T08:28:57.760235Z
+35188
+cyrus
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+7060
+
diff --git a/package/network/services/ppp/.svn/prop-base/Makefile.svn-base b/package/network/services/ppp/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..8e522ae
--- /dev/null
+++ b/package/network/services/ppp/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:copyright
+V 30
+Copyright (C) 2006 OpenWrt.org
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/services/ppp/.svn/text-base/Makefile.svn-base b/package/network/services/ppp/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..9a4640b
--- /dev/null
+++ b/package/network/services/ppp/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,263 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=ppp
+PKG_VERSION:=2.4.5
+PKG_RELEASE:=9
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=ftp://ftp.samba.org/pub/ppp/
+PKG_MD5SUM:=4621bc56167b6953ec4071043fe0ec57
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
+
+PKG_BUILD_DEPENDS:=libpcap
+
+PKG_BUILD_PARALLEL:=1
+PKG_INSTALL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/ppp/Default
+ SECTION:=net
+ CATEGORY:=Network
+ MAINTAINER:=Jo-Philipp Wich <xm@subsignal.org>
+ URL:=http://ppp.samba.org/
+endef
+
+define Package/ppp
+$(call Package/ppp/Default)
+ DEPENDS:=+kmod-ppp
+ TITLE:=PPP daemon
+ VARIANT:=default
+endef
+
+define Package/ppp-multilink
+$(call Package/ppp/Default)
+ DEPENDS:=+kmod-ppp
+ TITLE:=PPP daemon (with multilink support)
+ VARIANT:=multilink
+endef
+
+define Package/ppp/description
+This package contains the PPP (Point-to-Point Protocol) daemon.
+endef
+
+define Package/ppp/conffiles
+/etc/ppp/chap-secrets
+/etc/ppp/filter
+/etc/ppp/ip-down
+/etc/ppp/ip-up
+/etc/ppp/ipv6-down
+/etc/ppp/ipv6-up
+/etc/ppp/options
+endef
+
+define Package/ppp-mod-pppoa
+$(call Package/ppp/Default)
+ DEPENDS:=@(PACKAGE_ppp||PACKAGE_ppp-multilink) +linux-atm +kmod-pppoa
+ TITLE:=PPPoA plugin
+endef
+
+define Package/ppp-mod-pppoa/description
+This package contains a PPPoA (PPP over ATM) plugin for ppp.
+endef
+
+define Package/ppp-mod-pppoe
+$(call Package/ppp/Default)
+ DEPENDS:=@(PACKAGE_ppp||PACKAGE_ppp-multilink) +kmod-pppoe
+ TITLE:=PPPoE plugin
+endef
+
+define Package/ppp-mod-pppoe/description
+This package contains a PPPoE (PPP over Ethernet) plugin for ppp.
+endef
+
+define Package/ppp-mod-radius
+$(call Package/ppp/Default)
+ DEPENDS:=@(PACKAGE_ppp||PACKAGE_ppp-multilink)
+ TITLE:=RADIUS plugin
+endef
+
+define Package/ppp-mod-radius/description
+This package contains a RADIUS (Remote Authentication Dial-In User Service)
+plugin for ppp.
+endef
+
+define Package/ppp-mod-radius/conffiles
+/etc/ppp/radius.conf
+/etc/ppp/radius/
+endef
+
+define Package/ppp-mod-pppol2tp
+$(call Package/ppp/Default)
+ DEPENDS:=@(PACKAGE_ppp||PACKAGE_ppp-multilink) +kmod-pppol2tp
+ TITLE:=PPPoL2TP plugin
+endef
+
+define Package/ppp-mod-pppol2tp/description
+This package contains a PPPoL2TP (PPP over L2TP) plugin for ppp.
+endef
+
+define Package/ppp-mod-pptp
+$(call Package/ppp/Default)
+ DEPENDS:=@(PACKAGE_ppp||PACKAGE_ppp-multilink) +kmod-pptp +kmod-mppe +resolveip
+ TITLE:=PPtP plugin
+endef
+
+define Package/ppp-mod-pptp/description
+This package contains a PPtP plugin for ppp.
+endef
+
+define Package/chat
+$(call Package/ppp/Default)
+ DEPENDS:=@(PACKAGE_ppp||PACKAGE_ppp-multilink)
+ TITLE:=Establish conversation with a modem
+endef
+
+define Package/chat/description
+This package contains an utility to establish conversation with other PPP servers
+(via a modem).
+endef
+
+define Package/pppdump
+$(call Package/ppp/Default)
+ DEPENDS:=@(PACKAGE_ppp||PACKAGE_ppp-multilink)
+ TITLE:=Read PPP record file
+endef
+
+define Package/pppdump/description
+This package contains an utility to read PPP record file.
+endef
+
+define Package/pppstats
+$(call Package/ppp/Default)
+ DEPENDS:=@(PACKAGE_ppp||PACKAGE_ppp-multilink)
+ TITLE:=Report PPP statistics
+endef
+
+define Package/pppstats/description
+This package contains an utility to report PPP statistics.
+endef
+
+
+define Build/Configure
+$(call Build/Configure/Default,, \
+ UNAME_S="Linux" \
+ UNAME_R="$(LINUX_VERSION)" \
+ UNAME_M="$(ARCH)" \
+)
+ mkdir -p $(PKG_BUILD_DIR)/pppd/plugins/pppoatm/linux
+ cp \
+ $(LINUX_DIR)/include/linux/compiler.h \
+ $(LINUX_DIR)/include/$(LINUX_UAPI_DIR)linux/atm*.h \
+ $(PKG_BUILD_DIR)/pppd/plugins/pppoatm/linux/
+endef
+
+MAKE_FLAGS += COPTS="$(TARGET_CFLAGS)" \
+ PRECOMPILED_FILTER=1 \
+ STAGING_DIR="$(STAGING_DIR)"
+
+ifeq ($(BUILD_VARIANT),multilink)
+ MAKE_FLAGS += HAVE_MULTILINK=y
+else
+ MAKE_FLAGS += HAVE_MULTILINK=
+endif
+
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include
+ $(CP) $(PKG_INSTALL_DIR)/include/pppd $(1)/usr/include/
+endef
+
+define Package/ppp/script_install
+endef
+
+define Package/ppp/install
+ $(INSTALL_DIR) $(1)/usr/lib/pppd/$(PKG_VERSION)
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/sbin/pppd $(1)/usr/sbin/
+ $(INSTALL_DIR) $(1)/etc/ppp
+ $(INSTALL_CONF) ./files/etc/ppp/chap-secrets $(1)/etc/ppp/
+ $(INSTALL_DATA) ./files/etc/ppp/filter $(1)/etc/ppp/
+ $(INSTALL_DATA) ./files/etc/ppp/options $(1)/etc/ppp/
+ ln -sf /tmp/resolv.conf.ppp $(1)/etc/ppp/resolv.conf
+ $(INSTALL_DIR) $(1)/lib/netifd/proto
+ $(INSTALL_BIN) ./files/ppp.sh $(1)/lib/netifd/proto/
+ $(INSTALL_BIN) ./files/lib/netifd/ppp-up $(1)/lib/netifd/
+ $(INSTALL_BIN) ./files/lib/netifd/ppp-down $(1)/lib/netifd/
+endef
+Package/ppp-multilink/install=$(Package/ppp/install)
+
+define Package/ppp-mod-pppoa/install
+ $(INSTALL_DIR) $(1)/usr/lib/pppd/$(PKG_VERSION)
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/lib/pppd/$(PKG_VERSION)/pppoatm.so \
+ $(1)/usr/lib/pppd/$(PKG_VERSION)/
+endef
+
+define Package/ppp-mod-pppoe/install
+ $(INSTALL_DIR) $(1)/usr/lib/pppd/$(PKG_VERSION)
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/lib/pppd/$(PKG_VERSION)/rp-pppoe.so \
+ $(1)/usr/lib/pppd/$(PKG_VERSION)/
+endef
+
+define Package/ppp-mod-radius/install
+ $(INSTALL_DIR) $(1)/usr/lib/pppd/$(PKG_VERSION)
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/lib/pppd/$(PKG_VERSION)/radius.so \
+ $(1)/usr/lib/pppd/$(PKG_VERSION)/
+ $(INSTALL_DIR) $(1)/etc/ppp
+ $(INSTALL_DATA) ./files/etc/ppp/radius.conf $(1)/etc/ppp/
+ $(INSTALL_DIR) $(1)/etc/ppp/radius
+ $(INSTALL_DATA) ./files/etc/ppp/radius/dictionary* \
+ $(1)/etc/ppp/radius/
+ $(INSTALL_CONF) ./files/etc/ppp/radius/servers \
+ $(1)/etc/ppp/radius/
+endef
+
+define Package/ppp-mod-pppol2tp/install
+ $(INSTALL_DIR) $(1)/usr/lib/pppd/$(PKG_VERSION)
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/lib/pppd/$(PKG_VERSION)/pppol2tp.so \
+ $(1)/usr/lib/pppd/$(PKG_VERSION)/
+endef
+
+define Package/ppp-mod-pptp/install
+ $(INSTALL_DIR) $(1)/usr/lib/pppd/$(PKG_VERSION)
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/lib/pppd/$(PKG_VERSION)/pptp.so \
+ $(1)/usr/lib/pppd/$(PKG_VERSION)/
+ $(INSTALL_DIR) $(1)/etc/ppp
+ $(INSTALL_DATA) ./files/etc/ppp/options.pptp $(1)/etc/ppp/
+endef
+
+define Package/chat/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/sbin/chat $(1)/usr/sbin/
+endef
+
+define Package/pppdump/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/sbin/pppdump $(1)/usr/sbin/
+endef
+
+define Package/pppstats/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/sbin/pppstats $(1)/usr/sbin/
+endef
+
+$(eval $(call BuildPackage,ppp))
+$(eval $(call BuildPackage,ppp-multilink))
+$(eval $(call BuildPackage,ppp-mod-pppoa))
+$(eval $(call BuildPackage,ppp-mod-pppoe))
+$(eval $(call BuildPackage,ppp-mod-radius))
+$(eval $(call BuildPackage,ppp-mod-pppol2tp))
+$(eval $(call BuildPackage,ppp-mod-pptp))
+$(eval $(call BuildPackage,chat))
+$(eval $(call BuildPackage,pppdump))
+$(eval $(call BuildPackage,pppstats))
diff --git a/package/network/services/ppp/Makefile b/package/network/services/ppp/Makefile
new file mode 100644
index 0000000..9a4640b
--- /dev/null
+++ b/package/network/services/ppp/Makefile
@@ -0,0 +1,263 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=ppp
+PKG_VERSION:=2.4.5
+PKG_RELEASE:=9
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=ftp://ftp.samba.org/pub/ppp/
+PKG_MD5SUM:=4621bc56167b6953ec4071043fe0ec57
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
+
+PKG_BUILD_DEPENDS:=libpcap
+
+PKG_BUILD_PARALLEL:=1
+PKG_INSTALL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/ppp/Default
+ SECTION:=net
+ CATEGORY:=Network
+ MAINTAINER:=Jo-Philipp Wich <xm@subsignal.org>
+ URL:=http://ppp.samba.org/
+endef
+
+define Package/ppp
+$(call Package/ppp/Default)
+ DEPENDS:=+kmod-ppp
+ TITLE:=PPP daemon
+ VARIANT:=default
+endef
+
+define Package/ppp-multilink
+$(call Package/ppp/Default)
+ DEPENDS:=+kmod-ppp
+ TITLE:=PPP daemon (with multilink support)
+ VARIANT:=multilink
+endef
+
+define Package/ppp/description
+This package contains the PPP (Point-to-Point Protocol) daemon.
+endef
+
+define Package/ppp/conffiles
+/etc/ppp/chap-secrets
+/etc/ppp/filter
+/etc/ppp/ip-down
+/etc/ppp/ip-up
+/etc/ppp/ipv6-down
+/etc/ppp/ipv6-up
+/etc/ppp/options
+endef
+
+define Package/ppp-mod-pppoa
+$(call Package/ppp/Default)
+ DEPENDS:=@(PACKAGE_ppp||PACKAGE_ppp-multilink) +linux-atm +kmod-pppoa
+ TITLE:=PPPoA plugin
+endef
+
+define Package/ppp-mod-pppoa/description
+This package contains a PPPoA (PPP over ATM) plugin for ppp.
+endef
+
+define Package/ppp-mod-pppoe
+$(call Package/ppp/Default)
+ DEPENDS:=@(PACKAGE_ppp||PACKAGE_ppp-multilink) +kmod-pppoe
+ TITLE:=PPPoE plugin
+endef
+
+define Package/ppp-mod-pppoe/description
+This package contains a PPPoE (PPP over Ethernet) plugin for ppp.
+endef
+
+define Package/ppp-mod-radius
+$(call Package/ppp/Default)
+ DEPENDS:=@(PACKAGE_ppp||PACKAGE_ppp-multilink)
+ TITLE:=RADIUS plugin
+endef
+
+define Package/ppp-mod-radius/description
+This package contains a RADIUS (Remote Authentication Dial-In User Service)
+plugin for ppp.
+endef
+
+define Package/ppp-mod-radius/conffiles
+/etc/ppp/radius.conf
+/etc/ppp/radius/
+endef
+
+define Package/ppp-mod-pppol2tp
+$(call Package/ppp/Default)
+ DEPENDS:=@(PACKAGE_ppp||PACKAGE_ppp-multilink) +kmod-pppol2tp
+ TITLE:=PPPoL2TP plugin
+endef
+
+define Package/ppp-mod-pppol2tp/description
+This package contains a PPPoL2TP (PPP over L2TP) plugin for ppp.
+endef
+
+define Package/ppp-mod-pptp
+$(call Package/ppp/Default)
+ DEPENDS:=@(PACKAGE_ppp||PACKAGE_ppp-multilink) +kmod-pptp +kmod-mppe +resolveip
+ TITLE:=PPtP plugin
+endef
+
+define Package/ppp-mod-pptp/description
+This package contains a PPtP plugin for ppp.
+endef
+
+define Package/chat
+$(call Package/ppp/Default)
+ DEPENDS:=@(PACKAGE_ppp||PACKAGE_ppp-multilink)
+ TITLE:=Establish conversation with a modem
+endef
+
+define Package/chat/description
+This package contains an utility to establish conversation with other PPP servers
+(via a modem).
+endef
+
+define Package/pppdump
+$(call Package/ppp/Default)
+ DEPENDS:=@(PACKAGE_ppp||PACKAGE_ppp-multilink)
+ TITLE:=Read PPP record file
+endef
+
+define Package/pppdump/description
+This package contains an utility to read PPP record file.
+endef
+
+define Package/pppstats
+$(call Package/ppp/Default)
+ DEPENDS:=@(PACKAGE_ppp||PACKAGE_ppp-multilink)
+ TITLE:=Report PPP statistics
+endef
+
+define Package/pppstats/description
+This package contains an utility to report PPP statistics.
+endef
+
+
+define Build/Configure
+$(call Build/Configure/Default,, \
+ UNAME_S="Linux" \
+ UNAME_R="$(LINUX_VERSION)" \
+ UNAME_M="$(ARCH)" \
+)
+ mkdir -p $(PKG_BUILD_DIR)/pppd/plugins/pppoatm/linux
+ cp \
+ $(LINUX_DIR)/include/linux/compiler.h \
+ $(LINUX_DIR)/include/$(LINUX_UAPI_DIR)linux/atm*.h \
+ $(PKG_BUILD_DIR)/pppd/plugins/pppoatm/linux/
+endef
+
+MAKE_FLAGS += COPTS="$(TARGET_CFLAGS)" \
+ PRECOMPILED_FILTER=1 \
+ STAGING_DIR="$(STAGING_DIR)"
+
+ifeq ($(BUILD_VARIANT),multilink)
+ MAKE_FLAGS += HAVE_MULTILINK=y
+else
+ MAKE_FLAGS += HAVE_MULTILINK=
+endif
+
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include
+ $(CP) $(PKG_INSTALL_DIR)/include/pppd $(1)/usr/include/
+endef
+
+define Package/ppp/script_install
+endef
+
+define Package/ppp/install
+ $(INSTALL_DIR) $(1)/usr/lib/pppd/$(PKG_VERSION)
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/sbin/pppd $(1)/usr/sbin/
+ $(INSTALL_DIR) $(1)/etc/ppp
+ $(INSTALL_CONF) ./files/etc/ppp/chap-secrets $(1)/etc/ppp/
+ $(INSTALL_DATA) ./files/etc/ppp/filter $(1)/etc/ppp/
+ $(INSTALL_DATA) ./files/etc/ppp/options $(1)/etc/ppp/
+ ln -sf /tmp/resolv.conf.ppp $(1)/etc/ppp/resolv.conf
+ $(INSTALL_DIR) $(1)/lib/netifd/proto
+ $(INSTALL_BIN) ./files/ppp.sh $(1)/lib/netifd/proto/
+ $(INSTALL_BIN) ./files/lib/netifd/ppp-up $(1)/lib/netifd/
+ $(INSTALL_BIN) ./files/lib/netifd/ppp-down $(1)/lib/netifd/
+endef
+Package/ppp-multilink/install=$(Package/ppp/install)
+
+define Package/ppp-mod-pppoa/install
+ $(INSTALL_DIR) $(1)/usr/lib/pppd/$(PKG_VERSION)
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/lib/pppd/$(PKG_VERSION)/pppoatm.so \
+ $(1)/usr/lib/pppd/$(PKG_VERSION)/
+endef
+
+define Package/ppp-mod-pppoe/install
+ $(INSTALL_DIR) $(1)/usr/lib/pppd/$(PKG_VERSION)
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/lib/pppd/$(PKG_VERSION)/rp-pppoe.so \
+ $(1)/usr/lib/pppd/$(PKG_VERSION)/
+endef
+
+define Package/ppp-mod-radius/install
+ $(INSTALL_DIR) $(1)/usr/lib/pppd/$(PKG_VERSION)
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/lib/pppd/$(PKG_VERSION)/radius.so \
+ $(1)/usr/lib/pppd/$(PKG_VERSION)/
+ $(INSTALL_DIR) $(1)/etc/ppp
+ $(INSTALL_DATA) ./files/etc/ppp/radius.conf $(1)/etc/ppp/
+ $(INSTALL_DIR) $(1)/etc/ppp/radius
+ $(INSTALL_DATA) ./files/etc/ppp/radius/dictionary* \
+ $(1)/etc/ppp/radius/
+ $(INSTALL_CONF) ./files/etc/ppp/radius/servers \
+ $(1)/etc/ppp/radius/
+endef
+
+define Package/ppp-mod-pppol2tp/install
+ $(INSTALL_DIR) $(1)/usr/lib/pppd/$(PKG_VERSION)
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/lib/pppd/$(PKG_VERSION)/pppol2tp.so \
+ $(1)/usr/lib/pppd/$(PKG_VERSION)/
+endef
+
+define Package/ppp-mod-pptp/install
+ $(INSTALL_DIR) $(1)/usr/lib/pppd/$(PKG_VERSION)
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/lib/pppd/$(PKG_VERSION)/pptp.so \
+ $(1)/usr/lib/pppd/$(PKG_VERSION)/
+ $(INSTALL_DIR) $(1)/etc/ppp
+ $(INSTALL_DATA) ./files/etc/ppp/options.pptp $(1)/etc/ppp/
+endef
+
+define Package/chat/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/sbin/chat $(1)/usr/sbin/
+endef
+
+define Package/pppdump/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/sbin/pppdump $(1)/usr/sbin/
+endef
+
+define Package/pppstats/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/sbin/pppstats $(1)/usr/sbin/
+endef
+
+$(eval $(call BuildPackage,ppp))
+$(eval $(call BuildPackage,ppp-multilink))
+$(eval $(call BuildPackage,ppp-mod-pppoa))
+$(eval $(call BuildPackage,ppp-mod-pppoe))
+$(eval $(call BuildPackage,ppp-mod-radius))
+$(eval $(call BuildPackage,ppp-mod-pppol2tp))
+$(eval $(call BuildPackage,ppp-mod-pptp))
+$(eval $(call BuildPackage,chat))
+$(eval $(call BuildPackage,pppdump))
+$(eval $(call BuildPackage,pppstats))
diff --git a/package/network/services/ppp/files/.svn/entries b/package/network/services/ppp/files/.svn/entries
new file mode 100644
index 0000000..61eb5de
--- /dev/null
+++ b/package/network/services/ppp/files/.svn/entries
@@ -0,0 +1,68 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/services/ppp/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-17T08:28:57.760235Z
+35188
+cyrus
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+lib
+dir
+
+ppp.sh
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+059a0a15d1f6ebd59cb366656157b180
+2012-12-06T18:17:21.859221Z
+34536
+jow
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4595
+
+etc
+dir
+
diff --git a/package/network/services/ppp/files/.svn/prop-base/ppp.sh.svn-base b/package/network/services/ppp/files/.svn/prop-base/ppp.sh.svn-base
new file mode 100644
index 0000000..03b5bfa
--- /dev/null
+++ b/package/network/services/ppp/files/.svn/prop-base/ppp.sh.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:eol-style
+V 6
+native
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/network/services/ppp/files/.svn/text-base/ppp.sh.svn-base b/package/network/services/ppp/files/.svn/text-base/ppp.sh.svn-base
new file mode 100644
index 0000000..43a7de9
--- /dev/null
+++ b/package/network/services/ppp/files/.svn/text-base/ppp.sh.svn-base
@@ -0,0 +1,215 @@
+#!/bin/sh
+
+[ -x /usr/sbin/pppd ] || exit 0
+
+[ -n "$INCLUDE_ONLY" ] || {
+ . /lib/functions.sh
+ . ../netifd-proto.sh
+ init_proto "$@"
+}
+
+ppp_generic_init_config() {
+ proto_config_add_string "username"
+ proto_config_add_string "password"
+ proto_config_add_string "keepalive"
+ proto_config_add_int "demand"
+ proto_config_add_string "pppd_options"
+ proto_config_add_string "connect"
+ proto_config_add_string "disconnect"
+ proto_config_add_boolean "ipv6"
+ proto_config_add_boolean "authfail"
+ proto_config_add_int "mtu"
+}
+
+ppp_generic_setup() {
+ local config="$1"; shift
+
+ json_get_vars ipv6 demand keepalive username password pppd_options
+ [ "$ipv6" = 1 ] || ipv6=""
+ if [ "${demand:-0}" -gt 0 ]; then
+ demand="precompiled-active-filter /etc/ppp/filter demand idle $demand"
+ else
+ demand="persist"
+ fi
+
+ [ -n "$mtu" ] || json_get_var mtu mtu
+
+ local interval="${keepalive##*[, ]}"
+ [ "$interval" != "$keepalive" ] || interval=5
+ [ -n "$connect" ] || json_get_var connect connect
+ [ -n "$disconnect" ] || json_get_var disconnect disconnect
+
+ proto_run_command "$config" /usr/sbin/pppd \
+ nodetach ipparam "$config" \
+ ifname "${proto:-ppp}-$config" \
+ ${keepalive:+lcp-echo-interval $interval lcp-echo-failure ${keepalive%%[, ]*}} \
+ ${ipv6:++ipv6} \
+ nodefaultroute \
+ usepeerdns \
+ $demand maxfail 1 \
+ ${username:+user "$username" password "$password"} \
+ ${connect:+connect "$connect"} \
+ ${disconnect:+disconnect "$disconnect"} \
+ ip-up-script /lib/netifd/ppp-up \
+ ipv6-up-script /lib/netifd/ppp-up \
+ ip-down-script /lib/netifd/ppp-down \
+ ipv6-down-script /lib/netifd/ppp-down \
+ ${mtu:+mtu $mtu mru $mtu} \
+ $pppd_options "$@"
+}
+
+ppp_generic_teardown() {
+ local interface="$1"
+
+ case "$ERROR" in
+ 11|19)
+ proto_notify_error "$interface" AUTH_FAILED
+ json_get_var authfail authfail
+ if [ "${authfail:-0}" -gt 0 ]; then
+ proto_block_restart "$interface"
+ fi
+ ;;
+ 2)
+ proto_notify_error "$interface" INVALID_OPTIONS
+ proto_block_restart "$interface"
+ ;;
+ esac
+ proto_kill_command "$interface"
+}
+
+# PPP on serial device
+
+proto_ppp_init_config() {
+ proto_config_add_string "device"
+ ppp_generic_init_config
+ no_device=1
+ available=1
+}
+
+proto_ppp_setup() {
+ local config="$1"
+
+ json_get_var device device
+ ppp_generic_setup "$config" "$device"
+}
+
+proto_ppp_teardown() {
+ ppp_generic_teardown "$@"
+}
+
+proto_pppoe_init_config() {
+ ppp_generic_init_config
+ proto_config_add_string "ac"
+ proto_config_add_string "service"
+}
+
+proto_pppoe_setup() {
+ local config="$1"
+ local iface="$2"
+
+ for module in slhc ppp_generic pppox pppoe; do
+ /sbin/insmod $module 2>&- >&-
+ done
+
+ json_get_var mtu mtu
+ mtu="${mtu:-1492}"
+
+ json_get_var ac ac
+ json_get_var service service
+
+ ppp_generic_setup "$config" \
+ plugin rp-pppoe.so \
+ ${ac:+rp_pppoe_ac "$ac"} \
+ ${service:+rp_pppoe_service "$service"} \
+ "nic-$iface"
+}
+
+proto_pppoe_teardown() {
+ ppp_generic_teardown "$@"
+}
+
+proto_pppoa_init_config() {
+ ppp_generic_init_config
+ proto_config_add_int "atmdev"
+ proto_config_add_int "vci"
+ proto_config_add_int "vpi"
+ proto_config_add_string "encaps"
+ no_device=1
+ available=1
+}
+
+proto_pppoa_setup() {
+ local config="$1"
+ local iface="$2"
+
+ for module in slhc ppp_generic pppox pppoatm; do
+ /sbin/insmod $module 2>&- >&-
+ done
+
+ json_get_vars atmdev vci vpi encaps
+
+ case "$encaps" in
+ 1|vc) encaps="vc-encaps" ;;
+ *) encaps="llc-encaps" ;;
+ esac
+
+ ppp_generic_setup "$config" \
+ plugin pppoatm.so \
+ ${atmdev:+$atmdev.}${vpi:-8}.${vci:-35} \
+ ${encaps}
+}
+
+proto_pppoa_teardown() {
+ ppp_generic_teardown "$@"
+}
+
+proto_pptp_init_config() {
+ ppp_generic_init_config
+ proto_config_add_string "server"
+ available=1
+ no_device=1
+}
+
+proto_pptp_setup() {
+ local config="$1"
+ local iface="$2"
+
+ local ip serv_addr server
+ json_get_var server server && {
+ for ip in $(resolveip -t 5 "$server"); do
+ ( proto_add_host_dependency "$config" "$ip" )
+ serv_addr=1
+ done
+ }
+ [ -n "$serv_addr" ] || {
+ echo "Could not resolve server address"
+ sleep 5
+ proto_setup_failed "$config"
+ exit 1
+ }
+
+ local load
+ for module in slhc ppp_generic ppp_async ppp_mppe ip_gre gre pptp; do
+ grep -q "$module" /proc/modules && continue
+ /sbin/insmod $module 2>&- >&-
+ load=1
+ done
+ [ "$load" = "1" ] && sleep 1
+
+ ppp_generic_setup "$config" \
+ plugin pptp.so \
+ pptp_server $server \
+ file /etc/ppp/options.pptp
+}
+
+proto_pptp_teardown() {
+ ppp_generic_teardown "$@"
+}
+
+[ -n "$INCLUDE_ONLY" ] || {
+ add_protocol ppp
+ [ -f /usr/lib/pppd/*/rp-pppoe.so ] && add_protocol pppoe
+ [ -f /usr/lib/pppd/*/pppoatm.so ] && add_protocol pppoa
+ [ -f /usr/lib/pppd/*/pptp.so ] && add_protocol pptp
+}
+
diff --git a/package/network/services/ppp/files/etc/.svn/entries b/package/network/services/ppp/files/etc/.svn/entries
new file mode 100644
index 0000000..9beb6e4
--- /dev/null
+++ b/package/network/services/ppp/files/etc/.svn/entries
@@ -0,0 +1,31 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/services/ppp/files/etc
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-06-11T23:22:52.384604Z
+32233
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+ppp
+dir
+
diff --git a/package/network/services/ppp/files/etc/ppp/.svn/entries b/package/network/services/ppp/files/etc/ppp/.svn/entries
new file mode 100644
index 0000000..3408e32
--- /dev/null
+++ b/package/network/services/ppp/files/etc/ppp/.svn/entries
@@ -0,0 +1,201 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/services/ppp/files/etc/ppp
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-06-11T23:22:52.384604Z
+32233
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+chap-secrets
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+e29cbe6021f13bd9b14d780a80f188ab
+2009-04-17T14:32:29.989894Z
+15245
+nico
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+41
+
+filter
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+16b01d9201be60c9d1f16dd98f449484
+2007-03-04T04:41:46.644094Z
+6501
+pavlov
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+260
+
+radius
+dir
+
+options
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+77741c792e70b6c733e6b09be0abfecc
+2012-05-20T14:02:05.168039Z
+31831
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+118
+
+radius.conf
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+3169bf2a35ce81fca99cba47f3eb4fd4
+2009-04-17T14:32:29.989894Z
+15245
+nico
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+198
+
+options.pptp
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+feb44eb81f421893be7111c0dbca7c92
+2012-06-11T23:22:52.384604Z
+32233
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+90
+
diff --git a/package/network/services/ppp/files/etc/ppp/.svn/prop-base/chap-secrets.svn-base b/package/network/services/ppp/files/etc/ppp/.svn/prop-base/chap-secrets.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/network/services/ppp/files/etc/ppp/.svn/prop-base/chap-secrets.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/services/ppp/files/etc/ppp/.svn/prop-base/filter.svn-base b/package/network/services/ppp/files/etc/ppp/.svn/prop-base/filter.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/network/services/ppp/files/etc/ppp/.svn/prop-base/filter.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/services/ppp/files/etc/ppp/.svn/prop-base/options.svn-base b/package/network/services/ppp/files/etc/ppp/.svn/prop-base/options.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/network/services/ppp/files/etc/ppp/.svn/prop-base/options.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/services/ppp/files/etc/ppp/.svn/prop-base/radius.conf.svn-base b/package/network/services/ppp/files/etc/ppp/.svn/prop-base/radius.conf.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/network/services/ppp/files/etc/ppp/.svn/prop-base/radius.conf.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/services/ppp/files/etc/ppp/.svn/text-base/chap-secrets.svn-base b/package/network/services/ppp/files/etc/ppp/.svn/text-base/chap-secrets.svn-base
new file mode 100644
index 0000000..6ab76e4
--- /dev/null
+++ b/package/network/services/ppp/files/etc/ppp/.svn/text-base/chap-secrets.svn-base
@@ -0,0 +1 @@
+#USERNAME PROVIDER PASSWORD IPADDRESS
diff --git a/package/network/services/ppp/files/etc/ppp/.svn/text-base/filter.svn-base b/package/network/services/ppp/files/etc/ppp/.svn/text-base/filter.svn-base
new file mode 100644
index 0000000..ec72a81
--- /dev/null
+++ b/package/network/services/ppp/files/etc/ppp/.svn/text-base/filter.svn-base
@@ -0,0 +1,23 @@
+#
+# Expression: outbound and not icmp[0] != 8 and not tcp[13] & 4 != 0
+#
+19
+48 0 0 0
+21 0 16 1
+40 0 0 2
+21 0 13 33
+48 0 0 13
+21 0 5 1
+40 0 0 10
+69 9 0 8191
+177 0 0 4
+80 0 0 4
+21 6 7 8
+21 0 5 6
+40 0 0 10
+69 3 0 8191
+177 0 0 4
+80 0 0 17
+69 1 0 4
+6 0 0 4
+6 0 0 0
diff --git a/package/network/services/ppp/files/etc/ppp/.svn/text-base/options.pptp.svn-base b/package/network/services/ppp/files/etc/ppp/.svn/text-base/options.pptp.svn-base
new file mode 100644
index 0000000..46a3f48
--- /dev/null
+++ b/package/network/services/ppp/files/etc/ppp/.svn/text-base/options.pptp.svn-base
@@ -0,0 +1,7 @@
+noipdefault
+noauth
+nobsdcomp
+nodeflate
+idle 0
+mppe required,no40,no56,stateless
+maxfail 0
diff --git a/package/network/services/ppp/files/etc/ppp/.svn/text-base/options.svn-base b/package/network/services/ppp/files/etc/ppp/.svn/text-base/options.svn-base
new file mode 100644
index 0000000..6b93f7b
--- /dev/null
+++ b/package/network/services/ppp/files/etc/ppp/.svn/text-base/options.svn-base
@@ -0,0 +1,10 @@
+#debug
+logfile /dev/null
+noipdefault
+noaccomp
+nopcomp
+nocrtscts
+lock
+maxfail 0
+lcp-echo-failure 5
+lcp-echo-interval 1
diff --git a/package/network/services/ppp/files/etc/ppp/.svn/text-base/radius.conf.svn-base b/package/network/services/ppp/files/etc/ppp/.svn/text-base/radius.conf.svn-base
new file mode 100644
index 0000000..0f24a8c
--- /dev/null
+++ b/package/network/services/ppp/files/etc/ppp/.svn/text-base/radius.conf.svn-base
@@ -0,0 +1,8 @@
+authserver localhost:1812
+acctserver localhost:1813
+dictionary /etc/ppp/radius/dictionary
+servers /etc/ppp/radius/servers
+mapfile /dev/null
+seqfile /tmp/radius.seq
+radius_timeout 5
+radius_retries 3
diff --git a/package/network/services/ppp/files/etc/ppp/chap-secrets b/package/network/services/ppp/files/etc/ppp/chap-secrets
new file mode 100644
index 0000000..6ab76e4
--- /dev/null
+++ b/package/network/services/ppp/files/etc/ppp/chap-secrets
@@ -0,0 +1 @@
+#USERNAME PROVIDER PASSWORD IPADDRESS
diff --git a/package/network/services/ppp/files/etc/ppp/filter b/package/network/services/ppp/files/etc/ppp/filter
new file mode 100644
index 0000000..ec72a81
--- /dev/null
+++ b/package/network/services/ppp/files/etc/ppp/filter
@@ -0,0 +1,23 @@
+#
+# Expression: outbound and not icmp[0] != 8 and not tcp[13] & 4 != 0
+#
+19
+48 0 0 0
+21 0 16 1
+40 0 0 2
+21 0 13 33
+48 0 0 13
+21 0 5 1
+40 0 0 10
+69 9 0 8191
+177 0 0 4
+80 0 0 4
+21 6 7 8
+21 0 5 6
+40 0 0 10
+69 3 0 8191
+177 0 0 4
+80 0 0 17
+69 1 0 4
+6 0 0 4
+6 0 0 0
diff --git a/package/network/services/ppp/files/etc/ppp/options b/package/network/services/ppp/files/etc/ppp/options
new file mode 100644
index 0000000..6b93f7b
--- /dev/null
+++ b/package/network/services/ppp/files/etc/ppp/options
@@ -0,0 +1,10 @@
+#debug
+logfile /dev/null
+noipdefault
+noaccomp
+nopcomp
+nocrtscts
+lock
+maxfail 0
+lcp-echo-failure 5
+lcp-echo-interval 1
diff --git a/package/network/services/ppp/files/etc/ppp/options.pptp b/package/network/services/ppp/files/etc/ppp/options.pptp
new file mode 100644
index 0000000..46a3f48
--- /dev/null
+++ b/package/network/services/ppp/files/etc/ppp/options.pptp
@@ -0,0 +1,7 @@
+noipdefault
+noauth
+nobsdcomp
+nodeflate
+idle 0
+mppe required,no40,no56,stateless
+maxfail 0
diff --git a/package/network/services/ppp/files/etc/ppp/radius.conf b/package/network/services/ppp/files/etc/ppp/radius.conf
new file mode 100644
index 0000000..0f24a8c
--- /dev/null
+++ b/package/network/services/ppp/files/etc/ppp/radius.conf
@@ -0,0 +1,8 @@
+authserver localhost:1812
+acctserver localhost:1813
+dictionary /etc/ppp/radius/dictionary
+servers /etc/ppp/radius/servers
+mapfile /dev/null
+seqfile /tmp/radius.seq
+radius_timeout 5
+radius_retries 3
diff --git a/package/network/services/ppp/files/etc/ppp/radius/.svn/entries b/package/network/services/ppp/files/etc/ppp/radius/.svn/entries
new file mode 100644
index 0000000..8ea5822
--- /dev/null
+++ b/package/network/services/ppp/files/etc/ppp/radius/.svn/entries
@@ -0,0 +1,164 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/services/ppp/files/etc/ppp/radius
+svn://svn.openwrt.org/openwrt
+
+
+
+2009-04-17T14:32:29.989894Z
+15245
+nico
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+dictionary
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+cd14cf79ffd954f348983f007e6563b2
+2009-04-17T14:32:29.989894Z
+15245
+nico
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+7635
+
+dictionary.microsoft
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+15199d375d4f3f5db5ce1448f96725eb
+2009-04-17T14:32:29.989894Z
+15245
+nico
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2582
+
+servers
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+a6d4a0a9c3ab3c4d65419d887127baa8
+2009-04-17T14:32:29.989894Z
+15245
+nico
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+33
+
+dictionary.asnet
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+6916c5d5c18dd584300946a45e07c33e
+2009-04-17T14:32:29.989894Z
+15245
+nico
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+93
+
diff --git a/package/network/services/ppp/files/etc/ppp/radius/.svn/prop-base/dictionary.asnet.svn-base b/package/network/services/ppp/files/etc/ppp/radius/.svn/prop-base/dictionary.asnet.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/network/services/ppp/files/etc/ppp/radius/.svn/prop-base/dictionary.asnet.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/services/ppp/files/etc/ppp/radius/.svn/prop-base/dictionary.microsoft.svn-base b/package/network/services/ppp/files/etc/ppp/radius/.svn/prop-base/dictionary.microsoft.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/network/services/ppp/files/etc/ppp/radius/.svn/prop-base/dictionary.microsoft.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/services/ppp/files/etc/ppp/radius/.svn/prop-base/dictionary.svn-base b/package/network/services/ppp/files/etc/ppp/radius/.svn/prop-base/dictionary.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/network/services/ppp/files/etc/ppp/radius/.svn/prop-base/dictionary.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/services/ppp/files/etc/ppp/radius/.svn/prop-base/servers.svn-base b/package/network/services/ppp/files/etc/ppp/radius/.svn/prop-base/servers.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/network/services/ppp/files/etc/ppp/radius/.svn/prop-base/servers.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/services/ppp/files/etc/ppp/radius/.svn/text-base/dictionary.asnet.svn-base b/package/network/services/ppp/files/etc/ppp/radius/.svn/text-base/dictionary.asnet.svn-base
new file mode 100644
index 0000000..337d1e1
--- /dev/null
+++ b/package/network/services/ppp/files/etc/ppp/radius/.svn/text-base/dictionary.asnet.svn-base
@@ -0,0 +1,3 @@
+VENDOR ASNET 50000
+ATTRIBUTE Speed-Down 1 string ASNET
+ATTRIBUTE Speed-Up 2 string ASNET
diff --git a/package/network/services/ppp/files/etc/ppp/radius/.svn/text-base/dictionary.microsoft.svn-base b/package/network/services/ppp/files/etc/ppp/radius/.svn/text-base/dictionary.microsoft.svn-base
new file mode 100644
index 0000000..2a6c20e
--- /dev/null
+++ b/package/network/services/ppp/files/etc/ppp/radius/.svn/text-base/dictionary.microsoft.svn-base
@@ -0,0 +1,80 @@
+#
+# Microsoft's VSA's, from RFC 2548
+#
+#
+
+VENDOR Microsoft 311 Microsoft
+
+ATTRIBUTE MS-CHAP-Response 1 string Microsoft
+ATTRIBUTE MS-CHAP-Error 2 string Microsoft
+ATTRIBUTE MS-CHAP-CPW-1 3 string Microsoft
+ATTRIBUTE MS-CHAP-CPW-2 4 string Microsoft
+ATTRIBUTE MS-CHAP-LM-Enc-PW 5 string Microsoft
+ATTRIBUTE MS-CHAP-NT-Enc-PW 6 string Microsoft
+ATTRIBUTE MS-MPPE-Encryption-Policy 7 string Microsoft
+# This is referred to as both singular and plural in the RFC.
+# Plural seems to make more sense.
+ATTRIBUTE MS-MPPE-Encryption-Type 8 string Microsoft
+ATTRIBUTE MS-MPPE-Encryption-Types 8 string Microsoft
+ATTRIBUTE MS-RAS-Vendor 9 integer Microsoft
+ATTRIBUTE MS-CHAP-Domain 10 string Microsoft
+ATTRIBUTE MS-CHAP-Challenge 11 string Microsoft
+ATTRIBUTE MS-CHAP-MPPE-Keys 12 string Microsoft
+ATTRIBUTE MS-BAP-Usage 13 integer Microsoft
+ATTRIBUTE MS-Link-Utilization-Threshold 14 integer Microsoft
+ATTRIBUTE MS-Link-Drop-Time-Limit 15 integer Microsoft
+ATTRIBUTE MS-MPPE-Send-Key 16 string Microsoft
+ATTRIBUTE MS-MPPE-Recv-Key 17 string Microsoft
+ATTRIBUTE MS-RAS-Version 18 string Microsoft
+ATTRIBUTE MS-Old-ARAP-Password 19 string Microsoft
+ATTRIBUTE MS-New-ARAP-Password 20 string Microsoft
+ATTRIBUTE MS-ARAP-PW-Change-Reason 21 integer Microsoft
+
+ATTRIBUTE MS-Filter 22 string Microsoft
+ATTRIBUTE MS-Acct-Auth-Type 23 integer Microsoft
+ATTRIBUTE MS-Acct-EAP-Type 24 integer Microsoft
+
+ATTRIBUTE MS-CHAP2-Response 25 string Microsoft
+ATTRIBUTE MS-CHAP2-Success 26 string Microsoft
+ATTRIBUTE MS-CHAP2-CPW 27 string Microsoft
+
+ATTRIBUTE MS-Primary-DNS-Server 28 ipaddr Microsoft
+ATTRIBUTE MS-Secondary-DNS-Server 29 ipaddr Microsoft
+ATTRIBUTE MS-Primary-NBNS-Server 30 ipaddr Microsoft
+ATTRIBUTE MS-Secondary-NBNS-Server 31 ipaddr Microsoft
+
+#ATTRIBUTE MS-ARAP-Challenge 33 string Microsoft
+
+
+#
+# Integer Translations
+#
+
+# MS-BAP-Usage Values
+
+VALUE MS-BAP-Usage Not-Allowed 0
+VALUE MS-BAP-Usage Allowed 1
+VALUE MS-BAP-Usage Required 2
+
+# MS-ARAP-Password-Change-Reason Values
+
+VALUE MS-ARAP-PW-Change-Reason Just-Change-Password 1
+VALUE MS-ARAP-PW-Change-Reason Expired-Password 2
+VALUE MS-ARAP-PW-Change-Reason Admin-Requires-Password-Change 3
+VALUE MS-ARAP-PW-Change-Reason Password-Too-Short 4
+
+# MS-Acct-Auth-Type Values
+
+VALUE MS-Acct-Auth-Type PAP 1
+VALUE MS-Acct-Auth-Type CHAP 2
+VALUE MS-Acct-Auth-Type MS-CHAP-1 3
+VALUE MS-Acct-Auth-Type MS-CHAP-2 4
+VALUE MS-Acct-Auth-Type EAP 5
+
+# MS-Acct-EAP-Type Values
+
+VALUE MS-Acct-EAP-Type MD5 4
+VALUE MS-Acct-EAP-Type OTP 5
+VALUE MS-Acct-EAP-Type Generic-Token-Card 6
+VALUE MS-Acct-EAP-Type TLS 13
+
diff --git a/package/network/services/ppp/files/etc/ppp/radius/.svn/text-base/dictionary.svn-base b/package/network/services/ppp/files/etc/ppp/radius/.svn/text-base/dictionary.svn-base
new file mode 100644
index 0000000..706d1ce
--- /dev/null
+++ b/package/network/services/ppp/files/etc/ppp/radius/.svn/text-base/dictionary.svn-base
@@ -0,0 +1,253 @@
+#
+# Updated 97/06/13 to livingston-radius-2.01 miquels@cistron.nl
+#
+# This file contains dictionary translations for parsing
+# requests and generating responses. All transactions are
+# composed of Attribute/Value Pairs. The value of each attribute
+# is specified as one of 4 data types. Valid data types are:
+#
+# string - 0-253 octets
+# ipaddr - 4 octets in network byte order
+# integer - 32 bit value in big endian order (high byte first)
+# date - 32 bit value in big endian order - seconds since
+# 00:00:00 GMT, Jan. 1, 1970
+#
+# Enumerated values are stored in the user file with dictionary
+# VALUE translations for easy administration.
+#
+# Example:
+#
+# ATTRIBUTE VALUE
+# --------------- -----
+# Framed-Protocol = PPP
+# 7 = 1 (integer encoding)
+#
+
+# The dictionary format now supports vendor-specific attributes.
+# Vendors are introduced like this:
+#
+# VENDOR vendor_name vendor_number
+#
+# For example:
+#
+# VENDOR RoaringPenguin 10055
+#
+# Vendor-specific attributes have a fifth field with the name of the
+# vendor. For example:
+#
+# ATTRIBUTE RP-Upstream-Speed-Limit 1 integer RoaringPenguin
+#
+# introduces a Roaring Penguin vendor-specific attribbute with name
+# RP-Upstream-Speed-Limit, number 1, type integer and vendor RoaringPenguin.
+
+#
+# Following are the proper new names. Use these.
+#
+ATTRIBUTE User-Name 1 string
+ATTRIBUTE Password 2 string
+ATTRIBUTE CHAP-Password 3 string
+ATTRIBUTE NAS-IP-Address 4 ipaddr
+ATTRIBUTE NAS-Port-Id 5 integer
+ATTRIBUTE Service-Type 6 integer
+ATTRIBUTE Framed-Protocol 7 integer
+ATTRIBUTE Framed-IP-Address 8 ipaddr
+ATTRIBUTE Framed-IP-Netmask 9 ipaddr
+ATTRIBUTE Framed-Routing 10 integer
+ATTRIBUTE Filter-Id 11 string
+ATTRIBUTE Framed-MTU 12 integer
+ATTRIBUTE Framed-Compression 13 integer
+ATTRIBUTE Login-IP-Host 14 ipaddr
+ATTRIBUTE Login-Service 15 integer
+ATTRIBUTE Login-TCP-Port 16 integer
+ATTRIBUTE Reply-Message 18 string
+ATTRIBUTE Callback-Number 19 string
+ATTRIBUTE Callback-Id 20 string
+ATTRIBUTE Framed-Route 22 string
+ATTRIBUTE Framed-IPX-Network 23 ipaddr
+ATTRIBUTE State 24 string
+ATTRIBUTE Class 25 string
+ATTRIBUTE Session-Timeout 27 integer
+ATTRIBUTE Idle-Timeout 28 integer
+ATTRIBUTE Termination-Action 29 integer
+ATTRIBUTE Called-Station-Id 30 string
+ATTRIBUTE Calling-Station-Id 31 string
+ATTRIBUTE NAS-Identifier 32 string
+ATTRIBUTE Acct-Status-Type 40 integer
+ATTRIBUTE Acct-Delay-Time 41 integer
+ATTRIBUTE Acct-Input-Octets 42 integer
+ATTRIBUTE Acct-Output-Octets 43 integer
+ATTRIBUTE Acct-Session-Id 44 string
+ATTRIBUTE Acct-Authentic 45 integer
+ATTRIBUTE Acct-Session-Time 46 integer
+ATTRIBUTE Acct-Input-Packets 47 integer
+ATTRIBUTE Acct-Output-Packets 48 integer
+ATTRIBUTE Acct-Terminate-Cause 49 integer
+ATTRIBUTE Chap-Challenge 60 string
+ATTRIBUTE NAS-Port-Type 61 integer
+ATTRIBUTE Port-Limit 62 integer
+ATTRIBUTE Connect-Info 77 string
+
+# RFC 2869
+ATTRIBUTE Acct-Interim-Interval 85 integer
+
+#
+# Experimental Non Protocol Attributes used by Cistron-Radiusd
+#
+ATTRIBUTE Huntgroup-Name 221 string
+ATTRIBUTE User-Category 1029 string
+ATTRIBUTE Group-Name 1030 string
+ATTRIBUTE Simultaneous-Use 1034 integer
+ATTRIBUTE Strip-User-Name 1035 integer
+ATTRIBUTE Fall-Through 1036 integer
+ATTRIBUTE Add-Port-To-IP-Address 1037 integer
+ATTRIBUTE Exec-Program 1038 string
+ATTRIBUTE Exec-Program-Wait 1039 string
+ATTRIBUTE Hint 1040 string
+
+#
+# Non-Protocol Attributes
+# These attributes are used internally by the server
+#
+ATTRIBUTE Expiration 21 date
+ATTRIBUTE Auth-Type 1000 integer
+ATTRIBUTE Menu 1001 string
+ATTRIBUTE Termination-Menu 1002 string
+ATTRIBUTE Prefix 1003 string
+ATTRIBUTE Suffix 1004 string
+ATTRIBUTE Group 1005 string
+ATTRIBUTE Crypt-Password 1006 string
+ATTRIBUTE Connect-Rate 1007 integer
+
+#
+# Experimental, implementation specific attributes
+#
+# Limit session traffic
+ATTRIBUTE Session-Octets-Limit 227 integer
+# What to assume as limit - 0 in+out, 1 in, 2 out, 3 max(in,out)
+ATTRIBUTE Octets-Direction 228 integer
+
+#
+# Integer Translations
+#
+
+# User Types
+
+VALUE Service-Type Login-User 1
+VALUE Service-Type Framed-User 2
+VALUE Service-Type Callback-Login-User 3
+VALUE Service-Type Callback-Framed-User 4
+VALUE Service-Type Outbound-User 5
+VALUE Service-Type Administrative-User 6
+VALUE Service-Type NAS-Prompt-User 7
+
+# Framed Protocols
+
+VALUE Framed-Protocol PPP 1
+VALUE Framed-Protocol SLIP 2
+
+# Framed Routing Values
+
+VALUE Framed-Routing None 0
+VALUE Framed-Routing Broadcast 1
+VALUE Framed-Routing Listen 2
+VALUE Framed-Routing Broadcast-Listen 3
+
+# Framed Compression Types
+
+VALUE Framed-Compression None 0
+VALUE Framed-Compression Van-Jacobson-TCP-IP 1
+
+# Login Services
+
+VALUE Login-Service Telnet 0
+VALUE Login-Service Rlogin 1
+VALUE Login-Service TCP-Clear 2
+VALUE Login-Service PortMaster 3
+
+# Status Types
+
+VALUE Acct-Status-Type Start 1
+VALUE Acct-Status-Type Stop 2
+VALUE Acct-Status-Type Accounting-On 7
+VALUE Acct-Status-Type Accounting-Off 8
+
+# Authentication Types
+
+VALUE Acct-Authentic RADIUS 1
+VALUE Acct-Authentic Local 2
+VALUE Acct-Authentic PowerLink128 100
+
+# Termination Options
+
+VALUE Termination-Action Default 0
+VALUE Termination-Action RADIUS-Request 1
+
+# NAS Port Types, available in 3.3.1 and later
+
+VALUE NAS-Port-Type Async 0
+VALUE NAS-Port-Type Sync 1
+VALUE NAS-Port-Type ISDN 2
+VALUE NAS-Port-Type ISDN-V120 3
+VALUE NAS-Port-Type ISDN-V110 4
+
+# Acct Terminate Causes, available in 3.3.2 and later
+
+VALUE Acct-Terminate-Cause User-Request 1
+VALUE Acct-Terminate-Cause Lost-Carrier 2
+VALUE Acct-Terminate-Cause Lost-Service 3
+VALUE Acct-Terminate-Cause Idle-Timeout 4
+VALUE Acct-Terminate-Cause Session-Timeout 5
+VALUE Acct-Terminate-Cause Admin-Reset 6
+VALUE Acct-Terminate-Cause Admin-Reboot 7
+VALUE Acct-Terminate-Cause Port-Error 8
+VALUE Acct-Terminate-Cause NAS-Error 9
+VALUE Acct-Terminate-Cause NAS-Request 10
+VALUE Acct-Terminate-Cause NAS-Reboot 11
+VALUE Acct-Terminate-Cause Port-Unneeded 12
+VALUE Acct-Terminate-Cause Port-Preempted 13
+VALUE Acct-Terminate-Cause Port-Suspended 14
+VALUE Acct-Terminate-Cause Service-Unavailable 15
+VALUE Acct-Terminate-Cause Callback 16
+VALUE Acct-Terminate-Cause User-Error 17
+VALUE Acct-Terminate-Cause Host-Request 18
+
+#
+# Non-Protocol Integer Translations
+#
+
+VALUE Auth-Type Local 0
+VALUE Auth-Type System 1
+VALUE Auth-Type SecurID 2
+VALUE Auth-Type Crypt-Local 3
+VALUE Auth-Type Reject 4
+
+#
+# Cistron extensions
+#
+VALUE Auth-Type Pam 253
+VALUE Auth-Type None 254
+
+#
+# Experimental Non-Protocol Integer Translations for Cistron-Radiusd
+#
+VALUE Fall-Through No 0
+VALUE Fall-Through Yes 1
+VALUE Add-Port-To-IP-Address No 0
+VALUE Add-Port-To-IP-Address Yes 1
+
+#
+# Configuration Values
+# uncomment these two lines to turn account expiration on
+#
+
+#VALUE Server-Config Password-Expiration 30
+#VALUE Server-Config Password-Warning 5
+
+# Octets-Direction
+VALUE Octets-Direction Sum 0
+VALUE Octets-Direction Input 1
+VALUE Octets-Direction Output 2
+VALUE Octets-Direction MaxOveral 3
+VALUE Octets-Direction MaxSession 4
+
+INCLUDE /etc/ppp/radius/dictionary.microsoft
diff --git a/package/network/services/ppp/files/etc/ppp/radius/.svn/text-base/servers.svn-base b/package/network/services/ppp/files/etc/ppp/radius/.svn/text-base/servers.svn-base
new file mode 100644
index 0000000..0d4f069
--- /dev/null
+++ b/package/network/services/ppp/files/etc/ppp/radius/.svn/text-base/servers.svn-base
@@ -0,0 +1,2 @@
+# SERVER SECRET
+localhost secret
diff --git a/package/network/services/ppp/files/etc/ppp/radius/dictionary b/package/network/services/ppp/files/etc/ppp/radius/dictionary
new file mode 100644
index 0000000..706d1ce
--- /dev/null
+++ b/package/network/services/ppp/files/etc/ppp/radius/dictionary
@@ -0,0 +1,253 @@
+#
+# Updated 97/06/13 to livingston-radius-2.01 miquels@cistron.nl
+#
+# This file contains dictionary translations for parsing
+# requests and generating responses. All transactions are
+# composed of Attribute/Value Pairs. The value of each attribute
+# is specified as one of 4 data types. Valid data types are:
+#
+# string - 0-253 octets
+# ipaddr - 4 octets in network byte order
+# integer - 32 bit value in big endian order (high byte first)
+# date - 32 bit value in big endian order - seconds since
+# 00:00:00 GMT, Jan. 1, 1970
+#
+# Enumerated values are stored in the user file with dictionary
+# VALUE translations for easy administration.
+#
+# Example:
+#
+# ATTRIBUTE VALUE
+# --------------- -----
+# Framed-Protocol = PPP
+# 7 = 1 (integer encoding)
+#
+
+# The dictionary format now supports vendor-specific attributes.
+# Vendors are introduced like this:
+#
+# VENDOR vendor_name vendor_number
+#
+# For example:
+#
+# VENDOR RoaringPenguin 10055
+#
+# Vendor-specific attributes have a fifth field with the name of the
+# vendor. For example:
+#
+# ATTRIBUTE RP-Upstream-Speed-Limit 1 integer RoaringPenguin
+#
+# introduces a Roaring Penguin vendor-specific attribbute with name
+# RP-Upstream-Speed-Limit, number 1, type integer and vendor RoaringPenguin.
+
+#
+# Following are the proper new names. Use these.
+#
+ATTRIBUTE User-Name 1 string
+ATTRIBUTE Password 2 string
+ATTRIBUTE CHAP-Password 3 string
+ATTRIBUTE NAS-IP-Address 4 ipaddr
+ATTRIBUTE NAS-Port-Id 5 integer
+ATTRIBUTE Service-Type 6 integer
+ATTRIBUTE Framed-Protocol 7 integer
+ATTRIBUTE Framed-IP-Address 8 ipaddr
+ATTRIBUTE Framed-IP-Netmask 9 ipaddr
+ATTRIBUTE Framed-Routing 10 integer
+ATTRIBUTE Filter-Id 11 string
+ATTRIBUTE Framed-MTU 12 integer
+ATTRIBUTE Framed-Compression 13 integer
+ATTRIBUTE Login-IP-Host 14 ipaddr
+ATTRIBUTE Login-Service 15 integer
+ATTRIBUTE Login-TCP-Port 16 integer
+ATTRIBUTE Reply-Message 18 string
+ATTRIBUTE Callback-Number 19 string
+ATTRIBUTE Callback-Id 20 string
+ATTRIBUTE Framed-Route 22 string
+ATTRIBUTE Framed-IPX-Network 23 ipaddr
+ATTRIBUTE State 24 string
+ATTRIBUTE Class 25 string
+ATTRIBUTE Session-Timeout 27 integer
+ATTRIBUTE Idle-Timeout 28 integer
+ATTRIBUTE Termination-Action 29 integer
+ATTRIBUTE Called-Station-Id 30 string
+ATTRIBUTE Calling-Station-Id 31 string
+ATTRIBUTE NAS-Identifier 32 string
+ATTRIBUTE Acct-Status-Type 40 integer
+ATTRIBUTE Acct-Delay-Time 41 integer
+ATTRIBUTE Acct-Input-Octets 42 integer
+ATTRIBUTE Acct-Output-Octets 43 integer
+ATTRIBUTE Acct-Session-Id 44 string
+ATTRIBUTE Acct-Authentic 45 integer
+ATTRIBUTE Acct-Session-Time 46 integer
+ATTRIBUTE Acct-Input-Packets 47 integer
+ATTRIBUTE Acct-Output-Packets 48 integer
+ATTRIBUTE Acct-Terminate-Cause 49 integer
+ATTRIBUTE Chap-Challenge 60 string
+ATTRIBUTE NAS-Port-Type 61 integer
+ATTRIBUTE Port-Limit 62 integer
+ATTRIBUTE Connect-Info 77 string
+
+# RFC 2869
+ATTRIBUTE Acct-Interim-Interval 85 integer
+
+#
+# Experimental Non Protocol Attributes used by Cistron-Radiusd
+#
+ATTRIBUTE Huntgroup-Name 221 string
+ATTRIBUTE User-Category 1029 string
+ATTRIBUTE Group-Name 1030 string
+ATTRIBUTE Simultaneous-Use 1034 integer
+ATTRIBUTE Strip-User-Name 1035 integer
+ATTRIBUTE Fall-Through 1036 integer
+ATTRIBUTE Add-Port-To-IP-Address 1037 integer
+ATTRIBUTE Exec-Program 1038 string
+ATTRIBUTE Exec-Program-Wait 1039 string
+ATTRIBUTE Hint 1040 string
+
+#
+# Non-Protocol Attributes
+# These attributes are used internally by the server
+#
+ATTRIBUTE Expiration 21 date
+ATTRIBUTE Auth-Type 1000 integer
+ATTRIBUTE Menu 1001 string
+ATTRIBUTE Termination-Menu 1002 string
+ATTRIBUTE Prefix 1003 string
+ATTRIBUTE Suffix 1004 string
+ATTRIBUTE Group 1005 string
+ATTRIBUTE Crypt-Password 1006 string
+ATTRIBUTE Connect-Rate 1007 integer
+
+#
+# Experimental, implementation specific attributes
+#
+# Limit session traffic
+ATTRIBUTE Session-Octets-Limit 227 integer
+# What to assume as limit - 0 in+out, 1 in, 2 out, 3 max(in,out)
+ATTRIBUTE Octets-Direction 228 integer
+
+#
+# Integer Translations
+#
+
+# User Types
+
+VALUE Service-Type Login-User 1
+VALUE Service-Type Framed-User 2
+VALUE Service-Type Callback-Login-User 3
+VALUE Service-Type Callback-Framed-User 4
+VALUE Service-Type Outbound-User 5
+VALUE Service-Type Administrative-User 6
+VALUE Service-Type NAS-Prompt-User 7
+
+# Framed Protocols
+
+VALUE Framed-Protocol PPP 1
+VALUE Framed-Protocol SLIP 2
+
+# Framed Routing Values
+
+VALUE Framed-Routing None 0
+VALUE Framed-Routing Broadcast 1
+VALUE Framed-Routing Listen 2
+VALUE Framed-Routing Broadcast-Listen 3
+
+# Framed Compression Types
+
+VALUE Framed-Compression None 0
+VALUE Framed-Compression Van-Jacobson-TCP-IP 1
+
+# Login Services
+
+VALUE Login-Service Telnet 0
+VALUE Login-Service Rlogin 1
+VALUE Login-Service TCP-Clear 2
+VALUE Login-Service PortMaster 3
+
+# Status Types
+
+VALUE Acct-Status-Type Start 1
+VALUE Acct-Status-Type Stop 2
+VALUE Acct-Status-Type Accounting-On 7
+VALUE Acct-Status-Type Accounting-Off 8
+
+# Authentication Types
+
+VALUE Acct-Authentic RADIUS 1
+VALUE Acct-Authentic Local 2
+VALUE Acct-Authentic PowerLink128 100
+
+# Termination Options
+
+VALUE Termination-Action Default 0
+VALUE Termination-Action RADIUS-Request 1
+
+# NAS Port Types, available in 3.3.1 and later
+
+VALUE NAS-Port-Type Async 0
+VALUE NAS-Port-Type Sync 1
+VALUE NAS-Port-Type ISDN 2
+VALUE NAS-Port-Type ISDN-V120 3
+VALUE NAS-Port-Type ISDN-V110 4
+
+# Acct Terminate Causes, available in 3.3.2 and later
+
+VALUE Acct-Terminate-Cause User-Request 1
+VALUE Acct-Terminate-Cause Lost-Carrier 2
+VALUE Acct-Terminate-Cause Lost-Service 3
+VALUE Acct-Terminate-Cause Idle-Timeout 4
+VALUE Acct-Terminate-Cause Session-Timeout 5
+VALUE Acct-Terminate-Cause Admin-Reset 6
+VALUE Acct-Terminate-Cause Admin-Reboot 7
+VALUE Acct-Terminate-Cause Port-Error 8
+VALUE Acct-Terminate-Cause NAS-Error 9
+VALUE Acct-Terminate-Cause NAS-Request 10
+VALUE Acct-Terminate-Cause NAS-Reboot 11
+VALUE Acct-Terminate-Cause Port-Unneeded 12
+VALUE Acct-Terminate-Cause Port-Preempted 13
+VALUE Acct-Terminate-Cause Port-Suspended 14
+VALUE Acct-Terminate-Cause Service-Unavailable 15
+VALUE Acct-Terminate-Cause Callback 16
+VALUE Acct-Terminate-Cause User-Error 17
+VALUE Acct-Terminate-Cause Host-Request 18
+
+#
+# Non-Protocol Integer Translations
+#
+
+VALUE Auth-Type Local 0
+VALUE Auth-Type System 1
+VALUE Auth-Type SecurID 2
+VALUE Auth-Type Crypt-Local 3
+VALUE Auth-Type Reject 4
+
+#
+# Cistron extensions
+#
+VALUE Auth-Type Pam 253
+VALUE Auth-Type None 254
+
+#
+# Experimental Non-Protocol Integer Translations for Cistron-Radiusd
+#
+VALUE Fall-Through No 0
+VALUE Fall-Through Yes 1
+VALUE Add-Port-To-IP-Address No 0
+VALUE Add-Port-To-IP-Address Yes 1
+
+#
+# Configuration Values
+# uncomment these two lines to turn account expiration on
+#
+
+#VALUE Server-Config Password-Expiration 30
+#VALUE Server-Config Password-Warning 5
+
+# Octets-Direction
+VALUE Octets-Direction Sum 0
+VALUE Octets-Direction Input 1
+VALUE Octets-Direction Output 2
+VALUE Octets-Direction MaxOveral 3
+VALUE Octets-Direction MaxSession 4
+
+INCLUDE /etc/ppp/radius/dictionary.microsoft
diff --git a/package/network/services/ppp/files/etc/ppp/radius/dictionary.asnet b/package/network/services/ppp/files/etc/ppp/radius/dictionary.asnet
new file mode 100644
index 0000000..337d1e1
--- /dev/null
+++ b/package/network/services/ppp/files/etc/ppp/radius/dictionary.asnet
@@ -0,0 +1,3 @@
+VENDOR ASNET 50000
+ATTRIBUTE Speed-Down 1 string ASNET
+ATTRIBUTE Speed-Up 2 string ASNET
diff --git a/package/network/services/ppp/files/etc/ppp/radius/dictionary.microsoft b/package/network/services/ppp/files/etc/ppp/radius/dictionary.microsoft
new file mode 100644
index 0000000..2a6c20e
--- /dev/null
+++ b/package/network/services/ppp/files/etc/ppp/radius/dictionary.microsoft
@@ -0,0 +1,80 @@
+#
+# Microsoft's VSA's, from RFC 2548
+#
+#
+
+VENDOR Microsoft 311 Microsoft
+
+ATTRIBUTE MS-CHAP-Response 1 string Microsoft
+ATTRIBUTE MS-CHAP-Error 2 string Microsoft
+ATTRIBUTE MS-CHAP-CPW-1 3 string Microsoft
+ATTRIBUTE MS-CHAP-CPW-2 4 string Microsoft
+ATTRIBUTE MS-CHAP-LM-Enc-PW 5 string Microsoft
+ATTRIBUTE MS-CHAP-NT-Enc-PW 6 string Microsoft
+ATTRIBUTE MS-MPPE-Encryption-Policy 7 string Microsoft
+# This is referred to as both singular and plural in the RFC.
+# Plural seems to make more sense.
+ATTRIBUTE MS-MPPE-Encryption-Type 8 string Microsoft
+ATTRIBUTE MS-MPPE-Encryption-Types 8 string Microsoft
+ATTRIBUTE MS-RAS-Vendor 9 integer Microsoft
+ATTRIBUTE MS-CHAP-Domain 10 string Microsoft
+ATTRIBUTE MS-CHAP-Challenge 11 string Microsoft
+ATTRIBUTE MS-CHAP-MPPE-Keys 12 string Microsoft
+ATTRIBUTE MS-BAP-Usage 13 integer Microsoft
+ATTRIBUTE MS-Link-Utilization-Threshold 14 integer Microsoft
+ATTRIBUTE MS-Link-Drop-Time-Limit 15 integer Microsoft
+ATTRIBUTE MS-MPPE-Send-Key 16 string Microsoft
+ATTRIBUTE MS-MPPE-Recv-Key 17 string Microsoft
+ATTRIBUTE MS-RAS-Version 18 string Microsoft
+ATTRIBUTE MS-Old-ARAP-Password 19 string Microsoft
+ATTRIBUTE MS-New-ARAP-Password 20 string Microsoft
+ATTRIBUTE MS-ARAP-PW-Change-Reason 21 integer Microsoft
+
+ATTRIBUTE MS-Filter 22 string Microsoft
+ATTRIBUTE MS-Acct-Auth-Type 23 integer Microsoft
+ATTRIBUTE MS-Acct-EAP-Type 24 integer Microsoft
+
+ATTRIBUTE MS-CHAP2-Response 25 string Microsoft
+ATTRIBUTE MS-CHAP2-Success 26 string Microsoft
+ATTRIBUTE MS-CHAP2-CPW 27 string Microsoft
+
+ATTRIBUTE MS-Primary-DNS-Server 28 ipaddr Microsoft
+ATTRIBUTE MS-Secondary-DNS-Server 29 ipaddr Microsoft
+ATTRIBUTE MS-Primary-NBNS-Server 30 ipaddr Microsoft
+ATTRIBUTE MS-Secondary-NBNS-Server 31 ipaddr Microsoft
+
+#ATTRIBUTE MS-ARAP-Challenge 33 string Microsoft
+
+
+#
+# Integer Translations
+#
+
+# MS-BAP-Usage Values
+
+VALUE MS-BAP-Usage Not-Allowed 0
+VALUE MS-BAP-Usage Allowed 1
+VALUE MS-BAP-Usage Required 2
+
+# MS-ARAP-Password-Change-Reason Values
+
+VALUE MS-ARAP-PW-Change-Reason Just-Change-Password 1
+VALUE MS-ARAP-PW-Change-Reason Expired-Password 2
+VALUE MS-ARAP-PW-Change-Reason Admin-Requires-Password-Change 3
+VALUE MS-ARAP-PW-Change-Reason Password-Too-Short 4
+
+# MS-Acct-Auth-Type Values
+
+VALUE MS-Acct-Auth-Type PAP 1
+VALUE MS-Acct-Auth-Type CHAP 2
+VALUE MS-Acct-Auth-Type MS-CHAP-1 3
+VALUE MS-Acct-Auth-Type MS-CHAP-2 4
+VALUE MS-Acct-Auth-Type EAP 5
+
+# MS-Acct-EAP-Type Values
+
+VALUE MS-Acct-EAP-Type MD5 4
+VALUE MS-Acct-EAP-Type OTP 5
+VALUE MS-Acct-EAP-Type Generic-Token-Card 6
+VALUE MS-Acct-EAP-Type TLS 13
+
diff --git a/package/network/services/ppp/files/etc/ppp/radius/servers b/package/network/services/ppp/files/etc/ppp/radius/servers
new file mode 100644
index 0000000..0d4f069
--- /dev/null
+++ b/package/network/services/ppp/files/etc/ppp/radius/servers
@@ -0,0 +1,2 @@
+# SERVER SECRET
+localhost secret
diff --git a/package/network/services/ppp/files/lib/.svn/entries b/package/network/services/ppp/files/lib/.svn/entries
new file mode 100644
index 0000000..e6e3fac
--- /dev/null
+++ b/package/network/services/ppp/files/lib/.svn/entries
@@ -0,0 +1,31 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/services/ppp/files/lib
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-17T08:28:57.760235Z
+35188
+cyrus
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+netifd
+dir
+
diff --git a/package/network/services/ppp/files/lib/netifd/.svn/entries b/package/network/services/ppp/files/lib/netifd/.svn/entries
new file mode 100644
index 0000000..3f5a95c
--- /dev/null
+++ b/package/network/services/ppp/files/lib/netifd/.svn/entries
@@ -0,0 +1,96 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/services/ppp/files/lib/netifd
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-17T08:28:57.760235Z
+35188
+cyrus
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+ppp-up
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+fb0ee129fa8de081e4bee21364f08f36
+2013-01-17T08:28:57.760235Z
+35188
+cyrus
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+585
+
+ppp-down
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+e8c0b6db2f664f55fd6da559d238bc98
+2012-05-26T15:31:54.789852Z
+31860
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+238
+
diff --git a/package/network/services/ppp/files/lib/netifd/.svn/prop-base/ppp-down.svn-base b/package/network/services/ppp/files/lib/netifd/.svn/prop-base/ppp-down.svn-base
new file mode 100644
index 0000000..869ac71
--- /dev/null
+++ b/package/network/services/ppp/files/lib/netifd/.svn/prop-base/ppp-down.svn-base
@@ -0,0 +1,5 @@
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/network/services/ppp/files/lib/netifd/.svn/prop-base/ppp-up.svn-base b/package/network/services/ppp/files/lib/netifd/.svn/prop-base/ppp-up.svn-base
new file mode 100644
index 0000000..869ac71
--- /dev/null
+++ b/package/network/services/ppp/files/lib/netifd/.svn/prop-base/ppp-up.svn-base
@@ -0,0 +1,5 @@
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/network/services/ppp/files/lib/netifd/.svn/text-base/ppp-down.svn-base b/package/network/services/ppp/files/lib/netifd/.svn/text-base/ppp-down.svn-base
new file mode 100644
index 0000000..94cefc4
--- /dev/null
+++ b/package/network/services/ppp/files/lib/netifd/.svn/text-base/ppp-down.svn-base
@@ -0,0 +1,13 @@
+#!/bin/sh
+PPP_IPPARAM="$6"
+
+. /lib/netifd/netifd-proto.sh
+proto_init_update "$IFNAME" 0
+proto_send_update "$PPP_IPPARAM"
+
+[ -d /etc/ppp/ip-down.d ] && {
+ for SCRIPT in /etc/ppp/ip-down.d/*
+ do
+ [ -x "$SCRIPT" ] && "$SCRIPT" "$@"
+ done
+}
diff --git a/package/network/services/ppp/files/lib/netifd/.svn/text-base/ppp-up.svn-base b/package/network/services/ppp/files/lib/netifd/.svn/text-base/ppp-up.svn-base
new file mode 100644
index 0000000..d488b8d
--- /dev/null
+++ b/package/network/services/ppp/files/lib/netifd/.svn/text-base/ppp-up.svn-base
@@ -0,0 +1,21 @@
+#!/bin/sh
+PPP_IPPARAM="$6"
+
+. /lib/netifd/netifd-proto.sh
+proto_init_update "$IFNAME" 1 1
+proto_set_keep 1
+[ -n "$PPP_IPPARAM" ] && {
+ [ -n "$IPLOCAL" ] && proto_add_ipv4_address "$IPLOCAL" 32
+ [ -n "$IPREMOTE" ] && proto_add_ipv4_route 0.0.0.0 0 "$IPREMOTE"
+ [ -n "$LLLOCAL" ] && proto_add_ipv6_address "$LLLOCAL" 128
+ [ -n "$DNS1" ] && proto_add_dns_server "$DNS1"
+ [ -n "$DNS2" -a "$DNS1" != "$DNS2" ] && proto_add_dns_server "$DNS2"
+}
+proto_send_update "$PPP_IPPARAM"
+
+[ -d /etc/ppp/ip-up.d ] && {
+ for SCRIPT in /etc/ppp/ip-up.d/*
+ do
+ [ -x "$SCRIPT" ] && "$SCRIPT" "$@"
+ done
+}
diff --git a/package/network/services/ppp/files/lib/netifd/ppp-down b/package/network/services/ppp/files/lib/netifd/ppp-down
new file mode 100755
index 0000000..94cefc4
--- /dev/null
+++ b/package/network/services/ppp/files/lib/netifd/ppp-down
@@ -0,0 +1,13 @@
+#!/bin/sh
+PPP_IPPARAM="$6"
+
+. /lib/netifd/netifd-proto.sh
+proto_init_update "$IFNAME" 0
+proto_send_update "$PPP_IPPARAM"
+
+[ -d /etc/ppp/ip-down.d ] && {
+ for SCRIPT in /etc/ppp/ip-down.d/*
+ do
+ [ -x "$SCRIPT" ] && "$SCRIPT" "$@"
+ done
+}
diff --git a/package/network/services/ppp/files/lib/netifd/ppp-up b/package/network/services/ppp/files/lib/netifd/ppp-up
new file mode 100755
index 0000000..d488b8d
--- /dev/null
+++ b/package/network/services/ppp/files/lib/netifd/ppp-up
@@ -0,0 +1,21 @@
+#!/bin/sh
+PPP_IPPARAM="$6"
+
+. /lib/netifd/netifd-proto.sh
+proto_init_update "$IFNAME" 1 1
+proto_set_keep 1
+[ -n "$PPP_IPPARAM" ] && {
+ [ -n "$IPLOCAL" ] && proto_add_ipv4_address "$IPLOCAL" 32
+ [ -n "$IPREMOTE" ] && proto_add_ipv4_route 0.0.0.0 0 "$IPREMOTE"
+ [ -n "$LLLOCAL" ] && proto_add_ipv6_address "$LLLOCAL" 128
+ [ -n "$DNS1" ] && proto_add_dns_server "$DNS1"
+ [ -n "$DNS2" -a "$DNS1" != "$DNS2" ] && proto_add_dns_server "$DNS2"
+}
+proto_send_update "$PPP_IPPARAM"
+
+[ -d /etc/ppp/ip-up.d ] && {
+ for SCRIPT in /etc/ppp/ip-up.d/*
+ do
+ [ -x "$SCRIPT" ] && "$SCRIPT" "$@"
+ done
+}
diff --git a/package/network/services/ppp/files/ppp.sh b/package/network/services/ppp/files/ppp.sh
new file mode 100755
index 0000000..43a7de9
--- /dev/null
+++ b/package/network/services/ppp/files/ppp.sh
@@ -0,0 +1,215 @@
+#!/bin/sh
+
+[ -x /usr/sbin/pppd ] || exit 0
+
+[ -n "$INCLUDE_ONLY" ] || {
+ . /lib/functions.sh
+ . ../netifd-proto.sh
+ init_proto "$@"
+}
+
+ppp_generic_init_config() {
+ proto_config_add_string "username"
+ proto_config_add_string "password"
+ proto_config_add_string "keepalive"
+ proto_config_add_int "demand"
+ proto_config_add_string "pppd_options"
+ proto_config_add_string "connect"
+ proto_config_add_string "disconnect"
+ proto_config_add_boolean "ipv6"
+ proto_config_add_boolean "authfail"
+ proto_config_add_int "mtu"
+}
+
+ppp_generic_setup() {
+ local config="$1"; shift
+
+ json_get_vars ipv6 demand keepalive username password pppd_options
+ [ "$ipv6" = 1 ] || ipv6=""
+ if [ "${demand:-0}" -gt 0 ]; then
+ demand="precompiled-active-filter /etc/ppp/filter demand idle $demand"
+ else
+ demand="persist"
+ fi
+
+ [ -n "$mtu" ] || json_get_var mtu mtu
+
+ local interval="${keepalive##*[, ]}"
+ [ "$interval" != "$keepalive" ] || interval=5
+ [ -n "$connect" ] || json_get_var connect connect
+ [ -n "$disconnect" ] || json_get_var disconnect disconnect
+
+ proto_run_command "$config" /usr/sbin/pppd \
+ nodetach ipparam "$config" \
+ ifname "${proto:-ppp}-$config" \
+ ${keepalive:+lcp-echo-interval $interval lcp-echo-failure ${keepalive%%[, ]*}} \
+ ${ipv6:++ipv6} \
+ nodefaultroute \
+ usepeerdns \
+ $demand maxfail 1 \
+ ${username:+user "$username" password "$password"} \
+ ${connect:+connect "$connect"} \
+ ${disconnect:+disconnect "$disconnect"} \
+ ip-up-script /lib/netifd/ppp-up \
+ ipv6-up-script /lib/netifd/ppp-up \
+ ip-down-script /lib/netifd/ppp-down \
+ ipv6-down-script /lib/netifd/ppp-down \
+ ${mtu:+mtu $mtu mru $mtu} \
+ $pppd_options "$@"
+}
+
+ppp_generic_teardown() {
+ local interface="$1"
+
+ case "$ERROR" in
+ 11|19)
+ proto_notify_error "$interface" AUTH_FAILED
+ json_get_var authfail authfail
+ if [ "${authfail:-0}" -gt 0 ]; then
+ proto_block_restart "$interface"
+ fi
+ ;;
+ 2)
+ proto_notify_error "$interface" INVALID_OPTIONS
+ proto_block_restart "$interface"
+ ;;
+ esac
+ proto_kill_command "$interface"
+}
+
+# PPP on serial device
+
+proto_ppp_init_config() {
+ proto_config_add_string "device"
+ ppp_generic_init_config
+ no_device=1
+ available=1
+}
+
+proto_ppp_setup() {
+ local config="$1"
+
+ json_get_var device device
+ ppp_generic_setup "$config" "$device"
+}
+
+proto_ppp_teardown() {
+ ppp_generic_teardown "$@"
+}
+
+proto_pppoe_init_config() {
+ ppp_generic_init_config
+ proto_config_add_string "ac"
+ proto_config_add_string "service"
+}
+
+proto_pppoe_setup() {
+ local config="$1"
+ local iface="$2"
+
+ for module in slhc ppp_generic pppox pppoe; do
+ /sbin/insmod $module 2>&- >&-
+ done
+
+ json_get_var mtu mtu
+ mtu="${mtu:-1492}"
+
+ json_get_var ac ac
+ json_get_var service service
+
+ ppp_generic_setup "$config" \
+ plugin rp-pppoe.so \
+ ${ac:+rp_pppoe_ac "$ac"} \
+ ${service:+rp_pppoe_service "$service"} \
+ "nic-$iface"
+}
+
+proto_pppoe_teardown() {
+ ppp_generic_teardown "$@"
+}
+
+proto_pppoa_init_config() {
+ ppp_generic_init_config
+ proto_config_add_int "atmdev"
+ proto_config_add_int "vci"
+ proto_config_add_int "vpi"
+ proto_config_add_string "encaps"
+ no_device=1
+ available=1
+}
+
+proto_pppoa_setup() {
+ local config="$1"
+ local iface="$2"
+
+ for module in slhc ppp_generic pppox pppoatm; do
+ /sbin/insmod $module 2>&- >&-
+ done
+
+ json_get_vars atmdev vci vpi encaps
+
+ case "$encaps" in
+ 1|vc) encaps="vc-encaps" ;;
+ *) encaps="llc-encaps" ;;
+ esac
+
+ ppp_generic_setup "$config" \
+ plugin pppoatm.so \
+ ${atmdev:+$atmdev.}${vpi:-8}.${vci:-35} \
+ ${encaps}
+}
+
+proto_pppoa_teardown() {
+ ppp_generic_teardown "$@"
+}
+
+proto_pptp_init_config() {
+ ppp_generic_init_config
+ proto_config_add_string "server"
+ available=1
+ no_device=1
+}
+
+proto_pptp_setup() {
+ local config="$1"
+ local iface="$2"
+
+ local ip serv_addr server
+ json_get_var server server && {
+ for ip in $(resolveip -t 5 "$server"); do
+ ( proto_add_host_dependency "$config" "$ip" )
+ serv_addr=1
+ done
+ }
+ [ -n "$serv_addr" ] || {
+ echo "Could not resolve server address"
+ sleep 5
+ proto_setup_failed "$config"
+ exit 1
+ }
+
+ local load
+ for module in slhc ppp_generic ppp_async ppp_mppe ip_gre gre pptp; do
+ grep -q "$module" /proc/modules && continue
+ /sbin/insmod $module 2>&- >&-
+ load=1
+ done
+ [ "$load" = "1" ] && sleep 1
+
+ ppp_generic_setup "$config" \
+ plugin pptp.so \
+ pptp_server $server \
+ file /etc/ppp/options.pptp
+}
+
+proto_pptp_teardown() {
+ ppp_generic_teardown "$@"
+}
+
+[ -n "$INCLUDE_ONLY" ] || {
+ add_protocol ppp
+ [ -f /usr/lib/pppd/*/rp-pppoe.so ] && add_protocol pppoe
+ [ -f /usr/lib/pppd/*/pppoatm.so ] && add_protocol pppoa
+ [ -f /usr/lib/pppd/*/pptp.so ] && add_protocol pptp
+}
+
diff --git a/package/network/services/ppp/patches/.svn/entries b/package/network/services/ppp/patches/.svn/entries
new file mode 100644
index 0000000..d53d0aa
--- /dev/null
+++ b/package/network/services/ppp/patches/.svn/entries
@@ -0,0 +1,1082 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/services/ppp/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-11-12T19:13:45.122314Z
+34171
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+340-populate_default_gateway.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+19776f900e923015d439d9e6b643c667
+2012-11-12T19:13:45.122314Z
+34171
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1131
+
+320-custom_iface_names.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+e133be33393bc78ee2243cd1b26026c8
+2012-06-19T17:03:24.802042Z
+32463
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4314
+
+206-compensate_time_change.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+5e964c84d13bdd8d20efd8536f5e2242
+2012-06-19T17:03:24.802042Z
+32463
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2386
+
+403-no_wtmp.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+04da5ce4633d3883b4a856f05d3fada8
+2012-11-12T19:13:45.122314Z
+34171
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+552
+
+107-debian_pppoatm_wildcard.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+f6c1bc88d0a60e6ec03f61351391695d
+2012-06-19T17:03:24.802042Z
+32463
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+935
+
+405-no_multilink_option.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+aa693617dc24b4185969491bb70238d9
+2012-06-19T17:03:24.802042Z
+32463
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1122
+
+330-retain_foreign_default_routes.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+6855b9d18914522099af113337ad1350
+2012-11-12T19:13:45.122314Z
+34171
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+735
+
+110-debian_defaultroute.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+b2d34021e69101ed5956fce6ba6e6428
+2012-06-19T17:03:24.802042Z
+32463
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+11824
+
+500-add-pptp-plugin.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+87203c1e41d41013f3812f11cb8226ea
+2012-06-11T20:07:46.786229Z
+32197
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+109694
+
+321-multilink_support_custom_iface_names.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+5dd596601867f190c0ac41ace1adfac9
+2012-11-12T19:13:45.122314Z
+34171
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3760
+
+204-radius_config.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+f615bd6ce82777715fccb52a3a0c5735
+2009-05-21T10:49:21.592824Z
+15958
+hauke
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2013
+
+203-opt_flags.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+ca52fa5cf6cb446edcdfffbfe2b6a8ea
+2012-06-19T17:03:24.802042Z
+32463
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1067
+
+101-debian_close_dev_ppp.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+38dcd54c923cb548b6dd77c4df63f31b
+2012-06-19T17:03:24.802042Z
+32463
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+986
+
+208-fix_status_code.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+1f2e1258bf7903b1b8fd48165b717ea6
+2012-06-19T17:03:24.802042Z
+32463
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+771
+
+205-no_exponential_timeout.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+87937c482486bc39ac375883de93f2cd
+2012-06-19T17:03:24.802042Z
+32463
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+790
+
+105-debian_demand.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+8e19a2f72d297f73fd6a5942108a916c
+2011-07-28T16:51:12.085816Z
+27818
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5134
+
+202-no_strip.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+bdd19d0eb5ca2fd40e9cc5aa080bb810
+2012-06-19T17:03:24.802042Z
+32463
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2815
+
+201-mppe_mppc_1.1.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+006c3e45b728314a4265f1fe1b93bb4e
+2012-06-19T17:03:24.802042Z
+32463
+jow
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+46605
+
+106-debian_stripMSdomain.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+83db2174215a5c91f0003f0a7d02f315
+2012-06-19T17:03:24.802042Z
+32463
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1460
+
+103-debian_fix_link_pidfile.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+1c07bd87722691ac65fcf701e3c4a067
+2012-06-19T17:03:24.802042Z
+32463
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+743
+
+404-remove_obsolete_protocol_names.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+c87236d69c0ef47317acefd743979f2a
+2012-06-19T17:03:24.802042Z
+32463
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5496
+
+310-precompile_filter.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+97595043f11a376969d70c3f953c1982
+2012-06-19T17:03:24.802042Z
+32463
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5226
+
+100-debian_ip-ip_option.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+b62cef0331427758f5b73b97366c2fc1
+2012-06-19T17:03:24.802042Z
+32463
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3260
+
+010-use_target_for_configure.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+fc8e302c2ab6f518b3ed4f169d0ace21
+2012-06-19T17:03:24.802042Z
+32463
+jow
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+660
+
+120-debian_ipv6_updown_option.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+b94796b6450e040da7ae189076590d31
+2012-06-19T17:03:24.802042Z
+32463
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3431
+
+401-no_record_file.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+97463d762aaa56f5100a4a19744e8424
+2012-06-19T17:03:24.802042Z
+32463
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1717
+
+200-makefile.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+b20554d31e99905d96c1c1a442048259
+2012-06-19T17:03:24.802042Z
+32463
+jow
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1532
+
+400-simplify_kernel_checks.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+8b1cecd9cef60037d11b0507d710c007
+2012-11-12T19:13:45.122314Z
+34171
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4400
+
+207-lcp_mtu_max.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+97f2d56d787beb2144b95bdab0e6209b
+2012-06-19T17:03:24.802042Z
+32463
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+993
+
+300-filter-pcap-includes-lib.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+1821b01a9a0b2615839e7cbb654578ae
+2012-06-19T17:03:24.802042Z
+32463
+jow
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+485
+
+430-pppol2tpv3-struct.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+afbb045f1bbf9956f545bd00178843b5
+2012-11-04T17:01:27.169232Z
+34070
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1801
+
diff --git a/package/network/services/ppp/patches/.svn/prop-base/010-use_target_for_configure.patch.svn-base b/package/network/services/ppp/patches/.svn/prop-base/010-use_target_for_configure.patch.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/network/services/ppp/patches/.svn/prop-base/010-use_target_for_configure.patch.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/services/ppp/patches/.svn/prop-base/200-makefile.patch.svn-base b/package/network/services/ppp/patches/.svn/prop-base/200-makefile.patch.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/network/services/ppp/patches/.svn/prop-base/200-makefile.patch.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/services/ppp/patches/.svn/prop-base/201-mppe_mppc_1.1.patch.svn-base b/package/network/services/ppp/patches/.svn/prop-base/201-mppe_mppc_1.1.patch.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/network/services/ppp/patches/.svn/prop-base/201-mppe_mppc_1.1.patch.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/services/ppp/patches/.svn/prop-base/300-filter-pcap-includes-lib.patch.svn-base b/package/network/services/ppp/patches/.svn/prop-base/300-filter-pcap-includes-lib.patch.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/network/services/ppp/patches/.svn/prop-base/300-filter-pcap-includes-lib.patch.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/services/ppp/patches/.svn/text-base/010-use_target_for_configure.patch.svn-base b/package/network/services/ppp/patches/.svn/text-base/010-use_target_for_configure.patch.svn-base
new file mode 100644
index 0000000..aff0df6
--- /dev/null
+++ b/package/network/services/ppp/patches/.svn/text-base/010-use_target_for_configure.patch.svn-base
@@ -0,0 +1,24 @@
+configure: Allow overriding uname results
+
+In a cross compile setting it makes no sense to rely on the "uname" values
+reported by the build host system. This patch allows overriding the
+"uname -r", "uname -s" and "uname -m" results with the "UNAME_R", "UNAME_S"
+and "UNAME_M" environment variables.
+
+Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
+
+--- a/configure
++++ b/configure
+@@ -8,9 +8,9 @@ SYSCONF=/etc
+ # if [ -d /NextApps ]; then
+ # system="NeXTStep"
+ # else
+- system=`uname -s`
+- release=`uname -r`
+- arch=`uname -m`
++ system=${UNAME_S:-`uname -s`}
++ release=${UNAME_R:-`uname -r`}
++ arch=${UNAME_M:-`uname -m`}
+ # fi
+ state="unknown"
+
diff --git a/package/network/services/ppp/patches/.svn/text-base/100-debian_ip-ip_option.patch.svn-base b/package/network/services/ppp/patches/.svn/text-base/100-debian_ip-ip_option.patch.svn-base
new file mode 100644
index 0000000..ca43cb2
--- /dev/null
+++ b/package/network/services/ppp/patches/.svn/text-base/100-debian_ip-ip_option.patch.svn-base
@@ -0,0 +1,96 @@
+pppd: Allow specifying ip-up and ip-down scripts
+
+This patch implements the "ip-up-script" and "ip-down-script" options which
+allow to specify the path of the ip-up and ip-down scripts to call.
+
+These options default to _PATH_IPUP and _PATH_IPDOWN to retain the
+existing behaviour.
+
+The patch originated from the Debian project.
+
+Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
+
+--- a/pppd/ipcp.c
++++ b/pppd/ipcp.c
+@@ -1939,7 +1939,7 @@ ipcp_up(f)
+ */
+ if (ipcp_script_state == s_down && ipcp_script_pid == 0) {
+ ipcp_script_state = s_up;
+- ipcp_script(_PATH_IPUP, 0);
++ ipcp_script(path_ipup, 0);
+ }
+ }
+
+@@ -1989,7 +1989,7 @@ ipcp_down(f)
+ /* Execute the ip-down script */
+ if (ipcp_script_state == s_up && ipcp_script_pid == 0) {
+ ipcp_script_state = s_down;
+- ipcp_script(_PATH_IPDOWN, 0);
++ ipcp_script(path_ipdown, 0);
+ }
+ }
+
+@@ -2043,13 +2043,13 @@ ipcp_script_done(arg)
+ case s_up:
+ if (ipcp_fsm[0].state != OPENED) {
+ ipcp_script_state = s_down;
+- ipcp_script(_PATH_IPDOWN, 0);
++ ipcp_script(path_ipdown, 0);
+ }
+ break;
+ case s_down:
+ if (ipcp_fsm[0].state == OPENED) {
+ ipcp_script_state = s_up;
+- ipcp_script(_PATH_IPUP, 0);
++ ipcp_script(path_ipup, 0);
+ }
+ break;
+ }
+--- a/pppd/main.c
++++ b/pppd/main.c
+@@ -316,6 +316,9 @@ main(argc, argv)
+ struct protent *protp;
+ char numbuf[16];
+
++ strlcpy(path_ipup, _PATH_IPUP, sizeof(path_ipup));
++ strlcpy(path_ipdown, _PATH_IPDOWN, sizeof(path_ipdown));
++
+ link_stats_valid = 0;
+ new_phase(PHASE_INITIALIZE);
+
+--- a/pppd/options.c
++++ b/pppd/options.c
+@@ -113,6 +113,8 @@ char linkname[MAXPATHLEN]; /* logical na
+ bool tune_kernel; /* may alter kernel settings */
+ int connect_delay = 1000; /* wait this many ms after connect script */
+ int req_unit = -1; /* requested interface unit */
++char path_ipup[MAXPATHLEN]; /* pathname of ip-up script */
++char path_ipdown[MAXPATHLEN];/* pathname of ip-down script */
+ bool multilink = 0; /* Enable multilink operation */
+ char *bundle_name = NULL; /* bundle name for multilink */
+ bool dump_options; /* print out option values */
+@@ -281,6 +283,13 @@ option_t general_options[] = {
+ "Number of seconds to wait for child processes at exit",
+ OPT_PRIO },
+
++ { "ip-up-script", o_string, path_ipup,
++ "Set pathname of ip-up script",
++ OPT_PRIV|OPT_STATIC, NULL, MAXPATHLEN },
++ { "ip-down-script", o_string, path_ipdown,
++ "Set pathname of ip-down script",
++ OPT_PRIV|OPT_STATIC, NULL, MAXPATHLEN },
++
+ #ifdef HAVE_MULTILINK
+ { "multilink", o_bool, &multilink,
+ "Enable multilink operation", OPT_PRIO | 1 },
+--- a/pppd/pppd.h
++++ b/pppd/pppd.h
+@@ -313,6 +313,8 @@ extern bool tune_kernel; /* May alter ke
+ extern int connect_delay; /* Time to delay after connect script */
+ extern int max_data_rate; /* max bytes/sec through charshunt */
+ extern int req_unit; /* interface unit number to use */
++extern char path_ipup[MAXPATHLEN]; /* pathname of ip-up script */
++extern char path_ipdown[MAXPATHLEN]; /* pathname of ip-down script */
+ extern bool multilink; /* enable multilink operation */
+ extern bool noendpoint; /* don't send or accept endpt. discrim. */
+ extern char *bundle_name; /* bundle name for multilink */
diff --git a/package/network/services/ppp/patches/.svn/text-base/101-debian_close_dev_ppp.patch.svn-base b/package/network/services/ppp/patches/.svn/text-base/101-debian_close_dev_ppp.patch.svn-base
new file mode 100644
index 0000000..232b10b
--- /dev/null
+++ b/package/network/services/ppp/patches/.svn/text-base/101-debian_close_dev_ppp.patch.svn-base
@@ -0,0 +1,28 @@
+pppd: Close already open ppp descriptors
+
+When using the kernel PPPoE driver in conjunction with the "persist" option,
+the already open descriptor to /dev/ppp is not closed when the link is
+reestablished. This eventually leads to high CPU load because the stray
+descriptors are always reported as ready by select().
+
+This patch closes the descriptor if it is already open when establishing a
+new connection. It originated from the Debian project.
+
+Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
+
+--- a/pppd/sys-linux.c
++++ b/pppd/sys-linux.c
+@@ -453,6 +453,13 @@ int generic_establish_ppp (int fd)
+ if (new_style_driver) {
+ int flags;
+
++ /* if a ppp_fd is already open, close it first */
++ if(ppp_fd > 0) {
++ close(ppp_fd);
++ remove_fd(ppp_fd);
++ ppp_fd = -1;
++ }
++
+ /* Open an instance of /dev/ppp and connect the channel to it */
+ if (ioctl(fd, PPPIOCGCHAN, &chindex) == -1) {
+ error("Couldn't get channel number: %m");
diff --git a/package/network/services/ppp/patches/.svn/text-base/103-debian_fix_link_pidfile.patch.svn-base b/package/network/services/ppp/patches/.svn/text-base/103-debian_fix_link_pidfile.patch.svn-base
new file mode 100644
index 0000000..c8a23ed
--- /dev/null
+++ b/package/network/services/ppp/patches/.svn/text-base/103-debian_fix_link_pidfile.patch.svn-base
@@ -0,0 +1,23 @@
+pppd: Fix creation of linkpidfile
+
+When pppd is run without "nodetach" or with "updetach", the linkpidfile is
+never created. The call to create_linkpidfile() is protected by a check for
+linkpidfile[0] but this is only filled in when create_linkpidfile() is called.
+
+This patch changes to code to allways uncondiationally call
+create_linkpidfile(), it originated from the Debian project.
+
+Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
+
+--- a/pppd/main.c
++++ b/pppd/main.c
+@@ -773,8 +773,7 @@ detach()
+ /* update pid files if they have been written already */
+ if (pidfilename[0])
+ create_pidfile(pid);
+- if (linkpidfile[0])
+- create_linkpidfile(pid);
++ create_linkpidfile(pid);
+ exit(0); /* parent dies */
+ }
+ setsid();
diff --git a/package/network/services/ppp/patches/.svn/text-base/105-debian_demand.patch.svn-base b/package/network/services/ppp/patches/.svn/text-base/105-debian_demand.patch.svn-base
new file mode 100644
index 0000000..c278656
--- /dev/null
+++ b/package/network/services/ppp/patches/.svn/text-base/105-debian_demand.patch.svn-base
@@ -0,0 +1,172 @@
+--- a/pppd/demand.c
++++ b/pppd/demand.c
+@@ -36,6 +36,8 @@
+ #include <errno.h>
+ #include <fcntl.h>
+ #include <netdb.h>
++#include <unistd.h>
++#include <syslog.h>
+ #include <sys/param.h>
+ #include <sys/types.h>
+ #include <sys/wait.h>
+@@ -43,6 +45,8 @@
+ #include <sys/resource.h>
+ #include <sys/stat.h>
+ #include <sys/socket.h>
++#include <netinet/in.h>
++#include <arpa/inet.h>
+ #ifdef PPP_FILTER
+ #include <pcap-bpf.h>
+ #endif
+@@ -221,6 +225,14 @@ loop_chars(p, n)
+ int c, rv;
+
+ rv = 0;
++
++/* check for synchronous connection... */
++
++ if ( (p[0] == 0xFF) && (p[1] == 0x03) ) {
++ rv = loop_frame(p,n);
++ return rv;
++ }
++
+ for (; n > 0; --n) {
+ c = *p++;
+ if (c == PPP_FLAG) {
+@@ -299,17 +311,102 @@ loop_frame(frame, len)
+ * loopback, now that the real serial link is up.
+ */
+ void
+-demand_rexmit(proto)
++demand_rexmit(proto, newip)
+ int proto;
++ u_int32_t newip;
+ {
+ struct packet *pkt, *prev, *nextpkt;
++ unsigned short checksum;
++ unsigned short pkt_checksum = 0;
++ unsigned iphdr;
++ struct timeval tv;
++ char cv = 0;
++ char ipstr[16];
+
+ prev = NULL;
+ pkt = pend_q;
+ pend_q = NULL;
++ tv.tv_sec = 1;
++ tv.tv_usec = 0;
++ select(0,NULL,NULL,NULL,&tv); /* Sleep for 1 Seconds */
+ for (; pkt != NULL; pkt = nextpkt) {
+ nextpkt = pkt->next;
+ if (PPP_PROTOCOL(pkt->data) == proto) {
++ if ( (proto == PPP_IP) && newip ) {
++ /* Get old checksum */
++
++ iphdr = (pkt->data[4] & 15) << 2;
++ checksum = *((unsigned short *) (pkt->data+14));
++ if (checksum == 0xFFFF) {
++ checksum = 0;
++ }
++
++
++ if (pkt->data[13] == 17) {
++ pkt_checksum = *((unsigned short *) (pkt->data+10+iphdr));
++ if (pkt_checksum) {
++ cv = 1;
++ if (pkt_checksum == 0xFFFF) {
++ pkt_checksum = 0;
++ }
++ }
++ else {
++ cv = 0;
++ }
++ }
++
++ if (pkt->data[13] == 6) {
++ pkt_checksum = *((unsigned short *) (pkt->data+20+iphdr));
++ cv = 1;
++ if (pkt_checksum == 0xFFFF) {
++ pkt_checksum = 0;
++ }
++ }
++
++ /* Delete old Source-IP-Address */
++ checksum -= *((unsigned short *) (pkt->data+16)) ^ 0xFFFF;
++ checksum -= *((unsigned short *) (pkt->data+18)) ^ 0xFFFF;
++
++ pkt_checksum -= *((unsigned short *) (pkt->data+16)) ^ 0xFFFF;
++ pkt_checksum -= *((unsigned short *) (pkt->data+18)) ^ 0xFFFF;
++
++ /* Change Source-IP-Address */
++ * ((u_int32_t *) (pkt->data + 16)) = newip;
++
++ /* Add new Source-IP-Address */
++ checksum += *((unsigned short *) (pkt->data+16)) ^ 0xFFFF;
++ checksum += *((unsigned short *) (pkt->data+18)) ^ 0xFFFF;
++
++ pkt_checksum += *((unsigned short *) (pkt->data+16)) ^ 0xFFFF;
++ pkt_checksum += *((unsigned short *) (pkt->data+18)) ^ 0xFFFF;
++
++ /* Write new checksum */
++ if (!checksum) {
++ checksum = 0xFFFF;
++ }
++ *((unsigned short *) (pkt->data+14)) = checksum;
++ if (pkt->data[13] == 6) {
++ *((unsigned short *) (pkt->data+20+iphdr)) = pkt_checksum;
++ }
++ if (cv && (pkt->data[13] == 17) ) {
++ *((unsigned short *) (pkt->data+10+iphdr)) = pkt_checksum;
++ }
++
++ /* Log Packet */
++ strcpy(ipstr,inet_ntoa(*( (struct in_addr *) (pkt->data+16))));
++ if (pkt->data[13] == 1) {
++ syslog(LOG_INFO,"Open ICMP %s -> %s\n",
++ ipstr,
++ inet_ntoa(*( (struct in_addr *) (pkt->data+20))));
++ } else {
++ syslog(LOG_INFO,"Open %s %s:%d -> %s:%d\n",
++ pkt->data[13] == 6 ? "TCP" : "UDP",
++ ipstr,
++ ntohs(*( (short *) (pkt->data+iphdr+4))),
++ inet_ntoa(*( (struct in_addr *) (pkt->data+20))),
++ ntohs(*( (short *) (pkt->data+iphdr+6))));
++ }
++ }
+ output(0, pkt->data, pkt->length);
+ free(pkt);
+ } else {
+--- a/pppd/ipcp.c
++++ b/pppd/ipcp.c
+@@ -1864,7 +1864,7 @@ ipcp_up(f)
+ proxy_arp_set[f->unit] = 1;
+
+ }
+- demand_rexmit(PPP_IP);
++ demand_rexmit(PPP_IP,go->ouraddr);
+ sifnpmode(f->unit, PPP_IP, NPMODE_PASS);
+
+ } else {
+--- a/pppd/ipv6cp.c
++++ b/pppd/ipv6cp.c
+@@ -1232,7 +1232,7 @@ ipv6cp_up(f)
+ }
+
+ }
+- demand_rexmit(PPP_IPV6);
++ demand_rexmit(PPP_IPV6,0);
+ sifnpmode(f->unit, PPP_IPV6, NPMODE_PASS);
+
+ } else {
+--- a/pppd/pppd.h
++++ b/pppd/pppd.h
+@@ -566,7 +566,7 @@ void demand_conf __P((void)); /* config
+ void demand_block __P((void)); /* set all NPs to queue up packets */
+ void demand_unblock __P((void)); /* set all NPs to pass packets */
+ void demand_discard __P((void)); /* set all NPs to discard packets */
+-void demand_rexmit __P((int)); /* retransmit saved frames for an NP */
++void demand_rexmit __P((int, u_int32_t)); /* retransmit saved frames for an NP*/
+ int loop_chars __P((unsigned char *, int)); /* process chars from loopback */
+ int loop_frame __P((unsigned char *, int)); /* should we bring link up? */
+
diff --git a/package/network/services/ppp/patches/.svn/text-base/106-debian_stripMSdomain.patch.svn-base b/package/network/services/ppp/patches/.svn/text-base/106-debian_stripMSdomain.patch.svn-base
new file mode 100644
index 0000000..86af1ef
--- /dev/null
+++ b/package/network/services/ppp/patches/.svn/text-base/106-debian_stripMSdomain.patch.svn-base
@@ -0,0 +1,47 @@
+pppd: Implement option to strip domain part from MS CHAP response
+
+This patch implements a new boolean option "chapms-strip-domain" which
+strips the leading domain part of the username in a received MS Chap
+response.
+
+When the option is set, all leading chars up to and including the last
+backslash in the username are stripped. The option defaults to false.
+
+The patch originated from the Debian project.
+
+Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
+
+--- a/pppd/chap-new.c
++++ b/pppd/chap-new.c
+@@ -58,6 +58,7 @@ int (*chap_verify_hook)(char *name, char
+ int chap_timeout_time = 3;
+ int chap_max_transmits = 10;
+ int chap_rechallenge_time = 0;
++int chapms_strip_domain = 0;
+
+ /*
+ * Command-line options.
+@@ -69,6 +70,8 @@ static option_t chap_option_list[] = {
+ "Set max #xmits for challenge", OPT_PRIO },
+ { "chap-interval", o_int, &chap_rechallenge_time,
+ "Set interval for rechallenge", OPT_PRIO },
++ { "chapms-strip-domain", o_bool, &chapms_strip_domain,
++ "Strip the domain prefix before the Username", 1 },
+ { NULL }
+ };
+
+@@ -336,6 +339,14 @@ chap_handle_response(struct chap_server_
+ /* Null terminate and clean remote name. */
+ slprintf(rname, sizeof(rname), "%.*v", len, name);
+ name = rname;
++
++ /* strip the MS domain name */
++ if (chapms_strip_domain && strrchr(rname, '\\')) {
++ char tmp[MAXNAMELEN+1];
++
++ strcpy(tmp, strrchr(rname, '\\') + 1);
++ strcpy(rname, tmp);
++ }
+ }
+
+ if (chap_verify_hook)
diff --git a/package/network/services/ppp/patches/.svn/text-base/107-debian_pppoatm_wildcard.patch.svn-base b/package/network/services/ppp/patches/.svn/text-base/107-debian_pppoatm_wildcard.patch.svn-base
new file mode 100644
index 0000000..eaad2cd
--- /dev/null
+++ b/package/network/services/ppp/patches/.svn/text-base/107-debian_pppoatm_wildcard.patch.svn-base
@@ -0,0 +1,25 @@
+pppoatm: Allow wildcard ATM devices
+
+When operating pppd's pppoatm plugin with an USB ADSL modem, e.g. an
+Alcatel Speedtouch, the ATM device number might change when the modem is
+reconnected to the USB port or when the host controller resets the USB
+device.
+
+This patch allows to specify the ATM device as wildcard which gives
+enough flexibility to cope with changing device names.
+
+The patch originated from the Debain project.
+
+Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
+
+--- a/pppd/plugins/pppoatm/pppoatm.c
++++ b/pppd/plugins/pppoatm/pppoatm.c
+@@ -75,7 +75,7 @@ static int setdevname_pppoatm(const char
+ //info("PPPoATM setdevname_pppoatm: '%s'", cp);
+ memset(&addr, 0, sizeof addr);
+ if (text2atm(cp, (struct sockaddr *) &addr, sizeof(addr),
+- T2A_PVC | T2A_NAME) < 0) {
++ T2A_PVC | T2A_NAME | T2A_WILDCARD) < 0) {
+ if(doit)
+ info("atm does not recognize: %s", cp);
+ return 0;
diff --git a/package/network/services/ppp/patches/.svn/text-base/110-debian_defaultroute.patch.svn-base b/package/network/services/ppp/patches/.svn/text-base/110-debian_defaultroute.patch.svn-base
new file mode 100644
index 0000000..41d2890
--- /dev/null
+++ b/package/network/services/ppp/patches/.svn/text-base/110-debian_defaultroute.patch.svn-base
@@ -0,0 +1,313 @@
+pppd: Add "replacedefaultroute" and "noreplacedefaultroute" options
+
+This patch implements two new options, "replacedefaultroute" to replace any
+existing system default route when specified and "noreplacedefaultroute" to
+disable the "replacedefaultroute" option, which is useful in multi user
+environments where the administrator wants to allow users to dial pppd
+connections but not allow them to change the system default route.
+
+The patch originated from the Debian project.
+
+Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
+
+--- a/pppd/ipcp.c
++++ b/pppd/ipcp.c
+@@ -198,6 +198,14 @@ static option_t ipcp_option_list[] = {
+ "disable defaultroute option", OPT_ALIAS | OPT_A2CLR,
+ &ipcp_wantoptions[0].default_route },
+
++ { "replacedefaultroute", o_bool,
++ &ipcp_wantoptions[0].replace_default_route,
++ "Replace default route", 1
++ },
++ { "noreplacedefaultroute", o_bool,
++ &ipcp_allowoptions[0].replace_default_route,
++ "Never replace default route", OPT_A2COPY,
++ &ipcp_wantoptions[0].replace_default_route },
+ { "proxyarp", o_bool, &ipcp_wantoptions[0].proxy_arp,
+ "Add proxy ARP entry", OPT_ENABLE|1, &ipcp_allowoptions[0].proxy_arp },
+ { "noproxyarp", o_bool, &ipcp_allowoptions[0].proxy_arp,
+@@ -271,7 +279,7 @@ struct protent ipcp_protent = {
+ ip_active_pkt
+ };
+
+-static void ipcp_clear_addrs __P((int, u_int32_t, u_int32_t));
++static void ipcp_clear_addrs __P((int, u_int32_t, u_int32_t, bool));
+ static void ipcp_script __P((char *, int)); /* Run an up/down script */
+ static void ipcp_script_done __P((void *));
+
+@@ -1742,7 +1750,8 @@ ip_demand_conf(u)
+ if (!sifnpmode(u, PPP_IP, NPMODE_QUEUE))
+ return 0;
+ if (wo->default_route)
+- if (sifdefaultroute(u, wo->ouraddr, wo->hisaddr))
++ if (sifdefaultroute(u, wo->ouraddr, wo->hisaddr,
++ wo->replace_default_route))
+ default_route_set[u] = 1;
+ if (wo->proxy_arp)
+ if (sifproxyarp(u, wo->hisaddr))
+@@ -1830,7 +1839,8 @@ ipcp_up(f)
+ */
+ if (demand) {
+ if (go->ouraddr != wo->ouraddr || ho->hisaddr != wo->hisaddr) {
+- ipcp_clear_addrs(f->unit, wo->ouraddr, wo->hisaddr);
++ ipcp_clear_addrs(f->unit, wo->ouraddr, wo->hisaddr,
++ wo->replace_default_route);
+ if (go->ouraddr != wo->ouraddr) {
+ warn("Local IP address changed to %I", go->ouraddr);
+ script_setenv("OLDIPLOCAL", ip_ntoa(wo->ouraddr), 0);
+@@ -1855,7 +1865,8 @@ ipcp_up(f)
+
+ /* assign a default route through the interface if required */
+ if (ipcp_wantoptions[f->unit].default_route)
+- if (sifdefaultroute(f->unit, go->ouraddr, ho->hisaddr))
++ if (sifdefaultroute(f->unit, go->ouraddr, ho->hisaddr,
++ wo->replace_default_route))
+ default_route_set[f->unit] = 1;
+
+ /* Make a proxy ARP entry if requested. */
+@@ -1905,7 +1916,8 @@ ipcp_up(f)
+
+ /* assign a default route through the interface if required */
+ if (ipcp_wantoptions[f->unit].default_route)
+- if (sifdefaultroute(f->unit, go->ouraddr, ho->hisaddr))
++ if (sifdefaultroute(f->unit, go->ouraddr, ho->hisaddr,
++ wo->replace_default_route))
+ default_route_set[f->unit] = 1;
+
+ /* Make a proxy ARP entry if requested. */
+@@ -1983,7 +1995,7 @@ ipcp_down(f)
+ sifnpmode(f->unit, PPP_IP, NPMODE_DROP);
+ sifdown(f->unit);
+ ipcp_clear_addrs(f->unit, ipcp_gotoptions[f->unit].ouraddr,
+- ipcp_hisoptions[f->unit].hisaddr);
++ ipcp_hisoptions[f->unit].hisaddr, 0);
+ }
+
+ /* Execute the ip-down script */
+@@ -1999,16 +2011,25 @@ ipcp_down(f)
+ * proxy arp entries, etc.
+ */
+ static void
+-ipcp_clear_addrs(unit, ouraddr, hisaddr)
++ipcp_clear_addrs(unit, ouraddr, hisaddr, replacedefaultroute)
+ int unit;
+ u_int32_t ouraddr; /* local address */
+ u_int32_t hisaddr; /* remote address */
++ bool replacedefaultroute;
+ {
+ if (proxy_arp_set[unit]) {
+ cifproxyarp(unit, hisaddr);
+ proxy_arp_set[unit] = 0;
+ }
+- if (default_route_set[unit]) {
++ /* If replacedefaultroute, sifdefaultroute will be called soon
++ * with replacedefaultroute set and that will overwrite the current
++ * default route. This is the case only when doing demand, otherwise
++ * during demand, this cifdefaultroute would restore the old default
++ * route which is not what we want in this case. In the non-demand
++ * case, we'll delete the default route and restore the old if there
++ * is one saved by an sifdefaultroute with replacedefaultroute.
++ */
++ if (!replacedefaultroute && default_route_set[unit]) {
+ cifdefaultroute(unit, ouraddr, hisaddr);
+ default_route_set[unit] = 0;
+ }
+--- a/pppd/ipcp.h
++++ b/pppd/ipcp.h
+@@ -70,6 +70,7 @@ typedef struct ipcp_options {
+ bool old_addrs; /* Use old (IP-Addresses) option? */
+ bool req_addr; /* Ask peer to send IP address? */
+ bool default_route; /* Assign default route through interface? */
++ bool replace_default_route; /* Replace default route through interface? */
+ bool proxy_arp; /* Make proxy ARP entry for peer? */
+ bool neg_vj; /* Van Jacobson Compression? */
+ bool old_vj; /* use old (short) form of VJ option? */
+--- a/pppd/pppd.8
++++ b/pppd/pppd.8
+@@ -121,6 +121,11 @@ the gateway, when IPCP negotiation is su
+ This entry is removed when the PPP connection is broken. This option
+ is privileged if the \fInodefaultroute\fR option has been specified.
+ .TP
++.B replacedefaultroute
++This option is a flag to the defaultroute option. If defaultroute is
++set and this flag is also set, pppd replaces an existing default route
++with the new default route.
++.TP
+ .B disconnect \fIscript
+ Execute the command specified by \fIscript\fR, by passing it to a
+ shell, after
+@@ -717,7 +722,12 @@ disable both forms of hardware flow cont
+ .TP
+ .B nodefaultroute
+ Disable the \fIdefaultroute\fR option. The system administrator who
+-wishes to prevent users from creating default routes with pppd
++wishes to prevent users from adding a default route with pppd
++can do so by placing this option in the /etc/ppp/options file.
++.TP
++.B noreplacedefaultroute
++Disable the \fIreplacedefaultroute\fR option. The system administrator who
++wishes to prevent users from replacing a default route with pppd
+ can do so by placing this option in the /etc/ppp/options file.
+ .TP
+ .B nodeflate
+--- a/pppd/pppd.h
++++ b/pppd/pppd.h
+@@ -645,7 +645,7 @@ int sif6addr __P((int, eui64_t, eui64_t
+ int cif6addr __P((int, eui64_t, eui64_t));
+ /* Remove an IPv6 address from i/f */
+ #endif
+-int sifdefaultroute __P((int, u_int32_t, u_int32_t));
++int sifdefaultroute __P((int, u_int32_t, u_int32_t, bool replace_default_rt));
+ /* Create default route through i/f */
+ int cifdefaultroute __P((int, u_int32_t, u_int32_t));
+ /* Delete default route through i/f */
+--- a/pppd/sys-linux.c
++++ b/pppd/sys-linux.c
+@@ -206,6 +206,8 @@ static unsigned char inbuf[512]; /* buff
+
+ static int if_is_up; /* Interface has been marked up */
+ static int have_default_route; /* Gateway for default route added */
++static struct rtentry old_def_rt; /* Old default route */
++static int default_rt_repl_rest; /* replace and restore old default rt */
+ static u_int32_t proxy_arp_addr; /* Addr for proxy arp entry added */
+ static char proxy_arp_dev[16]; /* Device for proxy arp entry */
+ static u_int32_t our_old_addr; /* for detecting address changes */
+@@ -1544,6 +1546,9 @@ static int read_route_table(struct rtent
+ p = NULL;
+ }
+
++ SET_SA_FAMILY (rt->rt_dst, AF_INET);
++ SET_SA_FAMILY (rt->rt_gateway, AF_INET);
++
+ SIN_ADDR(rt->rt_dst) = strtoul(cols[route_dest_col], NULL, 16);
+ SIN_ADDR(rt->rt_gateway) = strtoul(cols[route_gw_col], NULL, 16);
+ SIN_ADDR(rt->rt_genmask) = strtoul(cols[route_mask_col], NULL, 16);
+@@ -1613,20 +1618,51 @@ int have_route_to(u_int32_t addr)
+ /********************************************************************
+ *
+ * sifdefaultroute - assign a default route through the address given.
+- */
+-
+-int sifdefaultroute (int unit, u_int32_t ouraddr, u_int32_t gateway)
+-{
+- struct rtentry rt;
+-
+- if (defaultroute_exists(&rt) && strcmp(rt.rt_dev, ifname) != 0) {
+- if (rt.rt_flags & RTF_GATEWAY)
+- error("not replacing existing default route via %I",
+- SIN_ADDR(rt.rt_gateway));
+- else
++ *
++ * If the global default_rt_repl_rest flag is set, then this function
++ * already replaced the original system defaultroute with some other
++ * route and it should just replace the current defaultroute with
++ * another one, without saving the current route. Use: demand mode,
++ * when pppd sets first a defaultroute it it's temporary ppp0 addresses
++ * and then changes the temporary addresses to the addresses for the real
++ * ppp connection when it has come up.
++ */
++
++int sifdefaultroute (int unit, u_int32_t ouraddr, u_int32_t gateway, bool replace)
++{
++ struct rtentry rt, tmp_rt;
++ struct rtentry *del_rt = NULL;
++
++ if (default_rt_repl_rest) {
++ /* We have already reclaced the original defaultroute, if we
++ are called again, we will delete the current default route
++ and set the new default route in this function.
++ - this is normally only the case the doing demand: */
++ if (defaultroute_exists(&tmp_rt))
++ del_rt = &tmp_rt;
++ } else if (defaultroute_exists(&old_def_rt) &&
++ strcmp(old_def_rt.rt_dev, ifname) != 0) {
++ /* We did not yet replace an existing default route, let's
++ check if we should save and replace a default route: */
++ if (old_def_rt.rt_flags & RTF_GATEWAY) {
++ if (!replace) {
++ error("not replacing existing default route via %I",
++ SIN_ADDR(old_def_rt.rt_gateway));
++ return 0;
++ } else {
++ /* we need to copy rt_dev because we need it permanent too: */
++ char *tmp_dev = malloc(strlen(old_def_rt.rt_dev) + 1);
++ strcpy(tmp_dev, old_def_rt.rt_dev);
++ old_def_rt.rt_dev = tmp_dev;
++
++ notice("replacing old default route to %s [%I]",
++ old_def_rt.rt_dev, SIN_ADDR(old_def_rt.rt_gateway));
++ default_rt_repl_rest = 1;
++ del_rt = &old_def_rt;
++ }
++ } else
+ error("not replacing existing default route through %s",
+- rt.rt_dev);
+- return 0;
++ old_def_rt.rt_dev);
+ }
+
+ memset (&rt, 0, sizeof (rt));
+@@ -1641,10 +1677,16 @@ int sifdefaultroute (int unit, u_int32_t
+
+ rt.rt_flags = RTF_UP;
+ if (ioctl(sock_fd, SIOCADDRT, &rt) < 0) {
+- if ( ! ok_error ( errno ))
++ if (!ok_error(errno))
+ error("default route ioctl(SIOCADDRT): %m");
+ return 0;
+ }
++ if (default_rt_repl_rest && del_rt)
++ if (ioctl(sock_fd, SIOCDELRT, del_rt) < 0) {
++ if (!ok_error(errno))
++ error("del old default route ioctl(SIOCDELRT): %m");
++ return 0;
++ }
+
+ have_default_route = 1;
+ return 1;
+@@ -1675,11 +1717,21 @@ int cifdefaultroute (int unit, u_int32_t
+ rt.rt_flags = RTF_UP;
+ if (ioctl(sock_fd, SIOCDELRT, &rt) < 0 && errno != ESRCH) {
+ if (still_ppp()) {
+- if ( ! ok_error ( errno ))
++ if (!ok_error(errno))
+ error("default route ioctl(SIOCDELRT): %m");
+ return 0;
+ }
+ }
++ if (default_rt_repl_rest) {
++ notice("restoring old default route to %s [%I]",
++ old_def_rt.rt_dev, SIN_ADDR(old_def_rt.rt_gateway));
++ if (ioctl(sock_fd, SIOCADDRT, &old_def_rt) < 0) {
++ if (!ok_error(errno))
++ error("restore default route ioctl(SIOCADDRT): %m");
++ return 0;
++ }
++ default_rt_repl_rest = 0;
++ }
+
+ return 1;
+ }
+--- a/pppd/sys-solaris.c
++++ b/pppd/sys-solaris.c
+@@ -2036,12 +2036,18 @@ cifaddr(u, o, h)
+ * sifdefaultroute - assign a default route through the address given.
+ */
+ int
+-sifdefaultroute(u, l, g)
++sifdefaultroute(u, l, g, replace)
+ int u;
+ u_int32_t l, g;
++ bool replace;
+ {
+ struct rtentry rt;
+
++ if (replace) {
++ error("replacedefaultroute not supported on this platform");
++ return 0;
++ }
++
+ #if defined(__USLC__)
+ g = l; /* use the local address as gateway */
+ #endif
diff --git a/package/network/services/ppp/patches/.svn/text-base/120-debian_ipv6_updown_option.patch.svn-base b/package/network/services/ppp/patches/.svn/text-base/120-debian_ipv6_updown_option.patch.svn-base
new file mode 100644
index 0000000..c5457fa
--- /dev/null
+++ b/package/network/services/ppp/patches/.svn/text-base/120-debian_ipv6_updown_option.patch.svn-base
@@ -0,0 +1,95 @@
+pppd: Allow specifying ipv6-up and ipv6-down scripts
+
+This patch implements the "ipv6-up-script" and "ipv6-down-script" options
+which allow to specify the path of the ipv6-up and ipv6-down scripts to call.
+
+These options default to _PATH_IPV6UP and _PATH_IPV6DOWN to retain the
+existing behaviour.
+
+The patch originated from the Debian project.
+
+Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
+
+--- a/pppd/main.c
++++ b/pppd/main.c
+@@ -318,6 +318,8 @@ main(argc, argv)
+
+ strlcpy(path_ipup, _PATH_IPUP, sizeof(path_ipup));
+ strlcpy(path_ipdown, _PATH_IPDOWN, sizeof(path_ipdown));
++ strlcpy(path_ipv6up, _PATH_IPV6UP, sizeof(path_ipv6up));
++ strlcpy(path_ipv6down, _PATH_IPV6DOWN, sizeof(path_ipv6down));
+
+ link_stats_valid = 0;
+ new_phase(PHASE_INITIALIZE);
+--- a/pppd/options.c
++++ b/pppd/options.c
+@@ -115,6 +115,8 @@ int connect_delay = 1000; /* wait this m
+ int req_unit = -1; /* requested interface unit */
+ char path_ipup[MAXPATHLEN]; /* pathname of ip-up script */
+ char path_ipdown[MAXPATHLEN];/* pathname of ip-down script */
++char path_ipv6up[MAXPATHLEN]; /* pathname of ipv6-up script */
++char path_ipv6down[MAXPATHLEN];/* pathname of ipv6-down script */
+ bool multilink = 0; /* Enable multilink operation */
+ char *bundle_name = NULL; /* bundle name for multilink */
+ bool dump_options; /* print out option values */
+@@ -290,6 +292,13 @@ option_t general_options[] = {
+ "Set pathname of ip-down script",
+ OPT_PRIV|OPT_STATIC, NULL, MAXPATHLEN },
+
++ { "ipv6-up-script", o_string, path_ipv6up,
++ "Set pathname of ipv6-up script",
++ OPT_PRIV|OPT_STATIC, NULL, MAXPATHLEN },
++ { "ipv6-down-script", o_string, path_ipv6down,
++ "Set pathname of ipv6-down script",
++ OPT_PRIV|OPT_STATIC, NULL, MAXPATHLEN },
++
+ #ifdef HAVE_MULTILINK
+ { "multilink", o_bool, &multilink,
+ "Enable multilink operation", OPT_PRIO | 1 },
+--- a/pppd/ipv6cp.c
++++ b/pppd/ipv6cp.c
+@@ -1288,7 +1288,7 @@ ipv6cp_up(f)
+ */
+ if (ipv6cp_script_state == s_down && ipv6cp_script_pid == 0) {
+ ipv6cp_script_state = s_up;
+- ipv6cp_script(_PATH_IPV6UP);
++ ipv6cp_script(path_ipv6up);
+ }
+ }
+
+@@ -1339,7 +1339,7 @@ ipv6cp_down(f)
+ /* Execute the ipv6-down script */
+ if (ipv6cp_script_state == s_up && ipv6cp_script_pid == 0) {
+ ipv6cp_script_state = s_down;
+- ipv6cp_script(_PATH_IPV6DOWN);
++ ipv6cp_script(path_ipv6down);
+ }
+ }
+
+@@ -1382,13 +1382,13 @@ ipv6cp_script_done(arg)
+ case s_up:
+ if (ipv6cp_fsm[0].state != OPENED) {
+ ipv6cp_script_state = s_down;
+- ipv6cp_script(_PATH_IPV6DOWN);
++ ipv6cp_script(path_ipv6down);
+ }
+ break;
+ case s_down:
+ if (ipv6cp_fsm[0].state == OPENED) {
+ ipv6cp_script_state = s_up;
+- ipv6cp_script(_PATH_IPV6UP);
++ ipv6cp_script(path_ipv6up);
+ }
+ break;
+ }
+--- a/pppd/pppd.h
++++ b/pppd/pppd.h
+@@ -315,6 +315,8 @@ extern int max_data_rate; /* max bytes/s
+ extern int req_unit; /* interface unit number to use */
+ extern char path_ipup[MAXPATHLEN]; /* pathname of ip-up script */
+ extern char path_ipdown[MAXPATHLEN]; /* pathname of ip-down script */
++extern char path_ipv6up[MAXPATHLEN]; /* pathname of ipv6-up script */
++extern char path_ipv6down[MAXPATHLEN]; /* pathname of ipv6-down script */
+ extern bool multilink; /* enable multilink operation */
+ extern bool noendpoint; /* don't send or accept endpt. discrim. */
+ extern char *bundle_name; /* bundle name for multilink */
diff --git a/package/network/services/ppp/patches/.svn/text-base/200-makefile.patch.svn-base b/package/network/services/ppp/patches/.svn/text-base/200-makefile.patch.svn-base
new file mode 100644
index 0000000..9db908d
--- /dev/null
+++ b/package/network/services/ppp/patches/.svn/text-base/200-makefile.patch.svn-base
@@ -0,0 +1,55 @@
+pppd: tune Linux config defaults for OpenWrt
+
+This patch adjusts a number defaults to properly match the OpenWrt environment.
+It is not intended for upstream.
+
+Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
+
+--- a/pppd/Makefile.linux
++++ b/pppd/Makefile.linux
+@@ -48,7 +48,7 @@ MPPE=y
+ # Uncomment the next line to include support for PPP packet filtering.
+ # This requires that the libpcap library and headers be installed
+ # and that the kernel driver support PPP packet filtering.
+-FILTER=y
++#FILTER=y
+
+ # Uncomment the next line to enable multilink PPP (enabled by default)
+ # Linux distributions: Please leave multilink ENABLED in your builds
+@@ -58,11 +58,11 @@ HAVE_MULTILINK=y
+ # Uncomment the next line to enable the TDB database (enabled by default.)
+ # If you enable multilink, then TDB is automatically enabled also.
+ # Linux distributions: Please leave TDB ENABLED in your builds.
+-USE_TDB=y
++#USE_TDB=y
+
+-HAS_SHADOW=y
++#HAS_SHADOW=y
+ #USE_PAM=y
+-#HAVE_INET6=y
++HAVE_INET6=y
+
+ # Enable plugins
+ PLUGIN=y
+@@ -77,7 +77,7 @@ MAXOCTETS=y
+
+ INCLUDE_DIRS= -I../include
+
+-COMPILE_FLAGS= -DHAVE_PATHS_H -DIPX_CHANGE -DHAVE_MMAP
++COMPILE_FLAGS= -DHAVE_PATHS_H -DHAVE_MMAP
+
+ CFLAGS= $(COPTS) $(COMPILE_FLAGS) $(INCLUDE_DIRS) '-DDESTDIR="@DESTDIR@"'
+
+@@ -117,10 +117,10 @@ CFLAGS += -DHAS_SHADOW
+ #LIBS += -lshadow $(LIBS)
+ endif
+
+-ifneq ($(wildcard /usr/include/crypt.h),)
++#ifneq ($(wildcard /usr/include/crypt.h),)
+ CFLAGS += -DHAVE_CRYPT_H=1
+ LIBS += -lcrypt
+-endif
++#endif
+
+ ifdef NEEDDES
+ ifndef USE_CRYPT
diff --git a/package/network/services/ppp/patches/.svn/text-base/201-mppe_mppc_1.1.patch.svn-base b/package/network/services/ppp/patches/.svn/text-base/201-mppe_mppc_1.1.patch.svn-base
new file mode 100644
index 0000000..3edd11e
--- /dev/null
+++ b/package/network/services/ppp/patches/.svn/text-base/201-mppe_mppc_1.1.patch.svn-base
@@ -0,0 +1,1495 @@
+pppd: add support for MPPE and MPPC encryption and compression protocols
+
+This is a forward ported version of ppp-2.4.3-mppe-mppc-1.1.patch.gz found on
+http://mppe-mppc.alphacron.de/ .
+
+Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
+
+--- a/include/linux/ppp-comp.h
++++ b/include/linux/ppp-comp.h
+@@ -36,7 +36,7 @@
+ */
+
+ /*
+- * ==FILEVERSION 20020319==
++ * ==FILEVERSION 20020715==
+ *
+ * NOTE TO MAINTAINERS:
+ * If you modify this file at all, please set the above date.
+@@ -201,6 +201,33 @@ struct compressor {
+ #define CI_MPPE 18 /* config option for MPPE */
+ #define CILEN_MPPE 6 /* length of config option */
+
++/* MPPE/MPPC definitions by J.D.*/
++#define MPPE_STATELESS MPPE_H_BIT /* configuration bit H */
++#define MPPE_40BIT MPPE_L_BIT /* configuration bit L */
++#define MPPE_56BIT MPPE_M_BIT /* configuration bit M */
++#define MPPE_128BIT MPPE_S_BIT /* configuration bit S */
++#define MPPE_MPPC MPPE_C_BIT /* configuration bit C */
++
++/*
++ * Definitions for Stac LZS.
++ */
++
++#define CI_LZS 17 /* config option for Stac LZS */
++#define CILEN_LZS 5 /* length of config option */
++
++#define LZS_OVHD 4 /* max. LZS overhead */
++#define LZS_HIST_LEN 2048 /* LZS history size */
++#define LZS_MAX_CCOUNT 0x0FFF /* max. coherency counter value */
++
++#define LZS_MODE_NONE 0
++#define LZS_MODE_LCB 1
++#define LZS_MODE_CRC 2
++#define LZS_MODE_SEQ 3
++#define LZS_MODE_EXT 4
++
++#define LZS_EXT_BIT_FLUSHED 0x80 /* bit A */
++#define LZS_EXT_BIT_COMP 0x20 /* bit C */
++
+ /*
+ * Definitions for other, as yet unsupported, compression methods.
+ */
+--- a/include/net/ppp-comp.h
++++ b/include/net/ppp-comp.h
+@@ -168,6 +168,33 @@ struct compressor {
+ #define CI_MPPE 18 /* config option for MPPE */
+ #define CILEN_MPPE 6 /* length of config option */
+
++/* MPPE/MPPC definitions by J.D.*/
++#define MPPE_STATELESS MPPE_H_BIT /* configuration bit H */
++#define MPPE_40BIT MPPE_L_BIT /* configuration bit L */
++#define MPPE_56BIT MPPE_M_BIT /* configuration bit M */
++#define MPPE_128BIT MPPE_S_BIT /* configuration bit S */
++#define MPPE_MPPC MPPE_C_BIT /* configuration bit C */
++
++/*
++ * Definitions for Stac LZS.
++ */
++
++#define CI_LZS 17 /* config option for Stac LZS */
++#define CILEN_LZS 5 /* length of config option */
++
++#define LZS_OVHD 4 /* max. LZS overhead */
++#define LZS_HIST_LEN 2048 /* LZS history size */
++#define LZS_MAX_CCOUNT 0x0FFF /* max. coherency counter value */
++
++#define LZS_MODE_NONE 0
++#define LZS_MODE_LCB 1
++#define LZS_MODE_CRC 2
++#define LZS_MODE_SEQ 3
++#define LZS_MODE_EXT 4
++
++#define LZS_EXT_BIT_FLUSHED 0x80 /* bit A */
++#define LZS_EXT_BIT_COMP 0x20 /* bit C */
++
+ /*
+ * Definitions for other, as yet unsupported, compression methods.
+ */
+--- a/pppd/ccp.c
++++ b/pppd/ccp.c
+@@ -62,12 +62,10 @@ static int setdeflate __P((char **));
+ static char bsd_value[8];
+ static char deflate_value[8];
+
+-/*
+- * Option variables.
+- */
+ #ifdef MPPE
+-bool refuse_mppe_stateful = 1; /* Allow stateful mode? */
+-#endif
++static int setmppe(char **);
++static int setnomppe(void);
++#endif /* MPPE */
+
+ static option_t ccp_option_list[] = {
+ { "noccp", o_bool, &ccp_protent.enabled_flag,
+@@ -108,54 +106,36 @@ static option_t ccp_option_list[] = {
+ "don't allow Predictor-1", OPT_ALIAS | OPT_PRIOSUB | OPT_A2CLR,
+ &ccp_allowoptions[0].predictor_1 },
+
++ { "lzs", o_bool, &ccp_wantoptions[0].lzs,
++ "request Stac LZS", 1, &ccp_allowoptions[0].lzs, OPT_PRIO },
++ { "+lzs", o_bool, &ccp_wantoptions[0].lzs,
++ "request Stac LZS", 1, &ccp_allowoptions[0].lzs, OPT_ALIAS | OPT_PRIO },
++ { "nolzs", o_bool, &ccp_wantoptions[0].lzs,
++ "don't allow Stac LZS", OPT_PRIOSUB | OPT_A2CLR,
++ &ccp_allowoptions[0].lzs },
++ { "-lzs", o_bool, &ccp_wantoptions[0].lzs,
++ "don't allow Stac LZS", OPT_ALIAS | OPT_PRIOSUB | OPT_A2CLR,
++ &ccp_allowoptions[0].lzs },
++
+ #ifdef MPPE
+- /* MPPE options are symmetrical ... we only set wantoptions here */
+- { "require-mppe", o_bool, &ccp_wantoptions[0].mppe,
+- "require MPPE encryption",
+- OPT_PRIO | MPPE_OPT_40 | MPPE_OPT_128 },
+- { "+mppe", o_bool, &ccp_wantoptions[0].mppe,
+- "require MPPE encryption",
+- OPT_ALIAS | OPT_PRIO | MPPE_OPT_40 | MPPE_OPT_128 },
+- { "nomppe", o_bool, &ccp_wantoptions[0].mppe,
+- "don't allow MPPE encryption", OPT_PRIO },
+- { "-mppe", o_bool, &ccp_wantoptions[0].mppe,
+- "don't allow MPPE encryption", OPT_ALIAS | OPT_PRIO },
+-
+- /* We use ccp_allowoptions[0].mppe as a junk var ... it is reset later */
+- { "require-mppe-40", o_bool, &ccp_allowoptions[0].mppe,
+- "require MPPE 40-bit encryption", OPT_PRIO | OPT_A2OR | MPPE_OPT_40,
+- &ccp_wantoptions[0].mppe },
+- { "+mppe-40", o_bool, &ccp_allowoptions[0].mppe,
+- "require MPPE 40-bit encryption", OPT_PRIO | OPT_A2OR | MPPE_OPT_40,
+- &ccp_wantoptions[0].mppe },
+- { "nomppe-40", o_bool, &ccp_allowoptions[0].mppe,
+- "don't allow MPPE 40-bit encryption",
+- OPT_PRIOSUB | OPT_A2CLRB | MPPE_OPT_40, &ccp_wantoptions[0].mppe },
+- { "-mppe-40", o_bool, &ccp_allowoptions[0].mppe,
+- "don't allow MPPE 40-bit encryption",
+- OPT_ALIAS | OPT_PRIOSUB | OPT_A2CLRB | MPPE_OPT_40,
+- &ccp_wantoptions[0].mppe },
+-
+- { "require-mppe-128", o_bool, &ccp_allowoptions[0].mppe,
+- "require MPPE 128-bit encryption", OPT_PRIO | OPT_A2OR | MPPE_OPT_128,
+- &ccp_wantoptions[0].mppe },
+- { "+mppe-128", o_bool, &ccp_allowoptions[0].mppe,
+- "require MPPE 128-bit encryption",
+- OPT_ALIAS | OPT_PRIO | OPT_A2OR | MPPE_OPT_128,
+- &ccp_wantoptions[0].mppe },
+- { "nomppe-128", o_bool, &ccp_allowoptions[0].mppe,
+- "don't allow MPPE 128-bit encryption",
+- OPT_PRIOSUB | OPT_A2CLRB | MPPE_OPT_128, &ccp_wantoptions[0].mppe },
+- { "-mppe-128", o_bool, &ccp_allowoptions[0].mppe,
+- "don't allow MPPE 128-bit encryption",
+- OPT_ALIAS | OPT_PRIOSUB | OPT_A2CLRB | MPPE_OPT_128,
+- &ccp_wantoptions[0].mppe },
+-
+- /* strange one; we always request stateless, but will we allow stateful? */
+- { "mppe-stateful", o_bool, &refuse_mppe_stateful,
+- "allow MPPE stateful mode", OPT_PRIO },
+- { "nomppe-stateful", o_bool, &refuse_mppe_stateful,
+- "disallow MPPE stateful mode", OPT_PRIO | 1 },
++ { "mppc", o_bool, &ccp_wantoptions[0].mppc,
++ "request MPPC compression", 1, &ccp_allowoptions[0].mppc },
++ { "+mppc", o_bool, &ccp_wantoptions[0].mppc,
++ "request MPPC compression", 1, &ccp_allowoptions[0].mppc, OPT_ALIAS },
++ { "nomppc", o_bool, &ccp_wantoptions[0].mppc,
++ "don't allow MPPC compression", OPT_PRIOSUB | OPT_A2CLR,
++ &ccp_allowoptions[0].mppc },
++ { "-mppc", o_bool, &ccp_wantoptions[0].mppc,
++ "don't allow MPPC compression", OPT_ALIAS | OPT_PRIOSUB | OPT_A2CLR,
++ &ccp_allowoptions[0].mppc },
++ { "mppe", o_special, (void *)setmppe,
++ "request MPPE encryption" },
++ { "+mppe", o_special, (void *)setmppe,
++ "request MPPE encryption" },
++ { "nomppe", o_special_noarg, (void *)setnomppe,
++ "don't allow MPPE encryption" },
++ { "-mppe", o_special_noarg, (void *)setnomppe,
++ "don't allow MPPE encryption" },
+ #endif /* MPPE */
+
+ { NULL }
+@@ -241,7 +221,7 @@ static fsm_callbacks ccp_callbacks = {
+ */
+ #define ANY_COMPRESS(opt) ((opt).deflate || (opt).bsd_compress \
+ || (opt).predictor_1 || (opt).predictor_2 \
+- || (opt).mppe)
++ || (opt).lzs || (opt).mppc || (opt).mppe)
+
+ /*
+ * Local state (mainly for handling reset-reqs and reset-acks).
+@@ -344,6 +324,100 @@ setdeflate(argv)
+ return 1;
+ }
+
++#ifdef MPPE
++/*
++ * Functions called from config options
++ */
++/*
++ MPPE suboptions:
++ required - require MPPE; disconnect if peer doesn't support it
++ stateless - use stateless mode
++ no40 - disable 40 bit keys
++ no56 - disable 56 bit keys
++ no128 - disable 128 bit keys
++*/
++int setmppe(char **argv)
++{
++ int i;
++ char *str, cmdbuf[16];
++
++ ccp_allowoptions[0].mppe = 1;
++ ccp_allowoptions[0].mppe_40 = 1;
++ ccp_allowoptions[0].mppe_56 = 1;
++ ccp_allowoptions[0].mppe_128 = 1;
++ ccp_allowoptions[0].mppe_stateless = 0;
++ ccp_wantoptions[0].mppe = 0;
++
++ str = *argv;
++
++ while (1) {
++ i = 0;
++ memset(cmdbuf, '\0', 16);
++ while ((i < 16) && (*str != ',') && (*str != '\0'))
++ cmdbuf[i++] = *str++;
++ cmdbuf[i] = '\0';
++ if (!strncasecmp(cmdbuf, "no40", strlen("no40"))) {
++ ccp_allowoptions[0].mppe_40 = 0;
++ goto next_param;
++ } else if (!strncasecmp(cmdbuf, "no56", strlen("no56"))) {
++ ccp_allowoptions[0].mppe_56 = 0;
++ goto next_param;
++ } else if (!strncasecmp(cmdbuf, "no128", strlen("no128"))) {
++ ccp_allowoptions[0].mppe_128 = 0;
++ goto next_param;
++ } else if (!strncasecmp(cmdbuf, "stateless", strlen("stateless"))) {
++ ccp_allowoptions[0].mppe_stateless = 1;
++ goto next_param;
++ } else if (!strncasecmp(cmdbuf, "required", strlen("required"))) {
++ ccp_wantoptions[0].mppe = 1;
++ goto next_param;
++ } else {
++ option_error("invalid parameter '%s' for mppe option", cmdbuf);
++ return 0;
++ }
++
++ next_param:
++ if (*str == ',') {
++ str++;
++ continue;
++ }
++ if (*str == '\0') {
++ if (!(ccp_allowoptions[0].mppe_40 || ccp_allowoptions[0].mppe_56 ||
++ ccp_allowoptions[0].mppe_128)) {
++ if (ccp_wantoptions[0].mppe == 1) {
++ option_error("You require MPPE but you have switched off "
++ "all encryption key lengths.");
++ return 0;
++ }
++ ccp_wantoptions[0].mppe = ccp_allowoptions[0].mppe = 0;
++ ccp_wantoptions[0].mppe_stateless =
++ ccp_allowoptions[0].mppe_stateless = 0;
++ } else {
++ ccp_allowoptions[0].mppe = 1;
++ ccp_wantoptions[0].mppe_stateless =
++ ccp_allowoptions[0].mppe_stateless;
++ if (ccp_wantoptions[0].mppe == 1) {
++ ccp_wantoptions[0].mppe_40 = ccp_allowoptions[0].mppe_40;
++ ccp_wantoptions[0].mppe_56 = ccp_allowoptions[0].mppe_56;
++ ccp_wantoptions[0].mppe_128 = ccp_allowoptions[0].mppe_128;
++ }
++ }
++ return 1;
++ }
++ }
++}
++
++int setnomppe(void)
++{
++ ccp_wantoptions[0].mppe = ccp_allowoptions[0].mppe = 0;
++ ccp_wantoptions[0].mppe_40 = ccp_allowoptions[0].mppe_40 = 0;
++ ccp_wantoptions[0].mppe_56 = ccp_allowoptions[0].mppe_56 = 0;
++ ccp_wantoptions[0].mppe_128 = ccp_allowoptions[0].mppe_128 = 0;
++ ccp_wantoptions[0].mppe_stateless = ccp_allowoptions[0].mppe_stateless = 0;
++ return 1;
++}
++#endif /* MPPE */
++
+ /*
+ * ccp_init - initialize CCP.
+ */
+@@ -378,6 +452,30 @@ ccp_init(unit)
+ ccp_allowoptions[0].bsd_bits = BSD_MAX_BITS;
+
+ ccp_allowoptions[0].predictor_1 = 1;
++
++ ccp_wantoptions[0].lzs = 0; /* Stac LZS - will be enabled in the future */
++ ccp_wantoptions[0].lzs_mode = LZS_MODE_SEQ;
++ ccp_wantoptions[0].lzs_hists = 1;
++ ccp_allowoptions[0].lzs = 0; /* Stac LZS - will be enabled in the future */
++ ccp_allowoptions[0].lzs_mode = LZS_MODE_SEQ;
++ ccp_allowoptions[0].lzs_hists = 1;
++
++#ifdef MPPE
++ /* by default allow and request MPPC... */
++ ccp_wantoptions[0].mppc = ccp_allowoptions[0].mppc = 1;
++
++ /* ... and allow but don't request MPPE */
++ ccp_allowoptions[0].mppe = 1;
++ ccp_allowoptions[0].mppe_40 = 1;
++ ccp_allowoptions[0].mppe_56 = 1;
++ ccp_allowoptions[0].mppe_128 = 1;
++ ccp_allowoptions[0].mppe_stateless = 1;
++ ccp_wantoptions[0].mppe = 0;
++ ccp_wantoptions[0].mppe_40 = 0;
++ ccp_wantoptions[0].mppe_56 = 0;
++ ccp_wantoptions[0].mppe_128 = 0;
++ ccp_wantoptions[0].mppe_stateless = 0;
++#endif /* MPPE */
+ }
+
+ /*
+@@ -455,11 +553,11 @@ ccp_input(unit, p, len)
+ if (oldstate == OPENED && p[0] == TERMREQ && f->state != OPENED) {
+ notice("Compression disabled by peer.");
+ #ifdef MPPE
+- if (ccp_gotoptions[unit].mppe) {
++ if (ccp_wantoptions[unit].mppe) {
+ error("MPPE disabled, closing LCP");
+ lcp_close(unit, "MPPE disabled by peer");
+ }
+-#endif
++#endif /* MPPE */
+ }
+
+ /*
+@@ -487,6 +585,15 @@ ccp_extcode(f, code, id, p, len)
+ break;
+ /* send a reset-ack, which the transmitter will see and
+ reset its compression state. */
++
++ /* In case of MPPE/MPPC or LZS we shouldn't send CCP_RESETACK,
++ but we do it in order to reset compressor; CCP_RESETACK is
++ then silently discarded. See functions ppp_send_frame and
++ ppp_ccp_peek in ppp_generic.c (Linux only !!!). All the
++ confusion is caused by the fact that CCP code is splited
++ into two parts - one part is handled by pppd, the other one
++ is handled by kernel. */
++
+ fsm_sdata(f, CCP_RESETACK, id, NULL, 0);
+ break;
+
+@@ -515,12 +622,11 @@ ccp_protrej(unit)
+ fsm_lowerdown(&ccp_fsm[unit]);
+
+ #ifdef MPPE
+- if (ccp_gotoptions[unit].mppe) {
++ if (ccp_wantoptions[unit].mppe) {
+ error("MPPE required but peer negotiation failed");
+ lcp_close(unit, "MPPE required but peer negotiation failed");
+ }
+-#endif
+-
++#endif /* MPPE */
+ }
+
+ /*
+@@ -537,7 +643,7 @@ ccp_resetci(f)
+ all_rejected[f->unit] = 0;
+
+ #ifdef MPPE
+- if (go->mppe) {
++ if (go->mppe || go->mppc) {
+ ccp_options *ao = &ccp_allowoptions[f->unit];
+ int auth_mschap_bits = auth_done[f->unit];
+ int numbits;
+@@ -551,80 +657,109 @@ ccp_resetci(f)
+ * NB: If MPPE is required, all other compression opts are invalid.
+ * So, we return right away if we can't do it.
+ */
++ if (ccp_wantoptions[f->unit].mppe) {
++ /* Leave only the mschap auth bits set */
++ auth_mschap_bits &= (CHAP_MS_WITHPEER | CHAP_MS_PEER |
++ CHAP_MS2_WITHPEER | CHAP_MS2_PEER);
++ /* Count the mschap auths */
++ auth_mschap_bits >>= CHAP_MS_SHIFT;
++ numbits = 0;
++ do {
++ numbits += auth_mschap_bits & 1;
++ auth_mschap_bits >>= 1;
++ } while (auth_mschap_bits);
++ if (numbits > 1) {
++ error("MPPE required, but auth done in both directions.");
++ lcp_close(f->unit, "MPPE required but not available");
++ return;
++ }
++ if (!numbits) {
++ error("MPPE required, but MS-CHAP[v2] auth not performed.");
++ lcp_close(f->unit, "MPPE required but not available");
++ return;
++ }
+
+- /* Leave only the mschap auth bits set */
+- auth_mschap_bits &= (CHAP_MS_WITHPEER | CHAP_MS_PEER |
+- CHAP_MS2_WITHPEER | CHAP_MS2_PEER);
+- /* Count the mschap auths */
+- auth_mschap_bits >>= CHAP_MS_SHIFT;
+- numbits = 0;
+- do {
+- numbits += auth_mschap_bits & 1;
+- auth_mschap_bits >>= 1;
+- } while (auth_mschap_bits);
+- if (numbits > 1) {
+- error("MPPE required, but auth done in both directions.");
+- lcp_close(f->unit, "MPPE required but not available");
+- return;
+- }
+- if (!numbits) {
+- error("MPPE required, but MS-CHAP[v2] auth not performed.");
+- lcp_close(f->unit, "MPPE required but not available");
+- return;
+- }
+-
+- /* A plugin (eg radius) may not have obtained key material. */
+- if (!mppe_keys_set) {
+- error("MPPE required, but keys are not available. "
+- "Possible plugin problem?");
+- lcp_close(f->unit, "MPPE required but not available");
+- return;
+- }
+-
+- /* LM auth not supported for MPPE */
+- if (auth_done[f->unit] & (CHAP_MS_WITHPEER | CHAP_MS_PEER)) {
+- /* This might be noise */
+- if (go->mppe & MPPE_OPT_40) {
+- notice("Disabling 40-bit MPPE; MS-CHAP LM not supported");
+- go->mppe &= ~MPPE_OPT_40;
+- ccp_wantoptions[f->unit].mppe &= ~MPPE_OPT_40;
++ /* A plugin (eg radius) may not have obtained key material. */
++ if (!mppe_keys_set) {
++ error("MPPE required, but keys are not available. "
++ "Possible plugin problem?");
++ lcp_close(f->unit, "MPPE required but not available");
++ return;
+ }
+ }
+
+- /* Last check: can we actually negotiate something? */
+- if (!(go->mppe & (MPPE_OPT_40 | MPPE_OPT_128))) {
+- /* Could be misconfig, could be 40-bit disabled above. */
+- error("MPPE required, but both 40-bit and 128-bit disabled.");
+- lcp_close(f->unit, "MPPE required but not available");
+- return;
++ /*
++ * Check whether the kernel knows about the various
++ * compression methods we might request. Key material
++ * unimportant here.
++ */
++ if (go->mppc) {
++ opt_buf[0] = CI_MPPE;
++ opt_buf[1] = CILEN_MPPE;
++ opt_buf[2] = 0;
++ opt_buf[3] = 0;
++ opt_buf[4] = 0;
++ opt_buf[5] = MPPE_MPPC;
++ if (ccp_test(f->unit, opt_buf, CILEN_MPPE, 0) <= 0)
++ go->mppc = 0;
++ }
++ if (go->mppe_40) {
++ opt_buf[0] = CI_MPPE;
++ opt_buf[1] = CILEN_MPPE;
++ opt_buf[2] = MPPE_STATELESS;
++ opt_buf[3] = 0;
++ opt_buf[4] = 0;
++ opt_buf[5] = MPPE_40BIT;
++ if (ccp_test(f->unit, opt_buf, CILEN_MPPE + MPPE_MAX_KEY_LEN, 0) <= 0)
++ go->mppe_40 = 0;
++ }
++ if (go->mppe_56) {
++ opt_buf[0] = CI_MPPE;
++ opt_buf[1] = CILEN_MPPE;
++ opt_buf[2] = MPPE_STATELESS;
++ opt_buf[3] = 0;
++ opt_buf[4] = 0;
++ opt_buf[5] = MPPE_56BIT;
++ if (ccp_test(f->unit, opt_buf, CILEN_MPPE + MPPE_MAX_KEY_LEN, 0) <= 0)
++ go->mppe_56 = 0;
++ }
++ if (go->mppe_128) {
++ opt_buf[0] = CI_MPPE;
++ opt_buf[1] = CILEN_MPPE;
++ opt_buf[2] = MPPE_STATELESS;
++ opt_buf[3] = 0;
++ opt_buf[4] = 0;
++ opt_buf[5] = MPPE_128BIT;
++ if (ccp_test(f->unit, opt_buf, CILEN_MPPE + MPPE_MAX_KEY_LEN, 0) <= 0)
++ go->mppe_128 = 0;
++ }
++ if (!go->mppe_40 && !go->mppe_56 && !go->mppe_128) {
++ if (ccp_wantoptions[f->unit].mppe) {
++ error("MPPE required, but kernel has no support.");
++ lcp_close(f->unit, "MPPE required but not available");
++ }
++ go->mppe = go->mppe_stateless = 0;
++ } else {
++ /* MPPE is not compatible with other compression types */
++ if (ccp_wantoptions[f->unit].mppe) {
++ ao->bsd_compress = go->bsd_compress = 0;
++ ao->predictor_1 = go->predictor_1 = 0;
++ ao->predictor_2 = go->predictor_2 = 0;
++ ao->deflate = go->deflate = 0;
++ ao->lzs = go->lzs = 0;
++ }
+ }
+-
+- /* sync options */
+- ao->mppe = go->mppe;
+- /* MPPE is not compatible with other compression types */
+- ao->bsd_compress = go->bsd_compress = 0;
+- ao->predictor_1 = go->predictor_1 = 0;
+- ao->predictor_2 = go->predictor_2 = 0;
+- ao->deflate = go->deflate = 0;
+ }
+ #endif /* MPPE */
+-
+- /*
+- * Check whether the kernel knows about the various
+- * compression methods we might request.
+- */
+-#ifdef MPPE
+- if (go->mppe) {
+- opt_buf[0] = CI_MPPE;
+- opt_buf[1] = CILEN_MPPE;
+- MPPE_OPTS_TO_CI(go->mppe, &opt_buf[2]);
+- /* Key material unimportant here. */
+- if (ccp_test(f->unit, opt_buf, CILEN_MPPE + MPPE_MAX_KEY_LEN, 0) <= 0) {
+- error("MPPE required, but kernel has no support.");
+- lcp_close(f->unit, "MPPE required but not available");
+- }
++ if (go->lzs) {
++ opt_buf[0] = CI_LZS;
++ opt_buf[1] = CILEN_LZS;
++ opt_buf[2] = go->lzs_hists >> 8;
++ opt_buf[3] = go->lzs_hists & 0xff;
++ opt_buf[4] = LZS_MODE_SEQ;
++ if (ccp_test(f->unit, opt_buf, CILEN_LZS, 0) <= 0)
++ go->lzs = 0;
+ }
+-#endif
+ if (go->bsd_compress) {
+ opt_buf[0] = CI_BSD_COMPRESS;
+ opt_buf[1] = CILEN_BSD_COMPRESS;
+@@ -679,7 +814,8 @@ ccp_cilen(f)
+ + (go->deflate? CILEN_DEFLATE: 0)
+ + (go->predictor_1? CILEN_PREDICTOR_1: 0)
+ + (go->predictor_2? CILEN_PREDICTOR_2: 0)
+- + (go->mppe? CILEN_MPPE: 0);
++ + (go->lzs? CILEN_LZS: 0)
++ + ((go->mppe || go->mppc)? CILEN_MPPE: 0);
+ }
+
+ /*
+@@ -693,6 +829,8 @@ ccp_addci(f, p, lenp)
+ {
+ int res;
+ ccp_options *go = &ccp_gotoptions[f->unit];
++ ccp_options *ao = &ccp_allowoptions[f->unit];
++ ccp_options *wo = &ccp_wantoptions[f->unit];
+ u_char *p0 = p;
+
+ /*
+@@ -701,22 +839,43 @@ ccp_addci(f, p, lenp)
+ * in case it gets Acked.
+ */
+ #ifdef MPPE
+- if (go->mppe) {
++ if (go->mppe || go->mppc || (!wo->mppe && ao->mppe)) {
+ u_char opt_buf[CILEN_MPPE + MPPE_MAX_KEY_LEN];
+
+- p[0] = opt_buf[0] = CI_MPPE;
+- p[1] = opt_buf[1] = CILEN_MPPE;
+- MPPE_OPTS_TO_CI(go->mppe, &p[2]);
+- MPPE_OPTS_TO_CI(go->mppe, &opt_buf[2]);
++ p[0] = CI_MPPE;
++ p[1] = CILEN_MPPE;
++ p[2] = (go->mppe_stateless ? MPPE_STATELESS : 0);
++ p[3] = 0;
++ p[4] = 0;
++ p[5] = (go->mppe_40 ? MPPE_40BIT : 0) | (go->mppe_56 ? MPPE_56BIT : 0) |
++ (go->mppe_128 ? MPPE_128BIT : 0) | (go->mppc ? MPPE_MPPC : 0);
++
++ BCOPY(p, opt_buf, CILEN_MPPE);
+ BCOPY(mppe_recv_key, &opt_buf[CILEN_MPPE], MPPE_MAX_KEY_LEN);
+ res = ccp_test(f->unit, opt_buf, CILEN_MPPE + MPPE_MAX_KEY_LEN, 0);
+- if (res > 0)
++ if (res > 0) {
+ p += CILEN_MPPE;
+- else
++ } else {
+ /* This shouldn't happen, we've already tested it! */
+- lcp_close(f->unit, "MPPE required but not available in kernel");
++ go->mppe = go->mppe_40 = go->mppe_56 = go->mppe_128 =
++ go->mppe_stateless = go->mppc = 0;
++ if (ccp_wantoptions[f->unit].mppe)
++ lcp_close(f->unit, "MPPE required but not available in kernel");
++ }
++ }
++#endif /* MPPE */
++ if (go->lzs) {
++ p[0] = CI_LZS;
++ p[1] = CILEN_LZS;
++ p[2] = go->lzs_hists >> 8;
++ p[3] = go->lzs_hists & 0xff;
++ p[4] = LZS_MODE_SEQ;
++ res = ccp_test(f->unit, p, CILEN_LZS, 0);
++ if (res > 0) {
++ p += CILEN_LZS;
++ } else
++ go->lzs = 0;
+ }
+-#endif
+ if (go->deflate) {
+ p[0] = go->deflate_correct? CI_DEFLATE: CI_DEFLATE_DRAFT;
+ p[1] = CILEN_DEFLATE;
+@@ -802,7 +961,7 @@ ccp_addci(f, p, lenp)
+
+ /*
+ * ccp_ackci - process a received configure-ack, and return
+- * 1 iff the packet was OK.
++ * 1 if the packet was OK.
+ */
+ static int
+ ccp_ackci(f, p, len)
+@@ -811,24 +970,44 @@ ccp_ackci(f, p, len)
+ int len;
+ {
+ ccp_options *go = &ccp_gotoptions[f->unit];
++ ccp_options *ao = &ccp_allowoptions[f->unit];
++ ccp_options *wo = &ccp_wantoptions[f->unit];
+ u_char *p0 = p;
+
+ #ifdef MPPE
+- if (go->mppe) {
+- u_char opt_buf[CILEN_MPPE];
+-
+- opt_buf[0] = CI_MPPE;
+- opt_buf[1] = CILEN_MPPE;
+- MPPE_OPTS_TO_CI(go->mppe, &opt_buf[2]);
+- if (len < CILEN_MPPE || memcmp(opt_buf, p, CILEN_MPPE))
++ if (go->mppe || go->mppc || (!wo->mppe && ao->mppe)) {
++ if (len < CILEN_MPPE
++ || p[1] != CILEN_MPPE || p[0] != CI_MPPE
++ || p[2] != (go->mppe_stateless ? MPPE_STATELESS : 0)
++ || p[3] != 0
++ || p[4] != 0
++ || (p[5] != ((go->mppe_40 ? MPPE_40BIT : 0) |
++ (go->mppc ? MPPE_MPPC : 0))
++ && p[5] != ((go->mppe_56 ? MPPE_56BIT : 0) |
++ (go->mppc ? MPPE_MPPC : 0))
++ && p[5] != ((go->mppe_128 ? MPPE_128BIT : 0) |
++ (go->mppc ? MPPE_MPPC : 0))))
+ return 0;
++ if (go->mppe_40 || go->mppe_56 || go->mppe_128)
++ go->mppe = 1;
+ p += CILEN_MPPE;
+ len -= CILEN_MPPE;
++ /* Cope with first/fast ack */
++ if (p == p0 && len == 0)
++ return 1;
++ }
++#endif /* MPPE */
++ if (go->lzs) {
++ if (len < CILEN_LZS || p[0] != CI_LZS || p[1] != CILEN_LZS
++ || p[2] != go->lzs_hists>>8 || p[3] != (go->lzs_hists&0xff)
++ || p[4] != LZS_MODE_SEQ)
++ return 0;
++ p += CILEN_LZS;
++ len -= CILEN_LZS;
+ /* XXX Cope with first/fast ack */
+- if (len == 0)
++ if (p == p0 && len == 0)
+ return 1;
+ }
+-#endif
+ if (go->deflate) {
+ if (len < CILEN_DEFLATE
+ || p[0] != (go->deflate_correct? CI_DEFLATE: CI_DEFLATE_DRAFT)
+@@ -901,6 +1080,8 @@ ccp_nakci(f, p, len, treat_as_reject)
+ int treat_as_reject;
+ {
+ ccp_options *go = &ccp_gotoptions[f->unit];
++ ccp_options *ao = &ccp_allowoptions[f->unit];
++ ccp_options *wo = &ccp_wantoptions[f->unit];
+ ccp_options no; /* options we've seen already */
+ ccp_options try; /* options to ask for next time */
+
+@@ -908,28 +1089,100 @@ ccp_nakci(f, p, len, treat_as_reject)
+ try = *go;
+
+ #ifdef MPPE
+- if (go->mppe && len >= CILEN_MPPE
+- && p[0] == CI_MPPE && p[1] == CILEN_MPPE) {
+- no.mppe = 1;
+- /*
+- * Peer wants us to use a different strength or other setting.
+- * Fail if we aren't willing to use his suggestion.
+- */
+- MPPE_CI_TO_OPTS(&p[2], try.mppe);
+- if ((try.mppe & MPPE_OPT_STATEFUL) && refuse_mppe_stateful) {
+- error("Refusing MPPE stateful mode offered by peer");
+- try.mppe = 0;
+- } else if (((go->mppe | MPPE_OPT_STATEFUL) & try.mppe) != try.mppe) {
+- /* Peer must have set options we didn't request (suggest) */
+- try.mppe = 0;
+- }
++ if ((go->mppe || go->mppc || (!wo->mppe && ao->mppe)) &&
++ len >= CILEN_MPPE && p[0] == CI_MPPE && p[1] == CILEN_MPPE) {
+
+- if (!try.mppe) {
+- error("MPPE required but peer negotiation failed");
+- lcp_close(f->unit, "MPPE required but peer negotiation failed");
++ if (go->mppc) {
++ no.mppc = 1;
++ if (!(p[5] & MPPE_MPPC))
++ try.mppc = 0;
++ }
++
++ if (go->mppe)
++ no.mppe = 1;
++ if (go->mppe_40)
++ no.mppe_40 = 1;
++ if (go->mppe_56)
++ no.mppe_56 = 1;
++ if (go->mppe_128)
++ no.mppe_128 = 1;
++ if (go->mppe_stateless)
++ no.mppe_stateless = 1;
++
++ if (ao->mppe_40) {
++ if ((p[5] & MPPE_40BIT))
++ try.mppe_40 = 1;
++ else
++ try.mppe_40 = (p[5] == 0) ? 1 : 0;
++ }
++ if (ao->mppe_56) {
++ if ((p[5] & MPPE_56BIT))
++ try.mppe_56 = 1;
++ else
++ try.mppe_56 = (p[5] == 0) ? 1 : 0;
++ }
++ if (ao->mppe_128) {
++ if ((p[5] & MPPE_128BIT))
++ try.mppe_128 = 1;
++ else
++ try.mppe_128 = (p[5] == 0) ? 1 : 0;
++ }
++
++ if (ao->mppe_stateless) {
++ if ((p[2] & MPPE_STATELESS) || wo->mppe_stateless)
++ try.mppe_stateless = 1;
++ else
++ try.mppe_stateless = 0;
++ }
++
++ if (!try.mppe_56 && !try.mppe_40 && !try.mppe_128) {
++ try.mppe = try.mppe_stateless = 0;
++ if (wo->mppe) {
++ /* we require encryption, but peer doesn't support it
++ so we close connection */
++ wo->mppc = wo->mppe = wo->mppe_stateless = wo->mppe_40 =
++ wo->mppe_56 = wo->mppe_128 = 0;
++ lcp_close(f->unit, "MPPE required but cannot negotiate MPPE "
++ "key length");
++ }
++ }
++ if (wo->mppe && (wo->mppe_40 != try.mppe_40) &&
++ (wo->mppe_56 != try.mppe_56) && (wo->mppe_128 != try.mppe_128)) {
++ /* cannot negotiate key length */
++ wo->mppc = wo->mppe = wo->mppe_stateless = wo->mppe_40 =
++ wo->mppe_56 = wo->mppe_128 = 0;
++ lcp_close(f->unit, "Cannot negotiate MPPE key length");
+ }
++ if (try.mppe_40 && try.mppe_56 && try.mppe_128)
++ try.mppe_40 = try.mppe_56 = 0;
++ else
++ if (try.mppe_56 && try.mppe_128)
++ try.mppe_56 = 0;
++ else
++ if (try.mppe_40 && try.mppe_128)
++ try.mppe_40 = 0;
++ else
++ if (try.mppe_40 && try.mppe_56)
++ try.mppe_40 = 0;
++
++ p += CILEN_MPPE;
++ len -= CILEN_MPPE;
+ }
+ #endif /* MPPE */
++
++ if (go->lzs && len >= CILEN_LZS && p[0] == CI_LZS && p[1] == CILEN_LZS) {
++ no.lzs = 1;
++ if (((p[2]<<8)|p[3]) > 1 || (p[4] != LZS_MODE_SEQ &&
++ p[4] != LZS_MODE_EXT))
++ try.lzs = 0;
++ else {
++ try.lzs_mode = p[4];
++ try.lzs_hists = (p[2] << 8) | p[3];
++ }
++ p += CILEN_LZS;
++ len -= CILEN_LZS;
++ }
++
+ if (go->deflate && len >= CILEN_DEFLATE
+ && p[0] == (go->deflate_correct? CI_DEFLATE: CI_DEFLATE_DRAFT)
+ && p[1] == CILEN_DEFLATE) {
+@@ -1002,14 +1255,50 @@ ccp_rejci(f, p, len)
+ return -1;
+
+ #ifdef MPPE
+- if (go->mppe && len >= CILEN_MPPE
++ if ((go->mppe || go->mppc) && len >= CILEN_MPPE
+ && p[0] == CI_MPPE && p[1] == CILEN_MPPE) {
+- error("MPPE required but peer refused");
+- lcp_close(f->unit, "MPPE required but peer refused");
++ ccp_options *wo = &ccp_wantoptions[f->unit];
++ if (p[2] != (go->mppe_stateless ? MPPE_STATELESS : 0) ||
++ p[3] != 0 ||
++ p[4] != 0 ||
++ p[5] != ((go->mppe_40 ? MPPE_40BIT : 0) |
++ (go->mppe_56 ? MPPE_56BIT : 0) |
++ (go->mppe_128 ? MPPE_128BIT : 0) |
++ (go->mppc ? MPPE_MPPC : 0)))
++ return 0;
++ if (go->mppc)
++ try.mppc = 0;
++ if (go->mppe) {
++ try.mppe = 0;
++ if (go->mppe_40)
++ try.mppe_40 = 0;
++ if (go->mppe_56)
++ try.mppe_56 = 0;
++ if (go->mppe_128)
++ try.mppe_128 = 0;
++ if (go->mppe_stateless)
++ try.mppe_stateless = 0;
++ if (!try.mppe_56 && !try.mppe_40 && !try.mppe_128)
++ try.mppe = try.mppe_stateless = 0;
++ if (wo->mppe) { /* we want MPPE but cannot negotiate key length */
++ wo->mppc = wo->mppe = wo->mppe_stateless = wo->mppe_40 =
++ wo->mppe_56 = wo->mppe_128 = 0;
++ lcp_close(f->unit, "MPPE required but cannot negotiate MPPE "
++ "key length");
++ }
++ }
+ p += CILEN_MPPE;
+ len -= CILEN_MPPE;
+ }
+-#endif
++#endif /* MPPE */
++ if (go->lzs && len >= CILEN_LZS && p[0] == CI_LZS && p[1] == CILEN_LZS) {
++ if (p[2] != go->lzs_hists>>8 || p[3] != (go->lzs_hists&0xff)
++ || p[4] != go->lzs_mode)
++ return 0;
++ try.lzs = 0;
++ p += CILEN_LZS;
++ len -= CILEN_LZS;
++ }
+ if (go->deflate_correct && len >= CILEN_DEFLATE
+ && p[0] == CI_DEFLATE && p[1] == CILEN_DEFLATE) {
+ if (p[2] != DEFLATE_MAKE_OPT(go->deflate_size)
+@@ -1073,14 +1362,15 @@ ccp_reqci(f, p, lenp, dont_nak)
+ int dont_nak;
+ {
+ int ret, newret, res;
+- u_char *p0, *retp;
++ u_char *p0, *retp, p2, p5;
+ int len, clen, type, nb;
+ ccp_options *ho = &ccp_hisoptions[f->unit];
+ ccp_options *ao = &ccp_allowoptions[f->unit];
++ ccp_options *wo = &ccp_wantoptions[f->unit];
+ #ifdef MPPE
+- bool rej_for_ci_mppe = 1; /* Are we rejecting based on a bad/missing */
+- /* CI_MPPE, or due to other options? */
+-#endif
++ u_char opt_buf[CILEN_MPPE + MPPE_MAX_KEY_LEN];
++/* int mtu; */
++#endif /* MPPE */
+
+ ret = CONFACK;
+ retp = p0 = p;
+@@ -1103,106 +1393,302 @@ ccp_reqci(f, p, lenp, dont_nak)
+ switch (type) {
+ #ifdef MPPE
+ case CI_MPPE:
+- if (!ao->mppe || clen != CILEN_MPPE) {
++ if ((!ao->mppc && !ao->mppe) || clen != CILEN_MPPE) {
+ newret = CONFREJ;
+ break;
+ }
+- MPPE_CI_TO_OPTS(&p[2], ho->mppe);
+-
+- /* Nak if anything unsupported or unknown are set. */
+- if (ho->mppe & MPPE_OPT_UNSUPPORTED) {
+- newret = CONFNAK;
+- ho->mppe &= ~MPPE_OPT_UNSUPPORTED;
+- }
+- if (ho->mppe & MPPE_OPT_UNKNOWN) {
++ p2 = p[2];
++ p5 = p[5];
++ /* not sure what they want, tell 'em what we got */
++ if (((p[2] & ~MPPE_STATELESS) != 0 || p[3] != 0 || p[4] != 0 ||
++ (p[5] & ~(MPPE_40BIT | MPPE_56BIT | MPPE_128BIT |
++ MPPE_MPPC)) != 0 || p[5] == 0) ||
++ (p[2] == 0 && p[3] == 0 && p[4] == 0 && p[5] == 0)) {
+ newret = CONFNAK;
+- ho->mppe &= ~MPPE_OPT_UNKNOWN;
+- }
+-
+- /* Check state opt */
+- if (ho->mppe & MPPE_OPT_STATEFUL) {
+- /*
+- * We can Nak and request stateless, but it's a
+- * lot easier to just assume the peer will request
+- * it if he can do it; stateful mode is bad over
+- * the Internet -- which is where we expect MPPE.
+- */
+- if (refuse_mppe_stateful) {
+- error("Refusing MPPE stateful mode offered by peer");
+- newret = CONFREJ;
+- break;
++ p[2] = (wo->mppe_stateless ? MPPE_STATELESS : 0);
++ p[3] = 0;
++ p[4] = 0;
++ p[5] = (wo->mppe_40 ? MPPE_40BIT : 0) |
++ (wo->mppe_56 ? MPPE_56BIT : 0) |
++ (wo->mppe_128 ? MPPE_128BIT : 0) |
++ (wo->mppc ? MPPE_MPPC : 0);
++ break;
++ }
++
++ if ((p[5] & MPPE_MPPC)) {
++ if (ao->mppc) {
++ ho->mppc = 1;
++ BCOPY(p, opt_buf, CILEN_MPPE);
++ opt_buf[2] = opt_buf[3] = opt_buf[4] = 0;
++ opt_buf[5] = MPPE_MPPC;
++ if (ccp_test(f->unit, opt_buf, CILEN_MPPE, 1) <= 0) {
++ ho->mppc = 0;
++ p[5] &= ~MPPE_MPPC;
++ newret = CONFNAK;
++ }
++ } else {
++ newret = CONFREJ;
++ if (wo->mppe || ao->mppe) {
++ p[5] &= ~MPPE_MPPC;
++ newret = CONFNAK;
++ }
+ }
+ }
+-
+- /* Find out which of {S,L} are set. */
+- if ((ho->mppe & MPPE_OPT_128)
+- && (ho->mppe & MPPE_OPT_40)) {
+- /* Both are set, negotiate the strongest. */
+- newret = CONFNAK;
+- if (ao->mppe & MPPE_OPT_128)
+- ho->mppe &= ~MPPE_OPT_40;
+- else if (ao->mppe & MPPE_OPT_40)
+- ho->mppe &= ~MPPE_OPT_128;
+- else {
+- newret = CONFREJ;
+- break;
+- }
+- } else if (ho->mppe & MPPE_OPT_128) {
+- if (!(ao->mppe & MPPE_OPT_128)) {
+- newret = CONFREJ;
+- break;
+- }
+- } else if (ho->mppe & MPPE_OPT_40) {
+- if (!(ao->mppe & MPPE_OPT_40)) {
+- newret = CONFREJ;
+- break;
+- }
++ if (ao->mppe)
++ ho->mppe = 1;
++
++ if ((p[2] & MPPE_STATELESS)) {
++ if (ao->mppe_stateless) {
++ if (wo->mppe_stateless)
++ ho->mppe_stateless = 1;
++ else {
++ newret = CONFNAK;
++ if (!dont_nak)
++ p[2] &= ~MPPE_STATELESS;
++ }
++ } else {
++ newret = CONFNAK;
++ if (!dont_nak)
++ p[2] &= ~MPPE_STATELESS;
++ }
++ } else {
++ if (wo->mppe_stateless && !dont_nak) {
++ wo->mppe_stateless = 0;
++ newret = CONFNAK;
++ p[2] |= MPPE_STATELESS;
++ }
++ }
++
++ if ((p[5] & ~MPPE_MPPC) == (MPPE_40BIT|MPPE_56BIT|MPPE_128BIT)) {
++ newret = CONFNAK;
++ if (ao->mppe_128) {
++ ho->mppe_128 = 1;
++ p[5] &= ~(MPPE_40BIT|MPPE_56BIT);
++ BCOPY(p, opt_buf, CILEN_MPPE);
++ BCOPY(mppe_send_key, &opt_buf[CILEN_MPPE],
++ MPPE_MAX_KEY_LEN);
++ if (ccp_test(f->unit, opt_buf, CILEN_MPPE +
++ MPPE_MAX_KEY_LEN, 1) <= 0) {
++ ho->mppe_128 = 0;
++ p[5] |= (MPPE_40BIT|MPPE_56BIT);
++ p[5] &= ~MPPE_128BIT;
++ goto check_mppe_56_40;
++ }
++ goto check_mppe;
++ }
++ p[5] &= ~MPPE_128BIT;
++ goto check_mppe_56_40;
++ }
++ if ((p[5] & ~MPPE_MPPC) == (MPPE_56BIT|MPPE_128BIT)) {
++ newret = CONFNAK;
++ if (ao->mppe_128) {
++ ho->mppe_128 = 1;
++ p[5] &= ~MPPE_56BIT;
++ BCOPY(p, opt_buf, CILEN_MPPE);
++ BCOPY(mppe_send_key, &opt_buf[CILEN_MPPE],
++ MPPE_MAX_KEY_LEN);
++ if (ccp_test(f->unit, opt_buf, CILEN_MPPE +
++ MPPE_MAX_KEY_LEN, 1) <= 0) {
++ ho->mppe_128 = 0;
++ p[5] |= MPPE_56BIT;
++ p[5] &= ~MPPE_128BIT;
++ goto check_mppe_56;
++ }
++ goto check_mppe;
++ }
++ p[5] &= ~MPPE_128BIT;
++ goto check_mppe_56;
++ }
++ if ((p[5] & ~MPPE_MPPC) == (MPPE_40BIT|MPPE_128BIT)) {
++ newret = CONFNAK;
++ if (ao->mppe_128) {
++ ho->mppe_128 = 1;
++ p[5] &= ~MPPE_40BIT;
++ BCOPY(p, opt_buf, CILEN_MPPE);
++ BCOPY(mppe_send_key, &opt_buf[CILEN_MPPE],
++ MPPE_MAX_KEY_LEN);
++ if (ccp_test(f->unit, opt_buf, CILEN_MPPE +
++ MPPE_MAX_KEY_LEN, 1) <= 0) {
++ ho->mppe_128 = 0;
++ p[5] |= MPPE_40BIT;
++ p[5] &= ~MPPE_128BIT;
++ goto check_mppe_40;
++ }
++ goto check_mppe;
++ }
++ p[5] &= ~MPPE_128BIT;
++ goto check_mppe_40;
++ }
++ if ((p[5] & ~MPPE_MPPC) == MPPE_128BIT) {
++ if (ao->mppe_128) {
++ ho->mppe_128 = 1;
++ BCOPY(p, opt_buf, CILEN_MPPE);
++ BCOPY(mppe_send_key, &opt_buf[CILEN_MPPE],
++ MPPE_MAX_KEY_LEN);
++ if (ccp_test(f->unit, opt_buf, CILEN_MPPE +
++ MPPE_MAX_KEY_LEN, 1) <= 0) {
++ ho->mppe_128 = 0;
++ p[5] &= ~MPPE_128BIT;
++ newret = CONFNAK;
++ }
++ goto check_mppe;
++ }
++ p[5] &= ~MPPE_128BIT;
++ newret = CONFNAK;
++ goto check_mppe;
++ }
++ check_mppe_56_40:
++ if ((p[5] & ~MPPE_MPPC) == (MPPE_40BIT|MPPE_56BIT)) {
++ newret = CONFNAK;
++ if (ao->mppe_56) {
++ ho->mppe_56 = 1;
++ p[5] &= ~MPPE_40BIT;
++ BCOPY(p, opt_buf, CILEN_MPPE);
++ BCOPY(mppe_send_key, &opt_buf[CILEN_MPPE],
++ MPPE_MAX_KEY_LEN);
++ if (ccp_test(f->unit, opt_buf, CILEN_MPPE +
++ MPPE_MAX_KEY_LEN, 1) <= 0) {
++ ho->mppe_56 = 0;
++ p[5] |= MPPE_40BIT;
++ p[5] &= ~MPPE_56BIT;
++ newret = CONFNAK;
++ goto check_mppe_40;
++ }
++ goto check_mppe;
++ }
++ p[5] &= ~MPPE_56BIT;
++ goto check_mppe_40;
++ }
++ check_mppe_56:
++ if ((p[5] & ~MPPE_MPPC) == MPPE_56BIT) {
++ if (ao->mppe_56) {
++ ho->mppe_56 = 1;
++ BCOPY(p, opt_buf, CILEN_MPPE);
++ BCOPY(mppe_send_key, &opt_buf[CILEN_MPPE],
++ MPPE_MAX_KEY_LEN);
++ if (ccp_test(f->unit, opt_buf, CILEN_MPPE +
++ MPPE_MAX_KEY_LEN, 1) <= 0) {
++ ho->mppe_56 = 0;
++ p[5] &= ~MPPE_56BIT;
++ newret = CONFNAK;
++ }
++ goto check_mppe;
++ }
++ p[5] &= ~MPPE_56BIT;
++ newret = CONFNAK;
++ goto check_mppe;
++ }
++ check_mppe_40:
++ if ((p[5] & ~MPPE_MPPC) == MPPE_40BIT) {
++ if (ao->mppe_40) {
++ ho->mppe_40 = 1;
++ BCOPY(p, opt_buf, CILEN_MPPE);
++ BCOPY(mppe_send_key, &opt_buf[CILEN_MPPE],
++ MPPE_MAX_KEY_LEN);
++ if (ccp_test(f->unit, opt_buf, CILEN_MPPE +
++ MPPE_MAX_KEY_LEN, 1) <= 0) {
++ ho->mppe_40 = 0;
++ p[5] &= ~MPPE_40BIT;
++ newret = CONFNAK;
++ }
++ goto check_mppe;
++ }
++ p[5] &= ~MPPE_40BIT;
++ }
++
++ check_mppe:
++ if (!ho->mppe_40 && !ho->mppe_56 && !ho->mppe_128) {
++ if (wo->mppe_40 || wo->mppe_56 || wo->mppe_128) {
++ newret = CONFNAK;
++ p[2] |= (wo->mppe_stateless ? MPPE_STATELESS : 0);
++ p[5] |= (wo->mppe_40 ? MPPE_40BIT : 0) |
++ (wo->mppe_56 ? MPPE_56BIT : 0) |
++ (wo->mppe_128 ? MPPE_128BIT : 0) |
++ (wo->mppc ? MPPE_MPPC : 0);
++ } else {
++ ho->mppe = ho->mppe_stateless = 0;
++ }
+ } else {
+- /* Neither are set. */
+- /* We cannot accept this. */
+- newret = CONFNAK;
+- /* Give the peer our idea of what can be used,
+- so it can choose and confirm */
+- ho->mppe = ao->mppe;
+- }
+-
+- /* rebuild the opts */
+- MPPE_OPTS_TO_CI(ho->mppe, &p[2]);
+- if (newret == CONFACK) {
+- u_char opt_buf[CILEN_MPPE + MPPE_MAX_KEY_LEN];
+- int mtu;
+-
+- BCOPY(p, opt_buf, CILEN_MPPE);
+- BCOPY(mppe_send_key, &opt_buf[CILEN_MPPE],
+- MPPE_MAX_KEY_LEN);
+- if (ccp_test(f->unit, opt_buf,
+- CILEN_MPPE + MPPE_MAX_KEY_LEN, 1) <= 0) {
+- /* This shouldn't happen, we've already tested it! */
+- error("MPPE required, but kernel has no support.");
+- lcp_close(f->unit, "MPPE required but not available");
+- newret = CONFREJ;
+- break;
+- }
+- /*
+- * We need to decrease the interface MTU by MPPE_PAD
+- * because MPPE frames **grow**. The kernel [must]
+- * allocate MPPE_PAD extra bytes in xmit buffers.
+- */
+- mtu = netif_get_mtu(f->unit);
+- if (mtu)
+- netif_set_mtu(f->unit, mtu - MPPE_PAD);
+- else
+- newret = CONFREJ;
+- }
+-
+- /*
+- * We have accepted MPPE or are willing to negotiate
+- * MPPE parameters. A CONFREJ is due to subsequent
+- * (non-MPPE) processing.
+- */
+- rej_for_ci_mppe = 0;
+- break;
+-#endif /* MPPE */
++ /* MPPE is not compatible with other compression types */
++ if (wo->mppe) {
++ ao->bsd_compress = 0;
++ ao->predictor_1 = 0;
++ ao->predictor_2 = 0;
++ ao->deflate = 0;
++ ao->lzs = 0;
++ }
++ }
++ if ((!ho->mppc || !ao->mppc) && !ho->mppe) {
++ p[2] = p2;
++ p[5] = p5;
++ newret = CONFREJ;
++ break;
++ }
++
++ /*
++ * I have commented the code below because according to RFC1547
++ * MTU is only information for higher level protocols about
++ * "the maximum allowable length for a packet (q.v.) transmitted
++ * over a point-to-point link without incurring network layer
++ * fragmentation." Of course a PPP implementation should be able
++ * to handle overhead added by MPPE - in our case apropriate code
++ * is located in drivers/net/ppp_generic.c in the kernel sources.
++ *
++ * According to RFC1661:
++ * - when negotiated MRU is less than 1500 octets, a PPP
++ * implementation must still be able to receive at least 1500
++ * octets,
++ * - when PFC is negotiated, a PPP implementation is still
++ * required to receive frames with uncompressed protocol field.
++ *
++ * So why not to handle MPPE overhead without changing MTU value?
++ * I am sure that RFC3078, unfortunately silently, assumes that.
++ */
++
++ /*
++ * We need to decrease the interface MTU by MPPE_PAD
++ * because MPPE frames **grow**. The kernel [must]
++ * allocate MPPE_PAD extra bytes in xmit buffers.
++ */
++ /*
++ mtu = netif_get_mtu(f->unit);
++ if (mtu) {
++ netif_set_mtu(f->unit, mtu - MPPE_PAD);
++ } else {
++ newret = CONFREJ;
++ if (ccp_wantoptions[f->unit].mppe) {
++ error("Cannot adjust MTU needed by MPPE.");
++ lcp_close(f->unit, "Cannot adjust MTU needed by MPPE.");
++ }
++ }
++ */
++ break;
++ #endif /* MPPE */
++
++ case CI_LZS:
++ if (!ao->lzs || clen != CILEN_LZS) {
++ newret = CONFREJ;
++ break;
++ }
++
++ ho->lzs = 1;
++ ho->lzs_hists = (p[2] << 8) | p[3];
++ ho->lzs_mode = p[4];
++ if ((ho->lzs_hists != ao->lzs_hists) ||
++ (ho->lzs_mode != ao->lzs_mode)) {
++ newret = CONFNAK;
++ if (!dont_nak) {
++ p[2] = ao->lzs_hists >> 8;
++ p[3] = ao->lzs_hists & 0xff;
++ p[4] = ao->lzs_mode;
++ } else
++ break;
++ }
++
++ if (p == p0 && ccp_test(f->unit, p, CILEN_LZS, 1) <= 0) {
++ newret = CONFREJ;
++ }
++ break;
+ case CI_DEFLATE:
+ case CI_DEFLATE_DRAFT:
+ if (!ao->deflate || clen != CILEN_DEFLATE
+@@ -1344,12 +1830,6 @@ ccp_reqci(f, p, lenp, dont_nak)
+ else
+ *lenp = retp - p0;
+ }
+-#ifdef MPPE
+- if (ret == CONFREJ && ao->mppe && rej_for_ci_mppe) {
+- error("MPPE required but peer negotiation failed");
+- lcp_close(f->unit, "MPPE required but peer negotiation failed");
+- }
+-#endif
+ return ret;
+ }
+
+@@ -1371,24 +1851,35 @@ method_name(opt, opt2)
+ char *p = result;
+ char *q = result + sizeof(result); /* 1 past result */
+
+- slprintf(p, q - p, "MPPE ");
+- p += 5;
+- if (opt->mppe & MPPE_OPT_128) {
+- slprintf(p, q - p, "128-bit ");
+- p += 8;
+- }
+- if (opt->mppe & MPPE_OPT_40) {
+- slprintf(p, q - p, "40-bit ");
+- p += 7;
+- }
+- if (opt->mppe & MPPE_OPT_STATEFUL)
+- slprintf(p, q - p, "stateful");
+- else
+- slprintf(p, q - p, "stateless");
+-
++ if (opt->mppe) {
++ if (opt->mppc) {
++ slprintf(p, q - p, "MPPC/MPPE ");
++ p += 10;
++ } else {
++ slprintf(p, q - p, "MPPE ");
++ p += 5;
++ }
++ if (opt->mppe_128) {
++ slprintf(p, q - p, "128-bit ");
++ p += 8;
++ } else if (opt->mppe_56) {
++ slprintf(p, q - p, "56-bit ");
++ p += 7;
++ } else if (opt->mppe_40) {
++ slprintf(p, q - p, "40-bit ");
++ p += 7;
++ }
++ if (opt->mppe_stateless)
++ slprintf(p, q - p, "stateless");
++ else
++ slprintf(p, q - p, "stateful");
++ } else if (opt->mppc)
++ slprintf(p, q - p, "MPPC");
+ break;
+ }
+-#endif
++#endif /* MPPE */
++ case CI_LZS:
++ return "Stac LZS";
+ case CI_DEFLATE:
+ case CI_DEFLATE_DRAFT:
+ if (opt2 != NULL && opt2->deflate_size != opt->deflate_size)
+@@ -1444,12 +1935,12 @@ ccp_up(f)
+ } else if (ANY_COMPRESS(*ho))
+ notice("%s transmit compression enabled", method_name(ho, NULL));
+ #ifdef MPPE
+- if (go->mppe) {
++ if (go->mppe || go->mppc) {
+ BZERO(mppe_recv_key, MPPE_MAX_KEY_LEN);
+ BZERO(mppe_send_key, MPPE_MAX_KEY_LEN);
+ continue_networks(f->unit); /* Bring up IP et al */
+ }
+-#endif
++#endif /* MPPE */
+ }
+
+ /*
+@@ -1472,7 +1963,7 @@ ccp_down(f)
+ lcp_close(f->unit, "MPPE disabled");
+ }
+ }
+-#endif
++#endif /* MPPE */
+ }
+
+ /*
+@@ -1532,24 +2023,28 @@ ccp_printpkt(p, plen, printer, arg)
+ #ifdef MPPE
+ case CI_MPPE:
+ if (optlen >= CILEN_MPPE) {
+- u_char mppe_opts;
+-
+- MPPE_CI_TO_OPTS(&p[2], mppe_opts);
+- printer(arg, "mppe %s %s %s %s %s %s%s",
+- (p[2] & MPPE_H_BIT)? "+H": "-H",
+- (p[5] & MPPE_M_BIT)? "+M": "-M",
+- (p[5] & MPPE_S_BIT)? "+S": "-S",
+- (p[5] & MPPE_L_BIT)? "+L": "-L",
++ printer(arg, "mppe %s %s %s %s %s %s",
++ (p[2] & MPPE_STATELESS)? "+H": "-H",
++ (p[5] & MPPE_56BIT)? "+M": "-M",
++ (p[5] & MPPE_128BIT)? "+S": "-S",
++ (p[5] & MPPE_40BIT)? "+L": "-L",
+ (p[5] & MPPE_D_BIT)? "+D": "-D",
+- (p[5] & MPPE_C_BIT)? "+C": "-C",
+- (mppe_opts & MPPE_OPT_UNKNOWN)? " +U": "");
+- if (mppe_opts & MPPE_OPT_UNKNOWN)
++ (p[5] & MPPE_MPPC)? "+C": "-C");
++ if ((p[5] & ~(MPPE_56BIT | MPPE_128BIT | MPPE_40BIT |
++ MPPE_D_BIT | MPPE_MPPC)) ||
++ (p[2] & ~MPPE_STATELESS))
+ printer(arg, " (%.2x %.2x %.2x %.2x)",
+ p[2], p[3], p[4], p[5]);
+ p += CILEN_MPPE;
+ }
+ break;
+-#endif
++#endif /* MPPE */
++ case CI_LZS:
++ if (optlen >= CILEN_LZS) {
++ printer(arg, "lzs %.2x %.2x %.2x", p[2], p[3], p[4]);
++ p += CILEN_LZS;
++ }
++ break;
+ case CI_DEFLATE:
+ case CI_DEFLATE_DRAFT:
+ if (optlen >= CILEN_DEFLATE) {
+@@ -1635,6 +2130,7 @@ ccp_datainput(unit, pkt, len)
+ error("Lost compression sync: disabling compression");
+ ccp_close(unit, "Lost compression sync");
+ #ifdef MPPE
++ /* My module dosn't need this. J.D., 2003-07-06 */
+ /*
+ * If we were doing MPPE, we must also take the link down.
+ */
+@@ -1642,9 +2138,18 @@ ccp_datainput(unit, pkt, len)
+ error("Too many MPPE errors, closing LCP");
+ lcp_close(unit, "Too many MPPE errors");
+ }
+-#endif
++#endif /* MPPE */
+ } else {
+ /*
++ * When LZS or MPPE/MPPC is negotiated we just send CCP_RESETREQ
++ * and don't wait for CCP_RESETACK
++ */
++ if ((ccp_gotoptions[f->unit].method == CI_LZS) ||
++ (ccp_gotoptions[f->unit].method == CI_MPPE)) {
++ fsm_sdata(f, CCP_RESETREQ, f->reqid = ++f->id, NULL, 0);
++ return;
++ }
++ /*
+ * Send a reset-request to reset the peer's compressor.
+ * We don't do that if we are still waiting for an
+ * acknowledgement to a previous reset-request.
+--- a/pppd/ccp.h
++++ b/pppd/ccp.h
+@@ -37,9 +37,17 @@ typedef struct ccp_options {
+ bool predictor_2; /* do Predictor-2? */
+ bool deflate_correct; /* use correct code for deflate? */
+ bool deflate_draft; /* use draft RFC code for deflate? */
++ bool lzs; /* do Stac LZS? */
++ bool mppc; /* do MPPC? */
+ bool mppe; /* do MPPE? */
++ bool mppe_40; /* allow 40 bit encryption? */
++ bool mppe_56; /* allow 56 bit encryption? */
++ bool mppe_128; /* allow 128 bit encryption? */
++ bool mppe_stateless; /* allow stateless encryption */
+ u_short bsd_bits; /* # bits/code for BSD Compress */
+ u_short deflate_size; /* lg(window size) for Deflate */
++ u_short lzs_mode; /* LZS check mode */
++ u_short lzs_hists; /* number of LZS histories */
+ short method; /* code for chosen compression method */
+ } ccp_options;
+
+--- a/pppd/chap_ms.c
++++ b/pppd/chap_ms.c
+@@ -898,13 +898,17 @@ set_mppe_enc_types(int policy, int types
+ /*
+ * Disable undesirable encryption types. Note that we don't ENABLE
+ * any encryption types, to avoid overriding manual configuration.
++ *
++ * It seems that 56 bit keys are unsupported in MS-RADIUS (see RFC 2548)
+ */
+ switch(types) {
+ case MPPE_ENC_TYPES_RC4_40:
+- ccp_wantoptions[0].mppe &= ~MPPE_OPT_128; /* disable 128-bit */
++ ccp_wantoptions[0].mppe_128 = 0; /* disable 128-bit */
++ ccp_wantoptions[0].mppe_56 = 0; /* disable 56-bit */
+ break;
+ case MPPE_ENC_TYPES_RC4_128:
+- ccp_wantoptions[0].mppe &= ~MPPE_OPT_40; /* disable 40-bit */
++ ccp_wantoptions[0].mppe_56 = 0; /* disable 56-bit */
++ ccp_wantoptions[0].mppe_40 = 0; /* disable 40-bit */
+ break;
+ default:
+ break;
diff --git a/package/network/services/ppp/patches/.svn/text-base/202-no_strip.patch.svn-base b/package/network/services/ppp/patches/.svn/text-base/202-no_strip.patch.svn-base
new file mode 100644
index 0000000..87c76ad
--- /dev/null
+++ b/package/network/services/ppp/patches/.svn/text-base/202-no_strip.patch.svn-base
@@ -0,0 +1,88 @@
+build: Do not strip binaries on install
+
+Strippign executables should be handled by the distro packaging, not by ppp
+itself. This patch removes the "-s" (strip) switch from all "install" commands
+in order to install unstripped binaries into the destination prefix.
+
+Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
+
+--- a/chat/Makefile.linux
++++ b/chat/Makefile.linux
+@@ -25,7 +25,7 @@ chat.o: chat.c
+
+ install: chat
+ mkdir -p $(BINDIR) $(MANDIR)
+- $(INSTALL) -s -c chat $(BINDIR)
++ $(INSTALL) -c chat $(BINDIR)
+ $(INSTALL) -c -m 644 chat.8 $(MANDIR)
+
+ clean:
+--- a/pppd/Makefile.linux
++++ b/pppd/Makefile.linux
+@@ -99,7 +99,7 @@ ifdef USE_SRP
+ CFLAGS += -DUSE_SRP -DOPENSSL -I/usr/local/ssl/include
+ LIBS += -lsrp -L/usr/local/ssl/lib -lcrypto
+ TARGETS += srp-entry
+-EXTRAINSTALL = $(INSTALL) -s -c -m 555 srp-entry $(BINDIR)/srp-entry
++EXTRAINSTALL = $(INSTALL) -c -m 555 srp-entry $(BINDIR)/srp-entry
+ MANPAGES += srp-entry.8
+ EXTRACLEAN += srp-entry.o
+ NEEDDES=y
+@@ -200,7 +200,7 @@ all: $(TARGETS)
+ install: pppd
+ mkdir -p $(BINDIR) $(MANDIR)
+ $(EXTRAINSTALL)
+- $(INSTALL) -s -c -m 555 pppd $(BINDIR)/pppd
++ $(INSTALL) -c -m 555 pppd $(BINDIR)/pppd
+ if chgrp pppusers $(BINDIR)/pppd 2>/dev/null; then \
+ chmod o-rx,u+s $(BINDIR)/pppd; fi
+ $(INSTALL) -c -m 444 pppd.8 $(MANDIR)
+--- a/pppd/plugins/radius/Makefile.linux
++++ b/pppd/plugins/radius/Makefile.linux
+@@ -36,9 +36,9 @@ all: $(PLUGIN)
+
+ install: all
+ $(INSTALL) -d -m 755 $(LIBDIR)
+- $(INSTALL) -s -c -m 755 radius.so $(LIBDIR)
+- $(INSTALL) -s -c -m 755 radattr.so $(LIBDIR)
+- $(INSTALL) -s -c -m 755 radrealms.so $(LIBDIR)
++ $(INSTALL) -c -m 755 radius.so $(LIBDIR)
++ $(INSTALL) -c -m 755 radattr.so $(LIBDIR)
++ $(INSTALL) -c -m 755 radrealms.so $(LIBDIR)
+ $(INSTALL) -c -m 444 pppd-radius.8 $(MANDIR)
+ $(INSTALL) -c -m 444 pppd-radattr.8 $(MANDIR)
+
+--- a/pppd/plugins/rp-pppoe/Makefile.linux
++++ b/pppd/plugins/rp-pppoe/Makefile.linux
+@@ -43,9 +43,9 @@ rp-pppoe.so: plugin.o discovery.o if.o c
+
+ install: all
+ $(INSTALL) -d -m 755 $(LIBDIR)
+- $(INSTALL) -s -c -m 4550 rp-pppoe.so $(LIBDIR)
++ $(INSTALL) -c -m 4550 rp-pppoe.so $(LIBDIR)
+ $(INSTALL) -d -m 755 $(BINDIR)
+- $(INSTALL) -s -c -m 555 pppoe-discovery $(BINDIR)
++ $(INSTALL) -c -m 555 pppoe-discovery $(BINDIR)
+
+ clean:
+ rm -f *.o *.so pppoe-discovery
+--- a/pppdump/Makefile.linux
++++ b/pppdump/Makefile.linux
+@@ -17,5 +17,5 @@ clean:
+
+ install:
+ mkdir -p $(BINDIR) $(MANDIR)
+- $(INSTALL) -s -c pppdump $(BINDIR)
++ $(INSTALL) -c pppdump $(BINDIR)
+ $(INSTALL) -c -m 444 pppdump.8 $(MANDIR)
+--- a/pppstats/Makefile.linux
++++ b/pppstats/Makefile.linux
+@@ -22,7 +22,7 @@ all: pppstats
+
+ install: pppstats
+ -mkdir -p $(MANDIR)
+- $(INSTALL) -s -c pppstats $(BINDIR)
++ $(INSTALL) -c pppstats $(BINDIR)
+ $(INSTALL) -c -m 444 pppstats.8 $(MANDIR)
+
+ pppstats: $(PPPSTATSRCS)
diff --git a/package/network/services/ppp/patches/.svn/text-base/203-opt_flags.patch.svn-base b/package/network/services/ppp/patches/.svn/text-base/203-opt_flags.patch.svn-base
new file mode 100644
index 0000000..a369163
--- /dev/null
+++ b/package/network/services/ppp/patches/.svn/text-base/203-opt_flags.patch.svn-base
@@ -0,0 +1,32 @@
+build: Move optimization flags into a separate variable
+
+Isolate optimization related compiler flags from CFLAGS and move them into a
+separate COPTS variable so that it is easier to override optimizations from
+the environment.
+
+Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
+
+--- a/pppd/plugins/radius/Makefile.linux
++++ b/pppd/plugins/radius/Makefile.linux
+@@ -12,7 +12,8 @@ VERSION = $(shell awk -F '"' '/VERSION/
+ INSTALL = install
+
+ PLUGIN=radius.so radattr.so radrealms.so
+-CFLAGS=-I. -I../.. -I../../../include -O2 -fPIC -DRC_LOG_FACILITY=LOG_DAEMON
++COPTS = -O2
++CFLAGS=-I. -I../.. -I../../../include $(COPTS) -fPIC -DRC_LOG_FACILITY=LOG_DAEMON
+
+ # Uncomment the next line to include support for Microsoft's
+ # MS-CHAP authentication protocol.
+--- a/pppdump/Makefile.linux
++++ b/pppdump/Makefile.linux
+@@ -2,7 +2,8 @@ DESTDIR = $(INSTROOT)@DESTDIR@
+ BINDIR = $(DESTDIR)/sbin
+ MANDIR = $(DESTDIR)/share/man/man8
+
+-CFLAGS= -O -I../include/net
++COPTS = -O
++CFLAGS= $(COPTS) -I../include/net
+ OBJS = pppdump.o bsd-comp.o deflate.o zlib.o
+
+ INSTALL= install
diff --git a/package/network/services/ppp/patches/.svn/text-base/204-radius_config.patch.svn-base b/package/network/services/ppp/patches/.svn/text-base/204-radius_config.patch.svn-base
new file mode 100644
index 0000000..c97a535
--- /dev/null
+++ b/package/network/services/ppp/patches/.svn/text-base/204-radius_config.patch.svn-base
@@ -0,0 +1,72 @@
+--- a/pppd/plugins/radius/config.c
++++ b/pppd/plugins/radius/config.c
+@@ -369,31 +369,37 @@ static int test_config(char *filename)
+ }
+ #endif
+
++#if 0
+ if (rc_conf_int("login_tries") <= 0)
+ {
+ error("%s: login_tries <= 0 is illegal", filename);
+ return (-1);
+ }
++#endif
+ if (rc_conf_str("seqfile") == NULL)
+ {
+ error("%s: seqfile not specified", filename);
+ return (-1);
+ }
++#if 0
+ if (rc_conf_int("login_timeout") <= 0)
+ {
+ error("%s: login_timeout <= 0 is illegal", filename);
+ return (-1);
+ }
++#endif
+ if (rc_conf_str("mapfile") == NULL)
+ {
+ error("%s: mapfile not specified", filename);
+ return (-1);
+ }
++#if 0
+ if (rc_conf_str("nologin") == NULL)
+ {
+ error("%s: nologin not specified", filename);
+ return (-1);
+ }
++#endif
+
+ return 0;
+ }
+--- a/pppd/plugins/radius/options.h
++++ b/pppd/plugins/radius/options.h
+@@ -31,24 +31,21 @@ typedef struct _option {
+ static SERVER acctserver = {0};
+ static SERVER authserver = {0};
+
+-int default_tries = 4;
+-int default_timeout = 60;
+-
+ static OPTION config_options[] = {
+ /* internally used options */
+ {"config_file", OT_STR, ST_UNDEF, NULL},
+ /* General options */
+ {"auth_order", OT_AUO, ST_UNDEF, NULL},
+-{"login_tries", OT_INT, ST_UNDEF, &default_tries},
+-{"login_timeout", OT_INT, ST_UNDEF, &default_timeout},
+-{"nologin", OT_STR, ST_UNDEF, "/etc/nologin"},
+-{"issue", OT_STR, ST_UNDEF, "/etc/radiusclient/issue"},
++{"login_tries", OT_INT, ST_UNDEF, NULL},
++{"login_timeout", OT_INT, ST_UNDEF, NULL},
++{"nologin", OT_STR, ST_UNDEF, NULL},
++{"issue", OT_STR, ST_UNDEF, NULL},
+ /* RADIUS specific options */
+ {"authserver", OT_SRV, ST_UNDEF, &authserver},
+ {"acctserver", OT_SRV, ST_UNDEF, &acctserver},
+ {"servers", OT_STR, ST_UNDEF, NULL},
+ {"dictionary", OT_STR, ST_UNDEF, NULL},
+-{"login_radius", OT_STR, ST_UNDEF, "/usr/sbin/login.radius"},
++{"login_radius", OT_STR, ST_UNDEF, NULL},
+ {"seqfile", OT_STR, ST_UNDEF, NULL},
+ {"mapfile", OT_STR, ST_UNDEF, NULL},
+ {"default_realm", OT_STR, ST_UNDEF, NULL},
diff --git a/package/network/services/ppp/patches/.svn/text-base/205-no_exponential_timeout.patch.svn-base b/package/network/services/ppp/patches/.svn/text-base/205-no_exponential_timeout.patch.svn-base
new file mode 100644
index 0000000..7119fb8
--- /dev/null
+++ b/package/network/services/ppp/patches/.svn/text-base/205-no_exponential_timeout.patch.svn-base
@@ -0,0 +1,29 @@
+pppd: Don't use exponential timeout in discovery phase
+
+This patch removes the exponential timeout increase between PADO or PADS
+discovery attempts.
+
+Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
+
+--- a/pppd/plugins/rp-pppoe/discovery.c
++++ b/pppd/plugins/rp-pppoe/discovery.c
+@@ -548,7 +548,9 @@ discovery(PPPoEConnection *conn)
+ conn->discoveryState = STATE_SENT_PADI;
+ waitForPADO(conn, timeout);
+
++#if 0
+ timeout *= 2;
++#endif
+ } while (conn->discoveryState == STATE_SENT_PADI);
+
+ timeout = conn->discoveryTimeout;
+@@ -563,7 +565,9 @@ discovery(PPPoEConnection *conn)
+ sendPADR(conn);
+ conn->discoveryState = STATE_SENT_PADR;
+ waitForPADS(conn, timeout);
++#if 0
+ timeout *= 2;
++#endif
+ } while (conn->discoveryState == STATE_SENT_PADR);
+
+ /* We're done. */
diff --git a/package/network/services/ppp/patches/.svn/text-base/206-compensate_time_change.patch.svn-base b/package/network/services/ppp/patches/.svn/text-base/206-compensate_time_change.patch.svn-base
new file mode 100644
index 0000000..fb6c656
--- /dev/null
+++ b/package/network/services/ppp/patches/.svn/text-base/206-compensate_time_change.patch.svn-base
@@ -0,0 +1,94 @@
+pppd: Watch out for time warps
+
+On many embedded systems there is no battery backed RTC and a proper system
+time only becomes available through NTP after establishing a connection.
+
+When the clock suddenly jumps forward, the internal accounting (connect time)
+is confused resulting in unreliable data.
+
+This patch implements periodic clock checking to look for time warps, if one
+is detected, the internal counters are adjusted accordingly.
+
+Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
+
+--- a/pppd/main.c
++++ b/pppd/main.c
+@@ -90,6 +90,7 @@
+ #include <sys/socket.h>
+ #include <netinet/in.h>
+ #include <arpa/inet.h>
++#include <sys/sysinfo.h>
+
+ #include "pppd.h"
+ #include "magic.h"
+@@ -228,6 +229,7 @@ static struct subprocess *children;
+
+ /* Prototypes for procedures local to this file. */
+
++static void check_time(void);
+ static void setup_signals __P((void));
+ static void create_pidfile __P((int pid));
+ static void create_linkpidfile __P((int pid));
+@@ -535,6 +537,7 @@ main(argc, argv)
+ info("Starting link");
+ }
+
++ check_time();
+ gettimeofday(&start_time, NULL);
+ script_unsetenv("CONNECT_TIME");
+ script_unsetenv("BYTES_SENT");
+@@ -1267,6 +1270,36 @@ struct callout {
+
+ static struct callout *callout = NULL; /* Callout list */
+ static struct timeval timenow; /* Current time */
++static long uptime_diff = 0;
++static int uptime_diff_set = 0;
++
++static void check_time(void)
++{
++ long new_diff;
++ struct timeval t;
++ struct sysinfo i;
++ struct callout *p;
++
++ gettimeofday(&t, NULL);
++ sysinfo(&i);
++ new_diff = t.tv_sec - i.uptime;
++
++ if (!uptime_diff_set) {
++ uptime_diff = new_diff;
++ uptime_diff_set = 1;
++ return;
++ }
++
++ if ((new_diff - 5 > uptime_diff) || (new_diff + 5 < uptime_diff)) {
++ /* system time has changed, update counters and timeouts */
++ info("System time change detected.");
++ start_time.tv_sec += new_diff - uptime_diff;
++
++ for (p = callout; p != NULL; p = p->c_next)
++ p->c_time.tv_sec += new_diff - uptime_diff;
++ }
++ uptime_diff = new_diff;
++}
+
+ /*
+ * timeout - Schedule a timeout.
+@@ -1337,6 +1370,8 @@ calltimeout()
+ {
+ struct callout *p;
+
++ check_time();
++
+ while (callout != NULL) {
+ p = callout;
+
+@@ -1364,6 +1399,8 @@ timeleft(tvp)
+ {
+ if (callout == NULL)
+ return NULL;
++
++ check_time();
+
+ gettimeofday(&timenow, NULL);
+ tvp->tv_sec = callout->c_time.tv_sec - timenow.tv_sec;
diff --git a/package/network/services/ppp/patches/.svn/text-base/207-lcp_mtu_max.patch.svn-base b/package/network/services/ppp/patches/.svn/text-base/207-lcp_mtu_max.patch.svn-base
new file mode 100644
index 0000000..1ebcf41
--- /dev/null
+++ b/package/network/services/ppp/patches/.svn/text-base/207-lcp_mtu_max.patch.svn-base
@@ -0,0 +1,25 @@
+pppd: Cap MTU to the user configured value
+
+This patchs caps the calculated MTU value in lcp.c to the user specified "mru"
+option value. Without this patch pppd would advertise a different MTU value
+compared to what is set on the local interface in some cases.
+
+Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
+
+--- a/pppd/lcp.c
++++ b/pppd/lcp.c
+@@ -1904,12 +1904,12 @@ lcp_up(f)
+ * the interface MTU is set to the lowest of that, the
+ * MTU we want to use, and our link MRU.
+ */
+- mtu = ho->neg_mru? ho->mru: PPP_MRU;
++ mtu = MIN(ho->neg_mru? ho->mru: PPP_MRU, ao->mru);
+ mru = go->neg_mru? MAX(wo->mru, go->mru): PPP_MRU;
+ #ifdef HAVE_MULTILINK
+ if (!(multilink && go->neg_mrru && ho->neg_mrru))
+ #endif /* HAVE_MULTILINK */
+- netif_set_mtu(f->unit, MIN(MIN(mtu, mru), ao->mru));
++ netif_set_mtu(f->unit, MIN(mtu, mru));
+ ppp_send_config(f->unit, mtu,
+ (ho->neg_asyncmap? ho->asyncmap: 0xffffffff),
+ ho->neg_pcompression, ho->neg_accompression);
diff --git a/package/network/services/ppp/patches/.svn/text-base/208-fix_status_code.patch.svn-base b/package/network/services/ppp/patches/.svn/text-base/208-fix_status_code.patch.svn-base
new file mode 100644
index 0000000..25e2a10
--- /dev/null
+++ b/package/network/services/ppp/patches/.svn/text-base/208-fix_status_code.patch.svn-base
@@ -0,0 +1,24 @@
+pppd: Do not clobber exit codes on hangup
+
+When a modem hangup occurs, pppd unconditionally sets the exit status code
+to EXIT_HANGUP. This patch only sets EXIT_HANGUP if the exit status code is
+not already set to an error value.
+
+The motiviation of this patch is to allow applications which remote control
+pppd to react properly on errors, e.g. only redial (relaunch pppd) if there
+was a hangup, but not if the CHAP authentication failed.
+
+Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
+
+--- a/pppd/main.c
++++ b/pppd/main.c
+@@ -1048,7 +1048,8 @@ get_input()
+ }
+ notice("Modem hangup");
+ hungup = 1;
+- status = EXIT_HANGUP;
++ if (status == EXIT_OK)
++ status = EXIT_HANGUP;
+ lcp_lowerdown(0); /* serial link is no longer available */
+ link_terminated(0);
+ return;
diff --git a/package/network/services/ppp/patches/.svn/text-base/300-filter-pcap-includes-lib.patch.svn-base b/package/network/services/ppp/patches/.svn/text-base/300-filter-pcap-includes-lib.patch.svn-base
new file mode 100644
index 0000000..d8dcc64
--- /dev/null
+++ b/package/network/services/ppp/patches/.svn/text-base/300-filter-pcap-includes-lib.patch.svn-base
@@ -0,0 +1,20 @@
+build: Add required CFLAGS for libpcap
+
+This patch adds some flags to required to properly link libpcap within the
+OpenWrt environment.
+
+Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
+
+--- a/pppd/Makefile.linux
++++ b/pppd/Makefile.linux
+@@ -170,8 +170,8 @@ endif
+
+ ifdef FILTER
+ ifneq ($(wildcard /usr/include/pcap-bpf.h),)
+-LIBS += -lpcap
+-CFLAGS += -DPPP_FILTER
++LIBS += -lpcap -L$(STAGING_DIR)/usr/lib
++CFLAGS += -DPPP_FILTER -I$(STAGING_DIR)/usr/include
+ endif
+ endif
+
diff --git a/package/network/services/ppp/patches/.svn/text-base/310-precompile_filter.patch.svn-base b/package/network/services/ppp/patches/.svn/text-base/310-precompile_filter.patch.svn-base
new file mode 100644
index 0000000..87b9687
--- /dev/null
+++ b/package/network/services/ppp/patches/.svn/text-base/310-precompile_filter.patch.svn-base
@@ -0,0 +1,196 @@
+pppd: Implement support for precompiled pcap filters
+
+This patch implements support for precompiled pcap filters which is useful to
+support dial-on-demand on memory constrained embedded devices without having
+to link the full libpcap into pppd to generate the filters during runtime.
+
+Two new options are introduced; "precompiled-pass-filter" specifies a pre-
+compiled filter file containing rules to match packets which should be passed,
+"precompiled-active-filter" specifies a filter file containing rules to match
+packets which are treated as active.
+
+Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
+
+--- a/pppd/Makefile.linux
++++ b/pppd/Makefile.linux
+@@ -50,6 +50,9 @@ MPPE=y
+ # and that the kernel driver support PPP packet filtering.
+ #FILTER=y
+
++# Support for precompiled filters
++PRECOMPILED_FILTER=y
++
+ # Uncomment the next line to enable multilink PPP (enabled by default)
+ # Linux distributions: Please leave multilink ENABLED in your builds
+ # of pppd!
+@@ -175,6 +178,14 @@ CFLAGS += -DPPP_FILTER -I$(STAGING_DIR)
+ endif
+ endif
+
++ifdef PRECOMPILED_FILTER
++PPPDSRCS += pcap_pcc.c
++HEADERS += pcap_pcc.h
++PPPDOBJS += pcap_pcc.o
++LIBS += $(STAGING_DIR)/usr/lib/libpcap.a
++CFLAGS += -DPPP_FILTER -DPPP_PRECOMPILED_FILTER -I$(STAGING_DIR)/usr/include
++endif
++
+ ifdef HAVE_INET6
+ PPPDSRCS += ipv6cp.c eui64.c
+ HEADERS += ipv6cp.h eui64.h
+--- a/pppd/options.c
++++ b/pppd/options.c
+@@ -57,6 +57,7 @@
+
+ #ifdef PPP_FILTER
+ #include <pcap.h>
++#include <pcap-bpf.h>
+ /*
+ * There have been 3 or 4 different names for this in libpcap CVS, but
+ * this seems to be what they have settled on...
+@@ -162,6 +163,13 @@ static int setlogfile __P((char **));
+ static int loadplugin __P((char **));
+ #endif
+
++#ifdef PPP_PRECOMPILED_FILTER
++#include "pcap_pcc.h"
++static int setprecompiledpassfilter __P((char **));
++static int setprecompiledactivefilter __P((char **));
++#undef PPP_FILTER
++#endif
++
+ #ifdef PPP_FILTER
+ static int setpassfilter __P((char **));
+ static int setactivefilter __P((char **));
+@@ -326,6 +334,14 @@ option_t general_options[] = {
+ "set filter for active pkts", OPT_PRIO },
+ #endif
+
++#ifdef PPP_PRECOMPILED_FILTER
++ { "precompiled-pass-filter", 1, setprecompiledpassfilter,
++ "set precompiled filter for packets to pass", OPT_PRIO },
++
++ { "precompiled-active-filter", 1, setprecompiledactivefilter,
++ "set precompiled filter for active pkts", OPT_PRIO },
++#endif
++
+ #ifdef MAXOCTETS
+ { "maxoctets", o_int, &maxoctets,
+ "Set connection traffic limit",
+@@ -1472,6 +1488,29 @@ callfile(argv)
+ return ok;
+ }
+
++#ifdef PPP_PRECOMPILED_FILTER
++/*
++ * setprecompiledpassfilter - Set the pass filter for packets using a
++ * precompiled expression
++ */
++static int
++setprecompiledpassfilter(argv)
++ char **argv;
++{
++ return pcap_pre_compiled (*argv, &pass_filter);
++}
++
++/*
++ * setactivefilter - Set the active filter for packets
++ */
++static int
++setprecompiledactivefilter(argv)
++ char **argv;
++{
++ return pcap_pre_compiled (*argv, &active_filter);
++}
++#endif
++
+ #ifdef PPP_FILTER
+ /*
+ * setpassfilter - Set the pass filter for packets
+--- /dev/null
++++ b/pppd/pcap_pcc.c
+@@ -0,0 +1,74 @@
++#include <pcap.h>
++#include <pcap-bpf.h>
++#include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
++#include <errno.h>
++#include "pppd.h"
++
++int pcap_pre_compiled (char * fname, struct bpf_program *p)
++{
++ char buf[128];
++ int line = 0, size = 0, index=0, ret=1;
++ FILE *f = fopen (fname, "r");
++ if (!f)
++ {
++ option_error("error opening precompiled active-filter '%s': %s",
++ fname, strerror (errno));
++ return 0;
++ }
++ while (fgets (buf, 127, f))
++ {
++ line++;
++ if (*buf == '#')
++ continue;
++ if (size)
++ {
++ /*
++ struct bpf_insn {
++ u_short code;
++ u_char jt;
++ u_char jf;
++ bpf_int32 k;
++ }
++ */
++ struct bpf_insn * insn = & p->bf_insns[index];
++ unsigned code, jt, jf, k;
++ if (sscanf (buf, "%u %u %u %u", &code, &jt, &jf, &k) != 4)
++ {
++ goto err;
++ }
++ insn->code = code;
++ insn->jt = jt;
++ insn->jf = jf;
++ insn->k = k;
++ index++;
++ }
++ else
++ {
++ if (sscanf (buf, "%u", &size) != 1)
++ {
++ goto err;
++ }
++ p->bf_len = size;
++ p->bf_insns = (struct bpf_insn *)
++ malloc (size * sizeof (struct bpf_insn));
++ }
++ }
++ if (size != index)
++ {
++ option_error("error in precompiled active-filter,"
++ " expected %d expressions, got %dn",
++ size, index);
++ ret = 0;
++ }
++ fclose(f);
++ return ret;
++
++err:
++ option_error("error in precompiled active-filter"
++ " expression line %s:%d (wrong size)\n",
++ fname, line);
++ fclose (f);
++ return 0;
++}
+--- /dev/null
++++ b/pppd/pcap_pcc.h
+@@ -0,0 +1,7 @@
++#ifndef PCAP_PCC_H
++#define PCAP_PCC_H
++
++#include <pcap.h>
++
++int pcap_pre_compiled (char * fname, struct bpf_program *p);
++#endif /* PCAP_PCC_H */
diff --git a/package/network/services/ppp/patches/.svn/text-base/320-custom_iface_names.patch.svn-base b/package/network/services/ppp/patches/.svn/text-base/320-custom_iface_names.patch.svn-base
new file mode 100644
index 0000000..a95f4f8
--- /dev/null
+++ b/package/network/services/ppp/patches/.svn/text-base/320-custom_iface_names.patch.svn-base
@@ -0,0 +1,135 @@
+pppd: Support arbitrary interface names
+
+This patch implements a new string option "ifname" which allows to specify
+fully custom PPP interface names on Linux. It does so by renaming the
+allocated pppX device immediately after it has been created to the requested
+interface name.
+
+Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
+
+--- a/pppd/main.c
++++ b/pppd/main.c
+@@ -745,8 +745,11 @@ void
+ set_ifunit(iskey)
+ int iskey;
+ {
+- info("Using interface %s%d", PPP_DRV_NAME, ifunit);
+- slprintf(ifname, sizeof(ifname), "%s%d", PPP_DRV_NAME, ifunit);
++ if (use_ifname[0] == 0)
++ slprintf(ifname, sizeof(ifname), "%s%d", PPP_DRV_NAME, ifunit);
++ else
++ slprintf(ifname, sizeof(ifname), "%s", use_ifname);
++ info("Using interface %s", ifname);
+ script_setenv("IFNAME", ifname, iskey);
+ if (iskey) {
+ create_pidfile(getpid()); /* write pid to file */
+--- a/pppd/options.c
++++ b/pppd/options.c
+@@ -111,6 +111,7 @@ int log_to_fd = 1; /* send log messages
+ bool log_default = 1; /* log_to_fd is default (stdout) */
+ int maxfail = 10; /* max # of unsuccessful connection attempts */
+ char linkname[MAXPATHLEN]; /* logical name for link */
++char use_ifname[IFNAMSIZ]; /* physical name for PPP link */
+ bool tune_kernel; /* may alter kernel settings */
+ int connect_delay = 1000; /* wait this many ms after connect script */
+ int req_unit = -1; /* requested interface unit */
+@@ -266,6 +267,9 @@ option_t general_options[] = {
+ { "linkname", o_string, linkname,
+ "Set logical name for link",
+ OPT_PRIO | OPT_PRIV | OPT_STATIC, NULL, MAXPATHLEN },
++ { "ifname", o_string, use_ifname,
++ "Set physical name for PPP interface",
++ OPT_PRIO | OPT_PRIV | OPT_STATIC, NULL, IFNAMSIZ },
+
+ { "maxfail", o_int, &maxfail,
+ "Maximum number of unsuccessful connection attempts to allow",
+--- a/pppd/pppd.h
++++ b/pppd/pppd.h
+@@ -71,6 +71,10 @@
+ #include "eui64.h"
+ #endif
+
++#ifndef IFNAMSIZ
++#define IFNAMSIZ 16
++#endif
++
+ /*
+ * Limits.
+ */
+@@ -309,6 +313,7 @@ extern char *record_file; /* File to rec
+ extern bool sync_serial; /* Device is synchronous serial device */
+ extern int maxfail; /* Max # of unsuccessful connection attempts */
+ extern char linkname[MAXPATHLEN]; /* logical name for link */
++extern char use_ifname[IFNAMSIZ]; /* physical name for PPP interface */
+ extern bool tune_kernel; /* May alter kernel settings as necessary */
+ extern int connect_delay; /* Time to delay after connect script */
+ extern int max_data_rate; /* max bytes/sec through charshunt */
+--- a/pppd/sys-linux.c
++++ b/pppd/sys-linux.c
+@@ -168,6 +168,10 @@ struct in6_ifreq {
+ /* We can get an EIO error on an ioctl if the modem has hung up */
+ #define ok_error(num) ((num)==EIO)
+
++#if !defined(PPP_DRV_NAME)
++#define PPP_DRV_NAME "ppp"
++#endif /* !defined(PPP_DRV_NAME) */
++
+ static int tty_disc = N_TTY; /* The TTY discipline */
+ static int ppp_disc = N_PPP; /* The PPP discpline */
+ static int initfdflags = -1; /* Initial file descriptor flags for fd */
+@@ -622,7 +626,8 @@ void generic_disestablish_ppp(int dev_fd
+ */
+ static int make_ppp_unit()
+ {
+- int x, flags;
++ struct ifreq ifr;
++ int x, flags, s;
+
+ if (ppp_dev_fd >= 0) {
+ dbglog("in make_ppp_unit, already had /dev/ppp open?");
+@@ -645,6 +650,30 @@ static int make_ppp_unit()
+ }
+ if (x < 0)
+ error("Couldn't create new ppp unit: %m");
++
++ if (use_ifname[0] != 0) {
++ s = socket(PF_INET, SOCK_DGRAM, 0);
++ if (s < 0)
++ s = socket(PF_PACKET, SOCK_DGRAM, 0);
++ if (s < 0)
++ s = socket(PF_INET6, SOCK_DGRAM, 0);
++ if (s < 0)
++ s = socket(PF_UNIX, SOCK_DGRAM, 0);
++ if (s >= 0) {
++ slprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "%s%d", PPP_DRV_NAME, ifunit);
++ slprintf(ifr.ifr_newname, sizeof(ifr.ifr_newname), "%s", use_ifname);
++ x = ioctl(s, SIOCSIFNAME, &ifr);
++ close(s);
++ } else {
++ x = s;
++ }
++ if (x < 0) {
++ error("Couldn't rename %s to %s", ifr.ifr_name, ifr.ifr_newname);
++ close(ppp_dev_fd);
++ ppp_dev_fd = -1;
++ }
++ }
++
+ return x;
+ }
+
+--- a/pppstats/pppstats.c
++++ b/pppstats/pppstats.c
+@@ -506,10 +506,12 @@ main(argc, argv)
+ if (argc > 0)
+ interface = argv[0];
+
++#if 0
+ if (sscanf(interface, PPP_DRV_NAME "%d", &unit) != 1) {
+ fprintf(stderr, "%s: invalid interface '%s' specified\n",
+ progname, interface);
+ }
++#endif
+
+ #ifndef STREAMS
+ {
diff --git a/package/network/services/ppp/patches/.svn/text-base/321-multilink_support_custom_iface_names.patch.svn-base b/package/network/services/ppp/patches/.svn/text-base/321-multilink_support_custom_iface_names.patch.svn-base
new file mode 100644
index 0000000..ed04886
--- /dev/null
+++ b/package/network/services/ppp/patches/.svn/text-base/321-multilink_support_custom_iface_names.patch.svn-base
@@ -0,0 +1,146 @@
+From: George Kashperko <george@znau.edu.ua>
+
+Make mlppp support more generic interface naming other than pppX
+Signed-off-by: George Kashperko <george@znau.edu.ua>
+---
+ pppd/multilink.c | 55 +++++++++++++++++++++++++++++++++------------
+ pppd/sys-linux.c | 12 +++++++++
+ 2 files changed, 53 insertions(+), 14 deletions(-)
+--- a/pppd/multilink.c
++++ b/pppd/multilink.c
+@@ -56,7 +56,8 @@ static void iterate_bundle_links __P((vo
+
+ static int get_default_epdisc __P((struct epdisc *));
+ static int parse_num __P((char *str, const char *key, int *valp));
+-static int owns_unit __P((TDB_DATA pid, int unit));
++static int parse_str __P((char *str, const char *key, char *buf, int buflen));
++static int owns_link __P((TDB_DATA pid, char *ifname));
+
+ #define set_ip_epdisc(ep, addr) do { \
+ ep->length = 4; \
+@@ -197,35 +198,38 @@ mp_join_bundle()
+ key.dptr = bundle_id;
+ key.dsize = p - bundle_id;
+ pid = tdb_fetch(pppdb, key);
++
+ if (pid.dptr != NULL) {
++ char tmp[IFNAMSIZ];
++
+ /* bundle ID exists, see if the pppd record exists */
+ rec = tdb_fetch(pppdb, pid);
++
+ if (rec.dptr != NULL && rec.dsize > 0) {
+ /* make sure the string is null-terminated */
+ rec.dptr[rec.dsize-1] = 0;
+- /* parse the interface number */
+- parse_num(rec.dptr, "IFNAME=ppp", &unit);
++
+ /* check the pid value */
+ if (!parse_num(rec.dptr, "PPPD_PID=", &pppd_pid)
++ || !parse_str(rec.dptr, "IFNAME=", tmp, sizeof(tmp))
++ || !parse_num(rec.dptr, "IFUNIT=", &unit)
+ || !process_exists(pppd_pid)
+- || !owns_unit(pid, unit))
++ || !owns_link(pid, tmp))
+ unit = -1;
+ free(rec.dptr);
+ }
+ free(pid.dptr);
+- }
+
+- if (unit >= 0) {
+ /* attach to existing unit */
+- if (bundle_attach(unit)) {
++ if (unit >= 0 && bundle_attach(unit)) {
+ set_ifunit(0);
+ script_setenv("BUNDLE", bundle_id + 7, 0);
+ make_bundle_links(1);
+ unlock_db();
+- info("Link attached to %s", ifname);
++ info("Link attached to %s", tmp);
+ return 1;
++ /* attach failed because bundle doesn't exist */
+ }
+- /* attach failed because bundle doesn't exist */
+ }
+
+ /* we have to make a new bundle */
+@@ -408,22 +412,45 @@ parse_num(str, key, valp)
+ return 0;
+ }
+
++static int
++parse_str(str, key, buf, buflen)
++ char *str;
++ const char *key;
++ char *buf;
++ int buflen;
++{
++ char *p, *endp;
++ int i;
++
++ p = strstr(str, key);
++ if (p) {
++ p += strlen(key);
++ while (--buflen && *p != 0 && *p != ';')
++ *(buf++) = *(p++);
++ *buf = 0;
++ return 1;
++ }
++ return 0;
++}
++
+ /*
+- * Check whether the pppd identified by `key' still owns ppp unit `unit'.
++ * Check whether the pppd identified by `key' still owns ppp link `ifname'.
+ */
+ static int
+-owns_unit(key, unit)
++owns_link(key, ifname)
+ TDB_DATA key;
+- int unit;
++ char *ifname;
+ {
+- char ifkey[32];
++ char ifkey[7 + IFNAMSIZ];
+ TDB_DATA kd, vd;
+ int ret = 0;
+
+- slprintf(ifkey, sizeof(ifkey), "IFNAME=ppp%d", unit);
++ slprintf(ifkey, sizeof(ifkey), "IFNAME=%s", ifname);
++
+ kd.dptr = ifkey;
+ kd.dsize = strlen(ifkey);
+ vd = tdb_fetch(pppdb, kd);
++
+ if (vd.dptr != NULL) {
+ ret = vd.dsize == key.dsize
+ && memcmp(vd.dptr, key.dptr, vd.dsize) == 0;
+--- a/pppd/sys-linux.c
++++ b/pppd/sys-linux.c
+@@ -700,6 +700,16 @@ void cfg_bundle(int mrru, int mtru, int
+ add_fd(ppp_dev_fd);
+ }
+
++static void
++setenv_ifunit(void)
++{
++#ifdef USE_TDB
++ char tmp[11];
++ slprintf(tmp, sizeof(tmp), "%d", ifunit);
++ script_setenv("IFUNIT", tmp, 0);
++#endif
++}
++
+ /*
+ * make_new_bundle - create a new PPP unit (i.e. a bundle)
+ * and connect our channel to it. This should only get called
+@@ -718,6 +728,8 @@ void make_new_bundle(int mrru, int mtru,
+
+ /* set the mrru and flags */
+ cfg_bundle(mrru, mtru, rssn, tssn);
++
++ setenv_ifunit();
+ }
+
+ /*
diff --git a/package/network/services/ppp/patches/.svn/text-base/330-retain_foreign_default_routes.patch.svn-base b/package/network/services/ppp/patches/.svn/text-base/330-retain_foreign_default_routes.patch.svn-base
new file mode 100644
index 0000000..6d93b04
--- /dev/null
+++ b/package/network/services/ppp/patches/.svn/text-base/330-retain_foreign_default_routes.patch.svn-base
@@ -0,0 +1,22 @@
+pppd: Retain foreign default routes on Linux
+
+On Linux, when pppd attempts to delete its default route it does not fill
+the rt_dev field of the struct rtentry used to match the system default route.
+As a consequence, pppd happily deletes any default route even if it belongs
+to another interface.
+
+This patch makes pppd fill out the rt_dev field so that only own default
+routes are ever matched.
+
+Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
+
+--- a/pppd/sys-linux.c
++++ b/pppd/sys-linux.c
+@@ -1755,6 +1755,7 @@ int cifdefaultroute (int unit, u_int32_t
+ SIN_ADDR(rt.rt_genmask) = 0L;
+ }
+
++ rt.rt_dev = ifname;
+ rt.rt_flags = RTF_UP;
+ if (ioctl(sock_fd, SIOCDELRT, &rt) < 0 && errno != ESRCH) {
+ if (still_ppp()) {
diff --git a/package/network/services/ppp/patches/.svn/text-base/340-populate_default_gateway.patch.svn-base b/package/network/services/ppp/patches/.svn/text-base/340-populate_default_gateway.patch.svn-base
new file mode 100644
index 0000000..1c6d9ac
--- /dev/null
+++ b/package/network/services/ppp/patches/.svn/text-base/340-populate_default_gateway.patch.svn-base
@@ -0,0 +1,34 @@
+pppd: Fill in default gateway on Linux
+
+On Linux, when pppd creates the default route, it does not set the peer
+address as gateway, leading to a default route without gateway address.
+
+This behaviour breaks various downstream programs which attempt to infer
+the default gateway IP address from the system default route entry.
+
+This patch addresses the issue by filling in the peer address as gateway
+when generating the default route entry.
+
+Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
+
+--- a/pppd/sys-linux.c
++++ b/pppd/sys-linux.c
+@@ -1709,6 +1709,9 @@ int sifdefaultroute (int unit, u_int32_t
+ memset (&rt, 0, sizeof (rt));
+ SET_SA_FAMILY (rt.rt_dst, AF_INET);
+
++ SET_SA_FAMILY(rt.rt_gateway, AF_INET);
++ SIN_ADDR(rt.rt_gateway) = gateway;
++
+ rt.rt_dev = ifname;
+
+ if (kernel_version > KVERSION(2,1,0)) {
+@@ -1716,7 +1719,7 @@ int sifdefaultroute (int unit, u_int32_t
+ SIN_ADDR(rt.rt_genmask) = 0L;
+ }
+
+- rt.rt_flags = RTF_UP;
++ rt.rt_flags = RTF_UP | RTF_GATEWAY;
+ if (ioctl(sock_fd, SIOCADDRT, &rt) < 0) {
+ if (!ok_error(errno))
+ error("default route ioctl(SIOCADDRT): %m");
diff --git a/package/network/services/ppp/patches/.svn/text-base/400-simplify_kernel_checks.patch.svn-base b/package/network/services/ppp/patches/.svn/text-base/400-simplify_kernel_checks.patch.svn-base
new file mode 100644
index 0000000..4494aba
--- /dev/null
+++ b/package/network/services/ppp/patches/.svn/text-base/400-simplify_kernel_checks.patch.svn-base
@@ -0,0 +1,154 @@
+pppd: Remove runtime kernel checks
+
+On embedded system distributions the required kernel features for pppd are
+more or less guaranteed to be present, so there is not much point in
+performing runtime checks, it just increases the binary size.
+
+This patch removes the runtime kernel feature checks.
+
+Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
+
+--- a/pppd/sys-linux.c
++++ b/pppd/sys-linux.c
+@@ -203,7 +203,7 @@ static int driver_is_old = 0;
+ static int restore_term = 0; /* 1 => we've munged the terminal */
+ static struct termios inittermios; /* Initial TTY termios */
+
+-int new_style_driver = 0;
++static const int new_style_driver = 1;
+
+ static char loop_name[20];
+ static unsigned char inbuf[512]; /* buffer for chars read from loopback */
+@@ -220,8 +220,8 @@ static int looped; /* 1 if using loop
+ static int link_mtu; /* mtu for the link (not bundle) */
+
+ static struct utsname utsname; /* for the kernel version */
+-static int kernel_version;
+ #define KVERSION(j,n,p) ((j)*1000000 + (n)*1000 + (p))
++static const int kernel_version = KVERSION(2,6,37);
+
+ #define MAX_IFS 100
+
+@@ -1450,11 +1450,12 @@ int ccp_fatal_error (int unit)
+ *
+ * path_to_procfs - find the path to the proc file system mount point
+ */
+-static char proc_path[MAXPATHLEN];
+-static int proc_path_len;
++static char proc_path[MAXPATHLEN] = "/proc";
++static int proc_path_len = 5;
+
+ static char *path_to_procfs(const char *tail)
+ {
++#if 0
+ struct mntent *mntent;
+ FILE *fp;
+
+@@ -1476,6 +1477,7 @@ static char *path_to_procfs(const char *
+ fclose (fp);
+ }
+ }
++#endif
+
+ strlcpy(proc_path + proc_path_len, tail,
+ sizeof(proc_path) - proc_path_len);
+@@ -2128,15 +2130,19 @@ int ppp_available(void)
+ int my_version, my_modification, my_patch;
+ int osmaj, osmin, ospatch;
+
++#if 0
+ /* get the kernel version now, since we are called before sys_init */
+ uname(&utsname);
+ osmaj = osmin = ospatch = 0;
+ sscanf(utsname.release, "%d.%d.%d", &osmaj, &osmin, &ospatch);
+ kernel_version = KVERSION(osmaj, osmin, ospatch);
++#endif
+
+ fd = open("/dev/ppp", O_RDWR);
+ if (fd >= 0) {
++#if 0
+ new_style_driver = 1;
++#endif
+
+ /* XXX should get from driver */
+ driver_version = 2;
+@@ -2197,6 +2203,7 @@ int ppp_available(void)
+
+ if (ok && ((ifr.ifr_hwaddr.sa_family & ~0xFF) != ARPHRD_PPP))
+ ok = 0;
++ return ok;
+
+ /*
+ * This is the PPP device. Validate the version of the driver at this
+@@ -2690,6 +2697,7 @@ get_pty(master_fdp, slave_fdp, slave_nam
+ }
+ #endif /* TIOCGPTN */
+
++#if 0
+ if (sfd < 0) {
+ /* the old way - scan through the pty name space */
+ for (i = 0; i < 64; ++i) {
+@@ -2708,6 +2716,7 @@ get_pty(master_fdp, slave_fdp, slave_nam
+ }
+ }
+ }
++#endif
+
+ if (sfd < 0)
+ return 0;
+--- a/pppd/plugins/pppoatm/pppoatm.c
++++ b/pppd/plugins/pppoatm/pppoatm.c
+@@ -170,14 +170,6 @@ static void disconnect_pppoatm(void)
+
+ void plugin_init(void)
+ {
+-#if defined(__linux__)
+- extern int new_style_driver; /* From sys-linux.c */
+- if (!ppp_available() && !new_style_driver)
+- fatal("Kernel doesn't support ppp_generic - "
+- "needed for PPPoATM");
+-#else
+- fatal("No PPPoATM support on this OS");
+-#endif
+ info("PPPoATM plugin_init");
+ add_options(pppoa_options);
+ }
+--- a/pppd/plugins/rp-pppoe/plugin.c
++++ b/pppd/plugins/rp-pppoe/plugin.c
+@@ -60,9 +60,6 @@ static char const RCSID[] =
+
+ char pppd_version[] = VERSION;
+
+-/* From sys-linux.c in pppd -- MUST FIX THIS! */
+-extern int new_style_driver;
+-
+ char *pppd_pppoe_service = NULL;
+ static char *acName = NULL;
+ static char *existingSession = NULL;
+@@ -340,10 +337,6 @@ PPPoEDevnameHook(char *cmd, char **argv,
+ void
+ plugin_init(void)
+ {
+- if (!ppp_available() && !new_style_driver) {
+- fatal("Linux kernel does not support PPPoE -- are you running 2.4.x?");
+- }
+-
+ add_options(Options);
+
+ info("RP-PPPoE plugin version %s compiled against pppd %s",
+--- a/pppd/plugins/pppol2tp/pppol2tp.c
++++ b/pppd/plugins/pppol2tp/pppol2tp.c
+@@ -500,12 +500,7 @@ static void pppol2tp_cleanup(void)
+
+ void plugin_init(void)
+ {
+-#if defined(__linux__)
+- extern int new_style_driver; /* From sys-linux.c */
+- if (!ppp_available() && !new_style_driver)
+- fatal("Kernel doesn't support ppp_generic - "
+- "needed for PPPoL2TP");
+-#else
++#if !defined(__linux__)
+ fatal("No PPPoL2TP support on this OS");
+ #endif
+ add_options(pppol2tp_options);
diff --git a/package/network/services/ppp/patches/.svn/text-base/401-no_record_file.patch.svn-base b/package/network/services/ppp/patches/.svn/text-base/401-no_record_file.patch.svn-base
new file mode 100644
index 0000000..94c0263
--- /dev/null
+++ b/package/network/services/ppp/patches/.svn/text-base/401-no_record_file.patch.svn-base
@@ -0,0 +1,39 @@
+pppd: Remove the "record" option
+
+On many embedded systems there is not enough space to record PPP session
+information to the permanent storage, therfore remove this option.
+
+Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
+
+--- a/pppd/pppd.h
++++ b/pppd/pppd.h
+@@ -309,7 +309,6 @@ extern int holdoff; /* Dead time before
+ extern bool holdoff_specified; /* true if user gave a holdoff value */
+ extern bool notty; /* Stdin/out is not a tty */
+ extern char *pty_socket; /* Socket to connect to pty */
+-extern char *record_file; /* File to record chars sent/received */
+ extern bool sync_serial; /* Device is synchronous serial device */
+ extern int maxfail; /* Max # of unsuccessful connection attempts */
+ extern char linkname[MAXPATHLEN]; /* logical name for link */
+--- a/pppd/tty.c
++++ b/pppd/tty.c
+@@ -145,7 +145,7 @@ char *disconnect_script = NULL; /* Scrip
+ char *welcomer = NULL; /* Script to run after phys link estab. */
+ char *ptycommand = NULL; /* Command to run on other side of pty */
+ bool notty = 0; /* Stdin/out is not a tty */
+-char *record_file = NULL; /* File to record chars sent/received */
++static char *const record_file = NULL; /* File to record chars sent/received */
+ int max_data_rate; /* max bytes/sec through charshunt */
+ bool sync_serial = 0; /* Device is synchronous serial device */
+ char *pty_socket = NULL; /* Socket to connect to pty */
+@@ -201,8 +201,10 @@ option_t tty_options[] = {
+ "Send and receive over socket, arg is host:port",
+ OPT_PRIO | OPT_DEVNAM },
+
++#if 0
+ { "record", o_string, &record_file,
+ "Record characters sent/received to file", OPT_PRIO },
++#endif
+
+ { "crtscts", o_int, &crtscts,
+ "Set hardware (RTS/CTS) flow control",
diff --git a/package/network/services/ppp/patches/.svn/text-base/403-no_wtmp.patch.svn-base b/package/network/services/ppp/patches/.svn/text-base/403-no_wtmp.patch.svn-base
new file mode 100644
index 0000000..e8e7625
--- /dev/null
+++ b/package/network/services/ppp/patches/.svn/text-base/403-no_wtmp.patch.svn-base
@@ -0,0 +1,25 @@
+pppd: Disable wtmp support
+
+Many uClibc based environments lack wtmp and utmp support, therfore remove
+the code updating the wtmp information.
+
+Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
+
+--- a/pppd/sys-linux.c
++++ b/pppd/sys-linux.c
+@@ -2266,6 +2266,7 @@ int ppp_available(void)
+
+ void logwtmp (const char *line, const char *name, const char *host)
+ {
++#if 0
+ struct utmp ut, *utp;
+ pid_t mypid = getpid();
+ #if __GLIBC__ < 2
+@@ -2331,6 +2332,7 @@ void logwtmp (const char *line, const ch
+ close (wtmp);
+ }
+ #endif
++#endif
+ }
+
+
diff --git a/package/network/services/ppp/patches/.svn/text-base/404-remove_obsolete_protocol_names.patch.svn-base b/package/network/services/ppp/patches/.svn/text-base/404-remove_obsolete_protocol_names.patch.svn-base
new file mode 100644
index 0000000..edbca76
--- /dev/null
+++ b/package/network/services/ppp/patches/.svn/text-base/404-remove_obsolete_protocol_names.patch.svn-base
@@ -0,0 +1,151 @@
+pppd: Remove historical protocol names
+
+Remove a number of historical protocol entries from pppd's builtin list, this
+reduced the binary size without loss of features.
+
+Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
+
+--- a/pppd/main.c
++++ b/pppd/main.c
+@@ -882,14 +882,17 @@ struct protocol_list {
+ const char *name;
+ } protocol_list[] = {
+ { 0x21, "IP" },
++#if 0
+ { 0x23, "OSI Network Layer" },
+ { 0x25, "Xerox NS IDP" },
+ { 0x27, "DECnet Phase IV" },
+ { 0x29, "Appletalk" },
+ { 0x2b, "Novell IPX" },
++#endif
+ { 0x2d, "VJ compressed TCP/IP" },
+ { 0x2f, "VJ uncompressed TCP/IP" },
+ { 0x31, "Bridging PDU" },
++#if 0
+ { 0x33, "Stream Protocol ST-II" },
+ { 0x35, "Banyan Vines" },
+ { 0x39, "AppleTalk EDDP" },
+@@ -903,8 +906,11 @@ struct protocol_list {
+ { 0x49, "Serial Data Transport Protocol (PPP-SDTP)" },
+ { 0x4b, "SNA over 802.2" },
+ { 0x4d, "SNA" },
++#endif
+ { 0x4f, "IP6 Header Compression" },
++#if 0
+ { 0x51, "KNX Bridging Data" },
++#endif
+ { 0x53, "Encryption" },
+ { 0x55, "Individual Link Encryption" },
+ { 0x57, "IPv6" },
+@@ -915,12 +921,15 @@ struct protocol_list {
+ { 0x65, "RTP IPHC Compressed non-TCP" },
+ { 0x67, "RTP IPHC Compressed UDP 8" },
+ { 0x69, "RTP IPHC Compressed RTP 8" },
++#if 0
+ { 0x6f, "Stampede Bridging" },
+ { 0x73, "MP+" },
+ { 0xc1, "NTCITS IPI" },
++#endif
+ { 0xfb, "single-link compression" },
+ { 0xfd, "Compressed Datagram" },
+ { 0x0201, "802.1d Hello Packets" },
++#if 0
+ { 0x0203, "IBM Source Routing BPDU" },
+ { 0x0205, "DEC LANBridge100 Spanning Tree" },
+ { 0x0207, "Cisco Discovery Protocol" },
+@@ -932,15 +941,19 @@ struct protocol_list {
+ { 0x0231, "Luxcom" },
+ { 0x0233, "Sigma Network Systems" },
+ { 0x0235, "Apple Client Server Protocol" },
++#endif
+ { 0x0281, "MPLS Unicast" },
+ { 0x0283, "MPLS Multicast" },
++#if 0
+ { 0x0285, "IEEE p1284.4 standard - data packets" },
+ { 0x0287, "ETSI TETRA Network Protocol Type 1" },
++#endif
+ { 0x0289, "Multichannel Flow Treatment Protocol" },
+ { 0x2063, "RTP IPHC Compressed TCP No Delta" },
+ { 0x2065, "RTP IPHC Context State" },
+ { 0x2067, "RTP IPHC Compressed UDP 16" },
+ { 0x2069, "RTP IPHC Compressed RTP 16" },
++#if 0
+ { 0x4001, "Cray Communications Control Protocol" },
+ { 0x4003, "CDPD Mobile Network Registration Protocol" },
+ { 0x4005, "Expand accelerator protocol" },
+@@ -951,8 +964,10 @@ struct protocol_list {
+ { 0x4023, "RefTek Protocol" },
+ { 0x4025, "Fibre Channel" },
+ { 0x4027, "EMIT Protocols" },
++#endif
+ { 0x405b, "Vendor-Specific Protocol (VSP)" },
+ { 0x8021, "Internet Protocol Control Protocol" },
++#if 0
+ { 0x8023, "OSI Network Layer Control Protocol" },
+ { 0x8025, "Xerox NS IDP Control Protocol" },
+ { 0x8027, "DECnet Phase IV Control Protocol" },
+@@ -961,7 +976,9 @@ struct protocol_list {
+ { 0x8031, "Bridging NCP" },
+ { 0x8033, "Stream Protocol Control Protocol" },
+ { 0x8035, "Banyan Vines Control Protocol" },
++#endif
+ { 0x803d, "Multi-Link Control Protocol" },
++#if 0
+ { 0x803f, "NETBIOS Framing Control Protocol" },
+ { 0x8041, "Cisco Systems Control Protocol" },
+ { 0x8043, "Ascom Timeplex" },
+@@ -970,18 +987,24 @@ struct protocol_list {
+ { 0x8049, "Serial Data Control Protocol (PPP-SDCP)" },
+ { 0x804b, "SNA over 802.2 Control Protocol" },
+ { 0x804d, "SNA Control Protocol" },
++#endif
+ { 0x804f, "IP6 Header Compression Control Protocol" },
++#if 0
+ { 0x8051, "KNX Bridging Control Protocol" },
++#endif
+ { 0x8053, "Encryption Control Protocol" },
+ { 0x8055, "Individual Link Encryption Control Protocol" },
+ { 0x8057, "IPv6 Control Protocol" },
+ { 0x8059, "PPP Muxing Control Protocol" },
+ { 0x805b, "Vendor-Specific Network Control Protocol (VSNCP)" },
++#if 0
+ { 0x806f, "Stampede Bridging Control Protocol" },
+ { 0x8073, "MP+ Control Protocol" },
+ { 0x80c1, "NTCITS IPI Control Protocol" },
++#endif
+ { 0x80fb, "Single Link Compression Control Protocol" },
+ { 0x80fd, "Compression Control Protocol" },
++#if 0
+ { 0x8207, "Cisco Discovery Protocol Control" },
+ { 0x8209, "Netcs Twin Routing" },
+ { 0x820b, "STP - Control Protocol" },
+@@ -990,24 +1013,29 @@ struct protocol_list {
+ { 0x8281, "MPLSCP" },
+ { 0x8285, "IEEE p1284.4 standard - Protocol Control" },
+ { 0x8287, "ETSI TETRA TNP1 Control Protocol" },
++#endif
+ { 0x8289, "Multichannel Flow Treatment Protocol" },
+ { 0xc021, "Link Control Protocol" },
+ { 0xc023, "Password Authentication Protocol" },
+ { 0xc025, "Link Quality Report" },
++#if 0
+ { 0xc027, "Shiva Password Authentication Protocol" },
+ { 0xc029, "CallBack Control Protocol (CBCP)" },
+ { 0xc02b, "BACP Bandwidth Allocation Control Protocol" },
+ { 0xc02d, "BAP" },
++#endif
+ { 0xc05b, "Vendor-Specific Authentication Protocol (VSAP)" },
+ { 0xc081, "Container Control Protocol" },
+ { 0xc223, "Challenge Handshake Authentication Protocol" },
+ { 0xc225, "RSA Authentication Protocol" },
+ { 0xc227, "Extensible Authentication Protocol" },
++#if 0
+ { 0xc229, "Mitsubishi Security Info Exch Ptcl (SIEP)" },
+ { 0xc26f, "Stampede Bridging Authorization Protocol" },
+ { 0xc281, "Proprietary Authentication Protocol" },
+ { 0xc283, "Proprietary Authentication Protocol" },
+ { 0xc481, "Proprietary Node ID Authentication Protocol" },
++#endif
+ { 0, NULL },
+ };
+
diff --git a/package/network/services/ppp/patches/.svn/text-base/405-no_multilink_option.patch.svn-base b/package/network/services/ppp/patches/.svn/text-base/405-no_multilink_option.patch.svn-base
new file mode 100644
index 0000000..97a79c4
--- /dev/null
+++ b/package/network/services/ppp/patches/.svn/text-base/405-no_multilink_option.patch.svn-base
@@ -0,0 +1,28 @@
+pppd: Support "nomp" option even if multilink support is off
+
+This patch moves the "nomp" option entry outside of the defines protecting
+the multilink specific code. The motivation is to allow "nomp" even if pppd
+does not support multilink, so that controlling programs can unconditionally
+pass it to pppd regardless of the compile time features.
+
+Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
+
+--- a/pppd/options.c
++++ b/pppd/options.c
+@@ -318,13 +318,14 @@ option_t general_options[] = {
+ "Enable multilink operation", OPT_PRIOSUB | OPT_ALIAS | 1 },
+ { "nomultilink", o_bool, &multilink,
+ "Disable multilink operation", OPT_PRIOSUB | 0 },
+- { "nomp", o_bool, &multilink,
+- "Disable multilink operation", OPT_PRIOSUB | OPT_ALIAS | 0 },
+
+ { "bundle", o_string, &bundle_name,
+ "Bundle name for multilink", OPT_PRIO },
+ #endif /* HAVE_MULTILINK */
+
++ { "nomp", o_bool, &multilink,
++ "Disable multilink operation", OPT_PRIOSUB | OPT_ALIAS | 0 },
++
+ #ifdef PLUGIN
+ { "plugin", o_special, (void *)loadplugin,
+ "Load a plug-in module into pppd", OPT_PRIV | OPT_A2LIST },
diff --git a/package/network/services/ppp/patches/.svn/text-base/430-pppol2tpv3-struct.patch.svn-base b/package/network/services/ppp/patches/.svn/text-base/430-pppol2tpv3-struct.patch.svn-base
new file mode 100644
index 0000000..204aa4e
--- /dev/null
+++ b/package/network/services/ppp/patches/.svn/text-base/430-pppol2tpv3-struct.patch.svn-base
@@ -0,0 +1,56 @@
+pppol2tp: Provide struct pppol2tpv3_addr to align with Linux
+
+The struct pppol2tpv3_addr is referenced in the current Linux kernel sources
+but not provided by the shipped kernel headers, add it.
+
+Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
+
+--- a/include/linux/if_pppol2tp.h
++++ b/include/linux/if_pppol2tp.h
+@@ -32,6 +32,46 @@ struct pppol2tp_addr
+ __u16 d_tunnel, d_session; /* For sending outgoing packets */
+ };
+
++/* Structure used to connect() the socket to a particular tunnel UDP
++ * socket over IPv6.
++ */
++struct pppol2tpin6_addr
++{
++ pid_t pid; /* pid that owns the fd.
++ * 0 => current */
++ int fd; /* FD of UDP socket to use */
++
++ __u16 s_tunnel, s_session; /* For matching incoming packets */
++ __u16 d_tunnel, d_session; /* For sending outgoing packets */
++
++ struct sockaddr_in6 addr; /* IP address and port to send to */
++};
++
++/* The L2TPv3 protocol changes tunnel and session ids from 16 to 32
++ * bits. So we need a different sockaddr structure.
++ */
++struct pppol2tpv3_addr {
++ pid_t pid; /* pid that owns the fd.
++ * 0 => current */
++ int fd; /* FD of UDP or IP socket to use */
++
++ struct sockaddr_in addr; /* IP address and port to send to */
++
++ __u32 s_tunnel, s_session; /* For matching incoming packets */
++ __u32 d_tunnel, d_session; /* For sending outgoing packets */
++};
++
++struct pppol2tpv3in6_addr {
++ pid_t pid; /* pid that owns the fd.
++ * 0 => current */
++ int fd; /* FD of UDP or IP socket to use */
++
++ __u32 s_tunnel, s_session; /* For matching incoming packets */
++ __u32 d_tunnel, d_session; /* For sending outgoing packets */
++
++ struct sockaddr_in6 addr; /* IP address and port to send to */
++};
++
+ /* Socket options:
+ * DEBUG - bitmask of debug message categories
+ * SENDSEQ - 0 => don't send packets with sequence numbers
diff --git a/package/network/services/ppp/patches/.svn/text-base/500-add-pptp-plugin.patch.svn-base b/package/network/services/ppp/patches/.svn/text-base/500-add-pptp-plugin.patch.svn-base
new file mode 100644
index 0000000..d984e1b
--- /dev/null
+++ b/package/network/services/ppp/patches/.svn/text-base/500-add-pptp-plugin.patch.svn-base
@@ -0,0 +1,3065 @@
+--- a/configure
++++ b/configure
+@@ -195,7 +195,7 @@ if [ -d "$ksrc" ]; then
+ mkmkf $ksrc/Makedefs$compiletype Makedefs.com
+ for dir in pppd pppstats chat pppdump pppd/plugins pppd/plugins/rp-pppoe \
+ pppd/plugins/radius pppd/plugins/pppoatm \
+- pppd/plugins/pppol2tp; do
++ pppd/plugins/pppol2tp pppd/plugins/pptp ; do
+ mkmkf $dir/Makefile.$makext $dir/Makefile
+ done
+ if [ -f $ksrc/Makefile.$makext$archvariant ]; then
+--- a/pppd/plugins/Makefile.linux
++++ b/pppd/plugins/Makefile.linux
+@@ -9,7 +9,7 @@ BINDIR = $(DESTDIR)/sbin
+ MANDIR = $(DESTDIR)/share/man/man8
+ LIBDIR = $(DESTDIR)/lib/pppd/$(VERSION)
+
+-SUBDIRS := rp-pppoe pppoatm pppol2tp
++SUBDIRS := rp-pppoe pppoatm pppol2tp pptp
+ # Uncomment the next line to include the radius authentication plugin
+ SUBDIRS += radius
+ PLUGINS := minconn.so passprompt.so passwordfd.so winbind.so
+--- /dev/null
++++ b/pppd/plugins/pptp/Makefile.linux
+@@ -0,0 +1,31 @@
++#
++# This program may be distributed according to the terms of the GNU
++# General Public License, version 2 or (at your option) any later version.
++#
++# $Id: Makefile.linux,v 1.9 2012/05/04 21:48:00 dgolle Exp $
++#***********************************************************************
++
++DESTDIR = $(INSTROOT)@DESTDIR@
++LIBDIR = $(DESTDIR)/lib/pppd/$(PPPDVERSION)
++
++PPPDVERSION = $(shell awk -F '"' '/VERSION/ { print $$2; }' ../../patchlevel.h)
++
++INSTALL = install
++
++COPTS=-O2 -g
++CFLAGS = $(COPTS) -I. -I../.. -I../../../include -fPIC -DPPPD_VERSION=\"$(PPPDVERSION)\"
++all: pptp.so
++
++%.o: %.c
++ $(CC) $(CFLAGS) -c -o $@ $<
++
++pptp.so: dirutil.o orckit_quirks.o pptp.o pptp_callmgr.o pptp_ctrl.o pptp_quirks.o util.o vector.o
++ $(CC) -o pptp.so -shared dirutil.o orckit_quirks.o pptp.o pptp_callmgr.o pptp_ctrl.o pptp_quirks.o util.o vector.o
++
++install: all
++ $(INSTALL) -d -m 755 $(LIBDIR)
++ $(INSTALL) -c -m 4550 pptp.so $(LIBDIR)
++
++clean:
++ rm -f *.o *.so
++
+--- /dev/null
++++ b/pppd/plugins/pptp/dirutil.c
+@@ -0,0 +1,68 @@
++/* dirutil.c ... directory utilities.
++ * C. Scott Ananian <cananian@alumni.princeton.edu>
++ *
++ * $Id: dirutil.c,v 1.2 2003/06/17 17:25:47 reink Exp $
++ */
++
++#include <sys/stat.h>
++#include <sys/types.h>
++#include <unistd.h>
++#include <string.h>
++#include <stdlib.h>
++#include "dirutil.h"
++
++/* Returned malloc'ed string representing basename */
++char *basenamex(char *pathname)
++{
++ char *dup = strdup(pathname);
++ char *ptr = strrchr(stripslash(dup), '/');
++ if (ptr == NULL) return dup;
++ ptr = strdup(ptr+1);
++ free(dup);
++ return ptr;
++}
++
++/* Return malloc'ed string representing directory name (no trailing slash) */
++char *dirnamex(char *pathname)
++{
++ char *dup = strdup(pathname);
++ char *ptr = strrchr(stripslash(dup), '/');
++ if (ptr == NULL) { free(dup); return strdup("."); }
++ if (ptr == dup && dup[0] == '/') ptr++;
++ *ptr = '\0';
++ return dup;
++}
++
++/* In-place modify a string to remove trailing slashes. Returns arg.
++ * stripslash("/") returns "/";
++ */
++char *stripslash(char *pathname) {
++ int len = strlen(pathname);
++ while (len > 1 && pathname[len - 1] == '/')
++ pathname[--len] = '\0';
++ return pathname;
++}
++
++/* ensure dirname exists, creating it if necessary. */
++int make_valid_path(char *dir, mode_t mode)
++{
++ struct stat st;
++ char *tmp = NULL, *path = stripslash(strdup(dir));
++ int retval;
++ if (stat(path, &st) == 0) { /* file exists */
++ if (S_ISDIR(st.st_mode)) { retval = 1; goto end; }
++ else { retval = 0; goto end; } /* not a directory. Oops. */
++ }
++ /* Directory doesn't exist. Let's make it. */
++ /* Make parent first. */
++ if (!make_valid_path(tmp = dirnamex(path), mode)) { retval = 0; goto end; }
++ /* Now make this 'un. */
++ if (mkdir(path, mode) < 0) { retval = 0; goto end; }
++ /* Success. */
++ retval = 1;
++
++end:
++ if (tmp != NULL) free(tmp);
++ if (path != NULL) free(path);
++ return retval;
++}
+--- /dev/null
++++ b/pppd/plugins/pptp/dirutil.h
+@@ -0,0 +1,14 @@
++/* dirutil.h ... directory utilities.
++ * C. Scott Ananian <cananian@alumni.princeton.edu>
++ *
++ * $Id: dirutil.h,v 1.1.1.1 2000/12/23 08:19:51 scott Exp $
++ */
++
++/* Returned malloc'ed string representing basename */
++char *basenamex(char *pathname);
++/* Return malloc'ed string representing directory name (no trailing slash) */
++char *dirnamex(char *pathname);
++/* In-place modify a string to remove trailing slashes. Returns arg. */
++char *stripslash(char *pathname);
++/* ensure dirname exists, creating it if necessary. */
++int make_valid_path(char *dirname, mode_t mode);
+--- /dev/null
++++ b/pppd/plugins/pptp/orckit_quirks.c
+@@ -0,0 +1,86 @@
++/* orckit_quirks.c ...... fix quirks in orckit adsl modems
++ * mulix <mulix@actcom.co.il>
++ *
++ * $Id: orckit_quirks.c,v 1.3 2002/03/01 01:23:36 quozl Exp $
++ */
++
++#include <string.h>
++#include <sys/types.h>
++#include <netinet/in.h>
++#include "pptp_msg.h"
++#include "pptp_options.h"
++#include "pptp_ctrl.h"
++#include "util.h"
++
++
++
++/* return 0 on success, non zero otherwise */
++int
++orckit_atur3_build_hook(struct pptp_out_call_rqst* packet)
++{
++ unsigned int name_length = 10;
++
++ struct pptp_out_call_rqst fixed_packet = {
++ PPTP_HEADER_CTRL(PPTP_OUT_CALL_RQST),
++ 0, /* hton16(call->callid) */
++ 0, /* hton16(call->sernum) */
++ hton32(PPTP_BPS_MIN), hton32(PPTP_BPS_MAX),
++ hton32(PPTP_BEARER_DIGITAL), hton32(PPTP_FRAME_ANY),
++ hton16(PPTP_WINDOW), 0, hton16(name_length), 0,
++ {'R','E','L','A','Y','_','P','P','P','1',0}, {0}
++ };
++
++ if (!packet)
++ return -1;
++
++ memcpy(packet, &fixed_packet, sizeof(*packet));
++
++ return 0;
++}
++
++/* return 0 on success, non zero otherwise */
++int
++orckit_atur3_set_link_hook(struct pptp_set_link_info* packet,
++ int peer_call_id)
++{
++ struct pptp_set_link_info fixed_packet = {
++ PPTP_HEADER_CTRL(PPTP_SET_LINK_INFO),
++ hton16(peer_call_id),
++ 0,
++ 0xffffffff,
++ 0xffffffff};
++
++ if (!packet)
++ return -1;
++
++ memcpy(packet, &fixed_packet, sizeof(*packet));
++ return 0;
++}
++
++/* return 0 on success, non 0 otherwise */
++int
++orckit_atur3_start_ctrl_conn_hook(struct pptp_start_ctrl_conn* packet)
++{
++ struct pptp_start_ctrl_conn fixed_packet = {
++ {0}, /* we'll set the header later */
++ hton16(PPTP_VERSION), 0, 0,
++ hton32(PPTP_FRAME_ASYNC), hton32(PPTP_BEARER_ANALOG),
++ hton16(0) /* max channels */,
++ hton16(0x6021),
++ {'R','E','L','A','Y','_','P','P','P','1',0}, /* hostname */
++ {'M','S',' ','W','i','n',' ','N','T',0} /* vendor */
++ };
++
++ if (!packet)
++ return -1;
++
++ /* grab the header from the original packet, since we dont
++ know if this is a request or a reply */
++ memcpy(&fixed_packet.header, &packet->header, sizeof(struct pptp_header));
++
++ /* and now overwrite the full packet, effectively preserving the header */
++ memcpy(packet, &fixed_packet, sizeof(*packet));
++ return 0;
++}
++
++
+--- /dev/null
++++ b/pppd/plugins/pptp/orckit_quirks.h
+@@ -0,0 +1,27 @@
++/* orckit_quirks.h ...... fix quirks in orckit adsl modems
++ * mulix <mulix@actcom.co.il>
++ *
++ * $Id: orckit_quirks.h,v 1.2 2001/11/23 03:42:51 quozl Exp $
++ */
++
++#ifndef INC_ORCKIT_QUIRKS_H_
++#define INC_ORCKIT_QUIRKS_H_
++
++#include "pptp_options.h"
++#include "pptp_ctrl.h"
++#include "pptp_msg.h"
++
++/* return 0 on success, non zero otherwise */
++int
++orckit_atur3_build_hook(struct pptp_out_call_rqst* packt);
++
++/* return 0 on success, non zero otherwise */
++int
++orckit_atur3_set_link_hook(struct pptp_set_link_info* packet,
++ int peer_call_id);
++
++/* return 0 on success, non zero otherwise */
++int
++orckit_atur3_start_ctrl_conn_hook(struct pptp_start_ctrl_conn* packet);
++
++#endif /* INC_ORCKIT_QUIRKS_H_ */
+--- /dev/null
++++ b/pppd/plugins/pptp/pppd-pptp.8
+@@ -0,0 +1,68 @@
++.\" manual page [] for PPTP plugin for pppd 2.4
++.\" $Id: pppd-pptp.8,v 1.0 2007/10/17 13:27:17 kad Exp $
++.\" SH section heading
++.\" SS subsection heading
++.\" LP paragraph
++.\" IP indented paragraph
++.\" TP hanging label
++.TH PPPD-PPTP 8
++.SH NAME
++pptp.so \- PPTP VPN plugin for
++.BR pppd (8)
++.SH SYNOPSIS
++.B pppd
++[
++.I options
++]
++plugin pptp.so
++.SH DESCRIPTION
++.LP
++The PPTP plugin for pppd performs interaction with pptp kernel module
++and has built-in call manager (client part of PPTP).
++It pasees necessary paremeters from \fIoptions\fR into kernel module
++to configure ppp-pptp channel. If it runs in client mode, then additionally
++call manager starts up. PPTPD daemon automaticaly invokes this plugin
++in server mode and passes necessary options, so additional configuration
++is not needed.
++
++.SH OPTIONS for client mode
++The PPTP plugin introduces one additional pppd option:
++.TP
++.BI "pptp_server " server " (required)"
++Specifies ip address or hostname of pptp server.
++.TP
++.BI "pptp_window " packets " (optional)"
++The amount of sliding window size.
++Set to 0 to turn off sliding window.
++ to 3-10 for low speed connections.
++ to >10 for hi speed connections.
++Default is 50
++.TP
++.BI "pptp_phone " phone " (optional)"
++The phone string that sended to pptp server.
++.SH USAGE
++Sample configuration file:
++.nf
++plugin "pptp.so"
++pptp_server 192.168.0.1
++pptp_window 100
++name myname
++remotename pptp
++noauth
++refuse-eap
++refuse-chap
++refuse-mschap
++nobsdcomp
++nodeflate
++novj
++novjccomp
++require-mppe-128
++lcp-echo-interval 20
++lcp-echo-failure 3
++.fi
++
++.SH SEE ALSO
++.BR pppd (8) " " pptpd (8) " " pptpd.conf (5)
++
++.SH AUTHOR
++xeb xeb@mail.ru
+--- /dev/null
++++ b/pppd/plugins/pptp/pptp.c
+@@ -0,0 +1,323 @@
++/***************************************************************************
++ * Copyright (C) 2006 by Kozlov D. <xeb@mail.ru> *
++ * some cleanup done (C) 2012 by Daniel Golle <dgolle@allnet.de> *
++ * *
++ * 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 of the License, 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; if not, write to the *
++ * Free Software Foundation, Inc., *
++ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
++ ***************************************************************************/
++
++#define PPTP_VERSION "1.00"
++
++#ifdef HAVE_CONFIG_H
++#include <config.h>
++#endif
++
++#include <netinet/in.h>
++#include <arpa/inet.h>
++#include <sys/un.h>
++#include <netdb.h>
++#include <stdio.h>
++#include <string.h>
++#include <stdlib.h>
++#include <syslog.h>
++#include <unistd.h>
++#include <signal.h>
++#include <errno.h>
++#include <fcntl.h>
++#include <sys/wait.h>
++#include <sys/ioctl.h>
++
++#include "pppd.h"
++#include "fsm.h"
++#include "lcp.h"
++#include "ipcp.h"
++#include "ccp.h"
++#include "pathnames.h"
++
++#include "pptp_callmgr.h"
++#include <net/if.h>
++#include <net/ethernet.h>
++#include <linux/if_pppox.h>
++
++#include <stdio.h>
++#include <stdlib.h>
++
++
++
++extern char** environ;
++
++char pppd_version[] = PPPD_VERSION;
++extern int new_style_driver;
++
++
++char *pptp_server = NULL;
++char *pptp_client = NULL;
++char *pptp_phone = NULL;
++int pptp_window=50;
++int pptp_sock=-1;
++struct in_addr localbind = { INADDR_NONE };
++
++static int callmgr_sock;
++static int pptp_fd;
++int call_ID;
++
++static int open_callmgr(int call_id,struct in_addr inetaddr, char *phonenr,int window);
++static void launch_callmgr(int call_is,struct in_addr inetaddr, char *phonenr,int window);
++static int get_call_id(int sock, pid_t gre, pid_t pppd, u_int16_t *peer_call_id);
++
++static option_t Options[] =
++{
++ { "pptp_server", o_string, &pptp_server,
++ "PPTP Server" },
++ { "pptp_client", o_string, &pptp_client,
++ "PPTP Client" },
++ { "pptp_sock",o_int, &pptp_sock,
++ "PPTP socket" },
++ { "pptp_phone", o_string, &pptp_phone,
++ "PPTP Phone number" },
++ { "pptp_window",o_int, &pptp_window,
++ "PPTP window" },
++ { NULL }
++};
++
++static int pptp_connect(void);
++static void pptp_disconnect(void);
++
++struct channel pptp_channel = {
++ options: Options,
++ check_options: NULL,
++ connect: &pptp_connect,
++ disconnect: &pptp_disconnect,
++ establish_ppp: &generic_establish_ppp,
++ disestablish_ppp: &generic_disestablish_ppp,
++ close: NULL,
++ cleanup: NULL
++};
++
++static int pptp_start_server(void)
++{
++ pptp_fd=pptp_sock;
++ sprintf(ppp_devnam,"pptp (%s)",pptp_client);
++
++ return pptp_fd;
++}
++static int pptp_start_client(void)
++{
++ socklen_t len;
++ struct sockaddr_pppox src_addr,dst_addr;
++ struct hostent *hostinfo;
++
++ hostinfo=gethostbyname(pptp_server);
++ if (!hostinfo)
++ {
++ error("PPTP: Unknown host %s\n", pptp_server);
++ return -1;
++ }
++ dst_addr.sa_addr.pptp.sin_addr=*(struct in_addr*)hostinfo->h_addr;
++ {
++ int sock;
++ struct sockaddr_in addr;
++ len=sizeof(addr);
++ addr.sin_addr=dst_addr.sa_addr.pptp.sin_addr;
++ addr.sin_family=AF_INET;
++ addr.sin_port=htons(1700);
++ sock=socket(AF_INET,SOCK_DGRAM,0);
++ if (connect(sock,(struct sockaddr*)&addr,sizeof(addr)))
++ {
++ close(sock);
++ error("PPTP: connect failed (%s)\n",strerror(errno));
++ return -1;
++ }
++ getsockname(sock,(struct sockaddr*)&addr,&len);
++ src_addr.sa_addr.pptp.sin_addr=addr.sin_addr;
++ close(sock);
++ }
++
++ src_addr.sa_family=AF_PPPOX;
++ src_addr.sa_protocol=PX_PROTO_PPTP;
++ src_addr.sa_addr.pptp.call_id=0;
++
++ dst_addr.sa_family=AF_PPPOX;
++ dst_addr.sa_protocol=PX_PROTO_PPTP;
++ dst_addr.sa_addr.pptp.call_id=0;
++
++ pptp_fd=socket(AF_PPPOX,SOCK_STREAM,PX_PROTO_PPTP);
++ if (pptp_fd<0)
++ {
++ error("PPTP: failed to create PPTP socket (%s)\n",strerror(errno));
++ return -1;
++ }
++ if (bind(pptp_fd,(struct sockaddr*)&src_addr,sizeof(src_addr)))
++ {
++ close(pptp_fd);
++ error("PPTP: failed to bind PPTP socket (%s)\n",strerror(errno));
++ return -1;
++ }
++ len=sizeof(src_addr);
++ getsockname(pptp_fd,(struct sockaddr*)&src_addr,&len);
++ call_ID=src_addr.sa_addr.pptp.call_id;
++
++ do {
++ /*
++ * Open connection to call manager (Launch call manager if necessary.)
++ */
++ callmgr_sock = open_callmgr(src_addr.sa_addr.pptp.call_id,dst_addr.sa_addr.pptp.sin_addr, pptp_phone, pptp_window);
++ if (callmgr_sock<0)
++ {
++ close(pptp_fd);
++ return -1;
++ }
++ /* Exchange PIDs, get call ID */
++ } while (get_call_id(callmgr_sock, getpid(), getpid(), &dst_addr.sa_addr.pptp.call_id) < 0);
++
++ if (connect(pptp_fd,(struct sockaddr*)&dst_addr,sizeof(dst_addr)))
++ {
++ close(callmgr_sock);
++ close(pptp_fd);
++ error("PPTP: failed to connect PPTP socket (%s)\n",strerror(errno));
++ return -1;
++ }
++
++ sprintf(ppp_devnam,"pptp (%s)",pptp_server);
++
++ return pptp_fd;
++}
++static int pptp_connect(void)
++{
++ if ((!pptp_server && !pptp_client) || (pptp_server && pptp_client))
++ {
++ fatal("PPTP: unknown mode (you must specify pptp_server or pptp_client option)");
++ return -1;
++ }
++
++ if (pptp_server) return pptp_start_client();
++ return pptp_start_server();
++}
++
++static void pptp_disconnect(void)
++{
++ if (pptp_server) close(callmgr_sock);
++ close(pptp_fd);
++}
++
++static int open_callmgr(int call_id,struct in_addr inetaddr, char *phonenr,int window)
++{
++ /* Try to open unix domain socket to call manager. */
++ struct sockaddr_un where;
++ const int NUM_TRIES = 3;
++ int i, fd;
++ pid_t pid;
++ int status;
++ /* Open socket */
++ if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
++ {
++ fatal("Could not create unix domain socket: %s", strerror(errno));
++ }
++ /* Make address */
++ callmgr_name_unixsock(&where, inetaddr, localbind);
++ for (i = 0; i < NUM_TRIES; i++)
++ {
++ if (connect(fd, (struct sockaddr *) &where, sizeof(where)) < 0)
++ {
++ /* couldn't connect. We'll have to launch this guy. */
++
++ unlink (where.sun_path);
++
++ /* fork and launch call manager process */
++ switch (pid = fork())
++ {
++ case -1: /* failure */
++ fatal("fork() to launch call manager failed.");
++ case 0: /* child */
++ {
++ /* close the pty and gre in the call manager */
++ close(fd);
++ close(pptp_fd);
++ launch_callmgr(call_id,inetaddr,phonenr,window);
++ }
++ default: /* parent */
++ waitpid(pid, &status, 0);
++ if (status!= 0)
++ {
++ close(fd);
++ error("Call manager exited with error %d", status);
++ return -1;
++ }
++ break;
++ }
++ sleep(1);
++ }
++ else return fd;
++ }
++ close(fd);
++ error("Could not launch call manager after %d tries.", i);
++ return -1; /* make gcc happy */
++}
++
++/*** call the call manager main ***********************************************/
++static void launch_callmgr(int call_id,struct in_addr inetaddr, char *phonenr,int window)
++{
++ dbglog("pptp: call manager for %s\n", inet_ntoa(inetaddr));
++ dbglog("window size:\t%d\n",window);
++ if (phonenr) dbglog("phone number:\t'%s'\n",phonenr);
++ dbglog("call id:\t%d\n",call_id);
++ exit(callmgr_main(inetaddr, phonenr, window, call_id));
++}
++
++/*** exchange data with the call manager *************************************/
++/* XXX need better error checking XXX */
++static int get_call_id(int sock, pid_t gre, pid_t pppd,
++ u_int16_t *peer_call_id)
++{
++ u_int16_t m_call_id, m_peer_call_id;
++ /* write pid's to socket */
++ /* don't bother with network byte order, because pid's are meaningless
++ * outside the local host.
++ */
++ int rc;
++ rc = write(sock, &gre, sizeof(gre));
++ if (rc != sizeof(gre))
++ return -1;
++ rc = write(sock, &pppd, sizeof(pppd));
++ if (rc != sizeof(pppd))
++ return -1;
++ rc = read(sock, &m_call_id, sizeof(m_call_id));
++ if (rc != sizeof(m_call_id))
++ return -1;
++ rc = read(sock, &m_peer_call_id, sizeof(m_peer_call_id));
++ if (rc != sizeof(m_peer_call_id))
++ return -1;
++ /*
++ * XXX FIXME ... DO ERROR CHECKING & TIME-OUTS XXX
++ * (Rhialto: I am assuming for now that timeouts are not relevant
++ * here, because the read and write calls would return -1 (fail) when
++ * the peer goes away during the process. We know it is (or was)
++ * running because the connect() call succeeded.)
++ * (James: on the other hand, if the route to the peer goes away, we
++ * wouldn't get told by read() or write() for quite some time.)
++ */
++ *peer_call_id = m_peer_call_id;
++ return 0;
++}
++
++void plugin_init(void)
++{
++ add_options(Options);
++
++ info("PPTP plugin version %s", PPTP_VERSION);
++
++ the_channel = &pptp_channel;
++ modem = 0;
++}
+--- /dev/null
++++ b/pppd/plugins/pptp/pptp_callmgr.c
+@@ -0,0 +1,381 @@
++/* pptp_callmgr.c ... Call manager for PPTP connections.
++ * Handles TCP port 1723 protocol.
++ * C. Scott Ananian <cananian@alumni.princeton.edu>
++ *
++ * $Id: pptp_callmgr.c,v 1.20 2005/03/31 07:42:39 quozl Exp $
++ */
++#include <signal.h>
++#include <sys/time.h>
++#include <sys/types.h>
++#include <sys/stat.h>
++#include <sys/socket.h>
++#include <netinet/in.h>
++#include <arpa/inet.h>
++#include <sys/un.h>
++#include <unistd.h>
++#include <stdlib.h>
++#include <string.h>
++#include <assert.h>
++#include <setjmp.h>
++#include <stdio.h>
++#include <errno.h>
++#include "pptp_callmgr.h"
++#include "pptp_ctrl.h"
++#include "pptp_msg.h"
++#include "dirutil.h"
++#include "vector.h"
++#include "util.h"
++#include "pppd.h"
++
++extern struct in_addr localbind; /* from pptp.c */
++extern int call_ID;
++
++int open_inetsock(struct in_addr inetaddr);
++int open_unixsock(struct in_addr inetaddr);
++void close_inetsock(int fd, struct in_addr inetaddr);
++void close_unixsock(int fd, struct in_addr inetaddr);
++
++sigjmp_buf callmgr_env;
++
++void callmgr_sighandler(int sig) {
++ /* TODO: according to signal(2), siglongjmp() is unsafe used here */
++ siglongjmp (callmgr_env, 1);
++}
++
++void callmgr_do_nothing(int sig) {
++ /* do nothing signal handler */
++}
++
++struct local_callinfo {
++ int unix_sock;
++ pid_t pid[2];
++};
++
++struct local_conninfo {
++ VECTOR * call_list;
++ fd_set * call_set;
++};
++
++/* Call callback */
++void call_callback(PPTP_CONN *conn, PPTP_CALL *call, enum call_state state)
++{
++ struct local_callinfo *lci;
++ struct local_conninfo *conninfo;
++ u_int16_t call_id[2];
++ switch(state) {
++ case CALL_OPEN_DONE:
++ /* okey dokey. This means that the call_id and peer_call_id are
++ * now valid, so lets send them on to our friends who requested
++ * this call. */
++ lci = pptp_call_closure_get(conn, call); assert(lci != NULL);
++ pptp_call_get_ids(conn, call, &call_id[0], &call_id[1]);
++ write(lci->unix_sock, &call_id, sizeof(call_id));
++ /* Our duty to the fatherland is now complete. */
++ break;
++ case CALL_OPEN_FAIL:
++ case CALL_CLOSE_RQST:
++ case CALL_CLOSE_DONE:
++ /* don't need to do anything here, except make sure tables
++ * are sync'ed */
++ dbglog("Closing connection (call state)");
++ conninfo = pptp_conn_closure_get(conn);
++ lci = pptp_call_closure_get(conn, call);
++ assert(lci != NULL && conninfo != NULL);
++ if (vector_contains(conninfo->call_list, lci->unix_sock)) {
++ vector_remove(conninfo->call_list, lci->unix_sock);
++ close(lci->unix_sock);
++ FD_CLR(lci->unix_sock, conninfo->call_set);
++ }
++ break;
++ default:
++ dbglog("Unhandled call callback state [%d].", (int) state);
++ break;
++ }
++}
++
++/******************************************************************************
++ * NOTE ABOUT 'VOLATILE':
++ * several variables here get a volatile qualifier to silence warnings
++ * from older (before 3.0) gccs. if the longjmp stuff is removed,
++ * the volatile qualifiers should be removed as well.
++ *****************************************************************************/
++
++/*** Call Manager *************************************************************/
++int callmgr_main(struct in_addr inetaddr, char phonenr[], int window, int pcallid)
++{
++ int inet_sock, unix_sock;
++ fd_set call_set;
++ PPTP_CONN * conn;
++ VECTOR * call_list;
++ int max_fd = 0;
++ volatile int first = 1;
++ int retval;
++ int i;
++ if (pcallid>0) call_ID=pcallid;
++
++ /* Step 1: Open sockets. */
++ if ((inet_sock = open_inetsock(inetaddr)) < 0)
++ fatal("Could not open control connection to %s", inet_ntoa(inetaddr));
++ dbglog("control connection");
++ if ((unix_sock = open_unixsock(inetaddr)) < 0)
++ fatal("Could not open unix socket for %s", inet_ntoa(inetaddr));
++ /* Step 1b: FORK and return status to calling process. */
++ dbglog("unix_sock");
++
++ switch (fork()) {
++ case 0: /* child. stick around. */
++ break;
++ case -1: /* failure. Fatal. */
++ fatal("Could not fork.");
++ default: /* Parent. Return status to caller. */
++ exit(0);
++ }
++ /* re-open stderr as /dev/null to release it */
++ file2fd("/dev/null", "wb", STDERR_FILENO);
++ /* Step 1c: Clean up unix socket on TERM */
++ if (sigsetjmp(callmgr_env, 1) != 0)
++ goto cleanup;
++ signal(SIGINT, callmgr_sighandler);
++ signal(SIGTERM, callmgr_sighandler);
++ signal(SIGPIPE, callmgr_do_nothing);
++ signal(SIGUSR1, callmgr_do_nothing); /* signal state change
++ wake up accept */
++ /* Step 2: Open control connection and register callback */
++ if ((conn = pptp_conn_open(inet_sock, 1, NULL/* callback */)) == NULL) {
++ close(unix_sock); close(inet_sock); fatal("Could not open connection.");
++ }
++ FD_ZERO(&call_set);
++ call_list = vector_create();
++ {
++ struct local_conninfo *conninfo = malloc(sizeof(*conninfo));
++ if (conninfo == NULL) {
++ close(unix_sock); close(inet_sock); fatal("No memory.");
++ }
++ conninfo->call_list = call_list;
++ conninfo->call_set = &call_set;
++ pptp_conn_closure_put(conn, conninfo);
++ }
++ if (sigsetjmp(callmgr_env, 1) != 0) goto shutdown;
++ /* Step 3: Get FD_SETs */
++ max_fd = unix_sock;
++ do {
++ int rc;
++ fd_set read_set = call_set, write_set;
++ FD_ZERO (&write_set);
++ if (pptp_conn_established(conn)) {
++ FD_SET (unix_sock, &read_set);
++ if (unix_sock > max_fd) max_fd = unix_sock;
++ }
++ pptp_fd_set(conn, &read_set, &write_set, &max_fd);
++ for (; max_fd > 0 ; max_fd--) {
++ if (FD_ISSET (max_fd, &read_set) ||
++ FD_ISSET (max_fd, &write_set))
++ break;
++ }
++ /* Step 4: Wait on INET or UNIX event */
++ if ((rc = select(max_fd + 1, &read_set, &write_set, NULL, NULL)) <0) {
++ if (errno == EBADF) break;
++ /* a signal or somesuch. */
++ continue;
++ }
++ /* Step 5a: Handle INET events */
++ rc = pptp_dispatch(conn, &read_set, &write_set);
++ if (rc < 0)
++ break;
++ /* Step 5b: Handle new connection to UNIX socket */
++ if (FD_ISSET(unix_sock, &read_set)) {
++ /* New call! */
++ struct sockaddr_un from;
++ int len = sizeof(from);
++ PPTP_CALL * call;
++ struct local_callinfo *lci;
++ int s;
++ /* Accept the socket */
++ FD_CLR (unix_sock, &read_set);
++ if ((s = accept(unix_sock, (struct sockaddr *) &from, &len)) < 0) {
++ warn("Socket not accepted: %s", strerror(errno));
++ goto skip_accept;
++ }
++ /* Allocate memory for local call information structure. */
++ if ((lci = malloc(sizeof(*lci))) == NULL) {
++ warn("Out of memory."); close(s); goto skip_accept;
++ }
++ lci->unix_sock = s;
++ /* Give the initiator time to write the PIDs while we open
++ * the call */
++ call = pptp_call_open(conn, call_ID,call_callback, phonenr,window);
++ /* Read and store the associated pids */
++ read(s, &lci->pid[0], sizeof(lci->pid[0]));
++ read(s, &lci->pid[1], sizeof(lci->pid[1]));
++ /* associate the local information with the call */
++ pptp_call_closure_put(conn, call, (void *) lci);
++ /* The rest is done on callback. */
++ /* Keep alive; wait for close */
++ retval = vector_insert(call_list, s, call); assert(retval);
++ if (s > max_fd) max_fd = s;
++ FD_SET(s, &call_set);
++ first = 0;
++ }
++skip_accept: /* Step 5c: Handle socket close */
++ for (i = 0; i < max_fd + 1; i++)
++ if (FD_ISSET(i, &read_set)) {
++ /* close it */
++ PPTP_CALL * call;
++ retval = vector_search(call_list, i, &call);
++ if (retval) {
++ struct local_callinfo *lci =
++ pptp_call_closure_get(conn, call);
++ dbglog("Closing connection (unhandled)");
++ free(lci);
++ /* soft shutdown. Callback will do hard shutdown later */
++ pptp_call_close(conn, call);
++ vector_remove(call_list, i);
++ }
++ FD_CLR(i, &call_set);
++ close(i);
++ }
++ } while (vector_size(call_list) > 0 || first);
++shutdown:
++ {
++ int rc;
++ fd_set read_set, write_set;
++ struct timeval tv;
++ signal(SIGINT, callmgr_do_nothing);
++ signal(SIGTERM, callmgr_do_nothing);
++ /* warn("Shutdown"); */
++ /* kill all open calls */
++ for (i = 0; i < vector_size(call_list); i++) {
++ PPTP_CALL *call = vector_get_Nth(call_list, i);
++ dbglog("Closing connection (shutdown)");
++ pptp_call_close(conn, call);
++ }
++ /* attempt to dispatch these messages */
++ FD_ZERO(&read_set);
++ FD_ZERO(&write_set);
++ pptp_fd_set(conn, &read_set, &write_set, &max_fd);
++ tv.tv_sec = 0;
++ tv.tv_usec = 0;
++ select(max_fd + 1, &read_set, &write_set, NULL, &tv);
++ rc = pptp_dispatch(conn, &read_set, &write_set);
++ if (rc > 0) {
++ /* wait for a respond, a timeout because there might not be one */
++ FD_ZERO(&read_set);
++ FD_ZERO(&write_set);
++ pptp_fd_set(conn, &read_set, &write_set, &max_fd);
++ tv.tv_sec = 2;
++ tv.tv_usec = 0;
++ select(max_fd + 1, &read_set, &write_set, NULL, &tv);
++ rc = pptp_dispatch(conn, &read_set, &write_set);
++ if (rc > 0) {
++ if (i > 0) sleep(2);
++ /* no more open calls. Close the connection. */
++ pptp_conn_close(conn, PPTP_STOP_LOCAL_SHUTDOWN);
++ /* wait for a respond, a timeout because there might not be one */
++ FD_ZERO(&read_set);
++ FD_ZERO(&write_set);
++ pptp_fd_set(conn, &read_set, &write_set, &max_fd);
++ tv.tv_sec = 2;
++ tv.tv_usec = 0;
++ select(max_fd + 1, &read_set, &write_set, NULL, &tv);
++ pptp_dispatch(conn, &read_set, &write_set);
++ if (rc > 0) sleep(2);
++ }
++ }
++ /* with extreme prejudice */
++ pptp_conn_destroy(conn);
++ vector_destroy(call_list);
++ }
++cleanup:
++ signal(SIGINT, callmgr_do_nothing);
++ signal(SIGTERM, callmgr_do_nothing);
++ close_inetsock(inet_sock, inetaddr);
++ close_unixsock(unix_sock, inetaddr);
++ return 0;
++}
++
++/*** open_inetsock ************************************************************/
++int open_inetsock(struct in_addr inetaddr)
++{
++ struct sockaddr_in dest, src;
++ int s;
++ dest.sin_family = AF_INET;
++ dest.sin_port = htons(PPTP_PORT);
++ dest.sin_addr = inetaddr;
++ if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
++ warn("socket: %s", strerror(errno));
++ return s;
++ }
++ if (localbind.s_addr != INADDR_NONE) {
++ bzero(&src, sizeof(src));
++ src.sin_family = AF_INET;
++ src.sin_addr = localbind;
++ if (bind(s, (struct sockaddr *) &src, sizeof(src)) != 0) {
++ warn("bind: %s", strerror(errno));
++ close(s); return -1;
++ }
++ }
++ if (connect(s, (struct sockaddr *) &dest, sizeof(dest)) < 0) {
++ warn("connect: %s", strerror(errno));
++ close(s); return -1;
++ }
++ return s;
++}
++
++/*** open_unixsock ************************************************************/
++int open_unixsock(struct in_addr inetaddr)
++{
++ struct sockaddr_un where;
++ struct stat st;
++ char *dir;
++ int s;
++ if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
++ warn("socket: %s", strerror(errno));
++ return s;
++ }
++ callmgr_name_unixsock( &where, inetaddr, localbind);
++ if (stat(where.sun_path, &st) >= 0)
++ {
++ warn("Call manager for %s is already running.", inet_ntoa(inetaddr));
++ close(s); return -1;
++ }
++ /* Make sure path is valid. */
++ dir = dirnamex(where.sun_path);
++ if (!make_valid_path(dir, 0770))
++ fatal("Could not make path to %s: %s", where.sun_path, strerror(errno));
++ free(dir);
++ if (bind(s, (struct sockaddr *) &where, sizeof(where)) < 0) {
++ warn("bind: %s", strerror(errno));
++ close(s); return -1;
++ }
++ chmod(where.sun_path, 0777);
++ listen(s, 127);
++ return s;
++}
++
++/*** close_inetsock ***********************************************************/
++void close_inetsock(int fd, struct in_addr inetaddr)
++{
++ close(fd);
++}
++
++/*** close_unixsock ***********************************************************/
++void close_unixsock(int fd, struct in_addr inetaddr)
++{
++ struct sockaddr_un where;
++ close(fd);
++ callmgr_name_unixsock(&where, inetaddr, localbind);
++ unlink(where.sun_path);
++}
++
++/*** make a unix socket address ***********************************************/
++void callmgr_name_unixsock(struct sockaddr_un *where,
++ struct in_addr inetaddr,
++ struct in_addr localbind)
++{
++ char localaddr[16], remoteaddr[16];
++ where->sun_family = AF_UNIX;
++ strncpy(localaddr, inet_ntoa(localbind), 16);
++ strncpy(remoteaddr, inet_ntoa(inetaddr), 16);
++ snprintf(where->sun_path, sizeof(where->sun_path),
++ PPTP_SOCKET_PREFIX "%s:%i", remoteaddr,call_ID);
++}
+--- /dev/null
++++ b/pppd/plugins/pptp/pptp_callmgr.h
+@@ -0,0 +1,17 @@
++/* pptp_callmgr.h ... Call manager for PPTP connections.
++ * Handles TCP port 1723 protocol.
++ * C. Scott Ananian <cananian@alumni.princeton.edu>
++ *
++ * $Id: pptp_callmgr.h,v 1.3 2003/02/17 00:22:17 quozl Exp $
++ */
++
++#define PPTP_SOCKET_PREFIX "/var/run/pptp/"
++
++int callmgr_main(struct in_addr inetaddr,
++ char phonenr[],
++ int window,
++ int pcallid);
++
++void callmgr_name_unixsock(struct sockaddr_un *where,
++ struct in_addr inetaddr,
++ struct in_addr localbind);
+--- /dev/null
++++ b/pppd/plugins/pptp/pptp_ctrl.c
+@@ -0,0 +1,1077 @@
++/* pptp_ctrl.c ... handle PPTP control connection.
++ * C. Scott Ananian <cananian@alumni.princeton.edu>
++ *
++ * $Id: pptp_ctrl.c,v 1.31 2005/03/31 07:42:39 quozl Exp $
++ */
++
++#include <errno.h>
++#include <sys/time.h>
++#include <sys/types.h>
++#include <sys/socket.h>
++#include <netinet/in.h>
++#include <unistd.h>
++#include <stdlib.h>
++#include <assert.h>
++#include <signal.h>
++#include <string.h>
++#include <ctype.h>
++#include <fcntl.h>
++#include "pptp_msg.h"
++#include "pptp_ctrl.h"
++#include "pptp_options.h"
++#include "vector.h"
++#include "util.h"
++#include "pptp_quirks.h"
++
++/* BECAUSE OF SIGNAL LIMITATIONS, EACH PROCESS CAN ONLY MANAGE ONE
++ * CONNECTION. SO THIS 'PPTP_CONN' STRUCTURE IS A BIT MISLEADING.
++ * WE'LL KEEP CONNECTION-SPECIFIC INFORMATION IN THERE ANYWAY (AS
++ * OPPOSED TO USING GLOBAL VARIABLES), BUT BEWARE THAT THE ENTIRE
++ * UNIX SIGNAL-HANDLING SEMANTICS WOULD HAVE TO CHANGE (OR THE
++ * TIME-OUT CODE DRASTICALLY REWRITTEN) BEFORE YOU COULD DO A
++ * PPTP_CONN_OPEN MORE THAN ONCE PER PROCESS AND GET AWAY WITH IT.
++ */
++
++/* This structure contains connection-specific information that the
++ * signal handler needs to see. Thus, it needs to be in a global
++ * variable. If you end up using pthreads or something (why not
++ * just processes?), this would have to be placed in a thread-specific
++ * data area, using pthread_get|set_specific, etc., so I've
++ * conveniently encapsulated it for you.
++ * [linux threads will have to support thread-specific signals
++ * before this would work at all, which, as of this writing
++ * (linux-threads v0.6, linux kernel 2.1.72), it does not.]
++ */
++
++/* Globals */
++
++/* control the number of times echo packets will be logged */
++static int nlogecho = 10;
++
++static struct thread_specific {
++ struct sigaction old_sigaction; /* evil signals */
++ PPTP_CONN * conn;
++} global;
++
++#define INITIAL_BUFSIZE 512 /* initial i/o buffer size. */
++
++struct PPTP_CONN {
++ int inet_sock;
++ /* Connection States */
++ enum {
++ CONN_IDLE, CONN_WAIT_CTL_REPLY, CONN_WAIT_STOP_REPLY, CONN_ESTABLISHED
++ } conn_state; /* on startup: CONN_IDLE */
++ /* Keep-alive states */
++ enum {
++ KA_NONE, KA_OUTSTANDING
++ } ka_state; /* on startup: KA_NONE */
++ /* Keep-alive ID; monotonically increasing (watch wrap-around!) */
++ u_int32_t ka_id; /* on startup: 1 */
++ /* Other properties. */
++ u_int16_t version;
++ u_int16_t firmware_rev;
++ u_int8_t hostname[64], vendor[64];
++ /* XXX these are only PNS properties, currently XXX */
++ /* Call assignment information. */
++ u_int16_t call_serial_number;
++ VECTOR *call;
++ void * closure;
++ pptp_conn_cb callback;
++ /******* IO buffers ******/
++ char * read_buffer, *write_buffer;
++ size_t read_alloc, write_alloc;
++ size_t read_size, write_size;
++};
++
++struct PPTP_CALL {
++ /* Call properties */
++ enum {
++ PPTP_CALL_PAC, PPTP_CALL_PNS
++ } call_type;
++ union {
++ enum pptp_pac_state {
++ PAC_IDLE, PAC_WAIT_REPLY, PAC_ESTABLISHED, PAC_WAIT_CS_ANS
++ } pac;
++ enum pptp_pns_state {
++ PNS_IDLE, PNS_WAIT_REPLY, PNS_ESTABLISHED, PNS_WAIT_DISCONNECT
++ } pns;
++ } state;
++ u_int16_t call_id, peer_call_id;
++ u_int16_t sernum;
++ u_int32_t speed;
++ /* For user data: */
++ pptp_call_cb callback;
++ void * closure;
++};
++
++
++/* PPTP error codes: ----------------------------------------------*/
++
++/* (General Error Codes) */
++static const struct {
++ const char *name, *desc;
++} pptp_general_errors[] = {
++#define PPTP_GENERAL_ERROR_NONE 0
++ { "(None)", "No general error" },
++#define PPTP_GENERAL_ERROR_NOT_CONNECTED 1
++ { "(Not-Connected)", "No control connection exists yet for this "
++ "PAC-PNS pair" },
++#define PPTP_GENERAL_ERROR_BAD_FORMAT 2
++ { "(Bad-Format)", "Length is wrong or Magic Cookie value is incorrect" },
++#define PPTP_GENERAL_ERROR_BAD_VALUE 3
++ { "(Bad-Value)", "One of the field values was out of range or "
++ "reserved field was non-zero" },
++#define PPTP_GENERAL_ERROR_NO_RESOURCE 4
++ { "(No-Resource)", "Insufficient resources to handle this command now" },
++#define PPTP_GENERAL_ERROR_BAD_CALLID 5
++ { "(Bad-Call ID)", "The Call ID is invalid in this context" },
++#define PPTP_GENERAL_ERROR_PAC_ERROR 6
++ { "(PAC-Error)", "A generic vendor-specific error occured in the PAC" }
++};
++
++#define MAX_GENERAL_ERROR ( sizeof(pptp_general_errors) / \
++ sizeof(pptp_general_errors[0]) - 1)
++
++/* Outgoing Call Reply Result Codes */
++static const char *pptp_out_call_reply_result[] = {
++/* 0 */ "Unknown Result Code",
++/* 1 */ "Connected",
++/* 2 */ "General Error",
++/* 3 */ "No Carrier Detected",
++/* 4 */ "Busy Signal",
++/* 5 */ "No Dial Tone",
++/* 6 */ "Time Out",
++/* 7 */ "Not Accepted, Call is administratively prohibited" };
++
++#define MAX_OUT_CALL_REPLY_RESULT 7
++
++/* Call Disconnect Notify Result Codes */
++static const char *pptp_call_disc_ntfy[] = {
++/* 0 */ "Unknown Result Code",
++/* 1 */ "Lost Carrier",
++/* 2 */ "General Error",
++/* 3 */ "Administrative Shutdown",
++/* 4 */ "(your) Request" };
++
++#define MAX_CALL_DISC_NTFY 4
++
++/* Call Disconnect Notify Result Codes */
++static const char *pptp_start_ctrl_conn_rply[] = {
++/* 0 */ "Unknown Result Code",
++/* 1 */ "Successful Channel Establishment",
++/* 2 */ "General Error",
++/* 3 */ "Command Channel Already Exists",
++/* 4 */ "Requester is not Authorized" };
++
++#define MAX_START_CTRL_CONN_REPLY 4
++
++/* timing options */
++int idle_wait = PPTP_TIMEOUT;
++int max_echo_wait = PPTP_TIMEOUT;
++
++/* Local prototypes */
++static void pptp_reset_timer(void);
++static void pptp_handle_timer();
++/* Write/read as much as we can without blocking. */
++int pptp_write_some(PPTP_CONN * conn);
++int pptp_read_some(PPTP_CONN * conn);
++/* Make valid packets from read_buffer */
++int pptp_make_packet(PPTP_CONN * conn, void **buf, size_t *size);
++/* Add packet to write_buffer */
++int pptp_send_ctrl_packet(PPTP_CONN * conn, void * buffer, size_t size);
++/* Dispatch packets (general) */
++int pptp_dispatch_packet(PPTP_CONN * conn, void * buffer, size_t size);
++/* Dispatch packets (control messages) */
++int ctrlp_disp(PPTP_CONN * conn, void * buffer, size_t size);
++/* Set link info, for pptp servers that need it.
++ this is a noop, unless the user specified a quirk and
++ there's a set_link hook defined in the quirks table
++ for that quirk */
++void pptp_set_link(PPTP_CONN * conn, int peer_call_id);
++
++/*** log error information in control packets *********************************/
++static void ctrlp_error( int result, int error, int cause,
++ const char *result_text[], int max_result)
++{
++ if( cause >= 0)
++ warn("Result code is %d '%s'. Error code is %d, Cause code is %d",
++ result, result_text[result <= max_result ? result : 0], error,
++ cause );
++ else
++ warn("Reply result code is %d '%s'. Error code is %d",
++ result, result_text[result <= max_result ? result : 0], error);
++ if ((error > 0) && (error <= MAX_GENERAL_ERROR)){
++ if( result != PPTP_RESULT_GENERAL_ERROR )
++ warn("Result code is something else then \"general error\", "
++ "so the following error is probably bogus.");
++ warn("Error is '%s', Error message: '%s'",
++ pptp_general_errors[error].name,
++ pptp_general_errors[error].desc);
++ }
++}
++
++static const char *ctrl_msg_types[] = {
++ "invalid control message type",
++/* (Control Connection Management) */
++ "Start-Control-Connection-Request", /* 1 */
++ "Start-Control-Connection-Reply", /* 2 */
++ "Stop-Control-Connection-Request", /* 3 */
++ "Stop-Control-Connection-Reply", /* 4 */
++ "Echo-Request", /* 5 */
++ "Echo-Reply", /* 6 */
++/* (Call Management) */
++ "Outgoing-Call-Request", /* 7 */
++ "Outgoing-Call-Reply", /* 8 */
++ "Incoming-Call-Request", /* 9 */
++ "Incoming-Call-Reply", /* 10 */
++ "Incoming-Call-Connected", /* 11 */
++ "Call-Clear-Request", /* 12 */
++ "Call-Disconnect-Notify", /* 13 */
++/* (Error Reporting) */
++ "WAN-Error-Notify", /* 14 */
++/* (PPP Session Control) */
++ "Set-Link-Info" /* 15 */
++};
++#define MAX_CTRLMSG_TYPE 15
++
++/*** report a sent packet ****************************************************/
++static void ctrlp_rep( void * buffer, int size, int isbuff)
++{
++ struct pptp_header *packet = buffer;
++ unsigned int type;
++ if(size < sizeof(struct pptp_header)) return;
++ type = ntoh16(packet->ctrl_type);
++ /* FIXME: do not report sending echo requests as long as they are
++ * sent in a signal handler. This may dead lock as the syslog call
++ * is not reentrant */
++ if( type == PPTP_ECHO_RQST ) return;
++ /* don't keep reporting sending of echo's */
++ if( (type == PPTP_ECHO_RQST || type == PPTP_ECHO_RPLY) && nlogecho <= 0 ) return;
++ dbglog("%s control packet type is %d '%s'\n",isbuff ? "Buffered" : "Sent",
++ type, ctrl_msg_types[type <= MAX_CTRLMSG_TYPE ? type : 0]);
++
++}
++
++
++
++/* Open new pptp_connection. Returns NULL on failure. */
++PPTP_CONN * pptp_conn_open(int inet_sock, int isclient, pptp_conn_cb callback)
++{
++ PPTP_CONN *conn;
++ /* Allocate structure */
++ if ((conn = malloc(sizeof(*conn))) == NULL) return NULL;
++ if ((conn->call = vector_create()) == NULL) { free(conn); return NULL; }
++ /* Initialize */
++ conn->inet_sock = inet_sock;
++ conn->conn_state = CONN_IDLE;
++ conn->ka_state = KA_NONE;
++ conn->ka_id = 1;
++ conn->call_serial_number = 0;
++ conn->callback = callback;
++ /* Create I/O buffers */
++ conn->read_size = conn->write_size = 0;
++ conn->read_alloc = conn->write_alloc = INITIAL_BUFSIZE;
++ conn->read_buffer =
++ malloc(sizeof(*(conn->read_buffer)) * conn->read_alloc);
++ conn->write_buffer =
++ malloc(sizeof(*(conn->write_buffer)) * conn->write_alloc);
++ if (conn->read_buffer == NULL || conn->write_buffer == NULL) {
++ if (conn->read_buffer != NULL) free(conn->read_buffer);
++ if (conn->write_buffer != NULL) free(conn->write_buffer);
++ vector_destroy(conn->call); free(conn); return NULL;
++ }
++ /* Make this socket non-blocking. */
++ fcntl(conn->inet_sock, F_SETFL, O_NONBLOCK);
++ /* Request connection from server, if this is a client */
++ if (isclient) {
++ struct pptp_start_ctrl_conn packet = {
++ PPTP_HEADER_CTRL(PPTP_START_CTRL_CONN_RQST),
++ hton16(PPTP_VERSION), 0, 0,
++ hton32(PPTP_FRAME_CAP), hton32(PPTP_BEARER_CAP),
++ hton16(PPTP_MAX_CHANNELS), hton16(PPTP_FIRMWARE_VERSION),
++ PPTP_HOSTNAME, PPTP_VENDOR
++ };
++ /* fix this packet, if necessary */
++ int idx, rc;
++ idx = get_quirk_index();
++ if (idx != -1 && pptp_fixups[idx].start_ctrl_conn) {
++ if ((rc = pptp_fixups[idx].start_ctrl_conn(&packet)))
++ warn("calling the start_ctrl_conn hook failed (%d)", rc);
++ }
++ if (pptp_send_ctrl_packet(conn, &packet, sizeof(packet)))
++ conn->conn_state = CONN_WAIT_CTL_REPLY;
++ else
++ return NULL; /* could not send initial start request. */
++ }
++ /* Set up interval/keep-alive timer */
++ /* First, register handler for SIGALRM */
++ sigpipe_create();
++ sigpipe_assign(SIGALRM);
++ global.conn = conn;
++ /* Reset event timer */
++ pptp_reset_timer();
++ /* all done. */
++ return conn;
++}
++
++int pptp_conn_established(PPTP_CONN *conn) {
++ return (conn->conn_state == CONN_ESTABLISHED);
++}
++
++/* This currently *only* works for client call requests.
++ * We need to do something else to allocate calls for incoming requests.
++ */
++PPTP_CALL * pptp_call_open(PPTP_CONN * conn, int call_id,pptp_call_cb callback,
++ char *phonenr,int window)
++{
++ PPTP_CALL * call;
++ int idx, rc;
++ /* Send off the call request */
++ struct pptp_out_call_rqst packet = {
++ PPTP_HEADER_CTRL(PPTP_OUT_CALL_RQST),
++ 0,0, /*call_id, sernum */
++ hton32(PPTP_BPS_MIN), hton32(PPTP_BPS_MAX),
++ hton32(PPTP_BEARER_CAP), hton32(PPTP_FRAME_CAP),
++ hton16(window), 0, 0, 0, {0}, {0}
++ };
++ assert(conn && conn->call);
++ assert(conn->conn_state == CONN_ESTABLISHED);
++ /* Assign call id */
++ if (!call_id && !vector_scan(conn->call, 0, PPTP_MAX_CHANNELS - 1, &call_id))
++ /* no more calls available! */
++ return NULL;
++ /* allocate structure. */
++ if ((call = malloc(sizeof(*call))) == NULL) return NULL;
++ /* Initialize call structure */
++ call->call_type = PPTP_CALL_PNS;
++ call->state.pns = PNS_IDLE;
++ call->call_id = (u_int16_t) call_id;
++ call->sernum = conn->call_serial_number++;
++ call->callback = callback;
++ call->closure = NULL;
++ packet.call_id = htons(call->call_id);
++ packet.call_sernum = htons(call->sernum);
++ /* if we have a quirk, build a new packet to fit it */
++ idx = get_quirk_index();
++ if (idx != -1 && pptp_fixups[idx].out_call_rqst_hook) {
++ if ((rc = pptp_fixups[idx].out_call_rqst_hook(&packet)))
++ warn("calling the out_call_rqst hook failed (%d)", rc);
++ }
++ /* fill in the phone number if it was specified */
++ if (phonenr) {
++ strncpy(packet.phone_num, phonenr, sizeof(packet.phone_num));
++ packet.phone_len = strlen(phonenr);
++ if( packet.phone_len > sizeof(packet.phone_num))
++ packet.phone_len = sizeof(packet.phone_num);
++ packet.phone_len = hton16 (packet.phone_len);
++ }
++ if (pptp_send_ctrl_packet(conn, &packet, sizeof(packet))) {
++ pptp_reset_timer();
++ call->state.pns = PNS_WAIT_REPLY;
++ /* and add it to the call vector */
++ vector_insert(conn->call, call_id, call);
++ return call;
++ } else { /* oops, unsuccessful. Deallocate. */
++ free(call);
++ return NULL;
++ }
++}
++
++/*** pptp_call_close **********************************************************/
++void pptp_call_close(PPTP_CONN * conn, PPTP_CALL * call)
++{
++ struct pptp_call_clear_rqst rqst = {
++ PPTP_HEADER_CTRL(PPTP_CALL_CLEAR_RQST), 0, 0
++ };
++ assert(conn && conn->call); assert(call);
++ assert(vector_contains(conn->call, call->call_id));
++ /* haven't thought about PAC yet */
++ assert(call->call_type == PPTP_CALL_PNS);
++ assert(call->state.pns != PNS_IDLE);
++ rqst.call_id = hton16(call->call_id);
++ /* don't check state against WAIT_DISCONNECT... allow multiple disconnect
++ * requests to be made.
++ */
++ pptp_send_ctrl_packet(conn, &rqst, sizeof(rqst));
++ pptp_reset_timer();
++ call->state.pns = PNS_WAIT_DISCONNECT;
++ /* call structure will be freed when we have confirmation of disconnect. */
++}
++
++/*** hard close ***************************************************************/
++void pptp_call_destroy(PPTP_CONN *conn, PPTP_CALL *call)
++{
++ assert(conn && conn->call); assert(call);
++ assert(vector_contains(conn->call, call->call_id));
++ /* notify */
++ if (call->callback != NULL) call->callback(conn, call, CALL_CLOSE_DONE);
++ /* deallocate */
++ vector_remove(conn->call, call->call_id);
++ free(call);
++}
++
++/*** this is a soft close *****************************************************/
++void pptp_conn_close(PPTP_CONN * conn, u_int8_t close_reason)
++{
++ struct pptp_stop_ctrl_conn rqst = {
++ PPTP_HEADER_CTRL(PPTP_STOP_CTRL_CONN_RQST),
++ hton8(close_reason), 0, 0
++ };
++ int i;
++ assert(conn && conn->call);
++ /* avoid repeated close attempts */
++ if (conn->conn_state == CONN_IDLE || conn->conn_state == CONN_WAIT_STOP_REPLY)
++ return;
++ /* close open calls, if any */
++ for (i = 0; i < vector_size(conn->call); i++)
++ pptp_call_close(conn, vector_get_Nth(conn->call, i));
++ /* now close connection */
++ info("Closing PPTP connection");
++ pptp_send_ctrl_packet(conn, &rqst, sizeof(rqst));
++ pptp_reset_timer(); /* wait 60 seconds for reply */
++ conn->conn_state = CONN_WAIT_STOP_REPLY;
++ return;
++}
++
++/*** this is a hard close *****************************************************/
++void pptp_conn_destroy(PPTP_CONN * conn)
++{
++ int i;
++ assert(conn != NULL); assert(conn->call != NULL);
++ /* destroy all open calls */
++ for (i = 0; i < vector_size(conn->call); i++)
++ pptp_call_destroy(conn, vector_get_Nth(conn->call, i));
++ /* notify */
++ if (conn->callback != NULL) conn->callback(conn, CONN_CLOSE_DONE);
++ sigpipe_close();
++ close(conn->inet_sock);
++ /* deallocate */
++ vector_destroy(conn->call);
++ free(conn);
++}
++
++/*** Deal with messages, in a non-blocking manner
++ * Add file descriptors used by pptp to fd_set.
++ */
++void pptp_fd_set(PPTP_CONN * conn, fd_set * read_set, fd_set * write_set,
++ int * max_fd)
++{
++ assert(conn && conn->call);
++ /* Add fd to write_set if there are outstanding writes. */
++ if (conn->write_size > 0)
++ FD_SET(conn->inet_sock, write_set);
++ /* Always add fd to read_set. (always want something to read) */
++ FD_SET(conn->inet_sock, read_set);
++ if (*max_fd < conn->inet_sock) *max_fd = conn->inet_sock;
++ /* Add signal pipe file descriptor to set */
++ int sig_fd = sigpipe_fd();
++ FD_SET(sig_fd, read_set);
++ if (*max_fd < sig_fd) *max_fd = sig_fd;
++}
++
++/*** handle any pptp file descriptors set in fd_set, and clear them ***********/
++int pptp_dispatch(PPTP_CONN * conn, fd_set * read_set, fd_set * write_set)
++{
++ int r = 0;
++ assert(conn && conn->call);
++ /* Check for signals */
++ if (FD_ISSET(sigpipe_fd(), read_set)) {
++ if (sigpipe_read() == SIGALRM) pptp_handle_timer();
++ FD_CLR(sigpipe_fd(), read_set);
++ }
++ /* Check write_set could be set. */
++ if (FD_ISSET(conn->inet_sock, write_set)) {
++ FD_CLR(conn->inet_sock, write_set);
++ if (conn->write_size > 0)
++ r = pptp_write_some(conn);/* write as much as we can without blocking */
++ }
++ /* Check read_set */
++ if (r >= 0 && FD_ISSET(conn->inet_sock, read_set)) {
++ void *buffer; size_t size;
++ FD_CLR(conn->inet_sock, read_set);
++ r = pptp_read_some(conn); /* read as much as we can without blocking */
++ if (r < 0)
++ return r;
++ /* make packets of the buffer, while we can. */
++ while (r >= 0 && pptp_make_packet(conn, &buffer, &size)) {
++ r = pptp_dispatch_packet(conn, buffer, size);
++ free(buffer);
++ }
++ }
++ /* That's all, folks. Simple, eh? */
++ return r;
++}
++
++/*** Non-blocking write *******************************************************/
++int pptp_write_some(PPTP_CONN * conn) {
++ ssize_t retval;
++ assert(conn && conn->call);
++ retval = write(conn->inet_sock, conn->write_buffer, conn->write_size);
++ if (retval < 0) { /* error. */
++ if (errno == EAGAIN || errno == EINTR) {
++ return 0;
++ } else { /* a real error */
++ warn("write error: %s", strerror(errno));
++ return -1;
++ }
++ }
++ assert(retval <= conn->write_size);
++ conn->write_size -= retval;
++ memmove(conn->write_buffer, conn->write_buffer + retval, conn->write_size);
++ ctrlp_rep(conn->write_buffer, retval, 0);
++ return 0;
++}
++
++/*** Non-blocking read ********************************************************/
++int pptp_read_some(PPTP_CONN * conn)
++{
++ ssize_t retval;
++ assert(conn && conn->call);
++ if (conn->read_size == conn->read_alloc) { /* need to alloc more memory */
++ char *new_buffer = realloc(conn->read_buffer,
++ sizeof(*(conn->read_buffer)) * conn->read_alloc * 2);
++ if (new_buffer == NULL) {
++ warn("Out of memory"); return -1;
++ }
++ conn->read_alloc *= 2;
++ conn->read_buffer = new_buffer;
++ }
++ retval = read(conn->inet_sock, conn->read_buffer + conn->read_size,
++ conn->read_alloc - conn->read_size);
++ if (retval == 0) {
++ warn("read returned zero, peer has closed");
++ return -1;
++ }
++ if (retval < 0) {
++ if (errno == EINTR || errno == EAGAIN)
++ return 0;
++ else { /* a real error */
++ warn("read error: %s", strerror(errno));
++ return -1;
++ }
++ }
++ conn->read_size += retval;
++ assert(conn->read_size <= conn->read_alloc);
++ return 0;
++}
++
++/*** Packet formation *********************************************************/
++int pptp_make_packet(PPTP_CONN * conn, void **buf, size_t *size)
++{
++ struct pptp_header *header;
++ size_t bad_bytes = 0;
++ assert(conn && conn->call); assert(buf != NULL); assert(size != NULL);
++ /* Give up unless there are at least sizeof(pptp_header) bytes */
++ while ((conn->read_size-bad_bytes) >= sizeof(struct pptp_header)) {
++ /* Throw out bytes until we have a valid header. */
++ header = (struct pptp_header *) (conn->read_buffer + bad_bytes);
++ if (ntoh32(header->magic) != PPTP_MAGIC) goto throwitout;
++ if (ntoh16(header->reserved0) != 0)
++ warn("reserved0 field is not zero! (0x%x) Cisco feature? \n",
++ ntoh16(header->reserved0));
++ if (ntoh16(header->length) < sizeof(struct pptp_header)) goto throwitout;
++ if (ntoh16(header->length) > PPTP_CTRL_SIZE_MAX) goto throwitout;
++ /* well. I guess it's good. Let's see if we've got it all. */
++ if (ntoh16(header->length) > (conn->read_size-bad_bytes))
++ /* nope. Let's wait until we've got it, then. */
++ goto flushbadbytes;
++ /* One last check: */
++ if ((ntoh16(header->pptp_type) == PPTP_MESSAGE_CONTROL) &&
++ (ntoh16(header->length) !=
++ PPTP_CTRL_SIZE(ntoh16(header->ctrl_type))))
++ goto throwitout;
++ /* well, I guess we've got it. */
++ *size = ntoh16(header->length);
++ *buf = malloc(*size);
++ if (*buf == NULL) { warn("Out of memory."); return 0; /* ack! */ }
++ memcpy(*buf, conn->read_buffer + bad_bytes, *size);
++ /* Delete this packet from the read_buffer. */
++ conn->read_size -= (bad_bytes + *size);
++ memmove(conn->read_buffer, conn->read_buffer + bad_bytes + *size,
++ conn->read_size);
++ if (bad_bytes > 0)
++ warn("%lu bad bytes thrown away.", (unsigned long) bad_bytes);
++ return 1;
++throwitout:
++ bad_bytes++;
++ }
++flushbadbytes:
++ /* no more packets. Let's get rid of those bad bytes */
++ conn->read_size -= bad_bytes;
++ memmove(conn->read_buffer, conn->read_buffer + bad_bytes, conn->read_size);
++ if (bad_bytes > 0)
++ warn("%lu bad bytes thrown away.", (unsigned long) bad_bytes);
++ return 0;
++}
++
++/*** pptp_send_ctrl_packet ****************************************************/
++int pptp_send_ctrl_packet(PPTP_CONN * conn, void * buffer, size_t size)
++{
++ assert(conn && conn->call); assert(buffer);
++ if( conn->write_size > 0) pptp_write_some( conn);
++ if( conn->write_size == 0) {
++ ssize_t retval;
++ retval = write(conn->inet_sock, buffer, size);
++ if (retval < 0) { /* error. */
++ if (errno == EAGAIN || errno == EINTR) {
++ /* ignore */;
++ retval = 0;
++ } else { /* a real error */
++ warn("write error: %s", strerror(errno));
++ pptp_conn_destroy(conn); /* shut down fast. */
++ return 0;
++ }
++ }
++ ctrlp_rep( buffer, retval, 0);
++ size -= retval;
++ if( size <= 0) return 1;
++ }
++ /* Shove anything not written into the write buffer */
++ if (conn->write_size + size > conn->write_alloc) { /* need more memory */
++ char *new_buffer = realloc(conn->write_buffer,
++ sizeof(*(conn->write_buffer)) * conn->write_alloc * 2);
++ if (new_buffer == NULL) {
++ warn("Out of memory"); return 0;
++ }
++ conn->write_alloc *= 2;
++ conn->write_buffer = new_buffer;
++ }
++ memcpy(conn->write_buffer + conn->write_size, buffer, size);
++ conn->write_size += size;
++ ctrlp_rep( buffer,size,1);
++ return 1;
++}
++
++/*** Packet Dispatch **********************************************************/
++int pptp_dispatch_packet(PPTP_CONN * conn, void * buffer, size_t size)
++{
++ int r = 0;
++ struct pptp_header *header = (struct pptp_header *)buffer;
++ assert(conn && conn->call); assert(buffer);
++ assert(ntoh32(header->magic) == PPTP_MAGIC);
++ assert(ntoh16(header->length) == size);
++ switch (ntoh16(header->pptp_type)) {
++ case PPTP_MESSAGE_CONTROL:
++ r = ctrlp_disp(conn, buffer, size);
++ break;
++ case PPTP_MESSAGE_MANAGE:
++ /* MANAGEMENT messages aren't even part of the spec right now. */
++ dbglog("PPTP management message received, but not understood.");
++ break;
++ default:
++ dbglog("Unknown PPTP control message type received: %u",
++ (unsigned int) ntoh16(header->pptp_type));
++ break;
++ }
++ return r;
++}
++
++/*** log echo request/replies *************************************************/
++static void logecho( int type)
++{
++ /* hack to stop flooding the log files (the most interesting part is right
++ * after the connection built-up) */
++ if( nlogecho > 0) {
++ dbglog("Echo Re%s received.", type == PPTP_ECHO_RQST ? "quest" :"ply");
++ if( --nlogecho == 0)
++ dbglog("no more Echo Reply/Request packets will be reported.");
++ }
++}
++
++/*** pptp_dispatch_ctrl_packet ************************************************/
++int ctrlp_disp(PPTP_CONN * conn, void * buffer, size_t size)
++{
++ struct pptp_header *header = (struct pptp_header *)buffer;
++ u_int8_t close_reason = PPTP_STOP_NONE;
++ assert(conn && conn->call); assert(buffer);
++ assert(ntoh32(header->magic) == PPTP_MAGIC);
++ assert(ntoh16(header->length) == size);
++ assert(ntoh16(header->pptp_type) == PPTP_MESSAGE_CONTROL);
++ if (size < PPTP_CTRL_SIZE(ntoh16(header->ctrl_type))) {
++ warn("Invalid packet received [type: %d; length: %d].",
++ (int) ntoh16(header->ctrl_type), (int) size);
++ return 0;
++ }
++ switch (ntoh16(header->ctrl_type)) {
++ /* ----------- STANDARD Start-Session MESSAGES ------------ */
++ case PPTP_START_CTRL_CONN_RQST:
++ {
++ struct pptp_start_ctrl_conn *packet =
++ (struct pptp_start_ctrl_conn *) buffer;
++ struct pptp_start_ctrl_conn reply = {
++ PPTP_HEADER_CTRL(PPTP_START_CTRL_CONN_RPLY),
++ hton16(PPTP_VERSION), 0, 0,
++ hton32(PPTP_FRAME_CAP), hton32(PPTP_BEARER_CAP),
++ hton16(PPTP_MAX_CHANNELS), hton16(PPTP_FIRMWARE_VERSION),
++ PPTP_HOSTNAME, PPTP_VENDOR };
++ int idx, rc;
++ dbglog("Received Start Control Connection Request");
++ /* fix this packet, if necessary */
++ idx = get_quirk_index();
++ if (idx != -1 && pptp_fixups[idx].start_ctrl_conn) {
++ if ((rc = pptp_fixups[idx].start_ctrl_conn(&reply)))
++ warn("calling the start_ctrl_conn hook failed (%d)", rc);
++ }
++ if (conn->conn_state == CONN_IDLE) {
++ if (ntoh16(packet->version) < PPTP_VERSION) {
++ /* Can't support this (earlier) PPTP_VERSION */
++ reply.version = packet->version;
++ /* protocol version not supported */
++ reply.result_code = hton8(5);
++ pptp_send_ctrl_packet(conn, &reply, sizeof(reply));
++ pptp_reset_timer(); /* give sender a chance for a retry */
++ } else { /* same or greater version */
++ if (pptp_send_ctrl_packet(conn, &reply, sizeof(reply))) {
++ conn->conn_state = CONN_ESTABLISHED;
++ dbglog("server connection ESTABLISHED.");
++ pptp_reset_timer();
++ }
++ }
++ }
++ break;
++ }
++ case PPTP_START_CTRL_CONN_RPLY:
++ {
++ struct pptp_start_ctrl_conn *packet =
++ (struct pptp_start_ctrl_conn *) buffer;
++ dbglog("Received Start Control Connection Reply");
++ if (conn->conn_state == CONN_WAIT_CTL_REPLY) {
++ /* XXX handle collision XXX [see rfc] */
++ if (ntoh16(packet->version) != PPTP_VERSION) {
++ if (conn->callback != NULL)
++ conn->callback(conn, CONN_OPEN_FAIL);
++ close_reason = PPTP_STOP_PROTOCOL;
++ goto pptp_conn_close;
++ }
++ if (ntoh8(packet->result_code) != 1 &&
++ /* J'ai change le if () afin que la connection ne se ferme
++ * pas pour un "rien" :p adel@cybercable.fr -
++ *
++ * Don't close the connection if the result code is zero
++ * (feature found in certain ADSL modems)
++ */
++ ntoh8(packet->result_code) != 0) {
++ dbglog("Negative reply received to our Start Control "
++ "Connection Request");
++ ctrlp_error(packet->result_code, packet->error_code,
++ -1, pptp_start_ctrl_conn_rply,
++ MAX_START_CTRL_CONN_REPLY);
++ if (conn->callback != NULL)
++ conn->callback(conn, CONN_OPEN_FAIL);
++ close_reason = PPTP_STOP_PROTOCOL;
++ goto pptp_conn_close;
++ }
++ conn->conn_state = CONN_ESTABLISHED;
++ /* log session properties */
++ conn->version = ntoh16(packet->version);
++ conn->firmware_rev = ntoh16(packet->firmware_rev);
++ memcpy(conn->hostname, packet->hostname, sizeof(conn->hostname));
++ memcpy(conn->vendor, packet->vendor, sizeof(conn->vendor));
++ pptp_reset_timer(); /* 60 seconds until keep-alive */
++ dbglog("Client connection established.");
++ if (conn->callback != NULL)
++ conn->callback(conn, CONN_OPEN_DONE);
++ } /* else goto pptp_conn_close; */
++ break;
++ }
++ /* ----------- STANDARD Stop-Session MESSAGES ------------ */
++ case PPTP_STOP_CTRL_CONN_RQST:
++ {
++ /* conn_state should be CONN_ESTABLISHED, but it could be
++ * something else */
++ struct pptp_stop_ctrl_conn reply = {
++ PPTP_HEADER_CTRL(PPTP_STOP_CTRL_CONN_RPLY),
++ hton8(1), hton8(PPTP_GENERAL_ERROR_NONE), 0
++ };
++ dbglog("Received Stop Control Connection Request.");
++ if (conn->conn_state == CONN_IDLE) break;
++ if (pptp_send_ctrl_packet(conn, &reply, sizeof(reply))) {
++ if (conn->callback != NULL)
++ conn->callback(conn, CONN_CLOSE_RQST);
++ conn->conn_state = CONN_IDLE;
++ return -1;
++ }
++ break;
++ }
++ case PPTP_STOP_CTRL_CONN_RPLY:
++ {
++ dbglog("Received Stop Control Connection Reply.");
++ /* conn_state should be CONN_WAIT_STOP_REPLY, but it
++ * could be something else */
++ if (conn->conn_state == CONN_IDLE) break;
++ conn->conn_state = CONN_IDLE;
++ return -1;
++ }
++ /* ----------- STANDARD Echo/Keepalive MESSAGES ------------ */
++ case PPTP_ECHO_RPLY:
++ {
++ struct pptp_echo_rply *packet =
++ (struct pptp_echo_rply *) buffer;
++ logecho( PPTP_ECHO_RPLY);
++ if ((conn->ka_state == KA_OUTSTANDING) &&
++ (ntoh32(packet->identifier) == conn->ka_id)) {
++ conn->ka_id++;
++ conn->ka_state = KA_NONE;
++ pptp_reset_timer();
++ }
++ break;
++ }
++ case PPTP_ECHO_RQST:
++ {
++ struct pptp_echo_rqst *packet =
++ (struct pptp_echo_rqst *) buffer;
++ struct pptp_echo_rply reply = {
++ PPTP_HEADER_CTRL(PPTP_ECHO_RPLY),
++ packet->identifier, /* skip hton32(ntoh32(id)) */
++ hton8(1), hton8(PPTP_GENERAL_ERROR_NONE), 0
++ };
++ logecho( PPTP_ECHO_RQST);
++ pptp_send_ctrl_packet(conn, &reply, sizeof(reply));
++ pptp_reset_timer();
++ break;
++ }
++ /* ----------- OUTGOING CALL MESSAGES ------------ */
++ case PPTP_OUT_CALL_RQST:
++ {
++ struct pptp_out_call_rqst *packet =
++ (struct pptp_out_call_rqst *)buffer;
++ struct pptp_out_call_rply reply = {
++ PPTP_HEADER_CTRL(PPTP_OUT_CALL_RPLY),
++ 0 /* callid */, packet->call_id, 1, PPTP_GENERAL_ERROR_NONE, 0,
++ hton32(PPTP_CONNECT_SPEED),
++ hton16(PPTP_WINDOW), hton16(PPTP_DELAY), 0
++ };
++ dbglog("Received Outgoing Call Request.");
++ /* XXX PAC: eventually this should make an outgoing call. XXX */
++ reply.result_code = hton8(7); /* outgoing calls verboten */
++ pptp_send_ctrl_packet(conn, &reply, sizeof(reply));
++ break;
++ }
++ case PPTP_OUT_CALL_RPLY:
++ {
++ struct pptp_out_call_rply *packet =
++ (struct pptp_out_call_rply *)buffer;
++ PPTP_CALL * call;
++ u_int16_t callid = ntoh16(packet->call_id_peer);
++ dbglog("Received Outgoing Call Reply.");
++ if (!vector_search(conn->call, (int) callid, &call)) {
++ dbglog("PPTP_OUT_CALL_RPLY received for non-existant call: "
++ "peer call ID (us) %d call ID (them) %d.",
++ callid, ntoh16(packet->call_id));
++ break;
++ }
++ if (call->call_type != PPTP_CALL_PNS) {
++ dbglog("Ack! How did this call_type get here?"); /* XXX? */
++ break;
++ }
++ if (call->state.pns != PNS_WAIT_REPLY) {
++ warn("Unexpected(?) Outgoing Call Reply will be ignored.");
++ break;
++ }
++ /* check for errors */
++ if (packet->result_code != 1) {
++ /* An error. Log it verbosely. */
++ dbglog("Our outgoing call request [callid %d] has not been "
++ "accepted.", (int) callid);
++ ctrlp_error(packet->result_code, packet->error_code,
++ packet->cause_code, pptp_out_call_reply_result,
++ MAX_OUT_CALL_REPLY_RESULT);
++ call->state.pns = PNS_IDLE;
++ if (call->callback != NULL)
++ call->callback(conn, call, CALL_OPEN_FAIL);
++ pptp_call_destroy(conn, call);
++ } else {
++ /* connection established */
++ call->state.pns = PNS_ESTABLISHED;
++ call->peer_call_id = ntoh16(packet->call_id);
++ call->speed = ntoh32(packet->speed);
++ pptp_reset_timer();
++ /* call pptp_set_link. unless the user specified a quirk
++ and this quirk has a set_link hook, this is a noop */
++ pptp_set_link(conn, call->peer_call_id);
++ if (call->callback != NULL)
++ call->callback(conn, call, CALL_OPEN_DONE);
++ dbglog("Outgoing call established (call ID %u, peer's "
++ "call ID %u).\n", call->call_id, call->peer_call_id);
++ }
++ break;
++ }
++ /* ----------- INCOMING CALL MESSAGES ------------ */
++ /* XXX write me XXX */
++ /* ----------- CALL CONTROL MESSAGES ------------ */
++ case PPTP_CALL_CLEAR_RQST:
++ {
++ struct pptp_call_clear_rqst *packet =
++ (struct pptp_call_clear_rqst *)buffer;
++ struct pptp_call_clear_ntfy reply = {
++ PPTP_HEADER_CTRL(PPTP_CALL_CLEAR_NTFY), packet->call_id,
++ 1, PPTP_GENERAL_ERROR_NONE, 0, 0, {0}
++ };
++ dbglog("Received Call Clear Request.");
++ if (vector_contains(conn->call, ntoh16(packet->call_id))) {
++ PPTP_CALL * call;
++ vector_search(conn->call, ntoh16(packet->call_id), &call);
++ if (call->callback != NULL)
++ call->callback(conn, call, CALL_CLOSE_RQST);
++ pptp_send_ctrl_packet(conn, &reply, sizeof(reply));
++ pptp_call_destroy(conn, call);
++ dbglog("Call closed (RQST) (call id %d)", (int) call->call_id);
++ }
++ break;
++ }
++ case PPTP_CALL_CLEAR_NTFY:
++ {
++ struct pptp_call_clear_ntfy *packet =
++ (struct pptp_call_clear_ntfy *)buffer;
++ dbglog("Call disconnect notification received (call id %d)",
++ ntoh16(packet->call_id));
++ if (vector_contains(conn->call, ntoh16(packet->call_id))) {
++ PPTP_CALL * call;
++ ctrlp_error(packet->result_code, packet->error_code,
++ packet->cause_code, pptp_call_disc_ntfy,
++ MAX_CALL_DISC_NTFY);
++ vector_search(conn->call, ntoh16(packet->call_id), &call);
++ pptp_call_destroy(conn, call);
++ }
++ /* XXX we could log call stats here XXX */
++ /* XXX not all servers send this XXX */
++ break;
++ }
++ case PPTP_SET_LINK_INFO:
++ {
++ /* I HAVE NO CLUE WHAT TO DO IF send_accm IS NOT 0! */
++ /* this is really dealt with in the HDLC deencapsulation, anyway. */
++ struct pptp_set_link_info *packet =
++ (struct pptp_set_link_info *)buffer;
++ /* log it. */
++ dbglog("PPTP_SET_LINK_INFO received from peer_callid %u",
++ (unsigned int) ntoh16(packet->call_id_peer));
++ dbglog(" send_accm is %08lX, recv_accm is %08lX",
++ (unsigned long) ntoh32(packet->send_accm),
++ (unsigned long) ntoh32(packet->recv_accm));
++ if (!(ntoh32(packet->send_accm) == 0 &&
++ ntoh32(packet->recv_accm) == 0))
++ warn("Non-zero Async Control Character Maps are not supported!");
++ break;
++ }
++ default:
++ dbglog("Unrecognized Packet %d received.",
++ (int) ntoh16(((struct pptp_header *)buffer)->ctrl_type));
++ /* goto pptp_conn_close; */
++ break;
++ }
++ return 0;
++pptp_conn_close:
++ warn("pptp_conn_close(%d)", (int) close_reason);
++ pptp_conn_close(conn, close_reason);
++ return 0;
++}
++
++/*** pptp_set_link **************************************************************/
++void pptp_set_link(PPTP_CONN* conn, int peer_call_id)
++{
++ int idx, rc;
++ /* if we need to send a set_link packet because of buggy
++ hardware or pptp server, do it now */
++ if ((idx = get_quirk_index()) != -1 && pptp_fixups[idx].set_link_hook) {
++ struct pptp_set_link_info packet;
++ if ((rc = pptp_fixups[idx].set_link_hook(&packet, peer_call_id)))
++ warn("calling the set_link hook failed (%d)", rc);
++ if (pptp_send_ctrl_packet(conn, &packet, sizeof(packet))) {
++ pptp_reset_timer();
++ }
++ }
++}
++
++/*** Get info from call structure *********************************************/
++/* NOTE: The peer_call_id is undefined until we get a server response. */
++void pptp_call_get_ids(PPTP_CONN * conn, PPTP_CALL * call,
++ u_int16_t * call_id, u_int16_t * peer_call_id)
++{
++ assert(conn != NULL); assert(call != NULL);
++ *call_id = call->call_id;
++ *peer_call_id = call->peer_call_id;
++}
++
++/*** pptp_call_closure_put ****************************************************/
++void pptp_call_closure_put(PPTP_CONN * conn, PPTP_CALL * call, void *cl)
++{
++ assert(conn != NULL); assert(call != NULL);
++ call->closure = cl;
++}
++
++/*** pptp_call_closure_get ****************************************************/
++void * pptp_call_closure_get(PPTP_CONN * conn, PPTP_CALL * call)
++{
++ assert(conn != NULL); assert(call != NULL);
++ return call->closure;
++}
++
++/*** pptp_conn_closure_put ****************************************************/
++void pptp_conn_closure_put(PPTP_CONN * conn, void *cl)
++{
++ assert(conn != NULL);
++ conn->closure = cl;
++}
++
++/*** pptp_conn_closure_get ****************************************************/
++void * pptp_conn_closure_get(PPTP_CONN * conn)
++{
++ assert(conn != NULL);
++ return conn->closure;
++}
++
++/*** Reset keep-alive timer ***************************************************/
++static void pptp_reset_timer(void)
++{
++ const struct itimerval tv = { { 0, 0 }, /* stop on time-out */
++ { idle_wait, 0 } };
++ if (idle_wait) setitimer(ITIMER_REAL, &tv, NULL);
++}
++
++
++/*** Handle keep-alive timer **************************************************/
++static void pptp_handle_timer()
++{
++ int i;
++ /* "Keep Alives and Timers, 1": check connection state */
++ if (global.conn->conn_state != CONN_ESTABLISHED) {
++ if (global.conn->conn_state == CONN_WAIT_STOP_REPLY)
++ /* hard close. */
++ pptp_conn_destroy(global.conn);
++ else /* soft close */
++ pptp_conn_close(global.conn, PPTP_STOP_NONE);
++ }
++ /* "Keep Alives and Timers, 2": check echo status */
++ if (global.conn->ka_state == KA_OUTSTANDING) {
++ /* no response to keep-alive */
++ info("closing control connection due to missing echo reply");
++ pptp_conn_close(global.conn, PPTP_STOP_NONE);
++ } else { /* ka_state == NONE */ /* send keep-alive */
++ struct pptp_echo_rqst rqst = {
++ PPTP_HEADER_CTRL(PPTP_ECHO_RQST), hton32(global.conn->ka_id) };
++ pptp_send_ctrl_packet(global.conn, &rqst, sizeof(rqst));
++ global.conn->ka_state = KA_OUTSTANDING;
++ }
++ /* check incoming/outgoing call states for !IDLE && !ESTABLISHED */
++ for (i = 0; i < vector_size(global.conn->call); i++) {
++ PPTP_CALL * call = vector_get_Nth(global.conn->call, i);
++ if (call->call_type == PPTP_CALL_PNS) {
++ if (call->state.pns == PNS_WAIT_REPLY) {
++ /* send close request */
++ pptp_call_close(global.conn, call);
++ assert(call->state.pns == PNS_WAIT_DISCONNECT);
++ } else if (call->state.pns == PNS_WAIT_DISCONNECT) {
++ /* hard-close the call */
++ pptp_call_destroy(global.conn, call);
++ }
++ } else if (call->call_type == PPTP_CALL_PAC) {
++ if (call->state.pac == PAC_WAIT_REPLY) {
++ /* XXX FIXME -- drop the PAC connection XXX */
++ } else if (call->state.pac == PAC_WAIT_CS_ANS) {
++ /* XXX FIXME -- drop the PAC connection XXX */
++ }
++ }
++ }
++ pptp_reset_timer();
++}
+--- /dev/null
++++ b/pppd/plugins/pptp/pptp_ctrl.h
+@@ -0,0 +1,57 @@
++/* pptp_ctrl.h ... handle PPTP control connection.
++ * C. Scott Ananian <cananian@alumni.princeton.edu>
++ *
++ * $Id: pptp_ctrl.h,v 1.5 2004/11/09 01:42:32 quozl Exp $
++ */
++
++#ifndef INC_PPTP_CTRL_H
++#define INC_PPTP_CTRL_H
++#include <sys/types.h>
++
++typedef struct PPTP_CONN PPTP_CONN;
++typedef struct PPTP_CALL PPTP_CALL;
++
++enum call_state { CALL_OPEN_RQST, CALL_OPEN_DONE, CALL_OPEN_FAIL,
++ CALL_CLOSE_RQST, CALL_CLOSE_DONE };
++enum conn_state { CONN_OPEN_RQST, CONN_OPEN_DONE, CONN_OPEN_FAIL,
++ CONN_CLOSE_RQST, CONN_CLOSE_DONE };
++
++typedef void (*pptp_call_cb)(PPTP_CONN*, PPTP_CALL*, enum call_state);
++typedef void (*pptp_conn_cb)(PPTP_CONN*, enum conn_state);
++
++/* if 'isclient' is true, then will send 'conn open' packet to other host.
++ * not necessary if this is being opened by a server process after
++ * receiving a conn_open packet from client.
++ */
++PPTP_CONN * pptp_conn_open(int inet_sock, int isclient,
++ pptp_conn_cb callback);
++PPTP_CALL * pptp_call_open(PPTP_CONN * conn, int call_id,
++ pptp_call_cb callback, char *phonenr,int window);
++int pptp_conn_established(PPTP_CONN * conn);
++/* soft close. Will callback on completion. */
++void pptp_call_close(PPTP_CONN * conn, PPTP_CALL * call);
++/* hard close. */
++void pptp_call_destroy(PPTP_CONN *conn, PPTP_CALL *call);
++/* soft close. Will callback on completion. */
++void pptp_conn_close(PPTP_CONN * conn, u_int8_t close_reason);
++/* hard close */
++void pptp_conn_destroy(PPTP_CONN * conn);
++
++/* Add file descriptors used by pptp to fd_set. */
++void pptp_fd_set(PPTP_CONN * conn, fd_set * read_set, fd_set * write_set, int *max_fd);
++/* handle any pptp file descriptors set in fd_set, and clear them */
++int pptp_dispatch(PPTP_CONN * conn, fd_set * read_set, fd_set * write_set);
++
++/* Get info about connection, call */
++void pptp_call_get_ids(PPTP_CONN * conn, PPTP_CALL * call,
++ u_int16_t * call_id, u_int16_t * peer_call_id);
++/* Arbitrary user data about this call/connection.
++ * It is the caller's responsibility to free this data before calling
++ * pptp_call|conn_close()
++ */
++void * pptp_conn_closure_get(PPTP_CONN * conn);
++void pptp_conn_closure_put(PPTP_CONN * conn, void *cl);
++void * pptp_call_closure_get(PPTP_CONN * conn, PPTP_CALL * call);
++void pptp_call_closure_put(PPTP_CONN * conn, PPTP_CALL * call, void *cl);
++
++#endif /* INC_PPTP_CTRL_H */
+--- /dev/null
++++ b/pppd/plugins/pptp/pptp_msg.h
+@@ -0,0 +1,303 @@
++/* pptp.h: packet structures and magic constants for the PPTP protocol
++ * C. Scott Ananian <cananian@alumni.princeton.edu>
++ *
++ * $Id: pptp_msg.h,v 1.3 2003/02/15 10:37:21 quozl Exp $
++ */
++
++#ifndef INC_PPTP_H
++#define INC_PPTP_H
++
++/* Grab definitions of int16, int32, etc. */
++#include <sys/types.h>
++/* define "portable" htons, etc. */
++#define hton8(x) (x)
++#define ntoh8(x) (x)
++#define hton16(x) htons(x)
++#define ntoh16(x) ntohs(x)
++#define hton32(x) htonl(x)
++#define ntoh32(x) ntohl(x)
++
++/* PPTP magic numbers: ----------------------------------------- */
++
++#define PPTP_MAGIC 0x1A2B3C4D /* Magic cookie for PPTP datagrams */
++#define PPTP_PORT 1723 /* PPTP TCP port number */
++#define PPTP_PROTO 47 /* PPTP IP protocol number */
++
++/* Control Connection Message Types: --------------------------- */
++
++#define PPTP_MESSAGE_CONTROL 1
++#define PPTP_MESSAGE_MANAGE 2
++
++/* Control Message Types: -------------------------------------- */
++
++/* (Control Connection Management) */
++#define PPTP_START_CTRL_CONN_RQST 1
++#define PPTP_START_CTRL_CONN_RPLY 2
++#define PPTP_STOP_CTRL_CONN_RQST 3
++#define PPTP_STOP_CTRL_CONN_RPLY 4
++#define PPTP_ECHO_RQST 5
++#define PPTP_ECHO_RPLY 6
++
++/* (Call Management) */
++#define PPTP_OUT_CALL_RQST 7
++#define PPTP_OUT_CALL_RPLY 8
++#define PPTP_IN_CALL_RQST 9
++#define PPTP_IN_CALL_RPLY 10
++#define PPTP_IN_CALL_CONNECT 11
++#define PPTP_CALL_CLEAR_RQST 12
++#define PPTP_CALL_CLEAR_NTFY 13
++
++/* (Error Reporting) */
++#define PPTP_WAN_ERR_NTFY 14
++
++/* (PPP Session Control) */
++#define PPTP_SET_LINK_INFO 15
++
++/* PPTP version information: --------------------------------------*/
++#define PPTP_VERSION_STRING "1.00"
++#define PPTP_VERSION 0x100
++#define PPTP_FIRMWARE_STRING "0.01"
++#define PPTP_FIRMWARE_VERSION 0x001
++
++/* PPTP capabilities: ---------------------------------------------*/
++
++/* (Framing capabilities for msg sender) */
++#define PPTP_FRAME_ASYNC 1
++#define PPTP_FRAME_SYNC 2
++#define PPTP_FRAME_ANY 3
++
++/* (Bearer capabilities for msg sender) */
++#define PPTP_BEARER_ANALOG 1
++#define PPTP_BEARER_DIGITAL 2
++#define PPTP_BEARER_ANY 3
++
++#define PPTP_RESULT_GENERAL_ERROR 2
++
++/* (Reasons to close a connection) */
++#define PPTP_STOP_NONE 1 /* no good reason */
++#define PPTP_STOP_PROTOCOL 2 /* can't support peer's protocol version */
++#define PPTP_STOP_LOCAL_SHUTDOWN 3 /* requester is being shut down */
++
++/* PPTP datagram structures (all data in network byte order): ----------*/
++
++struct pptp_header {
++ u_int16_t length; /* message length in octets, including header */
++ u_int16_t pptp_type; /* PPTP message type. 1 for control message. */
++ u_int32_t magic; /* this should be PPTP_MAGIC. */
++ u_int16_t ctrl_type; /* Control message type (0-15) */
++ u_int16_t reserved0; /* reserved. MUST BE ZERO. */
++};
++
++struct pptp_start_ctrl_conn { /* for control message types 1 and 2 */
++ struct pptp_header header;
++
++ u_int16_t version; /* PPTP protocol version. = PPTP_VERSION */
++ u_int8_t result_code; /* these two fields should be zero on rqst msg*/
++ u_int8_t error_code; /* 0 unless result_code==2 (General Error) */
++ u_int32_t framing_cap; /* Framing capabilities */
++ u_int32_t bearer_cap; /* Bearer Capabilities */
++ u_int16_t max_channels; /* Maximum Channels (=0 for PNS, PAC ignores) */
++ u_int16_t firmware_rev; /* Firmware or Software Revision */
++ u_int8_t hostname[64]; /* Host Name (64 octets, zero terminated) */
++ u_int8_t vendor[64]; /* Vendor string (64 octets, zero term.) */
++ /* MS says that end of hostname/vendor fields should be filled with */
++ /* octets of value 0, but Win95 PPTP driver doesn't do this. */
++};
++
++struct pptp_stop_ctrl_conn { /* for control message types 3 and 4 */
++ struct pptp_header header;
++
++ u_int8_t reason_result; /* reason for rqst, result for rply */
++ u_int8_t error_code; /* MUST be 0, unless rply result==2 (general err)*/
++ u_int16_t reserved1; /* MUST be 0 */
++};
++
++struct pptp_echo_rqst { /* for control message type 5 */
++ struct pptp_header header;
++ u_int32_t identifier; /* arbitrary value set by sender which is used */
++ /* to match up reply and request */
++};
++
++struct pptp_echo_rply { /* for control message type 6 */
++ struct pptp_header header;
++ u_int32_t identifier; /* should correspond to id of rqst */
++ u_int8_t result_code;
++ u_int8_t error_code; /* =0, unless result_code==2 (general error) */
++ u_int16_t reserved1; /* MUST BE ZERO */
++};
++
++struct pptp_out_call_rqst { /* for control message type 7 */
++ struct pptp_header header;
++ u_int16_t call_id; /* Call ID (unique id used to multiplex data) */
++ u_int16_t call_sernum; /* Call Serial Number (used for logging) */
++ u_int32_t bps_min; /* Minimum BPS (lowest acceptable line speed) */
++ u_int32_t bps_max; /* Maximum BPS (highest acceptable line speed) */
++ u_int32_t bearer; /* Bearer type */
++ u_int32_t framing; /* Framing type */
++ u_int16_t recv_size; /* Recv. Window Size (no. of buffered packets) */
++ u_int16_t delay; /* Packet Processing Delay (in 1/10 sec) */
++ u_int16_t phone_len; /* Phone Number Length (num. of valid digits) */
++ u_int16_t reserved1; /* MUST BE ZERO */
++ u_int8_t phone_num[64]; /* Phone Number (64 octets, null term.) */
++ u_int8_t subaddress[64]; /* Subaddress (64 octets, null term.) */
++};
++
++struct pptp_out_call_rply { /* for control message type 8 */
++ struct pptp_header header;
++ u_int16_t call_id; /* Call ID (used to multiplex data over tunnel)*/
++ u_int16_t call_id_peer; /* Peer's Call ID (call_id of pptp_out_call_rqst)*/
++ u_int8_t result_code; /* Result Code (1 is no errors) */
++ u_int8_t error_code; /* Error Code (=0 unless result_code==2) */
++ u_int16_t cause_code; /* Cause Code (addt'l failure information) */
++ u_int32_t speed; /* Connect Speed (in BPS) */
++ u_int16_t recv_size; /* Recv. Window Size (no. of buffered packets) */
++ u_int16_t delay; /* Packet Processing Delay (in 1/10 sec) */
++ u_int32_t channel; /* Physical Channel ID (for logging) */
++};
++
++struct pptp_in_call_rqst { /* for control message type 9 */
++ struct pptp_header header;
++ u_int16_t call_id; /* Call ID (unique id used to multiplex data) */
++ u_int16_t call_sernum; /* Call Serial Number (used for logging) */
++ u_int32_t bearer; /* Bearer type */
++ u_int32_t channel; /* Physical Channel ID (for logging) */
++ u_int16_t dialed_len; /* Dialed Number Length (# of valid digits) */
++ u_int16_t dialing_len; /* Dialing Number Length (# of valid digits) */
++ u_int8_t dialed_num[64]; /* Dialed Number (64 octets, zero term.) */
++ u_int8_t dialing_num[64]; /* Dialing Number (64 octets, zero term.) */
++ u_int8_t subaddress[64]; /* Subaddress (64 octets, zero term.) */
++};
++
++struct pptp_in_call_rply { /* for control message type 10 */
++ struct pptp_header header;
++ u_int16_t call_id; /* Call ID (used to multiplex data over tunnel)*/
++ u_int16_t call_id_peer; /* Peer's Call ID (call_id of pptp_out_call_rqst)*/
++ u_int8_t result_code; /* Result Code (1 is no errors) */
++ u_int8_t error_code; /* Error Code (=0 unless result_code==2) */
++ u_int16_t recv_size; /* Recv. Window Size (no. of buffered packets) */
++ u_int16_t delay; /* Packet Processing Delay (in 1/10 sec) */
++ u_int16_t reserved1; /* MUST BE ZERO */
++};
++
++struct pptp_in_call_connect { /* for control message type 11 */
++ struct pptp_header header;
++ u_int16_t call_id_peer; /* Peer's Call ID (call_id of pptp_out_call_rqst)*/
++ u_int16_t reserved1; /* MUST BE ZERO */
++ u_int32_t speed; /* Connect Speed (in BPS) */
++ u_int16_t recv_size; /* Recv. Window Size (no. of buffered packets) */
++ u_int16_t delay; /* Packet Processing Delay (in 1/10 sec) */
++ u_int32_t framing; /* Framing type */
++};
++
++struct pptp_call_clear_rqst { /* for control message type 12 */
++ struct pptp_header header;
++ u_int16_t call_id; /* Call ID (used to multiplex data over tunnel)*/
++ u_int16_t reserved1; /* MUST BE ZERO */
++};
++
++struct pptp_call_clear_ntfy { /* for control message type 13 */
++ struct pptp_header header;
++ u_int16_t call_id; /* Call ID (used to multiplex data over tunnel)*/
++ u_int8_t result_code; /* Result Code */
++ u_int8_t error_code; /* Error Code (=0 unless result_code==2) */
++ u_int16_t cause_code; /* Cause Code (for ISDN, is Q.931 cause code) */
++ u_int16_t reserved1; /* MUST BE ZERO */
++ u_int8_t call_stats[128]; /* Call Statistics: 128 octets, ascii, 0-term */
++};
++
++struct pptp_wan_err_ntfy { /* for control message type 14 */
++ struct pptp_header header;
++ u_int16_t call_id_peer; /* Peer's Call ID (call_id of pptp_out_call_rqst)*/
++ u_int16_t reserved1; /* MUST BE ZERO */
++ u_int32_t crc_errors; /* CRC errors */
++ u_int32_t frame_errors; /* Framing errors */
++ u_int32_t hard_errors; /* Hardware overruns */
++ u_int32_t buff_errors; /* Buffer overruns */
++ u_int32_t time_errors; /* Time-out errors */
++ u_int32_t align_errors; /* Alignment errors */
++};
++
++struct pptp_set_link_info { /* for control message type 15 */
++ struct pptp_header header;
++ u_int16_t call_id_peer; /* Peer's Call ID (call_id of pptp_out_call_rqst) */
++ u_int16_t reserved1; /* MUST BE ZERO */
++ u_int32_t send_accm; /* Send ACCM (for PPP packets; default 0xFFFFFFFF)*/
++ u_int32_t recv_accm; /* Receive ACCM (for PPP pack.;default 0xFFFFFFFF)*/
++};
++
++/* helpful #defines: -------------------------------------------- */
++#define pptp_isvalid_ctrl(header, type, length) \
++ (!( ( ntoh16(((struct pptp_header *)header)->length) < (length) ) || \
++ ( ntoh16(((struct pptp_header *)header)->pptp_type) !=(type) ) || \
++ ( ntoh32(((struct pptp_header *)header)->magic) !=PPTP_MAGIC) || \
++ ( ntoh16(((struct pptp_header *)header)->ctrl_type) > PPTP_SET_LINK_INFO) || \
++ ( ntoh16(((struct pptp_header *)header)->reserved0) !=0 ) ))
++
++#define PPTP_HEADER_CTRL(type) \
++{ hton16(PPTP_CTRL_SIZE(type)), \
++ hton16(PPTP_MESSAGE_CONTROL), \
++ hton32(PPTP_MAGIC), \
++ hton16(type), 0 }
++
++#define PPTP_CTRL_SIZE(type) ( \
++(type==PPTP_START_CTRL_CONN_RQST)?sizeof(struct pptp_start_ctrl_conn): \
++(type==PPTP_START_CTRL_CONN_RPLY)?sizeof(struct pptp_start_ctrl_conn): \
++(type==PPTP_STOP_CTRL_CONN_RQST )?sizeof(struct pptp_stop_ctrl_conn): \
++(type==PPTP_STOP_CTRL_CONN_RPLY )?sizeof(struct pptp_stop_ctrl_conn): \
++(type==PPTP_ECHO_RQST )?sizeof(struct pptp_echo_rqst): \
++(type==PPTP_ECHO_RPLY )?sizeof(struct pptp_echo_rply): \
++(type==PPTP_OUT_CALL_RQST )?sizeof(struct pptp_out_call_rqst): \
++(type==PPTP_OUT_CALL_RPLY )?sizeof(struct pptp_out_call_rply): \
++(type==PPTP_IN_CALL_RQST )?sizeof(struct pptp_in_call_rqst): \
++(type==PPTP_IN_CALL_RPLY )?sizeof(struct pptp_in_call_rply): \
++(type==PPTP_IN_CALL_CONNECT )?sizeof(struct pptp_in_call_connect): \
++(type==PPTP_CALL_CLEAR_RQST )?sizeof(struct pptp_call_clear_rqst): \
++(type==PPTP_CALL_CLEAR_NTFY )?sizeof(struct pptp_call_clear_ntfy): \
++(type==PPTP_WAN_ERR_NTFY )?sizeof(struct pptp_wan_err_ntfy): \
++(type==PPTP_SET_LINK_INFO )?sizeof(struct pptp_set_link_info): \
++0)
++#define max(a,b) (((a)>(b))?(a):(b))
++#define PPTP_CTRL_SIZE_MAX ( \
++max(sizeof(struct pptp_start_ctrl_conn), \
++max(sizeof(struct pptp_echo_rqst), \
++max(sizeof(struct pptp_echo_rply), \
++max(sizeof(struct pptp_out_call_rqst), \
++max(sizeof(struct pptp_out_call_rply), \
++max(sizeof(struct pptp_in_call_rqst), \
++max(sizeof(struct pptp_in_call_rply), \
++max(sizeof(struct pptp_in_call_connect), \
++max(sizeof(struct pptp_call_clear_rqst), \
++max(sizeof(struct pptp_call_clear_ntfy), \
++max(sizeof(struct pptp_wan_err_ntfy), \
++max(sizeof(struct pptp_set_link_info), 0)))))))))))))
++
++
++/* gre header structure: -------------------------------------------- */
++
++#define PPTP_GRE_PROTO 0x880B
++#define PPTP_GRE_VER 0x1
++
++#define PPTP_GRE_FLAG_C 0x80
++#define PPTP_GRE_FLAG_R 0x40
++#define PPTP_GRE_FLAG_K 0x20
++#define PPTP_GRE_FLAG_S 0x10
++#define PPTP_GRE_FLAG_A 0x80
++
++#define PPTP_GRE_IS_C(f) ((f)&PPTP_GRE_FLAG_C)
++#define PPTP_GRE_IS_R(f) ((f)&PPTP_GRE_FLAG_R)
++#define PPTP_GRE_IS_K(f) ((f)&PPTP_GRE_FLAG_K)
++#define PPTP_GRE_IS_S(f) ((f)&PPTP_GRE_FLAG_S)
++#define PPTP_GRE_IS_A(f) ((f)&PPTP_GRE_FLAG_A)
++
++struct pptp_gre_header {
++ u_int8_t flags; /* bitfield */
++ u_int8_t ver; /* should be PPTP_GRE_VER (enhanced GRE) */
++ u_int16_t protocol; /* should be PPTP_GRE_PROTO (ppp-encaps) */
++ u_int16_t payload_len; /* size of ppp payload, not inc. gre header */
++ u_int16_t call_id; /* peer's call_id for this session */
++ u_int32_t seq; /* sequence number. Present if S==1 */
++ u_int32_t ack; /* seq number of highest packet recieved by */
++ /* sender in this session */
++};
++
++#endif /* INC_PPTP_H */
+--- /dev/null
++++ b/pppd/plugins/pptp/pptp_options.h
+@@ -0,0 +1,41 @@
++/* pptp_options.h ...... various constants used in the PPTP protocol.
++ * #define STANDARD to emulate NT 4.0 exactly.
++ * C. Scott Ananian <cananian@alumni.princeton.edu>
++ *
++ * $Id: pptp_options.h,v 1.3 2004/11/09 01:42:32 quozl Exp $
++ */
++
++#ifndef INC_PPTP_OPTIONS_H
++#define INC_PPTP_OPTIONS_H
++
++#undef PPTP_FIRMWARE_STRING
++#undef PPTP_FIRMWARE_VERSION
++#define PPTP_BUF_MAX 65536
++#define PPTP_TIMEOUT 60 /* seconds */
++extern int idle_wait;
++extern int max_echo_wait;
++#define PPTP_CONNECT_SPEED 1000000000
++#define PPTP_WINDOW 3
++#define PPTP_DELAY 0
++#define PPTP_BPS_MIN 2400
++#define PPTP_BPS_MAX 1000000000
++
++#ifndef STANDARD
++#define PPTP_MAX_CHANNELS 65535
++#define PPTP_FIRMWARE_STRING "0.01"
++#define PPTP_FIRMWARE_VERSION 0x001
++#define PPTP_HOSTNAME {'l','o','c','a','l',0}
++#define PPTP_VENDOR {'c','a','n','a','n','i','a','n',0}
++#define PPTP_FRAME_CAP PPTP_FRAME_ANY
++#define PPTP_BEARER_CAP PPTP_BEARER_ANY
++#else
++#define PPTP_MAX_CHANNELS 5
++#define PPTP_FIRMWARE_STRING "0.01"
++#define PPTP_FIRMWARE_VERSION 0
++#define PPTP_HOSTNAME {'l','o','c','a','l',0}
++#define PPTP_VENDOR {'N','T',0}
++#define PPTP_FRAME_CAP 2
++#define PPTP_BEARER_CAP 1
++#endif
++
++#endif /* INC_PPTP_OPTIONS_H */
+--- /dev/null
++++ b/pppd/plugins/pptp/pptp_quirks.c
+@@ -0,0 +1,54 @@
++/* pptp_quirks.c ...... various options to fix quirks found in buggy adsl modems
++ * mulix <mulix@actcom.co.il>
++ *
++ * $Id: pptp_quirks.c,v 1.2 2001/11/23 03:42:51 quozl Exp $
++ */
++
++#include <string.h>
++#include "orckit_quirks.h"
++#include "pptp_quirks.h"
++
++static int quirk_index = -1;
++
++struct pptp_fixup pptp_fixups[] = {
++ {BEZEQ_ISRAEL, ORCKIT, ORCKIT_ATUR3,
++ orckit_atur3_build_hook,
++ orckit_atur3_start_ctrl_conn_hook,
++ orckit_atur3_set_link_hook}
++};
++
++static int fixups_sz = sizeof(pptp_fixups)/sizeof(pptp_fixups[0]);
++
++/* return 0 on success, non 0 otherwise */
++int set_quirk_index(int index)
++{
++ if (index >= 0 && index < fixups_sz) {
++ quirk_index = index;
++ return 0;
++ }
++
++ return -1;
++}
++
++int get_quirk_index()
++{
++ return quirk_index;
++}
++
++/* return the index for this isp in the quirks table, -1 if not found */
++int find_quirk(const char* isp_name)
++{
++ int i = 0;
++ if (isp_name) {
++ while (i < fixups_sz && pptp_fixups[i].isp) {
++ if (!strcmp(pptp_fixups[i].isp, isp_name)) {
++ return i;
++ }
++ ++i;
++ }
++ }
++
++ return -1;
++}
++
++
+--- /dev/null
++++ b/pppd/plugins/pptp/pptp_quirks.h
+@@ -0,0 +1,59 @@
++/* pptp_quirks.h ...... various options to fix quirks found in buggy adsl modems
++ * mulix <mulix@actcom.co.il>
++ *
++ * $Id: pptp_quirks.h,v 1.1 2001/11/20 06:30:10 quozl Exp $
++ */
++
++#ifndef INC_PPTP_QUIRKS_H
++#define INC_PPTP_QUIRKS_H
++
++/* isp defs - correspond to slots in the fixups table */
++#define BEZEQ_ISRAEL "BEZEQ_ISRAEL"
++
++/* vendor defs */
++
++#define ORCKIT 1
++#define ALCATEL 2
++
++/* device defs */
++
++#define ORCKIT_ATUR2 1
++#define ORCKIT_ATUR3 2
++
++#include "pptp_msg.h"
++#include "pptp_ctrl.h"
++
++struct pptp_fixup {
++ const char* isp; /* which isp? e.g. Bezeq in Israel */
++ int vendor; /* which vendor? e.g. Orckit */
++ int device; /* which device? e.g. Orckit Atur3 */
++
++ /* use this hook to build your own out call request packet */
++ int (*out_call_rqst_hook)(struct pptp_out_call_rqst* packet);
++
++ /* use this hook to build your own start control connection packet */
++ /* note that this hook is called from two different places, depending
++ on whether this is a request or reply */
++ int (*start_ctrl_conn)(struct pptp_start_ctrl_conn* packet);
++
++ /* use this hook if you need to send a 'set_link' packet once
++ the connection is established */
++ int (*set_link_hook)(struct pptp_set_link_info* packet,
++ int peer_call_id);
++};
++
++extern struct pptp_fixup pptp_fixups[];
++
++/* find the index for this isp in the quirks table */
++/* return the index on success, -1 if not found */
++int find_quirk(const char* isp_name);
++
++/* set the global quirk index. return 0 on success, non 0 otherwise */
++int set_quirk_index(int index);
++
++/* get the global quirk index. return the index on success,
++ -1 if no quirk is defined */
++int get_quirk_index();
++
++
++#endif /* INC_PPTP_QUIRKS_H */
+--- /dev/null
++++ b/pppd/plugins/pptp/util.c
+@@ -0,0 +1,109 @@
++/* util.c ....... error message utilities.
++ * C. Scott Ananian <cananian@alumni.princeton.edu>
++ *
++ * $Id: util.c,v 1.11 2005/08/22 00:49:48 quozl Exp $
++ */
++
++#include <stdio.h>
++#include <stdarg.h>
++#include <syslog.h>
++#include <unistd.h>
++#include <stdlib.h>
++#include "util.h"
++
++#define MAKE_STRING(label) \
++va_list ap; \
++char buf[256], string[256]; \
++va_start(ap, format); \
++vsnprintf(buf, sizeof(buf), format, ap); \
++snprintf(string, sizeof(string), "%s %s[%s:%s:%d]: %s", \
++ log_string, label, func, file, line, buf); \
++va_end(ap)
++
++/*** connect a file to a file descriptor **************************************/
++int file2fd(const char *path, const char *mode, int fd)
++{
++ int ok = 0;
++ FILE *file = NULL;
++ file = fopen(path, mode);
++ if (file != NULL && dup2(fileno(file), fd) != -1)
++ ok = 1;
++ if (file) fclose(file);
++ return ok;
++}
++
++/* signal to pipe delivery implementation */
++#include <unistd.h>
++#include <fcntl.h>
++#include <signal.h>
++#include <string.h>
++
++/* pipe private to process */
++static int sigpipe[2];
++
++/* create a signal pipe, returns 0 for success, -1 with errno for failure */
++int sigpipe_create()
++{
++ int rc;
++
++ rc = pipe(sigpipe);
++ if (rc < 0) return rc;
++
++ fcntl(sigpipe[0], F_SETFD, FD_CLOEXEC);
++ fcntl(sigpipe[1], F_SETFD, FD_CLOEXEC);
++
++#ifdef O_NONBLOCK
++#define FLAG_TO_SET O_NONBLOCK
++#else
++#ifdef SYSV
++#define FLAG_TO_SET O_NDELAY
++#else /* BSD */
++#define FLAG_TO_SET FNDELAY
++#endif
++#endif
++
++ rc = fcntl(sigpipe[1], F_GETFL);
++ if (rc != -1)
++ rc = fcntl(sigpipe[1], F_SETFL, rc | FLAG_TO_SET);
++ if (rc < 0) return rc;
++ return 0;
++#undef FLAG_TO_SET
++}
++
++/* generic handler for signals, writes signal number to pipe */
++void sigpipe_handler(int signum)
++{
++ write(sigpipe[1], &signum, sizeof(signum));
++ signal(signum, sigpipe_handler);
++}
++
++/* assign a signal number to the pipe */
++void sigpipe_assign(int signum)
++{
++ struct sigaction sa;
++
++ memset(&sa, 0, sizeof(sa));
++ sa.sa_handler = sigpipe_handler;
++ sigaction(signum, &sa, NULL);
++}
++
++/* return the signal pipe read file descriptor for select(2) */
++int sigpipe_fd()
++{
++ return sigpipe[0];
++}
++
++/* read and return the pending signal from the pipe */
++int sigpipe_read()
++{
++ int signum;
++ read(sigpipe[0], &signum, sizeof(signum));
++ return signum;
++}
++
++void sigpipe_close()
++{
++ close(sigpipe[0]);
++ close(sigpipe[1]);
++}
++
+--- /dev/null
++++ b/pppd/plugins/pptp/util.h
+@@ -0,0 +1,31 @@
++/* util.h ....... error message utilities.
++ * C. Scott Ananian <cananian@alumni.princeton.edu>
++ *
++ * $Id: util.h,v 1.6 2005/03/10 01:18:20 quozl Exp $
++ */
++
++#ifndef INC_UTIL_H
++#define INC_UTIL_H
++
++int file2fd(const char *path, const char *mode, int fd);
++
++/* signal to pipe delivery implementation */
++
++/* create a signal pipe, returns 0 for success, -1 with errno for failure */
++int sigpipe_create();
++
++/* generic handler for signals, writes signal number to pipe */
++void sigpipe_handler(int signum);
++
++/* assign a signal number to the pipe */
++void sigpipe_assign(int signum);
++
++/* return the signal pipe read file descriptor for select(2) */
++int sigpipe_fd();
++
++/* read and return the pending signal from the pipe */
++int sigpipe_read();
++
++void sigpipe_close();
++
++#endif /* INC_UTIL_H */
+--- /dev/null
++++ b/pppd/plugins/pptp/vector.c
+@@ -0,0 +1,209 @@
++/* vector.c ..... store a vector of PPTP_CALL information and search it
++ * efficiently.
++ * C. Scott Ananian <cananian@alumni.princeton.edu>
++ *
++ * $Id: vector.c,v 1.3 2003/06/17 10:12:55 reink Exp $
++ */
++
++#include <stdlib.h>
++#include <string.h>
++#include <assert.h>
++#include "pptp_ctrl.h"
++#include "vector.h"
++/* #define VECTOR_DEBUG */
++#ifndef TRUE
++#define TRUE 1
++#endif
++#ifndef FALSE
++#define FALSE 0
++#endif
++
++struct vector_item {
++ int key;
++ PPTP_CALL *call;
++};
++
++struct vector_struct {
++ struct vector_item *item;
++ int size;
++ int alloc;
++#ifdef VECTOR_DEBUG
++ int key_max;
++#endif
++};
++
++static struct vector_item *binary_search(VECTOR *v, int key);
++
++/*** vector_create ************************************************************/
++VECTOR *vector_create()
++{
++ const int INITIAL_SIZE = 4;
++
++ VECTOR *v = malloc(sizeof(*v));
++ if (v == NULL) return v;
++
++ v->size = 0;
++ v->alloc = INITIAL_SIZE;
++ v->item = malloc(sizeof(*(v->item)) * (v->alloc));
++#ifdef VECTOR_DEBUG
++ v->key_max = -1;
++#endif
++ if (v->item == NULL) { free(v); return NULL; }
++ else return v;
++}
++
++/*** vector_destroy ***********************************************************/
++void vector_destroy(VECTOR *v)
++{
++ free(v->item);
++#ifdef VECTOR_DEBUG
++ v->item = NULL;
++#endif
++ free(v);
++}
++
++/*** vector_size **************************************************************/
++int vector_size(VECTOR *v)
++{
++ assert(v != NULL);
++ return v->size;
++}
++
++/*** vector_insert*************************************************************
++ * nice thing about file descriptors is that we are assured by POSIX
++ * that they are monotonically increasing.
++ */
++int vector_insert(VECTOR *v, int key, PPTP_CALL * call)
++{
++ int i;
++ assert(v != NULL && call != NULL);
++ assert(!vector_contains(v, key));
++#ifdef VECTOR_DEBUG
++ assert(v->key_max < key);
++#endif
++ if (!(v->size < v->alloc)) {
++ void *tmp = realloc(v->item, sizeof(*(v->item)) * 2 * v->alloc);
++ if (tmp != NULL) {
++ v->alloc *= 2;
++ v->item = tmp;
++ } else return FALSE; /* failed to alloc memory. */
++ }
++ assert(v->size < v->alloc);
++ /* for safety, we make this work in the general case;
++ * but this is optimized for adding call to the end of the vector.
++ */
++ for(i = v->size - 1; i >= 0; i--)
++ if (v->item[i].key < key)
++ break;
++ /* insert after item i */
++ memmove(&v->item[i + 2], &v->item[i + 1],
++ (v->size - i - 1) * sizeof(*(v->item)));
++ v->item[i + 1].key = key;
++ v->item[i + 1].call = call;
++ v->size++;
++#ifdef VECTOR_DEBUG
++ if (v->key_max < key) /* ie, always. */
++ v->key_max = key;
++#endif
++ return TRUE;
++}
++
++/*** vector_remove ************************************************************/
++int vector_remove(VECTOR *v, int key)
++{
++ struct vector_item *tmp;
++ assert(v != NULL);
++ if ((tmp =binary_search(v,key)) == NULL) return FALSE;
++ assert(tmp >= v->item && tmp < v->item + v->size);
++ memmove(tmp, tmp + 1, (v->size - (v->item - tmp) - 1) * sizeof(*(v->item)));
++ v->size--;
++ return TRUE;
++}
++
++/*** vector_search ************************************************************/
++int vector_search(VECTOR *v, int key, PPTP_CALL **call)
++{
++ struct vector_item *tmp;
++ assert(v != NULL);
++ tmp = binary_search(v, key);
++ if (tmp ==NULL) return FALSE;
++ *call = tmp->call;
++ return TRUE;
++}
++
++/*** vector_contains **********************************************************/
++int vector_contains(VECTOR *v, int key)
++{
++ assert(v != NULL);
++ return (binary_search(v, key) != NULL);
++}
++
++/*** vector_item **************************************************************/
++static struct vector_item *binary_search(VECTOR *v, int key)
++{
++ int l,r,x;
++ l = 0;
++ r = v->size - 1;
++ while (r >= l) {
++ x = (l + r)/2;
++ if (key < v->item[x].key) r = x - 1; else l = x + 1;
++ if (key == v->item[x].key) return &(v->item[x]);
++ }
++ return NULL;
++}
++
++/*** vector_scan ***************************************************************
++ * Hmm. Let's be fancy and use a binary search for the first
++ * unused key, taking advantage of the list is stored sorted; ie
++ * we can look at pointers and keys at two different locations,
++ * and if (ptr1 - ptr2) = (key1 - key2) then all the slots
++ * between ptr1 and ptr2 are filled. Note that ptr1-ptr2 should
++ * never be greater than key1-key2 (no duplicate keys!)... we
++ * check for this.
++ */
++int vector_scan(VECTOR *v, int lo, int hi, int *key)
++{
++ int l,r,x;
++ assert(v != NULL);
++ assert(key != NULL);
++ if ((v->size<1) || (lo < v->item[0].key)) { *key = lo; return TRUE; }
++ /* our array bounds */
++ l = 0; r = v->size - 1;
++ while (r > l) {
++ /* check for a free spot right after l */
++ if (v->item[l].key + 1 < v->item[l + 1].key) { /* found it! */
++ *key = v->item[l].key + 1;
++ return TRUE;
++ }
++ /* no dice. Let's see if the free spot is before or after the midpoint */
++ x = (l + r)/2;
++ /* Okay, we have right (r), left (l) and the probe (x). */
++ assert(x - l <= v->item[x].key - v->item[l].key);
++ assert(r - x <= v->item[r].key - v->item[x].key);
++ if (x - l < v->item[x].key - v->item[l].key)
++ /* room between l and x */
++ r = x;
++ else /* no room between l and x */
++ if (r - x < v->item[r].key - v->item[x].key)
++ /* room between x and r */
++ l = x;
++ else /* no room between x and r, either */
++ break; /* game over, man. */
++ }
++ /* no room found in already allocated space. Check to see if
++ * there's free space above allocated entries. */
++ if (v->item[v->size - 1].key < hi) {
++ *key = v->item[v->size - 1].key + 1;
++ return TRUE;
++ }
++ /* outta luck */
++ return FALSE;
++}
++
++/*** vector_get_Nth ***********************************************************/
++PPTP_CALL * vector_get_Nth(VECTOR *v, int n)
++{
++ assert(v != NULL);
++ assert(0 <= n && n < vector_size(v));
++ return v->item[n].call;
++}
+--- /dev/null
++++ b/pppd/plugins/pptp/vector.h
+@@ -0,0 +1,31 @@
++/* vector.h ..... store a vector of PPTP_CALL information and search it
++ * efficiently.
++ * C. Scott Ananian <cananian@alumni.princeton.edu>
++ *
++ * $Id: vector.h,v 1.1.1.1 2000/12/23 08:19:51 scott Exp $
++ */
++
++#ifndef INC_VECTOR_H
++#define INC_VECTOR_H
++
++#include "pptp_ctrl.h" /* for definition of PPTP_CALL */
++
++typedef struct vector_struct VECTOR;
++
++VECTOR *vector_create();
++void vector_destroy(VECTOR *v);
++
++int vector_size(VECTOR *v);
++
++/* vector_insert and vector_search return TRUE on success, FALSE on failure. */
++int vector_insert(VECTOR *v, int key, PPTP_CALL * call);
++int vector_remove(VECTOR *v, int key);
++int vector_search(VECTOR *v, int key, PPTP_CALL ** call);
++/* vector_contains returns FALSE if not found, TRUE if found. */
++int vector_contains(VECTOR *v, int key);
++/* find first unused key. Returns TRUE on success, FALSE if no. */
++int vector_scan(VECTOR *v, int lo, int hi, int *key);
++/* get a specific PPTP_CALL ... useful only when iterating. */
++PPTP_CALL * vector_get_Nth(VECTOR *v, int n);
++
++#endif /* INC_VECTOR_H */
diff --git a/package/network/services/ppp/patches/010-use_target_for_configure.patch b/package/network/services/ppp/patches/010-use_target_for_configure.patch
new file mode 100644
index 0000000..aff0df6
--- /dev/null
+++ b/package/network/services/ppp/patches/010-use_target_for_configure.patch
@@ -0,0 +1,24 @@
+configure: Allow overriding uname results
+
+In a cross compile setting it makes no sense to rely on the "uname" values
+reported by the build host system. This patch allows overriding the
+"uname -r", "uname -s" and "uname -m" results with the "UNAME_R", "UNAME_S"
+and "UNAME_M" environment variables.
+
+Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
+
+--- a/configure
++++ b/configure
+@@ -8,9 +8,9 @@ SYSCONF=/etc
+ # if [ -d /NextApps ]; then
+ # system="NeXTStep"
+ # else
+- system=`uname -s`
+- release=`uname -r`
+- arch=`uname -m`
++ system=${UNAME_S:-`uname -s`}
++ release=${UNAME_R:-`uname -r`}
++ arch=${UNAME_M:-`uname -m`}
+ # fi
+ state="unknown"
+
diff --git a/package/network/services/ppp/patches/100-debian_ip-ip_option.patch b/package/network/services/ppp/patches/100-debian_ip-ip_option.patch
new file mode 100644
index 0000000..ca43cb2
--- /dev/null
+++ b/package/network/services/ppp/patches/100-debian_ip-ip_option.patch
@@ -0,0 +1,96 @@
+pppd: Allow specifying ip-up and ip-down scripts
+
+This patch implements the "ip-up-script" and "ip-down-script" options which
+allow to specify the path of the ip-up and ip-down scripts to call.
+
+These options default to _PATH_IPUP and _PATH_IPDOWN to retain the
+existing behaviour.
+
+The patch originated from the Debian project.
+
+Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
+
+--- a/pppd/ipcp.c
++++ b/pppd/ipcp.c
+@@ -1939,7 +1939,7 @@ ipcp_up(f)
+ */
+ if (ipcp_script_state == s_down && ipcp_script_pid == 0) {
+ ipcp_script_state = s_up;
+- ipcp_script(_PATH_IPUP, 0);
++ ipcp_script(path_ipup, 0);
+ }
+ }
+
+@@ -1989,7 +1989,7 @@ ipcp_down(f)
+ /* Execute the ip-down script */
+ if (ipcp_script_state == s_up && ipcp_script_pid == 0) {
+ ipcp_script_state = s_down;
+- ipcp_script(_PATH_IPDOWN, 0);
++ ipcp_script(path_ipdown, 0);
+ }
+ }
+
+@@ -2043,13 +2043,13 @@ ipcp_script_done(arg)
+ case s_up:
+ if (ipcp_fsm[0].state != OPENED) {
+ ipcp_script_state = s_down;
+- ipcp_script(_PATH_IPDOWN, 0);
++ ipcp_script(path_ipdown, 0);
+ }
+ break;
+ case s_down:
+ if (ipcp_fsm[0].state == OPENED) {
+ ipcp_script_state = s_up;
+- ipcp_script(_PATH_IPUP, 0);
++ ipcp_script(path_ipup, 0);
+ }
+ break;
+ }
+--- a/pppd/main.c
++++ b/pppd/main.c
+@@ -316,6 +316,9 @@ main(argc, argv)
+ struct protent *protp;
+ char numbuf[16];
+
++ strlcpy(path_ipup, _PATH_IPUP, sizeof(path_ipup));
++ strlcpy(path_ipdown, _PATH_IPDOWN, sizeof(path_ipdown));
++
+ link_stats_valid = 0;
+ new_phase(PHASE_INITIALIZE);
+
+--- a/pppd/options.c
++++ b/pppd/options.c
+@@ -113,6 +113,8 @@ char linkname[MAXPATHLEN]; /* logical na
+ bool tune_kernel; /* may alter kernel settings */
+ int connect_delay = 1000; /* wait this many ms after connect script */
+ int req_unit = -1; /* requested interface unit */
++char path_ipup[MAXPATHLEN]; /* pathname of ip-up script */
++char path_ipdown[MAXPATHLEN];/* pathname of ip-down script */
+ bool multilink = 0; /* Enable multilink operation */
+ char *bundle_name = NULL; /* bundle name for multilink */
+ bool dump_options; /* print out option values */
+@@ -281,6 +283,13 @@ option_t general_options[] = {
+ "Number of seconds to wait for child processes at exit",
+ OPT_PRIO },
+
++ { "ip-up-script", o_string, path_ipup,
++ "Set pathname of ip-up script",
++ OPT_PRIV|OPT_STATIC, NULL, MAXPATHLEN },
++ { "ip-down-script", o_string, path_ipdown,
++ "Set pathname of ip-down script",
++ OPT_PRIV|OPT_STATIC, NULL, MAXPATHLEN },
++
+ #ifdef HAVE_MULTILINK
+ { "multilink", o_bool, &multilink,
+ "Enable multilink operation", OPT_PRIO | 1 },
+--- a/pppd/pppd.h
++++ b/pppd/pppd.h
+@@ -313,6 +313,8 @@ extern bool tune_kernel; /* May alter ke
+ extern int connect_delay; /* Time to delay after connect script */
+ extern int max_data_rate; /* max bytes/sec through charshunt */
+ extern int req_unit; /* interface unit number to use */
++extern char path_ipup[MAXPATHLEN]; /* pathname of ip-up script */
++extern char path_ipdown[MAXPATHLEN]; /* pathname of ip-down script */
+ extern bool multilink; /* enable multilink operation */
+ extern bool noendpoint; /* don't send or accept endpt. discrim. */
+ extern char *bundle_name; /* bundle name for multilink */
diff --git a/package/network/services/ppp/patches/101-debian_close_dev_ppp.patch b/package/network/services/ppp/patches/101-debian_close_dev_ppp.patch
new file mode 100644
index 0000000..232b10b
--- /dev/null
+++ b/package/network/services/ppp/patches/101-debian_close_dev_ppp.patch
@@ -0,0 +1,28 @@
+pppd: Close already open ppp descriptors
+
+When using the kernel PPPoE driver in conjunction with the "persist" option,
+the already open descriptor to /dev/ppp is not closed when the link is
+reestablished. This eventually leads to high CPU load because the stray
+descriptors are always reported as ready by select().
+
+This patch closes the descriptor if it is already open when establishing a
+new connection. It originated from the Debian project.
+
+Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
+
+--- a/pppd/sys-linux.c
++++ b/pppd/sys-linux.c
+@@ -453,6 +453,13 @@ int generic_establish_ppp (int fd)
+ if (new_style_driver) {
+ int flags;
+
++ /* if a ppp_fd is already open, close it first */
++ if(ppp_fd > 0) {
++ close(ppp_fd);
++ remove_fd(ppp_fd);
++ ppp_fd = -1;
++ }
++
+ /* Open an instance of /dev/ppp and connect the channel to it */
+ if (ioctl(fd, PPPIOCGCHAN, &chindex) == -1) {
+ error("Couldn't get channel number: %m");
diff --git a/package/network/services/ppp/patches/103-debian_fix_link_pidfile.patch b/package/network/services/ppp/patches/103-debian_fix_link_pidfile.patch
new file mode 100644
index 0000000..c8a23ed
--- /dev/null
+++ b/package/network/services/ppp/patches/103-debian_fix_link_pidfile.patch
@@ -0,0 +1,23 @@
+pppd: Fix creation of linkpidfile
+
+When pppd is run without "nodetach" or with "updetach", the linkpidfile is
+never created. The call to create_linkpidfile() is protected by a check for
+linkpidfile[0] but this is only filled in when create_linkpidfile() is called.
+
+This patch changes to code to allways uncondiationally call
+create_linkpidfile(), it originated from the Debian project.
+
+Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
+
+--- a/pppd/main.c
++++ b/pppd/main.c
+@@ -773,8 +773,7 @@ detach()
+ /* update pid files if they have been written already */
+ if (pidfilename[0])
+ create_pidfile(pid);
+- if (linkpidfile[0])
+- create_linkpidfile(pid);
++ create_linkpidfile(pid);
+ exit(0); /* parent dies */
+ }
+ setsid();
diff --git a/package/network/services/ppp/patches/105-debian_demand.patch b/package/network/services/ppp/patches/105-debian_demand.patch
new file mode 100644
index 0000000..c278656
--- /dev/null
+++ b/package/network/services/ppp/patches/105-debian_demand.patch
@@ -0,0 +1,172 @@
+--- a/pppd/demand.c
++++ b/pppd/demand.c
+@@ -36,6 +36,8 @@
+ #include <errno.h>
+ #include <fcntl.h>
+ #include <netdb.h>
++#include <unistd.h>
++#include <syslog.h>
+ #include <sys/param.h>
+ #include <sys/types.h>
+ #include <sys/wait.h>
+@@ -43,6 +45,8 @@
+ #include <sys/resource.h>
+ #include <sys/stat.h>
+ #include <sys/socket.h>
++#include <netinet/in.h>
++#include <arpa/inet.h>
+ #ifdef PPP_FILTER
+ #include <pcap-bpf.h>
+ #endif
+@@ -221,6 +225,14 @@ loop_chars(p, n)
+ int c, rv;
+
+ rv = 0;
++
++/* check for synchronous connection... */
++
++ if ( (p[0] == 0xFF) && (p[1] == 0x03) ) {
++ rv = loop_frame(p,n);
++ return rv;
++ }
++
+ for (; n > 0; --n) {
+ c = *p++;
+ if (c == PPP_FLAG) {
+@@ -299,17 +311,102 @@ loop_frame(frame, len)
+ * loopback, now that the real serial link is up.
+ */
+ void
+-demand_rexmit(proto)
++demand_rexmit(proto, newip)
+ int proto;
++ u_int32_t newip;
+ {
+ struct packet *pkt, *prev, *nextpkt;
++ unsigned short checksum;
++ unsigned short pkt_checksum = 0;
++ unsigned iphdr;
++ struct timeval tv;
++ char cv = 0;
++ char ipstr[16];
+
+ prev = NULL;
+ pkt = pend_q;
+ pend_q = NULL;
++ tv.tv_sec = 1;
++ tv.tv_usec = 0;
++ select(0,NULL,NULL,NULL,&tv); /* Sleep for 1 Seconds */
+ for (; pkt != NULL; pkt = nextpkt) {
+ nextpkt = pkt->next;
+ if (PPP_PROTOCOL(pkt->data) == proto) {
++ if ( (proto == PPP_IP) && newip ) {
++ /* Get old checksum */
++
++ iphdr = (pkt->data[4] & 15) << 2;
++ checksum = *((unsigned short *) (pkt->data+14));
++ if (checksum == 0xFFFF) {
++ checksum = 0;
++ }
++
++
++ if (pkt->data[13] == 17) {
++ pkt_checksum = *((unsigned short *) (pkt->data+10+iphdr));
++ if (pkt_checksum) {
++ cv = 1;
++ if (pkt_checksum == 0xFFFF) {
++ pkt_checksum = 0;
++ }
++ }
++ else {
++ cv = 0;
++ }
++ }
++
++ if (pkt->data[13] == 6) {
++ pkt_checksum = *((unsigned short *) (pkt->data+20+iphdr));
++ cv = 1;
++ if (pkt_checksum == 0xFFFF) {
++ pkt_checksum = 0;
++ }
++ }
++
++ /* Delete old Source-IP-Address */
++ checksum -= *((unsigned short *) (pkt->data+16)) ^ 0xFFFF;
++ checksum -= *((unsigned short *) (pkt->data+18)) ^ 0xFFFF;
++
++ pkt_checksum -= *((unsigned short *) (pkt->data+16)) ^ 0xFFFF;
++ pkt_checksum -= *((unsigned short *) (pkt->data+18)) ^ 0xFFFF;
++
++ /* Change Source-IP-Address */
++ * ((u_int32_t *) (pkt->data + 16)) = newip;
++
++ /* Add new Source-IP-Address */
++ checksum += *((unsigned short *) (pkt->data+16)) ^ 0xFFFF;
++ checksum += *((unsigned short *) (pkt->data+18)) ^ 0xFFFF;
++
++ pkt_checksum += *((unsigned short *) (pkt->data+16)) ^ 0xFFFF;
++ pkt_checksum += *((unsigned short *) (pkt->data+18)) ^ 0xFFFF;
++
++ /* Write new checksum */
++ if (!checksum) {
++ checksum = 0xFFFF;
++ }
++ *((unsigned short *) (pkt->data+14)) = checksum;
++ if (pkt->data[13] == 6) {
++ *((unsigned short *) (pkt->data+20+iphdr)) = pkt_checksum;
++ }
++ if (cv && (pkt->data[13] == 17) ) {
++ *((unsigned short *) (pkt->data+10+iphdr)) = pkt_checksum;
++ }
++
++ /* Log Packet */
++ strcpy(ipstr,inet_ntoa(*( (struct in_addr *) (pkt->data+16))));
++ if (pkt->data[13] == 1) {
++ syslog(LOG_INFO,"Open ICMP %s -> %s\n",
++ ipstr,
++ inet_ntoa(*( (struct in_addr *) (pkt->data+20))));
++ } else {
++ syslog(LOG_INFO,"Open %s %s:%d -> %s:%d\n",
++ pkt->data[13] == 6 ? "TCP" : "UDP",
++ ipstr,
++ ntohs(*( (short *) (pkt->data+iphdr+4))),
++ inet_ntoa(*( (struct in_addr *) (pkt->data+20))),
++ ntohs(*( (short *) (pkt->data+iphdr+6))));
++ }
++ }
+ output(0, pkt->data, pkt->length);
+ free(pkt);
+ } else {
+--- a/pppd/ipcp.c
++++ b/pppd/ipcp.c
+@@ -1864,7 +1864,7 @@ ipcp_up(f)
+ proxy_arp_set[f->unit] = 1;
+
+ }
+- demand_rexmit(PPP_IP);
++ demand_rexmit(PPP_IP,go->ouraddr);
+ sifnpmode(f->unit, PPP_IP, NPMODE_PASS);
+
+ } else {
+--- a/pppd/ipv6cp.c
++++ b/pppd/ipv6cp.c
+@@ -1232,7 +1232,7 @@ ipv6cp_up(f)
+ }
+
+ }
+- demand_rexmit(PPP_IPV6);
++ demand_rexmit(PPP_IPV6,0);
+ sifnpmode(f->unit, PPP_IPV6, NPMODE_PASS);
+
+ } else {
+--- a/pppd/pppd.h
++++ b/pppd/pppd.h
+@@ -566,7 +566,7 @@ void demand_conf __P((void)); /* config
+ void demand_block __P((void)); /* set all NPs to queue up packets */
+ void demand_unblock __P((void)); /* set all NPs to pass packets */
+ void demand_discard __P((void)); /* set all NPs to discard packets */
+-void demand_rexmit __P((int)); /* retransmit saved frames for an NP */
++void demand_rexmit __P((int, u_int32_t)); /* retransmit saved frames for an NP*/
+ int loop_chars __P((unsigned char *, int)); /* process chars from loopback */
+ int loop_frame __P((unsigned char *, int)); /* should we bring link up? */
+
diff --git a/package/network/services/ppp/patches/106-debian_stripMSdomain.patch b/package/network/services/ppp/patches/106-debian_stripMSdomain.patch
new file mode 100644
index 0000000..86af1ef
--- /dev/null
+++ b/package/network/services/ppp/patches/106-debian_stripMSdomain.patch
@@ -0,0 +1,47 @@
+pppd: Implement option to strip domain part from MS CHAP response
+
+This patch implements a new boolean option "chapms-strip-domain" which
+strips the leading domain part of the username in a received MS Chap
+response.
+
+When the option is set, all leading chars up to and including the last
+backslash in the username are stripped. The option defaults to false.
+
+The patch originated from the Debian project.
+
+Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
+
+--- a/pppd/chap-new.c
++++ b/pppd/chap-new.c
+@@ -58,6 +58,7 @@ int (*chap_verify_hook)(char *name, char
+ int chap_timeout_time = 3;
+ int chap_max_transmits = 10;
+ int chap_rechallenge_time = 0;
++int chapms_strip_domain = 0;
+
+ /*
+ * Command-line options.
+@@ -69,6 +70,8 @@ static option_t chap_option_list[] = {
+ "Set max #xmits for challenge", OPT_PRIO },
+ { "chap-interval", o_int, &chap_rechallenge_time,
+ "Set interval for rechallenge", OPT_PRIO },
++ { "chapms-strip-domain", o_bool, &chapms_strip_domain,
++ "Strip the domain prefix before the Username", 1 },
+ { NULL }
+ };
+
+@@ -336,6 +339,14 @@ chap_handle_response(struct chap_server_
+ /* Null terminate and clean remote name. */
+ slprintf(rname, sizeof(rname), "%.*v", len, name);
+ name = rname;
++
++ /* strip the MS domain name */
++ if (chapms_strip_domain && strrchr(rname, '\\')) {
++ char tmp[MAXNAMELEN+1];
++
++ strcpy(tmp, strrchr(rname, '\\') + 1);
++ strcpy(rname, tmp);
++ }
+ }
+
+ if (chap_verify_hook)
diff --git a/package/network/services/ppp/patches/107-debian_pppoatm_wildcard.patch b/package/network/services/ppp/patches/107-debian_pppoatm_wildcard.patch
new file mode 100644
index 0000000..eaad2cd
--- /dev/null
+++ b/package/network/services/ppp/patches/107-debian_pppoatm_wildcard.patch
@@ -0,0 +1,25 @@
+pppoatm: Allow wildcard ATM devices
+
+When operating pppd's pppoatm plugin with an USB ADSL modem, e.g. an
+Alcatel Speedtouch, the ATM device number might change when the modem is
+reconnected to the USB port or when the host controller resets the USB
+device.
+
+This patch allows to specify the ATM device as wildcard which gives
+enough flexibility to cope with changing device names.
+
+The patch originated from the Debain project.
+
+Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
+
+--- a/pppd/plugins/pppoatm/pppoatm.c
++++ b/pppd/plugins/pppoatm/pppoatm.c
+@@ -75,7 +75,7 @@ static int setdevname_pppoatm(const char
+ //info("PPPoATM setdevname_pppoatm: '%s'", cp);
+ memset(&addr, 0, sizeof addr);
+ if (text2atm(cp, (struct sockaddr *) &addr, sizeof(addr),
+- T2A_PVC | T2A_NAME) < 0) {
++ T2A_PVC | T2A_NAME | T2A_WILDCARD) < 0) {
+ if(doit)
+ info("atm does not recognize: %s", cp);
+ return 0;
diff --git a/package/network/services/ppp/patches/110-debian_defaultroute.patch b/package/network/services/ppp/patches/110-debian_defaultroute.patch
new file mode 100644
index 0000000..41d2890
--- /dev/null
+++ b/package/network/services/ppp/patches/110-debian_defaultroute.patch
@@ -0,0 +1,313 @@
+pppd: Add "replacedefaultroute" and "noreplacedefaultroute" options
+
+This patch implements two new options, "replacedefaultroute" to replace any
+existing system default route when specified and "noreplacedefaultroute" to
+disable the "replacedefaultroute" option, which is useful in multi user
+environments where the administrator wants to allow users to dial pppd
+connections but not allow them to change the system default route.
+
+The patch originated from the Debian project.
+
+Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
+
+--- a/pppd/ipcp.c
++++ b/pppd/ipcp.c
+@@ -198,6 +198,14 @@ static option_t ipcp_option_list[] = {
+ "disable defaultroute option", OPT_ALIAS | OPT_A2CLR,
+ &ipcp_wantoptions[0].default_route },
+
++ { "replacedefaultroute", o_bool,
++ &ipcp_wantoptions[0].replace_default_route,
++ "Replace default route", 1
++ },
++ { "noreplacedefaultroute", o_bool,
++ &ipcp_allowoptions[0].replace_default_route,
++ "Never replace default route", OPT_A2COPY,
++ &ipcp_wantoptions[0].replace_default_route },
+ { "proxyarp", o_bool, &ipcp_wantoptions[0].proxy_arp,
+ "Add proxy ARP entry", OPT_ENABLE|1, &ipcp_allowoptions[0].proxy_arp },
+ { "noproxyarp", o_bool, &ipcp_allowoptions[0].proxy_arp,
+@@ -271,7 +279,7 @@ struct protent ipcp_protent = {
+ ip_active_pkt
+ };
+
+-static void ipcp_clear_addrs __P((int, u_int32_t, u_int32_t));
++static void ipcp_clear_addrs __P((int, u_int32_t, u_int32_t, bool));
+ static void ipcp_script __P((char *, int)); /* Run an up/down script */
+ static void ipcp_script_done __P((void *));
+
+@@ -1742,7 +1750,8 @@ ip_demand_conf(u)
+ if (!sifnpmode(u, PPP_IP, NPMODE_QUEUE))
+ return 0;
+ if (wo->default_route)
+- if (sifdefaultroute(u, wo->ouraddr, wo->hisaddr))
++ if (sifdefaultroute(u, wo->ouraddr, wo->hisaddr,
++ wo->replace_default_route))
+ default_route_set[u] = 1;
+ if (wo->proxy_arp)
+ if (sifproxyarp(u, wo->hisaddr))
+@@ -1830,7 +1839,8 @@ ipcp_up(f)
+ */
+ if (demand) {
+ if (go->ouraddr != wo->ouraddr || ho->hisaddr != wo->hisaddr) {
+- ipcp_clear_addrs(f->unit, wo->ouraddr, wo->hisaddr);
++ ipcp_clear_addrs(f->unit, wo->ouraddr, wo->hisaddr,
++ wo->replace_default_route);
+ if (go->ouraddr != wo->ouraddr) {
+ warn("Local IP address changed to %I", go->ouraddr);
+ script_setenv("OLDIPLOCAL", ip_ntoa(wo->ouraddr), 0);
+@@ -1855,7 +1865,8 @@ ipcp_up(f)
+
+ /* assign a default route through the interface if required */
+ if (ipcp_wantoptions[f->unit].default_route)
+- if (sifdefaultroute(f->unit, go->ouraddr, ho->hisaddr))
++ if (sifdefaultroute(f->unit, go->ouraddr, ho->hisaddr,
++ wo->replace_default_route))
+ default_route_set[f->unit] = 1;
+
+ /* Make a proxy ARP entry if requested. */
+@@ -1905,7 +1916,8 @@ ipcp_up(f)
+
+ /* assign a default route through the interface if required */
+ if (ipcp_wantoptions[f->unit].default_route)
+- if (sifdefaultroute(f->unit, go->ouraddr, ho->hisaddr))
++ if (sifdefaultroute(f->unit, go->ouraddr, ho->hisaddr,
++ wo->replace_default_route))
+ default_route_set[f->unit] = 1;
+
+ /* Make a proxy ARP entry if requested. */
+@@ -1983,7 +1995,7 @@ ipcp_down(f)
+ sifnpmode(f->unit, PPP_IP, NPMODE_DROP);
+ sifdown(f->unit);
+ ipcp_clear_addrs(f->unit, ipcp_gotoptions[f->unit].ouraddr,
+- ipcp_hisoptions[f->unit].hisaddr);
++ ipcp_hisoptions[f->unit].hisaddr, 0);
+ }
+
+ /* Execute the ip-down script */
+@@ -1999,16 +2011,25 @@ ipcp_down(f)
+ * proxy arp entries, etc.
+ */
+ static void
+-ipcp_clear_addrs(unit, ouraddr, hisaddr)
++ipcp_clear_addrs(unit, ouraddr, hisaddr, replacedefaultroute)
+ int unit;
+ u_int32_t ouraddr; /* local address */
+ u_int32_t hisaddr; /* remote address */
++ bool replacedefaultroute;
+ {
+ if (proxy_arp_set[unit]) {
+ cifproxyarp(unit, hisaddr);
+ proxy_arp_set[unit] = 0;
+ }
+- if (default_route_set[unit]) {
++ /* If replacedefaultroute, sifdefaultroute will be called soon
++ * with replacedefaultroute set and that will overwrite the current
++ * default route. This is the case only when doing demand, otherwise
++ * during demand, this cifdefaultroute would restore the old default
++ * route which is not what we want in this case. In the non-demand
++ * case, we'll delete the default route and restore the old if there
++ * is one saved by an sifdefaultroute with replacedefaultroute.
++ */
++ if (!replacedefaultroute && default_route_set[unit]) {
+ cifdefaultroute(unit, ouraddr, hisaddr);
+ default_route_set[unit] = 0;
+ }
+--- a/pppd/ipcp.h
++++ b/pppd/ipcp.h
+@@ -70,6 +70,7 @@ typedef struct ipcp_options {
+ bool old_addrs; /* Use old (IP-Addresses) option? */
+ bool req_addr; /* Ask peer to send IP address? */
+ bool default_route; /* Assign default route through interface? */
++ bool replace_default_route; /* Replace default route through interface? */
+ bool proxy_arp; /* Make proxy ARP entry for peer? */
+ bool neg_vj; /* Van Jacobson Compression? */
+ bool old_vj; /* use old (short) form of VJ option? */
+--- a/pppd/pppd.8
++++ b/pppd/pppd.8
+@@ -121,6 +121,11 @@ the gateway, when IPCP negotiation is su
+ This entry is removed when the PPP connection is broken. This option
+ is privileged if the \fInodefaultroute\fR option has been specified.
+ .TP
++.B replacedefaultroute
++This option is a flag to the defaultroute option. If defaultroute is
++set and this flag is also set, pppd replaces an existing default route
++with the new default route.
++.TP
+ .B disconnect \fIscript
+ Execute the command specified by \fIscript\fR, by passing it to a
+ shell, after
+@@ -717,7 +722,12 @@ disable both forms of hardware flow cont
+ .TP
+ .B nodefaultroute
+ Disable the \fIdefaultroute\fR option. The system administrator who
+-wishes to prevent users from creating default routes with pppd
++wishes to prevent users from adding a default route with pppd
++can do so by placing this option in the /etc/ppp/options file.
++.TP
++.B noreplacedefaultroute
++Disable the \fIreplacedefaultroute\fR option. The system administrator who
++wishes to prevent users from replacing a default route with pppd
+ can do so by placing this option in the /etc/ppp/options file.
+ .TP
+ .B nodeflate
+--- a/pppd/pppd.h
++++ b/pppd/pppd.h
+@@ -645,7 +645,7 @@ int sif6addr __P((int, eui64_t, eui64_t
+ int cif6addr __P((int, eui64_t, eui64_t));
+ /* Remove an IPv6 address from i/f */
+ #endif
+-int sifdefaultroute __P((int, u_int32_t, u_int32_t));
++int sifdefaultroute __P((int, u_int32_t, u_int32_t, bool replace_default_rt));
+ /* Create default route through i/f */
+ int cifdefaultroute __P((int, u_int32_t, u_int32_t));
+ /* Delete default route through i/f */
+--- a/pppd/sys-linux.c
++++ b/pppd/sys-linux.c
+@@ -206,6 +206,8 @@ static unsigned char inbuf[512]; /* buff
+
+ static int if_is_up; /* Interface has been marked up */
+ static int have_default_route; /* Gateway for default route added */
++static struct rtentry old_def_rt; /* Old default route */
++static int default_rt_repl_rest; /* replace and restore old default rt */
+ static u_int32_t proxy_arp_addr; /* Addr for proxy arp entry added */
+ static char proxy_arp_dev[16]; /* Device for proxy arp entry */
+ static u_int32_t our_old_addr; /* for detecting address changes */
+@@ -1544,6 +1546,9 @@ static int read_route_table(struct rtent
+ p = NULL;
+ }
+
++ SET_SA_FAMILY (rt->rt_dst, AF_INET);
++ SET_SA_FAMILY (rt->rt_gateway, AF_INET);
++
+ SIN_ADDR(rt->rt_dst) = strtoul(cols[route_dest_col], NULL, 16);
+ SIN_ADDR(rt->rt_gateway) = strtoul(cols[route_gw_col], NULL, 16);
+ SIN_ADDR(rt->rt_genmask) = strtoul(cols[route_mask_col], NULL, 16);
+@@ -1613,20 +1618,51 @@ int have_route_to(u_int32_t addr)
+ /********************************************************************
+ *
+ * sifdefaultroute - assign a default route through the address given.
+- */
+-
+-int sifdefaultroute (int unit, u_int32_t ouraddr, u_int32_t gateway)
+-{
+- struct rtentry rt;
+-
+- if (defaultroute_exists(&rt) && strcmp(rt.rt_dev, ifname) != 0) {
+- if (rt.rt_flags & RTF_GATEWAY)
+- error("not replacing existing default route via %I",
+- SIN_ADDR(rt.rt_gateway));
+- else
++ *
++ * If the global default_rt_repl_rest flag is set, then this function
++ * already replaced the original system defaultroute with some other
++ * route and it should just replace the current defaultroute with
++ * another one, without saving the current route. Use: demand mode,
++ * when pppd sets first a defaultroute it it's temporary ppp0 addresses
++ * and then changes the temporary addresses to the addresses for the real
++ * ppp connection when it has come up.
++ */
++
++int sifdefaultroute (int unit, u_int32_t ouraddr, u_int32_t gateway, bool replace)
++{
++ struct rtentry rt, tmp_rt;
++ struct rtentry *del_rt = NULL;
++
++ if (default_rt_repl_rest) {
++ /* We have already reclaced the original defaultroute, if we
++ are called again, we will delete the current default route
++ and set the new default route in this function.
++ - this is normally only the case the doing demand: */
++ if (defaultroute_exists(&tmp_rt))
++ del_rt = &tmp_rt;
++ } else if (defaultroute_exists(&old_def_rt) &&
++ strcmp(old_def_rt.rt_dev, ifname) != 0) {
++ /* We did not yet replace an existing default route, let's
++ check if we should save and replace a default route: */
++ if (old_def_rt.rt_flags & RTF_GATEWAY) {
++ if (!replace) {
++ error("not replacing existing default route via %I",
++ SIN_ADDR(old_def_rt.rt_gateway));
++ return 0;
++ } else {
++ /* we need to copy rt_dev because we need it permanent too: */
++ char *tmp_dev = malloc(strlen(old_def_rt.rt_dev) + 1);
++ strcpy(tmp_dev, old_def_rt.rt_dev);
++ old_def_rt.rt_dev = tmp_dev;
++
++ notice("replacing old default route to %s [%I]",
++ old_def_rt.rt_dev, SIN_ADDR(old_def_rt.rt_gateway));
++ default_rt_repl_rest = 1;
++ del_rt = &old_def_rt;
++ }
++ } else
+ error("not replacing existing default route through %s",
+- rt.rt_dev);
+- return 0;
++ old_def_rt.rt_dev);
+ }
+
+ memset (&rt, 0, sizeof (rt));
+@@ -1641,10 +1677,16 @@ int sifdefaultroute (int unit, u_int32_t
+
+ rt.rt_flags = RTF_UP;
+ if (ioctl(sock_fd, SIOCADDRT, &rt) < 0) {
+- if ( ! ok_error ( errno ))
++ if (!ok_error(errno))
+ error("default route ioctl(SIOCADDRT): %m");
+ return 0;
+ }
++ if (default_rt_repl_rest && del_rt)
++ if (ioctl(sock_fd, SIOCDELRT, del_rt) < 0) {
++ if (!ok_error(errno))
++ error("del old default route ioctl(SIOCDELRT): %m");
++ return 0;
++ }
+
+ have_default_route = 1;
+ return 1;
+@@ -1675,11 +1717,21 @@ int cifdefaultroute (int unit, u_int32_t
+ rt.rt_flags = RTF_UP;
+ if (ioctl(sock_fd, SIOCDELRT, &rt) < 0 && errno != ESRCH) {
+ if (still_ppp()) {
+- if ( ! ok_error ( errno ))
++ if (!ok_error(errno))
+ error("default route ioctl(SIOCDELRT): %m");
+ return 0;
+ }
+ }
++ if (default_rt_repl_rest) {
++ notice("restoring old default route to %s [%I]",
++ old_def_rt.rt_dev, SIN_ADDR(old_def_rt.rt_gateway));
++ if (ioctl(sock_fd, SIOCADDRT, &old_def_rt) < 0) {
++ if (!ok_error(errno))
++ error("restore default route ioctl(SIOCADDRT): %m");
++ return 0;
++ }
++ default_rt_repl_rest = 0;
++ }
+
+ return 1;
+ }
+--- a/pppd/sys-solaris.c
++++ b/pppd/sys-solaris.c
+@@ -2036,12 +2036,18 @@ cifaddr(u, o, h)
+ * sifdefaultroute - assign a default route through the address given.
+ */
+ int
+-sifdefaultroute(u, l, g)
++sifdefaultroute(u, l, g, replace)
+ int u;
+ u_int32_t l, g;
++ bool replace;
+ {
+ struct rtentry rt;
+
++ if (replace) {
++ error("replacedefaultroute not supported on this platform");
++ return 0;
++ }
++
+ #if defined(__USLC__)
+ g = l; /* use the local address as gateway */
+ #endif
diff --git a/package/network/services/ppp/patches/120-debian_ipv6_updown_option.patch b/package/network/services/ppp/patches/120-debian_ipv6_updown_option.patch
new file mode 100644
index 0000000..c5457fa
--- /dev/null
+++ b/package/network/services/ppp/patches/120-debian_ipv6_updown_option.patch
@@ -0,0 +1,95 @@
+pppd: Allow specifying ipv6-up and ipv6-down scripts
+
+This patch implements the "ipv6-up-script" and "ipv6-down-script" options
+which allow to specify the path of the ipv6-up and ipv6-down scripts to call.
+
+These options default to _PATH_IPV6UP and _PATH_IPV6DOWN to retain the
+existing behaviour.
+
+The patch originated from the Debian project.
+
+Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
+
+--- a/pppd/main.c
++++ b/pppd/main.c
+@@ -318,6 +318,8 @@ main(argc, argv)
+
+ strlcpy(path_ipup, _PATH_IPUP, sizeof(path_ipup));
+ strlcpy(path_ipdown, _PATH_IPDOWN, sizeof(path_ipdown));
++ strlcpy(path_ipv6up, _PATH_IPV6UP, sizeof(path_ipv6up));
++ strlcpy(path_ipv6down, _PATH_IPV6DOWN, sizeof(path_ipv6down));
+
+ link_stats_valid = 0;
+ new_phase(PHASE_INITIALIZE);
+--- a/pppd/options.c
++++ b/pppd/options.c
+@@ -115,6 +115,8 @@ int connect_delay = 1000; /* wait this m
+ int req_unit = -1; /* requested interface unit */
+ char path_ipup[MAXPATHLEN]; /* pathname of ip-up script */
+ char path_ipdown[MAXPATHLEN];/* pathname of ip-down script */
++char path_ipv6up[MAXPATHLEN]; /* pathname of ipv6-up script */
++char path_ipv6down[MAXPATHLEN];/* pathname of ipv6-down script */
+ bool multilink = 0; /* Enable multilink operation */
+ char *bundle_name = NULL; /* bundle name for multilink */
+ bool dump_options; /* print out option values */
+@@ -290,6 +292,13 @@ option_t general_options[] = {
+ "Set pathname of ip-down script",
+ OPT_PRIV|OPT_STATIC, NULL, MAXPATHLEN },
+
++ { "ipv6-up-script", o_string, path_ipv6up,
++ "Set pathname of ipv6-up script",
++ OPT_PRIV|OPT_STATIC, NULL, MAXPATHLEN },
++ { "ipv6-down-script", o_string, path_ipv6down,
++ "Set pathname of ipv6-down script",
++ OPT_PRIV|OPT_STATIC, NULL, MAXPATHLEN },
++
+ #ifdef HAVE_MULTILINK
+ { "multilink", o_bool, &multilink,
+ "Enable multilink operation", OPT_PRIO | 1 },
+--- a/pppd/ipv6cp.c
++++ b/pppd/ipv6cp.c
+@@ -1288,7 +1288,7 @@ ipv6cp_up(f)
+ */
+ if (ipv6cp_script_state == s_down && ipv6cp_script_pid == 0) {
+ ipv6cp_script_state = s_up;
+- ipv6cp_script(_PATH_IPV6UP);
++ ipv6cp_script(path_ipv6up);
+ }
+ }
+
+@@ -1339,7 +1339,7 @@ ipv6cp_down(f)
+ /* Execute the ipv6-down script */
+ if (ipv6cp_script_state == s_up && ipv6cp_script_pid == 0) {
+ ipv6cp_script_state = s_down;
+- ipv6cp_script(_PATH_IPV6DOWN);
++ ipv6cp_script(path_ipv6down);
+ }
+ }
+
+@@ -1382,13 +1382,13 @@ ipv6cp_script_done(arg)
+ case s_up:
+ if (ipv6cp_fsm[0].state != OPENED) {
+ ipv6cp_script_state = s_down;
+- ipv6cp_script(_PATH_IPV6DOWN);
++ ipv6cp_script(path_ipv6down);
+ }
+ break;
+ case s_down:
+ if (ipv6cp_fsm[0].state == OPENED) {
+ ipv6cp_script_state = s_up;
+- ipv6cp_script(_PATH_IPV6UP);
++ ipv6cp_script(path_ipv6up);
+ }
+ break;
+ }
+--- a/pppd/pppd.h
++++ b/pppd/pppd.h
+@@ -315,6 +315,8 @@ extern int max_data_rate; /* max bytes/s
+ extern int req_unit; /* interface unit number to use */
+ extern char path_ipup[MAXPATHLEN]; /* pathname of ip-up script */
+ extern char path_ipdown[MAXPATHLEN]; /* pathname of ip-down script */
++extern char path_ipv6up[MAXPATHLEN]; /* pathname of ipv6-up script */
++extern char path_ipv6down[MAXPATHLEN]; /* pathname of ipv6-down script */
+ extern bool multilink; /* enable multilink operation */
+ extern bool noendpoint; /* don't send or accept endpt. discrim. */
+ extern char *bundle_name; /* bundle name for multilink */
diff --git a/package/network/services/ppp/patches/200-makefile.patch b/package/network/services/ppp/patches/200-makefile.patch
new file mode 100644
index 0000000..9db908d
--- /dev/null
+++ b/package/network/services/ppp/patches/200-makefile.patch
@@ -0,0 +1,55 @@
+pppd: tune Linux config defaults for OpenWrt
+
+This patch adjusts a number defaults to properly match the OpenWrt environment.
+It is not intended for upstream.
+
+Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
+
+--- a/pppd/Makefile.linux
++++ b/pppd/Makefile.linux
+@@ -48,7 +48,7 @@ MPPE=y
+ # Uncomment the next line to include support for PPP packet filtering.
+ # This requires that the libpcap library and headers be installed
+ # and that the kernel driver support PPP packet filtering.
+-FILTER=y
++#FILTER=y
+
+ # Uncomment the next line to enable multilink PPP (enabled by default)
+ # Linux distributions: Please leave multilink ENABLED in your builds
+@@ -58,11 +58,11 @@ HAVE_MULTILINK=y
+ # Uncomment the next line to enable the TDB database (enabled by default.)
+ # If you enable multilink, then TDB is automatically enabled also.
+ # Linux distributions: Please leave TDB ENABLED in your builds.
+-USE_TDB=y
++#USE_TDB=y
+
+-HAS_SHADOW=y
++#HAS_SHADOW=y
+ #USE_PAM=y
+-#HAVE_INET6=y
++HAVE_INET6=y
+
+ # Enable plugins
+ PLUGIN=y
+@@ -77,7 +77,7 @@ MAXOCTETS=y
+
+ INCLUDE_DIRS= -I../include
+
+-COMPILE_FLAGS= -DHAVE_PATHS_H -DIPX_CHANGE -DHAVE_MMAP
++COMPILE_FLAGS= -DHAVE_PATHS_H -DHAVE_MMAP
+
+ CFLAGS= $(COPTS) $(COMPILE_FLAGS) $(INCLUDE_DIRS) '-DDESTDIR="@DESTDIR@"'
+
+@@ -117,10 +117,10 @@ CFLAGS += -DHAS_SHADOW
+ #LIBS += -lshadow $(LIBS)
+ endif
+
+-ifneq ($(wildcard /usr/include/crypt.h),)
++#ifneq ($(wildcard /usr/include/crypt.h),)
+ CFLAGS += -DHAVE_CRYPT_H=1
+ LIBS += -lcrypt
+-endif
++#endif
+
+ ifdef NEEDDES
+ ifndef USE_CRYPT
diff --git a/package/network/services/ppp/patches/201-mppe_mppc_1.1.patch b/package/network/services/ppp/patches/201-mppe_mppc_1.1.patch
new file mode 100644
index 0000000..3edd11e
--- /dev/null
+++ b/package/network/services/ppp/patches/201-mppe_mppc_1.1.patch
@@ -0,0 +1,1495 @@
+pppd: add support for MPPE and MPPC encryption and compression protocols
+
+This is a forward ported version of ppp-2.4.3-mppe-mppc-1.1.patch.gz found on
+http://mppe-mppc.alphacron.de/ .
+
+Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
+
+--- a/include/linux/ppp-comp.h
++++ b/include/linux/ppp-comp.h
+@@ -36,7 +36,7 @@
+ */
+
+ /*
+- * ==FILEVERSION 20020319==
++ * ==FILEVERSION 20020715==
+ *
+ * NOTE TO MAINTAINERS:
+ * If you modify this file at all, please set the above date.
+@@ -201,6 +201,33 @@ struct compressor {
+ #define CI_MPPE 18 /* config option for MPPE */
+ #define CILEN_MPPE 6 /* length of config option */
+
++/* MPPE/MPPC definitions by J.D.*/
++#define MPPE_STATELESS MPPE_H_BIT /* configuration bit H */
++#define MPPE_40BIT MPPE_L_BIT /* configuration bit L */
++#define MPPE_56BIT MPPE_M_BIT /* configuration bit M */
++#define MPPE_128BIT MPPE_S_BIT /* configuration bit S */
++#define MPPE_MPPC MPPE_C_BIT /* configuration bit C */
++
++/*
++ * Definitions for Stac LZS.
++ */
++
++#define CI_LZS 17 /* config option for Stac LZS */
++#define CILEN_LZS 5 /* length of config option */
++
++#define LZS_OVHD 4 /* max. LZS overhead */
++#define LZS_HIST_LEN 2048 /* LZS history size */
++#define LZS_MAX_CCOUNT 0x0FFF /* max. coherency counter value */
++
++#define LZS_MODE_NONE 0
++#define LZS_MODE_LCB 1
++#define LZS_MODE_CRC 2
++#define LZS_MODE_SEQ 3
++#define LZS_MODE_EXT 4
++
++#define LZS_EXT_BIT_FLUSHED 0x80 /* bit A */
++#define LZS_EXT_BIT_COMP 0x20 /* bit C */
++
+ /*
+ * Definitions for other, as yet unsupported, compression methods.
+ */
+--- a/include/net/ppp-comp.h
++++ b/include/net/ppp-comp.h
+@@ -168,6 +168,33 @@ struct compressor {
+ #define CI_MPPE 18 /* config option for MPPE */
+ #define CILEN_MPPE 6 /* length of config option */
+
++/* MPPE/MPPC definitions by J.D.*/
++#define MPPE_STATELESS MPPE_H_BIT /* configuration bit H */
++#define MPPE_40BIT MPPE_L_BIT /* configuration bit L */
++#define MPPE_56BIT MPPE_M_BIT /* configuration bit M */
++#define MPPE_128BIT MPPE_S_BIT /* configuration bit S */
++#define MPPE_MPPC MPPE_C_BIT /* configuration bit C */
++
++/*
++ * Definitions for Stac LZS.
++ */
++
++#define CI_LZS 17 /* config option for Stac LZS */
++#define CILEN_LZS 5 /* length of config option */
++
++#define LZS_OVHD 4 /* max. LZS overhead */
++#define LZS_HIST_LEN 2048 /* LZS history size */
++#define LZS_MAX_CCOUNT 0x0FFF /* max. coherency counter value */
++
++#define LZS_MODE_NONE 0
++#define LZS_MODE_LCB 1
++#define LZS_MODE_CRC 2
++#define LZS_MODE_SEQ 3
++#define LZS_MODE_EXT 4
++
++#define LZS_EXT_BIT_FLUSHED 0x80 /* bit A */
++#define LZS_EXT_BIT_COMP 0x20 /* bit C */
++
+ /*
+ * Definitions for other, as yet unsupported, compression methods.
+ */
+--- a/pppd/ccp.c
++++ b/pppd/ccp.c
+@@ -62,12 +62,10 @@ static int setdeflate __P((char **));
+ static char bsd_value[8];
+ static char deflate_value[8];
+
+-/*
+- * Option variables.
+- */
+ #ifdef MPPE
+-bool refuse_mppe_stateful = 1; /* Allow stateful mode? */
+-#endif
++static int setmppe(char **);
++static int setnomppe(void);
++#endif /* MPPE */
+
+ static option_t ccp_option_list[] = {
+ { "noccp", o_bool, &ccp_protent.enabled_flag,
+@@ -108,54 +106,36 @@ static option_t ccp_option_list[] = {
+ "don't allow Predictor-1", OPT_ALIAS | OPT_PRIOSUB | OPT_A2CLR,
+ &ccp_allowoptions[0].predictor_1 },
+
++ { "lzs", o_bool, &ccp_wantoptions[0].lzs,
++ "request Stac LZS", 1, &ccp_allowoptions[0].lzs, OPT_PRIO },
++ { "+lzs", o_bool, &ccp_wantoptions[0].lzs,
++ "request Stac LZS", 1, &ccp_allowoptions[0].lzs, OPT_ALIAS | OPT_PRIO },
++ { "nolzs", o_bool, &ccp_wantoptions[0].lzs,
++ "don't allow Stac LZS", OPT_PRIOSUB | OPT_A2CLR,
++ &ccp_allowoptions[0].lzs },
++ { "-lzs", o_bool, &ccp_wantoptions[0].lzs,
++ "don't allow Stac LZS", OPT_ALIAS | OPT_PRIOSUB | OPT_A2CLR,
++ &ccp_allowoptions[0].lzs },
++
+ #ifdef MPPE
+- /* MPPE options are symmetrical ... we only set wantoptions here */
+- { "require-mppe", o_bool, &ccp_wantoptions[0].mppe,
+- "require MPPE encryption",
+- OPT_PRIO | MPPE_OPT_40 | MPPE_OPT_128 },
+- { "+mppe", o_bool, &ccp_wantoptions[0].mppe,
+- "require MPPE encryption",
+- OPT_ALIAS | OPT_PRIO | MPPE_OPT_40 | MPPE_OPT_128 },
+- { "nomppe", o_bool, &ccp_wantoptions[0].mppe,
+- "don't allow MPPE encryption", OPT_PRIO },
+- { "-mppe", o_bool, &ccp_wantoptions[0].mppe,
+- "don't allow MPPE encryption", OPT_ALIAS | OPT_PRIO },
+-
+- /* We use ccp_allowoptions[0].mppe as a junk var ... it is reset later */
+- { "require-mppe-40", o_bool, &ccp_allowoptions[0].mppe,
+- "require MPPE 40-bit encryption", OPT_PRIO | OPT_A2OR | MPPE_OPT_40,
+- &ccp_wantoptions[0].mppe },
+- { "+mppe-40", o_bool, &ccp_allowoptions[0].mppe,
+- "require MPPE 40-bit encryption", OPT_PRIO | OPT_A2OR | MPPE_OPT_40,
+- &ccp_wantoptions[0].mppe },
+- { "nomppe-40", o_bool, &ccp_allowoptions[0].mppe,
+- "don't allow MPPE 40-bit encryption",
+- OPT_PRIOSUB | OPT_A2CLRB | MPPE_OPT_40, &ccp_wantoptions[0].mppe },
+- { "-mppe-40", o_bool, &ccp_allowoptions[0].mppe,
+- "don't allow MPPE 40-bit encryption",
+- OPT_ALIAS | OPT_PRIOSUB | OPT_A2CLRB | MPPE_OPT_40,
+- &ccp_wantoptions[0].mppe },
+-
+- { "require-mppe-128", o_bool, &ccp_allowoptions[0].mppe,
+- "require MPPE 128-bit encryption", OPT_PRIO | OPT_A2OR | MPPE_OPT_128,
+- &ccp_wantoptions[0].mppe },
+- { "+mppe-128", o_bool, &ccp_allowoptions[0].mppe,
+- "require MPPE 128-bit encryption",
+- OPT_ALIAS | OPT_PRIO | OPT_A2OR | MPPE_OPT_128,
+- &ccp_wantoptions[0].mppe },
+- { "nomppe-128", o_bool, &ccp_allowoptions[0].mppe,
+- "don't allow MPPE 128-bit encryption",
+- OPT_PRIOSUB | OPT_A2CLRB | MPPE_OPT_128, &ccp_wantoptions[0].mppe },
+- { "-mppe-128", o_bool, &ccp_allowoptions[0].mppe,
+- "don't allow MPPE 128-bit encryption",
+- OPT_ALIAS | OPT_PRIOSUB | OPT_A2CLRB | MPPE_OPT_128,
+- &ccp_wantoptions[0].mppe },
+-
+- /* strange one; we always request stateless, but will we allow stateful? */
+- { "mppe-stateful", o_bool, &refuse_mppe_stateful,
+- "allow MPPE stateful mode", OPT_PRIO },
+- { "nomppe-stateful", o_bool, &refuse_mppe_stateful,
+- "disallow MPPE stateful mode", OPT_PRIO | 1 },
++ { "mppc", o_bool, &ccp_wantoptions[0].mppc,
++ "request MPPC compression", 1, &ccp_allowoptions[0].mppc },
++ { "+mppc", o_bool, &ccp_wantoptions[0].mppc,
++ "request MPPC compression", 1, &ccp_allowoptions[0].mppc, OPT_ALIAS },
++ { "nomppc", o_bool, &ccp_wantoptions[0].mppc,
++ "don't allow MPPC compression", OPT_PRIOSUB | OPT_A2CLR,
++ &ccp_allowoptions[0].mppc },
++ { "-mppc", o_bool, &ccp_wantoptions[0].mppc,
++ "don't allow MPPC compression", OPT_ALIAS | OPT_PRIOSUB | OPT_A2CLR,
++ &ccp_allowoptions[0].mppc },
++ { "mppe", o_special, (void *)setmppe,
++ "request MPPE encryption" },
++ { "+mppe", o_special, (void *)setmppe,
++ "request MPPE encryption" },
++ { "nomppe", o_special_noarg, (void *)setnomppe,
++ "don't allow MPPE encryption" },
++ { "-mppe", o_special_noarg, (void *)setnomppe,
++ "don't allow MPPE encryption" },
+ #endif /* MPPE */
+
+ { NULL }
+@@ -241,7 +221,7 @@ static fsm_callbacks ccp_callbacks = {
+ */
+ #define ANY_COMPRESS(opt) ((opt).deflate || (opt).bsd_compress \
+ || (opt).predictor_1 || (opt).predictor_2 \
+- || (opt).mppe)
++ || (opt).lzs || (opt).mppc || (opt).mppe)
+
+ /*
+ * Local state (mainly for handling reset-reqs and reset-acks).
+@@ -344,6 +324,100 @@ setdeflate(argv)
+ return 1;
+ }
+
++#ifdef MPPE
++/*
++ * Functions called from config options
++ */
++/*
++ MPPE suboptions:
++ required - require MPPE; disconnect if peer doesn't support it
++ stateless - use stateless mode
++ no40 - disable 40 bit keys
++ no56 - disable 56 bit keys
++ no128 - disable 128 bit keys
++*/
++int setmppe(char **argv)
++{
++ int i;
++ char *str, cmdbuf[16];
++
++ ccp_allowoptions[0].mppe = 1;
++ ccp_allowoptions[0].mppe_40 = 1;
++ ccp_allowoptions[0].mppe_56 = 1;
++ ccp_allowoptions[0].mppe_128 = 1;
++ ccp_allowoptions[0].mppe_stateless = 0;
++ ccp_wantoptions[0].mppe = 0;
++
++ str = *argv;
++
++ while (1) {
++ i = 0;
++ memset(cmdbuf, '\0', 16);
++ while ((i < 16) && (*str != ',') && (*str != '\0'))
++ cmdbuf[i++] = *str++;
++ cmdbuf[i] = '\0';
++ if (!strncasecmp(cmdbuf, "no40", strlen("no40"))) {
++ ccp_allowoptions[0].mppe_40 = 0;
++ goto next_param;
++ } else if (!strncasecmp(cmdbuf, "no56", strlen("no56"))) {
++ ccp_allowoptions[0].mppe_56 = 0;
++ goto next_param;
++ } else if (!strncasecmp(cmdbuf, "no128", strlen("no128"))) {
++ ccp_allowoptions[0].mppe_128 = 0;
++ goto next_param;
++ } else if (!strncasecmp(cmdbuf, "stateless", strlen("stateless"))) {
++ ccp_allowoptions[0].mppe_stateless = 1;
++ goto next_param;
++ } else if (!strncasecmp(cmdbuf, "required", strlen("required"))) {
++ ccp_wantoptions[0].mppe = 1;
++ goto next_param;
++ } else {
++ option_error("invalid parameter '%s' for mppe option", cmdbuf);
++ return 0;
++ }
++
++ next_param:
++ if (*str == ',') {
++ str++;
++ continue;
++ }
++ if (*str == '\0') {
++ if (!(ccp_allowoptions[0].mppe_40 || ccp_allowoptions[0].mppe_56 ||
++ ccp_allowoptions[0].mppe_128)) {
++ if (ccp_wantoptions[0].mppe == 1) {
++ option_error("You require MPPE but you have switched off "
++ "all encryption key lengths.");
++ return 0;
++ }
++ ccp_wantoptions[0].mppe = ccp_allowoptions[0].mppe = 0;
++ ccp_wantoptions[0].mppe_stateless =
++ ccp_allowoptions[0].mppe_stateless = 0;
++ } else {
++ ccp_allowoptions[0].mppe = 1;
++ ccp_wantoptions[0].mppe_stateless =
++ ccp_allowoptions[0].mppe_stateless;
++ if (ccp_wantoptions[0].mppe == 1) {
++ ccp_wantoptions[0].mppe_40 = ccp_allowoptions[0].mppe_40;
++ ccp_wantoptions[0].mppe_56 = ccp_allowoptions[0].mppe_56;
++ ccp_wantoptions[0].mppe_128 = ccp_allowoptions[0].mppe_128;
++ }
++ }
++ return 1;
++ }
++ }
++}
++
++int setnomppe(void)
++{
++ ccp_wantoptions[0].mppe = ccp_allowoptions[0].mppe = 0;
++ ccp_wantoptions[0].mppe_40 = ccp_allowoptions[0].mppe_40 = 0;
++ ccp_wantoptions[0].mppe_56 = ccp_allowoptions[0].mppe_56 = 0;
++ ccp_wantoptions[0].mppe_128 = ccp_allowoptions[0].mppe_128 = 0;
++ ccp_wantoptions[0].mppe_stateless = ccp_allowoptions[0].mppe_stateless = 0;
++ return 1;
++}
++#endif /* MPPE */
++
+ /*
+ * ccp_init - initialize CCP.
+ */
+@@ -378,6 +452,30 @@ ccp_init(unit)
+ ccp_allowoptions[0].bsd_bits = BSD_MAX_BITS;
+
+ ccp_allowoptions[0].predictor_1 = 1;
++
++ ccp_wantoptions[0].lzs = 0; /* Stac LZS - will be enabled in the future */
++ ccp_wantoptions[0].lzs_mode = LZS_MODE_SEQ;
++ ccp_wantoptions[0].lzs_hists = 1;
++ ccp_allowoptions[0].lzs = 0; /* Stac LZS - will be enabled in the future */
++ ccp_allowoptions[0].lzs_mode = LZS_MODE_SEQ;
++ ccp_allowoptions[0].lzs_hists = 1;
++
++#ifdef MPPE
++ /* by default allow and request MPPC... */
++ ccp_wantoptions[0].mppc = ccp_allowoptions[0].mppc = 1;
++
++ /* ... and allow but don't request MPPE */
++ ccp_allowoptions[0].mppe = 1;
++ ccp_allowoptions[0].mppe_40 = 1;
++ ccp_allowoptions[0].mppe_56 = 1;
++ ccp_allowoptions[0].mppe_128 = 1;
++ ccp_allowoptions[0].mppe_stateless = 1;
++ ccp_wantoptions[0].mppe = 0;
++ ccp_wantoptions[0].mppe_40 = 0;
++ ccp_wantoptions[0].mppe_56 = 0;
++ ccp_wantoptions[0].mppe_128 = 0;
++ ccp_wantoptions[0].mppe_stateless = 0;
++#endif /* MPPE */
+ }
+
+ /*
+@@ -455,11 +553,11 @@ ccp_input(unit, p, len)
+ if (oldstate == OPENED && p[0] == TERMREQ && f->state != OPENED) {
+ notice("Compression disabled by peer.");
+ #ifdef MPPE
+- if (ccp_gotoptions[unit].mppe) {
++ if (ccp_wantoptions[unit].mppe) {
+ error("MPPE disabled, closing LCP");
+ lcp_close(unit, "MPPE disabled by peer");
+ }
+-#endif
++#endif /* MPPE */
+ }
+
+ /*
+@@ -487,6 +585,15 @@ ccp_extcode(f, code, id, p, len)
+ break;
+ /* send a reset-ack, which the transmitter will see and
+ reset its compression state. */
++
++ /* In case of MPPE/MPPC or LZS we shouldn't send CCP_RESETACK,
++ but we do it in order to reset compressor; CCP_RESETACK is
++ then silently discarded. See functions ppp_send_frame and
++ ppp_ccp_peek in ppp_generic.c (Linux only !!!). All the
++ confusion is caused by the fact that CCP code is splited
++ into two parts - one part is handled by pppd, the other one
++ is handled by kernel. */
++
+ fsm_sdata(f, CCP_RESETACK, id, NULL, 0);
+ break;
+
+@@ -515,12 +622,11 @@ ccp_protrej(unit)
+ fsm_lowerdown(&ccp_fsm[unit]);
+
+ #ifdef MPPE
+- if (ccp_gotoptions[unit].mppe) {
++ if (ccp_wantoptions[unit].mppe) {
+ error("MPPE required but peer negotiation failed");
+ lcp_close(unit, "MPPE required but peer negotiation failed");
+ }
+-#endif
+-
++#endif /* MPPE */
+ }
+
+ /*
+@@ -537,7 +643,7 @@ ccp_resetci(f)
+ all_rejected[f->unit] = 0;
+
+ #ifdef MPPE
+- if (go->mppe) {
++ if (go->mppe || go->mppc) {
+ ccp_options *ao = &ccp_allowoptions[f->unit];
+ int auth_mschap_bits = auth_done[f->unit];
+ int numbits;
+@@ -551,80 +657,109 @@ ccp_resetci(f)
+ * NB: If MPPE is required, all other compression opts are invalid.
+ * So, we return right away if we can't do it.
+ */
++ if (ccp_wantoptions[f->unit].mppe) {
++ /* Leave only the mschap auth bits set */
++ auth_mschap_bits &= (CHAP_MS_WITHPEER | CHAP_MS_PEER |
++ CHAP_MS2_WITHPEER | CHAP_MS2_PEER);
++ /* Count the mschap auths */
++ auth_mschap_bits >>= CHAP_MS_SHIFT;
++ numbits = 0;
++ do {
++ numbits += auth_mschap_bits & 1;
++ auth_mschap_bits >>= 1;
++ } while (auth_mschap_bits);
++ if (numbits > 1) {
++ error("MPPE required, but auth done in both directions.");
++ lcp_close(f->unit, "MPPE required but not available");
++ return;
++ }
++ if (!numbits) {
++ error("MPPE required, but MS-CHAP[v2] auth not performed.");
++ lcp_close(f->unit, "MPPE required but not available");
++ return;
++ }
+
+- /* Leave only the mschap auth bits set */
+- auth_mschap_bits &= (CHAP_MS_WITHPEER | CHAP_MS_PEER |
+- CHAP_MS2_WITHPEER | CHAP_MS2_PEER);
+- /* Count the mschap auths */
+- auth_mschap_bits >>= CHAP_MS_SHIFT;
+- numbits = 0;
+- do {
+- numbits += auth_mschap_bits & 1;
+- auth_mschap_bits >>= 1;
+- } while (auth_mschap_bits);
+- if (numbits > 1) {
+- error("MPPE required, but auth done in both directions.");
+- lcp_close(f->unit, "MPPE required but not available");
+- return;
+- }
+- if (!numbits) {
+- error("MPPE required, but MS-CHAP[v2] auth not performed.");
+- lcp_close(f->unit, "MPPE required but not available");
+- return;
+- }
+-
+- /* A plugin (eg radius) may not have obtained key material. */
+- if (!mppe_keys_set) {
+- error("MPPE required, but keys are not available. "
+- "Possible plugin problem?");
+- lcp_close(f->unit, "MPPE required but not available");
+- return;
+- }
+-
+- /* LM auth not supported for MPPE */
+- if (auth_done[f->unit] & (CHAP_MS_WITHPEER | CHAP_MS_PEER)) {
+- /* This might be noise */
+- if (go->mppe & MPPE_OPT_40) {
+- notice("Disabling 40-bit MPPE; MS-CHAP LM not supported");
+- go->mppe &= ~MPPE_OPT_40;
+- ccp_wantoptions[f->unit].mppe &= ~MPPE_OPT_40;
++ /* A plugin (eg radius) may not have obtained key material. */
++ if (!mppe_keys_set) {
++ error("MPPE required, but keys are not available. "
++ "Possible plugin problem?");
++ lcp_close(f->unit, "MPPE required but not available");
++ return;
+ }
+ }
+
+- /* Last check: can we actually negotiate something? */
+- if (!(go->mppe & (MPPE_OPT_40 | MPPE_OPT_128))) {
+- /* Could be misconfig, could be 40-bit disabled above. */
+- error("MPPE required, but both 40-bit and 128-bit disabled.");
+- lcp_close(f->unit, "MPPE required but not available");
+- return;
++ /*
++ * Check whether the kernel knows about the various
++ * compression methods we might request. Key material
++ * unimportant here.
++ */
++ if (go->mppc) {
++ opt_buf[0] = CI_MPPE;
++ opt_buf[1] = CILEN_MPPE;
++ opt_buf[2] = 0;
++ opt_buf[3] = 0;
++ opt_buf[4] = 0;
++ opt_buf[5] = MPPE_MPPC;
++ if (ccp_test(f->unit, opt_buf, CILEN_MPPE, 0) <= 0)
++ go->mppc = 0;
++ }
++ if (go->mppe_40) {
++ opt_buf[0] = CI_MPPE;
++ opt_buf[1] = CILEN_MPPE;
++ opt_buf[2] = MPPE_STATELESS;
++ opt_buf[3] = 0;
++ opt_buf[4] = 0;
++ opt_buf[5] = MPPE_40BIT;
++ if (ccp_test(f->unit, opt_buf, CILEN_MPPE + MPPE_MAX_KEY_LEN, 0) <= 0)
++ go->mppe_40 = 0;
++ }
++ if (go->mppe_56) {
++ opt_buf[0] = CI_MPPE;
++ opt_buf[1] = CILEN_MPPE;
++ opt_buf[2] = MPPE_STATELESS;
++ opt_buf[3] = 0;
++ opt_buf[4] = 0;
++ opt_buf[5] = MPPE_56BIT;
++ if (ccp_test(f->unit, opt_buf, CILEN_MPPE + MPPE_MAX_KEY_LEN, 0) <= 0)
++ go->mppe_56 = 0;
++ }
++ if (go->mppe_128) {
++ opt_buf[0] = CI_MPPE;
++ opt_buf[1] = CILEN_MPPE;
++ opt_buf[2] = MPPE_STATELESS;
++ opt_buf[3] = 0;
++ opt_buf[4] = 0;
++ opt_buf[5] = MPPE_128BIT;
++ if (ccp_test(f->unit, opt_buf, CILEN_MPPE + MPPE_MAX_KEY_LEN, 0) <= 0)
++ go->mppe_128 = 0;
++ }
++ if (!go->mppe_40 && !go->mppe_56 && !go->mppe_128) {
++ if (ccp_wantoptions[f->unit].mppe) {
++ error("MPPE required, but kernel has no support.");
++ lcp_close(f->unit, "MPPE required but not available");
++ }
++ go->mppe = go->mppe_stateless = 0;
++ } else {
++ /* MPPE is not compatible with other compression types */
++ if (ccp_wantoptions[f->unit].mppe) {
++ ao->bsd_compress = go->bsd_compress = 0;
++ ao->predictor_1 = go->predictor_1 = 0;
++ ao->predictor_2 = go->predictor_2 = 0;
++ ao->deflate = go->deflate = 0;
++ ao->lzs = go->lzs = 0;
++ }
+ }
+-
+- /* sync options */
+- ao->mppe = go->mppe;
+- /* MPPE is not compatible with other compression types */
+- ao->bsd_compress = go->bsd_compress = 0;
+- ao->predictor_1 = go->predictor_1 = 0;
+- ao->predictor_2 = go->predictor_2 = 0;
+- ao->deflate = go->deflate = 0;
+ }
+ #endif /* MPPE */
+-
+- /*
+- * Check whether the kernel knows about the various
+- * compression methods we might request.
+- */
+-#ifdef MPPE
+- if (go->mppe) {
+- opt_buf[0] = CI_MPPE;
+- opt_buf[1] = CILEN_MPPE;
+- MPPE_OPTS_TO_CI(go->mppe, &opt_buf[2]);
+- /* Key material unimportant here. */
+- if (ccp_test(f->unit, opt_buf, CILEN_MPPE + MPPE_MAX_KEY_LEN, 0) <= 0) {
+- error("MPPE required, but kernel has no support.");
+- lcp_close(f->unit, "MPPE required but not available");
+- }
++ if (go->lzs) {
++ opt_buf[0] = CI_LZS;
++ opt_buf[1] = CILEN_LZS;
++ opt_buf[2] = go->lzs_hists >> 8;
++ opt_buf[3] = go->lzs_hists & 0xff;
++ opt_buf[4] = LZS_MODE_SEQ;
++ if (ccp_test(f->unit, opt_buf, CILEN_LZS, 0) <= 0)
++ go->lzs = 0;
+ }
+-#endif
+ if (go->bsd_compress) {
+ opt_buf[0] = CI_BSD_COMPRESS;
+ opt_buf[1] = CILEN_BSD_COMPRESS;
+@@ -679,7 +814,8 @@ ccp_cilen(f)
+ + (go->deflate? CILEN_DEFLATE: 0)
+ + (go->predictor_1? CILEN_PREDICTOR_1: 0)
+ + (go->predictor_2? CILEN_PREDICTOR_2: 0)
+- + (go->mppe? CILEN_MPPE: 0);
++ + (go->lzs? CILEN_LZS: 0)
++ + ((go->mppe || go->mppc)? CILEN_MPPE: 0);
+ }
+
+ /*
+@@ -693,6 +829,8 @@ ccp_addci(f, p, lenp)
+ {
+ int res;
+ ccp_options *go = &ccp_gotoptions[f->unit];
++ ccp_options *ao = &ccp_allowoptions[f->unit];
++ ccp_options *wo = &ccp_wantoptions[f->unit];
+ u_char *p0 = p;
+
+ /*
+@@ -701,22 +839,43 @@ ccp_addci(f, p, lenp)
+ * in case it gets Acked.
+ */
+ #ifdef MPPE
+- if (go->mppe) {
++ if (go->mppe || go->mppc || (!wo->mppe && ao->mppe)) {
+ u_char opt_buf[CILEN_MPPE + MPPE_MAX_KEY_LEN];
+
+- p[0] = opt_buf[0] = CI_MPPE;
+- p[1] = opt_buf[1] = CILEN_MPPE;
+- MPPE_OPTS_TO_CI(go->mppe, &p[2]);
+- MPPE_OPTS_TO_CI(go->mppe, &opt_buf[2]);
++ p[0] = CI_MPPE;
++ p[1] = CILEN_MPPE;
++ p[2] = (go->mppe_stateless ? MPPE_STATELESS : 0);
++ p[3] = 0;
++ p[4] = 0;
++ p[5] = (go->mppe_40 ? MPPE_40BIT : 0) | (go->mppe_56 ? MPPE_56BIT : 0) |
++ (go->mppe_128 ? MPPE_128BIT : 0) | (go->mppc ? MPPE_MPPC : 0);
++
++ BCOPY(p, opt_buf, CILEN_MPPE);
+ BCOPY(mppe_recv_key, &opt_buf[CILEN_MPPE], MPPE_MAX_KEY_LEN);
+ res = ccp_test(f->unit, opt_buf, CILEN_MPPE + MPPE_MAX_KEY_LEN, 0);
+- if (res > 0)
++ if (res > 0) {
+ p += CILEN_MPPE;
+- else
++ } else {
+ /* This shouldn't happen, we've already tested it! */
+- lcp_close(f->unit, "MPPE required but not available in kernel");
++ go->mppe = go->mppe_40 = go->mppe_56 = go->mppe_128 =
++ go->mppe_stateless = go->mppc = 0;
++ if (ccp_wantoptions[f->unit].mppe)
++ lcp_close(f->unit, "MPPE required but not available in kernel");
++ }
++ }
++#endif /* MPPE */
++ if (go->lzs) {
++ p[0] = CI_LZS;
++ p[1] = CILEN_LZS;
++ p[2] = go->lzs_hists >> 8;
++ p[3] = go->lzs_hists & 0xff;
++ p[4] = LZS_MODE_SEQ;
++ res = ccp_test(f->unit, p, CILEN_LZS, 0);
++ if (res > 0) {
++ p += CILEN_LZS;
++ } else
++ go->lzs = 0;
+ }
+-#endif
+ if (go->deflate) {
+ p[0] = go->deflate_correct? CI_DEFLATE: CI_DEFLATE_DRAFT;
+ p[1] = CILEN_DEFLATE;
+@@ -802,7 +961,7 @@ ccp_addci(f, p, lenp)
+
+ /*
+ * ccp_ackci - process a received configure-ack, and return
+- * 1 iff the packet was OK.
++ * 1 if the packet was OK.
+ */
+ static int
+ ccp_ackci(f, p, len)
+@@ -811,24 +970,44 @@ ccp_ackci(f, p, len)
+ int len;
+ {
+ ccp_options *go = &ccp_gotoptions[f->unit];
++ ccp_options *ao = &ccp_allowoptions[f->unit];
++ ccp_options *wo = &ccp_wantoptions[f->unit];
+ u_char *p0 = p;
+
+ #ifdef MPPE
+- if (go->mppe) {
+- u_char opt_buf[CILEN_MPPE];
+-
+- opt_buf[0] = CI_MPPE;
+- opt_buf[1] = CILEN_MPPE;
+- MPPE_OPTS_TO_CI(go->mppe, &opt_buf[2]);
+- if (len < CILEN_MPPE || memcmp(opt_buf, p, CILEN_MPPE))
++ if (go->mppe || go->mppc || (!wo->mppe && ao->mppe)) {
++ if (len < CILEN_MPPE
++ || p[1] != CILEN_MPPE || p[0] != CI_MPPE
++ || p[2] != (go->mppe_stateless ? MPPE_STATELESS : 0)
++ || p[3] != 0
++ || p[4] != 0
++ || (p[5] != ((go->mppe_40 ? MPPE_40BIT : 0) |
++ (go->mppc ? MPPE_MPPC : 0))
++ && p[5] != ((go->mppe_56 ? MPPE_56BIT : 0) |
++ (go->mppc ? MPPE_MPPC : 0))
++ && p[5] != ((go->mppe_128 ? MPPE_128BIT : 0) |
++ (go->mppc ? MPPE_MPPC : 0))))
+ return 0;
++ if (go->mppe_40 || go->mppe_56 || go->mppe_128)
++ go->mppe = 1;
+ p += CILEN_MPPE;
+ len -= CILEN_MPPE;
++ /* Cope with first/fast ack */
++ if (p == p0 && len == 0)
++ return 1;
++ }
++#endif /* MPPE */
++ if (go->lzs) {
++ if (len < CILEN_LZS || p[0] != CI_LZS || p[1] != CILEN_LZS
++ || p[2] != go->lzs_hists>>8 || p[3] != (go->lzs_hists&0xff)
++ || p[4] != LZS_MODE_SEQ)
++ return 0;
++ p += CILEN_LZS;
++ len -= CILEN_LZS;
+ /* XXX Cope with first/fast ack */
+- if (len == 0)
++ if (p == p0 && len == 0)
+ return 1;
+ }
+-#endif
+ if (go->deflate) {
+ if (len < CILEN_DEFLATE
+ || p[0] != (go->deflate_correct? CI_DEFLATE: CI_DEFLATE_DRAFT)
+@@ -901,6 +1080,8 @@ ccp_nakci(f, p, len, treat_as_reject)
+ int treat_as_reject;
+ {
+ ccp_options *go = &ccp_gotoptions[f->unit];
++ ccp_options *ao = &ccp_allowoptions[f->unit];
++ ccp_options *wo = &ccp_wantoptions[f->unit];
+ ccp_options no; /* options we've seen already */
+ ccp_options try; /* options to ask for next time */
+
+@@ -908,28 +1089,100 @@ ccp_nakci(f, p, len, treat_as_reject)
+ try = *go;
+
+ #ifdef MPPE
+- if (go->mppe && len >= CILEN_MPPE
+- && p[0] == CI_MPPE && p[1] == CILEN_MPPE) {
+- no.mppe = 1;
+- /*
+- * Peer wants us to use a different strength or other setting.
+- * Fail if we aren't willing to use his suggestion.
+- */
+- MPPE_CI_TO_OPTS(&p[2], try.mppe);
+- if ((try.mppe & MPPE_OPT_STATEFUL) && refuse_mppe_stateful) {
+- error("Refusing MPPE stateful mode offered by peer");
+- try.mppe = 0;
+- } else if (((go->mppe | MPPE_OPT_STATEFUL) & try.mppe) != try.mppe) {
+- /* Peer must have set options we didn't request (suggest) */
+- try.mppe = 0;
+- }
++ if ((go->mppe || go->mppc || (!wo->mppe && ao->mppe)) &&
++ len >= CILEN_MPPE && p[0] == CI_MPPE && p[1] == CILEN_MPPE) {
+
+- if (!try.mppe) {
+- error("MPPE required but peer negotiation failed");
+- lcp_close(f->unit, "MPPE required but peer negotiation failed");
++ if (go->mppc) {
++ no.mppc = 1;
++ if (!(p[5] & MPPE_MPPC))
++ try.mppc = 0;
++ }
++
++ if (go->mppe)
++ no.mppe = 1;
++ if (go->mppe_40)
++ no.mppe_40 = 1;
++ if (go->mppe_56)
++ no.mppe_56 = 1;
++ if (go->mppe_128)
++ no.mppe_128 = 1;
++ if (go->mppe_stateless)
++ no.mppe_stateless = 1;
++
++ if (ao->mppe_40) {
++ if ((p[5] & MPPE_40BIT))
++ try.mppe_40 = 1;
++ else
++ try.mppe_40 = (p[5] == 0) ? 1 : 0;
++ }
++ if (ao->mppe_56) {
++ if ((p[5] & MPPE_56BIT))
++ try.mppe_56 = 1;
++ else
++ try.mppe_56 = (p[5] == 0) ? 1 : 0;
++ }
++ if (ao->mppe_128) {
++ if ((p[5] & MPPE_128BIT))
++ try.mppe_128 = 1;
++ else
++ try.mppe_128 = (p[5] == 0) ? 1 : 0;
++ }
++
++ if (ao->mppe_stateless) {
++ if ((p[2] & MPPE_STATELESS) || wo->mppe_stateless)
++ try.mppe_stateless = 1;
++ else
++ try.mppe_stateless = 0;
++ }
++
++ if (!try.mppe_56 && !try.mppe_40 && !try.mppe_128) {
++ try.mppe = try.mppe_stateless = 0;
++ if (wo->mppe) {
++ /* we require encryption, but peer doesn't support it
++ so we close connection */
++ wo->mppc = wo->mppe = wo->mppe_stateless = wo->mppe_40 =
++ wo->mppe_56 = wo->mppe_128 = 0;
++ lcp_close(f->unit, "MPPE required but cannot negotiate MPPE "
++ "key length");
++ }
++ }
++ if (wo->mppe && (wo->mppe_40 != try.mppe_40) &&
++ (wo->mppe_56 != try.mppe_56) && (wo->mppe_128 != try.mppe_128)) {
++ /* cannot negotiate key length */
++ wo->mppc = wo->mppe = wo->mppe_stateless = wo->mppe_40 =
++ wo->mppe_56 = wo->mppe_128 = 0;
++ lcp_close(f->unit, "Cannot negotiate MPPE key length");
+ }
++ if (try.mppe_40 && try.mppe_56 && try.mppe_128)
++ try.mppe_40 = try.mppe_56 = 0;
++ else
++ if (try.mppe_56 && try.mppe_128)
++ try.mppe_56 = 0;
++ else
++ if (try.mppe_40 && try.mppe_128)
++ try.mppe_40 = 0;
++ else
++ if (try.mppe_40 && try.mppe_56)
++ try.mppe_40 = 0;
++
++ p += CILEN_MPPE;
++ len -= CILEN_MPPE;
+ }
+ #endif /* MPPE */
++
++ if (go->lzs && len >= CILEN_LZS && p[0] == CI_LZS && p[1] == CILEN_LZS) {
++ no.lzs = 1;
++ if (((p[2]<<8)|p[3]) > 1 || (p[4] != LZS_MODE_SEQ &&
++ p[4] != LZS_MODE_EXT))
++ try.lzs = 0;
++ else {
++ try.lzs_mode = p[4];
++ try.lzs_hists = (p[2] << 8) | p[3];
++ }
++ p += CILEN_LZS;
++ len -= CILEN_LZS;
++ }
++
+ if (go->deflate && len >= CILEN_DEFLATE
+ && p[0] == (go->deflate_correct? CI_DEFLATE: CI_DEFLATE_DRAFT)
+ && p[1] == CILEN_DEFLATE) {
+@@ -1002,14 +1255,50 @@ ccp_rejci(f, p, len)
+ return -1;
+
+ #ifdef MPPE
+- if (go->mppe && len >= CILEN_MPPE
++ if ((go->mppe || go->mppc) && len >= CILEN_MPPE
+ && p[0] == CI_MPPE && p[1] == CILEN_MPPE) {
+- error("MPPE required but peer refused");
+- lcp_close(f->unit, "MPPE required but peer refused");
++ ccp_options *wo = &ccp_wantoptions[f->unit];
++ if (p[2] != (go->mppe_stateless ? MPPE_STATELESS : 0) ||
++ p[3] != 0 ||
++ p[4] != 0 ||
++ p[5] != ((go->mppe_40 ? MPPE_40BIT : 0) |
++ (go->mppe_56 ? MPPE_56BIT : 0) |
++ (go->mppe_128 ? MPPE_128BIT : 0) |
++ (go->mppc ? MPPE_MPPC : 0)))
++ return 0;
++ if (go->mppc)
++ try.mppc = 0;
++ if (go->mppe) {
++ try.mppe = 0;
++ if (go->mppe_40)
++ try.mppe_40 = 0;
++ if (go->mppe_56)
++ try.mppe_56 = 0;
++ if (go->mppe_128)
++ try.mppe_128 = 0;
++ if (go->mppe_stateless)
++ try.mppe_stateless = 0;
++ if (!try.mppe_56 && !try.mppe_40 && !try.mppe_128)
++ try.mppe = try.mppe_stateless = 0;
++ if (wo->mppe) { /* we want MPPE but cannot negotiate key length */
++ wo->mppc = wo->mppe = wo->mppe_stateless = wo->mppe_40 =
++ wo->mppe_56 = wo->mppe_128 = 0;
++ lcp_close(f->unit, "MPPE required but cannot negotiate MPPE "
++ "key length");
++ }
++ }
+ p += CILEN_MPPE;
+ len -= CILEN_MPPE;
+ }
+-#endif
++#endif /* MPPE */
++ if (go->lzs && len >= CILEN_LZS && p[0] == CI_LZS && p[1] == CILEN_LZS) {
++ if (p[2] != go->lzs_hists>>8 || p[3] != (go->lzs_hists&0xff)
++ || p[4] != go->lzs_mode)
++ return 0;
++ try.lzs = 0;
++ p += CILEN_LZS;
++ len -= CILEN_LZS;
++ }
+ if (go->deflate_correct && len >= CILEN_DEFLATE
+ && p[0] == CI_DEFLATE && p[1] == CILEN_DEFLATE) {
+ if (p[2] != DEFLATE_MAKE_OPT(go->deflate_size)
+@@ -1073,14 +1362,15 @@ ccp_reqci(f, p, lenp, dont_nak)
+ int dont_nak;
+ {
+ int ret, newret, res;
+- u_char *p0, *retp;
++ u_char *p0, *retp, p2, p5;
+ int len, clen, type, nb;
+ ccp_options *ho = &ccp_hisoptions[f->unit];
+ ccp_options *ao = &ccp_allowoptions[f->unit];
++ ccp_options *wo = &ccp_wantoptions[f->unit];
+ #ifdef MPPE
+- bool rej_for_ci_mppe = 1; /* Are we rejecting based on a bad/missing */
+- /* CI_MPPE, or due to other options? */
+-#endif
++ u_char opt_buf[CILEN_MPPE + MPPE_MAX_KEY_LEN];
++/* int mtu; */
++#endif /* MPPE */
+
+ ret = CONFACK;
+ retp = p0 = p;
+@@ -1103,106 +1393,302 @@ ccp_reqci(f, p, lenp, dont_nak)
+ switch (type) {
+ #ifdef MPPE
+ case CI_MPPE:
+- if (!ao->mppe || clen != CILEN_MPPE) {
++ if ((!ao->mppc && !ao->mppe) || clen != CILEN_MPPE) {
+ newret = CONFREJ;
+ break;
+ }
+- MPPE_CI_TO_OPTS(&p[2], ho->mppe);
+-
+- /* Nak if anything unsupported or unknown are set. */
+- if (ho->mppe & MPPE_OPT_UNSUPPORTED) {
+- newret = CONFNAK;
+- ho->mppe &= ~MPPE_OPT_UNSUPPORTED;
+- }
+- if (ho->mppe & MPPE_OPT_UNKNOWN) {
++ p2 = p[2];
++ p5 = p[5];
++ /* not sure what they want, tell 'em what we got */
++ if (((p[2] & ~MPPE_STATELESS) != 0 || p[3] != 0 || p[4] != 0 ||
++ (p[5] & ~(MPPE_40BIT | MPPE_56BIT | MPPE_128BIT |
++ MPPE_MPPC)) != 0 || p[5] == 0) ||
++ (p[2] == 0 && p[3] == 0 && p[4] == 0 && p[5] == 0)) {
+ newret = CONFNAK;
+- ho->mppe &= ~MPPE_OPT_UNKNOWN;
+- }
+-
+- /* Check state opt */
+- if (ho->mppe & MPPE_OPT_STATEFUL) {
+- /*
+- * We can Nak and request stateless, but it's a
+- * lot easier to just assume the peer will request
+- * it if he can do it; stateful mode is bad over
+- * the Internet -- which is where we expect MPPE.
+- */
+- if (refuse_mppe_stateful) {
+- error("Refusing MPPE stateful mode offered by peer");
+- newret = CONFREJ;
+- break;
++ p[2] = (wo->mppe_stateless ? MPPE_STATELESS : 0);
++ p[3] = 0;
++ p[4] = 0;
++ p[5] = (wo->mppe_40 ? MPPE_40BIT : 0) |
++ (wo->mppe_56 ? MPPE_56BIT : 0) |
++ (wo->mppe_128 ? MPPE_128BIT : 0) |
++ (wo->mppc ? MPPE_MPPC : 0);
++ break;
++ }
++
++ if ((p[5] & MPPE_MPPC)) {
++ if (ao->mppc) {
++ ho->mppc = 1;
++ BCOPY(p, opt_buf, CILEN_MPPE);
++ opt_buf[2] = opt_buf[3] = opt_buf[4] = 0;
++ opt_buf[5] = MPPE_MPPC;
++ if (ccp_test(f->unit, opt_buf, CILEN_MPPE, 1) <= 0) {
++ ho->mppc = 0;
++ p[5] &= ~MPPE_MPPC;
++ newret = CONFNAK;
++ }
++ } else {
++ newret = CONFREJ;
++ if (wo->mppe || ao->mppe) {
++ p[5] &= ~MPPE_MPPC;
++ newret = CONFNAK;
++ }
+ }
+ }
+-
+- /* Find out which of {S,L} are set. */
+- if ((ho->mppe & MPPE_OPT_128)
+- && (ho->mppe & MPPE_OPT_40)) {
+- /* Both are set, negotiate the strongest. */
+- newret = CONFNAK;
+- if (ao->mppe & MPPE_OPT_128)
+- ho->mppe &= ~MPPE_OPT_40;
+- else if (ao->mppe & MPPE_OPT_40)
+- ho->mppe &= ~MPPE_OPT_128;
+- else {
+- newret = CONFREJ;
+- break;
+- }
+- } else if (ho->mppe & MPPE_OPT_128) {
+- if (!(ao->mppe & MPPE_OPT_128)) {
+- newret = CONFREJ;
+- break;
+- }
+- } else if (ho->mppe & MPPE_OPT_40) {
+- if (!(ao->mppe & MPPE_OPT_40)) {
+- newret = CONFREJ;
+- break;
+- }
++ if (ao->mppe)
++ ho->mppe = 1;
++
++ if ((p[2] & MPPE_STATELESS)) {
++ if (ao->mppe_stateless) {
++ if (wo->mppe_stateless)
++ ho->mppe_stateless = 1;
++ else {
++ newret = CONFNAK;
++ if (!dont_nak)
++ p[2] &= ~MPPE_STATELESS;
++ }
++ } else {
++ newret = CONFNAK;
++ if (!dont_nak)
++ p[2] &= ~MPPE_STATELESS;
++ }
++ } else {
++ if (wo->mppe_stateless && !dont_nak) {
++ wo->mppe_stateless = 0;
++ newret = CONFNAK;
++ p[2] |= MPPE_STATELESS;
++ }
++ }
++
++ if ((p[5] & ~MPPE_MPPC) == (MPPE_40BIT|MPPE_56BIT|MPPE_128BIT)) {
++ newret = CONFNAK;
++ if (ao->mppe_128) {
++ ho->mppe_128 = 1;
++ p[5] &= ~(MPPE_40BIT|MPPE_56BIT);
++ BCOPY(p, opt_buf, CILEN_MPPE);
++ BCOPY(mppe_send_key, &opt_buf[CILEN_MPPE],
++ MPPE_MAX_KEY_LEN);
++ if (ccp_test(f->unit, opt_buf, CILEN_MPPE +
++ MPPE_MAX_KEY_LEN, 1) <= 0) {
++ ho->mppe_128 = 0;
++ p[5] |= (MPPE_40BIT|MPPE_56BIT);
++ p[5] &= ~MPPE_128BIT;
++ goto check_mppe_56_40;
++ }
++ goto check_mppe;
++ }
++ p[5] &= ~MPPE_128BIT;
++ goto check_mppe_56_40;
++ }
++ if ((p[5] & ~MPPE_MPPC) == (MPPE_56BIT|MPPE_128BIT)) {
++ newret = CONFNAK;
++ if (ao->mppe_128) {
++ ho->mppe_128 = 1;
++ p[5] &= ~MPPE_56BIT;
++ BCOPY(p, opt_buf, CILEN_MPPE);
++ BCOPY(mppe_send_key, &opt_buf[CILEN_MPPE],
++ MPPE_MAX_KEY_LEN);
++ if (ccp_test(f->unit, opt_buf, CILEN_MPPE +
++ MPPE_MAX_KEY_LEN, 1) <= 0) {
++ ho->mppe_128 = 0;
++ p[5] |= MPPE_56BIT;
++ p[5] &= ~MPPE_128BIT;
++ goto check_mppe_56;
++ }
++ goto check_mppe;
++ }
++ p[5] &= ~MPPE_128BIT;
++ goto check_mppe_56;
++ }
++ if ((p[5] & ~MPPE_MPPC) == (MPPE_40BIT|MPPE_128BIT)) {
++ newret = CONFNAK;
++ if (ao->mppe_128) {
++ ho->mppe_128 = 1;
++ p[5] &= ~MPPE_40BIT;
++ BCOPY(p, opt_buf, CILEN_MPPE);
++ BCOPY(mppe_send_key, &opt_buf[CILEN_MPPE],
++ MPPE_MAX_KEY_LEN);
++ if (ccp_test(f->unit, opt_buf, CILEN_MPPE +
++ MPPE_MAX_KEY_LEN, 1) <= 0) {
++ ho->mppe_128 = 0;
++ p[5] |= MPPE_40BIT;
++ p[5] &= ~MPPE_128BIT;
++ goto check_mppe_40;
++ }
++ goto check_mppe;
++ }
++ p[5] &= ~MPPE_128BIT;
++ goto check_mppe_40;
++ }
++ if ((p[5] & ~MPPE_MPPC) == MPPE_128BIT) {
++ if (ao->mppe_128) {
++ ho->mppe_128 = 1;
++ BCOPY(p, opt_buf, CILEN_MPPE);
++ BCOPY(mppe_send_key, &opt_buf[CILEN_MPPE],
++ MPPE_MAX_KEY_LEN);
++ if (ccp_test(f->unit, opt_buf, CILEN_MPPE +
++ MPPE_MAX_KEY_LEN, 1) <= 0) {
++ ho->mppe_128 = 0;
++ p[5] &= ~MPPE_128BIT;
++ newret = CONFNAK;
++ }
++ goto check_mppe;
++ }
++ p[5] &= ~MPPE_128BIT;
++ newret = CONFNAK;
++ goto check_mppe;
++ }
++ check_mppe_56_40:
++ if ((p[5] & ~MPPE_MPPC) == (MPPE_40BIT|MPPE_56BIT)) {
++ newret = CONFNAK;
++ if (ao->mppe_56) {
++ ho->mppe_56 = 1;
++ p[5] &= ~MPPE_40BIT;
++ BCOPY(p, opt_buf, CILEN_MPPE);
++ BCOPY(mppe_send_key, &opt_buf[CILEN_MPPE],
++ MPPE_MAX_KEY_LEN);
++ if (ccp_test(f->unit, opt_buf, CILEN_MPPE +
++ MPPE_MAX_KEY_LEN, 1) <= 0) {
++ ho->mppe_56 = 0;
++ p[5] |= MPPE_40BIT;
++ p[5] &= ~MPPE_56BIT;
++ newret = CONFNAK;
++ goto check_mppe_40;
++ }
++ goto check_mppe;
++ }
++ p[5] &= ~MPPE_56BIT;
++ goto check_mppe_40;
++ }
++ check_mppe_56:
++ if ((p[5] & ~MPPE_MPPC) == MPPE_56BIT) {
++ if (ao->mppe_56) {
++ ho->mppe_56 = 1;
++ BCOPY(p, opt_buf, CILEN_MPPE);
++ BCOPY(mppe_send_key, &opt_buf[CILEN_MPPE],
++ MPPE_MAX_KEY_LEN);
++ if (ccp_test(f->unit, opt_buf, CILEN_MPPE +
++ MPPE_MAX_KEY_LEN, 1) <= 0) {
++ ho->mppe_56 = 0;
++ p[5] &= ~MPPE_56BIT;
++ newret = CONFNAK;
++ }
++ goto check_mppe;
++ }
++ p[5] &= ~MPPE_56BIT;
++ newret = CONFNAK;
++ goto check_mppe;
++ }
++ check_mppe_40:
++ if ((p[5] & ~MPPE_MPPC) == MPPE_40BIT) {
++ if (ao->mppe_40) {
++ ho->mppe_40 = 1;
++ BCOPY(p, opt_buf, CILEN_MPPE);
++ BCOPY(mppe_send_key, &opt_buf[CILEN_MPPE],
++ MPPE_MAX_KEY_LEN);
++ if (ccp_test(f->unit, opt_buf, CILEN_MPPE +
++ MPPE_MAX_KEY_LEN, 1) <= 0) {
++ ho->mppe_40 = 0;
++ p[5] &= ~MPPE_40BIT;
++ newret = CONFNAK;
++ }
++ goto check_mppe;
++ }
++ p[5] &= ~MPPE_40BIT;
++ }
++
++ check_mppe:
++ if (!ho->mppe_40 && !ho->mppe_56 && !ho->mppe_128) {
++ if (wo->mppe_40 || wo->mppe_56 || wo->mppe_128) {
++ newret = CONFNAK;
++ p[2] |= (wo->mppe_stateless ? MPPE_STATELESS : 0);
++ p[5] |= (wo->mppe_40 ? MPPE_40BIT : 0) |
++ (wo->mppe_56 ? MPPE_56BIT : 0) |
++ (wo->mppe_128 ? MPPE_128BIT : 0) |
++ (wo->mppc ? MPPE_MPPC : 0);
++ } else {
++ ho->mppe = ho->mppe_stateless = 0;
++ }
+ } else {
+- /* Neither are set. */
+- /* We cannot accept this. */
+- newret = CONFNAK;
+- /* Give the peer our idea of what can be used,
+- so it can choose and confirm */
+- ho->mppe = ao->mppe;
+- }
+-
+- /* rebuild the opts */
+- MPPE_OPTS_TO_CI(ho->mppe, &p[2]);
+- if (newret == CONFACK) {
+- u_char opt_buf[CILEN_MPPE + MPPE_MAX_KEY_LEN];
+- int mtu;
+-
+- BCOPY(p, opt_buf, CILEN_MPPE);
+- BCOPY(mppe_send_key, &opt_buf[CILEN_MPPE],
+- MPPE_MAX_KEY_LEN);
+- if (ccp_test(f->unit, opt_buf,
+- CILEN_MPPE + MPPE_MAX_KEY_LEN, 1) <= 0) {
+- /* This shouldn't happen, we've already tested it! */
+- error("MPPE required, but kernel has no support.");
+- lcp_close(f->unit, "MPPE required but not available");
+- newret = CONFREJ;
+- break;
+- }
+- /*
+- * We need to decrease the interface MTU by MPPE_PAD
+- * because MPPE frames **grow**. The kernel [must]
+- * allocate MPPE_PAD extra bytes in xmit buffers.
+- */
+- mtu = netif_get_mtu(f->unit);
+- if (mtu)
+- netif_set_mtu(f->unit, mtu - MPPE_PAD);
+- else
+- newret = CONFREJ;
+- }
+-
+- /*
+- * We have accepted MPPE or are willing to negotiate
+- * MPPE parameters. A CONFREJ is due to subsequent
+- * (non-MPPE) processing.
+- */
+- rej_for_ci_mppe = 0;
+- break;
+-#endif /* MPPE */
++ /* MPPE is not compatible with other compression types */
++ if (wo->mppe) {
++ ao->bsd_compress = 0;
++ ao->predictor_1 = 0;
++ ao->predictor_2 = 0;
++ ao->deflate = 0;
++ ao->lzs = 0;
++ }
++ }
++ if ((!ho->mppc || !ao->mppc) && !ho->mppe) {
++ p[2] = p2;
++ p[5] = p5;
++ newret = CONFREJ;
++ break;
++ }
++
++ /*
++ * I have commented the code below because according to RFC1547
++ * MTU is only information for higher level protocols about
++ * "the maximum allowable length for a packet (q.v.) transmitted
++ * over a point-to-point link without incurring network layer
++ * fragmentation." Of course a PPP implementation should be able
++ * to handle overhead added by MPPE - in our case apropriate code
++ * is located in drivers/net/ppp_generic.c in the kernel sources.
++ *
++ * According to RFC1661:
++ * - when negotiated MRU is less than 1500 octets, a PPP
++ * implementation must still be able to receive at least 1500
++ * octets,
++ * - when PFC is negotiated, a PPP implementation is still
++ * required to receive frames with uncompressed protocol field.
++ *
++ * So why not to handle MPPE overhead without changing MTU value?
++ * I am sure that RFC3078, unfortunately silently, assumes that.
++ */
++
++ /*
++ * We need to decrease the interface MTU by MPPE_PAD
++ * because MPPE frames **grow**. The kernel [must]
++ * allocate MPPE_PAD extra bytes in xmit buffers.
++ */
++ /*
++ mtu = netif_get_mtu(f->unit);
++ if (mtu) {
++ netif_set_mtu(f->unit, mtu - MPPE_PAD);
++ } else {
++ newret = CONFREJ;
++ if (ccp_wantoptions[f->unit].mppe) {
++ error("Cannot adjust MTU needed by MPPE.");
++ lcp_close(f->unit, "Cannot adjust MTU needed by MPPE.");
++ }
++ }
++ */
++ break;
++ #endif /* MPPE */
++
++ case CI_LZS:
++ if (!ao->lzs || clen != CILEN_LZS) {
++ newret = CONFREJ;
++ break;
++ }
++
++ ho->lzs = 1;
++ ho->lzs_hists = (p[2] << 8) | p[3];
++ ho->lzs_mode = p[4];
++ if ((ho->lzs_hists != ao->lzs_hists) ||
++ (ho->lzs_mode != ao->lzs_mode)) {
++ newret = CONFNAK;
++ if (!dont_nak) {
++ p[2] = ao->lzs_hists >> 8;
++ p[3] = ao->lzs_hists & 0xff;
++ p[4] = ao->lzs_mode;
++ } else
++ break;
++ }
++
++ if (p == p0 && ccp_test(f->unit, p, CILEN_LZS, 1) <= 0) {
++ newret = CONFREJ;
++ }
++ break;
+ case CI_DEFLATE:
+ case CI_DEFLATE_DRAFT:
+ if (!ao->deflate || clen != CILEN_DEFLATE
+@@ -1344,12 +1830,6 @@ ccp_reqci(f, p, lenp, dont_nak)
+ else
+ *lenp = retp - p0;
+ }
+-#ifdef MPPE
+- if (ret == CONFREJ && ao->mppe && rej_for_ci_mppe) {
+- error("MPPE required but peer negotiation failed");
+- lcp_close(f->unit, "MPPE required but peer negotiation failed");
+- }
+-#endif
+ return ret;
+ }
+
+@@ -1371,24 +1851,35 @@ method_name(opt, opt2)
+ char *p = result;
+ char *q = result + sizeof(result); /* 1 past result */
+
+- slprintf(p, q - p, "MPPE ");
+- p += 5;
+- if (opt->mppe & MPPE_OPT_128) {
+- slprintf(p, q - p, "128-bit ");
+- p += 8;
+- }
+- if (opt->mppe & MPPE_OPT_40) {
+- slprintf(p, q - p, "40-bit ");
+- p += 7;
+- }
+- if (opt->mppe & MPPE_OPT_STATEFUL)
+- slprintf(p, q - p, "stateful");
+- else
+- slprintf(p, q - p, "stateless");
+-
++ if (opt->mppe) {
++ if (opt->mppc) {
++ slprintf(p, q - p, "MPPC/MPPE ");
++ p += 10;
++ } else {
++ slprintf(p, q - p, "MPPE ");
++ p += 5;
++ }
++ if (opt->mppe_128) {
++ slprintf(p, q - p, "128-bit ");
++ p += 8;
++ } else if (opt->mppe_56) {
++ slprintf(p, q - p, "56-bit ");
++ p += 7;
++ } else if (opt->mppe_40) {
++ slprintf(p, q - p, "40-bit ");
++ p += 7;
++ }
++ if (opt->mppe_stateless)
++ slprintf(p, q - p, "stateless");
++ else
++ slprintf(p, q - p, "stateful");
++ } else if (opt->mppc)
++ slprintf(p, q - p, "MPPC");
+ break;
+ }
+-#endif
++#endif /* MPPE */
++ case CI_LZS:
++ return "Stac LZS";
+ case CI_DEFLATE:
+ case CI_DEFLATE_DRAFT:
+ if (opt2 != NULL && opt2->deflate_size != opt->deflate_size)
+@@ -1444,12 +1935,12 @@ ccp_up(f)
+ } else if (ANY_COMPRESS(*ho))
+ notice("%s transmit compression enabled", method_name(ho, NULL));
+ #ifdef MPPE
+- if (go->mppe) {
++ if (go->mppe || go->mppc) {
+ BZERO(mppe_recv_key, MPPE_MAX_KEY_LEN);
+ BZERO(mppe_send_key, MPPE_MAX_KEY_LEN);
+ continue_networks(f->unit); /* Bring up IP et al */
+ }
+-#endif
++#endif /* MPPE */
+ }
+
+ /*
+@@ -1472,7 +1963,7 @@ ccp_down(f)
+ lcp_close(f->unit, "MPPE disabled");
+ }
+ }
+-#endif
++#endif /* MPPE */
+ }
+
+ /*
+@@ -1532,24 +2023,28 @@ ccp_printpkt(p, plen, printer, arg)
+ #ifdef MPPE
+ case CI_MPPE:
+ if (optlen >= CILEN_MPPE) {
+- u_char mppe_opts;
+-
+- MPPE_CI_TO_OPTS(&p[2], mppe_opts);
+- printer(arg, "mppe %s %s %s %s %s %s%s",
+- (p[2] & MPPE_H_BIT)? "+H": "-H",
+- (p[5] & MPPE_M_BIT)? "+M": "-M",
+- (p[5] & MPPE_S_BIT)? "+S": "-S",
+- (p[5] & MPPE_L_BIT)? "+L": "-L",
++ printer(arg, "mppe %s %s %s %s %s %s",
++ (p[2] & MPPE_STATELESS)? "+H": "-H",
++ (p[5] & MPPE_56BIT)? "+M": "-M",
++ (p[5] & MPPE_128BIT)? "+S": "-S",
++ (p[5] & MPPE_40BIT)? "+L": "-L",
+ (p[5] & MPPE_D_BIT)? "+D": "-D",
+- (p[5] & MPPE_C_BIT)? "+C": "-C",
+- (mppe_opts & MPPE_OPT_UNKNOWN)? " +U": "");
+- if (mppe_opts & MPPE_OPT_UNKNOWN)
++ (p[5] & MPPE_MPPC)? "+C": "-C");
++ if ((p[5] & ~(MPPE_56BIT | MPPE_128BIT | MPPE_40BIT |
++ MPPE_D_BIT | MPPE_MPPC)) ||
++ (p[2] & ~MPPE_STATELESS))
+ printer(arg, " (%.2x %.2x %.2x %.2x)",
+ p[2], p[3], p[4], p[5]);
+ p += CILEN_MPPE;
+ }
+ break;
+-#endif
++#endif /* MPPE */
++ case CI_LZS:
++ if (optlen >= CILEN_LZS) {
++ printer(arg, "lzs %.2x %.2x %.2x", p[2], p[3], p[4]);
++ p += CILEN_LZS;
++ }
++ break;
+ case CI_DEFLATE:
+ case CI_DEFLATE_DRAFT:
+ if (optlen >= CILEN_DEFLATE) {
+@@ -1635,6 +2130,7 @@ ccp_datainput(unit, pkt, len)
+ error("Lost compression sync: disabling compression");
+ ccp_close(unit, "Lost compression sync");
+ #ifdef MPPE
++ /* My module dosn't need this. J.D., 2003-07-06 */
+ /*
+ * If we were doing MPPE, we must also take the link down.
+ */
+@@ -1642,9 +2138,18 @@ ccp_datainput(unit, pkt, len)
+ error("Too many MPPE errors, closing LCP");
+ lcp_close(unit, "Too many MPPE errors");
+ }
+-#endif
++#endif /* MPPE */
+ } else {
+ /*
++ * When LZS or MPPE/MPPC is negotiated we just send CCP_RESETREQ
++ * and don't wait for CCP_RESETACK
++ */
++ if ((ccp_gotoptions[f->unit].method == CI_LZS) ||
++ (ccp_gotoptions[f->unit].method == CI_MPPE)) {
++ fsm_sdata(f, CCP_RESETREQ, f->reqid = ++f->id, NULL, 0);
++ return;
++ }
++ /*
+ * Send a reset-request to reset the peer's compressor.
+ * We don't do that if we are still waiting for an
+ * acknowledgement to a previous reset-request.
+--- a/pppd/ccp.h
++++ b/pppd/ccp.h
+@@ -37,9 +37,17 @@ typedef struct ccp_options {
+ bool predictor_2; /* do Predictor-2? */
+ bool deflate_correct; /* use correct code for deflate? */
+ bool deflate_draft; /* use draft RFC code for deflate? */
++ bool lzs; /* do Stac LZS? */
++ bool mppc; /* do MPPC? */
+ bool mppe; /* do MPPE? */
++ bool mppe_40; /* allow 40 bit encryption? */
++ bool mppe_56; /* allow 56 bit encryption? */
++ bool mppe_128; /* allow 128 bit encryption? */
++ bool mppe_stateless; /* allow stateless encryption */
+ u_short bsd_bits; /* # bits/code for BSD Compress */
+ u_short deflate_size; /* lg(window size) for Deflate */
++ u_short lzs_mode; /* LZS check mode */
++ u_short lzs_hists; /* number of LZS histories */
+ short method; /* code for chosen compression method */
+ } ccp_options;
+
+--- a/pppd/chap_ms.c
++++ b/pppd/chap_ms.c
+@@ -898,13 +898,17 @@ set_mppe_enc_types(int policy, int types
+ /*
+ * Disable undesirable encryption types. Note that we don't ENABLE
+ * any encryption types, to avoid overriding manual configuration.
++ *
++ * It seems that 56 bit keys are unsupported in MS-RADIUS (see RFC 2548)
+ */
+ switch(types) {
+ case MPPE_ENC_TYPES_RC4_40:
+- ccp_wantoptions[0].mppe &= ~MPPE_OPT_128; /* disable 128-bit */
++ ccp_wantoptions[0].mppe_128 = 0; /* disable 128-bit */
++ ccp_wantoptions[0].mppe_56 = 0; /* disable 56-bit */
+ break;
+ case MPPE_ENC_TYPES_RC4_128:
+- ccp_wantoptions[0].mppe &= ~MPPE_OPT_40; /* disable 40-bit */
++ ccp_wantoptions[0].mppe_56 = 0; /* disable 56-bit */
++ ccp_wantoptions[0].mppe_40 = 0; /* disable 40-bit */
+ break;
+ default:
+ break;
diff --git a/package/network/services/ppp/patches/202-no_strip.patch b/package/network/services/ppp/patches/202-no_strip.patch
new file mode 100644
index 0000000..87c76ad
--- /dev/null
+++ b/package/network/services/ppp/patches/202-no_strip.patch
@@ -0,0 +1,88 @@
+build: Do not strip binaries on install
+
+Strippign executables should be handled by the distro packaging, not by ppp
+itself. This patch removes the "-s" (strip) switch from all "install" commands
+in order to install unstripped binaries into the destination prefix.
+
+Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
+
+--- a/chat/Makefile.linux
++++ b/chat/Makefile.linux
+@@ -25,7 +25,7 @@ chat.o: chat.c
+
+ install: chat
+ mkdir -p $(BINDIR) $(MANDIR)
+- $(INSTALL) -s -c chat $(BINDIR)
++ $(INSTALL) -c chat $(BINDIR)
+ $(INSTALL) -c -m 644 chat.8 $(MANDIR)
+
+ clean:
+--- a/pppd/Makefile.linux
++++ b/pppd/Makefile.linux
+@@ -99,7 +99,7 @@ ifdef USE_SRP
+ CFLAGS += -DUSE_SRP -DOPENSSL -I/usr/local/ssl/include
+ LIBS += -lsrp -L/usr/local/ssl/lib -lcrypto
+ TARGETS += srp-entry
+-EXTRAINSTALL = $(INSTALL) -s -c -m 555 srp-entry $(BINDIR)/srp-entry
++EXTRAINSTALL = $(INSTALL) -c -m 555 srp-entry $(BINDIR)/srp-entry
+ MANPAGES += srp-entry.8
+ EXTRACLEAN += srp-entry.o
+ NEEDDES=y
+@@ -200,7 +200,7 @@ all: $(TARGETS)
+ install: pppd
+ mkdir -p $(BINDIR) $(MANDIR)
+ $(EXTRAINSTALL)
+- $(INSTALL) -s -c -m 555 pppd $(BINDIR)/pppd
++ $(INSTALL) -c -m 555 pppd $(BINDIR)/pppd
+ if chgrp pppusers $(BINDIR)/pppd 2>/dev/null; then \
+ chmod o-rx,u+s $(BINDIR)/pppd; fi
+ $(INSTALL) -c -m 444 pppd.8 $(MANDIR)
+--- a/pppd/plugins/radius/Makefile.linux
++++ b/pppd/plugins/radius/Makefile.linux
+@@ -36,9 +36,9 @@ all: $(PLUGIN)
+
+ install: all
+ $(INSTALL) -d -m 755 $(LIBDIR)
+- $(INSTALL) -s -c -m 755 radius.so $(LIBDIR)
+- $(INSTALL) -s -c -m 755 radattr.so $(LIBDIR)
+- $(INSTALL) -s -c -m 755 radrealms.so $(LIBDIR)
++ $(INSTALL) -c -m 755 radius.so $(LIBDIR)
++ $(INSTALL) -c -m 755 radattr.so $(LIBDIR)
++ $(INSTALL) -c -m 755 radrealms.so $(LIBDIR)
+ $(INSTALL) -c -m 444 pppd-radius.8 $(MANDIR)
+ $(INSTALL) -c -m 444 pppd-radattr.8 $(MANDIR)
+
+--- a/pppd/plugins/rp-pppoe/Makefile.linux
++++ b/pppd/plugins/rp-pppoe/Makefile.linux
+@@ -43,9 +43,9 @@ rp-pppoe.so: plugin.o discovery.o if.o c
+
+ install: all
+ $(INSTALL) -d -m 755 $(LIBDIR)
+- $(INSTALL) -s -c -m 4550 rp-pppoe.so $(LIBDIR)
++ $(INSTALL) -c -m 4550 rp-pppoe.so $(LIBDIR)
+ $(INSTALL) -d -m 755 $(BINDIR)
+- $(INSTALL) -s -c -m 555 pppoe-discovery $(BINDIR)
++ $(INSTALL) -c -m 555 pppoe-discovery $(BINDIR)
+
+ clean:
+ rm -f *.o *.so pppoe-discovery
+--- a/pppdump/Makefile.linux
++++ b/pppdump/Makefile.linux
+@@ -17,5 +17,5 @@ clean:
+
+ install:
+ mkdir -p $(BINDIR) $(MANDIR)
+- $(INSTALL) -s -c pppdump $(BINDIR)
++ $(INSTALL) -c pppdump $(BINDIR)
+ $(INSTALL) -c -m 444 pppdump.8 $(MANDIR)
+--- a/pppstats/Makefile.linux
++++ b/pppstats/Makefile.linux
+@@ -22,7 +22,7 @@ all: pppstats
+
+ install: pppstats
+ -mkdir -p $(MANDIR)
+- $(INSTALL) -s -c pppstats $(BINDIR)
++ $(INSTALL) -c pppstats $(BINDIR)
+ $(INSTALL) -c -m 444 pppstats.8 $(MANDIR)
+
+ pppstats: $(PPPSTATSRCS)
diff --git a/package/network/services/ppp/patches/203-opt_flags.patch b/package/network/services/ppp/patches/203-opt_flags.patch
new file mode 100644
index 0000000..a369163
--- /dev/null
+++ b/package/network/services/ppp/patches/203-opt_flags.patch
@@ -0,0 +1,32 @@
+build: Move optimization flags into a separate variable
+
+Isolate optimization related compiler flags from CFLAGS and move them into a
+separate COPTS variable so that it is easier to override optimizations from
+the environment.
+
+Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
+
+--- a/pppd/plugins/radius/Makefile.linux
++++ b/pppd/plugins/radius/Makefile.linux
+@@ -12,7 +12,8 @@ VERSION = $(shell awk -F '"' '/VERSION/
+ INSTALL = install
+
+ PLUGIN=radius.so radattr.so radrealms.so
+-CFLAGS=-I. -I../.. -I../../../include -O2 -fPIC -DRC_LOG_FACILITY=LOG_DAEMON
++COPTS = -O2
++CFLAGS=-I. -I../.. -I../../../include $(COPTS) -fPIC -DRC_LOG_FACILITY=LOG_DAEMON
+
+ # Uncomment the next line to include support for Microsoft's
+ # MS-CHAP authentication protocol.
+--- a/pppdump/Makefile.linux
++++ b/pppdump/Makefile.linux
+@@ -2,7 +2,8 @@ DESTDIR = $(INSTROOT)@DESTDIR@
+ BINDIR = $(DESTDIR)/sbin
+ MANDIR = $(DESTDIR)/share/man/man8
+
+-CFLAGS= -O -I../include/net
++COPTS = -O
++CFLAGS= $(COPTS) -I../include/net
+ OBJS = pppdump.o bsd-comp.o deflate.o zlib.o
+
+ INSTALL= install
diff --git a/package/network/services/ppp/patches/204-radius_config.patch b/package/network/services/ppp/patches/204-radius_config.patch
new file mode 100644
index 0000000..c97a535
--- /dev/null
+++ b/package/network/services/ppp/patches/204-radius_config.patch
@@ -0,0 +1,72 @@
+--- a/pppd/plugins/radius/config.c
++++ b/pppd/plugins/radius/config.c
+@@ -369,31 +369,37 @@ static int test_config(char *filename)
+ }
+ #endif
+
++#if 0
+ if (rc_conf_int("login_tries") <= 0)
+ {
+ error("%s: login_tries <= 0 is illegal", filename);
+ return (-1);
+ }
++#endif
+ if (rc_conf_str("seqfile") == NULL)
+ {
+ error("%s: seqfile not specified", filename);
+ return (-1);
+ }
++#if 0
+ if (rc_conf_int("login_timeout") <= 0)
+ {
+ error("%s: login_timeout <= 0 is illegal", filename);
+ return (-1);
+ }
++#endif
+ if (rc_conf_str("mapfile") == NULL)
+ {
+ error("%s: mapfile not specified", filename);
+ return (-1);
+ }
++#if 0
+ if (rc_conf_str("nologin") == NULL)
+ {
+ error("%s: nologin not specified", filename);
+ return (-1);
+ }
++#endif
+
+ return 0;
+ }
+--- a/pppd/plugins/radius/options.h
++++ b/pppd/plugins/radius/options.h
+@@ -31,24 +31,21 @@ typedef struct _option {
+ static SERVER acctserver = {0};
+ static SERVER authserver = {0};
+
+-int default_tries = 4;
+-int default_timeout = 60;
+-
+ static OPTION config_options[] = {
+ /* internally used options */
+ {"config_file", OT_STR, ST_UNDEF, NULL},
+ /* General options */
+ {"auth_order", OT_AUO, ST_UNDEF, NULL},
+-{"login_tries", OT_INT, ST_UNDEF, &default_tries},
+-{"login_timeout", OT_INT, ST_UNDEF, &default_timeout},
+-{"nologin", OT_STR, ST_UNDEF, "/etc/nologin"},
+-{"issue", OT_STR, ST_UNDEF, "/etc/radiusclient/issue"},
++{"login_tries", OT_INT, ST_UNDEF, NULL},
++{"login_timeout", OT_INT, ST_UNDEF, NULL},
++{"nologin", OT_STR, ST_UNDEF, NULL},
++{"issue", OT_STR, ST_UNDEF, NULL},
+ /* RADIUS specific options */
+ {"authserver", OT_SRV, ST_UNDEF, &authserver},
+ {"acctserver", OT_SRV, ST_UNDEF, &acctserver},
+ {"servers", OT_STR, ST_UNDEF, NULL},
+ {"dictionary", OT_STR, ST_UNDEF, NULL},
+-{"login_radius", OT_STR, ST_UNDEF, "/usr/sbin/login.radius"},
++{"login_radius", OT_STR, ST_UNDEF, NULL},
+ {"seqfile", OT_STR, ST_UNDEF, NULL},
+ {"mapfile", OT_STR, ST_UNDEF, NULL},
+ {"default_realm", OT_STR, ST_UNDEF, NULL},
diff --git a/package/network/services/ppp/patches/205-no_exponential_timeout.patch b/package/network/services/ppp/patches/205-no_exponential_timeout.patch
new file mode 100644
index 0000000..7119fb8
--- /dev/null
+++ b/package/network/services/ppp/patches/205-no_exponential_timeout.patch
@@ -0,0 +1,29 @@
+pppd: Don't use exponential timeout in discovery phase
+
+This patch removes the exponential timeout increase between PADO or PADS
+discovery attempts.
+
+Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
+
+--- a/pppd/plugins/rp-pppoe/discovery.c
++++ b/pppd/plugins/rp-pppoe/discovery.c
+@@ -548,7 +548,9 @@ discovery(PPPoEConnection *conn)
+ conn->discoveryState = STATE_SENT_PADI;
+ waitForPADO(conn, timeout);
+
++#if 0
+ timeout *= 2;
++#endif
+ } while (conn->discoveryState == STATE_SENT_PADI);
+
+ timeout = conn->discoveryTimeout;
+@@ -563,7 +565,9 @@ discovery(PPPoEConnection *conn)
+ sendPADR(conn);
+ conn->discoveryState = STATE_SENT_PADR;
+ waitForPADS(conn, timeout);
++#if 0
+ timeout *= 2;
++#endif
+ } while (conn->discoveryState == STATE_SENT_PADR);
+
+ /* We're done. */
diff --git a/package/network/services/ppp/patches/206-compensate_time_change.patch b/package/network/services/ppp/patches/206-compensate_time_change.patch
new file mode 100644
index 0000000..fb6c656
--- /dev/null
+++ b/package/network/services/ppp/patches/206-compensate_time_change.patch
@@ -0,0 +1,94 @@
+pppd: Watch out for time warps
+
+On many embedded systems there is no battery backed RTC and a proper system
+time only becomes available through NTP after establishing a connection.
+
+When the clock suddenly jumps forward, the internal accounting (connect time)
+is confused resulting in unreliable data.
+
+This patch implements periodic clock checking to look for time warps, if one
+is detected, the internal counters are adjusted accordingly.
+
+Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
+
+--- a/pppd/main.c
++++ b/pppd/main.c
+@@ -90,6 +90,7 @@
+ #include <sys/socket.h>
+ #include <netinet/in.h>
+ #include <arpa/inet.h>
++#include <sys/sysinfo.h>
+
+ #include "pppd.h"
+ #include "magic.h"
+@@ -228,6 +229,7 @@ static struct subprocess *children;
+
+ /* Prototypes for procedures local to this file. */
+
++static void check_time(void);
+ static void setup_signals __P((void));
+ static void create_pidfile __P((int pid));
+ static void create_linkpidfile __P((int pid));
+@@ -535,6 +537,7 @@ main(argc, argv)
+ info("Starting link");
+ }
+
++ check_time();
+ gettimeofday(&start_time, NULL);
+ script_unsetenv("CONNECT_TIME");
+ script_unsetenv("BYTES_SENT");
+@@ -1267,6 +1270,36 @@ struct callout {
+
+ static struct callout *callout = NULL; /* Callout list */
+ static struct timeval timenow; /* Current time */
++static long uptime_diff = 0;
++static int uptime_diff_set = 0;
++
++static void check_time(void)
++{
++ long new_diff;
++ struct timeval t;
++ struct sysinfo i;
++ struct callout *p;
++
++ gettimeofday(&t, NULL);
++ sysinfo(&i);
++ new_diff = t.tv_sec - i.uptime;
++
++ if (!uptime_diff_set) {
++ uptime_diff = new_diff;
++ uptime_diff_set = 1;
++ return;
++ }
++
++ if ((new_diff - 5 > uptime_diff) || (new_diff + 5 < uptime_diff)) {
++ /* system time has changed, update counters and timeouts */
++ info("System time change detected.");
++ start_time.tv_sec += new_diff - uptime_diff;
++
++ for (p = callout; p != NULL; p = p->c_next)
++ p->c_time.tv_sec += new_diff - uptime_diff;
++ }
++ uptime_diff = new_diff;
++}
+
+ /*
+ * timeout - Schedule a timeout.
+@@ -1337,6 +1370,8 @@ calltimeout()
+ {
+ struct callout *p;
+
++ check_time();
++
+ while (callout != NULL) {
+ p = callout;
+
+@@ -1364,6 +1399,8 @@ timeleft(tvp)
+ {
+ if (callout == NULL)
+ return NULL;
++
++ check_time();
+
+ gettimeofday(&timenow, NULL);
+ tvp->tv_sec = callout->c_time.tv_sec - timenow.tv_sec;
diff --git a/package/network/services/ppp/patches/207-lcp_mtu_max.patch b/package/network/services/ppp/patches/207-lcp_mtu_max.patch
new file mode 100644
index 0000000..1ebcf41
--- /dev/null
+++ b/package/network/services/ppp/patches/207-lcp_mtu_max.patch
@@ -0,0 +1,25 @@
+pppd: Cap MTU to the user configured value
+
+This patchs caps the calculated MTU value in lcp.c to the user specified "mru"
+option value. Without this patch pppd would advertise a different MTU value
+compared to what is set on the local interface in some cases.
+
+Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
+
+--- a/pppd/lcp.c
++++ b/pppd/lcp.c
+@@ -1904,12 +1904,12 @@ lcp_up(f)
+ * the interface MTU is set to the lowest of that, the
+ * MTU we want to use, and our link MRU.
+ */
+- mtu = ho->neg_mru? ho->mru: PPP_MRU;
++ mtu = MIN(ho->neg_mru? ho->mru: PPP_MRU, ao->mru);
+ mru = go->neg_mru? MAX(wo->mru, go->mru): PPP_MRU;
+ #ifdef HAVE_MULTILINK
+ if (!(multilink && go->neg_mrru && ho->neg_mrru))
+ #endif /* HAVE_MULTILINK */
+- netif_set_mtu(f->unit, MIN(MIN(mtu, mru), ao->mru));
++ netif_set_mtu(f->unit, MIN(mtu, mru));
+ ppp_send_config(f->unit, mtu,
+ (ho->neg_asyncmap? ho->asyncmap: 0xffffffff),
+ ho->neg_pcompression, ho->neg_accompression);
diff --git a/package/network/services/ppp/patches/208-fix_status_code.patch b/package/network/services/ppp/patches/208-fix_status_code.patch
new file mode 100644
index 0000000..25e2a10
--- /dev/null
+++ b/package/network/services/ppp/patches/208-fix_status_code.patch
@@ -0,0 +1,24 @@
+pppd: Do not clobber exit codes on hangup
+
+When a modem hangup occurs, pppd unconditionally sets the exit status code
+to EXIT_HANGUP. This patch only sets EXIT_HANGUP if the exit status code is
+not already set to an error value.
+
+The motiviation of this patch is to allow applications which remote control
+pppd to react properly on errors, e.g. only redial (relaunch pppd) if there
+was a hangup, but not if the CHAP authentication failed.
+
+Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
+
+--- a/pppd/main.c
++++ b/pppd/main.c
+@@ -1048,7 +1048,8 @@ get_input()
+ }
+ notice("Modem hangup");
+ hungup = 1;
+- status = EXIT_HANGUP;
++ if (status == EXIT_OK)
++ status = EXIT_HANGUP;
+ lcp_lowerdown(0); /* serial link is no longer available */
+ link_terminated(0);
+ return;
diff --git a/package/network/services/ppp/patches/300-filter-pcap-includes-lib.patch b/package/network/services/ppp/patches/300-filter-pcap-includes-lib.patch
new file mode 100644
index 0000000..d8dcc64
--- /dev/null
+++ b/package/network/services/ppp/patches/300-filter-pcap-includes-lib.patch
@@ -0,0 +1,20 @@
+build: Add required CFLAGS for libpcap
+
+This patch adds some flags to required to properly link libpcap within the
+OpenWrt environment.
+
+Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
+
+--- a/pppd/Makefile.linux
++++ b/pppd/Makefile.linux
+@@ -170,8 +170,8 @@ endif
+
+ ifdef FILTER
+ ifneq ($(wildcard /usr/include/pcap-bpf.h),)
+-LIBS += -lpcap
+-CFLAGS += -DPPP_FILTER
++LIBS += -lpcap -L$(STAGING_DIR)/usr/lib
++CFLAGS += -DPPP_FILTER -I$(STAGING_DIR)/usr/include
+ endif
+ endif
+
diff --git a/package/network/services/ppp/patches/310-precompile_filter.patch b/package/network/services/ppp/patches/310-precompile_filter.patch
new file mode 100644
index 0000000..87b9687
--- /dev/null
+++ b/package/network/services/ppp/patches/310-precompile_filter.patch
@@ -0,0 +1,196 @@
+pppd: Implement support for precompiled pcap filters
+
+This patch implements support for precompiled pcap filters which is useful to
+support dial-on-demand on memory constrained embedded devices without having
+to link the full libpcap into pppd to generate the filters during runtime.
+
+Two new options are introduced; "precompiled-pass-filter" specifies a pre-
+compiled filter file containing rules to match packets which should be passed,
+"precompiled-active-filter" specifies a filter file containing rules to match
+packets which are treated as active.
+
+Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
+
+--- a/pppd/Makefile.linux
++++ b/pppd/Makefile.linux
+@@ -50,6 +50,9 @@ MPPE=y
+ # and that the kernel driver support PPP packet filtering.
+ #FILTER=y
+
++# Support for precompiled filters
++PRECOMPILED_FILTER=y
++
+ # Uncomment the next line to enable multilink PPP (enabled by default)
+ # Linux distributions: Please leave multilink ENABLED in your builds
+ # of pppd!
+@@ -175,6 +178,14 @@ CFLAGS += -DPPP_FILTER -I$(STAGING_DIR)
+ endif
+ endif
+
++ifdef PRECOMPILED_FILTER
++PPPDSRCS += pcap_pcc.c
++HEADERS += pcap_pcc.h
++PPPDOBJS += pcap_pcc.o
++LIBS += $(STAGING_DIR)/usr/lib/libpcap.a
++CFLAGS += -DPPP_FILTER -DPPP_PRECOMPILED_FILTER -I$(STAGING_DIR)/usr/include
++endif
++
+ ifdef HAVE_INET6
+ PPPDSRCS += ipv6cp.c eui64.c
+ HEADERS += ipv6cp.h eui64.h
+--- a/pppd/options.c
++++ b/pppd/options.c
+@@ -57,6 +57,7 @@
+
+ #ifdef PPP_FILTER
+ #include <pcap.h>
++#include <pcap-bpf.h>
+ /*
+ * There have been 3 or 4 different names for this in libpcap CVS, but
+ * this seems to be what they have settled on...
+@@ -162,6 +163,13 @@ static int setlogfile __P((char **));
+ static int loadplugin __P((char **));
+ #endif
+
++#ifdef PPP_PRECOMPILED_FILTER
++#include "pcap_pcc.h"
++static int setprecompiledpassfilter __P((char **));
++static int setprecompiledactivefilter __P((char **));
++#undef PPP_FILTER
++#endif
++
+ #ifdef PPP_FILTER
+ static int setpassfilter __P((char **));
+ static int setactivefilter __P((char **));
+@@ -326,6 +334,14 @@ option_t general_options[] = {
+ "set filter for active pkts", OPT_PRIO },
+ #endif
+
++#ifdef PPP_PRECOMPILED_FILTER
++ { "precompiled-pass-filter", 1, setprecompiledpassfilter,
++ "set precompiled filter for packets to pass", OPT_PRIO },
++
++ { "precompiled-active-filter", 1, setprecompiledactivefilter,
++ "set precompiled filter for active pkts", OPT_PRIO },
++#endif
++
+ #ifdef MAXOCTETS
+ { "maxoctets", o_int, &maxoctets,
+ "Set connection traffic limit",
+@@ -1472,6 +1488,29 @@ callfile(argv)
+ return ok;
+ }
+
++#ifdef PPP_PRECOMPILED_FILTER
++/*
++ * setprecompiledpassfilter - Set the pass filter for packets using a
++ * precompiled expression
++ */
++static int
++setprecompiledpassfilter(argv)
++ char **argv;
++{
++ return pcap_pre_compiled (*argv, &pass_filter);
++}
++
++/*
++ * setactivefilter - Set the active filter for packets
++ */
++static int
++setprecompiledactivefilter(argv)
++ char **argv;
++{
++ return pcap_pre_compiled (*argv, &active_filter);
++}
++#endif
++
+ #ifdef PPP_FILTER
+ /*
+ * setpassfilter - Set the pass filter for packets
+--- /dev/null
++++ b/pppd/pcap_pcc.c
+@@ -0,0 +1,74 @@
++#include <pcap.h>
++#include <pcap-bpf.h>
++#include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
++#include <errno.h>
++#include "pppd.h"
++
++int pcap_pre_compiled (char * fname, struct bpf_program *p)
++{
++ char buf[128];
++ int line = 0, size = 0, index=0, ret=1;
++ FILE *f = fopen (fname, "r");
++ if (!f)
++ {
++ option_error("error opening precompiled active-filter '%s': %s",
++ fname, strerror (errno));
++ return 0;
++ }
++ while (fgets (buf, 127, f))
++ {
++ line++;
++ if (*buf == '#')
++ continue;
++ if (size)
++ {
++ /*
++ struct bpf_insn {
++ u_short code;
++ u_char jt;
++ u_char jf;
++ bpf_int32 k;
++ }
++ */
++ struct bpf_insn * insn = & p->bf_insns[index];
++ unsigned code, jt, jf, k;
++ if (sscanf (buf, "%u %u %u %u", &code, &jt, &jf, &k) != 4)
++ {
++ goto err;
++ }
++ insn->code = code;
++ insn->jt = jt;
++ insn->jf = jf;
++ insn->k = k;
++ index++;
++ }
++ else
++ {
++ if (sscanf (buf, "%u", &size) != 1)
++ {
++ goto err;
++ }
++ p->bf_len = size;
++ p->bf_insns = (struct bpf_insn *)
++ malloc (size * sizeof (struct bpf_insn));
++ }
++ }
++ if (size != index)
++ {
++ option_error("error in precompiled active-filter,"
++ " expected %d expressions, got %dn",
++ size, index);
++ ret = 0;
++ }
++ fclose(f);
++ return ret;
++
++err:
++ option_error("error in precompiled active-filter"
++ " expression line %s:%d (wrong size)\n",
++ fname, line);
++ fclose (f);
++ return 0;
++}
+--- /dev/null
++++ b/pppd/pcap_pcc.h
+@@ -0,0 +1,7 @@
++#ifndef PCAP_PCC_H
++#define PCAP_PCC_H
++
++#include <pcap.h>
++
++int pcap_pre_compiled (char * fname, struct bpf_program *p);
++#endif /* PCAP_PCC_H */
diff --git a/package/network/services/ppp/patches/320-custom_iface_names.patch b/package/network/services/ppp/patches/320-custom_iface_names.patch
new file mode 100644
index 0000000..a95f4f8
--- /dev/null
+++ b/package/network/services/ppp/patches/320-custom_iface_names.patch
@@ -0,0 +1,135 @@
+pppd: Support arbitrary interface names
+
+This patch implements a new string option "ifname" which allows to specify
+fully custom PPP interface names on Linux. It does so by renaming the
+allocated pppX device immediately after it has been created to the requested
+interface name.
+
+Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
+
+--- a/pppd/main.c
++++ b/pppd/main.c
+@@ -745,8 +745,11 @@ void
+ set_ifunit(iskey)
+ int iskey;
+ {
+- info("Using interface %s%d", PPP_DRV_NAME, ifunit);
+- slprintf(ifname, sizeof(ifname), "%s%d", PPP_DRV_NAME, ifunit);
++ if (use_ifname[0] == 0)
++ slprintf(ifname, sizeof(ifname), "%s%d", PPP_DRV_NAME, ifunit);
++ else
++ slprintf(ifname, sizeof(ifname), "%s", use_ifname);
++ info("Using interface %s", ifname);
+ script_setenv("IFNAME", ifname, iskey);
+ if (iskey) {
+ create_pidfile(getpid()); /* write pid to file */
+--- a/pppd/options.c
++++ b/pppd/options.c
+@@ -111,6 +111,7 @@ int log_to_fd = 1; /* send log messages
+ bool log_default = 1; /* log_to_fd is default (stdout) */
+ int maxfail = 10; /* max # of unsuccessful connection attempts */
+ char linkname[MAXPATHLEN]; /* logical name for link */
++char use_ifname[IFNAMSIZ]; /* physical name for PPP link */
+ bool tune_kernel; /* may alter kernel settings */
+ int connect_delay = 1000; /* wait this many ms after connect script */
+ int req_unit = -1; /* requested interface unit */
+@@ -266,6 +267,9 @@ option_t general_options[] = {
+ { "linkname", o_string, linkname,
+ "Set logical name for link",
+ OPT_PRIO | OPT_PRIV | OPT_STATIC, NULL, MAXPATHLEN },
++ { "ifname", o_string, use_ifname,
++ "Set physical name for PPP interface",
++ OPT_PRIO | OPT_PRIV | OPT_STATIC, NULL, IFNAMSIZ },
+
+ { "maxfail", o_int, &maxfail,
+ "Maximum number of unsuccessful connection attempts to allow",
+--- a/pppd/pppd.h
++++ b/pppd/pppd.h
+@@ -71,6 +71,10 @@
+ #include "eui64.h"
+ #endif
+
++#ifndef IFNAMSIZ
++#define IFNAMSIZ 16
++#endif
++
+ /*
+ * Limits.
+ */
+@@ -309,6 +313,7 @@ extern char *record_file; /* File to rec
+ extern bool sync_serial; /* Device is synchronous serial device */
+ extern int maxfail; /* Max # of unsuccessful connection attempts */
+ extern char linkname[MAXPATHLEN]; /* logical name for link */
++extern char use_ifname[IFNAMSIZ]; /* physical name for PPP interface */
+ extern bool tune_kernel; /* May alter kernel settings as necessary */
+ extern int connect_delay; /* Time to delay after connect script */
+ extern int max_data_rate; /* max bytes/sec through charshunt */
+--- a/pppd/sys-linux.c
++++ b/pppd/sys-linux.c
+@@ -168,6 +168,10 @@ struct in6_ifreq {
+ /* We can get an EIO error on an ioctl if the modem has hung up */
+ #define ok_error(num) ((num)==EIO)
+
++#if !defined(PPP_DRV_NAME)
++#define PPP_DRV_NAME "ppp"
++#endif /* !defined(PPP_DRV_NAME) */
++
+ static int tty_disc = N_TTY; /* The TTY discipline */
+ static int ppp_disc = N_PPP; /* The PPP discpline */
+ static int initfdflags = -1; /* Initial file descriptor flags for fd */
+@@ -622,7 +626,8 @@ void generic_disestablish_ppp(int dev_fd
+ */
+ static int make_ppp_unit()
+ {
+- int x, flags;
++ struct ifreq ifr;
++ int x, flags, s;
+
+ if (ppp_dev_fd >= 0) {
+ dbglog("in make_ppp_unit, already had /dev/ppp open?");
+@@ -645,6 +650,30 @@ static int make_ppp_unit()
+ }
+ if (x < 0)
+ error("Couldn't create new ppp unit: %m");
++
++ if (use_ifname[0] != 0) {
++ s = socket(PF_INET, SOCK_DGRAM, 0);
++ if (s < 0)
++ s = socket(PF_PACKET, SOCK_DGRAM, 0);
++ if (s < 0)
++ s = socket(PF_INET6, SOCK_DGRAM, 0);
++ if (s < 0)
++ s = socket(PF_UNIX, SOCK_DGRAM, 0);
++ if (s >= 0) {
++ slprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "%s%d", PPP_DRV_NAME, ifunit);
++ slprintf(ifr.ifr_newname, sizeof(ifr.ifr_newname), "%s", use_ifname);
++ x = ioctl(s, SIOCSIFNAME, &ifr);
++ close(s);
++ } else {
++ x = s;
++ }
++ if (x < 0) {
++ error("Couldn't rename %s to %s", ifr.ifr_name, ifr.ifr_newname);
++ close(ppp_dev_fd);
++ ppp_dev_fd = -1;
++ }
++ }
++
+ return x;
+ }
+
+--- a/pppstats/pppstats.c
++++ b/pppstats/pppstats.c
+@@ -506,10 +506,12 @@ main(argc, argv)
+ if (argc > 0)
+ interface = argv[0];
+
++#if 0
+ if (sscanf(interface, PPP_DRV_NAME "%d", &unit) != 1) {
+ fprintf(stderr, "%s: invalid interface '%s' specified\n",
+ progname, interface);
+ }
++#endif
+
+ #ifndef STREAMS
+ {
diff --git a/package/network/services/ppp/patches/321-multilink_support_custom_iface_names.patch b/package/network/services/ppp/patches/321-multilink_support_custom_iface_names.patch
new file mode 100644
index 0000000..ed04886
--- /dev/null
+++ b/package/network/services/ppp/patches/321-multilink_support_custom_iface_names.patch
@@ -0,0 +1,146 @@
+From: George Kashperko <george@znau.edu.ua>
+
+Make mlppp support more generic interface naming other than pppX
+Signed-off-by: George Kashperko <george@znau.edu.ua>
+---
+ pppd/multilink.c | 55 +++++++++++++++++++++++++++++++++------------
+ pppd/sys-linux.c | 12 +++++++++
+ 2 files changed, 53 insertions(+), 14 deletions(-)
+--- a/pppd/multilink.c
++++ b/pppd/multilink.c
+@@ -56,7 +56,8 @@ static void iterate_bundle_links __P((vo
+
+ static int get_default_epdisc __P((struct epdisc *));
+ static int parse_num __P((char *str, const char *key, int *valp));
+-static int owns_unit __P((TDB_DATA pid, int unit));
++static int parse_str __P((char *str, const char *key, char *buf, int buflen));
++static int owns_link __P((TDB_DATA pid, char *ifname));
+
+ #define set_ip_epdisc(ep, addr) do { \
+ ep->length = 4; \
+@@ -197,35 +198,38 @@ mp_join_bundle()
+ key.dptr = bundle_id;
+ key.dsize = p - bundle_id;
+ pid = tdb_fetch(pppdb, key);
++
+ if (pid.dptr != NULL) {
++ char tmp[IFNAMSIZ];
++
+ /* bundle ID exists, see if the pppd record exists */
+ rec = tdb_fetch(pppdb, pid);
++
+ if (rec.dptr != NULL && rec.dsize > 0) {
+ /* make sure the string is null-terminated */
+ rec.dptr[rec.dsize-1] = 0;
+- /* parse the interface number */
+- parse_num(rec.dptr, "IFNAME=ppp", &unit);
++
+ /* check the pid value */
+ if (!parse_num(rec.dptr, "PPPD_PID=", &pppd_pid)
++ || !parse_str(rec.dptr, "IFNAME=", tmp, sizeof(tmp))
++ || !parse_num(rec.dptr, "IFUNIT=", &unit)
+ || !process_exists(pppd_pid)
+- || !owns_unit(pid, unit))
++ || !owns_link(pid, tmp))
+ unit = -1;
+ free(rec.dptr);
+ }
+ free(pid.dptr);
+- }
+
+- if (unit >= 0) {
+ /* attach to existing unit */
+- if (bundle_attach(unit)) {
++ if (unit >= 0 && bundle_attach(unit)) {
+ set_ifunit(0);
+ script_setenv("BUNDLE", bundle_id + 7, 0);
+ make_bundle_links(1);
+ unlock_db();
+- info("Link attached to %s", ifname);
++ info("Link attached to %s", tmp);
+ return 1;
++ /* attach failed because bundle doesn't exist */
+ }
+- /* attach failed because bundle doesn't exist */
+ }
+
+ /* we have to make a new bundle */
+@@ -408,22 +412,45 @@ parse_num(str, key, valp)
+ return 0;
+ }
+
++static int
++parse_str(str, key, buf, buflen)
++ char *str;
++ const char *key;
++ char *buf;
++ int buflen;
++{
++ char *p, *endp;
++ int i;
++
++ p = strstr(str, key);
++ if (p) {
++ p += strlen(key);
++ while (--buflen && *p != 0 && *p != ';')
++ *(buf++) = *(p++);
++ *buf = 0;
++ return 1;
++ }
++ return 0;
++}
++
+ /*
+- * Check whether the pppd identified by `key' still owns ppp unit `unit'.
++ * Check whether the pppd identified by `key' still owns ppp link `ifname'.
+ */
+ static int
+-owns_unit(key, unit)
++owns_link(key, ifname)
+ TDB_DATA key;
+- int unit;
++ char *ifname;
+ {
+- char ifkey[32];
++ char ifkey[7 + IFNAMSIZ];
+ TDB_DATA kd, vd;
+ int ret = 0;
+
+- slprintf(ifkey, sizeof(ifkey), "IFNAME=ppp%d", unit);
++ slprintf(ifkey, sizeof(ifkey), "IFNAME=%s", ifname);
++
+ kd.dptr = ifkey;
+ kd.dsize = strlen(ifkey);
+ vd = tdb_fetch(pppdb, kd);
++
+ if (vd.dptr != NULL) {
+ ret = vd.dsize == key.dsize
+ && memcmp(vd.dptr, key.dptr, vd.dsize) == 0;
+--- a/pppd/sys-linux.c
++++ b/pppd/sys-linux.c
+@@ -700,6 +700,16 @@ void cfg_bundle(int mrru, int mtru, int
+ add_fd(ppp_dev_fd);
+ }
+
++static void
++setenv_ifunit(void)
++{
++#ifdef USE_TDB
++ char tmp[11];
++ slprintf(tmp, sizeof(tmp), "%d", ifunit);
++ script_setenv("IFUNIT", tmp, 0);
++#endif
++}
++
+ /*
+ * make_new_bundle - create a new PPP unit (i.e. a bundle)
+ * and connect our channel to it. This should only get called
+@@ -718,6 +728,8 @@ void make_new_bundle(int mrru, int mtru,
+
+ /* set the mrru and flags */
+ cfg_bundle(mrru, mtru, rssn, tssn);
++
++ setenv_ifunit();
+ }
+
+ /*
diff --git a/package/network/services/ppp/patches/330-retain_foreign_default_routes.patch b/package/network/services/ppp/patches/330-retain_foreign_default_routes.patch
new file mode 100644
index 0000000..6d93b04
--- /dev/null
+++ b/package/network/services/ppp/patches/330-retain_foreign_default_routes.patch
@@ -0,0 +1,22 @@
+pppd: Retain foreign default routes on Linux
+
+On Linux, when pppd attempts to delete its default route it does not fill
+the rt_dev field of the struct rtentry used to match the system default route.
+As a consequence, pppd happily deletes any default route even if it belongs
+to another interface.
+
+This patch makes pppd fill out the rt_dev field so that only own default
+routes are ever matched.
+
+Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
+
+--- a/pppd/sys-linux.c
++++ b/pppd/sys-linux.c
+@@ -1755,6 +1755,7 @@ int cifdefaultroute (int unit, u_int32_t
+ SIN_ADDR(rt.rt_genmask) = 0L;
+ }
+
++ rt.rt_dev = ifname;
+ rt.rt_flags = RTF_UP;
+ if (ioctl(sock_fd, SIOCDELRT, &rt) < 0 && errno != ESRCH) {
+ if (still_ppp()) {
diff --git a/package/network/services/ppp/patches/340-populate_default_gateway.patch b/package/network/services/ppp/patches/340-populate_default_gateway.patch
new file mode 100644
index 0000000..1c6d9ac
--- /dev/null
+++ b/package/network/services/ppp/patches/340-populate_default_gateway.patch
@@ -0,0 +1,34 @@
+pppd: Fill in default gateway on Linux
+
+On Linux, when pppd creates the default route, it does not set the peer
+address as gateway, leading to a default route without gateway address.
+
+This behaviour breaks various downstream programs which attempt to infer
+the default gateway IP address from the system default route entry.
+
+This patch addresses the issue by filling in the peer address as gateway
+when generating the default route entry.
+
+Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
+
+--- a/pppd/sys-linux.c
++++ b/pppd/sys-linux.c
+@@ -1709,6 +1709,9 @@ int sifdefaultroute (int unit, u_int32_t
+ memset (&rt, 0, sizeof (rt));
+ SET_SA_FAMILY (rt.rt_dst, AF_INET);
+
++ SET_SA_FAMILY(rt.rt_gateway, AF_INET);
++ SIN_ADDR(rt.rt_gateway) = gateway;
++
+ rt.rt_dev = ifname;
+
+ if (kernel_version > KVERSION(2,1,0)) {
+@@ -1716,7 +1719,7 @@ int sifdefaultroute (int unit, u_int32_t
+ SIN_ADDR(rt.rt_genmask) = 0L;
+ }
+
+- rt.rt_flags = RTF_UP;
++ rt.rt_flags = RTF_UP | RTF_GATEWAY;
+ if (ioctl(sock_fd, SIOCADDRT, &rt) < 0) {
+ if (!ok_error(errno))
+ error("default route ioctl(SIOCADDRT): %m");
diff --git a/package/network/services/ppp/patches/400-simplify_kernel_checks.patch b/package/network/services/ppp/patches/400-simplify_kernel_checks.patch
new file mode 100644
index 0000000..4494aba
--- /dev/null
+++ b/package/network/services/ppp/patches/400-simplify_kernel_checks.patch
@@ -0,0 +1,154 @@
+pppd: Remove runtime kernel checks
+
+On embedded system distributions the required kernel features for pppd are
+more or less guaranteed to be present, so there is not much point in
+performing runtime checks, it just increases the binary size.
+
+This patch removes the runtime kernel feature checks.
+
+Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
+
+--- a/pppd/sys-linux.c
++++ b/pppd/sys-linux.c
+@@ -203,7 +203,7 @@ static int driver_is_old = 0;
+ static int restore_term = 0; /* 1 => we've munged the terminal */
+ static struct termios inittermios; /* Initial TTY termios */
+
+-int new_style_driver = 0;
++static const int new_style_driver = 1;
+
+ static char loop_name[20];
+ static unsigned char inbuf[512]; /* buffer for chars read from loopback */
+@@ -220,8 +220,8 @@ static int looped; /* 1 if using loop
+ static int link_mtu; /* mtu for the link (not bundle) */
+
+ static struct utsname utsname; /* for the kernel version */
+-static int kernel_version;
+ #define KVERSION(j,n,p) ((j)*1000000 + (n)*1000 + (p))
++static const int kernel_version = KVERSION(2,6,37);
+
+ #define MAX_IFS 100
+
+@@ -1450,11 +1450,12 @@ int ccp_fatal_error (int unit)
+ *
+ * path_to_procfs - find the path to the proc file system mount point
+ */
+-static char proc_path[MAXPATHLEN];
+-static int proc_path_len;
++static char proc_path[MAXPATHLEN] = "/proc";
++static int proc_path_len = 5;
+
+ static char *path_to_procfs(const char *tail)
+ {
++#if 0
+ struct mntent *mntent;
+ FILE *fp;
+
+@@ -1476,6 +1477,7 @@ static char *path_to_procfs(const char *
+ fclose (fp);
+ }
+ }
++#endif
+
+ strlcpy(proc_path + proc_path_len, tail,
+ sizeof(proc_path) - proc_path_len);
+@@ -2128,15 +2130,19 @@ int ppp_available(void)
+ int my_version, my_modification, my_patch;
+ int osmaj, osmin, ospatch;
+
++#if 0
+ /* get the kernel version now, since we are called before sys_init */
+ uname(&utsname);
+ osmaj = osmin = ospatch = 0;
+ sscanf(utsname.release, "%d.%d.%d", &osmaj, &osmin, &ospatch);
+ kernel_version = KVERSION(osmaj, osmin, ospatch);
++#endif
+
+ fd = open("/dev/ppp", O_RDWR);
+ if (fd >= 0) {
++#if 0
+ new_style_driver = 1;
++#endif
+
+ /* XXX should get from driver */
+ driver_version = 2;
+@@ -2197,6 +2203,7 @@ int ppp_available(void)
+
+ if (ok && ((ifr.ifr_hwaddr.sa_family & ~0xFF) != ARPHRD_PPP))
+ ok = 0;
++ return ok;
+
+ /*
+ * This is the PPP device. Validate the version of the driver at this
+@@ -2690,6 +2697,7 @@ get_pty(master_fdp, slave_fdp, slave_nam
+ }
+ #endif /* TIOCGPTN */
+
++#if 0
+ if (sfd < 0) {
+ /* the old way - scan through the pty name space */
+ for (i = 0; i < 64; ++i) {
+@@ -2708,6 +2716,7 @@ get_pty(master_fdp, slave_fdp, slave_nam
+ }
+ }
+ }
++#endif
+
+ if (sfd < 0)
+ return 0;
+--- a/pppd/plugins/pppoatm/pppoatm.c
++++ b/pppd/plugins/pppoatm/pppoatm.c
+@@ -170,14 +170,6 @@ static void disconnect_pppoatm(void)
+
+ void plugin_init(void)
+ {
+-#if defined(__linux__)
+- extern int new_style_driver; /* From sys-linux.c */
+- if (!ppp_available() && !new_style_driver)
+- fatal("Kernel doesn't support ppp_generic - "
+- "needed for PPPoATM");
+-#else
+- fatal("No PPPoATM support on this OS");
+-#endif
+ info("PPPoATM plugin_init");
+ add_options(pppoa_options);
+ }
+--- a/pppd/plugins/rp-pppoe/plugin.c
++++ b/pppd/plugins/rp-pppoe/plugin.c
+@@ -60,9 +60,6 @@ static char const RCSID[] =
+
+ char pppd_version[] = VERSION;
+
+-/* From sys-linux.c in pppd -- MUST FIX THIS! */
+-extern int new_style_driver;
+-
+ char *pppd_pppoe_service = NULL;
+ static char *acName = NULL;
+ static char *existingSession = NULL;
+@@ -340,10 +337,6 @@ PPPoEDevnameHook(char *cmd, char **argv,
+ void
+ plugin_init(void)
+ {
+- if (!ppp_available() && !new_style_driver) {
+- fatal("Linux kernel does not support PPPoE -- are you running 2.4.x?");
+- }
+-
+ add_options(Options);
+
+ info("RP-PPPoE plugin version %s compiled against pppd %s",
+--- a/pppd/plugins/pppol2tp/pppol2tp.c
++++ b/pppd/plugins/pppol2tp/pppol2tp.c
+@@ -500,12 +500,7 @@ static void pppol2tp_cleanup(void)
+
+ void plugin_init(void)
+ {
+-#if defined(__linux__)
+- extern int new_style_driver; /* From sys-linux.c */
+- if (!ppp_available() && !new_style_driver)
+- fatal("Kernel doesn't support ppp_generic - "
+- "needed for PPPoL2TP");
+-#else
++#if !defined(__linux__)
+ fatal("No PPPoL2TP support on this OS");
+ #endif
+ add_options(pppol2tp_options);
diff --git a/package/network/services/ppp/patches/401-no_record_file.patch b/package/network/services/ppp/patches/401-no_record_file.patch
new file mode 100644
index 0000000..94c0263
--- /dev/null
+++ b/package/network/services/ppp/patches/401-no_record_file.patch
@@ -0,0 +1,39 @@
+pppd: Remove the "record" option
+
+On many embedded systems there is not enough space to record PPP session
+information to the permanent storage, therfore remove this option.
+
+Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
+
+--- a/pppd/pppd.h
++++ b/pppd/pppd.h
+@@ -309,7 +309,6 @@ extern int holdoff; /* Dead time before
+ extern bool holdoff_specified; /* true if user gave a holdoff value */
+ extern bool notty; /* Stdin/out is not a tty */
+ extern char *pty_socket; /* Socket to connect to pty */
+-extern char *record_file; /* File to record chars sent/received */
+ extern bool sync_serial; /* Device is synchronous serial device */
+ extern int maxfail; /* Max # of unsuccessful connection attempts */
+ extern char linkname[MAXPATHLEN]; /* logical name for link */
+--- a/pppd/tty.c
++++ b/pppd/tty.c
+@@ -145,7 +145,7 @@ char *disconnect_script = NULL; /* Scrip
+ char *welcomer = NULL; /* Script to run after phys link estab. */
+ char *ptycommand = NULL; /* Command to run on other side of pty */
+ bool notty = 0; /* Stdin/out is not a tty */
+-char *record_file = NULL; /* File to record chars sent/received */
++static char *const record_file = NULL; /* File to record chars sent/received */
+ int max_data_rate; /* max bytes/sec through charshunt */
+ bool sync_serial = 0; /* Device is synchronous serial device */
+ char *pty_socket = NULL; /* Socket to connect to pty */
+@@ -201,8 +201,10 @@ option_t tty_options[] = {
+ "Send and receive over socket, arg is host:port",
+ OPT_PRIO | OPT_DEVNAM },
+
++#if 0
+ { "record", o_string, &record_file,
+ "Record characters sent/received to file", OPT_PRIO },
++#endif
+
+ { "crtscts", o_int, &crtscts,
+ "Set hardware (RTS/CTS) flow control",
diff --git a/package/network/services/ppp/patches/403-no_wtmp.patch b/package/network/services/ppp/patches/403-no_wtmp.patch
new file mode 100644
index 0000000..e8e7625
--- /dev/null
+++ b/package/network/services/ppp/patches/403-no_wtmp.patch
@@ -0,0 +1,25 @@
+pppd: Disable wtmp support
+
+Many uClibc based environments lack wtmp and utmp support, therfore remove
+the code updating the wtmp information.
+
+Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
+
+--- a/pppd/sys-linux.c
++++ b/pppd/sys-linux.c
+@@ -2266,6 +2266,7 @@ int ppp_available(void)
+
+ void logwtmp (const char *line, const char *name, const char *host)
+ {
++#if 0
+ struct utmp ut, *utp;
+ pid_t mypid = getpid();
+ #if __GLIBC__ < 2
+@@ -2331,6 +2332,7 @@ void logwtmp (const char *line, const ch
+ close (wtmp);
+ }
+ #endif
++#endif
+ }
+
+
diff --git a/package/network/services/ppp/patches/404-remove_obsolete_protocol_names.patch b/package/network/services/ppp/patches/404-remove_obsolete_protocol_names.patch
new file mode 100644
index 0000000..edbca76
--- /dev/null
+++ b/package/network/services/ppp/patches/404-remove_obsolete_protocol_names.patch
@@ -0,0 +1,151 @@
+pppd: Remove historical protocol names
+
+Remove a number of historical protocol entries from pppd's builtin list, this
+reduced the binary size without loss of features.
+
+Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
+
+--- a/pppd/main.c
++++ b/pppd/main.c
+@@ -882,14 +882,17 @@ struct protocol_list {
+ const char *name;
+ } protocol_list[] = {
+ { 0x21, "IP" },
++#if 0
+ { 0x23, "OSI Network Layer" },
+ { 0x25, "Xerox NS IDP" },
+ { 0x27, "DECnet Phase IV" },
+ { 0x29, "Appletalk" },
+ { 0x2b, "Novell IPX" },
++#endif
+ { 0x2d, "VJ compressed TCP/IP" },
+ { 0x2f, "VJ uncompressed TCP/IP" },
+ { 0x31, "Bridging PDU" },
++#if 0
+ { 0x33, "Stream Protocol ST-II" },
+ { 0x35, "Banyan Vines" },
+ { 0x39, "AppleTalk EDDP" },
+@@ -903,8 +906,11 @@ struct protocol_list {
+ { 0x49, "Serial Data Transport Protocol (PPP-SDTP)" },
+ { 0x4b, "SNA over 802.2" },
+ { 0x4d, "SNA" },
++#endif
+ { 0x4f, "IP6 Header Compression" },
++#if 0
+ { 0x51, "KNX Bridging Data" },
++#endif
+ { 0x53, "Encryption" },
+ { 0x55, "Individual Link Encryption" },
+ { 0x57, "IPv6" },
+@@ -915,12 +921,15 @@ struct protocol_list {
+ { 0x65, "RTP IPHC Compressed non-TCP" },
+ { 0x67, "RTP IPHC Compressed UDP 8" },
+ { 0x69, "RTP IPHC Compressed RTP 8" },
++#if 0
+ { 0x6f, "Stampede Bridging" },
+ { 0x73, "MP+" },
+ { 0xc1, "NTCITS IPI" },
++#endif
+ { 0xfb, "single-link compression" },
+ { 0xfd, "Compressed Datagram" },
+ { 0x0201, "802.1d Hello Packets" },
++#if 0
+ { 0x0203, "IBM Source Routing BPDU" },
+ { 0x0205, "DEC LANBridge100 Spanning Tree" },
+ { 0x0207, "Cisco Discovery Protocol" },
+@@ -932,15 +941,19 @@ struct protocol_list {
+ { 0x0231, "Luxcom" },
+ { 0x0233, "Sigma Network Systems" },
+ { 0x0235, "Apple Client Server Protocol" },
++#endif
+ { 0x0281, "MPLS Unicast" },
+ { 0x0283, "MPLS Multicast" },
++#if 0
+ { 0x0285, "IEEE p1284.4 standard - data packets" },
+ { 0x0287, "ETSI TETRA Network Protocol Type 1" },
++#endif
+ { 0x0289, "Multichannel Flow Treatment Protocol" },
+ { 0x2063, "RTP IPHC Compressed TCP No Delta" },
+ { 0x2065, "RTP IPHC Context State" },
+ { 0x2067, "RTP IPHC Compressed UDP 16" },
+ { 0x2069, "RTP IPHC Compressed RTP 16" },
++#if 0
+ { 0x4001, "Cray Communications Control Protocol" },
+ { 0x4003, "CDPD Mobile Network Registration Protocol" },
+ { 0x4005, "Expand accelerator protocol" },
+@@ -951,8 +964,10 @@ struct protocol_list {
+ { 0x4023, "RefTek Protocol" },
+ { 0x4025, "Fibre Channel" },
+ { 0x4027, "EMIT Protocols" },
++#endif
+ { 0x405b, "Vendor-Specific Protocol (VSP)" },
+ { 0x8021, "Internet Protocol Control Protocol" },
++#if 0
+ { 0x8023, "OSI Network Layer Control Protocol" },
+ { 0x8025, "Xerox NS IDP Control Protocol" },
+ { 0x8027, "DECnet Phase IV Control Protocol" },
+@@ -961,7 +976,9 @@ struct protocol_list {
+ { 0x8031, "Bridging NCP" },
+ { 0x8033, "Stream Protocol Control Protocol" },
+ { 0x8035, "Banyan Vines Control Protocol" },
++#endif
+ { 0x803d, "Multi-Link Control Protocol" },
++#if 0
+ { 0x803f, "NETBIOS Framing Control Protocol" },
+ { 0x8041, "Cisco Systems Control Protocol" },
+ { 0x8043, "Ascom Timeplex" },
+@@ -970,18 +987,24 @@ struct protocol_list {
+ { 0x8049, "Serial Data Control Protocol (PPP-SDCP)" },
+ { 0x804b, "SNA over 802.2 Control Protocol" },
+ { 0x804d, "SNA Control Protocol" },
++#endif
+ { 0x804f, "IP6 Header Compression Control Protocol" },
++#if 0
+ { 0x8051, "KNX Bridging Control Protocol" },
++#endif
+ { 0x8053, "Encryption Control Protocol" },
+ { 0x8055, "Individual Link Encryption Control Protocol" },
+ { 0x8057, "IPv6 Control Protocol" },
+ { 0x8059, "PPP Muxing Control Protocol" },
+ { 0x805b, "Vendor-Specific Network Control Protocol (VSNCP)" },
++#if 0
+ { 0x806f, "Stampede Bridging Control Protocol" },
+ { 0x8073, "MP+ Control Protocol" },
+ { 0x80c1, "NTCITS IPI Control Protocol" },
++#endif
+ { 0x80fb, "Single Link Compression Control Protocol" },
+ { 0x80fd, "Compression Control Protocol" },
++#if 0
+ { 0x8207, "Cisco Discovery Protocol Control" },
+ { 0x8209, "Netcs Twin Routing" },
+ { 0x820b, "STP - Control Protocol" },
+@@ -990,24 +1013,29 @@ struct protocol_list {
+ { 0x8281, "MPLSCP" },
+ { 0x8285, "IEEE p1284.4 standard - Protocol Control" },
+ { 0x8287, "ETSI TETRA TNP1 Control Protocol" },
++#endif
+ { 0x8289, "Multichannel Flow Treatment Protocol" },
+ { 0xc021, "Link Control Protocol" },
+ { 0xc023, "Password Authentication Protocol" },
+ { 0xc025, "Link Quality Report" },
++#if 0
+ { 0xc027, "Shiva Password Authentication Protocol" },
+ { 0xc029, "CallBack Control Protocol (CBCP)" },
+ { 0xc02b, "BACP Bandwidth Allocation Control Protocol" },
+ { 0xc02d, "BAP" },
++#endif
+ { 0xc05b, "Vendor-Specific Authentication Protocol (VSAP)" },
+ { 0xc081, "Container Control Protocol" },
+ { 0xc223, "Challenge Handshake Authentication Protocol" },
+ { 0xc225, "RSA Authentication Protocol" },
+ { 0xc227, "Extensible Authentication Protocol" },
++#if 0
+ { 0xc229, "Mitsubishi Security Info Exch Ptcl (SIEP)" },
+ { 0xc26f, "Stampede Bridging Authorization Protocol" },
+ { 0xc281, "Proprietary Authentication Protocol" },
+ { 0xc283, "Proprietary Authentication Protocol" },
+ { 0xc481, "Proprietary Node ID Authentication Protocol" },
++#endif
+ { 0, NULL },
+ };
+
diff --git a/package/network/services/ppp/patches/405-no_multilink_option.patch b/package/network/services/ppp/patches/405-no_multilink_option.patch
new file mode 100644
index 0000000..97a79c4
--- /dev/null
+++ b/package/network/services/ppp/patches/405-no_multilink_option.patch
@@ -0,0 +1,28 @@
+pppd: Support "nomp" option even if multilink support is off
+
+This patch moves the "nomp" option entry outside of the defines protecting
+the multilink specific code. The motivation is to allow "nomp" even if pppd
+does not support multilink, so that controlling programs can unconditionally
+pass it to pppd regardless of the compile time features.
+
+Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
+
+--- a/pppd/options.c
++++ b/pppd/options.c
+@@ -318,13 +318,14 @@ option_t general_options[] = {
+ "Enable multilink operation", OPT_PRIOSUB | OPT_ALIAS | 1 },
+ { "nomultilink", o_bool, &multilink,
+ "Disable multilink operation", OPT_PRIOSUB | 0 },
+- { "nomp", o_bool, &multilink,
+- "Disable multilink operation", OPT_PRIOSUB | OPT_ALIAS | 0 },
+
+ { "bundle", o_string, &bundle_name,
+ "Bundle name for multilink", OPT_PRIO },
+ #endif /* HAVE_MULTILINK */
+
++ { "nomp", o_bool, &multilink,
++ "Disable multilink operation", OPT_PRIOSUB | OPT_ALIAS | 0 },
++
+ #ifdef PLUGIN
+ { "plugin", o_special, (void *)loadplugin,
+ "Load a plug-in module into pppd", OPT_PRIV | OPT_A2LIST },
diff --git a/package/network/services/ppp/patches/430-pppol2tpv3-struct.patch b/package/network/services/ppp/patches/430-pppol2tpv3-struct.patch
new file mode 100644
index 0000000..204aa4e
--- /dev/null
+++ b/package/network/services/ppp/patches/430-pppol2tpv3-struct.patch
@@ -0,0 +1,56 @@
+pppol2tp: Provide struct pppol2tpv3_addr to align with Linux
+
+The struct pppol2tpv3_addr is referenced in the current Linux kernel sources
+but not provided by the shipped kernel headers, add it.
+
+Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
+
+--- a/include/linux/if_pppol2tp.h
++++ b/include/linux/if_pppol2tp.h
+@@ -32,6 +32,46 @@ struct pppol2tp_addr
+ __u16 d_tunnel, d_session; /* For sending outgoing packets */
+ };
+
++/* Structure used to connect() the socket to a particular tunnel UDP
++ * socket over IPv6.
++ */
++struct pppol2tpin6_addr
++{
++ pid_t pid; /* pid that owns the fd.
++ * 0 => current */
++ int fd; /* FD of UDP socket to use */
++
++ __u16 s_tunnel, s_session; /* For matching incoming packets */
++ __u16 d_tunnel, d_session; /* For sending outgoing packets */
++
++ struct sockaddr_in6 addr; /* IP address and port to send to */
++};
++
++/* The L2TPv3 protocol changes tunnel and session ids from 16 to 32
++ * bits. So we need a different sockaddr structure.
++ */
++struct pppol2tpv3_addr {
++ pid_t pid; /* pid that owns the fd.
++ * 0 => current */
++ int fd; /* FD of UDP or IP socket to use */
++
++ struct sockaddr_in addr; /* IP address and port to send to */
++
++ __u32 s_tunnel, s_session; /* For matching incoming packets */
++ __u32 d_tunnel, d_session; /* For sending outgoing packets */
++};
++
++struct pppol2tpv3in6_addr {
++ pid_t pid; /* pid that owns the fd.
++ * 0 => current */
++ int fd; /* FD of UDP or IP socket to use */
++
++ __u32 s_tunnel, s_session; /* For matching incoming packets */
++ __u32 d_tunnel, d_session; /* For sending outgoing packets */
++
++ struct sockaddr_in6 addr; /* IP address and port to send to */
++};
++
+ /* Socket options:
+ * DEBUG - bitmask of debug message categories
+ * SENDSEQ - 0 => don't send packets with sequence numbers
diff --git a/package/network/services/ppp/patches/500-add-pptp-plugin.patch b/package/network/services/ppp/patches/500-add-pptp-plugin.patch
new file mode 100644
index 0000000..d984e1b
--- /dev/null
+++ b/package/network/services/ppp/patches/500-add-pptp-plugin.patch
@@ -0,0 +1,3065 @@
+--- a/configure
++++ b/configure
+@@ -195,7 +195,7 @@ if [ -d "$ksrc" ]; then
+ mkmkf $ksrc/Makedefs$compiletype Makedefs.com
+ for dir in pppd pppstats chat pppdump pppd/plugins pppd/plugins/rp-pppoe \
+ pppd/plugins/radius pppd/plugins/pppoatm \
+- pppd/plugins/pppol2tp; do
++ pppd/plugins/pppol2tp pppd/plugins/pptp ; do
+ mkmkf $dir/Makefile.$makext $dir/Makefile
+ done
+ if [ -f $ksrc/Makefile.$makext$archvariant ]; then
+--- a/pppd/plugins/Makefile.linux
++++ b/pppd/plugins/Makefile.linux
+@@ -9,7 +9,7 @@ BINDIR = $(DESTDIR)/sbin
+ MANDIR = $(DESTDIR)/share/man/man8
+ LIBDIR = $(DESTDIR)/lib/pppd/$(VERSION)
+
+-SUBDIRS := rp-pppoe pppoatm pppol2tp
++SUBDIRS := rp-pppoe pppoatm pppol2tp pptp
+ # Uncomment the next line to include the radius authentication plugin
+ SUBDIRS += radius
+ PLUGINS := minconn.so passprompt.so passwordfd.so winbind.so
+--- /dev/null
++++ b/pppd/plugins/pptp/Makefile.linux
+@@ -0,0 +1,31 @@
++#
++# This program may be distributed according to the terms of the GNU
++# General Public License, version 2 or (at your option) any later version.
++#
++# $Id: Makefile.linux,v 1.9 2012/05/04 21:48:00 dgolle Exp $
++#***********************************************************************
++
++DESTDIR = $(INSTROOT)@DESTDIR@
++LIBDIR = $(DESTDIR)/lib/pppd/$(PPPDVERSION)
++
++PPPDVERSION = $(shell awk -F '"' '/VERSION/ { print $$2; }' ../../patchlevel.h)
++
++INSTALL = install
++
++COPTS=-O2 -g
++CFLAGS = $(COPTS) -I. -I../.. -I../../../include -fPIC -DPPPD_VERSION=\"$(PPPDVERSION)\"
++all: pptp.so
++
++%.o: %.c
++ $(CC) $(CFLAGS) -c -o $@ $<
++
++pptp.so: dirutil.o orckit_quirks.o pptp.o pptp_callmgr.o pptp_ctrl.o pptp_quirks.o util.o vector.o
++ $(CC) -o pptp.so -shared dirutil.o orckit_quirks.o pptp.o pptp_callmgr.o pptp_ctrl.o pptp_quirks.o util.o vector.o
++
++install: all
++ $(INSTALL) -d -m 755 $(LIBDIR)
++ $(INSTALL) -c -m 4550 pptp.so $(LIBDIR)
++
++clean:
++ rm -f *.o *.so
++
+--- /dev/null
++++ b/pppd/plugins/pptp/dirutil.c
+@@ -0,0 +1,68 @@
++/* dirutil.c ... directory utilities.
++ * C. Scott Ananian <cananian@alumni.princeton.edu>
++ *
++ * $Id: dirutil.c,v 1.2 2003/06/17 17:25:47 reink Exp $
++ */
++
++#include <sys/stat.h>
++#include <sys/types.h>
++#include <unistd.h>
++#include <string.h>
++#include <stdlib.h>
++#include "dirutil.h"
++
++/* Returned malloc'ed string representing basename */
++char *basenamex(char *pathname)
++{
++ char *dup = strdup(pathname);
++ char *ptr = strrchr(stripslash(dup), '/');
++ if (ptr == NULL) return dup;
++ ptr = strdup(ptr+1);
++ free(dup);
++ return ptr;
++}
++
++/* Return malloc'ed string representing directory name (no trailing slash) */
++char *dirnamex(char *pathname)
++{
++ char *dup = strdup(pathname);
++ char *ptr = strrchr(stripslash(dup), '/');
++ if (ptr == NULL) { free(dup); return strdup("."); }
++ if (ptr == dup && dup[0] == '/') ptr++;
++ *ptr = '\0';
++ return dup;
++}
++
++/* In-place modify a string to remove trailing slashes. Returns arg.
++ * stripslash("/") returns "/";
++ */
++char *stripslash(char *pathname) {
++ int len = strlen(pathname);
++ while (len > 1 && pathname[len - 1] == '/')
++ pathname[--len] = '\0';
++ return pathname;
++}
++
++/* ensure dirname exists, creating it if necessary. */
++int make_valid_path(char *dir, mode_t mode)
++{
++ struct stat st;
++ char *tmp = NULL, *path = stripslash(strdup(dir));
++ int retval;
++ if (stat(path, &st) == 0) { /* file exists */
++ if (S_ISDIR(st.st_mode)) { retval = 1; goto end; }
++ else { retval = 0; goto end; } /* not a directory. Oops. */
++ }
++ /* Directory doesn't exist. Let's make it. */
++ /* Make parent first. */
++ if (!make_valid_path(tmp = dirnamex(path), mode)) { retval = 0; goto end; }
++ /* Now make this 'un. */
++ if (mkdir(path, mode) < 0) { retval = 0; goto end; }
++ /* Success. */
++ retval = 1;
++
++end:
++ if (tmp != NULL) free(tmp);
++ if (path != NULL) free(path);
++ return retval;
++}
+--- /dev/null
++++ b/pppd/plugins/pptp/dirutil.h
+@@ -0,0 +1,14 @@
++/* dirutil.h ... directory utilities.
++ * C. Scott Ananian <cananian@alumni.princeton.edu>
++ *
++ * $Id: dirutil.h,v 1.1.1.1 2000/12/23 08:19:51 scott Exp $
++ */
++
++/* Returned malloc'ed string representing basename */
++char *basenamex(char *pathname);
++/* Return malloc'ed string representing directory name (no trailing slash) */
++char *dirnamex(char *pathname);
++/* In-place modify a string to remove trailing slashes. Returns arg. */
++char *stripslash(char *pathname);
++/* ensure dirname exists, creating it if necessary. */
++int make_valid_path(char *dirname, mode_t mode);
+--- /dev/null
++++ b/pppd/plugins/pptp/orckit_quirks.c
+@@ -0,0 +1,86 @@
++/* orckit_quirks.c ...... fix quirks in orckit adsl modems
++ * mulix <mulix@actcom.co.il>
++ *
++ * $Id: orckit_quirks.c,v 1.3 2002/03/01 01:23:36 quozl Exp $
++ */
++
++#include <string.h>
++#include <sys/types.h>
++#include <netinet/in.h>
++#include "pptp_msg.h"
++#include "pptp_options.h"
++#include "pptp_ctrl.h"
++#include "util.h"
++
++
++
++/* return 0 on success, non zero otherwise */
++int
++orckit_atur3_build_hook(struct pptp_out_call_rqst* packet)
++{
++ unsigned int name_length = 10;
++
++ struct pptp_out_call_rqst fixed_packet = {
++ PPTP_HEADER_CTRL(PPTP_OUT_CALL_RQST),
++ 0, /* hton16(call->callid) */
++ 0, /* hton16(call->sernum) */
++ hton32(PPTP_BPS_MIN), hton32(PPTP_BPS_MAX),
++ hton32(PPTP_BEARER_DIGITAL), hton32(PPTP_FRAME_ANY),
++ hton16(PPTP_WINDOW), 0, hton16(name_length), 0,
++ {'R','E','L','A','Y','_','P','P','P','1',0}, {0}
++ };
++
++ if (!packet)
++ return -1;
++
++ memcpy(packet, &fixed_packet, sizeof(*packet));
++
++ return 0;
++}
++
++/* return 0 on success, non zero otherwise */
++int
++orckit_atur3_set_link_hook(struct pptp_set_link_info* packet,
++ int peer_call_id)
++{
++ struct pptp_set_link_info fixed_packet = {
++ PPTP_HEADER_CTRL(PPTP_SET_LINK_INFO),
++ hton16(peer_call_id),
++ 0,
++ 0xffffffff,
++ 0xffffffff};
++
++ if (!packet)
++ return -1;
++
++ memcpy(packet, &fixed_packet, sizeof(*packet));
++ return 0;
++}
++
++/* return 0 on success, non 0 otherwise */
++int
++orckit_atur3_start_ctrl_conn_hook(struct pptp_start_ctrl_conn* packet)
++{
++ struct pptp_start_ctrl_conn fixed_packet = {
++ {0}, /* we'll set the header later */
++ hton16(PPTP_VERSION), 0, 0,
++ hton32(PPTP_FRAME_ASYNC), hton32(PPTP_BEARER_ANALOG),
++ hton16(0) /* max channels */,
++ hton16(0x6021),
++ {'R','E','L','A','Y','_','P','P','P','1',0}, /* hostname */
++ {'M','S',' ','W','i','n',' ','N','T',0} /* vendor */
++ };
++
++ if (!packet)
++ return -1;
++
++ /* grab the header from the original packet, since we dont
++ know if this is a request or a reply */
++ memcpy(&fixed_packet.header, &packet->header, sizeof(struct pptp_header));
++
++ /* and now overwrite the full packet, effectively preserving the header */
++ memcpy(packet, &fixed_packet, sizeof(*packet));
++ return 0;
++}
++
++
+--- /dev/null
++++ b/pppd/plugins/pptp/orckit_quirks.h
+@@ -0,0 +1,27 @@
++/* orckit_quirks.h ...... fix quirks in orckit adsl modems
++ * mulix <mulix@actcom.co.il>
++ *
++ * $Id: orckit_quirks.h,v 1.2 2001/11/23 03:42:51 quozl Exp $
++ */
++
++#ifndef INC_ORCKIT_QUIRKS_H_
++#define INC_ORCKIT_QUIRKS_H_
++
++#include "pptp_options.h"
++#include "pptp_ctrl.h"
++#include "pptp_msg.h"
++
++/* return 0 on success, non zero otherwise */
++int
++orckit_atur3_build_hook(struct pptp_out_call_rqst* packt);
++
++/* return 0 on success, non zero otherwise */
++int
++orckit_atur3_set_link_hook(struct pptp_set_link_info* packet,
++ int peer_call_id);
++
++/* return 0 on success, non zero otherwise */
++int
++orckit_atur3_start_ctrl_conn_hook(struct pptp_start_ctrl_conn* packet);
++
++#endif /* INC_ORCKIT_QUIRKS_H_ */
+--- /dev/null
++++ b/pppd/plugins/pptp/pppd-pptp.8
+@@ -0,0 +1,68 @@
++.\" manual page [] for PPTP plugin for pppd 2.4
++.\" $Id: pppd-pptp.8,v 1.0 2007/10/17 13:27:17 kad Exp $
++.\" SH section heading
++.\" SS subsection heading
++.\" LP paragraph
++.\" IP indented paragraph
++.\" TP hanging label
++.TH PPPD-PPTP 8
++.SH NAME
++pptp.so \- PPTP VPN plugin for
++.BR pppd (8)
++.SH SYNOPSIS
++.B pppd
++[
++.I options
++]
++plugin pptp.so
++.SH DESCRIPTION
++.LP
++The PPTP plugin for pppd performs interaction with pptp kernel module
++and has built-in call manager (client part of PPTP).
++It pasees necessary paremeters from \fIoptions\fR into kernel module
++to configure ppp-pptp channel. If it runs in client mode, then additionally
++call manager starts up. PPTPD daemon automaticaly invokes this plugin
++in server mode and passes necessary options, so additional configuration
++is not needed.
++
++.SH OPTIONS for client mode
++The PPTP plugin introduces one additional pppd option:
++.TP
++.BI "pptp_server " server " (required)"
++Specifies ip address or hostname of pptp server.
++.TP
++.BI "pptp_window " packets " (optional)"
++The amount of sliding window size.
++Set to 0 to turn off sliding window.
++ to 3-10 for low speed connections.
++ to >10 for hi speed connections.
++Default is 50
++.TP
++.BI "pptp_phone " phone " (optional)"
++The phone string that sended to pptp server.
++.SH USAGE
++Sample configuration file:
++.nf
++plugin "pptp.so"
++pptp_server 192.168.0.1
++pptp_window 100
++name myname
++remotename pptp
++noauth
++refuse-eap
++refuse-chap
++refuse-mschap
++nobsdcomp
++nodeflate
++novj
++novjccomp
++require-mppe-128
++lcp-echo-interval 20
++lcp-echo-failure 3
++.fi
++
++.SH SEE ALSO
++.BR pppd (8) " " pptpd (8) " " pptpd.conf (5)
++
++.SH AUTHOR
++xeb xeb@mail.ru
+--- /dev/null
++++ b/pppd/plugins/pptp/pptp.c
+@@ -0,0 +1,323 @@
++/***************************************************************************
++ * Copyright (C) 2006 by Kozlov D. <xeb@mail.ru> *
++ * some cleanup done (C) 2012 by Daniel Golle <dgolle@allnet.de> *
++ * *
++ * 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 of the License, 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; if not, write to the *
++ * Free Software Foundation, Inc., *
++ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
++ ***************************************************************************/
++
++#define PPTP_VERSION "1.00"
++
++#ifdef HAVE_CONFIG_H
++#include <config.h>
++#endif
++
++#include <netinet/in.h>
++#include <arpa/inet.h>
++#include <sys/un.h>
++#include <netdb.h>
++#include <stdio.h>
++#include <string.h>
++#include <stdlib.h>
++#include <syslog.h>
++#include <unistd.h>
++#include <signal.h>
++#include <errno.h>
++#include <fcntl.h>
++#include <sys/wait.h>
++#include <sys/ioctl.h>
++
++#include "pppd.h"
++#include "fsm.h"
++#include "lcp.h"
++#include "ipcp.h"
++#include "ccp.h"
++#include "pathnames.h"
++
++#include "pptp_callmgr.h"
++#include <net/if.h>
++#include <net/ethernet.h>
++#include <linux/if_pppox.h>
++
++#include <stdio.h>
++#include <stdlib.h>
++
++
++
++extern char** environ;
++
++char pppd_version[] = PPPD_VERSION;
++extern int new_style_driver;
++
++
++char *pptp_server = NULL;
++char *pptp_client = NULL;
++char *pptp_phone = NULL;
++int pptp_window=50;
++int pptp_sock=-1;
++struct in_addr localbind = { INADDR_NONE };
++
++static int callmgr_sock;
++static int pptp_fd;
++int call_ID;
++
++static int open_callmgr(int call_id,struct in_addr inetaddr, char *phonenr,int window);
++static void launch_callmgr(int call_is,struct in_addr inetaddr, char *phonenr,int window);
++static int get_call_id(int sock, pid_t gre, pid_t pppd, u_int16_t *peer_call_id);
++
++static option_t Options[] =
++{
++ { "pptp_server", o_string, &pptp_server,
++ "PPTP Server" },
++ { "pptp_client", o_string, &pptp_client,
++ "PPTP Client" },
++ { "pptp_sock",o_int, &pptp_sock,
++ "PPTP socket" },
++ { "pptp_phone", o_string, &pptp_phone,
++ "PPTP Phone number" },
++ { "pptp_window",o_int, &pptp_window,
++ "PPTP window" },
++ { NULL }
++};
++
++static int pptp_connect(void);
++static void pptp_disconnect(void);
++
++struct channel pptp_channel = {
++ options: Options,
++ check_options: NULL,
++ connect: &pptp_connect,
++ disconnect: &pptp_disconnect,
++ establish_ppp: &generic_establish_ppp,
++ disestablish_ppp: &generic_disestablish_ppp,
++ close: NULL,
++ cleanup: NULL
++};
++
++static int pptp_start_server(void)
++{
++ pptp_fd=pptp_sock;
++ sprintf(ppp_devnam,"pptp (%s)",pptp_client);
++
++ return pptp_fd;
++}
++static int pptp_start_client(void)
++{
++ socklen_t len;
++ struct sockaddr_pppox src_addr,dst_addr;
++ struct hostent *hostinfo;
++
++ hostinfo=gethostbyname(pptp_server);
++ if (!hostinfo)
++ {
++ error("PPTP: Unknown host %s\n", pptp_server);
++ return -1;
++ }
++ dst_addr.sa_addr.pptp.sin_addr=*(struct in_addr*)hostinfo->h_addr;
++ {
++ int sock;
++ struct sockaddr_in addr;
++ len=sizeof(addr);
++ addr.sin_addr=dst_addr.sa_addr.pptp.sin_addr;
++ addr.sin_family=AF_INET;
++ addr.sin_port=htons(1700);
++ sock=socket(AF_INET,SOCK_DGRAM,0);
++ if (connect(sock,(struct sockaddr*)&addr,sizeof(addr)))
++ {
++ close(sock);
++ error("PPTP: connect failed (%s)\n",strerror(errno));
++ return -1;
++ }
++ getsockname(sock,(struct sockaddr*)&addr,&len);
++ src_addr.sa_addr.pptp.sin_addr=addr.sin_addr;
++ close(sock);
++ }
++
++ src_addr.sa_family=AF_PPPOX;
++ src_addr.sa_protocol=PX_PROTO_PPTP;
++ src_addr.sa_addr.pptp.call_id=0;
++
++ dst_addr.sa_family=AF_PPPOX;
++ dst_addr.sa_protocol=PX_PROTO_PPTP;
++ dst_addr.sa_addr.pptp.call_id=0;
++
++ pptp_fd=socket(AF_PPPOX,SOCK_STREAM,PX_PROTO_PPTP);
++ if (pptp_fd<0)
++ {
++ error("PPTP: failed to create PPTP socket (%s)\n",strerror(errno));
++ return -1;
++ }
++ if (bind(pptp_fd,(struct sockaddr*)&src_addr,sizeof(src_addr)))
++ {
++ close(pptp_fd);
++ error("PPTP: failed to bind PPTP socket (%s)\n",strerror(errno));
++ return -1;
++ }
++ len=sizeof(src_addr);
++ getsockname(pptp_fd,(struct sockaddr*)&src_addr,&len);
++ call_ID=src_addr.sa_addr.pptp.call_id;
++
++ do {
++ /*
++ * Open connection to call manager (Launch call manager if necessary.)
++ */
++ callmgr_sock = open_callmgr(src_addr.sa_addr.pptp.call_id,dst_addr.sa_addr.pptp.sin_addr, pptp_phone, pptp_window);
++ if (callmgr_sock<0)
++ {
++ close(pptp_fd);
++ return -1;
++ }
++ /* Exchange PIDs, get call ID */
++ } while (get_call_id(callmgr_sock, getpid(), getpid(), &dst_addr.sa_addr.pptp.call_id) < 0);
++
++ if (connect(pptp_fd,(struct sockaddr*)&dst_addr,sizeof(dst_addr)))
++ {
++ close(callmgr_sock);
++ close(pptp_fd);
++ error("PPTP: failed to connect PPTP socket (%s)\n",strerror(errno));
++ return -1;
++ }
++
++ sprintf(ppp_devnam,"pptp (%s)",pptp_server);
++
++ return pptp_fd;
++}
++static int pptp_connect(void)
++{
++ if ((!pptp_server && !pptp_client) || (pptp_server && pptp_client))
++ {
++ fatal("PPTP: unknown mode (you must specify pptp_server or pptp_client option)");
++ return -1;
++ }
++
++ if (pptp_server) return pptp_start_client();
++ return pptp_start_server();
++}
++
++static void pptp_disconnect(void)
++{
++ if (pptp_server) close(callmgr_sock);
++ close(pptp_fd);
++}
++
++static int open_callmgr(int call_id,struct in_addr inetaddr, char *phonenr,int window)
++{
++ /* Try to open unix domain socket to call manager. */
++ struct sockaddr_un where;
++ const int NUM_TRIES = 3;
++ int i, fd;
++ pid_t pid;
++ int status;
++ /* Open socket */
++ if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
++ {
++ fatal("Could not create unix domain socket: %s", strerror(errno));
++ }
++ /* Make address */
++ callmgr_name_unixsock(&where, inetaddr, localbind);
++ for (i = 0; i < NUM_TRIES; i++)
++ {
++ if (connect(fd, (struct sockaddr *) &where, sizeof(where)) < 0)
++ {
++ /* couldn't connect. We'll have to launch this guy. */
++
++ unlink (where.sun_path);
++
++ /* fork and launch call manager process */
++ switch (pid = fork())
++ {
++ case -1: /* failure */
++ fatal("fork() to launch call manager failed.");
++ case 0: /* child */
++ {
++ /* close the pty and gre in the call manager */
++ close(fd);
++ close(pptp_fd);
++ launch_callmgr(call_id,inetaddr,phonenr,window);
++ }
++ default: /* parent */
++ waitpid(pid, &status, 0);
++ if (status!= 0)
++ {
++ close(fd);
++ error("Call manager exited with error %d", status);
++ return -1;
++ }
++ break;
++ }
++ sleep(1);
++ }
++ else return fd;
++ }
++ close(fd);
++ error("Could not launch call manager after %d tries.", i);
++ return -1; /* make gcc happy */
++}
++
++/*** call the call manager main ***********************************************/
++static void launch_callmgr(int call_id,struct in_addr inetaddr, char *phonenr,int window)
++{
++ dbglog("pptp: call manager for %s\n", inet_ntoa(inetaddr));
++ dbglog("window size:\t%d\n",window);
++ if (phonenr) dbglog("phone number:\t'%s'\n",phonenr);
++ dbglog("call id:\t%d\n",call_id);
++ exit(callmgr_main(inetaddr, phonenr, window, call_id));
++}
++
++/*** exchange data with the call manager *************************************/
++/* XXX need better error checking XXX */
++static int get_call_id(int sock, pid_t gre, pid_t pppd,
++ u_int16_t *peer_call_id)
++{
++ u_int16_t m_call_id, m_peer_call_id;
++ /* write pid's to socket */
++ /* don't bother with network byte order, because pid's are meaningless
++ * outside the local host.
++ */
++ int rc;
++ rc = write(sock, &gre, sizeof(gre));
++ if (rc != sizeof(gre))
++ return -1;
++ rc = write(sock, &pppd, sizeof(pppd));
++ if (rc != sizeof(pppd))
++ return -1;
++ rc = read(sock, &m_call_id, sizeof(m_call_id));
++ if (rc != sizeof(m_call_id))
++ return -1;
++ rc = read(sock, &m_peer_call_id, sizeof(m_peer_call_id));
++ if (rc != sizeof(m_peer_call_id))
++ return -1;
++ /*
++ * XXX FIXME ... DO ERROR CHECKING & TIME-OUTS XXX
++ * (Rhialto: I am assuming for now that timeouts are not relevant
++ * here, because the read and write calls would return -1 (fail) when
++ * the peer goes away during the process. We know it is (or was)
++ * running because the connect() call succeeded.)
++ * (James: on the other hand, if the route to the peer goes away, we
++ * wouldn't get told by read() or write() for quite some time.)
++ */
++ *peer_call_id = m_peer_call_id;
++ return 0;
++}
++
++void plugin_init(void)
++{
++ add_options(Options);
++
++ info("PPTP plugin version %s", PPTP_VERSION);
++
++ the_channel = &pptp_channel;
++ modem = 0;
++}
+--- /dev/null
++++ b/pppd/plugins/pptp/pptp_callmgr.c
+@@ -0,0 +1,381 @@
++/* pptp_callmgr.c ... Call manager for PPTP connections.
++ * Handles TCP port 1723 protocol.
++ * C. Scott Ananian <cananian@alumni.princeton.edu>
++ *
++ * $Id: pptp_callmgr.c,v 1.20 2005/03/31 07:42:39 quozl Exp $
++ */
++#include <signal.h>
++#include <sys/time.h>
++#include <sys/types.h>
++#include <sys/stat.h>
++#include <sys/socket.h>
++#include <netinet/in.h>
++#include <arpa/inet.h>
++#include <sys/un.h>
++#include <unistd.h>
++#include <stdlib.h>
++#include <string.h>
++#include <assert.h>
++#include <setjmp.h>
++#include <stdio.h>
++#include <errno.h>
++#include "pptp_callmgr.h"
++#include "pptp_ctrl.h"
++#include "pptp_msg.h"
++#include "dirutil.h"
++#include "vector.h"
++#include "util.h"
++#include "pppd.h"
++
++extern struct in_addr localbind; /* from pptp.c */
++extern int call_ID;
++
++int open_inetsock(struct in_addr inetaddr);
++int open_unixsock(struct in_addr inetaddr);
++void close_inetsock(int fd, struct in_addr inetaddr);
++void close_unixsock(int fd, struct in_addr inetaddr);
++
++sigjmp_buf callmgr_env;
++
++void callmgr_sighandler(int sig) {
++ /* TODO: according to signal(2), siglongjmp() is unsafe used here */
++ siglongjmp (callmgr_env, 1);
++}
++
++void callmgr_do_nothing(int sig) {
++ /* do nothing signal handler */
++}
++
++struct local_callinfo {
++ int unix_sock;
++ pid_t pid[2];
++};
++
++struct local_conninfo {
++ VECTOR * call_list;
++ fd_set * call_set;
++};
++
++/* Call callback */
++void call_callback(PPTP_CONN *conn, PPTP_CALL *call, enum call_state state)
++{
++ struct local_callinfo *lci;
++ struct local_conninfo *conninfo;
++ u_int16_t call_id[2];
++ switch(state) {
++ case CALL_OPEN_DONE:
++ /* okey dokey. This means that the call_id and peer_call_id are
++ * now valid, so lets send them on to our friends who requested
++ * this call. */
++ lci = pptp_call_closure_get(conn, call); assert(lci != NULL);
++ pptp_call_get_ids(conn, call, &call_id[0], &call_id[1]);
++ write(lci->unix_sock, &call_id, sizeof(call_id));
++ /* Our duty to the fatherland is now complete. */
++ break;
++ case CALL_OPEN_FAIL:
++ case CALL_CLOSE_RQST:
++ case CALL_CLOSE_DONE:
++ /* don't need to do anything here, except make sure tables
++ * are sync'ed */
++ dbglog("Closing connection (call state)");
++ conninfo = pptp_conn_closure_get(conn);
++ lci = pptp_call_closure_get(conn, call);
++ assert(lci != NULL && conninfo != NULL);
++ if (vector_contains(conninfo->call_list, lci->unix_sock)) {
++ vector_remove(conninfo->call_list, lci->unix_sock);
++ close(lci->unix_sock);
++ FD_CLR(lci->unix_sock, conninfo->call_set);
++ }
++ break;
++ default:
++ dbglog("Unhandled call callback state [%d].", (int) state);
++ break;
++ }
++}
++
++/******************************************************************************
++ * NOTE ABOUT 'VOLATILE':
++ * several variables here get a volatile qualifier to silence warnings
++ * from older (before 3.0) gccs. if the longjmp stuff is removed,
++ * the volatile qualifiers should be removed as well.
++ *****************************************************************************/
++
++/*** Call Manager *************************************************************/
++int callmgr_main(struct in_addr inetaddr, char phonenr[], int window, int pcallid)
++{
++ int inet_sock, unix_sock;
++ fd_set call_set;
++ PPTP_CONN * conn;
++ VECTOR * call_list;
++ int max_fd = 0;
++ volatile int first = 1;
++ int retval;
++ int i;
++ if (pcallid>0) call_ID=pcallid;
++
++ /* Step 1: Open sockets. */
++ if ((inet_sock = open_inetsock(inetaddr)) < 0)
++ fatal("Could not open control connection to %s", inet_ntoa(inetaddr));
++ dbglog("control connection");
++ if ((unix_sock = open_unixsock(inetaddr)) < 0)
++ fatal("Could not open unix socket for %s", inet_ntoa(inetaddr));
++ /* Step 1b: FORK and return status to calling process. */
++ dbglog("unix_sock");
++
++ switch (fork()) {
++ case 0: /* child. stick around. */
++ break;
++ case -1: /* failure. Fatal. */
++ fatal("Could not fork.");
++ default: /* Parent. Return status to caller. */
++ exit(0);
++ }
++ /* re-open stderr as /dev/null to release it */
++ file2fd("/dev/null", "wb", STDERR_FILENO);
++ /* Step 1c: Clean up unix socket on TERM */
++ if (sigsetjmp(callmgr_env, 1) != 0)
++ goto cleanup;
++ signal(SIGINT, callmgr_sighandler);
++ signal(SIGTERM, callmgr_sighandler);
++ signal(SIGPIPE, callmgr_do_nothing);
++ signal(SIGUSR1, callmgr_do_nothing); /* signal state change
++ wake up accept */
++ /* Step 2: Open control connection and register callback */
++ if ((conn = pptp_conn_open(inet_sock, 1, NULL/* callback */)) == NULL) {
++ close(unix_sock); close(inet_sock); fatal("Could not open connection.");
++ }
++ FD_ZERO(&call_set);
++ call_list = vector_create();
++ {
++ struct local_conninfo *conninfo = malloc(sizeof(*conninfo));
++ if (conninfo == NULL) {
++ close(unix_sock); close(inet_sock); fatal("No memory.");
++ }
++ conninfo->call_list = call_list;
++ conninfo->call_set = &call_set;
++ pptp_conn_closure_put(conn, conninfo);
++ }
++ if (sigsetjmp(callmgr_env, 1) != 0) goto shutdown;
++ /* Step 3: Get FD_SETs */
++ max_fd = unix_sock;
++ do {
++ int rc;
++ fd_set read_set = call_set, write_set;
++ FD_ZERO (&write_set);
++ if (pptp_conn_established(conn)) {
++ FD_SET (unix_sock, &read_set);
++ if (unix_sock > max_fd) max_fd = unix_sock;
++ }
++ pptp_fd_set(conn, &read_set, &write_set, &max_fd);
++ for (; max_fd > 0 ; max_fd--) {
++ if (FD_ISSET (max_fd, &read_set) ||
++ FD_ISSET (max_fd, &write_set))
++ break;
++ }
++ /* Step 4: Wait on INET or UNIX event */
++ if ((rc = select(max_fd + 1, &read_set, &write_set, NULL, NULL)) <0) {
++ if (errno == EBADF) break;
++ /* a signal or somesuch. */
++ continue;
++ }
++ /* Step 5a: Handle INET events */
++ rc = pptp_dispatch(conn, &read_set, &write_set);
++ if (rc < 0)
++ break;
++ /* Step 5b: Handle new connection to UNIX socket */
++ if (FD_ISSET(unix_sock, &read_set)) {
++ /* New call! */
++ struct sockaddr_un from;
++ int len = sizeof(from);
++ PPTP_CALL * call;
++ struct local_callinfo *lci;
++ int s;
++ /* Accept the socket */
++ FD_CLR (unix_sock, &read_set);
++ if ((s = accept(unix_sock, (struct sockaddr *) &from, &len)) < 0) {
++ warn("Socket not accepted: %s", strerror(errno));
++ goto skip_accept;
++ }
++ /* Allocate memory for local call information structure. */
++ if ((lci = malloc(sizeof(*lci))) == NULL) {
++ warn("Out of memory."); close(s); goto skip_accept;
++ }
++ lci->unix_sock = s;
++ /* Give the initiator time to write the PIDs while we open
++ * the call */
++ call = pptp_call_open(conn, call_ID,call_callback, phonenr,window);
++ /* Read and store the associated pids */
++ read(s, &lci->pid[0], sizeof(lci->pid[0]));
++ read(s, &lci->pid[1], sizeof(lci->pid[1]));
++ /* associate the local information with the call */
++ pptp_call_closure_put(conn, call, (void *) lci);
++ /* The rest is done on callback. */
++ /* Keep alive; wait for close */
++ retval = vector_insert(call_list, s, call); assert(retval);
++ if (s > max_fd) max_fd = s;
++ FD_SET(s, &call_set);
++ first = 0;
++ }
++skip_accept: /* Step 5c: Handle socket close */
++ for (i = 0; i < max_fd + 1; i++)
++ if (FD_ISSET(i, &read_set)) {
++ /* close it */
++ PPTP_CALL * call;
++ retval = vector_search(call_list, i, &call);
++ if (retval) {
++ struct local_callinfo *lci =
++ pptp_call_closure_get(conn, call);
++ dbglog("Closing connection (unhandled)");
++ free(lci);
++ /* soft shutdown. Callback will do hard shutdown later */
++ pptp_call_close(conn, call);
++ vector_remove(call_list, i);
++ }
++ FD_CLR(i, &call_set);
++ close(i);
++ }
++ } while (vector_size(call_list) > 0 || first);
++shutdown:
++ {
++ int rc;
++ fd_set read_set, write_set;
++ struct timeval tv;
++ signal(SIGINT, callmgr_do_nothing);
++ signal(SIGTERM, callmgr_do_nothing);
++ /* warn("Shutdown"); */
++ /* kill all open calls */
++ for (i = 0; i < vector_size(call_list); i++) {
++ PPTP_CALL *call = vector_get_Nth(call_list, i);
++ dbglog("Closing connection (shutdown)");
++ pptp_call_close(conn, call);
++ }
++ /* attempt to dispatch these messages */
++ FD_ZERO(&read_set);
++ FD_ZERO(&write_set);
++ pptp_fd_set(conn, &read_set, &write_set, &max_fd);
++ tv.tv_sec = 0;
++ tv.tv_usec = 0;
++ select(max_fd + 1, &read_set, &write_set, NULL, &tv);
++ rc = pptp_dispatch(conn, &read_set, &write_set);
++ if (rc > 0) {
++ /* wait for a respond, a timeout because there might not be one */
++ FD_ZERO(&read_set);
++ FD_ZERO(&write_set);
++ pptp_fd_set(conn, &read_set, &write_set, &max_fd);
++ tv.tv_sec = 2;
++ tv.tv_usec = 0;
++ select(max_fd + 1, &read_set, &write_set, NULL, &tv);
++ rc = pptp_dispatch(conn, &read_set, &write_set);
++ if (rc > 0) {
++ if (i > 0) sleep(2);
++ /* no more open calls. Close the connection. */
++ pptp_conn_close(conn, PPTP_STOP_LOCAL_SHUTDOWN);
++ /* wait for a respond, a timeout because there might not be one */
++ FD_ZERO(&read_set);
++ FD_ZERO(&write_set);
++ pptp_fd_set(conn, &read_set, &write_set, &max_fd);
++ tv.tv_sec = 2;
++ tv.tv_usec = 0;
++ select(max_fd + 1, &read_set, &write_set, NULL, &tv);
++ pptp_dispatch(conn, &read_set, &write_set);
++ if (rc > 0) sleep(2);
++ }
++ }
++ /* with extreme prejudice */
++ pptp_conn_destroy(conn);
++ vector_destroy(call_list);
++ }
++cleanup:
++ signal(SIGINT, callmgr_do_nothing);
++ signal(SIGTERM, callmgr_do_nothing);
++ close_inetsock(inet_sock, inetaddr);
++ close_unixsock(unix_sock, inetaddr);
++ return 0;
++}
++
++/*** open_inetsock ************************************************************/
++int open_inetsock(struct in_addr inetaddr)
++{
++ struct sockaddr_in dest, src;
++ int s;
++ dest.sin_family = AF_INET;
++ dest.sin_port = htons(PPTP_PORT);
++ dest.sin_addr = inetaddr;
++ if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
++ warn("socket: %s", strerror(errno));
++ return s;
++ }
++ if (localbind.s_addr != INADDR_NONE) {
++ bzero(&src, sizeof(src));
++ src.sin_family = AF_INET;
++ src.sin_addr = localbind;
++ if (bind(s, (struct sockaddr *) &src, sizeof(src)) != 0) {
++ warn("bind: %s", strerror(errno));
++ close(s); return -1;
++ }
++ }
++ if (connect(s, (struct sockaddr *) &dest, sizeof(dest)) < 0) {
++ warn("connect: %s", strerror(errno));
++ close(s); return -1;
++ }
++ return s;
++}
++
++/*** open_unixsock ************************************************************/
++int open_unixsock(struct in_addr inetaddr)
++{
++ struct sockaddr_un where;
++ struct stat st;
++ char *dir;
++ int s;
++ if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
++ warn("socket: %s", strerror(errno));
++ return s;
++ }
++ callmgr_name_unixsock( &where, inetaddr, localbind);
++ if (stat(where.sun_path, &st) >= 0)
++ {
++ warn("Call manager for %s is already running.", inet_ntoa(inetaddr));
++ close(s); return -1;
++ }
++ /* Make sure path is valid. */
++ dir = dirnamex(where.sun_path);
++ if (!make_valid_path(dir, 0770))
++ fatal("Could not make path to %s: %s", where.sun_path, strerror(errno));
++ free(dir);
++ if (bind(s, (struct sockaddr *) &where, sizeof(where)) < 0) {
++ warn("bind: %s", strerror(errno));
++ close(s); return -1;
++ }
++ chmod(where.sun_path, 0777);
++ listen(s, 127);
++ return s;
++}
++
++/*** close_inetsock ***********************************************************/
++void close_inetsock(int fd, struct in_addr inetaddr)
++{
++ close(fd);
++}
++
++/*** close_unixsock ***********************************************************/
++void close_unixsock(int fd, struct in_addr inetaddr)
++{
++ struct sockaddr_un where;
++ close(fd);
++ callmgr_name_unixsock(&where, inetaddr, localbind);
++ unlink(where.sun_path);
++}
++
++/*** make a unix socket address ***********************************************/
++void callmgr_name_unixsock(struct sockaddr_un *where,
++ struct in_addr inetaddr,
++ struct in_addr localbind)
++{
++ char localaddr[16], remoteaddr[16];
++ where->sun_family = AF_UNIX;
++ strncpy(localaddr, inet_ntoa(localbind), 16);
++ strncpy(remoteaddr, inet_ntoa(inetaddr), 16);
++ snprintf(where->sun_path, sizeof(where->sun_path),
++ PPTP_SOCKET_PREFIX "%s:%i", remoteaddr,call_ID);
++}
+--- /dev/null
++++ b/pppd/plugins/pptp/pptp_callmgr.h
+@@ -0,0 +1,17 @@
++/* pptp_callmgr.h ... Call manager for PPTP connections.
++ * Handles TCP port 1723 protocol.
++ * C. Scott Ananian <cananian@alumni.princeton.edu>
++ *
++ * $Id: pptp_callmgr.h,v 1.3 2003/02/17 00:22:17 quozl Exp $
++ */
++
++#define PPTP_SOCKET_PREFIX "/var/run/pptp/"
++
++int callmgr_main(struct in_addr inetaddr,
++ char phonenr[],
++ int window,
++ int pcallid);
++
++void callmgr_name_unixsock(struct sockaddr_un *where,
++ struct in_addr inetaddr,
++ struct in_addr localbind);
+--- /dev/null
++++ b/pppd/plugins/pptp/pptp_ctrl.c
+@@ -0,0 +1,1077 @@
++/* pptp_ctrl.c ... handle PPTP control connection.
++ * C. Scott Ananian <cananian@alumni.princeton.edu>
++ *
++ * $Id: pptp_ctrl.c,v 1.31 2005/03/31 07:42:39 quozl Exp $
++ */
++
++#include <errno.h>
++#include <sys/time.h>
++#include <sys/types.h>
++#include <sys/socket.h>
++#include <netinet/in.h>
++#include <unistd.h>
++#include <stdlib.h>
++#include <assert.h>
++#include <signal.h>
++#include <string.h>
++#include <ctype.h>
++#include <fcntl.h>
++#include "pptp_msg.h"
++#include "pptp_ctrl.h"
++#include "pptp_options.h"
++#include "vector.h"
++#include "util.h"
++#include "pptp_quirks.h"
++
++/* BECAUSE OF SIGNAL LIMITATIONS, EACH PROCESS CAN ONLY MANAGE ONE
++ * CONNECTION. SO THIS 'PPTP_CONN' STRUCTURE IS A BIT MISLEADING.
++ * WE'LL KEEP CONNECTION-SPECIFIC INFORMATION IN THERE ANYWAY (AS
++ * OPPOSED TO USING GLOBAL VARIABLES), BUT BEWARE THAT THE ENTIRE
++ * UNIX SIGNAL-HANDLING SEMANTICS WOULD HAVE TO CHANGE (OR THE
++ * TIME-OUT CODE DRASTICALLY REWRITTEN) BEFORE YOU COULD DO A
++ * PPTP_CONN_OPEN MORE THAN ONCE PER PROCESS AND GET AWAY WITH IT.
++ */
++
++/* This structure contains connection-specific information that the
++ * signal handler needs to see. Thus, it needs to be in a global
++ * variable. If you end up using pthreads or something (why not
++ * just processes?), this would have to be placed in a thread-specific
++ * data area, using pthread_get|set_specific, etc., so I've
++ * conveniently encapsulated it for you.
++ * [linux threads will have to support thread-specific signals
++ * before this would work at all, which, as of this writing
++ * (linux-threads v0.6, linux kernel 2.1.72), it does not.]
++ */
++
++/* Globals */
++
++/* control the number of times echo packets will be logged */
++static int nlogecho = 10;
++
++static struct thread_specific {
++ struct sigaction old_sigaction; /* evil signals */
++ PPTP_CONN * conn;
++} global;
++
++#define INITIAL_BUFSIZE 512 /* initial i/o buffer size. */
++
++struct PPTP_CONN {
++ int inet_sock;
++ /* Connection States */
++ enum {
++ CONN_IDLE, CONN_WAIT_CTL_REPLY, CONN_WAIT_STOP_REPLY, CONN_ESTABLISHED
++ } conn_state; /* on startup: CONN_IDLE */
++ /* Keep-alive states */
++ enum {
++ KA_NONE, KA_OUTSTANDING
++ } ka_state; /* on startup: KA_NONE */
++ /* Keep-alive ID; monotonically increasing (watch wrap-around!) */
++ u_int32_t ka_id; /* on startup: 1 */
++ /* Other properties. */
++ u_int16_t version;
++ u_int16_t firmware_rev;
++ u_int8_t hostname[64], vendor[64];
++ /* XXX these are only PNS properties, currently XXX */
++ /* Call assignment information. */
++ u_int16_t call_serial_number;
++ VECTOR *call;
++ void * closure;
++ pptp_conn_cb callback;
++ /******* IO buffers ******/
++ char * read_buffer, *write_buffer;
++ size_t read_alloc, write_alloc;
++ size_t read_size, write_size;
++};
++
++struct PPTP_CALL {
++ /* Call properties */
++ enum {
++ PPTP_CALL_PAC, PPTP_CALL_PNS
++ } call_type;
++ union {
++ enum pptp_pac_state {
++ PAC_IDLE, PAC_WAIT_REPLY, PAC_ESTABLISHED, PAC_WAIT_CS_ANS
++ } pac;
++ enum pptp_pns_state {
++ PNS_IDLE, PNS_WAIT_REPLY, PNS_ESTABLISHED, PNS_WAIT_DISCONNECT
++ } pns;
++ } state;
++ u_int16_t call_id, peer_call_id;
++ u_int16_t sernum;
++ u_int32_t speed;
++ /* For user data: */
++ pptp_call_cb callback;
++ void * closure;
++};
++
++
++/* PPTP error codes: ----------------------------------------------*/
++
++/* (General Error Codes) */
++static const struct {
++ const char *name, *desc;
++} pptp_general_errors[] = {
++#define PPTP_GENERAL_ERROR_NONE 0
++ { "(None)", "No general error" },
++#define PPTP_GENERAL_ERROR_NOT_CONNECTED 1
++ { "(Not-Connected)", "No control connection exists yet for this "
++ "PAC-PNS pair" },
++#define PPTP_GENERAL_ERROR_BAD_FORMAT 2
++ { "(Bad-Format)", "Length is wrong or Magic Cookie value is incorrect" },
++#define PPTP_GENERAL_ERROR_BAD_VALUE 3
++ { "(Bad-Value)", "One of the field values was out of range or "
++ "reserved field was non-zero" },
++#define PPTP_GENERAL_ERROR_NO_RESOURCE 4
++ { "(No-Resource)", "Insufficient resources to handle this command now" },
++#define PPTP_GENERAL_ERROR_BAD_CALLID 5
++ { "(Bad-Call ID)", "The Call ID is invalid in this context" },
++#define PPTP_GENERAL_ERROR_PAC_ERROR 6
++ { "(PAC-Error)", "A generic vendor-specific error occured in the PAC" }
++};
++
++#define MAX_GENERAL_ERROR ( sizeof(pptp_general_errors) / \
++ sizeof(pptp_general_errors[0]) - 1)
++
++/* Outgoing Call Reply Result Codes */
++static const char *pptp_out_call_reply_result[] = {
++/* 0 */ "Unknown Result Code",
++/* 1 */ "Connected",
++/* 2 */ "General Error",
++/* 3 */ "No Carrier Detected",
++/* 4 */ "Busy Signal",
++/* 5 */ "No Dial Tone",
++/* 6 */ "Time Out",
++/* 7 */ "Not Accepted, Call is administratively prohibited" };
++
++#define MAX_OUT_CALL_REPLY_RESULT 7
++
++/* Call Disconnect Notify Result Codes */
++static const char *pptp_call_disc_ntfy[] = {
++/* 0 */ "Unknown Result Code",
++/* 1 */ "Lost Carrier",
++/* 2 */ "General Error",
++/* 3 */ "Administrative Shutdown",
++/* 4 */ "(your) Request" };
++
++#define MAX_CALL_DISC_NTFY 4
++
++/* Call Disconnect Notify Result Codes */
++static const char *pptp_start_ctrl_conn_rply[] = {
++/* 0 */ "Unknown Result Code",
++/* 1 */ "Successful Channel Establishment",
++/* 2 */ "General Error",
++/* 3 */ "Command Channel Already Exists",
++/* 4 */ "Requester is not Authorized" };
++
++#define MAX_START_CTRL_CONN_REPLY 4
++
++/* timing options */
++int idle_wait = PPTP_TIMEOUT;
++int max_echo_wait = PPTP_TIMEOUT;
++
++/* Local prototypes */
++static void pptp_reset_timer(void);
++static void pptp_handle_timer();
++/* Write/read as much as we can without blocking. */
++int pptp_write_some(PPTP_CONN * conn);
++int pptp_read_some(PPTP_CONN * conn);
++/* Make valid packets from read_buffer */
++int pptp_make_packet(PPTP_CONN * conn, void **buf, size_t *size);
++/* Add packet to write_buffer */
++int pptp_send_ctrl_packet(PPTP_CONN * conn, void * buffer, size_t size);
++/* Dispatch packets (general) */
++int pptp_dispatch_packet(PPTP_CONN * conn, void * buffer, size_t size);
++/* Dispatch packets (control messages) */
++int ctrlp_disp(PPTP_CONN * conn, void * buffer, size_t size);
++/* Set link info, for pptp servers that need it.
++ this is a noop, unless the user specified a quirk and
++ there's a set_link hook defined in the quirks table
++ for that quirk */
++void pptp_set_link(PPTP_CONN * conn, int peer_call_id);
++
++/*** log error information in control packets *********************************/
++static void ctrlp_error( int result, int error, int cause,
++ const char *result_text[], int max_result)
++{
++ if( cause >= 0)
++ warn("Result code is %d '%s'. Error code is %d, Cause code is %d",
++ result, result_text[result <= max_result ? result : 0], error,
++ cause );
++ else
++ warn("Reply result code is %d '%s'. Error code is %d",
++ result, result_text[result <= max_result ? result : 0], error);
++ if ((error > 0) && (error <= MAX_GENERAL_ERROR)){
++ if( result != PPTP_RESULT_GENERAL_ERROR )
++ warn("Result code is something else then \"general error\", "
++ "so the following error is probably bogus.");
++ warn("Error is '%s', Error message: '%s'",
++ pptp_general_errors[error].name,
++ pptp_general_errors[error].desc);
++ }
++}
++
++static const char *ctrl_msg_types[] = {
++ "invalid control message type",
++/* (Control Connection Management) */
++ "Start-Control-Connection-Request", /* 1 */
++ "Start-Control-Connection-Reply", /* 2 */
++ "Stop-Control-Connection-Request", /* 3 */
++ "Stop-Control-Connection-Reply", /* 4 */
++ "Echo-Request", /* 5 */
++ "Echo-Reply", /* 6 */
++/* (Call Management) */
++ "Outgoing-Call-Request", /* 7 */
++ "Outgoing-Call-Reply", /* 8 */
++ "Incoming-Call-Request", /* 9 */
++ "Incoming-Call-Reply", /* 10 */
++ "Incoming-Call-Connected", /* 11 */
++ "Call-Clear-Request", /* 12 */
++ "Call-Disconnect-Notify", /* 13 */
++/* (Error Reporting) */
++ "WAN-Error-Notify", /* 14 */
++/* (PPP Session Control) */
++ "Set-Link-Info" /* 15 */
++};
++#define MAX_CTRLMSG_TYPE 15
++
++/*** report a sent packet ****************************************************/
++static void ctrlp_rep( void * buffer, int size, int isbuff)
++{
++ struct pptp_header *packet = buffer;
++ unsigned int type;
++ if(size < sizeof(struct pptp_header)) return;
++ type = ntoh16(packet->ctrl_type);
++ /* FIXME: do not report sending echo requests as long as they are
++ * sent in a signal handler. This may dead lock as the syslog call
++ * is not reentrant */
++ if( type == PPTP_ECHO_RQST ) return;
++ /* don't keep reporting sending of echo's */
++ if( (type == PPTP_ECHO_RQST || type == PPTP_ECHO_RPLY) && nlogecho <= 0 ) return;
++ dbglog("%s control packet type is %d '%s'\n",isbuff ? "Buffered" : "Sent",
++ type, ctrl_msg_types[type <= MAX_CTRLMSG_TYPE ? type : 0]);
++
++}
++
++
++
++/* Open new pptp_connection. Returns NULL on failure. */
++PPTP_CONN * pptp_conn_open(int inet_sock, int isclient, pptp_conn_cb callback)
++{
++ PPTP_CONN *conn;
++ /* Allocate structure */
++ if ((conn = malloc(sizeof(*conn))) == NULL) return NULL;
++ if ((conn->call = vector_create()) == NULL) { free(conn); return NULL; }
++ /* Initialize */
++ conn->inet_sock = inet_sock;
++ conn->conn_state = CONN_IDLE;
++ conn->ka_state = KA_NONE;
++ conn->ka_id = 1;
++ conn->call_serial_number = 0;
++ conn->callback = callback;
++ /* Create I/O buffers */
++ conn->read_size = conn->write_size = 0;
++ conn->read_alloc = conn->write_alloc = INITIAL_BUFSIZE;
++ conn->read_buffer =
++ malloc(sizeof(*(conn->read_buffer)) * conn->read_alloc);
++ conn->write_buffer =
++ malloc(sizeof(*(conn->write_buffer)) * conn->write_alloc);
++ if (conn->read_buffer == NULL || conn->write_buffer == NULL) {
++ if (conn->read_buffer != NULL) free(conn->read_buffer);
++ if (conn->write_buffer != NULL) free(conn->write_buffer);
++ vector_destroy(conn->call); free(conn); return NULL;
++ }
++ /* Make this socket non-blocking. */
++ fcntl(conn->inet_sock, F_SETFL, O_NONBLOCK);
++ /* Request connection from server, if this is a client */
++ if (isclient) {
++ struct pptp_start_ctrl_conn packet = {
++ PPTP_HEADER_CTRL(PPTP_START_CTRL_CONN_RQST),
++ hton16(PPTP_VERSION), 0, 0,
++ hton32(PPTP_FRAME_CAP), hton32(PPTP_BEARER_CAP),
++ hton16(PPTP_MAX_CHANNELS), hton16(PPTP_FIRMWARE_VERSION),
++ PPTP_HOSTNAME, PPTP_VENDOR
++ };
++ /* fix this packet, if necessary */
++ int idx, rc;
++ idx = get_quirk_index();
++ if (idx != -1 && pptp_fixups[idx].start_ctrl_conn) {
++ if ((rc = pptp_fixups[idx].start_ctrl_conn(&packet)))
++ warn("calling the start_ctrl_conn hook failed (%d)", rc);
++ }
++ if (pptp_send_ctrl_packet(conn, &packet, sizeof(packet)))
++ conn->conn_state = CONN_WAIT_CTL_REPLY;
++ else
++ return NULL; /* could not send initial start request. */
++ }
++ /* Set up interval/keep-alive timer */
++ /* First, register handler for SIGALRM */
++ sigpipe_create();
++ sigpipe_assign(SIGALRM);
++ global.conn = conn;
++ /* Reset event timer */
++ pptp_reset_timer();
++ /* all done. */
++ return conn;
++}
++
++int pptp_conn_established(PPTP_CONN *conn) {
++ return (conn->conn_state == CONN_ESTABLISHED);
++}
++
++/* This currently *only* works for client call requests.
++ * We need to do something else to allocate calls for incoming requests.
++ */
++PPTP_CALL * pptp_call_open(PPTP_CONN * conn, int call_id,pptp_call_cb callback,
++ char *phonenr,int window)
++{
++ PPTP_CALL * call;
++ int idx, rc;
++ /* Send off the call request */
++ struct pptp_out_call_rqst packet = {
++ PPTP_HEADER_CTRL(PPTP_OUT_CALL_RQST),
++ 0,0, /*call_id, sernum */
++ hton32(PPTP_BPS_MIN), hton32(PPTP_BPS_MAX),
++ hton32(PPTP_BEARER_CAP), hton32(PPTP_FRAME_CAP),
++ hton16(window), 0, 0, 0, {0}, {0}
++ };
++ assert(conn && conn->call);
++ assert(conn->conn_state == CONN_ESTABLISHED);
++ /* Assign call id */
++ if (!call_id && !vector_scan(conn->call, 0, PPTP_MAX_CHANNELS - 1, &call_id))
++ /* no more calls available! */
++ return NULL;
++ /* allocate structure. */
++ if ((call = malloc(sizeof(*call))) == NULL) return NULL;
++ /* Initialize call structure */
++ call->call_type = PPTP_CALL_PNS;
++ call->state.pns = PNS_IDLE;
++ call->call_id = (u_int16_t) call_id;
++ call->sernum = conn->call_serial_number++;
++ call->callback = callback;
++ call->closure = NULL;
++ packet.call_id = htons(call->call_id);
++ packet.call_sernum = htons(call->sernum);
++ /* if we have a quirk, build a new packet to fit it */
++ idx = get_quirk_index();
++ if (idx != -1 && pptp_fixups[idx].out_call_rqst_hook) {
++ if ((rc = pptp_fixups[idx].out_call_rqst_hook(&packet)))
++ warn("calling the out_call_rqst hook failed (%d)", rc);
++ }
++ /* fill in the phone number if it was specified */
++ if (phonenr) {
++ strncpy(packet.phone_num, phonenr, sizeof(packet.phone_num));
++ packet.phone_len = strlen(phonenr);
++ if( packet.phone_len > sizeof(packet.phone_num))
++ packet.phone_len = sizeof(packet.phone_num);
++ packet.phone_len = hton16 (packet.phone_len);
++ }
++ if (pptp_send_ctrl_packet(conn, &packet, sizeof(packet))) {
++ pptp_reset_timer();
++ call->state.pns = PNS_WAIT_REPLY;
++ /* and add it to the call vector */
++ vector_insert(conn->call, call_id, call);
++ return call;
++ } else { /* oops, unsuccessful. Deallocate. */
++ free(call);
++ return NULL;
++ }
++}
++
++/*** pptp_call_close **********************************************************/
++void pptp_call_close(PPTP_CONN * conn, PPTP_CALL * call)
++{
++ struct pptp_call_clear_rqst rqst = {
++ PPTP_HEADER_CTRL(PPTP_CALL_CLEAR_RQST), 0, 0
++ };
++ assert(conn && conn->call); assert(call);
++ assert(vector_contains(conn->call, call->call_id));
++ /* haven't thought about PAC yet */
++ assert(call->call_type == PPTP_CALL_PNS);
++ assert(call->state.pns != PNS_IDLE);
++ rqst.call_id = hton16(call->call_id);
++ /* don't check state against WAIT_DISCONNECT... allow multiple disconnect
++ * requests to be made.
++ */
++ pptp_send_ctrl_packet(conn, &rqst, sizeof(rqst));
++ pptp_reset_timer();
++ call->state.pns = PNS_WAIT_DISCONNECT;
++ /* call structure will be freed when we have confirmation of disconnect. */
++}
++
++/*** hard close ***************************************************************/
++void pptp_call_destroy(PPTP_CONN *conn, PPTP_CALL *call)
++{
++ assert(conn && conn->call); assert(call);
++ assert(vector_contains(conn->call, call->call_id));
++ /* notify */
++ if (call->callback != NULL) call->callback(conn, call, CALL_CLOSE_DONE);
++ /* deallocate */
++ vector_remove(conn->call, call->call_id);
++ free(call);
++}
++
++/*** this is a soft close *****************************************************/
++void pptp_conn_close(PPTP_CONN * conn, u_int8_t close_reason)
++{
++ struct pptp_stop_ctrl_conn rqst = {
++ PPTP_HEADER_CTRL(PPTP_STOP_CTRL_CONN_RQST),
++ hton8(close_reason), 0, 0
++ };
++ int i;
++ assert(conn && conn->call);
++ /* avoid repeated close attempts */
++ if (conn->conn_state == CONN_IDLE || conn->conn_state == CONN_WAIT_STOP_REPLY)
++ return;
++ /* close open calls, if any */
++ for (i = 0; i < vector_size(conn->call); i++)
++ pptp_call_close(conn, vector_get_Nth(conn->call, i));
++ /* now close connection */
++ info("Closing PPTP connection");
++ pptp_send_ctrl_packet(conn, &rqst, sizeof(rqst));
++ pptp_reset_timer(); /* wait 60 seconds for reply */
++ conn->conn_state = CONN_WAIT_STOP_REPLY;
++ return;
++}
++
++/*** this is a hard close *****************************************************/
++void pptp_conn_destroy(PPTP_CONN * conn)
++{
++ int i;
++ assert(conn != NULL); assert(conn->call != NULL);
++ /* destroy all open calls */
++ for (i = 0; i < vector_size(conn->call); i++)
++ pptp_call_destroy(conn, vector_get_Nth(conn->call, i));
++ /* notify */
++ if (conn->callback != NULL) conn->callback(conn, CONN_CLOSE_DONE);
++ sigpipe_close();
++ close(conn->inet_sock);
++ /* deallocate */
++ vector_destroy(conn->call);
++ free(conn);
++}
++
++/*** Deal with messages, in a non-blocking manner
++ * Add file descriptors used by pptp to fd_set.
++ */
++void pptp_fd_set(PPTP_CONN * conn, fd_set * read_set, fd_set * write_set,
++ int * max_fd)
++{
++ assert(conn && conn->call);
++ /* Add fd to write_set if there are outstanding writes. */
++ if (conn->write_size > 0)
++ FD_SET(conn->inet_sock, write_set);
++ /* Always add fd to read_set. (always want something to read) */
++ FD_SET(conn->inet_sock, read_set);
++ if (*max_fd < conn->inet_sock) *max_fd = conn->inet_sock;
++ /* Add signal pipe file descriptor to set */
++ int sig_fd = sigpipe_fd();
++ FD_SET(sig_fd, read_set);
++ if (*max_fd < sig_fd) *max_fd = sig_fd;
++}
++
++/*** handle any pptp file descriptors set in fd_set, and clear them ***********/
++int pptp_dispatch(PPTP_CONN * conn, fd_set * read_set, fd_set * write_set)
++{
++ int r = 0;
++ assert(conn && conn->call);
++ /* Check for signals */
++ if (FD_ISSET(sigpipe_fd(), read_set)) {
++ if (sigpipe_read() == SIGALRM) pptp_handle_timer();
++ FD_CLR(sigpipe_fd(), read_set);
++ }
++ /* Check write_set could be set. */
++ if (FD_ISSET(conn->inet_sock, write_set)) {
++ FD_CLR(conn->inet_sock, write_set);
++ if (conn->write_size > 0)
++ r = pptp_write_some(conn);/* write as much as we can without blocking */
++ }
++ /* Check read_set */
++ if (r >= 0 && FD_ISSET(conn->inet_sock, read_set)) {
++ void *buffer; size_t size;
++ FD_CLR(conn->inet_sock, read_set);
++ r = pptp_read_some(conn); /* read as much as we can without blocking */
++ if (r < 0)
++ return r;
++ /* make packets of the buffer, while we can. */
++ while (r >= 0 && pptp_make_packet(conn, &buffer, &size)) {
++ r = pptp_dispatch_packet(conn, buffer, size);
++ free(buffer);
++ }
++ }
++ /* That's all, folks. Simple, eh? */
++ return r;
++}
++
++/*** Non-blocking write *******************************************************/
++int pptp_write_some(PPTP_CONN * conn) {
++ ssize_t retval;
++ assert(conn && conn->call);
++ retval = write(conn->inet_sock, conn->write_buffer, conn->write_size);
++ if (retval < 0) { /* error. */
++ if (errno == EAGAIN || errno == EINTR) {
++ return 0;
++ } else { /* a real error */
++ warn("write error: %s", strerror(errno));
++ return -1;
++ }
++ }
++ assert(retval <= conn->write_size);
++ conn->write_size -= retval;
++ memmove(conn->write_buffer, conn->write_buffer + retval, conn->write_size);
++ ctrlp_rep(conn->write_buffer, retval, 0);
++ return 0;
++}
++
++/*** Non-blocking read ********************************************************/
++int pptp_read_some(PPTP_CONN * conn)
++{
++ ssize_t retval;
++ assert(conn && conn->call);
++ if (conn->read_size == conn->read_alloc) { /* need to alloc more memory */
++ char *new_buffer = realloc(conn->read_buffer,
++ sizeof(*(conn->read_buffer)) * conn->read_alloc * 2);
++ if (new_buffer == NULL) {
++ warn("Out of memory"); return -1;
++ }
++ conn->read_alloc *= 2;
++ conn->read_buffer = new_buffer;
++ }
++ retval = read(conn->inet_sock, conn->read_buffer + conn->read_size,
++ conn->read_alloc - conn->read_size);
++ if (retval == 0) {
++ warn("read returned zero, peer has closed");
++ return -1;
++ }
++ if (retval < 0) {
++ if (errno == EINTR || errno == EAGAIN)
++ return 0;
++ else { /* a real error */
++ warn("read error: %s", strerror(errno));
++ return -1;
++ }
++ }
++ conn->read_size += retval;
++ assert(conn->read_size <= conn->read_alloc);
++ return 0;
++}
++
++/*** Packet formation *********************************************************/
++int pptp_make_packet(PPTP_CONN * conn, void **buf, size_t *size)
++{
++ struct pptp_header *header;
++ size_t bad_bytes = 0;
++ assert(conn && conn->call); assert(buf != NULL); assert(size != NULL);
++ /* Give up unless there are at least sizeof(pptp_header) bytes */
++ while ((conn->read_size-bad_bytes) >= sizeof(struct pptp_header)) {
++ /* Throw out bytes until we have a valid header. */
++ header = (struct pptp_header *) (conn->read_buffer + bad_bytes);
++ if (ntoh32(header->magic) != PPTP_MAGIC) goto throwitout;
++ if (ntoh16(header->reserved0) != 0)
++ warn("reserved0 field is not zero! (0x%x) Cisco feature? \n",
++ ntoh16(header->reserved0));
++ if (ntoh16(header->length) < sizeof(struct pptp_header)) goto throwitout;
++ if (ntoh16(header->length) > PPTP_CTRL_SIZE_MAX) goto throwitout;
++ /* well. I guess it's good. Let's see if we've got it all. */
++ if (ntoh16(header->length) > (conn->read_size-bad_bytes))
++ /* nope. Let's wait until we've got it, then. */
++ goto flushbadbytes;
++ /* One last check: */
++ if ((ntoh16(header->pptp_type) == PPTP_MESSAGE_CONTROL) &&
++ (ntoh16(header->length) !=
++ PPTP_CTRL_SIZE(ntoh16(header->ctrl_type))))
++ goto throwitout;
++ /* well, I guess we've got it. */
++ *size = ntoh16(header->length);
++ *buf = malloc(*size);
++ if (*buf == NULL) { warn("Out of memory."); return 0; /* ack! */ }
++ memcpy(*buf, conn->read_buffer + bad_bytes, *size);
++ /* Delete this packet from the read_buffer. */
++ conn->read_size -= (bad_bytes + *size);
++ memmove(conn->read_buffer, conn->read_buffer + bad_bytes + *size,
++ conn->read_size);
++ if (bad_bytes > 0)
++ warn("%lu bad bytes thrown away.", (unsigned long) bad_bytes);
++ return 1;
++throwitout:
++ bad_bytes++;
++ }
++flushbadbytes:
++ /* no more packets. Let's get rid of those bad bytes */
++ conn->read_size -= bad_bytes;
++ memmove(conn->read_buffer, conn->read_buffer + bad_bytes, conn->read_size);
++ if (bad_bytes > 0)
++ warn("%lu bad bytes thrown away.", (unsigned long) bad_bytes);
++ return 0;
++}
++
++/*** pptp_send_ctrl_packet ****************************************************/
++int pptp_send_ctrl_packet(PPTP_CONN * conn, void * buffer, size_t size)
++{
++ assert(conn && conn->call); assert(buffer);
++ if( conn->write_size > 0) pptp_write_some( conn);
++ if( conn->write_size == 0) {
++ ssize_t retval;
++ retval = write(conn->inet_sock, buffer, size);
++ if (retval < 0) { /* error. */
++ if (errno == EAGAIN || errno == EINTR) {
++ /* ignore */;
++ retval = 0;
++ } else { /* a real error */
++ warn("write error: %s", strerror(errno));
++ pptp_conn_destroy(conn); /* shut down fast. */
++ return 0;
++ }
++ }
++ ctrlp_rep( buffer, retval, 0);
++ size -= retval;
++ if( size <= 0) return 1;
++ }
++ /* Shove anything not written into the write buffer */
++ if (conn->write_size + size > conn->write_alloc) { /* need more memory */
++ char *new_buffer = realloc(conn->write_buffer,
++ sizeof(*(conn->write_buffer)) * conn->write_alloc * 2);
++ if (new_buffer == NULL) {
++ warn("Out of memory"); return 0;
++ }
++ conn->write_alloc *= 2;
++ conn->write_buffer = new_buffer;
++ }
++ memcpy(conn->write_buffer + conn->write_size, buffer, size);
++ conn->write_size += size;
++ ctrlp_rep( buffer,size,1);
++ return 1;
++}
++
++/*** Packet Dispatch **********************************************************/
++int pptp_dispatch_packet(PPTP_CONN * conn, void * buffer, size_t size)
++{
++ int r = 0;
++ struct pptp_header *header = (struct pptp_header *)buffer;
++ assert(conn && conn->call); assert(buffer);
++ assert(ntoh32(header->magic) == PPTP_MAGIC);
++ assert(ntoh16(header->length) == size);
++ switch (ntoh16(header->pptp_type)) {
++ case PPTP_MESSAGE_CONTROL:
++ r = ctrlp_disp(conn, buffer, size);
++ break;
++ case PPTP_MESSAGE_MANAGE:
++ /* MANAGEMENT messages aren't even part of the spec right now. */
++ dbglog("PPTP management message received, but not understood.");
++ break;
++ default:
++ dbglog("Unknown PPTP control message type received: %u",
++ (unsigned int) ntoh16(header->pptp_type));
++ break;
++ }
++ return r;
++}
++
++/*** log echo request/replies *************************************************/
++static void logecho( int type)
++{
++ /* hack to stop flooding the log files (the most interesting part is right
++ * after the connection built-up) */
++ if( nlogecho > 0) {
++ dbglog("Echo Re%s received.", type == PPTP_ECHO_RQST ? "quest" :"ply");
++ if( --nlogecho == 0)
++ dbglog("no more Echo Reply/Request packets will be reported.");
++ }
++}
++
++/*** pptp_dispatch_ctrl_packet ************************************************/
++int ctrlp_disp(PPTP_CONN * conn, void * buffer, size_t size)
++{
++ struct pptp_header *header = (struct pptp_header *)buffer;
++ u_int8_t close_reason = PPTP_STOP_NONE;
++ assert(conn && conn->call); assert(buffer);
++ assert(ntoh32(header->magic) == PPTP_MAGIC);
++ assert(ntoh16(header->length) == size);
++ assert(ntoh16(header->pptp_type) == PPTP_MESSAGE_CONTROL);
++ if (size < PPTP_CTRL_SIZE(ntoh16(header->ctrl_type))) {
++ warn("Invalid packet received [type: %d; length: %d].",
++ (int) ntoh16(header->ctrl_type), (int) size);
++ return 0;
++ }
++ switch (ntoh16(header->ctrl_type)) {
++ /* ----------- STANDARD Start-Session MESSAGES ------------ */
++ case PPTP_START_CTRL_CONN_RQST:
++ {
++ struct pptp_start_ctrl_conn *packet =
++ (struct pptp_start_ctrl_conn *) buffer;
++ struct pptp_start_ctrl_conn reply = {
++ PPTP_HEADER_CTRL(PPTP_START_CTRL_CONN_RPLY),
++ hton16(PPTP_VERSION), 0, 0,
++ hton32(PPTP_FRAME_CAP), hton32(PPTP_BEARER_CAP),
++ hton16(PPTP_MAX_CHANNELS), hton16(PPTP_FIRMWARE_VERSION),
++ PPTP_HOSTNAME, PPTP_VENDOR };
++ int idx, rc;
++ dbglog("Received Start Control Connection Request");
++ /* fix this packet, if necessary */
++ idx = get_quirk_index();
++ if (idx != -1 && pptp_fixups[idx].start_ctrl_conn) {
++ if ((rc = pptp_fixups[idx].start_ctrl_conn(&reply)))
++ warn("calling the start_ctrl_conn hook failed (%d)", rc);
++ }
++ if (conn->conn_state == CONN_IDLE) {
++ if (ntoh16(packet->version) < PPTP_VERSION) {
++ /* Can't support this (earlier) PPTP_VERSION */
++ reply.version = packet->version;
++ /* protocol version not supported */
++ reply.result_code = hton8(5);
++ pptp_send_ctrl_packet(conn, &reply, sizeof(reply));
++ pptp_reset_timer(); /* give sender a chance for a retry */
++ } else { /* same or greater version */
++ if (pptp_send_ctrl_packet(conn, &reply, sizeof(reply))) {
++ conn->conn_state = CONN_ESTABLISHED;
++ dbglog("server connection ESTABLISHED.");
++ pptp_reset_timer();
++ }
++ }
++ }
++ break;
++ }
++ case PPTP_START_CTRL_CONN_RPLY:
++ {
++ struct pptp_start_ctrl_conn *packet =
++ (struct pptp_start_ctrl_conn *) buffer;
++ dbglog("Received Start Control Connection Reply");
++ if (conn->conn_state == CONN_WAIT_CTL_REPLY) {
++ /* XXX handle collision XXX [see rfc] */
++ if (ntoh16(packet->version) != PPTP_VERSION) {
++ if (conn->callback != NULL)
++ conn->callback(conn, CONN_OPEN_FAIL);
++ close_reason = PPTP_STOP_PROTOCOL;
++ goto pptp_conn_close;
++ }
++ if (ntoh8(packet->result_code) != 1 &&
++ /* J'ai change le if () afin que la connection ne se ferme
++ * pas pour un "rien" :p adel@cybercable.fr -
++ *
++ * Don't close the connection if the result code is zero
++ * (feature found in certain ADSL modems)
++ */
++ ntoh8(packet->result_code) != 0) {
++ dbglog("Negative reply received to our Start Control "
++ "Connection Request");
++ ctrlp_error(packet->result_code, packet->error_code,
++ -1, pptp_start_ctrl_conn_rply,
++ MAX_START_CTRL_CONN_REPLY);
++ if (conn->callback != NULL)
++ conn->callback(conn, CONN_OPEN_FAIL);
++ close_reason = PPTP_STOP_PROTOCOL;
++ goto pptp_conn_close;
++ }
++ conn->conn_state = CONN_ESTABLISHED;
++ /* log session properties */
++ conn->version = ntoh16(packet->version);
++ conn->firmware_rev = ntoh16(packet->firmware_rev);
++ memcpy(conn->hostname, packet->hostname, sizeof(conn->hostname));
++ memcpy(conn->vendor, packet->vendor, sizeof(conn->vendor));
++ pptp_reset_timer(); /* 60 seconds until keep-alive */
++ dbglog("Client connection established.");
++ if (conn->callback != NULL)
++ conn->callback(conn, CONN_OPEN_DONE);
++ } /* else goto pptp_conn_close; */
++ break;
++ }
++ /* ----------- STANDARD Stop-Session MESSAGES ------------ */
++ case PPTP_STOP_CTRL_CONN_RQST:
++ {
++ /* conn_state should be CONN_ESTABLISHED, but it could be
++ * something else */
++ struct pptp_stop_ctrl_conn reply = {
++ PPTP_HEADER_CTRL(PPTP_STOP_CTRL_CONN_RPLY),
++ hton8(1), hton8(PPTP_GENERAL_ERROR_NONE), 0
++ };
++ dbglog("Received Stop Control Connection Request.");
++ if (conn->conn_state == CONN_IDLE) break;
++ if (pptp_send_ctrl_packet(conn, &reply, sizeof(reply))) {
++ if (conn->callback != NULL)
++ conn->callback(conn, CONN_CLOSE_RQST);
++ conn->conn_state = CONN_IDLE;
++ return -1;
++ }
++ break;
++ }
++ case PPTP_STOP_CTRL_CONN_RPLY:
++ {
++ dbglog("Received Stop Control Connection Reply.");
++ /* conn_state should be CONN_WAIT_STOP_REPLY, but it
++ * could be something else */
++ if (conn->conn_state == CONN_IDLE) break;
++ conn->conn_state = CONN_IDLE;
++ return -1;
++ }
++ /* ----------- STANDARD Echo/Keepalive MESSAGES ------------ */
++ case PPTP_ECHO_RPLY:
++ {
++ struct pptp_echo_rply *packet =
++ (struct pptp_echo_rply *) buffer;
++ logecho( PPTP_ECHO_RPLY);
++ if ((conn->ka_state == KA_OUTSTANDING) &&
++ (ntoh32(packet->identifier) == conn->ka_id)) {
++ conn->ka_id++;
++ conn->ka_state = KA_NONE;
++ pptp_reset_timer();
++ }
++ break;
++ }
++ case PPTP_ECHO_RQST:
++ {
++ struct pptp_echo_rqst *packet =
++ (struct pptp_echo_rqst *) buffer;
++ struct pptp_echo_rply reply = {
++ PPTP_HEADER_CTRL(PPTP_ECHO_RPLY),
++ packet->identifier, /* skip hton32(ntoh32(id)) */
++ hton8(1), hton8(PPTP_GENERAL_ERROR_NONE), 0
++ };
++ logecho( PPTP_ECHO_RQST);
++ pptp_send_ctrl_packet(conn, &reply, sizeof(reply));
++ pptp_reset_timer();
++ break;
++ }
++ /* ----------- OUTGOING CALL MESSAGES ------------ */
++ case PPTP_OUT_CALL_RQST:
++ {
++ struct pptp_out_call_rqst *packet =
++ (struct pptp_out_call_rqst *)buffer;
++ struct pptp_out_call_rply reply = {
++ PPTP_HEADER_CTRL(PPTP_OUT_CALL_RPLY),
++ 0 /* callid */, packet->call_id, 1, PPTP_GENERAL_ERROR_NONE, 0,
++ hton32(PPTP_CONNECT_SPEED),
++ hton16(PPTP_WINDOW), hton16(PPTP_DELAY), 0
++ };
++ dbglog("Received Outgoing Call Request.");
++ /* XXX PAC: eventually this should make an outgoing call. XXX */
++ reply.result_code = hton8(7); /* outgoing calls verboten */
++ pptp_send_ctrl_packet(conn, &reply, sizeof(reply));
++ break;
++ }
++ case PPTP_OUT_CALL_RPLY:
++ {
++ struct pptp_out_call_rply *packet =
++ (struct pptp_out_call_rply *)buffer;
++ PPTP_CALL * call;
++ u_int16_t callid = ntoh16(packet->call_id_peer);
++ dbglog("Received Outgoing Call Reply.");
++ if (!vector_search(conn->call, (int) callid, &call)) {
++ dbglog("PPTP_OUT_CALL_RPLY received for non-existant call: "
++ "peer call ID (us) %d call ID (them) %d.",
++ callid, ntoh16(packet->call_id));
++ break;
++ }
++ if (call->call_type != PPTP_CALL_PNS) {
++ dbglog("Ack! How did this call_type get here?"); /* XXX? */
++ break;
++ }
++ if (call->state.pns != PNS_WAIT_REPLY) {
++ warn("Unexpected(?) Outgoing Call Reply will be ignored.");
++ break;
++ }
++ /* check for errors */
++ if (packet->result_code != 1) {
++ /* An error. Log it verbosely. */
++ dbglog("Our outgoing call request [callid %d] has not been "
++ "accepted.", (int) callid);
++ ctrlp_error(packet->result_code, packet->error_code,
++ packet->cause_code, pptp_out_call_reply_result,
++ MAX_OUT_CALL_REPLY_RESULT);
++ call->state.pns = PNS_IDLE;
++ if (call->callback != NULL)
++ call->callback(conn, call, CALL_OPEN_FAIL);
++ pptp_call_destroy(conn, call);
++ } else {
++ /* connection established */
++ call->state.pns = PNS_ESTABLISHED;
++ call->peer_call_id = ntoh16(packet->call_id);
++ call->speed = ntoh32(packet->speed);
++ pptp_reset_timer();
++ /* call pptp_set_link. unless the user specified a quirk
++ and this quirk has a set_link hook, this is a noop */
++ pptp_set_link(conn, call->peer_call_id);
++ if (call->callback != NULL)
++ call->callback(conn, call, CALL_OPEN_DONE);
++ dbglog("Outgoing call established (call ID %u, peer's "
++ "call ID %u).\n", call->call_id, call->peer_call_id);
++ }
++ break;
++ }
++ /* ----------- INCOMING CALL MESSAGES ------------ */
++ /* XXX write me XXX */
++ /* ----------- CALL CONTROL MESSAGES ------------ */
++ case PPTP_CALL_CLEAR_RQST:
++ {
++ struct pptp_call_clear_rqst *packet =
++ (struct pptp_call_clear_rqst *)buffer;
++ struct pptp_call_clear_ntfy reply = {
++ PPTP_HEADER_CTRL(PPTP_CALL_CLEAR_NTFY), packet->call_id,
++ 1, PPTP_GENERAL_ERROR_NONE, 0, 0, {0}
++ };
++ dbglog("Received Call Clear Request.");
++ if (vector_contains(conn->call, ntoh16(packet->call_id))) {
++ PPTP_CALL * call;
++ vector_search(conn->call, ntoh16(packet->call_id), &call);
++ if (call->callback != NULL)
++ call->callback(conn, call, CALL_CLOSE_RQST);
++ pptp_send_ctrl_packet(conn, &reply, sizeof(reply));
++ pptp_call_destroy(conn, call);
++ dbglog("Call closed (RQST) (call id %d)", (int) call->call_id);
++ }
++ break;
++ }
++ case PPTP_CALL_CLEAR_NTFY:
++ {
++ struct pptp_call_clear_ntfy *packet =
++ (struct pptp_call_clear_ntfy *)buffer;
++ dbglog("Call disconnect notification received (call id %d)",
++ ntoh16(packet->call_id));
++ if (vector_contains(conn->call, ntoh16(packet->call_id))) {
++ PPTP_CALL * call;
++ ctrlp_error(packet->result_code, packet->error_code,
++ packet->cause_code, pptp_call_disc_ntfy,
++ MAX_CALL_DISC_NTFY);
++ vector_search(conn->call, ntoh16(packet->call_id), &call);
++ pptp_call_destroy(conn, call);
++ }
++ /* XXX we could log call stats here XXX */
++ /* XXX not all servers send this XXX */
++ break;
++ }
++ case PPTP_SET_LINK_INFO:
++ {
++ /* I HAVE NO CLUE WHAT TO DO IF send_accm IS NOT 0! */
++ /* this is really dealt with in the HDLC deencapsulation, anyway. */
++ struct pptp_set_link_info *packet =
++ (struct pptp_set_link_info *)buffer;
++ /* log it. */
++ dbglog("PPTP_SET_LINK_INFO received from peer_callid %u",
++ (unsigned int) ntoh16(packet->call_id_peer));
++ dbglog(" send_accm is %08lX, recv_accm is %08lX",
++ (unsigned long) ntoh32(packet->send_accm),
++ (unsigned long) ntoh32(packet->recv_accm));
++ if (!(ntoh32(packet->send_accm) == 0 &&
++ ntoh32(packet->recv_accm) == 0))
++ warn("Non-zero Async Control Character Maps are not supported!");
++ break;
++ }
++ default:
++ dbglog("Unrecognized Packet %d received.",
++ (int) ntoh16(((struct pptp_header *)buffer)->ctrl_type));
++ /* goto pptp_conn_close; */
++ break;
++ }
++ return 0;
++pptp_conn_close:
++ warn("pptp_conn_close(%d)", (int) close_reason);
++ pptp_conn_close(conn, close_reason);
++ return 0;
++}
++
++/*** pptp_set_link **************************************************************/
++void pptp_set_link(PPTP_CONN* conn, int peer_call_id)
++{
++ int idx, rc;
++ /* if we need to send a set_link packet because of buggy
++ hardware or pptp server, do it now */
++ if ((idx = get_quirk_index()) != -1 && pptp_fixups[idx].set_link_hook) {
++ struct pptp_set_link_info packet;
++ if ((rc = pptp_fixups[idx].set_link_hook(&packet, peer_call_id)))
++ warn("calling the set_link hook failed (%d)", rc);
++ if (pptp_send_ctrl_packet(conn, &packet, sizeof(packet))) {
++ pptp_reset_timer();
++ }
++ }
++}
++
++/*** Get info from call structure *********************************************/
++/* NOTE: The peer_call_id is undefined until we get a server response. */
++void pptp_call_get_ids(PPTP_CONN * conn, PPTP_CALL * call,
++ u_int16_t * call_id, u_int16_t * peer_call_id)
++{
++ assert(conn != NULL); assert(call != NULL);
++ *call_id = call->call_id;
++ *peer_call_id = call->peer_call_id;
++}
++
++/*** pptp_call_closure_put ****************************************************/
++void pptp_call_closure_put(PPTP_CONN * conn, PPTP_CALL * call, void *cl)
++{
++ assert(conn != NULL); assert(call != NULL);
++ call->closure = cl;
++}
++
++/*** pptp_call_closure_get ****************************************************/
++void * pptp_call_closure_get(PPTP_CONN * conn, PPTP_CALL * call)
++{
++ assert(conn != NULL); assert(call != NULL);
++ return call->closure;
++}
++
++/*** pptp_conn_closure_put ****************************************************/
++void pptp_conn_closure_put(PPTP_CONN * conn, void *cl)
++{
++ assert(conn != NULL);
++ conn->closure = cl;
++}
++
++/*** pptp_conn_closure_get ****************************************************/
++void * pptp_conn_closure_get(PPTP_CONN * conn)
++{
++ assert(conn != NULL);
++ return conn->closure;
++}
++
++/*** Reset keep-alive timer ***************************************************/
++static void pptp_reset_timer(void)
++{
++ const struct itimerval tv = { { 0, 0 }, /* stop on time-out */
++ { idle_wait, 0 } };
++ if (idle_wait) setitimer(ITIMER_REAL, &tv, NULL);
++}
++
++
++/*** Handle keep-alive timer **************************************************/
++static void pptp_handle_timer()
++{
++ int i;
++ /* "Keep Alives and Timers, 1": check connection state */
++ if (global.conn->conn_state != CONN_ESTABLISHED) {
++ if (global.conn->conn_state == CONN_WAIT_STOP_REPLY)
++ /* hard close. */
++ pptp_conn_destroy(global.conn);
++ else /* soft close */
++ pptp_conn_close(global.conn, PPTP_STOP_NONE);
++ }
++ /* "Keep Alives and Timers, 2": check echo status */
++ if (global.conn->ka_state == KA_OUTSTANDING) {
++ /* no response to keep-alive */
++ info("closing control connection due to missing echo reply");
++ pptp_conn_close(global.conn, PPTP_STOP_NONE);
++ } else { /* ka_state == NONE */ /* send keep-alive */
++ struct pptp_echo_rqst rqst = {
++ PPTP_HEADER_CTRL(PPTP_ECHO_RQST), hton32(global.conn->ka_id) };
++ pptp_send_ctrl_packet(global.conn, &rqst, sizeof(rqst));
++ global.conn->ka_state = KA_OUTSTANDING;
++ }
++ /* check incoming/outgoing call states for !IDLE && !ESTABLISHED */
++ for (i = 0; i < vector_size(global.conn->call); i++) {
++ PPTP_CALL * call = vector_get_Nth(global.conn->call, i);
++ if (call->call_type == PPTP_CALL_PNS) {
++ if (call->state.pns == PNS_WAIT_REPLY) {
++ /* send close request */
++ pptp_call_close(global.conn, call);
++ assert(call->state.pns == PNS_WAIT_DISCONNECT);
++ } else if (call->state.pns == PNS_WAIT_DISCONNECT) {
++ /* hard-close the call */
++ pptp_call_destroy(global.conn, call);
++ }
++ } else if (call->call_type == PPTP_CALL_PAC) {
++ if (call->state.pac == PAC_WAIT_REPLY) {
++ /* XXX FIXME -- drop the PAC connection XXX */
++ } else if (call->state.pac == PAC_WAIT_CS_ANS) {
++ /* XXX FIXME -- drop the PAC connection XXX */
++ }
++ }
++ }
++ pptp_reset_timer();
++}
+--- /dev/null
++++ b/pppd/plugins/pptp/pptp_ctrl.h
+@@ -0,0 +1,57 @@
++/* pptp_ctrl.h ... handle PPTP control connection.
++ * C. Scott Ananian <cananian@alumni.princeton.edu>
++ *
++ * $Id: pptp_ctrl.h,v 1.5 2004/11/09 01:42:32 quozl Exp $
++ */
++
++#ifndef INC_PPTP_CTRL_H
++#define INC_PPTP_CTRL_H
++#include <sys/types.h>
++
++typedef struct PPTP_CONN PPTP_CONN;
++typedef struct PPTP_CALL PPTP_CALL;
++
++enum call_state { CALL_OPEN_RQST, CALL_OPEN_DONE, CALL_OPEN_FAIL,
++ CALL_CLOSE_RQST, CALL_CLOSE_DONE };
++enum conn_state { CONN_OPEN_RQST, CONN_OPEN_DONE, CONN_OPEN_FAIL,
++ CONN_CLOSE_RQST, CONN_CLOSE_DONE };
++
++typedef void (*pptp_call_cb)(PPTP_CONN*, PPTP_CALL*, enum call_state);
++typedef void (*pptp_conn_cb)(PPTP_CONN*, enum conn_state);
++
++/* if 'isclient' is true, then will send 'conn open' packet to other host.
++ * not necessary if this is being opened by a server process after
++ * receiving a conn_open packet from client.
++ */
++PPTP_CONN * pptp_conn_open(int inet_sock, int isclient,
++ pptp_conn_cb callback);
++PPTP_CALL * pptp_call_open(PPTP_CONN * conn, int call_id,
++ pptp_call_cb callback, char *phonenr,int window);
++int pptp_conn_established(PPTP_CONN * conn);
++/* soft close. Will callback on completion. */
++void pptp_call_close(PPTP_CONN * conn, PPTP_CALL * call);
++/* hard close. */
++void pptp_call_destroy(PPTP_CONN *conn, PPTP_CALL *call);
++/* soft close. Will callback on completion. */
++void pptp_conn_close(PPTP_CONN * conn, u_int8_t close_reason);
++/* hard close */
++void pptp_conn_destroy(PPTP_CONN * conn);
++
++/* Add file descriptors used by pptp to fd_set. */
++void pptp_fd_set(PPTP_CONN * conn, fd_set * read_set, fd_set * write_set, int *max_fd);
++/* handle any pptp file descriptors set in fd_set, and clear them */
++int pptp_dispatch(PPTP_CONN * conn, fd_set * read_set, fd_set * write_set);
++
++/* Get info about connection, call */
++void pptp_call_get_ids(PPTP_CONN * conn, PPTP_CALL * call,
++ u_int16_t * call_id, u_int16_t * peer_call_id);
++/* Arbitrary user data about this call/connection.
++ * It is the caller's responsibility to free this data before calling
++ * pptp_call|conn_close()
++ */
++void * pptp_conn_closure_get(PPTP_CONN * conn);
++void pptp_conn_closure_put(PPTP_CONN * conn, void *cl);
++void * pptp_call_closure_get(PPTP_CONN * conn, PPTP_CALL * call);
++void pptp_call_closure_put(PPTP_CONN * conn, PPTP_CALL * call, void *cl);
++
++#endif /* INC_PPTP_CTRL_H */
+--- /dev/null
++++ b/pppd/plugins/pptp/pptp_msg.h
+@@ -0,0 +1,303 @@
++/* pptp.h: packet structures and magic constants for the PPTP protocol
++ * C. Scott Ananian <cananian@alumni.princeton.edu>
++ *
++ * $Id: pptp_msg.h,v 1.3 2003/02/15 10:37:21 quozl Exp $
++ */
++
++#ifndef INC_PPTP_H
++#define INC_PPTP_H
++
++/* Grab definitions of int16, int32, etc. */
++#include <sys/types.h>
++/* define "portable" htons, etc. */
++#define hton8(x) (x)
++#define ntoh8(x) (x)
++#define hton16(x) htons(x)
++#define ntoh16(x) ntohs(x)
++#define hton32(x) htonl(x)
++#define ntoh32(x) ntohl(x)
++
++/* PPTP magic numbers: ----------------------------------------- */
++
++#define PPTP_MAGIC 0x1A2B3C4D /* Magic cookie for PPTP datagrams */
++#define PPTP_PORT 1723 /* PPTP TCP port number */
++#define PPTP_PROTO 47 /* PPTP IP protocol number */
++
++/* Control Connection Message Types: --------------------------- */
++
++#define PPTP_MESSAGE_CONTROL 1
++#define PPTP_MESSAGE_MANAGE 2
++
++/* Control Message Types: -------------------------------------- */
++
++/* (Control Connection Management) */
++#define PPTP_START_CTRL_CONN_RQST 1
++#define PPTP_START_CTRL_CONN_RPLY 2
++#define PPTP_STOP_CTRL_CONN_RQST 3
++#define PPTP_STOP_CTRL_CONN_RPLY 4
++#define PPTP_ECHO_RQST 5
++#define PPTP_ECHO_RPLY 6
++
++/* (Call Management) */
++#define PPTP_OUT_CALL_RQST 7
++#define PPTP_OUT_CALL_RPLY 8
++#define PPTP_IN_CALL_RQST 9
++#define PPTP_IN_CALL_RPLY 10
++#define PPTP_IN_CALL_CONNECT 11
++#define PPTP_CALL_CLEAR_RQST 12
++#define PPTP_CALL_CLEAR_NTFY 13
++
++/* (Error Reporting) */
++#define PPTP_WAN_ERR_NTFY 14
++
++/* (PPP Session Control) */
++#define PPTP_SET_LINK_INFO 15
++
++/* PPTP version information: --------------------------------------*/
++#define PPTP_VERSION_STRING "1.00"
++#define PPTP_VERSION 0x100
++#define PPTP_FIRMWARE_STRING "0.01"
++#define PPTP_FIRMWARE_VERSION 0x001
++
++/* PPTP capabilities: ---------------------------------------------*/
++
++/* (Framing capabilities for msg sender) */
++#define PPTP_FRAME_ASYNC 1
++#define PPTP_FRAME_SYNC 2
++#define PPTP_FRAME_ANY 3
++
++/* (Bearer capabilities for msg sender) */
++#define PPTP_BEARER_ANALOG 1
++#define PPTP_BEARER_DIGITAL 2
++#define PPTP_BEARER_ANY 3
++
++#define PPTP_RESULT_GENERAL_ERROR 2
++
++/* (Reasons to close a connection) */
++#define PPTP_STOP_NONE 1 /* no good reason */
++#define PPTP_STOP_PROTOCOL 2 /* can't support peer's protocol version */
++#define PPTP_STOP_LOCAL_SHUTDOWN 3 /* requester is being shut down */
++
++/* PPTP datagram structures (all data in network byte order): ----------*/
++
++struct pptp_header {
++ u_int16_t length; /* message length in octets, including header */
++ u_int16_t pptp_type; /* PPTP message type. 1 for control message. */
++ u_int32_t magic; /* this should be PPTP_MAGIC. */
++ u_int16_t ctrl_type; /* Control message type (0-15) */
++ u_int16_t reserved0; /* reserved. MUST BE ZERO. */
++};
++
++struct pptp_start_ctrl_conn { /* for control message types 1 and 2 */
++ struct pptp_header header;
++
++ u_int16_t version; /* PPTP protocol version. = PPTP_VERSION */
++ u_int8_t result_code; /* these two fields should be zero on rqst msg*/
++ u_int8_t error_code; /* 0 unless result_code==2 (General Error) */
++ u_int32_t framing_cap; /* Framing capabilities */
++ u_int32_t bearer_cap; /* Bearer Capabilities */
++ u_int16_t max_channels; /* Maximum Channels (=0 for PNS, PAC ignores) */
++ u_int16_t firmware_rev; /* Firmware or Software Revision */
++ u_int8_t hostname[64]; /* Host Name (64 octets, zero terminated) */
++ u_int8_t vendor[64]; /* Vendor string (64 octets, zero term.) */
++ /* MS says that end of hostname/vendor fields should be filled with */
++ /* octets of value 0, but Win95 PPTP driver doesn't do this. */
++};
++
++struct pptp_stop_ctrl_conn { /* for control message types 3 and 4 */
++ struct pptp_header header;
++
++ u_int8_t reason_result; /* reason for rqst, result for rply */
++ u_int8_t error_code; /* MUST be 0, unless rply result==2 (general err)*/
++ u_int16_t reserved1; /* MUST be 0 */
++};
++
++struct pptp_echo_rqst { /* for control message type 5 */
++ struct pptp_header header;
++ u_int32_t identifier; /* arbitrary value set by sender which is used */
++ /* to match up reply and request */
++};
++
++struct pptp_echo_rply { /* for control message type 6 */
++ struct pptp_header header;
++ u_int32_t identifier; /* should correspond to id of rqst */
++ u_int8_t result_code;
++ u_int8_t error_code; /* =0, unless result_code==2 (general error) */
++ u_int16_t reserved1; /* MUST BE ZERO */
++};
++
++struct pptp_out_call_rqst { /* for control message type 7 */
++ struct pptp_header header;
++ u_int16_t call_id; /* Call ID (unique id used to multiplex data) */
++ u_int16_t call_sernum; /* Call Serial Number (used for logging) */
++ u_int32_t bps_min; /* Minimum BPS (lowest acceptable line speed) */
++ u_int32_t bps_max; /* Maximum BPS (highest acceptable line speed) */
++ u_int32_t bearer; /* Bearer type */
++ u_int32_t framing; /* Framing type */
++ u_int16_t recv_size; /* Recv. Window Size (no. of buffered packets) */
++ u_int16_t delay; /* Packet Processing Delay (in 1/10 sec) */
++ u_int16_t phone_len; /* Phone Number Length (num. of valid digits) */
++ u_int16_t reserved1; /* MUST BE ZERO */
++ u_int8_t phone_num[64]; /* Phone Number (64 octets, null term.) */
++ u_int8_t subaddress[64]; /* Subaddress (64 octets, null term.) */
++};
++
++struct pptp_out_call_rply { /* for control message type 8 */
++ struct pptp_header header;
++ u_int16_t call_id; /* Call ID (used to multiplex data over tunnel)*/
++ u_int16_t call_id_peer; /* Peer's Call ID (call_id of pptp_out_call_rqst)*/
++ u_int8_t result_code; /* Result Code (1 is no errors) */
++ u_int8_t error_code; /* Error Code (=0 unless result_code==2) */
++ u_int16_t cause_code; /* Cause Code (addt'l failure information) */
++ u_int32_t speed; /* Connect Speed (in BPS) */
++ u_int16_t recv_size; /* Recv. Window Size (no. of buffered packets) */
++ u_int16_t delay; /* Packet Processing Delay (in 1/10 sec) */
++ u_int32_t channel; /* Physical Channel ID (for logging) */
++};
++
++struct pptp_in_call_rqst { /* for control message type 9 */
++ struct pptp_header header;
++ u_int16_t call_id; /* Call ID (unique id used to multiplex data) */
++ u_int16_t call_sernum; /* Call Serial Number (used for logging) */
++ u_int32_t bearer; /* Bearer type */
++ u_int32_t channel; /* Physical Channel ID (for logging) */
++ u_int16_t dialed_len; /* Dialed Number Length (# of valid digits) */
++ u_int16_t dialing_len; /* Dialing Number Length (# of valid digits) */
++ u_int8_t dialed_num[64]; /* Dialed Number (64 octets, zero term.) */
++ u_int8_t dialing_num[64]; /* Dialing Number (64 octets, zero term.) */
++ u_int8_t subaddress[64]; /* Subaddress (64 octets, zero term.) */
++};
++
++struct pptp_in_call_rply { /* for control message type 10 */
++ struct pptp_header header;
++ u_int16_t call_id; /* Call ID (used to multiplex data over tunnel)*/
++ u_int16_t call_id_peer; /* Peer's Call ID (call_id of pptp_out_call_rqst)*/
++ u_int8_t result_code; /* Result Code (1 is no errors) */
++ u_int8_t error_code; /* Error Code (=0 unless result_code==2) */
++ u_int16_t recv_size; /* Recv. Window Size (no. of buffered packets) */
++ u_int16_t delay; /* Packet Processing Delay (in 1/10 sec) */
++ u_int16_t reserved1; /* MUST BE ZERO */
++};
++
++struct pptp_in_call_connect { /* for control message type 11 */
++ struct pptp_header header;
++ u_int16_t call_id_peer; /* Peer's Call ID (call_id of pptp_out_call_rqst)*/
++ u_int16_t reserved1; /* MUST BE ZERO */
++ u_int32_t speed; /* Connect Speed (in BPS) */
++ u_int16_t recv_size; /* Recv. Window Size (no. of buffered packets) */
++ u_int16_t delay; /* Packet Processing Delay (in 1/10 sec) */
++ u_int32_t framing; /* Framing type */
++};
++
++struct pptp_call_clear_rqst { /* for control message type 12 */
++ struct pptp_header header;
++ u_int16_t call_id; /* Call ID (used to multiplex data over tunnel)*/
++ u_int16_t reserved1; /* MUST BE ZERO */
++};
++
++struct pptp_call_clear_ntfy { /* for control message type 13 */
++ struct pptp_header header;
++ u_int16_t call_id; /* Call ID (used to multiplex data over tunnel)*/
++ u_int8_t result_code; /* Result Code */
++ u_int8_t error_code; /* Error Code (=0 unless result_code==2) */
++ u_int16_t cause_code; /* Cause Code (for ISDN, is Q.931 cause code) */
++ u_int16_t reserved1; /* MUST BE ZERO */
++ u_int8_t call_stats[128]; /* Call Statistics: 128 octets, ascii, 0-term */
++};
++
++struct pptp_wan_err_ntfy { /* for control message type 14 */
++ struct pptp_header header;
++ u_int16_t call_id_peer; /* Peer's Call ID (call_id of pptp_out_call_rqst)*/
++ u_int16_t reserved1; /* MUST BE ZERO */
++ u_int32_t crc_errors; /* CRC errors */
++ u_int32_t frame_errors; /* Framing errors */
++ u_int32_t hard_errors; /* Hardware overruns */
++ u_int32_t buff_errors; /* Buffer overruns */
++ u_int32_t time_errors; /* Time-out errors */
++ u_int32_t align_errors; /* Alignment errors */
++};
++
++struct pptp_set_link_info { /* for control message type 15 */
++ struct pptp_header header;
++ u_int16_t call_id_peer; /* Peer's Call ID (call_id of pptp_out_call_rqst) */
++ u_int16_t reserved1; /* MUST BE ZERO */
++ u_int32_t send_accm; /* Send ACCM (for PPP packets; default 0xFFFFFFFF)*/
++ u_int32_t recv_accm; /* Receive ACCM (for PPP pack.;default 0xFFFFFFFF)*/
++};
++
++/* helpful #defines: -------------------------------------------- */
++#define pptp_isvalid_ctrl(header, type, length) \
++ (!( ( ntoh16(((struct pptp_header *)header)->length) < (length) ) || \
++ ( ntoh16(((struct pptp_header *)header)->pptp_type) !=(type) ) || \
++ ( ntoh32(((struct pptp_header *)header)->magic) !=PPTP_MAGIC) || \
++ ( ntoh16(((struct pptp_header *)header)->ctrl_type) > PPTP_SET_LINK_INFO) || \
++ ( ntoh16(((struct pptp_header *)header)->reserved0) !=0 ) ))
++
++#define PPTP_HEADER_CTRL(type) \
++{ hton16(PPTP_CTRL_SIZE(type)), \
++ hton16(PPTP_MESSAGE_CONTROL), \
++ hton32(PPTP_MAGIC), \
++ hton16(type), 0 }
++
++#define PPTP_CTRL_SIZE(type) ( \
++(type==PPTP_START_CTRL_CONN_RQST)?sizeof(struct pptp_start_ctrl_conn): \
++(type==PPTP_START_CTRL_CONN_RPLY)?sizeof(struct pptp_start_ctrl_conn): \
++(type==PPTP_STOP_CTRL_CONN_RQST )?sizeof(struct pptp_stop_ctrl_conn): \
++(type==PPTP_STOP_CTRL_CONN_RPLY )?sizeof(struct pptp_stop_ctrl_conn): \
++(type==PPTP_ECHO_RQST )?sizeof(struct pptp_echo_rqst): \
++(type==PPTP_ECHO_RPLY )?sizeof(struct pptp_echo_rply): \
++(type==PPTP_OUT_CALL_RQST )?sizeof(struct pptp_out_call_rqst): \
++(type==PPTP_OUT_CALL_RPLY )?sizeof(struct pptp_out_call_rply): \
++(type==PPTP_IN_CALL_RQST )?sizeof(struct pptp_in_call_rqst): \
++(type==PPTP_IN_CALL_RPLY )?sizeof(struct pptp_in_call_rply): \
++(type==PPTP_IN_CALL_CONNECT )?sizeof(struct pptp_in_call_connect): \
++(type==PPTP_CALL_CLEAR_RQST )?sizeof(struct pptp_call_clear_rqst): \
++(type==PPTP_CALL_CLEAR_NTFY )?sizeof(struct pptp_call_clear_ntfy): \
++(type==PPTP_WAN_ERR_NTFY )?sizeof(struct pptp_wan_err_ntfy): \
++(type==PPTP_SET_LINK_INFO )?sizeof(struct pptp_set_link_info): \
++0)
++#define max(a,b) (((a)>(b))?(a):(b))
++#define PPTP_CTRL_SIZE_MAX ( \
++max(sizeof(struct pptp_start_ctrl_conn), \
++max(sizeof(struct pptp_echo_rqst), \
++max(sizeof(struct pptp_echo_rply), \
++max(sizeof(struct pptp_out_call_rqst), \
++max(sizeof(struct pptp_out_call_rply), \
++max(sizeof(struct pptp_in_call_rqst), \
++max(sizeof(struct pptp_in_call_rply), \
++max(sizeof(struct pptp_in_call_connect), \
++max(sizeof(struct pptp_call_clear_rqst), \
++max(sizeof(struct pptp_call_clear_ntfy), \
++max(sizeof(struct pptp_wan_err_ntfy), \
++max(sizeof(struct pptp_set_link_info), 0)))))))))))))
++
++
++/* gre header structure: -------------------------------------------- */
++
++#define PPTP_GRE_PROTO 0x880B
++#define PPTP_GRE_VER 0x1
++
++#define PPTP_GRE_FLAG_C 0x80
++#define PPTP_GRE_FLAG_R 0x40
++#define PPTP_GRE_FLAG_K 0x20
++#define PPTP_GRE_FLAG_S 0x10
++#define PPTP_GRE_FLAG_A 0x80
++
++#define PPTP_GRE_IS_C(f) ((f)&PPTP_GRE_FLAG_C)
++#define PPTP_GRE_IS_R(f) ((f)&PPTP_GRE_FLAG_R)
++#define PPTP_GRE_IS_K(f) ((f)&PPTP_GRE_FLAG_K)
++#define PPTP_GRE_IS_S(f) ((f)&PPTP_GRE_FLAG_S)
++#define PPTP_GRE_IS_A(f) ((f)&PPTP_GRE_FLAG_A)
++
++struct pptp_gre_header {
++ u_int8_t flags; /* bitfield */
++ u_int8_t ver; /* should be PPTP_GRE_VER (enhanced GRE) */
++ u_int16_t protocol; /* should be PPTP_GRE_PROTO (ppp-encaps) */
++ u_int16_t payload_len; /* size of ppp payload, not inc. gre header */
++ u_int16_t call_id; /* peer's call_id for this session */
++ u_int32_t seq; /* sequence number. Present if S==1 */
++ u_int32_t ack; /* seq number of highest packet recieved by */
++ /* sender in this session */
++};
++
++#endif /* INC_PPTP_H */
+--- /dev/null
++++ b/pppd/plugins/pptp/pptp_options.h
+@@ -0,0 +1,41 @@
++/* pptp_options.h ...... various constants used in the PPTP protocol.
++ * #define STANDARD to emulate NT 4.0 exactly.
++ * C. Scott Ananian <cananian@alumni.princeton.edu>
++ *
++ * $Id: pptp_options.h,v 1.3 2004/11/09 01:42:32 quozl Exp $
++ */
++
++#ifndef INC_PPTP_OPTIONS_H
++#define INC_PPTP_OPTIONS_H
++
++#undef PPTP_FIRMWARE_STRING
++#undef PPTP_FIRMWARE_VERSION
++#define PPTP_BUF_MAX 65536
++#define PPTP_TIMEOUT 60 /* seconds */
++extern int idle_wait;
++extern int max_echo_wait;
++#define PPTP_CONNECT_SPEED 1000000000
++#define PPTP_WINDOW 3
++#define PPTP_DELAY 0
++#define PPTP_BPS_MIN 2400
++#define PPTP_BPS_MAX 1000000000
++
++#ifndef STANDARD
++#define PPTP_MAX_CHANNELS 65535
++#define PPTP_FIRMWARE_STRING "0.01"
++#define PPTP_FIRMWARE_VERSION 0x001
++#define PPTP_HOSTNAME {'l','o','c','a','l',0}
++#define PPTP_VENDOR {'c','a','n','a','n','i','a','n',0}
++#define PPTP_FRAME_CAP PPTP_FRAME_ANY
++#define PPTP_BEARER_CAP PPTP_BEARER_ANY
++#else
++#define PPTP_MAX_CHANNELS 5
++#define PPTP_FIRMWARE_STRING "0.01"
++#define PPTP_FIRMWARE_VERSION 0
++#define PPTP_HOSTNAME {'l','o','c','a','l',0}
++#define PPTP_VENDOR {'N','T',0}
++#define PPTP_FRAME_CAP 2
++#define PPTP_BEARER_CAP 1
++#endif
++
++#endif /* INC_PPTP_OPTIONS_H */
+--- /dev/null
++++ b/pppd/plugins/pptp/pptp_quirks.c
+@@ -0,0 +1,54 @@
++/* pptp_quirks.c ...... various options to fix quirks found in buggy adsl modems
++ * mulix <mulix@actcom.co.il>
++ *
++ * $Id: pptp_quirks.c,v 1.2 2001/11/23 03:42:51 quozl Exp $
++ */
++
++#include <string.h>
++#include "orckit_quirks.h"
++#include "pptp_quirks.h"
++
++static int quirk_index = -1;
++
++struct pptp_fixup pptp_fixups[] = {
++ {BEZEQ_ISRAEL, ORCKIT, ORCKIT_ATUR3,
++ orckit_atur3_build_hook,
++ orckit_atur3_start_ctrl_conn_hook,
++ orckit_atur3_set_link_hook}
++};
++
++static int fixups_sz = sizeof(pptp_fixups)/sizeof(pptp_fixups[0]);
++
++/* return 0 on success, non 0 otherwise */
++int set_quirk_index(int index)
++{
++ if (index >= 0 && index < fixups_sz) {
++ quirk_index = index;
++ return 0;
++ }
++
++ return -1;
++}
++
++int get_quirk_index()
++{
++ return quirk_index;
++}
++
++/* return the index for this isp in the quirks table, -1 if not found */
++int find_quirk(const char* isp_name)
++{
++ int i = 0;
++ if (isp_name) {
++ while (i < fixups_sz && pptp_fixups[i].isp) {
++ if (!strcmp(pptp_fixups[i].isp, isp_name)) {
++ return i;
++ }
++ ++i;
++ }
++ }
++
++ return -1;
++}
++
++
+--- /dev/null
++++ b/pppd/plugins/pptp/pptp_quirks.h
+@@ -0,0 +1,59 @@
++/* pptp_quirks.h ...... various options to fix quirks found in buggy adsl modems
++ * mulix <mulix@actcom.co.il>
++ *
++ * $Id: pptp_quirks.h,v 1.1 2001/11/20 06:30:10 quozl Exp $
++ */
++
++#ifndef INC_PPTP_QUIRKS_H
++#define INC_PPTP_QUIRKS_H
++
++/* isp defs - correspond to slots in the fixups table */
++#define BEZEQ_ISRAEL "BEZEQ_ISRAEL"
++
++/* vendor defs */
++
++#define ORCKIT 1
++#define ALCATEL 2
++
++/* device defs */
++
++#define ORCKIT_ATUR2 1
++#define ORCKIT_ATUR3 2
++
++#include "pptp_msg.h"
++#include "pptp_ctrl.h"
++
++struct pptp_fixup {
++ const char* isp; /* which isp? e.g. Bezeq in Israel */
++ int vendor; /* which vendor? e.g. Orckit */
++ int device; /* which device? e.g. Orckit Atur3 */
++
++ /* use this hook to build your own out call request packet */
++ int (*out_call_rqst_hook)(struct pptp_out_call_rqst* packet);
++
++ /* use this hook to build your own start control connection packet */
++ /* note that this hook is called from two different places, depending
++ on whether this is a request or reply */
++ int (*start_ctrl_conn)(struct pptp_start_ctrl_conn* packet);
++
++ /* use this hook if you need to send a 'set_link' packet once
++ the connection is established */
++ int (*set_link_hook)(struct pptp_set_link_info* packet,
++ int peer_call_id);
++};
++
++extern struct pptp_fixup pptp_fixups[];
++
++/* find the index for this isp in the quirks table */
++/* return the index on success, -1 if not found */
++int find_quirk(const char* isp_name);
++
++/* set the global quirk index. return 0 on success, non 0 otherwise */
++int set_quirk_index(int index);
++
++/* get the global quirk index. return the index on success,
++ -1 if no quirk is defined */
++int get_quirk_index();
++
++
++#endif /* INC_PPTP_QUIRKS_H */
+--- /dev/null
++++ b/pppd/plugins/pptp/util.c
+@@ -0,0 +1,109 @@
++/* util.c ....... error message utilities.
++ * C. Scott Ananian <cananian@alumni.princeton.edu>
++ *
++ * $Id: util.c,v 1.11 2005/08/22 00:49:48 quozl Exp $
++ */
++
++#include <stdio.h>
++#include <stdarg.h>
++#include <syslog.h>
++#include <unistd.h>
++#include <stdlib.h>
++#include "util.h"
++
++#define MAKE_STRING(label) \
++va_list ap; \
++char buf[256], string[256]; \
++va_start(ap, format); \
++vsnprintf(buf, sizeof(buf), format, ap); \
++snprintf(string, sizeof(string), "%s %s[%s:%s:%d]: %s", \
++ log_string, label, func, file, line, buf); \
++va_end(ap)
++
++/*** connect a file to a file descriptor **************************************/
++int file2fd(const char *path, const char *mode, int fd)
++{
++ int ok = 0;
++ FILE *file = NULL;
++ file = fopen(path, mode);
++ if (file != NULL && dup2(fileno(file), fd) != -1)
++ ok = 1;
++ if (file) fclose(file);
++ return ok;
++}
++
++/* signal to pipe delivery implementation */
++#include <unistd.h>
++#include <fcntl.h>
++#include <signal.h>
++#include <string.h>
++
++/* pipe private to process */
++static int sigpipe[2];
++
++/* create a signal pipe, returns 0 for success, -1 with errno for failure */
++int sigpipe_create()
++{
++ int rc;
++
++ rc = pipe(sigpipe);
++ if (rc < 0) return rc;
++
++ fcntl(sigpipe[0], F_SETFD, FD_CLOEXEC);
++ fcntl(sigpipe[1], F_SETFD, FD_CLOEXEC);
++
++#ifdef O_NONBLOCK
++#define FLAG_TO_SET O_NONBLOCK
++#else
++#ifdef SYSV
++#define FLAG_TO_SET O_NDELAY
++#else /* BSD */
++#define FLAG_TO_SET FNDELAY
++#endif
++#endif
++
++ rc = fcntl(sigpipe[1], F_GETFL);
++ if (rc != -1)
++ rc = fcntl(sigpipe[1], F_SETFL, rc | FLAG_TO_SET);
++ if (rc < 0) return rc;
++ return 0;
++#undef FLAG_TO_SET
++}
++
++/* generic handler for signals, writes signal number to pipe */
++void sigpipe_handler(int signum)
++{
++ write(sigpipe[1], &signum, sizeof(signum));
++ signal(signum, sigpipe_handler);
++}
++
++/* assign a signal number to the pipe */
++void sigpipe_assign(int signum)
++{
++ struct sigaction sa;
++
++ memset(&sa, 0, sizeof(sa));
++ sa.sa_handler = sigpipe_handler;
++ sigaction(signum, &sa, NULL);
++}
++
++/* return the signal pipe read file descriptor for select(2) */
++int sigpipe_fd()
++{
++ return sigpipe[0];
++}
++
++/* read and return the pending signal from the pipe */
++int sigpipe_read()
++{
++ int signum;
++ read(sigpipe[0], &signum, sizeof(signum));
++ return signum;
++}
++
++void sigpipe_close()
++{
++ close(sigpipe[0]);
++ close(sigpipe[1]);
++}
++
+--- /dev/null
++++ b/pppd/plugins/pptp/util.h
+@@ -0,0 +1,31 @@
++/* util.h ....... error message utilities.
++ * C. Scott Ananian <cananian@alumni.princeton.edu>
++ *
++ * $Id: util.h,v 1.6 2005/03/10 01:18:20 quozl Exp $
++ */
++
++#ifndef INC_UTIL_H
++#define INC_UTIL_H
++
++int file2fd(const char *path, const char *mode, int fd);
++
++/* signal to pipe delivery implementation */
++
++/* create a signal pipe, returns 0 for success, -1 with errno for failure */
++int sigpipe_create();
++
++/* generic handler for signals, writes signal number to pipe */
++void sigpipe_handler(int signum);
++
++/* assign a signal number to the pipe */
++void sigpipe_assign(int signum);
++
++/* return the signal pipe read file descriptor for select(2) */
++int sigpipe_fd();
++
++/* read and return the pending signal from the pipe */
++int sigpipe_read();
++
++void sigpipe_close();
++
++#endif /* INC_UTIL_H */
+--- /dev/null
++++ b/pppd/plugins/pptp/vector.c
+@@ -0,0 +1,209 @@
++/* vector.c ..... store a vector of PPTP_CALL information and search it
++ * efficiently.
++ * C. Scott Ananian <cananian@alumni.princeton.edu>
++ *
++ * $Id: vector.c,v 1.3 2003/06/17 10:12:55 reink Exp $
++ */
++
++#include <stdlib.h>
++#include <string.h>
++#include <assert.h>
++#include "pptp_ctrl.h"
++#include "vector.h"
++/* #define VECTOR_DEBUG */
++#ifndef TRUE
++#define TRUE 1
++#endif
++#ifndef FALSE
++#define FALSE 0
++#endif
++
++struct vector_item {
++ int key;
++ PPTP_CALL *call;
++};
++
++struct vector_struct {
++ struct vector_item *item;
++ int size;
++ int alloc;
++#ifdef VECTOR_DEBUG
++ int key_max;
++#endif
++};
++
++static struct vector_item *binary_search(VECTOR *v, int key);
++
++/*** vector_create ************************************************************/
++VECTOR *vector_create()
++{
++ const int INITIAL_SIZE = 4;
++
++ VECTOR *v = malloc(sizeof(*v));
++ if (v == NULL) return v;
++
++ v->size = 0;
++ v->alloc = INITIAL_SIZE;
++ v->item = malloc(sizeof(*(v->item)) * (v->alloc));
++#ifdef VECTOR_DEBUG
++ v->key_max = -1;
++#endif
++ if (v->item == NULL) { free(v); return NULL; }
++ else return v;
++}
++
++/*** vector_destroy ***********************************************************/
++void vector_destroy(VECTOR *v)
++{
++ free(v->item);
++#ifdef VECTOR_DEBUG
++ v->item = NULL;
++#endif
++ free(v);
++}
++
++/*** vector_size **************************************************************/
++int vector_size(VECTOR *v)
++{
++ assert(v != NULL);
++ return v->size;
++}
++
++/*** vector_insert*************************************************************
++ * nice thing about file descriptors is that we are assured by POSIX
++ * that they are monotonically increasing.
++ */
++int vector_insert(VECTOR *v, int key, PPTP_CALL * call)
++{
++ int i;
++ assert(v != NULL && call != NULL);
++ assert(!vector_contains(v, key));
++#ifdef VECTOR_DEBUG
++ assert(v->key_max < key);
++#endif
++ if (!(v->size < v->alloc)) {
++ void *tmp = realloc(v->item, sizeof(*(v->item)) * 2 * v->alloc);
++ if (tmp != NULL) {
++ v->alloc *= 2;
++ v->item = tmp;
++ } else return FALSE; /* failed to alloc memory. */
++ }
++ assert(v->size < v->alloc);
++ /* for safety, we make this work in the general case;
++ * but this is optimized for adding call to the end of the vector.
++ */
++ for(i = v->size - 1; i >= 0; i--)
++ if (v->item[i].key < key)
++ break;
++ /* insert after item i */
++ memmove(&v->item[i + 2], &v->item[i + 1],
++ (v->size - i - 1) * sizeof(*(v->item)));
++ v->item[i + 1].key = key;
++ v->item[i + 1].call = call;
++ v->size++;
++#ifdef VECTOR_DEBUG
++ if (v->key_max < key) /* ie, always. */
++ v->key_max = key;
++#endif
++ return TRUE;
++}
++
++/*** vector_remove ************************************************************/
++int vector_remove(VECTOR *v, int key)
++{
++ struct vector_item *tmp;
++ assert(v != NULL);
++ if ((tmp =binary_search(v,key)) == NULL) return FALSE;
++ assert(tmp >= v->item && tmp < v->item + v->size);
++ memmove(tmp, tmp + 1, (v->size - (v->item - tmp) - 1) * sizeof(*(v->item)));
++ v->size--;
++ return TRUE;
++}
++
++/*** vector_search ************************************************************/
++int vector_search(VECTOR *v, int key, PPTP_CALL **call)
++{
++ struct vector_item *tmp;
++ assert(v != NULL);
++ tmp = binary_search(v, key);
++ if (tmp ==NULL) return FALSE;
++ *call = tmp->call;
++ return TRUE;
++}
++
++/*** vector_contains **********************************************************/
++int vector_contains(VECTOR *v, int key)
++{
++ assert(v != NULL);
++ return (binary_search(v, key) != NULL);
++}
++
++/*** vector_item **************************************************************/
++static struct vector_item *binary_search(VECTOR *v, int key)
++{
++ int l,r,x;
++ l = 0;
++ r = v->size - 1;
++ while (r >= l) {
++ x = (l + r)/2;
++ if (key < v->item[x].key) r = x - 1; else l = x + 1;
++ if (key == v->item[x].key) return &(v->item[x]);
++ }
++ return NULL;
++}
++
++/*** vector_scan ***************************************************************
++ * Hmm. Let's be fancy and use a binary search for the first
++ * unused key, taking advantage of the list is stored sorted; ie
++ * we can look at pointers and keys at two different locations,
++ * and if (ptr1 - ptr2) = (key1 - key2) then all the slots
++ * between ptr1 and ptr2 are filled. Note that ptr1-ptr2 should
++ * never be greater than key1-key2 (no duplicate keys!)... we
++ * check for this.
++ */
++int vector_scan(VECTOR *v, int lo, int hi, int *key)
++{
++ int l,r,x;
++ assert(v != NULL);
++ assert(key != NULL);
++ if ((v->size<1) || (lo < v->item[0].key)) { *key = lo; return TRUE; }
++ /* our array bounds */
++ l = 0; r = v->size - 1;
++ while (r > l) {
++ /* check for a free spot right after l */
++ if (v->item[l].key + 1 < v->item[l + 1].key) { /* found it! */
++ *key = v->item[l].key + 1;
++ return TRUE;
++ }
++ /* no dice. Let's see if the free spot is before or after the midpoint */
++ x = (l + r)/2;
++ /* Okay, we have right (r), left (l) and the probe (x). */
++ assert(x - l <= v->item[x].key - v->item[l].key);
++ assert(r - x <= v->item[r].key - v->item[x].key);
++ if (x - l < v->item[x].key - v->item[l].key)
++ /* room between l and x */
++ r = x;
++ else /* no room between l and x */
++ if (r - x < v->item[r].key - v->item[x].key)
++ /* room between x and r */
++ l = x;
++ else /* no room between x and r, either */
++ break; /* game over, man. */
++ }
++ /* no room found in already allocated space. Check to see if
++ * there's free space above allocated entries. */
++ if (v->item[v->size - 1].key < hi) {
++ *key = v->item[v->size - 1].key + 1;
++ return TRUE;
++ }
++ /* outta luck */
++ return FALSE;
++}
++
++/*** vector_get_Nth ***********************************************************/
++PPTP_CALL * vector_get_Nth(VECTOR *v, int n)
++{
++ assert(v != NULL);
++ assert(0 <= n && n < vector_size(v));
++ return v->item[n].call;
++}
+--- /dev/null
++++ b/pppd/plugins/pptp/vector.h
+@@ -0,0 +1,31 @@
++/* vector.h ..... store a vector of PPTP_CALL information and search it
++ * efficiently.
++ * C. Scott Ananian <cananian@alumni.princeton.edu>
++ *
++ * $Id: vector.h,v 1.1.1.1 2000/12/23 08:19:51 scott Exp $
++ */
++
++#ifndef INC_VECTOR_H
++#define INC_VECTOR_H
++
++#include "pptp_ctrl.h" /* for definition of PPTP_CALL */
++
++typedef struct vector_struct VECTOR;
++
++VECTOR *vector_create();
++void vector_destroy(VECTOR *v);
++
++int vector_size(VECTOR *v);
++
++/* vector_insert and vector_search return TRUE on success, FALSE on failure. */
++int vector_insert(VECTOR *v, int key, PPTP_CALL * call);
++int vector_remove(VECTOR *v, int key);
++int vector_search(VECTOR *v, int key, PPTP_CALL ** call);
++/* vector_contains returns FALSE if not found, TRUE if found. */
++int vector_contains(VECTOR *v, int key);
++/* find first unused key. Returns TRUE on success, FALSE if no. */
++int vector_scan(VECTOR *v, int lo, int hi, int *key);
++/* get a specific PPTP_CALL ... useful only when iterating. */
++PPTP_CALL * vector_get_Nth(VECTOR *v, int n);
++
++#endif /* INC_VECTOR_H */
diff --git a/package/network/services/ppp/utils/.svn/entries b/package/network/services/ppp/utils/.svn/entries
new file mode 100644
index 0000000..c9cbdd1
--- /dev/null
+++ b/package/network/services/ppp/utils/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/services/ppp/utils
+svn://svn.openwrt.org/openwrt
+
+
+
+2007-03-04T04:41:46.644094Z
+6501
+pavlov
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+pfc.c
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+2fb1a3037c5662c67f4ca968a9f15781
+2007-03-04T04:41:46.644094Z
+6501
+pavlov
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1061
+
diff --git a/package/network/services/ppp/utils/.svn/prop-base/pfc.c.svn-base b/package/network/services/ppp/utils/.svn/prop-base/pfc.c.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/network/services/ppp/utils/.svn/prop-base/pfc.c.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/services/ppp/utils/.svn/text-base/pfc.c.svn-base b/package/network/services/ppp/utils/.svn/text-base/pfc.c.svn-base
new file mode 100644
index 0000000..5476be1
--- /dev/null
+++ b/package/network/services/ppp/utils/.svn/text-base/pfc.c.svn-base
@@ -0,0 +1,51 @@
+/*
+ * Taken from fli4l 3.0
+ * Make sure you compile it against the same libpcap version used in OpenWrt
+ */
+
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <string.h>
+
+#include <linux/types.h>
+#include <linux/ppp_defs.h>
+
+#include <pcap.h>
+#include <pcap-bpf.h>
+
+int main (int argc, char ** argv)
+{
+ pcap_t *pc; /* Fake struct pcap so we can compile expr */
+ struct bpf_program filter; /* Filter program for link-active pkts */
+ u_int32_t netmask=0;
+
+ int dflag = 3;
+ if (argc == 4)
+ {
+ if (!strcmp (argv[1], "-d"))
+ {
+ dflag = atoi (argv[2]);
+ argv += 2;
+ argc -=2;
+ }
+ }
+ if (argc != 2)
+ {
+ printf ("usage; %s [ -d <debug_level> ] expression\n", argv[0]);
+ return 1;
+ }
+
+ pc = pcap_open_dead(DLT_PPP_PPPD, PPP_HDRLEN);
+ if (pcap_compile(pc, &filter, argv[1], 1, netmask) == 0)
+ {
+ printf ("#\n# Expression: %s\n#\n", argv[1]);
+ bpf_dump (&filter, dflag);
+ return 0;
+ }
+ else
+ {
+ printf("error in active-filter expression: %s\n", pcap_geterr(pc));
+ }
+ return 1;
+}
diff --git a/package/network/services/ppp/utils/pfc.c b/package/network/services/ppp/utils/pfc.c
new file mode 100644
index 0000000..5476be1
--- /dev/null
+++ b/package/network/services/ppp/utils/pfc.c
@@ -0,0 +1,51 @@
+/*
+ * Taken from fli4l 3.0
+ * Make sure you compile it against the same libpcap version used in OpenWrt
+ */
+
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <string.h>
+
+#include <linux/types.h>
+#include <linux/ppp_defs.h>
+
+#include <pcap.h>
+#include <pcap-bpf.h>
+
+int main (int argc, char ** argv)
+{
+ pcap_t *pc; /* Fake struct pcap so we can compile expr */
+ struct bpf_program filter; /* Filter program for link-active pkts */
+ u_int32_t netmask=0;
+
+ int dflag = 3;
+ if (argc == 4)
+ {
+ if (!strcmp (argv[1], "-d"))
+ {
+ dflag = atoi (argv[2]);
+ argv += 2;
+ argc -=2;
+ }
+ }
+ if (argc != 2)
+ {
+ printf ("usage; %s [ -d <debug_level> ] expression\n", argv[0]);
+ return 1;
+ }
+
+ pc = pcap_open_dead(DLT_PPP_PPPD, PPP_HDRLEN);
+ if (pcap_compile(pc, &filter, argv[1], 1, netmask) == 0)
+ {
+ printf ("#\n# Expression: %s\n#\n", argv[1]);
+ bpf_dump (&filter, dflag);
+ return 0;
+ }
+ else
+ {
+ printf("error in active-filter expression: %s\n", pcap_geterr(pc));
+ }
+ return 1;
+}
diff --git a/package/network/services/relayd/.svn/entries b/package/network/services/relayd/.svn/entries
new file mode 100644
index 0000000..7def96b
--- /dev/null
+++ b/package/network/services/relayd/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/services/relayd
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-10T12:32:29.935169Z
+33688
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+files
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+11706c42da5164a0e313c28795b95737
+2012-10-08T11:41:02.214093Z
+33660
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1174
+
diff --git a/package/network/services/relayd/.svn/text-base/Makefile.svn-base b/package/network/services/relayd/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..db957bd
--- /dev/null
+++ b/package/network/services/relayd/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,44 @@
+#
+# Copyright (C) 2010-2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=relayd
+PKG_VERSION:=2011-10-24
+PKG_RELEASE=$(PKG_SOURCE_VERSION)
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE_URL:=git://nbd.name/relayd.git
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_VERSION:=4e8f1fa4ca2b176500362843a9e57ea5abd4b7a3
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/cmake.mk
+
+define Package/relayd
+ SECTION:=net
+ CATEGORY:=Network
+ SUBMENU:=Routing and Redirection
+ TITLE:=Transparent routing / relay daemon
+ DEPENDS:=+libubox
+endef
+
+TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include
+
+define Package/relayd/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/relayd $(1)/usr/sbin/relayd
+ $(INSTALL_DIR) $(1)/etc/hotplug.d/iface
+ $(INSTALL_DATA) ./files/relay.hotplug $(1)/etc/hotplug.d/iface/30-relay
+ $(INSTALL_DIR) $(1)/etc/init.d
+ $(INSTALL_BIN) ./files/relay.init $(1)/etc/init.d/relayd
+endef
+
+$(eval $(call BuildPackage,relayd))
diff --git a/package/network/services/relayd/Makefile b/package/network/services/relayd/Makefile
new file mode 100644
index 0000000..db957bd
--- /dev/null
+++ b/package/network/services/relayd/Makefile
@@ -0,0 +1,44 @@
+#
+# Copyright (C) 2010-2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=relayd
+PKG_VERSION:=2011-10-24
+PKG_RELEASE=$(PKG_SOURCE_VERSION)
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE_URL:=git://nbd.name/relayd.git
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_VERSION:=4e8f1fa4ca2b176500362843a9e57ea5abd4b7a3
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/cmake.mk
+
+define Package/relayd
+ SECTION:=net
+ CATEGORY:=Network
+ SUBMENU:=Routing and Redirection
+ TITLE:=Transparent routing / relay daemon
+ DEPENDS:=+libubox
+endef
+
+TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include
+
+define Package/relayd/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/relayd $(1)/usr/sbin/relayd
+ $(INSTALL_DIR) $(1)/etc/hotplug.d/iface
+ $(INSTALL_DATA) ./files/relay.hotplug $(1)/etc/hotplug.d/iface/30-relay
+ $(INSTALL_DIR) $(1)/etc/init.d
+ $(INSTALL_BIN) ./files/relay.init $(1)/etc/init.d/relayd
+endef
+
+$(eval $(call BuildPackage,relayd))
diff --git a/package/network/services/relayd/files/.svn/entries b/package/network/services/relayd/files/.svn/entries
new file mode 100644
index 0000000..98bf272
--- /dev/null
+++ b/package/network/services/relayd/files/.svn/entries
@@ -0,0 +1,96 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/services/relayd/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-05-14T14:08:43.777949Z
+31712
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+relay.hotplug
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+a4f2f7eeff4d8be056283fe3e1db88bc
+2012-04-30T18:23:52.528743Z
+31542
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+65
+
+relay.init
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+bd3e824d97681a57ed8d9b2cfe6f44c7
+2012-05-14T14:08:43.777949Z
+31712
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1926
+
diff --git a/package/network/services/relayd/files/.svn/text-base/relay.hotplug.svn-base b/package/network/services/relayd/files/.svn/text-base/relay.hotplug.svn-base
new file mode 100644
index 0000000..afffbfe
--- /dev/null
+++ b/package/network/services/relayd/files/.svn/text-base/relay.hotplug.svn-base
@@ -0,0 +1,2 @@
+#!/bin/sh
+/etc/init.d/relayd enabled && /etc/init.d/relayd start
diff --git a/package/network/services/relayd/files/.svn/text-base/relay.init.svn-base b/package/network/services/relayd/files/.svn/text-base/relay.init.svn-base
new file mode 100644
index 0000000..43ba6e1
--- /dev/null
+++ b/package/network/services/relayd/files/.svn/text-base/relay.init.svn-base
@@ -0,0 +1,97 @@
+#!/bin/sh /etc/rc.common
+# Copyright (c) 2011-2012 OpenWrt.org
+START=80
+
+resolve_ifname() {
+ grep -qs "^ *$1:" /proc/net/dev && {
+ append args "-I $1"
+ append ifaces "$1"
+ }
+}
+
+resolve_network() {
+ local ifn
+ fixup_interface "$1"
+ config_get ifn "$1" ifname
+ [ -z "$ifn" ] && return 1
+ resolve_ifname "$ifn"
+}
+
+start_relay() {
+ local cfg="$1"
+
+ local args=""
+ local ifaces=""
+
+ config_get proto "$cfg" proto
+ [[ "$proto" == relay ]] || return 0
+
+ SERVICE_DAEMONIZE=1
+ SERVICE_WRITE_PID=1
+ SERVICE_PID_FILE="/var/run/relay-$cfg.pid"
+ [ -f "$SERVICE_PID_FILE" ] && {
+ if grep -q relayd "/proc/$(cat $SERVICE_PID_FILE)/cmdline"; then
+ return 0
+ else
+ rm -f "$SERVICE_PID_FILE"
+ fi
+ }
+
+ local net networks
+ config_get networks "$cfg" network
+ for net in $networks; do
+ resolve_network "$net" || {
+ return 1
+ }
+ done
+
+ local ifn ifnames
+ config_get ifnames "$cfg" ifname
+ for ifn in $ifnames; do
+ resolve_ifname "$ifn"
+ done
+
+ local ipaddr
+ config_get ipaddr "$cfg" ipaddr
+ [ -n "$ipaddr" ] && append args "-L $ipaddr"
+
+ local gateway
+ config_get gateway "$cfg" gateway
+ [ -n "$gateway" ] && append args "-G $gateway"
+
+ local expiry # = 30
+ config_get expiry "$cfg" expiry
+ [ -n "$expiry" ] && append args "-t $expiry"
+
+ local retry # = 5
+ config_get retry "$cfg" retry
+ [ -n "$retry" ] && append args "-p $retry"
+
+ local table # = 16800
+ config_get table "$cfg" table
+ [ -n "$table" ] && append args "-T $table"
+
+ local fwd_bcast # = 1
+ config_get_bool fwd_bcast "$cfg" forward_bcast 1
+ [ $fwd_bcast -eq 1 ] && append args "-B"
+
+ local fwd_dhcp # = 1
+ config_get_bool fwd_dhcp "$cfg" forward_dhcp 1
+ [ $fwd_dhcp -eq 1 ] && append args "-D"
+
+ service_start /usr/sbin/relayd $args
+}
+
+stop() {
+ for pid in /var/run/relay-*.pid; do
+ SERVICE_PID_FILE="$pid"
+ service_stop /usr/sbin/relayd
+ rm -f "$SERVICE_PID_FILE"
+ done
+}
+
+start() {
+ include /lib/network
+ config_load network
+ config_foreach start_relay interface
+}
diff --git a/package/network/services/relayd/files/relay.hotplug b/package/network/services/relayd/files/relay.hotplug
new file mode 100644
index 0000000..afffbfe
--- /dev/null
+++ b/package/network/services/relayd/files/relay.hotplug
@@ -0,0 +1,2 @@
+#!/bin/sh
+/etc/init.d/relayd enabled && /etc/init.d/relayd start
diff --git a/package/network/services/relayd/files/relay.init b/package/network/services/relayd/files/relay.init
new file mode 100644
index 0000000..43ba6e1
--- /dev/null
+++ b/package/network/services/relayd/files/relay.init
@@ -0,0 +1,97 @@
+#!/bin/sh /etc/rc.common
+# Copyright (c) 2011-2012 OpenWrt.org
+START=80
+
+resolve_ifname() {
+ grep -qs "^ *$1:" /proc/net/dev && {
+ append args "-I $1"
+ append ifaces "$1"
+ }
+}
+
+resolve_network() {
+ local ifn
+ fixup_interface "$1"
+ config_get ifn "$1" ifname
+ [ -z "$ifn" ] && return 1
+ resolve_ifname "$ifn"
+}
+
+start_relay() {
+ local cfg="$1"
+
+ local args=""
+ local ifaces=""
+
+ config_get proto "$cfg" proto
+ [[ "$proto" == relay ]] || return 0
+
+ SERVICE_DAEMONIZE=1
+ SERVICE_WRITE_PID=1
+ SERVICE_PID_FILE="/var/run/relay-$cfg.pid"
+ [ -f "$SERVICE_PID_FILE" ] && {
+ if grep -q relayd "/proc/$(cat $SERVICE_PID_FILE)/cmdline"; then
+ return 0
+ else
+ rm -f "$SERVICE_PID_FILE"
+ fi
+ }
+
+ local net networks
+ config_get networks "$cfg" network
+ for net in $networks; do
+ resolve_network "$net" || {
+ return 1
+ }
+ done
+
+ local ifn ifnames
+ config_get ifnames "$cfg" ifname
+ for ifn in $ifnames; do
+ resolve_ifname "$ifn"
+ done
+
+ local ipaddr
+ config_get ipaddr "$cfg" ipaddr
+ [ -n "$ipaddr" ] && append args "-L $ipaddr"
+
+ local gateway
+ config_get gateway "$cfg" gateway
+ [ -n "$gateway" ] && append args "-G $gateway"
+
+ local expiry # = 30
+ config_get expiry "$cfg" expiry
+ [ -n "$expiry" ] && append args "-t $expiry"
+
+ local retry # = 5
+ config_get retry "$cfg" retry
+ [ -n "$retry" ] && append args "-p $retry"
+
+ local table # = 16800
+ config_get table "$cfg" table
+ [ -n "$table" ] && append args "-T $table"
+
+ local fwd_bcast # = 1
+ config_get_bool fwd_bcast "$cfg" forward_bcast 1
+ [ $fwd_bcast -eq 1 ] && append args "-B"
+
+ local fwd_dhcp # = 1
+ config_get_bool fwd_dhcp "$cfg" forward_dhcp 1
+ [ $fwd_dhcp -eq 1 ] && append args "-D"
+
+ service_start /usr/sbin/relayd $args
+}
+
+stop() {
+ for pid in /var/run/relay-*.pid; do
+ SERVICE_PID_FILE="$pid"
+ service_stop /usr/sbin/relayd
+ rm -f "$SERVICE_PID_FILE"
+ done
+}
+
+start() {
+ include /lib/network
+ config_load network
+ config_foreach start_relay interface
+}
diff --git a/package/network/services/samba36/.svn/entries b/package/network/services/samba36/.svn/entries
new file mode 100644
index 0000000..4c44349
--- /dev/null
+++ b/package/network/services/samba36/.svn/entries
@@ -0,0 +1,68 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/services/samba36
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-02-16T11:39:42.634536Z
+35610
+jogo
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+files
+dir
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+36662077486c341b072e180f0bd82061
+2013-02-16T11:39:42.634536Z
+35610
+jogo
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4241
+
diff --git a/package/network/services/samba36/.svn/text-base/Makefile.svn-base b/package/network/services/samba36/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..2842c98
--- /dev/null
+++ b/package/network/services/samba36/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,147 @@
+#
+# Copyright (C) 2007-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=samba
+PKG_VERSION:=3.6.11
+PKG_RELEASE:=2
+
+PKG_SOURCE_URL:=http://ftp.samba.org/pub/samba \
+ http://ftp.samba.org/pub/samba/old-versions
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_MD5SUM:=9039e0ab3e4fc632ff0a1a8f2433edb4
+
+PKG_LICENSE:=GPLv3
+PKG_LICENSE_FILES:=COPYING
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+
+PKG_BUILD_PARALLEL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+MAKE_PATH:=source3
+CONFIGURE_PATH:=source3
+
+PKG_BUILD_BIN:=$(PKG_BUILD_DIR)/$(MAKE_PATH)/bin
+
+define Package/samba36-server
+ SECTION:=net
+ CATEGORY:=Network
+ TITLE:=Samba 3.6 SMB/CIFS server
+ URL:=http://www.samba.org/
+ DEPENDS:=+USE_EGLIBC:librt
+endef
+
+define Package/samba36-client
+ SECTION:=net
+ CATEGORY:=Network
+ TITLE:=Samba 3.6 SMB/CIFS client
+ URL:=http://www.samba.org/
+ DEPENDS:=+libreadline +libncurses
+endef
+
+define Package/samba36-server/config
+ config PACKAGE_SAMBA_MAX_DEBUG_LEVEL
+ int "Maximum level of compiled-in debug messages"
+ depends PACKAGE_samba36-server || PACKAGE_samba36-client
+ default -1
+
+endef
+
+define Package/samba36-server/description
+ The Samba software suite is a collection of programs that implements the
+ SMB protocol for UNIX systems, allowing you to serve files and printers to
+ Windows, NT, OS/2 and DOS clients. This protocol is sometimes also referred
+ to as the LanManager or Netbios protocol.
+endef
+
+TARGET_CFLAGS += -DMAX_DEBUG_LEVEL=$(CONFIG_PACKAGE_SAMBA_MAX_DEBUG_LEVEL) -D__location__=\\\"\\\" -ffunction-sections -fdata-sections
+TARGET_LDFLAGS += -Wl,--gc-sections
+
+CONFIGURE_VARS += \
+ ac_cv_file__proc_sys_kernel_core_pattern=yes \
+ libreplace_cv_HAVE_C99_VSNPRINTF=yes \
+ libreplace_cv_HAVE_GETADDRINFO=yes \
+ libreplace_cv_HAVE_IFACE_IFCONF=yes \
+ LINUX_LFS_SUPPORT=yes \
+ samba_cv_CC_NEGATIVE_ENUM_VALUES=yes \
+ samba_cv_HAVE_GETTIMEOFDAY_TZ=yes \
+ samba_cv_HAVE_IFACE_IFCONF=yes \
+ samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=yes \
+ samba_cv_HAVE_SECURE_MKSTEMP=yes \
+ samba_cv_HAVE_WRFILE_KEYTAB=no \
+ samba_cv_USE_SETREUID=yes \
+ samba_cv_USE_SETRESUID=yes \
+ samba_cv_have_setreuid=yes \
+ samba_cv_have_setresuid=yes \
+ ac_cv_header_zlib_h=no \
+ samba_cv_zlib_1_2_3=no
+
+CONFIGURE_ARGS += \
+ --exec-prefix=/usr \
+ --prefix=/ \
+ --disable-avahi \
+ --disable-cups \
+ --disable-pie \
+ --disable-relro \
+ --disable-static \
+ --disable-swat \
+ --disable-shared-libs \
+ --with-codepagedir=/etc/samba \
+ --with-configdir=/etc/samba \
+ --with-included-iniparser \
+ --with-included-popt \
+ --with-lockdir=/var/lock \
+ --with-logfilebase=/var/log \
+ --with-nmbdsocketdir=/var/nmbd \
+ --with-piddir=/var/run \
+ --with-privatedir=/etc/samba \
+ --with-sendfile-support \
+ --without-cluster-support \
+ --without-ads \
+ --without-krb5 \
+ --without-ldap \
+ --without-pam \
+ --without-winbind \
+ --without-libtdb \
+ --without-libtalloc \
+ --without-libnetapi \
+ --without-libsmbclient \
+ --without-libsmbsharemodes \
+ --without-libaddns \
+ --with-shared-modules=pdb_tdbsam,pdb_wbc_sam,idmap_nss,nss_info_template,auth_winbind,auth_wbc,auth_domain
+
+MAKE_FLAGS += DYNEXP= PICFLAG= MODULES=
+
+define Package/samba36-server/install
+ $(INSTALL_DIR) $(1)/etc/config
+ $(INSTALL_DATA) ./files/samba.config $(1)/etc/config/samba
+ $(INSTALL_DIR) $(1)/etc/samba
+ $(INSTALL_DATA) ./files/smb.conf.template $(1)/etc/samba
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/codepages/lowcase.dat $(1)/etc/samba
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/codepages/upcase.dat $(1)/etc/samba
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/codepages/valid.dat $(1)/etc/samba
+ $(INSTALL_DIR) $(1)/etc/init.d
+ $(INSTALL_BIN) ./files/samba.init $(1)/etc/init.d/samba
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_BIN)/samba_multicall $(1)/usr/sbin
+ ln -sf samba_multicall $(1)/usr/sbin/smbd
+ ln -sf samba_multicall $(1)/usr/sbin/nmbd
+ ln -sf samba_multicall $(1)/usr/sbin/smbpasswd
+endef
+
+define Package/samba36-client/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_BIN)/smbclient $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_BIN)/nmblookup $(1)/usr/sbin
+endef
+
+$(eval $(call BuildPackage,samba36-client))
+$(eval $(call BuildPackage,samba36-server))
+
diff --git a/package/network/services/samba36/Makefile b/package/network/services/samba36/Makefile
new file mode 100644
index 0000000..2842c98
--- /dev/null
+++ b/package/network/services/samba36/Makefile
@@ -0,0 +1,147 @@
+#
+# Copyright (C) 2007-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=samba
+PKG_VERSION:=3.6.11
+PKG_RELEASE:=2
+
+PKG_SOURCE_URL:=http://ftp.samba.org/pub/samba \
+ http://ftp.samba.org/pub/samba/old-versions
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_MD5SUM:=9039e0ab3e4fc632ff0a1a8f2433edb4
+
+PKG_LICENSE:=GPLv3
+PKG_LICENSE_FILES:=COPYING
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+
+PKG_BUILD_PARALLEL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+MAKE_PATH:=source3
+CONFIGURE_PATH:=source3
+
+PKG_BUILD_BIN:=$(PKG_BUILD_DIR)/$(MAKE_PATH)/bin
+
+define Package/samba36-server
+ SECTION:=net
+ CATEGORY:=Network
+ TITLE:=Samba 3.6 SMB/CIFS server
+ URL:=http://www.samba.org/
+ DEPENDS:=+USE_EGLIBC:librt
+endef
+
+define Package/samba36-client
+ SECTION:=net
+ CATEGORY:=Network
+ TITLE:=Samba 3.6 SMB/CIFS client
+ URL:=http://www.samba.org/
+ DEPENDS:=+libreadline +libncurses
+endef
+
+define Package/samba36-server/config
+ config PACKAGE_SAMBA_MAX_DEBUG_LEVEL
+ int "Maximum level of compiled-in debug messages"
+ depends PACKAGE_samba36-server || PACKAGE_samba36-client
+ default -1
+
+endef
+
+define Package/samba36-server/description
+ The Samba software suite is a collection of programs that implements the
+ SMB protocol for UNIX systems, allowing you to serve files and printers to
+ Windows, NT, OS/2 and DOS clients. This protocol is sometimes also referred
+ to as the LanManager or Netbios protocol.
+endef
+
+TARGET_CFLAGS += -DMAX_DEBUG_LEVEL=$(CONFIG_PACKAGE_SAMBA_MAX_DEBUG_LEVEL) -D__location__=\\\"\\\" -ffunction-sections -fdata-sections
+TARGET_LDFLAGS += -Wl,--gc-sections
+
+CONFIGURE_VARS += \
+ ac_cv_file__proc_sys_kernel_core_pattern=yes \
+ libreplace_cv_HAVE_C99_VSNPRINTF=yes \
+ libreplace_cv_HAVE_GETADDRINFO=yes \
+ libreplace_cv_HAVE_IFACE_IFCONF=yes \
+ LINUX_LFS_SUPPORT=yes \
+ samba_cv_CC_NEGATIVE_ENUM_VALUES=yes \
+ samba_cv_HAVE_GETTIMEOFDAY_TZ=yes \
+ samba_cv_HAVE_IFACE_IFCONF=yes \
+ samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=yes \
+ samba_cv_HAVE_SECURE_MKSTEMP=yes \
+ samba_cv_HAVE_WRFILE_KEYTAB=no \
+ samba_cv_USE_SETREUID=yes \
+ samba_cv_USE_SETRESUID=yes \
+ samba_cv_have_setreuid=yes \
+ samba_cv_have_setresuid=yes \
+ ac_cv_header_zlib_h=no \
+ samba_cv_zlib_1_2_3=no
+
+CONFIGURE_ARGS += \
+ --exec-prefix=/usr \
+ --prefix=/ \
+ --disable-avahi \
+ --disable-cups \
+ --disable-pie \
+ --disable-relro \
+ --disable-static \
+ --disable-swat \
+ --disable-shared-libs \
+ --with-codepagedir=/etc/samba \
+ --with-configdir=/etc/samba \
+ --with-included-iniparser \
+ --with-included-popt \
+ --with-lockdir=/var/lock \
+ --with-logfilebase=/var/log \
+ --with-nmbdsocketdir=/var/nmbd \
+ --with-piddir=/var/run \
+ --with-privatedir=/etc/samba \
+ --with-sendfile-support \
+ --without-cluster-support \
+ --without-ads \
+ --without-krb5 \
+ --without-ldap \
+ --without-pam \
+ --without-winbind \
+ --without-libtdb \
+ --without-libtalloc \
+ --without-libnetapi \
+ --without-libsmbclient \
+ --without-libsmbsharemodes \
+ --without-libaddns \
+ --with-shared-modules=pdb_tdbsam,pdb_wbc_sam,idmap_nss,nss_info_template,auth_winbind,auth_wbc,auth_domain
+
+MAKE_FLAGS += DYNEXP= PICFLAG= MODULES=
+
+define Package/samba36-server/install
+ $(INSTALL_DIR) $(1)/etc/config
+ $(INSTALL_DATA) ./files/samba.config $(1)/etc/config/samba
+ $(INSTALL_DIR) $(1)/etc/samba
+ $(INSTALL_DATA) ./files/smb.conf.template $(1)/etc/samba
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/codepages/lowcase.dat $(1)/etc/samba
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/codepages/upcase.dat $(1)/etc/samba
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/codepages/valid.dat $(1)/etc/samba
+ $(INSTALL_DIR) $(1)/etc/init.d
+ $(INSTALL_BIN) ./files/samba.init $(1)/etc/init.d/samba
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_BIN)/samba_multicall $(1)/usr/sbin
+ ln -sf samba_multicall $(1)/usr/sbin/smbd
+ ln -sf samba_multicall $(1)/usr/sbin/nmbd
+ ln -sf samba_multicall $(1)/usr/sbin/smbpasswd
+endef
+
+define Package/samba36-client/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_BIN)/smbclient $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_BIN)/nmblookup $(1)/usr/sbin
+endef
+
+$(eval $(call BuildPackage,samba36-client))
+$(eval $(call BuildPackage,samba36-server))
+
diff --git a/package/network/services/samba36/files/.svn/entries b/package/network/services/samba36/files/.svn/entries
new file mode 100644
index 0000000..18ed609
--- /dev/null
+++ b/package/network/services/samba36/files/.svn/entries
@@ -0,0 +1,130 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/services/samba36/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-05-28T03:52:12.917836Z
+31940
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+smb.conf.template
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+b498b14649537c4f6f9255ddcd0e32c3
+2012-03-30T09:46:16.426168Z
+31150
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+764
+
+samba.init
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+fdbb9a89d3b84a379e7d49f2f86d02dd
+2012-05-28T03:52:12.917836Z
+31940
+jow
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2488
+
+samba.config
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+e49c3ed12b2a3507d915ff486c9b5e42
+2012-02-13T03:51:59.372441Z
+30489
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+129
+
diff --git a/package/network/services/samba36/files/.svn/prop-base/samba.init.svn-base b/package/network/services/samba36/files/.svn/prop-base/samba.init.svn-base
new file mode 100644
index 0000000..869ac71
--- /dev/null
+++ b/package/network/services/samba36/files/.svn/prop-base/samba.init.svn-base
@@ -0,0 +1,5 @@
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/network/services/samba36/files/.svn/text-base/samba.config.svn-base b/package/network/services/samba36/files/.svn/text-base/samba.config.svn-base
new file mode 100644
index 0000000..c79db0d
--- /dev/null
+++ b/package/network/services/samba36/files/.svn/text-base/samba.config.svn-base
@@ -0,0 +1,6 @@
+config samba
+ option 'name' 'OpenWrt'
+ option 'workgroup' 'WORKGROUP'
+ option 'description' 'OpenWrt'
+ option 'homes' '1'
+
diff --git a/package/network/services/samba36/files/.svn/text-base/samba.init.svn-base b/package/network/services/samba36/files/.svn/text-base/samba.init.svn-base
new file mode 100644
index 0000000..61398d8
--- /dev/null
+++ b/package/network/services/samba36/files/.svn/text-base/samba.init.svn-base
@@ -0,0 +1,97 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2008-2012 OpenWrt.org
+
+START=60
+
+smb_header() {
+ local interface
+ config_get interface $1 interface "loopback lan"
+
+ # resolve interfaces
+ local interfaces=$(
+ . /lib/functions/network.sh
+
+ local net
+ for net in $interface; do
+ local device
+ network_get_device device "$net" && {
+ local subnet
+ network_get_subnet subnet "$net" && echo -n "$subnet "
+ network_get_subnet6 subnet "$net" && echo -n "$subnet "
+ }
+
+ echo -n "${device:-$net} "
+ done
+ )
+
+ local name workgroup description charset
+ local hostname="$(uci_get system.@system[0].hostname)"
+
+ config_get name $1 name "${hostname:-OpenWrt}"
+ config_get workgroup $1 workgroup "${hostname:-OpenWrt}"
+ config_get description $1 description "Samba on ${hostname:-OpenWrt}"
+ config_get charset $1 charset "UTF-8"
+
+ mkdir -p /var/etc
+ sed -e "s#|NAME|#$name#g" \
+ -e "s#|WORKGROUP|#$workgroup#g" \
+ -e "s#|DESCRIPTION|#$description#g" \
+ -e "s#|INTERFACES|#$interfaces#g" \
+ -e "s#|CHARSET|#$charset#g" \
+ /etc/samba/smb.conf.template > /var/etc/smb.conf
+
+ local homes
+ config_get_bool homes $1 homes 0
+ [ $homes -gt 0 ] && {
+ cat <<EOT >> /var/etc/smb.conf
+
+[homes]
+ comment = Home Directories
+ browsable = no
+ read only = no
+ create mode = 0750
+EOT
+ }
+
+ [ -L /etc/samba/smb.conf ] || ln -nsf /var/etc/smb.conf /etc/samba/smb.conf
+}
+
+smb_add_share() {
+ local name
+ local path
+ local users
+ local read_only
+ local guest_ok
+ local create_mask
+ local dir_mask
+
+ config_get name $1 name
+ config_get path $1 path
+ config_get users $1 users
+ config_get read_only $1 read_only
+ config_get guest_ok $1 guest_ok
+ config_get create_mask $1 create_mask
+ config_get dir_mask $1 dir_mask
+
+ [ -z "$name" -o -z "$path" ] && return
+
+ echo -e "\n[$name]\n\tpath = $path" >> /var/etc/smb.conf
+ [ -n "$users" ] && echo -e "\tvalid users = $users" >> /var/etc/smb.conf
+ [ -n "$read_only" ] && echo -e "\tread only = $read_only" >> /var/etc/smb.conf
+ [ -n "$guest_ok" ] && echo -e "\tguest ok = $guest_ok" >> /var/etc/smb.conf
+ [ -n "$create_mask" ] && echo -e "\tcreate mask = $create_mask" >> /var/etc/smb.conf
+ [ -n "$dir_mask" ] && echo -e "\tdirectory mask = $dir_mask" >> /var/etc/smb.conf
+}
+
+start() {
+ config_load samba
+ config_foreach smb_header samba
+ config_foreach smb_add_share sambashare
+ service_start /usr/sbin/smbd -D
+ service_start /usr/sbin/nmbd -D
+}
+
+stop() {
+ service_stop /usr/sbin/smbd
+ service_stop /usr/sbin/nmbd
+}
diff --git a/package/network/services/samba36/files/.svn/text-base/smb.conf.template.svn-base b/package/network/services/samba36/files/.svn/text-base/smb.conf.template.svn-base
new file mode 100644
index 0000000..38a3855
--- /dev/null
+++ b/package/network/services/samba36/files/.svn/text-base/smb.conf.template.svn-base
@@ -0,0 +1,34 @@
+[global]
+ netbios name = |NAME|
+ display charset = |CHARSET|
+ interfaces = |INTERFACES|
+ server string = |DESCRIPTION|
+ unix charset = |CHARSET|
+ workgroup = |WORKGROUP|
+ browseable = yes
+ deadtime = 30
+ domain master = yes
+ encrypt passwords = true
+ enable core files = no
+ guest account = nobody
+ guest ok = yes
+ invalid users = root
+ local master = yes
+ load printers = no
+ map to guest = Bad User
+ max protocol = SMB2
+ min receivefile size = 16384
+ null passwords = yes
+ obey pam restrictions = yes
+ os level = 20
+ passdb backend = smbpasswd
+ preferred master = yes
+ printable = no
+ security = user
+ smb encrypt = disabled
+ smb passwd file = /etc/samba/smbpasswd
+ socket options = TCP_NODELAY IPTOS_LOWDELAY
+ syslog = 2
+ use sendfile = yes
+ writeable = yes
+
diff --git a/package/network/services/samba36/files/samba.config b/package/network/services/samba36/files/samba.config
new file mode 100644
index 0000000..c79db0d
--- /dev/null
+++ b/package/network/services/samba36/files/samba.config
@@ -0,0 +1,6 @@
+config samba
+ option 'name' 'OpenWrt'
+ option 'workgroup' 'WORKGROUP'
+ option 'description' 'OpenWrt'
+ option 'homes' '1'
+
diff --git a/package/network/services/samba36/files/samba.init b/package/network/services/samba36/files/samba.init
new file mode 100755
index 0000000..61398d8
--- /dev/null
+++ b/package/network/services/samba36/files/samba.init
@@ -0,0 +1,97 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2008-2012 OpenWrt.org
+
+START=60
+
+smb_header() {
+ local interface
+ config_get interface $1 interface "loopback lan"
+
+ # resolve interfaces
+ local interfaces=$(
+ . /lib/functions/network.sh
+
+ local net
+ for net in $interface; do
+ local device
+ network_get_device device "$net" && {
+ local subnet
+ network_get_subnet subnet "$net" && echo -n "$subnet "
+ network_get_subnet6 subnet "$net" && echo -n "$subnet "
+ }
+
+ echo -n "${device:-$net} "
+ done
+ )
+
+ local name workgroup description charset
+ local hostname="$(uci_get system.@system[0].hostname)"
+
+ config_get name $1 name "${hostname:-OpenWrt}"
+ config_get workgroup $1 workgroup "${hostname:-OpenWrt}"
+ config_get description $1 description "Samba on ${hostname:-OpenWrt}"
+ config_get charset $1 charset "UTF-8"
+
+ mkdir -p /var/etc
+ sed -e "s#|NAME|#$name#g" \
+ -e "s#|WORKGROUP|#$workgroup#g" \
+ -e "s#|DESCRIPTION|#$description#g" \
+ -e "s#|INTERFACES|#$interfaces#g" \
+ -e "s#|CHARSET|#$charset#g" \
+ /etc/samba/smb.conf.template > /var/etc/smb.conf
+
+ local homes
+ config_get_bool homes $1 homes 0
+ [ $homes -gt 0 ] && {
+ cat <<EOT >> /var/etc/smb.conf
+
+[homes]
+ comment = Home Directories
+ browsable = no
+ read only = no
+ create mode = 0750
+EOT
+ }
+
+ [ -L /etc/samba/smb.conf ] || ln -nsf /var/etc/smb.conf /etc/samba/smb.conf
+}
+
+smb_add_share() {
+ local name
+ local path
+ local users
+ local read_only
+ local guest_ok
+ local create_mask
+ local dir_mask
+
+ config_get name $1 name
+ config_get path $1 path
+ config_get users $1 users
+ config_get read_only $1 read_only
+ config_get guest_ok $1 guest_ok
+ config_get create_mask $1 create_mask
+ config_get dir_mask $1 dir_mask
+
+ [ -z "$name" -o -z "$path" ] && return
+
+ echo -e "\n[$name]\n\tpath = $path" >> /var/etc/smb.conf
+ [ -n "$users" ] && echo -e "\tvalid users = $users" >> /var/etc/smb.conf
+ [ -n "$read_only" ] && echo -e "\tread only = $read_only" >> /var/etc/smb.conf
+ [ -n "$guest_ok" ] && echo -e "\tguest ok = $guest_ok" >> /var/etc/smb.conf
+ [ -n "$create_mask" ] && echo -e "\tcreate mask = $create_mask" >> /var/etc/smb.conf
+ [ -n "$dir_mask" ] && echo -e "\tdirectory mask = $dir_mask" >> /var/etc/smb.conf
+}
+
+start() {
+ config_load samba
+ config_foreach smb_header samba
+ config_foreach smb_add_share sambashare
+ service_start /usr/sbin/smbd -D
+ service_start /usr/sbin/nmbd -D
+}
+
+stop() {
+ service_stop /usr/sbin/smbd
+ service_stop /usr/sbin/nmbd
+}
diff --git a/package/network/services/samba36/files/smb.conf.template b/package/network/services/samba36/files/smb.conf.template
new file mode 100644
index 0000000..38a3855
--- /dev/null
+++ b/package/network/services/samba36/files/smb.conf.template
@@ -0,0 +1,34 @@
+[global]
+ netbios name = |NAME|
+ display charset = |CHARSET|
+ interfaces = |INTERFACES|
+ server string = |DESCRIPTION|
+ unix charset = |CHARSET|
+ workgroup = |WORKGROUP|
+ browseable = yes
+ deadtime = 30
+ domain master = yes
+ encrypt passwords = true
+ enable core files = no
+ guest account = nobody
+ guest ok = yes
+ invalid users = root
+ local master = yes
+ load printers = no
+ map to guest = Bad User
+ max protocol = SMB2
+ min receivefile size = 16384
+ null passwords = yes
+ obey pam restrictions = yes
+ os level = 20
+ passdb backend = smbpasswd
+ preferred master = yes
+ printable = no
+ security = user
+ smb encrypt = disabled
+ smb passwd file = /etc/samba/smbpasswd
+ socket options = TCP_NODELAY IPTOS_LOWDELAY
+ syslog = 2
+ use sendfile = yes
+ writeable = yes
+
diff --git a/package/network/services/samba36/patches/.svn/entries b/package/network/services/samba36/patches/.svn/entries
new file mode 100644
index 0000000..adffc9b
--- /dev/null
+++ b/package/network/services/samba36/patches/.svn/entries
@@ -0,0 +1,640 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/services/samba36/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-02-16T11:39:42.634536Z
+35610
+jogo
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+260-remove_samr.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+bcc3df4f80df5fa8c5730b33cd2cbf5a
+2013-01-29T13:18:56.624258Z
+35382
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3737
+
+240-remove_dfs_api.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+cadd6710d736c44daa8ec2da49e9a115
+2013-01-29T13:18:56.624258Z
+35382
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1721
+
+110-multicall.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+63636a9980b58a2766004c5ef282deb6
+2013-01-29T13:18:56.624258Z
+35382
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4158
+
+250-remove_domain_logon.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+8077193a102a15366278e4df69ea4f08
+2013-01-29T13:18:56.624258Z
+35382
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4826
+
+200-remove_printer_support.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+dd982e92f072d1602647856a45371c44
+2013-01-29T13:18:56.624258Z
+35382
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+8508
+
+210-remove_ad_support.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+2d028f207b9f33d362daf1e4d30d6001
+2013-01-29T13:18:56.624258Z
+35382
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2353
+
+330-librpc_default_print.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+1334cab9c2be0c973e3f6af5583958e3
+2013-01-29T13:18:56.624258Z
+35382
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+355370
+
+300-assert_debug_level.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+1c8f2817b1a580be2c27e22e37affd73
+2012-02-13T21:30:23.827711Z
+30512
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+377
+
+320-debug_level_checks.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+8305526ef72ffbc9262fb7cad2e08049
+2012-02-13T23:59:07.874419Z
+30513
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+627
+
+220-remove_services.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+a83ea6576f90f443343be8e8d063bbab
+2013-01-29T13:18:56.624258Z
+35382
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2435
+
+270-remove_registry_backend.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+f25742cbc4a89ff73a90c598ce62e866
+2013-01-29T13:18:56.624258Z
+35382
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1295
+
+290-remove_lsa.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+be44576a17eed4d01576ead4e8944950
+2013-01-29T13:18:56.624258Z
+35382
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1828
+
+230-remove_winreg_support.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+7678f8f0e1c2a65c38ecee996dcd3e94
+2013-01-29T13:18:56.624258Z
+35382
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3554
+
+100-configure_fixes.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+d4ca4ff82a32a4c46bc1ece76e06a298
+2013-01-29T13:18:56.624258Z
+35382
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+605
+
+280-strip_srvsvc.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+f21da1d2b77b32498d098fc2c3d341ae
+2012-02-13T20:26:29.312310Z
+30509
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3549
+
+120-add_missing_ifdef.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+be0ec8cde6cc1344a766c8b206b4a4c5
+2012-02-13T16:51:18.057494Z
+30505
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+693
+
+111-owrt_smbpasswd.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+e4d21fd583ee8874ce493b8ec871fe57
+2013-02-16T11:39:42.634536Z
+35610
+jogo
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+6634
+
+310-remove_error_strings.patch
+file
+
+
+
+
+2013-03-17T12:13:19.000000Z
+58607010a92df76a13b73e00699ed66e
+2013-01-29T13:18:56.624258Z
+35382
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+7720
+
diff --git a/package/network/services/samba36/patches/.svn/text-base/100-configure_fixes.patch.svn-base b/package/network/services/samba36/patches/.svn/text-base/100-configure_fixes.patch.svn-base
new file mode 100644
index 0000000..e40a133
--- /dev/null
+++ b/package/network/services/samba36/patches/.svn/text-base/100-configure_fixes.patch.svn-base
@@ -0,0 +1,14 @@
+--- a/source3/configure
++++ b/source3/configure
+@@ -13318,10 +13318,7 @@ if test x"$libreplace_cv_HAVE_GETADDRINF
+ # see bug 5910, use our replacements if we detect
+ # a broken system.
+ if test "$cross_compiling" = yes; then :
+- { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+-as_fn_error $? "cannot run test program while cross compiling
+-See \`config.log' for more details" "$LINENO" 5; }
++ $as_echo "assuming valid getaddrinfo without bug 5910" >&2
+ else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h. */
diff --git a/package/network/services/samba36/patches/.svn/text-base/110-multicall.patch.svn-base b/package/network/services/samba36/patches/.svn/text-base/110-multicall.patch.svn-base
new file mode 100644
index 0000000..a01bc58
--- /dev/null
+++ b/package/network/services/samba36/patches/.svn/text-base/110-multicall.patch.svn-base
@@ -0,0 +1,117 @@
+--- a/source3/Makefile.in
++++ b/source3/Makefile.in
+@@ -73,20 +73,20 @@ LDAP_LIBS=@LDAP_LIBS@
+ NSCD_LIBS=@NSCD_LIBS@
+ UUID_LIBS=@UUID_LIBS@
+ LIBWBCLIENT=@LIBWBCLIENT_STATIC@ @LIBWBCLIENT_SHARED@
+-LIBWBCLIENT_LIBS=@LIBWBCLIENT_LIBS@
++LIBWBCLIENT_LIBS=@LIBWBCLIENT_STATIC@
+ PTHREAD_LDFLAGS=@PTHREAD_LDFLAGS@
+ PTHREAD_CFLAGS=@PTHREAD_CFLAGS@
+ DNSSD_LIBS=@DNSSD_LIBS@
+ AVAHI_LIBS=@AVAHI_LIBS@
+ POPT_LIBS=@POPTLIBS@
+ LIBTALLOC=@LIBTALLOC_STATIC@ @LIBTALLOC_SHARED@
+-LIBTALLOC_LIBS=@LIBTALLOC_LIBS@
++LIBTALLOC_LIBS=@LIBTALLOC_STATIC@
+ LIBREPLACE_LIBS=@LIBREPLACE_LIBS@
+ LIBTDB=@LIBTDB_STATIC@ @LIBTDB_SHARED@
+-LIBTDB_LIBS=@LIBTDB_LIBS@
++LIBTDB_LIBS=@LIBTDB_STATIC@
+ TDB_DEPS=@TDB_DEPS@
+ LIBNETAPI=@LIBNETAPI_STATIC@ @LIBNETAPI_SHARED@
+-LIBNETAPI_LIBS=@LIBNETAPI_LIBS@
++LIBNETAPI_LIBS=@LIBNETAPI_STATIC@
+ LIBSMBCLIENT_LIBS=@LIBSMBCLIENT_LIBS@
+ LIBSMBSHAREMODES_LIBS=@LIBSMBSHAREMODES_LIBS@
+
+@@ -214,7 +214,7 @@ PATH_FLAGS = -DSMB_PASSWD_FILE=\"$(SMB_P
+
+ # Note that all executable programs now provide for an optional executable suffix.
+
+-SBIN_PROGS = bin/smbd@EXEEXT@ bin/nmbd@EXEEXT@ @SWAT_SBIN_TARGETS@ @EXTRA_SBIN_PROGS@
++SBIN_PROGS = bin/samba_multicall@EXEEXT@ bin/smbd@EXEEXT@ bin/nmbd@EXEEXT@ @SWAT_SBIN_TARGETS@ @EXTRA_SBIN_PROGS@
+
+ BIN_PROGS1 = bin/smbclient@EXEEXT@ bin/net@EXEEXT@ bin/smbspool@EXEEXT@ \
+ bin/testparm@EXEEXT@ bin/smbstatus@EXEEXT@ bin/smbget@EXEEXT@ \
+@@ -1775,6 +1775,42 @@ bin/.dummy:
+ dir=bin $(MAKEDIR); fi
+ @: >> $@ || : > $@ # what a fancy emoticon!
+
++smbd/server_multicall.o: smbd/server.c smbd/server.o
++ @echo Compiling $<.c
++ @$(COMPILE_CC_PATH) -Dmain=smbd_main && exit 0;\
++ echo "The following command failed:" 1>&2;\
++ echo "$(COMPILE_CC_PATH)" 1>&2;\
++ $(COMPILE_CC_PATH) >/dev/null 2>&1
++
++nmbd/nmbd_multicall.o: nmbd/nmbd.c nmbd/nmbd.o
++ @echo Compiling $<.c
++ @$(COMPILE_CC_PATH) -Dmain=nmbd_main && exit 0;\
++ echo "The following command failed:" 1>&2;\
++ echo "$(COMPILE_CC_PATH)" 1>&2;\
++ $(COMPILE_CC_PATH) >/dev/null 2>&1
++
++utils/smbpasswd_multicall.o: utils/smbpasswd.c utils/smbpasswd.o
++ @echo Compiling $<.c
++ @$(COMPILE_CC_PATH) -Dmain=smbpasswd_main && exit 0;\
++ echo "The following command failed:" 1>&2;\
++ echo "$(COMPILE_CC_PATH)" 1>&2;\
++ $(COMPILE_CC_PATH) >/dev/null 2>&1
++
++SMBD_MULTI_O = $(patsubst smbd/server.o,smbd/server_multicall.o,$(SMBD_OBJ))
++NMBD_MULTI_O = $(patsubst nmbd/nmbd.o,nmbd/nmbd_multicall.o,$(filter-out $(LIB_DUMMY_OBJ),$(NMBD_OBJ)))
++SMBPASSWD_MULTI_O = $(patsubst utils/smbpasswd.o,utils/smbpasswd_multicall.o,$(filter-out $(LIB_DUMMY_OBJ),$(SMBPASSWD_OBJ)))
++MULTI_O = multi.o
++
++MULTICALL_O = $(sort $(SMBD_MULTI_O) $(NMBD_MULTI_O) $(SMBPASSWD_MULTI_O) $(MULTI_O))
++
++bin/samba_multicall@EXEEXT@: $(BINARY_PREREQS) $(MULTICALL_O) $(LIBTALLOC) $(LIBTDB) $(LIBWBCLIENT) @BUILD_POPT@
++ @echo Linking $@
++ @$(CC) -o $@ $(MULTICALL_O) $(LDFLAGS) $(LDAP_LIBS) @SMBD_FAM_LIBS@ \
++ $(KRB5LIBS) $(DYNEXP) $(PRINT_LIBS) $(AUTH_LIBS) \
++ $(ACL_LIBS) $(PASSDB_LIBS) $(LIBS) $(DNSSD_LIBS) $(AVAHI_LIBS) \
++ $(POPT_LIBS) @SMBD_LIBS@ $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) \
++ $(LIBWBCLIENT_LIBS) $(ZLIB_LIBS)
++
+ bin/smbd@EXEEXT@: $(BINARY_PREREQS) $(SMBD_OBJ) $(LIBTALLOC) $(LIBTDB) $(LIBWBCLIENT) @BUILD_POPT@
+ @echo Linking $@
+ @$(CC) -o $@ $(SMBD_OBJ) $(LDFLAGS) $(LDAP_LIBS) @SMBD_FAM_LIBS@ \
+--- /dev/null
++++ b/source3/multi.c
+@@ -0,0 +1,35 @@
++#include <stdio.h>
++#include <string.h>
++
++extern int smbd_main(int argc, char **argv);
++extern int nmbd_main(int argc, char **argv);
++extern int smbpasswd_main(int argc, char **argv);
++
++static struct {
++ const char *name;
++ int (*func)(int argc, char **argv);
++} multicall[] = {
++ { "smbd", smbd_main },
++ { "nmbd", nmbd_main },
++ { "smbpasswd", smbpasswd_main },
++};
++
++#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
++
++int main(int argc, char **argv)
++{
++ int i;
++
++ for (i = 0; i < ARRAY_SIZE(multicall); i++) {
++ if (strstr(argv[0], multicall[i].name))
++ return multicall[i].func(argc, argv);
++ }
++
++ fprintf(stderr, "Invalid multicall command, available commands:");
++ for (i = 0; i < ARRAY_SIZE(multicall); i++)
++ fprintf(stderr, " %s", multicall[i].name);
++
++ fprintf(stderr, "\n");
++
++ return 1;
++}
diff --git a/package/network/services/samba36/patches/.svn/text-base/111-owrt_smbpasswd.patch.svn-base b/package/network/services/samba36/patches/.svn/text-base/111-owrt_smbpasswd.patch.svn-base
new file mode 100644
index 0000000..7d852c4
--- /dev/null
+++ b/package/network/services/samba36/patches/.svn/text-base/111-owrt_smbpasswd.patch.svn-base
@@ -0,0 +1,277 @@
+--- a/source3/Makefile.in
++++ b/source3/Makefile.in
+@@ -1017,7 +1017,7 @@ TEST_LP_LOAD_OBJ = param/test_lp_load.o
+
+ PASSWD_UTIL_OBJ = utils/passwd_util.o
+
+-SMBPASSWD_OBJ = utils/smbpasswd.o $(PASSWD_UTIL_OBJ) $(PASSCHANGE_OBJ) \
++SMBPASSWD_OBJ = utils/owrt_smbpasswd.o $(PASSWD_UTIL_OBJ) $(PASSCHANGE_OBJ) \
+ $(PARAM_OBJ) $(LIBSMB_OBJ) $(PASSDB_OBJ) \
+ $(GROUPDB_OBJ) $(LIB_NONSMBD_OBJ) $(KRBCLIENT_OBJ) \
+ $(POPT_LIB_OBJ) $(SMBLDAP_OBJ) \
+@@ -1789,7 +1789,7 @@ nmbd/nmbd_multicall.o: nmbd/nmbd.c nmbd/
+ echo "$(COMPILE_CC_PATH)" 1>&2;\
+ $(COMPILE_CC_PATH) >/dev/null 2>&1
+
+-utils/smbpasswd_multicall.o: utils/smbpasswd.c utils/smbpasswd.o
++utils/smbpasswd_multicall.o: utils/owrt_smbpasswd.c utils/owrt_smbpasswd.o
+ @echo Compiling $<.c
+ @$(COMPILE_CC_PATH) -Dmain=smbpasswd_main && exit 0;\
+ echo "The following command failed:" 1>&2;\
+@@ -1798,7 +1798,7 @@ utils/smbpasswd_multicall.o: utils/smbpa
+
+ SMBD_MULTI_O = $(patsubst smbd/server.o,smbd/server_multicall.o,$(SMBD_OBJ))
+ NMBD_MULTI_O = $(patsubst nmbd/nmbd.o,nmbd/nmbd_multicall.o,$(filter-out $(LIB_DUMMY_OBJ),$(NMBD_OBJ)))
+-SMBPASSWD_MULTI_O = $(patsubst utils/smbpasswd.o,utils/smbpasswd_multicall.o,$(filter-out $(LIB_DUMMY_OBJ),$(SMBPASSWD_OBJ)))
++SMBPASSWD_MULTI_O = $(patsubst utils/owrt_smbpasswd.o,utils/smbpasswd_multicall.o,$(filter-out $(LIB_DUMMY_OBJ),$(SMBPASSWD_OBJ)))
+ MULTI_O = multi.o
+
+ MULTICALL_O = $(sort $(SMBD_MULTI_O) $(NMBD_MULTI_O) $(SMBPASSWD_MULTI_O) $(MULTI_O))
+--- /dev/null
++++ b/source3/utils/owrt_smbpasswd.c
+@@ -0,0 +1,245 @@
++/*
++ * Copyright (C) 2012 Felix Fietkau <nbd@openwrt.org>
++ * Copyright (C) 2008 John Crispin <blogic@openwrt.org>
++ *
++ * 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 of the License, 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; if not, write to the Free Software Foundation, Inc., 675
++ * Mass Ave, Cambridge, MA 02139, USA. */
++
++#include "includes.h"
++#include <endian.h>
++#include <stdio.h>
++
++static char buf[256];
++
++static void md4hash(const char *passwd, uchar p16[16])
++{
++ int len;
++ smb_ucs2_t wpwd[129];
++ int i;
++
++ len = strlen(passwd);
++ for (i = 0; i < len; i++) {
++#if __BYTE_ORDER == __LITTLE_ENDIAN
++ wpwd[i] = (unsigned char)passwd[i];
++#else
++ wpwd[i] = (unsigned char)passwd[i] << 8;
++#endif
++ }
++ wpwd[i] = 0;
++
++ len = len * sizeof(int16);
++ mdfour(p16, (unsigned char *)wpwd, len);
++ ZERO_STRUCT(wpwd);
++}
++
++
++static bool find_passwd_line(FILE *fp, const char *user, char **next)
++{
++ char *p1;
++
++ while (!feof(fp)) {
++ if(!fgets(buf, sizeof(buf) - 1, fp))
++ continue;
++
++ p1 = strchr(buf, ':');
++
++ if (p1 - buf != strlen(user))
++ continue;
++
++ if (strncmp(buf, user, p1 - buf) != 0)
++ continue;
++
++ if (next)
++ *next = p1;
++ return true;
++ }
++ return false;
++}
++
++/* returns -1 if user is not present in /etc/passwd*/
++static int find_uid_for_user(const char *user)
++{
++ FILE *fp;
++ char *p1, *p2, *p3;
++ int ret = -1;
++
++ fp = fopen("/etc/passwd", "r");
++ if (!fp) {
++ printf("failed to open /etc/passwd");
++ goto out;
++ }
++
++ if (!find_passwd_line(fp, user, &p1)) {
++ printf("User %s not found or invalid in /etc/passwd\n", user);
++ goto out;
++ }
++
++ p2 = strchr(p1 + 1, ':');
++ if (!p2)
++ goto out;
++
++ p2++;
++ p3 = strchr(p2, ':');
++ if (!p1)
++ goto out;
++
++ *p3 = '\0';
++ ret = atoi(p2);
++
++out:
++ if(fp)
++ fclose(fp);
++ return ret;
++}
++
++static void smbpasswd_write_user(FILE *fp, const char *user, int uid, const char *password)
++{
++ static uchar nt_p16[NT_HASH_LEN];
++ int len = 0;
++ int i;
++
++ md4hash(strdup(password), nt_p16);
++
++ len += snprintf(buf + len, sizeof(buf) - len, "%s:%u:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:", user, uid);
++ for(i = 0; i < NT_HASH_LEN; i++)
++ len += snprintf(buf + len, sizeof(buf) - len, "%02X", nt_p16[i]);
++
++ snprintf(buf + len, sizeof(buf) - len, ":[U ]:LCT-00000001:\n");
++ fputs(buf, fp);
++}
++
++static void smbpasswd_delete_user(FILE *fp)
++{
++ fpos_t r_pos, w_pos;
++ int len = strlen(buf);
++
++ fgetpos(fp, &r_pos);
++ w_pos = r_pos;
++ w_pos.__pos -= len;
++
++ while (fgets(buf, sizeof(buf) - 1, fp)) {
++ int cur_len = strlen(buf);
++
++ fsetpos(fp, &w_pos);
++ fputs(buf, fp);
++ r_pos.__pos += cur_len;
++ w_pos.__pos += cur_len;
++ fsetpos(fp, &r_pos);
++ }
++
++ ftruncate(fileno(fp), w_pos.__pos);
++}
++
++static int usage(const char *progname)
++{
++ fprintf(stderr,
++ "Usage: %s [options] <username>\n"
++ "\n"
++ "Options:\n"
++ " -s read password from stdin\n"
++ " -a add user\n"
++ " -x delete user\n",
++ progname);
++ return 1;
++}
++
++int main(int argc, char **argv)
++{
++ const char *prog = argv[0];
++ const char *user;
++ char *pw1, *pw2;
++ FILE *fp;
++ bool add = false, delete = false, get_stdin = false, found;
++ int ch;
++ int uid;
++
++ TALLOC_CTX *frame = talloc_stackframe();
++
++ while ((ch = getopt(argc, argv, "asx")) != EOF) {
++ switch (ch) {
++ case 's':
++ get_stdin = true;
++ break;
++ case 'a':
++ add = true;
++ break;
++ case 'x':
++ delete = true;
++ break;
++ default:
++ return usage(prog);
++ }
++ }
++
++ if (add && delete)
++ return usage(prog);
++
++ argc -= optind;
++ argv += optind;
++
++ if (!argc)
++ return usage(prog);
++
++ user = argv[0];
++ if (!delete) {
++ uid = find_uid_for_user(user);
++ if (uid < 0) {
++ fprintf(stderr, "Could not find user '%s' in /etc/passwd\n", user);
++ return 2;
++ }
++ }
++
++ fp = fopen("/etc/samba/smbpasswd", "r+");
++ if(!fp) {
++ fprintf(stderr, "Failed to open /etc/samba/smbpasswd");
++ return 3;
++ }
++
++ found = find_passwd_line(fp, user, NULL);
++ if (!add && !found) {
++ fprintf(stderr, "Could not find user '%s' in /etc/samba/smbpasswd\n", user);
++ return 3;
++ }
++
++ if (delete) {
++ smbpasswd_delete_user(fp);
++ goto out;
++ }
++
++ pw1 = get_pass("New SMB password:", get_stdin);
++ if (!pw1)
++ pw1 = strdup("");
++
++ pw2 = get_pass("Retype SMB password:", get_stdin);
++ if (!pw2)
++ pw2 = strdup("");
++
++ if (strcmp(pw1, pw2) != 0) {
++ fprintf(stderr, "Mismatch - password unchanged.\n");
++ goto out_free;
++ }
++
++ if (found)
++ fseek(fp, -strlen(buf), SEEK_CUR);
++ smbpasswd_write_user(fp, user, uid, pw2);
++
++out_free:
++ free(pw1);
++ free(pw2);
++out:
++ fclose(fp);
++ TALLOC_FREE(frame);
++
++ return 0;
++}
diff --git a/package/network/services/samba36/patches/.svn/text-base/120-add_missing_ifdef.patch.svn-base b/package/network/services/samba36/patches/.svn/text-base/120-add_missing_ifdef.patch.svn-base
new file mode 100644
index 0000000..dbd9adc
--- /dev/null
+++ b/package/network/services/samba36/patches/.svn/text-base/120-add_missing_ifdef.patch.svn-base
@@ -0,0 +1,26 @@
+--- a/source3/librpc/rpc/rpc_common.c
++++ b/source3/librpc/rpc/rpc_common.c
+@@ -119,9 +119,11 @@ static bool initialize_interfaces(void)
+ if (!smb_register_ndr_interface(&ndr_table_netdfs)) {
+ return false;
+ }
++#ifdef DEVELOPER
+ if (!smb_register_ndr_interface(&ndr_table_rpcecho)) {
+ return false;
+ }
++#endif
+ if (!smb_register_ndr_interface(&ndr_table_initshutdown)) {
+ return false;
+ }
+--- a/source3/rpcclient/rpcclient.c
++++ b/source3/rpcclient/rpcclient.c
+@@ -628,7 +628,9 @@ static struct cmd_set *rpcclient_command
+ netlogon_commands,
+ srvsvc_commands,
+ dfs_commands,
++#ifdef DEVELOPER
+ echo_commands,
++#endif
+ epmapper_commands,
+ shutdown_commands,
+ test_commands,
diff --git a/package/network/services/samba36/patches/.svn/text-base/200-remove_printer_support.patch.svn-base b/package/network/services/samba36/patches/.svn/text-base/200-remove_printer_support.patch.svn-base
new file mode 100644
index 0000000..19d357f
--- /dev/null
+++ b/package/network/services/samba36/patches/.svn/text-base/200-remove_printer_support.patch.svn-base
@@ -0,0 +1,346 @@
+--- a/source3/rpc_server/rpc_ep_setup.c
++++ b/source3/rpc_server/rpc_ep_setup.c
+@@ -1110,6 +1110,10 @@ bool dcesrv_ep_setup(struct tevent_conte
+ "rpc_server",
+ "spoolss",
+ "embedded");
++#ifndef PRINTER_SUPPORT
++ if (1) {
++ } else
++#endif
+ if (StrCaseCmp(rpcsrv_type, "embedded") == 0) {
+ spoolss_cb.init = spoolss_init_cb;
+ spoolss_cb.shutdown = spoolss_shutdown_cb;
+--- a/source3/rpcclient/rpcclient.c
++++ b/source3/rpcclient/rpcclient.c
+@@ -624,7 +624,9 @@ static struct cmd_set *rpcclient_command
+ lsarpc_commands,
+ ds_commands,
+ samr_commands,
++#ifdef PRINTER_SUPPORT
+ spoolss_commands,
++#endif
+ netlogon_commands,
+ srvsvc_commands,
+ dfs_commands,
+--- a/source3/printing/spoolssd.c
++++ b/source3/printing/spoolssd.c
+@@ -153,6 +153,10 @@ void start_spoolssd(struct tevent_contex
+ NTSTATUS status;
+ int ret;
+
++#ifndef PRINTER_SUPPORT
++ return;
++#endif
++
+ DEBUG(1, ("Forking SPOOLSS Daemon\n"));
+
+ pid = sys_fork();
+--- a/source3/utils/net_rpc.c
++++ b/source3/utils/net_rpc.c
+@@ -7798,6 +7798,10 @@ int net_rpc_printer(struct net_context *
+ {NULL, NULL, 0, NULL, NULL}
+ };
+
++#ifndef PRINTER_SUPPORT
++ return 0;
++#endif
++
+ if (argc == 0) {
+ if (c->display_usage) {
+ d_printf(_("Usage:\n"));
+--- a/source3/smbd/reply.c
++++ b/source3/smbd/reply.c
+@@ -5196,7 +5196,11 @@ void reply_printopen(struct smb_request
+ return;
+ }
+
+- if (!CAN_PRINT(conn)) {
++
++#ifdef PRINTER_SUPPORT
++ if (!CAN_PRINT(conn))
++#endif
++ {
+ reply_nterror(req, NT_STATUS_ACCESS_DENIED);
+ END_PROFILE(SMBsplopen);
+ return;
+@@ -5302,7 +5306,10 @@ void reply_printqueue(struct smb_request
+ is really quite gross and only worked when there was only
+ one printer - I think we should now only accept it if they
+ get it right (tridge) */
+- if (!CAN_PRINT(conn)) {
++#ifdef PRINTER_SUPPORT
++ if (!CAN_PRINT(conn))
++#endif
++ {
+ reply_nterror(req, NT_STATUS_ACCESS_DENIED);
+ END_PROFILE(SMBsplretq);
+ return;
+--- a/source3/smbd/lanman.c
++++ b/source3/smbd/lanman.c
+@@ -784,6 +784,10 @@ static bool api_DosPrintQGetInfo(struct
+ union spoolss_JobInfo *job_info = NULL;
+ union spoolss_PrinterInfo printer_info;
+
++#ifndef PRINTER_SUPPORT
++ return False;
++#endif
++
+ if (!str1 || !str2 || !p) {
+ return False;
+ }
+@@ -999,6 +1003,10 @@ static bool api_DosPrintQEnum(struct smb
+ union spoolss_DriverInfo *driver_info;
+ union spoolss_JobInfo **job_info;
+
++#ifndef PRINTER_SUPPORT
++ return False;
++#endif
++
+ if (!param_format || !output_format1 || !p) {
+ return False;
+ }
+@@ -3350,6 +3358,10 @@ static bool api_RDosPrintJobDel(struct s
+ struct spoolss_DevmodeContainer devmode_ctr;
+ enum spoolss_JobControl command;
+
++#ifndef PRINTER_SUPPORT
++ return False;
++#endif
++
+ if (!str1 || !str2 || !p) {
+ return False;
+ }
+@@ -3483,6 +3495,10 @@ static bool api_WPrintQueueCtrl(struct s
+ struct sec_desc_buf secdesc_ctr;
+ enum spoolss_PrinterControl command;
+
++#ifndef PRINTER_SUPPORT
++ return False;
++#endif
++
+ if (!str1 || !str2 || !QueueName) {
+ return False;
+ }
+@@ -3649,6 +3665,10 @@ static bool api_PrintJobInfo(struct smbd
+ union spoolss_JobInfo info;
+ struct spoolss_SetJobInfo1 info1;
+
++#ifndef PRINTER_SUPPORT
++ return False;
++#endif
++
+ if (!str1 || !str2 || !p) {
+ return False;
+ }
+@@ -4792,6 +4812,10 @@ static bool api_WPrintJobGetInfo(struct
+ struct spoolss_DevmodeContainer devmode_ctr;
+ union spoolss_JobInfo info;
+
++#ifndef PRINTER_SUPPORT
++ return False;
++#endif
++
+ if (!str1 || !str2 || !p) {
+ return False;
+ }
+@@ -4930,6 +4954,10 @@ static bool api_WPrintJobEnumerate(struc
+ uint32_t count = 0;
+ union spoolss_JobInfo *info;
+
++#ifndef PRINTER_SUPPORT
++ return False;
++#endif
++
+ if (!str1 || !str2 || !p) {
+ return False;
+ }
+@@ -5135,6 +5163,10 @@ static bool api_WPrintDestGetInfo(struct
+ struct spoolss_DevmodeContainer devmode_ctr;
+ union spoolss_PrinterInfo info;
+
++#ifndef PRINTER_SUPPORT
++ return False;
++#endif
++
+ if (!str1 || !str2 || !p) {
+ return False;
+ }
+@@ -5271,6 +5303,10 @@ static bool api_WPrintDestEnum(struct sm
+ union spoolss_PrinterInfo *info;
+ uint32_t count;
+
++#ifndef PRINTER_SUPPORT
++ return False;
++#endif
++
+ if (!str1 || !str2 || !p) {
+ return False;
+ }
+@@ -5374,6 +5410,10 @@ static bool api_WPrintDriverEnum(struct
+ int succnt;
+ struct pack_desc desc;
+
++#ifndef PRINTER_SUPPORT
++ return False;
++#endif
++
+ if (!str1 || !str2 || !p) {
+ return False;
+ }
+@@ -5438,6 +5478,10 @@ static bool api_WPrintQProcEnum(struct s
+ int succnt;
+ struct pack_desc desc;
+
++#ifndef PRINTER_SUPPORT
++ return False;
++#endif
++
+ if (!str1 || !str2 || !p) {
+ return False;
+ }
+@@ -5502,6 +5546,10 @@ static bool api_WPrintPortEnum(struct sm
+ int succnt;
+ struct pack_desc desc;
+
++#ifndef PRINTER_SUPPORT
++ return False;
++#endif
++
+ if (!str1 || !str2 || !p) {
+ return False;
+ }
+--- a/source3/smbd/server_exit.c
++++ b/source3/smbd/server_exit.c
+@@ -141,7 +141,9 @@ static void exit_server_common(enum serv
+ rpc_eventlog_shutdown();
+ rpc_ntsvcs_shutdown();
+ rpc_svcctl_shutdown();
++#ifdef PRINTER_SUPPORT
+ rpc_spoolss_shutdown();
++#endif
+
+ rpc_srvsvc_shutdown();
+ rpc_winreg_shutdown();
+--- a/source3/smbd/open.c
++++ b/source3/smbd/open.c
+@@ -1566,6 +1566,9 @@ static NTSTATUS open_file_ntcreate(conne
+ * Most of the passed parameters are ignored.
+ */
+
++#ifndef PRINTER_SUPPORT
++ return NT_STATUS_ACCESS_DENIED;
++#endif
+ if (pinfo) {
+ *pinfo = FILE_WAS_CREATED;
+ }
+--- a/source3/smbd/close.c
++++ b/source3/smbd/close.c
+@@ -643,6 +643,9 @@ static NTSTATUS close_normal_file(struct
+ status = ntstatus_keeperror(status, tmp);
+
+ if (fsp->print_file) {
++#ifndef PRINTER_SUPPORT
++ return NT_STATUS_OK;
++#endif
+ /* FIXME: return spool errors */
+ print_spool_end(fsp, close_type);
+ file_free(req, fsp);
+--- a/source3/smbd/fileio.c
++++ b/source3/smbd/fileio.c
+@@ -298,6 +298,10 @@ ssize_t write_file(struct smb_request *r
+ uint32_t t;
+ int ret;
+
++#ifndef PRINTER_SUPPORT
++ return -1;
++#endif
++
+ ret = print_spool_write(fsp, data, n, pos, &t);
+ if (ret) {
+ errno = ret;
+--- a/source3/smbd/smb2_create.c
++++ b/source3/smbd/smb2_create.c
+@@ -486,7 +486,10 @@ static struct tevent_req *smbd_smb2_crea
+ info = FILE_WAS_OPENED;
+ } else if (CAN_PRINT(smb1req->conn)) {
+ status = file_new(smb1req, smb1req->conn, &result);
+- if(!NT_STATUS_IS_OK(status)) {
++#ifdef PRINTER_SUPPORT
++ if(!NT_STATUS_IS_OK(status))
++#endif
++ {
+ tevent_req_nterror(req, status);
+ return tevent_req_post(req, ev);
+ }
+--- a/source3/rpc_server/svcctl/srv_svcctl_nt.c
++++ b/source3/rpc_server/svcctl/srv_svcctl_nt.c
+@@ -85,9 +85,11 @@ bool init_service_op_table( void )
+
+ /* add builtin services */
+
++#ifdef PRINTER_SUPPORT
+ svcctl_ops[i].name = talloc_strdup( svcctl_ops, "Spooler" );
+ svcctl_ops[i].ops = &spoolss_svc_ops;
+ i++;
++#endif
+
+ svcctl_ops[i].name = talloc_strdup( svcctl_ops, "NETLOGON" );
+ svcctl_ops[i].ops = &netlogon_svc_ops;
+--- a/source3/librpc/rpc/rpc_common.c
++++ b/source3/librpc/rpc/rpc_common.c
+@@ -113,9 +113,11 @@ static bool initialize_interfaces(void)
+ if (!smb_register_ndr_interface(&ndr_table_winreg)) {
+ return false;
+ }
++#ifdef PRINTER_SUPPORT
+ if (!smb_register_ndr_interface(&ndr_table_spoolss)) {
+ return false;
+ }
++#endif
+ if (!smb_register_ndr_interface(&ndr_table_netdfs)) {
+ return false;
+ }
+--- a/source3/smbd/process.c
++++ b/source3/smbd/process.c
+@@ -2476,8 +2476,10 @@ static bool housekeeping_fn(const struct
+
+ change_to_root_user();
+
++#ifdef PRINTER_SUPPORT
+ /* update printer queue caches if necessary */
+ update_monitored_printq_cache(sconn->msg_ctx);
++#endif
+
+ /* check if we need to reload services */
+ check_reload(sconn, time_mono(NULL));
+--- a/source3/smbd/server.c
++++ b/source3/smbd/server.c
+@@ -126,7 +126,9 @@ static void smb_pcap_updated(struct mess
+ {
+ struct tevent_context *ev_ctx =
+ talloc_get_type_abort(private_data, struct tevent_context);
+-
++#ifndef PRINTER_SUPPORT
++ return;
++#endif
+ DEBUG(10,("Got message saying pcap was updated. Reloading.\n"));
+ change_to_root_user();
+ reload_printers(ev_ctx, msg);
+@@ -1231,6 +1233,7 @@ extern void build_options(bool screen);
+ * The print backend init also migrates the printing tdb's,
+ * this requires a winreg pipe.
+ */
++#ifdef PRINTER_SUPPORT
+ if (!print_backend_init(smbd_messaging_context()))
+ exit(1);
+
+@@ -1262,7 +1265,7 @@ extern void build_options(bool screen);
+ smbd_messaging_context());
+ }
+ }
+-
++#endif
+ if (!is_daemon) {
+ /* inetd mode */
+ TALLOC_FREE(frame);
diff --git a/package/network/services/samba36/patches/.svn/text-base/210-remove_ad_support.patch.svn-base b/package/network/services/samba36/patches/.svn/text-base/210-remove_ad_support.patch.svn-base
new file mode 100644
index 0000000..1a10a30
--- /dev/null
+++ b/package/network/services/samba36/patches/.svn/text-base/210-remove_ad_support.patch.svn-base
@@ -0,0 +1,88 @@
+--- a/source3/librpc/rpc/rpc_common.c
++++ b/source3/librpc/rpc/rpc_common.c
+@@ -95,9 +95,11 @@ static bool initialize_interfaces(void)
+ if (!smb_register_ndr_interface(&ndr_table_lsarpc)) {
+ return false;
+ }
++#ifdef ACTIVE_DIRECTORY
+ if (!smb_register_ndr_interface(&ndr_table_dssetup)) {
+ return false;
+ }
++#endif
+ if (!smb_register_ndr_interface(&ndr_table_samr)) {
+ return false;
+ }
+@@ -141,9 +143,11 @@ static bool initialize_interfaces(void)
+ if (!smb_register_ndr_interface(&ndr_table_epmapper)) {
+ return false;
+ }
++#ifdef ACTIVE_DIRECTORY
+ if (!smb_register_ndr_interface(&ndr_table_drsuapi)) {
+ return false;
+ }
++#endif
+ return true;
+ }
+
+--- a/source3/rpc_server/rpc_ep_setup.c
++++ b/source3/rpc_server/rpc_ep_setup.c
+@@ -918,6 +918,7 @@ static bool netdfs_init_cb(void *ptr)
+ return true;
+ }
+
++#ifdef ACTIVE_DIRECTORY
+ static bool dssetup_init_cb(void *ptr)
+ {
+ struct dcesrv_ep_context *ep_ctx =
+@@ -966,6 +967,7 @@ static bool dssetup_init_cb(void *ptr)
+
+ return true;
+ }
++#endif
+
+ static bool wkssvc_init_cb(void *ptr)
+ {
+@@ -1172,12 +1174,14 @@ bool dcesrv_ep_setup(struct tevent_conte
+ }
+ #endif
+
++#ifdef ACTIVE_DIRECTORY
+ dssetup_cb.init = dssetup_init_cb;
+ dssetup_cb.shutdown = NULL;
+ dssetup_cb.private_data = ep_ctx;
+ if (!NT_STATUS_IS_OK(rpc_dssetup_init(&dssetup_cb))) {
+ return false;
+ }
++#endif
+
+ wkssvc_cb.init = wkssvc_init_cb;
+ wkssvc_cb.shutdown = NULL;
+--- a/source3/smbd/server_exit.c
++++ b/source3/smbd/server_exit.c
+@@ -132,7 +132,9 @@ static void exit_server_common(enum serv
+
+ if (am_parent) {
+ rpc_wkssvc_shutdown();
++#ifdef ACTIVE_DIRECTORY
+ rpc_dssetup_shutdown();
++#endif
+ #ifdef DEVELOPER
+ rpc_rpcecho_shutdown();
+ #endif
+--- a/source3/rpc_client/cli_pipe.c
++++ b/source3/rpc_client/cli_pipe.c
+@@ -2874,12 +2874,14 @@ NTSTATUS cli_rpc_pipe_open_noauth_transp
+ status = rpc_pipe_bind(result, auth);
+ if (!NT_STATUS_IS_OK(status)) {
+ int lvl = 0;
++#ifdef ACTIVE_DIRECTORY
+ if (ndr_syntax_id_equal(interface,
+ &ndr_table_dssetup.syntax_id)) {
+ /* non AD domains just don't have this pipe, avoid
+ * level 0 statement in that case - gd */
+ lvl = 3;
+ }
++#endif
+ DEBUG(lvl, ("cli_rpc_pipe_open_noauth: rpc_pipe_bind for pipe "
+ "%s failed with error %s\n",
+ get_pipe_name_from_syntax(talloc_tos(), interface),
diff --git a/package/network/services/samba36/patches/.svn/text-base/220-remove_services.patch.svn-base b/package/network/services/samba36/patches/.svn/text-base/220-remove_services.patch.svn-base
new file mode 100644
index 0000000..498232d
--- /dev/null
+++ b/package/network/services/samba36/patches/.svn/text-base/220-remove_services.patch.svn-base
@@ -0,0 +1,98 @@
+--- a/source3/librpc/rpc/rpc_common.c
++++ b/source3/librpc/rpc/rpc_common.c
+@@ -131,6 +131,7 @@ static bool initialize_interfaces(void)
+ if (!smb_register_ndr_interface(&ndr_table_initshutdown)) {
+ return false;
+ }
++#ifdef EXTRA_SERVICES
+ if (!smb_register_ndr_interface(&ndr_table_svcctl)) {
+ return false;
+ }
+@@ -140,6 +141,7 @@ static bool initialize_interfaces(void)
+ if (!smb_register_ndr_interface(&ndr_table_ntsvcs)) {
+ return false;
+ }
++#endif
+ if (!smb_register_ndr_interface(&ndr_table_epmapper)) {
+ return false;
+ }
+--- a/source3/rpc_server/rpc_ep_setup.c
++++ b/source3/rpc_server/rpc_ep_setup.c
+@@ -697,6 +697,7 @@ static bool spoolss_shutdown_cb(void *pt
+ return true;
+ }
+
++#ifdef EXTRA_SERVICES
+ static bool svcctl_init_cb(void *ptr)
+ {
+ struct dcesrv_ep_context *ep_ctx =
+@@ -733,6 +734,7 @@ static bool svcctl_init_cb(void *ptr)
+
+ return true;
+ }
++#endif
+
+ static bool svcctl_shutdown_cb(void *ptr)
+ {
+@@ -741,6 +743,8 @@ static bool svcctl_shutdown_cb(void *ptr
+ return true;
+ }
+
++#ifdef EXTRA_SERVICES
++
+ static bool ntsvcs_init_cb(void *ptr)
+ {
+ struct dcesrv_ep_context *ep_ctx =
+@@ -802,6 +806,7 @@ static bool eventlog_init_cb(void *ptr)
+
+ return true;
+ }
++#endif
+
+ static bool initshutdown_init_cb(void *ptr)
+ {
+@@ -1130,6 +1135,7 @@ bool dcesrv_ep_setup(struct tevent_conte
+ }
+ }
+
++#ifdef EXTRA_SERVICES
+ svcctl_cb.init = svcctl_init_cb;
+ svcctl_cb.shutdown = svcctl_shutdown_cb;
+ svcctl_cb.private_data = ep_ctx;
+@@ -1150,6 +1156,7 @@ bool dcesrv_ep_setup(struct tevent_conte
+ if (!NT_STATUS_IS_OK(rpc_eventlog_init(&eventlog_cb))) {
+ return false;
+ }
++#endif
+
+ initshutdown_cb.init = initshutdown_init_cb;
+ initshutdown_cb.shutdown = NULL;
+--- a/source3/smbd/server_exit.c
++++ b/source3/smbd/server_exit.c
+@@ -140,9 +140,11 @@ static void exit_server_common(enum serv
+ #endif
+ rpc_netdfs_shutdown();
+ rpc_initshutdown_shutdown();
++#ifdef EXTRA_SERVICES
+ rpc_eventlog_shutdown();
+- rpc_ntsvcs_shutdown();
+ rpc_svcctl_shutdown();
++ rpc_ntsvcs_shutdown();
++#endif
+ #ifdef PRINTER_SUPPORT
+ rpc_spoolss_shutdown();
+ #endif
+--- a/source3/rpcclient/rpcclient.c
++++ b/source3/rpcclient/rpcclient.c
+@@ -637,9 +637,11 @@ static struct cmd_set *rpcclient_command
+ shutdown_commands,
+ test_commands,
+ wkssvc_commands,
++#ifdef EXTRA_SERVICES
+ ntsvcs_commands,
+ drsuapi_commands,
+ eventlog_commands,
++#endif
+ winreg_commands,
+ NULL
+ };
diff --git a/package/network/services/samba36/patches/.svn/text-base/230-remove_winreg_support.patch.svn-base b/package/network/services/samba36/patches/.svn/text-base/230-remove_winreg_support.patch.svn-base
new file mode 100644
index 0000000..df2be4f
--- /dev/null
+++ b/package/network/services/samba36/patches/.svn/text-base/230-remove_winreg_support.patch.svn-base
@@ -0,0 +1,146 @@
+--- a/source3/rpc_server/rpc_ep_setup.c
++++ b/source3/rpc_server/rpc_ep_setup.c
+@@ -409,6 +409,7 @@ static bool epmapper_shutdown_cb(void *p
+ return true;
+ }
+
++#ifdef WINREG_SUPPORT
+ static bool winreg_init_cb(void *ptr)
+ {
+ struct dcesrv_ep_context *ep_ctx =
+@@ -456,6 +457,7 @@ static bool winreg_init_cb(void *ptr)
+
+ return true;
+ }
++#endif
+
+ static bool srvsvc_init_cb(void *ptr)
+ {
+@@ -710,10 +712,12 @@ static bool svcctl_init_cb(void *ptr)
+ "epmapper",
+ "none");
+
++#ifdef WINREG_SUPPORT
+ ok = svcctl_init_winreg(ep_ctx->msg_ctx);
+ if (!ok) {
+ return false;
+ }
++#endif
+
+ /* initialize the control hooks */
+ init_service_op_table();
+@@ -785,10 +789,12 @@ static bool eventlog_init_cb(void *ptr)
+ "epmapper",
+ "none");
+
++#ifdef WINREG_SUPPORT
+ ok = eventlog_init_winreg(ep_ctx->msg_ctx);
+ if (!ok) {
+ return false;
+ }
++#endif
+
+ if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
+ StrCaseCmp(rpcsrv_type, "daemon") == 0) {
+@@ -1077,12 +1083,14 @@ bool dcesrv_ep_setup(struct tevent_conte
+ }
+ }
+
++#ifdef WINREG_SUPPORT
+ winreg_cb.init = winreg_init_cb;
+ winreg_cb.shutdown = NULL;
+ winreg_cb.private_data = ep_ctx;
+ if (!NT_STATUS_IS_OK(rpc_winreg_init(&winreg_cb))) {
+ return false;
+ }
++#endif
+
+ srvsvc_cb.init = srvsvc_init_cb;
+ srvsvc_cb.shutdown = NULL;
+--- a/source3/smbd/server_exit.c
++++ b/source3/smbd/server_exit.c
+@@ -150,7 +150,9 @@ static void exit_server_common(enum serv
+ #endif
+
+ rpc_srvsvc_shutdown();
++#ifdef WINREG_SUPPORT
+ rpc_winreg_shutdown();
++#endif
+
+ rpc_netlogon_shutdown();
+ rpc_samr_shutdown();
+--- a/source3/librpc/rpc/rpc_common.c
++++ b/source3/librpc/rpc/rpc_common.c
+@@ -112,9 +112,11 @@ static bool initialize_interfaces(void)
+ if (!smb_register_ndr_interface(&ndr_table_wkssvc)) {
+ return false;
+ }
++#ifdef WINREG_SUPPORT
+ if (!smb_register_ndr_interface(&ndr_table_winreg)) {
+ return false;
+ }
++#endif
+ #ifdef PRINTER_SUPPORT
+ if (!smb_register_ndr_interface(&ndr_table_spoolss)) {
+ return false;
+--- a/source3/rpc_server/svcctl/srv_svcctl_nt.c
++++ b/source3/rpc_server/svcctl/srv_svcctl_nt.c
+@@ -95,9 +95,11 @@ bool init_service_op_table( void )
+ svcctl_ops[i].ops = &netlogon_svc_ops;
+ i++;
+
++#ifdef WINREG_SUPPORT
+ svcctl_ops[i].name = talloc_strdup( svcctl_ops, "RemoteRegistry" );
+ svcctl_ops[i].ops = &winreg_svc_ops;
+ i++;
++#endif
+
+ svcctl_ops[i].name = talloc_strdup( svcctl_ops, "WINS" );
+ svcctl_ops[i].ops = &wins_svc_ops;
+--- a/source3/services/svc_winreg_glue.c
++++ b/source3/services/svc_winreg_glue.c
+@@ -88,6 +88,10 @@ struct security_descriptor *svcctl_get_s
+ NTSTATUS status;
+ WERROR result = WERR_OK;
+
++#ifndef WINREG_SUPPORT
++ return NULL;
++#endif
++
+ key = talloc_asprintf(mem_ctx,
+ "%s\\%s\\Security",
+ TOP_LEVEL_SERVICES_KEY, name);
+@@ -161,6 +165,10 @@ bool svcctl_set_secdesc(struct messaging
+ NTSTATUS status;
+ WERROR result = WERR_OK;
+
++#ifndef WINREG_SUPPORT
++ return false;
++#endif
++
+ tmp_ctx = talloc_stackframe();
+ if (tmp_ctx == NULL) {
+ return false;
+@@ -272,6 +280,10 @@ const char *svcctl_get_string_value(TALL
+ NTSTATUS status;
+ WERROR result = WERR_OK;
+
++#ifndef WINREG_SUPPORT
++ return NULL;
++#endif
++
+ tmp_ctx = talloc_stackframe();
+ if (tmp_ctx == NULL) {
+ return NULL;
+--- a/source3/rpcclient/rpcclient.c
++++ b/source3/rpcclient/rpcclient.c
+@@ -642,7 +642,9 @@ static struct cmd_set *rpcclient_command
+ drsuapi_commands,
+ eventlog_commands,
+ #endif
++#ifdef WINREG_SUPPORT
+ winreg_commands,
++#endif
+ NULL
+ };
+
diff --git a/package/network/services/samba36/patches/.svn/text-base/240-remove_dfs_api.patch.svn-base b/package/network/services/samba36/patches/.svn/text-base/240-remove_dfs_api.patch.svn-base
new file mode 100644
index 0000000..f4d432e
--- /dev/null
+++ b/package/network/services/samba36/patches/.svn/text-base/240-remove_dfs_api.patch.svn-base
@@ -0,0 +1,71 @@
+--- a/source3/rpc_server/rpc_ep_setup.c
++++ b/source3/rpc_server/rpc_ep_setup.c
+@@ -881,6 +881,7 @@ static bool rpcecho_init_cb(void *ptr) {
+
+ #endif
+
++#ifdef DFS_SUPPORT
+ static bool netdfs_init_cb(void *ptr)
+ {
+ struct dcesrv_ep_context *ep_ctx =
+@@ -928,6 +929,7 @@ static bool netdfs_init_cb(void *ptr)
+
+ return true;
+ }
++#endif
+
+ #ifdef ACTIVE_DIRECTORY
+ static bool dssetup_init_cb(void *ptr)
+@@ -1173,12 +1175,14 @@ bool dcesrv_ep_setup(struct tevent_conte
+ return false;
+ }
+
++#ifdef DFS_SUPPORT
+ netdfs_cb.init = netdfs_init_cb;
+ netdfs_cb.shutdown = NULL;
+ netdfs_cb.private_data = ep_ctx;
+ if (!NT_STATUS_IS_OK(rpc_netdfs_init(&netdfs_cb))) {
+ return false;
+ }
++#endif
+
+ #ifdef DEVELOPER
+ rpcecho_cb.init = rpcecho_init_cb;
+--- a/source3/librpc/rpc/rpc_common.c
++++ b/source3/librpc/rpc/rpc_common.c
+@@ -122,9 +122,11 @@ static bool initialize_interfaces(void)
+ return false;
+ }
+ #endif
++#ifdef DFS_SUPPORT
+ if (!smb_register_ndr_interface(&ndr_table_netdfs)) {
+ return false;
+ }
++#endif
+ #ifdef DEVELOPER
+ if (!smb_register_ndr_interface(&ndr_table_rpcecho)) {
+ return false;
+--- a/source3/smbd/server_exit.c
++++ b/source3/smbd/server_exit.c
+@@ -138,7 +138,9 @@ static void exit_server_common(enum serv
+ #ifdef DEVELOPER
+ rpc_rpcecho_shutdown();
+ #endif
++#ifdef DFS_SUPPORT
+ rpc_netdfs_shutdown();
++#endif
+ rpc_initshutdown_shutdown();
+ #ifdef EXTRA_SERVICES
+ rpc_eventlog_shutdown();
+--- a/source3/rpcclient/rpcclient.c
++++ b/source3/rpcclient/rpcclient.c
+@@ -629,7 +629,9 @@ static struct cmd_set *rpcclient_command
+ #endif
+ netlogon_commands,
+ srvsvc_commands,
++#ifdef DFS_SUPPORT
+ dfs_commands,
++#endif
+ #ifdef DEVELOPER
+ echo_commands,
+ #endif
diff --git a/package/network/services/samba36/patches/.svn/text-base/250-remove_domain_logon.patch.svn-base b/package/network/services/samba36/patches/.svn/text-base/250-remove_domain_logon.patch.svn-base
new file mode 100644
index 0000000..e97285b
--- /dev/null
+++ b/package/network/services/samba36/patches/.svn/text-base/250-remove_domain_logon.patch.svn-base
@@ -0,0 +1,185 @@
+--- a/source3/rpc_server/rpc_ep_setup.c
++++ b/source3/rpc_server/rpc_ep_setup.c
+@@ -606,6 +606,7 @@ static bool samr_init_cb(void *ptr)
+ return true;
+ }
+
++#ifdef NETLOGON_SUPPORT
+ static bool netlogon_init_cb(void *ptr)
+ {
+ struct dcesrv_ep_context *ep_ctx =
+@@ -654,6 +655,7 @@ static bool netlogon_init_cb(void *ptr)
+
+ return true;
+ }
++#endif
+
+ static bool spoolss_init_cb(void *ptr)
+ {
+@@ -1116,12 +1118,15 @@ bool dcesrv_ep_setup(struct tevent_conte
+ return false;
+ }
+
++#ifdef NETLOGON_SUPPORT
+ netlogon_cb.init = netlogon_init_cb;
+ netlogon_cb.shutdown = NULL;
+ netlogon_cb.private_data = ep_ctx;
+ if (!NT_STATUS_IS_OK(rpc_netlogon_init(&netlogon_cb))) {
+ return false;
+ }
++#endif
++
+
+ rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
+ "rpc_server",
+--- a/source3/librpc/rpc/rpc_common.c
++++ b/source3/librpc/rpc/rpc_common.c
+@@ -103,9 +103,11 @@ static bool initialize_interfaces(void)
+ if (!smb_register_ndr_interface(&ndr_table_samr)) {
+ return false;
+ }
++#ifdef NETLOGON_SUPPORT
+ if (!smb_register_ndr_interface(&ndr_table_netlogon)) {
+ return false;
+ }
++#endif
+ if (!smb_register_ndr_interface(&ndr_table_srvsvc)) {
+ return false;
+ }
+--- a/source3/smbd/server_exit.c
++++ b/source3/smbd/server_exit.c
+@@ -156,7 +156,9 @@ static void exit_server_common(enum serv
+ rpc_winreg_shutdown();
+ #endif
+
++#ifdef NETLOGON_SUPPORT
+ rpc_netlogon_shutdown();
++#endif
+ rpc_samr_shutdown();
+ rpc_lsarpc_shutdown();
+ }
+--- a/source3/rpc_server/svcctl/srv_svcctl_nt.c
++++ b/source3/rpc_server/svcctl/srv_svcctl_nt.c
+@@ -91,9 +91,11 @@ bool init_service_op_table( void )
+ i++;
+ #endif
+
++#ifdef NETLOGON_SUPPORT
+ svcctl_ops[i].name = talloc_strdup( svcctl_ops, "NETLOGON" );
+ svcctl_ops[i].ops = &netlogon_svc_ops;
+ i++;
++#endif
+
+ #ifdef WINREG_SUPPORT
+ svcctl_ops[i].name = talloc_strdup( svcctl_ops, "RemoteRegistry" );
+--- a/source3/nmbd/nmbd_processlogon.c
++++ b/source3/nmbd/nmbd_processlogon.c
+@@ -320,6 +320,10 @@ void process_logon_packet(struct packet_
+ NTSTATUS status;
+ const char *pdc_name;
+
++#ifndef NETLOGON_SUPPORT
++ return;
++#endif
++
+ in_addr_to_sockaddr_storage(&ss, p->ip);
+ pss = iface_ip((struct sockaddr *)&ss);
+ if (!pss) {
+--- a/source3/rpcclient/rpcclient.c
++++ b/source3/rpcclient/rpcclient.c
+@@ -627,7 +627,9 @@ static struct cmd_set *rpcclient_command
+ #ifdef PRINTER_SUPPORT
+ spoolss_commands,
+ #endif
++#ifdef NETLOGON_SUPPORT
+ netlogon_commands,
++#endif
+ srvsvc_commands,
+ #ifdef DFS_SUPPORT
+ dfs_commands,
+--- a/source3/rpc_server/wkssvc/srv_wkssvc_nt.c
++++ b/source3/rpc_server/wkssvc/srv_wkssvc_nt.c
+@@ -820,6 +820,10 @@ WERROR _wkssvc_NetrJoinDomain2(struct pi
+ WERROR werr;
+ struct security_token *token = p->session_info->security_token;
+
++#ifndef NETLOGON_SUPPORT
++ return WERR_NOT_SUPPORTED;
++#endif
++
+ if (!r->in.domain_name) {
+ return WERR_INVALID_PARAM;
+ }
+@@ -897,6 +901,10 @@ WERROR _wkssvc_NetrUnjoinDomain2(struct
+ WERROR werr;
+ struct security_token *token = p->session_info->security_token;
+
++#ifndef NETLOGON_SUPPORT
++ return WERR_NOT_SUPPORTED;
++#endif
++
+ if (!r->in.account || !r->in.encrypted_password) {
+ return WERR_INVALID_PARAM;
+ }
+--- a/source3/libsmb/trusts_util.c
++++ b/source3/libsmb/trusts_util.c
+@@ -46,9 +46,11 @@ NTSTATUS trust_pw_change_and_store_it(st
+ NTSTATUS nt_status;
+
+ switch (sec_channel_type) {
++#ifdef NETLOGON_SUPPORT
+ case SEC_CHAN_WKSTA:
+ case SEC_CHAN_DOMAIN:
+ break;
++#endif
+ default:
+ return NT_STATUS_NOT_SUPPORTED;
+ }
+@@ -159,6 +161,11 @@ bool enumerate_domain_trusts( TALLOC_CTX
+ *num_domains = 0;
+ *sids = NULL;
+
++#ifndef NETLOGON_SUPPORT
++ return False;
++#endif
++
++
+ /* lookup a DC first */
+
+ if ( !get_dc_name(domain, NULL, dc_name, &dc_ss) ) {
+@@ -243,6 +250,10 @@ NTSTATUS change_trust_account_password(
+ struct cli_state *cli = NULL;
+ struct rpc_pipe_client *netlogon_pipe = NULL;
+
++#ifndef NETLOGON_SUPPORT
++ return NT_STATUS_UNSUCCESSFUL;
++#endif
++
+ DEBUG(5,("change_trust_account_password: Attempting to change trust account password in domain %s....\n",
+ domain));
+
+--- a/source3/auth/auth_domain.c
++++ b/source3/auth/auth_domain.c
+@@ -538,7 +538,9 @@ static NTSTATUS auth_init_trustdomain(st
+
+ NTSTATUS auth_domain_init(void)
+ {
++#ifdef NETLOGON_SUPPORT
+ smb_register_auth(AUTH_INTERFACE_VERSION, "trustdomain", auth_init_trustdomain);
+ smb_register_auth(AUTH_INTERFACE_VERSION, "ntdomain", auth_init_ntdomain);
++#endif
+ return NT_STATUS_OK;
+ }
+--- a/source3/smbd/process.c
++++ b/source3/smbd/process.c
+@@ -2484,8 +2484,10 @@ static bool housekeeping_fn(const struct
+ /* check if we need to reload services */
+ check_reload(sconn, time_mono(NULL));
+
++#ifdef NETLOGON_SUPPORT
+ /* Change machine password if neccessary. */
+ attempt_machine_password_change();
++#endif
+
+ /*
+ * Force a log file check.
diff --git a/package/network/services/samba36/patches/.svn/text-base/260-remove_samr.patch.svn-base b/package/network/services/samba36/patches/.svn/text-base/260-remove_samr.patch.svn-base
new file mode 100644
index 0000000..eda6129
--- /dev/null
+++ b/package/network/services/samba36/patches/.svn/text-base/260-remove_samr.patch.svn-base
@@ -0,0 +1,155 @@
+--- a/source3/rpc_server/rpc_handles.c
++++ b/source3/rpc_server/rpc_handles.c
+@@ -59,8 +59,11 @@ struct handle_list {
+
+ static bool is_samr_lsa_pipe(const struct ndr_syntax_id *syntax)
+ {
+- return (ndr_syntax_id_equal(syntax, &ndr_table_samr.syntax_id)
+- || ndr_syntax_id_equal(syntax, &ndr_table_lsarpc.syntax_id));
++ return
++#ifdef SAMR_SUPPORT
++ ndr_syntax_id_equal(syntax, &ndr_table_samr.syntax_id) ||
++#endif
++ ndr_syntax_id_equal(syntax, &ndr_table_lsarpc.syntax_id);
+ }
+
+ size_t num_pipe_handles(struct pipes_struct *p)
+--- a/source3/librpc/rpc/rpc_common.c
++++ b/source3/librpc/rpc/rpc_common.c
+@@ -100,9 +100,11 @@ static bool initialize_interfaces(void)
+ return false;
+ }
+ #endif
++#ifdef SAMR_SUPPORT
+ if (!smb_register_ndr_interface(&ndr_table_samr)) {
+ return false;
+ }
++#endif
+ #ifdef NETLOGON_SUPPORT
+ if (!smb_register_ndr_interface(&ndr_table_netlogon)) {
+ return false;
+--- a/source3/rpc_server/rpc_ep_setup.c
++++ b/source3/rpc_server/rpc_ep_setup.c
+@@ -557,6 +557,7 @@ static bool lsarpc_init_cb(void *ptr)
+ return true;
+ }
+
++#ifdef SAMR_SUPPORT
+ static bool samr_init_cb(void *ptr)
+ {
+ struct dcesrv_ep_context *ep_ctx =
+@@ -605,6 +606,7 @@ static bool samr_init_cb(void *ptr)
+
+ return true;
+ }
++#endif
+
+ #ifdef NETLOGON_SUPPORT
+ static bool netlogon_init_cb(void *ptr)
+@@ -1111,12 +1113,14 @@ bool dcesrv_ep_setup(struct tevent_conte
+ return false;
+ }
+
++#ifdef SAMR_SUPPORT
+ samr_cb.init = samr_init_cb;
+ samr_cb.shutdown = NULL;
+ samr_cb.private_data = ep_ctx;
+ if (!NT_STATUS_IS_OK(rpc_samr_init(&samr_cb))) {
+ return false;
+ }
++#endif
+
+ #ifdef NETLOGON_SUPPORT
+ netlogon_cb.init = netlogon_init_cb;
+--- a/source3/smbd/server_exit.c
++++ b/source3/smbd/server_exit.c
+@@ -159,7 +159,9 @@ static void exit_server_common(enum serv
+ #ifdef NETLOGON_SUPPORT
+ rpc_netlogon_shutdown();
+ #endif
++#ifdef SAMR_SUPPORT
+ rpc_samr_shutdown();
++#endif
+ rpc_lsarpc_shutdown();
+ }
+
+--- a/source3/rpcclient/rpcclient.c
++++ b/source3/rpcclient/rpcclient.c
+@@ -623,7 +623,9 @@ static struct cmd_set *rpcclient_command
+ rpcclient_commands,
+ lsarpc_commands,
+ ds_commands,
++#ifdef SAMR_SUPPORT
+ samr_commands,
++#endif
+ #ifdef PRINTER_SUPPORT
+ spoolss_commands,
+ #endif
+--- a/source3/smbd/lanman.c
++++ b/source3/smbd/lanman.c
+@@ -2353,6 +2353,10 @@ static bool api_RNetGroupEnum(struct smb
+ NTSTATUS status, result;
+ struct dcerpc_binding_handle *b;
+
++#ifndef SAMR_SUPPORT
++ return False;
++#endif
++
+ if (!str1 || !str2 || !p) {
+ return False;
+ }
+@@ -2541,6 +2545,10 @@ static bool api_NetUserGetGroups(struct
+ NTSTATUS status, result;
+ struct dcerpc_binding_handle *b;
+
++#ifndef SAMR_SUPPORT
++ return False;
++#endif
++
+ if (!str1 || !str2 || !UserName || !p) {
+ return False;
+ }
+@@ -2733,6 +2741,10 @@ static bool api_RNetUserEnum(struct smbd
+
+ struct dcerpc_binding_handle *b;
+
++#ifndef SAMR_SUPPORT
++ return False;
++#endif
++
+ if (!str1 || !str2 || !p) {
+ return False;
+ }
+@@ -2979,6 +2991,10 @@ static bool api_SetUserPassword(struct s
+ int min_pwd_length;
+ struct dcerpc_binding_handle *b = NULL;
+
++#ifndef SAMR_SUPPORT
++ return False;
++#endif
++
+ /* Skip 2 strings. */
+ p = skip_string(param,tpscnt,np);
+ p = skip_string(param,tpscnt,p);
+@@ -3224,6 +3240,10 @@ static bool api_SamOEMChangePassword(str
+ int bufsize;
+ struct dcerpc_binding_handle *b;
+
++#ifndef SAMR_SUPPORT
++ return False;
++#endif
++
+ *rparam_len = 4;
+ *rparam = smb_realloc_limit(*rparam,*rparam_len);
+ if (!*rparam) {
+@@ -4265,6 +4285,10 @@ static bool api_RNetUserGetInfo(struct s
+ union samr_UserInfo *info;
+ struct dcerpc_binding_handle *b = NULL;
+
++#ifndef SAMR_SUPPORT
++ return False;
++#endif
++
+ if (!str1 || !str2 || !UserName || !p) {
+ return False;
+ }
diff --git a/package/network/services/samba36/patches/.svn/text-base/270-remove_registry_backend.patch.svn-base b/package/network/services/samba36/patches/.svn/text-base/270-remove_registry_backend.patch.svn-base
new file mode 100644
index 0000000..7714b86
--- /dev/null
+++ b/package/network/services/samba36/patches/.svn/text-base/270-remove_registry_backend.patch.svn-base
@@ -0,0 +1,43 @@
+--- a/source3/lib/smbconf/smbconf_init.c
++++ b/source3/lib/smbconf/smbconf_init.c
+@@ -68,9 +68,12 @@ sbcErr smbconf_init(TALLOC_CTX *mem_ctx,
+ }
+ }
+
++#ifdef REGISTRY_BACKEND
+ if (strequal(backend, "registry") || strequal(backend, "reg")) {
+ err = smbconf_init_reg(mem_ctx, conf_ctx, path);
+- } else if (strequal(backend, "file") || strequal(backend, "txt")) {
++ } else
++#endif
++ if (strequal(backend, "file") || strequal(backend, "txt")) {
+ err = smbconf_init_txt(mem_ctx, conf_ctx, path);
+ } else if (sep == NULL) {
+ /*
+--- a/source3/lib/netapi/serverinfo.c
++++ b/source3/lib/netapi/serverinfo.c
+@@ -557,7 +557,10 @@ static WERROR NetServerSetInfo_l_1005(st
+ return WERR_INVALID_PARAM;
+ }
+
+- if (!lp_config_backend_is_registry()) {
++#ifdef REGISTRY_BACKEND
++ if (!lp_config_backend_is_registry())
++#endif
++ {
+ libnetapi_set_error_string(ctx,
+ "Configuration manipulation requested but not "
+ "supported by backend");
+--- a/source3/smbd/server.c
++++ b/source3/smbd/server.c
+@@ -1184,8 +1184,10 @@ extern void build_options(bool screen);
+ exit(1);
+ }
+
++#ifdef REGISTRY_BACKEND
+ if (!W_ERROR_IS_OK(registry_init_full()))
+ exit(1);
++#endif
+
+ /* Open the share_info.tdb here, so we don't have to open
+ after the fork on every single connection. This is a small
diff --git a/package/network/services/samba36/patches/.svn/text-base/280-strip_srvsvc.patch.svn-base b/package/network/services/samba36/patches/.svn/text-base/280-strip_srvsvc.patch.svn-base
new file mode 100644
index 0000000..b93e3fc
--- /dev/null
+++ b/package/network/services/samba36/patches/.svn/text-base/280-strip_srvsvc.patch.svn-base
@@ -0,0 +1,143 @@
+--- a/source3/smbd/lanman.c
++++ b/source3/smbd/lanman.c
+@@ -2197,6 +2197,10 @@ static bool api_RNetShareAdd(struct smbd
+ struct srvsvc_NetShareInfo2 info2;
+ struct dcerpc_binding_handle *b;
+
++#ifndef SRVSVC_SUPPORT
++ return False;
++#endif
++
+ if (!str1 || !str2 || !p) {
+ return False;
+ }
+@@ -3838,10 +3842,7 @@ static bool api_RNetServerGetInfo(struct
+ NTSTATUS status;
+ WERROR werr;
+ TALLOC_CTX *mem_ctx = talloc_tos();
+- struct rpc_pipe_client *cli = NULL;
+- union srvsvc_NetSrvInfo info;
+ int errcode;
+- struct dcerpc_binding_handle *b;
+
+ if (!str1 || !str2 || !p) {
+ return False;
+@@ -3904,66 +3905,16 @@ static bool api_RNetServerGetInfo(struct
+ p = *rdata;
+ p2 = p + struct_len;
+
+- status = rpc_pipe_open_interface(mem_ctx, &ndr_table_srvsvc.syntax_id,
+- conn->session_info,
+- &conn->sconn->client_id,
+- conn->sconn->msg_ctx,
+- &cli);
+- if (!NT_STATUS_IS_OK(status)) {
+- DEBUG(0,("api_RNetServerGetInfo: could not connect to srvsvc: %s\n",
+- nt_errstr(status)));
+- errcode = W_ERROR_V(ntstatus_to_werror(status));
+- goto out;
+- }
+-
+- b = cli->binding_handle;
+-
+- status = dcerpc_srvsvc_NetSrvGetInfo(b, mem_ctx,
+- NULL,
+- 101,
+- &info,
+- &werr);
+- if (!NT_STATUS_IS_OK(status)) {
+- errcode = W_ERROR_V(ntstatus_to_werror(status));
+- goto out;
+- }
+- if (!W_ERROR_IS_OK(werr)) {
+- errcode = W_ERROR_V(werr);
+- goto out;
+- }
+-
+- if (info.info101 == NULL) {
+- errcode = W_ERROR_V(WERR_INVALID_PARAM);
+- goto out;
+- }
+-
+ if (uLevel != 20) {
+- srvstr_push(NULL, 0, p, info.info101->server_name, 16,
++ srvstr_push(NULL, 0, p, global_myname(), 16,
+ STR_ASCII|STR_UPPER|STR_TERMINATE);
+- }
++ }
+ p += 16;
+ if (uLevel > 0) {
+- SCVAL(p,0,info.info101->version_major);
+- SCVAL(p,1,info.info101->version_minor);
+- SIVAL(p,2,info.info101->server_type);
+-
+- if (mdrcnt == struct_len) {
+- SIVAL(p,6,0);
+- } else {
+- SIVAL(p,6,PTR_DIFF(p2,*rdata));
+- if (mdrcnt - struct_len <= 0) {
+- return false;
+- }
+- push_ascii(p2,
+- info.info101->comment,
+- MIN(mdrcnt - struct_len,
+- MAX_SERVER_STRING_LENGTH),
+- STR_TERMINATE);
+- p2 = skip_string(*rdata,*rdata_len,p2);
+- if (!p2) {
+- return False;
+- }
+- }
++ SCVAL(p,0,lp_major_announce_version());
++ SCVAL(p,1,lp_minor_announce_version());
++ SIVAL(p,2,lp_default_server_announce());
++ SIVAL(p,6,0);
+ }
+
+ if (uLevel > 1) {
+@@ -5654,6 +5605,10 @@ static bool api_RNetSessionEnum(struct s
+ uint32_t totalentries, resume_handle = 0;
+ uint32_t count = 0;
+
++#ifndef SRVSVC_SUPPORT
++ return False;
++#endif
++
+ if (!str1 || !str2 || !p) {
+ return False;
+ }
+--- a/source3/rpc_server/srvsvc/srv_srvsvc_nt.c
++++ b/source3/rpc_server/srvsvc/srv_srvsvc_nt.c
+@@ -1533,6 +1533,10 @@ WERROR _srvsvc_NetShareSetInfo(struct pi
+ TALLOC_CTX *ctx = p->mem_ctx;
+ union srvsvc_NetShareInfo *info = r->in.info;
+
++#ifndef FULL_SRVSVC
++ return WERR_ACCESS_DENIED;
++#endif
++
+ DEBUG(5,("_srvsvc_NetShareSetInfo: %d\n", __LINE__));
+
+ if (!r->in.share_name) {
+@@ -1763,6 +1767,10 @@ WERROR _srvsvc_NetShareAdd(struct pipes_
+ int max_connections = 0;
+ TALLOC_CTX *ctx = p->mem_ctx;
+
++#ifndef FULL_SRVSVC
++ return WERR_ACCESS_DENIED;
++#endif
++
+ DEBUG(5,("_srvsvc_NetShareAdd: %d\n", __LINE__));
+
+ if (r->out.parm_error) {
+@@ -1945,6 +1953,10 @@ WERROR _srvsvc_NetShareDel(struct pipes_
+ struct share_params *params;
+ TALLOC_CTX *ctx = p->mem_ctx;
+
++#ifndef FULL_SRVSVC
++ return WERR_ACCESS_DENIED;
++#endif
++
+ DEBUG(5,("_srvsvc_NetShareDel: %d\n", __LINE__));
+
+ if (!r->in.share_name) {
diff --git a/package/network/services/samba36/patches/.svn/text-base/290-remove_lsa.patch.svn-base b/package/network/services/samba36/patches/.svn/text-base/290-remove_lsa.patch.svn-base
new file mode 100644
index 0000000..fe37d5d
--- /dev/null
+++ b/package/network/services/samba36/patches/.svn/text-base/290-remove_lsa.patch.svn-base
@@ -0,0 +1,73 @@
+--- a/source3/librpc/rpc/rpc_common.c
++++ b/source3/librpc/rpc/rpc_common.c
+@@ -92,9 +92,11 @@ bool smb_register_ndr_interface(const st
+
+ static bool initialize_interfaces(void)
+ {
++#ifdef LSA_SUPPORT
+ if (!smb_register_ndr_interface(&ndr_table_lsarpc)) {
+ return false;
+ }
++#endif
+ #ifdef ACTIVE_DIRECTORY
+ if (!smb_register_ndr_interface(&ndr_table_dssetup)) {
+ return false;
+--- a/source3/smbd/server_exit.c
++++ b/source3/smbd/server_exit.c
+@@ -162,7 +162,9 @@ static void exit_server_common(enum serv
+ #ifdef SAMR_SUPPORT
+ rpc_samr_shutdown();
+ #endif
++#ifdef LSA_SUPPORT
+ rpc_lsarpc_shutdown();
++#endif
+ }
+
+ /*
+--- a/source3/rpc_server/rpc_ep_setup.c
++++ b/source3/rpc_server/rpc_ep_setup.c
+@@ -508,6 +508,7 @@ static bool srvsvc_init_cb(void *ptr)
+ return true;
+ }
+
++#ifdef LSA_SUPPORT
+ static bool lsarpc_init_cb(void *ptr)
+ {
+ struct dcesrv_ep_context *ep_ctx =
+@@ -556,6 +557,7 @@ static bool lsarpc_init_cb(void *ptr)
+
+ return true;
+ }
++#endif
+
+ #ifdef SAMR_SUPPORT
+ static bool samr_init_cb(void *ptr)
+@@ -1106,12 +1108,14 @@ bool dcesrv_ep_setup(struct tevent_conte
+ }
+
+
++#ifdef LSA_SUPPORT
+ lsarpc_cb.init = lsarpc_init_cb;
+ lsarpc_cb.shutdown = NULL;
+ lsarpc_cb.private_data = ep_ctx;
+ if (!NT_STATUS_IS_OK(rpc_lsarpc_init(&lsarpc_cb))) {
+ return false;
+ }
++#endif
+
+ #ifdef SAMR_SUPPORT
+ samr_cb.init = samr_init_cb;
+--- a/source3/rpc_server/rpc_handles.c
++++ b/source3/rpc_server/rpc_handles.c
+@@ -63,7 +63,10 @@ static bool is_samr_lsa_pipe(const struc
+ #ifdef SAMR_SUPPORT
+ ndr_syntax_id_equal(syntax, &ndr_table_samr.syntax_id) ||
+ #endif
+- ndr_syntax_id_equal(syntax, &ndr_table_lsarpc.syntax_id);
++#ifdef LSA_SUPPORT
++ ndr_syntax_id_equal(syntax, &ndr_table_lsarpc.syntax_id) ||
++#endif
++ false;
+ }
+
+ size_t num_pipe_handles(struct pipes_struct *p)
diff --git a/package/network/services/samba36/patches/.svn/text-base/300-assert_debug_level.patch.svn-base b/package/network/services/samba36/patches/.svn/text-base/300-assert_debug_level.patch.svn-base
new file mode 100644
index 0000000..c5b0716
--- /dev/null
+++ b/package/network/services/samba36/patches/.svn/text-base/300-assert_debug_level.patch.svn-base
@@ -0,0 +1,11 @@
+--- a/lib/util/util.h
++++ b/lib/util/util.h
+@@ -53,7 +53,7 @@ extern const char *panic_action;
+ #else
+ /* redefine the assert macro for non-developer builds */
+ #define SMB_ASSERT(b) do { if (!(b)) { \
+- DEBUG(0,("PANIC: assert failed at %s(%d): %s\n", \
++ DEBUG(3,("PANIC: assert failed at %s(%d): %s\n", \
+ __FILE__, __LINE__, #b)); }} while (0)
+ #endif
+
diff --git a/package/network/services/samba36/patches/.svn/text-base/310-remove_error_strings.patch.svn-base b/package/network/services/samba36/patches/.svn/text-base/310-remove_error_strings.patch.svn-base
new file mode 100644
index 0000000..44342ef
--- /dev/null
+++ b/package/network/services/samba36/patches/.svn/text-base/310-remove_error_strings.patch.svn-base
@@ -0,0 +1,253 @@
+--- a/libcli/util/doserr.c
++++ b/libcli/util/doserr.c
+@@ -28,6 +28,7 @@ struct werror_code_struct {
+
+ static const struct werror_code_struct dos_errs[] =
+ {
++#ifdef VERBOSE_ERROR
+ { "WERR_OK", WERR_OK },
+ { "WERR_BADFILE", WERR_BADFILE },
+ { "WERR_ACCESS_DENIED", WERR_ACCESS_DENIED },
+@@ -2668,6 +2669,7 @@ static const struct werror_code_struct d
+ { "WERR_AMBIGUOUS_SYSTEM_DEVICE", WERR_AMBIGUOUS_SYSTEM_DEVICE },
+ { "WERR_SYSTEM_DEVICE_NOT_FOUND", WERR_SYSTEM_DEVICE_NOT_FOUND },
+ /* END GENERATED-WIN32-ERROR-CODES */
++#endif
+ { NULL, W_ERROR(0) }
+ };
+
+@@ -2684,12 +2686,14 @@ const char *win_errstr(WERROR werror)
+ static char msg[40];
+ int idx = 0;
+
++#ifdef VERBOSE_ERROR
+ while (dos_errs[idx].dos_errstr != NULL) {
+ if (W_ERROR_V(dos_errs[idx].werror) ==
+ W_ERROR_V(werror))
+ return dos_errs[idx].dos_errstr;
+ idx++;
+ }
++#endif
+
+ slprintf(msg, sizeof(msg), "DOS code 0x%08x", W_ERROR_V(werror));
+
+@@ -2702,6 +2706,7 @@ struct werror_str_struct {
+ };
+
+ const struct werror_str_struct dos_err_strs[] = {
++#ifdef VERBOSE_ERROR
+ { WERR_OK, "Success" },
+ { WERR_ACCESS_DENIED, "Access is denied" },
+ { WERR_INVALID_PARAM, "Invalid parameter" },
+@@ -5324,6 +5329,7 @@ const struct werror_str_struct dos_err_s
+ { WERR_AMBIGUOUS_SYSTEM_DEVICE, "The requested system device cannot be identified due to multiple indistinguishable devices potentially matching the identification criteria." },
+ { WERR_SYSTEM_DEVICE_NOT_FOUND, "The requested system device cannot be found." },
+ /* END GENERATED-WIN32-ERROR-CODES-DESC */
++#endif
+ };
+
+
+@@ -5334,6 +5340,7 @@ const struct werror_str_struct dos_err_s
+
+ const char *get_friendly_werror_msg(WERROR werror)
+ {
++#ifdef VERBOSE_ERROR
+ int i = 0;
+
+ for (i = 0; i < ARRAY_SIZE(dos_err_strs); i++) {
+@@ -5342,6 +5349,7 @@ const char *get_friendly_werror_msg(WERR
+ return dos_err_strs[i].friendly_errstr;
+ }
+ }
++#endif
+
+ return win_errstr(werror);
+ }
+--- a/librpc/ndr/libndr.h
++++ b/librpc/ndr/libndr.h
+@@ -604,4 +604,20 @@ _PUBLIC_ enum ndr_err_code ndr_push_enum
+
+ _PUBLIC_ void ndr_print_bool(struct ndr_print *ndr, const char *name, const bool b);
+
++#ifndef VERBOSE_ERROR
++#define ndr_print_bool(...) do {} while (0)
++#define ndr_print_struct(...) do {} while (0)
++#define ndr_print_null(...) do {} while (0)
++#define ndr_print_enum(...) do {} while (0)
++#define ndr_print_bitmap_flag(...) do {} while (0)
++#define ndr_print_ptr(...) do {} while (0)
++#define ndr_print_union(...) do {} while (0)
++#define ndr_print_bad_level(...) do {} while (0)
++#define ndr_print_array_uint8(...) do {} while (0)
++#define ndr_print_string_array(...) do {} while (0)
++#define ndr_print_string_array(...) do {} while (0)
++#define ndr_print_NTSTATUS(...) do {} while (0)
++#define ndr_print_WERROR(...) do {} while (0)
++#endif
++
+ #endif /* __LIBNDR_H__ */
+--- a/librpc/ndr/ndr_basic.c
++++ b/librpc/ndr/ndr_basic.c
+@@ -31,6 +31,19 @@
+ #define NDR_SIVAL(ndr, ofs, v) do { if (NDR_BE(ndr)) { RSIVAL(ndr->data,ofs,v); } else SIVAL(ndr->data,ofs,v); } while (0)
+ #define NDR_SIVALS(ndr, ofs, v) do { if (NDR_BE(ndr)) { RSIVALS(ndr->data,ofs,v); } else SIVALS(ndr->data,ofs,v); } while (0)
+
++#undef ndr_print_bool
++#undef ndr_print_struct
++#undef ndr_print_null
++#undef ndr_print_enum
++#undef ndr_print_bitmap_flag
++#undef ndr_print_ptr
++#undef ndr_print_union
++#undef ndr_print_bad_level
++#undef ndr_print_array_uint8
++#undef ndr_print_string_array
++#undef ndr_print_string_array
++#undef ndr_print_NTSTATUS
++#undef ndr_print_WERROR
+
+ /*
+ check for data leaks from the server by looking for non-zero pad bytes
+--- a/librpc/ndr/ndr_string.c
++++ b/librpc/ndr/ndr_string.c
+@@ -588,6 +588,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_stri
+ return NDR_ERR_SUCCESS;
+ }
+
++#undef ndr_print_string_array
+ _PUBLIC_ void ndr_print_string_array(struct ndr_print *ndr, const char *name, const char **a)
+ {
+ uint32_t count;
+--- a/librpc/rpc/dcerpc_error.c
++++ b/librpc/rpc/dcerpc_error.c
+@@ -31,6 +31,7 @@ struct dcerpc_fault_table {
+ static const struct dcerpc_fault_table dcerpc_faults[] =
+ {
+ #define _FAULT_STR(x) { #x , x }
++#ifdef VERBOSE_ERROR
+ _FAULT_STR(DCERPC_NCA_S_COMM_FAILURE),
+ _FAULT_STR(DCERPC_NCA_S_OP_RNG_ERROR),
+ _FAULT_STR(DCERPC_NCA_S_UNKNOWN_IF),
+@@ -78,6 +79,7 @@ static const struct dcerpc_fault_table d
+ _FAULT_STR(DCERPC_NCA_S_FAULT_CODESET_CONV_ERROR),
+ _FAULT_STR(DCERPC_NCA_S_FAULT_OBJECT_NOT_FOUND),
+ _FAULT_STR(DCERPC_NCA_S_FAULT_NO_CLIENT_STUB),
++#endif
+ { NULL, 0 }
+ #undef _FAULT_STR
+ };
+@@ -87,12 +89,14 @@ _PUBLIC_ const char *dcerpc_errstr(TALLO
+ int idx = 0;
+ WERROR werr = W_ERROR(fault_code);
+
++#ifdef VERBOSE_ERROR
+ while (dcerpc_faults[idx].errstr != NULL) {
+ if (dcerpc_faults[idx].faultcode == fault_code) {
+ return dcerpc_faults[idx].errstr;
+ }
+ idx++;
+ }
++#endif
+
+ return win_errstr(werr);
+ }
+--- a/source3/libsmb/nterr.c
++++ b/source3/libsmb/nterr.c
+@@ -702,6 +702,7 @@ const char *nt_errstr(NTSTATUS nt_code)
+ NT_STATUS_DOS_CODE(nt_code));
+ }
+
++#ifdef VERBOSE_ERROR
+ while (nt_errs[idx].nt_errstr != NULL) {
+ if (NT_STATUS_V(nt_errs[idx].nt_errcode) ==
+ NT_STATUS_V(nt_code)) {
+@@ -709,6 +710,7 @@ const char *nt_errstr(NTSTATUS nt_code)
+ }
+ idx++;
+ }
++#endif
+
+ result = talloc_asprintf(talloc_tos(), "NT code 0x%08x",
+ NT_STATUS_V(nt_code));
+@@ -724,12 +726,14 @@ const char *get_friendly_nt_error_msg(NT
+ {
+ int idx = 0;
+
++#ifdef VERBOSE_ERROR
+ while (nt_err_desc[idx].nt_errstr != NULL) {
+ if (NT_STATUS_V(nt_err_desc[idx].nt_errcode) == NT_STATUS_V(nt_code)) {
+ return nt_err_desc[idx].nt_errstr;
+ }
+ idx++;
+ }
++#endif
+
+ /* fall back to NT_STATUS_XXX string */
+
+@@ -745,6 +749,7 @@ const char *get_nt_error_c_code(NTSTATUS
+ char *result;
+ int idx = 0;
+
++#ifdef VERBOSE_ERROR
+ while (nt_errs[idx].nt_errstr != NULL) {
+ if (NT_STATUS_V(nt_errs[idx].nt_errcode) ==
+ NT_STATUS_V(nt_code)) {
+@@ -752,6 +757,7 @@ const char *get_nt_error_c_code(NTSTATUS
+ }
+ idx++;
+ }
++#endif
+
+ result = talloc_asprintf(talloc_tos(), "NT_STATUS(0x%08x)",
+ NT_STATUS_V(nt_code));
+@@ -767,12 +773,14 @@ NTSTATUS nt_status_string_to_code(const
+ {
+ int idx = 0;
+
++#ifdef VERBOSE_ERROR
+ while (nt_errs[idx].nt_errstr != NULL) {
+ if (strcasecmp(nt_errs[idx].nt_errstr, nt_status_str) == 0) {
+ return nt_errs[idx].nt_errcode;
+ }
+ idx++;
+ }
++#endif
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+
+--- a/lib/tdb/common/tdb_private.h
++++ b/lib/tdb/common/tdb_private.h
+@@ -69,7 +69,11 @@ typedef uint32_t tdb_off_t;
+ /* NB assumes there is a local variable called "tdb" that is the
+ * current context, also takes doubly-parenthesized print-style
+ * argument. */
++#ifdef VERBOSE_DEBUG
+ #define TDB_LOG(x) tdb->log.log_fn x
++#else
++#define TDB_LOG(x) do {} while(0)
++#endif
+
+ #ifdef TDB_TRACE
+ void tdb_trace(struct tdb_context *tdb, const char *op);
+--- a/source3/script/mkbuildoptions.awk
++++ b/source3/script/mkbuildoptions.awk
+@@ -55,7 +55,7 @@ BEGIN {
+ print "****************************************************************************/";
+ print "void build_options(bool screen)";
+ print "{";
+- print " if ((DEBUGLEVEL < 4) && (!screen)) {";
++ print " if ((DEBUGLEVEL < 4) || (!screen)) {";
+ print " return;";
+ print " }";
+ print "";
+--- a/source3/script/mkbuildoptions-waf.awk
++++ b/source3/script/mkbuildoptions-waf.awk
+@@ -55,7 +55,7 @@ BEGIN {
+ print "****************************************************************************/";
+ print "void build_options(bool screen)";
+ print "{";
+- print " if ((DEBUGLEVEL < 4) && (!screen)) {";
++ print " if ((DEBUGLEVEL < 4) || (!screen)) {";
+ print " return;";
+ print " }";
+ print "";
diff --git a/package/network/services/samba36/patches/.svn/text-base/320-debug_level_checks.patch.svn-base b/package/network/services/samba36/patches/.svn/text-base/320-debug_level_checks.patch.svn-base
new file mode 100644
index 0000000..c6f2e6e
--- /dev/null
+++ b/package/network/services/samba36/patches/.svn/text-base/320-debug_level_checks.patch.svn-base
@@ -0,0 +1,22 @@
+--- a/lib/util/debug.h
++++ b/lib/util/debug.h
+@@ -45,7 +45,7 @@ bool dbghdr( int level, const char *loca
+ * Redefine DEBUGLEVEL because so we don't have to change every source file
+ * that *unnecessarily* references it.
+ */
+-#define DEBUGLEVEL DEBUGLEVEL_CLASS[DBGC_ALL]
++#define DEBUGLEVEL 0
+
+ /*
+ * Define all new debug classes here. A class is represented by an entry in
+--- a/source3/nmbd/asyncdns.c
++++ b/source3/nmbd/asyncdns.c
+@@ -85,7 +85,7 @@ static void asyncdns_process(void)
+ struct query_record r;
+ unstring qname;
+
+- DEBUGLEVEL = -1;
++ DEBUGLEVEL_CLASS[DBGC_ALL] = -1;
+
+ while (1) {
+ NTSTATUS status;
diff --git a/package/network/services/samba36/patches/.svn/text-base/330-librpc_default_print.patch.svn-base b/package/network/services/samba36/patches/.svn/text-base/330-librpc_default_print.patch.svn-base
new file mode 100644
index 0000000..4d16086
--- /dev/null
+++ b/package/network/services/samba36/patches/.svn/text-base/330-librpc_default_print.patch.svn-base
@@ -0,0 +1,8854 @@
+--- a/source3/librpc/ndr/util.c
++++ b/source3/librpc/ndr/util.c
+@@ -28,3 +28,7 @@ _PUBLIC_ void ndr_print_sockaddr_storage
+ char addr[INET6_ADDRSTRLEN];
+ ndr->print(ndr, "%-25s: %s", name, print_sockaddr(addr, sizeof(addr), ss));
+ }
++
++_PUBLIC_ void ndr_print_disabled(struct ndr_print *ndr, const char *name, int flags, void *r)
++{
++}
+--- a/source3/librpc/gen_ndr/ndr_atsvc.c
++++ b/source3/librpc/gen_ndr/ndr_atsvc.c
+@@ -867,7 +867,7 @@ static const struct ndr_interface_call a
+ sizeof(struct atsvc_JobAdd),
+ (ndr_push_flags_fn_t) ndr_push_atsvc_JobAdd,
+ (ndr_pull_flags_fn_t) ndr_pull_atsvc_JobAdd,
+- (ndr_print_function_t) ndr_print_atsvc_JobAdd,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -876,7 +876,7 @@ static const struct ndr_interface_call a
+ sizeof(struct atsvc_JobDel),
+ (ndr_push_flags_fn_t) ndr_push_atsvc_JobDel,
+ (ndr_pull_flags_fn_t) ndr_pull_atsvc_JobDel,
+- (ndr_print_function_t) ndr_print_atsvc_JobDel,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -885,7 +885,7 @@ static const struct ndr_interface_call a
+ sizeof(struct atsvc_JobEnum),
+ (ndr_push_flags_fn_t) ndr_push_atsvc_JobEnum,
+ (ndr_pull_flags_fn_t) ndr_pull_atsvc_JobEnum,
+- (ndr_print_function_t) ndr_print_atsvc_JobEnum,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -894,7 +894,7 @@ static const struct ndr_interface_call a
+ sizeof(struct atsvc_JobGetInfo),
+ (ndr_push_flags_fn_t) ndr_push_atsvc_JobGetInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_atsvc_JobGetInfo,
+- (ndr_print_function_t) ndr_print_atsvc_JobGetInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_audiosrv.c
++++ b/source3/librpc/gen_ndr/ndr_audiosrv.c
+@@ -594,7 +594,7 @@ static const struct ndr_interface_call a
+ sizeof(struct audiosrv_CreatezoneFactoriesList),
+ (ndr_push_flags_fn_t) ndr_push_audiosrv_CreatezoneFactoriesList,
+ (ndr_pull_flags_fn_t) ndr_pull_audiosrv_CreatezoneFactoriesList,
+- (ndr_print_function_t) ndr_print_audiosrv_CreatezoneFactoriesList,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -603,7 +603,7 @@ static const struct ndr_interface_call a
+ sizeof(struct audiosrv_CreateGfxFactoriesList),
+ (ndr_push_flags_fn_t) ndr_push_audiosrv_CreateGfxFactoriesList,
+ (ndr_pull_flags_fn_t) ndr_pull_audiosrv_CreateGfxFactoriesList,
+- (ndr_print_function_t) ndr_print_audiosrv_CreateGfxFactoriesList,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -612,7 +612,7 @@ static const struct ndr_interface_call a
+ sizeof(struct audiosrv_CreateGfxList),
+ (ndr_push_flags_fn_t) ndr_push_audiosrv_CreateGfxList,
+ (ndr_pull_flags_fn_t) ndr_pull_audiosrv_CreateGfxList,
+- (ndr_print_function_t) ndr_print_audiosrv_CreateGfxList,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -621,7 +621,7 @@ static const struct ndr_interface_call a
+ sizeof(struct audiosrv_RemoveGfx),
+ (ndr_push_flags_fn_t) ndr_push_audiosrv_RemoveGfx,
+ (ndr_pull_flags_fn_t) ndr_pull_audiosrv_RemoveGfx,
+- (ndr_print_function_t) ndr_print_audiosrv_RemoveGfx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -630,7 +630,7 @@ static const struct ndr_interface_call a
+ sizeof(struct audiosrv_AddGfx),
+ (ndr_push_flags_fn_t) ndr_push_audiosrv_AddGfx,
+ (ndr_pull_flags_fn_t) ndr_pull_audiosrv_AddGfx,
+- (ndr_print_function_t) ndr_print_audiosrv_AddGfx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -639,7 +639,7 @@ static const struct ndr_interface_call a
+ sizeof(struct audiosrv_ModifyGfx),
+ (ndr_push_flags_fn_t) ndr_push_audiosrv_ModifyGfx,
+ (ndr_pull_flags_fn_t) ndr_pull_audiosrv_ModifyGfx,
+- (ndr_print_function_t) ndr_print_audiosrv_ModifyGfx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -648,7 +648,7 @@ static const struct ndr_interface_call a
+ sizeof(struct audiosrv_OpenGfx),
+ (ndr_push_flags_fn_t) ndr_push_audiosrv_OpenGfx,
+ (ndr_pull_flags_fn_t) ndr_pull_audiosrv_OpenGfx,
+- (ndr_print_function_t) ndr_print_audiosrv_OpenGfx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -657,7 +657,7 @@ static const struct ndr_interface_call a
+ sizeof(struct audiosrv_Logon),
+ (ndr_push_flags_fn_t) ndr_push_audiosrv_Logon,
+ (ndr_pull_flags_fn_t) ndr_pull_audiosrv_Logon,
+- (ndr_print_function_t) ndr_print_audiosrv_Logon,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -666,7 +666,7 @@ static const struct ndr_interface_call a
+ sizeof(struct audiosrv_Logoff),
+ (ndr_push_flags_fn_t) ndr_push_audiosrv_Logoff,
+ (ndr_pull_flags_fn_t) ndr_pull_audiosrv_Logoff,
+- (ndr_print_function_t) ndr_print_audiosrv_Logoff,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -675,7 +675,7 @@ static const struct ndr_interface_call a
+ sizeof(struct audiosrv_RegisterSessionNotificationEvent),
+ (ndr_push_flags_fn_t) ndr_push_audiosrv_RegisterSessionNotificationEvent,
+ (ndr_pull_flags_fn_t) ndr_pull_audiosrv_RegisterSessionNotificationEvent,
+- (ndr_print_function_t) ndr_print_audiosrv_RegisterSessionNotificationEvent,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -684,7 +684,7 @@ static const struct ndr_interface_call a
+ sizeof(struct audiosrv_UnregisterSessionNotificationEvent),
+ (ndr_push_flags_fn_t) ndr_push_audiosrv_UnregisterSessionNotificationEvent,
+ (ndr_pull_flags_fn_t) ndr_pull_audiosrv_UnregisterSessionNotificationEvent,
+- (ndr_print_function_t) ndr_print_audiosrv_UnregisterSessionNotificationEvent,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -693,7 +693,7 @@ static const struct ndr_interface_call a
+ sizeof(struct audiosrv_SessionConnectState),
+ (ndr_push_flags_fn_t) ndr_push_audiosrv_SessionConnectState,
+ (ndr_pull_flags_fn_t) ndr_pull_audiosrv_SessionConnectState,
+- (ndr_print_function_t) ndr_print_audiosrv_SessionConnectState,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -702,7 +702,7 @@ static const struct ndr_interface_call a
+ sizeof(struct audiosrv_DriverOpenDrvRegKey),
+ (ndr_push_flags_fn_t) ndr_push_audiosrv_DriverOpenDrvRegKey,
+ (ndr_pull_flags_fn_t) ndr_pull_audiosrv_DriverOpenDrvRegKey,
+- (ndr_print_function_t) ndr_print_audiosrv_DriverOpenDrvRegKey,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -711,7 +711,7 @@ static const struct ndr_interface_call a
+ sizeof(struct audiosrv_AdvisePreferredDeviceChange),
+ (ndr_push_flags_fn_t) ndr_push_audiosrv_AdvisePreferredDeviceChange,
+ (ndr_pull_flags_fn_t) ndr_pull_audiosrv_AdvisePreferredDeviceChange,
+- (ndr_print_function_t) ndr_print_audiosrv_AdvisePreferredDeviceChange,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -720,7 +720,7 @@ static const struct ndr_interface_call a
+ sizeof(struct audiosrv_GetPnpInfo),
+ (ndr_push_flags_fn_t) ndr_push_audiosrv_GetPnpInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_audiosrv_GetPnpInfo,
+- (ndr_print_function_t) ndr_print_audiosrv_GetPnpInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_backupkey.c
++++ b/source3/librpc/gen_ndr/ndr_backupkey.c
+@@ -740,7 +740,7 @@ static const struct ndr_interface_call b
+ sizeof(struct bkrp_BackupKey),
+ (ndr_push_flags_fn_t) ndr_push_bkrp_BackupKey,
+ (ndr_pull_flags_fn_t) ndr_pull_bkrp_BackupKey,
+- (ndr_print_function_t) ndr_print_bkrp_BackupKey,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_browser.c
++++ b/source3/librpc/gen_ndr/ndr_browser.c
+@@ -928,7 +928,7 @@ static const struct ndr_interface_call b
+ sizeof(struct BrowserrServerEnum),
+ (ndr_push_flags_fn_t) ndr_push_BrowserrServerEnum,
+ (ndr_pull_flags_fn_t) ndr_pull_BrowserrServerEnum,
+- (ndr_print_function_t) ndr_print_BrowserrServerEnum,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -937,7 +937,7 @@ static const struct ndr_interface_call b
+ sizeof(struct BrowserrDebugCall),
+ (ndr_push_flags_fn_t) ndr_push_BrowserrDebugCall,
+ (ndr_pull_flags_fn_t) ndr_pull_BrowserrDebugCall,
+- (ndr_print_function_t) ndr_print_BrowserrDebugCall,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -946,7 +946,7 @@ static const struct ndr_interface_call b
+ sizeof(struct BrowserrQueryOtherDomains),
+ (ndr_push_flags_fn_t) ndr_push_BrowserrQueryOtherDomains,
+ (ndr_pull_flags_fn_t) ndr_pull_BrowserrQueryOtherDomains,
+- (ndr_print_function_t) ndr_print_BrowserrQueryOtherDomains,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -955,7 +955,7 @@ static const struct ndr_interface_call b
+ sizeof(struct BrowserrResetNetlogonState),
+ (ndr_push_flags_fn_t) ndr_push_BrowserrResetNetlogonState,
+ (ndr_pull_flags_fn_t) ndr_pull_BrowserrResetNetlogonState,
+- (ndr_print_function_t) ndr_print_BrowserrResetNetlogonState,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -964,7 +964,7 @@ static const struct ndr_interface_call b
+ sizeof(struct BrowserrDebugTrace),
+ (ndr_push_flags_fn_t) ndr_push_BrowserrDebugTrace,
+ (ndr_pull_flags_fn_t) ndr_pull_BrowserrDebugTrace,
+- (ndr_print_function_t) ndr_print_BrowserrDebugTrace,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -973,7 +973,7 @@ static const struct ndr_interface_call b
+ sizeof(struct BrowserrQueryStatistics),
+ (ndr_push_flags_fn_t) ndr_push_BrowserrQueryStatistics,
+ (ndr_pull_flags_fn_t) ndr_pull_BrowserrQueryStatistics,
+- (ndr_print_function_t) ndr_print_BrowserrQueryStatistics,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -982,7 +982,7 @@ static const struct ndr_interface_call b
+ sizeof(struct BrowserResetStatistics),
+ (ndr_push_flags_fn_t) ndr_push_BrowserResetStatistics,
+ (ndr_pull_flags_fn_t) ndr_pull_BrowserResetStatistics,
+- (ndr_print_function_t) ndr_print_BrowserResetStatistics,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -991,7 +991,7 @@ static const struct ndr_interface_call b
+ sizeof(struct NetrBrowserStatisticsClear),
+ (ndr_push_flags_fn_t) ndr_push_NetrBrowserStatisticsClear,
+ (ndr_pull_flags_fn_t) ndr_pull_NetrBrowserStatisticsClear,
+- (ndr_print_function_t) ndr_print_NetrBrowserStatisticsClear,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1000,7 +1000,7 @@ static const struct ndr_interface_call b
+ sizeof(struct NetrBrowserStatisticsGet),
+ (ndr_push_flags_fn_t) ndr_push_NetrBrowserStatisticsGet,
+ (ndr_pull_flags_fn_t) ndr_pull_NetrBrowserStatisticsGet,
+- (ndr_print_function_t) ndr_print_NetrBrowserStatisticsGet,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1009,7 +1009,7 @@ static const struct ndr_interface_call b
+ sizeof(struct BrowserrSetNetlogonState),
+ (ndr_push_flags_fn_t) ndr_push_BrowserrSetNetlogonState,
+ (ndr_pull_flags_fn_t) ndr_pull_BrowserrSetNetlogonState,
+- (ndr_print_function_t) ndr_print_BrowserrSetNetlogonState,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1018,7 +1018,7 @@ static const struct ndr_interface_call b
+ sizeof(struct BrowserrQueryEmulatedDomains),
+ (ndr_push_flags_fn_t) ndr_push_BrowserrQueryEmulatedDomains,
+ (ndr_pull_flags_fn_t) ndr_pull_BrowserrQueryEmulatedDomains,
+- (ndr_print_function_t) ndr_print_BrowserrQueryEmulatedDomains,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1027,7 +1027,7 @@ static const struct ndr_interface_call b
+ sizeof(struct BrowserrServerEnumEx),
+ (ndr_push_flags_fn_t) ndr_push_BrowserrServerEnumEx,
+ (ndr_pull_flags_fn_t) ndr_pull_BrowserrServerEnumEx,
+- (ndr_print_function_t) ndr_print_BrowserrServerEnumEx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_dbgidl.c
++++ b/source3/librpc/gen_ndr/ndr_dbgidl.c
+@@ -48,7 +48,7 @@ static const struct ndr_interface_call d
+ sizeof(struct dummy_dbgidl),
+ (ndr_push_flags_fn_t) ndr_push_dummy_dbgidl,
+ (ndr_pull_flags_fn_t) ndr_pull_dummy_dbgidl,
+- (ndr_print_function_t) ndr_print_dummy_dbgidl,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_dcom.c
++++ b/source3/librpc/gen_ndr/ndr_dcom.c
+@@ -128,7 +128,7 @@ static const struct ndr_interface_call d
+ sizeof(struct UseProtSeq),
+ (ndr_push_flags_fn_t) ndr_push_UseProtSeq,
+ (ndr_pull_flags_fn_t) ndr_pull_UseProtSeq,
+- (ndr_print_function_t) ndr_print_UseProtSeq,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -137,7 +137,7 @@ static const struct ndr_interface_call d
+ sizeof(struct GetCustomProtseqInfo),
+ (ndr_push_flags_fn_t) ndr_push_GetCustomProtseqInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_GetCustomProtseqInfo,
+- (ndr_print_function_t) ndr_print_GetCustomProtseqInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -146,7 +146,7 @@ static const struct ndr_interface_call d
+ sizeof(struct UpdateResolverBindings),
+ (ndr_push_flags_fn_t) ndr_push_UpdateResolverBindings,
+ (ndr_pull_flags_fn_t) ndr_pull_UpdateResolverBindings,
+- (ndr_print_function_t) ndr_print_UpdateResolverBindings,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -450,7 +450,7 @@ static const struct ndr_interface_call I
+ sizeof(struct QueryInterface),
+ (ndr_push_flags_fn_t) ndr_push_QueryInterface,
+ (ndr_pull_flags_fn_t) ndr_pull_QueryInterface,
+- (ndr_print_function_t) ndr_print_QueryInterface,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -459,7 +459,7 @@ static const struct ndr_interface_call I
+ sizeof(struct AddRef),
+ (ndr_push_flags_fn_t) ndr_push_AddRef,
+ (ndr_pull_flags_fn_t) ndr_pull_AddRef,
+- (ndr_print_function_t) ndr_print_AddRef,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -468,7 +468,7 @@ static const struct ndr_interface_call I
+ sizeof(struct Release),
+ (ndr_push_flags_fn_t) ndr_push_Release,
+ (ndr_pull_flags_fn_t) ndr_pull_Release,
+- (ndr_print_function_t) ndr_print_Release,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -849,7 +849,7 @@ static const struct ndr_interface_call I
+ sizeof(struct CreateInstance),
+ (ndr_push_flags_fn_t) ndr_push_CreateInstance,
+ (ndr_pull_flags_fn_t) ndr_pull_CreateInstance,
+- (ndr_print_function_t) ndr_print_CreateInstance,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -858,7 +858,7 @@ static const struct ndr_interface_call I
+ sizeof(struct RemoteCreateInstance),
+ (ndr_push_flags_fn_t) ndr_push_RemoteCreateInstance,
+ (ndr_pull_flags_fn_t) ndr_pull_RemoteCreateInstance,
+- (ndr_print_function_t) ndr_print_RemoteCreateInstance,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -867,7 +867,7 @@ static const struct ndr_interface_call I
+ sizeof(struct LockServer),
+ (ndr_push_flags_fn_t) ndr_push_LockServer,
+ (ndr_pull_flags_fn_t) ndr_pull_LockServer,
+- (ndr_print_function_t) ndr_print_LockServer,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -876,7 +876,7 @@ static const struct ndr_interface_call I
+ sizeof(struct RemoteLockServer),
+ (ndr_push_flags_fn_t) ndr_push_RemoteLockServer,
+ (ndr_pull_flags_fn_t) ndr_pull_RemoteLockServer,
+- (ndr_print_function_t) ndr_print_RemoteLockServer,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1434,7 +1434,7 @@ static const struct ndr_interface_call I
+ sizeof(struct RemQueryInterface),
+ (ndr_push_flags_fn_t) ndr_push_RemQueryInterface,
+ (ndr_pull_flags_fn_t) ndr_pull_RemQueryInterface,
+- (ndr_print_function_t) ndr_print_RemQueryInterface,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1443,7 +1443,7 @@ static const struct ndr_interface_call I
+ sizeof(struct RemAddRef),
+ (ndr_push_flags_fn_t) ndr_push_RemAddRef,
+ (ndr_pull_flags_fn_t) ndr_pull_RemAddRef,
+- (ndr_print_function_t) ndr_print_RemAddRef,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1452,7 +1452,7 @@ static const struct ndr_interface_call I
+ sizeof(struct RemRelease),
+ (ndr_push_flags_fn_t) ndr_push_RemRelease,
+ (ndr_pull_flags_fn_t) ndr_pull_RemRelease,
+- (ndr_print_function_t) ndr_print_RemRelease,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1590,7 +1590,7 @@ static const struct ndr_interface_call I
+ sizeof(struct GetClassObject),
+ (ndr_push_flags_fn_t) ndr_push_GetClassObject,
+ (ndr_pull_flags_fn_t) ndr_pull_GetClassObject,
+- (ndr_print_function_t) ndr_print_GetClassObject,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1701,7 +1701,7 @@ static const struct ndr_interface_call I
+ sizeof(struct ISCMLocalActivator_CreateInstance),
+ (ndr_push_flags_fn_t) ndr_push_ISCMLocalActivator_CreateInstance,
+ (ndr_pull_flags_fn_t) ndr_pull_ISCMLocalActivator_CreateInstance,
+- (ndr_print_function_t) ndr_print_ISCMLocalActivator_CreateInstance,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1788,7 +1788,7 @@ static const struct ndr_interface_call I
+ sizeof(struct IMachineLocalActivator_foo),
+ (ndr_push_flags_fn_t) ndr_push_IMachineLocalActivator_foo,
+ (ndr_pull_flags_fn_t) ndr_pull_IMachineLocalActivator_foo,
+- (ndr_print_function_t) ndr_print_IMachineLocalActivator_foo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1875,7 +1875,7 @@ static const struct ndr_interface_call I
+ sizeof(struct ILocalObjectExporter_Foo),
+ (ndr_push_flags_fn_t) ndr_push_ILocalObjectExporter_Foo,
+ (ndr_pull_flags_fn_t) ndr_pull_ILocalObjectExporter_Foo,
+- (ndr_print_function_t) ndr_print_ILocalObjectExporter_Foo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2031,7 +2031,7 @@ static const struct ndr_interface_call I
+ sizeof(struct ISystemActivatorRemoteCreateInstance),
+ (ndr_push_flags_fn_t) ndr_push_ISystemActivatorRemoteCreateInstance,
+ (ndr_pull_flags_fn_t) ndr_pull_ISystemActivatorRemoteCreateInstance,
+- (ndr_print_function_t) ndr_print_ISystemActivatorRemoteCreateInstance,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2319,7 +2319,7 @@ static const struct ndr_interface_call I
+ sizeof(struct RemQueryInterface2),
+ (ndr_push_flags_fn_t) ndr_push_RemQueryInterface2,
+ (ndr_pull_flags_fn_t) ndr_pull_RemQueryInterface2,
+- (ndr_print_function_t) ndr_print_RemQueryInterface2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3040,7 +3040,7 @@ static const struct ndr_interface_call I
+ sizeof(struct GetTypeInfoCount),
+ (ndr_push_flags_fn_t) ndr_push_GetTypeInfoCount,
+ (ndr_pull_flags_fn_t) ndr_pull_GetTypeInfoCount,
+- (ndr_print_function_t) ndr_print_GetTypeInfoCount,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3049,7 +3049,7 @@ static const struct ndr_interface_call I
+ sizeof(struct GetTypeInfo),
+ (ndr_push_flags_fn_t) ndr_push_GetTypeInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_GetTypeInfo,
+- (ndr_print_function_t) ndr_print_GetTypeInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3058,7 +3058,7 @@ static const struct ndr_interface_call I
+ sizeof(struct GetIDsOfNames),
+ (ndr_push_flags_fn_t) ndr_push_GetIDsOfNames,
+ (ndr_pull_flags_fn_t) ndr_pull_GetIDsOfNames,
+- (ndr_print_function_t) ndr_print_GetIDsOfNames,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3067,7 +3067,7 @@ static const struct ndr_interface_call I
+ sizeof(struct Invoke),
+ (ndr_push_flags_fn_t) ndr_push_Invoke,
+ (ndr_pull_flags_fn_t) ndr_pull_Invoke,
+- (ndr_print_function_t) ndr_print_Invoke,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3243,7 +3243,7 @@ static const struct ndr_interface_call I
+ sizeof(struct MarshalInterface),
+ (ndr_push_flags_fn_t) ndr_push_MarshalInterface,
+ (ndr_pull_flags_fn_t) ndr_pull_MarshalInterface,
+- (ndr_print_function_t) ndr_print_MarshalInterface,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3252,7 +3252,7 @@ static const struct ndr_interface_call I
+ sizeof(struct UnMarshalInterface),
+ (ndr_push_flags_fn_t) ndr_push_UnMarshalInterface,
+ (ndr_pull_flags_fn_t) ndr_pull_UnMarshalInterface,
+- (ndr_print_function_t) ndr_print_UnMarshalInterface,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3385,7 +3385,7 @@ static const struct ndr_interface_call I
+ sizeof(struct MakeCoffee),
+ (ndr_push_flags_fn_t) ndr_push_MakeCoffee,
+ (ndr_pull_flags_fn_t) ndr_pull_MakeCoffee,
+- (ndr_print_function_t) ndr_print_MakeCoffee,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3681,7 +3681,7 @@ static const struct ndr_interface_call I
+ sizeof(struct Read),
+ (ndr_push_flags_fn_t) ndr_push_Read,
+ (ndr_pull_flags_fn_t) ndr_pull_Read,
+- (ndr_print_function_t) ndr_print_Read,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3690,7 +3690,7 @@ static const struct ndr_interface_call I
+ sizeof(struct Write),
+ (ndr_push_flags_fn_t) ndr_push_Write,
+ (ndr_pull_flags_fn_t) ndr_pull_Write,
+- (ndr_print_function_t) ndr_print_Write,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_dfs.c
++++ b/source3/librpc/gen_ndr/ndr_dfs.c
+@@ -5910,7 +5910,7 @@ static const struct ndr_interface_call n
+ sizeof(struct dfs_GetManagerVersion),
+ (ndr_push_flags_fn_t) ndr_push_dfs_GetManagerVersion,
+ (ndr_pull_flags_fn_t) ndr_pull_dfs_GetManagerVersion,
+- (ndr_print_function_t) ndr_print_dfs_GetManagerVersion,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5919,7 +5919,7 @@ static const struct ndr_interface_call n
+ sizeof(struct dfs_Add),
+ (ndr_push_flags_fn_t) ndr_push_dfs_Add,
+ (ndr_pull_flags_fn_t) ndr_pull_dfs_Add,
+- (ndr_print_function_t) ndr_print_dfs_Add,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5928,7 +5928,7 @@ static const struct ndr_interface_call n
+ sizeof(struct dfs_Remove),
+ (ndr_push_flags_fn_t) ndr_push_dfs_Remove,
+ (ndr_pull_flags_fn_t) ndr_pull_dfs_Remove,
+- (ndr_print_function_t) ndr_print_dfs_Remove,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5937,7 +5937,7 @@ static const struct ndr_interface_call n
+ sizeof(struct dfs_SetInfo),
+ (ndr_push_flags_fn_t) ndr_push_dfs_SetInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_dfs_SetInfo,
+- (ndr_print_function_t) ndr_print_dfs_SetInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5946,7 +5946,7 @@ static const struct ndr_interface_call n
+ sizeof(struct dfs_GetInfo),
+ (ndr_push_flags_fn_t) ndr_push_dfs_GetInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_dfs_GetInfo,
+- (ndr_print_function_t) ndr_print_dfs_GetInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5955,7 +5955,7 @@ static const struct ndr_interface_call n
+ sizeof(struct dfs_Enum),
+ (ndr_push_flags_fn_t) ndr_push_dfs_Enum,
+ (ndr_pull_flags_fn_t) ndr_pull_dfs_Enum,
+- (ndr_print_function_t) ndr_print_dfs_Enum,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5964,7 +5964,7 @@ static const struct ndr_interface_call n
+ sizeof(struct dfs_Rename),
+ (ndr_push_flags_fn_t) ndr_push_dfs_Rename,
+ (ndr_pull_flags_fn_t) ndr_pull_dfs_Rename,
+- (ndr_print_function_t) ndr_print_dfs_Rename,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5973,7 +5973,7 @@ static const struct ndr_interface_call n
+ sizeof(struct dfs_Move),
+ (ndr_push_flags_fn_t) ndr_push_dfs_Move,
+ (ndr_pull_flags_fn_t) ndr_pull_dfs_Move,
+- (ndr_print_function_t) ndr_print_dfs_Move,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5982,7 +5982,7 @@ static const struct ndr_interface_call n
+ sizeof(struct dfs_ManagerGetConfigInfo),
+ (ndr_push_flags_fn_t) ndr_push_dfs_ManagerGetConfigInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_dfs_ManagerGetConfigInfo,
+- (ndr_print_function_t) ndr_print_dfs_ManagerGetConfigInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5991,7 +5991,7 @@ static const struct ndr_interface_call n
+ sizeof(struct dfs_ManagerSendSiteInfo),
+ (ndr_push_flags_fn_t) ndr_push_dfs_ManagerSendSiteInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_dfs_ManagerSendSiteInfo,
+- (ndr_print_function_t) ndr_print_dfs_ManagerSendSiteInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -6000,7 +6000,7 @@ static const struct ndr_interface_call n
+ sizeof(struct dfs_AddFtRoot),
+ (ndr_push_flags_fn_t) ndr_push_dfs_AddFtRoot,
+ (ndr_pull_flags_fn_t) ndr_pull_dfs_AddFtRoot,
+- (ndr_print_function_t) ndr_print_dfs_AddFtRoot,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -6009,7 +6009,7 @@ static const struct ndr_interface_call n
+ sizeof(struct dfs_RemoveFtRoot),
+ (ndr_push_flags_fn_t) ndr_push_dfs_RemoveFtRoot,
+ (ndr_pull_flags_fn_t) ndr_pull_dfs_RemoveFtRoot,
+- (ndr_print_function_t) ndr_print_dfs_RemoveFtRoot,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -6018,7 +6018,7 @@ static const struct ndr_interface_call n
+ sizeof(struct dfs_AddStdRoot),
+ (ndr_push_flags_fn_t) ndr_push_dfs_AddStdRoot,
+ (ndr_pull_flags_fn_t) ndr_pull_dfs_AddStdRoot,
+- (ndr_print_function_t) ndr_print_dfs_AddStdRoot,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -6027,7 +6027,7 @@ static const struct ndr_interface_call n
+ sizeof(struct dfs_RemoveStdRoot),
+ (ndr_push_flags_fn_t) ndr_push_dfs_RemoveStdRoot,
+ (ndr_pull_flags_fn_t) ndr_pull_dfs_RemoveStdRoot,
+- (ndr_print_function_t) ndr_print_dfs_RemoveStdRoot,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -6036,7 +6036,7 @@ static const struct ndr_interface_call n
+ sizeof(struct dfs_ManagerInitialize),
+ (ndr_push_flags_fn_t) ndr_push_dfs_ManagerInitialize,
+ (ndr_pull_flags_fn_t) ndr_pull_dfs_ManagerInitialize,
+- (ndr_print_function_t) ndr_print_dfs_ManagerInitialize,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -6045,7 +6045,7 @@ static const struct ndr_interface_call n
+ sizeof(struct dfs_AddStdRootForced),
+ (ndr_push_flags_fn_t) ndr_push_dfs_AddStdRootForced,
+ (ndr_pull_flags_fn_t) ndr_pull_dfs_AddStdRootForced,
+- (ndr_print_function_t) ndr_print_dfs_AddStdRootForced,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -6054,7 +6054,7 @@ static const struct ndr_interface_call n
+ sizeof(struct dfs_GetDcAddress),
+ (ndr_push_flags_fn_t) ndr_push_dfs_GetDcAddress,
+ (ndr_pull_flags_fn_t) ndr_pull_dfs_GetDcAddress,
+- (ndr_print_function_t) ndr_print_dfs_GetDcAddress,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -6063,7 +6063,7 @@ static const struct ndr_interface_call n
+ sizeof(struct dfs_SetDcAddress),
+ (ndr_push_flags_fn_t) ndr_push_dfs_SetDcAddress,
+ (ndr_pull_flags_fn_t) ndr_pull_dfs_SetDcAddress,
+- (ndr_print_function_t) ndr_print_dfs_SetDcAddress,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -6072,7 +6072,7 @@ static const struct ndr_interface_call n
+ sizeof(struct dfs_FlushFtTable),
+ (ndr_push_flags_fn_t) ndr_push_dfs_FlushFtTable,
+ (ndr_pull_flags_fn_t) ndr_pull_dfs_FlushFtTable,
+- (ndr_print_function_t) ndr_print_dfs_FlushFtTable,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -6081,7 +6081,7 @@ static const struct ndr_interface_call n
+ sizeof(struct dfs_Add2),
+ (ndr_push_flags_fn_t) ndr_push_dfs_Add2,
+ (ndr_pull_flags_fn_t) ndr_pull_dfs_Add2,
+- (ndr_print_function_t) ndr_print_dfs_Add2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -6090,7 +6090,7 @@ static const struct ndr_interface_call n
+ sizeof(struct dfs_Remove2),
+ (ndr_push_flags_fn_t) ndr_push_dfs_Remove2,
+ (ndr_pull_flags_fn_t) ndr_pull_dfs_Remove2,
+- (ndr_print_function_t) ndr_print_dfs_Remove2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -6099,7 +6099,7 @@ static const struct ndr_interface_call n
+ sizeof(struct dfs_EnumEx),
+ (ndr_push_flags_fn_t) ndr_push_dfs_EnumEx,
+ (ndr_pull_flags_fn_t) ndr_pull_dfs_EnumEx,
+- (ndr_print_function_t) ndr_print_dfs_EnumEx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -6108,7 +6108,7 @@ static const struct ndr_interface_call n
+ sizeof(struct dfs_SetInfo2),
+ (ndr_push_flags_fn_t) ndr_push_dfs_SetInfo2,
+ (ndr_pull_flags_fn_t) ndr_pull_dfs_SetInfo2,
+- (ndr_print_function_t) ndr_print_dfs_SetInfo2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_dfsblobs.c
++++ b/source3/librpc/gen_ndr/ndr_dfsblobs.c
+@@ -1398,7 +1398,7 @@ static const struct ndr_interface_call d
+ sizeof(struct dfs_GetDFSReferral),
+ (ndr_push_flags_fn_t) ndr_push_dfs_GetDFSReferral,
+ (ndr_pull_flags_fn_t) ndr_pull_dfs_GetDFSReferral,
+- (ndr_print_function_t) ndr_print_dfs_GetDFSReferral,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_dns.c
++++ b/source3/librpc/gen_ndr/ndr_dns.c
+@@ -860,7 +860,7 @@ static const struct ndr_interface_call d
+ sizeof(struct decode_dns_name_packet),
+ (ndr_push_flags_fn_t) ndr_push_decode_dns_name_packet,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_dns_name_packet,
+- (ndr_print_function_t) ndr_print_decode_dns_name_packet,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_dnsp.c
++++ b/source3/librpc/gen_ndr/ndr_dnsp.c
+@@ -700,7 +700,7 @@ static const struct ndr_interface_call d
+ sizeof(struct decode_DnssrvRpcRecord),
+ (ndr_push_flags_fn_t) ndr_push_decode_DnssrvRpcRecord,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_DnssrvRpcRecord,
+- (ndr_print_function_t) ndr_print_decode_DnssrvRpcRecord,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_dnsserver.c
++++ b/source3/librpc/gen_ndr/ndr_dnsserver.c
+@@ -48,7 +48,7 @@ static const struct ndr_interface_call d
+ sizeof(struct dnsserver_foo),
+ (ndr_push_flags_fn_t) ndr_push_dnsserver_foo,
+ (ndr_pull_flags_fn_t) ndr_pull_dnsserver_foo,
+- (ndr_print_function_t) ndr_print_dnsserver_foo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_drsblobs.c
++++ b/source3/librpc/gen_ndr/ndr_drsblobs.c
+@@ -5275,7 +5275,7 @@ static const struct ndr_interface_call d
+ sizeof(struct decode_replPropertyMetaData),
+ (ndr_push_flags_fn_t) ndr_push_decode_replPropertyMetaData,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_replPropertyMetaData,
+- (ndr_print_function_t) ndr_print_decode_replPropertyMetaData,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5284,7 +5284,7 @@ static const struct ndr_interface_call d
+ sizeof(struct decode_replUpToDateVector),
+ (ndr_push_flags_fn_t) ndr_push_decode_replUpToDateVector,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_replUpToDateVector,
+- (ndr_print_function_t) ndr_print_decode_replUpToDateVector,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5293,7 +5293,7 @@ static const struct ndr_interface_call d
+ sizeof(struct decode_repsFromTo),
+ (ndr_push_flags_fn_t) ndr_push_decode_repsFromTo,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_repsFromTo,
+- (ndr_print_function_t) ndr_print_decode_repsFromTo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5302,7 +5302,7 @@ static const struct ndr_interface_call d
+ sizeof(struct decode_partialAttributeSet),
+ (ndr_push_flags_fn_t) ndr_push_decode_partialAttributeSet,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_partialAttributeSet,
+- (ndr_print_function_t) ndr_print_decode_partialAttributeSet,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5311,7 +5311,7 @@ static const struct ndr_interface_call d
+ sizeof(struct decode_prefixMap),
+ (ndr_push_flags_fn_t) ndr_push_decode_prefixMap,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_prefixMap,
+- (ndr_print_function_t) ndr_print_decode_prefixMap,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5320,7 +5320,7 @@ static const struct ndr_interface_call d
+ sizeof(struct decode_ldapControlDirSync),
+ (ndr_push_flags_fn_t) ndr_push_decode_ldapControlDirSync,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_ldapControlDirSync,
+- (ndr_print_function_t) ndr_print_decode_ldapControlDirSync,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5329,7 +5329,7 @@ static const struct ndr_interface_call d
+ sizeof(struct decode_supplementalCredentials),
+ (ndr_push_flags_fn_t) ndr_push_decode_supplementalCredentials,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_supplementalCredentials,
+- (ndr_print_function_t) ndr_print_decode_supplementalCredentials,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5338,7 +5338,7 @@ static const struct ndr_interface_call d
+ sizeof(struct decode_Packages),
+ (ndr_push_flags_fn_t) ndr_push_decode_Packages,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_Packages,
+- (ndr_print_function_t) ndr_print_decode_Packages,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5347,7 +5347,7 @@ static const struct ndr_interface_call d
+ sizeof(struct decode_PrimaryKerberos),
+ (ndr_push_flags_fn_t) ndr_push_decode_PrimaryKerberos,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_PrimaryKerberos,
+- (ndr_print_function_t) ndr_print_decode_PrimaryKerberos,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5356,7 +5356,7 @@ static const struct ndr_interface_call d
+ sizeof(struct decode_PrimaryCLEARTEXT),
+ (ndr_push_flags_fn_t) ndr_push_decode_PrimaryCLEARTEXT,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_PrimaryCLEARTEXT,
+- (ndr_print_function_t) ndr_print_decode_PrimaryCLEARTEXT,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5365,7 +5365,7 @@ static const struct ndr_interface_call d
+ sizeof(struct decode_PrimaryWDigest),
+ (ndr_push_flags_fn_t) ndr_push_decode_PrimaryWDigest,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_PrimaryWDigest,
+- (ndr_print_function_t) ndr_print_decode_PrimaryWDigest,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5374,7 +5374,7 @@ static const struct ndr_interface_call d
+ sizeof(struct decode_trustAuthInOut),
+ (ndr_push_flags_fn_t) ndr_push_decode_trustAuthInOut,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_trustAuthInOut,
+- (ndr_print_function_t) ndr_print_decode_trustAuthInOut,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5383,7 +5383,7 @@ static const struct ndr_interface_call d
+ sizeof(struct decode_trustDomainPasswords),
+ (ndr_push_flags_fn_t) ndr_push_decode_trustDomainPasswords,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_trustDomainPasswords,
+- (ndr_print_function_t) ndr_print_decode_trustDomainPasswords,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5392,7 +5392,7 @@ static const struct ndr_interface_call d
+ sizeof(struct decode_ExtendedErrorInfo),
+ (ndr_push_flags_fn_t) ndr_push_decode_ExtendedErrorInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_ExtendedErrorInfo,
+- (ndr_print_function_t) ndr_print_decode_ExtendedErrorInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5401,7 +5401,7 @@ static const struct ndr_interface_call d
+ sizeof(struct decode_ForestTrustInfo),
+ (ndr_push_flags_fn_t) ndr_push_decode_ForestTrustInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_ForestTrustInfo,
+- (ndr_print_function_t) ndr_print_decode_ForestTrustInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_drsuapi.c
++++ b/source3/librpc/gen_ndr/ndr_drsuapi.c
+@@ -16500,7 +16500,7 @@ static const struct ndr_interface_call d
+ sizeof(struct drsuapi_DsBind),
+ (ndr_push_flags_fn_t) ndr_push_drsuapi_DsBind,
+ (ndr_pull_flags_fn_t) ndr_pull_drsuapi_DsBind,
+- (ndr_print_function_t) ndr_print_drsuapi_DsBind,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -16509,7 +16509,7 @@ static const struct ndr_interface_call d
+ sizeof(struct drsuapi_DsUnbind),
+ (ndr_push_flags_fn_t) ndr_push_drsuapi_DsUnbind,
+ (ndr_pull_flags_fn_t) ndr_pull_drsuapi_DsUnbind,
+- (ndr_print_function_t) ndr_print_drsuapi_DsUnbind,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -16518,7 +16518,7 @@ static const struct ndr_interface_call d
+ sizeof(struct drsuapi_DsReplicaSync),
+ (ndr_push_flags_fn_t) ndr_push_drsuapi_DsReplicaSync,
+ (ndr_pull_flags_fn_t) ndr_pull_drsuapi_DsReplicaSync,
+- (ndr_print_function_t) ndr_print_drsuapi_DsReplicaSync,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -16527,7 +16527,7 @@ static const struct ndr_interface_call d
+ sizeof(struct drsuapi_DsGetNCChanges),
+ (ndr_push_flags_fn_t) ndr_push_drsuapi_DsGetNCChanges,
+ (ndr_pull_flags_fn_t) ndr_pull_drsuapi_DsGetNCChanges,
+- (ndr_print_function_t) ndr_print_drsuapi_DsGetNCChanges,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -16536,7 +16536,7 @@ static const struct ndr_interface_call d
+ sizeof(struct drsuapi_DsReplicaUpdateRefs),
+ (ndr_push_flags_fn_t) ndr_push_drsuapi_DsReplicaUpdateRefs,
+ (ndr_pull_flags_fn_t) ndr_pull_drsuapi_DsReplicaUpdateRefs,
+- (ndr_print_function_t) ndr_print_drsuapi_DsReplicaUpdateRefs,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -16545,7 +16545,7 @@ static const struct ndr_interface_call d
+ sizeof(struct drsuapi_DsReplicaAdd),
+ (ndr_push_flags_fn_t) ndr_push_drsuapi_DsReplicaAdd,
+ (ndr_pull_flags_fn_t) ndr_pull_drsuapi_DsReplicaAdd,
+- (ndr_print_function_t) ndr_print_drsuapi_DsReplicaAdd,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -16554,7 +16554,7 @@ static const struct ndr_interface_call d
+ sizeof(struct drsuapi_DsReplicaDel),
+ (ndr_push_flags_fn_t) ndr_push_drsuapi_DsReplicaDel,
+ (ndr_pull_flags_fn_t) ndr_pull_drsuapi_DsReplicaDel,
+- (ndr_print_function_t) ndr_print_drsuapi_DsReplicaDel,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -16563,7 +16563,7 @@ static const struct ndr_interface_call d
+ sizeof(struct drsuapi_DsReplicaMod),
+ (ndr_push_flags_fn_t) ndr_push_drsuapi_DsReplicaMod,
+ (ndr_pull_flags_fn_t) ndr_pull_drsuapi_DsReplicaMod,
+- (ndr_print_function_t) ndr_print_drsuapi_DsReplicaMod,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -16572,7 +16572,7 @@ static const struct ndr_interface_call d
+ sizeof(struct DRSUAPI_VERIFY_NAMES),
+ (ndr_push_flags_fn_t) ndr_push_DRSUAPI_VERIFY_NAMES,
+ (ndr_pull_flags_fn_t) ndr_pull_DRSUAPI_VERIFY_NAMES,
+- (ndr_print_function_t) ndr_print_DRSUAPI_VERIFY_NAMES,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -16581,7 +16581,7 @@ static const struct ndr_interface_call d
+ sizeof(struct drsuapi_DsGetMemberships),
+ (ndr_push_flags_fn_t) ndr_push_drsuapi_DsGetMemberships,
+ (ndr_pull_flags_fn_t) ndr_pull_drsuapi_DsGetMemberships,
+- (ndr_print_function_t) ndr_print_drsuapi_DsGetMemberships,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -16590,7 +16590,7 @@ static const struct ndr_interface_call d
+ sizeof(struct DRSUAPI_INTER_DOMAIN_MOVE),
+ (ndr_push_flags_fn_t) ndr_push_DRSUAPI_INTER_DOMAIN_MOVE,
+ (ndr_pull_flags_fn_t) ndr_pull_DRSUAPI_INTER_DOMAIN_MOVE,
+- (ndr_print_function_t) ndr_print_DRSUAPI_INTER_DOMAIN_MOVE,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -16599,7 +16599,7 @@ static const struct ndr_interface_call d
+ sizeof(struct drsuapi_DsGetNT4ChangeLog),
+ (ndr_push_flags_fn_t) ndr_push_drsuapi_DsGetNT4ChangeLog,
+ (ndr_pull_flags_fn_t) ndr_pull_drsuapi_DsGetNT4ChangeLog,
+- (ndr_print_function_t) ndr_print_drsuapi_DsGetNT4ChangeLog,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -16608,7 +16608,7 @@ static const struct ndr_interface_call d
+ sizeof(struct drsuapi_DsCrackNames),
+ (ndr_push_flags_fn_t) ndr_push_drsuapi_DsCrackNames,
+ (ndr_pull_flags_fn_t) ndr_pull_drsuapi_DsCrackNames,
+- (ndr_print_function_t) ndr_print_drsuapi_DsCrackNames,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -16617,7 +16617,7 @@ static const struct ndr_interface_call d
+ sizeof(struct drsuapi_DsWriteAccountSpn),
+ (ndr_push_flags_fn_t) ndr_push_drsuapi_DsWriteAccountSpn,
+ (ndr_pull_flags_fn_t) ndr_pull_drsuapi_DsWriteAccountSpn,
+- (ndr_print_function_t) ndr_print_drsuapi_DsWriteAccountSpn,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -16626,7 +16626,7 @@ static const struct ndr_interface_call d
+ sizeof(struct drsuapi_DsRemoveDSServer),
+ (ndr_push_flags_fn_t) ndr_push_drsuapi_DsRemoveDSServer,
+ (ndr_pull_flags_fn_t) ndr_pull_drsuapi_DsRemoveDSServer,
+- (ndr_print_function_t) ndr_print_drsuapi_DsRemoveDSServer,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -16635,7 +16635,7 @@ static const struct ndr_interface_call d
+ sizeof(struct DRSUAPI_REMOVE_DS_DOMAIN),
+ (ndr_push_flags_fn_t) ndr_push_DRSUAPI_REMOVE_DS_DOMAIN,
+ (ndr_pull_flags_fn_t) ndr_pull_DRSUAPI_REMOVE_DS_DOMAIN,
+- (ndr_print_function_t) ndr_print_DRSUAPI_REMOVE_DS_DOMAIN,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -16644,7 +16644,7 @@ static const struct ndr_interface_call d
+ sizeof(struct drsuapi_DsGetDomainControllerInfo),
+ (ndr_push_flags_fn_t) ndr_push_drsuapi_DsGetDomainControllerInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_drsuapi_DsGetDomainControllerInfo,
+- (ndr_print_function_t) ndr_print_drsuapi_DsGetDomainControllerInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -16653,7 +16653,7 @@ static const struct ndr_interface_call d
+ sizeof(struct drsuapi_DsAddEntry),
+ (ndr_push_flags_fn_t) ndr_push_drsuapi_DsAddEntry,
+ (ndr_pull_flags_fn_t) ndr_pull_drsuapi_DsAddEntry,
+- (ndr_print_function_t) ndr_print_drsuapi_DsAddEntry,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -16662,7 +16662,7 @@ static const struct ndr_interface_call d
+ sizeof(struct drsuapi_DsExecuteKCC),
+ (ndr_push_flags_fn_t) ndr_push_drsuapi_DsExecuteKCC,
+ (ndr_pull_flags_fn_t) ndr_pull_drsuapi_DsExecuteKCC,
+- (ndr_print_function_t) ndr_print_drsuapi_DsExecuteKCC,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -16671,7 +16671,7 @@ static const struct ndr_interface_call d
+ sizeof(struct drsuapi_DsReplicaGetInfo),
+ (ndr_push_flags_fn_t) ndr_push_drsuapi_DsReplicaGetInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_drsuapi_DsReplicaGetInfo,
+- (ndr_print_function_t) ndr_print_drsuapi_DsReplicaGetInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -16680,7 +16680,7 @@ static const struct ndr_interface_call d
+ sizeof(struct DRSUAPI_ADD_SID_HISTORY),
+ (ndr_push_flags_fn_t) ndr_push_DRSUAPI_ADD_SID_HISTORY,
+ (ndr_pull_flags_fn_t) ndr_pull_DRSUAPI_ADD_SID_HISTORY,
+- (ndr_print_function_t) ndr_print_DRSUAPI_ADD_SID_HISTORY,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -16689,7 +16689,7 @@ static const struct ndr_interface_call d
+ sizeof(struct drsuapi_DsGetMemberships2),
+ (ndr_push_flags_fn_t) ndr_push_drsuapi_DsGetMemberships2,
+ (ndr_pull_flags_fn_t) ndr_pull_drsuapi_DsGetMemberships2,
+- (ndr_print_function_t) ndr_print_drsuapi_DsGetMemberships2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -16698,7 +16698,7 @@ static const struct ndr_interface_call d
+ sizeof(struct DRSUAPI_REPLICA_VERIFY_OBJECTS),
+ (ndr_push_flags_fn_t) ndr_push_DRSUAPI_REPLICA_VERIFY_OBJECTS,
+ (ndr_pull_flags_fn_t) ndr_pull_DRSUAPI_REPLICA_VERIFY_OBJECTS,
+- (ndr_print_function_t) ndr_print_DRSUAPI_REPLICA_VERIFY_OBJECTS,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -16707,7 +16707,7 @@ static const struct ndr_interface_call d
+ sizeof(struct DRSUAPI_GET_OBJECT_EXISTENCE),
+ (ndr_push_flags_fn_t) ndr_push_DRSUAPI_GET_OBJECT_EXISTENCE,
+ (ndr_pull_flags_fn_t) ndr_pull_DRSUAPI_GET_OBJECT_EXISTENCE,
+- (ndr_print_function_t) ndr_print_DRSUAPI_GET_OBJECT_EXISTENCE,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -16716,7 +16716,7 @@ static const struct ndr_interface_call d
+ sizeof(struct drsuapi_QuerySitesByCost),
+ (ndr_push_flags_fn_t) ndr_push_drsuapi_QuerySitesByCost,
+ (ndr_pull_flags_fn_t) ndr_pull_drsuapi_QuerySitesByCost,
+- (ndr_print_function_t) ndr_print_drsuapi_QuerySitesByCost,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_dsbackup.c
++++ b/source3/librpc/gen_ndr/ndr_dsbackup.c
+@@ -360,7 +360,7 @@ static const struct ndr_interface_call a
+ sizeof(struct HrRBackupPrepare),
+ (ndr_push_flags_fn_t) ndr_push_HrRBackupPrepare,
+ (ndr_pull_flags_fn_t) ndr_pull_HrRBackupPrepare,
+- (ndr_print_function_t) ndr_print_HrRBackupPrepare,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -369,7 +369,7 @@ static const struct ndr_interface_call a
+ sizeof(struct HrRBackupEnd),
+ (ndr_push_flags_fn_t) ndr_push_HrRBackupEnd,
+ (ndr_pull_flags_fn_t) ndr_pull_HrRBackupEnd,
+- (ndr_print_function_t) ndr_print_HrRBackupEnd,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -378,7 +378,7 @@ static const struct ndr_interface_call a
+ sizeof(struct HrRBackupGetAttachmentInformation),
+ (ndr_push_flags_fn_t) ndr_push_HrRBackupGetAttachmentInformation,
+ (ndr_pull_flags_fn_t) ndr_pull_HrRBackupGetAttachmentInformation,
+- (ndr_print_function_t) ndr_print_HrRBackupGetAttachmentInformation,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -387,7 +387,7 @@ static const struct ndr_interface_call a
+ sizeof(struct HrRBackupOpenFile),
+ (ndr_push_flags_fn_t) ndr_push_HrRBackupOpenFile,
+ (ndr_pull_flags_fn_t) ndr_pull_HrRBackupOpenFile,
+- (ndr_print_function_t) ndr_print_HrRBackupOpenFile,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -396,7 +396,7 @@ static const struct ndr_interface_call a
+ sizeof(struct HrRBackupRead),
+ (ndr_push_flags_fn_t) ndr_push_HrRBackupRead,
+ (ndr_pull_flags_fn_t) ndr_pull_HrRBackupRead,
+- (ndr_print_function_t) ndr_print_HrRBackupRead,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -405,7 +405,7 @@ static const struct ndr_interface_call a
+ sizeof(struct HrRBackupClose),
+ (ndr_push_flags_fn_t) ndr_push_HrRBackupClose,
+ (ndr_pull_flags_fn_t) ndr_pull_HrRBackupClose,
+- (ndr_print_function_t) ndr_print_HrRBackupClose,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -414,7 +414,7 @@ static const struct ndr_interface_call a
+ sizeof(struct HrRBackupGetBackupLogs),
+ (ndr_push_flags_fn_t) ndr_push_HrRBackupGetBackupLogs,
+ (ndr_pull_flags_fn_t) ndr_pull_HrRBackupGetBackupLogs,
+- (ndr_print_function_t) ndr_print_HrRBackupGetBackupLogs,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -423,7 +423,7 @@ static const struct ndr_interface_call a
+ sizeof(struct HrRBackupTruncateLogs),
+ (ndr_push_flags_fn_t) ndr_push_HrRBackupTruncateLogs,
+ (ndr_pull_flags_fn_t) ndr_pull_HrRBackupTruncateLogs,
+- (ndr_print_function_t) ndr_print_HrRBackupTruncateLogs,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -432,7 +432,7 @@ static const struct ndr_interface_call a
+ sizeof(struct HrRBackupPing),
+ (ndr_push_flags_fn_t) ndr_push_HrRBackupPing,
+ (ndr_pull_flags_fn_t) ndr_pull_HrRBackupPing,
+- (ndr_print_function_t) ndr_print_HrRBackupPing,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -789,7 +789,7 @@ static const struct ndr_interface_call a
+ sizeof(struct HrRIsNTDSOnline),
+ (ndr_push_flags_fn_t) ndr_push_HrRIsNTDSOnline,
+ (ndr_pull_flags_fn_t) ndr_pull_HrRIsNTDSOnline,
+- (ndr_print_function_t) ndr_print_HrRIsNTDSOnline,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -798,7 +798,7 @@ static const struct ndr_interface_call a
+ sizeof(struct HrRRestorePrepare),
+ (ndr_push_flags_fn_t) ndr_push_HrRRestorePrepare,
+ (ndr_pull_flags_fn_t) ndr_pull_HrRRestorePrepare,
+- (ndr_print_function_t) ndr_print_HrRRestorePrepare,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -807,7 +807,7 @@ static const struct ndr_interface_call a
+ sizeof(struct HrRRestoreRegister),
+ (ndr_push_flags_fn_t) ndr_push_HrRRestoreRegister,
+ (ndr_pull_flags_fn_t) ndr_pull_HrRRestoreRegister,
+- (ndr_print_function_t) ndr_print_HrRRestoreRegister,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -816,7 +816,7 @@ static const struct ndr_interface_call a
+ sizeof(struct HrRRestoreRegisterComplete),
+ (ndr_push_flags_fn_t) ndr_push_HrRRestoreRegisterComplete,
+ (ndr_pull_flags_fn_t) ndr_pull_HrRRestoreRegisterComplete,
+- (ndr_print_function_t) ndr_print_HrRRestoreRegisterComplete,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -825,7 +825,7 @@ static const struct ndr_interface_call a
+ sizeof(struct HrRRestoreGetDatabaseLocations),
+ (ndr_push_flags_fn_t) ndr_push_HrRRestoreGetDatabaseLocations,
+ (ndr_pull_flags_fn_t) ndr_pull_HrRRestoreGetDatabaseLocations,
+- (ndr_print_function_t) ndr_print_HrRRestoreGetDatabaseLocations,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -834,7 +834,7 @@ static const struct ndr_interface_call a
+ sizeof(struct HrRRestoreEnd),
+ (ndr_push_flags_fn_t) ndr_push_HrRRestoreEnd,
+ (ndr_pull_flags_fn_t) ndr_pull_HrRRestoreEnd,
+- (ndr_print_function_t) ndr_print_HrRRestoreEnd,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -843,7 +843,7 @@ static const struct ndr_interface_call a
+ sizeof(struct HrRRestoreSetCurrentLogNumber),
+ (ndr_push_flags_fn_t) ndr_push_HrRRestoreSetCurrentLogNumber,
+ (ndr_pull_flags_fn_t) ndr_pull_HrRRestoreSetCurrentLogNumber,
+- (ndr_print_function_t) ndr_print_HrRRestoreSetCurrentLogNumber,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -852,7 +852,7 @@ static const struct ndr_interface_call a
+ sizeof(struct HrRRestoreCheckLogsForBackup),
+ (ndr_push_flags_fn_t) ndr_push_HrRRestoreCheckLogsForBackup,
+ (ndr_pull_flags_fn_t) ndr_pull_HrRRestoreCheckLogsForBackup,
+- (ndr_print_function_t) ndr_print_HrRRestoreCheckLogsForBackup,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_dssetup.c
++++ b/source3/librpc/gen_ndr/ndr_dssetup.c
+@@ -995,7 +995,7 @@ static const struct ndr_interface_call d
+ sizeof(struct dssetup_DsRoleGetPrimaryDomainInformation),
+ (ndr_push_flags_fn_t) ndr_push_dssetup_DsRoleGetPrimaryDomainInformation,
+ (ndr_pull_flags_fn_t) ndr_pull_dssetup_DsRoleGetPrimaryDomainInformation,
+- (ndr_print_function_t) ndr_print_dssetup_DsRoleGetPrimaryDomainInformation,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1004,7 +1004,7 @@ static const struct ndr_interface_call d
+ sizeof(struct dssetup_DsRoleDnsNameToFlatName),
+ (ndr_push_flags_fn_t) ndr_push_dssetup_DsRoleDnsNameToFlatName,
+ (ndr_pull_flags_fn_t) ndr_pull_dssetup_DsRoleDnsNameToFlatName,
+- (ndr_print_function_t) ndr_print_dssetup_DsRoleDnsNameToFlatName,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1013,7 +1013,7 @@ static const struct ndr_interface_call d
+ sizeof(struct dssetup_DsRoleDcAsDc),
+ (ndr_push_flags_fn_t) ndr_push_dssetup_DsRoleDcAsDc,
+ (ndr_pull_flags_fn_t) ndr_pull_dssetup_DsRoleDcAsDc,
+- (ndr_print_function_t) ndr_print_dssetup_DsRoleDcAsDc,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1022,7 +1022,7 @@ static const struct ndr_interface_call d
+ sizeof(struct dssetup_DsRoleDcAsReplica),
+ (ndr_push_flags_fn_t) ndr_push_dssetup_DsRoleDcAsReplica,
+ (ndr_pull_flags_fn_t) ndr_pull_dssetup_DsRoleDcAsReplica,
+- (ndr_print_function_t) ndr_print_dssetup_DsRoleDcAsReplica,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1031,7 +1031,7 @@ static const struct ndr_interface_call d
+ sizeof(struct dssetup_DsRoleDemoteDc),
+ (ndr_push_flags_fn_t) ndr_push_dssetup_DsRoleDemoteDc,
+ (ndr_pull_flags_fn_t) ndr_pull_dssetup_DsRoleDemoteDc,
+- (ndr_print_function_t) ndr_print_dssetup_DsRoleDemoteDc,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1040,7 +1040,7 @@ static const struct ndr_interface_call d
+ sizeof(struct dssetup_DsRoleGetDcOperationProgress),
+ (ndr_push_flags_fn_t) ndr_push_dssetup_DsRoleGetDcOperationProgress,
+ (ndr_pull_flags_fn_t) ndr_pull_dssetup_DsRoleGetDcOperationProgress,
+- (ndr_print_function_t) ndr_print_dssetup_DsRoleGetDcOperationProgress,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1049,7 +1049,7 @@ static const struct ndr_interface_call d
+ sizeof(struct dssetup_DsRoleGetDcOperationResults),
+ (ndr_push_flags_fn_t) ndr_push_dssetup_DsRoleGetDcOperationResults,
+ (ndr_pull_flags_fn_t) ndr_pull_dssetup_DsRoleGetDcOperationResults,
+- (ndr_print_function_t) ndr_print_dssetup_DsRoleGetDcOperationResults,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1058,7 +1058,7 @@ static const struct ndr_interface_call d
+ sizeof(struct dssetup_DsRoleCancel),
+ (ndr_push_flags_fn_t) ndr_push_dssetup_DsRoleCancel,
+ (ndr_pull_flags_fn_t) ndr_pull_dssetup_DsRoleCancel,
+- (ndr_print_function_t) ndr_print_dssetup_DsRoleCancel,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1067,7 +1067,7 @@ static const struct ndr_interface_call d
+ sizeof(struct dssetup_DsRoleServerSaveStateForUpgrade),
+ (ndr_push_flags_fn_t) ndr_push_dssetup_DsRoleServerSaveStateForUpgrade,
+ (ndr_pull_flags_fn_t) ndr_pull_dssetup_DsRoleServerSaveStateForUpgrade,
+- (ndr_print_function_t) ndr_print_dssetup_DsRoleServerSaveStateForUpgrade,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1076,7 +1076,7 @@ static const struct ndr_interface_call d
+ sizeof(struct dssetup_DsRoleUpgradeDownlevelServer),
+ (ndr_push_flags_fn_t) ndr_push_dssetup_DsRoleUpgradeDownlevelServer,
+ (ndr_pull_flags_fn_t) ndr_pull_dssetup_DsRoleUpgradeDownlevelServer,
+- (ndr_print_function_t) ndr_print_dssetup_DsRoleUpgradeDownlevelServer,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1085,7 +1085,7 @@ static const struct ndr_interface_call d
+ sizeof(struct dssetup_DsRoleAbortDownlevelServerUpgrade),
+ (ndr_push_flags_fn_t) ndr_push_dssetup_DsRoleAbortDownlevelServerUpgrade,
+ (ndr_pull_flags_fn_t) ndr_pull_dssetup_DsRoleAbortDownlevelServerUpgrade,
+- (ndr_print_function_t) ndr_print_dssetup_DsRoleAbortDownlevelServerUpgrade,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_echo.c
++++ b/source3/librpc/gen_ndr/ndr_echo.c
+@@ -1458,7 +1458,7 @@ static const struct ndr_interface_call r
+ sizeof(struct echo_AddOne),
+ (ndr_push_flags_fn_t) ndr_push_echo_AddOne,
+ (ndr_pull_flags_fn_t) ndr_pull_echo_AddOne,
+- (ndr_print_function_t) ndr_print_echo_AddOne,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1467,7 +1467,7 @@ static const struct ndr_interface_call r
+ sizeof(struct echo_EchoData),
+ (ndr_push_flags_fn_t) ndr_push_echo_EchoData,
+ (ndr_pull_flags_fn_t) ndr_pull_echo_EchoData,
+- (ndr_print_function_t) ndr_print_echo_EchoData,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1476,7 +1476,7 @@ static const struct ndr_interface_call r
+ sizeof(struct echo_SinkData),
+ (ndr_push_flags_fn_t) ndr_push_echo_SinkData,
+ (ndr_pull_flags_fn_t) ndr_pull_echo_SinkData,
+- (ndr_print_function_t) ndr_print_echo_SinkData,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1485,7 +1485,7 @@ static const struct ndr_interface_call r
+ sizeof(struct echo_SourceData),
+ (ndr_push_flags_fn_t) ndr_push_echo_SourceData,
+ (ndr_pull_flags_fn_t) ndr_pull_echo_SourceData,
+- (ndr_print_function_t) ndr_print_echo_SourceData,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1494,7 +1494,7 @@ static const struct ndr_interface_call r
+ sizeof(struct echo_TestCall),
+ (ndr_push_flags_fn_t) ndr_push_echo_TestCall,
+ (ndr_pull_flags_fn_t) ndr_pull_echo_TestCall,
+- (ndr_print_function_t) ndr_print_echo_TestCall,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1503,7 +1503,7 @@ static const struct ndr_interface_call r
+ sizeof(struct echo_TestCall2),
+ (ndr_push_flags_fn_t) ndr_push_echo_TestCall2,
+ (ndr_pull_flags_fn_t) ndr_pull_echo_TestCall2,
+- (ndr_print_function_t) ndr_print_echo_TestCall2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1512,7 +1512,7 @@ static const struct ndr_interface_call r
+ sizeof(struct echo_TestSleep),
+ (ndr_push_flags_fn_t) ndr_push_echo_TestSleep,
+ (ndr_pull_flags_fn_t) ndr_pull_echo_TestSleep,
+- (ndr_print_function_t) ndr_print_echo_TestSleep,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1521,7 +1521,7 @@ static const struct ndr_interface_call r
+ sizeof(struct echo_TestEnum),
+ (ndr_push_flags_fn_t) ndr_push_echo_TestEnum,
+ (ndr_pull_flags_fn_t) ndr_pull_echo_TestEnum,
+- (ndr_print_function_t) ndr_print_echo_TestEnum,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1530,7 +1530,7 @@ static const struct ndr_interface_call r
+ sizeof(struct echo_TestSurrounding),
+ (ndr_push_flags_fn_t) ndr_push_echo_TestSurrounding,
+ (ndr_pull_flags_fn_t) ndr_pull_echo_TestSurrounding,
+- (ndr_print_function_t) ndr_print_echo_TestSurrounding,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1539,7 +1539,7 @@ static const struct ndr_interface_call r
+ sizeof(struct echo_TestDoublePointer),
+ (ndr_push_flags_fn_t) ndr_push_echo_TestDoublePointer,
+ (ndr_pull_flags_fn_t) ndr_pull_echo_TestDoublePointer,
+- (ndr_print_function_t) ndr_print_echo_TestDoublePointer,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_efs.c
++++ b/source3/librpc/gen_ndr/ndr_efs.c
+@@ -1327,7 +1327,7 @@ static const struct ndr_interface_call e
+ sizeof(struct EfsRpcOpenFileRaw),
+ (ndr_push_flags_fn_t) ndr_push_EfsRpcOpenFileRaw,
+ (ndr_pull_flags_fn_t) ndr_pull_EfsRpcOpenFileRaw,
+- (ndr_print_function_t) ndr_print_EfsRpcOpenFileRaw,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1336,7 +1336,7 @@ static const struct ndr_interface_call e
+ sizeof(struct EfsRpcReadFileRaw),
+ (ndr_push_flags_fn_t) ndr_push_EfsRpcReadFileRaw,
+ (ndr_pull_flags_fn_t) ndr_pull_EfsRpcReadFileRaw,
+- (ndr_print_function_t) ndr_print_EfsRpcReadFileRaw,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1345,7 +1345,7 @@ static const struct ndr_interface_call e
+ sizeof(struct EfsRpcWriteFileRaw),
+ (ndr_push_flags_fn_t) ndr_push_EfsRpcWriteFileRaw,
+ (ndr_pull_flags_fn_t) ndr_pull_EfsRpcWriteFileRaw,
+- (ndr_print_function_t) ndr_print_EfsRpcWriteFileRaw,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1354,7 +1354,7 @@ static const struct ndr_interface_call e
+ sizeof(struct EfsRpcCloseRaw),
+ (ndr_push_flags_fn_t) ndr_push_EfsRpcCloseRaw,
+ (ndr_pull_flags_fn_t) ndr_pull_EfsRpcCloseRaw,
+- (ndr_print_function_t) ndr_print_EfsRpcCloseRaw,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1363,7 +1363,7 @@ static const struct ndr_interface_call e
+ sizeof(struct EfsRpcEncryptFileSrv),
+ (ndr_push_flags_fn_t) ndr_push_EfsRpcEncryptFileSrv,
+ (ndr_pull_flags_fn_t) ndr_pull_EfsRpcEncryptFileSrv,
+- (ndr_print_function_t) ndr_print_EfsRpcEncryptFileSrv,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1372,7 +1372,7 @@ static const struct ndr_interface_call e
+ sizeof(struct EfsRpcDecryptFileSrv),
+ (ndr_push_flags_fn_t) ndr_push_EfsRpcDecryptFileSrv,
+ (ndr_pull_flags_fn_t) ndr_pull_EfsRpcDecryptFileSrv,
+- (ndr_print_function_t) ndr_print_EfsRpcDecryptFileSrv,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1381,7 +1381,7 @@ static const struct ndr_interface_call e
+ sizeof(struct EfsRpcQueryUsersOnFile),
+ (ndr_push_flags_fn_t) ndr_push_EfsRpcQueryUsersOnFile,
+ (ndr_pull_flags_fn_t) ndr_pull_EfsRpcQueryUsersOnFile,
+- (ndr_print_function_t) ndr_print_EfsRpcQueryUsersOnFile,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1390,7 +1390,7 @@ static const struct ndr_interface_call e
+ sizeof(struct EfsRpcQueryRecoveryAgents),
+ (ndr_push_flags_fn_t) ndr_push_EfsRpcQueryRecoveryAgents,
+ (ndr_pull_flags_fn_t) ndr_pull_EfsRpcQueryRecoveryAgents,
+- (ndr_print_function_t) ndr_print_EfsRpcQueryRecoveryAgents,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1399,7 +1399,7 @@ static const struct ndr_interface_call e
+ sizeof(struct EfsRpcRemoveUsersFromFile),
+ (ndr_push_flags_fn_t) ndr_push_EfsRpcRemoveUsersFromFile,
+ (ndr_pull_flags_fn_t) ndr_pull_EfsRpcRemoveUsersFromFile,
+- (ndr_print_function_t) ndr_print_EfsRpcRemoveUsersFromFile,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1408,7 +1408,7 @@ static const struct ndr_interface_call e
+ sizeof(struct EfsRpcAddUsersToFile),
+ (ndr_push_flags_fn_t) ndr_push_EfsRpcAddUsersToFile,
+ (ndr_pull_flags_fn_t) ndr_pull_EfsRpcAddUsersToFile,
+- (ndr_print_function_t) ndr_print_EfsRpcAddUsersToFile,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1417,7 +1417,7 @@ static const struct ndr_interface_call e
+ sizeof(struct EfsRpcSetFileEncryptionKey),
+ (ndr_push_flags_fn_t) ndr_push_EfsRpcSetFileEncryptionKey,
+ (ndr_pull_flags_fn_t) ndr_pull_EfsRpcSetFileEncryptionKey,
+- (ndr_print_function_t) ndr_print_EfsRpcSetFileEncryptionKey,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1426,7 +1426,7 @@ static const struct ndr_interface_call e
+ sizeof(struct EfsRpcNotSupported),
+ (ndr_push_flags_fn_t) ndr_push_EfsRpcNotSupported,
+ (ndr_pull_flags_fn_t) ndr_pull_EfsRpcNotSupported,
+- (ndr_print_function_t) ndr_print_EfsRpcNotSupported,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1435,7 +1435,7 @@ static const struct ndr_interface_call e
+ sizeof(struct EfsRpcFileKeyInfo),
+ (ndr_push_flags_fn_t) ndr_push_EfsRpcFileKeyInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_EfsRpcFileKeyInfo,
+- (ndr_print_function_t) ndr_print_EfsRpcFileKeyInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1444,7 +1444,7 @@ static const struct ndr_interface_call e
+ sizeof(struct EfsRpcDuplicateEncryptionInfoFile),
+ (ndr_push_flags_fn_t) ndr_push_EfsRpcDuplicateEncryptionInfoFile,
+ (ndr_pull_flags_fn_t) ndr_pull_EfsRpcDuplicateEncryptionInfoFile,
+- (ndr_print_function_t) ndr_print_EfsRpcDuplicateEncryptionInfoFile,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_epmapper.c
++++ b/source3/librpc/gen_ndr/ndr_epmapper.c
+@@ -2754,7 +2754,7 @@ static const struct ndr_interface_call e
+ sizeof(struct epm_Insert),
+ (ndr_push_flags_fn_t) ndr_push_epm_Insert,
+ (ndr_pull_flags_fn_t) ndr_pull_epm_Insert,
+- (ndr_print_function_t) ndr_print_epm_Insert,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2763,7 +2763,7 @@ static const struct ndr_interface_call e
+ sizeof(struct epm_Delete),
+ (ndr_push_flags_fn_t) ndr_push_epm_Delete,
+ (ndr_pull_flags_fn_t) ndr_pull_epm_Delete,
+- (ndr_print_function_t) ndr_print_epm_Delete,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2772,7 +2772,7 @@ static const struct ndr_interface_call e
+ sizeof(struct epm_Lookup),
+ (ndr_push_flags_fn_t) ndr_push_epm_Lookup,
+ (ndr_pull_flags_fn_t) ndr_pull_epm_Lookup,
+- (ndr_print_function_t) ndr_print_epm_Lookup,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2781,7 +2781,7 @@ static const struct ndr_interface_call e
+ sizeof(struct epm_Map),
+ (ndr_push_flags_fn_t) ndr_push_epm_Map,
+ (ndr_pull_flags_fn_t) ndr_pull_epm_Map,
+- (ndr_print_function_t) ndr_print_epm_Map,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2790,7 +2790,7 @@ static const struct ndr_interface_call e
+ sizeof(struct epm_LookupHandleFree),
+ (ndr_push_flags_fn_t) ndr_push_epm_LookupHandleFree,
+ (ndr_pull_flags_fn_t) ndr_pull_epm_LookupHandleFree,
+- (ndr_print_function_t) ndr_print_epm_LookupHandleFree,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2799,7 +2799,7 @@ static const struct ndr_interface_call e
+ sizeof(struct epm_InqObject),
+ (ndr_push_flags_fn_t) ndr_push_epm_InqObject,
+ (ndr_pull_flags_fn_t) ndr_pull_epm_InqObject,
+- (ndr_print_function_t) ndr_print_epm_InqObject,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2808,7 +2808,7 @@ static const struct ndr_interface_call e
+ sizeof(struct epm_MgmtDelete),
+ (ndr_push_flags_fn_t) ndr_push_epm_MgmtDelete,
+ (ndr_pull_flags_fn_t) ndr_pull_epm_MgmtDelete,
+- (ndr_print_function_t) ndr_print_epm_MgmtDelete,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2817,7 +2817,7 @@ static const struct ndr_interface_call e
+ sizeof(struct epm_MapAuth),
+ (ndr_push_flags_fn_t) ndr_push_epm_MapAuth,
+ (ndr_pull_flags_fn_t) ndr_pull_epm_MapAuth,
+- (ndr_print_function_t) ndr_print_epm_MapAuth,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_eventlog.c
++++ b/source3/librpc/gen_ndr/ndr_eventlog.c
+@@ -2983,7 +2983,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog_ClearEventLogW),
+ (ndr_push_flags_fn_t) ndr_push_eventlog_ClearEventLogW,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog_ClearEventLogW,
+- (ndr_print_function_t) ndr_print_eventlog_ClearEventLogW,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2992,7 +2992,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog_BackupEventLogW),
+ (ndr_push_flags_fn_t) ndr_push_eventlog_BackupEventLogW,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog_BackupEventLogW,
+- (ndr_print_function_t) ndr_print_eventlog_BackupEventLogW,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3001,7 +3001,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog_CloseEventLog),
+ (ndr_push_flags_fn_t) ndr_push_eventlog_CloseEventLog,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog_CloseEventLog,
+- (ndr_print_function_t) ndr_print_eventlog_CloseEventLog,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3010,7 +3010,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog_DeregisterEventSource),
+ (ndr_push_flags_fn_t) ndr_push_eventlog_DeregisterEventSource,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog_DeregisterEventSource,
+- (ndr_print_function_t) ndr_print_eventlog_DeregisterEventSource,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3019,7 +3019,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog_GetNumRecords),
+ (ndr_push_flags_fn_t) ndr_push_eventlog_GetNumRecords,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog_GetNumRecords,
+- (ndr_print_function_t) ndr_print_eventlog_GetNumRecords,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3028,7 +3028,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog_GetOldestRecord),
+ (ndr_push_flags_fn_t) ndr_push_eventlog_GetOldestRecord,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog_GetOldestRecord,
+- (ndr_print_function_t) ndr_print_eventlog_GetOldestRecord,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3037,7 +3037,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog_ChangeNotify),
+ (ndr_push_flags_fn_t) ndr_push_eventlog_ChangeNotify,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog_ChangeNotify,
+- (ndr_print_function_t) ndr_print_eventlog_ChangeNotify,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3046,7 +3046,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog_OpenEventLogW),
+ (ndr_push_flags_fn_t) ndr_push_eventlog_OpenEventLogW,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog_OpenEventLogW,
+- (ndr_print_function_t) ndr_print_eventlog_OpenEventLogW,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3055,7 +3055,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog_RegisterEventSourceW),
+ (ndr_push_flags_fn_t) ndr_push_eventlog_RegisterEventSourceW,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog_RegisterEventSourceW,
+- (ndr_print_function_t) ndr_print_eventlog_RegisterEventSourceW,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3064,7 +3064,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog_OpenBackupEventLogW),
+ (ndr_push_flags_fn_t) ndr_push_eventlog_OpenBackupEventLogW,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog_OpenBackupEventLogW,
+- (ndr_print_function_t) ndr_print_eventlog_OpenBackupEventLogW,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3073,7 +3073,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog_ReadEventLogW),
+ (ndr_push_flags_fn_t) ndr_push_eventlog_ReadEventLogW,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog_ReadEventLogW,
+- (ndr_print_function_t) ndr_print_eventlog_ReadEventLogW,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3082,7 +3082,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog_ReportEventW),
+ (ndr_push_flags_fn_t) ndr_push_eventlog_ReportEventW,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog_ReportEventW,
+- (ndr_print_function_t) ndr_print_eventlog_ReportEventW,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3091,7 +3091,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog_ClearEventLogA),
+ (ndr_push_flags_fn_t) ndr_push_eventlog_ClearEventLogA,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog_ClearEventLogA,
+- (ndr_print_function_t) ndr_print_eventlog_ClearEventLogA,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3100,7 +3100,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog_BackupEventLogA),
+ (ndr_push_flags_fn_t) ndr_push_eventlog_BackupEventLogA,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog_BackupEventLogA,
+- (ndr_print_function_t) ndr_print_eventlog_BackupEventLogA,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3109,7 +3109,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog_OpenEventLogA),
+ (ndr_push_flags_fn_t) ndr_push_eventlog_OpenEventLogA,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog_OpenEventLogA,
+- (ndr_print_function_t) ndr_print_eventlog_OpenEventLogA,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3118,7 +3118,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog_RegisterEventSourceA),
+ (ndr_push_flags_fn_t) ndr_push_eventlog_RegisterEventSourceA,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog_RegisterEventSourceA,
+- (ndr_print_function_t) ndr_print_eventlog_RegisterEventSourceA,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3127,7 +3127,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog_OpenBackupEventLogA),
+ (ndr_push_flags_fn_t) ndr_push_eventlog_OpenBackupEventLogA,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog_OpenBackupEventLogA,
+- (ndr_print_function_t) ndr_print_eventlog_OpenBackupEventLogA,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3136,7 +3136,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog_ReadEventLogA),
+ (ndr_push_flags_fn_t) ndr_push_eventlog_ReadEventLogA,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog_ReadEventLogA,
+- (ndr_print_function_t) ndr_print_eventlog_ReadEventLogA,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3145,7 +3145,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog_ReportEventA),
+ (ndr_push_flags_fn_t) ndr_push_eventlog_ReportEventA,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog_ReportEventA,
+- (ndr_print_function_t) ndr_print_eventlog_ReportEventA,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3154,7 +3154,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog_RegisterClusterSvc),
+ (ndr_push_flags_fn_t) ndr_push_eventlog_RegisterClusterSvc,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog_RegisterClusterSvc,
+- (ndr_print_function_t) ndr_print_eventlog_RegisterClusterSvc,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3163,7 +3163,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog_DeregisterClusterSvc),
+ (ndr_push_flags_fn_t) ndr_push_eventlog_DeregisterClusterSvc,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog_DeregisterClusterSvc,
+- (ndr_print_function_t) ndr_print_eventlog_DeregisterClusterSvc,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3172,7 +3172,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog_WriteClusterEvents),
+ (ndr_push_flags_fn_t) ndr_push_eventlog_WriteClusterEvents,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog_WriteClusterEvents,
+- (ndr_print_function_t) ndr_print_eventlog_WriteClusterEvents,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3181,7 +3181,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog_GetLogInformation),
+ (ndr_push_flags_fn_t) ndr_push_eventlog_GetLogInformation,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog_GetLogInformation,
+- (ndr_print_function_t) ndr_print_eventlog_GetLogInformation,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3190,7 +3190,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog_FlushEventLog),
+ (ndr_push_flags_fn_t) ndr_push_eventlog_FlushEventLog,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog_FlushEventLog,
+- (ndr_print_function_t) ndr_print_eventlog_FlushEventLog,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3199,7 +3199,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog_ReportEventAndSourceW),
+ (ndr_push_flags_fn_t) ndr_push_eventlog_ReportEventAndSourceW,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog_ReportEventAndSourceW,
+- (ndr_print_function_t) ndr_print_eventlog_ReportEventAndSourceW,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_eventlog6.c
++++ b/source3/librpc/gen_ndr/ndr_eventlog6.c
+@@ -5482,7 +5482,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog6_EvtRpcRegisterRemoteSubscription),
+ (ndr_push_flags_fn_t) ndr_push_eventlog6_EvtRpcRegisterRemoteSubscription,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog6_EvtRpcRegisterRemoteSubscription,
+- (ndr_print_function_t) ndr_print_eventlog6_EvtRpcRegisterRemoteSubscription,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5491,7 +5491,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog6_EvtRpcRemoteSubscriptionNextAsync),
+ (ndr_push_flags_fn_t) ndr_push_eventlog6_EvtRpcRemoteSubscriptionNextAsync,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog6_EvtRpcRemoteSubscriptionNextAsync,
+- (ndr_print_function_t) ndr_print_eventlog6_EvtRpcRemoteSubscriptionNextAsync,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5500,7 +5500,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog6_EvtRpcRemoteSubscriptionNext),
+ (ndr_push_flags_fn_t) ndr_push_eventlog6_EvtRpcRemoteSubscriptionNext,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog6_EvtRpcRemoteSubscriptionNext,
+- (ndr_print_function_t) ndr_print_eventlog6_EvtRpcRemoteSubscriptionNext,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5509,7 +5509,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog6_EvtRpcRemoteSubscriptionWaitAsync),
+ (ndr_push_flags_fn_t) ndr_push_eventlog6_EvtRpcRemoteSubscriptionWaitAsync,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog6_EvtRpcRemoteSubscriptionWaitAsync,
+- (ndr_print_function_t) ndr_print_eventlog6_EvtRpcRemoteSubscriptionWaitAsync,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5518,7 +5518,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog6_EvtRpcRegisterControllableOperation),
+ (ndr_push_flags_fn_t) ndr_push_eventlog6_EvtRpcRegisterControllableOperation,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog6_EvtRpcRegisterControllableOperation,
+- (ndr_print_function_t) ndr_print_eventlog6_EvtRpcRegisterControllableOperation,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5527,7 +5527,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog6_EvtRpcRegisterLogQuery),
+ (ndr_push_flags_fn_t) ndr_push_eventlog6_EvtRpcRegisterLogQuery,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog6_EvtRpcRegisterLogQuery,
+- (ndr_print_function_t) ndr_print_eventlog6_EvtRpcRegisterLogQuery,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5536,7 +5536,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog6_EvtRpcClearLog),
+ (ndr_push_flags_fn_t) ndr_push_eventlog6_EvtRpcClearLog,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog6_EvtRpcClearLog,
+- (ndr_print_function_t) ndr_print_eventlog6_EvtRpcClearLog,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5545,7 +5545,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog6_EvtRpcExportLog),
+ (ndr_push_flags_fn_t) ndr_push_eventlog6_EvtRpcExportLog,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog6_EvtRpcExportLog,
+- (ndr_print_function_t) ndr_print_eventlog6_EvtRpcExportLog,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5554,7 +5554,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog6_EvtRpcLocalizeExportLog),
+ (ndr_push_flags_fn_t) ndr_push_eventlog6_EvtRpcLocalizeExportLog,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog6_EvtRpcLocalizeExportLog,
+- (ndr_print_function_t) ndr_print_eventlog6_EvtRpcLocalizeExportLog,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5563,7 +5563,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog6_EvtRpcMessageRender),
+ (ndr_push_flags_fn_t) ndr_push_eventlog6_EvtRpcMessageRender,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog6_EvtRpcMessageRender,
+- (ndr_print_function_t) ndr_print_eventlog6_EvtRpcMessageRender,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5572,7 +5572,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog6_EvtRpcMessageRenderDefault),
+ (ndr_push_flags_fn_t) ndr_push_eventlog6_EvtRpcMessageRenderDefault,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog6_EvtRpcMessageRenderDefault,
+- (ndr_print_function_t) ndr_print_eventlog6_EvtRpcMessageRenderDefault,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5581,7 +5581,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog6_EvtRpcQueryNext),
+ (ndr_push_flags_fn_t) ndr_push_eventlog6_EvtRpcQueryNext,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog6_EvtRpcQueryNext,
+- (ndr_print_function_t) ndr_print_eventlog6_EvtRpcQueryNext,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5590,7 +5590,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog6_EvtRpcQuerySeek),
+ (ndr_push_flags_fn_t) ndr_push_eventlog6_EvtRpcQuerySeek,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog6_EvtRpcQuerySeek,
+- (ndr_print_function_t) ndr_print_eventlog6_EvtRpcQuerySeek,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5599,7 +5599,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog6_EvtRpcClose),
+ (ndr_push_flags_fn_t) ndr_push_eventlog6_EvtRpcClose,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog6_EvtRpcClose,
+- (ndr_print_function_t) ndr_print_eventlog6_EvtRpcClose,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5608,7 +5608,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog6_EvtRpcCancel),
+ (ndr_push_flags_fn_t) ndr_push_eventlog6_EvtRpcCancel,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog6_EvtRpcCancel,
+- (ndr_print_function_t) ndr_print_eventlog6_EvtRpcCancel,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5617,7 +5617,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog6_EvtRpcAssertConfig),
+ (ndr_push_flags_fn_t) ndr_push_eventlog6_EvtRpcAssertConfig,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog6_EvtRpcAssertConfig,
+- (ndr_print_function_t) ndr_print_eventlog6_EvtRpcAssertConfig,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5626,7 +5626,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog6_EvtRpcRetractConfig),
+ (ndr_push_flags_fn_t) ndr_push_eventlog6_EvtRpcRetractConfig,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog6_EvtRpcRetractConfig,
+- (ndr_print_function_t) ndr_print_eventlog6_EvtRpcRetractConfig,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5635,7 +5635,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog6_EvtRpcOpenLogHandle),
+ (ndr_push_flags_fn_t) ndr_push_eventlog6_EvtRpcOpenLogHandle,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog6_EvtRpcOpenLogHandle,
+- (ndr_print_function_t) ndr_print_eventlog6_EvtRpcOpenLogHandle,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5644,7 +5644,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog6_EvtRpcGetLogFileInfo),
+ (ndr_push_flags_fn_t) ndr_push_eventlog6_EvtRpcGetLogFileInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog6_EvtRpcGetLogFileInfo,
+- (ndr_print_function_t) ndr_print_eventlog6_EvtRpcGetLogFileInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5653,7 +5653,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog6_EvtRpcGetChannelList),
+ (ndr_push_flags_fn_t) ndr_push_eventlog6_EvtRpcGetChannelList,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog6_EvtRpcGetChannelList,
+- (ndr_print_function_t) ndr_print_eventlog6_EvtRpcGetChannelList,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5662,7 +5662,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog6_EvtRpcGetChannelConfig),
+ (ndr_push_flags_fn_t) ndr_push_eventlog6_EvtRpcGetChannelConfig,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog6_EvtRpcGetChannelConfig,
+- (ndr_print_function_t) ndr_print_eventlog6_EvtRpcGetChannelConfig,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5671,7 +5671,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog6_EvtRpcPutChannelConfig),
+ (ndr_push_flags_fn_t) ndr_push_eventlog6_EvtRpcPutChannelConfig,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog6_EvtRpcPutChannelConfig,
+- (ndr_print_function_t) ndr_print_eventlog6_EvtRpcPutChannelConfig,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5680,7 +5680,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog6_EvtRpcGetPublisherList),
+ (ndr_push_flags_fn_t) ndr_push_eventlog6_EvtRpcGetPublisherList,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog6_EvtRpcGetPublisherList,
+- (ndr_print_function_t) ndr_print_eventlog6_EvtRpcGetPublisherList,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5689,7 +5689,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog6_EvtRpcGetPublisherListForChannel),
+ (ndr_push_flags_fn_t) ndr_push_eventlog6_EvtRpcGetPublisherListForChannel,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog6_EvtRpcGetPublisherListForChannel,
+- (ndr_print_function_t) ndr_print_eventlog6_EvtRpcGetPublisherListForChannel,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5698,7 +5698,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog6_EvtRpcGetPublisherMetadata),
+ (ndr_push_flags_fn_t) ndr_push_eventlog6_EvtRpcGetPublisherMetadata,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog6_EvtRpcGetPublisherMetadata,
+- (ndr_print_function_t) ndr_print_eventlog6_EvtRpcGetPublisherMetadata,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5707,7 +5707,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog6_EvtRpcGetPublisherResourceMetadata),
+ (ndr_push_flags_fn_t) ndr_push_eventlog6_EvtRpcGetPublisherResourceMetadata,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog6_EvtRpcGetPublisherResourceMetadata,
+- (ndr_print_function_t) ndr_print_eventlog6_EvtRpcGetPublisherResourceMetadata,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5716,7 +5716,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog6_EvtRpcGetEventMetadataEnum),
+ (ndr_push_flags_fn_t) ndr_push_eventlog6_EvtRpcGetEventMetadataEnum,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog6_EvtRpcGetEventMetadataEnum,
+- (ndr_print_function_t) ndr_print_eventlog6_EvtRpcGetEventMetadataEnum,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5725,7 +5725,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog6_EvtRpcGetNextEventMetadata),
+ (ndr_push_flags_fn_t) ndr_push_eventlog6_EvtRpcGetNextEventMetadata,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog6_EvtRpcGetNextEventMetadata,
+- (ndr_print_function_t) ndr_print_eventlog6_EvtRpcGetNextEventMetadata,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5734,7 +5734,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog6_EvtRpcGetClassicLogDisplayName),
+ (ndr_push_flags_fn_t) ndr_push_eventlog6_EvtRpcGetClassicLogDisplayName,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog6_EvtRpcGetClassicLogDisplayName,
+- (ndr_print_function_t) ndr_print_eventlog6_EvtRpcGetClassicLogDisplayName,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_frsapi.c
++++ b/source3/librpc/gen_ndr/ndr_frsapi.c
+@@ -979,7 +979,7 @@ static const struct ndr_interface_call f
+ sizeof(struct FRSAPI_VERIFY_PROMOTION),
+ (ndr_push_flags_fn_t) ndr_push_FRSAPI_VERIFY_PROMOTION,
+ (ndr_pull_flags_fn_t) ndr_pull_FRSAPI_VERIFY_PROMOTION,
+- (ndr_print_function_t) ndr_print_FRSAPI_VERIFY_PROMOTION,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -988,7 +988,7 @@ static const struct ndr_interface_call f
+ sizeof(struct FRSAPI_PROMOTION_STATUS),
+ (ndr_push_flags_fn_t) ndr_push_FRSAPI_PROMOTION_STATUS,
+ (ndr_pull_flags_fn_t) ndr_pull_FRSAPI_PROMOTION_STATUS,
+- (ndr_print_function_t) ndr_print_FRSAPI_PROMOTION_STATUS,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -997,7 +997,7 @@ static const struct ndr_interface_call f
+ sizeof(struct FRSAPI_START_DEMOTION),
+ (ndr_push_flags_fn_t) ndr_push_FRSAPI_START_DEMOTION,
+ (ndr_pull_flags_fn_t) ndr_pull_FRSAPI_START_DEMOTION,
+- (ndr_print_function_t) ndr_print_FRSAPI_START_DEMOTION,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1006,7 +1006,7 @@ static const struct ndr_interface_call f
+ sizeof(struct FRSAPI_COMMIT_DEMOTION),
+ (ndr_push_flags_fn_t) ndr_push_FRSAPI_COMMIT_DEMOTION,
+ (ndr_pull_flags_fn_t) ndr_pull_FRSAPI_COMMIT_DEMOTION,
+- (ndr_print_function_t) ndr_print_FRSAPI_COMMIT_DEMOTION,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1015,7 +1015,7 @@ static const struct ndr_interface_call f
+ sizeof(struct frsapi_SetDsPollingIntervalW),
+ (ndr_push_flags_fn_t) ndr_push_frsapi_SetDsPollingIntervalW,
+ (ndr_pull_flags_fn_t) ndr_pull_frsapi_SetDsPollingIntervalW,
+- (ndr_print_function_t) ndr_print_frsapi_SetDsPollingIntervalW,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1024,7 +1024,7 @@ static const struct ndr_interface_call f
+ sizeof(struct frsapi_GetDsPollingIntervalW),
+ (ndr_push_flags_fn_t) ndr_push_frsapi_GetDsPollingIntervalW,
+ (ndr_pull_flags_fn_t) ndr_pull_frsapi_GetDsPollingIntervalW,
+- (ndr_print_function_t) ndr_print_frsapi_GetDsPollingIntervalW,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1033,7 +1033,7 @@ static const struct ndr_interface_call f
+ sizeof(struct FRSAPI_VERIFY_PROMOTION_W),
+ (ndr_push_flags_fn_t) ndr_push_FRSAPI_VERIFY_PROMOTION_W,
+ (ndr_pull_flags_fn_t) ndr_pull_FRSAPI_VERIFY_PROMOTION_W,
+- (ndr_print_function_t) ndr_print_FRSAPI_VERIFY_PROMOTION_W,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1042,7 +1042,7 @@ static const struct ndr_interface_call f
+ sizeof(struct frsapi_InfoW),
+ (ndr_push_flags_fn_t) ndr_push_frsapi_InfoW,
+ (ndr_pull_flags_fn_t) ndr_pull_frsapi_InfoW,
+- (ndr_print_function_t) ndr_print_frsapi_InfoW,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1051,7 +1051,7 @@ static const struct ndr_interface_call f
+ sizeof(struct frsapi_IsPathReplicated),
+ (ndr_push_flags_fn_t) ndr_push_frsapi_IsPathReplicated,
+ (ndr_pull_flags_fn_t) ndr_pull_frsapi_IsPathReplicated,
+- (ndr_print_function_t) ndr_print_frsapi_IsPathReplicated,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1060,7 +1060,7 @@ static const struct ndr_interface_call f
+ sizeof(struct frsapi_WriterCommand),
+ (ndr_push_flags_fn_t) ndr_push_frsapi_WriterCommand,
+ (ndr_pull_flags_fn_t) ndr_pull_frsapi_WriterCommand,
+- (ndr_print_function_t) ndr_print_frsapi_WriterCommand,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1069,7 +1069,7 @@ static const struct ndr_interface_call f
+ sizeof(struct frsapi_ForceReplication),
+ (ndr_push_flags_fn_t) ndr_push_frsapi_ForceReplication,
+ (ndr_pull_flags_fn_t) ndr_pull_frsapi_ForceReplication,
+- (ndr_print_function_t) ndr_print_frsapi_ForceReplication,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_frsrpc.c
++++ b/source3/librpc/gen_ndr/ndr_frsrpc.c
+@@ -2781,7 +2781,7 @@ static const struct ndr_interface_call f
+ sizeof(struct frsrpc_FrsSendCommPkt),
+ (ndr_push_flags_fn_t) ndr_push_frsrpc_FrsSendCommPkt,
+ (ndr_pull_flags_fn_t) ndr_pull_frsrpc_FrsSendCommPkt,
+- (ndr_print_function_t) ndr_print_frsrpc_FrsSendCommPkt,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2790,7 +2790,7 @@ static const struct ndr_interface_call f
+ sizeof(struct frsrpc_FrsVerifyPromotionParent),
+ (ndr_push_flags_fn_t) ndr_push_frsrpc_FrsVerifyPromotionParent,
+ (ndr_pull_flags_fn_t) ndr_pull_frsrpc_FrsVerifyPromotionParent,
+- (ndr_print_function_t) ndr_print_frsrpc_FrsVerifyPromotionParent,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2799,7 +2799,7 @@ static const struct ndr_interface_call f
+ sizeof(struct frsrpc_FrsStartPromotionParent),
+ (ndr_push_flags_fn_t) ndr_push_frsrpc_FrsStartPromotionParent,
+ (ndr_pull_flags_fn_t) ndr_pull_frsrpc_FrsStartPromotionParent,
+- (ndr_print_function_t) ndr_print_frsrpc_FrsStartPromotionParent,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2808,7 +2808,7 @@ static const struct ndr_interface_call f
+ sizeof(struct frsrpc_FrsNOP),
+ (ndr_push_flags_fn_t) ndr_push_frsrpc_FrsNOP,
+ (ndr_pull_flags_fn_t) ndr_pull_frsrpc_FrsNOP,
+- (ndr_print_function_t) ndr_print_frsrpc_FrsNOP,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2817,7 +2817,7 @@ static const struct ndr_interface_call f
+ sizeof(struct FRSRPC_BACKUP_COMPLETE),
+ (ndr_push_flags_fn_t) ndr_push_FRSRPC_BACKUP_COMPLETE,
+ (ndr_pull_flags_fn_t) ndr_pull_FRSRPC_BACKUP_COMPLETE,
+- (ndr_print_function_t) ndr_print_FRSRPC_BACKUP_COMPLETE,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2826,7 +2826,7 @@ static const struct ndr_interface_call f
+ sizeof(struct FRSRPC_BACKUP_COMPLETE_5),
+ (ndr_push_flags_fn_t) ndr_push_FRSRPC_BACKUP_COMPLETE_5,
+ (ndr_pull_flags_fn_t) ndr_pull_FRSRPC_BACKUP_COMPLETE_5,
+- (ndr_print_function_t) ndr_print_FRSRPC_BACKUP_COMPLETE_5,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2835,7 +2835,7 @@ static const struct ndr_interface_call f
+ sizeof(struct FRSRPC_BACKUP_COMPLETE_6),
+ (ndr_push_flags_fn_t) ndr_push_FRSRPC_BACKUP_COMPLETE_6,
+ (ndr_pull_flags_fn_t) ndr_pull_FRSRPC_BACKUP_COMPLETE_6,
+- (ndr_print_function_t) ndr_print_FRSRPC_BACKUP_COMPLETE_6,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2844,7 +2844,7 @@ static const struct ndr_interface_call f
+ sizeof(struct FRSRPC_BACKUP_COMPLETE_7),
+ (ndr_push_flags_fn_t) ndr_push_FRSRPC_BACKUP_COMPLETE_7,
+ (ndr_pull_flags_fn_t) ndr_pull_FRSRPC_BACKUP_COMPLETE_7,
+- (ndr_print_function_t) ndr_print_FRSRPC_BACKUP_COMPLETE_7,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2853,7 +2853,7 @@ static const struct ndr_interface_call f
+ sizeof(struct FRSRPC_BACKUP_COMPLETE_8),
+ (ndr_push_flags_fn_t) ndr_push_FRSRPC_BACKUP_COMPLETE_8,
+ (ndr_pull_flags_fn_t) ndr_pull_FRSRPC_BACKUP_COMPLETE_8,
+- (ndr_print_function_t) ndr_print_FRSRPC_BACKUP_COMPLETE_8,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2862,7 +2862,7 @@ static const struct ndr_interface_call f
+ sizeof(struct FRSRPC_BACKUP_COMPLETE_9),
+ (ndr_push_flags_fn_t) ndr_push_FRSRPC_BACKUP_COMPLETE_9,
+ (ndr_pull_flags_fn_t) ndr_pull_FRSRPC_BACKUP_COMPLETE_9,
+- (ndr_print_function_t) ndr_print_FRSRPC_BACKUP_COMPLETE_9,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2871,7 +2871,7 @@ static const struct ndr_interface_call f
+ sizeof(struct FRSRPC_VERIFY_PROMOTION_PARENT_EX),
+ (ndr_push_flags_fn_t) ndr_push_FRSRPC_VERIFY_PROMOTION_PARENT_EX,
+ (ndr_pull_flags_fn_t) ndr_pull_FRSRPC_VERIFY_PROMOTION_PARENT_EX,
+- (ndr_print_function_t) ndr_print_FRSRPC_VERIFY_PROMOTION_PARENT_EX,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_frstrans.c
++++ b/source3/librpc/gen_ndr/ndr_frstrans.c
+@@ -2331,7 +2331,7 @@ static const struct ndr_interface_call f
+ sizeof(struct frstrans_CheckConnectivity),
+ (ndr_push_flags_fn_t) ndr_push_frstrans_CheckConnectivity,
+ (ndr_pull_flags_fn_t) ndr_pull_frstrans_CheckConnectivity,
+- (ndr_print_function_t) ndr_print_frstrans_CheckConnectivity,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2340,7 +2340,7 @@ static const struct ndr_interface_call f
+ sizeof(struct frstrans_EstablishConnection),
+ (ndr_push_flags_fn_t) ndr_push_frstrans_EstablishConnection,
+ (ndr_pull_flags_fn_t) ndr_pull_frstrans_EstablishConnection,
+- (ndr_print_function_t) ndr_print_frstrans_EstablishConnection,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2349,7 +2349,7 @@ static const struct ndr_interface_call f
+ sizeof(struct frstrans_EstablishSession),
+ (ndr_push_flags_fn_t) ndr_push_frstrans_EstablishSession,
+ (ndr_pull_flags_fn_t) ndr_pull_frstrans_EstablishSession,
+- (ndr_print_function_t) ndr_print_frstrans_EstablishSession,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2358,7 +2358,7 @@ static const struct ndr_interface_call f
+ sizeof(struct frstrans_RequestUpdates),
+ (ndr_push_flags_fn_t) ndr_push_frstrans_RequestUpdates,
+ (ndr_pull_flags_fn_t) ndr_pull_frstrans_RequestUpdates,
+- (ndr_print_function_t) ndr_print_frstrans_RequestUpdates,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2367,7 +2367,7 @@ static const struct ndr_interface_call f
+ sizeof(struct frstrans_RequestVersionVector),
+ (ndr_push_flags_fn_t) ndr_push_frstrans_RequestVersionVector,
+ (ndr_pull_flags_fn_t) ndr_pull_frstrans_RequestVersionVector,
+- (ndr_print_function_t) ndr_print_frstrans_RequestVersionVector,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2376,7 +2376,7 @@ static const struct ndr_interface_call f
+ sizeof(struct frstrans_AsyncPoll),
+ (ndr_push_flags_fn_t) ndr_push_frstrans_AsyncPoll,
+ (ndr_pull_flags_fn_t) ndr_pull_frstrans_AsyncPoll,
+- (ndr_print_function_t) ndr_print_frstrans_AsyncPoll,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2385,7 +2385,7 @@ static const struct ndr_interface_call f
+ sizeof(struct FRSTRANS_REQUEST_RECORDS),
+ (ndr_push_flags_fn_t) ndr_push_FRSTRANS_REQUEST_RECORDS,
+ (ndr_pull_flags_fn_t) ndr_pull_FRSTRANS_REQUEST_RECORDS,
+- (ndr_print_function_t) ndr_print_FRSTRANS_REQUEST_RECORDS,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2394,7 +2394,7 @@ static const struct ndr_interface_call f
+ sizeof(struct FRSTRANS_UPDATE_CANCEL),
+ (ndr_push_flags_fn_t) ndr_push_FRSTRANS_UPDATE_CANCEL,
+ (ndr_pull_flags_fn_t) ndr_pull_FRSTRANS_UPDATE_CANCEL,
+- (ndr_print_function_t) ndr_print_FRSTRANS_UPDATE_CANCEL,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2403,7 +2403,7 @@ static const struct ndr_interface_call f
+ sizeof(struct FRSTRANS_RAW_GET_FILE_DATA),
+ (ndr_push_flags_fn_t) ndr_push_FRSTRANS_RAW_GET_FILE_DATA,
+ (ndr_pull_flags_fn_t) ndr_pull_FRSTRANS_RAW_GET_FILE_DATA,
+- (ndr_print_function_t) ndr_print_FRSTRANS_RAW_GET_FILE_DATA,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2412,7 +2412,7 @@ static const struct ndr_interface_call f
+ sizeof(struct FRSTRANS_RDC_GET_SIGNATURES),
+ (ndr_push_flags_fn_t) ndr_push_FRSTRANS_RDC_GET_SIGNATURES,
+ (ndr_pull_flags_fn_t) ndr_pull_FRSTRANS_RDC_GET_SIGNATURES,
+- (ndr_print_function_t) ndr_print_FRSTRANS_RDC_GET_SIGNATURES,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2421,7 +2421,7 @@ static const struct ndr_interface_call f
+ sizeof(struct FRSTRANS_RDC_PUSH_SOURCE_NEEDS),
+ (ndr_push_flags_fn_t) ndr_push_FRSTRANS_RDC_PUSH_SOURCE_NEEDS,
+ (ndr_pull_flags_fn_t) ndr_pull_FRSTRANS_RDC_PUSH_SOURCE_NEEDS,
+- (ndr_print_function_t) ndr_print_FRSTRANS_RDC_PUSH_SOURCE_NEEDS,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2430,7 +2430,7 @@ static const struct ndr_interface_call f
+ sizeof(struct FRSTRANS_RDC_GET_FILE_DATA),
+ (ndr_push_flags_fn_t) ndr_push_FRSTRANS_RDC_GET_FILE_DATA,
+ (ndr_pull_flags_fn_t) ndr_pull_FRSTRANS_RDC_GET_FILE_DATA,
+- (ndr_print_function_t) ndr_print_FRSTRANS_RDC_GET_FILE_DATA,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2439,7 +2439,7 @@ static const struct ndr_interface_call f
+ sizeof(struct FRSTRANS_RDC_CLOSE),
+ (ndr_push_flags_fn_t) ndr_push_FRSTRANS_RDC_CLOSE,
+ (ndr_pull_flags_fn_t) ndr_pull_FRSTRANS_RDC_CLOSE,
+- (ndr_print_function_t) ndr_print_FRSTRANS_RDC_CLOSE,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2448,7 +2448,7 @@ static const struct ndr_interface_call f
+ sizeof(struct frstrans_InitializeFileTransferAsync),
+ (ndr_push_flags_fn_t) ndr_push_frstrans_InitializeFileTransferAsync,
+ (ndr_pull_flags_fn_t) ndr_pull_frstrans_InitializeFileTransferAsync,
+- (ndr_print_function_t) ndr_print_frstrans_InitializeFileTransferAsync,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2457,7 +2457,7 @@ static const struct ndr_interface_call f
+ sizeof(struct FRSTRANS_OPNUM_0E_NOT_USED_ON_THE_WIRE),
+ (ndr_push_flags_fn_t) ndr_push_FRSTRANS_OPNUM_0E_NOT_USED_ON_THE_WIRE,
+ (ndr_pull_flags_fn_t) ndr_pull_FRSTRANS_OPNUM_0E_NOT_USED_ON_THE_WIRE,
+- (ndr_print_function_t) ndr_print_FRSTRANS_OPNUM_0E_NOT_USED_ON_THE_WIRE,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2466,7 +2466,7 @@ static const struct ndr_interface_call f
+ sizeof(struct frstrans_RawGetFileDataAsync),
+ (ndr_push_flags_fn_t) ndr_push_frstrans_RawGetFileDataAsync,
+ (ndr_pull_flags_fn_t) ndr_pull_frstrans_RawGetFileDataAsync,
+- (ndr_print_function_t) ndr_print_frstrans_RawGetFileDataAsync,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 1, frstrans_RawGetFileDataAsync_out_pipes },
+ },
+@@ -2475,7 +2475,7 @@ static const struct ndr_interface_call f
+ sizeof(struct frstrans_RdcGetFileDataAsync),
+ (ndr_push_flags_fn_t) ndr_push_frstrans_RdcGetFileDataAsync,
+ (ndr_pull_flags_fn_t) ndr_pull_frstrans_RdcGetFileDataAsync,
+- (ndr_print_function_t) ndr_print_frstrans_RdcGetFileDataAsync,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 1, frstrans_RdcGetFileDataAsync_out_pipes },
+ },
+--- a/source3/librpc/gen_ndr/ndr_initshutdown.c
++++ b/source3/librpc/gen_ndr/ndr_initshutdown.c
+@@ -277,7 +277,7 @@ static const struct ndr_interface_call i
+ sizeof(struct initshutdown_Init),
+ (ndr_push_flags_fn_t) ndr_push_initshutdown_Init,
+ (ndr_pull_flags_fn_t) ndr_pull_initshutdown_Init,
+- (ndr_print_function_t) ndr_print_initshutdown_Init,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -286,7 +286,7 @@ static const struct ndr_interface_call i
+ sizeof(struct initshutdown_Abort),
+ (ndr_push_flags_fn_t) ndr_push_initshutdown_Abort,
+ (ndr_pull_flags_fn_t) ndr_pull_initshutdown_Abort,
+- (ndr_print_function_t) ndr_print_initshutdown_Abort,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -295,7 +295,7 @@ static const struct ndr_interface_call i
+ sizeof(struct initshutdown_InitEx),
+ (ndr_push_flags_fn_t) ndr_push_initshutdown_InitEx,
+ (ndr_pull_flags_fn_t) ndr_pull_initshutdown_InitEx,
+- (ndr_print_function_t) ndr_print_initshutdown_InitEx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_keysvc.c
++++ b/source3/librpc/gen_ndr/ndr_keysvc.c
+@@ -51,7 +51,7 @@ static const struct ndr_interface_call k
+ sizeof(struct keysvc_Unknown0),
+ (ndr_push_flags_fn_t) ndr_push_keysvc_Unknown0,
+ (ndr_pull_flags_fn_t) ndr_pull_keysvc_Unknown0,
+- (ndr_print_function_t) ndr_print_keysvc_Unknown0,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_krb5pac.c
++++ b/source3/librpc/gen_ndr/ndr_krb5pac.c
+@@ -1002,7 +1002,7 @@ static const struct ndr_interface_call k
+ sizeof(struct decode_pac),
+ (ndr_push_flags_fn_t) ndr_push_decode_pac,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_pac,
+- (ndr_print_function_t) ndr_print_decode_pac,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1011,7 +1011,7 @@ static const struct ndr_interface_call k
+ sizeof(struct decode_pac_raw),
+ (ndr_push_flags_fn_t) ndr_push_decode_pac_raw,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_pac_raw,
+- (ndr_print_function_t) ndr_print_decode_pac_raw,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1020,7 +1020,7 @@ static const struct ndr_interface_call k
+ sizeof(struct decode_login_info),
+ (ndr_push_flags_fn_t) ndr_push_decode_login_info,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_login_info,
+- (ndr_print_function_t) ndr_print_decode_login_info,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1029,7 +1029,7 @@ static const struct ndr_interface_call k
+ sizeof(struct decode_login_info_ctr),
+ (ndr_push_flags_fn_t) ndr_push_decode_login_info_ctr,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_login_info_ctr,
+- (ndr_print_function_t) ndr_print_decode_login_info_ctr,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1038,7 +1038,7 @@ static const struct ndr_interface_call k
+ sizeof(struct decode_pac_validate),
+ (ndr_push_flags_fn_t) ndr_push_decode_pac_validate,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_pac_validate,
+- (ndr_print_function_t) ndr_print_decode_pac_validate,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_lsa.c
++++ b/source3/librpc/gen_ndr/ndr_lsa.c
+@@ -13565,7 +13565,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_Close),
+ (ndr_push_flags_fn_t) ndr_push_lsa_Close,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_Close,
+- (ndr_print_function_t) ndr_print_lsa_Close,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13574,7 +13574,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_Delete),
+ (ndr_push_flags_fn_t) ndr_push_lsa_Delete,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_Delete,
+- (ndr_print_function_t) ndr_print_lsa_Delete,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13583,7 +13583,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_EnumPrivs),
+ (ndr_push_flags_fn_t) ndr_push_lsa_EnumPrivs,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_EnumPrivs,
+- (ndr_print_function_t) ndr_print_lsa_EnumPrivs,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13592,7 +13592,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_QuerySecurity),
+ (ndr_push_flags_fn_t) ndr_push_lsa_QuerySecurity,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_QuerySecurity,
+- (ndr_print_function_t) ndr_print_lsa_QuerySecurity,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13601,7 +13601,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_SetSecObj),
+ (ndr_push_flags_fn_t) ndr_push_lsa_SetSecObj,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_SetSecObj,
+- (ndr_print_function_t) ndr_print_lsa_SetSecObj,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13610,7 +13610,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_ChangePassword),
+ (ndr_push_flags_fn_t) ndr_push_lsa_ChangePassword,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_ChangePassword,
+- (ndr_print_function_t) ndr_print_lsa_ChangePassword,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13619,7 +13619,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_OpenPolicy),
+ (ndr_push_flags_fn_t) ndr_push_lsa_OpenPolicy,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_OpenPolicy,
+- (ndr_print_function_t) ndr_print_lsa_OpenPolicy,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13628,7 +13628,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_QueryInfoPolicy),
+ (ndr_push_flags_fn_t) ndr_push_lsa_QueryInfoPolicy,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_QueryInfoPolicy,
+- (ndr_print_function_t) ndr_print_lsa_QueryInfoPolicy,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13637,7 +13637,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_SetInfoPolicy),
+ (ndr_push_flags_fn_t) ndr_push_lsa_SetInfoPolicy,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_SetInfoPolicy,
+- (ndr_print_function_t) ndr_print_lsa_SetInfoPolicy,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13646,7 +13646,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_ClearAuditLog),
+ (ndr_push_flags_fn_t) ndr_push_lsa_ClearAuditLog,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_ClearAuditLog,
+- (ndr_print_function_t) ndr_print_lsa_ClearAuditLog,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13655,7 +13655,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_CreateAccount),
+ (ndr_push_flags_fn_t) ndr_push_lsa_CreateAccount,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_CreateAccount,
+- (ndr_print_function_t) ndr_print_lsa_CreateAccount,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13664,7 +13664,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_EnumAccounts),
+ (ndr_push_flags_fn_t) ndr_push_lsa_EnumAccounts,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_EnumAccounts,
+- (ndr_print_function_t) ndr_print_lsa_EnumAccounts,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13673,7 +13673,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_CreateTrustedDomain),
+ (ndr_push_flags_fn_t) ndr_push_lsa_CreateTrustedDomain,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_CreateTrustedDomain,
+- (ndr_print_function_t) ndr_print_lsa_CreateTrustedDomain,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13682,7 +13682,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_EnumTrustDom),
+ (ndr_push_flags_fn_t) ndr_push_lsa_EnumTrustDom,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_EnumTrustDom,
+- (ndr_print_function_t) ndr_print_lsa_EnumTrustDom,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13691,7 +13691,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_LookupNames),
+ (ndr_push_flags_fn_t) ndr_push_lsa_LookupNames,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_LookupNames,
+- (ndr_print_function_t) ndr_print_lsa_LookupNames,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13700,7 +13700,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_LookupSids),
+ (ndr_push_flags_fn_t) ndr_push_lsa_LookupSids,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_LookupSids,
+- (ndr_print_function_t) ndr_print_lsa_LookupSids,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13709,7 +13709,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_CreateSecret),
+ (ndr_push_flags_fn_t) ndr_push_lsa_CreateSecret,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_CreateSecret,
+- (ndr_print_function_t) ndr_print_lsa_CreateSecret,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13718,7 +13718,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_OpenAccount),
+ (ndr_push_flags_fn_t) ndr_push_lsa_OpenAccount,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_OpenAccount,
+- (ndr_print_function_t) ndr_print_lsa_OpenAccount,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13727,7 +13727,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_EnumPrivsAccount),
+ (ndr_push_flags_fn_t) ndr_push_lsa_EnumPrivsAccount,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_EnumPrivsAccount,
+- (ndr_print_function_t) ndr_print_lsa_EnumPrivsAccount,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13736,7 +13736,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_AddPrivilegesToAccount),
+ (ndr_push_flags_fn_t) ndr_push_lsa_AddPrivilegesToAccount,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_AddPrivilegesToAccount,
+- (ndr_print_function_t) ndr_print_lsa_AddPrivilegesToAccount,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13745,7 +13745,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_RemovePrivilegesFromAccount),
+ (ndr_push_flags_fn_t) ndr_push_lsa_RemovePrivilegesFromAccount,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_RemovePrivilegesFromAccount,
+- (ndr_print_function_t) ndr_print_lsa_RemovePrivilegesFromAccount,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13754,7 +13754,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_GetQuotasForAccount),
+ (ndr_push_flags_fn_t) ndr_push_lsa_GetQuotasForAccount,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_GetQuotasForAccount,
+- (ndr_print_function_t) ndr_print_lsa_GetQuotasForAccount,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13763,7 +13763,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_SetQuotasForAccount),
+ (ndr_push_flags_fn_t) ndr_push_lsa_SetQuotasForAccount,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_SetQuotasForAccount,
+- (ndr_print_function_t) ndr_print_lsa_SetQuotasForAccount,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13772,7 +13772,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_GetSystemAccessAccount),
+ (ndr_push_flags_fn_t) ndr_push_lsa_GetSystemAccessAccount,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_GetSystemAccessAccount,
+- (ndr_print_function_t) ndr_print_lsa_GetSystemAccessAccount,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13781,7 +13781,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_SetSystemAccessAccount),
+ (ndr_push_flags_fn_t) ndr_push_lsa_SetSystemAccessAccount,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_SetSystemAccessAccount,
+- (ndr_print_function_t) ndr_print_lsa_SetSystemAccessAccount,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13790,7 +13790,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_OpenTrustedDomain),
+ (ndr_push_flags_fn_t) ndr_push_lsa_OpenTrustedDomain,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_OpenTrustedDomain,
+- (ndr_print_function_t) ndr_print_lsa_OpenTrustedDomain,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13799,7 +13799,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_QueryTrustedDomainInfo),
+ (ndr_push_flags_fn_t) ndr_push_lsa_QueryTrustedDomainInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_QueryTrustedDomainInfo,
+- (ndr_print_function_t) ndr_print_lsa_QueryTrustedDomainInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13808,7 +13808,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_SetInformationTrustedDomain),
+ (ndr_push_flags_fn_t) ndr_push_lsa_SetInformationTrustedDomain,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_SetInformationTrustedDomain,
+- (ndr_print_function_t) ndr_print_lsa_SetInformationTrustedDomain,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13817,7 +13817,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_OpenSecret),
+ (ndr_push_flags_fn_t) ndr_push_lsa_OpenSecret,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_OpenSecret,
+- (ndr_print_function_t) ndr_print_lsa_OpenSecret,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13826,7 +13826,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_SetSecret),
+ (ndr_push_flags_fn_t) ndr_push_lsa_SetSecret,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_SetSecret,
+- (ndr_print_function_t) ndr_print_lsa_SetSecret,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13835,7 +13835,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_QuerySecret),
+ (ndr_push_flags_fn_t) ndr_push_lsa_QuerySecret,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_QuerySecret,
+- (ndr_print_function_t) ndr_print_lsa_QuerySecret,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13844,7 +13844,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_LookupPrivValue),
+ (ndr_push_flags_fn_t) ndr_push_lsa_LookupPrivValue,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_LookupPrivValue,
+- (ndr_print_function_t) ndr_print_lsa_LookupPrivValue,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13853,7 +13853,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_LookupPrivName),
+ (ndr_push_flags_fn_t) ndr_push_lsa_LookupPrivName,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_LookupPrivName,
+- (ndr_print_function_t) ndr_print_lsa_LookupPrivName,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13862,7 +13862,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_LookupPrivDisplayName),
+ (ndr_push_flags_fn_t) ndr_push_lsa_LookupPrivDisplayName,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_LookupPrivDisplayName,
+- (ndr_print_function_t) ndr_print_lsa_LookupPrivDisplayName,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13871,7 +13871,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_DeleteObject),
+ (ndr_push_flags_fn_t) ndr_push_lsa_DeleteObject,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_DeleteObject,
+- (ndr_print_function_t) ndr_print_lsa_DeleteObject,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13880,7 +13880,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_EnumAccountsWithUserRight),
+ (ndr_push_flags_fn_t) ndr_push_lsa_EnumAccountsWithUserRight,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_EnumAccountsWithUserRight,
+- (ndr_print_function_t) ndr_print_lsa_EnumAccountsWithUserRight,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13889,7 +13889,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_EnumAccountRights),
+ (ndr_push_flags_fn_t) ndr_push_lsa_EnumAccountRights,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_EnumAccountRights,
+- (ndr_print_function_t) ndr_print_lsa_EnumAccountRights,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13898,7 +13898,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_AddAccountRights),
+ (ndr_push_flags_fn_t) ndr_push_lsa_AddAccountRights,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_AddAccountRights,
+- (ndr_print_function_t) ndr_print_lsa_AddAccountRights,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13907,7 +13907,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_RemoveAccountRights),
+ (ndr_push_flags_fn_t) ndr_push_lsa_RemoveAccountRights,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_RemoveAccountRights,
+- (ndr_print_function_t) ndr_print_lsa_RemoveAccountRights,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13916,7 +13916,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_QueryTrustedDomainInfoBySid),
+ (ndr_push_flags_fn_t) ndr_push_lsa_QueryTrustedDomainInfoBySid,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_QueryTrustedDomainInfoBySid,
+- (ndr_print_function_t) ndr_print_lsa_QueryTrustedDomainInfoBySid,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13925,7 +13925,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_SetTrustedDomainInfo),
+ (ndr_push_flags_fn_t) ndr_push_lsa_SetTrustedDomainInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_SetTrustedDomainInfo,
+- (ndr_print_function_t) ndr_print_lsa_SetTrustedDomainInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13934,7 +13934,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_DeleteTrustedDomain),
+ (ndr_push_flags_fn_t) ndr_push_lsa_DeleteTrustedDomain,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_DeleteTrustedDomain,
+- (ndr_print_function_t) ndr_print_lsa_DeleteTrustedDomain,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13943,7 +13943,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_StorePrivateData),
+ (ndr_push_flags_fn_t) ndr_push_lsa_StorePrivateData,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_StorePrivateData,
+- (ndr_print_function_t) ndr_print_lsa_StorePrivateData,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13952,7 +13952,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_RetrievePrivateData),
+ (ndr_push_flags_fn_t) ndr_push_lsa_RetrievePrivateData,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_RetrievePrivateData,
+- (ndr_print_function_t) ndr_print_lsa_RetrievePrivateData,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13961,7 +13961,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_OpenPolicy2),
+ (ndr_push_flags_fn_t) ndr_push_lsa_OpenPolicy2,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_OpenPolicy2,
+- (ndr_print_function_t) ndr_print_lsa_OpenPolicy2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13970,7 +13970,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_GetUserName),
+ (ndr_push_flags_fn_t) ndr_push_lsa_GetUserName,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_GetUserName,
+- (ndr_print_function_t) ndr_print_lsa_GetUserName,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13979,7 +13979,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_QueryInfoPolicy2),
+ (ndr_push_flags_fn_t) ndr_push_lsa_QueryInfoPolicy2,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_QueryInfoPolicy2,
+- (ndr_print_function_t) ndr_print_lsa_QueryInfoPolicy2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13988,7 +13988,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_SetInfoPolicy2),
+ (ndr_push_flags_fn_t) ndr_push_lsa_SetInfoPolicy2,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_SetInfoPolicy2,
+- (ndr_print_function_t) ndr_print_lsa_SetInfoPolicy2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13997,7 +13997,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_QueryTrustedDomainInfoByName),
+ (ndr_push_flags_fn_t) ndr_push_lsa_QueryTrustedDomainInfoByName,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_QueryTrustedDomainInfoByName,
+- (ndr_print_function_t) ndr_print_lsa_QueryTrustedDomainInfoByName,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14006,7 +14006,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_SetTrustedDomainInfoByName),
+ (ndr_push_flags_fn_t) ndr_push_lsa_SetTrustedDomainInfoByName,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_SetTrustedDomainInfoByName,
+- (ndr_print_function_t) ndr_print_lsa_SetTrustedDomainInfoByName,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14015,7 +14015,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_EnumTrustedDomainsEx),
+ (ndr_push_flags_fn_t) ndr_push_lsa_EnumTrustedDomainsEx,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_EnumTrustedDomainsEx,
+- (ndr_print_function_t) ndr_print_lsa_EnumTrustedDomainsEx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14024,7 +14024,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_CreateTrustedDomainEx),
+ (ndr_push_flags_fn_t) ndr_push_lsa_CreateTrustedDomainEx,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_CreateTrustedDomainEx,
+- (ndr_print_function_t) ndr_print_lsa_CreateTrustedDomainEx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14033,7 +14033,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_CloseTrustedDomainEx),
+ (ndr_push_flags_fn_t) ndr_push_lsa_CloseTrustedDomainEx,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_CloseTrustedDomainEx,
+- (ndr_print_function_t) ndr_print_lsa_CloseTrustedDomainEx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14042,7 +14042,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_QueryDomainInformationPolicy),
+ (ndr_push_flags_fn_t) ndr_push_lsa_QueryDomainInformationPolicy,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_QueryDomainInformationPolicy,
+- (ndr_print_function_t) ndr_print_lsa_QueryDomainInformationPolicy,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14051,7 +14051,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_SetDomainInformationPolicy),
+ (ndr_push_flags_fn_t) ndr_push_lsa_SetDomainInformationPolicy,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_SetDomainInformationPolicy,
+- (ndr_print_function_t) ndr_print_lsa_SetDomainInformationPolicy,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14060,7 +14060,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_OpenTrustedDomainByName),
+ (ndr_push_flags_fn_t) ndr_push_lsa_OpenTrustedDomainByName,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_OpenTrustedDomainByName,
+- (ndr_print_function_t) ndr_print_lsa_OpenTrustedDomainByName,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14069,7 +14069,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_TestCall),
+ (ndr_push_flags_fn_t) ndr_push_lsa_TestCall,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_TestCall,
+- (ndr_print_function_t) ndr_print_lsa_TestCall,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14078,7 +14078,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_LookupSids2),
+ (ndr_push_flags_fn_t) ndr_push_lsa_LookupSids2,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_LookupSids2,
+- (ndr_print_function_t) ndr_print_lsa_LookupSids2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14087,7 +14087,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_LookupNames2),
+ (ndr_push_flags_fn_t) ndr_push_lsa_LookupNames2,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_LookupNames2,
+- (ndr_print_function_t) ndr_print_lsa_LookupNames2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14096,7 +14096,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_CreateTrustedDomainEx2),
+ (ndr_push_flags_fn_t) ndr_push_lsa_CreateTrustedDomainEx2,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_CreateTrustedDomainEx2,
+- (ndr_print_function_t) ndr_print_lsa_CreateTrustedDomainEx2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14105,7 +14105,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_CREDRWRITE),
+ (ndr_push_flags_fn_t) ndr_push_lsa_CREDRWRITE,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_CREDRWRITE,
+- (ndr_print_function_t) ndr_print_lsa_CREDRWRITE,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14114,7 +14114,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_CREDRREAD),
+ (ndr_push_flags_fn_t) ndr_push_lsa_CREDRREAD,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_CREDRREAD,
+- (ndr_print_function_t) ndr_print_lsa_CREDRREAD,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14123,7 +14123,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_CREDRENUMERATE),
+ (ndr_push_flags_fn_t) ndr_push_lsa_CREDRENUMERATE,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_CREDRENUMERATE,
+- (ndr_print_function_t) ndr_print_lsa_CREDRENUMERATE,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14132,7 +14132,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_CREDRWRITEDOMAINCREDENTIALS),
+ (ndr_push_flags_fn_t) ndr_push_lsa_CREDRWRITEDOMAINCREDENTIALS,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_CREDRWRITEDOMAINCREDENTIALS,
+- (ndr_print_function_t) ndr_print_lsa_CREDRWRITEDOMAINCREDENTIALS,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14141,7 +14141,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_CREDRREADDOMAINCREDENTIALS),
+ (ndr_push_flags_fn_t) ndr_push_lsa_CREDRREADDOMAINCREDENTIALS,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_CREDRREADDOMAINCREDENTIALS,
+- (ndr_print_function_t) ndr_print_lsa_CREDRREADDOMAINCREDENTIALS,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14150,7 +14150,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_CREDRDELETE),
+ (ndr_push_flags_fn_t) ndr_push_lsa_CREDRDELETE,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_CREDRDELETE,
+- (ndr_print_function_t) ndr_print_lsa_CREDRDELETE,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14159,7 +14159,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_CREDRGETTARGETINFO),
+ (ndr_push_flags_fn_t) ndr_push_lsa_CREDRGETTARGETINFO,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_CREDRGETTARGETINFO,
+- (ndr_print_function_t) ndr_print_lsa_CREDRGETTARGETINFO,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14168,7 +14168,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_CREDRPROFILELOADED),
+ (ndr_push_flags_fn_t) ndr_push_lsa_CREDRPROFILELOADED,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_CREDRPROFILELOADED,
+- (ndr_print_function_t) ndr_print_lsa_CREDRPROFILELOADED,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14177,7 +14177,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_LookupNames3),
+ (ndr_push_flags_fn_t) ndr_push_lsa_LookupNames3,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_LookupNames3,
+- (ndr_print_function_t) ndr_print_lsa_LookupNames3,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14186,7 +14186,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_CREDRGETSESSIONTYPES),
+ (ndr_push_flags_fn_t) ndr_push_lsa_CREDRGETSESSIONTYPES,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_CREDRGETSESSIONTYPES,
+- (ndr_print_function_t) ndr_print_lsa_CREDRGETSESSIONTYPES,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14195,7 +14195,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_LSARREGISTERAUDITEVENT),
+ (ndr_push_flags_fn_t) ndr_push_lsa_LSARREGISTERAUDITEVENT,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_LSARREGISTERAUDITEVENT,
+- (ndr_print_function_t) ndr_print_lsa_LSARREGISTERAUDITEVENT,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14204,7 +14204,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_LSARGENAUDITEVENT),
+ (ndr_push_flags_fn_t) ndr_push_lsa_LSARGENAUDITEVENT,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_LSARGENAUDITEVENT,
+- (ndr_print_function_t) ndr_print_lsa_LSARGENAUDITEVENT,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14213,7 +14213,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_LSARUNREGISTERAUDITEVENT),
+ (ndr_push_flags_fn_t) ndr_push_lsa_LSARUNREGISTERAUDITEVENT,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_LSARUNREGISTERAUDITEVENT,
+- (ndr_print_function_t) ndr_print_lsa_LSARUNREGISTERAUDITEVENT,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14222,7 +14222,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_lsaRQueryForestTrustInformation),
+ (ndr_push_flags_fn_t) ndr_push_lsa_lsaRQueryForestTrustInformation,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_lsaRQueryForestTrustInformation,
+- (ndr_print_function_t) ndr_print_lsa_lsaRQueryForestTrustInformation,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14231,7 +14231,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_lsaRSetForestTrustInformation),
+ (ndr_push_flags_fn_t) ndr_push_lsa_lsaRSetForestTrustInformation,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_lsaRSetForestTrustInformation,
+- (ndr_print_function_t) ndr_print_lsa_lsaRSetForestTrustInformation,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14240,7 +14240,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_CREDRRENAME),
+ (ndr_push_flags_fn_t) ndr_push_lsa_CREDRRENAME,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_CREDRRENAME,
+- (ndr_print_function_t) ndr_print_lsa_CREDRRENAME,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14249,7 +14249,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_LookupSids3),
+ (ndr_push_flags_fn_t) ndr_push_lsa_LookupSids3,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_LookupSids3,
+- (ndr_print_function_t) ndr_print_lsa_LookupSids3,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14258,7 +14258,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_LookupNames4),
+ (ndr_push_flags_fn_t) ndr_push_lsa_LookupNames4,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_LookupNames4,
+- (ndr_print_function_t) ndr_print_lsa_LookupNames4,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14267,7 +14267,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_LSAROPENPOLICYSCE),
+ (ndr_push_flags_fn_t) ndr_push_lsa_LSAROPENPOLICYSCE,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_LSAROPENPOLICYSCE,
+- (ndr_print_function_t) ndr_print_lsa_LSAROPENPOLICYSCE,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14276,7 +14276,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_LSARADTREGISTERSECURITYEVENTSOURCE),
+ (ndr_push_flags_fn_t) ndr_push_lsa_LSARADTREGISTERSECURITYEVENTSOURCE,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_LSARADTREGISTERSECURITYEVENTSOURCE,
+- (ndr_print_function_t) ndr_print_lsa_LSARADTREGISTERSECURITYEVENTSOURCE,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14285,7 +14285,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_LSARADTUNREGISTERSECURITYEVENTSOURCE),
+ (ndr_push_flags_fn_t) ndr_push_lsa_LSARADTUNREGISTERSECURITYEVENTSOURCE,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_LSARADTUNREGISTERSECURITYEVENTSOURCE,
+- (ndr_print_function_t) ndr_print_lsa_LSARADTUNREGISTERSECURITYEVENTSOURCE,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14294,7 +14294,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_LSARADTREPORTSECURITYEVENT),
+ (ndr_push_flags_fn_t) ndr_push_lsa_LSARADTREPORTSECURITYEVENT,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_LSARADTREPORTSECURITYEVENT,
+- (ndr_print_function_t) ndr_print_lsa_LSARADTREPORTSECURITYEVENT,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_mgmt.c
++++ b/source3/librpc/gen_ndr/ndr_mgmt.c
+@@ -515,7 +515,7 @@ static const struct ndr_interface_call m
+ sizeof(struct mgmt_inq_if_ids),
+ (ndr_push_flags_fn_t) ndr_push_mgmt_inq_if_ids,
+ (ndr_pull_flags_fn_t) ndr_pull_mgmt_inq_if_ids,
+- (ndr_print_function_t) ndr_print_mgmt_inq_if_ids,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -524,7 +524,7 @@ static const struct ndr_interface_call m
+ sizeof(struct mgmt_inq_stats),
+ (ndr_push_flags_fn_t) ndr_push_mgmt_inq_stats,
+ (ndr_pull_flags_fn_t) ndr_pull_mgmt_inq_stats,
+- (ndr_print_function_t) ndr_print_mgmt_inq_stats,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -533,7 +533,7 @@ static const struct ndr_interface_call m
+ sizeof(struct mgmt_is_server_listening),
+ (ndr_push_flags_fn_t) ndr_push_mgmt_is_server_listening,
+ (ndr_pull_flags_fn_t) ndr_pull_mgmt_is_server_listening,
+- (ndr_print_function_t) ndr_print_mgmt_is_server_listening,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -542,7 +542,7 @@ static const struct ndr_interface_call m
+ sizeof(struct mgmt_stop_server_listening),
+ (ndr_push_flags_fn_t) ndr_push_mgmt_stop_server_listening,
+ (ndr_pull_flags_fn_t) ndr_pull_mgmt_stop_server_listening,
+- (ndr_print_function_t) ndr_print_mgmt_stop_server_listening,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -551,7 +551,7 @@ static const struct ndr_interface_call m
+ sizeof(struct mgmt_inq_princ_name),
+ (ndr_push_flags_fn_t) ndr_push_mgmt_inq_princ_name,
+ (ndr_pull_flags_fn_t) ndr_pull_mgmt_inq_princ_name,
+- (ndr_print_function_t) ndr_print_mgmt_inq_princ_name,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_msgsvc.c
++++ b/source3/librpc/gen_ndr/ndr_msgsvc.c
+@@ -165,7 +165,7 @@ static const struct ndr_interface_call m
+ sizeof(struct NetrMessageNameAdd),
+ (ndr_push_flags_fn_t) ndr_push_NetrMessageNameAdd,
+ (ndr_pull_flags_fn_t) ndr_pull_NetrMessageNameAdd,
+- (ndr_print_function_t) ndr_print_NetrMessageNameAdd,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -174,7 +174,7 @@ static const struct ndr_interface_call m
+ sizeof(struct NetrMessageNameEnum),
+ (ndr_push_flags_fn_t) ndr_push_NetrMessageNameEnum,
+ (ndr_pull_flags_fn_t) ndr_pull_NetrMessageNameEnum,
+- (ndr_print_function_t) ndr_print_NetrMessageNameEnum,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -183,7 +183,7 @@ static const struct ndr_interface_call m
+ sizeof(struct NetrMessageNameGetInfo),
+ (ndr_push_flags_fn_t) ndr_push_NetrMessageNameGetInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_NetrMessageNameGetInfo,
+- (ndr_print_function_t) ndr_print_NetrMessageNameGetInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -192,7 +192,7 @@ static const struct ndr_interface_call m
+ sizeof(struct NetrMessageNameDel),
+ (ndr_push_flags_fn_t) ndr_push_NetrMessageNameDel,
+ (ndr_pull_flags_fn_t) ndr_pull_NetrMessageNameDel,
+- (ndr_print_function_t) ndr_print_NetrMessageNameDel,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -276,7 +276,7 @@ static const struct ndr_interface_call m
+ sizeof(struct NetrSendMessage),
+ (ndr_push_flags_fn_t) ndr_push_NetrSendMessage,
+ (ndr_pull_flags_fn_t) ndr_pull_NetrSendMessage,
+- (ndr_print_function_t) ndr_print_NetrSendMessage,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_nbt.c
++++ b/source3/librpc/gen_ndr/ndr_nbt.c
+@@ -3671,7 +3671,7 @@ static const struct ndr_interface_call n
+ sizeof(struct decode_nbt_netlogon_packet),
+ (ndr_push_flags_fn_t) ndr_push_decode_nbt_netlogon_packet,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_nbt_netlogon_packet,
+- (ndr_print_function_t) ndr_print_decode_nbt_netlogon_packet,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_netlogon.c
++++ b/source3/librpc/gen_ndr/ndr_netlogon.c
+@@ -17827,7 +17827,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_LogonUasLogon),
+ (ndr_push_flags_fn_t) ndr_push_netr_LogonUasLogon,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_LogonUasLogon,
+- (ndr_print_function_t) ndr_print_netr_LogonUasLogon,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -17836,7 +17836,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_LogonUasLogoff),
+ (ndr_push_flags_fn_t) ndr_push_netr_LogonUasLogoff,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_LogonUasLogoff,
+- (ndr_print_function_t) ndr_print_netr_LogonUasLogoff,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -17845,7 +17845,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_LogonSamLogon),
+ (ndr_push_flags_fn_t) ndr_push_netr_LogonSamLogon,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_LogonSamLogon,
+- (ndr_print_function_t) ndr_print_netr_LogonSamLogon,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -17854,7 +17854,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_LogonSamLogoff),
+ (ndr_push_flags_fn_t) ndr_push_netr_LogonSamLogoff,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_LogonSamLogoff,
+- (ndr_print_function_t) ndr_print_netr_LogonSamLogoff,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -17863,7 +17863,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_ServerReqChallenge),
+ (ndr_push_flags_fn_t) ndr_push_netr_ServerReqChallenge,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_ServerReqChallenge,
+- (ndr_print_function_t) ndr_print_netr_ServerReqChallenge,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -17872,7 +17872,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_ServerAuthenticate),
+ (ndr_push_flags_fn_t) ndr_push_netr_ServerAuthenticate,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_ServerAuthenticate,
+- (ndr_print_function_t) ndr_print_netr_ServerAuthenticate,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -17881,7 +17881,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_ServerPasswordSet),
+ (ndr_push_flags_fn_t) ndr_push_netr_ServerPasswordSet,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_ServerPasswordSet,
+- (ndr_print_function_t) ndr_print_netr_ServerPasswordSet,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -17890,7 +17890,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_DatabaseDeltas),
+ (ndr_push_flags_fn_t) ndr_push_netr_DatabaseDeltas,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_DatabaseDeltas,
+- (ndr_print_function_t) ndr_print_netr_DatabaseDeltas,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -17899,7 +17899,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_DatabaseSync),
+ (ndr_push_flags_fn_t) ndr_push_netr_DatabaseSync,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_DatabaseSync,
+- (ndr_print_function_t) ndr_print_netr_DatabaseSync,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -17908,7 +17908,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_AccountDeltas),
+ (ndr_push_flags_fn_t) ndr_push_netr_AccountDeltas,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_AccountDeltas,
+- (ndr_print_function_t) ndr_print_netr_AccountDeltas,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -17917,7 +17917,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_AccountSync),
+ (ndr_push_flags_fn_t) ndr_push_netr_AccountSync,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_AccountSync,
+- (ndr_print_function_t) ndr_print_netr_AccountSync,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -17926,7 +17926,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_GetDcName),
+ (ndr_push_flags_fn_t) ndr_push_netr_GetDcName,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_GetDcName,
+- (ndr_print_function_t) ndr_print_netr_GetDcName,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -17935,7 +17935,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_LogonControl),
+ (ndr_push_flags_fn_t) ndr_push_netr_LogonControl,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_LogonControl,
+- (ndr_print_function_t) ndr_print_netr_LogonControl,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -17944,7 +17944,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_GetAnyDCName),
+ (ndr_push_flags_fn_t) ndr_push_netr_GetAnyDCName,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_GetAnyDCName,
+- (ndr_print_function_t) ndr_print_netr_GetAnyDCName,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -17953,7 +17953,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_LogonControl2),
+ (ndr_push_flags_fn_t) ndr_push_netr_LogonControl2,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_LogonControl2,
+- (ndr_print_function_t) ndr_print_netr_LogonControl2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -17962,7 +17962,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_ServerAuthenticate2),
+ (ndr_push_flags_fn_t) ndr_push_netr_ServerAuthenticate2,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_ServerAuthenticate2,
+- (ndr_print_function_t) ndr_print_netr_ServerAuthenticate2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -17971,7 +17971,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_DatabaseSync2),
+ (ndr_push_flags_fn_t) ndr_push_netr_DatabaseSync2,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_DatabaseSync2,
+- (ndr_print_function_t) ndr_print_netr_DatabaseSync2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -17980,7 +17980,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_DatabaseRedo),
+ (ndr_push_flags_fn_t) ndr_push_netr_DatabaseRedo,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_DatabaseRedo,
+- (ndr_print_function_t) ndr_print_netr_DatabaseRedo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -17989,7 +17989,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_LogonControl2Ex),
+ (ndr_push_flags_fn_t) ndr_push_netr_LogonControl2Ex,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_LogonControl2Ex,
+- (ndr_print_function_t) ndr_print_netr_LogonControl2Ex,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -17998,7 +17998,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_NetrEnumerateTrustedDomains),
+ (ndr_push_flags_fn_t) ndr_push_netr_NetrEnumerateTrustedDomains,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_NetrEnumerateTrustedDomains,
+- (ndr_print_function_t) ndr_print_netr_NetrEnumerateTrustedDomains,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -18007,7 +18007,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_DsRGetDCName),
+ (ndr_push_flags_fn_t) ndr_push_netr_DsRGetDCName,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_DsRGetDCName,
+- (ndr_print_function_t) ndr_print_netr_DsRGetDCName,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -18016,7 +18016,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_LogonGetCapabilities),
+ (ndr_push_flags_fn_t) ndr_push_netr_LogonGetCapabilities,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_LogonGetCapabilities,
+- (ndr_print_function_t) ndr_print_netr_LogonGetCapabilities,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -18025,7 +18025,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_NETRLOGONSETSERVICEBITS),
+ (ndr_push_flags_fn_t) ndr_push_netr_NETRLOGONSETSERVICEBITS,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_NETRLOGONSETSERVICEBITS,
+- (ndr_print_function_t) ndr_print_netr_NETRLOGONSETSERVICEBITS,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -18034,7 +18034,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_LogonGetTrustRid),
+ (ndr_push_flags_fn_t) ndr_push_netr_LogonGetTrustRid,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_LogonGetTrustRid,
+- (ndr_print_function_t) ndr_print_netr_LogonGetTrustRid,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -18043,7 +18043,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_NETRLOGONCOMPUTESERVERDIGEST),
+ (ndr_push_flags_fn_t) ndr_push_netr_NETRLOGONCOMPUTESERVERDIGEST,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_NETRLOGONCOMPUTESERVERDIGEST,
+- (ndr_print_function_t) ndr_print_netr_NETRLOGONCOMPUTESERVERDIGEST,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -18052,7 +18052,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_NETRLOGONCOMPUTECLIENTDIGEST),
+ (ndr_push_flags_fn_t) ndr_push_netr_NETRLOGONCOMPUTECLIENTDIGEST,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_NETRLOGONCOMPUTECLIENTDIGEST,
+- (ndr_print_function_t) ndr_print_netr_NETRLOGONCOMPUTECLIENTDIGEST,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -18061,7 +18061,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_ServerAuthenticate3),
+ (ndr_push_flags_fn_t) ndr_push_netr_ServerAuthenticate3,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_ServerAuthenticate3,
+- (ndr_print_function_t) ndr_print_netr_ServerAuthenticate3,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -18070,7 +18070,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_DsRGetDCNameEx),
+ (ndr_push_flags_fn_t) ndr_push_netr_DsRGetDCNameEx,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_DsRGetDCNameEx,
+- (ndr_print_function_t) ndr_print_netr_DsRGetDCNameEx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -18079,7 +18079,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_DsRGetSiteName),
+ (ndr_push_flags_fn_t) ndr_push_netr_DsRGetSiteName,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_DsRGetSiteName,
+- (ndr_print_function_t) ndr_print_netr_DsRGetSiteName,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -18088,7 +18088,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_LogonGetDomainInfo),
+ (ndr_push_flags_fn_t) ndr_push_netr_LogonGetDomainInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_LogonGetDomainInfo,
+- (ndr_print_function_t) ndr_print_netr_LogonGetDomainInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -18097,7 +18097,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_ServerPasswordSet2),
+ (ndr_push_flags_fn_t) ndr_push_netr_ServerPasswordSet2,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_ServerPasswordSet2,
+- (ndr_print_function_t) ndr_print_netr_ServerPasswordSet2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -18106,7 +18106,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_ServerPasswordGet),
+ (ndr_push_flags_fn_t) ndr_push_netr_ServerPasswordGet,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_ServerPasswordGet,
+- (ndr_print_function_t) ndr_print_netr_ServerPasswordGet,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -18115,7 +18115,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_NETRLOGONSENDTOSAM),
+ (ndr_push_flags_fn_t) ndr_push_netr_NETRLOGONSENDTOSAM,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_NETRLOGONSENDTOSAM,
+- (ndr_print_function_t) ndr_print_netr_NETRLOGONSENDTOSAM,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -18124,7 +18124,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_DsRAddressToSitenamesW),
+ (ndr_push_flags_fn_t) ndr_push_netr_DsRAddressToSitenamesW,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_DsRAddressToSitenamesW,
+- (ndr_print_function_t) ndr_print_netr_DsRAddressToSitenamesW,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -18133,7 +18133,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_DsRGetDCNameEx2),
+ (ndr_push_flags_fn_t) ndr_push_netr_DsRGetDCNameEx2,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_DsRGetDCNameEx2,
+- (ndr_print_function_t) ndr_print_netr_DsRGetDCNameEx2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -18142,7 +18142,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_NETRLOGONGETTIMESERVICEPARENTDOMAIN),
+ (ndr_push_flags_fn_t) ndr_push_netr_NETRLOGONGETTIMESERVICEPARENTDOMAIN,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_NETRLOGONGETTIMESERVICEPARENTDOMAIN,
+- (ndr_print_function_t) ndr_print_netr_NETRLOGONGETTIMESERVICEPARENTDOMAIN,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -18151,7 +18151,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_NetrEnumerateTrustedDomainsEx),
+ (ndr_push_flags_fn_t) ndr_push_netr_NetrEnumerateTrustedDomainsEx,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_NetrEnumerateTrustedDomainsEx,
+- (ndr_print_function_t) ndr_print_netr_NetrEnumerateTrustedDomainsEx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -18160,7 +18160,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_DsRAddressToSitenamesExW),
+ (ndr_push_flags_fn_t) ndr_push_netr_DsRAddressToSitenamesExW,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_DsRAddressToSitenamesExW,
+- (ndr_print_function_t) ndr_print_netr_DsRAddressToSitenamesExW,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -18169,7 +18169,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_DsrGetDcSiteCoverageW),
+ (ndr_push_flags_fn_t) ndr_push_netr_DsrGetDcSiteCoverageW,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_DsrGetDcSiteCoverageW,
+- (ndr_print_function_t) ndr_print_netr_DsrGetDcSiteCoverageW,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -18178,7 +18178,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_LogonSamLogonEx),
+ (ndr_push_flags_fn_t) ndr_push_netr_LogonSamLogonEx,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_LogonSamLogonEx,
+- (ndr_print_function_t) ndr_print_netr_LogonSamLogonEx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -18187,7 +18187,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_DsrEnumerateDomainTrusts),
+ (ndr_push_flags_fn_t) ndr_push_netr_DsrEnumerateDomainTrusts,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_DsrEnumerateDomainTrusts,
+- (ndr_print_function_t) ndr_print_netr_DsrEnumerateDomainTrusts,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -18196,7 +18196,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_DsrDeregisterDNSHostRecords),
+ (ndr_push_flags_fn_t) ndr_push_netr_DsrDeregisterDNSHostRecords,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_DsrDeregisterDNSHostRecords,
+- (ndr_print_function_t) ndr_print_netr_DsrDeregisterDNSHostRecords,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -18205,7 +18205,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_ServerTrustPasswordsGet),
+ (ndr_push_flags_fn_t) ndr_push_netr_ServerTrustPasswordsGet,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_ServerTrustPasswordsGet,
+- (ndr_print_function_t) ndr_print_netr_ServerTrustPasswordsGet,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -18214,7 +18214,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_DsRGetForestTrustInformation),
+ (ndr_push_flags_fn_t) ndr_push_netr_DsRGetForestTrustInformation,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_DsRGetForestTrustInformation,
+- (ndr_print_function_t) ndr_print_netr_DsRGetForestTrustInformation,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -18223,7 +18223,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_GetForestTrustInformation),
+ (ndr_push_flags_fn_t) ndr_push_netr_GetForestTrustInformation,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_GetForestTrustInformation,
+- (ndr_print_function_t) ndr_print_netr_GetForestTrustInformation,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -18232,7 +18232,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_LogonSamLogonWithFlags),
+ (ndr_push_flags_fn_t) ndr_push_netr_LogonSamLogonWithFlags,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_LogonSamLogonWithFlags,
+- (ndr_print_function_t) ndr_print_netr_LogonSamLogonWithFlags,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -18241,7 +18241,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_ServerGetTrustInfo),
+ (ndr_push_flags_fn_t) ndr_push_netr_ServerGetTrustInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_ServerGetTrustInfo,
+- (ndr_print_function_t) ndr_print_netr_ServerGetTrustInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -18250,7 +18250,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_Unused47),
+ (ndr_push_flags_fn_t) ndr_push_netr_Unused47,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_Unused47,
+- (ndr_print_function_t) ndr_print_netr_Unused47,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -18259,7 +18259,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_DsrUpdateReadOnlyServerDnsRecords),
+ (ndr_push_flags_fn_t) ndr_push_netr_DsrUpdateReadOnlyServerDnsRecords,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_DsrUpdateReadOnlyServerDnsRecords,
+- (ndr_print_function_t) ndr_print_netr_DsrUpdateReadOnlyServerDnsRecords,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_ntlmssp.c
++++ b/source3/librpc/gen_ndr/ndr_ntlmssp.c
+@@ -2408,7 +2408,7 @@ static const struct ndr_interface_call n
+ sizeof(struct decode_NEGOTIATE_MESSAGE),
+ (ndr_push_flags_fn_t) ndr_push_decode_NEGOTIATE_MESSAGE,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_NEGOTIATE_MESSAGE,
+- (ndr_print_function_t) ndr_print_decode_NEGOTIATE_MESSAGE,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2417,7 +2417,7 @@ static const struct ndr_interface_call n
+ sizeof(struct decode_CHALLENGE_MESSAGE),
+ (ndr_push_flags_fn_t) ndr_push_decode_CHALLENGE_MESSAGE,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_CHALLENGE_MESSAGE,
+- (ndr_print_function_t) ndr_print_decode_CHALLENGE_MESSAGE,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2426,7 +2426,7 @@ static const struct ndr_interface_call n
+ sizeof(struct decode_AUTHENTICATE_MESSAGE),
+ (ndr_push_flags_fn_t) ndr_push_decode_AUTHENTICATE_MESSAGE,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_AUTHENTICATE_MESSAGE,
+- (ndr_print_function_t) ndr_print_decode_AUTHENTICATE_MESSAGE,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2435,7 +2435,7 @@ static const struct ndr_interface_call n
+ sizeof(struct decode_NTLMv2_CLIENT_CHALLENGE),
+ (ndr_push_flags_fn_t) ndr_push_decode_NTLMv2_CLIENT_CHALLENGE,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_NTLMv2_CLIENT_CHALLENGE,
+- (ndr_print_function_t) ndr_print_decode_NTLMv2_CLIENT_CHALLENGE,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2444,7 +2444,7 @@ static const struct ndr_interface_call n
+ sizeof(struct decode_NTLMv2_RESPONSE),
+ (ndr_push_flags_fn_t) ndr_push_decode_NTLMv2_RESPONSE,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_NTLMv2_RESPONSE,
+- (ndr_print_function_t) ndr_print_decode_NTLMv2_RESPONSE,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_ntprinting.c
++++ b/source3/librpc/gen_ndr/ndr_ntprinting.c
+@@ -902,7 +902,7 @@ static const struct ndr_interface_call n
+ sizeof(struct decode_ntprinting_form),
+ (ndr_push_flags_fn_t) ndr_push_decode_ntprinting_form,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_ntprinting_form,
+- (ndr_print_function_t) ndr_print_decode_ntprinting_form,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -911,7 +911,7 @@ static const struct ndr_interface_call n
+ sizeof(struct decode_ntprinting_driver),
+ (ndr_push_flags_fn_t) ndr_push_decode_ntprinting_driver,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_ntprinting_driver,
+- (ndr_print_function_t) ndr_print_decode_ntprinting_driver,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -920,7 +920,7 @@ static const struct ndr_interface_call n
+ sizeof(struct decode_ntprinting_printer),
+ (ndr_push_flags_fn_t) ndr_push_decode_ntprinting_printer,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_ntprinting_printer,
+- (ndr_print_function_t) ndr_print_decode_ntprinting_printer,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_ntsvcs.c
++++ b/source3/librpc/gen_ndr/ndr_ntsvcs.c
+@@ -3466,7 +3466,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_Disconnect),
+ (ndr_push_flags_fn_t) ndr_push_PNP_Disconnect,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_Disconnect,
+- (ndr_print_function_t) ndr_print_PNP_Disconnect,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3475,7 +3475,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_Connect),
+ (ndr_push_flags_fn_t) ndr_push_PNP_Connect,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_Connect,
+- (ndr_print_function_t) ndr_print_PNP_Connect,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3484,7 +3484,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_GetVersion),
+ (ndr_push_flags_fn_t) ndr_push_PNP_GetVersion,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_GetVersion,
+- (ndr_print_function_t) ndr_print_PNP_GetVersion,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3493,7 +3493,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_GetGlobalState),
+ (ndr_push_flags_fn_t) ndr_push_PNP_GetGlobalState,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_GetGlobalState,
+- (ndr_print_function_t) ndr_print_PNP_GetGlobalState,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3502,7 +3502,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_InitDetection),
+ (ndr_push_flags_fn_t) ndr_push_PNP_InitDetection,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_InitDetection,
+- (ndr_print_function_t) ndr_print_PNP_InitDetection,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3511,7 +3511,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_ReportLogOn),
+ (ndr_push_flags_fn_t) ndr_push_PNP_ReportLogOn,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_ReportLogOn,
+- (ndr_print_function_t) ndr_print_PNP_ReportLogOn,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3520,7 +3520,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_ValidateDeviceInstance),
+ (ndr_push_flags_fn_t) ndr_push_PNP_ValidateDeviceInstance,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_ValidateDeviceInstance,
+- (ndr_print_function_t) ndr_print_PNP_ValidateDeviceInstance,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3529,7 +3529,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_GetRootDeviceInstance),
+ (ndr_push_flags_fn_t) ndr_push_PNP_GetRootDeviceInstance,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_GetRootDeviceInstance,
+- (ndr_print_function_t) ndr_print_PNP_GetRootDeviceInstance,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3538,7 +3538,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_GetRelatedDeviceInstance),
+ (ndr_push_flags_fn_t) ndr_push_PNP_GetRelatedDeviceInstance,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_GetRelatedDeviceInstance,
+- (ndr_print_function_t) ndr_print_PNP_GetRelatedDeviceInstance,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3547,7 +3547,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_EnumerateSubKeys),
+ (ndr_push_flags_fn_t) ndr_push_PNP_EnumerateSubKeys,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_EnumerateSubKeys,
+- (ndr_print_function_t) ndr_print_PNP_EnumerateSubKeys,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3556,7 +3556,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_GetDeviceList),
+ (ndr_push_flags_fn_t) ndr_push_PNP_GetDeviceList,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_GetDeviceList,
+- (ndr_print_function_t) ndr_print_PNP_GetDeviceList,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3565,7 +3565,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_GetDeviceListSize),
+ (ndr_push_flags_fn_t) ndr_push_PNP_GetDeviceListSize,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_GetDeviceListSize,
+- (ndr_print_function_t) ndr_print_PNP_GetDeviceListSize,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3574,7 +3574,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_GetDepth),
+ (ndr_push_flags_fn_t) ndr_push_PNP_GetDepth,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_GetDepth,
+- (ndr_print_function_t) ndr_print_PNP_GetDepth,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3583,7 +3583,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_GetDeviceRegProp),
+ (ndr_push_flags_fn_t) ndr_push_PNP_GetDeviceRegProp,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_GetDeviceRegProp,
+- (ndr_print_function_t) ndr_print_PNP_GetDeviceRegProp,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3592,7 +3592,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_SetDeviceRegProp),
+ (ndr_push_flags_fn_t) ndr_push_PNP_SetDeviceRegProp,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_SetDeviceRegProp,
+- (ndr_print_function_t) ndr_print_PNP_SetDeviceRegProp,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3601,7 +3601,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_GetClassInstance),
+ (ndr_push_flags_fn_t) ndr_push_PNP_GetClassInstance,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_GetClassInstance,
+- (ndr_print_function_t) ndr_print_PNP_GetClassInstance,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3610,7 +3610,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_CreateKey),
+ (ndr_push_flags_fn_t) ndr_push_PNP_CreateKey,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_CreateKey,
+- (ndr_print_function_t) ndr_print_PNP_CreateKey,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3619,7 +3619,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_DeleteRegistryKey),
+ (ndr_push_flags_fn_t) ndr_push_PNP_DeleteRegistryKey,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_DeleteRegistryKey,
+- (ndr_print_function_t) ndr_print_PNP_DeleteRegistryKey,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3628,7 +3628,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_GetClassCount),
+ (ndr_push_flags_fn_t) ndr_push_PNP_GetClassCount,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_GetClassCount,
+- (ndr_print_function_t) ndr_print_PNP_GetClassCount,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3637,7 +3637,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_GetClassName),
+ (ndr_push_flags_fn_t) ndr_push_PNP_GetClassName,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_GetClassName,
+- (ndr_print_function_t) ndr_print_PNP_GetClassName,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3646,7 +3646,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_DeleteClassKey),
+ (ndr_push_flags_fn_t) ndr_push_PNP_DeleteClassKey,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_DeleteClassKey,
+- (ndr_print_function_t) ndr_print_PNP_DeleteClassKey,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3655,7 +3655,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_GetInterfaceDeviceAlias),
+ (ndr_push_flags_fn_t) ndr_push_PNP_GetInterfaceDeviceAlias,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_GetInterfaceDeviceAlias,
+- (ndr_print_function_t) ndr_print_PNP_GetInterfaceDeviceAlias,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3664,7 +3664,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_GetInterfaceDeviceList),
+ (ndr_push_flags_fn_t) ndr_push_PNP_GetInterfaceDeviceList,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_GetInterfaceDeviceList,
+- (ndr_print_function_t) ndr_print_PNP_GetInterfaceDeviceList,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3673,7 +3673,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_GetInterfaceDeviceListSize),
+ (ndr_push_flags_fn_t) ndr_push_PNP_GetInterfaceDeviceListSize,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_GetInterfaceDeviceListSize,
+- (ndr_print_function_t) ndr_print_PNP_GetInterfaceDeviceListSize,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3682,7 +3682,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_RegisterDeviceClassAssociation),
+ (ndr_push_flags_fn_t) ndr_push_PNP_RegisterDeviceClassAssociation,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_RegisterDeviceClassAssociation,
+- (ndr_print_function_t) ndr_print_PNP_RegisterDeviceClassAssociation,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3691,7 +3691,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_UnregisterDeviceClassAssociation),
+ (ndr_push_flags_fn_t) ndr_push_PNP_UnregisterDeviceClassAssociation,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_UnregisterDeviceClassAssociation,
+- (ndr_print_function_t) ndr_print_PNP_UnregisterDeviceClassAssociation,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3700,7 +3700,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_GetClassRegProp),
+ (ndr_push_flags_fn_t) ndr_push_PNP_GetClassRegProp,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_GetClassRegProp,
+- (ndr_print_function_t) ndr_print_PNP_GetClassRegProp,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3709,7 +3709,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_SetClassRegProp),
+ (ndr_push_flags_fn_t) ndr_push_PNP_SetClassRegProp,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_SetClassRegProp,
+- (ndr_print_function_t) ndr_print_PNP_SetClassRegProp,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3718,7 +3718,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_CreateDevInst),
+ (ndr_push_flags_fn_t) ndr_push_PNP_CreateDevInst,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_CreateDevInst,
+- (ndr_print_function_t) ndr_print_PNP_CreateDevInst,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3727,7 +3727,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_DeviceInstanceAction),
+ (ndr_push_flags_fn_t) ndr_push_PNP_DeviceInstanceAction,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_DeviceInstanceAction,
+- (ndr_print_function_t) ndr_print_PNP_DeviceInstanceAction,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3736,7 +3736,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_GetDeviceStatus),
+ (ndr_push_flags_fn_t) ndr_push_PNP_GetDeviceStatus,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_GetDeviceStatus,
+- (ndr_print_function_t) ndr_print_PNP_GetDeviceStatus,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3745,7 +3745,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_SetDeviceProblem),
+ (ndr_push_flags_fn_t) ndr_push_PNP_SetDeviceProblem,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_SetDeviceProblem,
+- (ndr_print_function_t) ndr_print_PNP_SetDeviceProblem,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3754,7 +3754,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_DisableDevInst),
+ (ndr_push_flags_fn_t) ndr_push_PNP_DisableDevInst,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_DisableDevInst,
+- (ndr_print_function_t) ndr_print_PNP_DisableDevInst,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3763,7 +3763,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_UninstallDevInst),
+ (ndr_push_flags_fn_t) ndr_push_PNP_UninstallDevInst,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_UninstallDevInst,
+- (ndr_print_function_t) ndr_print_PNP_UninstallDevInst,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3772,7 +3772,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_AddID),
+ (ndr_push_flags_fn_t) ndr_push_PNP_AddID,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_AddID,
+- (ndr_print_function_t) ndr_print_PNP_AddID,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3781,7 +3781,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_RegisterDriver),
+ (ndr_push_flags_fn_t) ndr_push_PNP_RegisterDriver,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_RegisterDriver,
+- (ndr_print_function_t) ndr_print_PNP_RegisterDriver,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3790,7 +3790,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_QueryRemove),
+ (ndr_push_flags_fn_t) ndr_push_PNP_QueryRemove,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_QueryRemove,
+- (ndr_print_function_t) ndr_print_PNP_QueryRemove,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3799,7 +3799,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_RequestDeviceEject),
+ (ndr_push_flags_fn_t) ndr_push_PNP_RequestDeviceEject,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_RequestDeviceEject,
+- (ndr_print_function_t) ndr_print_PNP_RequestDeviceEject,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3808,7 +3808,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_IsDockStationPresent),
+ (ndr_push_flags_fn_t) ndr_push_PNP_IsDockStationPresent,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_IsDockStationPresent,
+- (ndr_print_function_t) ndr_print_PNP_IsDockStationPresent,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3817,7 +3817,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_RequestEjectPC),
+ (ndr_push_flags_fn_t) ndr_push_PNP_RequestEjectPC,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_RequestEjectPC,
+- (ndr_print_function_t) ndr_print_PNP_RequestEjectPC,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3826,7 +3826,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_HwProfFlags),
+ (ndr_push_flags_fn_t) ndr_push_PNP_HwProfFlags,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_HwProfFlags,
+- (ndr_print_function_t) ndr_print_PNP_HwProfFlags,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3835,7 +3835,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_GetHwProfInfo),
+ (ndr_push_flags_fn_t) ndr_push_PNP_GetHwProfInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_GetHwProfInfo,
+- (ndr_print_function_t) ndr_print_PNP_GetHwProfInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3844,7 +3844,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_AddEmptyLogConf),
+ (ndr_push_flags_fn_t) ndr_push_PNP_AddEmptyLogConf,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_AddEmptyLogConf,
+- (ndr_print_function_t) ndr_print_PNP_AddEmptyLogConf,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3853,7 +3853,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_FreeLogConf),
+ (ndr_push_flags_fn_t) ndr_push_PNP_FreeLogConf,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_FreeLogConf,
+- (ndr_print_function_t) ndr_print_PNP_FreeLogConf,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3862,7 +3862,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_GetFirstLogConf),
+ (ndr_push_flags_fn_t) ndr_push_PNP_GetFirstLogConf,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_GetFirstLogConf,
+- (ndr_print_function_t) ndr_print_PNP_GetFirstLogConf,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3871,7 +3871,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_GetNextLogConf),
+ (ndr_push_flags_fn_t) ndr_push_PNP_GetNextLogConf,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_GetNextLogConf,
+- (ndr_print_function_t) ndr_print_PNP_GetNextLogConf,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3880,7 +3880,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_GetLogConfPriority),
+ (ndr_push_flags_fn_t) ndr_push_PNP_GetLogConfPriority,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_GetLogConfPriority,
+- (ndr_print_function_t) ndr_print_PNP_GetLogConfPriority,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3889,7 +3889,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_AddResDes),
+ (ndr_push_flags_fn_t) ndr_push_PNP_AddResDes,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_AddResDes,
+- (ndr_print_function_t) ndr_print_PNP_AddResDes,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3898,7 +3898,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_FreeResDes),
+ (ndr_push_flags_fn_t) ndr_push_PNP_FreeResDes,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_FreeResDes,
+- (ndr_print_function_t) ndr_print_PNP_FreeResDes,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3907,7 +3907,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_GetNextResDes),
+ (ndr_push_flags_fn_t) ndr_push_PNP_GetNextResDes,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_GetNextResDes,
+- (ndr_print_function_t) ndr_print_PNP_GetNextResDes,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3916,7 +3916,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_GetResDesData),
+ (ndr_push_flags_fn_t) ndr_push_PNP_GetResDesData,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_GetResDesData,
+- (ndr_print_function_t) ndr_print_PNP_GetResDesData,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3925,7 +3925,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_GetResDesDataSize),
+ (ndr_push_flags_fn_t) ndr_push_PNP_GetResDesDataSize,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_GetResDesDataSize,
+- (ndr_print_function_t) ndr_print_PNP_GetResDesDataSize,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3934,7 +3934,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_ModifyResDes),
+ (ndr_push_flags_fn_t) ndr_push_PNP_ModifyResDes,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_ModifyResDes,
+- (ndr_print_function_t) ndr_print_PNP_ModifyResDes,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3943,7 +3943,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_DetectResourceLimit),
+ (ndr_push_flags_fn_t) ndr_push_PNP_DetectResourceLimit,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_DetectResourceLimit,
+- (ndr_print_function_t) ndr_print_PNP_DetectResourceLimit,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3952,7 +3952,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_QueryResConfList),
+ (ndr_push_flags_fn_t) ndr_push_PNP_QueryResConfList,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_QueryResConfList,
+- (ndr_print_function_t) ndr_print_PNP_QueryResConfList,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3961,7 +3961,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_SetHwProf),
+ (ndr_push_flags_fn_t) ndr_push_PNP_SetHwProf,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_SetHwProf,
+- (ndr_print_function_t) ndr_print_PNP_SetHwProf,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3970,7 +3970,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_QueryArbitratorFreeData),
+ (ndr_push_flags_fn_t) ndr_push_PNP_QueryArbitratorFreeData,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_QueryArbitratorFreeData,
+- (ndr_print_function_t) ndr_print_PNP_QueryArbitratorFreeData,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3979,7 +3979,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_QueryArbitratorFreeSize),
+ (ndr_push_flags_fn_t) ndr_push_PNP_QueryArbitratorFreeSize,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_QueryArbitratorFreeSize,
+- (ndr_print_function_t) ndr_print_PNP_QueryArbitratorFreeSize,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3988,7 +3988,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_RunDetection),
+ (ndr_push_flags_fn_t) ndr_push_PNP_RunDetection,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_RunDetection,
+- (ndr_print_function_t) ndr_print_PNP_RunDetection,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3997,7 +3997,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_RegisterNotification),
+ (ndr_push_flags_fn_t) ndr_push_PNP_RegisterNotification,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_RegisterNotification,
+- (ndr_print_function_t) ndr_print_PNP_RegisterNotification,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -4006,7 +4006,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_UnregisterNotification),
+ (ndr_push_flags_fn_t) ndr_push_PNP_UnregisterNotification,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_UnregisterNotification,
+- (ndr_print_function_t) ndr_print_PNP_UnregisterNotification,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -4015,7 +4015,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_GetCustomDevProp),
+ (ndr_push_flags_fn_t) ndr_push_PNP_GetCustomDevProp,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_GetCustomDevProp,
+- (ndr_print_function_t) ndr_print_PNP_GetCustomDevProp,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -4024,7 +4024,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_GetVersionInternal),
+ (ndr_push_flags_fn_t) ndr_push_PNP_GetVersionInternal,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_GetVersionInternal,
+- (ndr_print_function_t) ndr_print_PNP_GetVersionInternal,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -4033,7 +4033,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_GetBlockedDriverInfo),
+ (ndr_push_flags_fn_t) ndr_push_PNP_GetBlockedDriverInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_GetBlockedDriverInfo,
+- (ndr_print_function_t) ndr_print_PNP_GetBlockedDriverInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -4042,7 +4042,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_GetServerSideDeviceInstallFlags),
+ (ndr_push_flags_fn_t) ndr_push_PNP_GetServerSideDeviceInstallFlags,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_GetServerSideDeviceInstallFlags,
+- (ndr_print_function_t) ndr_print_PNP_GetServerSideDeviceInstallFlags,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_oxidresolver.c
++++ b/source3/librpc/gen_ndr/ndr_oxidresolver.c
+@@ -761,7 +761,7 @@ static const struct ndr_interface_call I
+ sizeof(struct ResolveOxid),
+ (ndr_push_flags_fn_t) ndr_push_ResolveOxid,
+ (ndr_pull_flags_fn_t) ndr_pull_ResolveOxid,
+- (ndr_print_function_t) ndr_print_ResolveOxid,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -770,7 +770,7 @@ static const struct ndr_interface_call I
+ sizeof(struct SimplePing),
+ (ndr_push_flags_fn_t) ndr_push_SimplePing,
+ (ndr_pull_flags_fn_t) ndr_pull_SimplePing,
+- (ndr_print_function_t) ndr_print_SimplePing,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -779,7 +779,7 @@ static const struct ndr_interface_call I
+ sizeof(struct ComplexPing),
+ (ndr_push_flags_fn_t) ndr_push_ComplexPing,
+ (ndr_pull_flags_fn_t) ndr_pull_ComplexPing,
+- (ndr_print_function_t) ndr_print_ComplexPing,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -788,7 +788,7 @@ static const struct ndr_interface_call I
+ sizeof(struct ServerAlive),
+ (ndr_push_flags_fn_t) ndr_push_ServerAlive,
+ (ndr_pull_flags_fn_t) ndr_pull_ServerAlive,
+- (ndr_print_function_t) ndr_print_ServerAlive,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -797,7 +797,7 @@ static const struct ndr_interface_call I
+ sizeof(struct ResolveOxid2),
+ (ndr_push_flags_fn_t) ndr_push_ResolveOxid2,
+ (ndr_pull_flags_fn_t) ndr_pull_ResolveOxid2,
+- (ndr_print_function_t) ndr_print_ResolveOxid2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -806,7 +806,7 @@ static const struct ndr_interface_call I
+ sizeof(struct ServerAlive2),
+ (ndr_push_flags_fn_t) ndr_push_ServerAlive2,
+ (ndr_pull_flags_fn_t) ndr_pull_ServerAlive2,
+- (ndr_print_function_t) ndr_print_ServerAlive2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_policyagent.c
++++ b/source3/librpc/gen_ndr/ndr_policyagent.c
+@@ -51,7 +51,7 @@ static const struct ndr_interface_call p
+ sizeof(struct policyagent_Dummy),
+ (ndr_push_flags_fn_t) ndr_push_policyagent_Dummy,
+ (ndr_pull_flags_fn_t) ndr_pull_policyagent_Dummy,
+- (ndr_print_function_t) ndr_print_policyagent_Dummy,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_preg.c
++++ b/source3/librpc/gen_ndr/ndr_preg.c
+@@ -204,7 +204,7 @@ static const struct ndr_interface_call p
+ sizeof(struct decode_preg_file),
+ (ndr_push_flags_fn_t) ndr_push_decode_preg_file,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_preg_file,
+- (ndr_print_function_t) ndr_print_decode_preg_file,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_remact.c
++++ b/source3/librpc/gen_ndr/ndr_remact.c
+@@ -373,7 +373,7 @@ static const struct ndr_interface_call I
+ sizeof(struct RemoteActivation),
+ (ndr_push_flags_fn_t) ndr_push_RemoteActivation,
+ (ndr_pull_flags_fn_t) ndr_pull_RemoteActivation,
+- (ndr_print_function_t) ndr_print_RemoteActivation,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_rot.c
++++ b/source3/librpc/gen_ndr/ndr_rot.c
+@@ -489,7 +489,7 @@ static const struct ndr_interface_call r
+ sizeof(struct rot_add),
+ (ndr_push_flags_fn_t) ndr_push_rot_add,
+ (ndr_pull_flags_fn_t) ndr_pull_rot_add,
+- (ndr_print_function_t) ndr_print_rot_add,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -498,7 +498,7 @@ static const struct ndr_interface_call r
+ sizeof(struct rot_remove),
+ (ndr_push_flags_fn_t) ndr_push_rot_remove,
+ (ndr_pull_flags_fn_t) ndr_pull_rot_remove,
+- (ndr_print_function_t) ndr_print_rot_remove,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -507,7 +507,7 @@ static const struct ndr_interface_call r
+ sizeof(struct rot_is_listed),
+ (ndr_push_flags_fn_t) ndr_push_rot_is_listed,
+ (ndr_pull_flags_fn_t) ndr_pull_rot_is_listed,
+- (ndr_print_function_t) ndr_print_rot_is_listed,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -516,7 +516,7 @@ static const struct ndr_interface_call r
+ sizeof(struct rot_get_interface_pointer),
+ (ndr_push_flags_fn_t) ndr_push_rot_get_interface_pointer,
+ (ndr_pull_flags_fn_t) ndr_pull_rot_get_interface_pointer,
+- (ndr_print_function_t) ndr_print_rot_get_interface_pointer,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -525,7 +525,7 @@ static const struct ndr_interface_call r
+ sizeof(struct rot_set_modification_time),
+ (ndr_push_flags_fn_t) ndr_push_rot_set_modification_time,
+ (ndr_pull_flags_fn_t) ndr_pull_rot_set_modification_time,
+- (ndr_print_function_t) ndr_print_rot_set_modification_time,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -534,7 +534,7 @@ static const struct ndr_interface_call r
+ sizeof(struct rot_get_modification_time),
+ (ndr_push_flags_fn_t) ndr_push_rot_get_modification_time,
+ (ndr_pull_flags_fn_t) ndr_pull_rot_get_modification_time,
+- (ndr_print_function_t) ndr_print_rot_get_modification_time,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -543,7 +543,7 @@ static const struct ndr_interface_call r
+ sizeof(struct rot_enum),
+ (ndr_push_flags_fn_t) ndr_push_rot_enum,
+ (ndr_pull_flags_fn_t) ndr_pull_rot_enum,
+- (ndr_print_function_t) ndr_print_rot_enum,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_samr.c
++++ b/source3/librpc/gen_ndr/ndr_samr.c
+@@ -12674,7 +12674,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_Connect),
+ (ndr_push_flags_fn_t) ndr_push_samr_Connect,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_Connect,
+- (ndr_print_function_t) ndr_print_samr_Connect,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12683,7 +12683,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_Close),
+ (ndr_push_flags_fn_t) ndr_push_samr_Close,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_Close,
+- (ndr_print_function_t) ndr_print_samr_Close,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12692,7 +12692,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_SetSecurity),
+ (ndr_push_flags_fn_t) ndr_push_samr_SetSecurity,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_SetSecurity,
+- (ndr_print_function_t) ndr_print_samr_SetSecurity,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12701,7 +12701,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_QuerySecurity),
+ (ndr_push_flags_fn_t) ndr_push_samr_QuerySecurity,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_QuerySecurity,
+- (ndr_print_function_t) ndr_print_samr_QuerySecurity,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12710,7 +12710,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_Shutdown),
+ (ndr_push_flags_fn_t) ndr_push_samr_Shutdown,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_Shutdown,
+- (ndr_print_function_t) ndr_print_samr_Shutdown,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12719,7 +12719,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_LookupDomain),
+ (ndr_push_flags_fn_t) ndr_push_samr_LookupDomain,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_LookupDomain,
+- (ndr_print_function_t) ndr_print_samr_LookupDomain,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12728,7 +12728,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_EnumDomains),
+ (ndr_push_flags_fn_t) ndr_push_samr_EnumDomains,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_EnumDomains,
+- (ndr_print_function_t) ndr_print_samr_EnumDomains,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12737,7 +12737,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_OpenDomain),
+ (ndr_push_flags_fn_t) ndr_push_samr_OpenDomain,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_OpenDomain,
+- (ndr_print_function_t) ndr_print_samr_OpenDomain,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12746,7 +12746,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_QueryDomainInfo),
+ (ndr_push_flags_fn_t) ndr_push_samr_QueryDomainInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_QueryDomainInfo,
+- (ndr_print_function_t) ndr_print_samr_QueryDomainInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12755,7 +12755,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_SetDomainInfo),
+ (ndr_push_flags_fn_t) ndr_push_samr_SetDomainInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_SetDomainInfo,
+- (ndr_print_function_t) ndr_print_samr_SetDomainInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12764,7 +12764,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_CreateDomainGroup),
+ (ndr_push_flags_fn_t) ndr_push_samr_CreateDomainGroup,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_CreateDomainGroup,
+- (ndr_print_function_t) ndr_print_samr_CreateDomainGroup,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12773,7 +12773,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_EnumDomainGroups),
+ (ndr_push_flags_fn_t) ndr_push_samr_EnumDomainGroups,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_EnumDomainGroups,
+- (ndr_print_function_t) ndr_print_samr_EnumDomainGroups,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12782,7 +12782,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_CreateUser),
+ (ndr_push_flags_fn_t) ndr_push_samr_CreateUser,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_CreateUser,
+- (ndr_print_function_t) ndr_print_samr_CreateUser,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12791,7 +12791,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_EnumDomainUsers),
+ (ndr_push_flags_fn_t) ndr_push_samr_EnumDomainUsers,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_EnumDomainUsers,
+- (ndr_print_function_t) ndr_print_samr_EnumDomainUsers,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12800,7 +12800,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_CreateDomAlias),
+ (ndr_push_flags_fn_t) ndr_push_samr_CreateDomAlias,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_CreateDomAlias,
+- (ndr_print_function_t) ndr_print_samr_CreateDomAlias,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12809,7 +12809,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_EnumDomainAliases),
+ (ndr_push_flags_fn_t) ndr_push_samr_EnumDomainAliases,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_EnumDomainAliases,
+- (ndr_print_function_t) ndr_print_samr_EnumDomainAliases,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12818,7 +12818,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_GetAliasMembership),
+ (ndr_push_flags_fn_t) ndr_push_samr_GetAliasMembership,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_GetAliasMembership,
+- (ndr_print_function_t) ndr_print_samr_GetAliasMembership,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12827,7 +12827,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_LookupNames),
+ (ndr_push_flags_fn_t) ndr_push_samr_LookupNames,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_LookupNames,
+- (ndr_print_function_t) ndr_print_samr_LookupNames,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12836,7 +12836,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_LookupRids),
+ (ndr_push_flags_fn_t) ndr_push_samr_LookupRids,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_LookupRids,
+- (ndr_print_function_t) ndr_print_samr_LookupRids,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12845,7 +12845,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_OpenGroup),
+ (ndr_push_flags_fn_t) ndr_push_samr_OpenGroup,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_OpenGroup,
+- (ndr_print_function_t) ndr_print_samr_OpenGroup,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12854,7 +12854,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_QueryGroupInfo),
+ (ndr_push_flags_fn_t) ndr_push_samr_QueryGroupInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_QueryGroupInfo,
+- (ndr_print_function_t) ndr_print_samr_QueryGroupInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12863,7 +12863,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_SetGroupInfo),
+ (ndr_push_flags_fn_t) ndr_push_samr_SetGroupInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_SetGroupInfo,
+- (ndr_print_function_t) ndr_print_samr_SetGroupInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12872,7 +12872,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_AddGroupMember),
+ (ndr_push_flags_fn_t) ndr_push_samr_AddGroupMember,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_AddGroupMember,
+- (ndr_print_function_t) ndr_print_samr_AddGroupMember,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12881,7 +12881,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_DeleteDomainGroup),
+ (ndr_push_flags_fn_t) ndr_push_samr_DeleteDomainGroup,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_DeleteDomainGroup,
+- (ndr_print_function_t) ndr_print_samr_DeleteDomainGroup,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12890,7 +12890,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_DeleteGroupMember),
+ (ndr_push_flags_fn_t) ndr_push_samr_DeleteGroupMember,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_DeleteGroupMember,
+- (ndr_print_function_t) ndr_print_samr_DeleteGroupMember,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12899,7 +12899,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_QueryGroupMember),
+ (ndr_push_flags_fn_t) ndr_push_samr_QueryGroupMember,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_QueryGroupMember,
+- (ndr_print_function_t) ndr_print_samr_QueryGroupMember,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12908,7 +12908,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_SetMemberAttributesOfGroup),
+ (ndr_push_flags_fn_t) ndr_push_samr_SetMemberAttributesOfGroup,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_SetMemberAttributesOfGroup,
+- (ndr_print_function_t) ndr_print_samr_SetMemberAttributesOfGroup,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12917,7 +12917,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_OpenAlias),
+ (ndr_push_flags_fn_t) ndr_push_samr_OpenAlias,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_OpenAlias,
+- (ndr_print_function_t) ndr_print_samr_OpenAlias,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12926,7 +12926,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_QueryAliasInfo),
+ (ndr_push_flags_fn_t) ndr_push_samr_QueryAliasInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_QueryAliasInfo,
+- (ndr_print_function_t) ndr_print_samr_QueryAliasInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12935,7 +12935,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_SetAliasInfo),
+ (ndr_push_flags_fn_t) ndr_push_samr_SetAliasInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_SetAliasInfo,
+- (ndr_print_function_t) ndr_print_samr_SetAliasInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12944,7 +12944,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_DeleteDomAlias),
+ (ndr_push_flags_fn_t) ndr_push_samr_DeleteDomAlias,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_DeleteDomAlias,
+- (ndr_print_function_t) ndr_print_samr_DeleteDomAlias,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12953,7 +12953,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_AddAliasMember),
+ (ndr_push_flags_fn_t) ndr_push_samr_AddAliasMember,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_AddAliasMember,
+- (ndr_print_function_t) ndr_print_samr_AddAliasMember,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12962,7 +12962,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_DeleteAliasMember),
+ (ndr_push_flags_fn_t) ndr_push_samr_DeleteAliasMember,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_DeleteAliasMember,
+- (ndr_print_function_t) ndr_print_samr_DeleteAliasMember,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12971,7 +12971,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_GetMembersInAlias),
+ (ndr_push_flags_fn_t) ndr_push_samr_GetMembersInAlias,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_GetMembersInAlias,
+- (ndr_print_function_t) ndr_print_samr_GetMembersInAlias,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12980,7 +12980,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_OpenUser),
+ (ndr_push_flags_fn_t) ndr_push_samr_OpenUser,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_OpenUser,
+- (ndr_print_function_t) ndr_print_samr_OpenUser,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12989,7 +12989,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_DeleteUser),
+ (ndr_push_flags_fn_t) ndr_push_samr_DeleteUser,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_DeleteUser,
+- (ndr_print_function_t) ndr_print_samr_DeleteUser,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12998,7 +12998,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_QueryUserInfo),
+ (ndr_push_flags_fn_t) ndr_push_samr_QueryUserInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_QueryUserInfo,
+- (ndr_print_function_t) ndr_print_samr_QueryUserInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13007,7 +13007,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_SetUserInfo),
+ (ndr_push_flags_fn_t) ndr_push_samr_SetUserInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_SetUserInfo,
+- (ndr_print_function_t) ndr_print_samr_SetUserInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13016,7 +13016,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_ChangePasswordUser),
+ (ndr_push_flags_fn_t) ndr_push_samr_ChangePasswordUser,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_ChangePasswordUser,
+- (ndr_print_function_t) ndr_print_samr_ChangePasswordUser,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13025,7 +13025,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_GetGroupsForUser),
+ (ndr_push_flags_fn_t) ndr_push_samr_GetGroupsForUser,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_GetGroupsForUser,
+- (ndr_print_function_t) ndr_print_samr_GetGroupsForUser,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13034,7 +13034,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_QueryDisplayInfo),
+ (ndr_push_flags_fn_t) ndr_push_samr_QueryDisplayInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_QueryDisplayInfo,
+- (ndr_print_function_t) ndr_print_samr_QueryDisplayInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13043,7 +13043,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_GetDisplayEnumerationIndex),
+ (ndr_push_flags_fn_t) ndr_push_samr_GetDisplayEnumerationIndex,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_GetDisplayEnumerationIndex,
+- (ndr_print_function_t) ndr_print_samr_GetDisplayEnumerationIndex,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13052,7 +13052,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_TestPrivateFunctionsDomain),
+ (ndr_push_flags_fn_t) ndr_push_samr_TestPrivateFunctionsDomain,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_TestPrivateFunctionsDomain,
+- (ndr_print_function_t) ndr_print_samr_TestPrivateFunctionsDomain,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13061,7 +13061,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_TestPrivateFunctionsUser),
+ (ndr_push_flags_fn_t) ndr_push_samr_TestPrivateFunctionsUser,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_TestPrivateFunctionsUser,
+- (ndr_print_function_t) ndr_print_samr_TestPrivateFunctionsUser,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13070,7 +13070,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_GetUserPwInfo),
+ (ndr_push_flags_fn_t) ndr_push_samr_GetUserPwInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_GetUserPwInfo,
+- (ndr_print_function_t) ndr_print_samr_GetUserPwInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13079,7 +13079,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_RemoveMemberFromForeignDomain),
+ (ndr_push_flags_fn_t) ndr_push_samr_RemoveMemberFromForeignDomain,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_RemoveMemberFromForeignDomain,
+- (ndr_print_function_t) ndr_print_samr_RemoveMemberFromForeignDomain,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13088,7 +13088,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_QueryDomainInfo2),
+ (ndr_push_flags_fn_t) ndr_push_samr_QueryDomainInfo2,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_QueryDomainInfo2,
+- (ndr_print_function_t) ndr_print_samr_QueryDomainInfo2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13097,7 +13097,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_QueryUserInfo2),
+ (ndr_push_flags_fn_t) ndr_push_samr_QueryUserInfo2,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_QueryUserInfo2,
+- (ndr_print_function_t) ndr_print_samr_QueryUserInfo2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13106,7 +13106,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_QueryDisplayInfo2),
+ (ndr_push_flags_fn_t) ndr_push_samr_QueryDisplayInfo2,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_QueryDisplayInfo2,
+- (ndr_print_function_t) ndr_print_samr_QueryDisplayInfo2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13115,7 +13115,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_GetDisplayEnumerationIndex2),
+ (ndr_push_flags_fn_t) ndr_push_samr_GetDisplayEnumerationIndex2,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_GetDisplayEnumerationIndex2,
+- (ndr_print_function_t) ndr_print_samr_GetDisplayEnumerationIndex2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13124,7 +13124,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_CreateUser2),
+ (ndr_push_flags_fn_t) ndr_push_samr_CreateUser2,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_CreateUser2,
+- (ndr_print_function_t) ndr_print_samr_CreateUser2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13133,7 +13133,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_QueryDisplayInfo3),
+ (ndr_push_flags_fn_t) ndr_push_samr_QueryDisplayInfo3,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_QueryDisplayInfo3,
+- (ndr_print_function_t) ndr_print_samr_QueryDisplayInfo3,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13142,7 +13142,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_AddMultipleMembersToAlias),
+ (ndr_push_flags_fn_t) ndr_push_samr_AddMultipleMembersToAlias,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_AddMultipleMembersToAlias,
+- (ndr_print_function_t) ndr_print_samr_AddMultipleMembersToAlias,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13151,7 +13151,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_RemoveMultipleMembersFromAlias),
+ (ndr_push_flags_fn_t) ndr_push_samr_RemoveMultipleMembersFromAlias,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_RemoveMultipleMembersFromAlias,
+- (ndr_print_function_t) ndr_print_samr_RemoveMultipleMembersFromAlias,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13160,7 +13160,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_OemChangePasswordUser2),
+ (ndr_push_flags_fn_t) ndr_push_samr_OemChangePasswordUser2,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_OemChangePasswordUser2,
+- (ndr_print_function_t) ndr_print_samr_OemChangePasswordUser2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13169,7 +13169,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_ChangePasswordUser2),
+ (ndr_push_flags_fn_t) ndr_push_samr_ChangePasswordUser2,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_ChangePasswordUser2,
+- (ndr_print_function_t) ndr_print_samr_ChangePasswordUser2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13178,7 +13178,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_GetDomPwInfo),
+ (ndr_push_flags_fn_t) ndr_push_samr_GetDomPwInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_GetDomPwInfo,
+- (ndr_print_function_t) ndr_print_samr_GetDomPwInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13187,7 +13187,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_Connect2),
+ (ndr_push_flags_fn_t) ndr_push_samr_Connect2,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_Connect2,
+- (ndr_print_function_t) ndr_print_samr_Connect2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13196,7 +13196,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_SetUserInfo2),
+ (ndr_push_flags_fn_t) ndr_push_samr_SetUserInfo2,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_SetUserInfo2,
+- (ndr_print_function_t) ndr_print_samr_SetUserInfo2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13205,7 +13205,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_SetBootKeyInformation),
+ (ndr_push_flags_fn_t) ndr_push_samr_SetBootKeyInformation,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_SetBootKeyInformation,
+- (ndr_print_function_t) ndr_print_samr_SetBootKeyInformation,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13214,7 +13214,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_GetBootKeyInformation),
+ (ndr_push_flags_fn_t) ndr_push_samr_GetBootKeyInformation,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_GetBootKeyInformation,
+- (ndr_print_function_t) ndr_print_samr_GetBootKeyInformation,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13223,7 +13223,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_Connect3),
+ (ndr_push_flags_fn_t) ndr_push_samr_Connect3,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_Connect3,
+- (ndr_print_function_t) ndr_print_samr_Connect3,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13232,7 +13232,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_Connect4),
+ (ndr_push_flags_fn_t) ndr_push_samr_Connect4,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_Connect4,
+- (ndr_print_function_t) ndr_print_samr_Connect4,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13241,7 +13241,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_ChangePasswordUser3),
+ (ndr_push_flags_fn_t) ndr_push_samr_ChangePasswordUser3,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_ChangePasswordUser3,
+- (ndr_print_function_t) ndr_print_samr_ChangePasswordUser3,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13250,7 +13250,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_Connect5),
+ (ndr_push_flags_fn_t) ndr_push_samr_Connect5,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_Connect5,
+- (ndr_print_function_t) ndr_print_samr_Connect5,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13259,7 +13259,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_RidToSid),
+ (ndr_push_flags_fn_t) ndr_push_samr_RidToSid,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_RidToSid,
+- (ndr_print_function_t) ndr_print_samr_RidToSid,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13268,7 +13268,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_SetDsrmPassword),
+ (ndr_push_flags_fn_t) ndr_push_samr_SetDsrmPassword,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_SetDsrmPassword,
+- (ndr_print_function_t) ndr_print_samr_SetDsrmPassword,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13277,7 +13277,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_ValidatePassword),
+ (ndr_push_flags_fn_t) ndr_push_samr_ValidatePassword,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_ValidatePassword,
+- (ndr_print_function_t) ndr_print_samr_ValidatePassword,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_scerpc.c
++++ b/source3/librpc/gen_ndr/ndr_scerpc.c
+@@ -51,7 +51,7 @@ static const struct ndr_interface_call s
+ sizeof(struct scerpc_Unknown0),
+ (ndr_push_flags_fn_t) ndr_push_scerpc_Unknown0,
+ (ndr_pull_flags_fn_t) ndr_pull_scerpc_Unknown0,
+- (ndr_print_function_t) ndr_print_scerpc_Unknown0,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_spoolss.c
++++ b/source3/librpc/gen_ndr/ndr_spoolss.c
+@@ -32660,7 +32660,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_EnumPrinters),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_EnumPrinters,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_EnumPrinters,
+- (ndr_print_function_t) ndr_print_spoolss_EnumPrinters,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32669,7 +32669,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_OpenPrinter),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_OpenPrinter,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_OpenPrinter,
+- (ndr_print_function_t) ndr_print_spoolss_OpenPrinter,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32678,7 +32678,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_SetJob),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_SetJob,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_SetJob,
+- (ndr_print_function_t) ndr_print_spoolss_SetJob,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32687,7 +32687,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_GetJob),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_GetJob,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_GetJob,
+- (ndr_print_function_t) ndr_print_spoolss_GetJob,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32696,7 +32696,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_EnumJobs),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_EnumJobs,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_EnumJobs,
+- (ndr_print_function_t) ndr_print_spoolss_EnumJobs,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32705,7 +32705,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_AddPrinter),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_AddPrinter,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_AddPrinter,
+- (ndr_print_function_t) ndr_print_spoolss_AddPrinter,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32714,7 +32714,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_DeletePrinter),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_DeletePrinter,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_DeletePrinter,
+- (ndr_print_function_t) ndr_print_spoolss_DeletePrinter,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32723,7 +32723,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_SetPrinter),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_SetPrinter,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_SetPrinter,
+- (ndr_print_function_t) ndr_print_spoolss_SetPrinter,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32732,7 +32732,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_GetPrinter),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_GetPrinter,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_GetPrinter,
+- (ndr_print_function_t) ndr_print_spoolss_GetPrinter,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32741,7 +32741,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_AddPrinterDriver),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_AddPrinterDriver,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_AddPrinterDriver,
+- (ndr_print_function_t) ndr_print_spoolss_AddPrinterDriver,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32750,7 +32750,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_EnumPrinterDrivers),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_EnumPrinterDrivers,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_EnumPrinterDrivers,
+- (ndr_print_function_t) ndr_print_spoolss_EnumPrinterDrivers,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32759,7 +32759,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_GetPrinterDriver),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_GetPrinterDriver,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_GetPrinterDriver,
+- (ndr_print_function_t) ndr_print_spoolss_GetPrinterDriver,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32768,7 +32768,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_GetPrinterDriverDirectory),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_GetPrinterDriverDirectory,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_GetPrinterDriverDirectory,
+- (ndr_print_function_t) ndr_print_spoolss_GetPrinterDriverDirectory,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32777,7 +32777,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_DeletePrinterDriver),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_DeletePrinterDriver,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_DeletePrinterDriver,
+- (ndr_print_function_t) ndr_print_spoolss_DeletePrinterDriver,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32786,7 +32786,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_AddPrintProcessor),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_AddPrintProcessor,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_AddPrintProcessor,
+- (ndr_print_function_t) ndr_print_spoolss_AddPrintProcessor,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32795,7 +32795,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_EnumPrintProcessors),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_EnumPrintProcessors,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_EnumPrintProcessors,
+- (ndr_print_function_t) ndr_print_spoolss_EnumPrintProcessors,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32804,7 +32804,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_GetPrintProcessorDirectory),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_GetPrintProcessorDirectory,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_GetPrintProcessorDirectory,
+- (ndr_print_function_t) ndr_print_spoolss_GetPrintProcessorDirectory,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32813,7 +32813,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_StartDocPrinter),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_StartDocPrinter,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_StartDocPrinter,
+- (ndr_print_function_t) ndr_print_spoolss_StartDocPrinter,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32822,7 +32822,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_StartPagePrinter),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_StartPagePrinter,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_StartPagePrinter,
+- (ndr_print_function_t) ndr_print_spoolss_StartPagePrinter,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32831,7 +32831,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_WritePrinter),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_WritePrinter,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_WritePrinter,
+- (ndr_print_function_t) ndr_print_spoolss_WritePrinter,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32840,7 +32840,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_EndPagePrinter),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_EndPagePrinter,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_EndPagePrinter,
+- (ndr_print_function_t) ndr_print_spoolss_EndPagePrinter,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32849,7 +32849,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_AbortPrinter),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_AbortPrinter,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_AbortPrinter,
+- (ndr_print_function_t) ndr_print_spoolss_AbortPrinter,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32858,7 +32858,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_ReadPrinter),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_ReadPrinter,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_ReadPrinter,
+- (ndr_print_function_t) ndr_print_spoolss_ReadPrinter,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32867,7 +32867,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_EndDocPrinter),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_EndDocPrinter,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_EndDocPrinter,
+- (ndr_print_function_t) ndr_print_spoolss_EndDocPrinter,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32876,7 +32876,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_AddJob),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_AddJob,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_AddJob,
+- (ndr_print_function_t) ndr_print_spoolss_AddJob,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32885,7 +32885,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_ScheduleJob),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_ScheduleJob,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_ScheduleJob,
+- (ndr_print_function_t) ndr_print_spoolss_ScheduleJob,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32894,7 +32894,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_GetPrinterData),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_GetPrinterData,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_GetPrinterData,
+- (ndr_print_function_t) ndr_print_spoolss_GetPrinterData,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32903,7 +32903,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_SetPrinterData),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_SetPrinterData,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_SetPrinterData,
+- (ndr_print_function_t) ndr_print_spoolss_SetPrinterData,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32912,7 +32912,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_WaitForPrinterChange),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_WaitForPrinterChange,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_WaitForPrinterChange,
+- (ndr_print_function_t) ndr_print_spoolss_WaitForPrinterChange,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32921,7 +32921,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_ClosePrinter),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_ClosePrinter,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_ClosePrinter,
+- (ndr_print_function_t) ndr_print_spoolss_ClosePrinter,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32930,7 +32930,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_AddForm),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_AddForm,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_AddForm,
+- (ndr_print_function_t) ndr_print_spoolss_AddForm,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32939,7 +32939,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_DeleteForm),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_DeleteForm,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_DeleteForm,
+- (ndr_print_function_t) ndr_print_spoolss_DeleteForm,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32948,7 +32948,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_GetForm),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_GetForm,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_GetForm,
+- (ndr_print_function_t) ndr_print_spoolss_GetForm,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32957,7 +32957,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_SetForm),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_SetForm,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_SetForm,
+- (ndr_print_function_t) ndr_print_spoolss_SetForm,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32966,7 +32966,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_EnumForms),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_EnumForms,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_EnumForms,
+- (ndr_print_function_t) ndr_print_spoolss_EnumForms,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32975,7 +32975,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_EnumPorts),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_EnumPorts,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_EnumPorts,
+- (ndr_print_function_t) ndr_print_spoolss_EnumPorts,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32984,7 +32984,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_EnumMonitors),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_EnumMonitors,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_EnumMonitors,
+- (ndr_print_function_t) ndr_print_spoolss_EnumMonitors,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32993,7 +32993,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_AddPort),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_AddPort,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_AddPort,
+- (ndr_print_function_t) ndr_print_spoolss_AddPort,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33002,7 +33002,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_ConfigurePort),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_ConfigurePort,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_ConfigurePort,
+- (ndr_print_function_t) ndr_print_spoolss_ConfigurePort,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33011,7 +33011,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_DeletePort),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_DeletePort,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_DeletePort,
+- (ndr_print_function_t) ndr_print_spoolss_DeletePort,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33020,7 +33020,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_CreatePrinterIC),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_CreatePrinterIC,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_CreatePrinterIC,
+- (ndr_print_function_t) ndr_print_spoolss_CreatePrinterIC,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33029,7 +33029,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_PlayGDIScriptOnPrinterIC),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_PlayGDIScriptOnPrinterIC,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_PlayGDIScriptOnPrinterIC,
+- (ndr_print_function_t) ndr_print_spoolss_PlayGDIScriptOnPrinterIC,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33038,7 +33038,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_DeletePrinterIC),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_DeletePrinterIC,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_DeletePrinterIC,
+- (ndr_print_function_t) ndr_print_spoolss_DeletePrinterIC,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33047,7 +33047,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_AddPrinterConnection),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_AddPrinterConnection,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_AddPrinterConnection,
+- (ndr_print_function_t) ndr_print_spoolss_AddPrinterConnection,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33056,7 +33056,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_DeletePrinterConnection),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_DeletePrinterConnection,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_DeletePrinterConnection,
+- (ndr_print_function_t) ndr_print_spoolss_DeletePrinterConnection,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33065,7 +33065,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_PrinterMessageBox),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_PrinterMessageBox,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_PrinterMessageBox,
+- (ndr_print_function_t) ndr_print_spoolss_PrinterMessageBox,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33074,7 +33074,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_AddMonitor),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_AddMonitor,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_AddMonitor,
+- (ndr_print_function_t) ndr_print_spoolss_AddMonitor,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33083,7 +33083,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_DeleteMonitor),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_DeleteMonitor,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_DeleteMonitor,
+- (ndr_print_function_t) ndr_print_spoolss_DeleteMonitor,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33092,7 +33092,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_DeletePrintProcessor),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_DeletePrintProcessor,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_DeletePrintProcessor,
+- (ndr_print_function_t) ndr_print_spoolss_DeletePrintProcessor,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33101,7 +33101,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_AddPrintProvidor),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_AddPrintProvidor,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_AddPrintProvidor,
+- (ndr_print_function_t) ndr_print_spoolss_AddPrintProvidor,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33110,7 +33110,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_DeletePrintProvidor),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_DeletePrintProvidor,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_DeletePrintProvidor,
+- (ndr_print_function_t) ndr_print_spoolss_DeletePrintProvidor,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33119,7 +33119,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_EnumPrintProcDataTypes),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_EnumPrintProcDataTypes,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_EnumPrintProcDataTypes,
+- (ndr_print_function_t) ndr_print_spoolss_EnumPrintProcDataTypes,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33128,7 +33128,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_ResetPrinter),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_ResetPrinter,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_ResetPrinter,
+- (ndr_print_function_t) ndr_print_spoolss_ResetPrinter,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33137,7 +33137,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_GetPrinterDriver2),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_GetPrinterDriver2,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_GetPrinterDriver2,
+- (ndr_print_function_t) ndr_print_spoolss_GetPrinterDriver2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33146,7 +33146,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_FindFirstPrinterChangeNotification),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_FindFirstPrinterChangeNotification,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_FindFirstPrinterChangeNotification,
+- (ndr_print_function_t) ndr_print_spoolss_FindFirstPrinterChangeNotification,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33155,7 +33155,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_FindNextPrinterChangeNotification),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_FindNextPrinterChangeNotification,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_FindNextPrinterChangeNotification,
+- (ndr_print_function_t) ndr_print_spoolss_FindNextPrinterChangeNotification,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33164,7 +33164,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_FindClosePrinterNotify),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_FindClosePrinterNotify,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_FindClosePrinterNotify,
+- (ndr_print_function_t) ndr_print_spoolss_FindClosePrinterNotify,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33173,7 +33173,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_RouterFindFirstPrinterChangeNotificationOld),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_RouterFindFirstPrinterChangeNotificationOld,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_RouterFindFirstPrinterChangeNotificationOld,
+- (ndr_print_function_t) ndr_print_spoolss_RouterFindFirstPrinterChangeNotificationOld,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33182,7 +33182,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_ReplyOpenPrinter),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_ReplyOpenPrinter,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_ReplyOpenPrinter,
+- (ndr_print_function_t) ndr_print_spoolss_ReplyOpenPrinter,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33191,7 +33191,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_RouterReplyPrinter),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_RouterReplyPrinter,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_RouterReplyPrinter,
+- (ndr_print_function_t) ndr_print_spoolss_RouterReplyPrinter,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33200,7 +33200,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_ReplyClosePrinter),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_ReplyClosePrinter,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_ReplyClosePrinter,
+- (ndr_print_function_t) ndr_print_spoolss_ReplyClosePrinter,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33209,7 +33209,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_AddPortEx),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_AddPortEx,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_AddPortEx,
+- (ndr_print_function_t) ndr_print_spoolss_AddPortEx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33218,7 +33218,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_RouterFindFirstPrinterChangeNotification),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_RouterFindFirstPrinterChangeNotification,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_RouterFindFirstPrinterChangeNotification,
+- (ndr_print_function_t) ndr_print_spoolss_RouterFindFirstPrinterChangeNotification,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33227,7 +33227,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_SpoolerInit),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_SpoolerInit,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_SpoolerInit,
+- (ndr_print_function_t) ndr_print_spoolss_SpoolerInit,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33236,7 +33236,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_ResetPrinterEx),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_ResetPrinterEx,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_ResetPrinterEx,
+- (ndr_print_function_t) ndr_print_spoolss_ResetPrinterEx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33245,7 +33245,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_RemoteFindFirstPrinterChangeNotifyEx),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_RemoteFindFirstPrinterChangeNotifyEx,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_RemoteFindFirstPrinterChangeNotifyEx,
+- (ndr_print_function_t) ndr_print_spoolss_RemoteFindFirstPrinterChangeNotifyEx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33254,7 +33254,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_RouterReplyPrinterEx),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_RouterReplyPrinterEx,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_RouterReplyPrinterEx,
+- (ndr_print_function_t) ndr_print_spoolss_RouterReplyPrinterEx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33263,7 +33263,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_RouterRefreshPrinterChangeNotify),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_RouterRefreshPrinterChangeNotify,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_RouterRefreshPrinterChangeNotify,
+- (ndr_print_function_t) ndr_print_spoolss_RouterRefreshPrinterChangeNotify,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33272,7 +33272,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_44),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_44,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_44,
+- (ndr_print_function_t) ndr_print_spoolss_44,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33281,7 +33281,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_OpenPrinterEx),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_OpenPrinterEx,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_OpenPrinterEx,
+- (ndr_print_function_t) ndr_print_spoolss_OpenPrinterEx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33290,7 +33290,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_AddPrinterEx),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_AddPrinterEx,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_AddPrinterEx,
+- (ndr_print_function_t) ndr_print_spoolss_AddPrinterEx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33299,7 +33299,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_SetPort),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_SetPort,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_SetPort,
+- (ndr_print_function_t) ndr_print_spoolss_SetPort,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33308,7 +33308,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_EnumPrinterData),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_EnumPrinterData,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_EnumPrinterData,
+- (ndr_print_function_t) ndr_print_spoolss_EnumPrinterData,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33317,7 +33317,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_DeletePrinterData),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_DeletePrinterData,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_DeletePrinterData,
+- (ndr_print_function_t) ndr_print_spoolss_DeletePrinterData,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33326,7 +33326,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_4a),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_4a,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_4a,
+- (ndr_print_function_t) ndr_print_spoolss_4a,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33335,7 +33335,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_4b),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_4b,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_4b,
+- (ndr_print_function_t) ndr_print_spoolss_4b,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33344,7 +33344,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_4c),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_4c,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_4c,
+- (ndr_print_function_t) ndr_print_spoolss_4c,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33353,7 +33353,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_SetPrinterDataEx),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_SetPrinterDataEx,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_SetPrinterDataEx,
+- (ndr_print_function_t) ndr_print_spoolss_SetPrinterDataEx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33362,7 +33362,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_GetPrinterDataEx),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_GetPrinterDataEx,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_GetPrinterDataEx,
+- (ndr_print_function_t) ndr_print_spoolss_GetPrinterDataEx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33371,7 +33371,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_EnumPrinterDataEx),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_EnumPrinterDataEx,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_EnumPrinterDataEx,
+- (ndr_print_function_t) ndr_print_spoolss_EnumPrinterDataEx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33380,7 +33380,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_EnumPrinterKey),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_EnumPrinterKey,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_EnumPrinterKey,
+- (ndr_print_function_t) ndr_print_spoolss_EnumPrinterKey,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33389,7 +33389,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_DeletePrinterDataEx),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_DeletePrinterDataEx,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_DeletePrinterDataEx,
+- (ndr_print_function_t) ndr_print_spoolss_DeletePrinterDataEx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33398,7 +33398,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_DeletePrinterKey),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_DeletePrinterKey,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_DeletePrinterKey,
+- (ndr_print_function_t) ndr_print_spoolss_DeletePrinterKey,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33407,7 +33407,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_53),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_53,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_53,
+- (ndr_print_function_t) ndr_print_spoolss_53,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33416,7 +33416,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_DeletePrinterDriverEx),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_DeletePrinterDriverEx,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_DeletePrinterDriverEx,
+- (ndr_print_function_t) ndr_print_spoolss_DeletePrinterDriverEx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33425,7 +33425,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_AddPerMachineConnection),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_AddPerMachineConnection,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_AddPerMachineConnection,
+- (ndr_print_function_t) ndr_print_spoolss_AddPerMachineConnection,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33434,7 +33434,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_DeletePerMachineConnection),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_DeletePerMachineConnection,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_DeletePerMachineConnection,
+- (ndr_print_function_t) ndr_print_spoolss_DeletePerMachineConnection,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33443,7 +33443,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_EnumPerMachineConnections),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_EnumPerMachineConnections,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_EnumPerMachineConnections,
+- (ndr_print_function_t) ndr_print_spoolss_EnumPerMachineConnections,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33452,7 +33452,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_XcvData),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_XcvData,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_XcvData,
+- (ndr_print_function_t) ndr_print_spoolss_XcvData,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33461,7 +33461,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_AddPrinterDriverEx),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_AddPrinterDriverEx,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_AddPrinterDriverEx,
+- (ndr_print_function_t) ndr_print_spoolss_AddPrinterDriverEx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33470,7 +33470,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_5a),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_5a,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_5a,
+- (ndr_print_function_t) ndr_print_spoolss_5a,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33479,7 +33479,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_5b),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_5b,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_5b,
+- (ndr_print_function_t) ndr_print_spoolss_5b,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33488,7 +33488,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_5c),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_5c,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_5c,
+- (ndr_print_function_t) ndr_print_spoolss_5c,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33497,7 +33497,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_5d),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_5d,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_5d,
+- (ndr_print_function_t) ndr_print_spoolss_5d,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33506,7 +33506,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_5e),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_5e,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_5e,
+- (ndr_print_function_t) ndr_print_spoolss_5e,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33515,7 +33515,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_5f),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_5f,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_5f,
+- (ndr_print_function_t) ndr_print_spoolss_5f,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33524,7 +33524,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_60),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_60,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_60,
+- (ndr_print_function_t) ndr_print_spoolss_60,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33533,7 +33533,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_61),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_61,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_61,
+- (ndr_print_function_t) ndr_print_spoolss_61,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33542,7 +33542,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_62),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_62,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_62,
+- (ndr_print_function_t) ndr_print_spoolss_62,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33551,7 +33551,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_63),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_63,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_63,
+- (ndr_print_function_t) ndr_print_spoolss_63,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33560,7 +33560,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_64),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_64,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_64,
+- (ndr_print_function_t) ndr_print_spoolss_64,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33569,7 +33569,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_65),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_65,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_65,
+- (ndr_print_function_t) ndr_print_spoolss_65,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33578,7 +33578,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_GetCorePrinterDrivers),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_GetCorePrinterDrivers,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_GetCorePrinterDrivers,
+- (ndr_print_function_t) ndr_print_spoolss_GetCorePrinterDrivers,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33587,7 +33587,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_67),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_67,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_67,
+- (ndr_print_function_t) ndr_print_spoolss_67,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33596,7 +33596,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_GetPrinterDriverPackagePath),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_GetPrinterDriverPackagePath,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_GetPrinterDriverPackagePath,
+- (ndr_print_function_t) ndr_print_spoolss_GetPrinterDriverPackagePath,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33605,7 +33605,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_69),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_69,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_69,
+- (ndr_print_function_t) ndr_print_spoolss_69,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33614,7 +33614,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_6a),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_6a,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_6a,
+- (ndr_print_function_t) ndr_print_spoolss_6a,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33623,7 +33623,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_6b),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_6b,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_6b,
+- (ndr_print_function_t) ndr_print_spoolss_6b,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33632,7 +33632,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_6c),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_6c,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_6c,
+- (ndr_print_function_t) ndr_print_spoolss_6c,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33641,7 +33641,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_6d),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_6d,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_6d,
+- (ndr_print_function_t) ndr_print_spoolss_6d,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_srvsvc.c
++++ b/source3/librpc/gen_ndr/ndr_srvsvc.c
+@@ -20229,7 +20229,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetCharDevEnum),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetCharDevEnum,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetCharDevEnum,
+- (ndr_print_function_t) ndr_print_srvsvc_NetCharDevEnum,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20238,7 +20238,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetCharDevGetInfo),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetCharDevGetInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetCharDevGetInfo,
+- (ndr_print_function_t) ndr_print_srvsvc_NetCharDevGetInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20247,7 +20247,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetCharDevControl),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetCharDevControl,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetCharDevControl,
+- (ndr_print_function_t) ndr_print_srvsvc_NetCharDevControl,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20256,7 +20256,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetCharDevQEnum),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetCharDevQEnum,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetCharDevQEnum,
+- (ndr_print_function_t) ndr_print_srvsvc_NetCharDevQEnum,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20265,7 +20265,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetCharDevQGetInfo),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetCharDevQGetInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetCharDevQGetInfo,
+- (ndr_print_function_t) ndr_print_srvsvc_NetCharDevQGetInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20274,7 +20274,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetCharDevQSetInfo),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetCharDevQSetInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetCharDevQSetInfo,
+- (ndr_print_function_t) ndr_print_srvsvc_NetCharDevQSetInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20283,7 +20283,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetCharDevQPurge),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetCharDevQPurge,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetCharDevQPurge,
+- (ndr_print_function_t) ndr_print_srvsvc_NetCharDevQPurge,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20292,7 +20292,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetCharDevQPurgeSelf),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetCharDevQPurgeSelf,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetCharDevQPurgeSelf,
+- (ndr_print_function_t) ndr_print_srvsvc_NetCharDevQPurgeSelf,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20301,7 +20301,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetConnEnum),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetConnEnum,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetConnEnum,
+- (ndr_print_function_t) ndr_print_srvsvc_NetConnEnum,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20310,7 +20310,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetFileEnum),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetFileEnum,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetFileEnum,
+- (ndr_print_function_t) ndr_print_srvsvc_NetFileEnum,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20319,7 +20319,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetFileGetInfo),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetFileGetInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetFileGetInfo,
+- (ndr_print_function_t) ndr_print_srvsvc_NetFileGetInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20328,7 +20328,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetFileClose),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetFileClose,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetFileClose,
+- (ndr_print_function_t) ndr_print_srvsvc_NetFileClose,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20337,7 +20337,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetSessEnum),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetSessEnum,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetSessEnum,
+- (ndr_print_function_t) ndr_print_srvsvc_NetSessEnum,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20346,7 +20346,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetSessDel),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetSessDel,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetSessDel,
+- (ndr_print_function_t) ndr_print_srvsvc_NetSessDel,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20355,7 +20355,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetShareAdd),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetShareAdd,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetShareAdd,
+- (ndr_print_function_t) ndr_print_srvsvc_NetShareAdd,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20364,7 +20364,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetShareEnumAll),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetShareEnumAll,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetShareEnumAll,
+- (ndr_print_function_t) ndr_print_srvsvc_NetShareEnumAll,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20373,7 +20373,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetShareGetInfo),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetShareGetInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetShareGetInfo,
+- (ndr_print_function_t) ndr_print_srvsvc_NetShareGetInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20382,7 +20382,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetShareSetInfo),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetShareSetInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetShareSetInfo,
+- (ndr_print_function_t) ndr_print_srvsvc_NetShareSetInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20391,7 +20391,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetShareDel),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetShareDel,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetShareDel,
+- (ndr_print_function_t) ndr_print_srvsvc_NetShareDel,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20400,7 +20400,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetShareDelSticky),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetShareDelSticky,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetShareDelSticky,
+- (ndr_print_function_t) ndr_print_srvsvc_NetShareDelSticky,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20409,7 +20409,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetShareCheck),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetShareCheck,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetShareCheck,
+- (ndr_print_function_t) ndr_print_srvsvc_NetShareCheck,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20418,7 +20418,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetSrvGetInfo),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetSrvGetInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetSrvGetInfo,
+- (ndr_print_function_t) ndr_print_srvsvc_NetSrvGetInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20427,7 +20427,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetSrvSetInfo),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetSrvSetInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetSrvSetInfo,
+- (ndr_print_function_t) ndr_print_srvsvc_NetSrvSetInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20436,7 +20436,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetDiskEnum),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetDiskEnum,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetDiskEnum,
+- (ndr_print_function_t) ndr_print_srvsvc_NetDiskEnum,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20445,7 +20445,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetServerStatisticsGet),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetServerStatisticsGet,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetServerStatisticsGet,
+- (ndr_print_function_t) ndr_print_srvsvc_NetServerStatisticsGet,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20454,7 +20454,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetTransportAdd),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetTransportAdd,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetTransportAdd,
+- (ndr_print_function_t) ndr_print_srvsvc_NetTransportAdd,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20463,7 +20463,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetTransportEnum),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetTransportEnum,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetTransportEnum,
+- (ndr_print_function_t) ndr_print_srvsvc_NetTransportEnum,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20472,7 +20472,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetTransportDel),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetTransportDel,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetTransportDel,
+- (ndr_print_function_t) ndr_print_srvsvc_NetTransportDel,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20481,7 +20481,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetRemoteTOD),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetRemoteTOD,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetRemoteTOD,
+- (ndr_print_function_t) ndr_print_srvsvc_NetRemoteTOD,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20490,7 +20490,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetSetServiceBits),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetSetServiceBits,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetSetServiceBits,
+- (ndr_print_function_t) ndr_print_srvsvc_NetSetServiceBits,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20499,7 +20499,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetPathType),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetPathType,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetPathType,
+- (ndr_print_function_t) ndr_print_srvsvc_NetPathType,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20508,7 +20508,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetPathCanonicalize),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetPathCanonicalize,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetPathCanonicalize,
+- (ndr_print_function_t) ndr_print_srvsvc_NetPathCanonicalize,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20517,7 +20517,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetPathCompare),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetPathCompare,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetPathCompare,
+- (ndr_print_function_t) ndr_print_srvsvc_NetPathCompare,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20526,7 +20526,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetNameValidate),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetNameValidate,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetNameValidate,
+- (ndr_print_function_t) ndr_print_srvsvc_NetNameValidate,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20535,7 +20535,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NETRPRNAMECANONICALIZE),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NETRPRNAMECANONICALIZE,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NETRPRNAMECANONICALIZE,
+- (ndr_print_function_t) ndr_print_srvsvc_NETRPRNAMECANONICALIZE,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20544,7 +20544,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetPRNameCompare),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetPRNameCompare,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetPRNameCompare,
+- (ndr_print_function_t) ndr_print_srvsvc_NetPRNameCompare,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20553,7 +20553,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetShareEnum),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetShareEnum,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetShareEnum,
+- (ndr_print_function_t) ndr_print_srvsvc_NetShareEnum,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20562,7 +20562,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetShareDelStart),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetShareDelStart,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetShareDelStart,
+- (ndr_print_function_t) ndr_print_srvsvc_NetShareDelStart,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20571,7 +20571,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetShareDelCommit),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetShareDelCommit,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetShareDelCommit,
+- (ndr_print_function_t) ndr_print_srvsvc_NetShareDelCommit,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20580,7 +20580,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetGetFileSecurity),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetGetFileSecurity,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetGetFileSecurity,
+- (ndr_print_function_t) ndr_print_srvsvc_NetGetFileSecurity,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20589,7 +20589,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetSetFileSecurity),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetSetFileSecurity,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetSetFileSecurity,
+- (ndr_print_function_t) ndr_print_srvsvc_NetSetFileSecurity,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20598,7 +20598,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetServerTransportAddEx),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetServerTransportAddEx,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetServerTransportAddEx,
+- (ndr_print_function_t) ndr_print_srvsvc_NetServerTransportAddEx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20607,7 +20607,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetServerSetServiceBitsEx),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetServerSetServiceBitsEx,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetServerSetServiceBitsEx,
+- (ndr_print_function_t) ndr_print_srvsvc_NetServerSetServiceBitsEx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20616,7 +20616,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NETRDFSGETVERSION),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NETRDFSGETVERSION,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NETRDFSGETVERSION,
+- (ndr_print_function_t) ndr_print_srvsvc_NETRDFSGETVERSION,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20625,7 +20625,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NETRDFSCREATELOCALPARTITION),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NETRDFSCREATELOCALPARTITION,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NETRDFSCREATELOCALPARTITION,
+- (ndr_print_function_t) ndr_print_srvsvc_NETRDFSCREATELOCALPARTITION,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20634,7 +20634,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NETRDFSDELETELOCALPARTITION),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NETRDFSDELETELOCALPARTITION,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NETRDFSDELETELOCALPARTITION,
+- (ndr_print_function_t) ndr_print_srvsvc_NETRDFSDELETELOCALPARTITION,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20643,7 +20643,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NETRDFSSETLOCALVOLUMESTATE),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NETRDFSSETLOCALVOLUMESTATE,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NETRDFSSETLOCALVOLUMESTATE,
+- (ndr_print_function_t) ndr_print_srvsvc_NETRDFSSETLOCALVOLUMESTATE,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20652,7 +20652,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NETRDFSSETSERVERINFO),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NETRDFSSETSERVERINFO,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NETRDFSSETSERVERINFO,
+- (ndr_print_function_t) ndr_print_srvsvc_NETRDFSSETSERVERINFO,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20661,7 +20661,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NETRDFSCREATEEXITPOINT),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NETRDFSCREATEEXITPOINT,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NETRDFSCREATEEXITPOINT,
+- (ndr_print_function_t) ndr_print_srvsvc_NETRDFSCREATEEXITPOINT,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20670,7 +20670,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NETRDFSDELETEEXITPOINT),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NETRDFSDELETEEXITPOINT,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NETRDFSDELETEEXITPOINT,
+- (ndr_print_function_t) ndr_print_srvsvc_NETRDFSDELETEEXITPOINT,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20679,7 +20679,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NETRDFSMODIFYPREFIX),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NETRDFSMODIFYPREFIX,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NETRDFSMODIFYPREFIX,
+- (ndr_print_function_t) ndr_print_srvsvc_NETRDFSMODIFYPREFIX,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20688,7 +20688,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NETRDFSFIXLOCALVOLUME),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NETRDFSFIXLOCALVOLUME,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NETRDFSFIXLOCALVOLUME,
+- (ndr_print_function_t) ndr_print_srvsvc_NETRDFSFIXLOCALVOLUME,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20697,7 +20697,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NETRDFSMANAGERREPORTSITEINFO),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NETRDFSMANAGERREPORTSITEINFO,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NETRDFSMANAGERREPORTSITEINFO,
+- (ndr_print_function_t) ndr_print_srvsvc_NETRDFSMANAGERREPORTSITEINFO,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20706,7 +20706,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NETRSERVERTRANSPORTDELEX),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NETRSERVERTRANSPORTDELEX,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NETRSERVERTRANSPORTDELEX,
+- (ndr_print_function_t) ndr_print_srvsvc_NETRSERVERTRANSPORTDELEX,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_svcctl.c
++++ b/source3/librpc/gen_ndr/ndr_svcctl.c
+@@ -7175,7 +7175,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_CloseServiceHandle),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_CloseServiceHandle,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_CloseServiceHandle,
+- (ndr_print_function_t) ndr_print_svcctl_CloseServiceHandle,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7184,7 +7184,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_ControlService),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_ControlService,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_ControlService,
+- (ndr_print_function_t) ndr_print_svcctl_ControlService,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7193,7 +7193,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_DeleteService),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_DeleteService,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_DeleteService,
+- (ndr_print_function_t) ndr_print_svcctl_DeleteService,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7202,7 +7202,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_LockServiceDatabase),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_LockServiceDatabase,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_LockServiceDatabase,
+- (ndr_print_function_t) ndr_print_svcctl_LockServiceDatabase,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7211,7 +7211,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_QueryServiceObjectSecurity),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_QueryServiceObjectSecurity,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_QueryServiceObjectSecurity,
+- (ndr_print_function_t) ndr_print_svcctl_QueryServiceObjectSecurity,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7220,7 +7220,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_SetServiceObjectSecurity),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_SetServiceObjectSecurity,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_SetServiceObjectSecurity,
+- (ndr_print_function_t) ndr_print_svcctl_SetServiceObjectSecurity,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7229,7 +7229,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_QueryServiceStatus),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_QueryServiceStatus,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_QueryServiceStatus,
+- (ndr_print_function_t) ndr_print_svcctl_QueryServiceStatus,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7238,7 +7238,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_SetServiceStatus),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_SetServiceStatus,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_SetServiceStatus,
+- (ndr_print_function_t) ndr_print_svcctl_SetServiceStatus,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7247,7 +7247,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_UnlockServiceDatabase),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_UnlockServiceDatabase,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_UnlockServiceDatabase,
+- (ndr_print_function_t) ndr_print_svcctl_UnlockServiceDatabase,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7256,7 +7256,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_NotifyBootConfigStatus),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_NotifyBootConfigStatus,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_NotifyBootConfigStatus,
+- (ndr_print_function_t) ndr_print_svcctl_NotifyBootConfigStatus,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7265,7 +7265,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_SCSetServiceBitsW),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_SCSetServiceBitsW,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_SCSetServiceBitsW,
+- (ndr_print_function_t) ndr_print_svcctl_SCSetServiceBitsW,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7274,7 +7274,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_ChangeServiceConfigW),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_ChangeServiceConfigW,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_ChangeServiceConfigW,
+- (ndr_print_function_t) ndr_print_svcctl_ChangeServiceConfigW,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7283,7 +7283,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_CreateServiceW),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_CreateServiceW,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_CreateServiceW,
+- (ndr_print_function_t) ndr_print_svcctl_CreateServiceW,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7292,7 +7292,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_EnumDependentServicesW),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_EnumDependentServicesW,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_EnumDependentServicesW,
+- (ndr_print_function_t) ndr_print_svcctl_EnumDependentServicesW,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7301,7 +7301,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_EnumServicesStatusW),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_EnumServicesStatusW,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_EnumServicesStatusW,
+- (ndr_print_function_t) ndr_print_svcctl_EnumServicesStatusW,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7310,7 +7310,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_OpenSCManagerW),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_OpenSCManagerW,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_OpenSCManagerW,
+- (ndr_print_function_t) ndr_print_svcctl_OpenSCManagerW,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7319,7 +7319,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_OpenServiceW),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_OpenServiceW,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_OpenServiceW,
+- (ndr_print_function_t) ndr_print_svcctl_OpenServiceW,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7328,7 +7328,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_QueryServiceConfigW),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_QueryServiceConfigW,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_QueryServiceConfigW,
+- (ndr_print_function_t) ndr_print_svcctl_QueryServiceConfigW,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7337,7 +7337,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_QueryServiceLockStatusW),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_QueryServiceLockStatusW,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_QueryServiceLockStatusW,
+- (ndr_print_function_t) ndr_print_svcctl_QueryServiceLockStatusW,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7346,7 +7346,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_StartServiceW),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_StartServiceW,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_StartServiceW,
+- (ndr_print_function_t) ndr_print_svcctl_StartServiceW,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7355,7 +7355,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_GetServiceDisplayNameW),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_GetServiceDisplayNameW,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_GetServiceDisplayNameW,
+- (ndr_print_function_t) ndr_print_svcctl_GetServiceDisplayNameW,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7364,7 +7364,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_GetServiceKeyNameW),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_GetServiceKeyNameW,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_GetServiceKeyNameW,
+- (ndr_print_function_t) ndr_print_svcctl_GetServiceKeyNameW,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7373,7 +7373,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_SCSetServiceBitsA),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_SCSetServiceBitsA,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_SCSetServiceBitsA,
+- (ndr_print_function_t) ndr_print_svcctl_SCSetServiceBitsA,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7382,7 +7382,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_ChangeServiceConfigA),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_ChangeServiceConfigA,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_ChangeServiceConfigA,
+- (ndr_print_function_t) ndr_print_svcctl_ChangeServiceConfigA,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7391,7 +7391,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_CreateServiceA),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_CreateServiceA,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_CreateServiceA,
+- (ndr_print_function_t) ndr_print_svcctl_CreateServiceA,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7400,7 +7400,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_EnumDependentServicesA),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_EnumDependentServicesA,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_EnumDependentServicesA,
+- (ndr_print_function_t) ndr_print_svcctl_EnumDependentServicesA,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7409,7 +7409,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_EnumServicesStatusA),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_EnumServicesStatusA,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_EnumServicesStatusA,
+- (ndr_print_function_t) ndr_print_svcctl_EnumServicesStatusA,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7418,7 +7418,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_OpenSCManagerA),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_OpenSCManagerA,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_OpenSCManagerA,
+- (ndr_print_function_t) ndr_print_svcctl_OpenSCManagerA,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7427,7 +7427,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_OpenServiceA),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_OpenServiceA,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_OpenServiceA,
+- (ndr_print_function_t) ndr_print_svcctl_OpenServiceA,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7436,7 +7436,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_QueryServiceConfigA),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_QueryServiceConfigA,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_QueryServiceConfigA,
+- (ndr_print_function_t) ndr_print_svcctl_QueryServiceConfigA,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7445,7 +7445,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_QueryServiceLockStatusA),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_QueryServiceLockStatusA,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_QueryServiceLockStatusA,
+- (ndr_print_function_t) ndr_print_svcctl_QueryServiceLockStatusA,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7454,7 +7454,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_StartServiceA),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_StartServiceA,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_StartServiceA,
+- (ndr_print_function_t) ndr_print_svcctl_StartServiceA,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7463,7 +7463,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_GetServiceDisplayNameA),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_GetServiceDisplayNameA,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_GetServiceDisplayNameA,
+- (ndr_print_function_t) ndr_print_svcctl_GetServiceDisplayNameA,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7472,7 +7472,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_GetServiceKeyNameA),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_GetServiceKeyNameA,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_GetServiceKeyNameA,
+- (ndr_print_function_t) ndr_print_svcctl_GetServiceKeyNameA,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7481,7 +7481,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_GetCurrentGroupeStateW),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_GetCurrentGroupeStateW,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_GetCurrentGroupeStateW,
+- (ndr_print_function_t) ndr_print_svcctl_GetCurrentGroupeStateW,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7490,7 +7490,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_EnumServiceGroupW),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_EnumServiceGroupW,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_EnumServiceGroupW,
+- (ndr_print_function_t) ndr_print_svcctl_EnumServiceGroupW,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7499,7 +7499,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_ChangeServiceConfig2A),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_ChangeServiceConfig2A,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_ChangeServiceConfig2A,
+- (ndr_print_function_t) ndr_print_svcctl_ChangeServiceConfig2A,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7508,7 +7508,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_ChangeServiceConfig2W),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_ChangeServiceConfig2W,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_ChangeServiceConfig2W,
+- (ndr_print_function_t) ndr_print_svcctl_ChangeServiceConfig2W,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7517,7 +7517,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_QueryServiceConfig2A),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_QueryServiceConfig2A,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_QueryServiceConfig2A,
+- (ndr_print_function_t) ndr_print_svcctl_QueryServiceConfig2A,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7526,7 +7526,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_QueryServiceConfig2W),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_QueryServiceConfig2W,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_QueryServiceConfig2W,
+- (ndr_print_function_t) ndr_print_svcctl_QueryServiceConfig2W,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7535,7 +7535,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_QueryServiceStatusEx),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_QueryServiceStatusEx,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_QueryServiceStatusEx,
+- (ndr_print_function_t) ndr_print_svcctl_QueryServiceStatusEx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7544,7 +7544,7 @@ static const struct ndr_interface_call s
+ sizeof(struct EnumServicesStatusExA),
+ (ndr_push_flags_fn_t) ndr_push_EnumServicesStatusExA,
+ (ndr_pull_flags_fn_t) ndr_pull_EnumServicesStatusExA,
+- (ndr_print_function_t) ndr_print_EnumServicesStatusExA,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7553,7 +7553,7 @@ static const struct ndr_interface_call s
+ sizeof(struct EnumServicesStatusExW),
+ (ndr_push_flags_fn_t) ndr_push_EnumServicesStatusExW,
+ (ndr_pull_flags_fn_t) ndr_pull_EnumServicesStatusExW,
+- (ndr_print_function_t) ndr_print_EnumServicesStatusExW,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7562,7 +7562,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_SCSendTSMessage),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_SCSendTSMessage,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_SCSendTSMessage,
+- (ndr_print_function_t) ndr_print_svcctl_SCSendTSMessage,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_trkwks.c
++++ b/source3/librpc/gen_ndr/ndr_trkwks.c
+@@ -51,7 +51,7 @@ static const struct ndr_interface_call t
+ sizeof(struct trkwks_Unknown0),
+ (ndr_push_flags_fn_t) ndr_push_trkwks_Unknown0,
+ (ndr_pull_flags_fn_t) ndr_pull_trkwks_Unknown0,
+- (ndr_print_function_t) ndr_print_trkwks_Unknown0,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_unixinfo.c
++++ b/source3/librpc/gen_ndr/ndr_unixinfo.c
+@@ -472,7 +472,7 @@ static const struct ndr_interface_call u
+ sizeof(struct unixinfo_SidToUid),
+ (ndr_push_flags_fn_t) ndr_push_unixinfo_SidToUid,
+ (ndr_pull_flags_fn_t) ndr_pull_unixinfo_SidToUid,
+- (ndr_print_function_t) ndr_print_unixinfo_SidToUid,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -481,7 +481,7 @@ static const struct ndr_interface_call u
+ sizeof(struct unixinfo_UidToSid),
+ (ndr_push_flags_fn_t) ndr_push_unixinfo_UidToSid,
+ (ndr_pull_flags_fn_t) ndr_pull_unixinfo_UidToSid,
+- (ndr_print_function_t) ndr_print_unixinfo_UidToSid,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -490,7 +490,7 @@ static const struct ndr_interface_call u
+ sizeof(struct unixinfo_SidToGid),
+ (ndr_push_flags_fn_t) ndr_push_unixinfo_SidToGid,
+ (ndr_pull_flags_fn_t) ndr_pull_unixinfo_SidToGid,
+- (ndr_print_function_t) ndr_print_unixinfo_SidToGid,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -499,7 +499,7 @@ static const struct ndr_interface_call u
+ sizeof(struct unixinfo_GidToSid),
+ (ndr_push_flags_fn_t) ndr_push_unixinfo_GidToSid,
+ (ndr_pull_flags_fn_t) ndr_pull_unixinfo_GidToSid,
+- (ndr_print_function_t) ndr_print_unixinfo_GidToSid,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -508,7 +508,7 @@ static const struct ndr_interface_call u
+ sizeof(struct unixinfo_GetPWUid),
+ (ndr_push_flags_fn_t) ndr_push_unixinfo_GetPWUid,
+ (ndr_pull_flags_fn_t) ndr_pull_unixinfo_GetPWUid,
+- (ndr_print_function_t) ndr_print_unixinfo_GetPWUid,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_w32time.c
++++ b/source3/librpc/gen_ndr/ndr_w32time.c
+@@ -135,7 +135,7 @@ static const struct ndr_interface_call w
+ sizeof(struct w32time_SyncTime),
+ (ndr_push_flags_fn_t) ndr_push_w32time_SyncTime,
+ (ndr_pull_flags_fn_t) ndr_pull_w32time_SyncTime,
+- (ndr_print_function_t) ndr_print_w32time_SyncTime,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -144,7 +144,7 @@ static const struct ndr_interface_call w
+ sizeof(struct w32time_GetNetLogonServiceBits),
+ (ndr_push_flags_fn_t) ndr_push_w32time_GetNetLogonServiceBits,
+ (ndr_pull_flags_fn_t) ndr_pull_w32time_GetNetLogonServiceBits,
+- (ndr_print_function_t) ndr_print_w32time_GetNetLogonServiceBits,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -153,7 +153,7 @@ static const struct ndr_interface_call w
+ sizeof(struct w32time_QueryProviderStatus),
+ (ndr_push_flags_fn_t) ndr_push_w32time_QueryProviderStatus,
+ (ndr_pull_flags_fn_t) ndr_pull_w32time_QueryProviderStatus,
+- (ndr_print_function_t) ndr_print_w32time_QueryProviderStatus,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_wbint.c
++++ b/source3/librpc/gen_ndr/ndr_wbint.c
+@@ -2696,7 +2696,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wbint_Ping),
+ (ndr_push_flags_fn_t) ndr_push_wbint_Ping,
+ (ndr_pull_flags_fn_t) ndr_pull_wbint_Ping,
+- (ndr_print_function_t) ndr_print_wbint_Ping,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2705,7 +2705,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wbint_LookupSid),
+ (ndr_push_flags_fn_t) ndr_push_wbint_LookupSid,
+ (ndr_pull_flags_fn_t) ndr_pull_wbint_LookupSid,
+- (ndr_print_function_t) ndr_print_wbint_LookupSid,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2714,7 +2714,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wbint_LookupSids),
+ (ndr_push_flags_fn_t) ndr_push_wbint_LookupSids,
+ (ndr_pull_flags_fn_t) ndr_pull_wbint_LookupSids,
+- (ndr_print_function_t) ndr_print_wbint_LookupSids,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2723,7 +2723,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wbint_LookupName),
+ (ndr_push_flags_fn_t) ndr_push_wbint_LookupName,
+ (ndr_pull_flags_fn_t) ndr_pull_wbint_LookupName,
+- (ndr_print_function_t) ndr_print_wbint_LookupName,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2732,7 +2732,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wbint_Sid2Uid),
+ (ndr_push_flags_fn_t) ndr_push_wbint_Sid2Uid,
+ (ndr_pull_flags_fn_t) ndr_pull_wbint_Sid2Uid,
+- (ndr_print_function_t) ndr_print_wbint_Sid2Uid,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2741,7 +2741,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wbint_Sid2Gid),
+ (ndr_push_flags_fn_t) ndr_push_wbint_Sid2Gid,
+ (ndr_pull_flags_fn_t) ndr_pull_wbint_Sid2Gid,
+- (ndr_print_function_t) ndr_print_wbint_Sid2Gid,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2750,7 +2750,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wbint_Sids2UnixIDs),
+ (ndr_push_flags_fn_t) ndr_push_wbint_Sids2UnixIDs,
+ (ndr_pull_flags_fn_t) ndr_pull_wbint_Sids2UnixIDs,
+- (ndr_print_function_t) ndr_print_wbint_Sids2UnixIDs,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2759,7 +2759,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wbint_Uid2Sid),
+ (ndr_push_flags_fn_t) ndr_push_wbint_Uid2Sid,
+ (ndr_pull_flags_fn_t) ndr_pull_wbint_Uid2Sid,
+- (ndr_print_function_t) ndr_print_wbint_Uid2Sid,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2768,7 +2768,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wbint_Gid2Sid),
+ (ndr_push_flags_fn_t) ndr_push_wbint_Gid2Sid,
+ (ndr_pull_flags_fn_t) ndr_pull_wbint_Gid2Sid,
+- (ndr_print_function_t) ndr_print_wbint_Gid2Sid,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2777,7 +2777,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wbint_AllocateUid),
+ (ndr_push_flags_fn_t) ndr_push_wbint_AllocateUid,
+ (ndr_pull_flags_fn_t) ndr_pull_wbint_AllocateUid,
+- (ndr_print_function_t) ndr_print_wbint_AllocateUid,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2786,7 +2786,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wbint_AllocateGid),
+ (ndr_push_flags_fn_t) ndr_push_wbint_AllocateGid,
+ (ndr_pull_flags_fn_t) ndr_pull_wbint_AllocateGid,
+- (ndr_print_function_t) ndr_print_wbint_AllocateGid,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2795,7 +2795,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wbint_QueryUser),
+ (ndr_push_flags_fn_t) ndr_push_wbint_QueryUser,
+ (ndr_pull_flags_fn_t) ndr_pull_wbint_QueryUser,
+- (ndr_print_function_t) ndr_print_wbint_QueryUser,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2804,7 +2804,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wbint_LookupUserAliases),
+ (ndr_push_flags_fn_t) ndr_push_wbint_LookupUserAliases,
+ (ndr_pull_flags_fn_t) ndr_pull_wbint_LookupUserAliases,
+- (ndr_print_function_t) ndr_print_wbint_LookupUserAliases,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2813,7 +2813,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wbint_LookupUserGroups),
+ (ndr_push_flags_fn_t) ndr_push_wbint_LookupUserGroups,
+ (ndr_pull_flags_fn_t) ndr_pull_wbint_LookupUserGroups,
+- (ndr_print_function_t) ndr_print_wbint_LookupUserGroups,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2822,7 +2822,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wbint_QuerySequenceNumber),
+ (ndr_push_flags_fn_t) ndr_push_wbint_QuerySequenceNumber,
+ (ndr_pull_flags_fn_t) ndr_pull_wbint_QuerySequenceNumber,
+- (ndr_print_function_t) ndr_print_wbint_QuerySequenceNumber,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2831,7 +2831,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wbint_LookupGroupMembers),
+ (ndr_push_flags_fn_t) ndr_push_wbint_LookupGroupMembers,
+ (ndr_pull_flags_fn_t) ndr_pull_wbint_LookupGroupMembers,
+- (ndr_print_function_t) ndr_print_wbint_LookupGroupMembers,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2840,7 +2840,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wbint_QueryUserList),
+ (ndr_push_flags_fn_t) ndr_push_wbint_QueryUserList,
+ (ndr_pull_flags_fn_t) ndr_pull_wbint_QueryUserList,
+- (ndr_print_function_t) ndr_print_wbint_QueryUserList,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2849,7 +2849,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wbint_QueryGroupList),
+ (ndr_push_flags_fn_t) ndr_push_wbint_QueryGroupList,
+ (ndr_pull_flags_fn_t) ndr_pull_wbint_QueryGroupList,
+- (ndr_print_function_t) ndr_print_wbint_QueryGroupList,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2858,7 +2858,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wbint_DsGetDcName),
+ (ndr_push_flags_fn_t) ndr_push_wbint_DsGetDcName,
+ (ndr_pull_flags_fn_t) ndr_pull_wbint_DsGetDcName,
+- (ndr_print_function_t) ndr_print_wbint_DsGetDcName,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2867,7 +2867,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wbint_LookupRids),
+ (ndr_push_flags_fn_t) ndr_push_wbint_LookupRids,
+ (ndr_pull_flags_fn_t) ndr_pull_wbint_LookupRids,
+- (ndr_print_function_t) ndr_print_wbint_LookupRids,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2876,7 +2876,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wbint_CheckMachineAccount),
+ (ndr_push_flags_fn_t) ndr_push_wbint_CheckMachineAccount,
+ (ndr_pull_flags_fn_t) ndr_pull_wbint_CheckMachineAccount,
+- (ndr_print_function_t) ndr_print_wbint_CheckMachineAccount,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2885,7 +2885,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wbint_ChangeMachineAccount),
+ (ndr_push_flags_fn_t) ndr_push_wbint_ChangeMachineAccount,
+ (ndr_pull_flags_fn_t) ndr_pull_wbint_ChangeMachineAccount,
+- (ndr_print_function_t) ndr_print_wbint_ChangeMachineAccount,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2894,7 +2894,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wbint_PingDc),
+ (ndr_push_flags_fn_t) ndr_push_wbint_PingDc,
+ (ndr_pull_flags_fn_t) ndr_pull_wbint_PingDc,
+- (ndr_print_function_t) ndr_print_wbint_PingDc,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_winreg.c
++++ b/source3/librpc/gen_ndr/ndr_winreg.c
+@@ -4864,7 +4864,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_OpenHKCR),
+ (ndr_push_flags_fn_t) ndr_push_winreg_OpenHKCR,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_OpenHKCR,
+- (ndr_print_function_t) ndr_print_winreg_OpenHKCR,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -4873,7 +4873,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_OpenHKCU),
+ (ndr_push_flags_fn_t) ndr_push_winreg_OpenHKCU,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_OpenHKCU,
+- (ndr_print_function_t) ndr_print_winreg_OpenHKCU,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -4882,7 +4882,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_OpenHKLM),
+ (ndr_push_flags_fn_t) ndr_push_winreg_OpenHKLM,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_OpenHKLM,
+- (ndr_print_function_t) ndr_print_winreg_OpenHKLM,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -4891,7 +4891,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_OpenHKPD),
+ (ndr_push_flags_fn_t) ndr_push_winreg_OpenHKPD,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_OpenHKPD,
+- (ndr_print_function_t) ndr_print_winreg_OpenHKPD,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -4900,7 +4900,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_OpenHKU),
+ (ndr_push_flags_fn_t) ndr_push_winreg_OpenHKU,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_OpenHKU,
+- (ndr_print_function_t) ndr_print_winreg_OpenHKU,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -4909,7 +4909,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_CloseKey),
+ (ndr_push_flags_fn_t) ndr_push_winreg_CloseKey,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_CloseKey,
+- (ndr_print_function_t) ndr_print_winreg_CloseKey,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -4918,7 +4918,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_CreateKey),
+ (ndr_push_flags_fn_t) ndr_push_winreg_CreateKey,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_CreateKey,
+- (ndr_print_function_t) ndr_print_winreg_CreateKey,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -4927,7 +4927,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_DeleteKey),
+ (ndr_push_flags_fn_t) ndr_push_winreg_DeleteKey,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_DeleteKey,
+- (ndr_print_function_t) ndr_print_winreg_DeleteKey,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -4936,7 +4936,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_DeleteValue),
+ (ndr_push_flags_fn_t) ndr_push_winreg_DeleteValue,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_DeleteValue,
+- (ndr_print_function_t) ndr_print_winreg_DeleteValue,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -4945,7 +4945,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_EnumKey),
+ (ndr_push_flags_fn_t) ndr_push_winreg_EnumKey,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_EnumKey,
+- (ndr_print_function_t) ndr_print_winreg_EnumKey,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -4954,7 +4954,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_EnumValue),
+ (ndr_push_flags_fn_t) ndr_push_winreg_EnumValue,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_EnumValue,
+- (ndr_print_function_t) ndr_print_winreg_EnumValue,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -4963,7 +4963,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_FlushKey),
+ (ndr_push_flags_fn_t) ndr_push_winreg_FlushKey,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_FlushKey,
+- (ndr_print_function_t) ndr_print_winreg_FlushKey,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -4972,7 +4972,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_GetKeySecurity),
+ (ndr_push_flags_fn_t) ndr_push_winreg_GetKeySecurity,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_GetKeySecurity,
+- (ndr_print_function_t) ndr_print_winreg_GetKeySecurity,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -4981,7 +4981,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_LoadKey),
+ (ndr_push_flags_fn_t) ndr_push_winreg_LoadKey,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_LoadKey,
+- (ndr_print_function_t) ndr_print_winreg_LoadKey,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -4990,7 +4990,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_NotifyChangeKeyValue),
+ (ndr_push_flags_fn_t) ndr_push_winreg_NotifyChangeKeyValue,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_NotifyChangeKeyValue,
+- (ndr_print_function_t) ndr_print_winreg_NotifyChangeKeyValue,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -4999,7 +4999,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_OpenKey),
+ (ndr_push_flags_fn_t) ndr_push_winreg_OpenKey,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_OpenKey,
+- (ndr_print_function_t) ndr_print_winreg_OpenKey,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5008,7 +5008,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_QueryInfoKey),
+ (ndr_push_flags_fn_t) ndr_push_winreg_QueryInfoKey,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_QueryInfoKey,
+- (ndr_print_function_t) ndr_print_winreg_QueryInfoKey,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5017,7 +5017,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_QueryValue),
+ (ndr_push_flags_fn_t) ndr_push_winreg_QueryValue,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_QueryValue,
+- (ndr_print_function_t) ndr_print_winreg_QueryValue,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5026,7 +5026,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_ReplaceKey),
+ (ndr_push_flags_fn_t) ndr_push_winreg_ReplaceKey,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_ReplaceKey,
+- (ndr_print_function_t) ndr_print_winreg_ReplaceKey,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5035,7 +5035,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_RestoreKey),
+ (ndr_push_flags_fn_t) ndr_push_winreg_RestoreKey,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_RestoreKey,
+- (ndr_print_function_t) ndr_print_winreg_RestoreKey,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5044,7 +5044,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_SaveKey),
+ (ndr_push_flags_fn_t) ndr_push_winreg_SaveKey,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_SaveKey,
+- (ndr_print_function_t) ndr_print_winreg_SaveKey,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5053,7 +5053,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_SetKeySecurity),
+ (ndr_push_flags_fn_t) ndr_push_winreg_SetKeySecurity,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_SetKeySecurity,
+- (ndr_print_function_t) ndr_print_winreg_SetKeySecurity,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5062,7 +5062,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_SetValue),
+ (ndr_push_flags_fn_t) ndr_push_winreg_SetValue,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_SetValue,
+- (ndr_print_function_t) ndr_print_winreg_SetValue,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5071,7 +5071,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_UnLoadKey),
+ (ndr_push_flags_fn_t) ndr_push_winreg_UnLoadKey,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_UnLoadKey,
+- (ndr_print_function_t) ndr_print_winreg_UnLoadKey,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5080,7 +5080,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_InitiateSystemShutdown),
+ (ndr_push_flags_fn_t) ndr_push_winreg_InitiateSystemShutdown,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_InitiateSystemShutdown,
+- (ndr_print_function_t) ndr_print_winreg_InitiateSystemShutdown,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5089,7 +5089,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_AbortSystemShutdown),
+ (ndr_push_flags_fn_t) ndr_push_winreg_AbortSystemShutdown,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_AbortSystemShutdown,
+- (ndr_print_function_t) ndr_print_winreg_AbortSystemShutdown,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5098,7 +5098,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_GetVersion),
+ (ndr_push_flags_fn_t) ndr_push_winreg_GetVersion,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_GetVersion,
+- (ndr_print_function_t) ndr_print_winreg_GetVersion,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5107,7 +5107,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_OpenHKCC),
+ (ndr_push_flags_fn_t) ndr_push_winreg_OpenHKCC,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_OpenHKCC,
+- (ndr_print_function_t) ndr_print_winreg_OpenHKCC,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5116,7 +5116,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_OpenHKDD),
+ (ndr_push_flags_fn_t) ndr_push_winreg_OpenHKDD,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_OpenHKDD,
+- (ndr_print_function_t) ndr_print_winreg_OpenHKDD,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5125,7 +5125,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_QueryMultipleValues),
+ (ndr_push_flags_fn_t) ndr_push_winreg_QueryMultipleValues,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_QueryMultipleValues,
+- (ndr_print_function_t) ndr_print_winreg_QueryMultipleValues,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5134,7 +5134,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_InitiateSystemShutdownEx),
+ (ndr_push_flags_fn_t) ndr_push_winreg_InitiateSystemShutdownEx,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_InitiateSystemShutdownEx,
+- (ndr_print_function_t) ndr_print_winreg_InitiateSystemShutdownEx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5143,7 +5143,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_SaveKeyEx),
+ (ndr_push_flags_fn_t) ndr_push_winreg_SaveKeyEx,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_SaveKeyEx,
+- (ndr_print_function_t) ndr_print_winreg_SaveKeyEx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5152,7 +5152,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_OpenHKPT),
+ (ndr_push_flags_fn_t) ndr_push_winreg_OpenHKPT,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_OpenHKPT,
+- (ndr_print_function_t) ndr_print_winreg_OpenHKPT,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5161,7 +5161,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_OpenHKPN),
+ (ndr_push_flags_fn_t) ndr_push_winreg_OpenHKPN,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_OpenHKPN,
+- (ndr_print_function_t) ndr_print_winreg_OpenHKPN,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5170,7 +5170,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_QueryMultipleValues2),
+ (ndr_push_flags_fn_t) ndr_push_winreg_QueryMultipleValues2,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_QueryMultipleValues2,
+- (ndr_print_function_t) ndr_print_winreg_QueryMultipleValues2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5179,7 +5179,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_DeleteKeyEx),
+ (ndr_push_flags_fn_t) ndr_push_winreg_DeleteKeyEx,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_DeleteKeyEx,
+- (ndr_print_function_t) ndr_print_winreg_DeleteKeyEx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_wkssvc.c
++++ b/source3/librpc/gen_ndr/ndr_wkssvc.c
+@@ -11005,7 +11005,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetWkstaGetInfo),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetWkstaGetInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetWkstaGetInfo,
+- (ndr_print_function_t) ndr_print_wkssvc_NetWkstaGetInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11014,7 +11014,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetWkstaSetInfo),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetWkstaSetInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetWkstaSetInfo,
+- (ndr_print_function_t) ndr_print_wkssvc_NetWkstaSetInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11023,7 +11023,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetWkstaEnumUsers),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetWkstaEnumUsers,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetWkstaEnumUsers,
+- (ndr_print_function_t) ndr_print_wkssvc_NetWkstaEnumUsers,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11032,7 +11032,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetrWkstaUserGetInfo),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetrWkstaUserGetInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetrWkstaUserGetInfo,
+- (ndr_print_function_t) ndr_print_wkssvc_NetrWkstaUserGetInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11041,7 +11041,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetrWkstaUserSetInfo),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetrWkstaUserSetInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetrWkstaUserSetInfo,
+- (ndr_print_function_t) ndr_print_wkssvc_NetrWkstaUserSetInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11050,7 +11050,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetWkstaTransportEnum),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetWkstaTransportEnum,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetWkstaTransportEnum,
+- (ndr_print_function_t) ndr_print_wkssvc_NetWkstaTransportEnum,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11059,7 +11059,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetrWkstaTransportAdd),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetrWkstaTransportAdd,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetrWkstaTransportAdd,
+- (ndr_print_function_t) ndr_print_wkssvc_NetrWkstaTransportAdd,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11068,7 +11068,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetrWkstaTransportDel),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetrWkstaTransportDel,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetrWkstaTransportDel,
+- (ndr_print_function_t) ndr_print_wkssvc_NetrWkstaTransportDel,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11077,7 +11077,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetrUseAdd),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetrUseAdd,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetrUseAdd,
+- (ndr_print_function_t) ndr_print_wkssvc_NetrUseAdd,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11086,7 +11086,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetrUseGetInfo),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetrUseGetInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetrUseGetInfo,
+- (ndr_print_function_t) ndr_print_wkssvc_NetrUseGetInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11095,7 +11095,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetrUseDel),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetrUseDel,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetrUseDel,
+- (ndr_print_function_t) ndr_print_wkssvc_NetrUseDel,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11104,7 +11104,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetrUseEnum),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetrUseEnum,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetrUseEnum,
+- (ndr_print_function_t) ndr_print_wkssvc_NetrUseEnum,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11113,7 +11113,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetrMessageBufferSend),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetrMessageBufferSend,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetrMessageBufferSend,
+- (ndr_print_function_t) ndr_print_wkssvc_NetrMessageBufferSend,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11122,7 +11122,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetrWorkstationStatisticsGet),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetrWorkstationStatisticsGet,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetrWorkstationStatisticsGet,
+- (ndr_print_function_t) ndr_print_wkssvc_NetrWorkstationStatisticsGet,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11131,7 +11131,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetrLogonDomainNameAdd),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetrLogonDomainNameAdd,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetrLogonDomainNameAdd,
+- (ndr_print_function_t) ndr_print_wkssvc_NetrLogonDomainNameAdd,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11140,7 +11140,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetrLogonDomainNameDel),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetrLogonDomainNameDel,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetrLogonDomainNameDel,
+- (ndr_print_function_t) ndr_print_wkssvc_NetrLogonDomainNameDel,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11149,7 +11149,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetrJoinDomain),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetrJoinDomain,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetrJoinDomain,
+- (ndr_print_function_t) ndr_print_wkssvc_NetrJoinDomain,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11158,7 +11158,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetrUnjoinDomain),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetrUnjoinDomain,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetrUnjoinDomain,
+- (ndr_print_function_t) ndr_print_wkssvc_NetrUnjoinDomain,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11167,7 +11167,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetrRenameMachineInDomain),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetrRenameMachineInDomain,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetrRenameMachineInDomain,
+- (ndr_print_function_t) ndr_print_wkssvc_NetrRenameMachineInDomain,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11176,7 +11176,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetrValidateName),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetrValidateName,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetrValidateName,
+- (ndr_print_function_t) ndr_print_wkssvc_NetrValidateName,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11185,7 +11185,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetrGetJoinInformation),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetrGetJoinInformation,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetrGetJoinInformation,
+- (ndr_print_function_t) ndr_print_wkssvc_NetrGetJoinInformation,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11194,7 +11194,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetrGetJoinableOus),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetrGetJoinableOus,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetrGetJoinableOus,
+- (ndr_print_function_t) ndr_print_wkssvc_NetrGetJoinableOus,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11203,7 +11203,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetrJoinDomain2),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetrJoinDomain2,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetrJoinDomain2,
+- (ndr_print_function_t) ndr_print_wkssvc_NetrJoinDomain2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11212,7 +11212,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetrUnjoinDomain2),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetrUnjoinDomain2,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetrUnjoinDomain2,
+- (ndr_print_function_t) ndr_print_wkssvc_NetrUnjoinDomain2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11221,7 +11221,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetrRenameMachineInDomain2),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetrRenameMachineInDomain2,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetrRenameMachineInDomain2,
+- (ndr_print_function_t) ndr_print_wkssvc_NetrRenameMachineInDomain2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11230,7 +11230,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetrValidateName2),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetrValidateName2,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetrValidateName2,
+- (ndr_print_function_t) ndr_print_wkssvc_NetrValidateName2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11239,7 +11239,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetrGetJoinableOus2),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetrGetJoinableOus2,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetrGetJoinableOus2,
+- (ndr_print_function_t) ndr_print_wkssvc_NetrGetJoinableOus2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11248,7 +11248,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetrAddAlternateComputerName),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetrAddAlternateComputerName,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetrAddAlternateComputerName,
+- (ndr_print_function_t) ndr_print_wkssvc_NetrAddAlternateComputerName,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11257,7 +11257,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetrRemoveAlternateComputerName),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetrRemoveAlternateComputerName,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetrRemoveAlternateComputerName,
+- (ndr_print_function_t) ndr_print_wkssvc_NetrRemoveAlternateComputerName,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11266,7 +11266,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetrSetPrimaryComputername),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetrSetPrimaryComputername,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetrSetPrimaryComputername,
+- (ndr_print_function_t) ndr_print_wkssvc_NetrSetPrimaryComputername,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11275,7 +11275,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetrEnumerateComputerNames),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetrEnumerateComputerNames,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetrEnumerateComputerNames,
+- (ndr_print_function_t) ndr_print_wkssvc_NetrEnumerateComputerNames,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_wmi.c
++++ b/source3/librpc/gen_ndr/ndr_wmi.c
+@@ -139,7 +139,7 @@ static const struct ndr_interface_call I
+ sizeof(struct Delete),
+ (ndr_push_flags_fn_t) ndr_push_Delete,
+ (ndr_pull_flags_fn_t) ndr_pull_Delete,
+- (ndr_print_function_t) ndr_print_Delete,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3704,7 +3704,7 @@ static const struct ndr_interface_call I
+ sizeof(struct OpenNamespace),
+ (ndr_push_flags_fn_t) ndr_push_OpenNamespace,
+ (ndr_pull_flags_fn_t) ndr_pull_OpenNamespace,
+- (ndr_print_function_t) ndr_print_OpenNamespace,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3713,7 +3713,7 @@ static const struct ndr_interface_call I
+ sizeof(struct CancelAsyncCall),
+ (ndr_push_flags_fn_t) ndr_push_CancelAsyncCall,
+ (ndr_pull_flags_fn_t) ndr_pull_CancelAsyncCall,
+- (ndr_print_function_t) ndr_print_CancelAsyncCall,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3722,7 +3722,7 @@ static const struct ndr_interface_call I
+ sizeof(struct QueryObjectSink),
+ (ndr_push_flags_fn_t) ndr_push_QueryObjectSink,
+ (ndr_pull_flags_fn_t) ndr_pull_QueryObjectSink,
+- (ndr_print_function_t) ndr_print_QueryObjectSink,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3731,7 +3731,7 @@ static const struct ndr_interface_call I
+ sizeof(struct GetObject),
+ (ndr_push_flags_fn_t) ndr_push_GetObject,
+ (ndr_pull_flags_fn_t) ndr_pull_GetObject,
+- (ndr_print_function_t) ndr_print_GetObject,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3740,7 +3740,7 @@ static const struct ndr_interface_call I
+ sizeof(struct GetObjectAsync),
+ (ndr_push_flags_fn_t) ndr_push_GetObjectAsync,
+ (ndr_pull_flags_fn_t) ndr_pull_GetObjectAsync,
+- (ndr_print_function_t) ndr_print_GetObjectAsync,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3749,7 +3749,7 @@ static const struct ndr_interface_call I
+ sizeof(struct PutClass),
+ (ndr_push_flags_fn_t) ndr_push_PutClass,
+ (ndr_pull_flags_fn_t) ndr_pull_PutClass,
+- (ndr_print_function_t) ndr_print_PutClass,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3758,7 +3758,7 @@ static const struct ndr_interface_call I
+ sizeof(struct PutClassAsync),
+ (ndr_push_flags_fn_t) ndr_push_PutClassAsync,
+ (ndr_pull_flags_fn_t) ndr_pull_PutClassAsync,
+- (ndr_print_function_t) ndr_print_PutClassAsync,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3767,7 +3767,7 @@ static const struct ndr_interface_call I
+ sizeof(struct DeleteClass),
+ (ndr_push_flags_fn_t) ndr_push_DeleteClass,
+ (ndr_pull_flags_fn_t) ndr_pull_DeleteClass,
+- (ndr_print_function_t) ndr_print_DeleteClass,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3776,7 +3776,7 @@ static const struct ndr_interface_call I
+ sizeof(struct DeleteClassAsync),
+ (ndr_push_flags_fn_t) ndr_push_DeleteClassAsync,
+ (ndr_pull_flags_fn_t) ndr_pull_DeleteClassAsync,
+- (ndr_print_function_t) ndr_print_DeleteClassAsync,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3785,7 +3785,7 @@ static const struct ndr_interface_call I
+ sizeof(struct CreateClassEnum),
+ (ndr_push_flags_fn_t) ndr_push_CreateClassEnum,
+ (ndr_pull_flags_fn_t) ndr_pull_CreateClassEnum,
+- (ndr_print_function_t) ndr_print_CreateClassEnum,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3794,7 +3794,7 @@ static const struct ndr_interface_call I
+ sizeof(struct CreateClassEnumAsync),
+ (ndr_push_flags_fn_t) ndr_push_CreateClassEnumAsync,
+ (ndr_pull_flags_fn_t) ndr_pull_CreateClassEnumAsync,
+- (ndr_print_function_t) ndr_print_CreateClassEnumAsync,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3803,7 +3803,7 @@ static const struct ndr_interface_call I
+ sizeof(struct PutInstance),
+ (ndr_push_flags_fn_t) ndr_push_PutInstance,
+ (ndr_pull_flags_fn_t) ndr_pull_PutInstance,
+- (ndr_print_function_t) ndr_print_PutInstance,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3812,7 +3812,7 @@ static const struct ndr_interface_call I
+ sizeof(struct PutInstanceAsync),
+ (ndr_push_flags_fn_t) ndr_push_PutInstanceAsync,
+ (ndr_pull_flags_fn_t) ndr_pull_PutInstanceAsync,
+- (ndr_print_function_t) ndr_print_PutInstanceAsync,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3821,7 +3821,7 @@ static const struct ndr_interface_call I
+ sizeof(struct DeleteInstance),
+ (ndr_push_flags_fn_t) ndr_push_DeleteInstance,
+ (ndr_pull_flags_fn_t) ndr_pull_DeleteInstance,
+- (ndr_print_function_t) ndr_print_DeleteInstance,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3830,7 +3830,7 @@ static const struct ndr_interface_call I
+ sizeof(struct DeleteInstanceAsync),
+ (ndr_push_flags_fn_t) ndr_push_DeleteInstanceAsync,
+ (ndr_pull_flags_fn_t) ndr_pull_DeleteInstanceAsync,
+- (ndr_print_function_t) ndr_print_DeleteInstanceAsync,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3839,7 +3839,7 @@ static const struct ndr_interface_call I
+ sizeof(struct CreateInstanceEnum),
+ (ndr_push_flags_fn_t) ndr_push_CreateInstanceEnum,
+ (ndr_pull_flags_fn_t) ndr_pull_CreateInstanceEnum,
+- (ndr_print_function_t) ndr_print_CreateInstanceEnum,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3848,7 +3848,7 @@ static const struct ndr_interface_call I
+ sizeof(struct CreateInstanceEnumAsync),
+ (ndr_push_flags_fn_t) ndr_push_CreateInstanceEnumAsync,
+ (ndr_pull_flags_fn_t) ndr_pull_CreateInstanceEnumAsync,
+- (ndr_print_function_t) ndr_print_CreateInstanceEnumAsync,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3857,7 +3857,7 @@ static const struct ndr_interface_call I
+ sizeof(struct ExecQuery),
+ (ndr_push_flags_fn_t) ndr_push_ExecQuery,
+ (ndr_pull_flags_fn_t) ndr_pull_ExecQuery,
+- (ndr_print_function_t) ndr_print_ExecQuery,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3866,7 +3866,7 @@ static const struct ndr_interface_call I
+ sizeof(struct ExecQueryAsync),
+ (ndr_push_flags_fn_t) ndr_push_ExecQueryAsync,
+ (ndr_pull_flags_fn_t) ndr_pull_ExecQueryAsync,
+- (ndr_print_function_t) ndr_print_ExecQueryAsync,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3875,7 +3875,7 @@ static const struct ndr_interface_call I
+ sizeof(struct ExecNotificationQuery),
+ (ndr_push_flags_fn_t) ndr_push_ExecNotificationQuery,
+ (ndr_pull_flags_fn_t) ndr_pull_ExecNotificationQuery,
+- (ndr_print_function_t) ndr_print_ExecNotificationQuery,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3884,7 +3884,7 @@ static const struct ndr_interface_call I
+ sizeof(struct ExecNotificationQueryAsync),
+ (ndr_push_flags_fn_t) ndr_push_ExecNotificationQueryAsync,
+ (ndr_pull_flags_fn_t) ndr_pull_ExecNotificationQueryAsync,
+- (ndr_print_function_t) ndr_print_ExecNotificationQueryAsync,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3893,7 +3893,7 @@ static const struct ndr_interface_call I
+ sizeof(struct ExecMethod),
+ (ndr_push_flags_fn_t) ndr_push_ExecMethod,
+ (ndr_pull_flags_fn_t) ndr_pull_ExecMethod,
+- (ndr_print_function_t) ndr_print_ExecMethod,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3902,7 +3902,7 @@ static const struct ndr_interface_call I
+ sizeof(struct ExecMethodAsync),
+ (ndr_push_flags_fn_t) ndr_push_ExecMethodAsync,
+ (ndr_pull_flags_fn_t) ndr_pull_ExecMethodAsync,
+- (ndr_print_function_t) ndr_print_ExecMethodAsync,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -4434,7 +4434,7 @@ static const struct ndr_interface_call I
+ sizeof(struct Reset),
+ (ndr_push_flags_fn_t) ndr_push_Reset,
+ (ndr_pull_flags_fn_t) ndr_pull_Reset,
+- (ndr_print_function_t) ndr_print_Reset,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -4443,7 +4443,7 @@ static const struct ndr_interface_call I
+ sizeof(struct IEnumWbemClassObject_Next),
+ (ndr_push_flags_fn_t) ndr_push_IEnumWbemClassObject_Next,
+ (ndr_pull_flags_fn_t) ndr_pull_IEnumWbemClassObject_Next,
+- (ndr_print_function_t) ndr_print_IEnumWbemClassObject_Next,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -4452,7 +4452,7 @@ static const struct ndr_interface_call I
+ sizeof(struct NextAsync),
+ (ndr_push_flags_fn_t) ndr_push_NextAsync,
+ (ndr_pull_flags_fn_t) ndr_pull_NextAsync,
+- (ndr_print_function_t) ndr_print_NextAsync,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -4461,7 +4461,7 @@ static const struct ndr_interface_call I
+ sizeof(struct IEnumWbemClassObject_Clone),
+ (ndr_push_flags_fn_t) ndr_push_IEnumWbemClassObject_Clone,
+ (ndr_pull_flags_fn_t) ndr_pull_IEnumWbemClassObject_Clone,
+- (ndr_print_function_t) ndr_print_IEnumWbemClassObject_Clone,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -4470,7 +4470,7 @@ static const struct ndr_interface_call I
+ sizeof(struct Skip),
+ (ndr_push_flags_fn_t) ndr_push_Skip,
+ (ndr_pull_flags_fn_t) ndr_pull_Skip,
+- (ndr_print_function_t) ndr_print_Skip,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5143,7 +5143,7 @@ static const struct ndr_interface_call I
+ sizeof(struct Clone),
+ (ndr_push_flags_fn_t) ndr_push_Clone,
+ (ndr_pull_flags_fn_t) ndr_pull_Clone,
+- (ndr_print_function_t) ndr_print_Clone,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5152,7 +5152,7 @@ static const struct ndr_interface_call I
+ sizeof(struct GetNames),
+ (ndr_push_flags_fn_t) ndr_push_GetNames,
+ (ndr_pull_flags_fn_t) ndr_pull_GetNames,
+- (ndr_print_function_t) ndr_print_GetNames,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5161,7 +5161,7 @@ static const struct ndr_interface_call I
+ sizeof(struct BeginEnumeration),
+ (ndr_push_flags_fn_t) ndr_push_BeginEnumeration,
+ (ndr_pull_flags_fn_t) ndr_pull_BeginEnumeration,
+- (ndr_print_function_t) ndr_print_BeginEnumeration,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5170,7 +5170,7 @@ static const struct ndr_interface_call I
+ sizeof(struct Next),
+ (ndr_push_flags_fn_t) ndr_push_Next,
+ (ndr_pull_flags_fn_t) ndr_pull_Next,
+- (ndr_print_function_t) ndr_print_Next,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5179,7 +5179,7 @@ static const struct ndr_interface_call I
+ sizeof(struct EndEnumeration),
+ (ndr_push_flags_fn_t) ndr_push_EndEnumeration,
+ (ndr_pull_flags_fn_t) ndr_pull_EndEnumeration,
+- (ndr_print_function_t) ndr_print_EndEnumeration,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5188,7 +5188,7 @@ static const struct ndr_interface_call I
+ sizeof(struct SetValue),
+ (ndr_push_flags_fn_t) ndr_push_SetValue,
+ (ndr_pull_flags_fn_t) ndr_pull_SetValue,
+- (ndr_print_function_t) ndr_print_SetValue,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5197,7 +5197,7 @@ static const struct ndr_interface_call I
+ sizeof(struct GetValue),
+ (ndr_push_flags_fn_t) ndr_push_GetValue,
+ (ndr_pull_flags_fn_t) ndr_pull_GetValue,
+- (ndr_print_function_t) ndr_print_GetValue,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5206,7 +5206,7 @@ static const struct ndr_interface_call I
+ sizeof(struct DeleteValue),
+ (ndr_push_flags_fn_t) ndr_push_DeleteValue,
+ (ndr_pull_flags_fn_t) ndr_pull_DeleteValue,
+- (ndr_print_function_t) ndr_print_DeleteValue,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5215,7 +5215,7 @@ static const struct ndr_interface_call I
+ sizeof(struct DeleteAll),
+ (ndr_push_flags_fn_t) ndr_push_DeleteAll,
+ (ndr_pull_flags_fn_t) ndr_pull_DeleteAll,
+- (ndr_print_function_t) ndr_print_DeleteAll,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5963,7 +5963,7 @@ static const struct ndr_interface_call I
+ sizeof(struct EstablishPosition),
+ (ndr_push_flags_fn_t) ndr_push_EstablishPosition,
+ (ndr_pull_flags_fn_t) ndr_pull_EstablishPosition,
+- (ndr_print_function_t) ndr_print_EstablishPosition,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5972,7 +5972,7 @@ static const struct ndr_interface_call I
+ sizeof(struct RequestChallenge),
+ (ndr_push_flags_fn_t) ndr_push_RequestChallenge,
+ (ndr_pull_flags_fn_t) ndr_pull_RequestChallenge,
+- (ndr_print_function_t) ndr_print_RequestChallenge,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5981,7 +5981,7 @@ static const struct ndr_interface_call I
+ sizeof(struct WBEMLogin),
+ (ndr_push_flags_fn_t) ndr_push_WBEMLogin,
+ (ndr_pull_flags_fn_t) ndr_pull_WBEMLogin,
+- (ndr_print_function_t) ndr_print_WBEMLogin,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5990,7 +5990,7 @@ static const struct ndr_interface_call I
+ sizeof(struct NTLMLogin),
+ (ndr_push_flags_fn_t) ndr_push_NTLMLogin,
+ (ndr_pull_flags_fn_t) ndr_pull_NTLMLogin,
+- (ndr_print_function_t) ndr_print_NTLMLogin,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -6225,7 +6225,7 @@ static const struct ndr_interface_call I
+ sizeof(struct IWbemWCOSmartEnum_Next),
+ (ndr_push_flags_fn_t) ndr_push_IWbemWCOSmartEnum_Next,
+ (ndr_pull_flags_fn_t) ndr_pull_IWbemWCOSmartEnum_Next,
+- (ndr_print_function_t) ndr_print_IWbemWCOSmartEnum_Next,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -6479,7 +6479,7 @@ static const struct ndr_interface_call I
+ sizeof(struct Fetch),
+ (ndr_push_flags_fn_t) ndr_push_Fetch,
+ (ndr_pull_flags_fn_t) ndr_pull_Fetch,
+- (ndr_print_function_t) ndr_print_Fetch,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -6488,7 +6488,7 @@ static const struct ndr_interface_call I
+ sizeof(struct Test),
+ (ndr_push_flags_fn_t) ndr_push_Test,
+ (ndr_pull_flags_fn_t) ndr_pull_Test,
+- (ndr_print_function_t) ndr_print_Test,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -6920,7 +6920,7 @@ static const struct ndr_interface_call I
+ sizeof(struct GetResultObject),
+ (ndr_push_flags_fn_t) ndr_push_GetResultObject,
+ (ndr_pull_flags_fn_t) ndr_pull_GetResultObject,
+- (ndr_print_function_t) ndr_print_GetResultObject,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -6929,7 +6929,7 @@ static const struct ndr_interface_call I
+ sizeof(struct GetResultString),
+ (ndr_push_flags_fn_t) ndr_push_GetResultString,
+ (ndr_pull_flags_fn_t) ndr_pull_GetResultString,
+- (ndr_print_function_t) ndr_print_GetResultString,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -6938,7 +6938,7 @@ static const struct ndr_interface_call I
+ sizeof(struct GetResultServices),
+ (ndr_push_flags_fn_t) ndr_push_GetResultServices,
+ (ndr_pull_flags_fn_t) ndr_pull_GetResultServices,
+- (ndr_print_function_t) ndr_print_GetResultServices,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -6947,7 +6947,7 @@ static const struct ndr_interface_call I
+ sizeof(struct GetCallStatus),
+ (ndr_push_flags_fn_t) ndr_push_GetCallStatus,
+ (ndr_pull_flags_fn_t) ndr_pull_GetCallStatus,
+- (ndr_print_function_t) ndr_print_GetCallStatus,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7211,7 +7211,7 @@ static const struct ndr_interface_call I
+ sizeof(struct SetStatus),
+ (ndr_push_flags_fn_t) ndr_push_SetStatus,
+ (ndr_pull_flags_fn_t) ndr_pull_SetStatus,
+- (ndr_print_function_t) ndr_print_SetStatus,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7220,7 +7220,7 @@ static const struct ndr_interface_call I
+ sizeof(struct Indicate),
+ (ndr_push_flags_fn_t) ndr_push_Indicate,
+ (ndr_pull_flags_fn_t) ndr_pull_Indicate,
+- (ndr_print_function_t) ndr_print_Indicate,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_wzcsvc.c
++++ b/source3/librpc/gen_ndr/ndr_wzcsvc.c
+@@ -711,7 +711,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wzcsvc_EnumInterfaces),
+ (ndr_push_flags_fn_t) ndr_push_wzcsvc_EnumInterfaces,
+ (ndr_pull_flags_fn_t) ndr_pull_wzcsvc_EnumInterfaces,
+- (ndr_print_function_t) ndr_print_wzcsvc_EnumInterfaces,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -720,7 +720,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wzcsvc_QueryInterface),
+ (ndr_push_flags_fn_t) ndr_push_wzcsvc_QueryInterface,
+ (ndr_pull_flags_fn_t) ndr_pull_wzcsvc_QueryInterface,
+- (ndr_print_function_t) ndr_print_wzcsvc_QueryInterface,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -729,7 +729,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wzcsvc_SetInterface),
+ (ndr_push_flags_fn_t) ndr_push_wzcsvc_SetInterface,
+ (ndr_pull_flags_fn_t) ndr_pull_wzcsvc_SetInterface,
+- (ndr_print_function_t) ndr_print_wzcsvc_SetInterface,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -738,7 +738,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wzcsvc_RefreshInterface),
+ (ndr_push_flags_fn_t) ndr_push_wzcsvc_RefreshInterface,
+ (ndr_pull_flags_fn_t) ndr_pull_wzcsvc_RefreshInterface,
+- (ndr_print_function_t) ndr_print_wzcsvc_RefreshInterface,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -747,7 +747,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wzcsvc_QueryContext),
+ (ndr_push_flags_fn_t) ndr_push_wzcsvc_QueryContext,
+ (ndr_pull_flags_fn_t) ndr_pull_wzcsvc_QueryContext,
+- (ndr_print_function_t) ndr_print_wzcsvc_QueryContext,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -756,7 +756,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wzcsvc_SetContext),
+ (ndr_push_flags_fn_t) ndr_push_wzcsvc_SetContext,
+ (ndr_pull_flags_fn_t) ndr_pull_wzcsvc_SetContext,
+- (ndr_print_function_t) ndr_print_wzcsvc_SetContext,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -765,7 +765,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wzcsvc_EapolUIResponse),
+ (ndr_push_flags_fn_t) ndr_push_wzcsvc_EapolUIResponse,
+ (ndr_pull_flags_fn_t) ndr_pull_wzcsvc_EapolUIResponse,
+- (ndr_print_function_t) ndr_print_wzcsvc_EapolUIResponse,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -774,7 +774,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wzcsvc_EapolGetCustomAuthData),
+ (ndr_push_flags_fn_t) ndr_push_wzcsvc_EapolGetCustomAuthData,
+ (ndr_pull_flags_fn_t) ndr_pull_wzcsvc_EapolGetCustomAuthData,
+- (ndr_print_function_t) ndr_print_wzcsvc_EapolGetCustomAuthData,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -783,7 +783,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wzcsvc_EapolSetCustomAuthData),
+ (ndr_push_flags_fn_t) ndr_push_wzcsvc_EapolSetCustomAuthData,
+ (ndr_pull_flags_fn_t) ndr_pull_wzcsvc_EapolSetCustomAuthData,
+- (ndr_print_function_t) ndr_print_wzcsvc_EapolSetCustomAuthData,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -792,7 +792,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wzcsvc_EapolGetInterfaceParams),
+ (ndr_push_flags_fn_t) ndr_push_wzcsvc_EapolGetInterfaceParams,
+ (ndr_pull_flags_fn_t) ndr_pull_wzcsvc_EapolGetInterfaceParams,
+- (ndr_print_function_t) ndr_print_wzcsvc_EapolGetInterfaceParams,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -801,7 +801,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wzcsvc_EapolSetInterfaceParams),
+ (ndr_push_flags_fn_t) ndr_push_wzcsvc_EapolSetInterfaceParams,
+ (ndr_pull_flags_fn_t) ndr_pull_wzcsvc_EapolSetInterfaceParams,
+- (ndr_print_function_t) ndr_print_wzcsvc_EapolSetInterfaceParams,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -810,7 +810,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wzcsvc_EapolReAuthenticateInterface),
+ (ndr_push_flags_fn_t) ndr_push_wzcsvc_EapolReAuthenticateInterface,
+ (ndr_pull_flags_fn_t) ndr_pull_wzcsvc_EapolReAuthenticateInterface,
+- (ndr_print_function_t) ndr_print_wzcsvc_EapolReAuthenticateInterface,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -819,7 +819,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wzcsvc_EapolQueryInterfaceState),
+ (ndr_push_flags_fn_t) ndr_push_wzcsvc_EapolQueryInterfaceState,
+ (ndr_pull_flags_fn_t) ndr_pull_wzcsvc_EapolQueryInterfaceState,
+- (ndr_print_function_t) ndr_print_wzcsvc_EapolQueryInterfaceState,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -828,7 +828,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wzcsvc_OpenWZCDbLogSession),
+ (ndr_push_flags_fn_t) ndr_push_wzcsvc_OpenWZCDbLogSession,
+ (ndr_pull_flags_fn_t) ndr_pull_wzcsvc_OpenWZCDbLogSession,
+- (ndr_print_function_t) ndr_print_wzcsvc_OpenWZCDbLogSession,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -837,7 +837,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wzcsvc_CloseWZCDbLogSession),
+ (ndr_push_flags_fn_t) ndr_push_wzcsvc_CloseWZCDbLogSession,
+ (ndr_pull_flags_fn_t) ndr_pull_wzcsvc_CloseWZCDbLogSession,
+- (ndr_print_function_t) ndr_print_wzcsvc_CloseWZCDbLogSession,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -846,7 +846,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wzcsvc_EnumWZCDbLogRecords),
+ (ndr_push_flags_fn_t) ndr_push_wzcsvc_EnumWZCDbLogRecords,
+ (ndr_pull_flags_fn_t) ndr_pull_wzcsvc_EnumWZCDbLogRecords,
+- (ndr_print_function_t) ndr_print_wzcsvc_EnumWZCDbLogRecords,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -855,7 +855,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wzcsvc_FlushWZCdbLog),
+ (ndr_push_flags_fn_t) ndr_push_wzcsvc_FlushWZCdbLog,
+ (ndr_pull_flags_fn_t) ndr_pull_wzcsvc_FlushWZCdbLog,
+- (ndr_print_function_t) ndr_print_wzcsvc_FlushWZCdbLog,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -864,7 +864,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wzcsvc_GetWZCDbLogRecord),
+ (ndr_push_flags_fn_t) ndr_push_wzcsvc_GetWZCDbLogRecord,
+ (ndr_pull_flags_fn_t) ndr_pull_wzcsvc_GetWZCDbLogRecord,
+- (ndr_print_function_t) ndr_print_wzcsvc_GetWZCDbLogRecord,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_xattr.c
++++ b/source3/librpc/gen_ndr/ndr_xattr.c
+@@ -1101,7 +1101,7 @@ static const struct ndr_interface_call x
+ sizeof(struct xattr_parse_DOSATTRIB),
+ (ndr_push_flags_fn_t) ndr_push_xattr_parse_DOSATTRIB,
+ (ndr_pull_flags_fn_t) ndr_pull_xattr_parse_DOSATTRIB,
+- (ndr_print_function_t) ndr_print_xattr_parse_DOSATTRIB,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- /dev/null
++++ b/source3/remove-librpc-print-calls.sh
+@@ -0,0 +1,22 @@
++#!/usr/bin/env bash
++set -e
++for file in ${1:-librpc/gen_ndr/ndr_*.c}; do
++ quilt add "$file" || true
++ awk '
++$0 ~ /^static const struct ndr_interface_call .* = {$/ {
++ replace = 1
++}
++
++$0 ~ /^}$/ {
++ replace = 0;
++}
++
++replace == 1 {
++ gsub(/.ndr_print_function_t. .*,/, "(ndr_print_function_t) ndr_print_disabled,", $0)
++}
++{
++ print $0
++}
++ ' < "$file" > "$file.new"
++ mv "$file.new" "$file"
++done
+--- a/librpc/ndr/libndr.h
++++ b/librpc/ndr/libndr.h
+@@ -603,6 +603,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_enum
+ _PUBLIC_ enum ndr_err_code ndr_push_enum_uint1632(struct ndr_push *ndr, int ndr_flags, uint16_t v);
+
+ _PUBLIC_ void ndr_print_bool(struct ndr_print *ndr, const char *name, const bool b);
++_PUBLIC_ void ndr_print_disabled(struct ndr_print *ndr, const char *name, int flags, void *r);
+
+ #ifndef VERBOSE_ERROR
+ #define ndr_print_bool(...) do {} while (0)
diff --git a/package/network/services/samba36/patches/100-configure_fixes.patch b/package/network/services/samba36/patches/100-configure_fixes.patch
new file mode 100644
index 0000000..e40a133
--- /dev/null
+++ b/package/network/services/samba36/patches/100-configure_fixes.patch
@@ -0,0 +1,14 @@
+--- a/source3/configure
++++ b/source3/configure
+@@ -13318,10 +13318,7 @@ if test x"$libreplace_cv_HAVE_GETADDRINF
+ # see bug 5910, use our replacements if we detect
+ # a broken system.
+ if test "$cross_compiling" = yes; then :
+- { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+-as_fn_error $? "cannot run test program while cross compiling
+-See \`config.log' for more details" "$LINENO" 5; }
++ $as_echo "assuming valid getaddrinfo without bug 5910" >&2
+ else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h. */
diff --git a/package/network/services/samba36/patches/110-multicall.patch b/package/network/services/samba36/patches/110-multicall.patch
new file mode 100644
index 0000000..a01bc58
--- /dev/null
+++ b/package/network/services/samba36/patches/110-multicall.patch
@@ -0,0 +1,117 @@
+--- a/source3/Makefile.in
++++ b/source3/Makefile.in
+@@ -73,20 +73,20 @@ LDAP_LIBS=@LDAP_LIBS@
+ NSCD_LIBS=@NSCD_LIBS@
+ UUID_LIBS=@UUID_LIBS@
+ LIBWBCLIENT=@LIBWBCLIENT_STATIC@ @LIBWBCLIENT_SHARED@
+-LIBWBCLIENT_LIBS=@LIBWBCLIENT_LIBS@
++LIBWBCLIENT_LIBS=@LIBWBCLIENT_STATIC@
+ PTHREAD_LDFLAGS=@PTHREAD_LDFLAGS@
+ PTHREAD_CFLAGS=@PTHREAD_CFLAGS@
+ DNSSD_LIBS=@DNSSD_LIBS@
+ AVAHI_LIBS=@AVAHI_LIBS@
+ POPT_LIBS=@POPTLIBS@
+ LIBTALLOC=@LIBTALLOC_STATIC@ @LIBTALLOC_SHARED@
+-LIBTALLOC_LIBS=@LIBTALLOC_LIBS@
++LIBTALLOC_LIBS=@LIBTALLOC_STATIC@
+ LIBREPLACE_LIBS=@LIBREPLACE_LIBS@
+ LIBTDB=@LIBTDB_STATIC@ @LIBTDB_SHARED@
+-LIBTDB_LIBS=@LIBTDB_LIBS@
++LIBTDB_LIBS=@LIBTDB_STATIC@
+ TDB_DEPS=@TDB_DEPS@
+ LIBNETAPI=@LIBNETAPI_STATIC@ @LIBNETAPI_SHARED@
+-LIBNETAPI_LIBS=@LIBNETAPI_LIBS@
++LIBNETAPI_LIBS=@LIBNETAPI_STATIC@
+ LIBSMBCLIENT_LIBS=@LIBSMBCLIENT_LIBS@
+ LIBSMBSHAREMODES_LIBS=@LIBSMBSHAREMODES_LIBS@
+
+@@ -214,7 +214,7 @@ PATH_FLAGS = -DSMB_PASSWD_FILE=\"$(SMB_P
+
+ # Note that all executable programs now provide for an optional executable suffix.
+
+-SBIN_PROGS = bin/smbd@EXEEXT@ bin/nmbd@EXEEXT@ @SWAT_SBIN_TARGETS@ @EXTRA_SBIN_PROGS@
++SBIN_PROGS = bin/samba_multicall@EXEEXT@ bin/smbd@EXEEXT@ bin/nmbd@EXEEXT@ @SWAT_SBIN_TARGETS@ @EXTRA_SBIN_PROGS@
+
+ BIN_PROGS1 = bin/smbclient@EXEEXT@ bin/net@EXEEXT@ bin/smbspool@EXEEXT@ \
+ bin/testparm@EXEEXT@ bin/smbstatus@EXEEXT@ bin/smbget@EXEEXT@ \
+@@ -1775,6 +1775,42 @@ bin/.dummy:
+ dir=bin $(MAKEDIR); fi
+ @: >> $@ || : > $@ # what a fancy emoticon!
+
++smbd/server_multicall.o: smbd/server.c smbd/server.o
++ @echo Compiling $<.c
++ @$(COMPILE_CC_PATH) -Dmain=smbd_main && exit 0;\
++ echo "The following command failed:" 1>&2;\
++ echo "$(COMPILE_CC_PATH)" 1>&2;\
++ $(COMPILE_CC_PATH) >/dev/null 2>&1
++
++nmbd/nmbd_multicall.o: nmbd/nmbd.c nmbd/nmbd.o
++ @echo Compiling $<.c
++ @$(COMPILE_CC_PATH) -Dmain=nmbd_main && exit 0;\
++ echo "The following command failed:" 1>&2;\
++ echo "$(COMPILE_CC_PATH)" 1>&2;\
++ $(COMPILE_CC_PATH) >/dev/null 2>&1
++
++utils/smbpasswd_multicall.o: utils/smbpasswd.c utils/smbpasswd.o
++ @echo Compiling $<.c
++ @$(COMPILE_CC_PATH) -Dmain=smbpasswd_main && exit 0;\
++ echo "The following command failed:" 1>&2;\
++ echo "$(COMPILE_CC_PATH)" 1>&2;\
++ $(COMPILE_CC_PATH) >/dev/null 2>&1
++
++SMBD_MULTI_O = $(patsubst smbd/server.o,smbd/server_multicall.o,$(SMBD_OBJ))
++NMBD_MULTI_O = $(patsubst nmbd/nmbd.o,nmbd/nmbd_multicall.o,$(filter-out $(LIB_DUMMY_OBJ),$(NMBD_OBJ)))
++SMBPASSWD_MULTI_O = $(patsubst utils/smbpasswd.o,utils/smbpasswd_multicall.o,$(filter-out $(LIB_DUMMY_OBJ),$(SMBPASSWD_OBJ)))
++MULTI_O = multi.o
++
++MULTICALL_O = $(sort $(SMBD_MULTI_O) $(NMBD_MULTI_O) $(SMBPASSWD_MULTI_O) $(MULTI_O))
++
++bin/samba_multicall@EXEEXT@: $(BINARY_PREREQS) $(MULTICALL_O) $(LIBTALLOC) $(LIBTDB) $(LIBWBCLIENT) @BUILD_POPT@
++ @echo Linking $@
++ @$(CC) -o $@ $(MULTICALL_O) $(LDFLAGS) $(LDAP_LIBS) @SMBD_FAM_LIBS@ \
++ $(KRB5LIBS) $(DYNEXP) $(PRINT_LIBS) $(AUTH_LIBS) \
++ $(ACL_LIBS) $(PASSDB_LIBS) $(LIBS) $(DNSSD_LIBS) $(AVAHI_LIBS) \
++ $(POPT_LIBS) @SMBD_LIBS@ $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) \
++ $(LIBWBCLIENT_LIBS) $(ZLIB_LIBS)
++
+ bin/smbd@EXEEXT@: $(BINARY_PREREQS) $(SMBD_OBJ) $(LIBTALLOC) $(LIBTDB) $(LIBWBCLIENT) @BUILD_POPT@
+ @echo Linking $@
+ @$(CC) -o $@ $(SMBD_OBJ) $(LDFLAGS) $(LDAP_LIBS) @SMBD_FAM_LIBS@ \
+--- /dev/null
++++ b/source3/multi.c
+@@ -0,0 +1,35 @@
++#include <stdio.h>
++#include <string.h>
++
++extern int smbd_main(int argc, char **argv);
++extern int nmbd_main(int argc, char **argv);
++extern int smbpasswd_main(int argc, char **argv);
++
++static struct {
++ const char *name;
++ int (*func)(int argc, char **argv);
++} multicall[] = {
++ { "smbd", smbd_main },
++ { "nmbd", nmbd_main },
++ { "smbpasswd", smbpasswd_main },
++};
++
++#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
++
++int main(int argc, char **argv)
++{
++ int i;
++
++ for (i = 0; i < ARRAY_SIZE(multicall); i++) {
++ if (strstr(argv[0], multicall[i].name))
++ return multicall[i].func(argc, argv);
++ }
++
++ fprintf(stderr, "Invalid multicall command, available commands:");
++ for (i = 0; i < ARRAY_SIZE(multicall); i++)
++ fprintf(stderr, " %s", multicall[i].name);
++
++ fprintf(stderr, "\n");
++
++ return 1;
++}
diff --git a/package/network/services/samba36/patches/111-owrt_smbpasswd.patch b/package/network/services/samba36/patches/111-owrt_smbpasswd.patch
new file mode 100644
index 0000000..7d852c4
--- /dev/null
+++ b/package/network/services/samba36/patches/111-owrt_smbpasswd.patch
@@ -0,0 +1,277 @@
+--- a/source3/Makefile.in
++++ b/source3/Makefile.in
+@@ -1017,7 +1017,7 @@ TEST_LP_LOAD_OBJ = param/test_lp_load.o
+
+ PASSWD_UTIL_OBJ = utils/passwd_util.o
+
+-SMBPASSWD_OBJ = utils/smbpasswd.o $(PASSWD_UTIL_OBJ) $(PASSCHANGE_OBJ) \
++SMBPASSWD_OBJ = utils/owrt_smbpasswd.o $(PASSWD_UTIL_OBJ) $(PASSCHANGE_OBJ) \
+ $(PARAM_OBJ) $(LIBSMB_OBJ) $(PASSDB_OBJ) \
+ $(GROUPDB_OBJ) $(LIB_NONSMBD_OBJ) $(KRBCLIENT_OBJ) \
+ $(POPT_LIB_OBJ) $(SMBLDAP_OBJ) \
+@@ -1789,7 +1789,7 @@ nmbd/nmbd_multicall.o: nmbd/nmbd.c nmbd/
+ echo "$(COMPILE_CC_PATH)" 1>&2;\
+ $(COMPILE_CC_PATH) >/dev/null 2>&1
+
+-utils/smbpasswd_multicall.o: utils/smbpasswd.c utils/smbpasswd.o
++utils/smbpasswd_multicall.o: utils/owrt_smbpasswd.c utils/owrt_smbpasswd.o
+ @echo Compiling $<.c
+ @$(COMPILE_CC_PATH) -Dmain=smbpasswd_main && exit 0;\
+ echo "The following command failed:" 1>&2;\
+@@ -1798,7 +1798,7 @@ utils/smbpasswd_multicall.o: utils/smbpa
+
+ SMBD_MULTI_O = $(patsubst smbd/server.o,smbd/server_multicall.o,$(SMBD_OBJ))
+ NMBD_MULTI_O = $(patsubst nmbd/nmbd.o,nmbd/nmbd_multicall.o,$(filter-out $(LIB_DUMMY_OBJ),$(NMBD_OBJ)))
+-SMBPASSWD_MULTI_O = $(patsubst utils/smbpasswd.o,utils/smbpasswd_multicall.o,$(filter-out $(LIB_DUMMY_OBJ),$(SMBPASSWD_OBJ)))
++SMBPASSWD_MULTI_O = $(patsubst utils/owrt_smbpasswd.o,utils/smbpasswd_multicall.o,$(filter-out $(LIB_DUMMY_OBJ),$(SMBPASSWD_OBJ)))
+ MULTI_O = multi.o
+
+ MULTICALL_O = $(sort $(SMBD_MULTI_O) $(NMBD_MULTI_O) $(SMBPASSWD_MULTI_O) $(MULTI_O))
+--- /dev/null
++++ b/source3/utils/owrt_smbpasswd.c
+@@ -0,0 +1,245 @@
++/*
++ * Copyright (C) 2012 Felix Fietkau <nbd@openwrt.org>
++ * Copyright (C) 2008 John Crispin <blogic@openwrt.org>
++ *
++ * 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 of the License, 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; if not, write to the Free Software Foundation, Inc., 675
++ * Mass Ave, Cambridge, MA 02139, USA. */
++
++#include "includes.h"
++#include <endian.h>
++#include <stdio.h>
++
++static char buf[256];
++
++static void md4hash(const char *passwd, uchar p16[16])
++{
++ int len;
++ smb_ucs2_t wpwd[129];
++ int i;
++
++ len = strlen(passwd);
++ for (i = 0; i < len; i++) {
++#if __BYTE_ORDER == __LITTLE_ENDIAN
++ wpwd[i] = (unsigned char)passwd[i];
++#else
++ wpwd[i] = (unsigned char)passwd[i] << 8;
++#endif
++ }
++ wpwd[i] = 0;
++
++ len = len * sizeof(int16);
++ mdfour(p16, (unsigned char *)wpwd, len);
++ ZERO_STRUCT(wpwd);
++}
++
++
++static bool find_passwd_line(FILE *fp, const char *user, char **next)
++{
++ char *p1;
++
++ while (!feof(fp)) {
++ if(!fgets(buf, sizeof(buf) - 1, fp))
++ continue;
++
++ p1 = strchr(buf, ':');
++
++ if (p1 - buf != strlen(user))
++ continue;
++
++ if (strncmp(buf, user, p1 - buf) != 0)
++ continue;
++
++ if (next)
++ *next = p1;
++ return true;
++ }
++ return false;
++}
++
++/* returns -1 if user is not present in /etc/passwd*/
++static int find_uid_for_user(const char *user)
++{
++ FILE *fp;
++ char *p1, *p2, *p3;
++ int ret = -1;
++
++ fp = fopen("/etc/passwd", "r");
++ if (!fp) {
++ printf("failed to open /etc/passwd");
++ goto out;
++ }
++
++ if (!find_passwd_line(fp, user, &p1)) {
++ printf("User %s not found or invalid in /etc/passwd\n", user);
++ goto out;
++ }
++
++ p2 = strchr(p1 + 1, ':');
++ if (!p2)
++ goto out;
++
++ p2++;
++ p3 = strchr(p2, ':');
++ if (!p1)
++ goto out;
++
++ *p3 = '\0';
++ ret = atoi(p2);
++
++out:
++ if(fp)
++ fclose(fp);
++ return ret;
++}
++
++static void smbpasswd_write_user(FILE *fp, const char *user, int uid, const char *password)
++{
++ static uchar nt_p16[NT_HASH_LEN];
++ int len = 0;
++ int i;
++
++ md4hash(strdup(password), nt_p16);
++
++ len += snprintf(buf + len, sizeof(buf) - len, "%s:%u:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:", user, uid);
++ for(i = 0; i < NT_HASH_LEN; i++)
++ len += snprintf(buf + len, sizeof(buf) - len, "%02X", nt_p16[i]);
++
++ snprintf(buf + len, sizeof(buf) - len, ":[U ]:LCT-00000001:\n");
++ fputs(buf, fp);
++}
++
++static void smbpasswd_delete_user(FILE *fp)
++{
++ fpos_t r_pos, w_pos;
++ int len = strlen(buf);
++
++ fgetpos(fp, &r_pos);
++ w_pos = r_pos;
++ w_pos.__pos -= len;
++
++ while (fgets(buf, sizeof(buf) - 1, fp)) {
++ int cur_len = strlen(buf);
++
++ fsetpos(fp, &w_pos);
++ fputs(buf, fp);
++ r_pos.__pos += cur_len;
++ w_pos.__pos += cur_len;
++ fsetpos(fp, &r_pos);
++ }
++
++ ftruncate(fileno(fp), w_pos.__pos);
++}
++
++static int usage(const char *progname)
++{
++ fprintf(stderr,
++ "Usage: %s [options] <username>\n"
++ "\n"
++ "Options:\n"
++ " -s read password from stdin\n"
++ " -a add user\n"
++ " -x delete user\n",
++ progname);
++ return 1;
++}
++
++int main(int argc, char **argv)
++{
++ const char *prog = argv[0];
++ const char *user;
++ char *pw1, *pw2;
++ FILE *fp;
++ bool add = false, delete = false, get_stdin = false, found;
++ int ch;
++ int uid;
++
++ TALLOC_CTX *frame = talloc_stackframe();
++
++ while ((ch = getopt(argc, argv, "asx")) != EOF) {
++ switch (ch) {
++ case 's':
++ get_stdin = true;
++ break;
++ case 'a':
++ add = true;
++ break;
++ case 'x':
++ delete = true;
++ break;
++ default:
++ return usage(prog);
++ }
++ }
++
++ if (add && delete)
++ return usage(prog);
++
++ argc -= optind;
++ argv += optind;
++
++ if (!argc)
++ return usage(prog);
++
++ user = argv[0];
++ if (!delete) {
++ uid = find_uid_for_user(user);
++ if (uid < 0) {
++ fprintf(stderr, "Could not find user '%s' in /etc/passwd\n", user);
++ return 2;
++ }
++ }
++
++ fp = fopen("/etc/samba/smbpasswd", "r+");
++ if(!fp) {
++ fprintf(stderr, "Failed to open /etc/samba/smbpasswd");
++ return 3;
++ }
++
++ found = find_passwd_line(fp, user, NULL);
++ if (!add && !found) {
++ fprintf(stderr, "Could not find user '%s' in /etc/samba/smbpasswd\n", user);
++ return 3;
++ }
++
++ if (delete) {
++ smbpasswd_delete_user(fp);
++ goto out;
++ }
++
++ pw1 = get_pass("New SMB password:", get_stdin);
++ if (!pw1)
++ pw1 = strdup("");
++
++ pw2 = get_pass("Retype SMB password:", get_stdin);
++ if (!pw2)
++ pw2 = strdup("");
++
++ if (strcmp(pw1, pw2) != 0) {
++ fprintf(stderr, "Mismatch - password unchanged.\n");
++ goto out_free;
++ }
++
++ if (found)
++ fseek(fp, -strlen(buf), SEEK_CUR);
++ smbpasswd_write_user(fp, user, uid, pw2);
++
++out_free:
++ free(pw1);
++ free(pw2);
++out:
++ fclose(fp);
++ TALLOC_FREE(frame);
++
++ return 0;
++}
diff --git a/package/network/services/samba36/patches/120-add_missing_ifdef.patch b/package/network/services/samba36/patches/120-add_missing_ifdef.patch
new file mode 100644
index 0000000..dbd9adc
--- /dev/null
+++ b/package/network/services/samba36/patches/120-add_missing_ifdef.patch
@@ -0,0 +1,26 @@
+--- a/source3/librpc/rpc/rpc_common.c
++++ b/source3/librpc/rpc/rpc_common.c
+@@ -119,9 +119,11 @@ static bool initialize_interfaces(void)
+ if (!smb_register_ndr_interface(&ndr_table_netdfs)) {
+ return false;
+ }
++#ifdef DEVELOPER
+ if (!smb_register_ndr_interface(&ndr_table_rpcecho)) {
+ return false;
+ }
++#endif
+ if (!smb_register_ndr_interface(&ndr_table_initshutdown)) {
+ return false;
+ }
+--- a/source3/rpcclient/rpcclient.c
++++ b/source3/rpcclient/rpcclient.c
+@@ -628,7 +628,9 @@ static struct cmd_set *rpcclient_command
+ netlogon_commands,
+ srvsvc_commands,
+ dfs_commands,
++#ifdef DEVELOPER
+ echo_commands,
++#endif
+ epmapper_commands,
+ shutdown_commands,
+ test_commands,
diff --git a/package/network/services/samba36/patches/200-remove_printer_support.patch b/package/network/services/samba36/patches/200-remove_printer_support.patch
new file mode 100644
index 0000000..19d357f
--- /dev/null
+++ b/package/network/services/samba36/patches/200-remove_printer_support.patch
@@ -0,0 +1,346 @@
+--- a/source3/rpc_server/rpc_ep_setup.c
++++ b/source3/rpc_server/rpc_ep_setup.c
+@@ -1110,6 +1110,10 @@ bool dcesrv_ep_setup(struct tevent_conte
+ "rpc_server",
+ "spoolss",
+ "embedded");
++#ifndef PRINTER_SUPPORT
++ if (1) {
++ } else
++#endif
+ if (StrCaseCmp(rpcsrv_type, "embedded") == 0) {
+ spoolss_cb.init = spoolss_init_cb;
+ spoolss_cb.shutdown = spoolss_shutdown_cb;
+--- a/source3/rpcclient/rpcclient.c
++++ b/source3/rpcclient/rpcclient.c
+@@ -624,7 +624,9 @@ static struct cmd_set *rpcclient_command
+ lsarpc_commands,
+ ds_commands,
+ samr_commands,
++#ifdef PRINTER_SUPPORT
+ spoolss_commands,
++#endif
+ netlogon_commands,
+ srvsvc_commands,
+ dfs_commands,
+--- a/source3/printing/spoolssd.c
++++ b/source3/printing/spoolssd.c
+@@ -153,6 +153,10 @@ void start_spoolssd(struct tevent_contex
+ NTSTATUS status;
+ int ret;
+
++#ifndef PRINTER_SUPPORT
++ return;
++#endif
++
+ DEBUG(1, ("Forking SPOOLSS Daemon\n"));
+
+ pid = sys_fork();
+--- a/source3/utils/net_rpc.c
++++ b/source3/utils/net_rpc.c
+@@ -7798,6 +7798,10 @@ int net_rpc_printer(struct net_context *
+ {NULL, NULL, 0, NULL, NULL}
+ };
+
++#ifndef PRINTER_SUPPORT
++ return 0;
++#endif
++
+ if (argc == 0) {
+ if (c->display_usage) {
+ d_printf(_("Usage:\n"));
+--- a/source3/smbd/reply.c
++++ b/source3/smbd/reply.c
+@@ -5196,7 +5196,11 @@ void reply_printopen(struct smb_request
+ return;
+ }
+
+- if (!CAN_PRINT(conn)) {
++
++#ifdef PRINTER_SUPPORT
++ if (!CAN_PRINT(conn))
++#endif
++ {
+ reply_nterror(req, NT_STATUS_ACCESS_DENIED);
+ END_PROFILE(SMBsplopen);
+ return;
+@@ -5302,7 +5306,10 @@ void reply_printqueue(struct smb_request
+ is really quite gross and only worked when there was only
+ one printer - I think we should now only accept it if they
+ get it right (tridge) */
+- if (!CAN_PRINT(conn)) {
++#ifdef PRINTER_SUPPORT
++ if (!CAN_PRINT(conn))
++#endif
++ {
+ reply_nterror(req, NT_STATUS_ACCESS_DENIED);
+ END_PROFILE(SMBsplretq);
+ return;
+--- a/source3/smbd/lanman.c
++++ b/source3/smbd/lanman.c
+@@ -784,6 +784,10 @@ static bool api_DosPrintQGetInfo(struct
+ union spoolss_JobInfo *job_info = NULL;
+ union spoolss_PrinterInfo printer_info;
+
++#ifndef PRINTER_SUPPORT
++ return False;
++#endif
++
+ if (!str1 || !str2 || !p) {
+ return False;
+ }
+@@ -999,6 +1003,10 @@ static bool api_DosPrintQEnum(struct smb
+ union spoolss_DriverInfo *driver_info;
+ union spoolss_JobInfo **job_info;
+
++#ifndef PRINTER_SUPPORT
++ return False;
++#endif
++
+ if (!param_format || !output_format1 || !p) {
+ return False;
+ }
+@@ -3350,6 +3358,10 @@ static bool api_RDosPrintJobDel(struct s
+ struct spoolss_DevmodeContainer devmode_ctr;
+ enum spoolss_JobControl command;
+
++#ifndef PRINTER_SUPPORT
++ return False;
++#endif
++
+ if (!str1 || !str2 || !p) {
+ return False;
+ }
+@@ -3483,6 +3495,10 @@ static bool api_WPrintQueueCtrl(struct s
+ struct sec_desc_buf secdesc_ctr;
+ enum spoolss_PrinterControl command;
+
++#ifndef PRINTER_SUPPORT
++ return False;
++#endif
++
+ if (!str1 || !str2 || !QueueName) {
+ return False;
+ }
+@@ -3649,6 +3665,10 @@ static bool api_PrintJobInfo(struct smbd
+ union spoolss_JobInfo info;
+ struct spoolss_SetJobInfo1 info1;
+
++#ifndef PRINTER_SUPPORT
++ return False;
++#endif
++
+ if (!str1 || !str2 || !p) {
+ return False;
+ }
+@@ -4792,6 +4812,10 @@ static bool api_WPrintJobGetInfo(struct
+ struct spoolss_DevmodeContainer devmode_ctr;
+ union spoolss_JobInfo info;
+
++#ifndef PRINTER_SUPPORT
++ return False;
++#endif
++
+ if (!str1 || !str2 || !p) {
+ return False;
+ }
+@@ -4930,6 +4954,10 @@ static bool api_WPrintJobEnumerate(struc
+ uint32_t count = 0;
+ union spoolss_JobInfo *info;
+
++#ifndef PRINTER_SUPPORT
++ return False;
++#endif
++
+ if (!str1 || !str2 || !p) {
+ return False;
+ }
+@@ -5135,6 +5163,10 @@ static bool api_WPrintDestGetInfo(struct
+ struct spoolss_DevmodeContainer devmode_ctr;
+ union spoolss_PrinterInfo info;
+
++#ifndef PRINTER_SUPPORT
++ return False;
++#endif
++
+ if (!str1 || !str2 || !p) {
+ return False;
+ }
+@@ -5271,6 +5303,10 @@ static bool api_WPrintDestEnum(struct sm
+ union spoolss_PrinterInfo *info;
+ uint32_t count;
+
++#ifndef PRINTER_SUPPORT
++ return False;
++#endif
++
+ if (!str1 || !str2 || !p) {
+ return False;
+ }
+@@ -5374,6 +5410,10 @@ static bool api_WPrintDriverEnum(struct
+ int succnt;
+ struct pack_desc desc;
+
++#ifndef PRINTER_SUPPORT
++ return False;
++#endif
++
+ if (!str1 || !str2 || !p) {
+ return False;
+ }
+@@ -5438,6 +5478,10 @@ static bool api_WPrintQProcEnum(struct s
+ int succnt;
+ struct pack_desc desc;
+
++#ifndef PRINTER_SUPPORT
++ return False;
++#endif
++
+ if (!str1 || !str2 || !p) {
+ return False;
+ }
+@@ -5502,6 +5546,10 @@ static bool api_WPrintPortEnum(struct sm
+ int succnt;
+ struct pack_desc desc;
+
++#ifndef PRINTER_SUPPORT
++ return False;
++#endif
++
+ if (!str1 || !str2 || !p) {
+ return False;
+ }
+--- a/source3/smbd/server_exit.c
++++ b/source3/smbd/server_exit.c
+@@ -141,7 +141,9 @@ static void exit_server_common(enum serv
+ rpc_eventlog_shutdown();
+ rpc_ntsvcs_shutdown();
+ rpc_svcctl_shutdown();
++#ifdef PRINTER_SUPPORT
+ rpc_spoolss_shutdown();
++#endif
+
+ rpc_srvsvc_shutdown();
+ rpc_winreg_shutdown();
+--- a/source3/smbd/open.c
++++ b/source3/smbd/open.c
+@@ -1566,6 +1566,9 @@ static NTSTATUS open_file_ntcreate(conne
+ * Most of the passed parameters are ignored.
+ */
+
++#ifndef PRINTER_SUPPORT
++ return NT_STATUS_ACCESS_DENIED;
++#endif
+ if (pinfo) {
+ *pinfo = FILE_WAS_CREATED;
+ }
+--- a/source3/smbd/close.c
++++ b/source3/smbd/close.c
+@@ -643,6 +643,9 @@ static NTSTATUS close_normal_file(struct
+ status = ntstatus_keeperror(status, tmp);
+
+ if (fsp->print_file) {
++#ifndef PRINTER_SUPPORT
++ return NT_STATUS_OK;
++#endif
+ /* FIXME: return spool errors */
+ print_spool_end(fsp, close_type);
+ file_free(req, fsp);
+--- a/source3/smbd/fileio.c
++++ b/source3/smbd/fileio.c
+@@ -298,6 +298,10 @@ ssize_t write_file(struct smb_request *r
+ uint32_t t;
+ int ret;
+
++#ifndef PRINTER_SUPPORT
++ return -1;
++#endif
++
+ ret = print_spool_write(fsp, data, n, pos, &t);
+ if (ret) {
+ errno = ret;
+--- a/source3/smbd/smb2_create.c
++++ b/source3/smbd/smb2_create.c
+@@ -486,7 +486,10 @@ static struct tevent_req *smbd_smb2_crea
+ info = FILE_WAS_OPENED;
+ } else if (CAN_PRINT(smb1req->conn)) {
+ status = file_new(smb1req, smb1req->conn, &result);
+- if(!NT_STATUS_IS_OK(status)) {
++#ifdef PRINTER_SUPPORT
++ if(!NT_STATUS_IS_OK(status))
++#endif
++ {
+ tevent_req_nterror(req, status);
+ return tevent_req_post(req, ev);
+ }
+--- a/source3/rpc_server/svcctl/srv_svcctl_nt.c
++++ b/source3/rpc_server/svcctl/srv_svcctl_nt.c
+@@ -85,9 +85,11 @@ bool init_service_op_table( void )
+
+ /* add builtin services */
+
++#ifdef PRINTER_SUPPORT
+ svcctl_ops[i].name = talloc_strdup( svcctl_ops, "Spooler" );
+ svcctl_ops[i].ops = &spoolss_svc_ops;
+ i++;
++#endif
+
+ svcctl_ops[i].name = talloc_strdup( svcctl_ops, "NETLOGON" );
+ svcctl_ops[i].ops = &netlogon_svc_ops;
+--- a/source3/librpc/rpc/rpc_common.c
++++ b/source3/librpc/rpc/rpc_common.c
+@@ -113,9 +113,11 @@ static bool initialize_interfaces(void)
+ if (!smb_register_ndr_interface(&ndr_table_winreg)) {
+ return false;
+ }
++#ifdef PRINTER_SUPPORT
+ if (!smb_register_ndr_interface(&ndr_table_spoolss)) {
+ return false;
+ }
++#endif
+ if (!smb_register_ndr_interface(&ndr_table_netdfs)) {
+ return false;
+ }
+--- a/source3/smbd/process.c
++++ b/source3/smbd/process.c
+@@ -2476,8 +2476,10 @@ static bool housekeeping_fn(const struct
+
+ change_to_root_user();
+
++#ifdef PRINTER_SUPPORT
+ /* update printer queue caches if necessary */
+ update_monitored_printq_cache(sconn->msg_ctx);
++#endif
+
+ /* check if we need to reload services */
+ check_reload(sconn, time_mono(NULL));
+--- a/source3/smbd/server.c
++++ b/source3/smbd/server.c
+@@ -126,7 +126,9 @@ static void smb_pcap_updated(struct mess
+ {
+ struct tevent_context *ev_ctx =
+ talloc_get_type_abort(private_data, struct tevent_context);
+-
++#ifndef PRINTER_SUPPORT
++ return;
++#endif
+ DEBUG(10,("Got message saying pcap was updated. Reloading.\n"));
+ change_to_root_user();
+ reload_printers(ev_ctx, msg);
+@@ -1231,6 +1233,7 @@ extern void build_options(bool screen);
+ * The print backend init also migrates the printing tdb's,
+ * this requires a winreg pipe.
+ */
++#ifdef PRINTER_SUPPORT
+ if (!print_backend_init(smbd_messaging_context()))
+ exit(1);
+
+@@ -1262,7 +1265,7 @@ extern void build_options(bool screen);
+ smbd_messaging_context());
+ }
+ }
+-
++#endif
+ if (!is_daemon) {
+ /* inetd mode */
+ TALLOC_FREE(frame);
diff --git a/package/network/services/samba36/patches/210-remove_ad_support.patch b/package/network/services/samba36/patches/210-remove_ad_support.patch
new file mode 100644
index 0000000..1a10a30
--- /dev/null
+++ b/package/network/services/samba36/patches/210-remove_ad_support.patch
@@ -0,0 +1,88 @@
+--- a/source3/librpc/rpc/rpc_common.c
++++ b/source3/librpc/rpc/rpc_common.c
+@@ -95,9 +95,11 @@ static bool initialize_interfaces(void)
+ if (!smb_register_ndr_interface(&ndr_table_lsarpc)) {
+ return false;
+ }
++#ifdef ACTIVE_DIRECTORY
+ if (!smb_register_ndr_interface(&ndr_table_dssetup)) {
+ return false;
+ }
++#endif
+ if (!smb_register_ndr_interface(&ndr_table_samr)) {
+ return false;
+ }
+@@ -141,9 +143,11 @@ static bool initialize_interfaces(void)
+ if (!smb_register_ndr_interface(&ndr_table_epmapper)) {
+ return false;
+ }
++#ifdef ACTIVE_DIRECTORY
+ if (!smb_register_ndr_interface(&ndr_table_drsuapi)) {
+ return false;
+ }
++#endif
+ return true;
+ }
+
+--- a/source3/rpc_server/rpc_ep_setup.c
++++ b/source3/rpc_server/rpc_ep_setup.c
+@@ -918,6 +918,7 @@ static bool netdfs_init_cb(void *ptr)
+ return true;
+ }
+
++#ifdef ACTIVE_DIRECTORY
+ static bool dssetup_init_cb(void *ptr)
+ {
+ struct dcesrv_ep_context *ep_ctx =
+@@ -966,6 +967,7 @@ static bool dssetup_init_cb(void *ptr)
+
+ return true;
+ }
++#endif
+
+ static bool wkssvc_init_cb(void *ptr)
+ {
+@@ -1172,12 +1174,14 @@ bool dcesrv_ep_setup(struct tevent_conte
+ }
+ #endif
+
++#ifdef ACTIVE_DIRECTORY
+ dssetup_cb.init = dssetup_init_cb;
+ dssetup_cb.shutdown = NULL;
+ dssetup_cb.private_data = ep_ctx;
+ if (!NT_STATUS_IS_OK(rpc_dssetup_init(&dssetup_cb))) {
+ return false;
+ }
++#endif
+
+ wkssvc_cb.init = wkssvc_init_cb;
+ wkssvc_cb.shutdown = NULL;
+--- a/source3/smbd/server_exit.c
++++ b/source3/smbd/server_exit.c
+@@ -132,7 +132,9 @@ static void exit_server_common(enum serv
+
+ if (am_parent) {
+ rpc_wkssvc_shutdown();
++#ifdef ACTIVE_DIRECTORY
+ rpc_dssetup_shutdown();
++#endif
+ #ifdef DEVELOPER
+ rpc_rpcecho_shutdown();
+ #endif
+--- a/source3/rpc_client/cli_pipe.c
++++ b/source3/rpc_client/cli_pipe.c
+@@ -2874,12 +2874,14 @@ NTSTATUS cli_rpc_pipe_open_noauth_transp
+ status = rpc_pipe_bind(result, auth);
+ if (!NT_STATUS_IS_OK(status)) {
+ int lvl = 0;
++#ifdef ACTIVE_DIRECTORY
+ if (ndr_syntax_id_equal(interface,
+ &ndr_table_dssetup.syntax_id)) {
+ /* non AD domains just don't have this pipe, avoid
+ * level 0 statement in that case - gd */
+ lvl = 3;
+ }
++#endif
+ DEBUG(lvl, ("cli_rpc_pipe_open_noauth: rpc_pipe_bind for pipe "
+ "%s failed with error %s\n",
+ get_pipe_name_from_syntax(talloc_tos(), interface),
diff --git a/package/network/services/samba36/patches/220-remove_services.patch b/package/network/services/samba36/patches/220-remove_services.patch
new file mode 100644
index 0000000..498232d
--- /dev/null
+++ b/package/network/services/samba36/patches/220-remove_services.patch
@@ -0,0 +1,98 @@
+--- a/source3/librpc/rpc/rpc_common.c
++++ b/source3/librpc/rpc/rpc_common.c
+@@ -131,6 +131,7 @@ static bool initialize_interfaces(void)
+ if (!smb_register_ndr_interface(&ndr_table_initshutdown)) {
+ return false;
+ }
++#ifdef EXTRA_SERVICES
+ if (!smb_register_ndr_interface(&ndr_table_svcctl)) {
+ return false;
+ }
+@@ -140,6 +141,7 @@ static bool initialize_interfaces(void)
+ if (!smb_register_ndr_interface(&ndr_table_ntsvcs)) {
+ return false;
+ }
++#endif
+ if (!smb_register_ndr_interface(&ndr_table_epmapper)) {
+ return false;
+ }
+--- a/source3/rpc_server/rpc_ep_setup.c
++++ b/source3/rpc_server/rpc_ep_setup.c
+@@ -697,6 +697,7 @@ static bool spoolss_shutdown_cb(void *pt
+ return true;
+ }
+
++#ifdef EXTRA_SERVICES
+ static bool svcctl_init_cb(void *ptr)
+ {
+ struct dcesrv_ep_context *ep_ctx =
+@@ -733,6 +734,7 @@ static bool svcctl_init_cb(void *ptr)
+
+ return true;
+ }
++#endif
+
+ static bool svcctl_shutdown_cb(void *ptr)
+ {
+@@ -741,6 +743,8 @@ static bool svcctl_shutdown_cb(void *ptr
+ return true;
+ }
+
++#ifdef EXTRA_SERVICES
++
+ static bool ntsvcs_init_cb(void *ptr)
+ {
+ struct dcesrv_ep_context *ep_ctx =
+@@ -802,6 +806,7 @@ static bool eventlog_init_cb(void *ptr)
+
+ return true;
+ }
++#endif
+
+ static bool initshutdown_init_cb(void *ptr)
+ {
+@@ -1130,6 +1135,7 @@ bool dcesrv_ep_setup(struct tevent_conte
+ }
+ }
+
++#ifdef EXTRA_SERVICES
+ svcctl_cb.init = svcctl_init_cb;
+ svcctl_cb.shutdown = svcctl_shutdown_cb;
+ svcctl_cb.private_data = ep_ctx;
+@@ -1150,6 +1156,7 @@ bool dcesrv_ep_setup(struct tevent_conte
+ if (!NT_STATUS_IS_OK(rpc_eventlog_init(&eventlog_cb))) {
+ return false;
+ }
++#endif
+
+ initshutdown_cb.init = initshutdown_init_cb;
+ initshutdown_cb.shutdown = NULL;
+--- a/source3/smbd/server_exit.c
++++ b/source3/smbd/server_exit.c
+@@ -140,9 +140,11 @@ static void exit_server_common(enum serv
+ #endif
+ rpc_netdfs_shutdown();
+ rpc_initshutdown_shutdown();
++#ifdef EXTRA_SERVICES
+ rpc_eventlog_shutdown();
+- rpc_ntsvcs_shutdown();
+ rpc_svcctl_shutdown();
++ rpc_ntsvcs_shutdown();
++#endif
+ #ifdef PRINTER_SUPPORT
+ rpc_spoolss_shutdown();
+ #endif
+--- a/source3/rpcclient/rpcclient.c
++++ b/source3/rpcclient/rpcclient.c
+@@ -637,9 +637,11 @@ static struct cmd_set *rpcclient_command
+ shutdown_commands,
+ test_commands,
+ wkssvc_commands,
++#ifdef EXTRA_SERVICES
+ ntsvcs_commands,
+ drsuapi_commands,
+ eventlog_commands,
++#endif
+ winreg_commands,
+ NULL
+ };
diff --git a/package/network/services/samba36/patches/230-remove_winreg_support.patch b/package/network/services/samba36/patches/230-remove_winreg_support.patch
new file mode 100644
index 0000000..df2be4f
--- /dev/null
+++ b/package/network/services/samba36/patches/230-remove_winreg_support.patch
@@ -0,0 +1,146 @@
+--- a/source3/rpc_server/rpc_ep_setup.c
++++ b/source3/rpc_server/rpc_ep_setup.c
+@@ -409,6 +409,7 @@ static bool epmapper_shutdown_cb(void *p
+ return true;
+ }
+
++#ifdef WINREG_SUPPORT
+ static bool winreg_init_cb(void *ptr)
+ {
+ struct dcesrv_ep_context *ep_ctx =
+@@ -456,6 +457,7 @@ static bool winreg_init_cb(void *ptr)
+
+ return true;
+ }
++#endif
+
+ static bool srvsvc_init_cb(void *ptr)
+ {
+@@ -710,10 +712,12 @@ static bool svcctl_init_cb(void *ptr)
+ "epmapper",
+ "none");
+
++#ifdef WINREG_SUPPORT
+ ok = svcctl_init_winreg(ep_ctx->msg_ctx);
+ if (!ok) {
+ return false;
+ }
++#endif
+
+ /* initialize the control hooks */
+ init_service_op_table();
+@@ -785,10 +789,12 @@ static bool eventlog_init_cb(void *ptr)
+ "epmapper",
+ "none");
+
++#ifdef WINREG_SUPPORT
+ ok = eventlog_init_winreg(ep_ctx->msg_ctx);
+ if (!ok) {
+ return false;
+ }
++#endif
+
+ if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
+ StrCaseCmp(rpcsrv_type, "daemon") == 0) {
+@@ -1077,12 +1083,14 @@ bool dcesrv_ep_setup(struct tevent_conte
+ }
+ }
+
++#ifdef WINREG_SUPPORT
+ winreg_cb.init = winreg_init_cb;
+ winreg_cb.shutdown = NULL;
+ winreg_cb.private_data = ep_ctx;
+ if (!NT_STATUS_IS_OK(rpc_winreg_init(&winreg_cb))) {
+ return false;
+ }
++#endif
+
+ srvsvc_cb.init = srvsvc_init_cb;
+ srvsvc_cb.shutdown = NULL;
+--- a/source3/smbd/server_exit.c
++++ b/source3/smbd/server_exit.c
+@@ -150,7 +150,9 @@ static void exit_server_common(enum serv
+ #endif
+
+ rpc_srvsvc_shutdown();
++#ifdef WINREG_SUPPORT
+ rpc_winreg_shutdown();
++#endif
+
+ rpc_netlogon_shutdown();
+ rpc_samr_shutdown();
+--- a/source3/librpc/rpc/rpc_common.c
++++ b/source3/librpc/rpc/rpc_common.c
+@@ -112,9 +112,11 @@ static bool initialize_interfaces(void)
+ if (!smb_register_ndr_interface(&ndr_table_wkssvc)) {
+ return false;
+ }
++#ifdef WINREG_SUPPORT
+ if (!smb_register_ndr_interface(&ndr_table_winreg)) {
+ return false;
+ }
++#endif
+ #ifdef PRINTER_SUPPORT
+ if (!smb_register_ndr_interface(&ndr_table_spoolss)) {
+ return false;
+--- a/source3/rpc_server/svcctl/srv_svcctl_nt.c
++++ b/source3/rpc_server/svcctl/srv_svcctl_nt.c
+@@ -95,9 +95,11 @@ bool init_service_op_table( void )
+ svcctl_ops[i].ops = &netlogon_svc_ops;
+ i++;
+
++#ifdef WINREG_SUPPORT
+ svcctl_ops[i].name = talloc_strdup( svcctl_ops, "RemoteRegistry" );
+ svcctl_ops[i].ops = &winreg_svc_ops;
+ i++;
++#endif
+
+ svcctl_ops[i].name = talloc_strdup( svcctl_ops, "WINS" );
+ svcctl_ops[i].ops = &wins_svc_ops;
+--- a/source3/services/svc_winreg_glue.c
++++ b/source3/services/svc_winreg_glue.c
+@@ -88,6 +88,10 @@ struct security_descriptor *svcctl_get_s
+ NTSTATUS status;
+ WERROR result = WERR_OK;
+
++#ifndef WINREG_SUPPORT
++ return NULL;
++#endif
++
+ key = talloc_asprintf(mem_ctx,
+ "%s\\%s\\Security",
+ TOP_LEVEL_SERVICES_KEY, name);
+@@ -161,6 +165,10 @@ bool svcctl_set_secdesc(struct messaging
+ NTSTATUS status;
+ WERROR result = WERR_OK;
+
++#ifndef WINREG_SUPPORT
++ return false;
++#endif
++
+ tmp_ctx = talloc_stackframe();
+ if (tmp_ctx == NULL) {
+ return false;
+@@ -272,6 +280,10 @@ const char *svcctl_get_string_value(TALL
+ NTSTATUS status;
+ WERROR result = WERR_OK;
+
++#ifndef WINREG_SUPPORT
++ return NULL;
++#endif
++
+ tmp_ctx = talloc_stackframe();
+ if (tmp_ctx == NULL) {
+ return NULL;
+--- a/source3/rpcclient/rpcclient.c
++++ b/source3/rpcclient/rpcclient.c
+@@ -642,7 +642,9 @@ static struct cmd_set *rpcclient_command
+ drsuapi_commands,
+ eventlog_commands,
+ #endif
++#ifdef WINREG_SUPPORT
+ winreg_commands,
++#endif
+ NULL
+ };
+
diff --git a/package/network/services/samba36/patches/240-remove_dfs_api.patch b/package/network/services/samba36/patches/240-remove_dfs_api.patch
new file mode 100644
index 0000000..f4d432e
--- /dev/null
+++ b/package/network/services/samba36/patches/240-remove_dfs_api.patch
@@ -0,0 +1,71 @@
+--- a/source3/rpc_server/rpc_ep_setup.c
++++ b/source3/rpc_server/rpc_ep_setup.c
+@@ -881,6 +881,7 @@ static bool rpcecho_init_cb(void *ptr) {
+
+ #endif
+
++#ifdef DFS_SUPPORT
+ static bool netdfs_init_cb(void *ptr)
+ {
+ struct dcesrv_ep_context *ep_ctx =
+@@ -928,6 +929,7 @@ static bool netdfs_init_cb(void *ptr)
+
+ return true;
+ }
++#endif
+
+ #ifdef ACTIVE_DIRECTORY
+ static bool dssetup_init_cb(void *ptr)
+@@ -1173,12 +1175,14 @@ bool dcesrv_ep_setup(struct tevent_conte
+ return false;
+ }
+
++#ifdef DFS_SUPPORT
+ netdfs_cb.init = netdfs_init_cb;
+ netdfs_cb.shutdown = NULL;
+ netdfs_cb.private_data = ep_ctx;
+ if (!NT_STATUS_IS_OK(rpc_netdfs_init(&netdfs_cb))) {
+ return false;
+ }
++#endif
+
+ #ifdef DEVELOPER
+ rpcecho_cb.init = rpcecho_init_cb;
+--- a/source3/librpc/rpc/rpc_common.c
++++ b/source3/librpc/rpc/rpc_common.c
+@@ -122,9 +122,11 @@ static bool initialize_interfaces(void)
+ return false;
+ }
+ #endif
++#ifdef DFS_SUPPORT
+ if (!smb_register_ndr_interface(&ndr_table_netdfs)) {
+ return false;
+ }
++#endif
+ #ifdef DEVELOPER
+ if (!smb_register_ndr_interface(&ndr_table_rpcecho)) {
+ return false;
+--- a/source3/smbd/server_exit.c
++++ b/source3/smbd/server_exit.c
+@@ -138,7 +138,9 @@ static void exit_server_common(enum serv
+ #ifdef DEVELOPER
+ rpc_rpcecho_shutdown();
+ #endif
++#ifdef DFS_SUPPORT
+ rpc_netdfs_shutdown();
++#endif
+ rpc_initshutdown_shutdown();
+ #ifdef EXTRA_SERVICES
+ rpc_eventlog_shutdown();
+--- a/source3/rpcclient/rpcclient.c
++++ b/source3/rpcclient/rpcclient.c
+@@ -629,7 +629,9 @@ static struct cmd_set *rpcclient_command
+ #endif
+ netlogon_commands,
+ srvsvc_commands,
++#ifdef DFS_SUPPORT
+ dfs_commands,
++#endif
+ #ifdef DEVELOPER
+ echo_commands,
+ #endif
diff --git a/package/network/services/samba36/patches/250-remove_domain_logon.patch b/package/network/services/samba36/patches/250-remove_domain_logon.patch
new file mode 100644
index 0000000..e97285b
--- /dev/null
+++ b/package/network/services/samba36/patches/250-remove_domain_logon.patch
@@ -0,0 +1,185 @@
+--- a/source3/rpc_server/rpc_ep_setup.c
++++ b/source3/rpc_server/rpc_ep_setup.c
+@@ -606,6 +606,7 @@ static bool samr_init_cb(void *ptr)
+ return true;
+ }
+
++#ifdef NETLOGON_SUPPORT
+ static bool netlogon_init_cb(void *ptr)
+ {
+ struct dcesrv_ep_context *ep_ctx =
+@@ -654,6 +655,7 @@ static bool netlogon_init_cb(void *ptr)
+
+ return true;
+ }
++#endif
+
+ static bool spoolss_init_cb(void *ptr)
+ {
+@@ -1116,12 +1118,15 @@ bool dcesrv_ep_setup(struct tevent_conte
+ return false;
+ }
+
++#ifdef NETLOGON_SUPPORT
+ netlogon_cb.init = netlogon_init_cb;
+ netlogon_cb.shutdown = NULL;
+ netlogon_cb.private_data = ep_ctx;
+ if (!NT_STATUS_IS_OK(rpc_netlogon_init(&netlogon_cb))) {
+ return false;
+ }
++#endif
++
+
+ rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
+ "rpc_server",
+--- a/source3/librpc/rpc/rpc_common.c
++++ b/source3/librpc/rpc/rpc_common.c
+@@ -103,9 +103,11 @@ static bool initialize_interfaces(void)
+ if (!smb_register_ndr_interface(&ndr_table_samr)) {
+ return false;
+ }
++#ifdef NETLOGON_SUPPORT
+ if (!smb_register_ndr_interface(&ndr_table_netlogon)) {
+ return false;
+ }
++#endif
+ if (!smb_register_ndr_interface(&ndr_table_srvsvc)) {
+ return false;
+ }
+--- a/source3/smbd/server_exit.c
++++ b/source3/smbd/server_exit.c
+@@ -156,7 +156,9 @@ static void exit_server_common(enum serv
+ rpc_winreg_shutdown();
+ #endif
+
++#ifdef NETLOGON_SUPPORT
+ rpc_netlogon_shutdown();
++#endif
+ rpc_samr_shutdown();
+ rpc_lsarpc_shutdown();
+ }
+--- a/source3/rpc_server/svcctl/srv_svcctl_nt.c
++++ b/source3/rpc_server/svcctl/srv_svcctl_nt.c
+@@ -91,9 +91,11 @@ bool init_service_op_table( void )
+ i++;
+ #endif
+
++#ifdef NETLOGON_SUPPORT
+ svcctl_ops[i].name = talloc_strdup( svcctl_ops, "NETLOGON" );
+ svcctl_ops[i].ops = &netlogon_svc_ops;
+ i++;
++#endif
+
+ #ifdef WINREG_SUPPORT
+ svcctl_ops[i].name = talloc_strdup( svcctl_ops, "RemoteRegistry" );
+--- a/source3/nmbd/nmbd_processlogon.c
++++ b/source3/nmbd/nmbd_processlogon.c
+@@ -320,6 +320,10 @@ void process_logon_packet(struct packet_
+ NTSTATUS status;
+ const char *pdc_name;
+
++#ifndef NETLOGON_SUPPORT
++ return;
++#endif
++
+ in_addr_to_sockaddr_storage(&ss, p->ip);
+ pss = iface_ip((struct sockaddr *)&ss);
+ if (!pss) {
+--- a/source3/rpcclient/rpcclient.c
++++ b/source3/rpcclient/rpcclient.c
+@@ -627,7 +627,9 @@ static struct cmd_set *rpcclient_command
+ #ifdef PRINTER_SUPPORT
+ spoolss_commands,
+ #endif
++#ifdef NETLOGON_SUPPORT
+ netlogon_commands,
++#endif
+ srvsvc_commands,
+ #ifdef DFS_SUPPORT
+ dfs_commands,
+--- a/source3/rpc_server/wkssvc/srv_wkssvc_nt.c
++++ b/source3/rpc_server/wkssvc/srv_wkssvc_nt.c
+@@ -820,6 +820,10 @@ WERROR _wkssvc_NetrJoinDomain2(struct pi
+ WERROR werr;
+ struct security_token *token = p->session_info->security_token;
+
++#ifndef NETLOGON_SUPPORT
++ return WERR_NOT_SUPPORTED;
++#endif
++
+ if (!r->in.domain_name) {
+ return WERR_INVALID_PARAM;
+ }
+@@ -897,6 +901,10 @@ WERROR _wkssvc_NetrUnjoinDomain2(struct
+ WERROR werr;
+ struct security_token *token = p->session_info->security_token;
+
++#ifndef NETLOGON_SUPPORT
++ return WERR_NOT_SUPPORTED;
++#endif
++
+ if (!r->in.account || !r->in.encrypted_password) {
+ return WERR_INVALID_PARAM;
+ }
+--- a/source3/libsmb/trusts_util.c
++++ b/source3/libsmb/trusts_util.c
+@@ -46,9 +46,11 @@ NTSTATUS trust_pw_change_and_store_it(st
+ NTSTATUS nt_status;
+
+ switch (sec_channel_type) {
++#ifdef NETLOGON_SUPPORT
+ case SEC_CHAN_WKSTA:
+ case SEC_CHAN_DOMAIN:
+ break;
++#endif
+ default:
+ return NT_STATUS_NOT_SUPPORTED;
+ }
+@@ -159,6 +161,11 @@ bool enumerate_domain_trusts( TALLOC_CTX
+ *num_domains = 0;
+ *sids = NULL;
+
++#ifndef NETLOGON_SUPPORT
++ return False;
++#endif
++
++
+ /* lookup a DC first */
+
+ if ( !get_dc_name(domain, NULL, dc_name, &dc_ss) ) {
+@@ -243,6 +250,10 @@ NTSTATUS change_trust_account_password(
+ struct cli_state *cli = NULL;
+ struct rpc_pipe_client *netlogon_pipe = NULL;
+
++#ifndef NETLOGON_SUPPORT
++ return NT_STATUS_UNSUCCESSFUL;
++#endif
++
+ DEBUG(5,("change_trust_account_password: Attempting to change trust account password in domain %s....\n",
+ domain));
+
+--- a/source3/auth/auth_domain.c
++++ b/source3/auth/auth_domain.c
+@@ -538,7 +538,9 @@ static NTSTATUS auth_init_trustdomain(st
+
+ NTSTATUS auth_domain_init(void)
+ {
++#ifdef NETLOGON_SUPPORT
+ smb_register_auth(AUTH_INTERFACE_VERSION, "trustdomain", auth_init_trustdomain);
+ smb_register_auth(AUTH_INTERFACE_VERSION, "ntdomain", auth_init_ntdomain);
++#endif
+ return NT_STATUS_OK;
+ }
+--- a/source3/smbd/process.c
++++ b/source3/smbd/process.c
+@@ -2484,8 +2484,10 @@ static bool housekeeping_fn(const struct
+ /* check if we need to reload services */
+ check_reload(sconn, time_mono(NULL));
+
++#ifdef NETLOGON_SUPPORT
+ /* Change machine password if neccessary. */
+ attempt_machine_password_change();
++#endif
+
+ /*
+ * Force a log file check.
diff --git a/package/network/services/samba36/patches/260-remove_samr.patch b/package/network/services/samba36/patches/260-remove_samr.patch
new file mode 100644
index 0000000..eda6129
--- /dev/null
+++ b/package/network/services/samba36/patches/260-remove_samr.patch
@@ -0,0 +1,155 @@
+--- a/source3/rpc_server/rpc_handles.c
++++ b/source3/rpc_server/rpc_handles.c
+@@ -59,8 +59,11 @@ struct handle_list {
+
+ static bool is_samr_lsa_pipe(const struct ndr_syntax_id *syntax)
+ {
+- return (ndr_syntax_id_equal(syntax, &ndr_table_samr.syntax_id)
+- || ndr_syntax_id_equal(syntax, &ndr_table_lsarpc.syntax_id));
++ return
++#ifdef SAMR_SUPPORT
++ ndr_syntax_id_equal(syntax, &ndr_table_samr.syntax_id) ||
++#endif
++ ndr_syntax_id_equal(syntax, &ndr_table_lsarpc.syntax_id);
+ }
+
+ size_t num_pipe_handles(struct pipes_struct *p)
+--- a/source3/librpc/rpc/rpc_common.c
++++ b/source3/librpc/rpc/rpc_common.c
+@@ -100,9 +100,11 @@ static bool initialize_interfaces(void)
+ return false;
+ }
+ #endif
++#ifdef SAMR_SUPPORT
+ if (!smb_register_ndr_interface(&ndr_table_samr)) {
+ return false;
+ }
++#endif
+ #ifdef NETLOGON_SUPPORT
+ if (!smb_register_ndr_interface(&ndr_table_netlogon)) {
+ return false;
+--- a/source3/rpc_server/rpc_ep_setup.c
++++ b/source3/rpc_server/rpc_ep_setup.c
+@@ -557,6 +557,7 @@ static bool lsarpc_init_cb(void *ptr)
+ return true;
+ }
+
++#ifdef SAMR_SUPPORT
+ static bool samr_init_cb(void *ptr)
+ {
+ struct dcesrv_ep_context *ep_ctx =
+@@ -605,6 +606,7 @@ static bool samr_init_cb(void *ptr)
+
+ return true;
+ }
++#endif
+
+ #ifdef NETLOGON_SUPPORT
+ static bool netlogon_init_cb(void *ptr)
+@@ -1111,12 +1113,14 @@ bool dcesrv_ep_setup(struct tevent_conte
+ return false;
+ }
+
++#ifdef SAMR_SUPPORT
+ samr_cb.init = samr_init_cb;
+ samr_cb.shutdown = NULL;
+ samr_cb.private_data = ep_ctx;
+ if (!NT_STATUS_IS_OK(rpc_samr_init(&samr_cb))) {
+ return false;
+ }
++#endif
+
+ #ifdef NETLOGON_SUPPORT
+ netlogon_cb.init = netlogon_init_cb;
+--- a/source3/smbd/server_exit.c
++++ b/source3/smbd/server_exit.c
+@@ -159,7 +159,9 @@ static void exit_server_common(enum serv
+ #ifdef NETLOGON_SUPPORT
+ rpc_netlogon_shutdown();
+ #endif
++#ifdef SAMR_SUPPORT
+ rpc_samr_shutdown();
++#endif
+ rpc_lsarpc_shutdown();
+ }
+
+--- a/source3/rpcclient/rpcclient.c
++++ b/source3/rpcclient/rpcclient.c
+@@ -623,7 +623,9 @@ static struct cmd_set *rpcclient_command
+ rpcclient_commands,
+ lsarpc_commands,
+ ds_commands,
++#ifdef SAMR_SUPPORT
+ samr_commands,
++#endif
+ #ifdef PRINTER_SUPPORT
+ spoolss_commands,
+ #endif
+--- a/source3/smbd/lanman.c
++++ b/source3/smbd/lanman.c
+@@ -2353,6 +2353,10 @@ static bool api_RNetGroupEnum(struct smb
+ NTSTATUS status, result;
+ struct dcerpc_binding_handle *b;
+
++#ifndef SAMR_SUPPORT
++ return False;
++#endif
++
+ if (!str1 || !str2 || !p) {
+ return False;
+ }
+@@ -2541,6 +2545,10 @@ static bool api_NetUserGetGroups(struct
+ NTSTATUS status, result;
+ struct dcerpc_binding_handle *b;
+
++#ifndef SAMR_SUPPORT
++ return False;
++#endif
++
+ if (!str1 || !str2 || !UserName || !p) {
+ return False;
+ }
+@@ -2733,6 +2741,10 @@ static bool api_RNetUserEnum(struct smbd
+
+ struct dcerpc_binding_handle *b;
+
++#ifndef SAMR_SUPPORT
++ return False;
++#endif
++
+ if (!str1 || !str2 || !p) {
+ return False;
+ }
+@@ -2979,6 +2991,10 @@ static bool api_SetUserPassword(struct s
+ int min_pwd_length;
+ struct dcerpc_binding_handle *b = NULL;
+
++#ifndef SAMR_SUPPORT
++ return False;
++#endif
++
+ /* Skip 2 strings. */
+ p = skip_string(param,tpscnt,np);
+ p = skip_string(param,tpscnt,p);
+@@ -3224,6 +3240,10 @@ static bool api_SamOEMChangePassword(str
+ int bufsize;
+ struct dcerpc_binding_handle *b;
+
++#ifndef SAMR_SUPPORT
++ return False;
++#endif
++
+ *rparam_len = 4;
+ *rparam = smb_realloc_limit(*rparam,*rparam_len);
+ if (!*rparam) {
+@@ -4265,6 +4285,10 @@ static bool api_RNetUserGetInfo(struct s
+ union samr_UserInfo *info;
+ struct dcerpc_binding_handle *b = NULL;
+
++#ifndef SAMR_SUPPORT
++ return False;
++#endif
++
+ if (!str1 || !str2 || !UserName || !p) {
+ return False;
+ }
diff --git a/package/network/services/samba36/patches/270-remove_registry_backend.patch b/package/network/services/samba36/patches/270-remove_registry_backend.patch
new file mode 100644
index 0000000..7714b86
--- /dev/null
+++ b/package/network/services/samba36/patches/270-remove_registry_backend.patch
@@ -0,0 +1,43 @@
+--- a/source3/lib/smbconf/smbconf_init.c
++++ b/source3/lib/smbconf/smbconf_init.c
+@@ -68,9 +68,12 @@ sbcErr smbconf_init(TALLOC_CTX *mem_ctx,
+ }
+ }
+
++#ifdef REGISTRY_BACKEND
+ if (strequal(backend, "registry") || strequal(backend, "reg")) {
+ err = smbconf_init_reg(mem_ctx, conf_ctx, path);
+- } else if (strequal(backend, "file") || strequal(backend, "txt")) {
++ } else
++#endif
++ if (strequal(backend, "file") || strequal(backend, "txt")) {
+ err = smbconf_init_txt(mem_ctx, conf_ctx, path);
+ } else if (sep == NULL) {
+ /*
+--- a/source3/lib/netapi/serverinfo.c
++++ b/source3/lib/netapi/serverinfo.c
+@@ -557,7 +557,10 @@ static WERROR NetServerSetInfo_l_1005(st
+ return WERR_INVALID_PARAM;
+ }
+
+- if (!lp_config_backend_is_registry()) {
++#ifdef REGISTRY_BACKEND
++ if (!lp_config_backend_is_registry())
++#endif
++ {
+ libnetapi_set_error_string(ctx,
+ "Configuration manipulation requested but not "
+ "supported by backend");
+--- a/source3/smbd/server.c
++++ b/source3/smbd/server.c
+@@ -1184,8 +1184,10 @@ extern void build_options(bool screen);
+ exit(1);
+ }
+
++#ifdef REGISTRY_BACKEND
+ if (!W_ERROR_IS_OK(registry_init_full()))
+ exit(1);
++#endif
+
+ /* Open the share_info.tdb here, so we don't have to open
+ after the fork on every single connection. This is a small
diff --git a/package/network/services/samba36/patches/280-strip_srvsvc.patch b/package/network/services/samba36/patches/280-strip_srvsvc.patch
new file mode 100644
index 0000000..b93e3fc
--- /dev/null
+++ b/package/network/services/samba36/patches/280-strip_srvsvc.patch
@@ -0,0 +1,143 @@
+--- a/source3/smbd/lanman.c
++++ b/source3/smbd/lanman.c
+@@ -2197,6 +2197,10 @@ static bool api_RNetShareAdd(struct smbd
+ struct srvsvc_NetShareInfo2 info2;
+ struct dcerpc_binding_handle *b;
+
++#ifndef SRVSVC_SUPPORT
++ return False;
++#endif
++
+ if (!str1 || !str2 || !p) {
+ return False;
+ }
+@@ -3838,10 +3842,7 @@ static bool api_RNetServerGetInfo(struct
+ NTSTATUS status;
+ WERROR werr;
+ TALLOC_CTX *mem_ctx = talloc_tos();
+- struct rpc_pipe_client *cli = NULL;
+- union srvsvc_NetSrvInfo info;
+ int errcode;
+- struct dcerpc_binding_handle *b;
+
+ if (!str1 || !str2 || !p) {
+ return False;
+@@ -3904,66 +3905,16 @@ static bool api_RNetServerGetInfo(struct
+ p = *rdata;
+ p2 = p + struct_len;
+
+- status = rpc_pipe_open_interface(mem_ctx, &ndr_table_srvsvc.syntax_id,
+- conn->session_info,
+- &conn->sconn->client_id,
+- conn->sconn->msg_ctx,
+- &cli);
+- if (!NT_STATUS_IS_OK(status)) {
+- DEBUG(0,("api_RNetServerGetInfo: could not connect to srvsvc: %s\n",
+- nt_errstr(status)));
+- errcode = W_ERROR_V(ntstatus_to_werror(status));
+- goto out;
+- }
+-
+- b = cli->binding_handle;
+-
+- status = dcerpc_srvsvc_NetSrvGetInfo(b, mem_ctx,
+- NULL,
+- 101,
+- &info,
+- &werr);
+- if (!NT_STATUS_IS_OK(status)) {
+- errcode = W_ERROR_V(ntstatus_to_werror(status));
+- goto out;
+- }
+- if (!W_ERROR_IS_OK(werr)) {
+- errcode = W_ERROR_V(werr);
+- goto out;
+- }
+-
+- if (info.info101 == NULL) {
+- errcode = W_ERROR_V(WERR_INVALID_PARAM);
+- goto out;
+- }
+-
+ if (uLevel != 20) {
+- srvstr_push(NULL, 0, p, info.info101->server_name, 16,
++ srvstr_push(NULL, 0, p, global_myname(), 16,
+ STR_ASCII|STR_UPPER|STR_TERMINATE);
+- }
++ }
+ p += 16;
+ if (uLevel > 0) {
+- SCVAL(p,0,info.info101->version_major);
+- SCVAL(p,1,info.info101->version_minor);
+- SIVAL(p,2,info.info101->server_type);
+-
+- if (mdrcnt == struct_len) {
+- SIVAL(p,6,0);
+- } else {
+- SIVAL(p,6,PTR_DIFF(p2,*rdata));
+- if (mdrcnt - struct_len <= 0) {
+- return false;
+- }
+- push_ascii(p2,
+- info.info101->comment,
+- MIN(mdrcnt - struct_len,
+- MAX_SERVER_STRING_LENGTH),
+- STR_TERMINATE);
+- p2 = skip_string(*rdata,*rdata_len,p2);
+- if (!p2) {
+- return False;
+- }
+- }
++ SCVAL(p,0,lp_major_announce_version());
++ SCVAL(p,1,lp_minor_announce_version());
++ SIVAL(p,2,lp_default_server_announce());
++ SIVAL(p,6,0);
+ }
+
+ if (uLevel > 1) {
+@@ -5654,6 +5605,10 @@ static bool api_RNetSessionEnum(struct s
+ uint32_t totalentries, resume_handle = 0;
+ uint32_t count = 0;
+
++#ifndef SRVSVC_SUPPORT
++ return False;
++#endif
++
+ if (!str1 || !str2 || !p) {
+ return False;
+ }
+--- a/source3/rpc_server/srvsvc/srv_srvsvc_nt.c
++++ b/source3/rpc_server/srvsvc/srv_srvsvc_nt.c
+@@ -1533,6 +1533,10 @@ WERROR _srvsvc_NetShareSetInfo(struct pi
+ TALLOC_CTX *ctx = p->mem_ctx;
+ union srvsvc_NetShareInfo *info = r->in.info;
+
++#ifndef FULL_SRVSVC
++ return WERR_ACCESS_DENIED;
++#endif
++
+ DEBUG(5,("_srvsvc_NetShareSetInfo: %d\n", __LINE__));
+
+ if (!r->in.share_name) {
+@@ -1763,6 +1767,10 @@ WERROR _srvsvc_NetShareAdd(struct pipes_
+ int max_connections = 0;
+ TALLOC_CTX *ctx = p->mem_ctx;
+
++#ifndef FULL_SRVSVC
++ return WERR_ACCESS_DENIED;
++#endif
++
+ DEBUG(5,("_srvsvc_NetShareAdd: %d\n", __LINE__));
+
+ if (r->out.parm_error) {
+@@ -1945,6 +1953,10 @@ WERROR _srvsvc_NetShareDel(struct pipes_
+ struct share_params *params;
+ TALLOC_CTX *ctx = p->mem_ctx;
+
++#ifndef FULL_SRVSVC
++ return WERR_ACCESS_DENIED;
++#endif
++
+ DEBUG(5,("_srvsvc_NetShareDel: %d\n", __LINE__));
+
+ if (!r->in.share_name) {
diff --git a/package/network/services/samba36/patches/290-remove_lsa.patch b/package/network/services/samba36/patches/290-remove_lsa.patch
new file mode 100644
index 0000000..fe37d5d
--- /dev/null
+++ b/package/network/services/samba36/patches/290-remove_lsa.patch
@@ -0,0 +1,73 @@
+--- a/source3/librpc/rpc/rpc_common.c
++++ b/source3/librpc/rpc/rpc_common.c
+@@ -92,9 +92,11 @@ bool smb_register_ndr_interface(const st
+
+ static bool initialize_interfaces(void)
+ {
++#ifdef LSA_SUPPORT
+ if (!smb_register_ndr_interface(&ndr_table_lsarpc)) {
+ return false;
+ }
++#endif
+ #ifdef ACTIVE_DIRECTORY
+ if (!smb_register_ndr_interface(&ndr_table_dssetup)) {
+ return false;
+--- a/source3/smbd/server_exit.c
++++ b/source3/smbd/server_exit.c
+@@ -162,7 +162,9 @@ static void exit_server_common(enum serv
+ #ifdef SAMR_SUPPORT
+ rpc_samr_shutdown();
+ #endif
++#ifdef LSA_SUPPORT
+ rpc_lsarpc_shutdown();
++#endif
+ }
+
+ /*
+--- a/source3/rpc_server/rpc_ep_setup.c
++++ b/source3/rpc_server/rpc_ep_setup.c
+@@ -508,6 +508,7 @@ static bool srvsvc_init_cb(void *ptr)
+ return true;
+ }
+
++#ifdef LSA_SUPPORT
+ static bool lsarpc_init_cb(void *ptr)
+ {
+ struct dcesrv_ep_context *ep_ctx =
+@@ -556,6 +557,7 @@ static bool lsarpc_init_cb(void *ptr)
+
+ return true;
+ }
++#endif
+
+ #ifdef SAMR_SUPPORT
+ static bool samr_init_cb(void *ptr)
+@@ -1106,12 +1108,14 @@ bool dcesrv_ep_setup(struct tevent_conte
+ }
+
+
++#ifdef LSA_SUPPORT
+ lsarpc_cb.init = lsarpc_init_cb;
+ lsarpc_cb.shutdown = NULL;
+ lsarpc_cb.private_data = ep_ctx;
+ if (!NT_STATUS_IS_OK(rpc_lsarpc_init(&lsarpc_cb))) {
+ return false;
+ }
++#endif
+
+ #ifdef SAMR_SUPPORT
+ samr_cb.init = samr_init_cb;
+--- a/source3/rpc_server/rpc_handles.c
++++ b/source3/rpc_server/rpc_handles.c
+@@ -63,7 +63,10 @@ static bool is_samr_lsa_pipe(const struc
+ #ifdef SAMR_SUPPORT
+ ndr_syntax_id_equal(syntax, &ndr_table_samr.syntax_id) ||
+ #endif
+- ndr_syntax_id_equal(syntax, &ndr_table_lsarpc.syntax_id);
++#ifdef LSA_SUPPORT
++ ndr_syntax_id_equal(syntax, &ndr_table_lsarpc.syntax_id) ||
++#endif
++ false;
+ }
+
+ size_t num_pipe_handles(struct pipes_struct *p)
diff --git a/package/network/services/samba36/patches/300-assert_debug_level.patch b/package/network/services/samba36/patches/300-assert_debug_level.patch
new file mode 100644
index 0000000..c5b0716
--- /dev/null
+++ b/package/network/services/samba36/patches/300-assert_debug_level.patch
@@ -0,0 +1,11 @@
+--- a/lib/util/util.h
++++ b/lib/util/util.h
+@@ -53,7 +53,7 @@ extern const char *panic_action;
+ #else
+ /* redefine the assert macro for non-developer builds */
+ #define SMB_ASSERT(b) do { if (!(b)) { \
+- DEBUG(0,("PANIC: assert failed at %s(%d): %s\n", \
++ DEBUG(3,("PANIC: assert failed at %s(%d): %s\n", \
+ __FILE__, __LINE__, #b)); }} while (0)
+ #endif
+
diff --git a/package/network/services/samba36/patches/310-remove_error_strings.patch b/package/network/services/samba36/patches/310-remove_error_strings.patch
new file mode 100644
index 0000000..44342ef
--- /dev/null
+++ b/package/network/services/samba36/patches/310-remove_error_strings.patch
@@ -0,0 +1,253 @@
+--- a/libcli/util/doserr.c
++++ b/libcli/util/doserr.c
+@@ -28,6 +28,7 @@ struct werror_code_struct {
+
+ static const struct werror_code_struct dos_errs[] =
+ {
++#ifdef VERBOSE_ERROR
+ { "WERR_OK", WERR_OK },
+ { "WERR_BADFILE", WERR_BADFILE },
+ { "WERR_ACCESS_DENIED", WERR_ACCESS_DENIED },
+@@ -2668,6 +2669,7 @@ static const struct werror_code_struct d
+ { "WERR_AMBIGUOUS_SYSTEM_DEVICE", WERR_AMBIGUOUS_SYSTEM_DEVICE },
+ { "WERR_SYSTEM_DEVICE_NOT_FOUND", WERR_SYSTEM_DEVICE_NOT_FOUND },
+ /* END GENERATED-WIN32-ERROR-CODES */
++#endif
+ { NULL, W_ERROR(0) }
+ };
+
+@@ -2684,12 +2686,14 @@ const char *win_errstr(WERROR werror)
+ static char msg[40];
+ int idx = 0;
+
++#ifdef VERBOSE_ERROR
+ while (dos_errs[idx].dos_errstr != NULL) {
+ if (W_ERROR_V(dos_errs[idx].werror) ==
+ W_ERROR_V(werror))
+ return dos_errs[idx].dos_errstr;
+ idx++;
+ }
++#endif
+
+ slprintf(msg, sizeof(msg), "DOS code 0x%08x", W_ERROR_V(werror));
+
+@@ -2702,6 +2706,7 @@ struct werror_str_struct {
+ };
+
+ const struct werror_str_struct dos_err_strs[] = {
++#ifdef VERBOSE_ERROR
+ { WERR_OK, "Success" },
+ { WERR_ACCESS_DENIED, "Access is denied" },
+ { WERR_INVALID_PARAM, "Invalid parameter" },
+@@ -5324,6 +5329,7 @@ const struct werror_str_struct dos_err_s
+ { WERR_AMBIGUOUS_SYSTEM_DEVICE, "The requested system device cannot be identified due to multiple indistinguishable devices potentially matching the identification criteria." },
+ { WERR_SYSTEM_DEVICE_NOT_FOUND, "The requested system device cannot be found." },
+ /* END GENERATED-WIN32-ERROR-CODES-DESC */
++#endif
+ };
+
+
+@@ -5334,6 +5340,7 @@ const struct werror_str_struct dos_err_s
+
+ const char *get_friendly_werror_msg(WERROR werror)
+ {
++#ifdef VERBOSE_ERROR
+ int i = 0;
+
+ for (i = 0; i < ARRAY_SIZE(dos_err_strs); i++) {
+@@ -5342,6 +5349,7 @@ const char *get_friendly_werror_msg(WERR
+ return dos_err_strs[i].friendly_errstr;
+ }
+ }
++#endif
+
+ return win_errstr(werror);
+ }
+--- a/librpc/ndr/libndr.h
++++ b/librpc/ndr/libndr.h
+@@ -604,4 +604,20 @@ _PUBLIC_ enum ndr_err_code ndr_push_enum
+
+ _PUBLIC_ void ndr_print_bool(struct ndr_print *ndr, const char *name, const bool b);
+
++#ifndef VERBOSE_ERROR
++#define ndr_print_bool(...) do {} while (0)
++#define ndr_print_struct(...) do {} while (0)
++#define ndr_print_null(...) do {} while (0)
++#define ndr_print_enum(...) do {} while (0)
++#define ndr_print_bitmap_flag(...) do {} while (0)
++#define ndr_print_ptr(...) do {} while (0)
++#define ndr_print_union(...) do {} while (0)
++#define ndr_print_bad_level(...) do {} while (0)
++#define ndr_print_array_uint8(...) do {} while (0)
++#define ndr_print_string_array(...) do {} while (0)
++#define ndr_print_string_array(...) do {} while (0)
++#define ndr_print_NTSTATUS(...) do {} while (0)
++#define ndr_print_WERROR(...) do {} while (0)
++#endif
++
+ #endif /* __LIBNDR_H__ */
+--- a/librpc/ndr/ndr_basic.c
++++ b/librpc/ndr/ndr_basic.c
+@@ -31,6 +31,19 @@
+ #define NDR_SIVAL(ndr, ofs, v) do { if (NDR_BE(ndr)) { RSIVAL(ndr->data,ofs,v); } else SIVAL(ndr->data,ofs,v); } while (0)
+ #define NDR_SIVALS(ndr, ofs, v) do { if (NDR_BE(ndr)) { RSIVALS(ndr->data,ofs,v); } else SIVALS(ndr->data,ofs,v); } while (0)
+
++#undef ndr_print_bool
++#undef ndr_print_struct
++#undef ndr_print_null
++#undef ndr_print_enum
++#undef ndr_print_bitmap_flag
++#undef ndr_print_ptr
++#undef ndr_print_union
++#undef ndr_print_bad_level
++#undef ndr_print_array_uint8
++#undef ndr_print_string_array
++#undef ndr_print_string_array
++#undef ndr_print_NTSTATUS
++#undef ndr_print_WERROR
+
+ /*
+ check for data leaks from the server by looking for non-zero pad bytes
+--- a/librpc/ndr/ndr_string.c
++++ b/librpc/ndr/ndr_string.c
+@@ -588,6 +588,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_stri
+ return NDR_ERR_SUCCESS;
+ }
+
++#undef ndr_print_string_array
+ _PUBLIC_ void ndr_print_string_array(struct ndr_print *ndr, const char *name, const char **a)
+ {
+ uint32_t count;
+--- a/librpc/rpc/dcerpc_error.c
++++ b/librpc/rpc/dcerpc_error.c
+@@ -31,6 +31,7 @@ struct dcerpc_fault_table {
+ static const struct dcerpc_fault_table dcerpc_faults[] =
+ {
+ #define _FAULT_STR(x) { #x , x }
++#ifdef VERBOSE_ERROR
+ _FAULT_STR(DCERPC_NCA_S_COMM_FAILURE),
+ _FAULT_STR(DCERPC_NCA_S_OP_RNG_ERROR),
+ _FAULT_STR(DCERPC_NCA_S_UNKNOWN_IF),
+@@ -78,6 +79,7 @@ static const struct dcerpc_fault_table d
+ _FAULT_STR(DCERPC_NCA_S_FAULT_CODESET_CONV_ERROR),
+ _FAULT_STR(DCERPC_NCA_S_FAULT_OBJECT_NOT_FOUND),
+ _FAULT_STR(DCERPC_NCA_S_FAULT_NO_CLIENT_STUB),
++#endif
+ { NULL, 0 }
+ #undef _FAULT_STR
+ };
+@@ -87,12 +89,14 @@ _PUBLIC_ const char *dcerpc_errstr(TALLO
+ int idx = 0;
+ WERROR werr = W_ERROR(fault_code);
+
++#ifdef VERBOSE_ERROR
+ while (dcerpc_faults[idx].errstr != NULL) {
+ if (dcerpc_faults[idx].faultcode == fault_code) {
+ return dcerpc_faults[idx].errstr;
+ }
+ idx++;
+ }
++#endif
+
+ return win_errstr(werr);
+ }
+--- a/source3/libsmb/nterr.c
++++ b/source3/libsmb/nterr.c
+@@ -702,6 +702,7 @@ const char *nt_errstr(NTSTATUS nt_code)
+ NT_STATUS_DOS_CODE(nt_code));
+ }
+
++#ifdef VERBOSE_ERROR
+ while (nt_errs[idx].nt_errstr != NULL) {
+ if (NT_STATUS_V(nt_errs[idx].nt_errcode) ==
+ NT_STATUS_V(nt_code)) {
+@@ -709,6 +710,7 @@ const char *nt_errstr(NTSTATUS nt_code)
+ }
+ idx++;
+ }
++#endif
+
+ result = talloc_asprintf(talloc_tos(), "NT code 0x%08x",
+ NT_STATUS_V(nt_code));
+@@ -724,12 +726,14 @@ const char *get_friendly_nt_error_msg(NT
+ {
+ int idx = 0;
+
++#ifdef VERBOSE_ERROR
+ while (nt_err_desc[idx].nt_errstr != NULL) {
+ if (NT_STATUS_V(nt_err_desc[idx].nt_errcode) == NT_STATUS_V(nt_code)) {
+ return nt_err_desc[idx].nt_errstr;
+ }
+ idx++;
+ }
++#endif
+
+ /* fall back to NT_STATUS_XXX string */
+
+@@ -745,6 +749,7 @@ const char *get_nt_error_c_code(NTSTATUS
+ char *result;
+ int idx = 0;
+
++#ifdef VERBOSE_ERROR
+ while (nt_errs[idx].nt_errstr != NULL) {
+ if (NT_STATUS_V(nt_errs[idx].nt_errcode) ==
+ NT_STATUS_V(nt_code)) {
+@@ -752,6 +757,7 @@ const char *get_nt_error_c_code(NTSTATUS
+ }
+ idx++;
+ }
++#endif
+
+ result = talloc_asprintf(talloc_tos(), "NT_STATUS(0x%08x)",
+ NT_STATUS_V(nt_code));
+@@ -767,12 +773,14 @@ NTSTATUS nt_status_string_to_code(const
+ {
+ int idx = 0;
+
++#ifdef VERBOSE_ERROR
+ while (nt_errs[idx].nt_errstr != NULL) {
+ if (strcasecmp(nt_errs[idx].nt_errstr, nt_status_str) == 0) {
+ return nt_errs[idx].nt_errcode;
+ }
+ idx++;
+ }
++#endif
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+
+--- a/lib/tdb/common/tdb_private.h
++++ b/lib/tdb/common/tdb_private.h
+@@ -69,7 +69,11 @@ typedef uint32_t tdb_off_t;
+ /* NB assumes there is a local variable called "tdb" that is the
+ * current context, also takes doubly-parenthesized print-style
+ * argument. */
++#ifdef VERBOSE_DEBUG
+ #define TDB_LOG(x) tdb->log.log_fn x
++#else
++#define TDB_LOG(x) do {} while(0)
++#endif
+
+ #ifdef TDB_TRACE
+ void tdb_trace(struct tdb_context *tdb, const char *op);
+--- a/source3/script/mkbuildoptions.awk
++++ b/source3/script/mkbuildoptions.awk
+@@ -55,7 +55,7 @@ BEGIN {
+ print "****************************************************************************/";
+ print "void build_options(bool screen)";
+ print "{";
+- print " if ((DEBUGLEVEL < 4) && (!screen)) {";
++ print " if ((DEBUGLEVEL < 4) || (!screen)) {";
+ print " return;";
+ print " }";
+ print "";
+--- a/source3/script/mkbuildoptions-waf.awk
++++ b/source3/script/mkbuildoptions-waf.awk
+@@ -55,7 +55,7 @@ BEGIN {
+ print "****************************************************************************/";
+ print "void build_options(bool screen)";
+ print "{";
+- print " if ((DEBUGLEVEL < 4) && (!screen)) {";
++ print " if ((DEBUGLEVEL < 4) || (!screen)) {";
+ print " return;";
+ print " }";
+ print "";
diff --git a/package/network/services/samba36/patches/320-debug_level_checks.patch b/package/network/services/samba36/patches/320-debug_level_checks.patch
new file mode 100644
index 0000000..c6f2e6e
--- /dev/null
+++ b/package/network/services/samba36/patches/320-debug_level_checks.patch
@@ -0,0 +1,22 @@
+--- a/lib/util/debug.h
++++ b/lib/util/debug.h
+@@ -45,7 +45,7 @@ bool dbghdr( int level, const char *loca
+ * Redefine DEBUGLEVEL because so we don't have to change every source file
+ * that *unnecessarily* references it.
+ */
+-#define DEBUGLEVEL DEBUGLEVEL_CLASS[DBGC_ALL]
++#define DEBUGLEVEL 0
+
+ /*
+ * Define all new debug classes here. A class is represented by an entry in
+--- a/source3/nmbd/asyncdns.c
++++ b/source3/nmbd/asyncdns.c
+@@ -85,7 +85,7 @@ static void asyncdns_process(void)
+ struct query_record r;
+ unstring qname;
+
+- DEBUGLEVEL = -1;
++ DEBUGLEVEL_CLASS[DBGC_ALL] = -1;
+
+ while (1) {
+ NTSTATUS status;
diff --git a/package/network/services/samba36/patches/330-librpc_default_print.patch b/package/network/services/samba36/patches/330-librpc_default_print.patch
new file mode 100644
index 0000000..4d16086
--- /dev/null
+++ b/package/network/services/samba36/patches/330-librpc_default_print.patch
@@ -0,0 +1,8854 @@
+--- a/source3/librpc/ndr/util.c
++++ b/source3/librpc/ndr/util.c
+@@ -28,3 +28,7 @@ _PUBLIC_ void ndr_print_sockaddr_storage
+ char addr[INET6_ADDRSTRLEN];
+ ndr->print(ndr, "%-25s: %s", name, print_sockaddr(addr, sizeof(addr), ss));
+ }
++
++_PUBLIC_ void ndr_print_disabled(struct ndr_print *ndr, const char *name, int flags, void *r)
++{
++}
+--- a/source3/librpc/gen_ndr/ndr_atsvc.c
++++ b/source3/librpc/gen_ndr/ndr_atsvc.c
+@@ -867,7 +867,7 @@ static const struct ndr_interface_call a
+ sizeof(struct atsvc_JobAdd),
+ (ndr_push_flags_fn_t) ndr_push_atsvc_JobAdd,
+ (ndr_pull_flags_fn_t) ndr_pull_atsvc_JobAdd,
+- (ndr_print_function_t) ndr_print_atsvc_JobAdd,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -876,7 +876,7 @@ static const struct ndr_interface_call a
+ sizeof(struct atsvc_JobDel),
+ (ndr_push_flags_fn_t) ndr_push_atsvc_JobDel,
+ (ndr_pull_flags_fn_t) ndr_pull_atsvc_JobDel,
+- (ndr_print_function_t) ndr_print_atsvc_JobDel,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -885,7 +885,7 @@ static const struct ndr_interface_call a
+ sizeof(struct atsvc_JobEnum),
+ (ndr_push_flags_fn_t) ndr_push_atsvc_JobEnum,
+ (ndr_pull_flags_fn_t) ndr_pull_atsvc_JobEnum,
+- (ndr_print_function_t) ndr_print_atsvc_JobEnum,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -894,7 +894,7 @@ static const struct ndr_interface_call a
+ sizeof(struct atsvc_JobGetInfo),
+ (ndr_push_flags_fn_t) ndr_push_atsvc_JobGetInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_atsvc_JobGetInfo,
+- (ndr_print_function_t) ndr_print_atsvc_JobGetInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_audiosrv.c
++++ b/source3/librpc/gen_ndr/ndr_audiosrv.c
+@@ -594,7 +594,7 @@ static const struct ndr_interface_call a
+ sizeof(struct audiosrv_CreatezoneFactoriesList),
+ (ndr_push_flags_fn_t) ndr_push_audiosrv_CreatezoneFactoriesList,
+ (ndr_pull_flags_fn_t) ndr_pull_audiosrv_CreatezoneFactoriesList,
+- (ndr_print_function_t) ndr_print_audiosrv_CreatezoneFactoriesList,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -603,7 +603,7 @@ static const struct ndr_interface_call a
+ sizeof(struct audiosrv_CreateGfxFactoriesList),
+ (ndr_push_flags_fn_t) ndr_push_audiosrv_CreateGfxFactoriesList,
+ (ndr_pull_flags_fn_t) ndr_pull_audiosrv_CreateGfxFactoriesList,
+- (ndr_print_function_t) ndr_print_audiosrv_CreateGfxFactoriesList,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -612,7 +612,7 @@ static const struct ndr_interface_call a
+ sizeof(struct audiosrv_CreateGfxList),
+ (ndr_push_flags_fn_t) ndr_push_audiosrv_CreateGfxList,
+ (ndr_pull_flags_fn_t) ndr_pull_audiosrv_CreateGfxList,
+- (ndr_print_function_t) ndr_print_audiosrv_CreateGfxList,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -621,7 +621,7 @@ static const struct ndr_interface_call a
+ sizeof(struct audiosrv_RemoveGfx),
+ (ndr_push_flags_fn_t) ndr_push_audiosrv_RemoveGfx,
+ (ndr_pull_flags_fn_t) ndr_pull_audiosrv_RemoveGfx,
+- (ndr_print_function_t) ndr_print_audiosrv_RemoveGfx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -630,7 +630,7 @@ static const struct ndr_interface_call a
+ sizeof(struct audiosrv_AddGfx),
+ (ndr_push_flags_fn_t) ndr_push_audiosrv_AddGfx,
+ (ndr_pull_flags_fn_t) ndr_pull_audiosrv_AddGfx,
+- (ndr_print_function_t) ndr_print_audiosrv_AddGfx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -639,7 +639,7 @@ static const struct ndr_interface_call a
+ sizeof(struct audiosrv_ModifyGfx),
+ (ndr_push_flags_fn_t) ndr_push_audiosrv_ModifyGfx,
+ (ndr_pull_flags_fn_t) ndr_pull_audiosrv_ModifyGfx,
+- (ndr_print_function_t) ndr_print_audiosrv_ModifyGfx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -648,7 +648,7 @@ static const struct ndr_interface_call a
+ sizeof(struct audiosrv_OpenGfx),
+ (ndr_push_flags_fn_t) ndr_push_audiosrv_OpenGfx,
+ (ndr_pull_flags_fn_t) ndr_pull_audiosrv_OpenGfx,
+- (ndr_print_function_t) ndr_print_audiosrv_OpenGfx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -657,7 +657,7 @@ static const struct ndr_interface_call a
+ sizeof(struct audiosrv_Logon),
+ (ndr_push_flags_fn_t) ndr_push_audiosrv_Logon,
+ (ndr_pull_flags_fn_t) ndr_pull_audiosrv_Logon,
+- (ndr_print_function_t) ndr_print_audiosrv_Logon,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -666,7 +666,7 @@ static const struct ndr_interface_call a
+ sizeof(struct audiosrv_Logoff),
+ (ndr_push_flags_fn_t) ndr_push_audiosrv_Logoff,
+ (ndr_pull_flags_fn_t) ndr_pull_audiosrv_Logoff,
+- (ndr_print_function_t) ndr_print_audiosrv_Logoff,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -675,7 +675,7 @@ static const struct ndr_interface_call a
+ sizeof(struct audiosrv_RegisterSessionNotificationEvent),
+ (ndr_push_flags_fn_t) ndr_push_audiosrv_RegisterSessionNotificationEvent,
+ (ndr_pull_flags_fn_t) ndr_pull_audiosrv_RegisterSessionNotificationEvent,
+- (ndr_print_function_t) ndr_print_audiosrv_RegisterSessionNotificationEvent,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -684,7 +684,7 @@ static const struct ndr_interface_call a
+ sizeof(struct audiosrv_UnregisterSessionNotificationEvent),
+ (ndr_push_flags_fn_t) ndr_push_audiosrv_UnregisterSessionNotificationEvent,
+ (ndr_pull_flags_fn_t) ndr_pull_audiosrv_UnregisterSessionNotificationEvent,
+- (ndr_print_function_t) ndr_print_audiosrv_UnregisterSessionNotificationEvent,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -693,7 +693,7 @@ static const struct ndr_interface_call a
+ sizeof(struct audiosrv_SessionConnectState),
+ (ndr_push_flags_fn_t) ndr_push_audiosrv_SessionConnectState,
+ (ndr_pull_flags_fn_t) ndr_pull_audiosrv_SessionConnectState,
+- (ndr_print_function_t) ndr_print_audiosrv_SessionConnectState,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -702,7 +702,7 @@ static const struct ndr_interface_call a
+ sizeof(struct audiosrv_DriverOpenDrvRegKey),
+ (ndr_push_flags_fn_t) ndr_push_audiosrv_DriverOpenDrvRegKey,
+ (ndr_pull_flags_fn_t) ndr_pull_audiosrv_DriverOpenDrvRegKey,
+- (ndr_print_function_t) ndr_print_audiosrv_DriverOpenDrvRegKey,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -711,7 +711,7 @@ static const struct ndr_interface_call a
+ sizeof(struct audiosrv_AdvisePreferredDeviceChange),
+ (ndr_push_flags_fn_t) ndr_push_audiosrv_AdvisePreferredDeviceChange,
+ (ndr_pull_flags_fn_t) ndr_pull_audiosrv_AdvisePreferredDeviceChange,
+- (ndr_print_function_t) ndr_print_audiosrv_AdvisePreferredDeviceChange,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -720,7 +720,7 @@ static const struct ndr_interface_call a
+ sizeof(struct audiosrv_GetPnpInfo),
+ (ndr_push_flags_fn_t) ndr_push_audiosrv_GetPnpInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_audiosrv_GetPnpInfo,
+- (ndr_print_function_t) ndr_print_audiosrv_GetPnpInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_backupkey.c
++++ b/source3/librpc/gen_ndr/ndr_backupkey.c
+@@ -740,7 +740,7 @@ static const struct ndr_interface_call b
+ sizeof(struct bkrp_BackupKey),
+ (ndr_push_flags_fn_t) ndr_push_bkrp_BackupKey,
+ (ndr_pull_flags_fn_t) ndr_pull_bkrp_BackupKey,
+- (ndr_print_function_t) ndr_print_bkrp_BackupKey,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_browser.c
++++ b/source3/librpc/gen_ndr/ndr_browser.c
+@@ -928,7 +928,7 @@ static const struct ndr_interface_call b
+ sizeof(struct BrowserrServerEnum),
+ (ndr_push_flags_fn_t) ndr_push_BrowserrServerEnum,
+ (ndr_pull_flags_fn_t) ndr_pull_BrowserrServerEnum,
+- (ndr_print_function_t) ndr_print_BrowserrServerEnum,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -937,7 +937,7 @@ static const struct ndr_interface_call b
+ sizeof(struct BrowserrDebugCall),
+ (ndr_push_flags_fn_t) ndr_push_BrowserrDebugCall,
+ (ndr_pull_flags_fn_t) ndr_pull_BrowserrDebugCall,
+- (ndr_print_function_t) ndr_print_BrowserrDebugCall,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -946,7 +946,7 @@ static const struct ndr_interface_call b
+ sizeof(struct BrowserrQueryOtherDomains),
+ (ndr_push_flags_fn_t) ndr_push_BrowserrQueryOtherDomains,
+ (ndr_pull_flags_fn_t) ndr_pull_BrowserrQueryOtherDomains,
+- (ndr_print_function_t) ndr_print_BrowserrQueryOtherDomains,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -955,7 +955,7 @@ static const struct ndr_interface_call b
+ sizeof(struct BrowserrResetNetlogonState),
+ (ndr_push_flags_fn_t) ndr_push_BrowserrResetNetlogonState,
+ (ndr_pull_flags_fn_t) ndr_pull_BrowserrResetNetlogonState,
+- (ndr_print_function_t) ndr_print_BrowserrResetNetlogonState,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -964,7 +964,7 @@ static const struct ndr_interface_call b
+ sizeof(struct BrowserrDebugTrace),
+ (ndr_push_flags_fn_t) ndr_push_BrowserrDebugTrace,
+ (ndr_pull_flags_fn_t) ndr_pull_BrowserrDebugTrace,
+- (ndr_print_function_t) ndr_print_BrowserrDebugTrace,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -973,7 +973,7 @@ static const struct ndr_interface_call b
+ sizeof(struct BrowserrQueryStatistics),
+ (ndr_push_flags_fn_t) ndr_push_BrowserrQueryStatistics,
+ (ndr_pull_flags_fn_t) ndr_pull_BrowserrQueryStatistics,
+- (ndr_print_function_t) ndr_print_BrowserrQueryStatistics,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -982,7 +982,7 @@ static const struct ndr_interface_call b
+ sizeof(struct BrowserResetStatistics),
+ (ndr_push_flags_fn_t) ndr_push_BrowserResetStatistics,
+ (ndr_pull_flags_fn_t) ndr_pull_BrowserResetStatistics,
+- (ndr_print_function_t) ndr_print_BrowserResetStatistics,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -991,7 +991,7 @@ static const struct ndr_interface_call b
+ sizeof(struct NetrBrowserStatisticsClear),
+ (ndr_push_flags_fn_t) ndr_push_NetrBrowserStatisticsClear,
+ (ndr_pull_flags_fn_t) ndr_pull_NetrBrowserStatisticsClear,
+- (ndr_print_function_t) ndr_print_NetrBrowserStatisticsClear,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1000,7 +1000,7 @@ static const struct ndr_interface_call b
+ sizeof(struct NetrBrowserStatisticsGet),
+ (ndr_push_flags_fn_t) ndr_push_NetrBrowserStatisticsGet,
+ (ndr_pull_flags_fn_t) ndr_pull_NetrBrowserStatisticsGet,
+- (ndr_print_function_t) ndr_print_NetrBrowserStatisticsGet,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1009,7 +1009,7 @@ static const struct ndr_interface_call b
+ sizeof(struct BrowserrSetNetlogonState),
+ (ndr_push_flags_fn_t) ndr_push_BrowserrSetNetlogonState,
+ (ndr_pull_flags_fn_t) ndr_pull_BrowserrSetNetlogonState,
+- (ndr_print_function_t) ndr_print_BrowserrSetNetlogonState,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1018,7 +1018,7 @@ static const struct ndr_interface_call b
+ sizeof(struct BrowserrQueryEmulatedDomains),
+ (ndr_push_flags_fn_t) ndr_push_BrowserrQueryEmulatedDomains,
+ (ndr_pull_flags_fn_t) ndr_pull_BrowserrQueryEmulatedDomains,
+- (ndr_print_function_t) ndr_print_BrowserrQueryEmulatedDomains,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1027,7 +1027,7 @@ static const struct ndr_interface_call b
+ sizeof(struct BrowserrServerEnumEx),
+ (ndr_push_flags_fn_t) ndr_push_BrowserrServerEnumEx,
+ (ndr_pull_flags_fn_t) ndr_pull_BrowserrServerEnumEx,
+- (ndr_print_function_t) ndr_print_BrowserrServerEnumEx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_dbgidl.c
++++ b/source3/librpc/gen_ndr/ndr_dbgidl.c
+@@ -48,7 +48,7 @@ static const struct ndr_interface_call d
+ sizeof(struct dummy_dbgidl),
+ (ndr_push_flags_fn_t) ndr_push_dummy_dbgidl,
+ (ndr_pull_flags_fn_t) ndr_pull_dummy_dbgidl,
+- (ndr_print_function_t) ndr_print_dummy_dbgidl,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_dcom.c
++++ b/source3/librpc/gen_ndr/ndr_dcom.c
+@@ -128,7 +128,7 @@ static const struct ndr_interface_call d
+ sizeof(struct UseProtSeq),
+ (ndr_push_flags_fn_t) ndr_push_UseProtSeq,
+ (ndr_pull_flags_fn_t) ndr_pull_UseProtSeq,
+- (ndr_print_function_t) ndr_print_UseProtSeq,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -137,7 +137,7 @@ static const struct ndr_interface_call d
+ sizeof(struct GetCustomProtseqInfo),
+ (ndr_push_flags_fn_t) ndr_push_GetCustomProtseqInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_GetCustomProtseqInfo,
+- (ndr_print_function_t) ndr_print_GetCustomProtseqInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -146,7 +146,7 @@ static const struct ndr_interface_call d
+ sizeof(struct UpdateResolverBindings),
+ (ndr_push_flags_fn_t) ndr_push_UpdateResolverBindings,
+ (ndr_pull_flags_fn_t) ndr_pull_UpdateResolverBindings,
+- (ndr_print_function_t) ndr_print_UpdateResolverBindings,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -450,7 +450,7 @@ static const struct ndr_interface_call I
+ sizeof(struct QueryInterface),
+ (ndr_push_flags_fn_t) ndr_push_QueryInterface,
+ (ndr_pull_flags_fn_t) ndr_pull_QueryInterface,
+- (ndr_print_function_t) ndr_print_QueryInterface,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -459,7 +459,7 @@ static const struct ndr_interface_call I
+ sizeof(struct AddRef),
+ (ndr_push_flags_fn_t) ndr_push_AddRef,
+ (ndr_pull_flags_fn_t) ndr_pull_AddRef,
+- (ndr_print_function_t) ndr_print_AddRef,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -468,7 +468,7 @@ static const struct ndr_interface_call I
+ sizeof(struct Release),
+ (ndr_push_flags_fn_t) ndr_push_Release,
+ (ndr_pull_flags_fn_t) ndr_pull_Release,
+- (ndr_print_function_t) ndr_print_Release,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -849,7 +849,7 @@ static const struct ndr_interface_call I
+ sizeof(struct CreateInstance),
+ (ndr_push_flags_fn_t) ndr_push_CreateInstance,
+ (ndr_pull_flags_fn_t) ndr_pull_CreateInstance,
+- (ndr_print_function_t) ndr_print_CreateInstance,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -858,7 +858,7 @@ static const struct ndr_interface_call I
+ sizeof(struct RemoteCreateInstance),
+ (ndr_push_flags_fn_t) ndr_push_RemoteCreateInstance,
+ (ndr_pull_flags_fn_t) ndr_pull_RemoteCreateInstance,
+- (ndr_print_function_t) ndr_print_RemoteCreateInstance,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -867,7 +867,7 @@ static const struct ndr_interface_call I
+ sizeof(struct LockServer),
+ (ndr_push_flags_fn_t) ndr_push_LockServer,
+ (ndr_pull_flags_fn_t) ndr_pull_LockServer,
+- (ndr_print_function_t) ndr_print_LockServer,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -876,7 +876,7 @@ static const struct ndr_interface_call I
+ sizeof(struct RemoteLockServer),
+ (ndr_push_flags_fn_t) ndr_push_RemoteLockServer,
+ (ndr_pull_flags_fn_t) ndr_pull_RemoteLockServer,
+- (ndr_print_function_t) ndr_print_RemoteLockServer,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1434,7 +1434,7 @@ static const struct ndr_interface_call I
+ sizeof(struct RemQueryInterface),
+ (ndr_push_flags_fn_t) ndr_push_RemQueryInterface,
+ (ndr_pull_flags_fn_t) ndr_pull_RemQueryInterface,
+- (ndr_print_function_t) ndr_print_RemQueryInterface,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1443,7 +1443,7 @@ static const struct ndr_interface_call I
+ sizeof(struct RemAddRef),
+ (ndr_push_flags_fn_t) ndr_push_RemAddRef,
+ (ndr_pull_flags_fn_t) ndr_pull_RemAddRef,
+- (ndr_print_function_t) ndr_print_RemAddRef,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1452,7 +1452,7 @@ static const struct ndr_interface_call I
+ sizeof(struct RemRelease),
+ (ndr_push_flags_fn_t) ndr_push_RemRelease,
+ (ndr_pull_flags_fn_t) ndr_pull_RemRelease,
+- (ndr_print_function_t) ndr_print_RemRelease,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1590,7 +1590,7 @@ static const struct ndr_interface_call I
+ sizeof(struct GetClassObject),
+ (ndr_push_flags_fn_t) ndr_push_GetClassObject,
+ (ndr_pull_flags_fn_t) ndr_pull_GetClassObject,
+- (ndr_print_function_t) ndr_print_GetClassObject,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1701,7 +1701,7 @@ static const struct ndr_interface_call I
+ sizeof(struct ISCMLocalActivator_CreateInstance),
+ (ndr_push_flags_fn_t) ndr_push_ISCMLocalActivator_CreateInstance,
+ (ndr_pull_flags_fn_t) ndr_pull_ISCMLocalActivator_CreateInstance,
+- (ndr_print_function_t) ndr_print_ISCMLocalActivator_CreateInstance,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1788,7 +1788,7 @@ static const struct ndr_interface_call I
+ sizeof(struct IMachineLocalActivator_foo),
+ (ndr_push_flags_fn_t) ndr_push_IMachineLocalActivator_foo,
+ (ndr_pull_flags_fn_t) ndr_pull_IMachineLocalActivator_foo,
+- (ndr_print_function_t) ndr_print_IMachineLocalActivator_foo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1875,7 +1875,7 @@ static const struct ndr_interface_call I
+ sizeof(struct ILocalObjectExporter_Foo),
+ (ndr_push_flags_fn_t) ndr_push_ILocalObjectExporter_Foo,
+ (ndr_pull_flags_fn_t) ndr_pull_ILocalObjectExporter_Foo,
+- (ndr_print_function_t) ndr_print_ILocalObjectExporter_Foo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2031,7 +2031,7 @@ static const struct ndr_interface_call I
+ sizeof(struct ISystemActivatorRemoteCreateInstance),
+ (ndr_push_flags_fn_t) ndr_push_ISystemActivatorRemoteCreateInstance,
+ (ndr_pull_flags_fn_t) ndr_pull_ISystemActivatorRemoteCreateInstance,
+- (ndr_print_function_t) ndr_print_ISystemActivatorRemoteCreateInstance,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2319,7 +2319,7 @@ static const struct ndr_interface_call I
+ sizeof(struct RemQueryInterface2),
+ (ndr_push_flags_fn_t) ndr_push_RemQueryInterface2,
+ (ndr_pull_flags_fn_t) ndr_pull_RemQueryInterface2,
+- (ndr_print_function_t) ndr_print_RemQueryInterface2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3040,7 +3040,7 @@ static const struct ndr_interface_call I
+ sizeof(struct GetTypeInfoCount),
+ (ndr_push_flags_fn_t) ndr_push_GetTypeInfoCount,
+ (ndr_pull_flags_fn_t) ndr_pull_GetTypeInfoCount,
+- (ndr_print_function_t) ndr_print_GetTypeInfoCount,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3049,7 +3049,7 @@ static const struct ndr_interface_call I
+ sizeof(struct GetTypeInfo),
+ (ndr_push_flags_fn_t) ndr_push_GetTypeInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_GetTypeInfo,
+- (ndr_print_function_t) ndr_print_GetTypeInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3058,7 +3058,7 @@ static const struct ndr_interface_call I
+ sizeof(struct GetIDsOfNames),
+ (ndr_push_flags_fn_t) ndr_push_GetIDsOfNames,
+ (ndr_pull_flags_fn_t) ndr_pull_GetIDsOfNames,
+- (ndr_print_function_t) ndr_print_GetIDsOfNames,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3067,7 +3067,7 @@ static const struct ndr_interface_call I
+ sizeof(struct Invoke),
+ (ndr_push_flags_fn_t) ndr_push_Invoke,
+ (ndr_pull_flags_fn_t) ndr_pull_Invoke,
+- (ndr_print_function_t) ndr_print_Invoke,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3243,7 +3243,7 @@ static const struct ndr_interface_call I
+ sizeof(struct MarshalInterface),
+ (ndr_push_flags_fn_t) ndr_push_MarshalInterface,
+ (ndr_pull_flags_fn_t) ndr_pull_MarshalInterface,
+- (ndr_print_function_t) ndr_print_MarshalInterface,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3252,7 +3252,7 @@ static const struct ndr_interface_call I
+ sizeof(struct UnMarshalInterface),
+ (ndr_push_flags_fn_t) ndr_push_UnMarshalInterface,
+ (ndr_pull_flags_fn_t) ndr_pull_UnMarshalInterface,
+- (ndr_print_function_t) ndr_print_UnMarshalInterface,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3385,7 +3385,7 @@ static const struct ndr_interface_call I
+ sizeof(struct MakeCoffee),
+ (ndr_push_flags_fn_t) ndr_push_MakeCoffee,
+ (ndr_pull_flags_fn_t) ndr_pull_MakeCoffee,
+- (ndr_print_function_t) ndr_print_MakeCoffee,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3681,7 +3681,7 @@ static const struct ndr_interface_call I
+ sizeof(struct Read),
+ (ndr_push_flags_fn_t) ndr_push_Read,
+ (ndr_pull_flags_fn_t) ndr_pull_Read,
+- (ndr_print_function_t) ndr_print_Read,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3690,7 +3690,7 @@ static const struct ndr_interface_call I
+ sizeof(struct Write),
+ (ndr_push_flags_fn_t) ndr_push_Write,
+ (ndr_pull_flags_fn_t) ndr_pull_Write,
+- (ndr_print_function_t) ndr_print_Write,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_dfs.c
++++ b/source3/librpc/gen_ndr/ndr_dfs.c
+@@ -5910,7 +5910,7 @@ static const struct ndr_interface_call n
+ sizeof(struct dfs_GetManagerVersion),
+ (ndr_push_flags_fn_t) ndr_push_dfs_GetManagerVersion,
+ (ndr_pull_flags_fn_t) ndr_pull_dfs_GetManagerVersion,
+- (ndr_print_function_t) ndr_print_dfs_GetManagerVersion,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5919,7 +5919,7 @@ static const struct ndr_interface_call n
+ sizeof(struct dfs_Add),
+ (ndr_push_flags_fn_t) ndr_push_dfs_Add,
+ (ndr_pull_flags_fn_t) ndr_pull_dfs_Add,
+- (ndr_print_function_t) ndr_print_dfs_Add,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5928,7 +5928,7 @@ static const struct ndr_interface_call n
+ sizeof(struct dfs_Remove),
+ (ndr_push_flags_fn_t) ndr_push_dfs_Remove,
+ (ndr_pull_flags_fn_t) ndr_pull_dfs_Remove,
+- (ndr_print_function_t) ndr_print_dfs_Remove,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5937,7 +5937,7 @@ static const struct ndr_interface_call n
+ sizeof(struct dfs_SetInfo),
+ (ndr_push_flags_fn_t) ndr_push_dfs_SetInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_dfs_SetInfo,
+- (ndr_print_function_t) ndr_print_dfs_SetInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5946,7 +5946,7 @@ static const struct ndr_interface_call n
+ sizeof(struct dfs_GetInfo),
+ (ndr_push_flags_fn_t) ndr_push_dfs_GetInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_dfs_GetInfo,
+- (ndr_print_function_t) ndr_print_dfs_GetInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5955,7 +5955,7 @@ static const struct ndr_interface_call n
+ sizeof(struct dfs_Enum),
+ (ndr_push_flags_fn_t) ndr_push_dfs_Enum,
+ (ndr_pull_flags_fn_t) ndr_pull_dfs_Enum,
+- (ndr_print_function_t) ndr_print_dfs_Enum,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5964,7 +5964,7 @@ static const struct ndr_interface_call n
+ sizeof(struct dfs_Rename),
+ (ndr_push_flags_fn_t) ndr_push_dfs_Rename,
+ (ndr_pull_flags_fn_t) ndr_pull_dfs_Rename,
+- (ndr_print_function_t) ndr_print_dfs_Rename,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5973,7 +5973,7 @@ static const struct ndr_interface_call n
+ sizeof(struct dfs_Move),
+ (ndr_push_flags_fn_t) ndr_push_dfs_Move,
+ (ndr_pull_flags_fn_t) ndr_pull_dfs_Move,
+- (ndr_print_function_t) ndr_print_dfs_Move,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5982,7 +5982,7 @@ static const struct ndr_interface_call n
+ sizeof(struct dfs_ManagerGetConfigInfo),
+ (ndr_push_flags_fn_t) ndr_push_dfs_ManagerGetConfigInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_dfs_ManagerGetConfigInfo,
+- (ndr_print_function_t) ndr_print_dfs_ManagerGetConfigInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5991,7 +5991,7 @@ static const struct ndr_interface_call n
+ sizeof(struct dfs_ManagerSendSiteInfo),
+ (ndr_push_flags_fn_t) ndr_push_dfs_ManagerSendSiteInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_dfs_ManagerSendSiteInfo,
+- (ndr_print_function_t) ndr_print_dfs_ManagerSendSiteInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -6000,7 +6000,7 @@ static const struct ndr_interface_call n
+ sizeof(struct dfs_AddFtRoot),
+ (ndr_push_flags_fn_t) ndr_push_dfs_AddFtRoot,
+ (ndr_pull_flags_fn_t) ndr_pull_dfs_AddFtRoot,
+- (ndr_print_function_t) ndr_print_dfs_AddFtRoot,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -6009,7 +6009,7 @@ static const struct ndr_interface_call n
+ sizeof(struct dfs_RemoveFtRoot),
+ (ndr_push_flags_fn_t) ndr_push_dfs_RemoveFtRoot,
+ (ndr_pull_flags_fn_t) ndr_pull_dfs_RemoveFtRoot,
+- (ndr_print_function_t) ndr_print_dfs_RemoveFtRoot,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -6018,7 +6018,7 @@ static const struct ndr_interface_call n
+ sizeof(struct dfs_AddStdRoot),
+ (ndr_push_flags_fn_t) ndr_push_dfs_AddStdRoot,
+ (ndr_pull_flags_fn_t) ndr_pull_dfs_AddStdRoot,
+- (ndr_print_function_t) ndr_print_dfs_AddStdRoot,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -6027,7 +6027,7 @@ static const struct ndr_interface_call n
+ sizeof(struct dfs_RemoveStdRoot),
+ (ndr_push_flags_fn_t) ndr_push_dfs_RemoveStdRoot,
+ (ndr_pull_flags_fn_t) ndr_pull_dfs_RemoveStdRoot,
+- (ndr_print_function_t) ndr_print_dfs_RemoveStdRoot,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -6036,7 +6036,7 @@ static const struct ndr_interface_call n
+ sizeof(struct dfs_ManagerInitialize),
+ (ndr_push_flags_fn_t) ndr_push_dfs_ManagerInitialize,
+ (ndr_pull_flags_fn_t) ndr_pull_dfs_ManagerInitialize,
+- (ndr_print_function_t) ndr_print_dfs_ManagerInitialize,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -6045,7 +6045,7 @@ static const struct ndr_interface_call n
+ sizeof(struct dfs_AddStdRootForced),
+ (ndr_push_flags_fn_t) ndr_push_dfs_AddStdRootForced,
+ (ndr_pull_flags_fn_t) ndr_pull_dfs_AddStdRootForced,
+- (ndr_print_function_t) ndr_print_dfs_AddStdRootForced,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -6054,7 +6054,7 @@ static const struct ndr_interface_call n
+ sizeof(struct dfs_GetDcAddress),
+ (ndr_push_flags_fn_t) ndr_push_dfs_GetDcAddress,
+ (ndr_pull_flags_fn_t) ndr_pull_dfs_GetDcAddress,
+- (ndr_print_function_t) ndr_print_dfs_GetDcAddress,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -6063,7 +6063,7 @@ static const struct ndr_interface_call n
+ sizeof(struct dfs_SetDcAddress),
+ (ndr_push_flags_fn_t) ndr_push_dfs_SetDcAddress,
+ (ndr_pull_flags_fn_t) ndr_pull_dfs_SetDcAddress,
+- (ndr_print_function_t) ndr_print_dfs_SetDcAddress,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -6072,7 +6072,7 @@ static const struct ndr_interface_call n
+ sizeof(struct dfs_FlushFtTable),
+ (ndr_push_flags_fn_t) ndr_push_dfs_FlushFtTable,
+ (ndr_pull_flags_fn_t) ndr_pull_dfs_FlushFtTable,
+- (ndr_print_function_t) ndr_print_dfs_FlushFtTable,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -6081,7 +6081,7 @@ static const struct ndr_interface_call n
+ sizeof(struct dfs_Add2),
+ (ndr_push_flags_fn_t) ndr_push_dfs_Add2,
+ (ndr_pull_flags_fn_t) ndr_pull_dfs_Add2,
+- (ndr_print_function_t) ndr_print_dfs_Add2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -6090,7 +6090,7 @@ static const struct ndr_interface_call n
+ sizeof(struct dfs_Remove2),
+ (ndr_push_flags_fn_t) ndr_push_dfs_Remove2,
+ (ndr_pull_flags_fn_t) ndr_pull_dfs_Remove2,
+- (ndr_print_function_t) ndr_print_dfs_Remove2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -6099,7 +6099,7 @@ static const struct ndr_interface_call n
+ sizeof(struct dfs_EnumEx),
+ (ndr_push_flags_fn_t) ndr_push_dfs_EnumEx,
+ (ndr_pull_flags_fn_t) ndr_pull_dfs_EnumEx,
+- (ndr_print_function_t) ndr_print_dfs_EnumEx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -6108,7 +6108,7 @@ static const struct ndr_interface_call n
+ sizeof(struct dfs_SetInfo2),
+ (ndr_push_flags_fn_t) ndr_push_dfs_SetInfo2,
+ (ndr_pull_flags_fn_t) ndr_pull_dfs_SetInfo2,
+- (ndr_print_function_t) ndr_print_dfs_SetInfo2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_dfsblobs.c
++++ b/source3/librpc/gen_ndr/ndr_dfsblobs.c
+@@ -1398,7 +1398,7 @@ static const struct ndr_interface_call d
+ sizeof(struct dfs_GetDFSReferral),
+ (ndr_push_flags_fn_t) ndr_push_dfs_GetDFSReferral,
+ (ndr_pull_flags_fn_t) ndr_pull_dfs_GetDFSReferral,
+- (ndr_print_function_t) ndr_print_dfs_GetDFSReferral,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_dns.c
++++ b/source3/librpc/gen_ndr/ndr_dns.c
+@@ -860,7 +860,7 @@ static const struct ndr_interface_call d
+ sizeof(struct decode_dns_name_packet),
+ (ndr_push_flags_fn_t) ndr_push_decode_dns_name_packet,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_dns_name_packet,
+- (ndr_print_function_t) ndr_print_decode_dns_name_packet,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_dnsp.c
++++ b/source3/librpc/gen_ndr/ndr_dnsp.c
+@@ -700,7 +700,7 @@ static const struct ndr_interface_call d
+ sizeof(struct decode_DnssrvRpcRecord),
+ (ndr_push_flags_fn_t) ndr_push_decode_DnssrvRpcRecord,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_DnssrvRpcRecord,
+- (ndr_print_function_t) ndr_print_decode_DnssrvRpcRecord,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_dnsserver.c
++++ b/source3/librpc/gen_ndr/ndr_dnsserver.c
+@@ -48,7 +48,7 @@ static const struct ndr_interface_call d
+ sizeof(struct dnsserver_foo),
+ (ndr_push_flags_fn_t) ndr_push_dnsserver_foo,
+ (ndr_pull_flags_fn_t) ndr_pull_dnsserver_foo,
+- (ndr_print_function_t) ndr_print_dnsserver_foo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_drsblobs.c
++++ b/source3/librpc/gen_ndr/ndr_drsblobs.c
+@@ -5275,7 +5275,7 @@ static const struct ndr_interface_call d
+ sizeof(struct decode_replPropertyMetaData),
+ (ndr_push_flags_fn_t) ndr_push_decode_replPropertyMetaData,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_replPropertyMetaData,
+- (ndr_print_function_t) ndr_print_decode_replPropertyMetaData,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5284,7 +5284,7 @@ static const struct ndr_interface_call d
+ sizeof(struct decode_replUpToDateVector),
+ (ndr_push_flags_fn_t) ndr_push_decode_replUpToDateVector,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_replUpToDateVector,
+- (ndr_print_function_t) ndr_print_decode_replUpToDateVector,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5293,7 +5293,7 @@ static const struct ndr_interface_call d
+ sizeof(struct decode_repsFromTo),
+ (ndr_push_flags_fn_t) ndr_push_decode_repsFromTo,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_repsFromTo,
+- (ndr_print_function_t) ndr_print_decode_repsFromTo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5302,7 +5302,7 @@ static const struct ndr_interface_call d
+ sizeof(struct decode_partialAttributeSet),
+ (ndr_push_flags_fn_t) ndr_push_decode_partialAttributeSet,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_partialAttributeSet,
+- (ndr_print_function_t) ndr_print_decode_partialAttributeSet,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5311,7 +5311,7 @@ static const struct ndr_interface_call d
+ sizeof(struct decode_prefixMap),
+ (ndr_push_flags_fn_t) ndr_push_decode_prefixMap,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_prefixMap,
+- (ndr_print_function_t) ndr_print_decode_prefixMap,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5320,7 +5320,7 @@ static const struct ndr_interface_call d
+ sizeof(struct decode_ldapControlDirSync),
+ (ndr_push_flags_fn_t) ndr_push_decode_ldapControlDirSync,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_ldapControlDirSync,
+- (ndr_print_function_t) ndr_print_decode_ldapControlDirSync,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5329,7 +5329,7 @@ static const struct ndr_interface_call d
+ sizeof(struct decode_supplementalCredentials),
+ (ndr_push_flags_fn_t) ndr_push_decode_supplementalCredentials,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_supplementalCredentials,
+- (ndr_print_function_t) ndr_print_decode_supplementalCredentials,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5338,7 +5338,7 @@ static const struct ndr_interface_call d
+ sizeof(struct decode_Packages),
+ (ndr_push_flags_fn_t) ndr_push_decode_Packages,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_Packages,
+- (ndr_print_function_t) ndr_print_decode_Packages,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5347,7 +5347,7 @@ static const struct ndr_interface_call d
+ sizeof(struct decode_PrimaryKerberos),
+ (ndr_push_flags_fn_t) ndr_push_decode_PrimaryKerberos,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_PrimaryKerberos,
+- (ndr_print_function_t) ndr_print_decode_PrimaryKerberos,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5356,7 +5356,7 @@ static const struct ndr_interface_call d
+ sizeof(struct decode_PrimaryCLEARTEXT),
+ (ndr_push_flags_fn_t) ndr_push_decode_PrimaryCLEARTEXT,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_PrimaryCLEARTEXT,
+- (ndr_print_function_t) ndr_print_decode_PrimaryCLEARTEXT,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5365,7 +5365,7 @@ static const struct ndr_interface_call d
+ sizeof(struct decode_PrimaryWDigest),
+ (ndr_push_flags_fn_t) ndr_push_decode_PrimaryWDigest,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_PrimaryWDigest,
+- (ndr_print_function_t) ndr_print_decode_PrimaryWDigest,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5374,7 +5374,7 @@ static const struct ndr_interface_call d
+ sizeof(struct decode_trustAuthInOut),
+ (ndr_push_flags_fn_t) ndr_push_decode_trustAuthInOut,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_trustAuthInOut,
+- (ndr_print_function_t) ndr_print_decode_trustAuthInOut,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5383,7 +5383,7 @@ static const struct ndr_interface_call d
+ sizeof(struct decode_trustDomainPasswords),
+ (ndr_push_flags_fn_t) ndr_push_decode_trustDomainPasswords,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_trustDomainPasswords,
+- (ndr_print_function_t) ndr_print_decode_trustDomainPasswords,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5392,7 +5392,7 @@ static const struct ndr_interface_call d
+ sizeof(struct decode_ExtendedErrorInfo),
+ (ndr_push_flags_fn_t) ndr_push_decode_ExtendedErrorInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_ExtendedErrorInfo,
+- (ndr_print_function_t) ndr_print_decode_ExtendedErrorInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5401,7 +5401,7 @@ static const struct ndr_interface_call d
+ sizeof(struct decode_ForestTrustInfo),
+ (ndr_push_flags_fn_t) ndr_push_decode_ForestTrustInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_ForestTrustInfo,
+- (ndr_print_function_t) ndr_print_decode_ForestTrustInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_drsuapi.c
++++ b/source3/librpc/gen_ndr/ndr_drsuapi.c
+@@ -16500,7 +16500,7 @@ static const struct ndr_interface_call d
+ sizeof(struct drsuapi_DsBind),
+ (ndr_push_flags_fn_t) ndr_push_drsuapi_DsBind,
+ (ndr_pull_flags_fn_t) ndr_pull_drsuapi_DsBind,
+- (ndr_print_function_t) ndr_print_drsuapi_DsBind,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -16509,7 +16509,7 @@ static const struct ndr_interface_call d
+ sizeof(struct drsuapi_DsUnbind),
+ (ndr_push_flags_fn_t) ndr_push_drsuapi_DsUnbind,
+ (ndr_pull_flags_fn_t) ndr_pull_drsuapi_DsUnbind,
+- (ndr_print_function_t) ndr_print_drsuapi_DsUnbind,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -16518,7 +16518,7 @@ static const struct ndr_interface_call d
+ sizeof(struct drsuapi_DsReplicaSync),
+ (ndr_push_flags_fn_t) ndr_push_drsuapi_DsReplicaSync,
+ (ndr_pull_flags_fn_t) ndr_pull_drsuapi_DsReplicaSync,
+- (ndr_print_function_t) ndr_print_drsuapi_DsReplicaSync,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -16527,7 +16527,7 @@ static const struct ndr_interface_call d
+ sizeof(struct drsuapi_DsGetNCChanges),
+ (ndr_push_flags_fn_t) ndr_push_drsuapi_DsGetNCChanges,
+ (ndr_pull_flags_fn_t) ndr_pull_drsuapi_DsGetNCChanges,
+- (ndr_print_function_t) ndr_print_drsuapi_DsGetNCChanges,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -16536,7 +16536,7 @@ static const struct ndr_interface_call d
+ sizeof(struct drsuapi_DsReplicaUpdateRefs),
+ (ndr_push_flags_fn_t) ndr_push_drsuapi_DsReplicaUpdateRefs,
+ (ndr_pull_flags_fn_t) ndr_pull_drsuapi_DsReplicaUpdateRefs,
+- (ndr_print_function_t) ndr_print_drsuapi_DsReplicaUpdateRefs,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -16545,7 +16545,7 @@ static const struct ndr_interface_call d
+ sizeof(struct drsuapi_DsReplicaAdd),
+ (ndr_push_flags_fn_t) ndr_push_drsuapi_DsReplicaAdd,
+ (ndr_pull_flags_fn_t) ndr_pull_drsuapi_DsReplicaAdd,
+- (ndr_print_function_t) ndr_print_drsuapi_DsReplicaAdd,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -16554,7 +16554,7 @@ static const struct ndr_interface_call d
+ sizeof(struct drsuapi_DsReplicaDel),
+ (ndr_push_flags_fn_t) ndr_push_drsuapi_DsReplicaDel,
+ (ndr_pull_flags_fn_t) ndr_pull_drsuapi_DsReplicaDel,
+- (ndr_print_function_t) ndr_print_drsuapi_DsReplicaDel,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -16563,7 +16563,7 @@ static const struct ndr_interface_call d
+ sizeof(struct drsuapi_DsReplicaMod),
+ (ndr_push_flags_fn_t) ndr_push_drsuapi_DsReplicaMod,
+ (ndr_pull_flags_fn_t) ndr_pull_drsuapi_DsReplicaMod,
+- (ndr_print_function_t) ndr_print_drsuapi_DsReplicaMod,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -16572,7 +16572,7 @@ static const struct ndr_interface_call d
+ sizeof(struct DRSUAPI_VERIFY_NAMES),
+ (ndr_push_flags_fn_t) ndr_push_DRSUAPI_VERIFY_NAMES,
+ (ndr_pull_flags_fn_t) ndr_pull_DRSUAPI_VERIFY_NAMES,
+- (ndr_print_function_t) ndr_print_DRSUAPI_VERIFY_NAMES,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -16581,7 +16581,7 @@ static const struct ndr_interface_call d
+ sizeof(struct drsuapi_DsGetMemberships),
+ (ndr_push_flags_fn_t) ndr_push_drsuapi_DsGetMemberships,
+ (ndr_pull_flags_fn_t) ndr_pull_drsuapi_DsGetMemberships,
+- (ndr_print_function_t) ndr_print_drsuapi_DsGetMemberships,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -16590,7 +16590,7 @@ static const struct ndr_interface_call d
+ sizeof(struct DRSUAPI_INTER_DOMAIN_MOVE),
+ (ndr_push_flags_fn_t) ndr_push_DRSUAPI_INTER_DOMAIN_MOVE,
+ (ndr_pull_flags_fn_t) ndr_pull_DRSUAPI_INTER_DOMAIN_MOVE,
+- (ndr_print_function_t) ndr_print_DRSUAPI_INTER_DOMAIN_MOVE,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -16599,7 +16599,7 @@ static const struct ndr_interface_call d
+ sizeof(struct drsuapi_DsGetNT4ChangeLog),
+ (ndr_push_flags_fn_t) ndr_push_drsuapi_DsGetNT4ChangeLog,
+ (ndr_pull_flags_fn_t) ndr_pull_drsuapi_DsGetNT4ChangeLog,
+- (ndr_print_function_t) ndr_print_drsuapi_DsGetNT4ChangeLog,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -16608,7 +16608,7 @@ static const struct ndr_interface_call d
+ sizeof(struct drsuapi_DsCrackNames),
+ (ndr_push_flags_fn_t) ndr_push_drsuapi_DsCrackNames,
+ (ndr_pull_flags_fn_t) ndr_pull_drsuapi_DsCrackNames,
+- (ndr_print_function_t) ndr_print_drsuapi_DsCrackNames,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -16617,7 +16617,7 @@ static const struct ndr_interface_call d
+ sizeof(struct drsuapi_DsWriteAccountSpn),
+ (ndr_push_flags_fn_t) ndr_push_drsuapi_DsWriteAccountSpn,
+ (ndr_pull_flags_fn_t) ndr_pull_drsuapi_DsWriteAccountSpn,
+- (ndr_print_function_t) ndr_print_drsuapi_DsWriteAccountSpn,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -16626,7 +16626,7 @@ static const struct ndr_interface_call d
+ sizeof(struct drsuapi_DsRemoveDSServer),
+ (ndr_push_flags_fn_t) ndr_push_drsuapi_DsRemoveDSServer,
+ (ndr_pull_flags_fn_t) ndr_pull_drsuapi_DsRemoveDSServer,
+- (ndr_print_function_t) ndr_print_drsuapi_DsRemoveDSServer,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -16635,7 +16635,7 @@ static const struct ndr_interface_call d
+ sizeof(struct DRSUAPI_REMOVE_DS_DOMAIN),
+ (ndr_push_flags_fn_t) ndr_push_DRSUAPI_REMOVE_DS_DOMAIN,
+ (ndr_pull_flags_fn_t) ndr_pull_DRSUAPI_REMOVE_DS_DOMAIN,
+- (ndr_print_function_t) ndr_print_DRSUAPI_REMOVE_DS_DOMAIN,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -16644,7 +16644,7 @@ static const struct ndr_interface_call d
+ sizeof(struct drsuapi_DsGetDomainControllerInfo),
+ (ndr_push_flags_fn_t) ndr_push_drsuapi_DsGetDomainControllerInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_drsuapi_DsGetDomainControllerInfo,
+- (ndr_print_function_t) ndr_print_drsuapi_DsGetDomainControllerInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -16653,7 +16653,7 @@ static const struct ndr_interface_call d
+ sizeof(struct drsuapi_DsAddEntry),
+ (ndr_push_flags_fn_t) ndr_push_drsuapi_DsAddEntry,
+ (ndr_pull_flags_fn_t) ndr_pull_drsuapi_DsAddEntry,
+- (ndr_print_function_t) ndr_print_drsuapi_DsAddEntry,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -16662,7 +16662,7 @@ static const struct ndr_interface_call d
+ sizeof(struct drsuapi_DsExecuteKCC),
+ (ndr_push_flags_fn_t) ndr_push_drsuapi_DsExecuteKCC,
+ (ndr_pull_flags_fn_t) ndr_pull_drsuapi_DsExecuteKCC,
+- (ndr_print_function_t) ndr_print_drsuapi_DsExecuteKCC,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -16671,7 +16671,7 @@ static const struct ndr_interface_call d
+ sizeof(struct drsuapi_DsReplicaGetInfo),
+ (ndr_push_flags_fn_t) ndr_push_drsuapi_DsReplicaGetInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_drsuapi_DsReplicaGetInfo,
+- (ndr_print_function_t) ndr_print_drsuapi_DsReplicaGetInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -16680,7 +16680,7 @@ static const struct ndr_interface_call d
+ sizeof(struct DRSUAPI_ADD_SID_HISTORY),
+ (ndr_push_flags_fn_t) ndr_push_DRSUAPI_ADD_SID_HISTORY,
+ (ndr_pull_flags_fn_t) ndr_pull_DRSUAPI_ADD_SID_HISTORY,
+- (ndr_print_function_t) ndr_print_DRSUAPI_ADD_SID_HISTORY,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -16689,7 +16689,7 @@ static const struct ndr_interface_call d
+ sizeof(struct drsuapi_DsGetMemberships2),
+ (ndr_push_flags_fn_t) ndr_push_drsuapi_DsGetMemberships2,
+ (ndr_pull_flags_fn_t) ndr_pull_drsuapi_DsGetMemberships2,
+- (ndr_print_function_t) ndr_print_drsuapi_DsGetMemberships2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -16698,7 +16698,7 @@ static const struct ndr_interface_call d
+ sizeof(struct DRSUAPI_REPLICA_VERIFY_OBJECTS),
+ (ndr_push_flags_fn_t) ndr_push_DRSUAPI_REPLICA_VERIFY_OBJECTS,
+ (ndr_pull_flags_fn_t) ndr_pull_DRSUAPI_REPLICA_VERIFY_OBJECTS,
+- (ndr_print_function_t) ndr_print_DRSUAPI_REPLICA_VERIFY_OBJECTS,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -16707,7 +16707,7 @@ static const struct ndr_interface_call d
+ sizeof(struct DRSUAPI_GET_OBJECT_EXISTENCE),
+ (ndr_push_flags_fn_t) ndr_push_DRSUAPI_GET_OBJECT_EXISTENCE,
+ (ndr_pull_flags_fn_t) ndr_pull_DRSUAPI_GET_OBJECT_EXISTENCE,
+- (ndr_print_function_t) ndr_print_DRSUAPI_GET_OBJECT_EXISTENCE,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -16716,7 +16716,7 @@ static const struct ndr_interface_call d
+ sizeof(struct drsuapi_QuerySitesByCost),
+ (ndr_push_flags_fn_t) ndr_push_drsuapi_QuerySitesByCost,
+ (ndr_pull_flags_fn_t) ndr_pull_drsuapi_QuerySitesByCost,
+- (ndr_print_function_t) ndr_print_drsuapi_QuerySitesByCost,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_dsbackup.c
++++ b/source3/librpc/gen_ndr/ndr_dsbackup.c
+@@ -360,7 +360,7 @@ static const struct ndr_interface_call a
+ sizeof(struct HrRBackupPrepare),
+ (ndr_push_flags_fn_t) ndr_push_HrRBackupPrepare,
+ (ndr_pull_flags_fn_t) ndr_pull_HrRBackupPrepare,
+- (ndr_print_function_t) ndr_print_HrRBackupPrepare,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -369,7 +369,7 @@ static const struct ndr_interface_call a
+ sizeof(struct HrRBackupEnd),
+ (ndr_push_flags_fn_t) ndr_push_HrRBackupEnd,
+ (ndr_pull_flags_fn_t) ndr_pull_HrRBackupEnd,
+- (ndr_print_function_t) ndr_print_HrRBackupEnd,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -378,7 +378,7 @@ static const struct ndr_interface_call a
+ sizeof(struct HrRBackupGetAttachmentInformation),
+ (ndr_push_flags_fn_t) ndr_push_HrRBackupGetAttachmentInformation,
+ (ndr_pull_flags_fn_t) ndr_pull_HrRBackupGetAttachmentInformation,
+- (ndr_print_function_t) ndr_print_HrRBackupGetAttachmentInformation,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -387,7 +387,7 @@ static const struct ndr_interface_call a
+ sizeof(struct HrRBackupOpenFile),
+ (ndr_push_flags_fn_t) ndr_push_HrRBackupOpenFile,
+ (ndr_pull_flags_fn_t) ndr_pull_HrRBackupOpenFile,
+- (ndr_print_function_t) ndr_print_HrRBackupOpenFile,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -396,7 +396,7 @@ static const struct ndr_interface_call a
+ sizeof(struct HrRBackupRead),
+ (ndr_push_flags_fn_t) ndr_push_HrRBackupRead,
+ (ndr_pull_flags_fn_t) ndr_pull_HrRBackupRead,
+- (ndr_print_function_t) ndr_print_HrRBackupRead,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -405,7 +405,7 @@ static const struct ndr_interface_call a
+ sizeof(struct HrRBackupClose),
+ (ndr_push_flags_fn_t) ndr_push_HrRBackupClose,
+ (ndr_pull_flags_fn_t) ndr_pull_HrRBackupClose,
+- (ndr_print_function_t) ndr_print_HrRBackupClose,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -414,7 +414,7 @@ static const struct ndr_interface_call a
+ sizeof(struct HrRBackupGetBackupLogs),
+ (ndr_push_flags_fn_t) ndr_push_HrRBackupGetBackupLogs,
+ (ndr_pull_flags_fn_t) ndr_pull_HrRBackupGetBackupLogs,
+- (ndr_print_function_t) ndr_print_HrRBackupGetBackupLogs,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -423,7 +423,7 @@ static const struct ndr_interface_call a
+ sizeof(struct HrRBackupTruncateLogs),
+ (ndr_push_flags_fn_t) ndr_push_HrRBackupTruncateLogs,
+ (ndr_pull_flags_fn_t) ndr_pull_HrRBackupTruncateLogs,
+- (ndr_print_function_t) ndr_print_HrRBackupTruncateLogs,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -432,7 +432,7 @@ static const struct ndr_interface_call a
+ sizeof(struct HrRBackupPing),
+ (ndr_push_flags_fn_t) ndr_push_HrRBackupPing,
+ (ndr_pull_flags_fn_t) ndr_pull_HrRBackupPing,
+- (ndr_print_function_t) ndr_print_HrRBackupPing,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -789,7 +789,7 @@ static const struct ndr_interface_call a
+ sizeof(struct HrRIsNTDSOnline),
+ (ndr_push_flags_fn_t) ndr_push_HrRIsNTDSOnline,
+ (ndr_pull_flags_fn_t) ndr_pull_HrRIsNTDSOnline,
+- (ndr_print_function_t) ndr_print_HrRIsNTDSOnline,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -798,7 +798,7 @@ static const struct ndr_interface_call a
+ sizeof(struct HrRRestorePrepare),
+ (ndr_push_flags_fn_t) ndr_push_HrRRestorePrepare,
+ (ndr_pull_flags_fn_t) ndr_pull_HrRRestorePrepare,
+- (ndr_print_function_t) ndr_print_HrRRestorePrepare,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -807,7 +807,7 @@ static const struct ndr_interface_call a
+ sizeof(struct HrRRestoreRegister),
+ (ndr_push_flags_fn_t) ndr_push_HrRRestoreRegister,
+ (ndr_pull_flags_fn_t) ndr_pull_HrRRestoreRegister,
+- (ndr_print_function_t) ndr_print_HrRRestoreRegister,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -816,7 +816,7 @@ static const struct ndr_interface_call a
+ sizeof(struct HrRRestoreRegisterComplete),
+ (ndr_push_flags_fn_t) ndr_push_HrRRestoreRegisterComplete,
+ (ndr_pull_flags_fn_t) ndr_pull_HrRRestoreRegisterComplete,
+- (ndr_print_function_t) ndr_print_HrRRestoreRegisterComplete,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -825,7 +825,7 @@ static const struct ndr_interface_call a
+ sizeof(struct HrRRestoreGetDatabaseLocations),
+ (ndr_push_flags_fn_t) ndr_push_HrRRestoreGetDatabaseLocations,
+ (ndr_pull_flags_fn_t) ndr_pull_HrRRestoreGetDatabaseLocations,
+- (ndr_print_function_t) ndr_print_HrRRestoreGetDatabaseLocations,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -834,7 +834,7 @@ static const struct ndr_interface_call a
+ sizeof(struct HrRRestoreEnd),
+ (ndr_push_flags_fn_t) ndr_push_HrRRestoreEnd,
+ (ndr_pull_flags_fn_t) ndr_pull_HrRRestoreEnd,
+- (ndr_print_function_t) ndr_print_HrRRestoreEnd,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -843,7 +843,7 @@ static const struct ndr_interface_call a
+ sizeof(struct HrRRestoreSetCurrentLogNumber),
+ (ndr_push_flags_fn_t) ndr_push_HrRRestoreSetCurrentLogNumber,
+ (ndr_pull_flags_fn_t) ndr_pull_HrRRestoreSetCurrentLogNumber,
+- (ndr_print_function_t) ndr_print_HrRRestoreSetCurrentLogNumber,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -852,7 +852,7 @@ static const struct ndr_interface_call a
+ sizeof(struct HrRRestoreCheckLogsForBackup),
+ (ndr_push_flags_fn_t) ndr_push_HrRRestoreCheckLogsForBackup,
+ (ndr_pull_flags_fn_t) ndr_pull_HrRRestoreCheckLogsForBackup,
+- (ndr_print_function_t) ndr_print_HrRRestoreCheckLogsForBackup,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_dssetup.c
++++ b/source3/librpc/gen_ndr/ndr_dssetup.c
+@@ -995,7 +995,7 @@ static const struct ndr_interface_call d
+ sizeof(struct dssetup_DsRoleGetPrimaryDomainInformation),
+ (ndr_push_flags_fn_t) ndr_push_dssetup_DsRoleGetPrimaryDomainInformation,
+ (ndr_pull_flags_fn_t) ndr_pull_dssetup_DsRoleGetPrimaryDomainInformation,
+- (ndr_print_function_t) ndr_print_dssetup_DsRoleGetPrimaryDomainInformation,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1004,7 +1004,7 @@ static const struct ndr_interface_call d
+ sizeof(struct dssetup_DsRoleDnsNameToFlatName),
+ (ndr_push_flags_fn_t) ndr_push_dssetup_DsRoleDnsNameToFlatName,
+ (ndr_pull_flags_fn_t) ndr_pull_dssetup_DsRoleDnsNameToFlatName,
+- (ndr_print_function_t) ndr_print_dssetup_DsRoleDnsNameToFlatName,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1013,7 +1013,7 @@ static const struct ndr_interface_call d
+ sizeof(struct dssetup_DsRoleDcAsDc),
+ (ndr_push_flags_fn_t) ndr_push_dssetup_DsRoleDcAsDc,
+ (ndr_pull_flags_fn_t) ndr_pull_dssetup_DsRoleDcAsDc,
+- (ndr_print_function_t) ndr_print_dssetup_DsRoleDcAsDc,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1022,7 +1022,7 @@ static const struct ndr_interface_call d
+ sizeof(struct dssetup_DsRoleDcAsReplica),
+ (ndr_push_flags_fn_t) ndr_push_dssetup_DsRoleDcAsReplica,
+ (ndr_pull_flags_fn_t) ndr_pull_dssetup_DsRoleDcAsReplica,
+- (ndr_print_function_t) ndr_print_dssetup_DsRoleDcAsReplica,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1031,7 +1031,7 @@ static const struct ndr_interface_call d
+ sizeof(struct dssetup_DsRoleDemoteDc),
+ (ndr_push_flags_fn_t) ndr_push_dssetup_DsRoleDemoteDc,
+ (ndr_pull_flags_fn_t) ndr_pull_dssetup_DsRoleDemoteDc,
+- (ndr_print_function_t) ndr_print_dssetup_DsRoleDemoteDc,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1040,7 +1040,7 @@ static const struct ndr_interface_call d
+ sizeof(struct dssetup_DsRoleGetDcOperationProgress),
+ (ndr_push_flags_fn_t) ndr_push_dssetup_DsRoleGetDcOperationProgress,
+ (ndr_pull_flags_fn_t) ndr_pull_dssetup_DsRoleGetDcOperationProgress,
+- (ndr_print_function_t) ndr_print_dssetup_DsRoleGetDcOperationProgress,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1049,7 +1049,7 @@ static const struct ndr_interface_call d
+ sizeof(struct dssetup_DsRoleGetDcOperationResults),
+ (ndr_push_flags_fn_t) ndr_push_dssetup_DsRoleGetDcOperationResults,
+ (ndr_pull_flags_fn_t) ndr_pull_dssetup_DsRoleGetDcOperationResults,
+- (ndr_print_function_t) ndr_print_dssetup_DsRoleGetDcOperationResults,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1058,7 +1058,7 @@ static const struct ndr_interface_call d
+ sizeof(struct dssetup_DsRoleCancel),
+ (ndr_push_flags_fn_t) ndr_push_dssetup_DsRoleCancel,
+ (ndr_pull_flags_fn_t) ndr_pull_dssetup_DsRoleCancel,
+- (ndr_print_function_t) ndr_print_dssetup_DsRoleCancel,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1067,7 +1067,7 @@ static const struct ndr_interface_call d
+ sizeof(struct dssetup_DsRoleServerSaveStateForUpgrade),
+ (ndr_push_flags_fn_t) ndr_push_dssetup_DsRoleServerSaveStateForUpgrade,
+ (ndr_pull_flags_fn_t) ndr_pull_dssetup_DsRoleServerSaveStateForUpgrade,
+- (ndr_print_function_t) ndr_print_dssetup_DsRoleServerSaveStateForUpgrade,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1076,7 +1076,7 @@ static const struct ndr_interface_call d
+ sizeof(struct dssetup_DsRoleUpgradeDownlevelServer),
+ (ndr_push_flags_fn_t) ndr_push_dssetup_DsRoleUpgradeDownlevelServer,
+ (ndr_pull_flags_fn_t) ndr_pull_dssetup_DsRoleUpgradeDownlevelServer,
+- (ndr_print_function_t) ndr_print_dssetup_DsRoleUpgradeDownlevelServer,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1085,7 +1085,7 @@ static const struct ndr_interface_call d
+ sizeof(struct dssetup_DsRoleAbortDownlevelServerUpgrade),
+ (ndr_push_flags_fn_t) ndr_push_dssetup_DsRoleAbortDownlevelServerUpgrade,
+ (ndr_pull_flags_fn_t) ndr_pull_dssetup_DsRoleAbortDownlevelServerUpgrade,
+- (ndr_print_function_t) ndr_print_dssetup_DsRoleAbortDownlevelServerUpgrade,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_echo.c
++++ b/source3/librpc/gen_ndr/ndr_echo.c
+@@ -1458,7 +1458,7 @@ static const struct ndr_interface_call r
+ sizeof(struct echo_AddOne),
+ (ndr_push_flags_fn_t) ndr_push_echo_AddOne,
+ (ndr_pull_flags_fn_t) ndr_pull_echo_AddOne,
+- (ndr_print_function_t) ndr_print_echo_AddOne,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1467,7 +1467,7 @@ static const struct ndr_interface_call r
+ sizeof(struct echo_EchoData),
+ (ndr_push_flags_fn_t) ndr_push_echo_EchoData,
+ (ndr_pull_flags_fn_t) ndr_pull_echo_EchoData,
+- (ndr_print_function_t) ndr_print_echo_EchoData,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1476,7 +1476,7 @@ static const struct ndr_interface_call r
+ sizeof(struct echo_SinkData),
+ (ndr_push_flags_fn_t) ndr_push_echo_SinkData,
+ (ndr_pull_flags_fn_t) ndr_pull_echo_SinkData,
+- (ndr_print_function_t) ndr_print_echo_SinkData,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1485,7 +1485,7 @@ static const struct ndr_interface_call r
+ sizeof(struct echo_SourceData),
+ (ndr_push_flags_fn_t) ndr_push_echo_SourceData,
+ (ndr_pull_flags_fn_t) ndr_pull_echo_SourceData,
+- (ndr_print_function_t) ndr_print_echo_SourceData,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1494,7 +1494,7 @@ static const struct ndr_interface_call r
+ sizeof(struct echo_TestCall),
+ (ndr_push_flags_fn_t) ndr_push_echo_TestCall,
+ (ndr_pull_flags_fn_t) ndr_pull_echo_TestCall,
+- (ndr_print_function_t) ndr_print_echo_TestCall,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1503,7 +1503,7 @@ static const struct ndr_interface_call r
+ sizeof(struct echo_TestCall2),
+ (ndr_push_flags_fn_t) ndr_push_echo_TestCall2,
+ (ndr_pull_flags_fn_t) ndr_pull_echo_TestCall2,
+- (ndr_print_function_t) ndr_print_echo_TestCall2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1512,7 +1512,7 @@ static const struct ndr_interface_call r
+ sizeof(struct echo_TestSleep),
+ (ndr_push_flags_fn_t) ndr_push_echo_TestSleep,
+ (ndr_pull_flags_fn_t) ndr_pull_echo_TestSleep,
+- (ndr_print_function_t) ndr_print_echo_TestSleep,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1521,7 +1521,7 @@ static const struct ndr_interface_call r
+ sizeof(struct echo_TestEnum),
+ (ndr_push_flags_fn_t) ndr_push_echo_TestEnum,
+ (ndr_pull_flags_fn_t) ndr_pull_echo_TestEnum,
+- (ndr_print_function_t) ndr_print_echo_TestEnum,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1530,7 +1530,7 @@ static const struct ndr_interface_call r
+ sizeof(struct echo_TestSurrounding),
+ (ndr_push_flags_fn_t) ndr_push_echo_TestSurrounding,
+ (ndr_pull_flags_fn_t) ndr_pull_echo_TestSurrounding,
+- (ndr_print_function_t) ndr_print_echo_TestSurrounding,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1539,7 +1539,7 @@ static const struct ndr_interface_call r
+ sizeof(struct echo_TestDoublePointer),
+ (ndr_push_flags_fn_t) ndr_push_echo_TestDoublePointer,
+ (ndr_pull_flags_fn_t) ndr_pull_echo_TestDoublePointer,
+- (ndr_print_function_t) ndr_print_echo_TestDoublePointer,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_efs.c
++++ b/source3/librpc/gen_ndr/ndr_efs.c
+@@ -1327,7 +1327,7 @@ static const struct ndr_interface_call e
+ sizeof(struct EfsRpcOpenFileRaw),
+ (ndr_push_flags_fn_t) ndr_push_EfsRpcOpenFileRaw,
+ (ndr_pull_flags_fn_t) ndr_pull_EfsRpcOpenFileRaw,
+- (ndr_print_function_t) ndr_print_EfsRpcOpenFileRaw,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1336,7 +1336,7 @@ static const struct ndr_interface_call e
+ sizeof(struct EfsRpcReadFileRaw),
+ (ndr_push_flags_fn_t) ndr_push_EfsRpcReadFileRaw,
+ (ndr_pull_flags_fn_t) ndr_pull_EfsRpcReadFileRaw,
+- (ndr_print_function_t) ndr_print_EfsRpcReadFileRaw,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1345,7 +1345,7 @@ static const struct ndr_interface_call e
+ sizeof(struct EfsRpcWriteFileRaw),
+ (ndr_push_flags_fn_t) ndr_push_EfsRpcWriteFileRaw,
+ (ndr_pull_flags_fn_t) ndr_pull_EfsRpcWriteFileRaw,
+- (ndr_print_function_t) ndr_print_EfsRpcWriteFileRaw,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1354,7 +1354,7 @@ static const struct ndr_interface_call e
+ sizeof(struct EfsRpcCloseRaw),
+ (ndr_push_flags_fn_t) ndr_push_EfsRpcCloseRaw,
+ (ndr_pull_flags_fn_t) ndr_pull_EfsRpcCloseRaw,
+- (ndr_print_function_t) ndr_print_EfsRpcCloseRaw,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1363,7 +1363,7 @@ static const struct ndr_interface_call e
+ sizeof(struct EfsRpcEncryptFileSrv),
+ (ndr_push_flags_fn_t) ndr_push_EfsRpcEncryptFileSrv,
+ (ndr_pull_flags_fn_t) ndr_pull_EfsRpcEncryptFileSrv,
+- (ndr_print_function_t) ndr_print_EfsRpcEncryptFileSrv,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1372,7 +1372,7 @@ static const struct ndr_interface_call e
+ sizeof(struct EfsRpcDecryptFileSrv),
+ (ndr_push_flags_fn_t) ndr_push_EfsRpcDecryptFileSrv,
+ (ndr_pull_flags_fn_t) ndr_pull_EfsRpcDecryptFileSrv,
+- (ndr_print_function_t) ndr_print_EfsRpcDecryptFileSrv,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1381,7 +1381,7 @@ static const struct ndr_interface_call e
+ sizeof(struct EfsRpcQueryUsersOnFile),
+ (ndr_push_flags_fn_t) ndr_push_EfsRpcQueryUsersOnFile,
+ (ndr_pull_flags_fn_t) ndr_pull_EfsRpcQueryUsersOnFile,
+- (ndr_print_function_t) ndr_print_EfsRpcQueryUsersOnFile,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1390,7 +1390,7 @@ static const struct ndr_interface_call e
+ sizeof(struct EfsRpcQueryRecoveryAgents),
+ (ndr_push_flags_fn_t) ndr_push_EfsRpcQueryRecoveryAgents,
+ (ndr_pull_flags_fn_t) ndr_pull_EfsRpcQueryRecoveryAgents,
+- (ndr_print_function_t) ndr_print_EfsRpcQueryRecoveryAgents,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1399,7 +1399,7 @@ static const struct ndr_interface_call e
+ sizeof(struct EfsRpcRemoveUsersFromFile),
+ (ndr_push_flags_fn_t) ndr_push_EfsRpcRemoveUsersFromFile,
+ (ndr_pull_flags_fn_t) ndr_pull_EfsRpcRemoveUsersFromFile,
+- (ndr_print_function_t) ndr_print_EfsRpcRemoveUsersFromFile,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1408,7 +1408,7 @@ static const struct ndr_interface_call e
+ sizeof(struct EfsRpcAddUsersToFile),
+ (ndr_push_flags_fn_t) ndr_push_EfsRpcAddUsersToFile,
+ (ndr_pull_flags_fn_t) ndr_pull_EfsRpcAddUsersToFile,
+- (ndr_print_function_t) ndr_print_EfsRpcAddUsersToFile,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1417,7 +1417,7 @@ static const struct ndr_interface_call e
+ sizeof(struct EfsRpcSetFileEncryptionKey),
+ (ndr_push_flags_fn_t) ndr_push_EfsRpcSetFileEncryptionKey,
+ (ndr_pull_flags_fn_t) ndr_pull_EfsRpcSetFileEncryptionKey,
+- (ndr_print_function_t) ndr_print_EfsRpcSetFileEncryptionKey,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1426,7 +1426,7 @@ static const struct ndr_interface_call e
+ sizeof(struct EfsRpcNotSupported),
+ (ndr_push_flags_fn_t) ndr_push_EfsRpcNotSupported,
+ (ndr_pull_flags_fn_t) ndr_pull_EfsRpcNotSupported,
+- (ndr_print_function_t) ndr_print_EfsRpcNotSupported,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1435,7 +1435,7 @@ static const struct ndr_interface_call e
+ sizeof(struct EfsRpcFileKeyInfo),
+ (ndr_push_flags_fn_t) ndr_push_EfsRpcFileKeyInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_EfsRpcFileKeyInfo,
+- (ndr_print_function_t) ndr_print_EfsRpcFileKeyInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1444,7 +1444,7 @@ static const struct ndr_interface_call e
+ sizeof(struct EfsRpcDuplicateEncryptionInfoFile),
+ (ndr_push_flags_fn_t) ndr_push_EfsRpcDuplicateEncryptionInfoFile,
+ (ndr_pull_flags_fn_t) ndr_pull_EfsRpcDuplicateEncryptionInfoFile,
+- (ndr_print_function_t) ndr_print_EfsRpcDuplicateEncryptionInfoFile,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_epmapper.c
++++ b/source3/librpc/gen_ndr/ndr_epmapper.c
+@@ -2754,7 +2754,7 @@ static const struct ndr_interface_call e
+ sizeof(struct epm_Insert),
+ (ndr_push_flags_fn_t) ndr_push_epm_Insert,
+ (ndr_pull_flags_fn_t) ndr_pull_epm_Insert,
+- (ndr_print_function_t) ndr_print_epm_Insert,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2763,7 +2763,7 @@ static const struct ndr_interface_call e
+ sizeof(struct epm_Delete),
+ (ndr_push_flags_fn_t) ndr_push_epm_Delete,
+ (ndr_pull_flags_fn_t) ndr_pull_epm_Delete,
+- (ndr_print_function_t) ndr_print_epm_Delete,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2772,7 +2772,7 @@ static const struct ndr_interface_call e
+ sizeof(struct epm_Lookup),
+ (ndr_push_flags_fn_t) ndr_push_epm_Lookup,
+ (ndr_pull_flags_fn_t) ndr_pull_epm_Lookup,
+- (ndr_print_function_t) ndr_print_epm_Lookup,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2781,7 +2781,7 @@ static const struct ndr_interface_call e
+ sizeof(struct epm_Map),
+ (ndr_push_flags_fn_t) ndr_push_epm_Map,
+ (ndr_pull_flags_fn_t) ndr_pull_epm_Map,
+- (ndr_print_function_t) ndr_print_epm_Map,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2790,7 +2790,7 @@ static const struct ndr_interface_call e
+ sizeof(struct epm_LookupHandleFree),
+ (ndr_push_flags_fn_t) ndr_push_epm_LookupHandleFree,
+ (ndr_pull_flags_fn_t) ndr_pull_epm_LookupHandleFree,
+- (ndr_print_function_t) ndr_print_epm_LookupHandleFree,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2799,7 +2799,7 @@ static const struct ndr_interface_call e
+ sizeof(struct epm_InqObject),
+ (ndr_push_flags_fn_t) ndr_push_epm_InqObject,
+ (ndr_pull_flags_fn_t) ndr_pull_epm_InqObject,
+- (ndr_print_function_t) ndr_print_epm_InqObject,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2808,7 +2808,7 @@ static const struct ndr_interface_call e
+ sizeof(struct epm_MgmtDelete),
+ (ndr_push_flags_fn_t) ndr_push_epm_MgmtDelete,
+ (ndr_pull_flags_fn_t) ndr_pull_epm_MgmtDelete,
+- (ndr_print_function_t) ndr_print_epm_MgmtDelete,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2817,7 +2817,7 @@ static const struct ndr_interface_call e
+ sizeof(struct epm_MapAuth),
+ (ndr_push_flags_fn_t) ndr_push_epm_MapAuth,
+ (ndr_pull_flags_fn_t) ndr_pull_epm_MapAuth,
+- (ndr_print_function_t) ndr_print_epm_MapAuth,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_eventlog.c
++++ b/source3/librpc/gen_ndr/ndr_eventlog.c
+@@ -2983,7 +2983,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog_ClearEventLogW),
+ (ndr_push_flags_fn_t) ndr_push_eventlog_ClearEventLogW,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog_ClearEventLogW,
+- (ndr_print_function_t) ndr_print_eventlog_ClearEventLogW,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2992,7 +2992,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog_BackupEventLogW),
+ (ndr_push_flags_fn_t) ndr_push_eventlog_BackupEventLogW,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog_BackupEventLogW,
+- (ndr_print_function_t) ndr_print_eventlog_BackupEventLogW,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3001,7 +3001,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog_CloseEventLog),
+ (ndr_push_flags_fn_t) ndr_push_eventlog_CloseEventLog,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog_CloseEventLog,
+- (ndr_print_function_t) ndr_print_eventlog_CloseEventLog,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3010,7 +3010,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog_DeregisterEventSource),
+ (ndr_push_flags_fn_t) ndr_push_eventlog_DeregisterEventSource,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog_DeregisterEventSource,
+- (ndr_print_function_t) ndr_print_eventlog_DeregisterEventSource,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3019,7 +3019,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog_GetNumRecords),
+ (ndr_push_flags_fn_t) ndr_push_eventlog_GetNumRecords,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog_GetNumRecords,
+- (ndr_print_function_t) ndr_print_eventlog_GetNumRecords,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3028,7 +3028,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog_GetOldestRecord),
+ (ndr_push_flags_fn_t) ndr_push_eventlog_GetOldestRecord,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog_GetOldestRecord,
+- (ndr_print_function_t) ndr_print_eventlog_GetOldestRecord,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3037,7 +3037,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog_ChangeNotify),
+ (ndr_push_flags_fn_t) ndr_push_eventlog_ChangeNotify,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog_ChangeNotify,
+- (ndr_print_function_t) ndr_print_eventlog_ChangeNotify,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3046,7 +3046,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog_OpenEventLogW),
+ (ndr_push_flags_fn_t) ndr_push_eventlog_OpenEventLogW,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog_OpenEventLogW,
+- (ndr_print_function_t) ndr_print_eventlog_OpenEventLogW,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3055,7 +3055,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog_RegisterEventSourceW),
+ (ndr_push_flags_fn_t) ndr_push_eventlog_RegisterEventSourceW,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog_RegisterEventSourceW,
+- (ndr_print_function_t) ndr_print_eventlog_RegisterEventSourceW,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3064,7 +3064,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog_OpenBackupEventLogW),
+ (ndr_push_flags_fn_t) ndr_push_eventlog_OpenBackupEventLogW,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog_OpenBackupEventLogW,
+- (ndr_print_function_t) ndr_print_eventlog_OpenBackupEventLogW,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3073,7 +3073,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog_ReadEventLogW),
+ (ndr_push_flags_fn_t) ndr_push_eventlog_ReadEventLogW,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog_ReadEventLogW,
+- (ndr_print_function_t) ndr_print_eventlog_ReadEventLogW,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3082,7 +3082,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog_ReportEventW),
+ (ndr_push_flags_fn_t) ndr_push_eventlog_ReportEventW,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog_ReportEventW,
+- (ndr_print_function_t) ndr_print_eventlog_ReportEventW,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3091,7 +3091,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog_ClearEventLogA),
+ (ndr_push_flags_fn_t) ndr_push_eventlog_ClearEventLogA,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog_ClearEventLogA,
+- (ndr_print_function_t) ndr_print_eventlog_ClearEventLogA,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3100,7 +3100,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog_BackupEventLogA),
+ (ndr_push_flags_fn_t) ndr_push_eventlog_BackupEventLogA,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog_BackupEventLogA,
+- (ndr_print_function_t) ndr_print_eventlog_BackupEventLogA,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3109,7 +3109,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog_OpenEventLogA),
+ (ndr_push_flags_fn_t) ndr_push_eventlog_OpenEventLogA,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog_OpenEventLogA,
+- (ndr_print_function_t) ndr_print_eventlog_OpenEventLogA,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3118,7 +3118,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog_RegisterEventSourceA),
+ (ndr_push_flags_fn_t) ndr_push_eventlog_RegisterEventSourceA,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog_RegisterEventSourceA,
+- (ndr_print_function_t) ndr_print_eventlog_RegisterEventSourceA,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3127,7 +3127,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog_OpenBackupEventLogA),
+ (ndr_push_flags_fn_t) ndr_push_eventlog_OpenBackupEventLogA,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog_OpenBackupEventLogA,
+- (ndr_print_function_t) ndr_print_eventlog_OpenBackupEventLogA,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3136,7 +3136,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog_ReadEventLogA),
+ (ndr_push_flags_fn_t) ndr_push_eventlog_ReadEventLogA,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog_ReadEventLogA,
+- (ndr_print_function_t) ndr_print_eventlog_ReadEventLogA,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3145,7 +3145,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog_ReportEventA),
+ (ndr_push_flags_fn_t) ndr_push_eventlog_ReportEventA,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog_ReportEventA,
+- (ndr_print_function_t) ndr_print_eventlog_ReportEventA,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3154,7 +3154,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog_RegisterClusterSvc),
+ (ndr_push_flags_fn_t) ndr_push_eventlog_RegisterClusterSvc,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog_RegisterClusterSvc,
+- (ndr_print_function_t) ndr_print_eventlog_RegisterClusterSvc,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3163,7 +3163,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog_DeregisterClusterSvc),
+ (ndr_push_flags_fn_t) ndr_push_eventlog_DeregisterClusterSvc,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog_DeregisterClusterSvc,
+- (ndr_print_function_t) ndr_print_eventlog_DeregisterClusterSvc,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3172,7 +3172,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog_WriteClusterEvents),
+ (ndr_push_flags_fn_t) ndr_push_eventlog_WriteClusterEvents,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog_WriteClusterEvents,
+- (ndr_print_function_t) ndr_print_eventlog_WriteClusterEvents,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3181,7 +3181,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog_GetLogInformation),
+ (ndr_push_flags_fn_t) ndr_push_eventlog_GetLogInformation,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog_GetLogInformation,
+- (ndr_print_function_t) ndr_print_eventlog_GetLogInformation,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3190,7 +3190,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog_FlushEventLog),
+ (ndr_push_flags_fn_t) ndr_push_eventlog_FlushEventLog,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog_FlushEventLog,
+- (ndr_print_function_t) ndr_print_eventlog_FlushEventLog,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3199,7 +3199,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog_ReportEventAndSourceW),
+ (ndr_push_flags_fn_t) ndr_push_eventlog_ReportEventAndSourceW,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog_ReportEventAndSourceW,
+- (ndr_print_function_t) ndr_print_eventlog_ReportEventAndSourceW,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_eventlog6.c
++++ b/source3/librpc/gen_ndr/ndr_eventlog6.c
+@@ -5482,7 +5482,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog6_EvtRpcRegisterRemoteSubscription),
+ (ndr_push_flags_fn_t) ndr_push_eventlog6_EvtRpcRegisterRemoteSubscription,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog6_EvtRpcRegisterRemoteSubscription,
+- (ndr_print_function_t) ndr_print_eventlog6_EvtRpcRegisterRemoteSubscription,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5491,7 +5491,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog6_EvtRpcRemoteSubscriptionNextAsync),
+ (ndr_push_flags_fn_t) ndr_push_eventlog6_EvtRpcRemoteSubscriptionNextAsync,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog6_EvtRpcRemoteSubscriptionNextAsync,
+- (ndr_print_function_t) ndr_print_eventlog6_EvtRpcRemoteSubscriptionNextAsync,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5500,7 +5500,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog6_EvtRpcRemoteSubscriptionNext),
+ (ndr_push_flags_fn_t) ndr_push_eventlog6_EvtRpcRemoteSubscriptionNext,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog6_EvtRpcRemoteSubscriptionNext,
+- (ndr_print_function_t) ndr_print_eventlog6_EvtRpcRemoteSubscriptionNext,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5509,7 +5509,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog6_EvtRpcRemoteSubscriptionWaitAsync),
+ (ndr_push_flags_fn_t) ndr_push_eventlog6_EvtRpcRemoteSubscriptionWaitAsync,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog6_EvtRpcRemoteSubscriptionWaitAsync,
+- (ndr_print_function_t) ndr_print_eventlog6_EvtRpcRemoteSubscriptionWaitAsync,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5518,7 +5518,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog6_EvtRpcRegisterControllableOperation),
+ (ndr_push_flags_fn_t) ndr_push_eventlog6_EvtRpcRegisterControllableOperation,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog6_EvtRpcRegisterControllableOperation,
+- (ndr_print_function_t) ndr_print_eventlog6_EvtRpcRegisterControllableOperation,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5527,7 +5527,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog6_EvtRpcRegisterLogQuery),
+ (ndr_push_flags_fn_t) ndr_push_eventlog6_EvtRpcRegisterLogQuery,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog6_EvtRpcRegisterLogQuery,
+- (ndr_print_function_t) ndr_print_eventlog6_EvtRpcRegisterLogQuery,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5536,7 +5536,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog6_EvtRpcClearLog),
+ (ndr_push_flags_fn_t) ndr_push_eventlog6_EvtRpcClearLog,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog6_EvtRpcClearLog,
+- (ndr_print_function_t) ndr_print_eventlog6_EvtRpcClearLog,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5545,7 +5545,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog6_EvtRpcExportLog),
+ (ndr_push_flags_fn_t) ndr_push_eventlog6_EvtRpcExportLog,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog6_EvtRpcExportLog,
+- (ndr_print_function_t) ndr_print_eventlog6_EvtRpcExportLog,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5554,7 +5554,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog6_EvtRpcLocalizeExportLog),
+ (ndr_push_flags_fn_t) ndr_push_eventlog6_EvtRpcLocalizeExportLog,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog6_EvtRpcLocalizeExportLog,
+- (ndr_print_function_t) ndr_print_eventlog6_EvtRpcLocalizeExportLog,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5563,7 +5563,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog6_EvtRpcMessageRender),
+ (ndr_push_flags_fn_t) ndr_push_eventlog6_EvtRpcMessageRender,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog6_EvtRpcMessageRender,
+- (ndr_print_function_t) ndr_print_eventlog6_EvtRpcMessageRender,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5572,7 +5572,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog6_EvtRpcMessageRenderDefault),
+ (ndr_push_flags_fn_t) ndr_push_eventlog6_EvtRpcMessageRenderDefault,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog6_EvtRpcMessageRenderDefault,
+- (ndr_print_function_t) ndr_print_eventlog6_EvtRpcMessageRenderDefault,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5581,7 +5581,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog6_EvtRpcQueryNext),
+ (ndr_push_flags_fn_t) ndr_push_eventlog6_EvtRpcQueryNext,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog6_EvtRpcQueryNext,
+- (ndr_print_function_t) ndr_print_eventlog6_EvtRpcQueryNext,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5590,7 +5590,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog6_EvtRpcQuerySeek),
+ (ndr_push_flags_fn_t) ndr_push_eventlog6_EvtRpcQuerySeek,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog6_EvtRpcQuerySeek,
+- (ndr_print_function_t) ndr_print_eventlog6_EvtRpcQuerySeek,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5599,7 +5599,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog6_EvtRpcClose),
+ (ndr_push_flags_fn_t) ndr_push_eventlog6_EvtRpcClose,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog6_EvtRpcClose,
+- (ndr_print_function_t) ndr_print_eventlog6_EvtRpcClose,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5608,7 +5608,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog6_EvtRpcCancel),
+ (ndr_push_flags_fn_t) ndr_push_eventlog6_EvtRpcCancel,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog6_EvtRpcCancel,
+- (ndr_print_function_t) ndr_print_eventlog6_EvtRpcCancel,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5617,7 +5617,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog6_EvtRpcAssertConfig),
+ (ndr_push_flags_fn_t) ndr_push_eventlog6_EvtRpcAssertConfig,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog6_EvtRpcAssertConfig,
+- (ndr_print_function_t) ndr_print_eventlog6_EvtRpcAssertConfig,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5626,7 +5626,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog6_EvtRpcRetractConfig),
+ (ndr_push_flags_fn_t) ndr_push_eventlog6_EvtRpcRetractConfig,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog6_EvtRpcRetractConfig,
+- (ndr_print_function_t) ndr_print_eventlog6_EvtRpcRetractConfig,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5635,7 +5635,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog6_EvtRpcOpenLogHandle),
+ (ndr_push_flags_fn_t) ndr_push_eventlog6_EvtRpcOpenLogHandle,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog6_EvtRpcOpenLogHandle,
+- (ndr_print_function_t) ndr_print_eventlog6_EvtRpcOpenLogHandle,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5644,7 +5644,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog6_EvtRpcGetLogFileInfo),
+ (ndr_push_flags_fn_t) ndr_push_eventlog6_EvtRpcGetLogFileInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog6_EvtRpcGetLogFileInfo,
+- (ndr_print_function_t) ndr_print_eventlog6_EvtRpcGetLogFileInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5653,7 +5653,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog6_EvtRpcGetChannelList),
+ (ndr_push_flags_fn_t) ndr_push_eventlog6_EvtRpcGetChannelList,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog6_EvtRpcGetChannelList,
+- (ndr_print_function_t) ndr_print_eventlog6_EvtRpcGetChannelList,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5662,7 +5662,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog6_EvtRpcGetChannelConfig),
+ (ndr_push_flags_fn_t) ndr_push_eventlog6_EvtRpcGetChannelConfig,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog6_EvtRpcGetChannelConfig,
+- (ndr_print_function_t) ndr_print_eventlog6_EvtRpcGetChannelConfig,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5671,7 +5671,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog6_EvtRpcPutChannelConfig),
+ (ndr_push_flags_fn_t) ndr_push_eventlog6_EvtRpcPutChannelConfig,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog6_EvtRpcPutChannelConfig,
+- (ndr_print_function_t) ndr_print_eventlog6_EvtRpcPutChannelConfig,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5680,7 +5680,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog6_EvtRpcGetPublisherList),
+ (ndr_push_flags_fn_t) ndr_push_eventlog6_EvtRpcGetPublisherList,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog6_EvtRpcGetPublisherList,
+- (ndr_print_function_t) ndr_print_eventlog6_EvtRpcGetPublisherList,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5689,7 +5689,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog6_EvtRpcGetPublisherListForChannel),
+ (ndr_push_flags_fn_t) ndr_push_eventlog6_EvtRpcGetPublisherListForChannel,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog6_EvtRpcGetPublisherListForChannel,
+- (ndr_print_function_t) ndr_print_eventlog6_EvtRpcGetPublisherListForChannel,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5698,7 +5698,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog6_EvtRpcGetPublisherMetadata),
+ (ndr_push_flags_fn_t) ndr_push_eventlog6_EvtRpcGetPublisherMetadata,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog6_EvtRpcGetPublisherMetadata,
+- (ndr_print_function_t) ndr_print_eventlog6_EvtRpcGetPublisherMetadata,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5707,7 +5707,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog6_EvtRpcGetPublisherResourceMetadata),
+ (ndr_push_flags_fn_t) ndr_push_eventlog6_EvtRpcGetPublisherResourceMetadata,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog6_EvtRpcGetPublisherResourceMetadata,
+- (ndr_print_function_t) ndr_print_eventlog6_EvtRpcGetPublisherResourceMetadata,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5716,7 +5716,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog6_EvtRpcGetEventMetadataEnum),
+ (ndr_push_flags_fn_t) ndr_push_eventlog6_EvtRpcGetEventMetadataEnum,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog6_EvtRpcGetEventMetadataEnum,
+- (ndr_print_function_t) ndr_print_eventlog6_EvtRpcGetEventMetadataEnum,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5725,7 +5725,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog6_EvtRpcGetNextEventMetadata),
+ (ndr_push_flags_fn_t) ndr_push_eventlog6_EvtRpcGetNextEventMetadata,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog6_EvtRpcGetNextEventMetadata,
+- (ndr_print_function_t) ndr_print_eventlog6_EvtRpcGetNextEventMetadata,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5734,7 +5734,7 @@ static const struct ndr_interface_call e
+ sizeof(struct eventlog6_EvtRpcGetClassicLogDisplayName),
+ (ndr_push_flags_fn_t) ndr_push_eventlog6_EvtRpcGetClassicLogDisplayName,
+ (ndr_pull_flags_fn_t) ndr_pull_eventlog6_EvtRpcGetClassicLogDisplayName,
+- (ndr_print_function_t) ndr_print_eventlog6_EvtRpcGetClassicLogDisplayName,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_frsapi.c
++++ b/source3/librpc/gen_ndr/ndr_frsapi.c
+@@ -979,7 +979,7 @@ static const struct ndr_interface_call f
+ sizeof(struct FRSAPI_VERIFY_PROMOTION),
+ (ndr_push_flags_fn_t) ndr_push_FRSAPI_VERIFY_PROMOTION,
+ (ndr_pull_flags_fn_t) ndr_pull_FRSAPI_VERIFY_PROMOTION,
+- (ndr_print_function_t) ndr_print_FRSAPI_VERIFY_PROMOTION,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -988,7 +988,7 @@ static const struct ndr_interface_call f
+ sizeof(struct FRSAPI_PROMOTION_STATUS),
+ (ndr_push_flags_fn_t) ndr_push_FRSAPI_PROMOTION_STATUS,
+ (ndr_pull_flags_fn_t) ndr_pull_FRSAPI_PROMOTION_STATUS,
+- (ndr_print_function_t) ndr_print_FRSAPI_PROMOTION_STATUS,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -997,7 +997,7 @@ static const struct ndr_interface_call f
+ sizeof(struct FRSAPI_START_DEMOTION),
+ (ndr_push_flags_fn_t) ndr_push_FRSAPI_START_DEMOTION,
+ (ndr_pull_flags_fn_t) ndr_pull_FRSAPI_START_DEMOTION,
+- (ndr_print_function_t) ndr_print_FRSAPI_START_DEMOTION,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1006,7 +1006,7 @@ static const struct ndr_interface_call f
+ sizeof(struct FRSAPI_COMMIT_DEMOTION),
+ (ndr_push_flags_fn_t) ndr_push_FRSAPI_COMMIT_DEMOTION,
+ (ndr_pull_flags_fn_t) ndr_pull_FRSAPI_COMMIT_DEMOTION,
+- (ndr_print_function_t) ndr_print_FRSAPI_COMMIT_DEMOTION,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1015,7 +1015,7 @@ static const struct ndr_interface_call f
+ sizeof(struct frsapi_SetDsPollingIntervalW),
+ (ndr_push_flags_fn_t) ndr_push_frsapi_SetDsPollingIntervalW,
+ (ndr_pull_flags_fn_t) ndr_pull_frsapi_SetDsPollingIntervalW,
+- (ndr_print_function_t) ndr_print_frsapi_SetDsPollingIntervalW,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1024,7 +1024,7 @@ static const struct ndr_interface_call f
+ sizeof(struct frsapi_GetDsPollingIntervalW),
+ (ndr_push_flags_fn_t) ndr_push_frsapi_GetDsPollingIntervalW,
+ (ndr_pull_flags_fn_t) ndr_pull_frsapi_GetDsPollingIntervalW,
+- (ndr_print_function_t) ndr_print_frsapi_GetDsPollingIntervalW,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1033,7 +1033,7 @@ static const struct ndr_interface_call f
+ sizeof(struct FRSAPI_VERIFY_PROMOTION_W),
+ (ndr_push_flags_fn_t) ndr_push_FRSAPI_VERIFY_PROMOTION_W,
+ (ndr_pull_flags_fn_t) ndr_pull_FRSAPI_VERIFY_PROMOTION_W,
+- (ndr_print_function_t) ndr_print_FRSAPI_VERIFY_PROMOTION_W,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1042,7 +1042,7 @@ static const struct ndr_interface_call f
+ sizeof(struct frsapi_InfoW),
+ (ndr_push_flags_fn_t) ndr_push_frsapi_InfoW,
+ (ndr_pull_flags_fn_t) ndr_pull_frsapi_InfoW,
+- (ndr_print_function_t) ndr_print_frsapi_InfoW,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1051,7 +1051,7 @@ static const struct ndr_interface_call f
+ sizeof(struct frsapi_IsPathReplicated),
+ (ndr_push_flags_fn_t) ndr_push_frsapi_IsPathReplicated,
+ (ndr_pull_flags_fn_t) ndr_pull_frsapi_IsPathReplicated,
+- (ndr_print_function_t) ndr_print_frsapi_IsPathReplicated,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1060,7 +1060,7 @@ static const struct ndr_interface_call f
+ sizeof(struct frsapi_WriterCommand),
+ (ndr_push_flags_fn_t) ndr_push_frsapi_WriterCommand,
+ (ndr_pull_flags_fn_t) ndr_pull_frsapi_WriterCommand,
+- (ndr_print_function_t) ndr_print_frsapi_WriterCommand,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1069,7 +1069,7 @@ static const struct ndr_interface_call f
+ sizeof(struct frsapi_ForceReplication),
+ (ndr_push_flags_fn_t) ndr_push_frsapi_ForceReplication,
+ (ndr_pull_flags_fn_t) ndr_pull_frsapi_ForceReplication,
+- (ndr_print_function_t) ndr_print_frsapi_ForceReplication,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_frsrpc.c
++++ b/source3/librpc/gen_ndr/ndr_frsrpc.c
+@@ -2781,7 +2781,7 @@ static const struct ndr_interface_call f
+ sizeof(struct frsrpc_FrsSendCommPkt),
+ (ndr_push_flags_fn_t) ndr_push_frsrpc_FrsSendCommPkt,
+ (ndr_pull_flags_fn_t) ndr_pull_frsrpc_FrsSendCommPkt,
+- (ndr_print_function_t) ndr_print_frsrpc_FrsSendCommPkt,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2790,7 +2790,7 @@ static const struct ndr_interface_call f
+ sizeof(struct frsrpc_FrsVerifyPromotionParent),
+ (ndr_push_flags_fn_t) ndr_push_frsrpc_FrsVerifyPromotionParent,
+ (ndr_pull_flags_fn_t) ndr_pull_frsrpc_FrsVerifyPromotionParent,
+- (ndr_print_function_t) ndr_print_frsrpc_FrsVerifyPromotionParent,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2799,7 +2799,7 @@ static const struct ndr_interface_call f
+ sizeof(struct frsrpc_FrsStartPromotionParent),
+ (ndr_push_flags_fn_t) ndr_push_frsrpc_FrsStartPromotionParent,
+ (ndr_pull_flags_fn_t) ndr_pull_frsrpc_FrsStartPromotionParent,
+- (ndr_print_function_t) ndr_print_frsrpc_FrsStartPromotionParent,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2808,7 +2808,7 @@ static const struct ndr_interface_call f
+ sizeof(struct frsrpc_FrsNOP),
+ (ndr_push_flags_fn_t) ndr_push_frsrpc_FrsNOP,
+ (ndr_pull_flags_fn_t) ndr_pull_frsrpc_FrsNOP,
+- (ndr_print_function_t) ndr_print_frsrpc_FrsNOP,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2817,7 +2817,7 @@ static const struct ndr_interface_call f
+ sizeof(struct FRSRPC_BACKUP_COMPLETE),
+ (ndr_push_flags_fn_t) ndr_push_FRSRPC_BACKUP_COMPLETE,
+ (ndr_pull_flags_fn_t) ndr_pull_FRSRPC_BACKUP_COMPLETE,
+- (ndr_print_function_t) ndr_print_FRSRPC_BACKUP_COMPLETE,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2826,7 +2826,7 @@ static const struct ndr_interface_call f
+ sizeof(struct FRSRPC_BACKUP_COMPLETE_5),
+ (ndr_push_flags_fn_t) ndr_push_FRSRPC_BACKUP_COMPLETE_5,
+ (ndr_pull_flags_fn_t) ndr_pull_FRSRPC_BACKUP_COMPLETE_5,
+- (ndr_print_function_t) ndr_print_FRSRPC_BACKUP_COMPLETE_5,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2835,7 +2835,7 @@ static const struct ndr_interface_call f
+ sizeof(struct FRSRPC_BACKUP_COMPLETE_6),
+ (ndr_push_flags_fn_t) ndr_push_FRSRPC_BACKUP_COMPLETE_6,
+ (ndr_pull_flags_fn_t) ndr_pull_FRSRPC_BACKUP_COMPLETE_6,
+- (ndr_print_function_t) ndr_print_FRSRPC_BACKUP_COMPLETE_6,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2844,7 +2844,7 @@ static const struct ndr_interface_call f
+ sizeof(struct FRSRPC_BACKUP_COMPLETE_7),
+ (ndr_push_flags_fn_t) ndr_push_FRSRPC_BACKUP_COMPLETE_7,
+ (ndr_pull_flags_fn_t) ndr_pull_FRSRPC_BACKUP_COMPLETE_7,
+- (ndr_print_function_t) ndr_print_FRSRPC_BACKUP_COMPLETE_7,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2853,7 +2853,7 @@ static const struct ndr_interface_call f
+ sizeof(struct FRSRPC_BACKUP_COMPLETE_8),
+ (ndr_push_flags_fn_t) ndr_push_FRSRPC_BACKUP_COMPLETE_8,
+ (ndr_pull_flags_fn_t) ndr_pull_FRSRPC_BACKUP_COMPLETE_8,
+- (ndr_print_function_t) ndr_print_FRSRPC_BACKUP_COMPLETE_8,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2862,7 +2862,7 @@ static const struct ndr_interface_call f
+ sizeof(struct FRSRPC_BACKUP_COMPLETE_9),
+ (ndr_push_flags_fn_t) ndr_push_FRSRPC_BACKUP_COMPLETE_9,
+ (ndr_pull_flags_fn_t) ndr_pull_FRSRPC_BACKUP_COMPLETE_9,
+- (ndr_print_function_t) ndr_print_FRSRPC_BACKUP_COMPLETE_9,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2871,7 +2871,7 @@ static const struct ndr_interface_call f
+ sizeof(struct FRSRPC_VERIFY_PROMOTION_PARENT_EX),
+ (ndr_push_flags_fn_t) ndr_push_FRSRPC_VERIFY_PROMOTION_PARENT_EX,
+ (ndr_pull_flags_fn_t) ndr_pull_FRSRPC_VERIFY_PROMOTION_PARENT_EX,
+- (ndr_print_function_t) ndr_print_FRSRPC_VERIFY_PROMOTION_PARENT_EX,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_frstrans.c
++++ b/source3/librpc/gen_ndr/ndr_frstrans.c
+@@ -2331,7 +2331,7 @@ static const struct ndr_interface_call f
+ sizeof(struct frstrans_CheckConnectivity),
+ (ndr_push_flags_fn_t) ndr_push_frstrans_CheckConnectivity,
+ (ndr_pull_flags_fn_t) ndr_pull_frstrans_CheckConnectivity,
+- (ndr_print_function_t) ndr_print_frstrans_CheckConnectivity,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2340,7 +2340,7 @@ static const struct ndr_interface_call f
+ sizeof(struct frstrans_EstablishConnection),
+ (ndr_push_flags_fn_t) ndr_push_frstrans_EstablishConnection,
+ (ndr_pull_flags_fn_t) ndr_pull_frstrans_EstablishConnection,
+- (ndr_print_function_t) ndr_print_frstrans_EstablishConnection,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2349,7 +2349,7 @@ static const struct ndr_interface_call f
+ sizeof(struct frstrans_EstablishSession),
+ (ndr_push_flags_fn_t) ndr_push_frstrans_EstablishSession,
+ (ndr_pull_flags_fn_t) ndr_pull_frstrans_EstablishSession,
+- (ndr_print_function_t) ndr_print_frstrans_EstablishSession,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2358,7 +2358,7 @@ static const struct ndr_interface_call f
+ sizeof(struct frstrans_RequestUpdates),
+ (ndr_push_flags_fn_t) ndr_push_frstrans_RequestUpdates,
+ (ndr_pull_flags_fn_t) ndr_pull_frstrans_RequestUpdates,
+- (ndr_print_function_t) ndr_print_frstrans_RequestUpdates,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2367,7 +2367,7 @@ static const struct ndr_interface_call f
+ sizeof(struct frstrans_RequestVersionVector),
+ (ndr_push_flags_fn_t) ndr_push_frstrans_RequestVersionVector,
+ (ndr_pull_flags_fn_t) ndr_pull_frstrans_RequestVersionVector,
+- (ndr_print_function_t) ndr_print_frstrans_RequestVersionVector,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2376,7 +2376,7 @@ static const struct ndr_interface_call f
+ sizeof(struct frstrans_AsyncPoll),
+ (ndr_push_flags_fn_t) ndr_push_frstrans_AsyncPoll,
+ (ndr_pull_flags_fn_t) ndr_pull_frstrans_AsyncPoll,
+- (ndr_print_function_t) ndr_print_frstrans_AsyncPoll,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2385,7 +2385,7 @@ static const struct ndr_interface_call f
+ sizeof(struct FRSTRANS_REQUEST_RECORDS),
+ (ndr_push_flags_fn_t) ndr_push_FRSTRANS_REQUEST_RECORDS,
+ (ndr_pull_flags_fn_t) ndr_pull_FRSTRANS_REQUEST_RECORDS,
+- (ndr_print_function_t) ndr_print_FRSTRANS_REQUEST_RECORDS,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2394,7 +2394,7 @@ static const struct ndr_interface_call f
+ sizeof(struct FRSTRANS_UPDATE_CANCEL),
+ (ndr_push_flags_fn_t) ndr_push_FRSTRANS_UPDATE_CANCEL,
+ (ndr_pull_flags_fn_t) ndr_pull_FRSTRANS_UPDATE_CANCEL,
+- (ndr_print_function_t) ndr_print_FRSTRANS_UPDATE_CANCEL,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2403,7 +2403,7 @@ static const struct ndr_interface_call f
+ sizeof(struct FRSTRANS_RAW_GET_FILE_DATA),
+ (ndr_push_flags_fn_t) ndr_push_FRSTRANS_RAW_GET_FILE_DATA,
+ (ndr_pull_flags_fn_t) ndr_pull_FRSTRANS_RAW_GET_FILE_DATA,
+- (ndr_print_function_t) ndr_print_FRSTRANS_RAW_GET_FILE_DATA,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2412,7 +2412,7 @@ static const struct ndr_interface_call f
+ sizeof(struct FRSTRANS_RDC_GET_SIGNATURES),
+ (ndr_push_flags_fn_t) ndr_push_FRSTRANS_RDC_GET_SIGNATURES,
+ (ndr_pull_flags_fn_t) ndr_pull_FRSTRANS_RDC_GET_SIGNATURES,
+- (ndr_print_function_t) ndr_print_FRSTRANS_RDC_GET_SIGNATURES,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2421,7 +2421,7 @@ static const struct ndr_interface_call f
+ sizeof(struct FRSTRANS_RDC_PUSH_SOURCE_NEEDS),
+ (ndr_push_flags_fn_t) ndr_push_FRSTRANS_RDC_PUSH_SOURCE_NEEDS,
+ (ndr_pull_flags_fn_t) ndr_pull_FRSTRANS_RDC_PUSH_SOURCE_NEEDS,
+- (ndr_print_function_t) ndr_print_FRSTRANS_RDC_PUSH_SOURCE_NEEDS,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2430,7 +2430,7 @@ static const struct ndr_interface_call f
+ sizeof(struct FRSTRANS_RDC_GET_FILE_DATA),
+ (ndr_push_flags_fn_t) ndr_push_FRSTRANS_RDC_GET_FILE_DATA,
+ (ndr_pull_flags_fn_t) ndr_pull_FRSTRANS_RDC_GET_FILE_DATA,
+- (ndr_print_function_t) ndr_print_FRSTRANS_RDC_GET_FILE_DATA,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2439,7 +2439,7 @@ static const struct ndr_interface_call f
+ sizeof(struct FRSTRANS_RDC_CLOSE),
+ (ndr_push_flags_fn_t) ndr_push_FRSTRANS_RDC_CLOSE,
+ (ndr_pull_flags_fn_t) ndr_pull_FRSTRANS_RDC_CLOSE,
+- (ndr_print_function_t) ndr_print_FRSTRANS_RDC_CLOSE,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2448,7 +2448,7 @@ static const struct ndr_interface_call f
+ sizeof(struct frstrans_InitializeFileTransferAsync),
+ (ndr_push_flags_fn_t) ndr_push_frstrans_InitializeFileTransferAsync,
+ (ndr_pull_flags_fn_t) ndr_pull_frstrans_InitializeFileTransferAsync,
+- (ndr_print_function_t) ndr_print_frstrans_InitializeFileTransferAsync,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2457,7 +2457,7 @@ static const struct ndr_interface_call f
+ sizeof(struct FRSTRANS_OPNUM_0E_NOT_USED_ON_THE_WIRE),
+ (ndr_push_flags_fn_t) ndr_push_FRSTRANS_OPNUM_0E_NOT_USED_ON_THE_WIRE,
+ (ndr_pull_flags_fn_t) ndr_pull_FRSTRANS_OPNUM_0E_NOT_USED_ON_THE_WIRE,
+- (ndr_print_function_t) ndr_print_FRSTRANS_OPNUM_0E_NOT_USED_ON_THE_WIRE,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2466,7 +2466,7 @@ static const struct ndr_interface_call f
+ sizeof(struct frstrans_RawGetFileDataAsync),
+ (ndr_push_flags_fn_t) ndr_push_frstrans_RawGetFileDataAsync,
+ (ndr_pull_flags_fn_t) ndr_pull_frstrans_RawGetFileDataAsync,
+- (ndr_print_function_t) ndr_print_frstrans_RawGetFileDataAsync,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 1, frstrans_RawGetFileDataAsync_out_pipes },
+ },
+@@ -2475,7 +2475,7 @@ static const struct ndr_interface_call f
+ sizeof(struct frstrans_RdcGetFileDataAsync),
+ (ndr_push_flags_fn_t) ndr_push_frstrans_RdcGetFileDataAsync,
+ (ndr_pull_flags_fn_t) ndr_pull_frstrans_RdcGetFileDataAsync,
+- (ndr_print_function_t) ndr_print_frstrans_RdcGetFileDataAsync,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 1, frstrans_RdcGetFileDataAsync_out_pipes },
+ },
+--- a/source3/librpc/gen_ndr/ndr_initshutdown.c
++++ b/source3/librpc/gen_ndr/ndr_initshutdown.c
+@@ -277,7 +277,7 @@ static const struct ndr_interface_call i
+ sizeof(struct initshutdown_Init),
+ (ndr_push_flags_fn_t) ndr_push_initshutdown_Init,
+ (ndr_pull_flags_fn_t) ndr_pull_initshutdown_Init,
+- (ndr_print_function_t) ndr_print_initshutdown_Init,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -286,7 +286,7 @@ static const struct ndr_interface_call i
+ sizeof(struct initshutdown_Abort),
+ (ndr_push_flags_fn_t) ndr_push_initshutdown_Abort,
+ (ndr_pull_flags_fn_t) ndr_pull_initshutdown_Abort,
+- (ndr_print_function_t) ndr_print_initshutdown_Abort,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -295,7 +295,7 @@ static const struct ndr_interface_call i
+ sizeof(struct initshutdown_InitEx),
+ (ndr_push_flags_fn_t) ndr_push_initshutdown_InitEx,
+ (ndr_pull_flags_fn_t) ndr_pull_initshutdown_InitEx,
+- (ndr_print_function_t) ndr_print_initshutdown_InitEx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_keysvc.c
++++ b/source3/librpc/gen_ndr/ndr_keysvc.c
+@@ -51,7 +51,7 @@ static const struct ndr_interface_call k
+ sizeof(struct keysvc_Unknown0),
+ (ndr_push_flags_fn_t) ndr_push_keysvc_Unknown0,
+ (ndr_pull_flags_fn_t) ndr_pull_keysvc_Unknown0,
+- (ndr_print_function_t) ndr_print_keysvc_Unknown0,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_krb5pac.c
++++ b/source3/librpc/gen_ndr/ndr_krb5pac.c
+@@ -1002,7 +1002,7 @@ static const struct ndr_interface_call k
+ sizeof(struct decode_pac),
+ (ndr_push_flags_fn_t) ndr_push_decode_pac,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_pac,
+- (ndr_print_function_t) ndr_print_decode_pac,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1011,7 +1011,7 @@ static const struct ndr_interface_call k
+ sizeof(struct decode_pac_raw),
+ (ndr_push_flags_fn_t) ndr_push_decode_pac_raw,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_pac_raw,
+- (ndr_print_function_t) ndr_print_decode_pac_raw,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1020,7 +1020,7 @@ static const struct ndr_interface_call k
+ sizeof(struct decode_login_info),
+ (ndr_push_flags_fn_t) ndr_push_decode_login_info,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_login_info,
+- (ndr_print_function_t) ndr_print_decode_login_info,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1029,7 +1029,7 @@ static const struct ndr_interface_call k
+ sizeof(struct decode_login_info_ctr),
+ (ndr_push_flags_fn_t) ndr_push_decode_login_info_ctr,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_login_info_ctr,
+- (ndr_print_function_t) ndr_print_decode_login_info_ctr,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -1038,7 +1038,7 @@ static const struct ndr_interface_call k
+ sizeof(struct decode_pac_validate),
+ (ndr_push_flags_fn_t) ndr_push_decode_pac_validate,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_pac_validate,
+- (ndr_print_function_t) ndr_print_decode_pac_validate,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_lsa.c
++++ b/source3/librpc/gen_ndr/ndr_lsa.c
+@@ -13565,7 +13565,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_Close),
+ (ndr_push_flags_fn_t) ndr_push_lsa_Close,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_Close,
+- (ndr_print_function_t) ndr_print_lsa_Close,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13574,7 +13574,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_Delete),
+ (ndr_push_flags_fn_t) ndr_push_lsa_Delete,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_Delete,
+- (ndr_print_function_t) ndr_print_lsa_Delete,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13583,7 +13583,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_EnumPrivs),
+ (ndr_push_flags_fn_t) ndr_push_lsa_EnumPrivs,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_EnumPrivs,
+- (ndr_print_function_t) ndr_print_lsa_EnumPrivs,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13592,7 +13592,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_QuerySecurity),
+ (ndr_push_flags_fn_t) ndr_push_lsa_QuerySecurity,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_QuerySecurity,
+- (ndr_print_function_t) ndr_print_lsa_QuerySecurity,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13601,7 +13601,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_SetSecObj),
+ (ndr_push_flags_fn_t) ndr_push_lsa_SetSecObj,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_SetSecObj,
+- (ndr_print_function_t) ndr_print_lsa_SetSecObj,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13610,7 +13610,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_ChangePassword),
+ (ndr_push_flags_fn_t) ndr_push_lsa_ChangePassword,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_ChangePassword,
+- (ndr_print_function_t) ndr_print_lsa_ChangePassword,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13619,7 +13619,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_OpenPolicy),
+ (ndr_push_flags_fn_t) ndr_push_lsa_OpenPolicy,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_OpenPolicy,
+- (ndr_print_function_t) ndr_print_lsa_OpenPolicy,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13628,7 +13628,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_QueryInfoPolicy),
+ (ndr_push_flags_fn_t) ndr_push_lsa_QueryInfoPolicy,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_QueryInfoPolicy,
+- (ndr_print_function_t) ndr_print_lsa_QueryInfoPolicy,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13637,7 +13637,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_SetInfoPolicy),
+ (ndr_push_flags_fn_t) ndr_push_lsa_SetInfoPolicy,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_SetInfoPolicy,
+- (ndr_print_function_t) ndr_print_lsa_SetInfoPolicy,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13646,7 +13646,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_ClearAuditLog),
+ (ndr_push_flags_fn_t) ndr_push_lsa_ClearAuditLog,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_ClearAuditLog,
+- (ndr_print_function_t) ndr_print_lsa_ClearAuditLog,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13655,7 +13655,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_CreateAccount),
+ (ndr_push_flags_fn_t) ndr_push_lsa_CreateAccount,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_CreateAccount,
+- (ndr_print_function_t) ndr_print_lsa_CreateAccount,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13664,7 +13664,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_EnumAccounts),
+ (ndr_push_flags_fn_t) ndr_push_lsa_EnumAccounts,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_EnumAccounts,
+- (ndr_print_function_t) ndr_print_lsa_EnumAccounts,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13673,7 +13673,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_CreateTrustedDomain),
+ (ndr_push_flags_fn_t) ndr_push_lsa_CreateTrustedDomain,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_CreateTrustedDomain,
+- (ndr_print_function_t) ndr_print_lsa_CreateTrustedDomain,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13682,7 +13682,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_EnumTrustDom),
+ (ndr_push_flags_fn_t) ndr_push_lsa_EnumTrustDom,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_EnumTrustDom,
+- (ndr_print_function_t) ndr_print_lsa_EnumTrustDom,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13691,7 +13691,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_LookupNames),
+ (ndr_push_flags_fn_t) ndr_push_lsa_LookupNames,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_LookupNames,
+- (ndr_print_function_t) ndr_print_lsa_LookupNames,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13700,7 +13700,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_LookupSids),
+ (ndr_push_flags_fn_t) ndr_push_lsa_LookupSids,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_LookupSids,
+- (ndr_print_function_t) ndr_print_lsa_LookupSids,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13709,7 +13709,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_CreateSecret),
+ (ndr_push_flags_fn_t) ndr_push_lsa_CreateSecret,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_CreateSecret,
+- (ndr_print_function_t) ndr_print_lsa_CreateSecret,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13718,7 +13718,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_OpenAccount),
+ (ndr_push_flags_fn_t) ndr_push_lsa_OpenAccount,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_OpenAccount,
+- (ndr_print_function_t) ndr_print_lsa_OpenAccount,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13727,7 +13727,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_EnumPrivsAccount),
+ (ndr_push_flags_fn_t) ndr_push_lsa_EnumPrivsAccount,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_EnumPrivsAccount,
+- (ndr_print_function_t) ndr_print_lsa_EnumPrivsAccount,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13736,7 +13736,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_AddPrivilegesToAccount),
+ (ndr_push_flags_fn_t) ndr_push_lsa_AddPrivilegesToAccount,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_AddPrivilegesToAccount,
+- (ndr_print_function_t) ndr_print_lsa_AddPrivilegesToAccount,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13745,7 +13745,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_RemovePrivilegesFromAccount),
+ (ndr_push_flags_fn_t) ndr_push_lsa_RemovePrivilegesFromAccount,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_RemovePrivilegesFromAccount,
+- (ndr_print_function_t) ndr_print_lsa_RemovePrivilegesFromAccount,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13754,7 +13754,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_GetQuotasForAccount),
+ (ndr_push_flags_fn_t) ndr_push_lsa_GetQuotasForAccount,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_GetQuotasForAccount,
+- (ndr_print_function_t) ndr_print_lsa_GetQuotasForAccount,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13763,7 +13763,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_SetQuotasForAccount),
+ (ndr_push_flags_fn_t) ndr_push_lsa_SetQuotasForAccount,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_SetQuotasForAccount,
+- (ndr_print_function_t) ndr_print_lsa_SetQuotasForAccount,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13772,7 +13772,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_GetSystemAccessAccount),
+ (ndr_push_flags_fn_t) ndr_push_lsa_GetSystemAccessAccount,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_GetSystemAccessAccount,
+- (ndr_print_function_t) ndr_print_lsa_GetSystemAccessAccount,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13781,7 +13781,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_SetSystemAccessAccount),
+ (ndr_push_flags_fn_t) ndr_push_lsa_SetSystemAccessAccount,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_SetSystemAccessAccount,
+- (ndr_print_function_t) ndr_print_lsa_SetSystemAccessAccount,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13790,7 +13790,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_OpenTrustedDomain),
+ (ndr_push_flags_fn_t) ndr_push_lsa_OpenTrustedDomain,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_OpenTrustedDomain,
+- (ndr_print_function_t) ndr_print_lsa_OpenTrustedDomain,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13799,7 +13799,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_QueryTrustedDomainInfo),
+ (ndr_push_flags_fn_t) ndr_push_lsa_QueryTrustedDomainInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_QueryTrustedDomainInfo,
+- (ndr_print_function_t) ndr_print_lsa_QueryTrustedDomainInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13808,7 +13808,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_SetInformationTrustedDomain),
+ (ndr_push_flags_fn_t) ndr_push_lsa_SetInformationTrustedDomain,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_SetInformationTrustedDomain,
+- (ndr_print_function_t) ndr_print_lsa_SetInformationTrustedDomain,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13817,7 +13817,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_OpenSecret),
+ (ndr_push_flags_fn_t) ndr_push_lsa_OpenSecret,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_OpenSecret,
+- (ndr_print_function_t) ndr_print_lsa_OpenSecret,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13826,7 +13826,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_SetSecret),
+ (ndr_push_flags_fn_t) ndr_push_lsa_SetSecret,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_SetSecret,
+- (ndr_print_function_t) ndr_print_lsa_SetSecret,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13835,7 +13835,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_QuerySecret),
+ (ndr_push_flags_fn_t) ndr_push_lsa_QuerySecret,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_QuerySecret,
+- (ndr_print_function_t) ndr_print_lsa_QuerySecret,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13844,7 +13844,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_LookupPrivValue),
+ (ndr_push_flags_fn_t) ndr_push_lsa_LookupPrivValue,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_LookupPrivValue,
+- (ndr_print_function_t) ndr_print_lsa_LookupPrivValue,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13853,7 +13853,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_LookupPrivName),
+ (ndr_push_flags_fn_t) ndr_push_lsa_LookupPrivName,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_LookupPrivName,
+- (ndr_print_function_t) ndr_print_lsa_LookupPrivName,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13862,7 +13862,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_LookupPrivDisplayName),
+ (ndr_push_flags_fn_t) ndr_push_lsa_LookupPrivDisplayName,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_LookupPrivDisplayName,
+- (ndr_print_function_t) ndr_print_lsa_LookupPrivDisplayName,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13871,7 +13871,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_DeleteObject),
+ (ndr_push_flags_fn_t) ndr_push_lsa_DeleteObject,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_DeleteObject,
+- (ndr_print_function_t) ndr_print_lsa_DeleteObject,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13880,7 +13880,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_EnumAccountsWithUserRight),
+ (ndr_push_flags_fn_t) ndr_push_lsa_EnumAccountsWithUserRight,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_EnumAccountsWithUserRight,
+- (ndr_print_function_t) ndr_print_lsa_EnumAccountsWithUserRight,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13889,7 +13889,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_EnumAccountRights),
+ (ndr_push_flags_fn_t) ndr_push_lsa_EnumAccountRights,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_EnumAccountRights,
+- (ndr_print_function_t) ndr_print_lsa_EnumAccountRights,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13898,7 +13898,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_AddAccountRights),
+ (ndr_push_flags_fn_t) ndr_push_lsa_AddAccountRights,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_AddAccountRights,
+- (ndr_print_function_t) ndr_print_lsa_AddAccountRights,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13907,7 +13907,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_RemoveAccountRights),
+ (ndr_push_flags_fn_t) ndr_push_lsa_RemoveAccountRights,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_RemoveAccountRights,
+- (ndr_print_function_t) ndr_print_lsa_RemoveAccountRights,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13916,7 +13916,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_QueryTrustedDomainInfoBySid),
+ (ndr_push_flags_fn_t) ndr_push_lsa_QueryTrustedDomainInfoBySid,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_QueryTrustedDomainInfoBySid,
+- (ndr_print_function_t) ndr_print_lsa_QueryTrustedDomainInfoBySid,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13925,7 +13925,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_SetTrustedDomainInfo),
+ (ndr_push_flags_fn_t) ndr_push_lsa_SetTrustedDomainInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_SetTrustedDomainInfo,
+- (ndr_print_function_t) ndr_print_lsa_SetTrustedDomainInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13934,7 +13934,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_DeleteTrustedDomain),
+ (ndr_push_flags_fn_t) ndr_push_lsa_DeleteTrustedDomain,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_DeleteTrustedDomain,
+- (ndr_print_function_t) ndr_print_lsa_DeleteTrustedDomain,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13943,7 +13943,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_StorePrivateData),
+ (ndr_push_flags_fn_t) ndr_push_lsa_StorePrivateData,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_StorePrivateData,
+- (ndr_print_function_t) ndr_print_lsa_StorePrivateData,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13952,7 +13952,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_RetrievePrivateData),
+ (ndr_push_flags_fn_t) ndr_push_lsa_RetrievePrivateData,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_RetrievePrivateData,
+- (ndr_print_function_t) ndr_print_lsa_RetrievePrivateData,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13961,7 +13961,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_OpenPolicy2),
+ (ndr_push_flags_fn_t) ndr_push_lsa_OpenPolicy2,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_OpenPolicy2,
+- (ndr_print_function_t) ndr_print_lsa_OpenPolicy2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13970,7 +13970,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_GetUserName),
+ (ndr_push_flags_fn_t) ndr_push_lsa_GetUserName,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_GetUserName,
+- (ndr_print_function_t) ndr_print_lsa_GetUserName,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13979,7 +13979,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_QueryInfoPolicy2),
+ (ndr_push_flags_fn_t) ndr_push_lsa_QueryInfoPolicy2,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_QueryInfoPolicy2,
+- (ndr_print_function_t) ndr_print_lsa_QueryInfoPolicy2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13988,7 +13988,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_SetInfoPolicy2),
+ (ndr_push_flags_fn_t) ndr_push_lsa_SetInfoPolicy2,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_SetInfoPolicy2,
+- (ndr_print_function_t) ndr_print_lsa_SetInfoPolicy2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13997,7 +13997,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_QueryTrustedDomainInfoByName),
+ (ndr_push_flags_fn_t) ndr_push_lsa_QueryTrustedDomainInfoByName,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_QueryTrustedDomainInfoByName,
+- (ndr_print_function_t) ndr_print_lsa_QueryTrustedDomainInfoByName,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14006,7 +14006,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_SetTrustedDomainInfoByName),
+ (ndr_push_flags_fn_t) ndr_push_lsa_SetTrustedDomainInfoByName,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_SetTrustedDomainInfoByName,
+- (ndr_print_function_t) ndr_print_lsa_SetTrustedDomainInfoByName,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14015,7 +14015,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_EnumTrustedDomainsEx),
+ (ndr_push_flags_fn_t) ndr_push_lsa_EnumTrustedDomainsEx,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_EnumTrustedDomainsEx,
+- (ndr_print_function_t) ndr_print_lsa_EnumTrustedDomainsEx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14024,7 +14024,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_CreateTrustedDomainEx),
+ (ndr_push_flags_fn_t) ndr_push_lsa_CreateTrustedDomainEx,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_CreateTrustedDomainEx,
+- (ndr_print_function_t) ndr_print_lsa_CreateTrustedDomainEx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14033,7 +14033,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_CloseTrustedDomainEx),
+ (ndr_push_flags_fn_t) ndr_push_lsa_CloseTrustedDomainEx,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_CloseTrustedDomainEx,
+- (ndr_print_function_t) ndr_print_lsa_CloseTrustedDomainEx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14042,7 +14042,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_QueryDomainInformationPolicy),
+ (ndr_push_flags_fn_t) ndr_push_lsa_QueryDomainInformationPolicy,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_QueryDomainInformationPolicy,
+- (ndr_print_function_t) ndr_print_lsa_QueryDomainInformationPolicy,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14051,7 +14051,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_SetDomainInformationPolicy),
+ (ndr_push_flags_fn_t) ndr_push_lsa_SetDomainInformationPolicy,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_SetDomainInformationPolicy,
+- (ndr_print_function_t) ndr_print_lsa_SetDomainInformationPolicy,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14060,7 +14060,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_OpenTrustedDomainByName),
+ (ndr_push_flags_fn_t) ndr_push_lsa_OpenTrustedDomainByName,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_OpenTrustedDomainByName,
+- (ndr_print_function_t) ndr_print_lsa_OpenTrustedDomainByName,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14069,7 +14069,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_TestCall),
+ (ndr_push_flags_fn_t) ndr_push_lsa_TestCall,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_TestCall,
+- (ndr_print_function_t) ndr_print_lsa_TestCall,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14078,7 +14078,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_LookupSids2),
+ (ndr_push_flags_fn_t) ndr_push_lsa_LookupSids2,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_LookupSids2,
+- (ndr_print_function_t) ndr_print_lsa_LookupSids2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14087,7 +14087,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_LookupNames2),
+ (ndr_push_flags_fn_t) ndr_push_lsa_LookupNames2,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_LookupNames2,
+- (ndr_print_function_t) ndr_print_lsa_LookupNames2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14096,7 +14096,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_CreateTrustedDomainEx2),
+ (ndr_push_flags_fn_t) ndr_push_lsa_CreateTrustedDomainEx2,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_CreateTrustedDomainEx2,
+- (ndr_print_function_t) ndr_print_lsa_CreateTrustedDomainEx2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14105,7 +14105,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_CREDRWRITE),
+ (ndr_push_flags_fn_t) ndr_push_lsa_CREDRWRITE,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_CREDRWRITE,
+- (ndr_print_function_t) ndr_print_lsa_CREDRWRITE,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14114,7 +14114,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_CREDRREAD),
+ (ndr_push_flags_fn_t) ndr_push_lsa_CREDRREAD,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_CREDRREAD,
+- (ndr_print_function_t) ndr_print_lsa_CREDRREAD,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14123,7 +14123,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_CREDRENUMERATE),
+ (ndr_push_flags_fn_t) ndr_push_lsa_CREDRENUMERATE,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_CREDRENUMERATE,
+- (ndr_print_function_t) ndr_print_lsa_CREDRENUMERATE,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14132,7 +14132,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_CREDRWRITEDOMAINCREDENTIALS),
+ (ndr_push_flags_fn_t) ndr_push_lsa_CREDRWRITEDOMAINCREDENTIALS,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_CREDRWRITEDOMAINCREDENTIALS,
+- (ndr_print_function_t) ndr_print_lsa_CREDRWRITEDOMAINCREDENTIALS,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14141,7 +14141,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_CREDRREADDOMAINCREDENTIALS),
+ (ndr_push_flags_fn_t) ndr_push_lsa_CREDRREADDOMAINCREDENTIALS,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_CREDRREADDOMAINCREDENTIALS,
+- (ndr_print_function_t) ndr_print_lsa_CREDRREADDOMAINCREDENTIALS,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14150,7 +14150,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_CREDRDELETE),
+ (ndr_push_flags_fn_t) ndr_push_lsa_CREDRDELETE,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_CREDRDELETE,
+- (ndr_print_function_t) ndr_print_lsa_CREDRDELETE,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14159,7 +14159,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_CREDRGETTARGETINFO),
+ (ndr_push_flags_fn_t) ndr_push_lsa_CREDRGETTARGETINFO,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_CREDRGETTARGETINFO,
+- (ndr_print_function_t) ndr_print_lsa_CREDRGETTARGETINFO,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14168,7 +14168,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_CREDRPROFILELOADED),
+ (ndr_push_flags_fn_t) ndr_push_lsa_CREDRPROFILELOADED,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_CREDRPROFILELOADED,
+- (ndr_print_function_t) ndr_print_lsa_CREDRPROFILELOADED,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14177,7 +14177,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_LookupNames3),
+ (ndr_push_flags_fn_t) ndr_push_lsa_LookupNames3,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_LookupNames3,
+- (ndr_print_function_t) ndr_print_lsa_LookupNames3,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14186,7 +14186,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_CREDRGETSESSIONTYPES),
+ (ndr_push_flags_fn_t) ndr_push_lsa_CREDRGETSESSIONTYPES,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_CREDRGETSESSIONTYPES,
+- (ndr_print_function_t) ndr_print_lsa_CREDRGETSESSIONTYPES,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14195,7 +14195,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_LSARREGISTERAUDITEVENT),
+ (ndr_push_flags_fn_t) ndr_push_lsa_LSARREGISTERAUDITEVENT,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_LSARREGISTERAUDITEVENT,
+- (ndr_print_function_t) ndr_print_lsa_LSARREGISTERAUDITEVENT,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14204,7 +14204,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_LSARGENAUDITEVENT),
+ (ndr_push_flags_fn_t) ndr_push_lsa_LSARGENAUDITEVENT,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_LSARGENAUDITEVENT,
+- (ndr_print_function_t) ndr_print_lsa_LSARGENAUDITEVENT,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14213,7 +14213,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_LSARUNREGISTERAUDITEVENT),
+ (ndr_push_flags_fn_t) ndr_push_lsa_LSARUNREGISTERAUDITEVENT,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_LSARUNREGISTERAUDITEVENT,
+- (ndr_print_function_t) ndr_print_lsa_LSARUNREGISTERAUDITEVENT,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14222,7 +14222,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_lsaRQueryForestTrustInformation),
+ (ndr_push_flags_fn_t) ndr_push_lsa_lsaRQueryForestTrustInformation,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_lsaRQueryForestTrustInformation,
+- (ndr_print_function_t) ndr_print_lsa_lsaRQueryForestTrustInformation,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14231,7 +14231,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_lsaRSetForestTrustInformation),
+ (ndr_push_flags_fn_t) ndr_push_lsa_lsaRSetForestTrustInformation,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_lsaRSetForestTrustInformation,
+- (ndr_print_function_t) ndr_print_lsa_lsaRSetForestTrustInformation,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14240,7 +14240,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_CREDRRENAME),
+ (ndr_push_flags_fn_t) ndr_push_lsa_CREDRRENAME,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_CREDRRENAME,
+- (ndr_print_function_t) ndr_print_lsa_CREDRRENAME,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14249,7 +14249,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_LookupSids3),
+ (ndr_push_flags_fn_t) ndr_push_lsa_LookupSids3,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_LookupSids3,
+- (ndr_print_function_t) ndr_print_lsa_LookupSids3,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14258,7 +14258,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_LookupNames4),
+ (ndr_push_flags_fn_t) ndr_push_lsa_LookupNames4,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_LookupNames4,
+- (ndr_print_function_t) ndr_print_lsa_LookupNames4,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14267,7 +14267,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_LSAROPENPOLICYSCE),
+ (ndr_push_flags_fn_t) ndr_push_lsa_LSAROPENPOLICYSCE,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_LSAROPENPOLICYSCE,
+- (ndr_print_function_t) ndr_print_lsa_LSAROPENPOLICYSCE,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14276,7 +14276,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_LSARADTREGISTERSECURITYEVENTSOURCE),
+ (ndr_push_flags_fn_t) ndr_push_lsa_LSARADTREGISTERSECURITYEVENTSOURCE,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_LSARADTREGISTERSECURITYEVENTSOURCE,
+- (ndr_print_function_t) ndr_print_lsa_LSARADTREGISTERSECURITYEVENTSOURCE,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14285,7 +14285,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_LSARADTUNREGISTERSECURITYEVENTSOURCE),
+ (ndr_push_flags_fn_t) ndr_push_lsa_LSARADTUNREGISTERSECURITYEVENTSOURCE,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_LSARADTUNREGISTERSECURITYEVENTSOURCE,
+- (ndr_print_function_t) ndr_print_lsa_LSARADTUNREGISTERSECURITYEVENTSOURCE,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -14294,7 +14294,7 @@ static const struct ndr_interface_call l
+ sizeof(struct lsa_LSARADTREPORTSECURITYEVENT),
+ (ndr_push_flags_fn_t) ndr_push_lsa_LSARADTREPORTSECURITYEVENT,
+ (ndr_pull_flags_fn_t) ndr_pull_lsa_LSARADTREPORTSECURITYEVENT,
+- (ndr_print_function_t) ndr_print_lsa_LSARADTREPORTSECURITYEVENT,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_mgmt.c
++++ b/source3/librpc/gen_ndr/ndr_mgmt.c
+@@ -515,7 +515,7 @@ static const struct ndr_interface_call m
+ sizeof(struct mgmt_inq_if_ids),
+ (ndr_push_flags_fn_t) ndr_push_mgmt_inq_if_ids,
+ (ndr_pull_flags_fn_t) ndr_pull_mgmt_inq_if_ids,
+- (ndr_print_function_t) ndr_print_mgmt_inq_if_ids,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -524,7 +524,7 @@ static const struct ndr_interface_call m
+ sizeof(struct mgmt_inq_stats),
+ (ndr_push_flags_fn_t) ndr_push_mgmt_inq_stats,
+ (ndr_pull_flags_fn_t) ndr_pull_mgmt_inq_stats,
+- (ndr_print_function_t) ndr_print_mgmt_inq_stats,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -533,7 +533,7 @@ static const struct ndr_interface_call m
+ sizeof(struct mgmt_is_server_listening),
+ (ndr_push_flags_fn_t) ndr_push_mgmt_is_server_listening,
+ (ndr_pull_flags_fn_t) ndr_pull_mgmt_is_server_listening,
+- (ndr_print_function_t) ndr_print_mgmt_is_server_listening,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -542,7 +542,7 @@ static const struct ndr_interface_call m
+ sizeof(struct mgmt_stop_server_listening),
+ (ndr_push_flags_fn_t) ndr_push_mgmt_stop_server_listening,
+ (ndr_pull_flags_fn_t) ndr_pull_mgmt_stop_server_listening,
+- (ndr_print_function_t) ndr_print_mgmt_stop_server_listening,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -551,7 +551,7 @@ static const struct ndr_interface_call m
+ sizeof(struct mgmt_inq_princ_name),
+ (ndr_push_flags_fn_t) ndr_push_mgmt_inq_princ_name,
+ (ndr_pull_flags_fn_t) ndr_pull_mgmt_inq_princ_name,
+- (ndr_print_function_t) ndr_print_mgmt_inq_princ_name,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_msgsvc.c
++++ b/source3/librpc/gen_ndr/ndr_msgsvc.c
+@@ -165,7 +165,7 @@ static const struct ndr_interface_call m
+ sizeof(struct NetrMessageNameAdd),
+ (ndr_push_flags_fn_t) ndr_push_NetrMessageNameAdd,
+ (ndr_pull_flags_fn_t) ndr_pull_NetrMessageNameAdd,
+- (ndr_print_function_t) ndr_print_NetrMessageNameAdd,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -174,7 +174,7 @@ static const struct ndr_interface_call m
+ sizeof(struct NetrMessageNameEnum),
+ (ndr_push_flags_fn_t) ndr_push_NetrMessageNameEnum,
+ (ndr_pull_flags_fn_t) ndr_pull_NetrMessageNameEnum,
+- (ndr_print_function_t) ndr_print_NetrMessageNameEnum,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -183,7 +183,7 @@ static const struct ndr_interface_call m
+ sizeof(struct NetrMessageNameGetInfo),
+ (ndr_push_flags_fn_t) ndr_push_NetrMessageNameGetInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_NetrMessageNameGetInfo,
+- (ndr_print_function_t) ndr_print_NetrMessageNameGetInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -192,7 +192,7 @@ static const struct ndr_interface_call m
+ sizeof(struct NetrMessageNameDel),
+ (ndr_push_flags_fn_t) ndr_push_NetrMessageNameDel,
+ (ndr_pull_flags_fn_t) ndr_pull_NetrMessageNameDel,
+- (ndr_print_function_t) ndr_print_NetrMessageNameDel,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -276,7 +276,7 @@ static const struct ndr_interface_call m
+ sizeof(struct NetrSendMessage),
+ (ndr_push_flags_fn_t) ndr_push_NetrSendMessage,
+ (ndr_pull_flags_fn_t) ndr_pull_NetrSendMessage,
+- (ndr_print_function_t) ndr_print_NetrSendMessage,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_nbt.c
++++ b/source3/librpc/gen_ndr/ndr_nbt.c
+@@ -3671,7 +3671,7 @@ static const struct ndr_interface_call n
+ sizeof(struct decode_nbt_netlogon_packet),
+ (ndr_push_flags_fn_t) ndr_push_decode_nbt_netlogon_packet,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_nbt_netlogon_packet,
+- (ndr_print_function_t) ndr_print_decode_nbt_netlogon_packet,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_netlogon.c
++++ b/source3/librpc/gen_ndr/ndr_netlogon.c
+@@ -17827,7 +17827,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_LogonUasLogon),
+ (ndr_push_flags_fn_t) ndr_push_netr_LogonUasLogon,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_LogonUasLogon,
+- (ndr_print_function_t) ndr_print_netr_LogonUasLogon,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -17836,7 +17836,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_LogonUasLogoff),
+ (ndr_push_flags_fn_t) ndr_push_netr_LogonUasLogoff,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_LogonUasLogoff,
+- (ndr_print_function_t) ndr_print_netr_LogonUasLogoff,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -17845,7 +17845,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_LogonSamLogon),
+ (ndr_push_flags_fn_t) ndr_push_netr_LogonSamLogon,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_LogonSamLogon,
+- (ndr_print_function_t) ndr_print_netr_LogonSamLogon,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -17854,7 +17854,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_LogonSamLogoff),
+ (ndr_push_flags_fn_t) ndr_push_netr_LogonSamLogoff,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_LogonSamLogoff,
+- (ndr_print_function_t) ndr_print_netr_LogonSamLogoff,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -17863,7 +17863,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_ServerReqChallenge),
+ (ndr_push_flags_fn_t) ndr_push_netr_ServerReqChallenge,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_ServerReqChallenge,
+- (ndr_print_function_t) ndr_print_netr_ServerReqChallenge,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -17872,7 +17872,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_ServerAuthenticate),
+ (ndr_push_flags_fn_t) ndr_push_netr_ServerAuthenticate,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_ServerAuthenticate,
+- (ndr_print_function_t) ndr_print_netr_ServerAuthenticate,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -17881,7 +17881,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_ServerPasswordSet),
+ (ndr_push_flags_fn_t) ndr_push_netr_ServerPasswordSet,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_ServerPasswordSet,
+- (ndr_print_function_t) ndr_print_netr_ServerPasswordSet,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -17890,7 +17890,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_DatabaseDeltas),
+ (ndr_push_flags_fn_t) ndr_push_netr_DatabaseDeltas,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_DatabaseDeltas,
+- (ndr_print_function_t) ndr_print_netr_DatabaseDeltas,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -17899,7 +17899,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_DatabaseSync),
+ (ndr_push_flags_fn_t) ndr_push_netr_DatabaseSync,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_DatabaseSync,
+- (ndr_print_function_t) ndr_print_netr_DatabaseSync,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -17908,7 +17908,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_AccountDeltas),
+ (ndr_push_flags_fn_t) ndr_push_netr_AccountDeltas,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_AccountDeltas,
+- (ndr_print_function_t) ndr_print_netr_AccountDeltas,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -17917,7 +17917,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_AccountSync),
+ (ndr_push_flags_fn_t) ndr_push_netr_AccountSync,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_AccountSync,
+- (ndr_print_function_t) ndr_print_netr_AccountSync,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -17926,7 +17926,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_GetDcName),
+ (ndr_push_flags_fn_t) ndr_push_netr_GetDcName,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_GetDcName,
+- (ndr_print_function_t) ndr_print_netr_GetDcName,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -17935,7 +17935,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_LogonControl),
+ (ndr_push_flags_fn_t) ndr_push_netr_LogonControl,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_LogonControl,
+- (ndr_print_function_t) ndr_print_netr_LogonControl,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -17944,7 +17944,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_GetAnyDCName),
+ (ndr_push_flags_fn_t) ndr_push_netr_GetAnyDCName,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_GetAnyDCName,
+- (ndr_print_function_t) ndr_print_netr_GetAnyDCName,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -17953,7 +17953,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_LogonControl2),
+ (ndr_push_flags_fn_t) ndr_push_netr_LogonControl2,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_LogonControl2,
+- (ndr_print_function_t) ndr_print_netr_LogonControl2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -17962,7 +17962,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_ServerAuthenticate2),
+ (ndr_push_flags_fn_t) ndr_push_netr_ServerAuthenticate2,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_ServerAuthenticate2,
+- (ndr_print_function_t) ndr_print_netr_ServerAuthenticate2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -17971,7 +17971,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_DatabaseSync2),
+ (ndr_push_flags_fn_t) ndr_push_netr_DatabaseSync2,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_DatabaseSync2,
+- (ndr_print_function_t) ndr_print_netr_DatabaseSync2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -17980,7 +17980,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_DatabaseRedo),
+ (ndr_push_flags_fn_t) ndr_push_netr_DatabaseRedo,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_DatabaseRedo,
+- (ndr_print_function_t) ndr_print_netr_DatabaseRedo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -17989,7 +17989,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_LogonControl2Ex),
+ (ndr_push_flags_fn_t) ndr_push_netr_LogonControl2Ex,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_LogonControl2Ex,
+- (ndr_print_function_t) ndr_print_netr_LogonControl2Ex,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -17998,7 +17998,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_NetrEnumerateTrustedDomains),
+ (ndr_push_flags_fn_t) ndr_push_netr_NetrEnumerateTrustedDomains,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_NetrEnumerateTrustedDomains,
+- (ndr_print_function_t) ndr_print_netr_NetrEnumerateTrustedDomains,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -18007,7 +18007,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_DsRGetDCName),
+ (ndr_push_flags_fn_t) ndr_push_netr_DsRGetDCName,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_DsRGetDCName,
+- (ndr_print_function_t) ndr_print_netr_DsRGetDCName,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -18016,7 +18016,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_LogonGetCapabilities),
+ (ndr_push_flags_fn_t) ndr_push_netr_LogonGetCapabilities,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_LogonGetCapabilities,
+- (ndr_print_function_t) ndr_print_netr_LogonGetCapabilities,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -18025,7 +18025,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_NETRLOGONSETSERVICEBITS),
+ (ndr_push_flags_fn_t) ndr_push_netr_NETRLOGONSETSERVICEBITS,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_NETRLOGONSETSERVICEBITS,
+- (ndr_print_function_t) ndr_print_netr_NETRLOGONSETSERVICEBITS,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -18034,7 +18034,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_LogonGetTrustRid),
+ (ndr_push_flags_fn_t) ndr_push_netr_LogonGetTrustRid,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_LogonGetTrustRid,
+- (ndr_print_function_t) ndr_print_netr_LogonGetTrustRid,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -18043,7 +18043,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_NETRLOGONCOMPUTESERVERDIGEST),
+ (ndr_push_flags_fn_t) ndr_push_netr_NETRLOGONCOMPUTESERVERDIGEST,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_NETRLOGONCOMPUTESERVERDIGEST,
+- (ndr_print_function_t) ndr_print_netr_NETRLOGONCOMPUTESERVERDIGEST,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -18052,7 +18052,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_NETRLOGONCOMPUTECLIENTDIGEST),
+ (ndr_push_flags_fn_t) ndr_push_netr_NETRLOGONCOMPUTECLIENTDIGEST,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_NETRLOGONCOMPUTECLIENTDIGEST,
+- (ndr_print_function_t) ndr_print_netr_NETRLOGONCOMPUTECLIENTDIGEST,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -18061,7 +18061,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_ServerAuthenticate3),
+ (ndr_push_flags_fn_t) ndr_push_netr_ServerAuthenticate3,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_ServerAuthenticate3,
+- (ndr_print_function_t) ndr_print_netr_ServerAuthenticate3,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -18070,7 +18070,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_DsRGetDCNameEx),
+ (ndr_push_flags_fn_t) ndr_push_netr_DsRGetDCNameEx,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_DsRGetDCNameEx,
+- (ndr_print_function_t) ndr_print_netr_DsRGetDCNameEx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -18079,7 +18079,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_DsRGetSiteName),
+ (ndr_push_flags_fn_t) ndr_push_netr_DsRGetSiteName,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_DsRGetSiteName,
+- (ndr_print_function_t) ndr_print_netr_DsRGetSiteName,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -18088,7 +18088,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_LogonGetDomainInfo),
+ (ndr_push_flags_fn_t) ndr_push_netr_LogonGetDomainInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_LogonGetDomainInfo,
+- (ndr_print_function_t) ndr_print_netr_LogonGetDomainInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -18097,7 +18097,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_ServerPasswordSet2),
+ (ndr_push_flags_fn_t) ndr_push_netr_ServerPasswordSet2,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_ServerPasswordSet2,
+- (ndr_print_function_t) ndr_print_netr_ServerPasswordSet2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -18106,7 +18106,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_ServerPasswordGet),
+ (ndr_push_flags_fn_t) ndr_push_netr_ServerPasswordGet,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_ServerPasswordGet,
+- (ndr_print_function_t) ndr_print_netr_ServerPasswordGet,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -18115,7 +18115,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_NETRLOGONSENDTOSAM),
+ (ndr_push_flags_fn_t) ndr_push_netr_NETRLOGONSENDTOSAM,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_NETRLOGONSENDTOSAM,
+- (ndr_print_function_t) ndr_print_netr_NETRLOGONSENDTOSAM,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -18124,7 +18124,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_DsRAddressToSitenamesW),
+ (ndr_push_flags_fn_t) ndr_push_netr_DsRAddressToSitenamesW,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_DsRAddressToSitenamesW,
+- (ndr_print_function_t) ndr_print_netr_DsRAddressToSitenamesW,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -18133,7 +18133,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_DsRGetDCNameEx2),
+ (ndr_push_flags_fn_t) ndr_push_netr_DsRGetDCNameEx2,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_DsRGetDCNameEx2,
+- (ndr_print_function_t) ndr_print_netr_DsRGetDCNameEx2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -18142,7 +18142,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_NETRLOGONGETTIMESERVICEPARENTDOMAIN),
+ (ndr_push_flags_fn_t) ndr_push_netr_NETRLOGONGETTIMESERVICEPARENTDOMAIN,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_NETRLOGONGETTIMESERVICEPARENTDOMAIN,
+- (ndr_print_function_t) ndr_print_netr_NETRLOGONGETTIMESERVICEPARENTDOMAIN,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -18151,7 +18151,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_NetrEnumerateTrustedDomainsEx),
+ (ndr_push_flags_fn_t) ndr_push_netr_NetrEnumerateTrustedDomainsEx,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_NetrEnumerateTrustedDomainsEx,
+- (ndr_print_function_t) ndr_print_netr_NetrEnumerateTrustedDomainsEx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -18160,7 +18160,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_DsRAddressToSitenamesExW),
+ (ndr_push_flags_fn_t) ndr_push_netr_DsRAddressToSitenamesExW,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_DsRAddressToSitenamesExW,
+- (ndr_print_function_t) ndr_print_netr_DsRAddressToSitenamesExW,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -18169,7 +18169,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_DsrGetDcSiteCoverageW),
+ (ndr_push_flags_fn_t) ndr_push_netr_DsrGetDcSiteCoverageW,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_DsrGetDcSiteCoverageW,
+- (ndr_print_function_t) ndr_print_netr_DsrGetDcSiteCoverageW,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -18178,7 +18178,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_LogonSamLogonEx),
+ (ndr_push_flags_fn_t) ndr_push_netr_LogonSamLogonEx,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_LogonSamLogonEx,
+- (ndr_print_function_t) ndr_print_netr_LogonSamLogonEx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -18187,7 +18187,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_DsrEnumerateDomainTrusts),
+ (ndr_push_flags_fn_t) ndr_push_netr_DsrEnumerateDomainTrusts,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_DsrEnumerateDomainTrusts,
+- (ndr_print_function_t) ndr_print_netr_DsrEnumerateDomainTrusts,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -18196,7 +18196,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_DsrDeregisterDNSHostRecords),
+ (ndr_push_flags_fn_t) ndr_push_netr_DsrDeregisterDNSHostRecords,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_DsrDeregisterDNSHostRecords,
+- (ndr_print_function_t) ndr_print_netr_DsrDeregisterDNSHostRecords,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -18205,7 +18205,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_ServerTrustPasswordsGet),
+ (ndr_push_flags_fn_t) ndr_push_netr_ServerTrustPasswordsGet,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_ServerTrustPasswordsGet,
+- (ndr_print_function_t) ndr_print_netr_ServerTrustPasswordsGet,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -18214,7 +18214,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_DsRGetForestTrustInformation),
+ (ndr_push_flags_fn_t) ndr_push_netr_DsRGetForestTrustInformation,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_DsRGetForestTrustInformation,
+- (ndr_print_function_t) ndr_print_netr_DsRGetForestTrustInformation,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -18223,7 +18223,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_GetForestTrustInformation),
+ (ndr_push_flags_fn_t) ndr_push_netr_GetForestTrustInformation,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_GetForestTrustInformation,
+- (ndr_print_function_t) ndr_print_netr_GetForestTrustInformation,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -18232,7 +18232,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_LogonSamLogonWithFlags),
+ (ndr_push_flags_fn_t) ndr_push_netr_LogonSamLogonWithFlags,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_LogonSamLogonWithFlags,
+- (ndr_print_function_t) ndr_print_netr_LogonSamLogonWithFlags,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -18241,7 +18241,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_ServerGetTrustInfo),
+ (ndr_push_flags_fn_t) ndr_push_netr_ServerGetTrustInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_ServerGetTrustInfo,
+- (ndr_print_function_t) ndr_print_netr_ServerGetTrustInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -18250,7 +18250,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_Unused47),
+ (ndr_push_flags_fn_t) ndr_push_netr_Unused47,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_Unused47,
+- (ndr_print_function_t) ndr_print_netr_Unused47,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -18259,7 +18259,7 @@ static const struct ndr_interface_call n
+ sizeof(struct netr_DsrUpdateReadOnlyServerDnsRecords),
+ (ndr_push_flags_fn_t) ndr_push_netr_DsrUpdateReadOnlyServerDnsRecords,
+ (ndr_pull_flags_fn_t) ndr_pull_netr_DsrUpdateReadOnlyServerDnsRecords,
+- (ndr_print_function_t) ndr_print_netr_DsrUpdateReadOnlyServerDnsRecords,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_ntlmssp.c
++++ b/source3/librpc/gen_ndr/ndr_ntlmssp.c
+@@ -2408,7 +2408,7 @@ static const struct ndr_interface_call n
+ sizeof(struct decode_NEGOTIATE_MESSAGE),
+ (ndr_push_flags_fn_t) ndr_push_decode_NEGOTIATE_MESSAGE,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_NEGOTIATE_MESSAGE,
+- (ndr_print_function_t) ndr_print_decode_NEGOTIATE_MESSAGE,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2417,7 +2417,7 @@ static const struct ndr_interface_call n
+ sizeof(struct decode_CHALLENGE_MESSAGE),
+ (ndr_push_flags_fn_t) ndr_push_decode_CHALLENGE_MESSAGE,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_CHALLENGE_MESSAGE,
+- (ndr_print_function_t) ndr_print_decode_CHALLENGE_MESSAGE,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2426,7 +2426,7 @@ static const struct ndr_interface_call n
+ sizeof(struct decode_AUTHENTICATE_MESSAGE),
+ (ndr_push_flags_fn_t) ndr_push_decode_AUTHENTICATE_MESSAGE,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_AUTHENTICATE_MESSAGE,
+- (ndr_print_function_t) ndr_print_decode_AUTHENTICATE_MESSAGE,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2435,7 +2435,7 @@ static const struct ndr_interface_call n
+ sizeof(struct decode_NTLMv2_CLIENT_CHALLENGE),
+ (ndr_push_flags_fn_t) ndr_push_decode_NTLMv2_CLIENT_CHALLENGE,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_NTLMv2_CLIENT_CHALLENGE,
+- (ndr_print_function_t) ndr_print_decode_NTLMv2_CLIENT_CHALLENGE,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2444,7 +2444,7 @@ static const struct ndr_interface_call n
+ sizeof(struct decode_NTLMv2_RESPONSE),
+ (ndr_push_flags_fn_t) ndr_push_decode_NTLMv2_RESPONSE,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_NTLMv2_RESPONSE,
+- (ndr_print_function_t) ndr_print_decode_NTLMv2_RESPONSE,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_ntprinting.c
++++ b/source3/librpc/gen_ndr/ndr_ntprinting.c
+@@ -902,7 +902,7 @@ static const struct ndr_interface_call n
+ sizeof(struct decode_ntprinting_form),
+ (ndr_push_flags_fn_t) ndr_push_decode_ntprinting_form,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_ntprinting_form,
+- (ndr_print_function_t) ndr_print_decode_ntprinting_form,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -911,7 +911,7 @@ static const struct ndr_interface_call n
+ sizeof(struct decode_ntprinting_driver),
+ (ndr_push_flags_fn_t) ndr_push_decode_ntprinting_driver,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_ntprinting_driver,
+- (ndr_print_function_t) ndr_print_decode_ntprinting_driver,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -920,7 +920,7 @@ static const struct ndr_interface_call n
+ sizeof(struct decode_ntprinting_printer),
+ (ndr_push_flags_fn_t) ndr_push_decode_ntprinting_printer,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_ntprinting_printer,
+- (ndr_print_function_t) ndr_print_decode_ntprinting_printer,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_ntsvcs.c
++++ b/source3/librpc/gen_ndr/ndr_ntsvcs.c
+@@ -3466,7 +3466,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_Disconnect),
+ (ndr_push_flags_fn_t) ndr_push_PNP_Disconnect,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_Disconnect,
+- (ndr_print_function_t) ndr_print_PNP_Disconnect,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3475,7 +3475,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_Connect),
+ (ndr_push_flags_fn_t) ndr_push_PNP_Connect,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_Connect,
+- (ndr_print_function_t) ndr_print_PNP_Connect,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3484,7 +3484,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_GetVersion),
+ (ndr_push_flags_fn_t) ndr_push_PNP_GetVersion,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_GetVersion,
+- (ndr_print_function_t) ndr_print_PNP_GetVersion,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3493,7 +3493,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_GetGlobalState),
+ (ndr_push_flags_fn_t) ndr_push_PNP_GetGlobalState,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_GetGlobalState,
+- (ndr_print_function_t) ndr_print_PNP_GetGlobalState,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3502,7 +3502,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_InitDetection),
+ (ndr_push_flags_fn_t) ndr_push_PNP_InitDetection,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_InitDetection,
+- (ndr_print_function_t) ndr_print_PNP_InitDetection,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3511,7 +3511,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_ReportLogOn),
+ (ndr_push_flags_fn_t) ndr_push_PNP_ReportLogOn,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_ReportLogOn,
+- (ndr_print_function_t) ndr_print_PNP_ReportLogOn,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3520,7 +3520,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_ValidateDeviceInstance),
+ (ndr_push_flags_fn_t) ndr_push_PNP_ValidateDeviceInstance,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_ValidateDeviceInstance,
+- (ndr_print_function_t) ndr_print_PNP_ValidateDeviceInstance,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3529,7 +3529,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_GetRootDeviceInstance),
+ (ndr_push_flags_fn_t) ndr_push_PNP_GetRootDeviceInstance,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_GetRootDeviceInstance,
+- (ndr_print_function_t) ndr_print_PNP_GetRootDeviceInstance,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3538,7 +3538,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_GetRelatedDeviceInstance),
+ (ndr_push_flags_fn_t) ndr_push_PNP_GetRelatedDeviceInstance,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_GetRelatedDeviceInstance,
+- (ndr_print_function_t) ndr_print_PNP_GetRelatedDeviceInstance,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3547,7 +3547,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_EnumerateSubKeys),
+ (ndr_push_flags_fn_t) ndr_push_PNP_EnumerateSubKeys,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_EnumerateSubKeys,
+- (ndr_print_function_t) ndr_print_PNP_EnumerateSubKeys,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3556,7 +3556,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_GetDeviceList),
+ (ndr_push_flags_fn_t) ndr_push_PNP_GetDeviceList,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_GetDeviceList,
+- (ndr_print_function_t) ndr_print_PNP_GetDeviceList,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3565,7 +3565,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_GetDeviceListSize),
+ (ndr_push_flags_fn_t) ndr_push_PNP_GetDeviceListSize,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_GetDeviceListSize,
+- (ndr_print_function_t) ndr_print_PNP_GetDeviceListSize,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3574,7 +3574,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_GetDepth),
+ (ndr_push_flags_fn_t) ndr_push_PNP_GetDepth,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_GetDepth,
+- (ndr_print_function_t) ndr_print_PNP_GetDepth,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3583,7 +3583,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_GetDeviceRegProp),
+ (ndr_push_flags_fn_t) ndr_push_PNP_GetDeviceRegProp,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_GetDeviceRegProp,
+- (ndr_print_function_t) ndr_print_PNP_GetDeviceRegProp,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3592,7 +3592,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_SetDeviceRegProp),
+ (ndr_push_flags_fn_t) ndr_push_PNP_SetDeviceRegProp,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_SetDeviceRegProp,
+- (ndr_print_function_t) ndr_print_PNP_SetDeviceRegProp,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3601,7 +3601,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_GetClassInstance),
+ (ndr_push_flags_fn_t) ndr_push_PNP_GetClassInstance,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_GetClassInstance,
+- (ndr_print_function_t) ndr_print_PNP_GetClassInstance,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3610,7 +3610,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_CreateKey),
+ (ndr_push_flags_fn_t) ndr_push_PNP_CreateKey,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_CreateKey,
+- (ndr_print_function_t) ndr_print_PNP_CreateKey,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3619,7 +3619,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_DeleteRegistryKey),
+ (ndr_push_flags_fn_t) ndr_push_PNP_DeleteRegistryKey,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_DeleteRegistryKey,
+- (ndr_print_function_t) ndr_print_PNP_DeleteRegistryKey,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3628,7 +3628,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_GetClassCount),
+ (ndr_push_flags_fn_t) ndr_push_PNP_GetClassCount,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_GetClassCount,
+- (ndr_print_function_t) ndr_print_PNP_GetClassCount,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3637,7 +3637,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_GetClassName),
+ (ndr_push_flags_fn_t) ndr_push_PNP_GetClassName,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_GetClassName,
+- (ndr_print_function_t) ndr_print_PNP_GetClassName,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3646,7 +3646,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_DeleteClassKey),
+ (ndr_push_flags_fn_t) ndr_push_PNP_DeleteClassKey,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_DeleteClassKey,
+- (ndr_print_function_t) ndr_print_PNP_DeleteClassKey,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3655,7 +3655,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_GetInterfaceDeviceAlias),
+ (ndr_push_flags_fn_t) ndr_push_PNP_GetInterfaceDeviceAlias,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_GetInterfaceDeviceAlias,
+- (ndr_print_function_t) ndr_print_PNP_GetInterfaceDeviceAlias,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3664,7 +3664,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_GetInterfaceDeviceList),
+ (ndr_push_flags_fn_t) ndr_push_PNP_GetInterfaceDeviceList,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_GetInterfaceDeviceList,
+- (ndr_print_function_t) ndr_print_PNP_GetInterfaceDeviceList,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3673,7 +3673,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_GetInterfaceDeviceListSize),
+ (ndr_push_flags_fn_t) ndr_push_PNP_GetInterfaceDeviceListSize,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_GetInterfaceDeviceListSize,
+- (ndr_print_function_t) ndr_print_PNP_GetInterfaceDeviceListSize,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3682,7 +3682,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_RegisterDeviceClassAssociation),
+ (ndr_push_flags_fn_t) ndr_push_PNP_RegisterDeviceClassAssociation,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_RegisterDeviceClassAssociation,
+- (ndr_print_function_t) ndr_print_PNP_RegisterDeviceClassAssociation,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3691,7 +3691,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_UnregisterDeviceClassAssociation),
+ (ndr_push_flags_fn_t) ndr_push_PNP_UnregisterDeviceClassAssociation,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_UnregisterDeviceClassAssociation,
+- (ndr_print_function_t) ndr_print_PNP_UnregisterDeviceClassAssociation,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3700,7 +3700,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_GetClassRegProp),
+ (ndr_push_flags_fn_t) ndr_push_PNP_GetClassRegProp,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_GetClassRegProp,
+- (ndr_print_function_t) ndr_print_PNP_GetClassRegProp,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3709,7 +3709,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_SetClassRegProp),
+ (ndr_push_flags_fn_t) ndr_push_PNP_SetClassRegProp,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_SetClassRegProp,
+- (ndr_print_function_t) ndr_print_PNP_SetClassRegProp,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3718,7 +3718,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_CreateDevInst),
+ (ndr_push_flags_fn_t) ndr_push_PNP_CreateDevInst,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_CreateDevInst,
+- (ndr_print_function_t) ndr_print_PNP_CreateDevInst,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3727,7 +3727,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_DeviceInstanceAction),
+ (ndr_push_flags_fn_t) ndr_push_PNP_DeviceInstanceAction,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_DeviceInstanceAction,
+- (ndr_print_function_t) ndr_print_PNP_DeviceInstanceAction,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3736,7 +3736,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_GetDeviceStatus),
+ (ndr_push_flags_fn_t) ndr_push_PNP_GetDeviceStatus,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_GetDeviceStatus,
+- (ndr_print_function_t) ndr_print_PNP_GetDeviceStatus,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3745,7 +3745,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_SetDeviceProblem),
+ (ndr_push_flags_fn_t) ndr_push_PNP_SetDeviceProblem,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_SetDeviceProblem,
+- (ndr_print_function_t) ndr_print_PNP_SetDeviceProblem,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3754,7 +3754,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_DisableDevInst),
+ (ndr_push_flags_fn_t) ndr_push_PNP_DisableDevInst,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_DisableDevInst,
+- (ndr_print_function_t) ndr_print_PNP_DisableDevInst,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3763,7 +3763,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_UninstallDevInst),
+ (ndr_push_flags_fn_t) ndr_push_PNP_UninstallDevInst,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_UninstallDevInst,
+- (ndr_print_function_t) ndr_print_PNP_UninstallDevInst,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3772,7 +3772,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_AddID),
+ (ndr_push_flags_fn_t) ndr_push_PNP_AddID,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_AddID,
+- (ndr_print_function_t) ndr_print_PNP_AddID,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3781,7 +3781,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_RegisterDriver),
+ (ndr_push_flags_fn_t) ndr_push_PNP_RegisterDriver,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_RegisterDriver,
+- (ndr_print_function_t) ndr_print_PNP_RegisterDriver,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3790,7 +3790,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_QueryRemove),
+ (ndr_push_flags_fn_t) ndr_push_PNP_QueryRemove,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_QueryRemove,
+- (ndr_print_function_t) ndr_print_PNP_QueryRemove,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3799,7 +3799,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_RequestDeviceEject),
+ (ndr_push_flags_fn_t) ndr_push_PNP_RequestDeviceEject,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_RequestDeviceEject,
+- (ndr_print_function_t) ndr_print_PNP_RequestDeviceEject,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3808,7 +3808,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_IsDockStationPresent),
+ (ndr_push_flags_fn_t) ndr_push_PNP_IsDockStationPresent,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_IsDockStationPresent,
+- (ndr_print_function_t) ndr_print_PNP_IsDockStationPresent,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3817,7 +3817,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_RequestEjectPC),
+ (ndr_push_flags_fn_t) ndr_push_PNP_RequestEjectPC,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_RequestEjectPC,
+- (ndr_print_function_t) ndr_print_PNP_RequestEjectPC,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3826,7 +3826,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_HwProfFlags),
+ (ndr_push_flags_fn_t) ndr_push_PNP_HwProfFlags,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_HwProfFlags,
+- (ndr_print_function_t) ndr_print_PNP_HwProfFlags,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3835,7 +3835,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_GetHwProfInfo),
+ (ndr_push_flags_fn_t) ndr_push_PNP_GetHwProfInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_GetHwProfInfo,
+- (ndr_print_function_t) ndr_print_PNP_GetHwProfInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3844,7 +3844,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_AddEmptyLogConf),
+ (ndr_push_flags_fn_t) ndr_push_PNP_AddEmptyLogConf,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_AddEmptyLogConf,
+- (ndr_print_function_t) ndr_print_PNP_AddEmptyLogConf,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3853,7 +3853,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_FreeLogConf),
+ (ndr_push_flags_fn_t) ndr_push_PNP_FreeLogConf,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_FreeLogConf,
+- (ndr_print_function_t) ndr_print_PNP_FreeLogConf,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3862,7 +3862,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_GetFirstLogConf),
+ (ndr_push_flags_fn_t) ndr_push_PNP_GetFirstLogConf,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_GetFirstLogConf,
+- (ndr_print_function_t) ndr_print_PNP_GetFirstLogConf,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3871,7 +3871,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_GetNextLogConf),
+ (ndr_push_flags_fn_t) ndr_push_PNP_GetNextLogConf,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_GetNextLogConf,
+- (ndr_print_function_t) ndr_print_PNP_GetNextLogConf,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3880,7 +3880,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_GetLogConfPriority),
+ (ndr_push_flags_fn_t) ndr_push_PNP_GetLogConfPriority,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_GetLogConfPriority,
+- (ndr_print_function_t) ndr_print_PNP_GetLogConfPriority,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3889,7 +3889,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_AddResDes),
+ (ndr_push_flags_fn_t) ndr_push_PNP_AddResDes,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_AddResDes,
+- (ndr_print_function_t) ndr_print_PNP_AddResDes,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3898,7 +3898,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_FreeResDes),
+ (ndr_push_flags_fn_t) ndr_push_PNP_FreeResDes,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_FreeResDes,
+- (ndr_print_function_t) ndr_print_PNP_FreeResDes,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3907,7 +3907,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_GetNextResDes),
+ (ndr_push_flags_fn_t) ndr_push_PNP_GetNextResDes,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_GetNextResDes,
+- (ndr_print_function_t) ndr_print_PNP_GetNextResDes,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3916,7 +3916,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_GetResDesData),
+ (ndr_push_flags_fn_t) ndr_push_PNP_GetResDesData,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_GetResDesData,
+- (ndr_print_function_t) ndr_print_PNP_GetResDesData,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3925,7 +3925,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_GetResDesDataSize),
+ (ndr_push_flags_fn_t) ndr_push_PNP_GetResDesDataSize,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_GetResDesDataSize,
+- (ndr_print_function_t) ndr_print_PNP_GetResDesDataSize,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3934,7 +3934,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_ModifyResDes),
+ (ndr_push_flags_fn_t) ndr_push_PNP_ModifyResDes,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_ModifyResDes,
+- (ndr_print_function_t) ndr_print_PNP_ModifyResDes,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3943,7 +3943,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_DetectResourceLimit),
+ (ndr_push_flags_fn_t) ndr_push_PNP_DetectResourceLimit,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_DetectResourceLimit,
+- (ndr_print_function_t) ndr_print_PNP_DetectResourceLimit,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3952,7 +3952,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_QueryResConfList),
+ (ndr_push_flags_fn_t) ndr_push_PNP_QueryResConfList,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_QueryResConfList,
+- (ndr_print_function_t) ndr_print_PNP_QueryResConfList,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3961,7 +3961,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_SetHwProf),
+ (ndr_push_flags_fn_t) ndr_push_PNP_SetHwProf,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_SetHwProf,
+- (ndr_print_function_t) ndr_print_PNP_SetHwProf,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3970,7 +3970,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_QueryArbitratorFreeData),
+ (ndr_push_flags_fn_t) ndr_push_PNP_QueryArbitratorFreeData,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_QueryArbitratorFreeData,
+- (ndr_print_function_t) ndr_print_PNP_QueryArbitratorFreeData,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3979,7 +3979,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_QueryArbitratorFreeSize),
+ (ndr_push_flags_fn_t) ndr_push_PNP_QueryArbitratorFreeSize,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_QueryArbitratorFreeSize,
+- (ndr_print_function_t) ndr_print_PNP_QueryArbitratorFreeSize,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3988,7 +3988,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_RunDetection),
+ (ndr_push_flags_fn_t) ndr_push_PNP_RunDetection,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_RunDetection,
+- (ndr_print_function_t) ndr_print_PNP_RunDetection,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3997,7 +3997,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_RegisterNotification),
+ (ndr_push_flags_fn_t) ndr_push_PNP_RegisterNotification,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_RegisterNotification,
+- (ndr_print_function_t) ndr_print_PNP_RegisterNotification,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -4006,7 +4006,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_UnregisterNotification),
+ (ndr_push_flags_fn_t) ndr_push_PNP_UnregisterNotification,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_UnregisterNotification,
+- (ndr_print_function_t) ndr_print_PNP_UnregisterNotification,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -4015,7 +4015,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_GetCustomDevProp),
+ (ndr_push_flags_fn_t) ndr_push_PNP_GetCustomDevProp,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_GetCustomDevProp,
+- (ndr_print_function_t) ndr_print_PNP_GetCustomDevProp,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -4024,7 +4024,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_GetVersionInternal),
+ (ndr_push_flags_fn_t) ndr_push_PNP_GetVersionInternal,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_GetVersionInternal,
+- (ndr_print_function_t) ndr_print_PNP_GetVersionInternal,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -4033,7 +4033,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_GetBlockedDriverInfo),
+ (ndr_push_flags_fn_t) ndr_push_PNP_GetBlockedDriverInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_GetBlockedDriverInfo,
+- (ndr_print_function_t) ndr_print_PNP_GetBlockedDriverInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -4042,7 +4042,7 @@ static const struct ndr_interface_call n
+ sizeof(struct PNP_GetServerSideDeviceInstallFlags),
+ (ndr_push_flags_fn_t) ndr_push_PNP_GetServerSideDeviceInstallFlags,
+ (ndr_pull_flags_fn_t) ndr_pull_PNP_GetServerSideDeviceInstallFlags,
+- (ndr_print_function_t) ndr_print_PNP_GetServerSideDeviceInstallFlags,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_oxidresolver.c
++++ b/source3/librpc/gen_ndr/ndr_oxidresolver.c
+@@ -761,7 +761,7 @@ static const struct ndr_interface_call I
+ sizeof(struct ResolveOxid),
+ (ndr_push_flags_fn_t) ndr_push_ResolveOxid,
+ (ndr_pull_flags_fn_t) ndr_pull_ResolveOxid,
+- (ndr_print_function_t) ndr_print_ResolveOxid,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -770,7 +770,7 @@ static const struct ndr_interface_call I
+ sizeof(struct SimplePing),
+ (ndr_push_flags_fn_t) ndr_push_SimplePing,
+ (ndr_pull_flags_fn_t) ndr_pull_SimplePing,
+- (ndr_print_function_t) ndr_print_SimplePing,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -779,7 +779,7 @@ static const struct ndr_interface_call I
+ sizeof(struct ComplexPing),
+ (ndr_push_flags_fn_t) ndr_push_ComplexPing,
+ (ndr_pull_flags_fn_t) ndr_pull_ComplexPing,
+- (ndr_print_function_t) ndr_print_ComplexPing,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -788,7 +788,7 @@ static const struct ndr_interface_call I
+ sizeof(struct ServerAlive),
+ (ndr_push_flags_fn_t) ndr_push_ServerAlive,
+ (ndr_pull_flags_fn_t) ndr_pull_ServerAlive,
+- (ndr_print_function_t) ndr_print_ServerAlive,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -797,7 +797,7 @@ static const struct ndr_interface_call I
+ sizeof(struct ResolveOxid2),
+ (ndr_push_flags_fn_t) ndr_push_ResolveOxid2,
+ (ndr_pull_flags_fn_t) ndr_pull_ResolveOxid2,
+- (ndr_print_function_t) ndr_print_ResolveOxid2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -806,7 +806,7 @@ static const struct ndr_interface_call I
+ sizeof(struct ServerAlive2),
+ (ndr_push_flags_fn_t) ndr_push_ServerAlive2,
+ (ndr_pull_flags_fn_t) ndr_pull_ServerAlive2,
+- (ndr_print_function_t) ndr_print_ServerAlive2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_policyagent.c
++++ b/source3/librpc/gen_ndr/ndr_policyagent.c
+@@ -51,7 +51,7 @@ static const struct ndr_interface_call p
+ sizeof(struct policyagent_Dummy),
+ (ndr_push_flags_fn_t) ndr_push_policyagent_Dummy,
+ (ndr_pull_flags_fn_t) ndr_pull_policyagent_Dummy,
+- (ndr_print_function_t) ndr_print_policyagent_Dummy,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_preg.c
++++ b/source3/librpc/gen_ndr/ndr_preg.c
+@@ -204,7 +204,7 @@ static const struct ndr_interface_call p
+ sizeof(struct decode_preg_file),
+ (ndr_push_flags_fn_t) ndr_push_decode_preg_file,
+ (ndr_pull_flags_fn_t) ndr_pull_decode_preg_file,
+- (ndr_print_function_t) ndr_print_decode_preg_file,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_remact.c
++++ b/source3/librpc/gen_ndr/ndr_remact.c
+@@ -373,7 +373,7 @@ static const struct ndr_interface_call I
+ sizeof(struct RemoteActivation),
+ (ndr_push_flags_fn_t) ndr_push_RemoteActivation,
+ (ndr_pull_flags_fn_t) ndr_pull_RemoteActivation,
+- (ndr_print_function_t) ndr_print_RemoteActivation,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_rot.c
++++ b/source3/librpc/gen_ndr/ndr_rot.c
+@@ -489,7 +489,7 @@ static const struct ndr_interface_call r
+ sizeof(struct rot_add),
+ (ndr_push_flags_fn_t) ndr_push_rot_add,
+ (ndr_pull_flags_fn_t) ndr_pull_rot_add,
+- (ndr_print_function_t) ndr_print_rot_add,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -498,7 +498,7 @@ static const struct ndr_interface_call r
+ sizeof(struct rot_remove),
+ (ndr_push_flags_fn_t) ndr_push_rot_remove,
+ (ndr_pull_flags_fn_t) ndr_pull_rot_remove,
+- (ndr_print_function_t) ndr_print_rot_remove,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -507,7 +507,7 @@ static const struct ndr_interface_call r
+ sizeof(struct rot_is_listed),
+ (ndr_push_flags_fn_t) ndr_push_rot_is_listed,
+ (ndr_pull_flags_fn_t) ndr_pull_rot_is_listed,
+- (ndr_print_function_t) ndr_print_rot_is_listed,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -516,7 +516,7 @@ static const struct ndr_interface_call r
+ sizeof(struct rot_get_interface_pointer),
+ (ndr_push_flags_fn_t) ndr_push_rot_get_interface_pointer,
+ (ndr_pull_flags_fn_t) ndr_pull_rot_get_interface_pointer,
+- (ndr_print_function_t) ndr_print_rot_get_interface_pointer,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -525,7 +525,7 @@ static const struct ndr_interface_call r
+ sizeof(struct rot_set_modification_time),
+ (ndr_push_flags_fn_t) ndr_push_rot_set_modification_time,
+ (ndr_pull_flags_fn_t) ndr_pull_rot_set_modification_time,
+- (ndr_print_function_t) ndr_print_rot_set_modification_time,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -534,7 +534,7 @@ static const struct ndr_interface_call r
+ sizeof(struct rot_get_modification_time),
+ (ndr_push_flags_fn_t) ndr_push_rot_get_modification_time,
+ (ndr_pull_flags_fn_t) ndr_pull_rot_get_modification_time,
+- (ndr_print_function_t) ndr_print_rot_get_modification_time,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -543,7 +543,7 @@ static const struct ndr_interface_call r
+ sizeof(struct rot_enum),
+ (ndr_push_flags_fn_t) ndr_push_rot_enum,
+ (ndr_pull_flags_fn_t) ndr_pull_rot_enum,
+- (ndr_print_function_t) ndr_print_rot_enum,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_samr.c
++++ b/source3/librpc/gen_ndr/ndr_samr.c
+@@ -12674,7 +12674,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_Connect),
+ (ndr_push_flags_fn_t) ndr_push_samr_Connect,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_Connect,
+- (ndr_print_function_t) ndr_print_samr_Connect,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12683,7 +12683,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_Close),
+ (ndr_push_flags_fn_t) ndr_push_samr_Close,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_Close,
+- (ndr_print_function_t) ndr_print_samr_Close,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12692,7 +12692,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_SetSecurity),
+ (ndr_push_flags_fn_t) ndr_push_samr_SetSecurity,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_SetSecurity,
+- (ndr_print_function_t) ndr_print_samr_SetSecurity,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12701,7 +12701,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_QuerySecurity),
+ (ndr_push_flags_fn_t) ndr_push_samr_QuerySecurity,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_QuerySecurity,
+- (ndr_print_function_t) ndr_print_samr_QuerySecurity,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12710,7 +12710,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_Shutdown),
+ (ndr_push_flags_fn_t) ndr_push_samr_Shutdown,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_Shutdown,
+- (ndr_print_function_t) ndr_print_samr_Shutdown,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12719,7 +12719,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_LookupDomain),
+ (ndr_push_flags_fn_t) ndr_push_samr_LookupDomain,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_LookupDomain,
+- (ndr_print_function_t) ndr_print_samr_LookupDomain,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12728,7 +12728,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_EnumDomains),
+ (ndr_push_flags_fn_t) ndr_push_samr_EnumDomains,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_EnumDomains,
+- (ndr_print_function_t) ndr_print_samr_EnumDomains,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12737,7 +12737,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_OpenDomain),
+ (ndr_push_flags_fn_t) ndr_push_samr_OpenDomain,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_OpenDomain,
+- (ndr_print_function_t) ndr_print_samr_OpenDomain,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12746,7 +12746,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_QueryDomainInfo),
+ (ndr_push_flags_fn_t) ndr_push_samr_QueryDomainInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_QueryDomainInfo,
+- (ndr_print_function_t) ndr_print_samr_QueryDomainInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12755,7 +12755,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_SetDomainInfo),
+ (ndr_push_flags_fn_t) ndr_push_samr_SetDomainInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_SetDomainInfo,
+- (ndr_print_function_t) ndr_print_samr_SetDomainInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12764,7 +12764,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_CreateDomainGroup),
+ (ndr_push_flags_fn_t) ndr_push_samr_CreateDomainGroup,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_CreateDomainGroup,
+- (ndr_print_function_t) ndr_print_samr_CreateDomainGroup,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12773,7 +12773,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_EnumDomainGroups),
+ (ndr_push_flags_fn_t) ndr_push_samr_EnumDomainGroups,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_EnumDomainGroups,
+- (ndr_print_function_t) ndr_print_samr_EnumDomainGroups,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12782,7 +12782,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_CreateUser),
+ (ndr_push_flags_fn_t) ndr_push_samr_CreateUser,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_CreateUser,
+- (ndr_print_function_t) ndr_print_samr_CreateUser,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12791,7 +12791,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_EnumDomainUsers),
+ (ndr_push_flags_fn_t) ndr_push_samr_EnumDomainUsers,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_EnumDomainUsers,
+- (ndr_print_function_t) ndr_print_samr_EnumDomainUsers,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12800,7 +12800,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_CreateDomAlias),
+ (ndr_push_flags_fn_t) ndr_push_samr_CreateDomAlias,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_CreateDomAlias,
+- (ndr_print_function_t) ndr_print_samr_CreateDomAlias,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12809,7 +12809,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_EnumDomainAliases),
+ (ndr_push_flags_fn_t) ndr_push_samr_EnumDomainAliases,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_EnumDomainAliases,
+- (ndr_print_function_t) ndr_print_samr_EnumDomainAliases,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12818,7 +12818,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_GetAliasMembership),
+ (ndr_push_flags_fn_t) ndr_push_samr_GetAliasMembership,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_GetAliasMembership,
+- (ndr_print_function_t) ndr_print_samr_GetAliasMembership,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12827,7 +12827,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_LookupNames),
+ (ndr_push_flags_fn_t) ndr_push_samr_LookupNames,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_LookupNames,
+- (ndr_print_function_t) ndr_print_samr_LookupNames,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12836,7 +12836,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_LookupRids),
+ (ndr_push_flags_fn_t) ndr_push_samr_LookupRids,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_LookupRids,
+- (ndr_print_function_t) ndr_print_samr_LookupRids,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12845,7 +12845,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_OpenGroup),
+ (ndr_push_flags_fn_t) ndr_push_samr_OpenGroup,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_OpenGroup,
+- (ndr_print_function_t) ndr_print_samr_OpenGroup,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12854,7 +12854,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_QueryGroupInfo),
+ (ndr_push_flags_fn_t) ndr_push_samr_QueryGroupInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_QueryGroupInfo,
+- (ndr_print_function_t) ndr_print_samr_QueryGroupInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12863,7 +12863,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_SetGroupInfo),
+ (ndr_push_flags_fn_t) ndr_push_samr_SetGroupInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_SetGroupInfo,
+- (ndr_print_function_t) ndr_print_samr_SetGroupInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12872,7 +12872,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_AddGroupMember),
+ (ndr_push_flags_fn_t) ndr_push_samr_AddGroupMember,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_AddGroupMember,
+- (ndr_print_function_t) ndr_print_samr_AddGroupMember,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12881,7 +12881,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_DeleteDomainGroup),
+ (ndr_push_flags_fn_t) ndr_push_samr_DeleteDomainGroup,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_DeleteDomainGroup,
+- (ndr_print_function_t) ndr_print_samr_DeleteDomainGroup,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12890,7 +12890,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_DeleteGroupMember),
+ (ndr_push_flags_fn_t) ndr_push_samr_DeleteGroupMember,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_DeleteGroupMember,
+- (ndr_print_function_t) ndr_print_samr_DeleteGroupMember,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12899,7 +12899,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_QueryGroupMember),
+ (ndr_push_flags_fn_t) ndr_push_samr_QueryGroupMember,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_QueryGroupMember,
+- (ndr_print_function_t) ndr_print_samr_QueryGroupMember,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12908,7 +12908,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_SetMemberAttributesOfGroup),
+ (ndr_push_flags_fn_t) ndr_push_samr_SetMemberAttributesOfGroup,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_SetMemberAttributesOfGroup,
+- (ndr_print_function_t) ndr_print_samr_SetMemberAttributesOfGroup,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12917,7 +12917,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_OpenAlias),
+ (ndr_push_flags_fn_t) ndr_push_samr_OpenAlias,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_OpenAlias,
+- (ndr_print_function_t) ndr_print_samr_OpenAlias,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12926,7 +12926,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_QueryAliasInfo),
+ (ndr_push_flags_fn_t) ndr_push_samr_QueryAliasInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_QueryAliasInfo,
+- (ndr_print_function_t) ndr_print_samr_QueryAliasInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12935,7 +12935,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_SetAliasInfo),
+ (ndr_push_flags_fn_t) ndr_push_samr_SetAliasInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_SetAliasInfo,
+- (ndr_print_function_t) ndr_print_samr_SetAliasInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12944,7 +12944,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_DeleteDomAlias),
+ (ndr_push_flags_fn_t) ndr_push_samr_DeleteDomAlias,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_DeleteDomAlias,
+- (ndr_print_function_t) ndr_print_samr_DeleteDomAlias,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12953,7 +12953,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_AddAliasMember),
+ (ndr_push_flags_fn_t) ndr_push_samr_AddAliasMember,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_AddAliasMember,
+- (ndr_print_function_t) ndr_print_samr_AddAliasMember,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12962,7 +12962,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_DeleteAliasMember),
+ (ndr_push_flags_fn_t) ndr_push_samr_DeleteAliasMember,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_DeleteAliasMember,
+- (ndr_print_function_t) ndr_print_samr_DeleteAliasMember,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12971,7 +12971,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_GetMembersInAlias),
+ (ndr_push_flags_fn_t) ndr_push_samr_GetMembersInAlias,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_GetMembersInAlias,
+- (ndr_print_function_t) ndr_print_samr_GetMembersInAlias,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12980,7 +12980,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_OpenUser),
+ (ndr_push_flags_fn_t) ndr_push_samr_OpenUser,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_OpenUser,
+- (ndr_print_function_t) ndr_print_samr_OpenUser,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12989,7 +12989,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_DeleteUser),
+ (ndr_push_flags_fn_t) ndr_push_samr_DeleteUser,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_DeleteUser,
+- (ndr_print_function_t) ndr_print_samr_DeleteUser,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -12998,7 +12998,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_QueryUserInfo),
+ (ndr_push_flags_fn_t) ndr_push_samr_QueryUserInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_QueryUserInfo,
+- (ndr_print_function_t) ndr_print_samr_QueryUserInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13007,7 +13007,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_SetUserInfo),
+ (ndr_push_flags_fn_t) ndr_push_samr_SetUserInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_SetUserInfo,
+- (ndr_print_function_t) ndr_print_samr_SetUserInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13016,7 +13016,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_ChangePasswordUser),
+ (ndr_push_flags_fn_t) ndr_push_samr_ChangePasswordUser,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_ChangePasswordUser,
+- (ndr_print_function_t) ndr_print_samr_ChangePasswordUser,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13025,7 +13025,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_GetGroupsForUser),
+ (ndr_push_flags_fn_t) ndr_push_samr_GetGroupsForUser,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_GetGroupsForUser,
+- (ndr_print_function_t) ndr_print_samr_GetGroupsForUser,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13034,7 +13034,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_QueryDisplayInfo),
+ (ndr_push_flags_fn_t) ndr_push_samr_QueryDisplayInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_QueryDisplayInfo,
+- (ndr_print_function_t) ndr_print_samr_QueryDisplayInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13043,7 +13043,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_GetDisplayEnumerationIndex),
+ (ndr_push_flags_fn_t) ndr_push_samr_GetDisplayEnumerationIndex,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_GetDisplayEnumerationIndex,
+- (ndr_print_function_t) ndr_print_samr_GetDisplayEnumerationIndex,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13052,7 +13052,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_TestPrivateFunctionsDomain),
+ (ndr_push_flags_fn_t) ndr_push_samr_TestPrivateFunctionsDomain,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_TestPrivateFunctionsDomain,
+- (ndr_print_function_t) ndr_print_samr_TestPrivateFunctionsDomain,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13061,7 +13061,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_TestPrivateFunctionsUser),
+ (ndr_push_flags_fn_t) ndr_push_samr_TestPrivateFunctionsUser,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_TestPrivateFunctionsUser,
+- (ndr_print_function_t) ndr_print_samr_TestPrivateFunctionsUser,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13070,7 +13070,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_GetUserPwInfo),
+ (ndr_push_flags_fn_t) ndr_push_samr_GetUserPwInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_GetUserPwInfo,
+- (ndr_print_function_t) ndr_print_samr_GetUserPwInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13079,7 +13079,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_RemoveMemberFromForeignDomain),
+ (ndr_push_flags_fn_t) ndr_push_samr_RemoveMemberFromForeignDomain,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_RemoveMemberFromForeignDomain,
+- (ndr_print_function_t) ndr_print_samr_RemoveMemberFromForeignDomain,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13088,7 +13088,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_QueryDomainInfo2),
+ (ndr_push_flags_fn_t) ndr_push_samr_QueryDomainInfo2,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_QueryDomainInfo2,
+- (ndr_print_function_t) ndr_print_samr_QueryDomainInfo2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13097,7 +13097,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_QueryUserInfo2),
+ (ndr_push_flags_fn_t) ndr_push_samr_QueryUserInfo2,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_QueryUserInfo2,
+- (ndr_print_function_t) ndr_print_samr_QueryUserInfo2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13106,7 +13106,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_QueryDisplayInfo2),
+ (ndr_push_flags_fn_t) ndr_push_samr_QueryDisplayInfo2,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_QueryDisplayInfo2,
+- (ndr_print_function_t) ndr_print_samr_QueryDisplayInfo2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13115,7 +13115,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_GetDisplayEnumerationIndex2),
+ (ndr_push_flags_fn_t) ndr_push_samr_GetDisplayEnumerationIndex2,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_GetDisplayEnumerationIndex2,
+- (ndr_print_function_t) ndr_print_samr_GetDisplayEnumerationIndex2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13124,7 +13124,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_CreateUser2),
+ (ndr_push_flags_fn_t) ndr_push_samr_CreateUser2,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_CreateUser2,
+- (ndr_print_function_t) ndr_print_samr_CreateUser2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13133,7 +13133,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_QueryDisplayInfo3),
+ (ndr_push_flags_fn_t) ndr_push_samr_QueryDisplayInfo3,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_QueryDisplayInfo3,
+- (ndr_print_function_t) ndr_print_samr_QueryDisplayInfo3,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13142,7 +13142,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_AddMultipleMembersToAlias),
+ (ndr_push_flags_fn_t) ndr_push_samr_AddMultipleMembersToAlias,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_AddMultipleMembersToAlias,
+- (ndr_print_function_t) ndr_print_samr_AddMultipleMembersToAlias,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13151,7 +13151,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_RemoveMultipleMembersFromAlias),
+ (ndr_push_flags_fn_t) ndr_push_samr_RemoveMultipleMembersFromAlias,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_RemoveMultipleMembersFromAlias,
+- (ndr_print_function_t) ndr_print_samr_RemoveMultipleMembersFromAlias,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13160,7 +13160,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_OemChangePasswordUser2),
+ (ndr_push_flags_fn_t) ndr_push_samr_OemChangePasswordUser2,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_OemChangePasswordUser2,
+- (ndr_print_function_t) ndr_print_samr_OemChangePasswordUser2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13169,7 +13169,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_ChangePasswordUser2),
+ (ndr_push_flags_fn_t) ndr_push_samr_ChangePasswordUser2,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_ChangePasswordUser2,
+- (ndr_print_function_t) ndr_print_samr_ChangePasswordUser2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13178,7 +13178,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_GetDomPwInfo),
+ (ndr_push_flags_fn_t) ndr_push_samr_GetDomPwInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_GetDomPwInfo,
+- (ndr_print_function_t) ndr_print_samr_GetDomPwInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13187,7 +13187,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_Connect2),
+ (ndr_push_flags_fn_t) ndr_push_samr_Connect2,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_Connect2,
+- (ndr_print_function_t) ndr_print_samr_Connect2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13196,7 +13196,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_SetUserInfo2),
+ (ndr_push_flags_fn_t) ndr_push_samr_SetUserInfo2,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_SetUserInfo2,
+- (ndr_print_function_t) ndr_print_samr_SetUserInfo2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13205,7 +13205,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_SetBootKeyInformation),
+ (ndr_push_flags_fn_t) ndr_push_samr_SetBootKeyInformation,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_SetBootKeyInformation,
+- (ndr_print_function_t) ndr_print_samr_SetBootKeyInformation,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13214,7 +13214,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_GetBootKeyInformation),
+ (ndr_push_flags_fn_t) ndr_push_samr_GetBootKeyInformation,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_GetBootKeyInformation,
+- (ndr_print_function_t) ndr_print_samr_GetBootKeyInformation,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13223,7 +13223,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_Connect3),
+ (ndr_push_flags_fn_t) ndr_push_samr_Connect3,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_Connect3,
+- (ndr_print_function_t) ndr_print_samr_Connect3,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13232,7 +13232,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_Connect4),
+ (ndr_push_flags_fn_t) ndr_push_samr_Connect4,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_Connect4,
+- (ndr_print_function_t) ndr_print_samr_Connect4,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13241,7 +13241,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_ChangePasswordUser3),
+ (ndr_push_flags_fn_t) ndr_push_samr_ChangePasswordUser3,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_ChangePasswordUser3,
+- (ndr_print_function_t) ndr_print_samr_ChangePasswordUser3,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13250,7 +13250,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_Connect5),
+ (ndr_push_flags_fn_t) ndr_push_samr_Connect5,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_Connect5,
+- (ndr_print_function_t) ndr_print_samr_Connect5,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13259,7 +13259,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_RidToSid),
+ (ndr_push_flags_fn_t) ndr_push_samr_RidToSid,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_RidToSid,
+- (ndr_print_function_t) ndr_print_samr_RidToSid,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13268,7 +13268,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_SetDsrmPassword),
+ (ndr_push_flags_fn_t) ndr_push_samr_SetDsrmPassword,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_SetDsrmPassword,
+- (ndr_print_function_t) ndr_print_samr_SetDsrmPassword,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -13277,7 +13277,7 @@ static const struct ndr_interface_call s
+ sizeof(struct samr_ValidatePassword),
+ (ndr_push_flags_fn_t) ndr_push_samr_ValidatePassword,
+ (ndr_pull_flags_fn_t) ndr_pull_samr_ValidatePassword,
+- (ndr_print_function_t) ndr_print_samr_ValidatePassword,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_scerpc.c
++++ b/source3/librpc/gen_ndr/ndr_scerpc.c
+@@ -51,7 +51,7 @@ static const struct ndr_interface_call s
+ sizeof(struct scerpc_Unknown0),
+ (ndr_push_flags_fn_t) ndr_push_scerpc_Unknown0,
+ (ndr_pull_flags_fn_t) ndr_pull_scerpc_Unknown0,
+- (ndr_print_function_t) ndr_print_scerpc_Unknown0,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_spoolss.c
++++ b/source3/librpc/gen_ndr/ndr_spoolss.c
+@@ -32660,7 +32660,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_EnumPrinters),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_EnumPrinters,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_EnumPrinters,
+- (ndr_print_function_t) ndr_print_spoolss_EnumPrinters,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32669,7 +32669,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_OpenPrinter),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_OpenPrinter,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_OpenPrinter,
+- (ndr_print_function_t) ndr_print_spoolss_OpenPrinter,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32678,7 +32678,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_SetJob),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_SetJob,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_SetJob,
+- (ndr_print_function_t) ndr_print_spoolss_SetJob,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32687,7 +32687,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_GetJob),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_GetJob,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_GetJob,
+- (ndr_print_function_t) ndr_print_spoolss_GetJob,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32696,7 +32696,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_EnumJobs),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_EnumJobs,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_EnumJobs,
+- (ndr_print_function_t) ndr_print_spoolss_EnumJobs,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32705,7 +32705,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_AddPrinter),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_AddPrinter,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_AddPrinter,
+- (ndr_print_function_t) ndr_print_spoolss_AddPrinter,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32714,7 +32714,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_DeletePrinter),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_DeletePrinter,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_DeletePrinter,
+- (ndr_print_function_t) ndr_print_spoolss_DeletePrinter,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32723,7 +32723,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_SetPrinter),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_SetPrinter,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_SetPrinter,
+- (ndr_print_function_t) ndr_print_spoolss_SetPrinter,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32732,7 +32732,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_GetPrinter),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_GetPrinter,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_GetPrinter,
+- (ndr_print_function_t) ndr_print_spoolss_GetPrinter,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32741,7 +32741,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_AddPrinterDriver),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_AddPrinterDriver,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_AddPrinterDriver,
+- (ndr_print_function_t) ndr_print_spoolss_AddPrinterDriver,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32750,7 +32750,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_EnumPrinterDrivers),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_EnumPrinterDrivers,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_EnumPrinterDrivers,
+- (ndr_print_function_t) ndr_print_spoolss_EnumPrinterDrivers,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32759,7 +32759,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_GetPrinterDriver),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_GetPrinterDriver,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_GetPrinterDriver,
+- (ndr_print_function_t) ndr_print_spoolss_GetPrinterDriver,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32768,7 +32768,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_GetPrinterDriverDirectory),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_GetPrinterDriverDirectory,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_GetPrinterDriverDirectory,
+- (ndr_print_function_t) ndr_print_spoolss_GetPrinterDriverDirectory,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32777,7 +32777,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_DeletePrinterDriver),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_DeletePrinterDriver,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_DeletePrinterDriver,
+- (ndr_print_function_t) ndr_print_spoolss_DeletePrinterDriver,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32786,7 +32786,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_AddPrintProcessor),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_AddPrintProcessor,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_AddPrintProcessor,
+- (ndr_print_function_t) ndr_print_spoolss_AddPrintProcessor,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32795,7 +32795,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_EnumPrintProcessors),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_EnumPrintProcessors,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_EnumPrintProcessors,
+- (ndr_print_function_t) ndr_print_spoolss_EnumPrintProcessors,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32804,7 +32804,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_GetPrintProcessorDirectory),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_GetPrintProcessorDirectory,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_GetPrintProcessorDirectory,
+- (ndr_print_function_t) ndr_print_spoolss_GetPrintProcessorDirectory,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32813,7 +32813,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_StartDocPrinter),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_StartDocPrinter,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_StartDocPrinter,
+- (ndr_print_function_t) ndr_print_spoolss_StartDocPrinter,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32822,7 +32822,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_StartPagePrinter),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_StartPagePrinter,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_StartPagePrinter,
+- (ndr_print_function_t) ndr_print_spoolss_StartPagePrinter,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32831,7 +32831,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_WritePrinter),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_WritePrinter,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_WritePrinter,
+- (ndr_print_function_t) ndr_print_spoolss_WritePrinter,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32840,7 +32840,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_EndPagePrinter),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_EndPagePrinter,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_EndPagePrinter,
+- (ndr_print_function_t) ndr_print_spoolss_EndPagePrinter,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32849,7 +32849,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_AbortPrinter),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_AbortPrinter,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_AbortPrinter,
+- (ndr_print_function_t) ndr_print_spoolss_AbortPrinter,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32858,7 +32858,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_ReadPrinter),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_ReadPrinter,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_ReadPrinter,
+- (ndr_print_function_t) ndr_print_spoolss_ReadPrinter,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32867,7 +32867,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_EndDocPrinter),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_EndDocPrinter,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_EndDocPrinter,
+- (ndr_print_function_t) ndr_print_spoolss_EndDocPrinter,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32876,7 +32876,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_AddJob),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_AddJob,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_AddJob,
+- (ndr_print_function_t) ndr_print_spoolss_AddJob,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32885,7 +32885,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_ScheduleJob),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_ScheduleJob,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_ScheduleJob,
+- (ndr_print_function_t) ndr_print_spoolss_ScheduleJob,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32894,7 +32894,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_GetPrinterData),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_GetPrinterData,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_GetPrinterData,
+- (ndr_print_function_t) ndr_print_spoolss_GetPrinterData,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32903,7 +32903,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_SetPrinterData),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_SetPrinterData,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_SetPrinterData,
+- (ndr_print_function_t) ndr_print_spoolss_SetPrinterData,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32912,7 +32912,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_WaitForPrinterChange),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_WaitForPrinterChange,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_WaitForPrinterChange,
+- (ndr_print_function_t) ndr_print_spoolss_WaitForPrinterChange,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32921,7 +32921,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_ClosePrinter),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_ClosePrinter,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_ClosePrinter,
+- (ndr_print_function_t) ndr_print_spoolss_ClosePrinter,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32930,7 +32930,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_AddForm),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_AddForm,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_AddForm,
+- (ndr_print_function_t) ndr_print_spoolss_AddForm,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32939,7 +32939,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_DeleteForm),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_DeleteForm,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_DeleteForm,
+- (ndr_print_function_t) ndr_print_spoolss_DeleteForm,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32948,7 +32948,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_GetForm),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_GetForm,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_GetForm,
+- (ndr_print_function_t) ndr_print_spoolss_GetForm,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32957,7 +32957,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_SetForm),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_SetForm,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_SetForm,
+- (ndr_print_function_t) ndr_print_spoolss_SetForm,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32966,7 +32966,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_EnumForms),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_EnumForms,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_EnumForms,
+- (ndr_print_function_t) ndr_print_spoolss_EnumForms,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32975,7 +32975,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_EnumPorts),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_EnumPorts,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_EnumPorts,
+- (ndr_print_function_t) ndr_print_spoolss_EnumPorts,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32984,7 +32984,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_EnumMonitors),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_EnumMonitors,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_EnumMonitors,
+- (ndr_print_function_t) ndr_print_spoolss_EnumMonitors,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -32993,7 +32993,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_AddPort),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_AddPort,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_AddPort,
+- (ndr_print_function_t) ndr_print_spoolss_AddPort,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33002,7 +33002,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_ConfigurePort),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_ConfigurePort,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_ConfigurePort,
+- (ndr_print_function_t) ndr_print_spoolss_ConfigurePort,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33011,7 +33011,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_DeletePort),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_DeletePort,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_DeletePort,
+- (ndr_print_function_t) ndr_print_spoolss_DeletePort,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33020,7 +33020,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_CreatePrinterIC),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_CreatePrinterIC,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_CreatePrinterIC,
+- (ndr_print_function_t) ndr_print_spoolss_CreatePrinterIC,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33029,7 +33029,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_PlayGDIScriptOnPrinterIC),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_PlayGDIScriptOnPrinterIC,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_PlayGDIScriptOnPrinterIC,
+- (ndr_print_function_t) ndr_print_spoolss_PlayGDIScriptOnPrinterIC,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33038,7 +33038,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_DeletePrinterIC),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_DeletePrinterIC,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_DeletePrinterIC,
+- (ndr_print_function_t) ndr_print_spoolss_DeletePrinterIC,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33047,7 +33047,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_AddPrinterConnection),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_AddPrinterConnection,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_AddPrinterConnection,
+- (ndr_print_function_t) ndr_print_spoolss_AddPrinterConnection,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33056,7 +33056,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_DeletePrinterConnection),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_DeletePrinterConnection,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_DeletePrinterConnection,
+- (ndr_print_function_t) ndr_print_spoolss_DeletePrinterConnection,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33065,7 +33065,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_PrinterMessageBox),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_PrinterMessageBox,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_PrinterMessageBox,
+- (ndr_print_function_t) ndr_print_spoolss_PrinterMessageBox,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33074,7 +33074,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_AddMonitor),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_AddMonitor,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_AddMonitor,
+- (ndr_print_function_t) ndr_print_spoolss_AddMonitor,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33083,7 +33083,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_DeleteMonitor),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_DeleteMonitor,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_DeleteMonitor,
+- (ndr_print_function_t) ndr_print_spoolss_DeleteMonitor,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33092,7 +33092,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_DeletePrintProcessor),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_DeletePrintProcessor,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_DeletePrintProcessor,
+- (ndr_print_function_t) ndr_print_spoolss_DeletePrintProcessor,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33101,7 +33101,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_AddPrintProvidor),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_AddPrintProvidor,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_AddPrintProvidor,
+- (ndr_print_function_t) ndr_print_spoolss_AddPrintProvidor,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33110,7 +33110,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_DeletePrintProvidor),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_DeletePrintProvidor,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_DeletePrintProvidor,
+- (ndr_print_function_t) ndr_print_spoolss_DeletePrintProvidor,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33119,7 +33119,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_EnumPrintProcDataTypes),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_EnumPrintProcDataTypes,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_EnumPrintProcDataTypes,
+- (ndr_print_function_t) ndr_print_spoolss_EnumPrintProcDataTypes,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33128,7 +33128,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_ResetPrinter),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_ResetPrinter,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_ResetPrinter,
+- (ndr_print_function_t) ndr_print_spoolss_ResetPrinter,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33137,7 +33137,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_GetPrinterDriver2),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_GetPrinterDriver2,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_GetPrinterDriver2,
+- (ndr_print_function_t) ndr_print_spoolss_GetPrinterDriver2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33146,7 +33146,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_FindFirstPrinterChangeNotification),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_FindFirstPrinterChangeNotification,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_FindFirstPrinterChangeNotification,
+- (ndr_print_function_t) ndr_print_spoolss_FindFirstPrinterChangeNotification,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33155,7 +33155,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_FindNextPrinterChangeNotification),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_FindNextPrinterChangeNotification,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_FindNextPrinterChangeNotification,
+- (ndr_print_function_t) ndr_print_spoolss_FindNextPrinterChangeNotification,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33164,7 +33164,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_FindClosePrinterNotify),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_FindClosePrinterNotify,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_FindClosePrinterNotify,
+- (ndr_print_function_t) ndr_print_spoolss_FindClosePrinterNotify,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33173,7 +33173,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_RouterFindFirstPrinterChangeNotificationOld),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_RouterFindFirstPrinterChangeNotificationOld,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_RouterFindFirstPrinterChangeNotificationOld,
+- (ndr_print_function_t) ndr_print_spoolss_RouterFindFirstPrinterChangeNotificationOld,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33182,7 +33182,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_ReplyOpenPrinter),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_ReplyOpenPrinter,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_ReplyOpenPrinter,
+- (ndr_print_function_t) ndr_print_spoolss_ReplyOpenPrinter,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33191,7 +33191,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_RouterReplyPrinter),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_RouterReplyPrinter,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_RouterReplyPrinter,
+- (ndr_print_function_t) ndr_print_spoolss_RouterReplyPrinter,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33200,7 +33200,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_ReplyClosePrinter),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_ReplyClosePrinter,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_ReplyClosePrinter,
+- (ndr_print_function_t) ndr_print_spoolss_ReplyClosePrinter,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33209,7 +33209,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_AddPortEx),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_AddPortEx,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_AddPortEx,
+- (ndr_print_function_t) ndr_print_spoolss_AddPortEx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33218,7 +33218,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_RouterFindFirstPrinterChangeNotification),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_RouterFindFirstPrinterChangeNotification,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_RouterFindFirstPrinterChangeNotification,
+- (ndr_print_function_t) ndr_print_spoolss_RouterFindFirstPrinterChangeNotification,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33227,7 +33227,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_SpoolerInit),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_SpoolerInit,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_SpoolerInit,
+- (ndr_print_function_t) ndr_print_spoolss_SpoolerInit,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33236,7 +33236,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_ResetPrinterEx),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_ResetPrinterEx,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_ResetPrinterEx,
+- (ndr_print_function_t) ndr_print_spoolss_ResetPrinterEx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33245,7 +33245,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_RemoteFindFirstPrinterChangeNotifyEx),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_RemoteFindFirstPrinterChangeNotifyEx,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_RemoteFindFirstPrinterChangeNotifyEx,
+- (ndr_print_function_t) ndr_print_spoolss_RemoteFindFirstPrinterChangeNotifyEx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33254,7 +33254,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_RouterReplyPrinterEx),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_RouterReplyPrinterEx,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_RouterReplyPrinterEx,
+- (ndr_print_function_t) ndr_print_spoolss_RouterReplyPrinterEx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33263,7 +33263,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_RouterRefreshPrinterChangeNotify),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_RouterRefreshPrinterChangeNotify,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_RouterRefreshPrinterChangeNotify,
+- (ndr_print_function_t) ndr_print_spoolss_RouterRefreshPrinterChangeNotify,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33272,7 +33272,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_44),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_44,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_44,
+- (ndr_print_function_t) ndr_print_spoolss_44,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33281,7 +33281,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_OpenPrinterEx),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_OpenPrinterEx,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_OpenPrinterEx,
+- (ndr_print_function_t) ndr_print_spoolss_OpenPrinterEx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33290,7 +33290,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_AddPrinterEx),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_AddPrinterEx,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_AddPrinterEx,
+- (ndr_print_function_t) ndr_print_spoolss_AddPrinterEx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33299,7 +33299,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_SetPort),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_SetPort,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_SetPort,
+- (ndr_print_function_t) ndr_print_spoolss_SetPort,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33308,7 +33308,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_EnumPrinterData),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_EnumPrinterData,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_EnumPrinterData,
+- (ndr_print_function_t) ndr_print_spoolss_EnumPrinterData,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33317,7 +33317,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_DeletePrinterData),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_DeletePrinterData,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_DeletePrinterData,
+- (ndr_print_function_t) ndr_print_spoolss_DeletePrinterData,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33326,7 +33326,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_4a),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_4a,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_4a,
+- (ndr_print_function_t) ndr_print_spoolss_4a,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33335,7 +33335,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_4b),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_4b,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_4b,
+- (ndr_print_function_t) ndr_print_spoolss_4b,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33344,7 +33344,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_4c),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_4c,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_4c,
+- (ndr_print_function_t) ndr_print_spoolss_4c,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33353,7 +33353,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_SetPrinterDataEx),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_SetPrinterDataEx,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_SetPrinterDataEx,
+- (ndr_print_function_t) ndr_print_spoolss_SetPrinterDataEx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33362,7 +33362,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_GetPrinterDataEx),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_GetPrinterDataEx,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_GetPrinterDataEx,
+- (ndr_print_function_t) ndr_print_spoolss_GetPrinterDataEx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33371,7 +33371,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_EnumPrinterDataEx),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_EnumPrinterDataEx,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_EnumPrinterDataEx,
+- (ndr_print_function_t) ndr_print_spoolss_EnumPrinterDataEx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33380,7 +33380,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_EnumPrinterKey),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_EnumPrinterKey,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_EnumPrinterKey,
+- (ndr_print_function_t) ndr_print_spoolss_EnumPrinterKey,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33389,7 +33389,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_DeletePrinterDataEx),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_DeletePrinterDataEx,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_DeletePrinterDataEx,
+- (ndr_print_function_t) ndr_print_spoolss_DeletePrinterDataEx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33398,7 +33398,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_DeletePrinterKey),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_DeletePrinterKey,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_DeletePrinterKey,
+- (ndr_print_function_t) ndr_print_spoolss_DeletePrinterKey,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33407,7 +33407,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_53),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_53,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_53,
+- (ndr_print_function_t) ndr_print_spoolss_53,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33416,7 +33416,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_DeletePrinterDriverEx),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_DeletePrinterDriverEx,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_DeletePrinterDriverEx,
+- (ndr_print_function_t) ndr_print_spoolss_DeletePrinterDriverEx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33425,7 +33425,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_AddPerMachineConnection),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_AddPerMachineConnection,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_AddPerMachineConnection,
+- (ndr_print_function_t) ndr_print_spoolss_AddPerMachineConnection,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33434,7 +33434,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_DeletePerMachineConnection),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_DeletePerMachineConnection,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_DeletePerMachineConnection,
+- (ndr_print_function_t) ndr_print_spoolss_DeletePerMachineConnection,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33443,7 +33443,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_EnumPerMachineConnections),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_EnumPerMachineConnections,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_EnumPerMachineConnections,
+- (ndr_print_function_t) ndr_print_spoolss_EnumPerMachineConnections,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33452,7 +33452,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_XcvData),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_XcvData,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_XcvData,
+- (ndr_print_function_t) ndr_print_spoolss_XcvData,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33461,7 +33461,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_AddPrinterDriverEx),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_AddPrinterDriverEx,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_AddPrinterDriverEx,
+- (ndr_print_function_t) ndr_print_spoolss_AddPrinterDriverEx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33470,7 +33470,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_5a),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_5a,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_5a,
+- (ndr_print_function_t) ndr_print_spoolss_5a,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33479,7 +33479,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_5b),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_5b,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_5b,
+- (ndr_print_function_t) ndr_print_spoolss_5b,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33488,7 +33488,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_5c),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_5c,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_5c,
+- (ndr_print_function_t) ndr_print_spoolss_5c,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33497,7 +33497,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_5d),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_5d,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_5d,
+- (ndr_print_function_t) ndr_print_spoolss_5d,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33506,7 +33506,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_5e),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_5e,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_5e,
+- (ndr_print_function_t) ndr_print_spoolss_5e,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33515,7 +33515,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_5f),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_5f,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_5f,
+- (ndr_print_function_t) ndr_print_spoolss_5f,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33524,7 +33524,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_60),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_60,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_60,
+- (ndr_print_function_t) ndr_print_spoolss_60,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33533,7 +33533,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_61),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_61,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_61,
+- (ndr_print_function_t) ndr_print_spoolss_61,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33542,7 +33542,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_62),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_62,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_62,
+- (ndr_print_function_t) ndr_print_spoolss_62,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33551,7 +33551,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_63),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_63,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_63,
+- (ndr_print_function_t) ndr_print_spoolss_63,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33560,7 +33560,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_64),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_64,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_64,
+- (ndr_print_function_t) ndr_print_spoolss_64,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33569,7 +33569,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_65),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_65,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_65,
+- (ndr_print_function_t) ndr_print_spoolss_65,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33578,7 +33578,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_GetCorePrinterDrivers),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_GetCorePrinterDrivers,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_GetCorePrinterDrivers,
+- (ndr_print_function_t) ndr_print_spoolss_GetCorePrinterDrivers,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33587,7 +33587,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_67),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_67,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_67,
+- (ndr_print_function_t) ndr_print_spoolss_67,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33596,7 +33596,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_GetPrinterDriverPackagePath),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_GetPrinterDriverPackagePath,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_GetPrinterDriverPackagePath,
+- (ndr_print_function_t) ndr_print_spoolss_GetPrinterDriverPackagePath,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33605,7 +33605,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_69),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_69,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_69,
+- (ndr_print_function_t) ndr_print_spoolss_69,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33614,7 +33614,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_6a),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_6a,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_6a,
+- (ndr_print_function_t) ndr_print_spoolss_6a,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33623,7 +33623,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_6b),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_6b,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_6b,
+- (ndr_print_function_t) ndr_print_spoolss_6b,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33632,7 +33632,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_6c),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_6c,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_6c,
+- (ndr_print_function_t) ndr_print_spoolss_6c,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -33641,7 +33641,7 @@ static const struct ndr_interface_call s
+ sizeof(struct spoolss_6d),
+ (ndr_push_flags_fn_t) ndr_push_spoolss_6d,
+ (ndr_pull_flags_fn_t) ndr_pull_spoolss_6d,
+- (ndr_print_function_t) ndr_print_spoolss_6d,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_srvsvc.c
++++ b/source3/librpc/gen_ndr/ndr_srvsvc.c
+@@ -20229,7 +20229,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetCharDevEnum),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetCharDevEnum,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetCharDevEnum,
+- (ndr_print_function_t) ndr_print_srvsvc_NetCharDevEnum,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20238,7 +20238,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetCharDevGetInfo),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetCharDevGetInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetCharDevGetInfo,
+- (ndr_print_function_t) ndr_print_srvsvc_NetCharDevGetInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20247,7 +20247,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetCharDevControl),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetCharDevControl,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetCharDevControl,
+- (ndr_print_function_t) ndr_print_srvsvc_NetCharDevControl,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20256,7 +20256,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetCharDevQEnum),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetCharDevQEnum,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetCharDevQEnum,
+- (ndr_print_function_t) ndr_print_srvsvc_NetCharDevQEnum,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20265,7 +20265,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetCharDevQGetInfo),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetCharDevQGetInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetCharDevQGetInfo,
+- (ndr_print_function_t) ndr_print_srvsvc_NetCharDevQGetInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20274,7 +20274,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetCharDevQSetInfo),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetCharDevQSetInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetCharDevQSetInfo,
+- (ndr_print_function_t) ndr_print_srvsvc_NetCharDevQSetInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20283,7 +20283,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetCharDevQPurge),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetCharDevQPurge,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetCharDevQPurge,
+- (ndr_print_function_t) ndr_print_srvsvc_NetCharDevQPurge,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20292,7 +20292,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetCharDevQPurgeSelf),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetCharDevQPurgeSelf,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetCharDevQPurgeSelf,
+- (ndr_print_function_t) ndr_print_srvsvc_NetCharDevQPurgeSelf,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20301,7 +20301,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetConnEnum),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetConnEnum,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetConnEnum,
+- (ndr_print_function_t) ndr_print_srvsvc_NetConnEnum,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20310,7 +20310,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetFileEnum),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetFileEnum,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetFileEnum,
+- (ndr_print_function_t) ndr_print_srvsvc_NetFileEnum,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20319,7 +20319,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetFileGetInfo),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetFileGetInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetFileGetInfo,
+- (ndr_print_function_t) ndr_print_srvsvc_NetFileGetInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20328,7 +20328,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetFileClose),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetFileClose,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetFileClose,
+- (ndr_print_function_t) ndr_print_srvsvc_NetFileClose,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20337,7 +20337,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetSessEnum),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetSessEnum,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetSessEnum,
+- (ndr_print_function_t) ndr_print_srvsvc_NetSessEnum,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20346,7 +20346,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetSessDel),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetSessDel,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetSessDel,
+- (ndr_print_function_t) ndr_print_srvsvc_NetSessDel,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20355,7 +20355,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetShareAdd),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetShareAdd,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetShareAdd,
+- (ndr_print_function_t) ndr_print_srvsvc_NetShareAdd,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20364,7 +20364,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetShareEnumAll),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetShareEnumAll,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetShareEnumAll,
+- (ndr_print_function_t) ndr_print_srvsvc_NetShareEnumAll,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20373,7 +20373,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetShareGetInfo),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetShareGetInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetShareGetInfo,
+- (ndr_print_function_t) ndr_print_srvsvc_NetShareGetInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20382,7 +20382,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetShareSetInfo),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetShareSetInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetShareSetInfo,
+- (ndr_print_function_t) ndr_print_srvsvc_NetShareSetInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20391,7 +20391,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetShareDel),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetShareDel,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetShareDel,
+- (ndr_print_function_t) ndr_print_srvsvc_NetShareDel,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20400,7 +20400,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetShareDelSticky),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetShareDelSticky,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetShareDelSticky,
+- (ndr_print_function_t) ndr_print_srvsvc_NetShareDelSticky,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20409,7 +20409,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetShareCheck),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetShareCheck,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetShareCheck,
+- (ndr_print_function_t) ndr_print_srvsvc_NetShareCheck,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20418,7 +20418,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetSrvGetInfo),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetSrvGetInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetSrvGetInfo,
+- (ndr_print_function_t) ndr_print_srvsvc_NetSrvGetInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20427,7 +20427,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetSrvSetInfo),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetSrvSetInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetSrvSetInfo,
+- (ndr_print_function_t) ndr_print_srvsvc_NetSrvSetInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20436,7 +20436,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetDiskEnum),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetDiskEnum,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetDiskEnum,
+- (ndr_print_function_t) ndr_print_srvsvc_NetDiskEnum,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20445,7 +20445,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetServerStatisticsGet),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetServerStatisticsGet,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetServerStatisticsGet,
+- (ndr_print_function_t) ndr_print_srvsvc_NetServerStatisticsGet,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20454,7 +20454,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetTransportAdd),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetTransportAdd,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetTransportAdd,
+- (ndr_print_function_t) ndr_print_srvsvc_NetTransportAdd,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20463,7 +20463,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetTransportEnum),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetTransportEnum,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetTransportEnum,
+- (ndr_print_function_t) ndr_print_srvsvc_NetTransportEnum,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20472,7 +20472,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetTransportDel),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetTransportDel,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetTransportDel,
+- (ndr_print_function_t) ndr_print_srvsvc_NetTransportDel,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20481,7 +20481,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetRemoteTOD),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetRemoteTOD,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetRemoteTOD,
+- (ndr_print_function_t) ndr_print_srvsvc_NetRemoteTOD,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20490,7 +20490,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetSetServiceBits),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetSetServiceBits,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetSetServiceBits,
+- (ndr_print_function_t) ndr_print_srvsvc_NetSetServiceBits,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20499,7 +20499,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetPathType),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetPathType,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetPathType,
+- (ndr_print_function_t) ndr_print_srvsvc_NetPathType,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20508,7 +20508,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetPathCanonicalize),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetPathCanonicalize,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetPathCanonicalize,
+- (ndr_print_function_t) ndr_print_srvsvc_NetPathCanonicalize,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20517,7 +20517,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetPathCompare),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetPathCompare,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetPathCompare,
+- (ndr_print_function_t) ndr_print_srvsvc_NetPathCompare,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20526,7 +20526,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetNameValidate),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetNameValidate,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetNameValidate,
+- (ndr_print_function_t) ndr_print_srvsvc_NetNameValidate,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20535,7 +20535,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NETRPRNAMECANONICALIZE),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NETRPRNAMECANONICALIZE,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NETRPRNAMECANONICALIZE,
+- (ndr_print_function_t) ndr_print_srvsvc_NETRPRNAMECANONICALIZE,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20544,7 +20544,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetPRNameCompare),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetPRNameCompare,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetPRNameCompare,
+- (ndr_print_function_t) ndr_print_srvsvc_NetPRNameCompare,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20553,7 +20553,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetShareEnum),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetShareEnum,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetShareEnum,
+- (ndr_print_function_t) ndr_print_srvsvc_NetShareEnum,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20562,7 +20562,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetShareDelStart),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetShareDelStart,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetShareDelStart,
+- (ndr_print_function_t) ndr_print_srvsvc_NetShareDelStart,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20571,7 +20571,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetShareDelCommit),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetShareDelCommit,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetShareDelCommit,
+- (ndr_print_function_t) ndr_print_srvsvc_NetShareDelCommit,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20580,7 +20580,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetGetFileSecurity),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetGetFileSecurity,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetGetFileSecurity,
+- (ndr_print_function_t) ndr_print_srvsvc_NetGetFileSecurity,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20589,7 +20589,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetSetFileSecurity),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetSetFileSecurity,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetSetFileSecurity,
+- (ndr_print_function_t) ndr_print_srvsvc_NetSetFileSecurity,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20598,7 +20598,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetServerTransportAddEx),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetServerTransportAddEx,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetServerTransportAddEx,
+- (ndr_print_function_t) ndr_print_srvsvc_NetServerTransportAddEx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20607,7 +20607,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NetServerSetServiceBitsEx),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NetServerSetServiceBitsEx,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NetServerSetServiceBitsEx,
+- (ndr_print_function_t) ndr_print_srvsvc_NetServerSetServiceBitsEx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20616,7 +20616,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NETRDFSGETVERSION),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NETRDFSGETVERSION,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NETRDFSGETVERSION,
+- (ndr_print_function_t) ndr_print_srvsvc_NETRDFSGETVERSION,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20625,7 +20625,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NETRDFSCREATELOCALPARTITION),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NETRDFSCREATELOCALPARTITION,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NETRDFSCREATELOCALPARTITION,
+- (ndr_print_function_t) ndr_print_srvsvc_NETRDFSCREATELOCALPARTITION,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20634,7 +20634,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NETRDFSDELETELOCALPARTITION),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NETRDFSDELETELOCALPARTITION,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NETRDFSDELETELOCALPARTITION,
+- (ndr_print_function_t) ndr_print_srvsvc_NETRDFSDELETELOCALPARTITION,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20643,7 +20643,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NETRDFSSETLOCALVOLUMESTATE),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NETRDFSSETLOCALVOLUMESTATE,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NETRDFSSETLOCALVOLUMESTATE,
+- (ndr_print_function_t) ndr_print_srvsvc_NETRDFSSETLOCALVOLUMESTATE,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20652,7 +20652,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NETRDFSSETSERVERINFO),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NETRDFSSETSERVERINFO,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NETRDFSSETSERVERINFO,
+- (ndr_print_function_t) ndr_print_srvsvc_NETRDFSSETSERVERINFO,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20661,7 +20661,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NETRDFSCREATEEXITPOINT),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NETRDFSCREATEEXITPOINT,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NETRDFSCREATEEXITPOINT,
+- (ndr_print_function_t) ndr_print_srvsvc_NETRDFSCREATEEXITPOINT,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20670,7 +20670,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NETRDFSDELETEEXITPOINT),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NETRDFSDELETEEXITPOINT,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NETRDFSDELETEEXITPOINT,
+- (ndr_print_function_t) ndr_print_srvsvc_NETRDFSDELETEEXITPOINT,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20679,7 +20679,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NETRDFSMODIFYPREFIX),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NETRDFSMODIFYPREFIX,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NETRDFSMODIFYPREFIX,
+- (ndr_print_function_t) ndr_print_srvsvc_NETRDFSMODIFYPREFIX,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20688,7 +20688,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NETRDFSFIXLOCALVOLUME),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NETRDFSFIXLOCALVOLUME,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NETRDFSFIXLOCALVOLUME,
+- (ndr_print_function_t) ndr_print_srvsvc_NETRDFSFIXLOCALVOLUME,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20697,7 +20697,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NETRDFSMANAGERREPORTSITEINFO),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NETRDFSMANAGERREPORTSITEINFO,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NETRDFSMANAGERREPORTSITEINFO,
+- (ndr_print_function_t) ndr_print_srvsvc_NETRDFSMANAGERREPORTSITEINFO,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -20706,7 +20706,7 @@ static const struct ndr_interface_call s
+ sizeof(struct srvsvc_NETRSERVERTRANSPORTDELEX),
+ (ndr_push_flags_fn_t) ndr_push_srvsvc_NETRSERVERTRANSPORTDELEX,
+ (ndr_pull_flags_fn_t) ndr_pull_srvsvc_NETRSERVERTRANSPORTDELEX,
+- (ndr_print_function_t) ndr_print_srvsvc_NETRSERVERTRANSPORTDELEX,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_svcctl.c
++++ b/source3/librpc/gen_ndr/ndr_svcctl.c
+@@ -7175,7 +7175,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_CloseServiceHandle),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_CloseServiceHandle,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_CloseServiceHandle,
+- (ndr_print_function_t) ndr_print_svcctl_CloseServiceHandle,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7184,7 +7184,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_ControlService),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_ControlService,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_ControlService,
+- (ndr_print_function_t) ndr_print_svcctl_ControlService,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7193,7 +7193,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_DeleteService),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_DeleteService,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_DeleteService,
+- (ndr_print_function_t) ndr_print_svcctl_DeleteService,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7202,7 +7202,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_LockServiceDatabase),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_LockServiceDatabase,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_LockServiceDatabase,
+- (ndr_print_function_t) ndr_print_svcctl_LockServiceDatabase,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7211,7 +7211,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_QueryServiceObjectSecurity),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_QueryServiceObjectSecurity,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_QueryServiceObjectSecurity,
+- (ndr_print_function_t) ndr_print_svcctl_QueryServiceObjectSecurity,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7220,7 +7220,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_SetServiceObjectSecurity),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_SetServiceObjectSecurity,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_SetServiceObjectSecurity,
+- (ndr_print_function_t) ndr_print_svcctl_SetServiceObjectSecurity,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7229,7 +7229,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_QueryServiceStatus),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_QueryServiceStatus,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_QueryServiceStatus,
+- (ndr_print_function_t) ndr_print_svcctl_QueryServiceStatus,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7238,7 +7238,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_SetServiceStatus),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_SetServiceStatus,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_SetServiceStatus,
+- (ndr_print_function_t) ndr_print_svcctl_SetServiceStatus,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7247,7 +7247,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_UnlockServiceDatabase),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_UnlockServiceDatabase,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_UnlockServiceDatabase,
+- (ndr_print_function_t) ndr_print_svcctl_UnlockServiceDatabase,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7256,7 +7256,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_NotifyBootConfigStatus),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_NotifyBootConfigStatus,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_NotifyBootConfigStatus,
+- (ndr_print_function_t) ndr_print_svcctl_NotifyBootConfigStatus,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7265,7 +7265,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_SCSetServiceBitsW),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_SCSetServiceBitsW,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_SCSetServiceBitsW,
+- (ndr_print_function_t) ndr_print_svcctl_SCSetServiceBitsW,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7274,7 +7274,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_ChangeServiceConfigW),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_ChangeServiceConfigW,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_ChangeServiceConfigW,
+- (ndr_print_function_t) ndr_print_svcctl_ChangeServiceConfigW,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7283,7 +7283,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_CreateServiceW),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_CreateServiceW,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_CreateServiceW,
+- (ndr_print_function_t) ndr_print_svcctl_CreateServiceW,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7292,7 +7292,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_EnumDependentServicesW),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_EnumDependentServicesW,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_EnumDependentServicesW,
+- (ndr_print_function_t) ndr_print_svcctl_EnumDependentServicesW,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7301,7 +7301,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_EnumServicesStatusW),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_EnumServicesStatusW,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_EnumServicesStatusW,
+- (ndr_print_function_t) ndr_print_svcctl_EnumServicesStatusW,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7310,7 +7310,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_OpenSCManagerW),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_OpenSCManagerW,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_OpenSCManagerW,
+- (ndr_print_function_t) ndr_print_svcctl_OpenSCManagerW,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7319,7 +7319,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_OpenServiceW),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_OpenServiceW,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_OpenServiceW,
+- (ndr_print_function_t) ndr_print_svcctl_OpenServiceW,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7328,7 +7328,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_QueryServiceConfigW),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_QueryServiceConfigW,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_QueryServiceConfigW,
+- (ndr_print_function_t) ndr_print_svcctl_QueryServiceConfigW,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7337,7 +7337,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_QueryServiceLockStatusW),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_QueryServiceLockStatusW,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_QueryServiceLockStatusW,
+- (ndr_print_function_t) ndr_print_svcctl_QueryServiceLockStatusW,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7346,7 +7346,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_StartServiceW),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_StartServiceW,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_StartServiceW,
+- (ndr_print_function_t) ndr_print_svcctl_StartServiceW,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7355,7 +7355,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_GetServiceDisplayNameW),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_GetServiceDisplayNameW,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_GetServiceDisplayNameW,
+- (ndr_print_function_t) ndr_print_svcctl_GetServiceDisplayNameW,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7364,7 +7364,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_GetServiceKeyNameW),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_GetServiceKeyNameW,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_GetServiceKeyNameW,
+- (ndr_print_function_t) ndr_print_svcctl_GetServiceKeyNameW,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7373,7 +7373,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_SCSetServiceBitsA),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_SCSetServiceBitsA,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_SCSetServiceBitsA,
+- (ndr_print_function_t) ndr_print_svcctl_SCSetServiceBitsA,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7382,7 +7382,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_ChangeServiceConfigA),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_ChangeServiceConfigA,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_ChangeServiceConfigA,
+- (ndr_print_function_t) ndr_print_svcctl_ChangeServiceConfigA,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7391,7 +7391,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_CreateServiceA),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_CreateServiceA,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_CreateServiceA,
+- (ndr_print_function_t) ndr_print_svcctl_CreateServiceA,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7400,7 +7400,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_EnumDependentServicesA),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_EnumDependentServicesA,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_EnumDependentServicesA,
+- (ndr_print_function_t) ndr_print_svcctl_EnumDependentServicesA,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7409,7 +7409,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_EnumServicesStatusA),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_EnumServicesStatusA,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_EnumServicesStatusA,
+- (ndr_print_function_t) ndr_print_svcctl_EnumServicesStatusA,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7418,7 +7418,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_OpenSCManagerA),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_OpenSCManagerA,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_OpenSCManagerA,
+- (ndr_print_function_t) ndr_print_svcctl_OpenSCManagerA,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7427,7 +7427,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_OpenServiceA),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_OpenServiceA,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_OpenServiceA,
+- (ndr_print_function_t) ndr_print_svcctl_OpenServiceA,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7436,7 +7436,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_QueryServiceConfigA),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_QueryServiceConfigA,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_QueryServiceConfigA,
+- (ndr_print_function_t) ndr_print_svcctl_QueryServiceConfigA,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7445,7 +7445,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_QueryServiceLockStatusA),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_QueryServiceLockStatusA,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_QueryServiceLockStatusA,
+- (ndr_print_function_t) ndr_print_svcctl_QueryServiceLockStatusA,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7454,7 +7454,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_StartServiceA),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_StartServiceA,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_StartServiceA,
+- (ndr_print_function_t) ndr_print_svcctl_StartServiceA,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7463,7 +7463,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_GetServiceDisplayNameA),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_GetServiceDisplayNameA,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_GetServiceDisplayNameA,
+- (ndr_print_function_t) ndr_print_svcctl_GetServiceDisplayNameA,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7472,7 +7472,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_GetServiceKeyNameA),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_GetServiceKeyNameA,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_GetServiceKeyNameA,
+- (ndr_print_function_t) ndr_print_svcctl_GetServiceKeyNameA,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7481,7 +7481,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_GetCurrentGroupeStateW),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_GetCurrentGroupeStateW,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_GetCurrentGroupeStateW,
+- (ndr_print_function_t) ndr_print_svcctl_GetCurrentGroupeStateW,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7490,7 +7490,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_EnumServiceGroupW),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_EnumServiceGroupW,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_EnumServiceGroupW,
+- (ndr_print_function_t) ndr_print_svcctl_EnumServiceGroupW,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7499,7 +7499,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_ChangeServiceConfig2A),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_ChangeServiceConfig2A,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_ChangeServiceConfig2A,
+- (ndr_print_function_t) ndr_print_svcctl_ChangeServiceConfig2A,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7508,7 +7508,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_ChangeServiceConfig2W),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_ChangeServiceConfig2W,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_ChangeServiceConfig2W,
+- (ndr_print_function_t) ndr_print_svcctl_ChangeServiceConfig2W,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7517,7 +7517,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_QueryServiceConfig2A),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_QueryServiceConfig2A,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_QueryServiceConfig2A,
+- (ndr_print_function_t) ndr_print_svcctl_QueryServiceConfig2A,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7526,7 +7526,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_QueryServiceConfig2W),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_QueryServiceConfig2W,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_QueryServiceConfig2W,
+- (ndr_print_function_t) ndr_print_svcctl_QueryServiceConfig2W,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7535,7 +7535,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_QueryServiceStatusEx),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_QueryServiceStatusEx,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_QueryServiceStatusEx,
+- (ndr_print_function_t) ndr_print_svcctl_QueryServiceStatusEx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7544,7 +7544,7 @@ static const struct ndr_interface_call s
+ sizeof(struct EnumServicesStatusExA),
+ (ndr_push_flags_fn_t) ndr_push_EnumServicesStatusExA,
+ (ndr_pull_flags_fn_t) ndr_pull_EnumServicesStatusExA,
+- (ndr_print_function_t) ndr_print_EnumServicesStatusExA,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7553,7 +7553,7 @@ static const struct ndr_interface_call s
+ sizeof(struct EnumServicesStatusExW),
+ (ndr_push_flags_fn_t) ndr_push_EnumServicesStatusExW,
+ (ndr_pull_flags_fn_t) ndr_pull_EnumServicesStatusExW,
+- (ndr_print_function_t) ndr_print_EnumServicesStatusExW,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7562,7 +7562,7 @@ static const struct ndr_interface_call s
+ sizeof(struct svcctl_SCSendTSMessage),
+ (ndr_push_flags_fn_t) ndr_push_svcctl_SCSendTSMessage,
+ (ndr_pull_flags_fn_t) ndr_pull_svcctl_SCSendTSMessage,
+- (ndr_print_function_t) ndr_print_svcctl_SCSendTSMessage,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_trkwks.c
++++ b/source3/librpc/gen_ndr/ndr_trkwks.c
+@@ -51,7 +51,7 @@ static const struct ndr_interface_call t
+ sizeof(struct trkwks_Unknown0),
+ (ndr_push_flags_fn_t) ndr_push_trkwks_Unknown0,
+ (ndr_pull_flags_fn_t) ndr_pull_trkwks_Unknown0,
+- (ndr_print_function_t) ndr_print_trkwks_Unknown0,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_unixinfo.c
++++ b/source3/librpc/gen_ndr/ndr_unixinfo.c
+@@ -472,7 +472,7 @@ static const struct ndr_interface_call u
+ sizeof(struct unixinfo_SidToUid),
+ (ndr_push_flags_fn_t) ndr_push_unixinfo_SidToUid,
+ (ndr_pull_flags_fn_t) ndr_pull_unixinfo_SidToUid,
+- (ndr_print_function_t) ndr_print_unixinfo_SidToUid,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -481,7 +481,7 @@ static const struct ndr_interface_call u
+ sizeof(struct unixinfo_UidToSid),
+ (ndr_push_flags_fn_t) ndr_push_unixinfo_UidToSid,
+ (ndr_pull_flags_fn_t) ndr_pull_unixinfo_UidToSid,
+- (ndr_print_function_t) ndr_print_unixinfo_UidToSid,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -490,7 +490,7 @@ static const struct ndr_interface_call u
+ sizeof(struct unixinfo_SidToGid),
+ (ndr_push_flags_fn_t) ndr_push_unixinfo_SidToGid,
+ (ndr_pull_flags_fn_t) ndr_pull_unixinfo_SidToGid,
+- (ndr_print_function_t) ndr_print_unixinfo_SidToGid,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -499,7 +499,7 @@ static const struct ndr_interface_call u
+ sizeof(struct unixinfo_GidToSid),
+ (ndr_push_flags_fn_t) ndr_push_unixinfo_GidToSid,
+ (ndr_pull_flags_fn_t) ndr_pull_unixinfo_GidToSid,
+- (ndr_print_function_t) ndr_print_unixinfo_GidToSid,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -508,7 +508,7 @@ static const struct ndr_interface_call u
+ sizeof(struct unixinfo_GetPWUid),
+ (ndr_push_flags_fn_t) ndr_push_unixinfo_GetPWUid,
+ (ndr_pull_flags_fn_t) ndr_pull_unixinfo_GetPWUid,
+- (ndr_print_function_t) ndr_print_unixinfo_GetPWUid,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_w32time.c
++++ b/source3/librpc/gen_ndr/ndr_w32time.c
+@@ -135,7 +135,7 @@ static const struct ndr_interface_call w
+ sizeof(struct w32time_SyncTime),
+ (ndr_push_flags_fn_t) ndr_push_w32time_SyncTime,
+ (ndr_pull_flags_fn_t) ndr_pull_w32time_SyncTime,
+- (ndr_print_function_t) ndr_print_w32time_SyncTime,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -144,7 +144,7 @@ static const struct ndr_interface_call w
+ sizeof(struct w32time_GetNetLogonServiceBits),
+ (ndr_push_flags_fn_t) ndr_push_w32time_GetNetLogonServiceBits,
+ (ndr_pull_flags_fn_t) ndr_pull_w32time_GetNetLogonServiceBits,
+- (ndr_print_function_t) ndr_print_w32time_GetNetLogonServiceBits,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -153,7 +153,7 @@ static const struct ndr_interface_call w
+ sizeof(struct w32time_QueryProviderStatus),
+ (ndr_push_flags_fn_t) ndr_push_w32time_QueryProviderStatus,
+ (ndr_pull_flags_fn_t) ndr_pull_w32time_QueryProviderStatus,
+- (ndr_print_function_t) ndr_print_w32time_QueryProviderStatus,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_wbint.c
++++ b/source3/librpc/gen_ndr/ndr_wbint.c
+@@ -2696,7 +2696,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wbint_Ping),
+ (ndr_push_flags_fn_t) ndr_push_wbint_Ping,
+ (ndr_pull_flags_fn_t) ndr_pull_wbint_Ping,
+- (ndr_print_function_t) ndr_print_wbint_Ping,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2705,7 +2705,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wbint_LookupSid),
+ (ndr_push_flags_fn_t) ndr_push_wbint_LookupSid,
+ (ndr_pull_flags_fn_t) ndr_pull_wbint_LookupSid,
+- (ndr_print_function_t) ndr_print_wbint_LookupSid,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2714,7 +2714,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wbint_LookupSids),
+ (ndr_push_flags_fn_t) ndr_push_wbint_LookupSids,
+ (ndr_pull_flags_fn_t) ndr_pull_wbint_LookupSids,
+- (ndr_print_function_t) ndr_print_wbint_LookupSids,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2723,7 +2723,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wbint_LookupName),
+ (ndr_push_flags_fn_t) ndr_push_wbint_LookupName,
+ (ndr_pull_flags_fn_t) ndr_pull_wbint_LookupName,
+- (ndr_print_function_t) ndr_print_wbint_LookupName,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2732,7 +2732,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wbint_Sid2Uid),
+ (ndr_push_flags_fn_t) ndr_push_wbint_Sid2Uid,
+ (ndr_pull_flags_fn_t) ndr_pull_wbint_Sid2Uid,
+- (ndr_print_function_t) ndr_print_wbint_Sid2Uid,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2741,7 +2741,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wbint_Sid2Gid),
+ (ndr_push_flags_fn_t) ndr_push_wbint_Sid2Gid,
+ (ndr_pull_flags_fn_t) ndr_pull_wbint_Sid2Gid,
+- (ndr_print_function_t) ndr_print_wbint_Sid2Gid,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2750,7 +2750,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wbint_Sids2UnixIDs),
+ (ndr_push_flags_fn_t) ndr_push_wbint_Sids2UnixIDs,
+ (ndr_pull_flags_fn_t) ndr_pull_wbint_Sids2UnixIDs,
+- (ndr_print_function_t) ndr_print_wbint_Sids2UnixIDs,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2759,7 +2759,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wbint_Uid2Sid),
+ (ndr_push_flags_fn_t) ndr_push_wbint_Uid2Sid,
+ (ndr_pull_flags_fn_t) ndr_pull_wbint_Uid2Sid,
+- (ndr_print_function_t) ndr_print_wbint_Uid2Sid,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2768,7 +2768,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wbint_Gid2Sid),
+ (ndr_push_flags_fn_t) ndr_push_wbint_Gid2Sid,
+ (ndr_pull_flags_fn_t) ndr_pull_wbint_Gid2Sid,
+- (ndr_print_function_t) ndr_print_wbint_Gid2Sid,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2777,7 +2777,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wbint_AllocateUid),
+ (ndr_push_flags_fn_t) ndr_push_wbint_AllocateUid,
+ (ndr_pull_flags_fn_t) ndr_pull_wbint_AllocateUid,
+- (ndr_print_function_t) ndr_print_wbint_AllocateUid,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2786,7 +2786,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wbint_AllocateGid),
+ (ndr_push_flags_fn_t) ndr_push_wbint_AllocateGid,
+ (ndr_pull_flags_fn_t) ndr_pull_wbint_AllocateGid,
+- (ndr_print_function_t) ndr_print_wbint_AllocateGid,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2795,7 +2795,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wbint_QueryUser),
+ (ndr_push_flags_fn_t) ndr_push_wbint_QueryUser,
+ (ndr_pull_flags_fn_t) ndr_pull_wbint_QueryUser,
+- (ndr_print_function_t) ndr_print_wbint_QueryUser,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2804,7 +2804,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wbint_LookupUserAliases),
+ (ndr_push_flags_fn_t) ndr_push_wbint_LookupUserAliases,
+ (ndr_pull_flags_fn_t) ndr_pull_wbint_LookupUserAliases,
+- (ndr_print_function_t) ndr_print_wbint_LookupUserAliases,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2813,7 +2813,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wbint_LookupUserGroups),
+ (ndr_push_flags_fn_t) ndr_push_wbint_LookupUserGroups,
+ (ndr_pull_flags_fn_t) ndr_pull_wbint_LookupUserGroups,
+- (ndr_print_function_t) ndr_print_wbint_LookupUserGroups,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2822,7 +2822,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wbint_QuerySequenceNumber),
+ (ndr_push_flags_fn_t) ndr_push_wbint_QuerySequenceNumber,
+ (ndr_pull_flags_fn_t) ndr_pull_wbint_QuerySequenceNumber,
+- (ndr_print_function_t) ndr_print_wbint_QuerySequenceNumber,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2831,7 +2831,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wbint_LookupGroupMembers),
+ (ndr_push_flags_fn_t) ndr_push_wbint_LookupGroupMembers,
+ (ndr_pull_flags_fn_t) ndr_pull_wbint_LookupGroupMembers,
+- (ndr_print_function_t) ndr_print_wbint_LookupGroupMembers,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2840,7 +2840,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wbint_QueryUserList),
+ (ndr_push_flags_fn_t) ndr_push_wbint_QueryUserList,
+ (ndr_pull_flags_fn_t) ndr_pull_wbint_QueryUserList,
+- (ndr_print_function_t) ndr_print_wbint_QueryUserList,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2849,7 +2849,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wbint_QueryGroupList),
+ (ndr_push_flags_fn_t) ndr_push_wbint_QueryGroupList,
+ (ndr_pull_flags_fn_t) ndr_pull_wbint_QueryGroupList,
+- (ndr_print_function_t) ndr_print_wbint_QueryGroupList,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2858,7 +2858,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wbint_DsGetDcName),
+ (ndr_push_flags_fn_t) ndr_push_wbint_DsGetDcName,
+ (ndr_pull_flags_fn_t) ndr_pull_wbint_DsGetDcName,
+- (ndr_print_function_t) ndr_print_wbint_DsGetDcName,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2867,7 +2867,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wbint_LookupRids),
+ (ndr_push_flags_fn_t) ndr_push_wbint_LookupRids,
+ (ndr_pull_flags_fn_t) ndr_pull_wbint_LookupRids,
+- (ndr_print_function_t) ndr_print_wbint_LookupRids,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2876,7 +2876,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wbint_CheckMachineAccount),
+ (ndr_push_flags_fn_t) ndr_push_wbint_CheckMachineAccount,
+ (ndr_pull_flags_fn_t) ndr_pull_wbint_CheckMachineAccount,
+- (ndr_print_function_t) ndr_print_wbint_CheckMachineAccount,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2885,7 +2885,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wbint_ChangeMachineAccount),
+ (ndr_push_flags_fn_t) ndr_push_wbint_ChangeMachineAccount,
+ (ndr_pull_flags_fn_t) ndr_pull_wbint_ChangeMachineAccount,
+- (ndr_print_function_t) ndr_print_wbint_ChangeMachineAccount,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -2894,7 +2894,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wbint_PingDc),
+ (ndr_push_flags_fn_t) ndr_push_wbint_PingDc,
+ (ndr_pull_flags_fn_t) ndr_pull_wbint_PingDc,
+- (ndr_print_function_t) ndr_print_wbint_PingDc,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_winreg.c
++++ b/source3/librpc/gen_ndr/ndr_winreg.c
+@@ -4864,7 +4864,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_OpenHKCR),
+ (ndr_push_flags_fn_t) ndr_push_winreg_OpenHKCR,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_OpenHKCR,
+- (ndr_print_function_t) ndr_print_winreg_OpenHKCR,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -4873,7 +4873,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_OpenHKCU),
+ (ndr_push_flags_fn_t) ndr_push_winreg_OpenHKCU,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_OpenHKCU,
+- (ndr_print_function_t) ndr_print_winreg_OpenHKCU,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -4882,7 +4882,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_OpenHKLM),
+ (ndr_push_flags_fn_t) ndr_push_winreg_OpenHKLM,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_OpenHKLM,
+- (ndr_print_function_t) ndr_print_winreg_OpenHKLM,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -4891,7 +4891,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_OpenHKPD),
+ (ndr_push_flags_fn_t) ndr_push_winreg_OpenHKPD,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_OpenHKPD,
+- (ndr_print_function_t) ndr_print_winreg_OpenHKPD,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -4900,7 +4900,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_OpenHKU),
+ (ndr_push_flags_fn_t) ndr_push_winreg_OpenHKU,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_OpenHKU,
+- (ndr_print_function_t) ndr_print_winreg_OpenHKU,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -4909,7 +4909,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_CloseKey),
+ (ndr_push_flags_fn_t) ndr_push_winreg_CloseKey,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_CloseKey,
+- (ndr_print_function_t) ndr_print_winreg_CloseKey,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -4918,7 +4918,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_CreateKey),
+ (ndr_push_flags_fn_t) ndr_push_winreg_CreateKey,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_CreateKey,
+- (ndr_print_function_t) ndr_print_winreg_CreateKey,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -4927,7 +4927,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_DeleteKey),
+ (ndr_push_flags_fn_t) ndr_push_winreg_DeleteKey,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_DeleteKey,
+- (ndr_print_function_t) ndr_print_winreg_DeleteKey,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -4936,7 +4936,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_DeleteValue),
+ (ndr_push_flags_fn_t) ndr_push_winreg_DeleteValue,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_DeleteValue,
+- (ndr_print_function_t) ndr_print_winreg_DeleteValue,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -4945,7 +4945,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_EnumKey),
+ (ndr_push_flags_fn_t) ndr_push_winreg_EnumKey,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_EnumKey,
+- (ndr_print_function_t) ndr_print_winreg_EnumKey,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -4954,7 +4954,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_EnumValue),
+ (ndr_push_flags_fn_t) ndr_push_winreg_EnumValue,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_EnumValue,
+- (ndr_print_function_t) ndr_print_winreg_EnumValue,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -4963,7 +4963,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_FlushKey),
+ (ndr_push_flags_fn_t) ndr_push_winreg_FlushKey,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_FlushKey,
+- (ndr_print_function_t) ndr_print_winreg_FlushKey,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -4972,7 +4972,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_GetKeySecurity),
+ (ndr_push_flags_fn_t) ndr_push_winreg_GetKeySecurity,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_GetKeySecurity,
+- (ndr_print_function_t) ndr_print_winreg_GetKeySecurity,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -4981,7 +4981,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_LoadKey),
+ (ndr_push_flags_fn_t) ndr_push_winreg_LoadKey,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_LoadKey,
+- (ndr_print_function_t) ndr_print_winreg_LoadKey,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -4990,7 +4990,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_NotifyChangeKeyValue),
+ (ndr_push_flags_fn_t) ndr_push_winreg_NotifyChangeKeyValue,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_NotifyChangeKeyValue,
+- (ndr_print_function_t) ndr_print_winreg_NotifyChangeKeyValue,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -4999,7 +4999,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_OpenKey),
+ (ndr_push_flags_fn_t) ndr_push_winreg_OpenKey,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_OpenKey,
+- (ndr_print_function_t) ndr_print_winreg_OpenKey,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5008,7 +5008,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_QueryInfoKey),
+ (ndr_push_flags_fn_t) ndr_push_winreg_QueryInfoKey,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_QueryInfoKey,
+- (ndr_print_function_t) ndr_print_winreg_QueryInfoKey,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5017,7 +5017,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_QueryValue),
+ (ndr_push_flags_fn_t) ndr_push_winreg_QueryValue,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_QueryValue,
+- (ndr_print_function_t) ndr_print_winreg_QueryValue,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5026,7 +5026,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_ReplaceKey),
+ (ndr_push_flags_fn_t) ndr_push_winreg_ReplaceKey,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_ReplaceKey,
+- (ndr_print_function_t) ndr_print_winreg_ReplaceKey,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5035,7 +5035,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_RestoreKey),
+ (ndr_push_flags_fn_t) ndr_push_winreg_RestoreKey,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_RestoreKey,
+- (ndr_print_function_t) ndr_print_winreg_RestoreKey,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5044,7 +5044,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_SaveKey),
+ (ndr_push_flags_fn_t) ndr_push_winreg_SaveKey,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_SaveKey,
+- (ndr_print_function_t) ndr_print_winreg_SaveKey,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5053,7 +5053,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_SetKeySecurity),
+ (ndr_push_flags_fn_t) ndr_push_winreg_SetKeySecurity,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_SetKeySecurity,
+- (ndr_print_function_t) ndr_print_winreg_SetKeySecurity,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5062,7 +5062,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_SetValue),
+ (ndr_push_flags_fn_t) ndr_push_winreg_SetValue,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_SetValue,
+- (ndr_print_function_t) ndr_print_winreg_SetValue,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5071,7 +5071,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_UnLoadKey),
+ (ndr_push_flags_fn_t) ndr_push_winreg_UnLoadKey,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_UnLoadKey,
+- (ndr_print_function_t) ndr_print_winreg_UnLoadKey,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5080,7 +5080,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_InitiateSystemShutdown),
+ (ndr_push_flags_fn_t) ndr_push_winreg_InitiateSystemShutdown,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_InitiateSystemShutdown,
+- (ndr_print_function_t) ndr_print_winreg_InitiateSystemShutdown,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5089,7 +5089,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_AbortSystemShutdown),
+ (ndr_push_flags_fn_t) ndr_push_winreg_AbortSystemShutdown,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_AbortSystemShutdown,
+- (ndr_print_function_t) ndr_print_winreg_AbortSystemShutdown,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5098,7 +5098,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_GetVersion),
+ (ndr_push_flags_fn_t) ndr_push_winreg_GetVersion,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_GetVersion,
+- (ndr_print_function_t) ndr_print_winreg_GetVersion,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5107,7 +5107,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_OpenHKCC),
+ (ndr_push_flags_fn_t) ndr_push_winreg_OpenHKCC,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_OpenHKCC,
+- (ndr_print_function_t) ndr_print_winreg_OpenHKCC,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5116,7 +5116,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_OpenHKDD),
+ (ndr_push_flags_fn_t) ndr_push_winreg_OpenHKDD,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_OpenHKDD,
+- (ndr_print_function_t) ndr_print_winreg_OpenHKDD,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5125,7 +5125,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_QueryMultipleValues),
+ (ndr_push_flags_fn_t) ndr_push_winreg_QueryMultipleValues,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_QueryMultipleValues,
+- (ndr_print_function_t) ndr_print_winreg_QueryMultipleValues,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5134,7 +5134,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_InitiateSystemShutdownEx),
+ (ndr_push_flags_fn_t) ndr_push_winreg_InitiateSystemShutdownEx,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_InitiateSystemShutdownEx,
+- (ndr_print_function_t) ndr_print_winreg_InitiateSystemShutdownEx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5143,7 +5143,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_SaveKeyEx),
+ (ndr_push_flags_fn_t) ndr_push_winreg_SaveKeyEx,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_SaveKeyEx,
+- (ndr_print_function_t) ndr_print_winreg_SaveKeyEx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5152,7 +5152,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_OpenHKPT),
+ (ndr_push_flags_fn_t) ndr_push_winreg_OpenHKPT,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_OpenHKPT,
+- (ndr_print_function_t) ndr_print_winreg_OpenHKPT,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5161,7 +5161,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_OpenHKPN),
+ (ndr_push_flags_fn_t) ndr_push_winreg_OpenHKPN,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_OpenHKPN,
+- (ndr_print_function_t) ndr_print_winreg_OpenHKPN,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5170,7 +5170,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_QueryMultipleValues2),
+ (ndr_push_flags_fn_t) ndr_push_winreg_QueryMultipleValues2,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_QueryMultipleValues2,
+- (ndr_print_function_t) ndr_print_winreg_QueryMultipleValues2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5179,7 +5179,7 @@ static const struct ndr_interface_call w
+ sizeof(struct winreg_DeleteKeyEx),
+ (ndr_push_flags_fn_t) ndr_push_winreg_DeleteKeyEx,
+ (ndr_pull_flags_fn_t) ndr_pull_winreg_DeleteKeyEx,
+- (ndr_print_function_t) ndr_print_winreg_DeleteKeyEx,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_wkssvc.c
++++ b/source3/librpc/gen_ndr/ndr_wkssvc.c
+@@ -11005,7 +11005,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetWkstaGetInfo),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetWkstaGetInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetWkstaGetInfo,
+- (ndr_print_function_t) ndr_print_wkssvc_NetWkstaGetInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11014,7 +11014,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetWkstaSetInfo),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetWkstaSetInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetWkstaSetInfo,
+- (ndr_print_function_t) ndr_print_wkssvc_NetWkstaSetInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11023,7 +11023,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetWkstaEnumUsers),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetWkstaEnumUsers,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetWkstaEnumUsers,
+- (ndr_print_function_t) ndr_print_wkssvc_NetWkstaEnumUsers,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11032,7 +11032,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetrWkstaUserGetInfo),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetrWkstaUserGetInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetrWkstaUserGetInfo,
+- (ndr_print_function_t) ndr_print_wkssvc_NetrWkstaUserGetInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11041,7 +11041,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetrWkstaUserSetInfo),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetrWkstaUserSetInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetrWkstaUserSetInfo,
+- (ndr_print_function_t) ndr_print_wkssvc_NetrWkstaUserSetInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11050,7 +11050,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetWkstaTransportEnum),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetWkstaTransportEnum,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetWkstaTransportEnum,
+- (ndr_print_function_t) ndr_print_wkssvc_NetWkstaTransportEnum,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11059,7 +11059,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetrWkstaTransportAdd),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetrWkstaTransportAdd,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetrWkstaTransportAdd,
+- (ndr_print_function_t) ndr_print_wkssvc_NetrWkstaTransportAdd,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11068,7 +11068,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetrWkstaTransportDel),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetrWkstaTransportDel,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetrWkstaTransportDel,
+- (ndr_print_function_t) ndr_print_wkssvc_NetrWkstaTransportDel,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11077,7 +11077,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetrUseAdd),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetrUseAdd,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetrUseAdd,
+- (ndr_print_function_t) ndr_print_wkssvc_NetrUseAdd,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11086,7 +11086,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetrUseGetInfo),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetrUseGetInfo,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetrUseGetInfo,
+- (ndr_print_function_t) ndr_print_wkssvc_NetrUseGetInfo,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11095,7 +11095,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetrUseDel),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetrUseDel,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetrUseDel,
+- (ndr_print_function_t) ndr_print_wkssvc_NetrUseDel,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11104,7 +11104,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetrUseEnum),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetrUseEnum,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetrUseEnum,
+- (ndr_print_function_t) ndr_print_wkssvc_NetrUseEnum,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11113,7 +11113,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetrMessageBufferSend),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetrMessageBufferSend,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetrMessageBufferSend,
+- (ndr_print_function_t) ndr_print_wkssvc_NetrMessageBufferSend,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11122,7 +11122,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetrWorkstationStatisticsGet),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetrWorkstationStatisticsGet,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetrWorkstationStatisticsGet,
+- (ndr_print_function_t) ndr_print_wkssvc_NetrWorkstationStatisticsGet,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11131,7 +11131,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetrLogonDomainNameAdd),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetrLogonDomainNameAdd,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetrLogonDomainNameAdd,
+- (ndr_print_function_t) ndr_print_wkssvc_NetrLogonDomainNameAdd,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11140,7 +11140,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetrLogonDomainNameDel),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetrLogonDomainNameDel,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetrLogonDomainNameDel,
+- (ndr_print_function_t) ndr_print_wkssvc_NetrLogonDomainNameDel,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11149,7 +11149,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetrJoinDomain),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetrJoinDomain,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetrJoinDomain,
+- (ndr_print_function_t) ndr_print_wkssvc_NetrJoinDomain,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11158,7 +11158,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetrUnjoinDomain),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetrUnjoinDomain,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetrUnjoinDomain,
+- (ndr_print_function_t) ndr_print_wkssvc_NetrUnjoinDomain,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11167,7 +11167,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetrRenameMachineInDomain),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetrRenameMachineInDomain,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetrRenameMachineInDomain,
+- (ndr_print_function_t) ndr_print_wkssvc_NetrRenameMachineInDomain,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11176,7 +11176,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetrValidateName),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetrValidateName,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetrValidateName,
+- (ndr_print_function_t) ndr_print_wkssvc_NetrValidateName,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11185,7 +11185,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetrGetJoinInformation),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetrGetJoinInformation,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetrGetJoinInformation,
+- (ndr_print_function_t) ndr_print_wkssvc_NetrGetJoinInformation,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11194,7 +11194,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetrGetJoinableOus),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetrGetJoinableOus,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetrGetJoinableOus,
+- (ndr_print_function_t) ndr_print_wkssvc_NetrGetJoinableOus,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11203,7 +11203,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetrJoinDomain2),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetrJoinDomain2,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetrJoinDomain2,
+- (ndr_print_function_t) ndr_print_wkssvc_NetrJoinDomain2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11212,7 +11212,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetrUnjoinDomain2),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetrUnjoinDomain2,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetrUnjoinDomain2,
+- (ndr_print_function_t) ndr_print_wkssvc_NetrUnjoinDomain2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11221,7 +11221,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetrRenameMachineInDomain2),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetrRenameMachineInDomain2,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetrRenameMachineInDomain2,
+- (ndr_print_function_t) ndr_print_wkssvc_NetrRenameMachineInDomain2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11230,7 +11230,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetrValidateName2),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetrValidateName2,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetrValidateName2,
+- (ndr_print_function_t) ndr_print_wkssvc_NetrValidateName2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11239,7 +11239,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetrGetJoinableOus2),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetrGetJoinableOus2,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetrGetJoinableOus2,
+- (ndr_print_function_t) ndr_print_wkssvc_NetrGetJoinableOus2,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11248,7 +11248,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetrAddAlternateComputerName),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetrAddAlternateComputerName,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetrAddAlternateComputerName,
+- (ndr_print_function_t) ndr_print_wkssvc_NetrAddAlternateComputerName,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11257,7 +11257,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetrRemoveAlternateComputerName),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetrRemoveAlternateComputerName,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetrRemoveAlternateComputerName,
+- (ndr_print_function_t) ndr_print_wkssvc_NetrRemoveAlternateComputerName,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11266,7 +11266,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetrSetPrimaryComputername),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetrSetPrimaryComputername,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetrSetPrimaryComputername,
+- (ndr_print_function_t) ndr_print_wkssvc_NetrSetPrimaryComputername,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -11275,7 +11275,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wkssvc_NetrEnumerateComputerNames),
+ (ndr_push_flags_fn_t) ndr_push_wkssvc_NetrEnumerateComputerNames,
+ (ndr_pull_flags_fn_t) ndr_pull_wkssvc_NetrEnumerateComputerNames,
+- (ndr_print_function_t) ndr_print_wkssvc_NetrEnumerateComputerNames,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_wmi.c
++++ b/source3/librpc/gen_ndr/ndr_wmi.c
+@@ -139,7 +139,7 @@ static const struct ndr_interface_call I
+ sizeof(struct Delete),
+ (ndr_push_flags_fn_t) ndr_push_Delete,
+ (ndr_pull_flags_fn_t) ndr_pull_Delete,
+- (ndr_print_function_t) ndr_print_Delete,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3704,7 +3704,7 @@ static const struct ndr_interface_call I
+ sizeof(struct OpenNamespace),
+ (ndr_push_flags_fn_t) ndr_push_OpenNamespace,
+ (ndr_pull_flags_fn_t) ndr_pull_OpenNamespace,
+- (ndr_print_function_t) ndr_print_OpenNamespace,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3713,7 +3713,7 @@ static const struct ndr_interface_call I
+ sizeof(struct CancelAsyncCall),
+ (ndr_push_flags_fn_t) ndr_push_CancelAsyncCall,
+ (ndr_pull_flags_fn_t) ndr_pull_CancelAsyncCall,
+- (ndr_print_function_t) ndr_print_CancelAsyncCall,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3722,7 +3722,7 @@ static const struct ndr_interface_call I
+ sizeof(struct QueryObjectSink),
+ (ndr_push_flags_fn_t) ndr_push_QueryObjectSink,
+ (ndr_pull_flags_fn_t) ndr_pull_QueryObjectSink,
+- (ndr_print_function_t) ndr_print_QueryObjectSink,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3731,7 +3731,7 @@ static const struct ndr_interface_call I
+ sizeof(struct GetObject),
+ (ndr_push_flags_fn_t) ndr_push_GetObject,
+ (ndr_pull_flags_fn_t) ndr_pull_GetObject,
+- (ndr_print_function_t) ndr_print_GetObject,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3740,7 +3740,7 @@ static const struct ndr_interface_call I
+ sizeof(struct GetObjectAsync),
+ (ndr_push_flags_fn_t) ndr_push_GetObjectAsync,
+ (ndr_pull_flags_fn_t) ndr_pull_GetObjectAsync,
+- (ndr_print_function_t) ndr_print_GetObjectAsync,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3749,7 +3749,7 @@ static const struct ndr_interface_call I
+ sizeof(struct PutClass),
+ (ndr_push_flags_fn_t) ndr_push_PutClass,
+ (ndr_pull_flags_fn_t) ndr_pull_PutClass,
+- (ndr_print_function_t) ndr_print_PutClass,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3758,7 +3758,7 @@ static const struct ndr_interface_call I
+ sizeof(struct PutClassAsync),
+ (ndr_push_flags_fn_t) ndr_push_PutClassAsync,
+ (ndr_pull_flags_fn_t) ndr_pull_PutClassAsync,
+- (ndr_print_function_t) ndr_print_PutClassAsync,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3767,7 +3767,7 @@ static const struct ndr_interface_call I
+ sizeof(struct DeleteClass),
+ (ndr_push_flags_fn_t) ndr_push_DeleteClass,
+ (ndr_pull_flags_fn_t) ndr_pull_DeleteClass,
+- (ndr_print_function_t) ndr_print_DeleteClass,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3776,7 +3776,7 @@ static const struct ndr_interface_call I
+ sizeof(struct DeleteClassAsync),
+ (ndr_push_flags_fn_t) ndr_push_DeleteClassAsync,
+ (ndr_pull_flags_fn_t) ndr_pull_DeleteClassAsync,
+- (ndr_print_function_t) ndr_print_DeleteClassAsync,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3785,7 +3785,7 @@ static const struct ndr_interface_call I
+ sizeof(struct CreateClassEnum),
+ (ndr_push_flags_fn_t) ndr_push_CreateClassEnum,
+ (ndr_pull_flags_fn_t) ndr_pull_CreateClassEnum,
+- (ndr_print_function_t) ndr_print_CreateClassEnum,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3794,7 +3794,7 @@ static const struct ndr_interface_call I
+ sizeof(struct CreateClassEnumAsync),
+ (ndr_push_flags_fn_t) ndr_push_CreateClassEnumAsync,
+ (ndr_pull_flags_fn_t) ndr_pull_CreateClassEnumAsync,
+- (ndr_print_function_t) ndr_print_CreateClassEnumAsync,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3803,7 +3803,7 @@ static const struct ndr_interface_call I
+ sizeof(struct PutInstance),
+ (ndr_push_flags_fn_t) ndr_push_PutInstance,
+ (ndr_pull_flags_fn_t) ndr_pull_PutInstance,
+- (ndr_print_function_t) ndr_print_PutInstance,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3812,7 +3812,7 @@ static const struct ndr_interface_call I
+ sizeof(struct PutInstanceAsync),
+ (ndr_push_flags_fn_t) ndr_push_PutInstanceAsync,
+ (ndr_pull_flags_fn_t) ndr_pull_PutInstanceAsync,
+- (ndr_print_function_t) ndr_print_PutInstanceAsync,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3821,7 +3821,7 @@ static const struct ndr_interface_call I
+ sizeof(struct DeleteInstance),
+ (ndr_push_flags_fn_t) ndr_push_DeleteInstance,
+ (ndr_pull_flags_fn_t) ndr_pull_DeleteInstance,
+- (ndr_print_function_t) ndr_print_DeleteInstance,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3830,7 +3830,7 @@ static const struct ndr_interface_call I
+ sizeof(struct DeleteInstanceAsync),
+ (ndr_push_flags_fn_t) ndr_push_DeleteInstanceAsync,
+ (ndr_pull_flags_fn_t) ndr_pull_DeleteInstanceAsync,
+- (ndr_print_function_t) ndr_print_DeleteInstanceAsync,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3839,7 +3839,7 @@ static const struct ndr_interface_call I
+ sizeof(struct CreateInstanceEnum),
+ (ndr_push_flags_fn_t) ndr_push_CreateInstanceEnum,
+ (ndr_pull_flags_fn_t) ndr_pull_CreateInstanceEnum,
+- (ndr_print_function_t) ndr_print_CreateInstanceEnum,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3848,7 +3848,7 @@ static const struct ndr_interface_call I
+ sizeof(struct CreateInstanceEnumAsync),
+ (ndr_push_flags_fn_t) ndr_push_CreateInstanceEnumAsync,
+ (ndr_pull_flags_fn_t) ndr_pull_CreateInstanceEnumAsync,
+- (ndr_print_function_t) ndr_print_CreateInstanceEnumAsync,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3857,7 +3857,7 @@ static const struct ndr_interface_call I
+ sizeof(struct ExecQuery),
+ (ndr_push_flags_fn_t) ndr_push_ExecQuery,
+ (ndr_pull_flags_fn_t) ndr_pull_ExecQuery,
+- (ndr_print_function_t) ndr_print_ExecQuery,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3866,7 +3866,7 @@ static const struct ndr_interface_call I
+ sizeof(struct ExecQueryAsync),
+ (ndr_push_flags_fn_t) ndr_push_ExecQueryAsync,
+ (ndr_pull_flags_fn_t) ndr_pull_ExecQueryAsync,
+- (ndr_print_function_t) ndr_print_ExecQueryAsync,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3875,7 +3875,7 @@ static const struct ndr_interface_call I
+ sizeof(struct ExecNotificationQuery),
+ (ndr_push_flags_fn_t) ndr_push_ExecNotificationQuery,
+ (ndr_pull_flags_fn_t) ndr_pull_ExecNotificationQuery,
+- (ndr_print_function_t) ndr_print_ExecNotificationQuery,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3884,7 +3884,7 @@ static const struct ndr_interface_call I
+ sizeof(struct ExecNotificationQueryAsync),
+ (ndr_push_flags_fn_t) ndr_push_ExecNotificationQueryAsync,
+ (ndr_pull_flags_fn_t) ndr_pull_ExecNotificationQueryAsync,
+- (ndr_print_function_t) ndr_print_ExecNotificationQueryAsync,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3893,7 +3893,7 @@ static const struct ndr_interface_call I
+ sizeof(struct ExecMethod),
+ (ndr_push_flags_fn_t) ndr_push_ExecMethod,
+ (ndr_pull_flags_fn_t) ndr_pull_ExecMethod,
+- (ndr_print_function_t) ndr_print_ExecMethod,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -3902,7 +3902,7 @@ static const struct ndr_interface_call I
+ sizeof(struct ExecMethodAsync),
+ (ndr_push_flags_fn_t) ndr_push_ExecMethodAsync,
+ (ndr_pull_flags_fn_t) ndr_pull_ExecMethodAsync,
+- (ndr_print_function_t) ndr_print_ExecMethodAsync,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -4434,7 +4434,7 @@ static const struct ndr_interface_call I
+ sizeof(struct Reset),
+ (ndr_push_flags_fn_t) ndr_push_Reset,
+ (ndr_pull_flags_fn_t) ndr_pull_Reset,
+- (ndr_print_function_t) ndr_print_Reset,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -4443,7 +4443,7 @@ static const struct ndr_interface_call I
+ sizeof(struct IEnumWbemClassObject_Next),
+ (ndr_push_flags_fn_t) ndr_push_IEnumWbemClassObject_Next,
+ (ndr_pull_flags_fn_t) ndr_pull_IEnumWbemClassObject_Next,
+- (ndr_print_function_t) ndr_print_IEnumWbemClassObject_Next,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -4452,7 +4452,7 @@ static const struct ndr_interface_call I
+ sizeof(struct NextAsync),
+ (ndr_push_flags_fn_t) ndr_push_NextAsync,
+ (ndr_pull_flags_fn_t) ndr_pull_NextAsync,
+- (ndr_print_function_t) ndr_print_NextAsync,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -4461,7 +4461,7 @@ static const struct ndr_interface_call I
+ sizeof(struct IEnumWbemClassObject_Clone),
+ (ndr_push_flags_fn_t) ndr_push_IEnumWbemClassObject_Clone,
+ (ndr_pull_flags_fn_t) ndr_pull_IEnumWbemClassObject_Clone,
+- (ndr_print_function_t) ndr_print_IEnumWbemClassObject_Clone,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -4470,7 +4470,7 @@ static const struct ndr_interface_call I
+ sizeof(struct Skip),
+ (ndr_push_flags_fn_t) ndr_push_Skip,
+ (ndr_pull_flags_fn_t) ndr_pull_Skip,
+- (ndr_print_function_t) ndr_print_Skip,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5143,7 +5143,7 @@ static const struct ndr_interface_call I
+ sizeof(struct Clone),
+ (ndr_push_flags_fn_t) ndr_push_Clone,
+ (ndr_pull_flags_fn_t) ndr_pull_Clone,
+- (ndr_print_function_t) ndr_print_Clone,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5152,7 +5152,7 @@ static const struct ndr_interface_call I
+ sizeof(struct GetNames),
+ (ndr_push_flags_fn_t) ndr_push_GetNames,
+ (ndr_pull_flags_fn_t) ndr_pull_GetNames,
+- (ndr_print_function_t) ndr_print_GetNames,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5161,7 +5161,7 @@ static const struct ndr_interface_call I
+ sizeof(struct BeginEnumeration),
+ (ndr_push_flags_fn_t) ndr_push_BeginEnumeration,
+ (ndr_pull_flags_fn_t) ndr_pull_BeginEnumeration,
+- (ndr_print_function_t) ndr_print_BeginEnumeration,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5170,7 +5170,7 @@ static const struct ndr_interface_call I
+ sizeof(struct Next),
+ (ndr_push_flags_fn_t) ndr_push_Next,
+ (ndr_pull_flags_fn_t) ndr_pull_Next,
+- (ndr_print_function_t) ndr_print_Next,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5179,7 +5179,7 @@ static const struct ndr_interface_call I
+ sizeof(struct EndEnumeration),
+ (ndr_push_flags_fn_t) ndr_push_EndEnumeration,
+ (ndr_pull_flags_fn_t) ndr_pull_EndEnumeration,
+- (ndr_print_function_t) ndr_print_EndEnumeration,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5188,7 +5188,7 @@ static const struct ndr_interface_call I
+ sizeof(struct SetValue),
+ (ndr_push_flags_fn_t) ndr_push_SetValue,
+ (ndr_pull_flags_fn_t) ndr_pull_SetValue,
+- (ndr_print_function_t) ndr_print_SetValue,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5197,7 +5197,7 @@ static const struct ndr_interface_call I
+ sizeof(struct GetValue),
+ (ndr_push_flags_fn_t) ndr_push_GetValue,
+ (ndr_pull_flags_fn_t) ndr_pull_GetValue,
+- (ndr_print_function_t) ndr_print_GetValue,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5206,7 +5206,7 @@ static const struct ndr_interface_call I
+ sizeof(struct DeleteValue),
+ (ndr_push_flags_fn_t) ndr_push_DeleteValue,
+ (ndr_pull_flags_fn_t) ndr_pull_DeleteValue,
+- (ndr_print_function_t) ndr_print_DeleteValue,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5215,7 +5215,7 @@ static const struct ndr_interface_call I
+ sizeof(struct DeleteAll),
+ (ndr_push_flags_fn_t) ndr_push_DeleteAll,
+ (ndr_pull_flags_fn_t) ndr_pull_DeleteAll,
+- (ndr_print_function_t) ndr_print_DeleteAll,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5963,7 +5963,7 @@ static const struct ndr_interface_call I
+ sizeof(struct EstablishPosition),
+ (ndr_push_flags_fn_t) ndr_push_EstablishPosition,
+ (ndr_pull_flags_fn_t) ndr_pull_EstablishPosition,
+- (ndr_print_function_t) ndr_print_EstablishPosition,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5972,7 +5972,7 @@ static const struct ndr_interface_call I
+ sizeof(struct RequestChallenge),
+ (ndr_push_flags_fn_t) ndr_push_RequestChallenge,
+ (ndr_pull_flags_fn_t) ndr_pull_RequestChallenge,
+- (ndr_print_function_t) ndr_print_RequestChallenge,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5981,7 +5981,7 @@ static const struct ndr_interface_call I
+ sizeof(struct WBEMLogin),
+ (ndr_push_flags_fn_t) ndr_push_WBEMLogin,
+ (ndr_pull_flags_fn_t) ndr_pull_WBEMLogin,
+- (ndr_print_function_t) ndr_print_WBEMLogin,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -5990,7 +5990,7 @@ static const struct ndr_interface_call I
+ sizeof(struct NTLMLogin),
+ (ndr_push_flags_fn_t) ndr_push_NTLMLogin,
+ (ndr_pull_flags_fn_t) ndr_pull_NTLMLogin,
+- (ndr_print_function_t) ndr_print_NTLMLogin,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -6225,7 +6225,7 @@ static const struct ndr_interface_call I
+ sizeof(struct IWbemWCOSmartEnum_Next),
+ (ndr_push_flags_fn_t) ndr_push_IWbemWCOSmartEnum_Next,
+ (ndr_pull_flags_fn_t) ndr_pull_IWbemWCOSmartEnum_Next,
+- (ndr_print_function_t) ndr_print_IWbemWCOSmartEnum_Next,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -6479,7 +6479,7 @@ static const struct ndr_interface_call I
+ sizeof(struct Fetch),
+ (ndr_push_flags_fn_t) ndr_push_Fetch,
+ (ndr_pull_flags_fn_t) ndr_pull_Fetch,
+- (ndr_print_function_t) ndr_print_Fetch,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -6488,7 +6488,7 @@ static const struct ndr_interface_call I
+ sizeof(struct Test),
+ (ndr_push_flags_fn_t) ndr_push_Test,
+ (ndr_pull_flags_fn_t) ndr_pull_Test,
+- (ndr_print_function_t) ndr_print_Test,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -6920,7 +6920,7 @@ static const struct ndr_interface_call I
+ sizeof(struct GetResultObject),
+ (ndr_push_flags_fn_t) ndr_push_GetResultObject,
+ (ndr_pull_flags_fn_t) ndr_pull_GetResultObject,
+- (ndr_print_function_t) ndr_print_GetResultObject,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -6929,7 +6929,7 @@ static const struct ndr_interface_call I
+ sizeof(struct GetResultString),
+ (ndr_push_flags_fn_t) ndr_push_GetResultString,
+ (ndr_pull_flags_fn_t) ndr_pull_GetResultString,
+- (ndr_print_function_t) ndr_print_GetResultString,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -6938,7 +6938,7 @@ static const struct ndr_interface_call I
+ sizeof(struct GetResultServices),
+ (ndr_push_flags_fn_t) ndr_push_GetResultServices,
+ (ndr_pull_flags_fn_t) ndr_pull_GetResultServices,
+- (ndr_print_function_t) ndr_print_GetResultServices,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -6947,7 +6947,7 @@ static const struct ndr_interface_call I
+ sizeof(struct GetCallStatus),
+ (ndr_push_flags_fn_t) ndr_push_GetCallStatus,
+ (ndr_pull_flags_fn_t) ndr_pull_GetCallStatus,
+- (ndr_print_function_t) ndr_print_GetCallStatus,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7211,7 +7211,7 @@ static const struct ndr_interface_call I
+ sizeof(struct SetStatus),
+ (ndr_push_flags_fn_t) ndr_push_SetStatus,
+ (ndr_pull_flags_fn_t) ndr_pull_SetStatus,
+- (ndr_print_function_t) ndr_print_SetStatus,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -7220,7 +7220,7 @@ static const struct ndr_interface_call I
+ sizeof(struct Indicate),
+ (ndr_push_flags_fn_t) ndr_push_Indicate,
+ (ndr_pull_flags_fn_t) ndr_pull_Indicate,
+- (ndr_print_function_t) ndr_print_Indicate,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_wzcsvc.c
++++ b/source3/librpc/gen_ndr/ndr_wzcsvc.c
+@@ -711,7 +711,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wzcsvc_EnumInterfaces),
+ (ndr_push_flags_fn_t) ndr_push_wzcsvc_EnumInterfaces,
+ (ndr_pull_flags_fn_t) ndr_pull_wzcsvc_EnumInterfaces,
+- (ndr_print_function_t) ndr_print_wzcsvc_EnumInterfaces,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -720,7 +720,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wzcsvc_QueryInterface),
+ (ndr_push_flags_fn_t) ndr_push_wzcsvc_QueryInterface,
+ (ndr_pull_flags_fn_t) ndr_pull_wzcsvc_QueryInterface,
+- (ndr_print_function_t) ndr_print_wzcsvc_QueryInterface,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -729,7 +729,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wzcsvc_SetInterface),
+ (ndr_push_flags_fn_t) ndr_push_wzcsvc_SetInterface,
+ (ndr_pull_flags_fn_t) ndr_pull_wzcsvc_SetInterface,
+- (ndr_print_function_t) ndr_print_wzcsvc_SetInterface,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -738,7 +738,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wzcsvc_RefreshInterface),
+ (ndr_push_flags_fn_t) ndr_push_wzcsvc_RefreshInterface,
+ (ndr_pull_flags_fn_t) ndr_pull_wzcsvc_RefreshInterface,
+- (ndr_print_function_t) ndr_print_wzcsvc_RefreshInterface,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -747,7 +747,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wzcsvc_QueryContext),
+ (ndr_push_flags_fn_t) ndr_push_wzcsvc_QueryContext,
+ (ndr_pull_flags_fn_t) ndr_pull_wzcsvc_QueryContext,
+- (ndr_print_function_t) ndr_print_wzcsvc_QueryContext,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -756,7 +756,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wzcsvc_SetContext),
+ (ndr_push_flags_fn_t) ndr_push_wzcsvc_SetContext,
+ (ndr_pull_flags_fn_t) ndr_pull_wzcsvc_SetContext,
+- (ndr_print_function_t) ndr_print_wzcsvc_SetContext,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -765,7 +765,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wzcsvc_EapolUIResponse),
+ (ndr_push_flags_fn_t) ndr_push_wzcsvc_EapolUIResponse,
+ (ndr_pull_flags_fn_t) ndr_pull_wzcsvc_EapolUIResponse,
+- (ndr_print_function_t) ndr_print_wzcsvc_EapolUIResponse,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -774,7 +774,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wzcsvc_EapolGetCustomAuthData),
+ (ndr_push_flags_fn_t) ndr_push_wzcsvc_EapolGetCustomAuthData,
+ (ndr_pull_flags_fn_t) ndr_pull_wzcsvc_EapolGetCustomAuthData,
+- (ndr_print_function_t) ndr_print_wzcsvc_EapolGetCustomAuthData,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -783,7 +783,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wzcsvc_EapolSetCustomAuthData),
+ (ndr_push_flags_fn_t) ndr_push_wzcsvc_EapolSetCustomAuthData,
+ (ndr_pull_flags_fn_t) ndr_pull_wzcsvc_EapolSetCustomAuthData,
+- (ndr_print_function_t) ndr_print_wzcsvc_EapolSetCustomAuthData,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -792,7 +792,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wzcsvc_EapolGetInterfaceParams),
+ (ndr_push_flags_fn_t) ndr_push_wzcsvc_EapolGetInterfaceParams,
+ (ndr_pull_flags_fn_t) ndr_pull_wzcsvc_EapolGetInterfaceParams,
+- (ndr_print_function_t) ndr_print_wzcsvc_EapolGetInterfaceParams,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -801,7 +801,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wzcsvc_EapolSetInterfaceParams),
+ (ndr_push_flags_fn_t) ndr_push_wzcsvc_EapolSetInterfaceParams,
+ (ndr_pull_flags_fn_t) ndr_pull_wzcsvc_EapolSetInterfaceParams,
+- (ndr_print_function_t) ndr_print_wzcsvc_EapolSetInterfaceParams,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -810,7 +810,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wzcsvc_EapolReAuthenticateInterface),
+ (ndr_push_flags_fn_t) ndr_push_wzcsvc_EapolReAuthenticateInterface,
+ (ndr_pull_flags_fn_t) ndr_pull_wzcsvc_EapolReAuthenticateInterface,
+- (ndr_print_function_t) ndr_print_wzcsvc_EapolReAuthenticateInterface,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -819,7 +819,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wzcsvc_EapolQueryInterfaceState),
+ (ndr_push_flags_fn_t) ndr_push_wzcsvc_EapolQueryInterfaceState,
+ (ndr_pull_flags_fn_t) ndr_pull_wzcsvc_EapolQueryInterfaceState,
+- (ndr_print_function_t) ndr_print_wzcsvc_EapolQueryInterfaceState,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -828,7 +828,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wzcsvc_OpenWZCDbLogSession),
+ (ndr_push_flags_fn_t) ndr_push_wzcsvc_OpenWZCDbLogSession,
+ (ndr_pull_flags_fn_t) ndr_pull_wzcsvc_OpenWZCDbLogSession,
+- (ndr_print_function_t) ndr_print_wzcsvc_OpenWZCDbLogSession,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -837,7 +837,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wzcsvc_CloseWZCDbLogSession),
+ (ndr_push_flags_fn_t) ndr_push_wzcsvc_CloseWZCDbLogSession,
+ (ndr_pull_flags_fn_t) ndr_pull_wzcsvc_CloseWZCDbLogSession,
+- (ndr_print_function_t) ndr_print_wzcsvc_CloseWZCDbLogSession,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -846,7 +846,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wzcsvc_EnumWZCDbLogRecords),
+ (ndr_push_flags_fn_t) ndr_push_wzcsvc_EnumWZCDbLogRecords,
+ (ndr_pull_flags_fn_t) ndr_pull_wzcsvc_EnumWZCDbLogRecords,
+- (ndr_print_function_t) ndr_print_wzcsvc_EnumWZCDbLogRecords,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -855,7 +855,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wzcsvc_FlushWZCdbLog),
+ (ndr_push_flags_fn_t) ndr_push_wzcsvc_FlushWZCdbLog,
+ (ndr_pull_flags_fn_t) ndr_pull_wzcsvc_FlushWZCdbLog,
+- (ndr_print_function_t) ndr_print_wzcsvc_FlushWZCdbLog,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+@@ -864,7 +864,7 @@ static const struct ndr_interface_call w
+ sizeof(struct wzcsvc_GetWZCDbLogRecord),
+ (ndr_push_flags_fn_t) ndr_push_wzcsvc_GetWZCDbLogRecord,
+ (ndr_pull_flags_fn_t) ndr_pull_wzcsvc_GetWZCDbLogRecord,
+- (ndr_print_function_t) ndr_print_wzcsvc_GetWZCDbLogRecord,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- a/source3/librpc/gen_ndr/ndr_xattr.c
++++ b/source3/librpc/gen_ndr/ndr_xattr.c
+@@ -1101,7 +1101,7 @@ static const struct ndr_interface_call x
+ sizeof(struct xattr_parse_DOSATTRIB),
+ (ndr_push_flags_fn_t) ndr_push_xattr_parse_DOSATTRIB,
+ (ndr_pull_flags_fn_t) ndr_pull_xattr_parse_DOSATTRIB,
+- (ndr_print_function_t) ndr_print_xattr_parse_DOSATTRIB,
++ (ndr_print_function_t) ndr_print_disabled,
+ { 0, NULL },
+ { 0, NULL },
+ },
+--- /dev/null
++++ b/source3/remove-librpc-print-calls.sh
+@@ -0,0 +1,22 @@
++#!/usr/bin/env bash
++set -e
++for file in ${1:-librpc/gen_ndr/ndr_*.c}; do
++ quilt add "$file" || true
++ awk '
++$0 ~ /^static const struct ndr_interface_call .* = {$/ {
++ replace = 1
++}
++
++$0 ~ /^}$/ {
++ replace = 0;
++}
++
++replace == 1 {
++ gsub(/.ndr_print_function_t. .*,/, "(ndr_print_function_t) ndr_print_disabled,", $0)
++}
++{
++ print $0
++}
++ ' < "$file" > "$file.new"
++ mv "$file.new" "$file"
++done
+--- a/librpc/ndr/libndr.h
++++ b/librpc/ndr/libndr.h
+@@ -603,6 +603,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_enum
+ _PUBLIC_ enum ndr_err_code ndr_push_enum_uint1632(struct ndr_push *ndr, int ndr_flags, uint16_t v);
+
+ _PUBLIC_ void ndr_print_bool(struct ndr_print *ndr, const char *name, const bool b);
++_PUBLIC_ void ndr_print_disabled(struct ndr_print *ndr, const char *name, int flags, void *r);
+
+ #ifndef VERBOSE_ERROR
+ #define ndr_print_bool(...) do {} while (0)
diff --git a/package/network/services/uhttpd/.svn/entries b/package/network/services/uhttpd/.svn/entries
new file mode 100644
index 0000000..163f519
--- /dev/null
+++ b/package/network/services/uhttpd/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/services/uhttpd
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-15T13:43:55.120823Z
+36034
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+files
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+29a7640ab8783fe85214d4b940740643
+2013-03-15T13:43:55.120823Z
+36034
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3287
+
diff --git a/package/network/services/uhttpd/.svn/text-base/Makefile.svn-base b/package/network/services/uhttpd/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..d54c0ad
--- /dev/null
+++ b/package/network/services/uhttpd/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,134 @@
+#
+# Copyright (C) 2010-2012 Jo-Philipp Wich <jow@openwrt.org>
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=uhttpd
+PKG_VERSION:=2013-03-15
+PKG_RELEASE=$(PKG_SOURCE_VERSION)
+
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL:=git://nbd.name/uhttpd2.git
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE_VERSION:=3675d407ecf4908a231eb6bde6bb6408f20a9e81
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+
+PKG_BUILD_DEPENDS = ustream-ssl
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/cmake.mk
+
+define Package/uhttpd/default
+ SECTION:=net
+ CATEGORY:=Network
+ SUBMENU:=Web Servers/Proxies
+ TITLE:=uHTTPd - tiny, single threaded HTTP server
+endef
+
+define Package/uhttpd
+ $(Package/uhttpd/default)
+ DEPENDS:=+libubox
+endef
+
+define Package/uhttpd/description
+ uHTTPd is a tiny single threaded HTTP server with TLS, CGI and Lua
+ support. It is intended as a drop-in replacement for the Busybox
+ HTTP daemon.
+endef
+
+define Package/uhttpd/config
+ config PACKAGE_uhttpd_debug
+ bool "Build with debug messages"
+ default n
+endef
+
+
+define Package/uhttpd-mod-tls
+ $(Package/uhttpd/default)
+ TITLE+= (TLS plugin)
+ DEPENDS:=uhttpd +PACKAGE_uhttpd-mod-tls_cyassl:libustream-cyassl +PACKAGE_uhttpd-mod-tls_openssl:libustream-openssl
+endef
+
+define Package/uhttpd-mod-tls/description
+ The TLS plugin adds HTTPS support to uHTTPd.
+endef
+
+define Package/uhttpd-mod-tls/config
+ choice
+ depends on PACKAGE_uhttpd-mod-tls
+ prompt "TLS Provider"
+ default PACKAGE_uhttpd-mod-tls_cyassl
+
+ config PACKAGE_uhttpd-mod-tls_cyassl
+ bool "CyaSSL"
+
+ config PACKAGE_uhttpd-mod-tls_openssl
+ bool "OpenSSL"
+ endchoice
+endef
+
+define Package/uhttpd-mod-lua
+ $(Package/uhttpd/default)
+ TITLE+= (Lua plugin)
+ DEPENDS:=uhttpd +liblua
+endef
+
+define Package/uhttpd-mod-lua/description
+ The Lua plugin adds a CGI-like Lua runtime interface to uHTTPd.
+endef
+
+
+define Package/uhttpd-mod-ubus
+ $(Package/uhttpd/default)
+ TITLE+= (ubus plugin)
+ DEPENDS:=uhttpd +libubus +libblobmsg-json
+endef
+
+define Package/uhttpd-mod-ubus/description
+ The ubus plugin adds a HTTP/JSON RPC proxy for ubus and publishes the
+ session.* namespace and procedures.
+endef
+
+define Package/uhttpd/conffiles
+/etc/config/uhttpd
+/etc/uhttpd.crt
+/etc/uhttpd.key
+endef
+
+TARGET_LDFLAGS += -lcrypt
+
+CMAKE_OPTIONS = -DTLS_SUPPORT=on
+
+define Package/uhttpd/install
+ $(INSTALL_DIR) $(1)/etc/init.d
+ $(INSTALL_BIN) ./files/uhttpd.init $(1)/etc/init.d/uhttpd
+ $(INSTALL_DIR) $(1)/etc/config
+ $(INSTALL_CONF) ./files/uhttpd.config $(1)/etc/config/uhttpd
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/uhttpd $(1)/usr/sbin/uhttpd
+endef
+
+define Package/uhttpd-mod-tls/install
+ true
+endef
+
+define Package/uhttpd-mod-lua/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/uhttpd_lua.so $(1)/usr/lib/
+endef
+
+define Package/uhttpd-mod-ubus/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/uhttpd_ubus.so $(1)/usr/lib/
+endef
+
+
+$(eval $(call BuildPackage,uhttpd))
+$(eval $(call BuildPackage,uhttpd-mod-tls))
+$(eval $(call BuildPackage,uhttpd-mod-lua))
+$(eval $(call BuildPackage,uhttpd-mod-ubus))
diff --git a/package/network/services/uhttpd/Makefile b/package/network/services/uhttpd/Makefile
new file mode 100644
index 0000000..d54c0ad
--- /dev/null
+++ b/package/network/services/uhttpd/Makefile
@@ -0,0 +1,134 @@
+#
+# Copyright (C) 2010-2012 Jo-Philipp Wich <jow@openwrt.org>
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=uhttpd
+PKG_VERSION:=2013-03-15
+PKG_RELEASE=$(PKG_SOURCE_VERSION)
+
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL:=git://nbd.name/uhttpd2.git
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE_VERSION:=3675d407ecf4908a231eb6bde6bb6408f20a9e81
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+
+PKG_BUILD_DEPENDS = ustream-ssl
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/cmake.mk
+
+define Package/uhttpd/default
+ SECTION:=net
+ CATEGORY:=Network
+ SUBMENU:=Web Servers/Proxies
+ TITLE:=uHTTPd - tiny, single threaded HTTP server
+endef
+
+define Package/uhttpd
+ $(Package/uhttpd/default)
+ DEPENDS:=+libubox
+endef
+
+define Package/uhttpd/description
+ uHTTPd is a tiny single threaded HTTP server with TLS, CGI and Lua
+ support. It is intended as a drop-in replacement for the Busybox
+ HTTP daemon.
+endef
+
+define Package/uhttpd/config
+ config PACKAGE_uhttpd_debug
+ bool "Build with debug messages"
+ default n
+endef
+
+
+define Package/uhttpd-mod-tls
+ $(Package/uhttpd/default)
+ TITLE+= (TLS plugin)
+ DEPENDS:=uhttpd +PACKAGE_uhttpd-mod-tls_cyassl:libustream-cyassl +PACKAGE_uhttpd-mod-tls_openssl:libustream-openssl
+endef
+
+define Package/uhttpd-mod-tls/description
+ The TLS plugin adds HTTPS support to uHTTPd.
+endef
+
+define Package/uhttpd-mod-tls/config
+ choice
+ depends on PACKAGE_uhttpd-mod-tls
+ prompt "TLS Provider"
+ default PACKAGE_uhttpd-mod-tls_cyassl
+
+ config PACKAGE_uhttpd-mod-tls_cyassl
+ bool "CyaSSL"
+
+ config PACKAGE_uhttpd-mod-tls_openssl
+ bool "OpenSSL"
+ endchoice
+endef
+
+define Package/uhttpd-mod-lua
+ $(Package/uhttpd/default)
+ TITLE+= (Lua plugin)
+ DEPENDS:=uhttpd +liblua
+endef
+
+define Package/uhttpd-mod-lua/description
+ The Lua plugin adds a CGI-like Lua runtime interface to uHTTPd.
+endef
+
+
+define Package/uhttpd-mod-ubus
+ $(Package/uhttpd/default)
+ TITLE+= (ubus plugin)
+ DEPENDS:=uhttpd +libubus +libblobmsg-json
+endef
+
+define Package/uhttpd-mod-ubus/description
+ The ubus plugin adds a HTTP/JSON RPC proxy for ubus and publishes the
+ session.* namespace and procedures.
+endef
+
+define Package/uhttpd/conffiles
+/etc/config/uhttpd
+/etc/uhttpd.crt
+/etc/uhttpd.key
+endef
+
+TARGET_LDFLAGS += -lcrypt
+
+CMAKE_OPTIONS = -DTLS_SUPPORT=on
+
+define Package/uhttpd/install
+ $(INSTALL_DIR) $(1)/etc/init.d
+ $(INSTALL_BIN) ./files/uhttpd.init $(1)/etc/init.d/uhttpd
+ $(INSTALL_DIR) $(1)/etc/config
+ $(INSTALL_CONF) ./files/uhttpd.config $(1)/etc/config/uhttpd
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/uhttpd $(1)/usr/sbin/uhttpd
+endef
+
+define Package/uhttpd-mod-tls/install
+ true
+endef
+
+define Package/uhttpd-mod-lua/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/uhttpd_lua.so $(1)/usr/lib/
+endef
+
+define Package/uhttpd-mod-ubus/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/uhttpd_ubus.so $(1)/usr/lib/
+endef
+
+
+$(eval $(call BuildPackage,uhttpd))
+$(eval $(call BuildPackage,uhttpd-mod-tls))
+$(eval $(call BuildPackage,uhttpd-mod-lua))
+$(eval $(call BuildPackage,uhttpd-mod-ubus))
diff --git a/package/network/services/uhttpd/files/.svn/entries b/package/network/services/uhttpd/files/.svn/entries
new file mode 100644
index 0000000..cc78373
--- /dev/null
+++ b/package/network/services/uhttpd/files/.svn/entries
@@ -0,0 +1,96 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/services/uhttpd/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-15T18:19:57.225392Z
+33778
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+uhttpd.init
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+1730772e355cb82fed13646b19e1dd13
+2012-10-15T18:19:57.225392Z
+33778
+jow
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3130
+
+uhttpd.config
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+17e6f94bf1e87b33b1b4558cbf96e723
+2012-05-28T00:52:24.979087Z
+31931
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2407
+
diff --git a/package/network/services/uhttpd/files/.svn/prop-base/uhttpd.init.svn-base b/package/network/services/uhttpd/files/.svn/prop-base/uhttpd.init.svn-base
new file mode 100644
index 0000000..869ac71
--- /dev/null
+++ b/package/network/services/uhttpd/files/.svn/prop-base/uhttpd.init.svn-base
@@ -0,0 +1,5 @@
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/network/services/uhttpd/files/.svn/text-base/uhttpd.config.svn-base b/package/network/services/uhttpd/files/.svn/text-base/uhttpd.config.svn-base
new file mode 100644
index 0000000..b33411e
--- /dev/null
+++ b/package/network/services/uhttpd/files/.svn/text-base/uhttpd.config.svn-base
@@ -0,0 +1,89 @@
+# Server configuration
+config uhttpd main
+
+ # HTTP listen addresses, multiple allowed
+ list listen_http 0.0.0.0:80
+# list listen_http [::]:80
+
+ # HTTPS listen addresses, multiple allowed
+ list listen_https 0.0.0.0:443
+# list listen_https [::]:443
+
+ # Server document root
+ option home /www
+
+ # Reject requests from RFC1918 IP addresses
+ # directed to the servers public IP(s).
+ # This is a DNS rebinding countermeasure.
+ option rfc1918_filter 1
+
+ # Maximum number of concurrent requests.
+ # If this number is exceeded, further requests are
+ # queued until the number of running requests drops
+ # below the limit again.
+ option max_requests 3
+
+ # Certificate and private key for HTTPS.
+ # If no listen_https addresses are given,
+ # the key options are ignored.
+ option cert /etc/uhttpd.crt
+ option key /etc/uhttpd.key
+
+ # CGI url prefix, will be searched in docroot.
+ # Default is /cgi-bin
+ option cgi_prefix /cgi-bin
+
+ # List of extension->interpreter mappings.
+ # Files with an associated interpreter can
+ # be called outside of the CGI prefix and do
+ # not need to be executable.
+# list interpreter ".php=/usr/bin/php-cgi"
+# list interpreter ".cgi=/usr/bin/perl"
+
+ # Lua url prefix and handler script.
+ # Lua support is disabled if no prefix given.
+# option lua_prefix /luci
+# option lua_handler /usr/lib/lua/luci/sgi/uhttpd.lua
+
+ # CGI/Lua timeout, if the called script does not
+ # write data within the given amount of seconds,
+ # the server will terminate the request with
+ # 504 Gateway Timeout response.
+ option script_timeout 60
+
+ # Network timeout, if the current connection is
+ # blocked for the specified amount of seconds,
+ # the server will terminate the associated
+ # request process.
+ option network_timeout 30
+
+ # TCP Keep-Alive, send periodic keep-alive probes
+ # over established connections to detect dead peers.
+ # The value is given in seconds to specify the
+ # interval between subsequent probes.
+ # Setting this to 0 will disable TCP keep-alive.
+ option tcp_keepalive 1
+
+ # Basic auth realm, defaults to local hostname
+# option realm OpenWrt
+
+ # Configuration file in busybox httpd format
+# option config /etc/httpd.conf
+
+
+# Certificate defaults for px5g key generator
+config cert px5g
+
+ # Validity time
+ option days 730
+
+ # RSA key size
+ option bits 1024
+
+ # Location
+ option country DE
+ option state Berlin
+ option location Berlin
+
+ # Common name
+ option commonname OpenWrt
diff --git a/package/network/services/uhttpd/files/.svn/text-base/uhttpd.init.svn-base b/package/network/services/uhttpd/files/.svn/text-base/uhttpd.init.svn-base
new file mode 100644
index 0000000..ad46d2c
--- /dev/null
+++ b/package/network/services/uhttpd/files/.svn/text-base/uhttpd.init.svn-base
@@ -0,0 +1,139 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2010 Jo-Philipp Wich
+
+START=50
+
+SERVICE_DAEMONIZE=1
+SERVICE_WRITE_PID=1
+
+UHTTPD_BIN="/usr/sbin/uhttpd"
+PX5G_BIN="/usr/sbin/px5g"
+
+append_arg() {
+ local cfg="$1"
+ local var="$2"
+ local opt="$3"
+ local def="$4"
+ local val
+
+ config_get val "$cfg" "$var"
+ [ -n "$val" -o -n "$def" ] && append UHTTPD_ARGS "$opt ${val:-$def}"
+}
+
+append_bool() {
+ local cfg="$1"
+ local var="$2"
+ local opt="$3"
+ local def="$4"
+ local val
+
+ config_get_bool val "$cfg" "$var" "$def"
+ [ "$val" = 1 ] && append UHTTPD_ARGS "$opt"
+}
+
+generate_keys() {
+ local cfg="$1"
+ local key="$2"
+ local crt="$3"
+ local days bits country state location commonname
+
+ config_get days "$cfg" days
+ config_get bits "$cfg" bits
+ config_get country "$cfg" country
+ config_get state "$cfg" state
+ config_get location "$cfg" location
+ config_get commonname "$cfg" commonname
+
+ [ -x "$PX5G_BIN" ] && {
+ $PX5G_BIN selfsigned -der \
+ -days ${days:-730} -newkey rsa:${bits:-1024} -keyout "$UHTTPD_KEY" -out "$UHTTPD_CERT" \
+ -subj /C="${country:-DE}"/ST="${state:-Saxony}"/L="${location:-Leipzig}"/CN="${commonname:-OpenWrt}"
+ }
+}
+
+start_instance()
+{
+ UHTTPD_ARGS=""
+ UHTTPD_CERT=""
+ UHTTPD_KEY=""
+
+ local cfg="$1"
+ local realm="$(uci_get system.@system[0].hostname)"
+ local listen http https interpreter indexes path
+
+ append_arg "$cfg" home "-h"
+ append_arg "$cfg" realm "-r" "${realm:-OpenWrt}"
+ append_arg "$cfg" config "-c"
+ append_arg "$cfg" cgi_prefix "-x"
+ append_arg "$cfg" lua_prefix "-l"
+ append_arg "$cfg" lua_handler "-L"
+ append_arg "$cfg" script_timeout "-t"
+ append_arg "$cfg" network_timeout "-T"
+ append_arg "$cfg" tcp_keepalive "-A"
+ append_arg "$cfg" error_page "-E"
+ append_arg "$cfg" max_requests "-n" 3
+
+ append_bool "$cfg" no_symlinks "-S" 0
+ append_bool "$cfg" no_dirlists "-D" 0
+ append_bool "$cfg" rfc1918_filter "-R" 0
+
+ config_get http "$cfg" listen_http
+ for listen in $http; do
+ append UHTTPD_ARGS "-p $listen"
+ done
+
+ config_get interpreter "$cfg" interpreter
+ for path in $interpreter; do
+ append UHTTPD_ARGS "-i $path"
+ done
+
+ config_get indexes "$cfg" index_page
+ for path in $indexes; do
+ append UHTTPD_ARGS "-I $path"
+ done
+
+ config_get https "$cfg" listen_https
+ config_get UHTTPD_KEY "$cfg" key /etc/uhttpd.key
+ config_get UHTTPD_CERT "$cfg" cert /etc/uhttpd.crt
+
+ [ -n "$https" ] && {
+ [ -f "$UHTTPD_CERT" -a -f "$UHTTPD_KEY" ] || {
+ config_foreach generate_keys cert
+ }
+
+ [ -f "$UHTTPD_CERT" -a -f "$UHTTPD_KEY" ] && {
+ append_arg "$cfg" cert "-C"
+ append_arg "$cfg" key "-K"
+
+ for listen in $https; do
+ append UHTTPD_ARGS "-s $listen"
+ done
+ }
+ }
+
+ SERVICE_PID_FILE=/var/run/uhttpd_${cfg}.pid
+ service_start $UHTTPD_BIN -f $UHTTPD_ARGS
+
+ # Check if daemon is running, if not then
+ # re-execute in foreground to display error.
+ sleep 1 && service_check $UHTTPD_BIN || \
+ $UHTTPD_BIN -f $UHTTPD_ARGS
+}
+
+stop_instance()
+{
+ local cfg="$1"
+
+ SERVICE_PID_FILE=/var/run/uhttpd_${cfg}.pid
+ service_stop $UHTTPD_BIN
+}
+
+start() {
+ config_load uhttpd
+ config_foreach start_instance uhttpd
+}
+
+stop() {
+ config_load uhttpd
+ config_foreach stop_instance uhttpd
+}
diff --git a/package/network/services/uhttpd/files/uhttpd.config b/package/network/services/uhttpd/files/uhttpd.config
new file mode 100644
index 0000000..b33411e
--- /dev/null
+++ b/package/network/services/uhttpd/files/uhttpd.config
@@ -0,0 +1,89 @@
+# Server configuration
+config uhttpd main
+
+ # HTTP listen addresses, multiple allowed
+ list listen_http 0.0.0.0:80
+# list listen_http [::]:80
+
+ # HTTPS listen addresses, multiple allowed
+ list listen_https 0.0.0.0:443
+# list listen_https [::]:443
+
+ # Server document root
+ option home /www
+
+ # Reject requests from RFC1918 IP addresses
+ # directed to the servers public IP(s).
+ # This is a DNS rebinding countermeasure.
+ option rfc1918_filter 1
+
+ # Maximum number of concurrent requests.
+ # If this number is exceeded, further requests are
+ # queued until the number of running requests drops
+ # below the limit again.
+ option max_requests 3
+
+ # Certificate and private key for HTTPS.
+ # If no listen_https addresses are given,
+ # the key options are ignored.
+ option cert /etc/uhttpd.crt
+ option key /etc/uhttpd.key
+
+ # CGI url prefix, will be searched in docroot.
+ # Default is /cgi-bin
+ option cgi_prefix /cgi-bin
+
+ # List of extension->interpreter mappings.
+ # Files with an associated interpreter can
+ # be called outside of the CGI prefix and do
+ # not need to be executable.
+# list interpreter ".php=/usr/bin/php-cgi"
+# list interpreter ".cgi=/usr/bin/perl"
+
+ # Lua url prefix and handler script.
+ # Lua support is disabled if no prefix given.
+# option lua_prefix /luci
+# option lua_handler /usr/lib/lua/luci/sgi/uhttpd.lua
+
+ # CGI/Lua timeout, if the called script does not
+ # write data within the given amount of seconds,
+ # the server will terminate the request with
+ # 504 Gateway Timeout response.
+ option script_timeout 60
+
+ # Network timeout, if the current connection is
+ # blocked for the specified amount of seconds,
+ # the server will terminate the associated
+ # request process.
+ option network_timeout 30
+
+ # TCP Keep-Alive, send periodic keep-alive probes
+ # over established connections to detect dead peers.
+ # The value is given in seconds to specify the
+ # interval between subsequent probes.
+ # Setting this to 0 will disable TCP keep-alive.
+ option tcp_keepalive 1
+
+ # Basic auth realm, defaults to local hostname
+# option realm OpenWrt
+
+ # Configuration file in busybox httpd format
+# option config /etc/httpd.conf
+
+
+# Certificate defaults for px5g key generator
+config cert px5g
+
+ # Validity time
+ option days 730
+
+ # RSA key size
+ option bits 1024
+
+ # Location
+ option country DE
+ option state Berlin
+ option location Berlin
+
+ # Common name
+ option commonname OpenWrt
diff --git a/package/network/services/uhttpd/files/uhttpd.init b/package/network/services/uhttpd/files/uhttpd.init
new file mode 100755
index 0000000..ad46d2c
--- /dev/null
+++ b/package/network/services/uhttpd/files/uhttpd.init
@@ -0,0 +1,139 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2010 Jo-Philipp Wich
+
+START=50
+
+SERVICE_DAEMONIZE=1
+SERVICE_WRITE_PID=1
+
+UHTTPD_BIN="/usr/sbin/uhttpd"
+PX5G_BIN="/usr/sbin/px5g"
+
+append_arg() {
+ local cfg="$1"
+ local var="$2"
+ local opt="$3"
+ local def="$4"
+ local val
+
+ config_get val "$cfg" "$var"
+ [ -n "$val" -o -n "$def" ] && append UHTTPD_ARGS "$opt ${val:-$def}"
+}
+
+append_bool() {
+ local cfg="$1"
+ local var="$2"
+ local opt="$3"
+ local def="$4"
+ local val
+
+ config_get_bool val "$cfg" "$var" "$def"
+ [ "$val" = 1 ] && append UHTTPD_ARGS "$opt"
+}
+
+generate_keys() {
+ local cfg="$1"
+ local key="$2"
+ local crt="$3"
+ local days bits country state location commonname
+
+ config_get days "$cfg" days
+ config_get bits "$cfg" bits
+ config_get country "$cfg" country
+ config_get state "$cfg" state
+ config_get location "$cfg" location
+ config_get commonname "$cfg" commonname
+
+ [ -x "$PX5G_BIN" ] && {
+ $PX5G_BIN selfsigned -der \
+ -days ${days:-730} -newkey rsa:${bits:-1024} -keyout "$UHTTPD_KEY" -out "$UHTTPD_CERT" \
+ -subj /C="${country:-DE}"/ST="${state:-Saxony}"/L="${location:-Leipzig}"/CN="${commonname:-OpenWrt}"
+ }
+}
+
+start_instance()
+{
+ UHTTPD_ARGS=""
+ UHTTPD_CERT=""
+ UHTTPD_KEY=""
+
+ local cfg="$1"
+ local realm="$(uci_get system.@system[0].hostname)"
+ local listen http https interpreter indexes path
+
+ append_arg "$cfg" home "-h"
+ append_arg "$cfg" realm "-r" "${realm:-OpenWrt}"
+ append_arg "$cfg" config "-c"
+ append_arg "$cfg" cgi_prefix "-x"
+ append_arg "$cfg" lua_prefix "-l"
+ append_arg "$cfg" lua_handler "-L"
+ append_arg "$cfg" script_timeout "-t"
+ append_arg "$cfg" network_timeout "-T"
+ append_arg "$cfg" tcp_keepalive "-A"
+ append_arg "$cfg" error_page "-E"
+ append_arg "$cfg" max_requests "-n" 3
+
+ append_bool "$cfg" no_symlinks "-S" 0
+ append_bool "$cfg" no_dirlists "-D" 0
+ append_bool "$cfg" rfc1918_filter "-R" 0
+
+ config_get http "$cfg" listen_http
+ for listen in $http; do
+ append UHTTPD_ARGS "-p $listen"
+ done
+
+ config_get interpreter "$cfg" interpreter
+ for path in $interpreter; do
+ append UHTTPD_ARGS "-i $path"
+ done
+
+ config_get indexes "$cfg" index_page
+ for path in $indexes; do
+ append UHTTPD_ARGS "-I $path"
+ done
+
+ config_get https "$cfg" listen_https
+ config_get UHTTPD_KEY "$cfg" key /etc/uhttpd.key
+ config_get UHTTPD_CERT "$cfg" cert /etc/uhttpd.crt
+
+ [ -n "$https" ] && {
+ [ -f "$UHTTPD_CERT" -a -f "$UHTTPD_KEY" ] || {
+ config_foreach generate_keys cert
+ }
+
+ [ -f "$UHTTPD_CERT" -a -f "$UHTTPD_KEY" ] && {
+ append_arg "$cfg" cert "-C"
+ append_arg "$cfg" key "-K"
+
+ for listen in $https; do
+ append UHTTPD_ARGS "-s $listen"
+ done
+ }
+ }
+
+ SERVICE_PID_FILE=/var/run/uhttpd_${cfg}.pid
+ service_start $UHTTPD_BIN -f $UHTTPD_ARGS
+
+ # Check if daemon is running, if not then
+ # re-execute in foreground to display error.
+ sleep 1 && service_check $UHTTPD_BIN || \
+ $UHTTPD_BIN -f $UHTTPD_ARGS
+}
+
+stop_instance()
+{
+ local cfg="$1"
+
+ SERVICE_PID_FILE=/var/run/uhttpd_${cfg}.pid
+ service_stop $UHTTPD_BIN
+}
+
+start() {
+ config_load uhttpd
+ config_foreach start_instance uhttpd
+}
+
+stop() {
+ config_load uhttpd
+ config_foreach stop_instance uhttpd
+}
diff --git a/package/network/utils/.svn/entries b/package/network/utils/.svn/entries
new file mode 100644
index 0000000..fa712f4
--- /dev/null
+++ b/package/network/utils/.svn/entries
@@ -0,0 +1,94 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/utils
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-07T08:48:41.905197Z
+35898
+cyrus
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+iw
+dir
+
+conntrack-tools
+dir
+
+ebtables
+dir
+
+iftop
+dir
+
+maccalc
+dir
+
+ipset
+dir
+
+rssileds
+dir
+
+iputils
+dir
+
+wireless-tools
+dir
+
+dante
+dir
+
+iwinfo
+dir
+
+owipcalc
+dir
+
+iwcap
+dir
+
+iptables
+dir
+
+iperf
+dir
+
+resolveip
+dir
+
+xtables-addons
+dir
+
+iproute2
+dir
+
+comgt
+dir
+
+ifenslave
+dir
+
+tcpdump
+dir
+
+arptables
+dir
+
diff --git a/package/network/utils/arptables/.svn/entries b/package/network/utils/arptables/.svn/entries
new file mode 100644
index 0000000..5950cff
--- /dev/null
+++ b/package/network/utils/arptables/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/utils/arptables
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-10T12:32:29.935169Z
+33688
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+dc62b396d13ca622b580450d412fe3bc
+2011-03-12T01:24:18.974350Z
+26056
+cshore
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+954
+
diff --git a/package/network/utils/arptables/.svn/prop-base/Makefile.svn-base b/package/network/utils/arptables/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..8e522ae
--- /dev/null
+++ b/package/network/utils/arptables/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:copyright
+V 30
+Copyright (C) 2006 OpenWrt.org
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/utils/arptables/.svn/text-base/Makefile.svn-base b/package/network/utils/arptables/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..9d61813
--- /dev/null
+++ b/package/network/utils/arptables/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,42 @@
+# Copyright (C) 2006-2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=arptables
+PKG_VERSION:=0.0.3-4
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-v$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=@SF/ebtables
+PKG_MD5SUM:=1d4ab05761f063b0751645d8f2b8f8e5
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-v$(PKG_VERSION)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/arptables
+ SECTION:=net
+ CATEGORY:=Network
+ SUBMENU:=Firewall
+ TITLE:=ARP firewalling software
+ DEPENDS:=+kmod-arptables
+ URL:=http://ebtables.sourceforge.net
+endef
+
+define Build/Compile
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ $(TARGET_CONFIGURE_OPTS) \
+ COPT_FLAGS="$(TARGET_CFLAGS)" \
+ KERNEL_DIR="./include/linux"
+endef
+
+define Package/arptables/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(CP) $(PKG_BUILD_DIR)/$(PKG_NAME) $(1)/usr/sbin/
+endef
+
+$(eval $(call BuildPackage,arptables))
diff --git a/package/network/utils/arptables/Makefile b/package/network/utils/arptables/Makefile
new file mode 100644
index 0000000..9d61813
--- /dev/null
+++ b/package/network/utils/arptables/Makefile
@@ -0,0 +1,42 @@
+# Copyright (C) 2006-2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=arptables
+PKG_VERSION:=0.0.3-4
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-v$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=@SF/ebtables
+PKG_MD5SUM:=1d4ab05761f063b0751645d8f2b8f8e5
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-v$(PKG_VERSION)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/arptables
+ SECTION:=net
+ CATEGORY:=Network
+ SUBMENU:=Firewall
+ TITLE:=ARP firewalling software
+ DEPENDS:=+kmod-arptables
+ URL:=http://ebtables.sourceforge.net
+endef
+
+define Build/Compile
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ $(TARGET_CONFIGURE_OPTS) \
+ COPT_FLAGS="$(TARGET_CFLAGS)" \
+ KERNEL_DIR="./include/linux"
+endef
+
+define Package/arptables/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(CP) $(PKG_BUILD_DIR)/$(PKG_NAME) $(1)/usr/sbin/
+endef
+
+$(eval $(call BuildPackage,arptables))
diff --git a/package/network/utils/arptables/patches/.svn/entries b/package/network/utils/arptables/patches/.svn/entries
new file mode 100644
index 0000000..ffb0caf
--- /dev/null
+++ b/package/network/utils/arptables/patches/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/utils/arptables/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-08-14T10:13:39.321288Z
+33179
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+100-always_optimize.patch
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+80c0e21e7b5649f42e7e0da2bf67a88b
+2012-08-14T10:13:39.321288Z
+33179
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+596
+
diff --git a/package/network/utils/arptables/patches/.svn/text-base/100-always_optimize.patch.svn-base b/package/network/utils/arptables/patches/.svn/text-base/100-always_optimize.patch.svn-base
new file mode 100644
index 0000000..b120eb7
--- /dev/null
+++ b/package/network/utils/arptables/patches/.svn/text-base/100-always_optimize.patch.svn-base
@@ -0,0 +1,19 @@
+Index: arptables-v0.0.3-4/libarptc/libarptc_incl.c
+===================================================================
+--- arptables-v0.0.3-4.orig/libarptc/libarptc_incl.c 2010-03-08 16:49:28.000000000 +0100
++++ arptables-v0.0.3-4/libarptc/libarptc_incl.c 2012-08-14 12:10:29.527945144 +0200
+@@ -11,14 +11,6 @@
+ /* (C)1999 Paul ``Rusty'' Russell - Placed under the GNU GPL (See
+ COPYING for details). */
+
+-#ifndef __OPTIMIZE__
+-STRUCT_ENTRY_TARGET *
+-GET_TARGET(STRUCT_ENTRY *e)
+-{
+- return (void *)e + e->target_offset;
+-}
+-#endif
+-
+ static int sockfd = -1;
+ static void *arptc_fn = NULL;
+
diff --git a/package/network/utils/arptables/patches/100-always_optimize.patch b/package/network/utils/arptables/patches/100-always_optimize.patch
new file mode 100644
index 0000000..b120eb7
--- /dev/null
+++ b/package/network/utils/arptables/patches/100-always_optimize.patch
@@ -0,0 +1,19 @@
+Index: arptables-v0.0.3-4/libarptc/libarptc_incl.c
+===================================================================
+--- arptables-v0.0.3-4.orig/libarptc/libarptc_incl.c 2010-03-08 16:49:28.000000000 +0100
++++ arptables-v0.0.3-4/libarptc/libarptc_incl.c 2012-08-14 12:10:29.527945144 +0200
+@@ -11,14 +11,6 @@
+ /* (C)1999 Paul ``Rusty'' Russell - Placed under the GNU GPL (See
+ COPYING for details). */
+
+-#ifndef __OPTIMIZE__
+-STRUCT_ENTRY_TARGET *
+-GET_TARGET(STRUCT_ENTRY *e)
+-{
+- return (void *)e + e->target_offset;
+-}
+-#endif
+-
+ static int sockfd = -1;
+ static void *arptc_fn = NULL;
+
diff --git a/package/network/utils/comgt/.svn/entries b/package/network/utils/comgt/.svn/entries
new file mode 100644
index 0000000..e7b8c40
--- /dev/null
+++ b/package/network/utils/comgt/.svn/entries
@@ -0,0 +1,68 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/utils/comgt
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-10T12:49:37.020840Z
+33693
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+files
+dir
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+6be6451320ad90b6860a738a8e7d12a8
+2012-10-10T12:49:37.020840Z
+33693
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2057
+
diff --git a/package/network/utils/comgt/.svn/prop-base/Makefile.svn-base b/package/network/utils/comgt/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..9f2b642
--- /dev/null
+++ b/package/network/utils/comgt/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,357 @@
+K 9
+copyright
+V 30
+Copyright (C) 2006 OpenWrt.org
+K 7
+licence
+V 17992
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ 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 of the License, 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; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
+
+K 13
+svn:copyright
+V 30
+Copyright (C) 2006 OpenWrt.org
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/utils/comgt/.svn/text-base/Makefile.svn-base b/package/network/utils/comgt/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..5324903
--- /dev/null
+++ b/package/network/utils/comgt/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,67 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=comgt
+PKG_VERSION:=0.32
+PKG_RELEASE:=21
+
+PKG_SOURCE:=$(PKG_NAME).$(PKG_VERSION).tgz
+PKG_SOURCE_URL:=@SF/comgt
+PKG_MD5SUM:=db2452680c3d953631299e331daf49ef
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME).$(PKG_VERSION)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/comgt
+ SECTION:=utils
+ CATEGORY:=Utilities
+ TITLE:=Option/Vodafone 3G/GPRS control tool
+ DEPENDS:=+chat
+ URL:=http://www.pharscape.org/comgt.html
+endef
+
+define Package/comgt/description
+ comgt is a scripting language interpreter useful for establishing
+ communications on serial lines and through PCMCIA modems as well as GPRS
+ and 3G datacards.
+endef
+
+define Build/Compile
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ $(TARGET_CONFIGURE_OPTS) \
+ CFLAGS="$(TARGET_CFLAGS)" \
+ LDFLAGS="" \
+ comgt
+endef
+
+define Package/comgt/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/comgt $(1)/usr/bin/
+ ln -s comgt $(1)/usr/bin/gcom
+ $(INSTALL_DIR) $(1)/etc/chatscripts
+ $(INSTALL_DATA) ./files/3g.chat $(1)/etc/chatscripts/3g.chat
+ $(INSTALL_DATA) ./files/evdo.chat $(1)/etc/chatscripts/evdo.chat
+ $(INSTALL_DIR) $(1)/etc/gcom
+ $(INSTALL_DATA) ./files/setpin.gcom $(1)/etc/gcom/setpin.gcom
+ $(INSTALL_DATA) ./files/setmode.gcom $(1)/etc/gcom/setmode.gcom
+ $(INSTALL_DATA) ./files/getcardinfo.gcom $(1)/etc/gcom/getcardinfo.gcom
+ $(INSTALL_DATA) ./files/getstrength.gcom $(1)/etc/gcom/getstrength.gcom
+ $(INSTALL_DATA) ./files/getcarrier.gcom $(1)/etc/gcom/getcarrier.gcom
+ $(INSTALL_DATA) ./files/getcnum.gcom $(1)/etc/gcom/getcnum.gcom
+ $(INSTALL_DATA) ./files/getimsi.gcom $(1)/etc/gcom/getimsi.gcom
+ $(INSTALL_DIR) $(1)/etc/hotplug.d/tty
+ $(INSTALL_DATA) ./files/3g.usb $(1)/etc/hotplug.d/tty/30-3g
+ $(INSTALL_DIR) $(1)/lib/netifd/proto
+ $(INSTALL_BIN) ./files/3g.sh $(1)/lib/netifd/proto/3g.sh
+endef
+
+$(eval $(call BuildPackage,comgt))
diff --git a/package/network/utils/comgt/Makefile b/package/network/utils/comgt/Makefile
new file mode 100644
index 0000000..5324903
--- /dev/null
+++ b/package/network/utils/comgt/Makefile
@@ -0,0 +1,67 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=comgt
+PKG_VERSION:=0.32
+PKG_RELEASE:=21
+
+PKG_SOURCE:=$(PKG_NAME).$(PKG_VERSION).tgz
+PKG_SOURCE_URL:=@SF/comgt
+PKG_MD5SUM:=db2452680c3d953631299e331daf49ef
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME).$(PKG_VERSION)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/comgt
+ SECTION:=utils
+ CATEGORY:=Utilities
+ TITLE:=Option/Vodafone 3G/GPRS control tool
+ DEPENDS:=+chat
+ URL:=http://www.pharscape.org/comgt.html
+endef
+
+define Package/comgt/description
+ comgt is a scripting language interpreter useful for establishing
+ communications on serial lines and through PCMCIA modems as well as GPRS
+ and 3G datacards.
+endef
+
+define Build/Compile
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ $(TARGET_CONFIGURE_OPTS) \
+ CFLAGS="$(TARGET_CFLAGS)" \
+ LDFLAGS="" \
+ comgt
+endef
+
+define Package/comgt/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/comgt $(1)/usr/bin/
+ ln -s comgt $(1)/usr/bin/gcom
+ $(INSTALL_DIR) $(1)/etc/chatscripts
+ $(INSTALL_DATA) ./files/3g.chat $(1)/etc/chatscripts/3g.chat
+ $(INSTALL_DATA) ./files/evdo.chat $(1)/etc/chatscripts/evdo.chat
+ $(INSTALL_DIR) $(1)/etc/gcom
+ $(INSTALL_DATA) ./files/setpin.gcom $(1)/etc/gcom/setpin.gcom
+ $(INSTALL_DATA) ./files/setmode.gcom $(1)/etc/gcom/setmode.gcom
+ $(INSTALL_DATA) ./files/getcardinfo.gcom $(1)/etc/gcom/getcardinfo.gcom
+ $(INSTALL_DATA) ./files/getstrength.gcom $(1)/etc/gcom/getstrength.gcom
+ $(INSTALL_DATA) ./files/getcarrier.gcom $(1)/etc/gcom/getcarrier.gcom
+ $(INSTALL_DATA) ./files/getcnum.gcom $(1)/etc/gcom/getcnum.gcom
+ $(INSTALL_DATA) ./files/getimsi.gcom $(1)/etc/gcom/getimsi.gcom
+ $(INSTALL_DIR) $(1)/etc/hotplug.d/tty
+ $(INSTALL_DATA) ./files/3g.usb $(1)/etc/hotplug.d/tty/30-3g
+ $(INSTALL_DIR) $(1)/lib/netifd/proto
+ $(INSTALL_BIN) ./files/3g.sh $(1)/lib/netifd/proto/3g.sh
+endef
+
+$(eval $(call BuildPackage,comgt))
diff --git a/package/network/utils/comgt/files/.svn/entries b/package/network/utils/comgt/files/.svn/entries
new file mode 100644
index 0000000..f2e9c85
--- /dev/null
+++ b/package/network/utils/comgt/files/.svn/entries
@@ -0,0 +1,402 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/utils/comgt/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-09-22T14:55:17.619273Z
+33507
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+3g.usb
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+c5d021507e87a8a4a0db1f972b49392e
+2012-09-09T19:46:38.657132Z
+33350
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+648
+
+3g.sh
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+c7eefaa44c9ca438a2210b2f02056072
+2012-09-22T14:55:17.619273Z
+33507
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2088
+
+getstrength.gcom
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+ec74cd87c07166c0b1103149cff3539a
+2007-03-04T04:41:46.644094Z
+6501
+pavlov
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+160
+
+setmode.gcom
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+da7f9a6df441614e4cf8a4be443f67ec
+2007-03-04T04:41:46.644094Z
+6501
+pavlov
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+403
+
+getimsi.gcom
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+e1e8ecddcba048533cdce8891daac451
+2011-11-30T14:16:44.594102Z
+29365
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+242
+
+getcnum.gcom
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+7ba130518bd256a38bda76a721ebd008
+2011-11-30T14:16:44.594102Z
+29365
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+275
+
+setpin.gcom
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+f37a8f45439b910b3041d10032c972b7
+2007-03-04T04:41:46.644094Z
+6501
+pavlov
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+919
+
+3g.chat
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+2d46a1097990ef1c6358c7c2fae3ae3d
+2007-03-04T04:41:46.644094Z
+6501
+pavlov
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+217
+
+getcardinfo.gcom
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+3977cb6e0a3ddcd024354b17ab5da77a
+2007-03-04T04:41:46.644094Z
+6501
+pavlov
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+157
+
+evdo.chat
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+ca63326032b71cfc0bb51a4e8225dc36
+2008-02-02T01:21:31.142902Z
+10347
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+364
+
+getcarrier.gcom
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+baaf2df2ee0dbf14f8e09278dcecfe6c
+2011-10-28T11:30:21.501399Z
+28648
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+312
+
diff --git a/package/network/utils/comgt/files/.svn/prop-base/3g.chat.svn-base b/package/network/utils/comgt/files/.svn/prop-base/3g.chat.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/network/utils/comgt/files/.svn/prop-base/3g.chat.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/utils/comgt/files/.svn/prop-base/getcardinfo.gcom.svn-base b/package/network/utils/comgt/files/.svn/prop-base/getcardinfo.gcom.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/network/utils/comgt/files/.svn/prop-base/getcardinfo.gcom.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/utils/comgt/files/.svn/prop-base/getimsi.gcom.svn-base b/package/network/utils/comgt/files/.svn/prop-base/getimsi.gcom.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/network/utils/comgt/files/.svn/prop-base/getimsi.gcom.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/utils/comgt/files/.svn/prop-base/getstrength.gcom.svn-base b/package/network/utils/comgt/files/.svn/prop-base/getstrength.gcom.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/network/utils/comgt/files/.svn/prop-base/getstrength.gcom.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/utils/comgt/files/.svn/prop-base/setmode.gcom.svn-base b/package/network/utils/comgt/files/.svn/prop-base/setmode.gcom.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/network/utils/comgt/files/.svn/prop-base/setmode.gcom.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/utils/comgt/files/.svn/prop-base/setpin.gcom.svn-base b/package/network/utils/comgt/files/.svn/prop-base/setpin.gcom.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/network/utils/comgt/files/.svn/prop-base/setpin.gcom.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/utils/comgt/files/.svn/text-base/3g.chat.svn-base b/package/network/utils/comgt/files/.svn/text-base/3g.chat.svn-base
new file mode 100644
index 0000000..a1fa2a0
--- /dev/null
+++ b/package/network/utils/comgt/files/.svn/text-base/3g.chat.svn-base
@@ -0,0 +1,12 @@
+ABORT BUSY
+ABORT 'NO CARRIER'
+ABORT ERROR
+REPORT CONNECT
+TIMEOUT 10
+"" "AT&F"
+OK "ATE1"
+OK 'AT+CGDCONT=1,"IP","$USE_APN"'
+SAY "Calling UMTS/GPRS"
+TIMEOUT 30
+OK "ATD*99***1#"
+CONNECT ' '
diff --git a/package/network/utils/comgt/files/.svn/text-base/3g.sh.svn-base b/package/network/utils/comgt/files/.svn/text-base/3g.sh.svn-base
new file mode 100644
index 0000000..2ed74b4
--- /dev/null
+++ b/package/network/utils/comgt/files/.svn/text-base/3g.sh.svn-base
@@ -0,0 +1,97 @@
+#!/bin/sh
+INCLUDE_ONLY=1
+
+. ../netifd-proto.sh
+. ./ppp.sh
+init_proto "$@"
+
+proto_3g_init_config() {
+ no_device=1
+ available=1
+ ppp_generic_init_config
+ proto_config_add_string "device"
+ proto_config_add_string "apn"
+ proto_config_add_string "service"
+ proto_config_add_string "pincode"
+}
+
+proto_3g_setup() {
+ local interface="$1"
+ local chat
+
+ json_get_var device device
+ json_get_var apn apn
+ json_get_var service service
+ json_get_var pincode pincode
+
+ [ -e "$device" ] || {
+ proto_set_available "$interface" 0
+ return 1
+ }
+
+ case "$service" in
+ cdma|evdo)
+ chat="/etc/chatscripts/evdo.chat"
+ ;;
+ *)
+ chat="/etc/chatscripts/3g.chat"
+ cardinfo=$(gcom -d "$device" -s /etc/gcom/getcardinfo.gcom)
+ if echo "$cardinfo" | grep -q Novatel; then
+ case "$service" in
+ umts_only) CODE=2;;
+ gprs_only) CODE=1;;
+ *) CODE=0;;
+ esac
+ export MODE="AT\$NWRAT=${CODE},2"
+ elif echo "$cardinfo" | grep -q Option; then
+ case "$service" in
+ umts_only) CODE=1;;
+ gprs_only) CODE=0;;
+ *) CODE=3;;
+ esac
+ export MODE="AT_OPSYS=${CODE}"
+ elif echo "$cardinfo" | grep -q "Sierra Wireless"; then
+ SIERRA=1
+ elif echo "$cardinfo" | grep -qi huawei; then
+ case "$service" in
+ umts_only) CODE="14,2";;
+ gprs_only) CODE="13,1";;
+ *) CODE="2,2";;
+ esac
+ export MODE="AT^SYSCFG=${CODE},3FFFFFFF,2,4"
+ fi
+
+ if [ -n "$pincode" ]; then
+ PINCODE="$pincode" gcom -d "$device" -s /etc/gcom/setpin.gcom || {
+ proto_notify_error "$interface" PIN_FAILED
+ proto_block_restart "$interface"
+ return 1
+ }
+ fi
+ [ -n "$MODE" ] && gcom -d "$device" -s /etc/gcom/setmode.gcom
+
+ # wait for carrier to avoid firmware stability bugs
+ [ -n "$SIERRA" ] && {
+ gcom -d "$device" -s /etc/gcom/getcarrier.gcom || return 1
+ }
+ ;;
+ esac
+
+ connect="${apn:+USE_APN=$apn }/usr/sbin/chat -t5 -v -E -f $chat"
+ ppp_generic_setup "$interface" \
+ noaccomp \
+ nopcomp \
+ novj \
+ nobsdcomp \
+ noauth \
+ lock \
+ crtscts \
+ 115200 "$device"
+ return 0
+}
+
+proto_3g_teardown() {
+ proto_kill_command "$interface"
+}
+
+add_protocol 3g
diff --git a/package/network/utils/comgt/files/.svn/text-base/3g.usb.svn-base b/package/network/utils/comgt/files/.svn/text-base/3g.usb.svn-base
new file mode 100644
index 0000000..fd6837e
--- /dev/null
+++ b/package/network/utils/comgt/files/.svn/text-base/3g.usb.svn-base
@@ -0,0 +1,33 @@
+#!/bin/sh
+. /lib/functions.sh
+. /lib/netifd/netifd-proto.sh
+
+find_3g_iface() {
+ local cfg="$1"
+ local tty="$2"
+
+ local proto
+ config_get proto "$cfg" proto
+ [ "$proto" = 3g ] || return 0
+
+ # bypass state vars here because 00-netstate could clobber .device
+ local dev=$(uci_get network "$cfg" device)
+
+ if [ "${dev##*/}" = "${tty##*/}" ]; then
+ if [ "$ACTION" = add ]; then
+ available=1
+ else
+ available=0
+ fi
+ proto_set_available "$cfg" $available
+ fi
+}
+
+case "$DEVICENAME" in
+ tty*)
+ [ -e "/dev/$DEVICENAME" ] || [ "$ACTION" = remove ] || exit 0
+ config_load network
+ config_foreach find_3g_iface interface "/dev/$DEVICENAME"
+ ;;
+esac
+
diff --git a/package/network/utils/comgt/files/.svn/text-base/evdo.chat.svn-base b/package/network/utils/comgt/files/.svn/text-base/evdo.chat.svn-base
new file mode 100644
index 0000000..de49e41
--- /dev/null
+++ b/package/network/utils/comgt/files/.svn/text-base/evdo.chat.svn-base
@@ -0,0 +1,17 @@
+# This is a simple chat script based off of the one provided by Sierra Wireless
+# for CDMA connections. It should work for both Sprint and Verizon networks.
+
+ABORT BUSY
+ABORT 'NO CARRIER'
+ABORT ERROR
+ABORT 'NO DIAL TONE'
+ABORT 'NO ANSWER'
+ABORT DELAYED
+REPORT CONNECT
+TIMEOUT 10
+'' AT
+OK ATZ
+SAY 'Calling CDMA/EVDO'
+TIMEOUT 30
+OK ATDT#777
+CONNECT ''
diff --git a/package/network/utils/comgt/files/.svn/text-base/getcardinfo.gcom.svn-base b/package/network/utils/comgt/files/.svn/text-base/getcardinfo.gcom.svn-base
new file mode 100644
index 0000000..5c69a64
--- /dev/null
+++ b/package/network/utils/comgt/files/.svn/text-base/getcardinfo.gcom.svn-base
@@ -0,0 +1,14 @@
+opengt
+ set com 115200n81
+ set comecho off
+ set senddelay 0.02
+ waitquiet 0.2 0.2
+ flash 0.1
+
+:start
+ send "ATI^m"
+ get 1 "" $s
+ print $s
+
+:continue
+ exit 0
diff --git a/package/network/utils/comgt/files/.svn/text-base/getcarrier.gcom.svn-base b/package/network/utils/comgt/files/.svn/text-base/getcarrier.gcom.svn-base
new file mode 100644
index 0000000..1e0216d
--- /dev/null
+++ b/package/network/utils/comgt/files/.svn/text-base/getcarrier.gcom.svn-base
@@ -0,0 +1,20 @@
+opengt
+ set senddelay 0.05
+ waitquiet 1 0.2
+ let c=1
+ :loop
+ inc c
+ send "AT+CGATT?^m"
+ waitfor 5 "+CGATT: 1","+CGATT: 0"
+ print "\n."
+ if % = -1 goto error
+ if c > 10 goto toolong
+ if % = 0 goto out
+ sleep 2
+ if % = 1 goto loop
+ :toolong
+ exit 1
+ :error
+ exit 0
+ :out
+ exit 0
diff --git a/package/network/utils/comgt/files/.svn/text-base/getcnum.gcom.svn-base b/package/network/utils/comgt/files/.svn/text-base/getcnum.gcom.svn-base
new file mode 100644
index 0000000..450cf8c
--- /dev/null
+++ b/package/network/utils/comgt/files/.svn/text-base/getcnum.gcom.svn-base
@@ -0,0 +1,20 @@
+opengt
+ set com 115200n81
+ set comecho off
+ set senddelay 0.02
+ waitquiet 0.2 0.2
+ flash 0.1
+
+:start
+ send "AT+CNUM^m"
+ get 1 "^m" $n
+ get 1 ":" $n
+ get 1 "\"" $n
+ get 1 "\"" $n
+ get 1 "\"" $n
+ get 1 "\"" $n
+ let n = len($n)
+ if n<1 goto continue
+ print $n
+:continue
+ exit 0
diff --git a/package/network/utils/comgt/files/.svn/text-base/getimsi.gcom.svn-base b/package/network/utils/comgt/files/.svn/text-base/getimsi.gcom.svn-base
new file mode 100644
index 0000000..0485456
--- /dev/null
+++ b/package/network/utils/comgt/files/.svn/text-base/getimsi.gcom.svn-base
@@ -0,0 +1,17 @@
+opengt
+ set com 115200n81
+ set comecho off
+ set senddelay 0.02
+ waitquiet 0.2 0.2
+ flash 0.1
+
+:start
+ send "AT+CIMI^m"
+ get 1 "^m" $s
+ get 1 "^m" $s
+ let x = len($s)
+ if x<2 goto continue
+ let $s = $right($s, x-1)
+ print $s
+:continue
+ exit 0
diff --git a/package/network/utils/comgt/files/.svn/text-base/getstrength.gcom.svn-base b/package/network/utils/comgt/files/.svn/text-base/getstrength.gcom.svn-base
new file mode 100644
index 0000000..2886285
--- /dev/null
+++ b/package/network/utils/comgt/files/.svn/text-base/getstrength.gcom.svn-base
@@ -0,0 +1,14 @@
+opengt
+ set com 115200n81
+ set comecho off
+ set senddelay 0.02
+ waitquiet 0.2 0.2
+ flash 0.1
+
+:start
+ send "AT+CSQ^m"
+ get 1 "" $s
+ print $s
+
+:continue
+ exit 0
diff --git a/package/network/utils/comgt/files/.svn/text-base/setmode.gcom.svn-base b/package/network/utils/comgt/files/.svn/text-base/setmode.gcom.svn-base
new file mode 100644
index 0000000..4ce0b5f
--- /dev/null
+++ b/package/network/utils/comgt/files/.svn/text-base/setmode.gcom.svn-base
@@ -0,0 +1,26 @@
+# set wwan mode from environment
+opengt
+ set com 115200n81
+ set senddelay 0.02
+ waitquiet 1 0.2
+ flash 0.1
+
+:start
+ print "Trying to set mode\n"
+ send $env("MODE")
+ send "^m"
+
+ waitfor 15 "OK","ERR","ERROR"
+ if % = 0 goto continue
+ if % = 1 goto modeerror
+ if % = 2 goto modeerror
+
+ print "Timeout setting WWAN mode!\n"
+ exit 1
+
+:modeerror
+ print "Error setting WWAN mode!\n"
+ exit 1
+
+:continue
+ exit 0
diff --git a/package/network/utils/comgt/files/.svn/text-base/setpin.gcom.svn-base b/package/network/utils/comgt/files/.svn/text-base/setpin.gcom.svn-base
new file mode 100644
index 0000000..66350fe
--- /dev/null
+++ b/package/network/utils/comgt/files/.svn/text-base/setpin.gcom.svn-base
@@ -0,0 +1,55 @@
+# set pin code from evnironment "$PINCODE"
+opengt
+ set com 115200n81
+ set senddelay 0.05
+ waitquiet 3 0.5
+ flash 0.1
+
+ let c=0
+:start
+ send "AT+CPIN?^m"
+ waitfor 15 "SIM PUK","SIM PIN","READY","ERROR","ERR"
+ if % = -1 goto timeout
+ if % = 0 goto ready
+ if % = 1 goto setpin
+ if % = 2 goto ready
+ if % = 3 goto checkrepeat
+ if % = 4 goto checkrepeat
+
+:checkrepeat
+ inc c
+ if c>3 goto pinerror
+ waitquiet 12 0.5
+ goto start
+
+:timeout
+ print "timeout checking for PIN."
+ exit 1
+
+:ready
+ print "SIM ready\n"
+ goto continue
+ exit 0
+
+:setpin
+ # check if output was "SIM PIN2", that's ok.
+ waitfor 1 "2"
+ if % = 0 goto ready
+
+ print "Trying to set PIN\n"
+ send "AT+CPIN=\""
+ send $env("PINCODE")
+ send "\"^m"
+
+ waitfor 20 "OK","ERR"
+ if % = -1 goto pinerror
+ if % = 0 goto continue
+ if % = 1 goto pinerror
+
+:pinerror
+ print "Error setting PIN, check card manually\n"
+ exit 1
+
+:continue
+ print "PIN set successfully\n"
+ exit 0
diff --git a/package/network/utils/comgt/files/3g.chat b/package/network/utils/comgt/files/3g.chat
new file mode 100644
index 0000000..a1fa2a0
--- /dev/null
+++ b/package/network/utils/comgt/files/3g.chat
@@ -0,0 +1,12 @@
+ABORT BUSY
+ABORT 'NO CARRIER'
+ABORT ERROR
+REPORT CONNECT
+TIMEOUT 10
+"" "AT&F"
+OK "ATE1"
+OK 'AT+CGDCONT=1,"IP","$USE_APN"'
+SAY "Calling UMTS/GPRS"
+TIMEOUT 30
+OK "ATD*99***1#"
+CONNECT ' '
diff --git a/package/network/utils/comgt/files/3g.sh b/package/network/utils/comgt/files/3g.sh
new file mode 100644
index 0000000..2ed74b4
--- /dev/null
+++ b/package/network/utils/comgt/files/3g.sh
@@ -0,0 +1,97 @@
+#!/bin/sh
+INCLUDE_ONLY=1
+
+. ../netifd-proto.sh
+. ./ppp.sh
+init_proto "$@"
+
+proto_3g_init_config() {
+ no_device=1
+ available=1
+ ppp_generic_init_config
+ proto_config_add_string "device"
+ proto_config_add_string "apn"
+ proto_config_add_string "service"
+ proto_config_add_string "pincode"
+}
+
+proto_3g_setup() {
+ local interface="$1"
+ local chat
+
+ json_get_var device device
+ json_get_var apn apn
+ json_get_var service service
+ json_get_var pincode pincode
+
+ [ -e "$device" ] || {
+ proto_set_available "$interface" 0
+ return 1
+ }
+
+ case "$service" in
+ cdma|evdo)
+ chat="/etc/chatscripts/evdo.chat"
+ ;;
+ *)
+ chat="/etc/chatscripts/3g.chat"
+ cardinfo=$(gcom -d "$device" -s /etc/gcom/getcardinfo.gcom)
+ if echo "$cardinfo" | grep -q Novatel; then
+ case "$service" in
+ umts_only) CODE=2;;
+ gprs_only) CODE=1;;
+ *) CODE=0;;
+ esac
+ export MODE="AT\$NWRAT=${CODE},2"
+ elif echo "$cardinfo" | grep -q Option; then
+ case "$service" in
+ umts_only) CODE=1;;
+ gprs_only) CODE=0;;
+ *) CODE=3;;
+ esac
+ export MODE="AT_OPSYS=${CODE}"
+ elif echo "$cardinfo" | grep -q "Sierra Wireless"; then
+ SIERRA=1
+ elif echo "$cardinfo" | grep -qi huawei; then
+ case "$service" in
+ umts_only) CODE="14,2";;
+ gprs_only) CODE="13,1";;
+ *) CODE="2,2";;
+ esac
+ export MODE="AT^SYSCFG=${CODE},3FFFFFFF,2,4"
+ fi
+
+ if [ -n "$pincode" ]; then
+ PINCODE="$pincode" gcom -d "$device" -s /etc/gcom/setpin.gcom || {
+ proto_notify_error "$interface" PIN_FAILED
+ proto_block_restart "$interface"
+ return 1
+ }
+ fi
+ [ -n "$MODE" ] && gcom -d "$device" -s /etc/gcom/setmode.gcom
+
+ # wait for carrier to avoid firmware stability bugs
+ [ -n "$SIERRA" ] && {
+ gcom -d "$device" -s /etc/gcom/getcarrier.gcom || return 1
+ }
+ ;;
+ esac
+
+ connect="${apn:+USE_APN=$apn }/usr/sbin/chat -t5 -v -E -f $chat"
+ ppp_generic_setup "$interface" \
+ noaccomp \
+ nopcomp \
+ novj \
+ nobsdcomp \
+ noauth \
+ lock \
+ crtscts \
+ 115200 "$device"
+ return 0
+}
+
+proto_3g_teardown() {
+ proto_kill_command "$interface"
+}
+
+add_protocol 3g
diff --git a/package/network/utils/comgt/files/3g.usb b/package/network/utils/comgt/files/3g.usb
new file mode 100644
index 0000000..fd6837e
--- /dev/null
+++ b/package/network/utils/comgt/files/3g.usb
@@ -0,0 +1,33 @@
+#!/bin/sh
+. /lib/functions.sh
+. /lib/netifd/netifd-proto.sh
+
+find_3g_iface() {
+ local cfg="$1"
+ local tty="$2"
+
+ local proto
+ config_get proto "$cfg" proto
+ [ "$proto" = 3g ] || return 0
+
+ # bypass state vars here because 00-netstate could clobber .device
+ local dev=$(uci_get network "$cfg" device)
+
+ if [ "${dev##*/}" = "${tty##*/}" ]; then
+ if [ "$ACTION" = add ]; then
+ available=1
+ else
+ available=0
+ fi
+ proto_set_available "$cfg" $available
+ fi
+}
+
+case "$DEVICENAME" in
+ tty*)
+ [ -e "/dev/$DEVICENAME" ] || [ "$ACTION" = remove ] || exit 0
+ config_load network
+ config_foreach find_3g_iface interface "/dev/$DEVICENAME"
+ ;;
+esac
+
diff --git a/package/network/utils/comgt/files/evdo.chat b/package/network/utils/comgt/files/evdo.chat
new file mode 100644
index 0000000..de49e41
--- /dev/null
+++ b/package/network/utils/comgt/files/evdo.chat
@@ -0,0 +1,17 @@
+# This is a simple chat script based off of the one provided by Sierra Wireless
+# for CDMA connections. It should work for both Sprint and Verizon networks.
+
+ABORT BUSY
+ABORT 'NO CARRIER'
+ABORT ERROR
+ABORT 'NO DIAL TONE'
+ABORT 'NO ANSWER'
+ABORT DELAYED
+REPORT CONNECT
+TIMEOUT 10
+'' AT
+OK ATZ
+SAY 'Calling CDMA/EVDO'
+TIMEOUT 30
+OK ATDT#777
+CONNECT ''
diff --git a/package/network/utils/comgt/files/getcardinfo.gcom b/package/network/utils/comgt/files/getcardinfo.gcom
new file mode 100644
index 0000000..5c69a64
--- /dev/null
+++ b/package/network/utils/comgt/files/getcardinfo.gcom
@@ -0,0 +1,14 @@
+opengt
+ set com 115200n81
+ set comecho off
+ set senddelay 0.02
+ waitquiet 0.2 0.2
+ flash 0.1
+
+:start
+ send "ATI^m"
+ get 1 "" $s
+ print $s
+
+:continue
+ exit 0
diff --git a/package/network/utils/comgt/files/getcarrier.gcom b/package/network/utils/comgt/files/getcarrier.gcom
new file mode 100644
index 0000000..1e0216d
--- /dev/null
+++ b/package/network/utils/comgt/files/getcarrier.gcom
@@ -0,0 +1,20 @@
+opengt
+ set senddelay 0.05
+ waitquiet 1 0.2
+ let c=1
+ :loop
+ inc c
+ send "AT+CGATT?^m"
+ waitfor 5 "+CGATT: 1","+CGATT: 0"
+ print "\n."
+ if % = -1 goto error
+ if c > 10 goto toolong
+ if % = 0 goto out
+ sleep 2
+ if % = 1 goto loop
+ :toolong
+ exit 1
+ :error
+ exit 0
+ :out
+ exit 0
diff --git a/package/network/utils/comgt/files/getcnum.gcom b/package/network/utils/comgt/files/getcnum.gcom
new file mode 100644
index 0000000..450cf8c
--- /dev/null
+++ b/package/network/utils/comgt/files/getcnum.gcom
@@ -0,0 +1,20 @@
+opengt
+ set com 115200n81
+ set comecho off
+ set senddelay 0.02
+ waitquiet 0.2 0.2
+ flash 0.1
+
+:start
+ send "AT+CNUM^m"
+ get 1 "^m" $n
+ get 1 ":" $n
+ get 1 "\"" $n
+ get 1 "\"" $n
+ get 1 "\"" $n
+ get 1 "\"" $n
+ let n = len($n)
+ if n<1 goto continue
+ print $n
+:continue
+ exit 0
diff --git a/package/network/utils/comgt/files/getimsi.gcom b/package/network/utils/comgt/files/getimsi.gcom
new file mode 100644
index 0000000..0485456
--- /dev/null
+++ b/package/network/utils/comgt/files/getimsi.gcom
@@ -0,0 +1,17 @@
+opengt
+ set com 115200n81
+ set comecho off
+ set senddelay 0.02
+ waitquiet 0.2 0.2
+ flash 0.1
+
+:start
+ send "AT+CIMI^m"
+ get 1 "^m" $s
+ get 1 "^m" $s
+ let x = len($s)
+ if x<2 goto continue
+ let $s = $right($s, x-1)
+ print $s
+:continue
+ exit 0
diff --git a/package/network/utils/comgt/files/getstrength.gcom b/package/network/utils/comgt/files/getstrength.gcom
new file mode 100644
index 0000000..2886285
--- /dev/null
+++ b/package/network/utils/comgt/files/getstrength.gcom
@@ -0,0 +1,14 @@
+opengt
+ set com 115200n81
+ set comecho off
+ set senddelay 0.02
+ waitquiet 0.2 0.2
+ flash 0.1
+
+:start
+ send "AT+CSQ^m"
+ get 1 "" $s
+ print $s
+
+:continue
+ exit 0
diff --git a/package/network/utils/comgt/files/setmode.gcom b/package/network/utils/comgt/files/setmode.gcom
new file mode 100644
index 0000000..4ce0b5f
--- /dev/null
+++ b/package/network/utils/comgt/files/setmode.gcom
@@ -0,0 +1,26 @@
+# set wwan mode from environment
+opengt
+ set com 115200n81
+ set senddelay 0.02
+ waitquiet 1 0.2
+ flash 0.1
+
+:start
+ print "Trying to set mode\n"
+ send $env("MODE")
+ send "^m"
+
+ waitfor 15 "OK","ERR","ERROR"
+ if % = 0 goto continue
+ if % = 1 goto modeerror
+ if % = 2 goto modeerror
+
+ print "Timeout setting WWAN mode!\n"
+ exit 1
+
+:modeerror
+ print "Error setting WWAN mode!\n"
+ exit 1
+
+:continue
+ exit 0
diff --git a/package/network/utils/comgt/files/setpin.gcom b/package/network/utils/comgt/files/setpin.gcom
new file mode 100644
index 0000000..66350fe
--- /dev/null
+++ b/package/network/utils/comgt/files/setpin.gcom
@@ -0,0 +1,55 @@
+# set pin code from evnironment "$PINCODE"
+opengt
+ set com 115200n81
+ set senddelay 0.05
+ waitquiet 3 0.5
+ flash 0.1
+
+ let c=0
+:start
+ send "AT+CPIN?^m"
+ waitfor 15 "SIM PUK","SIM PIN","READY","ERROR","ERR"
+ if % = -1 goto timeout
+ if % = 0 goto ready
+ if % = 1 goto setpin
+ if % = 2 goto ready
+ if % = 3 goto checkrepeat
+ if % = 4 goto checkrepeat
+
+:checkrepeat
+ inc c
+ if c>3 goto pinerror
+ waitquiet 12 0.5
+ goto start
+
+:timeout
+ print "timeout checking for PIN."
+ exit 1
+
+:ready
+ print "SIM ready\n"
+ goto continue
+ exit 0
+
+:setpin
+ # check if output was "SIM PIN2", that's ok.
+ waitfor 1 "2"
+ if % = 0 goto ready
+
+ print "Trying to set PIN\n"
+ send "AT+CPIN=\""
+ send $env("PINCODE")
+ send "\"^m"
+
+ waitfor 20 "OK","ERR"
+ if % = -1 goto pinerror
+ if % = 0 goto continue
+ if % = 1 goto pinerror
+
+:pinerror
+ print "Error setting PIN, check card manually\n"
+ exit 1
+
+:continue
+ print "PIN set successfully\n"
+ exit 0
diff --git a/package/network/utils/comgt/patches/.svn/entries b/package/network/utils/comgt/patches/.svn/entries
new file mode 100644
index 0000000..b517020
--- /dev/null
+++ b/package/network/utils/comgt/patches/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/utils/comgt/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2011-07-20T08:47:19.523684Z
+27699
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+001-compile_fix.patch
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+d824a793242469fdc3be05838f3b4751
+2011-07-20T08:47:19.523684Z
+27699
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+408
+
diff --git a/package/network/utils/comgt/patches/.svn/text-base/001-compile_fix.patch.svn-base b/package/network/utils/comgt/patches/.svn/text-base/001-compile_fix.patch.svn-base
new file mode 100644
index 0000000..15de850
--- /dev/null
+++ b/package/network/utils/comgt/patches/.svn/text-base/001-compile_fix.patch.svn-base
@@ -0,0 +1,23 @@
+--- a/Makefile
++++ b/Makefile
+@@ -32,6 +32,7 @@ SCRIPTPATH = /etc/comgt/
+ SCRIPTSRC = ./scripts/
+ BIN = $(CPROG)
+ MANP = comgt.1 sigmon.1
++CC = cc
+
+ CFLAGS = -c
+ LDFLAGS =
+@@ -70,10 +71,5 @@ clean:
+ -rm *~
+ -rm $(SCRIPTSRC)*~
+
+-
+-comgt: comgt.o
+- cc comgt.o $(LDFLAGS) -o comgt
+-
+-comgt.o: comgt.c comgt.h
+- cc comgt.c $(CFLAGS)
+-
++comgt: comgt.c comgt.h
++ $(CC) $(CFLAGS) -o comgt $< $(LDFLAGS)
diff --git a/package/network/utils/comgt/patches/001-compile_fix.patch b/package/network/utils/comgt/patches/001-compile_fix.patch
new file mode 100644
index 0000000..15de850
--- /dev/null
+++ b/package/network/utils/comgt/patches/001-compile_fix.patch
@@ -0,0 +1,23 @@
+--- a/Makefile
++++ b/Makefile
+@@ -32,6 +32,7 @@ SCRIPTPATH = /etc/comgt/
+ SCRIPTSRC = ./scripts/
+ BIN = $(CPROG)
+ MANP = comgt.1 sigmon.1
++CC = cc
+
+ CFLAGS = -c
+ LDFLAGS =
+@@ -70,10 +71,5 @@ clean:
+ -rm *~
+ -rm $(SCRIPTSRC)*~
+
+-
+-comgt: comgt.o
+- cc comgt.o $(LDFLAGS) -o comgt
+-
+-comgt.o: comgt.c comgt.h
+- cc comgt.c $(CFLAGS)
+-
++comgt: comgt.c comgt.h
++ $(CC) $(CFLAGS) -o comgt $< $(LDFLAGS)
diff --git a/package/network/utils/conntrack-tools/.svn/entries b/package/network/utils/conntrack-tools/.svn/entries
new file mode 100644
index 0000000..fbc9d25
--- /dev/null
+++ b/package/network/utils/conntrack-tools/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/utils/conntrack-tools
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-10T13:19:43.677179Z
+33701
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+3f396c540bc0758317bd7fe17a4c39a7
+2012-10-10T13:19:43.677179Z
+33701
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1688
+
diff --git a/package/network/utils/conntrack-tools/.svn/text-base/Makefile.svn-base b/package/network/utils/conntrack-tools/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..3c52441
--- /dev/null
+++ b/package/network/utils/conntrack-tools/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,61 @@
+#
+# Copyright (C) 2009-2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=conntrack-tools
+PKG_VERSION:=1.0.0
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:= \
+ http://www.netfilter.org/projects/conntrack-tools/files \
+ ftp://ftp.netfilter.org/pub/conntrack-tools \
+ http://mirrors.evolva.ro/netfilter.org/conntrack-tools
+PKG_MD5SUM:=5add24d4761baf17af630d5627a71752
+
+PKG_MAINTAINER:=Jo-Philipp Wich <jow@openwrt.org>
+
+PKG_FIXUP:=autoreconf
+PKG_INSTALL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/conntrack-tools
+ SECTION:=net
+ CATEGORY:=Network
+ DEPENDS:=+libnetfilter-conntrack
+ SUBMENU:=Firewall
+ TITLE:=Connection tracking userspace tools
+ URL:=http://conntrack-tools.netfilter.org/
+endef
+
+define Package/conntrack-tools/description
+ The conntrack-tools are a set of free software userspace tools for Linux
+ that allow system administrators interact with the Connection Tracking
+ System, which is the module that provides stateful packet inspection for
+ iptables. The conntrack-tools are the userspace daemon conntrackd and the
+ command line interface conntrack.
+endef
+
+define Package/conntrack-tools/conffiles
+/etc/conntrackd/conntrackd.conf
+endef
+
+define Package/conntrack-tools/install
+ $(INSTALL_DIR) $(1)/etc/conntrackd
+ $(INSTALL_CONF) \
+ $(PKG_BUILD_DIR)/doc/stats/conntrackd.conf \
+ $(1)/etc/conntrackd/
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) \
+ $(PKG_INSTALL_DIR)/usr/sbin/conntrack \
+ $(PKG_INSTALL_DIR)/usr/sbin/conntrackd \
+ $(1)/usr/sbin/
+endef
+
+$(eval $(call BuildPackage,conntrack-tools))
diff --git a/package/network/utils/conntrack-tools/Makefile b/package/network/utils/conntrack-tools/Makefile
new file mode 100644
index 0000000..3c52441
--- /dev/null
+++ b/package/network/utils/conntrack-tools/Makefile
@@ -0,0 +1,61 @@
+#
+# Copyright (C) 2009-2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=conntrack-tools
+PKG_VERSION:=1.0.0
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:= \
+ http://www.netfilter.org/projects/conntrack-tools/files \
+ ftp://ftp.netfilter.org/pub/conntrack-tools \
+ http://mirrors.evolva.ro/netfilter.org/conntrack-tools
+PKG_MD5SUM:=5add24d4761baf17af630d5627a71752
+
+PKG_MAINTAINER:=Jo-Philipp Wich <jow@openwrt.org>
+
+PKG_FIXUP:=autoreconf
+PKG_INSTALL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/conntrack-tools
+ SECTION:=net
+ CATEGORY:=Network
+ DEPENDS:=+libnetfilter-conntrack
+ SUBMENU:=Firewall
+ TITLE:=Connection tracking userspace tools
+ URL:=http://conntrack-tools.netfilter.org/
+endef
+
+define Package/conntrack-tools/description
+ The conntrack-tools are a set of free software userspace tools for Linux
+ that allow system administrators interact with the Connection Tracking
+ System, which is the module that provides stateful packet inspection for
+ iptables. The conntrack-tools are the userspace daemon conntrackd and the
+ command line interface conntrack.
+endef
+
+define Package/conntrack-tools/conffiles
+/etc/conntrackd/conntrackd.conf
+endef
+
+define Package/conntrack-tools/install
+ $(INSTALL_DIR) $(1)/etc/conntrackd
+ $(INSTALL_CONF) \
+ $(PKG_BUILD_DIR)/doc/stats/conntrackd.conf \
+ $(1)/etc/conntrackd/
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) \
+ $(PKG_INSTALL_DIR)/usr/sbin/conntrack \
+ $(PKG_INSTALL_DIR)/usr/sbin/conntrackd \
+ $(1)/usr/sbin/
+endef
+
+$(eval $(call BuildPackage,conntrack-tools))
diff --git a/package/network/utils/dante/.svn/entries b/package/network/utils/dante/.svn/entries
new file mode 100644
index 0000000..5e634fb
--- /dev/null
+++ b/package/network/utils/dante/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/utils/dante
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-02-19T17:22:55.065673Z
+35685
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+d7a237ea77adc06c6b9777a2a384945e
+2013-02-19T17:22:55.065673Z
+35685
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2733
+
diff --git a/package/network/utils/dante/.svn/text-base/Makefile.svn-base b/package/network/utils/dante/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..cdd472b
--- /dev/null
+++ b/package/network/utils/dante/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,116 @@
+#
+# Copyright (C) 2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=dante
+PKG_VERSION:=1.2.2
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://www.inet.no/dante/files/
+PKG_MD5SUM:=69b9d6234154d7d6a91fcbd98c68e62a
+
+PKG_MAINTAINER:=Jo-Philipp Wich <jow@openwrt.org>
+
+PKG_FIXUP:=autoreconf
+PKG_INSTALL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+TARGET_CFLAGS += -D_GNU_SOURCE
+CONFIGURE_ARGS += \
+ --without-upnp \
+ --without-pam \
+ --disable-libwrap
+
+CONFIGURE_VARS += \
+ CC="$(TARGET_CC) $(TARGET_CFLAGS)"
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include
+ $(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/*.{a,so*,la} $(1)/usr/lib/
+endef
+
+
+define Package/dante/default
+ TITLE:=Dante SOCKS
+ URL:=http://www.inet.no/dante/
+endef
+
+define Package/dante/default/description
+Dante is a circuit-level firewall/proxy that can be used to provide convenient
+and secure network connectivity, requiring only that the server Dante runs on
+has external network connectivity. Dante is used daily by Fortune 100 companies
+and large international organizations, either as a standard SOCKS server or as
+a "reverse proxy".
+endef
+
+define Package/libsocks
+ $(call Package/dante/default)
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE+= Library
+endef
+
+define Package/libsocks/description
+$(call Package/dante/default/description)
+This package provides the shared libsocks library.
+endef
+
+define Package/libsocks/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libsocks.so* $(1)/usr/lib/
+endef
+
+
+define Package/sockd
+ $(call Package/dante/default)
+ SUBMENU:=Web Servers/Proxies
+ SECTION:=net
+ CATEGORY:=Network
+ TITLE+= Daemon
+endef
+
+define Package/sockd/description
+$(call Package/dante/default/description)
+This package provides the Dante sockd daemon.
+endef
+
+define Package/sockd/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(CP) $(PKG_INSTALL_DIR)/usr/sbin/sockd $(1)/usr/sbin/
+endef
+
+
+define Package/socksify
+ $(call Package/dante/default)
+ SECTION:=net
+ CATEGORY:=Network
+ SUBMENU:=Web Servers/Proxies
+ TITLE+= Client
+endef
+
+define Package/socksify/description
+$(call Package/dante/default/description)
+This package provides the Dante socksify client.
+endef
+
+define Package/socksify/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(CP) $(PKG_INSTALL_DIR)/usr/bin/socksify $(1)/usr/bin/
+
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libdsocks.so* $(1)/usr/lib/
+endef
+
+
+$(eval $(call BuildPackage,libsocks))
+$(eval $(call BuildPackage,sockd))
+$(eval $(call BuildPackage,socksify))
diff --git a/package/network/utils/dante/Makefile b/package/network/utils/dante/Makefile
new file mode 100644
index 0000000..cdd472b
--- /dev/null
+++ b/package/network/utils/dante/Makefile
@@ -0,0 +1,116 @@
+#
+# Copyright (C) 2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=dante
+PKG_VERSION:=1.2.2
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://www.inet.no/dante/files/
+PKG_MD5SUM:=69b9d6234154d7d6a91fcbd98c68e62a
+
+PKG_MAINTAINER:=Jo-Philipp Wich <jow@openwrt.org>
+
+PKG_FIXUP:=autoreconf
+PKG_INSTALL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+TARGET_CFLAGS += -D_GNU_SOURCE
+CONFIGURE_ARGS += \
+ --without-upnp \
+ --without-pam \
+ --disable-libwrap
+
+CONFIGURE_VARS += \
+ CC="$(TARGET_CC) $(TARGET_CFLAGS)"
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include
+ $(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/*.{a,so*,la} $(1)/usr/lib/
+endef
+
+
+define Package/dante/default
+ TITLE:=Dante SOCKS
+ URL:=http://www.inet.no/dante/
+endef
+
+define Package/dante/default/description
+Dante is a circuit-level firewall/proxy that can be used to provide convenient
+and secure network connectivity, requiring only that the server Dante runs on
+has external network connectivity. Dante is used daily by Fortune 100 companies
+and large international organizations, either as a standard SOCKS server or as
+a "reverse proxy".
+endef
+
+define Package/libsocks
+ $(call Package/dante/default)
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE+= Library
+endef
+
+define Package/libsocks/description
+$(call Package/dante/default/description)
+This package provides the shared libsocks library.
+endef
+
+define Package/libsocks/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libsocks.so* $(1)/usr/lib/
+endef
+
+
+define Package/sockd
+ $(call Package/dante/default)
+ SUBMENU:=Web Servers/Proxies
+ SECTION:=net
+ CATEGORY:=Network
+ TITLE+= Daemon
+endef
+
+define Package/sockd/description
+$(call Package/dante/default/description)
+This package provides the Dante sockd daemon.
+endef
+
+define Package/sockd/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(CP) $(PKG_INSTALL_DIR)/usr/sbin/sockd $(1)/usr/sbin/
+endef
+
+
+define Package/socksify
+ $(call Package/dante/default)
+ SECTION:=net
+ CATEGORY:=Network
+ SUBMENU:=Web Servers/Proxies
+ TITLE+= Client
+endef
+
+define Package/socksify/description
+$(call Package/dante/default/description)
+This package provides the Dante socksify client.
+endef
+
+define Package/socksify/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(CP) $(PKG_INSTALL_DIR)/usr/bin/socksify $(1)/usr/bin/
+
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libdsocks.so* $(1)/usr/lib/
+endef
+
+
+$(eval $(call BuildPackage,libsocks))
+$(eval $(call BuildPackage,sockd))
+$(eval $(call BuildPackage,socksify))
diff --git a/package/network/utils/dante/patches/.svn/entries b/package/network/utils/dante/patches/.svn/entries
new file mode 100644
index 0000000..9a5d28c
--- /dev/null
+++ b/package/network/utils/dante/patches/.svn/entries
@@ -0,0 +1,130 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/utils/dante/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2011-02-27T23:22:38.253882Z
+25780
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+001-automake-compat.patch
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+982addaecd7ddf2c8584b44339f09114
+2011-02-27T23:22:38.253882Z
+25780
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+11832
+
+200-fix-RTLD_NEXT.patch
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+94c9b00be80af04177dacdacb48f7d90
+2011-02-27T23:22:38.253882Z
+25780
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+790
+
+100-do-not-use-defdname.patch
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+701c7a99de0c8b472aa2fe053ee4d7bd
+2011-02-27T23:22:38.253882Z
+25780
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1464
+
diff --git a/package/network/utils/dante/patches/.svn/text-base/001-automake-compat.patch.svn-base b/package/network/utils/dante/patches/.svn/text-base/001-automake-compat.patch.svn-base
new file mode 100644
index 0000000..4349a4b
--- /dev/null
+++ b/package/network/utils/dante/patches/.svn/text-base/001-automake-compat.patch.svn-base
@@ -0,0 +1,482 @@
+--- a/configure.ac
++++ b/configure.ac
+@@ -16,7 +16,7 @@ echo "Configuring Dante ${version}${pren
+
+ AM_INIT_AUTOMAKE(dante, ${version}${prename})
+ AC_CONFIG_SRCDIR(include/common.h)
+-AM_CONFIG_HEADER(include/autoconf.h)
++AM_CONFIG_HEADER(autoconfig-is-soo-stupid.h include/autoconf.h)
+
+ AC_DEFINE(BAREFOOTD, 0, [we are Dante])
+
+@@ -38,17 +38,6 @@ AC_PROG_CPP
+
+ AM_CONDITIONAL(PRERELEASE, test x$prerelease != x)
+
+-#known keywords for --enable/disable-foo(=yes/no)?
+-LTINTERNAL="dlopen|dlopen_self|dlopen_self_static|fast_install|libtool_lock|win32_dll|shared_with_static_runtimes|shared_with_static_runtimes_CXX|shared_with_static_runtimes_F77"
+-KNOWN_KEYWORDS="$LTINTERNAL|shared|static|debug|warnings|diagnostic|profiling|linting|libwrap|preload|serverdl|clientdl|internal|pidfile|drt_fallback"
+-for keyword in `set | egrep '^enable_' | sed -e 's/^enable_\(.*\)=.*/\1/'`; do
+- echo $keyword | egrep "^(${KNOWN_KEYWORDS})$" > /dev/null
+- if test $? -ne 0; then
+- AC_MSG_WARN([unknown option '$keyword', ignoring ...])
+- sleep 10;
+- fi
+-done
+-
+ case $host in
+ *-*-osf*)
+ AC_MSG_WARN([OSF support might be removed in the near future.])
+@@ -175,31 +164,6 @@ case $host in
+ #XXX make sure compiling with compiler options works
+ esac
+
+-AC_MSG_CHECKING([for support for -pipe compiler flag])
+-oCFLAGS=$CFLAGS
+-CFLAGS="$CFLAGS -pipe"
+-AC_TRY_RUN([
+-int main()
+-{
+- return 0;
+-}], [AC_MSG_RESULT([yes])
+- comp_flags="${comp_flags} -pipe"],
+- AC_MSG_RESULT([no]))
+-CFLAGS="$oCFLAGS"
+-
+-AC_MSG_CHECKING([for support for -Wbounded compiler flag])
+-oCFLAGS=$CFLAGS
+-CFLAGS="$CFLAGS -Wbounded"
+-AC_TRY_RUN([
+-int main()
+-{
+- return 0;
+-}], [AC_MSG_RESULT([yes])
+- comp_flags="${comp_flags} -Wbounded"],
+- [AC_MSG_RESULT([no])
+- AC_DEFINE(__bounded__(a,b,c), , [empty __bounded__ macro])])
+-CFLAGS="$oCFLAGS"
+-
+ AC_MSG_CHECKING([for compilation with debugging])
+ AC_ARG_ENABLE(debug,
+ [ --enable-debug compile with debugging support],
+@@ -608,43 +572,6 @@ else
+ fi], [AC_MSG_RESULT(no)
+ AC_MSG_WARN([performance in the server might be degraded without support for the SO_SNDLOWAT socket option])])
+
+-AC_MSG_CHECKING([whether realloc with a NULL pointer calls malloc])
+-AC_TRY_RUN([
+-#include <stdlib.h>
+-#ifndef NULL
+-#define NULL (char *)0
+-#endif
+-
+-int main()
+-{
+- /* will assume this test doesn\'t fail because of lack of memory */
+- if (realloc(NULL, 1) == NULL)
+- return 1;
+- else
+- return 0;
+-}], [AC_MSG_RESULT(yes)],
+- [AC_DEFINE(HAVE_NOMALLOC_REALLOC, 1, [realloc never calls malloc])
+- AC_MSG_RESULT(no)])
+-
+-AC_MSG_CHECKING([whether free can be called with NULL])
+-AC_TRY_RUN([
+-#include <stdlib.h>
+-#ifndef NULL
+-#define NULL (char *)0
+-#endif
+-
+-int main()
+-{
+- /* will assume core dump/seg fault if it doesn\'t work */
+- free(NULL);
+- return 0;
+-}], [AC_MSG_RESULT(yes)],
+- [AC_DEFINE(HAVE_NONULL_FREE, 1, [free does not accept NULL parameter])
+- AC_MSG_RESULT(no)])
+-
+-#A good time to save the cache (preload code might fail)
+-AC_CACHE_SAVE
+-
+ m4_include(preload.m4)
+
+ #construct SUBDIRS variable
+@@ -722,31 +649,8 @@ case $host in
+ ;;
+ esac
+
+-AC_MSG_CHECKING([for CMSG_SPACE in sys/socket.h])
+-AC_TRY_RUN([
+-#include <sys/types.h>
+-#include <sys/socket.h>
+-int main()
+-{
+- int d = CMSG_SPACE(4);
+- return 0;
+-}
+-], [AC_MSG_RESULT(yes)
+- AC_DEFINE(HAVE_CMSG_SPACE, 1, CMSG_SPACE exists)],
+- [AC_MSG_RESULT(no)])
+-
+-AC_MSG_CHECKING([for CMSG_LEN in sys/socket.h])
+-AC_TRY_RUN([
+-#include <sys/types.h>
+-#include <sys/socket.h>
+-
+-int main()
+-{
+- int d = CMSG_LEN(4);
+- return 0;
+-}], [AC_MSG_RESULT(yes)
+- AC_DEFINE(HAVE_CMSG_LEN, 1, [CMSG_LEN exists])],
+- [AC_MSG_RESULT(no)])
++AC_DEFINE(HAVE_CMSG_SPACE, 1, [CMSG_SPACE exists])
++AC_DEFINE(HAVE_CMSG_LEN, 1, [CMSG_LEN exists])
+
+ AC_MSG_CHECKING([for sa_len in sockaddr])
+ AC_TRY_COMPILE([
+@@ -913,10 +817,6 @@ else
+ AC_MSG_RESULT([yes])
+ fi
+
+-dnl determine GSSAPI support
+-no_gssapi=t
+-m4_include(gssapi.m4)
+-
+ dnl compatibility library tests
+ m4_include(libscompat.m4)
+
+@@ -978,15 +878,6 @@ global:
+ fi
+ AC_SUBST(MAPOPT)
+
+-#expected select behaviour?
+-unset nb_select_err
+-L_UNCON_SELECT([],
+- [nb_select_err=t])
+-
+-if test x"${nb_select_err}" = xt; then
+- AC_MSG_WARN([operations on nonblocking sockets might fail on this platform])
+-fi
+-
+ AC_MSG_CHECKING([direct route fallback in client enabled])
+ with_drtfallback=t
+ AC_ARG_ENABLE(drt-fallback,
+--- a/acinclude.m4
++++ b/acinclude.m4
+@@ -180,63 +180,7 @@ selectcheck(s)
+ [AC_MSG_RESULT(no)
+ [$2]])])
+
+-#can it really be this simple?
+-#nope, doesn't handle coff files which also have no underscore
+-AC_DEFUN([L_SYMBOL_UNDERSCORE],
+-[AC_MSG_CHECKING(for object file type)
+-AH_TEMPLATE([HAVE_NO_SYMBOL_UNDERSCORE], [platform symbol type])
+-AC_TRY_RUN([
+-/* look for ELF identification header at the start of argv[0] */
+-
+-#include <stdio.h>
+-#include <fcntl.h>
+-#include <string.h>
+-
+-/*
+- * ELF header, from ELF standard (Portable Formats Specification,
+- * Version 1.1).
+- */
+-char elfheader[] = { 0x7f, 'E', 'L', 'F' };
+-
+-int
+-main (argc, argv)
+- int argc;
+- char *argv[];
+-{
+- int fd;
+- int len = sizeof(elfheader);
+- char header[len];
+-
+- if ((fd = open(argv[0], O_RDONLY, 0)) == -1) {
+- perror("open");
+- exit(1);
+- }
+- if (read(fd, header, len) != len) {
+- perror("read");
+- exit(1);
+- }
+- if (memcmp(header, elfheader, len) == 0)
+- exit(0); /* pointy ears */
+- else
+- exit(1);
+-}
+-], [AC_MSG_RESULT(elf)
+- AC_DEFINE(HAVE_NO_SYMBOL_UNDERSCORE)],
+- [
+- #XXX exceptions for coff platforms, should be detected automatically
+- case $host in
+- alpha*-dec-osf*)
+- AC_DEFINE(HAVE_NO_SYMBOL_UNDERSCORE)
+- AC_MSG_RESULT(coff)
+- ;;
+- *-*-hpux*) #XXX apparently does not use underscore
+- AC_DEFINE(HAVE_NO_SYMBOL_UNDERSCORE)
+- AC_MSG_RESULT(a.out?)
+- ;;
+- *)
+- AC_MSG_RESULT(a.out)
+- ;;
+- esac])])
++AC_DEFUN([L_SYMBOL_UNDERSCORE], [AC_DEFINE(HAVE_NO_SYMBOL_UNDERSCORE, [1], [Automake sucks])])
+
+
+ dnl addproto - generate AC_DEFINE statements
+--- a/preload.m4
++++ b/preload.m4
+@@ -517,91 +517,6 @@ AC_DEFINE_UNQUOTED(LIBRARY_LIBC, "${LIBC
+
+ L_SYMBOL_UNDERSCORE()
+
+-AC_MSG_CHECKING([for working dlsym])
+-AC_TRY_RUN([
+-#include <dlfcn.h>
+-#include <stdio.h>
+-
+-#include "include/symbols.h"
+-
+-int main()
+-{
+- void *lib;
+- void *sym;
+-
+- if ((lib = dlopen(LIBRARY_CONNECT, DL_LAZY)) == NULL) {
+- fprintf(stderr, "dlopen: %s", dlerror());
+- return 1;
+- }
+- (void)dlerror();
+- if ((sym = dlsym(lib, SYMBOL_CONNECT)) == NULL) {
+- fprintf(stderr, "dlsym: %s", dlerror());
+- return 1;
+- }
+- return 0;
+-}], [AC_MSG_RESULT(yes)],
+- [AC_MSG_RESULT(no)
+- no_preload_client=t
+- no_preload_server=t
+- no_preload=t])
+-
+-AC_MSG_CHECKING([for working RTLD_NEXT])
+-AC_TRY_RUN([
+-#define _GNU_SOURCE
+-#include <dlfcn.h>
+-#include <stdio.h>
+-
+-#include "include/symbols.h"
+-
+-int main()
+-{
+- void *sym;
+-
+- if ((sym = dlsym(RTLD_NEXT, SYMBOL_READ)) == NULL) {
+- fprintf(stderr, "dlsym: %s", dlerror());
+- return 1;
+- }
+- return 0;
+-}], [AC_MSG_RESULT(yes)
+- AC_DEFINE(HAVE_RTLD_NEXT, 1, [have working dlsym RTLD_NEXT])],
+- [AC_MSG_RESULT(no)
+- AC_DEFINE(HAVE_RTLD_NEXT, 0, [no working dlsym RTLD_NEXT])])
+-
+-#solaris might block preloading
+-AC_MSG_CHECKING([libc preload blocking])
+-AC_TRY_RUN([
+-#include <stdlib.h>
+-#include <string.h>
+-#include <unistd.h>
+-int
+-main(int argc, char *argv[])
+-{
+- char buf[1024];
+-
+- strcpy(buf, "lari -V ");
+- strcat(buf, argv[0]);
+- strcat(buf, " | grep read | grep protected > /dev/null");
+-
+- /*
+- * return error if 'protected'
+- * (ignore errors, not indicative of blocking) */
+- if (system(buf) == 0)
+- return 1;
+- else
+- return 0;
+-}
+-
+-ssize_t
+-read(d, buf, nbytes)
+- int d;
+- void *buf;
+- size_t nbytes;
+-{
+- return 0;
+-}
+-], [AC_MSG_RESULT(no)],
+- [AC_MSG_RESULT(yes)
+- AC_MSG_WARN([this platform blocks preloading of libraries])
+- blocked_preload=t])
++AC_DEFINE(HAVE_RTLD_NEXT, 1, [have working dlsym RTLD_NEXT])
+
+ AC_CONFIG_FILES(bin/socksify)
+--- a/libscompat.m4
++++ b/libscompat.m4
+@@ -1,70 +1,6 @@
+ dnl libscompat.m4 - tests related to replacement code in libscompat directory
+
+-AC_MSG_CHECKING([for __attribute__ support])
+-AC_TRY_RUN([
+-#include <stdlib.h>
+-
+-void errfunc(void) __attribute((noreturn));
+-
+-void errfunc(void)
+-{
+- exit(0);
+-}
+-
+-int main()
+-{
+- errfunc();
+-}], [AC_MSG_RESULT([yes])],
+- [AC_MSG_RESULT([no])
+- AC_DEFINE(__attribute__(a), , [empty __attribute__ macro])])
+-
+-AC_MSG_CHECKING([for __printf__ attribute support])
+-if test x"$have_suncc" = xt; then
+- AC_MSG_RESULT([disabled for sun cc])
+- AC_DEFINE(format(a,b,c), , [empty format attribute macro])
+-else
+- AC_TRY_RUN([
+-#include <stdlib.h>
+-
+-void func(const char *fmt, ...)
+- __attribute__((format(__printf__, 1, 2)));
+-
+-void func(const char *fmt, ...) {
+- (void)fmt;
+- return;
+-}
+-
+-int main()
+-{
+- func("foo");
+- return 0;
+-}], [AC_MSG_RESULT([yes])],
+- [AC_MSG_RESULT([no])
+- AC_DEFINE(format(a,b,c), , [empty format attribute macro])])
+-fi
+-
+-AC_MSG_CHECKING([for timer macros])
+-AC_TRY_RUN([
+-#include <sys/time.h>
+-
+-int main()
+-{
+- struct timeval tv, tv2, tv3;
+-
+- tv.tv_sec = 0;
+- tv.tv_usec = 0;
+- tv2.tv_sec = 0;
+- tv2.tv_usec = 0;
+- tv3.tv_sec = 0;
+- tv3.tv_usec = 0;
+-
+- timeradd(&tv, &tv2, &tv3);
+- timersub(&tv3, &tv2, &tv);
+-
+- return 0; }],
+-[AC_MSG_RESULT(yes)
+- AC_DEFINE(HAVE_TIMER_MACROS, 1, [timeradd(), timersub etc. exist in sys/time.h])],
+-[AC_MSG_RESULT(no)])
++AC_DEFINE(HAVE_TIMER_MACROS, 1, [timeradd(), timersub etc. exist in sys/time.h])
+
+ AC_CHECK_FUNCS(daemon difftime getifaddrs freeifaddrs hstrerror inet_aton)
+ AC_CHECK_FUNCS(inet_pton issetugid memmove seteuid setegid)
+@@ -72,53 +8,7 @@ AC_CHECK_FUNCS(setproctitle sockatmark s
+ AC_CHECK_FUNCS(bzero)
+ #inet_ntoa - only checked for incorrect behavior
+
+-#try to detect gcc bug (irix 64 problem, affects among others inet_ntoa)
+-AC_MSG_CHECKING([for incorrect inet_ntoa behaviour])
+-AC_TRY_RUN([
+-#include <sys/types.h>
+-#include <netinet/in.h>
+-#include <arpa/inet.h>
+-#include <sys/socket.h>
+-int main(void)
+-{
+- struct sockaddr_in addr;
+- char *a, *b = "195.195.195.195";
+- addr.sin_addr.s_addr = inet_addr(b);
+- a = inet_ntoa(addr.sin_addr);
+- if (strcmp(a, b) == 0)
+- return 1;
+- else
+- return 0;
+-}
+-], [AC_DEFINE(HAVE_BROKEN_INET_NTOA, 1, [platform bug])
+- AC_MSG_RESULT(yes)
+- ac_cv_func_inet_ntoa=no],
+- AC_MSG_RESULT(no))
+-
+-if test x${ac_cv_func_sockatmark} = xyes; then
+- AC_MSG_CHECKING([for working sockatmark])
+- AC_TRY_RUN([
+-#include <sys/types.h>
+-#include <sys/socket.h>
+-
+-int
+-main()
+-{
+- int s;
+- int r;
+-
+- if ((s = socket(PF_UNIX, SOCK_STREAM, 0)) == -1)
+- return 1;
+- if ((r = sockatmark(s)) == -1)
+- return 1;
+- if (r == 0)
+- return 0;
+- else
+- return 1; /* would likely indicate an error */
+-}], [AC_MSG_RESULT(yes)],
+- [AC_MSG_RESULT(no)
+- ac_cv_func_sockatmark=no])
+-fi
++ac_cv_func_sockatmark=no
+
+ #only compile files that are needed
+ unset LIBSCSRC
+@@ -139,24 +29,3 @@ AC_SUBST([LIBSCSRC])
+ if test x${ac_cv_func_bzero} = xno; then
+ AC_DEFINE(bzero(b, len), memset((b), 0, (len)), [bzero replacement])
+ fi
+-
+-#causes problems with packaging, allow test to be turned off
+-AC_ARG_WITH(glibc-secure,
+-[ --without-glibc-secure disable libc_enable_secure check @<:@default=detect@:>@],
+-[GLIBCSEC=$withval])
+-
+-if test "${GLIBCSEC}" != no; then
+- AC_MSG_CHECKING([for __libc_enable_secure])
+- AC_TRY_RUN([
+-extern int __libc_enable_secure;
+-
+-int main()
+-{
+- if (__libc_enable_secure == 0)
+- return 0;
+-
+- return 1;
+-}],[AC_MSG_RESULT([yes])
+- AC_DEFINE(HAVE_LIBC_ENABLE_SECURE, 1, [linux version of issetugid()])],
+- AC_MSG_RESULT([no]))
+-fi
diff --git a/package/network/utils/dante/patches/.svn/text-base/100-do-not-use-defdname.patch.svn-base b/package/network/utils/dante/patches/.svn/text-base/100-do-not-use-defdname.patch.svn-base
new file mode 100644
index 0000000..37b91a9
--- /dev/null
+++ b/package/network/utils/dante/patches/.svn/text-base/100-do-not-use-defdname.patch.svn-base
@@ -0,0 +1,42 @@
+--- a/lib/addressmatch.c
++++ b/lib/addressmatch.c
+@@ -399,18 +399,6 @@ addrmatch(rule, address, protocol, alias
+ if (hostareeq(rule->addr.domain, hostent->h_name)
+ || hostisinlist(rule->addr.domain, (const char **)hostent->h_aliases))
+ matched = 1;
+-#if !HAVE_NO_RESOLVESTUFF
+- else if (strchr(hostent->h_name, '.') == NULL) {
+- /* if hostname we got is non-qualified, try to qualify it. */
+- char fqdn[MAXHOSTNAMELEN];
+-
+- snprintf(fqdn, sizeof(fqdn), "%s.%s",
+- hostent->h_name, _res.defdname);
+-
+- if (hostareeq(rule->addr.domain, fqdn))
+- matched = 1;
+- }
+-#endif /* !HAVE_NO_RESOLVESTUFF */
+ }
+
+ if (!matched && alias) {
+@@ -465,20 +453,6 @@ addrmatch(rule, address, protocol, alias
+ matched = 1;
+ break;
+ }
+-#if !HAVE_NO_RESOLVESTUFF
+- else if (strchr(ip->h_name, '.') == NULL) {
+- /* if hostname we got is non-qualified, try to qualify it. */
+- char fqdn[MAXHOSTNAMELEN];
+-
+- snprintf(fqdn, sizeof(fqdn), "%s.%s",
+- ip->h_name, _res.defdname);
+-
+- if (hostareeq(rule->addr.domain, fqdn)) {
+- matched = 1;
+- break;
+- }
+- }
+-#endif /* !HAVE_NO_RESOLVESTUFF */
+ }
+
+ hostentfree(host);
diff --git a/package/network/utils/dante/patches/.svn/text-base/200-fix-RTLD_NEXT.patch.svn-base b/package/network/utils/dante/patches/.svn/text-base/200-fix-RTLD_NEXT.patch.svn-base
new file mode 100644
index 0000000..7281ba6
--- /dev/null
+++ b/package/network/utils/dante/patches/.svn/text-base/200-fix-RTLD_NEXT.patch.svn-base
@@ -0,0 +1,36 @@
+--- a/lib/address.c
++++ b/lib/address.c
+@@ -45,11 +45,12 @@
+
+ #include "interposition.h"
+
+-#ifndef __USE_GNU
+-#define __USE_GNU /* XXX for RTLD_NEXT on Linux */
+-#endif /* !__USE_GNU */
+ #include <dlfcn.h>
+
++#ifndef RTLD_NEXT
++#define RTLD_NEXT ((void *) -1l)
++#endif
++
+ static const char rcsid[] =
+ "$Id: address.c,v 1.177.2.2 2010/05/24 16:38:36 karls Exp $";
+
+--- a/dlib/interposition.c
++++ b/dlib/interposition.c
+@@ -66,11 +66,12 @@ sendto(HAVE_PROT_SENDTO_1, HAVE_PROT_SEN
+ HAVE_PROT_SENDTO_4, HAVE_PROT_SENDTO_5, HAVE_PROT_SENDTO_6);
+ #endif
+
+-#ifndef __USE_GNU
+-#define __USE_GNU /* XXX for RTLD_NEXT on Linux */
+-#endif /* !__USE_GNU */
+ #include <dlfcn.h>
+
++#ifndef RTLD_NEXT
++#define RTLD_NEXT ((void *) -1l)
++#endif
++
+ #undef accept
+ #undef bind
+ #undef bindresvport
diff --git a/package/network/utils/dante/patches/001-automake-compat.patch b/package/network/utils/dante/patches/001-automake-compat.patch
new file mode 100644
index 0000000..4349a4b
--- /dev/null
+++ b/package/network/utils/dante/patches/001-automake-compat.patch
@@ -0,0 +1,482 @@
+--- a/configure.ac
++++ b/configure.ac
+@@ -16,7 +16,7 @@ echo "Configuring Dante ${version}${pren
+
+ AM_INIT_AUTOMAKE(dante, ${version}${prename})
+ AC_CONFIG_SRCDIR(include/common.h)
+-AM_CONFIG_HEADER(include/autoconf.h)
++AM_CONFIG_HEADER(autoconfig-is-soo-stupid.h include/autoconf.h)
+
+ AC_DEFINE(BAREFOOTD, 0, [we are Dante])
+
+@@ -38,17 +38,6 @@ AC_PROG_CPP
+
+ AM_CONDITIONAL(PRERELEASE, test x$prerelease != x)
+
+-#known keywords for --enable/disable-foo(=yes/no)?
+-LTINTERNAL="dlopen|dlopen_self|dlopen_self_static|fast_install|libtool_lock|win32_dll|shared_with_static_runtimes|shared_with_static_runtimes_CXX|shared_with_static_runtimes_F77"
+-KNOWN_KEYWORDS="$LTINTERNAL|shared|static|debug|warnings|diagnostic|profiling|linting|libwrap|preload|serverdl|clientdl|internal|pidfile|drt_fallback"
+-for keyword in `set | egrep '^enable_' | sed -e 's/^enable_\(.*\)=.*/\1/'`; do
+- echo $keyword | egrep "^(${KNOWN_KEYWORDS})$" > /dev/null
+- if test $? -ne 0; then
+- AC_MSG_WARN([unknown option '$keyword', ignoring ...])
+- sleep 10;
+- fi
+-done
+-
+ case $host in
+ *-*-osf*)
+ AC_MSG_WARN([OSF support might be removed in the near future.])
+@@ -175,31 +164,6 @@ case $host in
+ #XXX make sure compiling with compiler options works
+ esac
+
+-AC_MSG_CHECKING([for support for -pipe compiler flag])
+-oCFLAGS=$CFLAGS
+-CFLAGS="$CFLAGS -pipe"
+-AC_TRY_RUN([
+-int main()
+-{
+- return 0;
+-}], [AC_MSG_RESULT([yes])
+- comp_flags="${comp_flags} -pipe"],
+- AC_MSG_RESULT([no]))
+-CFLAGS="$oCFLAGS"
+-
+-AC_MSG_CHECKING([for support for -Wbounded compiler flag])
+-oCFLAGS=$CFLAGS
+-CFLAGS="$CFLAGS -Wbounded"
+-AC_TRY_RUN([
+-int main()
+-{
+- return 0;
+-}], [AC_MSG_RESULT([yes])
+- comp_flags="${comp_flags} -Wbounded"],
+- [AC_MSG_RESULT([no])
+- AC_DEFINE(__bounded__(a,b,c), , [empty __bounded__ macro])])
+-CFLAGS="$oCFLAGS"
+-
+ AC_MSG_CHECKING([for compilation with debugging])
+ AC_ARG_ENABLE(debug,
+ [ --enable-debug compile with debugging support],
+@@ -608,43 +572,6 @@ else
+ fi], [AC_MSG_RESULT(no)
+ AC_MSG_WARN([performance in the server might be degraded without support for the SO_SNDLOWAT socket option])])
+
+-AC_MSG_CHECKING([whether realloc with a NULL pointer calls malloc])
+-AC_TRY_RUN([
+-#include <stdlib.h>
+-#ifndef NULL
+-#define NULL (char *)0
+-#endif
+-
+-int main()
+-{
+- /* will assume this test doesn\'t fail because of lack of memory */
+- if (realloc(NULL, 1) == NULL)
+- return 1;
+- else
+- return 0;
+-}], [AC_MSG_RESULT(yes)],
+- [AC_DEFINE(HAVE_NOMALLOC_REALLOC, 1, [realloc never calls malloc])
+- AC_MSG_RESULT(no)])
+-
+-AC_MSG_CHECKING([whether free can be called with NULL])
+-AC_TRY_RUN([
+-#include <stdlib.h>
+-#ifndef NULL
+-#define NULL (char *)0
+-#endif
+-
+-int main()
+-{
+- /* will assume core dump/seg fault if it doesn\'t work */
+- free(NULL);
+- return 0;
+-}], [AC_MSG_RESULT(yes)],
+- [AC_DEFINE(HAVE_NONULL_FREE, 1, [free does not accept NULL parameter])
+- AC_MSG_RESULT(no)])
+-
+-#A good time to save the cache (preload code might fail)
+-AC_CACHE_SAVE
+-
+ m4_include(preload.m4)
+
+ #construct SUBDIRS variable
+@@ -722,31 +649,8 @@ case $host in
+ ;;
+ esac
+
+-AC_MSG_CHECKING([for CMSG_SPACE in sys/socket.h])
+-AC_TRY_RUN([
+-#include <sys/types.h>
+-#include <sys/socket.h>
+-int main()
+-{
+- int d = CMSG_SPACE(4);
+- return 0;
+-}
+-], [AC_MSG_RESULT(yes)
+- AC_DEFINE(HAVE_CMSG_SPACE, 1, CMSG_SPACE exists)],
+- [AC_MSG_RESULT(no)])
+-
+-AC_MSG_CHECKING([for CMSG_LEN in sys/socket.h])
+-AC_TRY_RUN([
+-#include <sys/types.h>
+-#include <sys/socket.h>
+-
+-int main()
+-{
+- int d = CMSG_LEN(4);
+- return 0;
+-}], [AC_MSG_RESULT(yes)
+- AC_DEFINE(HAVE_CMSG_LEN, 1, [CMSG_LEN exists])],
+- [AC_MSG_RESULT(no)])
++AC_DEFINE(HAVE_CMSG_SPACE, 1, [CMSG_SPACE exists])
++AC_DEFINE(HAVE_CMSG_LEN, 1, [CMSG_LEN exists])
+
+ AC_MSG_CHECKING([for sa_len in sockaddr])
+ AC_TRY_COMPILE([
+@@ -913,10 +817,6 @@ else
+ AC_MSG_RESULT([yes])
+ fi
+
+-dnl determine GSSAPI support
+-no_gssapi=t
+-m4_include(gssapi.m4)
+-
+ dnl compatibility library tests
+ m4_include(libscompat.m4)
+
+@@ -978,15 +878,6 @@ global:
+ fi
+ AC_SUBST(MAPOPT)
+
+-#expected select behaviour?
+-unset nb_select_err
+-L_UNCON_SELECT([],
+- [nb_select_err=t])
+-
+-if test x"${nb_select_err}" = xt; then
+- AC_MSG_WARN([operations on nonblocking sockets might fail on this platform])
+-fi
+-
+ AC_MSG_CHECKING([direct route fallback in client enabled])
+ with_drtfallback=t
+ AC_ARG_ENABLE(drt-fallback,
+--- a/acinclude.m4
++++ b/acinclude.m4
+@@ -180,63 +180,7 @@ selectcheck(s)
+ [AC_MSG_RESULT(no)
+ [$2]])])
+
+-#can it really be this simple?
+-#nope, doesn't handle coff files which also have no underscore
+-AC_DEFUN([L_SYMBOL_UNDERSCORE],
+-[AC_MSG_CHECKING(for object file type)
+-AH_TEMPLATE([HAVE_NO_SYMBOL_UNDERSCORE], [platform symbol type])
+-AC_TRY_RUN([
+-/* look for ELF identification header at the start of argv[0] */
+-
+-#include <stdio.h>
+-#include <fcntl.h>
+-#include <string.h>
+-
+-/*
+- * ELF header, from ELF standard (Portable Formats Specification,
+- * Version 1.1).
+- */
+-char elfheader[] = { 0x7f, 'E', 'L', 'F' };
+-
+-int
+-main (argc, argv)
+- int argc;
+- char *argv[];
+-{
+- int fd;
+- int len = sizeof(elfheader);
+- char header[len];
+-
+- if ((fd = open(argv[0], O_RDONLY, 0)) == -1) {
+- perror("open");
+- exit(1);
+- }
+- if (read(fd, header, len) != len) {
+- perror("read");
+- exit(1);
+- }
+- if (memcmp(header, elfheader, len) == 0)
+- exit(0); /* pointy ears */
+- else
+- exit(1);
+-}
+-], [AC_MSG_RESULT(elf)
+- AC_DEFINE(HAVE_NO_SYMBOL_UNDERSCORE)],
+- [
+- #XXX exceptions for coff platforms, should be detected automatically
+- case $host in
+- alpha*-dec-osf*)
+- AC_DEFINE(HAVE_NO_SYMBOL_UNDERSCORE)
+- AC_MSG_RESULT(coff)
+- ;;
+- *-*-hpux*) #XXX apparently does not use underscore
+- AC_DEFINE(HAVE_NO_SYMBOL_UNDERSCORE)
+- AC_MSG_RESULT(a.out?)
+- ;;
+- *)
+- AC_MSG_RESULT(a.out)
+- ;;
+- esac])])
++AC_DEFUN([L_SYMBOL_UNDERSCORE], [AC_DEFINE(HAVE_NO_SYMBOL_UNDERSCORE, [1], [Automake sucks])])
+
+
+ dnl addproto - generate AC_DEFINE statements
+--- a/preload.m4
++++ b/preload.m4
+@@ -517,91 +517,6 @@ AC_DEFINE_UNQUOTED(LIBRARY_LIBC, "${LIBC
+
+ L_SYMBOL_UNDERSCORE()
+
+-AC_MSG_CHECKING([for working dlsym])
+-AC_TRY_RUN([
+-#include <dlfcn.h>
+-#include <stdio.h>
+-
+-#include "include/symbols.h"
+-
+-int main()
+-{
+- void *lib;
+- void *sym;
+-
+- if ((lib = dlopen(LIBRARY_CONNECT, DL_LAZY)) == NULL) {
+- fprintf(stderr, "dlopen: %s", dlerror());
+- return 1;
+- }
+- (void)dlerror();
+- if ((sym = dlsym(lib, SYMBOL_CONNECT)) == NULL) {
+- fprintf(stderr, "dlsym: %s", dlerror());
+- return 1;
+- }
+- return 0;
+-}], [AC_MSG_RESULT(yes)],
+- [AC_MSG_RESULT(no)
+- no_preload_client=t
+- no_preload_server=t
+- no_preload=t])
+-
+-AC_MSG_CHECKING([for working RTLD_NEXT])
+-AC_TRY_RUN([
+-#define _GNU_SOURCE
+-#include <dlfcn.h>
+-#include <stdio.h>
+-
+-#include "include/symbols.h"
+-
+-int main()
+-{
+- void *sym;
+-
+- if ((sym = dlsym(RTLD_NEXT, SYMBOL_READ)) == NULL) {
+- fprintf(stderr, "dlsym: %s", dlerror());
+- return 1;
+- }
+- return 0;
+-}], [AC_MSG_RESULT(yes)
+- AC_DEFINE(HAVE_RTLD_NEXT, 1, [have working dlsym RTLD_NEXT])],
+- [AC_MSG_RESULT(no)
+- AC_DEFINE(HAVE_RTLD_NEXT, 0, [no working dlsym RTLD_NEXT])])
+-
+-#solaris might block preloading
+-AC_MSG_CHECKING([libc preload blocking])
+-AC_TRY_RUN([
+-#include <stdlib.h>
+-#include <string.h>
+-#include <unistd.h>
+-int
+-main(int argc, char *argv[])
+-{
+- char buf[1024];
+-
+- strcpy(buf, "lari -V ");
+- strcat(buf, argv[0]);
+- strcat(buf, " | grep read | grep protected > /dev/null");
+-
+- /*
+- * return error if 'protected'
+- * (ignore errors, not indicative of blocking) */
+- if (system(buf) == 0)
+- return 1;
+- else
+- return 0;
+-}
+-
+-ssize_t
+-read(d, buf, nbytes)
+- int d;
+- void *buf;
+- size_t nbytes;
+-{
+- return 0;
+-}
+-], [AC_MSG_RESULT(no)],
+- [AC_MSG_RESULT(yes)
+- AC_MSG_WARN([this platform blocks preloading of libraries])
+- blocked_preload=t])
++AC_DEFINE(HAVE_RTLD_NEXT, 1, [have working dlsym RTLD_NEXT])
+
+ AC_CONFIG_FILES(bin/socksify)
+--- a/libscompat.m4
++++ b/libscompat.m4
+@@ -1,70 +1,6 @@
+ dnl libscompat.m4 - tests related to replacement code in libscompat directory
+
+-AC_MSG_CHECKING([for __attribute__ support])
+-AC_TRY_RUN([
+-#include <stdlib.h>
+-
+-void errfunc(void) __attribute((noreturn));
+-
+-void errfunc(void)
+-{
+- exit(0);
+-}
+-
+-int main()
+-{
+- errfunc();
+-}], [AC_MSG_RESULT([yes])],
+- [AC_MSG_RESULT([no])
+- AC_DEFINE(__attribute__(a), , [empty __attribute__ macro])])
+-
+-AC_MSG_CHECKING([for __printf__ attribute support])
+-if test x"$have_suncc" = xt; then
+- AC_MSG_RESULT([disabled for sun cc])
+- AC_DEFINE(format(a,b,c), , [empty format attribute macro])
+-else
+- AC_TRY_RUN([
+-#include <stdlib.h>
+-
+-void func(const char *fmt, ...)
+- __attribute__((format(__printf__, 1, 2)));
+-
+-void func(const char *fmt, ...) {
+- (void)fmt;
+- return;
+-}
+-
+-int main()
+-{
+- func("foo");
+- return 0;
+-}], [AC_MSG_RESULT([yes])],
+- [AC_MSG_RESULT([no])
+- AC_DEFINE(format(a,b,c), , [empty format attribute macro])])
+-fi
+-
+-AC_MSG_CHECKING([for timer macros])
+-AC_TRY_RUN([
+-#include <sys/time.h>
+-
+-int main()
+-{
+- struct timeval tv, tv2, tv3;
+-
+- tv.tv_sec = 0;
+- tv.tv_usec = 0;
+- tv2.tv_sec = 0;
+- tv2.tv_usec = 0;
+- tv3.tv_sec = 0;
+- tv3.tv_usec = 0;
+-
+- timeradd(&tv, &tv2, &tv3);
+- timersub(&tv3, &tv2, &tv);
+-
+- return 0; }],
+-[AC_MSG_RESULT(yes)
+- AC_DEFINE(HAVE_TIMER_MACROS, 1, [timeradd(), timersub etc. exist in sys/time.h])],
+-[AC_MSG_RESULT(no)])
++AC_DEFINE(HAVE_TIMER_MACROS, 1, [timeradd(), timersub etc. exist in sys/time.h])
+
+ AC_CHECK_FUNCS(daemon difftime getifaddrs freeifaddrs hstrerror inet_aton)
+ AC_CHECK_FUNCS(inet_pton issetugid memmove seteuid setegid)
+@@ -72,53 +8,7 @@ AC_CHECK_FUNCS(setproctitle sockatmark s
+ AC_CHECK_FUNCS(bzero)
+ #inet_ntoa - only checked for incorrect behavior
+
+-#try to detect gcc bug (irix 64 problem, affects among others inet_ntoa)
+-AC_MSG_CHECKING([for incorrect inet_ntoa behaviour])
+-AC_TRY_RUN([
+-#include <sys/types.h>
+-#include <netinet/in.h>
+-#include <arpa/inet.h>
+-#include <sys/socket.h>
+-int main(void)
+-{
+- struct sockaddr_in addr;
+- char *a, *b = "195.195.195.195";
+- addr.sin_addr.s_addr = inet_addr(b);
+- a = inet_ntoa(addr.sin_addr);
+- if (strcmp(a, b) == 0)
+- return 1;
+- else
+- return 0;
+-}
+-], [AC_DEFINE(HAVE_BROKEN_INET_NTOA, 1, [platform bug])
+- AC_MSG_RESULT(yes)
+- ac_cv_func_inet_ntoa=no],
+- AC_MSG_RESULT(no))
+-
+-if test x${ac_cv_func_sockatmark} = xyes; then
+- AC_MSG_CHECKING([for working sockatmark])
+- AC_TRY_RUN([
+-#include <sys/types.h>
+-#include <sys/socket.h>
+-
+-int
+-main()
+-{
+- int s;
+- int r;
+-
+- if ((s = socket(PF_UNIX, SOCK_STREAM, 0)) == -1)
+- return 1;
+- if ((r = sockatmark(s)) == -1)
+- return 1;
+- if (r == 0)
+- return 0;
+- else
+- return 1; /* would likely indicate an error */
+-}], [AC_MSG_RESULT(yes)],
+- [AC_MSG_RESULT(no)
+- ac_cv_func_sockatmark=no])
+-fi
++ac_cv_func_sockatmark=no
+
+ #only compile files that are needed
+ unset LIBSCSRC
+@@ -139,24 +29,3 @@ AC_SUBST([LIBSCSRC])
+ if test x${ac_cv_func_bzero} = xno; then
+ AC_DEFINE(bzero(b, len), memset((b), 0, (len)), [bzero replacement])
+ fi
+-
+-#causes problems with packaging, allow test to be turned off
+-AC_ARG_WITH(glibc-secure,
+-[ --without-glibc-secure disable libc_enable_secure check @<:@default=detect@:>@],
+-[GLIBCSEC=$withval])
+-
+-if test "${GLIBCSEC}" != no; then
+- AC_MSG_CHECKING([for __libc_enable_secure])
+- AC_TRY_RUN([
+-extern int __libc_enable_secure;
+-
+-int main()
+-{
+- if (__libc_enable_secure == 0)
+- return 0;
+-
+- return 1;
+-}],[AC_MSG_RESULT([yes])
+- AC_DEFINE(HAVE_LIBC_ENABLE_SECURE, 1, [linux version of issetugid()])],
+- AC_MSG_RESULT([no]))
+-fi
diff --git a/package/network/utils/dante/patches/100-do-not-use-defdname.patch b/package/network/utils/dante/patches/100-do-not-use-defdname.patch
new file mode 100644
index 0000000..37b91a9
--- /dev/null
+++ b/package/network/utils/dante/patches/100-do-not-use-defdname.patch
@@ -0,0 +1,42 @@
+--- a/lib/addressmatch.c
++++ b/lib/addressmatch.c
+@@ -399,18 +399,6 @@ addrmatch(rule, address, protocol, alias
+ if (hostareeq(rule->addr.domain, hostent->h_name)
+ || hostisinlist(rule->addr.domain, (const char **)hostent->h_aliases))
+ matched = 1;
+-#if !HAVE_NO_RESOLVESTUFF
+- else if (strchr(hostent->h_name, '.') == NULL) {
+- /* if hostname we got is non-qualified, try to qualify it. */
+- char fqdn[MAXHOSTNAMELEN];
+-
+- snprintf(fqdn, sizeof(fqdn), "%s.%s",
+- hostent->h_name, _res.defdname);
+-
+- if (hostareeq(rule->addr.domain, fqdn))
+- matched = 1;
+- }
+-#endif /* !HAVE_NO_RESOLVESTUFF */
+ }
+
+ if (!matched && alias) {
+@@ -465,20 +453,6 @@ addrmatch(rule, address, protocol, alias
+ matched = 1;
+ break;
+ }
+-#if !HAVE_NO_RESOLVESTUFF
+- else if (strchr(ip->h_name, '.') == NULL) {
+- /* if hostname we got is non-qualified, try to qualify it. */
+- char fqdn[MAXHOSTNAMELEN];
+-
+- snprintf(fqdn, sizeof(fqdn), "%s.%s",
+- ip->h_name, _res.defdname);
+-
+- if (hostareeq(rule->addr.domain, fqdn)) {
+- matched = 1;
+- break;
+- }
+- }
+-#endif /* !HAVE_NO_RESOLVESTUFF */
+ }
+
+ hostentfree(host);
diff --git a/package/network/utils/dante/patches/200-fix-RTLD_NEXT.patch b/package/network/utils/dante/patches/200-fix-RTLD_NEXT.patch
new file mode 100644
index 0000000..7281ba6
--- /dev/null
+++ b/package/network/utils/dante/patches/200-fix-RTLD_NEXT.patch
@@ -0,0 +1,36 @@
+--- a/lib/address.c
++++ b/lib/address.c
+@@ -45,11 +45,12 @@
+
+ #include "interposition.h"
+
+-#ifndef __USE_GNU
+-#define __USE_GNU /* XXX for RTLD_NEXT on Linux */
+-#endif /* !__USE_GNU */
+ #include <dlfcn.h>
+
++#ifndef RTLD_NEXT
++#define RTLD_NEXT ((void *) -1l)
++#endif
++
+ static const char rcsid[] =
+ "$Id: address.c,v 1.177.2.2 2010/05/24 16:38:36 karls Exp $";
+
+--- a/dlib/interposition.c
++++ b/dlib/interposition.c
+@@ -66,11 +66,12 @@ sendto(HAVE_PROT_SENDTO_1, HAVE_PROT_SEN
+ HAVE_PROT_SENDTO_4, HAVE_PROT_SENDTO_5, HAVE_PROT_SENDTO_6);
+ #endif
+
+-#ifndef __USE_GNU
+-#define __USE_GNU /* XXX for RTLD_NEXT on Linux */
+-#endif /* !__USE_GNU */
+ #include <dlfcn.h>
+
++#ifndef RTLD_NEXT
++#define RTLD_NEXT ((void *) -1l)
++#endif
++
+ #undef accept
+ #undef bind
+ #undef bindresvport
diff --git a/package/network/utils/ebtables/.svn/entries b/package/network/utils/ebtables/.svn/entries
new file mode 100644
index 0000000..4f23597
--- /dev/null
+++ b/package/network/utils/ebtables/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/utils/ebtables
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-10T12:32:29.935169Z
+33688
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+978ff9e92be71a15b019e4ff2bf626d1
+2012-06-11T00:56:34.742697Z
+32181
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1932
+
diff --git a/package/network/utils/ebtables/.svn/prop-base/Makefile.svn-base b/package/network/utils/ebtables/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..8e522ae
--- /dev/null
+++ b/package/network/utils/ebtables/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:copyright
+V 30
+Copyright (C) 2006 OpenWrt.org
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/utils/ebtables/.svn/text-base/Makefile.svn-base b/package/network/utils/ebtables/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..17c6b37
--- /dev/null
+++ b/package/network/utils/ebtables/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,71 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=ebtables
+PKG_VERSION:=2.0.10-4
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-v$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=@SF/ebtables
+PKG_MD5SUM:=506742a3d44b9925955425a659c1a8d0
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/ebtables-v$(PKG_VERSION)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/ebtables
+ SECTION:=net
+ CATEGORY:=Network
+ SUBMENU:=Firewall
+ DEPENDS:=+kmod-ebtables
+ TITLE:=Ethernet bridge firewall administration utility
+ URL:=http://ebtables.sourceforge.net/
+endef
+
+define Package/ebtables-utils
+ $(call Package/ebtables)
+ DEPENDS += ebtables
+ TITLE:=ebtables save/restore utilities
+endef
+
+define Package/ebtables/description
+ The ebtables program is a filtering tool for a bridging firewall. The
+ filtering is focussed on the Link Layer Ethernet frame fields. Apart
+ from filtering, it also gives the ability to alter the Ethernet MAC
+ addresses and implement a brouter.
+endef
+
+define Package/ebtables-utils/description
+ $(call Package/ebtables/description)
+endef
+
+MAKE_VARS += EXT_LIBSI="$(LIBGCC_S)"
+
+MAKE_FLAGS += \
+ CFLAGS="$(TARGET_CFLAGS)" \
+ LIBDIR="/usr/lib/ebtables"
+
+define Package/ebtables/install
+ $(INSTALL_DIR) $(1)/etc
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/ethertypes $(1)/etc/
+ $(INSTALL_DIR) $(1)/usr/lib/ebtables
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/lib*.so $(1)/usr/lib/
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/extensions/*.so $(1)/usr/lib/ebtables/
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/ebtables $(1)/usr/sbin/
+endef
+
+define Package/ebtables-utils/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/ebtables-save $(1)/usr/sbin/
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/ebtables-restore $(1)/usr/sbin/
+endef
+
+$(eval $(call BuildPackage,ebtables))
+$(eval $(call BuildPackage,ebtables-utils))
diff --git a/package/network/utils/ebtables/Makefile b/package/network/utils/ebtables/Makefile
new file mode 100644
index 0000000..17c6b37
--- /dev/null
+++ b/package/network/utils/ebtables/Makefile
@@ -0,0 +1,71 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=ebtables
+PKG_VERSION:=2.0.10-4
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-v$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=@SF/ebtables
+PKG_MD5SUM:=506742a3d44b9925955425a659c1a8d0
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/ebtables-v$(PKG_VERSION)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/ebtables
+ SECTION:=net
+ CATEGORY:=Network
+ SUBMENU:=Firewall
+ DEPENDS:=+kmod-ebtables
+ TITLE:=Ethernet bridge firewall administration utility
+ URL:=http://ebtables.sourceforge.net/
+endef
+
+define Package/ebtables-utils
+ $(call Package/ebtables)
+ DEPENDS += ebtables
+ TITLE:=ebtables save/restore utilities
+endef
+
+define Package/ebtables/description
+ The ebtables program is a filtering tool for a bridging firewall. The
+ filtering is focussed on the Link Layer Ethernet frame fields. Apart
+ from filtering, it also gives the ability to alter the Ethernet MAC
+ addresses and implement a brouter.
+endef
+
+define Package/ebtables-utils/description
+ $(call Package/ebtables/description)
+endef
+
+MAKE_VARS += EXT_LIBSI="$(LIBGCC_S)"
+
+MAKE_FLAGS += \
+ CFLAGS="$(TARGET_CFLAGS)" \
+ LIBDIR="/usr/lib/ebtables"
+
+define Package/ebtables/install
+ $(INSTALL_DIR) $(1)/etc
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/ethertypes $(1)/etc/
+ $(INSTALL_DIR) $(1)/usr/lib/ebtables
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/lib*.so $(1)/usr/lib/
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/extensions/*.so $(1)/usr/lib/ebtables/
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/ebtables $(1)/usr/sbin/
+endef
+
+define Package/ebtables-utils/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/ebtables-save $(1)/usr/sbin/
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/ebtables-restore $(1)/usr/sbin/
+endef
+
+$(eval $(call BuildPackage,ebtables))
+$(eval $(call BuildPackage,ebtables-utils))
diff --git a/package/network/utils/ifenslave/.svn/entries b/package/network/utils/ifenslave/.svn/entries
new file mode 100644
index 0000000..73120ac
--- /dev/null
+++ b/package/network/utils/ifenslave/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/utils/ifenslave
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-10T12:32:29.935169Z
+33688
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+7d899213033aa5d94b30f8682be556ba
+2010-06-26T20:44:28.317476Z
+21956
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+964
+
diff --git a/package/network/utils/ifenslave/.svn/prop-base/Makefile.svn-base b/package/network/utils/ifenslave/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..8e522ae
--- /dev/null
+++ b/package/network/utils/ifenslave/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:copyright
+V 30
+Copyright (C) 2006 OpenWrt.org
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/utils/ifenslave/.svn/text-base/Makefile.svn-base b/package/network/utils/ifenslave/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..5292e45
--- /dev/null
+++ b/package/network/utils/ifenslave/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,42 @@
+#
+# Copyright (C) 2006 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=ifenslave
+PKG_RELEASE:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/ifenslave
+ SECTION:=net
+ CATEGORY:=Network
+ DEPENDS:=+kmod-bonding
+ TITLE:=A utility to manipulate kernel ethernet bonding devices
+ VERSION:=$(LINUX_VERSION)-$(PKG_RELEASE)
+ URL:=http://www.kernel.org
+endef
+
+define Package/ifenslave/description
+ ifenslave is needed to add/remove interfaces to/from ethernet bond devices.
+endef
+
+define Build/Prepare
+endef
+
+define Build/Compile
+ $(TARGET_CC) $(TARGET_CFLAGS) -o $(PKG_BUILD_DIR)/ifenslave \
+ $(LINUX_DIR)/Documentation/networking/ifenslave.c
+endef
+
+define Package/ifenslave/install
+ $(INSTALL_DIR) $(1)/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/ifenslave $(1)/sbin/
+endef
+
+$(eval $(call BuildPackage,ifenslave))
diff --git a/package/network/utils/ifenslave/Makefile b/package/network/utils/ifenslave/Makefile
new file mode 100644
index 0000000..5292e45
--- /dev/null
+++ b/package/network/utils/ifenslave/Makefile
@@ -0,0 +1,42 @@
+#
+# Copyright (C) 2006 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=ifenslave
+PKG_RELEASE:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/ifenslave
+ SECTION:=net
+ CATEGORY:=Network
+ DEPENDS:=+kmod-bonding
+ TITLE:=A utility to manipulate kernel ethernet bonding devices
+ VERSION:=$(LINUX_VERSION)-$(PKG_RELEASE)
+ URL:=http://www.kernel.org
+endef
+
+define Package/ifenslave/description
+ ifenslave is needed to add/remove interfaces to/from ethernet bond devices.
+endef
+
+define Build/Prepare
+endef
+
+define Build/Compile
+ $(TARGET_CC) $(TARGET_CFLAGS) -o $(PKG_BUILD_DIR)/ifenslave \
+ $(LINUX_DIR)/Documentation/networking/ifenslave.c
+endef
+
+define Package/ifenslave/install
+ $(INSTALL_DIR) $(1)/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/ifenslave $(1)/sbin/
+endef
+
+$(eval $(call BuildPackage,ifenslave))
diff --git a/package/network/utils/iftop/.svn/entries b/package/network/utils/iftop/.svn/entries
new file mode 100644
index 0000000..219db66
--- /dev/null
+++ b/package/network/utils/iftop/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/utils/iftop
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-16T15:49:49.283145Z
+33782
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+e040fadfb56a66217105171aa3627115
+2012-10-16T15:49:49.283145Z
+33782
+florian
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1117
+
diff --git a/package/network/utils/iftop/.svn/prop-base/Makefile.svn-base b/package/network/utils/iftop/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..f899379
--- /dev/null
+++ b/package/network/utils/iftop/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,13 @@
+K 9
+copyright
+V 30
+Copyright (C) 2006 OpenWrt.org
+K 7
+licence
+V 5
+GPLv2
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/utils/iftop/.svn/text-base/Makefile.svn-base b/package/network/utils/iftop/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..b054ed1
--- /dev/null
+++ b/package/network/utils/iftop/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,42 @@
+#
+# Copyright (C) 2006 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=iftop
+PKG_VERSION:=1.0pre2
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://www.ex-parrot.com/~pdw/iftop/download
+PKG_MD5SUM:=fef521a49ec0122458d02c64212af3c5
+
+PKG_MAINTAINER:=Jo-Philipp Wich <jow@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/iftop
+ SECTION:=net
+ CATEGORY:=Network
+ DEPENDS:=+libpcap +libncurses +libpthread
+ TITLE:=display bandwith usage on an interface
+ URL:=http://www.ex-parrot.com/~pdw/iftop/
+endef
+
+define Package/iftop/description
+ iftop does for network usage what top(1) does for CPU usage. It
+ listens to network traffic on a named interface and displays a
+ table of current bandwidth usage by pairs of hosts. Handy for
+ answering the question 'why is our ADSL link so slow?'.
+endef
+
+define Package/iftop/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/iftop $(1)/usr/bin/
+endef
+
+$(eval $(call BuildPackage,iftop))
diff --git a/package/network/utils/iftop/Makefile b/package/network/utils/iftop/Makefile
new file mode 100644
index 0000000..b054ed1
--- /dev/null
+++ b/package/network/utils/iftop/Makefile
@@ -0,0 +1,42 @@
+#
+# Copyright (C) 2006 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=iftop
+PKG_VERSION:=1.0pre2
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://www.ex-parrot.com/~pdw/iftop/download
+PKG_MD5SUM:=fef521a49ec0122458d02c64212af3c5
+
+PKG_MAINTAINER:=Jo-Philipp Wich <jow@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/iftop
+ SECTION:=net
+ CATEGORY:=Network
+ DEPENDS:=+libpcap +libncurses +libpthread
+ TITLE:=display bandwith usage on an interface
+ URL:=http://www.ex-parrot.com/~pdw/iftop/
+endef
+
+define Package/iftop/description
+ iftop does for network usage what top(1) does for CPU usage. It
+ listens to network traffic on a named interface and displays a
+ table of current bandwidth usage by pairs of hosts. Handy for
+ answering the question 'why is our ADSL link so slow?'.
+endef
+
+define Package/iftop/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/iftop $(1)/usr/bin/
+endef
+
+$(eval $(call BuildPackage,iftop))
diff --git a/package/network/utils/iftop/patches/.svn/entries b/package/network/utils/iftop/patches/.svn/entries
new file mode 100644
index 0000000..9fb32b6
--- /dev/null
+++ b/package/network/utils/iftop/patches/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/utils/iftop/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-16T15:49:49.283145Z
+33782
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+0001-force-ncurses.patch
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+7c897897a53ff3bea3aca80ba0a5aad7
+2012-10-16T15:49:49.283145Z
+33782
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+555
+
diff --git a/package/network/utils/iftop/patches/.svn/text-base/0001-force-ncurses.patch.svn-base b/package/network/utils/iftop/patches/.svn/text-base/0001-force-ncurses.patch.svn-base
new file mode 100644
index 0000000..bf23fb4
--- /dev/null
+++ b/package/network/utils/iftop/patches/.svn/text-base/0001-force-ncurses.patch.svn-base
@@ -0,0 +1,12 @@
+diff -ru iftop-1.0pre2-old/configure iftop-1.0pre2/configure
+--- iftop-1.0pre2-old/configure 2011-10-04 13:30:30.000000000 -0700
++++ iftop-1.0pre2/configure 2012-09-09 22:26:05.000000000 -0700
+@@ -7568,7 +7568,7 @@
+ { $as_echo "$as_me:$LINENO: checking for a curses library containing mvchgat" >&5
+ $as_echo_n "checking for a curses library containing mvchgat... " >&6; }
+ oldLIBS=$LIBS
+-for curseslib in ncursesw curses ncurses ; do
++for curseslib in ncurses ; do
+ LIBS="$oldLIBS -l$curseslib"
+ cat >conftest.$ac_ext <<_ACEOF
+ /* confdefs.h. */
diff --git a/package/network/utils/iftop/patches/0001-force-ncurses.patch b/package/network/utils/iftop/patches/0001-force-ncurses.patch
new file mode 100644
index 0000000..bf23fb4
--- /dev/null
+++ b/package/network/utils/iftop/patches/0001-force-ncurses.patch
@@ -0,0 +1,12 @@
+diff -ru iftop-1.0pre2-old/configure iftop-1.0pre2/configure
+--- iftop-1.0pre2-old/configure 2011-10-04 13:30:30.000000000 -0700
++++ iftop-1.0pre2/configure 2012-09-09 22:26:05.000000000 -0700
+@@ -7568,7 +7568,7 @@
+ { $as_echo "$as_me:$LINENO: checking for a curses library containing mvchgat" >&5
+ $as_echo_n "checking for a curses library containing mvchgat... " >&6; }
+ oldLIBS=$LIBS
+-for curseslib in ncursesw curses ncurses ; do
++for curseslib in ncurses ; do
+ LIBS="$oldLIBS -l$curseslib"
+ cat >conftest.$ac_ext <<_ACEOF
+ /* confdefs.h. */
diff --git a/package/network/utils/iperf/.svn/entries b/package/network/utils/iperf/.svn/entries
new file mode 100644
index 0000000..9ee9465
--- /dev/null
+++ b/package/network/utils/iperf/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/utils/iperf
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-10T12:35:43.527799Z
+33691
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+6a63a06dd4b7fc440df89731ccbbd87f
+2012-10-10T12:35:43.527799Z
+33691
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2131
+
diff --git a/package/network/utils/iperf/.svn/prop-base/Makefile.svn-base b/package/network/utils/iperf/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..8ac8620
--- /dev/null
+++ b/package/network/utils/iperf/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,13 @@
+K 9
+copyright
+V 30
+Copyright (C) 2007 OpenWrt.org
+K 7
+licence
+V 5
+GPLv2
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/utils/iperf/.svn/text-base/Makefile.svn-base b/package/network/utils/iperf/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..2937460
--- /dev/null
+++ b/package/network/utils/iperf/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,86 @@
+#
+# Copyright (C) 2007-2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=iperf
+PKG_VERSION:=2.0.5
+PKG_RELEASE:=1
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=@SF/$(PKG_NAME)
+PKG_MD5SUM:=44b5536b67719f4250faed632a3cd016
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+
+PKG_BUILD_PARALLEL:=1
+
+include $(INCLUDE_DIR)/uclibc++.mk
+include $(INCLUDE_DIR)/package.mk
+
+define Package/iperf/Default
+ SECTION:=net
+ CATEGORY:=Network
+ DEPENDS:= $(CXX_DEPENDS)
+ TITLE:=Internet Protocol bandwidth measuring tool
+ URL:=http://sourceforge.net/projects/iperf/
+endef
+
+define Package/iperf/Default/description
+ Iperf is a modern alternative for measuring TCP and UDP bandwidth
+ performance, allowing the tuning of various parameters and
+ characteristics.
+endef
+
+define Package/iperf
+$(call Package/iperf/Default)
+ TITLE+= (with single thread support)
+ VARIANT:=single
+endef
+
+define Package/iperf/description
+$(call Package/iperf/Default/description)
+ This package is built with single thread support.
+endef
+
+define Package/iperf-mt
+$(call Package/iperf/Default)
+ DEPENDS+= +libpthread
+ TITLE+= (with multithread support)
+ VARIANT:=mt
+endef
+
+define Package/iperf-mt/description
+$(call Package/iperf/Default/description)
+ This package is built with multithread support.
+endef
+
+CONFIGURE_ARGS += --disable-multicast
+CONFIGURE_VARS += ac_cv_func_malloc_0_nonnull=yes
+
+ifeq ($(BUILD_VARIANT),single)
+ CONFIGURE_ARGS += --disable-threads
+else
+ CONFIGURE_ARGS += --enable-threads=posix
+ CONFIGURE_VARS += ac_cv_func_pthread_cancel=no
+endif
+
+CONFIGURE_VARS += CXXFLAGS="$$$$CXXFLAGS -fno-rtti"
+
+ifeq ($(BUILD_VARIANT),mt)
+ CONFIGURE_VARS += LIBS="-lpthread"
+endif
+
+define Package/iperf/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/iperf $(1)/usr/bin/iperf
+endef
+Package/iperf-mt/install = $(Package/iperf/install)
+
+$(eval $(call BuildPackage,iperf))
+$(eval $(call BuildPackage,iperf-mt))
diff --git a/package/network/utils/iperf/Makefile b/package/network/utils/iperf/Makefile
new file mode 100644
index 0000000..2937460
--- /dev/null
+++ b/package/network/utils/iperf/Makefile
@@ -0,0 +1,86 @@
+#
+# Copyright (C) 2007-2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=iperf
+PKG_VERSION:=2.0.5
+PKG_RELEASE:=1
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=@SF/$(PKG_NAME)
+PKG_MD5SUM:=44b5536b67719f4250faed632a3cd016
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+
+PKG_BUILD_PARALLEL:=1
+
+include $(INCLUDE_DIR)/uclibc++.mk
+include $(INCLUDE_DIR)/package.mk
+
+define Package/iperf/Default
+ SECTION:=net
+ CATEGORY:=Network
+ DEPENDS:= $(CXX_DEPENDS)
+ TITLE:=Internet Protocol bandwidth measuring tool
+ URL:=http://sourceforge.net/projects/iperf/
+endef
+
+define Package/iperf/Default/description
+ Iperf is a modern alternative for measuring TCP and UDP bandwidth
+ performance, allowing the tuning of various parameters and
+ characteristics.
+endef
+
+define Package/iperf
+$(call Package/iperf/Default)
+ TITLE+= (with single thread support)
+ VARIANT:=single
+endef
+
+define Package/iperf/description
+$(call Package/iperf/Default/description)
+ This package is built with single thread support.
+endef
+
+define Package/iperf-mt
+$(call Package/iperf/Default)
+ DEPENDS+= +libpthread
+ TITLE+= (with multithread support)
+ VARIANT:=mt
+endef
+
+define Package/iperf-mt/description
+$(call Package/iperf/Default/description)
+ This package is built with multithread support.
+endef
+
+CONFIGURE_ARGS += --disable-multicast
+CONFIGURE_VARS += ac_cv_func_malloc_0_nonnull=yes
+
+ifeq ($(BUILD_VARIANT),single)
+ CONFIGURE_ARGS += --disable-threads
+else
+ CONFIGURE_ARGS += --enable-threads=posix
+ CONFIGURE_VARS += ac_cv_func_pthread_cancel=no
+endif
+
+CONFIGURE_VARS += CXXFLAGS="$$$$CXXFLAGS -fno-rtti"
+
+ifeq ($(BUILD_VARIANT),mt)
+ CONFIGURE_VARS += LIBS="-lpthread"
+endif
+
+define Package/iperf/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/iperf $(1)/usr/bin/iperf
+endef
+Package/iperf-mt/install = $(Package/iperf/install)
+
+$(eval $(call BuildPackage,iperf))
+$(eval $(call BuildPackage,iperf-mt))
diff --git a/package/network/utils/iperf/patches/.svn/entries b/package/network/utils/iperf/patches/.svn/entries
new file mode 100644
index 0000000..26c038d
--- /dev/null
+++ b/package/network/utils/iperf/patches/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/utils/iperf/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2010-07-13T09:11:08.452874Z
+22164
+swalker
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+001-set-report-next-time-in-single-thread-mode.patch
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+77837ba0a13ee7f8970c78c899c9ac84
+2010-07-13T09:11:08.452874Z
+22164
+swalker
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+428
+
diff --git a/package/network/utils/iperf/patches/.svn/text-base/001-set-report-next-time-in-single-thread-mode.patch.svn-base b/package/network/utils/iperf/patches/.svn/text-base/001-set-report-next-time-in-single-thread-mode.patch.svn-base
new file mode 100644
index 0000000..c61c754
--- /dev/null
+++ b/package/network/utils/iperf/patches/.svn/text-base/001-set-report-next-time-in-single-thread-mode.patch.svn-base
@@ -0,0 +1,14 @@
+--- a/src/Reporter.c
++++ b/src/Reporter.c
+@@ -308,6 +308,11 @@ ReportHeader* InitReport( thread_Setting
+ #else
+ // set start time
+ gettimeofday( &(reporthdr->report.startTime), NULL );
++
++ // set next time
++ reporthdr->report.nextTime = reporthdr->report.startTime;
++ TimeAdd( reporthdr->report.nextTime, reporthdr->report.intervalTime );
++
+ /*
+ * Process the report in this thread
+ */
diff --git a/package/network/utils/iperf/patches/001-set-report-next-time-in-single-thread-mode.patch b/package/network/utils/iperf/patches/001-set-report-next-time-in-single-thread-mode.patch
new file mode 100644
index 0000000..c61c754
--- /dev/null
+++ b/package/network/utils/iperf/patches/001-set-report-next-time-in-single-thread-mode.patch
@@ -0,0 +1,14 @@
+--- a/src/Reporter.c
++++ b/src/Reporter.c
+@@ -308,6 +308,11 @@ ReportHeader* InitReport( thread_Setting
+ #else
+ // set start time
+ gettimeofday( &(reporthdr->report.startTime), NULL );
++
++ // set next time
++ reporthdr->report.nextTime = reporthdr->report.startTime;
++ TimeAdd( reporthdr->report.nextTime, reporthdr->report.intervalTime );
++
+ /*
+ * Process the report in this thread
+ */
diff --git a/package/network/utils/iproute2/.svn/entries b/package/network/utils/iproute2/.svn/entries
new file mode 100644
index 0000000..92f09f4
--- /dev/null
+++ b/package/network/utils/iproute2/.svn/entries
@@ -0,0 +1,68 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/utils/iproute2
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-20T11:25:18.585539Z
+35250
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+files
+dir
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+d7020e2c7d8e7b0d9f21e91b1c636d3d
+2013-01-20T11:25:18.585539Z
+35250
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2953
+
diff --git a/package/network/utils/iproute2/.svn/prop-base/Makefile.svn-base b/package/network/utils/iproute2/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..8e522ae
--- /dev/null
+++ b/package/network/utils/iproute2/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:copyright
+V 30
+Copyright (C) 2006 OpenWrt.org
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/utils/iproute2/.svn/text-base/Makefile.svn-base b/package/network/utils/iproute2/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..578010f
--- /dev/null
+++ b/package/network/utils/iproute2/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,115 @@
+#
+# Copyright (C) 2006-2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=iproute2
+PKG_VERSION:=3.7.0
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=http://kernel.org/pub/linux/utils/net/iproute2/
+PKG_MD5SUM:=47040899f8fa30c8721fc5aec6509b44
+PKG_BUILD_PARALLEL:=1
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/iproute2-$(PKG_VERSION)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/iproute2/Default
+ SECTION:=net
+ CATEGORY:=Network
+ URL:=http://linux-net.osdl.org/index.php/Iproute2
+endef
+
+define Package/ip
+$(call Package/iproute2/Default)
+ SUBMENU:=Routing and Redirection
+ DEPENDS:= +libnl-tiny
+ TITLE:=Routing control utility
+endef
+
+define Package/ip/conffiles
+/etc/iproute2/rt_tables
+endef
+
+define Package/tc
+$(call Package/iproute2/Default)
+ TITLE:=Traffic control utility
+ DEPENDS:=+kmod-sched-core
+endef
+
+define Package/genl
+$(call Package/iproute2/Default)
+ TITLE:=General netlink utility frontend
+endef
+
+define Package/ss
+$(call Package/iproute2/Default)
+ TITLE:=Socket statistics utility
+endef
+
+define Build/Configure
+ $(SED) "s,-I/usr/include/db3,," $(PKG_BUILD_DIR)/Makefile
+ $(SED) "s,^KERNEL_INCLUDE.*,KERNEL_INCLUDE=$(LINUX_DIR)/include," \
+ $(PKG_BUILD_DIR)/Makefile
+ $(SED) "s,^LIBC_INCLUDE.*,LIBC_INCLUDE=$(STAGING_DIR)/include," \
+ $(PKG_BUILD_DIR)/Makefile
+ echo "static const char SNAPSHOT[] = \"$(PKG_VERSION)-$(PKG_RELEASE)-openwrt\";" \
+ > $(PKG_BUILD_DIR)/include/SNAPSHOT.h
+endef
+
+ifdef CONFIG_USE_EGLIBC
+ ifndef CONFIG_EGLIBC_VERSION_2_13
+ TARGET_CFLAGS += -DHAVE_SETNS
+ endif
+endif
+
+MAKE_FLAGS += \
+ EXTRA_CCOPTS="$(TARGET_CFLAGS) -I../include -I$(STAGING_DIR)/usr/include/libnl-tiny" \
+ KERNEL_INCLUDE="$(LINUX_DIR)/include" \
+ FPIC="$(FPIC)"
+
+define Build/Compile
+ +$(MAKE_VARS) $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) $(MAKE_FLAGS)
+endef
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include
+ $(CP) $(PKG_BUILD_DIR)/include/libnetlink.h $(1)/usr/include/
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_BUILD_DIR)/lib/libnetlink.a $(1)/usr/lib/
+endef
+
+define Package/ip/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_DIR) $(1)/etc/iproute2
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/etc/iproute2/rt_tables $(1)/etc/iproute2
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/ip/ip $(1)/usr/sbin/
+endef
+
+define Package/tc/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/tc/tc $(1)/usr/sbin/
+ $(INSTALL_DIR) $(1)/etc/hotplug.d/iface
+ $(INSTALL_BIN) ./files/15-teql $(1)/etc/hotplug.d/iface/
+endef
+
+define Package/genl/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/genl/genl $(1)/usr/sbin/
+endef
+
+define Package/ss/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc/ss $(1)/usr/sbin/
+endef
+
+$(eval $(call BuildPackage,ip))
+$(eval $(call BuildPackage,tc))
+$(eval $(call BuildPackage,genl))
+$(eval $(call BuildPackage,ss))
diff --git a/package/network/utils/iproute2/Makefile b/package/network/utils/iproute2/Makefile
new file mode 100644
index 0000000..578010f
--- /dev/null
+++ b/package/network/utils/iproute2/Makefile
@@ -0,0 +1,115 @@
+#
+# Copyright (C) 2006-2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=iproute2
+PKG_VERSION:=3.7.0
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=http://kernel.org/pub/linux/utils/net/iproute2/
+PKG_MD5SUM:=47040899f8fa30c8721fc5aec6509b44
+PKG_BUILD_PARALLEL:=1
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/iproute2-$(PKG_VERSION)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/iproute2/Default
+ SECTION:=net
+ CATEGORY:=Network
+ URL:=http://linux-net.osdl.org/index.php/Iproute2
+endef
+
+define Package/ip
+$(call Package/iproute2/Default)
+ SUBMENU:=Routing and Redirection
+ DEPENDS:= +libnl-tiny
+ TITLE:=Routing control utility
+endef
+
+define Package/ip/conffiles
+/etc/iproute2/rt_tables
+endef
+
+define Package/tc
+$(call Package/iproute2/Default)
+ TITLE:=Traffic control utility
+ DEPENDS:=+kmod-sched-core
+endef
+
+define Package/genl
+$(call Package/iproute2/Default)
+ TITLE:=General netlink utility frontend
+endef
+
+define Package/ss
+$(call Package/iproute2/Default)
+ TITLE:=Socket statistics utility
+endef
+
+define Build/Configure
+ $(SED) "s,-I/usr/include/db3,," $(PKG_BUILD_DIR)/Makefile
+ $(SED) "s,^KERNEL_INCLUDE.*,KERNEL_INCLUDE=$(LINUX_DIR)/include," \
+ $(PKG_BUILD_DIR)/Makefile
+ $(SED) "s,^LIBC_INCLUDE.*,LIBC_INCLUDE=$(STAGING_DIR)/include," \
+ $(PKG_BUILD_DIR)/Makefile
+ echo "static const char SNAPSHOT[] = \"$(PKG_VERSION)-$(PKG_RELEASE)-openwrt\";" \
+ > $(PKG_BUILD_DIR)/include/SNAPSHOT.h
+endef
+
+ifdef CONFIG_USE_EGLIBC
+ ifndef CONFIG_EGLIBC_VERSION_2_13
+ TARGET_CFLAGS += -DHAVE_SETNS
+ endif
+endif
+
+MAKE_FLAGS += \
+ EXTRA_CCOPTS="$(TARGET_CFLAGS) -I../include -I$(STAGING_DIR)/usr/include/libnl-tiny" \
+ KERNEL_INCLUDE="$(LINUX_DIR)/include" \
+ FPIC="$(FPIC)"
+
+define Build/Compile
+ +$(MAKE_VARS) $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) $(MAKE_FLAGS)
+endef
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include
+ $(CP) $(PKG_BUILD_DIR)/include/libnetlink.h $(1)/usr/include/
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_BUILD_DIR)/lib/libnetlink.a $(1)/usr/lib/
+endef
+
+define Package/ip/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_DIR) $(1)/etc/iproute2
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/etc/iproute2/rt_tables $(1)/etc/iproute2
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/ip/ip $(1)/usr/sbin/
+endef
+
+define Package/tc/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/tc/tc $(1)/usr/sbin/
+ $(INSTALL_DIR) $(1)/etc/hotplug.d/iface
+ $(INSTALL_BIN) ./files/15-teql $(1)/etc/hotplug.d/iface/
+endef
+
+define Package/genl/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/genl/genl $(1)/usr/sbin/
+endef
+
+define Package/ss/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc/ss $(1)/usr/sbin/
+endef
+
+$(eval $(call BuildPackage,ip))
+$(eval $(call BuildPackage,tc))
+$(eval $(call BuildPackage,genl))
+$(eval $(call BuildPackage,ss))
diff --git a/package/network/utils/iproute2/files/.svn/entries b/package/network/utils/iproute2/files/.svn/entries
new file mode 100644
index 0000000..da89afb
--- /dev/null
+++ b/package/network/utils/iproute2/files/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/utils/iproute2/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-12-02T13:04:03.330574Z
+34442
+juhosg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+15-teql
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+7fe397054763bd3778adb4cd9e35d311
+2012-12-02T13:04:03.330574Z
+34442
+juhosg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+486
+
diff --git a/package/network/utils/iproute2/files/.svn/text-base/15-teql.svn-base b/package/network/utils/iproute2/files/.svn/text-base/15-teql.svn-base
new file mode 100644
index 0000000..a0c0e50
--- /dev/null
+++ b/package/network/utils/iproute2/files/.svn/text-base/15-teql.svn-base
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+. /lib/functions.sh
+
+if [ "$ACTION" != "ifup" ]; then
+ exit
+fi
+
+config_load network
+
+config_get teql $INTERFACE teql
+
+if [ "$teql" != "" ]; then
+ logger Adding device $DEVICE to TEQL master $teql
+ insmod sch_teql
+ tc qdisc add dev $DEVICE root $teql
+
+ # The kernel doesn't let us bring it up until it has at least one
+ # slave. So bring it up now, if it isn't already.
+ if ! cat /sys/class/net/$teql/carrier &>/dev/null; then
+ ifup $teql &
+ fi
+fi
diff --git a/package/network/utils/iproute2/files/15-teql b/package/network/utils/iproute2/files/15-teql
new file mode 100644
index 0000000..a0c0e50
--- /dev/null
+++ b/package/network/utils/iproute2/files/15-teql
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+. /lib/functions.sh
+
+if [ "$ACTION" != "ifup" ]; then
+ exit
+fi
+
+config_load network
+
+config_get teql $INTERFACE teql
+
+if [ "$teql" != "" ]; then
+ logger Adding device $DEVICE to TEQL master $teql
+ insmod sch_teql
+ tc qdisc add dev $DEVICE root $teql
+
+ # The kernel doesn't let us bring it up until it has at least one
+ # slave. So bring it up now, if it isn't already.
+ if ! cat /sys/class/net/$teql/carrier &>/dev/null; then
+ ifup $teql &
+ fi
+fi
diff --git a/package/network/utils/iproute2/patches/.svn/entries b/package/network/utils/iproute2/patches/.svn/entries
new file mode 100644
index 0000000..7f9f990
--- /dev/null
+++ b/package/network/utils/iproute2/patches/.svn/entries
@@ -0,0 +1,436 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/utils/iproute2/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-20T11:25:18.585539Z
+35250
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+004-darwin_fixes.patch
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+6ee7c9736d5c97b7cd3586baa5a6a9c5
+2009-07-11T14:05:54.386537Z
+16777
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1297
+
+210-build-unbreak-linkage-of-m_xt.so.patch
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+db15fa9af449eec7bbf3838361d6d211
+2013-01-20T11:25:18.585539Z
+35250
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1430
+
+000-sync_pkt_sched_h.patch
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+e5618a2ece071525f4e713e754f2770d
+2013-01-20T11:25:18.585539Z
+35250
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+815
+
+120-libnetlink-pic.patch
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+c278af4b93450325ab17f8f3112f794c
+2010-05-20T06:09:49.031848Z
+21513
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+165
+
+007-no_arpd.patch
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+68c26fe2c0e403dcb9e352460b164c8d
+2012-05-16T15:23:12.201327Z
+31758
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+221
+
+008-no_netem.patch
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+51b030026ce6e35ca1a262cdc1475826
+2013-01-20T11:25:18.585539Z
+35250
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+323
+
+110-extra-ccopts.patch
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+3670666db767bc9a0856e69f5a10f61c
+2013-01-20T11:25:18.585539Z
+35250
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+284
+
+100-allow_pfifo_fast.patch
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+fbf3572e68781bae8483db40ad21e7a8
+2010-12-02T20:29:22.131755Z
+24216
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+369
+
+006-iproute2-tc_esfq.patch
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+7c5a57deb540e29d913cd8d9d842422d
+2012-05-16T15:23:12.201327Z
+31758
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5494
+
+200-act_connmark.patch
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+93811853e9dc674527fad770e99dbeb0
+2012-05-16T15:23:12.201327Z
+31758
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1955
+
+001-iproute2-2.6.11_Config.patch
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+2958795af18d0ff15a8c8e62e5a4a7ec
+2009-07-11T14:05:54.386537Z
+16777
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+181
+
+002-iproute2-ipxfrm_no_sctp.patch
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+5cee7636291543d39d9efafa6de5bbc3
+2012-05-16T15:23:12.201327Z
+31758
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+505
+
diff --git a/package/network/utils/iproute2/patches/.svn/prop-base/002-iproute2-ipxfrm_no_sctp.patch.svn-base b/package/network/utils/iproute2/patches/.svn/prop-base/002-iproute2-ipxfrm_no_sctp.patch.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/network/utils/iproute2/patches/.svn/prop-base/002-iproute2-ipxfrm_no_sctp.patch.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/utils/iproute2/patches/.svn/text-base/000-sync_pkt_sched_h.patch.svn-base b/package/network/utils/iproute2/patches/.svn/text-base/000-sync_pkt_sched_h.patch.svn-base
new file mode 100644
index 0000000..b06bc70
--- /dev/null
+++ b/package/network/utils/iproute2/patches/.svn/text-base/000-sync_pkt_sched_h.patch.svn-base
@@ -0,0 +1,36 @@
+--- a/include/linux/pkt_sched.h
++++ b/include/linux/pkt_sched.h
+@@ -214,6 +214,33 @@ struct tc_sfq_xstats {
+ __s32 allot;
+ };
+
++/* ESFQ section */
++
++enum
++{
++ /* traditional */
++ TCA_SFQ_HASH_CLASSIC,
++ TCA_SFQ_HASH_DST,
++ TCA_SFQ_HASH_SRC,
++ TCA_SFQ_HASH_FWMARK,
++ /* conntrack */
++ TCA_SFQ_HASH_CTORIGDST,
++ TCA_SFQ_HASH_CTORIGSRC,
++ TCA_SFQ_HASH_CTREPLDST,
++ TCA_SFQ_HASH_CTREPLSRC,
++ TCA_SFQ_HASH_CTNATCHG,
++};
++
++struct tc_esfq_qopt
++{
++ unsigned quantum; /* Bytes per round allocated to flow */
++ int perturb_period; /* Period of hash perturbation */
++ __u32 limit; /* Maximal packets in queue */
++ unsigned divisor; /* Hash divisor */
++ unsigned flows; /* Maximal number of flows */
++ unsigned hash_kind; /* Hash function to use for flow identification */
++};
++
+ /* RED section */
+
+ enum {
diff --git a/package/network/utils/iproute2/patches/.svn/text-base/001-iproute2-2.6.11_Config.patch.svn-base b/package/network/utils/iproute2/patches/.svn/text-base/001-iproute2-2.6.11_Config.patch.svn-base
new file mode 100644
index 0000000..ece8652
--- /dev/null
+++ b/package/network/utils/iproute2/patches/.svn/text-base/001-iproute2-2.6.11_Config.patch.svn-base
@@ -0,0 +1,7 @@
+--- /dev/null
++++ b/Config
+@@ -0,0 +1,4 @@
++# Fixed config to disable ATM support even if present on host system
++TC_CONFIG_ATM:=n
++TC_CONFIG_ACTION_GACT=y
++TC_CONFIG_ACTION_PROB=y
diff --git a/package/network/utils/iproute2/patches/.svn/text-base/002-iproute2-ipxfrm_no_sctp.patch.svn-base b/package/network/utils/iproute2/patches/.svn/text-base/002-iproute2-ipxfrm_no_sctp.patch.svn-base
new file mode 100644
index 0000000..3b1f4d6
--- /dev/null
+++ b/package/network/utils/iproute2/patches/.svn/text-base/002-iproute2-ipxfrm_no_sctp.patch.svn-base
@@ -0,0 +1,22 @@
+---
+ ip/ipxfrm.c | 2 --
+ 1 file changed, 2 deletions(-)
+
+--- a/ip/ipxfrm.c
++++ b/ip/ipxfrm.c
+@@ -468,7 +468,6 @@ void xfrm_selector_print(struct xfrm_sel
+ switch (sel->proto) {
+ case IPPROTO_TCP:
+ case IPPROTO_UDP:
+- case IPPROTO_SCTP:
+ case IPPROTO_DCCP:
+ default: /* XXX */
+ if (sel->sport_mask)
+@@ -1263,7 +1262,6 @@ static int xfrm_selector_upspec_parse(st
+ switch (sel->proto) {
+ case IPPROTO_TCP:
+ case IPPROTO_UDP:
+- case IPPROTO_SCTP:
+ case IPPROTO_DCCP:
+ break;
+ default:
diff --git a/package/network/utils/iproute2/patches/.svn/text-base/004-darwin_fixes.patch.svn-base b/package/network/utils/iproute2/patches/.svn/text-base/004-darwin_fixes.patch.svn-base
new file mode 100644
index 0000000..e1a5e97
--- /dev/null
+++ b/package/network/utils/iproute2/patches/.svn/text-base/004-darwin_fixes.patch.svn-base
@@ -0,0 +1,59 @@
+--- a/netem/maketable.c
++++ b/netem/maketable.c
+@@ -10,7 +10,9 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <math.h>
++#if !defined(__APPLE__) && !defined(__FreeBSD__)
+ #include <malloc.h>
++#endif
+ #include <string.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
+--- a/netem/normal.c
++++ b/netem/normal.c
+@@ -8,8 +8,12 @@
+ #include <string.h>
+ #include <limits.h>
+
++#if !defined(__APPLE__) && !defined(__FreeBSD__)
+ #include <linux/types.h>
+ #include <linux/pkt_sched.h>
++#else
++#define NETEM_DIST_SCALE 8192
++#endif
+
+ #define TABLESIZE 16384
+ #define TABLEFACTOR NETEM_DIST_SCALE
+--- a/netem/pareto.c
++++ b/netem/pareto.c
+@@ -7,8 +7,12 @@
+ #include <math.h>
+ #include <limits.h>
+
++#if !defined(__APPLE__) && !defined(__FreeBSD__)
+ #include <linux/types.h>
+ #include <linux/pkt_sched.h>
++#else
++#define NETEM_DIST_SCALE 8192
++#endif
+
+ static const double a=3.0;
+ #define TABLESIZE 16384
+--- a/netem/paretonormal.c
++++ b/netem/paretonormal.c
+@@ -15,10 +15,13 @@
+ #include <string.h>
+ #include <math.h>
+ #include <limits.h>
++#if !defined(__APPLE__) && !defined(__FreeBSD__)
+ #include <malloc.h>
+-
+ #include <linux/types.h>
+ #include <linux/pkt_sched.h>
++#else
++#define NETEM_DIST_SCALE 8192
++#endif
+
+ #define TABLESIZE 16384
+ #define TABLEFACTOR NETEM_DIST_SCALE
diff --git a/package/network/utils/iproute2/patches/.svn/text-base/006-iproute2-tc_esfq.patch.svn-base b/package/network/utils/iproute2/patches/.svn/text-base/006-iproute2-tc_esfq.patch.svn-base
new file mode 100644
index 0000000..8016dbb
--- /dev/null
+++ b/package/network/utils/iproute2/patches/.svn/text-base/006-iproute2-tc_esfq.patch.svn-base
@@ -0,0 +1,219 @@
+---
+ include/linux/pkt_sched.h | 59 +++++++++++++
+ tc/Makefile | 1
+ tc/q_esfq.c | 200 ++++++++++++++++++++++++++++++++++++++++++++++
+ 3 files changed, 260 insertions(+)
+
+--- a/tc/Makefile
++++ b/tc/Makefile
+@@ -8,6 +8,7 @@ SHARED_LIBS ?= y
+ TCMODULES :=
+ TCMODULES += q_fifo.o
+ TCMODULES += q_sfq.o
++TCMODULES += q_esfq.o
+ TCMODULES += q_red.o
+ TCMODULES += q_prio.o
+ TCMODULES += q_tbf.o
+--- /dev/null
++++ b/tc/q_esfq.c
+@@ -0,0 +1,200 @@
++/*
++ * q_esfq.c ESFQ.
++ *
++ * 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 of the License, or (at your option) any later version.
++ *
++ * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
++ *
++ * Changes: Alexander Atanasov, <alex@ssi.bg>
++ * Alexander Clouter, <alex@digriz.org.uk>
++ * Corey Hickey, <bugfood-c@fatooh.org>
++ *
++ */
++
++#include <stdio.h>
++#include <stdlib.h>
++#include <unistd.h>
++#include <syslog.h>
++#include <fcntl.h>
++#include <math.h>
++#include <sys/socket.h>
++#include <netinet/in.h>
++#include <arpa/inet.h>
++#include <string.h>
++
++#include "utils.h"
++#include "tc_util.h"
++
++static void explain(void)
++{
++ fprintf(stderr, "Usage: ... esfq [ perturb SECS ] [ quantum BYTES ] [ depth FLOWS ]\n\t[ divisor HASHBITS ] [ limit PKTS ] [ hash HASHTYPE]\n");
++ fprintf(stderr,"Where: \n");
++ fprintf(stderr,"HASHTYPE := { classic | src | dst | ctorigdst | ctorigsrc | ctrepldst | ctreplsrc | ctnatchg }\n");
++}
++
++#define usage() return(-1)
++
++static int esfq_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n)
++{
++ int ok=0;
++ struct tc_esfq_qopt opt;
++
++ memset(&opt, 0, sizeof(opt));
++
++ opt.hash_kind= TCA_SFQ_HASH_CLASSIC;
++
++ while (argc > 0) {
++ if (strcmp(*argv, "quantum") == 0) {
++ NEXT_ARG();
++ if (get_size(&opt.quantum, *argv)) {
++ fprintf(stderr, "Illegal \"quantum\"\n");
++ return -1;
++ }
++ ok++;
++ } else if (strcmp(*argv, "perturb") == 0) {
++ NEXT_ARG();
++ if (get_integer(&opt.perturb_period, *argv, 0)) {
++ fprintf(stderr, "Illegal \"perturb\"\n");
++ return -1;
++ }
++ ok++;
++ } else if (strcmp(*argv, "depth") == 0) {
++ NEXT_ARG();
++ if (get_integer((int *) &opt.flows, *argv, 0)) {
++ fprintf(stderr, "Illegal \"depth\"\n");
++ return -1;
++ }
++ ok++;
++ } else if (strcmp(*argv, "divisor") == 0) {
++ NEXT_ARG();
++ if (get_integer((int *) &opt.divisor, *argv, 0)) {
++ fprintf(stderr, "Illegal \"divisor\"\n");
++ return -1;
++ }
++ if(opt.divisor >= 14) {
++ fprintf(stderr, "Illegal \"divisor\": must be < 14\n");
++ return -1;
++ }
++ opt.divisor=pow(2,opt.divisor);
++ ok++;
++ } else if (strcmp(*argv, "limit") == 0) {
++ NEXT_ARG();
++ if (get_integer((int *) &opt.limit, *argv, 0)) {
++ fprintf(stderr, "Illegal \"limit\"\n");
++ return -1;
++ }
++ ok++;
++ } else if (strcmp(*argv, "hash") == 0) {
++ NEXT_ARG();
++ if(strcmp(*argv, "classic") == 0) {
++ opt.hash_kind= TCA_SFQ_HASH_CLASSIC;
++ } else
++ if(strcmp(*argv, "dst") == 0) {
++ opt.hash_kind= TCA_SFQ_HASH_DST;
++ } else
++ if(strcmp(*argv, "src") == 0) {
++ opt.hash_kind= TCA_SFQ_HASH_SRC;
++ } else
++ if(strcmp(*argv, "ctorigsrc") == 0) {
++ opt.hash_kind= TCA_SFQ_HASH_CTORIGSRC;
++ } else
++ if(strcmp(*argv, "ctorigdst") == 0) {
++ opt.hash_kind= TCA_SFQ_HASH_CTORIGDST;
++ } else
++ if(strcmp(*argv, "ctreplsrc") == 0) {
++ opt.hash_kind= TCA_SFQ_HASH_CTREPLSRC;
++ } else
++ if(strcmp(*argv, "ctrepldst") == 0) {
++ opt.hash_kind= TCA_SFQ_HASH_CTREPLDST;
++ } else
++ if(strcmp(*argv, "ctnatchg") == 0) {
++ opt.hash_kind= TCA_SFQ_HASH_CTNATCHG;
++ } else {
++ fprintf(stderr, "Illegal \"hash\"\n");
++ explain();
++ return -1;
++ }
++ ok++;
++ } else if (strcmp(*argv, "help") == 0) {
++ explain();
++ return -1;
++ } else {
++ fprintf(stderr, "What is \"%s\"?\n", *argv);
++ explain();
++ return -1;
++ }
++ argc--; argv++;
++ }
++
++ if (ok)
++ addattr_l(n, 1024, TCA_OPTIONS, &opt, sizeof(opt));
++ return 0;
++}
++
++static int esfq_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
++{
++ struct tc_esfq_qopt *qopt;
++ SPRINT_BUF(b1);
++
++ if (opt == NULL)
++ return 0;
++
++ if (RTA_PAYLOAD(opt) < sizeof(*qopt))
++ return -1;
++ qopt = RTA_DATA(opt);
++ fprintf(f, "quantum %s ", sprint_size(qopt->quantum, b1));
++ if (show_details) {
++ fprintf(f, "limit %up flows %u/%u ",
++ qopt->limit, qopt->flows, qopt->divisor);
++ }
++ if (qopt->perturb_period)
++ fprintf(f, "perturb %dsec ", qopt->perturb_period);
++
++ fprintf(f,"hash: ");
++ switch(qopt->hash_kind)
++ {
++ case TCA_SFQ_HASH_CLASSIC:
++ fprintf(f,"classic");
++ break;
++ case TCA_SFQ_HASH_DST:
++ fprintf(f,"dst");
++ break;
++ case TCA_SFQ_HASH_SRC:
++ fprintf(f,"src");
++ break;
++ case TCA_SFQ_HASH_CTORIGSRC:
++ fprintf(f,"ctorigsrc");
++ break;
++ case TCA_SFQ_HASH_CTORIGDST:
++ fprintf(f,"ctorigdst");
++ break;
++ case TCA_SFQ_HASH_CTREPLSRC:
++ fprintf(f,"ctreplsrc");
++ break;
++ case TCA_SFQ_HASH_CTREPLDST:
++ fprintf(f,"ctrepldst");
++ break;
++ case TCA_SFQ_HASH_CTNATCHG:
++ fprintf(f,"ctnatchg");
++ break;
++ default:
++ fprintf(f,"Unknown");
++ }
++ return 0;
++}
++
++static int esfq_print_xstats(struct qdisc_util *qu, FILE *f, struct rtattr *xstats)
++{
++ return 0;
++}
++
++
++struct qdisc_util esfq_qdisc_util = {
++ .id = "esfq",
++ .parse_qopt = esfq_parse_opt,
++ .print_qopt = esfq_print_opt,
++ .print_xstats = esfq_print_xstats,
++};
diff --git a/package/network/utils/iproute2/patches/.svn/text-base/007-no_arpd.patch.svn-base b/package/network/utils/iproute2/patches/.svn/text-base/007-no_arpd.patch.svn-base
new file mode 100644
index 0000000..6a7e24e
--- /dev/null
+++ b/package/network/utils/iproute2/patches/.svn/text-base/007-no_arpd.patch.svn-base
@@ -0,0 +1,11 @@
+--- a/misc/Makefile
++++ b/misc/Makefile
+@@ -1,7 +1,7 @@
+ SSOBJ=ss.o ssfilter.o
+ LNSTATOBJ=lnstat.o lnstat_util.o
+
+-TARGETS=ss nstat ifstat rtacct arpd lnstat
++TARGETS=ss nstat ifstat rtacct lnstat
+
+ include ../Config
+
diff --git a/package/network/utils/iproute2/patches/.svn/text-base/008-no_netem.patch.svn-base b/package/network/utils/iproute2/patches/.svn/text-base/008-no_netem.patch.svn-base
new file mode 100644
index 0000000..a6a74aa
--- /dev/null
+++ b/package/network/utils/iproute2/patches/.svn/text-base/008-no_netem.patch.svn-base
@@ -0,0 +1,11 @@
+--- a/Makefile
++++ b/Makefile
+@@ -34,7 +34,7 @@ WFLAGS = -Wall -Wstrict-prototypes
+ CFLAGS = $(WFLAGS) $(CCOPTS) -I../include $(DEFINES)
+ YACCFLAGS = -d -t -v
+
+-SUBDIRS=lib ip tc bridge misc netem genl man
++SUBDIRS=lib ip tc bridge misc genl man
+
+ LIBNETLINK=../lib/libnetlink.a ../lib/libutil.a
+ LDLIBS += $(LIBNETLINK)
diff --git a/package/network/utils/iproute2/patches/.svn/text-base/100-allow_pfifo_fast.patch.svn-base b/package/network/utils/iproute2/patches/.svn/text-base/100-allow_pfifo_fast.patch.svn-base
new file mode 100644
index 0000000..b31d4b7
--- /dev/null
+++ b/package/network/utils/iproute2/patches/.svn/text-base/100-allow_pfifo_fast.patch.svn-base
@@ -0,0 +1,13 @@
+---
+ tc/q_fifo.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/tc/q_fifo.c
++++ b/tc/q_fifo.c
+@@ -98,5 +98,6 @@ struct qdisc_util pfifo_head_drop_qdisc_
+ extern int prio_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt);
+ struct qdisc_util pfifo_fast_qdisc_util = {
+ .id = "pfifo_fast",
++ .parse_qopt = fifo_parse_opt,
+ .print_qopt = prio_print_opt,
+ };
diff --git a/package/network/utils/iproute2/patches/.svn/text-base/110-extra-ccopts.patch.svn-base b/package/network/utils/iproute2/patches/.svn/text-base/110-extra-ccopts.patch.svn-base
new file mode 100644
index 0000000..f4ef8d7
--- /dev/null
+++ b/package/network/utils/iproute2/patches/.svn/text-base/110-extra-ccopts.patch.svn-base
@@ -0,0 +1,11 @@
+--- a/Makefile
++++ b/Makefile
+@@ -29,7 +29,7 @@ ADDLIB+=ipx_ntop.o ipx_pton.o
+ CC = gcc
+ HOSTCC = gcc
+ DEFINES += -D_GNU_SOURCE
+-CCOPTS = -O2
++CCOPTS = -O2 $(EXTRA_CCOPTS)
+ WFLAGS = -Wall -Wstrict-prototypes
+ CFLAGS = $(WFLAGS) $(CCOPTS) -I../include $(DEFINES)
+ YACCFLAGS = -d -t -v
diff --git a/package/network/utils/iproute2/patches/.svn/text-base/120-libnetlink-pic.patch.svn-base b/package/network/utils/iproute2/patches/.svn/text-base/120-libnetlink-pic.patch.svn-base
new file mode 100644
index 0000000..c7b78d0
--- /dev/null
+++ b/package/network/utils/iproute2/patches/.svn/text-base/120-libnetlink-pic.patch.svn-base
@@ -0,0 +1,8 @@
+--- a/lib/Makefile
++++ b/lib/Makefile
+@@ -1,4 +1,4 @@
+-CFLAGS += -fPIC
++CFLAGS+=$(FPIC)
+
+ UTILOBJ=utils.o rt_names.o ll_types.o ll_proto.o ll_addr.o inet_proto.o
+
diff --git a/package/network/utils/iproute2/patches/.svn/text-base/200-act_connmark.patch.svn-base b/package/network/utils/iproute2/patches/.svn/text-base/200-act_connmark.patch.svn-base
new file mode 100644
index 0000000..4a48ac3
--- /dev/null
+++ b/package/network/utils/iproute2/patches/.svn/text-base/200-act_connmark.patch.svn-base
@@ -0,0 +1,84 @@
+--- a/tc/Makefile
++++ b/tc/Makefile
+@@ -38,6 +38,7 @@ TCMODULES += m_mirred.o
+ TCMODULES += m_nat.o
+ TCMODULES += m_pedit.o
+ TCMODULES += m_skbedit.o
++TCMODULES += m_connmark.o
+ TCMODULES += m_csum.o
+ TCMODULES += p_ip.o
+ TCMODULES += p_icmp.o
+--- /dev/null
++++ b/tc/m_connmark.c
+@@ -0,0 +1,71 @@
++/*
++ * m_connmark.c Connection tracking marking import
++ *
++ * Copyright (c) 2011 Felix Fietkau <nbd@openwrt.org>
++ *
++ * This program is free software; you can redistribute it and/or modify it
++ * under the terms and conditions of the GNU General Public License,
++ * version 2, as published by the Free Software Foundation.
++ *
++ * This program is distributed in the hope 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.
++ */
++
++#include <stdio.h>
++#include <stdlib.h>
++#include <unistd.h>
++#include <string.h>
++#include "utils.h"
++#include "tc_util.h"
++
++static void
++explain(void)
++{
++ fprintf(stderr, "Usage: ... connmark\n");
++}
++
++static void
++usage(void)
++{
++ explain();
++ exit(-1);
++}
++
++static int
++parse_connmark(struct action_util *a, int *argc_p, char ***argv_p, int tca_id,
++ struct nlmsghdr *n)
++{
++ int argc = *argc_p;
++ char **argv = *argv_p;
++
++ if (matches(*argv, "connmark") != 0)
++ return -1;
++
++ NEXT_ARG();
++
++ *argc_p = argc;
++ *argv_p = argv;
++ return 0;
++}
++
++static int print_connmark(struct action_util *au, FILE *f, struct rtattr *arg)
++{
++ if (arg == NULL)
++ return -1;
++
++ fprintf(f, " connmark");
++
++ return 0;
++}
++
++struct action_util connmark_action_util = {
++ .id = "connmark",
++ .parse_aopt = parse_connmark,
++ .print_aopt = print_connmark,
++};
diff --git a/package/network/utils/iproute2/patches/.svn/text-base/210-build-unbreak-linkage-of-m_xt.so.patch.svn-base b/package/network/utils/iproute2/patches/.svn/text-base/210-build-unbreak-linkage-of-m_xt.so.patch.svn-base
new file mode 100644
index 0000000..7fb2c11
--- /dev/null
+++ b/package/network/utils/iproute2/patches/.svn/text-base/210-build-unbreak-linkage-of-m_xt.so.patch.svn-base
@@ -0,0 +1,58 @@
+From 11e8a1034656eba6571401286b99dabbd9842dac Mon Sep 17 00:00:00 2001
+From: Jan Engelhardt <jengelh@inai.de>
+Date: Tue, 18 Dec 2012 09:18:45 -0800
+Subject: [PATCH] build: unbreak linakge of m_xt.so
+
+Commit v3.7.0~10 caused the variable new PKG_CONFIG variable never
+to be present at the time of calling make, leading to tc/m_xt.so
+not linked with -lxtables (result from pkg-config xtables --libs),
+that in turn leading to
+
+tc: symbol lookup error: /usr/lib64/tc//m_xt.so: undefined symbol:
+xtables_init_all
+
+Fixing that.
+
+Signed-off-by: Jan Engelhardt <jengelh@inai.de>
+
+Conflicts:
+ configure
+---
+ configure | 14 +++++++++++---
+ 1 file changed, 11 insertions(+), 3 deletions(-)
+
+--- a/configure
++++ b/configure
+@@ -2,14 +2,20 @@
+ # This is not an autconf generated configure
+ #
+ INCLUDE=${1:-"$PWD/include"}
+-: ${PKG_CONFIG:=pkg-config}
+-: ${CC=gcc}
+-echo "PKG_CONFIG:=${PKG_CONFIG}" >>Config
+
+ # Make a temp directory in build tree.
+ TMPDIR=$(mktemp -d config.XXXXXX)
+ trap 'status=$?; rm -rf $TMPDIR; exit $status' EXIT HUP INT QUIT TERM
+
++check_toolchain()
++{
++: ${PKG_CONFIG:=pkg-config}
++: ${AR=ar}
++: ${CC=gcc}
++echo "AR:=${AR}" >>Config
++echo "CC:=${CC}" >>Config
++}
++
+ check_atm()
+ {
+ cat >$TMPDIR/atmtest.c <<EOF
+@@ -224,6 +230,8 @@ rm -f $TMPDIR/ipsettest.c $TMPDIR/ipsett
+ }
+
+ echo "# Generated config based on" $INCLUDE >Config
++echo "PKG_CONFIG:=${PKG_CONFIG}" >>Config
++check_toolchain
+
+ echo "TC schedulers"
+
diff --git a/package/network/utils/iproute2/patches/000-sync_pkt_sched_h.patch b/package/network/utils/iproute2/patches/000-sync_pkt_sched_h.patch
new file mode 100644
index 0000000..b06bc70
--- /dev/null
+++ b/package/network/utils/iproute2/patches/000-sync_pkt_sched_h.patch
@@ -0,0 +1,36 @@
+--- a/include/linux/pkt_sched.h
++++ b/include/linux/pkt_sched.h
+@@ -214,6 +214,33 @@ struct tc_sfq_xstats {
+ __s32 allot;
+ };
+
++/* ESFQ section */
++
++enum
++{
++ /* traditional */
++ TCA_SFQ_HASH_CLASSIC,
++ TCA_SFQ_HASH_DST,
++ TCA_SFQ_HASH_SRC,
++ TCA_SFQ_HASH_FWMARK,
++ /* conntrack */
++ TCA_SFQ_HASH_CTORIGDST,
++ TCA_SFQ_HASH_CTORIGSRC,
++ TCA_SFQ_HASH_CTREPLDST,
++ TCA_SFQ_HASH_CTREPLSRC,
++ TCA_SFQ_HASH_CTNATCHG,
++};
++
++struct tc_esfq_qopt
++{
++ unsigned quantum; /* Bytes per round allocated to flow */
++ int perturb_period; /* Period of hash perturbation */
++ __u32 limit; /* Maximal packets in queue */
++ unsigned divisor; /* Hash divisor */
++ unsigned flows; /* Maximal number of flows */
++ unsigned hash_kind; /* Hash function to use for flow identification */
++};
++
+ /* RED section */
+
+ enum {
diff --git a/package/network/utils/iproute2/patches/001-iproute2-2.6.11_Config.patch b/package/network/utils/iproute2/patches/001-iproute2-2.6.11_Config.patch
new file mode 100644
index 0000000..ece8652
--- /dev/null
+++ b/package/network/utils/iproute2/patches/001-iproute2-2.6.11_Config.patch
@@ -0,0 +1,7 @@
+--- /dev/null
++++ b/Config
+@@ -0,0 +1,4 @@
++# Fixed config to disable ATM support even if present on host system
++TC_CONFIG_ATM:=n
++TC_CONFIG_ACTION_GACT=y
++TC_CONFIG_ACTION_PROB=y
diff --git a/package/network/utils/iproute2/patches/002-iproute2-ipxfrm_no_sctp.patch b/package/network/utils/iproute2/patches/002-iproute2-ipxfrm_no_sctp.patch
new file mode 100644
index 0000000..3b1f4d6
--- /dev/null
+++ b/package/network/utils/iproute2/patches/002-iproute2-ipxfrm_no_sctp.patch
@@ -0,0 +1,22 @@
+---
+ ip/ipxfrm.c | 2 --
+ 1 file changed, 2 deletions(-)
+
+--- a/ip/ipxfrm.c
++++ b/ip/ipxfrm.c
+@@ -468,7 +468,6 @@ void xfrm_selector_print(struct xfrm_sel
+ switch (sel->proto) {
+ case IPPROTO_TCP:
+ case IPPROTO_UDP:
+- case IPPROTO_SCTP:
+ case IPPROTO_DCCP:
+ default: /* XXX */
+ if (sel->sport_mask)
+@@ -1263,7 +1262,6 @@ static int xfrm_selector_upspec_parse(st
+ switch (sel->proto) {
+ case IPPROTO_TCP:
+ case IPPROTO_UDP:
+- case IPPROTO_SCTP:
+ case IPPROTO_DCCP:
+ break;
+ default:
diff --git a/package/network/utils/iproute2/patches/004-darwin_fixes.patch b/package/network/utils/iproute2/patches/004-darwin_fixes.patch
new file mode 100644
index 0000000..e1a5e97
--- /dev/null
+++ b/package/network/utils/iproute2/patches/004-darwin_fixes.patch
@@ -0,0 +1,59 @@
+--- a/netem/maketable.c
++++ b/netem/maketable.c
+@@ -10,7 +10,9 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <math.h>
++#if !defined(__APPLE__) && !defined(__FreeBSD__)
+ #include <malloc.h>
++#endif
+ #include <string.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
+--- a/netem/normal.c
++++ b/netem/normal.c
+@@ -8,8 +8,12 @@
+ #include <string.h>
+ #include <limits.h>
+
++#if !defined(__APPLE__) && !defined(__FreeBSD__)
+ #include <linux/types.h>
+ #include <linux/pkt_sched.h>
++#else
++#define NETEM_DIST_SCALE 8192
++#endif
+
+ #define TABLESIZE 16384
+ #define TABLEFACTOR NETEM_DIST_SCALE
+--- a/netem/pareto.c
++++ b/netem/pareto.c
+@@ -7,8 +7,12 @@
+ #include <math.h>
+ #include <limits.h>
+
++#if !defined(__APPLE__) && !defined(__FreeBSD__)
+ #include <linux/types.h>
+ #include <linux/pkt_sched.h>
++#else
++#define NETEM_DIST_SCALE 8192
++#endif
+
+ static const double a=3.0;
+ #define TABLESIZE 16384
+--- a/netem/paretonormal.c
++++ b/netem/paretonormal.c
+@@ -15,10 +15,13 @@
+ #include <string.h>
+ #include <math.h>
+ #include <limits.h>
++#if !defined(__APPLE__) && !defined(__FreeBSD__)
+ #include <malloc.h>
+-
+ #include <linux/types.h>
+ #include <linux/pkt_sched.h>
++#else
++#define NETEM_DIST_SCALE 8192
++#endif
+
+ #define TABLESIZE 16384
+ #define TABLEFACTOR NETEM_DIST_SCALE
diff --git a/package/network/utils/iproute2/patches/006-iproute2-tc_esfq.patch b/package/network/utils/iproute2/patches/006-iproute2-tc_esfq.patch
new file mode 100644
index 0000000..8016dbb
--- /dev/null
+++ b/package/network/utils/iproute2/patches/006-iproute2-tc_esfq.patch
@@ -0,0 +1,219 @@
+---
+ include/linux/pkt_sched.h | 59 +++++++++++++
+ tc/Makefile | 1
+ tc/q_esfq.c | 200 ++++++++++++++++++++++++++++++++++++++++++++++
+ 3 files changed, 260 insertions(+)
+
+--- a/tc/Makefile
++++ b/tc/Makefile
+@@ -8,6 +8,7 @@ SHARED_LIBS ?= y
+ TCMODULES :=
+ TCMODULES += q_fifo.o
+ TCMODULES += q_sfq.o
++TCMODULES += q_esfq.o
+ TCMODULES += q_red.o
+ TCMODULES += q_prio.o
+ TCMODULES += q_tbf.o
+--- /dev/null
++++ b/tc/q_esfq.c
+@@ -0,0 +1,200 @@
++/*
++ * q_esfq.c ESFQ.
++ *
++ * 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 of the License, or (at your option) any later version.
++ *
++ * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
++ *
++ * Changes: Alexander Atanasov, <alex@ssi.bg>
++ * Alexander Clouter, <alex@digriz.org.uk>
++ * Corey Hickey, <bugfood-c@fatooh.org>
++ *
++ */
++
++#include <stdio.h>
++#include <stdlib.h>
++#include <unistd.h>
++#include <syslog.h>
++#include <fcntl.h>
++#include <math.h>
++#include <sys/socket.h>
++#include <netinet/in.h>
++#include <arpa/inet.h>
++#include <string.h>
++
++#include "utils.h"
++#include "tc_util.h"
++
++static void explain(void)
++{
++ fprintf(stderr, "Usage: ... esfq [ perturb SECS ] [ quantum BYTES ] [ depth FLOWS ]\n\t[ divisor HASHBITS ] [ limit PKTS ] [ hash HASHTYPE]\n");
++ fprintf(stderr,"Where: \n");
++ fprintf(stderr,"HASHTYPE := { classic | src | dst | ctorigdst | ctorigsrc | ctrepldst | ctreplsrc | ctnatchg }\n");
++}
++
++#define usage() return(-1)
++
++static int esfq_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n)
++{
++ int ok=0;
++ struct tc_esfq_qopt opt;
++
++ memset(&opt, 0, sizeof(opt));
++
++ opt.hash_kind= TCA_SFQ_HASH_CLASSIC;
++
++ while (argc > 0) {
++ if (strcmp(*argv, "quantum") == 0) {
++ NEXT_ARG();
++ if (get_size(&opt.quantum, *argv)) {
++ fprintf(stderr, "Illegal \"quantum\"\n");
++ return -1;
++ }
++ ok++;
++ } else if (strcmp(*argv, "perturb") == 0) {
++ NEXT_ARG();
++ if (get_integer(&opt.perturb_period, *argv, 0)) {
++ fprintf(stderr, "Illegal \"perturb\"\n");
++ return -1;
++ }
++ ok++;
++ } else if (strcmp(*argv, "depth") == 0) {
++ NEXT_ARG();
++ if (get_integer((int *) &opt.flows, *argv, 0)) {
++ fprintf(stderr, "Illegal \"depth\"\n");
++ return -1;
++ }
++ ok++;
++ } else if (strcmp(*argv, "divisor") == 0) {
++ NEXT_ARG();
++ if (get_integer((int *) &opt.divisor, *argv, 0)) {
++ fprintf(stderr, "Illegal \"divisor\"\n");
++ return -1;
++ }
++ if(opt.divisor >= 14) {
++ fprintf(stderr, "Illegal \"divisor\": must be < 14\n");
++ return -1;
++ }
++ opt.divisor=pow(2,opt.divisor);
++ ok++;
++ } else if (strcmp(*argv, "limit") == 0) {
++ NEXT_ARG();
++ if (get_integer((int *) &opt.limit, *argv, 0)) {
++ fprintf(stderr, "Illegal \"limit\"\n");
++ return -1;
++ }
++ ok++;
++ } else if (strcmp(*argv, "hash") == 0) {
++ NEXT_ARG();
++ if(strcmp(*argv, "classic") == 0) {
++ opt.hash_kind= TCA_SFQ_HASH_CLASSIC;
++ } else
++ if(strcmp(*argv, "dst") == 0) {
++ opt.hash_kind= TCA_SFQ_HASH_DST;
++ } else
++ if(strcmp(*argv, "src") == 0) {
++ opt.hash_kind= TCA_SFQ_HASH_SRC;
++ } else
++ if(strcmp(*argv, "ctorigsrc") == 0) {
++ opt.hash_kind= TCA_SFQ_HASH_CTORIGSRC;
++ } else
++ if(strcmp(*argv, "ctorigdst") == 0) {
++ opt.hash_kind= TCA_SFQ_HASH_CTORIGDST;
++ } else
++ if(strcmp(*argv, "ctreplsrc") == 0) {
++ opt.hash_kind= TCA_SFQ_HASH_CTREPLSRC;
++ } else
++ if(strcmp(*argv, "ctrepldst") == 0) {
++ opt.hash_kind= TCA_SFQ_HASH_CTREPLDST;
++ } else
++ if(strcmp(*argv, "ctnatchg") == 0) {
++ opt.hash_kind= TCA_SFQ_HASH_CTNATCHG;
++ } else {
++ fprintf(stderr, "Illegal \"hash\"\n");
++ explain();
++ return -1;
++ }
++ ok++;
++ } else if (strcmp(*argv, "help") == 0) {
++ explain();
++ return -1;
++ } else {
++ fprintf(stderr, "What is \"%s\"?\n", *argv);
++ explain();
++ return -1;
++ }
++ argc--; argv++;
++ }
++
++ if (ok)
++ addattr_l(n, 1024, TCA_OPTIONS, &opt, sizeof(opt));
++ return 0;
++}
++
++static int esfq_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
++{
++ struct tc_esfq_qopt *qopt;
++ SPRINT_BUF(b1);
++
++ if (opt == NULL)
++ return 0;
++
++ if (RTA_PAYLOAD(opt) < sizeof(*qopt))
++ return -1;
++ qopt = RTA_DATA(opt);
++ fprintf(f, "quantum %s ", sprint_size(qopt->quantum, b1));
++ if (show_details) {
++ fprintf(f, "limit %up flows %u/%u ",
++ qopt->limit, qopt->flows, qopt->divisor);
++ }
++ if (qopt->perturb_period)
++ fprintf(f, "perturb %dsec ", qopt->perturb_period);
++
++ fprintf(f,"hash: ");
++ switch(qopt->hash_kind)
++ {
++ case TCA_SFQ_HASH_CLASSIC:
++ fprintf(f,"classic");
++ break;
++ case TCA_SFQ_HASH_DST:
++ fprintf(f,"dst");
++ break;
++ case TCA_SFQ_HASH_SRC:
++ fprintf(f,"src");
++ break;
++ case TCA_SFQ_HASH_CTORIGSRC:
++ fprintf(f,"ctorigsrc");
++ break;
++ case TCA_SFQ_HASH_CTORIGDST:
++ fprintf(f,"ctorigdst");
++ break;
++ case TCA_SFQ_HASH_CTREPLSRC:
++ fprintf(f,"ctreplsrc");
++ break;
++ case TCA_SFQ_HASH_CTREPLDST:
++ fprintf(f,"ctrepldst");
++ break;
++ case TCA_SFQ_HASH_CTNATCHG:
++ fprintf(f,"ctnatchg");
++ break;
++ default:
++ fprintf(f,"Unknown");
++ }
++ return 0;
++}
++
++static int esfq_print_xstats(struct qdisc_util *qu, FILE *f, struct rtattr *xstats)
++{
++ return 0;
++}
++
++
++struct qdisc_util esfq_qdisc_util = {
++ .id = "esfq",
++ .parse_qopt = esfq_parse_opt,
++ .print_qopt = esfq_print_opt,
++ .print_xstats = esfq_print_xstats,
++};
diff --git a/package/network/utils/iproute2/patches/007-no_arpd.patch b/package/network/utils/iproute2/patches/007-no_arpd.patch
new file mode 100644
index 0000000..6a7e24e
--- /dev/null
+++ b/package/network/utils/iproute2/patches/007-no_arpd.patch
@@ -0,0 +1,11 @@
+--- a/misc/Makefile
++++ b/misc/Makefile
+@@ -1,7 +1,7 @@
+ SSOBJ=ss.o ssfilter.o
+ LNSTATOBJ=lnstat.o lnstat_util.o
+
+-TARGETS=ss nstat ifstat rtacct arpd lnstat
++TARGETS=ss nstat ifstat rtacct lnstat
+
+ include ../Config
+
diff --git a/package/network/utils/iproute2/patches/008-no_netem.patch b/package/network/utils/iproute2/patches/008-no_netem.patch
new file mode 100644
index 0000000..a6a74aa
--- /dev/null
+++ b/package/network/utils/iproute2/patches/008-no_netem.patch
@@ -0,0 +1,11 @@
+--- a/Makefile
++++ b/Makefile
+@@ -34,7 +34,7 @@ WFLAGS = -Wall -Wstrict-prototypes
+ CFLAGS = $(WFLAGS) $(CCOPTS) -I../include $(DEFINES)
+ YACCFLAGS = -d -t -v
+
+-SUBDIRS=lib ip tc bridge misc netem genl man
++SUBDIRS=lib ip tc bridge misc genl man
+
+ LIBNETLINK=../lib/libnetlink.a ../lib/libutil.a
+ LDLIBS += $(LIBNETLINK)
diff --git a/package/network/utils/iproute2/patches/100-allow_pfifo_fast.patch b/package/network/utils/iproute2/patches/100-allow_pfifo_fast.patch
new file mode 100644
index 0000000..b31d4b7
--- /dev/null
+++ b/package/network/utils/iproute2/patches/100-allow_pfifo_fast.patch
@@ -0,0 +1,13 @@
+---
+ tc/q_fifo.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/tc/q_fifo.c
++++ b/tc/q_fifo.c
+@@ -98,5 +98,6 @@ struct qdisc_util pfifo_head_drop_qdisc_
+ extern int prio_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt);
+ struct qdisc_util pfifo_fast_qdisc_util = {
+ .id = "pfifo_fast",
++ .parse_qopt = fifo_parse_opt,
+ .print_qopt = prio_print_opt,
+ };
diff --git a/package/network/utils/iproute2/patches/110-extra-ccopts.patch b/package/network/utils/iproute2/patches/110-extra-ccopts.patch
new file mode 100644
index 0000000..f4ef8d7
--- /dev/null
+++ b/package/network/utils/iproute2/patches/110-extra-ccopts.patch
@@ -0,0 +1,11 @@
+--- a/Makefile
++++ b/Makefile
+@@ -29,7 +29,7 @@ ADDLIB+=ipx_ntop.o ipx_pton.o
+ CC = gcc
+ HOSTCC = gcc
+ DEFINES += -D_GNU_SOURCE
+-CCOPTS = -O2
++CCOPTS = -O2 $(EXTRA_CCOPTS)
+ WFLAGS = -Wall -Wstrict-prototypes
+ CFLAGS = $(WFLAGS) $(CCOPTS) -I../include $(DEFINES)
+ YACCFLAGS = -d -t -v
diff --git a/package/network/utils/iproute2/patches/120-libnetlink-pic.patch b/package/network/utils/iproute2/patches/120-libnetlink-pic.patch
new file mode 100644
index 0000000..c7b78d0
--- /dev/null
+++ b/package/network/utils/iproute2/patches/120-libnetlink-pic.patch
@@ -0,0 +1,8 @@
+--- a/lib/Makefile
++++ b/lib/Makefile
+@@ -1,4 +1,4 @@
+-CFLAGS += -fPIC
++CFLAGS+=$(FPIC)
+
+ UTILOBJ=utils.o rt_names.o ll_types.o ll_proto.o ll_addr.o inet_proto.o
+
diff --git a/package/network/utils/iproute2/patches/200-act_connmark.patch b/package/network/utils/iproute2/patches/200-act_connmark.patch
new file mode 100644
index 0000000..4a48ac3
--- /dev/null
+++ b/package/network/utils/iproute2/patches/200-act_connmark.patch
@@ -0,0 +1,84 @@
+--- a/tc/Makefile
++++ b/tc/Makefile
+@@ -38,6 +38,7 @@ TCMODULES += m_mirred.o
+ TCMODULES += m_nat.o
+ TCMODULES += m_pedit.o
+ TCMODULES += m_skbedit.o
++TCMODULES += m_connmark.o
+ TCMODULES += m_csum.o
+ TCMODULES += p_ip.o
+ TCMODULES += p_icmp.o
+--- /dev/null
++++ b/tc/m_connmark.c
+@@ -0,0 +1,71 @@
++/*
++ * m_connmark.c Connection tracking marking import
++ *
++ * Copyright (c) 2011 Felix Fietkau <nbd@openwrt.org>
++ *
++ * This program is free software; you can redistribute it and/or modify it
++ * under the terms and conditions of the GNU General Public License,
++ * version 2, as published by the Free Software Foundation.
++ *
++ * This program is distributed in the hope 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.
++ */
++
++#include <stdio.h>
++#include <stdlib.h>
++#include <unistd.h>
++#include <string.h>
++#include "utils.h"
++#include "tc_util.h"
++
++static void
++explain(void)
++{
++ fprintf(stderr, "Usage: ... connmark\n");
++}
++
++static void
++usage(void)
++{
++ explain();
++ exit(-1);
++}
++
++static int
++parse_connmark(struct action_util *a, int *argc_p, char ***argv_p, int tca_id,
++ struct nlmsghdr *n)
++{
++ int argc = *argc_p;
++ char **argv = *argv_p;
++
++ if (matches(*argv, "connmark") != 0)
++ return -1;
++
++ NEXT_ARG();
++
++ *argc_p = argc;
++ *argv_p = argv;
++ return 0;
++}
++
++static int print_connmark(struct action_util *au, FILE *f, struct rtattr *arg)
++{
++ if (arg == NULL)
++ return -1;
++
++ fprintf(f, " connmark");
++
++ return 0;
++}
++
++struct action_util connmark_action_util = {
++ .id = "connmark",
++ .parse_aopt = parse_connmark,
++ .print_aopt = print_connmark,
++};
diff --git a/package/network/utils/iproute2/patches/210-build-unbreak-linkage-of-m_xt.so.patch b/package/network/utils/iproute2/patches/210-build-unbreak-linkage-of-m_xt.so.patch
new file mode 100644
index 0000000..7fb2c11
--- /dev/null
+++ b/package/network/utils/iproute2/patches/210-build-unbreak-linkage-of-m_xt.so.patch
@@ -0,0 +1,58 @@
+From 11e8a1034656eba6571401286b99dabbd9842dac Mon Sep 17 00:00:00 2001
+From: Jan Engelhardt <jengelh@inai.de>
+Date: Tue, 18 Dec 2012 09:18:45 -0800
+Subject: [PATCH] build: unbreak linakge of m_xt.so
+
+Commit v3.7.0~10 caused the variable new PKG_CONFIG variable never
+to be present at the time of calling make, leading to tc/m_xt.so
+not linked with -lxtables (result from pkg-config xtables --libs),
+that in turn leading to
+
+tc: symbol lookup error: /usr/lib64/tc//m_xt.so: undefined symbol:
+xtables_init_all
+
+Fixing that.
+
+Signed-off-by: Jan Engelhardt <jengelh@inai.de>
+
+Conflicts:
+ configure
+---
+ configure | 14 +++++++++++---
+ 1 file changed, 11 insertions(+), 3 deletions(-)
+
+--- a/configure
++++ b/configure
+@@ -2,14 +2,20 @@
+ # This is not an autconf generated configure
+ #
+ INCLUDE=${1:-"$PWD/include"}
+-: ${PKG_CONFIG:=pkg-config}
+-: ${CC=gcc}
+-echo "PKG_CONFIG:=${PKG_CONFIG}" >>Config
+
+ # Make a temp directory in build tree.
+ TMPDIR=$(mktemp -d config.XXXXXX)
+ trap 'status=$?; rm -rf $TMPDIR; exit $status' EXIT HUP INT QUIT TERM
+
++check_toolchain()
++{
++: ${PKG_CONFIG:=pkg-config}
++: ${AR=ar}
++: ${CC=gcc}
++echo "AR:=${AR}" >>Config
++echo "CC:=${CC}" >>Config
++}
++
+ check_atm()
+ {
+ cat >$TMPDIR/atmtest.c <<EOF
+@@ -224,6 +230,8 @@ rm -f $TMPDIR/ipsettest.c $TMPDIR/ipsett
+ }
+
+ echo "# Generated config based on" $INCLUDE >Config
++echo "PKG_CONFIG:=${PKG_CONFIG}" >>Config
++check_toolchain
+
+ echo "TC schedulers"
+
diff --git a/package/network/utils/ipset/.svn/entries b/package/network/utils/ipset/.svn/entries
new file mode 100644
index 0000000..6d5ac00
--- /dev/null
+++ b/package/network/utils/ipset/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/utils/ipset
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-12-18T14:50:44.792508Z
+34752
+juhosg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+4c6384b2033cc87d2e05ddab6fbc32ce
+2012-12-18T14:50:44.792508Z
+34752
+juhosg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1991
+
diff --git a/package/network/utils/ipset/.svn/text-base/Makefile.svn-base b/package/network/utils/ipset/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..fd48a5d
--- /dev/null
+++ b/package/network/utils/ipset/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,82 @@
+
+# Copyright (C) 2009-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+#
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=ipset
+PKG_VERSION:=6.16.1
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=http://ipset.netfilter.org
+PKG_MD5SUM:=9fd70c825f052db7dc9d5ba0562b7083
+
+PKG_MAINTAINER:=Jo-Philipp Wich <jow@openwrt.org>
+
+PKG_FIXUP:=autoreconf
+PKG_INSTALL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/ipset/Default
+ DEPENDS:= @(!(TARGET_ps3||TARGET_pxcab)||BROKEN)
+endef
+
+define Package/ipset
+$(call Package/ipset/Default)
+ SECTION:=net
+ CATEGORY:=Network
+ DEPENDS+= +iptables-mod-ipset +kmod-ipt-ipset +libmnl
+ TITLE:=IPset administration utility
+ URL:=http://ipset.netfilter.org/
+endef
+
+CONFIGURE_ARGS += \
+ --with-kbuild="$(LINUX_DIR)"
+
+MAKE_FLAGS += \
+ ARCH="$(LINUX_KARCH)"
+
+IPSET_MODULES:= \
+ ipset/ip_set \
+ ipset/ip_set_bitmap_ip \
+ ipset/ip_set_bitmap_ipmac \
+ ipset/ip_set_bitmap_port \
+ ipset/ip_set_hash_ip \
+ ipset/ip_set_hash_ipport \
+ ipset/ip_set_hash_ipportip \
+ ipset/ip_set_hash_ipportnet \
+ ipset/ip_set_hash_net \
+ ipset/ip_set_hash_netiface \
+ ipset/ip_set_hash_netport \
+ ipset/ip_set_list_set \
+ xt_set \
+
+define Build/Compile
+ $(call Build/Compile/Default)
+ $(call Build/Compile/Default,modules)
+endef
+
+define Package/ipset/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(CP) $(PKG_INSTALL_DIR)/usr/sbin/ipset $(1)/usr/sbin/
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libipset*.so* $(1)/usr/lib/
+endef
+
+define KernelPackage/ipt-ipset
+$(call Package/ipset/Default)
+ SUBMENU:=Netfilter Extensions
+ TITLE:=IPset netfilter modules
+ DEPENDS+= +kmod-ipt-core +kmod-nfnetlink
+ FILES:=$(foreach mod,$(IPSET_MODULES),$(PKG_BUILD_DIR)/kernel/net/netfilter/$(mod).ko)
+ AUTOLOAD:=$(call AutoLoad,49,$(notdir $(IPSET_MODULES)))
+endef
+
+$(eval $(call BuildPackage,ipset))
+$(eval $(call KernelPackage,ipt-ipset))
diff --git a/package/network/utils/ipset/Makefile b/package/network/utils/ipset/Makefile
new file mode 100644
index 0000000..fd48a5d
--- /dev/null
+++ b/package/network/utils/ipset/Makefile
@@ -0,0 +1,82 @@
+
+# Copyright (C) 2009-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+#
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=ipset
+PKG_VERSION:=6.16.1
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=http://ipset.netfilter.org
+PKG_MD5SUM:=9fd70c825f052db7dc9d5ba0562b7083
+
+PKG_MAINTAINER:=Jo-Philipp Wich <jow@openwrt.org>
+
+PKG_FIXUP:=autoreconf
+PKG_INSTALL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/ipset/Default
+ DEPENDS:= @(!(TARGET_ps3||TARGET_pxcab)||BROKEN)
+endef
+
+define Package/ipset
+$(call Package/ipset/Default)
+ SECTION:=net
+ CATEGORY:=Network
+ DEPENDS+= +iptables-mod-ipset +kmod-ipt-ipset +libmnl
+ TITLE:=IPset administration utility
+ URL:=http://ipset.netfilter.org/
+endef
+
+CONFIGURE_ARGS += \
+ --with-kbuild="$(LINUX_DIR)"
+
+MAKE_FLAGS += \
+ ARCH="$(LINUX_KARCH)"
+
+IPSET_MODULES:= \
+ ipset/ip_set \
+ ipset/ip_set_bitmap_ip \
+ ipset/ip_set_bitmap_ipmac \
+ ipset/ip_set_bitmap_port \
+ ipset/ip_set_hash_ip \
+ ipset/ip_set_hash_ipport \
+ ipset/ip_set_hash_ipportip \
+ ipset/ip_set_hash_ipportnet \
+ ipset/ip_set_hash_net \
+ ipset/ip_set_hash_netiface \
+ ipset/ip_set_hash_netport \
+ ipset/ip_set_list_set \
+ xt_set \
+
+define Build/Compile
+ $(call Build/Compile/Default)
+ $(call Build/Compile/Default,modules)
+endef
+
+define Package/ipset/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(CP) $(PKG_INSTALL_DIR)/usr/sbin/ipset $(1)/usr/sbin/
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libipset*.so* $(1)/usr/lib/
+endef
+
+define KernelPackage/ipt-ipset
+$(call Package/ipset/Default)
+ SUBMENU:=Netfilter Extensions
+ TITLE:=IPset netfilter modules
+ DEPENDS+= +kmod-ipt-core +kmod-nfnetlink
+ FILES:=$(foreach mod,$(IPSET_MODULES),$(PKG_BUILD_DIR)/kernel/net/netfilter/$(mod).ko)
+ AUTOLOAD:=$(call AutoLoad,49,$(notdir $(IPSET_MODULES)))
+endef
+
+$(eval $(call BuildPackage,ipset))
+$(eval $(call KernelPackage,ipt-ipset))
diff --git a/package/network/utils/iptables/.svn/entries b/package/network/utils/iptables/.svn/entries
new file mode 100644
index 0000000..bdd1624
--- /dev/null
+++ b/package/network/utils/iptables/.svn/entries
@@ -0,0 +1,68 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/utils/iptables
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-07T08:48:41.905197Z
+35898
+cyrus
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+files
+dir
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+7f365c42ebe4096df97d25ee1c4f710e
+2013-03-07T08:48:41.905197Z
+35898
+cyrus
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+10534
+
diff --git a/package/network/utils/iptables/.svn/prop-base/Makefile.svn-base b/package/network/utils/iptables/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..8e522ae
--- /dev/null
+++ b/package/network/utils/iptables/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:copyright
+V 30
+Copyright (C) 2006 OpenWrt.org
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/utils/iptables/.svn/text-base/Makefile.svn-base b/package/network/utils/iptables/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..9d695c6
--- /dev/null
+++ b/package/network/utils/iptables/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,453 @@
+#
+# Copyright (C) 2006-2013 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=iptables
+PKG_VERSION:=1.4.18
+PKG_RELEASE:=2
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=http://www.netfilter.org/projects/iptables/files \
+ ftp://ftp.be.netfilter.org/pub/netfilter/iptables/ \
+ ftp://ftp.de.netfilter.org/pub/netfilter/iptables/ \
+ ftp://ftp.no.netfilter.org/pub/netfilter/iptables/
+PKG_MD5SUM:=a819199d5ec013b82da13a8ffbba857e
+
+PKG_FIXUP:=autoreconf
+PKG_INSTALL:=1
+PKG_BUILD_PARALLEL:=1
+
+ifneq ($(CONFIG_EXTERNAL_KERNEL_TREE),"")
+PATCH_DIR:=
+endif
+
+include $(INCLUDE_DIR)/package.mk
+ifeq ($(DUMP),)
+ -include $(LINUX_DIR)/.config
+ include $(INCLUDE_DIR)/netfilter.mk
+ STAMP_CONFIGURED:=$(strip $(STAMP_CONFIGURED))_$(shell $(SH_FUNC) grep 'NETFILTER' $(LINUX_DIR)/.config | md5s)
+endif
+
+
+define Package/iptables/Default
+ SECTION:=net
+ CATEGORY:=Network
+ SUBMENU:=Firewall
+ URL:=http://netfilter.org/
+endef
+
+define Package/iptables/Module
+$(call Package/iptables/Default)
+ DEPENDS:=iptables $(1)
+endef
+
+define Package/iptables
+$(call Package/iptables/Default)
+ TITLE:=IP firewall administration tool
+ MENU:=1
+ DEPENDS+= +kmod-ipt-core +libip4tc +IPV6:libip6tc +libxtables
+endef
+
+define Package/iptables/description
+IP firewall administration tool.
+
+ Matches:
+ - icmp
+ - tcp
+ - udp
+ - comment
+ - limit
+ - mac
+ - multiport
+
+ Targets:
+ - ACCEPT
+ - DROP
+ - REJECT
+ - LOG
+ - TCPMSS
+
+ Tables:
+ - filter
+ - mangle
+
+endef
+
+define Package/iptables-mod-conntrack-extra
+$(call Package/iptables/Module, +kmod-ipt-conntrack-extra)
+ TITLE:=Extra connection tracking extensions
+endef
+
+define Package/iptables-mod-conntrack-extra/description
+Extra iptables extensions for connection tracking.
+
+ Matches:
+ - connbytes
+ - connmark
+ - recent
+ - helper
+
+ Targets:
+ - CONNMARK
+
+endef
+
+define Package/iptables-mod-filter
+$(call Package/iptables/Module, +kmod-ipt-filter)
+ TITLE:=Content inspection extensions
+endef
+
+define Package/iptables-mod-filter/description
+iptables extensions for packet content inspection.
+Includes support for:
+
+ Matches:
+ - layer7
+ - string
+
+endef
+
+define Package/iptables-mod-ipopt
+$(call Package/iptables/Module, +kmod-ipt-ipopt)
+ TITLE:=IP/Packet option extensions
+endef
+
+define Package/iptables-mod-ipopt/description
+iptables extensions for matching/changing IP packet options.
+
+ Matches:
+ - dscp
+ - ecn
+ - length
+ - mark
+ - statistic
+ - tcpmss
+ - time
+ - unclean
+ - hl
+
+ Targets:
+ - DSCP
+ - CLASSIFY
+ - ECN
+ - MARK
+ - HL
+
+endef
+
+define Package/iptables-mod-ipsec
+$(call Package/iptables/Module, +kmod-ipt-ipsec)
+ TITLE:=IPsec extensions
+endef
+
+define Package/iptables-mod-ipsec/description
+iptables extensions for matching ipsec traffic.
+
+ Matches:
+ - ah
+ - esp
+ - policy
+
+endef
+
+define Package/iptables-mod-ipset
+$(call Package/iptables/Module,)
+ TITLE:=IPset iptables extensions
+endef
+
+define Package/iptables-mod-ipset/description
+IPset iptables extensions.
+
+ Matches:
+ - set
+
+ Targets:
+ - SET
+
+endef
+
+define Package/iptables-mod-nat-extra
+$(call Package/iptables/Module, +kmod-ipt-nat-extra)
+ TITLE:=Extra NAT extensions
+endef
+
+define Package/iptables-mod-nat-extra/description
+iptables extensions for extra NAT targets.
+
+ Targets:
+ - MIRROR
+ - NETMAP
+ - REDIRECT
+endef
+
+define Package/iptables-mod-ulog
+$(call Package/iptables/Module, +kmod-ipt-ulog)
+ TITLE:=user-space packet logging
+endef
+
+define Package/iptables-mod-ulog/description
+iptables extensions for user-space packet logging.
+
+ Targets:
+ - ULOG
+
+endef
+
+define Package/iptables-mod-hashlimit
+$(call Package/iptables/Module, +kmod-ipt-hashlimit)
+ TITLE:=hashlimit matching
+endef
+
+define Package/iptables-mod-hashlimit/description
+iptables extensions for hashlimit matching
+
+ Matches:
+ - hashlimit
+
+endef
+
+define Package/iptables-mod-iprange
+$(call Package/iptables/Module, +kmod-ipt-iprange)
+ TITLE:=IP range extension
+endef
+
+define Package/iptables-mod-iprange/description
+iptables extensions for matching ip ranges.
+
+ Matches:
+ - iprange
+
+endef
+
+define Package/iptables-mod-extra
+$(call Package/iptables/Module, +kmod-ipt-extra)
+ TITLE:=Other extra iptables extensions
+endef
+
+define Package/iptables-mod-extra/description
+Other extra iptables extensions.
+
+ Matches:
+ - addrtype
+ - condition
+ - owner
+ - physdev (if ebtables is enabled)
+ - pkttype
+ - quota
+
+endef
+
+define Package/iptables-mod-led
+$(call Package/iptables/Module, +kmod-ipt-led)
+ TITLE:=LED trigger iptables extension
+endef
+
+define Package/iptables-mod-led/description
+iptables extension for triggering a LED.
+
+ Targets:
+ - LED
+
+endef
+
+define Package/iptables-mod-tproxy
+$(call Package/iptables/Module, +kmod-ipt-tproxy)
+ TITLE:=Transparent proxy iptables extensions
+endef
+
+define Package/iptables-mod-tproxy/description
+Transparent proxy iptables extensions.
+
+ Matches:
+ - socket
+
+ Targets:
+ - TPROXY
+
+endef
+
+define Package/iptables-mod-tee
+$(call Package/iptables/Module, +kmod-ipt-tee)
+ TITLE:=TEE iptables extensions
+endef
+
+define Package/iptables-mod-tee/description
+TEE iptables extensions.
+
+ Targets:
+ - TEE
+
+endef
+
+define Package/iptables-mod-u32
+$(call Package/iptables/Module, +kmod-ipt-u32)
+ TITLE:=U32 iptables extensions
+endef
+
+define Package/iptables-mod-u32/description
+U32 iptables extensions.
+
+ Matches:
+ - u32
+
+endef
+
+define Package/ip6tables
+$(call Package/iptables/Default)
+ DEPENDS:=@IPV6 +kmod-ip6tables +iptables
+ CATEGORY:=IPv6
+ TITLE:=IPv6 firewall administration tool
+ MENU:=1
+endef
+
+define Package/libiptc
+$(call Package/iptables/Default)
+ SECTION:=libs
+ CATEGORY:=Libraries
+ DEPENDS:=+libip4tc +libip6tc
+ TITLE:=IPv4/IPv6 firewall - shared libiptc library (compatibility stub)
+endef
+
+define Package/libip4tc
+$(call Package/iptables/Default)
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=IPv4 firewall - shared libiptc library
+endef
+
+define Package/libip6tc
+$(call Package/iptables/Default)
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=IPv6 firewall - shared libiptc library
+endef
+
+define Package/libxtables
+ $(call Package/iptables/Default)
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=IPv4/IPv6 firewall - shared xtables library
+endef
+
+TARGET_CPPFLAGS := \
+ -I$(PKG_BUILD_DIR)/include \
+ -I$(LINUX_DIR)/user_headers/include \
+ $(TARGET_CPPFLAGS)
+
+TARGET_CFLAGS += \
+ -I$(PKG_BUILD_DIR)/include \
+ -I$(LINUX_DIR)/user_headers/include
+
+CONFIGURE_ARGS += \
+ --enable-shared \
+ --enable-devel \
+ $(if $(CONFIG_IPV6),--enable-ipv6,--disable-ipv6) \
+ --with-kernel="$(LINUX_DIR)/user_headers" \
+ --with-xtlibdir=/usr/lib/iptables \
+ --enable-static
+
+MAKE_FLAGS := \
+ $(TARGET_CONFIGURE_OPTS) \
+ COPT_FLAGS="$(TARGET_CFLAGS)" \
+ KERNEL_DIR="$(LINUX_DIR)/user_headers/" PREFIX=/usr \
+ KBUILD_OUTPUT="$(LINUX_DIR)" \
+ BUILTIN_MODULES="$(patsubst ip6t_%,%,$(patsubst ipt_%,%,$(patsubst xt_%,%,$(IPT_BUILTIN) $(IPT_CONNTRACK-m) $(IPT_NAT-m))))"
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include
+ $(INSTALL_DIR) $(1)/usr/include/iptables
+ $(INSTALL_DIR) $(1)/usr/include/net/netfilter
+
+ # XXX: iptables header fixup, some headers are not installed by iptables anymore
+ $(CP) $(PKG_BUILD_DIR)/include/iptables/*.h $(1)/usr/include/iptables/
+ $(CP) $(PKG_BUILD_DIR)/include/iptables.h $(1)/usr/include/
+ $(CP) $(PKG_BUILD_DIR)/include/ip6tables.h $(1)/usr/include/
+ $(CP) $(PKG_BUILD_DIR)/include/libipulog $(1)/usr/include/
+ $(CP) $(PKG_BUILD_DIR)/include/libiptc $(1)/usr/include/
+
+ $(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libxtables.so* $(1)/usr/lib/
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libip*tc.so* $(1)/usr/lib/
+ $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/xtables.pc $(1)/usr/lib/pkgconfig/
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libiptc.pc $(1)/usr/lib/pkgconfig/
+endef
+
+define Package/iptables/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(CP) $(PKG_INSTALL_DIR)/usr/sbin/xtables-multi $(1)/usr/sbin/
+ $(CP) $(PKG_INSTALL_DIR)/usr/sbin/iptables{,-restore,-save} $(1)/usr/sbin/
+ $(INSTALL_DIR) $(1)/usr/lib/iptables
+endef
+
+define Package/ip6tables/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(CP) $(PKG_INSTALL_DIR)/usr/sbin/ip6tables{,-restore,-save} $(1)/usr/sbin/
+endef
+
+define Package/libiptc/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libiptc.so* $(1)/usr/lib/
+endef
+
+define Package/libip4tc/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libip4tc.so* $(1)/usr/lib/
+endef
+
+define Package/libip6tc/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libip6tc.so* $(1)/usr/lib/
+endef
+
+define Package/libxtables/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libxtables.so* $(1)/usr/lib/
+endef
+
+define BuildPlugin
+ define Package/$(1)/install
+ $(INSTALL_DIR) $$(1)/usr/lib/iptables
+ for m in $(patsubst xt_%,ipt_%,$(2)) $(patsubst ipt_%,xt_%,$(2)) $(patsubst xt_%,ip6t_%,$(2)) $(patsubst ip6t_%,xt_%,$(2)); do \
+ if [ -f $(PKG_INSTALL_DIR)/usr/lib/iptables/lib$$$$$$$${m}.so ]; then \
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/iptables/lib$$$$$$$${m}.so $$(1)/usr/lib/iptables/ ; \
+ fi; \
+ done
+ $(3)
+ endef
+
+ $$(eval $$(call BuildPackage,$(1)))
+endef
+
+L7_INSTALL:=\
+ $(INSTALL_DIR) $$(1)/etc/l7-protocols; \
+ $(CP) files/l7/*.pat $$(1)/etc/l7-protocols/
+
+
+$(eval $(call BuildPackage,iptables))
+$(eval $(call BuildPlugin,iptables-mod-conntrack-extra,$(IPT_CONNTRACK_EXTRA-m)))
+$(eval $(call BuildPlugin,iptables-mod-extra,$(IPT_EXTRA-m)))
+$(eval $(call BuildPlugin,iptables-mod-filter,$(IPT_FILTER-m),$(L7_INSTALL)))
+$(eval $(call BuildPlugin,iptables-mod-ipopt,$(IPT_IPOPT-m)))
+$(eval $(call BuildPlugin,iptables-mod-ipsec,$(IPT_IPSEC-m)))
+$(eval $(call BuildPlugin,iptables-mod-ipset,ipt_set ipt_SET))
+$(eval $(call BuildPlugin,iptables-mod-nat-extra,$(IPT_NAT_EXTRA-m)))
+$(eval $(call BuildPlugin,iptables-mod-iprange,$(IPT_IPRANGE-m)))
+$(eval $(call BuildPlugin,iptables-mod-ulog,$(IPT_ULOG-m)))
+$(eval $(call BuildPlugin,iptables-mod-hashlimit,$(IPT_HASHLIMIT-m)))
+$(eval $(call BuildPlugin,iptables-mod-led,$(IPT_LED-m)))
+$(eval $(call BuildPlugin,iptables-mod-tproxy,$(IPT_TPROXY-m)))
+$(eval $(call BuildPlugin,iptables-mod-tee,$(IPT_TEE-m)))
+$(eval $(call BuildPlugin,iptables-mod-u32,$(IPT_U32-m)))
+$(eval $(call BuildPackage,ip6tables))
+$(eval $(call BuildPackage,libiptc))
+$(eval $(call BuildPackage,libip4tc))
+$(eval $(call BuildPackage,libip6tc))
+$(eval $(call BuildPackage,libxtables))
diff --git a/package/network/utils/iptables/Makefile b/package/network/utils/iptables/Makefile
new file mode 100644
index 0000000..9d695c6
--- /dev/null
+++ b/package/network/utils/iptables/Makefile
@@ -0,0 +1,453 @@
+#
+# Copyright (C) 2006-2013 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=iptables
+PKG_VERSION:=1.4.18
+PKG_RELEASE:=2
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=http://www.netfilter.org/projects/iptables/files \
+ ftp://ftp.be.netfilter.org/pub/netfilter/iptables/ \
+ ftp://ftp.de.netfilter.org/pub/netfilter/iptables/ \
+ ftp://ftp.no.netfilter.org/pub/netfilter/iptables/
+PKG_MD5SUM:=a819199d5ec013b82da13a8ffbba857e
+
+PKG_FIXUP:=autoreconf
+PKG_INSTALL:=1
+PKG_BUILD_PARALLEL:=1
+
+ifneq ($(CONFIG_EXTERNAL_KERNEL_TREE),"")
+PATCH_DIR:=
+endif
+
+include $(INCLUDE_DIR)/package.mk
+ifeq ($(DUMP),)
+ -include $(LINUX_DIR)/.config
+ include $(INCLUDE_DIR)/netfilter.mk
+ STAMP_CONFIGURED:=$(strip $(STAMP_CONFIGURED))_$(shell $(SH_FUNC) grep 'NETFILTER' $(LINUX_DIR)/.config | md5s)
+endif
+
+
+define Package/iptables/Default
+ SECTION:=net
+ CATEGORY:=Network
+ SUBMENU:=Firewall
+ URL:=http://netfilter.org/
+endef
+
+define Package/iptables/Module
+$(call Package/iptables/Default)
+ DEPENDS:=iptables $(1)
+endef
+
+define Package/iptables
+$(call Package/iptables/Default)
+ TITLE:=IP firewall administration tool
+ MENU:=1
+ DEPENDS+= +kmod-ipt-core +libip4tc +IPV6:libip6tc +libxtables
+endef
+
+define Package/iptables/description
+IP firewall administration tool.
+
+ Matches:
+ - icmp
+ - tcp
+ - udp
+ - comment
+ - limit
+ - mac
+ - multiport
+
+ Targets:
+ - ACCEPT
+ - DROP
+ - REJECT
+ - LOG
+ - TCPMSS
+
+ Tables:
+ - filter
+ - mangle
+
+endef
+
+define Package/iptables-mod-conntrack-extra
+$(call Package/iptables/Module, +kmod-ipt-conntrack-extra)
+ TITLE:=Extra connection tracking extensions
+endef
+
+define Package/iptables-mod-conntrack-extra/description
+Extra iptables extensions for connection tracking.
+
+ Matches:
+ - connbytes
+ - connmark
+ - recent
+ - helper
+
+ Targets:
+ - CONNMARK
+
+endef
+
+define Package/iptables-mod-filter
+$(call Package/iptables/Module, +kmod-ipt-filter)
+ TITLE:=Content inspection extensions
+endef
+
+define Package/iptables-mod-filter/description
+iptables extensions for packet content inspection.
+Includes support for:
+
+ Matches:
+ - layer7
+ - string
+
+endef
+
+define Package/iptables-mod-ipopt
+$(call Package/iptables/Module, +kmod-ipt-ipopt)
+ TITLE:=IP/Packet option extensions
+endef
+
+define Package/iptables-mod-ipopt/description
+iptables extensions for matching/changing IP packet options.
+
+ Matches:
+ - dscp
+ - ecn
+ - length
+ - mark
+ - statistic
+ - tcpmss
+ - time
+ - unclean
+ - hl
+
+ Targets:
+ - DSCP
+ - CLASSIFY
+ - ECN
+ - MARK
+ - HL
+
+endef
+
+define Package/iptables-mod-ipsec
+$(call Package/iptables/Module, +kmod-ipt-ipsec)
+ TITLE:=IPsec extensions
+endef
+
+define Package/iptables-mod-ipsec/description
+iptables extensions for matching ipsec traffic.
+
+ Matches:
+ - ah
+ - esp
+ - policy
+
+endef
+
+define Package/iptables-mod-ipset
+$(call Package/iptables/Module,)
+ TITLE:=IPset iptables extensions
+endef
+
+define Package/iptables-mod-ipset/description
+IPset iptables extensions.
+
+ Matches:
+ - set
+
+ Targets:
+ - SET
+
+endef
+
+define Package/iptables-mod-nat-extra
+$(call Package/iptables/Module, +kmod-ipt-nat-extra)
+ TITLE:=Extra NAT extensions
+endef
+
+define Package/iptables-mod-nat-extra/description
+iptables extensions for extra NAT targets.
+
+ Targets:
+ - MIRROR
+ - NETMAP
+ - REDIRECT
+endef
+
+define Package/iptables-mod-ulog
+$(call Package/iptables/Module, +kmod-ipt-ulog)
+ TITLE:=user-space packet logging
+endef
+
+define Package/iptables-mod-ulog/description
+iptables extensions for user-space packet logging.
+
+ Targets:
+ - ULOG
+
+endef
+
+define Package/iptables-mod-hashlimit
+$(call Package/iptables/Module, +kmod-ipt-hashlimit)
+ TITLE:=hashlimit matching
+endef
+
+define Package/iptables-mod-hashlimit/description
+iptables extensions for hashlimit matching
+
+ Matches:
+ - hashlimit
+
+endef
+
+define Package/iptables-mod-iprange
+$(call Package/iptables/Module, +kmod-ipt-iprange)
+ TITLE:=IP range extension
+endef
+
+define Package/iptables-mod-iprange/description
+iptables extensions for matching ip ranges.
+
+ Matches:
+ - iprange
+
+endef
+
+define Package/iptables-mod-extra
+$(call Package/iptables/Module, +kmod-ipt-extra)
+ TITLE:=Other extra iptables extensions
+endef
+
+define Package/iptables-mod-extra/description
+Other extra iptables extensions.
+
+ Matches:
+ - addrtype
+ - condition
+ - owner
+ - physdev (if ebtables is enabled)
+ - pkttype
+ - quota
+
+endef
+
+define Package/iptables-mod-led
+$(call Package/iptables/Module, +kmod-ipt-led)
+ TITLE:=LED trigger iptables extension
+endef
+
+define Package/iptables-mod-led/description
+iptables extension for triggering a LED.
+
+ Targets:
+ - LED
+
+endef
+
+define Package/iptables-mod-tproxy
+$(call Package/iptables/Module, +kmod-ipt-tproxy)
+ TITLE:=Transparent proxy iptables extensions
+endef
+
+define Package/iptables-mod-tproxy/description
+Transparent proxy iptables extensions.
+
+ Matches:
+ - socket
+
+ Targets:
+ - TPROXY
+
+endef
+
+define Package/iptables-mod-tee
+$(call Package/iptables/Module, +kmod-ipt-tee)
+ TITLE:=TEE iptables extensions
+endef
+
+define Package/iptables-mod-tee/description
+TEE iptables extensions.
+
+ Targets:
+ - TEE
+
+endef
+
+define Package/iptables-mod-u32
+$(call Package/iptables/Module, +kmod-ipt-u32)
+ TITLE:=U32 iptables extensions
+endef
+
+define Package/iptables-mod-u32/description
+U32 iptables extensions.
+
+ Matches:
+ - u32
+
+endef
+
+define Package/ip6tables
+$(call Package/iptables/Default)
+ DEPENDS:=@IPV6 +kmod-ip6tables +iptables
+ CATEGORY:=IPv6
+ TITLE:=IPv6 firewall administration tool
+ MENU:=1
+endef
+
+define Package/libiptc
+$(call Package/iptables/Default)
+ SECTION:=libs
+ CATEGORY:=Libraries
+ DEPENDS:=+libip4tc +libip6tc
+ TITLE:=IPv4/IPv6 firewall - shared libiptc library (compatibility stub)
+endef
+
+define Package/libip4tc
+$(call Package/iptables/Default)
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=IPv4 firewall - shared libiptc library
+endef
+
+define Package/libip6tc
+$(call Package/iptables/Default)
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=IPv6 firewall - shared libiptc library
+endef
+
+define Package/libxtables
+ $(call Package/iptables/Default)
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=IPv4/IPv6 firewall - shared xtables library
+endef
+
+TARGET_CPPFLAGS := \
+ -I$(PKG_BUILD_DIR)/include \
+ -I$(LINUX_DIR)/user_headers/include \
+ $(TARGET_CPPFLAGS)
+
+TARGET_CFLAGS += \
+ -I$(PKG_BUILD_DIR)/include \
+ -I$(LINUX_DIR)/user_headers/include
+
+CONFIGURE_ARGS += \
+ --enable-shared \
+ --enable-devel \
+ $(if $(CONFIG_IPV6),--enable-ipv6,--disable-ipv6) \
+ --with-kernel="$(LINUX_DIR)/user_headers" \
+ --with-xtlibdir=/usr/lib/iptables \
+ --enable-static
+
+MAKE_FLAGS := \
+ $(TARGET_CONFIGURE_OPTS) \
+ COPT_FLAGS="$(TARGET_CFLAGS)" \
+ KERNEL_DIR="$(LINUX_DIR)/user_headers/" PREFIX=/usr \
+ KBUILD_OUTPUT="$(LINUX_DIR)" \
+ BUILTIN_MODULES="$(patsubst ip6t_%,%,$(patsubst ipt_%,%,$(patsubst xt_%,%,$(IPT_BUILTIN) $(IPT_CONNTRACK-m) $(IPT_NAT-m))))"
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include
+ $(INSTALL_DIR) $(1)/usr/include/iptables
+ $(INSTALL_DIR) $(1)/usr/include/net/netfilter
+
+ # XXX: iptables header fixup, some headers are not installed by iptables anymore
+ $(CP) $(PKG_BUILD_DIR)/include/iptables/*.h $(1)/usr/include/iptables/
+ $(CP) $(PKG_BUILD_DIR)/include/iptables.h $(1)/usr/include/
+ $(CP) $(PKG_BUILD_DIR)/include/ip6tables.h $(1)/usr/include/
+ $(CP) $(PKG_BUILD_DIR)/include/libipulog $(1)/usr/include/
+ $(CP) $(PKG_BUILD_DIR)/include/libiptc $(1)/usr/include/
+
+ $(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libxtables.so* $(1)/usr/lib/
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libip*tc.so* $(1)/usr/lib/
+ $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/xtables.pc $(1)/usr/lib/pkgconfig/
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libiptc.pc $(1)/usr/lib/pkgconfig/
+endef
+
+define Package/iptables/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(CP) $(PKG_INSTALL_DIR)/usr/sbin/xtables-multi $(1)/usr/sbin/
+ $(CP) $(PKG_INSTALL_DIR)/usr/sbin/iptables{,-restore,-save} $(1)/usr/sbin/
+ $(INSTALL_DIR) $(1)/usr/lib/iptables
+endef
+
+define Package/ip6tables/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(CP) $(PKG_INSTALL_DIR)/usr/sbin/ip6tables{,-restore,-save} $(1)/usr/sbin/
+endef
+
+define Package/libiptc/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libiptc.so* $(1)/usr/lib/
+endef
+
+define Package/libip4tc/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libip4tc.so* $(1)/usr/lib/
+endef
+
+define Package/libip6tc/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libip6tc.so* $(1)/usr/lib/
+endef
+
+define Package/libxtables/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libxtables.so* $(1)/usr/lib/
+endef
+
+define BuildPlugin
+ define Package/$(1)/install
+ $(INSTALL_DIR) $$(1)/usr/lib/iptables
+ for m in $(patsubst xt_%,ipt_%,$(2)) $(patsubst ipt_%,xt_%,$(2)) $(patsubst xt_%,ip6t_%,$(2)) $(patsubst ip6t_%,xt_%,$(2)); do \
+ if [ -f $(PKG_INSTALL_DIR)/usr/lib/iptables/lib$$$$$$$${m}.so ]; then \
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/iptables/lib$$$$$$$${m}.so $$(1)/usr/lib/iptables/ ; \
+ fi; \
+ done
+ $(3)
+ endef
+
+ $$(eval $$(call BuildPackage,$(1)))
+endef
+
+L7_INSTALL:=\
+ $(INSTALL_DIR) $$(1)/etc/l7-protocols; \
+ $(CP) files/l7/*.pat $$(1)/etc/l7-protocols/
+
+
+$(eval $(call BuildPackage,iptables))
+$(eval $(call BuildPlugin,iptables-mod-conntrack-extra,$(IPT_CONNTRACK_EXTRA-m)))
+$(eval $(call BuildPlugin,iptables-mod-extra,$(IPT_EXTRA-m)))
+$(eval $(call BuildPlugin,iptables-mod-filter,$(IPT_FILTER-m),$(L7_INSTALL)))
+$(eval $(call BuildPlugin,iptables-mod-ipopt,$(IPT_IPOPT-m)))
+$(eval $(call BuildPlugin,iptables-mod-ipsec,$(IPT_IPSEC-m)))
+$(eval $(call BuildPlugin,iptables-mod-ipset,ipt_set ipt_SET))
+$(eval $(call BuildPlugin,iptables-mod-nat-extra,$(IPT_NAT_EXTRA-m)))
+$(eval $(call BuildPlugin,iptables-mod-iprange,$(IPT_IPRANGE-m)))
+$(eval $(call BuildPlugin,iptables-mod-ulog,$(IPT_ULOG-m)))
+$(eval $(call BuildPlugin,iptables-mod-hashlimit,$(IPT_HASHLIMIT-m)))
+$(eval $(call BuildPlugin,iptables-mod-led,$(IPT_LED-m)))
+$(eval $(call BuildPlugin,iptables-mod-tproxy,$(IPT_TPROXY-m)))
+$(eval $(call BuildPlugin,iptables-mod-tee,$(IPT_TEE-m)))
+$(eval $(call BuildPlugin,iptables-mod-u32,$(IPT_U32-m)))
+$(eval $(call BuildPackage,ip6tables))
+$(eval $(call BuildPackage,libiptc))
+$(eval $(call BuildPackage,libip4tc))
+$(eval $(call BuildPackage,libip6tc))
+$(eval $(call BuildPackage,libxtables))
diff --git a/package/network/utils/iptables/files/.svn/entries b/package/network/utils/iptables/files/.svn/entries
new file mode 100644
index 0000000..3317803
--- /dev/null
+++ b/package/network/utils/iptables/files/.svn/entries
@@ -0,0 +1,31 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/utils/iptables/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2009-05-01T15:20:34.240067Z
+15544
+hauke
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+l7
+dir
+
diff --git a/package/network/utils/iptables/files/l7/.svn/entries b/package/network/utils/iptables/files/l7/.svn/entries
new file mode 100644
index 0000000..40adf52
--- /dev/null
+++ b/package/network/utils/iptables/files/l7/.svn/entries
@@ -0,0 +1,572 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/utils/iptables/files/l7
+svn://svn.openwrt.org/openwrt
+
+
+
+2009-05-01T15:20:34.240067Z
+15544
+hauke
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+bittorrent.pat
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+df5febf5627392a1e6cdcd7a11d5bb12
+2009-05-01T15:20:34.240067Z
+15544
+hauke
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1211
+
+edonkey.pat
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+515ce55fca79d9ab254d70057b8d2d9c
+2009-05-01T15:20:34.240067Z
+15544
+hauke
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1656
+
+ssl.pat
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+c6698421723f87db9fc6d9c43b5e07ea
+2009-05-01T15:20:34.240067Z
+15544
+hauke
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+631
+
+ntp.pat
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+b3fae202057d0cbc090f23e3e80e7482
+2009-05-01T15:20:34.240067Z
+15544
+hauke
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+649
+
+ident.pat
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+6526938d492d341160c3ea99002c6eb3
+2009-05-01T15:20:34.240067Z
+15544
+hauke
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+575
+
+msnmessenger.pat
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+c410016ed85dabdbb07c284d02a1abc4
+2009-05-01T15:20:34.240067Z
+15544
+hauke
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1180
+
+aim.pat
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+b087b770a3afc46d7bc638b66fd2c03c
+2009-05-01T15:20:34.240067Z
+15544
+hauke
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1170
+
+gnutella.pat
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+70aa11c8fe9f286fe4e416453d7d56b9
+2009-05-01T15:20:34.240067Z
+15544
+hauke
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2237
+
+irc.pat
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+f404f0bb98e30ec52068aaa9b00a7aae
+2009-05-01T15:20:34.240067Z
+15544
+hauke
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+833
+
+http.pat
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+d5795d2270a70c637deb473c570e71b1
+2009-05-01T15:20:34.240067Z
+15544
+hauke
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1386
+
+pop3.pat
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+a645ae5e78b76044c3f70798b9b92401
+2009-05-01T15:20:34.240067Z
+15544
+hauke
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2244
+
+fasttrack.pat
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+e3449f58b0e3ca7de4327273098c7b76
+2009-05-01T15:20:34.240067Z
+15544
+hauke
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1336
+
+smtp.pat
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+8be5298dde31912cbac136ef6c4aa15e
+2009-05-01T15:20:34.240067Z
+15544
+hauke
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1783
+
+jabber.pat
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+7ec7c3038efb725b9e99bb5c40d9c4aa
+2009-05-01T15:20:34.240067Z
+15544
+hauke
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+984
+
+vnc.pat
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+997e4932fe2cd8da707ec1dc8f15d4ae
+2009-05-01T15:20:34.240067Z
+15544
+hauke
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+927
+
+ftp.pat
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+e3191313469ad6ad2a0cda3048e64044
+2009-05-01T15:20:34.240067Z
+15544
+hauke
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1851
+
diff --git a/package/network/utils/iptables/files/l7/.svn/prop-base/aim.pat.svn-base b/package/network/utils/iptables/files/l7/.svn/prop-base/aim.pat.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/network/utils/iptables/files/l7/.svn/prop-base/aim.pat.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/utils/iptables/files/l7/.svn/prop-base/bittorrent.pat.svn-base b/package/network/utils/iptables/files/l7/.svn/prop-base/bittorrent.pat.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/network/utils/iptables/files/l7/.svn/prop-base/bittorrent.pat.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/utils/iptables/files/l7/.svn/prop-base/edonkey.pat.svn-base b/package/network/utils/iptables/files/l7/.svn/prop-base/edonkey.pat.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/network/utils/iptables/files/l7/.svn/prop-base/edonkey.pat.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/utils/iptables/files/l7/.svn/prop-base/fasttrack.pat.svn-base b/package/network/utils/iptables/files/l7/.svn/prop-base/fasttrack.pat.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/network/utils/iptables/files/l7/.svn/prop-base/fasttrack.pat.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/utils/iptables/files/l7/.svn/prop-base/ftp.pat.svn-base b/package/network/utils/iptables/files/l7/.svn/prop-base/ftp.pat.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/network/utils/iptables/files/l7/.svn/prop-base/ftp.pat.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/utils/iptables/files/l7/.svn/prop-base/gnutella.pat.svn-base b/package/network/utils/iptables/files/l7/.svn/prop-base/gnutella.pat.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/network/utils/iptables/files/l7/.svn/prop-base/gnutella.pat.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/utils/iptables/files/l7/.svn/prop-base/http.pat.svn-base b/package/network/utils/iptables/files/l7/.svn/prop-base/http.pat.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/network/utils/iptables/files/l7/.svn/prop-base/http.pat.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/utils/iptables/files/l7/.svn/prop-base/ident.pat.svn-base b/package/network/utils/iptables/files/l7/.svn/prop-base/ident.pat.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/network/utils/iptables/files/l7/.svn/prop-base/ident.pat.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/utils/iptables/files/l7/.svn/prop-base/irc.pat.svn-base b/package/network/utils/iptables/files/l7/.svn/prop-base/irc.pat.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/network/utils/iptables/files/l7/.svn/prop-base/irc.pat.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/utils/iptables/files/l7/.svn/prop-base/jabber.pat.svn-base b/package/network/utils/iptables/files/l7/.svn/prop-base/jabber.pat.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/network/utils/iptables/files/l7/.svn/prop-base/jabber.pat.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/utils/iptables/files/l7/.svn/prop-base/msnmessenger.pat.svn-base b/package/network/utils/iptables/files/l7/.svn/prop-base/msnmessenger.pat.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/network/utils/iptables/files/l7/.svn/prop-base/msnmessenger.pat.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/utils/iptables/files/l7/.svn/prop-base/ntp.pat.svn-base b/package/network/utils/iptables/files/l7/.svn/prop-base/ntp.pat.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/network/utils/iptables/files/l7/.svn/prop-base/ntp.pat.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/utils/iptables/files/l7/.svn/prop-base/pop3.pat.svn-base b/package/network/utils/iptables/files/l7/.svn/prop-base/pop3.pat.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/network/utils/iptables/files/l7/.svn/prop-base/pop3.pat.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/utils/iptables/files/l7/.svn/prop-base/smtp.pat.svn-base b/package/network/utils/iptables/files/l7/.svn/prop-base/smtp.pat.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/network/utils/iptables/files/l7/.svn/prop-base/smtp.pat.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/utils/iptables/files/l7/.svn/prop-base/ssl.pat.svn-base b/package/network/utils/iptables/files/l7/.svn/prop-base/ssl.pat.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/network/utils/iptables/files/l7/.svn/prop-base/ssl.pat.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/utils/iptables/files/l7/.svn/prop-base/vnc.pat.svn-base b/package/network/utils/iptables/files/l7/.svn/prop-base/vnc.pat.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/network/utils/iptables/files/l7/.svn/prop-base/vnc.pat.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/utils/iptables/files/l7/.svn/text-base/aim.pat.svn-base b/package/network/utils/iptables/files/l7/.svn/text-base/aim.pat.svn-base
new file mode 100644
index 0000000..5c43930
--- /dev/null
+++ b/package/network/utils/iptables/files/l7/.svn/text-base/aim.pat.svn-base
@@ -0,0 +1,28 @@
+# AIM - AOL instant messenger (OSCAR and TOC)
+# Pattern attributes: good slow notsofast
+# Protocol groups: chat proprietary
+# Wiki: http://www.protocolinfo.org/wiki/AIM
+# Copyright (C) 2008 Matthew Strait, Ethan Sommer; See ../LICENSE
+#
+# Usually runs on port 5190
+#
+# This may also match ICQ traffic.
+#
+# This pattern has been tested and is believed to work well.
+
+aim
+# See http://gridley.res.carleton.edu/~straitm/final (and various other places)
+# The first bit matches OSCAR signon and data commands, but not sure what
+# \x03\x0b matches, but it works apparently.
+# The next three bits match various parts of the TOC signon process.
+# The third one is the magic number "*", then 0x01 for "signon", then up to four
+# bytes ("up to" because l7-filter strips out nulls) which contain a sequence
+# number (2 bytes) the data length (2 more) and 3 nulls (which don't count),
+# then 0x01 for the version number (not sure if there ever has been another
+# version)
+# The fourth one is a command string, followed by some stuff, then the
+# beginning of the "roasted" password
+
+# This pattern is too slow!
+
+^(\*[\x01\x02].*\x03\x0b|\*\x01.?.?.?.?\x01)|flapon|toc_signon.*0x
diff --git a/package/network/utils/iptables/files/l7/.svn/text-base/bittorrent.pat.svn-base b/package/network/utils/iptables/files/l7/.svn/text-base/bittorrent.pat.svn-base
new file mode 100644
index 0000000..4a3ba88
--- /dev/null
+++ b/package/network/utils/iptables/files/l7/.svn/text-base/bittorrent.pat.svn-base
@@ -0,0 +1,25 @@
+# Bittorrent - P2P filesharing / publishing tool - http://www.bittorrent.com
+# Pattern attributes: good slow594 notsofast undermatch
+# Protocol groups: p2p open_source
+# Wiki: http://www.protocolinfo.org/wiki/Bittorrent
+# Copyright (C) 2008 Matthew Strait, Ethan Sommer; See ../LICENSE
+#
+# This pattern has been tested and is believed to work well.
+# It will, however, not work on bittorrent streams that are encrypted, since
+# it's impossible to match (well) encrypted data.
+
+bittorrent
+
+# Does not attempt to match the HTTP download of the tracker
+# 0x13 is the length of "bittorrent protocol"
+# Second two bits match UDP wierdness
+# Next bit matches something Azureus does
+# Ditto on the next bit. Could also match on "user-agent: azureus", but that's in the next
+# packet and perhaps this will match multiple clients.
+# bitcomet-specific strings contributed by liangjun.
+
+# This is not a valid GNU basic regular expression (but that's ok).
+^(\x13bittorrent protocol|azver\x01$|get /scrape\?info_hash=get /announce\?info_hash=|get /client/bitcomet/|GET /data\?fid=)|d1:ad2:id20:|\x08'7P\)[RP]
+
+# This pattern is "fast", but won't catch as much
+#^(\x13bittorrent protocol|azver\x01$|get /scrape\?info_hash=)
diff --git a/package/network/utils/iptables/files/l7/.svn/text-base/edonkey.pat.svn-base b/package/network/utils/iptables/files/l7/.svn/text-base/edonkey.pat.svn-base
new file mode 100644
index 0000000..75807f8
--- /dev/null
+++ b/package/network/utils/iptables/files/l7/.svn/text-base/edonkey.pat.svn-base
@@ -0,0 +1,37 @@
+# eDonkey2000 - P2P filesharing - http://edonkey2000.com and others
+# Pattern attributes: good veryfast fast overmatch
+# Protocol groups: p2p
+# Wiki: http://www.protocolinfo.org/wiki/EDonkey
+# Copyright (C) 2008 Matthew Strait, Ethan Sommer; See ../LICENSE
+#
+# Tested recently (April/May 2006) with eMule 0.47a and eDonkey2000 1.4
+# and a long time ago with something else.
+#
+# In addition to matching what you might expect, this matches much of
+# what eMule does when you tell it to only connect to the KAD network.
+# I don't quite know what to make of this.
+
+# Thanks to Matt Skidmore <fox AT woozle.org>
+
+edonkey
+
+# http://gd.tuwien.ac.at/opsys/linux/sf/p/pdonkey/eDonkey-protocol-0.6
+#
+# In addition to \xe3, \xc5 and \xd4, I see a lot of \xe5.
+# As of April 2006, I also see some \xe4.
+#
+# God this is a mess. What an irritating protocol.
+# This will match about 2% of streams with random data in them!
+# (But fortunately much fewer than 2% of streams that are other protocols.
+# You can test this with the data in ../testing/)
+
+^[\xc5\xd4\xe3-\xe5].?.?.?.?([\x01\x02\x05\x14\x15\x16\x18\x19\x1a\x1b\x1c\x20\x21\x32\x33\x34\x35\x36\x38\x40\x41\x42\x43\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50\x51\x52\x53\x54\x55\x56\x57\x58[\x60\x81\x82\x90\x91\x93\x96\x97\x98\x99\x9a\x9b\x9c\x9e\xa0\xa1\xa2\xa3\xa4]|\x59................?[ -~]|\x96....$)
+
+# matches everything and too much
+# ^(\xe3|\xc5|\xd4)
+
+# ipp2p essentially uses "\xe3....\x47", which doesn't seem at all right to me.
+
+# bandwidtharbitrator uses
+# e0.*@.*6[a-z].*p$|e0.*@.*[a-z]6[a-z].*p0$|e.*@.*[0-9]6.*p$|emule|edonkey
+# no comments to explain what all the mush is, of course...
diff --git a/package/network/utils/iptables/files/l7/.svn/text-base/fasttrack.pat.svn-base b/package/network/utils/iptables/files/l7/.svn/text-base/fasttrack.pat.svn-base
new file mode 100644
index 0000000..6ed8ff1
--- /dev/null
+++ b/package/network/utils/iptables/files/l7/.svn/text-base/fasttrack.pat.svn-base
@@ -0,0 +1,23 @@
+# FastTrack - P2P filesharing (Kazaa, Morpheus, iMesh, Grokster, etc)
+# Pattern attributes: good slow notsofast
+# Protocol groups: p2p
+# Wiki: http://www.protocolinfo.org/wiki/Fasttrack
+# Copyright (C) 2008 Matthew Strait, Ethan Sommer; See ../LICENSE
+#
+# Tested with Kazaa Lite Resurrection 0.0.7.6F
+#
+# This appears to match the download connections well, but not the search
+# connections (I think they are encrypted :-( ).
+
+fasttrack
+# while this is a valid http request, this will be caught because
+# the http pattern matches the response (and therefore the next packet)
+# Even so, it's best to put this match earlier in the chain.
+# http://cvs.berlios.de/cgi-bin/viewcvs.cgi/gift-fasttrack/giFT-FastTrack/PROTOCOL?rev=HEAD&content-type=text/vnd.viewcvs-markup
+
+# This pattern is kinda slow, but not too bad.
+^get (/.download/[ -~]*|/.supernode[ -~]|/.status[ -~]|/.network[ -~]*|/.files|/.hash=[0-9a-f]*/[ -~]*) http/1.1|user-agent: kazaa|x-kazaa(-username|-network|-ip|-supernodeip|-xferid|-xferuid|tag)|^give [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]?[0-9]?[0-9]?
+
+# This isn't much faster:
+#^get (/.download/.*|/.supernode.|/.status.|/.network.*|/.files|/.hash=[0-9a-f]*/.*) http/1.1|user-agent: kazaa|x-kazaa(-username|-network|-ip|-supernodeip|-xferid|-xferuid|tag)|^give [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]?[0-9]?[0-9]?
+
diff --git a/package/network/utils/iptables/files/l7/.svn/text-base/ftp.pat.svn-base b/package/network/utils/iptables/files/l7/.svn/text-base/ftp.pat.svn-base
new file mode 100644
index 0000000..44d97c4
--- /dev/null
+++ b/package/network/utils/iptables/files/l7/.svn/text-base/ftp.pat.svn-base
@@ -0,0 +1,46 @@
+# FTP - File Transfer Protocol - RFC 959
+# Pattern attributes: great notsofast fast
+# Protocol groups: document_retrieval ietf_internet_standard
+# Wiki: http://protocolinfo.org/wiki/FTP
+# Copyright (C) 2008 Matthew Strait, Ethan Sommer; See ../LICENSE
+#
+# Usually runs on port 21. Note that the data stream is on a dynamically
+# assigned port, which means that you will need the FTP connection
+# tracking module in your kernel to usefully match FTP data transfers.
+#
+# This pattern is well tested.
+#
+# Handles the first two things a server should say:
+#
+# First, the server says it's ready by sending "220". Most servers say
+# something after 220, even though they don't have to, and it usually
+# includes the string "ftp" (l7-filter is case insensitive). This
+# includes proftpd, vsftpd, wuftpd, warftpd, pureftpd, Bulletproof FTP
+# Server, and whatever ftp.microsoft.com uses. Almost all servers use only
+# ASCII printable characters between the "220" and the "FTP", but non-English
+# ones might use others.
+#
+# The next thing the server sends is a 331. All the above servers also
+# send something including "password" after this code. By default, we
+# do not match on this because it takes another packet and is more work
+# for regexec.
+
+ftp
+# by default, we allow only ASCII
+^220[\x09-\x0d -~]*ftp
+
+# This covers UTF-8 as well
+#^220[\x09-\x0d -~\x80-\xfd]*ftp
+
+# This allows any characters and is about 4x faster than either of the above
+# (which are about the same as each other)
+#^220.*ftp
+
+# This is much slower
+#^220[\x09-\x0d -~]*ftp|331[\x09-\x0d -~]*password
+
+# This pattern is more precise, but takes longer to match. (3 packets vs. 1)
+#^220[\x09-\x0d -~]*\x0d\x0aUSER[\x09-\x0d -~]*\x0d\x0a331
+
+# same as above, but slightly less precise and only takes 2 packets.
+#^220[\x09-\x0d -~]*\x0d\x0aUSER[\x09-\x0d -~]*\x0d\x0a
diff --git a/package/network/utils/iptables/files/l7/.svn/text-base/gnutella.pat.svn-base b/package/network/utils/iptables/files/l7/.svn/text-base/gnutella.pat.svn-base
new file mode 100644
index 0000000..770ed43
--- /dev/null
+++ b/package/network/utils/iptables/files/l7/.svn/text-base/gnutella.pat.svn-base
@@ -0,0 +1,34 @@
+# Gnutella - P2P filesharing
+# Pattern attributes: good notsofast notsofast
+# Protocol groups: p2p open_source
+# Wiki: http://www.protocolinfo.org/wiki/Gnutella
+# Copyright (C) 2008 Matthew Strait, Ethan Sommer; See ../LICENSE
+#
+# This should match both Gnutella and "Gnutella2" ("Mike's protocol")
+#
+# Various clients use this protocol including Mactella, Shareaza,
+# GTK-gnutella, Gnucleus, Gnotella, LimeWire, iMesh and BearShare.
+#
+# This is tested with gtk-gnutella and Shareaza.
+
+# http://www.gnutella2.com/tiki-index.php?page=UDP%20Transceiver
+# http://rfc-gnutella.sf.net/
+# http://www.gnutella2.com/tiki-index.php?page=Gnutella2%20Specification
+# http://en.wikipedia.org/wiki/Shareaza
+
+gnutella
+
+# The first part matches UDP messages - All start with "GND", then have
+# a flag byte which is either \x00, \x01 or \x02, then two sequence bytes
+# that can be anything, then a fragment number, which must start at 1.
+# The rest matches TCP first client message or first server message (in case
+# we can't see client messages). Some parts of this are empirical rather than
+# document based. Assumes version is between 0.0 and 2.9. (usually is
+# 0.4 or 0.6). I'm guessing at many of the user-agents.
+# The last bit is emprical and probably only matches Limewire.
+^(gnd[\x01\x02]?.?.?\x01|gnutella connect/[012]\.[0-9]\x0d\x0a|get /uri-res/n2r\?urn:sha1:|get /.*user-agent: (gtk-gnutella|bearshare|mactella|gnucleus|gnotella|limewire|imesh)|get /.*content-type: application/x-gnutella-packets|giv [0-9]*:[0-9a-f]*/|queue [0-9a-f]* [1-9][0-9]?[0-9]?\.[1-9][0-9]?[0-9]?\.[1-9][0-9]?[0-9]?\.[1-9][0-9]?[0-9]?:[1-9][0-9]?[0-9]?[0-9]?|gnutella.*content-type: application/x-gnutella|...................?lime)
+
+# Needlessly precise, at the expense of time
+#^(gnd[\x01\x02]?.?.?\x01|gnutella connect/[012]\.[0-9]\x0d\x0a|get /uri-res/n2r\?urn:sha1:|get /[\x09-\x0d -~]*user-agent: (gtk-gnutella|bearshare|mactella|gnucleus|gnotella|limewire|imesh)|get /[\x09-\x0d -~]*content-type: application/x-gnutella-packets|giv [0-9]*:[0-9a-f]*/|queue [0-9a-f]* [1-9][0-9]?[0-9]?\.[1-9][0-9]?[0-9]?\.[1-9][0-9]?[0-9]?\.[1-9][0-9]?[0-9]?:[1-9][0-9]?[0-9]?[0-9]?|gnutella[\x09-\x0d -~]*content-type: application/x-gnutella|..................lime)
+
+
diff --git a/package/network/utils/iptables/files/l7/.svn/text-base/http.pat.svn-base b/package/network/utils/iptables/files/l7/.svn/text-base/http.pat.svn-base
new file mode 100644
index 0000000..5122310
--- /dev/null
+++ b/package/network/utils/iptables/files/l7/.svn/text-base/http.pat.svn-base
@@ -0,0 +1,28 @@
+# HTTP - HyperText Transfer Protocol - RFC 2616
+# Pattern attributes: great slow notsofast superset
+# Protocol groups: document_retrieval ietf_draft_standard
+# Wiki: http://protocolinfo.org/wiki/HTTP
+# Copyright (C) 2008 Matthew Strait, Ethan Sommer; See ../LICENSE
+#
+# Usually runs on port 80
+#
+# This pattern has been tested and is believed to work well.
+#
+# this intentionally catches the response from the server rather than
+# the request so that other protocols which use http (like kazaa) can be
+# caught based on specific http requests regardless of the ordering of
+# filters... also matches posts
+
+# Sites that serve really long cookies may break this by pushing the
+# server response too far away from the beginning of the connection. To
+# fix this, increase the kernel's data buffer length.
+
+http
+# Status-Line = HTTP-Version SP Status-Code SP Reason-Phrase CRLF (rfc 2616)
+# As specified in rfc 2616 a status code is preceeded and followed by a
+# space.
+http/(0\.9|1\.0|1\.1) [1-5][0-9][0-9] [\x09-\x0d -~]*(connection:|content-type:|content-length:|date:)|post [\x09-\x0d -~]* http/[01]\.[019]
+# A slightly faster version that might be good enough:
+#http/(0\.9|1\.0|1\.1) [1-5][0-9][0-9]|post [\x09-\x0d -~]* http/[01]\.[019]
+# old pattern(s):
+#(http[\x09-\x0d -~]*(200 ok|302 |304 )[\x09-\x0d -~]*(connection:|content-type:|content-length:))|^(post [\x09-\x0d -~]* http/)
diff --git a/package/network/utils/iptables/files/l7/.svn/text-base/ident.pat.svn-base b/package/network/utils/iptables/files/l7/.svn/text-base/ident.pat.svn-base
new file mode 100644
index 0000000..3205e5e
--- /dev/null
+++ b/package/network/utils/iptables/files/l7/.svn/text-base/ident.pat.svn-base
@@ -0,0 +1,15 @@
+# Ident - Identification Protocol - RFC 1413
+# Pattern attributes: good fast fast
+# Protocol groups: networking ietf_proposed_standard
+# Wiki: http://www.protocolinfo.org/wiki/Ident
+# Copyright (C) 2008 Matthew Strait, Ethan Sommer; See ../LICENSE
+#
+# Usually runs on port 113
+#
+# This pattern is believed to work.
+
+ident
+# "number , numberCRLF" possibly without the CR and/or LF.
+# ^$ is appropriate because the first packet should never have anything
+# else in it.
+^[1-9][0-9]?[0-9]?[0-9]?[0-9]?[\x09-\x0d]*,[\x09-\x0d]*[1-9][0-9]?[0-9]?[0-9]?[0-9]?(\x0d\x0a|[\x0d\x0a])?$
diff --git a/package/network/utils/iptables/files/l7/.svn/text-base/irc.pat.svn-base b/package/network/utils/iptables/files/l7/.svn/text-base/irc.pat.svn-base
new file mode 100644
index 0000000..e25360c
--- /dev/null
+++ b/package/network/utils/iptables/files/l7/.svn/text-base/irc.pat.svn-base
@@ -0,0 +1,20 @@
+# IRC - Internet Relay Chat - RFC 1459
+# Pattern attributes: great veryfast fast
+# Protocol groups: chat ietf_proposed_standard
+# Wiki: http://www.protocolinfo.org/wiki/IRC
+# Copyright (C) 2008 Matthew Strait, Ethan Sommer; See ../LICENSE
+#
+# Usually runs on port 6666 or 6667
+# Note that chat traffic runs on these ports, but IRC-DCC traffic (which
+# can use much more bandwidth) uses a dynamically assigned port, so you
+# must have the IRC connection tracking module in your kernel to classify
+# this.
+#
+# This pattern has been tested and is believed to work well.
+
+irc
+# First thing that happens is that the client sends NICK and USER, in
+# either order. This allows MIRC color codes (\x02-\x0d instead of
+# \x09-\x0d).
+^(nick[\x09-\x0d -~]*user[\x09-\x0d -~]*:|user[\x09-\x0d -~]*:[\x02-\x0d -~]*nick[\x09-\x0d -~]*\x0d\x0a)
+
diff --git a/package/network/utils/iptables/files/l7/.svn/text-base/jabber.pat.svn-base b/package/network/utils/iptables/files/l7/.svn/text-base/jabber.pat.svn-base
new file mode 100644
index 0000000..7c32890
--- /dev/null
+++ b/package/network/utils/iptables/files/l7/.svn/text-base/jabber.pat.svn-base
@@ -0,0 +1,24 @@
+# Jabber (XMPP) - open instant messenger protocol - RFC 3920 - http://jabber.org
+# Pattern attributes: good notsofast notsofast
+# Protocol groups: chat ietf_proposed_standard
+# Wiki: http://www.protocolinfo.org/wiki/Jabber
+# Copyright (C) 2008 Matthew Strait, Ethan Sommer; See ../LICENSE
+#
+# This pattern has been tested with Gaim and Gabber. It is only tested
+# with non-SSL mode Jabber with no proxies.
+
+# Thanks to Jan Hudec for some improvements.
+
+# Jabber seems to take a long time to set up a connection. I'm
+# connecting with Gabber 0.8.8 to 12jabber.org and the first 8 packets
+# is this:
+# <stream:stream to='12jabber.com' xmlns='jabber:client'
+# xmlns:stream='http://etherx.jabber.org/streams'><?xml
+# version='1.0'?><stream:stream
+# xmlns:stream='http://etherx.jabber.org/streams' id='3f73e951'
+# xmlns='jabber:client' from='12jabber.com'>
+#
+# No mention of my username or password yet, you'll note.
+
+jabber
+<stream:stream[\x09-\x0d ][ -~]*[\x09-\x0d ]xmlns=['"]jabber
diff --git a/package/network/utils/iptables/files/l7/.svn/text-base/msnmessenger.pat.svn-base b/package/network/utils/iptables/files/l7/.svn/text-base/msnmessenger.pat.svn-base
new file mode 100644
index 0000000..11dfc10
--- /dev/null
+++ b/package/network/utils/iptables/files/l7/.svn/text-base/msnmessenger.pat.svn-base
@@ -0,0 +1,28 @@
+# MSN Messenger - Microsoft Network chat client
+# Pattern attributes: good slow notsofast
+# Protocol groups: chat proprietary
+# Wiki: http://www.protocolinfo.org/wiki/MSN_Messenger
+# Copyright (C) 2008 Matthew Strait, Ethan Sommer; See ../LICENSE
+#
+# Usually uses TCP port 1863
+# http://www.hypothetic.org/docs/msn/index.php
+# http://msnpiki.msnfanatic.com/
+#
+# This pattern has been tested and is believed to work well.
+
+msnmessenger
+
+# First branch: login
+# ver: allow versions up to 99.
+# I've never seen a cvr other than cvr0. Maybe this will be trouble later?
+# Can't anchor at the beginning because sometimes this is encapsulated in
+# HTTP. But either way, the first packet ends like this.
+# Second/Third branches: accepting/sending a message
+# I will assume that these can also be encapsulated in HTTP, although I have
+# not checked. Example of each direction:
+# ANS 1 quadong@hotmail.com 1139803431.29427 17522047
+# USR 1 quadong@hotmail.com 530423708.968145.366138
+
+# Branches are written entirely separately for better performance.
+ver [0-9]+ msnp[1-9][0-9]? [\x09-\x0d -~]*cvr0\x0d\x0a$|usr 1 [!-~]+ [0-9. ]+\x0d\x0a$|ans 1 [!-~]+ [0-9. ]+\x0d\x0a$
+
diff --git a/package/network/utils/iptables/files/l7/.svn/text-base/ntp.pat.svn-base b/package/network/utils/iptables/files/l7/.svn/text-base/ntp.pat.svn-base
new file mode 100644
index 0000000..760cfdb
--- /dev/null
+++ b/package/network/utils/iptables/files/l7/.svn/text-base/ntp.pat.svn-base
@@ -0,0 +1,17 @@
+# (S)NTP - (Simple) Network Time Protocol - RFCs 1305 and 2030
+# Pattern attributes: good fast fast overmatch
+# Protocol groups: time_synchronization ietf_draft_standard
+# Wiki: http://www.protocolinfo.org/wiki/NTP
+# Copyright (C) 2008 Matthew Strait, Ethan Sommer; See ../LICENSE
+#
+# This pattern is tested and is believed to work.
+
+# client|server
+# Requires the server's timestamp to be in the present or future (of 2005).
+# Tested with ntpdate on Linux.
+# Assumes version 2, 3 or 4.
+
+# Note that ntp packets are always 48 bytes, so you should match on that too.
+
+ntp
+^([\x13\x1b\x23\xd3\xdb\xe3]|[\x14\x1c$].......?.?.?.?.?.?.?.?.?[\xc6-\xff])
diff --git a/package/network/utils/iptables/files/l7/.svn/text-base/pop3.pat.svn-base b/package/network/utils/iptables/files/l7/.svn/text-base/pop3.pat.svn-base
new file mode 100644
index 0000000..3ae4c14
--- /dev/null
+++ b/package/network/utils/iptables/files/l7/.svn/text-base/pop3.pat.svn-base
@@ -0,0 +1,50 @@
+# POP3 - Post Office Protocol version 3 (popular e-mail protocol) - RFC 1939
+# Pattern attributes: great veryfast fast
+# Protocol groups: mail ietf_internet_standard
+# Wiki: http://www.protocolinfo.org/wiki/POP
+# Copyright (C) 2008 Matthew Strait, Ethan Sommer; See ../LICENSE
+#
+# This pattern has been tested somewhat.
+
+# this is a difficult protocol to match because of the relative lack of
+# distinguishing information. Read on.
+pop3
+
+# this the most conservative pattern. It should definitely work.
+#^(\+ok|-err)
+
+# this pattern assumes that the server says _something_ after +ok or -err
+# I think this is probably the way to go.
+^(\+ok |-err )
+
+# more that 90% of servers seem to say "pop" after "+ok", but not all.
+#^(\+ok .*pop)
+
+# Here's another tack. I think this is my second favorite.
+#^(\+ok [\x09-\x0d -~]*(ready|hello|pop|starting)|-err [\x09-\x0d -~]*(invalid|unknown|unimplemented|unrecognized|command))
+
+# this matches the server saying "you have N messages that are M bytes",
+# which the client probably asks for early in the session (not tested)
+#\+ok [0-9]+ [0-9]+
+
+# some sample servers:
+# RFC example: +OK POP3 server ready <1896.697170952@dbc.mtview.ca.us>
+# mail.dreamhost.com: +OK Hello there.
+# pop.carleton.edu: +OK POP3D(*) Server PMDFV6.2.2 at Fri, 12 Sep 2003 19:28:10 -0500 (CDT) (APOP disabled)
+# mail.earthlink.net: +OK NGPopper vEL_4_38 at earthlink.net ready <25509.1063412951@falcon>
+# *.email.umn.edu: +OK Cubic Circle's v1.22 1998/04/11 POP3 ready <7d1e0000da67623f@aquamarine.tc.umn.edu>
+# mail.yale.edu: +OK POP3 pantheon-po01 v2002.81 server ready
+# mail.gustavus.edu: +OK POP3 solen v2001.78 server ready
+# mail.reed.edu: +OK POP3 letra.reed.edu v2002.81 server ready
+# mail.bowdoin.edu: +OK mail.bowdoin.edu POP3 service (iPlanet Messaging Server 5.2 HotFix 1.15 (built Apr 28 2003))
+# pop.colby.edu: +OK Qpopper (version 4.0.5) at basalt starting.
+# mail.mac.com: +OK Netscape Messaging Multiplexor ready
+
+# various error strings:
+#-ERR Invalid command.
+#-ERR invalid command
+#-ERR unimplemented
+#-ERR Invalid command, try one of: USER name, PASS string, QUIT
+#-ERR Unknown AUTHORIZATION state command
+#-ERR Unrecognized command
+#-ERR Unknown command: "sadf'".
diff --git a/package/network/utils/iptables/files/l7/.svn/text-base/smtp.pat.svn-base b/package/network/utils/iptables/files/l7/.svn/text-base/smtp.pat.svn-base
new file mode 100644
index 0000000..2f5d195
--- /dev/null
+++ b/package/network/utils/iptables/files/l7/.svn/text-base/smtp.pat.svn-base
@@ -0,0 +1,40 @@
+# SMTP - Simple Mail Transfer Protocol - RFC 2821 (See also RFC 1869)
+# Pattern attributes: great notsofast fast
+# Protocol groups: mail ietf_internet_standard
+# Wiki: http://www.protocolinfo.org/wiki/SMTP
+# Copyright (C) 2008 Matthew Strait, Ethan Sommer; See ../LICENSE
+#
+# usually runs on port 25
+#
+# This pattern has been tested and is believed to work well.
+
+# As usual, no text is required after "220", but all known servers have some
+# there. It (almost?) always has string "smtp" in it. The RFC examples
+# does not, so we match those too, just in case anyone has copied them
+# literally.
+#
+# Some examples:
+# 220 mail.stalker.com ESMTP CommuniGate Pro 4.1.3
+# 220 mail.vieodata.com ESMTP Merak 6.1.0; Mon, 15 Sep 2003 13:48:11 -0400
+# 220 mail.ut.caldera.com ESMTP
+# 220 persephone.pmail.gen.nz ESMTP server ready.
+# 220 smtp1.superb.net ESMTP
+# 220 mail.kerio.com Kerio MailServer 5.6.7 ESMTP ready
+# 220-mail.deerfield.com ESMTP VisNetic.MailServer.v6.0.9.0; Mon, 15 Sep 2003 13:4
+# 220 altn.com ESMTP MDaemon 6.8.5; Mon, 15 Sep 2003 12:46:42 -0500
+# 220 X1 NT-ESMTP Server ipsmin0165atl2.interland.net (IMail 6.06 73062-3)
+# 220 mail.icewarp.com ESMTP Merak 6.1.1; Mon, 15 Sep 2003 19:43:23 +0200
+# 220-mail.email-scan.com ESMTP
+# 220 smaug.dreamhost.com ESMTP
+# 220 kona.carleton.edu -- Server ESMTP (PMDF V6.2#30648)
+# 220 letra.reed.edu ESMTP Sendmail 8.12.9/8.12.9; Mon, 15 Sep 2003 10:35:57 -0700 (PDT)
+# 220-swan.mail.pas.earthlink.net ESMTP Exim 3.33 #1 Mon, 15 Sep 2003 10:32:15 -0700
+#
+# RFC examples:
+# 220 xyz.com Simple Mail Transfer Service Ready (RFC example)
+# 220 dbc.mtview.ca.us SMTP service ready
+
+smtp
+^220[\x09-\x0d -~]* (e?smtp|simple mail)
+userspace pattern=^220[\x09-\x0d -~]* (E?SMTP|[Ss]imple [Mm]ail)
+userspace flags=REG_NOSUB REG_EXTENDED
diff --git a/package/network/utils/iptables/files/l7/.svn/text-base/ssl.pat.svn-base b/package/network/utils/iptables/files/l7/.svn/text-base/ssl.pat.svn-base
new file mode 100644
index 0000000..ae30ee4
--- /dev/null
+++ b/package/network/utils/iptables/files/l7/.svn/text-base/ssl.pat.svn-base
@@ -0,0 +1,16 @@
+# SSL and TLS - Secure Socket Layer / Transport Layer Security - RFC 2246
+# Pattern attributes: good notsofast fast superset
+# Protocol groups: secure ietf_proposed_standard
+# Wiki: http://www.protocolinfo.org/wiki/SSL
+# Copyright (C) 2008 Matthew Strait, Ethan Sommer; See ../LICENSE
+#
+# Usually runs on port 443
+#
+# This is a superset of validcertssl. For it to match, it must be first.
+#
+# This pattern has been tested and is believed to work well.
+
+ssl
+# Server Hello with certificate | Client Hello
+# This allows SSL 3.X, which includes TLS 1.0, known internally as SSL 3.1
+^(.?.?\x16\x03.*\x16\x03|.?.?\x01\x03\x01?.*\x0b)
diff --git a/package/network/utils/iptables/files/l7/.svn/text-base/vnc.pat.svn-base b/package/network/utils/iptables/files/l7/.svn/text-base/vnc.pat.svn-base
new file mode 100644
index 0000000..79d0ae8
--- /dev/null
+++ b/package/network/utils/iptables/files/l7/.svn/text-base/vnc.pat.svn-base
@@ -0,0 +1,23 @@
+# VNC - Virtual Network Computing. Also known as RFB - Remote Frame Buffer
+# Pattern attributes: great veryfast fast
+# Protocol groups: remote_access
+# Wiki: http://www.protocolinfo.org/wiki/VNC
+# Copyright (C) 2008 Matthew Strait, Ethan Sommer; See ../LICENSE
+#
+# http://www.realvnc.com/documentation.html
+#
+# This pattern has been verified with vnc v3.3.7 on WinXP and Linux
+#
+# Thanks to Trevor Paskett <tpaskett AT cymphonix.com> for this pattern.
+
+vnc
+# Assumes single digit major and minor version numbers
+# This message should be all alone in the first packet, so ^$ is appropriate
+^rfb 00[1-9]\.00[0-9]\x0a$
+
+# This is a more restrictive version which assumes the version numbers
+# are ones actually in existance at the time of this writing, i.e. 3.3,
+# 3.7 and 3.8 (with some clients wrongly reporting 3.5). It should be
+# slightly faster, but probably not worth the extra maintenance.
+# ^rfb 003\.00[3578]\x0a$
+
diff --git a/package/network/utils/iptables/files/l7/aim.pat b/package/network/utils/iptables/files/l7/aim.pat
new file mode 100644
index 0000000..5c43930
--- /dev/null
+++ b/package/network/utils/iptables/files/l7/aim.pat
@@ -0,0 +1,28 @@
+# AIM - AOL instant messenger (OSCAR and TOC)
+# Pattern attributes: good slow notsofast
+# Protocol groups: chat proprietary
+# Wiki: http://www.protocolinfo.org/wiki/AIM
+# Copyright (C) 2008 Matthew Strait, Ethan Sommer; See ../LICENSE
+#
+# Usually runs on port 5190
+#
+# This may also match ICQ traffic.
+#
+# This pattern has been tested and is believed to work well.
+
+aim
+# See http://gridley.res.carleton.edu/~straitm/final (and various other places)
+# The first bit matches OSCAR signon and data commands, but not sure what
+# \x03\x0b matches, but it works apparently.
+# The next three bits match various parts of the TOC signon process.
+# The third one is the magic number "*", then 0x01 for "signon", then up to four
+# bytes ("up to" because l7-filter strips out nulls) which contain a sequence
+# number (2 bytes) the data length (2 more) and 3 nulls (which don't count),
+# then 0x01 for the version number (not sure if there ever has been another
+# version)
+# The fourth one is a command string, followed by some stuff, then the
+# beginning of the "roasted" password
+
+# This pattern is too slow!
+
+^(\*[\x01\x02].*\x03\x0b|\*\x01.?.?.?.?\x01)|flapon|toc_signon.*0x
diff --git a/package/network/utils/iptables/files/l7/bittorrent.pat b/package/network/utils/iptables/files/l7/bittorrent.pat
new file mode 100644
index 0000000..4a3ba88
--- /dev/null
+++ b/package/network/utils/iptables/files/l7/bittorrent.pat
@@ -0,0 +1,25 @@
+# Bittorrent - P2P filesharing / publishing tool - http://www.bittorrent.com
+# Pattern attributes: good slow594 notsofast undermatch
+# Protocol groups: p2p open_source
+# Wiki: http://www.protocolinfo.org/wiki/Bittorrent
+# Copyright (C) 2008 Matthew Strait, Ethan Sommer; See ../LICENSE
+#
+# This pattern has been tested and is believed to work well.
+# It will, however, not work on bittorrent streams that are encrypted, since
+# it's impossible to match (well) encrypted data.
+
+bittorrent
+
+# Does not attempt to match the HTTP download of the tracker
+# 0x13 is the length of "bittorrent protocol"
+# Second two bits match UDP wierdness
+# Next bit matches something Azureus does
+# Ditto on the next bit. Could also match on "user-agent: azureus", but that's in the next
+# packet and perhaps this will match multiple clients.
+# bitcomet-specific strings contributed by liangjun.
+
+# This is not a valid GNU basic regular expression (but that's ok).
+^(\x13bittorrent protocol|azver\x01$|get /scrape\?info_hash=get /announce\?info_hash=|get /client/bitcomet/|GET /data\?fid=)|d1:ad2:id20:|\x08'7P\)[RP]
+
+# This pattern is "fast", but won't catch as much
+#^(\x13bittorrent protocol|azver\x01$|get /scrape\?info_hash=)
diff --git a/package/network/utils/iptables/files/l7/edonkey.pat b/package/network/utils/iptables/files/l7/edonkey.pat
new file mode 100644
index 0000000..75807f8
--- /dev/null
+++ b/package/network/utils/iptables/files/l7/edonkey.pat
@@ -0,0 +1,37 @@
+# eDonkey2000 - P2P filesharing - http://edonkey2000.com and others
+# Pattern attributes: good veryfast fast overmatch
+# Protocol groups: p2p
+# Wiki: http://www.protocolinfo.org/wiki/EDonkey
+# Copyright (C) 2008 Matthew Strait, Ethan Sommer; See ../LICENSE
+#
+# Tested recently (April/May 2006) with eMule 0.47a and eDonkey2000 1.4
+# and a long time ago with something else.
+#
+# In addition to matching what you might expect, this matches much of
+# what eMule does when you tell it to only connect to the KAD network.
+# I don't quite know what to make of this.
+
+# Thanks to Matt Skidmore <fox AT woozle.org>
+
+edonkey
+
+# http://gd.tuwien.ac.at/opsys/linux/sf/p/pdonkey/eDonkey-protocol-0.6
+#
+# In addition to \xe3, \xc5 and \xd4, I see a lot of \xe5.
+# As of April 2006, I also see some \xe4.
+#
+# God this is a mess. What an irritating protocol.
+# This will match about 2% of streams with random data in them!
+# (But fortunately much fewer than 2% of streams that are other protocols.
+# You can test this with the data in ../testing/)
+
+^[\xc5\xd4\xe3-\xe5].?.?.?.?([\x01\x02\x05\x14\x15\x16\x18\x19\x1a\x1b\x1c\x20\x21\x32\x33\x34\x35\x36\x38\x40\x41\x42\x43\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50\x51\x52\x53\x54\x55\x56\x57\x58[\x60\x81\x82\x90\x91\x93\x96\x97\x98\x99\x9a\x9b\x9c\x9e\xa0\xa1\xa2\xa3\xa4]|\x59................?[ -~]|\x96....$)
+
+# matches everything and too much
+# ^(\xe3|\xc5|\xd4)
+
+# ipp2p essentially uses "\xe3....\x47", which doesn't seem at all right to me.
+
+# bandwidtharbitrator uses
+# e0.*@.*6[a-z].*p$|e0.*@.*[a-z]6[a-z].*p0$|e.*@.*[0-9]6.*p$|emule|edonkey
+# no comments to explain what all the mush is, of course...
diff --git a/package/network/utils/iptables/files/l7/fasttrack.pat b/package/network/utils/iptables/files/l7/fasttrack.pat
new file mode 100644
index 0000000..6ed8ff1
--- /dev/null
+++ b/package/network/utils/iptables/files/l7/fasttrack.pat
@@ -0,0 +1,23 @@
+# FastTrack - P2P filesharing (Kazaa, Morpheus, iMesh, Grokster, etc)
+# Pattern attributes: good slow notsofast
+# Protocol groups: p2p
+# Wiki: http://www.protocolinfo.org/wiki/Fasttrack
+# Copyright (C) 2008 Matthew Strait, Ethan Sommer; See ../LICENSE
+#
+# Tested with Kazaa Lite Resurrection 0.0.7.6F
+#
+# This appears to match the download connections well, but not the search
+# connections (I think they are encrypted :-( ).
+
+fasttrack
+# while this is a valid http request, this will be caught because
+# the http pattern matches the response (and therefore the next packet)
+# Even so, it's best to put this match earlier in the chain.
+# http://cvs.berlios.de/cgi-bin/viewcvs.cgi/gift-fasttrack/giFT-FastTrack/PROTOCOL?rev=HEAD&content-type=text/vnd.viewcvs-markup
+
+# This pattern is kinda slow, but not too bad.
+^get (/.download/[ -~]*|/.supernode[ -~]|/.status[ -~]|/.network[ -~]*|/.files|/.hash=[0-9a-f]*/[ -~]*) http/1.1|user-agent: kazaa|x-kazaa(-username|-network|-ip|-supernodeip|-xferid|-xferuid|tag)|^give [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]?[0-9]?[0-9]?
+
+# This isn't much faster:
+#^get (/.download/.*|/.supernode.|/.status.|/.network.*|/.files|/.hash=[0-9a-f]*/.*) http/1.1|user-agent: kazaa|x-kazaa(-username|-network|-ip|-supernodeip|-xferid|-xferuid|tag)|^give [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]?[0-9]?[0-9]?
+
diff --git a/package/network/utils/iptables/files/l7/ftp.pat b/package/network/utils/iptables/files/l7/ftp.pat
new file mode 100644
index 0000000..44d97c4
--- /dev/null
+++ b/package/network/utils/iptables/files/l7/ftp.pat
@@ -0,0 +1,46 @@
+# FTP - File Transfer Protocol - RFC 959
+# Pattern attributes: great notsofast fast
+# Protocol groups: document_retrieval ietf_internet_standard
+# Wiki: http://protocolinfo.org/wiki/FTP
+# Copyright (C) 2008 Matthew Strait, Ethan Sommer; See ../LICENSE
+#
+# Usually runs on port 21. Note that the data stream is on a dynamically
+# assigned port, which means that you will need the FTP connection
+# tracking module in your kernel to usefully match FTP data transfers.
+#
+# This pattern is well tested.
+#
+# Handles the first two things a server should say:
+#
+# First, the server says it's ready by sending "220". Most servers say
+# something after 220, even though they don't have to, and it usually
+# includes the string "ftp" (l7-filter is case insensitive). This
+# includes proftpd, vsftpd, wuftpd, warftpd, pureftpd, Bulletproof FTP
+# Server, and whatever ftp.microsoft.com uses. Almost all servers use only
+# ASCII printable characters between the "220" and the "FTP", but non-English
+# ones might use others.
+#
+# The next thing the server sends is a 331. All the above servers also
+# send something including "password" after this code. By default, we
+# do not match on this because it takes another packet and is more work
+# for regexec.
+
+ftp
+# by default, we allow only ASCII
+^220[\x09-\x0d -~]*ftp
+
+# This covers UTF-8 as well
+#^220[\x09-\x0d -~\x80-\xfd]*ftp
+
+# This allows any characters and is about 4x faster than either of the above
+# (which are about the same as each other)
+#^220.*ftp
+
+# This is much slower
+#^220[\x09-\x0d -~]*ftp|331[\x09-\x0d -~]*password
+
+# This pattern is more precise, but takes longer to match. (3 packets vs. 1)
+#^220[\x09-\x0d -~]*\x0d\x0aUSER[\x09-\x0d -~]*\x0d\x0a331
+
+# same as above, but slightly less precise and only takes 2 packets.
+#^220[\x09-\x0d -~]*\x0d\x0aUSER[\x09-\x0d -~]*\x0d\x0a
diff --git a/package/network/utils/iptables/files/l7/gnutella.pat b/package/network/utils/iptables/files/l7/gnutella.pat
new file mode 100644
index 0000000..770ed43
--- /dev/null
+++ b/package/network/utils/iptables/files/l7/gnutella.pat
@@ -0,0 +1,34 @@
+# Gnutella - P2P filesharing
+# Pattern attributes: good notsofast notsofast
+# Protocol groups: p2p open_source
+# Wiki: http://www.protocolinfo.org/wiki/Gnutella
+# Copyright (C) 2008 Matthew Strait, Ethan Sommer; See ../LICENSE
+#
+# This should match both Gnutella and "Gnutella2" ("Mike's protocol")
+#
+# Various clients use this protocol including Mactella, Shareaza,
+# GTK-gnutella, Gnucleus, Gnotella, LimeWire, iMesh and BearShare.
+#
+# This is tested with gtk-gnutella and Shareaza.
+
+# http://www.gnutella2.com/tiki-index.php?page=UDP%20Transceiver
+# http://rfc-gnutella.sf.net/
+# http://www.gnutella2.com/tiki-index.php?page=Gnutella2%20Specification
+# http://en.wikipedia.org/wiki/Shareaza
+
+gnutella
+
+# The first part matches UDP messages - All start with "GND", then have
+# a flag byte which is either \x00, \x01 or \x02, then two sequence bytes
+# that can be anything, then a fragment number, which must start at 1.
+# The rest matches TCP first client message or first server message (in case
+# we can't see client messages). Some parts of this are empirical rather than
+# document based. Assumes version is between 0.0 and 2.9. (usually is
+# 0.4 or 0.6). I'm guessing at many of the user-agents.
+# The last bit is emprical and probably only matches Limewire.
+^(gnd[\x01\x02]?.?.?\x01|gnutella connect/[012]\.[0-9]\x0d\x0a|get /uri-res/n2r\?urn:sha1:|get /.*user-agent: (gtk-gnutella|bearshare|mactella|gnucleus|gnotella|limewire|imesh)|get /.*content-type: application/x-gnutella-packets|giv [0-9]*:[0-9a-f]*/|queue [0-9a-f]* [1-9][0-9]?[0-9]?\.[1-9][0-9]?[0-9]?\.[1-9][0-9]?[0-9]?\.[1-9][0-9]?[0-9]?:[1-9][0-9]?[0-9]?[0-9]?|gnutella.*content-type: application/x-gnutella|...................?lime)
+
+# Needlessly precise, at the expense of time
+#^(gnd[\x01\x02]?.?.?\x01|gnutella connect/[012]\.[0-9]\x0d\x0a|get /uri-res/n2r\?urn:sha1:|get /[\x09-\x0d -~]*user-agent: (gtk-gnutella|bearshare|mactella|gnucleus|gnotella|limewire|imesh)|get /[\x09-\x0d -~]*content-type: application/x-gnutella-packets|giv [0-9]*:[0-9a-f]*/|queue [0-9a-f]* [1-9][0-9]?[0-9]?\.[1-9][0-9]?[0-9]?\.[1-9][0-9]?[0-9]?\.[1-9][0-9]?[0-9]?:[1-9][0-9]?[0-9]?[0-9]?|gnutella[\x09-\x0d -~]*content-type: application/x-gnutella|..................lime)
+
+
diff --git a/package/network/utils/iptables/files/l7/http.pat b/package/network/utils/iptables/files/l7/http.pat
new file mode 100644
index 0000000..5122310
--- /dev/null
+++ b/package/network/utils/iptables/files/l7/http.pat
@@ -0,0 +1,28 @@
+# HTTP - HyperText Transfer Protocol - RFC 2616
+# Pattern attributes: great slow notsofast superset
+# Protocol groups: document_retrieval ietf_draft_standard
+# Wiki: http://protocolinfo.org/wiki/HTTP
+# Copyright (C) 2008 Matthew Strait, Ethan Sommer; See ../LICENSE
+#
+# Usually runs on port 80
+#
+# This pattern has been tested and is believed to work well.
+#
+# this intentionally catches the response from the server rather than
+# the request so that other protocols which use http (like kazaa) can be
+# caught based on specific http requests regardless of the ordering of
+# filters... also matches posts
+
+# Sites that serve really long cookies may break this by pushing the
+# server response too far away from the beginning of the connection. To
+# fix this, increase the kernel's data buffer length.
+
+http
+# Status-Line = HTTP-Version SP Status-Code SP Reason-Phrase CRLF (rfc 2616)
+# As specified in rfc 2616 a status code is preceeded and followed by a
+# space.
+http/(0\.9|1\.0|1\.1) [1-5][0-9][0-9] [\x09-\x0d -~]*(connection:|content-type:|content-length:|date:)|post [\x09-\x0d -~]* http/[01]\.[019]
+# A slightly faster version that might be good enough:
+#http/(0\.9|1\.0|1\.1) [1-5][0-9][0-9]|post [\x09-\x0d -~]* http/[01]\.[019]
+# old pattern(s):
+#(http[\x09-\x0d -~]*(200 ok|302 |304 )[\x09-\x0d -~]*(connection:|content-type:|content-length:))|^(post [\x09-\x0d -~]* http/)
diff --git a/package/network/utils/iptables/files/l7/ident.pat b/package/network/utils/iptables/files/l7/ident.pat
new file mode 100644
index 0000000..3205e5e
--- /dev/null
+++ b/package/network/utils/iptables/files/l7/ident.pat
@@ -0,0 +1,15 @@
+# Ident - Identification Protocol - RFC 1413
+# Pattern attributes: good fast fast
+# Protocol groups: networking ietf_proposed_standard
+# Wiki: http://www.protocolinfo.org/wiki/Ident
+# Copyright (C) 2008 Matthew Strait, Ethan Sommer; See ../LICENSE
+#
+# Usually runs on port 113
+#
+# This pattern is believed to work.
+
+ident
+# "number , numberCRLF" possibly without the CR and/or LF.
+# ^$ is appropriate because the first packet should never have anything
+# else in it.
+^[1-9][0-9]?[0-9]?[0-9]?[0-9]?[\x09-\x0d]*,[\x09-\x0d]*[1-9][0-9]?[0-9]?[0-9]?[0-9]?(\x0d\x0a|[\x0d\x0a])?$
diff --git a/package/network/utils/iptables/files/l7/irc.pat b/package/network/utils/iptables/files/l7/irc.pat
new file mode 100644
index 0000000..e25360c
--- /dev/null
+++ b/package/network/utils/iptables/files/l7/irc.pat
@@ -0,0 +1,20 @@
+# IRC - Internet Relay Chat - RFC 1459
+# Pattern attributes: great veryfast fast
+# Protocol groups: chat ietf_proposed_standard
+# Wiki: http://www.protocolinfo.org/wiki/IRC
+# Copyright (C) 2008 Matthew Strait, Ethan Sommer; See ../LICENSE
+#
+# Usually runs on port 6666 or 6667
+# Note that chat traffic runs on these ports, but IRC-DCC traffic (which
+# can use much more bandwidth) uses a dynamically assigned port, so you
+# must have the IRC connection tracking module in your kernel to classify
+# this.
+#
+# This pattern has been tested and is believed to work well.
+
+irc
+# First thing that happens is that the client sends NICK and USER, in
+# either order. This allows MIRC color codes (\x02-\x0d instead of
+# \x09-\x0d).
+^(nick[\x09-\x0d -~]*user[\x09-\x0d -~]*:|user[\x09-\x0d -~]*:[\x02-\x0d -~]*nick[\x09-\x0d -~]*\x0d\x0a)
+
diff --git a/package/network/utils/iptables/files/l7/jabber.pat b/package/network/utils/iptables/files/l7/jabber.pat
new file mode 100644
index 0000000..7c32890
--- /dev/null
+++ b/package/network/utils/iptables/files/l7/jabber.pat
@@ -0,0 +1,24 @@
+# Jabber (XMPP) - open instant messenger protocol - RFC 3920 - http://jabber.org
+# Pattern attributes: good notsofast notsofast
+# Protocol groups: chat ietf_proposed_standard
+# Wiki: http://www.protocolinfo.org/wiki/Jabber
+# Copyright (C) 2008 Matthew Strait, Ethan Sommer; See ../LICENSE
+#
+# This pattern has been tested with Gaim and Gabber. It is only tested
+# with non-SSL mode Jabber with no proxies.
+
+# Thanks to Jan Hudec for some improvements.
+
+# Jabber seems to take a long time to set up a connection. I'm
+# connecting with Gabber 0.8.8 to 12jabber.org and the first 8 packets
+# is this:
+# <stream:stream to='12jabber.com' xmlns='jabber:client'
+# xmlns:stream='http://etherx.jabber.org/streams'><?xml
+# version='1.0'?><stream:stream
+# xmlns:stream='http://etherx.jabber.org/streams' id='3f73e951'
+# xmlns='jabber:client' from='12jabber.com'>
+#
+# No mention of my username or password yet, you'll note.
+
+jabber
+<stream:stream[\x09-\x0d ][ -~]*[\x09-\x0d ]xmlns=['"]jabber
diff --git a/package/network/utils/iptables/files/l7/msnmessenger.pat b/package/network/utils/iptables/files/l7/msnmessenger.pat
new file mode 100644
index 0000000..11dfc10
--- /dev/null
+++ b/package/network/utils/iptables/files/l7/msnmessenger.pat
@@ -0,0 +1,28 @@
+# MSN Messenger - Microsoft Network chat client
+# Pattern attributes: good slow notsofast
+# Protocol groups: chat proprietary
+# Wiki: http://www.protocolinfo.org/wiki/MSN_Messenger
+# Copyright (C) 2008 Matthew Strait, Ethan Sommer; See ../LICENSE
+#
+# Usually uses TCP port 1863
+# http://www.hypothetic.org/docs/msn/index.php
+# http://msnpiki.msnfanatic.com/
+#
+# This pattern has been tested and is believed to work well.
+
+msnmessenger
+
+# First branch: login
+# ver: allow versions up to 99.
+# I've never seen a cvr other than cvr0. Maybe this will be trouble later?
+# Can't anchor at the beginning because sometimes this is encapsulated in
+# HTTP. But either way, the first packet ends like this.
+# Second/Third branches: accepting/sending a message
+# I will assume that these can also be encapsulated in HTTP, although I have
+# not checked. Example of each direction:
+# ANS 1 quadong@hotmail.com 1139803431.29427 17522047
+# USR 1 quadong@hotmail.com 530423708.968145.366138
+
+# Branches are written entirely separately for better performance.
+ver [0-9]+ msnp[1-9][0-9]? [\x09-\x0d -~]*cvr0\x0d\x0a$|usr 1 [!-~]+ [0-9. ]+\x0d\x0a$|ans 1 [!-~]+ [0-9. ]+\x0d\x0a$
+
diff --git a/package/network/utils/iptables/files/l7/ntp.pat b/package/network/utils/iptables/files/l7/ntp.pat
new file mode 100644
index 0000000..760cfdb
--- /dev/null
+++ b/package/network/utils/iptables/files/l7/ntp.pat
@@ -0,0 +1,17 @@
+# (S)NTP - (Simple) Network Time Protocol - RFCs 1305 and 2030
+# Pattern attributes: good fast fast overmatch
+# Protocol groups: time_synchronization ietf_draft_standard
+# Wiki: http://www.protocolinfo.org/wiki/NTP
+# Copyright (C) 2008 Matthew Strait, Ethan Sommer; See ../LICENSE
+#
+# This pattern is tested and is believed to work.
+
+# client|server
+# Requires the server's timestamp to be in the present or future (of 2005).
+# Tested with ntpdate on Linux.
+# Assumes version 2, 3 or 4.
+
+# Note that ntp packets are always 48 bytes, so you should match on that too.
+
+ntp
+^([\x13\x1b\x23\xd3\xdb\xe3]|[\x14\x1c$].......?.?.?.?.?.?.?.?.?[\xc6-\xff])
diff --git a/package/network/utils/iptables/files/l7/pop3.pat b/package/network/utils/iptables/files/l7/pop3.pat
new file mode 100644
index 0000000..3ae4c14
--- /dev/null
+++ b/package/network/utils/iptables/files/l7/pop3.pat
@@ -0,0 +1,50 @@
+# POP3 - Post Office Protocol version 3 (popular e-mail protocol) - RFC 1939
+# Pattern attributes: great veryfast fast
+# Protocol groups: mail ietf_internet_standard
+# Wiki: http://www.protocolinfo.org/wiki/POP
+# Copyright (C) 2008 Matthew Strait, Ethan Sommer; See ../LICENSE
+#
+# This pattern has been tested somewhat.
+
+# this is a difficult protocol to match because of the relative lack of
+# distinguishing information. Read on.
+pop3
+
+# this the most conservative pattern. It should definitely work.
+#^(\+ok|-err)
+
+# this pattern assumes that the server says _something_ after +ok or -err
+# I think this is probably the way to go.
+^(\+ok |-err )
+
+# more that 90% of servers seem to say "pop" after "+ok", but not all.
+#^(\+ok .*pop)
+
+# Here's another tack. I think this is my second favorite.
+#^(\+ok [\x09-\x0d -~]*(ready|hello|pop|starting)|-err [\x09-\x0d -~]*(invalid|unknown|unimplemented|unrecognized|command))
+
+# this matches the server saying "you have N messages that are M bytes",
+# which the client probably asks for early in the session (not tested)
+#\+ok [0-9]+ [0-9]+
+
+# some sample servers:
+# RFC example: +OK POP3 server ready <1896.697170952@dbc.mtview.ca.us>
+# mail.dreamhost.com: +OK Hello there.
+# pop.carleton.edu: +OK POP3D(*) Server PMDFV6.2.2 at Fri, 12 Sep 2003 19:28:10 -0500 (CDT) (APOP disabled)
+# mail.earthlink.net: +OK NGPopper vEL_4_38 at earthlink.net ready <25509.1063412951@falcon>
+# *.email.umn.edu: +OK Cubic Circle's v1.22 1998/04/11 POP3 ready <7d1e0000da67623f@aquamarine.tc.umn.edu>
+# mail.yale.edu: +OK POP3 pantheon-po01 v2002.81 server ready
+# mail.gustavus.edu: +OK POP3 solen v2001.78 server ready
+# mail.reed.edu: +OK POP3 letra.reed.edu v2002.81 server ready
+# mail.bowdoin.edu: +OK mail.bowdoin.edu POP3 service (iPlanet Messaging Server 5.2 HotFix 1.15 (built Apr 28 2003))
+# pop.colby.edu: +OK Qpopper (version 4.0.5) at basalt starting.
+# mail.mac.com: +OK Netscape Messaging Multiplexor ready
+
+# various error strings:
+#-ERR Invalid command.
+#-ERR invalid command
+#-ERR unimplemented
+#-ERR Invalid command, try one of: USER name, PASS string, QUIT
+#-ERR Unknown AUTHORIZATION state command
+#-ERR Unrecognized command
+#-ERR Unknown command: "sadf'".
diff --git a/package/network/utils/iptables/files/l7/smtp.pat b/package/network/utils/iptables/files/l7/smtp.pat
new file mode 100644
index 0000000..2f5d195
--- /dev/null
+++ b/package/network/utils/iptables/files/l7/smtp.pat
@@ -0,0 +1,40 @@
+# SMTP - Simple Mail Transfer Protocol - RFC 2821 (See also RFC 1869)
+# Pattern attributes: great notsofast fast
+# Protocol groups: mail ietf_internet_standard
+# Wiki: http://www.protocolinfo.org/wiki/SMTP
+# Copyright (C) 2008 Matthew Strait, Ethan Sommer; See ../LICENSE
+#
+# usually runs on port 25
+#
+# This pattern has been tested and is believed to work well.
+
+# As usual, no text is required after "220", but all known servers have some
+# there. It (almost?) always has string "smtp" in it. The RFC examples
+# does not, so we match those too, just in case anyone has copied them
+# literally.
+#
+# Some examples:
+# 220 mail.stalker.com ESMTP CommuniGate Pro 4.1.3
+# 220 mail.vieodata.com ESMTP Merak 6.1.0; Mon, 15 Sep 2003 13:48:11 -0400
+# 220 mail.ut.caldera.com ESMTP
+# 220 persephone.pmail.gen.nz ESMTP server ready.
+# 220 smtp1.superb.net ESMTP
+# 220 mail.kerio.com Kerio MailServer 5.6.7 ESMTP ready
+# 220-mail.deerfield.com ESMTP VisNetic.MailServer.v6.0.9.0; Mon, 15 Sep 2003 13:4
+# 220 altn.com ESMTP MDaemon 6.8.5; Mon, 15 Sep 2003 12:46:42 -0500
+# 220 X1 NT-ESMTP Server ipsmin0165atl2.interland.net (IMail 6.06 73062-3)
+# 220 mail.icewarp.com ESMTP Merak 6.1.1; Mon, 15 Sep 2003 19:43:23 +0200
+# 220-mail.email-scan.com ESMTP
+# 220 smaug.dreamhost.com ESMTP
+# 220 kona.carleton.edu -- Server ESMTP (PMDF V6.2#30648)
+# 220 letra.reed.edu ESMTP Sendmail 8.12.9/8.12.9; Mon, 15 Sep 2003 10:35:57 -0700 (PDT)
+# 220-swan.mail.pas.earthlink.net ESMTP Exim 3.33 #1 Mon, 15 Sep 2003 10:32:15 -0700
+#
+# RFC examples:
+# 220 xyz.com Simple Mail Transfer Service Ready (RFC example)
+# 220 dbc.mtview.ca.us SMTP service ready
+
+smtp
+^220[\x09-\x0d -~]* (e?smtp|simple mail)
+userspace pattern=^220[\x09-\x0d -~]* (E?SMTP|[Ss]imple [Mm]ail)
+userspace flags=REG_NOSUB REG_EXTENDED
diff --git a/package/network/utils/iptables/files/l7/ssl.pat b/package/network/utils/iptables/files/l7/ssl.pat
new file mode 100644
index 0000000..ae30ee4
--- /dev/null
+++ b/package/network/utils/iptables/files/l7/ssl.pat
@@ -0,0 +1,16 @@
+# SSL and TLS - Secure Socket Layer / Transport Layer Security - RFC 2246
+# Pattern attributes: good notsofast fast superset
+# Protocol groups: secure ietf_proposed_standard
+# Wiki: http://www.protocolinfo.org/wiki/SSL
+# Copyright (C) 2008 Matthew Strait, Ethan Sommer; See ../LICENSE
+#
+# Usually runs on port 443
+#
+# This is a superset of validcertssl. For it to match, it must be first.
+#
+# This pattern has been tested and is believed to work well.
+
+ssl
+# Server Hello with certificate | Client Hello
+# This allows SSL 3.X, which includes TLS 1.0, known internally as SSL 3.1
+^(.?.?\x16\x03.*\x16\x03|.?.?\x01\x03\x01?.*\x0b)
diff --git a/package/network/utils/iptables/files/l7/vnc.pat b/package/network/utils/iptables/files/l7/vnc.pat
new file mode 100644
index 0000000..79d0ae8
--- /dev/null
+++ b/package/network/utils/iptables/files/l7/vnc.pat
@@ -0,0 +1,23 @@
+# VNC - Virtual Network Computing. Also known as RFB - Remote Frame Buffer
+# Pattern attributes: great veryfast fast
+# Protocol groups: remote_access
+# Wiki: http://www.protocolinfo.org/wiki/VNC
+# Copyright (C) 2008 Matthew Strait, Ethan Sommer; See ../LICENSE
+#
+# http://www.realvnc.com/documentation.html
+#
+# This pattern has been verified with vnc v3.3.7 on WinXP and Linux
+#
+# Thanks to Trevor Paskett <tpaskett AT cymphonix.com> for this pattern.
+
+vnc
+# Assumes single digit major and minor version numbers
+# This message should be all alone in the first packet, so ^$ is appropriate
+^rfb 00[1-9]\.00[0-9]\x0a$
+
+# This is a more restrictive version which assumes the version numbers
+# are ones actually in existance at the time of this writing, i.e. 3.3,
+# 3.7 and 3.8 (with some clients wrongly reporting 3.5). It should be
+# slightly faster, but probably not worth the extra maintenance.
+# ^rfb 003\.00[3578]\x0a$
+
diff --git a/package/network/utils/iptables/patches/.svn/entries b/package/network/utils/iptables/patches/.svn/entries
new file mode 100644
index 0000000..7dfa7cd
--- /dev/null
+++ b/package/network/utils/iptables/patches/.svn/entries
@@ -0,0 +1,300 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/utils/iptables/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-06T17:05:34.161606Z
+35896
+cyrus
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+100-bash-location.patch
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+20d2f34d73c618e3d8d29d291f5a202f
+2013-03-06T17:05:34.161606Z
+35896
+cyrus
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+177
+
+002-layer7_2.22.patch
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+3d064b3eae52b3e6d3bc25ad1265ccde
+2010-12-19T11:16:46.024141Z
+24719
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+9821
+
+200-configurable_builtin.patch
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+08d618081686e688ed020e9eddb60a23
+2013-03-06T17:05:34.161606Z
+35896
+cyrus
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2854
+
+020-iptables-disable-modprobe.patch
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+91d944bf4a7839cc813caa21394b7ce3
+2013-03-06T17:05:34.161606Z
+35896
+cyrus
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+409
+
+030-no-libnfnetlink.patch
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+102f2220f30695d3ad8e8d227dd110e0
+2013-03-06T17:05:34.161606Z
+35896
+cyrus
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3267
+
+300-musl_fixes.patch
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+6e388903e4e73c20f7134df4e3ff3fcd
+2013-03-06T17:05:34.161606Z
+35896
+cyrus
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3001
+
+010-use-old-linking.patch
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+42c805097559addafb45a3a713b23d3e
+2013-03-06T17:05:34.161606Z
+35896
+cyrus
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1973
+
+400-lenient-restore.patch
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+860aad2ebe209f4f1e6dc4eb6db6131c
+2013-03-06T17:05:34.161606Z
+35896
+cyrus
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4867
+
diff --git a/package/network/utils/iptables/patches/.svn/text-base/002-layer7_2.22.patch.svn-base b/package/network/utils/iptables/patches/.svn/text-base/002-layer7_2.22.patch.svn-base
new file mode 100644
index 0000000..ba4531e
--- /dev/null
+++ b/package/network/utils/iptables/patches/.svn/text-base/002-layer7_2.22.patch.svn-base
@@ -0,0 +1,371 @@
+--- /dev/null
++++ b/extensions/libxt_layer7.c
+@@ -0,0 +1,368 @@
++/*
++ Shared library add-on to iptables for layer 7 matching support.
++
++ By Matthew Strait <quadong@users.sf.net>, Oct 2003-Aug 2008.
++
++ http://l7-filter.sf.net
++
++ 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 of the License, or (at your option) any later version.
++ http://www.gnu.org/licenses/gpl.txt
++*/
++
++#define _GNU_SOURCE
++#include <stdio.h>
++#include <netdb.h>
++#include <string.h>
++#include <stdlib.h>
++#include <getopt.h>
++#include <ctype.h>
++#include <dirent.h>
++
++#include <xtables.h>
++#include <linux/netfilter/xt_layer7.h>
++
++#define MAX_FN_LEN 256
++
++static char l7dir[MAX_FN_LEN] = "\0";
++
++/* Function which prints out usage message. */
++static void help(void)
++{
++ printf(
++ "layer7 match options:\n"
++ " --l7dir <directory> : Look for patterns here instead of /etc/l7-protocols/\n"
++ " (--l7dir must be specified before --l7proto if used)\n"
++ "[!] --l7proto <name>: Match named protocol using /etc/l7-protocols/.../name.pat\n");
++}
++
++static const struct option opts[] = {
++ { .name = "l7proto", .has_arg = 1, .val = 'p' },
++ { .name = "l7dir", .has_arg = 1, .val = 'd' },
++ { .name = NULL }
++};
++
++/* reads filename, puts protocol info into layer7_protocol_info, number of protocols to numprotos */
++static int parse_protocol_file(char * filename, const char * protoname, struct xt_layer7_info *info)
++{
++ FILE * f;
++ char * line = NULL;
++ size_t len = 0;
++
++ enum { protocol, pattern, done } datatype = protocol;
++
++ f = fopen(filename, "r");
++
++ if(!f)
++ return 0;
++
++ while(getline(&line, &len, f) != -1)
++ {
++ if(strlen(line) < 2 || line[0] == '#')
++ continue;
++
++ /* strip the pesky newline... */
++ if(line[strlen(line) - 1] == '\n')
++ line[strlen(line) - 1] = '\0';
++
++ if(datatype == protocol)
++ {
++ /* Ignore everything on the line beginning with the
++ first space or tab . For instance, this allows the
++ protocol line in http.pat to be "http " (or
++ "http I am so cool") instead of just "http". */
++ if(strchr(line, ' ')){
++ char * space = strchr(line, ' ');
++ space[0] = '\0';
++ }
++ if(strchr(line, '\t')){
++ char * space = strchr(line, '\t');
++ space[0] = '\0';
++ }
++
++ /* sanity check. First non-comment non-blank
++ line must be the same as the file name. */
++ if(strcmp(line, protoname))
++ xtables_error(OTHER_PROBLEM,
++ "Protocol name (%s) doesn't match file name (%s). Bailing out\n",
++ line, filename);
++
++ if(strlen(line) >= MAX_PROTOCOL_LEN)
++ xtables_error(PARAMETER_PROBLEM,
++ "Protocol name in %s too long!", filename);
++ strncpy(info->protocol, line, MAX_PROTOCOL_LEN);
++
++ datatype = pattern;
++ }
++ else if(datatype == pattern)
++ {
++ if(strlen(line) >= MAX_PATTERN_LEN)
++ xtables_error(PARAMETER_PROBLEM, "Pattern in %s too long!", filename);
++ strncpy(info->pattern, line, MAX_PATTERN_LEN);
++
++ datatype = done;
++ break;
++ }
++ else
++ xtables_error(OTHER_PROBLEM, "Internal error");
++ }
++
++ if(datatype != done)
++ xtables_error(OTHER_PROBLEM, "Failed to get all needed data from %s", filename);
++
++ if(line) free(line);
++ fclose(f);
++
++ return 1;
++}
++
++static int hex2dec(char c)
++{
++ switch (c)
++ {
++ case '0' ... '9':
++ return c - '0';
++ case 'a' ... 'f':
++ return c - 'a' + 10;
++ case 'A' ... 'F':
++ return c - 'A' + 10;
++ default:
++ xtables_error(OTHER_PROBLEM, "hex2dec: bad value!\n");
++ return 0;
++ }
++}
++
++/* takes a string with \xHH escapes and returns one with the characters
++they stand for */
++static char * pre_process(char * s)
++{
++ char * result = malloc(strlen(s) + 1);
++ int sindex = 0, rrindex = 0;
++ while( sindex < strlen(s) )
++ {
++ if( sindex + 3 < strlen(s) &&
++ s[sindex] == '\\' && s[sindex+1] == 'x' &&
++ isxdigit(s[sindex + 2]) && isxdigit(s[sindex + 3]) )
++ {
++ /* carefully remember to call tolower here... */
++ result[rrindex] = tolower( hex2dec(s[sindex + 2])*16 +
++ hex2dec(s[sindex + 3] ) );
++
++ switch ( result[rrindex] )
++ {
++ case 0x24:
++ case 0x28:
++ case 0x29:
++ case 0x2a:
++ case 0x2b:
++ case 0x2e:
++ case 0x3f:
++ case 0x5b:
++ case 0x5c:
++ case 0x5d:
++ case 0x5e:
++ case 0x7c:
++ fprintf(stderr,
++ "Warning: layer7 regexp contains a control character, %c, in hex (\\x%c%c).\n"
++ "I recommend that you write this as %c or \\%c, depending on what you meant.\n",
++ result[rrindex], s[sindex + 2], s[sindex + 3], result[rrindex], result[rrindex]);
++ break;
++ case 0x00:
++ fprintf(stderr,
++ "Warning: null (\\x00) in layer7 regexp. A null terminates the regexp string!\n");
++ break;
++ default:
++ break;
++ }
++
++
++ sindex += 3; /* 4 total */
++ }
++ else
++ result[rrindex] = tolower(s[sindex]);
++
++ sindex++;
++ rrindex++;
++ }
++ result[rrindex] = '\0';
++
++ return result;
++}
++
++#define MAX_SUBDIRS 128
++static char ** readl7dir(char * dirname)
++{
++ DIR * scratchdir;
++ struct dirent ** namelist;
++ char ** subdirs = malloc(MAX_SUBDIRS * sizeof(char *));
++
++ int n, d = 1;
++ subdirs[0] = "";
++
++ n = scandir(dirname, &namelist, 0, alphasort);
++
++ if (n < 0)
++ {
++ perror("scandir");
++ xtables_error(OTHER_PROBLEM, "Couldn't open %s\n", dirname);
++ }
++ else
++ {
++ while(n--)
++ {
++ char fulldirname[MAX_FN_LEN];
++
++ snprintf(fulldirname, MAX_FN_LEN, "%s/%s", dirname, namelist[n]->d_name);
++
++ if((scratchdir = opendir(fulldirname)) != NULL)
++ {
++ closedir(scratchdir);
++
++ if(!strcmp(namelist[n]->d_name, ".") ||
++ !strcmp(namelist[n]->d_name, ".."))
++ /* do nothing */ ;
++ else
++ {
++ subdirs[d] = malloc(strlen(namelist[n]->d_name) + 1);
++ strcpy(subdirs[d], namelist[n]->d_name);
++ d++;
++ if(d >= MAX_SUBDIRS - 1)
++ {
++ fprintf(stderr,
++ "Too many subdirectories, skipping the rest!\n");
++ break;
++ }
++ }
++ }
++ free(namelist[n]);
++ }
++ free(namelist);
++ }
++
++ subdirs[d] = NULL;
++
++ return subdirs;
++}
++
++static void parse_layer7_protocol(const char *s, struct xt_layer7_info *info)
++{
++ char filename[MAX_FN_LEN];
++ char * dir = NULL;
++ char ** subdirs;
++ int n = 0, done = 0;
++
++ if(strlen(l7dir) > 0) dir = l7dir;
++ else dir = "/etc/l7-protocols";
++
++ subdirs = readl7dir(dir);
++
++ while(subdirs[n] != NULL)
++ {
++ int c = snprintf(filename, MAX_FN_LEN, "%s/%s/%s.pat", dir, subdirs[n], s);
++
++ if(c > MAX_FN_LEN)
++ xtables_error(OTHER_PROBLEM,
++ "Filename beginning with %s is too long!\n", filename);
++
++ /* read in the pattern from the file */
++ if(parse_protocol_file(filename, s, info)){
++ done = 1;
++ break;
++ }
++
++ n++;
++ }
++
++ if(!done)
++ xtables_error(OTHER_PROBLEM,
++ "Couldn't find a pattern definition file for %s.\n", s);
++
++ /* process \xHH escapes and tolower everything. (our regex lib has no
++ case insensitivity option.) */
++ strncpy(info->pattern, pre_process(info->pattern), MAX_PATTERN_LEN);
++}
++
++/* Function which parses command options; returns true if it ate an option */
++static int parse(int c, char **argv, int invert, unsigned int *flags,
++ const void *entry, struct xt_entry_match **match)
++{
++ struct xt_layer7_info *layer7info =
++ (struct xt_layer7_info *)(*match)->data;
++
++ switch (c) {
++ case 'p':
++ parse_layer7_protocol(argv[optind-1], layer7info);
++ if (invert)
++ layer7info->invert = true;
++ *flags = 1;
++ break;
++
++ case 'd':
++ if(strlen(argv[optind-1]) >= MAX_FN_LEN)
++ xtables_error(PARAMETER_PROBLEM, "directory name too long\n");
++
++ strncpy(l7dir, argv[optind-1], MAX_FN_LEN);
++
++ *flags = 1;
++ break;
++
++ default:
++ return 0;
++ }
++
++ return 1;
++}
++
++/* Final check; must have specified --l7proto */
++static void final_check(unsigned int flags)
++{
++ if (!flags)
++ xtables_error(PARAMETER_PROBLEM,
++ "LAYER7 match: You must specify `--l7proto'");
++}
++
++static void print_protocol(char s[], int invert, int numeric)
++{
++ fputs("l7proto ", stdout);
++ if (invert) fputc('!', stdout);
++ printf("%s ", s);
++}
++
++/* Prints out the matchinfo. */
++static void print(const void *ip,
++ const struct xt_entry_match *match,
++ int numeric)
++{
++ printf("LAYER7 ");
++ print_protocol(((struct xt_layer7_info *)match->data)->protocol,
++ ((struct xt_layer7_info *)match->data)->invert, numeric);
++}
++/* Saves the union ipt_matchinfo in parsable form to stdout. */
++static void save(const void *ip, const struct xt_entry_match *match)
++{
++ const struct xt_layer7_info *info =
++ (const struct xt_layer7_info*) match->data;
++
++ printf("--l7proto %s%s ", (info->invert)? "! ":"", info->protocol);
++}
++
++static struct xtables_match layer7 = {
++ .family = AF_INET,
++ .name = "layer7",
++ .version = XTABLES_VERSION,
++ .size = XT_ALIGN(sizeof(struct xt_layer7_info)),
++ .userspacesize = XT_ALIGN(sizeof(struct xt_layer7_info)),
++ .help = &help,
++ .parse = &parse,
++ .final_check = &final_check,
++ .print = &print,
++ .save = &save,
++ .extra_opts = opts
++};
++
++void _init(void)
++{
++ xtables_register_match(&layer7);
++}
diff --git a/package/network/utils/iptables/patches/.svn/text-base/010-use-old-linking.patch.svn-base b/package/network/utils/iptables/patches/.svn/text-base/010-use-old-linking.patch.svn-base
new file mode 100644
index 0000000..a848e1e
--- /dev/null
+++ b/package/network/utils/iptables/patches/.svn/text-base/010-use-old-linking.patch.svn-base
@@ -0,0 +1,51 @@
+Index: iptables-1.4.18/extensions/GNUmakefile.in
+===================================================================
+--- iptables-1.4.18.orig/extensions/GNUmakefile.in 2013-03-03 22:40:11.000000000 +0100
++++ iptables-1.4.18/extensions/GNUmakefile.in 2013-03-06 17:13:04.074584735 +0100
+@@ -33,7 +33,6 @@
+ AM_VERBOSE_CXXLD = @echo " CXXLD " $@;
+ AM_VERBOSE_AR = @echo " AR " $@;
+ AM_VERBOSE_GEN = @echo " GEN " $@;
+-AM_VERBOSE_NULL = @
+ endif
+
+ #
+@@ -76,7 +75,7 @@
+ if test -n "${targets_install}"; then install -pm0755 $^ "${DESTDIR}${xtlibdir}/"; fi;
+
+ clean:
+- rm -f *.la *.o *.lo *.so *.a {matches,targets}.man initext.c initext4.c initext6.c;
++ rm -f *.o *.oo *.so *.a {matches,targets}.man initext.c initext4.c initext6.c;
+ rm -f .*.d .*.dd;
+
+ distclean: clean
+@@ -90,22 +89,19 @@
+ #
+ # Shared libraries
+ #
+-lib%.so: lib%.la
+- ${AM_VERBOSE_NULL} ln -fs .libs/$@ $@
++lib%.so: lib%.oo
++ ${AM_VERBOSE_CCLD} ${CCLD} ${AM_LDFLAGS} -shared ${LDFLAGS} -o $@ $< -L../libxtables/.libs -L../libiptc/.libs -lxtables ${$*_LIBADD};
+
+-lib%.la: lib%.lo
+- ${AM_VERBOSE_CCLD} ../libtool ${AM_LIBTOOL_SILENT} --tag=CC --mode=link ${CCLD} ${AM_LDFLAGS} -module ${LDFLAGS} -o $@ $< ../libxtables/libxtables.la ${$*_LIBADD} -rpath ${xtlibdir}
+-
+-lib%.lo: ${srcdir}/lib%.c
+- ${AM_VERBOSE_CC} ../libtool ${AM_LIBTOOL_SILENT} --tag=CC --mode=compile ${CC} ${AM_CPPFLAGS} ${AM_DEPFLAGS} ${AM_CFLAGS} -D_INIT=lib$*_init ${CFLAGS} -o $@ -c $<
++lib%.oo: ${srcdir}/lib%.c
++ ${AM_VERBOSE_CC} ${CC} ${AM_CPPFLAGS} ${AM_DEPFLAGS} ${AM_CFLAGS} -D_INIT=lib$*_init -DPIC -fPIC ${CFLAGS} -o $@ -c $<;
+
+ libxt_NOTRACK.so: libxt_CT.so
+- ${AM_VERBOSE_GEN} ln -fs $< $@
++ ln -fs $< $@
+ libxt_state.so: libxt_conntrack.so
+- ${AM_VERBOSE_GEN} ln -fs $< $@
++ ln -fs $< $@
+
+ # Need the LIBADDs in iptables/Makefile.am too for libxtables_la_LIBADD
+-ip6t_NETMAP_LIBADD = ../libiptc/libip6tc.la
++ip6t_NETMAP_LIBADD = -lip6tc
+ xt_RATEEST_LIBADD = -lm
+ xt_statistic_LIBADD = -lm
+
diff --git a/package/network/utils/iptables/patches/.svn/text-base/020-iptables-disable-modprobe.patch.svn-base b/package/network/utils/iptables/patches/.svn/text-base/020-iptables-disable-modprobe.patch.svn-base
new file mode 100644
index 0000000..ad4889b
--- /dev/null
+++ b/package/network/utils/iptables/patches/.svn/text-base/020-iptables-disable-modprobe.patch.svn-base
@@ -0,0 +1,18 @@
+--- a/libxtables/xtables.c
++++ b/libxtables/xtables.c
+@@ -336,6 +336,7 @@ static char *get_modprobe(void)
+
+ int xtables_insmod(const char *modname, const char *modprobe, bool quiet)
+ {
++#if 0
+ char *buf = NULL;
+ char *argv[4];
+ int status;
+@@ -380,6 +381,7 @@ int xtables_insmod(const char *modname,
+ free(buf);
+ if (WIFEXITED(status) && WEXITSTATUS(status) == 0)
+ return 0;
++#endif
+ return -1;
+ }
+
diff --git a/package/network/utils/iptables/patches/.svn/text-base/030-no-libnfnetlink.patch.svn-base b/package/network/utils/iptables/patches/.svn/text-base/030-no-libnfnetlink.patch.svn-base
new file mode 100644
index 0000000..f795291
--- /dev/null
+++ b/package/network/utils/iptables/patches/.svn/text-base/030-no-libnfnetlink.patch.svn-base
@@ -0,0 +1,94 @@
+--- a/configure
++++ b/configure
+@@ -12173,77 +12173,7 @@ $as_echo "no" >&6; }
+ fi
+ fi
+
+-pkg_failed=no
+-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libnfnetlink" >&5
+-$as_echo_n "checking for libnfnetlink... " >&6; }
+-
+-if test -n "$libnfnetlink_CFLAGS"; then
+- pkg_cv_libnfnetlink_CFLAGS="$libnfnetlink_CFLAGS"
+- elif test -n "$PKG_CONFIG"; then
+- if test -n "$PKG_CONFIG" && \
+- { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libnfnetlink >= 1.0\""; } >&5
+- ($PKG_CONFIG --exists --print-errors "libnfnetlink >= 1.0") 2>&5
+- ac_status=$?
+- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+- test $ac_status = 0; }; then
+- pkg_cv_libnfnetlink_CFLAGS=`$PKG_CONFIG --cflags "libnfnetlink >= 1.0" 2>/dev/null`
+- test "x$?" != "x0" && pkg_failed=yes
+-else
+- pkg_failed=yes
+-fi
+- else
+- pkg_failed=untried
+-fi
+-if test -n "$libnfnetlink_LIBS"; then
+- pkg_cv_libnfnetlink_LIBS="$libnfnetlink_LIBS"
+- elif test -n "$PKG_CONFIG"; then
+- if test -n "$PKG_CONFIG" && \
+- { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libnfnetlink >= 1.0\""; } >&5
+- ($PKG_CONFIG --exists --print-errors "libnfnetlink >= 1.0") 2>&5
+- ac_status=$?
+- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+- test $ac_status = 0; }; then
+- pkg_cv_libnfnetlink_LIBS=`$PKG_CONFIG --libs "libnfnetlink >= 1.0" 2>/dev/null`
+- test "x$?" != "x0" && pkg_failed=yes
+-else
+- pkg_failed=yes
+-fi
+- else
+- pkg_failed=untried
+-fi
+-
+-
+-
+-if test $pkg_failed = yes; then
+- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+-$as_echo "no" >&6; }
+-
+-if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+- _pkg_short_errors_supported=yes
+-else
+- _pkg_short_errors_supported=no
+-fi
+- if test $_pkg_short_errors_supported = yes; then
+- libnfnetlink_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libnfnetlink >= 1.0" 2>&1`
+- else
+- libnfnetlink_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libnfnetlink >= 1.0" 2>&1`
+- fi
+- # Put the nasty error message in config.log where it belongs
+- echo "$libnfnetlink_PKG_ERRORS" >&5
+-
+- nfnetlink=0
+-elif test $pkg_failed = untried; then
+- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+-$as_echo "no" >&6; }
+- nfnetlink=0
+-else
+- libnfnetlink_CFLAGS=$pkg_cv_libnfnetlink_CFLAGS
+- libnfnetlink_LIBS=$pkg_cv_libnfnetlink_LIBS
+- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+-$as_echo "yes" >&6; }
+- nfnetlink=1
+-fi
+- if test "$nfnetlink" = 1; then
++if false; then
+ HAVE_LIBNFNETLINK_TRUE=
+ HAVE_LIBNFNETLINK_FALSE='#'
+ else
+--- a/configure.ac
++++ b/configure.ac
+@@ -89,9 +89,7 @@ AM_CONDITIONAL([ENABLE_LARGEFILE], [test
+ AM_CONDITIONAL([ENABLE_DEVEL], [test "$enable_devel" = "yes"])
+ AM_CONDITIONAL([ENABLE_LIBIPQ], [test "$enable_libipq" = "yes"])
+
+-PKG_CHECK_MODULES([libnfnetlink], [libnfnetlink >= 1.0],
+- [nfnetlink=1], [nfnetlink=0])
+-AM_CONDITIONAL([HAVE_LIBNFNETLINK], [test "$nfnetlink" = 1])
++AM_CONDITIONAL([HAVE_LIBNFNETLINK], [false])
+
+ regular_CFLAGS="-Wall -Waggregate-return -Wmissing-declarations \
+ -Wmissing-prototypes -Wredundant-decls -Wshadow -Wstrict-prototypes \
diff --git a/package/network/utils/iptables/patches/.svn/text-base/100-bash-location.patch.svn-base b/package/network/utils/iptables/patches/.svn/text-base/100-bash-location.patch.svn-base
new file mode 100644
index 0000000..02ee45b
--- /dev/null
+++ b/package/network/utils/iptables/patches/.svn/text-base/100-bash-location.patch.svn-base
@@ -0,0 +1,8 @@
+--- a/iptables/iptables-apply
++++ b/iptables/iptables-apply
+@@ -1,4 +1,4 @@
+-#!/bin/bash
++#!/usr/bin/env bash
+ #
+ # iptables-apply -- a safer way to update iptables remotely
+ #
diff --git a/package/network/utils/iptables/patches/.svn/text-base/200-configurable_builtin.patch.svn-base b/package/network/utils/iptables/patches/.svn/text-base/200-configurable_builtin.patch.svn-base
new file mode 100644
index 0000000..8f095c1
--- /dev/null
+++ b/package/network/utils/iptables/patches/.svn/text-base/200-configurable_builtin.patch.svn-base
@@ -0,0 +1,62 @@
+Index: iptables-1.4.18/extensions/GNUmakefile.in
+===================================================================
+--- iptables-1.4.18.orig/extensions/GNUmakefile.in 2013-03-03 22:40:11.000000000 +0100
++++ iptables-1.4.18/extensions/GNUmakefile.in 2013-03-05 16:37:07.583256974 +0100
+@@ -46,9 +46,24 @@
+ pfx_build_mod := $(filter-out @blacklist_modules@,${pfx_build_mod})
+ pf4_build_mod := $(filter-out @blacklist_modules@,${pf4_build_mod})
+ pf6_build_mod := $(filter-out @blacklist_modules@,${pf6_build_mod})
+-pfx_objs := $(patsubst %,libxt_%.o,${pfx_build_mod})
+-pf4_objs := $(patsubst %,libipt_%.o,${pf4_build_mod})
+-pf6_objs := $(patsubst %,libip6t_%.o,${pf6_build_mod})
++
++ifdef BUILTIN_MODULES
++pfx_build_static := $(filter $(BUILTIN_MODULES),${pfx_build_mod})
++pf4_build_static := $(filter $(BUILTIN_MODULES),${pf4_build_mod})
++pf6_build_static := $(filter $(BUILTIN_MODULES),${pf6_build_mod})
++else
++@ENABLE_STATIC_TRUE@ pfx_build_static := $(pfx_build_mod)
++@ENABLE_STATIC_TRUE@ pf4_build_static := $(pf4_build_mod)
++@ENABLE_STATIC_TRUE@ pf6_build_static := $(pf6_build_mod)
++endif
++
++pfx_build_mod := $(filter-out $(pfx_build_static),$(pfx_build_mod))
++pf4_build_mod := $(filter-out $(pf4_build_static),$(pf4_build_mod))
++pf6_build_mod := $(filter-out $(pf6_build_static),$(pf6_build_mod))
++
++pfx_objs := $(patsubst %,libxt_%.o,${pfx_build_static})
++pf4_objs := $(patsubst %,libipt_%.o,${pf4_build_static})
++pf6_objs := $(patsubst %,libip6t_%.o,${pf6_build_static})
+ pfx_solibs := $(patsubst %,libxt_%.so,${pfx_build_mod} ${pfx_symlinks})
+ pf4_solibs := $(patsubst %,libipt_%.so,${pf4_build_mod})
+ pf6_solibs := $(patsubst %,libip6t_%.so,${pf6_build_mod})
+@@ -59,11 +74,11 @@
+ #
+ targets := libext.a libext4.a libext6.a matches.man targets.man
+ targets_install :=
+-@ENABLE_STATIC_TRUE@ libext_objs := ${pfx_objs}
+-@ENABLE_STATIC_TRUE@ libext4_objs := ${pf4_objs}
+-@ENABLE_STATIC_TRUE@ libext6_objs := ${pf6_objs}
+-@ENABLE_STATIC_FALSE@ targets += ${pfx_solibs} ${pf4_solibs} ${pf6_solibs}
+-@ENABLE_STATIC_FALSE@ targets_install += ${pfx_solibs} ${pf4_solibs} ${pf6_solibs}
++libext_objs := ${pfx_objs}
++libext4_objs := ${pf4_objs}
++libext6_objs := ${pf6_objs}
++targets += ${pfx_solibs} ${pf4_solibs} ${pf6_solibs}
++targets_install := $(strip ${targets_install} ${pfx_solibs} ${pf4_solibs} ${pf6_solibs})
+
+ .SECONDARY:
+
+@@ -128,9 +143,9 @@
+ libext6.a: initext6.o ${libext6_objs}
+ ${AM_VERBOSE_AR} ${AR} crs $@ $^;
+
+-initext_func := $(addprefix xt_,${pfx_build_mod})
+-initext4_func := $(addprefix ipt_,${pf4_build_mod})
+-initext6_func := $(addprefix ip6t_,${pf6_build_mod})
++initext_func := $(addprefix xt_,${pfx_build_static})
++initext4_func := $(addprefix ipt_,${pf4_build_static})
++initext6_func := $(addprefix ip6t_,${pf6_build_static})
+
+ .initext.dd: FORCE
+ @echo "${initext_func}" >$@.tmp; \
diff --git a/package/network/utils/iptables/patches/.svn/text-base/300-musl_fixes.patch.svn-base b/package/network/utils/iptables/patches/.svn/text-base/300-musl_fixes.patch.svn-base
new file mode 100644
index 0000000..039af7c
--- /dev/null
+++ b/package/network/utils/iptables/patches/.svn/text-base/300-musl_fixes.patch.svn-base
@@ -0,0 +1,139 @@
+--- a/extensions/libip6t_ipv6header.c
++++ b/extensions/libip6t_ipv6header.c
+@@ -10,6 +10,9 @@ on whether they contain certain headers
+ #include <netdb.h>
+ #include <xtables.h>
+ #include <linux/netfilter_ipv6/ip6t_ipv6header.h>
++#ifndef IPPROTO_HOPOPTS
++# define IPPROTO_HOPOPTS 0
++#endif
+
+ enum {
+ O_HEADER = 0,
+--- a/extensions/libxt_TCPOPTSTRIP.c
++++ b/extensions/libxt_TCPOPTSTRIP.c
+@@ -12,6 +12,21 @@
+ #ifndef TCPOPT_MD5SIG
+ # define TCPOPT_MD5SIG 19
+ #endif
++#ifndef TCPOPT_MAXSEG
++# define TCPOPT_MAXSEG 2
++#endif
++#ifndef TCPOPT_WINDOW
++# define TCPOPT_WINDOW 3
++#endif
++#ifndef TCPOPT_SACK_PERMITTED
++# define TCPOPT_SACK_PERMITTED 4
++#endif
++#ifndef TCPOPT_SACK
++# define TCPOPT_SACK 5
++#endif
++#ifndef TCPOPT_TIMESTAMP
++# define TCPOPT_TIMESTAMP 8
++#endif
+
+ enum {
+ O_STRIP_OPTION = 0,
+--- a/include/libiptc/ipt_kernel_headers.h
++++ b/include/libiptc/ipt_kernel_headers.h
+@@ -5,7 +5,6 @@
+
+ #include <limits.h>
+
+-#if defined(__GLIBC__) && __GLIBC__ == 2
+ #include <netinet/ip.h>
+ #include <netinet/in.h>
+ #include <netinet/ip_icmp.h>
+@@ -13,15 +12,4 @@
+ #include <netinet/udp.h>
+ #include <net/if.h>
+ #include <sys/types.h>
+-#else /* libc5 */
+-#include <sys/socket.h>
+-#include <linux/ip.h>
+-#include <linux/in.h>
+-#include <linux/if.h>
+-#include <linux/icmp.h>
+-#include <linux/tcp.h>
+-#include <linux/udp.h>
+-#include <linux/types.h>
+-#include <linux/in6.h>
+-#endif
+ #endif
+--- a/include/linux/netfilter/xt_osf.h
++++ b/include/linux/netfilter/xt_osf.h
+@@ -21,6 +21,9 @@
+ #define _XT_OSF_H
+
+ #include <linux/types.h>
++#if !defined(__UCLIBC__) && !defined(__GLIBC__)
++#include <linux/tcp.h>
++#endif
+
+ #define MAXGENRELEN 32
+
+--- a/include/linux/netfilter_ipv4/ip_tables.h
++++ b/include/linux/netfilter_ipv4/ip_tables.h
+@@ -16,6 +16,7 @@
+ #define _IPTABLES_H
+
+ #include <linux/types.h>
++#include <sys/types.h>
+
+ #include <linux/netfilter_ipv4.h>
+
+--- a/iptables/ip6tables-restore.c
++++ b/iptables/ip6tables-restore.c
+@@ -9,7 +9,7 @@
+ */
+
+ #include <getopt.h>
+-#include <sys/errno.h>
++#include <errno.h>
+ #include <stdbool.h>
+ #include <string.h>
+ #include <stdio.h>
+--- a/iptables/ip6tables-save.c
++++ b/iptables/ip6tables-save.c
+@@ -6,7 +6,7 @@
+ * This code is distributed under the terms of GNU GPL v2
+ */
+ #include <getopt.h>
+-#include <sys/errno.h>
++#include <errno.h>
+ #include <stdio.h>
+ #include <fcntl.h>
+ #include <stdlib.h>
+--- a/iptables/iptables-restore.c
++++ b/iptables/iptables-restore.c
+@@ -6,7 +6,7 @@
+ */
+
+ #include <getopt.h>
+-#include <sys/errno.h>
++#include <errno.h>
+ #include <stdbool.h>
+ #include <string.h>
+ #include <stdio.h>
+--- a/iptables/iptables-save.c
++++ b/iptables/iptables-save.c
+@@ -6,7 +6,7 @@
+ *
+ */
+ #include <getopt.h>
+-#include <sys/errno.h>
++#include <errno.h>
+ #include <stdio.h>
+ #include <fcntl.h>
+ #include <stdlib.h>
+--- a/iptables/iptables-xml.c
++++ b/iptables/iptables-xml.c
+@@ -7,7 +7,7 @@
+ */
+
+ #include <getopt.h>
+-#include <sys/errno.h>
++#include <errno.h>
+ #include <string.h>
+ #include <stdio.h>
+ #include <stdlib.h>
diff --git a/package/network/utils/iptables/patches/.svn/text-base/400-lenient-restore.patch.svn-base b/package/network/utils/iptables/patches/.svn/text-base/400-lenient-restore.patch.svn-base
new file mode 100644
index 0000000..696d733
--- /dev/null
+++ b/package/network/utils/iptables/patches/.svn/text-base/400-lenient-restore.patch.svn-base
@@ -0,0 +1,176 @@
+Index: iptables-1.4.18/iptables/ip6tables-restore.c
+===================================================================
+--- iptables-1.4.18.orig/iptables/ip6tables-restore.c 2013-03-05 16:37:31.000000000 +0100
++++ iptables-1.4.18/iptables/ip6tables-restore.c 2013-03-05 16:42:57.475249794 +0100
+@@ -14,6 +14,8 @@
+ #include <string.h>
+ #include <stdio.h>
+ #include <stdlib.h>
++#include <stdarg.h>
++#include <setjmp.h>
+ #include "ip6tables.h"
+ #include "xtables.h"
+ #include "libiptc/libip6tc.h"
+@@ -25,6 +27,7 @@
+ #define DEBUGP(x, args...)
+ #endif
+
++static jmp_buf jmp;
+ static int binary = 0, counters = 0, verbose = 0, noflush = 0;
+
+ /* Keeping track of external matches and targets. */
+@@ -35,6 +38,7 @@
+ {.name = "test", .has_arg = false, .val = 't'},
+ {.name = "help", .has_arg = false, .val = 'h'},
+ {.name = "noflush", .has_arg = false, .val = 'n'},
++ {.name = "lenient", .has_arg = false, .val = 'l'},
+ {.name = "modprobe", .has_arg = true, .val = 'M'},
+ {.name = "table", .has_arg = true, .val = 'T'},
+ {NULL},
+@@ -51,6 +55,7 @@
+ " [ --test ]\n"
+ " [ --help ]\n"
+ " [ --noflush ]\n"
++ " [ --lenient ]\n"
+ " [ --modprobe=<command>]\n", name);
+
+ exit(1);
+@@ -114,6 +119,17 @@
+ free(newargv[i]);
+ }
+
++static void catch_exit_error(enum xtables_exittype status, const char *msg, ...)
++{
++ va_list args;
++ fprintf(stderr, "line %d: ", line);
++ va_start(args, msg);
++ vfprintf(stderr, msg, args);
++ va_end(args);
++ fprintf(stderr, "\n");
++ longjmp(jmp, status);
++}
++
+ static void add_param_to_argv(char *parsestart)
+ {
+ int quote_open = 0, escaped = 0, param_len = 0;
+@@ -204,7 +220,7 @@
+ init_extensions6();
+ #endif
+
+- while ((c = getopt_long(argc, argv, "bcvthnM:T:", options, NULL)) != -1) {
++ while ((c = getopt_long(argc, argv, "bcvthnlM:T:", options, NULL)) != -1) {
+ switch (c) {
+ case 'b':
+ binary = 1;
+@@ -225,6 +241,9 @@
+ case 'n':
+ noflush = 1;
+ break;
++ case 'l':
++ ip6tables_globals.exit_err = catch_exit_error;
++ break;
+ case 'M':
+ xtables_modprobe_program = optarg;
+ break;
+@@ -437,8 +456,11 @@
+ for (a = 0; a < newargc; a++)
+ DEBUGP("argv[%u]: %s\n", a, newargv[a]);
+
+- ret = do_command6(newargc, newargv,
+- &newargv[2], &handle);
++ if (!setjmp(jmp))
++ ret = do_command6(newargc, newargv,
++ &newargv[2], &handle);
++ else
++ ret = 1;
+
+ free_argv();
+ fflush(stdout);
+Index: iptables-1.4.18/iptables/iptables-restore.c
+===================================================================
+--- iptables-1.4.18.orig/iptables/iptables-restore.c 2013-03-05 16:37:31.000000000 +0100
++++ iptables-1.4.18/iptables/iptables-restore.c 2013-03-05 16:44:56.303247355 +0100
+@@ -11,6 +11,8 @@
+ #include <string.h>
+ #include <stdio.h>
+ #include <stdlib.h>
++#include <stdarg.h>
++#include <setjmp.h>
+ #include "iptables.h"
+ #include "xtables.h"
+ #include "libiptc/libiptc.h"
+@@ -22,6 +24,7 @@
+ #define DEBUGP(x, args...)
+ #endif
+
++static jmp_buf jmp;
+ static int binary = 0, counters = 0, verbose = 0, noflush = 0;
+
+ /* Keeping track of external matches and targets. */
+@@ -32,6 +35,7 @@
+ {.name = "test", .has_arg = false, .val = 't'},
+ {.name = "help", .has_arg = false, .val = 'h'},
+ {.name = "noflush", .has_arg = false, .val = 'n'},
++ {.name = "lenient", .has_arg = false, .val = 'l'},
+ {.name = "modprobe", .has_arg = true, .val = 'M'},
+ {.name = "table", .has_arg = true, .val = 'T'},
+ {NULL},
+@@ -50,6 +54,7 @@
+ " [ --test ]\n"
+ " [ --help ]\n"
+ " [ --noflush ]\n"
++ " [ --lenient ]\n"
+ " [ --table=<TABLE> ]\n"
+ " [ --modprobe=<command>]\n", name);
+
+@@ -113,6 +118,17 @@
+ free(newargv[i]);
+ }
+
++static void catch_exit_error(enum xtables_exittype status, const char *msg, ...)
++{
++ va_list args;
++ fprintf(stderr, "line %d: ", line);
++ va_start(args, msg);
++ vfprintf(stderr, msg, args);
++ va_end(args);
++ fprintf(stderr, "\n");
++ longjmp(jmp, status);
++}
++
+ static void add_param_to_argv(char *parsestart)
+ {
+ int quote_open = 0, escaped = 0, param_len = 0;
+@@ -204,7 +220,7 @@
+ init_extensions4();
+ #endif
+
+- while ((c = getopt_long(argc, argv, "bcvthnM:T:", options, NULL)) != -1) {
++ while ((c = getopt_long(argc, argv, "bcvthnlM:T:", options, NULL)) != -1) {
+ switch (c) {
+ case 'b':
+ binary = 1;
+@@ -225,6 +241,9 @@
+ case 'n':
+ noflush = 1;
+ break;
++ case 'l':
++ iptables_globals.exit_err = catch_exit_error;
++ break;
+ case 'M':
+ xtables_modprobe_program = optarg;
+ break;
+@@ -437,8 +456,11 @@
+ for (a = 0; a < newargc; a++)
+ DEBUGP("argv[%u]: %s\n", a, newargv[a]);
+
+- ret = do_command4(newargc, newargv,
+- &newargv[2], &handle);
++ if (!setjmp(jmp))
++ ret = do_command4(newargc, newargv,
++ &newargv[2], &handle);
++ else
++ ret = 1;
+
+ free_argv();
+ fflush(stdout);
diff --git a/package/network/utils/iptables/patches/002-layer7_2.22.patch b/package/network/utils/iptables/patches/002-layer7_2.22.patch
new file mode 100644
index 0000000..ba4531e
--- /dev/null
+++ b/package/network/utils/iptables/patches/002-layer7_2.22.patch
@@ -0,0 +1,371 @@
+--- /dev/null
++++ b/extensions/libxt_layer7.c
+@@ -0,0 +1,368 @@
++/*
++ Shared library add-on to iptables for layer 7 matching support.
++
++ By Matthew Strait <quadong@users.sf.net>, Oct 2003-Aug 2008.
++
++ http://l7-filter.sf.net
++
++ 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 of the License, or (at your option) any later version.
++ http://www.gnu.org/licenses/gpl.txt
++*/
++
++#define _GNU_SOURCE
++#include <stdio.h>
++#include <netdb.h>
++#include <string.h>
++#include <stdlib.h>
++#include <getopt.h>
++#include <ctype.h>
++#include <dirent.h>
++
++#include <xtables.h>
++#include <linux/netfilter/xt_layer7.h>
++
++#define MAX_FN_LEN 256
++
++static char l7dir[MAX_FN_LEN] = "\0";
++
++/* Function which prints out usage message. */
++static void help(void)
++{
++ printf(
++ "layer7 match options:\n"
++ " --l7dir <directory> : Look for patterns here instead of /etc/l7-protocols/\n"
++ " (--l7dir must be specified before --l7proto if used)\n"
++ "[!] --l7proto <name>: Match named protocol using /etc/l7-protocols/.../name.pat\n");
++}
++
++static const struct option opts[] = {
++ { .name = "l7proto", .has_arg = 1, .val = 'p' },
++ { .name = "l7dir", .has_arg = 1, .val = 'd' },
++ { .name = NULL }
++};
++
++/* reads filename, puts protocol info into layer7_protocol_info, number of protocols to numprotos */
++static int parse_protocol_file(char * filename, const char * protoname, struct xt_layer7_info *info)
++{
++ FILE * f;
++ char * line = NULL;
++ size_t len = 0;
++
++ enum { protocol, pattern, done } datatype = protocol;
++
++ f = fopen(filename, "r");
++
++ if(!f)
++ return 0;
++
++ while(getline(&line, &len, f) != -1)
++ {
++ if(strlen(line) < 2 || line[0] == '#')
++ continue;
++
++ /* strip the pesky newline... */
++ if(line[strlen(line) - 1] == '\n')
++ line[strlen(line) - 1] = '\0';
++
++ if(datatype == protocol)
++ {
++ /* Ignore everything on the line beginning with the
++ first space or tab . For instance, this allows the
++ protocol line in http.pat to be "http " (or
++ "http I am so cool") instead of just "http". */
++ if(strchr(line, ' ')){
++ char * space = strchr(line, ' ');
++ space[0] = '\0';
++ }
++ if(strchr(line, '\t')){
++ char * space = strchr(line, '\t');
++ space[0] = '\0';
++ }
++
++ /* sanity check. First non-comment non-blank
++ line must be the same as the file name. */
++ if(strcmp(line, protoname))
++ xtables_error(OTHER_PROBLEM,
++ "Protocol name (%s) doesn't match file name (%s). Bailing out\n",
++ line, filename);
++
++ if(strlen(line) >= MAX_PROTOCOL_LEN)
++ xtables_error(PARAMETER_PROBLEM,
++ "Protocol name in %s too long!", filename);
++ strncpy(info->protocol, line, MAX_PROTOCOL_LEN);
++
++ datatype = pattern;
++ }
++ else if(datatype == pattern)
++ {
++ if(strlen(line) >= MAX_PATTERN_LEN)
++ xtables_error(PARAMETER_PROBLEM, "Pattern in %s too long!", filename);
++ strncpy(info->pattern, line, MAX_PATTERN_LEN);
++
++ datatype = done;
++ break;
++ }
++ else
++ xtables_error(OTHER_PROBLEM, "Internal error");
++ }
++
++ if(datatype != done)
++ xtables_error(OTHER_PROBLEM, "Failed to get all needed data from %s", filename);
++
++ if(line) free(line);
++ fclose(f);
++
++ return 1;
++}
++
++static int hex2dec(char c)
++{
++ switch (c)
++ {
++ case '0' ... '9':
++ return c - '0';
++ case 'a' ... 'f':
++ return c - 'a' + 10;
++ case 'A' ... 'F':
++ return c - 'A' + 10;
++ default:
++ xtables_error(OTHER_PROBLEM, "hex2dec: bad value!\n");
++ return 0;
++ }
++}
++
++/* takes a string with \xHH escapes and returns one with the characters
++they stand for */
++static char * pre_process(char * s)
++{
++ char * result = malloc(strlen(s) + 1);
++ int sindex = 0, rrindex = 0;
++ while( sindex < strlen(s) )
++ {
++ if( sindex + 3 < strlen(s) &&
++ s[sindex] == '\\' && s[sindex+1] == 'x' &&
++ isxdigit(s[sindex + 2]) && isxdigit(s[sindex + 3]) )
++ {
++ /* carefully remember to call tolower here... */
++ result[rrindex] = tolower( hex2dec(s[sindex + 2])*16 +
++ hex2dec(s[sindex + 3] ) );
++
++ switch ( result[rrindex] )
++ {
++ case 0x24:
++ case 0x28:
++ case 0x29:
++ case 0x2a:
++ case 0x2b:
++ case 0x2e:
++ case 0x3f:
++ case 0x5b:
++ case 0x5c:
++ case 0x5d:
++ case 0x5e:
++ case 0x7c:
++ fprintf(stderr,
++ "Warning: layer7 regexp contains a control character, %c, in hex (\\x%c%c).\n"
++ "I recommend that you write this as %c or \\%c, depending on what you meant.\n",
++ result[rrindex], s[sindex + 2], s[sindex + 3], result[rrindex], result[rrindex]);
++ break;
++ case 0x00:
++ fprintf(stderr,
++ "Warning: null (\\x00) in layer7 regexp. A null terminates the regexp string!\n");
++ break;
++ default:
++ break;
++ }
++
++
++ sindex += 3; /* 4 total */
++ }
++ else
++ result[rrindex] = tolower(s[sindex]);
++
++ sindex++;
++ rrindex++;
++ }
++ result[rrindex] = '\0';
++
++ return result;
++}
++
++#define MAX_SUBDIRS 128
++static char ** readl7dir(char * dirname)
++{
++ DIR * scratchdir;
++ struct dirent ** namelist;
++ char ** subdirs = malloc(MAX_SUBDIRS * sizeof(char *));
++
++ int n, d = 1;
++ subdirs[0] = "";
++
++ n = scandir(dirname, &namelist, 0, alphasort);
++
++ if (n < 0)
++ {
++ perror("scandir");
++ xtables_error(OTHER_PROBLEM, "Couldn't open %s\n", dirname);
++ }
++ else
++ {
++ while(n--)
++ {
++ char fulldirname[MAX_FN_LEN];
++
++ snprintf(fulldirname, MAX_FN_LEN, "%s/%s", dirname, namelist[n]->d_name);
++
++ if((scratchdir = opendir(fulldirname)) != NULL)
++ {
++ closedir(scratchdir);
++
++ if(!strcmp(namelist[n]->d_name, ".") ||
++ !strcmp(namelist[n]->d_name, ".."))
++ /* do nothing */ ;
++ else
++ {
++ subdirs[d] = malloc(strlen(namelist[n]->d_name) + 1);
++ strcpy(subdirs[d], namelist[n]->d_name);
++ d++;
++ if(d >= MAX_SUBDIRS - 1)
++ {
++ fprintf(stderr,
++ "Too many subdirectories, skipping the rest!\n");
++ break;
++ }
++ }
++ }
++ free(namelist[n]);
++ }
++ free(namelist);
++ }
++
++ subdirs[d] = NULL;
++
++ return subdirs;
++}
++
++static void parse_layer7_protocol(const char *s, struct xt_layer7_info *info)
++{
++ char filename[MAX_FN_LEN];
++ char * dir = NULL;
++ char ** subdirs;
++ int n = 0, done = 0;
++
++ if(strlen(l7dir) > 0) dir = l7dir;
++ else dir = "/etc/l7-protocols";
++
++ subdirs = readl7dir(dir);
++
++ while(subdirs[n] != NULL)
++ {
++ int c = snprintf(filename, MAX_FN_LEN, "%s/%s/%s.pat", dir, subdirs[n], s);
++
++ if(c > MAX_FN_LEN)
++ xtables_error(OTHER_PROBLEM,
++ "Filename beginning with %s is too long!\n", filename);
++
++ /* read in the pattern from the file */
++ if(parse_protocol_file(filename, s, info)){
++ done = 1;
++ break;
++ }
++
++ n++;
++ }
++
++ if(!done)
++ xtables_error(OTHER_PROBLEM,
++ "Couldn't find a pattern definition file for %s.\n", s);
++
++ /* process \xHH escapes and tolower everything. (our regex lib has no
++ case insensitivity option.) */
++ strncpy(info->pattern, pre_process(info->pattern), MAX_PATTERN_LEN);
++}
++
++/* Function which parses command options; returns true if it ate an option */
++static int parse(int c, char **argv, int invert, unsigned int *flags,
++ const void *entry, struct xt_entry_match **match)
++{
++ struct xt_layer7_info *layer7info =
++ (struct xt_layer7_info *)(*match)->data;
++
++ switch (c) {
++ case 'p':
++ parse_layer7_protocol(argv[optind-1], layer7info);
++ if (invert)
++ layer7info->invert = true;
++ *flags = 1;
++ break;
++
++ case 'd':
++ if(strlen(argv[optind-1]) >= MAX_FN_LEN)
++ xtables_error(PARAMETER_PROBLEM, "directory name too long\n");
++
++ strncpy(l7dir, argv[optind-1], MAX_FN_LEN);
++
++ *flags = 1;
++ break;
++
++ default:
++ return 0;
++ }
++
++ return 1;
++}
++
++/* Final check; must have specified --l7proto */
++static void final_check(unsigned int flags)
++{
++ if (!flags)
++ xtables_error(PARAMETER_PROBLEM,
++ "LAYER7 match: You must specify `--l7proto'");
++}
++
++static void print_protocol(char s[], int invert, int numeric)
++{
++ fputs("l7proto ", stdout);
++ if (invert) fputc('!', stdout);
++ printf("%s ", s);
++}
++
++/* Prints out the matchinfo. */
++static void print(const void *ip,
++ const struct xt_entry_match *match,
++ int numeric)
++{
++ printf("LAYER7 ");
++ print_protocol(((struct xt_layer7_info *)match->data)->protocol,
++ ((struct xt_layer7_info *)match->data)->invert, numeric);
++}
++/* Saves the union ipt_matchinfo in parsable form to stdout. */
++static void save(const void *ip, const struct xt_entry_match *match)
++{
++ const struct xt_layer7_info *info =
++ (const struct xt_layer7_info*) match->data;
++
++ printf("--l7proto %s%s ", (info->invert)? "! ":"", info->protocol);
++}
++
++static struct xtables_match layer7 = {
++ .family = AF_INET,
++ .name = "layer7",
++ .version = XTABLES_VERSION,
++ .size = XT_ALIGN(sizeof(struct xt_layer7_info)),
++ .userspacesize = XT_ALIGN(sizeof(struct xt_layer7_info)),
++ .help = &help,
++ .parse = &parse,
++ .final_check = &final_check,
++ .print = &print,
++ .save = &save,
++ .extra_opts = opts
++};
++
++void _init(void)
++{
++ xtables_register_match(&layer7);
++}
diff --git a/package/network/utils/iptables/patches/010-use-old-linking.patch b/package/network/utils/iptables/patches/010-use-old-linking.patch
new file mode 100644
index 0000000..a848e1e
--- /dev/null
+++ b/package/network/utils/iptables/patches/010-use-old-linking.patch
@@ -0,0 +1,51 @@
+Index: iptables-1.4.18/extensions/GNUmakefile.in
+===================================================================
+--- iptables-1.4.18.orig/extensions/GNUmakefile.in 2013-03-03 22:40:11.000000000 +0100
++++ iptables-1.4.18/extensions/GNUmakefile.in 2013-03-06 17:13:04.074584735 +0100
+@@ -33,7 +33,6 @@
+ AM_VERBOSE_CXXLD = @echo " CXXLD " $@;
+ AM_VERBOSE_AR = @echo " AR " $@;
+ AM_VERBOSE_GEN = @echo " GEN " $@;
+-AM_VERBOSE_NULL = @
+ endif
+
+ #
+@@ -76,7 +75,7 @@
+ if test -n "${targets_install}"; then install -pm0755 $^ "${DESTDIR}${xtlibdir}/"; fi;
+
+ clean:
+- rm -f *.la *.o *.lo *.so *.a {matches,targets}.man initext.c initext4.c initext6.c;
++ rm -f *.o *.oo *.so *.a {matches,targets}.man initext.c initext4.c initext6.c;
+ rm -f .*.d .*.dd;
+
+ distclean: clean
+@@ -90,22 +89,19 @@
+ #
+ # Shared libraries
+ #
+-lib%.so: lib%.la
+- ${AM_VERBOSE_NULL} ln -fs .libs/$@ $@
++lib%.so: lib%.oo
++ ${AM_VERBOSE_CCLD} ${CCLD} ${AM_LDFLAGS} -shared ${LDFLAGS} -o $@ $< -L../libxtables/.libs -L../libiptc/.libs -lxtables ${$*_LIBADD};
+
+-lib%.la: lib%.lo
+- ${AM_VERBOSE_CCLD} ../libtool ${AM_LIBTOOL_SILENT} --tag=CC --mode=link ${CCLD} ${AM_LDFLAGS} -module ${LDFLAGS} -o $@ $< ../libxtables/libxtables.la ${$*_LIBADD} -rpath ${xtlibdir}
+-
+-lib%.lo: ${srcdir}/lib%.c
+- ${AM_VERBOSE_CC} ../libtool ${AM_LIBTOOL_SILENT} --tag=CC --mode=compile ${CC} ${AM_CPPFLAGS} ${AM_DEPFLAGS} ${AM_CFLAGS} -D_INIT=lib$*_init ${CFLAGS} -o $@ -c $<
++lib%.oo: ${srcdir}/lib%.c
++ ${AM_VERBOSE_CC} ${CC} ${AM_CPPFLAGS} ${AM_DEPFLAGS} ${AM_CFLAGS} -D_INIT=lib$*_init -DPIC -fPIC ${CFLAGS} -o $@ -c $<;
+
+ libxt_NOTRACK.so: libxt_CT.so
+- ${AM_VERBOSE_GEN} ln -fs $< $@
++ ln -fs $< $@
+ libxt_state.so: libxt_conntrack.so
+- ${AM_VERBOSE_GEN} ln -fs $< $@
++ ln -fs $< $@
+
+ # Need the LIBADDs in iptables/Makefile.am too for libxtables_la_LIBADD
+-ip6t_NETMAP_LIBADD = ../libiptc/libip6tc.la
++ip6t_NETMAP_LIBADD = -lip6tc
+ xt_RATEEST_LIBADD = -lm
+ xt_statistic_LIBADD = -lm
+
diff --git a/package/network/utils/iptables/patches/020-iptables-disable-modprobe.patch b/package/network/utils/iptables/patches/020-iptables-disable-modprobe.patch
new file mode 100644
index 0000000..ad4889b
--- /dev/null
+++ b/package/network/utils/iptables/patches/020-iptables-disable-modprobe.patch
@@ -0,0 +1,18 @@
+--- a/libxtables/xtables.c
++++ b/libxtables/xtables.c
+@@ -336,6 +336,7 @@ static char *get_modprobe(void)
+
+ int xtables_insmod(const char *modname, const char *modprobe, bool quiet)
+ {
++#if 0
+ char *buf = NULL;
+ char *argv[4];
+ int status;
+@@ -380,6 +381,7 @@ int xtables_insmod(const char *modname,
+ free(buf);
+ if (WIFEXITED(status) && WEXITSTATUS(status) == 0)
+ return 0;
++#endif
+ return -1;
+ }
+
diff --git a/package/network/utils/iptables/patches/030-no-libnfnetlink.patch b/package/network/utils/iptables/patches/030-no-libnfnetlink.patch
new file mode 100644
index 0000000..f795291
--- /dev/null
+++ b/package/network/utils/iptables/patches/030-no-libnfnetlink.patch
@@ -0,0 +1,94 @@
+--- a/configure
++++ b/configure
+@@ -12173,77 +12173,7 @@ $as_echo "no" >&6; }
+ fi
+ fi
+
+-pkg_failed=no
+-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libnfnetlink" >&5
+-$as_echo_n "checking for libnfnetlink... " >&6; }
+-
+-if test -n "$libnfnetlink_CFLAGS"; then
+- pkg_cv_libnfnetlink_CFLAGS="$libnfnetlink_CFLAGS"
+- elif test -n "$PKG_CONFIG"; then
+- if test -n "$PKG_CONFIG" && \
+- { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libnfnetlink >= 1.0\""; } >&5
+- ($PKG_CONFIG --exists --print-errors "libnfnetlink >= 1.0") 2>&5
+- ac_status=$?
+- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+- test $ac_status = 0; }; then
+- pkg_cv_libnfnetlink_CFLAGS=`$PKG_CONFIG --cflags "libnfnetlink >= 1.0" 2>/dev/null`
+- test "x$?" != "x0" && pkg_failed=yes
+-else
+- pkg_failed=yes
+-fi
+- else
+- pkg_failed=untried
+-fi
+-if test -n "$libnfnetlink_LIBS"; then
+- pkg_cv_libnfnetlink_LIBS="$libnfnetlink_LIBS"
+- elif test -n "$PKG_CONFIG"; then
+- if test -n "$PKG_CONFIG" && \
+- { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libnfnetlink >= 1.0\""; } >&5
+- ($PKG_CONFIG --exists --print-errors "libnfnetlink >= 1.0") 2>&5
+- ac_status=$?
+- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+- test $ac_status = 0; }; then
+- pkg_cv_libnfnetlink_LIBS=`$PKG_CONFIG --libs "libnfnetlink >= 1.0" 2>/dev/null`
+- test "x$?" != "x0" && pkg_failed=yes
+-else
+- pkg_failed=yes
+-fi
+- else
+- pkg_failed=untried
+-fi
+-
+-
+-
+-if test $pkg_failed = yes; then
+- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+-$as_echo "no" >&6; }
+-
+-if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+- _pkg_short_errors_supported=yes
+-else
+- _pkg_short_errors_supported=no
+-fi
+- if test $_pkg_short_errors_supported = yes; then
+- libnfnetlink_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libnfnetlink >= 1.0" 2>&1`
+- else
+- libnfnetlink_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libnfnetlink >= 1.0" 2>&1`
+- fi
+- # Put the nasty error message in config.log where it belongs
+- echo "$libnfnetlink_PKG_ERRORS" >&5
+-
+- nfnetlink=0
+-elif test $pkg_failed = untried; then
+- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+-$as_echo "no" >&6; }
+- nfnetlink=0
+-else
+- libnfnetlink_CFLAGS=$pkg_cv_libnfnetlink_CFLAGS
+- libnfnetlink_LIBS=$pkg_cv_libnfnetlink_LIBS
+- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+-$as_echo "yes" >&6; }
+- nfnetlink=1
+-fi
+- if test "$nfnetlink" = 1; then
++if false; then
+ HAVE_LIBNFNETLINK_TRUE=
+ HAVE_LIBNFNETLINK_FALSE='#'
+ else
+--- a/configure.ac
++++ b/configure.ac
+@@ -89,9 +89,7 @@ AM_CONDITIONAL([ENABLE_LARGEFILE], [test
+ AM_CONDITIONAL([ENABLE_DEVEL], [test "$enable_devel" = "yes"])
+ AM_CONDITIONAL([ENABLE_LIBIPQ], [test "$enable_libipq" = "yes"])
+
+-PKG_CHECK_MODULES([libnfnetlink], [libnfnetlink >= 1.0],
+- [nfnetlink=1], [nfnetlink=0])
+-AM_CONDITIONAL([HAVE_LIBNFNETLINK], [test "$nfnetlink" = 1])
++AM_CONDITIONAL([HAVE_LIBNFNETLINK], [false])
+
+ regular_CFLAGS="-Wall -Waggregate-return -Wmissing-declarations \
+ -Wmissing-prototypes -Wredundant-decls -Wshadow -Wstrict-prototypes \
diff --git a/package/network/utils/iptables/patches/100-bash-location.patch b/package/network/utils/iptables/patches/100-bash-location.patch
new file mode 100644
index 0000000..02ee45b
--- /dev/null
+++ b/package/network/utils/iptables/patches/100-bash-location.patch
@@ -0,0 +1,8 @@
+--- a/iptables/iptables-apply
++++ b/iptables/iptables-apply
+@@ -1,4 +1,4 @@
+-#!/bin/bash
++#!/usr/bin/env bash
+ #
+ # iptables-apply -- a safer way to update iptables remotely
+ #
diff --git a/package/network/utils/iptables/patches/200-configurable_builtin.patch b/package/network/utils/iptables/patches/200-configurable_builtin.patch
new file mode 100644
index 0000000..8f095c1
--- /dev/null
+++ b/package/network/utils/iptables/patches/200-configurable_builtin.patch
@@ -0,0 +1,62 @@
+Index: iptables-1.4.18/extensions/GNUmakefile.in
+===================================================================
+--- iptables-1.4.18.orig/extensions/GNUmakefile.in 2013-03-03 22:40:11.000000000 +0100
++++ iptables-1.4.18/extensions/GNUmakefile.in 2013-03-05 16:37:07.583256974 +0100
+@@ -46,9 +46,24 @@
+ pfx_build_mod := $(filter-out @blacklist_modules@,${pfx_build_mod})
+ pf4_build_mod := $(filter-out @blacklist_modules@,${pf4_build_mod})
+ pf6_build_mod := $(filter-out @blacklist_modules@,${pf6_build_mod})
+-pfx_objs := $(patsubst %,libxt_%.o,${pfx_build_mod})
+-pf4_objs := $(patsubst %,libipt_%.o,${pf4_build_mod})
+-pf6_objs := $(patsubst %,libip6t_%.o,${pf6_build_mod})
++
++ifdef BUILTIN_MODULES
++pfx_build_static := $(filter $(BUILTIN_MODULES),${pfx_build_mod})
++pf4_build_static := $(filter $(BUILTIN_MODULES),${pf4_build_mod})
++pf6_build_static := $(filter $(BUILTIN_MODULES),${pf6_build_mod})
++else
++@ENABLE_STATIC_TRUE@ pfx_build_static := $(pfx_build_mod)
++@ENABLE_STATIC_TRUE@ pf4_build_static := $(pf4_build_mod)
++@ENABLE_STATIC_TRUE@ pf6_build_static := $(pf6_build_mod)
++endif
++
++pfx_build_mod := $(filter-out $(pfx_build_static),$(pfx_build_mod))
++pf4_build_mod := $(filter-out $(pf4_build_static),$(pf4_build_mod))
++pf6_build_mod := $(filter-out $(pf6_build_static),$(pf6_build_mod))
++
++pfx_objs := $(patsubst %,libxt_%.o,${pfx_build_static})
++pf4_objs := $(patsubst %,libipt_%.o,${pf4_build_static})
++pf6_objs := $(patsubst %,libip6t_%.o,${pf6_build_static})
+ pfx_solibs := $(patsubst %,libxt_%.so,${pfx_build_mod} ${pfx_symlinks})
+ pf4_solibs := $(patsubst %,libipt_%.so,${pf4_build_mod})
+ pf6_solibs := $(patsubst %,libip6t_%.so,${pf6_build_mod})
+@@ -59,11 +74,11 @@
+ #
+ targets := libext.a libext4.a libext6.a matches.man targets.man
+ targets_install :=
+-@ENABLE_STATIC_TRUE@ libext_objs := ${pfx_objs}
+-@ENABLE_STATIC_TRUE@ libext4_objs := ${pf4_objs}
+-@ENABLE_STATIC_TRUE@ libext6_objs := ${pf6_objs}
+-@ENABLE_STATIC_FALSE@ targets += ${pfx_solibs} ${pf4_solibs} ${pf6_solibs}
+-@ENABLE_STATIC_FALSE@ targets_install += ${pfx_solibs} ${pf4_solibs} ${pf6_solibs}
++libext_objs := ${pfx_objs}
++libext4_objs := ${pf4_objs}
++libext6_objs := ${pf6_objs}
++targets += ${pfx_solibs} ${pf4_solibs} ${pf6_solibs}
++targets_install := $(strip ${targets_install} ${pfx_solibs} ${pf4_solibs} ${pf6_solibs})
+
+ .SECONDARY:
+
+@@ -128,9 +143,9 @@
+ libext6.a: initext6.o ${libext6_objs}
+ ${AM_VERBOSE_AR} ${AR} crs $@ $^;
+
+-initext_func := $(addprefix xt_,${pfx_build_mod})
+-initext4_func := $(addprefix ipt_,${pf4_build_mod})
+-initext6_func := $(addprefix ip6t_,${pf6_build_mod})
++initext_func := $(addprefix xt_,${pfx_build_static})
++initext4_func := $(addprefix ipt_,${pf4_build_static})
++initext6_func := $(addprefix ip6t_,${pf6_build_static})
+
+ .initext.dd: FORCE
+ @echo "${initext_func}" >$@.tmp; \
diff --git a/package/network/utils/iptables/patches/300-musl_fixes.patch b/package/network/utils/iptables/patches/300-musl_fixes.patch
new file mode 100644
index 0000000..039af7c
--- /dev/null
+++ b/package/network/utils/iptables/patches/300-musl_fixes.patch
@@ -0,0 +1,139 @@
+--- a/extensions/libip6t_ipv6header.c
++++ b/extensions/libip6t_ipv6header.c
+@@ -10,6 +10,9 @@ on whether they contain certain headers
+ #include <netdb.h>
+ #include <xtables.h>
+ #include <linux/netfilter_ipv6/ip6t_ipv6header.h>
++#ifndef IPPROTO_HOPOPTS
++# define IPPROTO_HOPOPTS 0
++#endif
+
+ enum {
+ O_HEADER = 0,
+--- a/extensions/libxt_TCPOPTSTRIP.c
++++ b/extensions/libxt_TCPOPTSTRIP.c
+@@ -12,6 +12,21 @@
+ #ifndef TCPOPT_MD5SIG
+ # define TCPOPT_MD5SIG 19
+ #endif
++#ifndef TCPOPT_MAXSEG
++# define TCPOPT_MAXSEG 2
++#endif
++#ifndef TCPOPT_WINDOW
++# define TCPOPT_WINDOW 3
++#endif
++#ifndef TCPOPT_SACK_PERMITTED
++# define TCPOPT_SACK_PERMITTED 4
++#endif
++#ifndef TCPOPT_SACK
++# define TCPOPT_SACK 5
++#endif
++#ifndef TCPOPT_TIMESTAMP
++# define TCPOPT_TIMESTAMP 8
++#endif
+
+ enum {
+ O_STRIP_OPTION = 0,
+--- a/include/libiptc/ipt_kernel_headers.h
++++ b/include/libiptc/ipt_kernel_headers.h
+@@ -5,7 +5,6 @@
+
+ #include <limits.h>
+
+-#if defined(__GLIBC__) && __GLIBC__ == 2
+ #include <netinet/ip.h>
+ #include <netinet/in.h>
+ #include <netinet/ip_icmp.h>
+@@ -13,15 +12,4 @@
+ #include <netinet/udp.h>
+ #include <net/if.h>
+ #include <sys/types.h>
+-#else /* libc5 */
+-#include <sys/socket.h>
+-#include <linux/ip.h>
+-#include <linux/in.h>
+-#include <linux/if.h>
+-#include <linux/icmp.h>
+-#include <linux/tcp.h>
+-#include <linux/udp.h>
+-#include <linux/types.h>
+-#include <linux/in6.h>
+-#endif
+ #endif
+--- a/include/linux/netfilter/xt_osf.h
++++ b/include/linux/netfilter/xt_osf.h
+@@ -21,6 +21,9 @@
+ #define _XT_OSF_H
+
+ #include <linux/types.h>
++#if !defined(__UCLIBC__) && !defined(__GLIBC__)
++#include <linux/tcp.h>
++#endif
+
+ #define MAXGENRELEN 32
+
+--- a/include/linux/netfilter_ipv4/ip_tables.h
++++ b/include/linux/netfilter_ipv4/ip_tables.h
+@@ -16,6 +16,7 @@
+ #define _IPTABLES_H
+
+ #include <linux/types.h>
++#include <sys/types.h>
+
+ #include <linux/netfilter_ipv4.h>
+
+--- a/iptables/ip6tables-restore.c
++++ b/iptables/ip6tables-restore.c
+@@ -9,7 +9,7 @@
+ */
+
+ #include <getopt.h>
+-#include <sys/errno.h>
++#include <errno.h>
+ #include <stdbool.h>
+ #include <string.h>
+ #include <stdio.h>
+--- a/iptables/ip6tables-save.c
++++ b/iptables/ip6tables-save.c
+@@ -6,7 +6,7 @@
+ * This code is distributed under the terms of GNU GPL v2
+ */
+ #include <getopt.h>
+-#include <sys/errno.h>
++#include <errno.h>
+ #include <stdio.h>
+ #include <fcntl.h>
+ #include <stdlib.h>
+--- a/iptables/iptables-restore.c
++++ b/iptables/iptables-restore.c
+@@ -6,7 +6,7 @@
+ */
+
+ #include <getopt.h>
+-#include <sys/errno.h>
++#include <errno.h>
+ #include <stdbool.h>
+ #include <string.h>
+ #include <stdio.h>
+--- a/iptables/iptables-save.c
++++ b/iptables/iptables-save.c
+@@ -6,7 +6,7 @@
+ *
+ */
+ #include <getopt.h>
+-#include <sys/errno.h>
++#include <errno.h>
+ #include <stdio.h>
+ #include <fcntl.h>
+ #include <stdlib.h>
+--- a/iptables/iptables-xml.c
++++ b/iptables/iptables-xml.c
+@@ -7,7 +7,7 @@
+ */
+
+ #include <getopt.h>
+-#include <sys/errno.h>
++#include <errno.h>
+ #include <string.h>
+ #include <stdio.h>
+ #include <stdlib.h>
diff --git a/package/network/utils/iptables/patches/400-lenient-restore.patch b/package/network/utils/iptables/patches/400-lenient-restore.patch
new file mode 100644
index 0000000..696d733
--- /dev/null
+++ b/package/network/utils/iptables/patches/400-lenient-restore.patch
@@ -0,0 +1,176 @@
+Index: iptables-1.4.18/iptables/ip6tables-restore.c
+===================================================================
+--- iptables-1.4.18.orig/iptables/ip6tables-restore.c 2013-03-05 16:37:31.000000000 +0100
++++ iptables-1.4.18/iptables/ip6tables-restore.c 2013-03-05 16:42:57.475249794 +0100
+@@ -14,6 +14,8 @@
+ #include <string.h>
+ #include <stdio.h>
+ #include <stdlib.h>
++#include <stdarg.h>
++#include <setjmp.h>
+ #include "ip6tables.h"
+ #include "xtables.h"
+ #include "libiptc/libip6tc.h"
+@@ -25,6 +27,7 @@
+ #define DEBUGP(x, args...)
+ #endif
+
++static jmp_buf jmp;
+ static int binary = 0, counters = 0, verbose = 0, noflush = 0;
+
+ /* Keeping track of external matches and targets. */
+@@ -35,6 +38,7 @@
+ {.name = "test", .has_arg = false, .val = 't'},
+ {.name = "help", .has_arg = false, .val = 'h'},
+ {.name = "noflush", .has_arg = false, .val = 'n'},
++ {.name = "lenient", .has_arg = false, .val = 'l'},
+ {.name = "modprobe", .has_arg = true, .val = 'M'},
+ {.name = "table", .has_arg = true, .val = 'T'},
+ {NULL},
+@@ -51,6 +55,7 @@
+ " [ --test ]\n"
+ " [ --help ]\n"
+ " [ --noflush ]\n"
++ " [ --lenient ]\n"
+ " [ --modprobe=<command>]\n", name);
+
+ exit(1);
+@@ -114,6 +119,17 @@
+ free(newargv[i]);
+ }
+
++static void catch_exit_error(enum xtables_exittype status, const char *msg, ...)
++{
++ va_list args;
++ fprintf(stderr, "line %d: ", line);
++ va_start(args, msg);
++ vfprintf(stderr, msg, args);
++ va_end(args);
++ fprintf(stderr, "\n");
++ longjmp(jmp, status);
++}
++
+ static void add_param_to_argv(char *parsestart)
+ {
+ int quote_open = 0, escaped = 0, param_len = 0;
+@@ -204,7 +220,7 @@
+ init_extensions6();
+ #endif
+
+- while ((c = getopt_long(argc, argv, "bcvthnM:T:", options, NULL)) != -1) {
++ while ((c = getopt_long(argc, argv, "bcvthnlM:T:", options, NULL)) != -1) {
+ switch (c) {
+ case 'b':
+ binary = 1;
+@@ -225,6 +241,9 @@
+ case 'n':
+ noflush = 1;
+ break;
++ case 'l':
++ ip6tables_globals.exit_err = catch_exit_error;
++ break;
+ case 'M':
+ xtables_modprobe_program = optarg;
+ break;
+@@ -437,8 +456,11 @@
+ for (a = 0; a < newargc; a++)
+ DEBUGP("argv[%u]: %s\n", a, newargv[a]);
+
+- ret = do_command6(newargc, newargv,
+- &newargv[2], &handle);
++ if (!setjmp(jmp))
++ ret = do_command6(newargc, newargv,
++ &newargv[2], &handle);
++ else
++ ret = 1;
+
+ free_argv();
+ fflush(stdout);
+Index: iptables-1.4.18/iptables/iptables-restore.c
+===================================================================
+--- iptables-1.4.18.orig/iptables/iptables-restore.c 2013-03-05 16:37:31.000000000 +0100
++++ iptables-1.4.18/iptables/iptables-restore.c 2013-03-05 16:44:56.303247355 +0100
+@@ -11,6 +11,8 @@
+ #include <string.h>
+ #include <stdio.h>
+ #include <stdlib.h>
++#include <stdarg.h>
++#include <setjmp.h>
+ #include "iptables.h"
+ #include "xtables.h"
+ #include "libiptc/libiptc.h"
+@@ -22,6 +24,7 @@
+ #define DEBUGP(x, args...)
+ #endif
+
++static jmp_buf jmp;
+ static int binary = 0, counters = 0, verbose = 0, noflush = 0;
+
+ /* Keeping track of external matches and targets. */
+@@ -32,6 +35,7 @@
+ {.name = "test", .has_arg = false, .val = 't'},
+ {.name = "help", .has_arg = false, .val = 'h'},
+ {.name = "noflush", .has_arg = false, .val = 'n'},
++ {.name = "lenient", .has_arg = false, .val = 'l'},
+ {.name = "modprobe", .has_arg = true, .val = 'M'},
+ {.name = "table", .has_arg = true, .val = 'T'},
+ {NULL},
+@@ -50,6 +54,7 @@
+ " [ --test ]\n"
+ " [ --help ]\n"
+ " [ --noflush ]\n"
++ " [ --lenient ]\n"
+ " [ --table=<TABLE> ]\n"
+ " [ --modprobe=<command>]\n", name);
+
+@@ -113,6 +118,17 @@
+ free(newargv[i]);
+ }
+
++static void catch_exit_error(enum xtables_exittype status, const char *msg, ...)
++{
++ va_list args;
++ fprintf(stderr, "line %d: ", line);
++ va_start(args, msg);
++ vfprintf(stderr, msg, args);
++ va_end(args);
++ fprintf(stderr, "\n");
++ longjmp(jmp, status);
++}
++
+ static void add_param_to_argv(char *parsestart)
+ {
+ int quote_open = 0, escaped = 0, param_len = 0;
+@@ -204,7 +220,7 @@
+ init_extensions4();
+ #endif
+
+- while ((c = getopt_long(argc, argv, "bcvthnM:T:", options, NULL)) != -1) {
++ while ((c = getopt_long(argc, argv, "bcvthnlM:T:", options, NULL)) != -1) {
+ switch (c) {
+ case 'b':
+ binary = 1;
+@@ -225,6 +241,9 @@
+ case 'n':
+ noflush = 1;
+ break;
++ case 'l':
++ iptables_globals.exit_err = catch_exit_error;
++ break;
+ case 'M':
+ xtables_modprobe_program = optarg;
+ break;
+@@ -437,8 +456,11 @@
+ for (a = 0; a < newargc; a++)
+ DEBUGP("argv[%u]: %s\n", a, newargv[a]);
+
+- ret = do_command4(newargc, newargv,
+- &newargv[2], &handle);
++ if (!setjmp(jmp))
++ ret = do_command4(newargc, newargv,
++ &newargv[2], &handle);
++ else
++ ret = 1;
+
+ free_argv();
+ fflush(stdout);
diff --git a/package/network/utils/iputils/.svn/entries b/package/network/utils/iputils/.svn/entries
new file mode 100644
index 0000000..b1216ee
--- /dev/null
+++ b/package/network/utils/iputils/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/utils/iputils
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-10T13:22:18.706716Z
+33704
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+1195f1fc3a8508ff961906b8e6e764d9
+2012-10-10T13:22:18.706716Z
+33704
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4230
+
diff --git a/package/network/utils/iputils/.svn/text-base/Makefile.svn-base b/package/network/utils/iputils/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..ff7505b
--- /dev/null
+++ b/package/network/utils/iputils/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,180 @@
+#
+# Copyright (C) 2006-2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=iputils
+PKG_VERSION:=20101006
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-s$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=http://www.skbuff.net/iputils
+PKG_MD5SUM:=a36c25e9ec17e48be514dc0485e7376c
+
+PKG_MAINTAINER:=Jo-Philipp Wich <jow@openwrt.org>
+
+PKG_BUILD_DEPENDS:=sysfsutils
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-s$(PKG_VERSION)
+
+include $(INCLUDE_DIR)/package.mk
+
+
+define Package/iputils/Default
+ SECTION:=net
+ CATEGORY:=Network
+ URL:=http://www.skbuff.net/iputils
+endef
+
+
+define Package/iputils-arping
+$(call Package/iputils/Default)
+ TITLE:=iputils - arping
+ DEPENDS+= +libsysfs
+endef
+
+define Package/iputils-arping/description
+ Program arping from iputils.
+ Sends ARP REQUEST to a neighbour host.
+endef
+
+
+define Package/iputils-clockdiff
+$(call Package/iputils/Default)
+ TITLE:=iputils - clockdiff
+endef
+
+define Package/iputils-clockdiff/description
+ Program clockdiff from iputils.
+ Measures clock difference between hosts.
+endef
+
+
+define Package/iputils-ping
+$(call Package/iputils/Default)
+ TITLE:=iputils - ping
+endef
+
+define Package/iputils-ping/description
+ Program ping from iputils.
+ Sends ICMP ECHO_REQUEST to network hosts (IPv4).
+endef
+
+
+define Package/iputils-ping6
+$(call Package/iputils/Default)
+ TITLE:=iputils - ping6
+ DEPENDS+= @IPV6
+endef
+
+define Package/iputils-ping6/description
+ Program ping6 from iputils.
+ Sends ICMP ECHO_REQUEST to network hosts (IPv6).
+endef
+
+
+define Package/iputils-tftpd
+$(call Package/iputils/Default)
+ TITLE:=iputils - tftpd
+endef
+
+define Package/iputils-tftpd/description
+ Program tftpd from iputils
+ Trivial File Transfer Protocol server.
+endef
+
+
+define Package/iputils-tracepath
+$(call Package/iputils/Default)
+ TITLE:=iputils - tracepath
+endef
+
+define Package/iputils-tracepath/description
+ Program tracepath from iputils.
+ Traces path to a network host discovering MTU along this path (IPv4).
+endef
+
+
+define Package/iputils-tracepath6
+$(call Package/iputils/Default)
+ TITLE:=iputils - tracepath6
+ DEPENDS+= @IPV6
+endef
+
+define Package/iputils-tracepath6/description
+ Program tracepath6 from iputils.
+ Traces path to a network host discovering MTU along this path (IPv6).
+endef
+
+
+define Package/iputils-traceroute6
+$(call Package/iputils/Default)
+ TITLE:=iputils - traceroute6
+ DEPENDS+= @IPV6
+endef
+
+define Package/iputils-traceroute6/description
+ Program traceroute6 from iputils.
+ Traces path to a network host (IPv6).
+endef
+
+ifeq ($(BOARD),brcm47xx)
+ TARGET_CFLAGS += -O2
+endif
+
+MAKE_FLAGS += \
+ CFLAGS="$(TARGET_CFLAGS) $(TARGET_CPPFLAGS) $(TARGET_LDFLAGS)" \
+ CONFIG_IPV6="$(CONFIG_IPV6)" \
+ CONFIG_USE_UCLIBC="$(CONFIG_USE_UCLIBC)" \
+
+define Package/iputils-arping/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/arping $(1)/usr/bin/
+endef
+
+define Package/iputils-clockdiff/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/clockdiff $(1)/usr/bin/
+endef
+
+define Package/iputils-ping/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/ping $(1)/usr/bin/
+endef
+
+define Package/iputils-ping6/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/ping6 $(1)/usr/bin/
+endef
+
+define Package/iputils-tftpd/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/tftpd $(1)/usr/sbin/
+endef
+
+define Package/iputils-tracepath/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/tracepath $(1)/usr/bin/
+endef
+
+define Package/iputils-tracepath6/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/tracepath6 $(1)/usr/bin/
+endef
+
+define Package/iputils-traceroute6/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/traceroute6 $(1)/usr/bin/
+endef
+
+$(eval $(call BuildPackage,iputils-arping))
+$(eval $(call BuildPackage,iputils-clockdiff))
+$(eval $(call BuildPackage,iputils-ping))
+$(eval $(call BuildPackage,iputils-tftpd))
+$(eval $(call BuildPackage,iputils-tracepath))
+$(eval $(call BuildPackage,iputils-ping6))
+$(eval $(call BuildPackage,iputils-tracepath6))
+$(eval $(call BuildPackage,iputils-traceroute6))
diff --git a/package/network/utils/iputils/Makefile b/package/network/utils/iputils/Makefile
new file mode 100644
index 0000000..ff7505b
--- /dev/null
+++ b/package/network/utils/iputils/Makefile
@@ -0,0 +1,180 @@
+#
+# Copyright (C) 2006-2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=iputils
+PKG_VERSION:=20101006
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-s$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=http://www.skbuff.net/iputils
+PKG_MD5SUM:=a36c25e9ec17e48be514dc0485e7376c
+
+PKG_MAINTAINER:=Jo-Philipp Wich <jow@openwrt.org>
+
+PKG_BUILD_DEPENDS:=sysfsutils
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-s$(PKG_VERSION)
+
+include $(INCLUDE_DIR)/package.mk
+
+
+define Package/iputils/Default
+ SECTION:=net
+ CATEGORY:=Network
+ URL:=http://www.skbuff.net/iputils
+endef
+
+
+define Package/iputils-arping
+$(call Package/iputils/Default)
+ TITLE:=iputils - arping
+ DEPENDS+= +libsysfs
+endef
+
+define Package/iputils-arping/description
+ Program arping from iputils.
+ Sends ARP REQUEST to a neighbour host.
+endef
+
+
+define Package/iputils-clockdiff
+$(call Package/iputils/Default)
+ TITLE:=iputils - clockdiff
+endef
+
+define Package/iputils-clockdiff/description
+ Program clockdiff from iputils.
+ Measures clock difference between hosts.
+endef
+
+
+define Package/iputils-ping
+$(call Package/iputils/Default)
+ TITLE:=iputils - ping
+endef
+
+define Package/iputils-ping/description
+ Program ping from iputils.
+ Sends ICMP ECHO_REQUEST to network hosts (IPv4).
+endef
+
+
+define Package/iputils-ping6
+$(call Package/iputils/Default)
+ TITLE:=iputils - ping6
+ DEPENDS+= @IPV6
+endef
+
+define Package/iputils-ping6/description
+ Program ping6 from iputils.
+ Sends ICMP ECHO_REQUEST to network hosts (IPv6).
+endef
+
+
+define Package/iputils-tftpd
+$(call Package/iputils/Default)
+ TITLE:=iputils - tftpd
+endef
+
+define Package/iputils-tftpd/description
+ Program tftpd from iputils
+ Trivial File Transfer Protocol server.
+endef
+
+
+define Package/iputils-tracepath
+$(call Package/iputils/Default)
+ TITLE:=iputils - tracepath
+endef
+
+define Package/iputils-tracepath/description
+ Program tracepath from iputils.
+ Traces path to a network host discovering MTU along this path (IPv4).
+endef
+
+
+define Package/iputils-tracepath6
+$(call Package/iputils/Default)
+ TITLE:=iputils - tracepath6
+ DEPENDS+= @IPV6
+endef
+
+define Package/iputils-tracepath6/description
+ Program tracepath6 from iputils.
+ Traces path to a network host discovering MTU along this path (IPv6).
+endef
+
+
+define Package/iputils-traceroute6
+$(call Package/iputils/Default)
+ TITLE:=iputils - traceroute6
+ DEPENDS+= @IPV6
+endef
+
+define Package/iputils-traceroute6/description
+ Program traceroute6 from iputils.
+ Traces path to a network host (IPv6).
+endef
+
+ifeq ($(BOARD),brcm47xx)
+ TARGET_CFLAGS += -O2
+endif
+
+MAKE_FLAGS += \
+ CFLAGS="$(TARGET_CFLAGS) $(TARGET_CPPFLAGS) $(TARGET_LDFLAGS)" \
+ CONFIG_IPV6="$(CONFIG_IPV6)" \
+ CONFIG_USE_UCLIBC="$(CONFIG_USE_UCLIBC)" \
+
+define Package/iputils-arping/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/arping $(1)/usr/bin/
+endef
+
+define Package/iputils-clockdiff/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/clockdiff $(1)/usr/bin/
+endef
+
+define Package/iputils-ping/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/ping $(1)/usr/bin/
+endef
+
+define Package/iputils-ping6/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/ping6 $(1)/usr/bin/
+endef
+
+define Package/iputils-tftpd/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/tftpd $(1)/usr/sbin/
+endef
+
+define Package/iputils-tracepath/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/tracepath $(1)/usr/bin/
+endef
+
+define Package/iputils-tracepath6/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/tracepath6 $(1)/usr/bin/
+endef
+
+define Package/iputils-traceroute6/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/traceroute6 $(1)/usr/bin/
+endef
+
+$(eval $(call BuildPackage,iputils-arping))
+$(eval $(call BuildPackage,iputils-clockdiff))
+$(eval $(call BuildPackage,iputils-ping))
+$(eval $(call BuildPackage,iputils-tftpd))
+$(eval $(call BuildPackage,iputils-tracepath))
+$(eval $(call BuildPackage,iputils-ping6))
+$(eval $(call BuildPackage,iputils-tracepath6))
+$(eval $(call BuildPackage,iputils-traceroute6))
diff --git a/package/network/utils/iputils/patches/.svn/entries b/package/network/utils/iputils/patches/.svn/entries
new file mode 100644
index 0000000..2445b24
--- /dev/null
+++ b/package/network/utils/iputils/patches/.svn/entries
@@ -0,0 +1,198 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/utils/iputils/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2011-06-04T14:12:34.880406Z
+27108
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+003-fix-makefile.patch
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+edcdcdc9d8737e5a59e412aeec5f3fdf
+2011-05-24T09:46:46.932482Z
+26994
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+466
+
+001-iputils.patch
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+94df69e0e9a2de9fd9b89e904fe1153d
+2011-05-24T09:46:46.932482Z
+26994
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+542
+
+002-fix-ipv6.patch
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+b205407271f5d3b1dd6bd1f2f57bf984
+2011-05-24T09:46:46.932482Z
+26994
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+398
+
+011-ping6_use_gnu_source.patch
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+1cfd6c3c825328082a6eb9ebaee828ef
+2011-06-04T14:12:34.880406Z
+27108
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+262
+
+010-ping6_uclibc_resolv.patch
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+d96022fc4aafb7dd03389f72318467c7
+2011-05-24T09:46:46.932482Z
+26994
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4869
+
diff --git a/package/network/utils/iputils/patches/.svn/text-base/001-iputils.patch.svn-base b/package/network/utils/iputils/patches/.svn/text-base/001-iputils.patch.svn-base
new file mode 100644
index 0000000..e57db13
--- /dev/null
+++ b/package/network/utils/iputils/patches/.svn/text-base/001-iputils.patch.svn-base
@@ -0,0 +1,14 @@
+diff -ur a/Makefile b/Makefile
+--- a/Makefile 2002-09-20 18:23:55.000000000 +0000
++++ b/Makefile 2007-05-17 13:59:55.000000000 +0000
+@@ -16,8 +16,8 @@
+ CCOPT=-D_GNU_SOURCE -O2 -Wstrict-prototypes -Wall -g
+ CFLAGS=$(CCOPT) $(GLIBCFIX) $(DEFINES)
+
+-IPV4_TARGETS=tracepath ping clockdiff rdisc arping tftpd rarpd
+-IPV6_TARGETS=tracepath6 traceroute6 ping6
++IPV4_TARGETS=tracepath ping clockdiff arping tftpd
++IPV6_TARGETS=tracepath6 traceroute6 ping6
+ TARGETS=$(IPV4_TARGETS) $(IPV6_TARGETS)
+
+ LASTTAG:=`git describe HEAD | sed -e 's/-.*//'`
diff --git a/package/network/utils/iputils/patches/.svn/text-base/002-fix-ipv6.patch.svn-base b/package/network/utils/iputils/patches/.svn/text-base/002-fix-ipv6.patch.svn-base
new file mode 100644
index 0000000..4411ca7
--- /dev/null
+++ b/package/network/utils/iputils/patches/.svn/text-base/002-fix-ipv6.patch.svn-base
@@ -0,0 +1,14 @@
+--- a/Makefile
++++ b/Makefile
+@@ -18,7 +18,10 @@ CFLAGS=$(CCOPT) $(GLIBCFIX) $(DEFINES)
+
+ IPV4_TARGETS=tracepath ping clockdiff arping tftpd
+ IPV6_TARGETS=tracepath6 traceroute6 ping6
+-TARGETS=$(IPV4_TARGETS) $(IPV6_TARGETS)
++TARGETS=$(IPV4_TARGETS)
++ifeq ($(CONFIG_IPV6),y)
++ TARGETS=$(IPV4_TARGETS) $(IPV6_TARGETS)
++endif
+
+ LASTTAG:=`git describe HEAD | sed -e 's/-.*//'`
+ TAG:=`date +s%Y%m%d`
diff --git a/package/network/utils/iputils/patches/.svn/text-base/003-fix-makefile.patch.svn-base b/package/network/utils/iputils/patches/.svn/text-base/003-fix-makefile.patch.svn-base
new file mode 100644
index 0000000..926c685
--- /dev/null
+++ b/package/network/utils/iputils/patches/.svn/text-base/003-fix-makefile.patch.svn-base
@@ -0,0 +1,18 @@
+--- a/Makefile
++++ b/Makefile
+@@ -30,9 +30,13 @@ all: $(TARGETS)
+
+
+ tftpd: tftpd.o tftpsubs.o
+-arping: arping.o -lsysfs
++arping: arping.o
++ $(CC) $(CFLAGS) -o $@ arping.o -lsysfs
+ ping: ping.o ping_common.o
+-ping6: ping6.o ping_common.o -lresolv -lcrypto
++ping6: ping6.o ping_common.o
++ifneq ($(CONFIG_USE_UCLIBC),y)
++ $(CC) $(CFLAGS) -o $@ ping6.o ping_common.o -lresolv -lcrypto
++endif
+ ping.o ping6.o ping_common.o: ping_common.h
+ tftpd.o tftpsubs.o: tftp.h
+
diff --git a/package/network/utils/iputils/patches/.svn/text-base/010-ping6_uclibc_resolv.patch.svn-base b/package/network/utils/iputils/patches/.svn/text-base/010-ping6_uclibc_resolv.patch.svn-base
new file mode 100644
index 0000000..6955803
--- /dev/null
+++ b/package/network/utils/iputils/patches/.svn/text-base/010-ping6_uclibc_resolv.patch.svn-base
@@ -0,0 +1,200 @@
+diff --git a/ping6.c b/ping6.c
+index c5ff881..ef2243f 100644
+--- a/ping6.c
++++ b/ping6.c
+@@ -71,9 +71,11 @@ char copyright[] =
+ #include <linux/filter.h>
+ #include <netinet/ip6.h>
+ #include <netinet/icmp6.h>
++#ifndef __UCLIBC__
+ #include <resolv.h>
+
+ #include "ping6_niquery.h"
++#endif /* __UCLIBC__ */
+
+ #ifndef SOL_IPV6
+ #define SOL_IPV6 IPPROTO_IPV6
+@@ -154,6 +156,7 @@ int pmtudisc=-1;
+
+ static int icmp_sock;
+
++#ifndef __UCLIBC__
+ #include <openssl/md5.h>
+
+ /* Node Information query */
+@@ -165,6 +168,7 @@ int ni_subject_type = 0;
+ char *ni_group;
+
+ __u8 ni_nonce[8];
++#endif /* __UCLIBC__ */
+
+ static struct in6_addr in6_anyaddr;
+ static __inline__ int ipv6_addr_any(struct in6_addr *addr)
+@@ -223,6 +227,7 @@ unsigned int if_name2index(const char *ifname)
+ return i;
+ }
+
++#ifndef __UCLIBC__
+ struct niquery_option {
+ char *name;
+ int namelen;
+@@ -512,6 +517,7 @@ char *ni_groupaddr(const char *name)
+ strcat(nigroup_buf, q);
+ return nigroup_buf;
+ }
++#endif /* __UCLIBC__ */
+
+ int main(int argc, char *argv[])
+ {
+@@ -595,12 +601,14 @@ int main(int argc, char *argv[])
+ case 'V':
+ printf("ping6 utility, iputils-ss%s\n", SNAPSHOT);
+ exit(0);
++#ifndef __UCLIBC__
+ case 'N':
+ if (niquery_option_handler(optarg) < 0) {
+ usage();
+ break;
+ }
+ break;
++#endif /* __UCLIBC__ */
+ COMMON_OPTIONS
+ common_options(ch);
+ break;
+@@ -663,6 +671,7 @@ int main(int argc, char *argv[])
+ argc--;
+ }
+
++#ifndef __UCLIBC__
+ if (ni_query >= 0) {
+ int i;
+ for (i = 0; i < 8; i++)
+@@ -674,15 +683,20 @@ int main(int argc, char *argv[])
+ ni_subject_type = NI_SUBJ_IPV6;
+ }
+ }
++#endif /* __UCLIBC__ */
+
+ if (argc > 1)
+ usage();
+ else if (argc == 1) {
+ target = *argv;
+ } else {
++#ifndef __UCLIBC__
+ if (ni_query < 0 && ni_subject_type != NI_SUBJ_NAME)
++#endif /* __UCLIBC__ */
+ usage();
++#ifndef __UCLIBC__
+ target = ni_group;
++#endif /* __UCLIBC__ */
+ }
+
+ memset(&hints, 0, sizeof(hints));
+@@ -817,7 +831,11 @@ int main(int argc, char *argv[])
+ exit(2);
+ }
+
++#ifndef __UCLIBC__
+ if (datalen >= sizeof(struct timeval) && (ni_query < 0)) {
++#else
++ if (datalen >= sizeof(struct timeval)) {
++#endif /* __UCLIBC__ */
+ /* can we time transfer */
+ timing = 1;
+ }
+@@ -866,9 +884,11 @@ int main(int argc, char *argv[])
+ ICMP6_FILTER_SETPASS(ICMP6_PARAM_PROB, &filter);
+ }
+
++#ifndef __UCLIBC__
+ if (ni_query >= 0)
+ ICMP6_FILTER_SETPASS(ICMPV6_NI_REPLY, &filter);
+ else
++#endif /* __UCLIBC__ */
+ ICMP6_FILTER_SETPASS(ICMP6_ECHO_REPLY, &filter);
+
+ err = setsockopt(icmp_sock, IPPROTO_ICMPV6, ICMP6_FILTER, &filter,
+@@ -1100,6 +1120,7 @@ int build_echo(__u8 *_icmph)
+ return cc;
+ }
+
++#ifndef __UCLIBC__
+ int build_niquery(__u8 *_nih)
+ {
+ struct ni_hdr *nih;
+@@ -1125,6 +1146,7 @@ int build_niquery(__u8 *_nih)
+
+ return cc;
+ }
++#endif /* __UCLIBC__ */
+
+ int send_probe(void)
+ {
+@@ -1132,9 +1154,11 @@ int send_probe(void)
+
+ CLR((ntransmitted+1) % mx_dup_ck);
+
++#ifndef __UCLIBC__
+ if (ni_query >= 0)
+ len = build_niquery(outpack);
+ else
++#endif /* __UCLIBC__ */
+ len = build_echo(outpack);
+
+ if (cmsglen == 0) {
+@@ -1176,6 +1200,7 @@ static void putchar_safe(char c)
+ printf("\\%03o", c);
+ }
+
++#ifndef __UCLIBC__
+ void pr_niquery_reply_name(struct ni_hdr *nih, int len)
+ {
+ __u8 *h = (__u8 *)(nih + 1);
+@@ -1304,6 +1329,7 @@ void pr_niquery_reply(__u8 *_nih, int len)
+ }
+ putchar(';');
+ }
++#endif /* __UCLIBC__ */
+
+ /*
+ * parse_reply --
+@@ -1353,6 +1379,7 @@ parse_reply(struct msghdr *msg, int cc, void *addr, struct timeval *tv)
+ hops, 0, tv, pr_addr(&from->sin6_addr),
+ pr_echo_reply))
+ return 0;
++#ifndef __UCLIBC__
+ } else if (icmph->icmp6_type == ICMPV6_NI_REPLY) {
+ struct ni_hdr *nih = (struct ni_hdr *)icmph;
+ __u16 seq = ntohs(*(__u16 *)nih->ni_nonce);
+@@ -1363,6 +1390,7 @@ parse_reply(struct msghdr *msg, int cc, void *addr, struct timeval *tv)
+ hops, 0, tv, pr_addr(&from->sin6_addr),
+ pr_niquery_reply))
+ return 0;
++#endif /* __UCLIBC__ */
+ } else {
+ int nexthdr;
+ struct ip6_hdr *iph1 = (struct ip6_hdr*)(icmph+1);
+@@ -1557,7 +1585,9 @@ void usage(void)
+ "Usage: ping6 [-LUdfnqrvVaAD] [-c count] [-i interval] [-w deadline]\n"
+ " [-p pattern] [-s packetsize] [-t ttl] [-I interface]\n"
+ " [-M pmtudisc-hint] [-S sndbuf] [-F flowlabel] [-Q tclass]\n"
++#ifndef __UCLIBC__
+ " [[-N nodeinfo-option] ...]\n"
++#endif /* __UCLIBC__ */
+ " [hop1 ...] destination\n");
+ exit(2);
+ }
+diff --git a/ping6_niquery.h b/ping6_niquery.h
+index 61a5cfa..34c31f8 100644
+--- a/ping6_niquery.h
++++ b/ping6_niquery.h
+@@ -1,3 +1,4 @@
++#ifndef __UCLIBC__
+ #include <asm/byteorder.h>
+
+ /* Node Information Query */
+@@ -45,3 +46,4 @@ struct ni_hdr {
+ #define NI_IPV4ADDR_F_TRUNCATE NI_IPV6ADDR_F_TRUNCATE
+ #define NI_IPV4ADDR_F_ALL NI_IPV6ADDR_F_ALL
+
++#endif /* __UCLIBC__ */
diff --git a/package/network/utils/iputils/patches/.svn/text-base/011-ping6_use_gnu_source.patch.svn-base b/package/network/utils/iputils/patches/.svn/text-base/011-ping6_use_gnu_source.patch.svn-base
new file mode 100644
index 0000000..dc61b8c
--- /dev/null
+++ b/package/network/utils/iputils/patches/.svn/text-base/011-ping6_use_gnu_source.patch.svn-base
@@ -0,0 +1,11 @@
+--- a/ping6.c
++++ b/ping6.c
+@@ -66,6 +66,8 @@ char copyright[] =
+ * More statistics could always be gathered.
+ * This program has to run SUID to ROOT to access the ICMP socket.
+ */
++
++#define _GNU_SOURCE
+ #include "ping_common.h"
+
+ #include <linux/filter.h>
diff --git a/package/network/utils/iputils/patches/001-iputils.patch b/package/network/utils/iputils/patches/001-iputils.patch
new file mode 100644
index 0000000..e57db13
--- /dev/null
+++ b/package/network/utils/iputils/patches/001-iputils.patch
@@ -0,0 +1,14 @@
+diff -ur a/Makefile b/Makefile
+--- a/Makefile 2002-09-20 18:23:55.000000000 +0000
++++ b/Makefile 2007-05-17 13:59:55.000000000 +0000
+@@ -16,8 +16,8 @@
+ CCOPT=-D_GNU_SOURCE -O2 -Wstrict-prototypes -Wall -g
+ CFLAGS=$(CCOPT) $(GLIBCFIX) $(DEFINES)
+
+-IPV4_TARGETS=tracepath ping clockdiff rdisc arping tftpd rarpd
+-IPV6_TARGETS=tracepath6 traceroute6 ping6
++IPV4_TARGETS=tracepath ping clockdiff arping tftpd
++IPV6_TARGETS=tracepath6 traceroute6 ping6
+ TARGETS=$(IPV4_TARGETS) $(IPV6_TARGETS)
+
+ LASTTAG:=`git describe HEAD | sed -e 's/-.*//'`
diff --git a/package/network/utils/iputils/patches/002-fix-ipv6.patch b/package/network/utils/iputils/patches/002-fix-ipv6.patch
new file mode 100644
index 0000000..4411ca7
--- /dev/null
+++ b/package/network/utils/iputils/patches/002-fix-ipv6.patch
@@ -0,0 +1,14 @@
+--- a/Makefile
++++ b/Makefile
+@@ -18,7 +18,10 @@ CFLAGS=$(CCOPT) $(GLIBCFIX) $(DEFINES)
+
+ IPV4_TARGETS=tracepath ping clockdiff arping tftpd
+ IPV6_TARGETS=tracepath6 traceroute6 ping6
+-TARGETS=$(IPV4_TARGETS) $(IPV6_TARGETS)
++TARGETS=$(IPV4_TARGETS)
++ifeq ($(CONFIG_IPV6),y)
++ TARGETS=$(IPV4_TARGETS) $(IPV6_TARGETS)
++endif
+
+ LASTTAG:=`git describe HEAD | sed -e 's/-.*//'`
+ TAG:=`date +s%Y%m%d`
diff --git a/package/network/utils/iputils/patches/003-fix-makefile.patch b/package/network/utils/iputils/patches/003-fix-makefile.patch
new file mode 100644
index 0000000..926c685
--- /dev/null
+++ b/package/network/utils/iputils/patches/003-fix-makefile.patch
@@ -0,0 +1,18 @@
+--- a/Makefile
++++ b/Makefile
+@@ -30,9 +30,13 @@ all: $(TARGETS)
+
+
+ tftpd: tftpd.o tftpsubs.o
+-arping: arping.o -lsysfs
++arping: arping.o
++ $(CC) $(CFLAGS) -o $@ arping.o -lsysfs
+ ping: ping.o ping_common.o
+-ping6: ping6.o ping_common.o -lresolv -lcrypto
++ping6: ping6.o ping_common.o
++ifneq ($(CONFIG_USE_UCLIBC),y)
++ $(CC) $(CFLAGS) -o $@ ping6.o ping_common.o -lresolv -lcrypto
++endif
+ ping.o ping6.o ping_common.o: ping_common.h
+ tftpd.o tftpsubs.o: tftp.h
+
diff --git a/package/network/utils/iputils/patches/010-ping6_uclibc_resolv.patch b/package/network/utils/iputils/patches/010-ping6_uclibc_resolv.patch
new file mode 100644
index 0000000..6955803
--- /dev/null
+++ b/package/network/utils/iputils/patches/010-ping6_uclibc_resolv.patch
@@ -0,0 +1,200 @@
+diff --git a/ping6.c b/ping6.c
+index c5ff881..ef2243f 100644
+--- a/ping6.c
++++ b/ping6.c
+@@ -71,9 +71,11 @@ char copyright[] =
+ #include <linux/filter.h>
+ #include <netinet/ip6.h>
+ #include <netinet/icmp6.h>
++#ifndef __UCLIBC__
+ #include <resolv.h>
+
+ #include "ping6_niquery.h"
++#endif /* __UCLIBC__ */
+
+ #ifndef SOL_IPV6
+ #define SOL_IPV6 IPPROTO_IPV6
+@@ -154,6 +156,7 @@ int pmtudisc=-1;
+
+ static int icmp_sock;
+
++#ifndef __UCLIBC__
+ #include <openssl/md5.h>
+
+ /* Node Information query */
+@@ -165,6 +168,7 @@ int ni_subject_type = 0;
+ char *ni_group;
+
+ __u8 ni_nonce[8];
++#endif /* __UCLIBC__ */
+
+ static struct in6_addr in6_anyaddr;
+ static __inline__ int ipv6_addr_any(struct in6_addr *addr)
+@@ -223,6 +227,7 @@ unsigned int if_name2index(const char *ifname)
+ return i;
+ }
+
++#ifndef __UCLIBC__
+ struct niquery_option {
+ char *name;
+ int namelen;
+@@ -512,6 +517,7 @@ char *ni_groupaddr(const char *name)
+ strcat(nigroup_buf, q);
+ return nigroup_buf;
+ }
++#endif /* __UCLIBC__ */
+
+ int main(int argc, char *argv[])
+ {
+@@ -595,12 +601,14 @@ int main(int argc, char *argv[])
+ case 'V':
+ printf("ping6 utility, iputils-ss%s\n", SNAPSHOT);
+ exit(0);
++#ifndef __UCLIBC__
+ case 'N':
+ if (niquery_option_handler(optarg) < 0) {
+ usage();
+ break;
+ }
+ break;
++#endif /* __UCLIBC__ */
+ COMMON_OPTIONS
+ common_options(ch);
+ break;
+@@ -663,6 +671,7 @@ int main(int argc, char *argv[])
+ argc--;
+ }
+
++#ifndef __UCLIBC__
+ if (ni_query >= 0) {
+ int i;
+ for (i = 0; i < 8; i++)
+@@ -674,15 +683,20 @@ int main(int argc, char *argv[])
+ ni_subject_type = NI_SUBJ_IPV6;
+ }
+ }
++#endif /* __UCLIBC__ */
+
+ if (argc > 1)
+ usage();
+ else if (argc == 1) {
+ target = *argv;
+ } else {
++#ifndef __UCLIBC__
+ if (ni_query < 0 && ni_subject_type != NI_SUBJ_NAME)
++#endif /* __UCLIBC__ */
+ usage();
++#ifndef __UCLIBC__
+ target = ni_group;
++#endif /* __UCLIBC__ */
+ }
+
+ memset(&hints, 0, sizeof(hints));
+@@ -817,7 +831,11 @@ int main(int argc, char *argv[])
+ exit(2);
+ }
+
++#ifndef __UCLIBC__
+ if (datalen >= sizeof(struct timeval) && (ni_query < 0)) {
++#else
++ if (datalen >= sizeof(struct timeval)) {
++#endif /* __UCLIBC__ */
+ /* can we time transfer */
+ timing = 1;
+ }
+@@ -866,9 +884,11 @@ int main(int argc, char *argv[])
+ ICMP6_FILTER_SETPASS(ICMP6_PARAM_PROB, &filter);
+ }
+
++#ifndef __UCLIBC__
+ if (ni_query >= 0)
+ ICMP6_FILTER_SETPASS(ICMPV6_NI_REPLY, &filter);
+ else
++#endif /* __UCLIBC__ */
+ ICMP6_FILTER_SETPASS(ICMP6_ECHO_REPLY, &filter);
+
+ err = setsockopt(icmp_sock, IPPROTO_ICMPV6, ICMP6_FILTER, &filter,
+@@ -1100,6 +1120,7 @@ int build_echo(__u8 *_icmph)
+ return cc;
+ }
+
++#ifndef __UCLIBC__
+ int build_niquery(__u8 *_nih)
+ {
+ struct ni_hdr *nih;
+@@ -1125,6 +1146,7 @@ int build_niquery(__u8 *_nih)
+
+ return cc;
+ }
++#endif /* __UCLIBC__ */
+
+ int send_probe(void)
+ {
+@@ -1132,9 +1154,11 @@ int send_probe(void)
+
+ CLR((ntransmitted+1) % mx_dup_ck);
+
++#ifndef __UCLIBC__
+ if (ni_query >= 0)
+ len = build_niquery(outpack);
+ else
++#endif /* __UCLIBC__ */
+ len = build_echo(outpack);
+
+ if (cmsglen == 0) {
+@@ -1176,6 +1200,7 @@ static void putchar_safe(char c)
+ printf("\\%03o", c);
+ }
+
++#ifndef __UCLIBC__
+ void pr_niquery_reply_name(struct ni_hdr *nih, int len)
+ {
+ __u8 *h = (__u8 *)(nih + 1);
+@@ -1304,6 +1329,7 @@ void pr_niquery_reply(__u8 *_nih, int len)
+ }
+ putchar(';');
+ }
++#endif /* __UCLIBC__ */
+
+ /*
+ * parse_reply --
+@@ -1353,6 +1379,7 @@ parse_reply(struct msghdr *msg, int cc, void *addr, struct timeval *tv)
+ hops, 0, tv, pr_addr(&from->sin6_addr),
+ pr_echo_reply))
+ return 0;
++#ifndef __UCLIBC__
+ } else if (icmph->icmp6_type == ICMPV6_NI_REPLY) {
+ struct ni_hdr *nih = (struct ni_hdr *)icmph;
+ __u16 seq = ntohs(*(__u16 *)nih->ni_nonce);
+@@ -1363,6 +1390,7 @@ parse_reply(struct msghdr *msg, int cc, void *addr, struct timeval *tv)
+ hops, 0, tv, pr_addr(&from->sin6_addr),
+ pr_niquery_reply))
+ return 0;
++#endif /* __UCLIBC__ */
+ } else {
+ int nexthdr;
+ struct ip6_hdr *iph1 = (struct ip6_hdr*)(icmph+1);
+@@ -1557,7 +1585,9 @@ void usage(void)
+ "Usage: ping6 [-LUdfnqrvVaAD] [-c count] [-i interval] [-w deadline]\n"
+ " [-p pattern] [-s packetsize] [-t ttl] [-I interface]\n"
+ " [-M pmtudisc-hint] [-S sndbuf] [-F flowlabel] [-Q tclass]\n"
++#ifndef __UCLIBC__
+ " [[-N nodeinfo-option] ...]\n"
++#endif /* __UCLIBC__ */
+ " [hop1 ...] destination\n");
+ exit(2);
+ }
+diff --git a/ping6_niquery.h b/ping6_niquery.h
+index 61a5cfa..34c31f8 100644
+--- a/ping6_niquery.h
++++ b/ping6_niquery.h
+@@ -1,3 +1,4 @@
++#ifndef __UCLIBC__
+ #include <asm/byteorder.h>
+
+ /* Node Information Query */
+@@ -45,3 +46,4 @@ struct ni_hdr {
+ #define NI_IPV4ADDR_F_TRUNCATE NI_IPV6ADDR_F_TRUNCATE
+ #define NI_IPV4ADDR_F_ALL NI_IPV6ADDR_F_ALL
+
++#endif /* __UCLIBC__ */
diff --git a/package/network/utils/iputils/patches/011-ping6_use_gnu_source.patch b/package/network/utils/iputils/patches/011-ping6_use_gnu_source.patch
new file mode 100644
index 0000000..dc61b8c
--- /dev/null
+++ b/package/network/utils/iputils/patches/011-ping6_use_gnu_source.patch
@@ -0,0 +1,11 @@
+--- a/ping6.c
++++ b/ping6.c
+@@ -66,6 +66,8 @@ char copyright[] =
+ * More statistics could always be gathered.
+ * This program has to run SUID to ROOT to access the ICMP socket.
+ */
++
++#define _GNU_SOURCE
+ #include "ping_common.h"
+
+ #include <linux/filter.h>
diff --git a/package/network/utils/iw/.svn/entries b/package/network/utils/iw/.svn/entries
new file mode 100644
index 0000000..63068ce
--- /dev/null
+++ b/package/network/utils/iw/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/utils/iw
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-02T11:28:11.029037Z
+34968
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+b5628907806a98d6f7b4ef17370f0fbe
+2013-01-02T11:28:11.029037Z
+34968
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1348
+
diff --git a/package/network/utils/iw/.svn/prop-base/Makefile.svn-base b/package/network/utils/iw/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/network/utils/iw/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/utils/iw/.svn/text-base/Makefile.svn-base b/package/network/utils/iw/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..91167d8
--- /dev/null
+++ b/package/network/utils/iw/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,56 @@
+#
+# Copyright (C) 2007-2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=iw
+PKG_VERSION:=3.6
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=http://wireless.kernel.org/download/iw/
+PKG_MD5SUM:=1c18bfbbc8773629e5e8ac733a39540c
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/iw
+ SECTION:=net
+ CATEGORY:=Network
+ TITLE:=cfg80211 interface configuration utility
+ URL:=http://wireless.kernel.org/en/users/Documentation/iw
+ DEPENDS:= +libnl-tiny @(!TARGET_avr32||BROKEN)
+endef
+
+define Build/Configure
+ echo "const char iw_version[] = \"$(PKG_VERSION)\";" > $(PKG_BUILD_DIR)/version.c
+ rm -f $(PKG_BUILD_DIR)/version.sh
+ touch $(PKG_BUILD_DIR)/version.sh
+ chmod +x $(PKG_BUILD_DIR)/version.sh
+endef
+
+TARGET_CPPFLAGS:= \
+ -I$(STAGING_DIR)/usr/include/libnl-tiny \
+ $(TARGET_CPPFLAGS) \
+ -DCONFIG_LIBNL20 \
+ -D_GNU_SOURCE
+
+MAKE_FLAGS += \
+ CFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" \
+ LDFLAGS="$(TARGET_LDFLAGS)" \
+ NL1FOUND="" NL2FOUND=Y \
+ NLLIBNAME="libnl-tiny" \
+ LIBS="-lm -lnl-tiny" \
+ V=1
+
+define Package/iw/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/iw $(1)/usr/sbin/
+endef
+
+$(eval $(call BuildPackage,iw))
diff --git a/package/network/utils/iw/Makefile b/package/network/utils/iw/Makefile
new file mode 100644
index 0000000..91167d8
--- /dev/null
+++ b/package/network/utils/iw/Makefile
@@ -0,0 +1,56 @@
+#
+# Copyright (C) 2007-2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=iw
+PKG_VERSION:=3.6
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=http://wireless.kernel.org/download/iw/
+PKG_MD5SUM:=1c18bfbbc8773629e5e8ac733a39540c
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/iw
+ SECTION:=net
+ CATEGORY:=Network
+ TITLE:=cfg80211 interface configuration utility
+ URL:=http://wireless.kernel.org/en/users/Documentation/iw
+ DEPENDS:= +libnl-tiny @(!TARGET_avr32||BROKEN)
+endef
+
+define Build/Configure
+ echo "const char iw_version[] = \"$(PKG_VERSION)\";" > $(PKG_BUILD_DIR)/version.c
+ rm -f $(PKG_BUILD_DIR)/version.sh
+ touch $(PKG_BUILD_DIR)/version.sh
+ chmod +x $(PKG_BUILD_DIR)/version.sh
+endef
+
+TARGET_CPPFLAGS:= \
+ -I$(STAGING_DIR)/usr/include/libnl-tiny \
+ $(TARGET_CPPFLAGS) \
+ -DCONFIG_LIBNL20 \
+ -D_GNU_SOURCE
+
+MAKE_FLAGS += \
+ CFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" \
+ LDFLAGS="$(TARGET_LDFLAGS)" \
+ NL1FOUND="" NL2FOUND=Y \
+ NLLIBNAME="libnl-tiny" \
+ LIBS="-lm -lnl-tiny" \
+ V=1
+
+define Package/iw/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/iw $(1)/usr/sbin/
+endef
+
+$(eval $(call BuildPackage,iw))
diff --git a/package/network/utils/iw/patches/.svn/entries b/package/network/utils/iw/patches/.svn/entries
new file mode 100644
index 0000000..8875257
--- /dev/null
+++ b/package/network/utils/iw/patches/.svn/entries
@@ -0,0 +1,198 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/utils/iw/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-12-10T13:51:06.143934Z
+34593
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+100-rx_rate.patch
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+751518b0e533dfed4b1235607e5a5060
+2012-09-28T18:29:16.238072Z
+33586
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3969
+
+110-per_chain_signal_strength.patch
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+8c915111ed6a3df4e3926f520648b0db
+2012-09-28T18:29:16.238072Z
+33586
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2124
+
+130-antenna_gain.patch
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+8ed2c733f59f909f09acc4ea81e1d23a
+2012-09-28T18:29:16.238072Z
+33586
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+872
+
+001-nl80211_h_sync.patch
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+a02fcb25b178e86b9a7af9d583bf5b49
+2012-12-10T13:51:06.143934Z
+34593
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+18502
+
+120-tdls_peer_indentation.patch
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+aaadc0d834cc12c170c94331dc0f0742
+2012-09-28T18:29:16.238072Z
+33586
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+313
+
diff --git a/package/network/utils/iw/patches/.svn/text-base/001-nl80211_h_sync.patch.svn-base b/package/network/utils/iw/patches/.svn/text-base/001-nl80211_h_sync.patch.svn-base
new file mode 100644
index 0000000..fc28a65
--- /dev/null
+++ b/package/network/utils/iw/patches/.svn/text-base/001-nl80211_h_sync.patch.svn-base
@@ -0,0 +1,416 @@
+--- a/nl80211.h
++++ b/nl80211.h
+@@ -118,8 +118,9 @@
+ * to get a list of all present wiphys.
+ * @NL80211_CMD_SET_WIPHY: set wiphy parameters, needs %NL80211_ATTR_WIPHY or
+ * %NL80211_ATTR_IFINDEX; can be used to set %NL80211_ATTR_WIPHY_NAME,
+- * %NL80211_ATTR_WIPHY_TXQ_PARAMS, %NL80211_ATTR_WIPHY_FREQ,
+- * %NL80211_ATTR_WIPHY_CHANNEL_TYPE, %NL80211_ATTR_WIPHY_RETRY_SHORT,
++ * %NL80211_ATTR_WIPHY_TXQ_PARAMS, %NL80211_ATTR_WIPHY_FREQ (and the
++ * attributes determining the channel width; this is used for setting
++ * monitor mode channel), %NL80211_ATTR_WIPHY_RETRY_SHORT,
+ * %NL80211_ATTR_WIPHY_RETRY_LONG, %NL80211_ATTR_WIPHY_FRAG_THRESHOLD,
+ * and/or %NL80211_ATTR_WIPHY_RTS_THRESHOLD.
+ * However, for setting the channel, see %NL80211_CMD_SET_CHANNEL
+@@ -171,7 +172,7 @@
+ * %NL80211_ATTR_AKM_SUITES, %NL80211_ATTR_PRIVACY,
+ * %NL80211_ATTR_AUTH_TYPE and %NL80211_ATTR_INACTIVITY_TIMEOUT.
+ * The channel to use can be set on the interface or be given using the
+- * %NL80211_ATTR_WIPHY_FREQ and %NL80211_ATTR_WIPHY_CHANNEL_TYPE attrs.
++ * %NL80211_ATTR_WIPHY_FREQ and the attributes determining channel width.
+ * @NL80211_CMD_NEW_BEACON: old alias for %NL80211_CMD_START_AP
+ * @NL80211_CMD_STOP_AP: Stop AP operation on the given interface
+ * @NL80211_CMD_DEL_BEACON: old alias for %NL80211_CMD_STOP_AP
+@@ -401,8 +402,7 @@
+ * a response while being associated to an AP on another channel.
+ * %NL80211_ATTR_IFINDEX is used to specify which interface (and thus
+ * radio) is used. %NL80211_ATTR_WIPHY_FREQ is used to specify the
+- * frequency for the operation and %NL80211_ATTR_WIPHY_CHANNEL_TYPE may be
+- * optionally used to specify additional channel parameters.
++ * frequency for the operation.
+ * %NL80211_ATTR_DURATION is used to specify the duration in milliseconds
+ * to remain on the channel. This command is also used as an event to
+ * notify when the requested duration starts (it may take a while for the
+@@ -440,12 +440,11 @@
+ * as an event indicating reception of a frame that was not processed in
+ * kernel code, but is for us (i.e., which may need to be processed in a
+ * user space application). %NL80211_ATTR_FRAME is used to specify the
+- * frame contents (including header). %NL80211_ATTR_WIPHY_FREQ (and
+- * optionally %NL80211_ATTR_WIPHY_CHANNEL_TYPE) is used to indicate on
+- * which channel the frame is to be transmitted or was received. If this
+- * channel is not the current channel (remain-on-channel or the
+- * operational channel) the device will switch to the given channel and
+- * transmit the frame, optionally waiting for a response for the time
++ * frame contents (including header). %NL80211_ATTR_WIPHY_FREQ is used
++ * to indicate on which channel the frame is to be transmitted or was
++ * received. If this channel is not the current channel (remain-on-channel
++ * or the operational channel) the device will switch to the given channel
++ * and transmit the frame, optionally waiting for a response for the time
+ * specified using %NL80211_ATTR_DURATION. When called, this operation
+ * returns a cookie (%NL80211_ATTR_COOKIE) that will be included with the
+ * TX status event pertaining to the TX request.
+@@ -473,8 +472,8 @@
+ * command is used as an event to indicate the that a trigger level was
+ * reached.
+ * @NL80211_CMD_SET_CHANNEL: Set the channel (using %NL80211_ATTR_WIPHY_FREQ
+- * and %NL80211_ATTR_WIPHY_CHANNEL_TYPE) the given interface (identifed
+- * by %NL80211_ATTR_IFINDEX) shall operate on.
++ * and the attributes determining channel width) the given interface
++ * (identifed by %NL80211_ATTR_IFINDEX) shall operate on.
+ * In case multiple channels are supported by the device, the mechanism
+ * with which it switches channels is implementation-defined.
+ * When a monitor interface is given, it can only switch channel while
+@@ -526,6 +525,12 @@
+ * of PMKSA caching dandidates.
+ *
+ * @NL80211_CMD_TDLS_OPER: Perform a high-level TDLS command (e.g. link setup).
++ * In addition, this can be used as an event to request userspace to take
++ * actions on TDLS links (set up a new link or tear down an existing one).
++ * In such events, %NL80211_ATTR_TDLS_OPERATION indicates the requested
++ * operation, %NL80211_ATTR_MAC contains the peer MAC address, and
++ * %NL80211_ATTR_REASON_CODE the reason code to be used (only with
++ * %NL80211_TDLS_TEARDOWN).
+ * @NL80211_CMD_TDLS_MGMT: Send a TDLS management frame.
+ *
+ * @NL80211_CMD_UNEXPECTED_FRAME: Used by an application controlling an AP
+@@ -562,8 +567,24 @@
+ *
+ * @NL80211_CMD_CH_SWITCH_NOTIFY: An AP or GO may decide to switch channels
+ * independently of the userspace SME, send this event indicating
+- * %NL80211_ATTR_IFINDEX is now on %NL80211_ATTR_WIPHY_FREQ with
+- * %NL80211_ATTR_WIPHY_CHANNEL_TYPE.
++ * %NL80211_ATTR_IFINDEX is now on %NL80211_ATTR_WIPHY_FREQ and the
++ * attributes determining channel width.
++ *
++ * @NL80211_CMD_START_P2P_DEVICE: Start the given P2P Device, identified by
++ * its %NL80211_ATTR_WDEV identifier. It must have been created with
++ * %NL80211_CMD_NEW_INTERFACE previously. After it has been started, the
++ * P2P Device can be used for P2P operations, e.g. remain-on-channel and
++ * public action frame TX.
++ * @NL80211_CMD_STOP_P2P_DEVICE: Stop the given P2P Device, identified by
++ * its %NL80211_ATTR_WDEV identifier.
++ *
++ * @NL80211_CMD_CONN_FAILED: connection request to an AP failed; used to
++ * notify userspace that AP has rejected the connection request from a
++ * station, due to particular reason. %NL80211_ATTR_CONN_FAILED_REASON
++ * is used for this.
++ *
++ * @NL80211_CMD_SET_MCAST_RATE: Change the rate used to send multicast frames
++ * for IBSS or MESH vif.
+ *
+ * @NL80211_CMD_MAX: highest used command number
+ * @__NL80211_CMD_AFTER_LAST: internal use
+@@ -708,6 +729,13 @@ enum nl80211_commands {
+
+ NL80211_CMD_CH_SWITCH_NOTIFY,
+
++ NL80211_CMD_START_P2P_DEVICE,
++ NL80211_CMD_STOP_P2P_DEVICE,
++
++ NL80211_CMD_CONN_FAILED,
++
++ NL80211_CMD_SET_MCAST_RATE,
++
+ /* add new commands above here */
+
+ /* used to define NL80211_CMD_MAX below */
+@@ -744,14 +772,26 @@ enum nl80211_commands {
+ * /sys/class/ieee80211/<phyname>/index
+ * @NL80211_ATTR_WIPHY_NAME: wiphy name (used for renaming)
+ * @NL80211_ATTR_WIPHY_TXQ_PARAMS: a nested array of TX queue parameters
+- * @NL80211_ATTR_WIPHY_FREQ: frequency of the selected channel in MHz
++ * @NL80211_ATTR_WIPHY_FREQ: frequency of the selected channel in MHz,
++ * defines the channel together with the (deprecated)
++ * %NL80211_ATTR_WIPHY_CHANNEL_TYPE attribute or the attributes
++ * %NL80211_ATTR_CHANNEL_WIDTH and if needed %NL80211_ATTR_CENTER_FREQ1
++ * and %NL80211_ATTR_CENTER_FREQ2
++ * @NL80211_ATTR_CHANNEL_WIDTH: u32 attribute containing one of the values
++ * of &enum nl80211_chan_width, describing the channel width. See the
++ * documentation of the enum for more information.
++ * @NL80211_ATTR_CENTER_FREQ1: Center frequency of the first part of the
++ * channel, used for anything but 20 MHz bandwidth
++ * @NL80211_ATTR_CENTER_FREQ2: Center frequency of the second part of the
++ * channel, used only for 80+80 MHz bandwidth
+ * @NL80211_ATTR_WIPHY_CHANNEL_TYPE: included with NL80211_ATTR_WIPHY_FREQ
+- * if HT20 or HT40 are allowed (i.e., 802.11n disabled if not included):
++ * if HT20 or HT40 are to be used (i.e., HT disabled if not included):
+ * NL80211_CHAN_NO_HT = HT not allowed (i.e., same as not including
+ * this attribute)
+ * NL80211_CHAN_HT20 = HT20 only
+ * NL80211_CHAN_HT40MINUS = secondary channel is below the primary channel
+ * NL80211_CHAN_HT40PLUS = secondary channel is above the primary channel
++ * This attribute is now deprecated.
+ * @NL80211_ATTR_WIPHY_RETRY_SHORT: TX retry limit for frames whose length is
+ * less than or equal to the RTS threshold; allowed range: 1..255;
+ * dot11ShortRetryLimit; u8
+@@ -1251,6 +1291,25 @@ enum nl80211_commands {
+ * was used to provide the hint. For the different types of
+ * allowed user regulatory hints see nl80211_user_reg_hint_type.
+ *
++ * @NL80211_ATTR_CONN_FAILED_REASON: The reason for which AP has rejected
++ * the connection request from a station. nl80211_connect_failed_reason
++ * enum has different reasons of connection failure.
++ *
++ * @NL80211_ATTR_SAE_DATA: SAE elements in Authentication frames. This starts
++ * with the Authentication transaction sequence number field.
++ *
++ * @NL80211_ATTR_VHT_CAPABILITY: VHT Capability information element (from
++ * association request when used with NL80211_CMD_NEW_STATION)
++ *
++ * @NL80211_ATTR_SCAN_FLAGS: scan request control flags (u32)
++ *
++ * @NL80211_ATTR_P2P_CTWINDOW: P2P GO Client Traffic Window (u8), used with
++ * the START_AP and SET_BSS commands
++ * @NL80211_ATTR_P2P_OPPPS: P2P GO opportunistic PS (u8), used with the
++ * START_AP and SET_BSS commands. This can have the values 0 or 1;
++ * if not given in START_AP 0 is assumed, if not given in SET_BSS
++ * no change is made.
++ *
+ * @NL80211_ATTR_MAX: highest attribute number currently defined
+ * @__NL80211_ATTR_AFTER_LAST: internal use
+ */
+@@ -1506,6 +1565,23 @@ enum nl80211_attrs {
+
+ NL80211_ATTR_USER_REG_HINT_TYPE,
+
++ NL80211_ATTR_CONN_FAILED_REASON,
++
++ NL80211_ATTR_SAE_DATA,
++
++ NL80211_ATTR_VHT_CAPABILITY,
++
++ NL80211_ATTR_SCAN_FLAGS,
++
++ NL80211_ATTR_CHANNEL_WIDTH,
++ NL80211_ATTR_CENTER_FREQ1,
++ NL80211_ATTR_CENTER_FREQ2,
++
++ NL80211_ATTR_P2P_CTWINDOW,
++ NL80211_ATTR_P2P_OPPPS,
++
++ NL80211_ATTR_WIPHY_ANTENNA_GAIN,
++
+ /* add attributes here, update the policy in nl80211.c */
+
+ __NL80211_ATTR_AFTER_LAST,
+@@ -1549,6 +1625,7 @@ enum nl80211_attrs {
+ #define NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY 16
+ #define NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY 24
+ #define NL80211_HT_CAPABILITY_LEN 26
++#define NL80211_VHT_CAPABILITY_LEN 12
+
+ #define NL80211_MAX_NR_CIPHER_SUITES 5
+ #define NL80211_MAX_NR_AKM_SUITES 2
+@@ -1575,6 +1652,10 @@ enum nl80211_attrs {
+ * @NL80211_IFTYPE_MESH_POINT: mesh point
+ * @NL80211_IFTYPE_P2P_CLIENT: P2P client
+ * @NL80211_IFTYPE_P2P_GO: P2P group owner
++ * @NL80211_IFTYPE_P2P_DEVICE: P2P device interface type, this is not a netdev
++ * and therefore can't be created in the normal ways, use the
++ * %NL80211_CMD_START_P2P_DEVICE and %NL80211_CMD_STOP_P2P_DEVICE
++ * commands to create and destroy one
+ * @NL80211_IFTYPE_MAX: highest interface type number currently defined
+ * @NUM_NL80211_IFTYPES: number of defined interface types
+ *
+@@ -1593,6 +1674,7 @@ enum nl80211_iftype {
+ NL80211_IFTYPE_MESH_POINT,
+ NL80211_IFTYPE_P2P_CLIENT,
+ NL80211_IFTYPE_P2P_GO,
++ NL80211_IFTYPE_P2P_DEVICE,
+
+ /* keep last */
+ NUM_NL80211_IFTYPES,
+@@ -1664,10 +1746,15 @@ struct nl80211_sta_flag_update {
+ * @__NL80211_RATE_INFO_INVALID: attribute number 0 is reserved
+ * @NL80211_RATE_INFO_BITRATE: total bitrate (u16, 100kbit/s)
+ * @NL80211_RATE_INFO_MCS: mcs index for 802.11n (u8)
+- * @NL80211_RATE_INFO_40_MHZ_WIDTH: 40 Mhz dualchannel bitrate
++ * @NL80211_RATE_INFO_40_MHZ_WIDTH: 40 MHz dualchannel bitrate
+ * @NL80211_RATE_INFO_SHORT_GI: 400ns guard interval
+ * @NL80211_RATE_INFO_BITRATE32: total bitrate (u32, 100kbit/s)
+ * @NL80211_RATE_INFO_MAX: highest rate_info number currently defined
++ * @NL80211_RATE_INFO_VHT_MCS: MCS index for VHT (u8)
++ * @NL80211_RATE_INFO_VHT_NSS: number of streams in VHT (u8)
++ * @NL80211_RATE_INFO_80_MHZ_WIDTH: 80 MHz VHT rate
++ * @NL80211_RATE_INFO_80P80_MHZ_WIDTH: 80+80 MHz VHT rate
++ * @NL80211_RATE_INFO_160_MHZ_WIDTH: 160 MHz VHT rate
+ * @__NL80211_RATE_INFO_AFTER_LAST: internal use
+ */
+ enum nl80211_rate_info {
+@@ -1677,6 +1764,11 @@ enum nl80211_rate_info {
+ NL80211_RATE_INFO_40_MHZ_WIDTH,
+ NL80211_RATE_INFO_SHORT_GI,
+ NL80211_RATE_INFO_BITRATE32,
++ NL80211_RATE_INFO_VHT_MCS,
++ NL80211_RATE_INFO_VHT_NSS,
++ NL80211_RATE_INFO_80_MHZ_WIDTH,
++ NL80211_RATE_INFO_80P80_MHZ_WIDTH,
++ NL80211_RATE_INFO_160_MHZ_WIDTH,
+
+ /* keep last */
+ __NL80211_RATE_INFO_AFTER_LAST,
+@@ -1744,6 +1836,8 @@ enum nl80211_sta_bss_param {
+ * @NL80211_STA_INFO_STA_FLAGS: Contains a struct nl80211_sta_flag_update.
+ * @NL80211_STA_INFO_BEACON_LOSS: count of times beacon loss was detected (u32)
+ * @NL80211_STA_INFO_T_OFFSET: timing offset with respect to this STA (s64)
++ * @NL80211_STA_INFO_CHAIN_SIGNAL: per-chain signal strength of last PPDU
++ * @NL80211_STA_INFO_CHAIN_SIGNAL_AVG: per-chain signal strength average
+ * @__NL80211_STA_INFO_AFTER_LAST: internal
+ * @NL80211_STA_INFO_MAX: highest possible station info attribute
+ */
+@@ -1768,6 +1862,8 @@ enum nl80211_sta_info {
+ NL80211_STA_INFO_STA_FLAGS,
+ NL80211_STA_INFO_BEACON_LOSS,
+ NL80211_STA_INFO_T_OFFSET,
++ NL80211_STA_INFO_CHAIN_SIGNAL,
++ NL80211_STA_INFO_CHAIN_SIGNAL_AVG,
+
+ /* keep last */
+ __NL80211_STA_INFO_AFTER_LAST,
+@@ -2385,6 +2481,15 @@ enum nl80211_ac {
+ #define NL80211_TXQ_Q_BE NL80211_AC_BE
+ #define NL80211_TXQ_Q_BK NL80211_AC_BK
+
++/**
++ * enum nl80211_channel_type - channel type
++ * @NL80211_CHAN_NO_HT: 20 MHz, non-HT channel
++ * @NL80211_CHAN_HT20: 20 MHz HT channel
++ * @NL80211_CHAN_HT40MINUS: HT40 channel, secondary channel
++ * below the control channel
++ * @NL80211_CHAN_HT40PLUS: HT40 channel, secondary channel
++ * above the control channel
++ */
+ enum nl80211_channel_type {
+ NL80211_CHAN_NO_HT,
+ NL80211_CHAN_HT20,
+@@ -2393,6 +2498,32 @@ enum nl80211_channel_type {
+ };
+
+ /**
++ * enum nl80211_chan_width - channel width definitions
++ *
++ * These values are used with the %NL80211_ATTR_CHANNEL_WIDTH
++ * attribute.
++ *
++ * @NL80211_CHAN_WIDTH_20_NOHT: 20 MHz, non-HT channel
++ * @NL80211_CHAN_WIDTH_20: 20 MHz HT channel
++ * @NL80211_CHAN_WIDTH_40: 40 MHz channel, the %NL80211_ATTR_CENTER_FREQ1
++ * attribute must be provided as well
++ * @NL80211_CHAN_WIDTH_80: 80 MHz channel, the %NL80211_ATTR_CENTER_FREQ1
++ * attribute must be provided as well
++ * @NL80211_CHAN_WIDTH_80P80: 80+80 MHz channel, the %NL80211_ATTR_CENTER_FREQ1
++ * and %NL80211_ATTR_CENTER_FREQ2 attributes must be provided as well
++ * @NL80211_CHAN_WIDTH_160: 160 MHz channel, the %NL80211_ATTR_CENTER_FREQ1
++ * attribute must be provided as well
++ */
++enum nl80211_chan_width {
++ NL80211_CHAN_WIDTH_20_NOHT,
++ NL80211_CHAN_WIDTH_20,
++ NL80211_CHAN_WIDTH_40,
++ NL80211_CHAN_WIDTH_80,
++ NL80211_CHAN_WIDTH_80P80,
++ NL80211_CHAN_WIDTH_160,
++};
++
++/**
+ * enum nl80211_bss - netlink attributes for a BSS
+ *
+ * @__NL80211_BSS_INVALID: invalid
+@@ -2460,6 +2591,7 @@ enum nl80211_bss_status {
+ * @NL80211_AUTHTYPE_SHARED_KEY: Shared Key authentication (WEP only)
+ * @NL80211_AUTHTYPE_FT: Fast BSS Transition (IEEE 802.11r)
+ * @NL80211_AUTHTYPE_NETWORK_EAP: Network EAP (some Cisco APs and mainly LEAP)
++ * @NL80211_AUTHTYPE_SAE: Simultaneous authentication of equals
+ * @__NL80211_AUTHTYPE_NUM: internal
+ * @NL80211_AUTHTYPE_MAX: maximum valid auth algorithm
+ * @NL80211_AUTHTYPE_AUTOMATIC: determine automatically (if necessary by
+@@ -2471,6 +2603,7 @@ enum nl80211_auth_type {
+ NL80211_AUTHTYPE_SHARED_KEY,
+ NL80211_AUTHTYPE_FT,
+ NL80211_AUTHTYPE_NETWORK_EAP,
++ NL80211_AUTHTYPE_SAE,
+
+ /* keep last */
+ __NL80211_AUTHTYPE_NUM,
+@@ -2994,12 +3127,40 @@ enum nl80211_ap_sme_features {
+ * @NL80211_FEATURE_CELL_BASE_REG_HINTS: This driver has been tested
+ * to work properly to suppport receiving regulatory hints from
+ * cellular base stations.
++ * @NL80211_FEATURE_P2P_DEVICE_NEEDS_CHANNEL: If this is set, an active
++ * P2P Device (%NL80211_IFTYPE_P2P_DEVICE) requires its own channel
++ * in the interface combinations, even when it's only used for scan
++ * and remain-on-channel. This could be due to, for example, the
++ * remain-on-channel implementation requiring a channel context.
++ * @NL80211_FEATURE_SAE: This driver supports simultaneous authentication of
++ * equals (SAE) with user space SME (NL80211_CMD_AUTHENTICATE) in station
++ * mode
++ * @NL80211_FEATURE_LOW_PRIORITY_SCAN: This driver supports low priority scan
++ * @NL80211_FEATURE_SCAN_FLUSH: Scan flush is supported
++ * @NL80211_FEATURE_AP_SCAN: Support scanning using an AP vif
++ * @NL80211_FEATURE_VIF_TXPOWER: The driver supports per-vif TX power setting
++ * @NL80211_FEATURE_NEED_OBSS_SCAN: The driver expects userspace to perform
++ * OBSS scans and generate 20/40 BSS coex reports. This flag is used only
++ * for drivers implementing the CONNECT API, for AUTH/ASSOC it is implied.
++ * @NL80211_FEATURE_P2P_GO_CTWIN: P2P GO implementation supports CT Window
++ * setting
++ * @NL80211_FEATURE_P2P_GO_OPPPS: P2P GO implementation supports opportunistic
++ * powersave
+ */
+ enum nl80211_feature_flags {
+- NL80211_FEATURE_SK_TX_STATUS = 1 << 0,
+- NL80211_FEATURE_HT_IBSS = 1 << 1,
+- NL80211_FEATURE_INACTIVITY_TIMER = 1 << 2,
+- NL80211_FEATURE_CELL_BASE_REG_HINTS = 1 << 3,
++ NL80211_FEATURE_SK_TX_STATUS = 1 << 0,
++ NL80211_FEATURE_HT_IBSS = 1 << 1,
++ NL80211_FEATURE_INACTIVITY_TIMER = 1 << 2,
++ NL80211_FEATURE_CELL_BASE_REG_HINTS = 1 << 3,
++ NL80211_FEATURE_P2P_DEVICE_NEEDS_CHANNEL = 1 << 4,
++ NL80211_FEATURE_SAE = 1 << 5,
++ NL80211_FEATURE_LOW_PRIORITY_SCAN = 1 << 6,
++ NL80211_FEATURE_SCAN_FLUSH = 1 << 7,
++ NL80211_FEATURE_AP_SCAN = 1 << 8,
++ NL80211_FEATURE_VIF_TXPOWER = 1 << 9,
++ NL80211_FEATURE_NEED_OBSS_SCAN = 1 << 10,
++ NL80211_FEATURE_P2P_GO_CTWIN = 1 << 11,
++ NL80211_FEATURE_P2P_GO_OPPPS = 1 << 12,
+ };
+
+ /**
+@@ -3023,4 +3184,36 @@ enum nl80211_probe_resp_offload_support_
+ NL80211_PROBE_RESP_OFFLOAD_SUPPORT_80211U = 1<<3,
+ };
+
++/**
++ * enum nl80211_connect_failed_reason - connection request failed reasons
++ * @NL80211_CONN_FAIL_MAX_CLIENTS: Maximum number of clients that can be
++ * handled by the AP is reached.
++ * @NL80211_CONN_FAIL_BLOCKED_CLIENT: Client's MAC is in the AP's blocklist.
++ */
++enum nl80211_connect_failed_reason {
++ NL80211_CONN_FAIL_MAX_CLIENTS,
++ NL80211_CONN_FAIL_BLOCKED_CLIENT,
++};
++
++/**
++ * enum nl80211_scan_flags - scan request control flags
++ *
++ * Scan request control flags are used to control the handling
++ * of NL80211_CMD_TRIGGER_SCAN and NL80211_CMD_START_SCHED_SCAN
++ * requests.
++ *
++ * @NL80211_SCAN_FLAG_LOW_PRIORITY: scan request has low priority
++ * @NL80211_SCAN_FLAG_FLUSH: flush cache before scanning
++ * @NL80211_SCAN_FLAG_AP: force a scan even if the interface is configured
++ * as AP and the beaconing has already been configured. This attribute is
++ * dangerous because will destroy stations performance as a lot of frames
++ * will be lost while scanning off-channel, therefore it must be used only
++ * when really needed
++ */
++enum nl80211_scan_flags {
++ NL80211_SCAN_FLAG_LOW_PRIORITY = 1<<0,
++ NL80211_SCAN_FLAG_FLUSH = 1<<1,
++ NL80211_SCAN_FLAG_AP = 1<<2,
++};
++
+ #endif /* __LINUX_NL80211_H */
diff --git a/package/network/utils/iw/patches/.svn/text-base/100-rx_rate.patch.svn-base b/package/network/utils/iw/patches/.svn/text-base/100-rx_rate.patch.svn-base
new file mode 100644
index 0000000..642b9f3
--- /dev/null
+++ b/package/network/utils/iw/patches/.svn/text-base/100-rx_rate.patch.svn-base
@@ -0,0 +1,105 @@
+--- a/station.c
++++ b/station.c
+@@ -29,13 +29,47 @@ enum plink_actions {
+ PLINK_ACTION_BLOCK,
+ };
+
++static void print_sta_bitrate(struct nlattr *nla, const char *name)
++{
++ struct nlattr *rinfo[NL80211_RATE_INFO_MAX + 1];
++
++ static struct nla_policy rate_policy[NL80211_RATE_INFO_MAX + 1] = {
++ [NL80211_RATE_INFO_BITRATE] = { .type = NLA_U16 },
++ [NL80211_RATE_INFO_BITRATE32] = { .type = NLA_U32 },
++ [NL80211_RATE_INFO_MCS] = { .type = NLA_U8 },
++ [NL80211_RATE_INFO_40_MHZ_WIDTH] = { .type = NLA_FLAG },
++ [NL80211_RATE_INFO_SHORT_GI] = { .type = NLA_FLAG },
++ };
++
++ if (!nla)
++ return;
++
++ if (nla_parse_nested(rinfo, NL80211_RATE_INFO_MAX, nla, rate_policy)) {
++ fprintf(stderr, "failed to parse nested rate attributes!\n");
++ } else {
++ int rate = 0;
++ printf("\n\t%s:\t", name);
++ if (rinfo[NL80211_RATE_INFO_BITRATE32])
++ rate = nla_get_u32(rinfo[NL80211_RATE_INFO_BITRATE32]);
++ else if (rinfo[NL80211_RATE_INFO_BITRATE])
++ rate = nla_get_u16(rinfo[NL80211_RATE_INFO_BITRATE]);
++ if (rate > 0)
++ printf("%d.%d MBit/s", rate / 10, rate % 10);
++
++ if (rinfo[NL80211_RATE_INFO_MCS])
++ printf(" MCS %d", nla_get_u8(rinfo[NL80211_RATE_INFO_MCS]));
++ if (rinfo[NL80211_RATE_INFO_40_MHZ_WIDTH])
++ printf(" 40Mhz");
++ if (rinfo[NL80211_RATE_INFO_SHORT_GI])
++ printf(" short GI");
++ }
++}
+
+ static int print_sta_handler(struct nl_msg *msg, void *arg)
+ {
+ struct nlattr *tb[NL80211_ATTR_MAX + 1];
+ struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
+ struct nlattr *sinfo[NL80211_STA_INFO_MAX + 1];
+- struct nlattr *rinfo[NL80211_RATE_INFO_MAX + 1];
+ char mac_addr[20], state_name[10], dev[20];
+ struct nl80211_sta_flag_update *sta_flags;
+ static struct nla_policy stats_policy[NL80211_STA_INFO_MAX + 1] = {
+@@ -47,6 +81,7 @@ static int print_sta_handler(struct nl_m
+ [NL80211_STA_INFO_SIGNAL] = { .type = NLA_U8 },
+ [NL80211_STA_INFO_T_OFFSET] = { .type = NLA_U64 },
+ [NL80211_STA_INFO_TX_BITRATE] = { .type = NLA_NESTED },
++ [NL80211_STA_INFO_RX_BITRATE] = { .type = NLA_NESTED },
+ [NL80211_STA_INFO_LLID] = { .type = NLA_U16 },
+ [NL80211_STA_INFO_PLID] = { .type = NLA_U16 },
+ [NL80211_STA_INFO_PLINK_STATE] = { .type = NLA_U8 },
+@@ -56,14 +91,6 @@ static int print_sta_handler(struct nl_m
+ { .minlen = sizeof(struct nl80211_sta_flag_update) },
+ };
+
+- static struct nla_policy rate_policy[NL80211_RATE_INFO_MAX + 1] = {
+- [NL80211_RATE_INFO_BITRATE] = { .type = NLA_U16 },
+- [NL80211_RATE_INFO_BITRATE32] = { .type = NLA_U32 },
+- [NL80211_RATE_INFO_MCS] = { .type = NLA_U8 },
+- [NL80211_RATE_INFO_40_MHZ_WIDTH] = { .type = NLA_FLAG },
+- [NL80211_RATE_INFO_SHORT_GI] = { .type = NLA_FLAG },
+- };
+-
+ nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
+ genlmsg_attrlen(gnlh, 0), NULL);
+
+@@ -119,28 +146,8 @@ static int print_sta_handler(struct nl_m
+ printf("\n\tToffset:\t%lld us",
+ (unsigned long long)nla_get_u64(sinfo[NL80211_STA_INFO_T_OFFSET]));
+
+- if (sinfo[NL80211_STA_INFO_TX_BITRATE]) {
+- if (nla_parse_nested(rinfo, NL80211_RATE_INFO_MAX,
+- sinfo[NL80211_STA_INFO_TX_BITRATE], rate_policy)) {
+- fprintf(stderr, "failed to parse nested rate attributes!\n");
+- } else {
+- int rate = 0;
+- printf("\n\ttx bitrate:\t");
+- if (rinfo[NL80211_RATE_INFO_BITRATE32])
+- rate = nla_get_u32(rinfo[NL80211_RATE_INFO_BITRATE32]);
+- else if (rinfo[NL80211_RATE_INFO_BITRATE])
+- rate = nla_get_u16(rinfo[NL80211_RATE_INFO_BITRATE]);
+- if (rate > 0)
+- printf("%d.%d MBit/s", rate / 10, rate % 10);
+-
+- if (rinfo[NL80211_RATE_INFO_MCS])
+- printf(" MCS %d", nla_get_u8(rinfo[NL80211_RATE_INFO_MCS]));
+- if (rinfo[NL80211_RATE_INFO_40_MHZ_WIDTH])
+- printf(" 40Mhz");
+- if (rinfo[NL80211_RATE_INFO_SHORT_GI])
+- printf(" short GI");
+- }
+- }
++ print_sta_bitrate(sinfo[NL80211_STA_INFO_TX_BITRATE], "tx bitrate");
++ print_sta_bitrate(sinfo[NL80211_STA_INFO_RX_BITRATE], "rx bitrate");
+
+ if (sinfo[NL80211_STA_INFO_LLID])
+ printf("\n\tmesh llid:\t%d",
diff --git a/package/network/utils/iw/patches/.svn/text-base/110-per_chain_signal_strength.patch.svn-base b/package/network/utils/iw/patches/.svn/text-base/110-per_chain_signal_strength.patch.svn-base
new file mode 100644
index 0000000..813a7d9
--- /dev/null
+++ b/package/network/utils/iw/patches/.svn/text-base/110-per_chain_signal_strength.patch.svn-base
@@ -0,0 +1,71 @@
+--- a/station.c
++++ b/station.c
+@@ -65,6 +65,33 @@ static void print_sta_bitrate(struct nla
+ }
+ }
+
++static char *get_chain_signal(struct nlattr *attr_list)
++{
++ struct nlattr *attr;
++ static char buf[64];
++ char *cur = buf;
++ int i = 0, rem;
++ const char *prefix;
++
++ if (!attr_list)
++ return "";
++
++ nla_for_each_nested(attr, attr_list, rem) {
++ if (i++ > 0)
++ prefix = ", ";
++ else
++ prefix = "[";
++
++ cur += snprintf(cur, sizeof(buf) - (cur - buf), "%s%d", prefix,
++ (int8_t) nla_get_u8(attr));
++ }
++
++ if (i)
++ snprintf(cur, sizeof(buf) - (cur - buf), "] ");
++
++ return buf;
++}
++
+ static int print_sta_handler(struct nl_msg *msg, void *arg)
+ {
+ struct nlattr *tb[NL80211_ATTR_MAX + 1];
+@@ -89,7 +116,10 @@ static int print_sta_handler(struct nl_m
+ [NL80211_STA_INFO_TX_FAILED] = { .type = NLA_U32 },
+ [NL80211_STA_INFO_STA_FLAGS] =
+ { .minlen = sizeof(struct nl80211_sta_flag_update) },
++ [NL80211_STA_INFO_CHAIN_SIGNAL] = { .type = NLA_NESTED },
++ [NL80211_STA_INFO_CHAIN_SIGNAL_AVG] = { .type = NLA_NESTED },
+ };
++ char *chain;
+
+ nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
+ genlmsg_attrlen(gnlh, 0), NULL);
+@@ -136,12 +166,19 @@ static int print_sta_handler(struct nl_m
+ if (sinfo[NL80211_STA_INFO_TX_FAILED])
+ printf("\n\ttx failed:\t%u",
+ nla_get_u32(sinfo[NL80211_STA_INFO_TX_FAILED]));
++
++ chain = get_chain_signal(sinfo[NL80211_STA_INFO_CHAIN_SIGNAL]);
+ if (sinfo[NL80211_STA_INFO_SIGNAL])
+- printf("\n\tsignal: \t%d dBm",
+- (int8_t)nla_get_u8(sinfo[NL80211_STA_INFO_SIGNAL]));
++ printf("\n\tsignal: \t%d %sdBm",
++ (int8_t)nla_get_u8(sinfo[NL80211_STA_INFO_SIGNAL]),
++ chain);
++
++ chain = get_chain_signal(sinfo[NL80211_STA_INFO_CHAIN_SIGNAL_AVG]);
+ if (sinfo[NL80211_STA_INFO_SIGNAL_AVG])
+- printf("\n\tsignal avg:\t%d dBm",
+- (int8_t)nla_get_u8(sinfo[NL80211_STA_INFO_SIGNAL_AVG]));
++ printf("\n\tsignal avg:\t%d %sdBm",
++ (int8_t)nla_get_u8(sinfo[NL80211_STA_INFO_SIGNAL_AVG]),
++ chain);
++
+ if (sinfo[NL80211_STA_INFO_T_OFFSET])
+ printf("\n\tToffset:\t%lld us",
+ (unsigned long long)nla_get_u64(sinfo[NL80211_STA_INFO_T_OFFSET]));
diff --git a/package/network/utils/iw/patches/.svn/text-base/120-tdls_peer_indentation.patch.svn-base b/package/network/utils/iw/patches/.svn/text-base/120-tdls_peer_indentation.patch.svn-base
new file mode 100644
index 0000000..6836873
--- /dev/null
+++ b/package/network/utils/iw/patches/.svn/text-base/120-tdls_peer_indentation.patch.svn-base
@@ -0,0 +1,11 @@
+--- a/station.c
++++ b/station.c
+@@ -267,7 +267,7 @@ static int print_sta_handler(struct nl_m
+ }
+
+ if (sta_flags->mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
+- printf("\n\tTDLS peer:\t\t");
++ printf("\n\tTDLS peer:\t");
+ if (sta_flags->set & BIT(NL80211_STA_FLAG_TDLS_PEER))
+ printf("yes");
+ else
diff --git a/package/network/utils/iw/patches/.svn/text-base/130-antenna_gain.patch.svn-base b/package/network/utils/iw/patches/.svn/text-base/130-antenna_gain.patch.svn-base
new file mode 100644
index 0000000..f3ca691
--- /dev/null
+++ b/package/network/utils/iw/patches/.svn/text-base/130-antenna_gain.patch.svn-base
@@ -0,0 +1,34 @@
+--- a/phy.c
++++ b/phy.c
+@@ -359,3 +359,31 @@ COMMAND(set, antenna, "<bitmap> | all |
+ NL80211_CMD_SET_WIPHY, 0, CIB_PHY, handle_antenna,
+ "Set a bitmap of allowed antennas to use for TX and RX.\n"
+ "The driver may reject antenna configurations it cannot support.");
++
++static int handle_antenna_gain(struct nl80211_state *state,
++ struct nl_cb *cb,
++ struct nl_msg *msg,
++ int argc, char **argv,
++ enum id_input id)
++{
++ char *endptr;
++ int dbm;
++
++ /* get the required args */
++ if (argc != 1)
++ return 1;
++
++ dbm = strtol(argv[0], &endptr, 10);
++ if (*endptr)
++ return 2;
++
++ NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_ANTENNA_GAIN, dbm);
++
++ return 0;
++
++ nla_put_failure:
++ return -ENOBUFS;
++}
++COMMAND(set, antenna_gain, "<antenna gain in dBm>",
++ NL80211_CMD_SET_WIPHY, 0, CIB_PHY, handle_antenna_gain,
++ "Specify antenna gain.");
diff --git a/package/network/utils/iw/patches/001-nl80211_h_sync.patch b/package/network/utils/iw/patches/001-nl80211_h_sync.patch
new file mode 100644
index 0000000..fc28a65
--- /dev/null
+++ b/package/network/utils/iw/patches/001-nl80211_h_sync.patch
@@ -0,0 +1,416 @@
+--- a/nl80211.h
++++ b/nl80211.h
+@@ -118,8 +118,9 @@
+ * to get a list of all present wiphys.
+ * @NL80211_CMD_SET_WIPHY: set wiphy parameters, needs %NL80211_ATTR_WIPHY or
+ * %NL80211_ATTR_IFINDEX; can be used to set %NL80211_ATTR_WIPHY_NAME,
+- * %NL80211_ATTR_WIPHY_TXQ_PARAMS, %NL80211_ATTR_WIPHY_FREQ,
+- * %NL80211_ATTR_WIPHY_CHANNEL_TYPE, %NL80211_ATTR_WIPHY_RETRY_SHORT,
++ * %NL80211_ATTR_WIPHY_TXQ_PARAMS, %NL80211_ATTR_WIPHY_FREQ (and the
++ * attributes determining the channel width; this is used for setting
++ * monitor mode channel), %NL80211_ATTR_WIPHY_RETRY_SHORT,
+ * %NL80211_ATTR_WIPHY_RETRY_LONG, %NL80211_ATTR_WIPHY_FRAG_THRESHOLD,
+ * and/or %NL80211_ATTR_WIPHY_RTS_THRESHOLD.
+ * However, for setting the channel, see %NL80211_CMD_SET_CHANNEL
+@@ -171,7 +172,7 @@
+ * %NL80211_ATTR_AKM_SUITES, %NL80211_ATTR_PRIVACY,
+ * %NL80211_ATTR_AUTH_TYPE and %NL80211_ATTR_INACTIVITY_TIMEOUT.
+ * The channel to use can be set on the interface or be given using the
+- * %NL80211_ATTR_WIPHY_FREQ and %NL80211_ATTR_WIPHY_CHANNEL_TYPE attrs.
++ * %NL80211_ATTR_WIPHY_FREQ and the attributes determining channel width.
+ * @NL80211_CMD_NEW_BEACON: old alias for %NL80211_CMD_START_AP
+ * @NL80211_CMD_STOP_AP: Stop AP operation on the given interface
+ * @NL80211_CMD_DEL_BEACON: old alias for %NL80211_CMD_STOP_AP
+@@ -401,8 +402,7 @@
+ * a response while being associated to an AP on another channel.
+ * %NL80211_ATTR_IFINDEX is used to specify which interface (and thus
+ * radio) is used. %NL80211_ATTR_WIPHY_FREQ is used to specify the
+- * frequency for the operation and %NL80211_ATTR_WIPHY_CHANNEL_TYPE may be
+- * optionally used to specify additional channel parameters.
++ * frequency for the operation.
+ * %NL80211_ATTR_DURATION is used to specify the duration in milliseconds
+ * to remain on the channel. This command is also used as an event to
+ * notify when the requested duration starts (it may take a while for the
+@@ -440,12 +440,11 @@
+ * as an event indicating reception of a frame that was not processed in
+ * kernel code, but is for us (i.e., which may need to be processed in a
+ * user space application). %NL80211_ATTR_FRAME is used to specify the
+- * frame contents (including header). %NL80211_ATTR_WIPHY_FREQ (and
+- * optionally %NL80211_ATTR_WIPHY_CHANNEL_TYPE) is used to indicate on
+- * which channel the frame is to be transmitted or was received. If this
+- * channel is not the current channel (remain-on-channel or the
+- * operational channel) the device will switch to the given channel and
+- * transmit the frame, optionally waiting for a response for the time
++ * frame contents (including header). %NL80211_ATTR_WIPHY_FREQ is used
++ * to indicate on which channel the frame is to be transmitted or was
++ * received. If this channel is not the current channel (remain-on-channel
++ * or the operational channel) the device will switch to the given channel
++ * and transmit the frame, optionally waiting for a response for the time
+ * specified using %NL80211_ATTR_DURATION. When called, this operation
+ * returns a cookie (%NL80211_ATTR_COOKIE) that will be included with the
+ * TX status event pertaining to the TX request.
+@@ -473,8 +472,8 @@
+ * command is used as an event to indicate the that a trigger level was
+ * reached.
+ * @NL80211_CMD_SET_CHANNEL: Set the channel (using %NL80211_ATTR_WIPHY_FREQ
+- * and %NL80211_ATTR_WIPHY_CHANNEL_TYPE) the given interface (identifed
+- * by %NL80211_ATTR_IFINDEX) shall operate on.
++ * and the attributes determining channel width) the given interface
++ * (identifed by %NL80211_ATTR_IFINDEX) shall operate on.
+ * In case multiple channels are supported by the device, the mechanism
+ * with which it switches channels is implementation-defined.
+ * When a monitor interface is given, it can only switch channel while
+@@ -526,6 +525,12 @@
+ * of PMKSA caching dandidates.
+ *
+ * @NL80211_CMD_TDLS_OPER: Perform a high-level TDLS command (e.g. link setup).
++ * In addition, this can be used as an event to request userspace to take
++ * actions on TDLS links (set up a new link or tear down an existing one).
++ * In such events, %NL80211_ATTR_TDLS_OPERATION indicates the requested
++ * operation, %NL80211_ATTR_MAC contains the peer MAC address, and
++ * %NL80211_ATTR_REASON_CODE the reason code to be used (only with
++ * %NL80211_TDLS_TEARDOWN).
+ * @NL80211_CMD_TDLS_MGMT: Send a TDLS management frame.
+ *
+ * @NL80211_CMD_UNEXPECTED_FRAME: Used by an application controlling an AP
+@@ -562,8 +567,24 @@
+ *
+ * @NL80211_CMD_CH_SWITCH_NOTIFY: An AP or GO may decide to switch channels
+ * independently of the userspace SME, send this event indicating
+- * %NL80211_ATTR_IFINDEX is now on %NL80211_ATTR_WIPHY_FREQ with
+- * %NL80211_ATTR_WIPHY_CHANNEL_TYPE.
++ * %NL80211_ATTR_IFINDEX is now on %NL80211_ATTR_WIPHY_FREQ and the
++ * attributes determining channel width.
++ *
++ * @NL80211_CMD_START_P2P_DEVICE: Start the given P2P Device, identified by
++ * its %NL80211_ATTR_WDEV identifier. It must have been created with
++ * %NL80211_CMD_NEW_INTERFACE previously. After it has been started, the
++ * P2P Device can be used for P2P operations, e.g. remain-on-channel and
++ * public action frame TX.
++ * @NL80211_CMD_STOP_P2P_DEVICE: Stop the given P2P Device, identified by
++ * its %NL80211_ATTR_WDEV identifier.
++ *
++ * @NL80211_CMD_CONN_FAILED: connection request to an AP failed; used to
++ * notify userspace that AP has rejected the connection request from a
++ * station, due to particular reason. %NL80211_ATTR_CONN_FAILED_REASON
++ * is used for this.
++ *
++ * @NL80211_CMD_SET_MCAST_RATE: Change the rate used to send multicast frames
++ * for IBSS or MESH vif.
+ *
+ * @NL80211_CMD_MAX: highest used command number
+ * @__NL80211_CMD_AFTER_LAST: internal use
+@@ -708,6 +729,13 @@ enum nl80211_commands {
+
+ NL80211_CMD_CH_SWITCH_NOTIFY,
+
++ NL80211_CMD_START_P2P_DEVICE,
++ NL80211_CMD_STOP_P2P_DEVICE,
++
++ NL80211_CMD_CONN_FAILED,
++
++ NL80211_CMD_SET_MCAST_RATE,
++
+ /* add new commands above here */
+
+ /* used to define NL80211_CMD_MAX below */
+@@ -744,14 +772,26 @@ enum nl80211_commands {
+ * /sys/class/ieee80211/<phyname>/index
+ * @NL80211_ATTR_WIPHY_NAME: wiphy name (used for renaming)
+ * @NL80211_ATTR_WIPHY_TXQ_PARAMS: a nested array of TX queue parameters
+- * @NL80211_ATTR_WIPHY_FREQ: frequency of the selected channel in MHz
++ * @NL80211_ATTR_WIPHY_FREQ: frequency of the selected channel in MHz,
++ * defines the channel together with the (deprecated)
++ * %NL80211_ATTR_WIPHY_CHANNEL_TYPE attribute or the attributes
++ * %NL80211_ATTR_CHANNEL_WIDTH and if needed %NL80211_ATTR_CENTER_FREQ1
++ * and %NL80211_ATTR_CENTER_FREQ2
++ * @NL80211_ATTR_CHANNEL_WIDTH: u32 attribute containing one of the values
++ * of &enum nl80211_chan_width, describing the channel width. See the
++ * documentation of the enum for more information.
++ * @NL80211_ATTR_CENTER_FREQ1: Center frequency of the first part of the
++ * channel, used for anything but 20 MHz bandwidth
++ * @NL80211_ATTR_CENTER_FREQ2: Center frequency of the second part of the
++ * channel, used only for 80+80 MHz bandwidth
+ * @NL80211_ATTR_WIPHY_CHANNEL_TYPE: included with NL80211_ATTR_WIPHY_FREQ
+- * if HT20 or HT40 are allowed (i.e., 802.11n disabled if not included):
++ * if HT20 or HT40 are to be used (i.e., HT disabled if not included):
+ * NL80211_CHAN_NO_HT = HT not allowed (i.e., same as not including
+ * this attribute)
+ * NL80211_CHAN_HT20 = HT20 only
+ * NL80211_CHAN_HT40MINUS = secondary channel is below the primary channel
+ * NL80211_CHAN_HT40PLUS = secondary channel is above the primary channel
++ * This attribute is now deprecated.
+ * @NL80211_ATTR_WIPHY_RETRY_SHORT: TX retry limit for frames whose length is
+ * less than or equal to the RTS threshold; allowed range: 1..255;
+ * dot11ShortRetryLimit; u8
+@@ -1251,6 +1291,25 @@ enum nl80211_commands {
+ * was used to provide the hint. For the different types of
+ * allowed user regulatory hints see nl80211_user_reg_hint_type.
+ *
++ * @NL80211_ATTR_CONN_FAILED_REASON: The reason for which AP has rejected
++ * the connection request from a station. nl80211_connect_failed_reason
++ * enum has different reasons of connection failure.
++ *
++ * @NL80211_ATTR_SAE_DATA: SAE elements in Authentication frames. This starts
++ * with the Authentication transaction sequence number field.
++ *
++ * @NL80211_ATTR_VHT_CAPABILITY: VHT Capability information element (from
++ * association request when used with NL80211_CMD_NEW_STATION)
++ *
++ * @NL80211_ATTR_SCAN_FLAGS: scan request control flags (u32)
++ *
++ * @NL80211_ATTR_P2P_CTWINDOW: P2P GO Client Traffic Window (u8), used with
++ * the START_AP and SET_BSS commands
++ * @NL80211_ATTR_P2P_OPPPS: P2P GO opportunistic PS (u8), used with the
++ * START_AP and SET_BSS commands. This can have the values 0 or 1;
++ * if not given in START_AP 0 is assumed, if not given in SET_BSS
++ * no change is made.
++ *
+ * @NL80211_ATTR_MAX: highest attribute number currently defined
+ * @__NL80211_ATTR_AFTER_LAST: internal use
+ */
+@@ -1506,6 +1565,23 @@ enum nl80211_attrs {
+
+ NL80211_ATTR_USER_REG_HINT_TYPE,
+
++ NL80211_ATTR_CONN_FAILED_REASON,
++
++ NL80211_ATTR_SAE_DATA,
++
++ NL80211_ATTR_VHT_CAPABILITY,
++
++ NL80211_ATTR_SCAN_FLAGS,
++
++ NL80211_ATTR_CHANNEL_WIDTH,
++ NL80211_ATTR_CENTER_FREQ1,
++ NL80211_ATTR_CENTER_FREQ2,
++
++ NL80211_ATTR_P2P_CTWINDOW,
++ NL80211_ATTR_P2P_OPPPS,
++
++ NL80211_ATTR_WIPHY_ANTENNA_GAIN,
++
+ /* add attributes here, update the policy in nl80211.c */
+
+ __NL80211_ATTR_AFTER_LAST,
+@@ -1549,6 +1625,7 @@ enum nl80211_attrs {
+ #define NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY 16
+ #define NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY 24
+ #define NL80211_HT_CAPABILITY_LEN 26
++#define NL80211_VHT_CAPABILITY_LEN 12
+
+ #define NL80211_MAX_NR_CIPHER_SUITES 5
+ #define NL80211_MAX_NR_AKM_SUITES 2
+@@ -1575,6 +1652,10 @@ enum nl80211_attrs {
+ * @NL80211_IFTYPE_MESH_POINT: mesh point
+ * @NL80211_IFTYPE_P2P_CLIENT: P2P client
+ * @NL80211_IFTYPE_P2P_GO: P2P group owner
++ * @NL80211_IFTYPE_P2P_DEVICE: P2P device interface type, this is not a netdev
++ * and therefore can't be created in the normal ways, use the
++ * %NL80211_CMD_START_P2P_DEVICE and %NL80211_CMD_STOP_P2P_DEVICE
++ * commands to create and destroy one
+ * @NL80211_IFTYPE_MAX: highest interface type number currently defined
+ * @NUM_NL80211_IFTYPES: number of defined interface types
+ *
+@@ -1593,6 +1674,7 @@ enum nl80211_iftype {
+ NL80211_IFTYPE_MESH_POINT,
+ NL80211_IFTYPE_P2P_CLIENT,
+ NL80211_IFTYPE_P2P_GO,
++ NL80211_IFTYPE_P2P_DEVICE,
+
+ /* keep last */
+ NUM_NL80211_IFTYPES,
+@@ -1664,10 +1746,15 @@ struct nl80211_sta_flag_update {
+ * @__NL80211_RATE_INFO_INVALID: attribute number 0 is reserved
+ * @NL80211_RATE_INFO_BITRATE: total bitrate (u16, 100kbit/s)
+ * @NL80211_RATE_INFO_MCS: mcs index for 802.11n (u8)
+- * @NL80211_RATE_INFO_40_MHZ_WIDTH: 40 Mhz dualchannel bitrate
++ * @NL80211_RATE_INFO_40_MHZ_WIDTH: 40 MHz dualchannel bitrate
+ * @NL80211_RATE_INFO_SHORT_GI: 400ns guard interval
+ * @NL80211_RATE_INFO_BITRATE32: total bitrate (u32, 100kbit/s)
+ * @NL80211_RATE_INFO_MAX: highest rate_info number currently defined
++ * @NL80211_RATE_INFO_VHT_MCS: MCS index for VHT (u8)
++ * @NL80211_RATE_INFO_VHT_NSS: number of streams in VHT (u8)
++ * @NL80211_RATE_INFO_80_MHZ_WIDTH: 80 MHz VHT rate
++ * @NL80211_RATE_INFO_80P80_MHZ_WIDTH: 80+80 MHz VHT rate
++ * @NL80211_RATE_INFO_160_MHZ_WIDTH: 160 MHz VHT rate
+ * @__NL80211_RATE_INFO_AFTER_LAST: internal use
+ */
+ enum nl80211_rate_info {
+@@ -1677,6 +1764,11 @@ enum nl80211_rate_info {
+ NL80211_RATE_INFO_40_MHZ_WIDTH,
+ NL80211_RATE_INFO_SHORT_GI,
+ NL80211_RATE_INFO_BITRATE32,
++ NL80211_RATE_INFO_VHT_MCS,
++ NL80211_RATE_INFO_VHT_NSS,
++ NL80211_RATE_INFO_80_MHZ_WIDTH,
++ NL80211_RATE_INFO_80P80_MHZ_WIDTH,
++ NL80211_RATE_INFO_160_MHZ_WIDTH,
+
+ /* keep last */
+ __NL80211_RATE_INFO_AFTER_LAST,
+@@ -1744,6 +1836,8 @@ enum nl80211_sta_bss_param {
+ * @NL80211_STA_INFO_STA_FLAGS: Contains a struct nl80211_sta_flag_update.
+ * @NL80211_STA_INFO_BEACON_LOSS: count of times beacon loss was detected (u32)
+ * @NL80211_STA_INFO_T_OFFSET: timing offset with respect to this STA (s64)
++ * @NL80211_STA_INFO_CHAIN_SIGNAL: per-chain signal strength of last PPDU
++ * @NL80211_STA_INFO_CHAIN_SIGNAL_AVG: per-chain signal strength average
+ * @__NL80211_STA_INFO_AFTER_LAST: internal
+ * @NL80211_STA_INFO_MAX: highest possible station info attribute
+ */
+@@ -1768,6 +1862,8 @@ enum nl80211_sta_info {
+ NL80211_STA_INFO_STA_FLAGS,
+ NL80211_STA_INFO_BEACON_LOSS,
+ NL80211_STA_INFO_T_OFFSET,
++ NL80211_STA_INFO_CHAIN_SIGNAL,
++ NL80211_STA_INFO_CHAIN_SIGNAL_AVG,
+
+ /* keep last */
+ __NL80211_STA_INFO_AFTER_LAST,
+@@ -2385,6 +2481,15 @@ enum nl80211_ac {
+ #define NL80211_TXQ_Q_BE NL80211_AC_BE
+ #define NL80211_TXQ_Q_BK NL80211_AC_BK
+
++/**
++ * enum nl80211_channel_type - channel type
++ * @NL80211_CHAN_NO_HT: 20 MHz, non-HT channel
++ * @NL80211_CHAN_HT20: 20 MHz HT channel
++ * @NL80211_CHAN_HT40MINUS: HT40 channel, secondary channel
++ * below the control channel
++ * @NL80211_CHAN_HT40PLUS: HT40 channel, secondary channel
++ * above the control channel
++ */
+ enum nl80211_channel_type {
+ NL80211_CHAN_NO_HT,
+ NL80211_CHAN_HT20,
+@@ -2393,6 +2498,32 @@ enum nl80211_channel_type {
+ };
+
+ /**
++ * enum nl80211_chan_width - channel width definitions
++ *
++ * These values are used with the %NL80211_ATTR_CHANNEL_WIDTH
++ * attribute.
++ *
++ * @NL80211_CHAN_WIDTH_20_NOHT: 20 MHz, non-HT channel
++ * @NL80211_CHAN_WIDTH_20: 20 MHz HT channel
++ * @NL80211_CHAN_WIDTH_40: 40 MHz channel, the %NL80211_ATTR_CENTER_FREQ1
++ * attribute must be provided as well
++ * @NL80211_CHAN_WIDTH_80: 80 MHz channel, the %NL80211_ATTR_CENTER_FREQ1
++ * attribute must be provided as well
++ * @NL80211_CHAN_WIDTH_80P80: 80+80 MHz channel, the %NL80211_ATTR_CENTER_FREQ1
++ * and %NL80211_ATTR_CENTER_FREQ2 attributes must be provided as well
++ * @NL80211_CHAN_WIDTH_160: 160 MHz channel, the %NL80211_ATTR_CENTER_FREQ1
++ * attribute must be provided as well
++ */
++enum nl80211_chan_width {
++ NL80211_CHAN_WIDTH_20_NOHT,
++ NL80211_CHAN_WIDTH_20,
++ NL80211_CHAN_WIDTH_40,
++ NL80211_CHAN_WIDTH_80,
++ NL80211_CHAN_WIDTH_80P80,
++ NL80211_CHAN_WIDTH_160,
++};
++
++/**
+ * enum nl80211_bss - netlink attributes for a BSS
+ *
+ * @__NL80211_BSS_INVALID: invalid
+@@ -2460,6 +2591,7 @@ enum nl80211_bss_status {
+ * @NL80211_AUTHTYPE_SHARED_KEY: Shared Key authentication (WEP only)
+ * @NL80211_AUTHTYPE_FT: Fast BSS Transition (IEEE 802.11r)
+ * @NL80211_AUTHTYPE_NETWORK_EAP: Network EAP (some Cisco APs and mainly LEAP)
++ * @NL80211_AUTHTYPE_SAE: Simultaneous authentication of equals
+ * @__NL80211_AUTHTYPE_NUM: internal
+ * @NL80211_AUTHTYPE_MAX: maximum valid auth algorithm
+ * @NL80211_AUTHTYPE_AUTOMATIC: determine automatically (if necessary by
+@@ -2471,6 +2603,7 @@ enum nl80211_auth_type {
+ NL80211_AUTHTYPE_SHARED_KEY,
+ NL80211_AUTHTYPE_FT,
+ NL80211_AUTHTYPE_NETWORK_EAP,
++ NL80211_AUTHTYPE_SAE,
+
+ /* keep last */
+ __NL80211_AUTHTYPE_NUM,
+@@ -2994,12 +3127,40 @@ enum nl80211_ap_sme_features {
+ * @NL80211_FEATURE_CELL_BASE_REG_HINTS: This driver has been tested
+ * to work properly to suppport receiving regulatory hints from
+ * cellular base stations.
++ * @NL80211_FEATURE_P2P_DEVICE_NEEDS_CHANNEL: If this is set, an active
++ * P2P Device (%NL80211_IFTYPE_P2P_DEVICE) requires its own channel
++ * in the interface combinations, even when it's only used for scan
++ * and remain-on-channel. This could be due to, for example, the
++ * remain-on-channel implementation requiring a channel context.
++ * @NL80211_FEATURE_SAE: This driver supports simultaneous authentication of
++ * equals (SAE) with user space SME (NL80211_CMD_AUTHENTICATE) in station
++ * mode
++ * @NL80211_FEATURE_LOW_PRIORITY_SCAN: This driver supports low priority scan
++ * @NL80211_FEATURE_SCAN_FLUSH: Scan flush is supported
++ * @NL80211_FEATURE_AP_SCAN: Support scanning using an AP vif
++ * @NL80211_FEATURE_VIF_TXPOWER: The driver supports per-vif TX power setting
++ * @NL80211_FEATURE_NEED_OBSS_SCAN: The driver expects userspace to perform
++ * OBSS scans and generate 20/40 BSS coex reports. This flag is used only
++ * for drivers implementing the CONNECT API, for AUTH/ASSOC it is implied.
++ * @NL80211_FEATURE_P2P_GO_CTWIN: P2P GO implementation supports CT Window
++ * setting
++ * @NL80211_FEATURE_P2P_GO_OPPPS: P2P GO implementation supports opportunistic
++ * powersave
+ */
+ enum nl80211_feature_flags {
+- NL80211_FEATURE_SK_TX_STATUS = 1 << 0,
+- NL80211_FEATURE_HT_IBSS = 1 << 1,
+- NL80211_FEATURE_INACTIVITY_TIMER = 1 << 2,
+- NL80211_FEATURE_CELL_BASE_REG_HINTS = 1 << 3,
++ NL80211_FEATURE_SK_TX_STATUS = 1 << 0,
++ NL80211_FEATURE_HT_IBSS = 1 << 1,
++ NL80211_FEATURE_INACTIVITY_TIMER = 1 << 2,
++ NL80211_FEATURE_CELL_BASE_REG_HINTS = 1 << 3,
++ NL80211_FEATURE_P2P_DEVICE_NEEDS_CHANNEL = 1 << 4,
++ NL80211_FEATURE_SAE = 1 << 5,
++ NL80211_FEATURE_LOW_PRIORITY_SCAN = 1 << 6,
++ NL80211_FEATURE_SCAN_FLUSH = 1 << 7,
++ NL80211_FEATURE_AP_SCAN = 1 << 8,
++ NL80211_FEATURE_VIF_TXPOWER = 1 << 9,
++ NL80211_FEATURE_NEED_OBSS_SCAN = 1 << 10,
++ NL80211_FEATURE_P2P_GO_CTWIN = 1 << 11,
++ NL80211_FEATURE_P2P_GO_OPPPS = 1 << 12,
+ };
+
+ /**
+@@ -3023,4 +3184,36 @@ enum nl80211_probe_resp_offload_support_
+ NL80211_PROBE_RESP_OFFLOAD_SUPPORT_80211U = 1<<3,
+ };
+
++/**
++ * enum nl80211_connect_failed_reason - connection request failed reasons
++ * @NL80211_CONN_FAIL_MAX_CLIENTS: Maximum number of clients that can be
++ * handled by the AP is reached.
++ * @NL80211_CONN_FAIL_BLOCKED_CLIENT: Client's MAC is in the AP's blocklist.
++ */
++enum nl80211_connect_failed_reason {
++ NL80211_CONN_FAIL_MAX_CLIENTS,
++ NL80211_CONN_FAIL_BLOCKED_CLIENT,
++};
++
++/**
++ * enum nl80211_scan_flags - scan request control flags
++ *
++ * Scan request control flags are used to control the handling
++ * of NL80211_CMD_TRIGGER_SCAN and NL80211_CMD_START_SCHED_SCAN
++ * requests.
++ *
++ * @NL80211_SCAN_FLAG_LOW_PRIORITY: scan request has low priority
++ * @NL80211_SCAN_FLAG_FLUSH: flush cache before scanning
++ * @NL80211_SCAN_FLAG_AP: force a scan even if the interface is configured
++ * as AP and the beaconing has already been configured. This attribute is
++ * dangerous because will destroy stations performance as a lot of frames
++ * will be lost while scanning off-channel, therefore it must be used only
++ * when really needed
++ */
++enum nl80211_scan_flags {
++ NL80211_SCAN_FLAG_LOW_PRIORITY = 1<<0,
++ NL80211_SCAN_FLAG_FLUSH = 1<<1,
++ NL80211_SCAN_FLAG_AP = 1<<2,
++};
++
+ #endif /* __LINUX_NL80211_H */
diff --git a/package/network/utils/iw/patches/100-rx_rate.patch b/package/network/utils/iw/patches/100-rx_rate.patch
new file mode 100644
index 0000000..642b9f3
--- /dev/null
+++ b/package/network/utils/iw/patches/100-rx_rate.patch
@@ -0,0 +1,105 @@
+--- a/station.c
++++ b/station.c
+@@ -29,13 +29,47 @@ enum plink_actions {
+ PLINK_ACTION_BLOCK,
+ };
+
++static void print_sta_bitrate(struct nlattr *nla, const char *name)
++{
++ struct nlattr *rinfo[NL80211_RATE_INFO_MAX + 1];
++
++ static struct nla_policy rate_policy[NL80211_RATE_INFO_MAX + 1] = {
++ [NL80211_RATE_INFO_BITRATE] = { .type = NLA_U16 },
++ [NL80211_RATE_INFO_BITRATE32] = { .type = NLA_U32 },
++ [NL80211_RATE_INFO_MCS] = { .type = NLA_U8 },
++ [NL80211_RATE_INFO_40_MHZ_WIDTH] = { .type = NLA_FLAG },
++ [NL80211_RATE_INFO_SHORT_GI] = { .type = NLA_FLAG },
++ };
++
++ if (!nla)
++ return;
++
++ if (nla_parse_nested(rinfo, NL80211_RATE_INFO_MAX, nla, rate_policy)) {
++ fprintf(stderr, "failed to parse nested rate attributes!\n");
++ } else {
++ int rate = 0;
++ printf("\n\t%s:\t", name);
++ if (rinfo[NL80211_RATE_INFO_BITRATE32])
++ rate = nla_get_u32(rinfo[NL80211_RATE_INFO_BITRATE32]);
++ else if (rinfo[NL80211_RATE_INFO_BITRATE])
++ rate = nla_get_u16(rinfo[NL80211_RATE_INFO_BITRATE]);
++ if (rate > 0)
++ printf("%d.%d MBit/s", rate / 10, rate % 10);
++
++ if (rinfo[NL80211_RATE_INFO_MCS])
++ printf(" MCS %d", nla_get_u8(rinfo[NL80211_RATE_INFO_MCS]));
++ if (rinfo[NL80211_RATE_INFO_40_MHZ_WIDTH])
++ printf(" 40Mhz");
++ if (rinfo[NL80211_RATE_INFO_SHORT_GI])
++ printf(" short GI");
++ }
++}
+
+ static int print_sta_handler(struct nl_msg *msg, void *arg)
+ {
+ struct nlattr *tb[NL80211_ATTR_MAX + 1];
+ struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
+ struct nlattr *sinfo[NL80211_STA_INFO_MAX + 1];
+- struct nlattr *rinfo[NL80211_RATE_INFO_MAX + 1];
+ char mac_addr[20], state_name[10], dev[20];
+ struct nl80211_sta_flag_update *sta_flags;
+ static struct nla_policy stats_policy[NL80211_STA_INFO_MAX + 1] = {
+@@ -47,6 +81,7 @@ static int print_sta_handler(struct nl_m
+ [NL80211_STA_INFO_SIGNAL] = { .type = NLA_U8 },
+ [NL80211_STA_INFO_T_OFFSET] = { .type = NLA_U64 },
+ [NL80211_STA_INFO_TX_BITRATE] = { .type = NLA_NESTED },
++ [NL80211_STA_INFO_RX_BITRATE] = { .type = NLA_NESTED },
+ [NL80211_STA_INFO_LLID] = { .type = NLA_U16 },
+ [NL80211_STA_INFO_PLID] = { .type = NLA_U16 },
+ [NL80211_STA_INFO_PLINK_STATE] = { .type = NLA_U8 },
+@@ -56,14 +91,6 @@ static int print_sta_handler(struct nl_m
+ { .minlen = sizeof(struct nl80211_sta_flag_update) },
+ };
+
+- static struct nla_policy rate_policy[NL80211_RATE_INFO_MAX + 1] = {
+- [NL80211_RATE_INFO_BITRATE] = { .type = NLA_U16 },
+- [NL80211_RATE_INFO_BITRATE32] = { .type = NLA_U32 },
+- [NL80211_RATE_INFO_MCS] = { .type = NLA_U8 },
+- [NL80211_RATE_INFO_40_MHZ_WIDTH] = { .type = NLA_FLAG },
+- [NL80211_RATE_INFO_SHORT_GI] = { .type = NLA_FLAG },
+- };
+-
+ nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
+ genlmsg_attrlen(gnlh, 0), NULL);
+
+@@ -119,28 +146,8 @@ static int print_sta_handler(struct nl_m
+ printf("\n\tToffset:\t%lld us",
+ (unsigned long long)nla_get_u64(sinfo[NL80211_STA_INFO_T_OFFSET]));
+
+- if (sinfo[NL80211_STA_INFO_TX_BITRATE]) {
+- if (nla_parse_nested(rinfo, NL80211_RATE_INFO_MAX,
+- sinfo[NL80211_STA_INFO_TX_BITRATE], rate_policy)) {
+- fprintf(stderr, "failed to parse nested rate attributes!\n");
+- } else {
+- int rate = 0;
+- printf("\n\ttx bitrate:\t");
+- if (rinfo[NL80211_RATE_INFO_BITRATE32])
+- rate = nla_get_u32(rinfo[NL80211_RATE_INFO_BITRATE32]);
+- else if (rinfo[NL80211_RATE_INFO_BITRATE])
+- rate = nla_get_u16(rinfo[NL80211_RATE_INFO_BITRATE]);
+- if (rate > 0)
+- printf("%d.%d MBit/s", rate / 10, rate % 10);
+-
+- if (rinfo[NL80211_RATE_INFO_MCS])
+- printf(" MCS %d", nla_get_u8(rinfo[NL80211_RATE_INFO_MCS]));
+- if (rinfo[NL80211_RATE_INFO_40_MHZ_WIDTH])
+- printf(" 40Mhz");
+- if (rinfo[NL80211_RATE_INFO_SHORT_GI])
+- printf(" short GI");
+- }
+- }
++ print_sta_bitrate(sinfo[NL80211_STA_INFO_TX_BITRATE], "tx bitrate");
++ print_sta_bitrate(sinfo[NL80211_STA_INFO_RX_BITRATE], "rx bitrate");
+
+ if (sinfo[NL80211_STA_INFO_LLID])
+ printf("\n\tmesh llid:\t%d",
diff --git a/package/network/utils/iw/patches/110-per_chain_signal_strength.patch b/package/network/utils/iw/patches/110-per_chain_signal_strength.patch
new file mode 100644
index 0000000..813a7d9
--- /dev/null
+++ b/package/network/utils/iw/patches/110-per_chain_signal_strength.patch
@@ -0,0 +1,71 @@
+--- a/station.c
++++ b/station.c
+@@ -65,6 +65,33 @@ static void print_sta_bitrate(struct nla
+ }
+ }
+
++static char *get_chain_signal(struct nlattr *attr_list)
++{
++ struct nlattr *attr;
++ static char buf[64];
++ char *cur = buf;
++ int i = 0, rem;
++ const char *prefix;
++
++ if (!attr_list)
++ return "";
++
++ nla_for_each_nested(attr, attr_list, rem) {
++ if (i++ > 0)
++ prefix = ", ";
++ else
++ prefix = "[";
++
++ cur += snprintf(cur, sizeof(buf) - (cur - buf), "%s%d", prefix,
++ (int8_t) nla_get_u8(attr));
++ }
++
++ if (i)
++ snprintf(cur, sizeof(buf) - (cur - buf), "] ");
++
++ return buf;
++}
++
+ static int print_sta_handler(struct nl_msg *msg, void *arg)
+ {
+ struct nlattr *tb[NL80211_ATTR_MAX + 1];
+@@ -89,7 +116,10 @@ static int print_sta_handler(struct nl_m
+ [NL80211_STA_INFO_TX_FAILED] = { .type = NLA_U32 },
+ [NL80211_STA_INFO_STA_FLAGS] =
+ { .minlen = sizeof(struct nl80211_sta_flag_update) },
++ [NL80211_STA_INFO_CHAIN_SIGNAL] = { .type = NLA_NESTED },
++ [NL80211_STA_INFO_CHAIN_SIGNAL_AVG] = { .type = NLA_NESTED },
+ };
++ char *chain;
+
+ nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
+ genlmsg_attrlen(gnlh, 0), NULL);
+@@ -136,12 +166,19 @@ static int print_sta_handler(struct nl_m
+ if (sinfo[NL80211_STA_INFO_TX_FAILED])
+ printf("\n\ttx failed:\t%u",
+ nla_get_u32(sinfo[NL80211_STA_INFO_TX_FAILED]));
++
++ chain = get_chain_signal(sinfo[NL80211_STA_INFO_CHAIN_SIGNAL]);
+ if (sinfo[NL80211_STA_INFO_SIGNAL])
+- printf("\n\tsignal: \t%d dBm",
+- (int8_t)nla_get_u8(sinfo[NL80211_STA_INFO_SIGNAL]));
++ printf("\n\tsignal: \t%d %sdBm",
++ (int8_t)nla_get_u8(sinfo[NL80211_STA_INFO_SIGNAL]),
++ chain);
++
++ chain = get_chain_signal(sinfo[NL80211_STA_INFO_CHAIN_SIGNAL_AVG]);
+ if (sinfo[NL80211_STA_INFO_SIGNAL_AVG])
+- printf("\n\tsignal avg:\t%d dBm",
+- (int8_t)nla_get_u8(sinfo[NL80211_STA_INFO_SIGNAL_AVG]));
++ printf("\n\tsignal avg:\t%d %sdBm",
++ (int8_t)nla_get_u8(sinfo[NL80211_STA_INFO_SIGNAL_AVG]),
++ chain);
++
+ if (sinfo[NL80211_STA_INFO_T_OFFSET])
+ printf("\n\tToffset:\t%lld us",
+ (unsigned long long)nla_get_u64(sinfo[NL80211_STA_INFO_T_OFFSET]));
diff --git a/package/network/utils/iw/patches/120-tdls_peer_indentation.patch b/package/network/utils/iw/patches/120-tdls_peer_indentation.patch
new file mode 100644
index 0000000..6836873
--- /dev/null
+++ b/package/network/utils/iw/patches/120-tdls_peer_indentation.patch
@@ -0,0 +1,11 @@
+--- a/station.c
++++ b/station.c
+@@ -267,7 +267,7 @@ static int print_sta_handler(struct nl_m
+ }
+
+ if (sta_flags->mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
+- printf("\n\tTDLS peer:\t\t");
++ printf("\n\tTDLS peer:\t");
+ if (sta_flags->set & BIT(NL80211_STA_FLAG_TDLS_PEER))
+ printf("yes");
+ else
diff --git a/package/network/utils/iw/patches/130-antenna_gain.patch b/package/network/utils/iw/patches/130-antenna_gain.patch
new file mode 100644
index 0000000..f3ca691
--- /dev/null
+++ b/package/network/utils/iw/patches/130-antenna_gain.patch
@@ -0,0 +1,34 @@
+--- a/phy.c
++++ b/phy.c
+@@ -359,3 +359,31 @@ COMMAND(set, antenna, "<bitmap> | all |
+ NL80211_CMD_SET_WIPHY, 0, CIB_PHY, handle_antenna,
+ "Set a bitmap of allowed antennas to use for TX and RX.\n"
+ "The driver may reject antenna configurations it cannot support.");
++
++static int handle_antenna_gain(struct nl80211_state *state,
++ struct nl_cb *cb,
++ struct nl_msg *msg,
++ int argc, char **argv,
++ enum id_input id)
++{
++ char *endptr;
++ int dbm;
++
++ /* get the required args */
++ if (argc != 1)
++ return 1;
++
++ dbm = strtol(argv[0], &endptr, 10);
++ if (*endptr)
++ return 2;
++
++ NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_ANTENNA_GAIN, dbm);
++
++ return 0;
++
++ nla_put_failure:
++ return -ENOBUFS;
++}
++COMMAND(set, antenna_gain, "<antenna gain in dBm>",
++ NL80211_CMD_SET_WIPHY, 0, CIB_PHY, handle_antenna_gain,
++ "Specify antenna gain.");
diff --git a/package/network/utils/iwcap/.svn/entries b/package/network/utils/iwcap/.svn/entries
new file mode 100644
index 0000000..99caf23
--- /dev/null
+++ b/package/network/utils/iwcap/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/utils/iwcap
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-10T12:32:29.935169Z
+33688
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+src
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+66b19516457100876bcbdccba91273be
+2012-02-27T22:57:15.901381Z
+30747
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1172
+
diff --git a/package/network/utils/iwcap/.svn/text-base/Makefile.svn-base b/package/network/utils/iwcap/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..b406bdf
--- /dev/null
+++ b/package/network/utils/iwcap/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,50 @@
+#
+# Copyright (C) 2012 Jo-Philipp Wich <jow@openwrt.org>
+#
+# This is free software, licensed under the Apache 2 license.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=iwcap
+PKG_RELEASE:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+
+define Package/iwcap
+ SECTION:=utils
+ CATEGORY:=Utilities
+ TITLE:=Simple radiotap capture utility
+ MAINTAINER:=Jo-Philipp Wich <jow@openwrt.org>
+endef
+
+define Package/iwcap/description
+ The iwcap utility receives radiotap packet data from wifi monitor interfaces
+ and outputs it to pcap format. It gathers recived packets in a fixed ring
+ buffer to dump them on demand which is useful for background monitoring.
+ Alternatively the utility can stream the data to stdout to act as remote
+ capture drone for Wireshark or similar programs.
+endef
+
+
+define Build/Prepare
+ $(INSTALL_DIR) $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+ $(TARGET_CC) $(TARGET_CFLAGS) \
+ -o $(PKG_BUILD_DIR)/iwcap $(PKG_BUILD_DIR)/iwcap.c
+endef
+
+
+define Package/iwcap/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/iwcap $(1)/usr/sbin/iwcap
+endef
+
+$(eval $(call BuildPackage,iwcap))
diff --git a/package/network/utils/iwcap/Makefile b/package/network/utils/iwcap/Makefile
new file mode 100644
index 0000000..b406bdf
--- /dev/null
+++ b/package/network/utils/iwcap/Makefile
@@ -0,0 +1,50 @@
+#
+# Copyright (C) 2012 Jo-Philipp Wich <jow@openwrt.org>
+#
+# This is free software, licensed under the Apache 2 license.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=iwcap
+PKG_RELEASE:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+
+define Package/iwcap
+ SECTION:=utils
+ CATEGORY:=Utilities
+ TITLE:=Simple radiotap capture utility
+ MAINTAINER:=Jo-Philipp Wich <jow@openwrt.org>
+endef
+
+define Package/iwcap/description
+ The iwcap utility receives radiotap packet data from wifi monitor interfaces
+ and outputs it to pcap format. It gathers recived packets in a fixed ring
+ buffer to dump them on demand which is useful for background monitoring.
+ Alternatively the utility can stream the data to stdout to act as remote
+ capture drone for Wireshark or similar programs.
+endef
+
+
+define Build/Prepare
+ $(INSTALL_DIR) $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+ $(TARGET_CC) $(TARGET_CFLAGS) \
+ -o $(PKG_BUILD_DIR)/iwcap $(PKG_BUILD_DIR)/iwcap.c
+endef
+
+
+define Package/iwcap/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/iwcap $(1)/usr/sbin/iwcap
+endef
+
+$(eval $(call BuildPackage,iwcap))
diff --git a/package/network/utils/iwcap/src/.svn/entries b/package/network/utils/iwcap/src/.svn/entries
new file mode 100644
index 0000000..d87b6a5
--- /dev/null
+++ b/package/network/utils/iwcap/src/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/utils/iwcap/src
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-02-27T23:08:15.594122Z
+30748
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+iwcap.c
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+87d87aae4e1f189614b7e019f826b52b
+2012-02-27T23:08:15.594122Z
+30748
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+11963
+
diff --git a/package/network/utils/iwcap/src/.svn/text-base/iwcap.c.svn-base b/package/network/utils/iwcap/src/.svn/text-base/iwcap.c.svn-base
new file mode 100644
index 0000000..a71dca2
--- /dev/null
+++ b/package/network/utils/iwcap/src/.svn/text-base/iwcap.c.svn-base
@@ -0,0 +1,582 @@
+/*
+ * iwcap.c - A simply radiotap capture utility outputting pcap dumps
+ *
+ * Copyright 2012 Jo-Philipp Wich <jow@openwrt.org>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <unistd.h>
+#include <string.h>
+#include <signal.h>
+#include <syslog.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+#include <net/ethernet.h>
+#include <net/if.h>
+#include <netinet/in.h>
+#include <linux/if_packet.h>
+
+#define ARPHRD_IEEE80211_RADIOTAP 803
+
+#define DLT_IEEE802_11_RADIO 127
+#define LEN_IEEE802_11_HDR 32
+
+#define FRAMETYPE_MASK 0xFC
+#define FRAMETYPE_BEACON 0x80
+#define FRAMETYPE_DATA 0x08
+
+#if __BYTE_ORDER == __BIG_ENDIAN
+#define le16(x) __bswap_16(x)
+#else
+#define le16(x) (x)
+#endif
+
+uint8_t run_dump = 0;
+uint8_t run_stop = 0;
+uint8_t run_daemon = 0;
+
+uint32_t frames_captured = 0;
+uint32_t frames_filtered = 0;
+
+int capture_sock = -1;
+const char *ifname = NULL;
+
+
+struct ringbuf {
+ uint32_t len; /* number of slots */
+ uint32_t fill; /* last used slot */
+ uint32_t slen; /* slot size */
+ void *buf; /* ring memory */
+};
+
+struct ringbuf_entry {
+ uint32_t len; /* used slot memory */
+ uint32_t olen; /* original data size */
+ uint32_t sec; /* epoch of slot creation */
+ uint32_t usec; /* epoch microseconds */
+};
+
+typedef struct pcap_hdr_s {
+ uint32_t magic_number; /* magic number */
+ uint16_t version_major; /* major version number */
+ uint16_t version_minor; /* minor version number */
+ int32_t thiszone; /* GMT to local correction */
+ uint32_t sigfigs; /* accuracy of timestamps */
+ uint32_t snaplen; /* max length of captured packets, in octets */
+ uint32_t network; /* data link type */
+} pcap_hdr_t;
+
+typedef struct pcaprec_hdr_s {
+ uint32_t ts_sec; /* timestamp seconds */
+ uint32_t ts_usec; /* timestamp microseconds */
+ uint32_t incl_len; /* number of octets of packet saved in file */
+ uint32_t orig_len; /* actual length of packet */
+} pcaprec_hdr_t;
+
+typedef struct ieee80211_radiotap_header {
+ u_int8_t it_version; /* set to 0 */
+ u_int8_t it_pad;
+ u_int16_t it_len; /* entire length */
+ u_int32_t it_present; /* fields present */
+} __attribute__((__packed__)) radiotap_hdr_t;
+
+
+int check_type(void)
+{
+ struct ifreq ifr;
+
+ strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
+
+ if (ioctl(capture_sock, SIOCGIFHWADDR, &ifr) < 0)
+ return -1;
+
+ return (ifr.ifr_hwaddr.sa_family == ARPHRD_IEEE80211_RADIOTAP);
+}
+
+int set_promisc(int on)
+{
+ struct ifreq ifr;
+
+ strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
+
+ if (ioctl(capture_sock, SIOCGIFFLAGS, &ifr) < 0)
+ return -1;
+
+ if (on && !(ifr.ifr_flags & IFF_PROMISC))
+ {
+ ifr.ifr_flags |= IFF_PROMISC;
+
+ if (ioctl(capture_sock, SIOCSIFFLAGS, &ifr))
+ return -1;
+
+ return 1;
+ }
+ else if (!on && (ifr.ifr_flags & IFF_PROMISC))
+ {
+ ifr.ifr_flags &= ~IFF_PROMISC;
+
+ if (ioctl(capture_sock, SIOCSIFFLAGS, &ifr))
+ return -1;
+
+ return 1;
+ }
+
+ return 0;
+}
+
+
+void sig_dump(int sig)
+{
+ run_dump = 1;
+}
+
+void sig_teardown(int sig)
+{
+ run_stop = 1;
+}
+
+
+void write_pcap_header(FILE *o)
+{
+ pcap_hdr_t ghdr = {
+ .magic_number = 0xa1b2c3d4,
+ .version_major = 2,
+ .version_minor = 4,
+ .thiszone = 0,
+ .sigfigs = 0,
+ .snaplen = 0xFFFF,
+ .network = DLT_IEEE802_11_RADIO
+ };
+
+ fwrite(&ghdr, 1, sizeof(ghdr), o);
+}
+
+void write_pcap_frame(FILE *o, uint32_t *sec, uint32_t *usec,
+ uint16_t len, uint16_t olen)
+{
+ struct timeval tv;
+ pcaprec_hdr_t fhdr;
+
+ if (!sec || !usec)
+ {
+ gettimeofday(&tv, NULL);
+ }
+ else
+ {
+ tv.tv_sec = *sec;
+ tv.tv_usec = *usec;
+ }
+
+ fhdr.ts_sec = tv.tv_sec;
+ fhdr.ts_usec = tv.tv_usec;
+ fhdr.incl_len = len;
+ fhdr.orig_len = olen;
+
+ fwrite(&fhdr, 1, sizeof(fhdr), o);
+}
+
+
+struct ringbuf * ringbuf_init(uint32_t num_item, uint16_t len_item)
+{
+ static struct ringbuf r;
+
+ if (len_item <= 0)
+ return NULL;
+
+ r.buf = malloc(num_item * (len_item + sizeof(struct ringbuf_entry)));
+
+ if (r.buf)
+ {
+ r.len = num_item;
+ r.fill = 0;
+ r.slen = (len_item + sizeof(struct ringbuf_entry));
+
+ memset(r.buf, 0, num_item * len_item);
+
+ return &r;
+ }
+
+ return NULL;
+}
+
+struct ringbuf_entry * ringbuf_add(struct ringbuf *r)
+{
+ struct timeval t;
+ struct ringbuf_entry *e;
+
+ gettimeofday(&t, NULL);
+
+ e = r->buf + (r->fill++ * r->slen);
+ r->fill %= r->len;
+
+ memset(e, 0, r->slen);
+
+ e->sec = t.tv_sec;
+ e->usec = t.tv_usec;
+
+ return e;
+}
+
+struct ringbuf_entry * ringbuf_get(struct ringbuf *r, int i)
+{
+ struct ringbuf_entry *e = r->buf + (((r->fill + i) % r->len) * r->slen);
+
+ if (e->len > 0)
+ return e;
+
+ return NULL;
+}
+
+void ringbuf_free(struct ringbuf *r)
+{
+ free(r->buf);
+ memset(r, 0, sizeof(*r));
+}
+
+
+void msg(const char *fmt, ...)
+{
+ va_list ap;
+ va_start(ap, fmt);
+
+ if (run_daemon)
+ vsyslog(LOG_INFO | LOG_USER, fmt, ap);
+ else
+ vfprintf(stderr, fmt, ap);
+
+ va_end(ap);
+}
+
+
+int main(int argc, char **argv)
+{
+ int i, n;
+ struct ringbuf *ring;
+ struct ringbuf_entry *e;
+ struct sockaddr_ll local = {
+ .sll_family = AF_PACKET,
+ .sll_protocol = htons(ETH_P_ALL)
+ };
+
+ radiotap_hdr_t *rhdr;
+
+ uint8_t frametype;
+ uint8_t pktbuf[0xFFFF];
+ ssize_t pktlen;
+
+ FILE *o;
+
+ int opt;
+
+ uint8_t promisc = 0;
+ uint8_t streaming = 0;
+ uint8_t foreground = 0;
+ uint8_t filter_data = 0;
+ uint8_t filter_beacon = 0;
+ uint8_t header_written = 0;
+
+ uint32_t ringsz = 1024 * 1024; /* 1 Mbyte ring buffer */
+ uint16_t pktcap = 256; /* truncate frames after 265KB */
+
+ const char *output = NULL;
+
+
+ while ((opt = getopt(argc, argv, "i:r:c:o:sfhBD")) != -1)
+ {
+ switch (opt)
+ {
+ case 'i':
+ ifname = optarg;
+ if (!(local.sll_ifindex = if_nametoindex(ifname)))
+ {
+ msg("Unknown interface '%s'\n", ifname);
+ return 2;
+ }
+ break;
+
+ case 'r':
+ ringsz = atoi(optarg);
+ if (ringsz < (3 * pktcap))
+ {
+ msg("Ring size of %d bytes is too short, "
+ "must be at least %d bytes\n", ringsz, 3 * pktcap);
+ return 3;
+ }
+ break;
+
+ case 'c':
+ pktcap = atoi(optarg);
+ if (pktcap <= (sizeof(radiotap_hdr_t) + LEN_IEEE802_11_HDR))
+ {
+ msg("Packet truncate after %d bytes is too short, "
+ "must be at least %d bytes\n",
+ pktcap, sizeof(radiotap_hdr_t) + LEN_IEEE802_11_HDR);
+ return 4;
+ }
+ break;
+
+ case 's':
+ streaming = 1;
+ break;
+
+ case 'o':
+ output = optarg;
+ break;
+
+ case 'B':
+ filter_beacon = 1;
+ break;
+
+ case 'D':
+ filter_data = 1;
+ break;
+
+ case 'f':
+ foreground = 1;
+ break;
+
+ case 'h':
+ msg(
+ "Usage:\n"
+ " %s -i {iface} -s [-b] [-d]\n"
+ " %s -i {iface} -o {file} [-r len] [-c len] [-B] [-D] [-f]\n"
+ "\n"
+ " -i iface\n"
+ " Specify interface to use, must be in monitor mode and\n"
+ " produce IEEE 802.11 Radiotap headers.\n\n"
+ " -s\n"
+ " Stream to stdout instead of Dumping to file on USR1.\n\n"
+ " -o file\n"
+ " Write current ringbuffer contents to given output file\n"
+ " on receipt of SIGUSR1.\n\n"
+ " -r len\n"
+ " Specify the amount of bytes to use for the ringbuffer.\n"
+ " The default length is %d bytes.\n\n"
+ " -c len\n"
+ " Truncate captured packets after given amount of bytes.\n"
+ " The default size limit is %d bytes.\n\n"
+ " -B\n"
+ " Don't store beacon frames in ring, default is keep.\n\n"
+ " -D\n"
+ " Don't store data frames in ring, default is keep.\n\n"
+ " -f\n"
+ " Do not daemonize but keep running in foreground.\n\n"
+ " -h\n"
+ " Display this help.\n\n",
+ argv[0], argv[0], ringsz, pktcap);
+
+ return 1;
+ }
+ }
+
+ if (!streaming && !output)
+ {
+ msg("No output file specified\n");
+ return 1;
+ }
+
+ if (streaming && output)
+ {
+ msg("The -s and -o options are exclusive\n");
+ return 1;
+ }
+
+ if (streaming && isatty(1))
+ {
+ msg("Refusing to stream into a terminal\n");
+ return 1;
+ }
+
+ if (!local.sll_ifindex)
+ {
+ msg("No interface specified\n");
+ return 2;
+ }
+
+ if (!check_type())
+ {
+ msg("Bad interface: not ARPHRD_IEEE80211_RADIOTAP\n");
+ return 2;
+ }
+
+ if ((capture_sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL))) < 0)
+ {
+ msg("Unable to create raw socket: %s\n",
+ strerror(errno));
+ return 6;
+ }
+
+ if (bind(capture_sock, (struct sockaddr *)&local, sizeof(local)) == -1)
+ {
+ msg("Unable to bind to interface: %s\n",
+ strerror(errno));
+ return 7;
+ }
+
+ if (!streaming)
+ {
+ if (!foreground)
+ {
+ switch (fork())
+ {
+ case -1:
+ msg("Unable to fork: %s\n", strerror(errno));
+ return 8;
+
+ case 0:
+ umask(0077);
+ chdir("/");
+ freopen("/dev/null", "r", stdin);
+ freopen("/dev/null", "w", stdout);
+ freopen("/dev/null", "w", stderr);
+ run_daemon = 1;
+ break;
+
+ default:
+ msg("Daemon launched ...\n");
+ return 0;
+ }
+ }
+
+ msg("Monitoring interface %s ...\n", ifname);
+
+ if (!(ring = ringbuf_init(ringsz / pktcap, pktcap)))
+ {
+ msg("Unable to allocate ring buffer: %s\n",
+ strerror(errno));
+ return 5;
+ }
+
+ msg(" * Using %d bytes ringbuffer with %d slots\n", ringsz, ring->len);
+ msg(" * Truncating frames at %d bytes\n", pktcap);
+ msg(" * Dumping data to file %s\n", output);
+
+ signal(SIGUSR1, sig_dump);
+ }
+ else
+ {
+ msg("Monitoring interface %s ...\n", ifname);
+ msg(" * Streaming data to stdout\n");
+ }
+
+ msg(" * Beacon frames are %sfiltered\n", filter_beacon ? "" : "not ");
+ msg(" * Data frames are %sfiltered\n", filter_data ? "" : "not ");
+
+ signal(SIGINT, sig_teardown);
+ signal(SIGTERM, sig_teardown);
+
+ promisc = set_promisc(1);
+
+ /* capture loop */
+ while (1)
+ {
+ if (run_stop)
+ {
+ msg("Shutting down ...\n");
+
+ if (promisc)
+ set_promisc(0);
+
+ if (ring)
+ ringbuf_free(ring);
+
+ return 0;
+ }
+ else if (run_dump)
+ {
+ msg("Dumping ring to %s ...\n", output);
+
+ if (!(o = fopen(output, "w")))
+ {
+ msg("Unable to open %s: %s\n",
+ output, strerror(errno));
+ }
+ else
+ {
+ write_pcap_header(o);
+
+ /* sig_dump packet buffer */
+ for (i = 0, n = 0; i < ring->len; i++)
+ {
+ if (!(e = ringbuf_get(ring, i)))
+ continue;
+
+ write_pcap_frame(o, &(e->sec), &(e->usec), e->len, e->olen);
+ fwrite((void *)e + sizeof(*e), 1, e->len, o);
+ n++;
+ }
+
+ fclose(o);
+
+ msg(" * %d frames captured\n", frames_captured);
+ msg(" * %d frames filtered\n", frames_filtered);
+ msg(" * %d frames dumped\n", n);
+ }
+
+ run_dump = 0;
+ }
+
+ pktlen = recvfrom(capture_sock, pktbuf, sizeof(pktbuf), 0, NULL, 0);
+ frames_captured++;
+
+ /* check received frametype, if we should filter it, rewind the ring */
+ rhdr = (radiotap_hdr_t *)pktbuf;
+
+ if (pktlen <= sizeof(radiotap_hdr_t) || le16(rhdr->it_len) >= pktlen)
+ {
+ frames_filtered++;
+ continue;
+ }
+
+ frametype = *(uint8_t *)(pktbuf + le16(rhdr->it_len));
+
+ if ((filter_data && (frametype & FRAMETYPE_MASK) == FRAMETYPE_DATA) ||
+ (filter_beacon && (frametype & FRAMETYPE_MASK) == FRAMETYPE_BEACON))
+ {
+ frames_filtered++;
+ continue;
+ }
+
+ if (streaming)
+ {
+ if (!header_written)
+ {
+ write_pcap_header(stdout);
+ header_written = 1;
+ }
+
+ write_pcap_frame(stdout, NULL, NULL, pktlen, pktlen);
+ fwrite(pktbuf, 1, pktlen, stdout);
+ fflush(stdout);
+ }
+ else
+ {
+ e = ringbuf_add(ring);
+ e->olen = pktlen;
+ e->len = (pktlen > pktcap) ? pktcap : pktlen;
+
+ memcpy((void *)e + sizeof(*e), pktbuf, e->len);
+ }
+ }
+
+ return 0;
+}
diff --git a/package/network/utils/iwcap/src/iwcap.c b/package/network/utils/iwcap/src/iwcap.c
new file mode 100644
index 0000000..a71dca2
--- /dev/null
+++ b/package/network/utils/iwcap/src/iwcap.c
@@ -0,0 +1,582 @@
+/*
+ * iwcap.c - A simply radiotap capture utility outputting pcap dumps
+ *
+ * Copyright 2012 Jo-Philipp Wich <jow@openwrt.org>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <unistd.h>
+#include <string.h>
+#include <signal.h>
+#include <syslog.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+#include <net/ethernet.h>
+#include <net/if.h>
+#include <netinet/in.h>
+#include <linux/if_packet.h>
+
+#define ARPHRD_IEEE80211_RADIOTAP 803
+
+#define DLT_IEEE802_11_RADIO 127
+#define LEN_IEEE802_11_HDR 32
+
+#define FRAMETYPE_MASK 0xFC
+#define FRAMETYPE_BEACON 0x80
+#define FRAMETYPE_DATA 0x08
+
+#if __BYTE_ORDER == __BIG_ENDIAN
+#define le16(x) __bswap_16(x)
+#else
+#define le16(x) (x)
+#endif
+
+uint8_t run_dump = 0;
+uint8_t run_stop = 0;
+uint8_t run_daemon = 0;
+
+uint32_t frames_captured = 0;
+uint32_t frames_filtered = 0;
+
+int capture_sock = -1;
+const char *ifname = NULL;
+
+
+struct ringbuf {
+ uint32_t len; /* number of slots */
+ uint32_t fill; /* last used slot */
+ uint32_t slen; /* slot size */
+ void *buf; /* ring memory */
+};
+
+struct ringbuf_entry {
+ uint32_t len; /* used slot memory */
+ uint32_t olen; /* original data size */
+ uint32_t sec; /* epoch of slot creation */
+ uint32_t usec; /* epoch microseconds */
+};
+
+typedef struct pcap_hdr_s {
+ uint32_t magic_number; /* magic number */
+ uint16_t version_major; /* major version number */
+ uint16_t version_minor; /* minor version number */
+ int32_t thiszone; /* GMT to local correction */
+ uint32_t sigfigs; /* accuracy of timestamps */
+ uint32_t snaplen; /* max length of captured packets, in octets */
+ uint32_t network; /* data link type */
+} pcap_hdr_t;
+
+typedef struct pcaprec_hdr_s {
+ uint32_t ts_sec; /* timestamp seconds */
+ uint32_t ts_usec; /* timestamp microseconds */
+ uint32_t incl_len; /* number of octets of packet saved in file */
+ uint32_t orig_len; /* actual length of packet */
+} pcaprec_hdr_t;
+
+typedef struct ieee80211_radiotap_header {
+ u_int8_t it_version; /* set to 0 */
+ u_int8_t it_pad;
+ u_int16_t it_len; /* entire length */
+ u_int32_t it_present; /* fields present */
+} __attribute__((__packed__)) radiotap_hdr_t;
+
+
+int check_type(void)
+{
+ struct ifreq ifr;
+
+ strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
+
+ if (ioctl(capture_sock, SIOCGIFHWADDR, &ifr) < 0)
+ return -1;
+
+ return (ifr.ifr_hwaddr.sa_family == ARPHRD_IEEE80211_RADIOTAP);
+}
+
+int set_promisc(int on)
+{
+ struct ifreq ifr;
+
+ strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
+
+ if (ioctl(capture_sock, SIOCGIFFLAGS, &ifr) < 0)
+ return -1;
+
+ if (on && !(ifr.ifr_flags & IFF_PROMISC))
+ {
+ ifr.ifr_flags |= IFF_PROMISC;
+
+ if (ioctl(capture_sock, SIOCSIFFLAGS, &ifr))
+ return -1;
+
+ return 1;
+ }
+ else if (!on && (ifr.ifr_flags & IFF_PROMISC))
+ {
+ ifr.ifr_flags &= ~IFF_PROMISC;
+
+ if (ioctl(capture_sock, SIOCSIFFLAGS, &ifr))
+ return -1;
+
+ return 1;
+ }
+
+ return 0;
+}
+
+
+void sig_dump(int sig)
+{
+ run_dump = 1;
+}
+
+void sig_teardown(int sig)
+{
+ run_stop = 1;
+}
+
+
+void write_pcap_header(FILE *o)
+{
+ pcap_hdr_t ghdr = {
+ .magic_number = 0xa1b2c3d4,
+ .version_major = 2,
+ .version_minor = 4,
+ .thiszone = 0,
+ .sigfigs = 0,
+ .snaplen = 0xFFFF,
+ .network = DLT_IEEE802_11_RADIO
+ };
+
+ fwrite(&ghdr, 1, sizeof(ghdr), o);
+}
+
+void write_pcap_frame(FILE *o, uint32_t *sec, uint32_t *usec,
+ uint16_t len, uint16_t olen)
+{
+ struct timeval tv;
+ pcaprec_hdr_t fhdr;
+
+ if (!sec || !usec)
+ {
+ gettimeofday(&tv, NULL);
+ }
+ else
+ {
+ tv.tv_sec = *sec;
+ tv.tv_usec = *usec;
+ }
+
+ fhdr.ts_sec = tv.tv_sec;
+ fhdr.ts_usec = tv.tv_usec;
+ fhdr.incl_len = len;
+ fhdr.orig_len = olen;
+
+ fwrite(&fhdr, 1, sizeof(fhdr), o);
+}
+
+
+struct ringbuf * ringbuf_init(uint32_t num_item, uint16_t len_item)
+{
+ static struct ringbuf r;
+
+ if (len_item <= 0)
+ return NULL;
+
+ r.buf = malloc(num_item * (len_item + sizeof(struct ringbuf_entry)));
+
+ if (r.buf)
+ {
+ r.len = num_item;
+ r.fill = 0;
+ r.slen = (len_item + sizeof(struct ringbuf_entry));
+
+ memset(r.buf, 0, num_item * len_item);
+
+ return &r;
+ }
+
+ return NULL;
+}
+
+struct ringbuf_entry * ringbuf_add(struct ringbuf *r)
+{
+ struct timeval t;
+ struct ringbuf_entry *e;
+
+ gettimeofday(&t, NULL);
+
+ e = r->buf + (r->fill++ * r->slen);
+ r->fill %= r->len;
+
+ memset(e, 0, r->slen);
+
+ e->sec = t.tv_sec;
+ e->usec = t.tv_usec;
+
+ return e;
+}
+
+struct ringbuf_entry * ringbuf_get(struct ringbuf *r, int i)
+{
+ struct ringbuf_entry *e = r->buf + (((r->fill + i) % r->len) * r->slen);
+
+ if (e->len > 0)
+ return e;
+
+ return NULL;
+}
+
+void ringbuf_free(struct ringbuf *r)
+{
+ free(r->buf);
+ memset(r, 0, sizeof(*r));
+}
+
+
+void msg(const char *fmt, ...)
+{
+ va_list ap;
+ va_start(ap, fmt);
+
+ if (run_daemon)
+ vsyslog(LOG_INFO | LOG_USER, fmt, ap);
+ else
+ vfprintf(stderr, fmt, ap);
+
+ va_end(ap);
+}
+
+
+int main(int argc, char **argv)
+{
+ int i, n;
+ struct ringbuf *ring;
+ struct ringbuf_entry *e;
+ struct sockaddr_ll local = {
+ .sll_family = AF_PACKET,
+ .sll_protocol = htons(ETH_P_ALL)
+ };
+
+ radiotap_hdr_t *rhdr;
+
+ uint8_t frametype;
+ uint8_t pktbuf[0xFFFF];
+ ssize_t pktlen;
+
+ FILE *o;
+
+ int opt;
+
+ uint8_t promisc = 0;
+ uint8_t streaming = 0;
+ uint8_t foreground = 0;
+ uint8_t filter_data = 0;
+ uint8_t filter_beacon = 0;
+ uint8_t header_written = 0;
+
+ uint32_t ringsz = 1024 * 1024; /* 1 Mbyte ring buffer */
+ uint16_t pktcap = 256; /* truncate frames after 265KB */
+
+ const char *output = NULL;
+
+
+ while ((opt = getopt(argc, argv, "i:r:c:o:sfhBD")) != -1)
+ {
+ switch (opt)
+ {
+ case 'i':
+ ifname = optarg;
+ if (!(local.sll_ifindex = if_nametoindex(ifname)))
+ {
+ msg("Unknown interface '%s'\n", ifname);
+ return 2;
+ }
+ break;
+
+ case 'r':
+ ringsz = atoi(optarg);
+ if (ringsz < (3 * pktcap))
+ {
+ msg("Ring size of %d bytes is too short, "
+ "must be at least %d bytes\n", ringsz, 3 * pktcap);
+ return 3;
+ }
+ break;
+
+ case 'c':
+ pktcap = atoi(optarg);
+ if (pktcap <= (sizeof(radiotap_hdr_t) + LEN_IEEE802_11_HDR))
+ {
+ msg("Packet truncate after %d bytes is too short, "
+ "must be at least %d bytes\n",
+ pktcap, sizeof(radiotap_hdr_t) + LEN_IEEE802_11_HDR);
+ return 4;
+ }
+ break;
+
+ case 's':
+ streaming = 1;
+ break;
+
+ case 'o':
+ output = optarg;
+ break;
+
+ case 'B':
+ filter_beacon = 1;
+ break;
+
+ case 'D':
+ filter_data = 1;
+ break;
+
+ case 'f':
+ foreground = 1;
+ break;
+
+ case 'h':
+ msg(
+ "Usage:\n"
+ " %s -i {iface} -s [-b] [-d]\n"
+ " %s -i {iface} -o {file} [-r len] [-c len] [-B] [-D] [-f]\n"
+ "\n"
+ " -i iface\n"
+ " Specify interface to use, must be in monitor mode and\n"
+ " produce IEEE 802.11 Radiotap headers.\n\n"
+ " -s\n"
+ " Stream to stdout instead of Dumping to file on USR1.\n\n"
+ " -o file\n"
+ " Write current ringbuffer contents to given output file\n"
+ " on receipt of SIGUSR1.\n\n"
+ " -r len\n"
+ " Specify the amount of bytes to use for the ringbuffer.\n"
+ " The default length is %d bytes.\n\n"
+ " -c len\n"
+ " Truncate captured packets after given amount of bytes.\n"
+ " The default size limit is %d bytes.\n\n"
+ " -B\n"
+ " Don't store beacon frames in ring, default is keep.\n\n"
+ " -D\n"
+ " Don't store data frames in ring, default is keep.\n\n"
+ " -f\n"
+ " Do not daemonize but keep running in foreground.\n\n"
+ " -h\n"
+ " Display this help.\n\n",
+ argv[0], argv[0], ringsz, pktcap);
+
+ return 1;
+ }
+ }
+
+ if (!streaming && !output)
+ {
+ msg("No output file specified\n");
+ return 1;
+ }
+
+ if (streaming && output)
+ {
+ msg("The -s and -o options are exclusive\n");
+ return 1;
+ }
+
+ if (streaming && isatty(1))
+ {
+ msg("Refusing to stream into a terminal\n");
+ return 1;
+ }
+
+ if (!local.sll_ifindex)
+ {
+ msg("No interface specified\n");
+ return 2;
+ }
+
+ if (!check_type())
+ {
+ msg("Bad interface: not ARPHRD_IEEE80211_RADIOTAP\n");
+ return 2;
+ }
+
+ if ((capture_sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL))) < 0)
+ {
+ msg("Unable to create raw socket: %s\n",
+ strerror(errno));
+ return 6;
+ }
+
+ if (bind(capture_sock, (struct sockaddr *)&local, sizeof(local)) == -1)
+ {
+ msg("Unable to bind to interface: %s\n",
+ strerror(errno));
+ return 7;
+ }
+
+ if (!streaming)
+ {
+ if (!foreground)
+ {
+ switch (fork())
+ {
+ case -1:
+ msg("Unable to fork: %s\n", strerror(errno));
+ return 8;
+
+ case 0:
+ umask(0077);
+ chdir("/");
+ freopen("/dev/null", "r", stdin);
+ freopen("/dev/null", "w", stdout);
+ freopen("/dev/null", "w", stderr);
+ run_daemon = 1;
+ break;
+
+ default:
+ msg("Daemon launched ...\n");
+ return 0;
+ }
+ }
+
+ msg("Monitoring interface %s ...\n", ifname);
+
+ if (!(ring = ringbuf_init(ringsz / pktcap, pktcap)))
+ {
+ msg("Unable to allocate ring buffer: %s\n",
+ strerror(errno));
+ return 5;
+ }
+
+ msg(" * Using %d bytes ringbuffer with %d slots\n", ringsz, ring->len);
+ msg(" * Truncating frames at %d bytes\n", pktcap);
+ msg(" * Dumping data to file %s\n", output);
+
+ signal(SIGUSR1, sig_dump);
+ }
+ else
+ {
+ msg("Monitoring interface %s ...\n", ifname);
+ msg(" * Streaming data to stdout\n");
+ }
+
+ msg(" * Beacon frames are %sfiltered\n", filter_beacon ? "" : "not ");
+ msg(" * Data frames are %sfiltered\n", filter_data ? "" : "not ");
+
+ signal(SIGINT, sig_teardown);
+ signal(SIGTERM, sig_teardown);
+
+ promisc = set_promisc(1);
+
+ /* capture loop */
+ while (1)
+ {
+ if (run_stop)
+ {
+ msg("Shutting down ...\n");
+
+ if (promisc)
+ set_promisc(0);
+
+ if (ring)
+ ringbuf_free(ring);
+
+ return 0;
+ }
+ else if (run_dump)
+ {
+ msg("Dumping ring to %s ...\n", output);
+
+ if (!(o = fopen(output, "w")))
+ {
+ msg("Unable to open %s: %s\n",
+ output, strerror(errno));
+ }
+ else
+ {
+ write_pcap_header(o);
+
+ /* sig_dump packet buffer */
+ for (i = 0, n = 0; i < ring->len; i++)
+ {
+ if (!(e = ringbuf_get(ring, i)))
+ continue;
+
+ write_pcap_frame(o, &(e->sec), &(e->usec), e->len, e->olen);
+ fwrite((void *)e + sizeof(*e), 1, e->len, o);
+ n++;
+ }
+
+ fclose(o);
+
+ msg(" * %d frames captured\n", frames_captured);
+ msg(" * %d frames filtered\n", frames_filtered);
+ msg(" * %d frames dumped\n", n);
+ }
+
+ run_dump = 0;
+ }
+
+ pktlen = recvfrom(capture_sock, pktbuf, sizeof(pktbuf), 0, NULL, 0);
+ frames_captured++;
+
+ /* check received frametype, if we should filter it, rewind the ring */
+ rhdr = (radiotap_hdr_t *)pktbuf;
+
+ if (pktlen <= sizeof(radiotap_hdr_t) || le16(rhdr->it_len) >= pktlen)
+ {
+ frames_filtered++;
+ continue;
+ }
+
+ frametype = *(uint8_t *)(pktbuf + le16(rhdr->it_len));
+
+ if ((filter_data && (frametype & FRAMETYPE_MASK) == FRAMETYPE_DATA) ||
+ (filter_beacon && (frametype & FRAMETYPE_MASK) == FRAMETYPE_BEACON))
+ {
+ frames_filtered++;
+ continue;
+ }
+
+ if (streaming)
+ {
+ if (!header_written)
+ {
+ write_pcap_header(stdout);
+ header_written = 1;
+ }
+
+ write_pcap_frame(stdout, NULL, NULL, pktlen, pktlen);
+ fwrite(pktbuf, 1, pktlen, stdout);
+ fflush(stdout);
+ }
+ else
+ {
+ e = ringbuf_add(ring);
+ e->olen = pktlen;
+ e->len = (pktlen > pktcap) ? pktcap : pktlen;
+
+ memcpy((void *)e + sizeof(*e), pktbuf, e->len);
+ }
+ }
+
+ return 0;
+}
diff --git a/package/network/utils/iwinfo/.svn/entries b/package/network/utils/iwinfo/.svn/entries
new file mode 100644
index 0000000..3b781db
--- /dev/null
+++ b/package/network/utils/iwinfo/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/utils/iwinfo
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-02-03T12:03:24.606559Z
+35471
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+src
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+83e52bb7ce9c55aff23dbb697847fc0a
+2013-02-03T12:03:24.606559Z
+35471
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3036
+
diff --git a/package/network/utils/iwinfo/.svn/text-base/Makefile.svn-base b/package/network/utils/iwinfo/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..f8a92da
--- /dev/null
+++ b/package/network/utils/iwinfo/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,118 @@
+#
+# Copyright (C) 2010-2013 Jo-Philipp Wich <xm@subsignal.org>
+#
+# This is free software, licensed under the GPL 2 license.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=libiwinfo
+PKG_RELEASE:=39
+
+PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
+PKG_CONFIG_DEPENDS := \
+ CONFIG_PACKAGE_kmod-brcm-wl \
+ CONFIG_PACKAGE_kmod-brcm-wl-mini \
+ CONFIG_PACKAGE_kmod-brcm-wl-mimo \
+ CONFIG_PACKAGE_kmod-madwifi \
+ CONFIG_PACKAGE_kmod-mac80211
+
+include $(INCLUDE_DIR)/package.mk
+
+
+define Package/libiwinfo
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=Generalized Wireless Information Library (iwinfo)
+ DEPENDS:=+PACKAGE_kmod-mac80211:libnl-tiny
+ MAINTAINER:=Jo-Philipp Wich <xm@subsignal.org>
+endef
+
+define Package/libiwinfo/description
+ Wireless information library with consistent interface for proprietary Broadcom,
+ madwifi, nl80211 and wext driver interfaces.
+endef
+
+
+define Package/libiwinfo-lua
+ SUBMENU:=Lua
+ SECTION:=lang
+ CATEGORY:=Languages
+ TITLE:=libiwinfo Lua binding
+ DEPENDS:=+libiwinfo +liblua
+ MAINTAINER:=Jo-Philipp Wich <xm@subsignal.org>
+endef
+
+define Package/libiwinfo-lua/description
+ This is the Lua binding for the iwinfo library. It provides access to all enabled
+ backends.
+endef
+
+
+define Package/iwinfo
+ SECTION:=utils
+ CATEGORY:=Utilities
+ TITLE:=Generalized Wireless Information utility
+ DEPENDS:=+libiwinfo
+ MAINTAINER:=Jo-Philipp Wich <xm@subsignal.org>
+endef
+
+define Package/iwinfo/description
+ Command line frontend for the wireless information library.
+endef
+
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+define Build/Configure
+endef
+
+IWINFO_BACKENDS := \
+ $(if $(CONFIG_PACKAGE_kmod-brcm-wl),wl) \
+ $(if $(CONFIG_PACKAGE_kmod-brcm-wl-mini),wl) \
+ $(if $(CONFIG_PACKAGE_kmod-brcm-wl-mimo),wl) \
+ $(if $(CONFIG_PACKAGE_kmod-madwifi),madwifi) \
+ $(if $(CONFIG_PACKAGE_kmod-mac80211),nl80211)
+
+TARGET_CFLAGS += \
+ -I$(STAGING_DIR)/usr/include/libnl-tiny \
+ -I$(STAGING_DIR)/usr/include \
+ -D_GNU_SOURCE
+
+MAKE_FLAGS += \
+ FPIC="$(FPIC)" \
+ CFLAGS="$(TARGET_CFLAGS)" \
+ LDFLAGS="$(TARGET_LDFLAGS)" \
+ BACKENDS="$(IWINFO_BACKENDS)"
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include/iwinfo
+ $(CP) $(PKG_BUILD_DIR)/include/iwinfo.h $(1)/usr/include/
+ $(CP) $(PKG_BUILD_DIR)/include/iwinfo/* $(1)/usr/include/iwinfo/
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/libiwinfo.so $(1)/usr/lib/libiwinfo.so
+ $(INSTALL_DIR) $(1)/usr/lib/lua
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/iwinfo.so $(1)/usr/lib/lua/iwinfo.so
+endef
+
+define Package/libiwinfo/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/libiwinfo.so $(1)/usr/lib/libiwinfo.so
+endef
+
+define Package/libiwinfo-lua/install
+ $(INSTALL_DIR) $(1)/usr/lib/lua
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/iwinfo.so $(1)/usr/lib/lua/iwinfo.so
+endef
+
+define Package/iwinfo/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/iwinfo $(1)/usr/bin/iwinfo
+endef
+
+$(eval $(call BuildPackage,libiwinfo))
+$(eval $(call BuildPackage,libiwinfo-lua))
+$(eval $(call BuildPackage,iwinfo))
diff --git a/package/network/utils/iwinfo/Makefile b/package/network/utils/iwinfo/Makefile
new file mode 100644
index 0000000..f8a92da
--- /dev/null
+++ b/package/network/utils/iwinfo/Makefile
@@ -0,0 +1,118 @@
+#
+# Copyright (C) 2010-2013 Jo-Philipp Wich <xm@subsignal.org>
+#
+# This is free software, licensed under the GPL 2 license.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=libiwinfo
+PKG_RELEASE:=39
+
+PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
+PKG_CONFIG_DEPENDS := \
+ CONFIG_PACKAGE_kmod-brcm-wl \
+ CONFIG_PACKAGE_kmod-brcm-wl-mini \
+ CONFIG_PACKAGE_kmod-brcm-wl-mimo \
+ CONFIG_PACKAGE_kmod-madwifi \
+ CONFIG_PACKAGE_kmod-mac80211
+
+include $(INCLUDE_DIR)/package.mk
+
+
+define Package/libiwinfo
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=Generalized Wireless Information Library (iwinfo)
+ DEPENDS:=+PACKAGE_kmod-mac80211:libnl-tiny
+ MAINTAINER:=Jo-Philipp Wich <xm@subsignal.org>
+endef
+
+define Package/libiwinfo/description
+ Wireless information library with consistent interface for proprietary Broadcom,
+ madwifi, nl80211 and wext driver interfaces.
+endef
+
+
+define Package/libiwinfo-lua
+ SUBMENU:=Lua
+ SECTION:=lang
+ CATEGORY:=Languages
+ TITLE:=libiwinfo Lua binding
+ DEPENDS:=+libiwinfo +liblua
+ MAINTAINER:=Jo-Philipp Wich <xm@subsignal.org>
+endef
+
+define Package/libiwinfo-lua/description
+ This is the Lua binding for the iwinfo library. It provides access to all enabled
+ backends.
+endef
+
+
+define Package/iwinfo
+ SECTION:=utils
+ CATEGORY:=Utilities
+ TITLE:=Generalized Wireless Information utility
+ DEPENDS:=+libiwinfo
+ MAINTAINER:=Jo-Philipp Wich <xm@subsignal.org>
+endef
+
+define Package/iwinfo/description
+ Command line frontend for the wireless information library.
+endef
+
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+define Build/Configure
+endef
+
+IWINFO_BACKENDS := \
+ $(if $(CONFIG_PACKAGE_kmod-brcm-wl),wl) \
+ $(if $(CONFIG_PACKAGE_kmod-brcm-wl-mini),wl) \
+ $(if $(CONFIG_PACKAGE_kmod-brcm-wl-mimo),wl) \
+ $(if $(CONFIG_PACKAGE_kmod-madwifi),madwifi) \
+ $(if $(CONFIG_PACKAGE_kmod-mac80211),nl80211)
+
+TARGET_CFLAGS += \
+ -I$(STAGING_DIR)/usr/include/libnl-tiny \
+ -I$(STAGING_DIR)/usr/include \
+ -D_GNU_SOURCE
+
+MAKE_FLAGS += \
+ FPIC="$(FPIC)" \
+ CFLAGS="$(TARGET_CFLAGS)" \
+ LDFLAGS="$(TARGET_LDFLAGS)" \
+ BACKENDS="$(IWINFO_BACKENDS)"
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include/iwinfo
+ $(CP) $(PKG_BUILD_DIR)/include/iwinfo.h $(1)/usr/include/
+ $(CP) $(PKG_BUILD_DIR)/include/iwinfo/* $(1)/usr/include/iwinfo/
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/libiwinfo.so $(1)/usr/lib/libiwinfo.so
+ $(INSTALL_DIR) $(1)/usr/lib/lua
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/iwinfo.so $(1)/usr/lib/lua/iwinfo.so
+endef
+
+define Package/libiwinfo/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/libiwinfo.so $(1)/usr/lib/libiwinfo.so
+endef
+
+define Package/libiwinfo-lua/install
+ $(INSTALL_DIR) $(1)/usr/lib/lua
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/iwinfo.so $(1)/usr/lib/lua/iwinfo.so
+endef
+
+define Package/iwinfo/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/iwinfo $(1)/usr/bin/iwinfo
+endef
+
+$(eval $(call BuildPackage,libiwinfo))
+$(eval $(call BuildPackage,libiwinfo-lua))
+$(eval $(call BuildPackage,iwinfo))
diff --git a/package/network/utils/iwinfo/src/.svn/entries b/package/network/utils/iwinfo/src/.svn/entries
new file mode 100644
index 0000000..074e71f
--- /dev/null
+++ b/package/network/utils/iwinfo/src/.svn/entries
@@ -0,0 +1,405 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/utils/iwinfo/src
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-02-03T12:03:24.606559Z
+35471
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+iwinfo_nl80211.c
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+bb86c5d11142be9e72c97e32b41ba20e
+2013-01-04T14:08:08.691763Z
+35007
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+50569
+
+iwinfo_lib.c
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+1377e07a785dbd34c567a2232e6036ba
+2013-01-02T19:10:29.781239Z
+34982
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+16010
+
+include
+dir
+
+iwinfo_cli.c
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+0413ba2472e41009ab5fa4d5288a657c
+2012-03-05T17:52:46.765236Z
+30825
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+16362
+
+iwinfo_wext.c
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+963d4be006ccc0d796c61992d0386bc5
+2012-02-23T13:16:09.383816Z
+30692
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+10161
+
+iwinfo_wext_scan.c
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+149ccf5fa47e1d32a7fc4e9d23125e89
+2012-02-23T13:16:09.383816Z
+30692
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+13619
+
+COPYING
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+751419260aa954499f7abaabaa882bbe
+2011-12-03T13:57:38.074666Z
+29403
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+17987
+
+iwinfo_madwifi.c
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+4dcacfe0f02eb819df8ef37e938592dd
+2012-08-14T10:33:40.189807Z
+33180
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+25767
+
+iwinfo_utils.c
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+4f95bd7f48c4f1dad2387cc35a890c80
+2013-02-03T12:03:24.606559Z
+35471
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+7745
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+eeda98cc839124fb4ee9ca56e6700b15
+2011-12-03T13:57:38.074666Z
+29403
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1297
+
+iwinfo_lua.c
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+4d47f737663540493ec64cf5489285ba
+2012-05-28T00:52:26.626723Z
+31932
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+19971
+
+iwinfo_wl.c
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+126cb26afc6f6c1205d2615121073c2e
+2012-02-23T18:20:51.092372Z
+30693
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+13419
+
diff --git a/package/network/utils/iwinfo/src/.svn/text-base/COPYING.svn-base b/package/network/utils/iwinfo/src/.svn/text-base/COPYING.svn-base
new file mode 100644
index 0000000..d511905
--- /dev/null
+++ b/package/network/utils/iwinfo/src/.svn/text-base/COPYING.svn-base
@@ -0,0 +1,339 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ 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 of the License, 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; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.
diff --git a/package/network/utils/iwinfo/src/.svn/text-base/Makefile.svn-base b/package/network/utils/iwinfo/src/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..572bef9
--- /dev/null
+++ b/package/network/utils/iwinfo/src/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,44 @@
+IWINFO_BACKENDS = $(BACKENDS)
+IWINFO_CFLAGS = $(CFLAGS) -std=gnu99 -fstrict-aliasing -Iinclude
+
+IWINFO_LIB = libiwinfo.so
+IWINFO_LIB_LDFLAGS = $(LDFLAGS) -shared
+IWINFO_LIB_OBJ = iwinfo_utils.o iwinfo_wext.o iwinfo_wext_scan.o iwinfo_lib.o
+
+IWINFO_LUA = iwinfo.so
+IWINFO_LUA_LDFLAGS = $(LDFLAGS) -shared -L. -liwinfo -llua
+IWINFO_LUA_OBJ = iwinfo_lua.o
+
+IWINFO_CLI = iwinfo
+IWINFO_CLI_LDFLAGS = $(LDFLAGS) -L. -liwinfo
+IWINFO_CLI_OBJ = iwinfo_cli.o
+
+
+ifneq ($(filter wl,$(IWINFO_BACKENDS)),)
+ IWINFO_CFLAGS += -DUSE_WL
+ IWINFO_LIB_OBJ += iwinfo_wl.o
+endif
+
+ifneq ($(filter madwifi,$(IWINFO_BACKENDS)),)
+ IWINFO_CFLAGS += -DUSE_MADWIFI
+ IWINFO_LIB_OBJ += iwinfo_madwifi.o
+endif
+
+ifneq ($(filter nl80211,$(IWINFO_BACKENDS)),)
+ IWINFO_CFLAGS += -DUSE_NL80211
+ IWINFO_CLI_LDFLAGS += -lnl-tiny
+ IWINFO_LIB_LDFLAGS += -lnl-tiny
+ IWINFO_LIB_OBJ += iwinfo_nl80211.o
+endif
+
+
+%.o: %.c
+ $(CC) $(IWINFO_CFLAGS) $(FPIC) -c -o $@ $<
+
+compile: clean $(IWINFO_LIB_OBJ) $(IWINFO_LUA_OBJ) $(IWINFO_CLI_OBJ)
+ $(CC) $(IWINFO_LIB_LDFLAGS) -o $(IWINFO_LIB) $(IWINFO_LIB_OBJ)
+ $(CC) $(IWINFO_LUA_LDFLAGS) -o $(IWINFO_LUA) $(IWINFO_LUA_OBJ)
+ $(CC) $(IWINFO_CLI_LDFLAGS) -o $(IWINFO_CLI) $(IWINFO_CLI_OBJ)
+
+clean:
+ rm -f *.o $(IWINFO_LIB) $(IWINFO_LUA) $(IWINFO_CLI)
diff --git a/package/network/utils/iwinfo/src/.svn/text-base/iwinfo_cli.c.svn-base b/package/network/utils/iwinfo/src/.svn/text-base/iwinfo_cli.c.svn-base
new file mode 100644
index 0000000..7ec5aef
--- /dev/null
+++ b/package/network/utils/iwinfo/src/.svn/text-base/iwinfo_cli.c.svn-base
@@ -0,0 +1,800 @@
+/*
+ * iwinfo - Wireless Information Library - Command line frontend
+ *
+ * Copyright (C) 2011 Jo-Philipp Wich <xm@subsignal.org>
+ *
+ * The iwinfo library is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * The iwinfo library 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 the iwinfo library. If not, see http://www.gnu.org/licenses/.
+ */
+
+#include <stdio.h>
+
+#include "iwinfo.h"
+
+
+static char * format_bssid(unsigned char *mac)
+{
+ static char buf[18];
+
+ snprintf(buf, sizeof(buf), "%02X:%02X:%02X:%02X:%02X:%02X",
+ mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
+
+ return buf;
+}
+
+static char * format_ssid(char *ssid)
+{
+ static char buf[IWINFO_ESSID_MAX_SIZE+3];
+
+ if (ssid && ssid[0])
+ snprintf(buf, sizeof(buf), "\"%s\"", ssid);
+ else
+ snprintf(buf, sizeof(buf), "unknown");
+
+ return buf;
+}
+
+static char * format_channel(int ch)
+{
+ static char buf[8];
+
+ if (ch <= 0)
+ snprintf(buf, sizeof(buf), "unknown");
+ else
+ snprintf(buf, sizeof(buf), "%d", ch);
+
+ return buf;
+}
+
+static char * format_frequency(int freq)
+{
+ static char buf[10];
+
+ if (freq <= 0)
+ snprintf(buf, sizeof(buf), "unknown");
+ else
+ snprintf(buf, sizeof(buf), "%.3f GHz", ((float)freq / 1000.0));
+
+ return buf;
+}
+
+static char * format_txpower(int pwr)
+{
+ static char buf[10];
+
+ if (pwr < 0)
+ snprintf(buf, sizeof(buf), "unknown");
+ else
+ snprintf(buf, sizeof(buf), "%d dBm", pwr);
+
+ return buf;
+}
+
+static char * format_quality(int qual)
+{
+ static char buf[8];
+
+ if (qual < 0)
+ snprintf(buf, sizeof(buf), "unknown");
+ else
+ snprintf(buf, sizeof(buf), "%d", qual);
+
+ return buf;
+}
+
+static char * format_quality_max(int qmax)
+{
+ static char buf[8];
+
+ if (qmax < 0)
+ snprintf(buf, sizeof(buf), "unknown");
+ else
+ snprintf(buf, sizeof(buf), "%d", qmax);
+
+ return buf;
+}
+
+static char * format_signal(int sig)
+{
+ static char buf[10];
+
+ if (!sig)
+ snprintf(buf, sizeof(buf), "unknown");
+ else
+ snprintf(buf, sizeof(buf), "%d dBm", sig);
+
+ return buf;
+}
+
+static char * format_noise(int noise)
+{
+ static char buf[10];
+
+ if (!noise)
+ snprintf(buf, sizeof(buf), "unknown");
+ else
+ snprintf(buf, sizeof(buf), "%d dBm", noise);
+
+ return buf;
+}
+
+static char * format_rate(int rate)
+{
+ static char buf[14];
+
+ if (rate <= 0)
+ snprintf(buf, sizeof(buf), "unknown");
+ else
+ snprintf(buf, sizeof(buf), "%d.%d MBit/s",
+ rate / 1000, (rate % 1000) / 100);
+
+ return buf;
+}
+
+static char * format_enc_ciphers(int ciphers)
+{
+ static char str[128] = { 0 };
+ char *pos = str;
+
+ if (ciphers & IWINFO_CIPHER_WEP40)
+ pos += sprintf(pos, "WEP-40, ");
+
+ if (ciphers & IWINFO_CIPHER_WEP104)
+ pos += sprintf(pos, "WEP-104, ");
+
+ if (ciphers & IWINFO_CIPHER_TKIP)
+ pos += sprintf(pos, "TKIP, ");
+
+ if (ciphers & IWINFO_CIPHER_CCMP)
+ pos += sprintf(pos, "CCMP, ");
+
+ if (ciphers & IWINFO_CIPHER_WRAP)
+ pos += sprintf(pos, "WRAP, ");
+
+ if (ciphers & IWINFO_CIPHER_AESOCB)
+ pos += sprintf(pos, "AES-OCB, ");
+
+ if (ciphers & IWINFO_CIPHER_CKIP)
+ pos += sprintf(pos, "CKIP, ");
+
+ if (!ciphers || (ciphers & IWINFO_CIPHER_NONE))
+ pos += sprintf(pos, "NONE, ");
+
+ *(pos - 2) = 0;
+
+ return str;
+}
+
+static char * format_enc_suites(int suites)
+{
+ static char str[64] = { 0 };
+ char *pos = str;
+
+ if (suites & IWINFO_KMGMT_PSK)
+ pos += sprintf(pos, "PSK/");
+
+ if (suites & IWINFO_KMGMT_8021x)
+ pos += sprintf(pos, "802.1X/");
+
+ if (!suites || (suites & IWINFO_KMGMT_NONE))
+ pos += sprintf(pos, "NONE/");
+
+ *(pos - 1) = 0;
+
+ return str;
+}
+
+static char * format_encryption(struct iwinfo_crypto_entry *c)
+{
+ static char buf[512];
+
+ if (!c)
+ {
+ snprintf(buf, sizeof(buf), "unknown");
+ }
+ else if (c->enabled)
+ {
+ /* WEP */
+ if (c->auth_algs && !c->wpa_version)
+ {
+ if ((c->auth_algs & IWINFO_AUTH_OPEN) &&
+ (c->auth_algs & IWINFO_AUTH_SHARED))
+ {
+ snprintf(buf, sizeof(buf), "WEP Open/Shared (%s)",
+ format_enc_ciphers(c->pair_ciphers));
+ }
+ else if (c->auth_algs & IWINFO_AUTH_OPEN)
+ {
+ snprintf(buf, sizeof(buf), "WEP Open System (%s)",
+ format_enc_ciphers(c->pair_ciphers));
+ }
+ else if (c->auth_algs & IWINFO_AUTH_SHARED)
+ {
+ snprintf(buf, sizeof(buf), "WEP Shared Auth (%s)",
+ format_enc_ciphers(c->pair_ciphers));
+ }
+ }
+
+ /* WPA */
+ else if (c->wpa_version)
+ {
+ switch (c->wpa_version) {
+ case 3:
+ snprintf(buf, sizeof(buf), "mixed WPA/WPA2 %s (%s)",
+ format_enc_suites(c->auth_suites),
+ format_enc_ciphers(c->pair_ciphers | c->group_ciphers));
+ break;
+
+ case 2:
+ snprintf(buf, sizeof(buf), "WPA2 %s (%s)",
+ format_enc_suites(c->auth_suites),
+ format_enc_ciphers(c->pair_ciphers | c->group_ciphers));
+ break;
+
+ case 1:
+ snprintf(buf, sizeof(buf), "WPA %s (%s)",
+ format_enc_suites(c->auth_suites),
+ format_enc_ciphers(c->pair_ciphers | c->group_ciphers));
+ break;
+ }
+ }
+ else
+ {
+ snprintf(buf, sizeof(buf), "none");
+ }
+ }
+ else
+ {
+ snprintf(buf, sizeof(buf), "none");
+ }
+
+ return buf;
+}
+
+static char * format_hwmodes(int modes)
+{
+ static char buf[12];
+
+ if (modes <= 0)
+ snprintf(buf, sizeof(buf), "unknown");
+ else
+ snprintf(buf, sizeof(buf), "802.11%s%s%s%s",
+ (modes & IWINFO_80211_A) ? "a" : "",
+ (modes & IWINFO_80211_B) ? "b" : "",
+ (modes & IWINFO_80211_G) ? "g" : "",
+ (modes & IWINFO_80211_N) ? "n" : "");
+
+ return buf;
+}
+
+static char * format_assocrate(struct iwinfo_rate_entry *r)
+{
+ static char buf[40];
+ char *p = buf;
+ int l = sizeof(buf);
+
+ if (r->rate <= 0)
+ {
+ snprintf(buf, sizeof(buf), "unknown");
+ }
+ else
+ {
+ p += snprintf(p, l, "%s", format_rate(r->rate));
+ l = sizeof(buf) - (p - buf);
+
+ if (r->mcs >= 0)
+ {
+ p += snprintf(p, l, ", MCS %d, %dMHz", r->mcs, 20 + r->is_40mhz*20);
+ l = sizeof(buf) - (p - buf);
+
+ if (r->is_short_gi)
+ p += snprintf(p, l, ", short GI");
+ }
+ }
+
+ return buf;
+}
+
+
+static const char * print_type(const struct iwinfo_ops *iw, const char *ifname)
+{
+ const char *type = iwinfo_type(ifname);
+ return type ? type : "unknown";
+}
+
+static char * print_hardware_id(const struct iwinfo_ops *iw, const char *ifname)
+{
+ static char buf[20];
+ struct iwinfo_hardware_id ids;
+
+ if (!iw->hardware_id(ifname, (char *)&ids))
+ {
+ snprintf(buf, sizeof(buf), "%04X:%04X %04X:%04X",
+ ids.vendor_id, ids.device_id,
+ ids.subsystem_vendor_id, ids.subsystem_device_id);
+ }
+ else
+ {
+ snprintf(buf, sizeof(buf), "unknown");
+ }
+
+ return buf;
+}
+
+static char * print_hardware_name(const struct iwinfo_ops *iw, const char *ifname)
+{
+ static char buf[128];
+
+ if (iw->hardware_name(ifname, buf))
+ snprintf(buf, sizeof(buf), "unknown");
+
+ return buf;
+}
+
+static char * print_txpower_offset(const struct iwinfo_ops *iw, const char *ifname)
+{
+ int off;
+ static char buf[12];
+
+ if (iw->txpower_offset(ifname, &off))
+ snprintf(buf, sizeof(buf), "unknown");
+ else if (off != 0)
+ snprintf(buf, sizeof(buf), "%d dB", off);
+ else
+ snprintf(buf, sizeof(buf), "none");
+
+ return buf;
+}
+
+static char * print_frequency_offset(const struct iwinfo_ops *iw, const char *ifname)
+{
+ int off;
+ static char buf[12];
+
+ if (iw->frequency_offset(ifname, &off))
+ snprintf(buf, sizeof(buf), "unknown");
+ else if (off != 0)
+ snprintf(buf, sizeof(buf), "%.3f GHz", ((float)off / 1000.0));
+ else
+ snprintf(buf, sizeof(buf), "none");
+
+ return buf;
+}
+
+static char * print_ssid(const struct iwinfo_ops *iw, const char *ifname)
+{
+ char buf[IWINFO_ESSID_MAX_SIZE+1] = { 0 };
+
+ if (iw->ssid(ifname, buf))
+ memset(buf, 0, sizeof(buf));
+
+ return format_ssid(buf);
+}
+
+static char * print_bssid(const struct iwinfo_ops *iw, const char *ifname)
+{
+ static char buf[18] = { 0 };
+
+ if (iw->bssid(ifname, buf))
+ snprintf(buf, sizeof(buf), "00:00:00:00:00:00");
+
+ return buf;
+}
+
+static char * print_mode(const struct iwinfo_ops *iw, const char *ifname)
+{
+ int mode;
+ static char buf[128];
+
+ if (iw->mode(ifname, &mode))
+ mode = IWINFO_OPMODE_UNKNOWN;
+
+ snprintf(buf, sizeof(buf), "%s", IWINFO_OPMODE_NAMES[mode]);
+
+ return buf;
+}
+
+static char * print_channel(const struct iwinfo_ops *iw, const char *ifname)
+{
+ int ch;
+ if (iw->channel(ifname, &ch))
+ ch = -1;
+
+ return format_channel(ch);
+}
+
+static char * print_frequency(const struct iwinfo_ops *iw, const char *ifname)
+{
+ int freq;
+ if (iw->frequency(ifname, &freq))
+ freq = -1;
+
+ return format_frequency(freq);
+}
+
+static char * print_txpower(const struct iwinfo_ops *iw, const char *ifname)
+{
+ int pwr, off;
+ if (iw->txpower_offset(ifname, &off))
+ off = 0;
+
+ if (iw->txpower(ifname, &pwr))
+ pwr = -1;
+ else
+ pwr += off;
+
+ return format_txpower(pwr);
+}
+
+static char * print_quality(const struct iwinfo_ops *iw, const char *ifname)
+{
+ int qual;
+ if (iw->quality(ifname, &qual))
+ qual = -1;
+
+ return format_quality(qual);
+}
+
+static char * print_quality_max(const struct iwinfo_ops *iw, const char *ifname)
+{
+ int qmax;
+ if (iw->quality_max(ifname, &qmax))
+ qmax = -1;
+
+ return format_quality_max(qmax);
+}
+
+static char * print_signal(const struct iwinfo_ops *iw, const char *ifname)
+{
+ int sig;
+ if (iw->signal(ifname, &sig))
+ sig = 0;
+
+ return format_signal(sig);
+}
+
+static char * print_noise(const struct iwinfo_ops *iw, const char *ifname)
+{
+ int noise;
+ if (iw->noise(ifname, &noise))
+ noise = 0;
+
+ return format_noise(noise);
+}
+
+static char * print_rate(const struct iwinfo_ops *iw, const char *ifname)
+{
+ int rate;
+ if (iw->bitrate(ifname, &rate))
+ rate = -1;
+
+ return format_rate(rate);
+}
+
+static char * print_encryption(const struct iwinfo_ops *iw, const char *ifname)
+{
+ struct iwinfo_crypto_entry c = { 0 };
+ if (iw->encryption(ifname, (char *)&c))
+ return format_encryption(NULL);
+
+ return format_encryption(&c);
+}
+
+static char * print_hwmodes(const struct iwinfo_ops *iw, const char *ifname)
+{
+ int modes;
+ if (iw->hwmodelist(ifname, &modes))
+ modes = -1;
+
+ return format_hwmodes(modes);
+}
+
+static char * print_mbssid_supp(const struct iwinfo_ops *iw, const char *ifname)
+{
+ int supp;
+ static char buf[4];
+
+ if (iw->mbssid_support(ifname, &supp))
+ snprintf(buf, sizeof(buf), "no");
+ else
+ snprintf(buf, sizeof(buf), "%s", supp ? "yes" : "no");
+
+ return buf;
+}
+
+
+static void print_info(const struct iwinfo_ops *iw, const char *ifname)
+{
+ printf("%-9s ESSID: %s\n",
+ ifname,
+ print_ssid(iw, ifname));
+ printf(" Access Point: %s\n",
+ print_bssid(iw, ifname));
+ printf(" Mode: %s Channel: %s (%s)\n",
+ print_mode(iw, ifname),
+ print_channel(iw, ifname),
+ print_frequency(iw, ifname));
+ printf(" Tx-Power: %s Link Quality: %s/%s\n",
+ print_txpower(iw, ifname),
+ print_quality(iw, ifname),
+ print_quality_max(iw, ifname));
+ printf(" Signal: %s Noise: %s\n",
+ print_signal(iw, ifname),
+ print_noise(iw, ifname));
+ printf(" Bit Rate: %s\n",
+ print_rate(iw, ifname));
+ printf(" Encryption: %s\n",
+ print_encryption(iw, ifname));
+ printf(" Type: %s HW Mode(s): %s\n",
+ print_type(iw, ifname),
+ print_hwmodes(iw, ifname));
+ printf(" Hardware: %s [%s]\n",
+ print_hardware_id(iw, ifname),
+ print_hardware_name(iw, ifname));
+ printf(" TX power offset: %s\n",
+ print_txpower_offset(iw, ifname));
+ printf(" Frequency offset: %s\n",
+ print_frequency_offset(iw, ifname));
+ printf(" Supports VAPs: %s\n",
+ print_mbssid_supp(iw, ifname));
+}
+
+
+static void print_scanlist(const struct iwinfo_ops *iw, const char *ifname)
+{
+ int i, x, len;
+ char buf[IWINFO_BUFSIZE];
+ struct iwinfo_scanlist_entry *e;
+
+ if (iw->scanlist(ifname, buf, &len))
+ {
+ printf("Scanning not possible\n\n");
+ return;
+ }
+ else if (len <= 0)
+ {
+ printf("No scan results\n\n");
+ return;
+ }
+
+ for (i = 0, x = 1; i < len; i += sizeof(struct iwinfo_scanlist_entry), x++)
+ {
+ e = (struct iwinfo_scanlist_entry *) &buf[i];
+
+ printf("Cell %02d - Address: %s\n",
+ x,
+ format_bssid(e->mac));
+ printf(" ESSID: %s\n",
+ format_ssid(e->ssid));
+ printf(" Mode: %s Channel: %s\n",
+ IWINFO_OPMODE_NAMES[e->mode],
+ format_channel(e->channel));
+ printf(" Signal: %s Quality: %s/%s\n",
+ format_signal(e->signal - 0x100),
+ format_quality(e->quality),
+ format_quality_max(e->quality_max));
+ printf(" Encryption: %s\n\n",
+ format_encryption(&e->crypto));
+ }
+}
+
+
+static void print_txpwrlist(const struct iwinfo_ops *iw, const char *ifname)
+{
+ int len, pwr, off, i;
+ char buf[IWINFO_BUFSIZE];
+ struct iwinfo_txpwrlist_entry *e;
+
+ if (iw->txpwrlist(ifname, buf, &len) || len <= 0)
+ {
+ printf("No TX power information available\n");
+ return;
+ }
+
+ if (iw->txpower(ifname, &pwr))
+ pwr = -1;
+
+ if (iw->txpower_offset(ifname, &off))
+ off = 0;
+
+ for (i = 0; i < len; i += sizeof(struct iwinfo_txpwrlist_entry))
+ {
+ e = (struct iwinfo_txpwrlist_entry *) &buf[i];
+
+ printf("%s%3d dBm (%4d mW)\n",
+ (pwr == e->dbm) ? "*" : " ",
+ e->dbm + off,
+ iwinfo_dbm2mw(e->dbm + off));
+ }
+}
+
+
+static void print_freqlist(const struct iwinfo_ops *iw, const char *ifname)
+{
+ int i, len, ch;
+ char buf[IWINFO_BUFSIZE];
+ struct iwinfo_freqlist_entry *e;
+
+ if (iw->freqlist(ifname, buf, &len) || len <= 0)
+ {
+ printf("No frequency information available\n");
+ return;
+ }
+
+ if (iw->channel(ifname, &ch))
+ ch = -1;
+
+ for (i = 0; i < len; i += sizeof(struct iwinfo_freqlist_entry))
+ {
+ e = (struct iwinfo_freqlist_entry *) &buf[i];
+
+ printf("%s %s (Channel %s)%s\n",
+ (ch == e->channel) ? "*" : " ",
+ format_frequency(e->mhz),
+ format_channel(e->channel),
+ e->restricted ? " [restricted]" : "");
+ }
+}
+
+
+static void print_assoclist(const struct iwinfo_ops *iw, const char *ifname)
+{
+ int i, len;
+ char buf[IWINFO_BUFSIZE];
+ struct iwinfo_assoclist_entry *e;
+
+ if (iw->assoclist(ifname, buf, &len))
+ {
+ printf("No information available\n");
+ return;
+ }
+ else if (len <= 0)
+ {
+ printf("No station connected\n");
+ return;
+ }
+
+ for (i = 0; i < len; i += sizeof(struct iwinfo_assoclist_entry))
+ {
+ e = (struct iwinfo_assoclist_entry *) &buf[i];
+
+ printf("%s %s / %s (SNR %d) %d ms ago\n",
+ format_bssid(e->mac),
+ format_signal(e->signal),
+ format_noise(e->noise),
+ (e->signal - e->noise),
+ e->inactive);
+
+ printf(" RX: %-38s %8d Pkts.\n",
+ format_assocrate(&e->rx_rate),
+ e->rx_packets
+ );
+
+ printf(" TX: %-38s %8d Pkts.\n\n",
+ format_assocrate(&e->tx_rate),
+ e->tx_packets
+ );
+ }
+}
+
+
+static char * lookup_country(char *buf, int len, int iso3166)
+{
+ int i;
+ struct iwinfo_country_entry *c;
+
+ for (i = 0; i < len; i += sizeof(struct iwinfo_country_entry))
+ {
+ c = (struct iwinfo_country_entry *) &buf[i];
+
+ if (c->iso3166 == iso3166)
+ return c->ccode;
+ }
+
+ return NULL;
+}
+
+static void print_countrylist(const struct iwinfo_ops *iw, const char *ifname)
+{
+ int len;
+ char buf[IWINFO_BUFSIZE];
+ char *ccode;
+ char curcode[3];
+ const struct iwinfo_iso3166_label *l;
+
+ if (iw->countrylist(ifname, buf, &len))
+ {
+ printf("No country code information available\n");
+ return;
+ }
+
+ if (iw->country(ifname, curcode))
+ memset(curcode, 0, sizeof(curcode));
+
+ for (l = IWINFO_ISO3166_NAMES; l->iso3166; l++)
+ {
+ if ((ccode = lookup_country(buf, len, l->iso3166)) != NULL)
+ {
+ printf("%s %4s %c%c\n",
+ strncmp(ccode, curcode, 2) ? " " : "*",
+ ccode, (l->iso3166 / 256), (l->iso3166 % 256));
+ }
+ }
+}
+
+
+int main(int argc, char **argv)
+{
+ int i;
+ const struct iwinfo_ops *iw;
+
+ if (argc < 3)
+ {
+ fprintf(stderr,
+ "Usage:\n"
+ " iwinfo <device> info\n"
+ " iwinfo <device> scan\n"
+ " iwinfo <device> txpowerlist\n"
+ " iwinfo <device> freqlist\n"
+ " iwinfo <device> assoclist\n"
+ " iwinfo <device> countrylist\n"
+ );
+
+ return 1;
+ }
+
+ iw = iwinfo_backend(argv[1]);
+
+ if (!iw)
+ {
+ fprintf(stderr, "No such wireless device: %s\n", argv[1]);
+ return 1;
+ }
+
+ for (i = 2; i < argc; i++)
+ {
+ switch(argv[i][0])
+ {
+ case 'i':
+ print_info(iw, argv[1]);
+ break;
+
+ case 's':
+ print_scanlist(iw, argv[1]);
+ break;
+
+ case 't':
+ print_txpwrlist(iw, argv[1]);
+ break;
+
+ case 'f':
+ print_freqlist(iw, argv[1]);
+ break;
+
+ case 'a':
+ print_assoclist(iw, argv[1]);
+ break;
+
+ case 'c':
+ print_countrylist(iw, argv[1]);
+ break;
+
+ default:
+ fprintf(stderr, "Unknown command: %s\n", argv[i]);
+ return 1;
+ }
+ }
+
+ iwinfo_finish();
+
+ return 0;
+}
diff --git a/package/network/utils/iwinfo/src/.svn/text-base/iwinfo_lib.c.svn-base b/package/network/utils/iwinfo/src/.svn/text-base/iwinfo_lib.c.svn-base
new file mode 100644
index 0000000..e943546
--- /dev/null
+++ b/package/network/utils/iwinfo/src/.svn/text-base/iwinfo_lib.c.svn-base
@@ -0,0 +1,458 @@
+/*
+ * iwinfo - Wireless Information Library - Lua Bindings
+ *
+ * Copyright (C) 2009-2013 Jo-Philipp Wich <xm@subsignal.org>
+ *
+ * The iwinfo library is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * The iwinfo library 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 the iwinfo library. If not, see http://www.gnu.org/licenses/.
+ */
+
+#include "iwinfo.h"
+
+
+/*
+ * name constants
+ */
+const char *IWINFO_CIPHER_NAMES[] = {
+ "NONE",
+ "WEP40",
+ "TKIP",
+ "WRAP",
+ "CCMP",
+ "WEP104",
+ "AES-OCB",
+ "CKIP",
+};
+
+const char *IWINFO_KMGMT_NAMES[] = {
+ "NONE",
+ "802.1X",
+ "PSK",
+};
+
+const char *IWINFO_AUTH_NAMES[] = {
+ "OPEN",
+ "SHARED",
+};
+
+const char *IWINFO_OPMODE_NAMES[] = {
+ "Unknown",
+ "Master",
+ "Ad-Hoc",
+ "Client",
+ "Monitor",
+ "Master (VLAN)",
+ "WDS",
+ "Mesh Point",
+ "P2P Client",
+ "P2P Go",
+};
+
+
+/*
+ * ISO3166 country labels
+ */
+
+const struct iwinfo_iso3166_label IWINFO_ISO3166_NAMES[] = {
+ { 0x3030 /* 00 */, "World" },
+ { 0x4144 /* AD */, "Andorra" },
+ { 0x4145 /* AE */, "United Arab Emirates" },
+ { 0x4146 /* AF */, "Afghanistan" },
+ { 0x4147 /* AG */, "Antigua and Barbuda" },
+ { 0x4149 /* AI */, "Anguilla" },
+ { 0x414C /* AL */, "Albania" },
+ { 0x414D /* AM */, "Armenia" },
+ { 0x414E /* AN */, "Netherlands Antilles" },
+ { 0x414F /* AO */, "Angola" },
+ { 0x4151 /* AQ */, "Antarctica" },
+ { 0x4152 /* AR */, "Argentina" },
+ { 0x4153 /* AS */, "American Samoa" },
+ { 0x4154 /* AT */, "Austria" },
+ { 0x4155 /* AU */, "Australia" },
+ { 0x4157 /* AW */, "Aruba" },
+ { 0x4158 /* AX */, "Aland Islands" },
+ { 0x415A /* AZ */, "Azerbaijan" },
+ { 0x4241 /* BA */, "Bosnia and Herzegovina" },
+ { 0x4242 /* BB */, "Barbados" },
+ { 0x4244 /* BD */, "Bangladesh" },
+ { 0x4245 /* BE */, "Belgium" },
+ { 0x4246 /* BF */, "Burkina Faso" },
+ { 0x4247 /* BG */, "Bulgaria" },
+ { 0x4248 /* BH */, "Bahrain" },
+ { 0x4249 /* BI */, "Burundi" },
+ { 0x424A /* BJ */, "Benin" },
+ { 0x424C /* BL */, "Saint Barthelemy" },
+ { 0x424D /* BM */, "Bermuda" },
+ { 0x424E /* BN */, "Brunei Darussalam" },
+ { 0x424F /* BO */, "Bolivia" },
+ { 0x4252 /* BR */, "Brazil" },
+ { 0x4253 /* BS */, "Bahamas" },
+ { 0x4254 /* BT */, "Bhutan" },
+ { 0x4256 /* BV */, "Bouvet Island" },
+ { 0x4257 /* BW */, "Botswana" },
+ { 0x4259 /* BY */, "Belarus" },
+ { 0x425A /* BZ */, "Belize" },
+ { 0x4341 /* CA */, "Canada" },
+ { 0x4343 /* CC */, "Cocos (Keeling) Islands" },
+ { 0x4344 /* CD */, "Congo" },
+ { 0x4346 /* CF */, "Central African Republic" },
+ { 0x4347 /* CG */, "Congo" },
+ { 0x4348 /* CH */, "Switzerland" },
+ { 0x4349 /* CI */, "Cote d'Ivoire" },
+ { 0x434B /* CK */, "Cook Islands" },
+ { 0x434C /* CL */, "Chile" },
+ { 0x434D /* CM */, "Cameroon" },
+ { 0x434E /* CN */, "China" },
+ { 0x434F /* CO */, "Colombia" },
+ { 0x4352 /* CR */, "Costa Rica" },
+ { 0x4355 /* CU */, "Cuba" },
+ { 0x4356 /* CV */, "Cape Verde" },
+ { 0x4358 /* CX */, "Christmas Island" },
+ { 0x4359 /* CY */, "Cyprus" },
+ { 0x435A /* CZ */, "Czech Republic" },
+ { 0x4445 /* DE */, "Germany" },
+ { 0x444A /* DJ */, "Djibouti" },
+ { 0x444B /* DK */, "Denmark" },
+ { 0x444D /* DM */, "Dominica" },
+ { 0x444F /* DO */, "Dominican Republic" },
+ { 0x445A /* DZ */, "Algeria" },
+ { 0x4543 /* EC */, "Ecuador" },
+ { 0x4545 /* EE */, "Estonia" },
+ { 0x4547 /* EG */, "Egypt" },
+ { 0x4548 /* EH */, "Western Sahara" },
+ { 0x4552 /* ER */, "Eritrea" },
+ { 0x4553 /* ES */, "Spain" },
+ { 0x4554 /* ET */, "Ethiopia" },
+ { 0x4649 /* FI */, "Finland" },
+ { 0x464A /* FJ */, "Fiji" },
+ { 0x464B /* FK */, "Falkland Islands" },
+ { 0x464D /* FM */, "Micronesia" },
+ { 0x464F /* FO */, "Faroe Islands" },
+ { 0x4652 /* FR */, "France" },
+ { 0x4741 /* GA */, "Gabon" },
+ { 0x4742 /* GB */, "United Kingdom" },
+ { 0x4744 /* GD */, "Grenada" },
+ { 0x4745 /* GE */, "Georgia" },
+ { 0x4746 /* GF */, "French Guiana" },
+ { 0x4747 /* GG */, "Guernsey" },
+ { 0x4748 /* GH */, "Ghana" },
+ { 0x4749 /* GI */, "Gibraltar" },
+ { 0x474C /* GL */, "Greenland" },
+ { 0x474D /* GM */, "Gambia" },
+ { 0x474E /* GN */, "Guinea" },
+ { 0x4750 /* GP */, "Guadeloupe" },
+ { 0x4751 /* GQ */, "Equatorial Guinea" },
+ { 0x4752 /* GR */, "Greece" },
+ { 0x4753 /* GS */, "South Georgia" },
+ { 0x4754 /* GT */, "Guatemala" },
+ { 0x4755 /* GU */, "Guam" },
+ { 0x4757 /* GW */, "Guinea-Bissau" },
+ { 0x4759 /* GY */, "Guyana" },
+ { 0x484B /* HK */, "Hong Kong" },
+ { 0x484D /* HM */, "Heard and McDonald Islands" },
+ { 0x484E /* HN */, "Honduras" },
+ { 0x4852 /* HR */, "Croatia" },
+ { 0x4854 /* HT */, "Haiti" },
+ { 0x4855 /* HU */, "Hungary" },
+ { 0x4944 /* ID */, "Indonesia" },
+ { 0x4945 /* IE */, "Ireland" },
+ { 0x494C /* IL */, "Israel" },
+ { 0x494D /* IM */, "Isle of Man" },
+ { 0x494E /* IN */, "India" },
+ { 0x494F /* IO */, "Chagos Islands" },
+ { 0x4951 /* IQ */, "Iraq" },
+ { 0x4952 /* IR */, "Iran" },
+ { 0x4953 /* IS */, "Iceland" },
+ { 0x4954 /* IT */, "Italy" },
+ { 0x4A45 /* JE */, "Jersey" },
+ { 0x4A4D /* JM */, "Jamaica" },
+ { 0x4A4F /* JO */, "Jordan" },
+ { 0x4A50 /* JP */, "Japan" },
+ { 0x4B45 /* KE */, "Kenya" },
+ { 0x4B47 /* KG */, "Kyrgyzstan" },
+ { 0x4B48 /* KH */, "Cambodia" },
+ { 0x4B49 /* KI */, "Kiribati" },
+ { 0x4B4D /* KM */, "Comoros" },
+ { 0x4B4E /* KN */, "Saint Kitts and Nevis" },
+ { 0x4B50 /* KP */, "North Korea" },
+ { 0x4B52 /* KR */, "South Korea" },
+ { 0x4B57 /* KW */, "Kuwait" },
+ { 0x4B59 /* KY */, "Cayman Islands" },
+ { 0x4B5A /* KZ */, "Kazakhstan" },
+ { 0x4C41 /* LA */, "Laos" },
+ { 0x4C42 /* LB */, "Lebanon" },
+ { 0x4C43 /* LC */, "Saint Lucia" },
+ { 0x4C49 /* LI */, "Liechtenstein" },
+ { 0x4C4B /* LK */, "Sri Lanka" },
+ { 0x4C52 /* LR */, "Liberia" },
+ { 0x4C53 /* LS */, "Lesotho" },
+ { 0x4C54 /* LT */, "Lithuania" },
+ { 0x4C55 /* LU */, "Luxembourg" },
+ { 0x4C56 /* LV */, "Latvia" },
+ { 0x4C59 /* LY */, "Libyan Arab Jamahiriya" },
+ { 0x4D41 /* MA */, "Morocco" },
+ { 0x4D43 /* MC */, "Monaco" },
+ { 0x4D44 /* MD */, "Moldova" },
+ { 0x4D45 /* ME */, "Montenegro" },
+ { 0x4D46 /* MF */, "Saint Martin (French part)" },
+ { 0x4D47 /* MG */, "Madagascar" },
+ { 0x4D48 /* MH */, "Marshall Islands" },
+ { 0x4D4B /* MK */, "Macedonia" },
+ { 0x4D4C /* ML */, "Mali" },
+ { 0x4D4D /* MM */, "Myanmar" },
+ { 0x4D4E /* MN */, "Mongolia" },
+ { 0x4D4F /* MO */, "Macao" },
+ { 0x4D50 /* MP */, "Northern Mariana Islands" },
+ { 0x4D51 /* MQ */, "Martinique" },
+ { 0x4D52 /* MR */, "Mauritania" },
+ { 0x4D53 /* MS */, "Montserrat" },
+ { 0x4D54 /* MT */, "Malta" },
+ { 0x4D55 /* MU */, "Mauritius" },
+ { 0x4D56 /* MV */, "Maldives" },
+ { 0x4D57 /* MW */, "Malawi" },
+ { 0x4D58 /* MX */, "Mexico" },
+ { 0x4D59 /* MY */, "Malaysia" },
+ { 0x4D5A /* MZ */, "Mozambique" },
+ { 0x4E41 /* NA */, "Namibia" },
+ { 0x4E43 /* NC */, "New Caledonia" },
+ { 0x4E45 /* NE */, "Niger" },
+ { 0x4E46 /* NF */, "Norfolk Island" },
+ { 0x4E47 /* NG */, "Nigeria" },
+ { 0x4E49 /* NI */, "Nicaragua" },
+ { 0x4E4C /* NL */, "Netherlands" },
+ { 0x4E4F /* NO */, "Norway" },
+ { 0x4E50 /* NP */, "Nepal" },
+ { 0x4E52 /* NR */, "Nauru" },
+ { 0x4E55 /* NU */, "Niue" },
+ { 0x4E5A /* NZ */, "New Zealand" },
+ { 0x4F4D /* OM */, "Oman" },
+ { 0x5041 /* PA */, "Panama" },
+ { 0x5045 /* PE */, "Peru" },
+ { 0x5046 /* PF */, "French Polynesia" },
+ { 0x5047 /* PG */, "Papua New Guinea" },
+ { 0x5048 /* PH */, "Philippines" },
+ { 0x504B /* PK */, "Pakistan" },
+ { 0x504C /* PL */, "Poland" },
+ { 0x504D /* PM */, "Saint Pierre and Miquelon" },
+ { 0x504E /* PN */, "Pitcairn" },
+ { 0x5052 /* PR */, "Puerto Rico" },
+ { 0x5053 /* PS */, "Palestinian Territory" },
+ { 0x5054 /* PT */, "Portugal" },
+ { 0x5057 /* PW */, "Palau" },
+ { 0x5059 /* PY */, "Paraguay" },
+ { 0x5141 /* QA */, "Qatar" },
+ { 0x5245 /* RE */, "Reunion" },
+ { 0x524F /* RO */, "Romania" },
+ { 0x5253 /* RS */, "Serbia" },
+ { 0x5255 /* RU */, "Russian Federation" },
+ { 0x5257 /* RW */, "Rwanda" },
+ { 0x5341 /* SA */, "Saudi Arabia" },
+ { 0x5342 /* SB */, "Solomon Islands" },
+ { 0x5343 /* SC */, "Seychelles" },
+ { 0x5344 /* SD */, "Sudan" },
+ { 0x5345 /* SE */, "Sweden" },
+ { 0x5347 /* SG */, "Singapore" },
+ { 0x5348 /* SH */, "St. Helena and Dependencies" },
+ { 0x5349 /* SI */, "Slovenia" },
+ { 0x534A /* SJ */, "Svalbard and Jan Mayen" },
+ { 0x534B /* SK */, "Slovakia" },
+ { 0x534C /* SL */, "Sierra Leone" },
+ { 0x534D /* SM */, "San Marino" },
+ { 0x534E /* SN */, "Senegal" },
+ { 0x534F /* SO */, "Somalia" },
+ { 0x5352 /* SR */, "Suriname" },
+ { 0x5354 /* ST */, "Sao Tome and Principe" },
+ { 0x5356 /* SV */, "El Salvador" },
+ { 0x5359 /* SY */, "Syrian Arab Republic" },
+ { 0x535A /* SZ */, "Swaziland" },
+ { 0x5443 /* TC */, "Turks and Caicos Islands" },
+ { 0x5444 /* TD */, "Chad" },
+ { 0x5446 /* TF */, "French Southern Territories" },
+ { 0x5447 /* TG */, "Togo" },
+ { 0x5448 /* TH */, "Thailand" },
+ { 0x544A /* TJ */, "Tajikistan" },
+ { 0x544B /* TK */, "Tokelau" },
+ { 0x544C /* TL */, "Timor-Leste" },
+ { 0x544D /* TM */, "Turkmenistan" },
+ { 0x544E /* TN */, "Tunisia" },
+ { 0x544F /* TO */, "Tonga" },
+ { 0x5452 /* TR */, "Turkey" },
+ { 0x5454 /* TT */, "Trinidad and Tobago" },
+ { 0x5456 /* TV */, "Tuvalu" },
+ { 0x5457 /* TW */, "Taiwan" },
+ { 0x545A /* TZ */, "Tanzania" },
+ { 0x5541 /* UA */, "Ukraine" },
+ { 0x5547 /* UG */, "Uganda" },
+ { 0x554D /* UM */, "U.S. Minor Outlying Islands" },
+ { 0x5553 /* US */, "United States" },
+ { 0x5559 /* UY */, "Uruguay" },
+ { 0x555A /* UZ */, "Uzbekistan" },
+ { 0x5641 /* VA */, "Vatican City State" },
+ { 0x5643 /* VC */, "St. Vincent and Grenadines" },
+ { 0x5645 /* VE */, "Venezuela" },
+ { 0x5647 /* VG */, "Virgin Islands, British" },
+ { 0x5649 /* VI */, "Virgin Islands, U.S." },
+ { 0x564E /* VN */, "Viet Nam" },
+ { 0x5655 /* VU */, "Vanuatu" },
+ { 0x5746 /* WF */, "Wallis and Futuna" },
+ { 0x5753 /* WS */, "Samoa" },
+ { 0x5945 /* YE */, "Yemen" },
+ { 0x5954 /* YT */, "Mayotte" },
+ { 0x5A41 /* ZA */, "South Africa" },
+ { 0x5A4D /* ZM */, "Zambia" },
+ { 0x5A57 /* ZW */, "Zimbabwe" },
+ { 0, "" }
+};
+
+/*
+ * hardware database
+ */
+
+const char VENDOR_UBNT[] = "Ubiquiti";
+const char VENDOR_ATH[] = "Atheros";
+const char VENDOR_RALINK[] = "RaLink";
+
+const struct iwinfo_hardware_entry IWINFO_HARDWARE_ENTRIES[] = {
+/* { vendor, model, vendorid, deviceid, subsys vendorid, subsys deviceid, poweroff, freqoff } */
+#if defined(USE_MADWIFI) || defined(USE_NL80211)
+ { VENDOR_UBNT, "PowerStation2 (18V)", 0xffff, 0xffff, 0xffff, 0xb102, 0, 0 },
+ { VENDOR_UBNT, "PowerStation2 (16D)", 0xffff, 0xffff, 0xffff, 0xb202, 0, 0 },
+ { VENDOR_UBNT, "PowerStation2 (EXT)", 0xffff, 0xffff, 0xffff, 0xb302, 0, 0 },
+ { VENDOR_UBNT, "PowerStation5 (22V)", 0xffff, 0xffff, 0xffff, 0xb105, 0, 0 },
+ { VENDOR_UBNT, "PowerStation5 (EXT)", 0xffff, 0xffff, 0xffff, 0xb305, 0, 0 },
+ { VENDOR_UBNT, "PicoStation2", 0xffff, 0xffff, 0xffff, 0xc302, 0, 0 },
+ { VENDOR_UBNT, "PicoStation2 HP", 0xffff, 0xffff, 0xffff, 0xc3a2, 10, 0 },
+ { VENDOR_UBNT, "WispStation5", 0xffff, 0xffff, 0xffff, 0xa105, 0, 0 },
+ { VENDOR_UBNT, "LiteStation2", 0xffff, 0xffff, 0xffff, 0xa002, 10, 0 },
+ { VENDOR_UBNT, "LiteStation5", 0xffff, 0xffff, 0xffff, 0xa005, 5, 0 },
+ { VENDOR_UBNT, "NanoStation2", 0xffff, 0xffff, 0xffff, 0xc002, 10, 0 },
+ { VENDOR_UBNT, "NanoStation5", 0xffff, 0xffff, 0xffff, 0xc005, 5, 0 },
+ { VENDOR_UBNT, "NanoStation Loco2", 0xffff, 0xffff, 0xffff, 0xc102, 10, 0 },
+ { VENDOR_UBNT, "NanoStation Loco5", 0xffff, 0xffff, 0xffff, 0xc105, 5, 0 },
+ { VENDOR_UBNT, "Bullet2", 0xffff, 0xffff, 0xffff, 0xc202, 10, 0 },
+ { VENDOR_UBNT, "Bullet5", 0xffff, 0xffff, 0xffff, 0xc205, 5, 0 },
+ { VENDOR_UBNT, "XR2", 0x168c, 0x001b, 0x0777, 0x3002, 10, 0 },
+ { VENDOR_UBNT, "XR2", 0x168c, 0x001b, 0x7777, 0x3002, 10, 0 },
+ { VENDOR_UBNT, "XR2.3", 0x168c, 0x001b, 0x0777, 0x3b02, 10, 0 },
+ { VENDOR_UBNT, "XR2.6", 0x168c, 0x001b, 0x0777, 0x3c02, 10, 0 },
+ { VENDOR_UBNT, "XR3-2.8", 0x168c, 0x001b, 0x0777, 0x3b03, 10, 0 },
+ { VENDOR_UBNT, "XR3-3.6", 0x168c, 0x001b, 0x0777, 0x3c03, 10, 0 },
+ { VENDOR_UBNT, "XR3", 0x168c, 0x001b, 0x0777, 0x3003, 10, 0 },
+ { VENDOR_UBNT, "XR4", 0x168c, 0x001b, 0x0777, 0x3004, 10, 0 },
+ { VENDOR_UBNT, "XR5", 0x168c, 0x001b, 0x0777, 0x3005, 10, 0 },
+ { VENDOR_UBNT, "XR5", 0x168c, 0x001b, 0x7777, 0x3005, 10, 0 },
+ { VENDOR_UBNT, "XR7", 0x168c, 0x001b, 0x0777, 0x3007, 10, 0 },
+ { VENDOR_UBNT, "XR9", 0x168c, 0x001b, 0x0777, 0x3009, 10, -1520 },
+ { VENDOR_ATH, "AR5413", 0x168c, 0x001b, 0x168c, 0x2063, 0, 0 },
+ { VENDOR_UBNT, "SRC", 0x168c, 0x0013, 0x168c, 0x1042, 1, 0 },
+ { VENDOR_UBNT, "SR2", 0x168c, 0x0013, 0x0777, 0x2041, 10, 0 },
+ { VENDOR_UBNT, "SR4", 0x168c, 0x0013, 0x0777, 0x2004, 6, 0 },
+ { VENDOR_UBNT, "SR4", 0x168c, 0x0013, 0x7777, 0x2004, 6, 0 },
+ { VENDOR_UBNT, "SR4C", 0x168c, 0x0013, 0x0777, 0x1004, 6, 0 },
+ { VENDOR_UBNT, "SR4C", 0x168c, 0x0013, 0x7777, 0x1004, 6, 0 },
+ { VENDOR_UBNT, "SR5", 0x168c, 0x0013, 0x168c, 0x2042, 7, 0 },
+ { VENDOR_UBNT, "SR9", 0x168c, 0x0013, 0x7777, 0x2009, 12, -1500 },
+ { VENDOR_UBNT, "SR71A", 0x168c, 0x0027, 0x168c, 0x2082, 10, 0 },
+ { VENDOR_UBNT, "SR71", 0x168c, 0x0027, 0x0777, 0x4082, 10, 0 },
+#endif
+#ifdef USE_NL80211
+ { VENDOR_UBNT, "PicoStation M2", 0x168c, 0x002a, 0x0777, 0xe302, 12, 0 }, /* ToDo: confirm offset */
+ { VENDOR_UBNT, "NanoStation M2", 0x168c, 0x002a, 0x0777, 0xe012, 12, 0 }, /* ToDo: confirm offset */
+ { VENDOR_UBNT, "NanoStation M5", 0x168c, 0x002a, 0x0777, 0xe005, 5, 0 }, /* ToDo: confirm offset */
+ { VENDOR_UBNT, "Bullet M2", 0x168c, 0x002a, 0x0777, 0xe202, 12, 0 },
+ { VENDOR_UBNT, "Bullet M5", 0x168c, 0x002a, 0x0777, 0xe805, 5, 0 },
+
+ { VENDOR_ATH, "AR9220", 0x168c, 0x0029, 0x168c, 0xa094, 0, 0 },
+ { VENDOR_ATH, "AR9223", 0x168c, 0x0029, 0x168c, 0xa095, 0, 0 },
+ { VENDOR_ATH, "AR9280", 0x168c, 0x002a, 0x168c, 0xa093, 0, 0 },
+ { VENDOR_ATH, "AR9285", 0x168c, 0x002b, 0x168c, 0xa091, 0, 0 },
+ { VENDOR_RALINK, "Rt3050", 0x1814, 0x3050, 0x1814, 0x0005, 0, 0 },
+ { VENDOR_RALINK, "Rt3052", 0x1814, 0x3052, 0x1814, 0x0008, 0, 0 },
+ { VENDOR_RALINK, "Rt3352", 0x1814, 0x3352, 0x1814, 0x000c, 0, 0 },
+#endif
+ { NULL }
+};
+
+
+const char * iwinfo_type(const char *ifname)
+{
+#ifdef USE_NL80211
+ if (nl80211_probe(ifname))
+ return "nl80211";
+ else
+#endif
+
+#ifdef USE_MADWIFI
+ if (madwifi_probe(ifname))
+ return "madwifi";
+ else
+#endif
+
+#ifdef USE_WL
+ if (wl_probe(ifname))
+ return "wl";
+ else
+#endif
+
+ if (wext_probe(ifname))
+ return "wext";
+
+ return NULL;
+}
+
+const struct iwinfo_ops * iwinfo_backend(const char *ifname)
+{
+ const char *type;
+ struct iwinfo_ops *ops;
+
+ type = iwinfo_type(ifname);
+ if (!type)
+ return NULL;
+
+#ifdef USE_NL80211
+ if (!strcmp(type, "nl80211"))
+ return &nl80211_ops;
+ else
+#endif
+
+#ifdef USE_MADWIFI
+ if (!strcmp(type, "madwifi"))
+ return &madwifi_ops;
+ else
+#endif
+
+#ifdef USE_WL
+ if (!strcmp(type, "wl"))
+ return &wl_ops;
+ else
+#endif
+
+ if (!strcmp(type, "wext"))
+ return &wext_ops;
+
+ return NULL;
+}
+
+void iwinfo_finish(void)
+{
+#ifdef USE_WL
+ wl_close();
+#endif
+#ifdef USE_MADWIFI
+ madwifi_close();
+#endif
+#ifdef USE_NL80211
+ nl80211_close();
+#endif
+ wext_close();
+ iwinfo_close();
+}
diff --git a/package/network/utils/iwinfo/src/.svn/text-base/iwinfo_lua.c.svn-base b/package/network/utils/iwinfo/src/.svn/text-base/iwinfo_lua.c.svn-base
new file mode 100644
index 0000000..bd8faf9
--- /dev/null
+++ b/package/network/utils/iwinfo/src/.svn/text-base/iwinfo_lua.c.svn-base
@@ -0,0 +1,886 @@
+/*
+ * iwinfo - Wireless Information Library - Lua Bindings
+ *
+ * Copyright (C) 2009 Jo-Philipp Wich <xm@subsignal.org>
+ *
+ * The iwinfo library is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * The iwinfo library 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 the iwinfo library. If not, see http://www.gnu.org/licenses/.
+ */
+
+#include "iwinfo/lua.h"
+
+
+/* Determine type */
+static int iwinfo_L_type(lua_State *L)
+{
+ const char *ifname = luaL_checkstring(L, 1);
+ const char *type = iwinfo_type(ifname);
+
+ if (type)
+ lua_pushstring(L, type);
+ else
+ lua_pushnil(L);
+
+ return 1;
+}
+
+/* Shutdown backends */
+static int iwinfo_L__gc(lua_State *L)
+{
+ iwinfo_finish();
+ return 0;
+}
+
+/*
+ * Build a short textual description of the crypto info
+ */
+
+static char * iwinfo_crypto_print_ciphers(int ciphers)
+{
+ static char str[128] = { 0 };
+ char *pos = str;
+
+ if (ciphers & IWINFO_CIPHER_WEP40)
+ pos += sprintf(pos, "WEP-40, ");
+
+ if (ciphers & IWINFO_CIPHER_WEP104)
+ pos += sprintf(pos, "WEP-104, ");
+
+ if (ciphers & IWINFO_CIPHER_TKIP)
+ pos += sprintf(pos, "TKIP, ");
+
+ if (ciphers & IWINFO_CIPHER_CCMP)
+ pos += sprintf(pos, "CCMP, ");
+
+ if (ciphers & IWINFO_CIPHER_WRAP)
+ pos += sprintf(pos, "WRAP, ");
+
+ if (ciphers & IWINFO_CIPHER_AESOCB)
+ pos += sprintf(pos, "AES-OCB, ");
+
+ if (ciphers & IWINFO_CIPHER_CKIP)
+ pos += sprintf(pos, "CKIP, ");
+
+ if (!ciphers || (ciphers & IWINFO_CIPHER_NONE))
+ pos += sprintf(pos, "NONE, ");
+
+ *(pos - 2) = 0;
+
+ return str;
+}
+
+static char * iwinfo_crypto_print_suites(int suites)
+{
+ static char str[64] = { 0 };
+ char *pos = str;
+
+ if (suites & IWINFO_KMGMT_PSK)
+ pos += sprintf(pos, "PSK/");
+
+ if (suites & IWINFO_KMGMT_8021x)
+ pos += sprintf(pos, "802.1X/");
+
+ if (!suites || (suites & IWINFO_KMGMT_NONE))
+ pos += sprintf(pos, "NONE/");
+
+ *(pos - 1) = 0;
+
+ return str;
+}
+
+static char * iwinfo_crypto_desc(struct iwinfo_crypto_entry *c)
+{
+ static char desc[512] = { 0 };
+
+ if (c)
+ {
+ if (c->enabled)
+ {
+ /* WEP */
+ if (c->auth_algs && !c->wpa_version)
+ {
+ if ((c->auth_algs & IWINFO_AUTH_OPEN) &&
+ (c->auth_algs & IWINFO_AUTH_SHARED))
+ {
+ sprintf(desc, "WEP Open/Shared (%s)",
+ iwinfo_crypto_print_ciphers(c->pair_ciphers));
+ }
+ else if (c->auth_algs & IWINFO_AUTH_OPEN)
+ {
+ sprintf(desc, "WEP Open System (%s)",
+ iwinfo_crypto_print_ciphers(c->pair_ciphers));
+ }
+ else if (c->auth_algs & IWINFO_AUTH_SHARED)
+ {
+ sprintf(desc, "WEP Shared Auth (%s)",
+ iwinfo_crypto_print_ciphers(c->pair_ciphers));
+ }
+ }
+
+ /* WPA */
+ else if (c->wpa_version)
+ {
+ switch (c->wpa_version) {
+ case 3:
+ sprintf(desc, "mixed WPA/WPA2 %s (%s)",
+ iwinfo_crypto_print_suites(c->auth_suites),
+ iwinfo_crypto_print_ciphers(
+ c->pair_ciphers & c->group_ciphers));
+ break;
+
+ case 2:
+ sprintf(desc, "WPA2 %s (%s)",
+ iwinfo_crypto_print_suites(c->auth_suites),
+ iwinfo_crypto_print_ciphers(
+ c->pair_ciphers & c->group_ciphers));
+ break;
+
+ case 1:
+ sprintf(desc, "WPA %s (%s)",
+ iwinfo_crypto_print_suites(c->auth_suites),
+ iwinfo_crypto_print_ciphers(
+ c->pair_ciphers & c->group_ciphers));
+ break;
+ }
+ }
+ else
+ {
+ sprintf(desc, "None");
+ }
+ }
+ else
+ {
+ sprintf(desc, "None");
+ }
+ }
+ else
+ {
+ sprintf(desc, "Unknown");
+ }
+
+ return desc;
+}
+
+/* Build Lua table from crypto data */
+static void iwinfo_L_cryptotable(lua_State *L, struct iwinfo_crypto_entry *c)
+{
+ int i, j;
+
+ lua_newtable(L);
+
+ lua_pushboolean(L, c->enabled);
+ lua_setfield(L, -2, "enabled");
+
+ lua_pushstring(L, iwinfo_crypto_desc(c));
+ lua_setfield(L, -2, "description");
+
+ lua_pushboolean(L, (c->enabled && !c->wpa_version));
+ lua_setfield(L, -2, "wep");
+
+ lua_pushinteger(L, c->wpa_version);
+ lua_setfield(L, -2, "wpa");
+
+ lua_newtable(L);
+ for (i = 0, j = 1; i < 8; i++)
+ {
+ if (c->pair_ciphers & (1 << i))
+ {
+ lua_pushstring(L, IWINFO_CIPHER_NAMES[i]);
+ lua_rawseti(L, -2, j++);
+ }
+ }
+ lua_setfield(L, -2, "pair_ciphers");
+
+ lua_newtable(L);
+ for (i = 0, j = 1; i < 8; i++)
+ {
+ if (c->group_ciphers & (1 << i))
+ {
+ lua_pushstring(L, IWINFO_CIPHER_NAMES[i]);
+ lua_rawseti(L, -2, j++);
+ }
+ }
+ lua_setfield(L, -2, "group_ciphers");
+
+ lua_newtable(L);
+ for (i = 0, j = 1; i < 8; i++)
+ {
+ if (c->auth_suites & (1 << i))
+ {
+ lua_pushstring(L, IWINFO_KMGMT_NAMES[i]);
+ lua_rawseti(L, -2, j++);
+ }
+ }
+ lua_setfield(L, -2, "auth_suites");
+
+ lua_newtable(L);
+ for (i = 0, j = 1; i < 8; i++)
+ {
+ if (c->auth_algs & (1 << i))
+ {
+ lua_pushstring(L, IWINFO_AUTH_NAMES[i]);
+ lua_rawseti(L, -2, j++);
+ }
+ }
+ lua_setfield(L, -2, "auth_algs");
+}
+
+
+/* Wrapper for mode */
+static int iwinfo_L_mode(lua_State *L, int (*func)(const char *, int *))
+{
+ int mode;
+ const char *ifname = luaL_checkstring(L, 1);
+
+ if ((*func)(ifname, &mode))
+ mode = IWINFO_OPMODE_UNKNOWN;
+
+ lua_pushstring(L, IWINFO_OPMODE_NAMES[mode]);
+ return 1;
+}
+
+/* Wrapper for assoclist */
+static int iwinfo_L_assoclist(lua_State *L, int (*func)(const char *, char *, int *))
+{
+ int i, len;
+ char rv[IWINFO_BUFSIZE];
+ char macstr[18];
+ const char *ifname = luaL_checkstring(L, 1);
+ struct iwinfo_assoclist_entry *e;
+
+ lua_newtable(L);
+ memset(rv, 0, sizeof(rv));
+
+ if (!(*func)(ifname, rv, &len))
+ {
+ for (i = 0; i < len; i += sizeof(struct iwinfo_assoclist_entry))
+ {
+ e = (struct iwinfo_assoclist_entry *) &rv[i];
+
+ sprintf(macstr, "%02X:%02X:%02X:%02X:%02X:%02X",
+ e->mac[0], e->mac[1], e->mac[2],
+ e->mac[3], e->mac[4], e->mac[5]);
+
+ lua_newtable(L);
+
+ lua_pushnumber(L, e->signal);
+ lua_setfield(L, -2, "signal");
+
+ lua_pushnumber(L, e->noise);
+ lua_setfield(L, -2, "noise");
+
+ lua_pushnumber(L, e->inactive);
+ lua_setfield(L, -2, "inactive");
+
+ lua_pushnumber(L, e->rx_packets);
+ lua_setfield(L, -2, "rx_packets");
+
+ lua_pushnumber(L, e->tx_packets);
+ lua_setfield(L, -2, "tx_packets");
+
+ lua_pushnumber(L, e->rx_rate.rate);
+ lua_setfield(L, -2, "rx_rate");
+
+ lua_pushnumber(L, e->tx_rate.rate);
+ lua_setfield(L, -2, "tx_rate");
+
+ if (e->rx_rate.mcs >= 0)
+ {
+ lua_pushnumber(L, e->rx_rate.mcs);
+ lua_setfield(L, -2, "rx_mcs");
+
+ lua_pushboolean(L, e->rx_rate.is_40mhz);
+ lua_setfield(L, -2, "rx_40mhz");
+
+ lua_pushboolean(L, e->rx_rate.is_short_gi);
+ lua_setfield(L, -2, "rx_short_gi");
+ }
+
+ if (e->tx_rate.mcs >= 0)
+ {
+ lua_pushnumber(L, e->tx_rate.mcs);
+ lua_setfield(L, -2, "tx_mcs");
+
+ lua_pushboolean(L, e->tx_rate.is_40mhz);
+ lua_setfield(L, -2, "tx_40mhz");
+
+ lua_pushboolean(L, e->tx_rate.is_short_gi);
+ lua_setfield(L, -2, "tx_short_gi");
+ }
+
+ lua_setfield(L, -2, macstr);
+ }
+ }
+
+ return 1;
+}
+
+/* Wrapper for tx power list */
+static int iwinfo_L_txpwrlist(lua_State *L, int (*func)(const char *, char *, int *))
+{
+ int i, x, len;
+ char rv[IWINFO_BUFSIZE];
+ const char *ifname = luaL_checkstring(L, 1);
+ struct iwinfo_txpwrlist_entry *e;
+
+ memset(rv, 0, sizeof(rv));
+
+ if (!(*func)(ifname, rv, &len))
+ {
+ lua_newtable(L);
+
+ for (i = 0, x = 1; i < len; i += sizeof(struct iwinfo_txpwrlist_entry), x++)
+ {
+ e = (struct iwinfo_txpwrlist_entry *) &rv[i];
+
+ lua_newtable(L);
+
+ lua_pushnumber(L, e->mw);
+ lua_setfield(L, -2, "mw");
+
+ lua_pushnumber(L, e->dbm);
+ lua_setfield(L, -2, "dbm");
+
+ lua_rawseti(L, -2, x);
+ }
+
+ return 1;
+ }
+
+ return 0;
+}
+
+/* Wrapper for scan list */
+static int iwinfo_L_scanlist(lua_State *L, int (*func)(const char *, char *, int *))
+{
+ int i, x, len;
+ char rv[IWINFO_BUFSIZE];
+ char macstr[18];
+ const char *ifname = luaL_checkstring(L, 1);
+ struct iwinfo_scanlist_entry *e;
+
+ lua_newtable(L);
+ memset(rv, 0, sizeof(rv));
+
+ if (!(*func)(ifname, rv, &len))
+ {
+ for (i = 0, x = 1; i < len; i += sizeof(struct iwinfo_scanlist_entry), x++)
+ {
+ e = (struct iwinfo_scanlist_entry *) &rv[i];
+
+ lua_newtable(L);
+
+ /* BSSID */
+ sprintf(macstr, "%02X:%02X:%02X:%02X:%02X:%02X",
+ e->mac[0], e->mac[1], e->mac[2],
+ e->mac[3], e->mac[4], e->mac[5]);
+
+ lua_pushstring(L, macstr);
+ lua_setfield(L, -2, "bssid");
+
+ /* ESSID */
+ if (e->ssid[0])
+ {
+ lua_pushstring(L, (char *) e->ssid);
+ lua_setfield(L, -2, "ssid");
+ }
+
+ /* Channel */
+ lua_pushinteger(L, e->channel);
+ lua_setfield(L, -2, "channel");
+
+ /* Mode */
+ lua_pushstring(L, IWINFO_OPMODE_NAMES[e->mode]);
+ lua_setfield(L, -2, "mode");
+
+ /* Quality, Signal */
+ lua_pushinteger(L, e->quality);
+ lua_setfield(L, -2, "quality");
+
+ lua_pushinteger(L, e->quality_max);
+ lua_setfield(L, -2, "quality_max");
+
+ lua_pushnumber(L, (e->signal - 0x100));
+ lua_setfield(L, -2, "signal");
+
+ /* Crypto */
+ iwinfo_L_cryptotable(L, &e->crypto);
+ lua_setfield(L, -2, "encryption");
+
+ lua_rawseti(L, -2, x);
+ }
+ }
+
+ return 1;
+}
+
+/* Wrapper for frequency list */
+static int iwinfo_L_freqlist(lua_State *L, int (*func)(const char *, char *, int *))
+{
+ int i, x, len;
+ char rv[IWINFO_BUFSIZE];
+ const char *ifname = luaL_checkstring(L, 1);
+ struct iwinfo_freqlist_entry *e;
+
+ lua_newtable(L);
+ memset(rv, 0, sizeof(rv));
+
+ if (!(*func)(ifname, rv, &len))
+ {
+ for (i = 0, x = 1; i < len; i += sizeof(struct iwinfo_freqlist_entry), x++)
+ {
+ e = (struct iwinfo_freqlist_entry *) &rv[i];
+
+ lua_newtable(L);
+
+ /* MHz */
+ lua_pushinteger(L, e->mhz);
+ lua_setfield(L, -2, "mhz");
+
+ /* Channel */
+ lua_pushinteger(L, e->channel);
+ lua_setfield(L, -2, "channel");
+
+ /* Restricted (DFS/TPC/Radar) */
+ lua_pushboolean(L, e->restricted);
+ lua_setfield(L, -2, "restricted");
+
+ lua_rawseti(L, -2, x);
+ }
+ }
+
+ return 1;
+}
+
+/* Wrapper for crypto settings */
+static int iwinfo_L_encryption(lua_State *L, int (*func)(const char *, char *))
+{
+ const char *ifname = luaL_checkstring(L, 1);
+ struct iwinfo_crypto_entry c = { 0 };
+
+ if (!(*func)(ifname, (char *)&c))
+ {
+ iwinfo_L_cryptotable(L, &c);
+ return 1;
+ }
+
+ lua_pushnil(L);
+ return 1;
+}
+
+/* Wrapper for hwmode list */
+static int iwinfo_L_hwmodelist(lua_State *L, int (*func)(const char *, int *))
+{
+ const char *ifname = luaL_checkstring(L, 1);
+ int hwmodes = 0;
+
+ if (!(*func)(ifname, &hwmodes))
+ {
+ lua_newtable(L);
+
+ lua_pushboolean(L, hwmodes & IWINFO_80211_A);
+ lua_setfield(L, -2, "a");
+
+ lua_pushboolean(L, hwmodes & IWINFO_80211_B);
+ lua_setfield(L, -2, "b");
+
+ lua_pushboolean(L, hwmodes & IWINFO_80211_G);
+ lua_setfield(L, -2, "g");
+
+ lua_pushboolean(L, hwmodes & IWINFO_80211_N);
+ lua_setfield(L, -2, "n");
+
+ return 1;
+ }
+
+ lua_pushnil(L);
+ return 1;
+}
+
+/* Wrapper for mbssid_support */
+static int iwinfo_L_mbssid_support(lua_State *L, int (*func)(const char *, int *))
+{
+ const char *ifname = luaL_checkstring(L, 1);
+ int support = 0;
+
+ if (!(*func)(ifname, &support))
+ {
+ lua_pushboolean(L, support);
+ return 1;
+ }
+
+ lua_pushnil(L);
+ return 1;
+}
+
+/* Wrapper for hardware_id */
+static int iwinfo_L_hardware_id(lua_State *L, int (*func)(const char *, char *))
+{
+ const char *ifname = luaL_checkstring(L, 1);
+ struct iwinfo_hardware_id ids;
+
+ if (!(*func)(ifname, (char *)&ids))
+ {
+ lua_newtable(L);
+
+ lua_pushnumber(L, ids.vendor_id);
+ lua_setfield(L, -2, "vendor_id");
+
+ lua_pushnumber(L, ids.device_id);
+ lua_setfield(L, -2, "device_id");
+
+ lua_pushnumber(L, ids.subsystem_vendor_id);
+ lua_setfield(L, -2, "subsystem_vendor_id");
+
+ lua_pushnumber(L, ids.subsystem_device_id);
+ lua_setfield(L, -2, "subsystem_device_id");
+ }
+ else
+ {
+ lua_pushnil(L);
+ }
+
+ return 1;
+}
+
+/* Wrapper for country list */
+static char * iwinfo_L_country_lookup(char *buf, int len, int iso3166)
+{
+ int i;
+ struct iwinfo_country_entry *c;
+
+ for (i = 0; i < len; i += sizeof(struct iwinfo_country_entry))
+ {
+ c = (struct iwinfo_country_entry *) &buf[i];
+
+ if (c->iso3166 == iso3166)
+ return c->ccode;
+ }
+
+ return NULL;
+}
+
+static int iwinfo_L_countrylist(lua_State *L, int (*func)(const char *, char *, int *))
+{
+ int len, i, j;
+ char rv[IWINFO_BUFSIZE], alpha2[3];
+ char *ccode;
+ const char *ifname = luaL_checkstring(L, 1);
+ const struct iwinfo_iso3166_label *l;
+
+ lua_newtable(L);
+ memset(rv, 0, sizeof(rv));
+
+ if (!(*func)(ifname, rv, &len))
+ {
+ for (l = IWINFO_ISO3166_NAMES, j = 1; l->iso3166; l++)
+ {
+ if ((ccode = iwinfo_L_country_lookup(rv, len, l->iso3166)) != NULL)
+ {
+ sprintf(alpha2, "%c%c",
+ (l->iso3166 / 256), (l->iso3166 % 256));
+
+ lua_newtable(L);
+
+ lua_pushstring(L, alpha2);
+ lua_setfield(L, -2, "alpha2");
+
+ lua_pushstring(L, ccode);
+ lua_setfield(L, -2, "ccode");
+
+ lua_pushstring(L, l->name);
+ lua_setfield(L, -2, "name");
+
+ lua_rawseti(L, -2, j++);
+ }
+ }
+ }
+
+ return 1;
+}
+
+
+#ifdef USE_WL
+/* Broadcom */
+LUA_WRAP_INT(wl,channel)
+LUA_WRAP_INT(wl,frequency)
+LUA_WRAP_INT(wl,frequency_offset)
+LUA_WRAP_INT(wl,txpower)
+LUA_WRAP_INT(wl,txpower_offset)
+LUA_WRAP_INT(wl,bitrate)
+LUA_WRAP_INT(wl,signal)
+LUA_WRAP_INT(wl,noise)
+LUA_WRAP_INT(wl,quality)
+LUA_WRAP_INT(wl,quality_max)
+LUA_WRAP_STRING(wl,ssid)
+LUA_WRAP_STRING(wl,bssid)
+LUA_WRAP_STRING(wl,country)
+LUA_WRAP_STRING(wl,hardware_name)
+LUA_WRAP_STRUCT(wl,mode)
+LUA_WRAP_STRUCT(wl,assoclist)
+LUA_WRAP_STRUCT(wl,txpwrlist)
+LUA_WRAP_STRUCT(wl,scanlist)
+LUA_WRAP_STRUCT(wl,freqlist)
+LUA_WRAP_STRUCT(wl,countrylist)
+LUA_WRAP_STRUCT(wl,hwmodelist)
+LUA_WRAP_STRUCT(wl,encryption)
+LUA_WRAP_STRUCT(wl,mbssid_support)
+LUA_WRAP_STRUCT(wl,hardware_id)
+#endif
+
+#ifdef USE_MADWIFI
+/* Madwifi */
+LUA_WRAP_INT(madwifi,channel)
+LUA_WRAP_INT(madwifi,frequency)
+LUA_WRAP_INT(madwifi,frequency_offset)
+LUA_WRAP_INT(madwifi,txpower)
+LUA_WRAP_INT(madwifi,txpower_offset)
+LUA_WRAP_INT(madwifi,bitrate)
+LUA_WRAP_INT(madwifi,signal)
+LUA_WRAP_INT(madwifi,noise)
+LUA_WRAP_INT(madwifi,quality)
+LUA_WRAP_INT(madwifi,quality_max)
+LUA_WRAP_STRING(madwifi,ssid)
+LUA_WRAP_STRING(madwifi,bssid)
+LUA_WRAP_STRING(madwifi,country)
+LUA_WRAP_STRING(madwifi,hardware_name)
+LUA_WRAP_STRUCT(madwifi,mode)
+LUA_WRAP_STRUCT(madwifi,assoclist)
+LUA_WRAP_STRUCT(madwifi,txpwrlist)
+LUA_WRAP_STRUCT(madwifi,scanlist)
+LUA_WRAP_STRUCT(madwifi,freqlist)
+LUA_WRAP_STRUCT(madwifi,countrylist)
+LUA_WRAP_STRUCT(madwifi,hwmodelist)
+LUA_WRAP_STRUCT(madwifi,encryption)
+LUA_WRAP_STRUCT(madwifi,mbssid_support)
+LUA_WRAP_STRUCT(madwifi,hardware_id)
+#endif
+
+#ifdef USE_NL80211
+/* NL80211 */
+LUA_WRAP_INT(nl80211,channel)
+LUA_WRAP_INT(nl80211,frequency)
+LUA_WRAP_INT(nl80211,frequency_offset)
+LUA_WRAP_INT(nl80211,txpower)
+LUA_WRAP_INT(nl80211,txpower_offset)
+LUA_WRAP_INT(nl80211,bitrate)
+LUA_WRAP_INT(nl80211,signal)
+LUA_WRAP_INT(nl80211,noise)
+LUA_WRAP_INT(nl80211,quality)
+LUA_WRAP_INT(nl80211,quality_max)
+LUA_WRAP_STRING(nl80211,ssid)
+LUA_WRAP_STRING(nl80211,bssid)
+LUA_WRAP_STRING(nl80211,country)
+LUA_WRAP_STRING(nl80211,hardware_name)
+LUA_WRAP_STRUCT(nl80211,mode)
+LUA_WRAP_STRUCT(nl80211,assoclist)
+LUA_WRAP_STRUCT(nl80211,txpwrlist)
+LUA_WRAP_STRUCT(nl80211,scanlist)
+LUA_WRAP_STRUCT(nl80211,freqlist)
+LUA_WRAP_STRUCT(nl80211,countrylist)
+LUA_WRAP_STRUCT(nl80211,hwmodelist)
+LUA_WRAP_STRUCT(nl80211,encryption)
+LUA_WRAP_STRUCT(nl80211,mbssid_support)
+LUA_WRAP_STRUCT(nl80211,hardware_id)
+#endif
+
+/* Wext */
+LUA_WRAP_INT(wext,channel)
+LUA_WRAP_INT(wext,frequency)
+LUA_WRAP_INT(wext,frequency_offset)
+LUA_WRAP_INT(wext,txpower)
+LUA_WRAP_INT(wext,txpower_offset)
+LUA_WRAP_INT(wext,bitrate)
+LUA_WRAP_INT(wext,signal)
+LUA_WRAP_INT(wext,noise)
+LUA_WRAP_INT(wext,quality)
+LUA_WRAP_INT(wext,quality_max)
+LUA_WRAP_STRING(wext,ssid)
+LUA_WRAP_STRING(wext,bssid)
+LUA_WRAP_STRING(wext,country)
+LUA_WRAP_STRING(wext,hardware_name)
+LUA_WRAP_STRUCT(wext,mode)
+LUA_WRAP_STRUCT(wext,assoclist)
+LUA_WRAP_STRUCT(wext,txpwrlist)
+LUA_WRAP_STRUCT(wext,scanlist)
+LUA_WRAP_STRUCT(wext,freqlist)
+LUA_WRAP_STRUCT(wext,countrylist)
+LUA_WRAP_STRUCT(wext,hwmodelist)
+LUA_WRAP_STRUCT(wext,encryption)
+LUA_WRAP_STRUCT(wext,mbssid_support)
+LUA_WRAP_STRUCT(wext,hardware_id)
+
+#ifdef USE_WL
+/* Broadcom table */
+static const luaL_reg R_wl[] = {
+ LUA_REG(wl,channel),
+ LUA_REG(wl,frequency),
+ LUA_REG(wl,frequency_offset),
+ LUA_REG(wl,txpower),
+ LUA_REG(wl,txpower_offset),
+ LUA_REG(wl,bitrate),
+ LUA_REG(wl,signal),
+ LUA_REG(wl,noise),
+ LUA_REG(wl,quality),
+ LUA_REG(wl,quality_max),
+ LUA_REG(wl,mode),
+ LUA_REG(wl,ssid),
+ LUA_REG(wl,bssid),
+ LUA_REG(wl,country),
+ LUA_REG(wl,assoclist),
+ LUA_REG(wl,txpwrlist),
+ LUA_REG(wl,scanlist),
+ LUA_REG(wl,freqlist),
+ LUA_REG(wl,countrylist),
+ LUA_REG(wl,hwmodelist),
+ LUA_REG(wl,encryption),
+ LUA_REG(wl,mbssid_support),
+ LUA_REG(wl,hardware_id),
+ LUA_REG(wl,hardware_name),
+ { NULL, NULL }
+};
+#endif
+
+#ifdef USE_MADWIFI
+/* Madwifi table */
+static const luaL_reg R_madwifi[] = {
+ LUA_REG(madwifi,channel),
+ LUA_REG(madwifi,frequency),
+ LUA_REG(madwifi,frequency_offset),
+ LUA_REG(madwifi,txpower),
+ LUA_REG(madwifi,txpower_offset),
+ LUA_REG(madwifi,bitrate),
+ LUA_REG(madwifi,signal),
+ LUA_REG(madwifi,noise),
+ LUA_REG(madwifi,quality),
+ LUA_REG(madwifi,quality_max),
+ LUA_REG(madwifi,mode),
+ LUA_REG(madwifi,ssid),
+ LUA_REG(madwifi,bssid),
+ LUA_REG(madwifi,country),
+ LUA_REG(madwifi,assoclist),
+ LUA_REG(madwifi,txpwrlist),
+ LUA_REG(madwifi,scanlist),
+ LUA_REG(madwifi,freqlist),
+ LUA_REG(madwifi,countrylist),
+ LUA_REG(madwifi,hwmodelist),
+ LUA_REG(madwifi,encryption),
+ LUA_REG(madwifi,mbssid_support),
+ LUA_REG(madwifi,hardware_id),
+ LUA_REG(madwifi,hardware_name),
+ { NULL, NULL }
+};
+#endif
+
+#ifdef USE_NL80211
+/* NL80211 table */
+static const luaL_reg R_nl80211[] = {
+ LUA_REG(nl80211,channel),
+ LUA_REG(nl80211,frequency),
+ LUA_REG(nl80211,frequency_offset),
+ LUA_REG(nl80211,txpower),
+ LUA_REG(nl80211,txpower_offset),
+ LUA_REG(nl80211,bitrate),
+ LUA_REG(nl80211,signal),
+ LUA_REG(nl80211,noise),
+ LUA_REG(nl80211,quality),
+ LUA_REG(nl80211,quality_max),
+ LUA_REG(nl80211,mode),
+ LUA_REG(nl80211,ssid),
+ LUA_REG(nl80211,bssid),
+ LUA_REG(nl80211,country),
+ LUA_REG(nl80211,assoclist),
+ LUA_REG(nl80211,txpwrlist),
+ LUA_REG(nl80211,scanlist),
+ LUA_REG(nl80211,freqlist),
+ LUA_REG(nl80211,countrylist),
+ LUA_REG(nl80211,hwmodelist),
+ LUA_REG(nl80211,encryption),
+ LUA_REG(nl80211,mbssid_support),
+ LUA_REG(nl80211,hardware_id),
+ LUA_REG(nl80211,hardware_name),
+ { NULL, NULL }
+};
+#endif
+
+/* Wext table */
+static const luaL_reg R_wext[] = {
+ LUA_REG(wext,channel),
+ LUA_REG(wext,frequency),
+ LUA_REG(wext,frequency_offset),
+ LUA_REG(wext,txpower),
+ LUA_REG(wext,txpower_offset),
+ LUA_REG(wext,bitrate),
+ LUA_REG(wext,signal),
+ LUA_REG(wext,noise),
+ LUA_REG(wext,quality),
+ LUA_REG(wext,quality_max),
+ LUA_REG(wext,mode),
+ LUA_REG(wext,ssid),
+ LUA_REG(wext,bssid),
+ LUA_REG(wext,country),
+ LUA_REG(wext,assoclist),
+ LUA_REG(wext,txpwrlist),
+ LUA_REG(wext,scanlist),
+ LUA_REG(wext,freqlist),
+ LUA_REG(wext,countrylist),
+ LUA_REG(wext,hwmodelist),
+ LUA_REG(wext,encryption),
+ LUA_REG(wext,mbssid_support),
+ LUA_REG(wext,hardware_id),
+ LUA_REG(wext,hardware_name),
+ { NULL, NULL }
+};
+
+/* Common */
+static const luaL_reg R_common[] = {
+ { "type", iwinfo_L_type },
+ { "__gc", iwinfo_L__gc },
+ { NULL, NULL }
+};
+
+
+LUALIB_API int luaopen_iwinfo(lua_State *L) {
+ luaL_register(L, IWINFO_META, R_common);
+
+#ifdef USE_WL
+ luaL_newmetatable(L, IWINFO_WL_META);
+ luaL_register(L, NULL, R_wl);
+ lua_pushvalue(L, -1);
+ lua_setfield(L, -2, "__index");
+ lua_setfield(L, -2, "wl");
+#endif
+
+#ifdef USE_MADWIFI
+ luaL_newmetatable(L, IWINFO_MADWIFI_META);
+ luaL_register(L, NULL, R_madwifi);
+ lua_pushvalue(L, -1);
+ lua_setfield(L, -2, "__index");
+ lua_setfield(L, -2, "madwifi");
+#endif
+
+#ifdef USE_NL80211
+ luaL_newmetatable(L, IWINFO_NL80211_META);
+ luaL_register(L, NULL, R_nl80211);
+ lua_pushvalue(L, -1);
+ lua_setfield(L, -2, "__index");
+ lua_setfield(L, -2, "nl80211");
+#endif
+
+ luaL_newmetatable(L, IWINFO_WEXT_META);
+ luaL_register(L, NULL, R_wext);
+ lua_pushvalue(L, -1);
+ lua_setfield(L, -2, "__index");
+ lua_setfield(L, -2, "wext");
+
+ return 1;
+}
diff --git a/package/network/utils/iwinfo/src/.svn/text-base/iwinfo_madwifi.c.svn-base b/package/network/utils/iwinfo/src/.svn/text-base/iwinfo_madwifi.c.svn-base
new file mode 100644
index 0000000..832f40b
--- /dev/null
+++ b/package/network/utils/iwinfo/src/.svn/text-base/iwinfo_madwifi.c.svn-base
@@ -0,0 +1,1082 @@
+/*
+ * iwinfo - Wireless Information Library - Madwifi Backend
+ *
+ * Copyright (C) 2009-2010 Jo-Philipp Wich <xm@subsignal.org>
+ *
+ * The iwinfo library is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * The iwinfo library 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 the iwinfo library. If not, see http://www.gnu.org/licenses/.
+ *
+ * The signal handling code is derived from the official madwifi tools,
+ * wlanconfig.c in particular. The encryption property handling was
+ * inspired by the hostapd madwifi driver.
+ */
+
+#include "iwinfo/madwifi.h"
+#include "iwinfo/wext.h"
+
+
+/*
+ * Madwifi ISO 3166 to Country/Region Code mapping.
+ */
+
+static struct ISO3166_to_CCode
+{
+ u_int16_t iso3166;
+ u_int16_t ccode;
+} CountryCodes[] = {
+ { 0x3030 /* 00 */, 0 }, /* World */
+ { 0x4145 /* AE */, 784 }, /* U.A.E. */
+ { 0x414C /* AL */, 8 }, /* Albania */
+ { 0x414D /* AM */, 51 }, /* Armenia */
+ { 0x4152 /* AR */, 32 }, /* Argentina */
+ { 0x4154 /* AT */, 40 }, /* Austria */
+ { 0x4155 /* AU */, 36 }, /* Australia */
+ { 0x415A /* AZ */, 31 }, /* Azerbaijan */
+ { 0x4245 /* BE */, 56 }, /* Belgium */
+ { 0x4247 /* BG */, 100 }, /* Bulgaria */
+ { 0x4248 /* BH */, 48 }, /* Bahrain */
+ { 0x424E /* BN */, 96 }, /* Brunei Darussalam */
+ { 0x424F /* BO */, 68 }, /* Bolivia */
+ { 0x4252 /* BR */, 76 }, /* Brazil */
+ { 0x4259 /* BY */, 112 }, /* Belarus */
+ { 0x425A /* BZ */, 84 }, /* Belize */
+ { 0x4341 /* CA */, 124 }, /* Canada */
+ { 0x4348 /* CH */, 756 }, /* Switzerland */
+ { 0x434C /* CL */, 152 }, /* Chile */
+ { 0x434E /* CN */, 156 }, /* People's Republic of China */
+ { 0x434F /* CO */, 170 }, /* Colombia */
+ { 0x4352 /* CR */, 188 }, /* Costa Rica */
+ { 0x4359 /* CY */, 196 }, /* Cyprus */
+ { 0x435A /* CZ */, 203 }, /* Czech Republic */
+ { 0x4445 /* DE */, 276 }, /* Germany */
+ { 0x444B /* DK */, 208 }, /* Denmark */
+ { 0x444F /* DO */, 214 }, /* Dominican Republic */
+ { 0x445A /* DZ */, 12 }, /* Algeria */
+ { 0x4543 /* EC */, 218 }, /* Ecuador */
+ { 0x4545 /* EE */, 233 }, /* Estonia */
+ { 0x4547 /* EG */, 818 }, /* Egypt */
+ { 0x4553 /* ES */, 724 }, /* Spain */
+ { 0x4649 /* FI */, 246 }, /* Finland */
+ { 0x464F /* FO */, 234 }, /* Faeroe Islands */
+ { 0x4652 /* FR */, 250 }, /* France */
+ { 0x4652 /* FR */, 255 }, /* France2 */
+ { 0x4742 /* GB */, 826 }, /* United Kingdom */
+ { 0x4745 /* GE */, 268 }, /* Georgia */
+ { 0x4752 /* GR */, 300 }, /* Greece */
+ { 0x4754 /* GT */, 320 }, /* Guatemala */
+ { 0x484B /* HK */, 344 }, /* Hong Kong S.A.R., P.R.C. */
+ { 0x484E /* HN */, 340 }, /* Honduras */
+ { 0x4852 /* HR */, 191 }, /* Croatia */
+ { 0x4855 /* HU */, 348 }, /* Hungary */
+ { 0x4944 /* ID */, 360 }, /* Indonesia */
+ { 0x4945 /* IE */, 372 }, /* Ireland */
+ { 0x494C /* IL */, 376 }, /* Israel */
+ { 0x494E /* IN */, 356 }, /* India */
+ { 0x4951 /* IQ */, 368 }, /* Iraq */
+ { 0x4952 /* IR */, 364 }, /* Iran */
+ { 0x4953 /* IS */, 352 }, /* Iceland */
+ { 0x4954 /* IT */, 380 }, /* Italy */
+ { 0x4A4D /* JM */, 388 }, /* Jamaica */
+ { 0x4A4F /* JO */, 400 }, /* Jordan */
+ { 0x4A50 /* JP */, 392 }, /* Japan */
+ { 0x4A50 /* JP */, 393 }, /* Japan (JP1) */
+ { 0x4A50 /* JP */, 394 }, /* Japan (JP0) */
+ { 0x4A50 /* JP */, 395 }, /* Japan (JP1-1) */
+ { 0x4A50 /* JP */, 396 }, /* Japan (JE1) */
+ { 0x4A50 /* JP */, 397 }, /* Japan (JE2) */
+ { 0x4A50 /* JP */, 399 }, /* Japan (JP6) */
+ { 0x4A50 /* JP */, 900 }, /* Japan */
+ { 0x4A50 /* JP */, 901 }, /* Japan */
+ { 0x4A50 /* JP */, 902 }, /* Japan */
+ { 0x4A50 /* JP */, 903 }, /* Japan */
+ { 0x4A50 /* JP */, 904 }, /* Japan */
+ { 0x4A50 /* JP */, 905 }, /* Japan */
+ { 0x4A50 /* JP */, 906 }, /* Japan */
+ { 0x4A50 /* JP */, 907 }, /* Japan */
+ { 0x4A50 /* JP */, 908 }, /* Japan */
+ { 0x4A50 /* JP */, 909 }, /* Japan */
+ { 0x4A50 /* JP */, 910 }, /* Japan */
+ { 0x4A50 /* JP */, 911 }, /* Japan */
+ { 0x4A50 /* JP */, 912 }, /* Japan */
+ { 0x4A50 /* JP */, 913 }, /* Japan */
+ { 0x4A50 /* JP */, 914 }, /* Japan */
+ { 0x4A50 /* JP */, 915 }, /* Japan */
+ { 0x4A50 /* JP */, 916 }, /* Japan */
+ { 0x4A50 /* JP */, 917 }, /* Japan */
+ { 0x4A50 /* JP */, 918 }, /* Japan */
+ { 0x4A50 /* JP */, 919 }, /* Japan */
+ { 0x4A50 /* JP */, 920 }, /* Japan */
+ { 0x4A50 /* JP */, 921 }, /* Japan */
+ { 0x4A50 /* JP */, 922 }, /* Japan */
+ { 0x4A50 /* JP */, 923 }, /* Japan */
+ { 0x4A50 /* JP */, 924 }, /* Japan */
+ { 0x4A50 /* JP */, 925 }, /* Japan */
+ { 0x4A50 /* JP */, 926 }, /* Japan */
+ { 0x4A50 /* JP */, 927 }, /* Japan */
+ { 0x4A50 /* JP */, 928 }, /* Japan */
+ { 0x4A50 /* JP */, 929 }, /* Japan */
+ { 0x4A50 /* JP */, 930 }, /* Japan */
+ { 0x4A50 /* JP */, 931 }, /* Japan */
+ { 0x4A50 /* JP */, 932 }, /* Japan */
+ { 0x4A50 /* JP */, 933 }, /* Japan */
+ { 0x4A50 /* JP */, 934 }, /* Japan */
+ { 0x4A50 /* JP */, 935 }, /* Japan */
+ { 0x4A50 /* JP */, 936 }, /* Japan */
+ { 0x4A50 /* JP */, 937 }, /* Japan */
+ { 0x4A50 /* JP */, 938 }, /* Japan */
+ { 0x4A50 /* JP */, 939 }, /* Japan */
+ { 0x4A50 /* JP */, 940 }, /* Japan */
+ { 0x4A50 /* JP */, 941 }, /* Japan */
+ { 0x4B45 /* KE */, 404 }, /* Kenya */
+ { 0x4B50 /* KP */, 408 }, /* North Korea */
+ { 0x4B52 /* KR */, 410 }, /* South Korea */
+ { 0x4B52 /* KR */, 411 }, /* South Korea */
+ { 0x4B57 /* KW */, 414 }, /* Kuwait */
+ { 0x4B5A /* KZ */, 398 }, /* Kazakhstan */
+ { 0x4C42 /* LB */, 422 }, /* Lebanon */
+ { 0x4C49 /* LI */, 438 }, /* Liechtenstein */
+ { 0x4C54 /* LT */, 440 }, /* Lithuania */
+ { 0x4C55 /* LU */, 442 }, /* Luxembourg */
+ { 0x4C56 /* LV */, 428 }, /* Latvia */
+ { 0x4C59 /* LY */, 434 }, /* Libya */
+ { 0x4D41 /* MA */, 504 }, /* Morocco */
+ { 0x4D43 /* MC */, 492 }, /* Principality of Monaco */
+ { 0x4D4B /* MK */, 807 }, /* the Former Yugoslav Republic of Macedonia */
+ { 0x4D4F /* MO */, 446 }, /* Macau */
+ { 0x4D58 /* MX */, 484 }, /* Mexico */
+ { 0x4D59 /* MY */, 458 }, /* Malaysia */
+ { 0x4E49 /* NI */, 558 }, /* Nicaragua */
+ { 0x4E4C /* NL */, 528 }, /* Netherlands */
+ { 0x4E4F /* NO */, 578 }, /* Norway */
+ { 0x4E5A /* NZ */, 554 }, /* New Zealand */
+ { 0x4F4D /* OM */, 512 }, /* Oman */
+ { 0x5041 /* PA */, 591 }, /* Panama */
+ { 0x5045 /* PE */, 604 }, /* Peru */
+ { 0x5048 /* PH */, 608 }, /* Republic of the Philippines */
+ { 0x504B /* PK */, 586 }, /* Islamic Republic of Pakistan */
+ { 0x504C /* PL */, 616 }, /* Poland */
+ { 0x5052 /* PR */, 630 }, /* Puerto Rico */
+ { 0x5054 /* PT */, 620 }, /* Portugal */
+ { 0x5059 /* PY */, 600 }, /* Paraguay */
+ { 0x5141 /* QA */, 634 }, /* Qatar */
+ { 0x524F /* RO */, 642 }, /* Romania */
+ { 0x5255 /* RU */, 643 }, /* Russia */
+ { 0x5341 /* SA */, 682 }, /* Saudi Arabia */
+ { 0x5345 /* SE */, 752 }, /* Sweden */
+ { 0x5347 /* SG */, 702 }, /* Singapore */
+ { 0x5349 /* SI */, 705 }, /* Slovenia */
+ { 0x534B /* SK */, 703 }, /* Slovak Republic */
+ { 0x5356 /* SV */, 222 }, /* El Salvador */
+ { 0x5359 /* SY */, 760 }, /* Syria */
+ { 0x5448 /* TH */, 764 }, /* Thailand */
+ { 0x544E /* TN */, 788 }, /* Tunisia */
+ { 0x5452 /* TR */, 792 }, /* Turkey */
+ { 0x5454 /* TT */, 780 }, /* Trinidad y Tobago */
+ { 0x5457 /* TW */, 158 }, /* Taiwan */
+ { 0x5541 /* UA */, 804 }, /* Ukraine */
+ { 0x554B /* UK */, 826 }, /* United Kingdom */
+ { 0x5553 /* US */, 840 }, /* United States */
+ { 0x5553 /* US */, 842 }, /* United States (Public Safety)*/
+ { 0x5559 /* UY */, 858 }, /* Uruguay */
+ { 0x555A /* UZ */, 860 }, /* Uzbekistan */
+ { 0x5645 /* VE */, 862 }, /* Venezuela */
+ { 0x564E /* VN */, 704 }, /* Viet Nam */
+ { 0x5945 /* YE */, 887 }, /* Yemen */
+ { 0x5A41 /* ZA */, 710 }, /* South Africa */
+ { 0x5A57 /* ZW */, 716 }, /* Zimbabwe */
+};
+
+
+static const char * madwifi_phyname(const char *ifname)
+{
+ static char phyname[IFNAMSIZ];
+
+ if (strlen(ifname) > 5 && !strncmp(ifname, "radio", 5))
+ snprintf(phyname, sizeof(phyname), "wifi%s", ifname + 5);
+ else
+ snprintf(phyname, sizeof(phyname), "%s", ifname);
+
+ return (const char *)phyname;
+}
+
+static int madwifi_wrq(struct iwreq *wrq, const char *ifname, int cmd, void *data, size_t len)
+{
+ strncpy(wrq->ifr_name, ifname, IFNAMSIZ);
+
+ if( data != NULL )
+ {
+ if( len < IFNAMSIZ )
+ {
+ memcpy(wrq->u.name, data, len);
+ }
+ else
+ {
+ wrq->u.data.pointer = data;
+ wrq->u.data.length = len;
+ }
+ }
+
+ return iwinfo_ioctl(cmd, wrq);
+}
+
+static int get80211priv(const char *ifname, int op, void *data, size_t len)
+{
+ struct iwreq iwr;
+
+ if( madwifi_wrq(&iwr, ifname, op, data, len) < 0 )
+ return -1;
+
+ return iwr.u.data.length;
+}
+
+static char * madwifi_isvap(const char *ifname, const char *wifiname)
+{
+ int fd, ln;
+ char path[32];
+ char *ret = NULL;
+ static char name[IFNAMSIZ];
+
+ if( strlen(ifname) <= 9 )
+ {
+ sprintf(path, "/proc/sys/net/%s/%%parent", ifname);
+
+ if( (fd = open(path, O_RDONLY)) > -1 )
+ {
+ if( wifiname != NULL )
+ {
+ if( read(fd, name, strlen(wifiname)) == strlen(wifiname) )
+ ret = strncmp(name, wifiname, strlen(wifiname))
+ ? NULL : name;
+ }
+ else if( (ln = read(fd, name, IFNAMSIZ)) >= 4 )
+ {
+ name[ln-1] = 0;
+ ret = name;
+ }
+
+ (void) close(fd);
+ }
+ }
+
+ return ret;
+}
+
+static int madwifi_iswifi(const char *ifname)
+{
+ int ret;
+ char path[32];
+ struct stat s;
+ const char *phy;
+
+ ret = 0;
+ phy = madwifi_phyname(ifname);
+
+ if( strlen(phy) <= 7 )
+ {
+ sprintf(path, "/proc/sys/dev/%s/diversity", phy);
+
+ if( ! stat(path, &s) )
+ ret = (s.st_mode & S_IFREG);
+ }
+
+ return ret;
+}
+
+static char * madwifi_ifadd(const char *ifname)
+{
+ const char *wifidev = NULL;
+ struct ifreq ifr = { 0 };
+ struct ieee80211_clone_params cp = { 0 };
+ static char nif[IFNAMSIZ] = { 0 };
+
+ if( !(wifidev = madwifi_isvap(ifname, NULL)) && madwifi_iswifi(ifname) )
+ wifidev = madwifi_phyname(ifname);
+
+ if( wifidev )
+ {
+ snprintf(nif, sizeof(nif), "tmp.%s", ifname);
+
+ strncpy(cp.icp_name, nif, IFNAMSIZ);
+ cp.icp_opmode = IEEE80211_M_STA;
+ cp.icp_flags = IEEE80211_CLONE_BSSID;
+
+ strncpy(ifr.ifr_name, wifidev, IFNAMSIZ);
+ ifr.ifr_data = (void *)&cp;
+
+ if( !iwinfo_ioctl(SIOC80211IFCREATE, &ifr) )
+ {
+ return nif;
+ }
+ else
+ {
+ cp.icp_opmode = IEEE80211_M_MONITOR;
+
+ if( !iwinfo_ioctl(SIOC80211IFCREATE, &ifr) )
+ return nif;
+ }
+ }
+
+ return NULL;
+}
+
+static void madwifi_ifdel(const char *ifname)
+{
+ struct ifreq ifr = { 0 };
+
+ strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
+ iwinfo_ioctl(SIOC80211IFDESTROY, &ifr);
+}
+
+
+int madwifi_probe(const char *ifname)
+{
+ return ( !!madwifi_isvap(ifname, NULL) || madwifi_iswifi(ifname) );
+}
+
+void madwifi_close(void)
+{
+ /* Nop */
+}
+
+int madwifi_get_mode(const char *ifname, int *buf)
+{
+ return wext_get_mode(ifname, buf);
+}
+
+int madwifi_get_ssid(const char *ifname, char *buf)
+{
+ return wext_get_ssid(ifname, buf);
+}
+
+int madwifi_get_bssid(const char *ifname, char *buf)
+{
+ return wext_get_bssid(ifname, buf);
+}
+
+int madwifi_get_channel(const char *ifname, int *buf)
+{
+ int i;
+ uint16_t freq;
+ struct iwreq wrq;
+ struct ieee80211req_chaninfo chans;
+
+ if( madwifi_wrq(&wrq, ifname, SIOCGIWFREQ, NULL, 0) >= 0 )
+ {
+ /* Madwifi returns a Hz frequency, get it's freq list to find channel index */
+ freq = (uint16_t)(wrq.u.freq.m / 100000);
+
+ if( get80211priv(ifname, IEEE80211_IOCTL_GETCHANINFO, &chans, sizeof(chans)) >= 0 )
+ {
+ *buf = 0;
+
+ for( i = 0; i < chans.ic_nchans; i++ )
+ {
+ if( freq == chans.ic_chans[i].ic_freq )
+ {
+ *buf = chans.ic_chans[i].ic_ieee;
+ break;
+ }
+ }
+
+ return 0;
+ }
+ }
+
+ return -1;
+}
+
+int madwifi_get_frequency(const char *ifname, int *buf)
+{
+ struct iwreq wrq;
+
+ if( madwifi_wrq(&wrq, ifname, SIOCGIWFREQ, NULL, 0) >= 0 )
+ {
+ *buf = (uint16_t)(wrq.u.freq.m / 100000);
+ return 0;
+ }
+
+ return -1;
+}
+
+int madwifi_get_txpower(const char *ifname, int *buf)
+{
+ return wext_get_txpower(ifname, buf);
+}
+
+int madwifi_get_bitrate(const char *ifname, int *buf)
+{
+ unsigned int mode, len, rate, rate_count;
+ uint8_t tmp[24*1024];
+ uint8_t *cp;
+ struct iwreq wrq;
+ struct ieee80211req_sta_info *si;
+
+ if( madwifi_wrq(&wrq, ifname, SIOCGIWMODE, NULL, 0) >= 0 )
+ {
+ mode = wrq.u.mode;
+
+ /* Calculate bitrate average from associated stations in ad-hoc mode */
+ if( mode == 1 )
+ {
+ rate = rate_count = 0;
+
+ if( (len = get80211priv(ifname, IEEE80211_IOCTL_STA_INFO, tmp, 24*1024)) > 0 )
+ {
+ cp = tmp;
+
+ do {
+ si = (struct ieee80211req_sta_info *) cp;
+
+ if( si->isi_rssi > 0 )
+ {
+ rate_count++;
+ rate += ((si->isi_rates[si->isi_txrate] & IEEE80211_RATE_VAL) / 2);
+ }
+
+ cp += si->isi_len;
+ len -= si->isi_len;
+ } while (len >= sizeof(struct ieee80211req_sta_info));
+ }
+
+ *buf = (rate == 0 || rate_count == 0) ? 0 : (rate / rate_count) * 1000;
+ return 0;
+ }
+
+ /* Return whatever wext tells us ... */
+ return wext_get_bitrate(ifname, buf);
+ }
+
+ return -1;
+}
+
+int madwifi_get_signal(const char *ifname, int *buf)
+{
+ unsigned int mode, len, rssi, rssi_count;
+ uint8_t tmp[24*1024];
+ uint8_t *cp;
+ struct iwreq wrq;
+ struct ieee80211req_sta_info *si;
+
+ if( madwifi_wrq(&wrq, ifname, SIOCGIWMODE, NULL, 0) >= 0 )
+ {
+ mode = wrq.u.mode;
+
+ /* Calculate signal average from associated stations in ap or ad-hoc mode */
+ if( mode == 1 )
+ {
+ rssi = rssi_count = 0;
+
+ if( (len = get80211priv(ifname, IEEE80211_IOCTL_STA_INFO, tmp, 24*1024)) > 0 )
+ {
+ cp = tmp;
+
+ do {
+ si = (struct ieee80211req_sta_info *) cp;
+
+ if( si->isi_rssi > 0 )
+ {
+ rssi_count++;
+ rssi -= (si->isi_rssi - 95);
+ }
+
+ cp += si->isi_len;
+ len -= si->isi_len;
+ } while (len >= sizeof(struct ieee80211req_sta_info));
+ }
+
+ *buf = (rssi == 0 || rssi_count == 0) ? 1 : -(rssi / rssi_count);
+ return 0;
+ }
+
+ /* Return whatever wext tells us ... */
+ return wext_get_signal(ifname, buf);
+ }
+
+ return -1;
+}
+
+int madwifi_get_noise(const char *ifname, int *buf)
+{
+ return wext_get_noise(ifname, buf);
+}
+
+int madwifi_get_quality(const char *ifname, int *buf)
+{
+ unsigned int mode, len, quality, quality_count;
+ uint8_t tmp[24*1024];
+ uint8_t *cp;
+ struct iwreq wrq;
+ struct ieee80211req_sta_info *si;
+
+ if( madwifi_wrq(&wrq, ifname, SIOCGIWMODE, NULL, 0) >= 0 )
+ {
+ mode = wrq.u.mode;
+
+ /* Calculate signal average from associated stations in ad-hoc mode */
+ if( mode == 1 )
+ {
+ quality = quality_count = 0;
+
+ if( (len = get80211priv(ifname, IEEE80211_IOCTL_STA_INFO, tmp, 24*1024)) > 0 )
+ {
+ cp = tmp;
+
+ do {
+ si = (struct ieee80211req_sta_info *) cp;
+
+ if( si->isi_rssi > 0 )
+ {
+ quality_count++;
+ quality += si->isi_rssi;
+ }
+
+ cp += si->isi_len;
+ len -= si->isi_len;
+ } while (len >= sizeof(struct ieee80211req_sta_info));
+ }
+
+ *buf = (quality == 0 || quality_count == 0) ? 0 : (quality / quality_count);
+ return 0;
+ }
+
+ /* Return whatever wext tells us ... */
+ return wext_get_quality(ifname, buf);
+ }
+
+ return -1;
+}
+
+int madwifi_get_quality_max(const char *ifname, int *buf)
+{
+ return wext_get_quality_max(ifname, buf);
+}
+
+int madwifi_get_encryption(const char *ifname, char *buf)
+{
+ int ciphers = 0, key_len = 0;
+ char keybuf[IW_ENCODING_TOKEN_MAX];
+ struct iwinfo_crypto_entry *c = (struct iwinfo_crypto_entry *)buf;
+ struct iwreq wrq;
+ struct ieee80211req_key wk;
+
+ memset(&wrq, 0, sizeof(wrq));
+
+ /* Obtain key info */
+ if( madwifi_wrq(&wrq, ifname, SIOCGIWENCODE, keybuf, sizeof(keybuf)) < 0 )
+ return -1;
+
+#if 0
+ /* Have any encryption? */
+ if( (wrq.u.data.flags & IW_ENCODE_DISABLED) || (wrq.u.data.length == 0) )
+ return 0;
+#endif
+
+ /* Save key len */
+ key_len = wrq.u.data.length;
+
+ /* Get wpa protocol version */
+ wrq.u.mode = IEEE80211_PARAM_WPA;
+ if( madwifi_wrq(&wrq, ifname, IEEE80211_IOCTL_GETPARAM, NULL, 0) >= 0 )
+ c->wpa_version = wrq.u.mode;
+
+ /* Get authentication suites */
+ wrq.u.mode = IEEE80211_PARAM_AUTHMODE;
+ if( madwifi_wrq(&wrq, ifname, IEEE80211_IOCTL_GETPARAM, NULL, 0) >= 0 )
+ {
+ switch(wrq.u.mode) {
+ case IEEE80211_AUTH_8021X:
+ c->auth_suites |= IWINFO_KMGMT_8021x;
+ break;
+
+ case IEEE80211_AUTH_WPA:
+ c->auth_suites |= IWINFO_KMGMT_PSK;
+ break;
+
+ case IEEE80211_AUTH_OPEN:
+ c->auth_algs |= IWINFO_AUTH_OPEN;
+ break;
+
+ case IEEE80211_AUTH_SHARED:
+ c->auth_algs |= IWINFO_AUTH_SHARED;
+ break;
+
+ default:
+ c->auth_suites |= IWINFO_KMGMT_NONE;
+ break;
+ }
+ }
+
+ memset(&wk, 0, sizeof(wk));
+ memset(wk.ik_macaddr, 0xff, IEEE80211_ADDR_LEN);
+
+ /* Get key information */
+ if( get80211priv(ifname, IEEE80211_IOCTL_GETKEY, &wk, sizeof(wk)) >= 0 )
+ {
+ /* Type 0 == WEP */
+ if( (wk.ik_type == 0) && (c->auth_algs == 0) )
+ c->auth_algs = (IWINFO_AUTH_OPEN | IWINFO_AUTH_SHARED);
+ }
+
+ /* Get used pairwise ciphers */
+ wrq.u.mode = IEEE80211_PARAM_UCASTCIPHERS;
+ if( madwifi_wrq(&wrq, ifname, IEEE80211_IOCTL_GETPARAM, NULL, 0) >= 0 )
+ {
+ ciphers = wrq.u.mode;
+
+ if( c->wpa_version && ciphers & (1 << IEEE80211_CIPHER_TKIP) )
+ c->pair_ciphers |= IWINFO_CIPHER_TKIP;
+
+ if( c->wpa_version && ciphers & (1 << IEEE80211_CIPHER_AES_CCM) )
+ c->pair_ciphers |= IWINFO_CIPHER_CCMP;
+
+ if( c->wpa_version && ciphers & (1 << IEEE80211_CIPHER_AES_OCB) )
+ c->pair_ciphers |= IWINFO_CIPHER_AESOCB;
+
+ if( c->wpa_version && ciphers & (1 << IEEE80211_CIPHER_CKIP) )
+ c->pair_ciphers |= IWINFO_CIPHER_CKIP;
+
+ if( !c->pair_ciphers && ciphers & (1 << IEEE80211_CIPHER_WEP) )
+ {
+ switch(key_len) {
+ case 13:
+ c->pair_ciphers |= IWINFO_CIPHER_WEP104;
+ break;
+
+ case 5:
+ c->pair_ciphers |= IWINFO_CIPHER_WEP40;
+ break;
+
+ case 0:
+ break;
+
+ default:
+ c->pair_ciphers = IWINFO_CIPHER_WEP40 |
+ IWINFO_CIPHER_WEP104;
+ break;
+ }
+ }
+
+ if( ciphers & (1 << IEEE80211_CIPHER_NONE) )
+ c->pair_ciphers |= IWINFO_CIPHER_NONE;
+ }
+
+ /* Get used group cipher */
+ wrq.u.mode = IEEE80211_PARAM_MCASTCIPHER;
+ if( madwifi_wrq(&wrq, ifname, IEEE80211_IOCTL_GETPARAM, NULL, 0) >= 0 )
+ {
+ ciphers = c->wpa_version ? wrq.u.mode : IEEE80211_CIPHER_WEP;
+
+ switch(ciphers) {
+ case IEEE80211_CIPHER_TKIP:
+ c->group_ciphers |= IWINFO_CIPHER_TKIP;
+ break;
+
+ case IEEE80211_CIPHER_AES_CCM:
+ c->group_ciphers |= IWINFO_CIPHER_CCMP;
+ break;
+
+ case IEEE80211_CIPHER_AES_OCB:
+ c->group_ciphers |= IWINFO_CIPHER_AESOCB;
+ break;
+
+ case IEEE80211_CIPHER_CKIP:
+ c->group_ciphers |= IWINFO_CIPHER_CKIP;
+ break;
+
+ case IEEE80211_CIPHER_WEP:
+ switch(key_len) {
+ case 13:
+ c->group_ciphers |= IWINFO_CIPHER_WEP104;
+ break;
+
+ case 5:
+ c->group_ciphers |= IWINFO_CIPHER_WEP40;
+ break;
+
+ default:
+ break;
+ }
+ break;
+
+ case IEEE80211_CIPHER_NONE:
+ c->group_ciphers |= IWINFO_CIPHER_NONE;
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ c->enabled = (c->wpa_version || (c->auth_algs && c->pair_ciphers)) ? 1 : 0;
+
+ return 0;
+}
+
+int madwifi_get_assoclist(const char *ifname, char *buf, int *len)
+{
+ int bl, tl, noise;
+ uint8_t *cp;
+ uint8_t tmp[24*1024];
+ struct ieee80211req_sta_info *si;
+ struct iwinfo_assoclist_entry entry;
+
+ if( (tl = get80211priv(ifname, IEEE80211_IOCTL_STA_INFO, tmp, 24*1024)) > 0 )
+ {
+ cp = tmp;
+ bl = 0;
+
+ if( madwifi_get_noise(ifname, &noise) )
+ noise = 0;
+
+ do {
+ si = (struct ieee80211req_sta_info *) cp;
+
+ memset(&entry, 0, sizeof(entry));
+
+ entry.signal = (si->isi_rssi - 95);
+ entry.noise = noise;
+ memcpy(entry.mac, &si->isi_macaddr, 6);
+
+ entry.inactive = si->isi_inact * 1000;
+
+ entry.tx_packets = (si->isi_txseqs[0] & IEEE80211_SEQ_SEQ_MASK)
+ >> IEEE80211_SEQ_SEQ_SHIFT;
+
+ entry.rx_packets = (si->isi_rxseqs[0] & IEEE80211_SEQ_SEQ_MASK)
+ >> IEEE80211_SEQ_SEQ_SHIFT;
+
+ entry.tx_rate.rate =
+ (si->isi_rates[si->isi_txrate] & IEEE80211_RATE_VAL) * 500;
+
+ /* XXX: this is just a guess */
+ entry.rx_rate.rate = entry.tx_rate.rate;
+
+ entry.rx_rate.mcs = -1;
+ entry.tx_rate.mcs = -1;
+
+ memcpy(&buf[bl], &entry, sizeof(struct iwinfo_assoclist_entry));
+
+ bl += sizeof(struct iwinfo_assoclist_entry);
+ cp += si->isi_len;
+ tl -= si->isi_len;
+ } while (tl >= sizeof(struct ieee80211req_sta_info));
+
+ *len = bl;
+ return 0;
+ }
+
+ return -1;
+}
+
+int madwifi_get_txpwrlist(const char *ifname, char *buf, int *len)
+{
+ int rc = -1;
+ char *res;
+
+ /* A wifiX device? */
+ if( madwifi_iswifi(ifname) )
+ {
+ if( (res = madwifi_ifadd(ifname)) != NULL )
+ {
+ rc = wext_get_txpwrlist(res, buf, len);
+ madwifi_ifdel(res);
+ }
+ }
+
+ /* Its an athX ... */
+ else if( !!madwifi_isvap(ifname, NULL) )
+ {
+ rc = wext_get_txpwrlist(ifname, buf, len);
+ }
+
+ return rc;
+}
+
+int madwifi_get_scanlist(const char *ifname, char *buf, int *len)
+{
+ int ret;
+ char *res;
+ DIR *proc;
+ struct dirent *e;
+
+ ret = -1;
+
+ /* We got a wifiX device passed, try to lookup a vap on it */
+ if( madwifi_iswifi(ifname) )
+ {
+ if( (proc = opendir("/proc/sys/net/")) != NULL )
+ {
+ while( (e = readdir(proc)) != NULL )
+ {
+ if( !!madwifi_isvap(e->d_name, ifname) )
+ {
+ if( iwinfo_ifup(e->d_name) )
+ {
+ ret = wext_get_scanlist(e->d_name, buf, len);
+ break;
+ }
+ }
+ }
+
+ closedir(proc);
+ }
+
+ /* Still nothing found, try to create a vap */
+ if( ret == -1 )
+ {
+ if( (res = madwifi_ifadd(ifname)) != NULL )
+ {
+ if( iwinfo_ifup(res) )
+ {
+ wext_get_scanlist(res, buf, len);
+ sleep(1);
+
+ wext_get_scanlist(res, buf, len);
+ sleep(1);
+
+ ret = wext_get_scanlist(res, buf, len);
+ }
+
+ iwinfo_ifdown(res);
+ madwifi_ifdel(res);
+ }
+ }
+ }
+
+ /* Got athX device? */
+ else if( !!madwifi_isvap(ifname, NULL) )
+ {
+ ret = wext_get_scanlist(ifname, buf, len);
+ }
+
+ return ret;
+}
+
+int madwifi_get_freqlist(const char *ifname, char *buf, int *len)
+{
+ int i, bl;
+ int rc = -1;
+ char *res;
+ struct ieee80211req_chaninfo chans;
+ struct iwinfo_freqlist_entry entry;
+
+ /* A wifiX device? */
+ if( madwifi_iswifi(ifname) )
+ {
+ if( (res = madwifi_ifadd(ifname)) != NULL )
+ {
+ rc = get80211priv(res, IEEE80211_IOCTL_GETCHANINFO,
+ &chans, sizeof(chans));
+
+ madwifi_ifdel(res);
+ }
+ }
+
+ /* Its an athX ... */
+ else if( !!madwifi_isvap(ifname, NULL) )
+ {
+ rc = get80211priv(ifname, IEEE80211_IOCTL_GETCHANINFO,
+ &chans, sizeof(chans));
+ }
+
+
+ /* Got chaninfo? */
+ if( rc >= 0 )
+ {
+ bl = 0;
+
+ for( i = 0; i < chans.ic_nchans; i++ )
+ {
+ entry.mhz = chans.ic_chans[i].ic_freq;
+ entry.channel = chans.ic_chans[i].ic_ieee;
+ entry.restricted = 0;
+
+ memcpy(&buf[bl], &entry, sizeof(struct iwinfo_freqlist_entry));
+ bl += sizeof(struct iwinfo_freqlist_entry);
+ }
+
+ *len = bl;
+ return 0;
+ }
+
+ return -1;
+}
+
+int madwifi_get_country(const char *ifname, char *buf)
+{
+ int i, fd, ccode = -1;
+ char buffer[34];
+ char *wifi = madwifi_iswifi(ifname)
+ ? (char *)ifname : madwifi_isvap(ifname, NULL);
+
+ struct ISO3166_to_CCode *e;
+
+ if( wifi )
+ {
+ snprintf(buffer, sizeof(buffer), "/proc/sys/dev/%s/countrycode", wifi);
+
+ if( (fd = open(buffer, O_RDONLY)) > -1 )
+ {
+ memset(buffer, 0, sizeof(buffer));
+
+ if( read(fd, buffer, sizeof(buffer)-1) > 0 )
+ ccode = atoi(buffer);
+
+ close(fd);
+ }
+ }
+
+ for( i = 0; i < (sizeof(CountryCodes)/sizeof(CountryCodes[0])); i++ )
+ {
+ e = &CountryCodes[i];
+
+ if( e->ccode == ccode )
+ {
+ sprintf(buf, "%c%c", e->iso3166 / 256, e->iso3166 % 256);
+ return 0;
+ }
+ }
+
+ return -1;
+}
+
+int madwifi_get_countrylist(const char *ifname, char *buf, int *len)
+{
+ int i, count;
+ struct ISO3166_to_CCode *e, *p = NULL;
+ struct iwinfo_country_entry *c = (struct iwinfo_country_entry *)buf;
+
+ count = 0;
+
+ for( int i = 0; i < (sizeof(CountryCodes)/sizeof(CountryCodes[0])); i++ )
+ {
+ e = &CountryCodes[i];
+
+ if( !p || (e->iso3166 != p->iso3166) )
+ {
+ c->iso3166 = e->iso3166;
+ snprintf(c->ccode, sizeof(c->ccode), "%i", e->ccode);
+
+ c++;
+ count++;
+ }
+
+ p = e;
+ }
+
+ *len = (count * sizeof(struct iwinfo_country_entry));
+ return 0;
+}
+
+int madwifi_get_hwmodelist(const char *ifname, int *buf)
+{
+ char chans[IWINFO_BUFSIZE] = { 0 };
+ struct iwinfo_freqlist_entry *e = NULL;
+ int len = 0;
+
+ if( !madwifi_get_freqlist(ifname, chans, &len) )
+ {
+ for( e = (struct iwinfo_freqlist_entry *)chans; e->channel; e++ )
+ {
+ if( e->channel <= 14 )
+ {
+ *buf |= IWINFO_80211_B;
+ *buf |= IWINFO_80211_G;
+ }
+ else
+ {
+ *buf |= IWINFO_80211_A;
+ }
+ }
+
+ return 0;
+ }
+
+ return -1;
+}
+
+int madwifi_get_mbssid_support(const char *ifname, int *buf)
+{
+ /* Test whether we can create another interface */
+ char *nif = madwifi_ifadd(ifname);
+
+ if( nif )
+ {
+ *buf = iwinfo_ifup(nif);
+
+ iwinfo_ifdown(nif);
+ madwifi_ifdel(nif);
+
+ return 0;
+ }
+
+ return -1;
+}
+
+int madwifi_get_hardware_id(const char *ifname, char *buf)
+{
+ char vendor[64];
+ char device[64];
+ struct iwinfo_hardware_id *ids;
+ struct iwinfo_hardware_entry *e;
+ const char *phy = madwifi_phyname(ifname);
+
+ if (wext_get_hardware_id(phy, buf))
+ return iwinfo_hardware_id_from_mtd((struct iwinfo_hardware_id *)buf);
+
+ return 0;
+}
+
+static const struct iwinfo_hardware_entry *
+madwifi_get_hardware_entry(const char *ifname)
+{
+ struct iwinfo_hardware_id id;
+
+ if (madwifi_get_hardware_id(ifname, (char *)&id))
+ return NULL;
+
+ return iwinfo_hardware(&id);
+}
+
+int madwifi_get_hardware_name(const char *ifname, char *buf)
+{
+ const struct iwinfo_hardware_entry *hw;
+
+ if (!(hw = madwifi_get_hardware_entry(ifname)))
+ sprintf(buf, "Generic Atheros");
+ else
+ sprintf(buf, "%s %s", hw->vendor_name, hw->device_name);
+
+ return 0;
+}
+
+int madwifi_get_txpower_offset(const char *ifname, int *buf)
+{
+ const struct iwinfo_hardware_entry *hw;
+
+ if (!(hw = madwifi_get_hardware_entry(ifname)))
+ return -1;
+
+ *buf = hw->txpower_offset;
+ return 0;
+}
+
+int madwifi_get_frequency_offset(const char *ifname, int *buf)
+{
+ const struct iwinfo_hardware_entry *hw;
+
+ if (!(hw = madwifi_get_hardware_entry(ifname)))
+ return -1;
+
+ *buf = hw->frequency_offset;
+ return 0;
+}
diff --git a/package/network/utils/iwinfo/src/.svn/text-base/iwinfo_nl80211.c.svn-base b/package/network/utils/iwinfo/src/.svn/text-base/iwinfo_nl80211.c.svn-base
new file mode 100644
index 0000000..819845a
--- /dev/null
+++ b/package/network/utils/iwinfo/src/.svn/text-base/iwinfo_nl80211.c.svn-base
@@ -0,0 +1,2246 @@
+/*
+ * iwinfo - Wireless Information Library - NL80211 Backend
+ *
+ * Copyright (C) 2010-2013 Jo-Philipp Wich <xm@subsignal.org>
+ *
+ * The iwinfo library is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * The iwinfo library 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 the iwinfo library. If not, see http://www.gnu.org/licenses/.
+ *
+ * The signal handling code is derived from the official madwifi tools,
+ * wlanconfig.c in particular. The encryption property handling was
+ * inspired by the hostapd madwifi driver.
+ *
+ * Parts of this code are derived from the Linux iw utility.
+ */
+
+#include "iwinfo/nl80211.h"
+#include "iwinfo/wext.h"
+
+#define min(x, y) ((x) < (y)) ? (x) : (y)
+
+static struct nl80211_state *nls = NULL;
+
+static int nl80211_init(void)
+{
+ int err, fd;
+
+ if (!nls)
+ {
+ nls = malloc(sizeof(struct nl80211_state));
+ if (!nls) {
+ err = -ENOMEM;
+ goto err;
+ }
+
+ memset(nls, 0, sizeof(*nls));
+
+ nls->nl_sock = nl_socket_alloc();
+ if (!nls->nl_sock) {
+ err = -ENOMEM;
+ goto err;
+ }
+
+ if (genl_connect(nls->nl_sock)) {
+ err = -ENOLINK;
+ goto err;
+ }
+
+ fd = nl_socket_get_fd(nls->nl_sock);
+ if (fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC) < 0) {
+ err = -EINVAL;
+ goto err;
+ }
+
+ if (genl_ctrl_alloc_cache(nls->nl_sock, &nls->nl_cache)) {
+ err = -ENOMEM;
+ goto err;
+ }
+
+ nls->nl80211 = genl_ctrl_search_by_name(nls->nl_cache, "nl80211");
+ if (!nls->nl80211) {
+ err = -ENOENT;
+ goto err;
+ }
+
+ nls->nlctrl = genl_ctrl_search_by_name(nls->nl_cache, "nlctrl");
+ if (!nls->nlctrl) {
+ err = -ENOENT;
+ goto err;
+ }
+ }
+
+ return 0;
+
+
+err:
+ nl80211_close();
+ return err;
+}
+
+
+static int nl80211_msg_error(struct sockaddr_nl *nla,
+ struct nlmsgerr *err, void *arg)
+{
+ int *ret = arg;
+ *ret = err->error;
+ return NL_STOP;
+}
+
+static int nl80211_msg_finish(struct nl_msg *msg, void *arg)
+{
+ int *ret = arg;
+ *ret = 0;
+ return NL_SKIP;
+}
+
+static int nl80211_msg_ack(struct nl_msg *msg, void *arg)
+{
+ int *ret = arg;
+ *ret = 0;
+ return NL_STOP;
+}
+
+static int nl80211_msg_response(struct nl_msg *msg, void *arg)
+{
+ return NL_SKIP;
+}
+
+static void nl80211_free(struct nl80211_msg_conveyor *cv)
+{
+ if (cv)
+ {
+ if (cv->cb)
+ nl_cb_put(cv->cb);
+
+ if (cv->msg)
+ nlmsg_free(cv->msg);
+
+ cv->cb = NULL;
+ cv->msg = NULL;
+ }
+}
+
+static struct nl80211_msg_conveyor * nl80211_new(struct genl_family *family,
+ int cmd, int flags)
+{
+ static struct nl80211_msg_conveyor cv;
+
+ struct nl_msg *req = NULL;
+ struct nl_cb *cb = NULL;
+
+ req = nlmsg_alloc();
+ if (!req)
+ goto err;
+
+ cb = nl_cb_alloc(NL_CB_DEFAULT);
+ if (!cb)
+ goto err;
+
+ genlmsg_put(req, 0, 0, genl_family_get_id(family), 0, flags, cmd, 0);
+
+ cv.msg = req;
+ cv.cb = cb;
+
+ return &cv;
+
+err:
+nla_put_failure:
+ if (cb)
+ nl_cb_put(cb);
+
+ if (req)
+ nlmsg_free(req);
+
+ return NULL;
+}
+
+static struct nl80211_msg_conveyor * nl80211_ctl(int cmd, int flags)
+{
+ if (nl80211_init() < 0)
+ return NULL;
+
+ return nl80211_new(nls->nlctrl, cmd, flags);
+}
+
+static struct nl80211_msg_conveyor * nl80211_msg(const char *ifname,
+ int cmd, int flags)
+{
+ int ifidx = -1, phyidx = -1;
+ struct nl80211_msg_conveyor *cv;
+
+ if (nl80211_init() < 0)
+ return NULL;
+
+ if (!strncmp(ifname, "phy", 3))
+ phyidx = atoi(&ifname[3]);
+ else if (!strncmp(ifname, "radio", 5))
+ phyidx = atoi(&ifname[5]);
+ else if (!strncmp(ifname, "mon.", 4))
+ ifidx = if_nametoindex(&ifname[4]);
+ else
+ ifidx = if_nametoindex(ifname);
+
+ if ((ifidx < 0) && (phyidx < 0))
+ return NULL;
+
+ cv = nl80211_new(nls->nl80211, cmd, flags);
+ if (!cv)
+ return NULL;
+
+ if (ifidx > -1)
+ NLA_PUT_U32(cv->msg, NL80211_ATTR_IFINDEX, ifidx);
+
+ if (phyidx > -1)
+ NLA_PUT_U32(cv->msg, NL80211_ATTR_WIPHY, phyidx);
+
+ return cv;
+
+nla_put_failure:
+ nl80211_free(cv);
+ return NULL;
+}
+
+static struct nl80211_msg_conveyor * nl80211_send(
+ struct nl80211_msg_conveyor *cv,
+ int (*cb_func)(struct nl_msg *, void *), void *cb_arg
+) {
+ static struct nl80211_msg_conveyor rcv;
+ int err = 1;
+
+ if (cb_func)
+ nl_cb_set(cv->cb, NL_CB_VALID, NL_CB_CUSTOM, cb_func, cb_arg);
+ else
+ nl_cb_set(cv->cb, NL_CB_VALID, NL_CB_CUSTOM, nl80211_msg_response, &rcv);
+
+ if (nl_send_auto_complete(nls->nl_sock, cv->msg) < 0)
+ goto err;
+
+ nl_cb_err(cv->cb, NL_CB_CUSTOM, nl80211_msg_error, &err);
+ nl_cb_set(cv->cb, NL_CB_FINISH, NL_CB_CUSTOM, nl80211_msg_finish, &err);
+ nl_cb_set(cv->cb, NL_CB_ACK, NL_CB_CUSTOM, nl80211_msg_ack, &err);
+
+ while (err > 0)
+ nl_recvmsgs(nls->nl_sock, cv->cb);
+
+ return &rcv;
+
+err:
+ nl_cb_put(cv->cb);
+ nlmsg_free(cv->msg);
+
+ return NULL;
+}
+
+static struct nlattr ** nl80211_parse(struct nl_msg *msg)
+{
+ struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
+ static struct nlattr *attr[NL80211_ATTR_MAX + 1];
+
+ nla_parse(attr, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
+ genlmsg_attrlen(gnlh, 0), NULL);
+
+ return attr;
+}
+
+
+static int nl80211_subscribe_cb(struct nl_msg *msg, void *arg)
+{
+ struct nl80211_group_conveyor *cv = arg;
+
+ struct nlattr **attr = nl80211_parse(msg);
+ struct nlattr *mgrpinfo[CTRL_ATTR_MCAST_GRP_MAX + 1];
+ struct nlattr *mgrp;
+ int mgrpidx;
+
+ if (!attr[CTRL_ATTR_MCAST_GROUPS])
+ return NL_SKIP;
+
+ nla_for_each_nested(mgrp, attr[CTRL_ATTR_MCAST_GROUPS], mgrpidx)
+ {
+ nla_parse(mgrpinfo, CTRL_ATTR_MCAST_GRP_MAX,
+ nla_data(mgrp), nla_len(mgrp), NULL);
+
+ if (mgrpinfo[CTRL_ATTR_MCAST_GRP_ID] &&
+ mgrpinfo[CTRL_ATTR_MCAST_GRP_NAME] &&
+ !strncmp(nla_data(mgrpinfo[CTRL_ATTR_MCAST_GRP_NAME]),
+ cv->name, nla_len(mgrpinfo[CTRL_ATTR_MCAST_GRP_NAME])))
+ {
+ cv->id = nla_get_u32(mgrpinfo[CTRL_ATTR_MCAST_GRP_ID]);
+ break;
+ }
+ }
+
+ return NL_SKIP;
+}
+
+static int nl80211_subscribe(const char *family, const char *group)
+{
+ struct nl80211_group_conveyor cv = { .name = group, .id = -ENOENT };
+ struct nl80211_msg_conveyor *req;
+
+ req = nl80211_ctl(CTRL_CMD_GETFAMILY, 0);
+ if (req)
+ {
+ NLA_PUT_STRING(req->msg, CTRL_ATTR_FAMILY_NAME, family);
+ nl80211_send(req, nl80211_subscribe_cb, &cv);
+
+nla_put_failure:
+ nl80211_free(req);
+ }
+
+ return nl_socket_add_membership(nls->nl_sock, cv.id);
+}
+
+
+static int nl80211_wait_cb(struct nl_msg *msg, void *arg)
+{
+ struct nl80211_event_conveyor *cv = arg;
+ struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
+
+ if (gnlh->cmd == cv->wait)
+ cv->recv = gnlh->cmd;
+
+ return NL_SKIP;
+}
+
+static int nl80211_wait_seq_check(struct nl_msg *msg, void *arg)
+{
+ return NL_OK;
+}
+
+static int nl80211_wait(const char *family, const char *group, int cmd)
+{
+ struct nl80211_event_conveyor cv = { .wait = cmd };
+ struct nl_cb *cb;
+
+ if (nl80211_subscribe(family, group))
+ return -ENOENT;
+
+ cb = nl_cb_alloc(NL_CB_DEFAULT);
+
+ if (!cb)
+ return -ENOMEM;
+
+ nl_cb_set(cb, NL_CB_SEQ_CHECK, NL_CB_CUSTOM, nl80211_wait_seq_check, NULL);
+ nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, nl80211_wait_cb, &cv );
+
+ while (!cv.recv)
+ nl_recvmsgs(nls->nl_sock, cb);
+
+ nl_cb_put(cb);
+
+ return 0;
+}
+
+
+static int nl80211_freq2channel(int freq)
+{
+ if (freq == 2484)
+ return 14;
+
+ if (freq < 2484)
+ return (freq - 2407) / 5;
+
+ return (freq / 5) - 1000;
+}
+
+static int nl80211_channel2freq(int channel, const char *band)
+{
+ if (channel == 14)
+ return 2484;
+
+ if ((channel < 14) && (!band || band[0] != 'a'))
+ return (channel * 5) + 2407;
+
+ if (channel > 0)
+ return (1000 + channel) * 5;
+
+ return 0;
+}
+
+static char * nl80211_getval(const char *ifname, const char *buf, const char *key)
+{
+ int i, len;
+ char lkey[64] = { 0 };
+ const char *ln = buf;
+ static char lval[256] = { 0 };
+
+ int matched_if = ifname ? 0 : 1;
+
+
+ for( i = 0, len = strlen(buf); i < len; i++ )
+ {
+ if (!lkey[0] && (buf[i] == ' ' || buf[i] == '\t'))
+ {
+ ln++;
+ }
+ else if (!lkey[0] && (buf[i] == '='))
+ {
+ if ((&buf[i] - ln) > 0)
+ memcpy(lkey, ln, min(sizeof(lkey) - 1, &buf[i] - ln));
+ }
+ else if (buf[i] == '\n')
+ {
+ if (lkey[0])
+ {
+ memcpy(lval, ln + strlen(lkey) + 1,
+ min(sizeof(lval) - 1, &buf[i] - ln - strlen(lkey) - 1));
+
+ if ((ifname != NULL) &&
+ (!strcmp(lkey, "interface") || !strcmp(lkey, "bss")) )
+ {
+ matched_if = !strcmp(lval, ifname);
+ }
+ else if (matched_if && !strcmp(lkey, key))
+ {
+ return lval;
+ }
+ }
+
+ ln = &buf[i+1];
+ memset(lkey, 0, sizeof(lkey));
+ memset(lval, 0, sizeof(lval));
+ }
+ }
+
+ return NULL;
+}
+
+static int nl80211_ifname2phy_cb(struct nl_msg *msg, void *arg)
+{
+ char *buf = arg;
+ struct nlattr **attr = nl80211_parse(msg);
+
+ if (attr[NL80211_ATTR_WIPHY_NAME])
+ memcpy(buf, nla_data(attr[NL80211_ATTR_WIPHY_NAME]),
+ nla_len(attr[NL80211_ATTR_WIPHY_NAME]));
+ else
+ buf[0] = 0;
+
+ return NL_SKIP;
+}
+
+static char * nl80211_ifname2phy(const char *ifname)
+{
+ static char phy[32] = { 0 };
+ struct nl80211_msg_conveyor *req;
+
+ memset(phy, 0, sizeof(phy));
+
+ req = nl80211_msg(ifname, NL80211_CMD_GET_WIPHY, 0);
+ if (req)
+ {
+ nl80211_send(req, nl80211_ifname2phy_cb, phy);
+ nl80211_free(req);
+ }
+
+ return phy[0] ? phy : NULL;
+}
+
+static char * nl80211_hostapd_info(const char *ifname)
+{
+ int mode;
+ char *phy;
+ char path[32] = { 0 };
+ static char buf[4096] = { 0 };
+ FILE *conf;
+
+ if (nl80211_get_mode(ifname, &mode))
+ return NULL;
+
+ if ((mode == IWINFO_OPMODE_MASTER || mode == IWINFO_OPMODE_AP_VLAN) &&
+ (phy = nl80211_ifname2phy(ifname)) != NULL)
+ {
+ snprintf(path, sizeof(path), "/var/run/hostapd-%s.conf", phy);
+
+ if ((conf = fopen(path, "r")) != NULL)
+ {
+ fread(buf, sizeof(buf) - 1, 1, conf);
+ fclose(conf);
+
+ return buf;
+ }
+ }
+
+ return NULL;
+}
+
+static inline int nl80211_wpactl_recv(int sock, char *buf, int blen)
+{
+ fd_set rfds;
+ struct timeval tv = { 2, 0 };
+
+ FD_ZERO(&rfds);
+ FD_SET(sock, &rfds);
+
+ memset(buf, 0, blen);
+
+
+ if (select(sock + 1, &rfds, NULL, NULL, &tv) < 0)
+ return -1;
+
+ if (!FD_ISSET(sock, &rfds))
+ return -1;
+
+ return recv(sock, buf, blen, 0);
+}
+
+static char * nl80211_wpactl_info(const char *ifname, const char *cmd,
+ const char *event)
+{
+ int numtry = 0;
+ int sock = -1;
+ char *rv = NULL;
+ size_t remote_length, local_length;
+ static char buffer[10240] = { 0 };
+
+ struct sockaddr_un local = { 0 };
+ struct sockaddr_un remote = { 0 };
+
+
+ sock = socket(PF_UNIX, SOCK_DGRAM, 0);
+ if (sock < 0)
+ return NULL;
+
+ remote.sun_family = AF_UNIX;
+ remote_length = sizeof(remote.sun_family) + sprintf(remote.sun_path,
+ "/var/run/wpa_supplicant-%s/%s", ifname, ifname);
+
+ if (fcntl(sock, F_SETFD, fcntl(sock, F_GETFD) | FD_CLOEXEC) < 0)
+ goto out;
+
+ if (connect(sock, (struct sockaddr *) &remote, remote_length))
+ goto out;
+
+ local.sun_family = AF_UNIX;
+ local_length = sizeof(local.sun_family) +
+ sprintf(local.sun_path, "/var/run/iwinfo-%s-%d", ifname, getpid());
+
+ if (bind(sock, (struct sockaddr *) &local, local_length))
+ goto out;
+
+
+ if (event)
+ {
+ send(sock, "ATTACH", 6, 0);
+
+ if (nl80211_wpactl_recv(sock, buffer, sizeof(buffer)) <= 0)
+ goto out;
+ }
+
+
+ send(sock, cmd, strlen(cmd), 0);
+
+ while( numtry++ < 5 )
+ {
+ if (nl80211_wpactl_recv(sock, buffer, sizeof(buffer)) <= 0)
+ {
+ if (event)
+ continue;
+
+ break;
+ }
+
+ if ((!event && buffer[0] != '<') || (event && strstr(buffer, event)))
+ break;
+ }
+
+ rv = buffer;
+
+out:
+ close(sock);
+
+ if (local.sun_family)
+ unlink(local.sun_path);
+
+ return rv;
+}
+
+static inline int nl80211_readint(const char *path)
+{
+ int fd;
+ int rv = -1;
+ char buffer[16];
+
+ if ((fd = open(path, O_RDONLY)) > -1)
+ {
+ if (read(fd, buffer, sizeof(buffer)) > 0)
+ rv = atoi(buffer);
+
+ close(fd);
+ }
+
+ return rv;
+}
+
+static char * nl80211_phy2ifname(const char *ifname)
+{
+ int fd, ifidx = -1, cifidx = -1, phyidx = -1;
+ char buffer[64];
+ static char nif[IFNAMSIZ] = { 0 };
+
+ DIR *d;
+ struct dirent *e;
+
+ if (!ifname)
+ return NULL;
+ else if (!strncmp(ifname, "phy", 3))
+ phyidx = atoi(&ifname[3]);
+ else if (!strncmp(ifname, "radio", 5))
+ phyidx = atoi(&ifname[5]);
+
+ memset(nif, 0, sizeof(nif));
+
+ if (phyidx > -1)
+ {
+ if ((d = opendir("/sys/class/net")) != NULL)
+ {
+ while ((e = readdir(d)) != NULL)
+ {
+ snprintf(buffer, sizeof(buffer),
+ "/sys/class/net/%s/phy80211/index", e->d_name);
+
+ if (nl80211_readint(buffer) == phyidx)
+ {
+ snprintf(buffer, sizeof(buffer),
+ "/sys/class/net/%s/ifindex", e->d_name);
+
+ if ((cifidx = nl80211_readint(buffer)) >= 0 &&
+ ((ifidx < 0) || (cifidx < ifidx)))
+ {
+ ifidx = cifidx;
+ strncpy(nif, e->d_name, sizeof(nif));
+ }
+ }
+ }
+
+ closedir(d);
+ }
+ }
+
+ return nif[0] ? nif : NULL;
+}
+
+static char * nl80211_ifadd(const char *ifname)
+{
+ int phyidx;
+ char *rv = NULL;
+ static char nif[IFNAMSIZ] = { 0 };
+ struct nl80211_msg_conveyor *req, *res;
+
+ req = nl80211_msg(ifname, NL80211_CMD_NEW_INTERFACE, 0);
+ if (req)
+ {
+ snprintf(nif, sizeof(nif), "tmp.%s", ifname);
+
+ NLA_PUT_STRING(req->msg, NL80211_ATTR_IFNAME, nif);
+ NLA_PUT_U32(req->msg, NL80211_ATTR_IFTYPE, NL80211_IFTYPE_STATION);
+
+ nl80211_send(req, NULL, NULL);
+
+ rv = nif;
+
+ nla_put_failure:
+ nl80211_free(req);
+ }
+
+ return rv;
+}
+
+static void nl80211_ifdel(const char *ifname)
+{
+ struct nl80211_msg_conveyor *req;
+
+ req = nl80211_msg(ifname, NL80211_CMD_DEL_INTERFACE, 0);
+ if (req)
+ {
+ NLA_PUT_STRING(req->msg, NL80211_ATTR_IFNAME, ifname);
+
+ nl80211_send(req, NULL, NULL);
+
+ nla_put_failure:
+ nl80211_free(req);
+ }
+}
+
+static void nl80211_hostapd_hup(const char *ifname)
+{
+ int fd, pid = 0;
+ char buf[32];
+ char *phy = nl80211_ifname2phy(ifname);
+
+ if (phy)
+ {
+ snprintf(buf, sizeof(buf), "/var/run/wifi-%s.pid", phy);
+ if ((fd = open(buf, O_RDONLY)) > 0)
+ {
+ if (read(fd, buf, sizeof(buf)) > 0)
+ pid = atoi(buf);
+
+ close(fd);
+ }
+
+ if (pid > 0)
+ kill(pid, 1);
+ }
+}
+
+
+int nl80211_probe(const char *ifname)
+{
+ return !!nl80211_ifname2phy(ifname);
+}
+
+void nl80211_close(void)
+{
+ if (nls)
+ {
+ if (nls->nlctrl)
+ genl_family_put(nls->nlctrl);
+
+ if (nls->nl80211)
+ genl_family_put(nls->nl80211);
+
+ if (nls->nl_sock)
+ nl_socket_free(nls->nl_sock);
+
+ if (nls->nl_cache)
+ nl_cache_free(nls->nl_cache);
+
+ free(nls);
+ nls = NULL;
+ }
+}
+
+
+static int nl80211_get_mode_cb(struct nl_msg *msg, void *arg)
+{
+ int *mode = arg;
+ struct nlattr **tb = nl80211_parse(msg);
+ const int ifmodes[NL80211_IFTYPE_MAX + 1] = {
+ IWINFO_OPMODE_UNKNOWN, /* unspecified */
+ IWINFO_OPMODE_ADHOC, /* IBSS */
+ IWINFO_OPMODE_CLIENT, /* managed */
+ IWINFO_OPMODE_MASTER, /* AP */
+ IWINFO_OPMODE_AP_VLAN, /* AP/VLAN */
+ IWINFO_OPMODE_WDS, /* WDS */
+ IWINFO_OPMODE_MONITOR, /* monitor */
+ IWINFO_OPMODE_MESHPOINT, /* mesh point */
+ IWINFO_OPMODE_P2P_CLIENT, /* P2P-client */
+ IWINFO_OPMODE_P2P_GO, /* P2P-GO */
+ };
+
+ if (tb[NL80211_ATTR_IFTYPE])
+ *mode = ifmodes[nla_get_u32(tb[NL80211_ATTR_IFTYPE])];
+
+ return NL_SKIP;
+}
+
+int nl80211_get_mode(const char *ifname, int *buf)
+{
+ char *res;
+ struct nl80211_msg_conveyor *req;
+
+ res = nl80211_phy2ifname(ifname);
+ req = nl80211_msg(res ? res : ifname, NL80211_CMD_GET_INTERFACE, 0);
+ *buf = IWINFO_OPMODE_UNKNOWN;
+
+ if (req)
+ {
+ nl80211_send(req, nl80211_get_mode_cb, buf);
+ nl80211_free(req);
+ }
+
+ return (*buf == IWINFO_OPMODE_UNKNOWN) ? -1 : 0;
+}
+
+
+struct nl80211_ssid_bssid {
+ unsigned char *ssid;
+ unsigned char bssid[7];
+};
+
+static int nl80211_get_ssid_bssid_cb(struct nl_msg *msg, void *arg)
+{
+ int ielen;
+ unsigned char *ie;
+ struct nl80211_ssid_bssid *sb = arg;
+ struct nlattr **tb = nl80211_parse(msg);
+ struct nlattr *bss[NL80211_BSS_MAX + 1];
+
+ static struct nla_policy bss_policy[NL80211_BSS_MAX + 1] = {
+ [NL80211_BSS_INFORMATION_ELEMENTS] = { },
+ [NL80211_BSS_STATUS] = { .type = NLA_U32 },
+ };
+
+ if (!tb[NL80211_ATTR_BSS] ||
+ nla_parse_nested(bss, NL80211_BSS_MAX, tb[NL80211_ATTR_BSS],
+ bss_policy) ||
+ !bss[NL80211_BSS_BSSID] ||
+ !bss[NL80211_BSS_STATUS] ||
+ !bss[NL80211_BSS_INFORMATION_ELEMENTS])
+ {
+ return NL_SKIP;
+ }
+
+ switch (nla_get_u32(bss[NL80211_BSS_STATUS]))
+ {
+ case NL80211_BSS_STATUS_ASSOCIATED:
+ case NL80211_BSS_STATUS_AUTHENTICATED:
+ case NL80211_BSS_STATUS_IBSS_JOINED:
+
+ if (sb->ssid)
+ {
+ ie = nla_data(bss[NL80211_BSS_INFORMATION_ELEMENTS]);
+ ielen = nla_len(bss[NL80211_BSS_INFORMATION_ELEMENTS]);
+
+ while (ielen >= 2 && ielen >= ie[1])
+ {
+ if (ie[0] == 0)
+ {
+ memcpy(sb->ssid, ie + 2, min(ie[1], IWINFO_ESSID_MAX_SIZE));
+ return NL_SKIP;
+ }
+
+ ielen -= ie[1] + 2;
+ ie += ie[1] + 2;
+ }
+ }
+ else
+ {
+ sb->bssid[0] = 1;
+ memcpy(sb->bssid + 1, nla_data(bss[NL80211_BSS_BSSID]), 6);
+ return NL_SKIP;
+ }
+
+ default:
+ return NL_SKIP;
+ }
+}
+
+int nl80211_get_ssid(const char *ifname, char *buf)
+{
+ char *res;
+ struct nl80211_msg_conveyor *req;
+ struct nl80211_ssid_bssid sb;
+
+ /* try to find ssid from scan dump results */
+ res = nl80211_phy2ifname(ifname);
+ req = nl80211_msg(res ? res : ifname, NL80211_CMD_GET_SCAN, NLM_F_DUMP);
+
+ sb.ssid = buf;
+ *buf = 0;
+
+ if (req)
+ {
+ nl80211_send(req, nl80211_get_ssid_bssid_cb, &sb);
+ nl80211_free(req);
+ }
+
+ /* failed, try to find from hostapd info */
+ if ((*buf == 0) &&
+ (res = nl80211_hostapd_info(ifname)) &&
+ (res = nl80211_getval(ifname, res, "ssid")))
+ {
+ memcpy(buf, res, strlen(res));
+ }
+
+ return (*buf == 0) ? -1 : 0;
+}
+
+int nl80211_get_bssid(const char *ifname, char *buf)
+{
+ char *res;
+ struct nl80211_msg_conveyor *req;
+ struct nl80211_ssid_bssid sb;
+
+ /* try to find bssid from scan dump results */
+ res = nl80211_phy2ifname(ifname);
+ req = nl80211_msg(res ? res : ifname, NL80211_CMD_GET_SCAN, NLM_F_DUMP);
+
+ sb.ssid = NULL;
+ sb.bssid[0] = 0;
+
+ if (req)
+ {
+ nl80211_send(req, nl80211_get_ssid_bssid_cb, &sb);
+ nl80211_free(req);
+ }
+
+ /* failed, try to find mac from hostapd info */
+ if ((sb.bssid[0] == 0) &&
+ (res = nl80211_hostapd_info(ifname)) &&
+ (res = nl80211_getval(ifname, res, "bssid")))
+ {
+ sb.bssid[0] = 1;
+ sb.bssid[1] = strtol(&res[0], NULL, 16);
+ sb.bssid[2] = strtol(&res[3], NULL, 16);
+ sb.bssid[3] = strtol(&res[6], NULL, 16);
+ sb.bssid[4] = strtol(&res[9], NULL, 16);
+ sb.bssid[5] = strtol(&res[12], NULL, 16);
+ sb.bssid[6] = strtol(&res[15], NULL, 16);
+ }
+
+ if (sb.bssid[0])
+ {
+ sprintf(buf, "%02X:%02X:%02X:%02X:%02X:%02X",
+ sb.bssid[1], sb.bssid[2], sb.bssid[3],
+ sb.bssid[4], sb.bssid[5], sb.bssid[6]);
+
+ return 0;
+ }
+
+ return -1;
+}
+
+
+static int nl80211_get_frequency_scan_cb(struct nl_msg *msg, void *arg)
+{
+ int *freq = arg;
+ struct nlattr **attr = nl80211_parse(msg);
+ struct nlattr *binfo[NL80211_BSS_MAX + 1];
+
+ static struct nla_policy bss_policy[NL80211_BSS_MAX + 1] = {
+ [NL80211_BSS_FREQUENCY] = { .type = NLA_U32 },
+ };
+
+ if (attr[NL80211_ATTR_BSS] &&
+ !nla_parse_nested(binfo, NL80211_BSS_MAX,
+ attr[NL80211_ATTR_BSS], bss_policy))
+ {
+ if (binfo[NL80211_BSS_FREQUENCY])
+ *freq = nla_get_u32(binfo[NL80211_BSS_FREQUENCY]);
+ }
+
+ return NL_SKIP;
+}
+
+static int nl80211_get_frequency_info_cb(struct nl_msg *msg, void *arg)
+{
+ int *freq = arg;
+ struct nlattr **tb = nl80211_parse(msg);
+
+ if (tb[NL80211_ATTR_WIPHY_FREQ])
+ *freq = nla_get_u32(tb[NL80211_ATTR_WIPHY_FREQ]);
+
+ return NL_SKIP;
+}
+
+int nl80211_get_frequency(const char *ifname, int *buf)
+{
+ char *res, *channel;
+ struct nl80211_msg_conveyor *req;
+
+ /* try to find frequency from interface info */
+ res = nl80211_phy2ifname(ifname);
+ req = nl80211_msg(res ? res : ifname, NL80211_CMD_GET_INTERFACE, 0);
+ *buf = 0;
+
+ if (req)
+ {
+ nl80211_send(req, nl80211_get_frequency_info_cb, buf);
+ nl80211_free(req);
+ }
+
+ /* failed, try to find frequency from hostapd info */
+ if ((*buf == 0) &&
+ (res = nl80211_hostapd_info(ifname)) &&
+ (channel = nl80211_getval(NULL, res, "channel")))
+ {
+ *buf = nl80211_channel2freq(atoi(channel),
+ nl80211_getval(NULL, res, "hw_mode"));
+ }
+ else
+ {
+ /* failed, try to find frequency from scan results */
+ if (*buf == 0)
+ {
+ res = nl80211_phy2ifname(ifname);
+ req = nl80211_msg(res ? res : ifname, NL80211_CMD_GET_SCAN,
+ NLM_F_DUMP);
+
+ if (req)
+ {
+ nl80211_send(req, nl80211_get_frequency_scan_cb, buf);
+ nl80211_free(req);
+ }
+ }
+ }
+
+ return (*buf == 0) ? -1 : 0;
+}
+
+int nl80211_get_channel(const char *ifname, int *buf)
+{
+ if (!nl80211_get_frequency(ifname, buf))
+ {
+ *buf = nl80211_freq2channel(*buf);
+ return 0;
+ }
+
+ return -1;
+}
+
+
+int nl80211_get_txpower(const char *ifname, int *buf)
+{
+#if 0
+ char *res;
+ char path[PATH_MAX];
+
+ res = nl80211_ifname2phy(ifname);
+ snprintf(path, sizeof(path), "/sys/kernel/debug/ieee80211/%s/power",
+ res ? res : ifname);
+
+ if ((*buf = nl80211_readint(path)) > -1)
+ return 0;
+#endif
+
+ return wext_get_txpower(ifname, buf);
+}
+
+
+static int nl80211_fill_signal_cb(struct nl_msg *msg, void *arg)
+{
+ int8_t dbm;
+ int16_t mbit;
+ struct nl80211_rssi_rate *rr = arg;
+ struct nlattr **attr = nl80211_parse(msg);
+ struct nlattr *sinfo[NL80211_STA_INFO_MAX + 1];
+ struct nlattr *rinfo[NL80211_RATE_INFO_MAX + 1];
+
+ static struct nla_policy stats_policy[NL80211_STA_INFO_MAX + 1] = {
+ [NL80211_STA_INFO_INACTIVE_TIME] = { .type = NLA_U32 },
+ [NL80211_STA_INFO_RX_BYTES] = { .type = NLA_U32 },
+ [NL80211_STA_INFO_TX_BYTES] = { .type = NLA_U32 },
+ [NL80211_STA_INFO_RX_PACKETS] = { .type = NLA_U32 },
+ [NL80211_STA_INFO_TX_PACKETS] = { .type = NLA_U32 },
+ [NL80211_STA_INFO_SIGNAL] = { .type = NLA_U8 },
+ [NL80211_STA_INFO_TX_BITRATE] = { .type = NLA_NESTED },
+ [NL80211_STA_INFO_LLID] = { .type = NLA_U16 },
+ [NL80211_STA_INFO_PLID] = { .type = NLA_U16 },
+ [NL80211_STA_INFO_PLINK_STATE] = { .type = NLA_U8 },
+ };
+
+ static struct nla_policy rate_policy[NL80211_RATE_INFO_MAX + 1] = {
+ [NL80211_RATE_INFO_BITRATE] = { .type = NLA_U16 },
+ [NL80211_RATE_INFO_MCS] = { .type = NLA_U8 },
+ [NL80211_RATE_INFO_40_MHZ_WIDTH] = { .type = NLA_FLAG },
+ [NL80211_RATE_INFO_SHORT_GI] = { .type = NLA_FLAG },
+ };
+
+ if (attr[NL80211_ATTR_STA_INFO])
+ {
+ if (!nla_parse_nested(sinfo, NL80211_STA_INFO_MAX,
+ attr[NL80211_ATTR_STA_INFO], stats_policy))
+ {
+ if (sinfo[NL80211_STA_INFO_SIGNAL])
+ {
+ dbm = nla_get_u8(sinfo[NL80211_STA_INFO_SIGNAL]);
+ rr->rssi = rr->rssi ? (int8_t)((rr->rssi + dbm) / 2) : dbm;
+ }
+
+ if (sinfo[NL80211_STA_INFO_TX_BITRATE])
+ {
+ if (!nla_parse_nested(rinfo, NL80211_RATE_INFO_MAX,
+ sinfo[NL80211_STA_INFO_TX_BITRATE],
+ rate_policy))
+ {
+ if (rinfo[NL80211_RATE_INFO_BITRATE])
+ {
+ mbit = nla_get_u16(rinfo[NL80211_RATE_INFO_BITRATE]);
+ rr->rate = rr->rate
+ ? (int16_t)((rr->rate + mbit) / 2) : mbit;
+ }
+ }
+ }
+ }
+ }
+
+ return NL_SKIP;
+}
+
+static void nl80211_fill_signal(const char *ifname, struct nl80211_rssi_rate *r)
+{
+ DIR *d;
+ struct dirent *de;
+ struct nl80211_msg_conveyor *req;
+
+ r->rssi = 0;
+ r->rate = 0;
+
+ if ((d = opendir("/sys/class/net")) != NULL)
+ {
+ while ((de = readdir(d)) != NULL)
+ {
+ if (!strncmp(de->d_name, ifname, strlen(ifname)) &&
+ (!de->d_name[strlen(ifname)] ||
+ !strncmp(&de->d_name[strlen(ifname)], ".sta", 4)))
+ {
+ req = nl80211_msg(de->d_name, NL80211_CMD_GET_STATION,
+ NLM_F_DUMP);
+
+ if (req)
+ {
+ nl80211_send(req, nl80211_fill_signal_cb, r);
+ nl80211_free(req);
+ }
+ }
+ }
+
+ closedir(d);
+ }
+}
+
+int nl80211_get_bitrate(const char *ifname, int *buf)
+{
+ struct nl80211_rssi_rate rr;
+
+ nl80211_fill_signal(ifname, &rr);
+
+ if (rr.rate)
+ {
+ *buf = (rr.rate * 100);
+ return 0;
+ }
+
+ return -1;
+}
+
+int nl80211_get_signal(const char *ifname, int *buf)
+{
+ struct nl80211_rssi_rate rr;
+
+ nl80211_fill_signal(ifname, &rr);
+
+ if (rr.rssi)
+ {
+ *buf = rr.rssi;
+ return 0;
+ }
+
+ return -1;
+}
+
+static int nl80211_get_noise_cb(struct nl_msg *msg, void *arg)
+{
+ int8_t *noise = arg;
+ struct nlattr **tb = nl80211_parse(msg);
+ struct nlattr *si[NL80211_SURVEY_INFO_MAX + 1];
+
+ static struct nla_policy sp[NL80211_SURVEY_INFO_MAX + 1] = {
+ [NL80211_SURVEY_INFO_FREQUENCY] = { .type = NLA_U32 },
+ [NL80211_SURVEY_INFO_NOISE] = { .type = NLA_U8 },
+ };
+
+ if (!tb[NL80211_ATTR_SURVEY_INFO])
+ return NL_SKIP;
+
+ if (nla_parse_nested(si, NL80211_SURVEY_INFO_MAX,
+ tb[NL80211_ATTR_SURVEY_INFO], sp))
+ return NL_SKIP;
+
+ if (!si[NL80211_SURVEY_INFO_NOISE])
+ return NL_SKIP;
+
+ if (!*noise || si[NL80211_SURVEY_INFO_IN_USE])
+ *noise = (int8_t)nla_get_u8(si[NL80211_SURVEY_INFO_NOISE]);
+
+ return NL_SKIP;
+}
+
+
+int nl80211_get_noise(const char *ifname, int *buf)
+{
+ int8_t noise;
+ struct nl80211_msg_conveyor *req;
+
+ req = nl80211_msg(ifname, NL80211_CMD_GET_SURVEY, NLM_F_DUMP);
+ if (req)
+ {
+ noise = 0;
+
+ nl80211_send(req, nl80211_get_noise_cb, &noise);
+ nl80211_free(req);
+
+ if (noise)
+ {
+ *buf = noise;
+ return 0;
+ }
+ }
+
+ return -1;
+}
+
+int nl80211_get_quality(const char *ifname, int *buf)
+{
+ int signal;
+
+ if (!nl80211_get_signal(ifname, &signal))
+ {
+ /* A positive signal level is usually just a quality
+ * value, pass through as-is */
+ if (signal >= 0)
+ {
+ *buf = signal;
+ }
+
+ /* The cfg80211 wext compat layer assumes a signal range
+ * of -110 dBm to -40 dBm, the quality value is derived
+ * by adding 110 to the signal level */
+ else
+ {
+ if (signal < -110)
+ signal = -110;
+ else if (signal > -40)
+ signal = -40;
+
+ *buf = (signal + 110);
+ }
+
+ return 0;
+ }
+
+ return -1;
+}
+
+int nl80211_get_quality_max(const char *ifname, int *buf)
+{
+ /* The cfg80211 wext compat layer assumes a maximum
+ * quality of 70 */
+ *buf = 70;
+
+ return 0;
+}
+
+int nl80211_get_encryption(const char *ifname, char *buf)
+{
+ int i;
+ char k[9];
+ char *val, *res;
+ struct iwinfo_crypto_entry *c = (struct iwinfo_crypto_entry *)buf;
+
+ /* WPA supplicant */
+ if ((res = nl80211_wpactl_info(ifname, "STATUS", NULL)) &&
+ (val = nl80211_getval(NULL, res, "pairwise_cipher")))
+ {
+ /* WEP */
+ if (strstr(val, "WEP"))
+ {
+ if (strstr(val, "WEP-40"))
+ c->pair_ciphers |= IWINFO_CIPHER_WEP40;
+
+ else if (strstr(val, "WEP-104"))
+ c->pair_ciphers |= IWINFO_CIPHER_WEP104;
+
+ c->enabled = 1;
+ c->group_ciphers = c->pair_ciphers;
+
+ c->auth_suites |= IWINFO_KMGMT_NONE;
+ c->auth_algs |= IWINFO_AUTH_OPEN; /* XXX: assumption */
+ }
+
+ /* WPA */
+ else
+ {
+ if (strstr(val, "TKIP"))
+ c->pair_ciphers |= IWINFO_CIPHER_TKIP;
+
+ else if (strstr(val, "CCMP"))
+ c->pair_ciphers |= IWINFO_CIPHER_CCMP;
+
+ else if (strstr(val, "NONE"))
+ c->pair_ciphers |= IWINFO_CIPHER_NONE;
+
+ else if (strstr(val, "WEP-40"))
+ c->pair_ciphers |= IWINFO_CIPHER_WEP40;
+
+ else if (strstr(val, "WEP-104"))
+ c->pair_ciphers |= IWINFO_CIPHER_WEP104;
+
+
+ if ((val = nl80211_getval(NULL, res, "group_cipher")))
+ {
+ if (strstr(val, "TKIP"))
+ c->group_ciphers |= IWINFO_CIPHER_TKIP;
+
+ else if (strstr(val, "CCMP"))
+ c->group_ciphers |= IWINFO_CIPHER_CCMP;
+
+ else if (strstr(val, "NONE"))
+ c->group_ciphers |= IWINFO_CIPHER_NONE;
+
+ else if (strstr(val, "WEP-40"))
+ c->group_ciphers |= IWINFO_CIPHER_WEP40;
+
+ else if (strstr(val, "WEP-104"))
+ c->group_ciphers |= IWINFO_CIPHER_WEP104;
+ }
+
+
+ if ((val = nl80211_getval(NULL, res, "key_mgmt")))
+ {
+ if (strstr(val, "WPA2"))
+ c->wpa_version = 2;
+
+ else if (strstr(val, "WPA"))
+ c->wpa_version = 1;
+
+
+ if (strstr(val, "PSK"))
+ c->auth_suites |= IWINFO_KMGMT_PSK;
+
+ else if (strstr(val, "EAP") || strstr(val, "802.1X"))
+ c->auth_suites |= IWINFO_KMGMT_8021x;
+
+ else if (strstr(val, "NONE"))
+ c->auth_suites |= IWINFO_KMGMT_NONE;
+ }
+
+ c->enabled = (c->wpa_version && c->auth_suites) ? 1 : 0;
+ }
+
+ return 0;
+ }
+
+ /* Hostapd */
+ else if ((res = nl80211_hostapd_info(ifname)))
+ {
+ if ((val = nl80211_getval(ifname, res, "wpa")) != NULL)
+ c->wpa_version = atoi(val);
+
+ val = nl80211_getval(ifname, res, "wpa_key_mgmt");
+
+ if (!val || strstr(val, "PSK"))
+ c->auth_suites |= IWINFO_KMGMT_PSK;
+
+ if (val && strstr(val, "EAP"))
+ c->auth_suites |= IWINFO_KMGMT_8021x;
+
+ if (val && strstr(val, "NONE"))
+ c->auth_suites |= IWINFO_KMGMT_NONE;
+
+ if ((val = nl80211_getval(ifname, res, "wpa_pairwise")) != NULL)
+ {
+ if (strstr(val, "TKIP"))
+ c->pair_ciphers |= IWINFO_CIPHER_TKIP;
+
+ if (strstr(val, "CCMP"))
+ c->pair_ciphers |= IWINFO_CIPHER_CCMP;
+
+ if (strstr(val, "NONE"))
+ c->pair_ciphers |= IWINFO_CIPHER_NONE;
+ }
+
+ if ((val = nl80211_getval(ifname, res, "auth_algs")) != NULL)
+ {
+ switch(atoi(val)) {
+ case 1:
+ c->auth_algs |= IWINFO_AUTH_OPEN;
+ break;
+
+ case 2:
+ c->auth_algs |= IWINFO_AUTH_SHARED;
+ break;
+
+ case 3:
+ c->auth_algs |= IWINFO_AUTH_OPEN;
+ c->auth_algs |= IWINFO_AUTH_SHARED;
+ break;
+
+ default:
+ break;
+ }
+
+ for (i = 0; i < 4; i++)
+ {
+ snprintf(k, sizeof(k), "wep_key%d", i);
+
+ if ((val = nl80211_getval(ifname, res, k)))
+ {
+ if ((strlen(val) == 5) || (strlen(val) == 10))
+ c->pair_ciphers |= IWINFO_CIPHER_WEP40;
+
+ else if ((strlen(val) == 13) || (strlen(val) == 26))
+ c->pair_ciphers |= IWINFO_CIPHER_WEP104;
+ }
+ }
+ }
+
+ c->group_ciphers = c->pair_ciphers;
+ c->enabled = (c->wpa_version || c->pair_ciphers) ? 1 : 0;
+
+ return 0;
+ }
+
+ return -1;
+}
+
+
+static int nl80211_get_assoclist_cb(struct nl_msg *msg, void *arg)
+{
+ struct nl80211_array_buf *arr = arg;
+ struct iwinfo_assoclist_entry *e = arr->buf;
+ struct nlattr **attr = nl80211_parse(msg);
+ struct nlattr *sinfo[NL80211_STA_INFO_MAX + 1];
+ struct nlattr *rinfo[NL80211_RATE_INFO_MAX + 1];
+
+ static struct nla_policy stats_policy[NL80211_STA_INFO_MAX + 1] = {
+ [NL80211_STA_INFO_INACTIVE_TIME] = { .type = NLA_U32 },
+ [NL80211_STA_INFO_RX_PACKETS] = { .type = NLA_U32 },
+ [NL80211_STA_INFO_TX_PACKETS] = { .type = NLA_U32 },
+ [NL80211_STA_INFO_RX_BITRATE] = { .type = NLA_NESTED },
+ [NL80211_STA_INFO_TX_BITRATE] = { .type = NLA_NESTED },
+ [NL80211_STA_INFO_SIGNAL] = { .type = NLA_U8 },
+ };
+
+ static struct nla_policy rate_policy[NL80211_RATE_INFO_MAX + 1] = {
+ [NL80211_RATE_INFO_BITRATE] = { .type = NLA_U16 },
+ [NL80211_RATE_INFO_MCS] = { .type = NLA_U8 },
+ [NL80211_RATE_INFO_40_MHZ_WIDTH] = { .type = NLA_FLAG },
+ [NL80211_RATE_INFO_SHORT_GI] = { .type = NLA_FLAG },
+ };
+
+ /* advance to end of array */
+ e += arr->count;
+ memset(e, 0, sizeof(*e));
+
+ if (attr[NL80211_ATTR_MAC])
+ memcpy(e->mac, nla_data(attr[NL80211_ATTR_MAC]), 6);
+
+ if (attr[NL80211_ATTR_STA_INFO] &&
+ !nla_parse_nested(sinfo, NL80211_STA_INFO_MAX,
+ attr[NL80211_ATTR_STA_INFO], stats_policy))
+ {
+ if (sinfo[NL80211_STA_INFO_SIGNAL])
+ e->signal = nla_get_u8(sinfo[NL80211_STA_INFO_SIGNAL]);
+
+ if (sinfo[NL80211_STA_INFO_INACTIVE_TIME])
+ e->inactive = nla_get_u32(sinfo[NL80211_STA_INFO_INACTIVE_TIME]);
+
+ if (sinfo[NL80211_STA_INFO_RX_PACKETS])
+ e->rx_packets = nla_get_u32(sinfo[NL80211_STA_INFO_RX_PACKETS]);
+
+ if (sinfo[NL80211_STA_INFO_TX_PACKETS])
+ e->tx_packets = nla_get_u32(sinfo[NL80211_STA_INFO_TX_PACKETS]);
+
+ if (sinfo[NL80211_STA_INFO_RX_BITRATE] &&
+ !nla_parse_nested(rinfo, NL80211_RATE_INFO_MAX,
+ sinfo[NL80211_STA_INFO_RX_BITRATE], rate_policy))
+ {
+ if (rinfo[NL80211_RATE_INFO_BITRATE])
+ e->rx_rate.rate =
+ nla_get_u16(rinfo[NL80211_RATE_INFO_BITRATE]) * 100;
+
+ if (rinfo[NL80211_RATE_INFO_MCS])
+ e->rx_rate.mcs = nla_get_u8(rinfo[NL80211_RATE_INFO_MCS]);
+
+ if (rinfo[NL80211_RATE_INFO_40_MHZ_WIDTH])
+ e->rx_rate.is_40mhz = 1;
+
+ if (rinfo[NL80211_RATE_INFO_SHORT_GI])
+ e->rx_rate.is_short_gi = 1;
+ }
+
+ if (sinfo[NL80211_STA_INFO_TX_BITRATE] &&
+ !nla_parse_nested(rinfo, NL80211_RATE_INFO_MAX,
+ sinfo[NL80211_STA_INFO_TX_BITRATE], rate_policy))
+ {
+ if (rinfo[NL80211_RATE_INFO_BITRATE])
+ e->tx_rate.rate =
+ nla_get_u16(rinfo[NL80211_RATE_INFO_BITRATE]) * 100;
+
+ if (rinfo[NL80211_RATE_INFO_MCS])
+ e->tx_rate.mcs = nla_get_u8(rinfo[NL80211_RATE_INFO_MCS]);
+
+ if (rinfo[NL80211_RATE_INFO_40_MHZ_WIDTH])
+ e->tx_rate.is_40mhz = 1;
+
+ if (rinfo[NL80211_RATE_INFO_SHORT_GI])
+ e->tx_rate.is_short_gi = 1;
+ }
+ }
+
+ e->noise = 0; /* filled in by caller */
+ arr->count++;
+
+ return NL_SKIP;
+}
+
+int nl80211_get_assoclist(const char *ifname, char *buf, int *len)
+{
+ DIR *d;
+ int i, noise = 0;
+ struct dirent *de;
+ struct nl80211_msg_conveyor *req;
+ struct nl80211_array_buf arr = { .buf = buf, .count = 0 };
+ struct iwinfo_assoclist_entry *e;
+
+ if ((d = opendir("/sys/class/net")) != NULL)
+ {
+ while ((de = readdir(d)) != NULL)
+ {
+ if (!strncmp(de->d_name, ifname, strlen(ifname)) &&
+ (!de->d_name[strlen(ifname)] ||
+ !strncmp(&de->d_name[strlen(ifname)], ".sta", 4)))
+ {
+ req = nl80211_msg(de->d_name, NL80211_CMD_GET_STATION,
+ NLM_F_DUMP);
+
+ if (req)
+ {
+ nl80211_send(req, nl80211_get_assoclist_cb, &arr);
+ nl80211_free(req);
+ }
+ }
+ }
+
+ closedir(d);
+
+ if (!nl80211_get_noise(ifname, &noise))
+ for (i = 0, e = arr.buf; i < arr.count; i++, e++)
+ e->noise = noise;
+
+ *len = (arr.count * sizeof(struct iwinfo_assoclist_entry));
+ return 0;
+ }
+
+ return -1;
+}
+
+static int nl80211_get_txpwrlist_cb(struct nl_msg *msg, void *arg)
+{
+ int *dbm_max = arg;
+ int ch_cur, ch_cmp, bands_remain, freqs_remain;
+
+ struct nlattr **attr = nl80211_parse(msg);
+ struct nlattr *bands[NL80211_BAND_ATTR_MAX + 1];
+ struct nlattr *freqs[NL80211_FREQUENCY_ATTR_MAX + 1];
+ struct nlattr *band, *freq;
+
+ static struct nla_policy freq_policy[NL80211_FREQUENCY_ATTR_MAX + 1] = {
+ [NL80211_FREQUENCY_ATTR_FREQ] = { .type = NLA_U32 },
+ [NL80211_FREQUENCY_ATTR_DISABLED] = { .type = NLA_FLAG },
+ [NL80211_FREQUENCY_ATTR_PASSIVE_SCAN] = { .type = NLA_FLAG },
+ [NL80211_FREQUENCY_ATTR_NO_IBSS] = { .type = NLA_FLAG },
+ [NL80211_FREQUENCY_ATTR_RADAR] = { .type = NLA_FLAG },
+ [NL80211_FREQUENCY_ATTR_MAX_TX_POWER] = { .type = NLA_U32 },
+ };
+
+ ch_cur = *dbm_max; /* value int* is initialized with channel by caller */
+ *dbm_max = -1;
+
+ nla_for_each_nested(band, attr[NL80211_ATTR_WIPHY_BANDS], bands_remain)
+ {
+ nla_parse(bands, NL80211_BAND_ATTR_MAX, nla_data(band),
+ nla_len(band), NULL);
+
+ nla_for_each_nested(freq, bands[NL80211_BAND_ATTR_FREQS], freqs_remain)
+ {
+ nla_parse(freqs, NL80211_FREQUENCY_ATTR_MAX,
+ nla_data(freq), nla_len(freq), freq_policy);
+
+ ch_cmp = nl80211_freq2channel(nla_get_u32(
+ freqs[NL80211_FREQUENCY_ATTR_FREQ]));
+
+ if ((!ch_cur || (ch_cmp == ch_cur)) &&
+ freqs[NL80211_FREQUENCY_ATTR_MAX_TX_POWER])
+ {
+ *dbm_max = (int)(0.01 * nla_get_u32(
+ freqs[NL80211_FREQUENCY_ATTR_MAX_TX_POWER]));
+
+ break;
+ }
+ }
+ }
+
+ return NL_SKIP;
+}
+
+int nl80211_get_txpwrlist(const char *ifname, char *buf, int *len)
+{
+ int ch_cur;
+ int dbm_max = -1, dbm_cur, dbm_cnt;
+ struct nl80211_msg_conveyor *req;
+ struct iwinfo_txpwrlist_entry entry;
+
+ if (nl80211_get_channel(ifname, &ch_cur))
+ ch_cur = 0;
+
+ req = nl80211_msg(ifname, NL80211_CMD_GET_WIPHY, 0);
+ if (req)
+ {
+ /* initialize the value pointer with channel for callback */
+ dbm_max = ch_cur;
+
+ nl80211_send(req, nl80211_get_txpwrlist_cb, &dbm_max);
+ nl80211_free(req);
+ }
+
+ if (dbm_max > 0)
+ {
+ for (dbm_cur = 0, dbm_cnt = 0;
+ dbm_cur < dbm_max;
+ dbm_cur++, dbm_cnt++)
+ {
+ entry.dbm = dbm_cur;
+ entry.mw = iwinfo_dbm2mw(dbm_cur);
+
+ memcpy(&buf[dbm_cnt * sizeof(entry)], &entry, sizeof(entry));
+ }
+
+ entry.dbm = dbm_max;
+ entry.mw = iwinfo_dbm2mw(dbm_max);
+
+ memcpy(&buf[dbm_cnt * sizeof(entry)], &entry, sizeof(entry));
+ dbm_cnt++;
+
+ *len = dbm_cnt * sizeof(entry);
+ return 0;
+ }
+
+ return -1;
+}
+
+static void nl80211_get_scancrypto(const char *spec,
+ struct iwinfo_crypto_entry *c)
+{
+ if (strstr(spec, "WPA") || strstr(spec, "WEP"))
+ {
+ c->enabled = 1;
+
+ if (strstr(spec, "WPA2-") && strstr(spec, "WPA-"))
+ c->wpa_version = 3;
+
+ else if (strstr(spec, "WPA2"))
+ c->wpa_version = 2;
+
+ else if (strstr(spec, "WPA"))
+ c->wpa_version = 1;
+
+ else if (strstr(spec, "WEP"))
+ c->auth_algs = IWINFO_AUTH_OPEN | IWINFO_AUTH_SHARED;
+
+
+ if (strstr(spec, "PSK"))
+ c->auth_suites |= IWINFO_KMGMT_PSK;
+
+ if (strstr(spec, "802.1X") || strstr(spec, "EAP"))
+ c->auth_suites |= IWINFO_KMGMT_8021x;
+
+ if (strstr(spec, "WPA-NONE"))
+ c->auth_suites |= IWINFO_KMGMT_NONE;
+
+
+ if (strstr(spec, "TKIP"))
+ c->pair_ciphers |= IWINFO_CIPHER_TKIP;
+
+ if (strstr(spec, "CCMP"))
+ c->pair_ciphers |= IWINFO_CIPHER_CCMP;
+
+ if (strstr(spec, "WEP-40"))
+ c->pair_ciphers |= IWINFO_CIPHER_WEP40;
+
+ if (strstr(spec, "WEP-104"))
+ c->pair_ciphers |= IWINFO_CIPHER_WEP104;
+
+ c->group_ciphers = c->pair_ciphers;
+ }
+ else
+ {
+ c->enabled = 0;
+ }
+}
+
+
+struct nl80211_scanlist {
+ struct iwinfo_scanlist_entry *e;
+ int len;
+};
+
+
+static void nl80211_get_scanlist_ie(struct nlattr **bss,
+ struct iwinfo_scanlist_entry *e)
+{
+ int ielen = nla_len(bss[NL80211_BSS_INFORMATION_ELEMENTS]);
+ unsigned char *ie = nla_data(bss[NL80211_BSS_INFORMATION_ELEMENTS]);
+ static unsigned char ms_oui[3] = { 0x00, 0x50, 0xf2 };
+
+ while (ielen >= 2 && ielen >= ie[1])
+ {
+ switch (ie[0])
+ {
+ case 0: /* SSID */
+ memcpy(e->ssid, ie + 2, min(ie[1], IWINFO_ESSID_MAX_SIZE));
+ break;
+
+ case 48: /* RSN */
+ iwinfo_parse_rsn(&e->crypto, ie + 2, ie[1],
+ IWINFO_CIPHER_CCMP, IWINFO_KMGMT_8021x);
+ break;
+
+ case 221: /* Vendor */
+ if (ie[1] >= 4 && !memcmp(ie + 2, ms_oui, 3) && ie[5] == 1)
+ iwinfo_parse_rsn(&e->crypto, ie + 6, ie[1] - 4,
+ IWINFO_CIPHER_TKIP, IWINFO_KMGMT_PSK);
+ break;
+ }
+
+ ielen -= ie[1] + 2;
+ ie += ie[1] + 2;
+ }
+}
+
+static int nl80211_get_scanlist_cb(struct nl_msg *msg, void *arg)
+{
+ int8_t rssi;
+ uint16_t caps;
+
+ struct nl80211_scanlist *sl = arg;
+ struct nlattr **tb = nl80211_parse(msg);
+ struct nlattr *bss[NL80211_BSS_MAX + 1];
+
+ static struct nla_policy bss_policy[NL80211_BSS_MAX + 1] = {
+ [NL80211_BSS_TSF] = { .type = NLA_U64 },
+ [NL80211_BSS_FREQUENCY] = { .type = NLA_U32 },
+ [NL80211_BSS_BSSID] = { },
+ [NL80211_BSS_BEACON_INTERVAL] = { .type = NLA_U16 },
+ [NL80211_BSS_CAPABILITY] = { .type = NLA_U16 },
+ [NL80211_BSS_INFORMATION_ELEMENTS] = { },
+ [NL80211_BSS_SIGNAL_MBM] = { .type = NLA_U32 },
+ [NL80211_BSS_SIGNAL_UNSPEC] = { .type = NLA_U8 },
+ [NL80211_BSS_STATUS] = { .type = NLA_U32 },
+ [NL80211_BSS_SEEN_MS_AGO] = { .type = NLA_U32 },
+ [NL80211_BSS_BEACON_IES] = { },
+ };
+
+ if (!tb[NL80211_ATTR_BSS] ||
+ nla_parse_nested(bss, NL80211_BSS_MAX, tb[NL80211_ATTR_BSS],
+ bss_policy) ||
+ !bss[NL80211_BSS_BSSID])
+ {
+ return NL_SKIP;
+ }
+
+ if (bss[NL80211_BSS_CAPABILITY])
+ caps = nla_get_u16(bss[NL80211_BSS_CAPABILITY]);
+ else
+ caps = 0;
+
+ memset(sl->e, 0, sizeof(*sl->e));
+ memcpy(sl->e->mac, nla_data(bss[NL80211_BSS_BSSID]), 6);
+
+ if (caps & (1<<1))
+ sl->e->mode = IWINFO_OPMODE_ADHOC;
+ else
+ sl->e->mode = IWINFO_OPMODE_MASTER;
+
+ if (caps & (1<<4))
+ sl->e->crypto.enabled = 1;
+
+ if (bss[NL80211_BSS_FREQUENCY])
+ sl->e->channel = nl80211_freq2channel(nla_get_u32(
+ bss[NL80211_BSS_FREQUENCY]));
+
+ if (bss[NL80211_BSS_INFORMATION_ELEMENTS])
+ nl80211_get_scanlist_ie(bss, sl->e);
+
+ if (bss[NL80211_BSS_SIGNAL_MBM])
+ {
+ sl->e->signal =
+ (uint8_t)((int32_t)nla_get_u32(bss[NL80211_BSS_SIGNAL_MBM]) / 100);
+
+ rssi = sl->e->signal - 0x100;
+
+ if (rssi < -110)
+ rssi = -110;
+ else if (rssi > -40)
+ rssi = -40;
+
+ sl->e->quality = (rssi + 110);
+ sl->e->quality_max = 70;
+ }
+
+ if (sl->e->crypto.enabled && !sl->e->crypto.wpa_version)
+ {
+ sl->e->crypto.auth_algs = IWINFO_AUTH_OPEN | IWINFO_AUTH_SHARED;
+ sl->e->crypto.pair_ciphers = IWINFO_CIPHER_WEP40 | IWINFO_CIPHER_WEP104;
+ }
+
+ sl->e++;
+ sl->len++;
+
+ return NL_SKIP;
+}
+
+static int nl80211_get_scanlist_nl(const char *ifname, char *buf, int *len)
+{
+ struct nl80211_msg_conveyor *req;
+ struct nl80211_scanlist sl = { .e = (struct iwinfo_scanlist_entry *)buf };
+
+ req = nl80211_msg(ifname, NL80211_CMD_TRIGGER_SCAN, 0);
+ if (req)
+ {
+ nl80211_send(req, NULL, NULL);
+ nl80211_free(req);
+ }
+
+ nl80211_wait("nl80211", "scan", NL80211_CMD_NEW_SCAN_RESULTS);
+
+ req = nl80211_msg(ifname, NL80211_CMD_GET_SCAN, NLM_F_DUMP);
+ if (req)
+ {
+ nl80211_send(req, nl80211_get_scanlist_cb, &sl);
+ nl80211_free(req);
+ }
+
+ *len = sl.len * sizeof(struct iwinfo_scanlist_entry);
+ return *len ? 0 : -1;
+}
+
+int nl80211_get_scanlist(const char *ifname, char *buf, int *len)
+{
+ int freq, rssi, qmax, count;
+ char *res;
+ char ssid[128] = { 0 };
+ char bssid[18] = { 0 };
+ char cipher[256] = { 0 };
+
+ /* Got a radioX pseudo interface, find some interface on it or create one */
+ if (!strncmp(ifname, "radio", 5))
+ {
+ /* Reuse existing interface */
+ if ((res = nl80211_phy2ifname(ifname)) != NULL)
+ {
+ return nl80211_get_scanlist(res, buf, len);
+ }
+
+ /* Need to spawn a temporary iface for scanning */
+ else if ((res = nl80211_ifadd(ifname)) != NULL)
+ {
+ count = nl80211_get_scanlist(res, buf, len);
+ nl80211_ifdel(res);
+ return count;
+ }
+ }
+
+ struct iwinfo_scanlist_entry *e = (struct iwinfo_scanlist_entry *)buf;
+
+ /* WPA supplicant */
+ if ((res = nl80211_wpactl_info(ifname, "SCAN", "CTRL-EVENT-SCAN-RESULTS")))
+ {
+ if ((res = nl80211_wpactl_info(ifname, "SCAN_RESULTS", NULL)))
+ {
+ nl80211_get_quality_max(ifname, &qmax);
+
+ /* skip header line */
+ while (*res++ != '\n');
+
+ count = 0;
+
+ while (sscanf(res, "%17s %d %d %255s%*[ \t]%127[^\n]\n",
+ bssid, &freq, &rssi, cipher, ssid) > 0)
+ {
+ /* BSSID */
+ e->mac[0] = strtol(&bssid[0], NULL, 16);
+ e->mac[1] = strtol(&bssid[3], NULL, 16);
+ e->mac[2] = strtol(&bssid[6], NULL, 16);
+ e->mac[3] = strtol(&bssid[9], NULL, 16);
+ e->mac[4] = strtol(&bssid[12], NULL, 16);
+ e->mac[5] = strtol(&bssid[15], NULL, 16);
+
+ /* SSID */
+ memcpy(e->ssid, ssid, min(strlen(ssid), sizeof(e->ssid) - 1));
+
+ /* Mode (assume master) */
+ e->mode = IWINFO_OPMODE_MASTER;
+
+ /* Channel */
+ e->channel = nl80211_freq2channel(freq);
+
+ /* Signal */
+ e->signal = rssi;
+
+ /* Quality */
+ if (rssi < 0)
+ {
+ /* The cfg80211 wext compat layer assumes a signal range
+ * of -110 dBm to -40 dBm, the quality value is derived
+ * by adding 110 to the signal level */
+ if (rssi < -110)
+ rssi = -110;
+ else if (rssi > -40)
+ rssi = -40;
+
+ e->quality = (rssi + 110);
+ }
+ else
+ {
+ e->quality = rssi;
+ }
+
+ /* Max. Quality */
+ e->quality_max = qmax;
+
+ /* Crypto */
+ nl80211_get_scancrypto(cipher, &e->crypto);
+
+ /* advance to next line */
+ while (*res && *res++ != '\n');
+
+ count++;
+ e++;
+
+ memset(ssid, 0, sizeof(ssid));
+ memset(bssid, 0, sizeof(bssid));
+ memset(cipher, 0, sizeof(cipher));
+ }
+
+ *len = count * sizeof(struct iwinfo_scanlist_entry);
+ return 0;
+ }
+ }
+
+ /* AP scan */
+ else
+ {
+ /* Got a temp interface, don't create yet another one */
+ if (!strncmp(ifname, "tmp.", 4))
+ {
+ if (!iwinfo_ifup(ifname))
+ return -1;
+
+ nl80211_get_scanlist_nl(ifname, buf, len);
+ iwinfo_ifdown(ifname);
+ return 0;
+ }
+
+ /* Spawn a new scan interface */
+ else
+ {
+ if (!(res = nl80211_ifadd(ifname)))
+ goto out;
+
+ if (!iwinfo_ifmac(res))
+ goto out;
+
+ /* if we can take the new interface up, the driver supports an
+ * additional interface and there's no need to tear down the ap */
+ if (iwinfo_ifup(res))
+ {
+ nl80211_get_scanlist_nl(res, buf, len);
+ iwinfo_ifdown(res);
+ }
+
+ /* driver cannot create secondary interface, take down ap
+ * during scan */
+ else if (iwinfo_ifdown(ifname) && iwinfo_ifup(res))
+ {
+ nl80211_get_scanlist_nl(res, buf, len);
+ iwinfo_ifdown(res);
+ iwinfo_ifup(ifname);
+ nl80211_hostapd_hup(ifname);
+ }
+
+ out:
+ nl80211_ifdel(res);
+ return 0;
+ }
+ }
+
+ return -1;
+}
+
+static int nl80211_get_freqlist_cb(struct nl_msg *msg, void *arg)
+{
+ int bands_remain, freqs_remain;
+
+ struct nl80211_array_buf *arr = arg;
+ struct iwinfo_freqlist_entry *e = arr->buf;
+
+ struct nlattr **attr = nl80211_parse(msg);
+ struct nlattr *bands[NL80211_BAND_ATTR_MAX + 1];
+ struct nlattr *freqs[NL80211_FREQUENCY_ATTR_MAX + 1];
+ struct nlattr *band, *freq;
+
+ static struct nla_policy freq_policy[NL80211_FREQUENCY_ATTR_MAX + 1] = {
+ [NL80211_FREQUENCY_ATTR_FREQ] = { .type = NLA_U32 },
+ [NL80211_FREQUENCY_ATTR_DISABLED] = { .type = NLA_FLAG },
+ [NL80211_FREQUENCY_ATTR_PASSIVE_SCAN] = { .type = NLA_FLAG },
+ [NL80211_FREQUENCY_ATTR_NO_IBSS] = { .type = NLA_FLAG },
+ [NL80211_FREQUENCY_ATTR_RADAR] = { .type = NLA_FLAG },
+ [NL80211_FREQUENCY_ATTR_MAX_TX_POWER] = { .type = NLA_U32 },
+ };
+
+ nla_for_each_nested(band, attr[NL80211_ATTR_WIPHY_BANDS], bands_remain)
+ {
+ nla_parse(bands, NL80211_BAND_ATTR_MAX,
+ nla_data(band), nla_len(band), NULL);
+
+ nla_for_each_nested(freq, bands[NL80211_BAND_ATTR_FREQS], freqs_remain)
+ {
+ nla_parse(freqs, NL80211_FREQUENCY_ATTR_MAX,
+ nla_data(freq), nla_len(freq), NULL);
+
+ if (!freqs[NL80211_FREQUENCY_ATTR_FREQ] ||
+ freqs[NL80211_FREQUENCY_ATTR_DISABLED])
+ continue;
+
+ e->mhz = nla_get_u32(freqs[NL80211_FREQUENCY_ATTR_FREQ]);
+ e->channel = nl80211_freq2channel(e->mhz);
+
+ e->restricted = (
+ freqs[NL80211_FREQUENCY_ATTR_PASSIVE_SCAN] ||
+ freqs[NL80211_FREQUENCY_ATTR_NO_IBSS] ||
+ freqs[NL80211_FREQUENCY_ATTR_RADAR]
+ ) ? 1 : 0;
+
+ e++;
+ arr->count++;
+ }
+ }
+
+ return NL_SKIP;
+}
+
+int nl80211_get_freqlist(const char *ifname, char *buf, int *len)
+{
+ struct nl80211_msg_conveyor *req;
+ struct nl80211_array_buf arr = { .buf = buf, .count = 0 };
+
+ req = nl80211_msg(ifname, NL80211_CMD_GET_WIPHY, 0);
+ if (req)
+ {
+ nl80211_send(req, nl80211_get_freqlist_cb, &arr);
+ nl80211_free(req);
+ }
+
+ if (arr.count > 0)
+ {
+ *len = arr.count * sizeof(struct iwinfo_freqlist_entry);
+ return 0;
+ }
+
+ return -1;
+}
+
+static int nl80211_get_country_cb(struct nl_msg *msg, void *arg)
+{
+ char *buf = arg;
+ struct nlattr **attr = nl80211_parse(msg);
+
+ if (attr[NL80211_ATTR_REG_ALPHA2])
+ memcpy(buf, nla_data(attr[NL80211_ATTR_REG_ALPHA2]), 2);
+ else
+ buf[0] = 0;
+
+ return NL_SKIP;
+}
+
+int nl80211_get_country(const char *ifname, char *buf)
+{
+ int rv = -1;
+ struct nl80211_msg_conveyor *req;
+
+ req = nl80211_msg(ifname, NL80211_CMD_GET_REG, 0);
+ if (req)
+ {
+ nl80211_send(req, nl80211_get_country_cb, buf);
+ nl80211_free(req);
+
+ if (buf[0])
+ rv = 0;
+ }
+
+ return rv;
+}
+
+int nl80211_get_countrylist(const char *ifname, char *buf, int *len)
+{
+ int i, count;
+ struct iwinfo_country_entry *e = (struct iwinfo_country_entry *)buf;
+ const struct iwinfo_iso3166_label *l;
+
+ for (l = IWINFO_ISO3166_NAMES, count = 0; l->iso3166; l++, e++, count++)
+ {
+ e->iso3166 = l->iso3166;
+ e->ccode[0] = (l->iso3166 / 256);
+ e->ccode[1] = (l->iso3166 % 256);
+ }
+
+ *len = (count * sizeof(struct iwinfo_country_entry));
+ return 0;
+}
+
+static int nl80211_get_hwmodelist_cb(struct nl_msg *msg, void *arg)
+{
+ int *modes = arg;
+ int bands_remain, freqs_remain;
+ uint16_t caps = 0;
+ struct nlattr **attr = nl80211_parse(msg);
+ struct nlattr *bands[NL80211_BAND_ATTR_MAX + 1];
+ struct nlattr *freqs[NL80211_FREQUENCY_ATTR_MAX + 1];
+ struct nlattr *band, *freq;
+
+ *modes = 0;
+
+ if (attr[NL80211_ATTR_WIPHY_BANDS])
+ {
+ nla_for_each_nested(band, attr[NL80211_ATTR_WIPHY_BANDS], bands_remain)
+ {
+ nla_parse(bands, NL80211_BAND_ATTR_MAX,
+ nla_data(band), nla_len(band), NULL);
+
+ if (bands[NL80211_BAND_ATTR_HT_CAPA])
+ caps = nla_get_u16(bands[NL80211_BAND_ATTR_HT_CAPA]);
+
+ /* Treat any nonzero capability as 11n */
+ if (caps > 0)
+ *modes |= IWINFO_80211_N;
+
+ nla_for_each_nested(freq, bands[NL80211_BAND_ATTR_FREQS],
+ freqs_remain)
+ {
+ nla_parse(freqs, NL80211_FREQUENCY_ATTR_MAX,
+ nla_data(freq), nla_len(freq), NULL);
+
+ if (!freqs[NL80211_FREQUENCY_ATTR_FREQ])
+ continue;
+
+ if (nla_get_u32(freqs[NL80211_FREQUENCY_ATTR_FREQ]) < 2485)
+ {
+ *modes |= IWINFO_80211_B;
+ *modes |= IWINFO_80211_G;
+ }
+ else
+ {
+ *modes |= IWINFO_80211_A;
+ }
+ }
+ }
+ }
+
+ return NL_SKIP;
+}
+
+int nl80211_get_hwmodelist(const char *ifname, int *buf)
+{
+ struct nl80211_msg_conveyor *req;
+
+ req = nl80211_msg(ifname, NL80211_CMD_GET_WIPHY, 0);
+ if (req)
+ {
+ nl80211_send(req, nl80211_get_hwmodelist_cb, buf);
+ nl80211_free(req);
+ }
+
+ return *buf ? 0 : -1;
+}
+
+int nl80211_get_mbssid_support(const char *ifname, int *buf)
+{
+ /* Test whether we can create another interface */
+ char *nif = nl80211_ifadd(ifname);
+
+ if (nif)
+ {
+ *buf = (iwinfo_ifmac(nif) && iwinfo_ifup(nif));
+
+ iwinfo_ifdown(nif);
+ nl80211_ifdel(nif);
+
+ return 0;
+ }
+
+ return -1;
+}
+
+int nl80211_get_hardware_id(const char *ifname, char *buf)
+{
+ int rv;
+ char *res;
+
+ /* Got a radioX pseudo interface, find some interface on it or create one */
+ if (!strncmp(ifname, "radio", 5))
+ {
+ /* Reuse existing interface */
+ if ((res = nl80211_phy2ifname(ifname)) != NULL)
+ {
+ rv = wext_get_hardware_id(res, buf);
+ }
+
+ /* Need to spawn a temporary iface for finding IDs */
+ else if ((res = nl80211_ifadd(ifname)) != NULL)
+ {
+ rv = wext_get_hardware_id(res, buf);
+ nl80211_ifdel(res);
+ }
+ }
+ else
+ {
+ rv = wext_get_hardware_id(ifname, buf);
+ }
+
+ /* Failed to obtain hardware IDs, search board config */
+ if (rv)
+ {
+ rv = iwinfo_hardware_id_from_mtd((struct iwinfo_hardware_id *)buf);
+ }
+
+ return rv;
+}
+
+static const struct iwinfo_hardware_entry *
+nl80211_get_hardware_entry(const char *ifname)
+{
+ struct iwinfo_hardware_id id;
+
+ if (nl80211_get_hardware_id(ifname, (char *)&id))
+ return NULL;
+
+ return iwinfo_hardware(&id);
+}
+
+int nl80211_get_hardware_name(const char *ifname, char *buf)
+{
+ const struct iwinfo_hardware_entry *hw;
+
+ if (!(hw = nl80211_get_hardware_entry(ifname)))
+ sprintf(buf, "Generic MAC80211");
+ else
+ sprintf(buf, "%s %s", hw->vendor_name, hw->device_name);
+
+ return 0;
+}
+
+int nl80211_get_txpower_offset(const char *ifname, int *buf)
+{
+ const struct iwinfo_hardware_entry *hw;
+
+ if (!(hw = nl80211_get_hardware_entry(ifname)))
+ return -1;
+
+ *buf = hw->txpower_offset;
+ return 0;
+}
+
+int nl80211_get_frequency_offset(const char *ifname, int *buf)
+{
+ const struct iwinfo_hardware_entry *hw;
+
+ if (!(hw = nl80211_get_hardware_entry(ifname)))
+ return -1;
+
+ *buf = hw->frequency_offset;
+ return 0;
+}
diff --git a/package/network/utils/iwinfo/src/.svn/text-base/iwinfo_utils.c.svn-base b/package/network/utils/iwinfo/src/.svn/text-base/iwinfo_utils.c.svn-base
new file mode 100644
index 0000000..6616f14
--- /dev/null
+++ b/package/network/utils/iwinfo/src/.svn/text-base/iwinfo_utils.c.svn-base
@@ -0,0 +1,349 @@
+/*
+ * iwinfo - Wireless Information Library - Shared utility routines
+ *
+ * Copyright (C) 2010 Jo-Philipp Wich <xm@subsignal.org>
+ *
+ * The iwinfo library is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * The iwinfo library 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 the iwinfo library. If not, see http://www.gnu.org/licenses/.
+ *
+ * The signal handling code is derived from the official madwifi tools,
+ * wlanconfig.c in particular. The encryption property handling was
+ * inspired by the hostapd madwifi driver.
+ */
+
+#include "iwinfo/utils.h"
+
+
+static int ioctl_socket = -1;
+
+static int iwinfo_ioctl_socket(void)
+{
+ /* Prepare socket */
+ if (ioctl_socket == -1)
+ {
+ ioctl_socket = socket(AF_INET, SOCK_DGRAM, 0);
+ fcntl(ioctl_socket, F_SETFD, fcntl(ioctl_socket, F_GETFD) | FD_CLOEXEC);
+ }
+
+ return ioctl_socket;
+}
+
+int iwinfo_ioctl(int cmd, void *ifr)
+{
+ int s = iwinfo_ioctl_socket();
+ return ioctl(s, cmd, ifr);
+}
+
+int iwinfo_dbm2mw(int in)
+{
+ double res = 1.0;
+ int ip = in / 10;
+ int fp = in % 10;
+ int k;
+
+ for(k = 0; k < ip; k++) res *= 10;
+ for(k = 0; k < fp; k++) res *= LOG10_MAGIC;
+
+ return (int)res;
+}
+
+int iwinfo_mw2dbm(int in)
+{
+ double fin = (double) in;
+ int res = 0;
+
+ while(fin > 10.0)
+ {
+ res += 10;
+ fin /= 10.0;
+ }
+
+ while(fin > 1.000001)
+ {
+ res += 1;
+ fin /= LOG10_MAGIC;
+ }
+
+ return (int)res;
+}
+
+int iwinfo_ifup(const char *ifname)
+{
+ struct ifreq ifr;
+
+ strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
+
+ if (iwinfo_ioctl(SIOCGIFFLAGS, &ifr))
+ return 0;
+
+ ifr.ifr_flags |= (IFF_UP | IFF_RUNNING);
+
+ return !iwinfo_ioctl(SIOCSIFFLAGS, &ifr);
+}
+
+int iwinfo_ifdown(const char *ifname)
+{
+ struct ifreq ifr;
+
+ strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
+
+ if (iwinfo_ioctl(SIOCGIFFLAGS, &ifr))
+ return 0;
+
+ ifr.ifr_flags &= ~(IFF_UP | IFF_RUNNING);
+
+ return !iwinfo_ioctl(SIOCSIFFLAGS, &ifr);
+}
+
+int iwinfo_ifmac(const char *ifname)
+{
+ struct ifreq ifr;
+
+ strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
+
+ if (iwinfo_ioctl(SIOCGIFHWADDR, &ifr))
+ return 0;
+
+ ifr.ifr_hwaddr.sa_data[1]++;
+ ifr.ifr_hwaddr.sa_data[2]++;
+
+ return !iwinfo_ioctl(SIOCSIFHWADDR, &ifr);
+}
+
+void iwinfo_close(void)
+{
+ if (ioctl_socket > -1)
+ close(ioctl_socket);
+
+ ioctl_socket = -1;
+}
+
+struct iwinfo_hardware_entry * iwinfo_hardware(struct iwinfo_hardware_id *id)
+{
+ const struct iwinfo_hardware_entry *e;
+
+ for (e = IWINFO_HARDWARE_ENTRIES; e->vendor_name; e++)
+ {
+ if ((e->vendor_id != 0xffff) && (e->vendor_id != id->vendor_id))
+ continue;
+
+ if ((e->device_id != 0xffff) && (e->device_id != id->device_id))
+ continue;
+
+ if ((e->subsystem_vendor_id != 0xffff) &&
+ (e->subsystem_vendor_id != id->subsystem_vendor_id))
+ continue;
+
+ if ((e->subsystem_device_id != 0xffff) &&
+ (e->subsystem_device_id != id->subsystem_device_id))
+ continue;
+
+ return (struct iwinfo_hardware_entry *)e;
+ }
+
+ return NULL;
+}
+
+int iwinfo_hardware_id_from_mtd(struct iwinfo_hardware_id *id)
+{
+ FILE *mtd;
+ uint16_t *bc;
+
+ int fd, len, off;
+ char buf[128];
+
+ if (!(mtd = fopen("/proc/mtd", "r")))
+ return -1;
+
+ while (fgets(buf, sizeof(buf), mtd) > 0)
+ {
+ if (fscanf(mtd, "mtd%d: %*x %x %127s", &off, &len, buf) < 3 ||
+ (strcmp(buf, "\"boardconfig\"") && strcmp(buf, "\"EEPROM\"") &&
+ strcmp(buf, "\"factory\"")))
+ {
+ off = -1;
+ continue;
+ }
+
+ break;
+ }
+
+ fclose(mtd);
+
+ if (off < 0)
+ return -1;
+
+ snprintf(buf, sizeof(buf), "/dev/mtdblock%d", off);
+
+ if ((fd = open(buf, O_RDONLY)) < 0)
+ return -1;
+
+ bc = mmap(NULL, len, PROT_READ, MAP_PRIVATE|MAP_LOCKED, fd, 0);
+
+ if ((void *)bc != MAP_FAILED)
+ {
+ id->vendor_id = 0;
+ id->device_id = 0;
+
+ for (off = len / 2 - 0x800; off >= 0; off -= 0x800)
+ {
+ /* AR531X board data magic */
+ if ((bc[off] == 0x3533) && (bc[off + 1] == 0x3131))
+ {
+ id->vendor_id = bc[off + 0x7d];
+ id->device_id = bc[off + 0x7c];
+ id->subsystem_vendor_id = bc[off + 0x84];
+ id->subsystem_device_id = bc[off + 0x83];
+ break;
+ }
+
+ /* AR5416 EEPROM magic */
+ else if ((bc[off] == 0xA55A) || (bc[off] == 0x5AA5))
+ {
+ id->vendor_id = bc[off + 0x0D];
+ id->device_id = bc[off + 0x0E];
+ id->subsystem_vendor_id = bc[off + 0x13];
+ id->subsystem_device_id = bc[off + 0x14];
+ break;
+ }
+
+ /* Rt3xxx SoC */
+ else if ((bc[off] == 0x3352) || (bc[off] == 0x5233) ||
+ (bc[off] == 0x3350) || (bc[off] == 0x5033) ||
+ (bc[off] == 0x3050) || (bc[off] == 0x5030) ||
+ (bc[off] == 0x3052) || (bc[off] == 0x5230))
+ {
+ /* vendor: RaLink */
+ id->vendor_id = 0x1814;
+ id->subsystem_vendor_id = 0x1814;
+
+ /* device */
+ if (bc[off] & 0xf0 == 0x30)
+ id->device_id = (bc[off] >> 8) | (bc[off] & 0x00ff) << 8;
+ else
+ id->device_id = bc[off];
+
+ /* subsystem from EEPROM_NIC_CONF0_RF_TYPE */
+ id->subsystem_device_id = (bc[off + 0x1a] & 0x0f00) >> 8;
+ }
+ }
+
+ munmap(bc, len);
+ }
+
+ close(fd);
+
+ return (id->vendor_id && id->device_id) ? 0 : -1;
+}
+
+void iwinfo_parse_rsn(struct iwinfo_crypto_entry *c, uint8_t *data, uint8_t len,
+ uint8_t defcipher, uint8_t defauth)
+{
+ uint16_t i, count;
+
+ static unsigned char ms_oui[3] = { 0x00, 0x50, 0xf2 };
+ static unsigned char ieee80211_oui[3] = { 0x00, 0x0f, 0xac };
+
+ data += 2;
+ len -= 2;
+
+ if (!memcmp(data, ms_oui, 3))
+ c->wpa_version += 1;
+ else if (!memcmp(data, ieee80211_oui, 3))
+ c->wpa_version += 2;
+
+ if (len < 4)
+ {
+ c->group_ciphers |= defcipher;
+ c->pair_ciphers |= defcipher;
+ c->auth_suites |= defauth;
+ return;
+ }
+
+ if (!memcmp(data, ms_oui, 3) || !memcmp(data, ieee80211_oui, 3))
+ {
+ switch (data[3])
+ {
+ case 1: c->group_ciphers |= IWINFO_CIPHER_WEP40; break;
+ case 2: c->group_ciphers |= IWINFO_CIPHER_TKIP; break;
+ case 4: c->group_ciphers |= IWINFO_CIPHER_CCMP; break;
+ case 5: c->group_ciphers |= IWINFO_CIPHER_WEP104; break;
+ case 6: /* AES-128-CMAC */ break;
+ default: /* proprietary */ break;
+ }
+ }
+
+ data += 4;
+ len -= 4;
+
+ if (len < 2)
+ {
+ c->pair_ciphers |= defcipher;
+ c->auth_suites |= defauth;
+ return;
+ }
+
+ count = data[0] | (data[1] << 8);
+ if (2 + (count * 4) > len)
+ return;
+
+ for (i = 0; i < count; i++)
+ {
+ if (!memcmp(data + 2 + (i * 4), ms_oui, 3) ||
+ !memcmp(data + 2 + (i * 4), ieee80211_oui, 3))
+ {
+ switch (data[2 + (i * 4) + 3])
+ {
+ case 1: c->pair_ciphers |= IWINFO_CIPHER_WEP40; break;
+ case 2: c->pair_ciphers |= IWINFO_CIPHER_TKIP; break;
+ case 4: c->pair_ciphers |= IWINFO_CIPHER_CCMP; break;
+ case 5: c->pair_ciphers |= IWINFO_CIPHER_WEP104; break;
+ case 6: /* AES-128-CMAC */ break;
+ default: /* proprietary */ break;
+ }
+ }
+ }
+
+ data += 2 + (count * 4);
+ len -= 2 + (count * 4);
+
+ if (len < 2)
+ {
+ c->auth_suites |= defauth;
+ return;
+ }
+
+ count = data[0] | (data[1] << 8);
+ if (2 + (count * 4) > len)
+ return;
+
+ for (i = 0; i < count; i++)
+ {
+ if (!memcmp(data + 2 + (i * 4), ms_oui, 3) ||
+ !memcmp(data + 2 + (i * 4), ieee80211_oui, 3))
+ {
+ switch (data[2 + (i * 4) + 3])
+ {
+ case 1: c->auth_suites |= IWINFO_KMGMT_8021x; break;
+ case 2: c->auth_suites |= IWINFO_KMGMT_PSK; break;
+ case 3: /* FT/IEEE 802.1X */ break;
+ case 4: /* FT/PSK */ break;
+ case 5: /* IEEE 802.1X/SHA-256 */ break;
+ case 6: /* PSK/SHA-256 */ break;
+ default: /* proprietary */ break;
+ }
+ }
+ }
+
+ data += 2 + (count * 4);
+ len -= 2 + (count * 4);
+}
diff --git a/package/network/utils/iwinfo/src/.svn/text-base/iwinfo_wext.c.svn-base b/package/network/utils/iwinfo/src/.svn/text-base/iwinfo_wext.c.svn-base
new file mode 100644
index 0000000..cf3dccc
--- /dev/null
+++ b/package/network/utils/iwinfo/src/.svn/text-base/iwinfo_wext.c.svn-base
@@ -0,0 +1,520 @@
+/*
+ * iwinfo - Wireless Information Library - Linux Wireless Extension Backend
+ *
+ * Copyright (C) 2009 Jo-Philipp Wich <xm@subsignal.org>
+ *
+ * The iwinfo library is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * The iwinfo library 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 the iwinfo library. If not, see http://www.gnu.org/licenses/.
+ *
+ * Parts of this code are derived from the Linux wireless tools, iwlib.c,
+ * iwlist.c and iwconfig.c in particular.
+ */
+
+#include "iwinfo.h"
+#include "iwinfo/wext.h"
+
+static double wext_freq2float(const struct iw_freq *in)
+{
+ int i;
+ double res = (double) in->m;
+ for(i = 0; i < in->e; i++) res *= 10;
+ return res;
+}
+
+static inline int wext_freq2mhz(const struct iw_freq *in)
+{
+ int i;
+
+ if( in->e == 6 )
+ {
+ return in->m;
+ }
+ else
+ {
+ return (int)(wext_freq2float(in) / 1000000);
+ }
+}
+
+static inline int wext_ioctl(const char *ifname, int cmd, struct iwreq *wrq)
+{
+ if( !strncmp(ifname, "mon.", 4) )
+ strncpy(wrq->ifr_name, &ifname[4], IFNAMSIZ);
+ else
+ strncpy(wrq->ifr_name, ifname, IFNAMSIZ);
+
+ return iwinfo_ioctl(cmd, wrq);
+}
+
+
+int wext_probe(const char *ifname)
+{
+ struct iwreq wrq;
+
+ if(wext_ioctl(ifname, SIOCGIWNAME, &wrq) >= 0)
+ return 1;
+
+ return 0;
+}
+
+void wext_close(void)
+{
+ /* Nop */
+}
+
+int wext_get_mode(const char *ifname, int *buf)
+{
+ struct iwreq wrq;
+
+ if(wext_ioctl(ifname, SIOCGIWMODE, &wrq) >= 0)
+ {
+ switch(wrq.u.mode)
+ {
+ case 1:
+ *buf = IWINFO_OPMODE_ADHOC;
+ break;
+
+ case 2:
+ *buf = IWINFO_OPMODE_CLIENT;
+ break;
+
+ case 3:
+ *buf = IWINFO_OPMODE_MASTER;
+ break;
+
+ case 6:
+ *buf = IWINFO_OPMODE_MONITOR;
+ break;
+
+ default:
+ *buf = IWINFO_OPMODE_UNKNOWN;
+ break;
+ }
+
+ return 0;
+ }
+
+ return -1;
+}
+
+int wext_get_ssid(const char *ifname, char *buf)
+{
+ struct iwreq wrq;
+
+ wrq.u.essid.pointer = (caddr_t) buf;
+ wrq.u.essid.length = IW_ESSID_MAX_SIZE + 1;
+ wrq.u.essid.flags = 0;
+
+ if(wext_ioctl(ifname, SIOCGIWESSID, &wrq) >= 0)
+ return 0;
+
+ return -1;
+}
+
+int wext_get_bssid(const char *ifname, char *buf)
+{
+ struct iwreq wrq;
+
+ if(wext_ioctl(ifname, SIOCGIWAP, &wrq) >= 0)
+ {
+ sprintf(buf, "%02X:%02X:%02X:%02X:%02X:%02X",
+ (uint8_t)wrq.u.ap_addr.sa_data[0], (uint8_t)wrq.u.ap_addr.sa_data[1],
+ (uint8_t)wrq.u.ap_addr.sa_data[2], (uint8_t)wrq.u.ap_addr.sa_data[3],
+ (uint8_t)wrq.u.ap_addr.sa_data[4], (uint8_t)wrq.u.ap_addr.sa_data[5]);
+
+ return 0;
+ }
+
+ return -1;
+}
+
+int wext_get_bitrate(const char *ifname, int *buf)
+{
+ struct iwreq wrq;
+
+ if(wext_ioctl(ifname, SIOCGIWRATE, &wrq) >= 0)
+ {
+ *buf = (wrq.u.bitrate.value / 1000);
+ return 0;
+ }
+
+ return -1;
+}
+
+int wext_get_channel(const char *ifname, int *buf)
+{
+ struct iwreq wrq;
+ struct iw_range range;
+ double freq;
+ int i;
+
+ if(wext_ioctl(ifname, SIOCGIWFREQ, &wrq) >= 0)
+ {
+ if( wrq.u.freq.m >= 1000 )
+ {
+ freq = wext_freq2float(&wrq.u.freq);
+ wrq.u.data.pointer = (caddr_t) &range;
+ wrq.u.data.length = sizeof(struct iw_range);
+ wrq.u.data.flags = 0;
+
+ if(wext_ioctl(ifname, SIOCGIWRANGE, &wrq) >= 0)
+ {
+ for(i = 0; i < range.num_frequency; i++)
+ {
+ if( wext_freq2float(&range.freq[i]) == freq )
+ {
+ *buf = range.freq[i].i;
+ return 0;
+ }
+ }
+ }
+ }
+ else
+ {
+ *buf = wrq.u.freq.m;
+ return 0;
+ }
+ }
+
+ return -1;
+}
+
+int wext_get_frequency(const char *ifname, int *buf)
+{
+ struct iwreq wrq;
+ struct iw_range range;
+ int i, channel;
+
+ if(wext_ioctl(ifname, SIOCGIWFREQ, &wrq) >= 0)
+ {
+ /* We got a channel number instead ... */
+ if( wrq.u.freq.m < 1000 )
+ {
+ channel = wrq.u.freq.m;
+ wrq.u.data.pointer = (caddr_t) &range;
+ wrq.u.data.length = sizeof(struct iw_range);
+ wrq.u.data.flags = 0;
+
+ if(wext_ioctl(ifname, SIOCGIWRANGE, &wrq) >= 0)
+ {
+ for(i = 0; i < range.num_frequency; i++)
+ {
+ if( range.freq[i].i == channel )
+ {
+ *buf = wext_freq2mhz(&range.freq[i]);
+ return 0;
+ }
+ }
+ }
+ }
+ else
+ {
+ *buf = wext_freq2mhz(&wrq.u.freq);
+ return 0;
+ }
+ }
+
+ return -1;
+}
+
+int wext_get_txpower(const char *ifname, int *buf)
+{
+ struct iwreq wrq;
+
+ wrq.u.txpower.flags = 0;
+
+ if(wext_ioctl(ifname, SIOCGIWTXPOW, &wrq) >= 0)
+ {
+ if(wrq.u.txpower.flags & IW_TXPOW_MWATT)
+ *buf = iwinfo_mw2dbm(wrq.u.txpower.value);
+ else
+ *buf = wrq.u.txpower.value;
+
+ return 0;
+ }
+
+ return -1;
+}
+
+int wext_get_signal(const char *ifname, int *buf)
+{
+ struct iwreq wrq;
+ struct iw_statistics stats;
+
+ wrq.u.data.pointer = (caddr_t) &stats;
+ wrq.u.data.length = sizeof(struct iw_statistics);
+ wrq.u.data.flags = 1;
+
+ if(wext_ioctl(ifname, SIOCGIWSTATS, &wrq) >= 0)
+ {
+ *buf = (stats.qual.updated & IW_QUAL_DBM)
+ ? (stats.qual.level - 0x100) : stats.qual.level;
+
+ return 0;
+ }
+
+ return -1;
+}
+
+int wext_get_noise(const char *ifname, int *buf)
+{
+ struct iwreq wrq;
+ struct iw_statistics stats;
+
+ wrq.u.data.pointer = (caddr_t) &stats;
+ wrq.u.data.length = sizeof(struct iw_statistics);
+ wrq.u.data.flags = 1;
+
+ if(wext_ioctl(ifname, SIOCGIWSTATS, &wrq) >= 0)
+ {
+ *buf = (stats.qual.updated & IW_QUAL_DBM)
+ ? (stats.qual.noise - 0x100) : stats.qual.noise;
+
+ return 0;
+ }
+
+ return -1;
+}
+
+int wext_get_quality(const char *ifname, int *buf)
+{
+ struct iwreq wrq;
+ struct iw_statistics stats;
+
+ wrq.u.data.pointer = (caddr_t) &stats;
+ wrq.u.data.length = sizeof(struct iw_statistics);
+ wrq.u.data.flags = 1;
+
+ if(wext_ioctl(ifname, SIOCGIWSTATS, &wrq) >= 0)
+ {
+ *buf = stats.qual.qual;
+ return 0;
+ }
+
+ return -1;
+}
+
+int wext_get_quality_max(const char *ifname, int *buf)
+{
+ struct iwreq wrq;
+ struct iw_range range;
+
+ wrq.u.data.pointer = (caddr_t) &range;
+ wrq.u.data.length = sizeof(struct iw_range);
+ wrq.u.data.flags = 0;
+
+ if(wext_ioctl(ifname, SIOCGIWRANGE, &wrq) >= 0)
+ {
+ *buf = range.max_qual.qual;
+ return 0;
+ }
+
+ return -1;
+}
+
+int wext_get_assoclist(const char *ifname, char *buf, int *len)
+{
+ /* Stub */
+ return -1;
+}
+
+int wext_get_txpwrlist(const char *ifname, char *buf, int *len)
+{
+ struct iwreq wrq;
+ struct iw_range range;
+ struct iwinfo_txpwrlist_entry entry;
+ int i;
+
+ wrq.u.data.pointer = (caddr_t) &range;
+ wrq.u.data.length = sizeof(struct iw_range);
+ wrq.u.data.flags = 0;
+
+ if( (wext_ioctl(ifname, SIOCGIWRANGE, &wrq) >= 0) &&
+ (range.num_txpower > 0) && (range.num_txpower <= IW_MAX_TXPOWER) &&
+ !(range.txpower_capa & IW_TXPOW_RELATIVE)
+ ) {
+ for( i = 0; i < range.num_txpower; i++ )
+ {
+ if( range.txpower_capa & IW_TXPOW_MWATT )
+ {
+ entry.dbm = iwinfo_mw2dbm(range.txpower[i]);
+ entry.mw = range.txpower[i];
+ }
+
+ /* Madwifi does neither set mW not dBm caps, also iwlist assumes
+ * dBm if mW is not set, so don't check here... */
+ else /* if( range.txpower_capa & IW_TXPOW_DBM ) */
+ {
+ entry.dbm = range.txpower[i];
+ entry.mw = iwinfo_dbm2mw(range.txpower[i]);
+ }
+
+ memcpy(&buf[i*sizeof(entry)], &entry, sizeof(entry));
+ }
+
+ *len = i * sizeof(entry);
+ return 0;
+ }
+
+ return -1;
+}
+
+int wext_get_freqlist(const char *ifname, char *buf, int *len)
+{
+ struct iwreq wrq;
+ struct iw_range range;
+ struct iwinfo_freqlist_entry entry;
+ int i, bl;
+
+ wrq.u.data.pointer = (caddr_t) &range;
+ wrq.u.data.length = sizeof(struct iw_range);
+ wrq.u.data.flags = 0;
+
+ if(wext_ioctl(ifname, SIOCGIWRANGE, &wrq) >= 0)
+ {
+ bl = 0;
+
+ for(i = 0; i < range.num_frequency; i++)
+ {
+ entry.mhz = wext_freq2mhz(&range.freq[i]);
+ entry.channel = range.freq[i].i;
+ entry.restricted = 0;
+
+ memcpy(&buf[bl], &entry, sizeof(struct iwinfo_freqlist_entry));
+ bl += sizeof(struct iwinfo_freqlist_entry);
+ }
+
+ *len = bl;
+ return 0;
+ }
+
+ return -1;
+}
+
+int wext_get_country(const char *ifname, char *buf)
+{
+ sprintf(buf, "00");
+ return 0;
+}
+
+int wext_get_countrylist(const char *ifname, char *buf, int *len)
+{
+ /* Stub */
+ return -1;
+}
+
+int wext_get_hwmodelist(const char *ifname, int *buf)
+{
+ char chans[IWINFO_BUFSIZE] = { 0 };
+ struct iwinfo_freqlist_entry *e = NULL;
+ int len = 0;
+
+ *buf = 0;
+
+ if( !wext_get_freqlist(ifname, chans, &len) )
+ {
+ for( e = (struct iwinfo_freqlist_entry *)chans; e->channel; e++ )
+ {
+ if( e->channel <= 14 )
+ {
+ *buf |= IWINFO_80211_B;
+ *buf |= IWINFO_80211_G;
+ }
+ else
+ {
+ *buf |= IWINFO_80211_A;
+ }
+ }
+
+ return 0;
+ }
+
+ return -1;
+}
+
+int wext_get_encryption(const char *ifname, char *buf)
+{
+ /* No reliable crypto info in wext */
+ return -1;
+}
+
+int wext_get_mbssid_support(const char *ifname, int *buf)
+{
+ /* No multi bssid support atm */
+ return -1;
+}
+
+static char * wext_sysfs_ifname_file(const char *ifname, const char *path)
+{
+ FILE *f;
+ static char buf[128];
+ char *rv = NULL;
+
+ snprintf(buf, sizeof(buf), "/sys/class/net/%s/%s", ifname, path);
+
+ if ((f = fopen(buf, "r")) != NULL)
+ {
+ memset(buf, 0, sizeof(buf));
+
+ if (fread(buf, 1, sizeof(buf), f))
+ rv = buf;
+
+ fclose(f);
+ }
+
+ return rv;
+}
+
+int wext_get_hardware_id(const char *ifname, char *buf)
+{
+ char *data;
+ struct iwinfo_hardware_id *id = (struct iwinfo_hardware_id *)buf;
+
+ memset(id, 0, sizeof(struct iwinfo_hardware_id));
+
+ data = wext_sysfs_ifname_file(ifname, "device/vendor");
+ if (data)
+ id->vendor_id = strtoul(data, NULL, 16);
+
+ data = wext_sysfs_ifname_file(ifname, "device/device");
+ if (data)
+ id->device_id = strtoul(data, NULL, 16);
+
+ data = wext_sysfs_ifname_file(ifname, "device/subsystem_device");
+ if (data)
+ id->subsystem_device_id = strtoul(data, NULL, 16);
+
+ data = wext_sysfs_ifname_file(ifname, "device/subsystem_vendor");
+ if (data)
+ id->subsystem_vendor_id = strtoul(data, NULL, 16);
+
+ return (id->vendor_id > 0 && id->device_id > 0) ? 0 : -1;
+}
+
+int wext_get_hardware_name(const char *ifname, char *buf)
+{
+ sprintf(buf, "Generic WEXT");
+ return 0;
+}
+
+int wext_get_txpower_offset(const char *ifname, int *buf)
+{
+ /* Stub */
+ *buf = 0;
+ return -1;
+}
+
+int wext_get_frequency_offset(const char *ifname, int *buf)
+{
+ /* Stub */
+ *buf = 0;
+ return -1;
+}
diff --git a/package/network/utils/iwinfo/src/.svn/text-base/iwinfo_wext_scan.c.svn-base b/package/network/utils/iwinfo/src/.svn/text-base/iwinfo_wext_scan.c.svn-base
new file mode 100644
index 0000000..ecd40d7
--- /dev/null
+++ b/package/network/utils/iwinfo/src/.svn/text-base/iwinfo_wext_scan.c.svn-base
@@ -0,0 +1,527 @@
+/*
+ * iwinfo - Wireless Information Library - Linux Wireless Extension Backend
+ *
+ * Copyright (C) 2009-2010 Jo-Philipp Wich <xm@subsignal.org>
+ *
+ * The iwinfo library is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * The iwinfo library 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 the iwinfo library. If not, see http://www.gnu.org/licenses/.
+ *
+ * Parts of this code are derived from the Linux wireless tools, iwlib.c,
+ * iwlist.c and iwconfig.c in particular.
+ */
+
+#include "iwinfo.h"
+#include "iwinfo/wext_scan.h"
+
+
+static int wext_ioctl(const char *ifname, int cmd, struct iwreq *wrq)
+{
+ strncpy(wrq->ifr_name, ifname, IFNAMSIZ);
+ return iwinfo_ioctl(cmd, wrq);
+}
+
+static inline double wext_freq2float(const struct iw_freq *in)
+{
+ int i;
+ double res = (double) in->m;
+ for(i = 0; i < in->e; i++) res *= 10;
+ return res;
+}
+
+static inline int wext_extract_event(struct stream_descr *stream, struct iw_event *iwe, int wev)
+{
+ const struct iw_ioctl_description *descr = NULL;
+ int event_type = 0;
+ unsigned int event_len = 1;
+ char *pointer;
+ unsigned cmd_index; /* *MUST* be unsigned */
+
+ /* Check for end of stream */
+ if((stream->current + IW_EV_LCP_PK_LEN) > stream->end)
+ return 0;
+
+ /* Extract the event header (to get the event id).
+ * Note : the event may be unaligned, therefore copy... */
+ memcpy((char *) iwe, stream->current, IW_EV_LCP_PK_LEN);
+
+ /* Check invalid events */
+ if(iwe->len <= IW_EV_LCP_PK_LEN)
+ return -1;
+
+ /* Get the type and length of that event */
+ if(iwe->cmd <= SIOCIWLAST)
+ {
+ cmd_index = iwe->cmd - SIOCIWFIRST;
+ if(cmd_index < standard_ioctl_num)
+ descr = &(standard_ioctl_descr[cmd_index]);
+ }
+ else
+ {
+ cmd_index = iwe->cmd - IWEVFIRST;
+ if(cmd_index < standard_event_num)
+ descr = &(standard_event_descr[cmd_index]);
+ }
+
+ if(descr != NULL)
+ event_type = descr->header_type;
+
+ /* Unknown events -> event_type=0 => IW_EV_LCP_PK_LEN */
+ event_len = event_type_size[event_type];
+
+ /* Fixup for earlier version of WE */
+ if((wev <= 18) && (event_type == IW_HEADER_TYPE_POINT))
+ event_len += IW_EV_POINT_OFF;
+
+ /* Check if we know about this event */
+ if(event_len <= IW_EV_LCP_PK_LEN)
+ {
+ /* Skip to next event */
+ stream->current += iwe->len;
+ return 2;
+ }
+
+ event_len -= IW_EV_LCP_PK_LEN;
+
+ /* Set pointer on data */
+ if(stream->value != NULL)
+ pointer = stream->value; /* Next value in event */
+ else
+ pointer = stream->current + IW_EV_LCP_PK_LEN; /* First value in event */
+
+ /* Copy the rest of the event (at least, fixed part) */
+ if((pointer + event_len) > stream->end)
+ {
+ /* Go to next event */
+ stream->current += iwe->len;
+ return -2;
+ }
+
+ /* Fixup for WE-19 and later : pointer no longer in the stream */
+ /* Beware of alignement. Dest has local alignement, not packed */
+ if( (wev > 18) && (event_type == IW_HEADER_TYPE_POINT) )
+ memcpy((char *) iwe + IW_EV_LCP_LEN + IW_EV_POINT_OFF, pointer, event_len);
+ else
+ memcpy((char *) iwe + IW_EV_LCP_LEN, pointer, event_len);
+
+ /* Skip event in the stream */
+ pointer += event_len;
+
+ /* Special processing for iw_point events */
+ if(event_type == IW_HEADER_TYPE_POINT)
+ {
+ /* Check the length of the payload */
+ unsigned int extra_len = iwe->len - (event_len + IW_EV_LCP_PK_LEN);
+ if(extra_len > 0)
+ {
+ /* Set pointer on variable part (warning : non aligned) */
+ iwe->u.data.pointer = pointer;
+
+ /* Check that we have a descriptor for the command */
+ if(descr == NULL)
+ /* Can't check payload -> unsafe... */
+ iwe->u.data.pointer = NULL; /* Discard paylod */
+ else
+ {
+ /* Those checks are actually pretty hard to trigger,
+ * because of the checks done in the kernel... */
+
+ unsigned int token_len = iwe->u.data.length * descr->token_size;
+
+ /* Ugly fixup for alignement issues.
+ * If the kernel is 64 bits and userspace 32 bits,
+ * we have an extra 4+4 bytes.
+ * Fixing that in the kernel would break 64 bits userspace. */
+ if((token_len != extra_len) && (extra_len >= 4))
+ {
+ uint16_t alt_dlen = *((uint16_t *) pointer);
+ unsigned int alt_token_len = alt_dlen * descr->token_size;
+ if((alt_token_len + 8) == extra_len)
+ {
+ /* Ok, let's redo everything */
+ pointer -= event_len;
+ pointer += 4;
+ /* Dest has local alignement, not packed */
+ memcpy((char *) iwe + IW_EV_LCP_LEN + IW_EV_POINT_OFF, pointer, event_len);
+ pointer += event_len + 4;
+ iwe->u.data.pointer = pointer;
+ token_len = alt_token_len;
+ }
+ }
+
+ /* Discard bogus events which advertise more tokens than
+ * what they carry... */
+ if(token_len > extra_len)
+ iwe->u.data.pointer = NULL; /* Discard paylod */
+
+ /* Check that the advertised token size is not going to
+ * produce buffer overflow to our caller... */
+ if((iwe->u.data.length > descr->max_tokens)
+ && !(descr->flags & IW_DESCR_FLAG_NOMAX))
+ iwe->u.data.pointer = NULL; /* Discard paylod */
+
+ /* Same for underflows... */
+ if(iwe->u.data.length < descr->min_tokens)
+ iwe->u.data.pointer = NULL; /* Discard paylod */
+ }
+ }
+ else
+ /* No data */
+ iwe->u.data.pointer = NULL;
+
+ /* Go to next event */
+ stream->current += iwe->len;
+ }
+ else
+ {
+ /* Ugly fixup for alignement issues.
+ * If the kernel is 64 bits and userspace 32 bits,
+ * we have an extra 4 bytes.
+ * Fixing that in the kernel would break 64 bits userspace. */
+ if((stream->value == NULL)
+ && ((((iwe->len - IW_EV_LCP_PK_LEN) % event_len) == 4)
+ || ((iwe->len == 12) && ((event_type == IW_HEADER_TYPE_UINT) ||
+ (event_type == IW_HEADER_TYPE_QUAL))) ))
+ {
+ pointer -= event_len;
+ pointer += 4;
+ /* Beware of alignement. Dest has local alignement, not packed */
+ memcpy((char *) iwe + IW_EV_LCP_LEN, pointer, event_len);
+ pointer += event_len;
+ }
+
+ /* Is there more value in the event ? */
+ if((pointer + event_len) <= (stream->current + iwe->len))
+ /* Go to next value */
+ stream->value = pointer;
+ else
+ {
+ /* Go to next event */
+ stream->value = NULL;
+ stream->current += iwe->len;
+ }
+ }
+
+ return 1;
+}
+
+static inline void wext_fill_wpa(unsigned char *iebuf, int ielen, struct iwinfo_scanlist_entry *e)
+{
+ static unsigned char ms_oui[3] = { 0x00, 0x50, 0xf2 };
+
+ while (ielen >= 2 && ielen >= iebuf[1])
+ {
+ switch (iebuf[0])
+ {
+ case 48: /* RSN */
+ iwinfo_parse_rsn(&e->crypto, iebuf + 2, iebuf[1],
+ IWINFO_CIPHER_CCMP, IWINFO_KMGMT_8021x);
+ break;
+
+ case 221: /* Vendor */
+ if (iebuf[1] >= 4 && !memcmp(iebuf + 2, ms_oui, 3) && iebuf[5] == 1)
+ iwinfo_parse_rsn(&e->crypto, iebuf + 6, iebuf[1] - 4,
+ IWINFO_CIPHER_TKIP, IWINFO_KMGMT_PSK);
+ break;
+ }
+
+ ielen -= iebuf[1] + 2;
+ iebuf += iebuf[1] + 2;
+ }
+}
+
+
+static inline void wext_fill_entry(struct stream_descr *stream, struct iw_event *event,
+ struct iw_range *iw_range, int has_range, struct iwinfo_scanlist_entry *e)
+{
+ int i;
+ double freq;
+
+ /* Now, let's decode the event */
+ switch(event->cmd)
+ {
+ case SIOCGIWAP:
+ memcpy(e->mac, &event->u.ap_addr.sa_data, 6);
+ break;
+
+ case SIOCGIWFREQ:
+ if( event->u.freq.m >= 1000 )
+ {
+ freq = wext_freq2float(&(event->u.freq));
+
+ for(i = 0; i < iw_range->num_frequency; i++)
+ {
+ if( wext_freq2float(&iw_range->freq[i]) == freq )
+ {
+ e->channel = iw_range->freq[i].i;
+ break;
+ }
+ }
+ }
+ else
+ {
+ e->channel = event->u.freq.m;
+ }
+
+ break;
+
+ case SIOCGIWMODE:
+ switch(event->u.mode)
+ {
+ case 1:
+ e->mode = IWINFO_OPMODE_ADHOC;
+ break;
+
+ case 2:
+ case 3:
+ e->mode = IWINFO_OPMODE_MASTER;
+ break;
+
+ default:
+ e->mode = IWINFO_OPMODE_UNKNOWN;
+ break;
+ }
+
+ break;
+
+ case SIOCGIWESSID:
+ if( event->u.essid.pointer && event->u.essid.length && event->u.essid.flags )
+ memcpy(e->ssid, event->u.essid.pointer, event->u.essid.length);
+
+ break;
+
+ case SIOCGIWENCODE:
+ e->crypto.enabled = !(event->u.data.flags & IW_ENCODE_DISABLED);
+ break;
+
+ case IWEVQUAL:
+ e->signal = event->u.qual.level;
+ e->quality = event->u.qual.qual;
+ e->quality_max = iw_range->max_qual.qual;
+ break;
+#if 0
+ case SIOCGIWRATE:
+ if(state->val_index == 0)
+ {
+ lua_pushstring(L, "bitrates");
+ lua_newtable(L);
+ }
+ //iw_print_bitrate(buffer, sizeof(buffer), event->u.bitrate.value);
+ snprintf(buffer, sizeof(buffer), "%d", event->u.bitrate.value);
+ lua_pushinteger(L, state->val_index + 1);
+ lua_pushstring(L, buffer);
+ lua_settable(L, -3);
+
+ /* Check for termination */
+ if(stream->value == NULL)
+ {
+ lua_settable(L, -3);
+ state->val_index = 0;
+ } else
+ state->val_index++;
+ break;
+#endif
+ case IWEVGENIE:
+ wext_fill_wpa(event->u.data.pointer, event->u.data.length, e);
+ break;
+ }
+}
+
+
+int wext_get_scanlist(const char *ifname, char *buf, int *len)
+{
+ struct iwreq wrq;
+ struct iw_scan_req scanopt; /* Options for 'set' */
+ unsigned char *buffer = NULL; /* Results */
+ int buflen = IW_SCAN_MAX_DATA; /* Min for compat WE<17 */
+ struct iw_range range;
+ int has_range = 1;
+ struct timeval tv; /* Select timeout */
+ int timeout = 15000000; /* 15s */
+
+ int entrylen = 0;
+ struct iwinfo_scanlist_entry e;
+
+ wrq.u.data.pointer = (caddr_t) &range;
+ wrq.u.data.length = sizeof(struct iw_range);
+ wrq.u.data.flags = 0;
+
+ if( wext_ioctl(ifname, SIOCGIWRANGE, &wrq) >= 0 )
+ {
+ /* Init timeout value -> 250ms between set and first get */
+ tv.tv_sec = 0;
+ tv.tv_usec = 250000;
+
+ /* Clean up set args */
+ memset(&scanopt, 0, sizeof(scanopt));
+
+ wrq.u.data.pointer = NULL;
+ wrq.u.data.flags = 0;
+ wrq.u.data.length = 0;
+
+ /* Initiate Scanning */
+ if( wext_ioctl(ifname, SIOCSIWSCAN, &wrq) >= 0 )
+ {
+ timeout -= tv.tv_usec;
+
+ /* Forever */
+ while(1)
+ {
+ fd_set rfds; /* File descriptors for select */
+ int last_fd; /* Last fd */
+ int ret;
+
+ /* Guess what ? We must re-generate rfds each time */
+ FD_ZERO(&rfds);
+ last_fd = -1;
+ /* In here, add the rtnetlink fd in the list */
+
+ /* Wait until something happens */
+ ret = select(last_fd + 1, &rfds, NULL, NULL, &tv);
+
+ /* Check if there was an error */
+ if(ret < 0)
+ {
+ if(errno == EAGAIN || errno == EINTR)
+ continue;
+
+ return -1;
+ }
+
+ /* Check if there was a timeout */
+ if(ret == 0)
+ {
+ unsigned char *newbuf;
+
+ realloc:
+ /* (Re)allocate the buffer - realloc(NULL, len) == malloc(len) */
+ newbuf = realloc(buffer, buflen);
+ if(newbuf == NULL)
+ {
+ if(buffer)
+ free(buffer);
+
+ return -1;
+ }
+
+ buffer = newbuf;
+
+ /* Try to read the results */
+ wrq.u.data.pointer = buffer;
+ wrq.u.data.flags = 0;
+ wrq.u.data.length = buflen;
+
+ if( wext_ioctl(ifname, SIOCGIWSCAN, &wrq) )
+ {
+ /* Check if buffer was too small (WE-17 only) */
+ if((errno == E2BIG) && (range.we_version_compiled > 16))
+ {
+ /* Some driver may return very large scan results, either
+ * because there are many cells, or because they have many
+ * large elements in cells (like IWEVCUSTOM). Most will
+ * only need the regular sized buffer. We now use a dynamic
+ * allocation of the buffer to satisfy everybody. Of course,
+ * as we don't know in advance the size of the array, we try
+ * various increasing sizes. Jean II */
+
+ /* Check if the driver gave us any hints. */
+ if(wrq.u.data.length > buflen)
+ buflen = wrq.u.data.length;
+ else
+ buflen *= 2;
+
+ /* Try again */
+ goto realloc;
+ }
+
+ /* Check if results not available yet */
+ if(errno == EAGAIN)
+ {
+ /* Restart timer for only 100ms*/
+ tv.tv_sec = 0;
+ tv.tv_usec = 100000;
+ timeout -= tv.tv_usec;
+
+ if(timeout > 0)
+ continue; /* Try again later */
+ }
+
+ /* Bad error */
+ free(buffer);
+ return -1;
+
+ } else {
+ /* We have the results, go to process them */
+ break;
+ }
+ }
+ }
+
+ if( wrq.u.data.length )
+ {
+ struct iw_event iwe;
+ struct stream_descr stream;
+ int ret;
+ int first = 1;
+
+ memset(&stream, 0, sizeof(stream));
+ stream.current = (char *)buffer;
+ stream.end = (char *)buffer + wrq.u.data.length;
+
+ do
+ {
+ /* Extract an event and print it */
+ ret = wext_extract_event(&stream, &iwe, range.we_version_compiled);
+
+ if(ret >= 0)
+ {
+ if( (iwe.cmd == SIOCGIWAP) || (ret == 0) )
+ {
+ if( first )
+ {
+ first = 0;
+ }
+ else if( (entrylen + sizeof(struct iwinfo_scanlist_entry)) <= IWINFO_BUFSIZE )
+ {
+ /* if encryption is off, clear the crypto strunct */
+ if( !e.crypto.enabled )
+ memset(&e.crypto, 0, sizeof(struct iwinfo_crypto_entry));
+
+ memcpy(&buf[entrylen], &e, sizeof(struct iwinfo_scanlist_entry));
+ entrylen += sizeof(struct iwinfo_scanlist_entry);
+ }
+ else
+ {
+ /* we exceed the callers buffer size, abort here ... */
+ break;
+ }
+
+ memset(&e, 0, sizeof(struct iwinfo_scanlist_entry));
+ }
+
+ wext_fill_entry(&stream, &iwe, &range, has_range, &e);
+ }
+
+ } while(ret > 0);
+
+ free(buffer);
+ *len = entrylen;
+ return 0;
+ }
+
+ *len = 0;
+ free(buffer);
+ return 0;
+ }
+ }
+
+ return -1;
+}
diff --git a/package/network/utils/iwinfo/src/.svn/text-base/iwinfo_wl.c.svn-base b/package/network/utils/iwinfo/src/.svn/text-base/iwinfo_wl.c.svn-base
new file mode 100644
index 0000000..3d15fc9
--- /dev/null
+++ b/package/network/utils/iwinfo/src/.svn/text-base/iwinfo_wl.c.svn-base
@@ -0,0 +1,645 @@
+/*
+ * iwinfo - Wireless Information Library - Broadcom wl.o Backend
+ *
+ * Copyright (C) 2009 Jo-Philipp Wich <xm@subsignal.org>
+ *
+ * The iwinfo library is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * The iwinfo library 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 the iwinfo library. If not, see http://www.gnu.org/licenses/.
+ *
+ * This code is based on the wlc.c utility published by OpenWrt.org .
+ */
+
+#include "iwinfo/wl.h"
+#include "iwinfo/wext.h"
+
+static int wl_ioctl(const char *name, int cmd, void *buf, int len)
+{
+ struct ifreq ifr;
+ wl_ioctl_t ioc;
+
+ /* do it */
+ ioc.cmd = cmd;
+ ioc.buf = buf;
+ ioc.len = len;
+
+ strncpy(ifr.ifr_name, name, IFNAMSIZ);
+ ifr.ifr_data = (caddr_t) &ioc;
+
+ return iwinfo_ioctl(SIOCDEVPRIVATE, &ifr);
+}
+
+static int wl_iovar(const char *name, const char *cmd, const char *arg,
+ int arglen, void *buf, int buflen)
+{
+ int cmdlen = strlen(cmd) + 1;
+
+ memcpy(buf, cmd, cmdlen);
+
+ if (arg && arglen > 0)
+ memcpy(buf + cmdlen, arg, arglen);
+
+ return wl_ioctl(name, WLC_GET_VAR, buf, buflen);
+}
+
+static struct wl_maclist * wl_read_assoclist(const char *ifname)
+{
+ struct wl_maclist *macs;
+ int maclen = 4 + WL_MAX_STA_COUNT * 6;
+
+ if ((macs = (struct wl_maclist *) malloc(maclen)) != NULL)
+ {
+ memset(macs, 0, maclen);
+ macs->count = WL_MAX_STA_COUNT;
+
+ if (!wl_ioctl(ifname, WLC_GET_ASSOCLIST, macs, maclen))
+ return macs;
+
+ free(macs);
+ }
+
+ return NULL;
+}
+
+
+int wl_probe(const char *ifname)
+{
+ int magic;
+ return (!wl_ioctl(ifname, WLC_GET_MAGIC, &magic, sizeof(magic)) &&
+ (magic == WLC_IOCTL_MAGIC));
+}
+
+void wl_close(void)
+{
+ /* Nop */
+}
+
+int wl_get_mode(const char *ifname, int *buf)
+{
+ int ret = -1;
+ int ap, infra, passive;
+
+ if ((ret = wl_ioctl(ifname, WLC_GET_AP, &ap, sizeof(ap))))
+ return ret;
+
+ if ((ret = wl_ioctl(ifname, WLC_GET_INFRA, &infra, sizeof(infra))))
+ return ret;
+
+ if ((ret = wl_ioctl(ifname, WLC_GET_PASSIVE, &passive, sizeof(passive))))
+ return ret;
+
+ if (passive)
+ *buf = IWINFO_OPMODE_MONITOR;
+ else if (!infra)
+ *buf = IWINFO_OPMODE_ADHOC;
+ else if (ap)
+ *buf = IWINFO_OPMODE_MASTER;
+ else
+ *buf = IWINFO_OPMODE_CLIENT;
+
+ return 0;
+}
+
+int wl_get_ssid(const char *ifname, char *buf)
+{
+ int ret = -1;
+ wlc_ssid_t ssid;
+
+ if (!(ret = wl_ioctl(ifname, WLC_GET_SSID, &ssid, sizeof(ssid))))
+ memcpy(buf, ssid.ssid, ssid.ssid_len);
+
+ return ret;
+}
+
+int wl_get_bssid(const char *ifname, char *buf)
+{
+ int ret = -1;
+ char bssid[6];
+
+ if (!(ret = wl_ioctl(ifname, WLC_GET_BSSID, bssid, 6)))
+ sprintf(buf, "%02X:%02X:%02X:%02X:%02X:%02X",
+ (uint8_t)bssid[0], (uint8_t)bssid[1], (uint8_t)bssid[2],
+ (uint8_t)bssid[3], (uint8_t)bssid[4], (uint8_t)bssid[5]
+ );
+
+ return ret;
+}
+
+int wl_get_channel(const char *ifname, int *buf)
+{
+ return wl_ioctl(ifname, WLC_GET_CHANNEL, buf, sizeof(buf));
+}
+
+int wl_get_frequency(const char *ifname, int *buf)
+{
+ return wext_get_frequency(ifname, buf);
+}
+
+int wl_get_txpower(const char *ifname, int *buf)
+{
+ /* WLC_GET_VAR "qtxpower" */
+ return wext_get_txpower(ifname, buf);
+}
+
+int wl_get_bitrate(const char *ifname, int *buf)
+{
+ int ret = -1;
+ int rate = 0;
+
+ if( !(ret = wl_ioctl(ifname, WLC_GET_RATE, &rate, sizeof(rate))) && (rate > 0))
+ *buf = ((rate / 2) * 1000) + ((rate & 1) ? 500 : 0);
+
+ return ret;
+}
+
+int wl_get_signal(const char *ifname, int *buf)
+{
+ unsigned int ap, rssi, i, rssi_count;
+ int ioctl_req_version = 0x2000;
+ char tmp[WLC_IOCTL_MAXLEN];
+ struct wl_maclist *macs = NULL;
+ wl_sta_rssi_t starssi;
+
+ memset(tmp, 0, WLC_IOCTL_MAXLEN);
+ memcpy(tmp, &ioctl_req_version, sizeof(ioctl_req_version));
+
+ wl_ioctl(ifname, WLC_GET_BSS_INFO, tmp, WLC_IOCTL_MAXLEN);
+
+ if (!wl_ioctl(ifname, WLC_GET_AP, &ap, sizeof(ap)) && !ap)
+ {
+ *buf = tmp[WL_BSS_RSSI_OFFSET];
+ }
+ else
+ {
+ rssi = rssi_count = 0;
+
+ /* Calculate average rssi from conntected stations */
+ if ((macs = wl_read_assoclist(ifname)) != NULL)
+ {
+ for (i = 0; i < macs->count; i++)
+ {
+ memcpy(starssi.mac, &macs->ea[i], 6);
+
+ if (!wl_ioctl(ifname, WLC_GET_RSSI, &starssi, 12))
+ {
+ rssi -= starssi.rssi;
+ rssi_count++;
+ }
+ }
+
+ free(macs);
+ }
+
+ *buf = (rssi == 0 || rssi_count == 0) ? 1 : -(rssi / rssi_count);
+ }
+
+ return 0;
+}
+
+int wl_get_noise(const char *ifname, int *buf)
+{
+ unsigned int ap, noise;
+ int ioctl_req_version = 0x2000;
+ char tmp[WLC_IOCTL_MAXLEN];
+
+ memset(tmp, 0, WLC_IOCTL_MAXLEN);
+ memcpy(tmp, &ioctl_req_version, sizeof(ioctl_req_version));
+
+ wl_ioctl(ifname, WLC_GET_BSS_INFO, tmp, WLC_IOCTL_MAXLEN);
+
+ if ((wl_ioctl(ifname, WLC_GET_AP, &ap, sizeof(ap)) < 0) || ap)
+ {
+ if (wl_ioctl(ifname, WLC_GET_PHY_NOISE, &noise, sizeof(noise)) < 0)
+ noise = 0;
+ }
+ else
+ {
+ noise = tmp[WL_BSS_NOISE_OFFSET];
+ }
+
+ *buf = noise;
+
+ return 0;
+}
+
+int wl_get_quality(const char *ifname, int *buf)
+{
+ return wext_get_quality(ifname, buf);
+}
+
+int wl_get_quality_max(const char *ifname, int *buf)
+{
+ return wext_get_quality_max(ifname, buf);
+}
+
+int wl_get_encryption(const char *ifname, char *buf)
+{
+ uint32_t wsec, wauth, wpa;
+ struct iwinfo_crypto_entry *c = (struct iwinfo_crypto_entry *)buf;
+
+ if( wl_ioctl(ifname, WLC_GET_WPA_AUTH, &wpa, sizeof(uint32_t)) ||
+ wl_ioctl(ifname, WLC_GET_WSEC, &wsec, sizeof(uint32_t)) ||
+ wl_ioctl(ifname, WLC_GET_AUTH, &wauth, sizeof(uint32_t)) )
+ return -1;
+
+ switch(wsec)
+ {
+ case 2:
+ c->pair_ciphers |= IWINFO_CIPHER_TKIP;
+ break;
+
+ case 4:
+ c->pair_ciphers |= IWINFO_CIPHER_CCMP;
+ break;
+
+ case 6:
+ c->pair_ciphers |= IWINFO_CIPHER_TKIP;
+ c->pair_ciphers |= IWINFO_CIPHER_CCMP;
+ break;
+ }
+
+ switch(wpa)
+ {
+ case 0:
+ if (wsec && !wauth)
+ c->auth_algs |= IWINFO_AUTH_OPEN;
+
+ else if (wsec && wauth)
+ c->auth_algs |= IWINFO_AUTH_SHARED;
+
+ /* ToDo: evaluate WEP key lengths */
+ c->pair_ciphers = IWINFO_CIPHER_WEP40 | IWINFO_CIPHER_WEP104;
+ c->auth_suites |= IWINFO_KMGMT_NONE;
+ break;
+
+ case 2:
+ c->wpa_version = 1;
+ c->auth_suites |= IWINFO_KMGMT_8021x;
+ break;
+
+ case 4:
+ c->wpa_version = 1;
+ c->auth_suites |= IWINFO_KMGMT_PSK;
+ break;
+
+ case 32:
+ case 64:
+ c->wpa_version = 2;
+ c->auth_suites |= IWINFO_KMGMT_8021x;
+ break;
+
+ case 66:
+ c->wpa_version = 3;
+ c->auth_suites |= IWINFO_KMGMT_8021x;
+ break;
+
+ case 128:
+ c->wpa_version = 2;
+ c->auth_suites |= IWINFO_KMGMT_PSK;
+ break;
+
+ case 132:
+ c->wpa_version = 3;
+ c->auth_suites |= IWINFO_KMGMT_PSK;
+ break;
+
+ default:
+ break;
+ }
+
+ c->enabled = (c->wpa_version || c->auth_algs) ? 1 : 0;
+ c->group_ciphers = c->pair_ciphers;
+
+ return 0;
+}
+
+int wl_get_enctype(const char *ifname, char *buf)
+{
+ uint32_t wsec, wpa;
+ char algo[11];
+
+ if( wl_ioctl(ifname, WLC_GET_WPA_AUTH, &wpa, sizeof(uint32_t)) ||
+ wl_ioctl(ifname, WLC_GET_WSEC, &wsec, sizeof(uint32_t)) )
+ return -1;
+
+ switch(wsec)
+ {
+ case 2:
+ sprintf(algo, "TKIP");
+ break;
+
+ case 4:
+ sprintf(algo, "CCMP");
+ break;
+
+ case 6:
+ sprintf(algo, "TKIP, CCMP");
+ break;
+ }
+
+ switch(wpa)
+ {
+ case 0:
+ sprintf(buf, "%s", wsec ? "WEP" : "None");
+ break;
+
+ case 2:
+ sprintf(buf, "WPA 802.1X (%s)", algo);
+ break;
+
+ case 4:
+ sprintf(buf, "WPA PSK (%s)", algo);
+ break;
+
+ case 32:
+ sprintf(buf, "802.1X (%s)", algo);
+ break;
+
+ case 64:
+ sprintf(buf, "WPA2 802.1X (%s)", algo);
+ break;
+
+ case 66:
+ sprintf(buf, "mixed WPA/WPA2 802.1X (%s)", algo);
+ break;
+
+ case 128:
+ sprintf(buf, "WPA2 PSK (%s)", algo);
+ break;
+
+ case 132:
+ sprintf(buf, "mixed WPA/WPA2 PSK (%s)", algo);
+ break;
+
+ default:
+ sprintf(buf, "Unknown");
+ }
+
+ return 0;
+}
+
+static void wl_get_assoclist_cb(const char *ifname,
+ struct iwinfo_assoclist_entry *e)
+{
+ wl_sta_info_t sta = { 0 };
+
+ if (!wl_iovar(ifname, "sta_info", e->mac, 6, &sta, sizeof(sta)) &&
+ (sta.ver >= 2))
+ {
+ e->inactive = sta.idle * 1000;
+ e->rx_packets = sta.rx_ucast_pkts;
+ e->tx_packets = sta.tx_pkts;
+ e->rx_rate.rate = sta.rx_rate;
+ e->tx_rate.rate = sta.tx_rate;
+
+ /* ToDo: 11n */
+ e->rx_rate.mcs = -1;
+ e->tx_rate.mcs = -1;
+ }
+}
+
+int wl_get_assoclist(const char *ifname, char *buf, int *len)
+{
+ int i, j, noise;
+ int ap, infra, passive;
+ char line[128];
+ char macstr[18];
+ char devstr[IFNAMSIZ];
+ struct wl_maclist *macs;
+ struct wl_sta_rssi rssi;
+ struct iwinfo_assoclist_entry entry;
+ FILE *arp;
+
+ ap = infra = passive = 0;
+
+ wl_ioctl(ifname, WLC_GET_AP, &ap, sizeof(ap));
+ wl_ioctl(ifname, WLC_GET_INFRA, &infra, sizeof(infra));
+ wl_ioctl(ifname, WLC_GET_PASSIVE, &passive, sizeof(passive));
+
+ if (wl_get_noise(ifname, &noise))
+ noise = 0;
+
+ if ((ap || infra || passive) && ((macs = wl_read_assoclist(ifname)) != NULL))
+ {
+ for (i = 0, j = 0; i < macs->count; i++, j += sizeof(struct iwinfo_assoclist_entry))
+ {
+ memset(&entry, 0, sizeof(entry));
+ memcpy(rssi.mac, &macs->ea[i], 6);
+
+ if (!wl_ioctl(ifname, WLC_GET_RSSI, &rssi, sizeof(struct wl_sta_rssi)))
+ entry.signal = (rssi.rssi - 0x100);
+ else
+ entry.signal = 0;
+
+ entry.noise = noise;
+ memcpy(entry.mac, &macs->ea[i], 6);
+ wl_get_assoclist_cb(ifname, &entry);
+
+ memcpy(&buf[j], &entry, sizeof(entry));
+ }
+
+ *len = j;
+ free(macs);
+ return 0;
+ }
+ else if ((arp = fopen("/proc/net/arp", "r")) != NULL)
+ {
+ j = 0;
+
+ while (fgets(line, sizeof(line), arp) != NULL)
+ {
+ if (sscanf(line, "%*s 0x%*d 0x%*d %17s %*s %s", macstr, devstr) && !strcmp(devstr, ifname))
+ {
+ rssi.mac[0] = strtol(&macstr[0], NULL, 16);
+ rssi.mac[1] = strtol(&macstr[3], NULL, 16);
+ rssi.mac[2] = strtol(&macstr[6], NULL, 16);
+ rssi.mac[3] = strtol(&macstr[9], NULL, 16);
+ rssi.mac[4] = strtol(&macstr[12], NULL, 16);
+ rssi.mac[5] = strtol(&macstr[15], NULL, 16);
+
+ if (!wl_ioctl(ifname, WLC_GET_RSSI, &rssi, sizeof(struct wl_sta_rssi)))
+ entry.signal = (rssi.rssi - 0x100);
+ else
+ entry.signal = 0;
+
+ entry.noise = noise;
+ memcpy(entry.mac, rssi.mac, 6);
+ memcpy(&buf[j], &entry, sizeof(entry));
+
+ j += sizeof(entry);
+ }
+ }
+
+ *len = j;
+ (void) fclose(arp);
+ return 0;
+ }
+
+ return -1;
+}
+
+int wl_get_txpwrlist(const char *ifname, char *buf, int *len)
+{
+ struct iwinfo_txpwrlist_entry entry;
+ uint8_t dbm[11] = { 0, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24 };
+ uint8_t mw[11] = { 1, 3, 6, 10, 15, 25, 39, 63, 100, 158, 251 };
+ int i;
+
+ for (i = 0; i < 11; i++)
+ {
+ entry.dbm = dbm[i];
+ entry.mw = mw[i];
+ memcpy(&buf[i*sizeof(entry)], &entry, sizeof(entry));
+ }
+
+ *len = 11 * sizeof(entry);
+ return 0;
+}
+
+int wl_get_scanlist(const char *ifname, char *buf, int *len)
+{
+ return wext_get_scanlist(ifname, buf, len);
+}
+
+int wl_get_freqlist(const char *ifname, char *buf, int *len)
+{
+ return wext_get_freqlist(ifname, buf, len);
+}
+
+int wl_get_country(const char *ifname, char *buf)
+{
+ char ccode[WLC_CNTRY_BUF_SZ];
+
+ if (!wl_ioctl(ifname, WLC_GET_COUNTRY, ccode, WLC_CNTRY_BUF_SZ))
+ {
+ /* IL0 -> World */
+ if (!strcmp(ccode, "IL0"))
+ sprintf(buf, "00");
+
+ /* YU -> RS */
+ else if (!strcmp(ccode, "YU"))
+ sprintf(buf, "RS");
+
+ else
+ memcpy(buf, ccode, 2);
+
+ return 0;
+ }
+
+ return -1;
+}
+
+int wl_get_countrylist(const char *ifname, char *buf, int *len)
+{
+ int i, count;
+ char cdata[WLC_IOCTL_MAXLEN];
+ struct iwinfo_country_entry *c = (struct iwinfo_country_entry *)buf;
+ wl_country_list_t *cl = (wl_country_list_t *)cdata;
+
+ cl->buflen = sizeof(cdata);
+
+ if (!wl_ioctl(ifname, WLC_GET_COUNTRY_LIST, cl, cl->buflen))
+ {
+ for (i = 0, count = 0; i < cl->count; i++, c++)
+ {
+ sprintf(c->ccode, &cl->country_abbrev[i * WLC_CNTRY_BUF_SZ]);
+ c->iso3166 = c->ccode[0] * 256 + c->ccode[1];
+
+ /* IL0 -> World */
+ if (!strcmp(c->ccode, "IL0"))
+ c->iso3166 = 0x3030;
+
+ /* YU -> RS */
+ else if (!strcmp(c->ccode, "YU"))
+ c->iso3166 = 0x5253;
+ }
+
+ *len = (i * sizeof(struct iwinfo_country_entry));
+ return 0;
+ }
+
+ return -1;
+}
+
+int wl_get_hwmodelist(const char *ifname, int *buf)
+{
+ return wext_get_hwmodelist(ifname, buf);
+}
+
+int wl_get_mbssid_support(const char *ifname, int *buf)
+{
+ wlc_rev_info_t revinfo;
+
+ /* Multi bssid support only works on corerev >= 9 */
+ if (!wl_ioctl(ifname, WLC_GET_REVINFO, &revinfo, sizeof(revinfo)))
+ {
+ if (revinfo.corerev >= 9)
+ {
+ *buf = 1;
+ return 0;
+ }
+ }
+
+ return -1;
+}
+
+int wl_get_hardware_id(const char *ifname, char *buf)
+{
+ wlc_rev_info_t revinfo;
+ struct iwinfo_hardware_id *ids = (struct iwinfo_hardware_id *)buf;
+
+ if (wl_ioctl(ifname, WLC_GET_REVINFO, &revinfo, sizeof(revinfo)))
+ return -1;
+
+ ids->vendor_id = revinfo.vendorid;
+ ids->device_id = revinfo.deviceid;
+ ids->subsystem_vendor_id = revinfo.boardvendor;
+ ids->subsystem_device_id = revinfo.boardid;
+
+ return 0;
+}
+
+int wl_get_hardware_name(const char *ifname, char *buf)
+{
+ struct iwinfo_hardware_id ids;
+
+ if (wl_get_hardware_id(ifname, (char *)&ids))
+ return -1;
+
+ sprintf(buf, "Broadcom BCM%04X", ids.device_id);
+
+ return 0;
+}
+
+int wl_get_txpower_offset(const char *ifname, int *buf)
+{
+ FILE *p;
+ char off[8];
+
+ *buf = 0;
+
+ if ((p = popen("/usr/sbin/nvram get opo", "r")) != NULL)
+ {
+ if (fread(off, 1, sizeof(off), p))
+ *buf = strtoul(off, NULL, 16);
+
+ pclose(p);
+ }
+
+ return 0;
+}
+
+int wl_get_frequency_offset(const char *ifname, int *buf)
+{
+ /* Stub */
+ *buf = 0;
+ return -1;
+}
diff --git a/package/network/utils/iwinfo/src/COPYING b/package/network/utils/iwinfo/src/COPYING
new file mode 100644
index 0000000..d511905
--- /dev/null
+++ b/package/network/utils/iwinfo/src/COPYING
@@ -0,0 +1,339 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ 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 of the License, 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; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.
diff --git a/package/network/utils/iwinfo/src/Makefile b/package/network/utils/iwinfo/src/Makefile
new file mode 100644
index 0000000..572bef9
--- /dev/null
+++ b/package/network/utils/iwinfo/src/Makefile
@@ -0,0 +1,44 @@
+IWINFO_BACKENDS = $(BACKENDS)
+IWINFO_CFLAGS = $(CFLAGS) -std=gnu99 -fstrict-aliasing -Iinclude
+
+IWINFO_LIB = libiwinfo.so
+IWINFO_LIB_LDFLAGS = $(LDFLAGS) -shared
+IWINFO_LIB_OBJ = iwinfo_utils.o iwinfo_wext.o iwinfo_wext_scan.o iwinfo_lib.o
+
+IWINFO_LUA = iwinfo.so
+IWINFO_LUA_LDFLAGS = $(LDFLAGS) -shared -L. -liwinfo -llua
+IWINFO_LUA_OBJ = iwinfo_lua.o
+
+IWINFO_CLI = iwinfo
+IWINFO_CLI_LDFLAGS = $(LDFLAGS) -L. -liwinfo
+IWINFO_CLI_OBJ = iwinfo_cli.o
+
+
+ifneq ($(filter wl,$(IWINFO_BACKENDS)),)
+ IWINFO_CFLAGS += -DUSE_WL
+ IWINFO_LIB_OBJ += iwinfo_wl.o
+endif
+
+ifneq ($(filter madwifi,$(IWINFO_BACKENDS)),)
+ IWINFO_CFLAGS += -DUSE_MADWIFI
+ IWINFO_LIB_OBJ += iwinfo_madwifi.o
+endif
+
+ifneq ($(filter nl80211,$(IWINFO_BACKENDS)),)
+ IWINFO_CFLAGS += -DUSE_NL80211
+ IWINFO_CLI_LDFLAGS += -lnl-tiny
+ IWINFO_LIB_LDFLAGS += -lnl-tiny
+ IWINFO_LIB_OBJ += iwinfo_nl80211.o
+endif
+
+
+%.o: %.c
+ $(CC) $(IWINFO_CFLAGS) $(FPIC) -c -o $@ $<
+
+compile: clean $(IWINFO_LIB_OBJ) $(IWINFO_LUA_OBJ) $(IWINFO_CLI_OBJ)
+ $(CC) $(IWINFO_LIB_LDFLAGS) -o $(IWINFO_LIB) $(IWINFO_LIB_OBJ)
+ $(CC) $(IWINFO_LUA_LDFLAGS) -o $(IWINFO_LUA) $(IWINFO_LUA_OBJ)
+ $(CC) $(IWINFO_CLI_LDFLAGS) -o $(IWINFO_CLI) $(IWINFO_CLI_OBJ)
+
+clean:
+ rm -f *.o $(IWINFO_LIB) $(IWINFO_LUA) $(IWINFO_CLI)
diff --git a/package/network/utils/iwinfo/src/include/.svn/entries b/package/network/utils/iwinfo/src/include/.svn/entries
new file mode 100644
index 0000000..a6fb6c5
--- /dev/null
+++ b/package/network/utils/iwinfo/src/include/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/utils/iwinfo/src/include
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-02T19:10:29.781239Z
+34982
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+iwinfo.h
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+98ac2045720c7cd7a0585d7126421328
+2013-01-02T19:10:29.781239Z
+34982
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4490
+
+iwinfo
+dir
+
diff --git a/package/network/utils/iwinfo/src/include/.svn/text-base/iwinfo.h.svn-base b/package/network/utils/iwinfo/src/include/.svn/text-base/iwinfo.h.svn-base
new file mode 100644
index 0000000..bf7d618
--- /dev/null
+++ b/package/network/utils/iwinfo/src/include/.svn/text-base/iwinfo.h.svn-base
@@ -0,0 +1,195 @@
+#ifndef __IWINFO_H_
+#define __IWINFO_H_
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/wait.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#include <glob.h>
+#include <ctype.h>
+#include <dirent.h>
+#include <stdint.h>
+
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <net/if.h>
+#include <errno.h>
+
+
+#define IWINFO_BUFSIZE 24 * 1024
+#define IWINFO_ESSID_MAX_SIZE 32
+
+#define IWINFO_80211_A (1 << 0)
+#define IWINFO_80211_B (1 << 1)
+#define IWINFO_80211_G (1 << 2)
+#define IWINFO_80211_N (1 << 3)
+
+#define IWINFO_CIPHER_NONE (1 << 0)
+#define IWINFO_CIPHER_WEP40 (1 << 1)
+#define IWINFO_CIPHER_TKIP (1 << 2)
+#define IWINFO_CIPHER_WRAP (1 << 3)
+#define IWINFO_CIPHER_CCMP (1 << 4)
+#define IWINFO_CIPHER_WEP104 (1 << 5)
+#define IWINFO_CIPHER_AESOCB (1 << 6)
+#define IWINFO_CIPHER_CKIP (1 << 7)
+
+#define IWINFO_KMGMT_NONE (1 << 0)
+#define IWINFO_KMGMT_8021x (1 << 1)
+#define IWINFO_KMGMT_PSK (1 << 2)
+
+#define IWINFO_AUTH_OPEN (1 << 0)
+#define IWINFO_AUTH_SHARED (1 << 1)
+
+extern const char *IWINFO_CIPHER_NAMES[];
+extern const char *IWINFO_KMGMT_NAMES[];
+extern const char *IWINFO_AUTH_NAMES[];
+
+
+enum iwinfo_opmode {
+ IWINFO_OPMODE_UNKNOWN = 0,
+ IWINFO_OPMODE_MASTER = 1,
+ IWINFO_OPMODE_ADHOC = 2,
+ IWINFO_OPMODE_CLIENT = 3,
+ IWINFO_OPMODE_MONITOR = 4,
+ IWINFO_OPMODE_AP_VLAN = 5,
+ IWINFO_OPMODE_WDS = 6,
+ IWINFO_OPMODE_MESHPOINT = 7,
+ IWINFO_OPMODE_P2P_CLIENT = 8,
+ IWINFO_OPMODE_P2P_GO = 9,
+};
+
+extern const char *IWINFO_OPMODE_NAMES[];
+
+
+struct iwinfo_rate_entry {
+ uint32_t rate;
+ int8_t mcs;
+ uint8_t is_40mhz:1;
+ uint8_t is_short_gi:1;
+};
+
+struct iwinfo_assoclist_entry {
+ uint8_t mac[6];
+ int8_t signal;
+ int8_t noise;
+ uint32_t inactive;
+ uint32_t rx_packets;
+ uint32_t tx_packets;
+ struct iwinfo_rate_entry rx_rate;
+ struct iwinfo_rate_entry tx_rate;
+};
+
+struct iwinfo_txpwrlist_entry {
+ uint8_t dbm;
+ uint16_t mw;
+};
+
+struct iwinfo_freqlist_entry {
+ uint8_t channel;
+ uint32_t mhz;
+ uint8_t restricted;
+};
+
+struct iwinfo_crypto_entry {
+ uint8_t enabled;
+ uint8_t wpa_version;
+ uint8_t group_ciphers;
+ uint8_t pair_ciphers;
+ uint8_t auth_suites;
+ uint8_t auth_algs;
+};
+
+struct iwinfo_scanlist_entry {
+ uint8_t mac[6];
+ uint8_t ssid[IWINFO_ESSID_MAX_SIZE+1];
+ enum iwinfo_opmode mode;
+ uint8_t channel;
+ uint8_t signal;
+ uint8_t quality;
+ uint8_t quality_max;
+ struct iwinfo_crypto_entry crypto;
+};
+
+struct iwinfo_country_entry {
+ uint16_t iso3166;
+ uint8_t ccode[4];
+};
+
+struct iwinfo_iso3166_label {
+ uint16_t iso3166;
+ uint8_t name[28];
+};
+
+struct iwinfo_hardware_id {
+ uint16_t vendor_id;
+ uint16_t device_id;
+ uint16_t subsystem_vendor_id;
+ uint16_t subsystem_device_id;
+};
+
+struct iwinfo_hardware_entry {
+ const char *vendor_name;
+ const char *device_name;
+ uint16_t vendor_id;
+ uint16_t device_id;
+ uint16_t subsystem_vendor_id;
+ uint16_t subsystem_device_id;
+ int16_t txpower_offset;
+ int16_t frequency_offset;
+};
+
+extern const struct iwinfo_iso3166_label IWINFO_ISO3166_NAMES[];
+extern const struct iwinfo_hardware_entry IWINFO_HARDWARE_ENTRIES[];
+
+
+struct iwinfo_ops {
+ int (*mode)(const char *, int *);
+ int (*channel)(const char *, int *);
+ int (*frequency)(const char *, int *);
+ int (*frequency_offset)(const char *, int *);
+ int (*txpower)(const char *, int *);
+ int (*txpower_offset)(const char *, int *);
+ int (*bitrate)(const char *, int *);
+ int (*signal)(const char *, int *);
+ int (*noise)(const char *, int *);
+ int (*quality)(const char *, int *);
+ int (*quality_max)(const char *, int *);
+ int (*mbssid_support)(const char *, int *);
+ int (*hwmodelist)(const char *, int *);
+ int (*ssid)(const char *, char *);
+ int (*bssid)(const char *, char *);
+ int (*country)(const char *, char *);
+ int (*hardware_id)(const char *, char *);
+ int (*hardware_name)(const char *, char *);
+ int (*encryption)(const char *, char *);
+ int (*assoclist)(const char *, char *, int *);
+ int (*txpwrlist)(const char *, char *, int *);
+ int (*scanlist)(const char *, char *, int *);
+ int (*freqlist)(const char *, char *, int *);
+ int (*countrylist)(const char *, char *, int *);
+ void (*close)(void);
+};
+
+const char * iwinfo_type(const char *ifname);
+const struct iwinfo_ops * iwinfo_backend(const char *ifname);
+void iwinfo_finish(void);
+
+#include "iwinfo/wext.h"
+
+#ifdef USE_WL
+#include "iwinfo/wl.h"
+#endif
+
+#ifdef USE_MADWIFI
+#include "iwinfo/madwifi.h"
+#endif
+
+#ifdef USE_NL80211
+#include "iwinfo/nl80211.h"
+#endif
+
+#endif
diff --git a/package/network/utils/iwinfo/src/include/iwinfo.h b/package/network/utils/iwinfo/src/include/iwinfo.h
new file mode 100644
index 0000000..bf7d618
--- /dev/null
+++ b/package/network/utils/iwinfo/src/include/iwinfo.h
@@ -0,0 +1,195 @@
+#ifndef __IWINFO_H_
+#define __IWINFO_H_
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/wait.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#include <glob.h>
+#include <ctype.h>
+#include <dirent.h>
+#include <stdint.h>
+
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <net/if.h>
+#include <errno.h>
+
+
+#define IWINFO_BUFSIZE 24 * 1024
+#define IWINFO_ESSID_MAX_SIZE 32
+
+#define IWINFO_80211_A (1 << 0)
+#define IWINFO_80211_B (1 << 1)
+#define IWINFO_80211_G (1 << 2)
+#define IWINFO_80211_N (1 << 3)
+
+#define IWINFO_CIPHER_NONE (1 << 0)
+#define IWINFO_CIPHER_WEP40 (1 << 1)
+#define IWINFO_CIPHER_TKIP (1 << 2)
+#define IWINFO_CIPHER_WRAP (1 << 3)
+#define IWINFO_CIPHER_CCMP (1 << 4)
+#define IWINFO_CIPHER_WEP104 (1 << 5)
+#define IWINFO_CIPHER_AESOCB (1 << 6)
+#define IWINFO_CIPHER_CKIP (1 << 7)
+
+#define IWINFO_KMGMT_NONE (1 << 0)
+#define IWINFO_KMGMT_8021x (1 << 1)
+#define IWINFO_KMGMT_PSK (1 << 2)
+
+#define IWINFO_AUTH_OPEN (1 << 0)
+#define IWINFO_AUTH_SHARED (1 << 1)
+
+extern const char *IWINFO_CIPHER_NAMES[];
+extern const char *IWINFO_KMGMT_NAMES[];
+extern const char *IWINFO_AUTH_NAMES[];
+
+
+enum iwinfo_opmode {
+ IWINFO_OPMODE_UNKNOWN = 0,
+ IWINFO_OPMODE_MASTER = 1,
+ IWINFO_OPMODE_ADHOC = 2,
+ IWINFO_OPMODE_CLIENT = 3,
+ IWINFO_OPMODE_MONITOR = 4,
+ IWINFO_OPMODE_AP_VLAN = 5,
+ IWINFO_OPMODE_WDS = 6,
+ IWINFO_OPMODE_MESHPOINT = 7,
+ IWINFO_OPMODE_P2P_CLIENT = 8,
+ IWINFO_OPMODE_P2P_GO = 9,
+};
+
+extern const char *IWINFO_OPMODE_NAMES[];
+
+
+struct iwinfo_rate_entry {
+ uint32_t rate;
+ int8_t mcs;
+ uint8_t is_40mhz:1;
+ uint8_t is_short_gi:1;
+};
+
+struct iwinfo_assoclist_entry {
+ uint8_t mac[6];
+ int8_t signal;
+ int8_t noise;
+ uint32_t inactive;
+ uint32_t rx_packets;
+ uint32_t tx_packets;
+ struct iwinfo_rate_entry rx_rate;
+ struct iwinfo_rate_entry tx_rate;
+};
+
+struct iwinfo_txpwrlist_entry {
+ uint8_t dbm;
+ uint16_t mw;
+};
+
+struct iwinfo_freqlist_entry {
+ uint8_t channel;
+ uint32_t mhz;
+ uint8_t restricted;
+};
+
+struct iwinfo_crypto_entry {
+ uint8_t enabled;
+ uint8_t wpa_version;
+ uint8_t group_ciphers;
+ uint8_t pair_ciphers;
+ uint8_t auth_suites;
+ uint8_t auth_algs;
+};
+
+struct iwinfo_scanlist_entry {
+ uint8_t mac[6];
+ uint8_t ssid[IWINFO_ESSID_MAX_SIZE+1];
+ enum iwinfo_opmode mode;
+ uint8_t channel;
+ uint8_t signal;
+ uint8_t quality;
+ uint8_t quality_max;
+ struct iwinfo_crypto_entry crypto;
+};
+
+struct iwinfo_country_entry {
+ uint16_t iso3166;
+ uint8_t ccode[4];
+};
+
+struct iwinfo_iso3166_label {
+ uint16_t iso3166;
+ uint8_t name[28];
+};
+
+struct iwinfo_hardware_id {
+ uint16_t vendor_id;
+ uint16_t device_id;
+ uint16_t subsystem_vendor_id;
+ uint16_t subsystem_device_id;
+};
+
+struct iwinfo_hardware_entry {
+ const char *vendor_name;
+ const char *device_name;
+ uint16_t vendor_id;
+ uint16_t device_id;
+ uint16_t subsystem_vendor_id;
+ uint16_t subsystem_device_id;
+ int16_t txpower_offset;
+ int16_t frequency_offset;
+};
+
+extern const struct iwinfo_iso3166_label IWINFO_ISO3166_NAMES[];
+extern const struct iwinfo_hardware_entry IWINFO_HARDWARE_ENTRIES[];
+
+
+struct iwinfo_ops {
+ int (*mode)(const char *, int *);
+ int (*channel)(const char *, int *);
+ int (*frequency)(const char *, int *);
+ int (*frequency_offset)(const char *, int *);
+ int (*txpower)(const char *, int *);
+ int (*txpower_offset)(const char *, int *);
+ int (*bitrate)(const char *, int *);
+ int (*signal)(const char *, int *);
+ int (*noise)(const char *, int *);
+ int (*quality)(const char *, int *);
+ int (*quality_max)(const char *, int *);
+ int (*mbssid_support)(const char *, int *);
+ int (*hwmodelist)(const char *, int *);
+ int (*ssid)(const char *, char *);
+ int (*bssid)(const char *, char *);
+ int (*country)(const char *, char *);
+ int (*hardware_id)(const char *, char *);
+ int (*hardware_name)(const char *, char *);
+ int (*encryption)(const char *, char *);
+ int (*assoclist)(const char *, char *, int *);
+ int (*txpwrlist)(const char *, char *, int *);
+ int (*scanlist)(const char *, char *, int *);
+ int (*freqlist)(const char *, char *, int *);
+ int (*countrylist)(const char *, char *, int *);
+ void (*close)(void);
+};
+
+const char * iwinfo_type(const char *ifname);
+const struct iwinfo_ops * iwinfo_backend(const char *ifname);
+void iwinfo_finish(void);
+
+#include "iwinfo/wext.h"
+
+#ifdef USE_WL
+#include "iwinfo/wl.h"
+#endif
+
+#ifdef USE_MADWIFI
+#include "iwinfo/madwifi.h"
+#endif
+
+#ifdef USE_NL80211
+#include "iwinfo/nl80211.h"
+#endif
+
+#endif
diff --git a/package/network/utils/iwinfo/src/include/iwinfo/.svn/entries b/package/network/utils/iwinfo/src/include/iwinfo/.svn/entries
new file mode 100644
index 0000000..8440224
--- /dev/null
+++ b/package/network/utils/iwinfo/src/include/iwinfo/.svn/entries
@@ -0,0 +1,269 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/utils/iwinfo/src/include/iwinfo
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-02-23T13:16:09.383816Z
+30692
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+wext_scan.h
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+fa3abd9ccc1a12225151e96406a3a51d
+2011-12-03T13:57:38.074666Z
+29403
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+11090
+
+madwifi.h
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+f246a52512fac2a21711038f9185945c
+2012-02-23T13:16:09.383816Z
+30692
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3519
+
+utils.h
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+bdee86e376f01cbac24a159f8cd28e73
+2012-02-23T12:18:46.864984Z
+30691
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1394
+
+lua.h
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+4628f7724cca2ef034ce4a481fc9eb10
+2011-12-04T03:42:17.206521Z
+29421
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2101
+
+wl.h
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+619b1db715d940c428acdf6fc04d0692
+2012-02-23T13:16:09.383816Z
+30692
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3312
+
+api
+dir
+
+nl80211.h
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+7503ab1231a21b2a22b808637b886ec9
+2012-02-23T13:16:09.383816Z
+30692
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4214
+
+wext.h
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+ba99254ec6c1256a8211a12dae55e232
+2012-02-23T13:16:09.383816Z
+30692
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3377
+
diff --git a/package/network/utils/iwinfo/src/include/iwinfo/.svn/text-base/lua.h.svn-base b/package/network/utils/iwinfo/src/include/iwinfo/.svn/text-base/lua.h.svn-base
new file mode 100644
index 0000000..d976c0c
--- /dev/null
+++ b/package/network/utils/iwinfo/src/include/iwinfo/.svn/text-base/lua.h.svn-base
@@ -0,0 +1,80 @@
+/*
+ * iwinfo - Wireless Information Library - Lua Headers
+ *
+ * Copyright (C) 2009 Jo-Philipp Wich <xm@subsignal.org>
+ *
+ * The iwinfo library is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * The iwinfo library 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 the iwinfo library. If not, see http://www.gnu.org/licenses/.
+ */
+
+#ifndef __IWINFO_LUALUB_H_
+#define __IWINFO_LUALIB_H_
+
+#include <lua.h>
+#include <lualib.h>
+#include <lauxlib.h>
+
+#include "iwinfo.h"
+#include "iwinfo/wext_scan.h"
+
+
+#define IWINFO_META "iwinfo"
+#define IWINFO_WEXT_META "iwinfo.wext"
+
+#ifdef USE_WL
+#define IWINFO_WL_META "iwinfo.wl"
+#endif
+
+#ifdef USE_MADWIFI
+#define IWINFO_MADWIFI_META "iwinfo.madwifi"
+#endif
+
+#ifdef USE_NL80211
+#define IWINFO_NL80211_META "iwinfo.nl80211"
+#endif
+
+
+#define LUA_REG(type,op) \
+ { #op, iwinfo_L_##type##_##op }
+
+#define LUA_WRAP_INT(type,op) \
+ static int iwinfo_L_##type##_##op(lua_State *L) \
+ { \
+ const char *ifname = luaL_checkstring(L, 1); \
+ int rv; \
+ if( !type##_get_##op(ifname, &rv) ) \
+ lua_pushnumber(L, rv); \
+ else \
+ lua_pushnil(L); \
+ return 1; \
+ }
+
+#define LUA_WRAP_STRING(type,op) \
+ static int iwinfo_L_##type##_##op(lua_State *L) \
+ { \
+ const char *ifname = luaL_checkstring(L, 1); \
+ char rv[IWINFO_BUFSIZE]; \
+ memset(rv, 0, IWINFO_BUFSIZE); \
+ if( !type##_get_##op(ifname, rv) ) \
+ lua_pushstring(L, rv); \
+ else \
+ lua_pushnil(L); \
+ return 1; \
+ }
+
+#define LUA_WRAP_STRUCT(type,op) \
+ static int iwinfo_L_##type##_##op(lua_State *L) \
+ { \
+ return iwinfo_L_##op(L, type##_get_##op); \
+ }
+
+#endif
diff --git a/package/network/utils/iwinfo/src/include/iwinfo/.svn/text-base/madwifi.h.svn-base b/package/network/utils/iwinfo/src/include/iwinfo/.svn/text-base/madwifi.h.svn-base
new file mode 100644
index 0000000..14d8135
--- /dev/null
+++ b/package/network/utils/iwinfo/src/include/iwinfo/.svn/text-base/madwifi.h.svn-base
@@ -0,0 +1,83 @@
+/*
+ * iwinfo - Wireless Information Library - Madwifi Headers
+ *
+ * Copyright (C) 2009 Jo-Philipp Wich <xm@subsignal.org>
+ *
+ * The iwinfo library is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * The iwinfo library 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 the iwinfo library. If not, see http://www.gnu.org/licenses/.
+ */
+
+#ifndef __IWINFO_MADWIFI_H_
+#define __IWINFO_MADWIFI_H_
+
+#include <fcntl.h>
+
+#include "iwinfo.h"
+#include "iwinfo/utils.h"
+#include "iwinfo/api/madwifi.h"
+
+int madwifi_probe(const char *ifname);
+int madwifi_get_mode(const char *ifname, int *buf);
+int madwifi_get_ssid(const char *ifname, char *buf);
+int madwifi_get_bssid(const char *ifname, char *buf);
+int madwifi_get_country(const char *ifname, char *buf);
+int madwifi_get_channel(const char *ifname, int *buf);
+int madwifi_get_frequency(const char *ifname, int *buf);
+int madwifi_get_frequency_offset(const char *ifname, int *buf);
+int madwifi_get_txpower(const char *ifname, int *buf);
+int madwifi_get_txpower_offset(const char *ifname, int *buf);
+int madwifi_get_bitrate(const char *ifname, int *buf);
+int madwifi_get_signal(const char *ifname, int *buf);
+int madwifi_get_noise(const char *ifname, int *buf);
+int madwifi_get_quality(const char *ifname, int *buf);
+int madwifi_get_quality_max(const char *ifname, int *buf);
+int madwifi_get_encryption(const char *ifname, char *buf);
+int madwifi_get_assoclist(const char *ifname, char *buf, int *len);
+int madwifi_get_txpwrlist(const char *ifname, char *buf, int *len);
+int madwifi_get_scanlist(const char *ifname, char *buf, int *len);
+int madwifi_get_freqlist(const char *ifname, char *buf, int *len);
+int madwifi_get_countrylist(const char *ifname, char *buf, int *len);
+int madwifi_get_hwmodelist(const char *ifname, int *buf);
+int madwifi_get_mbssid_support(const char *ifname, int *buf);
+int madwifi_get_hardware_id(const char *ifname, char *buf);
+int madwifi_get_hardware_name(const char *ifname, char *buf);
+void madwifi_close(void);
+
+static const struct iwinfo_ops madwifi_ops = {
+ .channel = madwifi_get_channel,
+ .frequency = madwifi_get_frequency,
+ .frequency_offset = madwifi_get_frequency_offset,
+ .txpower = madwifi_get_txpower,
+ .txpower_offset = madwifi_get_txpower_offset,
+ .bitrate = madwifi_get_bitrate,
+ .signal = madwifi_get_signal,
+ .noise = madwifi_get_noise,
+ .quality = madwifi_get_quality,
+ .quality_max = madwifi_get_quality_max,
+ .mbssid_support = madwifi_get_mbssid_support,
+ .hwmodelist = madwifi_get_hwmodelist,
+ .mode = madwifi_get_mode,
+ .ssid = madwifi_get_ssid,
+ .bssid = madwifi_get_bssid,
+ .country = madwifi_get_country,
+ .hardware_id = madwifi_get_hardware_id,
+ .hardware_name = madwifi_get_hardware_name,
+ .encryption = madwifi_get_encryption,
+ .assoclist = madwifi_get_assoclist,
+ .txpwrlist = madwifi_get_txpwrlist,
+ .scanlist = madwifi_get_scanlist,
+ .freqlist = madwifi_get_freqlist,
+ .countrylist = madwifi_get_countrylist,
+ .close = madwifi_close
+};
+
+#endif
diff --git a/package/network/utils/iwinfo/src/include/iwinfo/.svn/text-base/nl80211.h.svn-base b/package/network/utils/iwinfo/src/include/iwinfo/.svn/text-base/nl80211.h.svn-base
new file mode 100644
index 0000000..2854514
--- /dev/null
+++ b/package/network/utils/iwinfo/src/include/iwinfo/.svn/text-base/nl80211.h.svn-base
@@ -0,0 +1,125 @@
+/*
+ * iwinfo - Wireless Information Library - NL80211 Headers
+ *
+ * Copyright (C) 2010 Jo-Philipp Wich <xm@subsignal.org>
+ *
+ * The iwinfo library is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * The iwinfo library 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 the iwinfo library. If not, see http://www.gnu.org/licenses/.
+ */
+
+#ifndef __IWINFO_NL80211_H_
+#define __IWINFO_NL80211_H_
+
+#include <errno.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <string.h>
+#include <dirent.h>
+#include <signal.h>
+#include <sys/un.h>
+#include <netlink/netlink.h>
+#include <netlink/genl/genl.h>
+#include <netlink/genl/family.h>
+#include <netlink/genl/ctrl.h>
+
+#include "iwinfo.h"
+#include "iwinfo/utils.h"
+#include "iwinfo/api/nl80211.h"
+
+struct nl80211_state {
+ struct nl_sock *nl_sock;
+ struct nl_cache *nl_cache;
+ struct genl_family *nl80211;
+ struct genl_family *nlctrl;
+};
+
+struct nl80211_msg_conveyor {
+ struct nl_msg *msg;
+ struct nl_cb *cb;
+};
+
+struct nl80211_event_conveyor {
+ int wait;
+ int recv;
+};
+
+struct nl80211_group_conveyor {
+ const char *name;
+ int id;
+};
+
+struct nl80211_rssi_rate {
+ int16_t rate;
+ int8_t rssi;
+};
+
+struct nl80211_array_buf {
+ void *buf;
+ int count;
+};
+
+int nl80211_probe(const char *ifname);
+int nl80211_get_mode(const char *ifname, int *buf);
+int nl80211_get_ssid(const char *ifname, char *buf);
+int nl80211_get_bssid(const char *ifname, char *buf);
+int nl80211_get_country(const char *ifname, char *buf);
+int nl80211_get_channel(const char *ifname, int *buf);
+int nl80211_get_frequency(const char *ifname, int *buf);
+int nl80211_get_frequency_offset(const char *ifname, int *buf);
+int nl80211_get_txpower(const char *ifname, int *buf);
+int nl80211_get_txpower_offset(const char *ifname, int *buf);
+int nl80211_get_bitrate(const char *ifname, int *buf);
+int nl80211_get_signal(const char *ifname, int *buf);
+int nl80211_get_noise(const char *ifname, int *buf);
+int nl80211_get_quality(const char *ifname, int *buf);
+int nl80211_get_quality_max(const char *ifname, int *buf);
+int nl80211_get_encryption(const char *ifname, char *buf);
+int nl80211_get_assoclist(const char *ifname, char *buf, int *len);
+int nl80211_get_txpwrlist(const char *ifname, char *buf, int *len);
+int nl80211_get_scanlist(const char *ifname, char *buf, int *len);
+int nl80211_get_freqlist(const char *ifname, char *buf, int *len);
+int nl80211_get_countrylist(const char *ifname, char *buf, int *len);
+int nl80211_get_hwmodelist(const char *ifname, int *buf);
+int nl80211_get_mbssid_support(const char *ifname, int *buf);
+int nl80211_get_hardware_id(const char *ifname, char *buf);
+int nl80211_get_hardware_name(const char *ifname, char *buf);
+void nl80211_close(void);
+
+static const struct iwinfo_ops nl80211_ops = {
+ .channel = nl80211_get_channel,
+ .frequency = nl80211_get_frequency,
+ .frequency_offset = nl80211_get_frequency_offset,
+ .txpower = nl80211_get_txpower,
+ .txpower_offset = nl80211_get_txpower_offset,
+ .bitrate = nl80211_get_bitrate,
+ .signal = nl80211_get_signal,
+ .noise = nl80211_get_noise,
+ .quality = nl80211_get_quality,
+ .quality_max = nl80211_get_quality_max,
+ .mbssid_support = nl80211_get_mbssid_support,
+ .hwmodelist = nl80211_get_hwmodelist,
+ .mode = nl80211_get_mode,
+ .ssid = nl80211_get_ssid,
+ .bssid = nl80211_get_bssid,
+ .country = nl80211_get_country,
+ .hardware_id = nl80211_get_hardware_id,
+ .hardware_name = nl80211_get_hardware_name,
+ .encryption = nl80211_get_encryption,
+ .assoclist = nl80211_get_assoclist,
+ .txpwrlist = nl80211_get_txpwrlist,
+ .scanlist = nl80211_get_scanlist,
+ .freqlist = nl80211_get_freqlist,
+ .countrylist = nl80211_get_countrylist,
+ .close = nl80211_close
+};
+
+#endif
diff --git a/package/network/utils/iwinfo/src/include/iwinfo/.svn/text-base/utils.h.svn-base b/package/network/utils/iwinfo/src/include/iwinfo/.svn/text-base/utils.h.svn-base
new file mode 100644
index 0000000..d58ec5f
--- /dev/null
+++ b/package/network/utils/iwinfo/src/include/iwinfo/.svn/text-base/utils.h.svn-base
@@ -0,0 +1,47 @@
+/*
+ * iwinfo - Wireless Information Library - Utility Headers
+ *
+ * Copyright (C) 2010 Jo-Philipp Wich <xm@subsignal.org>
+ *
+ * The iwinfo library is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * The iwinfo library 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 the iwinfo library. If not, see http://www.gnu.org/licenses/.
+ */
+
+#ifndef __IWINFO_UTILS_H_
+#define __IWINFO_UTILS_H_
+
+#include <sys/socket.h>
+#include <net/if.h>
+
+#include "iwinfo.h"
+
+#define LOG10_MAGIC 1.25892541179
+
+int iwinfo_ioctl(int cmd, void *ifr);
+
+int iwinfo_dbm2mw(int in);
+int iwinfo_mw2dbm(int in);
+
+int iwinfo_ifup(const char *ifname);
+int iwinfo_ifdown(const char *ifname);
+int iwinfo_ifmac(const char *ifname);
+
+void iwinfo_close(void);
+
+struct iwinfo_hardware_entry * iwinfo_hardware(struct iwinfo_hardware_id *id);
+
+int iwinfo_hardware_id_from_mtd(struct iwinfo_hardware_id *id);
+
+void iwinfo_parse_rsn(struct iwinfo_crypto_entry *c, uint8_t *data, uint8_t len,
+ uint8_t defcipher, uint8_t defauth);
+
+#endif
diff --git a/package/network/utils/iwinfo/src/include/iwinfo/.svn/text-base/wext.h.svn-base b/package/network/utils/iwinfo/src/include/iwinfo/.svn/text-base/wext.h.svn-base
new file mode 100644
index 0000000..68b596e
--- /dev/null
+++ b/package/network/utils/iwinfo/src/include/iwinfo/.svn/text-base/wext.h.svn-base
@@ -0,0 +1,84 @@
+/*
+ * iwinfo - Wireless Information Library - Linux Wireless Extension Headers
+ *
+ * Copyright (C) 2009-2010 Jo-Philipp Wich <xm@subsignal.org>
+ *
+ * The iwinfo library is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * The iwinfo library 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 the iwinfo library. If not, see http://www.gnu.org/licenses/.
+ */
+
+#ifndef __IWINFO_WEXT_H_
+#define __IWINFO_WEXT_H_
+
+#include <fcntl.h>
+
+#include "iwinfo.h"
+#include "iwinfo/utils.h"
+#include "iwinfo/api/wext.h"
+
+
+int wext_probe(const char *ifname);
+int wext_get_mode(const char *ifname, int *buf);
+int wext_get_ssid(const char *ifname, char *buf);
+int wext_get_bssid(const char *ifname, char *buf);
+int wext_get_country(const char *ifname, char *buf);
+int wext_get_channel(const char *ifname, int *buf);
+int wext_get_frequency(const char *ifname, int *buf);
+int wext_get_frequency_offset(const char *ifname, int *buf);
+int wext_get_txpower(const char *ifname, int *buf);
+int wext_get_txpower_offset(const char *ifname, int *buf);
+int wext_get_bitrate(const char *ifname, int *buf);
+int wext_get_signal(const char *ifname, int *buf);
+int wext_get_noise(const char *ifname, int *buf);
+int wext_get_quality(const char *ifname, int *buf);
+int wext_get_quality_max(const char *ifname, int *buf);
+int wext_get_encryption(const char *ifname, char *buf);
+int wext_get_assoclist(const char *ifname, char *buf, int *len);
+int wext_get_txpwrlist(const char *ifname, char *buf, int *len);
+int wext_get_scanlist(const char *ifname, char *buf, int *len);
+int wext_get_freqlist(const char *ifname, char *buf, int *len);
+int wext_get_countrylist(const char *ifname, char *buf, int *len);
+int wext_get_hwmodelist(const char *ifname, int *buf);
+int wext_get_mbssid_support(const char *ifname, int *buf);
+int wext_get_hardware_id(const char *ifname, char *buf);
+int wext_get_hardware_name(const char *ifname, char *buf);
+void wext_close(void);
+
+static const struct iwinfo_ops wext_ops = {
+ .channel = wext_get_channel,
+ .frequency = wext_get_frequency,
+ .frequency_offset = wext_get_frequency_offset,
+ .txpower = wext_get_txpower,
+ .txpower_offset = wext_get_txpower_offset,
+ .bitrate = wext_get_bitrate,
+ .signal = wext_get_signal,
+ .noise = wext_get_noise,
+ .quality = wext_get_quality,
+ .quality_max = wext_get_quality_max,
+ .mbssid_support = wext_get_mbssid_support,
+ .hwmodelist = wext_get_hwmodelist,
+ .mode = wext_get_mode,
+ .ssid = wext_get_ssid,
+ .bssid = wext_get_bssid,
+ .country = wext_get_country,
+ .hardware_id = wext_get_hardware_id,
+ .hardware_name = wext_get_hardware_name,
+ .encryption = wext_get_encryption,
+ .assoclist = wext_get_assoclist,
+ .txpwrlist = wext_get_txpwrlist,
+ .scanlist = wext_get_scanlist,
+ .freqlist = wext_get_freqlist,
+ .countrylist = wext_get_countrylist,
+ .close = wext_close
+};
+
+#endif
diff --git a/package/network/utils/iwinfo/src/include/iwinfo/.svn/text-base/wext_scan.h.svn-base b/package/network/utils/iwinfo/src/include/iwinfo/.svn/text-base/wext_scan.h.svn-base
new file mode 100644
index 0000000..085c653
--- /dev/null
+++ b/package/network/utils/iwinfo/src/include/iwinfo/.svn/text-base/wext_scan.h.svn-base
@@ -0,0 +1,380 @@
+/*
+ * iwinfo - Wireless Information Library - Linux Wireless Extension Headers
+ *
+ * Copyright (C) 2009-2010 Jo-Philipp Wich <xm@subsignal.org>
+ *
+ * The iwinfo library is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * The iwinfo library 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 the iwinfo library. If not, see http://www.gnu.org/licenses/.
+ */
+
+#ifndef __IWINFO_WEXT_SCAN_H_
+#define __IWINFO_WEXT_SCAN_H_
+
+#include <fcntl.h>
+
+#include "iwinfo.h"
+#include "iwinfo/utils.h"
+#include "iwinfo/api/wext.h"
+
+
+typedef struct stream_descr
+{
+ char * end; /* End of the stream */
+ char * current; /* Current event in stream of events */
+ char * value; /* Current value in event */
+} stream_descr;
+
+/*
+ * Describe how a standard IOCTL looks like.
+ */
+struct iw_ioctl_description
+{
+ uint8_t header_type; /* NULL, iw_point or other */
+ uint8_t token_type; /* Future */
+ uint16_t token_size; /* Granularity of payload */
+ uint16_t min_tokens; /* Min acceptable token number */
+ uint16_t max_tokens; /* Max acceptable token number */
+ uint32_t flags; /* Special handling of the request */
+};
+
+/* Type of headers we know about (basically union iwreq_data) */
+#define IW_HEADER_TYPE_NULL 0 /* Not available */
+#define IW_HEADER_TYPE_CHAR 2 /* char [IFNAMSIZ] */
+#define IW_HEADER_TYPE_UINT 4 /* __u32 */
+#define IW_HEADER_TYPE_FREQ 5 /* struct iw_freq */
+#define IW_HEADER_TYPE_ADDR 6 /* struct sockaddr */
+#define IW_HEADER_TYPE_POINT 8 /* struct iw_point */
+#define IW_HEADER_TYPE_PARAM 9 /* struct iw_param */
+#define IW_HEADER_TYPE_QUAL 10 /* struct iw_quality */
+
+/* Handling flags */
+/* Most are not implemented. I just use them as a reminder of some
+ * cool features we might need one day ;-) */
+#define IW_DESCR_FLAG_NONE 0x0000 /* Obvious */
+/* Wrapper level flags */
+#define IW_DESCR_FLAG_DUMP 0x0001 /* Not part of the dump command */
+#define IW_DESCR_FLAG_EVENT 0x0002 /* Generate an event on SET */
+#define IW_DESCR_FLAG_RESTRICT 0x0004 /* GET : request is ROOT only */
+ /* SET : Omit payload from generated iwevent */
+#define IW_DESCR_FLAG_NOMAX 0x0008 /* GET : no limit on request size */
+/* Driver level flags */
+#define IW_DESCR_FLAG_WAIT 0x0100 /* Wait for driver event */
+
+
+/*
+ * Meta-data about all the standard Wireless Extension request we
+ * know about.
+ */
+static const struct iw_ioctl_description standard_ioctl_descr[] = {
+ [SIOCSIWCOMMIT - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_NULL,
+ },
+ [SIOCGIWNAME - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_CHAR,
+ .flags = IW_DESCR_FLAG_DUMP,
+ },
+ [SIOCSIWNWID - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ .flags = IW_DESCR_FLAG_EVENT,
+ },
+ [SIOCGIWNWID - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ .flags = IW_DESCR_FLAG_DUMP,
+ },
+ [SIOCSIWFREQ - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_FREQ,
+ .flags = IW_DESCR_FLAG_EVENT,
+ },
+ [SIOCGIWFREQ - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_FREQ,
+ .flags = IW_DESCR_FLAG_DUMP,
+ },
+ [SIOCSIWMODE - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_UINT,
+ .flags = IW_DESCR_FLAG_EVENT,
+ },
+ [SIOCGIWMODE - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_UINT,
+ .flags = IW_DESCR_FLAG_DUMP,
+ },
+ [SIOCSIWSENS - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ },
+ [SIOCGIWSENS - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ },
+ [SIOCSIWRANGE - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_NULL,
+ },
+ [SIOCGIWRANGE - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .max_tokens = sizeof(struct iw_range),
+ .flags = IW_DESCR_FLAG_DUMP,
+ },
+ [SIOCSIWPRIV - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_NULL,
+ },
+ [SIOCGIWPRIV - SIOCIWFIRST] = { /* (handled directly by us) */
+ .header_type = IW_HEADER_TYPE_NULL,
+ },
+ [SIOCSIWSTATS - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_NULL,
+ },
+ [SIOCGIWSTATS - SIOCIWFIRST] = { /* (handled directly by us) */
+ .header_type = IW_HEADER_TYPE_NULL,
+ .flags = IW_DESCR_FLAG_DUMP,
+ },
+ [SIOCSIWSPY - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = sizeof(struct sockaddr),
+ .max_tokens = IW_MAX_SPY,
+ },
+ [SIOCGIWSPY - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = sizeof(struct sockaddr) +
+ sizeof(struct iw_quality),
+ .max_tokens = IW_MAX_SPY,
+ },
+ [SIOCSIWTHRSPY - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = sizeof(struct iw_thrspy),
+ .min_tokens = 1,
+ .max_tokens = 1,
+ },
+ [SIOCGIWTHRSPY - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = sizeof(struct iw_thrspy),
+ .min_tokens = 1,
+ .max_tokens = 1,
+ },
+ [SIOCSIWAP - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_ADDR,
+ },
+ [SIOCGIWAP - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_ADDR,
+ .flags = IW_DESCR_FLAG_DUMP,
+ },
+ [SIOCSIWMLME - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .min_tokens = sizeof(struct iw_mlme),
+ .max_tokens = sizeof(struct iw_mlme),
+ },
+ [SIOCGIWAPLIST - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = sizeof(struct sockaddr) +
+ sizeof(struct iw_quality),
+ .max_tokens = IW_MAX_AP,
+ .flags = IW_DESCR_FLAG_NOMAX,
+ },
+ [SIOCSIWSCAN - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .min_tokens = 0,
+ .max_tokens = sizeof(struct iw_scan_req),
+ },
+ [SIOCGIWSCAN - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .max_tokens = IW_SCAN_MAX_DATA,
+ .flags = IW_DESCR_FLAG_NOMAX,
+ },
+ [SIOCSIWESSID - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .max_tokens = IW_ESSID_MAX_SIZE + 1,
+ .flags = IW_DESCR_FLAG_EVENT,
+ },
+ [SIOCGIWESSID - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .max_tokens = IW_ESSID_MAX_SIZE + 1,
+ .flags = IW_DESCR_FLAG_DUMP,
+ },
+ [SIOCSIWNICKN - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .max_tokens = IW_ESSID_MAX_SIZE + 1,
+ },
+ [SIOCGIWNICKN - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .max_tokens = IW_ESSID_MAX_SIZE + 1,
+ },
+ [SIOCSIWRATE - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ },
+ [SIOCGIWRATE - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ },
+ [SIOCSIWRTS - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ },
+ [SIOCGIWRTS - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ },
+ [SIOCSIWFRAG - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ },
+ [SIOCGIWFRAG - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ },
+ [SIOCSIWTXPOW - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ },
+ [SIOCGIWTXPOW - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ },
+ [SIOCSIWRETRY - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ },
+ [SIOCGIWRETRY - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ },
+ [SIOCSIWENCODE - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .max_tokens = IW_ENCODING_TOKEN_MAX,
+ .flags = IW_DESCR_FLAG_EVENT | IW_DESCR_FLAG_RESTRICT,
+ },
+ [SIOCGIWENCODE - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .max_tokens = IW_ENCODING_TOKEN_MAX,
+ .flags = IW_DESCR_FLAG_DUMP | IW_DESCR_FLAG_RESTRICT,
+ },
+ [SIOCSIWPOWER - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ },
+ [SIOCGIWPOWER - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ },
+ [SIOCSIWMODUL - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ },
+ [SIOCGIWMODUL - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ },
+ [SIOCSIWGENIE - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .max_tokens = IW_GENERIC_IE_MAX,
+ },
+ [SIOCGIWGENIE - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .max_tokens = IW_GENERIC_IE_MAX,
+ },
+ [SIOCSIWAUTH - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ },
+ [SIOCGIWAUTH - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ },
+ [SIOCSIWENCODEEXT - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .min_tokens = sizeof(struct iw_encode_ext),
+ .max_tokens = sizeof(struct iw_encode_ext) +
+ IW_ENCODING_TOKEN_MAX,
+ },
+ [SIOCGIWENCODEEXT - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .min_tokens = sizeof(struct iw_encode_ext),
+ .max_tokens = sizeof(struct iw_encode_ext) +
+ IW_ENCODING_TOKEN_MAX,
+ },
+ [SIOCSIWPMKSA - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .min_tokens = sizeof(struct iw_pmksa),
+ .max_tokens = sizeof(struct iw_pmksa),
+ },
+};
+
+/*
+ * Meta-data about all the additional standard Wireless Extension events
+ * we know about.
+ */
+static const struct iw_ioctl_description standard_event_descr[] = {
+ [IWEVTXDROP - IWEVFIRST] = {
+ .header_type = IW_HEADER_TYPE_ADDR,
+ },
+ [IWEVQUAL - IWEVFIRST] = {
+ .header_type = IW_HEADER_TYPE_QUAL,
+ },
+ [IWEVCUSTOM - IWEVFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .max_tokens = IW_CUSTOM_MAX,
+ },
+ [IWEVREGISTERED - IWEVFIRST] = {
+ .header_type = IW_HEADER_TYPE_ADDR,
+ },
+ [IWEVEXPIRED - IWEVFIRST] = {
+ .header_type = IW_HEADER_TYPE_ADDR,
+ },
+ [IWEVGENIE - IWEVFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .max_tokens = IW_GENERIC_IE_MAX,
+ },
+ [IWEVMICHAELMICFAILURE - IWEVFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .max_tokens = sizeof(struct iw_michaelmicfailure),
+ },
+ [IWEVASSOCREQIE - IWEVFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .max_tokens = IW_GENERIC_IE_MAX,
+ },
+ [IWEVASSOCRESPIE - IWEVFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .max_tokens = IW_GENERIC_IE_MAX,
+ },
+ [IWEVPMKIDCAND - IWEVFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .max_tokens = sizeof(struct iw_pmkid_cand),
+ },
+};
+
+/* Size (in bytes) of various events */
+static const int event_type_size[] = {
+ IW_EV_LCP_PK_LEN, /* IW_HEADER_TYPE_NULL */
+ 0,
+ IW_EV_CHAR_PK_LEN, /* IW_HEADER_TYPE_CHAR */
+ 0,
+ IW_EV_UINT_PK_LEN, /* IW_HEADER_TYPE_UINT */
+ IW_EV_FREQ_PK_LEN, /* IW_HEADER_TYPE_FREQ */
+ IW_EV_ADDR_PK_LEN, /* IW_HEADER_TYPE_ADDR */
+ 0,
+ IW_EV_POINT_PK_LEN, /* Without variable payload */
+ IW_EV_PARAM_PK_LEN, /* IW_HEADER_TYPE_PARAM */
+ IW_EV_QUAL_PK_LEN, /* IW_HEADER_TYPE_QUAL */
+};
+
+
+static const unsigned int standard_ioctl_num =
+ (sizeof(standard_ioctl_descr) / sizeof(struct iw_ioctl_description));
+
+static const unsigned int standard_event_num =
+ (sizeof(standard_event_descr) / sizeof(struct iw_ioctl_description));
+
+#define IW_IE_CYPHER_NUM 8
+#define IW_IE_KEY_MGMT_NUM 3
+
+#endif
diff --git a/package/network/utils/iwinfo/src/include/iwinfo/.svn/text-base/wl.h.svn-base b/package/network/utils/iwinfo/src/include/iwinfo/.svn/text-base/wl.h.svn-base
new file mode 100644
index 0000000..db37e37
--- /dev/null
+++ b/package/network/utils/iwinfo/src/include/iwinfo/.svn/text-base/wl.h.svn-base
@@ -0,0 +1,84 @@
+/*
+ * iwinfo - Wireless Information Library - Broadcom wl.o Headers
+ *
+ * Copyright (C) 2009-2010 Jo-Philipp Wich <xm@subsignal.org>
+ *
+ * The iwinfo library is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * The iwinfo library 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 the iwinfo library. If not, see http://www.gnu.org/licenses/.
+ */
+
+#ifndef __IWINFO_WL_H_
+#define __IWINFO_WL_H_
+
+#include <fcntl.h>
+
+#include "iwinfo.h"
+#include "iwinfo/utils.h"
+#include "iwinfo/api/broadcom.h"
+
+int wl_probe(const char *ifname);
+int wl_get_mode(const char *ifname, int *buf);
+int wl_get_ssid(const char *ifname, char *buf);
+int wl_get_bssid(const char *ifname, char *buf);
+int wl_get_country(const char *ifname, char *buf);
+int wl_get_channel(const char *ifname, int *buf);
+int wl_get_frequency(const char *ifname, int *buf);
+int wl_get_frequency_offset(const char *ifname, int *buf);
+int wl_get_txpower(const char *ifname, int *buf);
+int wl_get_txpower_offset(const char *ifname, int *buf);
+int wl_get_bitrate(const char *ifname, int *buf);
+int wl_get_signal(const char *ifname, int *buf);
+int wl_get_noise(const char *ifname, int *buf);
+int wl_get_quality(const char *ifname, int *buf);
+int wl_get_quality_max(const char *ifname, int *buf);
+int wl_get_enctype(const char *ifname, char *buf);
+int wl_get_encryption(const char *ifname, char *buf);
+int wl_get_assoclist(const char *ifname, char *buf, int *len);
+int wl_get_txpwrlist(const char *ifname, char *buf, int *len);
+int wl_get_scanlist(const char *ifname, char *buf, int *len);
+int wl_get_freqlist(const char *ifname, char *buf, int *len);
+int wl_get_countrylist(const char *ifname, char *buf, int *len);
+int wl_get_hwmodelist(const char *ifname, int *buf);
+int wl_get_mbssid_support(const char *ifname, int *buf);
+int wl_get_hardware_id(const char *ifname, char *buf);
+int wl_get_hardware_name(const char *ifname, char *buf);
+void wl_close(void);
+
+static const struct iwinfo_ops wl_ops = {
+ .channel = wl_get_channel,
+ .frequency = wl_get_frequency,
+ .frequency_offset = wl_get_frequency_offset,
+ .txpower = wl_get_txpower,
+ .txpower_offset = wl_get_txpower_offset,
+ .bitrate = wl_get_bitrate,
+ .signal = wl_get_signal,
+ .noise = wl_get_noise,
+ .quality = wl_get_quality,
+ .quality_max = wl_get_quality_max,
+ .mbssid_support = wl_get_mbssid_support,
+ .hwmodelist = wl_get_hwmodelist,
+ .mode = wl_get_mode,
+ .ssid = wl_get_ssid,
+ .bssid = wl_get_bssid,
+ .country = wl_get_country,
+ .hardware_id = wl_get_hardware_id,
+ .hardware_name = wl_get_hardware_name,
+ .encryption = wl_get_encryption,
+ .assoclist = wl_get_assoclist,
+ .txpwrlist = wl_get_txpwrlist,
+ .scanlist = wl_get_scanlist,
+ .freqlist = wl_get_freqlist,
+ .countrylist = wl_get_countrylist,
+ .close = wl_close
+};
+
+#endif
diff --git a/package/network/utils/iwinfo/src/include/iwinfo/api/.svn/entries b/package/network/utils/iwinfo/src/include/iwinfo/api/.svn/entries
new file mode 100644
index 0000000..b1b4332
--- /dev/null
+++ b/package/network/utils/iwinfo/src/include/iwinfo/api/.svn/entries
@@ -0,0 +1,164 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/utils/iwinfo/src/include/iwinfo/api
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-02-22T13:39:16.526452Z
+30682
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+madwifi.h
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+e71abfc034728e7127b43fe9d1f75c85
+2012-02-22T13:39:16.526452Z
+30682
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5549
+
+nl80211.h
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+194f6c9c11f4e7a6b3a7ecff986e8775
+2012-02-22T13:39:16.526452Z
+30682
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+116067
+
+broadcom.h
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+704d20baacc98a1ce13adfb4dcf9da8f
+2012-02-22T13:39:16.526452Z
+30682
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4025
+
+wext.h
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+7a7ea34fa1349bf764d62b6b07681ccb
+2011-12-03T13:57:38.074666Z
+29403
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+43877
+
diff --git a/package/network/utils/iwinfo/src/include/iwinfo/api/.svn/text-base/broadcom.h.svn-base b/package/network/utils/iwinfo/src/include/iwinfo/api/.svn/text-base/broadcom.h.svn-base
new file mode 100644
index 0000000..50eedd9
--- /dev/null
+++ b/package/network/utils/iwinfo/src/include/iwinfo/api/.svn/text-base/broadcom.h.svn-base
@@ -0,0 +1,131 @@
+/*
+ * Custom OID/ioctl definitions for
+ * Broadcom 802.11abg Networking Device Driver
+ *
+ * Definitions subject to change without notice.
+ *
+ * Copyright 2006, Broadcom Corporation
+ * All Rights Reserved.
+ *
+ * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
+ * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
+ * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
+ * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
+ *
+ */
+
+#ifndef _BROADCOM_H
+#define _BROADCOM_H
+
+#define WL_MCSSET_LEN 16
+#define WL_MAX_STA_COUNT 32
+
+#define WL_BSS_RSSI_OFFSET 82
+#define WL_BSS_NOISE_OFFSET 84
+
+#define WLC_IOCTL_MAGIC 0x14e46c77
+#define WLC_IOCTL_MAXLEN 8192
+
+#define WLC_CNTRY_BUF_SZ 4
+
+#define WLC_GET_MAGIC 0
+#define WLC_GET_RATE 12
+#define WLC_GET_INFRA 19
+#define WLC_GET_AUTH 21
+#define WLC_GET_BSSID 23
+#define WLC_GET_SSID 25
+#define WLC_GET_CHANNEL 29
+#define WLC_GET_PASSIVE 48
+#define WLC_GET_COUNTRY 83
+#define WLC_GET_REVINFO 98
+#define WLC_GET_AP 117
+#define WLC_GET_RSSI 127
+#define WLC_GET_WSEC 133
+#define WLC_GET_PHY_NOISE 135
+#define WLC_GET_BSS_INFO 136
+#define WLC_GET_ASSOCLIST 159
+#define WLC_GET_WPA_AUTH 164
+#define WLC_GET_COUNTRY_LIST 261
+#define WLC_GET_VAR 262
+
+
+struct wl_ether_addr {
+ uint8_t octet[6];
+};
+
+struct wl_maclist {
+ uint count;
+ struct wl_ether_addr ea[1];
+};
+
+typedef struct wl_sta_rssi {
+ int rssi;
+ char mac[6];
+ uint16_t foo;
+} wl_sta_rssi_t;
+
+#define WL_NUMRATES 255 /* max # of rates in a rateset */
+typedef struct wl_rateset {
+ uint32_t count; /* # rates in this set */
+ uint8_t rates[WL_NUMRATES]; /* rates in 500kbps units w/hi bit set if basic */
+} wl_rateset_t;
+
+typedef struct wl_sta_info {
+ uint16_t ver; /* version of this struct */
+ uint16_t len; /* length in bytes of this structure */
+ uint16_t cap; /* sta's advertised capabilities */
+ uint32_t flags; /* flags defined below */
+ uint32_t idle; /* time since data pkt rx'd from sta */
+ unsigned char ea[6]; /* Station address */
+ wl_rateset_t rateset; /* rateset in use */
+ uint32_t in; /* seconds elapsed since associated */
+ uint32_t listen_interval_inms; /* Min Listen interval in ms for this STA */
+ uint32_t tx_pkts; /* # of packets transmitted */
+ uint32_t tx_failures; /* # of packets failed */
+ uint32_t rx_ucast_pkts; /* # of unicast packets received */
+ uint32_t rx_mcast_pkts; /* # of multicast packets received */
+ uint32_t tx_rate; /* Rate of last successful tx frame */
+ uint32_t rx_rate; /* Rate of last successful rx frame */
+} wl_sta_info_t;
+
+typedef struct wlc_ssid {
+ uint32_t ssid_len;
+ unsigned char ssid[32];
+} wlc_ssid_t;
+
+/* Linux network driver ioctl encoding */
+typedef struct wl_ioctl {
+ uint32_t cmd; /* common ioctl definition */
+ void *buf; /* pointer to user buffer */
+ uint32_t len; /* length of user buffer */
+ uint8_t set; /* get or set request (optional) */
+ uint32_t used; /* bytes read or written (optional) */
+ uint32_t needed; /* bytes needed (optional) */
+} wl_ioctl_t;
+
+/* Revision info */
+typedef struct wlc_rev_info {
+ uint vendorid; /* PCI vendor id */
+ uint deviceid; /* device id of chip */
+ uint radiorev; /* radio revision */
+ uint chiprev; /* chip revision */
+ uint corerev; /* core revision */
+ uint boardid; /* board identifier (usu. PCI sub-device id) */
+ uint boardvendor; /* board vendor (usu. PCI sub-vendor id) */
+ uint boardrev; /* board revision */
+ uint driverrev; /* driver version */
+ uint ucoderev; /* microcode version */
+ uint bus; /* bus type */
+ uint chipnum; /* chip number */
+} wlc_rev_info_t;
+
+typedef struct wl_country_list {
+ uint32_t buflen;
+ uint32_t band_set;
+ uint32_t band;
+ uint32_t count;
+ char country_abbrev[1];
+} wl_country_list_t;
+
+
+#endif
diff --git a/package/network/utils/iwinfo/src/include/iwinfo/api/.svn/text-base/madwifi.h.svn-base b/package/network/utils/iwinfo/src/include/iwinfo/api/.svn/text-base/madwifi.h.svn-base
new file mode 100644
index 0000000..80d32e1
--- /dev/null
+++ b/package/network/utils/iwinfo/src/include/iwinfo/api/.svn/text-base/madwifi.h.svn-base
@@ -0,0 +1,160 @@
+/*
+ * Header bits derived from MadWifi source:
+ * Copyright (c) 2001 Atsushi Onoe
+ * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
+ * All rights reserved.
+ *
+ * Distributed under the terms of the GPLv2 license.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _MADWIFI_H
+#define _MADWIFI_H
+
+/* ieee80211.h */
+#define IEEE80211_ADDR_LEN 6
+#define IEEE80211_RATE_VAL 0x7f
+#define IEEE80211_SEQ_SEQ_MASK 0xfff0
+#define IEEE80211_SEQ_SEQ_SHIFT 4
+
+
+/* ieee80211_crypto.h */
+#define IEEE80211_KEYBUF_SIZE 16
+#define IEEE80211_MICBUF_SIZE 16
+#define IEEE80211_TID_SIZE 17
+
+#define IEEE80211_CIPHER_WEP 0
+#define IEEE80211_CIPHER_TKIP 1
+#define IEEE80211_CIPHER_AES_OCB 2
+#define IEEE80211_CIPHER_AES_CCM 3
+#define IEEE80211_CIPHER_CKIP 5
+#define IEEE80211_CIPHER_NONE 6
+#define IEEE80211_CIPHER_MAX (IEEE80211_CIPHER_NONE + 1)
+
+
+/* ieee80211_ioctl.h */
+#define IEEE80211_KEY_DEFAULT 0x80
+#define IEEE80211_CHAN_MAX 255
+#define IEEE80211_CHAN_BYTES 32
+#define IEEE80211_RATE_MAXSIZE 15
+
+#define IEEE80211_IOCTL_GETKEY (SIOCDEVPRIVATE+3)
+#define IEEE80211_IOCTL_STA_STATS (SIOCDEVPRIVATE+5)
+#define IEEE80211_IOCTL_STA_INFO (SIOCDEVPRIVATE+6)
+
+#define IEEE80211_IOCTL_GETPARAM (SIOCIWFIRSTPRIV+1)
+#define IEEE80211_IOCTL_GETMODE (SIOCIWFIRSTPRIV+3)
+#define IEEE80211_IOCTL_GETCHANLIST (SIOCIWFIRSTPRIV+7)
+#define IEEE80211_IOCTL_GETCHANINFO (SIOCIWFIRSTPRIV+13)
+
+#define SIOC80211IFCREATE (SIOCDEVPRIVATE+7)
+#define SIOC80211IFDESTROY (SIOCDEVPRIVATE+8)
+
+#define IEEE80211_CLONE_BSSID 0x0001 /* allocate unique mac/bssid */
+#define IEEE80211_NO_STABEACONS 0x0002 /* Do not setup the station beacon timers */
+
+struct ieee80211_clone_params {
+ char icp_name[IFNAMSIZ]; /* device name */
+ u_int16_t icp_opmode; /* operating mode */
+ u_int16_t icp_flags; /* see below */
+};
+
+enum ieee80211_opmode {
+ IEEE80211_M_STA = 1, /* infrastructure station */
+ IEEE80211_M_IBSS = 0, /* IBSS (adhoc) station */
+ IEEE80211_M_AHDEMO = 3, /* Old lucent compatible adhoc demo */
+ IEEE80211_M_HOSTAP = 6, /* Software Access Point */
+ IEEE80211_M_MONITOR = 8, /* Monitor mode */
+ IEEE80211_M_WDS = 2, /* WDS link */
+};
+
+enum {
+ IEEE80211_PARAM_AUTHMODE = 3, /* authentication mode */
+ IEEE80211_PARAM_MCASTCIPHER = 5, /* multicast/default cipher */
+ IEEE80211_PARAM_MCASTKEYLEN = 6, /* multicast key length */
+ IEEE80211_PARAM_UCASTCIPHERS = 7, /* unicast cipher suites */
+ IEEE80211_PARAM_WPA = 10, /* WPA mode (0,1,2) */
+};
+
+/*
+ * Authentication mode.
+ */
+enum ieee80211_authmode {
+ IEEE80211_AUTH_NONE = 0,
+ IEEE80211_AUTH_OPEN = 1, /* open */
+ IEEE80211_AUTH_SHARED = 2, /* shared-key */
+ IEEE80211_AUTH_8021X = 3, /* 802.1x */
+ IEEE80211_AUTH_AUTO = 4, /* auto-select/accept */
+ /* NB: these are used only for ioctls */
+ IEEE80211_AUTH_WPA = 5, /* WPA/RSN w/ 802.1x/PSK */
+};
+
+struct ieee80211_channel {
+ u_int16_t ic_freq; /* setting in MHz */
+ u_int16_t ic_flags; /* see below */
+ u_int8_t ic_ieee; /* IEEE channel number */
+ int8_t ic_maxregpower; /* maximum regulatory tx power in dBm */
+ int8_t ic_maxpower; /* maximum tx power in dBm */
+ int8_t ic_minpower; /* minimum tx power in dBm */
+ u_int8_t ic_scanflags;
+ u_int8_t ic_idletime; /* phy idle time in % */
+};
+
+struct ieee80211req_key {
+ u_int8_t ik_type; /* key/cipher type */
+ u_int8_t ik_pad;
+ u_int16_t ik_keyix; /* key index */
+ u_int8_t ik_keylen; /* key length in bytes */
+ u_int8_t ik_flags;
+ u_int8_t ik_macaddr[IEEE80211_ADDR_LEN];
+ u_int64_t ik_keyrsc; /* key receive sequence counter */
+ u_int64_t ik_keytsc; /* key transmit sequence counter */
+ u_int8_t ik_keydata[IEEE80211_KEYBUF_SIZE+IEEE80211_MICBUF_SIZE];
+};
+
+struct ieee80211req_chanlist {
+ u_int8_t ic_channels[IEEE80211_CHAN_BYTES];
+};
+
+struct ieee80211req_chaninfo {
+ u_int ic_nchans;
+ struct ieee80211_channel ic_chans[IEEE80211_CHAN_MAX];
+};
+
+struct ieee80211req_sta_info {
+ u_int16_t isi_len; /* length (mult of 4) */
+ u_int16_t isi_freq; /* MHz */
+ u_int16_t isi_flags; /* channel flags */
+ u_int16_t isi_state; /* state flags */
+ u_int8_t isi_authmode; /* authentication algorithm */
+ u_int8_t isi_rssi;
+ int8_t isi_noise;
+ u_int16_t isi_capinfo; /* capabilities */
+ u_int8_t isi_athflags; /* Atheros capabilities */
+ u_int8_t isi_erp; /* ERP element */
+ u_int8_t isi_macaddr[IEEE80211_ADDR_LEN];
+ u_int8_t isi_nrates; /* negotiated rates */
+ u_int8_t isi_rates[IEEE80211_RATE_MAXSIZE];
+ u_int8_t isi_txrate; /* index to isi_rates[] */
+ u_int16_t isi_ie_len; /* IE length */
+ u_int16_t isi_associd; /* assoc response */
+ u_int16_t isi_txpower; /* current tx power */
+ u_int16_t isi_vlan; /* vlan tag */
+ u_int16_t isi_txseqs[17]; /* seq to be transmitted */
+ u_int16_t isi_rxseqs[17]; /* seq previous for qos frames*/
+ u_int16_t isi_inact; /* inactivity timer */
+ u_int8_t isi_uapsd; /* UAPSD queues */
+ u_int8_t isi_opmode; /* sta operating mode */
+};
+
+#endif
diff --git a/package/network/utils/iwinfo/src/include/iwinfo/api/.svn/text-base/nl80211.h.svn-base b/package/network/utils/iwinfo/src/include/iwinfo/api/.svn/text-base/nl80211.h.svn-base
new file mode 100644
index 0000000..d73dcb8
--- /dev/null
+++ b/package/network/utils/iwinfo/src/include/iwinfo/api/.svn/text-base/nl80211.h.svn-base
@@ -0,0 +1,2834 @@
+#ifndef __LINUX_NL80211_H
+#define __LINUX_NL80211_H
+/*
+ * 802.11 netlink interface public header
+ *
+ * Copyright 2006-2010 Johannes Berg <johannes@sipsolutions.net>
+ * Copyright 2008 Michael Wu <flamingice@sourmilk.net>
+ * Copyright 2008 Luis Carlos Cobo <luisca@cozybit.com>
+ * Copyright 2008 Michael Buesch <m@bues.ch>
+ * Copyright 2008, 2009 Luis R. Rodriguez <lrodriguez@atheros.com>
+ * Copyright 2008 Jouni Malinen <jouni.malinen@atheros.com>
+ * Copyright 2008 Colin McCabe <colin@cozybit.com>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+#include <linux/types.h>
+
+/**
+ * DOC: Station handling
+ *
+ * Stations are added per interface, but a special case exists with VLAN
+ * interfaces. When a station is bound to an AP interface, it may be moved
+ * into a VLAN identified by a VLAN interface index (%NL80211_ATTR_STA_VLAN).
+ * The station is still assumed to belong to the AP interface it was added
+ * to.
+ *
+ * TODO: need more info?
+ */
+
+/**
+ * DOC: Frame transmission/registration support
+ *
+ * Frame transmission and registration support exists to allow userspace
+ * management entities such as wpa_supplicant react to management frames
+ * that are not being handled by the kernel. This includes, for example,
+ * certain classes of action frames that cannot be handled in the kernel
+ * for various reasons.
+ *
+ * Frame registration is done on a per-interface basis and registrations
+ * cannot be removed other than by closing the socket. It is possible to
+ * specify a registration filter to register, for example, only for a
+ * certain type of action frame. In particular with action frames, those
+ * that userspace registers for will not be returned as unhandled by the
+ * driver, so that the registered application has to take responsibility
+ * for doing that.
+ *
+ * The type of frame that can be registered for is also dependent on the
+ * driver and interface type. The frame types are advertised in wiphy
+ * attributes so applications know what to expect.
+ *
+ * NOTE: When an interface changes type while registrations are active,
+ * these registrations are ignored until the interface type is
+ * changed again. This means that changing the interface type can
+ * lead to a situation that couldn't otherwise be produced, but
+ * any such registrations will be dormant in the sense that they
+ * will not be serviced, i.e. they will not receive any frames.
+ *
+ * Frame transmission allows userspace to send for example the required
+ * responses to action frames. It is subject to some sanity checking,
+ * but many frames can be transmitted. When a frame was transmitted, its
+ * status is indicated to the sending socket.
+ *
+ * For more technical details, see the corresponding command descriptions
+ * below.
+ */
+
+/**
+ * DOC: Virtual interface / concurrency capabilities
+ *
+ * Some devices are able to operate with virtual MACs, they can have
+ * more than one virtual interface. The capability handling for this
+ * is a bit complex though, as there may be a number of restrictions
+ * on the types of concurrency that are supported.
+ *
+ * To start with, each device supports the interface types listed in
+ * the %NL80211_ATTR_SUPPORTED_IFTYPES attribute, but by listing the
+ * types there no concurrency is implied.
+ *
+ * Once concurrency is desired, more attributes must be observed:
+ * To start with, since some interface types are purely managed in
+ * software, like the AP-VLAN type in mac80211 for example, there's
+ * an additional list of these, they can be added at any time and
+ * are only restricted by some semantic restrictions (e.g. AP-VLAN
+ * cannot be added without a corresponding AP interface). This list
+ * is exported in the %NL80211_ATTR_SOFTWARE_IFTYPES attribute.
+ *
+ * Further, the list of supported combinations is exported. This is
+ * in the %NL80211_ATTR_INTERFACE_COMBINATIONS attribute. Basically,
+ * it exports a list of "groups", and at any point in time the
+ * interfaces that are currently active must fall into any one of
+ * the advertised groups. Within each group, there are restrictions
+ * on the number of interfaces of different types that are supported
+ * and also the number of different channels, along with potentially
+ * some other restrictions. See &enum nl80211_if_combination_attrs.
+ *
+ * All together, these attributes define the concurrency of virtual
+ * interfaces that a given device supports.
+ */
+
+/**
+ * enum nl80211_commands - supported nl80211 commands
+ *
+ * @NL80211_CMD_UNSPEC: unspecified command to catch errors
+ *
+ * @NL80211_CMD_GET_WIPHY: request information about a wiphy or dump request
+ * to get a list of all present wiphys.
+ * @NL80211_CMD_SET_WIPHY: set wiphy parameters, needs %NL80211_ATTR_WIPHY or
+ * %NL80211_ATTR_IFINDEX; can be used to set %NL80211_ATTR_WIPHY_NAME,
+ * %NL80211_ATTR_WIPHY_TXQ_PARAMS, %NL80211_ATTR_WIPHY_FREQ,
+ * %NL80211_ATTR_WIPHY_CHANNEL_TYPE, %NL80211_ATTR_WIPHY_RETRY_SHORT,
+ * %NL80211_ATTR_WIPHY_RETRY_LONG, %NL80211_ATTR_WIPHY_FRAG_THRESHOLD,
+ * and/or %NL80211_ATTR_WIPHY_RTS_THRESHOLD.
+ * However, for setting the channel, see %NL80211_CMD_SET_CHANNEL
+ * instead, the support here is for backward compatibility only.
+ * @NL80211_CMD_NEW_WIPHY: Newly created wiphy, response to get request
+ * or rename notification. Has attributes %NL80211_ATTR_WIPHY and
+ * %NL80211_ATTR_WIPHY_NAME.
+ * @NL80211_CMD_DEL_WIPHY: Wiphy deleted. Has attributes
+ * %NL80211_ATTR_WIPHY and %NL80211_ATTR_WIPHY_NAME.
+ *
+ * @NL80211_CMD_GET_INTERFACE: Request an interface's configuration;
+ * either a dump request on a %NL80211_ATTR_WIPHY or a specific get
+ * on an %NL80211_ATTR_IFINDEX is supported.
+ * @NL80211_CMD_SET_INTERFACE: Set type of a virtual interface, requires
+ * %NL80211_ATTR_IFINDEX and %NL80211_ATTR_IFTYPE.
+ * @NL80211_CMD_NEW_INTERFACE: Newly created virtual interface or response
+ * to %NL80211_CMD_GET_INTERFACE. Has %NL80211_ATTR_IFINDEX,
+ * %NL80211_ATTR_WIPHY and %NL80211_ATTR_IFTYPE attributes. Can also
+ * be sent from userspace to request creation of a new virtual interface,
+ * then requires attributes %NL80211_ATTR_WIPHY, %NL80211_ATTR_IFTYPE and
+ * %NL80211_ATTR_IFNAME.
+ * @NL80211_CMD_DEL_INTERFACE: Virtual interface was deleted, has attributes
+ * %NL80211_ATTR_IFINDEX and %NL80211_ATTR_WIPHY. Can also be sent from
+ * userspace to request deletion of a virtual interface, then requires
+ * attribute %NL80211_ATTR_IFINDEX.
+ *
+ * @NL80211_CMD_GET_KEY: Get sequence counter information for a key specified
+ * by %NL80211_ATTR_KEY_IDX and/or %NL80211_ATTR_MAC.
+ * @NL80211_CMD_SET_KEY: Set key attributes %NL80211_ATTR_KEY_DEFAULT,
+ * %NL80211_ATTR_KEY_DEFAULT_MGMT, or %NL80211_ATTR_KEY_THRESHOLD.
+ * @NL80211_CMD_NEW_KEY: add a key with given %NL80211_ATTR_KEY_DATA,
+ * %NL80211_ATTR_KEY_IDX, %NL80211_ATTR_MAC, %NL80211_ATTR_KEY_CIPHER,
+ * and %NL80211_ATTR_KEY_SEQ attributes.
+ * @NL80211_CMD_DEL_KEY: delete a key identified by %NL80211_ATTR_KEY_IDX
+ * or %NL80211_ATTR_MAC.
+ *
+ * @NL80211_CMD_GET_BEACON: retrieve beacon information (returned in a
+ * %NL80222_CMD_NEW_BEACON message)
+ * @NL80211_CMD_SET_BEACON: set the beacon on an access point interface
+ * using the %NL80211_ATTR_BEACON_INTERVAL, %NL80211_ATTR_DTIM_PERIOD,
+ * %NL80211_ATTR_BEACON_HEAD and %NL80211_ATTR_BEACON_TAIL attributes.
+ * Following attributes are provided for drivers that generate full Beacon
+ * and Probe Response frames internally: %NL80211_ATTR_SSID,
+ * %NL80211_ATTR_HIDDEN_SSID, %NL80211_ATTR_CIPHERS_PAIRWISE,
+ * %NL80211_ATTR_CIPHER_GROUP, %NL80211_ATTR_WPA_VERSIONS,
+ * %NL80211_ATTR_AKM_SUITES, %NL80211_ATTR_PRIVACY,
+ * %NL80211_ATTR_AUTH_TYPE, %NL80211_ATTR_IE, %NL80211_ATTR_IE_PROBE_RESP,
+ * %NL80211_ATTR_IE_ASSOC_RESP.
+ * @NL80211_CMD_NEW_BEACON: add a new beacon to an access point interface,
+ * parameters are like for %NL80211_CMD_SET_BEACON.
+ * @NL80211_CMD_DEL_BEACON: remove the beacon, stop sending it
+ *
+ * @NL80211_CMD_GET_STATION: Get station attributes for station identified by
+ * %NL80211_ATTR_MAC on the interface identified by %NL80211_ATTR_IFINDEX.
+ * @NL80211_CMD_SET_STATION: Set station attributes for station identified by
+ * %NL80211_ATTR_MAC on the interface identified by %NL80211_ATTR_IFINDEX.
+ * @NL80211_CMD_NEW_STATION: Add a station with given attributes to the
+ * the interface identified by %NL80211_ATTR_IFINDEX.
+ * @NL80211_CMD_DEL_STATION: Remove a station identified by %NL80211_ATTR_MAC
+ * or, if no MAC address given, all stations, on the interface identified
+ * by %NL80211_ATTR_IFINDEX.
+ *
+ * @NL80211_CMD_GET_MPATH: Get mesh path attributes for mesh path to
+ * destination %NL80211_ATTR_MAC on the interface identified by
+ * %NL80211_ATTR_IFINDEX.
+ * @NL80211_CMD_SET_MPATH: Set mesh path attributes for mesh path to
+ * destination %NL80211_ATTR_MAC on the interface identified by
+ * %NL80211_ATTR_IFINDEX.
+ * @NL80211_CMD_NEW_MPATH: Create a new mesh path for the destination given by
+ * %NL80211_ATTR_MAC via %NL80211_ATTR_MPATH_NEXT_HOP.
+ * @NL80211_CMD_DEL_MPATH: Delete a mesh path to the destination given by
+ * %NL80211_ATTR_MAC.
+ * @NL80211_CMD_NEW_PATH: Add a mesh path with given attributes to the
+ * the interface identified by %NL80211_ATTR_IFINDEX.
+ * @NL80211_CMD_DEL_PATH: Remove a mesh path identified by %NL80211_ATTR_MAC
+ * or, if no MAC address given, all mesh paths, on the interface identified
+ * by %NL80211_ATTR_IFINDEX.
+ * @NL80211_CMD_SET_BSS: Set BSS attributes for BSS identified by
+ * %NL80211_ATTR_IFINDEX.
+ *
+ * @NL80211_CMD_GET_REG: ask the wireless core to send us its currently set
+ * regulatory domain.
+ * @NL80211_CMD_SET_REG: Set current regulatory domain. CRDA sends this command
+ * after being queried by the kernel. CRDA replies by sending a regulatory
+ * domain structure which consists of %NL80211_ATTR_REG_ALPHA set to our
+ * current alpha2 if it found a match. It also provides
+ * NL80211_ATTR_REG_RULE_FLAGS, and a set of regulatory rules. Each
+ * regulatory rule is a nested set of attributes given by
+ * %NL80211_ATTR_REG_RULE_FREQ_[START|END] and
+ * %NL80211_ATTR_FREQ_RANGE_MAX_BW with an attached power rule given by
+ * %NL80211_ATTR_REG_RULE_POWER_MAX_ANT_GAIN and
+ * %NL80211_ATTR_REG_RULE_POWER_MAX_EIRP.
+ * @NL80211_CMD_REQ_SET_REG: ask the wireless core to set the regulatory domain
+ * to the specified ISO/IEC 3166-1 alpha2 country code. The core will
+ * store this as a valid request and then query userspace for it.
+ *
+ * @NL80211_CMD_GET_MESH_CONFIG: Get mesh networking properties for the
+ * interface identified by %NL80211_ATTR_IFINDEX
+ *
+ * @NL80211_CMD_SET_MESH_CONFIG: Set mesh networking properties for the
+ * interface identified by %NL80211_ATTR_IFINDEX
+ *
+ * @NL80211_CMD_SET_MGMT_EXTRA_IE: Set extra IEs for management frames. The
+ * interface is identified with %NL80211_ATTR_IFINDEX and the management
+ * frame subtype with %NL80211_ATTR_MGMT_SUBTYPE. The extra IE data to be
+ * added to the end of the specified management frame is specified with
+ * %NL80211_ATTR_IE. If the command succeeds, the requested data will be
+ * added to all specified management frames generated by
+ * kernel/firmware/driver.
+ * Note: This command has been removed and it is only reserved at this
+ * point to avoid re-using existing command number. The functionality this
+ * command was planned for has been provided with cleaner design with the
+ * option to specify additional IEs in NL80211_CMD_TRIGGER_SCAN,
+ * NL80211_CMD_AUTHENTICATE, NL80211_CMD_ASSOCIATE,
+ * NL80211_CMD_DEAUTHENTICATE, and NL80211_CMD_DISASSOCIATE.
+ *
+ * @NL80211_CMD_GET_SCAN: get scan results
+ * @NL80211_CMD_TRIGGER_SCAN: trigger a new scan with the given parameters
+ * %NL80211_ATTR_TX_NO_CCK_RATE is used to decide whether to send the
+ * probe requests at CCK rate or not.
+ * @NL80211_CMD_NEW_SCAN_RESULTS: scan notification (as a reply to
+ * NL80211_CMD_GET_SCAN and on the "scan" multicast group)
+ * @NL80211_CMD_SCAN_ABORTED: scan was aborted, for unspecified reasons,
+ * partial scan results may be available
+ *
+ * @NL80211_CMD_START_SCHED_SCAN: start a scheduled scan at certain
+ * intervals, as specified by %NL80211_ATTR_SCHED_SCAN_INTERVAL.
+ * Like with normal scans, if SSIDs (%NL80211_ATTR_SCAN_SSIDS)
+ * are passed, they are used in the probe requests. For
+ * broadcast, a broadcast SSID must be passed (ie. an empty
+ * string). If no SSID is passed, no probe requests are sent and
+ * a passive scan is performed. %NL80211_ATTR_SCAN_FREQUENCIES,
+ * if passed, define which channels should be scanned; if not
+ * passed, all channels allowed for the current regulatory domain
+ * are used. Extra IEs can also be passed from the userspace by
+ * using the %NL80211_ATTR_IE attribute.
+ * @NL80211_CMD_STOP_SCHED_SCAN: stop a scheduled scan. Returns -ENOENT
+ * if scheduled scan is not running.
+ * @NL80211_CMD_SCHED_SCAN_RESULTS: indicates that there are scheduled scan
+ * results available.
+ * @NL80211_CMD_SCHED_SCAN_STOPPED: indicates that the scheduled scan has
+ * stopped. The driver may issue this event at any time during a
+ * scheduled scan. One reason for stopping the scan is if the hardware
+ * does not support starting an association or a normal scan while running
+ * a scheduled scan. This event is also sent when the
+ * %NL80211_CMD_STOP_SCHED_SCAN command is received or when the interface
+ * is brought down while a scheduled scan was running.
+ *
+ * @NL80211_CMD_GET_SURVEY: get survey resuls, e.g. channel occupation
+ * or noise level
+ * @NL80211_CMD_NEW_SURVEY_RESULTS: survey data notification (as a reply to
+ * NL80211_CMD_GET_SURVEY and on the "scan" multicast group)
+ *
+ * @NL80211_CMD_REG_CHANGE: indicates to userspace the regulatory domain
+ * has been changed and provides details of the request information
+ * that caused the change such as who initiated the regulatory request
+ * (%NL80211_ATTR_REG_INITIATOR), the wiphy_idx
+ * (%NL80211_ATTR_REG_ALPHA2) on which the request was made from if
+ * the initiator was %NL80211_REGDOM_SET_BY_COUNTRY_IE or
+ * %NL80211_REGDOM_SET_BY_DRIVER, the type of regulatory domain
+ * set (%NL80211_ATTR_REG_TYPE), if the type of regulatory domain is
+ * %NL80211_REG_TYPE_COUNTRY the alpha2 to which we have moved on
+ * to (%NL80211_ATTR_REG_ALPHA2).
+ * @NL80211_CMD_REG_BEACON_HINT: indicates to userspace that an AP beacon
+ * has been found while world roaming thus enabling active scan or
+ * any mode of operation that initiates TX (beacons) on a channel
+ * where we would not have been able to do either before. As an example
+ * if you are world roaming (regulatory domain set to world or if your
+ * driver is using a custom world roaming regulatory domain) and while
+ * doing a passive scan on the 5 GHz band you find an AP there (if not
+ * on a DFS channel) you will now be able to actively scan for that AP
+ * or use AP mode on your card on that same channel. Note that this will
+ * never be used for channels 1-11 on the 2 GHz band as they are always
+ * enabled world wide. This beacon hint is only sent if your device had
+ * either disabled active scanning or beaconing on a channel. We send to
+ * userspace the wiphy on which we removed a restriction from
+ * (%NL80211_ATTR_WIPHY) and the channel on which this occurred
+ * before (%NL80211_ATTR_FREQ_BEFORE) and after (%NL80211_ATTR_FREQ_AFTER)
+ * the beacon hint was processed.
+ *
+ * @NL80211_CMD_AUTHENTICATE: authentication request and notification.
+ * This command is used both as a command (request to authenticate) and
+ * as an event on the "mlme" multicast group indicating completion of the
+ * authentication process.
+ * When used as a command, %NL80211_ATTR_IFINDEX is used to identify the
+ * interface. %NL80211_ATTR_MAC is used to specify PeerSTAAddress (and
+ * BSSID in case of station mode). %NL80211_ATTR_SSID is used to specify
+ * the SSID (mainly for association, but is included in authentication
+ * request, too, to help BSS selection. %NL80211_ATTR_WIPHY_FREQ is used
+ * to specify the frequence of the channel in MHz. %NL80211_ATTR_AUTH_TYPE
+ * is used to specify the authentication type. %NL80211_ATTR_IE is used to
+ * define IEs (VendorSpecificInfo, but also including RSN IE and FT IEs)
+ * to be added to the frame.
+ * When used as an event, this reports reception of an Authentication
+ * frame in station and IBSS modes when the local MLME processed the
+ * frame, i.e., it was for the local STA and was received in correct
+ * state. This is similar to MLME-AUTHENTICATE.confirm primitive in the
+ * MLME SAP interface (kernel providing MLME, userspace SME). The
+ * included %NL80211_ATTR_FRAME attribute contains the management frame
+ * (including both the header and frame body, but not FCS). This event is
+ * also used to indicate if the authentication attempt timed out. In that
+ * case the %NL80211_ATTR_FRAME attribute is replaced with a
+ * %NL80211_ATTR_TIMED_OUT flag (and %NL80211_ATTR_MAC to indicate which
+ * pending authentication timed out).
+ * @NL80211_CMD_ASSOCIATE: association request and notification; like
+ * NL80211_CMD_AUTHENTICATE but for Association and Reassociation
+ * (similar to MLME-ASSOCIATE.request, MLME-REASSOCIATE.request,
+ * MLME-ASSOCIATE.confirm or MLME-REASSOCIATE.confirm primitives).
+ * @NL80211_CMD_DEAUTHENTICATE: deauthentication request and notification; like
+ * NL80211_CMD_AUTHENTICATE but for Deauthentication frames (similar to
+ * MLME-DEAUTHENTICATION.request and MLME-DEAUTHENTICATE.indication
+ * primitives).
+ * @NL80211_CMD_DISASSOCIATE: disassociation request and notification; like
+ * NL80211_CMD_AUTHENTICATE but for Disassociation frames (similar to
+ * MLME-DISASSOCIATE.request and MLME-DISASSOCIATE.indication primitives).
+ *
+ * @NL80211_CMD_MICHAEL_MIC_FAILURE: notification of a locally detected Michael
+ * MIC (part of TKIP) failure; sent on the "mlme" multicast group; the
+ * event includes %NL80211_ATTR_MAC to describe the source MAC address of
+ * the frame with invalid MIC, %NL80211_ATTR_KEY_TYPE to show the key
+ * type, %NL80211_ATTR_KEY_IDX to indicate the key identifier, and
+ * %NL80211_ATTR_KEY_SEQ to indicate the TSC value of the frame; this
+ * event matches with MLME-MICHAELMICFAILURE.indication() primitive
+ *
+ * @NL80211_CMD_JOIN_IBSS: Join a new IBSS -- given at least an SSID and a
+ * FREQ attribute (for the initial frequency if no peer can be found)
+ * and optionally a MAC (as BSSID) and FREQ_FIXED attribute if those
+ * should be fixed rather than automatically determined. Can only be
+ * executed on a network interface that is UP, and fixed BSSID/FREQ
+ * may be rejected. Another optional parameter is the beacon interval,
+ * given in the %NL80211_ATTR_BEACON_INTERVAL attribute, which if not
+ * given defaults to 100 TU (102.4ms).
+ * @NL80211_CMD_LEAVE_IBSS: Leave the IBSS -- no special arguments, the IBSS is
+ * determined by the network interface.
+ *
+ * @NL80211_CMD_TESTMODE: testmode command, takes a wiphy (or ifindex) attribute
+ * to identify the device, and the TESTDATA blob attribute to pass through
+ * to the driver.
+ *
+ * @NL80211_CMD_CONNECT: connection request and notification; this command
+ * requests to connect to a specified network but without separating
+ * auth and assoc steps. For this, you need to specify the SSID in a
+ * %NL80211_ATTR_SSID attribute, and can optionally specify the association
+ * IEs in %NL80211_ATTR_IE, %NL80211_ATTR_AUTH_TYPE, %NL80211_ATTR_MAC,
+ * %NL80211_ATTR_WIPHY_FREQ, %NL80211_ATTR_CONTROL_PORT,
+ * %NL80211_ATTR_CONTROL_PORT_ETHERTYPE and
+ * %NL80211_ATTR_CONTROL_PORT_NO_ENCRYPT.
+ * It is also sent as an event, with the BSSID and response IEs when the
+ * connection is established or failed to be established. This can be
+ * determined by the STATUS_CODE attribute.
+ * @NL80211_CMD_ROAM: request that the card roam (currently not implemented),
+ * sent as an event when the card/driver roamed by itself.
+ * @NL80211_CMD_DISCONNECT: drop a given connection; also used to notify
+ * userspace that a connection was dropped by the AP or due to other
+ * reasons, for this the %NL80211_ATTR_DISCONNECTED_BY_AP and
+ * %NL80211_ATTR_REASON_CODE attributes are used.
+ *
+ * @NL80211_CMD_SET_WIPHY_NETNS: Set a wiphy's netns. Note that all devices
+ * associated with this wiphy must be down and will follow.
+ *
+ * @NL80211_CMD_REMAIN_ON_CHANNEL: Request to remain awake on the specified
+ * channel for the specified amount of time. This can be used to do
+ * off-channel operations like transmit a Public Action frame and wait for
+ * a response while being associated to an AP on another channel.
+ * %NL80211_ATTR_IFINDEX is used to specify which interface (and thus
+ * radio) is used. %NL80211_ATTR_WIPHY_FREQ is used to specify the
+ * frequency for the operation and %NL80211_ATTR_WIPHY_CHANNEL_TYPE may be
+ * optionally used to specify additional channel parameters.
+ * %NL80211_ATTR_DURATION is used to specify the duration in milliseconds
+ * to remain on the channel. This command is also used as an event to
+ * notify when the requested duration starts (it may take a while for the
+ * driver to schedule this time due to other concurrent needs for the
+ * radio).
+ * When called, this operation returns a cookie (%NL80211_ATTR_COOKIE)
+ * that will be included with any events pertaining to this request;
+ * the cookie is also used to cancel the request.
+ * @NL80211_CMD_CANCEL_REMAIN_ON_CHANNEL: This command can be used to cancel a
+ * pending remain-on-channel duration if the desired operation has been
+ * completed prior to expiration of the originally requested duration.
+ * %NL80211_ATTR_WIPHY or %NL80211_ATTR_IFINDEX is used to specify the
+ * radio. The %NL80211_ATTR_COOKIE attribute must be given as well to
+ * uniquely identify the request.
+ * This command is also used as an event to notify when a requested
+ * remain-on-channel duration has expired.
+ *
+ * @NL80211_CMD_SET_TX_BITRATE_MASK: Set the mask of rates to be used in TX
+ * rate selection. %NL80211_ATTR_IFINDEX is used to specify the interface
+ * and @NL80211_ATTR_TX_RATES the set of allowed rates.
+ *
+ * @NL80211_CMD_REGISTER_FRAME: Register for receiving certain mgmt frames
+ * (via @NL80211_CMD_FRAME) for processing in userspace. This command
+ * requires an interface index, a frame type attribute (optional for
+ * backward compatibility reasons, if not given assumes action frames)
+ * and a match attribute containing the first few bytes of the frame
+ * that should match, e.g. a single byte for only a category match or
+ * four bytes for vendor frames including the OUI. The registration
+ * cannot be dropped, but is removed automatically when the netlink
+ * socket is closed. Multiple registrations can be made.
+ * @NL80211_CMD_REGISTER_ACTION: Alias for @NL80211_CMD_REGISTER_FRAME for
+ * backward compatibility
+ * @NL80211_CMD_FRAME: Management frame TX request and RX notification. This
+ * command is used both as a request to transmit a management frame and
+ * as an event indicating reception of a frame that was not processed in
+ * kernel code, but is for us (i.e., which may need to be processed in a
+ * user space application). %NL80211_ATTR_FRAME is used to specify the
+ * frame contents (including header). %NL80211_ATTR_WIPHY_FREQ (and
+ * optionally %NL80211_ATTR_WIPHY_CHANNEL_TYPE) is used to indicate on
+ * which channel the frame is to be transmitted or was received. If this
+ * channel is not the current channel (remain-on-channel or the
+ * operational channel) the device will switch to the given channel and
+ * transmit the frame, optionally waiting for a response for the time
+ * specified using %NL80211_ATTR_DURATION. When called, this operation
+ * returns a cookie (%NL80211_ATTR_COOKIE) that will be included with the
+ * TX status event pertaining to the TX request.
+ * %NL80211_ATTR_TX_NO_CCK_RATE is used to decide whether to send the
+ * management frames at CCK rate or not in 2GHz band.
+ * @NL80211_CMD_FRAME_WAIT_CANCEL: When an off-channel TX was requested, this
+ * command may be used with the corresponding cookie to cancel the wait
+ * time if it is known that it is no longer necessary.
+ * @NL80211_CMD_ACTION: Alias for @NL80211_CMD_FRAME for backward compatibility.
+ * @NL80211_CMD_FRAME_TX_STATUS: Report TX status of a management frame
+ * transmitted with %NL80211_CMD_FRAME. %NL80211_ATTR_COOKIE identifies
+ * the TX command and %NL80211_ATTR_FRAME includes the contents of the
+ * frame. %NL80211_ATTR_ACK flag is included if the recipient acknowledged
+ * the frame.
+ * @NL80211_CMD_ACTION_TX_STATUS: Alias for @NL80211_CMD_FRAME_TX_STATUS for
+ * backward compatibility.
+ * @NL80211_CMD_SET_CQM: Connection quality monitor configuration. This command
+ * is used to configure connection quality monitoring notification trigger
+ * levels.
+ * @NL80211_CMD_NOTIFY_CQM: Connection quality monitor notification. This
+ * command is used as an event to indicate the that a trigger level was
+ * reached.
+ * @NL80211_CMD_SET_CHANNEL: Set the channel (using %NL80211_ATTR_WIPHY_FREQ
+ * and %NL80211_ATTR_WIPHY_CHANNEL_TYPE) the given interface (identifed
+ * by %NL80211_ATTR_IFINDEX) shall operate on.
+ * In case multiple channels are supported by the device, the mechanism
+ * with which it switches channels is implementation-defined.
+ * When a monitor interface is given, it can only switch channel while
+ * no other interfaces are operating to avoid disturbing the operation
+ * of any other interfaces, and other interfaces will again take
+ * precedence when they are used.
+ *
+ * @NL80211_CMD_SET_WDS_PEER: Set the MAC address of the peer on a WDS interface.
+ *
+ * @NL80211_CMD_JOIN_MESH: Join a mesh. The mesh ID must be given, and initial
+ * mesh config parameters may be given.
+ * @NL80211_CMD_LEAVE_MESH: Leave the mesh network -- no special arguments, the
+ * network is determined by the network interface.
+ *
+ * @NL80211_CMD_UNPROT_DEAUTHENTICATE: Unprotected deauthentication frame
+ * notification. This event is used to indicate that an unprotected
+ * deauthentication frame was dropped when MFP is in use.
+ * @NL80211_CMD_UNPROT_DISASSOCIATE: Unprotected disassociation frame
+ * notification. This event is used to indicate that an unprotected
+ * disassociation frame was dropped when MFP is in use.
+ *
+ * @NL80211_CMD_NEW_PEER_CANDIDATE: Notification on the reception of a
+ * beacon or probe response from a compatible mesh peer. This is only
+ * sent while no station information (sta_info) exists for the new peer
+ * candidate and when @NL80211_MESH_SETUP_USERSPACE_AUTH is set. On
+ * reception of this notification, userspace may decide to create a new
+ * station (@NL80211_CMD_NEW_STATION). To stop this notification from
+ * reoccurring, the userspace authentication daemon may want to create the
+ * new station with the AUTHENTICATED flag unset and maybe change it later
+ * depending on the authentication result.
+ *
+ * @NL80211_CMD_GET_WOWLAN: get Wake-on-Wireless-LAN (WoWLAN) settings.
+ * @NL80211_CMD_SET_WOWLAN: set Wake-on-Wireless-LAN (WoWLAN) settings.
+ * Since wireless is more complex than wired ethernet, it supports
+ * various triggers. These triggers can be configured through this
+ * command with the %NL80211_ATTR_WOWLAN_TRIGGERS attribute. For
+ * more background information, see
+ * http://wireless.kernel.org/en/users/Documentation/WoWLAN.
+ *
+ * @NL80211_CMD_SET_REKEY_OFFLOAD: This command is used give the driver
+ * the necessary information for supporting GTK rekey offload. This
+ * feature is typically used during WoWLAN. The configuration data
+ * is contained in %NL80211_ATTR_REKEY_DATA (which is nested and
+ * contains the data in sub-attributes). After rekeying happened,
+ * this command may also be sent by the driver as an MLME event to
+ * inform userspace of the new replay counter.
+ *
+ * @NL80211_CMD_PMKSA_CANDIDATE: This is used as an event to inform userspace
+ * of PMKSA caching dandidates.
+ *
+ * @NL80211_CMD_TDLS_OPER: Perform a high-level TDLS command (e.g. link setup).
+ * @NL80211_CMD_TDLS_MGMT: Send a TDLS management frame.
+ *
+ * @NL80211_CMD_UNEXPECTED_FRAME: Used by an application controlling an AP
+ * (or GO) interface (i.e. hostapd) to ask for unexpected frames to
+ * implement sending deauth to stations that send unexpected class 3
+ * frames. Also used as the event sent by the kernel when such a frame
+ * is received.
+ * For the event, the %NL80211_ATTR_MAC attribute carries the TA and
+ * other attributes like the interface index are present.
+ * If used as the command it must have an interface index and you can
+ * only unsubscribe from the event by closing the socket. Subscription
+ * is also for %NL80211_CMD_UNEXPECTED_4ADDR_FRAME events.
+ *
+ * @NL80211_CMD_UNEXPECTED_4ADDR_FRAME: Sent as an event indicating that the
+ * associated station identified by %NL80211_ATTR_MAC sent a 4addr frame
+ * and wasn't already in a 4-addr VLAN. The event will be sent similarly
+ * to the %NL80211_CMD_UNEXPECTED_FRAME event, to the same listener.
+ *
+ * @NL80211_CMD_PROBE_CLIENT: Probe an associated station on an AP interface
+ * by sending a null data frame to it and reporting when the frame is
+ * acknowleged. This is used to allow timing out inactive clients. Uses
+ * %NL80211_ATTR_IFINDEX and %NL80211_ATTR_MAC. The command returns a
+ * direct reply with an %NL80211_ATTR_COOKIE that is later used to match
+ * up the event with the request. The event includes the same data and
+ * has %NL80211_ATTR_ACK set if the frame was ACKed.
+ *
+ * @NL80211_CMD_REGISTER_BEACONS: Register this socket to receive beacons from
+ * other BSSes when any interfaces are in AP mode. This helps implement
+ * OLBC handling in hostapd. Beacons are reported in %NL80211_CMD_FRAME
+ * messages. Note that per PHY only one application may register.
+ *
+ * @NL80211_CMD_SET_NOACK_MAP: sets a bitmap for the individual TIDs whether
+ * No Acknowledgement Policy should be applied.
+ *
+ * @NL80211_CMD_MAX: highest used command number
+ * @__NL80211_CMD_AFTER_LAST: internal use
+ */
+enum nl80211_commands {
+/* don't change the order or add anything between, this is ABI! */
+ NL80211_CMD_UNSPEC,
+
+ NL80211_CMD_GET_WIPHY, /* can dump */
+ NL80211_CMD_SET_WIPHY,
+ NL80211_CMD_NEW_WIPHY,
+ NL80211_CMD_DEL_WIPHY,
+
+ NL80211_CMD_GET_INTERFACE, /* can dump */
+ NL80211_CMD_SET_INTERFACE,
+ NL80211_CMD_NEW_INTERFACE,
+ NL80211_CMD_DEL_INTERFACE,
+
+ NL80211_CMD_GET_KEY,
+ NL80211_CMD_SET_KEY,
+ NL80211_CMD_NEW_KEY,
+ NL80211_CMD_DEL_KEY,
+
+ NL80211_CMD_GET_BEACON,
+ NL80211_CMD_SET_BEACON,
+ NL80211_CMD_NEW_BEACON,
+ NL80211_CMD_DEL_BEACON,
+
+ NL80211_CMD_GET_STATION,
+ NL80211_CMD_SET_STATION,
+ NL80211_CMD_NEW_STATION,
+ NL80211_CMD_DEL_STATION,
+
+ NL80211_CMD_GET_MPATH,
+ NL80211_CMD_SET_MPATH,
+ NL80211_CMD_NEW_MPATH,
+ NL80211_CMD_DEL_MPATH,
+
+ NL80211_CMD_SET_BSS,
+
+ NL80211_CMD_SET_REG,
+ NL80211_CMD_REQ_SET_REG,
+
+ NL80211_CMD_GET_MESH_CONFIG,
+ NL80211_CMD_SET_MESH_CONFIG,
+
+ NL80211_CMD_SET_MGMT_EXTRA_IE /* reserved; not used */,
+
+ NL80211_CMD_GET_REG,
+
+ NL80211_CMD_GET_SCAN,
+ NL80211_CMD_TRIGGER_SCAN,
+ NL80211_CMD_NEW_SCAN_RESULTS,
+ NL80211_CMD_SCAN_ABORTED,
+
+ NL80211_CMD_REG_CHANGE,
+
+ NL80211_CMD_AUTHENTICATE,
+ NL80211_CMD_ASSOCIATE,
+ NL80211_CMD_DEAUTHENTICATE,
+ NL80211_CMD_DISASSOCIATE,
+
+ NL80211_CMD_MICHAEL_MIC_FAILURE,
+
+ NL80211_CMD_REG_BEACON_HINT,
+
+ NL80211_CMD_JOIN_IBSS,
+ NL80211_CMD_LEAVE_IBSS,
+
+ NL80211_CMD_TESTMODE,
+
+ NL80211_CMD_CONNECT,
+ NL80211_CMD_ROAM,
+ NL80211_CMD_DISCONNECT,
+
+ NL80211_CMD_SET_WIPHY_NETNS,
+
+ NL80211_CMD_GET_SURVEY,
+ NL80211_CMD_NEW_SURVEY_RESULTS,
+
+ NL80211_CMD_SET_PMKSA,
+ NL80211_CMD_DEL_PMKSA,
+ NL80211_CMD_FLUSH_PMKSA,
+
+ NL80211_CMD_REMAIN_ON_CHANNEL,
+ NL80211_CMD_CANCEL_REMAIN_ON_CHANNEL,
+
+ NL80211_CMD_SET_TX_BITRATE_MASK,
+
+ NL80211_CMD_REGISTER_FRAME,
+ NL80211_CMD_REGISTER_ACTION = NL80211_CMD_REGISTER_FRAME,
+ NL80211_CMD_FRAME,
+ NL80211_CMD_ACTION = NL80211_CMD_FRAME,
+ NL80211_CMD_FRAME_TX_STATUS,
+ NL80211_CMD_ACTION_TX_STATUS = NL80211_CMD_FRAME_TX_STATUS,
+
+ NL80211_CMD_SET_POWER_SAVE,
+ NL80211_CMD_GET_POWER_SAVE,
+
+ NL80211_CMD_SET_CQM,
+ NL80211_CMD_NOTIFY_CQM,
+
+ NL80211_CMD_SET_CHANNEL,
+ NL80211_CMD_SET_WDS_PEER,
+
+ NL80211_CMD_FRAME_WAIT_CANCEL,
+
+ NL80211_CMD_JOIN_MESH,
+ NL80211_CMD_LEAVE_MESH,
+
+ NL80211_CMD_UNPROT_DEAUTHENTICATE,
+ NL80211_CMD_UNPROT_DISASSOCIATE,
+
+ NL80211_CMD_NEW_PEER_CANDIDATE,
+
+ NL80211_CMD_GET_WOWLAN,
+ NL80211_CMD_SET_WOWLAN,
+
+ NL80211_CMD_START_SCHED_SCAN,
+ NL80211_CMD_STOP_SCHED_SCAN,
+ NL80211_CMD_SCHED_SCAN_RESULTS,
+ NL80211_CMD_SCHED_SCAN_STOPPED,
+
+ NL80211_CMD_SET_REKEY_OFFLOAD,
+
+ NL80211_CMD_PMKSA_CANDIDATE,
+
+ NL80211_CMD_TDLS_OPER,
+ NL80211_CMD_TDLS_MGMT,
+
+ NL80211_CMD_UNEXPECTED_FRAME,
+
+ NL80211_CMD_PROBE_CLIENT,
+
+ NL80211_CMD_REGISTER_BEACONS,
+
+ NL80211_CMD_UNEXPECTED_4ADDR_FRAME,
+
+ NL80211_CMD_SET_NOACK_MAP,
+
+ /* add new commands above here */
+
+ /* used to define NL80211_CMD_MAX below */
+ __NL80211_CMD_AFTER_LAST,
+ NL80211_CMD_MAX = __NL80211_CMD_AFTER_LAST - 1
+};
+
+/*
+ * Allow user space programs to use #ifdef on new commands by defining them
+ * here
+ */
+#define NL80211_CMD_SET_BSS NL80211_CMD_SET_BSS
+#define NL80211_CMD_SET_MGMT_EXTRA_IE NL80211_CMD_SET_MGMT_EXTRA_IE
+#define NL80211_CMD_REG_CHANGE NL80211_CMD_REG_CHANGE
+#define NL80211_CMD_AUTHENTICATE NL80211_CMD_AUTHENTICATE
+#define NL80211_CMD_ASSOCIATE NL80211_CMD_ASSOCIATE
+#define NL80211_CMD_DEAUTHENTICATE NL80211_CMD_DEAUTHENTICATE
+#define NL80211_CMD_DISASSOCIATE NL80211_CMD_DISASSOCIATE
+#define NL80211_CMD_REG_BEACON_HINT NL80211_CMD_REG_BEACON_HINT
+
+#define NL80211_ATTR_FEATURE_FLAGS NL80211_ATTR_FEATURE_FLAGS
+
+/* source-level API compatibility */
+#define NL80211_CMD_GET_MESH_PARAMS NL80211_CMD_GET_MESH_CONFIG
+#define NL80211_CMD_SET_MESH_PARAMS NL80211_CMD_SET_MESH_CONFIG
+#define NL80211_MESH_SETUP_VENDOR_PATH_SEL_IE NL80211_MESH_SETUP_IE
+
+/**
+ * enum nl80211_attrs - nl80211 netlink attributes
+ *
+ * @NL80211_ATTR_UNSPEC: unspecified attribute to catch errors
+ *
+ * @NL80211_ATTR_WIPHY: index of wiphy to operate on, cf.
+ * /sys/class/ieee80211/<phyname>/index
+ * @NL80211_ATTR_WIPHY_NAME: wiphy name (used for renaming)
+ * @NL80211_ATTR_WIPHY_TXQ_PARAMS: a nested array of TX queue parameters
+ * @NL80211_ATTR_WIPHY_FREQ: frequency of the selected channel in MHz
+ * @NL80211_ATTR_WIPHY_CHANNEL_TYPE: included with NL80211_ATTR_WIPHY_FREQ
+ * if HT20 or HT40 are allowed (i.e., 802.11n disabled if not included):
+ * NL80211_CHAN_NO_HT = HT not allowed (i.e., same as not including
+ * this attribute)
+ * NL80211_CHAN_HT20 = HT20 only
+ * NL80211_CHAN_HT40MINUS = secondary channel is below the primary channel
+ * NL80211_CHAN_HT40PLUS = secondary channel is above the primary channel
+ * @NL80211_ATTR_WIPHY_RETRY_SHORT: TX retry limit for frames whose length is
+ * less than or equal to the RTS threshold; allowed range: 1..255;
+ * dot11ShortRetryLimit; u8
+ * @NL80211_ATTR_WIPHY_RETRY_LONG: TX retry limit for frames whose length is
+ * greater than the RTS threshold; allowed range: 1..255;
+ * dot11ShortLongLimit; u8
+ * @NL80211_ATTR_WIPHY_FRAG_THRESHOLD: fragmentation threshold, i.e., maximum
+ * length in octets for frames; allowed range: 256..8000, disable
+ * fragmentation with (u32)-1; dot11FragmentationThreshold; u32
+ * @NL80211_ATTR_WIPHY_RTS_THRESHOLD: RTS threshold (TX frames with length
+ * larger than or equal to this use RTS/CTS handshake); allowed range:
+ * 0..65536, disable with (u32)-1; dot11RTSThreshold; u32
+ * @NL80211_ATTR_WIPHY_COVERAGE_CLASS: Coverage Class as defined by IEEE 802.11
+ * section 7.3.2.9; dot11CoverageClass; u8
+ *
+ * @NL80211_ATTR_IFINDEX: network interface index of the device to operate on
+ * @NL80211_ATTR_IFNAME: network interface name
+ * @NL80211_ATTR_IFTYPE: type of virtual interface, see &enum nl80211_iftype
+ *
+ * @NL80211_ATTR_MAC: MAC address (various uses)
+ *
+ * @NL80211_ATTR_KEY_DATA: (temporal) key data; for TKIP this consists of
+ * 16 bytes encryption key followed by 8 bytes each for TX and RX MIC
+ * keys
+ * @NL80211_ATTR_KEY_IDX: key ID (u8, 0-3)
+ * @NL80211_ATTR_KEY_CIPHER: key cipher suite (u32, as defined by IEEE 802.11
+ * section 7.3.2.25.1, e.g. 0x000FAC04)
+ * @NL80211_ATTR_KEY_SEQ: transmit key sequence number (IV/PN) for TKIP and
+ * CCMP keys, each six bytes in little endian
+ *
+ * @NL80211_ATTR_BEACON_INTERVAL: beacon interval in TU
+ * @NL80211_ATTR_DTIM_PERIOD: DTIM period for beaconing
+ * @NL80211_ATTR_BEACON_HEAD: portion of the beacon before the TIM IE
+ * @NL80211_ATTR_BEACON_TAIL: portion of the beacon after the TIM IE
+ *
+ * @NL80211_ATTR_STA_AID: Association ID for the station (u16)
+ * @NL80211_ATTR_STA_FLAGS: flags, nested element with NLA_FLAG attributes of
+ * &enum nl80211_sta_flags (deprecated, use %NL80211_ATTR_STA_FLAGS2)
+ * @NL80211_ATTR_STA_LISTEN_INTERVAL: listen interval as defined by
+ * IEEE 802.11 7.3.1.6 (u16).
+ * @NL80211_ATTR_STA_SUPPORTED_RATES: supported rates, array of supported
+ * rates as defined by IEEE 802.11 7.3.2.2 but without the length
+ * restriction (at most %NL80211_MAX_SUPP_RATES).
+ * @NL80211_ATTR_STA_VLAN: interface index of VLAN interface to move station
+ * to, or the AP interface the station was originally added to to.
+ * @NL80211_ATTR_STA_INFO: information about a station, part of station info
+ * given for %NL80211_CMD_GET_STATION, nested attribute containing
+ * info as possible, see &enum nl80211_sta_info.
+ *
+ * @NL80211_ATTR_WIPHY_BANDS: Information about an operating bands,
+ * consisting of a nested array.
+ *
+ * @NL80211_ATTR_MESH_ID: mesh id (1-32 bytes).
+ * @NL80211_ATTR_STA_PLINK_ACTION: action to perform on the mesh peer link.
+ * @NL80211_ATTR_MPATH_NEXT_HOP: MAC address of the next hop for a mesh path.
+ * @NL80211_ATTR_MPATH_INFO: information about a mesh_path, part of mesh path
+ * info given for %NL80211_CMD_GET_MPATH, nested attribute described at
+ * &enum nl80211_mpath_info.
+ *
+ * @NL80211_ATTR_MNTR_FLAGS: flags, nested element with NLA_FLAG attributes of
+ * &enum nl80211_mntr_flags.
+ *
+ * @NL80211_ATTR_REG_ALPHA2: an ISO-3166-alpha2 country code for which the
+ * current regulatory domain should be set to or is already set to.
+ * For example, 'CR', for Costa Rica. This attribute is used by the kernel
+ * to query the CRDA to retrieve one regulatory domain. This attribute can
+ * also be used by userspace to query the kernel for the currently set
+ * regulatory domain. We chose an alpha2 as that is also used by the
+ * IEEE-802.11d country information element to identify a country.
+ * Users can also simply ask the wireless core to set regulatory domain
+ * to a specific alpha2.
+ * @NL80211_ATTR_REG_RULES: a nested array of regulatory domain regulatory
+ * rules.
+ *
+ * @NL80211_ATTR_BSS_CTS_PROT: whether CTS protection is enabled (u8, 0 or 1)
+ * @NL80211_ATTR_BSS_SHORT_PREAMBLE: whether short preamble is enabled
+ * (u8, 0 or 1)
+ * @NL80211_ATTR_BSS_SHORT_SLOT_TIME: whether short slot time enabled
+ * (u8, 0 or 1)
+ * @NL80211_ATTR_BSS_BASIC_RATES: basic rates, array of basic
+ * rates in format defined by IEEE 802.11 7.3.2.2 but without the length
+ * restriction (at most %NL80211_MAX_SUPP_RATES).
+ *
+ * @NL80211_ATTR_HT_CAPABILITY: HT Capability information element (from
+ * association request when used with NL80211_CMD_NEW_STATION)
+ *
+ * @NL80211_ATTR_SUPPORTED_IFTYPES: nested attribute containing all
+ * supported interface types, each a flag attribute with the number
+ * of the interface mode.
+ *
+ * @NL80211_ATTR_MGMT_SUBTYPE: Management frame subtype for
+ * %NL80211_CMD_SET_MGMT_EXTRA_IE.
+ *
+ * @NL80211_ATTR_IE: Information element(s) data (used, e.g., with
+ * %NL80211_CMD_SET_MGMT_EXTRA_IE).
+ *
+ * @NL80211_ATTR_MAX_NUM_SCAN_SSIDS: number of SSIDs you can scan with
+ * a single scan request, a wiphy attribute.
+ * @NL80211_ATTR_MAX_NUM_SCHED_SCAN_SSIDS: number of SSIDs you can
+ * scan with a single scheduled scan request, a wiphy attribute.
+ * @NL80211_ATTR_MAX_SCAN_IE_LEN: maximum length of information elements
+ * that can be added to a scan request
+ * @NL80211_ATTR_MAX_SCHED_SCAN_IE_LEN: maximum length of information
+ * elements that can be added to a scheduled scan request
+ * @NL80211_ATTR_MAX_MATCH_SETS: maximum number of sets that can be
+ * used with @NL80211_ATTR_SCHED_SCAN_MATCH, a wiphy attribute.
+ *
+ * @NL80211_ATTR_SCAN_FREQUENCIES: nested attribute with frequencies (in MHz)
+ * @NL80211_ATTR_SCAN_SSIDS: nested attribute with SSIDs, leave out for passive
+ * scanning and include a zero-length SSID (wildcard) for wildcard scan
+ * @NL80211_ATTR_BSS: scan result BSS
+ *
+ * @NL80211_ATTR_REG_INITIATOR: indicates who requested the regulatory domain
+ * currently in effect. This could be any of the %NL80211_REGDOM_SET_BY_*
+ * @NL80211_ATTR_REG_TYPE: indicates the type of the regulatory domain currently
+ * set. This can be one of the nl80211_reg_type (%NL80211_REGDOM_TYPE_*)
+ *
+ * @NL80211_ATTR_SUPPORTED_COMMANDS: wiphy attribute that specifies
+ * an array of command numbers (i.e. a mapping index to command number)
+ * that the driver for the given wiphy supports.
+ *
+ * @NL80211_ATTR_FRAME: frame data (binary attribute), including frame header
+ * and body, but not FCS; used, e.g., with NL80211_CMD_AUTHENTICATE and
+ * NL80211_CMD_ASSOCIATE events
+ * @NL80211_ATTR_SSID: SSID (binary attribute, 0..32 octets)
+ * @NL80211_ATTR_AUTH_TYPE: AuthenticationType, see &enum nl80211_auth_type,
+ * represented as a u32
+ * @NL80211_ATTR_REASON_CODE: ReasonCode for %NL80211_CMD_DEAUTHENTICATE and
+ * %NL80211_CMD_DISASSOCIATE, u16
+ *
+ * @NL80211_ATTR_KEY_TYPE: Key Type, see &enum nl80211_key_type, represented as
+ * a u32
+ *
+ * @NL80211_ATTR_FREQ_BEFORE: A channel which has suffered a regulatory change
+ * due to considerations from a beacon hint. This attribute reflects
+ * the state of the channel _before_ the beacon hint processing. This
+ * attributes consists of a nested attribute containing
+ * NL80211_FREQUENCY_ATTR_*
+ * @NL80211_ATTR_FREQ_AFTER: A channel which has suffered a regulatory change
+ * due to considerations from a beacon hint. This attribute reflects
+ * the state of the channel _after_ the beacon hint processing. This
+ * attributes consists of a nested attribute containing
+ * NL80211_FREQUENCY_ATTR_*
+ *
+ * @NL80211_ATTR_CIPHER_SUITES: a set of u32 values indicating the supported
+ * cipher suites
+ *
+ * @NL80211_ATTR_FREQ_FIXED: a flag indicating the IBSS should not try to look
+ * for other networks on different channels
+ *
+ * @NL80211_ATTR_TIMED_OUT: a flag indicating than an operation timed out; this
+ * is used, e.g., with %NL80211_CMD_AUTHENTICATE event
+ *
+ * @NL80211_ATTR_USE_MFP: Whether management frame protection (IEEE 802.11w) is
+ * used for the association (&enum nl80211_mfp, represented as a u32);
+ * this attribute can be used
+ * with %NL80211_CMD_ASSOCIATE request
+ *
+ * @NL80211_ATTR_STA_FLAGS2: Attribute containing a
+ * &struct nl80211_sta_flag_update.
+ *
+ * @NL80211_ATTR_CONTROL_PORT: A flag indicating whether user space controls
+ * IEEE 802.1X port, i.e., sets/clears %NL80211_STA_FLAG_AUTHORIZED, in
+ * station mode. If the flag is included in %NL80211_CMD_ASSOCIATE
+ * request, the driver will assume that the port is unauthorized until
+ * authorized by user space. Otherwise, port is marked authorized by
+ * default in station mode.
+ * @NL80211_ATTR_CONTROL_PORT_ETHERTYPE: A 16-bit value indicating the
+ * ethertype that will be used for key negotiation. It can be
+ * specified with the associate and connect commands. If it is not
+ * specified, the value defaults to 0x888E (PAE, 802.1X). This
+ * attribute is also used as a flag in the wiphy information to
+ * indicate that protocols other than PAE are supported.
+ * @NL80211_ATTR_CONTROL_PORT_NO_ENCRYPT: When included along with
+ * %NL80211_ATTR_CONTROL_PORT_ETHERTYPE, indicates that the custom
+ * ethertype frames used for key negotiation must not be encrypted.
+ *
+ * @NL80211_ATTR_TESTDATA: Testmode data blob, passed through to the driver.
+ * We recommend using nested, driver-specific attributes within this.
+ *
+ * @NL80211_ATTR_DISCONNECTED_BY_AP: A flag indicating that the DISCONNECT
+ * event was due to the AP disconnecting the station, and not due to
+ * a local disconnect request.
+ * @NL80211_ATTR_STATUS_CODE: StatusCode for the %NL80211_CMD_CONNECT
+ * event (u16)
+ * @NL80211_ATTR_PRIVACY: Flag attribute, used with connect(), indicating
+ * that protected APs should be used. This is also used with NEW_BEACON to
+ * indicate that the BSS is to use protection.
+ *
+ * @NL80211_ATTR_CIPHERS_PAIRWISE: Used with CONNECT, ASSOCIATE, and NEW_BEACON
+ * to indicate which unicast key ciphers will be used with the connection
+ * (an array of u32).
+ * @NL80211_ATTR_CIPHER_GROUP: Used with CONNECT, ASSOCIATE, and NEW_BEACON to
+ * indicate which group key cipher will be used with the connection (a
+ * u32).
+ * @NL80211_ATTR_WPA_VERSIONS: Used with CONNECT, ASSOCIATE, and NEW_BEACON to
+ * indicate which WPA version(s) the AP we want to associate with is using
+ * (a u32 with flags from &enum nl80211_wpa_versions).
+ * @NL80211_ATTR_AKM_SUITES: Used with CONNECT, ASSOCIATE, and NEW_BEACON to
+ * indicate which key management algorithm(s) to use (an array of u32).
+ *
+ * @NL80211_ATTR_REQ_IE: (Re)association request information elements as
+ * sent out by the card, for ROAM and successful CONNECT events.
+ * @NL80211_ATTR_RESP_IE: (Re)association response information elements as
+ * sent by peer, for ROAM and successful CONNECT events.
+ *
+ * @NL80211_ATTR_PREV_BSSID: previous BSSID, to be used by in ASSOCIATE
+ * commands to specify using a reassociate frame
+ *
+ * @NL80211_ATTR_KEY: key information in a nested attribute with
+ * %NL80211_KEY_* sub-attributes
+ * @NL80211_ATTR_KEYS: array of keys for static WEP keys for connect()
+ * and join_ibss(), key information is in a nested attribute each
+ * with %NL80211_KEY_* sub-attributes
+ *
+ * @NL80211_ATTR_PID: Process ID of a network namespace.
+ *
+ * @NL80211_ATTR_GENERATION: Used to indicate consistent snapshots for
+ * dumps. This number increases whenever the object list being
+ * dumped changes, and as such userspace can verify that it has
+ * obtained a complete and consistent snapshot by verifying that
+ * all dump messages contain the same generation number. If it
+ * changed then the list changed and the dump should be repeated
+ * completely from scratch.
+ *
+ * @NL80211_ATTR_4ADDR: Use 4-address frames on a virtual interface
+ *
+ * @NL80211_ATTR_SURVEY_INFO: survey information about a channel, part of
+ * the survey response for %NL80211_CMD_GET_SURVEY, nested attribute
+ * containing info as possible, see &enum survey_info.
+ *
+ * @NL80211_ATTR_PMKID: PMK material for PMKSA caching.
+ * @NL80211_ATTR_MAX_NUM_PMKIDS: maximum number of PMKIDs a firmware can
+ * cache, a wiphy attribute.
+ *
+ * @NL80211_ATTR_DURATION: Duration of an operation in milliseconds, u32.
+ * @NL80211_ATTR_MAX_REMAIN_ON_CHANNEL_DURATION: Device attribute that
+ * specifies the maximum duration that can be requested with the
+ * remain-on-channel operation, in milliseconds, u32.
+ *
+ * @NL80211_ATTR_COOKIE: Generic 64-bit cookie to identify objects.
+ *
+ * @NL80211_ATTR_TX_RATES: Nested set of attributes
+ * (enum nl80211_tx_rate_attributes) describing TX rates per band. The
+ * enum nl80211_band value is used as the index (nla_type() of the nested
+ * data. If a band is not included, it will be configured to allow all
+ * rates based on negotiated supported rates information. This attribute
+ * is used with %NL80211_CMD_SET_TX_BITRATE_MASK.
+ *
+ * @NL80211_ATTR_FRAME_MATCH: A binary attribute which typically must contain
+ * at least one byte, currently used with @NL80211_CMD_REGISTER_FRAME.
+ * @NL80211_ATTR_FRAME_TYPE: A u16 indicating the frame type/subtype for the
+ * @NL80211_CMD_REGISTER_FRAME command.
+ * @NL80211_ATTR_TX_FRAME_TYPES: wiphy capability attribute, which is a
+ * nested attribute of %NL80211_ATTR_FRAME_TYPE attributes, containing
+ * information about which frame types can be transmitted with
+ * %NL80211_CMD_FRAME.
+ * @NL80211_ATTR_RX_FRAME_TYPES: wiphy capability attribute, which is a
+ * nested attribute of %NL80211_ATTR_FRAME_TYPE attributes, containing
+ * information about which frame types can be registered for RX.
+ *
+ * @NL80211_ATTR_ACK: Flag attribute indicating that the frame was
+ * acknowledged by the recipient.
+ *
+ * @NL80211_ATTR_CQM: connection quality monitor configuration in a
+ * nested attribute with %NL80211_ATTR_CQM_* sub-attributes.
+ *
+ * @NL80211_ATTR_LOCAL_STATE_CHANGE: Flag attribute to indicate that a command
+ * is requesting a local authentication/association state change without
+ * invoking actual management frame exchange. This can be used with
+ * NL80211_CMD_AUTHENTICATE, NL80211_CMD_DEAUTHENTICATE,
+ * NL80211_CMD_DISASSOCIATE.
+ *
+ * @NL80211_ATTR_AP_ISOLATE: (AP mode) Do not forward traffic between stations
+ * connected to this BSS.
+ *
+ * @NL80211_ATTR_WIPHY_TX_POWER_SETTING: Transmit power setting type. See
+ * &enum nl80211_tx_power_setting for possible values.
+ * @NL80211_ATTR_WIPHY_TX_POWER_LEVEL: Transmit power level in signed mBm units.
+ * This is used in association with @NL80211_ATTR_WIPHY_TX_POWER_SETTING
+ * for non-automatic settings.
+ *
+ * @NL80211_ATTR_SUPPORT_IBSS_RSN: The device supports IBSS RSN, which mostly
+ * means support for per-station GTKs.
+ *
+ * @NL80211_ATTR_WIPHY_ANTENNA_TX: Bitmap of allowed antennas for transmitting.
+ * This can be used to mask out antennas which are not attached or should
+ * not be used for transmitting. If an antenna is not selected in this
+ * bitmap the hardware is not allowed to transmit on this antenna.
+ *
+ * Each bit represents one antenna, starting with antenna 1 at the first
+ * bit. Depending on which antennas are selected in the bitmap, 802.11n
+ * drivers can derive which chainmasks to use (if all antennas belonging to
+ * a particular chain are disabled this chain should be disabled) and if
+ * a chain has diversity antennas wether diversity should be used or not.
+ * HT capabilities (STBC, TX Beamforming, Antenna selection) can be
+ * derived from the available chains after applying the antenna mask.
+ * Non-802.11n drivers can derive wether to use diversity or not.
+ * Drivers may reject configurations or RX/TX mask combinations they cannot
+ * support by returning -EINVAL.
+ *
+ * @NL80211_ATTR_WIPHY_ANTENNA_RX: Bitmap of allowed antennas for receiving.
+ * This can be used to mask out antennas which are not attached or should
+ * not be used for receiving. If an antenna is not selected in this bitmap
+ * the hardware should not be configured to receive on this antenna.
+ * For a more detailed description see @NL80211_ATTR_WIPHY_ANTENNA_TX.
+ *
+ * @NL80211_ATTR_WIPHY_ANTENNA_AVAIL_TX: Bitmap of antennas which are available
+ * for configuration as TX antennas via the above parameters.
+ *
+ * @NL80211_ATTR_WIPHY_ANTENNA_AVAIL_RX: Bitmap of antennas which are available
+ * for configuration as RX antennas via the above parameters.
+ *
+ * @NL80211_ATTR_MCAST_RATE: Multicast tx rate (in 100 kbps) for IBSS
+ *
+ * @NL80211_ATTR_OFFCHANNEL_TX_OK: For management frame TX, the frame may be
+ * transmitted on another channel when the channel given doesn't match
+ * the current channel. If the current channel doesn't match and this
+ * flag isn't set, the frame will be rejected. This is also used as an
+ * nl80211 capability flag.
+ *
+ * @NL80211_ATTR_BSS_HTOPMODE: HT operation mode (u16)
+ *
+ * @NL80211_ATTR_KEY_DEFAULT_TYPES: A nested attribute containing flags
+ * attributes, specifying what a key should be set as default as.
+ * See &enum nl80211_key_default_types.
+ *
+ * @NL80211_ATTR_MESH_SETUP: Optional mesh setup parameters. These cannot be
+ * changed once the mesh is active.
+ * @NL80211_ATTR_MESH_CONFIG: Mesh configuration parameters, a nested attribute
+ * containing attributes from &enum nl80211_meshconf_params.
+ * @NL80211_ATTR_SUPPORT_MESH_AUTH: Currently, this means the underlying driver
+ * allows auth frames in a mesh to be passed to userspace for processing via
+ * the @NL80211_MESH_SETUP_USERSPACE_AUTH flag.
+ * @NL80211_ATTR_STA_PLINK_STATE: The state of a mesh peer link as
+ * defined in &enum nl80211_plink_state. Used when userspace is
+ * driving the peer link management state machine.
+ * @NL80211_MESH_SETUP_USERSPACE_AMPE must be enabled.
+ *
+ * @NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED: indicates, as part of the wiphy
+ * capabilities, the supported WoWLAN triggers
+ * @NL80211_ATTR_WOWLAN_TRIGGERS: used by %NL80211_CMD_SET_WOWLAN to
+ * indicate which WoW triggers should be enabled. This is also
+ * used by %NL80211_CMD_GET_WOWLAN to get the currently enabled WoWLAN
+ * triggers.
+
+ * @NL80211_ATTR_SCHED_SCAN_INTERVAL: Interval between scheduled scan
+ * cycles, in msecs.
+
+ * @NL80211_ATTR_SCHED_SCAN_MATCH: Nested attribute with one or more
+ * sets of attributes to match during scheduled scans. Only BSSs
+ * that match any of the sets will be reported. These are
+ * pass-thru filter rules.
+ * For a match to succeed, the BSS must match all attributes of a
+ * set. Since not every hardware supports matching all types of
+ * attributes, there is no guarantee that the reported BSSs are
+ * fully complying with the match sets and userspace needs to be
+ * able to ignore them by itself.
+ * Thus, the implementation is somewhat hardware-dependent, but
+ * this is only an optimization and the userspace application
+ * needs to handle all the non-filtered results anyway.
+ * If the match attributes don't make sense when combined with
+ * the values passed in @NL80211_ATTR_SCAN_SSIDS (eg. if an SSID
+ * is included in the probe request, but the match attributes
+ * will never let it go through), -EINVAL may be returned.
+ * If ommited, no filtering is done.
+ *
+ * @NL80211_ATTR_INTERFACE_COMBINATIONS: Nested attribute listing the supported
+ * interface combinations. In each nested item, it contains attributes
+ * defined in &enum nl80211_if_combination_attrs.
+ * @NL80211_ATTR_SOFTWARE_IFTYPES: Nested attribute (just like
+ * %NL80211_ATTR_SUPPORTED_IFTYPES) containing the interface types that
+ * are managed in software: interfaces of these types aren't subject to
+ * any restrictions in their number or combinations.
+ *
+ * @%NL80211_ATTR_REKEY_DATA: nested attribute containing the information
+ * necessary for GTK rekeying in the device, see &enum nl80211_rekey_data.
+ *
+ * @NL80211_ATTR_SCAN_SUPP_RATES: rates per to be advertised as supported in scan,
+ * nested array attribute containing an entry for each band, with the entry
+ * being a list of supported rates as defined by IEEE 802.11 7.3.2.2 but
+ * without the length restriction (at most %NL80211_MAX_SUPP_RATES).
+ *
+ * @NL80211_ATTR_HIDDEN_SSID: indicates whether SSID is to be hidden from Beacon
+ * and Probe Response (when response to wildcard Probe Request); see
+ * &enum nl80211_hidden_ssid, represented as a u32
+ *
+ * @NL80211_ATTR_IE_PROBE_RESP: Information element(s) for Probe Response frame.
+ * This is used with %NL80211_CMD_NEW_BEACON and %NL80211_CMD_SET_BEACON to
+ * provide extra IEs (e.g., WPS/P2P IE) into Probe Response frames when the
+ * driver (or firmware) replies to Probe Request frames.
+ * @NL80211_ATTR_IE_ASSOC_RESP: Information element(s) for (Re)Association
+ * Response frames. This is used with %NL80211_CMD_NEW_BEACON and
+ * %NL80211_CMD_SET_BEACON to provide extra IEs (e.g., WPS/P2P IE) into
+ * (Re)Association Response frames when the driver (or firmware) replies to
+ * (Re)Association Request frames.
+ *
+ * @NL80211_ATTR_STA_WME: Nested attribute containing the wme configuration
+ * of the station, see &enum nl80211_sta_wme_attr.
+ * @NL80211_ATTR_SUPPORT_AP_UAPSD: the device supports uapsd when working
+ * as AP.
+ *
+ * @NL80211_ATTR_ROAM_SUPPORT: Indicates whether the firmware is capable of
+ * roaming to another AP in the same ESS if the signal lever is low.
+ *
+ * @NL80211_ATTR_PMKSA_CANDIDATE: Nested attribute containing the PMKSA caching
+ * candidate information, see &enum nl80211_pmksa_candidate_attr.
+ *
+ * @NL80211_ATTR_TX_NO_CCK_RATE: Indicates whether to use CCK rate or not
+ * for management frames transmission. In order to avoid p2p probe/action
+ * frames are being transmitted at CCK rate in 2GHz band, the user space
+ * applications use this attribute.
+ * This attribute is used with %NL80211_CMD_TRIGGER_SCAN and
+ * %NL80211_CMD_FRAME commands.
+ *
+ * @NL80211_ATTR_TDLS_ACTION: Low level TDLS action code (e.g. link setup
+ * request, link setup confirm, link teardown, etc.). Values are
+ * described in the TDLS (802.11z) specification.
+ * @NL80211_ATTR_TDLS_DIALOG_TOKEN: Non-zero token for uniquely identifying a
+ * TDLS conversation between two devices.
+ * @NL80211_ATTR_TDLS_OPERATION: High level TDLS operation; see
+ * &enum nl80211_tdls_operation, represented as a u8.
+ * @NL80211_ATTR_TDLS_SUPPORT: A flag indicating the device can operate
+ * as a TDLS peer sta.
+ * @NL80211_ATTR_TDLS_EXTERNAL_SETUP: The TDLS discovery/setup and teardown
+ * procedures should be performed by sending TDLS packets via
+ * %NL80211_CMD_TDLS_MGMT. Otherwise %NL80211_CMD_TDLS_OPER should be
+ * used for asking the driver to perform a TDLS operation.
+ *
+ * @NL80211_ATTR_DEVICE_AP_SME: This u32 attribute may be listed for devices
+ * that have AP support to indicate that they have the AP SME integrated
+ * with support for the features listed in this attribute, see
+ * &enum nl80211_ap_sme_features.
+ *
+ * @NL80211_ATTR_DONT_WAIT_FOR_ACK: Used with %NL80211_CMD_FRAME, this tells
+ * the driver to not wait for an acknowledgement. Note that due to this,
+ * it will also not give a status callback nor return a cookie. This is
+ * mostly useful for probe responses to save airtime.
+ *
+ * @NL80211_ATTR_FEATURE_FLAGS: This u32 attribute contains flags from
+ * &enum nl80211_feature_flags and is advertised in wiphy information.
+ * @NL80211_ATTR_PROBE_RESP_OFFLOAD: Indicates that the HW responds to probe
+ *
+ * requests while operating in AP-mode.
+ * This attribute holds a bitmap of the supported protocols for
+ * offloading (see &enum nl80211_probe_resp_offload_support_attr).
+ *
+ * @NL80211_ATTR_PROBE_RESP: Probe Response template data. Contains the entire
+ * probe-response frame. The DA field in the 802.11 header is zero-ed out,
+ * to be filled by the FW.
+ * @NL80211_ATTR_DISABLE_HT: Force HT capable interfaces to disable
+ * this feature. Currently, only supported in mac80211 drivers.
+ * @NL80211_ATTR_HT_CAPABILITY_MASK: Specify which bits of the
+ * ATTR_HT_CAPABILITY to which attention should be paid.
+ * Currently, only mac80211 NICs support this feature.
+ * The values that may be configured are:
+ * MCS rates, MAX-AMSDU, HT-20-40 and HT_CAP_SGI_40
+ * AMPDU density and AMPDU factor.
+ * All values are treated as suggestions and may be ignored
+ * by the driver as required. The actual values may be seen in
+ * the station debugfs ht_caps file.
+ *
+ * @NL80211_ATTR_DFS_REGION: region for regulatory rules which this country
+ * abides to when initiating radiation on DFS channels. A country maps
+ * to one DFS region.
+ *
+ * @NL80211_ATTR_NOACK_MAP: This u16 bitmap contains the No Ack Policy of
+ * up to 16 TIDs.
+ *
+ * @NL80211_ATTR_MAX: highest attribute number currently defined
+ * @__NL80211_ATTR_AFTER_LAST: internal use
+ */
+enum nl80211_attrs {
+/* don't change the order or add anything between, this is ABI! */
+ NL80211_ATTR_UNSPEC,
+
+ NL80211_ATTR_WIPHY,
+ NL80211_ATTR_WIPHY_NAME,
+
+ NL80211_ATTR_IFINDEX,
+ NL80211_ATTR_IFNAME,
+ NL80211_ATTR_IFTYPE,
+
+ NL80211_ATTR_MAC,
+
+ NL80211_ATTR_KEY_DATA,
+ NL80211_ATTR_KEY_IDX,
+ NL80211_ATTR_KEY_CIPHER,
+ NL80211_ATTR_KEY_SEQ,
+ NL80211_ATTR_KEY_DEFAULT,
+
+ NL80211_ATTR_BEACON_INTERVAL,
+ NL80211_ATTR_DTIM_PERIOD,
+ NL80211_ATTR_BEACON_HEAD,
+ NL80211_ATTR_BEACON_TAIL,
+
+ NL80211_ATTR_STA_AID,
+ NL80211_ATTR_STA_FLAGS,
+ NL80211_ATTR_STA_LISTEN_INTERVAL,
+ NL80211_ATTR_STA_SUPPORTED_RATES,
+ NL80211_ATTR_STA_VLAN,
+ NL80211_ATTR_STA_INFO,
+
+ NL80211_ATTR_WIPHY_BANDS,
+
+ NL80211_ATTR_MNTR_FLAGS,
+
+ NL80211_ATTR_MESH_ID,
+ NL80211_ATTR_STA_PLINK_ACTION,
+ NL80211_ATTR_MPATH_NEXT_HOP,
+ NL80211_ATTR_MPATH_INFO,
+
+ NL80211_ATTR_BSS_CTS_PROT,
+ NL80211_ATTR_BSS_SHORT_PREAMBLE,
+ NL80211_ATTR_BSS_SHORT_SLOT_TIME,
+
+ NL80211_ATTR_HT_CAPABILITY,
+
+ NL80211_ATTR_SUPPORTED_IFTYPES,
+
+ NL80211_ATTR_REG_ALPHA2,
+ NL80211_ATTR_REG_RULES,
+
+ NL80211_ATTR_MESH_CONFIG,
+
+ NL80211_ATTR_BSS_BASIC_RATES,
+
+ NL80211_ATTR_WIPHY_TXQ_PARAMS,
+ NL80211_ATTR_WIPHY_FREQ,
+ NL80211_ATTR_WIPHY_CHANNEL_TYPE,
+
+ NL80211_ATTR_KEY_DEFAULT_MGMT,
+
+ NL80211_ATTR_MGMT_SUBTYPE,
+ NL80211_ATTR_IE,
+
+ NL80211_ATTR_MAX_NUM_SCAN_SSIDS,
+
+ NL80211_ATTR_SCAN_FREQUENCIES,
+ NL80211_ATTR_SCAN_SSIDS,
+ NL80211_ATTR_GENERATION, /* replaces old SCAN_GENERATION */
+ NL80211_ATTR_BSS,
+
+ NL80211_ATTR_REG_INITIATOR,
+ NL80211_ATTR_REG_TYPE,
+
+ NL80211_ATTR_SUPPORTED_COMMANDS,
+
+ NL80211_ATTR_FRAME,
+ NL80211_ATTR_SSID,
+ NL80211_ATTR_AUTH_TYPE,
+ NL80211_ATTR_REASON_CODE,
+
+ NL80211_ATTR_KEY_TYPE,
+
+ NL80211_ATTR_MAX_SCAN_IE_LEN,
+ NL80211_ATTR_CIPHER_SUITES,
+
+ NL80211_ATTR_FREQ_BEFORE,
+ NL80211_ATTR_FREQ_AFTER,
+
+ NL80211_ATTR_FREQ_FIXED,
+
+
+ NL80211_ATTR_WIPHY_RETRY_SHORT,
+ NL80211_ATTR_WIPHY_RETRY_LONG,
+ NL80211_ATTR_WIPHY_FRAG_THRESHOLD,
+ NL80211_ATTR_WIPHY_RTS_THRESHOLD,
+
+ NL80211_ATTR_TIMED_OUT,
+
+ NL80211_ATTR_USE_MFP,
+
+ NL80211_ATTR_STA_FLAGS2,
+
+ NL80211_ATTR_CONTROL_PORT,
+
+ NL80211_ATTR_TESTDATA,
+
+ NL80211_ATTR_PRIVACY,
+
+ NL80211_ATTR_DISCONNECTED_BY_AP,
+ NL80211_ATTR_STATUS_CODE,
+
+ NL80211_ATTR_CIPHER_SUITES_PAIRWISE,
+ NL80211_ATTR_CIPHER_SUITE_GROUP,
+ NL80211_ATTR_WPA_VERSIONS,
+ NL80211_ATTR_AKM_SUITES,
+
+ NL80211_ATTR_REQ_IE,
+ NL80211_ATTR_RESP_IE,
+
+ NL80211_ATTR_PREV_BSSID,
+
+ NL80211_ATTR_KEY,
+ NL80211_ATTR_KEYS,
+
+ NL80211_ATTR_PID,
+
+ NL80211_ATTR_4ADDR,
+
+ NL80211_ATTR_SURVEY_INFO,
+
+ NL80211_ATTR_PMKID,
+ NL80211_ATTR_MAX_NUM_PMKIDS,
+
+ NL80211_ATTR_DURATION,
+
+ NL80211_ATTR_COOKIE,
+
+ NL80211_ATTR_WIPHY_COVERAGE_CLASS,
+
+ NL80211_ATTR_TX_RATES,
+
+ NL80211_ATTR_FRAME_MATCH,
+
+ NL80211_ATTR_ACK,
+
+ NL80211_ATTR_PS_STATE,
+
+ NL80211_ATTR_CQM,
+
+ NL80211_ATTR_LOCAL_STATE_CHANGE,
+
+ NL80211_ATTR_AP_ISOLATE,
+
+ NL80211_ATTR_WIPHY_TX_POWER_SETTING,
+ NL80211_ATTR_WIPHY_TX_POWER_LEVEL,
+
+ NL80211_ATTR_TX_FRAME_TYPES,
+ NL80211_ATTR_RX_FRAME_TYPES,
+ NL80211_ATTR_FRAME_TYPE,
+
+ NL80211_ATTR_CONTROL_PORT_ETHERTYPE,
+ NL80211_ATTR_CONTROL_PORT_NO_ENCRYPT,
+
+ NL80211_ATTR_SUPPORT_IBSS_RSN,
+
+ NL80211_ATTR_WIPHY_ANTENNA_TX,
+ NL80211_ATTR_WIPHY_ANTENNA_RX,
+
+ NL80211_ATTR_MCAST_RATE,
+
+ NL80211_ATTR_OFFCHANNEL_TX_OK,
+
+ NL80211_ATTR_BSS_HT_OPMODE,
+
+ NL80211_ATTR_KEY_DEFAULT_TYPES,
+
+ NL80211_ATTR_MAX_REMAIN_ON_CHANNEL_DURATION,
+
+ NL80211_ATTR_MESH_SETUP,
+
+ NL80211_ATTR_WIPHY_ANTENNA_AVAIL_TX,
+ NL80211_ATTR_WIPHY_ANTENNA_AVAIL_RX,
+
+ NL80211_ATTR_SUPPORT_MESH_AUTH,
+ NL80211_ATTR_STA_PLINK_STATE,
+
+ NL80211_ATTR_WOWLAN_TRIGGERS,
+ NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED,
+
+ NL80211_ATTR_SCHED_SCAN_INTERVAL,
+
+ NL80211_ATTR_INTERFACE_COMBINATIONS,
+ NL80211_ATTR_SOFTWARE_IFTYPES,
+
+ NL80211_ATTR_REKEY_DATA,
+
+ NL80211_ATTR_MAX_NUM_SCHED_SCAN_SSIDS,
+ NL80211_ATTR_MAX_SCHED_SCAN_IE_LEN,
+
+ NL80211_ATTR_SCAN_SUPP_RATES,
+
+ NL80211_ATTR_HIDDEN_SSID,
+
+ NL80211_ATTR_IE_PROBE_RESP,
+ NL80211_ATTR_IE_ASSOC_RESP,
+
+ NL80211_ATTR_STA_WME,
+ NL80211_ATTR_SUPPORT_AP_UAPSD,
+
+ NL80211_ATTR_ROAM_SUPPORT,
+
+ NL80211_ATTR_SCHED_SCAN_MATCH,
+ NL80211_ATTR_MAX_MATCH_SETS,
+
+ NL80211_ATTR_PMKSA_CANDIDATE,
+
+ NL80211_ATTR_TX_NO_CCK_RATE,
+
+ NL80211_ATTR_TDLS_ACTION,
+ NL80211_ATTR_TDLS_DIALOG_TOKEN,
+ NL80211_ATTR_TDLS_OPERATION,
+ NL80211_ATTR_TDLS_SUPPORT,
+ NL80211_ATTR_TDLS_EXTERNAL_SETUP,
+
+ NL80211_ATTR_DEVICE_AP_SME,
+
+ NL80211_ATTR_DONT_WAIT_FOR_ACK,
+
+ NL80211_ATTR_FEATURE_FLAGS,
+
+ NL80211_ATTR_PROBE_RESP_OFFLOAD,
+
+ NL80211_ATTR_PROBE_RESP,
+
+ NL80211_ATTR_DFS_REGION,
+
+ NL80211_ATTR_DISABLE_HT,
+ NL80211_ATTR_HT_CAPABILITY_MASK,
+
+ NL80211_ATTR_NOACK_MAP,
+
+ /* add attributes here, update the policy in nl80211.c */
+
+ __NL80211_ATTR_AFTER_LAST,
+ NL80211_ATTR_MAX = __NL80211_ATTR_AFTER_LAST - 1
+};
+
+/* source-level API compatibility */
+#define NL80211_ATTR_SCAN_GENERATION NL80211_ATTR_GENERATION
+#define NL80211_ATTR_MESH_PARAMS NL80211_ATTR_MESH_CONFIG
+
+/*
+ * Allow user space programs to use #ifdef on new attributes by defining them
+ * here
+ */
+#define NL80211_CMD_CONNECT NL80211_CMD_CONNECT
+#define NL80211_ATTR_HT_CAPABILITY NL80211_ATTR_HT_CAPABILITY
+#define NL80211_ATTR_BSS_BASIC_RATES NL80211_ATTR_BSS_BASIC_RATES
+#define NL80211_ATTR_WIPHY_TXQ_PARAMS NL80211_ATTR_WIPHY_TXQ_PARAMS
+#define NL80211_ATTR_WIPHY_FREQ NL80211_ATTR_WIPHY_FREQ
+#define NL80211_ATTR_WIPHY_CHANNEL_TYPE NL80211_ATTR_WIPHY_CHANNEL_TYPE
+#define NL80211_ATTR_MGMT_SUBTYPE NL80211_ATTR_MGMT_SUBTYPE
+#define NL80211_ATTR_IE NL80211_ATTR_IE
+#define NL80211_ATTR_REG_INITIATOR NL80211_ATTR_REG_INITIATOR
+#define NL80211_ATTR_REG_TYPE NL80211_ATTR_REG_TYPE
+#define NL80211_ATTR_FRAME NL80211_ATTR_FRAME
+#define NL80211_ATTR_SSID NL80211_ATTR_SSID
+#define NL80211_ATTR_AUTH_TYPE NL80211_ATTR_AUTH_TYPE
+#define NL80211_ATTR_REASON_CODE NL80211_ATTR_REASON_CODE
+#define NL80211_ATTR_CIPHER_SUITES_PAIRWISE NL80211_ATTR_CIPHER_SUITES_PAIRWISE
+#define NL80211_ATTR_CIPHER_SUITE_GROUP NL80211_ATTR_CIPHER_SUITE_GROUP
+#define NL80211_ATTR_WPA_VERSIONS NL80211_ATTR_WPA_VERSIONS
+#define NL80211_ATTR_AKM_SUITES NL80211_ATTR_AKM_SUITES
+#define NL80211_ATTR_KEY NL80211_ATTR_KEY
+#define NL80211_ATTR_KEYS NL80211_ATTR_KEYS
+#define NL80211_ATTR_FEATURE_FLAGS NL80211_ATTR_FEATURE_FLAGS
+
+#define NL80211_MAX_SUPP_RATES 32
+#define NL80211_MAX_SUPP_HT_RATES 77
+#define NL80211_MAX_SUPP_REG_RULES 32
+#define NL80211_TKIP_DATA_OFFSET_ENCR_KEY 0
+#define NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY 16
+#define NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY 24
+#define NL80211_HT_CAPABILITY_LEN 26
+
+#define NL80211_MAX_NR_CIPHER_SUITES 5
+#define NL80211_MAX_NR_AKM_SUITES 2
+
+/**
+ * enum nl80211_iftype - (virtual) interface types
+ *
+ * @NL80211_IFTYPE_UNSPECIFIED: unspecified type, driver decides
+ * @NL80211_IFTYPE_ADHOC: independent BSS member
+ * @NL80211_IFTYPE_STATION: managed BSS member
+ * @NL80211_IFTYPE_AP: access point
+ * @NL80211_IFTYPE_AP_VLAN: VLAN interface for access points; VLAN interfaces
+ * are a bit special in that they must always be tied to a pre-existing
+ * AP type interface.
+ * @NL80211_IFTYPE_WDS: wireless distribution interface
+ * @NL80211_IFTYPE_MONITOR: monitor interface receiving all frames
+ * @NL80211_IFTYPE_MESH_POINT: mesh point
+ * @NL80211_IFTYPE_P2P_CLIENT: P2P client
+ * @NL80211_IFTYPE_P2P_GO: P2P group owner
+ * @NL80211_IFTYPE_MAX: highest interface type number currently defined
+ * @NUM_NL80211_IFTYPES: number of defined interface types
+ *
+ * These values are used with the %NL80211_ATTR_IFTYPE
+ * to set the type of an interface.
+ *
+ */
+enum nl80211_iftype {
+ NL80211_IFTYPE_UNSPECIFIED,
+ NL80211_IFTYPE_ADHOC,
+ NL80211_IFTYPE_STATION,
+ NL80211_IFTYPE_AP,
+ NL80211_IFTYPE_AP_VLAN,
+ NL80211_IFTYPE_WDS,
+ NL80211_IFTYPE_MONITOR,
+ NL80211_IFTYPE_MESH_POINT,
+ NL80211_IFTYPE_P2P_CLIENT,
+ NL80211_IFTYPE_P2P_GO,
+
+ /* keep last */
+ NUM_NL80211_IFTYPES,
+ NL80211_IFTYPE_MAX = NUM_NL80211_IFTYPES - 1
+};
+
+/**
+ * enum nl80211_sta_flags - station flags
+ *
+ * Station flags. When a station is added to an AP interface, it is
+ * assumed to be already associated (and hence authenticated.)
+ *
+ * @__NL80211_STA_FLAG_INVALID: attribute number 0 is reserved
+ * @NL80211_STA_FLAG_AUTHORIZED: station is authorized (802.1X)
+ * @NL80211_STA_FLAG_SHORT_PREAMBLE: station is capable of receiving frames
+ * with short barker preamble
+ * @NL80211_STA_FLAG_WME: station is WME/QoS capable
+ * @NL80211_STA_FLAG_MFP: station uses management frame protection
+ * @NL80211_STA_FLAG_AUTHENTICATED: station is authenticated
+ * @NL80211_STA_FLAG_TDLS_PEER: station is a TDLS peer -- this flag should
+ * only be used in managed mode (even in the flags mask). Note that the
+ * flag can't be changed, it is only valid while adding a station, and
+ * attempts to change it will silently be ignored (rather than rejected
+ * as errors.)
+ * @NL80211_STA_FLAG_MAX: highest station flag number currently defined
+ * @__NL80211_STA_FLAG_AFTER_LAST: internal use
+ */
+enum nl80211_sta_flags {
+ __NL80211_STA_FLAG_INVALID,
+ NL80211_STA_FLAG_AUTHORIZED,
+ NL80211_STA_FLAG_SHORT_PREAMBLE,
+ NL80211_STA_FLAG_WME,
+ NL80211_STA_FLAG_MFP,
+ NL80211_STA_FLAG_AUTHENTICATED,
+ NL80211_STA_FLAG_TDLS_PEER,
+
+ /* keep last */
+ __NL80211_STA_FLAG_AFTER_LAST,
+ NL80211_STA_FLAG_MAX = __NL80211_STA_FLAG_AFTER_LAST - 1
+};
+
+/**
+ * struct nl80211_sta_flag_update - station flags mask/set
+ * @mask: mask of station flags to set
+ * @set: which values to set them to
+ *
+ * Both mask and set contain bits as per &enum nl80211_sta_flags.
+ */
+struct nl80211_sta_flag_update {
+ __u32 mask;
+ __u32 set;
+} __attribute__((packed));
+
+/**
+ * enum nl80211_rate_info - bitrate information
+ *
+ * These attribute types are used with %NL80211_STA_INFO_TXRATE
+ * when getting information about the bitrate of a station.
+ *
+ * @__NL80211_RATE_INFO_INVALID: attribute number 0 is reserved
+ * @NL80211_RATE_INFO_BITRATE: total bitrate (u16, 100kbit/s)
+ * @NL80211_RATE_INFO_MCS: mcs index for 802.11n (u8)
+ * @NL80211_RATE_INFO_40_MHZ_WIDTH: 40 Mhz dualchannel bitrate
+ * @NL80211_RATE_INFO_SHORT_GI: 400ns guard interval
+ * @NL80211_RATE_INFO_MAX: highest rate_info number currently defined
+ * @__NL80211_RATE_INFO_AFTER_LAST: internal use
+ */
+enum nl80211_rate_info {
+ __NL80211_RATE_INFO_INVALID,
+ NL80211_RATE_INFO_BITRATE,
+ NL80211_RATE_INFO_MCS,
+ NL80211_RATE_INFO_40_MHZ_WIDTH,
+ NL80211_RATE_INFO_SHORT_GI,
+
+ /* keep last */
+ __NL80211_RATE_INFO_AFTER_LAST,
+ NL80211_RATE_INFO_MAX = __NL80211_RATE_INFO_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_sta_bss_param - BSS information collected by STA
+ *
+ * These attribute types are used with %NL80211_STA_INFO_BSS_PARAM
+ * when getting information about the bitrate of a station.
+ *
+ * @__NL80211_STA_BSS_PARAM_INVALID: attribute number 0 is reserved
+ * @NL80211_STA_BSS_PARAM_CTS_PROT: whether CTS protection is enabled (flag)
+ * @NL80211_STA_BSS_PARAM_SHORT_PREAMBLE: whether short preamble is enabled
+ * (flag)
+ * @NL80211_STA_BSS_PARAM_SHORT_SLOT_TIME: whether short slot time is enabled
+ * (flag)
+ * @NL80211_STA_BSS_PARAM_DTIM_PERIOD: DTIM period for beaconing (u8)
+ * @NL80211_STA_BSS_PARAM_BEACON_INTERVAL: Beacon interval (u16)
+ * @NL80211_STA_BSS_PARAM_MAX: highest sta_bss_param number currently defined
+ * @__NL80211_STA_BSS_PARAM_AFTER_LAST: internal use
+ */
+enum nl80211_sta_bss_param {
+ __NL80211_STA_BSS_PARAM_INVALID,
+ NL80211_STA_BSS_PARAM_CTS_PROT,
+ NL80211_STA_BSS_PARAM_SHORT_PREAMBLE,
+ NL80211_STA_BSS_PARAM_SHORT_SLOT_TIME,
+ NL80211_STA_BSS_PARAM_DTIM_PERIOD,
+ NL80211_STA_BSS_PARAM_BEACON_INTERVAL,
+
+ /* keep last */
+ __NL80211_STA_BSS_PARAM_AFTER_LAST,
+ NL80211_STA_BSS_PARAM_MAX = __NL80211_STA_BSS_PARAM_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_sta_info - station information
+ *
+ * These attribute types are used with %NL80211_ATTR_STA_INFO
+ * when getting information about a station.
+ *
+ * @__NL80211_STA_INFO_INVALID: attribute number 0 is reserved
+ * @NL80211_STA_INFO_INACTIVE_TIME: time since last activity (u32, msecs)
+ * @NL80211_STA_INFO_RX_BYTES: total received bytes (u32, from this station)
+ * @NL80211_STA_INFO_TX_BYTES: total transmitted bytes (u32, to this station)
+ * @NL80211_STA_INFO_SIGNAL: signal strength of last received PPDU (u8, dBm)
+ * @NL80211_STA_INFO_TX_BITRATE: current unicast tx rate, nested attribute
+ * containing info as possible, see &enum nl80211_rate_info
+ * @NL80211_STA_INFO_RX_PACKETS: total received packet (u32, from this station)
+ * @NL80211_STA_INFO_TX_PACKETS: total transmitted packets (u32, to this
+ * station)
+ * @NL80211_STA_INFO_TX_RETRIES: total retries (u32, to this station)
+ * @NL80211_STA_INFO_TX_FAILED: total failed packets (u32, to this station)
+ * @NL80211_STA_INFO_SIGNAL_AVG: signal strength average (u8, dBm)
+ * @NL80211_STA_INFO_LLID: the station's mesh LLID
+ * @NL80211_STA_INFO_PLID: the station's mesh PLID
+ * @NL80211_STA_INFO_PLINK_STATE: peer link state for the station
+ * (see %enum nl80211_plink_state)
+ * @NL80211_STA_INFO_RX_BITRATE: last unicast data frame rx rate, nested
+ * attribute, like NL80211_STA_INFO_TX_BITRATE.
+ * @NL80211_STA_INFO_BSS_PARAM: current station's view of BSS, nested attribute
+ * containing info as possible, see &enum nl80211_sta_bss_param
+ * @NL80211_STA_INFO_CONNECTED_TIME: time since the station is last connected
+ * @NL80211_STA_INFO_STA_FLAGS: Contains a struct nl80211_sta_flag_update.
+ * @NL80211_STA_INFO_BEACON_LOSS: count of times beacon loss was detected (u32)
+ * @NL80211_STA_INFO_CHAIN_SIGNAL: per-chain signal strength of last PPDU
+ * @NL80211_STA_INFO_CHAIN_SIGNAL_AVG: per-chain signal strength average
+ * @__NL80211_STA_INFO_AFTER_LAST: internal
+ * @NL80211_STA_INFO_MAX: highest possible station info attribute
+ */
+enum nl80211_sta_info {
+ __NL80211_STA_INFO_INVALID,
+ NL80211_STA_INFO_INACTIVE_TIME,
+ NL80211_STA_INFO_RX_BYTES,
+ NL80211_STA_INFO_TX_BYTES,
+ NL80211_STA_INFO_LLID,
+ NL80211_STA_INFO_PLID,
+ NL80211_STA_INFO_PLINK_STATE,
+ NL80211_STA_INFO_SIGNAL,
+ NL80211_STA_INFO_TX_BITRATE,
+ NL80211_STA_INFO_RX_PACKETS,
+ NL80211_STA_INFO_TX_PACKETS,
+ NL80211_STA_INFO_TX_RETRIES,
+ NL80211_STA_INFO_TX_FAILED,
+ NL80211_STA_INFO_SIGNAL_AVG,
+ NL80211_STA_INFO_RX_BITRATE,
+ NL80211_STA_INFO_BSS_PARAM,
+ NL80211_STA_INFO_CONNECTED_TIME,
+ NL80211_STA_INFO_STA_FLAGS,
+ NL80211_STA_INFO_BEACON_LOSS,
+ NL80211_STA_INFO_CHAIN_SIGNAL,
+ NL80211_STA_INFO_CHAIN_SIGNAL_AVG,
+
+ /* keep last */
+ __NL80211_STA_INFO_AFTER_LAST,
+ NL80211_STA_INFO_MAX = __NL80211_STA_INFO_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_mpath_flags - nl80211 mesh path flags
+ *
+ * @NL80211_MPATH_FLAG_ACTIVE: the mesh path is active
+ * @NL80211_MPATH_FLAG_RESOLVING: the mesh path discovery process is running
+ * @NL80211_MPATH_FLAG_SN_VALID: the mesh path contains a valid SN
+ * @NL80211_MPATH_FLAG_FIXED: the mesh path has been manually set
+ * @NL80211_MPATH_FLAG_RESOLVED: the mesh path discovery process succeeded
+ */
+enum nl80211_mpath_flags {
+ NL80211_MPATH_FLAG_ACTIVE = 1<<0,
+ NL80211_MPATH_FLAG_RESOLVING = 1<<1,
+ NL80211_MPATH_FLAG_SN_VALID = 1<<2,
+ NL80211_MPATH_FLAG_FIXED = 1<<3,
+ NL80211_MPATH_FLAG_RESOLVED = 1<<4,
+};
+
+/**
+ * enum nl80211_mpath_info - mesh path information
+ *
+ * These attribute types are used with %NL80211_ATTR_MPATH_INFO when getting
+ * information about a mesh path.
+ *
+ * @__NL80211_MPATH_INFO_INVALID: attribute number 0 is reserved
+ * @NL80211_MPATH_INFO_FRAME_QLEN: number of queued frames for this destination
+ * @NL80211_MPATH_INFO_SN: destination sequence number
+ * @NL80211_MPATH_INFO_METRIC: metric (cost) of this mesh path
+ * @NL80211_MPATH_INFO_EXPTIME: expiration time for the path, in msec from now
+ * @NL80211_MPATH_INFO_FLAGS: mesh path flags, enumerated in
+ * &enum nl80211_mpath_flags;
+ * @NL80211_MPATH_INFO_DISCOVERY_TIMEOUT: total path discovery timeout, in msec
+ * @NL80211_MPATH_INFO_DISCOVERY_RETRIES: mesh path discovery retries
+ * @NL80211_MPATH_INFO_MAX: highest mesh path information attribute number
+ * currently defind
+ * @__NL80211_MPATH_INFO_AFTER_LAST: internal use
+ */
+enum nl80211_mpath_info {
+ __NL80211_MPATH_INFO_INVALID,
+ NL80211_MPATH_INFO_FRAME_QLEN,
+ NL80211_MPATH_INFO_SN,
+ NL80211_MPATH_INFO_METRIC,
+ NL80211_MPATH_INFO_EXPTIME,
+ NL80211_MPATH_INFO_FLAGS,
+ NL80211_MPATH_INFO_DISCOVERY_TIMEOUT,
+ NL80211_MPATH_INFO_DISCOVERY_RETRIES,
+
+ /* keep last */
+ __NL80211_MPATH_INFO_AFTER_LAST,
+ NL80211_MPATH_INFO_MAX = __NL80211_MPATH_INFO_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_band_attr - band attributes
+ * @__NL80211_BAND_ATTR_INVALID: attribute number 0 is reserved
+ * @NL80211_BAND_ATTR_FREQS: supported frequencies in this band,
+ * an array of nested frequency attributes
+ * @NL80211_BAND_ATTR_RATES: supported bitrates in this band,
+ * an array of nested bitrate attributes
+ * @NL80211_BAND_ATTR_HT_MCS_SET: 16-byte attribute containing the MCS set as
+ * defined in 802.11n
+ * @NL80211_BAND_ATTR_HT_CAPA: HT capabilities, as in the HT information IE
+ * @NL80211_BAND_ATTR_HT_AMPDU_FACTOR: A-MPDU factor, as in 11n
+ * @NL80211_BAND_ATTR_HT_AMPDU_DENSITY: A-MPDU density, as in 11n
+ * @NL80211_BAND_ATTR_MAX: highest band attribute currently defined
+ * @__NL80211_BAND_ATTR_AFTER_LAST: internal use
+ */
+enum nl80211_band_attr {
+ __NL80211_BAND_ATTR_INVALID,
+ NL80211_BAND_ATTR_FREQS,
+ NL80211_BAND_ATTR_RATES,
+
+ NL80211_BAND_ATTR_HT_MCS_SET,
+ NL80211_BAND_ATTR_HT_CAPA,
+ NL80211_BAND_ATTR_HT_AMPDU_FACTOR,
+ NL80211_BAND_ATTR_HT_AMPDU_DENSITY,
+
+ /* keep last */
+ __NL80211_BAND_ATTR_AFTER_LAST,
+ NL80211_BAND_ATTR_MAX = __NL80211_BAND_ATTR_AFTER_LAST - 1
+};
+
+#define NL80211_BAND_ATTR_HT_CAPA NL80211_BAND_ATTR_HT_CAPA
+
+/**
+ * enum nl80211_frequency_attr - frequency attributes
+ * @__NL80211_FREQUENCY_ATTR_INVALID: attribute number 0 is reserved
+ * @NL80211_FREQUENCY_ATTR_FREQ: Frequency in MHz
+ * @NL80211_FREQUENCY_ATTR_DISABLED: Channel is disabled in current
+ * regulatory domain.
+ * @NL80211_FREQUENCY_ATTR_PASSIVE_SCAN: Only passive scanning is
+ * permitted on this channel in current regulatory domain.
+ * @NL80211_FREQUENCY_ATTR_NO_IBSS: IBSS networks are not permitted
+ * on this channel in current regulatory domain.
+ * @NL80211_FREQUENCY_ATTR_RADAR: Radar detection is mandatory
+ * on this channel in current regulatory domain.
+ * @NL80211_FREQUENCY_ATTR_MAX_TX_POWER: Maximum transmission power in mBm
+ * (100 * dBm).
+ * @NL80211_FREQUENCY_ATTR_MAX: highest frequency attribute number
+ * currently defined
+ * @__NL80211_FREQUENCY_ATTR_AFTER_LAST: internal use
+ */
+enum nl80211_frequency_attr {
+ __NL80211_FREQUENCY_ATTR_INVALID,
+ NL80211_FREQUENCY_ATTR_FREQ,
+ NL80211_FREQUENCY_ATTR_DISABLED,
+ NL80211_FREQUENCY_ATTR_PASSIVE_SCAN,
+ NL80211_FREQUENCY_ATTR_NO_IBSS,
+ NL80211_FREQUENCY_ATTR_RADAR,
+ NL80211_FREQUENCY_ATTR_MAX_TX_POWER,
+
+ /* keep last */
+ __NL80211_FREQUENCY_ATTR_AFTER_LAST,
+ NL80211_FREQUENCY_ATTR_MAX = __NL80211_FREQUENCY_ATTR_AFTER_LAST - 1
+};
+
+#define NL80211_FREQUENCY_ATTR_MAX_TX_POWER NL80211_FREQUENCY_ATTR_MAX_TX_POWER
+
+/**
+ * enum nl80211_bitrate_attr - bitrate attributes
+ * @__NL80211_BITRATE_ATTR_INVALID: attribute number 0 is reserved
+ * @NL80211_BITRATE_ATTR_RATE: Bitrate in units of 100 kbps
+ * @NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE: Short preamble supported
+ * in 2.4 GHz band.
+ * @NL80211_BITRATE_ATTR_MAX: highest bitrate attribute number
+ * currently defined
+ * @__NL80211_BITRATE_ATTR_AFTER_LAST: internal use
+ */
+enum nl80211_bitrate_attr {
+ __NL80211_BITRATE_ATTR_INVALID,
+ NL80211_BITRATE_ATTR_RATE,
+ NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE,
+
+ /* keep last */
+ __NL80211_BITRATE_ATTR_AFTER_LAST,
+ NL80211_BITRATE_ATTR_MAX = __NL80211_BITRATE_ATTR_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_initiator - Indicates the initiator of a reg domain request
+ * @NL80211_REGDOM_SET_BY_CORE: Core queried CRDA for a dynamic world
+ * regulatory domain.
+ * @NL80211_REGDOM_SET_BY_USER: User asked the wireless core to set the
+ * regulatory domain.
+ * @NL80211_REGDOM_SET_BY_DRIVER: a wireless drivers has hinted to the
+ * wireless core it thinks its knows the regulatory domain we should be in.
+ * @NL80211_REGDOM_SET_BY_COUNTRY_IE: the wireless core has received an
+ * 802.11 country information element with regulatory information it
+ * thinks we should consider. cfg80211 only processes the country
+ * code from the IE, and relies on the regulatory domain information
+ * structure passed by userspace (CRDA) from our wireless-regdb.
+ * If a channel is enabled but the country code indicates it should
+ * be disabled we disable the channel and re-enable it upon disassociation.
+ */
+enum nl80211_reg_initiator {
+ NL80211_REGDOM_SET_BY_CORE,
+ NL80211_REGDOM_SET_BY_USER,
+ NL80211_REGDOM_SET_BY_DRIVER,
+ NL80211_REGDOM_SET_BY_COUNTRY_IE,
+};
+
+/**
+ * enum nl80211_reg_type - specifies the type of regulatory domain
+ * @NL80211_REGDOM_TYPE_COUNTRY: the regulatory domain set is one that pertains
+ * to a specific country. When this is set you can count on the
+ * ISO / IEC 3166 alpha2 country code being valid.
+ * @NL80211_REGDOM_TYPE_WORLD: the regulatory set domain is the world regulatory
+ * domain.
+ * @NL80211_REGDOM_TYPE_CUSTOM_WORLD: the regulatory domain set is a custom
+ * driver specific world regulatory domain. These do not apply system-wide
+ * and are only applicable to the individual devices which have requested
+ * them to be applied.
+ * @NL80211_REGDOM_TYPE_INTERSECTION: the regulatory domain set is the product
+ * of an intersection between two regulatory domains -- the previously
+ * set regulatory domain on the system and the last accepted regulatory
+ * domain request to be processed.
+ */
+enum nl80211_reg_type {
+ NL80211_REGDOM_TYPE_COUNTRY,
+ NL80211_REGDOM_TYPE_WORLD,
+ NL80211_REGDOM_TYPE_CUSTOM_WORLD,
+ NL80211_REGDOM_TYPE_INTERSECTION,
+};
+
+/**
+ * enum nl80211_reg_rule_attr - regulatory rule attributes
+ * @__NL80211_REG_RULE_ATTR_INVALID: attribute number 0 is reserved
+ * @NL80211_ATTR_REG_RULE_FLAGS: a set of flags which specify additional
+ * considerations for a given frequency range. These are the
+ * &enum nl80211_reg_rule_flags.
+ * @NL80211_ATTR_FREQ_RANGE_START: starting frequencry for the regulatory
+ * rule in KHz. This is not a center of frequency but an actual regulatory
+ * band edge.
+ * @NL80211_ATTR_FREQ_RANGE_END: ending frequency for the regulatory rule
+ * in KHz. This is not a center a frequency but an actual regulatory
+ * band edge.
+ * @NL80211_ATTR_FREQ_RANGE_MAX_BW: maximum allowed bandwidth for this
+ * frequency range, in KHz.
+ * @NL80211_ATTR_POWER_RULE_MAX_ANT_GAIN: the maximum allowed antenna gain
+ * for a given frequency range. The value is in mBi (100 * dBi).
+ * If you don't have one then don't send this.
+ * @NL80211_ATTR_POWER_RULE_MAX_EIRP: the maximum allowed EIRP for
+ * a given frequency range. The value is in mBm (100 * dBm).
+ * @NL80211_REG_RULE_ATTR_MAX: highest regulatory rule attribute number
+ * currently defined
+ * @__NL80211_REG_RULE_ATTR_AFTER_LAST: internal use
+ */
+enum nl80211_reg_rule_attr {
+ __NL80211_REG_RULE_ATTR_INVALID,
+ NL80211_ATTR_REG_RULE_FLAGS,
+
+ NL80211_ATTR_FREQ_RANGE_START,
+ NL80211_ATTR_FREQ_RANGE_END,
+ NL80211_ATTR_FREQ_RANGE_MAX_BW,
+
+ NL80211_ATTR_POWER_RULE_MAX_ANT_GAIN,
+ NL80211_ATTR_POWER_RULE_MAX_EIRP,
+
+ /* keep last */
+ __NL80211_REG_RULE_ATTR_AFTER_LAST,
+ NL80211_REG_RULE_ATTR_MAX = __NL80211_REG_RULE_ATTR_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_sched_scan_match_attr - scheduled scan match attributes
+ * @__NL80211_SCHED_SCAN_MATCH_ATTR_INVALID: attribute number 0 is reserved
+ * @NL80211_SCHED_SCAN_MATCH_ATTR_SSID: SSID to be used for matching,
+ * only report BSS with matching SSID.
+ * @NL80211_SCHED_SCAN_MATCH_ATTR_MAX: highest scheduled scan filter
+ * attribute number currently defined
+ * @__NL80211_SCHED_SCAN_MATCH_ATTR_AFTER_LAST: internal use
+ */
+enum nl80211_sched_scan_match_attr {
+ __NL80211_SCHED_SCAN_MATCH_ATTR_INVALID,
+
+ NL80211_ATTR_SCHED_SCAN_MATCH_SSID,
+
+ /* keep last */
+ __NL80211_SCHED_SCAN_MATCH_ATTR_AFTER_LAST,
+ NL80211_SCHED_SCAN_MATCH_ATTR_MAX =
+ __NL80211_SCHED_SCAN_MATCH_ATTR_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_reg_rule_flags - regulatory rule flags
+ *
+ * @NL80211_RRF_NO_OFDM: OFDM modulation not allowed
+ * @NL80211_RRF_NO_CCK: CCK modulation not allowed
+ * @NL80211_RRF_NO_INDOOR: indoor operation not allowed
+ * @NL80211_RRF_NO_OUTDOOR: outdoor operation not allowed
+ * @NL80211_RRF_DFS: DFS support is required to be used
+ * @NL80211_RRF_PTP_ONLY: this is only for Point To Point links
+ * @NL80211_RRF_PTMP_ONLY: this is only for Point To Multi Point links
+ * @NL80211_RRF_PASSIVE_SCAN: passive scan is required
+ * @NL80211_RRF_NO_IBSS: no IBSS is allowed
+ */
+enum nl80211_reg_rule_flags {
+ NL80211_RRF_NO_OFDM = 1<<0,
+ NL80211_RRF_NO_CCK = 1<<1,
+ NL80211_RRF_NO_INDOOR = 1<<2,
+ NL80211_RRF_NO_OUTDOOR = 1<<3,
+ NL80211_RRF_DFS = 1<<4,
+ NL80211_RRF_PTP_ONLY = 1<<5,
+ NL80211_RRF_PTMP_ONLY = 1<<6,
+ NL80211_RRF_PASSIVE_SCAN = 1<<7,
+ NL80211_RRF_NO_IBSS = 1<<8,
+};
+
+/**
+ * enum nl80211_dfs_regions - regulatory DFS regions
+ *
+ * @NL80211_DFS_UNSET: Country has no DFS master region specified
+ * @NL80211_DFS_FCC_: Country follows DFS master rules from FCC
+ * @NL80211_DFS_FCC_: Country follows DFS master rules from ETSI
+ * @NL80211_DFS_JP_: Country follows DFS master rules from JP/MKK/Telec
+ */
+enum nl80211_dfs_regions {
+ NL80211_DFS_UNSET = 0,
+ NL80211_DFS_FCC = 1,
+ NL80211_DFS_ETSI = 2,
+ NL80211_DFS_JP = 3,
+};
+
+/**
+ * enum nl80211_survey_info - survey information
+ *
+ * These attribute types are used with %NL80211_ATTR_SURVEY_INFO
+ * when getting information about a survey.
+ *
+ * @__NL80211_SURVEY_INFO_INVALID: attribute number 0 is reserved
+ * @NL80211_SURVEY_INFO_FREQUENCY: center frequency of channel
+ * @NL80211_SURVEY_INFO_NOISE: noise level of channel (u8, dBm)
+ * @NL80211_SURVEY_INFO_IN_USE: channel is currently being used
+ * @NL80211_SURVEY_INFO_CHANNEL_TIME: amount of time (in ms) that the radio
+ * spent on this channel
+ * @NL80211_SURVEY_INFO_CHANNEL_TIME_BUSY: amount of the time the primary
+ * channel was sensed busy (either due to activity or energy detect)
+ * @NL80211_SURVEY_INFO_CHANNEL_TIME_EXT_BUSY: amount of time the extension
+ * channel was sensed busy
+ * @NL80211_SURVEY_INFO_CHANNEL_TIME_RX: amount of time the radio spent
+ * receiving data
+ * @NL80211_SURVEY_INFO_CHANNEL_TIME_TX: amount of time the radio spent
+ * transmitting data
+ * @NL80211_SURVEY_INFO_MAX: highest survey info attribute number
+ * currently defined
+ * @__NL80211_SURVEY_INFO_AFTER_LAST: internal use
+ */
+enum nl80211_survey_info {
+ __NL80211_SURVEY_INFO_INVALID,
+ NL80211_SURVEY_INFO_FREQUENCY,
+ NL80211_SURVEY_INFO_NOISE,
+ NL80211_SURVEY_INFO_IN_USE,
+ NL80211_SURVEY_INFO_CHANNEL_TIME,
+ NL80211_SURVEY_INFO_CHANNEL_TIME_BUSY,
+ NL80211_SURVEY_INFO_CHANNEL_TIME_EXT_BUSY,
+ NL80211_SURVEY_INFO_CHANNEL_TIME_RX,
+ NL80211_SURVEY_INFO_CHANNEL_TIME_TX,
+
+ /* keep last */
+ __NL80211_SURVEY_INFO_AFTER_LAST,
+ NL80211_SURVEY_INFO_MAX = __NL80211_SURVEY_INFO_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_mntr_flags - monitor configuration flags
+ *
+ * Monitor configuration flags.
+ *
+ * @__NL80211_MNTR_FLAG_INVALID: reserved
+ *
+ * @NL80211_MNTR_FLAG_FCSFAIL: pass frames with bad FCS
+ * @NL80211_MNTR_FLAG_PLCPFAIL: pass frames with bad PLCP
+ * @NL80211_MNTR_FLAG_CONTROL: pass control frames
+ * @NL80211_MNTR_FLAG_OTHER_BSS: disable BSSID filtering
+ * @NL80211_MNTR_FLAG_COOK_FRAMES: report frames after processing.
+ * overrides all other flags.
+ *
+ * @__NL80211_MNTR_FLAG_AFTER_LAST: internal use
+ * @NL80211_MNTR_FLAG_MAX: highest possible monitor flag
+ */
+enum nl80211_mntr_flags {
+ __NL80211_MNTR_FLAG_INVALID,
+ NL80211_MNTR_FLAG_FCSFAIL,
+ NL80211_MNTR_FLAG_PLCPFAIL,
+ NL80211_MNTR_FLAG_CONTROL,
+ NL80211_MNTR_FLAG_OTHER_BSS,
+ NL80211_MNTR_FLAG_COOK_FRAMES,
+
+ /* keep last */
+ __NL80211_MNTR_FLAG_AFTER_LAST,
+ NL80211_MNTR_FLAG_MAX = __NL80211_MNTR_FLAG_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_meshconf_params - mesh configuration parameters
+ *
+ * Mesh configuration parameters. These can be changed while the mesh is
+ * active.
+ *
+ * @__NL80211_MESHCONF_INVALID: internal use
+ *
+ * @NL80211_MESHCONF_RETRY_TIMEOUT: specifies the initial retry timeout in
+ * millisecond units, used by the Peer Link Open message
+ *
+ * @NL80211_MESHCONF_CONFIRM_TIMEOUT: specifies the initial confirm timeout, in
+ * millisecond units, used by the peer link management to close a peer link
+ *
+ * @NL80211_MESHCONF_HOLDING_TIMEOUT: specifies the holding timeout, in
+ * millisecond units
+ *
+ * @NL80211_MESHCONF_MAX_PEER_LINKS: maximum number of peer links allowed
+ * on this mesh interface
+ *
+ * @NL80211_MESHCONF_MAX_RETRIES: specifies the maximum number of peer link
+ * open retries that can be sent to establish a new peer link instance in a
+ * mesh
+ *
+ * @NL80211_MESHCONF_TTL: specifies the value of TTL field set at a source mesh
+ * point.
+ *
+ * @NL80211_MESHCONF_AUTO_OPEN_PLINKS: whether we should automatically
+ * open peer links when we detect compatible mesh peers.
+ *
+ * @NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES: the number of action frames
+ * containing a PREQ that an MP can send to a particular destination (path
+ * target)
+ *
+ * @NL80211_MESHCONF_PATH_REFRESH_TIME: how frequently to refresh mesh paths
+ * (in milliseconds)
+ *
+ * @NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT: minimum length of time to wait
+ * until giving up on a path discovery (in milliseconds)
+ *
+ * @NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT: The time (in TUs) for which mesh
+ * points receiving a PREQ shall consider the forwarding information from the
+ * root to be valid. (TU = time unit)
+ *
+ * @NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL: The minimum interval of time (in
+ * TUs) during which an MP can send only one action frame containing a PREQ
+ * reference element
+ *
+ * @NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME: The interval of time (in TUs)
+ * that it takes for an HWMP information element to propagate across the mesh
+ *
+ * @NL80211_MESHCONF_HWMP_ROOTMODE: whether root mode is enabled or not
+ *
+ * @NL80211_MESHCONF_ELEMENT_TTL: specifies the value of TTL field set at a
+ * source mesh point for path selection elements.
+ *
+ * @NL80211_MESHCONF_HWMP_RANN_INTERVAL: The interval of time (in TUs) between
+ * root announcements are transmitted.
+ *
+ * @NL80211_MESHCONF_GATE_ANNOUNCEMENTS: Advertise that this mesh station has
+ * access to a broader network beyond the MBSS. This is done via Root
+ * Announcement frames.
+ *
+ * @NL80211_MESHCONF_HWMP_PERR_MIN_INTERVAL: The minimum interval of time (in
+ * TUs) during which a mesh STA can send only one Action frame containing a
+ * PERR element.
+ *
+ * @NL80211_MESHCONF_FORWARDING: set Mesh STA as forwarding or non-forwarding
+ * or forwarding entity (default is TRUE - forwarding entity)
+ *
+ * @NL80211_MESHCONF_ATTR_MAX: highest possible mesh configuration attribute
+ *
+ * @__NL80211_MESHCONF_ATTR_AFTER_LAST: internal use
+ */
+enum nl80211_meshconf_params {
+ __NL80211_MESHCONF_INVALID,
+ NL80211_MESHCONF_RETRY_TIMEOUT,
+ NL80211_MESHCONF_CONFIRM_TIMEOUT,
+ NL80211_MESHCONF_HOLDING_TIMEOUT,
+ NL80211_MESHCONF_MAX_PEER_LINKS,
+ NL80211_MESHCONF_MAX_RETRIES,
+ NL80211_MESHCONF_TTL,
+ NL80211_MESHCONF_AUTO_OPEN_PLINKS,
+ NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES,
+ NL80211_MESHCONF_PATH_REFRESH_TIME,
+ NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT,
+ NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT,
+ NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL,
+ NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME,
+ NL80211_MESHCONF_HWMP_ROOTMODE,
+ NL80211_MESHCONF_ELEMENT_TTL,
+ NL80211_MESHCONF_HWMP_RANN_INTERVAL,
+ NL80211_MESHCONF_GATE_ANNOUNCEMENTS,
+ NL80211_MESHCONF_HWMP_PERR_MIN_INTERVAL,
+ NL80211_MESHCONF_FORWARDING,
+
+ /* keep last */
+ __NL80211_MESHCONF_ATTR_AFTER_LAST,
+ NL80211_MESHCONF_ATTR_MAX = __NL80211_MESHCONF_ATTR_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_mesh_setup_params - mesh setup parameters
+ *
+ * Mesh setup parameters. These are used to start/join a mesh and cannot be
+ * changed while the mesh is active.
+ *
+ * @__NL80211_MESH_SETUP_INVALID: Internal use
+ *
+ * @NL80211_MESH_SETUP_ENABLE_VENDOR_PATH_SEL: Enable this option to use a
+ * vendor specific path selection algorithm or disable it to use the default
+ * HWMP.
+ *
+ * @NL80211_MESH_SETUP_ENABLE_VENDOR_METRIC: Enable this option to use a
+ * vendor specific path metric or disable it to use the default Airtime
+ * metric.
+ *
+ * @NL80211_MESH_SETUP_IE: Information elements for this mesh, for instance, a
+ * robust security network ie, or a vendor specific information element that
+ * vendors will use to identify the path selection methods and metrics in use.
+ *
+ * @NL80211_MESH_SETUP_USERSPACE_AUTH: Enable this option if an authentication
+ * daemon will be authenticating mesh candidates.
+ *
+ * @NL80211_MESH_SETUP_USERSPACE_AMPE: Enable this option if an authentication
+ * daemon will be securing peer link frames. AMPE is a secured version of Mesh
+ * Peering Management (MPM) and is implemented with the assistance of a
+ * userspace daemon. When this flag is set, the kernel will send peer
+ * management frames to a userspace daemon that will implement AMPE
+ * functionality (security capabilities selection, key confirmation, and key
+ * management). When the flag is unset (default), the kernel can autonomously
+ * complete (unsecured) mesh peering without the need of a userspace daemon.
+ *
+ * @NL80211_MESH_SETUP_ATTR_MAX: highest possible mesh setup attribute number
+ * @__NL80211_MESH_SETUP_ATTR_AFTER_LAST: Internal use
+ */
+enum nl80211_mesh_setup_params {
+ __NL80211_MESH_SETUP_INVALID,
+ NL80211_MESH_SETUP_ENABLE_VENDOR_PATH_SEL,
+ NL80211_MESH_SETUP_ENABLE_VENDOR_METRIC,
+ NL80211_MESH_SETUP_IE,
+ NL80211_MESH_SETUP_USERSPACE_AUTH,
+ NL80211_MESH_SETUP_USERSPACE_AMPE,
+
+ /* keep last */
+ __NL80211_MESH_SETUP_ATTR_AFTER_LAST,
+ NL80211_MESH_SETUP_ATTR_MAX = __NL80211_MESH_SETUP_ATTR_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_txq_attr - TX queue parameter attributes
+ * @__NL80211_TXQ_ATTR_INVALID: Attribute number 0 is reserved
+ * @NL80211_TXQ_ATTR_QUEUE: TX queue identifier (NL80211_TXQ_Q_*)
+ * @NL80211_TXQ_ATTR_TXOP: Maximum burst time in units of 32 usecs, 0 meaning
+ * disabled
+ * @NL80211_TXQ_ATTR_CWMIN: Minimum contention window [a value of the form
+ * 2^n-1 in the range 1..32767]
+ * @NL80211_TXQ_ATTR_CWMAX: Maximum contention window [a value of the form
+ * 2^n-1 in the range 1..32767]
+ * @NL80211_TXQ_ATTR_AIFS: Arbitration interframe space [0..255]
+ * @__NL80211_TXQ_ATTR_AFTER_LAST: Internal
+ * @NL80211_TXQ_ATTR_MAX: Maximum TXQ attribute number
+ */
+enum nl80211_txq_attr {
+ __NL80211_TXQ_ATTR_INVALID,
+ NL80211_TXQ_ATTR_QUEUE,
+ NL80211_TXQ_ATTR_TXOP,
+ NL80211_TXQ_ATTR_CWMIN,
+ NL80211_TXQ_ATTR_CWMAX,
+ NL80211_TXQ_ATTR_AIFS,
+
+ /* keep last */
+ __NL80211_TXQ_ATTR_AFTER_LAST,
+ NL80211_TXQ_ATTR_MAX = __NL80211_TXQ_ATTR_AFTER_LAST - 1
+};
+
+enum nl80211_txq_q {
+ NL80211_TXQ_Q_VO,
+ NL80211_TXQ_Q_VI,
+ NL80211_TXQ_Q_BE,
+ NL80211_TXQ_Q_BK
+};
+
+enum nl80211_channel_type {
+ NL80211_CHAN_NO_HT,
+ NL80211_CHAN_HT20,
+ NL80211_CHAN_HT40MINUS,
+ NL80211_CHAN_HT40PLUS
+};
+
+/**
+ * enum nl80211_bss - netlink attributes for a BSS
+ *
+ * @__NL80211_BSS_INVALID: invalid
+ * @NL80211_BSS_BSSID: BSSID of the BSS (6 octets)
+ * @NL80211_BSS_FREQUENCY: frequency in MHz (u32)
+ * @NL80211_BSS_TSF: TSF of the received probe response/beacon (u64)
+ * @NL80211_BSS_BEACON_INTERVAL: beacon interval of the (I)BSS (u16)
+ * @NL80211_BSS_CAPABILITY: capability field (CPU order, u16)
+ * @NL80211_BSS_INFORMATION_ELEMENTS: binary attribute containing the
+ * raw information elements from the probe response/beacon (bin);
+ * if the %NL80211_BSS_BEACON_IES attribute is present, the IEs here are
+ * from a Probe Response frame; otherwise they are from a Beacon frame.
+ * However, if the driver does not indicate the source of the IEs, these
+ * IEs may be from either frame subtype.
+ * @NL80211_BSS_SIGNAL_MBM: signal strength of probe response/beacon
+ * in mBm (100 * dBm) (s32)
+ * @NL80211_BSS_SIGNAL_UNSPEC: signal strength of the probe response/beacon
+ * in unspecified units, scaled to 0..100 (u8)
+ * @NL80211_BSS_STATUS: status, if this BSS is "used"
+ * @NL80211_BSS_SEEN_MS_AGO: age of this BSS entry in ms
+ * @NL80211_BSS_BEACON_IES: binary attribute containing the raw information
+ * elements from a Beacon frame (bin); not present if no Beacon frame has
+ * yet been received
+ * @__NL80211_BSS_AFTER_LAST: internal
+ * @NL80211_BSS_MAX: highest BSS attribute
+ */
+enum nl80211_bss {
+ __NL80211_BSS_INVALID,
+ NL80211_BSS_BSSID,
+ NL80211_BSS_FREQUENCY,
+ NL80211_BSS_TSF,
+ NL80211_BSS_BEACON_INTERVAL,
+ NL80211_BSS_CAPABILITY,
+ NL80211_BSS_INFORMATION_ELEMENTS,
+ NL80211_BSS_SIGNAL_MBM,
+ NL80211_BSS_SIGNAL_UNSPEC,
+ NL80211_BSS_STATUS,
+ NL80211_BSS_SEEN_MS_AGO,
+ NL80211_BSS_BEACON_IES,
+
+ /* keep last */
+ __NL80211_BSS_AFTER_LAST,
+ NL80211_BSS_MAX = __NL80211_BSS_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_bss_status - BSS "status"
+ * @NL80211_BSS_STATUS_AUTHENTICATED: Authenticated with this BSS.
+ * @NL80211_BSS_STATUS_ASSOCIATED: Associated with this BSS.
+ * @NL80211_BSS_STATUS_IBSS_JOINED: Joined to this IBSS.
+ *
+ * The BSS status is a BSS attribute in scan dumps, which
+ * indicates the status the interface has wrt. this BSS.
+ */
+enum nl80211_bss_status {
+ NL80211_BSS_STATUS_AUTHENTICATED,
+ NL80211_BSS_STATUS_ASSOCIATED,
+ NL80211_BSS_STATUS_IBSS_JOINED,
+};
+
+/**
+ * enum nl80211_auth_type - AuthenticationType
+ *
+ * @NL80211_AUTHTYPE_OPEN_SYSTEM: Open System authentication
+ * @NL80211_AUTHTYPE_SHARED_KEY: Shared Key authentication (WEP only)
+ * @NL80211_AUTHTYPE_FT: Fast BSS Transition (IEEE 802.11r)
+ * @NL80211_AUTHTYPE_NETWORK_EAP: Network EAP (some Cisco APs and mainly LEAP)
+ * @__NL80211_AUTHTYPE_NUM: internal
+ * @NL80211_AUTHTYPE_MAX: maximum valid auth algorithm
+ * @NL80211_AUTHTYPE_AUTOMATIC: determine automatically (if necessary by
+ * trying multiple times); this is invalid in netlink -- leave out
+ * the attribute for this on CONNECT commands.
+ */
+enum nl80211_auth_type {
+ NL80211_AUTHTYPE_OPEN_SYSTEM,
+ NL80211_AUTHTYPE_SHARED_KEY,
+ NL80211_AUTHTYPE_FT,
+ NL80211_AUTHTYPE_NETWORK_EAP,
+
+ /* keep last */
+ __NL80211_AUTHTYPE_NUM,
+ NL80211_AUTHTYPE_MAX = __NL80211_AUTHTYPE_NUM - 1,
+ NL80211_AUTHTYPE_AUTOMATIC
+};
+
+/**
+ * enum nl80211_key_type - Key Type
+ * @NL80211_KEYTYPE_GROUP: Group (broadcast/multicast) key
+ * @NL80211_KEYTYPE_PAIRWISE: Pairwise (unicast/individual) key
+ * @NL80211_KEYTYPE_PEERKEY: PeerKey (DLS)
+ * @NUM_NL80211_KEYTYPES: number of defined key types
+ */
+enum nl80211_key_type {
+ NL80211_KEYTYPE_GROUP,
+ NL80211_KEYTYPE_PAIRWISE,
+ NL80211_KEYTYPE_PEERKEY,
+
+ NUM_NL80211_KEYTYPES
+};
+
+/**
+ * enum nl80211_mfp - Management frame protection state
+ * @NL80211_MFP_NO: Management frame protection not used
+ * @NL80211_MFP_REQUIRED: Management frame protection required
+ */
+enum nl80211_mfp {
+ NL80211_MFP_NO,
+ NL80211_MFP_REQUIRED,
+};
+
+enum nl80211_wpa_versions {
+ NL80211_WPA_VERSION_1 = 1 << 0,
+ NL80211_WPA_VERSION_2 = 1 << 1,
+};
+
+/**
+ * enum nl80211_key_default_types - key default types
+ * @__NL80211_KEY_DEFAULT_TYPE_INVALID: invalid
+ * @NL80211_KEY_DEFAULT_TYPE_UNICAST: key should be used as default
+ * unicast key
+ * @NL80211_KEY_DEFAULT_TYPE_MULTICAST: key should be used as default
+ * multicast key
+ * @NUM_NL80211_KEY_DEFAULT_TYPES: number of default types
+ */
+enum nl80211_key_default_types {
+ __NL80211_KEY_DEFAULT_TYPE_INVALID,
+ NL80211_KEY_DEFAULT_TYPE_UNICAST,
+ NL80211_KEY_DEFAULT_TYPE_MULTICAST,
+
+ NUM_NL80211_KEY_DEFAULT_TYPES
+};
+
+/**
+ * enum nl80211_key_attributes - key attributes
+ * @__NL80211_KEY_INVALID: invalid
+ * @NL80211_KEY_DATA: (temporal) key data; for TKIP this consists of
+ * 16 bytes encryption key followed by 8 bytes each for TX and RX MIC
+ * keys
+ * @NL80211_KEY_IDX: key ID (u8, 0-3)
+ * @NL80211_KEY_CIPHER: key cipher suite (u32, as defined by IEEE 802.11
+ * section 7.3.2.25.1, e.g. 0x000FAC04)
+ * @NL80211_KEY_SEQ: transmit key sequence number (IV/PN) for TKIP and
+ * CCMP keys, each six bytes in little endian
+ * @NL80211_KEY_DEFAULT: flag indicating default key
+ * @NL80211_KEY_DEFAULT_MGMT: flag indicating default management key
+ * @NL80211_KEY_TYPE: the key type from enum nl80211_key_type, if not
+ * specified the default depends on whether a MAC address was
+ * given with the command using the key or not (u32)
+ * @NL80211_KEY_DEFAULT_TYPES: A nested attribute containing flags
+ * attributes, specifying what a key should be set as default as.
+ * See &enum nl80211_key_default_types.
+ * @__NL80211_KEY_AFTER_LAST: internal
+ * @NL80211_KEY_MAX: highest key attribute
+ */
+enum nl80211_key_attributes {
+ __NL80211_KEY_INVALID,
+ NL80211_KEY_DATA,
+ NL80211_KEY_IDX,
+ NL80211_KEY_CIPHER,
+ NL80211_KEY_SEQ,
+ NL80211_KEY_DEFAULT,
+ NL80211_KEY_DEFAULT_MGMT,
+ NL80211_KEY_TYPE,
+ NL80211_KEY_DEFAULT_TYPES,
+
+ /* keep last */
+ __NL80211_KEY_AFTER_LAST,
+ NL80211_KEY_MAX = __NL80211_KEY_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_tx_rate_attributes - TX rate set attributes
+ * @__NL80211_TXRATE_INVALID: invalid
+ * @NL80211_TXRATE_LEGACY: Legacy (non-MCS) rates allowed for TX rate selection
+ * in an array of rates as defined in IEEE 802.11 7.3.2.2 (u8 values with
+ * 1 = 500 kbps) but without the IE length restriction (at most
+ * %NL80211_MAX_SUPP_RATES in a single array).
+ * @NL80211_TXRATE_MCS: HT (MCS) rates allowed for TX rate selection
+ * in an array of MCS numbers.
+ * @__NL80211_TXRATE_AFTER_LAST: internal
+ * @NL80211_TXRATE_MAX: highest TX rate attribute
+ */
+enum nl80211_tx_rate_attributes {
+ __NL80211_TXRATE_INVALID,
+ NL80211_TXRATE_LEGACY,
+ NL80211_TXRATE_MCS,
+
+ /* keep last */
+ __NL80211_TXRATE_AFTER_LAST,
+ NL80211_TXRATE_MAX = __NL80211_TXRATE_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_band - Frequency band
+ * @NL80211_BAND_2GHZ: 2.4 GHz ISM band
+ * @NL80211_BAND_5GHZ: around 5 GHz band (4.9 - 5.7 GHz)
+ */
+enum nl80211_band {
+ NL80211_BAND_2GHZ,
+ NL80211_BAND_5GHZ,
+};
+
+enum nl80211_ps_state {
+ NL80211_PS_DISABLED,
+ NL80211_PS_ENABLED,
+};
+
+/**
+ * enum nl80211_attr_cqm - connection quality monitor attributes
+ * @__NL80211_ATTR_CQM_INVALID: invalid
+ * @NL80211_ATTR_CQM_RSSI_THOLD: RSSI threshold in dBm. This value specifies
+ * the threshold for the RSSI level at which an event will be sent. Zero
+ * to disable.
+ * @NL80211_ATTR_CQM_RSSI_HYST: RSSI hysteresis in dBm. This value specifies
+ * the minimum amount the RSSI level must change after an event before a
+ * new event may be issued (to reduce effects of RSSI oscillation).
+ * @NL80211_ATTR_CQM_RSSI_THRESHOLD_EVENT: RSSI threshold event
+ * @NL80211_ATTR_CQM_PKT_LOSS_EVENT: a u32 value indicating that this many
+ * consecutive packets were not acknowledged by the peer
+ * @__NL80211_ATTR_CQM_AFTER_LAST: internal
+ * @NL80211_ATTR_CQM_MAX: highest key attribute
+ */
+enum nl80211_attr_cqm {
+ __NL80211_ATTR_CQM_INVALID,
+ NL80211_ATTR_CQM_RSSI_THOLD,
+ NL80211_ATTR_CQM_RSSI_HYST,
+ NL80211_ATTR_CQM_RSSI_THRESHOLD_EVENT,
+ NL80211_ATTR_CQM_PKT_LOSS_EVENT,
+
+ /* keep last */
+ __NL80211_ATTR_CQM_AFTER_LAST,
+ NL80211_ATTR_CQM_MAX = __NL80211_ATTR_CQM_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_cqm_rssi_threshold_event - RSSI threshold event
+ * @NL80211_CQM_RSSI_THRESHOLD_EVENT_LOW: The RSSI level is lower than the
+ * configured threshold
+ * @NL80211_CQM_RSSI_THRESHOLD_EVENT_HIGH: The RSSI is higher than the
+ * configured threshold
+ */
+enum nl80211_cqm_rssi_threshold_event {
+ NL80211_CQM_RSSI_THRESHOLD_EVENT_LOW,
+ NL80211_CQM_RSSI_THRESHOLD_EVENT_HIGH,
+};
+
+
+/**
+ * enum nl80211_tx_power_setting - TX power adjustment
+ * @NL80211_TX_POWER_AUTOMATIC: automatically determine transmit power
+ * @NL80211_TX_POWER_LIMITED: limit TX power by the mBm parameter
+ * @NL80211_TX_POWER_FIXED: fix TX power to the mBm parameter
+ */
+enum nl80211_tx_power_setting {
+ NL80211_TX_POWER_AUTOMATIC,
+ NL80211_TX_POWER_LIMITED,
+ NL80211_TX_POWER_FIXED,
+};
+
+/**
+ * enum nl80211_wowlan_packet_pattern_attr - WoWLAN packet pattern attribute
+ * @__NL80211_WOWLAN_PKTPAT_INVALID: invalid number for nested attribute
+ * @NL80211_WOWLAN_PKTPAT_PATTERN: the pattern, values where the mask has
+ * a zero bit are ignored
+ * @NL80211_WOWLAN_PKTPAT_MASK: pattern mask, must be long enough to have
+ * a bit for each byte in the pattern. The lowest-order bit corresponds
+ * to the first byte of the pattern, but the bytes of the pattern are
+ * in a little-endian-like format, i.e. the 9th byte of the pattern
+ * corresponds to the lowest-order bit in the second byte of the mask.
+ * For example: The match 00:xx:00:00:xx:00:00:00:00:xx:xx:xx (where
+ * xx indicates "don't care") would be represented by a pattern of
+ * twelve zero bytes, and a mask of "0xed,0x07".
+ * Note that the pattern matching is done as though frames were not
+ * 802.11 frames but 802.3 frames, i.e. the frame is fully unpacked
+ * first (including SNAP header unpacking) and then matched.
+ * @NUM_NL80211_WOWLAN_PKTPAT: number of attributes
+ * @MAX_NL80211_WOWLAN_PKTPAT: max attribute number
+ */
+enum nl80211_wowlan_packet_pattern_attr {
+ __NL80211_WOWLAN_PKTPAT_INVALID,
+ NL80211_WOWLAN_PKTPAT_MASK,
+ NL80211_WOWLAN_PKTPAT_PATTERN,
+
+ NUM_NL80211_WOWLAN_PKTPAT,
+ MAX_NL80211_WOWLAN_PKTPAT = NUM_NL80211_WOWLAN_PKTPAT - 1,
+};
+
+/**
+ * struct nl80211_wowlan_pattern_support - pattern support information
+ * @max_patterns: maximum number of patterns supported
+ * @min_pattern_len: minimum length of each pattern
+ * @max_pattern_len: maximum length of each pattern
+ *
+ * This struct is carried in %NL80211_WOWLAN_TRIG_PKT_PATTERN when
+ * that is part of %NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED in the
+ * capability information given by the kernel to userspace.
+ */
+struct nl80211_wowlan_pattern_support {
+ __u32 max_patterns;
+ __u32 min_pattern_len;
+ __u32 max_pattern_len;
+} __attribute__((packed));
+
+/**
+ * enum nl80211_wowlan_triggers - WoWLAN trigger definitions
+ * @__NL80211_WOWLAN_TRIG_INVALID: invalid number for nested attributes
+ * @NL80211_WOWLAN_TRIG_ANY: wake up on any activity, do not really put
+ * the chip into a special state -- works best with chips that have
+ * support for low-power operation already (flag)
+ * @NL80211_WOWLAN_TRIG_DISCONNECT: wake up on disconnect, the way disconnect
+ * is detected is implementation-specific (flag)
+ * @NL80211_WOWLAN_TRIG_MAGIC_PKT: wake up on magic packet (6x 0xff, followed
+ * by 16 repetitions of MAC addr, anywhere in payload) (flag)
+ * @NL80211_WOWLAN_TRIG_PKT_PATTERN: wake up on the specified packet patterns
+ * which are passed in an array of nested attributes, each nested attribute
+ * defining a with attributes from &struct nl80211_wowlan_trig_pkt_pattern.
+ * Each pattern defines a wakeup packet. The matching is done on the MSDU,
+ * i.e. as though the packet was an 802.3 packet, so the pattern matching
+ * is done after the packet is converted to the MSDU.
+ *
+ * In %NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED, it is a binary attribute
+ * carrying a &struct nl80211_wowlan_pattern_support.
+ * @NL80211_WOWLAN_TRIG_GTK_REKEY_SUPPORTED: Not a real trigger, and cannot be
+ * used when setting, used only to indicate that GTK rekeying is supported
+ * by the device (flag)
+ * @NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE: wake up on GTK rekey failure (if
+ * done by the device) (flag)
+ * @NL80211_WOWLAN_TRIG_EAP_IDENT_REQUEST: wake up on EAP Identity Request
+ * packet (flag)
+ * @NL80211_WOWLAN_TRIG_4WAY_HANDSHAKE: wake up on 4-way handshake (flag)
+ * @NL80211_WOWLAN_TRIG_RFKILL_RELEASE: wake up when rfkill is released
+ * (on devices that have rfkill in the device) (flag)
+ * @NUM_NL80211_WOWLAN_TRIG: number of wake on wireless triggers
+ * @MAX_NL80211_WOWLAN_TRIG: highest wowlan trigger attribute number
+ */
+enum nl80211_wowlan_triggers {
+ __NL80211_WOWLAN_TRIG_INVALID,
+ NL80211_WOWLAN_TRIG_ANY,
+ NL80211_WOWLAN_TRIG_DISCONNECT,
+ NL80211_WOWLAN_TRIG_MAGIC_PKT,
+ NL80211_WOWLAN_TRIG_PKT_PATTERN,
+ NL80211_WOWLAN_TRIG_GTK_REKEY_SUPPORTED,
+ NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE,
+ NL80211_WOWLAN_TRIG_EAP_IDENT_REQUEST,
+ NL80211_WOWLAN_TRIG_4WAY_HANDSHAKE,
+ NL80211_WOWLAN_TRIG_RFKILL_RELEASE,
+
+ /* keep last */
+ NUM_NL80211_WOWLAN_TRIG,
+ MAX_NL80211_WOWLAN_TRIG = NUM_NL80211_WOWLAN_TRIG - 1
+};
+
+/**
+ * enum nl80211_iface_limit_attrs - limit attributes
+ * @NL80211_IFACE_LIMIT_UNSPEC: (reserved)
+ * @NL80211_IFACE_LIMIT_MAX: maximum number of interfaces that
+ * can be chosen from this set of interface types (u32)
+ * @NL80211_IFACE_LIMIT_TYPES: nested attribute containing a
+ * flag attribute for each interface type in this set
+ * @NUM_NL80211_IFACE_LIMIT: number of attributes
+ * @MAX_NL80211_IFACE_LIMIT: highest attribute number
+ */
+enum nl80211_iface_limit_attrs {
+ NL80211_IFACE_LIMIT_UNSPEC,
+ NL80211_IFACE_LIMIT_MAX,
+ NL80211_IFACE_LIMIT_TYPES,
+
+ /* keep last */
+ NUM_NL80211_IFACE_LIMIT,
+ MAX_NL80211_IFACE_LIMIT = NUM_NL80211_IFACE_LIMIT - 1
+};
+
+/**
+ * enum nl80211_if_combination_attrs -- interface combination attributes
+ *
+ * @NL80211_IFACE_COMB_UNSPEC: (reserved)
+ * @NL80211_IFACE_COMB_LIMITS: Nested attributes containing the limits
+ * for given interface types, see &enum nl80211_iface_limit_attrs.
+ * @NL80211_IFACE_COMB_MAXNUM: u32 attribute giving the total number of
+ * interfaces that can be created in this group. This number doesn't
+ * apply to interfaces purely managed in software, which are listed
+ * in a separate attribute %NL80211_ATTR_INTERFACES_SOFTWARE.
+ * @NL80211_IFACE_COMB_STA_AP_BI_MATCH: flag attribute specifying that
+ * beacon intervals within this group must be all the same even for
+ * infrastructure and AP/GO combinations, i.e. the GO(s) must adopt
+ * the infrastructure network's beacon interval.
+ * @NL80211_IFACE_COMB_NUM_CHANNELS: u32 attribute specifying how many
+ * different channels may be used within this group.
+ * @NUM_NL80211_IFACE_COMB: number of attributes
+ * @MAX_NL80211_IFACE_COMB: highest attribute number
+ *
+ * Examples:
+ * limits = [ #{STA} <= 1, #{AP} <= 1 ], matching BI, channels = 1, max = 2
+ * => allows an AP and a STA that must match BIs
+ *
+ * numbers = [ #{AP, P2P-GO} <= 8 ], channels = 1, max = 8
+ * => allows 8 of AP/GO
+ *
+ * numbers = [ #{STA} <= 2 ], channels = 2, max = 2
+ * => allows two STAs on different channels
+ *
+ * numbers = [ #{STA} <= 1, #{P2P-client,P2P-GO} <= 3 ], max = 4
+ * => allows a STA plus three P2P interfaces
+ *
+ * The list of these four possiblities could completely be contained
+ * within the %NL80211_ATTR_INTERFACE_COMBINATIONS attribute to indicate
+ * that any of these groups must match.
+ *
+ * "Combinations" of just a single interface will not be listed here,
+ * a single interface of any valid interface type is assumed to always
+ * be possible by itself. This means that implicitly, for each valid
+ * interface type, the following group always exists:
+ * numbers = [ #{<type>} <= 1 ], channels = 1, max = 1
+ */
+enum nl80211_if_combination_attrs {
+ NL80211_IFACE_COMB_UNSPEC,
+ NL80211_IFACE_COMB_LIMITS,
+ NL80211_IFACE_COMB_MAXNUM,
+ NL80211_IFACE_COMB_STA_AP_BI_MATCH,
+ NL80211_IFACE_COMB_NUM_CHANNELS,
+
+ /* keep last */
+ NUM_NL80211_IFACE_COMB,
+ MAX_NL80211_IFACE_COMB = NUM_NL80211_IFACE_COMB - 1
+};
+
+
+/**
+ * enum nl80211_plink_state - state of a mesh peer link finite state machine
+ *
+ * @NL80211_PLINK_LISTEN: initial state, considered the implicit
+ * state of non existant mesh peer links
+ * @NL80211_PLINK_OPN_SNT: mesh plink open frame has been sent to
+ * this mesh peer
+ * @NL80211_PLINK_OPN_RCVD: mesh plink open frame has been received
+ * from this mesh peer
+ * @NL80211_PLINK_CNF_RCVD: mesh plink confirm frame has been
+ * received from this mesh peer
+ * @NL80211_PLINK_ESTAB: mesh peer link is established
+ * @NL80211_PLINK_HOLDING: mesh peer link is being closed or cancelled
+ * @NL80211_PLINK_BLOCKED: all frames transmitted from this mesh
+ * plink are discarded
+ * @NUM_NL80211_PLINK_STATES: number of peer link states
+ * @MAX_NL80211_PLINK_STATES: highest numerical value of plink states
+ */
+enum nl80211_plink_state {
+ NL80211_PLINK_LISTEN,
+ NL80211_PLINK_OPN_SNT,
+ NL80211_PLINK_OPN_RCVD,
+ NL80211_PLINK_CNF_RCVD,
+ NL80211_PLINK_ESTAB,
+ NL80211_PLINK_HOLDING,
+ NL80211_PLINK_BLOCKED,
+
+ /* keep last */
+ NUM_NL80211_PLINK_STATES,
+ MAX_NL80211_PLINK_STATES = NUM_NL80211_PLINK_STATES - 1
+};
+
+#define NL80211_KCK_LEN 16
+#define NL80211_KEK_LEN 16
+#define NL80211_REPLAY_CTR_LEN 8
+
+/**
+ * enum nl80211_rekey_data - attributes for GTK rekey offload
+ * @__NL80211_REKEY_DATA_INVALID: invalid number for nested attributes
+ * @NL80211_REKEY_DATA_KEK: key encryption key (binary)
+ * @NL80211_REKEY_DATA_KCK: key confirmation key (binary)
+ * @NL80211_REKEY_DATA_REPLAY_CTR: replay counter (binary)
+ * @NUM_NL80211_REKEY_DATA: number of rekey attributes (internal)
+ * @MAX_NL80211_REKEY_DATA: highest rekey attribute (internal)
+ */
+enum nl80211_rekey_data {
+ __NL80211_REKEY_DATA_INVALID,
+ NL80211_REKEY_DATA_KEK,
+ NL80211_REKEY_DATA_KCK,
+ NL80211_REKEY_DATA_REPLAY_CTR,
+
+ /* keep last */
+ NUM_NL80211_REKEY_DATA,
+ MAX_NL80211_REKEY_DATA = NUM_NL80211_REKEY_DATA - 1
+};
+
+/**
+ * enum nl80211_hidden_ssid - values for %NL80211_ATTR_HIDDEN_SSID
+ * @NL80211_HIDDEN_SSID_NOT_IN_USE: do not hide SSID (i.e., broadcast it in
+ * Beacon frames)
+ * @NL80211_HIDDEN_SSID_ZERO_LEN: hide SSID by using zero-length SSID element
+ * in Beacon frames
+ * @NL80211_HIDDEN_SSID_ZERO_CONTENTS: hide SSID by using correct length of SSID
+ * element in Beacon frames but zero out each byte in the SSID
+ */
+enum nl80211_hidden_ssid {
+ NL80211_HIDDEN_SSID_NOT_IN_USE,
+ NL80211_HIDDEN_SSID_ZERO_LEN,
+ NL80211_HIDDEN_SSID_ZERO_CONTENTS
+};
+
+/**
+ * enum nl80211_sta_wme_attr - station WME attributes
+ * @__NL80211_STA_WME_INVALID: invalid number for nested attribute
+ * @NL80211_STA_WME_UAPSD_QUEUES: bitmap of uapsd queues. the format
+ * is the same as the AC bitmap in the QoS info field.
+ * @NL80211_STA_WME_MAX_SP: max service period. the format is the same
+ * as the MAX_SP field in the QoS info field (but already shifted down).
+ * @__NL80211_STA_WME_AFTER_LAST: internal
+ * @NL80211_STA_WME_MAX: highest station WME attribute
+ */
+enum nl80211_sta_wme_attr {
+ __NL80211_STA_WME_INVALID,
+ NL80211_STA_WME_UAPSD_QUEUES,
+ NL80211_STA_WME_MAX_SP,
+
+ /* keep last */
+ __NL80211_STA_WME_AFTER_LAST,
+ NL80211_STA_WME_MAX = __NL80211_STA_WME_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_pmksa_candidate_attr - attributes for PMKSA caching candidates
+ * @__NL80211_PMKSA_CANDIDATE_INVALID: invalid number for nested attributes
+ * @NL80211_PMKSA_CANDIDATE_INDEX: candidate index (u32; the smaller, the higher
+ * priority)
+ * @NL80211_PMKSA_CANDIDATE_BSSID: candidate BSSID (6 octets)
+ * @NL80211_PMKSA_CANDIDATE_PREAUTH: RSN pre-authentication supported (flag)
+ * @NUM_NL80211_PMKSA_CANDIDATE: number of PMKSA caching candidate attributes
+ * (internal)
+ * @MAX_NL80211_PMKSA_CANDIDATE: highest PMKSA caching candidate attribute
+ * (internal)
+ */
+enum nl80211_pmksa_candidate_attr {
+ __NL80211_PMKSA_CANDIDATE_INVALID,
+ NL80211_PMKSA_CANDIDATE_INDEX,
+ NL80211_PMKSA_CANDIDATE_BSSID,
+ NL80211_PMKSA_CANDIDATE_PREAUTH,
+
+ /* keep last */
+ NUM_NL80211_PMKSA_CANDIDATE,
+ MAX_NL80211_PMKSA_CANDIDATE = NUM_NL80211_PMKSA_CANDIDATE - 1
+};
+
+/**
+ * enum nl80211_tdls_operation - values for %NL80211_ATTR_TDLS_OPERATION
+ * @NL80211_TDLS_DISCOVERY_REQ: Send a TDLS discovery request
+ * @NL80211_TDLS_SETUP: Setup TDLS link
+ * @NL80211_TDLS_TEARDOWN: Teardown a TDLS link which is already established
+ * @NL80211_TDLS_ENABLE_LINK: Enable TDLS link
+ * @NL80211_TDLS_DISABLE_LINK: Disable TDLS link
+ */
+enum nl80211_tdls_operation {
+ NL80211_TDLS_DISCOVERY_REQ,
+ NL80211_TDLS_SETUP,
+ NL80211_TDLS_TEARDOWN,
+ NL80211_TDLS_ENABLE_LINK,
+ NL80211_TDLS_DISABLE_LINK,
+};
+
+/*
+ * enum nl80211_ap_sme_features - device-integrated AP features
+ * Reserved for future use, no bits are defined in
+ * NL80211_ATTR_DEVICE_AP_SME yet.
+enum nl80211_ap_sme_features {
+};
+ */
+
+/**
+ * enum nl80211_feature_flags - device/driver features
+ * @NL80211_FEATURE_SK_TX_STATUS: This driver supports reflecting back
+ * TX status to the socket error queue when requested with the
+ * socket option.
+ * @NL80211_FEATURE_HT_IBSS: This driver supports IBSS with HT datarates.
+ */
+enum nl80211_feature_flags {
+ NL80211_FEATURE_SK_TX_STATUS = 1 << 0,
+ NL80211_FEATURE_HT_IBSS = 1 << 1,
+};
+
+/**
+ * enum nl80211_probe_resp_offload_support_attr - optional supported
+ * protocols for probe-response offloading by the driver/FW.
+ * To be used with the %NL80211_ATTR_PROBE_RESP_OFFLOAD attribute.
+ * Each enum value represents a bit in the bitmap of supported
+ * protocols. Typically a subset of probe-requests belonging to a
+ * supported protocol will be excluded from offload and uploaded
+ * to the host.
+ *
+ * @NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS: Support for WPS ver. 1
+ * @NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2: Support for WPS ver. 2
+ * @NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P: Support for P2P
+ * @NL80211_PROBE_RESP_OFFLOAD_SUPPORT_80211U: Support for 802.11u
+ */
+enum nl80211_probe_resp_offload_support_attr {
+ NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS = 1<<0,
+ NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2 = 1<<1,
+ NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P = 1<<2,
+ NL80211_PROBE_RESP_OFFLOAD_SUPPORT_80211U = 1<<3,
+};
+
+#endif /* __LINUX_NL80211_H */
diff --git a/package/network/utils/iwinfo/src/include/iwinfo/api/.svn/text-base/wext.h.svn-base b/package/network/utils/iwinfo/src/include/iwinfo/api/.svn/text-base/wext.h.svn-base
new file mode 100644
index 0000000..6b5838e
--- /dev/null
+++ b/package/network/utils/iwinfo/src/include/iwinfo/api/.svn/text-base/wext.h.svn-base
@@ -0,0 +1,1139 @@
+/*
+ * This file define a set of standard wireless extensions
+ *
+ * Version : 22 16.3.07
+ *
+ * Authors : Jean Tourrilhes - HPL - <jt@hpl.hp.com>
+ * Copyright (c) 1997-2007 Jean Tourrilhes, All Rights Reserved.
+ */
+
+#ifndef _LINUX_WIRELESS_H
+#define _LINUX_WIRELESS_H
+
+/************************** DOCUMENTATION **************************/
+/*
+ * Initial APIs (1996 -> onward) :
+ * -----------------------------
+ * Basically, the wireless extensions are for now a set of standard ioctl
+ * call + /proc/net/wireless
+ *
+ * The entry /proc/net/wireless give statistics and information on the
+ * driver.
+ * This is better than having each driver having its entry because
+ * its centralised and we may remove the driver module safely.
+ *
+ * Ioctl are used to configure the driver and issue commands. This is
+ * better than command line options of insmod because we may want to
+ * change dynamically (while the driver is running) some parameters.
+ *
+ * The ioctl mechanimsm are copied from standard devices ioctl.
+ * We have the list of command plus a structure descibing the
+ * data exchanged...
+ * Note that to add these ioctl, I was obliged to modify :
+ * # net/core/dev.c (two place + add include)
+ * # net/ipv4/af_inet.c (one place + add include)
+ *
+ * /proc/net/wireless is a copy of /proc/net/dev.
+ * We have a structure for data passed from the driver to /proc/net/wireless
+ * Too add this, I've modified :
+ * # net/core/dev.c (two other places)
+ * # include/linux/netdevice.h (one place)
+ * # include/linux/proc_fs.h (one place)
+ *
+ * New driver API (2002 -> onward) :
+ * -------------------------------
+ * This file is only concerned with the user space API and common definitions.
+ * The new driver API is defined and documented in :
+ * # include/net/iw_handler.h
+ *
+ * Note as well that /proc/net/wireless implementation has now moved in :
+ * # net/core/wireless.c
+ *
+ * Wireless Events (2002 -> onward) :
+ * --------------------------------
+ * Events are defined at the end of this file, and implemented in :
+ * # net/core/wireless.c
+ *
+ * Other comments :
+ * --------------
+ * Do not add here things that are redundant with other mechanisms
+ * (drivers init, ifconfig, /proc/net/dev, ...) and with are not
+ * wireless specific.
+ *
+ * These wireless extensions are not magic : each driver has to provide
+ * support for them...
+ *
+ * IMPORTANT NOTE : As everything in the kernel, this is very much a
+ * work in progress. Contact me if you have ideas of improvements...
+ */
+
+/***************************** INCLUDES *****************************/
+
+/* This header is used in user-space, therefore need to be sanitised
+ * for that purpose. Those includes are usually not compatible with glibc.
+ * To know which includes to use in user-space, check iwlib.h. */
+#ifdef __KERNEL__
+#include <linux/types.h> /* for "caddr_t" et al */
+#include <linux/socket.h> /* for "struct sockaddr" et al */
+#include <linux/if.h> /* for IFNAMSIZ and co... */
+#endif /* __KERNEL__ */
+
+/***************************** VERSION *****************************/
+/*
+ * This constant is used to know the availability of the wireless
+ * extensions and to know which version of wireless extensions it is
+ * (there is some stuff that will be added in the future...)
+ * I just plan to increment with each new version.
+ */
+#define WIRELESS_EXT 22
+
+/*
+ * Changes :
+ *
+ * V2 to V3
+ * --------
+ * Alan Cox start some incompatibles changes. I've integrated a bit more.
+ * - Encryption renamed to Encode to avoid US regulation problems
+ * - Frequency changed from float to struct to avoid problems on old 386
+ *
+ * V3 to V4
+ * --------
+ * - Add sensitivity
+ *
+ * V4 to V5
+ * --------
+ * - Missing encoding definitions in range
+ * - Access points stuff
+ *
+ * V5 to V6
+ * --------
+ * - 802.11 support (ESSID ioctls)
+ *
+ * V6 to V7
+ * --------
+ * - define IW_ESSID_MAX_SIZE and IW_MAX_AP
+ *
+ * V7 to V8
+ * --------
+ * - Changed my e-mail address
+ * - More 802.11 support (nickname, rate, rts, frag)
+ * - List index in frequencies
+ *
+ * V8 to V9
+ * --------
+ * - Support for 'mode of operation' (ad-hoc, managed...)
+ * - Support for unicast and multicast power saving
+ * - Change encoding to support larger tokens (>64 bits)
+ * - Updated iw_params (disable, flags) and use it for NWID
+ * - Extracted iw_point from iwreq for clarity
+ *
+ * V9 to V10
+ * ---------
+ * - Add PM capability to range structure
+ * - Add PM modifier : MAX/MIN/RELATIVE
+ * - Add encoding option : IW_ENCODE_NOKEY
+ * - Add TxPower ioctls (work like TxRate)
+ *
+ * V10 to V11
+ * ----------
+ * - Add WE version in range (help backward/forward compatibility)
+ * - Add retry ioctls (work like PM)
+ *
+ * V11 to V12
+ * ----------
+ * - Add SIOCSIWSTATS to get /proc/net/wireless programatically
+ * - Add DEV PRIVATE IOCTL to avoid collisions in SIOCDEVPRIVATE space
+ * - Add new statistics (frag, retry, beacon)
+ * - Add average quality (for user space calibration)
+ *
+ * V12 to V13
+ * ----------
+ * - Document creation of new driver API.
+ * - Extract union iwreq_data from struct iwreq (for new driver API).
+ * - Rename SIOCSIWNAME as SIOCSIWCOMMIT
+ *
+ * V13 to V14
+ * ----------
+ * - Wireless Events support : define struct iw_event
+ * - Define additional specific event numbers
+ * - Add "addr" and "param" fields in union iwreq_data
+ * - AP scanning stuff (SIOCSIWSCAN and friends)
+ *
+ * V14 to V15
+ * ----------
+ * - Add IW_PRIV_TYPE_ADDR for struct sockaddr private arg
+ * - Make struct iw_freq signed (both m & e), add explicit padding
+ * - Add IWEVCUSTOM for driver specific event/scanning token
+ * - Add IW_MAX_GET_SPY for driver returning a lot of addresses
+ * - Add IW_TXPOW_RANGE for range of Tx Powers
+ * - Add IWEVREGISTERED & IWEVEXPIRED events for Access Points
+ * - Add IW_MODE_MONITOR for passive monitor
+ *
+ * V15 to V16
+ * ----------
+ * - Increase the number of bitrates in iw_range to 32 (for 802.11g)
+ * - Increase the number of frequencies in iw_range to 32 (for 802.11b+a)
+ * - Reshuffle struct iw_range for increases, add filler
+ * - Increase IW_MAX_AP to 64 for driver returning a lot of addresses
+ * - Remove IW_MAX_GET_SPY because conflict with enhanced spy support
+ * - Add SIOCSIWTHRSPY/SIOCGIWTHRSPY and "struct iw_thrspy"
+ * - Add IW_ENCODE_TEMP and iw_range->encoding_login_index
+ *
+ * V16 to V17
+ * ----------
+ * - Add flags to frequency -> auto/fixed
+ * - Document (struct iw_quality *)->updated, add new flags (INVALID)
+ * - Wireless Event capability in struct iw_range
+ * - Add support for relative TxPower (yick !)
+ *
+ * V17 to V18 (From Jouni Malinen <jkmaline@cc.hut.fi>)
+ * ----------
+ * - Add support for WPA/WPA2
+ * - Add extended encoding configuration (SIOCSIWENCODEEXT and
+ * SIOCGIWENCODEEXT)
+ * - Add SIOCSIWGENIE/SIOCGIWGENIE
+ * - Add SIOCSIWMLME
+ * - Add SIOCSIWPMKSA
+ * - Add struct iw_range bit field for supported encoding capabilities
+ * - Add optional scan request parameters for SIOCSIWSCAN
+ * - Add SIOCSIWAUTH/SIOCGIWAUTH for setting authentication and WPA
+ * related parameters (extensible up to 4096 parameter values)
+ * - Add wireless events: IWEVGENIE, IWEVMICHAELMICFAILURE,
+ * IWEVASSOCREQIE, IWEVASSOCRESPIE, IWEVPMKIDCAND
+ *
+ * V18 to V19
+ * ----------
+ * - Remove (struct iw_point *)->pointer from events and streams
+ * - Remove header includes to help user space
+ * - Increase IW_ENCODING_TOKEN_MAX from 32 to 64
+ * - Add IW_QUAL_ALL_UPDATED and IW_QUAL_ALL_INVALID macros
+ * - Add explicit flag to tell stats are in dBm : IW_QUAL_DBM
+ * - Add IW_IOCTL_IDX() and IW_EVENT_IDX() macros
+ *
+ * V19 to V20
+ * ----------
+ * - RtNetlink requests support (SET/GET)
+ *
+ * V20 to V21
+ * ----------
+ * - Remove (struct net_device *)->get_wireless_stats()
+ * - Change length in ESSID and NICK to strlen() instead of strlen()+1
+ * - Add IW_RETRY_SHORT/IW_RETRY_LONG retry modifiers
+ * - Power/Retry relative values no longer * 100000
+ * - Add explicit flag to tell stats are in 802.11k RCPI : IW_QUAL_RCPI
+ *
+ * V21 to V22
+ * ----------
+ * - Prevent leaking of kernel space in stream on 64 bits.
+ */
+
+/**************************** CONSTANTS ****************************/
+
+/* -------------------------- IOCTL LIST -------------------------- */
+
+/* Wireless Identification */
+#define SIOCSIWCOMMIT 0x8B00 /* Commit pending changes to driver */
+#define SIOCGIWNAME 0x8B01 /* get name == wireless protocol */
+/* SIOCGIWNAME is used to verify the presence of Wireless Extensions.
+ * Common values : "IEEE 802.11-DS", "IEEE 802.11-FH", "IEEE 802.11b"...
+ * Don't put the name of your driver there, it's useless. */
+
+/* Basic operations */
+#define SIOCSIWNWID 0x8B02 /* set network id (pre-802.11) */
+#define SIOCGIWNWID 0x8B03 /* get network id (the cell) */
+#define SIOCSIWFREQ 0x8B04 /* set channel/frequency (Hz) */
+#define SIOCGIWFREQ 0x8B05 /* get channel/frequency (Hz) */
+#define SIOCSIWMODE 0x8B06 /* set operation mode */
+#define SIOCGIWMODE 0x8B07 /* get operation mode */
+#define SIOCSIWSENS 0x8B08 /* set sensitivity (dBm) */
+#define SIOCGIWSENS 0x8B09 /* get sensitivity (dBm) */
+
+/* Informative stuff */
+#define SIOCSIWRANGE 0x8B0A /* Unused */
+#define SIOCGIWRANGE 0x8B0B /* Get range of parameters */
+#define SIOCSIWPRIV 0x8B0C /* Unused */
+#define SIOCGIWPRIV 0x8B0D /* get private ioctl interface info */
+#define SIOCSIWSTATS 0x8B0E /* Unused */
+#define SIOCGIWSTATS 0x8B0F /* Get /proc/net/wireless stats */
+/* SIOCGIWSTATS is strictly used between user space and the kernel, and
+ * is never passed to the driver (i.e. the driver will never see it). */
+
+/* Spy support (statistics per MAC address - used for Mobile IP support) */
+#define SIOCSIWSPY 0x8B10 /* set spy addresses */
+#define SIOCGIWSPY 0x8B11 /* get spy info (quality of link) */
+#define SIOCSIWTHRSPY 0x8B12 /* set spy threshold (spy event) */
+#define SIOCGIWTHRSPY 0x8B13 /* get spy threshold */
+
+/* Access Point manipulation */
+#define SIOCSIWAP 0x8B14 /* set access point MAC addresses */
+#define SIOCGIWAP 0x8B15 /* get access point MAC addresses */
+#define SIOCGIWAPLIST 0x8B17 /* Deprecated in favor of scanning */
+#define SIOCSIWSCAN 0x8B18 /* trigger scanning (list cells) */
+#define SIOCGIWSCAN 0x8B19 /* get scanning results */
+
+/* 802.11 specific support */
+#define SIOCSIWESSID 0x8B1A /* set ESSID (network name) */
+#define SIOCGIWESSID 0x8B1B /* get ESSID */
+#define SIOCSIWNICKN 0x8B1C /* set node name/nickname */
+#define SIOCGIWNICKN 0x8B1D /* get node name/nickname */
+/* As the ESSID and NICKN are strings up to 32 bytes long, it doesn't fit
+ * within the 'iwreq' structure, so we need to use the 'data' member to
+ * point to a string in user space, like it is done for RANGE... */
+
+/* Other parameters useful in 802.11 and some other devices */
+#define SIOCSIWRATE 0x8B20 /* set default bit rate (bps) */
+#define SIOCGIWRATE 0x8B21 /* get default bit rate (bps) */
+#define SIOCSIWRTS 0x8B22 /* set RTS/CTS threshold (bytes) */
+#define SIOCGIWRTS 0x8B23 /* get RTS/CTS threshold (bytes) */
+#define SIOCSIWFRAG 0x8B24 /* set fragmentation thr (bytes) */
+#define SIOCGIWFRAG 0x8B25 /* get fragmentation thr (bytes) */
+#define SIOCSIWTXPOW 0x8B26 /* set transmit power (dBm) */
+#define SIOCGIWTXPOW 0x8B27 /* get transmit power (dBm) */
+#define SIOCSIWRETRY 0x8B28 /* set retry limits and lifetime */
+#define SIOCGIWRETRY 0x8B29 /* get retry limits and lifetime */
+
+/* Encoding stuff (scrambling, hardware security, WEP...) */
+#define SIOCSIWENCODE 0x8B2A /* set encoding token & mode */
+#define SIOCGIWENCODE 0x8B2B /* get encoding token & mode */
+/* Power saving stuff (power management, unicast and multicast) */
+#define SIOCSIWPOWER 0x8B2C /* set Power Management settings */
+#define SIOCGIWPOWER 0x8B2D /* get Power Management settings */
+/* Modulation bitmask */
+#define SIOCSIWMODUL 0x8B2E /* set Modulations settings */
+#define SIOCGIWMODUL 0x8B2F /* get Modulations settings */
+
+/* WPA : Generic IEEE 802.11 informatiom element (e.g., for WPA/RSN/WMM).
+ * This ioctl uses struct iw_point and data buffer that includes IE id and len
+ * fields. More than one IE may be included in the request. Setting the generic
+ * IE to empty buffer (len=0) removes the generic IE from the driver. Drivers
+ * are allowed to generate their own WPA/RSN IEs, but in these cases, drivers
+ * are required to report the used IE as a wireless event, e.g., when
+ * associating with an AP. */
+#define SIOCSIWGENIE 0x8B30 /* set generic IE */
+#define SIOCGIWGENIE 0x8B31 /* get generic IE */
+
+/* WPA : IEEE 802.11 MLME requests */
+#define SIOCSIWMLME 0x8B16 /* request MLME operation; uses
+ * struct iw_mlme */
+/* WPA : Authentication mode parameters */
+#define SIOCSIWAUTH 0x8B32 /* set authentication mode params */
+#define SIOCGIWAUTH 0x8B33 /* get authentication mode params */
+
+/* WPA : Extended version of encoding configuration */
+#define SIOCSIWENCODEEXT 0x8B34 /* set encoding token & mode */
+#define SIOCGIWENCODEEXT 0x8B35 /* get encoding token & mode */
+
+/* WPA2 : PMKSA cache management */
+#define SIOCSIWPMKSA 0x8B36 /* PMKSA cache operation */
+
+/* -------------------- DEV PRIVATE IOCTL LIST -------------------- */
+
+/* These 32 ioctl are wireless device private, for 16 commands.
+ * Each driver is free to use them for whatever purpose it chooses,
+ * however the driver *must* export the description of those ioctls
+ * with SIOCGIWPRIV and *must* use arguments as defined below.
+ * If you don't follow those rules, DaveM is going to hate you (reason :
+ * it make mixed 32/64bit operation impossible).
+ */
+#define SIOCIWFIRSTPRIV 0x8BE0
+#define SIOCIWLASTPRIV 0x8BFF
+/* Previously, we were using SIOCDEVPRIVATE, but we now have our
+ * separate range because of collisions with other tools such as
+ * 'mii-tool'.
+ * We now have 32 commands, so a bit more space ;-).
+ * Also, all 'even' commands are only usable by root and don't return the
+ * content of ifr/iwr to user (but you are not obliged to use the set/get
+ * convention, just use every other two command). More details in iwpriv.c.
+ * And I repeat : you are not forced to use them with iwpriv, but you
+ * must be compliant with it.
+ */
+
+/* ------------------------- IOCTL STUFF ------------------------- */
+
+/* The first and the last (range) */
+#define SIOCIWFIRST 0x8B00
+#define SIOCIWLAST SIOCIWLASTPRIV /* 0x8BFF */
+#define IW_IOCTL_IDX(cmd) ((cmd) - SIOCIWFIRST)
+
+/* Odd : get (world access), even : set (root access) */
+#define IW_IS_SET(cmd) (!((cmd) & 0x1))
+#define IW_IS_GET(cmd) ((cmd) & 0x1)
+
+/* ----------------------- WIRELESS EVENTS ----------------------- */
+/* Those are *NOT* ioctls, do not issue request on them !!! */
+/* Most events use the same identifier as ioctl requests */
+
+#define IWEVTXDROP 0x8C00 /* Packet dropped to excessive retry */
+#define IWEVQUAL 0x8C01 /* Quality part of statistics (scan) */
+#define IWEVCUSTOM 0x8C02 /* Driver specific ascii string */
+#define IWEVREGISTERED 0x8C03 /* Discovered a new node (AP mode) */
+#define IWEVEXPIRED 0x8C04 /* Expired a node (AP mode) */
+#define IWEVGENIE 0x8C05 /* Generic IE (WPA, RSN, WMM, ..)
+ * (scan results); This includes id and
+ * length fields. One IWEVGENIE may
+ * contain more than one IE. Scan
+ * results may contain one or more
+ * IWEVGENIE events. */
+#define IWEVMICHAELMICFAILURE 0x8C06 /* Michael MIC failure
+ * (struct iw_michaelmicfailure)
+ */
+#define IWEVASSOCREQIE 0x8C07 /* IEs used in (Re)Association Request.
+ * The data includes id and length
+ * fields and may contain more than one
+ * IE. This event is required in
+ * Managed mode if the driver
+ * generates its own WPA/RSN IE. This
+ * should be sent just before
+ * IWEVREGISTERED event for the
+ * association. */
+#define IWEVASSOCRESPIE 0x8C08 /* IEs used in (Re)Association
+ * Response. The data includes id and
+ * length fields and may contain more
+ * than one IE. This may be sent
+ * between IWEVASSOCREQIE and
+ * IWEVREGISTERED events for the
+ * association. */
+#define IWEVPMKIDCAND 0x8C09 /* PMKID candidate for RSN
+ * pre-authentication
+ * (struct iw_pmkid_cand) */
+
+#define IWEVFIRST 0x8C00
+#define IW_EVENT_IDX(cmd) ((cmd) - IWEVFIRST)
+
+/* ------------------------- PRIVATE INFO ------------------------- */
+/*
+ * The following is used with SIOCGIWPRIV. It allow a driver to define
+ * the interface (name, type of data) for its private ioctl.
+ * Privates ioctl are SIOCIWFIRSTPRIV -> SIOCIWLASTPRIV
+ */
+
+#define IW_PRIV_TYPE_MASK 0x7000 /* Type of arguments */
+#define IW_PRIV_TYPE_NONE 0x0000
+#define IW_PRIV_TYPE_BYTE 0x1000 /* Char as number */
+#define IW_PRIV_TYPE_CHAR 0x2000 /* Char as character */
+#define IW_PRIV_TYPE_INT 0x4000 /* 32 bits int */
+#define IW_PRIV_TYPE_FLOAT 0x5000 /* struct iw_freq */
+#define IW_PRIV_TYPE_ADDR 0x6000 /* struct sockaddr */
+
+#define IW_PRIV_SIZE_FIXED 0x0800 /* Variable or fixed number of args */
+
+#define IW_PRIV_SIZE_MASK 0x07FF /* Max number of those args */
+
+/*
+ * Note : if the number of args is fixed and the size < 16 octets,
+ * instead of passing a pointer we will put args in the iwreq struct...
+ */
+
+/* ----------------------- OTHER CONSTANTS ----------------------- */
+
+/* Maximum frequencies in the range struct */
+#define IW_MAX_FREQUENCIES 32
+/* Note : if you have something like 80 frequencies,
+ * don't increase this constant and don't fill the frequency list.
+ * The user will be able to set by channel anyway... */
+
+/* Maximum bit rates in the range struct */
+#define IW_MAX_BITRATES 32
+
+/* Maximum tx powers in the range struct */
+#define IW_MAX_TXPOWER 8
+/* Note : if you more than 8 TXPowers, just set the max and min or
+ * a few of them in the struct iw_range. */
+
+/* Maximum of address that you may set with SPY */
+#define IW_MAX_SPY 8
+
+/* Maximum of address that you may get in the
+ list of access points in range */
+#define IW_MAX_AP 64
+
+/* Maximum size of the ESSID and NICKN strings */
+#define IW_ESSID_MAX_SIZE 32
+
+/* Modes of operation */
+#define IW_MODE_AUTO 0 /* Let the driver decides */
+#define IW_MODE_ADHOC 1 /* Single cell network */
+#define IW_MODE_INFRA 2 /* Multi cell network, roaming, ... */
+#define IW_MODE_MASTER 3 /* Synchronisation master or Access Point */
+#define IW_MODE_REPEAT 4 /* Wireless Repeater (forwarder) */
+#define IW_MODE_SECOND 5 /* Secondary master/repeater (backup) */
+#define IW_MODE_MONITOR 6 /* Passive monitor (listen only) */
+
+/* Statistics flags (bitmask in updated) */
+#define IW_QUAL_QUAL_UPDATED 0x01 /* Value was updated since last read */
+#define IW_QUAL_LEVEL_UPDATED 0x02
+#define IW_QUAL_NOISE_UPDATED 0x04
+#define IW_QUAL_ALL_UPDATED 0x07
+#define IW_QUAL_DBM 0x08 /* Level + Noise are dBm */
+#define IW_QUAL_QUAL_INVALID 0x10 /* Driver doesn't provide value */
+#define IW_QUAL_LEVEL_INVALID 0x20
+#define IW_QUAL_NOISE_INVALID 0x40
+#define IW_QUAL_RCPI 0x80 /* Level + Noise are 802.11k RCPI */
+#define IW_QUAL_ALL_INVALID 0x70
+
+/* Frequency flags */
+#define IW_FREQ_AUTO 0x00 /* Let the driver decides */
+#define IW_FREQ_FIXED 0x01 /* Force a specific value */
+
+/* Maximum number of size of encoding token available
+ * they are listed in the range structure */
+#define IW_MAX_ENCODING_SIZES 8
+
+/* Maximum size of the encoding token in bytes */
+#define IW_ENCODING_TOKEN_MAX 64 /* 512 bits (for now) */
+
+/* Flags for encoding (along with the token) */
+#define IW_ENCODE_INDEX 0x00FF /* Token index (if needed) */
+#define IW_ENCODE_FLAGS 0xFF00 /* Flags defined below */
+#define IW_ENCODE_MODE 0xF000 /* Modes defined below */
+#define IW_ENCODE_DISABLED 0x8000 /* Encoding disabled */
+#define IW_ENCODE_ENABLED 0x0000 /* Encoding enabled */
+#define IW_ENCODE_RESTRICTED 0x4000 /* Refuse non-encoded packets */
+#define IW_ENCODE_OPEN 0x2000 /* Accept non-encoded packets */
+#define IW_ENCODE_NOKEY 0x0800 /* Key is write only, so not present */
+#define IW_ENCODE_TEMP 0x0400 /* Temporary key */
+
+/* Power management flags available (along with the value, if any) */
+#define IW_POWER_ON 0x0000 /* No details... */
+#define IW_POWER_TYPE 0xF000 /* Type of parameter */
+#define IW_POWER_PERIOD 0x1000 /* Value is a period/duration of */
+#define IW_POWER_TIMEOUT 0x2000 /* Value is a timeout (to go asleep) */
+#define IW_POWER_SAVING 0x4000 /* Value is relative (how aggressive)*/
+#define IW_POWER_MODE 0x0F00 /* Power Management mode */
+#define IW_POWER_UNICAST_R 0x0100 /* Receive only unicast messages */
+#define IW_POWER_MULTICAST_R 0x0200 /* Receive only multicast messages */
+#define IW_POWER_ALL_R 0x0300 /* Receive all messages though PM */
+#define IW_POWER_FORCE_S 0x0400 /* Force PM procedure for sending unicast */
+#define IW_POWER_REPEATER 0x0800 /* Repeat broadcast messages in PM period */
+#define IW_POWER_MODIFIER 0x000F /* Modify a parameter */
+#define IW_POWER_MIN 0x0001 /* Value is a minimum */
+#define IW_POWER_MAX 0x0002 /* Value is a maximum */
+#define IW_POWER_RELATIVE 0x0004 /* Value is not in seconds/ms/us */
+
+/* Transmit Power flags available */
+#define IW_TXPOW_TYPE 0x00FF /* Type of value */
+#define IW_TXPOW_DBM 0x0000 /* Value is in dBm */
+#define IW_TXPOW_MWATT 0x0001 /* Value is in mW */
+#define IW_TXPOW_RELATIVE 0x0002 /* Value is in arbitrary units */
+#define IW_TXPOW_RANGE 0x1000 /* Range of value between min/max */
+
+/* Retry limits and lifetime flags available */
+#define IW_RETRY_ON 0x0000 /* No details... */
+#define IW_RETRY_TYPE 0xF000 /* Type of parameter */
+#define IW_RETRY_LIMIT 0x1000 /* Maximum number of retries*/
+#define IW_RETRY_LIFETIME 0x2000 /* Maximum duration of retries in us */
+#define IW_RETRY_MODIFIER 0x00FF /* Modify a parameter */
+#define IW_RETRY_MIN 0x0001 /* Value is a minimum */
+#define IW_RETRY_MAX 0x0002 /* Value is a maximum */
+#define IW_RETRY_RELATIVE 0x0004 /* Value is not in seconds/ms/us */
+#define IW_RETRY_SHORT 0x0010 /* Value is for short packets */
+#define IW_RETRY_LONG 0x0020 /* Value is for long packets */
+
+/* Scanning request flags */
+#define IW_SCAN_DEFAULT 0x0000 /* Default scan of the driver */
+#define IW_SCAN_ALL_ESSID 0x0001 /* Scan all ESSIDs */
+#define IW_SCAN_THIS_ESSID 0x0002 /* Scan only this ESSID */
+#define IW_SCAN_ALL_FREQ 0x0004 /* Scan all Frequencies */
+#define IW_SCAN_THIS_FREQ 0x0008 /* Scan only this Frequency */
+#define IW_SCAN_ALL_MODE 0x0010 /* Scan all Modes */
+#define IW_SCAN_THIS_MODE 0x0020 /* Scan only this Mode */
+#define IW_SCAN_ALL_RATE 0x0040 /* Scan all Bit-Rates */
+#define IW_SCAN_THIS_RATE 0x0080 /* Scan only this Bit-Rate */
+/* struct iw_scan_req scan_type */
+#define IW_SCAN_TYPE_ACTIVE 0
+#define IW_SCAN_TYPE_PASSIVE 1
+/* Maximum size of returned data */
+#define IW_SCAN_MAX_DATA 4096 /* In bytes */
+
+/* Max number of char in custom event - use multiple of them if needed */
+#define IW_CUSTOM_MAX 256 /* In bytes */
+
+/* Generic information element */
+#define IW_GENERIC_IE_MAX 1024
+
+/* MLME requests (SIOCSIWMLME / struct iw_mlme) */
+#define IW_MLME_DEAUTH 0
+#define IW_MLME_DISASSOC 1
+#define IW_MLME_AUTH 2
+#define IW_MLME_ASSOC 3
+
+/* SIOCSIWAUTH/SIOCGIWAUTH struct iw_param flags */
+#define IW_AUTH_INDEX 0x0FFF
+#define IW_AUTH_FLAGS 0xF000
+/* SIOCSIWAUTH/SIOCGIWAUTH parameters (0 .. 4095)
+ * (IW_AUTH_INDEX mask in struct iw_param flags; this is the index of the
+ * parameter that is being set/get to; value will be read/written to
+ * struct iw_param value field) */
+#define IW_AUTH_WPA_VERSION 0
+#define IW_AUTH_CIPHER_PAIRWISE 1
+#define IW_AUTH_CIPHER_GROUP 2
+#define IW_AUTH_KEY_MGMT 3
+#define IW_AUTH_TKIP_COUNTERMEASURES 4
+#define IW_AUTH_DROP_UNENCRYPTED 5
+#define IW_AUTH_80211_AUTH_ALG 6
+#define IW_AUTH_WPA_ENABLED 7
+#define IW_AUTH_RX_UNENCRYPTED_EAPOL 8
+#define IW_AUTH_ROAMING_CONTROL 9
+#define IW_AUTH_PRIVACY_INVOKED 10
+
+/* IW_AUTH_WPA_VERSION values (bit field) */
+#define IW_AUTH_WPA_VERSION_DISABLED 0x00000001
+#define IW_AUTH_WPA_VERSION_WPA 0x00000002
+#define IW_AUTH_WPA_VERSION_WPA2 0x00000004
+
+/* IW_AUTH_PAIRWISE_CIPHER and IW_AUTH_GROUP_CIPHER values (bit field) */
+#define IW_AUTH_CIPHER_NONE 0x00000001
+#define IW_AUTH_CIPHER_WEP40 0x00000002
+#define IW_AUTH_CIPHER_TKIP 0x00000004
+#define IW_AUTH_CIPHER_CCMP 0x00000008
+#define IW_AUTH_CIPHER_WEP104 0x00000010
+
+/* IW_AUTH_KEY_MGMT values (bit field) */
+#define IW_AUTH_KEY_MGMT_802_1X 1
+#define IW_AUTH_KEY_MGMT_PSK 2
+
+/* IW_AUTH_80211_AUTH_ALG values (bit field) */
+#define IW_AUTH_ALG_OPEN_SYSTEM 0x00000001
+#define IW_AUTH_ALG_SHARED_KEY 0x00000002
+#define IW_AUTH_ALG_LEAP 0x00000004
+
+/* IW_AUTH_ROAMING_CONTROL values */
+#define IW_AUTH_ROAMING_ENABLE 0 /* driver/firmware based roaming */
+#define IW_AUTH_ROAMING_DISABLE 1 /* user space program used for roaming
+ * control */
+
+/* SIOCSIWENCODEEXT definitions */
+#define IW_ENCODE_SEQ_MAX_SIZE 8
+/* struct iw_encode_ext ->alg */
+#define IW_ENCODE_ALG_NONE 0
+#define IW_ENCODE_ALG_WEP 1
+#define IW_ENCODE_ALG_TKIP 2
+#define IW_ENCODE_ALG_CCMP 3
+/* struct iw_encode_ext ->ext_flags */
+#define IW_ENCODE_EXT_TX_SEQ_VALID 0x00000001
+#define IW_ENCODE_EXT_RX_SEQ_VALID 0x00000002
+#define IW_ENCODE_EXT_GROUP_KEY 0x00000004
+#define IW_ENCODE_EXT_SET_TX_KEY 0x00000008
+
+/* IWEVMICHAELMICFAILURE : struct iw_michaelmicfailure ->flags */
+#define IW_MICFAILURE_KEY_ID 0x00000003 /* Key ID 0..3 */
+#define IW_MICFAILURE_GROUP 0x00000004
+#define IW_MICFAILURE_PAIRWISE 0x00000008
+#define IW_MICFAILURE_STAKEY 0x00000010
+#define IW_MICFAILURE_COUNT 0x00000060 /* 1 or 2 (0 = count not supported)
+ */
+
+/* Bit field values for enc_capa in struct iw_range */
+#define IW_ENC_CAPA_WPA 0x00000001
+#define IW_ENC_CAPA_WPA2 0x00000002
+#define IW_ENC_CAPA_CIPHER_TKIP 0x00000004
+#define IW_ENC_CAPA_CIPHER_CCMP 0x00000008
+
+/* Event capability macros - in (struct iw_range *)->event_capa
+ * Because we have more than 32 possible events, we use an array of
+ * 32 bit bitmasks. Note : 32 bits = 0x20 = 2^5. */
+#define IW_EVENT_CAPA_BASE(cmd) ((cmd >= SIOCIWFIRSTPRIV) ? \
+ (cmd - SIOCIWFIRSTPRIV + 0x60) : \
+ (cmd - SIOCSIWCOMMIT))
+#define IW_EVENT_CAPA_INDEX(cmd) (IW_EVENT_CAPA_BASE(cmd) >> 5)
+#define IW_EVENT_CAPA_MASK(cmd) (1 << (IW_EVENT_CAPA_BASE(cmd) & 0x1F))
+/* Event capability constants - event autogenerated by the kernel
+ * This list is valid for most 802.11 devices, customise as needed... */
+#define IW_EVENT_CAPA_K_0 (IW_EVENT_CAPA_MASK(0x8B04) | \
+ IW_EVENT_CAPA_MASK(0x8B06) | \
+ IW_EVENT_CAPA_MASK(0x8B1A))
+#define IW_EVENT_CAPA_K_1 (IW_EVENT_CAPA_MASK(0x8B2A))
+/* "Easy" macro to set events in iw_range (less efficient) */
+#define IW_EVENT_CAPA_SET(event_capa, cmd) (event_capa[IW_EVENT_CAPA_INDEX(cmd)] |= IW_EVENT_CAPA_MASK(cmd))
+#define IW_EVENT_CAPA_SET_KERNEL(event_capa) {event_capa[0] |= IW_EVENT_CAPA_K_0; event_capa[1] |= IW_EVENT_CAPA_K_1; }
+
+/* Modulations bitmasks */
+#define IW_MODUL_ALL 0x00000000 /* Everything supported */
+#define IW_MODUL_FH 0x00000001 /* Frequency Hopping */
+#define IW_MODUL_DS 0x00000002 /* Original Direct Sequence */
+#define IW_MODUL_CCK 0x00000004 /* 802.11b : 5.5 + 11 Mb/s */
+#define IW_MODUL_11B (IW_MODUL_DS | IW_MODUL_CCK)
+#define IW_MODUL_PBCC 0x00000008 /* TI : 5.5 + 11 + 22 Mb/s */
+#define IW_MODUL_OFDM_A 0x00000010 /* 802.11a : 54 Mb/s */
+#define IW_MODUL_11A (IW_MODUL_OFDM_A)
+#define IW_MODUL_11AB (IW_MODUL_11B | IW_MODUL_11A)
+#define IW_MODUL_OFDM_G 0x00000020 /* 802.11g : 54 Mb/s */
+#define IW_MODUL_11G (IW_MODUL_11B | IW_MODUL_OFDM_G)
+#define IW_MODUL_11AG (IW_MODUL_11G | IW_MODUL_11A)
+#define IW_MODUL_TURBO 0x00000040 /* ATH : bonding, 108 Mb/s */
+/* In here we should define MIMO stuff. Later... */
+#define IW_MODUL_CUSTOM 0x40000000 /* Driver specific */
+
+/* Bitrate flags available */
+#define IW_BITRATE_TYPE 0x00FF /* Type of value */
+#define IW_BITRATE_UNICAST 0x0001 /* Maximum/Fixed unicast bitrate */
+#define IW_BITRATE_BROADCAST 0x0002 /* Fixed broadcast bitrate */
+
+/****************************** TYPES ******************************/
+
+/* --------------------------- SUBTYPES --------------------------- */
+/*
+ * Generic format for most parameters that fit in an int
+ */
+struct iw_param
+{
+ int32_t value; /* The value of the parameter itself */
+ uint8_t fixed; /* Hardware should not use auto select */
+ uint8_t disabled; /* Disable the feature */
+ uint16_t flags; /* Various specifc flags (if any) */
+};
+
+/*
+ * For all data larger than 16 octets, we need to use a
+ * pointer to memory allocated in user space.
+ */
+struct iw_point
+{
+ void *pointer; /* Pointer to the data (in user space) */
+ uint16_t length; /* number of fields or size in bytes */
+ uint16_t flags; /* Optional params */
+};
+
+/*
+ * A frequency
+ * For numbers lower than 10^9, we encode the number in 'm' and
+ * set 'e' to 0
+ * For number greater than 10^9, we divide it by the lowest power
+ * of 10 to get 'm' lower than 10^9, with 'm'= f / (10^'e')...
+ * The power of 10 is in 'e', the result of the division is in 'm'.
+ */
+struct iw_freq
+{
+ int32_t m; /* Mantissa */
+ int16_t e; /* Exponent */
+ uint8_t i; /* List index (when in range struct) */
+ uint8_t flags; /* Flags (fixed/auto) */
+};
+
+/*
+ * Quality of the link
+ */
+struct iw_quality
+{
+ uint8_t qual; /* link quality (%retries, SNR,
+ %missed beacons or better...) */
+ uint8_t level; /* signal level (dBm) */
+ uint8_t noise; /* noise level (dBm) */
+ uint8_t updated; /* Flags to know if updated */
+};
+
+/*
+ * Packet discarded in the wireless adapter due to
+ * "wireless" specific problems...
+ * Note : the list of counter and statistics in net_device_stats
+ * is already pretty exhaustive, and you should use that first.
+ * This is only additional stats...
+ */
+struct iw_discarded
+{
+ uint32_t nwid; /* Rx : Wrong nwid/essid */
+ uint32_t code; /* Rx : Unable to code/decode (WEP) */
+ uint32_t fragment; /* Rx : Can't perform MAC reassembly */
+ uint32_t retries; /* Tx : Max MAC retries num reached */
+ uint32_t misc; /* Others cases */
+};
+
+/*
+ * Packet/Time period missed in the wireless adapter due to
+ * "wireless" specific problems...
+ */
+struct iw_missed
+{
+ uint32_t beacon; /* Missed beacons/superframe */
+};
+
+/*
+ * Quality range (for spy threshold)
+ */
+struct iw_thrspy
+{
+ struct sockaddr addr; /* Source address (hw/mac) */
+ struct iw_quality qual; /* Quality of the link */
+ struct iw_quality low; /* Low threshold */
+ struct iw_quality high; /* High threshold */
+};
+
+/*
+ * Optional data for scan request
+ *
+ * Note: these optional parameters are controlling parameters for the
+ * scanning behavior, these do not apply to getting scan results
+ * (SIOCGIWSCAN). Drivers are expected to keep a local BSS table and
+ * provide a merged results with all BSSes even if the previous scan
+ * request limited scanning to a subset, e.g., by specifying an SSID.
+ * Especially, scan results are required to include an entry for the
+ * current BSS if the driver is in Managed mode and associated with an AP.
+ */
+struct iw_scan_req
+{
+ uint8_t scan_type; /* IW_SCAN_TYPE_{ACTIVE,PASSIVE} */
+ uint8_t essid_len;
+ uint8_t num_channels; /* num entries in channel_list;
+ * 0 = scan all allowed channels */
+ uint8_t flags; /* reserved as padding; use zero, this may
+ * be used in the future for adding flags
+ * to request different scan behavior */
+ struct sockaddr bssid; /* ff:ff:ff:ff:ff:ff for broadcast BSSID or
+ * individual address of a specific BSS */
+
+ /*
+ * Use this ESSID if IW_SCAN_THIS_ESSID flag is used instead of using
+ * the current ESSID. This allows scan requests for specific ESSID
+ * without having to change the current ESSID and potentially breaking
+ * the current association.
+ */
+ uint8_t essid[IW_ESSID_MAX_SIZE];
+
+ /*
+ * Optional parameters for changing the default scanning behavior.
+ * These are based on the MLME-SCAN.request from IEEE Std 802.11.
+ * TU is 1.024 ms. If these are set to 0, driver is expected to use
+ * reasonable default values. min_channel_time defines the time that
+ * will be used to wait for the first reply on each channel. If no
+ * replies are received, next channel will be scanned after this. If
+ * replies are received, total time waited on the channel is defined by
+ * max_channel_time.
+ */
+ uint32_t min_channel_time; /* in TU */
+ uint32_t max_channel_time; /* in TU */
+
+ struct iw_freq channel_list[IW_MAX_FREQUENCIES];
+};
+
+/* ------------------------- WPA SUPPORT ------------------------- */
+
+/*
+ * Extended data structure for get/set encoding (this is used with
+ * SIOCSIWENCODEEXT/SIOCGIWENCODEEXT. struct iw_point and IW_ENCODE_*
+ * flags are used in the same way as with SIOCSIWENCODE/SIOCGIWENCODE and
+ * only the data contents changes (key data -> this structure, including
+ * key data).
+ *
+ * If the new key is the first group key, it will be set as the default
+ * TX key. Otherwise, default TX key index is only changed if
+ * IW_ENCODE_EXT_SET_TX_KEY flag is set.
+ *
+ * Key will be changed with SIOCSIWENCODEEXT in all cases except for
+ * special "change TX key index" operation which is indicated by setting
+ * key_len = 0 and ext_flags |= IW_ENCODE_EXT_SET_TX_KEY.
+ *
+ * tx_seq/rx_seq are only used when respective
+ * IW_ENCODE_EXT_{TX,RX}_SEQ_VALID flag is set in ext_flags. Normal
+ * TKIP/CCMP operation is to set RX seq with SIOCSIWENCODEEXT and start
+ * TX seq from zero whenever key is changed. SIOCGIWENCODEEXT is normally
+ * used only by an Authenticator (AP or an IBSS station) to get the
+ * current TX sequence number. Using TX_SEQ_VALID for SIOCSIWENCODEEXT and
+ * RX_SEQ_VALID for SIOCGIWENCODEEXT are optional, but can be useful for
+ * debugging/testing.
+ */
+struct iw_encode_ext
+{
+ uint32_t ext_flags; /* IW_ENCODE_EXT_* */
+ uint8_t tx_seq[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */
+ uint8_t rx_seq[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */
+ struct sockaddr addr; /* ff:ff:ff:ff:ff:ff for broadcast/multicast
+ * (group) keys or unicast address for
+ * individual keys */
+ uint16_t alg; /* IW_ENCODE_ALG_* */
+ uint16_t key_len;
+ uint8_t key[1];
+};
+
+/* SIOCSIWMLME data */
+struct iw_mlme
+{
+ uint16_t cmd; /* IW_MLME_* */
+ uint16_t reason_code;
+ struct sockaddr addr;
+};
+
+/* SIOCSIWPMKSA data */
+#define IW_PMKSA_ADD 1
+#define IW_PMKSA_REMOVE 2
+#define IW_PMKSA_FLUSH 3
+
+#define IW_PMKID_LEN 16
+
+struct iw_pmksa
+{
+ uint32_t cmd; /* IW_PMKSA_* */
+ struct sockaddr bssid;
+ uint8_t pmkid[IW_PMKID_LEN];
+};
+
+/* IWEVMICHAELMICFAILURE data */
+struct iw_michaelmicfailure
+{
+ uint32_t flags;
+ struct sockaddr src_addr;
+ uint8_t tsc[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */
+};
+
+/* IWEVPMKIDCAND data */
+#define IW_PMKID_CAND_PREAUTH 0x00000001 /* RNS pre-authentication enabled */
+struct iw_pmkid_cand
+{
+ uint32_t flags; /* IW_PMKID_CAND_* */
+ uint32_t index; /* the smaller the index, the higher the
+ * priority */
+ struct sockaddr bssid;
+};
+
+/* ------------------------ WIRELESS STATS ------------------------ */
+/*
+ * Wireless statistics (used for /proc/net/wireless)
+ */
+struct iw_statistics
+{
+ uint16_t status; /* Status
+ * - device dependent for now */
+
+ struct iw_quality qual; /* Quality of the link
+ * (instant/mean/max) */
+ struct iw_discarded discard; /* Packet discarded counts */
+ struct iw_missed miss; /* Packet missed counts */
+};
+
+/* ------------------------ IOCTL REQUEST ------------------------ */
+/*
+ * This structure defines the payload of an ioctl, and is used
+ * below.
+ *
+ * Note that this structure should fit on the memory footprint
+ * of iwreq (which is the same as ifreq), which mean a max size of
+ * 16 octets = 128 bits. Warning, pointers might be 64 bits wide...
+ * You should check this when increasing the structures defined
+ * above in this file...
+ */
+union iwreq_data
+{
+ /* Config - generic */
+ char name[16];
+ /* Name : used to verify the presence of wireless extensions.
+ * Name of the protocol/provider... */
+
+ struct iw_point essid; /* Extended network name */
+ struct iw_param nwid; /* network id (or domain - the cell) */
+ struct iw_freq freq; /* frequency or channel :
+ * 0-1000 = channel
+ * > 1000 = frequency in Hz */
+
+ struct iw_param sens; /* signal level threshold */
+ struct iw_param bitrate; /* default bit rate */
+ struct iw_param txpower; /* default transmit power */
+ struct iw_param rts; /* RTS threshold threshold */
+ struct iw_param frag; /* Fragmentation threshold */
+ uint32_t mode; /* Operation mode */
+ struct iw_param retry; /* Retry limits & lifetime */
+
+ struct iw_point encoding; /* Encoding stuff : tokens */
+ struct iw_param power; /* PM duration/timeout */
+ struct iw_quality qual; /* Quality part of statistics */
+
+ struct sockaddr ap_addr; /* Access point address */
+ struct sockaddr addr; /* Destination address (hw/mac) */
+
+ struct iw_param param; /* Other small parameters */
+ struct iw_point data; /* Other large parameters */
+};
+
+/*
+ * The structure to exchange data for ioctl.
+ * This structure is the same as 'struct ifreq', but (re)defined for
+ * convenience...
+ * Do I need to remind you about structure size (32 octets) ?
+ */
+struct iwreq
+{
+ union
+ {
+ char ifrn_name[16]; /* if name, e.g. "eth0" */
+ } ifr_ifrn;
+
+ /* Data part (defined just above) */
+ union iwreq_data u;
+};
+
+/* -------------------------- IOCTL DATA -------------------------- */
+/*
+ * For those ioctl which want to exchange mode data that what could
+ * fit in the above structure...
+ */
+
+/*
+ * Range of parameters
+ */
+
+struct iw_range
+{
+ /* Informative stuff (to choose between different interface) */
+ uint32_t throughput; /* To give an idea... */
+ /* In theory this value should be the maximum benchmarked
+ * TCP/IP throughput, because with most of these devices the
+ * bit rate is meaningless (overhead an co) to estimate how
+ * fast the connection will go and pick the fastest one.
+ * I suggest people to play with Netperf or any benchmark...
+ */
+
+ /* NWID (or domain id) */
+ uint32_t min_nwid; /* Minimal NWID we are able to set */
+ uint32_t max_nwid; /* Maximal NWID we are able to set */
+
+ /* Old Frequency (backward compat - moved lower ) */
+ uint16_t old_num_channels;
+ uint8_t old_num_frequency;
+
+ /* Wireless event capability bitmasks */
+ uint32_t event_capa[6];
+
+ /* signal level threshold range */
+ int32_t sensitivity;
+
+ /* Quality of link & SNR stuff */
+ /* Quality range (link, level, noise)
+ * If the quality is absolute, it will be in the range [0 ; max_qual],
+ * if the quality is dBm, it will be in the range [max_qual ; 0].
+ * Don't forget that we use 8 bit arithmetics... */
+ struct iw_quality max_qual; /* Quality of the link */
+ /* This should contain the average/typical values of the quality
+ * indicator. This should be the threshold between a "good" and
+ * a "bad" link (example : monitor going from green to orange).
+ * Currently, user space apps like quality monitors don't have any
+ * way to calibrate the measurement. With this, they can split
+ * the range between 0 and max_qual in different quality level
+ * (using a geometric subdivision centered on the average).
+ * I expect that people doing the user space apps will feedback
+ * us on which value we need to put in each driver... */
+ struct iw_quality avg_qual; /* Quality of the link */
+
+ /* Rates */
+ uint8_t num_bitrates; /* Number of entries in the list */
+ int32_t bitrate[IW_MAX_BITRATES]; /* list, in bps */
+
+ /* RTS threshold */
+ int32_t min_rts; /* Minimal RTS threshold */
+ int32_t max_rts; /* Maximal RTS threshold */
+
+ /* Frag threshold */
+ int32_t min_frag; /* Minimal frag threshold */
+ int32_t max_frag; /* Maximal frag threshold */
+
+ /* Power Management duration & timeout */
+ int32_t min_pmp; /* Minimal PM period */
+ int32_t max_pmp; /* Maximal PM period */
+ int32_t min_pmt; /* Minimal PM timeout */
+ int32_t max_pmt; /* Maximal PM timeout */
+ uint16_t pmp_flags; /* How to decode max/min PM period */
+ uint16_t pmt_flags; /* How to decode max/min PM timeout */
+ uint16_t pm_capa; /* What PM options are supported */
+
+ /* Encoder stuff */
+ uint16_t encoding_size[IW_MAX_ENCODING_SIZES]; /* Different token sizes */
+ uint8_t num_encoding_sizes; /* Number of entry in the list */
+ uint8_t max_encoding_tokens; /* Max number of tokens */
+ /* For drivers that need a "login/passwd" form */
+ uint8_t encoding_login_index; /* token index for login token */
+
+ /* Transmit power */
+ uint16_t txpower_capa; /* What options are supported */
+ uint8_t num_txpower; /* Number of entries in the list */
+ int32_t txpower[IW_MAX_TXPOWER]; /* list, in bps */
+
+ /* Wireless Extension version info */
+ uint8_t we_version_compiled; /* Must be WIRELESS_EXT */
+ uint8_t we_version_source; /* Last update of source */
+
+ /* Retry limits and lifetime */
+ uint16_t retry_capa; /* What retry options are supported */
+ uint16_t retry_flags; /* How to decode max/min retry limit */
+ uint16_t r_time_flags; /* How to decode max/min retry life */
+ int32_t min_retry; /* Minimal number of retries */
+ int32_t max_retry; /* Maximal number of retries */
+ int32_t min_r_time; /* Minimal retry lifetime */
+ int32_t max_r_time; /* Maximal retry lifetime */
+
+ /* Frequency */
+ uint16_t num_channels; /* Number of channels [0; num - 1] */
+ uint8_t num_frequency; /* Number of entry in the list */
+ struct iw_freq freq[IW_MAX_FREQUENCIES]; /* list */
+ /* Note : this frequency list doesn't need to fit channel numbers,
+ * because each entry contain its channel index */
+
+ uint32_t enc_capa; /* IW_ENC_CAPA_* bit field */
+
+ /* More power management stuff */
+ int32_t min_pms; /* Minimal PM saving */
+ int32_t max_pms; /* Maximal PM saving */
+ uint16_t pms_flags; /* How to decode max/min PM saving */
+
+ /* All available modulations for driver (hw may support less) */
+ int32_t modul_capa; /* IW_MODUL_* bit field */
+
+ /* More bitrate stuff */
+ uint32_t bitrate_capa; /* Types of bitrates supported */
+};
+
+/*
+ * Private ioctl interface information
+ */
+
+struct iw_priv_args
+{
+ uint32_t cmd; /* Number of the ioctl to issue */
+ uint16_t set_args; /* Type and number of args */
+ uint16_t get_args; /* Type and number of args */
+ char name[16]; /* Name of the extension */
+};
+
+/* ----------------------- WIRELESS EVENTS ----------------------- */
+/*
+ * Wireless events are carried through the rtnetlink socket to user
+ * space. They are encapsulated in the IFLA_WIRELESS field of
+ * a RTM_NEWLINK message.
+ */
+
+/*
+ * A Wireless Event. Contains basically the same data as the ioctl...
+ */
+struct iw_event
+{
+ uint16_t len; /* Real lenght of this stuff */
+ uint16_t cmd; /* Wireless IOCTL */
+ union iwreq_data u; /* IOCTL fixed payload */
+};
+
+/* Size of the Event prefix (including padding and alignement junk) */
+#define IW_EV_LCP_LEN (sizeof(struct iw_event) - sizeof(union iwreq_data))
+/* Size of the various events */
+#define IW_EV_CHAR_LEN (IW_EV_LCP_LEN + IFNAMSIZ)
+#define IW_EV_UINT_LEN (IW_EV_LCP_LEN + sizeof(uint32_t))
+#define IW_EV_FREQ_LEN (IW_EV_LCP_LEN + sizeof(struct iw_freq))
+#define IW_EV_PARAM_LEN (IW_EV_LCP_LEN + sizeof(struct iw_param))
+#define IW_EV_ADDR_LEN (IW_EV_LCP_LEN + sizeof(struct sockaddr))
+#define IW_EV_QUAL_LEN (IW_EV_LCP_LEN + sizeof(struct iw_quality))
+
+/* iw_point events are special. First, the payload (extra data) come at
+ * the end of the event, so they are bigger than IW_EV_POINT_LEN. Second,
+ * we omit the pointer, so start at an offset. */
+#define IW_EV_POINT_OFF (((char *) &(((struct iw_point *) NULL)->length)) - \
+ (char *) NULL)
+#define IW_EV_POINT_LEN (IW_EV_LCP_LEN + sizeof(struct iw_point) - \
+ IW_EV_POINT_OFF)
+
+/* Size of the Event prefix when packed in stream */
+#define IW_EV_LCP_PK_LEN (4)
+/* Size of the various events when packed in stream */
+#define IW_EV_CHAR_PK_LEN (IW_EV_LCP_PK_LEN + IFNAMSIZ)
+#define IW_EV_UINT_PK_LEN (IW_EV_LCP_PK_LEN + sizeof(uint32_t))
+#define IW_EV_FREQ_PK_LEN (IW_EV_LCP_PK_LEN + sizeof(struct iw_freq))
+#define IW_EV_PARAM_PK_LEN (IW_EV_LCP_PK_LEN + sizeof(struct iw_param))
+#define IW_EV_ADDR_PK_LEN (IW_EV_LCP_PK_LEN + sizeof(struct sockaddr))
+#define IW_EV_QUAL_PK_LEN (IW_EV_LCP_PK_LEN + sizeof(struct iw_quality))
+#define IW_EV_POINT_PK_LEN (IW_EV_LCP_PK_LEN + 4)
+
+#endif /* _LINUX_WIRELESS_H */
diff --git a/package/network/utils/iwinfo/src/include/iwinfo/api/broadcom.h b/package/network/utils/iwinfo/src/include/iwinfo/api/broadcom.h
new file mode 100644
index 0000000..50eedd9
--- /dev/null
+++ b/package/network/utils/iwinfo/src/include/iwinfo/api/broadcom.h
@@ -0,0 +1,131 @@
+/*
+ * Custom OID/ioctl definitions for
+ * Broadcom 802.11abg Networking Device Driver
+ *
+ * Definitions subject to change without notice.
+ *
+ * Copyright 2006, Broadcom Corporation
+ * All Rights Reserved.
+ *
+ * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
+ * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
+ * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
+ * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
+ *
+ */
+
+#ifndef _BROADCOM_H
+#define _BROADCOM_H
+
+#define WL_MCSSET_LEN 16
+#define WL_MAX_STA_COUNT 32
+
+#define WL_BSS_RSSI_OFFSET 82
+#define WL_BSS_NOISE_OFFSET 84
+
+#define WLC_IOCTL_MAGIC 0x14e46c77
+#define WLC_IOCTL_MAXLEN 8192
+
+#define WLC_CNTRY_BUF_SZ 4
+
+#define WLC_GET_MAGIC 0
+#define WLC_GET_RATE 12
+#define WLC_GET_INFRA 19
+#define WLC_GET_AUTH 21
+#define WLC_GET_BSSID 23
+#define WLC_GET_SSID 25
+#define WLC_GET_CHANNEL 29
+#define WLC_GET_PASSIVE 48
+#define WLC_GET_COUNTRY 83
+#define WLC_GET_REVINFO 98
+#define WLC_GET_AP 117
+#define WLC_GET_RSSI 127
+#define WLC_GET_WSEC 133
+#define WLC_GET_PHY_NOISE 135
+#define WLC_GET_BSS_INFO 136
+#define WLC_GET_ASSOCLIST 159
+#define WLC_GET_WPA_AUTH 164
+#define WLC_GET_COUNTRY_LIST 261
+#define WLC_GET_VAR 262
+
+
+struct wl_ether_addr {
+ uint8_t octet[6];
+};
+
+struct wl_maclist {
+ uint count;
+ struct wl_ether_addr ea[1];
+};
+
+typedef struct wl_sta_rssi {
+ int rssi;
+ char mac[6];
+ uint16_t foo;
+} wl_sta_rssi_t;
+
+#define WL_NUMRATES 255 /* max # of rates in a rateset */
+typedef struct wl_rateset {
+ uint32_t count; /* # rates in this set */
+ uint8_t rates[WL_NUMRATES]; /* rates in 500kbps units w/hi bit set if basic */
+} wl_rateset_t;
+
+typedef struct wl_sta_info {
+ uint16_t ver; /* version of this struct */
+ uint16_t len; /* length in bytes of this structure */
+ uint16_t cap; /* sta's advertised capabilities */
+ uint32_t flags; /* flags defined below */
+ uint32_t idle; /* time since data pkt rx'd from sta */
+ unsigned char ea[6]; /* Station address */
+ wl_rateset_t rateset; /* rateset in use */
+ uint32_t in; /* seconds elapsed since associated */
+ uint32_t listen_interval_inms; /* Min Listen interval in ms for this STA */
+ uint32_t tx_pkts; /* # of packets transmitted */
+ uint32_t tx_failures; /* # of packets failed */
+ uint32_t rx_ucast_pkts; /* # of unicast packets received */
+ uint32_t rx_mcast_pkts; /* # of multicast packets received */
+ uint32_t tx_rate; /* Rate of last successful tx frame */
+ uint32_t rx_rate; /* Rate of last successful rx frame */
+} wl_sta_info_t;
+
+typedef struct wlc_ssid {
+ uint32_t ssid_len;
+ unsigned char ssid[32];
+} wlc_ssid_t;
+
+/* Linux network driver ioctl encoding */
+typedef struct wl_ioctl {
+ uint32_t cmd; /* common ioctl definition */
+ void *buf; /* pointer to user buffer */
+ uint32_t len; /* length of user buffer */
+ uint8_t set; /* get or set request (optional) */
+ uint32_t used; /* bytes read or written (optional) */
+ uint32_t needed; /* bytes needed (optional) */
+} wl_ioctl_t;
+
+/* Revision info */
+typedef struct wlc_rev_info {
+ uint vendorid; /* PCI vendor id */
+ uint deviceid; /* device id of chip */
+ uint radiorev; /* radio revision */
+ uint chiprev; /* chip revision */
+ uint corerev; /* core revision */
+ uint boardid; /* board identifier (usu. PCI sub-device id) */
+ uint boardvendor; /* board vendor (usu. PCI sub-vendor id) */
+ uint boardrev; /* board revision */
+ uint driverrev; /* driver version */
+ uint ucoderev; /* microcode version */
+ uint bus; /* bus type */
+ uint chipnum; /* chip number */
+} wlc_rev_info_t;
+
+typedef struct wl_country_list {
+ uint32_t buflen;
+ uint32_t band_set;
+ uint32_t band;
+ uint32_t count;
+ char country_abbrev[1];
+} wl_country_list_t;
+
+
+#endif
diff --git a/package/network/utils/iwinfo/src/include/iwinfo/api/madwifi.h b/package/network/utils/iwinfo/src/include/iwinfo/api/madwifi.h
new file mode 100644
index 0000000..80d32e1
--- /dev/null
+++ b/package/network/utils/iwinfo/src/include/iwinfo/api/madwifi.h
@@ -0,0 +1,160 @@
+/*
+ * Header bits derived from MadWifi source:
+ * Copyright (c) 2001 Atsushi Onoe
+ * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
+ * All rights reserved.
+ *
+ * Distributed under the terms of the GPLv2 license.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _MADWIFI_H
+#define _MADWIFI_H
+
+/* ieee80211.h */
+#define IEEE80211_ADDR_LEN 6
+#define IEEE80211_RATE_VAL 0x7f
+#define IEEE80211_SEQ_SEQ_MASK 0xfff0
+#define IEEE80211_SEQ_SEQ_SHIFT 4
+
+
+/* ieee80211_crypto.h */
+#define IEEE80211_KEYBUF_SIZE 16
+#define IEEE80211_MICBUF_SIZE 16
+#define IEEE80211_TID_SIZE 17
+
+#define IEEE80211_CIPHER_WEP 0
+#define IEEE80211_CIPHER_TKIP 1
+#define IEEE80211_CIPHER_AES_OCB 2
+#define IEEE80211_CIPHER_AES_CCM 3
+#define IEEE80211_CIPHER_CKIP 5
+#define IEEE80211_CIPHER_NONE 6
+#define IEEE80211_CIPHER_MAX (IEEE80211_CIPHER_NONE + 1)
+
+
+/* ieee80211_ioctl.h */
+#define IEEE80211_KEY_DEFAULT 0x80
+#define IEEE80211_CHAN_MAX 255
+#define IEEE80211_CHAN_BYTES 32
+#define IEEE80211_RATE_MAXSIZE 15
+
+#define IEEE80211_IOCTL_GETKEY (SIOCDEVPRIVATE+3)
+#define IEEE80211_IOCTL_STA_STATS (SIOCDEVPRIVATE+5)
+#define IEEE80211_IOCTL_STA_INFO (SIOCDEVPRIVATE+6)
+
+#define IEEE80211_IOCTL_GETPARAM (SIOCIWFIRSTPRIV+1)
+#define IEEE80211_IOCTL_GETMODE (SIOCIWFIRSTPRIV+3)
+#define IEEE80211_IOCTL_GETCHANLIST (SIOCIWFIRSTPRIV+7)
+#define IEEE80211_IOCTL_GETCHANINFO (SIOCIWFIRSTPRIV+13)
+
+#define SIOC80211IFCREATE (SIOCDEVPRIVATE+7)
+#define SIOC80211IFDESTROY (SIOCDEVPRIVATE+8)
+
+#define IEEE80211_CLONE_BSSID 0x0001 /* allocate unique mac/bssid */
+#define IEEE80211_NO_STABEACONS 0x0002 /* Do not setup the station beacon timers */
+
+struct ieee80211_clone_params {
+ char icp_name[IFNAMSIZ]; /* device name */
+ u_int16_t icp_opmode; /* operating mode */
+ u_int16_t icp_flags; /* see below */
+};
+
+enum ieee80211_opmode {
+ IEEE80211_M_STA = 1, /* infrastructure station */
+ IEEE80211_M_IBSS = 0, /* IBSS (adhoc) station */
+ IEEE80211_M_AHDEMO = 3, /* Old lucent compatible adhoc demo */
+ IEEE80211_M_HOSTAP = 6, /* Software Access Point */
+ IEEE80211_M_MONITOR = 8, /* Monitor mode */
+ IEEE80211_M_WDS = 2, /* WDS link */
+};
+
+enum {
+ IEEE80211_PARAM_AUTHMODE = 3, /* authentication mode */
+ IEEE80211_PARAM_MCASTCIPHER = 5, /* multicast/default cipher */
+ IEEE80211_PARAM_MCASTKEYLEN = 6, /* multicast key length */
+ IEEE80211_PARAM_UCASTCIPHERS = 7, /* unicast cipher suites */
+ IEEE80211_PARAM_WPA = 10, /* WPA mode (0,1,2) */
+};
+
+/*
+ * Authentication mode.
+ */
+enum ieee80211_authmode {
+ IEEE80211_AUTH_NONE = 0,
+ IEEE80211_AUTH_OPEN = 1, /* open */
+ IEEE80211_AUTH_SHARED = 2, /* shared-key */
+ IEEE80211_AUTH_8021X = 3, /* 802.1x */
+ IEEE80211_AUTH_AUTO = 4, /* auto-select/accept */
+ /* NB: these are used only for ioctls */
+ IEEE80211_AUTH_WPA = 5, /* WPA/RSN w/ 802.1x/PSK */
+};
+
+struct ieee80211_channel {
+ u_int16_t ic_freq; /* setting in MHz */
+ u_int16_t ic_flags; /* see below */
+ u_int8_t ic_ieee; /* IEEE channel number */
+ int8_t ic_maxregpower; /* maximum regulatory tx power in dBm */
+ int8_t ic_maxpower; /* maximum tx power in dBm */
+ int8_t ic_minpower; /* minimum tx power in dBm */
+ u_int8_t ic_scanflags;
+ u_int8_t ic_idletime; /* phy idle time in % */
+};
+
+struct ieee80211req_key {
+ u_int8_t ik_type; /* key/cipher type */
+ u_int8_t ik_pad;
+ u_int16_t ik_keyix; /* key index */
+ u_int8_t ik_keylen; /* key length in bytes */
+ u_int8_t ik_flags;
+ u_int8_t ik_macaddr[IEEE80211_ADDR_LEN];
+ u_int64_t ik_keyrsc; /* key receive sequence counter */
+ u_int64_t ik_keytsc; /* key transmit sequence counter */
+ u_int8_t ik_keydata[IEEE80211_KEYBUF_SIZE+IEEE80211_MICBUF_SIZE];
+};
+
+struct ieee80211req_chanlist {
+ u_int8_t ic_channels[IEEE80211_CHAN_BYTES];
+};
+
+struct ieee80211req_chaninfo {
+ u_int ic_nchans;
+ struct ieee80211_channel ic_chans[IEEE80211_CHAN_MAX];
+};
+
+struct ieee80211req_sta_info {
+ u_int16_t isi_len; /* length (mult of 4) */
+ u_int16_t isi_freq; /* MHz */
+ u_int16_t isi_flags; /* channel flags */
+ u_int16_t isi_state; /* state flags */
+ u_int8_t isi_authmode; /* authentication algorithm */
+ u_int8_t isi_rssi;
+ int8_t isi_noise;
+ u_int16_t isi_capinfo; /* capabilities */
+ u_int8_t isi_athflags; /* Atheros capabilities */
+ u_int8_t isi_erp; /* ERP element */
+ u_int8_t isi_macaddr[IEEE80211_ADDR_LEN];
+ u_int8_t isi_nrates; /* negotiated rates */
+ u_int8_t isi_rates[IEEE80211_RATE_MAXSIZE];
+ u_int8_t isi_txrate; /* index to isi_rates[] */
+ u_int16_t isi_ie_len; /* IE length */
+ u_int16_t isi_associd; /* assoc response */
+ u_int16_t isi_txpower; /* current tx power */
+ u_int16_t isi_vlan; /* vlan tag */
+ u_int16_t isi_txseqs[17]; /* seq to be transmitted */
+ u_int16_t isi_rxseqs[17]; /* seq previous for qos frames*/
+ u_int16_t isi_inact; /* inactivity timer */
+ u_int8_t isi_uapsd; /* UAPSD queues */
+ u_int8_t isi_opmode; /* sta operating mode */
+};
+
+#endif
diff --git a/package/network/utils/iwinfo/src/include/iwinfo/api/nl80211.h b/package/network/utils/iwinfo/src/include/iwinfo/api/nl80211.h
new file mode 100644
index 0000000..d73dcb8
--- /dev/null
+++ b/package/network/utils/iwinfo/src/include/iwinfo/api/nl80211.h
@@ -0,0 +1,2834 @@
+#ifndef __LINUX_NL80211_H
+#define __LINUX_NL80211_H
+/*
+ * 802.11 netlink interface public header
+ *
+ * Copyright 2006-2010 Johannes Berg <johannes@sipsolutions.net>
+ * Copyright 2008 Michael Wu <flamingice@sourmilk.net>
+ * Copyright 2008 Luis Carlos Cobo <luisca@cozybit.com>
+ * Copyright 2008 Michael Buesch <m@bues.ch>
+ * Copyright 2008, 2009 Luis R. Rodriguez <lrodriguez@atheros.com>
+ * Copyright 2008 Jouni Malinen <jouni.malinen@atheros.com>
+ * Copyright 2008 Colin McCabe <colin@cozybit.com>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+#include <linux/types.h>
+
+/**
+ * DOC: Station handling
+ *
+ * Stations are added per interface, but a special case exists with VLAN
+ * interfaces. When a station is bound to an AP interface, it may be moved
+ * into a VLAN identified by a VLAN interface index (%NL80211_ATTR_STA_VLAN).
+ * The station is still assumed to belong to the AP interface it was added
+ * to.
+ *
+ * TODO: need more info?
+ */
+
+/**
+ * DOC: Frame transmission/registration support
+ *
+ * Frame transmission and registration support exists to allow userspace
+ * management entities such as wpa_supplicant react to management frames
+ * that are not being handled by the kernel. This includes, for example,
+ * certain classes of action frames that cannot be handled in the kernel
+ * for various reasons.
+ *
+ * Frame registration is done on a per-interface basis and registrations
+ * cannot be removed other than by closing the socket. It is possible to
+ * specify a registration filter to register, for example, only for a
+ * certain type of action frame. In particular with action frames, those
+ * that userspace registers for will not be returned as unhandled by the
+ * driver, so that the registered application has to take responsibility
+ * for doing that.
+ *
+ * The type of frame that can be registered for is also dependent on the
+ * driver and interface type. The frame types are advertised in wiphy
+ * attributes so applications know what to expect.
+ *
+ * NOTE: When an interface changes type while registrations are active,
+ * these registrations are ignored until the interface type is
+ * changed again. This means that changing the interface type can
+ * lead to a situation that couldn't otherwise be produced, but
+ * any such registrations will be dormant in the sense that they
+ * will not be serviced, i.e. they will not receive any frames.
+ *
+ * Frame transmission allows userspace to send for example the required
+ * responses to action frames. It is subject to some sanity checking,
+ * but many frames can be transmitted. When a frame was transmitted, its
+ * status is indicated to the sending socket.
+ *
+ * For more technical details, see the corresponding command descriptions
+ * below.
+ */
+
+/**
+ * DOC: Virtual interface / concurrency capabilities
+ *
+ * Some devices are able to operate with virtual MACs, they can have
+ * more than one virtual interface. The capability handling for this
+ * is a bit complex though, as there may be a number of restrictions
+ * on the types of concurrency that are supported.
+ *
+ * To start with, each device supports the interface types listed in
+ * the %NL80211_ATTR_SUPPORTED_IFTYPES attribute, but by listing the
+ * types there no concurrency is implied.
+ *
+ * Once concurrency is desired, more attributes must be observed:
+ * To start with, since some interface types are purely managed in
+ * software, like the AP-VLAN type in mac80211 for example, there's
+ * an additional list of these, they can be added at any time and
+ * are only restricted by some semantic restrictions (e.g. AP-VLAN
+ * cannot be added without a corresponding AP interface). This list
+ * is exported in the %NL80211_ATTR_SOFTWARE_IFTYPES attribute.
+ *
+ * Further, the list of supported combinations is exported. This is
+ * in the %NL80211_ATTR_INTERFACE_COMBINATIONS attribute. Basically,
+ * it exports a list of "groups", and at any point in time the
+ * interfaces that are currently active must fall into any one of
+ * the advertised groups. Within each group, there are restrictions
+ * on the number of interfaces of different types that are supported
+ * and also the number of different channels, along with potentially
+ * some other restrictions. See &enum nl80211_if_combination_attrs.
+ *
+ * All together, these attributes define the concurrency of virtual
+ * interfaces that a given device supports.
+ */
+
+/**
+ * enum nl80211_commands - supported nl80211 commands
+ *
+ * @NL80211_CMD_UNSPEC: unspecified command to catch errors
+ *
+ * @NL80211_CMD_GET_WIPHY: request information about a wiphy or dump request
+ * to get a list of all present wiphys.
+ * @NL80211_CMD_SET_WIPHY: set wiphy parameters, needs %NL80211_ATTR_WIPHY or
+ * %NL80211_ATTR_IFINDEX; can be used to set %NL80211_ATTR_WIPHY_NAME,
+ * %NL80211_ATTR_WIPHY_TXQ_PARAMS, %NL80211_ATTR_WIPHY_FREQ,
+ * %NL80211_ATTR_WIPHY_CHANNEL_TYPE, %NL80211_ATTR_WIPHY_RETRY_SHORT,
+ * %NL80211_ATTR_WIPHY_RETRY_LONG, %NL80211_ATTR_WIPHY_FRAG_THRESHOLD,
+ * and/or %NL80211_ATTR_WIPHY_RTS_THRESHOLD.
+ * However, for setting the channel, see %NL80211_CMD_SET_CHANNEL
+ * instead, the support here is for backward compatibility only.
+ * @NL80211_CMD_NEW_WIPHY: Newly created wiphy, response to get request
+ * or rename notification. Has attributes %NL80211_ATTR_WIPHY and
+ * %NL80211_ATTR_WIPHY_NAME.
+ * @NL80211_CMD_DEL_WIPHY: Wiphy deleted. Has attributes
+ * %NL80211_ATTR_WIPHY and %NL80211_ATTR_WIPHY_NAME.
+ *
+ * @NL80211_CMD_GET_INTERFACE: Request an interface's configuration;
+ * either a dump request on a %NL80211_ATTR_WIPHY or a specific get
+ * on an %NL80211_ATTR_IFINDEX is supported.
+ * @NL80211_CMD_SET_INTERFACE: Set type of a virtual interface, requires
+ * %NL80211_ATTR_IFINDEX and %NL80211_ATTR_IFTYPE.
+ * @NL80211_CMD_NEW_INTERFACE: Newly created virtual interface or response
+ * to %NL80211_CMD_GET_INTERFACE. Has %NL80211_ATTR_IFINDEX,
+ * %NL80211_ATTR_WIPHY and %NL80211_ATTR_IFTYPE attributes. Can also
+ * be sent from userspace to request creation of a new virtual interface,
+ * then requires attributes %NL80211_ATTR_WIPHY, %NL80211_ATTR_IFTYPE and
+ * %NL80211_ATTR_IFNAME.
+ * @NL80211_CMD_DEL_INTERFACE: Virtual interface was deleted, has attributes
+ * %NL80211_ATTR_IFINDEX and %NL80211_ATTR_WIPHY. Can also be sent from
+ * userspace to request deletion of a virtual interface, then requires
+ * attribute %NL80211_ATTR_IFINDEX.
+ *
+ * @NL80211_CMD_GET_KEY: Get sequence counter information for a key specified
+ * by %NL80211_ATTR_KEY_IDX and/or %NL80211_ATTR_MAC.
+ * @NL80211_CMD_SET_KEY: Set key attributes %NL80211_ATTR_KEY_DEFAULT,
+ * %NL80211_ATTR_KEY_DEFAULT_MGMT, or %NL80211_ATTR_KEY_THRESHOLD.
+ * @NL80211_CMD_NEW_KEY: add a key with given %NL80211_ATTR_KEY_DATA,
+ * %NL80211_ATTR_KEY_IDX, %NL80211_ATTR_MAC, %NL80211_ATTR_KEY_CIPHER,
+ * and %NL80211_ATTR_KEY_SEQ attributes.
+ * @NL80211_CMD_DEL_KEY: delete a key identified by %NL80211_ATTR_KEY_IDX
+ * or %NL80211_ATTR_MAC.
+ *
+ * @NL80211_CMD_GET_BEACON: retrieve beacon information (returned in a
+ * %NL80222_CMD_NEW_BEACON message)
+ * @NL80211_CMD_SET_BEACON: set the beacon on an access point interface
+ * using the %NL80211_ATTR_BEACON_INTERVAL, %NL80211_ATTR_DTIM_PERIOD,
+ * %NL80211_ATTR_BEACON_HEAD and %NL80211_ATTR_BEACON_TAIL attributes.
+ * Following attributes are provided for drivers that generate full Beacon
+ * and Probe Response frames internally: %NL80211_ATTR_SSID,
+ * %NL80211_ATTR_HIDDEN_SSID, %NL80211_ATTR_CIPHERS_PAIRWISE,
+ * %NL80211_ATTR_CIPHER_GROUP, %NL80211_ATTR_WPA_VERSIONS,
+ * %NL80211_ATTR_AKM_SUITES, %NL80211_ATTR_PRIVACY,
+ * %NL80211_ATTR_AUTH_TYPE, %NL80211_ATTR_IE, %NL80211_ATTR_IE_PROBE_RESP,
+ * %NL80211_ATTR_IE_ASSOC_RESP.
+ * @NL80211_CMD_NEW_BEACON: add a new beacon to an access point interface,
+ * parameters are like for %NL80211_CMD_SET_BEACON.
+ * @NL80211_CMD_DEL_BEACON: remove the beacon, stop sending it
+ *
+ * @NL80211_CMD_GET_STATION: Get station attributes for station identified by
+ * %NL80211_ATTR_MAC on the interface identified by %NL80211_ATTR_IFINDEX.
+ * @NL80211_CMD_SET_STATION: Set station attributes for station identified by
+ * %NL80211_ATTR_MAC on the interface identified by %NL80211_ATTR_IFINDEX.
+ * @NL80211_CMD_NEW_STATION: Add a station with given attributes to the
+ * the interface identified by %NL80211_ATTR_IFINDEX.
+ * @NL80211_CMD_DEL_STATION: Remove a station identified by %NL80211_ATTR_MAC
+ * or, if no MAC address given, all stations, on the interface identified
+ * by %NL80211_ATTR_IFINDEX.
+ *
+ * @NL80211_CMD_GET_MPATH: Get mesh path attributes for mesh path to
+ * destination %NL80211_ATTR_MAC on the interface identified by
+ * %NL80211_ATTR_IFINDEX.
+ * @NL80211_CMD_SET_MPATH: Set mesh path attributes for mesh path to
+ * destination %NL80211_ATTR_MAC on the interface identified by
+ * %NL80211_ATTR_IFINDEX.
+ * @NL80211_CMD_NEW_MPATH: Create a new mesh path for the destination given by
+ * %NL80211_ATTR_MAC via %NL80211_ATTR_MPATH_NEXT_HOP.
+ * @NL80211_CMD_DEL_MPATH: Delete a mesh path to the destination given by
+ * %NL80211_ATTR_MAC.
+ * @NL80211_CMD_NEW_PATH: Add a mesh path with given attributes to the
+ * the interface identified by %NL80211_ATTR_IFINDEX.
+ * @NL80211_CMD_DEL_PATH: Remove a mesh path identified by %NL80211_ATTR_MAC
+ * or, if no MAC address given, all mesh paths, on the interface identified
+ * by %NL80211_ATTR_IFINDEX.
+ * @NL80211_CMD_SET_BSS: Set BSS attributes for BSS identified by
+ * %NL80211_ATTR_IFINDEX.
+ *
+ * @NL80211_CMD_GET_REG: ask the wireless core to send us its currently set
+ * regulatory domain.
+ * @NL80211_CMD_SET_REG: Set current regulatory domain. CRDA sends this command
+ * after being queried by the kernel. CRDA replies by sending a regulatory
+ * domain structure which consists of %NL80211_ATTR_REG_ALPHA set to our
+ * current alpha2 if it found a match. It also provides
+ * NL80211_ATTR_REG_RULE_FLAGS, and a set of regulatory rules. Each
+ * regulatory rule is a nested set of attributes given by
+ * %NL80211_ATTR_REG_RULE_FREQ_[START|END] and
+ * %NL80211_ATTR_FREQ_RANGE_MAX_BW with an attached power rule given by
+ * %NL80211_ATTR_REG_RULE_POWER_MAX_ANT_GAIN and
+ * %NL80211_ATTR_REG_RULE_POWER_MAX_EIRP.
+ * @NL80211_CMD_REQ_SET_REG: ask the wireless core to set the regulatory domain
+ * to the specified ISO/IEC 3166-1 alpha2 country code. The core will
+ * store this as a valid request and then query userspace for it.
+ *
+ * @NL80211_CMD_GET_MESH_CONFIG: Get mesh networking properties for the
+ * interface identified by %NL80211_ATTR_IFINDEX
+ *
+ * @NL80211_CMD_SET_MESH_CONFIG: Set mesh networking properties for the
+ * interface identified by %NL80211_ATTR_IFINDEX
+ *
+ * @NL80211_CMD_SET_MGMT_EXTRA_IE: Set extra IEs for management frames. The
+ * interface is identified with %NL80211_ATTR_IFINDEX and the management
+ * frame subtype with %NL80211_ATTR_MGMT_SUBTYPE. The extra IE data to be
+ * added to the end of the specified management frame is specified with
+ * %NL80211_ATTR_IE. If the command succeeds, the requested data will be
+ * added to all specified management frames generated by
+ * kernel/firmware/driver.
+ * Note: This command has been removed and it is only reserved at this
+ * point to avoid re-using existing command number. The functionality this
+ * command was planned for has been provided with cleaner design with the
+ * option to specify additional IEs in NL80211_CMD_TRIGGER_SCAN,
+ * NL80211_CMD_AUTHENTICATE, NL80211_CMD_ASSOCIATE,
+ * NL80211_CMD_DEAUTHENTICATE, and NL80211_CMD_DISASSOCIATE.
+ *
+ * @NL80211_CMD_GET_SCAN: get scan results
+ * @NL80211_CMD_TRIGGER_SCAN: trigger a new scan with the given parameters
+ * %NL80211_ATTR_TX_NO_CCK_RATE is used to decide whether to send the
+ * probe requests at CCK rate or not.
+ * @NL80211_CMD_NEW_SCAN_RESULTS: scan notification (as a reply to
+ * NL80211_CMD_GET_SCAN and on the "scan" multicast group)
+ * @NL80211_CMD_SCAN_ABORTED: scan was aborted, for unspecified reasons,
+ * partial scan results may be available
+ *
+ * @NL80211_CMD_START_SCHED_SCAN: start a scheduled scan at certain
+ * intervals, as specified by %NL80211_ATTR_SCHED_SCAN_INTERVAL.
+ * Like with normal scans, if SSIDs (%NL80211_ATTR_SCAN_SSIDS)
+ * are passed, they are used in the probe requests. For
+ * broadcast, a broadcast SSID must be passed (ie. an empty
+ * string). If no SSID is passed, no probe requests are sent and
+ * a passive scan is performed. %NL80211_ATTR_SCAN_FREQUENCIES,
+ * if passed, define which channels should be scanned; if not
+ * passed, all channels allowed for the current regulatory domain
+ * are used. Extra IEs can also be passed from the userspace by
+ * using the %NL80211_ATTR_IE attribute.
+ * @NL80211_CMD_STOP_SCHED_SCAN: stop a scheduled scan. Returns -ENOENT
+ * if scheduled scan is not running.
+ * @NL80211_CMD_SCHED_SCAN_RESULTS: indicates that there are scheduled scan
+ * results available.
+ * @NL80211_CMD_SCHED_SCAN_STOPPED: indicates that the scheduled scan has
+ * stopped. The driver may issue this event at any time during a
+ * scheduled scan. One reason for stopping the scan is if the hardware
+ * does not support starting an association or a normal scan while running
+ * a scheduled scan. This event is also sent when the
+ * %NL80211_CMD_STOP_SCHED_SCAN command is received or when the interface
+ * is brought down while a scheduled scan was running.
+ *
+ * @NL80211_CMD_GET_SURVEY: get survey resuls, e.g. channel occupation
+ * or noise level
+ * @NL80211_CMD_NEW_SURVEY_RESULTS: survey data notification (as a reply to
+ * NL80211_CMD_GET_SURVEY and on the "scan" multicast group)
+ *
+ * @NL80211_CMD_REG_CHANGE: indicates to userspace the regulatory domain
+ * has been changed and provides details of the request information
+ * that caused the change such as who initiated the regulatory request
+ * (%NL80211_ATTR_REG_INITIATOR), the wiphy_idx
+ * (%NL80211_ATTR_REG_ALPHA2) on which the request was made from if
+ * the initiator was %NL80211_REGDOM_SET_BY_COUNTRY_IE or
+ * %NL80211_REGDOM_SET_BY_DRIVER, the type of regulatory domain
+ * set (%NL80211_ATTR_REG_TYPE), if the type of regulatory domain is
+ * %NL80211_REG_TYPE_COUNTRY the alpha2 to which we have moved on
+ * to (%NL80211_ATTR_REG_ALPHA2).
+ * @NL80211_CMD_REG_BEACON_HINT: indicates to userspace that an AP beacon
+ * has been found while world roaming thus enabling active scan or
+ * any mode of operation that initiates TX (beacons) on a channel
+ * where we would not have been able to do either before. As an example
+ * if you are world roaming (regulatory domain set to world or if your
+ * driver is using a custom world roaming regulatory domain) and while
+ * doing a passive scan on the 5 GHz band you find an AP there (if not
+ * on a DFS channel) you will now be able to actively scan for that AP
+ * or use AP mode on your card on that same channel. Note that this will
+ * never be used for channels 1-11 on the 2 GHz band as they are always
+ * enabled world wide. This beacon hint is only sent if your device had
+ * either disabled active scanning or beaconing on a channel. We send to
+ * userspace the wiphy on which we removed a restriction from
+ * (%NL80211_ATTR_WIPHY) and the channel on which this occurred
+ * before (%NL80211_ATTR_FREQ_BEFORE) and after (%NL80211_ATTR_FREQ_AFTER)
+ * the beacon hint was processed.
+ *
+ * @NL80211_CMD_AUTHENTICATE: authentication request and notification.
+ * This command is used both as a command (request to authenticate) and
+ * as an event on the "mlme" multicast group indicating completion of the
+ * authentication process.
+ * When used as a command, %NL80211_ATTR_IFINDEX is used to identify the
+ * interface. %NL80211_ATTR_MAC is used to specify PeerSTAAddress (and
+ * BSSID in case of station mode). %NL80211_ATTR_SSID is used to specify
+ * the SSID (mainly for association, but is included in authentication
+ * request, too, to help BSS selection. %NL80211_ATTR_WIPHY_FREQ is used
+ * to specify the frequence of the channel in MHz. %NL80211_ATTR_AUTH_TYPE
+ * is used to specify the authentication type. %NL80211_ATTR_IE is used to
+ * define IEs (VendorSpecificInfo, but also including RSN IE and FT IEs)
+ * to be added to the frame.
+ * When used as an event, this reports reception of an Authentication
+ * frame in station and IBSS modes when the local MLME processed the
+ * frame, i.e., it was for the local STA and was received in correct
+ * state. This is similar to MLME-AUTHENTICATE.confirm primitive in the
+ * MLME SAP interface (kernel providing MLME, userspace SME). The
+ * included %NL80211_ATTR_FRAME attribute contains the management frame
+ * (including both the header and frame body, but not FCS). This event is
+ * also used to indicate if the authentication attempt timed out. In that
+ * case the %NL80211_ATTR_FRAME attribute is replaced with a
+ * %NL80211_ATTR_TIMED_OUT flag (and %NL80211_ATTR_MAC to indicate which
+ * pending authentication timed out).
+ * @NL80211_CMD_ASSOCIATE: association request and notification; like
+ * NL80211_CMD_AUTHENTICATE but for Association and Reassociation
+ * (similar to MLME-ASSOCIATE.request, MLME-REASSOCIATE.request,
+ * MLME-ASSOCIATE.confirm or MLME-REASSOCIATE.confirm primitives).
+ * @NL80211_CMD_DEAUTHENTICATE: deauthentication request and notification; like
+ * NL80211_CMD_AUTHENTICATE but for Deauthentication frames (similar to
+ * MLME-DEAUTHENTICATION.request and MLME-DEAUTHENTICATE.indication
+ * primitives).
+ * @NL80211_CMD_DISASSOCIATE: disassociation request and notification; like
+ * NL80211_CMD_AUTHENTICATE but for Disassociation frames (similar to
+ * MLME-DISASSOCIATE.request and MLME-DISASSOCIATE.indication primitives).
+ *
+ * @NL80211_CMD_MICHAEL_MIC_FAILURE: notification of a locally detected Michael
+ * MIC (part of TKIP) failure; sent on the "mlme" multicast group; the
+ * event includes %NL80211_ATTR_MAC to describe the source MAC address of
+ * the frame with invalid MIC, %NL80211_ATTR_KEY_TYPE to show the key
+ * type, %NL80211_ATTR_KEY_IDX to indicate the key identifier, and
+ * %NL80211_ATTR_KEY_SEQ to indicate the TSC value of the frame; this
+ * event matches with MLME-MICHAELMICFAILURE.indication() primitive
+ *
+ * @NL80211_CMD_JOIN_IBSS: Join a new IBSS -- given at least an SSID and a
+ * FREQ attribute (for the initial frequency if no peer can be found)
+ * and optionally a MAC (as BSSID) and FREQ_FIXED attribute if those
+ * should be fixed rather than automatically determined. Can only be
+ * executed on a network interface that is UP, and fixed BSSID/FREQ
+ * may be rejected. Another optional parameter is the beacon interval,
+ * given in the %NL80211_ATTR_BEACON_INTERVAL attribute, which if not
+ * given defaults to 100 TU (102.4ms).
+ * @NL80211_CMD_LEAVE_IBSS: Leave the IBSS -- no special arguments, the IBSS is
+ * determined by the network interface.
+ *
+ * @NL80211_CMD_TESTMODE: testmode command, takes a wiphy (or ifindex) attribute
+ * to identify the device, and the TESTDATA blob attribute to pass through
+ * to the driver.
+ *
+ * @NL80211_CMD_CONNECT: connection request and notification; this command
+ * requests to connect to a specified network but without separating
+ * auth and assoc steps. For this, you need to specify the SSID in a
+ * %NL80211_ATTR_SSID attribute, and can optionally specify the association
+ * IEs in %NL80211_ATTR_IE, %NL80211_ATTR_AUTH_TYPE, %NL80211_ATTR_MAC,
+ * %NL80211_ATTR_WIPHY_FREQ, %NL80211_ATTR_CONTROL_PORT,
+ * %NL80211_ATTR_CONTROL_PORT_ETHERTYPE and
+ * %NL80211_ATTR_CONTROL_PORT_NO_ENCRYPT.
+ * It is also sent as an event, with the BSSID and response IEs when the
+ * connection is established or failed to be established. This can be
+ * determined by the STATUS_CODE attribute.
+ * @NL80211_CMD_ROAM: request that the card roam (currently not implemented),
+ * sent as an event when the card/driver roamed by itself.
+ * @NL80211_CMD_DISCONNECT: drop a given connection; also used to notify
+ * userspace that a connection was dropped by the AP or due to other
+ * reasons, for this the %NL80211_ATTR_DISCONNECTED_BY_AP and
+ * %NL80211_ATTR_REASON_CODE attributes are used.
+ *
+ * @NL80211_CMD_SET_WIPHY_NETNS: Set a wiphy's netns. Note that all devices
+ * associated with this wiphy must be down and will follow.
+ *
+ * @NL80211_CMD_REMAIN_ON_CHANNEL: Request to remain awake on the specified
+ * channel for the specified amount of time. This can be used to do
+ * off-channel operations like transmit a Public Action frame and wait for
+ * a response while being associated to an AP on another channel.
+ * %NL80211_ATTR_IFINDEX is used to specify which interface (and thus
+ * radio) is used. %NL80211_ATTR_WIPHY_FREQ is used to specify the
+ * frequency for the operation and %NL80211_ATTR_WIPHY_CHANNEL_TYPE may be
+ * optionally used to specify additional channel parameters.
+ * %NL80211_ATTR_DURATION is used to specify the duration in milliseconds
+ * to remain on the channel. This command is also used as an event to
+ * notify when the requested duration starts (it may take a while for the
+ * driver to schedule this time due to other concurrent needs for the
+ * radio).
+ * When called, this operation returns a cookie (%NL80211_ATTR_COOKIE)
+ * that will be included with any events pertaining to this request;
+ * the cookie is also used to cancel the request.
+ * @NL80211_CMD_CANCEL_REMAIN_ON_CHANNEL: This command can be used to cancel a
+ * pending remain-on-channel duration if the desired operation has been
+ * completed prior to expiration of the originally requested duration.
+ * %NL80211_ATTR_WIPHY or %NL80211_ATTR_IFINDEX is used to specify the
+ * radio. The %NL80211_ATTR_COOKIE attribute must be given as well to
+ * uniquely identify the request.
+ * This command is also used as an event to notify when a requested
+ * remain-on-channel duration has expired.
+ *
+ * @NL80211_CMD_SET_TX_BITRATE_MASK: Set the mask of rates to be used in TX
+ * rate selection. %NL80211_ATTR_IFINDEX is used to specify the interface
+ * and @NL80211_ATTR_TX_RATES the set of allowed rates.
+ *
+ * @NL80211_CMD_REGISTER_FRAME: Register for receiving certain mgmt frames
+ * (via @NL80211_CMD_FRAME) for processing in userspace. This command
+ * requires an interface index, a frame type attribute (optional for
+ * backward compatibility reasons, if not given assumes action frames)
+ * and a match attribute containing the first few bytes of the frame
+ * that should match, e.g. a single byte for only a category match or
+ * four bytes for vendor frames including the OUI. The registration
+ * cannot be dropped, but is removed automatically when the netlink
+ * socket is closed. Multiple registrations can be made.
+ * @NL80211_CMD_REGISTER_ACTION: Alias for @NL80211_CMD_REGISTER_FRAME for
+ * backward compatibility
+ * @NL80211_CMD_FRAME: Management frame TX request and RX notification. This
+ * command is used both as a request to transmit a management frame and
+ * as an event indicating reception of a frame that was not processed in
+ * kernel code, but is for us (i.e., which may need to be processed in a
+ * user space application). %NL80211_ATTR_FRAME is used to specify the
+ * frame contents (including header). %NL80211_ATTR_WIPHY_FREQ (and
+ * optionally %NL80211_ATTR_WIPHY_CHANNEL_TYPE) is used to indicate on
+ * which channel the frame is to be transmitted or was received. If this
+ * channel is not the current channel (remain-on-channel or the
+ * operational channel) the device will switch to the given channel and
+ * transmit the frame, optionally waiting for a response for the time
+ * specified using %NL80211_ATTR_DURATION. When called, this operation
+ * returns a cookie (%NL80211_ATTR_COOKIE) that will be included with the
+ * TX status event pertaining to the TX request.
+ * %NL80211_ATTR_TX_NO_CCK_RATE is used to decide whether to send the
+ * management frames at CCK rate or not in 2GHz band.
+ * @NL80211_CMD_FRAME_WAIT_CANCEL: When an off-channel TX was requested, this
+ * command may be used with the corresponding cookie to cancel the wait
+ * time if it is known that it is no longer necessary.
+ * @NL80211_CMD_ACTION: Alias for @NL80211_CMD_FRAME for backward compatibility.
+ * @NL80211_CMD_FRAME_TX_STATUS: Report TX status of a management frame
+ * transmitted with %NL80211_CMD_FRAME. %NL80211_ATTR_COOKIE identifies
+ * the TX command and %NL80211_ATTR_FRAME includes the contents of the
+ * frame. %NL80211_ATTR_ACK flag is included if the recipient acknowledged
+ * the frame.
+ * @NL80211_CMD_ACTION_TX_STATUS: Alias for @NL80211_CMD_FRAME_TX_STATUS for
+ * backward compatibility.
+ * @NL80211_CMD_SET_CQM: Connection quality monitor configuration. This command
+ * is used to configure connection quality monitoring notification trigger
+ * levels.
+ * @NL80211_CMD_NOTIFY_CQM: Connection quality monitor notification. This
+ * command is used as an event to indicate the that a trigger level was
+ * reached.
+ * @NL80211_CMD_SET_CHANNEL: Set the channel (using %NL80211_ATTR_WIPHY_FREQ
+ * and %NL80211_ATTR_WIPHY_CHANNEL_TYPE) the given interface (identifed
+ * by %NL80211_ATTR_IFINDEX) shall operate on.
+ * In case multiple channels are supported by the device, the mechanism
+ * with which it switches channels is implementation-defined.
+ * When a monitor interface is given, it can only switch channel while
+ * no other interfaces are operating to avoid disturbing the operation
+ * of any other interfaces, and other interfaces will again take
+ * precedence when they are used.
+ *
+ * @NL80211_CMD_SET_WDS_PEER: Set the MAC address of the peer on a WDS interface.
+ *
+ * @NL80211_CMD_JOIN_MESH: Join a mesh. The mesh ID must be given, and initial
+ * mesh config parameters may be given.
+ * @NL80211_CMD_LEAVE_MESH: Leave the mesh network -- no special arguments, the
+ * network is determined by the network interface.
+ *
+ * @NL80211_CMD_UNPROT_DEAUTHENTICATE: Unprotected deauthentication frame
+ * notification. This event is used to indicate that an unprotected
+ * deauthentication frame was dropped when MFP is in use.
+ * @NL80211_CMD_UNPROT_DISASSOCIATE: Unprotected disassociation frame
+ * notification. This event is used to indicate that an unprotected
+ * disassociation frame was dropped when MFP is in use.
+ *
+ * @NL80211_CMD_NEW_PEER_CANDIDATE: Notification on the reception of a
+ * beacon or probe response from a compatible mesh peer. This is only
+ * sent while no station information (sta_info) exists for the new peer
+ * candidate and when @NL80211_MESH_SETUP_USERSPACE_AUTH is set. On
+ * reception of this notification, userspace may decide to create a new
+ * station (@NL80211_CMD_NEW_STATION). To stop this notification from
+ * reoccurring, the userspace authentication daemon may want to create the
+ * new station with the AUTHENTICATED flag unset and maybe change it later
+ * depending on the authentication result.
+ *
+ * @NL80211_CMD_GET_WOWLAN: get Wake-on-Wireless-LAN (WoWLAN) settings.
+ * @NL80211_CMD_SET_WOWLAN: set Wake-on-Wireless-LAN (WoWLAN) settings.
+ * Since wireless is more complex than wired ethernet, it supports
+ * various triggers. These triggers can be configured through this
+ * command with the %NL80211_ATTR_WOWLAN_TRIGGERS attribute. For
+ * more background information, see
+ * http://wireless.kernel.org/en/users/Documentation/WoWLAN.
+ *
+ * @NL80211_CMD_SET_REKEY_OFFLOAD: This command is used give the driver
+ * the necessary information for supporting GTK rekey offload. This
+ * feature is typically used during WoWLAN. The configuration data
+ * is contained in %NL80211_ATTR_REKEY_DATA (which is nested and
+ * contains the data in sub-attributes). After rekeying happened,
+ * this command may also be sent by the driver as an MLME event to
+ * inform userspace of the new replay counter.
+ *
+ * @NL80211_CMD_PMKSA_CANDIDATE: This is used as an event to inform userspace
+ * of PMKSA caching dandidates.
+ *
+ * @NL80211_CMD_TDLS_OPER: Perform a high-level TDLS command (e.g. link setup).
+ * @NL80211_CMD_TDLS_MGMT: Send a TDLS management frame.
+ *
+ * @NL80211_CMD_UNEXPECTED_FRAME: Used by an application controlling an AP
+ * (or GO) interface (i.e. hostapd) to ask for unexpected frames to
+ * implement sending deauth to stations that send unexpected class 3
+ * frames. Also used as the event sent by the kernel when such a frame
+ * is received.
+ * For the event, the %NL80211_ATTR_MAC attribute carries the TA and
+ * other attributes like the interface index are present.
+ * If used as the command it must have an interface index and you can
+ * only unsubscribe from the event by closing the socket. Subscription
+ * is also for %NL80211_CMD_UNEXPECTED_4ADDR_FRAME events.
+ *
+ * @NL80211_CMD_UNEXPECTED_4ADDR_FRAME: Sent as an event indicating that the
+ * associated station identified by %NL80211_ATTR_MAC sent a 4addr frame
+ * and wasn't already in a 4-addr VLAN. The event will be sent similarly
+ * to the %NL80211_CMD_UNEXPECTED_FRAME event, to the same listener.
+ *
+ * @NL80211_CMD_PROBE_CLIENT: Probe an associated station on an AP interface
+ * by sending a null data frame to it and reporting when the frame is
+ * acknowleged. This is used to allow timing out inactive clients. Uses
+ * %NL80211_ATTR_IFINDEX and %NL80211_ATTR_MAC. The command returns a
+ * direct reply with an %NL80211_ATTR_COOKIE that is later used to match
+ * up the event with the request. The event includes the same data and
+ * has %NL80211_ATTR_ACK set if the frame was ACKed.
+ *
+ * @NL80211_CMD_REGISTER_BEACONS: Register this socket to receive beacons from
+ * other BSSes when any interfaces are in AP mode. This helps implement
+ * OLBC handling in hostapd. Beacons are reported in %NL80211_CMD_FRAME
+ * messages. Note that per PHY only one application may register.
+ *
+ * @NL80211_CMD_SET_NOACK_MAP: sets a bitmap for the individual TIDs whether
+ * No Acknowledgement Policy should be applied.
+ *
+ * @NL80211_CMD_MAX: highest used command number
+ * @__NL80211_CMD_AFTER_LAST: internal use
+ */
+enum nl80211_commands {
+/* don't change the order or add anything between, this is ABI! */
+ NL80211_CMD_UNSPEC,
+
+ NL80211_CMD_GET_WIPHY, /* can dump */
+ NL80211_CMD_SET_WIPHY,
+ NL80211_CMD_NEW_WIPHY,
+ NL80211_CMD_DEL_WIPHY,
+
+ NL80211_CMD_GET_INTERFACE, /* can dump */
+ NL80211_CMD_SET_INTERFACE,
+ NL80211_CMD_NEW_INTERFACE,
+ NL80211_CMD_DEL_INTERFACE,
+
+ NL80211_CMD_GET_KEY,
+ NL80211_CMD_SET_KEY,
+ NL80211_CMD_NEW_KEY,
+ NL80211_CMD_DEL_KEY,
+
+ NL80211_CMD_GET_BEACON,
+ NL80211_CMD_SET_BEACON,
+ NL80211_CMD_NEW_BEACON,
+ NL80211_CMD_DEL_BEACON,
+
+ NL80211_CMD_GET_STATION,
+ NL80211_CMD_SET_STATION,
+ NL80211_CMD_NEW_STATION,
+ NL80211_CMD_DEL_STATION,
+
+ NL80211_CMD_GET_MPATH,
+ NL80211_CMD_SET_MPATH,
+ NL80211_CMD_NEW_MPATH,
+ NL80211_CMD_DEL_MPATH,
+
+ NL80211_CMD_SET_BSS,
+
+ NL80211_CMD_SET_REG,
+ NL80211_CMD_REQ_SET_REG,
+
+ NL80211_CMD_GET_MESH_CONFIG,
+ NL80211_CMD_SET_MESH_CONFIG,
+
+ NL80211_CMD_SET_MGMT_EXTRA_IE /* reserved; not used */,
+
+ NL80211_CMD_GET_REG,
+
+ NL80211_CMD_GET_SCAN,
+ NL80211_CMD_TRIGGER_SCAN,
+ NL80211_CMD_NEW_SCAN_RESULTS,
+ NL80211_CMD_SCAN_ABORTED,
+
+ NL80211_CMD_REG_CHANGE,
+
+ NL80211_CMD_AUTHENTICATE,
+ NL80211_CMD_ASSOCIATE,
+ NL80211_CMD_DEAUTHENTICATE,
+ NL80211_CMD_DISASSOCIATE,
+
+ NL80211_CMD_MICHAEL_MIC_FAILURE,
+
+ NL80211_CMD_REG_BEACON_HINT,
+
+ NL80211_CMD_JOIN_IBSS,
+ NL80211_CMD_LEAVE_IBSS,
+
+ NL80211_CMD_TESTMODE,
+
+ NL80211_CMD_CONNECT,
+ NL80211_CMD_ROAM,
+ NL80211_CMD_DISCONNECT,
+
+ NL80211_CMD_SET_WIPHY_NETNS,
+
+ NL80211_CMD_GET_SURVEY,
+ NL80211_CMD_NEW_SURVEY_RESULTS,
+
+ NL80211_CMD_SET_PMKSA,
+ NL80211_CMD_DEL_PMKSA,
+ NL80211_CMD_FLUSH_PMKSA,
+
+ NL80211_CMD_REMAIN_ON_CHANNEL,
+ NL80211_CMD_CANCEL_REMAIN_ON_CHANNEL,
+
+ NL80211_CMD_SET_TX_BITRATE_MASK,
+
+ NL80211_CMD_REGISTER_FRAME,
+ NL80211_CMD_REGISTER_ACTION = NL80211_CMD_REGISTER_FRAME,
+ NL80211_CMD_FRAME,
+ NL80211_CMD_ACTION = NL80211_CMD_FRAME,
+ NL80211_CMD_FRAME_TX_STATUS,
+ NL80211_CMD_ACTION_TX_STATUS = NL80211_CMD_FRAME_TX_STATUS,
+
+ NL80211_CMD_SET_POWER_SAVE,
+ NL80211_CMD_GET_POWER_SAVE,
+
+ NL80211_CMD_SET_CQM,
+ NL80211_CMD_NOTIFY_CQM,
+
+ NL80211_CMD_SET_CHANNEL,
+ NL80211_CMD_SET_WDS_PEER,
+
+ NL80211_CMD_FRAME_WAIT_CANCEL,
+
+ NL80211_CMD_JOIN_MESH,
+ NL80211_CMD_LEAVE_MESH,
+
+ NL80211_CMD_UNPROT_DEAUTHENTICATE,
+ NL80211_CMD_UNPROT_DISASSOCIATE,
+
+ NL80211_CMD_NEW_PEER_CANDIDATE,
+
+ NL80211_CMD_GET_WOWLAN,
+ NL80211_CMD_SET_WOWLAN,
+
+ NL80211_CMD_START_SCHED_SCAN,
+ NL80211_CMD_STOP_SCHED_SCAN,
+ NL80211_CMD_SCHED_SCAN_RESULTS,
+ NL80211_CMD_SCHED_SCAN_STOPPED,
+
+ NL80211_CMD_SET_REKEY_OFFLOAD,
+
+ NL80211_CMD_PMKSA_CANDIDATE,
+
+ NL80211_CMD_TDLS_OPER,
+ NL80211_CMD_TDLS_MGMT,
+
+ NL80211_CMD_UNEXPECTED_FRAME,
+
+ NL80211_CMD_PROBE_CLIENT,
+
+ NL80211_CMD_REGISTER_BEACONS,
+
+ NL80211_CMD_UNEXPECTED_4ADDR_FRAME,
+
+ NL80211_CMD_SET_NOACK_MAP,
+
+ /* add new commands above here */
+
+ /* used to define NL80211_CMD_MAX below */
+ __NL80211_CMD_AFTER_LAST,
+ NL80211_CMD_MAX = __NL80211_CMD_AFTER_LAST - 1
+};
+
+/*
+ * Allow user space programs to use #ifdef on new commands by defining them
+ * here
+ */
+#define NL80211_CMD_SET_BSS NL80211_CMD_SET_BSS
+#define NL80211_CMD_SET_MGMT_EXTRA_IE NL80211_CMD_SET_MGMT_EXTRA_IE
+#define NL80211_CMD_REG_CHANGE NL80211_CMD_REG_CHANGE
+#define NL80211_CMD_AUTHENTICATE NL80211_CMD_AUTHENTICATE
+#define NL80211_CMD_ASSOCIATE NL80211_CMD_ASSOCIATE
+#define NL80211_CMD_DEAUTHENTICATE NL80211_CMD_DEAUTHENTICATE
+#define NL80211_CMD_DISASSOCIATE NL80211_CMD_DISASSOCIATE
+#define NL80211_CMD_REG_BEACON_HINT NL80211_CMD_REG_BEACON_HINT
+
+#define NL80211_ATTR_FEATURE_FLAGS NL80211_ATTR_FEATURE_FLAGS
+
+/* source-level API compatibility */
+#define NL80211_CMD_GET_MESH_PARAMS NL80211_CMD_GET_MESH_CONFIG
+#define NL80211_CMD_SET_MESH_PARAMS NL80211_CMD_SET_MESH_CONFIG
+#define NL80211_MESH_SETUP_VENDOR_PATH_SEL_IE NL80211_MESH_SETUP_IE
+
+/**
+ * enum nl80211_attrs - nl80211 netlink attributes
+ *
+ * @NL80211_ATTR_UNSPEC: unspecified attribute to catch errors
+ *
+ * @NL80211_ATTR_WIPHY: index of wiphy to operate on, cf.
+ * /sys/class/ieee80211/<phyname>/index
+ * @NL80211_ATTR_WIPHY_NAME: wiphy name (used for renaming)
+ * @NL80211_ATTR_WIPHY_TXQ_PARAMS: a nested array of TX queue parameters
+ * @NL80211_ATTR_WIPHY_FREQ: frequency of the selected channel in MHz
+ * @NL80211_ATTR_WIPHY_CHANNEL_TYPE: included with NL80211_ATTR_WIPHY_FREQ
+ * if HT20 or HT40 are allowed (i.e., 802.11n disabled if not included):
+ * NL80211_CHAN_NO_HT = HT not allowed (i.e., same as not including
+ * this attribute)
+ * NL80211_CHAN_HT20 = HT20 only
+ * NL80211_CHAN_HT40MINUS = secondary channel is below the primary channel
+ * NL80211_CHAN_HT40PLUS = secondary channel is above the primary channel
+ * @NL80211_ATTR_WIPHY_RETRY_SHORT: TX retry limit for frames whose length is
+ * less than or equal to the RTS threshold; allowed range: 1..255;
+ * dot11ShortRetryLimit; u8
+ * @NL80211_ATTR_WIPHY_RETRY_LONG: TX retry limit for frames whose length is
+ * greater than the RTS threshold; allowed range: 1..255;
+ * dot11ShortLongLimit; u8
+ * @NL80211_ATTR_WIPHY_FRAG_THRESHOLD: fragmentation threshold, i.e., maximum
+ * length in octets for frames; allowed range: 256..8000, disable
+ * fragmentation with (u32)-1; dot11FragmentationThreshold; u32
+ * @NL80211_ATTR_WIPHY_RTS_THRESHOLD: RTS threshold (TX frames with length
+ * larger than or equal to this use RTS/CTS handshake); allowed range:
+ * 0..65536, disable with (u32)-1; dot11RTSThreshold; u32
+ * @NL80211_ATTR_WIPHY_COVERAGE_CLASS: Coverage Class as defined by IEEE 802.11
+ * section 7.3.2.9; dot11CoverageClass; u8
+ *
+ * @NL80211_ATTR_IFINDEX: network interface index of the device to operate on
+ * @NL80211_ATTR_IFNAME: network interface name
+ * @NL80211_ATTR_IFTYPE: type of virtual interface, see &enum nl80211_iftype
+ *
+ * @NL80211_ATTR_MAC: MAC address (various uses)
+ *
+ * @NL80211_ATTR_KEY_DATA: (temporal) key data; for TKIP this consists of
+ * 16 bytes encryption key followed by 8 bytes each for TX and RX MIC
+ * keys
+ * @NL80211_ATTR_KEY_IDX: key ID (u8, 0-3)
+ * @NL80211_ATTR_KEY_CIPHER: key cipher suite (u32, as defined by IEEE 802.11
+ * section 7.3.2.25.1, e.g. 0x000FAC04)
+ * @NL80211_ATTR_KEY_SEQ: transmit key sequence number (IV/PN) for TKIP and
+ * CCMP keys, each six bytes in little endian
+ *
+ * @NL80211_ATTR_BEACON_INTERVAL: beacon interval in TU
+ * @NL80211_ATTR_DTIM_PERIOD: DTIM period for beaconing
+ * @NL80211_ATTR_BEACON_HEAD: portion of the beacon before the TIM IE
+ * @NL80211_ATTR_BEACON_TAIL: portion of the beacon after the TIM IE
+ *
+ * @NL80211_ATTR_STA_AID: Association ID for the station (u16)
+ * @NL80211_ATTR_STA_FLAGS: flags, nested element with NLA_FLAG attributes of
+ * &enum nl80211_sta_flags (deprecated, use %NL80211_ATTR_STA_FLAGS2)
+ * @NL80211_ATTR_STA_LISTEN_INTERVAL: listen interval as defined by
+ * IEEE 802.11 7.3.1.6 (u16).
+ * @NL80211_ATTR_STA_SUPPORTED_RATES: supported rates, array of supported
+ * rates as defined by IEEE 802.11 7.3.2.2 but without the length
+ * restriction (at most %NL80211_MAX_SUPP_RATES).
+ * @NL80211_ATTR_STA_VLAN: interface index of VLAN interface to move station
+ * to, or the AP interface the station was originally added to to.
+ * @NL80211_ATTR_STA_INFO: information about a station, part of station info
+ * given for %NL80211_CMD_GET_STATION, nested attribute containing
+ * info as possible, see &enum nl80211_sta_info.
+ *
+ * @NL80211_ATTR_WIPHY_BANDS: Information about an operating bands,
+ * consisting of a nested array.
+ *
+ * @NL80211_ATTR_MESH_ID: mesh id (1-32 bytes).
+ * @NL80211_ATTR_STA_PLINK_ACTION: action to perform on the mesh peer link.
+ * @NL80211_ATTR_MPATH_NEXT_HOP: MAC address of the next hop for a mesh path.
+ * @NL80211_ATTR_MPATH_INFO: information about a mesh_path, part of mesh path
+ * info given for %NL80211_CMD_GET_MPATH, nested attribute described at
+ * &enum nl80211_mpath_info.
+ *
+ * @NL80211_ATTR_MNTR_FLAGS: flags, nested element with NLA_FLAG attributes of
+ * &enum nl80211_mntr_flags.
+ *
+ * @NL80211_ATTR_REG_ALPHA2: an ISO-3166-alpha2 country code for which the
+ * current regulatory domain should be set to or is already set to.
+ * For example, 'CR', for Costa Rica. This attribute is used by the kernel
+ * to query the CRDA to retrieve one regulatory domain. This attribute can
+ * also be used by userspace to query the kernel for the currently set
+ * regulatory domain. We chose an alpha2 as that is also used by the
+ * IEEE-802.11d country information element to identify a country.
+ * Users can also simply ask the wireless core to set regulatory domain
+ * to a specific alpha2.
+ * @NL80211_ATTR_REG_RULES: a nested array of regulatory domain regulatory
+ * rules.
+ *
+ * @NL80211_ATTR_BSS_CTS_PROT: whether CTS protection is enabled (u8, 0 or 1)
+ * @NL80211_ATTR_BSS_SHORT_PREAMBLE: whether short preamble is enabled
+ * (u8, 0 or 1)
+ * @NL80211_ATTR_BSS_SHORT_SLOT_TIME: whether short slot time enabled
+ * (u8, 0 or 1)
+ * @NL80211_ATTR_BSS_BASIC_RATES: basic rates, array of basic
+ * rates in format defined by IEEE 802.11 7.3.2.2 but without the length
+ * restriction (at most %NL80211_MAX_SUPP_RATES).
+ *
+ * @NL80211_ATTR_HT_CAPABILITY: HT Capability information element (from
+ * association request when used with NL80211_CMD_NEW_STATION)
+ *
+ * @NL80211_ATTR_SUPPORTED_IFTYPES: nested attribute containing all
+ * supported interface types, each a flag attribute with the number
+ * of the interface mode.
+ *
+ * @NL80211_ATTR_MGMT_SUBTYPE: Management frame subtype for
+ * %NL80211_CMD_SET_MGMT_EXTRA_IE.
+ *
+ * @NL80211_ATTR_IE: Information element(s) data (used, e.g., with
+ * %NL80211_CMD_SET_MGMT_EXTRA_IE).
+ *
+ * @NL80211_ATTR_MAX_NUM_SCAN_SSIDS: number of SSIDs you can scan with
+ * a single scan request, a wiphy attribute.
+ * @NL80211_ATTR_MAX_NUM_SCHED_SCAN_SSIDS: number of SSIDs you can
+ * scan with a single scheduled scan request, a wiphy attribute.
+ * @NL80211_ATTR_MAX_SCAN_IE_LEN: maximum length of information elements
+ * that can be added to a scan request
+ * @NL80211_ATTR_MAX_SCHED_SCAN_IE_LEN: maximum length of information
+ * elements that can be added to a scheduled scan request
+ * @NL80211_ATTR_MAX_MATCH_SETS: maximum number of sets that can be
+ * used with @NL80211_ATTR_SCHED_SCAN_MATCH, a wiphy attribute.
+ *
+ * @NL80211_ATTR_SCAN_FREQUENCIES: nested attribute with frequencies (in MHz)
+ * @NL80211_ATTR_SCAN_SSIDS: nested attribute with SSIDs, leave out for passive
+ * scanning and include a zero-length SSID (wildcard) for wildcard scan
+ * @NL80211_ATTR_BSS: scan result BSS
+ *
+ * @NL80211_ATTR_REG_INITIATOR: indicates who requested the regulatory domain
+ * currently in effect. This could be any of the %NL80211_REGDOM_SET_BY_*
+ * @NL80211_ATTR_REG_TYPE: indicates the type of the regulatory domain currently
+ * set. This can be one of the nl80211_reg_type (%NL80211_REGDOM_TYPE_*)
+ *
+ * @NL80211_ATTR_SUPPORTED_COMMANDS: wiphy attribute that specifies
+ * an array of command numbers (i.e. a mapping index to command number)
+ * that the driver for the given wiphy supports.
+ *
+ * @NL80211_ATTR_FRAME: frame data (binary attribute), including frame header
+ * and body, but not FCS; used, e.g., with NL80211_CMD_AUTHENTICATE and
+ * NL80211_CMD_ASSOCIATE events
+ * @NL80211_ATTR_SSID: SSID (binary attribute, 0..32 octets)
+ * @NL80211_ATTR_AUTH_TYPE: AuthenticationType, see &enum nl80211_auth_type,
+ * represented as a u32
+ * @NL80211_ATTR_REASON_CODE: ReasonCode for %NL80211_CMD_DEAUTHENTICATE and
+ * %NL80211_CMD_DISASSOCIATE, u16
+ *
+ * @NL80211_ATTR_KEY_TYPE: Key Type, see &enum nl80211_key_type, represented as
+ * a u32
+ *
+ * @NL80211_ATTR_FREQ_BEFORE: A channel which has suffered a regulatory change
+ * due to considerations from a beacon hint. This attribute reflects
+ * the state of the channel _before_ the beacon hint processing. This
+ * attributes consists of a nested attribute containing
+ * NL80211_FREQUENCY_ATTR_*
+ * @NL80211_ATTR_FREQ_AFTER: A channel which has suffered a regulatory change
+ * due to considerations from a beacon hint. This attribute reflects
+ * the state of the channel _after_ the beacon hint processing. This
+ * attributes consists of a nested attribute containing
+ * NL80211_FREQUENCY_ATTR_*
+ *
+ * @NL80211_ATTR_CIPHER_SUITES: a set of u32 values indicating the supported
+ * cipher suites
+ *
+ * @NL80211_ATTR_FREQ_FIXED: a flag indicating the IBSS should not try to look
+ * for other networks on different channels
+ *
+ * @NL80211_ATTR_TIMED_OUT: a flag indicating than an operation timed out; this
+ * is used, e.g., with %NL80211_CMD_AUTHENTICATE event
+ *
+ * @NL80211_ATTR_USE_MFP: Whether management frame protection (IEEE 802.11w) is
+ * used for the association (&enum nl80211_mfp, represented as a u32);
+ * this attribute can be used
+ * with %NL80211_CMD_ASSOCIATE request
+ *
+ * @NL80211_ATTR_STA_FLAGS2: Attribute containing a
+ * &struct nl80211_sta_flag_update.
+ *
+ * @NL80211_ATTR_CONTROL_PORT: A flag indicating whether user space controls
+ * IEEE 802.1X port, i.e., sets/clears %NL80211_STA_FLAG_AUTHORIZED, in
+ * station mode. If the flag is included in %NL80211_CMD_ASSOCIATE
+ * request, the driver will assume that the port is unauthorized until
+ * authorized by user space. Otherwise, port is marked authorized by
+ * default in station mode.
+ * @NL80211_ATTR_CONTROL_PORT_ETHERTYPE: A 16-bit value indicating the
+ * ethertype that will be used for key negotiation. It can be
+ * specified with the associate and connect commands. If it is not
+ * specified, the value defaults to 0x888E (PAE, 802.1X). This
+ * attribute is also used as a flag in the wiphy information to
+ * indicate that protocols other than PAE are supported.
+ * @NL80211_ATTR_CONTROL_PORT_NO_ENCRYPT: When included along with
+ * %NL80211_ATTR_CONTROL_PORT_ETHERTYPE, indicates that the custom
+ * ethertype frames used for key negotiation must not be encrypted.
+ *
+ * @NL80211_ATTR_TESTDATA: Testmode data blob, passed through to the driver.
+ * We recommend using nested, driver-specific attributes within this.
+ *
+ * @NL80211_ATTR_DISCONNECTED_BY_AP: A flag indicating that the DISCONNECT
+ * event was due to the AP disconnecting the station, and not due to
+ * a local disconnect request.
+ * @NL80211_ATTR_STATUS_CODE: StatusCode for the %NL80211_CMD_CONNECT
+ * event (u16)
+ * @NL80211_ATTR_PRIVACY: Flag attribute, used with connect(), indicating
+ * that protected APs should be used. This is also used with NEW_BEACON to
+ * indicate that the BSS is to use protection.
+ *
+ * @NL80211_ATTR_CIPHERS_PAIRWISE: Used with CONNECT, ASSOCIATE, and NEW_BEACON
+ * to indicate which unicast key ciphers will be used with the connection
+ * (an array of u32).
+ * @NL80211_ATTR_CIPHER_GROUP: Used with CONNECT, ASSOCIATE, and NEW_BEACON to
+ * indicate which group key cipher will be used with the connection (a
+ * u32).
+ * @NL80211_ATTR_WPA_VERSIONS: Used with CONNECT, ASSOCIATE, and NEW_BEACON to
+ * indicate which WPA version(s) the AP we want to associate with is using
+ * (a u32 with flags from &enum nl80211_wpa_versions).
+ * @NL80211_ATTR_AKM_SUITES: Used with CONNECT, ASSOCIATE, and NEW_BEACON to
+ * indicate which key management algorithm(s) to use (an array of u32).
+ *
+ * @NL80211_ATTR_REQ_IE: (Re)association request information elements as
+ * sent out by the card, for ROAM and successful CONNECT events.
+ * @NL80211_ATTR_RESP_IE: (Re)association response information elements as
+ * sent by peer, for ROAM and successful CONNECT events.
+ *
+ * @NL80211_ATTR_PREV_BSSID: previous BSSID, to be used by in ASSOCIATE
+ * commands to specify using a reassociate frame
+ *
+ * @NL80211_ATTR_KEY: key information in a nested attribute with
+ * %NL80211_KEY_* sub-attributes
+ * @NL80211_ATTR_KEYS: array of keys for static WEP keys for connect()
+ * and join_ibss(), key information is in a nested attribute each
+ * with %NL80211_KEY_* sub-attributes
+ *
+ * @NL80211_ATTR_PID: Process ID of a network namespace.
+ *
+ * @NL80211_ATTR_GENERATION: Used to indicate consistent snapshots for
+ * dumps. This number increases whenever the object list being
+ * dumped changes, and as such userspace can verify that it has
+ * obtained a complete and consistent snapshot by verifying that
+ * all dump messages contain the same generation number. If it
+ * changed then the list changed and the dump should be repeated
+ * completely from scratch.
+ *
+ * @NL80211_ATTR_4ADDR: Use 4-address frames on a virtual interface
+ *
+ * @NL80211_ATTR_SURVEY_INFO: survey information about a channel, part of
+ * the survey response for %NL80211_CMD_GET_SURVEY, nested attribute
+ * containing info as possible, see &enum survey_info.
+ *
+ * @NL80211_ATTR_PMKID: PMK material for PMKSA caching.
+ * @NL80211_ATTR_MAX_NUM_PMKIDS: maximum number of PMKIDs a firmware can
+ * cache, a wiphy attribute.
+ *
+ * @NL80211_ATTR_DURATION: Duration of an operation in milliseconds, u32.
+ * @NL80211_ATTR_MAX_REMAIN_ON_CHANNEL_DURATION: Device attribute that
+ * specifies the maximum duration that can be requested with the
+ * remain-on-channel operation, in milliseconds, u32.
+ *
+ * @NL80211_ATTR_COOKIE: Generic 64-bit cookie to identify objects.
+ *
+ * @NL80211_ATTR_TX_RATES: Nested set of attributes
+ * (enum nl80211_tx_rate_attributes) describing TX rates per band. The
+ * enum nl80211_band value is used as the index (nla_type() of the nested
+ * data. If a band is not included, it will be configured to allow all
+ * rates based on negotiated supported rates information. This attribute
+ * is used with %NL80211_CMD_SET_TX_BITRATE_MASK.
+ *
+ * @NL80211_ATTR_FRAME_MATCH: A binary attribute which typically must contain
+ * at least one byte, currently used with @NL80211_CMD_REGISTER_FRAME.
+ * @NL80211_ATTR_FRAME_TYPE: A u16 indicating the frame type/subtype for the
+ * @NL80211_CMD_REGISTER_FRAME command.
+ * @NL80211_ATTR_TX_FRAME_TYPES: wiphy capability attribute, which is a
+ * nested attribute of %NL80211_ATTR_FRAME_TYPE attributes, containing
+ * information about which frame types can be transmitted with
+ * %NL80211_CMD_FRAME.
+ * @NL80211_ATTR_RX_FRAME_TYPES: wiphy capability attribute, which is a
+ * nested attribute of %NL80211_ATTR_FRAME_TYPE attributes, containing
+ * information about which frame types can be registered for RX.
+ *
+ * @NL80211_ATTR_ACK: Flag attribute indicating that the frame was
+ * acknowledged by the recipient.
+ *
+ * @NL80211_ATTR_CQM: connection quality monitor configuration in a
+ * nested attribute with %NL80211_ATTR_CQM_* sub-attributes.
+ *
+ * @NL80211_ATTR_LOCAL_STATE_CHANGE: Flag attribute to indicate that a command
+ * is requesting a local authentication/association state change without
+ * invoking actual management frame exchange. This can be used with
+ * NL80211_CMD_AUTHENTICATE, NL80211_CMD_DEAUTHENTICATE,
+ * NL80211_CMD_DISASSOCIATE.
+ *
+ * @NL80211_ATTR_AP_ISOLATE: (AP mode) Do not forward traffic between stations
+ * connected to this BSS.
+ *
+ * @NL80211_ATTR_WIPHY_TX_POWER_SETTING: Transmit power setting type. See
+ * &enum nl80211_tx_power_setting for possible values.
+ * @NL80211_ATTR_WIPHY_TX_POWER_LEVEL: Transmit power level in signed mBm units.
+ * This is used in association with @NL80211_ATTR_WIPHY_TX_POWER_SETTING
+ * for non-automatic settings.
+ *
+ * @NL80211_ATTR_SUPPORT_IBSS_RSN: The device supports IBSS RSN, which mostly
+ * means support for per-station GTKs.
+ *
+ * @NL80211_ATTR_WIPHY_ANTENNA_TX: Bitmap of allowed antennas for transmitting.
+ * This can be used to mask out antennas which are not attached or should
+ * not be used for transmitting. If an antenna is not selected in this
+ * bitmap the hardware is not allowed to transmit on this antenna.
+ *
+ * Each bit represents one antenna, starting with antenna 1 at the first
+ * bit. Depending on which antennas are selected in the bitmap, 802.11n
+ * drivers can derive which chainmasks to use (if all antennas belonging to
+ * a particular chain are disabled this chain should be disabled) and if
+ * a chain has diversity antennas wether diversity should be used or not.
+ * HT capabilities (STBC, TX Beamforming, Antenna selection) can be
+ * derived from the available chains after applying the antenna mask.
+ * Non-802.11n drivers can derive wether to use diversity or not.
+ * Drivers may reject configurations or RX/TX mask combinations they cannot
+ * support by returning -EINVAL.
+ *
+ * @NL80211_ATTR_WIPHY_ANTENNA_RX: Bitmap of allowed antennas for receiving.
+ * This can be used to mask out antennas which are not attached or should
+ * not be used for receiving. If an antenna is not selected in this bitmap
+ * the hardware should not be configured to receive on this antenna.
+ * For a more detailed description see @NL80211_ATTR_WIPHY_ANTENNA_TX.
+ *
+ * @NL80211_ATTR_WIPHY_ANTENNA_AVAIL_TX: Bitmap of antennas which are available
+ * for configuration as TX antennas via the above parameters.
+ *
+ * @NL80211_ATTR_WIPHY_ANTENNA_AVAIL_RX: Bitmap of antennas which are available
+ * for configuration as RX antennas via the above parameters.
+ *
+ * @NL80211_ATTR_MCAST_RATE: Multicast tx rate (in 100 kbps) for IBSS
+ *
+ * @NL80211_ATTR_OFFCHANNEL_TX_OK: For management frame TX, the frame may be
+ * transmitted on another channel when the channel given doesn't match
+ * the current channel. If the current channel doesn't match and this
+ * flag isn't set, the frame will be rejected. This is also used as an
+ * nl80211 capability flag.
+ *
+ * @NL80211_ATTR_BSS_HTOPMODE: HT operation mode (u16)
+ *
+ * @NL80211_ATTR_KEY_DEFAULT_TYPES: A nested attribute containing flags
+ * attributes, specifying what a key should be set as default as.
+ * See &enum nl80211_key_default_types.
+ *
+ * @NL80211_ATTR_MESH_SETUP: Optional mesh setup parameters. These cannot be
+ * changed once the mesh is active.
+ * @NL80211_ATTR_MESH_CONFIG: Mesh configuration parameters, a nested attribute
+ * containing attributes from &enum nl80211_meshconf_params.
+ * @NL80211_ATTR_SUPPORT_MESH_AUTH: Currently, this means the underlying driver
+ * allows auth frames in a mesh to be passed to userspace for processing via
+ * the @NL80211_MESH_SETUP_USERSPACE_AUTH flag.
+ * @NL80211_ATTR_STA_PLINK_STATE: The state of a mesh peer link as
+ * defined in &enum nl80211_plink_state. Used when userspace is
+ * driving the peer link management state machine.
+ * @NL80211_MESH_SETUP_USERSPACE_AMPE must be enabled.
+ *
+ * @NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED: indicates, as part of the wiphy
+ * capabilities, the supported WoWLAN triggers
+ * @NL80211_ATTR_WOWLAN_TRIGGERS: used by %NL80211_CMD_SET_WOWLAN to
+ * indicate which WoW triggers should be enabled. This is also
+ * used by %NL80211_CMD_GET_WOWLAN to get the currently enabled WoWLAN
+ * triggers.
+
+ * @NL80211_ATTR_SCHED_SCAN_INTERVAL: Interval between scheduled scan
+ * cycles, in msecs.
+
+ * @NL80211_ATTR_SCHED_SCAN_MATCH: Nested attribute with one or more
+ * sets of attributes to match during scheduled scans. Only BSSs
+ * that match any of the sets will be reported. These are
+ * pass-thru filter rules.
+ * For a match to succeed, the BSS must match all attributes of a
+ * set. Since not every hardware supports matching all types of
+ * attributes, there is no guarantee that the reported BSSs are
+ * fully complying with the match sets and userspace needs to be
+ * able to ignore them by itself.
+ * Thus, the implementation is somewhat hardware-dependent, but
+ * this is only an optimization and the userspace application
+ * needs to handle all the non-filtered results anyway.
+ * If the match attributes don't make sense when combined with
+ * the values passed in @NL80211_ATTR_SCAN_SSIDS (eg. if an SSID
+ * is included in the probe request, but the match attributes
+ * will never let it go through), -EINVAL may be returned.
+ * If ommited, no filtering is done.
+ *
+ * @NL80211_ATTR_INTERFACE_COMBINATIONS: Nested attribute listing the supported
+ * interface combinations. In each nested item, it contains attributes
+ * defined in &enum nl80211_if_combination_attrs.
+ * @NL80211_ATTR_SOFTWARE_IFTYPES: Nested attribute (just like
+ * %NL80211_ATTR_SUPPORTED_IFTYPES) containing the interface types that
+ * are managed in software: interfaces of these types aren't subject to
+ * any restrictions in their number or combinations.
+ *
+ * @%NL80211_ATTR_REKEY_DATA: nested attribute containing the information
+ * necessary for GTK rekeying in the device, see &enum nl80211_rekey_data.
+ *
+ * @NL80211_ATTR_SCAN_SUPP_RATES: rates per to be advertised as supported in scan,
+ * nested array attribute containing an entry for each band, with the entry
+ * being a list of supported rates as defined by IEEE 802.11 7.3.2.2 but
+ * without the length restriction (at most %NL80211_MAX_SUPP_RATES).
+ *
+ * @NL80211_ATTR_HIDDEN_SSID: indicates whether SSID is to be hidden from Beacon
+ * and Probe Response (when response to wildcard Probe Request); see
+ * &enum nl80211_hidden_ssid, represented as a u32
+ *
+ * @NL80211_ATTR_IE_PROBE_RESP: Information element(s) for Probe Response frame.
+ * This is used with %NL80211_CMD_NEW_BEACON and %NL80211_CMD_SET_BEACON to
+ * provide extra IEs (e.g., WPS/P2P IE) into Probe Response frames when the
+ * driver (or firmware) replies to Probe Request frames.
+ * @NL80211_ATTR_IE_ASSOC_RESP: Information element(s) for (Re)Association
+ * Response frames. This is used with %NL80211_CMD_NEW_BEACON and
+ * %NL80211_CMD_SET_BEACON to provide extra IEs (e.g., WPS/P2P IE) into
+ * (Re)Association Response frames when the driver (or firmware) replies to
+ * (Re)Association Request frames.
+ *
+ * @NL80211_ATTR_STA_WME: Nested attribute containing the wme configuration
+ * of the station, see &enum nl80211_sta_wme_attr.
+ * @NL80211_ATTR_SUPPORT_AP_UAPSD: the device supports uapsd when working
+ * as AP.
+ *
+ * @NL80211_ATTR_ROAM_SUPPORT: Indicates whether the firmware is capable of
+ * roaming to another AP in the same ESS if the signal lever is low.
+ *
+ * @NL80211_ATTR_PMKSA_CANDIDATE: Nested attribute containing the PMKSA caching
+ * candidate information, see &enum nl80211_pmksa_candidate_attr.
+ *
+ * @NL80211_ATTR_TX_NO_CCK_RATE: Indicates whether to use CCK rate or not
+ * for management frames transmission. In order to avoid p2p probe/action
+ * frames are being transmitted at CCK rate in 2GHz band, the user space
+ * applications use this attribute.
+ * This attribute is used with %NL80211_CMD_TRIGGER_SCAN and
+ * %NL80211_CMD_FRAME commands.
+ *
+ * @NL80211_ATTR_TDLS_ACTION: Low level TDLS action code (e.g. link setup
+ * request, link setup confirm, link teardown, etc.). Values are
+ * described in the TDLS (802.11z) specification.
+ * @NL80211_ATTR_TDLS_DIALOG_TOKEN: Non-zero token for uniquely identifying a
+ * TDLS conversation between two devices.
+ * @NL80211_ATTR_TDLS_OPERATION: High level TDLS operation; see
+ * &enum nl80211_tdls_operation, represented as a u8.
+ * @NL80211_ATTR_TDLS_SUPPORT: A flag indicating the device can operate
+ * as a TDLS peer sta.
+ * @NL80211_ATTR_TDLS_EXTERNAL_SETUP: The TDLS discovery/setup and teardown
+ * procedures should be performed by sending TDLS packets via
+ * %NL80211_CMD_TDLS_MGMT. Otherwise %NL80211_CMD_TDLS_OPER should be
+ * used for asking the driver to perform a TDLS operation.
+ *
+ * @NL80211_ATTR_DEVICE_AP_SME: This u32 attribute may be listed for devices
+ * that have AP support to indicate that they have the AP SME integrated
+ * with support for the features listed in this attribute, see
+ * &enum nl80211_ap_sme_features.
+ *
+ * @NL80211_ATTR_DONT_WAIT_FOR_ACK: Used with %NL80211_CMD_FRAME, this tells
+ * the driver to not wait for an acknowledgement. Note that due to this,
+ * it will also not give a status callback nor return a cookie. This is
+ * mostly useful for probe responses to save airtime.
+ *
+ * @NL80211_ATTR_FEATURE_FLAGS: This u32 attribute contains flags from
+ * &enum nl80211_feature_flags and is advertised in wiphy information.
+ * @NL80211_ATTR_PROBE_RESP_OFFLOAD: Indicates that the HW responds to probe
+ *
+ * requests while operating in AP-mode.
+ * This attribute holds a bitmap of the supported protocols for
+ * offloading (see &enum nl80211_probe_resp_offload_support_attr).
+ *
+ * @NL80211_ATTR_PROBE_RESP: Probe Response template data. Contains the entire
+ * probe-response frame. The DA field in the 802.11 header is zero-ed out,
+ * to be filled by the FW.
+ * @NL80211_ATTR_DISABLE_HT: Force HT capable interfaces to disable
+ * this feature. Currently, only supported in mac80211 drivers.
+ * @NL80211_ATTR_HT_CAPABILITY_MASK: Specify which bits of the
+ * ATTR_HT_CAPABILITY to which attention should be paid.
+ * Currently, only mac80211 NICs support this feature.
+ * The values that may be configured are:
+ * MCS rates, MAX-AMSDU, HT-20-40 and HT_CAP_SGI_40
+ * AMPDU density and AMPDU factor.
+ * All values are treated as suggestions and may be ignored
+ * by the driver as required. The actual values may be seen in
+ * the station debugfs ht_caps file.
+ *
+ * @NL80211_ATTR_DFS_REGION: region for regulatory rules which this country
+ * abides to when initiating radiation on DFS channels. A country maps
+ * to one DFS region.
+ *
+ * @NL80211_ATTR_NOACK_MAP: This u16 bitmap contains the No Ack Policy of
+ * up to 16 TIDs.
+ *
+ * @NL80211_ATTR_MAX: highest attribute number currently defined
+ * @__NL80211_ATTR_AFTER_LAST: internal use
+ */
+enum nl80211_attrs {
+/* don't change the order or add anything between, this is ABI! */
+ NL80211_ATTR_UNSPEC,
+
+ NL80211_ATTR_WIPHY,
+ NL80211_ATTR_WIPHY_NAME,
+
+ NL80211_ATTR_IFINDEX,
+ NL80211_ATTR_IFNAME,
+ NL80211_ATTR_IFTYPE,
+
+ NL80211_ATTR_MAC,
+
+ NL80211_ATTR_KEY_DATA,
+ NL80211_ATTR_KEY_IDX,
+ NL80211_ATTR_KEY_CIPHER,
+ NL80211_ATTR_KEY_SEQ,
+ NL80211_ATTR_KEY_DEFAULT,
+
+ NL80211_ATTR_BEACON_INTERVAL,
+ NL80211_ATTR_DTIM_PERIOD,
+ NL80211_ATTR_BEACON_HEAD,
+ NL80211_ATTR_BEACON_TAIL,
+
+ NL80211_ATTR_STA_AID,
+ NL80211_ATTR_STA_FLAGS,
+ NL80211_ATTR_STA_LISTEN_INTERVAL,
+ NL80211_ATTR_STA_SUPPORTED_RATES,
+ NL80211_ATTR_STA_VLAN,
+ NL80211_ATTR_STA_INFO,
+
+ NL80211_ATTR_WIPHY_BANDS,
+
+ NL80211_ATTR_MNTR_FLAGS,
+
+ NL80211_ATTR_MESH_ID,
+ NL80211_ATTR_STA_PLINK_ACTION,
+ NL80211_ATTR_MPATH_NEXT_HOP,
+ NL80211_ATTR_MPATH_INFO,
+
+ NL80211_ATTR_BSS_CTS_PROT,
+ NL80211_ATTR_BSS_SHORT_PREAMBLE,
+ NL80211_ATTR_BSS_SHORT_SLOT_TIME,
+
+ NL80211_ATTR_HT_CAPABILITY,
+
+ NL80211_ATTR_SUPPORTED_IFTYPES,
+
+ NL80211_ATTR_REG_ALPHA2,
+ NL80211_ATTR_REG_RULES,
+
+ NL80211_ATTR_MESH_CONFIG,
+
+ NL80211_ATTR_BSS_BASIC_RATES,
+
+ NL80211_ATTR_WIPHY_TXQ_PARAMS,
+ NL80211_ATTR_WIPHY_FREQ,
+ NL80211_ATTR_WIPHY_CHANNEL_TYPE,
+
+ NL80211_ATTR_KEY_DEFAULT_MGMT,
+
+ NL80211_ATTR_MGMT_SUBTYPE,
+ NL80211_ATTR_IE,
+
+ NL80211_ATTR_MAX_NUM_SCAN_SSIDS,
+
+ NL80211_ATTR_SCAN_FREQUENCIES,
+ NL80211_ATTR_SCAN_SSIDS,
+ NL80211_ATTR_GENERATION, /* replaces old SCAN_GENERATION */
+ NL80211_ATTR_BSS,
+
+ NL80211_ATTR_REG_INITIATOR,
+ NL80211_ATTR_REG_TYPE,
+
+ NL80211_ATTR_SUPPORTED_COMMANDS,
+
+ NL80211_ATTR_FRAME,
+ NL80211_ATTR_SSID,
+ NL80211_ATTR_AUTH_TYPE,
+ NL80211_ATTR_REASON_CODE,
+
+ NL80211_ATTR_KEY_TYPE,
+
+ NL80211_ATTR_MAX_SCAN_IE_LEN,
+ NL80211_ATTR_CIPHER_SUITES,
+
+ NL80211_ATTR_FREQ_BEFORE,
+ NL80211_ATTR_FREQ_AFTER,
+
+ NL80211_ATTR_FREQ_FIXED,
+
+
+ NL80211_ATTR_WIPHY_RETRY_SHORT,
+ NL80211_ATTR_WIPHY_RETRY_LONG,
+ NL80211_ATTR_WIPHY_FRAG_THRESHOLD,
+ NL80211_ATTR_WIPHY_RTS_THRESHOLD,
+
+ NL80211_ATTR_TIMED_OUT,
+
+ NL80211_ATTR_USE_MFP,
+
+ NL80211_ATTR_STA_FLAGS2,
+
+ NL80211_ATTR_CONTROL_PORT,
+
+ NL80211_ATTR_TESTDATA,
+
+ NL80211_ATTR_PRIVACY,
+
+ NL80211_ATTR_DISCONNECTED_BY_AP,
+ NL80211_ATTR_STATUS_CODE,
+
+ NL80211_ATTR_CIPHER_SUITES_PAIRWISE,
+ NL80211_ATTR_CIPHER_SUITE_GROUP,
+ NL80211_ATTR_WPA_VERSIONS,
+ NL80211_ATTR_AKM_SUITES,
+
+ NL80211_ATTR_REQ_IE,
+ NL80211_ATTR_RESP_IE,
+
+ NL80211_ATTR_PREV_BSSID,
+
+ NL80211_ATTR_KEY,
+ NL80211_ATTR_KEYS,
+
+ NL80211_ATTR_PID,
+
+ NL80211_ATTR_4ADDR,
+
+ NL80211_ATTR_SURVEY_INFO,
+
+ NL80211_ATTR_PMKID,
+ NL80211_ATTR_MAX_NUM_PMKIDS,
+
+ NL80211_ATTR_DURATION,
+
+ NL80211_ATTR_COOKIE,
+
+ NL80211_ATTR_WIPHY_COVERAGE_CLASS,
+
+ NL80211_ATTR_TX_RATES,
+
+ NL80211_ATTR_FRAME_MATCH,
+
+ NL80211_ATTR_ACK,
+
+ NL80211_ATTR_PS_STATE,
+
+ NL80211_ATTR_CQM,
+
+ NL80211_ATTR_LOCAL_STATE_CHANGE,
+
+ NL80211_ATTR_AP_ISOLATE,
+
+ NL80211_ATTR_WIPHY_TX_POWER_SETTING,
+ NL80211_ATTR_WIPHY_TX_POWER_LEVEL,
+
+ NL80211_ATTR_TX_FRAME_TYPES,
+ NL80211_ATTR_RX_FRAME_TYPES,
+ NL80211_ATTR_FRAME_TYPE,
+
+ NL80211_ATTR_CONTROL_PORT_ETHERTYPE,
+ NL80211_ATTR_CONTROL_PORT_NO_ENCRYPT,
+
+ NL80211_ATTR_SUPPORT_IBSS_RSN,
+
+ NL80211_ATTR_WIPHY_ANTENNA_TX,
+ NL80211_ATTR_WIPHY_ANTENNA_RX,
+
+ NL80211_ATTR_MCAST_RATE,
+
+ NL80211_ATTR_OFFCHANNEL_TX_OK,
+
+ NL80211_ATTR_BSS_HT_OPMODE,
+
+ NL80211_ATTR_KEY_DEFAULT_TYPES,
+
+ NL80211_ATTR_MAX_REMAIN_ON_CHANNEL_DURATION,
+
+ NL80211_ATTR_MESH_SETUP,
+
+ NL80211_ATTR_WIPHY_ANTENNA_AVAIL_TX,
+ NL80211_ATTR_WIPHY_ANTENNA_AVAIL_RX,
+
+ NL80211_ATTR_SUPPORT_MESH_AUTH,
+ NL80211_ATTR_STA_PLINK_STATE,
+
+ NL80211_ATTR_WOWLAN_TRIGGERS,
+ NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED,
+
+ NL80211_ATTR_SCHED_SCAN_INTERVAL,
+
+ NL80211_ATTR_INTERFACE_COMBINATIONS,
+ NL80211_ATTR_SOFTWARE_IFTYPES,
+
+ NL80211_ATTR_REKEY_DATA,
+
+ NL80211_ATTR_MAX_NUM_SCHED_SCAN_SSIDS,
+ NL80211_ATTR_MAX_SCHED_SCAN_IE_LEN,
+
+ NL80211_ATTR_SCAN_SUPP_RATES,
+
+ NL80211_ATTR_HIDDEN_SSID,
+
+ NL80211_ATTR_IE_PROBE_RESP,
+ NL80211_ATTR_IE_ASSOC_RESP,
+
+ NL80211_ATTR_STA_WME,
+ NL80211_ATTR_SUPPORT_AP_UAPSD,
+
+ NL80211_ATTR_ROAM_SUPPORT,
+
+ NL80211_ATTR_SCHED_SCAN_MATCH,
+ NL80211_ATTR_MAX_MATCH_SETS,
+
+ NL80211_ATTR_PMKSA_CANDIDATE,
+
+ NL80211_ATTR_TX_NO_CCK_RATE,
+
+ NL80211_ATTR_TDLS_ACTION,
+ NL80211_ATTR_TDLS_DIALOG_TOKEN,
+ NL80211_ATTR_TDLS_OPERATION,
+ NL80211_ATTR_TDLS_SUPPORT,
+ NL80211_ATTR_TDLS_EXTERNAL_SETUP,
+
+ NL80211_ATTR_DEVICE_AP_SME,
+
+ NL80211_ATTR_DONT_WAIT_FOR_ACK,
+
+ NL80211_ATTR_FEATURE_FLAGS,
+
+ NL80211_ATTR_PROBE_RESP_OFFLOAD,
+
+ NL80211_ATTR_PROBE_RESP,
+
+ NL80211_ATTR_DFS_REGION,
+
+ NL80211_ATTR_DISABLE_HT,
+ NL80211_ATTR_HT_CAPABILITY_MASK,
+
+ NL80211_ATTR_NOACK_MAP,
+
+ /* add attributes here, update the policy in nl80211.c */
+
+ __NL80211_ATTR_AFTER_LAST,
+ NL80211_ATTR_MAX = __NL80211_ATTR_AFTER_LAST - 1
+};
+
+/* source-level API compatibility */
+#define NL80211_ATTR_SCAN_GENERATION NL80211_ATTR_GENERATION
+#define NL80211_ATTR_MESH_PARAMS NL80211_ATTR_MESH_CONFIG
+
+/*
+ * Allow user space programs to use #ifdef on new attributes by defining them
+ * here
+ */
+#define NL80211_CMD_CONNECT NL80211_CMD_CONNECT
+#define NL80211_ATTR_HT_CAPABILITY NL80211_ATTR_HT_CAPABILITY
+#define NL80211_ATTR_BSS_BASIC_RATES NL80211_ATTR_BSS_BASIC_RATES
+#define NL80211_ATTR_WIPHY_TXQ_PARAMS NL80211_ATTR_WIPHY_TXQ_PARAMS
+#define NL80211_ATTR_WIPHY_FREQ NL80211_ATTR_WIPHY_FREQ
+#define NL80211_ATTR_WIPHY_CHANNEL_TYPE NL80211_ATTR_WIPHY_CHANNEL_TYPE
+#define NL80211_ATTR_MGMT_SUBTYPE NL80211_ATTR_MGMT_SUBTYPE
+#define NL80211_ATTR_IE NL80211_ATTR_IE
+#define NL80211_ATTR_REG_INITIATOR NL80211_ATTR_REG_INITIATOR
+#define NL80211_ATTR_REG_TYPE NL80211_ATTR_REG_TYPE
+#define NL80211_ATTR_FRAME NL80211_ATTR_FRAME
+#define NL80211_ATTR_SSID NL80211_ATTR_SSID
+#define NL80211_ATTR_AUTH_TYPE NL80211_ATTR_AUTH_TYPE
+#define NL80211_ATTR_REASON_CODE NL80211_ATTR_REASON_CODE
+#define NL80211_ATTR_CIPHER_SUITES_PAIRWISE NL80211_ATTR_CIPHER_SUITES_PAIRWISE
+#define NL80211_ATTR_CIPHER_SUITE_GROUP NL80211_ATTR_CIPHER_SUITE_GROUP
+#define NL80211_ATTR_WPA_VERSIONS NL80211_ATTR_WPA_VERSIONS
+#define NL80211_ATTR_AKM_SUITES NL80211_ATTR_AKM_SUITES
+#define NL80211_ATTR_KEY NL80211_ATTR_KEY
+#define NL80211_ATTR_KEYS NL80211_ATTR_KEYS
+#define NL80211_ATTR_FEATURE_FLAGS NL80211_ATTR_FEATURE_FLAGS
+
+#define NL80211_MAX_SUPP_RATES 32
+#define NL80211_MAX_SUPP_HT_RATES 77
+#define NL80211_MAX_SUPP_REG_RULES 32
+#define NL80211_TKIP_DATA_OFFSET_ENCR_KEY 0
+#define NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY 16
+#define NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY 24
+#define NL80211_HT_CAPABILITY_LEN 26
+
+#define NL80211_MAX_NR_CIPHER_SUITES 5
+#define NL80211_MAX_NR_AKM_SUITES 2
+
+/**
+ * enum nl80211_iftype - (virtual) interface types
+ *
+ * @NL80211_IFTYPE_UNSPECIFIED: unspecified type, driver decides
+ * @NL80211_IFTYPE_ADHOC: independent BSS member
+ * @NL80211_IFTYPE_STATION: managed BSS member
+ * @NL80211_IFTYPE_AP: access point
+ * @NL80211_IFTYPE_AP_VLAN: VLAN interface for access points; VLAN interfaces
+ * are a bit special in that they must always be tied to a pre-existing
+ * AP type interface.
+ * @NL80211_IFTYPE_WDS: wireless distribution interface
+ * @NL80211_IFTYPE_MONITOR: monitor interface receiving all frames
+ * @NL80211_IFTYPE_MESH_POINT: mesh point
+ * @NL80211_IFTYPE_P2P_CLIENT: P2P client
+ * @NL80211_IFTYPE_P2P_GO: P2P group owner
+ * @NL80211_IFTYPE_MAX: highest interface type number currently defined
+ * @NUM_NL80211_IFTYPES: number of defined interface types
+ *
+ * These values are used with the %NL80211_ATTR_IFTYPE
+ * to set the type of an interface.
+ *
+ */
+enum nl80211_iftype {
+ NL80211_IFTYPE_UNSPECIFIED,
+ NL80211_IFTYPE_ADHOC,
+ NL80211_IFTYPE_STATION,
+ NL80211_IFTYPE_AP,
+ NL80211_IFTYPE_AP_VLAN,
+ NL80211_IFTYPE_WDS,
+ NL80211_IFTYPE_MONITOR,
+ NL80211_IFTYPE_MESH_POINT,
+ NL80211_IFTYPE_P2P_CLIENT,
+ NL80211_IFTYPE_P2P_GO,
+
+ /* keep last */
+ NUM_NL80211_IFTYPES,
+ NL80211_IFTYPE_MAX = NUM_NL80211_IFTYPES - 1
+};
+
+/**
+ * enum nl80211_sta_flags - station flags
+ *
+ * Station flags. When a station is added to an AP interface, it is
+ * assumed to be already associated (and hence authenticated.)
+ *
+ * @__NL80211_STA_FLAG_INVALID: attribute number 0 is reserved
+ * @NL80211_STA_FLAG_AUTHORIZED: station is authorized (802.1X)
+ * @NL80211_STA_FLAG_SHORT_PREAMBLE: station is capable of receiving frames
+ * with short barker preamble
+ * @NL80211_STA_FLAG_WME: station is WME/QoS capable
+ * @NL80211_STA_FLAG_MFP: station uses management frame protection
+ * @NL80211_STA_FLAG_AUTHENTICATED: station is authenticated
+ * @NL80211_STA_FLAG_TDLS_PEER: station is a TDLS peer -- this flag should
+ * only be used in managed mode (even in the flags mask). Note that the
+ * flag can't be changed, it is only valid while adding a station, and
+ * attempts to change it will silently be ignored (rather than rejected
+ * as errors.)
+ * @NL80211_STA_FLAG_MAX: highest station flag number currently defined
+ * @__NL80211_STA_FLAG_AFTER_LAST: internal use
+ */
+enum nl80211_sta_flags {
+ __NL80211_STA_FLAG_INVALID,
+ NL80211_STA_FLAG_AUTHORIZED,
+ NL80211_STA_FLAG_SHORT_PREAMBLE,
+ NL80211_STA_FLAG_WME,
+ NL80211_STA_FLAG_MFP,
+ NL80211_STA_FLAG_AUTHENTICATED,
+ NL80211_STA_FLAG_TDLS_PEER,
+
+ /* keep last */
+ __NL80211_STA_FLAG_AFTER_LAST,
+ NL80211_STA_FLAG_MAX = __NL80211_STA_FLAG_AFTER_LAST - 1
+};
+
+/**
+ * struct nl80211_sta_flag_update - station flags mask/set
+ * @mask: mask of station flags to set
+ * @set: which values to set them to
+ *
+ * Both mask and set contain bits as per &enum nl80211_sta_flags.
+ */
+struct nl80211_sta_flag_update {
+ __u32 mask;
+ __u32 set;
+} __attribute__((packed));
+
+/**
+ * enum nl80211_rate_info - bitrate information
+ *
+ * These attribute types are used with %NL80211_STA_INFO_TXRATE
+ * when getting information about the bitrate of a station.
+ *
+ * @__NL80211_RATE_INFO_INVALID: attribute number 0 is reserved
+ * @NL80211_RATE_INFO_BITRATE: total bitrate (u16, 100kbit/s)
+ * @NL80211_RATE_INFO_MCS: mcs index for 802.11n (u8)
+ * @NL80211_RATE_INFO_40_MHZ_WIDTH: 40 Mhz dualchannel bitrate
+ * @NL80211_RATE_INFO_SHORT_GI: 400ns guard interval
+ * @NL80211_RATE_INFO_MAX: highest rate_info number currently defined
+ * @__NL80211_RATE_INFO_AFTER_LAST: internal use
+ */
+enum nl80211_rate_info {
+ __NL80211_RATE_INFO_INVALID,
+ NL80211_RATE_INFO_BITRATE,
+ NL80211_RATE_INFO_MCS,
+ NL80211_RATE_INFO_40_MHZ_WIDTH,
+ NL80211_RATE_INFO_SHORT_GI,
+
+ /* keep last */
+ __NL80211_RATE_INFO_AFTER_LAST,
+ NL80211_RATE_INFO_MAX = __NL80211_RATE_INFO_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_sta_bss_param - BSS information collected by STA
+ *
+ * These attribute types are used with %NL80211_STA_INFO_BSS_PARAM
+ * when getting information about the bitrate of a station.
+ *
+ * @__NL80211_STA_BSS_PARAM_INVALID: attribute number 0 is reserved
+ * @NL80211_STA_BSS_PARAM_CTS_PROT: whether CTS protection is enabled (flag)
+ * @NL80211_STA_BSS_PARAM_SHORT_PREAMBLE: whether short preamble is enabled
+ * (flag)
+ * @NL80211_STA_BSS_PARAM_SHORT_SLOT_TIME: whether short slot time is enabled
+ * (flag)
+ * @NL80211_STA_BSS_PARAM_DTIM_PERIOD: DTIM period for beaconing (u8)
+ * @NL80211_STA_BSS_PARAM_BEACON_INTERVAL: Beacon interval (u16)
+ * @NL80211_STA_BSS_PARAM_MAX: highest sta_bss_param number currently defined
+ * @__NL80211_STA_BSS_PARAM_AFTER_LAST: internal use
+ */
+enum nl80211_sta_bss_param {
+ __NL80211_STA_BSS_PARAM_INVALID,
+ NL80211_STA_BSS_PARAM_CTS_PROT,
+ NL80211_STA_BSS_PARAM_SHORT_PREAMBLE,
+ NL80211_STA_BSS_PARAM_SHORT_SLOT_TIME,
+ NL80211_STA_BSS_PARAM_DTIM_PERIOD,
+ NL80211_STA_BSS_PARAM_BEACON_INTERVAL,
+
+ /* keep last */
+ __NL80211_STA_BSS_PARAM_AFTER_LAST,
+ NL80211_STA_BSS_PARAM_MAX = __NL80211_STA_BSS_PARAM_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_sta_info - station information
+ *
+ * These attribute types are used with %NL80211_ATTR_STA_INFO
+ * when getting information about a station.
+ *
+ * @__NL80211_STA_INFO_INVALID: attribute number 0 is reserved
+ * @NL80211_STA_INFO_INACTIVE_TIME: time since last activity (u32, msecs)
+ * @NL80211_STA_INFO_RX_BYTES: total received bytes (u32, from this station)
+ * @NL80211_STA_INFO_TX_BYTES: total transmitted bytes (u32, to this station)
+ * @NL80211_STA_INFO_SIGNAL: signal strength of last received PPDU (u8, dBm)
+ * @NL80211_STA_INFO_TX_BITRATE: current unicast tx rate, nested attribute
+ * containing info as possible, see &enum nl80211_rate_info
+ * @NL80211_STA_INFO_RX_PACKETS: total received packet (u32, from this station)
+ * @NL80211_STA_INFO_TX_PACKETS: total transmitted packets (u32, to this
+ * station)
+ * @NL80211_STA_INFO_TX_RETRIES: total retries (u32, to this station)
+ * @NL80211_STA_INFO_TX_FAILED: total failed packets (u32, to this station)
+ * @NL80211_STA_INFO_SIGNAL_AVG: signal strength average (u8, dBm)
+ * @NL80211_STA_INFO_LLID: the station's mesh LLID
+ * @NL80211_STA_INFO_PLID: the station's mesh PLID
+ * @NL80211_STA_INFO_PLINK_STATE: peer link state for the station
+ * (see %enum nl80211_plink_state)
+ * @NL80211_STA_INFO_RX_BITRATE: last unicast data frame rx rate, nested
+ * attribute, like NL80211_STA_INFO_TX_BITRATE.
+ * @NL80211_STA_INFO_BSS_PARAM: current station's view of BSS, nested attribute
+ * containing info as possible, see &enum nl80211_sta_bss_param
+ * @NL80211_STA_INFO_CONNECTED_TIME: time since the station is last connected
+ * @NL80211_STA_INFO_STA_FLAGS: Contains a struct nl80211_sta_flag_update.
+ * @NL80211_STA_INFO_BEACON_LOSS: count of times beacon loss was detected (u32)
+ * @NL80211_STA_INFO_CHAIN_SIGNAL: per-chain signal strength of last PPDU
+ * @NL80211_STA_INFO_CHAIN_SIGNAL_AVG: per-chain signal strength average
+ * @__NL80211_STA_INFO_AFTER_LAST: internal
+ * @NL80211_STA_INFO_MAX: highest possible station info attribute
+ */
+enum nl80211_sta_info {
+ __NL80211_STA_INFO_INVALID,
+ NL80211_STA_INFO_INACTIVE_TIME,
+ NL80211_STA_INFO_RX_BYTES,
+ NL80211_STA_INFO_TX_BYTES,
+ NL80211_STA_INFO_LLID,
+ NL80211_STA_INFO_PLID,
+ NL80211_STA_INFO_PLINK_STATE,
+ NL80211_STA_INFO_SIGNAL,
+ NL80211_STA_INFO_TX_BITRATE,
+ NL80211_STA_INFO_RX_PACKETS,
+ NL80211_STA_INFO_TX_PACKETS,
+ NL80211_STA_INFO_TX_RETRIES,
+ NL80211_STA_INFO_TX_FAILED,
+ NL80211_STA_INFO_SIGNAL_AVG,
+ NL80211_STA_INFO_RX_BITRATE,
+ NL80211_STA_INFO_BSS_PARAM,
+ NL80211_STA_INFO_CONNECTED_TIME,
+ NL80211_STA_INFO_STA_FLAGS,
+ NL80211_STA_INFO_BEACON_LOSS,
+ NL80211_STA_INFO_CHAIN_SIGNAL,
+ NL80211_STA_INFO_CHAIN_SIGNAL_AVG,
+
+ /* keep last */
+ __NL80211_STA_INFO_AFTER_LAST,
+ NL80211_STA_INFO_MAX = __NL80211_STA_INFO_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_mpath_flags - nl80211 mesh path flags
+ *
+ * @NL80211_MPATH_FLAG_ACTIVE: the mesh path is active
+ * @NL80211_MPATH_FLAG_RESOLVING: the mesh path discovery process is running
+ * @NL80211_MPATH_FLAG_SN_VALID: the mesh path contains a valid SN
+ * @NL80211_MPATH_FLAG_FIXED: the mesh path has been manually set
+ * @NL80211_MPATH_FLAG_RESOLVED: the mesh path discovery process succeeded
+ */
+enum nl80211_mpath_flags {
+ NL80211_MPATH_FLAG_ACTIVE = 1<<0,
+ NL80211_MPATH_FLAG_RESOLVING = 1<<1,
+ NL80211_MPATH_FLAG_SN_VALID = 1<<2,
+ NL80211_MPATH_FLAG_FIXED = 1<<3,
+ NL80211_MPATH_FLAG_RESOLVED = 1<<4,
+};
+
+/**
+ * enum nl80211_mpath_info - mesh path information
+ *
+ * These attribute types are used with %NL80211_ATTR_MPATH_INFO when getting
+ * information about a mesh path.
+ *
+ * @__NL80211_MPATH_INFO_INVALID: attribute number 0 is reserved
+ * @NL80211_MPATH_INFO_FRAME_QLEN: number of queued frames for this destination
+ * @NL80211_MPATH_INFO_SN: destination sequence number
+ * @NL80211_MPATH_INFO_METRIC: metric (cost) of this mesh path
+ * @NL80211_MPATH_INFO_EXPTIME: expiration time for the path, in msec from now
+ * @NL80211_MPATH_INFO_FLAGS: mesh path flags, enumerated in
+ * &enum nl80211_mpath_flags;
+ * @NL80211_MPATH_INFO_DISCOVERY_TIMEOUT: total path discovery timeout, in msec
+ * @NL80211_MPATH_INFO_DISCOVERY_RETRIES: mesh path discovery retries
+ * @NL80211_MPATH_INFO_MAX: highest mesh path information attribute number
+ * currently defind
+ * @__NL80211_MPATH_INFO_AFTER_LAST: internal use
+ */
+enum nl80211_mpath_info {
+ __NL80211_MPATH_INFO_INVALID,
+ NL80211_MPATH_INFO_FRAME_QLEN,
+ NL80211_MPATH_INFO_SN,
+ NL80211_MPATH_INFO_METRIC,
+ NL80211_MPATH_INFO_EXPTIME,
+ NL80211_MPATH_INFO_FLAGS,
+ NL80211_MPATH_INFO_DISCOVERY_TIMEOUT,
+ NL80211_MPATH_INFO_DISCOVERY_RETRIES,
+
+ /* keep last */
+ __NL80211_MPATH_INFO_AFTER_LAST,
+ NL80211_MPATH_INFO_MAX = __NL80211_MPATH_INFO_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_band_attr - band attributes
+ * @__NL80211_BAND_ATTR_INVALID: attribute number 0 is reserved
+ * @NL80211_BAND_ATTR_FREQS: supported frequencies in this band,
+ * an array of nested frequency attributes
+ * @NL80211_BAND_ATTR_RATES: supported bitrates in this band,
+ * an array of nested bitrate attributes
+ * @NL80211_BAND_ATTR_HT_MCS_SET: 16-byte attribute containing the MCS set as
+ * defined in 802.11n
+ * @NL80211_BAND_ATTR_HT_CAPA: HT capabilities, as in the HT information IE
+ * @NL80211_BAND_ATTR_HT_AMPDU_FACTOR: A-MPDU factor, as in 11n
+ * @NL80211_BAND_ATTR_HT_AMPDU_DENSITY: A-MPDU density, as in 11n
+ * @NL80211_BAND_ATTR_MAX: highest band attribute currently defined
+ * @__NL80211_BAND_ATTR_AFTER_LAST: internal use
+ */
+enum nl80211_band_attr {
+ __NL80211_BAND_ATTR_INVALID,
+ NL80211_BAND_ATTR_FREQS,
+ NL80211_BAND_ATTR_RATES,
+
+ NL80211_BAND_ATTR_HT_MCS_SET,
+ NL80211_BAND_ATTR_HT_CAPA,
+ NL80211_BAND_ATTR_HT_AMPDU_FACTOR,
+ NL80211_BAND_ATTR_HT_AMPDU_DENSITY,
+
+ /* keep last */
+ __NL80211_BAND_ATTR_AFTER_LAST,
+ NL80211_BAND_ATTR_MAX = __NL80211_BAND_ATTR_AFTER_LAST - 1
+};
+
+#define NL80211_BAND_ATTR_HT_CAPA NL80211_BAND_ATTR_HT_CAPA
+
+/**
+ * enum nl80211_frequency_attr - frequency attributes
+ * @__NL80211_FREQUENCY_ATTR_INVALID: attribute number 0 is reserved
+ * @NL80211_FREQUENCY_ATTR_FREQ: Frequency in MHz
+ * @NL80211_FREQUENCY_ATTR_DISABLED: Channel is disabled in current
+ * regulatory domain.
+ * @NL80211_FREQUENCY_ATTR_PASSIVE_SCAN: Only passive scanning is
+ * permitted on this channel in current regulatory domain.
+ * @NL80211_FREQUENCY_ATTR_NO_IBSS: IBSS networks are not permitted
+ * on this channel in current regulatory domain.
+ * @NL80211_FREQUENCY_ATTR_RADAR: Radar detection is mandatory
+ * on this channel in current regulatory domain.
+ * @NL80211_FREQUENCY_ATTR_MAX_TX_POWER: Maximum transmission power in mBm
+ * (100 * dBm).
+ * @NL80211_FREQUENCY_ATTR_MAX: highest frequency attribute number
+ * currently defined
+ * @__NL80211_FREQUENCY_ATTR_AFTER_LAST: internal use
+ */
+enum nl80211_frequency_attr {
+ __NL80211_FREQUENCY_ATTR_INVALID,
+ NL80211_FREQUENCY_ATTR_FREQ,
+ NL80211_FREQUENCY_ATTR_DISABLED,
+ NL80211_FREQUENCY_ATTR_PASSIVE_SCAN,
+ NL80211_FREQUENCY_ATTR_NO_IBSS,
+ NL80211_FREQUENCY_ATTR_RADAR,
+ NL80211_FREQUENCY_ATTR_MAX_TX_POWER,
+
+ /* keep last */
+ __NL80211_FREQUENCY_ATTR_AFTER_LAST,
+ NL80211_FREQUENCY_ATTR_MAX = __NL80211_FREQUENCY_ATTR_AFTER_LAST - 1
+};
+
+#define NL80211_FREQUENCY_ATTR_MAX_TX_POWER NL80211_FREQUENCY_ATTR_MAX_TX_POWER
+
+/**
+ * enum nl80211_bitrate_attr - bitrate attributes
+ * @__NL80211_BITRATE_ATTR_INVALID: attribute number 0 is reserved
+ * @NL80211_BITRATE_ATTR_RATE: Bitrate in units of 100 kbps
+ * @NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE: Short preamble supported
+ * in 2.4 GHz band.
+ * @NL80211_BITRATE_ATTR_MAX: highest bitrate attribute number
+ * currently defined
+ * @__NL80211_BITRATE_ATTR_AFTER_LAST: internal use
+ */
+enum nl80211_bitrate_attr {
+ __NL80211_BITRATE_ATTR_INVALID,
+ NL80211_BITRATE_ATTR_RATE,
+ NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE,
+
+ /* keep last */
+ __NL80211_BITRATE_ATTR_AFTER_LAST,
+ NL80211_BITRATE_ATTR_MAX = __NL80211_BITRATE_ATTR_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_initiator - Indicates the initiator of a reg domain request
+ * @NL80211_REGDOM_SET_BY_CORE: Core queried CRDA for a dynamic world
+ * regulatory domain.
+ * @NL80211_REGDOM_SET_BY_USER: User asked the wireless core to set the
+ * regulatory domain.
+ * @NL80211_REGDOM_SET_BY_DRIVER: a wireless drivers has hinted to the
+ * wireless core it thinks its knows the regulatory domain we should be in.
+ * @NL80211_REGDOM_SET_BY_COUNTRY_IE: the wireless core has received an
+ * 802.11 country information element with regulatory information it
+ * thinks we should consider. cfg80211 only processes the country
+ * code from the IE, and relies on the regulatory domain information
+ * structure passed by userspace (CRDA) from our wireless-regdb.
+ * If a channel is enabled but the country code indicates it should
+ * be disabled we disable the channel and re-enable it upon disassociation.
+ */
+enum nl80211_reg_initiator {
+ NL80211_REGDOM_SET_BY_CORE,
+ NL80211_REGDOM_SET_BY_USER,
+ NL80211_REGDOM_SET_BY_DRIVER,
+ NL80211_REGDOM_SET_BY_COUNTRY_IE,
+};
+
+/**
+ * enum nl80211_reg_type - specifies the type of regulatory domain
+ * @NL80211_REGDOM_TYPE_COUNTRY: the regulatory domain set is one that pertains
+ * to a specific country. When this is set you can count on the
+ * ISO / IEC 3166 alpha2 country code being valid.
+ * @NL80211_REGDOM_TYPE_WORLD: the regulatory set domain is the world regulatory
+ * domain.
+ * @NL80211_REGDOM_TYPE_CUSTOM_WORLD: the regulatory domain set is a custom
+ * driver specific world regulatory domain. These do not apply system-wide
+ * and are only applicable to the individual devices which have requested
+ * them to be applied.
+ * @NL80211_REGDOM_TYPE_INTERSECTION: the regulatory domain set is the product
+ * of an intersection between two regulatory domains -- the previously
+ * set regulatory domain on the system and the last accepted regulatory
+ * domain request to be processed.
+ */
+enum nl80211_reg_type {
+ NL80211_REGDOM_TYPE_COUNTRY,
+ NL80211_REGDOM_TYPE_WORLD,
+ NL80211_REGDOM_TYPE_CUSTOM_WORLD,
+ NL80211_REGDOM_TYPE_INTERSECTION,
+};
+
+/**
+ * enum nl80211_reg_rule_attr - regulatory rule attributes
+ * @__NL80211_REG_RULE_ATTR_INVALID: attribute number 0 is reserved
+ * @NL80211_ATTR_REG_RULE_FLAGS: a set of flags which specify additional
+ * considerations for a given frequency range. These are the
+ * &enum nl80211_reg_rule_flags.
+ * @NL80211_ATTR_FREQ_RANGE_START: starting frequencry for the regulatory
+ * rule in KHz. This is not a center of frequency but an actual regulatory
+ * band edge.
+ * @NL80211_ATTR_FREQ_RANGE_END: ending frequency for the regulatory rule
+ * in KHz. This is not a center a frequency but an actual regulatory
+ * band edge.
+ * @NL80211_ATTR_FREQ_RANGE_MAX_BW: maximum allowed bandwidth for this
+ * frequency range, in KHz.
+ * @NL80211_ATTR_POWER_RULE_MAX_ANT_GAIN: the maximum allowed antenna gain
+ * for a given frequency range. The value is in mBi (100 * dBi).
+ * If you don't have one then don't send this.
+ * @NL80211_ATTR_POWER_RULE_MAX_EIRP: the maximum allowed EIRP for
+ * a given frequency range. The value is in mBm (100 * dBm).
+ * @NL80211_REG_RULE_ATTR_MAX: highest regulatory rule attribute number
+ * currently defined
+ * @__NL80211_REG_RULE_ATTR_AFTER_LAST: internal use
+ */
+enum nl80211_reg_rule_attr {
+ __NL80211_REG_RULE_ATTR_INVALID,
+ NL80211_ATTR_REG_RULE_FLAGS,
+
+ NL80211_ATTR_FREQ_RANGE_START,
+ NL80211_ATTR_FREQ_RANGE_END,
+ NL80211_ATTR_FREQ_RANGE_MAX_BW,
+
+ NL80211_ATTR_POWER_RULE_MAX_ANT_GAIN,
+ NL80211_ATTR_POWER_RULE_MAX_EIRP,
+
+ /* keep last */
+ __NL80211_REG_RULE_ATTR_AFTER_LAST,
+ NL80211_REG_RULE_ATTR_MAX = __NL80211_REG_RULE_ATTR_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_sched_scan_match_attr - scheduled scan match attributes
+ * @__NL80211_SCHED_SCAN_MATCH_ATTR_INVALID: attribute number 0 is reserved
+ * @NL80211_SCHED_SCAN_MATCH_ATTR_SSID: SSID to be used for matching,
+ * only report BSS with matching SSID.
+ * @NL80211_SCHED_SCAN_MATCH_ATTR_MAX: highest scheduled scan filter
+ * attribute number currently defined
+ * @__NL80211_SCHED_SCAN_MATCH_ATTR_AFTER_LAST: internal use
+ */
+enum nl80211_sched_scan_match_attr {
+ __NL80211_SCHED_SCAN_MATCH_ATTR_INVALID,
+
+ NL80211_ATTR_SCHED_SCAN_MATCH_SSID,
+
+ /* keep last */
+ __NL80211_SCHED_SCAN_MATCH_ATTR_AFTER_LAST,
+ NL80211_SCHED_SCAN_MATCH_ATTR_MAX =
+ __NL80211_SCHED_SCAN_MATCH_ATTR_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_reg_rule_flags - regulatory rule flags
+ *
+ * @NL80211_RRF_NO_OFDM: OFDM modulation not allowed
+ * @NL80211_RRF_NO_CCK: CCK modulation not allowed
+ * @NL80211_RRF_NO_INDOOR: indoor operation not allowed
+ * @NL80211_RRF_NO_OUTDOOR: outdoor operation not allowed
+ * @NL80211_RRF_DFS: DFS support is required to be used
+ * @NL80211_RRF_PTP_ONLY: this is only for Point To Point links
+ * @NL80211_RRF_PTMP_ONLY: this is only for Point To Multi Point links
+ * @NL80211_RRF_PASSIVE_SCAN: passive scan is required
+ * @NL80211_RRF_NO_IBSS: no IBSS is allowed
+ */
+enum nl80211_reg_rule_flags {
+ NL80211_RRF_NO_OFDM = 1<<0,
+ NL80211_RRF_NO_CCK = 1<<1,
+ NL80211_RRF_NO_INDOOR = 1<<2,
+ NL80211_RRF_NO_OUTDOOR = 1<<3,
+ NL80211_RRF_DFS = 1<<4,
+ NL80211_RRF_PTP_ONLY = 1<<5,
+ NL80211_RRF_PTMP_ONLY = 1<<6,
+ NL80211_RRF_PASSIVE_SCAN = 1<<7,
+ NL80211_RRF_NO_IBSS = 1<<8,
+};
+
+/**
+ * enum nl80211_dfs_regions - regulatory DFS regions
+ *
+ * @NL80211_DFS_UNSET: Country has no DFS master region specified
+ * @NL80211_DFS_FCC_: Country follows DFS master rules from FCC
+ * @NL80211_DFS_FCC_: Country follows DFS master rules from ETSI
+ * @NL80211_DFS_JP_: Country follows DFS master rules from JP/MKK/Telec
+ */
+enum nl80211_dfs_regions {
+ NL80211_DFS_UNSET = 0,
+ NL80211_DFS_FCC = 1,
+ NL80211_DFS_ETSI = 2,
+ NL80211_DFS_JP = 3,
+};
+
+/**
+ * enum nl80211_survey_info - survey information
+ *
+ * These attribute types are used with %NL80211_ATTR_SURVEY_INFO
+ * when getting information about a survey.
+ *
+ * @__NL80211_SURVEY_INFO_INVALID: attribute number 0 is reserved
+ * @NL80211_SURVEY_INFO_FREQUENCY: center frequency of channel
+ * @NL80211_SURVEY_INFO_NOISE: noise level of channel (u8, dBm)
+ * @NL80211_SURVEY_INFO_IN_USE: channel is currently being used
+ * @NL80211_SURVEY_INFO_CHANNEL_TIME: amount of time (in ms) that the radio
+ * spent on this channel
+ * @NL80211_SURVEY_INFO_CHANNEL_TIME_BUSY: amount of the time the primary
+ * channel was sensed busy (either due to activity or energy detect)
+ * @NL80211_SURVEY_INFO_CHANNEL_TIME_EXT_BUSY: amount of time the extension
+ * channel was sensed busy
+ * @NL80211_SURVEY_INFO_CHANNEL_TIME_RX: amount of time the radio spent
+ * receiving data
+ * @NL80211_SURVEY_INFO_CHANNEL_TIME_TX: amount of time the radio spent
+ * transmitting data
+ * @NL80211_SURVEY_INFO_MAX: highest survey info attribute number
+ * currently defined
+ * @__NL80211_SURVEY_INFO_AFTER_LAST: internal use
+ */
+enum nl80211_survey_info {
+ __NL80211_SURVEY_INFO_INVALID,
+ NL80211_SURVEY_INFO_FREQUENCY,
+ NL80211_SURVEY_INFO_NOISE,
+ NL80211_SURVEY_INFO_IN_USE,
+ NL80211_SURVEY_INFO_CHANNEL_TIME,
+ NL80211_SURVEY_INFO_CHANNEL_TIME_BUSY,
+ NL80211_SURVEY_INFO_CHANNEL_TIME_EXT_BUSY,
+ NL80211_SURVEY_INFO_CHANNEL_TIME_RX,
+ NL80211_SURVEY_INFO_CHANNEL_TIME_TX,
+
+ /* keep last */
+ __NL80211_SURVEY_INFO_AFTER_LAST,
+ NL80211_SURVEY_INFO_MAX = __NL80211_SURVEY_INFO_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_mntr_flags - monitor configuration flags
+ *
+ * Monitor configuration flags.
+ *
+ * @__NL80211_MNTR_FLAG_INVALID: reserved
+ *
+ * @NL80211_MNTR_FLAG_FCSFAIL: pass frames with bad FCS
+ * @NL80211_MNTR_FLAG_PLCPFAIL: pass frames with bad PLCP
+ * @NL80211_MNTR_FLAG_CONTROL: pass control frames
+ * @NL80211_MNTR_FLAG_OTHER_BSS: disable BSSID filtering
+ * @NL80211_MNTR_FLAG_COOK_FRAMES: report frames after processing.
+ * overrides all other flags.
+ *
+ * @__NL80211_MNTR_FLAG_AFTER_LAST: internal use
+ * @NL80211_MNTR_FLAG_MAX: highest possible monitor flag
+ */
+enum nl80211_mntr_flags {
+ __NL80211_MNTR_FLAG_INVALID,
+ NL80211_MNTR_FLAG_FCSFAIL,
+ NL80211_MNTR_FLAG_PLCPFAIL,
+ NL80211_MNTR_FLAG_CONTROL,
+ NL80211_MNTR_FLAG_OTHER_BSS,
+ NL80211_MNTR_FLAG_COOK_FRAMES,
+
+ /* keep last */
+ __NL80211_MNTR_FLAG_AFTER_LAST,
+ NL80211_MNTR_FLAG_MAX = __NL80211_MNTR_FLAG_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_meshconf_params - mesh configuration parameters
+ *
+ * Mesh configuration parameters. These can be changed while the mesh is
+ * active.
+ *
+ * @__NL80211_MESHCONF_INVALID: internal use
+ *
+ * @NL80211_MESHCONF_RETRY_TIMEOUT: specifies the initial retry timeout in
+ * millisecond units, used by the Peer Link Open message
+ *
+ * @NL80211_MESHCONF_CONFIRM_TIMEOUT: specifies the initial confirm timeout, in
+ * millisecond units, used by the peer link management to close a peer link
+ *
+ * @NL80211_MESHCONF_HOLDING_TIMEOUT: specifies the holding timeout, in
+ * millisecond units
+ *
+ * @NL80211_MESHCONF_MAX_PEER_LINKS: maximum number of peer links allowed
+ * on this mesh interface
+ *
+ * @NL80211_MESHCONF_MAX_RETRIES: specifies the maximum number of peer link
+ * open retries that can be sent to establish a new peer link instance in a
+ * mesh
+ *
+ * @NL80211_MESHCONF_TTL: specifies the value of TTL field set at a source mesh
+ * point.
+ *
+ * @NL80211_MESHCONF_AUTO_OPEN_PLINKS: whether we should automatically
+ * open peer links when we detect compatible mesh peers.
+ *
+ * @NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES: the number of action frames
+ * containing a PREQ that an MP can send to a particular destination (path
+ * target)
+ *
+ * @NL80211_MESHCONF_PATH_REFRESH_TIME: how frequently to refresh mesh paths
+ * (in milliseconds)
+ *
+ * @NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT: minimum length of time to wait
+ * until giving up on a path discovery (in milliseconds)
+ *
+ * @NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT: The time (in TUs) for which mesh
+ * points receiving a PREQ shall consider the forwarding information from the
+ * root to be valid. (TU = time unit)
+ *
+ * @NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL: The minimum interval of time (in
+ * TUs) during which an MP can send only one action frame containing a PREQ
+ * reference element
+ *
+ * @NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME: The interval of time (in TUs)
+ * that it takes for an HWMP information element to propagate across the mesh
+ *
+ * @NL80211_MESHCONF_HWMP_ROOTMODE: whether root mode is enabled or not
+ *
+ * @NL80211_MESHCONF_ELEMENT_TTL: specifies the value of TTL field set at a
+ * source mesh point for path selection elements.
+ *
+ * @NL80211_MESHCONF_HWMP_RANN_INTERVAL: The interval of time (in TUs) between
+ * root announcements are transmitted.
+ *
+ * @NL80211_MESHCONF_GATE_ANNOUNCEMENTS: Advertise that this mesh station has
+ * access to a broader network beyond the MBSS. This is done via Root
+ * Announcement frames.
+ *
+ * @NL80211_MESHCONF_HWMP_PERR_MIN_INTERVAL: The minimum interval of time (in
+ * TUs) during which a mesh STA can send only one Action frame containing a
+ * PERR element.
+ *
+ * @NL80211_MESHCONF_FORWARDING: set Mesh STA as forwarding or non-forwarding
+ * or forwarding entity (default is TRUE - forwarding entity)
+ *
+ * @NL80211_MESHCONF_ATTR_MAX: highest possible mesh configuration attribute
+ *
+ * @__NL80211_MESHCONF_ATTR_AFTER_LAST: internal use
+ */
+enum nl80211_meshconf_params {
+ __NL80211_MESHCONF_INVALID,
+ NL80211_MESHCONF_RETRY_TIMEOUT,
+ NL80211_MESHCONF_CONFIRM_TIMEOUT,
+ NL80211_MESHCONF_HOLDING_TIMEOUT,
+ NL80211_MESHCONF_MAX_PEER_LINKS,
+ NL80211_MESHCONF_MAX_RETRIES,
+ NL80211_MESHCONF_TTL,
+ NL80211_MESHCONF_AUTO_OPEN_PLINKS,
+ NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES,
+ NL80211_MESHCONF_PATH_REFRESH_TIME,
+ NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT,
+ NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT,
+ NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL,
+ NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME,
+ NL80211_MESHCONF_HWMP_ROOTMODE,
+ NL80211_MESHCONF_ELEMENT_TTL,
+ NL80211_MESHCONF_HWMP_RANN_INTERVAL,
+ NL80211_MESHCONF_GATE_ANNOUNCEMENTS,
+ NL80211_MESHCONF_HWMP_PERR_MIN_INTERVAL,
+ NL80211_MESHCONF_FORWARDING,
+
+ /* keep last */
+ __NL80211_MESHCONF_ATTR_AFTER_LAST,
+ NL80211_MESHCONF_ATTR_MAX = __NL80211_MESHCONF_ATTR_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_mesh_setup_params - mesh setup parameters
+ *
+ * Mesh setup parameters. These are used to start/join a mesh and cannot be
+ * changed while the mesh is active.
+ *
+ * @__NL80211_MESH_SETUP_INVALID: Internal use
+ *
+ * @NL80211_MESH_SETUP_ENABLE_VENDOR_PATH_SEL: Enable this option to use a
+ * vendor specific path selection algorithm or disable it to use the default
+ * HWMP.
+ *
+ * @NL80211_MESH_SETUP_ENABLE_VENDOR_METRIC: Enable this option to use a
+ * vendor specific path metric or disable it to use the default Airtime
+ * metric.
+ *
+ * @NL80211_MESH_SETUP_IE: Information elements for this mesh, for instance, a
+ * robust security network ie, or a vendor specific information element that
+ * vendors will use to identify the path selection methods and metrics in use.
+ *
+ * @NL80211_MESH_SETUP_USERSPACE_AUTH: Enable this option if an authentication
+ * daemon will be authenticating mesh candidates.
+ *
+ * @NL80211_MESH_SETUP_USERSPACE_AMPE: Enable this option if an authentication
+ * daemon will be securing peer link frames. AMPE is a secured version of Mesh
+ * Peering Management (MPM) and is implemented with the assistance of a
+ * userspace daemon. When this flag is set, the kernel will send peer
+ * management frames to a userspace daemon that will implement AMPE
+ * functionality (security capabilities selection, key confirmation, and key
+ * management). When the flag is unset (default), the kernel can autonomously
+ * complete (unsecured) mesh peering without the need of a userspace daemon.
+ *
+ * @NL80211_MESH_SETUP_ATTR_MAX: highest possible mesh setup attribute number
+ * @__NL80211_MESH_SETUP_ATTR_AFTER_LAST: Internal use
+ */
+enum nl80211_mesh_setup_params {
+ __NL80211_MESH_SETUP_INVALID,
+ NL80211_MESH_SETUP_ENABLE_VENDOR_PATH_SEL,
+ NL80211_MESH_SETUP_ENABLE_VENDOR_METRIC,
+ NL80211_MESH_SETUP_IE,
+ NL80211_MESH_SETUP_USERSPACE_AUTH,
+ NL80211_MESH_SETUP_USERSPACE_AMPE,
+
+ /* keep last */
+ __NL80211_MESH_SETUP_ATTR_AFTER_LAST,
+ NL80211_MESH_SETUP_ATTR_MAX = __NL80211_MESH_SETUP_ATTR_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_txq_attr - TX queue parameter attributes
+ * @__NL80211_TXQ_ATTR_INVALID: Attribute number 0 is reserved
+ * @NL80211_TXQ_ATTR_QUEUE: TX queue identifier (NL80211_TXQ_Q_*)
+ * @NL80211_TXQ_ATTR_TXOP: Maximum burst time in units of 32 usecs, 0 meaning
+ * disabled
+ * @NL80211_TXQ_ATTR_CWMIN: Minimum contention window [a value of the form
+ * 2^n-1 in the range 1..32767]
+ * @NL80211_TXQ_ATTR_CWMAX: Maximum contention window [a value of the form
+ * 2^n-1 in the range 1..32767]
+ * @NL80211_TXQ_ATTR_AIFS: Arbitration interframe space [0..255]
+ * @__NL80211_TXQ_ATTR_AFTER_LAST: Internal
+ * @NL80211_TXQ_ATTR_MAX: Maximum TXQ attribute number
+ */
+enum nl80211_txq_attr {
+ __NL80211_TXQ_ATTR_INVALID,
+ NL80211_TXQ_ATTR_QUEUE,
+ NL80211_TXQ_ATTR_TXOP,
+ NL80211_TXQ_ATTR_CWMIN,
+ NL80211_TXQ_ATTR_CWMAX,
+ NL80211_TXQ_ATTR_AIFS,
+
+ /* keep last */
+ __NL80211_TXQ_ATTR_AFTER_LAST,
+ NL80211_TXQ_ATTR_MAX = __NL80211_TXQ_ATTR_AFTER_LAST - 1
+};
+
+enum nl80211_txq_q {
+ NL80211_TXQ_Q_VO,
+ NL80211_TXQ_Q_VI,
+ NL80211_TXQ_Q_BE,
+ NL80211_TXQ_Q_BK
+};
+
+enum nl80211_channel_type {
+ NL80211_CHAN_NO_HT,
+ NL80211_CHAN_HT20,
+ NL80211_CHAN_HT40MINUS,
+ NL80211_CHAN_HT40PLUS
+};
+
+/**
+ * enum nl80211_bss - netlink attributes for a BSS
+ *
+ * @__NL80211_BSS_INVALID: invalid
+ * @NL80211_BSS_BSSID: BSSID of the BSS (6 octets)
+ * @NL80211_BSS_FREQUENCY: frequency in MHz (u32)
+ * @NL80211_BSS_TSF: TSF of the received probe response/beacon (u64)
+ * @NL80211_BSS_BEACON_INTERVAL: beacon interval of the (I)BSS (u16)
+ * @NL80211_BSS_CAPABILITY: capability field (CPU order, u16)
+ * @NL80211_BSS_INFORMATION_ELEMENTS: binary attribute containing the
+ * raw information elements from the probe response/beacon (bin);
+ * if the %NL80211_BSS_BEACON_IES attribute is present, the IEs here are
+ * from a Probe Response frame; otherwise they are from a Beacon frame.
+ * However, if the driver does not indicate the source of the IEs, these
+ * IEs may be from either frame subtype.
+ * @NL80211_BSS_SIGNAL_MBM: signal strength of probe response/beacon
+ * in mBm (100 * dBm) (s32)
+ * @NL80211_BSS_SIGNAL_UNSPEC: signal strength of the probe response/beacon
+ * in unspecified units, scaled to 0..100 (u8)
+ * @NL80211_BSS_STATUS: status, if this BSS is "used"
+ * @NL80211_BSS_SEEN_MS_AGO: age of this BSS entry in ms
+ * @NL80211_BSS_BEACON_IES: binary attribute containing the raw information
+ * elements from a Beacon frame (bin); not present if no Beacon frame has
+ * yet been received
+ * @__NL80211_BSS_AFTER_LAST: internal
+ * @NL80211_BSS_MAX: highest BSS attribute
+ */
+enum nl80211_bss {
+ __NL80211_BSS_INVALID,
+ NL80211_BSS_BSSID,
+ NL80211_BSS_FREQUENCY,
+ NL80211_BSS_TSF,
+ NL80211_BSS_BEACON_INTERVAL,
+ NL80211_BSS_CAPABILITY,
+ NL80211_BSS_INFORMATION_ELEMENTS,
+ NL80211_BSS_SIGNAL_MBM,
+ NL80211_BSS_SIGNAL_UNSPEC,
+ NL80211_BSS_STATUS,
+ NL80211_BSS_SEEN_MS_AGO,
+ NL80211_BSS_BEACON_IES,
+
+ /* keep last */
+ __NL80211_BSS_AFTER_LAST,
+ NL80211_BSS_MAX = __NL80211_BSS_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_bss_status - BSS "status"
+ * @NL80211_BSS_STATUS_AUTHENTICATED: Authenticated with this BSS.
+ * @NL80211_BSS_STATUS_ASSOCIATED: Associated with this BSS.
+ * @NL80211_BSS_STATUS_IBSS_JOINED: Joined to this IBSS.
+ *
+ * The BSS status is a BSS attribute in scan dumps, which
+ * indicates the status the interface has wrt. this BSS.
+ */
+enum nl80211_bss_status {
+ NL80211_BSS_STATUS_AUTHENTICATED,
+ NL80211_BSS_STATUS_ASSOCIATED,
+ NL80211_BSS_STATUS_IBSS_JOINED,
+};
+
+/**
+ * enum nl80211_auth_type - AuthenticationType
+ *
+ * @NL80211_AUTHTYPE_OPEN_SYSTEM: Open System authentication
+ * @NL80211_AUTHTYPE_SHARED_KEY: Shared Key authentication (WEP only)
+ * @NL80211_AUTHTYPE_FT: Fast BSS Transition (IEEE 802.11r)
+ * @NL80211_AUTHTYPE_NETWORK_EAP: Network EAP (some Cisco APs and mainly LEAP)
+ * @__NL80211_AUTHTYPE_NUM: internal
+ * @NL80211_AUTHTYPE_MAX: maximum valid auth algorithm
+ * @NL80211_AUTHTYPE_AUTOMATIC: determine automatically (if necessary by
+ * trying multiple times); this is invalid in netlink -- leave out
+ * the attribute for this on CONNECT commands.
+ */
+enum nl80211_auth_type {
+ NL80211_AUTHTYPE_OPEN_SYSTEM,
+ NL80211_AUTHTYPE_SHARED_KEY,
+ NL80211_AUTHTYPE_FT,
+ NL80211_AUTHTYPE_NETWORK_EAP,
+
+ /* keep last */
+ __NL80211_AUTHTYPE_NUM,
+ NL80211_AUTHTYPE_MAX = __NL80211_AUTHTYPE_NUM - 1,
+ NL80211_AUTHTYPE_AUTOMATIC
+};
+
+/**
+ * enum nl80211_key_type - Key Type
+ * @NL80211_KEYTYPE_GROUP: Group (broadcast/multicast) key
+ * @NL80211_KEYTYPE_PAIRWISE: Pairwise (unicast/individual) key
+ * @NL80211_KEYTYPE_PEERKEY: PeerKey (DLS)
+ * @NUM_NL80211_KEYTYPES: number of defined key types
+ */
+enum nl80211_key_type {
+ NL80211_KEYTYPE_GROUP,
+ NL80211_KEYTYPE_PAIRWISE,
+ NL80211_KEYTYPE_PEERKEY,
+
+ NUM_NL80211_KEYTYPES
+};
+
+/**
+ * enum nl80211_mfp - Management frame protection state
+ * @NL80211_MFP_NO: Management frame protection not used
+ * @NL80211_MFP_REQUIRED: Management frame protection required
+ */
+enum nl80211_mfp {
+ NL80211_MFP_NO,
+ NL80211_MFP_REQUIRED,
+};
+
+enum nl80211_wpa_versions {
+ NL80211_WPA_VERSION_1 = 1 << 0,
+ NL80211_WPA_VERSION_2 = 1 << 1,
+};
+
+/**
+ * enum nl80211_key_default_types - key default types
+ * @__NL80211_KEY_DEFAULT_TYPE_INVALID: invalid
+ * @NL80211_KEY_DEFAULT_TYPE_UNICAST: key should be used as default
+ * unicast key
+ * @NL80211_KEY_DEFAULT_TYPE_MULTICAST: key should be used as default
+ * multicast key
+ * @NUM_NL80211_KEY_DEFAULT_TYPES: number of default types
+ */
+enum nl80211_key_default_types {
+ __NL80211_KEY_DEFAULT_TYPE_INVALID,
+ NL80211_KEY_DEFAULT_TYPE_UNICAST,
+ NL80211_KEY_DEFAULT_TYPE_MULTICAST,
+
+ NUM_NL80211_KEY_DEFAULT_TYPES
+};
+
+/**
+ * enum nl80211_key_attributes - key attributes
+ * @__NL80211_KEY_INVALID: invalid
+ * @NL80211_KEY_DATA: (temporal) key data; for TKIP this consists of
+ * 16 bytes encryption key followed by 8 bytes each for TX and RX MIC
+ * keys
+ * @NL80211_KEY_IDX: key ID (u8, 0-3)
+ * @NL80211_KEY_CIPHER: key cipher suite (u32, as defined by IEEE 802.11
+ * section 7.3.2.25.1, e.g. 0x000FAC04)
+ * @NL80211_KEY_SEQ: transmit key sequence number (IV/PN) for TKIP and
+ * CCMP keys, each six bytes in little endian
+ * @NL80211_KEY_DEFAULT: flag indicating default key
+ * @NL80211_KEY_DEFAULT_MGMT: flag indicating default management key
+ * @NL80211_KEY_TYPE: the key type from enum nl80211_key_type, if not
+ * specified the default depends on whether a MAC address was
+ * given with the command using the key or not (u32)
+ * @NL80211_KEY_DEFAULT_TYPES: A nested attribute containing flags
+ * attributes, specifying what a key should be set as default as.
+ * See &enum nl80211_key_default_types.
+ * @__NL80211_KEY_AFTER_LAST: internal
+ * @NL80211_KEY_MAX: highest key attribute
+ */
+enum nl80211_key_attributes {
+ __NL80211_KEY_INVALID,
+ NL80211_KEY_DATA,
+ NL80211_KEY_IDX,
+ NL80211_KEY_CIPHER,
+ NL80211_KEY_SEQ,
+ NL80211_KEY_DEFAULT,
+ NL80211_KEY_DEFAULT_MGMT,
+ NL80211_KEY_TYPE,
+ NL80211_KEY_DEFAULT_TYPES,
+
+ /* keep last */
+ __NL80211_KEY_AFTER_LAST,
+ NL80211_KEY_MAX = __NL80211_KEY_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_tx_rate_attributes - TX rate set attributes
+ * @__NL80211_TXRATE_INVALID: invalid
+ * @NL80211_TXRATE_LEGACY: Legacy (non-MCS) rates allowed for TX rate selection
+ * in an array of rates as defined in IEEE 802.11 7.3.2.2 (u8 values with
+ * 1 = 500 kbps) but without the IE length restriction (at most
+ * %NL80211_MAX_SUPP_RATES in a single array).
+ * @NL80211_TXRATE_MCS: HT (MCS) rates allowed for TX rate selection
+ * in an array of MCS numbers.
+ * @__NL80211_TXRATE_AFTER_LAST: internal
+ * @NL80211_TXRATE_MAX: highest TX rate attribute
+ */
+enum nl80211_tx_rate_attributes {
+ __NL80211_TXRATE_INVALID,
+ NL80211_TXRATE_LEGACY,
+ NL80211_TXRATE_MCS,
+
+ /* keep last */
+ __NL80211_TXRATE_AFTER_LAST,
+ NL80211_TXRATE_MAX = __NL80211_TXRATE_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_band - Frequency band
+ * @NL80211_BAND_2GHZ: 2.4 GHz ISM band
+ * @NL80211_BAND_5GHZ: around 5 GHz band (4.9 - 5.7 GHz)
+ */
+enum nl80211_band {
+ NL80211_BAND_2GHZ,
+ NL80211_BAND_5GHZ,
+};
+
+enum nl80211_ps_state {
+ NL80211_PS_DISABLED,
+ NL80211_PS_ENABLED,
+};
+
+/**
+ * enum nl80211_attr_cqm - connection quality monitor attributes
+ * @__NL80211_ATTR_CQM_INVALID: invalid
+ * @NL80211_ATTR_CQM_RSSI_THOLD: RSSI threshold in dBm. This value specifies
+ * the threshold for the RSSI level at which an event will be sent. Zero
+ * to disable.
+ * @NL80211_ATTR_CQM_RSSI_HYST: RSSI hysteresis in dBm. This value specifies
+ * the minimum amount the RSSI level must change after an event before a
+ * new event may be issued (to reduce effects of RSSI oscillation).
+ * @NL80211_ATTR_CQM_RSSI_THRESHOLD_EVENT: RSSI threshold event
+ * @NL80211_ATTR_CQM_PKT_LOSS_EVENT: a u32 value indicating that this many
+ * consecutive packets were not acknowledged by the peer
+ * @__NL80211_ATTR_CQM_AFTER_LAST: internal
+ * @NL80211_ATTR_CQM_MAX: highest key attribute
+ */
+enum nl80211_attr_cqm {
+ __NL80211_ATTR_CQM_INVALID,
+ NL80211_ATTR_CQM_RSSI_THOLD,
+ NL80211_ATTR_CQM_RSSI_HYST,
+ NL80211_ATTR_CQM_RSSI_THRESHOLD_EVENT,
+ NL80211_ATTR_CQM_PKT_LOSS_EVENT,
+
+ /* keep last */
+ __NL80211_ATTR_CQM_AFTER_LAST,
+ NL80211_ATTR_CQM_MAX = __NL80211_ATTR_CQM_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_cqm_rssi_threshold_event - RSSI threshold event
+ * @NL80211_CQM_RSSI_THRESHOLD_EVENT_LOW: The RSSI level is lower than the
+ * configured threshold
+ * @NL80211_CQM_RSSI_THRESHOLD_EVENT_HIGH: The RSSI is higher than the
+ * configured threshold
+ */
+enum nl80211_cqm_rssi_threshold_event {
+ NL80211_CQM_RSSI_THRESHOLD_EVENT_LOW,
+ NL80211_CQM_RSSI_THRESHOLD_EVENT_HIGH,
+};
+
+
+/**
+ * enum nl80211_tx_power_setting - TX power adjustment
+ * @NL80211_TX_POWER_AUTOMATIC: automatically determine transmit power
+ * @NL80211_TX_POWER_LIMITED: limit TX power by the mBm parameter
+ * @NL80211_TX_POWER_FIXED: fix TX power to the mBm parameter
+ */
+enum nl80211_tx_power_setting {
+ NL80211_TX_POWER_AUTOMATIC,
+ NL80211_TX_POWER_LIMITED,
+ NL80211_TX_POWER_FIXED,
+};
+
+/**
+ * enum nl80211_wowlan_packet_pattern_attr - WoWLAN packet pattern attribute
+ * @__NL80211_WOWLAN_PKTPAT_INVALID: invalid number for nested attribute
+ * @NL80211_WOWLAN_PKTPAT_PATTERN: the pattern, values where the mask has
+ * a zero bit are ignored
+ * @NL80211_WOWLAN_PKTPAT_MASK: pattern mask, must be long enough to have
+ * a bit for each byte in the pattern. The lowest-order bit corresponds
+ * to the first byte of the pattern, but the bytes of the pattern are
+ * in a little-endian-like format, i.e. the 9th byte of the pattern
+ * corresponds to the lowest-order bit in the second byte of the mask.
+ * For example: The match 00:xx:00:00:xx:00:00:00:00:xx:xx:xx (where
+ * xx indicates "don't care") would be represented by a pattern of
+ * twelve zero bytes, and a mask of "0xed,0x07".
+ * Note that the pattern matching is done as though frames were not
+ * 802.11 frames but 802.3 frames, i.e. the frame is fully unpacked
+ * first (including SNAP header unpacking) and then matched.
+ * @NUM_NL80211_WOWLAN_PKTPAT: number of attributes
+ * @MAX_NL80211_WOWLAN_PKTPAT: max attribute number
+ */
+enum nl80211_wowlan_packet_pattern_attr {
+ __NL80211_WOWLAN_PKTPAT_INVALID,
+ NL80211_WOWLAN_PKTPAT_MASK,
+ NL80211_WOWLAN_PKTPAT_PATTERN,
+
+ NUM_NL80211_WOWLAN_PKTPAT,
+ MAX_NL80211_WOWLAN_PKTPAT = NUM_NL80211_WOWLAN_PKTPAT - 1,
+};
+
+/**
+ * struct nl80211_wowlan_pattern_support - pattern support information
+ * @max_patterns: maximum number of patterns supported
+ * @min_pattern_len: minimum length of each pattern
+ * @max_pattern_len: maximum length of each pattern
+ *
+ * This struct is carried in %NL80211_WOWLAN_TRIG_PKT_PATTERN when
+ * that is part of %NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED in the
+ * capability information given by the kernel to userspace.
+ */
+struct nl80211_wowlan_pattern_support {
+ __u32 max_patterns;
+ __u32 min_pattern_len;
+ __u32 max_pattern_len;
+} __attribute__((packed));
+
+/**
+ * enum nl80211_wowlan_triggers - WoWLAN trigger definitions
+ * @__NL80211_WOWLAN_TRIG_INVALID: invalid number for nested attributes
+ * @NL80211_WOWLAN_TRIG_ANY: wake up on any activity, do not really put
+ * the chip into a special state -- works best with chips that have
+ * support for low-power operation already (flag)
+ * @NL80211_WOWLAN_TRIG_DISCONNECT: wake up on disconnect, the way disconnect
+ * is detected is implementation-specific (flag)
+ * @NL80211_WOWLAN_TRIG_MAGIC_PKT: wake up on magic packet (6x 0xff, followed
+ * by 16 repetitions of MAC addr, anywhere in payload) (flag)
+ * @NL80211_WOWLAN_TRIG_PKT_PATTERN: wake up on the specified packet patterns
+ * which are passed in an array of nested attributes, each nested attribute
+ * defining a with attributes from &struct nl80211_wowlan_trig_pkt_pattern.
+ * Each pattern defines a wakeup packet. The matching is done on the MSDU,
+ * i.e. as though the packet was an 802.3 packet, so the pattern matching
+ * is done after the packet is converted to the MSDU.
+ *
+ * In %NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED, it is a binary attribute
+ * carrying a &struct nl80211_wowlan_pattern_support.
+ * @NL80211_WOWLAN_TRIG_GTK_REKEY_SUPPORTED: Not a real trigger, and cannot be
+ * used when setting, used only to indicate that GTK rekeying is supported
+ * by the device (flag)
+ * @NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE: wake up on GTK rekey failure (if
+ * done by the device) (flag)
+ * @NL80211_WOWLAN_TRIG_EAP_IDENT_REQUEST: wake up on EAP Identity Request
+ * packet (flag)
+ * @NL80211_WOWLAN_TRIG_4WAY_HANDSHAKE: wake up on 4-way handshake (flag)
+ * @NL80211_WOWLAN_TRIG_RFKILL_RELEASE: wake up when rfkill is released
+ * (on devices that have rfkill in the device) (flag)
+ * @NUM_NL80211_WOWLAN_TRIG: number of wake on wireless triggers
+ * @MAX_NL80211_WOWLAN_TRIG: highest wowlan trigger attribute number
+ */
+enum nl80211_wowlan_triggers {
+ __NL80211_WOWLAN_TRIG_INVALID,
+ NL80211_WOWLAN_TRIG_ANY,
+ NL80211_WOWLAN_TRIG_DISCONNECT,
+ NL80211_WOWLAN_TRIG_MAGIC_PKT,
+ NL80211_WOWLAN_TRIG_PKT_PATTERN,
+ NL80211_WOWLAN_TRIG_GTK_REKEY_SUPPORTED,
+ NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE,
+ NL80211_WOWLAN_TRIG_EAP_IDENT_REQUEST,
+ NL80211_WOWLAN_TRIG_4WAY_HANDSHAKE,
+ NL80211_WOWLAN_TRIG_RFKILL_RELEASE,
+
+ /* keep last */
+ NUM_NL80211_WOWLAN_TRIG,
+ MAX_NL80211_WOWLAN_TRIG = NUM_NL80211_WOWLAN_TRIG - 1
+};
+
+/**
+ * enum nl80211_iface_limit_attrs - limit attributes
+ * @NL80211_IFACE_LIMIT_UNSPEC: (reserved)
+ * @NL80211_IFACE_LIMIT_MAX: maximum number of interfaces that
+ * can be chosen from this set of interface types (u32)
+ * @NL80211_IFACE_LIMIT_TYPES: nested attribute containing a
+ * flag attribute for each interface type in this set
+ * @NUM_NL80211_IFACE_LIMIT: number of attributes
+ * @MAX_NL80211_IFACE_LIMIT: highest attribute number
+ */
+enum nl80211_iface_limit_attrs {
+ NL80211_IFACE_LIMIT_UNSPEC,
+ NL80211_IFACE_LIMIT_MAX,
+ NL80211_IFACE_LIMIT_TYPES,
+
+ /* keep last */
+ NUM_NL80211_IFACE_LIMIT,
+ MAX_NL80211_IFACE_LIMIT = NUM_NL80211_IFACE_LIMIT - 1
+};
+
+/**
+ * enum nl80211_if_combination_attrs -- interface combination attributes
+ *
+ * @NL80211_IFACE_COMB_UNSPEC: (reserved)
+ * @NL80211_IFACE_COMB_LIMITS: Nested attributes containing the limits
+ * for given interface types, see &enum nl80211_iface_limit_attrs.
+ * @NL80211_IFACE_COMB_MAXNUM: u32 attribute giving the total number of
+ * interfaces that can be created in this group. This number doesn't
+ * apply to interfaces purely managed in software, which are listed
+ * in a separate attribute %NL80211_ATTR_INTERFACES_SOFTWARE.
+ * @NL80211_IFACE_COMB_STA_AP_BI_MATCH: flag attribute specifying that
+ * beacon intervals within this group must be all the same even for
+ * infrastructure and AP/GO combinations, i.e. the GO(s) must adopt
+ * the infrastructure network's beacon interval.
+ * @NL80211_IFACE_COMB_NUM_CHANNELS: u32 attribute specifying how many
+ * different channels may be used within this group.
+ * @NUM_NL80211_IFACE_COMB: number of attributes
+ * @MAX_NL80211_IFACE_COMB: highest attribute number
+ *
+ * Examples:
+ * limits = [ #{STA} <= 1, #{AP} <= 1 ], matching BI, channels = 1, max = 2
+ * => allows an AP and a STA that must match BIs
+ *
+ * numbers = [ #{AP, P2P-GO} <= 8 ], channels = 1, max = 8
+ * => allows 8 of AP/GO
+ *
+ * numbers = [ #{STA} <= 2 ], channels = 2, max = 2
+ * => allows two STAs on different channels
+ *
+ * numbers = [ #{STA} <= 1, #{P2P-client,P2P-GO} <= 3 ], max = 4
+ * => allows a STA plus three P2P interfaces
+ *
+ * The list of these four possiblities could completely be contained
+ * within the %NL80211_ATTR_INTERFACE_COMBINATIONS attribute to indicate
+ * that any of these groups must match.
+ *
+ * "Combinations" of just a single interface will not be listed here,
+ * a single interface of any valid interface type is assumed to always
+ * be possible by itself. This means that implicitly, for each valid
+ * interface type, the following group always exists:
+ * numbers = [ #{<type>} <= 1 ], channels = 1, max = 1
+ */
+enum nl80211_if_combination_attrs {
+ NL80211_IFACE_COMB_UNSPEC,
+ NL80211_IFACE_COMB_LIMITS,
+ NL80211_IFACE_COMB_MAXNUM,
+ NL80211_IFACE_COMB_STA_AP_BI_MATCH,
+ NL80211_IFACE_COMB_NUM_CHANNELS,
+
+ /* keep last */
+ NUM_NL80211_IFACE_COMB,
+ MAX_NL80211_IFACE_COMB = NUM_NL80211_IFACE_COMB - 1
+};
+
+
+/**
+ * enum nl80211_plink_state - state of a mesh peer link finite state machine
+ *
+ * @NL80211_PLINK_LISTEN: initial state, considered the implicit
+ * state of non existant mesh peer links
+ * @NL80211_PLINK_OPN_SNT: mesh plink open frame has been sent to
+ * this mesh peer
+ * @NL80211_PLINK_OPN_RCVD: mesh plink open frame has been received
+ * from this mesh peer
+ * @NL80211_PLINK_CNF_RCVD: mesh plink confirm frame has been
+ * received from this mesh peer
+ * @NL80211_PLINK_ESTAB: mesh peer link is established
+ * @NL80211_PLINK_HOLDING: mesh peer link is being closed or cancelled
+ * @NL80211_PLINK_BLOCKED: all frames transmitted from this mesh
+ * plink are discarded
+ * @NUM_NL80211_PLINK_STATES: number of peer link states
+ * @MAX_NL80211_PLINK_STATES: highest numerical value of plink states
+ */
+enum nl80211_plink_state {
+ NL80211_PLINK_LISTEN,
+ NL80211_PLINK_OPN_SNT,
+ NL80211_PLINK_OPN_RCVD,
+ NL80211_PLINK_CNF_RCVD,
+ NL80211_PLINK_ESTAB,
+ NL80211_PLINK_HOLDING,
+ NL80211_PLINK_BLOCKED,
+
+ /* keep last */
+ NUM_NL80211_PLINK_STATES,
+ MAX_NL80211_PLINK_STATES = NUM_NL80211_PLINK_STATES - 1
+};
+
+#define NL80211_KCK_LEN 16
+#define NL80211_KEK_LEN 16
+#define NL80211_REPLAY_CTR_LEN 8
+
+/**
+ * enum nl80211_rekey_data - attributes for GTK rekey offload
+ * @__NL80211_REKEY_DATA_INVALID: invalid number for nested attributes
+ * @NL80211_REKEY_DATA_KEK: key encryption key (binary)
+ * @NL80211_REKEY_DATA_KCK: key confirmation key (binary)
+ * @NL80211_REKEY_DATA_REPLAY_CTR: replay counter (binary)
+ * @NUM_NL80211_REKEY_DATA: number of rekey attributes (internal)
+ * @MAX_NL80211_REKEY_DATA: highest rekey attribute (internal)
+ */
+enum nl80211_rekey_data {
+ __NL80211_REKEY_DATA_INVALID,
+ NL80211_REKEY_DATA_KEK,
+ NL80211_REKEY_DATA_KCK,
+ NL80211_REKEY_DATA_REPLAY_CTR,
+
+ /* keep last */
+ NUM_NL80211_REKEY_DATA,
+ MAX_NL80211_REKEY_DATA = NUM_NL80211_REKEY_DATA - 1
+};
+
+/**
+ * enum nl80211_hidden_ssid - values for %NL80211_ATTR_HIDDEN_SSID
+ * @NL80211_HIDDEN_SSID_NOT_IN_USE: do not hide SSID (i.e., broadcast it in
+ * Beacon frames)
+ * @NL80211_HIDDEN_SSID_ZERO_LEN: hide SSID by using zero-length SSID element
+ * in Beacon frames
+ * @NL80211_HIDDEN_SSID_ZERO_CONTENTS: hide SSID by using correct length of SSID
+ * element in Beacon frames but zero out each byte in the SSID
+ */
+enum nl80211_hidden_ssid {
+ NL80211_HIDDEN_SSID_NOT_IN_USE,
+ NL80211_HIDDEN_SSID_ZERO_LEN,
+ NL80211_HIDDEN_SSID_ZERO_CONTENTS
+};
+
+/**
+ * enum nl80211_sta_wme_attr - station WME attributes
+ * @__NL80211_STA_WME_INVALID: invalid number for nested attribute
+ * @NL80211_STA_WME_UAPSD_QUEUES: bitmap of uapsd queues. the format
+ * is the same as the AC bitmap in the QoS info field.
+ * @NL80211_STA_WME_MAX_SP: max service period. the format is the same
+ * as the MAX_SP field in the QoS info field (but already shifted down).
+ * @__NL80211_STA_WME_AFTER_LAST: internal
+ * @NL80211_STA_WME_MAX: highest station WME attribute
+ */
+enum nl80211_sta_wme_attr {
+ __NL80211_STA_WME_INVALID,
+ NL80211_STA_WME_UAPSD_QUEUES,
+ NL80211_STA_WME_MAX_SP,
+
+ /* keep last */
+ __NL80211_STA_WME_AFTER_LAST,
+ NL80211_STA_WME_MAX = __NL80211_STA_WME_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_pmksa_candidate_attr - attributes for PMKSA caching candidates
+ * @__NL80211_PMKSA_CANDIDATE_INVALID: invalid number for nested attributes
+ * @NL80211_PMKSA_CANDIDATE_INDEX: candidate index (u32; the smaller, the higher
+ * priority)
+ * @NL80211_PMKSA_CANDIDATE_BSSID: candidate BSSID (6 octets)
+ * @NL80211_PMKSA_CANDIDATE_PREAUTH: RSN pre-authentication supported (flag)
+ * @NUM_NL80211_PMKSA_CANDIDATE: number of PMKSA caching candidate attributes
+ * (internal)
+ * @MAX_NL80211_PMKSA_CANDIDATE: highest PMKSA caching candidate attribute
+ * (internal)
+ */
+enum nl80211_pmksa_candidate_attr {
+ __NL80211_PMKSA_CANDIDATE_INVALID,
+ NL80211_PMKSA_CANDIDATE_INDEX,
+ NL80211_PMKSA_CANDIDATE_BSSID,
+ NL80211_PMKSA_CANDIDATE_PREAUTH,
+
+ /* keep last */
+ NUM_NL80211_PMKSA_CANDIDATE,
+ MAX_NL80211_PMKSA_CANDIDATE = NUM_NL80211_PMKSA_CANDIDATE - 1
+};
+
+/**
+ * enum nl80211_tdls_operation - values for %NL80211_ATTR_TDLS_OPERATION
+ * @NL80211_TDLS_DISCOVERY_REQ: Send a TDLS discovery request
+ * @NL80211_TDLS_SETUP: Setup TDLS link
+ * @NL80211_TDLS_TEARDOWN: Teardown a TDLS link which is already established
+ * @NL80211_TDLS_ENABLE_LINK: Enable TDLS link
+ * @NL80211_TDLS_DISABLE_LINK: Disable TDLS link
+ */
+enum nl80211_tdls_operation {
+ NL80211_TDLS_DISCOVERY_REQ,
+ NL80211_TDLS_SETUP,
+ NL80211_TDLS_TEARDOWN,
+ NL80211_TDLS_ENABLE_LINK,
+ NL80211_TDLS_DISABLE_LINK,
+};
+
+/*
+ * enum nl80211_ap_sme_features - device-integrated AP features
+ * Reserved for future use, no bits are defined in
+ * NL80211_ATTR_DEVICE_AP_SME yet.
+enum nl80211_ap_sme_features {
+};
+ */
+
+/**
+ * enum nl80211_feature_flags - device/driver features
+ * @NL80211_FEATURE_SK_TX_STATUS: This driver supports reflecting back
+ * TX status to the socket error queue when requested with the
+ * socket option.
+ * @NL80211_FEATURE_HT_IBSS: This driver supports IBSS with HT datarates.
+ */
+enum nl80211_feature_flags {
+ NL80211_FEATURE_SK_TX_STATUS = 1 << 0,
+ NL80211_FEATURE_HT_IBSS = 1 << 1,
+};
+
+/**
+ * enum nl80211_probe_resp_offload_support_attr - optional supported
+ * protocols for probe-response offloading by the driver/FW.
+ * To be used with the %NL80211_ATTR_PROBE_RESP_OFFLOAD attribute.
+ * Each enum value represents a bit in the bitmap of supported
+ * protocols. Typically a subset of probe-requests belonging to a
+ * supported protocol will be excluded from offload and uploaded
+ * to the host.
+ *
+ * @NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS: Support for WPS ver. 1
+ * @NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2: Support for WPS ver. 2
+ * @NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P: Support for P2P
+ * @NL80211_PROBE_RESP_OFFLOAD_SUPPORT_80211U: Support for 802.11u
+ */
+enum nl80211_probe_resp_offload_support_attr {
+ NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS = 1<<0,
+ NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2 = 1<<1,
+ NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P = 1<<2,
+ NL80211_PROBE_RESP_OFFLOAD_SUPPORT_80211U = 1<<3,
+};
+
+#endif /* __LINUX_NL80211_H */
diff --git a/package/network/utils/iwinfo/src/include/iwinfo/api/wext.h b/package/network/utils/iwinfo/src/include/iwinfo/api/wext.h
new file mode 100644
index 0000000..6b5838e
--- /dev/null
+++ b/package/network/utils/iwinfo/src/include/iwinfo/api/wext.h
@@ -0,0 +1,1139 @@
+/*
+ * This file define a set of standard wireless extensions
+ *
+ * Version : 22 16.3.07
+ *
+ * Authors : Jean Tourrilhes - HPL - <jt@hpl.hp.com>
+ * Copyright (c) 1997-2007 Jean Tourrilhes, All Rights Reserved.
+ */
+
+#ifndef _LINUX_WIRELESS_H
+#define _LINUX_WIRELESS_H
+
+/************************** DOCUMENTATION **************************/
+/*
+ * Initial APIs (1996 -> onward) :
+ * -----------------------------
+ * Basically, the wireless extensions are for now a set of standard ioctl
+ * call + /proc/net/wireless
+ *
+ * The entry /proc/net/wireless give statistics and information on the
+ * driver.
+ * This is better than having each driver having its entry because
+ * its centralised and we may remove the driver module safely.
+ *
+ * Ioctl are used to configure the driver and issue commands. This is
+ * better than command line options of insmod because we may want to
+ * change dynamically (while the driver is running) some parameters.
+ *
+ * The ioctl mechanimsm are copied from standard devices ioctl.
+ * We have the list of command plus a structure descibing the
+ * data exchanged...
+ * Note that to add these ioctl, I was obliged to modify :
+ * # net/core/dev.c (two place + add include)
+ * # net/ipv4/af_inet.c (one place + add include)
+ *
+ * /proc/net/wireless is a copy of /proc/net/dev.
+ * We have a structure for data passed from the driver to /proc/net/wireless
+ * Too add this, I've modified :
+ * # net/core/dev.c (two other places)
+ * # include/linux/netdevice.h (one place)
+ * # include/linux/proc_fs.h (one place)
+ *
+ * New driver API (2002 -> onward) :
+ * -------------------------------
+ * This file is only concerned with the user space API and common definitions.
+ * The new driver API is defined and documented in :
+ * # include/net/iw_handler.h
+ *
+ * Note as well that /proc/net/wireless implementation has now moved in :
+ * # net/core/wireless.c
+ *
+ * Wireless Events (2002 -> onward) :
+ * --------------------------------
+ * Events are defined at the end of this file, and implemented in :
+ * # net/core/wireless.c
+ *
+ * Other comments :
+ * --------------
+ * Do not add here things that are redundant with other mechanisms
+ * (drivers init, ifconfig, /proc/net/dev, ...) and with are not
+ * wireless specific.
+ *
+ * These wireless extensions are not magic : each driver has to provide
+ * support for them...
+ *
+ * IMPORTANT NOTE : As everything in the kernel, this is very much a
+ * work in progress. Contact me if you have ideas of improvements...
+ */
+
+/***************************** INCLUDES *****************************/
+
+/* This header is used in user-space, therefore need to be sanitised
+ * for that purpose. Those includes are usually not compatible with glibc.
+ * To know which includes to use in user-space, check iwlib.h. */
+#ifdef __KERNEL__
+#include <linux/types.h> /* for "caddr_t" et al */
+#include <linux/socket.h> /* for "struct sockaddr" et al */
+#include <linux/if.h> /* for IFNAMSIZ and co... */
+#endif /* __KERNEL__ */
+
+/***************************** VERSION *****************************/
+/*
+ * This constant is used to know the availability of the wireless
+ * extensions and to know which version of wireless extensions it is
+ * (there is some stuff that will be added in the future...)
+ * I just plan to increment with each new version.
+ */
+#define WIRELESS_EXT 22
+
+/*
+ * Changes :
+ *
+ * V2 to V3
+ * --------
+ * Alan Cox start some incompatibles changes. I've integrated a bit more.
+ * - Encryption renamed to Encode to avoid US regulation problems
+ * - Frequency changed from float to struct to avoid problems on old 386
+ *
+ * V3 to V4
+ * --------
+ * - Add sensitivity
+ *
+ * V4 to V5
+ * --------
+ * - Missing encoding definitions in range
+ * - Access points stuff
+ *
+ * V5 to V6
+ * --------
+ * - 802.11 support (ESSID ioctls)
+ *
+ * V6 to V7
+ * --------
+ * - define IW_ESSID_MAX_SIZE and IW_MAX_AP
+ *
+ * V7 to V8
+ * --------
+ * - Changed my e-mail address
+ * - More 802.11 support (nickname, rate, rts, frag)
+ * - List index in frequencies
+ *
+ * V8 to V9
+ * --------
+ * - Support for 'mode of operation' (ad-hoc, managed...)
+ * - Support for unicast and multicast power saving
+ * - Change encoding to support larger tokens (>64 bits)
+ * - Updated iw_params (disable, flags) and use it for NWID
+ * - Extracted iw_point from iwreq for clarity
+ *
+ * V9 to V10
+ * ---------
+ * - Add PM capability to range structure
+ * - Add PM modifier : MAX/MIN/RELATIVE
+ * - Add encoding option : IW_ENCODE_NOKEY
+ * - Add TxPower ioctls (work like TxRate)
+ *
+ * V10 to V11
+ * ----------
+ * - Add WE version in range (help backward/forward compatibility)
+ * - Add retry ioctls (work like PM)
+ *
+ * V11 to V12
+ * ----------
+ * - Add SIOCSIWSTATS to get /proc/net/wireless programatically
+ * - Add DEV PRIVATE IOCTL to avoid collisions in SIOCDEVPRIVATE space
+ * - Add new statistics (frag, retry, beacon)
+ * - Add average quality (for user space calibration)
+ *
+ * V12 to V13
+ * ----------
+ * - Document creation of new driver API.
+ * - Extract union iwreq_data from struct iwreq (for new driver API).
+ * - Rename SIOCSIWNAME as SIOCSIWCOMMIT
+ *
+ * V13 to V14
+ * ----------
+ * - Wireless Events support : define struct iw_event
+ * - Define additional specific event numbers
+ * - Add "addr" and "param" fields in union iwreq_data
+ * - AP scanning stuff (SIOCSIWSCAN and friends)
+ *
+ * V14 to V15
+ * ----------
+ * - Add IW_PRIV_TYPE_ADDR for struct sockaddr private arg
+ * - Make struct iw_freq signed (both m & e), add explicit padding
+ * - Add IWEVCUSTOM for driver specific event/scanning token
+ * - Add IW_MAX_GET_SPY for driver returning a lot of addresses
+ * - Add IW_TXPOW_RANGE for range of Tx Powers
+ * - Add IWEVREGISTERED & IWEVEXPIRED events for Access Points
+ * - Add IW_MODE_MONITOR for passive monitor
+ *
+ * V15 to V16
+ * ----------
+ * - Increase the number of bitrates in iw_range to 32 (for 802.11g)
+ * - Increase the number of frequencies in iw_range to 32 (for 802.11b+a)
+ * - Reshuffle struct iw_range for increases, add filler
+ * - Increase IW_MAX_AP to 64 for driver returning a lot of addresses
+ * - Remove IW_MAX_GET_SPY because conflict with enhanced spy support
+ * - Add SIOCSIWTHRSPY/SIOCGIWTHRSPY and "struct iw_thrspy"
+ * - Add IW_ENCODE_TEMP and iw_range->encoding_login_index
+ *
+ * V16 to V17
+ * ----------
+ * - Add flags to frequency -> auto/fixed
+ * - Document (struct iw_quality *)->updated, add new flags (INVALID)
+ * - Wireless Event capability in struct iw_range
+ * - Add support for relative TxPower (yick !)
+ *
+ * V17 to V18 (From Jouni Malinen <jkmaline@cc.hut.fi>)
+ * ----------
+ * - Add support for WPA/WPA2
+ * - Add extended encoding configuration (SIOCSIWENCODEEXT and
+ * SIOCGIWENCODEEXT)
+ * - Add SIOCSIWGENIE/SIOCGIWGENIE
+ * - Add SIOCSIWMLME
+ * - Add SIOCSIWPMKSA
+ * - Add struct iw_range bit field for supported encoding capabilities
+ * - Add optional scan request parameters for SIOCSIWSCAN
+ * - Add SIOCSIWAUTH/SIOCGIWAUTH for setting authentication and WPA
+ * related parameters (extensible up to 4096 parameter values)
+ * - Add wireless events: IWEVGENIE, IWEVMICHAELMICFAILURE,
+ * IWEVASSOCREQIE, IWEVASSOCRESPIE, IWEVPMKIDCAND
+ *
+ * V18 to V19
+ * ----------
+ * - Remove (struct iw_point *)->pointer from events and streams
+ * - Remove header includes to help user space
+ * - Increase IW_ENCODING_TOKEN_MAX from 32 to 64
+ * - Add IW_QUAL_ALL_UPDATED and IW_QUAL_ALL_INVALID macros
+ * - Add explicit flag to tell stats are in dBm : IW_QUAL_DBM
+ * - Add IW_IOCTL_IDX() and IW_EVENT_IDX() macros
+ *
+ * V19 to V20
+ * ----------
+ * - RtNetlink requests support (SET/GET)
+ *
+ * V20 to V21
+ * ----------
+ * - Remove (struct net_device *)->get_wireless_stats()
+ * - Change length in ESSID and NICK to strlen() instead of strlen()+1
+ * - Add IW_RETRY_SHORT/IW_RETRY_LONG retry modifiers
+ * - Power/Retry relative values no longer * 100000
+ * - Add explicit flag to tell stats are in 802.11k RCPI : IW_QUAL_RCPI
+ *
+ * V21 to V22
+ * ----------
+ * - Prevent leaking of kernel space in stream on 64 bits.
+ */
+
+/**************************** CONSTANTS ****************************/
+
+/* -------------------------- IOCTL LIST -------------------------- */
+
+/* Wireless Identification */
+#define SIOCSIWCOMMIT 0x8B00 /* Commit pending changes to driver */
+#define SIOCGIWNAME 0x8B01 /* get name == wireless protocol */
+/* SIOCGIWNAME is used to verify the presence of Wireless Extensions.
+ * Common values : "IEEE 802.11-DS", "IEEE 802.11-FH", "IEEE 802.11b"...
+ * Don't put the name of your driver there, it's useless. */
+
+/* Basic operations */
+#define SIOCSIWNWID 0x8B02 /* set network id (pre-802.11) */
+#define SIOCGIWNWID 0x8B03 /* get network id (the cell) */
+#define SIOCSIWFREQ 0x8B04 /* set channel/frequency (Hz) */
+#define SIOCGIWFREQ 0x8B05 /* get channel/frequency (Hz) */
+#define SIOCSIWMODE 0x8B06 /* set operation mode */
+#define SIOCGIWMODE 0x8B07 /* get operation mode */
+#define SIOCSIWSENS 0x8B08 /* set sensitivity (dBm) */
+#define SIOCGIWSENS 0x8B09 /* get sensitivity (dBm) */
+
+/* Informative stuff */
+#define SIOCSIWRANGE 0x8B0A /* Unused */
+#define SIOCGIWRANGE 0x8B0B /* Get range of parameters */
+#define SIOCSIWPRIV 0x8B0C /* Unused */
+#define SIOCGIWPRIV 0x8B0D /* get private ioctl interface info */
+#define SIOCSIWSTATS 0x8B0E /* Unused */
+#define SIOCGIWSTATS 0x8B0F /* Get /proc/net/wireless stats */
+/* SIOCGIWSTATS is strictly used between user space and the kernel, and
+ * is never passed to the driver (i.e. the driver will never see it). */
+
+/* Spy support (statistics per MAC address - used for Mobile IP support) */
+#define SIOCSIWSPY 0x8B10 /* set spy addresses */
+#define SIOCGIWSPY 0x8B11 /* get spy info (quality of link) */
+#define SIOCSIWTHRSPY 0x8B12 /* set spy threshold (spy event) */
+#define SIOCGIWTHRSPY 0x8B13 /* get spy threshold */
+
+/* Access Point manipulation */
+#define SIOCSIWAP 0x8B14 /* set access point MAC addresses */
+#define SIOCGIWAP 0x8B15 /* get access point MAC addresses */
+#define SIOCGIWAPLIST 0x8B17 /* Deprecated in favor of scanning */
+#define SIOCSIWSCAN 0x8B18 /* trigger scanning (list cells) */
+#define SIOCGIWSCAN 0x8B19 /* get scanning results */
+
+/* 802.11 specific support */
+#define SIOCSIWESSID 0x8B1A /* set ESSID (network name) */
+#define SIOCGIWESSID 0x8B1B /* get ESSID */
+#define SIOCSIWNICKN 0x8B1C /* set node name/nickname */
+#define SIOCGIWNICKN 0x8B1D /* get node name/nickname */
+/* As the ESSID and NICKN are strings up to 32 bytes long, it doesn't fit
+ * within the 'iwreq' structure, so we need to use the 'data' member to
+ * point to a string in user space, like it is done for RANGE... */
+
+/* Other parameters useful in 802.11 and some other devices */
+#define SIOCSIWRATE 0x8B20 /* set default bit rate (bps) */
+#define SIOCGIWRATE 0x8B21 /* get default bit rate (bps) */
+#define SIOCSIWRTS 0x8B22 /* set RTS/CTS threshold (bytes) */
+#define SIOCGIWRTS 0x8B23 /* get RTS/CTS threshold (bytes) */
+#define SIOCSIWFRAG 0x8B24 /* set fragmentation thr (bytes) */
+#define SIOCGIWFRAG 0x8B25 /* get fragmentation thr (bytes) */
+#define SIOCSIWTXPOW 0x8B26 /* set transmit power (dBm) */
+#define SIOCGIWTXPOW 0x8B27 /* get transmit power (dBm) */
+#define SIOCSIWRETRY 0x8B28 /* set retry limits and lifetime */
+#define SIOCGIWRETRY 0x8B29 /* get retry limits and lifetime */
+
+/* Encoding stuff (scrambling, hardware security, WEP...) */
+#define SIOCSIWENCODE 0x8B2A /* set encoding token & mode */
+#define SIOCGIWENCODE 0x8B2B /* get encoding token & mode */
+/* Power saving stuff (power management, unicast and multicast) */
+#define SIOCSIWPOWER 0x8B2C /* set Power Management settings */
+#define SIOCGIWPOWER 0x8B2D /* get Power Management settings */
+/* Modulation bitmask */
+#define SIOCSIWMODUL 0x8B2E /* set Modulations settings */
+#define SIOCGIWMODUL 0x8B2F /* get Modulations settings */
+
+/* WPA : Generic IEEE 802.11 informatiom element (e.g., for WPA/RSN/WMM).
+ * This ioctl uses struct iw_point and data buffer that includes IE id and len
+ * fields. More than one IE may be included in the request. Setting the generic
+ * IE to empty buffer (len=0) removes the generic IE from the driver. Drivers
+ * are allowed to generate their own WPA/RSN IEs, but in these cases, drivers
+ * are required to report the used IE as a wireless event, e.g., when
+ * associating with an AP. */
+#define SIOCSIWGENIE 0x8B30 /* set generic IE */
+#define SIOCGIWGENIE 0x8B31 /* get generic IE */
+
+/* WPA : IEEE 802.11 MLME requests */
+#define SIOCSIWMLME 0x8B16 /* request MLME operation; uses
+ * struct iw_mlme */
+/* WPA : Authentication mode parameters */
+#define SIOCSIWAUTH 0x8B32 /* set authentication mode params */
+#define SIOCGIWAUTH 0x8B33 /* get authentication mode params */
+
+/* WPA : Extended version of encoding configuration */
+#define SIOCSIWENCODEEXT 0x8B34 /* set encoding token & mode */
+#define SIOCGIWENCODEEXT 0x8B35 /* get encoding token & mode */
+
+/* WPA2 : PMKSA cache management */
+#define SIOCSIWPMKSA 0x8B36 /* PMKSA cache operation */
+
+/* -------------------- DEV PRIVATE IOCTL LIST -------------------- */
+
+/* These 32 ioctl are wireless device private, for 16 commands.
+ * Each driver is free to use them for whatever purpose it chooses,
+ * however the driver *must* export the description of those ioctls
+ * with SIOCGIWPRIV and *must* use arguments as defined below.
+ * If you don't follow those rules, DaveM is going to hate you (reason :
+ * it make mixed 32/64bit operation impossible).
+ */
+#define SIOCIWFIRSTPRIV 0x8BE0
+#define SIOCIWLASTPRIV 0x8BFF
+/* Previously, we were using SIOCDEVPRIVATE, but we now have our
+ * separate range because of collisions with other tools such as
+ * 'mii-tool'.
+ * We now have 32 commands, so a bit more space ;-).
+ * Also, all 'even' commands are only usable by root and don't return the
+ * content of ifr/iwr to user (but you are not obliged to use the set/get
+ * convention, just use every other two command). More details in iwpriv.c.
+ * And I repeat : you are not forced to use them with iwpriv, but you
+ * must be compliant with it.
+ */
+
+/* ------------------------- IOCTL STUFF ------------------------- */
+
+/* The first and the last (range) */
+#define SIOCIWFIRST 0x8B00
+#define SIOCIWLAST SIOCIWLASTPRIV /* 0x8BFF */
+#define IW_IOCTL_IDX(cmd) ((cmd) - SIOCIWFIRST)
+
+/* Odd : get (world access), even : set (root access) */
+#define IW_IS_SET(cmd) (!((cmd) & 0x1))
+#define IW_IS_GET(cmd) ((cmd) & 0x1)
+
+/* ----------------------- WIRELESS EVENTS ----------------------- */
+/* Those are *NOT* ioctls, do not issue request on them !!! */
+/* Most events use the same identifier as ioctl requests */
+
+#define IWEVTXDROP 0x8C00 /* Packet dropped to excessive retry */
+#define IWEVQUAL 0x8C01 /* Quality part of statistics (scan) */
+#define IWEVCUSTOM 0x8C02 /* Driver specific ascii string */
+#define IWEVREGISTERED 0x8C03 /* Discovered a new node (AP mode) */
+#define IWEVEXPIRED 0x8C04 /* Expired a node (AP mode) */
+#define IWEVGENIE 0x8C05 /* Generic IE (WPA, RSN, WMM, ..)
+ * (scan results); This includes id and
+ * length fields. One IWEVGENIE may
+ * contain more than one IE. Scan
+ * results may contain one or more
+ * IWEVGENIE events. */
+#define IWEVMICHAELMICFAILURE 0x8C06 /* Michael MIC failure
+ * (struct iw_michaelmicfailure)
+ */
+#define IWEVASSOCREQIE 0x8C07 /* IEs used in (Re)Association Request.
+ * The data includes id and length
+ * fields and may contain more than one
+ * IE. This event is required in
+ * Managed mode if the driver
+ * generates its own WPA/RSN IE. This
+ * should be sent just before
+ * IWEVREGISTERED event for the
+ * association. */
+#define IWEVASSOCRESPIE 0x8C08 /* IEs used in (Re)Association
+ * Response. The data includes id and
+ * length fields and may contain more
+ * than one IE. This may be sent
+ * between IWEVASSOCREQIE and
+ * IWEVREGISTERED events for the
+ * association. */
+#define IWEVPMKIDCAND 0x8C09 /* PMKID candidate for RSN
+ * pre-authentication
+ * (struct iw_pmkid_cand) */
+
+#define IWEVFIRST 0x8C00
+#define IW_EVENT_IDX(cmd) ((cmd) - IWEVFIRST)
+
+/* ------------------------- PRIVATE INFO ------------------------- */
+/*
+ * The following is used with SIOCGIWPRIV. It allow a driver to define
+ * the interface (name, type of data) for its private ioctl.
+ * Privates ioctl are SIOCIWFIRSTPRIV -> SIOCIWLASTPRIV
+ */
+
+#define IW_PRIV_TYPE_MASK 0x7000 /* Type of arguments */
+#define IW_PRIV_TYPE_NONE 0x0000
+#define IW_PRIV_TYPE_BYTE 0x1000 /* Char as number */
+#define IW_PRIV_TYPE_CHAR 0x2000 /* Char as character */
+#define IW_PRIV_TYPE_INT 0x4000 /* 32 bits int */
+#define IW_PRIV_TYPE_FLOAT 0x5000 /* struct iw_freq */
+#define IW_PRIV_TYPE_ADDR 0x6000 /* struct sockaddr */
+
+#define IW_PRIV_SIZE_FIXED 0x0800 /* Variable or fixed number of args */
+
+#define IW_PRIV_SIZE_MASK 0x07FF /* Max number of those args */
+
+/*
+ * Note : if the number of args is fixed and the size < 16 octets,
+ * instead of passing a pointer we will put args in the iwreq struct...
+ */
+
+/* ----------------------- OTHER CONSTANTS ----------------------- */
+
+/* Maximum frequencies in the range struct */
+#define IW_MAX_FREQUENCIES 32
+/* Note : if you have something like 80 frequencies,
+ * don't increase this constant and don't fill the frequency list.
+ * The user will be able to set by channel anyway... */
+
+/* Maximum bit rates in the range struct */
+#define IW_MAX_BITRATES 32
+
+/* Maximum tx powers in the range struct */
+#define IW_MAX_TXPOWER 8
+/* Note : if you more than 8 TXPowers, just set the max and min or
+ * a few of them in the struct iw_range. */
+
+/* Maximum of address that you may set with SPY */
+#define IW_MAX_SPY 8
+
+/* Maximum of address that you may get in the
+ list of access points in range */
+#define IW_MAX_AP 64
+
+/* Maximum size of the ESSID and NICKN strings */
+#define IW_ESSID_MAX_SIZE 32
+
+/* Modes of operation */
+#define IW_MODE_AUTO 0 /* Let the driver decides */
+#define IW_MODE_ADHOC 1 /* Single cell network */
+#define IW_MODE_INFRA 2 /* Multi cell network, roaming, ... */
+#define IW_MODE_MASTER 3 /* Synchronisation master or Access Point */
+#define IW_MODE_REPEAT 4 /* Wireless Repeater (forwarder) */
+#define IW_MODE_SECOND 5 /* Secondary master/repeater (backup) */
+#define IW_MODE_MONITOR 6 /* Passive monitor (listen only) */
+
+/* Statistics flags (bitmask in updated) */
+#define IW_QUAL_QUAL_UPDATED 0x01 /* Value was updated since last read */
+#define IW_QUAL_LEVEL_UPDATED 0x02
+#define IW_QUAL_NOISE_UPDATED 0x04
+#define IW_QUAL_ALL_UPDATED 0x07
+#define IW_QUAL_DBM 0x08 /* Level + Noise are dBm */
+#define IW_QUAL_QUAL_INVALID 0x10 /* Driver doesn't provide value */
+#define IW_QUAL_LEVEL_INVALID 0x20
+#define IW_QUAL_NOISE_INVALID 0x40
+#define IW_QUAL_RCPI 0x80 /* Level + Noise are 802.11k RCPI */
+#define IW_QUAL_ALL_INVALID 0x70
+
+/* Frequency flags */
+#define IW_FREQ_AUTO 0x00 /* Let the driver decides */
+#define IW_FREQ_FIXED 0x01 /* Force a specific value */
+
+/* Maximum number of size of encoding token available
+ * they are listed in the range structure */
+#define IW_MAX_ENCODING_SIZES 8
+
+/* Maximum size of the encoding token in bytes */
+#define IW_ENCODING_TOKEN_MAX 64 /* 512 bits (for now) */
+
+/* Flags for encoding (along with the token) */
+#define IW_ENCODE_INDEX 0x00FF /* Token index (if needed) */
+#define IW_ENCODE_FLAGS 0xFF00 /* Flags defined below */
+#define IW_ENCODE_MODE 0xF000 /* Modes defined below */
+#define IW_ENCODE_DISABLED 0x8000 /* Encoding disabled */
+#define IW_ENCODE_ENABLED 0x0000 /* Encoding enabled */
+#define IW_ENCODE_RESTRICTED 0x4000 /* Refuse non-encoded packets */
+#define IW_ENCODE_OPEN 0x2000 /* Accept non-encoded packets */
+#define IW_ENCODE_NOKEY 0x0800 /* Key is write only, so not present */
+#define IW_ENCODE_TEMP 0x0400 /* Temporary key */
+
+/* Power management flags available (along with the value, if any) */
+#define IW_POWER_ON 0x0000 /* No details... */
+#define IW_POWER_TYPE 0xF000 /* Type of parameter */
+#define IW_POWER_PERIOD 0x1000 /* Value is a period/duration of */
+#define IW_POWER_TIMEOUT 0x2000 /* Value is a timeout (to go asleep) */
+#define IW_POWER_SAVING 0x4000 /* Value is relative (how aggressive)*/
+#define IW_POWER_MODE 0x0F00 /* Power Management mode */
+#define IW_POWER_UNICAST_R 0x0100 /* Receive only unicast messages */
+#define IW_POWER_MULTICAST_R 0x0200 /* Receive only multicast messages */
+#define IW_POWER_ALL_R 0x0300 /* Receive all messages though PM */
+#define IW_POWER_FORCE_S 0x0400 /* Force PM procedure for sending unicast */
+#define IW_POWER_REPEATER 0x0800 /* Repeat broadcast messages in PM period */
+#define IW_POWER_MODIFIER 0x000F /* Modify a parameter */
+#define IW_POWER_MIN 0x0001 /* Value is a minimum */
+#define IW_POWER_MAX 0x0002 /* Value is a maximum */
+#define IW_POWER_RELATIVE 0x0004 /* Value is not in seconds/ms/us */
+
+/* Transmit Power flags available */
+#define IW_TXPOW_TYPE 0x00FF /* Type of value */
+#define IW_TXPOW_DBM 0x0000 /* Value is in dBm */
+#define IW_TXPOW_MWATT 0x0001 /* Value is in mW */
+#define IW_TXPOW_RELATIVE 0x0002 /* Value is in arbitrary units */
+#define IW_TXPOW_RANGE 0x1000 /* Range of value between min/max */
+
+/* Retry limits and lifetime flags available */
+#define IW_RETRY_ON 0x0000 /* No details... */
+#define IW_RETRY_TYPE 0xF000 /* Type of parameter */
+#define IW_RETRY_LIMIT 0x1000 /* Maximum number of retries*/
+#define IW_RETRY_LIFETIME 0x2000 /* Maximum duration of retries in us */
+#define IW_RETRY_MODIFIER 0x00FF /* Modify a parameter */
+#define IW_RETRY_MIN 0x0001 /* Value is a minimum */
+#define IW_RETRY_MAX 0x0002 /* Value is a maximum */
+#define IW_RETRY_RELATIVE 0x0004 /* Value is not in seconds/ms/us */
+#define IW_RETRY_SHORT 0x0010 /* Value is for short packets */
+#define IW_RETRY_LONG 0x0020 /* Value is for long packets */
+
+/* Scanning request flags */
+#define IW_SCAN_DEFAULT 0x0000 /* Default scan of the driver */
+#define IW_SCAN_ALL_ESSID 0x0001 /* Scan all ESSIDs */
+#define IW_SCAN_THIS_ESSID 0x0002 /* Scan only this ESSID */
+#define IW_SCAN_ALL_FREQ 0x0004 /* Scan all Frequencies */
+#define IW_SCAN_THIS_FREQ 0x0008 /* Scan only this Frequency */
+#define IW_SCAN_ALL_MODE 0x0010 /* Scan all Modes */
+#define IW_SCAN_THIS_MODE 0x0020 /* Scan only this Mode */
+#define IW_SCAN_ALL_RATE 0x0040 /* Scan all Bit-Rates */
+#define IW_SCAN_THIS_RATE 0x0080 /* Scan only this Bit-Rate */
+/* struct iw_scan_req scan_type */
+#define IW_SCAN_TYPE_ACTIVE 0
+#define IW_SCAN_TYPE_PASSIVE 1
+/* Maximum size of returned data */
+#define IW_SCAN_MAX_DATA 4096 /* In bytes */
+
+/* Max number of char in custom event - use multiple of them if needed */
+#define IW_CUSTOM_MAX 256 /* In bytes */
+
+/* Generic information element */
+#define IW_GENERIC_IE_MAX 1024
+
+/* MLME requests (SIOCSIWMLME / struct iw_mlme) */
+#define IW_MLME_DEAUTH 0
+#define IW_MLME_DISASSOC 1
+#define IW_MLME_AUTH 2
+#define IW_MLME_ASSOC 3
+
+/* SIOCSIWAUTH/SIOCGIWAUTH struct iw_param flags */
+#define IW_AUTH_INDEX 0x0FFF
+#define IW_AUTH_FLAGS 0xF000
+/* SIOCSIWAUTH/SIOCGIWAUTH parameters (0 .. 4095)
+ * (IW_AUTH_INDEX mask in struct iw_param flags; this is the index of the
+ * parameter that is being set/get to; value will be read/written to
+ * struct iw_param value field) */
+#define IW_AUTH_WPA_VERSION 0
+#define IW_AUTH_CIPHER_PAIRWISE 1
+#define IW_AUTH_CIPHER_GROUP 2
+#define IW_AUTH_KEY_MGMT 3
+#define IW_AUTH_TKIP_COUNTERMEASURES 4
+#define IW_AUTH_DROP_UNENCRYPTED 5
+#define IW_AUTH_80211_AUTH_ALG 6
+#define IW_AUTH_WPA_ENABLED 7
+#define IW_AUTH_RX_UNENCRYPTED_EAPOL 8
+#define IW_AUTH_ROAMING_CONTROL 9
+#define IW_AUTH_PRIVACY_INVOKED 10
+
+/* IW_AUTH_WPA_VERSION values (bit field) */
+#define IW_AUTH_WPA_VERSION_DISABLED 0x00000001
+#define IW_AUTH_WPA_VERSION_WPA 0x00000002
+#define IW_AUTH_WPA_VERSION_WPA2 0x00000004
+
+/* IW_AUTH_PAIRWISE_CIPHER and IW_AUTH_GROUP_CIPHER values (bit field) */
+#define IW_AUTH_CIPHER_NONE 0x00000001
+#define IW_AUTH_CIPHER_WEP40 0x00000002
+#define IW_AUTH_CIPHER_TKIP 0x00000004
+#define IW_AUTH_CIPHER_CCMP 0x00000008
+#define IW_AUTH_CIPHER_WEP104 0x00000010
+
+/* IW_AUTH_KEY_MGMT values (bit field) */
+#define IW_AUTH_KEY_MGMT_802_1X 1
+#define IW_AUTH_KEY_MGMT_PSK 2
+
+/* IW_AUTH_80211_AUTH_ALG values (bit field) */
+#define IW_AUTH_ALG_OPEN_SYSTEM 0x00000001
+#define IW_AUTH_ALG_SHARED_KEY 0x00000002
+#define IW_AUTH_ALG_LEAP 0x00000004
+
+/* IW_AUTH_ROAMING_CONTROL values */
+#define IW_AUTH_ROAMING_ENABLE 0 /* driver/firmware based roaming */
+#define IW_AUTH_ROAMING_DISABLE 1 /* user space program used for roaming
+ * control */
+
+/* SIOCSIWENCODEEXT definitions */
+#define IW_ENCODE_SEQ_MAX_SIZE 8
+/* struct iw_encode_ext ->alg */
+#define IW_ENCODE_ALG_NONE 0
+#define IW_ENCODE_ALG_WEP 1
+#define IW_ENCODE_ALG_TKIP 2
+#define IW_ENCODE_ALG_CCMP 3
+/* struct iw_encode_ext ->ext_flags */
+#define IW_ENCODE_EXT_TX_SEQ_VALID 0x00000001
+#define IW_ENCODE_EXT_RX_SEQ_VALID 0x00000002
+#define IW_ENCODE_EXT_GROUP_KEY 0x00000004
+#define IW_ENCODE_EXT_SET_TX_KEY 0x00000008
+
+/* IWEVMICHAELMICFAILURE : struct iw_michaelmicfailure ->flags */
+#define IW_MICFAILURE_KEY_ID 0x00000003 /* Key ID 0..3 */
+#define IW_MICFAILURE_GROUP 0x00000004
+#define IW_MICFAILURE_PAIRWISE 0x00000008
+#define IW_MICFAILURE_STAKEY 0x00000010
+#define IW_MICFAILURE_COUNT 0x00000060 /* 1 or 2 (0 = count not supported)
+ */
+
+/* Bit field values for enc_capa in struct iw_range */
+#define IW_ENC_CAPA_WPA 0x00000001
+#define IW_ENC_CAPA_WPA2 0x00000002
+#define IW_ENC_CAPA_CIPHER_TKIP 0x00000004
+#define IW_ENC_CAPA_CIPHER_CCMP 0x00000008
+
+/* Event capability macros - in (struct iw_range *)->event_capa
+ * Because we have more than 32 possible events, we use an array of
+ * 32 bit bitmasks. Note : 32 bits = 0x20 = 2^5. */
+#define IW_EVENT_CAPA_BASE(cmd) ((cmd >= SIOCIWFIRSTPRIV) ? \
+ (cmd - SIOCIWFIRSTPRIV + 0x60) : \
+ (cmd - SIOCSIWCOMMIT))
+#define IW_EVENT_CAPA_INDEX(cmd) (IW_EVENT_CAPA_BASE(cmd) >> 5)
+#define IW_EVENT_CAPA_MASK(cmd) (1 << (IW_EVENT_CAPA_BASE(cmd) & 0x1F))
+/* Event capability constants - event autogenerated by the kernel
+ * This list is valid for most 802.11 devices, customise as needed... */
+#define IW_EVENT_CAPA_K_0 (IW_EVENT_CAPA_MASK(0x8B04) | \
+ IW_EVENT_CAPA_MASK(0x8B06) | \
+ IW_EVENT_CAPA_MASK(0x8B1A))
+#define IW_EVENT_CAPA_K_1 (IW_EVENT_CAPA_MASK(0x8B2A))
+/* "Easy" macro to set events in iw_range (less efficient) */
+#define IW_EVENT_CAPA_SET(event_capa, cmd) (event_capa[IW_EVENT_CAPA_INDEX(cmd)] |= IW_EVENT_CAPA_MASK(cmd))
+#define IW_EVENT_CAPA_SET_KERNEL(event_capa) {event_capa[0] |= IW_EVENT_CAPA_K_0; event_capa[1] |= IW_EVENT_CAPA_K_1; }
+
+/* Modulations bitmasks */
+#define IW_MODUL_ALL 0x00000000 /* Everything supported */
+#define IW_MODUL_FH 0x00000001 /* Frequency Hopping */
+#define IW_MODUL_DS 0x00000002 /* Original Direct Sequence */
+#define IW_MODUL_CCK 0x00000004 /* 802.11b : 5.5 + 11 Mb/s */
+#define IW_MODUL_11B (IW_MODUL_DS | IW_MODUL_CCK)
+#define IW_MODUL_PBCC 0x00000008 /* TI : 5.5 + 11 + 22 Mb/s */
+#define IW_MODUL_OFDM_A 0x00000010 /* 802.11a : 54 Mb/s */
+#define IW_MODUL_11A (IW_MODUL_OFDM_A)
+#define IW_MODUL_11AB (IW_MODUL_11B | IW_MODUL_11A)
+#define IW_MODUL_OFDM_G 0x00000020 /* 802.11g : 54 Mb/s */
+#define IW_MODUL_11G (IW_MODUL_11B | IW_MODUL_OFDM_G)
+#define IW_MODUL_11AG (IW_MODUL_11G | IW_MODUL_11A)
+#define IW_MODUL_TURBO 0x00000040 /* ATH : bonding, 108 Mb/s */
+/* In here we should define MIMO stuff. Later... */
+#define IW_MODUL_CUSTOM 0x40000000 /* Driver specific */
+
+/* Bitrate flags available */
+#define IW_BITRATE_TYPE 0x00FF /* Type of value */
+#define IW_BITRATE_UNICAST 0x0001 /* Maximum/Fixed unicast bitrate */
+#define IW_BITRATE_BROADCAST 0x0002 /* Fixed broadcast bitrate */
+
+/****************************** TYPES ******************************/
+
+/* --------------------------- SUBTYPES --------------------------- */
+/*
+ * Generic format for most parameters that fit in an int
+ */
+struct iw_param
+{
+ int32_t value; /* The value of the parameter itself */
+ uint8_t fixed; /* Hardware should not use auto select */
+ uint8_t disabled; /* Disable the feature */
+ uint16_t flags; /* Various specifc flags (if any) */
+};
+
+/*
+ * For all data larger than 16 octets, we need to use a
+ * pointer to memory allocated in user space.
+ */
+struct iw_point
+{
+ void *pointer; /* Pointer to the data (in user space) */
+ uint16_t length; /* number of fields or size in bytes */
+ uint16_t flags; /* Optional params */
+};
+
+/*
+ * A frequency
+ * For numbers lower than 10^9, we encode the number in 'm' and
+ * set 'e' to 0
+ * For number greater than 10^9, we divide it by the lowest power
+ * of 10 to get 'm' lower than 10^9, with 'm'= f / (10^'e')...
+ * The power of 10 is in 'e', the result of the division is in 'm'.
+ */
+struct iw_freq
+{
+ int32_t m; /* Mantissa */
+ int16_t e; /* Exponent */
+ uint8_t i; /* List index (when in range struct) */
+ uint8_t flags; /* Flags (fixed/auto) */
+};
+
+/*
+ * Quality of the link
+ */
+struct iw_quality
+{
+ uint8_t qual; /* link quality (%retries, SNR,
+ %missed beacons or better...) */
+ uint8_t level; /* signal level (dBm) */
+ uint8_t noise; /* noise level (dBm) */
+ uint8_t updated; /* Flags to know if updated */
+};
+
+/*
+ * Packet discarded in the wireless adapter due to
+ * "wireless" specific problems...
+ * Note : the list of counter and statistics in net_device_stats
+ * is already pretty exhaustive, and you should use that first.
+ * This is only additional stats...
+ */
+struct iw_discarded
+{
+ uint32_t nwid; /* Rx : Wrong nwid/essid */
+ uint32_t code; /* Rx : Unable to code/decode (WEP) */
+ uint32_t fragment; /* Rx : Can't perform MAC reassembly */
+ uint32_t retries; /* Tx : Max MAC retries num reached */
+ uint32_t misc; /* Others cases */
+};
+
+/*
+ * Packet/Time period missed in the wireless adapter due to
+ * "wireless" specific problems...
+ */
+struct iw_missed
+{
+ uint32_t beacon; /* Missed beacons/superframe */
+};
+
+/*
+ * Quality range (for spy threshold)
+ */
+struct iw_thrspy
+{
+ struct sockaddr addr; /* Source address (hw/mac) */
+ struct iw_quality qual; /* Quality of the link */
+ struct iw_quality low; /* Low threshold */
+ struct iw_quality high; /* High threshold */
+};
+
+/*
+ * Optional data for scan request
+ *
+ * Note: these optional parameters are controlling parameters for the
+ * scanning behavior, these do not apply to getting scan results
+ * (SIOCGIWSCAN). Drivers are expected to keep a local BSS table and
+ * provide a merged results with all BSSes even if the previous scan
+ * request limited scanning to a subset, e.g., by specifying an SSID.
+ * Especially, scan results are required to include an entry for the
+ * current BSS if the driver is in Managed mode and associated with an AP.
+ */
+struct iw_scan_req
+{
+ uint8_t scan_type; /* IW_SCAN_TYPE_{ACTIVE,PASSIVE} */
+ uint8_t essid_len;
+ uint8_t num_channels; /* num entries in channel_list;
+ * 0 = scan all allowed channels */
+ uint8_t flags; /* reserved as padding; use zero, this may
+ * be used in the future for adding flags
+ * to request different scan behavior */
+ struct sockaddr bssid; /* ff:ff:ff:ff:ff:ff for broadcast BSSID or
+ * individual address of a specific BSS */
+
+ /*
+ * Use this ESSID if IW_SCAN_THIS_ESSID flag is used instead of using
+ * the current ESSID. This allows scan requests for specific ESSID
+ * without having to change the current ESSID and potentially breaking
+ * the current association.
+ */
+ uint8_t essid[IW_ESSID_MAX_SIZE];
+
+ /*
+ * Optional parameters for changing the default scanning behavior.
+ * These are based on the MLME-SCAN.request from IEEE Std 802.11.
+ * TU is 1.024 ms. If these are set to 0, driver is expected to use
+ * reasonable default values. min_channel_time defines the time that
+ * will be used to wait for the first reply on each channel. If no
+ * replies are received, next channel will be scanned after this. If
+ * replies are received, total time waited on the channel is defined by
+ * max_channel_time.
+ */
+ uint32_t min_channel_time; /* in TU */
+ uint32_t max_channel_time; /* in TU */
+
+ struct iw_freq channel_list[IW_MAX_FREQUENCIES];
+};
+
+/* ------------------------- WPA SUPPORT ------------------------- */
+
+/*
+ * Extended data structure for get/set encoding (this is used with
+ * SIOCSIWENCODEEXT/SIOCGIWENCODEEXT. struct iw_point and IW_ENCODE_*
+ * flags are used in the same way as with SIOCSIWENCODE/SIOCGIWENCODE and
+ * only the data contents changes (key data -> this structure, including
+ * key data).
+ *
+ * If the new key is the first group key, it will be set as the default
+ * TX key. Otherwise, default TX key index is only changed if
+ * IW_ENCODE_EXT_SET_TX_KEY flag is set.
+ *
+ * Key will be changed with SIOCSIWENCODEEXT in all cases except for
+ * special "change TX key index" operation which is indicated by setting
+ * key_len = 0 and ext_flags |= IW_ENCODE_EXT_SET_TX_KEY.
+ *
+ * tx_seq/rx_seq are only used when respective
+ * IW_ENCODE_EXT_{TX,RX}_SEQ_VALID flag is set in ext_flags. Normal
+ * TKIP/CCMP operation is to set RX seq with SIOCSIWENCODEEXT and start
+ * TX seq from zero whenever key is changed. SIOCGIWENCODEEXT is normally
+ * used only by an Authenticator (AP or an IBSS station) to get the
+ * current TX sequence number. Using TX_SEQ_VALID for SIOCSIWENCODEEXT and
+ * RX_SEQ_VALID for SIOCGIWENCODEEXT are optional, but can be useful for
+ * debugging/testing.
+ */
+struct iw_encode_ext
+{
+ uint32_t ext_flags; /* IW_ENCODE_EXT_* */
+ uint8_t tx_seq[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */
+ uint8_t rx_seq[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */
+ struct sockaddr addr; /* ff:ff:ff:ff:ff:ff for broadcast/multicast
+ * (group) keys or unicast address for
+ * individual keys */
+ uint16_t alg; /* IW_ENCODE_ALG_* */
+ uint16_t key_len;
+ uint8_t key[1];
+};
+
+/* SIOCSIWMLME data */
+struct iw_mlme
+{
+ uint16_t cmd; /* IW_MLME_* */
+ uint16_t reason_code;
+ struct sockaddr addr;
+};
+
+/* SIOCSIWPMKSA data */
+#define IW_PMKSA_ADD 1
+#define IW_PMKSA_REMOVE 2
+#define IW_PMKSA_FLUSH 3
+
+#define IW_PMKID_LEN 16
+
+struct iw_pmksa
+{
+ uint32_t cmd; /* IW_PMKSA_* */
+ struct sockaddr bssid;
+ uint8_t pmkid[IW_PMKID_LEN];
+};
+
+/* IWEVMICHAELMICFAILURE data */
+struct iw_michaelmicfailure
+{
+ uint32_t flags;
+ struct sockaddr src_addr;
+ uint8_t tsc[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */
+};
+
+/* IWEVPMKIDCAND data */
+#define IW_PMKID_CAND_PREAUTH 0x00000001 /* RNS pre-authentication enabled */
+struct iw_pmkid_cand
+{
+ uint32_t flags; /* IW_PMKID_CAND_* */
+ uint32_t index; /* the smaller the index, the higher the
+ * priority */
+ struct sockaddr bssid;
+};
+
+/* ------------------------ WIRELESS STATS ------------------------ */
+/*
+ * Wireless statistics (used for /proc/net/wireless)
+ */
+struct iw_statistics
+{
+ uint16_t status; /* Status
+ * - device dependent for now */
+
+ struct iw_quality qual; /* Quality of the link
+ * (instant/mean/max) */
+ struct iw_discarded discard; /* Packet discarded counts */
+ struct iw_missed miss; /* Packet missed counts */
+};
+
+/* ------------------------ IOCTL REQUEST ------------------------ */
+/*
+ * This structure defines the payload of an ioctl, and is used
+ * below.
+ *
+ * Note that this structure should fit on the memory footprint
+ * of iwreq (which is the same as ifreq), which mean a max size of
+ * 16 octets = 128 bits. Warning, pointers might be 64 bits wide...
+ * You should check this when increasing the structures defined
+ * above in this file...
+ */
+union iwreq_data
+{
+ /* Config - generic */
+ char name[16];
+ /* Name : used to verify the presence of wireless extensions.
+ * Name of the protocol/provider... */
+
+ struct iw_point essid; /* Extended network name */
+ struct iw_param nwid; /* network id (or domain - the cell) */
+ struct iw_freq freq; /* frequency or channel :
+ * 0-1000 = channel
+ * > 1000 = frequency in Hz */
+
+ struct iw_param sens; /* signal level threshold */
+ struct iw_param bitrate; /* default bit rate */
+ struct iw_param txpower; /* default transmit power */
+ struct iw_param rts; /* RTS threshold threshold */
+ struct iw_param frag; /* Fragmentation threshold */
+ uint32_t mode; /* Operation mode */
+ struct iw_param retry; /* Retry limits & lifetime */
+
+ struct iw_point encoding; /* Encoding stuff : tokens */
+ struct iw_param power; /* PM duration/timeout */
+ struct iw_quality qual; /* Quality part of statistics */
+
+ struct sockaddr ap_addr; /* Access point address */
+ struct sockaddr addr; /* Destination address (hw/mac) */
+
+ struct iw_param param; /* Other small parameters */
+ struct iw_point data; /* Other large parameters */
+};
+
+/*
+ * The structure to exchange data for ioctl.
+ * This structure is the same as 'struct ifreq', but (re)defined for
+ * convenience...
+ * Do I need to remind you about structure size (32 octets) ?
+ */
+struct iwreq
+{
+ union
+ {
+ char ifrn_name[16]; /* if name, e.g. "eth0" */
+ } ifr_ifrn;
+
+ /* Data part (defined just above) */
+ union iwreq_data u;
+};
+
+/* -------------------------- IOCTL DATA -------------------------- */
+/*
+ * For those ioctl which want to exchange mode data that what could
+ * fit in the above structure...
+ */
+
+/*
+ * Range of parameters
+ */
+
+struct iw_range
+{
+ /* Informative stuff (to choose between different interface) */
+ uint32_t throughput; /* To give an idea... */
+ /* In theory this value should be the maximum benchmarked
+ * TCP/IP throughput, because with most of these devices the
+ * bit rate is meaningless (overhead an co) to estimate how
+ * fast the connection will go and pick the fastest one.
+ * I suggest people to play with Netperf or any benchmark...
+ */
+
+ /* NWID (or domain id) */
+ uint32_t min_nwid; /* Minimal NWID we are able to set */
+ uint32_t max_nwid; /* Maximal NWID we are able to set */
+
+ /* Old Frequency (backward compat - moved lower ) */
+ uint16_t old_num_channels;
+ uint8_t old_num_frequency;
+
+ /* Wireless event capability bitmasks */
+ uint32_t event_capa[6];
+
+ /* signal level threshold range */
+ int32_t sensitivity;
+
+ /* Quality of link & SNR stuff */
+ /* Quality range (link, level, noise)
+ * If the quality is absolute, it will be in the range [0 ; max_qual],
+ * if the quality is dBm, it will be in the range [max_qual ; 0].
+ * Don't forget that we use 8 bit arithmetics... */
+ struct iw_quality max_qual; /* Quality of the link */
+ /* This should contain the average/typical values of the quality
+ * indicator. This should be the threshold between a "good" and
+ * a "bad" link (example : monitor going from green to orange).
+ * Currently, user space apps like quality monitors don't have any
+ * way to calibrate the measurement. With this, they can split
+ * the range between 0 and max_qual in different quality level
+ * (using a geometric subdivision centered on the average).
+ * I expect that people doing the user space apps will feedback
+ * us on which value we need to put in each driver... */
+ struct iw_quality avg_qual; /* Quality of the link */
+
+ /* Rates */
+ uint8_t num_bitrates; /* Number of entries in the list */
+ int32_t bitrate[IW_MAX_BITRATES]; /* list, in bps */
+
+ /* RTS threshold */
+ int32_t min_rts; /* Minimal RTS threshold */
+ int32_t max_rts; /* Maximal RTS threshold */
+
+ /* Frag threshold */
+ int32_t min_frag; /* Minimal frag threshold */
+ int32_t max_frag; /* Maximal frag threshold */
+
+ /* Power Management duration & timeout */
+ int32_t min_pmp; /* Minimal PM period */
+ int32_t max_pmp; /* Maximal PM period */
+ int32_t min_pmt; /* Minimal PM timeout */
+ int32_t max_pmt; /* Maximal PM timeout */
+ uint16_t pmp_flags; /* How to decode max/min PM period */
+ uint16_t pmt_flags; /* How to decode max/min PM timeout */
+ uint16_t pm_capa; /* What PM options are supported */
+
+ /* Encoder stuff */
+ uint16_t encoding_size[IW_MAX_ENCODING_SIZES]; /* Different token sizes */
+ uint8_t num_encoding_sizes; /* Number of entry in the list */
+ uint8_t max_encoding_tokens; /* Max number of tokens */
+ /* For drivers that need a "login/passwd" form */
+ uint8_t encoding_login_index; /* token index for login token */
+
+ /* Transmit power */
+ uint16_t txpower_capa; /* What options are supported */
+ uint8_t num_txpower; /* Number of entries in the list */
+ int32_t txpower[IW_MAX_TXPOWER]; /* list, in bps */
+
+ /* Wireless Extension version info */
+ uint8_t we_version_compiled; /* Must be WIRELESS_EXT */
+ uint8_t we_version_source; /* Last update of source */
+
+ /* Retry limits and lifetime */
+ uint16_t retry_capa; /* What retry options are supported */
+ uint16_t retry_flags; /* How to decode max/min retry limit */
+ uint16_t r_time_flags; /* How to decode max/min retry life */
+ int32_t min_retry; /* Minimal number of retries */
+ int32_t max_retry; /* Maximal number of retries */
+ int32_t min_r_time; /* Minimal retry lifetime */
+ int32_t max_r_time; /* Maximal retry lifetime */
+
+ /* Frequency */
+ uint16_t num_channels; /* Number of channels [0; num - 1] */
+ uint8_t num_frequency; /* Number of entry in the list */
+ struct iw_freq freq[IW_MAX_FREQUENCIES]; /* list */
+ /* Note : this frequency list doesn't need to fit channel numbers,
+ * because each entry contain its channel index */
+
+ uint32_t enc_capa; /* IW_ENC_CAPA_* bit field */
+
+ /* More power management stuff */
+ int32_t min_pms; /* Minimal PM saving */
+ int32_t max_pms; /* Maximal PM saving */
+ uint16_t pms_flags; /* How to decode max/min PM saving */
+
+ /* All available modulations for driver (hw may support less) */
+ int32_t modul_capa; /* IW_MODUL_* bit field */
+
+ /* More bitrate stuff */
+ uint32_t bitrate_capa; /* Types of bitrates supported */
+};
+
+/*
+ * Private ioctl interface information
+ */
+
+struct iw_priv_args
+{
+ uint32_t cmd; /* Number of the ioctl to issue */
+ uint16_t set_args; /* Type and number of args */
+ uint16_t get_args; /* Type and number of args */
+ char name[16]; /* Name of the extension */
+};
+
+/* ----------------------- WIRELESS EVENTS ----------------------- */
+/*
+ * Wireless events are carried through the rtnetlink socket to user
+ * space. They are encapsulated in the IFLA_WIRELESS field of
+ * a RTM_NEWLINK message.
+ */
+
+/*
+ * A Wireless Event. Contains basically the same data as the ioctl...
+ */
+struct iw_event
+{
+ uint16_t len; /* Real lenght of this stuff */
+ uint16_t cmd; /* Wireless IOCTL */
+ union iwreq_data u; /* IOCTL fixed payload */
+};
+
+/* Size of the Event prefix (including padding and alignement junk) */
+#define IW_EV_LCP_LEN (sizeof(struct iw_event) - sizeof(union iwreq_data))
+/* Size of the various events */
+#define IW_EV_CHAR_LEN (IW_EV_LCP_LEN + IFNAMSIZ)
+#define IW_EV_UINT_LEN (IW_EV_LCP_LEN + sizeof(uint32_t))
+#define IW_EV_FREQ_LEN (IW_EV_LCP_LEN + sizeof(struct iw_freq))
+#define IW_EV_PARAM_LEN (IW_EV_LCP_LEN + sizeof(struct iw_param))
+#define IW_EV_ADDR_LEN (IW_EV_LCP_LEN + sizeof(struct sockaddr))
+#define IW_EV_QUAL_LEN (IW_EV_LCP_LEN + sizeof(struct iw_quality))
+
+/* iw_point events are special. First, the payload (extra data) come at
+ * the end of the event, so they are bigger than IW_EV_POINT_LEN. Second,
+ * we omit the pointer, so start at an offset. */
+#define IW_EV_POINT_OFF (((char *) &(((struct iw_point *) NULL)->length)) - \
+ (char *) NULL)
+#define IW_EV_POINT_LEN (IW_EV_LCP_LEN + sizeof(struct iw_point) - \
+ IW_EV_POINT_OFF)
+
+/* Size of the Event prefix when packed in stream */
+#define IW_EV_LCP_PK_LEN (4)
+/* Size of the various events when packed in stream */
+#define IW_EV_CHAR_PK_LEN (IW_EV_LCP_PK_LEN + IFNAMSIZ)
+#define IW_EV_UINT_PK_LEN (IW_EV_LCP_PK_LEN + sizeof(uint32_t))
+#define IW_EV_FREQ_PK_LEN (IW_EV_LCP_PK_LEN + sizeof(struct iw_freq))
+#define IW_EV_PARAM_PK_LEN (IW_EV_LCP_PK_LEN + sizeof(struct iw_param))
+#define IW_EV_ADDR_PK_LEN (IW_EV_LCP_PK_LEN + sizeof(struct sockaddr))
+#define IW_EV_QUAL_PK_LEN (IW_EV_LCP_PK_LEN + sizeof(struct iw_quality))
+#define IW_EV_POINT_PK_LEN (IW_EV_LCP_PK_LEN + 4)
+
+#endif /* _LINUX_WIRELESS_H */
diff --git a/package/network/utils/iwinfo/src/include/iwinfo/lua.h b/package/network/utils/iwinfo/src/include/iwinfo/lua.h
new file mode 100644
index 0000000..d976c0c
--- /dev/null
+++ b/package/network/utils/iwinfo/src/include/iwinfo/lua.h
@@ -0,0 +1,80 @@
+/*
+ * iwinfo - Wireless Information Library - Lua Headers
+ *
+ * Copyright (C) 2009 Jo-Philipp Wich <xm@subsignal.org>
+ *
+ * The iwinfo library is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * The iwinfo library 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 the iwinfo library. If not, see http://www.gnu.org/licenses/.
+ */
+
+#ifndef __IWINFO_LUALUB_H_
+#define __IWINFO_LUALIB_H_
+
+#include <lua.h>
+#include <lualib.h>
+#include <lauxlib.h>
+
+#include "iwinfo.h"
+#include "iwinfo/wext_scan.h"
+
+
+#define IWINFO_META "iwinfo"
+#define IWINFO_WEXT_META "iwinfo.wext"
+
+#ifdef USE_WL
+#define IWINFO_WL_META "iwinfo.wl"
+#endif
+
+#ifdef USE_MADWIFI
+#define IWINFO_MADWIFI_META "iwinfo.madwifi"
+#endif
+
+#ifdef USE_NL80211
+#define IWINFO_NL80211_META "iwinfo.nl80211"
+#endif
+
+
+#define LUA_REG(type,op) \
+ { #op, iwinfo_L_##type##_##op }
+
+#define LUA_WRAP_INT(type,op) \
+ static int iwinfo_L_##type##_##op(lua_State *L) \
+ { \
+ const char *ifname = luaL_checkstring(L, 1); \
+ int rv; \
+ if( !type##_get_##op(ifname, &rv) ) \
+ lua_pushnumber(L, rv); \
+ else \
+ lua_pushnil(L); \
+ return 1; \
+ }
+
+#define LUA_WRAP_STRING(type,op) \
+ static int iwinfo_L_##type##_##op(lua_State *L) \
+ { \
+ const char *ifname = luaL_checkstring(L, 1); \
+ char rv[IWINFO_BUFSIZE]; \
+ memset(rv, 0, IWINFO_BUFSIZE); \
+ if( !type##_get_##op(ifname, rv) ) \
+ lua_pushstring(L, rv); \
+ else \
+ lua_pushnil(L); \
+ return 1; \
+ }
+
+#define LUA_WRAP_STRUCT(type,op) \
+ static int iwinfo_L_##type##_##op(lua_State *L) \
+ { \
+ return iwinfo_L_##op(L, type##_get_##op); \
+ }
+
+#endif
diff --git a/package/network/utils/iwinfo/src/include/iwinfo/madwifi.h b/package/network/utils/iwinfo/src/include/iwinfo/madwifi.h
new file mode 100644
index 0000000..14d8135
--- /dev/null
+++ b/package/network/utils/iwinfo/src/include/iwinfo/madwifi.h
@@ -0,0 +1,83 @@
+/*
+ * iwinfo - Wireless Information Library - Madwifi Headers
+ *
+ * Copyright (C) 2009 Jo-Philipp Wich <xm@subsignal.org>
+ *
+ * The iwinfo library is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * The iwinfo library 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 the iwinfo library. If not, see http://www.gnu.org/licenses/.
+ */
+
+#ifndef __IWINFO_MADWIFI_H_
+#define __IWINFO_MADWIFI_H_
+
+#include <fcntl.h>
+
+#include "iwinfo.h"
+#include "iwinfo/utils.h"
+#include "iwinfo/api/madwifi.h"
+
+int madwifi_probe(const char *ifname);
+int madwifi_get_mode(const char *ifname, int *buf);
+int madwifi_get_ssid(const char *ifname, char *buf);
+int madwifi_get_bssid(const char *ifname, char *buf);
+int madwifi_get_country(const char *ifname, char *buf);
+int madwifi_get_channel(const char *ifname, int *buf);
+int madwifi_get_frequency(const char *ifname, int *buf);
+int madwifi_get_frequency_offset(const char *ifname, int *buf);
+int madwifi_get_txpower(const char *ifname, int *buf);
+int madwifi_get_txpower_offset(const char *ifname, int *buf);
+int madwifi_get_bitrate(const char *ifname, int *buf);
+int madwifi_get_signal(const char *ifname, int *buf);
+int madwifi_get_noise(const char *ifname, int *buf);
+int madwifi_get_quality(const char *ifname, int *buf);
+int madwifi_get_quality_max(const char *ifname, int *buf);
+int madwifi_get_encryption(const char *ifname, char *buf);
+int madwifi_get_assoclist(const char *ifname, char *buf, int *len);
+int madwifi_get_txpwrlist(const char *ifname, char *buf, int *len);
+int madwifi_get_scanlist(const char *ifname, char *buf, int *len);
+int madwifi_get_freqlist(const char *ifname, char *buf, int *len);
+int madwifi_get_countrylist(const char *ifname, char *buf, int *len);
+int madwifi_get_hwmodelist(const char *ifname, int *buf);
+int madwifi_get_mbssid_support(const char *ifname, int *buf);
+int madwifi_get_hardware_id(const char *ifname, char *buf);
+int madwifi_get_hardware_name(const char *ifname, char *buf);
+void madwifi_close(void);
+
+static const struct iwinfo_ops madwifi_ops = {
+ .channel = madwifi_get_channel,
+ .frequency = madwifi_get_frequency,
+ .frequency_offset = madwifi_get_frequency_offset,
+ .txpower = madwifi_get_txpower,
+ .txpower_offset = madwifi_get_txpower_offset,
+ .bitrate = madwifi_get_bitrate,
+ .signal = madwifi_get_signal,
+ .noise = madwifi_get_noise,
+ .quality = madwifi_get_quality,
+ .quality_max = madwifi_get_quality_max,
+ .mbssid_support = madwifi_get_mbssid_support,
+ .hwmodelist = madwifi_get_hwmodelist,
+ .mode = madwifi_get_mode,
+ .ssid = madwifi_get_ssid,
+ .bssid = madwifi_get_bssid,
+ .country = madwifi_get_country,
+ .hardware_id = madwifi_get_hardware_id,
+ .hardware_name = madwifi_get_hardware_name,
+ .encryption = madwifi_get_encryption,
+ .assoclist = madwifi_get_assoclist,
+ .txpwrlist = madwifi_get_txpwrlist,
+ .scanlist = madwifi_get_scanlist,
+ .freqlist = madwifi_get_freqlist,
+ .countrylist = madwifi_get_countrylist,
+ .close = madwifi_close
+};
+
+#endif
diff --git a/package/network/utils/iwinfo/src/include/iwinfo/nl80211.h b/package/network/utils/iwinfo/src/include/iwinfo/nl80211.h
new file mode 100644
index 0000000..2854514
--- /dev/null
+++ b/package/network/utils/iwinfo/src/include/iwinfo/nl80211.h
@@ -0,0 +1,125 @@
+/*
+ * iwinfo - Wireless Information Library - NL80211 Headers
+ *
+ * Copyright (C) 2010 Jo-Philipp Wich <xm@subsignal.org>
+ *
+ * The iwinfo library is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * The iwinfo library 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 the iwinfo library. If not, see http://www.gnu.org/licenses/.
+ */
+
+#ifndef __IWINFO_NL80211_H_
+#define __IWINFO_NL80211_H_
+
+#include <errno.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <string.h>
+#include <dirent.h>
+#include <signal.h>
+#include <sys/un.h>
+#include <netlink/netlink.h>
+#include <netlink/genl/genl.h>
+#include <netlink/genl/family.h>
+#include <netlink/genl/ctrl.h>
+
+#include "iwinfo.h"
+#include "iwinfo/utils.h"
+#include "iwinfo/api/nl80211.h"
+
+struct nl80211_state {
+ struct nl_sock *nl_sock;
+ struct nl_cache *nl_cache;
+ struct genl_family *nl80211;
+ struct genl_family *nlctrl;
+};
+
+struct nl80211_msg_conveyor {
+ struct nl_msg *msg;
+ struct nl_cb *cb;
+};
+
+struct nl80211_event_conveyor {
+ int wait;
+ int recv;
+};
+
+struct nl80211_group_conveyor {
+ const char *name;
+ int id;
+};
+
+struct nl80211_rssi_rate {
+ int16_t rate;
+ int8_t rssi;
+};
+
+struct nl80211_array_buf {
+ void *buf;
+ int count;
+};
+
+int nl80211_probe(const char *ifname);
+int nl80211_get_mode(const char *ifname, int *buf);
+int nl80211_get_ssid(const char *ifname, char *buf);
+int nl80211_get_bssid(const char *ifname, char *buf);
+int nl80211_get_country(const char *ifname, char *buf);
+int nl80211_get_channel(const char *ifname, int *buf);
+int nl80211_get_frequency(const char *ifname, int *buf);
+int nl80211_get_frequency_offset(const char *ifname, int *buf);
+int nl80211_get_txpower(const char *ifname, int *buf);
+int nl80211_get_txpower_offset(const char *ifname, int *buf);
+int nl80211_get_bitrate(const char *ifname, int *buf);
+int nl80211_get_signal(const char *ifname, int *buf);
+int nl80211_get_noise(const char *ifname, int *buf);
+int nl80211_get_quality(const char *ifname, int *buf);
+int nl80211_get_quality_max(const char *ifname, int *buf);
+int nl80211_get_encryption(const char *ifname, char *buf);
+int nl80211_get_assoclist(const char *ifname, char *buf, int *len);
+int nl80211_get_txpwrlist(const char *ifname, char *buf, int *len);
+int nl80211_get_scanlist(const char *ifname, char *buf, int *len);
+int nl80211_get_freqlist(const char *ifname, char *buf, int *len);
+int nl80211_get_countrylist(const char *ifname, char *buf, int *len);
+int nl80211_get_hwmodelist(const char *ifname, int *buf);
+int nl80211_get_mbssid_support(const char *ifname, int *buf);
+int nl80211_get_hardware_id(const char *ifname, char *buf);
+int nl80211_get_hardware_name(const char *ifname, char *buf);
+void nl80211_close(void);
+
+static const struct iwinfo_ops nl80211_ops = {
+ .channel = nl80211_get_channel,
+ .frequency = nl80211_get_frequency,
+ .frequency_offset = nl80211_get_frequency_offset,
+ .txpower = nl80211_get_txpower,
+ .txpower_offset = nl80211_get_txpower_offset,
+ .bitrate = nl80211_get_bitrate,
+ .signal = nl80211_get_signal,
+ .noise = nl80211_get_noise,
+ .quality = nl80211_get_quality,
+ .quality_max = nl80211_get_quality_max,
+ .mbssid_support = nl80211_get_mbssid_support,
+ .hwmodelist = nl80211_get_hwmodelist,
+ .mode = nl80211_get_mode,
+ .ssid = nl80211_get_ssid,
+ .bssid = nl80211_get_bssid,
+ .country = nl80211_get_country,
+ .hardware_id = nl80211_get_hardware_id,
+ .hardware_name = nl80211_get_hardware_name,
+ .encryption = nl80211_get_encryption,
+ .assoclist = nl80211_get_assoclist,
+ .txpwrlist = nl80211_get_txpwrlist,
+ .scanlist = nl80211_get_scanlist,
+ .freqlist = nl80211_get_freqlist,
+ .countrylist = nl80211_get_countrylist,
+ .close = nl80211_close
+};
+
+#endif
diff --git a/package/network/utils/iwinfo/src/include/iwinfo/utils.h b/package/network/utils/iwinfo/src/include/iwinfo/utils.h
new file mode 100644
index 0000000..d58ec5f
--- /dev/null
+++ b/package/network/utils/iwinfo/src/include/iwinfo/utils.h
@@ -0,0 +1,47 @@
+/*
+ * iwinfo - Wireless Information Library - Utility Headers
+ *
+ * Copyright (C) 2010 Jo-Philipp Wich <xm@subsignal.org>
+ *
+ * The iwinfo library is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * The iwinfo library 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 the iwinfo library. If not, see http://www.gnu.org/licenses/.
+ */
+
+#ifndef __IWINFO_UTILS_H_
+#define __IWINFO_UTILS_H_
+
+#include <sys/socket.h>
+#include <net/if.h>
+
+#include "iwinfo.h"
+
+#define LOG10_MAGIC 1.25892541179
+
+int iwinfo_ioctl(int cmd, void *ifr);
+
+int iwinfo_dbm2mw(int in);
+int iwinfo_mw2dbm(int in);
+
+int iwinfo_ifup(const char *ifname);
+int iwinfo_ifdown(const char *ifname);
+int iwinfo_ifmac(const char *ifname);
+
+void iwinfo_close(void);
+
+struct iwinfo_hardware_entry * iwinfo_hardware(struct iwinfo_hardware_id *id);
+
+int iwinfo_hardware_id_from_mtd(struct iwinfo_hardware_id *id);
+
+void iwinfo_parse_rsn(struct iwinfo_crypto_entry *c, uint8_t *data, uint8_t len,
+ uint8_t defcipher, uint8_t defauth);
+
+#endif
diff --git a/package/network/utils/iwinfo/src/include/iwinfo/wext.h b/package/network/utils/iwinfo/src/include/iwinfo/wext.h
new file mode 100644
index 0000000..68b596e
--- /dev/null
+++ b/package/network/utils/iwinfo/src/include/iwinfo/wext.h
@@ -0,0 +1,84 @@
+/*
+ * iwinfo - Wireless Information Library - Linux Wireless Extension Headers
+ *
+ * Copyright (C) 2009-2010 Jo-Philipp Wich <xm@subsignal.org>
+ *
+ * The iwinfo library is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * The iwinfo library 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 the iwinfo library. If not, see http://www.gnu.org/licenses/.
+ */
+
+#ifndef __IWINFO_WEXT_H_
+#define __IWINFO_WEXT_H_
+
+#include <fcntl.h>
+
+#include "iwinfo.h"
+#include "iwinfo/utils.h"
+#include "iwinfo/api/wext.h"
+
+
+int wext_probe(const char *ifname);
+int wext_get_mode(const char *ifname, int *buf);
+int wext_get_ssid(const char *ifname, char *buf);
+int wext_get_bssid(const char *ifname, char *buf);
+int wext_get_country(const char *ifname, char *buf);
+int wext_get_channel(const char *ifname, int *buf);
+int wext_get_frequency(const char *ifname, int *buf);
+int wext_get_frequency_offset(const char *ifname, int *buf);
+int wext_get_txpower(const char *ifname, int *buf);
+int wext_get_txpower_offset(const char *ifname, int *buf);
+int wext_get_bitrate(const char *ifname, int *buf);
+int wext_get_signal(const char *ifname, int *buf);
+int wext_get_noise(const char *ifname, int *buf);
+int wext_get_quality(const char *ifname, int *buf);
+int wext_get_quality_max(const char *ifname, int *buf);
+int wext_get_encryption(const char *ifname, char *buf);
+int wext_get_assoclist(const char *ifname, char *buf, int *len);
+int wext_get_txpwrlist(const char *ifname, char *buf, int *len);
+int wext_get_scanlist(const char *ifname, char *buf, int *len);
+int wext_get_freqlist(const char *ifname, char *buf, int *len);
+int wext_get_countrylist(const char *ifname, char *buf, int *len);
+int wext_get_hwmodelist(const char *ifname, int *buf);
+int wext_get_mbssid_support(const char *ifname, int *buf);
+int wext_get_hardware_id(const char *ifname, char *buf);
+int wext_get_hardware_name(const char *ifname, char *buf);
+void wext_close(void);
+
+static const struct iwinfo_ops wext_ops = {
+ .channel = wext_get_channel,
+ .frequency = wext_get_frequency,
+ .frequency_offset = wext_get_frequency_offset,
+ .txpower = wext_get_txpower,
+ .txpower_offset = wext_get_txpower_offset,
+ .bitrate = wext_get_bitrate,
+ .signal = wext_get_signal,
+ .noise = wext_get_noise,
+ .quality = wext_get_quality,
+ .quality_max = wext_get_quality_max,
+ .mbssid_support = wext_get_mbssid_support,
+ .hwmodelist = wext_get_hwmodelist,
+ .mode = wext_get_mode,
+ .ssid = wext_get_ssid,
+ .bssid = wext_get_bssid,
+ .country = wext_get_country,
+ .hardware_id = wext_get_hardware_id,
+ .hardware_name = wext_get_hardware_name,
+ .encryption = wext_get_encryption,
+ .assoclist = wext_get_assoclist,
+ .txpwrlist = wext_get_txpwrlist,
+ .scanlist = wext_get_scanlist,
+ .freqlist = wext_get_freqlist,
+ .countrylist = wext_get_countrylist,
+ .close = wext_close
+};
+
+#endif
diff --git a/package/network/utils/iwinfo/src/include/iwinfo/wext_scan.h b/package/network/utils/iwinfo/src/include/iwinfo/wext_scan.h
new file mode 100644
index 0000000..085c653
--- /dev/null
+++ b/package/network/utils/iwinfo/src/include/iwinfo/wext_scan.h
@@ -0,0 +1,380 @@
+/*
+ * iwinfo - Wireless Information Library - Linux Wireless Extension Headers
+ *
+ * Copyright (C) 2009-2010 Jo-Philipp Wich <xm@subsignal.org>
+ *
+ * The iwinfo library is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * The iwinfo library 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 the iwinfo library. If not, see http://www.gnu.org/licenses/.
+ */
+
+#ifndef __IWINFO_WEXT_SCAN_H_
+#define __IWINFO_WEXT_SCAN_H_
+
+#include <fcntl.h>
+
+#include "iwinfo.h"
+#include "iwinfo/utils.h"
+#include "iwinfo/api/wext.h"
+
+
+typedef struct stream_descr
+{
+ char * end; /* End of the stream */
+ char * current; /* Current event in stream of events */
+ char * value; /* Current value in event */
+} stream_descr;
+
+/*
+ * Describe how a standard IOCTL looks like.
+ */
+struct iw_ioctl_description
+{
+ uint8_t header_type; /* NULL, iw_point or other */
+ uint8_t token_type; /* Future */
+ uint16_t token_size; /* Granularity of payload */
+ uint16_t min_tokens; /* Min acceptable token number */
+ uint16_t max_tokens; /* Max acceptable token number */
+ uint32_t flags; /* Special handling of the request */
+};
+
+/* Type of headers we know about (basically union iwreq_data) */
+#define IW_HEADER_TYPE_NULL 0 /* Not available */
+#define IW_HEADER_TYPE_CHAR 2 /* char [IFNAMSIZ] */
+#define IW_HEADER_TYPE_UINT 4 /* __u32 */
+#define IW_HEADER_TYPE_FREQ 5 /* struct iw_freq */
+#define IW_HEADER_TYPE_ADDR 6 /* struct sockaddr */
+#define IW_HEADER_TYPE_POINT 8 /* struct iw_point */
+#define IW_HEADER_TYPE_PARAM 9 /* struct iw_param */
+#define IW_HEADER_TYPE_QUAL 10 /* struct iw_quality */
+
+/* Handling flags */
+/* Most are not implemented. I just use them as a reminder of some
+ * cool features we might need one day ;-) */
+#define IW_DESCR_FLAG_NONE 0x0000 /* Obvious */
+/* Wrapper level flags */
+#define IW_DESCR_FLAG_DUMP 0x0001 /* Not part of the dump command */
+#define IW_DESCR_FLAG_EVENT 0x0002 /* Generate an event on SET */
+#define IW_DESCR_FLAG_RESTRICT 0x0004 /* GET : request is ROOT only */
+ /* SET : Omit payload from generated iwevent */
+#define IW_DESCR_FLAG_NOMAX 0x0008 /* GET : no limit on request size */
+/* Driver level flags */
+#define IW_DESCR_FLAG_WAIT 0x0100 /* Wait for driver event */
+
+
+/*
+ * Meta-data about all the standard Wireless Extension request we
+ * know about.
+ */
+static const struct iw_ioctl_description standard_ioctl_descr[] = {
+ [SIOCSIWCOMMIT - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_NULL,
+ },
+ [SIOCGIWNAME - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_CHAR,
+ .flags = IW_DESCR_FLAG_DUMP,
+ },
+ [SIOCSIWNWID - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ .flags = IW_DESCR_FLAG_EVENT,
+ },
+ [SIOCGIWNWID - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ .flags = IW_DESCR_FLAG_DUMP,
+ },
+ [SIOCSIWFREQ - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_FREQ,
+ .flags = IW_DESCR_FLAG_EVENT,
+ },
+ [SIOCGIWFREQ - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_FREQ,
+ .flags = IW_DESCR_FLAG_DUMP,
+ },
+ [SIOCSIWMODE - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_UINT,
+ .flags = IW_DESCR_FLAG_EVENT,
+ },
+ [SIOCGIWMODE - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_UINT,
+ .flags = IW_DESCR_FLAG_DUMP,
+ },
+ [SIOCSIWSENS - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ },
+ [SIOCGIWSENS - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ },
+ [SIOCSIWRANGE - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_NULL,
+ },
+ [SIOCGIWRANGE - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .max_tokens = sizeof(struct iw_range),
+ .flags = IW_DESCR_FLAG_DUMP,
+ },
+ [SIOCSIWPRIV - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_NULL,
+ },
+ [SIOCGIWPRIV - SIOCIWFIRST] = { /* (handled directly by us) */
+ .header_type = IW_HEADER_TYPE_NULL,
+ },
+ [SIOCSIWSTATS - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_NULL,
+ },
+ [SIOCGIWSTATS - SIOCIWFIRST] = { /* (handled directly by us) */
+ .header_type = IW_HEADER_TYPE_NULL,
+ .flags = IW_DESCR_FLAG_DUMP,
+ },
+ [SIOCSIWSPY - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = sizeof(struct sockaddr),
+ .max_tokens = IW_MAX_SPY,
+ },
+ [SIOCGIWSPY - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = sizeof(struct sockaddr) +
+ sizeof(struct iw_quality),
+ .max_tokens = IW_MAX_SPY,
+ },
+ [SIOCSIWTHRSPY - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = sizeof(struct iw_thrspy),
+ .min_tokens = 1,
+ .max_tokens = 1,
+ },
+ [SIOCGIWTHRSPY - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = sizeof(struct iw_thrspy),
+ .min_tokens = 1,
+ .max_tokens = 1,
+ },
+ [SIOCSIWAP - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_ADDR,
+ },
+ [SIOCGIWAP - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_ADDR,
+ .flags = IW_DESCR_FLAG_DUMP,
+ },
+ [SIOCSIWMLME - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .min_tokens = sizeof(struct iw_mlme),
+ .max_tokens = sizeof(struct iw_mlme),
+ },
+ [SIOCGIWAPLIST - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = sizeof(struct sockaddr) +
+ sizeof(struct iw_quality),
+ .max_tokens = IW_MAX_AP,
+ .flags = IW_DESCR_FLAG_NOMAX,
+ },
+ [SIOCSIWSCAN - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .min_tokens = 0,
+ .max_tokens = sizeof(struct iw_scan_req),
+ },
+ [SIOCGIWSCAN - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .max_tokens = IW_SCAN_MAX_DATA,
+ .flags = IW_DESCR_FLAG_NOMAX,
+ },
+ [SIOCSIWESSID - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .max_tokens = IW_ESSID_MAX_SIZE + 1,
+ .flags = IW_DESCR_FLAG_EVENT,
+ },
+ [SIOCGIWESSID - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .max_tokens = IW_ESSID_MAX_SIZE + 1,
+ .flags = IW_DESCR_FLAG_DUMP,
+ },
+ [SIOCSIWNICKN - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .max_tokens = IW_ESSID_MAX_SIZE + 1,
+ },
+ [SIOCGIWNICKN - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .max_tokens = IW_ESSID_MAX_SIZE + 1,
+ },
+ [SIOCSIWRATE - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ },
+ [SIOCGIWRATE - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ },
+ [SIOCSIWRTS - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ },
+ [SIOCGIWRTS - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ },
+ [SIOCSIWFRAG - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ },
+ [SIOCGIWFRAG - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ },
+ [SIOCSIWTXPOW - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ },
+ [SIOCGIWTXPOW - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ },
+ [SIOCSIWRETRY - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ },
+ [SIOCGIWRETRY - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ },
+ [SIOCSIWENCODE - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .max_tokens = IW_ENCODING_TOKEN_MAX,
+ .flags = IW_DESCR_FLAG_EVENT | IW_DESCR_FLAG_RESTRICT,
+ },
+ [SIOCGIWENCODE - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .max_tokens = IW_ENCODING_TOKEN_MAX,
+ .flags = IW_DESCR_FLAG_DUMP | IW_DESCR_FLAG_RESTRICT,
+ },
+ [SIOCSIWPOWER - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ },
+ [SIOCGIWPOWER - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ },
+ [SIOCSIWMODUL - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ },
+ [SIOCGIWMODUL - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ },
+ [SIOCSIWGENIE - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .max_tokens = IW_GENERIC_IE_MAX,
+ },
+ [SIOCGIWGENIE - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .max_tokens = IW_GENERIC_IE_MAX,
+ },
+ [SIOCSIWAUTH - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ },
+ [SIOCGIWAUTH - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ },
+ [SIOCSIWENCODEEXT - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .min_tokens = sizeof(struct iw_encode_ext),
+ .max_tokens = sizeof(struct iw_encode_ext) +
+ IW_ENCODING_TOKEN_MAX,
+ },
+ [SIOCGIWENCODEEXT - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .min_tokens = sizeof(struct iw_encode_ext),
+ .max_tokens = sizeof(struct iw_encode_ext) +
+ IW_ENCODING_TOKEN_MAX,
+ },
+ [SIOCSIWPMKSA - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .min_tokens = sizeof(struct iw_pmksa),
+ .max_tokens = sizeof(struct iw_pmksa),
+ },
+};
+
+/*
+ * Meta-data about all the additional standard Wireless Extension events
+ * we know about.
+ */
+static const struct iw_ioctl_description standard_event_descr[] = {
+ [IWEVTXDROP - IWEVFIRST] = {
+ .header_type = IW_HEADER_TYPE_ADDR,
+ },
+ [IWEVQUAL - IWEVFIRST] = {
+ .header_type = IW_HEADER_TYPE_QUAL,
+ },
+ [IWEVCUSTOM - IWEVFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .max_tokens = IW_CUSTOM_MAX,
+ },
+ [IWEVREGISTERED - IWEVFIRST] = {
+ .header_type = IW_HEADER_TYPE_ADDR,
+ },
+ [IWEVEXPIRED - IWEVFIRST] = {
+ .header_type = IW_HEADER_TYPE_ADDR,
+ },
+ [IWEVGENIE - IWEVFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .max_tokens = IW_GENERIC_IE_MAX,
+ },
+ [IWEVMICHAELMICFAILURE - IWEVFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .max_tokens = sizeof(struct iw_michaelmicfailure),
+ },
+ [IWEVASSOCREQIE - IWEVFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .max_tokens = IW_GENERIC_IE_MAX,
+ },
+ [IWEVASSOCRESPIE - IWEVFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .max_tokens = IW_GENERIC_IE_MAX,
+ },
+ [IWEVPMKIDCAND - IWEVFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .max_tokens = sizeof(struct iw_pmkid_cand),
+ },
+};
+
+/* Size (in bytes) of various events */
+static const int event_type_size[] = {
+ IW_EV_LCP_PK_LEN, /* IW_HEADER_TYPE_NULL */
+ 0,
+ IW_EV_CHAR_PK_LEN, /* IW_HEADER_TYPE_CHAR */
+ 0,
+ IW_EV_UINT_PK_LEN, /* IW_HEADER_TYPE_UINT */
+ IW_EV_FREQ_PK_LEN, /* IW_HEADER_TYPE_FREQ */
+ IW_EV_ADDR_PK_LEN, /* IW_HEADER_TYPE_ADDR */
+ 0,
+ IW_EV_POINT_PK_LEN, /* Without variable payload */
+ IW_EV_PARAM_PK_LEN, /* IW_HEADER_TYPE_PARAM */
+ IW_EV_QUAL_PK_LEN, /* IW_HEADER_TYPE_QUAL */
+};
+
+
+static const unsigned int standard_ioctl_num =
+ (sizeof(standard_ioctl_descr) / sizeof(struct iw_ioctl_description));
+
+static const unsigned int standard_event_num =
+ (sizeof(standard_event_descr) / sizeof(struct iw_ioctl_description));
+
+#define IW_IE_CYPHER_NUM 8
+#define IW_IE_KEY_MGMT_NUM 3
+
+#endif
diff --git a/package/network/utils/iwinfo/src/include/iwinfo/wl.h b/package/network/utils/iwinfo/src/include/iwinfo/wl.h
new file mode 100644
index 0000000..db37e37
--- /dev/null
+++ b/package/network/utils/iwinfo/src/include/iwinfo/wl.h
@@ -0,0 +1,84 @@
+/*
+ * iwinfo - Wireless Information Library - Broadcom wl.o Headers
+ *
+ * Copyright (C) 2009-2010 Jo-Philipp Wich <xm@subsignal.org>
+ *
+ * The iwinfo library is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * The iwinfo library 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 the iwinfo library. If not, see http://www.gnu.org/licenses/.
+ */
+
+#ifndef __IWINFO_WL_H_
+#define __IWINFO_WL_H_
+
+#include <fcntl.h>
+
+#include "iwinfo.h"
+#include "iwinfo/utils.h"
+#include "iwinfo/api/broadcom.h"
+
+int wl_probe(const char *ifname);
+int wl_get_mode(const char *ifname, int *buf);
+int wl_get_ssid(const char *ifname, char *buf);
+int wl_get_bssid(const char *ifname, char *buf);
+int wl_get_country(const char *ifname, char *buf);
+int wl_get_channel(const char *ifname, int *buf);
+int wl_get_frequency(const char *ifname, int *buf);
+int wl_get_frequency_offset(const char *ifname, int *buf);
+int wl_get_txpower(const char *ifname, int *buf);
+int wl_get_txpower_offset(const char *ifname, int *buf);
+int wl_get_bitrate(const char *ifname, int *buf);
+int wl_get_signal(const char *ifname, int *buf);
+int wl_get_noise(const char *ifname, int *buf);
+int wl_get_quality(const char *ifname, int *buf);
+int wl_get_quality_max(const char *ifname, int *buf);
+int wl_get_enctype(const char *ifname, char *buf);
+int wl_get_encryption(const char *ifname, char *buf);
+int wl_get_assoclist(const char *ifname, char *buf, int *len);
+int wl_get_txpwrlist(const char *ifname, char *buf, int *len);
+int wl_get_scanlist(const char *ifname, char *buf, int *len);
+int wl_get_freqlist(const char *ifname, char *buf, int *len);
+int wl_get_countrylist(const char *ifname, char *buf, int *len);
+int wl_get_hwmodelist(const char *ifname, int *buf);
+int wl_get_mbssid_support(const char *ifname, int *buf);
+int wl_get_hardware_id(const char *ifname, char *buf);
+int wl_get_hardware_name(const char *ifname, char *buf);
+void wl_close(void);
+
+static const struct iwinfo_ops wl_ops = {
+ .channel = wl_get_channel,
+ .frequency = wl_get_frequency,
+ .frequency_offset = wl_get_frequency_offset,
+ .txpower = wl_get_txpower,
+ .txpower_offset = wl_get_txpower_offset,
+ .bitrate = wl_get_bitrate,
+ .signal = wl_get_signal,
+ .noise = wl_get_noise,
+ .quality = wl_get_quality,
+ .quality_max = wl_get_quality_max,
+ .mbssid_support = wl_get_mbssid_support,
+ .hwmodelist = wl_get_hwmodelist,
+ .mode = wl_get_mode,
+ .ssid = wl_get_ssid,
+ .bssid = wl_get_bssid,
+ .country = wl_get_country,
+ .hardware_id = wl_get_hardware_id,
+ .hardware_name = wl_get_hardware_name,
+ .encryption = wl_get_encryption,
+ .assoclist = wl_get_assoclist,
+ .txpwrlist = wl_get_txpwrlist,
+ .scanlist = wl_get_scanlist,
+ .freqlist = wl_get_freqlist,
+ .countrylist = wl_get_countrylist,
+ .close = wl_close
+};
+
+#endif
diff --git a/package/network/utils/iwinfo/src/iwinfo_cli.c b/package/network/utils/iwinfo/src/iwinfo_cli.c
new file mode 100644
index 0000000..7ec5aef
--- /dev/null
+++ b/package/network/utils/iwinfo/src/iwinfo_cli.c
@@ -0,0 +1,800 @@
+/*
+ * iwinfo - Wireless Information Library - Command line frontend
+ *
+ * Copyright (C) 2011 Jo-Philipp Wich <xm@subsignal.org>
+ *
+ * The iwinfo library is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * The iwinfo library 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 the iwinfo library. If not, see http://www.gnu.org/licenses/.
+ */
+
+#include <stdio.h>
+
+#include "iwinfo.h"
+
+
+static char * format_bssid(unsigned char *mac)
+{
+ static char buf[18];
+
+ snprintf(buf, sizeof(buf), "%02X:%02X:%02X:%02X:%02X:%02X",
+ mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
+
+ return buf;
+}
+
+static char * format_ssid(char *ssid)
+{
+ static char buf[IWINFO_ESSID_MAX_SIZE+3];
+
+ if (ssid && ssid[0])
+ snprintf(buf, sizeof(buf), "\"%s\"", ssid);
+ else
+ snprintf(buf, sizeof(buf), "unknown");
+
+ return buf;
+}
+
+static char * format_channel(int ch)
+{
+ static char buf[8];
+
+ if (ch <= 0)
+ snprintf(buf, sizeof(buf), "unknown");
+ else
+ snprintf(buf, sizeof(buf), "%d", ch);
+
+ return buf;
+}
+
+static char * format_frequency(int freq)
+{
+ static char buf[10];
+
+ if (freq <= 0)
+ snprintf(buf, sizeof(buf), "unknown");
+ else
+ snprintf(buf, sizeof(buf), "%.3f GHz", ((float)freq / 1000.0));
+
+ return buf;
+}
+
+static char * format_txpower(int pwr)
+{
+ static char buf[10];
+
+ if (pwr < 0)
+ snprintf(buf, sizeof(buf), "unknown");
+ else
+ snprintf(buf, sizeof(buf), "%d dBm", pwr);
+
+ return buf;
+}
+
+static char * format_quality(int qual)
+{
+ static char buf[8];
+
+ if (qual < 0)
+ snprintf(buf, sizeof(buf), "unknown");
+ else
+ snprintf(buf, sizeof(buf), "%d", qual);
+
+ return buf;
+}
+
+static char * format_quality_max(int qmax)
+{
+ static char buf[8];
+
+ if (qmax < 0)
+ snprintf(buf, sizeof(buf), "unknown");
+ else
+ snprintf(buf, sizeof(buf), "%d", qmax);
+
+ return buf;
+}
+
+static char * format_signal(int sig)
+{
+ static char buf[10];
+
+ if (!sig)
+ snprintf(buf, sizeof(buf), "unknown");
+ else
+ snprintf(buf, sizeof(buf), "%d dBm", sig);
+
+ return buf;
+}
+
+static char * format_noise(int noise)
+{
+ static char buf[10];
+
+ if (!noise)
+ snprintf(buf, sizeof(buf), "unknown");
+ else
+ snprintf(buf, sizeof(buf), "%d dBm", noise);
+
+ return buf;
+}
+
+static char * format_rate(int rate)
+{
+ static char buf[14];
+
+ if (rate <= 0)
+ snprintf(buf, sizeof(buf), "unknown");
+ else
+ snprintf(buf, sizeof(buf), "%d.%d MBit/s",
+ rate / 1000, (rate % 1000) / 100);
+
+ return buf;
+}
+
+static char * format_enc_ciphers(int ciphers)
+{
+ static char str[128] = { 0 };
+ char *pos = str;
+
+ if (ciphers & IWINFO_CIPHER_WEP40)
+ pos += sprintf(pos, "WEP-40, ");
+
+ if (ciphers & IWINFO_CIPHER_WEP104)
+ pos += sprintf(pos, "WEP-104, ");
+
+ if (ciphers & IWINFO_CIPHER_TKIP)
+ pos += sprintf(pos, "TKIP, ");
+
+ if (ciphers & IWINFO_CIPHER_CCMP)
+ pos += sprintf(pos, "CCMP, ");
+
+ if (ciphers & IWINFO_CIPHER_WRAP)
+ pos += sprintf(pos, "WRAP, ");
+
+ if (ciphers & IWINFO_CIPHER_AESOCB)
+ pos += sprintf(pos, "AES-OCB, ");
+
+ if (ciphers & IWINFO_CIPHER_CKIP)
+ pos += sprintf(pos, "CKIP, ");
+
+ if (!ciphers || (ciphers & IWINFO_CIPHER_NONE))
+ pos += sprintf(pos, "NONE, ");
+
+ *(pos - 2) = 0;
+
+ return str;
+}
+
+static char * format_enc_suites(int suites)
+{
+ static char str[64] = { 0 };
+ char *pos = str;
+
+ if (suites & IWINFO_KMGMT_PSK)
+ pos += sprintf(pos, "PSK/");
+
+ if (suites & IWINFO_KMGMT_8021x)
+ pos += sprintf(pos, "802.1X/");
+
+ if (!suites || (suites & IWINFO_KMGMT_NONE))
+ pos += sprintf(pos, "NONE/");
+
+ *(pos - 1) = 0;
+
+ return str;
+}
+
+static char * format_encryption(struct iwinfo_crypto_entry *c)
+{
+ static char buf[512];
+
+ if (!c)
+ {
+ snprintf(buf, sizeof(buf), "unknown");
+ }
+ else if (c->enabled)
+ {
+ /* WEP */
+ if (c->auth_algs && !c->wpa_version)
+ {
+ if ((c->auth_algs & IWINFO_AUTH_OPEN) &&
+ (c->auth_algs & IWINFO_AUTH_SHARED))
+ {
+ snprintf(buf, sizeof(buf), "WEP Open/Shared (%s)",
+ format_enc_ciphers(c->pair_ciphers));
+ }
+ else if (c->auth_algs & IWINFO_AUTH_OPEN)
+ {
+ snprintf(buf, sizeof(buf), "WEP Open System (%s)",
+ format_enc_ciphers(c->pair_ciphers));
+ }
+ else if (c->auth_algs & IWINFO_AUTH_SHARED)
+ {
+ snprintf(buf, sizeof(buf), "WEP Shared Auth (%s)",
+ format_enc_ciphers(c->pair_ciphers));
+ }
+ }
+
+ /* WPA */
+ else if (c->wpa_version)
+ {
+ switch (c->wpa_version) {
+ case 3:
+ snprintf(buf, sizeof(buf), "mixed WPA/WPA2 %s (%s)",
+ format_enc_suites(c->auth_suites),
+ format_enc_ciphers(c->pair_ciphers | c->group_ciphers));
+ break;
+
+ case 2:
+ snprintf(buf, sizeof(buf), "WPA2 %s (%s)",
+ format_enc_suites(c->auth_suites),
+ format_enc_ciphers(c->pair_ciphers | c->group_ciphers));
+ break;
+
+ case 1:
+ snprintf(buf, sizeof(buf), "WPA %s (%s)",
+ format_enc_suites(c->auth_suites),
+ format_enc_ciphers(c->pair_ciphers | c->group_ciphers));
+ break;
+ }
+ }
+ else
+ {
+ snprintf(buf, sizeof(buf), "none");
+ }
+ }
+ else
+ {
+ snprintf(buf, sizeof(buf), "none");
+ }
+
+ return buf;
+}
+
+static char * format_hwmodes(int modes)
+{
+ static char buf[12];
+
+ if (modes <= 0)
+ snprintf(buf, sizeof(buf), "unknown");
+ else
+ snprintf(buf, sizeof(buf), "802.11%s%s%s%s",
+ (modes & IWINFO_80211_A) ? "a" : "",
+ (modes & IWINFO_80211_B) ? "b" : "",
+ (modes & IWINFO_80211_G) ? "g" : "",
+ (modes & IWINFO_80211_N) ? "n" : "");
+
+ return buf;
+}
+
+static char * format_assocrate(struct iwinfo_rate_entry *r)
+{
+ static char buf[40];
+ char *p = buf;
+ int l = sizeof(buf);
+
+ if (r->rate <= 0)
+ {
+ snprintf(buf, sizeof(buf), "unknown");
+ }
+ else
+ {
+ p += snprintf(p, l, "%s", format_rate(r->rate));
+ l = sizeof(buf) - (p - buf);
+
+ if (r->mcs >= 0)
+ {
+ p += snprintf(p, l, ", MCS %d, %dMHz", r->mcs, 20 + r->is_40mhz*20);
+ l = sizeof(buf) - (p - buf);
+
+ if (r->is_short_gi)
+ p += snprintf(p, l, ", short GI");
+ }
+ }
+
+ return buf;
+}
+
+
+static const char * print_type(const struct iwinfo_ops *iw, const char *ifname)
+{
+ const char *type = iwinfo_type(ifname);
+ return type ? type : "unknown";
+}
+
+static char * print_hardware_id(const struct iwinfo_ops *iw, const char *ifname)
+{
+ static char buf[20];
+ struct iwinfo_hardware_id ids;
+
+ if (!iw->hardware_id(ifname, (char *)&ids))
+ {
+ snprintf(buf, sizeof(buf), "%04X:%04X %04X:%04X",
+ ids.vendor_id, ids.device_id,
+ ids.subsystem_vendor_id, ids.subsystem_device_id);
+ }
+ else
+ {
+ snprintf(buf, sizeof(buf), "unknown");
+ }
+
+ return buf;
+}
+
+static char * print_hardware_name(const struct iwinfo_ops *iw, const char *ifname)
+{
+ static char buf[128];
+
+ if (iw->hardware_name(ifname, buf))
+ snprintf(buf, sizeof(buf), "unknown");
+
+ return buf;
+}
+
+static char * print_txpower_offset(const struct iwinfo_ops *iw, const char *ifname)
+{
+ int off;
+ static char buf[12];
+
+ if (iw->txpower_offset(ifname, &off))
+ snprintf(buf, sizeof(buf), "unknown");
+ else if (off != 0)
+ snprintf(buf, sizeof(buf), "%d dB", off);
+ else
+ snprintf(buf, sizeof(buf), "none");
+
+ return buf;
+}
+
+static char * print_frequency_offset(const struct iwinfo_ops *iw, const char *ifname)
+{
+ int off;
+ static char buf[12];
+
+ if (iw->frequency_offset(ifname, &off))
+ snprintf(buf, sizeof(buf), "unknown");
+ else if (off != 0)
+ snprintf(buf, sizeof(buf), "%.3f GHz", ((float)off / 1000.0));
+ else
+ snprintf(buf, sizeof(buf), "none");
+
+ return buf;
+}
+
+static char * print_ssid(const struct iwinfo_ops *iw, const char *ifname)
+{
+ char buf[IWINFO_ESSID_MAX_SIZE+1] = { 0 };
+
+ if (iw->ssid(ifname, buf))
+ memset(buf, 0, sizeof(buf));
+
+ return format_ssid(buf);
+}
+
+static char * print_bssid(const struct iwinfo_ops *iw, const char *ifname)
+{
+ static char buf[18] = { 0 };
+
+ if (iw->bssid(ifname, buf))
+ snprintf(buf, sizeof(buf), "00:00:00:00:00:00");
+
+ return buf;
+}
+
+static char * print_mode(const struct iwinfo_ops *iw, const char *ifname)
+{
+ int mode;
+ static char buf[128];
+
+ if (iw->mode(ifname, &mode))
+ mode = IWINFO_OPMODE_UNKNOWN;
+
+ snprintf(buf, sizeof(buf), "%s", IWINFO_OPMODE_NAMES[mode]);
+
+ return buf;
+}
+
+static char * print_channel(const struct iwinfo_ops *iw, const char *ifname)
+{
+ int ch;
+ if (iw->channel(ifname, &ch))
+ ch = -1;
+
+ return format_channel(ch);
+}
+
+static char * print_frequency(const struct iwinfo_ops *iw, const char *ifname)
+{
+ int freq;
+ if (iw->frequency(ifname, &freq))
+ freq = -1;
+
+ return format_frequency(freq);
+}
+
+static char * print_txpower(const struct iwinfo_ops *iw, const char *ifname)
+{
+ int pwr, off;
+ if (iw->txpower_offset(ifname, &off))
+ off = 0;
+
+ if (iw->txpower(ifname, &pwr))
+ pwr = -1;
+ else
+ pwr += off;
+
+ return format_txpower(pwr);
+}
+
+static char * print_quality(const struct iwinfo_ops *iw, const char *ifname)
+{
+ int qual;
+ if (iw->quality(ifname, &qual))
+ qual = -1;
+
+ return format_quality(qual);
+}
+
+static char * print_quality_max(const struct iwinfo_ops *iw, const char *ifname)
+{
+ int qmax;
+ if (iw->quality_max(ifname, &qmax))
+ qmax = -1;
+
+ return format_quality_max(qmax);
+}
+
+static char * print_signal(const struct iwinfo_ops *iw, const char *ifname)
+{
+ int sig;
+ if (iw->signal(ifname, &sig))
+ sig = 0;
+
+ return format_signal(sig);
+}
+
+static char * print_noise(const struct iwinfo_ops *iw, const char *ifname)
+{
+ int noise;
+ if (iw->noise(ifname, &noise))
+ noise = 0;
+
+ return format_noise(noise);
+}
+
+static char * print_rate(const struct iwinfo_ops *iw, const char *ifname)
+{
+ int rate;
+ if (iw->bitrate(ifname, &rate))
+ rate = -1;
+
+ return format_rate(rate);
+}
+
+static char * print_encryption(const struct iwinfo_ops *iw, const char *ifname)
+{
+ struct iwinfo_crypto_entry c = { 0 };
+ if (iw->encryption(ifname, (char *)&c))
+ return format_encryption(NULL);
+
+ return format_encryption(&c);
+}
+
+static char * print_hwmodes(const struct iwinfo_ops *iw, const char *ifname)
+{
+ int modes;
+ if (iw->hwmodelist(ifname, &modes))
+ modes = -1;
+
+ return format_hwmodes(modes);
+}
+
+static char * print_mbssid_supp(const struct iwinfo_ops *iw, const char *ifname)
+{
+ int supp;
+ static char buf[4];
+
+ if (iw->mbssid_support(ifname, &supp))
+ snprintf(buf, sizeof(buf), "no");
+ else
+ snprintf(buf, sizeof(buf), "%s", supp ? "yes" : "no");
+
+ return buf;
+}
+
+
+static void print_info(const struct iwinfo_ops *iw, const char *ifname)
+{
+ printf("%-9s ESSID: %s\n",
+ ifname,
+ print_ssid(iw, ifname));
+ printf(" Access Point: %s\n",
+ print_bssid(iw, ifname));
+ printf(" Mode: %s Channel: %s (%s)\n",
+ print_mode(iw, ifname),
+ print_channel(iw, ifname),
+ print_frequency(iw, ifname));
+ printf(" Tx-Power: %s Link Quality: %s/%s\n",
+ print_txpower(iw, ifname),
+ print_quality(iw, ifname),
+ print_quality_max(iw, ifname));
+ printf(" Signal: %s Noise: %s\n",
+ print_signal(iw, ifname),
+ print_noise(iw, ifname));
+ printf(" Bit Rate: %s\n",
+ print_rate(iw, ifname));
+ printf(" Encryption: %s\n",
+ print_encryption(iw, ifname));
+ printf(" Type: %s HW Mode(s): %s\n",
+ print_type(iw, ifname),
+ print_hwmodes(iw, ifname));
+ printf(" Hardware: %s [%s]\n",
+ print_hardware_id(iw, ifname),
+ print_hardware_name(iw, ifname));
+ printf(" TX power offset: %s\n",
+ print_txpower_offset(iw, ifname));
+ printf(" Frequency offset: %s\n",
+ print_frequency_offset(iw, ifname));
+ printf(" Supports VAPs: %s\n",
+ print_mbssid_supp(iw, ifname));
+}
+
+
+static void print_scanlist(const struct iwinfo_ops *iw, const char *ifname)
+{
+ int i, x, len;
+ char buf[IWINFO_BUFSIZE];
+ struct iwinfo_scanlist_entry *e;
+
+ if (iw->scanlist(ifname, buf, &len))
+ {
+ printf("Scanning not possible\n\n");
+ return;
+ }
+ else if (len <= 0)
+ {
+ printf("No scan results\n\n");
+ return;
+ }
+
+ for (i = 0, x = 1; i < len; i += sizeof(struct iwinfo_scanlist_entry), x++)
+ {
+ e = (struct iwinfo_scanlist_entry *) &buf[i];
+
+ printf("Cell %02d - Address: %s\n",
+ x,
+ format_bssid(e->mac));
+ printf(" ESSID: %s\n",
+ format_ssid(e->ssid));
+ printf(" Mode: %s Channel: %s\n",
+ IWINFO_OPMODE_NAMES[e->mode],
+ format_channel(e->channel));
+ printf(" Signal: %s Quality: %s/%s\n",
+ format_signal(e->signal - 0x100),
+ format_quality(e->quality),
+ format_quality_max(e->quality_max));
+ printf(" Encryption: %s\n\n",
+ format_encryption(&e->crypto));
+ }
+}
+
+
+static void print_txpwrlist(const struct iwinfo_ops *iw, const char *ifname)
+{
+ int len, pwr, off, i;
+ char buf[IWINFO_BUFSIZE];
+ struct iwinfo_txpwrlist_entry *e;
+
+ if (iw->txpwrlist(ifname, buf, &len) || len <= 0)
+ {
+ printf("No TX power information available\n");
+ return;
+ }
+
+ if (iw->txpower(ifname, &pwr))
+ pwr = -1;
+
+ if (iw->txpower_offset(ifname, &off))
+ off = 0;
+
+ for (i = 0; i < len; i += sizeof(struct iwinfo_txpwrlist_entry))
+ {
+ e = (struct iwinfo_txpwrlist_entry *) &buf[i];
+
+ printf("%s%3d dBm (%4d mW)\n",
+ (pwr == e->dbm) ? "*" : " ",
+ e->dbm + off,
+ iwinfo_dbm2mw(e->dbm + off));
+ }
+}
+
+
+static void print_freqlist(const struct iwinfo_ops *iw, const char *ifname)
+{
+ int i, len, ch;
+ char buf[IWINFO_BUFSIZE];
+ struct iwinfo_freqlist_entry *e;
+
+ if (iw->freqlist(ifname, buf, &len) || len <= 0)
+ {
+ printf("No frequency information available\n");
+ return;
+ }
+
+ if (iw->channel(ifname, &ch))
+ ch = -1;
+
+ for (i = 0; i < len; i += sizeof(struct iwinfo_freqlist_entry))
+ {
+ e = (struct iwinfo_freqlist_entry *) &buf[i];
+
+ printf("%s %s (Channel %s)%s\n",
+ (ch == e->channel) ? "*" : " ",
+ format_frequency(e->mhz),
+ format_channel(e->channel),
+ e->restricted ? " [restricted]" : "");
+ }
+}
+
+
+static void print_assoclist(const struct iwinfo_ops *iw, const char *ifname)
+{
+ int i, len;
+ char buf[IWINFO_BUFSIZE];
+ struct iwinfo_assoclist_entry *e;
+
+ if (iw->assoclist(ifname, buf, &len))
+ {
+ printf("No information available\n");
+ return;
+ }
+ else if (len <= 0)
+ {
+ printf("No station connected\n");
+ return;
+ }
+
+ for (i = 0; i < len; i += sizeof(struct iwinfo_assoclist_entry))
+ {
+ e = (struct iwinfo_assoclist_entry *) &buf[i];
+
+ printf("%s %s / %s (SNR %d) %d ms ago\n",
+ format_bssid(e->mac),
+ format_signal(e->signal),
+ format_noise(e->noise),
+ (e->signal - e->noise),
+ e->inactive);
+
+ printf(" RX: %-38s %8d Pkts.\n",
+ format_assocrate(&e->rx_rate),
+ e->rx_packets
+ );
+
+ printf(" TX: %-38s %8d Pkts.\n\n",
+ format_assocrate(&e->tx_rate),
+ e->tx_packets
+ );
+ }
+}
+
+
+static char * lookup_country(char *buf, int len, int iso3166)
+{
+ int i;
+ struct iwinfo_country_entry *c;
+
+ for (i = 0; i < len; i += sizeof(struct iwinfo_country_entry))
+ {
+ c = (struct iwinfo_country_entry *) &buf[i];
+
+ if (c->iso3166 == iso3166)
+ return c->ccode;
+ }
+
+ return NULL;
+}
+
+static void print_countrylist(const struct iwinfo_ops *iw, const char *ifname)
+{
+ int len;
+ char buf[IWINFO_BUFSIZE];
+ char *ccode;
+ char curcode[3];
+ const struct iwinfo_iso3166_label *l;
+
+ if (iw->countrylist(ifname, buf, &len))
+ {
+ printf("No country code information available\n");
+ return;
+ }
+
+ if (iw->country(ifname, curcode))
+ memset(curcode, 0, sizeof(curcode));
+
+ for (l = IWINFO_ISO3166_NAMES; l->iso3166; l++)
+ {
+ if ((ccode = lookup_country(buf, len, l->iso3166)) != NULL)
+ {
+ printf("%s %4s %c%c\n",
+ strncmp(ccode, curcode, 2) ? " " : "*",
+ ccode, (l->iso3166 / 256), (l->iso3166 % 256));
+ }
+ }
+}
+
+
+int main(int argc, char **argv)
+{
+ int i;
+ const struct iwinfo_ops *iw;
+
+ if (argc < 3)
+ {
+ fprintf(stderr,
+ "Usage:\n"
+ " iwinfo <device> info\n"
+ " iwinfo <device> scan\n"
+ " iwinfo <device> txpowerlist\n"
+ " iwinfo <device> freqlist\n"
+ " iwinfo <device> assoclist\n"
+ " iwinfo <device> countrylist\n"
+ );
+
+ return 1;
+ }
+
+ iw = iwinfo_backend(argv[1]);
+
+ if (!iw)
+ {
+ fprintf(stderr, "No such wireless device: %s\n", argv[1]);
+ return 1;
+ }
+
+ for (i = 2; i < argc; i++)
+ {
+ switch(argv[i][0])
+ {
+ case 'i':
+ print_info(iw, argv[1]);
+ break;
+
+ case 's':
+ print_scanlist(iw, argv[1]);
+ break;
+
+ case 't':
+ print_txpwrlist(iw, argv[1]);
+ break;
+
+ case 'f':
+ print_freqlist(iw, argv[1]);
+ break;
+
+ case 'a':
+ print_assoclist(iw, argv[1]);
+ break;
+
+ case 'c':
+ print_countrylist(iw, argv[1]);
+ break;
+
+ default:
+ fprintf(stderr, "Unknown command: %s\n", argv[i]);
+ return 1;
+ }
+ }
+
+ iwinfo_finish();
+
+ return 0;
+}
diff --git a/package/network/utils/iwinfo/src/iwinfo_lib.c b/package/network/utils/iwinfo/src/iwinfo_lib.c
new file mode 100644
index 0000000..e943546
--- /dev/null
+++ b/package/network/utils/iwinfo/src/iwinfo_lib.c
@@ -0,0 +1,458 @@
+/*
+ * iwinfo - Wireless Information Library - Lua Bindings
+ *
+ * Copyright (C) 2009-2013 Jo-Philipp Wich <xm@subsignal.org>
+ *
+ * The iwinfo library is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * The iwinfo library 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 the iwinfo library. If not, see http://www.gnu.org/licenses/.
+ */
+
+#include "iwinfo.h"
+
+
+/*
+ * name constants
+ */
+const char *IWINFO_CIPHER_NAMES[] = {
+ "NONE",
+ "WEP40",
+ "TKIP",
+ "WRAP",
+ "CCMP",
+ "WEP104",
+ "AES-OCB",
+ "CKIP",
+};
+
+const char *IWINFO_KMGMT_NAMES[] = {
+ "NONE",
+ "802.1X",
+ "PSK",
+};
+
+const char *IWINFO_AUTH_NAMES[] = {
+ "OPEN",
+ "SHARED",
+};
+
+const char *IWINFO_OPMODE_NAMES[] = {
+ "Unknown",
+ "Master",
+ "Ad-Hoc",
+ "Client",
+ "Monitor",
+ "Master (VLAN)",
+ "WDS",
+ "Mesh Point",
+ "P2P Client",
+ "P2P Go",
+};
+
+
+/*
+ * ISO3166 country labels
+ */
+
+const struct iwinfo_iso3166_label IWINFO_ISO3166_NAMES[] = {
+ { 0x3030 /* 00 */, "World" },
+ { 0x4144 /* AD */, "Andorra" },
+ { 0x4145 /* AE */, "United Arab Emirates" },
+ { 0x4146 /* AF */, "Afghanistan" },
+ { 0x4147 /* AG */, "Antigua and Barbuda" },
+ { 0x4149 /* AI */, "Anguilla" },
+ { 0x414C /* AL */, "Albania" },
+ { 0x414D /* AM */, "Armenia" },
+ { 0x414E /* AN */, "Netherlands Antilles" },
+ { 0x414F /* AO */, "Angola" },
+ { 0x4151 /* AQ */, "Antarctica" },
+ { 0x4152 /* AR */, "Argentina" },
+ { 0x4153 /* AS */, "American Samoa" },
+ { 0x4154 /* AT */, "Austria" },
+ { 0x4155 /* AU */, "Australia" },
+ { 0x4157 /* AW */, "Aruba" },
+ { 0x4158 /* AX */, "Aland Islands" },
+ { 0x415A /* AZ */, "Azerbaijan" },
+ { 0x4241 /* BA */, "Bosnia and Herzegovina" },
+ { 0x4242 /* BB */, "Barbados" },
+ { 0x4244 /* BD */, "Bangladesh" },
+ { 0x4245 /* BE */, "Belgium" },
+ { 0x4246 /* BF */, "Burkina Faso" },
+ { 0x4247 /* BG */, "Bulgaria" },
+ { 0x4248 /* BH */, "Bahrain" },
+ { 0x4249 /* BI */, "Burundi" },
+ { 0x424A /* BJ */, "Benin" },
+ { 0x424C /* BL */, "Saint Barthelemy" },
+ { 0x424D /* BM */, "Bermuda" },
+ { 0x424E /* BN */, "Brunei Darussalam" },
+ { 0x424F /* BO */, "Bolivia" },
+ { 0x4252 /* BR */, "Brazil" },
+ { 0x4253 /* BS */, "Bahamas" },
+ { 0x4254 /* BT */, "Bhutan" },
+ { 0x4256 /* BV */, "Bouvet Island" },
+ { 0x4257 /* BW */, "Botswana" },
+ { 0x4259 /* BY */, "Belarus" },
+ { 0x425A /* BZ */, "Belize" },
+ { 0x4341 /* CA */, "Canada" },
+ { 0x4343 /* CC */, "Cocos (Keeling) Islands" },
+ { 0x4344 /* CD */, "Congo" },
+ { 0x4346 /* CF */, "Central African Republic" },
+ { 0x4347 /* CG */, "Congo" },
+ { 0x4348 /* CH */, "Switzerland" },
+ { 0x4349 /* CI */, "Cote d'Ivoire" },
+ { 0x434B /* CK */, "Cook Islands" },
+ { 0x434C /* CL */, "Chile" },
+ { 0x434D /* CM */, "Cameroon" },
+ { 0x434E /* CN */, "China" },
+ { 0x434F /* CO */, "Colombia" },
+ { 0x4352 /* CR */, "Costa Rica" },
+ { 0x4355 /* CU */, "Cuba" },
+ { 0x4356 /* CV */, "Cape Verde" },
+ { 0x4358 /* CX */, "Christmas Island" },
+ { 0x4359 /* CY */, "Cyprus" },
+ { 0x435A /* CZ */, "Czech Republic" },
+ { 0x4445 /* DE */, "Germany" },
+ { 0x444A /* DJ */, "Djibouti" },
+ { 0x444B /* DK */, "Denmark" },
+ { 0x444D /* DM */, "Dominica" },
+ { 0x444F /* DO */, "Dominican Republic" },
+ { 0x445A /* DZ */, "Algeria" },
+ { 0x4543 /* EC */, "Ecuador" },
+ { 0x4545 /* EE */, "Estonia" },
+ { 0x4547 /* EG */, "Egypt" },
+ { 0x4548 /* EH */, "Western Sahara" },
+ { 0x4552 /* ER */, "Eritrea" },
+ { 0x4553 /* ES */, "Spain" },
+ { 0x4554 /* ET */, "Ethiopia" },
+ { 0x4649 /* FI */, "Finland" },
+ { 0x464A /* FJ */, "Fiji" },
+ { 0x464B /* FK */, "Falkland Islands" },
+ { 0x464D /* FM */, "Micronesia" },
+ { 0x464F /* FO */, "Faroe Islands" },
+ { 0x4652 /* FR */, "France" },
+ { 0x4741 /* GA */, "Gabon" },
+ { 0x4742 /* GB */, "United Kingdom" },
+ { 0x4744 /* GD */, "Grenada" },
+ { 0x4745 /* GE */, "Georgia" },
+ { 0x4746 /* GF */, "French Guiana" },
+ { 0x4747 /* GG */, "Guernsey" },
+ { 0x4748 /* GH */, "Ghana" },
+ { 0x4749 /* GI */, "Gibraltar" },
+ { 0x474C /* GL */, "Greenland" },
+ { 0x474D /* GM */, "Gambia" },
+ { 0x474E /* GN */, "Guinea" },
+ { 0x4750 /* GP */, "Guadeloupe" },
+ { 0x4751 /* GQ */, "Equatorial Guinea" },
+ { 0x4752 /* GR */, "Greece" },
+ { 0x4753 /* GS */, "South Georgia" },
+ { 0x4754 /* GT */, "Guatemala" },
+ { 0x4755 /* GU */, "Guam" },
+ { 0x4757 /* GW */, "Guinea-Bissau" },
+ { 0x4759 /* GY */, "Guyana" },
+ { 0x484B /* HK */, "Hong Kong" },
+ { 0x484D /* HM */, "Heard and McDonald Islands" },
+ { 0x484E /* HN */, "Honduras" },
+ { 0x4852 /* HR */, "Croatia" },
+ { 0x4854 /* HT */, "Haiti" },
+ { 0x4855 /* HU */, "Hungary" },
+ { 0x4944 /* ID */, "Indonesia" },
+ { 0x4945 /* IE */, "Ireland" },
+ { 0x494C /* IL */, "Israel" },
+ { 0x494D /* IM */, "Isle of Man" },
+ { 0x494E /* IN */, "India" },
+ { 0x494F /* IO */, "Chagos Islands" },
+ { 0x4951 /* IQ */, "Iraq" },
+ { 0x4952 /* IR */, "Iran" },
+ { 0x4953 /* IS */, "Iceland" },
+ { 0x4954 /* IT */, "Italy" },
+ { 0x4A45 /* JE */, "Jersey" },
+ { 0x4A4D /* JM */, "Jamaica" },
+ { 0x4A4F /* JO */, "Jordan" },
+ { 0x4A50 /* JP */, "Japan" },
+ { 0x4B45 /* KE */, "Kenya" },
+ { 0x4B47 /* KG */, "Kyrgyzstan" },
+ { 0x4B48 /* KH */, "Cambodia" },
+ { 0x4B49 /* KI */, "Kiribati" },
+ { 0x4B4D /* KM */, "Comoros" },
+ { 0x4B4E /* KN */, "Saint Kitts and Nevis" },
+ { 0x4B50 /* KP */, "North Korea" },
+ { 0x4B52 /* KR */, "South Korea" },
+ { 0x4B57 /* KW */, "Kuwait" },
+ { 0x4B59 /* KY */, "Cayman Islands" },
+ { 0x4B5A /* KZ */, "Kazakhstan" },
+ { 0x4C41 /* LA */, "Laos" },
+ { 0x4C42 /* LB */, "Lebanon" },
+ { 0x4C43 /* LC */, "Saint Lucia" },
+ { 0x4C49 /* LI */, "Liechtenstein" },
+ { 0x4C4B /* LK */, "Sri Lanka" },
+ { 0x4C52 /* LR */, "Liberia" },
+ { 0x4C53 /* LS */, "Lesotho" },
+ { 0x4C54 /* LT */, "Lithuania" },
+ { 0x4C55 /* LU */, "Luxembourg" },
+ { 0x4C56 /* LV */, "Latvia" },
+ { 0x4C59 /* LY */, "Libyan Arab Jamahiriya" },
+ { 0x4D41 /* MA */, "Morocco" },
+ { 0x4D43 /* MC */, "Monaco" },
+ { 0x4D44 /* MD */, "Moldova" },
+ { 0x4D45 /* ME */, "Montenegro" },
+ { 0x4D46 /* MF */, "Saint Martin (French part)" },
+ { 0x4D47 /* MG */, "Madagascar" },
+ { 0x4D48 /* MH */, "Marshall Islands" },
+ { 0x4D4B /* MK */, "Macedonia" },
+ { 0x4D4C /* ML */, "Mali" },
+ { 0x4D4D /* MM */, "Myanmar" },
+ { 0x4D4E /* MN */, "Mongolia" },
+ { 0x4D4F /* MO */, "Macao" },
+ { 0x4D50 /* MP */, "Northern Mariana Islands" },
+ { 0x4D51 /* MQ */, "Martinique" },
+ { 0x4D52 /* MR */, "Mauritania" },
+ { 0x4D53 /* MS */, "Montserrat" },
+ { 0x4D54 /* MT */, "Malta" },
+ { 0x4D55 /* MU */, "Mauritius" },
+ { 0x4D56 /* MV */, "Maldives" },
+ { 0x4D57 /* MW */, "Malawi" },
+ { 0x4D58 /* MX */, "Mexico" },
+ { 0x4D59 /* MY */, "Malaysia" },
+ { 0x4D5A /* MZ */, "Mozambique" },
+ { 0x4E41 /* NA */, "Namibia" },
+ { 0x4E43 /* NC */, "New Caledonia" },
+ { 0x4E45 /* NE */, "Niger" },
+ { 0x4E46 /* NF */, "Norfolk Island" },
+ { 0x4E47 /* NG */, "Nigeria" },
+ { 0x4E49 /* NI */, "Nicaragua" },
+ { 0x4E4C /* NL */, "Netherlands" },
+ { 0x4E4F /* NO */, "Norway" },
+ { 0x4E50 /* NP */, "Nepal" },
+ { 0x4E52 /* NR */, "Nauru" },
+ { 0x4E55 /* NU */, "Niue" },
+ { 0x4E5A /* NZ */, "New Zealand" },
+ { 0x4F4D /* OM */, "Oman" },
+ { 0x5041 /* PA */, "Panama" },
+ { 0x5045 /* PE */, "Peru" },
+ { 0x5046 /* PF */, "French Polynesia" },
+ { 0x5047 /* PG */, "Papua New Guinea" },
+ { 0x5048 /* PH */, "Philippines" },
+ { 0x504B /* PK */, "Pakistan" },
+ { 0x504C /* PL */, "Poland" },
+ { 0x504D /* PM */, "Saint Pierre and Miquelon" },
+ { 0x504E /* PN */, "Pitcairn" },
+ { 0x5052 /* PR */, "Puerto Rico" },
+ { 0x5053 /* PS */, "Palestinian Territory" },
+ { 0x5054 /* PT */, "Portugal" },
+ { 0x5057 /* PW */, "Palau" },
+ { 0x5059 /* PY */, "Paraguay" },
+ { 0x5141 /* QA */, "Qatar" },
+ { 0x5245 /* RE */, "Reunion" },
+ { 0x524F /* RO */, "Romania" },
+ { 0x5253 /* RS */, "Serbia" },
+ { 0x5255 /* RU */, "Russian Federation" },
+ { 0x5257 /* RW */, "Rwanda" },
+ { 0x5341 /* SA */, "Saudi Arabia" },
+ { 0x5342 /* SB */, "Solomon Islands" },
+ { 0x5343 /* SC */, "Seychelles" },
+ { 0x5344 /* SD */, "Sudan" },
+ { 0x5345 /* SE */, "Sweden" },
+ { 0x5347 /* SG */, "Singapore" },
+ { 0x5348 /* SH */, "St. Helena and Dependencies" },
+ { 0x5349 /* SI */, "Slovenia" },
+ { 0x534A /* SJ */, "Svalbard and Jan Mayen" },
+ { 0x534B /* SK */, "Slovakia" },
+ { 0x534C /* SL */, "Sierra Leone" },
+ { 0x534D /* SM */, "San Marino" },
+ { 0x534E /* SN */, "Senegal" },
+ { 0x534F /* SO */, "Somalia" },
+ { 0x5352 /* SR */, "Suriname" },
+ { 0x5354 /* ST */, "Sao Tome and Principe" },
+ { 0x5356 /* SV */, "El Salvador" },
+ { 0x5359 /* SY */, "Syrian Arab Republic" },
+ { 0x535A /* SZ */, "Swaziland" },
+ { 0x5443 /* TC */, "Turks and Caicos Islands" },
+ { 0x5444 /* TD */, "Chad" },
+ { 0x5446 /* TF */, "French Southern Territories" },
+ { 0x5447 /* TG */, "Togo" },
+ { 0x5448 /* TH */, "Thailand" },
+ { 0x544A /* TJ */, "Tajikistan" },
+ { 0x544B /* TK */, "Tokelau" },
+ { 0x544C /* TL */, "Timor-Leste" },
+ { 0x544D /* TM */, "Turkmenistan" },
+ { 0x544E /* TN */, "Tunisia" },
+ { 0x544F /* TO */, "Tonga" },
+ { 0x5452 /* TR */, "Turkey" },
+ { 0x5454 /* TT */, "Trinidad and Tobago" },
+ { 0x5456 /* TV */, "Tuvalu" },
+ { 0x5457 /* TW */, "Taiwan" },
+ { 0x545A /* TZ */, "Tanzania" },
+ { 0x5541 /* UA */, "Ukraine" },
+ { 0x5547 /* UG */, "Uganda" },
+ { 0x554D /* UM */, "U.S. Minor Outlying Islands" },
+ { 0x5553 /* US */, "United States" },
+ { 0x5559 /* UY */, "Uruguay" },
+ { 0x555A /* UZ */, "Uzbekistan" },
+ { 0x5641 /* VA */, "Vatican City State" },
+ { 0x5643 /* VC */, "St. Vincent and Grenadines" },
+ { 0x5645 /* VE */, "Venezuela" },
+ { 0x5647 /* VG */, "Virgin Islands, British" },
+ { 0x5649 /* VI */, "Virgin Islands, U.S." },
+ { 0x564E /* VN */, "Viet Nam" },
+ { 0x5655 /* VU */, "Vanuatu" },
+ { 0x5746 /* WF */, "Wallis and Futuna" },
+ { 0x5753 /* WS */, "Samoa" },
+ { 0x5945 /* YE */, "Yemen" },
+ { 0x5954 /* YT */, "Mayotte" },
+ { 0x5A41 /* ZA */, "South Africa" },
+ { 0x5A4D /* ZM */, "Zambia" },
+ { 0x5A57 /* ZW */, "Zimbabwe" },
+ { 0, "" }
+};
+
+/*
+ * hardware database
+ */
+
+const char VENDOR_UBNT[] = "Ubiquiti";
+const char VENDOR_ATH[] = "Atheros";
+const char VENDOR_RALINK[] = "RaLink";
+
+const struct iwinfo_hardware_entry IWINFO_HARDWARE_ENTRIES[] = {
+/* { vendor, model, vendorid, deviceid, subsys vendorid, subsys deviceid, poweroff, freqoff } */
+#if defined(USE_MADWIFI) || defined(USE_NL80211)
+ { VENDOR_UBNT, "PowerStation2 (18V)", 0xffff, 0xffff, 0xffff, 0xb102, 0, 0 },
+ { VENDOR_UBNT, "PowerStation2 (16D)", 0xffff, 0xffff, 0xffff, 0xb202, 0, 0 },
+ { VENDOR_UBNT, "PowerStation2 (EXT)", 0xffff, 0xffff, 0xffff, 0xb302, 0, 0 },
+ { VENDOR_UBNT, "PowerStation5 (22V)", 0xffff, 0xffff, 0xffff, 0xb105, 0, 0 },
+ { VENDOR_UBNT, "PowerStation5 (EXT)", 0xffff, 0xffff, 0xffff, 0xb305, 0, 0 },
+ { VENDOR_UBNT, "PicoStation2", 0xffff, 0xffff, 0xffff, 0xc302, 0, 0 },
+ { VENDOR_UBNT, "PicoStation2 HP", 0xffff, 0xffff, 0xffff, 0xc3a2, 10, 0 },
+ { VENDOR_UBNT, "WispStation5", 0xffff, 0xffff, 0xffff, 0xa105, 0, 0 },
+ { VENDOR_UBNT, "LiteStation2", 0xffff, 0xffff, 0xffff, 0xa002, 10, 0 },
+ { VENDOR_UBNT, "LiteStation5", 0xffff, 0xffff, 0xffff, 0xa005, 5, 0 },
+ { VENDOR_UBNT, "NanoStation2", 0xffff, 0xffff, 0xffff, 0xc002, 10, 0 },
+ { VENDOR_UBNT, "NanoStation5", 0xffff, 0xffff, 0xffff, 0xc005, 5, 0 },
+ { VENDOR_UBNT, "NanoStation Loco2", 0xffff, 0xffff, 0xffff, 0xc102, 10, 0 },
+ { VENDOR_UBNT, "NanoStation Loco5", 0xffff, 0xffff, 0xffff, 0xc105, 5, 0 },
+ { VENDOR_UBNT, "Bullet2", 0xffff, 0xffff, 0xffff, 0xc202, 10, 0 },
+ { VENDOR_UBNT, "Bullet5", 0xffff, 0xffff, 0xffff, 0xc205, 5, 0 },
+ { VENDOR_UBNT, "XR2", 0x168c, 0x001b, 0x0777, 0x3002, 10, 0 },
+ { VENDOR_UBNT, "XR2", 0x168c, 0x001b, 0x7777, 0x3002, 10, 0 },
+ { VENDOR_UBNT, "XR2.3", 0x168c, 0x001b, 0x0777, 0x3b02, 10, 0 },
+ { VENDOR_UBNT, "XR2.6", 0x168c, 0x001b, 0x0777, 0x3c02, 10, 0 },
+ { VENDOR_UBNT, "XR3-2.8", 0x168c, 0x001b, 0x0777, 0x3b03, 10, 0 },
+ { VENDOR_UBNT, "XR3-3.6", 0x168c, 0x001b, 0x0777, 0x3c03, 10, 0 },
+ { VENDOR_UBNT, "XR3", 0x168c, 0x001b, 0x0777, 0x3003, 10, 0 },
+ { VENDOR_UBNT, "XR4", 0x168c, 0x001b, 0x0777, 0x3004, 10, 0 },
+ { VENDOR_UBNT, "XR5", 0x168c, 0x001b, 0x0777, 0x3005, 10, 0 },
+ { VENDOR_UBNT, "XR5", 0x168c, 0x001b, 0x7777, 0x3005, 10, 0 },
+ { VENDOR_UBNT, "XR7", 0x168c, 0x001b, 0x0777, 0x3007, 10, 0 },
+ { VENDOR_UBNT, "XR9", 0x168c, 0x001b, 0x0777, 0x3009, 10, -1520 },
+ { VENDOR_ATH, "AR5413", 0x168c, 0x001b, 0x168c, 0x2063, 0, 0 },
+ { VENDOR_UBNT, "SRC", 0x168c, 0x0013, 0x168c, 0x1042, 1, 0 },
+ { VENDOR_UBNT, "SR2", 0x168c, 0x0013, 0x0777, 0x2041, 10, 0 },
+ { VENDOR_UBNT, "SR4", 0x168c, 0x0013, 0x0777, 0x2004, 6, 0 },
+ { VENDOR_UBNT, "SR4", 0x168c, 0x0013, 0x7777, 0x2004, 6, 0 },
+ { VENDOR_UBNT, "SR4C", 0x168c, 0x0013, 0x0777, 0x1004, 6, 0 },
+ { VENDOR_UBNT, "SR4C", 0x168c, 0x0013, 0x7777, 0x1004, 6, 0 },
+ { VENDOR_UBNT, "SR5", 0x168c, 0x0013, 0x168c, 0x2042, 7, 0 },
+ { VENDOR_UBNT, "SR9", 0x168c, 0x0013, 0x7777, 0x2009, 12, -1500 },
+ { VENDOR_UBNT, "SR71A", 0x168c, 0x0027, 0x168c, 0x2082, 10, 0 },
+ { VENDOR_UBNT, "SR71", 0x168c, 0x0027, 0x0777, 0x4082, 10, 0 },
+#endif
+#ifdef USE_NL80211
+ { VENDOR_UBNT, "PicoStation M2", 0x168c, 0x002a, 0x0777, 0xe302, 12, 0 }, /* ToDo: confirm offset */
+ { VENDOR_UBNT, "NanoStation M2", 0x168c, 0x002a, 0x0777, 0xe012, 12, 0 }, /* ToDo: confirm offset */
+ { VENDOR_UBNT, "NanoStation M5", 0x168c, 0x002a, 0x0777, 0xe005, 5, 0 }, /* ToDo: confirm offset */
+ { VENDOR_UBNT, "Bullet M2", 0x168c, 0x002a, 0x0777, 0xe202, 12, 0 },
+ { VENDOR_UBNT, "Bullet M5", 0x168c, 0x002a, 0x0777, 0xe805, 5, 0 },
+
+ { VENDOR_ATH, "AR9220", 0x168c, 0x0029, 0x168c, 0xa094, 0, 0 },
+ { VENDOR_ATH, "AR9223", 0x168c, 0x0029, 0x168c, 0xa095, 0, 0 },
+ { VENDOR_ATH, "AR9280", 0x168c, 0x002a, 0x168c, 0xa093, 0, 0 },
+ { VENDOR_ATH, "AR9285", 0x168c, 0x002b, 0x168c, 0xa091, 0, 0 },
+ { VENDOR_RALINK, "Rt3050", 0x1814, 0x3050, 0x1814, 0x0005, 0, 0 },
+ { VENDOR_RALINK, "Rt3052", 0x1814, 0x3052, 0x1814, 0x0008, 0, 0 },
+ { VENDOR_RALINK, "Rt3352", 0x1814, 0x3352, 0x1814, 0x000c, 0, 0 },
+#endif
+ { NULL }
+};
+
+
+const char * iwinfo_type(const char *ifname)
+{
+#ifdef USE_NL80211
+ if (nl80211_probe(ifname))
+ return "nl80211";
+ else
+#endif
+
+#ifdef USE_MADWIFI
+ if (madwifi_probe(ifname))
+ return "madwifi";
+ else
+#endif
+
+#ifdef USE_WL
+ if (wl_probe(ifname))
+ return "wl";
+ else
+#endif
+
+ if (wext_probe(ifname))
+ return "wext";
+
+ return NULL;
+}
+
+const struct iwinfo_ops * iwinfo_backend(const char *ifname)
+{
+ const char *type;
+ struct iwinfo_ops *ops;
+
+ type = iwinfo_type(ifname);
+ if (!type)
+ return NULL;
+
+#ifdef USE_NL80211
+ if (!strcmp(type, "nl80211"))
+ return &nl80211_ops;
+ else
+#endif
+
+#ifdef USE_MADWIFI
+ if (!strcmp(type, "madwifi"))
+ return &madwifi_ops;
+ else
+#endif
+
+#ifdef USE_WL
+ if (!strcmp(type, "wl"))
+ return &wl_ops;
+ else
+#endif
+
+ if (!strcmp(type, "wext"))
+ return &wext_ops;
+
+ return NULL;
+}
+
+void iwinfo_finish(void)
+{
+#ifdef USE_WL
+ wl_close();
+#endif
+#ifdef USE_MADWIFI
+ madwifi_close();
+#endif
+#ifdef USE_NL80211
+ nl80211_close();
+#endif
+ wext_close();
+ iwinfo_close();
+}
diff --git a/package/network/utils/iwinfo/src/iwinfo_lua.c b/package/network/utils/iwinfo/src/iwinfo_lua.c
new file mode 100644
index 0000000..bd8faf9
--- /dev/null
+++ b/package/network/utils/iwinfo/src/iwinfo_lua.c
@@ -0,0 +1,886 @@
+/*
+ * iwinfo - Wireless Information Library - Lua Bindings
+ *
+ * Copyright (C) 2009 Jo-Philipp Wich <xm@subsignal.org>
+ *
+ * The iwinfo library is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * The iwinfo library 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 the iwinfo library. If not, see http://www.gnu.org/licenses/.
+ */
+
+#include "iwinfo/lua.h"
+
+
+/* Determine type */
+static int iwinfo_L_type(lua_State *L)
+{
+ const char *ifname = luaL_checkstring(L, 1);
+ const char *type = iwinfo_type(ifname);
+
+ if (type)
+ lua_pushstring(L, type);
+ else
+ lua_pushnil(L);
+
+ return 1;
+}
+
+/* Shutdown backends */
+static int iwinfo_L__gc(lua_State *L)
+{
+ iwinfo_finish();
+ return 0;
+}
+
+/*
+ * Build a short textual description of the crypto info
+ */
+
+static char * iwinfo_crypto_print_ciphers(int ciphers)
+{
+ static char str[128] = { 0 };
+ char *pos = str;
+
+ if (ciphers & IWINFO_CIPHER_WEP40)
+ pos += sprintf(pos, "WEP-40, ");
+
+ if (ciphers & IWINFO_CIPHER_WEP104)
+ pos += sprintf(pos, "WEP-104, ");
+
+ if (ciphers & IWINFO_CIPHER_TKIP)
+ pos += sprintf(pos, "TKIP, ");
+
+ if (ciphers & IWINFO_CIPHER_CCMP)
+ pos += sprintf(pos, "CCMP, ");
+
+ if (ciphers & IWINFO_CIPHER_WRAP)
+ pos += sprintf(pos, "WRAP, ");
+
+ if (ciphers & IWINFO_CIPHER_AESOCB)
+ pos += sprintf(pos, "AES-OCB, ");
+
+ if (ciphers & IWINFO_CIPHER_CKIP)
+ pos += sprintf(pos, "CKIP, ");
+
+ if (!ciphers || (ciphers & IWINFO_CIPHER_NONE))
+ pos += sprintf(pos, "NONE, ");
+
+ *(pos - 2) = 0;
+
+ return str;
+}
+
+static char * iwinfo_crypto_print_suites(int suites)
+{
+ static char str[64] = { 0 };
+ char *pos = str;
+
+ if (suites & IWINFO_KMGMT_PSK)
+ pos += sprintf(pos, "PSK/");
+
+ if (suites & IWINFO_KMGMT_8021x)
+ pos += sprintf(pos, "802.1X/");
+
+ if (!suites || (suites & IWINFO_KMGMT_NONE))
+ pos += sprintf(pos, "NONE/");
+
+ *(pos - 1) = 0;
+
+ return str;
+}
+
+static char * iwinfo_crypto_desc(struct iwinfo_crypto_entry *c)
+{
+ static char desc[512] = { 0 };
+
+ if (c)
+ {
+ if (c->enabled)
+ {
+ /* WEP */
+ if (c->auth_algs && !c->wpa_version)
+ {
+ if ((c->auth_algs & IWINFO_AUTH_OPEN) &&
+ (c->auth_algs & IWINFO_AUTH_SHARED))
+ {
+ sprintf(desc, "WEP Open/Shared (%s)",
+ iwinfo_crypto_print_ciphers(c->pair_ciphers));
+ }
+ else if (c->auth_algs & IWINFO_AUTH_OPEN)
+ {
+ sprintf(desc, "WEP Open System (%s)",
+ iwinfo_crypto_print_ciphers(c->pair_ciphers));
+ }
+ else if (c->auth_algs & IWINFO_AUTH_SHARED)
+ {
+ sprintf(desc, "WEP Shared Auth (%s)",
+ iwinfo_crypto_print_ciphers(c->pair_ciphers));
+ }
+ }
+
+ /* WPA */
+ else if (c->wpa_version)
+ {
+ switch (c->wpa_version) {
+ case 3:
+ sprintf(desc, "mixed WPA/WPA2 %s (%s)",
+ iwinfo_crypto_print_suites(c->auth_suites),
+ iwinfo_crypto_print_ciphers(
+ c->pair_ciphers & c->group_ciphers));
+ break;
+
+ case 2:
+ sprintf(desc, "WPA2 %s (%s)",
+ iwinfo_crypto_print_suites(c->auth_suites),
+ iwinfo_crypto_print_ciphers(
+ c->pair_ciphers & c->group_ciphers));
+ break;
+
+ case 1:
+ sprintf(desc, "WPA %s (%s)",
+ iwinfo_crypto_print_suites(c->auth_suites),
+ iwinfo_crypto_print_ciphers(
+ c->pair_ciphers & c->group_ciphers));
+ break;
+ }
+ }
+ else
+ {
+ sprintf(desc, "None");
+ }
+ }
+ else
+ {
+ sprintf(desc, "None");
+ }
+ }
+ else
+ {
+ sprintf(desc, "Unknown");
+ }
+
+ return desc;
+}
+
+/* Build Lua table from crypto data */
+static void iwinfo_L_cryptotable(lua_State *L, struct iwinfo_crypto_entry *c)
+{
+ int i, j;
+
+ lua_newtable(L);
+
+ lua_pushboolean(L, c->enabled);
+ lua_setfield(L, -2, "enabled");
+
+ lua_pushstring(L, iwinfo_crypto_desc(c));
+ lua_setfield(L, -2, "description");
+
+ lua_pushboolean(L, (c->enabled && !c->wpa_version));
+ lua_setfield(L, -2, "wep");
+
+ lua_pushinteger(L, c->wpa_version);
+ lua_setfield(L, -2, "wpa");
+
+ lua_newtable(L);
+ for (i = 0, j = 1; i < 8; i++)
+ {
+ if (c->pair_ciphers & (1 << i))
+ {
+ lua_pushstring(L, IWINFO_CIPHER_NAMES[i]);
+ lua_rawseti(L, -2, j++);
+ }
+ }
+ lua_setfield(L, -2, "pair_ciphers");
+
+ lua_newtable(L);
+ for (i = 0, j = 1; i < 8; i++)
+ {
+ if (c->group_ciphers & (1 << i))
+ {
+ lua_pushstring(L, IWINFO_CIPHER_NAMES[i]);
+ lua_rawseti(L, -2, j++);
+ }
+ }
+ lua_setfield(L, -2, "group_ciphers");
+
+ lua_newtable(L);
+ for (i = 0, j = 1; i < 8; i++)
+ {
+ if (c->auth_suites & (1 << i))
+ {
+ lua_pushstring(L, IWINFO_KMGMT_NAMES[i]);
+ lua_rawseti(L, -2, j++);
+ }
+ }
+ lua_setfield(L, -2, "auth_suites");
+
+ lua_newtable(L);
+ for (i = 0, j = 1; i < 8; i++)
+ {
+ if (c->auth_algs & (1 << i))
+ {
+ lua_pushstring(L, IWINFO_AUTH_NAMES[i]);
+ lua_rawseti(L, -2, j++);
+ }
+ }
+ lua_setfield(L, -2, "auth_algs");
+}
+
+
+/* Wrapper for mode */
+static int iwinfo_L_mode(lua_State *L, int (*func)(const char *, int *))
+{
+ int mode;
+ const char *ifname = luaL_checkstring(L, 1);
+
+ if ((*func)(ifname, &mode))
+ mode = IWINFO_OPMODE_UNKNOWN;
+
+ lua_pushstring(L, IWINFO_OPMODE_NAMES[mode]);
+ return 1;
+}
+
+/* Wrapper for assoclist */
+static int iwinfo_L_assoclist(lua_State *L, int (*func)(const char *, char *, int *))
+{
+ int i, len;
+ char rv[IWINFO_BUFSIZE];
+ char macstr[18];
+ const char *ifname = luaL_checkstring(L, 1);
+ struct iwinfo_assoclist_entry *e;
+
+ lua_newtable(L);
+ memset(rv, 0, sizeof(rv));
+
+ if (!(*func)(ifname, rv, &len))
+ {
+ for (i = 0; i < len; i += sizeof(struct iwinfo_assoclist_entry))
+ {
+ e = (struct iwinfo_assoclist_entry *) &rv[i];
+
+ sprintf(macstr, "%02X:%02X:%02X:%02X:%02X:%02X",
+ e->mac[0], e->mac[1], e->mac[2],
+ e->mac[3], e->mac[4], e->mac[5]);
+
+ lua_newtable(L);
+
+ lua_pushnumber(L, e->signal);
+ lua_setfield(L, -2, "signal");
+
+ lua_pushnumber(L, e->noise);
+ lua_setfield(L, -2, "noise");
+
+ lua_pushnumber(L, e->inactive);
+ lua_setfield(L, -2, "inactive");
+
+ lua_pushnumber(L, e->rx_packets);
+ lua_setfield(L, -2, "rx_packets");
+
+ lua_pushnumber(L, e->tx_packets);
+ lua_setfield(L, -2, "tx_packets");
+
+ lua_pushnumber(L, e->rx_rate.rate);
+ lua_setfield(L, -2, "rx_rate");
+
+ lua_pushnumber(L, e->tx_rate.rate);
+ lua_setfield(L, -2, "tx_rate");
+
+ if (e->rx_rate.mcs >= 0)
+ {
+ lua_pushnumber(L, e->rx_rate.mcs);
+ lua_setfield(L, -2, "rx_mcs");
+
+ lua_pushboolean(L, e->rx_rate.is_40mhz);
+ lua_setfield(L, -2, "rx_40mhz");
+
+ lua_pushboolean(L, e->rx_rate.is_short_gi);
+ lua_setfield(L, -2, "rx_short_gi");
+ }
+
+ if (e->tx_rate.mcs >= 0)
+ {
+ lua_pushnumber(L, e->tx_rate.mcs);
+ lua_setfield(L, -2, "tx_mcs");
+
+ lua_pushboolean(L, e->tx_rate.is_40mhz);
+ lua_setfield(L, -2, "tx_40mhz");
+
+ lua_pushboolean(L, e->tx_rate.is_short_gi);
+ lua_setfield(L, -2, "tx_short_gi");
+ }
+
+ lua_setfield(L, -2, macstr);
+ }
+ }
+
+ return 1;
+}
+
+/* Wrapper for tx power list */
+static int iwinfo_L_txpwrlist(lua_State *L, int (*func)(const char *, char *, int *))
+{
+ int i, x, len;
+ char rv[IWINFO_BUFSIZE];
+ const char *ifname = luaL_checkstring(L, 1);
+ struct iwinfo_txpwrlist_entry *e;
+
+ memset(rv, 0, sizeof(rv));
+
+ if (!(*func)(ifname, rv, &len))
+ {
+ lua_newtable(L);
+
+ for (i = 0, x = 1; i < len; i += sizeof(struct iwinfo_txpwrlist_entry), x++)
+ {
+ e = (struct iwinfo_txpwrlist_entry *) &rv[i];
+
+ lua_newtable(L);
+
+ lua_pushnumber(L, e->mw);
+ lua_setfield(L, -2, "mw");
+
+ lua_pushnumber(L, e->dbm);
+ lua_setfield(L, -2, "dbm");
+
+ lua_rawseti(L, -2, x);
+ }
+
+ return 1;
+ }
+
+ return 0;
+}
+
+/* Wrapper for scan list */
+static int iwinfo_L_scanlist(lua_State *L, int (*func)(const char *, char *, int *))
+{
+ int i, x, len;
+ char rv[IWINFO_BUFSIZE];
+ char macstr[18];
+ const char *ifname = luaL_checkstring(L, 1);
+ struct iwinfo_scanlist_entry *e;
+
+ lua_newtable(L);
+ memset(rv, 0, sizeof(rv));
+
+ if (!(*func)(ifname, rv, &len))
+ {
+ for (i = 0, x = 1; i < len; i += sizeof(struct iwinfo_scanlist_entry), x++)
+ {
+ e = (struct iwinfo_scanlist_entry *) &rv[i];
+
+ lua_newtable(L);
+
+ /* BSSID */
+ sprintf(macstr, "%02X:%02X:%02X:%02X:%02X:%02X",
+ e->mac[0], e->mac[1], e->mac[2],
+ e->mac[3], e->mac[4], e->mac[5]);
+
+ lua_pushstring(L, macstr);
+ lua_setfield(L, -2, "bssid");
+
+ /* ESSID */
+ if (e->ssid[0])
+ {
+ lua_pushstring(L, (char *) e->ssid);
+ lua_setfield(L, -2, "ssid");
+ }
+
+ /* Channel */
+ lua_pushinteger(L, e->channel);
+ lua_setfield(L, -2, "channel");
+
+ /* Mode */
+ lua_pushstring(L, IWINFO_OPMODE_NAMES[e->mode]);
+ lua_setfield(L, -2, "mode");
+
+ /* Quality, Signal */
+ lua_pushinteger(L, e->quality);
+ lua_setfield(L, -2, "quality");
+
+ lua_pushinteger(L, e->quality_max);
+ lua_setfield(L, -2, "quality_max");
+
+ lua_pushnumber(L, (e->signal - 0x100));
+ lua_setfield(L, -2, "signal");
+
+ /* Crypto */
+ iwinfo_L_cryptotable(L, &e->crypto);
+ lua_setfield(L, -2, "encryption");
+
+ lua_rawseti(L, -2, x);
+ }
+ }
+
+ return 1;
+}
+
+/* Wrapper for frequency list */
+static int iwinfo_L_freqlist(lua_State *L, int (*func)(const char *, char *, int *))
+{
+ int i, x, len;
+ char rv[IWINFO_BUFSIZE];
+ const char *ifname = luaL_checkstring(L, 1);
+ struct iwinfo_freqlist_entry *e;
+
+ lua_newtable(L);
+ memset(rv, 0, sizeof(rv));
+
+ if (!(*func)(ifname, rv, &len))
+ {
+ for (i = 0, x = 1; i < len; i += sizeof(struct iwinfo_freqlist_entry), x++)
+ {
+ e = (struct iwinfo_freqlist_entry *) &rv[i];
+
+ lua_newtable(L);
+
+ /* MHz */
+ lua_pushinteger(L, e->mhz);
+ lua_setfield(L, -2, "mhz");
+
+ /* Channel */
+ lua_pushinteger(L, e->channel);
+ lua_setfield(L, -2, "channel");
+
+ /* Restricted (DFS/TPC/Radar) */
+ lua_pushboolean(L, e->restricted);
+ lua_setfield(L, -2, "restricted");
+
+ lua_rawseti(L, -2, x);
+ }
+ }
+
+ return 1;
+}
+
+/* Wrapper for crypto settings */
+static int iwinfo_L_encryption(lua_State *L, int (*func)(const char *, char *))
+{
+ const char *ifname = luaL_checkstring(L, 1);
+ struct iwinfo_crypto_entry c = { 0 };
+
+ if (!(*func)(ifname, (char *)&c))
+ {
+ iwinfo_L_cryptotable(L, &c);
+ return 1;
+ }
+
+ lua_pushnil(L);
+ return 1;
+}
+
+/* Wrapper for hwmode list */
+static int iwinfo_L_hwmodelist(lua_State *L, int (*func)(const char *, int *))
+{
+ const char *ifname = luaL_checkstring(L, 1);
+ int hwmodes = 0;
+
+ if (!(*func)(ifname, &hwmodes))
+ {
+ lua_newtable(L);
+
+ lua_pushboolean(L, hwmodes & IWINFO_80211_A);
+ lua_setfield(L, -2, "a");
+
+ lua_pushboolean(L, hwmodes & IWINFO_80211_B);
+ lua_setfield(L, -2, "b");
+
+ lua_pushboolean(L, hwmodes & IWINFO_80211_G);
+ lua_setfield(L, -2, "g");
+
+ lua_pushboolean(L, hwmodes & IWINFO_80211_N);
+ lua_setfield(L, -2, "n");
+
+ return 1;
+ }
+
+ lua_pushnil(L);
+ return 1;
+}
+
+/* Wrapper for mbssid_support */
+static int iwinfo_L_mbssid_support(lua_State *L, int (*func)(const char *, int *))
+{
+ const char *ifname = luaL_checkstring(L, 1);
+ int support = 0;
+
+ if (!(*func)(ifname, &support))
+ {
+ lua_pushboolean(L, support);
+ return 1;
+ }
+
+ lua_pushnil(L);
+ return 1;
+}
+
+/* Wrapper for hardware_id */
+static int iwinfo_L_hardware_id(lua_State *L, int (*func)(const char *, char *))
+{
+ const char *ifname = luaL_checkstring(L, 1);
+ struct iwinfo_hardware_id ids;
+
+ if (!(*func)(ifname, (char *)&ids))
+ {
+ lua_newtable(L);
+
+ lua_pushnumber(L, ids.vendor_id);
+ lua_setfield(L, -2, "vendor_id");
+
+ lua_pushnumber(L, ids.device_id);
+ lua_setfield(L, -2, "device_id");
+
+ lua_pushnumber(L, ids.subsystem_vendor_id);
+ lua_setfield(L, -2, "subsystem_vendor_id");
+
+ lua_pushnumber(L, ids.subsystem_device_id);
+ lua_setfield(L, -2, "subsystem_device_id");
+ }
+ else
+ {
+ lua_pushnil(L);
+ }
+
+ return 1;
+}
+
+/* Wrapper for country list */
+static char * iwinfo_L_country_lookup(char *buf, int len, int iso3166)
+{
+ int i;
+ struct iwinfo_country_entry *c;
+
+ for (i = 0; i < len; i += sizeof(struct iwinfo_country_entry))
+ {
+ c = (struct iwinfo_country_entry *) &buf[i];
+
+ if (c->iso3166 == iso3166)
+ return c->ccode;
+ }
+
+ return NULL;
+}
+
+static int iwinfo_L_countrylist(lua_State *L, int (*func)(const char *, char *, int *))
+{
+ int len, i, j;
+ char rv[IWINFO_BUFSIZE], alpha2[3];
+ char *ccode;
+ const char *ifname = luaL_checkstring(L, 1);
+ const struct iwinfo_iso3166_label *l;
+
+ lua_newtable(L);
+ memset(rv, 0, sizeof(rv));
+
+ if (!(*func)(ifname, rv, &len))
+ {
+ for (l = IWINFO_ISO3166_NAMES, j = 1; l->iso3166; l++)
+ {
+ if ((ccode = iwinfo_L_country_lookup(rv, len, l->iso3166)) != NULL)
+ {
+ sprintf(alpha2, "%c%c",
+ (l->iso3166 / 256), (l->iso3166 % 256));
+
+ lua_newtable(L);
+
+ lua_pushstring(L, alpha2);
+ lua_setfield(L, -2, "alpha2");
+
+ lua_pushstring(L, ccode);
+ lua_setfield(L, -2, "ccode");
+
+ lua_pushstring(L, l->name);
+ lua_setfield(L, -2, "name");
+
+ lua_rawseti(L, -2, j++);
+ }
+ }
+ }
+
+ return 1;
+}
+
+
+#ifdef USE_WL
+/* Broadcom */
+LUA_WRAP_INT(wl,channel)
+LUA_WRAP_INT(wl,frequency)
+LUA_WRAP_INT(wl,frequency_offset)
+LUA_WRAP_INT(wl,txpower)
+LUA_WRAP_INT(wl,txpower_offset)
+LUA_WRAP_INT(wl,bitrate)
+LUA_WRAP_INT(wl,signal)
+LUA_WRAP_INT(wl,noise)
+LUA_WRAP_INT(wl,quality)
+LUA_WRAP_INT(wl,quality_max)
+LUA_WRAP_STRING(wl,ssid)
+LUA_WRAP_STRING(wl,bssid)
+LUA_WRAP_STRING(wl,country)
+LUA_WRAP_STRING(wl,hardware_name)
+LUA_WRAP_STRUCT(wl,mode)
+LUA_WRAP_STRUCT(wl,assoclist)
+LUA_WRAP_STRUCT(wl,txpwrlist)
+LUA_WRAP_STRUCT(wl,scanlist)
+LUA_WRAP_STRUCT(wl,freqlist)
+LUA_WRAP_STRUCT(wl,countrylist)
+LUA_WRAP_STRUCT(wl,hwmodelist)
+LUA_WRAP_STRUCT(wl,encryption)
+LUA_WRAP_STRUCT(wl,mbssid_support)
+LUA_WRAP_STRUCT(wl,hardware_id)
+#endif
+
+#ifdef USE_MADWIFI
+/* Madwifi */
+LUA_WRAP_INT(madwifi,channel)
+LUA_WRAP_INT(madwifi,frequency)
+LUA_WRAP_INT(madwifi,frequency_offset)
+LUA_WRAP_INT(madwifi,txpower)
+LUA_WRAP_INT(madwifi,txpower_offset)
+LUA_WRAP_INT(madwifi,bitrate)
+LUA_WRAP_INT(madwifi,signal)
+LUA_WRAP_INT(madwifi,noise)
+LUA_WRAP_INT(madwifi,quality)
+LUA_WRAP_INT(madwifi,quality_max)
+LUA_WRAP_STRING(madwifi,ssid)
+LUA_WRAP_STRING(madwifi,bssid)
+LUA_WRAP_STRING(madwifi,country)
+LUA_WRAP_STRING(madwifi,hardware_name)
+LUA_WRAP_STRUCT(madwifi,mode)
+LUA_WRAP_STRUCT(madwifi,assoclist)
+LUA_WRAP_STRUCT(madwifi,txpwrlist)
+LUA_WRAP_STRUCT(madwifi,scanlist)
+LUA_WRAP_STRUCT(madwifi,freqlist)
+LUA_WRAP_STRUCT(madwifi,countrylist)
+LUA_WRAP_STRUCT(madwifi,hwmodelist)
+LUA_WRAP_STRUCT(madwifi,encryption)
+LUA_WRAP_STRUCT(madwifi,mbssid_support)
+LUA_WRAP_STRUCT(madwifi,hardware_id)
+#endif
+
+#ifdef USE_NL80211
+/* NL80211 */
+LUA_WRAP_INT(nl80211,channel)
+LUA_WRAP_INT(nl80211,frequency)
+LUA_WRAP_INT(nl80211,frequency_offset)
+LUA_WRAP_INT(nl80211,txpower)
+LUA_WRAP_INT(nl80211,txpower_offset)
+LUA_WRAP_INT(nl80211,bitrate)
+LUA_WRAP_INT(nl80211,signal)
+LUA_WRAP_INT(nl80211,noise)
+LUA_WRAP_INT(nl80211,quality)
+LUA_WRAP_INT(nl80211,quality_max)
+LUA_WRAP_STRING(nl80211,ssid)
+LUA_WRAP_STRING(nl80211,bssid)
+LUA_WRAP_STRING(nl80211,country)
+LUA_WRAP_STRING(nl80211,hardware_name)
+LUA_WRAP_STRUCT(nl80211,mode)
+LUA_WRAP_STRUCT(nl80211,assoclist)
+LUA_WRAP_STRUCT(nl80211,txpwrlist)
+LUA_WRAP_STRUCT(nl80211,scanlist)
+LUA_WRAP_STRUCT(nl80211,freqlist)
+LUA_WRAP_STRUCT(nl80211,countrylist)
+LUA_WRAP_STRUCT(nl80211,hwmodelist)
+LUA_WRAP_STRUCT(nl80211,encryption)
+LUA_WRAP_STRUCT(nl80211,mbssid_support)
+LUA_WRAP_STRUCT(nl80211,hardware_id)
+#endif
+
+/* Wext */
+LUA_WRAP_INT(wext,channel)
+LUA_WRAP_INT(wext,frequency)
+LUA_WRAP_INT(wext,frequency_offset)
+LUA_WRAP_INT(wext,txpower)
+LUA_WRAP_INT(wext,txpower_offset)
+LUA_WRAP_INT(wext,bitrate)
+LUA_WRAP_INT(wext,signal)
+LUA_WRAP_INT(wext,noise)
+LUA_WRAP_INT(wext,quality)
+LUA_WRAP_INT(wext,quality_max)
+LUA_WRAP_STRING(wext,ssid)
+LUA_WRAP_STRING(wext,bssid)
+LUA_WRAP_STRING(wext,country)
+LUA_WRAP_STRING(wext,hardware_name)
+LUA_WRAP_STRUCT(wext,mode)
+LUA_WRAP_STRUCT(wext,assoclist)
+LUA_WRAP_STRUCT(wext,txpwrlist)
+LUA_WRAP_STRUCT(wext,scanlist)
+LUA_WRAP_STRUCT(wext,freqlist)
+LUA_WRAP_STRUCT(wext,countrylist)
+LUA_WRAP_STRUCT(wext,hwmodelist)
+LUA_WRAP_STRUCT(wext,encryption)
+LUA_WRAP_STRUCT(wext,mbssid_support)
+LUA_WRAP_STRUCT(wext,hardware_id)
+
+#ifdef USE_WL
+/* Broadcom table */
+static const luaL_reg R_wl[] = {
+ LUA_REG(wl,channel),
+ LUA_REG(wl,frequency),
+ LUA_REG(wl,frequency_offset),
+ LUA_REG(wl,txpower),
+ LUA_REG(wl,txpower_offset),
+ LUA_REG(wl,bitrate),
+ LUA_REG(wl,signal),
+ LUA_REG(wl,noise),
+ LUA_REG(wl,quality),
+ LUA_REG(wl,quality_max),
+ LUA_REG(wl,mode),
+ LUA_REG(wl,ssid),
+ LUA_REG(wl,bssid),
+ LUA_REG(wl,country),
+ LUA_REG(wl,assoclist),
+ LUA_REG(wl,txpwrlist),
+ LUA_REG(wl,scanlist),
+ LUA_REG(wl,freqlist),
+ LUA_REG(wl,countrylist),
+ LUA_REG(wl,hwmodelist),
+ LUA_REG(wl,encryption),
+ LUA_REG(wl,mbssid_support),
+ LUA_REG(wl,hardware_id),
+ LUA_REG(wl,hardware_name),
+ { NULL, NULL }
+};
+#endif
+
+#ifdef USE_MADWIFI
+/* Madwifi table */
+static const luaL_reg R_madwifi[] = {
+ LUA_REG(madwifi,channel),
+ LUA_REG(madwifi,frequency),
+ LUA_REG(madwifi,frequency_offset),
+ LUA_REG(madwifi,txpower),
+ LUA_REG(madwifi,txpower_offset),
+ LUA_REG(madwifi,bitrate),
+ LUA_REG(madwifi,signal),
+ LUA_REG(madwifi,noise),
+ LUA_REG(madwifi,quality),
+ LUA_REG(madwifi,quality_max),
+ LUA_REG(madwifi,mode),
+ LUA_REG(madwifi,ssid),
+ LUA_REG(madwifi,bssid),
+ LUA_REG(madwifi,country),
+ LUA_REG(madwifi,assoclist),
+ LUA_REG(madwifi,txpwrlist),
+ LUA_REG(madwifi,scanlist),
+ LUA_REG(madwifi,freqlist),
+ LUA_REG(madwifi,countrylist),
+ LUA_REG(madwifi,hwmodelist),
+ LUA_REG(madwifi,encryption),
+ LUA_REG(madwifi,mbssid_support),
+ LUA_REG(madwifi,hardware_id),
+ LUA_REG(madwifi,hardware_name),
+ { NULL, NULL }
+};
+#endif
+
+#ifdef USE_NL80211
+/* NL80211 table */
+static const luaL_reg R_nl80211[] = {
+ LUA_REG(nl80211,channel),
+ LUA_REG(nl80211,frequency),
+ LUA_REG(nl80211,frequency_offset),
+ LUA_REG(nl80211,txpower),
+ LUA_REG(nl80211,txpower_offset),
+ LUA_REG(nl80211,bitrate),
+ LUA_REG(nl80211,signal),
+ LUA_REG(nl80211,noise),
+ LUA_REG(nl80211,quality),
+ LUA_REG(nl80211,quality_max),
+ LUA_REG(nl80211,mode),
+ LUA_REG(nl80211,ssid),
+ LUA_REG(nl80211,bssid),
+ LUA_REG(nl80211,country),
+ LUA_REG(nl80211,assoclist),
+ LUA_REG(nl80211,txpwrlist),
+ LUA_REG(nl80211,scanlist),
+ LUA_REG(nl80211,freqlist),
+ LUA_REG(nl80211,countrylist),
+ LUA_REG(nl80211,hwmodelist),
+ LUA_REG(nl80211,encryption),
+ LUA_REG(nl80211,mbssid_support),
+ LUA_REG(nl80211,hardware_id),
+ LUA_REG(nl80211,hardware_name),
+ { NULL, NULL }
+};
+#endif
+
+/* Wext table */
+static const luaL_reg R_wext[] = {
+ LUA_REG(wext,channel),
+ LUA_REG(wext,frequency),
+ LUA_REG(wext,frequency_offset),
+ LUA_REG(wext,txpower),
+ LUA_REG(wext,txpower_offset),
+ LUA_REG(wext,bitrate),
+ LUA_REG(wext,signal),
+ LUA_REG(wext,noise),
+ LUA_REG(wext,quality),
+ LUA_REG(wext,quality_max),
+ LUA_REG(wext,mode),
+ LUA_REG(wext,ssid),
+ LUA_REG(wext,bssid),
+ LUA_REG(wext,country),
+ LUA_REG(wext,assoclist),
+ LUA_REG(wext,txpwrlist),
+ LUA_REG(wext,scanlist),
+ LUA_REG(wext,freqlist),
+ LUA_REG(wext,countrylist),
+ LUA_REG(wext,hwmodelist),
+ LUA_REG(wext,encryption),
+ LUA_REG(wext,mbssid_support),
+ LUA_REG(wext,hardware_id),
+ LUA_REG(wext,hardware_name),
+ { NULL, NULL }
+};
+
+/* Common */
+static const luaL_reg R_common[] = {
+ { "type", iwinfo_L_type },
+ { "__gc", iwinfo_L__gc },
+ { NULL, NULL }
+};
+
+
+LUALIB_API int luaopen_iwinfo(lua_State *L) {
+ luaL_register(L, IWINFO_META, R_common);
+
+#ifdef USE_WL
+ luaL_newmetatable(L, IWINFO_WL_META);
+ luaL_register(L, NULL, R_wl);
+ lua_pushvalue(L, -1);
+ lua_setfield(L, -2, "__index");
+ lua_setfield(L, -2, "wl");
+#endif
+
+#ifdef USE_MADWIFI
+ luaL_newmetatable(L, IWINFO_MADWIFI_META);
+ luaL_register(L, NULL, R_madwifi);
+ lua_pushvalue(L, -1);
+ lua_setfield(L, -2, "__index");
+ lua_setfield(L, -2, "madwifi");
+#endif
+
+#ifdef USE_NL80211
+ luaL_newmetatable(L, IWINFO_NL80211_META);
+ luaL_register(L, NULL, R_nl80211);
+ lua_pushvalue(L, -1);
+ lua_setfield(L, -2, "__index");
+ lua_setfield(L, -2, "nl80211");
+#endif
+
+ luaL_newmetatable(L, IWINFO_WEXT_META);
+ luaL_register(L, NULL, R_wext);
+ lua_pushvalue(L, -1);
+ lua_setfield(L, -2, "__index");
+ lua_setfield(L, -2, "wext");
+
+ return 1;
+}
diff --git a/package/network/utils/iwinfo/src/iwinfo_madwifi.c b/package/network/utils/iwinfo/src/iwinfo_madwifi.c
new file mode 100644
index 0000000..832f40b
--- /dev/null
+++ b/package/network/utils/iwinfo/src/iwinfo_madwifi.c
@@ -0,0 +1,1082 @@
+/*
+ * iwinfo - Wireless Information Library - Madwifi Backend
+ *
+ * Copyright (C) 2009-2010 Jo-Philipp Wich <xm@subsignal.org>
+ *
+ * The iwinfo library is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * The iwinfo library 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 the iwinfo library. If not, see http://www.gnu.org/licenses/.
+ *
+ * The signal handling code is derived from the official madwifi tools,
+ * wlanconfig.c in particular. The encryption property handling was
+ * inspired by the hostapd madwifi driver.
+ */
+
+#include "iwinfo/madwifi.h"
+#include "iwinfo/wext.h"
+
+
+/*
+ * Madwifi ISO 3166 to Country/Region Code mapping.
+ */
+
+static struct ISO3166_to_CCode
+{
+ u_int16_t iso3166;
+ u_int16_t ccode;
+} CountryCodes[] = {
+ { 0x3030 /* 00 */, 0 }, /* World */
+ { 0x4145 /* AE */, 784 }, /* U.A.E. */
+ { 0x414C /* AL */, 8 }, /* Albania */
+ { 0x414D /* AM */, 51 }, /* Armenia */
+ { 0x4152 /* AR */, 32 }, /* Argentina */
+ { 0x4154 /* AT */, 40 }, /* Austria */
+ { 0x4155 /* AU */, 36 }, /* Australia */
+ { 0x415A /* AZ */, 31 }, /* Azerbaijan */
+ { 0x4245 /* BE */, 56 }, /* Belgium */
+ { 0x4247 /* BG */, 100 }, /* Bulgaria */
+ { 0x4248 /* BH */, 48 }, /* Bahrain */
+ { 0x424E /* BN */, 96 }, /* Brunei Darussalam */
+ { 0x424F /* BO */, 68 }, /* Bolivia */
+ { 0x4252 /* BR */, 76 }, /* Brazil */
+ { 0x4259 /* BY */, 112 }, /* Belarus */
+ { 0x425A /* BZ */, 84 }, /* Belize */
+ { 0x4341 /* CA */, 124 }, /* Canada */
+ { 0x4348 /* CH */, 756 }, /* Switzerland */
+ { 0x434C /* CL */, 152 }, /* Chile */
+ { 0x434E /* CN */, 156 }, /* People's Republic of China */
+ { 0x434F /* CO */, 170 }, /* Colombia */
+ { 0x4352 /* CR */, 188 }, /* Costa Rica */
+ { 0x4359 /* CY */, 196 }, /* Cyprus */
+ { 0x435A /* CZ */, 203 }, /* Czech Republic */
+ { 0x4445 /* DE */, 276 }, /* Germany */
+ { 0x444B /* DK */, 208 }, /* Denmark */
+ { 0x444F /* DO */, 214 }, /* Dominican Republic */
+ { 0x445A /* DZ */, 12 }, /* Algeria */
+ { 0x4543 /* EC */, 218 }, /* Ecuador */
+ { 0x4545 /* EE */, 233 }, /* Estonia */
+ { 0x4547 /* EG */, 818 }, /* Egypt */
+ { 0x4553 /* ES */, 724 }, /* Spain */
+ { 0x4649 /* FI */, 246 }, /* Finland */
+ { 0x464F /* FO */, 234 }, /* Faeroe Islands */
+ { 0x4652 /* FR */, 250 }, /* France */
+ { 0x4652 /* FR */, 255 }, /* France2 */
+ { 0x4742 /* GB */, 826 }, /* United Kingdom */
+ { 0x4745 /* GE */, 268 }, /* Georgia */
+ { 0x4752 /* GR */, 300 }, /* Greece */
+ { 0x4754 /* GT */, 320 }, /* Guatemala */
+ { 0x484B /* HK */, 344 }, /* Hong Kong S.A.R., P.R.C. */
+ { 0x484E /* HN */, 340 }, /* Honduras */
+ { 0x4852 /* HR */, 191 }, /* Croatia */
+ { 0x4855 /* HU */, 348 }, /* Hungary */
+ { 0x4944 /* ID */, 360 }, /* Indonesia */
+ { 0x4945 /* IE */, 372 }, /* Ireland */
+ { 0x494C /* IL */, 376 }, /* Israel */
+ { 0x494E /* IN */, 356 }, /* India */
+ { 0x4951 /* IQ */, 368 }, /* Iraq */
+ { 0x4952 /* IR */, 364 }, /* Iran */
+ { 0x4953 /* IS */, 352 }, /* Iceland */
+ { 0x4954 /* IT */, 380 }, /* Italy */
+ { 0x4A4D /* JM */, 388 }, /* Jamaica */
+ { 0x4A4F /* JO */, 400 }, /* Jordan */
+ { 0x4A50 /* JP */, 392 }, /* Japan */
+ { 0x4A50 /* JP */, 393 }, /* Japan (JP1) */
+ { 0x4A50 /* JP */, 394 }, /* Japan (JP0) */
+ { 0x4A50 /* JP */, 395 }, /* Japan (JP1-1) */
+ { 0x4A50 /* JP */, 396 }, /* Japan (JE1) */
+ { 0x4A50 /* JP */, 397 }, /* Japan (JE2) */
+ { 0x4A50 /* JP */, 399 }, /* Japan (JP6) */
+ { 0x4A50 /* JP */, 900 }, /* Japan */
+ { 0x4A50 /* JP */, 901 }, /* Japan */
+ { 0x4A50 /* JP */, 902 }, /* Japan */
+ { 0x4A50 /* JP */, 903 }, /* Japan */
+ { 0x4A50 /* JP */, 904 }, /* Japan */
+ { 0x4A50 /* JP */, 905 }, /* Japan */
+ { 0x4A50 /* JP */, 906 }, /* Japan */
+ { 0x4A50 /* JP */, 907 }, /* Japan */
+ { 0x4A50 /* JP */, 908 }, /* Japan */
+ { 0x4A50 /* JP */, 909 }, /* Japan */
+ { 0x4A50 /* JP */, 910 }, /* Japan */
+ { 0x4A50 /* JP */, 911 }, /* Japan */
+ { 0x4A50 /* JP */, 912 }, /* Japan */
+ { 0x4A50 /* JP */, 913 }, /* Japan */
+ { 0x4A50 /* JP */, 914 }, /* Japan */
+ { 0x4A50 /* JP */, 915 }, /* Japan */
+ { 0x4A50 /* JP */, 916 }, /* Japan */
+ { 0x4A50 /* JP */, 917 }, /* Japan */
+ { 0x4A50 /* JP */, 918 }, /* Japan */
+ { 0x4A50 /* JP */, 919 }, /* Japan */
+ { 0x4A50 /* JP */, 920 }, /* Japan */
+ { 0x4A50 /* JP */, 921 }, /* Japan */
+ { 0x4A50 /* JP */, 922 }, /* Japan */
+ { 0x4A50 /* JP */, 923 }, /* Japan */
+ { 0x4A50 /* JP */, 924 }, /* Japan */
+ { 0x4A50 /* JP */, 925 }, /* Japan */
+ { 0x4A50 /* JP */, 926 }, /* Japan */
+ { 0x4A50 /* JP */, 927 }, /* Japan */
+ { 0x4A50 /* JP */, 928 }, /* Japan */
+ { 0x4A50 /* JP */, 929 }, /* Japan */
+ { 0x4A50 /* JP */, 930 }, /* Japan */
+ { 0x4A50 /* JP */, 931 }, /* Japan */
+ { 0x4A50 /* JP */, 932 }, /* Japan */
+ { 0x4A50 /* JP */, 933 }, /* Japan */
+ { 0x4A50 /* JP */, 934 }, /* Japan */
+ { 0x4A50 /* JP */, 935 }, /* Japan */
+ { 0x4A50 /* JP */, 936 }, /* Japan */
+ { 0x4A50 /* JP */, 937 }, /* Japan */
+ { 0x4A50 /* JP */, 938 }, /* Japan */
+ { 0x4A50 /* JP */, 939 }, /* Japan */
+ { 0x4A50 /* JP */, 940 }, /* Japan */
+ { 0x4A50 /* JP */, 941 }, /* Japan */
+ { 0x4B45 /* KE */, 404 }, /* Kenya */
+ { 0x4B50 /* KP */, 408 }, /* North Korea */
+ { 0x4B52 /* KR */, 410 }, /* South Korea */
+ { 0x4B52 /* KR */, 411 }, /* South Korea */
+ { 0x4B57 /* KW */, 414 }, /* Kuwait */
+ { 0x4B5A /* KZ */, 398 }, /* Kazakhstan */
+ { 0x4C42 /* LB */, 422 }, /* Lebanon */
+ { 0x4C49 /* LI */, 438 }, /* Liechtenstein */
+ { 0x4C54 /* LT */, 440 }, /* Lithuania */
+ { 0x4C55 /* LU */, 442 }, /* Luxembourg */
+ { 0x4C56 /* LV */, 428 }, /* Latvia */
+ { 0x4C59 /* LY */, 434 }, /* Libya */
+ { 0x4D41 /* MA */, 504 }, /* Morocco */
+ { 0x4D43 /* MC */, 492 }, /* Principality of Monaco */
+ { 0x4D4B /* MK */, 807 }, /* the Former Yugoslav Republic of Macedonia */
+ { 0x4D4F /* MO */, 446 }, /* Macau */
+ { 0x4D58 /* MX */, 484 }, /* Mexico */
+ { 0x4D59 /* MY */, 458 }, /* Malaysia */
+ { 0x4E49 /* NI */, 558 }, /* Nicaragua */
+ { 0x4E4C /* NL */, 528 }, /* Netherlands */
+ { 0x4E4F /* NO */, 578 }, /* Norway */
+ { 0x4E5A /* NZ */, 554 }, /* New Zealand */
+ { 0x4F4D /* OM */, 512 }, /* Oman */
+ { 0x5041 /* PA */, 591 }, /* Panama */
+ { 0x5045 /* PE */, 604 }, /* Peru */
+ { 0x5048 /* PH */, 608 }, /* Republic of the Philippines */
+ { 0x504B /* PK */, 586 }, /* Islamic Republic of Pakistan */
+ { 0x504C /* PL */, 616 }, /* Poland */
+ { 0x5052 /* PR */, 630 }, /* Puerto Rico */
+ { 0x5054 /* PT */, 620 }, /* Portugal */
+ { 0x5059 /* PY */, 600 }, /* Paraguay */
+ { 0x5141 /* QA */, 634 }, /* Qatar */
+ { 0x524F /* RO */, 642 }, /* Romania */
+ { 0x5255 /* RU */, 643 }, /* Russia */
+ { 0x5341 /* SA */, 682 }, /* Saudi Arabia */
+ { 0x5345 /* SE */, 752 }, /* Sweden */
+ { 0x5347 /* SG */, 702 }, /* Singapore */
+ { 0x5349 /* SI */, 705 }, /* Slovenia */
+ { 0x534B /* SK */, 703 }, /* Slovak Republic */
+ { 0x5356 /* SV */, 222 }, /* El Salvador */
+ { 0x5359 /* SY */, 760 }, /* Syria */
+ { 0x5448 /* TH */, 764 }, /* Thailand */
+ { 0x544E /* TN */, 788 }, /* Tunisia */
+ { 0x5452 /* TR */, 792 }, /* Turkey */
+ { 0x5454 /* TT */, 780 }, /* Trinidad y Tobago */
+ { 0x5457 /* TW */, 158 }, /* Taiwan */
+ { 0x5541 /* UA */, 804 }, /* Ukraine */
+ { 0x554B /* UK */, 826 }, /* United Kingdom */
+ { 0x5553 /* US */, 840 }, /* United States */
+ { 0x5553 /* US */, 842 }, /* United States (Public Safety)*/
+ { 0x5559 /* UY */, 858 }, /* Uruguay */
+ { 0x555A /* UZ */, 860 }, /* Uzbekistan */
+ { 0x5645 /* VE */, 862 }, /* Venezuela */
+ { 0x564E /* VN */, 704 }, /* Viet Nam */
+ { 0x5945 /* YE */, 887 }, /* Yemen */
+ { 0x5A41 /* ZA */, 710 }, /* South Africa */
+ { 0x5A57 /* ZW */, 716 }, /* Zimbabwe */
+};
+
+
+static const char * madwifi_phyname(const char *ifname)
+{
+ static char phyname[IFNAMSIZ];
+
+ if (strlen(ifname) > 5 && !strncmp(ifname, "radio", 5))
+ snprintf(phyname, sizeof(phyname), "wifi%s", ifname + 5);
+ else
+ snprintf(phyname, sizeof(phyname), "%s", ifname);
+
+ return (const char *)phyname;
+}
+
+static int madwifi_wrq(struct iwreq *wrq, const char *ifname, int cmd, void *data, size_t len)
+{
+ strncpy(wrq->ifr_name, ifname, IFNAMSIZ);
+
+ if( data != NULL )
+ {
+ if( len < IFNAMSIZ )
+ {
+ memcpy(wrq->u.name, data, len);
+ }
+ else
+ {
+ wrq->u.data.pointer = data;
+ wrq->u.data.length = len;
+ }
+ }
+
+ return iwinfo_ioctl(cmd, wrq);
+}
+
+static int get80211priv(const char *ifname, int op, void *data, size_t len)
+{
+ struct iwreq iwr;
+
+ if( madwifi_wrq(&iwr, ifname, op, data, len) < 0 )
+ return -1;
+
+ return iwr.u.data.length;
+}
+
+static char * madwifi_isvap(const char *ifname, const char *wifiname)
+{
+ int fd, ln;
+ char path[32];
+ char *ret = NULL;
+ static char name[IFNAMSIZ];
+
+ if( strlen(ifname) <= 9 )
+ {
+ sprintf(path, "/proc/sys/net/%s/%%parent", ifname);
+
+ if( (fd = open(path, O_RDONLY)) > -1 )
+ {
+ if( wifiname != NULL )
+ {
+ if( read(fd, name, strlen(wifiname)) == strlen(wifiname) )
+ ret = strncmp(name, wifiname, strlen(wifiname))
+ ? NULL : name;
+ }
+ else if( (ln = read(fd, name, IFNAMSIZ)) >= 4 )
+ {
+ name[ln-1] = 0;
+ ret = name;
+ }
+
+ (void) close(fd);
+ }
+ }
+
+ return ret;
+}
+
+static int madwifi_iswifi(const char *ifname)
+{
+ int ret;
+ char path[32];
+ struct stat s;
+ const char *phy;
+
+ ret = 0;
+ phy = madwifi_phyname(ifname);
+
+ if( strlen(phy) <= 7 )
+ {
+ sprintf(path, "/proc/sys/dev/%s/diversity", phy);
+
+ if( ! stat(path, &s) )
+ ret = (s.st_mode & S_IFREG);
+ }
+
+ return ret;
+}
+
+static char * madwifi_ifadd(const char *ifname)
+{
+ const char *wifidev = NULL;
+ struct ifreq ifr = { 0 };
+ struct ieee80211_clone_params cp = { 0 };
+ static char nif[IFNAMSIZ] = { 0 };
+
+ if( !(wifidev = madwifi_isvap(ifname, NULL)) && madwifi_iswifi(ifname) )
+ wifidev = madwifi_phyname(ifname);
+
+ if( wifidev )
+ {
+ snprintf(nif, sizeof(nif), "tmp.%s", ifname);
+
+ strncpy(cp.icp_name, nif, IFNAMSIZ);
+ cp.icp_opmode = IEEE80211_M_STA;
+ cp.icp_flags = IEEE80211_CLONE_BSSID;
+
+ strncpy(ifr.ifr_name, wifidev, IFNAMSIZ);
+ ifr.ifr_data = (void *)&cp;
+
+ if( !iwinfo_ioctl(SIOC80211IFCREATE, &ifr) )
+ {
+ return nif;
+ }
+ else
+ {
+ cp.icp_opmode = IEEE80211_M_MONITOR;
+
+ if( !iwinfo_ioctl(SIOC80211IFCREATE, &ifr) )
+ return nif;
+ }
+ }
+
+ return NULL;
+}
+
+static void madwifi_ifdel(const char *ifname)
+{
+ struct ifreq ifr = { 0 };
+
+ strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
+ iwinfo_ioctl(SIOC80211IFDESTROY, &ifr);
+}
+
+
+int madwifi_probe(const char *ifname)
+{
+ return ( !!madwifi_isvap(ifname, NULL) || madwifi_iswifi(ifname) );
+}
+
+void madwifi_close(void)
+{
+ /* Nop */
+}
+
+int madwifi_get_mode(const char *ifname, int *buf)
+{
+ return wext_get_mode(ifname, buf);
+}
+
+int madwifi_get_ssid(const char *ifname, char *buf)
+{
+ return wext_get_ssid(ifname, buf);
+}
+
+int madwifi_get_bssid(const char *ifname, char *buf)
+{
+ return wext_get_bssid(ifname, buf);
+}
+
+int madwifi_get_channel(const char *ifname, int *buf)
+{
+ int i;
+ uint16_t freq;
+ struct iwreq wrq;
+ struct ieee80211req_chaninfo chans;
+
+ if( madwifi_wrq(&wrq, ifname, SIOCGIWFREQ, NULL, 0) >= 0 )
+ {
+ /* Madwifi returns a Hz frequency, get it's freq list to find channel index */
+ freq = (uint16_t)(wrq.u.freq.m / 100000);
+
+ if( get80211priv(ifname, IEEE80211_IOCTL_GETCHANINFO, &chans, sizeof(chans)) >= 0 )
+ {
+ *buf = 0;
+
+ for( i = 0; i < chans.ic_nchans; i++ )
+ {
+ if( freq == chans.ic_chans[i].ic_freq )
+ {
+ *buf = chans.ic_chans[i].ic_ieee;
+ break;
+ }
+ }
+
+ return 0;
+ }
+ }
+
+ return -1;
+}
+
+int madwifi_get_frequency(const char *ifname, int *buf)
+{
+ struct iwreq wrq;
+
+ if( madwifi_wrq(&wrq, ifname, SIOCGIWFREQ, NULL, 0) >= 0 )
+ {
+ *buf = (uint16_t)(wrq.u.freq.m / 100000);
+ return 0;
+ }
+
+ return -1;
+}
+
+int madwifi_get_txpower(const char *ifname, int *buf)
+{
+ return wext_get_txpower(ifname, buf);
+}
+
+int madwifi_get_bitrate(const char *ifname, int *buf)
+{
+ unsigned int mode, len, rate, rate_count;
+ uint8_t tmp[24*1024];
+ uint8_t *cp;
+ struct iwreq wrq;
+ struct ieee80211req_sta_info *si;
+
+ if( madwifi_wrq(&wrq, ifname, SIOCGIWMODE, NULL, 0) >= 0 )
+ {
+ mode = wrq.u.mode;
+
+ /* Calculate bitrate average from associated stations in ad-hoc mode */
+ if( mode == 1 )
+ {
+ rate = rate_count = 0;
+
+ if( (len = get80211priv(ifname, IEEE80211_IOCTL_STA_INFO, tmp, 24*1024)) > 0 )
+ {
+ cp = tmp;
+
+ do {
+ si = (struct ieee80211req_sta_info *) cp;
+
+ if( si->isi_rssi > 0 )
+ {
+ rate_count++;
+ rate += ((si->isi_rates[si->isi_txrate] & IEEE80211_RATE_VAL) / 2);
+ }
+
+ cp += si->isi_len;
+ len -= si->isi_len;
+ } while (len >= sizeof(struct ieee80211req_sta_info));
+ }
+
+ *buf = (rate == 0 || rate_count == 0) ? 0 : (rate / rate_count) * 1000;
+ return 0;
+ }
+
+ /* Return whatever wext tells us ... */
+ return wext_get_bitrate(ifname, buf);
+ }
+
+ return -1;
+}
+
+int madwifi_get_signal(const char *ifname, int *buf)
+{
+ unsigned int mode, len, rssi, rssi_count;
+ uint8_t tmp[24*1024];
+ uint8_t *cp;
+ struct iwreq wrq;
+ struct ieee80211req_sta_info *si;
+
+ if( madwifi_wrq(&wrq, ifname, SIOCGIWMODE, NULL, 0) >= 0 )
+ {
+ mode = wrq.u.mode;
+
+ /* Calculate signal average from associated stations in ap or ad-hoc mode */
+ if( mode == 1 )
+ {
+ rssi = rssi_count = 0;
+
+ if( (len = get80211priv(ifname, IEEE80211_IOCTL_STA_INFO, tmp, 24*1024)) > 0 )
+ {
+ cp = tmp;
+
+ do {
+ si = (struct ieee80211req_sta_info *) cp;
+
+ if( si->isi_rssi > 0 )
+ {
+ rssi_count++;
+ rssi -= (si->isi_rssi - 95);
+ }
+
+ cp += si->isi_len;
+ len -= si->isi_len;
+ } while (len >= sizeof(struct ieee80211req_sta_info));
+ }
+
+ *buf = (rssi == 0 || rssi_count == 0) ? 1 : -(rssi / rssi_count);
+ return 0;
+ }
+
+ /* Return whatever wext tells us ... */
+ return wext_get_signal(ifname, buf);
+ }
+
+ return -1;
+}
+
+int madwifi_get_noise(const char *ifname, int *buf)
+{
+ return wext_get_noise(ifname, buf);
+}
+
+int madwifi_get_quality(const char *ifname, int *buf)
+{
+ unsigned int mode, len, quality, quality_count;
+ uint8_t tmp[24*1024];
+ uint8_t *cp;
+ struct iwreq wrq;
+ struct ieee80211req_sta_info *si;
+
+ if( madwifi_wrq(&wrq, ifname, SIOCGIWMODE, NULL, 0) >= 0 )
+ {
+ mode = wrq.u.mode;
+
+ /* Calculate signal average from associated stations in ad-hoc mode */
+ if( mode == 1 )
+ {
+ quality = quality_count = 0;
+
+ if( (len = get80211priv(ifname, IEEE80211_IOCTL_STA_INFO, tmp, 24*1024)) > 0 )
+ {
+ cp = tmp;
+
+ do {
+ si = (struct ieee80211req_sta_info *) cp;
+
+ if( si->isi_rssi > 0 )
+ {
+ quality_count++;
+ quality += si->isi_rssi;
+ }
+
+ cp += si->isi_len;
+ len -= si->isi_len;
+ } while (len >= sizeof(struct ieee80211req_sta_info));
+ }
+
+ *buf = (quality == 0 || quality_count == 0) ? 0 : (quality / quality_count);
+ return 0;
+ }
+
+ /* Return whatever wext tells us ... */
+ return wext_get_quality(ifname, buf);
+ }
+
+ return -1;
+}
+
+int madwifi_get_quality_max(const char *ifname, int *buf)
+{
+ return wext_get_quality_max(ifname, buf);
+}
+
+int madwifi_get_encryption(const char *ifname, char *buf)
+{
+ int ciphers = 0, key_len = 0;
+ char keybuf[IW_ENCODING_TOKEN_MAX];
+ struct iwinfo_crypto_entry *c = (struct iwinfo_crypto_entry *)buf;
+ struct iwreq wrq;
+ struct ieee80211req_key wk;
+
+ memset(&wrq, 0, sizeof(wrq));
+
+ /* Obtain key info */
+ if( madwifi_wrq(&wrq, ifname, SIOCGIWENCODE, keybuf, sizeof(keybuf)) < 0 )
+ return -1;
+
+#if 0
+ /* Have any encryption? */
+ if( (wrq.u.data.flags & IW_ENCODE_DISABLED) || (wrq.u.data.length == 0) )
+ return 0;
+#endif
+
+ /* Save key len */
+ key_len = wrq.u.data.length;
+
+ /* Get wpa protocol version */
+ wrq.u.mode = IEEE80211_PARAM_WPA;
+ if( madwifi_wrq(&wrq, ifname, IEEE80211_IOCTL_GETPARAM, NULL, 0) >= 0 )
+ c->wpa_version = wrq.u.mode;
+
+ /* Get authentication suites */
+ wrq.u.mode = IEEE80211_PARAM_AUTHMODE;
+ if( madwifi_wrq(&wrq, ifname, IEEE80211_IOCTL_GETPARAM, NULL, 0) >= 0 )
+ {
+ switch(wrq.u.mode) {
+ case IEEE80211_AUTH_8021X:
+ c->auth_suites |= IWINFO_KMGMT_8021x;
+ break;
+
+ case IEEE80211_AUTH_WPA:
+ c->auth_suites |= IWINFO_KMGMT_PSK;
+ break;
+
+ case IEEE80211_AUTH_OPEN:
+ c->auth_algs |= IWINFO_AUTH_OPEN;
+ break;
+
+ case IEEE80211_AUTH_SHARED:
+ c->auth_algs |= IWINFO_AUTH_SHARED;
+ break;
+
+ default:
+ c->auth_suites |= IWINFO_KMGMT_NONE;
+ break;
+ }
+ }
+
+ memset(&wk, 0, sizeof(wk));
+ memset(wk.ik_macaddr, 0xff, IEEE80211_ADDR_LEN);
+
+ /* Get key information */
+ if( get80211priv(ifname, IEEE80211_IOCTL_GETKEY, &wk, sizeof(wk)) >= 0 )
+ {
+ /* Type 0 == WEP */
+ if( (wk.ik_type == 0) && (c->auth_algs == 0) )
+ c->auth_algs = (IWINFO_AUTH_OPEN | IWINFO_AUTH_SHARED);
+ }
+
+ /* Get used pairwise ciphers */
+ wrq.u.mode = IEEE80211_PARAM_UCASTCIPHERS;
+ if( madwifi_wrq(&wrq, ifname, IEEE80211_IOCTL_GETPARAM, NULL, 0) >= 0 )
+ {
+ ciphers = wrq.u.mode;
+
+ if( c->wpa_version && ciphers & (1 << IEEE80211_CIPHER_TKIP) )
+ c->pair_ciphers |= IWINFO_CIPHER_TKIP;
+
+ if( c->wpa_version && ciphers & (1 << IEEE80211_CIPHER_AES_CCM) )
+ c->pair_ciphers |= IWINFO_CIPHER_CCMP;
+
+ if( c->wpa_version && ciphers & (1 << IEEE80211_CIPHER_AES_OCB) )
+ c->pair_ciphers |= IWINFO_CIPHER_AESOCB;
+
+ if( c->wpa_version && ciphers & (1 << IEEE80211_CIPHER_CKIP) )
+ c->pair_ciphers |= IWINFO_CIPHER_CKIP;
+
+ if( !c->pair_ciphers && ciphers & (1 << IEEE80211_CIPHER_WEP) )
+ {
+ switch(key_len) {
+ case 13:
+ c->pair_ciphers |= IWINFO_CIPHER_WEP104;
+ break;
+
+ case 5:
+ c->pair_ciphers |= IWINFO_CIPHER_WEP40;
+ break;
+
+ case 0:
+ break;
+
+ default:
+ c->pair_ciphers = IWINFO_CIPHER_WEP40 |
+ IWINFO_CIPHER_WEP104;
+ break;
+ }
+ }
+
+ if( ciphers & (1 << IEEE80211_CIPHER_NONE) )
+ c->pair_ciphers |= IWINFO_CIPHER_NONE;
+ }
+
+ /* Get used group cipher */
+ wrq.u.mode = IEEE80211_PARAM_MCASTCIPHER;
+ if( madwifi_wrq(&wrq, ifname, IEEE80211_IOCTL_GETPARAM, NULL, 0) >= 0 )
+ {
+ ciphers = c->wpa_version ? wrq.u.mode : IEEE80211_CIPHER_WEP;
+
+ switch(ciphers) {
+ case IEEE80211_CIPHER_TKIP:
+ c->group_ciphers |= IWINFO_CIPHER_TKIP;
+ break;
+
+ case IEEE80211_CIPHER_AES_CCM:
+ c->group_ciphers |= IWINFO_CIPHER_CCMP;
+ break;
+
+ case IEEE80211_CIPHER_AES_OCB:
+ c->group_ciphers |= IWINFO_CIPHER_AESOCB;
+ break;
+
+ case IEEE80211_CIPHER_CKIP:
+ c->group_ciphers |= IWINFO_CIPHER_CKIP;
+ break;
+
+ case IEEE80211_CIPHER_WEP:
+ switch(key_len) {
+ case 13:
+ c->group_ciphers |= IWINFO_CIPHER_WEP104;
+ break;
+
+ case 5:
+ c->group_ciphers |= IWINFO_CIPHER_WEP40;
+ break;
+
+ default:
+ break;
+ }
+ break;
+
+ case IEEE80211_CIPHER_NONE:
+ c->group_ciphers |= IWINFO_CIPHER_NONE;
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ c->enabled = (c->wpa_version || (c->auth_algs && c->pair_ciphers)) ? 1 : 0;
+
+ return 0;
+}
+
+int madwifi_get_assoclist(const char *ifname, char *buf, int *len)
+{
+ int bl, tl, noise;
+ uint8_t *cp;
+ uint8_t tmp[24*1024];
+ struct ieee80211req_sta_info *si;
+ struct iwinfo_assoclist_entry entry;
+
+ if( (tl = get80211priv(ifname, IEEE80211_IOCTL_STA_INFO, tmp, 24*1024)) > 0 )
+ {
+ cp = tmp;
+ bl = 0;
+
+ if( madwifi_get_noise(ifname, &noise) )
+ noise = 0;
+
+ do {
+ si = (struct ieee80211req_sta_info *) cp;
+
+ memset(&entry, 0, sizeof(entry));
+
+ entry.signal = (si->isi_rssi - 95);
+ entry.noise = noise;
+ memcpy(entry.mac, &si->isi_macaddr, 6);
+
+ entry.inactive = si->isi_inact * 1000;
+
+ entry.tx_packets = (si->isi_txseqs[0] & IEEE80211_SEQ_SEQ_MASK)
+ >> IEEE80211_SEQ_SEQ_SHIFT;
+
+ entry.rx_packets = (si->isi_rxseqs[0] & IEEE80211_SEQ_SEQ_MASK)
+ >> IEEE80211_SEQ_SEQ_SHIFT;
+
+ entry.tx_rate.rate =
+ (si->isi_rates[si->isi_txrate] & IEEE80211_RATE_VAL) * 500;
+
+ /* XXX: this is just a guess */
+ entry.rx_rate.rate = entry.tx_rate.rate;
+
+ entry.rx_rate.mcs = -1;
+ entry.tx_rate.mcs = -1;
+
+ memcpy(&buf[bl], &entry, sizeof(struct iwinfo_assoclist_entry));
+
+ bl += sizeof(struct iwinfo_assoclist_entry);
+ cp += si->isi_len;
+ tl -= si->isi_len;
+ } while (tl >= sizeof(struct ieee80211req_sta_info));
+
+ *len = bl;
+ return 0;
+ }
+
+ return -1;
+}
+
+int madwifi_get_txpwrlist(const char *ifname, char *buf, int *len)
+{
+ int rc = -1;
+ char *res;
+
+ /* A wifiX device? */
+ if( madwifi_iswifi(ifname) )
+ {
+ if( (res = madwifi_ifadd(ifname)) != NULL )
+ {
+ rc = wext_get_txpwrlist(res, buf, len);
+ madwifi_ifdel(res);
+ }
+ }
+
+ /* Its an athX ... */
+ else if( !!madwifi_isvap(ifname, NULL) )
+ {
+ rc = wext_get_txpwrlist(ifname, buf, len);
+ }
+
+ return rc;
+}
+
+int madwifi_get_scanlist(const char *ifname, char *buf, int *len)
+{
+ int ret;
+ char *res;
+ DIR *proc;
+ struct dirent *e;
+
+ ret = -1;
+
+ /* We got a wifiX device passed, try to lookup a vap on it */
+ if( madwifi_iswifi(ifname) )
+ {
+ if( (proc = opendir("/proc/sys/net/")) != NULL )
+ {
+ while( (e = readdir(proc)) != NULL )
+ {
+ if( !!madwifi_isvap(e->d_name, ifname) )
+ {
+ if( iwinfo_ifup(e->d_name) )
+ {
+ ret = wext_get_scanlist(e->d_name, buf, len);
+ break;
+ }
+ }
+ }
+
+ closedir(proc);
+ }
+
+ /* Still nothing found, try to create a vap */
+ if( ret == -1 )
+ {
+ if( (res = madwifi_ifadd(ifname)) != NULL )
+ {
+ if( iwinfo_ifup(res) )
+ {
+ wext_get_scanlist(res, buf, len);
+ sleep(1);
+
+ wext_get_scanlist(res, buf, len);
+ sleep(1);
+
+ ret = wext_get_scanlist(res, buf, len);
+ }
+
+ iwinfo_ifdown(res);
+ madwifi_ifdel(res);
+ }
+ }
+ }
+
+ /* Got athX device? */
+ else if( !!madwifi_isvap(ifname, NULL) )
+ {
+ ret = wext_get_scanlist(ifname, buf, len);
+ }
+
+ return ret;
+}
+
+int madwifi_get_freqlist(const char *ifname, char *buf, int *len)
+{
+ int i, bl;
+ int rc = -1;
+ char *res;
+ struct ieee80211req_chaninfo chans;
+ struct iwinfo_freqlist_entry entry;
+
+ /* A wifiX device? */
+ if( madwifi_iswifi(ifname) )
+ {
+ if( (res = madwifi_ifadd(ifname)) != NULL )
+ {
+ rc = get80211priv(res, IEEE80211_IOCTL_GETCHANINFO,
+ &chans, sizeof(chans));
+
+ madwifi_ifdel(res);
+ }
+ }
+
+ /* Its an athX ... */
+ else if( !!madwifi_isvap(ifname, NULL) )
+ {
+ rc = get80211priv(ifname, IEEE80211_IOCTL_GETCHANINFO,
+ &chans, sizeof(chans));
+ }
+
+
+ /* Got chaninfo? */
+ if( rc >= 0 )
+ {
+ bl = 0;
+
+ for( i = 0; i < chans.ic_nchans; i++ )
+ {
+ entry.mhz = chans.ic_chans[i].ic_freq;
+ entry.channel = chans.ic_chans[i].ic_ieee;
+ entry.restricted = 0;
+
+ memcpy(&buf[bl], &entry, sizeof(struct iwinfo_freqlist_entry));
+ bl += sizeof(struct iwinfo_freqlist_entry);
+ }
+
+ *len = bl;
+ return 0;
+ }
+
+ return -1;
+}
+
+int madwifi_get_country(const char *ifname, char *buf)
+{
+ int i, fd, ccode = -1;
+ char buffer[34];
+ char *wifi = madwifi_iswifi(ifname)
+ ? (char *)ifname : madwifi_isvap(ifname, NULL);
+
+ struct ISO3166_to_CCode *e;
+
+ if( wifi )
+ {
+ snprintf(buffer, sizeof(buffer), "/proc/sys/dev/%s/countrycode", wifi);
+
+ if( (fd = open(buffer, O_RDONLY)) > -1 )
+ {
+ memset(buffer, 0, sizeof(buffer));
+
+ if( read(fd, buffer, sizeof(buffer)-1) > 0 )
+ ccode = atoi(buffer);
+
+ close(fd);
+ }
+ }
+
+ for( i = 0; i < (sizeof(CountryCodes)/sizeof(CountryCodes[0])); i++ )
+ {
+ e = &CountryCodes[i];
+
+ if( e->ccode == ccode )
+ {
+ sprintf(buf, "%c%c", e->iso3166 / 256, e->iso3166 % 256);
+ return 0;
+ }
+ }
+
+ return -1;
+}
+
+int madwifi_get_countrylist(const char *ifname, char *buf, int *len)
+{
+ int i, count;
+ struct ISO3166_to_CCode *e, *p = NULL;
+ struct iwinfo_country_entry *c = (struct iwinfo_country_entry *)buf;
+
+ count = 0;
+
+ for( int i = 0; i < (sizeof(CountryCodes)/sizeof(CountryCodes[0])); i++ )
+ {
+ e = &CountryCodes[i];
+
+ if( !p || (e->iso3166 != p->iso3166) )
+ {
+ c->iso3166 = e->iso3166;
+ snprintf(c->ccode, sizeof(c->ccode), "%i", e->ccode);
+
+ c++;
+ count++;
+ }
+
+ p = e;
+ }
+
+ *len = (count * sizeof(struct iwinfo_country_entry));
+ return 0;
+}
+
+int madwifi_get_hwmodelist(const char *ifname, int *buf)
+{
+ char chans[IWINFO_BUFSIZE] = { 0 };
+ struct iwinfo_freqlist_entry *e = NULL;
+ int len = 0;
+
+ if( !madwifi_get_freqlist(ifname, chans, &len) )
+ {
+ for( e = (struct iwinfo_freqlist_entry *)chans; e->channel; e++ )
+ {
+ if( e->channel <= 14 )
+ {
+ *buf |= IWINFO_80211_B;
+ *buf |= IWINFO_80211_G;
+ }
+ else
+ {
+ *buf |= IWINFO_80211_A;
+ }
+ }
+
+ return 0;
+ }
+
+ return -1;
+}
+
+int madwifi_get_mbssid_support(const char *ifname, int *buf)
+{
+ /* Test whether we can create another interface */
+ char *nif = madwifi_ifadd(ifname);
+
+ if( nif )
+ {
+ *buf = iwinfo_ifup(nif);
+
+ iwinfo_ifdown(nif);
+ madwifi_ifdel(nif);
+
+ return 0;
+ }
+
+ return -1;
+}
+
+int madwifi_get_hardware_id(const char *ifname, char *buf)
+{
+ char vendor[64];
+ char device[64];
+ struct iwinfo_hardware_id *ids;
+ struct iwinfo_hardware_entry *e;
+ const char *phy = madwifi_phyname(ifname);
+
+ if (wext_get_hardware_id(phy, buf))
+ return iwinfo_hardware_id_from_mtd((struct iwinfo_hardware_id *)buf);
+
+ return 0;
+}
+
+static const struct iwinfo_hardware_entry *
+madwifi_get_hardware_entry(const char *ifname)
+{
+ struct iwinfo_hardware_id id;
+
+ if (madwifi_get_hardware_id(ifname, (char *)&id))
+ return NULL;
+
+ return iwinfo_hardware(&id);
+}
+
+int madwifi_get_hardware_name(const char *ifname, char *buf)
+{
+ const struct iwinfo_hardware_entry *hw;
+
+ if (!(hw = madwifi_get_hardware_entry(ifname)))
+ sprintf(buf, "Generic Atheros");
+ else
+ sprintf(buf, "%s %s", hw->vendor_name, hw->device_name);
+
+ return 0;
+}
+
+int madwifi_get_txpower_offset(const char *ifname, int *buf)
+{
+ const struct iwinfo_hardware_entry *hw;
+
+ if (!(hw = madwifi_get_hardware_entry(ifname)))
+ return -1;
+
+ *buf = hw->txpower_offset;
+ return 0;
+}
+
+int madwifi_get_frequency_offset(const char *ifname, int *buf)
+{
+ const struct iwinfo_hardware_entry *hw;
+
+ if (!(hw = madwifi_get_hardware_entry(ifname)))
+ return -1;
+
+ *buf = hw->frequency_offset;
+ return 0;
+}
diff --git a/package/network/utils/iwinfo/src/iwinfo_nl80211.c b/package/network/utils/iwinfo/src/iwinfo_nl80211.c
new file mode 100644
index 0000000..819845a
--- /dev/null
+++ b/package/network/utils/iwinfo/src/iwinfo_nl80211.c
@@ -0,0 +1,2246 @@
+/*
+ * iwinfo - Wireless Information Library - NL80211 Backend
+ *
+ * Copyright (C) 2010-2013 Jo-Philipp Wich <xm@subsignal.org>
+ *
+ * The iwinfo library is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * The iwinfo library 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 the iwinfo library. If not, see http://www.gnu.org/licenses/.
+ *
+ * The signal handling code is derived from the official madwifi tools,
+ * wlanconfig.c in particular. The encryption property handling was
+ * inspired by the hostapd madwifi driver.
+ *
+ * Parts of this code are derived from the Linux iw utility.
+ */
+
+#include "iwinfo/nl80211.h"
+#include "iwinfo/wext.h"
+
+#define min(x, y) ((x) < (y)) ? (x) : (y)
+
+static struct nl80211_state *nls = NULL;
+
+static int nl80211_init(void)
+{
+ int err, fd;
+
+ if (!nls)
+ {
+ nls = malloc(sizeof(struct nl80211_state));
+ if (!nls) {
+ err = -ENOMEM;
+ goto err;
+ }
+
+ memset(nls, 0, sizeof(*nls));
+
+ nls->nl_sock = nl_socket_alloc();
+ if (!nls->nl_sock) {
+ err = -ENOMEM;
+ goto err;
+ }
+
+ if (genl_connect(nls->nl_sock)) {
+ err = -ENOLINK;
+ goto err;
+ }
+
+ fd = nl_socket_get_fd(nls->nl_sock);
+ if (fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC) < 0) {
+ err = -EINVAL;
+ goto err;
+ }
+
+ if (genl_ctrl_alloc_cache(nls->nl_sock, &nls->nl_cache)) {
+ err = -ENOMEM;
+ goto err;
+ }
+
+ nls->nl80211 = genl_ctrl_search_by_name(nls->nl_cache, "nl80211");
+ if (!nls->nl80211) {
+ err = -ENOENT;
+ goto err;
+ }
+
+ nls->nlctrl = genl_ctrl_search_by_name(nls->nl_cache, "nlctrl");
+ if (!nls->nlctrl) {
+ err = -ENOENT;
+ goto err;
+ }
+ }
+
+ return 0;
+
+
+err:
+ nl80211_close();
+ return err;
+}
+
+
+static int nl80211_msg_error(struct sockaddr_nl *nla,
+ struct nlmsgerr *err, void *arg)
+{
+ int *ret = arg;
+ *ret = err->error;
+ return NL_STOP;
+}
+
+static int nl80211_msg_finish(struct nl_msg *msg, void *arg)
+{
+ int *ret = arg;
+ *ret = 0;
+ return NL_SKIP;
+}
+
+static int nl80211_msg_ack(struct nl_msg *msg, void *arg)
+{
+ int *ret = arg;
+ *ret = 0;
+ return NL_STOP;
+}
+
+static int nl80211_msg_response(struct nl_msg *msg, void *arg)
+{
+ return NL_SKIP;
+}
+
+static void nl80211_free(struct nl80211_msg_conveyor *cv)
+{
+ if (cv)
+ {
+ if (cv->cb)
+ nl_cb_put(cv->cb);
+
+ if (cv->msg)
+ nlmsg_free(cv->msg);
+
+ cv->cb = NULL;
+ cv->msg = NULL;
+ }
+}
+
+static struct nl80211_msg_conveyor * nl80211_new(struct genl_family *family,
+ int cmd, int flags)
+{
+ static struct nl80211_msg_conveyor cv;
+
+ struct nl_msg *req = NULL;
+ struct nl_cb *cb = NULL;
+
+ req = nlmsg_alloc();
+ if (!req)
+ goto err;
+
+ cb = nl_cb_alloc(NL_CB_DEFAULT);
+ if (!cb)
+ goto err;
+
+ genlmsg_put(req, 0, 0, genl_family_get_id(family), 0, flags, cmd, 0);
+
+ cv.msg = req;
+ cv.cb = cb;
+
+ return &cv;
+
+err:
+nla_put_failure:
+ if (cb)
+ nl_cb_put(cb);
+
+ if (req)
+ nlmsg_free(req);
+
+ return NULL;
+}
+
+static struct nl80211_msg_conveyor * nl80211_ctl(int cmd, int flags)
+{
+ if (nl80211_init() < 0)
+ return NULL;
+
+ return nl80211_new(nls->nlctrl, cmd, flags);
+}
+
+static struct nl80211_msg_conveyor * nl80211_msg(const char *ifname,
+ int cmd, int flags)
+{
+ int ifidx = -1, phyidx = -1;
+ struct nl80211_msg_conveyor *cv;
+
+ if (nl80211_init() < 0)
+ return NULL;
+
+ if (!strncmp(ifname, "phy", 3))
+ phyidx = atoi(&ifname[3]);
+ else if (!strncmp(ifname, "radio", 5))
+ phyidx = atoi(&ifname[5]);
+ else if (!strncmp(ifname, "mon.", 4))
+ ifidx = if_nametoindex(&ifname[4]);
+ else
+ ifidx = if_nametoindex(ifname);
+
+ if ((ifidx < 0) && (phyidx < 0))
+ return NULL;
+
+ cv = nl80211_new(nls->nl80211, cmd, flags);
+ if (!cv)
+ return NULL;
+
+ if (ifidx > -1)
+ NLA_PUT_U32(cv->msg, NL80211_ATTR_IFINDEX, ifidx);
+
+ if (phyidx > -1)
+ NLA_PUT_U32(cv->msg, NL80211_ATTR_WIPHY, phyidx);
+
+ return cv;
+
+nla_put_failure:
+ nl80211_free(cv);
+ return NULL;
+}
+
+static struct nl80211_msg_conveyor * nl80211_send(
+ struct nl80211_msg_conveyor *cv,
+ int (*cb_func)(struct nl_msg *, void *), void *cb_arg
+) {
+ static struct nl80211_msg_conveyor rcv;
+ int err = 1;
+
+ if (cb_func)
+ nl_cb_set(cv->cb, NL_CB_VALID, NL_CB_CUSTOM, cb_func, cb_arg);
+ else
+ nl_cb_set(cv->cb, NL_CB_VALID, NL_CB_CUSTOM, nl80211_msg_response, &rcv);
+
+ if (nl_send_auto_complete(nls->nl_sock, cv->msg) < 0)
+ goto err;
+
+ nl_cb_err(cv->cb, NL_CB_CUSTOM, nl80211_msg_error, &err);
+ nl_cb_set(cv->cb, NL_CB_FINISH, NL_CB_CUSTOM, nl80211_msg_finish, &err);
+ nl_cb_set(cv->cb, NL_CB_ACK, NL_CB_CUSTOM, nl80211_msg_ack, &err);
+
+ while (err > 0)
+ nl_recvmsgs(nls->nl_sock, cv->cb);
+
+ return &rcv;
+
+err:
+ nl_cb_put(cv->cb);
+ nlmsg_free(cv->msg);
+
+ return NULL;
+}
+
+static struct nlattr ** nl80211_parse(struct nl_msg *msg)
+{
+ struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
+ static struct nlattr *attr[NL80211_ATTR_MAX + 1];
+
+ nla_parse(attr, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
+ genlmsg_attrlen(gnlh, 0), NULL);
+
+ return attr;
+}
+
+
+static int nl80211_subscribe_cb(struct nl_msg *msg, void *arg)
+{
+ struct nl80211_group_conveyor *cv = arg;
+
+ struct nlattr **attr = nl80211_parse(msg);
+ struct nlattr *mgrpinfo[CTRL_ATTR_MCAST_GRP_MAX + 1];
+ struct nlattr *mgrp;
+ int mgrpidx;
+
+ if (!attr[CTRL_ATTR_MCAST_GROUPS])
+ return NL_SKIP;
+
+ nla_for_each_nested(mgrp, attr[CTRL_ATTR_MCAST_GROUPS], mgrpidx)
+ {
+ nla_parse(mgrpinfo, CTRL_ATTR_MCAST_GRP_MAX,
+ nla_data(mgrp), nla_len(mgrp), NULL);
+
+ if (mgrpinfo[CTRL_ATTR_MCAST_GRP_ID] &&
+ mgrpinfo[CTRL_ATTR_MCAST_GRP_NAME] &&
+ !strncmp(nla_data(mgrpinfo[CTRL_ATTR_MCAST_GRP_NAME]),
+ cv->name, nla_len(mgrpinfo[CTRL_ATTR_MCAST_GRP_NAME])))
+ {
+ cv->id = nla_get_u32(mgrpinfo[CTRL_ATTR_MCAST_GRP_ID]);
+ break;
+ }
+ }
+
+ return NL_SKIP;
+}
+
+static int nl80211_subscribe(const char *family, const char *group)
+{
+ struct nl80211_group_conveyor cv = { .name = group, .id = -ENOENT };
+ struct nl80211_msg_conveyor *req;
+
+ req = nl80211_ctl(CTRL_CMD_GETFAMILY, 0);
+ if (req)
+ {
+ NLA_PUT_STRING(req->msg, CTRL_ATTR_FAMILY_NAME, family);
+ nl80211_send(req, nl80211_subscribe_cb, &cv);
+
+nla_put_failure:
+ nl80211_free(req);
+ }
+
+ return nl_socket_add_membership(nls->nl_sock, cv.id);
+}
+
+
+static int nl80211_wait_cb(struct nl_msg *msg, void *arg)
+{
+ struct nl80211_event_conveyor *cv = arg;
+ struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
+
+ if (gnlh->cmd == cv->wait)
+ cv->recv = gnlh->cmd;
+
+ return NL_SKIP;
+}
+
+static int nl80211_wait_seq_check(struct nl_msg *msg, void *arg)
+{
+ return NL_OK;
+}
+
+static int nl80211_wait(const char *family, const char *group, int cmd)
+{
+ struct nl80211_event_conveyor cv = { .wait = cmd };
+ struct nl_cb *cb;
+
+ if (nl80211_subscribe(family, group))
+ return -ENOENT;
+
+ cb = nl_cb_alloc(NL_CB_DEFAULT);
+
+ if (!cb)
+ return -ENOMEM;
+
+ nl_cb_set(cb, NL_CB_SEQ_CHECK, NL_CB_CUSTOM, nl80211_wait_seq_check, NULL);
+ nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, nl80211_wait_cb, &cv );
+
+ while (!cv.recv)
+ nl_recvmsgs(nls->nl_sock, cb);
+
+ nl_cb_put(cb);
+
+ return 0;
+}
+
+
+static int nl80211_freq2channel(int freq)
+{
+ if (freq == 2484)
+ return 14;
+
+ if (freq < 2484)
+ return (freq - 2407) / 5;
+
+ return (freq / 5) - 1000;
+}
+
+static int nl80211_channel2freq(int channel, const char *band)
+{
+ if (channel == 14)
+ return 2484;
+
+ if ((channel < 14) && (!band || band[0] != 'a'))
+ return (channel * 5) + 2407;
+
+ if (channel > 0)
+ return (1000 + channel) * 5;
+
+ return 0;
+}
+
+static char * nl80211_getval(const char *ifname, const char *buf, const char *key)
+{
+ int i, len;
+ char lkey[64] = { 0 };
+ const char *ln = buf;
+ static char lval[256] = { 0 };
+
+ int matched_if = ifname ? 0 : 1;
+
+
+ for( i = 0, len = strlen(buf); i < len; i++ )
+ {
+ if (!lkey[0] && (buf[i] == ' ' || buf[i] == '\t'))
+ {
+ ln++;
+ }
+ else if (!lkey[0] && (buf[i] == '='))
+ {
+ if ((&buf[i] - ln) > 0)
+ memcpy(lkey, ln, min(sizeof(lkey) - 1, &buf[i] - ln));
+ }
+ else if (buf[i] == '\n')
+ {
+ if (lkey[0])
+ {
+ memcpy(lval, ln + strlen(lkey) + 1,
+ min(sizeof(lval) - 1, &buf[i] - ln - strlen(lkey) - 1));
+
+ if ((ifname != NULL) &&
+ (!strcmp(lkey, "interface") || !strcmp(lkey, "bss")) )
+ {
+ matched_if = !strcmp(lval, ifname);
+ }
+ else if (matched_if && !strcmp(lkey, key))
+ {
+ return lval;
+ }
+ }
+
+ ln = &buf[i+1];
+ memset(lkey, 0, sizeof(lkey));
+ memset(lval, 0, sizeof(lval));
+ }
+ }
+
+ return NULL;
+}
+
+static int nl80211_ifname2phy_cb(struct nl_msg *msg, void *arg)
+{
+ char *buf = arg;
+ struct nlattr **attr = nl80211_parse(msg);
+
+ if (attr[NL80211_ATTR_WIPHY_NAME])
+ memcpy(buf, nla_data(attr[NL80211_ATTR_WIPHY_NAME]),
+ nla_len(attr[NL80211_ATTR_WIPHY_NAME]));
+ else
+ buf[0] = 0;
+
+ return NL_SKIP;
+}
+
+static char * nl80211_ifname2phy(const char *ifname)
+{
+ static char phy[32] = { 0 };
+ struct nl80211_msg_conveyor *req;
+
+ memset(phy, 0, sizeof(phy));
+
+ req = nl80211_msg(ifname, NL80211_CMD_GET_WIPHY, 0);
+ if (req)
+ {
+ nl80211_send(req, nl80211_ifname2phy_cb, phy);
+ nl80211_free(req);
+ }
+
+ return phy[0] ? phy : NULL;
+}
+
+static char * nl80211_hostapd_info(const char *ifname)
+{
+ int mode;
+ char *phy;
+ char path[32] = { 0 };
+ static char buf[4096] = { 0 };
+ FILE *conf;
+
+ if (nl80211_get_mode(ifname, &mode))
+ return NULL;
+
+ if ((mode == IWINFO_OPMODE_MASTER || mode == IWINFO_OPMODE_AP_VLAN) &&
+ (phy = nl80211_ifname2phy(ifname)) != NULL)
+ {
+ snprintf(path, sizeof(path), "/var/run/hostapd-%s.conf", phy);
+
+ if ((conf = fopen(path, "r")) != NULL)
+ {
+ fread(buf, sizeof(buf) - 1, 1, conf);
+ fclose(conf);
+
+ return buf;
+ }
+ }
+
+ return NULL;
+}
+
+static inline int nl80211_wpactl_recv(int sock, char *buf, int blen)
+{
+ fd_set rfds;
+ struct timeval tv = { 2, 0 };
+
+ FD_ZERO(&rfds);
+ FD_SET(sock, &rfds);
+
+ memset(buf, 0, blen);
+
+
+ if (select(sock + 1, &rfds, NULL, NULL, &tv) < 0)
+ return -1;
+
+ if (!FD_ISSET(sock, &rfds))
+ return -1;
+
+ return recv(sock, buf, blen, 0);
+}
+
+static char * nl80211_wpactl_info(const char *ifname, const char *cmd,
+ const char *event)
+{
+ int numtry = 0;
+ int sock = -1;
+ char *rv = NULL;
+ size_t remote_length, local_length;
+ static char buffer[10240] = { 0 };
+
+ struct sockaddr_un local = { 0 };
+ struct sockaddr_un remote = { 0 };
+
+
+ sock = socket(PF_UNIX, SOCK_DGRAM, 0);
+ if (sock < 0)
+ return NULL;
+
+ remote.sun_family = AF_UNIX;
+ remote_length = sizeof(remote.sun_family) + sprintf(remote.sun_path,
+ "/var/run/wpa_supplicant-%s/%s", ifname, ifname);
+
+ if (fcntl(sock, F_SETFD, fcntl(sock, F_GETFD) | FD_CLOEXEC) < 0)
+ goto out;
+
+ if (connect(sock, (struct sockaddr *) &remote, remote_length))
+ goto out;
+
+ local.sun_family = AF_UNIX;
+ local_length = sizeof(local.sun_family) +
+ sprintf(local.sun_path, "/var/run/iwinfo-%s-%d", ifname, getpid());
+
+ if (bind(sock, (struct sockaddr *) &local, local_length))
+ goto out;
+
+
+ if (event)
+ {
+ send(sock, "ATTACH", 6, 0);
+
+ if (nl80211_wpactl_recv(sock, buffer, sizeof(buffer)) <= 0)
+ goto out;
+ }
+
+
+ send(sock, cmd, strlen(cmd), 0);
+
+ while( numtry++ < 5 )
+ {
+ if (nl80211_wpactl_recv(sock, buffer, sizeof(buffer)) <= 0)
+ {
+ if (event)
+ continue;
+
+ break;
+ }
+
+ if ((!event && buffer[0] != '<') || (event && strstr(buffer, event)))
+ break;
+ }
+
+ rv = buffer;
+
+out:
+ close(sock);
+
+ if (local.sun_family)
+ unlink(local.sun_path);
+
+ return rv;
+}
+
+static inline int nl80211_readint(const char *path)
+{
+ int fd;
+ int rv = -1;
+ char buffer[16];
+
+ if ((fd = open(path, O_RDONLY)) > -1)
+ {
+ if (read(fd, buffer, sizeof(buffer)) > 0)
+ rv = atoi(buffer);
+
+ close(fd);
+ }
+
+ return rv;
+}
+
+static char * nl80211_phy2ifname(const char *ifname)
+{
+ int fd, ifidx = -1, cifidx = -1, phyidx = -1;
+ char buffer[64];
+ static char nif[IFNAMSIZ] = { 0 };
+
+ DIR *d;
+ struct dirent *e;
+
+ if (!ifname)
+ return NULL;
+ else if (!strncmp(ifname, "phy", 3))
+ phyidx = atoi(&ifname[3]);
+ else if (!strncmp(ifname, "radio", 5))
+ phyidx = atoi(&ifname[5]);
+
+ memset(nif, 0, sizeof(nif));
+
+ if (phyidx > -1)
+ {
+ if ((d = opendir("/sys/class/net")) != NULL)
+ {
+ while ((e = readdir(d)) != NULL)
+ {
+ snprintf(buffer, sizeof(buffer),
+ "/sys/class/net/%s/phy80211/index", e->d_name);
+
+ if (nl80211_readint(buffer) == phyidx)
+ {
+ snprintf(buffer, sizeof(buffer),
+ "/sys/class/net/%s/ifindex", e->d_name);
+
+ if ((cifidx = nl80211_readint(buffer)) >= 0 &&
+ ((ifidx < 0) || (cifidx < ifidx)))
+ {
+ ifidx = cifidx;
+ strncpy(nif, e->d_name, sizeof(nif));
+ }
+ }
+ }
+
+ closedir(d);
+ }
+ }
+
+ return nif[0] ? nif : NULL;
+}
+
+static char * nl80211_ifadd(const char *ifname)
+{
+ int phyidx;
+ char *rv = NULL;
+ static char nif[IFNAMSIZ] = { 0 };
+ struct nl80211_msg_conveyor *req, *res;
+
+ req = nl80211_msg(ifname, NL80211_CMD_NEW_INTERFACE, 0);
+ if (req)
+ {
+ snprintf(nif, sizeof(nif), "tmp.%s", ifname);
+
+ NLA_PUT_STRING(req->msg, NL80211_ATTR_IFNAME, nif);
+ NLA_PUT_U32(req->msg, NL80211_ATTR_IFTYPE, NL80211_IFTYPE_STATION);
+
+ nl80211_send(req, NULL, NULL);
+
+ rv = nif;
+
+ nla_put_failure:
+ nl80211_free(req);
+ }
+
+ return rv;
+}
+
+static void nl80211_ifdel(const char *ifname)
+{
+ struct nl80211_msg_conveyor *req;
+
+ req = nl80211_msg(ifname, NL80211_CMD_DEL_INTERFACE, 0);
+ if (req)
+ {
+ NLA_PUT_STRING(req->msg, NL80211_ATTR_IFNAME, ifname);
+
+ nl80211_send(req, NULL, NULL);
+
+ nla_put_failure:
+ nl80211_free(req);
+ }
+}
+
+static void nl80211_hostapd_hup(const char *ifname)
+{
+ int fd, pid = 0;
+ char buf[32];
+ char *phy = nl80211_ifname2phy(ifname);
+
+ if (phy)
+ {
+ snprintf(buf, sizeof(buf), "/var/run/wifi-%s.pid", phy);
+ if ((fd = open(buf, O_RDONLY)) > 0)
+ {
+ if (read(fd, buf, sizeof(buf)) > 0)
+ pid = atoi(buf);
+
+ close(fd);
+ }
+
+ if (pid > 0)
+ kill(pid, 1);
+ }
+}
+
+
+int nl80211_probe(const char *ifname)
+{
+ return !!nl80211_ifname2phy(ifname);
+}
+
+void nl80211_close(void)
+{
+ if (nls)
+ {
+ if (nls->nlctrl)
+ genl_family_put(nls->nlctrl);
+
+ if (nls->nl80211)
+ genl_family_put(nls->nl80211);
+
+ if (nls->nl_sock)
+ nl_socket_free(nls->nl_sock);
+
+ if (nls->nl_cache)
+ nl_cache_free(nls->nl_cache);
+
+ free(nls);
+ nls = NULL;
+ }
+}
+
+
+static int nl80211_get_mode_cb(struct nl_msg *msg, void *arg)
+{
+ int *mode = arg;
+ struct nlattr **tb = nl80211_parse(msg);
+ const int ifmodes[NL80211_IFTYPE_MAX + 1] = {
+ IWINFO_OPMODE_UNKNOWN, /* unspecified */
+ IWINFO_OPMODE_ADHOC, /* IBSS */
+ IWINFO_OPMODE_CLIENT, /* managed */
+ IWINFO_OPMODE_MASTER, /* AP */
+ IWINFO_OPMODE_AP_VLAN, /* AP/VLAN */
+ IWINFO_OPMODE_WDS, /* WDS */
+ IWINFO_OPMODE_MONITOR, /* monitor */
+ IWINFO_OPMODE_MESHPOINT, /* mesh point */
+ IWINFO_OPMODE_P2P_CLIENT, /* P2P-client */
+ IWINFO_OPMODE_P2P_GO, /* P2P-GO */
+ };
+
+ if (tb[NL80211_ATTR_IFTYPE])
+ *mode = ifmodes[nla_get_u32(tb[NL80211_ATTR_IFTYPE])];
+
+ return NL_SKIP;
+}
+
+int nl80211_get_mode(const char *ifname, int *buf)
+{
+ char *res;
+ struct nl80211_msg_conveyor *req;
+
+ res = nl80211_phy2ifname(ifname);
+ req = nl80211_msg(res ? res : ifname, NL80211_CMD_GET_INTERFACE, 0);
+ *buf = IWINFO_OPMODE_UNKNOWN;
+
+ if (req)
+ {
+ nl80211_send(req, nl80211_get_mode_cb, buf);
+ nl80211_free(req);
+ }
+
+ return (*buf == IWINFO_OPMODE_UNKNOWN) ? -1 : 0;
+}
+
+
+struct nl80211_ssid_bssid {
+ unsigned char *ssid;
+ unsigned char bssid[7];
+};
+
+static int nl80211_get_ssid_bssid_cb(struct nl_msg *msg, void *arg)
+{
+ int ielen;
+ unsigned char *ie;
+ struct nl80211_ssid_bssid *sb = arg;
+ struct nlattr **tb = nl80211_parse(msg);
+ struct nlattr *bss[NL80211_BSS_MAX + 1];
+
+ static struct nla_policy bss_policy[NL80211_BSS_MAX + 1] = {
+ [NL80211_BSS_INFORMATION_ELEMENTS] = { },
+ [NL80211_BSS_STATUS] = { .type = NLA_U32 },
+ };
+
+ if (!tb[NL80211_ATTR_BSS] ||
+ nla_parse_nested(bss, NL80211_BSS_MAX, tb[NL80211_ATTR_BSS],
+ bss_policy) ||
+ !bss[NL80211_BSS_BSSID] ||
+ !bss[NL80211_BSS_STATUS] ||
+ !bss[NL80211_BSS_INFORMATION_ELEMENTS])
+ {
+ return NL_SKIP;
+ }
+
+ switch (nla_get_u32(bss[NL80211_BSS_STATUS]))
+ {
+ case NL80211_BSS_STATUS_ASSOCIATED:
+ case NL80211_BSS_STATUS_AUTHENTICATED:
+ case NL80211_BSS_STATUS_IBSS_JOINED:
+
+ if (sb->ssid)
+ {
+ ie = nla_data(bss[NL80211_BSS_INFORMATION_ELEMENTS]);
+ ielen = nla_len(bss[NL80211_BSS_INFORMATION_ELEMENTS]);
+
+ while (ielen >= 2 && ielen >= ie[1])
+ {
+ if (ie[0] == 0)
+ {
+ memcpy(sb->ssid, ie + 2, min(ie[1], IWINFO_ESSID_MAX_SIZE));
+ return NL_SKIP;
+ }
+
+ ielen -= ie[1] + 2;
+ ie += ie[1] + 2;
+ }
+ }
+ else
+ {
+ sb->bssid[0] = 1;
+ memcpy(sb->bssid + 1, nla_data(bss[NL80211_BSS_BSSID]), 6);
+ return NL_SKIP;
+ }
+
+ default:
+ return NL_SKIP;
+ }
+}
+
+int nl80211_get_ssid(const char *ifname, char *buf)
+{
+ char *res;
+ struct nl80211_msg_conveyor *req;
+ struct nl80211_ssid_bssid sb;
+
+ /* try to find ssid from scan dump results */
+ res = nl80211_phy2ifname(ifname);
+ req = nl80211_msg(res ? res : ifname, NL80211_CMD_GET_SCAN, NLM_F_DUMP);
+
+ sb.ssid = buf;
+ *buf = 0;
+
+ if (req)
+ {
+ nl80211_send(req, nl80211_get_ssid_bssid_cb, &sb);
+ nl80211_free(req);
+ }
+
+ /* failed, try to find from hostapd info */
+ if ((*buf == 0) &&
+ (res = nl80211_hostapd_info(ifname)) &&
+ (res = nl80211_getval(ifname, res, "ssid")))
+ {
+ memcpy(buf, res, strlen(res));
+ }
+
+ return (*buf == 0) ? -1 : 0;
+}
+
+int nl80211_get_bssid(const char *ifname, char *buf)
+{
+ char *res;
+ struct nl80211_msg_conveyor *req;
+ struct nl80211_ssid_bssid sb;
+
+ /* try to find bssid from scan dump results */
+ res = nl80211_phy2ifname(ifname);
+ req = nl80211_msg(res ? res : ifname, NL80211_CMD_GET_SCAN, NLM_F_DUMP);
+
+ sb.ssid = NULL;
+ sb.bssid[0] = 0;
+
+ if (req)
+ {
+ nl80211_send(req, nl80211_get_ssid_bssid_cb, &sb);
+ nl80211_free(req);
+ }
+
+ /* failed, try to find mac from hostapd info */
+ if ((sb.bssid[0] == 0) &&
+ (res = nl80211_hostapd_info(ifname)) &&
+ (res = nl80211_getval(ifname, res, "bssid")))
+ {
+ sb.bssid[0] = 1;
+ sb.bssid[1] = strtol(&res[0], NULL, 16);
+ sb.bssid[2] = strtol(&res[3], NULL, 16);
+ sb.bssid[3] = strtol(&res[6], NULL, 16);
+ sb.bssid[4] = strtol(&res[9], NULL, 16);
+ sb.bssid[5] = strtol(&res[12], NULL, 16);
+ sb.bssid[6] = strtol(&res[15], NULL, 16);
+ }
+
+ if (sb.bssid[0])
+ {
+ sprintf(buf, "%02X:%02X:%02X:%02X:%02X:%02X",
+ sb.bssid[1], sb.bssid[2], sb.bssid[3],
+ sb.bssid[4], sb.bssid[5], sb.bssid[6]);
+
+ return 0;
+ }
+
+ return -1;
+}
+
+
+static int nl80211_get_frequency_scan_cb(struct nl_msg *msg, void *arg)
+{
+ int *freq = arg;
+ struct nlattr **attr = nl80211_parse(msg);
+ struct nlattr *binfo[NL80211_BSS_MAX + 1];
+
+ static struct nla_policy bss_policy[NL80211_BSS_MAX + 1] = {
+ [NL80211_BSS_FREQUENCY] = { .type = NLA_U32 },
+ };
+
+ if (attr[NL80211_ATTR_BSS] &&
+ !nla_parse_nested(binfo, NL80211_BSS_MAX,
+ attr[NL80211_ATTR_BSS], bss_policy))
+ {
+ if (binfo[NL80211_BSS_FREQUENCY])
+ *freq = nla_get_u32(binfo[NL80211_BSS_FREQUENCY]);
+ }
+
+ return NL_SKIP;
+}
+
+static int nl80211_get_frequency_info_cb(struct nl_msg *msg, void *arg)
+{
+ int *freq = arg;
+ struct nlattr **tb = nl80211_parse(msg);
+
+ if (tb[NL80211_ATTR_WIPHY_FREQ])
+ *freq = nla_get_u32(tb[NL80211_ATTR_WIPHY_FREQ]);
+
+ return NL_SKIP;
+}
+
+int nl80211_get_frequency(const char *ifname, int *buf)
+{
+ char *res, *channel;
+ struct nl80211_msg_conveyor *req;
+
+ /* try to find frequency from interface info */
+ res = nl80211_phy2ifname(ifname);
+ req = nl80211_msg(res ? res : ifname, NL80211_CMD_GET_INTERFACE, 0);
+ *buf = 0;
+
+ if (req)
+ {
+ nl80211_send(req, nl80211_get_frequency_info_cb, buf);
+ nl80211_free(req);
+ }
+
+ /* failed, try to find frequency from hostapd info */
+ if ((*buf == 0) &&
+ (res = nl80211_hostapd_info(ifname)) &&
+ (channel = nl80211_getval(NULL, res, "channel")))
+ {
+ *buf = nl80211_channel2freq(atoi(channel),
+ nl80211_getval(NULL, res, "hw_mode"));
+ }
+ else
+ {
+ /* failed, try to find frequency from scan results */
+ if (*buf == 0)
+ {
+ res = nl80211_phy2ifname(ifname);
+ req = nl80211_msg(res ? res : ifname, NL80211_CMD_GET_SCAN,
+ NLM_F_DUMP);
+
+ if (req)
+ {
+ nl80211_send(req, nl80211_get_frequency_scan_cb, buf);
+ nl80211_free(req);
+ }
+ }
+ }
+
+ return (*buf == 0) ? -1 : 0;
+}
+
+int nl80211_get_channel(const char *ifname, int *buf)
+{
+ if (!nl80211_get_frequency(ifname, buf))
+ {
+ *buf = nl80211_freq2channel(*buf);
+ return 0;
+ }
+
+ return -1;
+}
+
+
+int nl80211_get_txpower(const char *ifname, int *buf)
+{
+#if 0
+ char *res;
+ char path[PATH_MAX];
+
+ res = nl80211_ifname2phy(ifname);
+ snprintf(path, sizeof(path), "/sys/kernel/debug/ieee80211/%s/power",
+ res ? res : ifname);
+
+ if ((*buf = nl80211_readint(path)) > -1)
+ return 0;
+#endif
+
+ return wext_get_txpower(ifname, buf);
+}
+
+
+static int nl80211_fill_signal_cb(struct nl_msg *msg, void *arg)
+{
+ int8_t dbm;
+ int16_t mbit;
+ struct nl80211_rssi_rate *rr = arg;
+ struct nlattr **attr = nl80211_parse(msg);
+ struct nlattr *sinfo[NL80211_STA_INFO_MAX + 1];
+ struct nlattr *rinfo[NL80211_RATE_INFO_MAX + 1];
+
+ static struct nla_policy stats_policy[NL80211_STA_INFO_MAX + 1] = {
+ [NL80211_STA_INFO_INACTIVE_TIME] = { .type = NLA_U32 },
+ [NL80211_STA_INFO_RX_BYTES] = { .type = NLA_U32 },
+ [NL80211_STA_INFO_TX_BYTES] = { .type = NLA_U32 },
+ [NL80211_STA_INFO_RX_PACKETS] = { .type = NLA_U32 },
+ [NL80211_STA_INFO_TX_PACKETS] = { .type = NLA_U32 },
+ [NL80211_STA_INFO_SIGNAL] = { .type = NLA_U8 },
+ [NL80211_STA_INFO_TX_BITRATE] = { .type = NLA_NESTED },
+ [NL80211_STA_INFO_LLID] = { .type = NLA_U16 },
+ [NL80211_STA_INFO_PLID] = { .type = NLA_U16 },
+ [NL80211_STA_INFO_PLINK_STATE] = { .type = NLA_U8 },
+ };
+
+ static struct nla_policy rate_policy[NL80211_RATE_INFO_MAX + 1] = {
+ [NL80211_RATE_INFO_BITRATE] = { .type = NLA_U16 },
+ [NL80211_RATE_INFO_MCS] = { .type = NLA_U8 },
+ [NL80211_RATE_INFO_40_MHZ_WIDTH] = { .type = NLA_FLAG },
+ [NL80211_RATE_INFO_SHORT_GI] = { .type = NLA_FLAG },
+ };
+
+ if (attr[NL80211_ATTR_STA_INFO])
+ {
+ if (!nla_parse_nested(sinfo, NL80211_STA_INFO_MAX,
+ attr[NL80211_ATTR_STA_INFO], stats_policy))
+ {
+ if (sinfo[NL80211_STA_INFO_SIGNAL])
+ {
+ dbm = nla_get_u8(sinfo[NL80211_STA_INFO_SIGNAL]);
+ rr->rssi = rr->rssi ? (int8_t)((rr->rssi + dbm) / 2) : dbm;
+ }
+
+ if (sinfo[NL80211_STA_INFO_TX_BITRATE])
+ {
+ if (!nla_parse_nested(rinfo, NL80211_RATE_INFO_MAX,
+ sinfo[NL80211_STA_INFO_TX_BITRATE],
+ rate_policy))
+ {
+ if (rinfo[NL80211_RATE_INFO_BITRATE])
+ {
+ mbit = nla_get_u16(rinfo[NL80211_RATE_INFO_BITRATE]);
+ rr->rate = rr->rate
+ ? (int16_t)((rr->rate + mbit) / 2) : mbit;
+ }
+ }
+ }
+ }
+ }
+
+ return NL_SKIP;
+}
+
+static void nl80211_fill_signal(const char *ifname, struct nl80211_rssi_rate *r)
+{
+ DIR *d;
+ struct dirent *de;
+ struct nl80211_msg_conveyor *req;
+
+ r->rssi = 0;
+ r->rate = 0;
+
+ if ((d = opendir("/sys/class/net")) != NULL)
+ {
+ while ((de = readdir(d)) != NULL)
+ {
+ if (!strncmp(de->d_name, ifname, strlen(ifname)) &&
+ (!de->d_name[strlen(ifname)] ||
+ !strncmp(&de->d_name[strlen(ifname)], ".sta", 4)))
+ {
+ req = nl80211_msg(de->d_name, NL80211_CMD_GET_STATION,
+ NLM_F_DUMP);
+
+ if (req)
+ {
+ nl80211_send(req, nl80211_fill_signal_cb, r);
+ nl80211_free(req);
+ }
+ }
+ }
+
+ closedir(d);
+ }
+}
+
+int nl80211_get_bitrate(const char *ifname, int *buf)
+{
+ struct nl80211_rssi_rate rr;
+
+ nl80211_fill_signal(ifname, &rr);
+
+ if (rr.rate)
+ {
+ *buf = (rr.rate * 100);
+ return 0;
+ }
+
+ return -1;
+}
+
+int nl80211_get_signal(const char *ifname, int *buf)
+{
+ struct nl80211_rssi_rate rr;
+
+ nl80211_fill_signal(ifname, &rr);
+
+ if (rr.rssi)
+ {
+ *buf = rr.rssi;
+ return 0;
+ }
+
+ return -1;
+}
+
+static int nl80211_get_noise_cb(struct nl_msg *msg, void *arg)
+{
+ int8_t *noise = arg;
+ struct nlattr **tb = nl80211_parse(msg);
+ struct nlattr *si[NL80211_SURVEY_INFO_MAX + 1];
+
+ static struct nla_policy sp[NL80211_SURVEY_INFO_MAX + 1] = {
+ [NL80211_SURVEY_INFO_FREQUENCY] = { .type = NLA_U32 },
+ [NL80211_SURVEY_INFO_NOISE] = { .type = NLA_U8 },
+ };
+
+ if (!tb[NL80211_ATTR_SURVEY_INFO])
+ return NL_SKIP;
+
+ if (nla_parse_nested(si, NL80211_SURVEY_INFO_MAX,
+ tb[NL80211_ATTR_SURVEY_INFO], sp))
+ return NL_SKIP;
+
+ if (!si[NL80211_SURVEY_INFO_NOISE])
+ return NL_SKIP;
+
+ if (!*noise || si[NL80211_SURVEY_INFO_IN_USE])
+ *noise = (int8_t)nla_get_u8(si[NL80211_SURVEY_INFO_NOISE]);
+
+ return NL_SKIP;
+}
+
+
+int nl80211_get_noise(const char *ifname, int *buf)
+{
+ int8_t noise;
+ struct nl80211_msg_conveyor *req;
+
+ req = nl80211_msg(ifname, NL80211_CMD_GET_SURVEY, NLM_F_DUMP);
+ if (req)
+ {
+ noise = 0;
+
+ nl80211_send(req, nl80211_get_noise_cb, &noise);
+ nl80211_free(req);
+
+ if (noise)
+ {
+ *buf = noise;
+ return 0;
+ }
+ }
+
+ return -1;
+}
+
+int nl80211_get_quality(const char *ifname, int *buf)
+{
+ int signal;
+
+ if (!nl80211_get_signal(ifname, &signal))
+ {
+ /* A positive signal level is usually just a quality
+ * value, pass through as-is */
+ if (signal >= 0)
+ {
+ *buf = signal;
+ }
+
+ /* The cfg80211 wext compat layer assumes a signal range
+ * of -110 dBm to -40 dBm, the quality value is derived
+ * by adding 110 to the signal level */
+ else
+ {
+ if (signal < -110)
+ signal = -110;
+ else if (signal > -40)
+ signal = -40;
+
+ *buf = (signal + 110);
+ }
+
+ return 0;
+ }
+
+ return -1;
+}
+
+int nl80211_get_quality_max(const char *ifname, int *buf)
+{
+ /* The cfg80211 wext compat layer assumes a maximum
+ * quality of 70 */
+ *buf = 70;
+
+ return 0;
+}
+
+int nl80211_get_encryption(const char *ifname, char *buf)
+{
+ int i;
+ char k[9];
+ char *val, *res;
+ struct iwinfo_crypto_entry *c = (struct iwinfo_crypto_entry *)buf;
+
+ /* WPA supplicant */
+ if ((res = nl80211_wpactl_info(ifname, "STATUS", NULL)) &&
+ (val = nl80211_getval(NULL, res, "pairwise_cipher")))
+ {
+ /* WEP */
+ if (strstr(val, "WEP"))
+ {
+ if (strstr(val, "WEP-40"))
+ c->pair_ciphers |= IWINFO_CIPHER_WEP40;
+
+ else if (strstr(val, "WEP-104"))
+ c->pair_ciphers |= IWINFO_CIPHER_WEP104;
+
+ c->enabled = 1;
+ c->group_ciphers = c->pair_ciphers;
+
+ c->auth_suites |= IWINFO_KMGMT_NONE;
+ c->auth_algs |= IWINFO_AUTH_OPEN; /* XXX: assumption */
+ }
+
+ /* WPA */
+ else
+ {
+ if (strstr(val, "TKIP"))
+ c->pair_ciphers |= IWINFO_CIPHER_TKIP;
+
+ else if (strstr(val, "CCMP"))
+ c->pair_ciphers |= IWINFO_CIPHER_CCMP;
+
+ else if (strstr(val, "NONE"))
+ c->pair_ciphers |= IWINFO_CIPHER_NONE;
+
+ else if (strstr(val, "WEP-40"))
+ c->pair_ciphers |= IWINFO_CIPHER_WEP40;
+
+ else if (strstr(val, "WEP-104"))
+ c->pair_ciphers |= IWINFO_CIPHER_WEP104;
+
+
+ if ((val = nl80211_getval(NULL, res, "group_cipher")))
+ {
+ if (strstr(val, "TKIP"))
+ c->group_ciphers |= IWINFO_CIPHER_TKIP;
+
+ else if (strstr(val, "CCMP"))
+ c->group_ciphers |= IWINFO_CIPHER_CCMP;
+
+ else if (strstr(val, "NONE"))
+ c->group_ciphers |= IWINFO_CIPHER_NONE;
+
+ else if (strstr(val, "WEP-40"))
+ c->group_ciphers |= IWINFO_CIPHER_WEP40;
+
+ else if (strstr(val, "WEP-104"))
+ c->group_ciphers |= IWINFO_CIPHER_WEP104;
+ }
+
+
+ if ((val = nl80211_getval(NULL, res, "key_mgmt")))
+ {
+ if (strstr(val, "WPA2"))
+ c->wpa_version = 2;
+
+ else if (strstr(val, "WPA"))
+ c->wpa_version = 1;
+
+
+ if (strstr(val, "PSK"))
+ c->auth_suites |= IWINFO_KMGMT_PSK;
+
+ else if (strstr(val, "EAP") || strstr(val, "802.1X"))
+ c->auth_suites |= IWINFO_KMGMT_8021x;
+
+ else if (strstr(val, "NONE"))
+ c->auth_suites |= IWINFO_KMGMT_NONE;
+ }
+
+ c->enabled = (c->wpa_version && c->auth_suites) ? 1 : 0;
+ }
+
+ return 0;
+ }
+
+ /* Hostapd */
+ else if ((res = nl80211_hostapd_info(ifname)))
+ {
+ if ((val = nl80211_getval(ifname, res, "wpa")) != NULL)
+ c->wpa_version = atoi(val);
+
+ val = nl80211_getval(ifname, res, "wpa_key_mgmt");
+
+ if (!val || strstr(val, "PSK"))
+ c->auth_suites |= IWINFO_KMGMT_PSK;
+
+ if (val && strstr(val, "EAP"))
+ c->auth_suites |= IWINFO_KMGMT_8021x;
+
+ if (val && strstr(val, "NONE"))
+ c->auth_suites |= IWINFO_KMGMT_NONE;
+
+ if ((val = nl80211_getval(ifname, res, "wpa_pairwise")) != NULL)
+ {
+ if (strstr(val, "TKIP"))
+ c->pair_ciphers |= IWINFO_CIPHER_TKIP;
+
+ if (strstr(val, "CCMP"))
+ c->pair_ciphers |= IWINFO_CIPHER_CCMP;
+
+ if (strstr(val, "NONE"))
+ c->pair_ciphers |= IWINFO_CIPHER_NONE;
+ }
+
+ if ((val = nl80211_getval(ifname, res, "auth_algs")) != NULL)
+ {
+ switch(atoi(val)) {
+ case 1:
+ c->auth_algs |= IWINFO_AUTH_OPEN;
+ break;
+
+ case 2:
+ c->auth_algs |= IWINFO_AUTH_SHARED;
+ break;
+
+ case 3:
+ c->auth_algs |= IWINFO_AUTH_OPEN;
+ c->auth_algs |= IWINFO_AUTH_SHARED;
+ break;
+
+ default:
+ break;
+ }
+
+ for (i = 0; i < 4; i++)
+ {
+ snprintf(k, sizeof(k), "wep_key%d", i);
+
+ if ((val = nl80211_getval(ifname, res, k)))
+ {
+ if ((strlen(val) == 5) || (strlen(val) == 10))
+ c->pair_ciphers |= IWINFO_CIPHER_WEP40;
+
+ else if ((strlen(val) == 13) || (strlen(val) == 26))
+ c->pair_ciphers |= IWINFO_CIPHER_WEP104;
+ }
+ }
+ }
+
+ c->group_ciphers = c->pair_ciphers;
+ c->enabled = (c->wpa_version || c->pair_ciphers) ? 1 : 0;
+
+ return 0;
+ }
+
+ return -1;
+}
+
+
+static int nl80211_get_assoclist_cb(struct nl_msg *msg, void *arg)
+{
+ struct nl80211_array_buf *arr = arg;
+ struct iwinfo_assoclist_entry *e = arr->buf;
+ struct nlattr **attr = nl80211_parse(msg);
+ struct nlattr *sinfo[NL80211_STA_INFO_MAX + 1];
+ struct nlattr *rinfo[NL80211_RATE_INFO_MAX + 1];
+
+ static struct nla_policy stats_policy[NL80211_STA_INFO_MAX + 1] = {
+ [NL80211_STA_INFO_INACTIVE_TIME] = { .type = NLA_U32 },
+ [NL80211_STA_INFO_RX_PACKETS] = { .type = NLA_U32 },
+ [NL80211_STA_INFO_TX_PACKETS] = { .type = NLA_U32 },
+ [NL80211_STA_INFO_RX_BITRATE] = { .type = NLA_NESTED },
+ [NL80211_STA_INFO_TX_BITRATE] = { .type = NLA_NESTED },
+ [NL80211_STA_INFO_SIGNAL] = { .type = NLA_U8 },
+ };
+
+ static struct nla_policy rate_policy[NL80211_RATE_INFO_MAX + 1] = {
+ [NL80211_RATE_INFO_BITRATE] = { .type = NLA_U16 },
+ [NL80211_RATE_INFO_MCS] = { .type = NLA_U8 },
+ [NL80211_RATE_INFO_40_MHZ_WIDTH] = { .type = NLA_FLAG },
+ [NL80211_RATE_INFO_SHORT_GI] = { .type = NLA_FLAG },
+ };
+
+ /* advance to end of array */
+ e += arr->count;
+ memset(e, 0, sizeof(*e));
+
+ if (attr[NL80211_ATTR_MAC])
+ memcpy(e->mac, nla_data(attr[NL80211_ATTR_MAC]), 6);
+
+ if (attr[NL80211_ATTR_STA_INFO] &&
+ !nla_parse_nested(sinfo, NL80211_STA_INFO_MAX,
+ attr[NL80211_ATTR_STA_INFO], stats_policy))
+ {
+ if (sinfo[NL80211_STA_INFO_SIGNAL])
+ e->signal = nla_get_u8(sinfo[NL80211_STA_INFO_SIGNAL]);
+
+ if (sinfo[NL80211_STA_INFO_INACTIVE_TIME])
+ e->inactive = nla_get_u32(sinfo[NL80211_STA_INFO_INACTIVE_TIME]);
+
+ if (sinfo[NL80211_STA_INFO_RX_PACKETS])
+ e->rx_packets = nla_get_u32(sinfo[NL80211_STA_INFO_RX_PACKETS]);
+
+ if (sinfo[NL80211_STA_INFO_TX_PACKETS])
+ e->tx_packets = nla_get_u32(sinfo[NL80211_STA_INFO_TX_PACKETS]);
+
+ if (sinfo[NL80211_STA_INFO_RX_BITRATE] &&
+ !nla_parse_nested(rinfo, NL80211_RATE_INFO_MAX,
+ sinfo[NL80211_STA_INFO_RX_BITRATE], rate_policy))
+ {
+ if (rinfo[NL80211_RATE_INFO_BITRATE])
+ e->rx_rate.rate =
+ nla_get_u16(rinfo[NL80211_RATE_INFO_BITRATE]) * 100;
+
+ if (rinfo[NL80211_RATE_INFO_MCS])
+ e->rx_rate.mcs = nla_get_u8(rinfo[NL80211_RATE_INFO_MCS]);
+
+ if (rinfo[NL80211_RATE_INFO_40_MHZ_WIDTH])
+ e->rx_rate.is_40mhz = 1;
+
+ if (rinfo[NL80211_RATE_INFO_SHORT_GI])
+ e->rx_rate.is_short_gi = 1;
+ }
+
+ if (sinfo[NL80211_STA_INFO_TX_BITRATE] &&
+ !nla_parse_nested(rinfo, NL80211_RATE_INFO_MAX,
+ sinfo[NL80211_STA_INFO_TX_BITRATE], rate_policy))
+ {
+ if (rinfo[NL80211_RATE_INFO_BITRATE])
+ e->tx_rate.rate =
+ nla_get_u16(rinfo[NL80211_RATE_INFO_BITRATE]) * 100;
+
+ if (rinfo[NL80211_RATE_INFO_MCS])
+ e->tx_rate.mcs = nla_get_u8(rinfo[NL80211_RATE_INFO_MCS]);
+
+ if (rinfo[NL80211_RATE_INFO_40_MHZ_WIDTH])
+ e->tx_rate.is_40mhz = 1;
+
+ if (rinfo[NL80211_RATE_INFO_SHORT_GI])
+ e->tx_rate.is_short_gi = 1;
+ }
+ }
+
+ e->noise = 0; /* filled in by caller */
+ arr->count++;
+
+ return NL_SKIP;
+}
+
+int nl80211_get_assoclist(const char *ifname, char *buf, int *len)
+{
+ DIR *d;
+ int i, noise = 0;
+ struct dirent *de;
+ struct nl80211_msg_conveyor *req;
+ struct nl80211_array_buf arr = { .buf = buf, .count = 0 };
+ struct iwinfo_assoclist_entry *e;
+
+ if ((d = opendir("/sys/class/net")) != NULL)
+ {
+ while ((de = readdir(d)) != NULL)
+ {
+ if (!strncmp(de->d_name, ifname, strlen(ifname)) &&
+ (!de->d_name[strlen(ifname)] ||
+ !strncmp(&de->d_name[strlen(ifname)], ".sta", 4)))
+ {
+ req = nl80211_msg(de->d_name, NL80211_CMD_GET_STATION,
+ NLM_F_DUMP);
+
+ if (req)
+ {
+ nl80211_send(req, nl80211_get_assoclist_cb, &arr);
+ nl80211_free(req);
+ }
+ }
+ }
+
+ closedir(d);
+
+ if (!nl80211_get_noise(ifname, &noise))
+ for (i = 0, e = arr.buf; i < arr.count; i++, e++)
+ e->noise = noise;
+
+ *len = (arr.count * sizeof(struct iwinfo_assoclist_entry));
+ return 0;
+ }
+
+ return -1;
+}
+
+static int nl80211_get_txpwrlist_cb(struct nl_msg *msg, void *arg)
+{
+ int *dbm_max = arg;
+ int ch_cur, ch_cmp, bands_remain, freqs_remain;
+
+ struct nlattr **attr = nl80211_parse(msg);
+ struct nlattr *bands[NL80211_BAND_ATTR_MAX + 1];
+ struct nlattr *freqs[NL80211_FREQUENCY_ATTR_MAX + 1];
+ struct nlattr *band, *freq;
+
+ static struct nla_policy freq_policy[NL80211_FREQUENCY_ATTR_MAX + 1] = {
+ [NL80211_FREQUENCY_ATTR_FREQ] = { .type = NLA_U32 },
+ [NL80211_FREQUENCY_ATTR_DISABLED] = { .type = NLA_FLAG },
+ [NL80211_FREQUENCY_ATTR_PASSIVE_SCAN] = { .type = NLA_FLAG },
+ [NL80211_FREQUENCY_ATTR_NO_IBSS] = { .type = NLA_FLAG },
+ [NL80211_FREQUENCY_ATTR_RADAR] = { .type = NLA_FLAG },
+ [NL80211_FREQUENCY_ATTR_MAX_TX_POWER] = { .type = NLA_U32 },
+ };
+
+ ch_cur = *dbm_max; /* value int* is initialized with channel by caller */
+ *dbm_max = -1;
+
+ nla_for_each_nested(band, attr[NL80211_ATTR_WIPHY_BANDS], bands_remain)
+ {
+ nla_parse(bands, NL80211_BAND_ATTR_MAX, nla_data(band),
+ nla_len(band), NULL);
+
+ nla_for_each_nested(freq, bands[NL80211_BAND_ATTR_FREQS], freqs_remain)
+ {
+ nla_parse(freqs, NL80211_FREQUENCY_ATTR_MAX,
+ nla_data(freq), nla_len(freq), freq_policy);
+
+ ch_cmp = nl80211_freq2channel(nla_get_u32(
+ freqs[NL80211_FREQUENCY_ATTR_FREQ]));
+
+ if ((!ch_cur || (ch_cmp == ch_cur)) &&
+ freqs[NL80211_FREQUENCY_ATTR_MAX_TX_POWER])
+ {
+ *dbm_max = (int)(0.01 * nla_get_u32(
+ freqs[NL80211_FREQUENCY_ATTR_MAX_TX_POWER]));
+
+ break;
+ }
+ }
+ }
+
+ return NL_SKIP;
+}
+
+int nl80211_get_txpwrlist(const char *ifname, char *buf, int *len)
+{
+ int ch_cur;
+ int dbm_max = -1, dbm_cur, dbm_cnt;
+ struct nl80211_msg_conveyor *req;
+ struct iwinfo_txpwrlist_entry entry;
+
+ if (nl80211_get_channel(ifname, &ch_cur))
+ ch_cur = 0;
+
+ req = nl80211_msg(ifname, NL80211_CMD_GET_WIPHY, 0);
+ if (req)
+ {
+ /* initialize the value pointer with channel for callback */
+ dbm_max = ch_cur;
+
+ nl80211_send(req, nl80211_get_txpwrlist_cb, &dbm_max);
+ nl80211_free(req);
+ }
+
+ if (dbm_max > 0)
+ {
+ for (dbm_cur = 0, dbm_cnt = 0;
+ dbm_cur < dbm_max;
+ dbm_cur++, dbm_cnt++)
+ {
+ entry.dbm = dbm_cur;
+ entry.mw = iwinfo_dbm2mw(dbm_cur);
+
+ memcpy(&buf[dbm_cnt * sizeof(entry)], &entry, sizeof(entry));
+ }
+
+ entry.dbm = dbm_max;
+ entry.mw = iwinfo_dbm2mw(dbm_max);
+
+ memcpy(&buf[dbm_cnt * sizeof(entry)], &entry, sizeof(entry));
+ dbm_cnt++;
+
+ *len = dbm_cnt * sizeof(entry);
+ return 0;
+ }
+
+ return -1;
+}
+
+static void nl80211_get_scancrypto(const char *spec,
+ struct iwinfo_crypto_entry *c)
+{
+ if (strstr(spec, "WPA") || strstr(spec, "WEP"))
+ {
+ c->enabled = 1;
+
+ if (strstr(spec, "WPA2-") && strstr(spec, "WPA-"))
+ c->wpa_version = 3;
+
+ else if (strstr(spec, "WPA2"))
+ c->wpa_version = 2;
+
+ else if (strstr(spec, "WPA"))
+ c->wpa_version = 1;
+
+ else if (strstr(spec, "WEP"))
+ c->auth_algs = IWINFO_AUTH_OPEN | IWINFO_AUTH_SHARED;
+
+
+ if (strstr(spec, "PSK"))
+ c->auth_suites |= IWINFO_KMGMT_PSK;
+
+ if (strstr(spec, "802.1X") || strstr(spec, "EAP"))
+ c->auth_suites |= IWINFO_KMGMT_8021x;
+
+ if (strstr(spec, "WPA-NONE"))
+ c->auth_suites |= IWINFO_KMGMT_NONE;
+
+
+ if (strstr(spec, "TKIP"))
+ c->pair_ciphers |= IWINFO_CIPHER_TKIP;
+
+ if (strstr(spec, "CCMP"))
+ c->pair_ciphers |= IWINFO_CIPHER_CCMP;
+
+ if (strstr(spec, "WEP-40"))
+ c->pair_ciphers |= IWINFO_CIPHER_WEP40;
+
+ if (strstr(spec, "WEP-104"))
+ c->pair_ciphers |= IWINFO_CIPHER_WEP104;
+
+ c->group_ciphers = c->pair_ciphers;
+ }
+ else
+ {
+ c->enabled = 0;
+ }
+}
+
+
+struct nl80211_scanlist {
+ struct iwinfo_scanlist_entry *e;
+ int len;
+};
+
+
+static void nl80211_get_scanlist_ie(struct nlattr **bss,
+ struct iwinfo_scanlist_entry *e)
+{
+ int ielen = nla_len(bss[NL80211_BSS_INFORMATION_ELEMENTS]);
+ unsigned char *ie = nla_data(bss[NL80211_BSS_INFORMATION_ELEMENTS]);
+ static unsigned char ms_oui[3] = { 0x00, 0x50, 0xf2 };
+
+ while (ielen >= 2 && ielen >= ie[1])
+ {
+ switch (ie[0])
+ {
+ case 0: /* SSID */
+ memcpy(e->ssid, ie + 2, min(ie[1], IWINFO_ESSID_MAX_SIZE));
+ break;
+
+ case 48: /* RSN */
+ iwinfo_parse_rsn(&e->crypto, ie + 2, ie[1],
+ IWINFO_CIPHER_CCMP, IWINFO_KMGMT_8021x);
+ break;
+
+ case 221: /* Vendor */
+ if (ie[1] >= 4 && !memcmp(ie + 2, ms_oui, 3) && ie[5] == 1)
+ iwinfo_parse_rsn(&e->crypto, ie + 6, ie[1] - 4,
+ IWINFO_CIPHER_TKIP, IWINFO_KMGMT_PSK);
+ break;
+ }
+
+ ielen -= ie[1] + 2;
+ ie += ie[1] + 2;
+ }
+}
+
+static int nl80211_get_scanlist_cb(struct nl_msg *msg, void *arg)
+{
+ int8_t rssi;
+ uint16_t caps;
+
+ struct nl80211_scanlist *sl = arg;
+ struct nlattr **tb = nl80211_parse(msg);
+ struct nlattr *bss[NL80211_BSS_MAX + 1];
+
+ static struct nla_policy bss_policy[NL80211_BSS_MAX + 1] = {
+ [NL80211_BSS_TSF] = { .type = NLA_U64 },
+ [NL80211_BSS_FREQUENCY] = { .type = NLA_U32 },
+ [NL80211_BSS_BSSID] = { },
+ [NL80211_BSS_BEACON_INTERVAL] = { .type = NLA_U16 },
+ [NL80211_BSS_CAPABILITY] = { .type = NLA_U16 },
+ [NL80211_BSS_INFORMATION_ELEMENTS] = { },
+ [NL80211_BSS_SIGNAL_MBM] = { .type = NLA_U32 },
+ [NL80211_BSS_SIGNAL_UNSPEC] = { .type = NLA_U8 },
+ [NL80211_BSS_STATUS] = { .type = NLA_U32 },
+ [NL80211_BSS_SEEN_MS_AGO] = { .type = NLA_U32 },
+ [NL80211_BSS_BEACON_IES] = { },
+ };
+
+ if (!tb[NL80211_ATTR_BSS] ||
+ nla_parse_nested(bss, NL80211_BSS_MAX, tb[NL80211_ATTR_BSS],
+ bss_policy) ||
+ !bss[NL80211_BSS_BSSID])
+ {
+ return NL_SKIP;
+ }
+
+ if (bss[NL80211_BSS_CAPABILITY])
+ caps = nla_get_u16(bss[NL80211_BSS_CAPABILITY]);
+ else
+ caps = 0;
+
+ memset(sl->e, 0, sizeof(*sl->e));
+ memcpy(sl->e->mac, nla_data(bss[NL80211_BSS_BSSID]), 6);
+
+ if (caps & (1<<1))
+ sl->e->mode = IWINFO_OPMODE_ADHOC;
+ else
+ sl->e->mode = IWINFO_OPMODE_MASTER;
+
+ if (caps & (1<<4))
+ sl->e->crypto.enabled = 1;
+
+ if (bss[NL80211_BSS_FREQUENCY])
+ sl->e->channel = nl80211_freq2channel(nla_get_u32(
+ bss[NL80211_BSS_FREQUENCY]));
+
+ if (bss[NL80211_BSS_INFORMATION_ELEMENTS])
+ nl80211_get_scanlist_ie(bss, sl->e);
+
+ if (bss[NL80211_BSS_SIGNAL_MBM])
+ {
+ sl->e->signal =
+ (uint8_t)((int32_t)nla_get_u32(bss[NL80211_BSS_SIGNAL_MBM]) / 100);
+
+ rssi = sl->e->signal - 0x100;
+
+ if (rssi < -110)
+ rssi = -110;
+ else if (rssi > -40)
+ rssi = -40;
+
+ sl->e->quality = (rssi + 110);
+ sl->e->quality_max = 70;
+ }
+
+ if (sl->e->crypto.enabled && !sl->e->crypto.wpa_version)
+ {
+ sl->e->crypto.auth_algs = IWINFO_AUTH_OPEN | IWINFO_AUTH_SHARED;
+ sl->e->crypto.pair_ciphers = IWINFO_CIPHER_WEP40 | IWINFO_CIPHER_WEP104;
+ }
+
+ sl->e++;
+ sl->len++;
+
+ return NL_SKIP;
+}
+
+static int nl80211_get_scanlist_nl(const char *ifname, char *buf, int *len)
+{
+ struct nl80211_msg_conveyor *req;
+ struct nl80211_scanlist sl = { .e = (struct iwinfo_scanlist_entry *)buf };
+
+ req = nl80211_msg(ifname, NL80211_CMD_TRIGGER_SCAN, 0);
+ if (req)
+ {
+ nl80211_send(req, NULL, NULL);
+ nl80211_free(req);
+ }
+
+ nl80211_wait("nl80211", "scan", NL80211_CMD_NEW_SCAN_RESULTS);
+
+ req = nl80211_msg(ifname, NL80211_CMD_GET_SCAN, NLM_F_DUMP);
+ if (req)
+ {
+ nl80211_send(req, nl80211_get_scanlist_cb, &sl);
+ nl80211_free(req);
+ }
+
+ *len = sl.len * sizeof(struct iwinfo_scanlist_entry);
+ return *len ? 0 : -1;
+}
+
+int nl80211_get_scanlist(const char *ifname, char *buf, int *len)
+{
+ int freq, rssi, qmax, count;
+ char *res;
+ char ssid[128] = { 0 };
+ char bssid[18] = { 0 };
+ char cipher[256] = { 0 };
+
+ /* Got a radioX pseudo interface, find some interface on it or create one */
+ if (!strncmp(ifname, "radio", 5))
+ {
+ /* Reuse existing interface */
+ if ((res = nl80211_phy2ifname(ifname)) != NULL)
+ {
+ return nl80211_get_scanlist(res, buf, len);
+ }
+
+ /* Need to spawn a temporary iface for scanning */
+ else if ((res = nl80211_ifadd(ifname)) != NULL)
+ {
+ count = nl80211_get_scanlist(res, buf, len);
+ nl80211_ifdel(res);
+ return count;
+ }
+ }
+
+ struct iwinfo_scanlist_entry *e = (struct iwinfo_scanlist_entry *)buf;
+
+ /* WPA supplicant */
+ if ((res = nl80211_wpactl_info(ifname, "SCAN", "CTRL-EVENT-SCAN-RESULTS")))
+ {
+ if ((res = nl80211_wpactl_info(ifname, "SCAN_RESULTS", NULL)))
+ {
+ nl80211_get_quality_max(ifname, &qmax);
+
+ /* skip header line */
+ while (*res++ != '\n');
+
+ count = 0;
+
+ while (sscanf(res, "%17s %d %d %255s%*[ \t]%127[^\n]\n",
+ bssid, &freq, &rssi, cipher, ssid) > 0)
+ {
+ /* BSSID */
+ e->mac[0] = strtol(&bssid[0], NULL, 16);
+ e->mac[1] = strtol(&bssid[3], NULL, 16);
+ e->mac[2] = strtol(&bssid[6], NULL, 16);
+ e->mac[3] = strtol(&bssid[9], NULL, 16);
+ e->mac[4] = strtol(&bssid[12], NULL, 16);
+ e->mac[5] = strtol(&bssid[15], NULL, 16);
+
+ /* SSID */
+ memcpy(e->ssid, ssid, min(strlen(ssid), sizeof(e->ssid) - 1));
+
+ /* Mode (assume master) */
+ e->mode = IWINFO_OPMODE_MASTER;
+
+ /* Channel */
+ e->channel = nl80211_freq2channel(freq);
+
+ /* Signal */
+ e->signal = rssi;
+
+ /* Quality */
+ if (rssi < 0)
+ {
+ /* The cfg80211 wext compat layer assumes a signal range
+ * of -110 dBm to -40 dBm, the quality value is derived
+ * by adding 110 to the signal level */
+ if (rssi < -110)
+ rssi = -110;
+ else if (rssi > -40)
+ rssi = -40;
+
+ e->quality = (rssi + 110);
+ }
+ else
+ {
+ e->quality = rssi;
+ }
+
+ /* Max. Quality */
+ e->quality_max = qmax;
+
+ /* Crypto */
+ nl80211_get_scancrypto(cipher, &e->crypto);
+
+ /* advance to next line */
+ while (*res && *res++ != '\n');
+
+ count++;
+ e++;
+
+ memset(ssid, 0, sizeof(ssid));
+ memset(bssid, 0, sizeof(bssid));
+ memset(cipher, 0, sizeof(cipher));
+ }
+
+ *len = count * sizeof(struct iwinfo_scanlist_entry);
+ return 0;
+ }
+ }
+
+ /* AP scan */
+ else
+ {
+ /* Got a temp interface, don't create yet another one */
+ if (!strncmp(ifname, "tmp.", 4))
+ {
+ if (!iwinfo_ifup(ifname))
+ return -1;
+
+ nl80211_get_scanlist_nl(ifname, buf, len);
+ iwinfo_ifdown(ifname);
+ return 0;
+ }
+
+ /* Spawn a new scan interface */
+ else
+ {
+ if (!(res = nl80211_ifadd(ifname)))
+ goto out;
+
+ if (!iwinfo_ifmac(res))
+ goto out;
+
+ /* if we can take the new interface up, the driver supports an
+ * additional interface and there's no need to tear down the ap */
+ if (iwinfo_ifup(res))
+ {
+ nl80211_get_scanlist_nl(res, buf, len);
+ iwinfo_ifdown(res);
+ }
+
+ /* driver cannot create secondary interface, take down ap
+ * during scan */
+ else if (iwinfo_ifdown(ifname) && iwinfo_ifup(res))
+ {
+ nl80211_get_scanlist_nl(res, buf, len);
+ iwinfo_ifdown(res);
+ iwinfo_ifup(ifname);
+ nl80211_hostapd_hup(ifname);
+ }
+
+ out:
+ nl80211_ifdel(res);
+ return 0;
+ }
+ }
+
+ return -1;
+}
+
+static int nl80211_get_freqlist_cb(struct nl_msg *msg, void *arg)
+{
+ int bands_remain, freqs_remain;
+
+ struct nl80211_array_buf *arr = arg;
+ struct iwinfo_freqlist_entry *e = arr->buf;
+
+ struct nlattr **attr = nl80211_parse(msg);
+ struct nlattr *bands[NL80211_BAND_ATTR_MAX + 1];
+ struct nlattr *freqs[NL80211_FREQUENCY_ATTR_MAX + 1];
+ struct nlattr *band, *freq;
+
+ static struct nla_policy freq_policy[NL80211_FREQUENCY_ATTR_MAX + 1] = {
+ [NL80211_FREQUENCY_ATTR_FREQ] = { .type = NLA_U32 },
+ [NL80211_FREQUENCY_ATTR_DISABLED] = { .type = NLA_FLAG },
+ [NL80211_FREQUENCY_ATTR_PASSIVE_SCAN] = { .type = NLA_FLAG },
+ [NL80211_FREQUENCY_ATTR_NO_IBSS] = { .type = NLA_FLAG },
+ [NL80211_FREQUENCY_ATTR_RADAR] = { .type = NLA_FLAG },
+ [NL80211_FREQUENCY_ATTR_MAX_TX_POWER] = { .type = NLA_U32 },
+ };
+
+ nla_for_each_nested(band, attr[NL80211_ATTR_WIPHY_BANDS], bands_remain)
+ {
+ nla_parse(bands, NL80211_BAND_ATTR_MAX,
+ nla_data(band), nla_len(band), NULL);
+
+ nla_for_each_nested(freq, bands[NL80211_BAND_ATTR_FREQS], freqs_remain)
+ {
+ nla_parse(freqs, NL80211_FREQUENCY_ATTR_MAX,
+ nla_data(freq), nla_len(freq), NULL);
+
+ if (!freqs[NL80211_FREQUENCY_ATTR_FREQ] ||
+ freqs[NL80211_FREQUENCY_ATTR_DISABLED])
+ continue;
+
+ e->mhz = nla_get_u32(freqs[NL80211_FREQUENCY_ATTR_FREQ]);
+ e->channel = nl80211_freq2channel(e->mhz);
+
+ e->restricted = (
+ freqs[NL80211_FREQUENCY_ATTR_PASSIVE_SCAN] ||
+ freqs[NL80211_FREQUENCY_ATTR_NO_IBSS] ||
+ freqs[NL80211_FREQUENCY_ATTR_RADAR]
+ ) ? 1 : 0;
+
+ e++;
+ arr->count++;
+ }
+ }
+
+ return NL_SKIP;
+}
+
+int nl80211_get_freqlist(const char *ifname, char *buf, int *len)
+{
+ struct nl80211_msg_conveyor *req;
+ struct nl80211_array_buf arr = { .buf = buf, .count = 0 };
+
+ req = nl80211_msg(ifname, NL80211_CMD_GET_WIPHY, 0);
+ if (req)
+ {
+ nl80211_send(req, nl80211_get_freqlist_cb, &arr);
+ nl80211_free(req);
+ }
+
+ if (arr.count > 0)
+ {
+ *len = arr.count * sizeof(struct iwinfo_freqlist_entry);
+ return 0;
+ }
+
+ return -1;
+}
+
+static int nl80211_get_country_cb(struct nl_msg *msg, void *arg)
+{
+ char *buf = arg;
+ struct nlattr **attr = nl80211_parse(msg);
+
+ if (attr[NL80211_ATTR_REG_ALPHA2])
+ memcpy(buf, nla_data(attr[NL80211_ATTR_REG_ALPHA2]), 2);
+ else
+ buf[0] = 0;
+
+ return NL_SKIP;
+}
+
+int nl80211_get_country(const char *ifname, char *buf)
+{
+ int rv = -1;
+ struct nl80211_msg_conveyor *req;
+
+ req = nl80211_msg(ifname, NL80211_CMD_GET_REG, 0);
+ if (req)
+ {
+ nl80211_send(req, nl80211_get_country_cb, buf);
+ nl80211_free(req);
+
+ if (buf[0])
+ rv = 0;
+ }
+
+ return rv;
+}
+
+int nl80211_get_countrylist(const char *ifname, char *buf, int *len)
+{
+ int i, count;
+ struct iwinfo_country_entry *e = (struct iwinfo_country_entry *)buf;
+ const struct iwinfo_iso3166_label *l;
+
+ for (l = IWINFO_ISO3166_NAMES, count = 0; l->iso3166; l++, e++, count++)
+ {
+ e->iso3166 = l->iso3166;
+ e->ccode[0] = (l->iso3166 / 256);
+ e->ccode[1] = (l->iso3166 % 256);
+ }
+
+ *len = (count * sizeof(struct iwinfo_country_entry));
+ return 0;
+}
+
+static int nl80211_get_hwmodelist_cb(struct nl_msg *msg, void *arg)
+{
+ int *modes = arg;
+ int bands_remain, freqs_remain;
+ uint16_t caps = 0;
+ struct nlattr **attr = nl80211_parse(msg);
+ struct nlattr *bands[NL80211_BAND_ATTR_MAX + 1];
+ struct nlattr *freqs[NL80211_FREQUENCY_ATTR_MAX + 1];
+ struct nlattr *band, *freq;
+
+ *modes = 0;
+
+ if (attr[NL80211_ATTR_WIPHY_BANDS])
+ {
+ nla_for_each_nested(band, attr[NL80211_ATTR_WIPHY_BANDS], bands_remain)
+ {
+ nla_parse(bands, NL80211_BAND_ATTR_MAX,
+ nla_data(band), nla_len(band), NULL);
+
+ if (bands[NL80211_BAND_ATTR_HT_CAPA])
+ caps = nla_get_u16(bands[NL80211_BAND_ATTR_HT_CAPA]);
+
+ /* Treat any nonzero capability as 11n */
+ if (caps > 0)
+ *modes |= IWINFO_80211_N;
+
+ nla_for_each_nested(freq, bands[NL80211_BAND_ATTR_FREQS],
+ freqs_remain)
+ {
+ nla_parse(freqs, NL80211_FREQUENCY_ATTR_MAX,
+ nla_data(freq), nla_len(freq), NULL);
+
+ if (!freqs[NL80211_FREQUENCY_ATTR_FREQ])
+ continue;
+
+ if (nla_get_u32(freqs[NL80211_FREQUENCY_ATTR_FREQ]) < 2485)
+ {
+ *modes |= IWINFO_80211_B;
+ *modes |= IWINFO_80211_G;
+ }
+ else
+ {
+ *modes |= IWINFO_80211_A;
+ }
+ }
+ }
+ }
+
+ return NL_SKIP;
+}
+
+int nl80211_get_hwmodelist(const char *ifname, int *buf)
+{
+ struct nl80211_msg_conveyor *req;
+
+ req = nl80211_msg(ifname, NL80211_CMD_GET_WIPHY, 0);
+ if (req)
+ {
+ nl80211_send(req, nl80211_get_hwmodelist_cb, buf);
+ nl80211_free(req);
+ }
+
+ return *buf ? 0 : -1;
+}
+
+int nl80211_get_mbssid_support(const char *ifname, int *buf)
+{
+ /* Test whether we can create another interface */
+ char *nif = nl80211_ifadd(ifname);
+
+ if (nif)
+ {
+ *buf = (iwinfo_ifmac(nif) && iwinfo_ifup(nif));
+
+ iwinfo_ifdown(nif);
+ nl80211_ifdel(nif);
+
+ return 0;
+ }
+
+ return -1;
+}
+
+int nl80211_get_hardware_id(const char *ifname, char *buf)
+{
+ int rv;
+ char *res;
+
+ /* Got a radioX pseudo interface, find some interface on it or create one */
+ if (!strncmp(ifname, "radio", 5))
+ {
+ /* Reuse existing interface */
+ if ((res = nl80211_phy2ifname(ifname)) != NULL)
+ {
+ rv = wext_get_hardware_id(res, buf);
+ }
+
+ /* Need to spawn a temporary iface for finding IDs */
+ else if ((res = nl80211_ifadd(ifname)) != NULL)
+ {
+ rv = wext_get_hardware_id(res, buf);
+ nl80211_ifdel(res);
+ }
+ }
+ else
+ {
+ rv = wext_get_hardware_id(ifname, buf);
+ }
+
+ /* Failed to obtain hardware IDs, search board config */
+ if (rv)
+ {
+ rv = iwinfo_hardware_id_from_mtd((struct iwinfo_hardware_id *)buf);
+ }
+
+ return rv;
+}
+
+static const struct iwinfo_hardware_entry *
+nl80211_get_hardware_entry(const char *ifname)
+{
+ struct iwinfo_hardware_id id;
+
+ if (nl80211_get_hardware_id(ifname, (char *)&id))
+ return NULL;
+
+ return iwinfo_hardware(&id);
+}
+
+int nl80211_get_hardware_name(const char *ifname, char *buf)
+{
+ const struct iwinfo_hardware_entry *hw;
+
+ if (!(hw = nl80211_get_hardware_entry(ifname)))
+ sprintf(buf, "Generic MAC80211");
+ else
+ sprintf(buf, "%s %s", hw->vendor_name, hw->device_name);
+
+ return 0;
+}
+
+int nl80211_get_txpower_offset(const char *ifname, int *buf)
+{
+ const struct iwinfo_hardware_entry *hw;
+
+ if (!(hw = nl80211_get_hardware_entry(ifname)))
+ return -1;
+
+ *buf = hw->txpower_offset;
+ return 0;
+}
+
+int nl80211_get_frequency_offset(const char *ifname, int *buf)
+{
+ const struct iwinfo_hardware_entry *hw;
+
+ if (!(hw = nl80211_get_hardware_entry(ifname)))
+ return -1;
+
+ *buf = hw->frequency_offset;
+ return 0;
+}
diff --git a/package/network/utils/iwinfo/src/iwinfo_utils.c b/package/network/utils/iwinfo/src/iwinfo_utils.c
new file mode 100644
index 0000000..6616f14
--- /dev/null
+++ b/package/network/utils/iwinfo/src/iwinfo_utils.c
@@ -0,0 +1,349 @@
+/*
+ * iwinfo - Wireless Information Library - Shared utility routines
+ *
+ * Copyright (C) 2010 Jo-Philipp Wich <xm@subsignal.org>
+ *
+ * The iwinfo library is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * The iwinfo library 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 the iwinfo library. If not, see http://www.gnu.org/licenses/.
+ *
+ * The signal handling code is derived from the official madwifi tools,
+ * wlanconfig.c in particular. The encryption property handling was
+ * inspired by the hostapd madwifi driver.
+ */
+
+#include "iwinfo/utils.h"
+
+
+static int ioctl_socket = -1;
+
+static int iwinfo_ioctl_socket(void)
+{
+ /* Prepare socket */
+ if (ioctl_socket == -1)
+ {
+ ioctl_socket = socket(AF_INET, SOCK_DGRAM, 0);
+ fcntl(ioctl_socket, F_SETFD, fcntl(ioctl_socket, F_GETFD) | FD_CLOEXEC);
+ }
+
+ return ioctl_socket;
+}
+
+int iwinfo_ioctl(int cmd, void *ifr)
+{
+ int s = iwinfo_ioctl_socket();
+ return ioctl(s, cmd, ifr);
+}
+
+int iwinfo_dbm2mw(int in)
+{
+ double res = 1.0;
+ int ip = in / 10;
+ int fp = in % 10;
+ int k;
+
+ for(k = 0; k < ip; k++) res *= 10;
+ for(k = 0; k < fp; k++) res *= LOG10_MAGIC;
+
+ return (int)res;
+}
+
+int iwinfo_mw2dbm(int in)
+{
+ double fin = (double) in;
+ int res = 0;
+
+ while(fin > 10.0)
+ {
+ res += 10;
+ fin /= 10.0;
+ }
+
+ while(fin > 1.000001)
+ {
+ res += 1;
+ fin /= LOG10_MAGIC;
+ }
+
+ return (int)res;
+}
+
+int iwinfo_ifup(const char *ifname)
+{
+ struct ifreq ifr;
+
+ strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
+
+ if (iwinfo_ioctl(SIOCGIFFLAGS, &ifr))
+ return 0;
+
+ ifr.ifr_flags |= (IFF_UP | IFF_RUNNING);
+
+ return !iwinfo_ioctl(SIOCSIFFLAGS, &ifr);
+}
+
+int iwinfo_ifdown(const char *ifname)
+{
+ struct ifreq ifr;
+
+ strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
+
+ if (iwinfo_ioctl(SIOCGIFFLAGS, &ifr))
+ return 0;
+
+ ifr.ifr_flags &= ~(IFF_UP | IFF_RUNNING);
+
+ return !iwinfo_ioctl(SIOCSIFFLAGS, &ifr);
+}
+
+int iwinfo_ifmac(const char *ifname)
+{
+ struct ifreq ifr;
+
+ strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
+
+ if (iwinfo_ioctl(SIOCGIFHWADDR, &ifr))
+ return 0;
+
+ ifr.ifr_hwaddr.sa_data[1]++;
+ ifr.ifr_hwaddr.sa_data[2]++;
+
+ return !iwinfo_ioctl(SIOCSIFHWADDR, &ifr);
+}
+
+void iwinfo_close(void)
+{
+ if (ioctl_socket > -1)
+ close(ioctl_socket);
+
+ ioctl_socket = -1;
+}
+
+struct iwinfo_hardware_entry * iwinfo_hardware(struct iwinfo_hardware_id *id)
+{
+ const struct iwinfo_hardware_entry *e;
+
+ for (e = IWINFO_HARDWARE_ENTRIES; e->vendor_name; e++)
+ {
+ if ((e->vendor_id != 0xffff) && (e->vendor_id != id->vendor_id))
+ continue;
+
+ if ((e->device_id != 0xffff) && (e->device_id != id->device_id))
+ continue;
+
+ if ((e->subsystem_vendor_id != 0xffff) &&
+ (e->subsystem_vendor_id != id->subsystem_vendor_id))
+ continue;
+
+ if ((e->subsystem_device_id != 0xffff) &&
+ (e->subsystem_device_id != id->subsystem_device_id))
+ continue;
+
+ return (struct iwinfo_hardware_entry *)e;
+ }
+
+ return NULL;
+}
+
+int iwinfo_hardware_id_from_mtd(struct iwinfo_hardware_id *id)
+{
+ FILE *mtd;
+ uint16_t *bc;
+
+ int fd, len, off;
+ char buf[128];
+
+ if (!(mtd = fopen("/proc/mtd", "r")))
+ return -1;
+
+ while (fgets(buf, sizeof(buf), mtd) > 0)
+ {
+ if (fscanf(mtd, "mtd%d: %*x %x %127s", &off, &len, buf) < 3 ||
+ (strcmp(buf, "\"boardconfig\"") && strcmp(buf, "\"EEPROM\"") &&
+ strcmp(buf, "\"factory\"")))
+ {
+ off = -1;
+ continue;
+ }
+
+ break;
+ }
+
+ fclose(mtd);
+
+ if (off < 0)
+ return -1;
+
+ snprintf(buf, sizeof(buf), "/dev/mtdblock%d", off);
+
+ if ((fd = open(buf, O_RDONLY)) < 0)
+ return -1;
+
+ bc = mmap(NULL, len, PROT_READ, MAP_PRIVATE|MAP_LOCKED, fd, 0);
+
+ if ((void *)bc != MAP_FAILED)
+ {
+ id->vendor_id = 0;
+ id->device_id = 0;
+
+ for (off = len / 2 - 0x800; off >= 0; off -= 0x800)
+ {
+ /* AR531X board data magic */
+ if ((bc[off] == 0x3533) && (bc[off + 1] == 0x3131))
+ {
+ id->vendor_id = bc[off + 0x7d];
+ id->device_id = bc[off + 0x7c];
+ id->subsystem_vendor_id = bc[off + 0x84];
+ id->subsystem_device_id = bc[off + 0x83];
+ break;
+ }
+
+ /* AR5416 EEPROM magic */
+ else if ((bc[off] == 0xA55A) || (bc[off] == 0x5AA5))
+ {
+ id->vendor_id = bc[off + 0x0D];
+ id->device_id = bc[off + 0x0E];
+ id->subsystem_vendor_id = bc[off + 0x13];
+ id->subsystem_device_id = bc[off + 0x14];
+ break;
+ }
+
+ /* Rt3xxx SoC */
+ else if ((bc[off] == 0x3352) || (bc[off] == 0x5233) ||
+ (bc[off] == 0x3350) || (bc[off] == 0x5033) ||
+ (bc[off] == 0x3050) || (bc[off] == 0x5030) ||
+ (bc[off] == 0x3052) || (bc[off] == 0x5230))
+ {
+ /* vendor: RaLink */
+ id->vendor_id = 0x1814;
+ id->subsystem_vendor_id = 0x1814;
+
+ /* device */
+ if (bc[off] & 0xf0 == 0x30)
+ id->device_id = (bc[off] >> 8) | (bc[off] & 0x00ff) << 8;
+ else
+ id->device_id = bc[off];
+
+ /* subsystem from EEPROM_NIC_CONF0_RF_TYPE */
+ id->subsystem_device_id = (bc[off + 0x1a] & 0x0f00) >> 8;
+ }
+ }
+
+ munmap(bc, len);
+ }
+
+ close(fd);
+
+ return (id->vendor_id && id->device_id) ? 0 : -1;
+}
+
+void iwinfo_parse_rsn(struct iwinfo_crypto_entry *c, uint8_t *data, uint8_t len,
+ uint8_t defcipher, uint8_t defauth)
+{
+ uint16_t i, count;
+
+ static unsigned char ms_oui[3] = { 0x00, 0x50, 0xf2 };
+ static unsigned char ieee80211_oui[3] = { 0x00, 0x0f, 0xac };
+
+ data += 2;
+ len -= 2;
+
+ if (!memcmp(data, ms_oui, 3))
+ c->wpa_version += 1;
+ else if (!memcmp(data, ieee80211_oui, 3))
+ c->wpa_version += 2;
+
+ if (len < 4)
+ {
+ c->group_ciphers |= defcipher;
+ c->pair_ciphers |= defcipher;
+ c->auth_suites |= defauth;
+ return;
+ }
+
+ if (!memcmp(data, ms_oui, 3) || !memcmp(data, ieee80211_oui, 3))
+ {
+ switch (data[3])
+ {
+ case 1: c->group_ciphers |= IWINFO_CIPHER_WEP40; break;
+ case 2: c->group_ciphers |= IWINFO_CIPHER_TKIP; break;
+ case 4: c->group_ciphers |= IWINFO_CIPHER_CCMP; break;
+ case 5: c->group_ciphers |= IWINFO_CIPHER_WEP104; break;
+ case 6: /* AES-128-CMAC */ break;
+ default: /* proprietary */ break;
+ }
+ }
+
+ data += 4;
+ len -= 4;
+
+ if (len < 2)
+ {
+ c->pair_ciphers |= defcipher;
+ c->auth_suites |= defauth;
+ return;
+ }
+
+ count = data[0] | (data[1] << 8);
+ if (2 + (count * 4) > len)
+ return;
+
+ for (i = 0; i < count; i++)
+ {
+ if (!memcmp(data + 2 + (i * 4), ms_oui, 3) ||
+ !memcmp(data + 2 + (i * 4), ieee80211_oui, 3))
+ {
+ switch (data[2 + (i * 4) + 3])
+ {
+ case 1: c->pair_ciphers |= IWINFO_CIPHER_WEP40; break;
+ case 2: c->pair_ciphers |= IWINFO_CIPHER_TKIP; break;
+ case 4: c->pair_ciphers |= IWINFO_CIPHER_CCMP; break;
+ case 5: c->pair_ciphers |= IWINFO_CIPHER_WEP104; break;
+ case 6: /* AES-128-CMAC */ break;
+ default: /* proprietary */ break;
+ }
+ }
+ }
+
+ data += 2 + (count * 4);
+ len -= 2 + (count * 4);
+
+ if (len < 2)
+ {
+ c->auth_suites |= defauth;
+ return;
+ }
+
+ count = data[0] | (data[1] << 8);
+ if (2 + (count * 4) > len)
+ return;
+
+ for (i = 0; i < count; i++)
+ {
+ if (!memcmp(data + 2 + (i * 4), ms_oui, 3) ||
+ !memcmp(data + 2 + (i * 4), ieee80211_oui, 3))
+ {
+ switch (data[2 + (i * 4) + 3])
+ {
+ case 1: c->auth_suites |= IWINFO_KMGMT_8021x; break;
+ case 2: c->auth_suites |= IWINFO_KMGMT_PSK; break;
+ case 3: /* FT/IEEE 802.1X */ break;
+ case 4: /* FT/PSK */ break;
+ case 5: /* IEEE 802.1X/SHA-256 */ break;
+ case 6: /* PSK/SHA-256 */ break;
+ default: /* proprietary */ break;
+ }
+ }
+ }
+
+ data += 2 + (count * 4);
+ len -= 2 + (count * 4);
+}
diff --git a/package/network/utils/iwinfo/src/iwinfo_wext.c b/package/network/utils/iwinfo/src/iwinfo_wext.c
new file mode 100644
index 0000000..cf3dccc
--- /dev/null
+++ b/package/network/utils/iwinfo/src/iwinfo_wext.c
@@ -0,0 +1,520 @@
+/*
+ * iwinfo - Wireless Information Library - Linux Wireless Extension Backend
+ *
+ * Copyright (C) 2009 Jo-Philipp Wich <xm@subsignal.org>
+ *
+ * The iwinfo library is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * The iwinfo library 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 the iwinfo library. If not, see http://www.gnu.org/licenses/.
+ *
+ * Parts of this code are derived from the Linux wireless tools, iwlib.c,
+ * iwlist.c and iwconfig.c in particular.
+ */
+
+#include "iwinfo.h"
+#include "iwinfo/wext.h"
+
+static double wext_freq2float(const struct iw_freq *in)
+{
+ int i;
+ double res = (double) in->m;
+ for(i = 0; i < in->e; i++) res *= 10;
+ return res;
+}
+
+static inline int wext_freq2mhz(const struct iw_freq *in)
+{
+ int i;
+
+ if( in->e == 6 )
+ {
+ return in->m;
+ }
+ else
+ {
+ return (int)(wext_freq2float(in) / 1000000);
+ }
+}
+
+static inline int wext_ioctl(const char *ifname, int cmd, struct iwreq *wrq)
+{
+ if( !strncmp(ifname, "mon.", 4) )
+ strncpy(wrq->ifr_name, &ifname[4], IFNAMSIZ);
+ else
+ strncpy(wrq->ifr_name, ifname, IFNAMSIZ);
+
+ return iwinfo_ioctl(cmd, wrq);
+}
+
+
+int wext_probe(const char *ifname)
+{
+ struct iwreq wrq;
+
+ if(wext_ioctl(ifname, SIOCGIWNAME, &wrq) >= 0)
+ return 1;
+
+ return 0;
+}
+
+void wext_close(void)
+{
+ /* Nop */
+}
+
+int wext_get_mode(const char *ifname, int *buf)
+{
+ struct iwreq wrq;
+
+ if(wext_ioctl(ifname, SIOCGIWMODE, &wrq) >= 0)
+ {
+ switch(wrq.u.mode)
+ {
+ case 1:
+ *buf = IWINFO_OPMODE_ADHOC;
+ break;
+
+ case 2:
+ *buf = IWINFO_OPMODE_CLIENT;
+ break;
+
+ case 3:
+ *buf = IWINFO_OPMODE_MASTER;
+ break;
+
+ case 6:
+ *buf = IWINFO_OPMODE_MONITOR;
+ break;
+
+ default:
+ *buf = IWINFO_OPMODE_UNKNOWN;
+ break;
+ }
+
+ return 0;
+ }
+
+ return -1;
+}
+
+int wext_get_ssid(const char *ifname, char *buf)
+{
+ struct iwreq wrq;
+
+ wrq.u.essid.pointer = (caddr_t) buf;
+ wrq.u.essid.length = IW_ESSID_MAX_SIZE + 1;
+ wrq.u.essid.flags = 0;
+
+ if(wext_ioctl(ifname, SIOCGIWESSID, &wrq) >= 0)
+ return 0;
+
+ return -1;
+}
+
+int wext_get_bssid(const char *ifname, char *buf)
+{
+ struct iwreq wrq;
+
+ if(wext_ioctl(ifname, SIOCGIWAP, &wrq) >= 0)
+ {
+ sprintf(buf, "%02X:%02X:%02X:%02X:%02X:%02X",
+ (uint8_t)wrq.u.ap_addr.sa_data[0], (uint8_t)wrq.u.ap_addr.sa_data[1],
+ (uint8_t)wrq.u.ap_addr.sa_data[2], (uint8_t)wrq.u.ap_addr.sa_data[3],
+ (uint8_t)wrq.u.ap_addr.sa_data[4], (uint8_t)wrq.u.ap_addr.sa_data[5]);
+
+ return 0;
+ }
+
+ return -1;
+}
+
+int wext_get_bitrate(const char *ifname, int *buf)
+{
+ struct iwreq wrq;
+
+ if(wext_ioctl(ifname, SIOCGIWRATE, &wrq) >= 0)
+ {
+ *buf = (wrq.u.bitrate.value / 1000);
+ return 0;
+ }
+
+ return -1;
+}
+
+int wext_get_channel(const char *ifname, int *buf)
+{
+ struct iwreq wrq;
+ struct iw_range range;
+ double freq;
+ int i;
+
+ if(wext_ioctl(ifname, SIOCGIWFREQ, &wrq) >= 0)
+ {
+ if( wrq.u.freq.m >= 1000 )
+ {
+ freq = wext_freq2float(&wrq.u.freq);
+ wrq.u.data.pointer = (caddr_t) &range;
+ wrq.u.data.length = sizeof(struct iw_range);
+ wrq.u.data.flags = 0;
+
+ if(wext_ioctl(ifname, SIOCGIWRANGE, &wrq) >= 0)
+ {
+ for(i = 0; i < range.num_frequency; i++)
+ {
+ if( wext_freq2float(&range.freq[i]) == freq )
+ {
+ *buf = range.freq[i].i;
+ return 0;
+ }
+ }
+ }
+ }
+ else
+ {
+ *buf = wrq.u.freq.m;
+ return 0;
+ }
+ }
+
+ return -1;
+}
+
+int wext_get_frequency(const char *ifname, int *buf)
+{
+ struct iwreq wrq;
+ struct iw_range range;
+ int i, channel;
+
+ if(wext_ioctl(ifname, SIOCGIWFREQ, &wrq) >= 0)
+ {
+ /* We got a channel number instead ... */
+ if( wrq.u.freq.m < 1000 )
+ {
+ channel = wrq.u.freq.m;
+ wrq.u.data.pointer = (caddr_t) &range;
+ wrq.u.data.length = sizeof(struct iw_range);
+ wrq.u.data.flags = 0;
+
+ if(wext_ioctl(ifname, SIOCGIWRANGE, &wrq) >= 0)
+ {
+ for(i = 0; i < range.num_frequency; i++)
+ {
+ if( range.freq[i].i == channel )
+ {
+ *buf = wext_freq2mhz(&range.freq[i]);
+ return 0;
+ }
+ }
+ }
+ }
+ else
+ {
+ *buf = wext_freq2mhz(&wrq.u.freq);
+ return 0;
+ }
+ }
+
+ return -1;
+}
+
+int wext_get_txpower(const char *ifname, int *buf)
+{
+ struct iwreq wrq;
+
+ wrq.u.txpower.flags = 0;
+
+ if(wext_ioctl(ifname, SIOCGIWTXPOW, &wrq) >= 0)
+ {
+ if(wrq.u.txpower.flags & IW_TXPOW_MWATT)
+ *buf = iwinfo_mw2dbm(wrq.u.txpower.value);
+ else
+ *buf = wrq.u.txpower.value;
+
+ return 0;
+ }
+
+ return -1;
+}
+
+int wext_get_signal(const char *ifname, int *buf)
+{
+ struct iwreq wrq;
+ struct iw_statistics stats;
+
+ wrq.u.data.pointer = (caddr_t) &stats;
+ wrq.u.data.length = sizeof(struct iw_statistics);
+ wrq.u.data.flags = 1;
+
+ if(wext_ioctl(ifname, SIOCGIWSTATS, &wrq) >= 0)
+ {
+ *buf = (stats.qual.updated & IW_QUAL_DBM)
+ ? (stats.qual.level - 0x100) : stats.qual.level;
+
+ return 0;
+ }
+
+ return -1;
+}
+
+int wext_get_noise(const char *ifname, int *buf)
+{
+ struct iwreq wrq;
+ struct iw_statistics stats;
+
+ wrq.u.data.pointer = (caddr_t) &stats;
+ wrq.u.data.length = sizeof(struct iw_statistics);
+ wrq.u.data.flags = 1;
+
+ if(wext_ioctl(ifname, SIOCGIWSTATS, &wrq) >= 0)
+ {
+ *buf = (stats.qual.updated & IW_QUAL_DBM)
+ ? (stats.qual.noise - 0x100) : stats.qual.noise;
+
+ return 0;
+ }
+
+ return -1;
+}
+
+int wext_get_quality(const char *ifname, int *buf)
+{
+ struct iwreq wrq;
+ struct iw_statistics stats;
+
+ wrq.u.data.pointer = (caddr_t) &stats;
+ wrq.u.data.length = sizeof(struct iw_statistics);
+ wrq.u.data.flags = 1;
+
+ if(wext_ioctl(ifname, SIOCGIWSTATS, &wrq) >= 0)
+ {
+ *buf = stats.qual.qual;
+ return 0;
+ }
+
+ return -1;
+}
+
+int wext_get_quality_max(const char *ifname, int *buf)
+{
+ struct iwreq wrq;
+ struct iw_range range;
+
+ wrq.u.data.pointer = (caddr_t) &range;
+ wrq.u.data.length = sizeof(struct iw_range);
+ wrq.u.data.flags = 0;
+
+ if(wext_ioctl(ifname, SIOCGIWRANGE, &wrq) >= 0)
+ {
+ *buf = range.max_qual.qual;
+ return 0;
+ }
+
+ return -1;
+}
+
+int wext_get_assoclist(const char *ifname, char *buf, int *len)
+{
+ /* Stub */
+ return -1;
+}
+
+int wext_get_txpwrlist(const char *ifname, char *buf, int *len)
+{
+ struct iwreq wrq;
+ struct iw_range range;
+ struct iwinfo_txpwrlist_entry entry;
+ int i;
+
+ wrq.u.data.pointer = (caddr_t) &range;
+ wrq.u.data.length = sizeof(struct iw_range);
+ wrq.u.data.flags = 0;
+
+ if( (wext_ioctl(ifname, SIOCGIWRANGE, &wrq) >= 0) &&
+ (range.num_txpower > 0) && (range.num_txpower <= IW_MAX_TXPOWER) &&
+ !(range.txpower_capa & IW_TXPOW_RELATIVE)
+ ) {
+ for( i = 0; i < range.num_txpower; i++ )
+ {
+ if( range.txpower_capa & IW_TXPOW_MWATT )
+ {
+ entry.dbm = iwinfo_mw2dbm(range.txpower[i]);
+ entry.mw = range.txpower[i];
+ }
+
+ /* Madwifi does neither set mW not dBm caps, also iwlist assumes
+ * dBm if mW is not set, so don't check here... */
+ else /* if( range.txpower_capa & IW_TXPOW_DBM ) */
+ {
+ entry.dbm = range.txpower[i];
+ entry.mw = iwinfo_dbm2mw(range.txpower[i]);
+ }
+
+ memcpy(&buf[i*sizeof(entry)], &entry, sizeof(entry));
+ }
+
+ *len = i * sizeof(entry);
+ return 0;
+ }
+
+ return -1;
+}
+
+int wext_get_freqlist(const char *ifname, char *buf, int *len)
+{
+ struct iwreq wrq;
+ struct iw_range range;
+ struct iwinfo_freqlist_entry entry;
+ int i, bl;
+
+ wrq.u.data.pointer = (caddr_t) &range;
+ wrq.u.data.length = sizeof(struct iw_range);
+ wrq.u.data.flags = 0;
+
+ if(wext_ioctl(ifname, SIOCGIWRANGE, &wrq) >= 0)
+ {
+ bl = 0;
+
+ for(i = 0; i < range.num_frequency; i++)
+ {
+ entry.mhz = wext_freq2mhz(&range.freq[i]);
+ entry.channel = range.freq[i].i;
+ entry.restricted = 0;
+
+ memcpy(&buf[bl], &entry, sizeof(struct iwinfo_freqlist_entry));
+ bl += sizeof(struct iwinfo_freqlist_entry);
+ }
+
+ *len = bl;
+ return 0;
+ }
+
+ return -1;
+}
+
+int wext_get_country(const char *ifname, char *buf)
+{
+ sprintf(buf, "00");
+ return 0;
+}
+
+int wext_get_countrylist(const char *ifname, char *buf, int *len)
+{
+ /* Stub */
+ return -1;
+}
+
+int wext_get_hwmodelist(const char *ifname, int *buf)
+{
+ char chans[IWINFO_BUFSIZE] = { 0 };
+ struct iwinfo_freqlist_entry *e = NULL;
+ int len = 0;
+
+ *buf = 0;
+
+ if( !wext_get_freqlist(ifname, chans, &len) )
+ {
+ for( e = (struct iwinfo_freqlist_entry *)chans; e->channel; e++ )
+ {
+ if( e->channel <= 14 )
+ {
+ *buf |= IWINFO_80211_B;
+ *buf |= IWINFO_80211_G;
+ }
+ else
+ {
+ *buf |= IWINFO_80211_A;
+ }
+ }
+
+ return 0;
+ }
+
+ return -1;
+}
+
+int wext_get_encryption(const char *ifname, char *buf)
+{
+ /* No reliable crypto info in wext */
+ return -1;
+}
+
+int wext_get_mbssid_support(const char *ifname, int *buf)
+{
+ /* No multi bssid support atm */
+ return -1;
+}
+
+static char * wext_sysfs_ifname_file(const char *ifname, const char *path)
+{
+ FILE *f;
+ static char buf[128];
+ char *rv = NULL;
+
+ snprintf(buf, sizeof(buf), "/sys/class/net/%s/%s", ifname, path);
+
+ if ((f = fopen(buf, "r")) != NULL)
+ {
+ memset(buf, 0, sizeof(buf));
+
+ if (fread(buf, 1, sizeof(buf), f))
+ rv = buf;
+
+ fclose(f);
+ }
+
+ return rv;
+}
+
+int wext_get_hardware_id(const char *ifname, char *buf)
+{
+ char *data;
+ struct iwinfo_hardware_id *id = (struct iwinfo_hardware_id *)buf;
+
+ memset(id, 0, sizeof(struct iwinfo_hardware_id));
+
+ data = wext_sysfs_ifname_file(ifname, "device/vendor");
+ if (data)
+ id->vendor_id = strtoul(data, NULL, 16);
+
+ data = wext_sysfs_ifname_file(ifname, "device/device");
+ if (data)
+ id->device_id = strtoul(data, NULL, 16);
+
+ data = wext_sysfs_ifname_file(ifname, "device/subsystem_device");
+ if (data)
+ id->subsystem_device_id = strtoul(data, NULL, 16);
+
+ data = wext_sysfs_ifname_file(ifname, "device/subsystem_vendor");
+ if (data)
+ id->subsystem_vendor_id = strtoul(data, NULL, 16);
+
+ return (id->vendor_id > 0 && id->device_id > 0) ? 0 : -1;
+}
+
+int wext_get_hardware_name(const char *ifname, char *buf)
+{
+ sprintf(buf, "Generic WEXT");
+ return 0;
+}
+
+int wext_get_txpower_offset(const char *ifname, int *buf)
+{
+ /* Stub */
+ *buf = 0;
+ return -1;
+}
+
+int wext_get_frequency_offset(const char *ifname, int *buf)
+{
+ /* Stub */
+ *buf = 0;
+ return -1;
+}
diff --git a/package/network/utils/iwinfo/src/iwinfo_wext_scan.c b/package/network/utils/iwinfo/src/iwinfo_wext_scan.c
new file mode 100644
index 0000000..ecd40d7
--- /dev/null
+++ b/package/network/utils/iwinfo/src/iwinfo_wext_scan.c
@@ -0,0 +1,527 @@
+/*
+ * iwinfo - Wireless Information Library - Linux Wireless Extension Backend
+ *
+ * Copyright (C) 2009-2010 Jo-Philipp Wich <xm@subsignal.org>
+ *
+ * The iwinfo library is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * The iwinfo library 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 the iwinfo library. If not, see http://www.gnu.org/licenses/.
+ *
+ * Parts of this code are derived from the Linux wireless tools, iwlib.c,
+ * iwlist.c and iwconfig.c in particular.
+ */
+
+#include "iwinfo.h"
+#include "iwinfo/wext_scan.h"
+
+
+static int wext_ioctl(const char *ifname, int cmd, struct iwreq *wrq)
+{
+ strncpy(wrq->ifr_name, ifname, IFNAMSIZ);
+ return iwinfo_ioctl(cmd, wrq);
+}
+
+static inline double wext_freq2float(const struct iw_freq *in)
+{
+ int i;
+ double res = (double) in->m;
+ for(i = 0; i < in->e; i++) res *= 10;
+ return res;
+}
+
+static inline int wext_extract_event(struct stream_descr *stream, struct iw_event *iwe, int wev)
+{
+ const struct iw_ioctl_description *descr = NULL;
+ int event_type = 0;
+ unsigned int event_len = 1;
+ char *pointer;
+ unsigned cmd_index; /* *MUST* be unsigned */
+
+ /* Check for end of stream */
+ if((stream->current + IW_EV_LCP_PK_LEN) > stream->end)
+ return 0;
+
+ /* Extract the event header (to get the event id).
+ * Note : the event may be unaligned, therefore copy... */
+ memcpy((char *) iwe, stream->current, IW_EV_LCP_PK_LEN);
+
+ /* Check invalid events */
+ if(iwe->len <= IW_EV_LCP_PK_LEN)
+ return -1;
+
+ /* Get the type and length of that event */
+ if(iwe->cmd <= SIOCIWLAST)
+ {
+ cmd_index = iwe->cmd - SIOCIWFIRST;
+ if(cmd_index < standard_ioctl_num)
+ descr = &(standard_ioctl_descr[cmd_index]);
+ }
+ else
+ {
+ cmd_index = iwe->cmd - IWEVFIRST;
+ if(cmd_index < standard_event_num)
+ descr = &(standard_event_descr[cmd_index]);
+ }
+
+ if(descr != NULL)
+ event_type = descr->header_type;
+
+ /* Unknown events -> event_type=0 => IW_EV_LCP_PK_LEN */
+ event_len = event_type_size[event_type];
+
+ /* Fixup for earlier version of WE */
+ if((wev <= 18) && (event_type == IW_HEADER_TYPE_POINT))
+ event_len += IW_EV_POINT_OFF;
+
+ /* Check if we know about this event */
+ if(event_len <= IW_EV_LCP_PK_LEN)
+ {
+ /* Skip to next event */
+ stream->current += iwe->len;
+ return 2;
+ }
+
+ event_len -= IW_EV_LCP_PK_LEN;
+
+ /* Set pointer on data */
+ if(stream->value != NULL)
+ pointer = stream->value; /* Next value in event */
+ else
+ pointer = stream->current + IW_EV_LCP_PK_LEN; /* First value in event */
+
+ /* Copy the rest of the event (at least, fixed part) */
+ if((pointer + event_len) > stream->end)
+ {
+ /* Go to next event */
+ stream->current += iwe->len;
+ return -2;
+ }
+
+ /* Fixup for WE-19 and later : pointer no longer in the stream */
+ /* Beware of alignement. Dest has local alignement, not packed */
+ if( (wev > 18) && (event_type == IW_HEADER_TYPE_POINT) )
+ memcpy((char *) iwe + IW_EV_LCP_LEN + IW_EV_POINT_OFF, pointer, event_len);
+ else
+ memcpy((char *) iwe + IW_EV_LCP_LEN, pointer, event_len);
+
+ /* Skip event in the stream */
+ pointer += event_len;
+
+ /* Special processing for iw_point events */
+ if(event_type == IW_HEADER_TYPE_POINT)
+ {
+ /* Check the length of the payload */
+ unsigned int extra_len = iwe->len - (event_len + IW_EV_LCP_PK_LEN);
+ if(extra_len > 0)
+ {
+ /* Set pointer on variable part (warning : non aligned) */
+ iwe->u.data.pointer = pointer;
+
+ /* Check that we have a descriptor for the command */
+ if(descr == NULL)
+ /* Can't check payload -> unsafe... */
+ iwe->u.data.pointer = NULL; /* Discard paylod */
+ else
+ {
+ /* Those checks are actually pretty hard to trigger,
+ * because of the checks done in the kernel... */
+
+ unsigned int token_len = iwe->u.data.length * descr->token_size;
+
+ /* Ugly fixup for alignement issues.
+ * If the kernel is 64 bits and userspace 32 bits,
+ * we have an extra 4+4 bytes.
+ * Fixing that in the kernel would break 64 bits userspace. */
+ if((token_len != extra_len) && (extra_len >= 4))
+ {
+ uint16_t alt_dlen = *((uint16_t *) pointer);
+ unsigned int alt_token_len = alt_dlen * descr->token_size;
+ if((alt_token_len + 8) == extra_len)
+ {
+ /* Ok, let's redo everything */
+ pointer -= event_len;
+ pointer += 4;
+ /* Dest has local alignement, not packed */
+ memcpy((char *) iwe + IW_EV_LCP_LEN + IW_EV_POINT_OFF, pointer, event_len);
+ pointer += event_len + 4;
+ iwe->u.data.pointer = pointer;
+ token_len = alt_token_len;
+ }
+ }
+
+ /* Discard bogus events which advertise more tokens than
+ * what they carry... */
+ if(token_len > extra_len)
+ iwe->u.data.pointer = NULL; /* Discard paylod */
+
+ /* Check that the advertised token size is not going to
+ * produce buffer overflow to our caller... */
+ if((iwe->u.data.length > descr->max_tokens)
+ && !(descr->flags & IW_DESCR_FLAG_NOMAX))
+ iwe->u.data.pointer = NULL; /* Discard paylod */
+
+ /* Same for underflows... */
+ if(iwe->u.data.length < descr->min_tokens)
+ iwe->u.data.pointer = NULL; /* Discard paylod */
+ }
+ }
+ else
+ /* No data */
+ iwe->u.data.pointer = NULL;
+
+ /* Go to next event */
+ stream->current += iwe->len;
+ }
+ else
+ {
+ /* Ugly fixup for alignement issues.
+ * If the kernel is 64 bits and userspace 32 bits,
+ * we have an extra 4 bytes.
+ * Fixing that in the kernel would break 64 bits userspace. */
+ if((stream->value == NULL)
+ && ((((iwe->len - IW_EV_LCP_PK_LEN) % event_len) == 4)
+ || ((iwe->len == 12) && ((event_type == IW_HEADER_TYPE_UINT) ||
+ (event_type == IW_HEADER_TYPE_QUAL))) ))
+ {
+ pointer -= event_len;
+ pointer += 4;
+ /* Beware of alignement. Dest has local alignement, not packed */
+ memcpy((char *) iwe + IW_EV_LCP_LEN, pointer, event_len);
+ pointer += event_len;
+ }
+
+ /* Is there more value in the event ? */
+ if((pointer + event_len) <= (stream->current + iwe->len))
+ /* Go to next value */
+ stream->value = pointer;
+ else
+ {
+ /* Go to next event */
+ stream->value = NULL;
+ stream->current += iwe->len;
+ }
+ }
+
+ return 1;
+}
+
+static inline void wext_fill_wpa(unsigned char *iebuf, int ielen, struct iwinfo_scanlist_entry *e)
+{
+ static unsigned char ms_oui[3] = { 0x00, 0x50, 0xf2 };
+
+ while (ielen >= 2 && ielen >= iebuf[1])
+ {
+ switch (iebuf[0])
+ {
+ case 48: /* RSN */
+ iwinfo_parse_rsn(&e->crypto, iebuf + 2, iebuf[1],
+ IWINFO_CIPHER_CCMP, IWINFO_KMGMT_8021x);
+ break;
+
+ case 221: /* Vendor */
+ if (iebuf[1] >= 4 && !memcmp(iebuf + 2, ms_oui, 3) && iebuf[5] == 1)
+ iwinfo_parse_rsn(&e->crypto, iebuf + 6, iebuf[1] - 4,
+ IWINFO_CIPHER_TKIP, IWINFO_KMGMT_PSK);
+ break;
+ }
+
+ ielen -= iebuf[1] + 2;
+ iebuf += iebuf[1] + 2;
+ }
+}
+
+
+static inline void wext_fill_entry(struct stream_descr *stream, struct iw_event *event,
+ struct iw_range *iw_range, int has_range, struct iwinfo_scanlist_entry *e)
+{
+ int i;
+ double freq;
+
+ /* Now, let's decode the event */
+ switch(event->cmd)
+ {
+ case SIOCGIWAP:
+ memcpy(e->mac, &event->u.ap_addr.sa_data, 6);
+ break;
+
+ case SIOCGIWFREQ:
+ if( event->u.freq.m >= 1000 )
+ {
+ freq = wext_freq2float(&(event->u.freq));
+
+ for(i = 0; i < iw_range->num_frequency; i++)
+ {
+ if( wext_freq2float(&iw_range->freq[i]) == freq )
+ {
+ e->channel = iw_range->freq[i].i;
+ break;
+ }
+ }
+ }
+ else
+ {
+ e->channel = event->u.freq.m;
+ }
+
+ break;
+
+ case SIOCGIWMODE:
+ switch(event->u.mode)
+ {
+ case 1:
+ e->mode = IWINFO_OPMODE_ADHOC;
+ break;
+
+ case 2:
+ case 3:
+ e->mode = IWINFO_OPMODE_MASTER;
+ break;
+
+ default:
+ e->mode = IWINFO_OPMODE_UNKNOWN;
+ break;
+ }
+
+ break;
+
+ case SIOCGIWESSID:
+ if( event->u.essid.pointer && event->u.essid.length && event->u.essid.flags )
+ memcpy(e->ssid, event->u.essid.pointer, event->u.essid.length);
+
+ break;
+
+ case SIOCGIWENCODE:
+ e->crypto.enabled = !(event->u.data.flags & IW_ENCODE_DISABLED);
+ break;
+
+ case IWEVQUAL:
+ e->signal = event->u.qual.level;
+ e->quality = event->u.qual.qual;
+ e->quality_max = iw_range->max_qual.qual;
+ break;
+#if 0
+ case SIOCGIWRATE:
+ if(state->val_index == 0)
+ {
+ lua_pushstring(L, "bitrates");
+ lua_newtable(L);
+ }
+ //iw_print_bitrate(buffer, sizeof(buffer), event->u.bitrate.value);
+ snprintf(buffer, sizeof(buffer), "%d", event->u.bitrate.value);
+ lua_pushinteger(L, state->val_index + 1);
+ lua_pushstring(L, buffer);
+ lua_settable(L, -3);
+
+ /* Check for termination */
+ if(stream->value == NULL)
+ {
+ lua_settable(L, -3);
+ state->val_index = 0;
+ } else
+ state->val_index++;
+ break;
+#endif
+ case IWEVGENIE:
+ wext_fill_wpa(event->u.data.pointer, event->u.data.length, e);
+ break;
+ }
+}
+
+
+int wext_get_scanlist(const char *ifname, char *buf, int *len)
+{
+ struct iwreq wrq;
+ struct iw_scan_req scanopt; /* Options for 'set' */
+ unsigned char *buffer = NULL; /* Results */
+ int buflen = IW_SCAN_MAX_DATA; /* Min for compat WE<17 */
+ struct iw_range range;
+ int has_range = 1;
+ struct timeval tv; /* Select timeout */
+ int timeout = 15000000; /* 15s */
+
+ int entrylen = 0;
+ struct iwinfo_scanlist_entry e;
+
+ wrq.u.data.pointer = (caddr_t) &range;
+ wrq.u.data.length = sizeof(struct iw_range);
+ wrq.u.data.flags = 0;
+
+ if( wext_ioctl(ifname, SIOCGIWRANGE, &wrq) >= 0 )
+ {
+ /* Init timeout value -> 250ms between set and first get */
+ tv.tv_sec = 0;
+ tv.tv_usec = 250000;
+
+ /* Clean up set args */
+ memset(&scanopt, 0, sizeof(scanopt));
+
+ wrq.u.data.pointer = NULL;
+ wrq.u.data.flags = 0;
+ wrq.u.data.length = 0;
+
+ /* Initiate Scanning */
+ if( wext_ioctl(ifname, SIOCSIWSCAN, &wrq) >= 0 )
+ {
+ timeout -= tv.tv_usec;
+
+ /* Forever */
+ while(1)
+ {
+ fd_set rfds; /* File descriptors for select */
+ int last_fd; /* Last fd */
+ int ret;
+
+ /* Guess what ? We must re-generate rfds each time */
+ FD_ZERO(&rfds);
+ last_fd = -1;
+ /* In here, add the rtnetlink fd in the list */
+
+ /* Wait until something happens */
+ ret = select(last_fd + 1, &rfds, NULL, NULL, &tv);
+
+ /* Check if there was an error */
+ if(ret < 0)
+ {
+ if(errno == EAGAIN || errno == EINTR)
+ continue;
+
+ return -1;
+ }
+
+ /* Check if there was a timeout */
+ if(ret == 0)
+ {
+ unsigned char *newbuf;
+
+ realloc:
+ /* (Re)allocate the buffer - realloc(NULL, len) == malloc(len) */
+ newbuf = realloc(buffer, buflen);
+ if(newbuf == NULL)
+ {
+ if(buffer)
+ free(buffer);
+
+ return -1;
+ }
+
+ buffer = newbuf;
+
+ /* Try to read the results */
+ wrq.u.data.pointer = buffer;
+ wrq.u.data.flags = 0;
+ wrq.u.data.length = buflen;
+
+ if( wext_ioctl(ifname, SIOCGIWSCAN, &wrq) )
+ {
+ /* Check if buffer was too small (WE-17 only) */
+ if((errno == E2BIG) && (range.we_version_compiled > 16))
+ {
+ /* Some driver may return very large scan results, either
+ * because there are many cells, or because they have many
+ * large elements in cells (like IWEVCUSTOM). Most will
+ * only need the regular sized buffer. We now use a dynamic
+ * allocation of the buffer to satisfy everybody. Of course,
+ * as we don't know in advance the size of the array, we try
+ * various increasing sizes. Jean II */
+
+ /* Check if the driver gave us any hints. */
+ if(wrq.u.data.length > buflen)
+ buflen = wrq.u.data.length;
+ else
+ buflen *= 2;
+
+ /* Try again */
+ goto realloc;
+ }
+
+ /* Check if results not available yet */
+ if(errno == EAGAIN)
+ {
+ /* Restart timer for only 100ms*/
+ tv.tv_sec = 0;
+ tv.tv_usec = 100000;
+ timeout -= tv.tv_usec;
+
+ if(timeout > 0)
+ continue; /* Try again later */
+ }
+
+ /* Bad error */
+ free(buffer);
+ return -1;
+
+ } else {
+ /* We have the results, go to process them */
+ break;
+ }
+ }
+ }
+
+ if( wrq.u.data.length )
+ {
+ struct iw_event iwe;
+ struct stream_descr stream;
+ int ret;
+ int first = 1;
+
+ memset(&stream, 0, sizeof(stream));
+ stream.current = (char *)buffer;
+ stream.end = (char *)buffer + wrq.u.data.length;
+
+ do
+ {
+ /* Extract an event and print it */
+ ret = wext_extract_event(&stream, &iwe, range.we_version_compiled);
+
+ if(ret >= 0)
+ {
+ if( (iwe.cmd == SIOCGIWAP) || (ret == 0) )
+ {
+ if( first )
+ {
+ first = 0;
+ }
+ else if( (entrylen + sizeof(struct iwinfo_scanlist_entry)) <= IWINFO_BUFSIZE )
+ {
+ /* if encryption is off, clear the crypto strunct */
+ if( !e.crypto.enabled )
+ memset(&e.crypto, 0, sizeof(struct iwinfo_crypto_entry));
+
+ memcpy(&buf[entrylen], &e, sizeof(struct iwinfo_scanlist_entry));
+ entrylen += sizeof(struct iwinfo_scanlist_entry);
+ }
+ else
+ {
+ /* we exceed the callers buffer size, abort here ... */
+ break;
+ }
+
+ memset(&e, 0, sizeof(struct iwinfo_scanlist_entry));
+ }
+
+ wext_fill_entry(&stream, &iwe, &range, has_range, &e);
+ }
+
+ } while(ret > 0);
+
+ free(buffer);
+ *len = entrylen;
+ return 0;
+ }
+
+ *len = 0;
+ free(buffer);
+ return 0;
+ }
+ }
+
+ return -1;
+}
diff --git a/package/network/utils/iwinfo/src/iwinfo_wl.c b/package/network/utils/iwinfo/src/iwinfo_wl.c
new file mode 100644
index 0000000..3d15fc9
--- /dev/null
+++ b/package/network/utils/iwinfo/src/iwinfo_wl.c
@@ -0,0 +1,645 @@
+/*
+ * iwinfo - Wireless Information Library - Broadcom wl.o Backend
+ *
+ * Copyright (C) 2009 Jo-Philipp Wich <xm@subsignal.org>
+ *
+ * The iwinfo library is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * The iwinfo library 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 the iwinfo library. If not, see http://www.gnu.org/licenses/.
+ *
+ * This code is based on the wlc.c utility published by OpenWrt.org .
+ */
+
+#include "iwinfo/wl.h"
+#include "iwinfo/wext.h"
+
+static int wl_ioctl(const char *name, int cmd, void *buf, int len)
+{
+ struct ifreq ifr;
+ wl_ioctl_t ioc;
+
+ /* do it */
+ ioc.cmd = cmd;
+ ioc.buf = buf;
+ ioc.len = len;
+
+ strncpy(ifr.ifr_name, name, IFNAMSIZ);
+ ifr.ifr_data = (caddr_t) &ioc;
+
+ return iwinfo_ioctl(SIOCDEVPRIVATE, &ifr);
+}
+
+static int wl_iovar(const char *name, const char *cmd, const char *arg,
+ int arglen, void *buf, int buflen)
+{
+ int cmdlen = strlen(cmd) + 1;
+
+ memcpy(buf, cmd, cmdlen);
+
+ if (arg && arglen > 0)
+ memcpy(buf + cmdlen, arg, arglen);
+
+ return wl_ioctl(name, WLC_GET_VAR, buf, buflen);
+}
+
+static struct wl_maclist * wl_read_assoclist(const char *ifname)
+{
+ struct wl_maclist *macs;
+ int maclen = 4 + WL_MAX_STA_COUNT * 6;
+
+ if ((macs = (struct wl_maclist *) malloc(maclen)) != NULL)
+ {
+ memset(macs, 0, maclen);
+ macs->count = WL_MAX_STA_COUNT;
+
+ if (!wl_ioctl(ifname, WLC_GET_ASSOCLIST, macs, maclen))
+ return macs;
+
+ free(macs);
+ }
+
+ return NULL;
+}
+
+
+int wl_probe(const char *ifname)
+{
+ int magic;
+ return (!wl_ioctl(ifname, WLC_GET_MAGIC, &magic, sizeof(magic)) &&
+ (magic == WLC_IOCTL_MAGIC));
+}
+
+void wl_close(void)
+{
+ /* Nop */
+}
+
+int wl_get_mode(const char *ifname, int *buf)
+{
+ int ret = -1;
+ int ap, infra, passive;
+
+ if ((ret = wl_ioctl(ifname, WLC_GET_AP, &ap, sizeof(ap))))
+ return ret;
+
+ if ((ret = wl_ioctl(ifname, WLC_GET_INFRA, &infra, sizeof(infra))))
+ return ret;
+
+ if ((ret = wl_ioctl(ifname, WLC_GET_PASSIVE, &passive, sizeof(passive))))
+ return ret;
+
+ if (passive)
+ *buf = IWINFO_OPMODE_MONITOR;
+ else if (!infra)
+ *buf = IWINFO_OPMODE_ADHOC;
+ else if (ap)
+ *buf = IWINFO_OPMODE_MASTER;
+ else
+ *buf = IWINFO_OPMODE_CLIENT;
+
+ return 0;
+}
+
+int wl_get_ssid(const char *ifname, char *buf)
+{
+ int ret = -1;
+ wlc_ssid_t ssid;
+
+ if (!(ret = wl_ioctl(ifname, WLC_GET_SSID, &ssid, sizeof(ssid))))
+ memcpy(buf, ssid.ssid, ssid.ssid_len);
+
+ return ret;
+}
+
+int wl_get_bssid(const char *ifname, char *buf)
+{
+ int ret = -1;
+ char bssid[6];
+
+ if (!(ret = wl_ioctl(ifname, WLC_GET_BSSID, bssid, 6)))
+ sprintf(buf, "%02X:%02X:%02X:%02X:%02X:%02X",
+ (uint8_t)bssid[0], (uint8_t)bssid[1], (uint8_t)bssid[2],
+ (uint8_t)bssid[3], (uint8_t)bssid[4], (uint8_t)bssid[5]
+ );
+
+ return ret;
+}
+
+int wl_get_channel(const char *ifname, int *buf)
+{
+ return wl_ioctl(ifname, WLC_GET_CHANNEL, buf, sizeof(buf));
+}
+
+int wl_get_frequency(const char *ifname, int *buf)
+{
+ return wext_get_frequency(ifname, buf);
+}
+
+int wl_get_txpower(const char *ifname, int *buf)
+{
+ /* WLC_GET_VAR "qtxpower" */
+ return wext_get_txpower(ifname, buf);
+}
+
+int wl_get_bitrate(const char *ifname, int *buf)
+{
+ int ret = -1;
+ int rate = 0;
+
+ if( !(ret = wl_ioctl(ifname, WLC_GET_RATE, &rate, sizeof(rate))) && (rate > 0))
+ *buf = ((rate / 2) * 1000) + ((rate & 1) ? 500 : 0);
+
+ return ret;
+}
+
+int wl_get_signal(const char *ifname, int *buf)
+{
+ unsigned int ap, rssi, i, rssi_count;
+ int ioctl_req_version = 0x2000;
+ char tmp[WLC_IOCTL_MAXLEN];
+ struct wl_maclist *macs = NULL;
+ wl_sta_rssi_t starssi;
+
+ memset(tmp, 0, WLC_IOCTL_MAXLEN);
+ memcpy(tmp, &ioctl_req_version, sizeof(ioctl_req_version));
+
+ wl_ioctl(ifname, WLC_GET_BSS_INFO, tmp, WLC_IOCTL_MAXLEN);
+
+ if (!wl_ioctl(ifname, WLC_GET_AP, &ap, sizeof(ap)) && !ap)
+ {
+ *buf = tmp[WL_BSS_RSSI_OFFSET];
+ }
+ else
+ {
+ rssi = rssi_count = 0;
+
+ /* Calculate average rssi from conntected stations */
+ if ((macs = wl_read_assoclist(ifname)) != NULL)
+ {
+ for (i = 0; i < macs->count; i++)
+ {
+ memcpy(starssi.mac, &macs->ea[i], 6);
+
+ if (!wl_ioctl(ifname, WLC_GET_RSSI, &starssi, 12))
+ {
+ rssi -= starssi.rssi;
+ rssi_count++;
+ }
+ }
+
+ free(macs);
+ }
+
+ *buf = (rssi == 0 || rssi_count == 0) ? 1 : -(rssi / rssi_count);
+ }
+
+ return 0;
+}
+
+int wl_get_noise(const char *ifname, int *buf)
+{
+ unsigned int ap, noise;
+ int ioctl_req_version = 0x2000;
+ char tmp[WLC_IOCTL_MAXLEN];
+
+ memset(tmp, 0, WLC_IOCTL_MAXLEN);
+ memcpy(tmp, &ioctl_req_version, sizeof(ioctl_req_version));
+
+ wl_ioctl(ifname, WLC_GET_BSS_INFO, tmp, WLC_IOCTL_MAXLEN);
+
+ if ((wl_ioctl(ifname, WLC_GET_AP, &ap, sizeof(ap)) < 0) || ap)
+ {
+ if (wl_ioctl(ifname, WLC_GET_PHY_NOISE, &noise, sizeof(noise)) < 0)
+ noise = 0;
+ }
+ else
+ {
+ noise = tmp[WL_BSS_NOISE_OFFSET];
+ }
+
+ *buf = noise;
+
+ return 0;
+}
+
+int wl_get_quality(const char *ifname, int *buf)
+{
+ return wext_get_quality(ifname, buf);
+}
+
+int wl_get_quality_max(const char *ifname, int *buf)
+{
+ return wext_get_quality_max(ifname, buf);
+}
+
+int wl_get_encryption(const char *ifname, char *buf)
+{
+ uint32_t wsec, wauth, wpa;
+ struct iwinfo_crypto_entry *c = (struct iwinfo_crypto_entry *)buf;
+
+ if( wl_ioctl(ifname, WLC_GET_WPA_AUTH, &wpa, sizeof(uint32_t)) ||
+ wl_ioctl(ifname, WLC_GET_WSEC, &wsec, sizeof(uint32_t)) ||
+ wl_ioctl(ifname, WLC_GET_AUTH, &wauth, sizeof(uint32_t)) )
+ return -1;
+
+ switch(wsec)
+ {
+ case 2:
+ c->pair_ciphers |= IWINFO_CIPHER_TKIP;
+ break;
+
+ case 4:
+ c->pair_ciphers |= IWINFO_CIPHER_CCMP;
+ break;
+
+ case 6:
+ c->pair_ciphers |= IWINFO_CIPHER_TKIP;
+ c->pair_ciphers |= IWINFO_CIPHER_CCMP;
+ break;
+ }
+
+ switch(wpa)
+ {
+ case 0:
+ if (wsec && !wauth)
+ c->auth_algs |= IWINFO_AUTH_OPEN;
+
+ else if (wsec && wauth)
+ c->auth_algs |= IWINFO_AUTH_SHARED;
+
+ /* ToDo: evaluate WEP key lengths */
+ c->pair_ciphers = IWINFO_CIPHER_WEP40 | IWINFO_CIPHER_WEP104;
+ c->auth_suites |= IWINFO_KMGMT_NONE;
+ break;
+
+ case 2:
+ c->wpa_version = 1;
+ c->auth_suites |= IWINFO_KMGMT_8021x;
+ break;
+
+ case 4:
+ c->wpa_version = 1;
+ c->auth_suites |= IWINFO_KMGMT_PSK;
+ break;
+
+ case 32:
+ case 64:
+ c->wpa_version = 2;
+ c->auth_suites |= IWINFO_KMGMT_8021x;
+ break;
+
+ case 66:
+ c->wpa_version = 3;
+ c->auth_suites |= IWINFO_KMGMT_8021x;
+ break;
+
+ case 128:
+ c->wpa_version = 2;
+ c->auth_suites |= IWINFO_KMGMT_PSK;
+ break;
+
+ case 132:
+ c->wpa_version = 3;
+ c->auth_suites |= IWINFO_KMGMT_PSK;
+ break;
+
+ default:
+ break;
+ }
+
+ c->enabled = (c->wpa_version || c->auth_algs) ? 1 : 0;
+ c->group_ciphers = c->pair_ciphers;
+
+ return 0;
+}
+
+int wl_get_enctype(const char *ifname, char *buf)
+{
+ uint32_t wsec, wpa;
+ char algo[11];
+
+ if( wl_ioctl(ifname, WLC_GET_WPA_AUTH, &wpa, sizeof(uint32_t)) ||
+ wl_ioctl(ifname, WLC_GET_WSEC, &wsec, sizeof(uint32_t)) )
+ return -1;
+
+ switch(wsec)
+ {
+ case 2:
+ sprintf(algo, "TKIP");
+ break;
+
+ case 4:
+ sprintf(algo, "CCMP");
+ break;
+
+ case 6:
+ sprintf(algo, "TKIP, CCMP");
+ break;
+ }
+
+ switch(wpa)
+ {
+ case 0:
+ sprintf(buf, "%s", wsec ? "WEP" : "None");
+ break;
+
+ case 2:
+ sprintf(buf, "WPA 802.1X (%s)", algo);
+ break;
+
+ case 4:
+ sprintf(buf, "WPA PSK (%s)", algo);
+ break;
+
+ case 32:
+ sprintf(buf, "802.1X (%s)", algo);
+ break;
+
+ case 64:
+ sprintf(buf, "WPA2 802.1X (%s)", algo);
+ break;
+
+ case 66:
+ sprintf(buf, "mixed WPA/WPA2 802.1X (%s)", algo);
+ break;
+
+ case 128:
+ sprintf(buf, "WPA2 PSK (%s)", algo);
+ break;
+
+ case 132:
+ sprintf(buf, "mixed WPA/WPA2 PSK (%s)", algo);
+ break;
+
+ default:
+ sprintf(buf, "Unknown");
+ }
+
+ return 0;
+}
+
+static void wl_get_assoclist_cb(const char *ifname,
+ struct iwinfo_assoclist_entry *e)
+{
+ wl_sta_info_t sta = { 0 };
+
+ if (!wl_iovar(ifname, "sta_info", e->mac, 6, &sta, sizeof(sta)) &&
+ (sta.ver >= 2))
+ {
+ e->inactive = sta.idle * 1000;
+ e->rx_packets = sta.rx_ucast_pkts;
+ e->tx_packets = sta.tx_pkts;
+ e->rx_rate.rate = sta.rx_rate;
+ e->tx_rate.rate = sta.tx_rate;
+
+ /* ToDo: 11n */
+ e->rx_rate.mcs = -1;
+ e->tx_rate.mcs = -1;
+ }
+}
+
+int wl_get_assoclist(const char *ifname, char *buf, int *len)
+{
+ int i, j, noise;
+ int ap, infra, passive;
+ char line[128];
+ char macstr[18];
+ char devstr[IFNAMSIZ];
+ struct wl_maclist *macs;
+ struct wl_sta_rssi rssi;
+ struct iwinfo_assoclist_entry entry;
+ FILE *arp;
+
+ ap = infra = passive = 0;
+
+ wl_ioctl(ifname, WLC_GET_AP, &ap, sizeof(ap));
+ wl_ioctl(ifname, WLC_GET_INFRA, &infra, sizeof(infra));
+ wl_ioctl(ifname, WLC_GET_PASSIVE, &passive, sizeof(passive));
+
+ if (wl_get_noise(ifname, &noise))
+ noise = 0;
+
+ if ((ap || infra || passive) && ((macs = wl_read_assoclist(ifname)) != NULL))
+ {
+ for (i = 0, j = 0; i < macs->count; i++, j += sizeof(struct iwinfo_assoclist_entry))
+ {
+ memset(&entry, 0, sizeof(entry));
+ memcpy(rssi.mac, &macs->ea[i], 6);
+
+ if (!wl_ioctl(ifname, WLC_GET_RSSI, &rssi, sizeof(struct wl_sta_rssi)))
+ entry.signal = (rssi.rssi - 0x100);
+ else
+ entry.signal = 0;
+
+ entry.noise = noise;
+ memcpy(entry.mac, &macs->ea[i], 6);
+ wl_get_assoclist_cb(ifname, &entry);
+
+ memcpy(&buf[j], &entry, sizeof(entry));
+ }
+
+ *len = j;
+ free(macs);
+ return 0;
+ }
+ else if ((arp = fopen("/proc/net/arp", "r")) != NULL)
+ {
+ j = 0;
+
+ while (fgets(line, sizeof(line), arp) != NULL)
+ {
+ if (sscanf(line, "%*s 0x%*d 0x%*d %17s %*s %s", macstr, devstr) && !strcmp(devstr, ifname))
+ {
+ rssi.mac[0] = strtol(&macstr[0], NULL, 16);
+ rssi.mac[1] = strtol(&macstr[3], NULL, 16);
+ rssi.mac[2] = strtol(&macstr[6], NULL, 16);
+ rssi.mac[3] = strtol(&macstr[9], NULL, 16);
+ rssi.mac[4] = strtol(&macstr[12], NULL, 16);
+ rssi.mac[5] = strtol(&macstr[15], NULL, 16);
+
+ if (!wl_ioctl(ifname, WLC_GET_RSSI, &rssi, sizeof(struct wl_sta_rssi)))
+ entry.signal = (rssi.rssi - 0x100);
+ else
+ entry.signal = 0;
+
+ entry.noise = noise;
+ memcpy(entry.mac, rssi.mac, 6);
+ memcpy(&buf[j], &entry, sizeof(entry));
+
+ j += sizeof(entry);
+ }
+ }
+
+ *len = j;
+ (void) fclose(arp);
+ return 0;
+ }
+
+ return -1;
+}
+
+int wl_get_txpwrlist(const char *ifname, char *buf, int *len)
+{
+ struct iwinfo_txpwrlist_entry entry;
+ uint8_t dbm[11] = { 0, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24 };
+ uint8_t mw[11] = { 1, 3, 6, 10, 15, 25, 39, 63, 100, 158, 251 };
+ int i;
+
+ for (i = 0; i < 11; i++)
+ {
+ entry.dbm = dbm[i];
+ entry.mw = mw[i];
+ memcpy(&buf[i*sizeof(entry)], &entry, sizeof(entry));
+ }
+
+ *len = 11 * sizeof(entry);
+ return 0;
+}
+
+int wl_get_scanlist(const char *ifname, char *buf, int *len)
+{
+ return wext_get_scanlist(ifname, buf, len);
+}
+
+int wl_get_freqlist(const char *ifname, char *buf, int *len)
+{
+ return wext_get_freqlist(ifname, buf, len);
+}
+
+int wl_get_country(const char *ifname, char *buf)
+{
+ char ccode[WLC_CNTRY_BUF_SZ];
+
+ if (!wl_ioctl(ifname, WLC_GET_COUNTRY, ccode, WLC_CNTRY_BUF_SZ))
+ {
+ /* IL0 -> World */
+ if (!strcmp(ccode, "IL0"))
+ sprintf(buf, "00");
+
+ /* YU -> RS */
+ else if (!strcmp(ccode, "YU"))
+ sprintf(buf, "RS");
+
+ else
+ memcpy(buf, ccode, 2);
+
+ return 0;
+ }
+
+ return -1;
+}
+
+int wl_get_countrylist(const char *ifname, char *buf, int *len)
+{
+ int i, count;
+ char cdata[WLC_IOCTL_MAXLEN];
+ struct iwinfo_country_entry *c = (struct iwinfo_country_entry *)buf;
+ wl_country_list_t *cl = (wl_country_list_t *)cdata;
+
+ cl->buflen = sizeof(cdata);
+
+ if (!wl_ioctl(ifname, WLC_GET_COUNTRY_LIST, cl, cl->buflen))
+ {
+ for (i = 0, count = 0; i < cl->count; i++, c++)
+ {
+ sprintf(c->ccode, &cl->country_abbrev[i * WLC_CNTRY_BUF_SZ]);
+ c->iso3166 = c->ccode[0] * 256 + c->ccode[1];
+
+ /* IL0 -> World */
+ if (!strcmp(c->ccode, "IL0"))
+ c->iso3166 = 0x3030;
+
+ /* YU -> RS */
+ else if (!strcmp(c->ccode, "YU"))
+ c->iso3166 = 0x5253;
+ }
+
+ *len = (i * sizeof(struct iwinfo_country_entry));
+ return 0;
+ }
+
+ return -1;
+}
+
+int wl_get_hwmodelist(const char *ifname, int *buf)
+{
+ return wext_get_hwmodelist(ifname, buf);
+}
+
+int wl_get_mbssid_support(const char *ifname, int *buf)
+{
+ wlc_rev_info_t revinfo;
+
+ /* Multi bssid support only works on corerev >= 9 */
+ if (!wl_ioctl(ifname, WLC_GET_REVINFO, &revinfo, sizeof(revinfo)))
+ {
+ if (revinfo.corerev >= 9)
+ {
+ *buf = 1;
+ return 0;
+ }
+ }
+
+ return -1;
+}
+
+int wl_get_hardware_id(const char *ifname, char *buf)
+{
+ wlc_rev_info_t revinfo;
+ struct iwinfo_hardware_id *ids = (struct iwinfo_hardware_id *)buf;
+
+ if (wl_ioctl(ifname, WLC_GET_REVINFO, &revinfo, sizeof(revinfo)))
+ return -1;
+
+ ids->vendor_id = revinfo.vendorid;
+ ids->device_id = revinfo.deviceid;
+ ids->subsystem_vendor_id = revinfo.boardvendor;
+ ids->subsystem_device_id = revinfo.boardid;
+
+ return 0;
+}
+
+int wl_get_hardware_name(const char *ifname, char *buf)
+{
+ struct iwinfo_hardware_id ids;
+
+ if (wl_get_hardware_id(ifname, (char *)&ids))
+ return -1;
+
+ sprintf(buf, "Broadcom BCM%04X", ids.device_id);
+
+ return 0;
+}
+
+int wl_get_txpower_offset(const char *ifname, int *buf)
+{
+ FILE *p;
+ char off[8];
+
+ *buf = 0;
+
+ if ((p = popen("/usr/sbin/nvram get opo", "r")) != NULL)
+ {
+ if (fread(off, 1, sizeof(off), p))
+ *buf = strtoul(off, NULL, 16);
+
+ pclose(p);
+ }
+
+ return 0;
+}
+
+int wl_get_frequency_offset(const char *ifname, int *buf)
+{
+ /* Stub */
+ *buf = 0;
+ return -1;
+}
diff --git a/package/network/utils/maccalc/.svn/entries b/package/network/utils/maccalc/.svn/entries
new file mode 100644
index 0000000..52b6469
--- /dev/null
+++ b/package/network/utils/maccalc/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/utils/maccalc
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-10T12:32:29.935169Z
+33688
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+src
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+0af840bc74ddd953cc60c1692895a21a
+2011-08-15T18:55:51.371841Z
+28004
+juhosg
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+921
+
diff --git a/package/network/utils/maccalc/.svn/prop-base/Makefile.svn-base b/package/network/utils/maccalc/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/network/utils/maccalc/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/utils/maccalc/.svn/text-base/Makefile.svn-base b/package/network/utils/maccalc/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..09cdfc8
--- /dev/null
+++ b/package/network/utils/maccalc/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,47 @@
+#
+# Copyright (C) 2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=maccalc
+PKG_RELEASE:=1
+
+PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/maccalc
+ SECTION:=utils
+ CATEGORY:=Utilities
+ TITLE:=MAC address calculation
+endef
+
+define Package/maccalc/description
+ This package contains a MAC address manipulation utility.
+endef
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ CC="$(TARGET_CC)" \
+ CFLAGS="$(TARGET_CFLAGS) -Wall" \
+ LDFLAGS="$(TARGET_LDFLAGS)"
+endef
+
+define Package/maccalc/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/maccalc $(1)/usr/sbin/
+endef
+
+$(eval $(call BuildPackage,maccalc))
diff --git a/package/network/utils/maccalc/Makefile b/package/network/utils/maccalc/Makefile
new file mode 100644
index 0000000..09cdfc8
--- /dev/null
+++ b/package/network/utils/maccalc/Makefile
@@ -0,0 +1,47 @@
+#
+# Copyright (C) 2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=maccalc
+PKG_RELEASE:=1
+
+PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/maccalc
+ SECTION:=utils
+ CATEGORY:=Utilities
+ TITLE:=MAC address calculation
+endef
+
+define Package/maccalc/description
+ This package contains a MAC address manipulation utility.
+endef
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ CC="$(TARGET_CC)" \
+ CFLAGS="$(TARGET_CFLAGS) -Wall" \
+ LDFLAGS="$(TARGET_LDFLAGS)"
+endef
+
+define Package/maccalc/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/maccalc $(1)/usr/sbin/
+endef
+
+$(eval $(call BuildPackage,maccalc))
diff --git a/package/network/utils/maccalc/src/.svn/entries b/package/network/utils/maccalc/src/.svn/entries
new file mode 100644
index 0000000..61319f9
--- /dev/null
+++ b/package/network/utils/maccalc/src/.svn/entries
@@ -0,0 +1,96 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/utils/maccalc/src
+svn://svn.openwrt.org/openwrt
+
+
+
+2011-09-21T11:47:35.705323Z
+28266
+juhosg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+main.c
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+641b6faf83ff4caf4264dde86a5ef503
+2011-09-21T11:47:35.705323Z
+28266
+juhosg
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4581
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+4f4d09f95e66e7695ff4b2b2f414fd03
+2011-08-15T18:55:51.371841Z
+28004
+juhosg
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+157
+
diff --git a/package/network/utils/maccalc/src/.svn/prop-base/Makefile.svn-base b/package/network/utils/maccalc/src/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/network/utils/maccalc/src/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/utils/maccalc/src/.svn/prop-base/main.c.svn-base b/package/network/utils/maccalc/src/.svn/prop-base/main.c.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/network/utils/maccalc/src/.svn/prop-base/main.c.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/utils/maccalc/src/.svn/text-base/Makefile.svn-base b/package/network/utils/maccalc/src/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..486badb
--- /dev/null
+++ b/package/network/utils/maccalc/src/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,14 @@
+CC = gcc
+CFLAGS = -Wall
+OBJS = main.o
+
+all: maccalc
+
+%.o: %.c
+ $(CC) $(CFLAGS) -c -o $@ $<
+
+maccalc: $(OBJS)
+ $(CC) -o $@ $(OBJS)
+
+clean:
+ rm -f maccalc *.o
diff --git a/package/network/utils/maccalc/src/.svn/text-base/main.c.svn-base b/package/network/utils/maccalc/src/.svn/text-base/main.c.svn-base
new file mode 100644
index 0000000..dcb5f55
--- /dev/null
+++ b/package/network/utils/maccalc/src/.svn/text-base/main.c.svn-base
@@ -0,0 +1,256 @@
+/*
+ * MAC address manupulation utility
+ *
+ * Copyright (C) 2011 Gabor Juhos <juhosg@openwrt.org>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ *
+ */
+
+#include <errno.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+#include <unistd.h>
+
+#define MAC_ADDRESS_LEN 6
+
+#define ERR_INVALID 1
+#define ERR_IO 2
+
+static void usage(void);
+
+char *maccalc_name;
+
+static int parse_mac(const char *mac_str, unsigned char *buf)
+{
+ int t;
+
+ t = sscanf(mac_str, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx",
+ &buf[0], &buf[1], &buf[2], &buf[3], &buf[4], &buf[5]);
+
+ if (t != MAC_ADDRESS_LEN)
+ return ERR_INVALID;
+
+ return 0;
+}
+
+static void print_mac(unsigned char *buf)
+{
+ printf("%02x:%02x:%02x:%02x:%02x:%02x\n",
+ buf[0], buf[1], buf[2], buf[3], buf[4], buf[5]);
+}
+
+static int maccalc_do_add(int argc, const char *argv[])
+{
+ unsigned char mac[MAC_ADDRESS_LEN];
+ uint32_t t;
+ int err;
+ int i;
+
+ if (argc != 2) {
+ usage();
+ return ERR_INVALID;
+ }
+
+ err = parse_mac(argv[0], mac);
+ if (err)
+ return err;
+
+ i = atoi(argv[1]);
+
+ t = (mac[3] << 16) | (mac[4] << 8) | mac[5];
+ t += i;
+ mac[3] = (t >> 16) & 0xff;
+ mac[4] = (t >> 8) & 0xff;
+ mac[5] = t & 0xff;
+
+ print_mac(mac);
+ return 0;
+}
+
+static int maccalc_do_logical(int argc, const char *argv[],
+ unsigned char (*op)(unsigned char n1,
+ unsigned char n2))
+{
+ unsigned char mac1[MAC_ADDRESS_LEN];
+ unsigned char mac2[MAC_ADDRESS_LEN];
+ int err;
+ int i;
+
+ if (argc != 2) {
+ usage();
+ return ERR_INVALID;
+ }
+
+ err = parse_mac(argv[0], mac1);
+ if (err)
+ return err;
+
+ err = parse_mac(argv[1], mac2);
+ if (err)
+ return err;
+
+ for (i = 0; i < MAC_ADDRESS_LEN; i++)
+ mac1[i] = op(mac1[i],mac2[i]);
+
+ print_mac(mac1);
+ return 0;
+}
+
+static int maccalc_do_mac2bin(int argc, const char *argv[])
+{
+ unsigned char mac[MAC_ADDRESS_LEN];
+ ssize_t c;
+ int err;
+
+ if (argc != 1) {
+ usage();
+ return ERR_INVALID;
+ }
+
+ err = parse_mac(argv[0], mac);
+ if (err)
+ return err;
+
+ c = write(STDOUT_FILENO, mac, sizeof(mac));
+ if (c != sizeof(mac)) {
+ fprintf(stderr, "failed to write to stdout\n");
+ return ERR_IO;
+ }
+
+ return 0;
+}
+
+static ssize_t read_safe(int fd, void *buf, size_t count)
+{
+ ssize_t total = 0;
+ ssize_t r;
+
+ while(count > 0) {
+ r = read(fd, buf, count);
+ if (r == 0)
+ /* EOF */
+ break;
+ if (r < 0) {
+ if (errno == EINTR)
+ /* interrupted by a signal, restart */
+ continue;
+ /* error */
+ total = -1;
+ break;
+ }
+
+ /* ok */
+ total += r;
+ count -= r;
+ buf += r;
+ }
+
+ return total;
+}
+
+static int maccalc_do_bin2mac(int argc, const char *argv[])
+{
+ unsigned char mac[MAC_ADDRESS_LEN];
+ ssize_t c;
+
+ if (argc != 0) {
+ usage();
+ return ERR_INVALID;
+ }
+
+ c = read_safe(STDIN_FILENO, mac, sizeof(mac));
+ if (c != sizeof(mac)) {
+ fprintf(stderr, "failed to read from stdin\n");
+ return ERR_IO;
+ }
+
+ print_mac(mac);
+ return 0;
+}
+
+static unsigned char op_or(unsigned char n1, unsigned char n2)
+{
+ return n1 | n2;
+}
+
+static int maccalc_do_or(int argc, const char *argv[])
+{
+ return maccalc_do_logical(argc, argv, op_or);
+}
+
+static unsigned char op_and(unsigned char n1, unsigned char n2)
+{
+ return n1 & n2;
+}
+
+static int maccalc_do_and(int argc, const char *argv[])
+{
+ return maccalc_do_logical(argc, argv, op_and);
+}
+
+static unsigned char op_xor(unsigned char n1, unsigned char n2)
+{
+ return n1 ^ n2;
+}
+
+static int maccalc_do_xor(int argc, const char *argv[])
+{
+ return maccalc_do_logical(argc, argv, op_xor);
+}
+
+static void usage(void)
+{
+ fprintf(stderr,
+ "Usage: %s <command>\n"
+ "valid commands:\n"
+ " add <mac> <number>\n"
+ " and|or|xor <mac1> <mac2>\n"
+ " mac2bin <mac>\n"
+ " bin2mac\n",
+ maccalc_name);
+}
+
+int main(int argc, const char *argv[])
+{
+ int (*op)(int argc, const char *argv[]);
+ int ret;
+
+ maccalc_name = (char *) argv[0];
+
+ if (argc < 2) {
+ usage();
+ return EXIT_FAILURE;
+ }
+
+ if (strcmp(argv[1], "add") == 0) {
+ op = maccalc_do_add;
+ } else if (strcmp(argv[1], "and") == 0) {
+ op = maccalc_do_and;
+ } else if (strcmp(argv[1], "or") == 0) {
+ op = maccalc_do_or;
+ } else if (strcmp(argv[1], "xor") == 0) {
+ op = maccalc_do_xor;
+ } else if (strcmp(argv[1], "mac2bin") == 0) {
+ op = maccalc_do_mac2bin;
+ } else if (strcmp(argv[1], "bin2mac") == 0) {
+ op = maccalc_do_bin2mac;
+ } else {
+ fprintf(stderr, "unknown command '%s'\n", argv[1]);
+ usage();
+ return EXIT_FAILURE;
+ }
+
+ argc -= 2;
+ argv += 2;
+
+ ret = op(argc, argv);
+ if (ret)
+ return EXIT_FAILURE;
+
+ return EXIT_SUCCESS;
+}
diff --git a/package/network/utils/maccalc/src/Makefile b/package/network/utils/maccalc/src/Makefile
new file mode 100644
index 0000000..486badb
--- /dev/null
+++ b/package/network/utils/maccalc/src/Makefile
@@ -0,0 +1,14 @@
+CC = gcc
+CFLAGS = -Wall
+OBJS = main.o
+
+all: maccalc
+
+%.o: %.c
+ $(CC) $(CFLAGS) -c -o $@ $<
+
+maccalc: $(OBJS)
+ $(CC) -o $@ $(OBJS)
+
+clean:
+ rm -f maccalc *.o
diff --git a/package/network/utils/maccalc/src/main.c b/package/network/utils/maccalc/src/main.c
new file mode 100644
index 0000000..dcb5f55
--- /dev/null
+++ b/package/network/utils/maccalc/src/main.c
@@ -0,0 +1,256 @@
+/*
+ * MAC address manupulation utility
+ *
+ * Copyright (C) 2011 Gabor Juhos <juhosg@openwrt.org>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ *
+ */
+
+#include <errno.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+#include <unistd.h>
+
+#define MAC_ADDRESS_LEN 6
+
+#define ERR_INVALID 1
+#define ERR_IO 2
+
+static void usage(void);
+
+char *maccalc_name;
+
+static int parse_mac(const char *mac_str, unsigned char *buf)
+{
+ int t;
+
+ t = sscanf(mac_str, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx",
+ &buf[0], &buf[1], &buf[2], &buf[3], &buf[4], &buf[5]);
+
+ if (t != MAC_ADDRESS_LEN)
+ return ERR_INVALID;
+
+ return 0;
+}
+
+static void print_mac(unsigned char *buf)
+{
+ printf("%02x:%02x:%02x:%02x:%02x:%02x\n",
+ buf[0], buf[1], buf[2], buf[3], buf[4], buf[5]);
+}
+
+static int maccalc_do_add(int argc, const char *argv[])
+{
+ unsigned char mac[MAC_ADDRESS_LEN];
+ uint32_t t;
+ int err;
+ int i;
+
+ if (argc != 2) {
+ usage();
+ return ERR_INVALID;
+ }
+
+ err = parse_mac(argv[0], mac);
+ if (err)
+ return err;
+
+ i = atoi(argv[1]);
+
+ t = (mac[3] << 16) | (mac[4] << 8) | mac[5];
+ t += i;
+ mac[3] = (t >> 16) & 0xff;
+ mac[4] = (t >> 8) & 0xff;
+ mac[5] = t & 0xff;
+
+ print_mac(mac);
+ return 0;
+}
+
+static int maccalc_do_logical(int argc, const char *argv[],
+ unsigned char (*op)(unsigned char n1,
+ unsigned char n2))
+{
+ unsigned char mac1[MAC_ADDRESS_LEN];
+ unsigned char mac2[MAC_ADDRESS_LEN];
+ int err;
+ int i;
+
+ if (argc != 2) {
+ usage();
+ return ERR_INVALID;
+ }
+
+ err = parse_mac(argv[0], mac1);
+ if (err)
+ return err;
+
+ err = parse_mac(argv[1], mac2);
+ if (err)
+ return err;
+
+ for (i = 0; i < MAC_ADDRESS_LEN; i++)
+ mac1[i] = op(mac1[i],mac2[i]);
+
+ print_mac(mac1);
+ return 0;
+}
+
+static int maccalc_do_mac2bin(int argc, const char *argv[])
+{
+ unsigned char mac[MAC_ADDRESS_LEN];
+ ssize_t c;
+ int err;
+
+ if (argc != 1) {
+ usage();
+ return ERR_INVALID;
+ }
+
+ err = parse_mac(argv[0], mac);
+ if (err)
+ return err;
+
+ c = write(STDOUT_FILENO, mac, sizeof(mac));
+ if (c != sizeof(mac)) {
+ fprintf(stderr, "failed to write to stdout\n");
+ return ERR_IO;
+ }
+
+ return 0;
+}
+
+static ssize_t read_safe(int fd, void *buf, size_t count)
+{
+ ssize_t total = 0;
+ ssize_t r;
+
+ while(count > 0) {
+ r = read(fd, buf, count);
+ if (r == 0)
+ /* EOF */
+ break;
+ if (r < 0) {
+ if (errno == EINTR)
+ /* interrupted by a signal, restart */
+ continue;
+ /* error */
+ total = -1;
+ break;
+ }
+
+ /* ok */
+ total += r;
+ count -= r;
+ buf += r;
+ }
+
+ return total;
+}
+
+static int maccalc_do_bin2mac(int argc, const char *argv[])
+{
+ unsigned char mac[MAC_ADDRESS_LEN];
+ ssize_t c;
+
+ if (argc != 0) {
+ usage();
+ return ERR_INVALID;
+ }
+
+ c = read_safe(STDIN_FILENO, mac, sizeof(mac));
+ if (c != sizeof(mac)) {
+ fprintf(stderr, "failed to read from stdin\n");
+ return ERR_IO;
+ }
+
+ print_mac(mac);
+ return 0;
+}
+
+static unsigned char op_or(unsigned char n1, unsigned char n2)
+{
+ return n1 | n2;
+}
+
+static int maccalc_do_or(int argc, const char *argv[])
+{
+ return maccalc_do_logical(argc, argv, op_or);
+}
+
+static unsigned char op_and(unsigned char n1, unsigned char n2)
+{
+ return n1 & n2;
+}
+
+static int maccalc_do_and(int argc, const char *argv[])
+{
+ return maccalc_do_logical(argc, argv, op_and);
+}
+
+static unsigned char op_xor(unsigned char n1, unsigned char n2)
+{
+ return n1 ^ n2;
+}
+
+static int maccalc_do_xor(int argc, const char *argv[])
+{
+ return maccalc_do_logical(argc, argv, op_xor);
+}
+
+static void usage(void)
+{
+ fprintf(stderr,
+ "Usage: %s <command>\n"
+ "valid commands:\n"
+ " add <mac> <number>\n"
+ " and|or|xor <mac1> <mac2>\n"
+ " mac2bin <mac>\n"
+ " bin2mac\n",
+ maccalc_name);
+}
+
+int main(int argc, const char *argv[])
+{
+ int (*op)(int argc, const char *argv[]);
+ int ret;
+
+ maccalc_name = (char *) argv[0];
+
+ if (argc < 2) {
+ usage();
+ return EXIT_FAILURE;
+ }
+
+ if (strcmp(argv[1], "add") == 0) {
+ op = maccalc_do_add;
+ } else if (strcmp(argv[1], "and") == 0) {
+ op = maccalc_do_and;
+ } else if (strcmp(argv[1], "or") == 0) {
+ op = maccalc_do_or;
+ } else if (strcmp(argv[1], "xor") == 0) {
+ op = maccalc_do_xor;
+ } else if (strcmp(argv[1], "mac2bin") == 0) {
+ op = maccalc_do_mac2bin;
+ } else if (strcmp(argv[1], "bin2mac") == 0) {
+ op = maccalc_do_bin2mac;
+ } else {
+ fprintf(stderr, "unknown command '%s'\n", argv[1]);
+ usage();
+ return EXIT_FAILURE;
+ }
+
+ argc -= 2;
+ argv += 2;
+
+ ret = op(argc, argv);
+ if (ret)
+ return EXIT_FAILURE;
+
+ return EXIT_SUCCESS;
+}
diff --git a/package/network/utils/owipcalc/.svn/entries b/package/network/utils/owipcalc/.svn/entries
new file mode 100644
index 0000000..a9bd58d
--- /dev/null
+++ b/package/network/utils/owipcalc/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/utils/owipcalc
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-10T12:32:29.935169Z
+33688
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+src
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+f9a2d96df115dbe3f3cc0354d3099707
+2012-07-20T13:43:10.320055Z
+32785
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1085
+
diff --git a/package/network/utils/owipcalc/.svn/text-base/Makefile.svn-base b/package/network/utils/owipcalc/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..a441319
--- /dev/null
+++ b/package/network/utils/owipcalc/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,49 @@
+#
+# Copyright (C) 2012 Jo-Philipp Wich <jow@openwrt.org>
+#
+# This is free software, licensed under the Apache 2 license.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=owipcalc
+PKG_RELEASE:=3
+
+include $(INCLUDE_DIR)/package.mk
+
+
+define Package/owipcalc
+ SECTION:=utils
+ CATEGORY:=Utilities
+ TITLE:=Simple IPv4/IPv6 address calculator
+ MAINTAINER:=Jo-Philipp Wich <jow@openwrt.org>
+endef
+
+define Package/owipcalc/description
+ The owipcalc utility supports a number of calculations and tests to work
+ with ip-address ranges, this is useful for scripts that e.g. need to
+ partition ipv6-prefixes into small subnets or to calculate address ranges
+ for dhcp pools.
+endef
+
+
+define Build/Prepare
+ $(INSTALL_DIR) $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+ $(TARGET_CC) $(TARGET_CFLAGS) \
+ -o $(PKG_BUILD_DIR)/owipcalc $(PKG_BUILD_DIR)/owipcalc.c
+endef
+
+
+define Package/owipcalc/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/owipcalc $(1)/usr/bin/owipcalc
+endef
+
+$(eval $(call BuildPackage,owipcalc))
diff --git a/package/network/utils/owipcalc/Makefile b/package/network/utils/owipcalc/Makefile
new file mode 100644
index 0000000..a441319
--- /dev/null
+++ b/package/network/utils/owipcalc/Makefile
@@ -0,0 +1,49 @@
+#
+# Copyright (C) 2012 Jo-Philipp Wich <jow@openwrt.org>
+#
+# This is free software, licensed under the Apache 2 license.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=owipcalc
+PKG_RELEASE:=3
+
+include $(INCLUDE_DIR)/package.mk
+
+
+define Package/owipcalc
+ SECTION:=utils
+ CATEGORY:=Utilities
+ TITLE:=Simple IPv4/IPv6 address calculator
+ MAINTAINER:=Jo-Philipp Wich <jow@openwrt.org>
+endef
+
+define Package/owipcalc/description
+ The owipcalc utility supports a number of calculations and tests to work
+ with ip-address ranges, this is useful for scripts that e.g. need to
+ partition ipv6-prefixes into small subnets or to calculate address ranges
+ for dhcp pools.
+endef
+
+
+define Build/Prepare
+ $(INSTALL_DIR) $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+ $(TARGET_CC) $(TARGET_CFLAGS) \
+ -o $(PKG_BUILD_DIR)/owipcalc $(PKG_BUILD_DIR)/owipcalc.c
+endef
+
+
+define Package/owipcalc/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/owipcalc $(1)/usr/bin/owipcalc
+endef
+
+$(eval $(call BuildPackage,owipcalc))
diff --git a/package/network/utils/owipcalc/src/.svn/entries b/package/network/utils/owipcalc/src/.svn/entries
new file mode 100644
index 0000000..db9703a
--- /dev/null
+++ b/package/network/utils/owipcalc/src/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/utils/owipcalc/src
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-07-20T15:05:30.818407Z
+32786
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+owipcalc.c
+file
+
+
+
+
+2013-03-17T12:13:18.000000Z
+d94eceeeda2b0c1e6ce75a1d4c3d7dd6
+2012-07-20T15:05:30.818407Z
+32786
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+17998
+
diff --git a/package/network/utils/owipcalc/src/.svn/text-base/owipcalc.c.svn-base b/package/network/utils/owipcalc/src/.svn/text-base/owipcalc.c.svn-base
new file mode 100644
index 0000000..d22594b
--- /dev/null
+++ b/package/network/utils/owipcalc/src/.svn/text-base/owipcalc.c.svn-base
@@ -0,0 +1,951 @@
+/*
+ * owipcalc - OpenWrt IP Calculator
+ *
+ * Copyright (C) 2012 Jo-Philipp Wich <jow@openwrt.org>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdint.h>
+#include <stdbool.h>
+#include <stdlib.h>
+
+#include <string.h>
+#include <unistd.h>
+
+#include <arpa/inet.h>
+
+
+struct cidr {
+ uint8_t family;
+ uint32_t prefix;
+ union {
+ struct in_addr v4;
+ struct in6_addr v6;
+ } addr;
+ union {
+ char v4[sizeof("255.255.255.255/255.255.255.255 ")];
+ char v6[sizeof("FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:255.255.255.255/128 ")];
+ } buf;
+ struct cidr *next;
+};
+
+struct op {
+ const char *name;
+ const char *desc;
+ struct {
+ bool (*a1)(struct cidr *a);
+ bool (*a2)(struct cidr *a, struct cidr *b);
+ } f4;
+ struct {
+ bool (*a1)(struct cidr *a);
+ bool (*a2)(struct cidr *a, struct cidr *b);
+ } f6;
+};
+
+
+static bool quiet = false;
+static bool printed = false;
+
+static struct cidr *stack = NULL;
+
+#define qprintf(...) \
+ do { \
+ if (!quiet) printf(__VA_ARGS__); \
+ printed = true; \
+ } while(0)
+
+static void cidr_push(struct cidr *a)
+{
+ if (a)
+ {
+ a->next = stack;
+ stack = a;
+ }
+}
+
+static bool cidr_pop(struct cidr *a)
+{
+ struct cidr *old = stack;
+
+ if (old)
+ {
+ stack = stack->next;
+ free(old);
+
+ return true;
+ }
+
+ return false;
+}
+
+static struct cidr * cidr_clone(struct cidr *a)
+{
+ struct cidr *b = malloc(sizeof(*b));
+
+ if (!b)
+ {
+ fprintf(stderr, "out of memory\n");
+ exit(255);
+ }
+
+ memcpy(b, a, sizeof(*b));
+ cidr_push(b);
+
+ return b;
+}
+
+
+static struct cidr * cidr_parse4(const char *s)
+{
+ char *p = NULL, *r;
+ struct in_addr mask;
+ struct cidr *addr = malloc(sizeof(struct cidr));
+
+ if (!addr || (strlen(s) >= sizeof(addr->buf.v4)))
+ goto err;
+
+ snprintf(addr->buf.v4, sizeof(addr->buf.v4), "%s", s);
+
+ addr->family = AF_INET;
+
+ if ((p = strchr(addr->buf.v4, '/')) != NULL)
+ {
+ *p++ = 0;
+
+ if (strchr(p, '.') != NULL)
+ {
+ if (inet_pton(AF_INET, p, &mask) != 1)
+ goto err;
+
+ for (addr->prefix = 0; mask.s_addr; mask.s_addr >>= 1)
+ addr->prefix += (mask.s_addr & 1);
+ }
+ else
+ {
+ addr->prefix = strtoul(p, &r, 10);
+
+ if ((p == r) || (*r != 0) || (addr->prefix > 32))
+ goto err;
+ }
+ }
+ else
+ {
+ addr->prefix = 32;
+ }
+
+ if (p == addr->buf.v4+1)
+ memset(&addr->addr.v4, 0, sizeof(addr->addr.v4));
+ else if (inet_pton(AF_INET, addr->buf.v4, &addr->addr.v4) != 1)
+ goto err;
+
+ return addr;
+
+err:
+ if (addr)
+ free(addr);
+
+ return NULL;
+}
+
+static bool cidr_add4(struct cidr *a, struct cidr *b)
+{
+ uint32_t x = ntohl(a->addr.v4.s_addr);
+ uint32_t y = ntohl(b->addr.v4.s_addr);
+
+ struct cidr *n = cidr_clone(a);
+
+ if ((n->family != AF_INET) || (b->family != AF_INET))
+ return false;
+
+ if ((uint32_t)(x + y) < x)
+ {
+ fprintf(stderr, "overflow during 'add'\n");
+ return false;
+ }
+
+ n->addr.v4.s_addr = htonl(x + y);
+ return true;
+}
+
+static bool cidr_sub4(struct cidr *a, struct cidr *b)
+{
+ uint32_t x = ntohl(a->addr.v4.s_addr);
+ uint32_t y = ntohl(b->addr.v4.s_addr);
+
+ struct cidr *n = cidr_clone(a);
+
+ if ((n->family != AF_INET) || (b->family != AF_INET))
+ return false;
+
+ if ((uint32_t)(x - y) > x)
+ {
+ fprintf(stderr, "underflow during 'sub'\n");
+ return false;
+ }
+
+ n->addr.v4.s_addr = htonl(x - y);
+ return true;
+}
+
+static bool cidr_network4(struct cidr *a)
+{
+ struct cidr *n = cidr_clone(a);
+
+ n->addr.v4.s_addr &= htonl(~((1 << (32 - n->prefix)) - 1));
+ n->prefix = 32;
+
+ return true;
+}
+
+static bool cidr_broadcast4(struct cidr *a)
+{
+ struct cidr *n = cidr_clone(a);
+
+ n->addr.v4.s_addr |= htonl(((1 << (32 - n->prefix)) - 1));
+ n->prefix = 32;
+
+ return true;
+}
+
+static bool cidr_contains4(struct cidr *a, struct cidr *b)
+{
+ uint32_t net1 = a->addr.v4.s_addr & htonl(~((1 << (32 - a->prefix)) - 1));
+ uint32_t net2 = b->addr.v4.s_addr & htonl(~((1 << (32 - a->prefix)) - 1));
+
+ if (printed)
+ qprintf(" ");
+
+ if ((b->prefix >= a->prefix) && (net1 == net2))
+ {
+ qprintf("1");
+ return true;
+ }
+ else
+ {
+ qprintf("0");
+ return false;
+ }
+}
+
+static bool cidr_netmask4(struct cidr *a)
+{
+ struct cidr *n = cidr_clone(a);
+
+ n->addr.v4.s_addr = htonl(~((1 << (32 - n->prefix)) - 1));
+ n->prefix = 32;
+
+ return true;
+}
+
+static bool cidr_private4(struct cidr *a)
+{
+ uint32_t x = ntohl(a->addr.v4.s_addr);
+
+ if (printed)
+ qprintf(" ");
+
+ if (((x >= 0x0A000000) && (x <= 0x0AFFFFFF)) ||
+ ((x >= 0xAC100000) && (x <= 0xAC1FFFFF)) ||
+ ((x >= 0xC0A80000) && (x <= 0xC0A8FFFF)))
+ {
+ qprintf("1");
+ return true;
+ }
+ else
+ {
+ qprintf("0");
+ return false;
+ }
+}
+
+static bool cidr_linklocal4(struct cidr *a)
+{
+ uint32_t x = ntohl(a->addr.v4.s_addr);
+
+ if (printed)
+ qprintf(" ");
+
+ if ((x >= 0xA9FE0000) && (x <= 0xA9FEFFFF))
+ {
+ qprintf("1");
+ return true;
+ }
+ else
+ {
+ qprintf("0");
+ return false;
+ }
+}
+
+static bool cidr_prev4(struct cidr *a, struct cidr *b)
+{
+ struct cidr *n = cidr_clone(a);
+
+ n->prefix = b->prefix;
+ n->addr.v4.s_addr -= htonl(1 << (32 - b->prefix));
+
+ return true;
+}
+
+static bool cidr_next4(struct cidr *a, struct cidr *b)
+{
+ struct cidr *n = cidr_clone(a);
+
+ n->prefix = b->prefix;
+ n->addr.v4.s_addr += htonl(1 << (32 - b->prefix));
+
+ return true;
+}
+
+static bool cidr_6to4(struct cidr *a)
+{
+ struct cidr *n = cidr_clone(a);
+ uint32_t x = a->addr.v4.s_addr;
+
+ memset(&n->addr.v6.s6_addr, 0, sizeof(n->addr.v6.s6_addr));
+
+ n->family = AF_INET6;
+ n->prefix = 48;
+
+ n->addr.v6.s6_addr[0] = 0x20;
+ n->addr.v6.s6_addr[1] = 0x02;
+ n->addr.v6.s6_addr[2] = (x >> 24);
+ n->addr.v6.s6_addr[3] = (x >> 16) & 0xFF;
+ n->addr.v6.s6_addr[4] = (x >> 8) & 0xFF;
+ n->addr.v6.s6_addr[5] = x & 0xFF;
+
+ return true;
+}
+
+static bool cidr_print4(struct cidr *a)
+{
+ char *p;
+
+ if (!a || (a->family != AF_INET))
+ return false;
+
+ if (!(p = (char *)inet_ntop(AF_INET, &a->addr.v4, a->buf.v4, sizeof(a->buf.v4))))
+ return false;
+
+ if (printed)
+ qprintf(" ");
+
+ qprintf("%s", p);
+
+ if (a->prefix < 32)
+ qprintf("/%u", a->prefix);
+
+ cidr_pop(a);
+
+ return true;
+}
+
+
+static struct cidr * cidr_parse6(const char *s)
+{
+ char *p = NULL, *r;
+ struct cidr *addr = malloc(sizeof(struct cidr));
+
+ if (!addr || (strlen(s) >= sizeof(addr->buf.v6)))
+ goto err;
+
+ snprintf(addr->buf.v4, sizeof(addr->buf.v6), "%s", s);
+
+ addr->family = AF_INET6;
+
+ if ((p = strchr(addr->buf.v4, '/')) != NULL)
+ {
+ *p++ = 0;
+
+ addr->prefix = strtoul(p, &r, 10);
+
+ if ((p == r) || (*r != 0) || (addr->prefix > 128))
+ goto err;
+ }
+ else
+ {
+ addr->prefix = 128;
+ }
+
+ if (p == addr->buf.v4+1)
+ memset(&addr->addr.v6, 0, sizeof(addr->addr.v6));
+ else if (inet_pton(AF_INET6, addr->buf.v4, &addr->addr.v6) != 1)
+ goto err;
+
+ return addr;
+
+err:
+ if (addr)
+ free(addr);
+
+ return NULL;
+}
+
+static bool cidr_add6(struct cidr *a, struct cidr *b)
+{
+ uint8_t idx = 15, carry = 0, overflow = 0;
+
+ struct cidr *n = cidr_clone(a);
+ struct in6_addr *x = &n->addr.v6;
+ struct in6_addr *y = &b->addr.v6;
+
+ if ((a->family != AF_INET6) || (b->family != AF_INET6))
+ return false;
+
+ do {
+ overflow = !!((x->s6_addr[idx] + y->s6_addr[idx] + carry) >= 256);
+ x->s6_addr[idx] += y->s6_addr[idx] + carry;
+ carry = overflow;
+ }
+ while (idx-- > 0);
+
+ if (carry)
+ {
+ fprintf(stderr, "overflow during 'add'\n");
+ return false;
+ }
+
+ return true;
+}
+
+static bool cidr_sub6(struct cidr *a, struct cidr *b)
+{
+ uint8_t idx = 15, carry = 0, underflow = 0;
+
+ struct cidr *n = cidr_clone(a);
+ struct in6_addr *x = &n->addr.v6;
+ struct in6_addr *y = &b->addr.v6;
+
+ if ((n->family != AF_INET6) || (b->family != AF_INET6))
+ return false;
+
+ do {
+ underflow = !!((x->s6_addr[idx] - y->s6_addr[idx] - carry) < 0);
+ x->s6_addr[idx] -= y->s6_addr[idx] + carry;
+ carry = underflow;
+ }
+ while (idx-- > 0);
+
+ if (carry)
+ {
+ fprintf(stderr, "underflow during 'sub'\n");
+ return false;
+ }
+
+ return true;
+}
+
+static bool cidr_prev6(struct cidr *a, struct cidr *b)
+{
+ uint8_t idx, carry = 1, underflow = 0;
+ struct cidr *n = cidr_clone(a);
+ struct in6_addr *x = &n->addr.v6;
+
+ if (b->prefix == 0)
+ {
+ fprintf(stderr, "underflow during 'prev'\n");
+ return false;
+ }
+
+ idx = (b->prefix - 1) / 8;
+
+ do {
+ underflow = !!((x->s6_addr[idx] - carry) < 0);
+ x->s6_addr[idx] -= carry;
+ carry = underflow;
+ }
+ while (idx-- > 0);
+
+ if (carry)
+ {
+ fprintf(stderr, "underflow during 'prev'\n");
+ return false;
+ }
+
+ n->prefix = b->prefix;
+
+ return true;
+}
+
+static bool cidr_next6(struct cidr *a, struct cidr *b)
+{
+ uint8_t idx, carry = 1, overflow = 0;
+ struct cidr *n = cidr_clone(a);
+ struct in6_addr *x = &n->addr.v6;
+
+ if (b->prefix == 0)
+ {
+ fprintf(stderr, "overflow during 'next'\n");
+ return false;
+ }
+
+ idx = (b->prefix - 1) / 8;
+
+ do {
+ overflow = !!((x->s6_addr[idx] + carry) >= 256);
+ x->s6_addr[idx] += carry;
+ carry = overflow;
+ }
+ while (idx-- > 0);
+
+ if (carry)
+ {
+ fprintf(stderr, "overflow during 'next'\n");
+ return false;
+ }
+
+ n->prefix = b->prefix;
+
+ return true;
+}
+
+static bool cidr_network6(struct cidr *a)
+{
+ uint8_t i;
+ struct cidr *n = cidr_clone(a);
+
+ for (i = 0; i < (128 - n->prefix) / 8; i++)
+ n->addr.v6.s6_addr[15-i] = 0;
+
+ if ((128 - n->prefix) % 8)
+ n->addr.v6.s6_addr[15-i] &= ~((1 << ((128 - n->prefix) % 8)) - 1);
+
+ return true;
+}
+
+static bool cidr_contains6(struct cidr *a, struct cidr *b)
+{
+ struct cidr *n = cidr_clone(a);
+ struct in6_addr *x = &n->addr.v6;
+ struct in6_addr *y = &b->addr.v6;
+ uint8_t i = (128 - n->prefix) / 8;
+ uint8_t m = ~((1 << ((128 - n->prefix) % 8)) - 1);
+ uint8_t net1 = x->s6_addr[15-i] & m;
+ uint8_t net2 = y->s6_addr[15-i] & m;
+
+ if (printed)
+ qprintf(" ");
+
+ if ((b->prefix >= n->prefix) && (net1 == net2) &&
+ ((i == 15) || !memcmp(&x->s6_addr, &y->s6_addr, 15-i)))
+ {
+ qprintf("1");
+ return true;
+ }
+ else
+ {
+ qprintf("0");
+ return false;
+ }
+}
+
+static bool cidr_linklocal6(struct cidr *a)
+{
+ if (printed)
+ qprintf(" ");
+
+ if ((a->addr.v6.s6_addr[0] == 0xFE) &&
+ (a->addr.v6.s6_addr[1] >= 0x80) &&
+ (a->addr.v6.s6_addr[1] <= 0xBF))
+ {
+ qprintf("1");
+ return true;
+ }
+ else
+ {
+ qprintf("0");
+ return false;
+ }
+}
+
+static bool cidr_ula6(struct cidr *a)
+{
+ if (printed)
+ qprintf(" ");
+
+ if ((a->addr.v6.s6_addr[0] >= 0xFC) &&
+ (a->addr.v6.s6_addr[0] <= 0xFD))
+ {
+ qprintf("1");
+ return true;
+ }
+ else
+ {
+ qprintf("0");
+ return false;
+ }
+}
+
+static bool cidr_print6(struct cidr *a)
+{
+ char *p;
+
+ if (!a || (a->family != AF_INET6))
+ return NULL;
+
+ if (!(p = (char *)inet_ntop(AF_INET6, &a->addr.v6, a->buf.v6, sizeof(a->buf.v6))))
+ return false;
+
+ if (printed)
+ qprintf(" ");
+
+ qprintf("%s", p);
+
+ if (a->prefix < 128)
+ qprintf("/%u", a->prefix);
+
+ cidr_pop(a);
+
+ return true;
+}
+
+
+static struct cidr * cidr_parse(const char *op, const char *s, int af_hint)
+{
+ char *r;
+ struct cidr *a;
+
+ uint8_t i;
+ uint32_t sum = strtoul(s, &r, 0);
+
+ if ((r > s) && (*r == 0))
+ {
+ a = malloc(sizeof(struct cidr));
+
+ if (!a)
+ return NULL;
+
+ if (af_hint == AF_INET)
+ {
+ a->family = AF_INET;
+ a->prefix = sum;
+ a->addr.v4.s_addr = htonl(sum);
+ }
+ else
+ {
+ a->family = AF_INET6;
+ a->prefix = sum;
+
+ for (i = 0; i <= 15; i++)
+ {
+ a->addr.v6.s6_addr[15-i] = sum % 256;
+ sum >>= 8;
+ }
+ }
+
+ return a;
+ }
+
+ if (strchr(s, ':'))
+ a = cidr_parse6(s);
+ else
+ a = cidr_parse4(s);
+
+ if (!a)
+ return NULL;
+
+ if (a->family != af_hint)
+ {
+ fprintf(stderr, "attempt to '%s' %s with %s address\n",
+ op,
+ (af_hint == AF_INET) ? "ipv4" : "ipv6",
+ (af_hint != AF_INET) ? "ipv4" : "ipv6");
+ exit(4);
+ }
+
+ return a;
+}
+
+static bool cidr_howmany(struct cidr *a, struct cidr *b)
+{
+ if (printed)
+ qprintf(" ");
+
+ if (b->prefix < a->prefix)
+ qprintf("0");
+ else
+ qprintf("%u", 1 << (b->prefix - a->prefix));
+
+ return true;
+}
+
+static bool cidr_prefix(struct cidr *a, struct cidr *b)
+{
+ a->prefix = b->prefix;
+ return true;
+}
+
+static bool cidr_quiet(struct cidr *a)
+{
+ quiet = true;
+ return true;
+}
+
+
+struct op ops[] = {
+ { .name = "add",
+ .desc = "Add argument to base address",
+ .f4.a2 = cidr_add4,
+ .f6.a2 = cidr_add6 },
+
+ { .name = "sub",
+ .desc = "Substract argument from base address",
+ .f4.a2 = cidr_sub4,
+ .f6.a2 = cidr_sub6 },
+
+ { .name = "next",
+ .desc = "Advance base address to next prefix of given size",
+ .f4.a2 = cidr_next4,
+ .f6.a2 = cidr_next6 },
+
+ { .name = "prev",
+ .desc = "Lower base address to previous prefix of give size",
+ .f4.a2 = cidr_prev4,
+ .f6.a2 = cidr_prev6 },
+
+ { .name = "network",
+ .desc = "Turn base address into network address",
+ .f4.a1 = cidr_network4,
+ .f6.a1 = cidr_network6 },
+
+ { .name = "broadcast",
+ .desc = "Turn base address into broadcast address",
+ .f4.a1 = cidr_broadcast4 },
+
+ { .name = "prefix",
+ .desc = "Set the prefix of base address to argument",
+ .f4.a2 = cidr_prefix,
+ .f6.a2 = cidr_prefix },
+
+ { .name = "netmask",
+ .desc = "Calculate netmask of base address",
+ .f4.a1 = cidr_netmask4 },
+
+ { .name = "6to4",
+ .desc = "Calculate 6to4 prefix of given ipv4-address",
+ .f4.a1 = cidr_6to4 },
+
+ { .name = "howmany",
+ .desc = "Print amount of righ-hand prefixes that fit into base address",
+ .f4.a2 = cidr_howmany,
+ .f6.a2 = cidr_howmany },
+
+ { .name = "contains",
+ .desc = "Print '1' if argument fits into base address or '0' if not",
+ .f4.a2 = cidr_contains4,
+ .f6.a2 = cidr_contains6 },
+
+ { .name = "private",
+ .desc = "Print '1' if base address is in RFC1918 private space or '0' "
+ "if not",
+ .f4.a1 = cidr_private4 },
+
+ { .name = "linklocal",
+ .desc = "Print '1' if base address is in 169.254.0.0/16 or FE80::/10 "
+ "link local space or '0' if not",
+ .f4.a1 = cidr_linklocal4,
+ .f6.a1 = cidr_linklocal6 },
+
+ { .name = "ula",
+ .desc = "Print '1' if base address is in FC00::/7 unique local address "
+ "(ULA) space or '0' if not",
+ .f6.a1 = cidr_ula6 },
+
+ { .name = "quiet",
+ .desc = "Suppress output, useful for test operation where the result can "
+ "be inferred from the exit code",
+ .f4.a1 = cidr_quiet,
+ .f6.a1 = cidr_quiet },
+
+ { .name = "pop",
+ .desc = "Pop intermediate result from stack",
+ .f4.a1 = cidr_pop,
+ .f6.a1 = cidr_pop },
+
+ { .name = "print",
+ .desc = "Print intermediate result and pop it from stack, invoked "
+ "implicitely at the end of calculation if no intermediate prints "
+ "happened",
+ .f4.a1 = cidr_print4,
+ .f6.a1 = cidr_print6 },
+};
+
+static void usage(const char *prog)
+{
+ int i;
+
+ fprintf(stderr,
+ "\n"
+ "Usage:\n\n"
+ " %s {base address} operation [argument] "
+ "[operation [argument] ...]\n\n"
+ "Operations:\n\n",
+ prog);
+
+ for (i = 0; i < sizeof(ops) / sizeof(ops[0]); i++)
+ {
+ if (ops[i].f4.a2 || ops[i].f6.a2)
+ {
+ fprintf(stderr, " %s %s\n",
+ ops[i].name,
+ (ops[i].f4.a2 && ops[i].f6.a2) ? "{ipv4/ipv6/amount}" :
+ (ops[i].f6.a2 ? "{ipv6/amount}" : "{ipv4/amount}"));
+ }
+ else
+ {
+ fprintf(stderr, " %s\n", ops[i].name);
+ }
+
+ fprintf(stderr, " %s.\n", ops[i].desc);
+
+ if ((ops[i].f4.a1 && ops[i].f6.a1) || (ops[i].f4.a2 && ops[i].f6.a2))
+ fprintf(stderr, " Applicable to ipv4- and ipv6-addresses.\n\n");
+ else if (ops[i].f6.a2 || ops[i].f6.a1)
+ fprintf(stderr, " Only applicable to ipv6-addresses.\n\n");
+ else
+ fprintf(stderr, " Only applicable to ipv4-addresses.\n\n");
+ }
+
+ fprintf(stderr,
+ "Examples:\n\n"
+ " Calculate a DHCP range:\n\n"
+ " $ %s 192.168.1.1/255.255.255.0 network add 100 print add 150 print\n"
+ " 192.168.1.100\n"
+ " 192.168.1.250\n\n"
+ " Count number of prefixes:\n\n"
+ " $ %s 2001:0DB8:FDEF::/48 howmany ::/64\n"
+ " 65536\n\n",
+ prog, prog);
+
+ exit(1);
+}
+
+static bool runop(char ***arg, int *status)
+{
+ int i;
+ char *arg1 = **arg;
+ char *arg2 = *(*arg+1);
+ struct cidr *a = stack;
+ struct cidr *b = NULL;
+
+ if (!arg1)
+ return false;
+
+ for (i = 0; i < sizeof(ops) / sizeof(ops[0]); i++)
+ {
+ if (!strcmp(ops[i].name, arg1))
+ {
+ if (ops[i].f4.a2 || ops[i].f6.a2)
+ {
+ if (!arg2)
+ {
+ fprintf(stderr, "'%s' requires an argument\n",
+ ops[i].name);
+
+ *status = 2;
+ return false;
+ }
+
+ b = cidr_parse(ops[i].name, arg2, a->family);
+
+ if (!b)
+ {
+ fprintf(stderr, "invalid address argument for '%s'\n",
+ ops[i].name);
+
+ *status = 3;
+ return false;
+ }
+
+ *arg += 2;
+
+ if (((a->family == AF_INET) && !ops[i].f4.a2) ||
+ ((a->family == AF_INET6) && !ops[i].f6.a2))
+ {
+ fprintf(stderr, "'%s' not supported for %s addresses\n",
+ ops[i].name,
+ (a->family == AF_INET) ? "ipv4" : "ipv6");
+
+ *status = 5;
+ return false;
+ }
+
+ *status = !((a->family == AF_INET) ? ops[i].f4.a2(a, b)
+ : ops[i].f6.a2(a, b));
+
+ return true;
+ }
+ else
+ {
+ *arg += 1;
+
+ if (((a->family == AF_INET) && !ops[i].f4.a1) ||
+ ((a->family == AF_INET6) && !ops[i].f6.a1))
+ {
+ fprintf(stderr, "'%s' not supported for %s addresses\n",
+ ops[i].name,
+ (a->family == AF_INET) ? "ipv4" : "ipv6");
+
+ *status = 5;
+ return false;
+ }
+
+ *status = !((a->family == AF_INET) ? ops[i].f4.a1(a)
+ : ops[i].f6.a1(a));
+
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
+int main(int argc, char **argv)
+{
+ int status = 0;
+ char **arg = argv+2;
+ struct cidr *a;
+
+ if (argc < 3)
+ usage(argv[0]);
+
+ a = strchr(argv[1], ':') ? cidr_parse6(argv[1]) : cidr_parse4(argv[1]);
+
+ if (!a)
+ usage(argv[0]);
+
+ cidr_push(a);
+
+ while (runop(&arg, &status));
+
+ if (*arg)
+ {
+ fprintf(stderr, "unknown operation '%s'\n", *arg);
+ exit(6);
+ }
+
+ if (!printed && (status < 2))
+ {
+ if (stack->family == AF_INET)
+ cidr_print4(stack);
+ else
+ cidr_print6(stack);
+ }
+
+ qprintf("\n");
+
+ exit(status);
+}
diff --git a/package/network/utils/owipcalc/src/owipcalc.c b/package/network/utils/owipcalc/src/owipcalc.c
new file mode 100644
index 0000000..d22594b
--- /dev/null
+++ b/package/network/utils/owipcalc/src/owipcalc.c
@@ -0,0 +1,951 @@
+/*
+ * owipcalc - OpenWrt IP Calculator
+ *
+ * Copyright (C) 2012 Jo-Philipp Wich <jow@openwrt.org>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdint.h>
+#include <stdbool.h>
+#include <stdlib.h>
+
+#include <string.h>
+#include <unistd.h>
+
+#include <arpa/inet.h>
+
+
+struct cidr {
+ uint8_t family;
+ uint32_t prefix;
+ union {
+ struct in_addr v4;
+ struct in6_addr v6;
+ } addr;
+ union {
+ char v4[sizeof("255.255.255.255/255.255.255.255 ")];
+ char v6[sizeof("FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:255.255.255.255/128 ")];
+ } buf;
+ struct cidr *next;
+};
+
+struct op {
+ const char *name;
+ const char *desc;
+ struct {
+ bool (*a1)(struct cidr *a);
+ bool (*a2)(struct cidr *a, struct cidr *b);
+ } f4;
+ struct {
+ bool (*a1)(struct cidr *a);
+ bool (*a2)(struct cidr *a, struct cidr *b);
+ } f6;
+};
+
+
+static bool quiet = false;
+static bool printed = false;
+
+static struct cidr *stack = NULL;
+
+#define qprintf(...) \
+ do { \
+ if (!quiet) printf(__VA_ARGS__); \
+ printed = true; \
+ } while(0)
+
+static void cidr_push(struct cidr *a)
+{
+ if (a)
+ {
+ a->next = stack;
+ stack = a;
+ }
+}
+
+static bool cidr_pop(struct cidr *a)
+{
+ struct cidr *old = stack;
+
+ if (old)
+ {
+ stack = stack->next;
+ free(old);
+
+ return true;
+ }
+
+ return false;
+}
+
+static struct cidr * cidr_clone(struct cidr *a)
+{
+ struct cidr *b = malloc(sizeof(*b));
+
+ if (!b)
+ {
+ fprintf(stderr, "out of memory\n");
+ exit(255);
+ }
+
+ memcpy(b, a, sizeof(*b));
+ cidr_push(b);
+
+ return b;
+}
+
+
+static struct cidr * cidr_parse4(const char *s)
+{
+ char *p = NULL, *r;
+ struct in_addr mask;
+ struct cidr *addr = malloc(sizeof(struct cidr));
+
+ if (!addr || (strlen(s) >= sizeof(addr->buf.v4)))
+ goto err;
+
+ snprintf(addr->buf.v4, sizeof(addr->buf.v4), "%s", s);
+
+ addr->family = AF_INET;
+
+ if ((p = strchr(addr->buf.v4, '/')) != NULL)
+ {
+ *p++ = 0;
+
+ if (strchr(p, '.') != NULL)
+ {
+ if (inet_pton(AF_INET, p, &mask) != 1)
+ goto err;
+
+ for (addr->prefix = 0; mask.s_addr; mask.s_addr >>= 1)
+ addr->prefix += (mask.s_addr & 1);
+ }
+ else
+ {
+ addr->prefix = strtoul(p, &r, 10);
+
+ if ((p == r) || (*r != 0) || (addr->prefix > 32))
+ goto err;
+ }
+ }
+ else
+ {
+ addr->prefix = 32;
+ }
+
+ if (p == addr->buf.v4+1)
+ memset(&addr->addr.v4, 0, sizeof(addr->addr.v4));
+ else if (inet_pton(AF_INET, addr->buf.v4, &addr->addr.v4) != 1)
+ goto err;
+
+ return addr;
+
+err:
+ if (addr)
+ free(addr);
+
+ return NULL;
+}
+
+static bool cidr_add4(struct cidr *a, struct cidr *b)
+{
+ uint32_t x = ntohl(a->addr.v4.s_addr);
+ uint32_t y = ntohl(b->addr.v4.s_addr);
+
+ struct cidr *n = cidr_clone(a);
+
+ if ((n->family != AF_INET) || (b->family != AF_INET))
+ return false;
+
+ if ((uint32_t)(x + y) < x)
+ {
+ fprintf(stderr, "overflow during 'add'\n");
+ return false;
+ }
+
+ n->addr.v4.s_addr = htonl(x + y);
+ return true;
+}
+
+static bool cidr_sub4(struct cidr *a, struct cidr *b)
+{
+ uint32_t x = ntohl(a->addr.v4.s_addr);
+ uint32_t y = ntohl(b->addr.v4.s_addr);
+
+ struct cidr *n = cidr_clone(a);
+
+ if ((n->family != AF_INET) || (b->family != AF_INET))
+ return false;
+
+ if ((uint32_t)(x - y) > x)
+ {
+ fprintf(stderr, "underflow during 'sub'\n");
+ return false;
+ }
+
+ n->addr.v4.s_addr = htonl(x - y);
+ return true;
+}
+
+static bool cidr_network4(struct cidr *a)
+{
+ struct cidr *n = cidr_clone(a);
+
+ n->addr.v4.s_addr &= htonl(~((1 << (32 - n->prefix)) - 1));
+ n->prefix = 32;
+
+ return true;
+}
+
+static bool cidr_broadcast4(struct cidr *a)
+{
+ struct cidr *n = cidr_clone(a);
+
+ n->addr.v4.s_addr |= htonl(((1 << (32 - n->prefix)) - 1));
+ n->prefix = 32;
+
+ return true;
+}
+
+static bool cidr_contains4(struct cidr *a, struct cidr *b)
+{
+ uint32_t net1 = a->addr.v4.s_addr & htonl(~((1 << (32 - a->prefix)) - 1));
+ uint32_t net2 = b->addr.v4.s_addr & htonl(~((1 << (32 - a->prefix)) - 1));
+
+ if (printed)
+ qprintf(" ");
+
+ if ((b->prefix >= a->prefix) && (net1 == net2))
+ {
+ qprintf("1");
+ return true;
+ }
+ else
+ {
+ qprintf("0");
+ return false;
+ }
+}
+
+static bool cidr_netmask4(struct cidr *a)
+{
+ struct cidr *n = cidr_clone(a);
+
+ n->addr.v4.s_addr = htonl(~((1 << (32 - n->prefix)) - 1));
+ n->prefix = 32;
+
+ return true;
+}
+
+static bool cidr_private4(struct cidr *a)
+{
+ uint32_t x = ntohl(a->addr.v4.s_addr);
+
+ if (printed)
+ qprintf(" ");
+
+ if (((x >= 0x0A000000) && (x <= 0x0AFFFFFF)) ||
+ ((x >= 0xAC100000) && (x <= 0xAC1FFFFF)) ||
+ ((x >= 0xC0A80000) && (x <= 0xC0A8FFFF)))
+ {
+ qprintf("1");
+ return true;
+ }
+ else
+ {
+ qprintf("0");
+ return false;
+ }
+}
+
+static bool cidr_linklocal4(struct cidr *a)
+{
+ uint32_t x = ntohl(a->addr.v4.s_addr);
+
+ if (printed)
+ qprintf(" ");
+
+ if ((x >= 0xA9FE0000) && (x <= 0xA9FEFFFF))
+ {
+ qprintf("1");
+ return true;
+ }
+ else
+ {
+ qprintf("0");
+ return false;
+ }
+}
+
+static bool cidr_prev4(struct cidr *a, struct cidr *b)
+{
+ struct cidr *n = cidr_clone(a);
+
+ n->prefix = b->prefix;
+ n->addr.v4.s_addr -= htonl(1 << (32 - b->prefix));
+
+ return true;
+}
+
+static bool cidr_next4(struct cidr *a, struct cidr *b)
+{
+ struct cidr *n = cidr_clone(a);
+
+ n->prefix = b->prefix;
+ n->addr.v4.s_addr += htonl(1 << (32 - b->prefix));
+
+ return true;
+}
+
+static bool cidr_6to4(struct cidr *a)
+{
+ struct cidr *n = cidr_clone(a);
+ uint32_t x = a->addr.v4.s_addr;
+
+ memset(&n->addr.v6.s6_addr, 0, sizeof(n->addr.v6.s6_addr));
+
+ n->family = AF_INET6;
+ n->prefix = 48;
+
+ n->addr.v6.s6_addr[0] = 0x20;
+ n->addr.v6.s6_addr[1] = 0x02;
+ n->addr.v6.s6_addr[2] = (x >> 24);
+ n->addr.v6.s6_addr[3] = (x >> 16) & 0xFF;
+ n->addr.v6.s6_addr[4] = (x >> 8) & 0xFF;
+ n->addr.v6.s6_addr[5] = x & 0xFF;
+
+ return true;
+}
+
+static bool cidr_print4(struct cidr *a)
+{
+ char *p;
+
+ if (!a || (a->family != AF_INET))
+ return false;
+
+ if (!(p = (char *)inet_ntop(AF_INET, &a->addr.v4, a->buf.v4, sizeof(a->buf.v4))))
+ return false;
+
+ if (printed)
+ qprintf(" ");
+
+ qprintf("%s", p);
+
+ if (a->prefix < 32)
+ qprintf("/%u", a->prefix);
+
+ cidr_pop(a);
+
+ return true;
+}
+
+
+static struct cidr * cidr_parse6(const char *s)
+{
+ char *p = NULL, *r;
+ struct cidr *addr = malloc(sizeof(struct cidr));
+
+ if (!addr || (strlen(s) >= sizeof(addr->buf.v6)))
+ goto err;
+
+ snprintf(addr->buf.v4, sizeof(addr->buf.v6), "%s", s);
+
+ addr->family = AF_INET6;
+
+ if ((p = strchr(addr->buf.v4, '/')) != NULL)
+ {
+ *p++ = 0;
+
+ addr->prefix = strtoul(p, &r, 10);
+
+ if ((p == r) || (*r != 0) || (addr->prefix > 128))
+ goto err;
+ }
+ else
+ {
+ addr->prefix = 128;
+ }
+
+ if (p == addr->buf.v4+1)
+ memset(&addr->addr.v6, 0, sizeof(addr->addr.v6));
+ else if (inet_pton(AF_INET6, addr->buf.v4, &addr->addr.v6) != 1)
+ goto err;
+
+ return addr;
+
+err:
+ if (addr)
+ free(addr);
+
+ return NULL;
+}
+
+static bool cidr_add6(struct cidr *a, struct cidr *b)
+{
+ uint8_t idx = 15, carry = 0, overflow = 0;
+
+ struct cidr *n = cidr_clone(a);
+ struct in6_addr *x = &n->addr.v6;
+ struct in6_addr *y = &b->addr.v6;
+
+ if ((a->family != AF_INET6) || (b->family != AF_INET6))
+ return false;
+
+ do {
+ overflow = !!((x->s6_addr[idx] + y->s6_addr[idx] + carry) >= 256);
+ x->s6_addr[idx] += y->s6_addr[idx] + carry;
+ carry = overflow;
+ }
+ while (idx-- > 0);
+
+ if (carry)
+ {
+ fprintf(stderr, "overflow during 'add'\n");
+ return false;
+ }
+
+ return true;
+}
+
+static bool cidr_sub6(struct cidr *a, struct cidr *b)
+{
+ uint8_t idx = 15, carry = 0, underflow = 0;
+
+ struct cidr *n = cidr_clone(a);
+ struct in6_addr *x = &n->addr.v6;
+ struct in6_addr *y = &b->addr.v6;
+
+ if ((n->family != AF_INET6) || (b->family != AF_INET6))
+ return false;
+
+ do {
+ underflow = !!((x->s6_addr[idx] - y->s6_addr[idx] - carry) < 0);
+ x->s6_addr[idx] -= y->s6_addr[idx] + carry;
+ carry = underflow;
+ }
+ while (idx-- > 0);
+
+ if (carry)
+ {
+ fprintf(stderr, "underflow during 'sub'\n");
+ return false;
+ }
+
+ return true;
+}
+
+static bool cidr_prev6(struct cidr *a, struct cidr *b)
+{
+ uint8_t idx, carry = 1, underflow = 0;
+ struct cidr *n = cidr_clone(a);
+ struct in6_addr *x = &n->addr.v6;
+
+ if (b->prefix == 0)
+ {
+ fprintf(stderr, "underflow during 'prev'\n");
+ return false;
+ }
+
+ idx = (b->prefix - 1) / 8;
+
+ do {
+ underflow = !!((x->s6_addr[idx] - carry) < 0);
+ x->s6_addr[idx] -= carry;
+ carry = underflow;
+ }
+ while (idx-- > 0);
+
+ if (carry)
+ {
+ fprintf(stderr, "underflow during 'prev'\n");
+ return false;
+ }
+
+ n->prefix = b->prefix;
+
+ return true;
+}
+
+static bool cidr_next6(struct cidr *a, struct cidr *b)
+{
+ uint8_t idx, carry = 1, overflow = 0;
+ struct cidr *n = cidr_clone(a);
+ struct in6_addr *x = &n->addr.v6;
+
+ if (b->prefix == 0)
+ {
+ fprintf(stderr, "overflow during 'next'\n");
+ return false;
+ }
+
+ idx = (b->prefix - 1) / 8;
+
+ do {
+ overflow = !!((x->s6_addr[idx] + carry) >= 256);
+ x->s6_addr[idx] += carry;
+ carry = overflow;
+ }
+ while (idx-- > 0);
+
+ if (carry)
+ {
+ fprintf(stderr, "overflow during 'next'\n");
+ return false;
+ }
+
+ n->prefix = b->prefix;
+
+ return true;
+}
+
+static bool cidr_network6(struct cidr *a)
+{
+ uint8_t i;
+ struct cidr *n = cidr_clone(a);
+
+ for (i = 0; i < (128 - n->prefix) / 8; i++)
+ n->addr.v6.s6_addr[15-i] = 0;
+
+ if ((128 - n->prefix) % 8)
+ n->addr.v6.s6_addr[15-i] &= ~((1 << ((128 - n->prefix) % 8)) - 1);
+
+ return true;
+}
+
+static bool cidr_contains6(struct cidr *a, struct cidr *b)
+{
+ struct cidr *n = cidr_clone(a);
+ struct in6_addr *x = &n->addr.v6;
+ struct in6_addr *y = &b->addr.v6;
+ uint8_t i = (128 - n->prefix) / 8;
+ uint8_t m = ~((1 << ((128 - n->prefix) % 8)) - 1);
+ uint8_t net1 = x->s6_addr[15-i] & m;
+ uint8_t net2 = y->s6_addr[15-i] & m;
+
+ if (printed)
+ qprintf(" ");
+
+ if ((b->prefix >= n->prefix) && (net1 == net2) &&
+ ((i == 15) || !memcmp(&x->s6_addr, &y->s6_addr, 15-i)))
+ {
+ qprintf("1");
+ return true;
+ }
+ else
+ {
+ qprintf("0");
+ return false;
+ }
+}
+
+static bool cidr_linklocal6(struct cidr *a)
+{
+ if (printed)
+ qprintf(" ");
+
+ if ((a->addr.v6.s6_addr[0] == 0xFE) &&
+ (a->addr.v6.s6_addr[1] >= 0x80) &&
+ (a->addr.v6.s6_addr[1] <= 0xBF))
+ {
+ qprintf("1");
+ return true;
+ }
+ else
+ {
+ qprintf("0");
+ return false;
+ }
+}
+
+static bool cidr_ula6(struct cidr *a)
+{
+ if (printed)
+ qprintf(" ");
+
+ if ((a->addr.v6.s6_addr[0] >= 0xFC) &&
+ (a->addr.v6.s6_addr[0] <= 0xFD))
+ {
+ qprintf("1");
+ return true;
+ }
+ else
+ {
+ qprintf("0");
+ return false;
+ }
+}
+
+static bool cidr_print6(struct cidr *a)
+{
+ char *p;
+
+ if (!a || (a->family != AF_INET6))
+ return NULL;
+
+ if (!(p = (char *)inet_ntop(AF_INET6, &a->addr.v6, a->buf.v6, sizeof(a->buf.v6))))
+ return false;
+
+ if (printed)
+ qprintf(" ");
+
+ qprintf("%s", p);
+
+ if (a->prefix < 128)
+ qprintf("/%u", a->prefix);
+
+ cidr_pop(a);
+
+ return true;
+}
+
+
+static struct cidr * cidr_parse(const char *op, const char *s, int af_hint)
+{
+ char *r;
+ struct cidr *a;
+
+ uint8_t i;
+ uint32_t sum = strtoul(s, &r, 0);
+
+ if ((r > s) && (*r == 0))
+ {
+ a = malloc(sizeof(struct cidr));
+
+ if (!a)
+ return NULL;
+
+ if (af_hint == AF_INET)
+ {
+ a->family = AF_INET;
+ a->prefix = sum;
+ a->addr.v4.s_addr = htonl(sum);
+ }
+ else
+ {
+ a->family = AF_INET6;
+ a->prefix = sum;
+
+ for (i = 0; i <= 15; i++)
+ {
+ a->addr.v6.s6_addr[15-i] = sum % 256;
+ sum >>= 8;
+ }
+ }
+
+ return a;
+ }
+
+ if (strchr(s, ':'))
+ a = cidr_parse6(s);
+ else
+ a = cidr_parse4(s);
+
+ if (!a)
+ return NULL;
+
+ if (a->family != af_hint)
+ {
+ fprintf(stderr, "attempt to '%s' %s with %s address\n",
+ op,
+ (af_hint == AF_INET) ? "ipv4" : "ipv6",
+ (af_hint != AF_INET) ? "ipv4" : "ipv6");
+ exit(4);
+ }
+
+ return a;
+}
+
+static bool cidr_howmany(struct cidr *a, struct cidr *b)
+{
+ if (printed)
+ qprintf(" ");
+
+ if (b->prefix < a->prefix)
+ qprintf("0");
+ else
+ qprintf("%u", 1 << (b->prefix - a->prefix));
+
+ return true;
+}
+
+static bool cidr_prefix(struct cidr *a, struct cidr *b)
+{
+ a->prefix = b->prefix;
+ return true;
+}
+
+static bool cidr_quiet(struct cidr *a)
+{
+ quiet = true;
+ return true;
+}
+
+
+struct op ops[] = {
+ { .name = "add",
+ .desc = "Add argument to base address",
+ .f4.a2 = cidr_add4,
+ .f6.a2 = cidr_add6 },
+
+ { .name = "sub",
+ .desc = "Substract argument from base address",
+ .f4.a2 = cidr_sub4,
+ .f6.a2 = cidr_sub6 },
+
+ { .name = "next",
+ .desc = "Advance base address to next prefix of given size",
+ .f4.a2 = cidr_next4,
+ .f6.a2 = cidr_next6 },
+
+ { .name = "prev",
+ .desc = "Lower base address to previous prefix of give size",
+ .f4.a2 = cidr_prev4,
+ .f6.a2 = cidr_prev6 },
+
+ { .name = "network",
+ .desc = "Turn base address into network address",
+ .f4.a1 = cidr_network4,
+ .f6.a1 = cidr_network6 },
+
+ { .name = "broadcast",
+ .desc = "Turn base address into broadcast address",
+ .f4.a1 = cidr_broadcast4 },
+
+ { .name = "prefix",
+ .desc = "Set the prefix of base address to argument",
+ .f4.a2 = cidr_prefix,
+ .f6.a2 = cidr_prefix },
+
+ { .name = "netmask",
+ .desc = "Calculate netmask of base address",
+ .f4.a1 = cidr_netmask4 },
+
+ { .name = "6to4",
+ .desc = "Calculate 6to4 prefix of given ipv4-address",
+ .f4.a1 = cidr_6to4 },
+
+ { .name = "howmany",
+ .desc = "Print amount of righ-hand prefixes that fit into base address",
+ .f4.a2 = cidr_howmany,
+ .f6.a2 = cidr_howmany },
+
+ { .name = "contains",
+ .desc = "Print '1' if argument fits into base address or '0' if not",
+ .f4.a2 = cidr_contains4,
+ .f6.a2 = cidr_contains6 },
+
+ { .name = "private",
+ .desc = "Print '1' if base address is in RFC1918 private space or '0' "
+ "if not",
+ .f4.a1 = cidr_private4 },
+
+ { .name = "linklocal",
+ .desc = "Print '1' if base address is in 169.254.0.0/16 or FE80::/10 "
+ "link local space or '0' if not",
+ .f4.a1 = cidr_linklocal4,
+ .f6.a1 = cidr_linklocal6 },
+
+ { .name = "ula",
+ .desc = "Print '1' if base address is in FC00::/7 unique local address "
+ "(ULA) space or '0' if not",
+ .f6.a1 = cidr_ula6 },
+
+ { .name = "quiet",
+ .desc = "Suppress output, useful for test operation where the result can "
+ "be inferred from the exit code",
+ .f4.a1 = cidr_quiet,
+ .f6.a1 = cidr_quiet },
+
+ { .name = "pop",
+ .desc = "Pop intermediate result from stack",
+ .f4.a1 = cidr_pop,
+ .f6.a1 = cidr_pop },
+
+ { .name = "print",
+ .desc = "Print intermediate result and pop it from stack, invoked "
+ "implicitely at the end of calculation if no intermediate prints "
+ "happened",
+ .f4.a1 = cidr_print4,
+ .f6.a1 = cidr_print6 },
+};
+
+static void usage(const char *prog)
+{
+ int i;
+
+ fprintf(stderr,
+ "\n"
+ "Usage:\n\n"
+ " %s {base address} operation [argument] "
+ "[operation [argument] ...]\n\n"
+ "Operations:\n\n",
+ prog);
+
+ for (i = 0; i < sizeof(ops) / sizeof(ops[0]); i++)
+ {
+ if (ops[i].f4.a2 || ops[i].f6.a2)
+ {
+ fprintf(stderr, " %s %s\n",
+ ops[i].name,
+ (ops[i].f4.a2 && ops[i].f6.a2) ? "{ipv4/ipv6/amount}" :
+ (ops[i].f6.a2 ? "{ipv6/amount}" : "{ipv4/amount}"));
+ }
+ else
+ {
+ fprintf(stderr, " %s\n", ops[i].name);
+ }
+
+ fprintf(stderr, " %s.\n", ops[i].desc);
+
+ if ((ops[i].f4.a1 && ops[i].f6.a1) || (ops[i].f4.a2 && ops[i].f6.a2))
+ fprintf(stderr, " Applicable to ipv4- and ipv6-addresses.\n\n");
+ else if (ops[i].f6.a2 || ops[i].f6.a1)
+ fprintf(stderr, " Only applicable to ipv6-addresses.\n\n");
+ else
+ fprintf(stderr, " Only applicable to ipv4-addresses.\n\n");
+ }
+
+ fprintf(stderr,
+ "Examples:\n\n"
+ " Calculate a DHCP range:\n\n"
+ " $ %s 192.168.1.1/255.255.255.0 network add 100 print add 150 print\n"
+ " 192.168.1.100\n"
+ " 192.168.1.250\n\n"
+ " Count number of prefixes:\n\n"
+ " $ %s 2001:0DB8:FDEF::/48 howmany ::/64\n"
+ " 65536\n\n",
+ prog, prog);
+
+ exit(1);
+}
+
+static bool runop(char ***arg, int *status)
+{
+ int i;
+ char *arg1 = **arg;
+ char *arg2 = *(*arg+1);
+ struct cidr *a = stack;
+ struct cidr *b = NULL;
+
+ if (!arg1)
+ return false;
+
+ for (i = 0; i < sizeof(ops) / sizeof(ops[0]); i++)
+ {
+ if (!strcmp(ops[i].name, arg1))
+ {
+ if (ops[i].f4.a2 || ops[i].f6.a2)
+ {
+ if (!arg2)
+ {
+ fprintf(stderr, "'%s' requires an argument\n",
+ ops[i].name);
+
+ *status = 2;
+ return false;
+ }
+
+ b = cidr_parse(ops[i].name, arg2, a->family);
+
+ if (!b)
+ {
+ fprintf(stderr, "invalid address argument for '%s'\n",
+ ops[i].name);
+
+ *status = 3;
+ return false;
+ }
+
+ *arg += 2;
+
+ if (((a->family == AF_INET) && !ops[i].f4.a2) ||
+ ((a->family == AF_INET6) && !ops[i].f6.a2))
+ {
+ fprintf(stderr, "'%s' not supported for %s addresses\n",
+ ops[i].name,
+ (a->family == AF_INET) ? "ipv4" : "ipv6");
+
+ *status = 5;
+ return false;
+ }
+
+ *status = !((a->family == AF_INET) ? ops[i].f4.a2(a, b)
+ : ops[i].f6.a2(a, b));
+
+ return true;
+ }
+ else
+ {
+ *arg += 1;
+
+ if (((a->family == AF_INET) && !ops[i].f4.a1) ||
+ ((a->family == AF_INET6) && !ops[i].f6.a1))
+ {
+ fprintf(stderr, "'%s' not supported for %s addresses\n",
+ ops[i].name,
+ (a->family == AF_INET) ? "ipv4" : "ipv6");
+
+ *status = 5;
+ return false;
+ }
+
+ *status = !((a->family == AF_INET) ? ops[i].f4.a1(a)
+ : ops[i].f6.a1(a));
+
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
+int main(int argc, char **argv)
+{
+ int status = 0;
+ char **arg = argv+2;
+ struct cidr *a;
+
+ if (argc < 3)
+ usage(argv[0]);
+
+ a = strchr(argv[1], ':') ? cidr_parse6(argv[1]) : cidr_parse4(argv[1]);
+
+ if (!a)
+ usage(argv[0]);
+
+ cidr_push(a);
+
+ while (runop(&arg, &status));
+
+ if (*arg)
+ {
+ fprintf(stderr, "unknown operation '%s'\n", *arg);
+ exit(6);
+ }
+
+ if (!printed && (status < 2))
+ {
+ if (stack->family == AF_INET)
+ cidr_print4(stack);
+ else
+ cidr_print6(stack);
+ }
+
+ qprintf("\n");
+
+ exit(status);
+}
diff --git a/package/network/utils/resolveip/.svn/entries b/package/network/utils/resolveip/.svn/entries
new file mode 100644
index 0000000..cf3d7dd
--- /dev/null
+++ b/package/network/utils/resolveip/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/utils/resolveip
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-11-08T10:48:08.097938Z
+34116
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+src
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+1fa9897b6ef6d0f594dd26fbd8e322b1
+2012-11-08T10:48:08.097938Z
+34116
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1159
+
diff --git a/package/network/utils/resolveip/.svn/text-base/Makefile.svn-base b/package/network/utils/resolveip/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..d1e675e
--- /dev/null
+++ b/package/network/utils/resolveip/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,45 @@
+#
+# Copyright (C) 2011-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=resolveip
+PKG_RELEASE:=2
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/resolveip
+ SECTION:=utils
+ CATEGORY:=Base system
+ TITLE:=Simple DNS resolver with configurable timeout
+ MAINTAINER:=Jo-Philipp Wich <jow@openwrt.org>
+endef
+
+define Package/resolveip/description
+ This package contains the small resolveip utility which
+ can be used by scripts to turn host names into numeric
+ IP addresses. It supports IPv4 and IPv6 resolving and
+ has a configurable timeout to guarantee a certain maximum
+ runtime in case of slow or defunct DNS servers.
+endef
+
+define Build/Prepare
+ $(INSTALL_DIR) $(PKG_BUILD_DIR)
+ $(INSTALL_DATA) ./src/resolveip.c $(PKG_BUILD_DIR)/
+endef
+
+define Build/Compile
+ $(TARGET_CC) $(TARGET_CFLAGS) -Wall \
+ -o $(PKG_BUILD_DIR)/resolveip $(PKG_BUILD_DIR)/resolveip.c
+endef
+
+define Package/resolveip/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/resolveip $(1)/usr/bin/
+endef
+
+$(eval $(call BuildPackage,resolveip))
diff --git a/package/network/utils/resolveip/Makefile b/package/network/utils/resolveip/Makefile
new file mode 100644
index 0000000..d1e675e
--- /dev/null
+++ b/package/network/utils/resolveip/Makefile
@@ -0,0 +1,45 @@
+#
+# Copyright (C) 2011-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=resolveip
+PKG_RELEASE:=2
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/resolveip
+ SECTION:=utils
+ CATEGORY:=Base system
+ TITLE:=Simple DNS resolver with configurable timeout
+ MAINTAINER:=Jo-Philipp Wich <jow@openwrt.org>
+endef
+
+define Package/resolveip/description
+ This package contains the small resolveip utility which
+ can be used by scripts to turn host names into numeric
+ IP addresses. It supports IPv4 and IPv6 resolving and
+ has a configurable timeout to guarantee a certain maximum
+ runtime in case of slow or defunct DNS servers.
+endef
+
+define Build/Prepare
+ $(INSTALL_DIR) $(PKG_BUILD_DIR)
+ $(INSTALL_DATA) ./src/resolveip.c $(PKG_BUILD_DIR)/
+endef
+
+define Build/Compile
+ $(TARGET_CC) $(TARGET_CFLAGS) -Wall \
+ -o $(PKG_BUILD_DIR)/resolveip $(PKG_BUILD_DIR)/resolveip.c
+endef
+
+define Package/resolveip/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/resolveip $(1)/usr/bin/
+endef
+
+$(eval $(call BuildPackage,resolveip))
diff --git a/package/network/utils/resolveip/src/.svn/entries b/package/network/utils/resolveip/src/.svn/entries
new file mode 100644
index 0000000..0bc2478
--- /dev/null
+++ b/package/network/utils/resolveip/src/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/utils/resolveip/src
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-11-08T10:48:08.097938Z
+34116
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+resolveip.c
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+202783d173f5dd5f020df23e8a5c41c2
+2012-11-08T10:48:08.097938Z
+34116
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1885
+
diff --git a/package/network/utils/resolveip/src/.svn/text-base/resolveip.c.svn-base b/package/network/utils/resolveip/src/.svn/text-base/resolveip.c.svn-base
new file mode 100644
index 0000000..43c5ae7
--- /dev/null
+++ b/package/network/utils/resolveip/src/.svn/text-base/resolveip.c.svn-base
@@ -0,0 +1,98 @@
+/*
+ * Based on code found at https://dev.openwrt.org/ticket/4876 .
+ * Extended by Jo-Philipp Wich <jow@openwrt.org> for use in OpenWrt.
+ *
+ * You may use this program under the terms of the GPLv2 license.
+ */
+
+#include <string.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netdb.h>
+#include <arpa/inet.h>
+#include <netinet/in.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <signal.h>
+
+
+static void abort_query(int sig)
+{
+ exit(1);
+}
+
+static void show_usage(void)
+{
+ printf("Usage:\n");
+ printf(" resolveip -h\n");
+ printf(" resolveip [-t timeout] hostname\n");
+ printf(" resolveip -4 [-t timeout] hostname\n");
+ printf(" resolveip -6 [-t timeout] hostname\n");
+ exit(255);
+}
+
+int main(int argc, char **argv)
+{
+ int timeout = 3;
+ int opt;
+ char ipaddr[INET6_ADDRSTRLEN];
+ void *addr;
+ struct addrinfo *res, *rp;
+ struct sigaction sa = { .sa_handler = &abort_query };
+ struct addrinfo hints = {
+ .ai_family = AF_UNSPEC,
+ .ai_socktype = SOCK_STREAM,
+ .ai_protocol = IPPROTO_TCP,
+ .ai_flags = 0
+ };
+
+ while ((opt = getopt(argc, argv, "46t:h")) > -1)
+ {
+ switch ((char)opt)
+ {
+ case '4':
+ hints.ai_family = AF_INET;
+ break;
+
+ case '6':
+ hints.ai_family = AF_INET6;
+ break;
+
+ case 't':
+ timeout = atoi(optarg);
+ if (timeout <= 0)
+ show_usage();
+ break;
+
+ case 'h':
+ show_usage();
+ break;
+ }
+ }
+
+ if (!argv[optind])
+ show_usage();
+
+ sigaction(SIGALRM, &sa, NULL);
+ alarm(timeout);
+
+ if (getaddrinfo(argv[optind], NULL, &hints, &res))
+ exit(2);
+
+ for (rp = res; rp != NULL; rp = rp->ai_next)
+ {
+ addr = (rp->ai_family == AF_INET)
+ ? (void *)&((struct sockaddr_in *)rp->ai_addr)->sin_addr
+ : (void *)&((struct sockaddr_in6 *)rp->ai_addr)->sin6_addr
+ ;
+
+ if (!inet_ntop(rp->ai_family, addr, ipaddr, INET6_ADDRSTRLEN - 1))
+ exit(3);
+
+ printf("%s\n", ipaddr);
+ }
+
+ freeaddrinfo(res);
+ exit(0);
+}
diff --git a/package/network/utils/resolveip/src/resolveip.c b/package/network/utils/resolveip/src/resolveip.c
new file mode 100644
index 0000000..43c5ae7
--- /dev/null
+++ b/package/network/utils/resolveip/src/resolveip.c
@@ -0,0 +1,98 @@
+/*
+ * Based on code found at https://dev.openwrt.org/ticket/4876 .
+ * Extended by Jo-Philipp Wich <jow@openwrt.org> for use in OpenWrt.
+ *
+ * You may use this program under the terms of the GPLv2 license.
+ */
+
+#include <string.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netdb.h>
+#include <arpa/inet.h>
+#include <netinet/in.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <signal.h>
+
+
+static void abort_query(int sig)
+{
+ exit(1);
+}
+
+static void show_usage(void)
+{
+ printf("Usage:\n");
+ printf(" resolveip -h\n");
+ printf(" resolveip [-t timeout] hostname\n");
+ printf(" resolveip -4 [-t timeout] hostname\n");
+ printf(" resolveip -6 [-t timeout] hostname\n");
+ exit(255);
+}
+
+int main(int argc, char **argv)
+{
+ int timeout = 3;
+ int opt;
+ char ipaddr[INET6_ADDRSTRLEN];
+ void *addr;
+ struct addrinfo *res, *rp;
+ struct sigaction sa = { .sa_handler = &abort_query };
+ struct addrinfo hints = {
+ .ai_family = AF_UNSPEC,
+ .ai_socktype = SOCK_STREAM,
+ .ai_protocol = IPPROTO_TCP,
+ .ai_flags = 0
+ };
+
+ while ((opt = getopt(argc, argv, "46t:h")) > -1)
+ {
+ switch ((char)opt)
+ {
+ case '4':
+ hints.ai_family = AF_INET;
+ break;
+
+ case '6':
+ hints.ai_family = AF_INET6;
+ break;
+
+ case 't':
+ timeout = atoi(optarg);
+ if (timeout <= 0)
+ show_usage();
+ break;
+
+ case 'h':
+ show_usage();
+ break;
+ }
+ }
+
+ if (!argv[optind])
+ show_usage();
+
+ sigaction(SIGALRM, &sa, NULL);
+ alarm(timeout);
+
+ if (getaddrinfo(argv[optind], NULL, &hints, &res))
+ exit(2);
+
+ for (rp = res; rp != NULL; rp = rp->ai_next)
+ {
+ addr = (rp->ai_family == AF_INET)
+ ? (void *)&((struct sockaddr_in *)rp->ai_addr)->sin_addr
+ : (void *)&((struct sockaddr_in6 *)rp->ai_addr)->sin6_addr
+ ;
+
+ if (!inet_ntop(rp->ai_family, addr, ipaddr, INET6_ADDRSTRLEN - 1))
+ exit(3);
+
+ printf("%s\n", ipaddr);
+ }
+
+ freeaddrinfo(res);
+ exit(0);
+}
diff --git a/package/network/utils/rssileds/.svn/entries b/package/network/utils/rssileds/.svn/entries
new file mode 100644
index 0000000..e85a918
--- /dev/null
+++ b/package/network/utils/rssileds/.svn/entries
@@ -0,0 +1,68 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/utils/rssileds
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-14T16:22:04.158745Z
+33766
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+files
+dir
+
+src
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+3b4d1526d30460a64957fb17649175a8
+2012-10-14T16:22:04.158745Z
+33766
+florian
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1095
+
diff --git a/package/network/utils/rssileds/.svn/prop-base/Makefile.svn-base b/package/network/utils/rssileds/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/network/utils/rssileds/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/utils/rssileds/.svn/text-base/Makefile.svn-base b/package/network/utils/rssileds/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..b572eac
--- /dev/null
+++ b/package/network/utils/rssileds/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,48 @@
+#
+# Copyright (C) 2011-2012 Daniel Golle <dgolle@allnet.de>
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=rssileds
+PKG_VERSION:=0.2
+PKG_RELEASE:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/rssileds
+ SECTION:=net
+ CATEGORY:=Network
+ TITLE:=RSSI real-time LED indicator
+ DEPENDS:=+libiwinfo
+ MAINTAINER:=Daniel Golle <dgolle@allnet.de>
+endef
+
+define Package/rssileds/description
+ A small process written in C to update the signal-strength indicator LEDs
+endef
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+ $(TARGET_CC) $(TARGET_CFLAGS) -Wall -liwinfo \
+ -o $(PKG_BUILD_DIR)/rssileds $(PKG_BUILD_DIR)/rssileds.c
+endef
+
+define Package/rssileds/install
+ $(INSTALL_DIR) $(1)/etc/init.d
+ $(INSTALL_BIN) ./files/rssileds.init $(1)/etc/init.d/rssileds
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/rssileds $(1)/usr/sbin/
+endef
+
+$(eval $(call BuildPackage,rssileds))
diff --git a/package/network/utils/rssileds/Makefile b/package/network/utils/rssileds/Makefile
new file mode 100644
index 0000000..b572eac
--- /dev/null
+++ b/package/network/utils/rssileds/Makefile
@@ -0,0 +1,48 @@
+#
+# Copyright (C) 2011-2012 Daniel Golle <dgolle@allnet.de>
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=rssileds
+PKG_VERSION:=0.2
+PKG_RELEASE:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/rssileds
+ SECTION:=net
+ CATEGORY:=Network
+ TITLE:=RSSI real-time LED indicator
+ DEPENDS:=+libiwinfo
+ MAINTAINER:=Daniel Golle <dgolle@allnet.de>
+endef
+
+define Package/rssileds/description
+ A small process written in C to update the signal-strength indicator LEDs
+endef
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+ $(TARGET_CC) $(TARGET_CFLAGS) -Wall -liwinfo \
+ -o $(PKG_BUILD_DIR)/rssileds $(PKG_BUILD_DIR)/rssileds.c
+endef
+
+define Package/rssileds/install
+ $(INSTALL_DIR) $(1)/etc/init.d
+ $(INSTALL_BIN) ./files/rssileds.init $(1)/etc/init.d/rssileds
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/rssileds $(1)/usr/sbin/
+endef
+
+$(eval $(call BuildPackage,rssileds))
diff --git a/package/network/utils/rssileds/files/.svn/entries b/package/network/utils/rssileds/files/.svn/entries
new file mode 100644
index 0000000..6aa8b5e
--- /dev/null
+++ b/package/network/utils/rssileds/files/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/utils/rssileds/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-08-13T14:01:34.982346Z
+33163
+juhosg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+rssileds.init
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+c7c5868b7978324df1756fa0bf08a3ff
+2012-08-13T14:01:34.982346Z
+33163
+juhosg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1660
+
diff --git a/package/network/utils/rssileds/files/.svn/text-base/rssileds.init.svn-base b/package/network/utils/rssileds/files/.svn/text-base/rssileds.init.svn-base
new file mode 100644
index 0000000..b0d2627
--- /dev/null
+++ b/package/network/utils/rssileds/files/.svn/text-base/rssileds.init.svn-base
@@ -0,0 +1,75 @@
+#!/bin/sh /etc/rc.common
+# (C) 2012 Daniel Golle, Allnet GmbH <dgolle@allnet.de>
+
+START=96
+STOP=96
+RSSILEDS_BIN="/usr/sbin/rssileds"
+
+SERVICE_DAEMONIZE=1
+SERVICE_WRITE_PID=1
+
+start_rssid() {
+ local name
+ local dev
+ local threshold
+ local refresh
+ local leds
+ config_get name $1 name
+ config_get dev $1 dev
+ config_get threshold $1 threshold
+ config_get refresh $1 refresh
+ leds="$( cur_iface=$1 ; config_foreach get_led led )"
+ SERVICE_PID_FILE=/var/run/rssileds-$dev.pid
+ service_start $RSSILEDS_BIN $dev $refresh $threshold $leds
+}
+
+stop_rssid() {
+ local dev
+ config_get dev $1 dev
+ SERVICE_PID_FILE=/var/run/rssileds-$dev.pid
+ service_stop $RSSILEDS_BIN
+}
+
+get_led() {
+ local name
+ local sysfs
+ local trigger
+ local iface
+ config_get sysfs $1 sysfs
+ config_get name $1 name "$sysfs"
+ config_get trigger $1 trigger "none"
+ config_get iface $1 iface
+ config_get minq $1 minq
+ config_get maxq $1 maxq
+ config_get offset $1 offset
+ config_get factor $1 factor
+ [ "$trigger" = "rssi" ] || return
+ [ "$iface" = "$cur_iface" ] || return
+ [ ! "$minq" ] || [ ! "$maxq" ] || [ ! "$offset" ] || [ ! "$factor" ] && return
+ echo "none" > /sys/class/leds/$sysfs/trigger
+ echo "$sysfs $minq $maxq $offset $factor"
+}
+
+off_led() {
+ local name
+ local sysfs
+ local trigger
+ config_get sysfs $1 sysfs
+ config_get name $1 name "$sysfs"
+ config_get trigger $1 trigger "none"
+ [ "$trigger" = "rssi" ] || return
+ echo "0" > /sys/class/leds/$sysfs/brightness
+}
+
+start() {
+ [ -e /sys/class/leds/ ] && [ -x "$RSSILEDS_BIN" ] && {
+ config_load system
+ config_foreach start_rssid rssid
+ }
+}
+
+stop() {
+ config_load system
+ config_foreach stop_rssid rssid
+ config_foreach off_led led
+}
diff --git a/package/network/utils/rssileds/files/rssileds.init b/package/network/utils/rssileds/files/rssileds.init
new file mode 100644
index 0000000..b0d2627
--- /dev/null
+++ b/package/network/utils/rssileds/files/rssileds.init
@@ -0,0 +1,75 @@
+#!/bin/sh /etc/rc.common
+# (C) 2012 Daniel Golle, Allnet GmbH <dgolle@allnet.de>
+
+START=96
+STOP=96
+RSSILEDS_BIN="/usr/sbin/rssileds"
+
+SERVICE_DAEMONIZE=1
+SERVICE_WRITE_PID=1
+
+start_rssid() {
+ local name
+ local dev
+ local threshold
+ local refresh
+ local leds
+ config_get name $1 name
+ config_get dev $1 dev
+ config_get threshold $1 threshold
+ config_get refresh $1 refresh
+ leds="$( cur_iface=$1 ; config_foreach get_led led )"
+ SERVICE_PID_FILE=/var/run/rssileds-$dev.pid
+ service_start $RSSILEDS_BIN $dev $refresh $threshold $leds
+}
+
+stop_rssid() {
+ local dev
+ config_get dev $1 dev
+ SERVICE_PID_FILE=/var/run/rssileds-$dev.pid
+ service_stop $RSSILEDS_BIN
+}
+
+get_led() {
+ local name
+ local sysfs
+ local trigger
+ local iface
+ config_get sysfs $1 sysfs
+ config_get name $1 name "$sysfs"
+ config_get trigger $1 trigger "none"
+ config_get iface $1 iface
+ config_get minq $1 minq
+ config_get maxq $1 maxq
+ config_get offset $1 offset
+ config_get factor $1 factor
+ [ "$trigger" = "rssi" ] || return
+ [ "$iface" = "$cur_iface" ] || return
+ [ ! "$minq" ] || [ ! "$maxq" ] || [ ! "$offset" ] || [ ! "$factor" ] && return
+ echo "none" > /sys/class/leds/$sysfs/trigger
+ echo "$sysfs $minq $maxq $offset $factor"
+}
+
+off_led() {
+ local name
+ local sysfs
+ local trigger
+ config_get sysfs $1 sysfs
+ config_get name $1 name "$sysfs"
+ config_get trigger $1 trigger "none"
+ [ "$trigger" = "rssi" ] || return
+ echo "0" > /sys/class/leds/$sysfs/brightness
+}
+
+start() {
+ [ -e /sys/class/leds/ ] && [ -x "$RSSILEDS_BIN" ] && {
+ config_load system
+ config_foreach start_rssid rssid
+ }
+}
+
+stop() {
+ config_load system
+ config_foreach stop_rssid rssid
+ config_foreach off_led led
+}
diff --git a/package/network/utils/rssileds/src/.svn/entries b/package/network/utils/rssileds/src/.svn/entries
new file mode 100644
index 0000000..77c204f
--- /dev/null
+++ b/package/network/utils/rssileds/src/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/utils/rssileds/src
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-14T16:22:04.158745Z
+33766
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+rssileds.c
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+15d9c802ad680479ab2cdc2f65d58877
+2012-10-14T16:22:04.158745Z
+33766
+florian
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5647
+
diff --git a/package/network/utils/rssileds/src/.svn/prop-base/rssileds.c.svn-base b/package/network/utils/rssileds/src/.svn/prop-base/rssileds.c.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/network/utils/rssileds/src/.svn/prop-base/rssileds.c.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/utils/rssileds/src/.svn/text-base/rssileds.c.svn-base b/package/network/utils/rssileds/src/.svn/text-base/rssileds.c.svn-base
new file mode 100644
index 0000000..60d30f1
--- /dev/null
+++ b/package/network/utils/rssileds/src/.svn/text-base/rssileds.c.svn-base
@@ -0,0 +1,290 @@
+/*
+ * configurable RSSI LED control daemon for OpenWrt
+ * (c) 2012 Allnet GmbH, Daniel Golle <dgolle@allnet.de>
+ *
+ * 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 of the License, 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * The author may be reached as dgolle@allnet.de, or
+ * ALLNET GmbH
+ * Maistr. 2
+ * D-82110 Germering
+ * Germany
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <unistd.h>
+#include <syslog.h>
+
+#include "iwinfo.h"
+
+#define RUN_DIR "/var/run"
+#define LEDS_BASEPATH "/sys/class/leds/"
+#define BACKEND_RETRY_DELAY 500000
+
+char *ifname;
+int qual_max;
+
+struct led {
+ char *sysfspath;
+ FILE *controlfd;
+ unsigned char state;
+};
+
+typedef struct rule rule_t;
+struct rule {
+ struct led *led;
+ int minq;
+ int maxq;
+ int boffset;
+ int bfactor;
+ rule_t *next;
+};
+
+void log_rules(rule_t *rules)
+{
+ rule_t *rule = rules;
+ while (rule)
+ {
+ syslog(LOG_INFO, " %s r: %d..%d, o: %d, f: %d\n",
+ rule->led->sysfspath,
+ rule->minq, rule->maxq,
+ rule->boffset, rule->bfactor);
+ rule = rule->next;
+ }
+}
+
+int set_led(struct led *led, unsigned char value)
+{
+ char buf[8];
+
+ if ( ! led )
+ return -1;
+
+ if ( ! led->controlfd )
+ return -1;
+
+ if ( led->state == value )
+ return 0;
+
+ snprintf(buf, 8, "%d", value);
+
+ rewind(led->controlfd);
+
+ if ( ! fwrite(buf, sizeof(char), strlen(buf), led->controlfd) )
+ return -2;
+
+ fflush(led->controlfd);
+ led->state=value;
+
+ return 0;
+}
+
+int init_led(struct led **led, char *ledname)
+{
+ struct led *newled;
+ struct stat statbuffer;
+ int status;
+ char *bp;
+ FILE *bfp;
+
+ bp = calloc(sizeof(char), strlen(ledname) + strlen(LEDS_BASEPATH) + 12);
+ if ( ! bp )
+ goto return_error;
+
+ sprintf(bp, "%s%s/brightness", LEDS_BASEPATH, ledname);
+
+ status = stat(bp, &statbuffer);
+ if ( status )
+ goto cleanup_fname;
+
+ bfp = fopen( bp, "w" );
+ if ( !bfp )
+ goto cleanup_fname;
+
+ if ( ferror(bfp) )
+ goto cleanup_fp;
+
+ /* sysfs path exists and, allocate LED struct */
+ newled = calloc(sizeof(struct led),1);
+ if ( !newled )
+ goto cleanup_fp;
+
+ newled->sysfspath = bp;
+ newled->controlfd = bfp;
+
+ *led = newled;
+
+ if ( set_led(newled, 255) )
+ goto cleanup_fp;
+
+ if ( set_led(newled, 0) )
+ goto cleanup_fp;
+
+ return 0;
+
+cleanup_fp:
+ fclose(bfp);
+cleanup_fname:
+ free(bp);
+return_error:
+ syslog(LOG_CRIT, "can't open LED %s\n", ledname);
+ *led = NULL;
+ return -1;
+}
+
+void close_led(struct led **led)
+{
+ fclose((*led)->controlfd);
+ free((*led)->sysfspath);
+ free((*led));
+ (*led)=NULL;
+}
+
+
+int quality(const struct iwinfo_ops *iw, const char *ifname)
+{
+ int qual;
+
+ if ( ! iw ) return -1;
+
+ if (qual_max < 1)
+ if (iw->quality_max(ifname, &qual_max))
+ return -1;
+
+ if (iw->quality(ifname, &qual))
+ return -1;
+
+ return ( qual * 100 ) / qual_max ;
+}
+
+int open_backend(const struct iwinfo_ops **iw, const char *ifname)
+{
+ *iw = iwinfo_backend(ifname);
+
+ if (!(*iw))
+ return 1;
+
+ return 0;
+}
+
+void update_leds(rule_t *rules, int q)
+{
+ rule_t *rule = rules;
+ while (rule)
+ {
+ int b;
+ /* offset and factore correction according to rule */
+ b = ( q + rule->boffset ) * rule->bfactor;
+ if ( b < 0 )
+ b=0;
+ if ( b > 255 )
+ b=255;
+
+ if ( q >= rule->minq && q <= rule->maxq )
+ set_led(rule->led, (unsigned char)b);
+ else
+ set_led(rule->led, 0);
+
+ rule = rule->next;
+ }
+}
+
+int main(int argc, char **argv)
+{
+ int i,q,q0,r,s;
+ const struct iwinfo_ops *iw = NULL;
+ rule_t *headrule = NULL, *currentrule = NULL;
+
+ if (argc < 9 || ( (argc-4) % 5 != 0 ) )
+ {
+ printf("syntax: %s (ifname) (refresh) (threshold) (rule) [rule] ...\n", argv[0]);
+ printf(" rule: (sysfs-name) (minq) (maxq) (offset) (factore)\n");
+ return 1;
+ }
+
+ ifname = argv[1];
+
+ /* refresh interval */
+ if ( sscanf(argv[2], "%d", &r) != 1 )
+ return 1;
+
+ /* sustain threshold */
+ if ( sscanf(argv[3], "%d", &s) != 1 )
+ return 1;
+
+ openlog("rssileds", LOG_PID, LOG_DAEMON);
+ syslog(LOG_INFO, "monitoring %s, refresh rate %d, threshold %d\n", ifname, r, s);
+
+ currentrule = headrule;
+ for (i=4; i<argc; i=i+5) {
+ if (! currentrule)
+ {
+ /* first element in the list */
+ currentrule = calloc(sizeof(rule_t),1);
+ headrule = currentrule;
+ }
+ else
+ {
+ /* follow-up element */
+ currentrule->next = calloc(sizeof(rule_t),1);
+ currentrule = currentrule->next;
+ }
+
+ if ( init_led(&(currentrule->led), argv[i]) )
+ return 1;
+
+ if ( sscanf(argv[i+1], "%d", &(currentrule->minq)) != 1 )
+ return 1;
+
+ if ( sscanf(argv[i+2], "%d", &(currentrule->maxq)) != 1 )
+ return 1;
+
+ if ( sscanf(argv[i+3], "%d", &(currentrule->boffset)) != 1 )
+ return 1;
+
+ if ( sscanf(argv[i+4], "%d", &(currentrule->bfactor)) != 1 )
+ return 1;
+ }
+ log_rules(headrule);
+
+ q0 = -1;
+ do {
+ q = quality(iw, ifname);
+ if ( q < q0 - s || q > q0 + s ) {
+ update_leds(headrule, q);
+ q0=q;
+ };
+ // re-open backend...
+ if ( q == -1 && q0 == -1 ) {
+ if (iw) {
+ iwinfo_finish();
+ iw=NULL;
+ usleep(BACKEND_RETRY_DELAY);
+ }
+ while (open_backend(&iw, ifname))
+ usleep(BACKEND_RETRY_DELAY);
+ }
+ usleep(r);
+ } while(1);
+
+ iwinfo_finish();
+
+ return 0;
+}
diff --git a/package/network/utils/rssileds/src/rssileds.c b/package/network/utils/rssileds/src/rssileds.c
new file mode 100644
index 0000000..60d30f1
--- /dev/null
+++ b/package/network/utils/rssileds/src/rssileds.c
@@ -0,0 +1,290 @@
+/*
+ * configurable RSSI LED control daemon for OpenWrt
+ * (c) 2012 Allnet GmbH, Daniel Golle <dgolle@allnet.de>
+ *
+ * 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 of the License, 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * The author may be reached as dgolle@allnet.de, or
+ * ALLNET GmbH
+ * Maistr. 2
+ * D-82110 Germering
+ * Germany
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <unistd.h>
+#include <syslog.h>
+
+#include "iwinfo.h"
+
+#define RUN_DIR "/var/run"
+#define LEDS_BASEPATH "/sys/class/leds/"
+#define BACKEND_RETRY_DELAY 500000
+
+char *ifname;
+int qual_max;
+
+struct led {
+ char *sysfspath;
+ FILE *controlfd;
+ unsigned char state;
+};
+
+typedef struct rule rule_t;
+struct rule {
+ struct led *led;
+ int minq;
+ int maxq;
+ int boffset;
+ int bfactor;
+ rule_t *next;
+};
+
+void log_rules(rule_t *rules)
+{
+ rule_t *rule = rules;
+ while (rule)
+ {
+ syslog(LOG_INFO, " %s r: %d..%d, o: %d, f: %d\n",
+ rule->led->sysfspath,
+ rule->minq, rule->maxq,
+ rule->boffset, rule->bfactor);
+ rule = rule->next;
+ }
+}
+
+int set_led(struct led *led, unsigned char value)
+{
+ char buf[8];
+
+ if ( ! led )
+ return -1;
+
+ if ( ! led->controlfd )
+ return -1;
+
+ if ( led->state == value )
+ return 0;
+
+ snprintf(buf, 8, "%d", value);
+
+ rewind(led->controlfd);
+
+ if ( ! fwrite(buf, sizeof(char), strlen(buf), led->controlfd) )
+ return -2;
+
+ fflush(led->controlfd);
+ led->state=value;
+
+ return 0;
+}
+
+int init_led(struct led **led, char *ledname)
+{
+ struct led *newled;
+ struct stat statbuffer;
+ int status;
+ char *bp;
+ FILE *bfp;
+
+ bp = calloc(sizeof(char), strlen(ledname) + strlen(LEDS_BASEPATH) + 12);
+ if ( ! bp )
+ goto return_error;
+
+ sprintf(bp, "%s%s/brightness", LEDS_BASEPATH, ledname);
+
+ status = stat(bp, &statbuffer);
+ if ( status )
+ goto cleanup_fname;
+
+ bfp = fopen( bp, "w" );
+ if ( !bfp )
+ goto cleanup_fname;
+
+ if ( ferror(bfp) )
+ goto cleanup_fp;
+
+ /* sysfs path exists and, allocate LED struct */
+ newled = calloc(sizeof(struct led),1);
+ if ( !newled )
+ goto cleanup_fp;
+
+ newled->sysfspath = bp;
+ newled->controlfd = bfp;
+
+ *led = newled;
+
+ if ( set_led(newled, 255) )
+ goto cleanup_fp;
+
+ if ( set_led(newled, 0) )
+ goto cleanup_fp;
+
+ return 0;
+
+cleanup_fp:
+ fclose(bfp);
+cleanup_fname:
+ free(bp);
+return_error:
+ syslog(LOG_CRIT, "can't open LED %s\n", ledname);
+ *led = NULL;
+ return -1;
+}
+
+void close_led(struct led **led)
+{
+ fclose((*led)->controlfd);
+ free((*led)->sysfspath);
+ free((*led));
+ (*led)=NULL;
+}
+
+
+int quality(const struct iwinfo_ops *iw, const char *ifname)
+{
+ int qual;
+
+ if ( ! iw ) return -1;
+
+ if (qual_max < 1)
+ if (iw->quality_max(ifname, &qual_max))
+ return -1;
+
+ if (iw->quality(ifname, &qual))
+ return -1;
+
+ return ( qual * 100 ) / qual_max ;
+}
+
+int open_backend(const struct iwinfo_ops **iw, const char *ifname)
+{
+ *iw = iwinfo_backend(ifname);
+
+ if (!(*iw))
+ return 1;
+
+ return 0;
+}
+
+void update_leds(rule_t *rules, int q)
+{
+ rule_t *rule = rules;
+ while (rule)
+ {
+ int b;
+ /* offset and factore correction according to rule */
+ b = ( q + rule->boffset ) * rule->bfactor;
+ if ( b < 0 )
+ b=0;
+ if ( b > 255 )
+ b=255;
+
+ if ( q >= rule->minq && q <= rule->maxq )
+ set_led(rule->led, (unsigned char)b);
+ else
+ set_led(rule->led, 0);
+
+ rule = rule->next;
+ }
+}
+
+int main(int argc, char **argv)
+{
+ int i,q,q0,r,s;
+ const struct iwinfo_ops *iw = NULL;
+ rule_t *headrule = NULL, *currentrule = NULL;
+
+ if (argc < 9 || ( (argc-4) % 5 != 0 ) )
+ {
+ printf("syntax: %s (ifname) (refresh) (threshold) (rule) [rule] ...\n", argv[0]);
+ printf(" rule: (sysfs-name) (minq) (maxq) (offset) (factore)\n");
+ return 1;
+ }
+
+ ifname = argv[1];
+
+ /* refresh interval */
+ if ( sscanf(argv[2], "%d", &r) != 1 )
+ return 1;
+
+ /* sustain threshold */
+ if ( sscanf(argv[3], "%d", &s) != 1 )
+ return 1;
+
+ openlog("rssileds", LOG_PID, LOG_DAEMON);
+ syslog(LOG_INFO, "monitoring %s, refresh rate %d, threshold %d\n", ifname, r, s);
+
+ currentrule = headrule;
+ for (i=4; i<argc; i=i+5) {
+ if (! currentrule)
+ {
+ /* first element in the list */
+ currentrule = calloc(sizeof(rule_t),1);
+ headrule = currentrule;
+ }
+ else
+ {
+ /* follow-up element */
+ currentrule->next = calloc(sizeof(rule_t),1);
+ currentrule = currentrule->next;
+ }
+
+ if ( init_led(&(currentrule->led), argv[i]) )
+ return 1;
+
+ if ( sscanf(argv[i+1], "%d", &(currentrule->minq)) != 1 )
+ return 1;
+
+ if ( sscanf(argv[i+2], "%d", &(currentrule->maxq)) != 1 )
+ return 1;
+
+ if ( sscanf(argv[i+3], "%d", &(currentrule->boffset)) != 1 )
+ return 1;
+
+ if ( sscanf(argv[i+4], "%d", &(currentrule->bfactor)) != 1 )
+ return 1;
+ }
+ log_rules(headrule);
+
+ q0 = -1;
+ do {
+ q = quality(iw, ifname);
+ if ( q < q0 - s || q > q0 + s ) {
+ update_leds(headrule, q);
+ q0=q;
+ };
+ // re-open backend...
+ if ( q == -1 && q0 == -1 ) {
+ if (iw) {
+ iwinfo_finish();
+ iw=NULL;
+ usleep(BACKEND_RETRY_DELAY);
+ }
+ while (open_backend(&iw, ifname))
+ usleep(BACKEND_RETRY_DELAY);
+ }
+ usleep(r);
+ } while(1);
+
+ iwinfo_finish();
+
+ return 0;
+}
diff --git a/package/network/utils/tcpdump/.svn/entries b/package/network/utils/tcpdump/.svn/entries
new file mode 100644
index 0000000..7ad52f6
--- /dev/null
+++ b/package/network/utils/tcpdump/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/utils/tcpdump
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-22T07:51:15.696421Z
+35288
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+349d6f20057dffaec2230498e056f718
+2013-01-22T07:51:15.696421Z
+35288
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1961
+
diff --git a/package/network/utils/tcpdump/.svn/prop-base/Makefile.svn-base b/package/network/utils/tcpdump/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..f899379
--- /dev/null
+++ b/package/network/utils/tcpdump/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,13 @@
+K 9
+copyright
+V 30
+Copyright (C) 2006 OpenWrt.org
+K 7
+licence
+V 5
+GPLv2
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/utils/tcpdump/.svn/text-base/Makefile.svn-base b/package/network/utils/tcpdump/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..b32d25f
--- /dev/null
+++ b/package/network/utils/tcpdump/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,89 @@
+#
+# Copyright (C) 2007-2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=tcpdump
+PKG_VERSION:=4.2.1
+PKG_RELEASE:=3
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://www.tcpdump.org/release/ \
+ http://ftp.gwdg.de/pub/misc/tcpdump/ \
+ http://www.at.tcpdump.org/ \
+ http://www.br.tcpdump.org/
+PKG_MD5SUM:=c202878c6db054767b52651041b9e60e
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
+PKG_BUILD_PARALLEL:=1
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+
+PKG_INSTALL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/tcpdump/default
+ SECTION:=net
+ CATEGORY:=Network
+ DEPENDS:=+libpcap
+ TITLE:=Network monitoring and data acquisition tool
+ URL:=http://www.tcpdump.org/
+endef
+
+define Package/tcpdump
+ $(Package/tcpdump/default)
+ VARIANT:=full
+endef
+
+define Package/tcpdump-mini
+ $(Package/tcpdump/default)
+ TITLE+= (minimal version)
+ VARIANT:=mini
+endef
+
+CONFIGURE_ARGS += \
+ --without-crypto
+
+ifeq ($(CONFIG_IPV6),y)
+CONFIGURE_ARGS += \
+ --enable-ipv6
+endif
+
+TARGET_CFLAGS += -ffunction-sections -fdata-sections
+TARGET_LDFLAGS += -Wl,--gc-sections
+
+CONFIGURE_VARS += \
+ BUILD_CC="$(TARGET_CC)" \
+ HOSTCC="$(HOSTCC)" \
+ td_cv_buggygetaddrinfo="no" \
+ ac_cv_linux_vers=$(LINUX_VERSION) \
+ ac_cv_header_rpc_rpcent_h=no \
+ ac_cv_lib_rpc_main=no \
+ ac_cv_path_PCAP_CONFIG=""
+
+MAKE_FLAGS :=
+
+ifeq ($(BUILD_VARIANT),mini)
+ TARGET_CFLAGS += -DTCPDUMP_MINI
+ CONFIGURE_ARGS += --disable-smb
+ MAKE_FLAGS += TCPDUMP_MINI=1
+endif
+
+MAKE_FLAGS += \
+ CCOPT="$(TARGET_CFLAGS)" INCLS="-I. $(TARGET_CPPFLAGS)"
+
+
+define Package/tcpdump/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/tcpdump $(1)/usr/sbin/
+endef
+
+Package/tcpdump-mini/install = $(Package/tcpdump/install)
+
+$(eval $(call BuildPackage,tcpdump))
+$(eval $(call BuildPackage,tcpdump-mini))
diff --git a/package/network/utils/tcpdump/Makefile b/package/network/utils/tcpdump/Makefile
new file mode 100644
index 0000000..b32d25f
--- /dev/null
+++ b/package/network/utils/tcpdump/Makefile
@@ -0,0 +1,89 @@
+#
+# Copyright (C) 2007-2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=tcpdump
+PKG_VERSION:=4.2.1
+PKG_RELEASE:=3
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://www.tcpdump.org/release/ \
+ http://ftp.gwdg.de/pub/misc/tcpdump/ \
+ http://www.at.tcpdump.org/ \
+ http://www.br.tcpdump.org/
+PKG_MD5SUM:=c202878c6db054767b52651041b9e60e
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
+PKG_BUILD_PARALLEL:=1
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+
+PKG_INSTALL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/tcpdump/default
+ SECTION:=net
+ CATEGORY:=Network
+ DEPENDS:=+libpcap
+ TITLE:=Network monitoring and data acquisition tool
+ URL:=http://www.tcpdump.org/
+endef
+
+define Package/tcpdump
+ $(Package/tcpdump/default)
+ VARIANT:=full
+endef
+
+define Package/tcpdump-mini
+ $(Package/tcpdump/default)
+ TITLE+= (minimal version)
+ VARIANT:=mini
+endef
+
+CONFIGURE_ARGS += \
+ --without-crypto
+
+ifeq ($(CONFIG_IPV6),y)
+CONFIGURE_ARGS += \
+ --enable-ipv6
+endif
+
+TARGET_CFLAGS += -ffunction-sections -fdata-sections
+TARGET_LDFLAGS += -Wl,--gc-sections
+
+CONFIGURE_VARS += \
+ BUILD_CC="$(TARGET_CC)" \
+ HOSTCC="$(HOSTCC)" \
+ td_cv_buggygetaddrinfo="no" \
+ ac_cv_linux_vers=$(LINUX_VERSION) \
+ ac_cv_header_rpc_rpcent_h=no \
+ ac_cv_lib_rpc_main=no \
+ ac_cv_path_PCAP_CONFIG=""
+
+MAKE_FLAGS :=
+
+ifeq ($(BUILD_VARIANT),mini)
+ TARGET_CFLAGS += -DTCPDUMP_MINI
+ CONFIGURE_ARGS += --disable-smb
+ MAKE_FLAGS += TCPDUMP_MINI=1
+endif
+
+MAKE_FLAGS += \
+ CCOPT="$(TARGET_CFLAGS)" INCLS="-I. $(TARGET_CPPFLAGS)"
+
+
+define Package/tcpdump/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/tcpdump $(1)/usr/sbin/
+endef
+
+Package/tcpdump-mini/install = $(Package/tcpdump/install)
+
+$(eval $(call BuildPackage,tcpdump))
+$(eval $(call BuildPackage,tcpdump-mini))
diff --git a/package/network/utils/tcpdump/patches/.svn/entries b/package/network/utils/tcpdump/patches/.svn/entries
new file mode 100644
index 0000000..5d1bce8
--- /dev/null
+++ b/package/network/utils/tcpdump/patches/.svn/entries
@@ -0,0 +1,164 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/utils/tcpdump/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-22T07:51:15.696421Z
+35288
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+001-remove_pcap_debug.patch
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+705ea86506fe767fda8856d5a8c54e0f
+2012-02-16T11:58:29.282018Z
+30579
+juhosg
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+468
+
+100-tcpdump_mini.patch
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+1559eb29f3ec904b9893bdd433910d23
+2013-01-22T07:51:15.696421Z
+35288
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+20784
+
+004-fix_3g_iface.patch
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+52d52c866a2018a1e94fec62b639ec12
+2012-02-16T11:58:29.282018Z
+30579
+juhosg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+768
+
+002-remove_static_libpcap_check.patch
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+950b3c3606ce586885931d44d607013d
+2012-02-16T11:58:29.282018Z
+30579
+juhosg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2790
+
diff --git a/package/network/utils/tcpdump/patches/.svn/prop-base/001-remove_pcap_debug.patch.svn-base b/package/network/utils/tcpdump/patches/.svn/prop-base/001-remove_pcap_debug.patch.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/network/utils/tcpdump/patches/.svn/prop-base/001-remove_pcap_debug.patch.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/utils/tcpdump/patches/.svn/text-base/001-remove_pcap_debug.patch.svn-base b/package/network/utils/tcpdump/patches/.svn/text-base/001-remove_pcap_debug.patch.svn-base
new file mode 100644
index 0000000..14d1b84
--- /dev/null
+++ b/package/network/utils/tcpdump/patches/.svn/text-base/001-remove_pcap_debug.patch.svn-base
@@ -0,0 +1,23 @@
+--- a/tcpdump.c
++++ b/tcpdump.c
+@@ -982,20 +982,6 @@ main(int argc, char **argv)
+ error("invalid data link type %s", gndo->ndo_dltname);
+ break;
+
+-#if defined(HAVE_PCAP_DEBUG) || defined(HAVE_YYDEBUG)
+- case 'Y':
+- {
+- /* Undocumented flag */
+-#ifdef HAVE_PCAP_DEBUG
+- extern int pcap_debug;
+- pcap_debug = 1;
+-#else
+- extern int yydebug;
+- yydebug = 1;
+-#endif
+- }
+- break;
+-#endif
+ case 'z':
+ if (optarg) {
+ zflag = strdup(optarg);
diff --git a/package/network/utils/tcpdump/patches/.svn/text-base/002-remove_static_libpcap_check.patch.svn-base b/package/network/utils/tcpdump/patches/.svn/text-base/002-remove_static_libpcap_check.patch.svn-base
new file mode 100644
index 0000000..8ab54aa
--- /dev/null
+++ b/package/network/utils/tcpdump/patches/.svn/text-base/002-remove_static_libpcap_check.patch.svn-base
@@ -0,0 +1,77 @@
+--- a/configure
++++ b/configure
+@@ -7130,28 +7130,6 @@ echo "${ECHO_T}Using $pfopen" >&6; }
+ LIBS="$LIBS $pfopen"
+ fi
+ fi
+- { echo "$as_me:$LINENO: checking for local pcap library" >&5
+-echo $ECHO_N "checking for local pcap library... $ECHO_C" >&6; }
+- libpcap=FAIL
+- lastdir=FAIL
+- places=`ls $srcdir/.. | sed -e 's,/$,,' -e "s,^,$srcdir/../," | \
+- egrep '/libpcap-[0-9]+\.[0-9]+(\.[0-9]*)?([ab][0-9]*|-PRE-GIT)?$'`
+- for dir in $places $srcdir/../libpcap $srcdir/libpcap ; do
+- basedir=`echo $dir | sed -e 's/[ab][0-9]*$//' | \
+- sed -e 's/-PRE-GIT$//' `
+- if test $lastdir = $basedir ; then
+- continue;
+- fi
+- lastdir=$dir
+- if test -r $dir/libpcap.a ; then
+- libpcap=$dir/libpcap.a
+- d=$dir
+- fi
+- done
+- if test $libpcap = FAIL ; then
+- { echo "$as_me:$LINENO: result: not found" >&5
+-echo "${ECHO_T}not found" >&6; }
+-
+ #
+ # Look for pcap-config.
+ #
+@@ -7335,45 +7313,6 @@ if test $ac_cv_lib_pcap_main = yes; then
+ libpcap="-lpcap"
+ fi
+
+- if test $libpcap = FAIL ; then
+- { { echo "$as_me:$LINENO: error: see the INSTALL doc for more info" >&5
+-echo "$as_me: error: see the INSTALL doc for more info" >&2;}
+- { (exit 1); exit 1; }; }
+- fi
+- { echo "$as_me:$LINENO: checking for extraneous pcap header directories" >&5
+-echo $ECHO_N "checking for extraneous pcap header directories... $ECHO_C" >&6; }
+- if test \( ! -r /usr/local/include/pcap.h \) -a \
+- \( ! -r /usr/include/pcap.h \); then
+- if test -r /usr/local/include/pcap/pcap.h; then
+- d="/usr/local/include/pcap"
+- elif test -r /usr/include/pcap/pcap.h; then
+- d="/usr/include/pcap"
+- fi
+- fi
+- if test -z "$d" ; then
+- { echo "$as_me:$LINENO: result: not found" >&5
+-echo "${ECHO_T}not found" >&6; }
+- else
+- V_INCLS="-I$d $V_INCLS"
+- { echo "$as_me:$LINENO: result: found -- -I$d added" >&5
+-echo "${ECHO_T}found -- -I$d added" >&6; }
+- fi
+- fi
+- else
+- V_PCAPDEP=$libpcap
+- places=`ls $srcdir/.. | sed -e 's,/$,,' -e "s,^,$srcdir/../," | \
+- egrep '/libpcap-[0-9]*.[0-9]*(.[0-9]*)?([ab][0-9]*)?$'`
+- if test -r $d/pcap.h; then
+- V_INCLS="-I$d $V_INCLS"
+- elif test -r $places/pcap.h; then
+- V_INCLS="-I$places $V_INCLS"
+- else
+- { { echo "$as_me:$LINENO: error: cannot find pcap.h" >&5
+-echo "$as_me: error: cannot find pcap.h" >&2;}
+- { (exit see INSTALL); exit see INSTALL; }; }
+- fi
+- { echo "$as_me:$LINENO: result: $libpcap" >&5
+-echo "${ECHO_T}$libpcap" >&6; }
+ # Extract the first word of "pcap-config", so it can be a program name with args.
+ set dummy pcap-config; ac_word=$2
+ { echo "$as_me:$LINENO: checking for $ac_word" >&5
diff --git a/package/network/utils/tcpdump/patches/.svn/text-base/004-fix_3g_iface.patch.svn-base b/package/network/utils/tcpdump/patches/.svn/text-base/004-fix_3g_iface.patch.svn-base
new file mode 100644
index 0000000..35d105f
--- /dev/null
+++ b/package/network/utils/tcpdump/patches/.svn/text-base/004-fix_3g_iface.patch.svn-base
@@ -0,0 +1,28 @@
+--- a/tcpdump.c
++++ b/tcpdump.c
+@@ -66,6 +66,7 @@ extern int SIZE_BUF;
+ #include <stdlib.h>
+ #include <string.h>
+ #include <limits.h>
++#include <ctype.h>
+ #ifndef WIN32
+ #include <sys/wait.h>
+ #include <sys/resource.h>
+@@ -625,6 +626,7 @@ main(int argc, char **argv)
+ #ifdef HAVE_PCAP_FINDALLDEVS
+ pcap_if_t *devpointer;
+ int devnum;
++ char *devp;
+ #endif
+ int status;
+ #ifdef WIN32
+@@ -775,7 +777,8 @@ main(int argc, char **argv)
+ * It can be useful on Windows, where more than
+ * one interface can have the same name.
+ */
+- if ((devnum = atoi(optarg)) != 0) {
++ for (devp = optarg; *devp && isdigit(*devp); devp++);
++ if ((!*devp || isspace(*devp)) && (devnum = atoi(optarg)) != 0) {
+ if (devnum < 0)
+ error("Invalid adapter index");
+
diff --git a/package/network/utils/tcpdump/patches/.svn/text-base/100-tcpdump_mini.patch.svn-base b/package/network/utils/tcpdump/patches/.svn/text-base/100-tcpdump_mini.patch.svn-base
new file mode 100644
index 0000000..1d114b6
--- /dev/null
+++ b/package/network/utils/tcpdump/patches/.svn/text-base/100-tcpdump_mini.patch.svn-base
@@ -0,0 +1,763 @@
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -68,6 +68,22 @@ RANLIB = @RANLIB@
+ @rm -f $@
+ $(CC) $(FULL_CFLAGS) -c $(srcdir)/$*.c
+
++ifdef TCPDUMP_MINI
++
++CSRC = addrtoname.c af.c checksum.c cpack.c gmpls.c oui.c gmt2local.c ipproto.c \
++ nlpid.c l2vpn.c machdep.c parsenfsfh.c in_cksum.c \
++ print-802_11.c print-aodv.c print-arp.c print-ascii.c \
++ print-bgp.c print-bootp.c print-cdp.c print-domain.c print-eap.c print-ether.c \
++ print-gre.c print-icmp.c print-igmp.c print-ip.c \
++ print-l2tp.c print-lldp.c print-llc.c \
++ print-nfs.c print-ntp.c print-null.c print-olsr.c print-ospf.c \
++ print-ppp.c print-pppoe.c print-pptp.c print-radius.c print-raw.c print-rsvp.c \
++ print-sctp.c print-sip.c print-sll.c print-snmp.c print-stp.c print-sunrpc.c \
++ print-syslog.c print-tcp.c print-telnet.c print-tftp.c print-udp.c \
++ setsignal.c tcpdump.c util.c signature.c print-ipnet.c print-forces.c
++
++else
++
+ CSRC = addrtoname.c af.c checksum.c cpack.c gmpls.c oui.c gmt2local.c ipproto.c \
+ nlpid.c l2vpn.c machdep.c parsenfsfh.c in_cksum.c \
+ print-802_11.c print-802_15_4.c print-ap1394.c print-ah.c \
+@@ -99,6 +115,8 @@ LIBNETDISSECT_SRC=print-isakmp.c
+ LIBNETDISSECT_OBJ=$(LIBNETDISSECT_SRC:.c=.o)
+ LIBNETDISSECT=libnetdissect.a
+
++endif
++
+ LOCALSRC = @LOCALSRC@
+ GENSRC = version.c
+ LIBOBJS = @LIBOBJS@
+@@ -361,10 +379,12 @@ $(PROG): $(OBJ) @V_PCAPDEP@
+ @rm -f $@
+ $(CC) $(FULL_CFLAGS) $(LDFLAGS) -o $@ $(OBJ) $(LIBS)
+
++ifndef TCPDUMP_MINI
+ $(LIBNETDISSECT): $(LIBNETDISSECT_OBJ)
+ @rm -f $@
+ $(AR) cr $@ $(LIBNETDISSECT_OBJ)
+ $(RANLIB) $@
++endif
+
+ datalinks.o: $(srcdir)/missing/datalinks.c
+ $(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/datalinks.c
+--- a/addrtoname.c
++++ b/addrtoname.c
+@@ -547,10 +547,10 @@ linkaddr_string(const u_char *ep, const
+
+ if (type == LINKADDR_ETHER && len == ETHER_ADDR_LEN)
+ return (etheraddr_string(ep));
+-
++#ifndef TCPDUMP_MINI
+ if (type == LINKADDR_FRELAY)
+ return (q922_string(ep));
+-
++#endif
+ tp = lookup_bytestring(ep, len);
+ if (tp->e_name)
+ return (tp->e_name);
+@@ -1150,6 +1150,7 @@ init_addrtoname(u_int32_t localnet, u_in
+ init_ipxsaparray();
+ }
+
++#ifndef TCPDUMP_MINI
+ const char *
+ dnaddr_string(u_short dnaddr)
+ {
+@@ -1169,6 +1170,7 @@ dnaddr_string(u_short dnaddr)
+
+ return(tp->name);
+ }
++#endif
+
+ /* Return a zero'ed hnamemem struct and cuts down on calloc() overhead */
+ struct hnamemem *
+--- a/print-ether.c
++++ b/print-ether.c
+@@ -338,6 +338,7 @@ ethertype_print(netdissect_options *ndo,
+ arp_print(ndo, p, length, caplen);
+ return (1);
+
++#ifndef TCPDUMP_MINI
+ case ETHERTYPE_DN:
+ decnet_print(/*ndo,*/p, length, caplen);
+ return (1);
+@@ -356,10 +357,13 @@ ethertype_print(netdissect_options *ndo,
+ ND_PRINT((ndo, "(NOV-ETHII) "));
+ ipx_print(/*ndo,*/p, length);
+ return (1);
++#endif
+
++#ifndef TCPDUMP_MINI
+ case ETHERTYPE_ISO:
+ isoclns_print(/*ndo,*/p+1, length-1, length-1);
+ return(1);
++#endif
+
+ case ETHERTYPE_PPPOED:
+ case ETHERTYPE_PPPOES:
+@@ -372,9 +376,11 @@ ethertype_print(netdissect_options *ndo,
+ eap_print(ndo, p, length);
+ return (1);
+
++#ifndef TCPDUMP_MINI
+ case ETHERTYPE_RRCP:
+ rrcp_print(ndo, p - 14 , length + 14);
+ return (1);
++#endif
+
+ case ETHERTYPE_PPP:
+ if (length) {
+@@ -383,6 +389,7 @@ ethertype_print(netdissect_options *ndo,
+ }
+ return (1);
+
++#ifndef TCPDUMP_MINI
+ case ETHERTYPE_MPCP:
+ mpcp_print(/*ndo,*/p, length);
+ return (1);
+@@ -395,7 +402,7 @@ ethertype_print(netdissect_options *ndo,
+ case ETHERTYPE_CFM_OLD:
+ cfm_print(/*ndo,*/p, length);
+ return (1);
+-
++#endif
+ case ETHERTYPE_LLDP:
+ lldp_print(/*ndo,*/p, length);
+ return (1);
+@@ -403,10 +410,12 @@ ethertype_print(netdissect_options *ndo,
+ case ETHERTYPE_LOOPBACK:
+ return (1);
+
++#ifndef TCPDUMP_MINI
+ case ETHERTYPE_MPLS:
+ case ETHERTYPE_MPLS_MULTI:
+ mpls_print(/*ndo,*/p, length);
+ return (1);
++#endif
+
+ case ETHERTYPE_LAT:
+ case ETHERTYPE_SCA:
+--- a/print-gre.c
++++ b/print-gre.c
+@@ -213,6 +213,7 @@ gre_print_0(const u_char *bp, u_int leng
+ ip6_print(gndo, bp, len);
+ break;
+ #endif
++#ifndef TCPDUMP_MINI
+ case ETHERTYPE_MPLS:
+ mpls_print(bp, len);
+ break;
+@@ -228,6 +229,7 @@ gre_print_0(const u_char *bp, u_int leng
+ case ETHERTYPE_TEB:
+ ether_print(gndo, bp, len, len, NULL, NULL);
+ break;
++#endif
+ default:
+ printf("gre-proto-0x%x", prot);
+ }
+--- a/print-igmp.c
++++ b/print-igmp.c
+@@ -305,6 +305,7 @@ igmp_print(register const u_char *bp, re
+ TCHECK2(bp[4], 4);
+ (void)printf("igmp leave %s", ipaddr_string(&bp[4]));
+ break;
++#ifndef TCPDUMP_MINI
+ case 0x13:
+ (void)printf("igmp dvmrp");
+ if (len < 8)
+@@ -316,6 +317,7 @@ igmp_print(register const u_char *bp, re
+ (void)printf("igmp pimv1");
+ pimv1_print(bp, len);
+ break;
++#endif
+ case 0x1e:
+ print_mresp(bp, len);
+ break;
+--- a/print-ip.c
++++ b/print-ip.c
+@@ -328,6 +328,7 @@ ip_print_demux(netdissect_options *ndo,
+ again:
+ switch (ipds->nh) {
+
++#ifndef TCPDUMP_MINI
+ case IPPROTO_AH:
+ ipds->nh = *ipds->cp;
+ ipds->advance = ah_print(ipds->cp);
+@@ -362,14 +363,16 @@ again:
+ ipds->nh = enh & 0xff;
+ goto again;
+ }
+-
++#endif
+ case IPPROTO_SCTP:
+ sctp_print(ipds->cp, (const u_char *)ipds->ip, ipds->len);
+ break;
+
++#ifndef TCPDUMP_MINI
+ case IPPROTO_DCCP:
+ dccp_print(ipds->cp, (const u_char *)ipds->ip, ipds->len);
+ break;
++#endif
+
+ case IPPROTO_TCP:
+ /* pass on the MF bit plus the offset to detect fragments */
+@@ -389,6 +392,7 @@ again:
+ ipds->off & (IP_MF|IP_OFFMASK));
+ break;
+
++#ifndef TCPDUMP_MINI
+ case IPPROTO_PIGP:
+ /*
+ * XXX - the current IANA protocol number assignments
+@@ -409,15 +413,16 @@ again:
+ case IPPROTO_EIGRP:
+ eigrp_print(ipds->cp, ipds->len);
+ break;
+-
++#endif
+ case IPPROTO_ND:
+ ND_PRINT((ndo, " nd %d", ipds->len));
+ break;
+
++#ifndef TCPDUMP_MINI
+ case IPPROTO_EGP:
+ egp_print(ipds->cp, ipds->len);
+ break;
+-
++#endif
+ case IPPROTO_OSPF:
+ ospf_print(ipds->cp, ipds->len, (const u_char *)ipds->ip);
+ break;
+@@ -451,10 +456,10 @@ again:
+ gre_print(ipds->cp, ipds->len);
+ break;
+
++#ifndef TCPDUMP_MINI
+ case IPPROTO_MOBILE:
+ mobile_print(ipds->cp, ipds->len);
+ break;
+-
+ case IPPROTO_PIM:
+ vec[0].ptr = ipds->cp;
+ vec[0].len = ipds->len;
+@@ -480,7 +485,7 @@ again:
+ case IPPROTO_PGM:
+ pgm_print(ipds->cp, ipds->len, (const u_char *)ipds->ip);
+ break;
+-
++#endif
+ default:
+ if ((proto = getprotobynumber(ipds->nh)) != NULL)
+ ND_PRINT((ndo, " %s", proto->p_name));
+--- a/print-ip6.c
++++ b/print-ip6.c
+@@ -192,9 +192,11 @@ ip6_print(netdissect_options *ndo, const
+ case IPPROTO_SCTP:
+ sctp_print(cp, (const u_char *)ip6, len);
+ return;
++#ifndef TCPDUMP_MINI
+ case IPPROTO_DCCP:
+ dccp_print(cp, (const u_char *)ip6, len);
+ return;
++#endif
+ case IPPROTO_TCP:
+ tcp_print(cp, len, (const u_char *)ip6, fragmented);
+ return;
+@@ -204,6 +206,7 @@ ip6_print(netdissect_options *ndo, const
+ case IPPROTO_ICMPV6:
+ icmp6_print(ndo, cp, len, (const u_char *)ip6, fragmented);
+ return;
++#ifndef TCPDUMP_MINI
+ case IPPROTO_AH:
+ advance = ah_print(cp);
+ nh = *cp;
+@@ -228,7 +231,7 @@ ip6_print(netdissect_options *ndo, const
+ pim_print(cp, len, nextproto6_cksum(ip6, cp, len,
+ IPPROTO_PIM));
+ return;
+-
++#endif
+ case IPPROTO_OSPF:
+ ospf6_print(cp, len);
+ return;
+@@ -240,11 +243,11 @@ ip6_print(netdissect_options *ndo, const
+ case IPPROTO_IPV4:
+ ip_print(ndo, cp, len);
+ return;
+-
++#ifndef TCPDUMP_MINI
+ case IPPROTO_PGM:
+ pgm_print(cp, len, (const u_char *)ip6);
+ return;
+-
++#endif
+ case IPPROTO_GRE:
+ gre_print(cp, len);
+ return;
+--- a/print-llc.c
++++ b/print-llc.c
+@@ -195,7 +195,7 @@ llc_print(const u_char *p, u_int length,
+ control = EXTRACT_LE_16BITS(p + 2);
+ is_u = 0;
+ }
+-
++#ifndef TCPDUMP_MINI
+ if (ssap_field == LLCSAP_GLOBAL && dsap_field == LLCSAP_GLOBAL) {
+ /*
+ * This is an Ethernet_802.3 IPX frame; it has an
+@@ -218,6 +218,7 @@ llc_print(const u_char *p, u_int length,
+ ipx_print(p, length);
+ return (1);
+ }
++#endif
+
+ dsap = dsap_field & ~LLC_IG;
+ ssap = ssap_field & ~LLC_GSAP;
+@@ -250,6 +251,7 @@ llc_print(const u_char *p, u_int length,
+ return (1);
+ }
+
++#ifndef TCPDUMP_MINI
+ if (ssap == LLCSAP_IPX && dsap == LLCSAP_IPX &&
+ control == LLC_UI) {
+ /*
+@@ -265,6 +267,7 @@ llc_print(const u_char *p, u_int length,
+ ipx_print(p+3, length-3);
+ return (1);
+ }
++#endif
+
+ #ifdef TCPDUMP_DO_SMB
+ if (ssap == LLCSAP_NETBEUI && dsap == LLCSAP_NETBEUI
+@@ -296,11 +299,13 @@ llc_print(const u_char *p, u_int length,
+ return (1);
+ }
+ #endif
++#ifndef TCPDUMP_MINI
+ if (ssap == LLCSAP_ISONS && dsap == LLCSAP_ISONS
+ && control == LLC_UI) {
+ isoclns_print(p + 3, length - 3, caplen - 3);
+ return (1);
+ }
++#endif
+
+ if (ssap == LLCSAP_SNAP && dsap == LLCSAP_SNAP
+ && control == LLC_UI) {
+@@ -443,6 +448,7 @@ snap_print(const u_char *p, u_int length
+ case PID_CISCO_CDP:
+ cdp_print(p, length, caplen);
+ return (1);
++#ifndef TCPDUMP_MINI
+ case PID_CISCO_DTP:
+ dtp_print(p, length);
+ return (1);
+@@ -452,6 +458,7 @@ snap_print(const u_char *p, u_int length
+ case PID_CISCO_VTP:
+ vtp_print(p, length);
+ return (1);
++#endif
+ case PID_CISCO_PVST:
+ stp_print(p, length);
+ return (1);
+@@ -482,6 +489,7 @@ snap_print(const u_char *p, u_int length
+ ether_print(gndo, p, length, caplen, NULL, NULL);
+ return (1);
+
++#ifndef TCPDUMP_MINI
+ case PID_RFC2684_802_5_FCS:
+ case PID_RFC2684_802_5_NOFCS:
+ /*
+@@ -523,6 +531,7 @@ snap_print(const u_char *p, u_int length
+ */
+ fddi_print(p, length, caplen);
+ return (1);
++#endif
+
+ case PID_RFC2684_BPDU:
+ stp_print(p, length);
+--- a/print-null.c
++++ b/print-null.c
+@@ -128,7 +128,7 @@ null_if_print(const struct pcap_pkthdr *
+ ip6_print(gndo, p, length);
+ break;
+ #endif
+-
++#ifndef TCPDUMP_MINI
+ case BSD_AFNUM_ISO:
+ isoclns_print(p, length, caplen);
+ break;
+@@ -140,7 +140,7 @@ null_if_print(const struct pcap_pkthdr *
+ case BSD_AFNUM_IPX:
+ ipx_print(p, length);
+ break;
+-
++#endif
+ default:
+ /* unknown AF_ value */
+ if (!eflag)
+--- a/print-ppp.c
++++ b/print-ppp.c
+@@ -1262,7 +1262,7 @@ trunc:
+ return 0;
+ }
+
+-
++#ifndef TCPDUMP_MINI
+ static void
+ ppp_hdlc(const u_char *p, int length)
+ {
+@@ -1327,17 +1327,19 @@ cleanup:
+ free(b);
+ return;
+ }
++#endif
+
+
+ /* PPP */
+ static void
+ handle_ppp(u_int proto, const u_char *p, int length)
+ {
++#ifndef TCPDUMP_MINI
+ if ((proto & 0xff00) == 0x7e00) {/* is this an escape code ? */
+ ppp_hdlc(p-1, length);
+ return;
+ }
+-
++#endif
+ switch (proto) {
+ case PPP_LCP: /* fall through */
+ case PPP_IPCP:
+@@ -1371,6 +1373,7 @@ handle_ppp(u_int proto, const u_char *p,
+ ip6_print(gndo, p, length);
+ break;
+ #endif
++#ifndef TCPDUMP_MINI
+ case ETHERTYPE_IPX: /*XXX*/
+ case PPP_IPX:
+ ipx_print(p, length);
+@@ -1382,6 +1385,7 @@ handle_ppp(u_int proto, const u_char *p,
+ case PPP_MPLS_MCAST:
+ mpls_print(p, length);
+ break;
++#endif
+ case PPP_COMP:
+ printf("compressed PPP data");
+ break;
+@@ -1520,6 +1524,7 @@ ppp_if_print(const struct pcap_pkthdr *h
+ return (0);
+ }
+
++#ifndef TCPDUMP_MINI
+ /*
+ * PPP I/F printer to use if we know that RFC 1662-style PPP in HDLC-like
+ * framing, or Cisco PPP with HDLC framing as per section 4.3.1 of RFC 1547,
+@@ -1747,7 +1752,7 @@ printx:
+ #endif /* __bsdi__ */
+ return (hdrlength);
+ }
+-
++#endif
+
+ /*
+ * Local Variables:
+--- a/print-tcp.c
++++ b/print-tcp.c
+@@ -652,8 +652,10 @@ tcp_print(register const u_char *bp, reg
+ else if (sport == SMB_PORT || dport == SMB_PORT)
+ smb_tcp_print(bp, length);
+ #endif
++#ifndef TCPDUMP_MINI
+ else if (sport == BEEP_PORT || dport == BEEP_PORT)
+ beep_print(bp, length);
++#endif
+ else if (length > 2 &&
+ (sport == NAMESERVER_PORT || dport == NAMESERVER_PORT ||
+ sport == MULTICASTDNS_PORT || dport == MULTICASTDNS_PORT)) {
+@@ -662,6 +664,7 @@ tcp_print(register const u_char *bp, reg
+ * XXX packet could be unaligned, it can go strange
+ */
+ ns_print(bp + 2, length - 2, 0);
++#ifndef TCPDUMP_MINI
+ } else if (sport == MSDP_PORT || dport == MSDP_PORT) {
+ msdp_print(bp, length);
+ } else if (sport == RPKI_RTR_PORT || dport == RPKI_RTR_PORT) {
+@@ -669,6 +672,7 @@ tcp_print(register const u_char *bp, reg
+ }
+ else if (length > 0 && (sport == LDP_PORT || dport == LDP_PORT)) {
+ ldp_print(bp, length);
++#endif
+ }
+
+ return;
+--- a/print-udp.c
++++ b/print-udp.c
+@@ -418,11 +418,12 @@ udp_print(register const u_char *bp, u_i
+ vat_print((void *)(up + 1), up);
+ break;
+
++#ifndef TCPDUMP_MINI
+ case PT_WB:
+ udpipaddr_print(ip, sport, dport);
+ wb_print((void *)(up + 1), length);
+ break;
+-
++#endif
+ case PT_RPC:
+ rp = (struct sunrpc_msg *)(up + 1);
+ direction = (enum sunrpc_msg_type)EXTRACT_32BITS(&rp->rm_direction);
+@@ -450,11 +451,12 @@ udp_print(register const u_char *bp, u_i
+ snmp_print((const u_char *)(up + 1), length);
+ break;
+
++#ifndef TCPDUMP_MINI
+ case PT_CNFP:
+ udpipaddr_print(ip, sport, dport);
+ cnfp_print(cp, (const u_char *)ip);
+ break;
+-
++#endif
+ case PT_TFTP:
+ udpipaddr_print(ip, sport, dport);
+ tftp_print(cp, length);
+@@ -497,6 +499,7 @@ udp_print(register const u_char *bp, u_i
+ }
+ #endif
+ }
++#ifndef TCPDUMP_MINI
+ if (TTEST(((struct LAP *)cp)->type) &&
+ ((struct LAP *)cp)->type == lapDDP &&
+ (atalk_port(sport) || atalk_port(dport))) {
+@@ -505,6 +508,7 @@ udp_print(register const u_char *bp, u_i
+ llap_print(cp, length);
+ return;
+ }
++#endif
+ }
+ udpipaddr_print(ip, sport, dport);
+
+@@ -555,14 +559,18 @@ udp_print(register const u_char *bp, u_i
+ ns_print((const u_char *)(up + 1), length, 0);
+ else if (ISPORT(MULTICASTDNS_PORT))
+ ns_print((const u_char *)(up + 1), length, 1);
++#ifndef TCPDUMP_MINI
+ else if (ISPORT(TIMED_PORT))
+ timed_print((const u_char *)(up + 1));
++#endif
+ else if (ISPORT(TFTP_PORT))
+ tftp_print((const u_char *)(up + 1), length);
+ else if (ISPORT(IPPORT_BOOTPC) || ISPORT(IPPORT_BOOTPS))
+ bootp_print((const u_char *)(up + 1), length);
++#ifndef TCPDUMP_MINI
+ else if (ISPORT(RIP_PORT))
+ rip_print((const u_char *)(up + 1), length);
++#endif
+ else if (ISPORT(AODV_PORT))
+ aodv_print((const u_char *)(up + 1), length,
+ #ifdef INET6
+@@ -570,6 +578,7 @@ udp_print(register const u_char *bp, u_i
+ #else
+ 0);
+ #endif
++#ifndef TCPDUMP_MINI
+ else if (ISPORT(ISAKMP_PORT))
+ isakmp_print(gndo, (const u_char *)(up + 1), length, bp2);
+ else if (ISPORT(ISAKMP_PORT_NATT))
+@@ -578,12 +587,15 @@ udp_print(register const u_char *bp, u_i
+ else if (ISPORT(ISAKMP_PORT_USER1) || ISPORT(ISAKMP_PORT_USER2))
+ isakmp_print(gndo, (const u_char *)(up + 1), length, bp2);
+ #endif
++#endif
+ else if (ISPORT(SNMP_PORT) || ISPORT(SNMPTRAP_PORT))
+ snmp_print((const u_char *)(up + 1), length);
+ else if (ISPORT(NTP_PORT))
+ ntp_print((const u_char *)(up + 1), length);
++#ifndef TCPDUMP_MINI
+ else if (ISPORT(KERBEROS_PORT) || ISPORT(KERBEROS_SEC_PORT))
+ krb_print((const void *)(up + 1));
++#endif
+ else if (ISPORT(L2TP_PORT))
+ l2tp_print((const u_char *)(up + 1), length);
+ #ifdef TCPDUMP_DO_SMB
+@@ -594,6 +606,7 @@ udp_print(register const u_char *bp, u_i
+ #endif
+ else if (dport == 3456)
+ vat_print((const void *)(up + 1), up);
++#ifndef TCPDUMP_MINI
+ else if (ISPORT(ZEPHYR_SRV_PORT) || ISPORT(ZEPHYR_CLT_PORT))
+ zephyr_print((const void *)(up + 1), length);
+ /*
+@@ -604,6 +617,7 @@ udp_print(register const u_char *bp, u_i
+ (dport >= RX_PORT_LOW && dport <= RX_PORT_HIGH))
+ rx_print((const void *)(up + 1), length, sport, dport,
+ (u_char *) ip);
++#endif
+ #ifdef INET6
+ else if (ISPORT(RIPNG_PORT))
+ ripng_print((const u_char *)(up + 1), length);
+@@ -615,21 +629,25 @@ udp_print(register const u_char *bp, u_i
+ /*
+ * Kludge in test for whiteboard packets.
+ */
++#ifndef TCPDUMP_MINI
+ else if (dport == 4567)
+ wb_print((const void *)(up + 1), length);
+ else if (ISPORT(CISCO_AUTORP_PORT))
+ cisco_autorp_print((const void *)(up + 1), length);
++#endif
+ else if (ISPORT(RADIUS_PORT) ||
+ ISPORT(RADIUS_NEW_PORT) ||
+ ISPORT(RADIUS_ACCOUNTING_PORT) ||
+ ISPORT(RADIUS_NEW_ACCOUNTING_PORT) )
+ radius_print((const u_char *)(up+1), length);
++#ifndef TCPDUMP_MINI
+ else if (dport == HSRP_PORT)
+ hsrp_print((const u_char *)(up + 1), length);
+ else if (ISPORT(LWRES_PORT))
+ lwres_print((const u_char *)(up + 1), length);
+ else if (ISPORT(LDP_PORT))
+ ldp_print((const u_char *)(up + 1), length);
++#endif
+ else if (ISPORT(OLSR_PORT))
+ olsr_print((const u_char *)(up + 1), length,
+ #if INET6
+@@ -637,6 +655,7 @@ udp_print(register const u_char *bp, u_i
+ #else
+ 0);
+ #endif
++#ifndef TCPDUMP_MINI
+ else if (ISPORT(MPLS_LSP_PING_PORT))
+ lspping_print((const u_char *)(up + 1), length);
+ else if (dport == BFD_CONTROL_PORT ||
+@@ -654,6 +673,7 @@ udp_print(register const u_char *bp, u_i
+ lwapp_control_print((const u_char *)(up + 1), length, 0);
+ else if (ISPORT(LWAPP_DATA_PORT))
+ lwapp_data_print((const u_char *)(up + 1), length);
++#endif
+ else if (ISPORT(SIP_PORT))
+ sip_print((const u_char *)(up + 1), length);
+ else if (ISPORT(SYSLOG_PORT))
+--- a/tcpdump.c
++++ b/tcpdump.c
+@@ -148,6 +148,7 @@ struct ndo_printer {
+
+
+ static struct printer printers[] = {
++#ifndef TCPDUMP_MINI
+ { arcnet_if_print, DLT_ARCNET },
+ #ifdef DLT_ARCNET_LINUX
+ { arcnet_linux_if_print, DLT_ARCNET_LINUX },
+@@ -166,19 +167,23 @@ static struct printer printers[] = {
+ #ifdef DLT_SLIP_BSDOS
+ { sl_bsdos_if_print, DLT_SLIP_BSDOS },
+ #endif
++#endif
+ { ppp_if_print, DLT_PPP },
+ #ifdef DLT_PPP_WITHDIRECTION
+ { ppp_if_print, DLT_PPP_WITHDIRECTION },
+ #endif
++#ifndef TCPDUMP_MINI
+ #ifdef DLT_PPP_BSDOS
+ { ppp_bsdos_if_print, DLT_PPP_BSDOS },
+ #endif
+ { fddi_if_print, DLT_FDDI },
++#endif
+ { null_if_print, DLT_NULL },
+ #ifdef DLT_LOOP
+ { null_if_print, DLT_LOOP },
+ #endif
+ { raw_if_print, DLT_RAW },
++#ifndef TCPDUMP_MINI
+ { atm_if_print, DLT_ATM_RFC1483 },
+ #ifdef DLT_C_HDLC
+ { chdlc_if_print, DLT_C_HDLC },
+@@ -189,6 +194,7 @@ static struct printer printers[] = {
+ #ifdef DLT_PPP_SERIAL
+ { ppp_hdlc_if_print, DLT_PPP_SERIAL },
+ #endif
++#endif
+ #ifdef DLT_PPP_ETHER
+ { pppoe_if_print, DLT_PPP_ETHER },
+ #endif
+@@ -198,6 +204,7 @@ static struct printer printers[] = {
+ #ifdef DLT_IEEE802_11
+ { ieee802_11_if_print, DLT_IEEE802_11},
+ #endif
++#ifndef TCPDUMP_MINI
+ #ifdef DLT_LTALK
+ { ltalk_if_print, DLT_LTALK },
+ #endif
+@@ -216,12 +223,14 @@ static struct printer printers[] = {
+ #ifdef DLT_IP_OVER_FC
+ { ipfc_if_print, DLT_IP_OVER_FC },
+ #endif
++#endif
+ #ifdef DLT_PRISM_HEADER
+ { prism_if_print, DLT_PRISM_HEADER },
+ #endif
+ #ifdef DLT_IEEE802_11_RADIO
+ { ieee802_11_radio_if_print, DLT_IEEE802_11_RADIO },
+ #endif
++#ifndef TCPDUMP_MINI
+ #ifdef DLT_ENC
+ { enc_if_print, DLT_ENC },
+ #endif
+@@ -231,9 +240,11 @@ static struct printer printers[] = {
+ #ifdef DLT_APPLE_IP_OVER_IEEE1394
+ { ap1394_if_print, DLT_APPLE_IP_OVER_IEEE1394 },
+ #endif
++#endif
+ #ifdef DLT_IEEE802_11_RADIO_AVS
+ { ieee802_11_radio_avs_if_print, DLT_IEEE802_11_RADIO_AVS },
+ #endif
++#ifndef TCPDUMP_MINI
+ #ifdef DLT_JUNIPER_ATM1
+ { juniper_atm1_print, DLT_JUNIPER_ATM1 },
+ #endif
+@@ -299,6 +310,7 @@ static struct printer printers[] = {
+ #ifdef DLT_IPV6
+ { raw_if_print, DLT_IPV6 },
+ #endif
++#endif
+ { NULL, 0 },
+ };
+
+@@ -307,6 +319,7 @@ static struct ndo_printer ndo_printers[]
+ #ifdef DLT_IPNET
+ { ipnet_if_print, DLT_IPNET },
+ #endif
++#ifndef TCPDUMP_MINI
+ #ifdef DLT_IEEE802_15_4
+ { ieee802_15_4_if_print, DLT_IEEE802_15_4 },
+ #endif
+@@ -316,6 +329,7 @@ static struct ndo_printer ndo_printers[]
+ #ifdef DLT_PPI
+ { ppi_if_print, DLT_PPI },
+ #endif
++#endif
+ #ifdef DLT_NETANALYZER
+ { netanalyzer_if_print, DLT_NETANALYZER },
+ #endif
+--- a/print-sll.c
++++ b/print-sll.c
+@@ -154,14 +154,14 @@ recurse:
+ * Yes - what type is it?
+ */
+ switch (ether_type) {
+-
++#ifndef TCPDUMP_MINI
+ case LINUX_SLL_P_802_3:
+ /*
+ * Ethernet_802.3 IPX frame.
+ */
+ ipx_print(p, length);
+ break;
+-
++#endif
+ case LINUX_SLL_P_802_2:
+ /*
+ * 802.2.
diff --git a/package/network/utils/tcpdump/patches/001-remove_pcap_debug.patch b/package/network/utils/tcpdump/patches/001-remove_pcap_debug.patch
new file mode 100644
index 0000000..14d1b84
--- /dev/null
+++ b/package/network/utils/tcpdump/patches/001-remove_pcap_debug.patch
@@ -0,0 +1,23 @@
+--- a/tcpdump.c
++++ b/tcpdump.c
+@@ -982,20 +982,6 @@ main(int argc, char **argv)
+ error("invalid data link type %s", gndo->ndo_dltname);
+ break;
+
+-#if defined(HAVE_PCAP_DEBUG) || defined(HAVE_YYDEBUG)
+- case 'Y':
+- {
+- /* Undocumented flag */
+-#ifdef HAVE_PCAP_DEBUG
+- extern int pcap_debug;
+- pcap_debug = 1;
+-#else
+- extern int yydebug;
+- yydebug = 1;
+-#endif
+- }
+- break;
+-#endif
+ case 'z':
+ if (optarg) {
+ zflag = strdup(optarg);
diff --git a/package/network/utils/tcpdump/patches/002-remove_static_libpcap_check.patch b/package/network/utils/tcpdump/patches/002-remove_static_libpcap_check.patch
new file mode 100644
index 0000000..8ab54aa
--- /dev/null
+++ b/package/network/utils/tcpdump/patches/002-remove_static_libpcap_check.patch
@@ -0,0 +1,77 @@
+--- a/configure
++++ b/configure
+@@ -7130,28 +7130,6 @@ echo "${ECHO_T}Using $pfopen" >&6; }
+ LIBS="$LIBS $pfopen"
+ fi
+ fi
+- { echo "$as_me:$LINENO: checking for local pcap library" >&5
+-echo $ECHO_N "checking for local pcap library... $ECHO_C" >&6; }
+- libpcap=FAIL
+- lastdir=FAIL
+- places=`ls $srcdir/.. | sed -e 's,/$,,' -e "s,^,$srcdir/../," | \
+- egrep '/libpcap-[0-9]+\.[0-9]+(\.[0-9]*)?([ab][0-9]*|-PRE-GIT)?$'`
+- for dir in $places $srcdir/../libpcap $srcdir/libpcap ; do
+- basedir=`echo $dir | sed -e 's/[ab][0-9]*$//' | \
+- sed -e 's/-PRE-GIT$//' `
+- if test $lastdir = $basedir ; then
+- continue;
+- fi
+- lastdir=$dir
+- if test -r $dir/libpcap.a ; then
+- libpcap=$dir/libpcap.a
+- d=$dir
+- fi
+- done
+- if test $libpcap = FAIL ; then
+- { echo "$as_me:$LINENO: result: not found" >&5
+-echo "${ECHO_T}not found" >&6; }
+-
+ #
+ # Look for pcap-config.
+ #
+@@ -7335,45 +7313,6 @@ if test $ac_cv_lib_pcap_main = yes; then
+ libpcap="-lpcap"
+ fi
+
+- if test $libpcap = FAIL ; then
+- { { echo "$as_me:$LINENO: error: see the INSTALL doc for more info" >&5
+-echo "$as_me: error: see the INSTALL doc for more info" >&2;}
+- { (exit 1); exit 1; }; }
+- fi
+- { echo "$as_me:$LINENO: checking for extraneous pcap header directories" >&5
+-echo $ECHO_N "checking for extraneous pcap header directories... $ECHO_C" >&6; }
+- if test \( ! -r /usr/local/include/pcap.h \) -a \
+- \( ! -r /usr/include/pcap.h \); then
+- if test -r /usr/local/include/pcap/pcap.h; then
+- d="/usr/local/include/pcap"
+- elif test -r /usr/include/pcap/pcap.h; then
+- d="/usr/include/pcap"
+- fi
+- fi
+- if test -z "$d" ; then
+- { echo "$as_me:$LINENO: result: not found" >&5
+-echo "${ECHO_T}not found" >&6; }
+- else
+- V_INCLS="-I$d $V_INCLS"
+- { echo "$as_me:$LINENO: result: found -- -I$d added" >&5
+-echo "${ECHO_T}found -- -I$d added" >&6; }
+- fi
+- fi
+- else
+- V_PCAPDEP=$libpcap
+- places=`ls $srcdir/.. | sed -e 's,/$,,' -e "s,^,$srcdir/../," | \
+- egrep '/libpcap-[0-9]*.[0-9]*(.[0-9]*)?([ab][0-9]*)?$'`
+- if test -r $d/pcap.h; then
+- V_INCLS="-I$d $V_INCLS"
+- elif test -r $places/pcap.h; then
+- V_INCLS="-I$places $V_INCLS"
+- else
+- { { echo "$as_me:$LINENO: error: cannot find pcap.h" >&5
+-echo "$as_me: error: cannot find pcap.h" >&2;}
+- { (exit see INSTALL); exit see INSTALL; }; }
+- fi
+- { echo "$as_me:$LINENO: result: $libpcap" >&5
+-echo "${ECHO_T}$libpcap" >&6; }
+ # Extract the first word of "pcap-config", so it can be a program name with args.
+ set dummy pcap-config; ac_word=$2
+ { echo "$as_me:$LINENO: checking for $ac_word" >&5
diff --git a/package/network/utils/tcpdump/patches/004-fix_3g_iface.patch b/package/network/utils/tcpdump/patches/004-fix_3g_iface.patch
new file mode 100644
index 0000000..35d105f
--- /dev/null
+++ b/package/network/utils/tcpdump/patches/004-fix_3g_iface.patch
@@ -0,0 +1,28 @@
+--- a/tcpdump.c
++++ b/tcpdump.c
+@@ -66,6 +66,7 @@ extern int SIZE_BUF;
+ #include <stdlib.h>
+ #include <string.h>
+ #include <limits.h>
++#include <ctype.h>
+ #ifndef WIN32
+ #include <sys/wait.h>
+ #include <sys/resource.h>
+@@ -625,6 +626,7 @@ main(int argc, char **argv)
+ #ifdef HAVE_PCAP_FINDALLDEVS
+ pcap_if_t *devpointer;
+ int devnum;
++ char *devp;
+ #endif
+ int status;
+ #ifdef WIN32
+@@ -775,7 +777,8 @@ main(int argc, char **argv)
+ * It can be useful on Windows, where more than
+ * one interface can have the same name.
+ */
+- if ((devnum = atoi(optarg)) != 0) {
++ for (devp = optarg; *devp && isdigit(*devp); devp++);
++ if ((!*devp || isspace(*devp)) && (devnum = atoi(optarg)) != 0) {
+ if (devnum < 0)
+ error("Invalid adapter index");
+
diff --git a/package/network/utils/tcpdump/patches/100-tcpdump_mini.patch b/package/network/utils/tcpdump/patches/100-tcpdump_mini.patch
new file mode 100644
index 0000000..1d114b6
--- /dev/null
+++ b/package/network/utils/tcpdump/patches/100-tcpdump_mini.patch
@@ -0,0 +1,763 @@
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -68,6 +68,22 @@ RANLIB = @RANLIB@
+ @rm -f $@
+ $(CC) $(FULL_CFLAGS) -c $(srcdir)/$*.c
+
++ifdef TCPDUMP_MINI
++
++CSRC = addrtoname.c af.c checksum.c cpack.c gmpls.c oui.c gmt2local.c ipproto.c \
++ nlpid.c l2vpn.c machdep.c parsenfsfh.c in_cksum.c \
++ print-802_11.c print-aodv.c print-arp.c print-ascii.c \
++ print-bgp.c print-bootp.c print-cdp.c print-domain.c print-eap.c print-ether.c \
++ print-gre.c print-icmp.c print-igmp.c print-ip.c \
++ print-l2tp.c print-lldp.c print-llc.c \
++ print-nfs.c print-ntp.c print-null.c print-olsr.c print-ospf.c \
++ print-ppp.c print-pppoe.c print-pptp.c print-radius.c print-raw.c print-rsvp.c \
++ print-sctp.c print-sip.c print-sll.c print-snmp.c print-stp.c print-sunrpc.c \
++ print-syslog.c print-tcp.c print-telnet.c print-tftp.c print-udp.c \
++ setsignal.c tcpdump.c util.c signature.c print-ipnet.c print-forces.c
++
++else
++
+ CSRC = addrtoname.c af.c checksum.c cpack.c gmpls.c oui.c gmt2local.c ipproto.c \
+ nlpid.c l2vpn.c machdep.c parsenfsfh.c in_cksum.c \
+ print-802_11.c print-802_15_4.c print-ap1394.c print-ah.c \
+@@ -99,6 +115,8 @@ LIBNETDISSECT_SRC=print-isakmp.c
+ LIBNETDISSECT_OBJ=$(LIBNETDISSECT_SRC:.c=.o)
+ LIBNETDISSECT=libnetdissect.a
+
++endif
++
+ LOCALSRC = @LOCALSRC@
+ GENSRC = version.c
+ LIBOBJS = @LIBOBJS@
+@@ -361,10 +379,12 @@ $(PROG): $(OBJ) @V_PCAPDEP@
+ @rm -f $@
+ $(CC) $(FULL_CFLAGS) $(LDFLAGS) -o $@ $(OBJ) $(LIBS)
+
++ifndef TCPDUMP_MINI
+ $(LIBNETDISSECT): $(LIBNETDISSECT_OBJ)
+ @rm -f $@
+ $(AR) cr $@ $(LIBNETDISSECT_OBJ)
+ $(RANLIB) $@
++endif
+
+ datalinks.o: $(srcdir)/missing/datalinks.c
+ $(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/datalinks.c
+--- a/addrtoname.c
++++ b/addrtoname.c
+@@ -547,10 +547,10 @@ linkaddr_string(const u_char *ep, const
+
+ if (type == LINKADDR_ETHER && len == ETHER_ADDR_LEN)
+ return (etheraddr_string(ep));
+-
++#ifndef TCPDUMP_MINI
+ if (type == LINKADDR_FRELAY)
+ return (q922_string(ep));
+-
++#endif
+ tp = lookup_bytestring(ep, len);
+ if (tp->e_name)
+ return (tp->e_name);
+@@ -1150,6 +1150,7 @@ init_addrtoname(u_int32_t localnet, u_in
+ init_ipxsaparray();
+ }
+
++#ifndef TCPDUMP_MINI
+ const char *
+ dnaddr_string(u_short dnaddr)
+ {
+@@ -1169,6 +1170,7 @@ dnaddr_string(u_short dnaddr)
+
+ return(tp->name);
+ }
++#endif
+
+ /* Return a zero'ed hnamemem struct and cuts down on calloc() overhead */
+ struct hnamemem *
+--- a/print-ether.c
++++ b/print-ether.c
+@@ -338,6 +338,7 @@ ethertype_print(netdissect_options *ndo,
+ arp_print(ndo, p, length, caplen);
+ return (1);
+
++#ifndef TCPDUMP_MINI
+ case ETHERTYPE_DN:
+ decnet_print(/*ndo,*/p, length, caplen);
+ return (1);
+@@ -356,10 +357,13 @@ ethertype_print(netdissect_options *ndo,
+ ND_PRINT((ndo, "(NOV-ETHII) "));
+ ipx_print(/*ndo,*/p, length);
+ return (1);
++#endif
+
++#ifndef TCPDUMP_MINI
+ case ETHERTYPE_ISO:
+ isoclns_print(/*ndo,*/p+1, length-1, length-1);
+ return(1);
++#endif
+
+ case ETHERTYPE_PPPOED:
+ case ETHERTYPE_PPPOES:
+@@ -372,9 +376,11 @@ ethertype_print(netdissect_options *ndo,
+ eap_print(ndo, p, length);
+ return (1);
+
++#ifndef TCPDUMP_MINI
+ case ETHERTYPE_RRCP:
+ rrcp_print(ndo, p - 14 , length + 14);
+ return (1);
++#endif
+
+ case ETHERTYPE_PPP:
+ if (length) {
+@@ -383,6 +389,7 @@ ethertype_print(netdissect_options *ndo,
+ }
+ return (1);
+
++#ifndef TCPDUMP_MINI
+ case ETHERTYPE_MPCP:
+ mpcp_print(/*ndo,*/p, length);
+ return (1);
+@@ -395,7 +402,7 @@ ethertype_print(netdissect_options *ndo,
+ case ETHERTYPE_CFM_OLD:
+ cfm_print(/*ndo,*/p, length);
+ return (1);
+-
++#endif
+ case ETHERTYPE_LLDP:
+ lldp_print(/*ndo,*/p, length);
+ return (1);
+@@ -403,10 +410,12 @@ ethertype_print(netdissect_options *ndo,
+ case ETHERTYPE_LOOPBACK:
+ return (1);
+
++#ifndef TCPDUMP_MINI
+ case ETHERTYPE_MPLS:
+ case ETHERTYPE_MPLS_MULTI:
+ mpls_print(/*ndo,*/p, length);
+ return (1);
++#endif
+
+ case ETHERTYPE_LAT:
+ case ETHERTYPE_SCA:
+--- a/print-gre.c
++++ b/print-gre.c
+@@ -213,6 +213,7 @@ gre_print_0(const u_char *bp, u_int leng
+ ip6_print(gndo, bp, len);
+ break;
+ #endif
++#ifndef TCPDUMP_MINI
+ case ETHERTYPE_MPLS:
+ mpls_print(bp, len);
+ break;
+@@ -228,6 +229,7 @@ gre_print_0(const u_char *bp, u_int leng
+ case ETHERTYPE_TEB:
+ ether_print(gndo, bp, len, len, NULL, NULL);
+ break;
++#endif
+ default:
+ printf("gre-proto-0x%x", prot);
+ }
+--- a/print-igmp.c
++++ b/print-igmp.c
+@@ -305,6 +305,7 @@ igmp_print(register const u_char *bp, re
+ TCHECK2(bp[4], 4);
+ (void)printf("igmp leave %s", ipaddr_string(&bp[4]));
+ break;
++#ifndef TCPDUMP_MINI
+ case 0x13:
+ (void)printf("igmp dvmrp");
+ if (len < 8)
+@@ -316,6 +317,7 @@ igmp_print(register const u_char *bp, re
+ (void)printf("igmp pimv1");
+ pimv1_print(bp, len);
+ break;
++#endif
+ case 0x1e:
+ print_mresp(bp, len);
+ break;
+--- a/print-ip.c
++++ b/print-ip.c
+@@ -328,6 +328,7 @@ ip_print_demux(netdissect_options *ndo,
+ again:
+ switch (ipds->nh) {
+
++#ifndef TCPDUMP_MINI
+ case IPPROTO_AH:
+ ipds->nh = *ipds->cp;
+ ipds->advance = ah_print(ipds->cp);
+@@ -362,14 +363,16 @@ again:
+ ipds->nh = enh & 0xff;
+ goto again;
+ }
+-
++#endif
+ case IPPROTO_SCTP:
+ sctp_print(ipds->cp, (const u_char *)ipds->ip, ipds->len);
+ break;
+
++#ifndef TCPDUMP_MINI
+ case IPPROTO_DCCP:
+ dccp_print(ipds->cp, (const u_char *)ipds->ip, ipds->len);
+ break;
++#endif
+
+ case IPPROTO_TCP:
+ /* pass on the MF bit plus the offset to detect fragments */
+@@ -389,6 +392,7 @@ again:
+ ipds->off & (IP_MF|IP_OFFMASK));
+ break;
+
++#ifndef TCPDUMP_MINI
+ case IPPROTO_PIGP:
+ /*
+ * XXX - the current IANA protocol number assignments
+@@ -409,15 +413,16 @@ again:
+ case IPPROTO_EIGRP:
+ eigrp_print(ipds->cp, ipds->len);
+ break;
+-
++#endif
+ case IPPROTO_ND:
+ ND_PRINT((ndo, " nd %d", ipds->len));
+ break;
+
++#ifndef TCPDUMP_MINI
+ case IPPROTO_EGP:
+ egp_print(ipds->cp, ipds->len);
+ break;
+-
++#endif
+ case IPPROTO_OSPF:
+ ospf_print(ipds->cp, ipds->len, (const u_char *)ipds->ip);
+ break;
+@@ -451,10 +456,10 @@ again:
+ gre_print(ipds->cp, ipds->len);
+ break;
+
++#ifndef TCPDUMP_MINI
+ case IPPROTO_MOBILE:
+ mobile_print(ipds->cp, ipds->len);
+ break;
+-
+ case IPPROTO_PIM:
+ vec[0].ptr = ipds->cp;
+ vec[0].len = ipds->len;
+@@ -480,7 +485,7 @@ again:
+ case IPPROTO_PGM:
+ pgm_print(ipds->cp, ipds->len, (const u_char *)ipds->ip);
+ break;
+-
++#endif
+ default:
+ if ((proto = getprotobynumber(ipds->nh)) != NULL)
+ ND_PRINT((ndo, " %s", proto->p_name));
+--- a/print-ip6.c
++++ b/print-ip6.c
+@@ -192,9 +192,11 @@ ip6_print(netdissect_options *ndo, const
+ case IPPROTO_SCTP:
+ sctp_print(cp, (const u_char *)ip6, len);
+ return;
++#ifndef TCPDUMP_MINI
+ case IPPROTO_DCCP:
+ dccp_print(cp, (const u_char *)ip6, len);
+ return;
++#endif
+ case IPPROTO_TCP:
+ tcp_print(cp, len, (const u_char *)ip6, fragmented);
+ return;
+@@ -204,6 +206,7 @@ ip6_print(netdissect_options *ndo, const
+ case IPPROTO_ICMPV6:
+ icmp6_print(ndo, cp, len, (const u_char *)ip6, fragmented);
+ return;
++#ifndef TCPDUMP_MINI
+ case IPPROTO_AH:
+ advance = ah_print(cp);
+ nh = *cp;
+@@ -228,7 +231,7 @@ ip6_print(netdissect_options *ndo, const
+ pim_print(cp, len, nextproto6_cksum(ip6, cp, len,
+ IPPROTO_PIM));
+ return;
+-
++#endif
+ case IPPROTO_OSPF:
+ ospf6_print(cp, len);
+ return;
+@@ -240,11 +243,11 @@ ip6_print(netdissect_options *ndo, const
+ case IPPROTO_IPV4:
+ ip_print(ndo, cp, len);
+ return;
+-
++#ifndef TCPDUMP_MINI
+ case IPPROTO_PGM:
+ pgm_print(cp, len, (const u_char *)ip6);
+ return;
+-
++#endif
+ case IPPROTO_GRE:
+ gre_print(cp, len);
+ return;
+--- a/print-llc.c
++++ b/print-llc.c
+@@ -195,7 +195,7 @@ llc_print(const u_char *p, u_int length,
+ control = EXTRACT_LE_16BITS(p + 2);
+ is_u = 0;
+ }
+-
++#ifndef TCPDUMP_MINI
+ if (ssap_field == LLCSAP_GLOBAL && dsap_field == LLCSAP_GLOBAL) {
+ /*
+ * This is an Ethernet_802.3 IPX frame; it has an
+@@ -218,6 +218,7 @@ llc_print(const u_char *p, u_int length,
+ ipx_print(p, length);
+ return (1);
+ }
++#endif
+
+ dsap = dsap_field & ~LLC_IG;
+ ssap = ssap_field & ~LLC_GSAP;
+@@ -250,6 +251,7 @@ llc_print(const u_char *p, u_int length,
+ return (1);
+ }
+
++#ifndef TCPDUMP_MINI
+ if (ssap == LLCSAP_IPX && dsap == LLCSAP_IPX &&
+ control == LLC_UI) {
+ /*
+@@ -265,6 +267,7 @@ llc_print(const u_char *p, u_int length,
+ ipx_print(p+3, length-3);
+ return (1);
+ }
++#endif
+
+ #ifdef TCPDUMP_DO_SMB
+ if (ssap == LLCSAP_NETBEUI && dsap == LLCSAP_NETBEUI
+@@ -296,11 +299,13 @@ llc_print(const u_char *p, u_int length,
+ return (1);
+ }
+ #endif
++#ifndef TCPDUMP_MINI
+ if (ssap == LLCSAP_ISONS && dsap == LLCSAP_ISONS
+ && control == LLC_UI) {
+ isoclns_print(p + 3, length - 3, caplen - 3);
+ return (1);
+ }
++#endif
+
+ if (ssap == LLCSAP_SNAP && dsap == LLCSAP_SNAP
+ && control == LLC_UI) {
+@@ -443,6 +448,7 @@ snap_print(const u_char *p, u_int length
+ case PID_CISCO_CDP:
+ cdp_print(p, length, caplen);
+ return (1);
++#ifndef TCPDUMP_MINI
+ case PID_CISCO_DTP:
+ dtp_print(p, length);
+ return (1);
+@@ -452,6 +458,7 @@ snap_print(const u_char *p, u_int length
+ case PID_CISCO_VTP:
+ vtp_print(p, length);
+ return (1);
++#endif
+ case PID_CISCO_PVST:
+ stp_print(p, length);
+ return (1);
+@@ -482,6 +489,7 @@ snap_print(const u_char *p, u_int length
+ ether_print(gndo, p, length, caplen, NULL, NULL);
+ return (1);
+
++#ifndef TCPDUMP_MINI
+ case PID_RFC2684_802_5_FCS:
+ case PID_RFC2684_802_5_NOFCS:
+ /*
+@@ -523,6 +531,7 @@ snap_print(const u_char *p, u_int length
+ */
+ fddi_print(p, length, caplen);
+ return (1);
++#endif
+
+ case PID_RFC2684_BPDU:
+ stp_print(p, length);
+--- a/print-null.c
++++ b/print-null.c
+@@ -128,7 +128,7 @@ null_if_print(const struct pcap_pkthdr *
+ ip6_print(gndo, p, length);
+ break;
+ #endif
+-
++#ifndef TCPDUMP_MINI
+ case BSD_AFNUM_ISO:
+ isoclns_print(p, length, caplen);
+ break;
+@@ -140,7 +140,7 @@ null_if_print(const struct pcap_pkthdr *
+ case BSD_AFNUM_IPX:
+ ipx_print(p, length);
+ break;
+-
++#endif
+ default:
+ /* unknown AF_ value */
+ if (!eflag)
+--- a/print-ppp.c
++++ b/print-ppp.c
+@@ -1262,7 +1262,7 @@ trunc:
+ return 0;
+ }
+
+-
++#ifndef TCPDUMP_MINI
+ static void
+ ppp_hdlc(const u_char *p, int length)
+ {
+@@ -1327,17 +1327,19 @@ cleanup:
+ free(b);
+ return;
+ }
++#endif
+
+
+ /* PPP */
+ static void
+ handle_ppp(u_int proto, const u_char *p, int length)
+ {
++#ifndef TCPDUMP_MINI
+ if ((proto & 0xff00) == 0x7e00) {/* is this an escape code ? */
+ ppp_hdlc(p-1, length);
+ return;
+ }
+-
++#endif
+ switch (proto) {
+ case PPP_LCP: /* fall through */
+ case PPP_IPCP:
+@@ -1371,6 +1373,7 @@ handle_ppp(u_int proto, const u_char *p,
+ ip6_print(gndo, p, length);
+ break;
+ #endif
++#ifndef TCPDUMP_MINI
+ case ETHERTYPE_IPX: /*XXX*/
+ case PPP_IPX:
+ ipx_print(p, length);
+@@ -1382,6 +1385,7 @@ handle_ppp(u_int proto, const u_char *p,
+ case PPP_MPLS_MCAST:
+ mpls_print(p, length);
+ break;
++#endif
+ case PPP_COMP:
+ printf("compressed PPP data");
+ break;
+@@ -1520,6 +1524,7 @@ ppp_if_print(const struct pcap_pkthdr *h
+ return (0);
+ }
+
++#ifndef TCPDUMP_MINI
+ /*
+ * PPP I/F printer to use if we know that RFC 1662-style PPP in HDLC-like
+ * framing, or Cisco PPP with HDLC framing as per section 4.3.1 of RFC 1547,
+@@ -1747,7 +1752,7 @@ printx:
+ #endif /* __bsdi__ */
+ return (hdrlength);
+ }
+-
++#endif
+
+ /*
+ * Local Variables:
+--- a/print-tcp.c
++++ b/print-tcp.c
+@@ -652,8 +652,10 @@ tcp_print(register const u_char *bp, reg
+ else if (sport == SMB_PORT || dport == SMB_PORT)
+ smb_tcp_print(bp, length);
+ #endif
++#ifndef TCPDUMP_MINI
+ else if (sport == BEEP_PORT || dport == BEEP_PORT)
+ beep_print(bp, length);
++#endif
+ else if (length > 2 &&
+ (sport == NAMESERVER_PORT || dport == NAMESERVER_PORT ||
+ sport == MULTICASTDNS_PORT || dport == MULTICASTDNS_PORT)) {
+@@ -662,6 +664,7 @@ tcp_print(register const u_char *bp, reg
+ * XXX packet could be unaligned, it can go strange
+ */
+ ns_print(bp + 2, length - 2, 0);
++#ifndef TCPDUMP_MINI
+ } else if (sport == MSDP_PORT || dport == MSDP_PORT) {
+ msdp_print(bp, length);
+ } else if (sport == RPKI_RTR_PORT || dport == RPKI_RTR_PORT) {
+@@ -669,6 +672,7 @@ tcp_print(register const u_char *bp, reg
+ }
+ else if (length > 0 && (sport == LDP_PORT || dport == LDP_PORT)) {
+ ldp_print(bp, length);
++#endif
+ }
+
+ return;
+--- a/print-udp.c
++++ b/print-udp.c
+@@ -418,11 +418,12 @@ udp_print(register const u_char *bp, u_i
+ vat_print((void *)(up + 1), up);
+ break;
+
++#ifndef TCPDUMP_MINI
+ case PT_WB:
+ udpipaddr_print(ip, sport, dport);
+ wb_print((void *)(up + 1), length);
+ break;
+-
++#endif
+ case PT_RPC:
+ rp = (struct sunrpc_msg *)(up + 1);
+ direction = (enum sunrpc_msg_type)EXTRACT_32BITS(&rp->rm_direction);
+@@ -450,11 +451,12 @@ udp_print(register const u_char *bp, u_i
+ snmp_print((const u_char *)(up + 1), length);
+ break;
+
++#ifndef TCPDUMP_MINI
+ case PT_CNFP:
+ udpipaddr_print(ip, sport, dport);
+ cnfp_print(cp, (const u_char *)ip);
+ break;
+-
++#endif
+ case PT_TFTP:
+ udpipaddr_print(ip, sport, dport);
+ tftp_print(cp, length);
+@@ -497,6 +499,7 @@ udp_print(register const u_char *bp, u_i
+ }
+ #endif
+ }
++#ifndef TCPDUMP_MINI
+ if (TTEST(((struct LAP *)cp)->type) &&
+ ((struct LAP *)cp)->type == lapDDP &&
+ (atalk_port(sport) || atalk_port(dport))) {
+@@ -505,6 +508,7 @@ udp_print(register const u_char *bp, u_i
+ llap_print(cp, length);
+ return;
+ }
++#endif
+ }
+ udpipaddr_print(ip, sport, dport);
+
+@@ -555,14 +559,18 @@ udp_print(register const u_char *bp, u_i
+ ns_print((const u_char *)(up + 1), length, 0);
+ else if (ISPORT(MULTICASTDNS_PORT))
+ ns_print((const u_char *)(up + 1), length, 1);
++#ifndef TCPDUMP_MINI
+ else if (ISPORT(TIMED_PORT))
+ timed_print((const u_char *)(up + 1));
++#endif
+ else if (ISPORT(TFTP_PORT))
+ tftp_print((const u_char *)(up + 1), length);
+ else if (ISPORT(IPPORT_BOOTPC) || ISPORT(IPPORT_BOOTPS))
+ bootp_print((const u_char *)(up + 1), length);
++#ifndef TCPDUMP_MINI
+ else if (ISPORT(RIP_PORT))
+ rip_print((const u_char *)(up + 1), length);
++#endif
+ else if (ISPORT(AODV_PORT))
+ aodv_print((const u_char *)(up + 1), length,
+ #ifdef INET6
+@@ -570,6 +578,7 @@ udp_print(register const u_char *bp, u_i
+ #else
+ 0);
+ #endif
++#ifndef TCPDUMP_MINI
+ else if (ISPORT(ISAKMP_PORT))
+ isakmp_print(gndo, (const u_char *)(up + 1), length, bp2);
+ else if (ISPORT(ISAKMP_PORT_NATT))
+@@ -578,12 +587,15 @@ udp_print(register const u_char *bp, u_i
+ else if (ISPORT(ISAKMP_PORT_USER1) || ISPORT(ISAKMP_PORT_USER2))
+ isakmp_print(gndo, (const u_char *)(up + 1), length, bp2);
+ #endif
++#endif
+ else if (ISPORT(SNMP_PORT) || ISPORT(SNMPTRAP_PORT))
+ snmp_print((const u_char *)(up + 1), length);
+ else if (ISPORT(NTP_PORT))
+ ntp_print((const u_char *)(up + 1), length);
++#ifndef TCPDUMP_MINI
+ else if (ISPORT(KERBEROS_PORT) || ISPORT(KERBEROS_SEC_PORT))
+ krb_print((const void *)(up + 1));
++#endif
+ else if (ISPORT(L2TP_PORT))
+ l2tp_print((const u_char *)(up + 1), length);
+ #ifdef TCPDUMP_DO_SMB
+@@ -594,6 +606,7 @@ udp_print(register const u_char *bp, u_i
+ #endif
+ else if (dport == 3456)
+ vat_print((const void *)(up + 1), up);
++#ifndef TCPDUMP_MINI
+ else if (ISPORT(ZEPHYR_SRV_PORT) || ISPORT(ZEPHYR_CLT_PORT))
+ zephyr_print((const void *)(up + 1), length);
+ /*
+@@ -604,6 +617,7 @@ udp_print(register const u_char *bp, u_i
+ (dport >= RX_PORT_LOW && dport <= RX_PORT_HIGH))
+ rx_print((const void *)(up + 1), length, sport, dport,
+ (u_char *) ip);
++#endif
+ #ifdef INET6
+ else if (ISPORT(RIPNG_PORT))
+ ripng_print((const u_char *)(up + 1), length);
+@@ -615,21 +629,25 @@ udp_print(register const u_char *bp, u_i
+ /*
+ * Kludge in test for whiteboard packets.
+ */
++#ifndef TCPDUMP_MINI
+ else if (dport == 4567)
+ wb_print((const void *)(up + 1), length);
+ else if (ISPORT(CISCO_AUTORP_PORT))
+ cisco_autorp_print((const void *)(up + 1), length);
++#endif
+ else if (ISPORT(RADIUS_PORT) ||
+ ISPORT(RADIUS_NEW_PORT) ||
+ ISPORT(RADIUS_ACCOUNTING_PORT) ||
+ ISPORT(RADIUS_NEW_ACCOUNTING_PORT) )
+ radius_print((const u_char *)(up+1), length);
++#ifndef TCPDUMP_MINI
+ else if (dport == HSRP_PORT)
+ hsrp_print((const u_char *)(up + 1), length);
+ else if (ISPORT(LWRES_PORT))
+ lwres_print((const u_char *)(up + 1), length);
+ else if (ISPORT(LDP_PORT))
+ ldp_print((const u_char *)(up + 1), length);
++#endif
+ else if (ISPORT(OLSR_PORT))
+ olsr_print((const u_char *)(up + 1), length,
+ #if INET6
+@@ -637,6 +655,7 @@ udp_print(register const u_char *bp, u_i
+ #else
+ 0);
+ #endif
++#ifndef TCPDUMP_MINI
+ else if (ISPORT(MPLS_LSP_PING_PORT))
+ lspping_print((const u_char *)(up + 1), length);
+ else if (dport == BFD_CONTROL_PORT ||
+@@ -654,6 +673,7 @@ udp_print(register const u_char *bp, u_i
+ lwapp_control_print((const u_char *)(up + 1), length, 0);
+ else if (ISPORT(LWAPP_DATA_PORT))
+ lwapp_data_print((const u_char *)(up + 1), length);
++#endif
+ else if (ISPORT(SIP_PORT))
+ sip_print((const u_char *)(up + 1), length);
+ else if (ISPORT(SYSLOG_PORT))
+--- a/tcpdump.c
++++ b/tcpdump.c
+@@ -148,6 +148,7 @@ struct ndo_printer {
+
+
+ static struct printer printers[] = {
++#ifndef TCPDUMP_MINI
+ { arcnet_if_print, DLT_ARCNET },
+ #ifdef DLT_ARCNET_LINUX
+ { arcnet_linux_if_print, DLT_ARCNET_LINUX },
+@@ -166,19 +167,23 @@ static struct printer printers[] = {
+ #ifdef DLT_SLIP_BSDOS
+ { sl_bsdos_if_print, DLT_SLIP_BSDOS },
+ #endif
++#endif
+ { ppp_if_print, DLT_PPP },
+ #ifdef DLT_PPP_WITHDIRECTION
+ { ppp_if_print, DLT_PPP_WITHDIRECTION },
+ #endif
++#ifndef TCPDUMP_MINI
+ #ifdef DLT_PPP_BSDOS
+ { ppp_bsdos_if_print, DLT_PPP_BSDOS },
+ #endif
+ { fddi_if_print, DLT_FDDI },
++#endif
+ { null_if_print, DLT_NULL },
+ #ifdef DLT_LOOP
+ { null_if_print, DLT_LOOP },
+ #endif
+ { raw_if_print, DLT_RAW },
++#ifndef TCPDUMP_MINI
+ { atm_if_print, DLT_ATM_RFC1483 },
+ #ifdef DLT_C_HDLC
+ { chdlc_if_print, DLT_C_HDLC },
+@@ -189,6 +194,7 @@ static struct printer printers[] = {
+ #ifdef DLT_PPP_SERIAL
+ { ppp_hdlc_if_print, DLT_PPP_SERIAL },
+ #endif
++#endif
+ #ifdef DLT_PPP_ETHER
+ { pppoe_if_print, DLT_PPP_ETHER },
+ #endif
+@@ -198,6 +204,7 @@ static struct printer printers[] = {
+ #ifdef DLT_IEEE802_11
+ { ieee802_11_if_print, DLT_IEEE802_11},
+ #endif
++#ifndef TCPDUMP_MINI
+ #ifdef DLT_LTALK
+ { ltalk_if_print, DLT_LTALK },
+ #endif
+@@ -216,12 +223,14 @@ static struct printer printers[] = {
+ #ifdef DLT_IP_OVER_FC
+ { ipfc_if_print, DLT_IP_OVER_FC },
+ #endif
++#endif
+ #ifdef DLT_PRISM_HEADER
+ { prism_if_print, DLT_PRISM_HEADER },
+ #endif
+ #ifdef DLT_IEEE802_11_RADIO
+ { ieee802_11_radio_if_print, DLT_IEEE802_11_RADIO },
+ #endif
++#ifndef TCPDUMP_MINI
+ #ifdef DLT_ENC
+ { enc_if_print, DLT_ENC },
+ #endif
+@@ -231,9 +240,11 @@ static struct printer printers[] = {
+ #ifdef DLT_APPLE_IP_OVER_IEEE1394
+ { ap1394_if_print, DLT_APPLE_IP_OVER_IEEE1394 },
+ #endif
++#endif
+ #ifdef DLT_IEEE802_11_RADIO_AVS
+ { ieee802_11_radio_avs_if_print, DLT_IEEE802_11_RADIO_AVS },
+ #endif
++#ifndef TCPDUMP_MINI
+ #ifdef DLT_JUNIPER_ATM1
+ { juniper_atm1_print, DLT_JUNIPER_ATM1 },
+ #endif
+@@ -299,6 +310,7 @@ static struct printer printers[] = {
+ #ifdef DLT_IPV6
+ { raw_if_print, DLT_IPV6 },
+ #endif
++#endif
+ { NULL, 0 },
+ };
+
+@@ -307,6 +319,7 @@ static struct ndo_printer ndo_printers[]
+ #ifdef DLT_IPNET
+ { ipnet_if_print, DLT_IPNET },
+ #endif
++#ifndef TCPDUMP_MINI
+ #ifdef DLT_IEEE802_15_4
+ { ieee802_15_4_if_print, DLT_IEEE802_15_4 },
+ #endif
+@@ -316,6 +329,7 @@ static struct ndo_printer ndo_printers[]
+ #ifdef DLT_PPI
+ { ppi_if_print, DLT_PPI },
+ #endif
++#endif
+ #ifdef DLT_NETANALYZER
+ { netanalyzer_if_print, DLT_NETANALYZER },
+ #endif
+--- a/print-sll.c
++++ b/print-sll.c
+@@ -154,14 +154,14 @@ recurse:
+ * Yes - what type is it?
+ */
+ switch (ether_type) {
+-
++#ifndef TCPDUMP_MINI
+ case LINUX_SLL_P_802_3:
+ /*
+ * Ethernet_802.3 IPX frame.
+ */
+ ipx_print(p, length);
+ break;
+-
++#endif
+ case LINUX_SLL_P_802_2:
+ /*
+ * 802.2.
diff --git a/package/network/utils/wireless-tools/.svn/entries b/package/network/utils/wireless-tools/.svn/entries
new file mode 100644
index 0000000..c30eb90
--- /dev/null
+++ b/package/network/utils/wireless-tools/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/utils/wireless-tools
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-10T12:49:37.020840Z
+33693
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+01d6def258dc0f5c915b4e609391a802
+2012-10-10T12:49:37.020840Z
+33693
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2450
+
diff --git a/package/network/utils/wireless-tools/.svn/prop-base/Makefile.svn-base b/package/network/utils/wireless-tools/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..8e522ae
--- /dev/null
+++ b/package/network/utils/wireless-tools/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:copyright
+V 30
+Copyright (C) 2006 OpenWrt.org
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/utils/wireless-tools/.svn/text-base/Makefile.svn-base b/package/network/utils/wireless-tools/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..f0cf2cd
--- /dev/null
+++ b/package/network/utils/wireless-tools/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,91 @@
+#
+# Copyright (C) 2006-2009 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=wireless-tools
+PKG_VERSION:=29
+PKG_MINOR:=
+PKG_RELEASE:=5
+
+PKG_SOURCE:=wireless_tools.$(PKG_VERSION)$(PKG_MINOR).tar.gz
+PKG_SOURCE_URL:=http://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux
+PKG_MD5SUM:=e06c222e186f7cc013fd272d023710cb
+TAR_OPTIONS += || true
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/wireless_tools.$(PKG_VERSION)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/wireless-tools/Default
+ URL:=http://hplabs.hp.com/personal/Jean_Tourrilhes/Linux/Tools.html
+endef
+
+define Package/wireless-tools
+$(call Package/wireless-tools/Default)
+ SECTION:=net
+ CATEGORY:=Base system
+ TITLE:=Tools for manipulating Linux Wireless Extensions
+endef
+
+define Package/wireless-tools/description
+ This package contains a collection of tools for configuring wireless
+ adapters implementing the "Linux Wireless Extensions".
+endef
+
+define Package/libiw
+$(call Package/wireless-tools/Default)
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=Library for manipulating Linux Wireless Extensions
+endef
+
+define Package/libiw/description
+ This package contains a library for manipulating
+ "Linux Wireless Extensions".
+endef
+
+define Build/Compile
+ rm -rf $(PKG_INSTALL_DIR)
+ mkdir -p $(PKG_INSTALL_DIR)
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ $(TARGET_CONFIGURE_OPTS) \
+ CFLAGS="$(TARGET_CFLAGS) -I." \
+ BUILD_WE_ESSENTIAL=y \
+ LIBS="-lm -Wl,--gc-sections" \
+ libiw.so.$(PKG_VERSION) iwmulticall
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ PREFIX="$(PKG_INSTALL_DIR)" \
+ INSTALL_DIR="$(PKG_INSTALL_DIR)/usr/sbin" \
+ INSTALL_LIB="$(PKG_INSTALL_DIR)/usr/lib" \
+ install-iwmulticall
+endef
+
+define Build/InstallDev
+ mkdir -p $(1)/usr/include
+ $(CP) $(PKG_BUILD_DIR)/{iwlib,wireless}.h $(1)/usr/include/
+ mkdir -p $(1)/usr/lib
+ $(CP) $(PKG_BUILD_DIR)/libiw.so* $(1)/usr/lib/
+ ln -sf libiw.so.$(PKG_VERSION) $(1)/usr/lib/libiw.so
+endef
+
+define Package/wireless-tools/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/iwconfig $(1)/usr/sbin/
+ ln -sf iwconfig $(1)/usr/sbin/iwlist
+ ln -sf iwconfig $(1)/usr/sbin/iwpriv
+endef
+
+define Package/libiw/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_BUILD_DIR)/libiw.so.* $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,wireless-tools))
+$(eval $(call BuildPackage,libiw))
diff --git a/package/network/utils/wireless-tools/Makefile b/package/network/utils/wireless-tools/Makefile
new file mode 100644
index 0000000..f0cf2cd
--- /dev/null
+++ b/package/network/utils/wireless-tools/Makefile
@@ -0,0 +1,91 @@
+#
+# Copyright (C) 2006-2009 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=wireless-tools
+PKG_VERSION:=29
+PKG_MINOR:=
+PKG_RELEASE:=5
+
+PKG_SOURCE:=wireless_tools.$(PKG_VERSION)$(PKG_MINOR).tar.gz
+PKG_SOURCE_URL:=http://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux
+PKG_MD5SUM:=e06c222e186f7cc013fd272d023710cb
+TAR_OPTIONS += || true
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/wireless_tools.$(PKG_VERSION)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/wireless-tools/Default
+ URL:=http://hplabs.hp.com/personal/Jean_Tourrilhes/Linux/Tools.html
+endef
+
+define Package/wireless-tools
+$(call Package/wireless-tools/Default)
+ SECTION:=net
+ CATEGORY:=Base system
+ TITLE:=Tools for manipulating Linux Wireless Extensions
+endef
+
+define Package/wireless-tools/description
+ This package contains a collection of tools for configuring wireless
+ adapters implementing the "Linux Wireless Extensions".
+endef
+
+define Package/libiw
+$(call Package/wireless-tools/Default)
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=Library for manipulating Linux Wireless Extensions
+endef
+
+define Package/libiw/description
+ This package contains a library for manipulating
+ "Linux Wireless Extensions".
+endef
+
+define Build/Compile
+ rm -rf $(PKG_INSTALL_DIR)
+ mkdir -p $(PKG_INSTALL_DIR)
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ $(TARGET_CONFIGURE_OPTS) \
+ CFLAGS="$(TARGET_CFLAGS) -I." \
+ BUILD_WE_ESSENTIAL=y \
+ LIBS="-lm -Wl,--gc-sections" \
+ libiw.so.$(PKG_VERSION) iwmulticall
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ PREFIX="$(PKG_INSTALL_DIR)" \
+ INSTALL_DIR="$(PKG_INSTALL_DIR)/usr/sbin" \
+ INSTALL_LIB="$(PKG_INSTALL_DIR)/usr/lib" \
+ install-iwmulticall
+endef
+
+define Build/InstallDev
+ mkdir -p $(1)/usr/include
+ $(CP) $(PKG_BUILD_DIR)/{iwlib,wireless}.h $(1)/usr/include/
+ mkdir -p $(1)/usr/lib
+ $(CP) $(PKG_BUILD_DIR)/libiw.so* $(1)/usr/lib/
+ ln -sf libiw.so.$(PKG_VERSION) $(1)/usr/lib/libiw.so
+endef
+
+define Package/wireless-tools/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/iwconfig $(1)/usr/sbin/
+ ln -sf iwconfig $(1)/usr/sbin/iwlist
+ ln -sf iwconfig $(1)/usr/sbin/iwpriv
+endef
+
+define Package/libiw/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_BUILD_DIR)/libiw.so.* $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,wireless-tools))
+$(eval $(call BuildPackage,libiw))
diff --git a/package/network/utils/wireless-tools/patches/.svn/entries b/package/network/utils/wireless-tools/patches/.svn/entries
new file mode 100644
index 0000000..529055c
--- /dev/null
+++ b/package/network/utils/wireless-tools/patches/.svn/entries
@@ -0,0 +1,164 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/utils/wireless-tools/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-07-19T08:36:11.822317Z
+32777
+hcg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+002-fix-iwconfig-power-argument-parsing.patch
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+e3f1e65f0c5ac5f1b2b131b9584e1db4
+2009-06-17T14:42:24.637364Z
+16491
+juhosg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+315
+
+004-increase_iwlist_buffer.patch
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+22082263b2f7d412ad65b27b1fbd0507
+2012-07-19T08:36:11.822317Z
+32777
+hcg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1308
+
+001-debian.patch
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+3a659046f6d5d3454c716737cc5eead1
+2009-04-17T14:32:29.989894Z
+15245
+nico
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1031
+
+003-we_essential_def.patch
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+51183b0c028b902dd37bac1daccc5c2a
+2011-03-18T03:41:22.482811Z
+26218
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+11142
+
diff --git a/package/network/utils/wireless-tools/patches/.svn/prop-base/001-debian.patch.svn-base b/package/network/utils/wireless-tools/patches/.svn/prop-base/001-debian.patch.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/network/utils/wireless-tools/patches/.svn/prop-base/001-debian.patch.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/network/utils/wireless-tools/patches/.svn/text-base/001-debian.patch.svn-base b/package/network/utils/wireless-tools/patches/.svn/text-base/001-debian.patch.svn-base
new file mode 100644
index 0000000..e00bad2
--- /dev/null
+++ b/package/network/utils/wireless-tools/patches/.svn/text-base/001-debian.patch.svn-base
@@ -0,0 +1,35 @@
+--- a/iwlib.c
++++ b/iwlib.c
+@@ -667,6 +667,7 @@ iw_get_basic_config(int skfd,
+ {
+ struct iwreq wrq;
+
++ memset((char *) &wrq, 0, sizeof(struct iwreq));
+ memset((char *) info, 0, sizeof(struct wireless_config));
+
+ /* Get wireless name */
+--- a/Makefile
++++ b/Makefile
+@@ -73,8 +73,8 @@ DYNAMIC_LINK= libiw.so
+ # Install directories
+ INSTALL_DIR= $(PREFIX)/sbin/
+ INSTALL_LIB= $(PREFIX)/lib/
+-INSTALL_INC= $(PREFIX)/include/
+-INSTALL_MAN= $(PREFIX)/man/
++INSTALL_INC= $(PREFIX)/usr/include/
++INSTALL_MAN= $(PREFIX)/usr/share/man/
+
+ # Various commands
+ RM = rm -f
+@@ -102,9 +102,9 @@ ifdef BUILD_WE_ESSENTIAL
+ endif
+
+ # Other flags
+-CFLAGS=-Os -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow \
++#CFLAGS=-Os -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow \
+ -Wpointer-arith -Wcast-qual -Winline -I.
+-#CFLAGS=-O2 -W -Wall -Wstrict-prototypes -I.
++CFLAGS=-O2 -W -Wall -Wstrict-prototypes -I.
+ DEPFLAGS=-MMD
+ XCFLAGS=$(CFLAGS) $(DEPFLAGS) $(WARN) $(HEADERS) $(WELIB_FLAG) $(WEDEF_FLAG)
+ PICFLAG=-fPIC
diff --git a/package/network/utils/wireless-tools/patches/.svn/text-base/002-fix-iwconfig-power-argument-parsing.patch.svn-base b/package/network/utils/wireless-tools/patches/.svn/text-base/002-fix-iwconfig-power-argument-parsing.patch.svn-base
new file mode 100644
index 0000000..2b61ef2
--- /dev/null
+++ b/package/network/utils/wireless-tools/patches/.svn/text-base/002-fix-iwconfig-power-argument-parsing.patch.svn-base
@@ -0,0 +1,13 @@
+--- a/iwconfig.c
++++ b/iwconfig.c
+@@ -1034,8 +1034,8 @@ set_power_info(int skfd,
+ wrq.u.power.disabled = 0;
+
+ /* Is there any value to grab ? */
+- value = strtod(args[0], &unit);
+- if(unit != args[0])
++ value = strtod(args[i], &unit);
++ if(unit != args[i])
+ {
+ struct iw_range range;
+ int flags;
diff --git a/package/network/utils/wireless-tools/patches/.svn/text-base/003-we_essential_def.patch.svn-base b/package/network/utils/wireless-tools/patches/.svn/text-base/003-we_essential_def.patch.svn-base
new file mode 100644
index 0000000..8666f3e
--- /dev/null
+++ b/package/network/utils/wireless-tools/patches/.svn/text-base/003-we_essential_def.patch.svn-base
@@ -0,0 +1,359 @@
+--- a/iwlist.c
++++ b/iwlist.c
+@@ -58,7 +58,6 @@ typedef struct iw_auth_descr
+ * Maybe this should go in iwlib.c ?
+ */
+
+-#ifndef WE_ESSENTIAL
+ #define IW_ARRAY_LEN(x) (sizeof(x)/sizeof((x)[0]))
+
+ //static const struct iwmask_name iw_enc_mode_name[] = {
+@@ -161,11 +160,8 @@ static const char * iw_ie_key_mgmt_name[
+ };
+ #define IW_IE_KEY_MGMT_NUM IW_ARRAY_LEN(iw_ie_key_mgmt_name)
+
+-#endif /* WE_ESSENTIAL */
+-
+ /************************* WPA SUBROUTINES *************************/
+
+-#ifndef WE_ESSENTIAL
+ /*------------------------------------------------------------------*/
+ /*
+ * Print all names corresponding to a mask.
+@@ -431,7 +427,6 @@ iw_print_gen_ie(unsigned char * buffer,
+ offset += buffer[offset+1] + 2;
+ }
+ }
+-#endif /* WE_ESSENTIAL */
+
+ /***************************** SCANNING *****************************/
+ /*
+@@ -585,12 +580,10 @@ print_scanning_token(struct stream_descr
+ &event->u.qual, iw_range, has_range);
+ printf(" %s\n", buffer);
+ break;
+-#ifndef WE_ESSENTIAL
+ case IWEVGENIE:
+ /* Informations Elements are complex, let's do only some of them */
+ iw_print_gen_ie(event->u.data.pointer, event->u.data.length);
+ break;
+-#endif /* WE_ESSENTIAL */
+ case IWEVCUSTOM:
+ {
+ char custom[IW_CUSTOM_MAX+1];
+@@ -1302,7 +1295,6 @@ print_pm_info(int skfd,
+ return(0);
+ }
+
+-#ifndef WE_ESSENTIAL
+ /************************** TRANSMIT POWER **************************/
+
+ /*------------------------------------------------------------------*/
+@@ -1405,6 +1397,7 @@ print_txpower_info(int skfd,
+ return(0);
+ }
+
++#ifndef WE_ESSENTIAL
+ /*********************** RETRY LIMIT/LIFETIME ***********************/
+
+ /*------------------------------------------------------------------*/
+@@ -2060,8 +2053,8 @@ static const struct iwlist_entry iwlist_
+ { "encryption", print_keys_info, 0, NULL },
+ { "keys", print_keys_info, 0, NULL },
+ { "power", print_pm_info, 0, NULL },
+-#ifndef WE_ESSENTIAL
+ { "txpower", print_txpower_info, 0, NULL },
++#ifndef WE_ESSENTIAL
+ { "retry", print_retry_info, 0, NULL },
+ { "ap", print_ap_info, 0, NULL },
+ { "accesspoints", print_ap_info, 0, NULL },
+--- a/iwconfig.c
++++ b/iwconfig.c
+@@ -106,16 +106,6 @@ get_info(int skfd,
+ if(wrq.u.data.length > 1)
+ info->has_nickname = 1;
+
+- if((info->has_range) && (info->range.we_version_compiled > 9))
+- {
+- /* Get Transmit Power */
+- if(iw_get_ext(skfd, ifname, SIOCGIWTXPOW, &wrq) >= 0)
+- {
+- info->has_txpower = 1;
+- memcpy(&(info->txpower), &(wrq.u.txpower), sizeof(iwparam));
+- }
+- }
+-
+ /* Get sensitivity */
+ if(iw_get_ext(skfd, ifname, SIOCGIWSENS, &wrq) >= 0)
+ {
+@@ -132,6 +122,17 @@ get_info(int skfd,
+ memcpy(&(info->retry), &(wrq.u.retry), sizeof(iwparam));
+ }
+ }
++#endif /* WE_ESSENTIAL */
++
++ if((info->has_range) && (info->range.we_version_compiled > 9))
++ {
++ /* Get Transmit Power */
++ if(iw_get_ext(skfd, ifname, SIOCGIWTXPOW, &wrq) >= 0)
++ {
++ info->has_txpower = 1;
++ memcpy(&(info->txpower), &(wrq.u.txpower), sizeof(iwparam));
++ }
++ }
+
+ /* Get RTS threshold */
+ if(iw_get_ext(skfd, ifname, SIOCGIWRTS, &wrq) >= 0)
+@@ -146,7 +147,6 @@ get_info(int skfd,
+ info->has_frag = 1;
+ memcpy(&(info->frag), &(wrq.u.frag), sizeof(iwparam));
+ }
+-#endif /* WE_ESSENTIAL */
+
+ return(0);
+ }
+@@ -269,7 +269,6 @@ display_info(struct wireless_info * info
+ printf("Bit Rate%c%s ", (info->bitrate.fixed ? '=' : ':'), buffer);
+ }
+
+-#ifndef WE_ESSENTIAL
+ /* Display the Transmit Power */
+ if(info->has_txpower)
+ {
+@@ -286,6 +285,7 @@ display_info(struct wireless_info * info
+ printf("Tx-Power%c%s ", (info->txpower.fixed ? '=' : ':'), buffer);
+ }
+
++#ifndef WE_ESSENTIAL
+ /* Display sensitivity */
+ if(info->has_sens)
+ {
+@@ -340,6 +340,7 @@ display_info(struct wireless_info * info
+ printf(" ");
+ tokens += 5; /* Between 3 and 5, depend on flags */
+ }
++#endif /* WE_ESSENTIAL */
+
+ /* Display the RTS threshold */
+ if(info->has_rts)
+@@ -383,7 +384,6 @@ display_info(struct wireless_info * info
+ /* Formating */
+ if(tokens > 0)
+ printf("\n ");
+-#endif /* WE_ESSENTIAL */
+
+ /* Display encryption information */
+ /* Note : we display only the "current" key, use iwlist to list all keys */
+@@ -1196,6 +1196,7 @@ set_nwid_info(int skfd,
+ /* 1 arg */
+ return(1);
+ }
++#endif /* WE_ESSENTIAL */
+
+ /*------------------------------------------------------------------*/
+ /*
+@@ -1362,6 +1363,7 @@ set_txpower_info(int skfd,
+ return(i);
+ }
+
++#ifndef WE_ESSENTIAL
+ /*------------------------------------------------------------------*/
+ /*
+ * Set Sensitivity
+@@ -1459,6 +1461,7 @@ set_retry_info(int skfd,
+ /* Var args */
+ return(i);
+ }
++#endif /* WE_ESSENTIAL */
+
+ /*------------------------------------------------------------------*/
+ /*
+@@ -1565,6 +1568,7 @@ set_frag_info(int skfd,
+ return(1);
+ }
+
++#ifndef WE_ESSENTIAL
+ /*------------------------------------------------------------------*/
+ /*
+ * Set Modulation
+@@ -1719,21 +1723,21 @@ static const struct iwconfig_entry iwcon
+ "Set Nickname", "NNN" },
+ { "nwid", set_nwid_info, 1, SIOCSIWNWID,
+ "Set NWID", "{NN|on|off}" },
+- { "ap", set_apaddr_info, 1, SIOCSIWAP,
+- "Set AP Address", "{N|off|auto}" },
+- { "txpower", set_txpower_info, 1, SIOCSIWTXPOW,
+- "Set Tx Power", "{NmW|NdBm|off|auto}" },
+ { "sens", set_sens_info, 1, SIOCSIWSENS,
+ "Set Sensitivity", "N" },
++ { "modulation", set_modulation_info, 1, SIOCGIWMODUL,
++ "Set Modulation", "{11g|11a|CCK|OFDMg|...}" },
+ { "retry", set_retry_info, 1, SIOCSIWRETRY,
+ "Set Retry Limit", "{limit N|lifetime N}" },
++#endif /* WE_ESSENTIAL */
++ { "ap", set_apaddr_info, 1, SIOCSIWAP,
++ "Set AP Address", "{N|off|auto}" },
++ { "txpower", set_txpower_info, 1, SIOCSIWTXPOW,
++ "Set Tx Power", "{NmW|NdBm|off|auto}" },
+ { "rts", set_rts_info, 1, SIOCSIWRTS,
+ "Set RTS Threshold", "{N|auto|fixed|off}" },
+ { "frag", set_frag_info, 1, SIOCSIWFRAG,
+ "Set Fragmentation Threshold", "{N|auto|fixed|off}" },
+- { "modulation", set_modulation_info, 1, SIOCGIWMODUL,
+- "Set Modulation", "{11g|11a|CCK|OFDMg|...}" },
+-#endif /* WE_ESSENTIAL */
+ { "commit", set_commit_info, 0, SIOCSIWCOMMIT,
+ "Commit changes", "" },
+ { NULL, NULL, 0, 0, NULL, NULL },
+--- a/iwmulticall.c
++++ b/iwmulticall.c
+@@ -81,7 +81,7 @@ extern int
+ #define main(args...) main_iwspy(args)
+ #include "iwspy.c"
+ #undef main
+-#endif /* WE_ESSENTIAL */
++#endif
+
+ /* Get iwpriv in there. Mandatory for HostAP and some other drivers. */
+ #define main(args...) main_iwpriv(args)
+@@ -90,12 +90,14 @@ extern int
+ #undef iw_usage
+ #undef main
+
++#ifndef WE_ESSENTIAL
+ /* Do we really need iwgetid ? Well, it's not like it's a big one */
+ #define main(args...) main_iwgetid(args)
+ #define iw_usage(args...) iwgetid_usage(args)
+ #include "iwgetid.c"
+ #undef iw_usage
+ #undef main
++#endif
+
+ /* iwevent is useless for most people, don't grab it ? */
+
+@@ -131,11 +133,13 @@ main(int argc,
+ #ifndef WE_ESSENTIAL
+ if(!strcmp(call_name, "iwspy"))
+ return(main_iwspy(argc, argv));
+-#endif /* WE_ESSENTIAL */
++#endif
+ if(!strcmp(call_name, "iwpriv"))
+ return(main_iwpriv(argc, argv));
++#ifndef WE_ESSENTIAL
+ if(!strcmp(call_name, "iwgetid"))
+ return(main_iwgetid(argc, argv));
++#endif
+
+ /* Uh oh... Not supposed to come here. */
+ printf("iwmulticall : you are not supposed to call me this way...\n");
+--- a/iwlib.c
++++ b/iwlib.c
+@@ -113,6 +113,7 @@ const struct iw_modul_descr iw_modul_lis
+ { IW_MODUL_11A, "11a", "IEEE 802.11a (5 GHz, up to 54 Mb/s)" },
+ { IW_MODUL_11B, "11b", "IEEE 802.11b (2.4 GHz, up to 11 Mb/s)" },
+
++#ifndef WE_ESSENTIAL
+ /* Proprietary aggregates */
+ { IW_MODUL_TURBO | IW_MODUL_11A, "turboa",
+ "Atheros turbo mode at 5 GHz (up to 108 Mb/s)" },
+@@ -120,6 +121,7 @@ const struct iw_modul_descr iw_modul_lis
+ "Atheros turbo mode at 2.4 GHz (up to 108 Mb/s)" },
+ { IW_MODUL_PBCC | IW_MODUL_11B, "11+",
+ "TI 802.11+ (2.4 GHz, up to 22 Mb/s)" },
++#endif
+
+ /* Individual modulations */
+ { IW_MODUL_OFDM_G, "OFDMg",
+@@ -129,6 +131,7 @@ const struct iw_modul_descr iw_modul_lis
+ { IW_MODUL_DS, "DS", "802.11 Direct Sequence (2.4 GHz, up to 2 Mb/s)" },
+ { IW_MODUL_FH, "FH", "802.11 Frequency Hopping (2,4 GHz, up to 2 Mb/s)" },
+
++#ifndef WE_ESSENTIAL
+ /* Proprietary modulations */
+ { IW_MODUL_TURBO, "turbo",
+ "Atheros turbo mode, channel bonding (up to 108 Mb/s)" },
+@@ -136,6 +139,7 @@ const struct iw_modul_descr iw_modul_lis
+ "TI 802.11+ higher rates (2.4 GHz, up to 22 Mb/s)" },
+ { IW_MODUL_CUSTOM, "custom",
+ "Driver specific modulation (check driver documentation)" },
++#endif
+ };
+
+ /* Disable runtime version warning in iw_get_range_info() */
+@@ -440,6 +444,7 @@ iw_print_version_info(const char * tooln
+ return -1;
+ }
+
++#ifndef WE_ESSENTIAL
+ /* Information about the tools themselves */
+ if(toolname != NULL)
+ printf("%-8.16s Wireless-Tools version %d\n", toolname, WT_VERSION);
+@@ -452,6 +457,7 @@ iw_print_version_info(const char * tooln
+ if(we_kernel_version > 15)
+ printf("Kernel Currently compiled with Wireless Extension v%d.\n\n",
+ we_kernel_version);
++#endif
+
+ /* Version for each device */
+ iw_enum_devices(skfd, &print_iface_version_info, NULL, 0);
+@@ -501,6 +507,7 @@ iw_get_range_info(int skfd,
+ /* Copy stuff at the right place, ignore extra */
+ memcpy((char *) range, buffer, sizeof(iwrange));
+ }
++#ifndef WE_ESSENTIAL
+ else
+ {
+ /* Zero unknown fields */
+@@ -574,6 +581,7 @@ iw_get_range_info(int skfd,
+ * If the driver source has not been updated to the latest, it doesn't
+ * matter because the new fields are set to zero */
+ }
++#endif
+
+ /* Don't complain twice.
+ * In theory, the test apply to each individual driver, but usually
+@@ -1542,6 +1550,7 @@ iw_print_key(char * buffer,
+ }
+ }
+
++#ifndef WE_ESSENTIAL
+ /*------------------------------------------------------------------*/
+ /*
+ * Convert a passphrase into a key
+@@ -1556,6 +1565,7 @@ iw_pass_key(const char * input,
+ fprintf(stderr, "Error: Passphrase not implemented\n");
+ return(-1);
+ }
++#endif
+
+ /*------------------------------------------------------------------*/
+ /*
+@@ -1578,12 +1588,14 @@ iw_in_key(const char * input,
+ keylen = IW_ENCODING_TOKEN_MAX;
+ memcpy(key, input + 2, keylen);
+ }
++#ifndef WE_ESSENTIAL
+ else
+ if(!strncmp(input, "p:", 2))
+ {
+ /* Second case : as a passphrase (PrismII cards) */
+ return(iw_pass_key(input + 2, key)); /* skip "p:" */
+ }
++#endif
+ else
+ {
+ const char * p;
+--- a/Makefile
++++ b/Makefile
+@@ -195,9 +195,9 @@ install-iwmulticall:: iwmulticall
+ install -m 755 $< $(INSTALL_DIR)/iwconfig
+ ( cd $(INSTALL_DIR) ; \
+ ln -f -s iwconfig iwlist ; \
+- ln -f -s iwconfig iwspy ; \
++ $(if $(BUILD_WE_ESSENTIAL),,ln -f -s iwconfig iwspy ;) \
+ ln -f -s iwconfig iwpriv ; \
+- ln -f -s iwconfig iwgetid )
++ $(if $(BUILD_WE_ESSENTIAL),,ln -f -s iwconfig iwgetid ) )
+
+ clean::
+ $(RM_CMD)
diff --git a/package/network/utils/wireless-tools/patches/.svn/text-base/004-increase_iwlist_buffer.patch.svn-base b/package/network/utils/wireless-tools/patches/.svn/text-base/004-increase_iwlist_buffer.patch.svn-base
new file mode 100644
index 0000000..f2fdb12
--- /dev/null
+++ b/package/network/utils/wireless-tools/patches/.svn/text-base/004-increase_iwlist_buffer.patch.svn-base
@@ -0,0 +1,46 @@
+--- a/iwlist.c
++++ b/iwlist.c
+@@ -792,7 +792,8 @@ print_scanning_info(int skfd,
+ if(iw_get_ext(skfd, ifname, SIOCGIWSCAN, &wrq) < 0)
+ {
+ /* Check if buffer was too small (WE-17 only) */
+- if((errno == E2BIG) && (range.we_version_compiled > 16))
++ if((errno == E2BIG) && (range.we_version_compiled > 16)
++ && (buflen < 0xFFFF))
+ {
+ /* Some driver may return very large scan results, either
+ * because there are many cells, or because they have many
+@@ -808,6 +809,10 @@ print_scanning_info(int skfd,
+ else
+ buflen *= 2;
+
++ /* wrq.u.data.length is 16 bits so max size is 65535 */
++ if(buflen > 0xFFFF)
++ buflen = 0xFFFF;
++
+ /* Try again */
+ goto realloc;
+ }
+@@ -2152,6 +2157,7 @@ main(int argc,
+ char **args; /* Command arguments */
+ int count; /* Number of arguments */
+ const iwlist_cmd *iwcmd;
++ int goterr = 0;
+
+ if(argc < 2)
+ iw_usage(1);
+@@ -2199,12 +2205,12 @@ main(int argc,
+
+ /* do the actual work */
+ if (dev)
+- (*iwcmd->fn)(skfd, dev, args, count);
++ goterr = (*iwcmd->fn)(skfd, dev, args, count);
+ else
+ iw_enum_devices(skfd, iwcmd->fn, args, count);
+
+ /* Close the socket. */
+ iw_sockets_close(skfd);
+
+- return 0;
++ return goterr;
+ }
diff --git a/package/network/utils/wireless-tools/patches/001-debian.patch b/package/network/utils/wireless-tools/patches/001-debian.patch
new file mode 100644
index 0000000..e00bad2
--- /dev/null
+++ b/package/network/utils/wireless-tools/patches/001-debian.patch
@@ -0,0 +1,35 @@
+--- a/iwlib.c
++++ b/iwlib.c
+@@ -667,6 +667,7 @@ iw_get_basic_config(int skfd,
+ {
+ struct iwreq wrq;
+
++ memset((char *) &wrq, 0, sizeof(struct iwreq));
+ memset((char *) info, 0, sizeof(struct wireless_config));
+
+ /* Get wireless name */
+--- a/Makefile
++++ b/Makefile
+@@ -73,8 +73,8 @@ DYNAMIC_LINK= libiw.so
+ # Install directories
+ INSTALL_DIR= $(PREFIX)/sbin/
+ INSTALL_LIB= $(PREFIX)/lib/
+-INSTALL_INC= $(PREFIX)/include/
+-INSTALL_MAN= $(PREFIX)/man/
++INSTALL_INC= $(PREFIX)/usr/include/
++INSTALL_MAN= $(PREFIX)/usr/share/man/
+
+ # Various commands
+ RM = rm -f
+@@ -102,9 +102,9 @@ ifdef BUILD_WE_ESSENTIAL
+ endif
+
+ # Other flags
+-CFLAGS=-Os -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow \
++#CFLAGS=-Os -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow \
+ -Wpointer-arith -Wcast-qual -Winline -I.
+-#CFLAGS=-O2 -W -Wall -Wstrict-prototypes -I.
++CFLAGS=-O2 -W -Wall -Wstrict-prototypes -I.
+ DEPFLAGS=-MMD
+ XCFLAGS=$(CFLAGS) $(DEPFLAGS) $(WARN) $(HEADERS) $(WELIB_FLAG) $(WEDEF_FLAG)
+ PICFLAG=-fPIC
diff --git a/package/network/utils/wireless-tools/patches/002-fix-iwconfig-power-argument-parsing.patch b/package/network/utils/wireless-tools/patches/002-fix-iwconfig-power-argument-parsing.patch
new file mode 100644
index 0000000..2b61ef2
--- /dev/null
+++ b/package/network/utils/wireless-tools/patches/002-fix-iwconfig-power-argument-parsing.patch
@@ -0,0 +1,13 @@
+--- a/iwconfig.c
++++ b/iwconfig.c
+@@ -1034,8 +1034,8 @@ set_power_info(int skfd,
+ wrq.u.power.disabled = 0;
+
+ /* Is there any value to grab ? */
+- value = strtod(args[0], &unit);
+- if(unit != args[0])
++ value = strtod(args[i], &unit);
++ if(unit != args[i])
+ {
+ struct iw_range range;
+ int flags;
diff --git a/package/network/utils/wireless-tools/patches/003-we_essential_def.patch b/package/network/utils/wireless-tools/patches/003-we_essential_def.patch
new file mode 100644
index 0000000..8666f3e
--- /dev/null
+++ b/package/network/utils/wireless-tools/patches/003-we_essential_def.patch
@@ -0,0 +1,359 @@
+--- a/iwlist.c
++++ b/iwlist.c
+@@ -58,7 +58,6 @@ typedef struct iw_auth_descr
+ * Maybe this should go in iwlib.c ?
+ */
+
+-#ifndef WE_ESSENTIAL
+ #define IW_ARRAY_LEN(x) (sizeof(x)/sizeof((x)[0]))
+
+ //static const struct iwmask_name iw_enc_mode_name[] = {
+@@ -161,11 +160,8 @@ static const char * iw_ie_key_mgmt_name[
+ };
+ #define IW_IE_KEY_MGMT_NUM IW_ARRAY_LEN(iw_ie_key_mgmt_name)
+
+-#endif /* WE_ESSENTIAL */
+-
+ /************************* WPA SUBROUTINES *************************/
+
+-#ifndef WE_ESSENTIAL
+ /*------------------------------------------------------------------*/
+ /*
+ * Print all names corresponding to a mask.
+@@ -431,7 +427,6 @@ iw_print_gen_ie(unsigned char * buffer,
+ offset += buffer[offset+1] + 2;
+ }
+ }
+-#endif /* WE_ESSENTIAL */
+
+ /***************************** SCANNING *****************************/
+ /*
+@@ -585,12 +580,10 @@ print_scanning_token(struct stream_descr
+ &event->u.qual, iw_range, has_range);
+ printf(" %s\n", buffer);
+ break;
+-#ifndef WE_ESSENTIAL
+ case IWEVGENIE:
+ /* Informations Elements are complex, let's do only some of them */
+ iw_print_gen_ie(event->u.data.pointer, event->u.data.length);
+ break;
+-#endif /* WE_ESSENTIAL */
+ case IWEVCUSTOM:
+ {
+ char custom[IW_CUSTOM_MAX+1];
+@@ -1302,7 +1295,6 @@ print_pm_info(int skfd,
+ return(0);
+ }
+
+-#ifndef WE_ESSENTIAL
+ /************************** TRANSMIT POWER **************************/
+
+ /*------------------------------------------------------------------*/
+@@ -1405,6 +1397,7 @@ print_txpower_info(int skfd,
+ return(0);
+ }
+
++#ifndef WE_ESSENTIAL
+ /*********************** RETRY LIMIT/LIFETIME ***********************/
+
+ /*------------------------------------------------------------------*/
+@@ -2060,8 +2053,8 @@ static const struct iwlist_entry iwlist_
+ { "encryption", print_keys_info, 0, NULL },
+ { "keys", print_keys_info, 0, NULL },
+ { "power", print_pm_info, 0, NULL },
+-#ifndef WE_ESSENTIAL
+ { "txpower", print_txpower_info, 0, NULL },
++#ifndef WE_ESSENTIAL
+ { "retry", print_retry_info, 0, NULL },
+ { "ap", print_ap_info, 0, NULL },
+ { "accesspoints", print_ap_info, 0, NULL },
+--- a/iwconfig.c
++++ b/iwconfig.c
+@@ -106,16 +106,6 @@ get_info(int skfd,
+ if(wrq.u.data.length > 1)
+ info->has_nickname = 1;
+
+- if((info->has_range) && (info->range.we_version_compiled > 9))
+- {
+- /* Get Transmit Power */
+- if(iw_get_ext(skfd, ifname, SIOCGIWTXPOW, &wrq) >= 0)
+- {
+- info->has_txpower = 1;
+- memcpy(&(info->txpower), &(wrq.u.txpower), sizeof(iwparam));
+- }
+- }
+-
+ /* Get sensitivity */
+ if(iw_get_ext(skfd, ifname, SIOCGIWSENS, &wrq) >= 0)
+ {
+@@ -132,6 +122,17 @@ get_info(int skfd,
+ memcpy(&(info->retry), &(wrq.u.retry), sizeof(iwparam));
+ }
+ }
++#endif /* WE_ESSENTIAL */
++
++ if((info->has_range) && (info->range.we_version_compiled > 9))
++ {
++ /* Get Transmit Power */
++ if(iw_get_ext(skfd, ifname, SIOCGIWTXPOW, &wrq) >= 0)
++ {
++ info->has_txpower = 1;
++ memcpy(&(info->txpower), &(wrq.u.txpower), sizeof(iwparam));
++ }
++ }
+
+ /* Get RTS threshold */
+ if(iw_get_ext(skfd, ifname, SIOCGIWRTS, &wrq) >= 0)
+@@ -146,7 +147,6 @@ get_info(int skfd,
+ info->has_frag = 1;
+ memcpy(&(info->frag), &(wrq.u.frag), sizeof(iwparam));
+ }
+-#endif /* WE_ESSENTIAL */
+
+ return(0);
+ }
+@@ -269,7 +269,6 @@ display_info(struct wireless_info * info
+ printf("Bit Rate%c%s ", (info->bitrate.fixed ? '=' : ':'), buffer);
+ }
+
+-#ifndef WE_ESSENTIAL
+ /* Display the Transmit Power */
+ if(info->has_txpower)
+ {
+@@ -286,6 +285,7 @@ display_info(struct wireless_info * info
+ printf("Tx-Power%c%s ", (info->txpower.fixed ? '=' : ':'), buffer);
+ }
+
++#ifndef WE_ESSENTIAL
+ /* Display sensitivity */
+ if(info->has_sens)
+ {
+@@ -340,6 +340,7 @@ display_info(struct wireless_info * info
+ printf(" ");
+ tokens += 5; /* Between 3 and 5, depend on flags */
+ }
++#endif /* WE_ESSENTIAL */
+
+ /* Display the RTS threshold */
+ if(info->has_rts)
+@@ -383,7 +384,6 @@ display_info(struct wireless_info * info
+ /* Formating */
+ if(tokens > 0)
+ printf("\n ");
+-#endif /* WE_ESSENTIAL */
+
+ /* Display encryption information */
+ /* Note : we display only the "current" key, use iwlist to list all keys */
+@@ -1196,6 +1196,7 @@ set_nwid_info(int skfd,
+ /* 1 arg */
+ return(1);
+ }
++#endif /* WE_ESSENTIAL */
+
+ /*------------------------------------------------------------------*/
+ /*
+@@ -1362,6 +1363,7 @@ set_txpower_info(int skfd,
+ return(i);
+ }
+
++#ifndef WE_ESSENTIAL
+ /*------------------------------------------------------------------*/
+ /*
+ * Set Sensitivity
+@@ -1459,6 +1461,7 @@ set_retry_info(int skfd,
+ /* Var args */
+ return(i);
+ }
++#endif /* WE_ESSENTIAL */
+
+ /*------------------------------------------------------------------*/
+ /*
+@@ -1565,6 +1568,7 @@ set_frag_info(int skfd,
+ return(1);
+ }
+
++#ifndef WE_ESSENTIAL
+ /*------------------------------------------------------------------*/
+ /*
+ * Set Modulation
+@@ -1719,21 +1723,21 @@ static const struct iwconfig_entry iwcon
+ "Set Nickname", "NNN" },
+ { "nwid", set_nwid_info, 1, SIOCSIWNWID,
+ "Set NWID", "{NN|on|off}" },
+- { "ap", set_apaddr_info, 1, SIOCSIWAP,
+- "Set AP Address", "{N|off|auto}" },
+- { "txpower", set_txpower_info, 1, SIOCSIWTXPOW,
+- "Set Tx Power", "{NmW|NdBm|off|auto}" },
+ { "sens", set_sens_info, 1, SIOCSIWSENS,
+ "Set Sensitivity", "N" },
++ { "modulation", set_modulation_info, 1, SIOCGIWMODUL,
++ "Set Modulation", "{11g|11a|CCK|OFDMg|...}" },
+ { "retry", set_retry_info, 1, SIOCSIWRETRY,
+ "Set Retry Limit", "{limit N|lifetime N}" },
++#endif /* WE_ESSENTIAL */
++ { "ap", set_apaddr_info, 1, SIOCSIWAP,
++ "Set AP Address", "{N|off|auto}" },
++ { "txpower", set_txpower_info, 1, SIOCSIWTXPOW,
++ "Set Tx Power", "{NmW|NdBm|off|auto}" },
+ { "rts", set_rts_info, 1, SIOCSIWRTS,
+ "Set RTS Threshold", "{N|auto|fixed|off}" },
+ { "frag", set_frag_info, 1, SIOCSIWFRAG,
+ "Set Fragmentation Threshold", "{N|auto|fixed|off}" },
+- { "modulation", set_modulation_info, 1, SIOCGIWMODUL,
+- "Set Modulation", "{11g|11a|CCK|OFDMg|...}" },
+-#endif /* WE_ESSENTIAL */
+ { "commit", set_commit_info, 0, SIOCSIWCOMMIT,
+ "Commit changes", "" },
+ { NULL, NULL, 0, 0, NULL, NULL },
+--- a/iwmulticall.c
++++ b/iwmulticall.c
+@@ -81,7 +81,7 @@ extern int
+ #define main(args...) main_iwspy(args)
+ #include "iwspy.c"
+ #undef main
+-#endif /* WE_ESSENTIAL */
++#endif
+
+ /* Get iwpriv in there. Mandatory for HostAP and some other drivers. */
+ #define main(args...) main_iwpriv(args)
+@@ -90,12 +90,14 @@ extern int
+ #undef iw_usage
+ #undef main
+
++#ifndef WE_ESSENTIAL
+ /* Do we really need iwgetid ? Well, it's not like it's a big one */
+ #define main(args...) main_iwgetid(args)
+ #define iw_usage(args...) iwgetid_usage(args)
+ #include "iwgetid.c"
+ #undef iw_usage
+ #undef main
++#endif
+
+ /* iwevent is useless for most people, don't grab it ? */
+
+@@ -131,11 +133,13 @@ main(int argc,
+ #ifndef WE_ESSENTIAL
+ if(!strcmp(call_name, "iwspy"))
+ return(main_iwspy(argc, argv));
+-#endif /* WE_ESSENTIAL */
++#endif
+ if(!strcmp(call_name, "iwpriv"))
+ return(main_iwpriv(argc, argv));
++#ifndef WE_ESSENTIAL
+ if(!strcmp(call_name, "iwgetid"))
+ return(main_iwgetid(argc, argv));
++#endif
+
+ /* Uh oh... Not supposed to come here. */
+ printf("iwmulticall : you are not supposed to call me this way...\n");
+--- a/iwlib.c
++++ b/iwlib.c
+@@ -113,6 +113,7 @@ const struct iw_modul_descr iw_modul_lis
+ { IW_MODUL_11A, "11a", "IEEE 802.11a (5 GHz, up to 54 Mb/s)" },
+ { IW_MODUL_11B, "11b", "IEEE 802.11b (2.4 GHz, up to 11 Mb/s)" },
+
++#ifndef WE_ESSENTIAL
+ /* Proprietary aggregates */
+ { IW_MODUL_TURBO | IW_MODUL_11A, "turboa",
+ "Atheros turbo mode at 5 GHz (up to 108 Mb/s)" },
+@@ -120,6 +121,7 @@ const struct iw_modul_descr iw_modul_lis
+ "Atheros turbo mode at 2.4 GHz (up to 108 Mb/s)" },
+ { IW_MODUL_PBCC | IW_MODUL_11B, "11+",
+ "TI 802.11+ (2.4 GHz, up to 22 Mb/s)" },
++#endif
+
+ /* Individual modulations */
+ { IW_MODUL_OFDM_G, "OFDMg",
+@@ -129,6 +131,7 @@ const struct iw_modul_descr iw_modul_lis
+ { IW_MODUL_DS, "DS", "802.11 Direct Sequence (2.4 GHz, up to 2 Mb/s)" },
+ { IW_MODUL_FH, "FH", "802.11 Frequency Hopping (2,4 GHz, up to 2 Mb/s)" },
+
++#ifndef WE_ESSENTIAL
+ /* Proprietary modulations */
+ { IW_MODUL_TURBO, "turbo",
+ "Atheros turbo mode, channel bonding (up to 108 Mb/s)" },
+@@ -136,6 +139,7 @@ const struct iw_modul_descr iw_modul_lis
+ "TI 802.11+ higher rates (2.4 GHz, up to 22 Mb/s)" },
+ { IW_MODUL_CUSTOM, "custom",
+ "Driver specific modulation (check driver documentation)" },
++#endif
+ };
+
+ /* Disable runtime version warning in iw_get_range_info() */
+@@ -440,6 +444,7 @@ iw_print_version_info(const char * tooln
+ return -1;
+ }
+
++#ifndef WE_ESSENTIAL
+ /* Information about the tools themselves */
+ if(toolname != NULL)
+ printf("%-8.16s Wireless-Tools version %d\n", toolname, WT_VERSION);
+@@ -452,6 +457,7 @@ iw_print_version_info(const char * tooln
+ if(we_kernel_version > 15)
+ printf("Kernel Currently compiled with Wireless Extension v%d.\n\n",
+ we_kernel_version);
++#endif
+
+ /* Version for each device */
+ iw_enum_devices(skfd, &print_iface_version_info, NULL, 0);
+@@ -501,6 +507,7 @@ iw_get_range_info(int skfd,
+ /* Copy stuff at the right place, ignore extra */
+ memcpy((char *) range, buffer, sizeof(iwrange));
+ }
++#ifndef WE_ESSENTIAL
+ else
+ {
+ /* Zero unknown fields */
+@@ -574,6 +581,7 @@ iw_get_range_info(int skfd,
+ * If the driver source has not been updated to the latest, it doesn't
+ * matter because the new fields are set to zero */
+ }
++#endif
+
+ /* Don't complain twice.
+ * In theory, the test apply to each individual driver, but usually
+@@ -1542,6 +1550,7 @@ iw_print_key(char * buffer,
+ }
+ }
+
++#ifndef WE_ESSENTIAL
+ /*------------------------------------------------------------------*/
+ /*
+ * Convert a passphrase into a key
+@@ -1556,6 +1565,7 @@ iw_pass_key(const char * input,
+ fprintf(stderr, "Error: Passphrase not implemented\n");
+ return(-1);
+ }
++#endif
+
+ /*------------------------------------------------------------------*/
+ /*
+@@ -1578,12 +1588,14 @@ iw_in_key(const char * input,
+ keylen = IW_ENCODING_TOKEN_MAX;
+ memcpy(key, input + 2, keylen);
+ }
++#ifndef WE_ESSENTIAL
+ else
+ if(!strncmp(input, "p:", 2))
+ {
+ /* Second case : as a passphrase (PrismII cards) */
+ return(iw_pass_key(input + 2, key)); /* skip "p:" */
+ }
++#endif
+ else
+ {
+ const char * p;
+--- a/Makefile
++++ b/Makefile
+@@ -195,9 +195,9 @@ install-iwmulticall:: iwmulticall
+ install -m 755 $< $(INSTALL_DIR)/iwconfig
+ ( cd $(INSTALL_DIR) ; \
+ ln -f -s iwconfig iwlist ; \
+- ln -f -s iwconfig iwspy ; \
++ $(if $(BUILD_WE_ESSENTIAL),,ln -f -s iwconfig iwspy ;) \
+ ln -f -s iwconfig iwpriv ; \
+- ln -f -s iwconfig iwgetid )
++ $(if $(BUILD_WE_ESSENTIAL),,ln -f -s iwconfig iwgetid ) )
+
+ clean::
+ $(RM_CMD)
diff --git a/package/network/utils/wireless-tools/patches/004-increase_iwlist_buffer.patch b/package/network/utils/wireless-tools/patches/004-increase_iwlist_buffer.patch
new file mode 100644
index 0000000..f2fdb12
--- /dev/null
+++ b/package/network/utils/wireless-tools/patches/004-increase_iwlist_buffer.patch
@@ -0,0 +1,46 @@
+--- a/iwlist.c
++++ b/iwlist.c
+@@ -792,7 +792,8 @@ print_scanning_info(int skfd,
+ if(iw_get_ext(skfd, ifname, SIOCGIWSCAN, &wrq) < 0)
+ {
+ /* Check if buffer was too small (WE-17 only) */
+- if((errno == E2BIG) && (range.we_version_compiled > 16))
++ if((errno == E2BIG) && (range.we_version_compiled > 16)
++ && (buflen < 0xFFFF))
+ {
+ /* Some driver may return very large scan results, either
+ * because there are many cells, or because they have many
+@@ -808,6 +809,10 @@ print_scanning_info(int skfd,
+ else
+ buflen *= 2;
+
++ /* wrq.u.data.length is 16 bits so max size is 65535 */
++ if(buflen > 0xFFFF)
++ buflen = 0xFFFF;
++
+ /* Try again */
+ goto realloc;
+ }
+@@ -2152,6 +2157,7 @@ main(int argc,
+ char **args; /* Command arguments */
+ int count; /* Number of arguments */
+ const iwlist_cmd *iwcmd;
++ int goterr = 0;
+
+ if(argc < 2)
+ iw_usage(1);
+@@ -2199,12 +2205,12 @@ main(int argc,
+
+ /* do the actual work */
+ if (dev)
+- (*iwcmd->fn)(skfd, dev, args, count);
++ goterr = (*iwcmd->fn)(skfd, dev, args, count);
+ else
+ iw_enum_devices(skfd, iwcmd->fn, args, count);
+
+ /* Close the socket. */
+ iw_sockets_close(skfd);
+
+- return 0;
++ return goterr;
+ }
diff --git a/package/network/utils/xtables-addons/.svn/entries b/package/network/utils/xtables-addons/.svn/entries
new file mode 100644
index 0000000..c745c0e
--- /dev/null
+++ b/package/network/utils/xtables-addons/.svn/entries
@@ -0,0 +1,68 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/utils/xtables-addons
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-02-28T10:58:12.328443Z
+35831
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+patches
+dir
+
+patches-1.x
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+16c8b1f857499c324e234b1c2819cb7a
+2013-02-28T10:58:12.328443Z
+35831
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5424
+
diff --git a/package/network/utils/xtables-addons/.svn/text-base/Makefile.svn-base b/package/network/utils/xtables-addons/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..10bafd1
--- /dev/null
+++ b/package/network/utils/xtables-addons/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,160 @@
+#
+# Copyright (C) 2009-2013 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=xtables-addons
+ifeq ($(strip $(call CompareKernelPatchVer,$(KERNEL_PATCHVER),ge,3.7.0)),1)
+PKG_VERSION:=2.1
+PKG_RELEASE:=1
+PKG_MD5SUM:=b624fc57bbda9e15c33a6471e4ec75e1
+else
+PKG_VERSION:=1.45
+PKG_RELEASE:=3
+PKG_MD5SUM:=802d2f556a5e545f44e4b69937bf8490
+PATCH_DIR:=./patches-1.x
+endif
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
+PKG_SOURCE_URL:=@SF/xtables-addons
+PKG_BUILD_DEPENDS:=iptables
+PKG_INSTALL:=1
+PKG_BUILD_PARALLEL:=1
+
+PKG_MAINTAINER:=Jo-Philipp Wich <jow@openwrt.org>
+
+PKG_FIXUP:=autoreconf
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/xtables-addons
+ SECTION:=net
+ CATEGORY:=Network
+ SUBMENU:=Firewall
+ TITLE:=Extensions not distributed in the main Xtables
+ URL:=http://xtables-addons.sourceforge.net/
+endef
+
+# uses GNU configure
+
+CONFIGURE_ARGS+= \
+ --with-kbuild="$(LINUX_DIR)" \
+ --with-xtables="$(STAGING_DIR)/usr" \
+ --with-xtlibdir="/usr/lib/iptables" \
+
+define Build/Compile
+ +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
+ ARCH="$(LINUX_KARCH)" \
+ CROSS_COMPILE="$(TARGET_CROSS)" \
+ DESTDIR="$(PKG_INSTALL_DIR)" \
+ DEPMOD="/bin/true" \
+ all
+endef
+
+define Build/Install
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ ARCH="$(LINUX_KARCH)" \
+ CROSS_COMPILE="$(TARGET_CROSS)" \
+ DESTDIR="$(PKG_INSTALL_DIR)" \
+ DEPMOD="/bin/true" \
+ install
+endef
+
+# 1: extension/module suffix used in package name
+# 2: extension/module display name used in package title/description
+# 3: list of extensions to package
+# 4: list of modules to package
+# 5: module load priority
+# 6: module depends
+define BuildTemplate
+
+ ifneq ($(3),)
+ define Package/iptables-mod-$(1)
+ $$(call Package/xtables-addons)
+ CATEGORY:=Network
+ TITLE:=$(2) iptables extension
+ DEPENDS:=iptables $(if $(4),+kmod-ipt-$(1))
+ endef
+
+ define Package/iptables-mod-$(1)/install
+ $(INSTALL_DIR) $$(1)/usr/lib/iptables
+ for m in $(3); do \
+ $(CP) \
+ $(PKG_INSTALL_DIR)/usr/lib/iptables/lib$$$$$$$${m}.so \
+ $$(1)/usr/lib/iptables/ ; \
+ done
+ endef
+
+ $$(eval $$(call BuildPackage,iptables-mod-$(1)))
+ endif
+
+ ifneq ($(4),)
+ define KernelPackage/ipt-$(1)
+ SUBMENU:=Netfilter Extensions
+ TITLE:=$(2) netfilter module
+ DEPENDS:=kmod-ipt-core $(6)
+ KCONFIG:=$(7)
+ FILES:=$(foreach mod,$(4),$(PKG_BUILD_DIR)/extensions/$(mod).$(LINUX_KMOD_SUFFIX))
+ AUTOLOAD:=$(call AutoLoad,$(5),$(notdir $(4)))
+ endef
+
+ $$(eval $$(call KernelPackage,ipt-$(1)))
+ endif
+
+endef
+
+
+define Package/iptaccount
+ $(call Package/xtables-addons)
+ CATEGORY:=Network
+ TITLE:=iptables-mod-account control utility
+ DEPENDS:=iptables +iptables-mod-account
+endef
+
+define Package/iptaccount/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(CP) \
+ $(PKG_INSTALL_DIR)/usr/lib/libxt_ACCOUNT_cl.so* \
+ $(1)/usr/lib/
+ $(CP) \
+ $(PKG_INSTALL_DIR)/usr/sbin/iptaccount \
+ $(1)/usr/sbin/
+endef
+
+
+#$(eval $(call BuildTemplate,SUFFIX,DESCRIPTION,EXTENSION,MODULE,PRIORITY,DEPENDS))
+
+$(eval $(call BuildTemplate,compat-xtables,API compatibilty layer,,compat_xtables,45,,CONFIG_NF_CONNTRACK_MARK=y))
+$(eval $(call BuildTemplate,rawpost,RAWPOST,,iptable_rawpost $(if $(CONFIG_IPV6),ip6table_rawpost),50,+kmod-ipt-compat-xtables +IPV6:kmod-ip6tables))
+$(eval $(call BuildTemplate,nathelper-rtsp,RTSP Conntrack and NAT,,rtsp/nf_conntrack_rtsp rtsp/nf_nat_rtsp,46,+kmod-ipt-conntrack-extra))
+
+$(eval $(call BuildTemplate,account,ACCOUNT,xt_ACCOUNT,ACCOUNT/xt_ACCOUNT,46,+kmod-ipt-compat-xtables))
+$(eval $(call BuildTemplate,chaos,CHAOS,xt_CHAOS,xt_CHAOS,47,+kmod-ipt-compat-xtables +kmod-ipt-delude +kmod-ipt-tarpit))
+$(eval $(call BuildTemplate,condition,Condition,xt_condition,xt_condition,46,))
+$(eval $(call BuildTemplate,delude,DELUDE,xt_DELUDE,xt_DELUDE,46,+kmod-ipt-compat-xtables))
+$(eval $(call BuildTemplate,dhcpmac,DHCPMAC,xt_DHCPMAC,xt_DHCPMAC,46,+kmod-ipt-compat-xtables))
+$(eval $(call BuildTemplate,dnetmap,DNETMAP,xt_DNETMAP,xt_DNETMAP,46,+kmod-ipt-compat-xtables))
+$(eval $(call BuildTemplate,fuzzy,fuzzy,xt_fuzzy,xt_fuzzy,46,))
+$(eval $(call BuildTemplate,geoip,geoip,xt_geoip,xt_geoip,46,))
+$(eval $(call BuildTemplate,iface,iface,xt_iface,xt_iface,46,))
+$(eval $(call BuildTemplate,ipmark,IPMARK,xt_IPMARK,xt_IPMARK,46,+kmod-ipt-compat-xtables))
+$(eval $(call BuildTemplate,ipp2p,IPP2P,xt_ipp2p,xt_ipp2p,46,+kmod-ipt-compat-xtables))
+$(eval $(call BuildTemplate,ipv4options,ipv4options,xt_ipv4options,xt_ipv4options,46,))
+$(eval $(call BuildTemplate,length2,length2,xt_length2,xt_length2,46,))
+$(eval $(call BuildTemplate,logmark,LOGMARK,xt_LOGMARK,xt_LOGMARK,46,+kmod-ipt-compat-xtables))
+$(eval $(call BuildTemplate,lscan,lscan,xt_lscan,xt_lscan,46,))
+$(eval $(call BuildTemplate,lua,Lua PacketScript,xt_LUA,LUA/xt_LUA,46,+kmod-ipt-conntrack-extra))
+$(eval $(call BuildTemplate,psd,psd,xt_psd,xt_psd,46,))
+$(eval $(call BuildTemplate,quota2,quota2,xt_quota2,xt_quota2,46,))
+$(eval $(call BuildTemplate,rawnat,RAWNAT,xt_RAWDNAT xt_RAWSNAT,xt_RAWNAT,46,+kmod-ipt-compat-xtables))
+$(eval $(call BuildTemplate,steal,STEAL,xt_STEAL,xt_STEAL,46,+kmod-ipt-compat-xtables))
+$(eval $(call BuildTemplate,sysrq,SYSRQ,xt_SYSRQ,xt_SYSRQ,46,+kmod-ipt-compat-xtables))
+$(eval $(call BuildTemplate,tarpit,TARPIT,xt_TARPIT,xt_TARPIT,46,+kmod-ipt-compat-xtables))
+
+$(eval $(call BuildPackage,iptaccount))
diff --git a/package/network/utils/xtables-addons/Makefile b/package/network/utils/xtables-addons/Makefile
new file mode 100644
index 0000000..10bafd1
--- /dev/null
+++ b/package/network/utils/xtables-addons/Makefile
@@ -0,0 +1,160 @@
+#
+# Copyright (C) 2009-2013 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=xtables-addons
+ifeq ($(strip $(call CompareKernelPatchVer,$(KERNEL_PATCHVER),ge,3.7.0)),1)
+PKG_VERSION:=2.1
+PKG_RELEASE:=1
+PKG_MD5SUM:=b624fc57bbda9e15c33a6471e4ec75e1
+else
+PKG_VERSION:=1.45
+PKG_RELEASE:=3
+PKG_MD5SUM:=802d2f556a5e545f44e4b69937bf8490
+PATCH_DIR:=./patches-1.x
+endif
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
+PKG_SOURCE_URL:=@SF/xtables-addons
+PKG_BUILD_DEPENDS:=iptables
+PKG_INSTALL:=1
+PKG_BUILD_PARALLEL:=1
+
+PKG_MAINTAINER:=Jo-Philipp Wich <jow@openwrt.org>
+
+PKG_FIXUP:=autoreconf
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/xtables-addons
+ SECTION:=net
+ CATEGORY:=Network
+ SUBMENU:=Firewall
+ TITLE:=Extensions not distributed in the main Xtables
+ URL:=http://xtables-addons.sourceforge.net/
+endef
+
+# uses GNU configure
+
+CONFIGURE_ARGS+= \
+ --with-kbuild="$(LINUX_DIR)" \
+ --with-xtables="$(STAGING_DIR)/usr" \
+ --with-xtlibdir="/usr/lib/iptables" \
+
+define Build/Compile
+ +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
+ ARCH="$(LINUX_KARCH)" \
+ CROSS_COMPILE="$(TARGET_CROSS)" \
+ DESTDIR="$(PKG_INSTALL_DIR)" \
+ DEPMOD="/bin/true" \
+ all
+endef
+
+define Build/Install
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ ARCH="$(LINUX_KARCH)" \
+ CROSS_COMPILE="$(TARGET_CROSS)" \
+ DESTDIR="$(PKG_INSTALL_DIR)" \
+ DEPMOD="/bin/true" \
+ install
+endef
+
+# 1: extension/module suffix used in package name
+# 2: extension/module display name used in package title/description
+# 3: list of extensions to package
+# 4: list of modules to package
+# 5: module load priority
+# 6: module depends
+define BuildTemplate
+
+ ifneq ($(3),)
+ define Package/iptables-mod-$(1)
+ $$(call Package/xtables-addons)
+ CATEGORY:=Network
+ TITLE:=$(2) iptables extension
+ DEPENDS:=iptables $(if $(4),+kmod-ipt-$(1))
+ endef
+
+ define Package/iptables-mod-$(1)/install
+ $(INSTALL_DIR) $$(1)/usr/lib/iptables
+ for m in $(3); do \
+ $(CP) \
+ $(PKG_INSTALL_DIR)/usr/lib/iptables/lib$$$$$$$${m}.so \
+ $$(1)/usr/lib/iptables/ ; \
+ done
+ endef
+
+ $$(eval $$(call BuildPackage,iptables-mod-$(1)))
+ endif
+
+ ifneq ($(4),)
+ define KernelPackage/ipt-$(1)
+ SUBMENU:=Netfilter Extensions
+ TITLE:=$(2) netfilter module
+ DEPENDS:=kmod-ipt-core $(6)
+ KCONFIG:=$(7)
+ FILES:=$(foreach mod,$(4),$(PKG_BUILD_DIR)/extensions/$(mod).$(LINUX_KMOD_SUFFIX))
+ AUTOLOAD:=$(call AutoLoad,$(5),$(notdir $(4)))
+ endef
+
+ $$(eval $$(call KernelPackage,ipt-$(1)))
+ endif
+
+endef
+
+
+define Package/iptaccount
+ $(call Package/xtables-addons)
+ CATEGORY:=Network
+ TITLE:=iptables-mod-account control utility
+ DEPENDS:=iptables +iptables-mod-account
+endef
+
+define Package/iptaccount/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(CP) \
+ $(PKG_INSTALL_DIR)/usr/lib/libxt_ACCOUNT_cl.so* \
+ $(1)/usr/lib/
+ $(CP) \
+ $(PKG_INSTALL_DIR)/usr/sbin/iptaccount \
+ $(1)/usr/sbin/
+endef
+
+
+#$(eval $(call BuildTemplate,SUFFIX,DESCRIPTION,EXTENSION,MODULE,PRIORITY,DEPENDS))
+
+$(eval $(call BuildTemplate,compat-xtables,API compatibilty layer,,compat_xtables,45,,CONFIG_NF_CONNTRACK_MARK=y))
+$(eval $(call BuildTemplate,rawpost,RAWPOST,,iptable_rawpost $(if $(CONFIG_IPV6),ip6table_rawpost),50,+kmod-ipt-compat-xtables +IPV6:kmod-ip6tables))
+$(eval $(call BuildTemplate,nathelper-rtsp,RTSP Conntrack and NAT,,rtsp/nf_conntrack_rtsp rtsp/nf_nat_rtsp,46,+kmod-ipt-conntrack-extra))
+
+$(eval $(call BuildTemplate,account,ACCOUNT,xt_ACCOUNT,ACCOUNT/xt_ACCOUNT,46,+kmod-ipt-compat-xtables))
+$(eval $(call BuildTemplate,chaos,CHAOS,xt_CHAOS,xt_CHAOS,47,+kmod-ipt-compat-xtables +kmod-ipt-delude +kmod-ipt-tarpit))
+$(eval $(call BuildTemplate,condition,Condition,xt_condition,xt_condition,46,))
+$(eval $(call BuildTemplate,delude,DELUDE,xt_DELUDE,xt_DELUDE,46,+kmod-ipt-compat-xtables))
+$(eval $(call BuildTemplate,dhcpmac,DHCPMAC,xt_DHCPMAC,xt_DHCPMAC,46,+kmod-ipt-compat-xtables))
+$(eval $(call BuildTemplate,dnetmap,DNETMAP,xt_DNETMAP,xt_DNETMAP,46,+kmod-ipt-compat-xtables))
+$(eval $(call BuildTemplate,fuzzy,fuzzy,xt_fuzzy,xt_fuzzy,46,))
+$(eval $(call BuildTemplate,geoip,geoip,xt_geoip,xt_geoip,46,))
+$(eval $(call BuildTemplate,iface,iface,xt_iface,xt_iface,46,))
+$(eval $(call BuildTemplate,ipmark,IPMARK,xt_IPMARK,xt_IPMARK,46,+kmod-ipt-compat-xtables))
+$(eval $(call BuildTemplate,ipp2p,IPP2P,xt_ipp2p,xt_ipp2p,46,+kmod-ipt-compat-xtables))
+$(eval $(call BuildTemplate,ipv4options,ipv4options,xt_ipv4options,xt_ipv4options,46,))
+$(eval $(call BuildTemplate,length2,length2,xt_length2,xt_length2,46,))
+$(eval $(call BuildTemplate,logmark,LOGMARK,xt_LOGMARK,xt_LOGMARK,46,+kmod-ipt-compat-xtables))
+$(eval $(call BuildTemplate,lscan,lscan,xt_lscan,xt_lscan,46,))
+$(eval $(call BuildTemplate,lua,Lua PacketScript,xt_LUA,LUA/xt_LUA,46,+kmod-ipt-conntrack-extra))
+$(eval $(call BuildTemplate,psd,psd,xt_psd,xt_psd,46,))
+$(eval $(call BuildTemplate,quota2,quota2,xt_quota2,xt_quota2,46,))
+$(eval $(call BuildTemplate,rawnat,RAWNAT,xt_RAWDNAT xt_RAWSNAT,xt_RAWNAT,46,+kmod-ipt-compat-xtables))
+$(eval $(call BuildTemplate,steal,STEAL,xt_STEAL,xt_STEAL,46,+kmod-ipt-compat-xtables))
+$(eval $(call BuildTemplate,sysrq,SYSRQ,xt_SYSRQ,xt_SYSRQ,46,+kmod-ipt-compat-xtables))
+$(eval $(call BuildTemplate,tarpit,TARPIT,xt_TARPIT,xt_TARPIT,46,+kmod-ipt-compat-xtables))
+
+$(eval $(call BuildPackage,iptaccount))
diff --git a/package/network/utils/xtables-addons/patches-1.x/.svn/entries b/package/network/utils/xtables-addons/patches-1.x/.svn/entries
new file mode 100644
index 0000000..24d3fb8
--- /dev/null
+++ b/package/network/utils/xtables-addons/patches-1.x/.svn/entries
@@ -0,0 +1,300 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/utils/xtables-addons/patches-1.x
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-12-29T16:45:40.527444Z
+34921
+juhosg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+001-no_depmod.patch
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+a6181179fc21396ed4bf10271171fbe6
+2012-12-29T16:45:40.527444Z
+34921
+juhosg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+308
+
+002-fix-kernel-version-detection.patch
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+214ae71f9652686a062f342f215a922e
+2012-12-29T16:45:40.527444Z
+34921
+juhosg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+892
+
+101-rtsp-linux-3.6-compat.patch
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+3362b293109c48451514a8605a90b855
+2012-12-29T16:45:40.527444Z
+34921
+juhosg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+520
+
+300-geoip-endian-detection.patch
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+d5908fec20ffc0a5a999d9291aa64263
+2012-12-29T16:45:40.527444Z
+34921
+juhosg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+613
+
+100-add-rtsp-conntrack.patch
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+235725857f305c562462d2a07d59e2f7
+2012-12-29T16:45:40.527444Z
+34921
+juhosg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+39249
+
+003-redundant-bracket.patch
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+9876ee2e46225a22cbf40dc78286bc95
+2012-12-29T16:45:40.527444Z
+34921
+juhosg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+388
+
+201-fix-lua-packetscript.patch
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+26fe3500a0e2b0cc7321c5edd3a4f89b
+2012-12-29T16:45:40.527444Z
+34921
+juhosg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2108
+
+200-add-lua-packetscript.patch
+file
+
+
+
+
+2013-03-17T12:13:17.000000Z
+3255b20b8eb10455c9964f5ea972d309
+2012-12-29T16:45:40.527444Z
+34921
+juhosg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+527328
+
diff --git a/package/network/utils/xtables-addons/patches-1.x/.svn/text-base/001-no_depmod.patch.svn-base b/package/network/utils/xtables-addons/patches-1.x/.svn/text-base/001-no_depmod.patch.svn-base
new file mode 100644
index 0000000..9905af1
--- /dev/null
+++ b/package/network/utils/xtables-addons/patches-1.x/.svn/text-base/001-no_depmod.patch.svn-base
@@ -0,0 +1,16 @@
+---
+ Makefile.in | 3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -11,9 +11,6 @@ FORCE:
+ xtables-addons.8: FORCE
+ ${MAKE} -f Makefile.mans all;
+
+-install-exec-hook:
+- depmod -a || :;
+-
+ config.status: Makefile.iptrules.in
+
+ tmpdir := $(shell mktemp -dtu)
diff --git a/package/network/utils/xtables-addons/patches-1.x/.svn/text-base/002-fix-kernel-version-detection.patch.svn-base b/package/network/utils/xtables-addons/patches-1.x/.svn/text-base/002-fix-kernel-version-detection.patch.svn-base
new file mode 100644
index 0000000..b31f9f1
--- /dev/null
+++ b/package/network/utils/xtables-addons/patches-1.x/.svn/text-base/002-fix-kernel-version-detection.patch.svn-base
@@ -0,0 +1,22 @@
+--- a/configure
++++ b/configure
+@@ -11780,7 +11780,7 @@ regular_CFLAGS="-Wall -Waggregate-return
+ if test -n "$kbuilddir"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking kernel version that we will build against" >&5
+ $as_echo_n "checking kernel version that we will build against... " >&6; }
+- krel="$(make -sC "$kbuilddir" M=$PWD kernelrelease)";
++ krel="$(make -sC "$kbuilddir" M=$PWD kernelversion)";
+ kmajor="${krel%%[^0-9]*}";
+ kmajor="$(($kmajor+0))";
+ krel="${krel:${#kmajor}}";
+--- a/configure.ac
++++ b/configure.ac
+@@ -44,7 +44,7 @@ regular_CFLAGS="-Wall -Waggregate-return
+
+ if test -n "$kbuilddir"; then
+ AC_MSG_CHECKING([kernel version that we will build against])
+- krel="$(make -sC "$kbuilddir" M=$PWD kernelrelease)";
++ krel="$(make -sC "$kbuilddir" M=$PWD kernelversion)";
+ kmajor="${krel%%[[^0-9]]*}";
+ kmajor="$(($kmajor+0))";
+ krel="${krel:${#kmajor}}";
diff --git a/package/network/utils/xtables-addons/patches-1.x/.svn/text-base/003-redundant-bracket.patch.svn-base b/package/network/utils/xtables-addons/patches-1.x/.svn/text-base/003-redundant-bracket.patch.svn-base
new file mode 100644
index 0000000..ae3911a
--- /dev/null
+++ b/package/network/utils/xtables-addons/patches-1.x/.svn/text-base/003-redundant-bracket.patch.svn-base
@@ -0,0 +1,11 @@
+--- a/configure.ac
++++ b/configure.ac
+@@ -31,7 +31,7 @@ xtlibdir="$(pkg-config --variable=xtlibd
+
+ AC_ARG_WITH([xtlibdir],
+ AS_HELP_STRING([--with-xtlibdir=PATH],
+- [Path where to install Xtables extensions [[autodetect]]]]),
++ [Path where to install Xtables extensions [[autodetect]]]),
+ [xtlibdir="$withval"])
+ AC_MSG_CHECKING([Xtables module directory])
+ AC_MSG_RESULT([$xtlibdir])
diff --git a/package/network/utils/xtables-addons/patches-1.x/.svn/text-base/100-add-rtsp-conntrack.patch.svn-base b/package/network/utils/xtables-addons/patches-1.x/.svn/text-base/100-add-rtsp-conntrack.patch.svn-base
new file mode 100644
index 0000000..34cdc8c
--- /dev/null
+++ b/package/network/utils/xtables-addons/patches-1.x/.svn/text-base/100-add-rtsp-conntrack.patch.svn-base
@@ -0,0 +1,1334 @@
+--- /dev/null
++++ b/extensions/rtsp/Kbuild
+@@ -0,0 +1,4 @@
++# -*- Makefile -*-
++
++obj-m += nf_nat_rtsp.o
++obj-m += nf_conntrack_rtsp.o
+--- /dev/null
++++ b/extensions/rtsp/netfilter_helpers.h
+@@ -0,0 +1,133 @@
++/*
++ * Helpers for netfiler modules. This file provides implementations for basic
++ * functions such as strncasecmp(), etc.
++ *
++ * gcc will warn for defined but unused functions, so we only include the
++ * functions requested. The following macros are used:
++ * NF_NEED_STRNCASECMP nf_strncasecmp()
++ * NF_NEED_STRTOU16 nf_strtou16()
++ * NF_NEED_STRTOU32 nf_strtou32()
++ */
++#ifndef _NETFILTER_HELPERS_H
++#define _NETFILTER_HELPERS_H
++
++/* Only include these functions for kernel code. */
++#ifdef __KERNEL__
++
++#include <linux/ctype.h>
++#define iseol(c) ( (c) == '\r' || (c) == '\n' )
++
++/*
++ * The standard strncasecmp()
++ */
++#ifdef NF_NEED_STRNCASECMP
++static int
++nf_strncasecmp(const char* s1, const char* s2, u_int32_t len)
++{
++ if (s1 == NULL || s2 == NULL)
++ {
++ if (s1 == NULL && s2 == NULL)
++ {
++ return 0;
++ }
++ return (s1 == NULL) ? -1 : 1;
++ }
++ while (len > 0 && tolower(*s1) == tolower(*s2))
++ {
++ len--;
++ s1++;
++ s2++;
++ }
++ return ( (len == 0) ? 0 : (tolower(*s1) - tolower(*s2)) );
++}
++#endif /* NF_NEED_STRNCASECMP */
++
++/*
++ * Parse a string containing a 16-bit unsigned integer.
++ * Returns the number of chars used, or zero if no number is found.
++ */
++#ifdef NF_NEED_STRTOU16
++static int
++nf_strtou16(const char* pbuf, u_int16_t* pval)
++{
++ int n = 0;
++
++ *pval = 0;
++ while (isdigit(pbuf[n]))
++ {
++ *pval = (*pval * 10) + (pbuf[n] - '0');
++ n++;
++ }
++
++ return n;
++}
++#endif /* NF_NEED_STRTOU16 */
++
++/*
++ * Parse a string containing a 32-bit unsigned integer.
++ * Returns the number of chars used, or zero if no number is found.
++ */
++#ifdef NF_NEED_STRTOU32
++static int
++nf_strtou32(const char* pbuf, u_int32_t* pval)
++{
++ int n = 0;
++
++ *pval = 0;
++ while (pbuf[n] >= '0' && pbuf[n] <= '9')
++ {
++ *pval = (*pval * 10) + (pbuf[n] - '0');
++ n++;
++ }
++
++ return n;
++}
++#endif /* NF_NEED_STRTOU32 */
++
++/*
++ * Given a buffer and length, advance to the next line and mark the current
++ * line.
++ */
++#ifdef NF_NEED_NEXTLINE
++static int
++nf_nextline(char* p, uint len, uint* poff, uint* plineoff, uint* plinelen)
++{
++ uint off = *poff;
++ uint physlen = 0;
++
++ if (off >= len)
++ {
++ return 0;
++ }
++
++ while (p[off] != '\n')
++ {
++ if (len-off <= 1)
++ {
++ return 0;
++ }
++
++ physlen++;
++ off++;
++ }
++
++ /* if we saw a crlf, physlen needs adjusted */
++ if (physlen > 0 && p[off] == '\n' && p[off-1] == '\r')
++ {
++ physlen--;
++ }
++
++ /* advance past the newline */
++ off++;
++
++ *plineoff = *poff;
++ *plinelen = physlen;
++ *poff = off;
++
++ return 1;
++}
++#endif /* NF_NEED_NEXTLINE */
++
++#endif /* __KERNEL__ */
++
++#endif /* _NETFILTER_HELPERS_H */
+--- /dev/null
++++ b/extensions/rtsp/netfilter_mime.h
+@@ -0,0 +1,89 @@
++/*
++ * MIME functions for netfilter modules. This file provides implementations
++ * for basic MIME parsing. MIME headers are used in many protocols, such as
++ * HTTP, RTSP, SIP, etc.
++ *
++ * gcc will warn for defined but unused functions, so we only include the
++ * functions requested. The following macros are used:
++ * NF_NEED_MIME_NEXTLINE nf_mime_nextline()
++ */
++#ifndef _NETFILTER_MIME_H
++#define _NETFILTER_MIME_H
++
++/* Only include these functions for kernel code. */
++#ifdef __KERNEL__
++
++#include <linux/ctype.h>
++
++/*
++ * Given a buffer and length, advance to the next line and mark the current
++ * line. If the current line is empty, *plinelen will be set to zero. If
++ * not, it will be set to the actual line length (including CRLF).
++ *
++ * 'line' in this context means logical line (includes LWS continuations).
++ * Returns 1 on success, 0 on failure.
++ */
++#ifdef NF_NEED_MIME_NEXTLINE
++static int
++nf_mime_nextline(char* p, uint len, uint* poff, uint* plineoff, uint* plinelen)
++{
++ uint off = *poff;
++ uint physlen = 0;
++ int is_first_line = 1;
++
++ if (off >= len)
++ {
++ return 0;
++ }
++
++ do
++ {
++ while (p[off] != '\n')
++ {
++ if (len-off <= 1)
++ {
++ return 0;
++ }
++
++ physlen++;
++ off++;
++ }
++
++ /* if we saw a crlf, physlen needs adjusted */
++ if (physlen > 0 && p[off] == '\n' && p[off-1] == '\r')
++ {
++ physlen--;
++ }
++
++ /* advance past the newline */
++ off++;
++
++ /* check for an empty line */
++ if (physlen == 0)
++ {
++ break;
++ }
++
++ /* check for colon on the first physical line */
++ if (is_first_line)
++ {
++ is_first_line = 0;
++ if (memchr(p+(*poff), ':', physlen) == NULL)
++ {
++ return 0;
++ }
++ }
++ }
++ while (p[off] == ' ' || p[off] == '\t');
++
++ *plineoff = *poff;
++ *plinelen = (physlen == 0) ? 0 : (off - *poff);
++ *poff = off;
++
++ return 1;
++}
++#endif /* NF_NEED_MIME_NEXTLINE */
++
++#endif /* __KERNEL__ */
++
++#endif /* _NETFILTER_MIME_H */
+--- /dev/null
++++ b/extensions/rtsp/nf_conntrack_rtsp.c
+@@ -0,0 +1,519 @@
++/*
++ * RTSP extension for IP connection tracking
++ * (C) 2003 by Tom Marshall <tmarshall at real.com>
++ * based on ip_conntrack_irc.c
++ *
++ * 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 of the License, or (at your option) any later version.
++ *
++ * Module load syntax:
++ * insmod nf_conntrack_rtsp.o ports=port1,port2,...port<MAX_PORTS>
++ * max_outstanding=n setup_timeout=secs
++ *
++ * If no ports are specified, the default will be port 554.
++ *
++ * With max_outstanding you can define the maximum number of not yet
++ * answered SETUP requests per RTSP session (default 8).
++ * With setup_timeout you can specify how long the system waits for
++ * an expected data channel (default 300 seconds).
++ *
++ * 2005-02-13: Harald Welte <laforge at netfilter.org>
++ * - port to 2.6
++ * - update to recent post-2.6.11 api changes
++ * 2006-09-14: Steven Van Acker <deepstar at singularity.be>
++ * - removed calls to NAT code from conntrack helper: NAT no longer needed to use rtsp-conntrack
++ * 2007-04-18: Michael Guntsche <mike at it-loops.com>
++ * - Port to new NF API
++ */
++
++#include <linux/module.h>
++#include <linux/netfilter.h>
++#include <linux/ip.h>
++#include <linux/inet.h>
++#include <net/tcp.h>
++
++#include <net/netfilter/nf_conntrack.h>
++#include <net/netfilter/nf_conntrack_expect.h>
++#include <net/netfilter/nf_conntrack_helper.h>
++#include "nf_conntrack_rtsp.h"
++
++#define NF_NEED_STRNCASECMP
++#define NF_NEED_STRTOU16
++#define NF_NEED_STRTOU32
++#define NF_NEED_NEXTLINE
++#include "netfilter_helpers.h"
++#define NF_NEED_MIME_NEXTLINE
++#include "netfilter_mime.h"
++
++#include <linux/ctype.h>
++#define MAX_SIMUL_SETUP 8 /* XXX: use max_outstanding */
++
++#define MAX_PORTS 8
++static int ports[MAX_PORTS];
++static int num_ports = 0;
++static int max_outstanding = 8;
++static unsigned int setup_timeout = 300;
++
++MODULE_AUTHOR("Tom Marshall <tmarshall at real.com>");
++MODULE_DESCRIPTION("RTSP connection tracking module");
++MODULE_LICENSE("GPL");
++module_param_array(ports, int, &num_ports, 0400);
++MODULE_PARM_DESC(ports, "port numbers of RTSP servers");
++module_param(max_outstanding, int, 0400);
++MODULE_PARM_DESC(max_outstanding, "max number of outstanding SETUP requests per RTSP session");
++module_param(setup_timeout, int, 0400);
++MODULE_PARM_DESC(setup_timeout, "timeout on for unestablished data channels");
++
++static char *rtsp_buffer;
++static DEFINE_SPINLOCK(rtsp_buffer_lock);
++
++static struct nf_conntrack_expect_policy rtsp_exp_policy;
++
++unsigned int (*nf_nat_rtsp_hook)(struct sk_buff *skb,
++ enum ip_conntrack_info ctinfo,
++ unsigned int matchoff, unsigned int matchlen,struct ip_ct_rtsp_expect* prtspexp,
++ struct nf_conntrack_expect *exp);
++void (*nf_nat_rtsp_hook_expectfn)(struct nf_conn *ct, struct nf_conntrack_expect *exp);
++
++EXPORT_SYMBOL_GPL(nf_nat_rtsp_hook);
++
++/*
++ * Max mappings we will allow for one RTSP connection (for RTP, the number
++ * of allocated ports is twice this value). Note that SMIL burns a lot of
++ * ports so keep this reasonably high. If this is too low, you will see a
++ * lot of "no free client map entries" messages.
++ */
++#define MAX_PORT_MAPS 16
++
++/*** default port list was here in the masq code: 554, 3030, 4040 ***/
++
++#define SKIP_WSPACE(ptr,len,off) while(off < len && isspace(*(ptr+off))) { off++; }
++
++/*
++ * Parse an RTSP packet.
++ *
++ * Returns zero if parsing failed.
++ *
++ * Parameters:
++ * IN ptcp tcp data pointer
++ * IN tcplen tcp data len
++ * IN/OUT ptcpoff points to current tcp offset
++ * OUT phdrsoff set to offset of rtsp headers
++ * OUT phdrslen set to length of rtsp headers
++ * OUT pcseqoff set to offset of CSeq header
++ * OUT pcseqlen set to length of CSeq header
++ */
++static int
++rtsp_parse_message(char* ptcp, uint tcplen, uint* ptcpoff,
++ uint* phdrsoff, uint* phdrslen,
++ uint* pcseqoff, uint* pcseqlen,
++ uint* transoff, uint* translen)
++{
++ uint entitylen = 0;
++ uint lineoff;
++ uint linelen;
++
++ if (!nf_nextline(ptcp, tcplen, ptcpoff, &lineoff, &linelen))
++ return 0;
++
++ *phdrsoff = *ptcpoff;
++ while (nf_mime_nextline(ptcp, tcplen, ptcpoff, &lineoff, &linelen)) {
++ if (linelen == 0) {
++ if (entitylen > 0)
++ *ptcpoff += min(entitylen, tcplen - *ptcpoff);
++ break;
++ }
++ if (lineoff+linelen > tcplen) {
++ pr_info("!! overrun !!\n");
++ break;
++ }
++
++ if (nf_strncasecmp(ptcp+lineoff, "CSeq:", 5) == 0) {
++ *pcseqoff = lineoff;
++ *pcseqlen = linelen;
++ }
++
++ if (nf_strncasecmp(ptcp+lineoff, "Transport:", 10) == 0) {
++ *transoff = lineoff;
++ *translen = linelen;
++ }
++
++ if (nf_strncasecmp(ptcp+lineoff, "Content-Length:", 15) == 0) {
++ uint off = lineoff+15;
++ SKIP_WSPACE(ptcp+lineoff, linelen, off);
++ nf_strtou32(ptcp+off, &entitylen);
++ }
++ }
++ *phdrslen = (*ptcpoff) - (*phdrsoff);
++
++ return 1;
++}
++
++/*
++ * Find lo/hi client ports (if any) in transport header
++ * In:
++ * ptcp, tcplen = packet
++ * tranoff, tranlen = buffer to search
++ *
++ * Out:
++ * pport_lo, pport_hi = lo/hi ports (host endian)
++ *
++ * Returns nonzero if any client ports found
++ *
++ * Note: it is valid (and expected) for the client to request multiple
++ * transports, so we need to parse the entire line.
++ */
++static int
++rtsp_parse_transport(char* ptran, uint tranlen,
++ struct ip_ct_rtsp_expect* prtspexp)
++{
++ int rc = 0;
++ uint off = 0;
++
++ if (tranlen < 10 || !iseol(ptran[tranlen-1]) ||
++ nf_strncasecmp(ptran, "Transport:", 10) != 0) {
++ pr_info("sanity check failed\n");
++ return 0;
++ }
++
++ pr_debug("tran='%.*s'\n", (int)tranlen, ptran);
++ off += 10;
++ SKIP_WSPACE(ptran, tranlen, off);
++
++ /* Transport: tran;field;field=val,tran;field;field=val,... */
++ while (off < tranlen) {
++ const char* pparamend;
++ uint nextparamoff;
++
++ pparamend = memchr(ptran+off, ',', tranlen-off);
++ pparamend = (pparamend == NULL) ? ptran+tranlen : pparamend+1;
++ nextparamoff = pparamend-ptran;
++
++ while (off < nextparamoff) {
++ const char* pfieldend;
++ uint nextfieldoff;
++
++ pfieldend = memchr(ptran+off, ';', nextparamoff-off);
++ nextfieldoff = (pfieldend == NULL) ? nextparamoff : pfieldend-ptran+1;
++
++ if (strncmp(ptran+off, "client_port=", 12) == 0) {
++ u_int16_t port;
++ uint numlen;
++
++ off += 12;
++ numlen = nf_strtou16(ptran+off, &port);
++ off += numlen;
++ if (prtspexp->loport != 0 && prtspexp->loport != port)
++ pr_debug("multiple ports found, port %hu ignored\n", port);
++ else {
++ pr_debug("lo port found : %hu\n", port);
++ prtspexp->loport = prtspexp->hiport = port;
++ if (ptran[off] == '-') {
++ off++;
++ numlen = nf_strtou16(ptran+off, &port);
++ off += numlen;
++ prtspexp->pbtype = pb_range;
++ prtspexp->hiport = port;
++
++ // If we have a range, assume rtp:
++ // loport must be even, hiport must be loport+1
++ if ((prtspexp->loport & 0x0001) != 0 ||
++ prtspexp->hiport != prtspexp->loport+1) {
++ pr_debug("incorrect range: %hu-%hu, correcting\n",
++ prtspexp->loport, prtspexp->hiport);
++ prtspexp->loport &= 0xfffe;
++ prtspexp->hiport = prtspexp->loport+1;
++ }
++ } else if (ptran[off] == '/') {
++ off++;
++ numlen = nf_strtou16(ptran+off, &port);
++ off += numlen;
++ prtspexp->pbtype = pb_discon;
++ prtspexp->hiport = port;
++ }
++ rc = 1;
++ }
++ }
++
++ /*
++ * Note we don't look for the destination parameter here.
++ * If we are using NAT, the NAT module will handle it. If not,
++ * and the client is sending packets elsewhere, the expectation
++ * will quietly time out.
++ */
++
++ off = nextfieldoff;
++ }
++
++ off = nextparamoff;
++ }
++
++ return rc;
++}
++
++void expected(struct nf_conn *ct, struct nf_conntrack_expect *exp)
++{
++ typeof(nf_nat_rtsp_hook_expectfn) nf_nat_rtsp_expectfn;
++ nf_nat_rtsp_expectfn = rcu_dereference(nf_nat_rtsp_hook_expectfn);
++ if(nf_nat_rtsp_expectfn && ct->master->status & IPS_NAT_MASK) {
++ nf_nat_rtsp_expectfn(ct,exp);
++ }
++}
++
++/*** conntrack functions ***/
++
++/* outbound packet: client->server */
++
++static inline int
++help_out(struct sk_buff *skb, unsigned char *rb_ptr, unsigned int datalen,
++ struct nf_conn *ct, enum ip_conntrack_info ctinfo)
++{
++ struct ip_ct_rtsp_expect expinfo;
++
++ int dir = CTINFO2DIR(ctinfo); /* = IP_CT_DIR_ORIGINAL */
++ //struct tcphdr* tcph = (void*)iph + iph->ihl * 4;
++ //uint tcplen = pktlen - iph->ihl * 4;
++ char* pdata = rb_ptr;
++ //uint datalen = tcplen - tcph->doff * 4;
++ uint dataoff = 0;
++ int ret = NF_ACCEPT;
++
++ struct nf_conntrack_expect *exp;
++
++ __be16 be_loport;
++
++ typeof(nf_nat_rtsp_hook) nf_nat_rtsp;
++
++ memset(&expinfo, 0, sizeof(expinfo));
++
++ while (dataoff < datalen) {
++ uint cmdoff = dataoff;
++ uint hdrsoff = 0;
++ uint hdrslen = 0;
++ uint cseqoff = 0;
++ uint cseqlen = 0;
++ uint transoff = 0;
++ uint translen = 0;
++ uint off;
++
++ if (!rtsp_parse_message(pdata, datalen, &dataoff,
++ &hdrsoff, &hdrslen,
++ &cseqoff, &cseqlen,
++ &transoff, &translen))
++ break; /* not a valid message */
++
++ if (strncmp(pdata+cmdoff, "SETUP ", 6) != 0)
++ continue; /* not a SETUP message */
++ pr_debug("found a setup message\n");
++
++ off = 0;
++ if(translen) {
++ rtsp_parse_transport(pdata+transoff, translen, &expinfo);
++ }
++
++ if (expinfo.loport == 0) {
++ pr_debug("no udp transports found\n");
++ continue; /* no udp transports found */
++ }
++
++ pr_debug("udp transport found, ports=(%d,%hu,%hu)\n",
++ (int)expinfo.pbtype, expinfo.loport, expinfo.hiport);
++
++ exp = nf_ct_expect_alloc(ct);
++ if (!exp) {
++ ret = NF_DROP;
++ goto out;
++ }
++
++ be_loport = htons(expinfo.loport);
++
++ nf_ct_expect_init(exp, NF_CT_EXPECT_CLASS_DEFAULT, nf_ct_l3num(ct),
++ &ct->tuplehash[!dir].tuple.src.u3, &ct->tuplehash[!dir].tuple.dst.u3,
++ IPPROTO_UDP, NULL, &be_loport);
++
++ exp->master = ct;
++
++ exp->expectfn = expected;
++ exp->flags = 0;
++
++ if (expinfo.pbtype == pb_range) {
++ pr_debug("Changing expectation mask to handle multiple ports\n");
++ //exp->mask.dst.u.udp.port = 0xfffe;
++ }
++
++ pr_debug("expect_related %pI4:%u-%pI4:%u\n",
++ &exp->tuple.src.u3.ip,
++ ntohs(exp->tuple.src.u.udp.port),
++ &exp->tuple.dst.u3.ip,
++ ntohs(exp->tuple.dst.u.udp.port));
++
++ nf_nat_rtsp = rcu_dereference(nf_nat_rtsp_hook);
++ if (nf_nat_rtsp && ct->status & IPS_NAT_MASK)
++ /* pass the request off to the nat helper */
++ ret = nf_nat_rtsp(skb, ctinfo, hdrsoff, hdrslen, &expinfo, exp);
++ else if (nf_ct_expect_related(exp) != 0) {
++ pr_info("nf_conntrack_expect_related failed\n");
++ ret = NF_DROP;
++ }
++ nf_ct_expect_put(exp);
++ goto out;
++ }
++out:
++
++ return ret;
++}
++
++
++static inline int
++help_in(struct sk_buff *skb, size_t pktlen,
++ struct nf_conn* ct, enum ip_conntrack_info ctinfo)
++{
++ return NF_ACCEPT;
++}
++
++static int help(struct sk_buff *skb, unsigned int protoff,
++ struct nf_conn *ct, enum ip_conntrack_info ctinfo)
++{
++ struct tcphdr _tcph, *th;
++ unsigned int dataoff, datalen;
++ char *rb_ptr;
++ int ret = NF_DROP;
++
++ /* Until there's been traffic both ways, don't look in packets. */
++ if (ctinfo != IP_CT_ESTABLISHED &&
++ ctinfo != IP_CT_ESTABLISHED + IP_CT_IS_REPLY) {
++ pr_debug("conntrackinfo = %u\n", ctinfo);
++ return NF_ACCEPT;
++ }
++
++ /* Not whole TCP header? */
++ th = skb_header_pointer(skb,protoff, sizeof(_tcph), &_tcph);
++
++ if (!th)
++ return NF_ACCEPT;
++
++ /* No data ? */
++ dataoff = protoff + th->doff*4;
++ datalen = skb->len - dataoff;
++ if (dataoff >= skb->len)
++ return NF_ACCEPT;
++
++ spin_lock_bh(&rtsp_buffer_lock);
++ rb_ptr = skb_header_pointer(skb, dataoff,
++ skb->len - dataoff, rtsp_buffer);
++ BUG_ON(rb_ptr == NULL);
++
++#if 0
++ /* Checksum invalid? Ignore. */
++ /* FIXME: Source route IP option packets --RR */
++ if (tcp_v4_check(tcph, tcplen, iph->saddr, iph->daddr,
++ csum_partial((char*)tcph, tcplen, 0)))
++ {
++ DEBUGP("bad csum: %p %u %u.%u.%u.%u %u.%u.%u.%u\n",
++ tcph, tcplen, NIPQUAD(iph->saddr), NIPQUAD(iph->daddr));
++ return NF_ACCEPT;
++ }
++#endif
++
++ switch (CTINFO2DIR(ctinfo)) {
++ case IP_CT_DIR_ORIGINAL:
++ ret = help_out(skb, rb_ptr, datalen, ct, ctinfo);
++ break;
++ case IP_CT_DIR_REPLY:
++ pr_debug("IP_CT_DIR_REPLY\n");
++ /* inbound packet: server->client */
++ ret = NF_ACCEPT;
++ break;
++ }
++
++ spin_unlock_bh(&rtsp_buffer_lock);
++
++ return ret;
++}
++
++static struct nf_conntrack_helper rtsp_helpers[MAX_PORTS];
++static char rtsp_names[MAX_PORTS][10];
++
++/* This function is intentionally _NOT_ defined as __exit */
++static void
++fini(void)
++{
++ int i;
++ for (i = 0; i < num_ports; i++) {
++ pr_debug("unregistering port %d\n", ports[i]);
++ nf_conntrack_helper_unregister(&rtsp_helpers[i]);
++ }
++ kfree(rtsp_buffer);
++}
++
++static int __init
++init(void)
++{
++ int i, ret;
++ struct nf_conntrack_helper *hlpr;
++ char *tmpname;
++
++ printk("nf_conntrack_rtsp v" IP_NF_RTSP_VERSION " loading\n");
++
++ if (max_outstanding < 1) {
++ printk("nf_conntrack_rtsp: max_outstanding must be a positive integer\n");
++ return -EBUSY;
++ }
++ if (setup_timeout < 0) {
++ printk("nf_conntrack_rtsp: setup_timeout must be a positive integer\n");
++ return -EBUSY;
++ }
++
++ rtsp_exp_policy.max_expected = max_outstanding;
++ rtsp_exp_policy.timeout = setup_timeout;
++
++ rtsp_buffer = kmalloc(65536, GFP_KERNEL);
++ if (!rtsp_buffer)
++ return -ENOMEM;
++
++ /* If no port given, default to standard rtsp port */
++ if (ports[0] == 0) {
++ ports[0] = RTSP_PORT;
++ }
++
++ for (i = 0; (i < MAX_PORTS) && ports[i]; i++) {
++ hlpr = &rtsp_helpers[i];
++ memset(hlpr, 0, sizeof(struct nf_conntrack_helper));
++ hlpr->tuple.src.l3num = AF_INET;
++ hlpr->tuple.src.u.tcp.port = htons(ports[i]);
++ hlpr->tuple.dst.protonum = IPPROTO_TCP;
++ //hlpr->mask.src.u.tcp.port = 0xFFFF;
++ //hlpr->mask.dst.protonum = 0xFF;
++ hlpr->expect_policy = &rtsp_exp_policy;
++ hlpr->me = THIS_MODULE;
++ hlpr->help = help;
++
++ tmpname = &rtsp_names[i][0];
++ if (ports[i] == RTSP_PORT) {
++ sprintf(tmpname, "rtsp");
++ } else {
++ sprintf(tmpname, "rtsp-%d", i);
++ }
++ hlpr->name = tmpname;
++
++ pr_debug("port #%d: %d\n", i, ports[i]);
++
++ ret = nf_conntrack_helper_register(hlpr);
++
++ if (ret) {
++ printk("nf_conntrack_rtsp: ERROR registering port %d\n", ports[i]);
++ fini();
++ return -EBUSY;
++ }
++ num_ports++;
++ }
++ return 0;
++}
++
++module_init(init);
++module_exit(fini);
++
++EXPORT_SYMBOL(nf_nat_rtsp_hook_expectfn);
++
+--- /dev/null
++++ b/extensions/rtsp/nf_conntrack_rtsp.h
+@@ -0,0 +1,63 @@
++/*
++ * RTSP extension for IP connection tracking.
++ * (C) 2003 by Tom Marshall <tmarshall at real.com>
++ * based on ip_conntrack_irc.h
++ *
++ * 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 of the License, or (at your option) any later version.
++ */
++#ifndef _IP_CONNTRACK_RTSP_H
++#define _IP_CONNTRACK_RTSP_H
++
++//#define IP_NF_RTSP_DEBUG 1
++#define IP_NF_RTSP_VERSION "0.6.21"
++
++#ifdef __KERNEL__
++/* port block types */
++typedef enum {
++ pb_single, /* client_port=x */
++ pb_range, /* client_port=x-y */
++ pb_discon /* client_port=x/y (rtspbis) */
++} portblock_t;
++
++/* We record seq number and length of rtsp headers here, all in host order. */
++
++/*
++ * This structure is per expected connection. It is a member of struct
++ * ip_conntrack_expect. The TCP SEQ for the conntrack expect is stored
++ * there and we are expected to only store the length of the data which
++ * needs replaced. If a packet contains multiple RTSP messages, we create
++ * one expected connection per message.
++ *
++ * We use these variables to mark the entire header block. This may seem
++ * like overkill, but the nature of RTSP requires it. A header may appear
++ * multiple times in a message. We must treat two Transport headers the
++ * same as one Transport header with two entries.
++ */
++struct ip_ct_rtsp_expect
++{
++ u_int32_t len; /* length of header block */
++ portblock_t pbtype; /* Type of port block that was requested */
++ u_int16_t loport; /* Port that was requested, low or first */
++ u_int16_t hiport; /* Port that was requested, high or second */
++#if 0
++ uint method; /* RTSP method */
++ uint cseq; /* CSeq from request */
++#endif
++};
++
++extern unsigned int (*nf_nat_rtsp_hook)(struct sk_buff *skb,
++ enum ip_conntrack_info ctinfo,
++ unsigned int matchoff, unsigned int matchlen,
++ struct ip_ct_rtsp_expect *prtspexp,
++ struct nf_conntrack_expect *exp);
++
++extern void (*nf_nat_rtsp_hook_expectfn)(struct nf_conn *ct, struct nf_conntrack_expect *exp);
++
++#define RTSP_PORT 554
++
++#endif /* __KERNEL__ */
++
++#endif /* _IP_CONNTRACK_RTSP_H */
+--- /dev/null
++++ b/extensions/rtsp/nf_nat_rtsp.c
+@@ -0,0 +1,491 @@
++/*
++ * RTSP extension for TCP NAT alteration
++ * (C) 2003 by Tom Marshall <tmarshall at real.com>
++ * based on ip_nat_irc.c
++ *
++ * 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 of the License, or (at your option) any later version.
++ *
++ * Module load syntax:
++ * insmod nf_nat_rtsp.o ports=port1,port2,...port<MAX_PORTS>
++ * stunaddr=<address>
++ * destaction=[auto|strip|none]
++ *
++ * If no ports are specified, the default will be port 554 only.
++ *
++ * stunaddr specifies the address used to detect that a client is using STUN.
++ * If this address is seen in the destination parameter, it is assumed that
++ * the client has already punched a UDP hole in the firewall, so we don't
++ * mangle the client_port. If none is specified, it is autodetected. It
++ * only needs to be set if you have multiple levels of NAT. It should be
++ * set to the external address that the STUN clients detect. Note that in
++ * this case, it will not be possible for clients to use UDP with servers
++ * between the NATs.
++ *
++ * If no destaction is specified, auto is used.
++ * destaction=auto: strip destination parameter if it is not stunaddr.
++ * destaction=strip: always strip destination parameter (not recommended).
++ * destaction=none: do not touch destination parameter (not recommended).
++ */
++
++#include <linux/module.h>
++#include <net/tcp.h>
++#include <net/netfilter/nf_nat_helper.h>
++#include <net/netfilter/nf_nat_rule.h>
++#include "nf_conntrack_rtsp.h"
++#include <net/netfilter/nf_conntrack_expect.h>
++
++#include <linux/inet.h>
++#include <linux/ctype.h>
++#define NF_NEED_STRNCASECMP
++#define NF_NEED_STRTOU16
++#include "netfilter_helpers.h"
++#define NF_NEED_MIME_NEXTLINE
++#include "netfilter_mime.h"
++
++#include "../compat_xtables.h"
++
++#define MAX_PORTS 8
++#define DSTACT_AUTO 0
++#define DSTACT_STRIP 1
++#define DSTACT_NONE 2
++
++static char* stunaddr = NULL;
++static char* destaction = NULL;
++
++static u_int32_t extip = 0;
++static int dstact = 0;
++
++MODULE_AUTHOR("Tom Marshall <tmarshall at real.com>");
++MODULE_DESCRIPTION("RTSP network address translation module");
++MODULE_LICENSE("GPL");
++module_param(stunaddr, charp, 0644);
++MODULE_PARM_DESC(stunaddr, "Address for detecting STUN");
++module_param(destaction, charp, 0644);
++MODULE_PARM_DESC(destaction, "Action for destination parameter (auto/strip/none)");
++
++#define SKIP_WSPACE(ptr,len,off) while(off < len && isspace(*(ptr+off))) { off++; }
++
++/*** helper functions ***/
++
++static void
++get_skb_tcpdata(struct sk_buff* skb, char** pptcpdata, uint* ptcpdatalen)
++{
++ struct iphdr* iph = ip_hdr(skb);
++ struct tcphdr* tcph = (void *)iph + ip_hdrlen(skb);
++
++ *pptcpdata = (char*)tcph + tcph->doff*4;
++ *ptcpdatalen = ((char*)skb_transport_header(skb) + skb->len) - *pptcpdata;
++}
++
++/*** nat functions ***/
++
++/*
++ * Mangle the "Transport:" header:
++ * - Replace all occurences of "client_port=<spec>"
++ * - Handle destination parameter
++ *
++ * In:
++ * ct, ctinfo = conntrack context
++ * skb = packet
++ * tranoff = Transport header offset from TCP data
++ * tranlen = Transport header length (incl. CRLF)
++ * rport_lo = replacement low port (host endian)
++ * rport_hi = replacement high port (host endian)
++ *
++ * Returns packet size difference.
++ *
++ * Assumes that a complete transport header is present, ending with CR or LF
++ */
++static int
++rtsp_mangle_tran(enum ip_conntrack_info ctinfo,
++ struct nf_conntrack_expect* exp,
++ struct ip_ct_rtsp_expect* prtspexp,
++ struct sk_buff* skb, uint tranoff, uint tranlen)
++{
++ char* ptcp;
++ uint tcplen;
++ char* ptran;
++ char rbuf1[16]; /* Replacement buffer (one port) */
++ uint rbuf1len; /* Replacement len (one port) */
++ char rbufa[16]; /* Replacement buffer (all ports) */
++ uint rbufalen; /* Replacement len (all ports) */
++ u_int32_t newip;
++ u_int16_t loport, hiport;
++ uint off = 0;
++ uint diff; /* Number of bytes we removed */
++
++ struct nf_conn *ct = exp->master;
++ struct nf_conntrack_tuple *t;
++
++ char szextaddr[15+1];
++ uint extaddrlen;
++ int is_stun;
++
++ get_skb_tcpdata(skb, &ptcp, &tcplen);
++ ptran = ptcp+tranoff;
++
++ if (tranoff+tranlen > tcplen || tcplen-tranoff < tranlen ||
++ tranlen < 10 || !iseol(ptran[tranlen-1]) ||
++ nf_strncasecmp(ptran, "Transport:", 10) != 0)
++ {
++ pr_info("sanity check failed\n");
++ return 0;
++ }
++ off += 10;
++ SKIP_WSPACE(ptcp+tranoff, tranlen, off);
++
++ newip = ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u3.ip;
++ t = &exp->tuple;
++ t->dst.u3.ip = newip;
++
++ extaddrlen = extip ? sprintf(szextaddr, "%pI4", &extip)
++ : sprintf(szextaddr, "%pI4", &newip);
++ pr_debug("stunaddr=%s (%s)\n", szextaddr, (extip?"forced":"auto"));
++
++ rbuf1len = rbufalen = 0;
++ switch (prtspexp->pbtype)
++ {
++ case pb_single:
++ for (loport = prtspexp->loport; loport != 0; loport++) /* XXX: improper wrap? */
++ {
++ t->dst.u.udp.port = htons(loport);
++ if (nf_ct_expect_related(exp) == 0)
++ {
++ pr_debug("using port %hu\n", loport);
++ break;
++ }
++ }
++ if (loport != 0)
++ {
++ rbuf1len = sprintf(rbuf1, "%hu", loport);
++ rbufalen = sprintf(rbufa, "%hu", loport);
++ }
++ break;
++ case pb_range:
++ for (loport = prtspexp->loport; loport != 0; loport += 2) /* XXX: improper wrap? */
++ {
++ t->dst.u.udp.port = htons(loport);
++ if (nf_ct_expect_related(exp) == 0)
++ {
++ hiport = loport + 1; //~exp->mask.dst.u.udp.port;
++ pr_debug("using ports %hu-%hu\n", loport, hiport);
++ break;
++ }
++ }
++ if (loport != 0)
++ {
++ rbuf1len = sprintf(rbuf1, "%hu", loport);
++ rbufalen = sprintf(rbufa, "%hu-%hu", loport, loport+1);
++ }
++ break;
++ case pb_discon:
++ for (loport = prtspexp->loport; loport != 0; loport++) /* XXX: improper wrap? */
++ {
++ t->dst.u.udp.port = htons(loport);
++ if (nf_ct_expect_related(exp) == 0)
++ {
++ pr_debug("using port %hu (1 of 2)\n", loport);
++ break;
++ }
++ }
++ for (hiport = prtspexp->hiport; hiport != 0; hiport++) /* XXX: improper wrap? */
++ {
++ t->dst.u.udp.port = htons(hiport);
++ if (nf_ct_expect_related(exp) == 0)
++ {
++ pr_debug("using port %hu (2 of 2)\n", hiport);
++ break;
++ }
++ }
++ if (loport != 0 && hiport != 0)
++ {
++ rbuf1len = sprintf(rbuf1, "%hu", loport);
++ if (hiport == loport+1)
++ {
++ rbufalen = sprintf(rbufa, "%hu-%hu", loport, hiport);
++ }
++ else
++ {
++ rbufalen = sprintf(rbufa, "%hu/%hu", loport, hiport);
++ }
++ }
++ break;
++ }
++
++ if (rbuf1len == 0)
++ {
++ return 0; /* cannot get replacement port(s) */
++ }
++
++ /* Transport: tran;field;field=val,tran;field;field=val,... */
++ while (off < tranlen)
++ {
++ uint saveoff;
++ const char* pparamend;
++ uint nextparamoff;
++
++ pparamend = memchr(ptran+off, ',', tranlen-off);
++ pparamend = (pparamend == NULL) ? ptran+tranlen : pparamend+1;
++ nextparamoff = pparamend-ptcp;
++
++ /*
++ * We pass over each param twice. On the first pass, we look for a
++ * destination= field. It is handled by the security policy. If it
++ * is present, allowed, and equal to our external address, we assume
++ * that STUN is being used and we leave the client_port= field alone.
++ */
++ is_stun = 0;
++ saveoff = off;
++ while (off < nextparamoff)
++ {
++ const char* pfieldend;
++ uint nextfieldoff;
++
++ pfieldend = memchr(ptran+off, ';', nextparamoff-off);
++ nextfieldoff = (pfieldend == NULL) ? nextparamoff : pfieldend-ptran+1;
++
++ if (dstact != DSTACT_NONE && strncmp(ptran+off, "destination=", 12) == 0)
++ {
++ if (strncmp(ptran+off+12, szextaddr, extaddrlen) == 0)
++ {
++ is_stun = 1;
++ }
++ if (dstact == DSTACT_STRIP || (dstact == DSTACT_AUTO && !is_stun))
++ {
++ diff = nextfieldoff-off;
++ if (!nf_nat_mangle_tcp_packet(skb, ct, ctinfo,
++ off, diff, NULL, 0))
++ {
++ /* mangle failed, all we can do is bail */
++ nf_ct_unexpect_related(exp);
++ return 0;
++ }
++ get_skb_tcpdata(skb, &ptcp, &tcplen);
++ ptran = ptcp+tranoff;
++ tranlen -= diff;
++ nextparamoff -= diff;
++ nextfieldoff -= diff;
++ }
++ }
++
++ off = nextfieldoff;
++ }
++ if (is_stun)
++ {
++ continue;
++ }
++ off = saveoff;
++ while (off < nextparamoff)
++ {
++ const char* pfieldend;
++ uint nextfieldoff;
++
++ pfieldend = memchr(ptran+off, ';', nextparamoff-off);
++ nextfieldoff = (pfieldend == NULL) ? nextparamoff : pfieldend-ptran+1;
++
++ if (strncmp(ptran+off, "client_port=", 12) == 0)
++ {
++ u_int16_t port;
++ uint numlen;
++ uint origoff;
++ uint origlen;
++ char* rbuf = rbuf1;
++ uint rbuflen = rbuf1len;
++
++ off += 12;
++ origoff = (ptran-ptcp)+off;
++ origlen = 0;
++ numlen = nf_strtou16(ptran+off, &port);
++ off += numlen;
++ origlen += numlen;
++ if (port != prtspexp->loport)
++ {
++ pr_debug("multiple ports found, port %hu ignored\n", port);
++ }
++ else
++ {
++ if (ptran[off] == '-' || ptran[off] == '/')
++ {
++ off++;
++ origlen++;
++ numlen = nf_strtou16(ptran+off, &port);
++ off += numlen;
++ origlen += numlen;
++ rbuf = rbufa;
++ rbuflen = rbufalen;
++ }
++
++ /*
++ * note we cannot just memcpy() if the sizes are the same.
++ * the mangle function does skb resizing, checks for a
++ * cloned skb, and updates the checksums.
++ *
++ * parameter 4 below is offset from start of tcp data.
++ */
++ diff = origlen-rbuflen;
++ if (!nf_nat_mangle_tcp_packet(skb, ct, ctinfo,
++ origoff, origlen, rbuf, rbuflen))
++ {
++ /* mangle failed, all we can do is bail */
++ nf_ct_unexpect_related(exp);
++ return 0;
++ }
++ get_skb_tcpdata(skb, &ptcp, &tcplen);
++ ptran = ptcp+tranoff;
++ tranlen -= diff;
++ nextparamoff -= diff;
++ nextfieldoff -= diff;
++ }
++ }
++
++ off = nextfieldoff;
++ }
++
++ off = nextparamoff;
++ }
++
++ return 1;
++}
++
++static uint
++help_out(struct sk_buff *skb, enum ip_conntrack_info ctinfo,
++ unsigned int matchoff, unsigned int matchlen, struct ip_ct_rtsp_expect* prtspexp,
++ struct nf_conntrack_expect* exp)
++{
++ char* ptcp;
++ uint tcplen;
++ uint hdrsoff;
++ uint hdrslen;
++ uint lineoff;
++ uint linelen;
++ uint off;
++
++ //struct iphdr* iph = (struct iphdr*)(*pskb)->nh.iph;
++ //struct tcphdr* tcph = (struct tcphdr*)((void*)iph + iph->ihl*4);
++
++ get_skb_tcpdata(skb, &ptcp, &tcplen);
++ hdrsoff = matchoff;//exp->seq - ntohl(tcph->seq);
++ hdrslen = matchlen;
++ off = hdrsoff;
++ pr_debug("NAT rtsp help_out\n");
++
++ while (nf_mime_nextline(ptcp, hdrsoff+hdrslen, &off, &lineoff, &linelen))
++ {
++ if (linelen == 0)
++ {
++ break;
++ }
++ if (off > hdrsoff+hdrslen)
++ {
++ pr_info("!! overrun !!");
++ break;
++ }
++ pr_debug("hdr: len=%u, %.*s", linelen, (int)linelen, ptcp+lineoff);
++
++ if (nf_strncasecmp(ptcp+lineoff, "Transport:", 10) == 0)
++ {
++ uint oldtcplen = tcplen;
++ pr_debug("hdr: Transport\n");
++ if (!rtsp_mangle_tran(ctinfo, exp, prtspexp, skb, lineoff, linelen))
++ {
++ pr_debug("hdr: Transport mangle failed");
++ break;
++ }
++ get_skb_tcpdata(skb, &ptcp, &tcplen);
++ hdrslen -= (oldtcplen-tcplen);
++ off -= (oldtcplen-tcplen);
++ lineoff -= (oldtcplen-tcplen);
++ linelen -= (oldtcplen-tcplen);
++ pr_debug("rep: len=%u, %.*s", linelen, (int)linelen, ptcp+lineoff);
++ }
++ }
++
++ return NF_ACCEPT;
++}
++
++static unsigned int
++help(struct sk_buff *skb, enum ip_conntrack_info ctinfo,
++ unsigned int matchoff, unsigned int matchlen, struct ip_ct_rtsp_expect* prtspexp,
++ struct nf_conntrack_expect* exp)
++{
++ int dir = CTINFO2DIR(ctinfo);
++ int rc = NF_ACCEPT;
++
++ switch (dir)
++ {
++ case IP_CT_DIR_ORIGINAL:
++ rc = help_out(skb, ctinfo, matchoff, matchlen, prtspexp, exp);
++ break;
++ case IP_CT_DIR_REPLY:
++ pr_debug("unmangle ! %u\n", ctinfo);
++ /* XXX: unmangle */
++ rc = NF_ACCEPT;
++ break;
++ }
++ //UNLOCK_BH(&ip_rtsp_lock);
++
++ return rc;
++}
++
++static void expected(struct nf_conn* ct, struct nf_conntrack_expect *exp)
++{
++ struct nf_nat_ipv4_multi_range_compat mr;
++ u_int32_t newdstip, newsrcip, newip;
++
++ struct nf_conn *master = ct->master;
++
++ newdstip = master->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u3.ip;
++ newsrcip = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u3.ip;
++ //FIXME (how to port that ?)
++ //code from 2.4 : newip = (HOOK2MANIP(hooknum) == NF_NAT_MANIP_SRC) ? newsrcip : newdstip;
++ newip = newdstip;
++
++ pr_debug("newsrcip=%pI4, newdstip=%pI4, newip=%pI4\n",
++ &newsrcip, &newdstip, &newip);
++
++ mr.rangesize = 1;
++ // We don't want to manip the per-protocol, just the IPs.
++ mr.range[0].flags = NF_NAT_RANGE_MAP_IPS;
++ mr.range[0].min_ip = mr.range[0].max_ip = newip;
++
++ nf_nat_setup_info(ct, &mr.range[0], NF_NAT_MANIP_DST);
++}
++
++
++static void __exit fini(void)
++{
++ nf_nat_rtsp_hook = NULL;
++ nf_nat_rtsp_hook_expectfn = NULL;
++ synchronize_net();
++}
++
++static int __init init(void)
++{
++ printk("nf_nat_rtsp v" IP_NF_RTSP_VERSION " loading\n");
++
++ BUG_ON(nf_nat_rtsp_hook);
++ nf_nat_rtsp_hook = help;
++ nf_nat_rtsp_hook_expectfn = &expected;
++
++ if (stunaddr != NULL)
++ extip = in_aton(stunaddr);
++
++ if (destaction != NULL) {
++ if (strcmp(destaction, "auto") == 0)
++ dstact = DSTACT_AUTO;
++
++ if (strcmp(destaction, "strip") == 0)
++ dstact = DSTACT_STRIP;
++
++ if (strcmp(destaction, "none") == 0)
++ dstact = DSTACT_NONE;
++ }
++
++ return 0;
++}
++
++module_init(init);
++module_exit(fini);
+--- a/extensions/Kbuild
++++ b/extensions/Kbuild
+@@ -35,6 +35,7 @@ obj-${build_lscan} += xt_lscan.o
+ obj-${build_pknock} += pknock/
+ obj-${build_psd} += xt_psd.o
+ obj-${build_quota2} += xt_quota2.o
++obj-${build_rtsp} += rtsp/
+
+ -include ${M}/*.Kbuild
+ -include ${M}/Kbuild.*
+--- a/mconfig
++++ b/mconfig
+@@ -26,3 +26,4 @@ build_lscan=m
+ build_pknock=m
+ build_psd=m
+ build_quota2=m
++build_rtsp=m
diff --git a/package/network/utils/xtables-addons/patches-1.x/.svn/text-base/101-rtsp-linux-3.6-compat.patch.svn-base b/package/network/utils/xtables-addons/patches-1.x/.svn/text-base/101-rtsp-linux-3.6-compat.patch.svn-base
new file mode 100644
index 0000000..b8e08b3
--- /dev/null
+++ b/package/network/utils/xtables-addons/patches-1.x/.svn/text-base/101-rtsp-linux-3.6-compat.patch.svn-base
@@ -0,0 +1,22 @@
+--- a/extensions/rtsp/nf_conntrack_rtsp.c
++++ b/extensions/rtsp/nf_conntrack_rtsp.c
+@@ -28,6 +28,7 @@
+ * - Port to new NF API
+ */
+
++#include <linux/version.h>
+ #include <linux/module.h>
+ #include <linux/netfilter.h>
+ #include <linux/ip.h>
+@@ -496,7 +497,11 @@ init(void)
+ } else {
+ sprintf(tmpname, "rtsp-%d", i);
+ }
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)
++ strncpy(hlpr->name, tmpname, sizeof(hlpr->name));
++#else
+ hlpr->name = tmpname;
++#endif
+
+ pr_debug("port #%d: %d\n", i, ports[i]);
+
diff --git a/package/network/utils/xtables-addons/patches-1.x/.svn/text-base/200-add-lua-packetscript.patch.svn-base b/package/network/utils/xtables-addons/patches-1.x/.svn/text-base/200-add-lua-packetscript.patch.svn-base
new file mode 100644
index 0000000..1717bf5
--- /dev/null
+++ b/package/network/utils/xtables-addons/patches-1.x/.svn/text-base/200-add-lua-packetscript.patch.svn-base
@@ -0,0 +1,18230 @@
+--- /dev/null
++++ b/extensions/LUA/byte_array.c
+@@ -0,0 +1,145 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre@dergraf.org>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++#include "controller.h"
++
++/* Initialization helper function. This function should be used whenever
++ * a new byte array need to be initialized. Depending on the arguments it
++ * initializes the array in a different way. Have a look at the inline
++ * comments */
++lua_packet_segment * init_byte_array(lua_State *L, unsigned char * start, int length, int do_copy)
++{
++ lua_packet_segment *array;
++
++ if (length < 0)
++ luaL_error(L, "init_byte_array, requested size < 0");
++
++ if (start && do_copy) {
++ /* we have a start address where we copy from */
++ array = lua_newuserdata(L, sizeof(lua_packet_segment) + length);
++ array->start = (unsigned char *)array + sizeof(lua_packet_segment); /* aligning pointer */
++ memcpy(array->start, start, length);
++ }else if (start && !do_copy) {
++ /* just link the start pointer, in this case you have to free the memory yourself */
++ array = lua_newuserdata(L, sizeof(lua_packet_segment));
++ array->start = start;
++ }else{
++ /* create an empty array, fully managed by Lua */
++ array = lua_newuserdata(L, sizeof(lua_packet_segment) + length);
++ array->start = (unsigned char *)array + sizeof(lua_packet_segment); /* aligning pointer */
++ memset(array->start, 0, length);
++ }
++
++ array->length = length;
++ array->offset = 0;
++ array->changes = NULL;
++
++ luaL_getmetatable(L, LUA_BYTE_ARRAY);
++ lua_setmetatable(L, -2);
++
++ return array;
++}
++
++
++
++/* LUA_API: get one byte of the given byte array
++ * access-pattern: array[<index>] */
++static int32_t get_byte_array(lua_State *L)
++{
++ lua_packet_segment * array = checkbytearray(L, 1);
++ int32_t index = luaL_checkinteger(L, 2); /* array starts with index 0 (not 1 as usual in Lua) */
++
++ luaL_argcheck(L, 0 <= index && index < array->length, 1, "index out of range");
++ lua_pushinteger(L, (array->start + array->offset)[index]);
++
++ return 1;
++}
++
++/* LUA_API: set one byte of the given byte array
++ * access-pattern: array[<index>]= 0xFF */
++static int32_t set_byte_array(lua_State *L)
++{
++ lua_packet_segment * array = checkbytearray(L, 1);
++ uint8_t byte;
++ int32_t index = luaL_checkinteger(L, 2); /* array starts with index 0 (not 1 as usual in Lua) */
++ int32_t val = luaL_checkinteger(L, 3);
++ uint32_t nob = 1 << CHAR_BIT; /* we should use something like 1 << CHAR_BIT */
++
++ luaL_argcheck(L, 0 <= index && index < array->length, 1, "index out of range");
++ luaL_argcheck(L, 0 <= val && val < nob, 2, "cannot cast value to char");
++
++ byte = (uint8_t)val;
++
++ (array->start + array->offset)[index] = byte;
++
++ return 0;
++}
++
++/* LUA_API: get size of the given byte array
++ * access-pattern: #array (__length meta-method) */
++static int32_t get_byte_array_size(lua_State *L)
++{
++ lua_packet_segment * array = checkbytearray(L, 1);
++
++ lua_pushnumber(L, array->length);
++
++ return 1;
++}
++
++
++/* LUA_API: converts a given byte array to a string.
++ * access-pattern: implicit through functions calling the
++ * __to_string() metamethod , e.g. print32_t */
++static int32_t byte_array_to_string(lua_State *L)
++{
++ lua_packet_segment * array = checkbytearray(L, 1);
++ uint8_t buf[(array->length * 3) + 255];
++ uint8_t hexval[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
++ char res[255 + (array->length * 3)]; /* make sure the buffer is big enough*/
++ int32_t i, n;
++ uint8_t *ptr = array->start + array->offset;
++
++ for (i = 0; i < array->length; i++) {
++ buf[i * 3] = hexval[(ptr[i] >> 4) & 0xF];
++ buf[(i * 3) + 1] = hexval[ptr[i] & 0x0F];
++ buf[(i * 3) + 2] = ' '; /* seperator */
++ }
++
++ buf[array->length * 3] = '\0';
++ n = sprintf(res, "byte_array: length: %d value: %s", array->length, buf);
++
++ lua_pushlstring(L, res, n);
++
++ return 1;
++}
++
++static const struct luaL_Reg bytearray_lib_m [] = {
++ { "__len", get_byte_array_size },
++ { "__newindex", set_byte_array },
++ { "__index", get_byte_array },
++ { "__tostring", byte_array_to_string },
++ { NULL, NULL }
++};
++
++void luaopen_bytearraylib(lua_State *L)
++{
++ luaL_newmetatable(L, LUA_BYTE_ARRAY);
++ luaL_register(L, NULL, bytearray_lib_m);
++ lua_pop(L, 1);
++}
++
++
+--- /dev/null
++++ b/extensions/LUA/controller.c
+@@ -0,0 +1,604 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre@dergraf.org>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++
++#if defined(__KERNEL__)
++ #include <linux/mm.h>
++#endif
++#include "controller.h"
++
++/* the array 'supported_protocols' holds all pointers to the
++ * static and dynamic protocol buffers. It is filled by the
++ * call to register_protbuf */
++static struct protocol_buf * supported_protocols[MAX_NR_OF_PROTOCOLS];
++
++/* C_API: the function 'get_protocol_buf' returns the pointer
++ * to the protocol buffer of a given protocol id. */
++struct protocol_buf * get_protocol_buf(uint32_t protocol_id)
++{
++ return (struct protocol_buf *)supported_protocols[protocol_id];
++}
++
++
++/* LUA_INT: the function 'gc_packet_segment' is triggered by the
++ * garbage collector whenever a userdata annotated with one of
++ * the protocol buffer metatable should be collected. */
++static int32_t gc_packet_segment(lua_State *L)
++{
++ lua_packet_segment * seg = (lua_packet_segment *)lua_touserdata(L, 1);
++ if (seg && seg->changes) {
++ seg->changes->ref_count--;
++ if (seg->changes->ref_count <= 0) {
++ kfree(seg->changes->field_length_changes);
++ kfree(seg->changes->field_offset_changes);
++ kfree(seg->changes);
++ seg->changes = NULL;
++ }
++ }
++ return 0;
++}
++
++
++/* LUA_API: the function 'set_raw' is used to set the bytes of a segment
++ * in 'raw' mode. The function is per default available in each protocol
++ * buffer until it gets overridden by a specific setter function inside
++ * a protocol buffer.
++ *
++ * Parameters:
++ * 1. lua_packet_segment (implicit)
++ * 2. int32_t byte_value
++ *
++ * Upvalues:
++ * 1. struct protocol_buf*
++ * 2. int32_t field index, not used in this function
++ *
++ * Return: void
++ */
++static int32_t set_raw(lua_State *L)
++{
++ int32_t i;
++ uint32_t nob;
++ uint8_t byte;
++ uint8_t *ptr;
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ int32_t val = luaL_checkinteger(L, 2);
++
++ nob = 1 << CHAR_BIT;
++
++ luaL_argcheck(L, 0 <= val && val < nob, 2, "cannot cast value to char");
++
++ byte = (uint8_t)val;
++ ptr = seg->start + seg->offset;
++
++ for (i = 0; i < seg->length; i++)
++ ptr[i] = byte;
++
++ return 0;
++}
++
++/* LUA_API: the function 'get_raw' is used to get the bytes of a segment
++ * in 'raw' mode. The function is per default available in each protocol
++ * buffer until it gets overridden by a specific getter function inside
++ * a protocol buffer.
++ *
++ * Parameters:
++ * 1. lua_packet_segment (implicit)
++ * 2. uint32_t offset
++ * 3. uint32_t length
++ *
++ * Upvalues:
++ * 1. struct protocol_buf*
++ * 2. int32_t field index, not used in this function
++ *
++ * Return:
++ * the byte array representing the given array
++ */
++static int32_t get_raw(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ init_byte_array(L, seg->start + seg->offset, seg->length, 1);
++
++ return 1;
++}
++/* LUA_API: The function 'get_segment' is used to get a new segment in 'raw' mode.
++ * Typically this function is applied on another raw segment in order
++ * to extract a part of the segment as new segment.
++ *
++ * Parameters:
++ * 1. lua_packet_segment, implicit through object oriented access seg:raw(..)
++ * 2. uint32_t offset, this indicates where to start the new segment, see e.g below.
++ * 3. uint32_t length, this indicates the size of the new segment
++ *
++ * Upvalues:
++ * 1. struct protocol_buf*
++ * 2. int32_t field index, not used in this function
++ *
++ * Return:
++ * 1. A lua_packet_segment annotated with the according metatable or False in
++ * case the input data is not valid
++ *
++ * Example:
++ *
++ * +------------------------+---------------------------------------+
++ * | function call | resulting lua_packet_segment |
++ * +========================+===+===+===+===+===+===+===+===+===+===+
++ * | seg = packet:raw(0,10) | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
++ * +------------------------+---+---+---+---+---+---+---+---+---+---+
++ * | 1st_half = seg:raw(0,5)| 0 | 1 | 2 | 3 | 4 | |
++ * +------------------------+---+---+---+---+---+---+---+---+---+---+
++ * | 2nd_half = seg:raw(5,5)| | 5 | 6 | 7 | 8 | 9 |
++ * +------------------------+-------------------+---+---+---+---+---+
++ */
++static int32_t get_segment(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++ uint32_t offset = luaL_checkinteger(L, 2);
++ uint32_t length = luaL_checkinteger(L, 3);
++ lua_packet_segment * new = (lua_packet_segment *)lua_newuserdata(L, sizeof(lua_packet_segment));
++
++ new->start = seg->start;
++ new->offset = seg->offset + offset;
++ new->changes = NULL;
++ /* we allow a seg->length == 0 , this enables processing packets where the packetsize is not fixed (0 = not fixed)*/
++ if (seg->length != 0 && length > seg->length) {
++ lua_pushboolean(L, 0);
++ return 1;
++ }
++
++ new->length = length;
++ luaL_getmetatable(L, prot_buf->name);
++ lua_setmetatable(L, -2);
++
++ return 1;
++}
++
++/* LUA_API: the function 'get_segment_size' is used to get the size of a segment.
++ *
++ * Parameters:
++ * 1. lua_packet_segment, implicit through object oriented access seg:raw(..)
++ *
++ * Upvalues:
++ * 1. struct protocol_buf*
++ * 2. int32_t field index, not used in this function
++ *
++ * Return:
++ * 1. Size as lua_Number
++ */
++static int32_t get_segment_size(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ lua_pushnumber(L, seg->length);
++ return 1;
++}
++
++/* LUA_API: the function 'get_segment_offset' is used to get the real offset
++ * of a segment. This function returns the offset of the segment to the start
++ * of the buffer. This means the following
++ * seg1 = packet:raw(2,10)
++ * seg2 = seg1:raw(3,5)
++ * offset = seg2:get_offset()
++ *
++ * will give an offset of 5, since the seg1 starts at offset 2, and seg2 starts
++ * at offset (seg1:get_offset() + 3).
++ *
++ * Parameters:
++ * 1. lua_packet_segment, implicit through object oriented access seg:raw(..)
++ *
++ * Upvalues:
++ * 1. struct protocol_buf*
++ * 2. int32_t field index, not used in this function
++ *
++ * Return:
++ * 1. Offset as lua_Number
++ */
++static int32_t get_segment_offset(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ lua_pushnumber(L, seg->offset);
++ return 1;
++}
++
++/* LUA_API: overwrites the __tostring function of a lua_packet_segment.
++ * this will print32_t a nicely formated string, including length,
++ * offset and name of the protocol buffer.
++ *
++ * Parameters:
++ * 1. lua_packet_segment (implicit)
++ *
++ * Returns:
++ * 1. the representing string
++ */
++static int32_t packet_segment_tostring(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++ int32_t n;
++ char buf[128];
++
++ n = sprintf(buf, "type: %s, offset: %d, length: %d", prot_buf->name, seg->offset, seg->length);
++ lua_pushlstring(L, buf, n);
++
++ return 1;
++}
++
++
++static const struct luaL_Reg seg_access_functions [] = {
++ { "set", set_raw },
++ { "get", get_raw },
++ { "raw", get_segment },
++ { "get_offset", get_segment_offset },
++ { "get_size", get_segment_size },
++ { "to_bytes", get_raw },
++ { "__tostring", packet_segment_tostring },
++ { "__gc", gc_packet_segment },
++ { NULL, NULL }
++};
++
++/* C_API: the function 'get_metatable_from_protocol_type' is a helper
++ * used in controller.c as well as it may find usage in the static
++ * protocol buffers and byte array implementation. */
++void get_metatable_from_protocol_type(lua_State *L, int32_t type)
++{
++ char * table;
++ lua_getglobal(L, SUPPORTED_PROTOCOL_TABLE);
++ lua_rawgeti(L, -1, type);
++ table = (char *)luaL_checkstring(L, -1);
++ lua_pop(L, 2); /* pop the table SUPPORTED_PROTOCOL_TABLE and the string pushed by lua_gettable */
++ luaL_getmetatable(L, table);
++ return;
++}
++
++/* C_INT: the function 'payload_contains_protocol' is used internally.
++ * Depending if static or dynamic protocol buffer it calls the right
++ * validation function. */
++static int32_t payload_contains_protocol(lua_State *L, struct protocol_buf *prot_buf, lua_packet_segment *seg, uint32_t prot_type)
++{
++ if (prot_buf->is_dynamic)
++ return has_protocol_dynamic(L, prot_buf, seg, prot_type);
++ else
++ return prot_buf->has_protocol(L, prot_buf, seg, prot_type);
++}
++
++/* C_INT: the function 'protocol_get_field_changes' is used interally.
++ * It requests the field_changes struct calling the protocol buffers
++ * 'get_field_changes' function. This funciton is called, whenever
++ * the payload field with a given protocol type is requested inside
++ * the function 'get_protocol_field' */
++static struct field_changes * protocol_get_field_changes(lua_State *L, struct protocol_buf *prot_buf, lua_packet_segment * seg)
++{
++ struct field_changes * changes = NULL;
++
++ if (prot_buf->get_field_changes) {
++ if (prot_buf->is_dynamic)
++ changes = get_field_changes_dynamic(L, prot_buf, seg);
++ else
++ changes = prot_buf->get_field_changes(L, seg);
++ /* is already 1 when set by helper 'get_allocated_field_changes,
++ * since not every prot_buf may use this function we enforce it. */
++ changes->ref_count = 1;
++ }
++ return changes;
++}
++
++/* C_INT: the function 'get_field_offset_in_bytes' wrapps the logic of
++ * calculating the new length with considering the optional field_changes. */
++static int32_t get_field_offset_in_bytes(struct protocol_field * field, lua_packet_segment * seg, int32_t field_index)
++{
++ uint32_t nr_of_bits, nr_of_bytes, field_offset;
++
++ field_offset = field->offset;
++ /* do we need to manipulate the default values stored inside the protocol buffer ?? */
++ if (seg->changes)
++ field_offset += seg->changes->field_offset_changes[field_index];
++ /* how many bits remain */
++ nr_of_bits = field_offset & (CHAR_BIT - 1);
++ /* assuming CHAR_BIT == 2 ^ 3 */
++ nr_of_bytes = (field_offset - nr_of_bits) >> 3;
++
++ return seg->offset + nr_of_bytes;
++}
++
++/* C_INT: the function 'get_field_length_in_bytes' wrapps the logic of
++ * calculating the new offset with considering the optional field_changes. */
++static int32_t get_field_length_in_bytes(struct protocol_field * field, lua_packet_segment * seg, int32_t field_index)
++{
++ uint32_t nr_of_bits, nr_of_bytes, field_length;
++
++ field_length = field->length;
++ /* if the field length is smaller than 1 byte, we take the size of one byte
++ * we treat the case where field_length == 0 in a special way ...*/
++ if (field_length < CHAR_BIT && field_length > 0)
++ field_length = CHAR_BIT;
++
++ /* do we need to manipulate the default values stored inside the protocol buffer ?? */
++ if (seg->changes)
++ field_length += seg->changes->field_length_changes[field_index];
++ /* how many bits remain */
++ nr_of_bits = field_length & (CHAR_BIT - 1);
++ /* assuming CHAR_BIT == 2 ^ 3 */
++ nr_of_bytes = (field_length - nr_of_bits) >> 3;
++ return nr_of_bytes;
++}
++
++/* C_INT: the function 'initialize_field_getter_and_setter' initializes
++ * the setter and getter function of the field, considering the optional
++ * field manipulator functions defined inside the protocol buffers. */
++static void initialize_field_getter_and_setter(lua_State *L, struct protocol_buf *prot_buf, int32_t field_index)
++{
++ /* lets check if there is a metatable on top of the stack */
++ struct protocol_field * f = (struct protocol_field *)&prot_buf->protocol_fields[field_index];
++
++ if (!lua_istable(L, -1)) luaL_error(L, "cannot initialize getter and setter for field %s->%s, "
++ "not a table on top of the stack, is '%s'", prot_buf->name, f->name, lua_typename(L, lua_type(L, -1)));
++
++ /* is there a 'getter' to initialize ? */
++ lua_pushlightuserdata(L, prot_buf); /* push upvalue 1 */
++ lua_pushinteger(L, field_index); /* push upvalue 2 */
++ if (f->get) {
++ if (prot_buf->is_dynamic)
++ lua_pushcclosure(L, field_dynamic_getter, 2);
++ else
++ lua_pushcclosure(L, f->get, 2);
++ }else
++ /* there is no specific getter defined - fall back to 'get_raw' */
++ lua_pushcclosure(L, get_raw, 2);
++ /* set the metatable field 'get' */
++ lua_setfield(L, -2, "get");
++
++ /* is there a 'setter' to initialize ? */
++ lua_pushlightuserdata(L, prot_buf); /* push upvalue 1 */
++ lua_pushinteger(L, field_index); /* push upvalue 2 */
++ if (f->set) {
++ if (prot_buf->is_dynamic)
++ lua_pushcclosure(L, field_dynamic_setter, 2);
++ else
++ lua_pushcclosure(L, f->set, 2);
++ }else
++ /* there is no specific setter defined - fall back to 'set_raw' */
++ lua_pushcclosure(L, set_raw, 2);
++ /* set the metatable field 'set' */
++ lua_setfield(L, -2, "set");
++}
++
++/* LUA_API: 'get_protocol_field' is used in Lua as a closure for each field of a protocol
++ * buffer. E.g a call to ip = packet:data(packet_ip) will go to this function,
++ * and trigger the conversion of the raw packet to a ip packet. Each call
++ * to a field function of an IP packet, like ip:daddr() uses this function
++ * to to return the right data. In each case you will end up either with a
++ * new packet segment (annotated with the proper metatable) or a boolean
++ * value (False) if something went wrong. In the case everything went fine,
++ * the newly created lua_packet_segment is annotated with the proper
++ * metatable where the fields get and set also contain the specific getter
++ * and setter functions given by the protocol buffer. E.g. the function call
++ * ip:daddr():get() or ip:daddr():set(...) will call the proper function
++ * defined inside the corresponding field definition.
++ *
++ * Parameters:
++ * 1. lua_packet_segment, implicit through object oriented access seg:raw(..)
++ * 2. type of the protocol buffer, optional, and only used if the accessed
++ * field is the payload field. If a type is provided for the access of the
++ * payload field, the function tries to convert the data pointed to by the
++ * payload field to the given type. To check if such a conversion is
++ * possible, it calls the function pointed to by the protocol buffer member
++ * has_protocol. If this function returns True, the conversion takes place.
++ *
++ * Upvalues:
++ * 1. struct protocol_buf*
++ * 2. int32_t field index
++ *
++ * Return:
++ * 1. A lua_packet_segment annotated with the according metatable or False in
++ * case the input data is not valid
++ */
++static int32_t get_protocol_field(lua_State *L)
++{
++ int32_t prot_type;
++ lua_packet_segment * seg, *new;
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ int32_t field_index = lua_tointeger(L, lua_upvalueindex(2));
++ struct protocol_field * field = &prot_buf->protocol_fields[field_index];
++
++ /* get the current packet segment */
++ seg = checkpacketseg(L, 1, prot_buf->name);
++
++ /* initialize the new packet segment */
++ new = (lua_packet_segment *)lua_newuserdata(L, sizeof(lua_packet_segment));
++ new->start = seg->start; /* the start is unchanged */
++ new->offset = get_field_offset_in_bytes(field, seg, field_index);
++ new->length = get_field_length_in_bytes(field, seg, field_index);
++
++ /* if new->length == 0 then no configuration was done, we guess the size by subtracting the
++ * new offset from the packet length. since the old length is getting initialized by the
++ * netfilter extension this assumption holds for the very last field of the protocol.
++ * this 'feature' should be used by protocol buffers containing a payload, whereas the
++ * payload field is the last field of the buffer. However, at compile-time unknown field
++ * sizes (and offsets) of fields not being placed at the end of the protocol should be
++ * initialized using the 'get_field_changes' hook system. */
++ if (new->length == 0)
++ new->length = (seg->length + seg->offset) - (new->offset);
++ /*
++ printf("%s->%s:: seg->offset %i, seg->length %i, new->offset %i, new->length %i\n",
++ prot_buf->name, field->name, seg->offset, seg->length, new->offset, new->length);
++ */
++ /* special care for packet payload requests */
++ if (prot_buf->payload_field != NULL && strcmp(prot_buf->payload_field, field->name) == 0) {
++ /* we know the payload field is requested */
++ /* the requested payload can be delivered either as a common segment or as
++ * an other packet type, such a conversion needs an extra protocol parameter
++ * ... so lets check */
++
++ if (lua_isnumber(L, 2)) {
++ /* we have an extra parameter, ... lets see if it is a valid protocol
++ * the parameter is the index of the 'supported_protocols'-array member */
++ prot_type = lua_tointeger(L, 2);
++ if (prot_type >= 0 && prot_type < PACKET_SENTINEL) {
++ /* we are sure the purpose of the request is to get the payload data,
++ * converted to the given protocol. lets check if the payload contains
++ * data of the given protocol */
++ if (payload_contains_protocol(L, prot_buf, seg, prot_type)) {
++ /* success, we can push the metatable for the given protocol */
++ get_metatable_from_protocol_type(L, prot_type);
++ if (!lua_isnil(L, -1)) /* check if the metatable was found */
++ /* perhaps the field offsets and lengths of the containing protocol
++ * are not set correctly. request the optional 'field_changes' structure
++ * holding the changes for lengths and offsets. */
++ new->changes = protocol_get_field_changes(L, get_protocol_buf(prot_type), new);
++ else{
++ /* failed, the requested protocol is not available
++ * we push false and return */
++ lua_pop(L, 1); /* pop the userdata */
++ lua_pushboolean(L, 0);
++ return 1;
++ }
++ }else{
++ /* payload does not carry the provided protocol */
++ /* we push false and return */
++ lua_pop(L, 1); /* pop the userdata */
++ lua_pushboolean(L, 0);
++ return 1;
++ }
++ }else{
++ /* unknown protocol */
++ lua_pop(L, 1); /* pop the userdata */
++ luaL_error(L, "provided protocol is unknown");
++ }
++ }
++ }
++
++ /* if there is still the 'new' userdata on the top, we push our own metatable */
++ if (lua_isuserdata(L, -1)) {
++ luaL_getmetatable(L, prot_buf->name);
++ new->changes = seg->changes;
++ if (seg->changes)
++ new->changes->ref_count++;
++ }
++
++ /* a new packet segment is at index -2 , and the proper metatable at index -1 of the stack
++ * lets set the propper setter and getter function for the requested field */
++ initialize_field_getter_and_setter(L, prot_buf, field_index);
++
++ lua_setmetatable(L, -2);
++ return 1;
++}
++
++/* C_API: 'register_protbuf' is only used internally. This function takes a
++ * pointer to a fully initialized protocol buffer struct and registers it
++ * inside the Lua state. Registering means:
++ *
++ * 1. it creates a new metatable with the name of the protocol buffer.
++ * 2. it registers the default functions which are stored in the luaL_Reg
++ * array seg_access_functions.
++ * 3. it loops over the protocol fields stored at prot_buf->protocol_fields
++ * and registers a new function (using the field name) inside the
++ * metatable. Each field points to the function 'get_protocol_field'
++ * which acts as a closure taking a pointer to the protocol buffer as
++ * well as the index of the field as upvalues.
++ * 4. The protocol index, serves as numerical identifier of this protocol
++ * buffer or even of the protocol itself. This index is stored as a
++ * global value inside the Lua state as well as inside the Lua table
++ * 'supported_protocols'. Assuming the name of a procotol buffer is
++ * "packet_ip" the following statements are true:
++ *
++ * supported_protocols[protocol_index] == "packet_ip"
++ * packet_ip == protocol_index
++ *
++ * This allows you to get all registered protocols from within Lua. This
++ * is especially usefull for the dynamic protocol buffers where you have
++ * to provide your own "has_protocol"-function, which probably needs the
++ * information on which protocols it is able to contain.
++ */
++void register_protbuf(lua_State *L, struct protocol_buf * prot_buf, uint32_t protocol_index)
++{
++ int32_t field_index;
++ luaL_Reg *reg = (struct luaL_Reg *)seg_access_functions;
++ struct protocol_field * field = prot_buf->protocol_fields;
++
++ luaL_newmetatable(L, prot_buf->name);
++
++ /* metatable.__index = metatable */
++ lua_pushvalue(L, -1); /* duplicates the metatable */
++ lua_setfield(L, -2, "__index");
++
++ /* pushing default functions */
++ for (; reg->name; reg++) {
++ lua_pushlightuserdata(L, (void *)prot_buf);
++ lua_pushcclosure(L, reg->func, 1);
++ lua_setfield(L, -2, reg->name);
++ }
++
++ /* pushing functions specific to the protocol buffer */
++ for (field_index = 0; field->name; field++, field_index++) {
++ lua_pushlightuserdata(L, (void *)prot_buf); /* upvalue: prot_buf */
++ lua_pushinteger(L, field_index); /* upvalue: index of protocol field */
++ lua_pushcclosure(L, get_protocol_field, 2);
++ lua_setfield(L, -2, field->name);
++ }
++ /* pop the metatable */
++ lua_pop(L, 1);
++
++ /* registering the array-index as the protocol_id*/
++ lua_getglobal(L, "_G");
++ lua_pushinteger(L, protocol_index);
++ lua_setfield(L, -2, prot_buf->name);
++ lua_pop(L, 1); /* pop _G */
++
++ lua_getglobal(L, SUPPORTED_PROTOCOL_TABLE);
++ lua_pushstring(L, prot_buf->name);
++ lua_rawseti(L, -2, protocol_index);
++
++ lua_pop(L, 1); /* pop SUPPORTED_PROTOCOL_TABLE */
++
++ supported_protocols[protocol_index] = prot_buf;
++}
++
++void luaopen_controller(lua_State *L)
++{
++ /* registering a table inside the _G with table[protocol_index] = prot_buf->name */
++ lua_getglobal(L, "_G");
++ lua_newtable(L);
++ lua_setfield(L, -2, SUPPORTED_PROTOCOL_TABLE);
++ lua_pop(L, 1); /* pop _G */
++
++ luaopen_protbuf_raw(L);
++ luaopen_protbuf_eth(L);
++ luaopen_protbuf_ip(L);
++ luaopen_protbuf_icmp(L);
++ luaopen_protbuf_tcp(L);
++ luaopen_protbuf_tcp_options(L);
++ luaopen_protbuf_udp(L);
++ luaopen_protbuf_tftp(L);
++ luaopen_protbuf_dynamic(L);
++ /* should follow all other static buffers */
++#if defined(__KERNEL__)
++ luaopen_nflib(L);
++#endif
++
++ luaopen_bytearraylib(L);
++}
++
++
++
++
+--- /dev/null
++++ b/extensions/LUA/controller.h
+@@ -0,0 +1,264 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre@dergraf.org>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++
++#ifndef CONTROLLER_H_
++#define CONTROLLER_H_
++
++#include "stdlib.h" /* wrapper */
++#include "string.h" /* wrapper */
++#include "lua.h"
++#include "lualib.h"
++#include "lauxlib.h"
++
++#if defined(__KERNEL__)
++#include <linux/skbuff.h>
++#include <linux/slab.h>
++#include <linux/vmalloc.h>
++#endif
++
++
++/* to compile the stuff in userspace (for testing)*/
++#if !defined(__KERNEL__)
++#include <stdint.h>
++#define pr_debug printf;
++
++#define kmalloc(size, type) malloc(size)
++#define kfree(ptr) free(ptr)
++
++#endif
++
++
++/**********************************************************************/
++/* nf Lua configuration */
++/**********************************************************************/
++#define MAX_NR_OF_PROTOCOLS 16
++#define SUPPORTED_PROTOCOL_TABLE "supported_protocols"
++
++#define MAX_NR_OF_FIELDS_IN_DYN_PROT_BUF 32
++
++
++/**********************************************************************/
++/* Static Protocol Buffer configuration */
++/**********************************************************************/
++
++/* the definitions of the stringified expression of the prot_bufs...
++ * make sure all static prot_bufs are listed and are unique */
++#define LUA_PACKET_SEG_RAW "packet_raw"
++#define LUA_PACKET_SEG_ETH "packet_eth"
++#define LUA_PACKET_SEG_ICMP "packet_icmp"
++#define LUA_PACKET_SEG_IP "packet_ip"
++#define LUA_PACKET_SEG_TCP "packet_tcp"
++#define LUA_PACKET_SEG_TCP_OPT "packet_tcp_opt"
++#define LUA_PACKET_SEG_UDP "packet_udp"
++#define LUA_PACKET_SEG_TFTP "packet_tftp"
++
++/* the enum holding all static prot_bufs... make sure it contains all
++ * static prot_bufs */
++enum PROT_BUF {
++ PACKET_RAW,
++ PACKET_ETH,
++ PACKET_IP,
++ PACKET_ICMP,
++ PACKET_TCP,
++ PACKET_TCP_OPTIONS,
++ PACKET_UDP,
++ PACKET_TFTP,
++ PACKET_DYNAMIC,
++ PACKET_SENTINEL
++};
++
++/* the luaopen-function of the prot_bufs... make sure it is called
++ * inside luaopen_controller */
++void luaopen_protbuf_raw(lua_State *L);
++void luaopen_protbuf_eth(lua_State *L);
++void luaopen_protbuf_ip(lua_State *L);
++void luaopen_protbuf_icmp(lua_State *L);
++void luaopen_protbuf_tcp(lua_State *L);
++void luaopen_protbuf_tcp_options(lua_State *L);
++void luaopen_protbuf_udp(lua_State *L);
++void luaopen_protbuf_tftp(lua_State *L);
++void luaopen_protbuf_dynamic(lua_State *L);
++
++/**********************************************************************/
++/* field changes */
++/**********************************************************************/
++struct field_changes {
++ int ref_count;
++ int *field_length_changes;
++ int *field_offset_changes;
++};
++
++/**********************************************************************/
++/* lua packet segment */
++/* ------------------ */
++/* The struct lua_packet_segment is the integral part of a Lua packet.*/
++/* At the very beginning, when a new packet arrives in `lua_tg`_ such */
++/* a struct is initialized. The field start then points to the lowest */
++/* available header inside the sk_buff structure. During packet */
++/* processing the start pointer remains the same, only the offset and */
++/* length value change. */
++/**********************************************************************/
++#define checkpacketseg(L, i, seg_type) \
++ (lua_packet_segment *)luaL_checkudata(L, i, seg_type)
++
++typedef struct lua_packet_segment {
++ unsigned int offset;
++ unsigned int length;
++ struct field_changes * changes;
++ unsigned char * start; /* need to be at the end because of the memory alignment */
++} lua_packet_segment;
++
++/**********************************************************************/
++/* protocol field */
++/* -------------- */
++/* This structure is a container for the field definitions used by the*/
++/* protocol buffer. Each protocol field is expressed using this struct*/
++/* Have a look at the protocol buffers to see how the struct gets */
++/* initialized. */
++/* */
++/* name: */
++/* This member expresses the name of the field, ending */
++/* in its own Lua function to access the field. */
++/* offset / length: */
++/* These members do specify the position inside the protocol header */
++/* in bits (not bytes!). */
++/* get / set: */
++/* The get and set functions take a function pointer pointing to the*/
++/* specific getter and setter function for this field. */
++/**********************************************************************/
++struct protocol_field {
++ const char * name;
++ uint32_t offset;
++ uint32_t length;
++ lua_CFunction get;
++ lua_CFunction set;
++};
++#define PROT_FIELD_SENTINEL { NULL, 0, 0, NULL, NULL }
++
++
++/**********************************************************************/
++/* protocol_buf */
++/**********************************************************************/
++/* This structure is a container for all the information needed for a
++ * protocol buffer. It gets initialized in each protocol buffer header
++ * file or for the dynamic protocol buffers on runtime using the
++ * 'register_dynamic_protocol_buffer' function.
++ *
++ * name:
++ * This member is used throughout the system. It is also exported
++ * to Lua as a variable name holding the index of the 'supported_protocols'
++ * array. The name is also used as the name of the generated Lua
++ * metatable, that is why inside the macro checkpacketseg_ it
++ * is always the name of a protocol buffer that is passed as the
++ * second parameter.
++ * payload_field:
++ * This member holds the string of the field responsible for payload
++ * data. The payload field of a protocol has an extra property, since
++ * it can be used to invoke another protocol buffer that is applied to
++ * the payload content.
++ * has_protocol:
++ * This member is used together with the payload_field. Since we must
++ * be sure that the payload content does really contain a protocol
++ * of type X. The function pointed to by has_protocol checks if the
++ * protocol buffer X can be applied on the payload_data.
++ * protocol_fields:
++ * This member points to the array of 'protocol_field' structures
++ * get_field_changes:
++ * This member is optional. It is used to return a pointer to an initialized
++ * field_changes struct. The function is called, whenever the payload field
++ * is requested with a given protocol type. Usually this function will
++ * initialize the field_changes struct depending on the content of the
++ * payload data. e.g.
++ * tcp = ip:data(packet_tcp)
++ * such a request will call the 'get_field_changes' function of the tcp
++ * protocol buffer. This enables, that the tcp options field have the proper
++ * length as well as the tcp data start at the right offset.
++ */
++struct protocol_buf {
++ int is_dynamic;
++ const char * name;
++ char * payload_field;
++ int (*has_protocol)(lua_State *L, struct protocol_buf *prot_buf, lua_packet_segment * seg, int type);
++ struct protocol_field * protocol_fields;
++ struct field_changes * (*get_field_changes)(lua_State *L, lua_packet_segment * seg);
++};
++
++/**********************************************************************/
++/* lua byte array library */
++/**********************************************************************/
++#define LUA_BYTE_ARRAY "byte_array"
++#define checkbytearray(L, i) \
++ (lua_packet_segment *)luaL_checkudata(L, i, LUA_BYTE_ARRAY)
++lua_packet_segment * init_byte_array(lua_State *L, unsigned char * start, int length, int do_copy);
++void luaopen_bytearraylib(lua_State *L);
++
++
++/**********************************************************************/
++/* lua netfilter environment library */
++/**********************************************************************/
++#define NETFILTER_LIB "nf"
++#if defined(__KERNEL__)
++ struct lua_env {
++ lua_State *L;
++ /* perhaps more to come here (e.g. a state per CPU) */
++ };
++ #define LUA_ENV "lua_env"
++ #define checkluaenv(L, i) \
++ (struct lua_env *)luaL_checkudata(L, i, LUA_ENV)
++
++ void luaopen_nflib(lua_State *L);
++#endif
++
++void cleanup_dynamic_prot_bufs(void); /* freeing all dynamic prot bufs */
++/**********************************************************************/
++/* lua protbuf helpers */
++/**********************************************************************/
++int get_1_bit_generic(lua_State *L);
++int set_1_bit_generic(lua_State *L);
++int get_lower_4_bit_generic(lua_State *L);
++int set_lower_4_bit_generic(lua_State *L);
++int get_upper_4_bit_generic(lua_State *L);
++int set_upper_4_bit_generic(lua_State *L);
++int get_8_bit_generic(lua_State *L);
++int set_8_bit_generic(lua_State *L);
++int get_16_bit_generic(lua_State *L);
++int set_16_bit_generic(lua_State *L);
++int get_32_bit_generic(lua_State *L);
++int set_32_bit_generic(lua_State *L);
++int set_data_generic(lua_State *L);
++int get_string_generic(lua_State *L);
++int get_byte_generic_str(lua_State *L);
++struct field_changes * get_allocated_field_changes(lua_State *L, int nr_of_fields);
++
++/* only used by the dynamic prot buf subsystem */
++#define MAX_NR_OF_DYN_PROT_BUFS 16
++int field_dynamic_setter(lua_State *L);
++int field_dynamic_getter(lua_State *L);
++int has_protocol_dynamic(lua_State *L, struct protocol_buf * prot_buf, lua_packet_segment * seg, int type);
++struct field_changes * get_field_changes_dynamic(lua_State *L, struct protocol_buf *prot_buf, lua_packet_segment * seg);
++
++/**********************************************************************/
++/* lua controller API */
++/**********************************************************************/
++void luaopen_controller(lua_State *L);
++struct protocol_buf * get_protocol_buf(unsigned int protocol_id);
++void get_metatable_from_protocol_type(lua_State *L, int type);
++void register_protbuf(lua_State *L, struct protocol_buf * prot_buf, unsigned int protocol_index);
++
++
++#endif /* CONTROLLER_H_ */
+--- /dev/null
++++ b/extensions/LUA/Kbuild
+@@ -0,0 +1,49 @@
++# -*- Makefile -*-
++
++# Adding debug options
++EXTRA_CFLAGS += -DDEBUG
++
++obj-m += xt_LUA.o
++
++EXTRA_CFLAGS += -I$(src)/prot_buf_new
++xt_LUA-y += xt_LUA_target.o \
++
++xt_LUA-y += nf_lua.o \
++ prot_buf_helpers.o \
++ byte_array.o \
++ controller.o \
++ prot_buf_ethernet.o \
++ prot_buf_icmp.o \
++ prot_buf_ip.o \
++ prot_buf_raw.o \
++ prot_buf_tcp.o \
++ prot_buf_udp.o \
++ prot_buf_tftp.o \
++ prot_buf_dynamic.o \
++
++
++# Adding Lua Support
++EXTRA_CFLAGS += -I$(src)/lua -I$(src)/lua/include
++xt_LUA-y += lua/lapi.o \
++ lua/lbaselib.o \
++ lua/lcode.o \
++ lua/ldebug.o \
++ lua/ldo.o \
++ lua/ldump.o \
++ lua/lfunc.o \
++ lua/lgc.o \
++ lua/llex.o \
++ lua/lmem.o \
++ lua/lobject.o \
++ lua/lopcodes.o \
++ lua/lparser.o \
++ lua/lstate.o \
++ lua/lstring.o \
++ lua/lstrlib.o \
++ lua/ltable.o \
++ lua/ltablib.o \
++ lua/ltm.o \
++ lua/lundump.o \
++ lua/lvm.o \
++ lua/lzio.o \
++ lua/lauxlib.o \
+--- /dev/null
++++ b/extensions/LUA/libxt_LUA.c
+@@ -0,0 +1,191 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre@dergraf.org>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++
++#include <getopt.h>
++#include <stdio.h>
++#include <stdbool.h>
++#include <stdlib.h>
++#include <string.h>
++#include <xtables.h>
++#include <linux/netfilter.h>
++#include <linux/netfilter/x_tables.h>
++#include "xt_LUA.h"
++
++enum {
++ FLAG_SCRIPT = 1 << 0,
++ FLAG_STATE = 1 << 1,
++ FLAG_FUNCTION = 1 << 2,
++};
++
++static const struct option lua_tg_opts[] = {
++ { .name = "script", .has_arg = true, .val = 's' },
++ { .name = "state", .has_arg = true, .val = 'l' },
++ { .name = "function", .has_arg = true, .val = 'f' },
++ { NULL },
++};
++
++
++static void lua_tg_help(void)
++{
++ printf(
++ "LUA target options:\n"
++ " --script SCRIPT Process packet with the Lua script given by SCRIPT\n"
++ " \n"
++ " --state ID Process packet within the Lua state given by ID.\n"
++ " Omitting --state infers the ID 0, which can be\n"
++ " refered to the 'global' state.\n"
++ " \n"
++ " --function FUNCTION Name of the function that processes the Lua packet\n"
++ "\n");
++}
++
++static void
++lua_tg_init(struct xt_entry_target *target)
++{
++ struct xt_lua_tginfo *info = (void *)target->data;
++
++ info->state_id = 0;
++ strncpy(info->function, "process_packet\0", sizeof("process_packet\0"));
++}
++
++static int
++lua_tg_parse(int32_t c, char **argv, int32_t invert, uint32_t *flags,
++ const void *entry, struct xt_entry_target **target)
++{
++ struct xt_lua_tginfo *info = (void *)(*target)->data;
++ char buf[MAX_SCRIPT_SIZE];
++ long script_size;
++ uint32_t state_id;
++ FILE *file;
++
++ switch (c) {
++ case 's':
++ if (*flags & FLAG_SCRIPT)
++ xtables_error(PARAMETER_PROBLEM,
++ "LUA: Cannot specify --script more than once");
++
++ if (strlen(optarg) > sizeof(info->filename))
++ xtables_error(PARAMETER_PROBLEM,
++ "LUA: Maximum script length is %zu",
++ sizeof(info->filename));
++
++ if (strchr(optarg, '\n'))
++ xtables_error(PARAMETER_PROBLEM,
++ "LUA: Newlines not allowed in script name");
++ file = fopen(optarg, "rb");
++ if (file != NULL) {
++ fseek(file, 0, SEEK_END);
++ script_size = ftell(file);
++ if (script_size > MAX_SCRIPT_SIZE)
++ xtables_error(PARAMETER_PROBLEM,
++ "LUA: The size of the script is too big");
++
++ fseek(file, 0, SEEK_SET);
++ fread(buf, script_size, 1, file);
++ fclose(file);
++ } else
++ xtables_error(PARAMETER_PROBLEM,
++ "LUA: Cannot open script %s", optarg);
++
++ strncpy(info->filename, optarg, sizeof(info->filename));
++ strncpy(info->buf, buf, sizeof(info->buf));
++ info->script_size = script_size;
++
++ *flags |= FLAG_SCRIPT;
++ return true;
++
++ case 'l':
++ if (*flags & FLAG_STATE)
++ xtables_error(PARAMETER_PROBLEM,
++ "LUA: Cannot specify --state more than once");
++
++ if (!xtables_strtoui(optarg, NULL, &state_id, 0, 8))
++ xtables_error(PARAMETER_PROBLEM,
++ "LUA: Invalid --state %s", optarg);
++
++ info->state_id = state_id;
++ *flags |= FLAG_STATE;
++ return true;
++
++ case 'f':
++ if (*flags & FLAG_FUNCTION)
++ xtables_error(PARAMETER_PROBLEM,
++ "LUA: Cannot specify --function more than once");
++ if (strlen(optarg) > sizeof(info->function))
++ xtables_error(PARAMETER_PROBLEM,
++ "LUA: Maximum function length is %zu",
++ sizeof(info->function));
++
++ if (strchr(optarg, '\n'))
++ xtables_error(PARAMETER_PROBLEM,
++ "LUA: Newlines not allowed in function name");
++
++ strncpy(info->function, optarg, sizeof(info->function));
++
++ *flags |= FLAG_FUNCTION;
++ return true;
++ }
++
++ return false;
++}
++
++static void
++lua_tg_check(uint32_t flags)
++{
++ if (flags == 0)
++ xtables_error(PARAMETER_PROBLEM, "LUA: --script parameter required");
++}
++
++static void
++lua_tg_print(const void *entry, const struct xt_entry_target *target,
++ int32_t numeric)
++{
++ const struct xt_lua_tginfo *info = (const void *)target->data;
++
++ printf("LUA script: %s ", info->filename);
++}
++
++static void
++lua_tg_save(const void *entry, const struct xt_entry_target *target)
++{
++ const struct xt_lua_tginfo *info = (const void *)target->data;
++
++ printf("--script %s ", info->filename);
++}
++
++static struct xtables_target lua_tg_reg = {
++ .name = "LUA",
++ .version = XTABLES_VERSION,
++ .revision = 0,
++ .family = NFPROTO_UNSPEC,
++ .size = XT_ALIGN(sizeof(struct xt_lua_tginfo)),
++ .userspacesize = XT_ALIGN(sizeof(struct xt_lua_tginfo)),
++ .help = lua_tg_help,
++ .init = lua_tg_init,
++ .parse = lua_tg_parse,
++ .final_check = lua_tg_check,
++ .print = lua_tg_print,
++ .save = lua_tg_save,
++ .extra_opts = lua_tg_opts,
++};
++
++static __attribute__((constructor)) void lua_tg_ldr(void)
++{
++ xtables_register_target(&lua_tg_reg);
++}
++
+--- /dev/null
++++ b/extensions/LUA/libxt_LUA.man
+@@ -0,0 +1 @@
++Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
+--- /dev/null
++++ b/extensions/LUA/lua/include/ctype.h
+@@ -0,0 +1,11 @@
++#include <linux/ctype.h>
++#undef isalnum
++#define isalnum(c) (((__ismask(c)&(_U|_L|_D)) != 0) && (c > 0))
++#undef isalpha
++#define isalpha(c) (((__ismask(c)&(_U|_L)) != 0) && (c > 0))
++#undef iscntrl
++#define iscntrl(c) (((__ismask(c)&(_C)) != 0) && (c > 0))
++#undef isdigit
++#define isdigit(c) (((__ismask(c)&(_D)) != 0) && (c > 0))
++#undef isspace
++#define isspace(c) (((__ismask(c)&(_S)) != 0) && (c > 0))
+--- /dev/null
++++ b/extensions/LUA/lua/include/errno.h
+@@ -0,0 +1 @@
++#include <linux/errno.h>
+--- /dev/null
++++ b/extensions/LUA/lua/include/locale.h
+@@ -0,0 +1,5 @@
++struct lconv {
++ char * decimal_point ;
++} ;
++
++#define localeconv() NULL
+--- /dev/null
++++ b/extensions/LUA/lua/include/setjmp.h
+@@ -0,0 +1,26 @@
++/*
++ * arch/um/include/sysdep-i386/archsetjmp.h
++ */
++
++#ifndef _KLIBC_ARCHSETJMP_H
++#define _KLIBC_ARCHSETJMP_H
++
++struct __jmp_buf {
++ unsigned int __ebx;
++ unsigned int __esp;
++ unsigned int __ebp;
++ unsigned int __esi;
++ unsigned int __edi;
++ unsigned int __eip;
++};
++
++typedef struct __jmp_buf jmp_buf[1];
++
++#define JB_IP __eip
++#define JB_SP __esp
++
++int setjmp(jmp_buf);
++void longjmp(jmp_buf, int);
++
++#endif /* _SETJMP_H */
++
+--- /dev/null
++++ b/extensions/LUA/lua/include/stdio.h
+@@ -0,0 +1 @@
++#include <linux/kernel.h>
+--- /dev/null
++++ b/extensions/LUA/lua/include/stdlib.h
+@@ -0,0 +1,7 @@
++#include <linux/kernel.h>
++
++#define exit(E) return
++#define strtoul simple_strtoul
++#define strcoll strcmp
++
++#define CHAR_BIT 8
+--- /dev/null
++++ b/extensions/LUA/lua/include/string.h
+@@ -0,0 +1 @@
++#include <linux/string.h>
+--- /dev/null
++++ b/extensions/LUA/lua/lapi.c
+@@ -0,0 +1,1086 @@
++/*
++** $Id: lapi.c,v 2.55.1.5 2008/07/04 18:41:18 roberto Exp $
++** Lua API
++** See Copyright Notice in lua.h
++*/
++
++#include <stdarg.h>
++#include <math.h>
++#include <assert.h>
++#include <string.h>
++
++#define lapi_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "lapi.h"
++#include "ldebug.h"
++#include "ldo.h"
++#include "lfunc.h"
++#include "lgc.h"
++#include "lmem.h"
++#include "lobject.h"
++#include "lstate.h"
++#include "lstring.h"
++#include "ltable.h"
++#include "ltm.h"
++#include "lundump.h"
++#include "lvm.h"
++
++
++
++const char lua_ident[] =
++ "$Lua: " LUA_RELEASE " " LUA_COPYRIGHT " $\n"
++ "$Authors: " LUA_AUTHORS " $\n"
++ "$URL: www.lua.org $\n";
++
++
++
++#define api_checknelems(L, n) api_check(L, (n) <= (L->top - L->base))
++
++#define api_checkvalidindex(L, i) api_check(L, (i) != luaO_nilobject)
++
++#define api_incr_top(L) {api_check(L, L->top < L->ci->top); L->top++;}
++
++
++
++static TValue *index2adr (lua_State *L, int idx) {
++ if (idx > 0) {
++ TValue *o = L->base + (idx - 1);
++ api_check(L, idx <= L->ci->top - L->base);
++ if (o >= L->top) return cast(TValue *, luaO_nilobject);
++ else return o;
++ }
++ else if (idx > LUA_REGISTRYINDEX) {
++ api_check(L, idx != 0 && -idx <= L->top - L->base);
++ return L->top + idx;
++ }
++ else switch (idx) { /* pseudo-indices */
++ case LUA_REGISTRYINDEX: return registry(L);
++ case LUA_ENVIRONINDEX: {
++ Closure *func = curr_func(L);
++ sethvalue(L, &L->env, func->c.env);
++ return &L->env;
++ }
++ case LUA_GLOBALSINDEX: return gt(L);
++ default: {
++ Closure *func = curr_func(L);
++ idx = LUA_GLOBALSINDEX - idx;
++ return (idx <= func->c.nupvalues)
++ ? &func->c.upvalue[idx-1]
++ : cast(TValue *, luaO_nilobject);
++ }
++ }
++}
++
++
++static Table *getcurrenv (lua_State *L) {
++ if (L->ci == L->base_ci) /* no enclosing function? */
++ return hvalue(gt(L)); /* use global table as environment */
++ else {
++ Closure *func = curr_func(L);
++ return func->c.env;
++ }
++}
++
++
++void luaA_pushobject (lua_State *L, const TValue *o) {
++ setobj2s(L, L->top, o);
++ api_incr_top(L);
++}
++
++
++LUA_API int lua_checkstack (lua_State *L, int size) {
++ int res = 1;
++ lua_lock(L);
++ if (size > LUAI_MAXCSTACK || (L->top - L->base + size) > LUAI_MAXCSTACK)
++ res = 0; /* stack overflow */
++ else if (size > 0) {
++ luaD_checkstack(L, size);
++ if (L->ci->top < L->top + size)
++ L->ci->top = L->top + size;
++ }
++ lua_unlock(L);
++ return res;
++}
++
++
++LUA_API void lua_xmove (lua_State *from, lua_State *to, int n) {
++ int i;
++ if (from == to) return;
++ lua_lock(to);
++ api_checknelems(from, n);
++ api_check(from, G(from) == G(to));
++ api_check(from, to->ci->top - to->top >= n);
++ from->top -= n;
++ for (i = 0; i < n; i++) {
++ setobj2s(to, to->top++, from->top + i);
++ }
++ lua_unlock(to);
++}
++
++
++LUA_API void lua_setlevel (lua_State *from, lua_State *to) {
++ to->nCcalls = from->nCcalls;
++}
++
++
++LUA_API lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf) {
++ lua_CFunction old;
++ lua_lock(L);
++ old = G(L)->panic;
++ G(L)->panic = panicf;
++ lua_unlock(L);
++ return old;
++}
++
++
++LUA_API lua_State *lua_newthread (lua_State *L) {
++ lua_State *L1;
++ lua_lock(L);
++ luaC_checkGC(L);
++ L1 = luaE_newthread(L);
++ setthvalue(L, L->top, L1);
++ api_incr_top(L);
++ lua_unlock(L);
++ luai_userstatethread(L, L1);
++ return L1;
++}
++
++
++
++/*
++** basic stack manipulation
++*/
++
++
++LUA_API int lua_gettop (lua_State *L) {
++ return cast_int(L->top - L->base);
++}
++
++
++LUA_API void lua_settop (lua_State *L, int idx) {
++ lua_lock(L);
++ if (idx >= 0) {
++ api_check(L, idx <= L->stack_last - L->base);
++ while (L->top < L->base + idx)
++ setnilvalue(L->top++);
++ L->top = L->base + idx;
++ }
++ else {
++ api_check(L, -(idx+1) <= (L->top - L->base));
++ L->top += idx+1; /* `subtract' index (index is negative) */
++ }
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_remove (lua_State *L, int idx) {
++ StkId p;
++ lua_lock(L);
++ p = index2adr(L, idx);
++ api_checkvalidindex(L, p);
++ while (++p < L->top) setobjs2s(L, p-1, p);
++ L->top--;
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_insert (lua_State *L, int idx) {
++ StkId p;
++ StkId q;
++ lua_lock(L);
++ p = index2adr(L, idx);
++ api_checkvalidindex(L, p);
++ for (q = L->top; q>p; q--) setobjs2s(L, q, q-1);
++ setobjs2s(L, p, L->top);
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_replace (lua_State *L, int idx) {
++ StkId o;
++ lua_lock(L);
++ /* explicit test for incompatible code */
++ if (idx == LUA_ENVIRONINDEX && L->ci == L->base_ci)
++ luaG_runerror(L, "no calling environment");
++ api_checknelems(L, 1);
++ o = index2adr(L, idx);
++ api_checkvalidindex(L, o);
++ if (idx == LUA_ENVIRONINDEX) {
++ Closure *func = curr_func(L);
++ api_check(L, ttistable(L->top - 1));
++ func->c.env = hvalue(L->top - 1);
++ luaC_barrier(L, func, L->top - 1);
++ }
++ else {
++ setobj(L, o, L->top - 1);
++ if (idx < LUA_GLOBALSINDEX) /* function upvalue? */
++ luaC_barrier(L, curr_func(L), L->top - 1);
++ }
++ L->top--;
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_pushvalue (lua_State *L, int idx) {
++ lua_lock(L);
++ setobj2s(L, L->top, index2adr(L, idx));
++ api_incr_top(L);
++ lua_unlock(L);
++}
++
++
++
++/*
++** access functions (stack -> C)
++*/
++
++
++LUA_API int lua_type (lua_State *L, int idx) {
++ StkId o = index2adr(L, idx);
++ return (o == luaO_nilobject) ? LUA_TNONE : ttype(o);
++}
++
++
++LUA_API const char *lua_typename (lua_State *L, int t) {
++ UNUSED(L);
++ return (t == LUA_TNONE) ? "no value" : luaT_typenames[t];
++}
++
++
++LUA_API int lua_iscfunction (lua_State *L, int idx) {
++ StkId o = index2adr(L, idx);
++ return iscfunction(o);
++}
++
++
++LUA_API int lua_isnumber (lua_State *L, int idx) {
++ TValue n;
++ const TValue *o = index2adr(L, idx);
++ return tonumber(o, &n);
++}
++
++
++LUA_API int lua_isstring (lua_State *L, int idx) {
++ int t = lua_type(L, idx);
++ return (t == LUA_TSTRING || t == LUA_TNUMBER);
++}
++
++
++LUA_API int lua_isuserdata (lua_State *L, int idx) {
++ const TValue *o = index2adr(L, idx);
++ return (ttisuserdata(o) || ttislightuserdata(o));
++}
++
++
++LUA_API int lua_rawequal (lua_State *L, int index1, int index2) {
++ StkId o1 = index2adr(L, index1);
++ StkId o2 = index2adr(L, index2);
++ return (o1 == luaO_nilobject || o2 == luaO_nilobject) ? 0
++ : luaO_rawequalObj(o1, o2);
++}
++
++
++LUA_API int lua_equal (lua_State *L, int index1, int index2) {
++ StkId o1, o2;
++ int i;
++ lua_lock(L); /* may call tag method */
++ o1 = index2adr(L, index1);
++ o2 = index2adr(L, index2);
++ i = (o1 == luaO_nilobject || o2 == luaO_nilobject) ? 0 : equalobj(L, o1, o2);
++ lua_unlock(L);
++ return i;
++}
++
++
++LUA_API int lua_lessthan (lua_State *L, int index1, int index2) {
++ StkId o1, o2;
++ int i;
++ lua_lock(L); /* may call tag method */
++ o1 = index2adr(L, index1);
++ o2 = index2adr(L, index2);
++ i = (o1 == luaO_nilobject || o2 == luaO_nilobject) ? 0
++ : luaV_lessthan(L, o1, o2);
++ lua_unlock(L);
++ return i;
++}
++
++
++
++LUA_API lua_Number lua_tonumber (lua_State *L, int idx) {
++ TValue n;
++ const TValue *o = index2adr(L, idx);
++ if (tonumber(o, &n))
++ return nvalue(o);
++ else
++ return 0;
++}
++
++
++LUA_API lua_Integer lua_tointeger (lua_State *L, int idx) {
++ TValue n;
++ const TValue *o = index2adr(L, idx);
++ if (tonumber(o, &n)) {
++ lua_Integer res;
++ lua_Number num = nvalue(o);
++ lua_number2integer(res, num);
++ return res;
++ }
++ else
++ return 0;
++}
++
++
++LUA_API int lua_toboolean (lua_State *L, int idx) {
++ const TValue *o = index2adr(L, idx);
++ return !l_isfalse(o);
++}
++
++
++LUA_API const char *lua_tolstring (lua_State *L, int idx, size_t *len) {
++ StkId o = index2adr(L, idx);
++ if (!ttisstring(o)) {
++ lua_lock(L); /* `luaV_tostring' may create a new string */
++ if (!luaV_tostring(L, o)) { /* conversion failed? */
++ if (len != NULL) *len = 0;
++ lua_unlock(L);
++ return NULL;
++ }
++ luaC_checkGC(L);
++ o = index2adr(L, idx); /* previous call may reallocate the stack */
++ lua_unlock(L);
++ }
++ if (len != NULL) *len = tsvalue(o)->len;
++ return svalue(o);
++}
++
++
++LUA_API size_t lua_objlen (lua_State *L, int idx) {
++ StkId o = index2adr(L, idx);
++ switch (ttype(o)) {
++ case LUA_TSTRING: return tsvalue(o)->len;
++ case LUA_TUSERDATA: return uvalue(o)->len;
++ case LUA_TTABLE: return luaH_getn(hvalue(o));
++ case LUA_TNUMBER: {
++ size_t l;
++ lua_lock(L); /* `luaV_tostring' may create a new string */
++ l = (luaV_tostring(L, o) ? tsvalue(o)->len : 0);
++ lua_unlock(L);
++ return l;
++ }
++ default: return 0;
++ }
++}
++
++
++LUA_API lua_CFunction lua_tocfunction (lua_State *L, int idx) {
++ StkId o = index2adr(L, idx);
++ return (!iscfunction(o)) ? NULL : clvalue(o)->c.f;
++}
++
++
++LUA_API void *lua_touserdata (lua_State *L, int idx) {
++ StkId o = index2adr(L, idx);
++ switch (ttype(o)) {
++ case LUA_TUSERDATA: return (rawuvalue(o) + 1);
++ case LUA_TLIGHTUSERDATA: return pvalue(o);
++ default: return NULL;
++ }
++}
++
++
++LUA_API lua_State *lua_tothread (lua_State *L, int idx) {
++ StkId o = index2adr(L, idx);
++ return (!ttisthread(o)) ? NULL : thvalue(o);
++}
++
++
++LUA_API const void *lua_topointer (lua_State *L, int idx) {
++ StkId o = index2adr(L, idx);
++ switch (ttype(o)) {
++ case LUA_TTABLE: return hvalue(o);
++ case LUA_TFUNCTION: return clvalue(o);
++ case LUA_TTHREAD: return thvalue(o);
++ case LUA_TUSERDATA:
++ case LUA_TLIGHTUSERDATA:
++ return lua_touserdata(L, idx);
++ default: return NULL;
++ }
++}
++
++
++
++/*
++** push functions (C -> stack)
++*/
++
++
++LUA_API void lua_pushnil (lua_State *L) {
++ lua_lock(L);
++ setnilvalue(L->top);
++ api_incr_top(L);
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_pushnumber (lua_State *L, lua_Number n) {
++ lua_lock(L);
++ setnvalue(L->top, n);
++ api_incr_top(L);
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_pushinteger (lua_State *L, lua_Integer n) {
++ lua_lock(L);
++ setnvalue(L->top, cast_num(n));
++ api_incr_top(L);
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_pushlstring (lua_State *L, const char *s, size_t len) {
++ lua_lock(L);
++ luaC_checkGC(L);
++ setsvalue2s(L, L->top, luaS_newlstr(L, s, len));
++ api_incr_top(L);
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_pushstring (lua_State *L, const char *s) {
++ if (s == NULL)
++ lua_pushnil(L);
++ else
++ lua_pushlstring(L, s, strlen(s));
++}
++
++
++LUA_API const char *lua_pushvfstring (lua_State *L, const char *fmt,
++ va_list argp) {
++ const char *ret;
++ lua_lock(L);
++ luaC_checkGC(L);
++ ret = luaO_pushvfstring(L, fmt, argp);
++ lua_unlock(L);
++ return ret;
++}
++
++
++LUA_API const char *lua_pushfstring (lua_State *L, const char *fmt, ...) {
++ const char *ret;
++ va_list argp;
++ lua_lock(L);
++ luaC_checkGC(L);
++ va_start(argp, fmt);
++ ret = luaO_pushvfstring(L, fmt, argp);
++ va_end(argp);
++ lua_unlock(L);
++ return ret;
++}
++
++
++LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) {
++ Closure *cl;
++ lua_lock(L);
++ luaC_checkGC(L);
++ api_checknelems(L, n);
++ cl = luaF_newCclosure(L, n, getcurrenv(L));
++ cl->c.f = fn;
++ L->top -= n;
++ while (n--)
++ setobj2n(L, &cl->c.upvalue[n], L->top+n);
++ setclvalue(L, L->top, cl);
++ lua_assert(iswhite(obj2gco(cl)));
++ api_incr_top(L);
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_pushboolean (lua_State *L, int b) {
++ lua_lock(L);
++ setbvalue(L->top, (b != 0)); /* ensure that true is 1 */
++ api_incr_top(L);
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_pushlightuserdata (lua_State *L, void *p) {
++ lua_lock(L);
++ setpvalue(L->top, p);
++ api_incr_top(L);
++ lua_unlock(L);
++}
++
++
++LUA_API int lua_pushthread (lua_State *L) {
++ lua_lock(L);
++ setthvalue(L, L->top, L);
++ api_incr_top(L);
++ lua_unlock(L);
++ return (G(L)->mainthread == L);
++}
++
++
++
++/*
++** get functions (Lua -> stack)
++*/
++
++
++LUA_API void lua_gettable (lua_State *L, int idx) {
++ StkId t;
++ lua_lock(L);
++ t = index2adr(L, idx);
++ api_checkvalidindex(L, t);
++ luaV_gettable(L, t, L->top - 1, L->top - 1);
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_getfield (lua_State *L, int idx, const char *k) {
++ StkId t;
++ TValue key;
++ lua_lock(L);
++ t = index2adr(L, idx);
++ api_checkvalidindex(L, t);
++ setsvalue(L, &key, luaS_new(L, k));
++ luaV_gettable(L, t, &key, L->top);
++ api_incr_top(L);
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_rawget (lua_State *L, int idx) {
++ StkId t;
++ lua_lock(L);
++ t = index2adr(L, idx);
++ api_check(L, ttistable(t));
++ setobj2s(L, L->top - 1, luaH_get(hvalue(t), L->top - 1));
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_rawgeti (lua_State *L, int idx, int n) {
++ StkId o;
++ lua_lock(L);
++ o = index2adr(L, idx);
++ api_check(L, ttistable(o));
++ setobj2s(L, L->top, luaH_getnum(hvalue(o), n));
++ api_incr_top(L);
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_createtable (lua_State *L, int narray, int nrec) {
++ lua_lock(L);
++ luaC_checkGC(L);
++ sethvalue(L, L->top, luaH_new(L, narray, nrec));
++ api_incr_top(L);
++ lua_unlock(L);
++}
++
++
++LUA_API int lua_getmetatable (lua_State *L, int objindex) {
++ const TValue *obj;
++ Table *mt = NULL;
++ int res;
++ lua_lock(L);
++ obj = index2adr(L, objindex);
++ switch (ttype(obj)) {
++ case LUA_TTABLE:
++ mt = hvalue(obj)->metatable;
++ break;
++ case LUA_TUSERDATA:
++ mt = uvalue(obj)->metatable;
++ break;
++ default:
++ mt = G(L)->mt[ttype(obj)];
++ break;
++ }
++ if (mt == NULL)
++ res = 0;
++ else {
++ sethvalue(L, L->top, mt);
++ api_incr_top(L);
++ res = 1;
++ }
++ lua_unlock(L);
++ return res;
++}
++
++
++LUA_API void lua_getfenv (lua_State *L, int idx) {
++ StkId o;
++ lua_lock(L);
++ o = index2adr(L, idx);
++ api_checkvalidindex(L, o);
++ switch (ttype(o)) {
++ case LUA_TFUNCTION:
++ sethvalue(L, L->top, clvalue(o)->c.env);
++ break;
++ case LUA_TUSERDATA:
++ sethvalue(L, L->top, uvalue(o)->env);
++ break;
++ case LUA_TTHREAD:
++ setobj2s(L, L->top, gt(thvalue(o)));
++ break;
++ default:
++ setnilvalue(L->top);
++ break;
++ }
++ api_incr_top(L);
++ lua_unlock(L);
++}
++
++
++/*
++** set functions (stack -> Lua)
++*/
++
++
++LUA_API void lua_settable (lua_State *L, int idx) {
++ StkId t;
++ lua_lock(L);
++ api_checknelems(L, 2);
++ t = index2adr(L, idx);
++ api_checkvalidindex(L, t);
++ luaV_settable(L, t, L->top - 2, L->top - 1);
++ L->top -= 2; /* pop index and value */
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_setfield (lua_State *L, int idx, const char *k) {
++ StkId t;
++ TValue key;
++ lua_lock(L);
++ api_checknelems(L, 1);
++ t = index2adr(L, idx);
++ api_checkvalidindex(L, t);
++ setsvalue(L, &key, luaS_new(L, k));
++ luaV_settable(L, t, &key, L->top - 1);
++ L->top--; /* pop value */
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_rawset (lua_State *L, int idx) {
++ StkId t;
++ lua_lock(L);
++ api_checknelems(L, 2);
++ t = index2adr(L, idx);
++ api_check(L, ttistable(t));
++ setobj2t(L, luaH_set(L, hvalue(t), L->top-2), L->top-1);
++ luaC_barriert(L, hvalue(t), L->top-1);
++ L->top -= 2;
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_rawseti (lua_State *L, int idx, int n) {
++ StkId o;
++ lua_lock(L);
++ api_checknelems(L, 1);
++ o = index2adr(L, idx);
++ api_check(L, ttistable(o));
++ setobj2t(L, luaH_setnum(L, hvalue(o), n), L->top-1);
++ luaC_barriert(L, hvalue(o), L->top-1);
++ L->top--;
++ lua_unlock(L);
++}
++
++
++LUA_API int lua_setmetatable (lua_State *L, int objindex) {
++ TValue *obj;
++ Table *mt;
++ lua_lock(L);
++ api_checknelems(L, 1);
++ obj = index2adr(L, objindex);
++ api_checkvalidindex(L, obj);
++ if (ttisnil(L->top - 1))
++ mt = NULL;
++ else {
++ api_check(L, ttistable(L->top - 1));
++ mt = hvalue(L->top - 1);
++ }
++ switch (ttype(obj)) {
++ case LUA_TTABLE: {
++ hvalue(obj)->metatable = mt;
++ if (mt)
++ luaC_objbarriert(L, hvalue(obj), mt);
++ break;
++ }
++ case LUA_TUSERDATA: {
++ uvalue(obj)->metatable = mt;
++ if (mt)
++ luaC_objbarrier(L, rawuvalue(obj), mt);
++ break;
++ }
++ default: {
++ G(L)->mt[ttype(obj)] = mt;
++ break;
++ }
++ }
++ L->top--;
++ lua_unlock(L);
++ return 1;
++}
++
++
++LUA_API int lua_setfenv (lua_State *L, int idx) {
++ StkId o;
++ int res = 1;
++ lua_lock(L);
++ api_checknelems(L, 1);
++ o = index2adr(L, idx);
++ api_checkvalidindex(L, o);
++ api_check(L, ttistable(L->top - 1));
++ switch (ttype(o)) {
++ case LUA_TFUNCTION:
++ clvalue(o)->c.env = hvalue(L->top - 1);
++ break;
++ case LUA_TUSERDATA:
++ uvalue(o)->env = hvalue(L->top - 1);
++ break;
++ case LUA_TTHREAD:
++ sethvalue(L, gt(thvalue(o)), hvalue(L->top - 1));
++ break;
++ default:
++ res = 0;
++ break;
++ }
++ if (res) luaC_objbarrier(L, gcvalue(o), hvalue(L->top - 1));
++ L->top--;
++ lua_unlock(L);
++ return res;
++}
++
++
++/*
++** `load' and `call' functions (run Lua code)
++*/
++
++
++#define adjustresults(L,nres) \
++ { if (nres == LUA_MULTRET && L->top >= L->ci->top) L->ci->top = L->top; }
++
++
++#define checkresults(L,na,nr) \
++ api_check(L, (nr) == LUA_MULTRET || (L->ci->top - L->top >= (nr) - (na)))
++
++
++LUA_API void lua_call (lua_State *L, int nargs, int nresults) {
++ StkId func;
++ lua_lock(L);
++ api_checknelems(L, nargs+1);
++ checkresults(L, nargs, nresults);
++ func = L->top - (nargs+1);
++ luaD_call(L, func, nresults);
++ adjustresults(L, nresults);
++ lua_unlock(L);
++}
++
++
++
++/*
++** Execute a protected call.
++*/
++struct CallS { /* data to `f_call' */
++ StkId func;
++ int nresults;
++};
++
++
++static void f_call (lua_State *L, void *ud) {
++ struct CallS *c = cast(struct CallS *, ud);
++ luaD_call(L, c->func, c->nresults);
++}
++
++
++
++LUA_API int lua_pcall (lua_State *L, int nargs, int nresults, int errfunc) {
++ struct CallS c;
++ int status;
++ ptrdiff_t func;
++ lua_lock(L);
++ api_checknelems(L, nargs+1);
++ checkresults(L, nargs, nresults);
++ if (errfunc == 0)
++ func = 0;
++ else {
++ StkId o = index2adr(L, errfunc);
++ api_checkvalidindex(L, o);
++ func = savestack(L, o);
++ }
++ c.func = L->top - (nargs+1); /* function to be called */
++ c.nresults = nresults;
++ status = luaD_pcall(L, f_call, &c, savestack(L, c.func), func);
++ adjustresults(L, nresults);
++ lua_unlock(L);
++ return status;
++}
++
++
++/*
++** Execute a protected C call.
++*/
++struct CCallS { /* data to `f_Ccall' */
++ lua_CFunction func;
++ void *ud;
++};
++
++
++static void f_Ccall (lua_State *L, void *ud) {
++ struct CCallS *c = cast(struct CCallS *, ud);
++ Closure *cl;
++ cl = luaF_newCclosure(L, 0, getcurrenv(L));
++ cl->c.f = c->func;
++ setclvalue(L, L->top, cl); /* push function */
++ api_incr_top(L);
++ setpvalue(L->top, c->ud); /* push only argument */
++ api_incr_top(L);
++ luaD_call(L, L->top - 2, 0);
++}
++
++
++LUA_API int lua_cpcall (lua_State *L, lua_CFunction func, void *ud) {
++ struct CCallS c;
++ int status;
++ lua_lock(L);
++ c.func = func;
++ c.ud = ud;
++ status = luaD_pcall(L, f_Ccall, &c, savestack(L, L->top), 0);
++ lua_unlock(L);
++ return status;
++}
++
++
++LUA_API int lua_load (lua_State *L, lua_Reader reader, void *data,
++ const char *chunkname) {
++ ZIO z;
++ int status;
++ lua_lock(L);
++ if (!chunkname) chunkname = "?";
++ luaZ_init(L, &z, reader, data);
++ status = luaD_protectedparser(L, &z, chunkname);
++ lua_unlock(L);
++ return status;
++}
++
++
++LUA_API int lua_dump (lua_State *L, lua_Writer writer, void *data) {
++ int status;
++ TValue *o;
++ lua_lock(L);
++ api_checknelems(L, 1);
++ o = L->top - 1;
++ if (isLfunction(o))
++ status = luaU_dump(L, clvalue(o)->l.p, writer, data, 0);
++ else
++ status = 1;
++ lua_unlock(L);
++ return status;
++}
++
++
++LUA_API int lua_status (lua_State *L) {
++ return L->status;
++}
++
++
++/*
++** Garbage-collection function
++*/
++
++LUA_API int lua_gc (lua_State *L, int what, int data) {
++ int res = 0;
++ global_State *g;
++ lua_lock(L);
++ g = G(L);
++ switch (what) {
++ case LUA_GCSTOP: {
++ g->GCthreshold = MAX_LUMEM;
++ break;
++ }
++ case LUA_GCRESTART: {
++ g->GCthreshold = g->totalbytes;
++ break;
++ }
++ case LUA_GCCOLLECT: {
++ luaC_fullgc(L);
++ break;
++ }
++ case LUA_GCCOUNT: {
++ /* GC values are expressed in Kbytes: #bytes/2^10 */
++ res = cast_int(g->totalbytes >> 10);
++ break;
++ }
++ case LUA_GCCOUNTB: {
++ res = cast_int(g->totalbytes & 0x3ff);
++ break;
++ }
++ case LUA_GCSTEP: {
++ lu_mem a = (cast(lu_mem, data) << 10);
++ if (a <= g->totalbytes)
++ g->GCthreshold = g->totalbytes - a;
++ else
++ g->GCthreshold = 0;
++ while (g->GCthreshold <= g->totalbytes) {
++ luaC_step(L);
++ if (g->gcstate == GCSpause) { /* end of cycle? */
++ res = 1; /* signal it */
++ break;
++ }
++ }
++ break;
++ }
++ case LUA_GCSETPAUSE: {
++ res = g->gcpause;
++ g->gcpause = data;
++ break;
++ }
++ case LUA_GCSETSTEPMUL: {
++ res = g->gcstepmul;
++ g->gcstepmul = data;
++ break;
++ }
++ default: res = -1; /* invalid option */
++ }
++ lua_unlock(L);
++ return res;
++}
++
++
++
++/*
++** miscellaneous functions
++*/
++
++
++LUA_API int lua_error (lua_State *L) {
++ lua_lock(L);
++ api_checknelems(L, 1);
++ luaG_errormsg(L);
++ lua_unlock(L);
++ return 0; /* to avoid warnings */
++}
++
++
++LUA_API int lua_next (lua_State *L, int idx) {
++ StkId t;
++ int more;
++ lua_lock(L);
++ t = index2adr(L, idx);
++ api_check(L, ttistable(t));
++ more = luaH_next(L, hvalue(t), L->top - 1);
++ if (more) {
++ api_incr_top(L);
++ }
++ else /* no more elements */
++ L->top -= 1; /* remove key */
++ lua_unlock(L);
++ return more;
++}
++
++
++LUA_API void lua_concat (lua_State *L, int n) {
++ lua_lock(L);
++ api_checknelems(L, n);
++ if (n >= 2) {
++ luaC_checkGC(L);
++ luaV_concat(L, n, cast_int(L->top - L->base) - 1);
++ L->top -= (n-1);
++ }
++ else if (n == 0) { /* push empty string */
++ setsvalue2s(L, L->top, luaS_newlstr(L, "", 0));
++ api_incr_top(L);
++ }
++ /* else n == 1; nothing to do */
++ lua_unlock(L);
++}
++
++
++LUA_API lua_Alloc lua_getallocf (lua_State *L, void **ud) {
++ lua_Alloc f;
++ lua_lock(L);
++ if (ud) *ud = G(L)->ud;
++ f = G(L)->frealloc;
++ lua_unlock(L);
++ return f;
++}
++
++
++LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud) {
++ lua_lock(L);
++ G(L)->ud = ud;
++ G(L)->frealloc = f;
++ lua_unlock(L);
++}
++
++
++LUA_API void *lua_newuserdata (lua_State *L, size_t size) {
++ Udata *u;
++ lua_lock(L);
++ luaC_checkGC(L);
++ u = luaS_newudata(L, size, getcurrenv(L));
++ setuvalue(L, L->top, u);
++ api_incr_top(L);
++ lua_unlock(L);
++ return u + 1;
++}
++
++
++
++
++static const char *aux_upvalue (StkId fi, int n, TValue **val) {
++ Closure *f;
++ if (!ttisfunction(fi)) return NULL;
++ f = clvalue(fi);
++ if (f->c.isC) {
++ if (!(1 <= n && n <= f->c.nupvalues)) return NULL;
++ *val = &f->c.upvalue[n-1];
++ return "";
++ }
++ else {
++ Proto *p = f->l.p;
++ if (!(1 <= n && n <= p->sizeupvalues)) return NULL;
++ *val = f->l.upvals[n-1]->v;
++ return getstr(p->upvalues[n-1]);
++ }
++}
++
++
++LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n) {
++ const char *name;
++ TValue *val;
++ lua_lock(L);
++ name = aux_upvalue(index2adr(L, funcindex), n, &val);
++ if (name) {
++ setobj2s(L, L->top, val);
++ api_incr_top(L);
++ }
++ lua_unlock(L);
++ return name;
++}
++
++
++LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n) {
++ const char *name;
++ TValue *val;
++ StkId fi;
++ lua_lock(L);
++ fi = index2adr(L, funcindex);
++ api_checknelems(L, 1);
++ name = aux_upvalue(fi, n, &val);
++ if (name) {
++ L->top--;
++ setobj(L, val, L->top);
++ luaC_barrier(L, clvalue(fi), L->top);
++ }
++ lua_unlock(L);
++ return name;
++}
++
+--- /dev/null
++++ b/extensions/LUA/lua/lapi.h
+@@ -0,0 +1,16 @@
++/*
++** $Id: lapi.h,v 2.2.1.1 2007/12/27 13:02:25 roberto Exp $
++** Auxiliary functions from Lua API
++** See Copyright Notice in lua.h
++*/
++
++#ifndef lapi_h
++#define lapi_h
++
++
++#include "lobject.h"
++
++
++LUAI_FUNC void luaA_pushobject (lua_State *L, const TValue *o);
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/lauxlib.c
+@@ -0,0 +1,674 @@
++/*
++** $Id: lauxlib.c,v 1.159.1.3 2008/01/21 13:20:51 roberto Exp $
++** Auxiliary functions for building Lua libraries
++** See Copyright Notice in lua.h
++*/
++
++#include <stdarg.h>
++
++#if !defined(__KERNEL__)
++#include <ctype.h>
++#include <errno.h>
++#include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
++#else
++#include <linux/ctype.h>
++#include <linux/errno.h>
++#include <linux/kernel.h>
++#include <linux/slab.h>
++#include <linux/string.h>
++#endif
++
++/* This file uses only the official API of Lua.
++** Any function declared here could be written as an application function.
++*/
++
++#define lauxlib_c
++#define LUA_LIB
++
++#include "lua.h"
++
++#include "lauxlib.h"
++
++
++#define FREELIST_REF 0 /* free list of references */
++
++
++/* convert a stack index to positive */
++#define abs_index(L, i) ((i) > 0 || (i) <= LUA_REGISTRYINDEX ? (i) : \
++ lua_gettop(L) + (i) + 1)
++
++
++/*
++** {======================================================
++** Error-report functions
++** =======================================================
++*/
++
++
++LUALIB_API int luaL_argerror (lua_State *L, int narg, const char *extramsg) {
++ lua_Debug ar;
++ if (!lua_getstack(L, 0, &ar)) /* no stack frame? */
++ return luaL_error(L, "bad argument #%d (%s)", narg, extramsg);
++ lua_getinfo(L, "n", &ar);
++ if (strcmp(ar.namewhat, "method") == 0) {
++ narg--; /* do not count `self' */
++ if (narg == 0) /* error is in the self argument itself? */
++ return luaL_error(L, "calling " LUA_QS " on bad self (%s)",
++ ar.name, extramsg);
++ }
++ if (ar.name == NULL)
++ ar.name = "?";
++ return luaL_error(L, "bad argument #%d to " LUA_QS " (%s)",
++ narg, ar.name, extramsg);
++}
++
++
++LUALIB_API int luaL_typerror (lua_State *L, int narg, const char *tname) {
++ const char *msg = lua_pushfstring(L, "%s expected, got %s",
++ tname, luaL_typename(L, narg));
++ return luaL_argerror(L, narg, msg);
++}
++
++
++static void tag_error (lua_State *L, int narg, int tag) {
++ luaL_typerror(L, narg, lua_typename(L, tag));
++}
++
++
++LUALIB_API void luaL_where (lua_State *L, int level) {
++ lua_Debug ar;
++ if (lua_getstack(L, level, &ar)) { /* check function at level */
++ lua_getinfo(L, "Sl", &ar); /* get info about it */
++ if (ar.currentline > 0) { /* is there info? */
++ lua_pushfstring(L, "%s:%d: ", ar.short_src, ar.currentline);
++ return;
++ }
++ }
++ lua_pushliteral(L, ""); /* else, no information available... */
++}
++
++
++LUALIB_API int luaL_error (lua_State *L, const char *fmt, ...) {
++ va_list argp;
++ va_start(argp, fmt);
++ luaL_where(L, 1);
++ lua_pushvfstring(L, fmt, argp);
++ va_end(argp);
++ lua_concat(L, 2);
++ return lua_error(L);
++}
++
++/* }====================================================== */
++
++
++LUALIB_API int luaL_checkoption (lua_State *L, int narg, const char *def,
++ const char *const lst[]) {
++ const char *name = (def) ? luaL_optstring(L, narg, def) :
++ luaL_checkstring(L, narg);
++ int i;
++ for (i=0; lst[i]; i++)
++ if (strcmp(lst[i], name) == 0)
++ return i;
++ return luaL_argerror(L, narg,
++ lua_pushfstring(L, "invalid option " LUA_QS, name));
++}
++
++
++LUALIB_API int luaL_newmetatable (lua_State *L, const char *tname) {
++ lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get registry.name */
++ if (!lua_isnil(L, -1)) /* name already in use? */
++ return 0; /* leave previous value on top, but return 0 */
++ lua_pop(L, 1);
++ lua_newtable(L); /* create metatable */
++ lua_pushvalue(L, -1);
++ lua_setfield(L, LUA_REGISTRYINDEX, tname); /* registry.name = metatable */
++ return 1;
++}
++
++
++LUALIB_API void *luaL_checkudata (lua_State *L, int ud, const char *tname) {
++ void *p = lua_touserdata(L, ud);
++ if (p != NULL) { /* value is a userdata? */
++ if (lua_getmetatable(L, ud)) { /* does it have a metatable? */
++ lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get correct metatable */
++ if (lua_rawequal(L, -1, -2)) { /* does it have the correct mt? */
++ lua_pop(L, 2); /* remove both metatables */
++ return p;
++ }
++ }
++ }
++ luaL_typerror(L, ud, tname); /* else error */
++ return NULL; /* to avoid warnings */
++}
++
++
++LUALIB_API void luaL_checkstack (lua_State *L, int space, const char *mes) {
++ if (!lua_checkstack(L, space))
++ luaL_error(L, "stack overflow (%s)", mes);
++}
++
++
++LUALIB_API void luaL_checktype (lua_State *L, int narg, int t) {
++ if (lua_type(L, narg) != t)
++ tag_error(L, narg, t);
++}
++
++
++LUALIB_API void luaL_checkany (lua_State *L, int narg) {
++ if (lua_type(L, narg) == LUA_TNONE)
++ luaL_argerror(L, narg, "value expected");
++}
++
++
++LUALIB_API const char *luaL_checklstring (lua_State *L, int narg, size_t *len) {
++ const char *s = lua_tolstring(L, narg, len);
++ if (!s) tag_error(L, narg, LUA_TSTRING);
++ return s;
++}
++
++
++LUALIB_API const char *luaL_optlstring (lua_State *L, int narg,
++ const char *def, size_t *len) {
++ if (lua_isnoneornil(L, narg)) {
++ if (len)
++ *len = (def ? strlen(def) : 0);
++ return def;
++ }
++ else return luaL_checklstring(L, narg, len);
++}
++
++
++LUALIB_API lua_Number luaL_checknumber (lua_State *L, int narg) {
++ lua_Number d = lua_tonumber(L, narg);
++ if (d == 0 && !lua_isnumber(L, narg)) /* avoid extra test when d is not 0 */
++ tag_error(L, narg, LUA_TNUMBER);
++ return d;
++}
++
++
++LUALIB_API lua_Number luaL_optnumber (lua_State *L, int narg, lua_Number def) {
++ return luaL_opt(L, luaL_checknumber, narg, def);
++}
++
++
++LUALIB_API lua_Integer luaL_checkinteger (lua_State *L, int narg) {
++ lua_Integer d = lua_tointeger(L, narg);
++ if (d == 0 && !lua_isnumber(L, narg)) /* avoid extra test when d is not 0 */
++ tag_error(L, narg, LUA_TNUMBER);
++ return d;
++}
++
++
++LUALIB_API lua_Integer luaL_optinteger (lua_State *L, int narg,
++ lua_Integer def) {
++ return luaL_opt(L, luaL_checkinteger, narg, def);
++}
++
++
++LUALIB_API int luaL_getmetafield (lua_State *L, int obj, const char *event) {
++ if (!lua_getmetatable(L, obj)) /* no metatable? */
++ return 0;
++ lua_pushstring(L, event);
++ lua_rawget(L, -2);
++ if (lua_isnil(L, -1)) {
++ lua_pop(L, 2); /* remove metatable and metafield */
++ return 0;
++ }
++ else {
++ lua_remove(L, -2); /* remove only metatable */
++ return 1;
++ }
++}
++
++
++LUALIB_API int luaL_callmeta (lua_State *L, int obj, const char *event) {
++ obj = abs_index(L, obj);
++ if (!luaL_getmetafield(L, obj, event)) /* no metafield? */
++ return 0;
++ lua_pushvalue(L, obj);
++ lua_call(L, 1, 1);
++ return 1;
++}
++
++
++LUALIB_API void (luaL_register) (lua_State *L, const char *libname,
++ const luaL_Reg *l) {
++ luaI_openlib(L, libname, l, 0);
++}
++
++
++static int libsize (const luaL_Reg *l) {
++ int size = 0;
++ for (; l->name; l++) size++;
++ return size;
++}
++
++
++LUALIB_API void luaI_openlib (lua_State *L, const char *libname,
++ const luaL_Reg *l, int nup) {
++ if (libname) {
++ int size = libsize(l);
++ /* check whether lib already exists */
++ luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 1);
++ lua_getfield(L, -1, libname); /* get _LOADED[libname] */
++ if (!lua_istable(L, -1)) { /* not found? */
++ lua_pop(L, 1); /* remove previous result */
++ /* try global variable (and create one if it does not exist) */
++ if (luaL_findtable(L, LUA_GLOBALSINDEX, libname, size) != NULL)
++ luaL_error(L, "name conflict for module " LUA_QS, libname);
++ lua_pushvalue(L, -1);
++ lua_setfield(L, -3, libname); /* _LOADED[libname] = new table */
++ }
++ lua_remove(L, -2); /* remove _LOADED table */
++ lua_insert(L, -(nup+1)); /* move library table to below upvalues */
++ }
++ for (; l->name; l++) {
++ int i;
++ for (i=0; i<nup; i++) /* copy upvalues to the top */
++ lua_pushvalue(L, -nup);
++ lua_pushcclosure(L, l->func, nup);
++ lua_setfield(L, -(nup+2), l->name);
++ }
++ lua_pop(L, nup); /* remove upvalues */
++}
++
++
++
++/*
++** {======================================================
++** getn-setn: size for arrays
++** =======================================================
++*/
++
++#if defined(LUA_COMPAT_GETN)
++
++static int checkint (lua_State *L, int topop) {
++ int n = (lua_type(L, -1) == LUA_TNUMBER) ? lua_tointeger(L, -1) : -1;
++ lua_pop(L, topop);
++ return n;
++}
++
++
++static void getsizes (lua_State *L) {
++ lua_getfield(L, LUA_REGISTRYINDEX, "LUA_SIZES");
++ if (lua_isnil(L, -1)) { /* no `size' table? */
++ lua_pop(L, 1); /* remove nil */
++ lua_newtable(L); /* create it */
++ lua_pushvalue(L, -1); /* `size' will be its own metatable */
++ lua_setmetatable(L, -2);
++ lua_pushliteral(L, "kv");
++ lua_setfield(L, -2, "__mode"); /* metatable(N).__mode = "kv" */
++ lua_pushvalue(L, -1);
++ lua_setfield(L, LUA_REGISTRYINDEX, "LUA_SIZES"); /* store in register */
++ }
++}
++
++
++LUALIB_API void luaL_setn (lua_State *L, int t, int n) {
++ t = abs_index(L, t);
++ lua_pushliteral(L, "n");
++ lua_rawget(L, t);
++ if (checkint(L, 1) >= 0) { /* is there a numeric field `n'? */
++ lua_pushliteral(L, "n"); /* use it */
++ lua_pushinteger(L, n);
++ lua_rawset(L, t);
++ }
++ else { /* use `sizes' */
++ getsizes(L);
++ lua_pushvalue(L, t);
++ lua_pushinteger(L, n);
++ lua_rawset(L, -3); /* sizes[t] = n */
++ lua_pop(L, 1); /* remove `sizes' */
++ }
++}
++
++
++LUALIB_API int luaL_getn (lua_State *L, int t) {
++ int n;
++ t = abs_index(L, t);
++ lua_pushliteral(L, "n"); /* try t.n */
++ lua_rawget(L, t);
++ if ((n = checkint(L, 1)) >= 0) return n;
++ getsizes(L); /* else try sizes[t] */
++ lua_pushvalue(L, t);
++ lua_rawget(L, -2);
++ if ((n = checkint(L, 2)) >= 0) return n;
++ return (int)lua_objlen(L, t);
++}
++
++#endif
++
++/* }====================================================== */
++
++
++
++LUALIB_API const char *luaL_gsub (lua_State *L, const char *s, const char *p,
++ const char *r) {
++ const char *wild;
++ size_t l = strlen(p);
++ luaL_Buffer *b = (luaL_Buffer *)kmalloc(sizeof(luaL_Buffer) + BUFSIZ, GFP_ATOMIC);
++ if(!b) luaL_error(L, "luaL_gsub: cannot allocate memory");
++ luaL_buffinit(L, b);
++ while ((wild = strstr(s, p)) != NULL) {
++ luaL_addlstring(b, s, wild - s); /* push prefix */
++ luaL_addstring(b, r); /* push replacement in place of pattern */
++ s = wild + l; /* continue after `p' */
++ }
++ luaL_addstring(b, s); /* push last suffix */
++ luaL_pushresult(b);
++ kfree(b);
++ return lua_tostring(L, -1);
++}
++
++
++LUALIB_API const char *luaL_findtable (lua_State *L, int idx,
++ const char *fname, int szhint) {
++ const char *e;
++ lua_pushvalue(L, idx);
++ do {
++ e = strchr(fname, '.');
++ if (e == NULL) e = fname + strlen(fname);
++ lua_pushlstring(L, fname, e - fname);
++ lua_rawget(L, -2);
++ if (lua_isnil(L, -1)) { /* no such field? */
++ lua_pop(L, 1); /* remove this nil */
++ lua_createtable(L, 0, (*e == '.' ? 1 : szhint)); /* new table for field */
++ lua_pushlstring(L, fname, e - fname);
++ lua_pushvalue(L, -2);
++ lua_settable(L, -4); /* set new table into field */
++ }
++ else if (!lua_istable(L, -1)) { /* field has a non-table value? */
++ lua_pop(L, 2); /* remove table and value */
++ return fname; /* return problematic part of the name */
++ }
++ lua_remove(L, -2); /* remove previous table */
++ fname = e + 1;
++ } while (*e == '.');
++ return NULL;
++}
++
++
++
++/*
++** {======================================================
++** Generic Buffer manipulation
++** =======================================================
++*/
++
++
++#define bufflen(B) ((B)->p - (B)->buffer)
++#define bufffree(B) ((size_t)(LUAL_BUFFERSIZE - bufflen(B)))
++
++#define LIMIT (LUA_MINSTACK/2)
++
++
++static int emptybuffer (luaL_Buffer *B) {
++ size_t l = bufflen(B);
++ if (l == 0) return 0; /* put nothing on stack */
++ else {
++ lua_pushlstring(B->L, B->buffer, l);
++ B->p = B->buffer;
++ B->lvl++;
++ return 1;
++ }
++}
++
++
++static void adjuststack (luaL_Buffer *B) {
++ if (B->lvl > 1) {
++ lua_State *L = B->L;
++ int toget = 1; /* number of levels to concat */
++ size_t toplen = lua_strlen(L, -1);
++ do {
++ size_t l = lua_strlen(L, -(toget+1));
++ if (B->lvl - toget + 1 >= LIMIT || toplen > l) {
++ toplen += l;
++ toget++;
++ }
++ else break;
++ } while (toget < B->lvl);
++ lua_concat(L, toget);
++ B->lvl = B->lvl - toget + 1;
++ }
++}
++
++
++LUALIB_API char *luaL_prepbuffer (luaL_Buffer *B) {
++ if (emptybuffer(B))
++ adjuststack(B);
++ return B->buffer;
++}
++
++
++LUALIB_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) {
++ while (l--)
++ luaL_addchar(B, *s++);
++}
++
++
++LUALIB_API void luaL_addstring (luaL_Buffer *B, const char *s) {
++ luaL_addlstring(B, s, strlen(s));
++}
++
++
++LUALIB_API void luaL_pushresult (luaL_Buffer *B) {
++ emptybuffer(B);
++ lua_concat(B->L, B->lvl);
++ B->lvl = 1;
++}
++
++
++LUALIB_API void luaL_addvalue (luaL_Buffer *B) {
++ lua_State *L = B->L;
++ size_t vl;
++ const char *s = lua_tolstring(L, -1, &vl);
++ if (vl <= bufffree(B)) { /* fit into buffer? */
++ memcpy(B->p, s, vl); /* put it there */
++ B->p += vl;
++ lua_pop(L, 1); /* remove from stack */
++ }
++ else {
++ if (emptybuffer(B))
++ lua_insert(L, -2); /* put buffer before new value */
++ B->lvl++; /* add new value into B stack */
++ adjuststack(B);
++ }
++}
++
++
++LUALIB_API void luaL_buffinit (lua_State *L, luaL_Buffer *B) {
++ B->L = L;
++ B->p = B->buffer;
++ B->lvl = 0;
++}
++
++/* }====================================================== */
++
++
++LUALIB_API int luaL_ref (lua_State *L, int t) {
++ int ref;
++ t = abs_index(L, t);
++ if (lua_isnil(L, -1)) {
++ lua_pop(L, 1); /* remove from stack */
++ return LUA_REFNIL; /* `nil' has a unique fixed reference */
++ }
++ lua_rawgeti(L, t, FREELIST_REF); /* get first free element */
++ ref = (int)lua_tointeger(L, -1); /* ref = t[FREELIST_REF] */
++ lua_pop(L, 1); /* remove it from stack */
++ if (ref != 0) { /* any free element? */
++ lua_rawgeti(L, t, ref); /* remove it from list */
++ lua_rawseti(L, t, FREELIST_REF); /* (t[FREELIST_REF] = t[ref]) */
++ }
++ else { /* no free elements */
++ ref = (int)lua_objlen(L, t);
++ ref++; /* create new reference */
++ }
++ lua_rawseti(L, t, ref);
++ return ref;
++}
++
++
++LUALIB_API void luaL_unref (lua_State *L, int t, int ref) {
++ if (ref >= 0) {
++ t = abs_index(L, t);
++ lua_rawgeti(L, t, FREELIST_REF);
++ lua_rawseti(L, t, ref); /* t[ref] = t[FREELIST_REF] */
++ lua_pushinteger(L, ref);
++ lua_rawseti(L, t, FREELIST_REF); /* t[FREELIST_REF] = ref */
++ }
++}
++
++
++
++/*
++** {======================================================
++** Load functions
++** =======================================================
++*/
++
++#if !defined(__KERNEL__)
++typedef struct LoadF {
++ int extraline;
++ FILE *f;
++ char buff[LUAL_BUFFERSIZE];
++} LoadF;
++
++
++static const char *getF (lua_State *L, void *ud, size_t *size) {
++ LoadF *lf = (LoadF *)ud;
++ (void)L;
++ if (lf->extraline) {
++ lf->extraline = 0;
++ *size = 1;
++ return "\n";
++ }
++ if (feof(lf->f)) return NULL;
++ *size = fread(lf->buff, 1, sizeof(lf->buff), lf->f);
++ return (*size > 0) ? lf->buff : NULL;
++}
++
++
++static int errfile (lua_State *L, const char *what, int fnameindex) {
++ const char *serr = strerror(errno);
++ const char *filename = lua_tostring(L, fnameindex) + 1;
++ lua_pushfstring(L, "cannot %s %s: %s", what, filename, serr);
++ lua_remove(L, fnameindex);
++ return LUA_ERRFILE;
++}
++
++
++LUALIB_API int luaL_loadfile (lua_State *L, const char *filename) {
++ LoadF lf;
++ int status, readstatus;
++ int c;
++ int fnameindex = lua_gettop(L) + 1; /* index of filename on the stack */
++ lf.extraline = 0;
++ if (filename == NULL) {
++ lua_pushliteral(L, "=stdin");
++ lf.f = stdin;
++ }
++ else {
++ lua_pushfstring(L, "@%s", filename);
++ lf.f = fopen(filename, "r");
++ if (lf.f == NULL) return errfile(L, "open", fnameindex);
++ }
++ c = getc(lf.f);
++ if (c == '#') { /* Unix exec. file? */
++ lf.extraline = 1;
++ while ((c = getc(lf.f)) != EOF && c != '\n') ; /* skip first line */
++ if (c == '\n') c = getc(lf.f);
++ }
++ if (c == LUA_SIGNATURE[0] && filename) { /* binary file? */
++ lf.f = freopen(filename, "rb", lf.f); /* reopen in binary mode */
++ if (lf.f == NULL) return errfile(L, "reopen", fnameindex);
++ /* skip eventual `#!...' */
++ while ((c = getc(lf.f)) != EOF && c != LUA_SIGNATURE[0]) ;
++ lf.extraline = 0;
++ }
++ ungetc(c, lf.f);
++ status = lua_load(L, getF, &lf, lua_tostring(L, -1));
++ readstatus = ferror(lf.f);
++ if (filename) fclose(lf.f); /* close file (even in case of errors) */
++ if (readstatus) {
++ lua_settop(L, fnameindex); /* ignore results from `lua_load' */
++ return errfile(L, "read", fnameindex);
++ }
++ lua_remove(L, fnameindex);
++ return status;
++}
++#endif
++
++typedef struct LoadS {
++ const char *s;
++ size_t size;
++} LoadS;
++
++
++static const char *getS (lua_State *L, void *ud, size_t *size) {
++ LoadS *ls = (LoadS *)ud;
++ (void)L;
++ if (ls->size == 0) return NULL;
++ *size = ls->size;
++ ls->size = 0;
++ return ls->s;
++}
++
++
++LUALIB_API int luaL_loadbuffer (lua_State *L, const char *buff, size_t size,
++ const char *name) {
++ LoadS ls;
++ ls.s = buff;
++ ls.size = size;
++ return lua_load(L, getS, &ls, name);
++}
++
++
++LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s) {
++ return luaL_loadbuffer(L, s, strlen(s), s);
++}
++
++
++
++/* }====================================================== */
++
++
++static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) {
++ (void)ud;
++ (void)osize;
++ if (nsize == 0) {
++#if !defined(__KERNEL__)
++ free(ptr);
++#else
++ kfree(ptr);
++#endif
++ return NULL;
++ }
++ else
++#if !defined(__KERNEL__)
++ return realloc(ptr, nsize);
++#else
++ return krealloc(ptr, nsize, GFP_ATOMIC);
++#endif
++}
++
++
++static int lpanic (lua_State *L) {
++ (void)L; /* to avoid warnings */
++#if !defined(__KERNEL__)
++ fprintf(stderr, "PANIC: unprotected error in call to Lua API (%s)\n",
++#else
++ printk( "PANIC: unprotected error in call to Lua API (%s)\n",
++#endif
++ lua_tostring(L, -1));
++ return 0;
++}
++
++
++LUALIB_API lua_State *luaL_newstate (void) {
++ lua_State *L = lua_newstate(l_alloc, NULL);
++ if (L) lua_atpanic(L, &lpanic);
++ return L;
++}
++
+--- /dev/null
++++ b/extensions/LUA/lua/lauxlib.h
+@@ -0,0 +1,184 @@
++/*
++** $Id: lauxlib.h,v 1.88.1.1 2007/12/27 13:02:25 roberto Exp $
++** Auxiliary functions for building Lua libraries
++** See Copyright Notice in lua.h
++*/
++
++
++#ifndef lauxlib_h
++#define lauxlib_h
++
++
++#include <stddef.h>
++#include <linux/slab.h> /* for kmalloc and kfree when allocating luaL_Buffer */
++
++#if !defined(__KERNEL__)
++#include <stdio.h>
++#endif
++
++#include "lua.h"
++
++
++#if defined(LUA_COMPAT_GETN)
++LUALIB_API int (luaL_getn) (lua_State *L, int t);
++LUALIB_API void (luaL_setn) (lua_State *L, int t, int n);
++#else
++#define luaL_getn(L,i) ((int)lua_objlen(L, i))
++#define luaL_setn(L,i,j) ((void)0) /* no op! */
++#endif
++
++#if defined(LUA_COMPAT_OPENLIB)
++#define luaI_openlib luaL_openlib
++#endif
++
++
++/* extra error code for `luaL_load' */
++#define LUA_ERRFILE (LUA_ERRERR+1)
++
++
++typedef struct luaL_Reg {
++ const char *name;
++ lua_CFunction func;
++} luaL_Reg;
++
++
++
++LUALIB_API void (luaI_openlib) (lua_State *L, const char *libname,
++ const luaL_Reg *l, int nup);
++LUALIB_API void (luaL_register) (lua_State *L, const char *libname,
++ const luaL_Reg *l);
++LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e);
++LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e);
++LUALIB_API int (luaL_typerror) (lua_State *L, int narg, const char *tname);
++LUALIB_API int (luaL_argerror) (lua_State *L, int numarg, const char *extramsg);
++LUALIB_API const char *(luaL_checklstring) (lua_State *L, int numArg,
++ size_t *l);
++LUALIB_API const char *(luaL_optlstring) (lua_State *L, int numArg,
++ const char *def, size_t *l);
++LUALIB_API lua_Number (luaL_checknumber) (lua_State *L, int numArg);
++LUALIB_API lua_Number (luaL_optnumber) (lua_State *L, int nArg, lua_Number def);
++
++LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int numArg);
++LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int nArg,
++ lua_Integer def);
++
++LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg);
++LUALIB_API void (luaL_checktype) (lua_State *L, int narg, int t);
++LUALIB_API void (luaL_checkany) (lua_State *L, int narg);
++
++LUALIB_API int (luaL_newmetatable) (lua_State *L, const char *tname);
++LUALIB_API void *(luaL_checkudata) (lua_State *L, int ud, const char *tname);
++
++LUALIB_API void (luaL_where) (lua_State *L, int lvl);
++LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...);
++
++LUALIB_API int (luaL_checkoption) (lua_State *L, int narg, const char *def,
++ const char *const lst[]);
++
++LUALIB_API int (luaL_ref) (lua_State *L, int t);
++LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref);
++
++#if !defined(__KERNEL__)
++LUALIB_API int (luaL_loadfile) (lua_State *L, const char *filename);
++#endif
++
++LUALIB_API int (luaL_loadbuffer) (lua_State *L, const char *buff, size_t sz,
++ const char *name);
++LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s);
++
++LUALIB_API lua_State *(luaL_newstate) (void);
++
++
++LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s, const char *p,
++ const char *r);
++
++LUALIB_API const char *(luaL_findtable) (lua_State *L, int idx,
++ const char *fname, int szhint);
++
++
++
++
++/*
++** ===============================================================
++** some useful macros
++** ===============================================================
++*/
++
++#define luaL_argcheck(L, cond,numarg,extramsg) \
++ ((void)((cond) || luaL_argerror(L, (numarg), (extramsg))))
++#define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL))
++#define luaL_optstring(L,n,d) (luaL_optlstring(L, (n), (d), NULL))
++#define luaL_checkint(L,n) ((int)luaL_checkinteger(L, (n)))
++#define luaL_optint(L,n,d) ((int)luaL_optinteger(L, (n), (d)))
++#define luaL_checklong(L,n) ((long)luaL_checkinteger(L, (n)))
++#define luaL_optlong(L,n,d) ((long)luaL_optinteger(L, (n), (d)))
++
++#define luaL_typename(L,i) lua_typename(L, lua_type(L,(i)))
++
++#if !defined(__KERNEL__)
++#define luaL_dofile(L, fn) \
++ (luaL_loadfile(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0))
++#endif
++
++#define luaL_dostring(L, s) \
++ (luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0))
++
++#define luaL_getmetatable(L,n) (lua_getfield(L, LUA_REGISTRYINDEX, (n)))
++
++#define luaL_opt(L,f,n,d) (lua_isnoneornil(L,(n)) ? (d) : f(L,(n)))
++
++/*
++** {======================================================
++** Generic Buffer manipulation
++** =======================================================
++*/
++
++
++
++typedef struct luaL_Buffer {
++ char *p; /* current position in buffer */
++ int lvl; /* number of strings in the stack (level) */
++ lua_State *L;
++ char buffer[LUAL_BUFFERSIZE];
++} luaL_Buffer;
++
++#define luaL_addchar(B,c) \
++ ((void)((B)->p < ((B)->buffer+LUAL_BUFFERSIZE) || luaL_prepbuffer(B)), \
++ (*(B)->p++ = (char)(c)))
++
++/* compatibility only */
++#define luaL_putchar(B,c) luaL_addchar(B,c)
++
++#define luaL_addsize(B,n) ((B)->p += (n))
++
++
++LUALIB_API void (luaL_buffinit) (lua_State *L, luaL_Buffer *B);
++LUALIB_API char *(luaL_prepbuffer) (luaL_Buffer *B);
++LUALIB_API void (luaL_addlstring) (luaL_Buffer *B, const char *s, size_t l);
++LUALIB_API void (luaL_addstring) (luaL_Buffer *B, const char *s);
++LUALIB_API void (luaL_addvalue) (luaL_Buffer *B);
++LUALIB_API void (luaL_pushresult) (luaL_Buffer *B);
++
++
++/* }====================================================== */
++
++
++/* compatibility with ref system */
++
++/* pre-defined references */
++#define LUA_NOREF (-2)
++#define LUA_REFNIL (-1)
++
++#define lua_ref(L,lock) ((lock) ? luaL_ref(L, LUA_REGISTRYINDEX) : \
++ (lua_pushstring(L, "unlocked references are obsolete"), lua_error(L), 0))
++
++#define lua_unref(L,ref) luaL_unref(L, LUA_REGISTRYINDEX, (ref))
++
++#define lua_getref(L,ref) lua_rawgeti(L, LUA_REGISTRYINDEX, (ref))
++
++
++#define luaL_reg luaL_Reg
++
++#endif
++
++
+--- /dev/null
++++ b/extensions/LUA/lua/lbaselib.c
+@@ -0,0 +1,647 @@
++/*
++** $Id: lbaselib.c,v 1.191.1.6 2008/02/14 16:46:22 roberto Exp $
++** Basic library
++** See Copyright Notice in lua.h
++*/
++
++
++#include <linux/kernel.h>
++#include <linux/ctype.h>
++#include <linux/string.h>
++
++#define lbaselib_c
++#define LUA_LIB
++
++#include "lua.h"
++
++#include "lauxlib.h"
++#include "lualib.h"
++
++
++
++
++/*
++** If your system does not support `stdout', you can just remove this function.
++** If you need, you can define your own `print' function, following this
++** model but changing `fputs' to put the strings at a proper place
++** (a console window or a log file, for instance).
++*/
++static int luaB_print (lua_State *L) {
++ int n = lua_gettop(L); /* number of arguments */
++ int i;
++ lua_getglobal(L, "tostring");
++ for (i=1; i<=n; i++) {
++ const char *s;
++ lua_pushvalue(L, -1); /* function to be called */
++ lua_pushvalue(L, i); /* value to print */
++ lua_call(L, 1, 1);
++ s = lua_tostring(L, -1); /* get result */
++ if (s == NULL)
++ return luaL_error(L, LUA_QL("tostring") " must return a string to "
++ LUA_QL("print"));
++ printk(KERN_INFO "LUA[print]: %s", s);
++ lua_pop(L, 1); /* pop result */
++ }
++ return 0;
++}
++
++
++static int luaB_tonumber (lua_State *L) {
++ int base = luaL_optint(L, 2, 10);
++ if (base == 10) { /* standard conversion */
++ luaL_checkany(L, 1);
++ if (lua_isnumber(L, 1)) {
++ lua_pushnumber(L, lua_tonumber(L, 1));
++ return 1;
++ }
++ }
++ else {
++ const char *s1 = luaL_checkstring(L, 1);
++ char *s2;
++ unsigned long n;
++ luaL_argcheck(L, 2 <= base && base <= 36, 2, "base out of range");
++ n = simple_strtoul(s1, &s2, base);
++ if (s1 != s2) { /* at least one valid digit? */
++ while (isspace((unsigned char)(*s2))) s2++; /* skip trailing spaces */
++ if (*s2 == '\0') { /* no invalid trailing characters? */
++ lua_pushnumber(L, (lua_Number)n);
++ return 1;
++ }
++ }
++ }
++ lua_pushnil(L); /* else not a number */
++ return 1;
++}
++
++
++static int luaB_error (lua_State *L) {
++ int level = luaL_optint(L, 2, 1);
++ lua_settop(L, 1);
++ if (lua_isstring(L, 1) && level > 0) { /* add extra information? */
++ luaL_where(L, level);
++ lua_pushvalue(L, 1);
++ lua_concat(L, 2);
++ }
++ return lua_error(L);
++}
++
++
++static int luaB_getmetatable (lua_State *L) {
++ luaL_checkany(L, 1);
++ if (!lua_getmetatable(L, 1)) {
++ lua_pushnil(L);
++ return 1; /* no metatable */
++ }
++ luaL_getmetafield(L, 1, "__metatable");
++ return 1; /* returns either __metatable field (if present) or metatable */
++}
++
++
++static int luaB_setmetatable (lua_State *L) {
++ int t = lua_type(L, 2);
++ luaL_checktype(L, 1, LUA_TTABLE);
++ luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2,
++ "nil or table expected");
++ if (luaL_getmetafield(L, 1, "__metatable"))
++ luaL_error(L, "cannot change a protected metatable");
++ lua_settop(L, 2);
++ lua_setmetatable(L, 1);
++ return 1;
++}
++
++
++static void getfunc (lua_State *L, int opt) {
++ if (lua_isfunction(L, 1)) lua_pushvalue(L, 1);
++ else {
++ lua_Debug ar;
++ int level = opt ? luaL_optint(L, 1, 1) : luaL_checkint(L, 1);
++ luaL_argcheck(L, level >= 0, 1, "level must be non-negative");
++ if (lua_getstack(L, level, &ar) == 0)
++ luaL_argerror(L, 1, "invalid level");
++ lua_getinfo(L, "f", &ar);
++ if (lua_isnil(L, -1))
++ luaL_error(L, "no function environment for tail call at level %d",
++ level);
++ }
++}
++
++
++static int luaB_getfenv (lua_State *L) {
++ getfunc(L, 1);
++ if (lua_iscfunction(L, -1)) /* is a C function? */
++ lua_pushvalue(L, LUA_GLOBALSINDEX); /* return the thread's global env. */
++ else
++ lua_getfenv(L, -1);
++ return 1;
++}
++
++
++static int luaB_setfenv (lua_State *L) {
++ luaL_checktype(L, 2, LUA_TTABLE);
++ getfunc(L, 0);
++ lua_pushvalue(L, 2);
++ if (lua_isnumber(L, 1) && lua_tonumber(L, 1) == 0) {
++ /* change environment of current thread */
++ lua_pushthread(L);
++ lua_insert(L, -2);
++ lua_setfenv(L, -2);
++ return 0;
++ }
++ else if (lua_iscfunction(L, -2) || lua_setfenv(L, -2) == 0)
++ luaL_error(L,
++ LUA_QL("setfenv") " cannot change environment of given object");
++ return 1;
++}
++
++
++static int luaB_rawequal (lua_State *L) {
++ luaL_checkany(L, 1);
++ luaL_checkany(L, 2);
++ lua_pushboolean(L, lua_rawequal(L, 1, 2));
++ return 1;
++}
++
++
++static int luaB_rawget (lua_State *L) {
++ luaL_checktype(L, 1, LUA_TTABLE);
++ luaL_checkany(L, 2);
++ lua_settop(L, 2);
++ lua_rawget(L, 1);
++ return 1;
++}
++
++static int luaB_rawset (lua_State *L) {
++ luaL_checktype(L, 1, LUA_TTABLE);
++ luaL_checkany(L, 2);
++ luaL_checkany(L, 3);
++ lua_settop(L, 3);
++ lua_rawset(L, 1);
++ return 1;
++}
++
++
++static int luaB_gcinfo (lua_State *L) {
++ lua_pushinteger(L, lua_getgccount(L));
++ return 1;
++}
++
++static int luaB_collectgarbage (lua_State *L) {
++ static const char *const opts[] = {"stop", "restart", "collect",
++ "count", "step", "setpause", "setstepmul", NULL};
++ static const int optsnum[] = {LUA_GCSTOP, LUA_GCRESTART, LUA_GCCOLLECT,
++ LUA_GCCOUNT, LUA_GCSTEP, LUA_GCSETPAUSE, LUA_GCSETSTEPMUL};
++ int o = luaL_checkoption(L, 1, "collect", opts);
++ int ex = luaL_optint(L, 2, 0);
++ int res = lua_gc(L, optsnum[o], ex);
++ switch (optsnum[o]) {
++ case LUA_GCCOUNT: {
++ int b = lua_gc(L, LUA_GCCOUNTB, 0);
++ lua_pushnumber(L, res + ((lua_Number)b/1024));
++ return 1;
++ }
++ case LUA_GCSTEP: {
++ lua_pushboolean(L, res);
++ return 1;
++ }
++ default: {
++ lua_pushnumber(L, res);
++ return 1;
++ }
++ }
++}
++
++
++static int luaB_type (lua_State *L) {
++ luaL_checkany(L, 1);
++ lua_pushstring(L, luaL_typename(L, 1));
++ return 1;
++}
++
++
++static int luaB_next (lua_State *L) {
++ luaL_checktype(L, 1, LUA_TTABLE);
++ lua_settop(L, 2); /* create a 2nd argument if there isn't one */
++ if (lua_next(L, 1))
++ return 2;
++ else {
++ lua_pushnil(L);
++ return 1;
++ }
++}
++
++
++static int luaB_pairs (lua_State *L) {
++ luaL_checktype(L, 1, LUA_TTABLE);
++ lua_pushvalue(L, lua_upvalueindex(1)); /* return generator, */
++ lua_pushvalue(L, 1); /* state, */
++ lua_pushnil(L); /* and initial value */
++ return 3;
++}
++
++
++static int ipairsaux (lua_State *L) {
++ int i = luaL_checkint(L, 2);
++ luaL_checktype(L, 1, LUA_TTABLE);
++ i++; /* next value */
++ lua_pushinteger(L, i);
++ lua_rawgeti(L, 1, i);
++ return (lua_isnil(L, -1)) ? 0 : 2;
++}
++
++
++static int luaB_ipairs (lua_State *L) {
++ luaL_checktype(L, 1, LUA_TTABLE);
++ lua_pushvalue(L, lua_upvalueindex(1)); /* return generator, */
++ lua_pushvalue(L, 1); /* state, */
++ lua_pushinteger(L, 0); /* and initial value */
++ return 3;
++}
++
++
++static int load_aux (lua_State *L, int status) {
++ if (status == 0) /* OK? */
++ return 1;
++ else {
++ lua_pushnil(L);
++ lua_insert(L, -2); /* put before error message */
++ return 2; /* return nil plus error message */
++ }
++}
++
++
++static int luaB_loadstring (lua_State *L) {
++ size_t l;
++ const char *s = luaL_checklstring(L, 1, &l);
++ const char *chunkname = luaL_optstring(L, 2, s);
++ return load_aux(L, luaL_loadbuffer(L, s, l, chunkname));
++}
++
++/*
++static int luaB_loadfile (lua_State *L) {
++ const char *fname = luaL_optstring(L, 1, NULL);
++ return load_aux(L, luaL_loadfile(L, fname));
++}
++*/
++
++/*
++** Reader for generic `load' function: `lua_load' uses the
++** stack for internal stuff, so the reader cannot change the
++** stack top. Instead, it keeps its resulting string in a
++** reserved slot inside the stack.
++*/
++static const char *generic_reader (lua_State *L, void *ud, size_t *size) {
++ (void)ud; /* to avoid warnings */
++ luaL_checkstack(L, 2, "too many nested functions");
++ lua_pushvalue(L, 1); /* get function */
++ lua_call(L, 0, 1); /* call it */
++ if (lua_isnil(L, -1)) {
++ *size = 0;
++ return NULL;
++ }
++ else if (lua_isstring(L, -1)) {
++ lua_replace(L, 3); /* save string in a reserved stack slot */
++ return lua_tolstring(L, 3, size);
++ }
++ else luaL_error(L, "reader function must return a string");
++ return NULL; /* to avoid warnings */
++}
++
++
++static int luaB_load (lua_State *L) {
++ int status;
++ const char *cname = luaL_optstring(L, 2, "=(load)");
++ luaL_checktype(L, 1, LUA_TFUNCTION);
++ lua_settop(L, 3); /* function, eventual name, plus one reserved slot */
++ status = lua_load(L, generic_reader, NULL, cname);
++ return load_aux(L, status);
++}
++
++/*
++static int luaB_dofile (lua_State *L) {
++ const char *fname = luaL_optstring(L, 1, NULL);
++ int n = lua_gettop(L);
++ if (luaL_loadfile(L, fname) != 0) lua_error(L);
++ lua_call(L, 0, LUA_MULTRET);
++ return lua_gettop(L) - n;
++}
++*/
++
++static int luaB_assert (lua_State *L) {
++ luaL_checkany(L, 1);
++ if (!lua_toboolean(L, 1))
++ return luaL_error(L, "%s", luaL_optstring(L, 2, "assertion failed!"));
++ return lua_gettop(L);
++}
++
++
++static int luaB_unpack (lua_State *L) {
++ int i, e, n;
++ luaL_checktype(L, 1, LUA_TTABLE);
++ i = luaL_optint(L, 2, 1);
++ e = luaL_opt(L, luaL_checkint, 3, luaL_getn(L, 1));
++ if (i > e) return 0; /* empty range */
++ n = e - i + 1; /* number of elements */
++ if (n <= 0 || !lua_checkstack(L, n)) /* n <= 0 means arith. overflow */
++ return luaL_error(L, "too many results to unpack");
++ lua_rawgeti(L, 1, i); /* push arg[i] (avoiding overflow problems) */
++ while (i++ < e) /* push arg[i + 1...e] */
++ lua_rawgeti(L, 1, i);
++ return n;
++}
++
++
++static int luaB_select (lua_State *L) {
++ int n = lua_gettop(L);
++ if (lua_type(L, 1) == LUA_TSTRING && *lua_tostring(L, 1) == '#') {
++ lua_pushinteger(L, n-1);
++ return 1;
++ }
++ else {
++ int i = luaL_checkint(L, 1);
++ if (i < 0) i = n + i;
++ else if (i > n) i = n;
++ luaL_argcheck(L, 1 <= i, 1, "index out of range");
++ return n - i;
++ }
++}
++
++
++static int luaB_pcall (lua_State *L) {
++ int status;
++ luaL_checkany(L, 1);
++ status = lua_pcall(L, lua_gettop(L) - 1, LUA_MULTRET, 0);
++ lua_pushboolean(L, (status == 0));
++ lua_insert(L, 1);
++ return lua_gettop(L); /* return status + all results */
++}
++
++
++static int luaB_xpcall (lua_State *L) {
++ int status;
++ luaL_checkany(L, 2);
++ lua_settop(L, 2);
++ lua_insert(L, 1); /* put error function under function to be called */
++ status = lua_pcall(L, 0, LUA_MULTRET, 1);
++ lua_pushboolean(L, (status == 0));
++ lua_replace(L, 1);
++ return lua_gettop(L); /* return status + all results */
++}
++
++
++static int luaB_tostring (lua_State *L) {
++ luaL_checkany(L, 1);
++ if (luaL_callmeta(L, 1, "__tostring")) /* is there a metafield? */
++ return 1; /* use its value */
++ switch (lua_type(L, 1)) {
++ case LUA_TNUMBER:
++ lua_pushstring(L, lua_tostring(L, 1));
++ break;
++ case LUA_TSTRING:
++ lua_pushvalue(L, 1);
++ break;
++ case LUA_TBOOLEAN:
++ lua_pushstring(L, (lua_toboolean(L, 1) ? "true" : "false"));
++ break;
++ case LUA_TNIL:
++ lua_pushliteral(L, "nil");
++ break;
++ default:
++ lua_pushfstring(L, "%s: %p", luaL_typename(L, 1), lua_topointer(L, 1));
++ break;
++ }
++ return 1;
++}
++
++
++static int luaB_newproxy (lua_State *L) {
++ lua_settop(L, 1);
++ lua_newuserdata(L, 0); /* create proxy */
++ if (lua_toboolean(L, 1) == 0)
++ return 1; /* no metatable */
++ else if (lua_isboolean(L, 1)) {
++ lua_newtable(L); /* create a new metatable `m' ... */
++ lua_pushvalue(L, -1); /* ... and mark `m' as a valid metatable */
++ lua_pushboolean(L, 1);
++ lua_rawset(L, lua_upvalueindex(1)); /* weaktable[m] = true */
++ }
++ else {
++ int validproxy = 0; /* to check if weaktable[metatable(u)] == true */
++ if (lua_getmetatable(L, 1)) {
++ lua_rawget(L, lua_upvalueindex(1));
++ validproxy = lua_toboolean(L, -1);
++ lua_pop(L, 1); /* remove value */
++ }
++ luaL_argcheck(L, validproxy, 1, "boolean or proxy expected");
++ lua_getmetatable(L, 1); /* metatable is valid; get it */
++ }
++ lua_setmetatable(L, 2);
++ return 1;
++}
++
++
++static const luaL_Reg base_funcs[] = {
++ {"assert", luaB_assert},
++ {"collectgarbage", luaB_collectgarbage},
++// {"dofile", luaB_dofile},
++ {"error", luaB_error},
++ {"gcinfo", luaB_gcinfo},
++ {"getfenv", luaB_getfenv},
++ {"getmetatable", luaB_getmetatable},
++// {"loadfile", luaB_loadfile},
++ {"load", luaB_load},
++ {"loadstring", luaB_loadstring},
++ {"next", luaB_next},
++ {"pcall", luaB_pcall},
++ {"print", luaB_print},
++ {"rawequal", luaB_rawequal},
++ {"rawget", luaB_rawget},
++ {"rawset", luaB_rawset},
++ {"select", luaB_select},
++ {"setfenv", luaB_setfenv},
++ {"setmetatable", luaB_setmetatable},
++ {"tonumber", luaB_tonumber},
++ {"tostring", luaB_tostring},
++ {"type", luaB_type},
++ {"unpack", luaB_unpack},
++ {"xpcall", luaB_xpcall},
++ {NULL, NULL}
++};
++
++
++/*
++** {======================================================
++** Coroutine library
++** =======================================================
++*/
++
++#define CO_RUN 0 /* running */
++#define CO_SUS 1 /* suspended */
++#define CO_NOR 2 /* 'normal' (it resumed another coroutine) */
++#define CO_DEAD 3
++
++static const char *const statnames[] =
++ {"running", "suspended", "normal", "dead"};
++
++static int costatus (lua_State *L, lua_State *co) {
++ if (L == co) return CO_RUN;
++ switch (lua_status(co)) {
++ case LUA_YIELD:
++ return CO_SUS;
++ case 0: {
++ lua_Debug ar;
++ if (lua_getstack(co, 0, &ar) > 0) /* does it have frames? */
++ return CO_NOR; /* it is running */
++ else if (lua_gettop(co) == 0)
++ return CO_DEAD;
++ else
++ return CO_SUS; /* initial state */
++ }
++ default: /* some error occured */
++ return CO_DEAD;
++ }
++}
++
++
++static int luaB_costatus (lua_State *L) {
++ lua_State *co = lua_tothread(L, 1);
++ luaL_argcheck(L, co, 1, "coroutine expected");
++ lua_pushstring(L, statnames[costatus(L, co)]);
++ return 1;
++}
++
++
++static int auxresume (lua_State *L, lua_State *co, int narg) {
++ int status = costatus(L, co);
++ if (!lua_checkstack(co, narg))
++ luaL_error(L, "too many arguments to resume");
++ if (status != CO_SUS) {
++ lua_pushfstring(L, "cannot resume %s coroutine", statnames[status]);
++ return -1; /* error flag */
++ }
++ lua_xmove(L, co, narg);
++ lua_setlevel(L, co);
++ status = lua_resume(co, narg);
++ if (status == 0 || status == LUA_YIELD) {
++ int nres = lua_gettop(co);
++ if (!lua_checkstack(L, nres + 1))
++ luaL_error(L, "too many results to resume");
++ lua_xmove(co, L, nres); /* move yielded values */
++ return nres;
++ }
++ else {
++ lua_xmove(co, L, 1); /* move error message */
++ return -1; /* error flag */
++ }
++}
++
++
++static int luaB_coresume (lua_State *L) {
++ lua_State *co = lua_tothread(L, 1);
++ int r;
++ luaL_argcheck(L, co, 1, "coroutine expected");
++ r = auxresume(L, co, lua_gettop(L) - 1);
++ if (r < 0) {
++ lua_pushboolean(L, 0);
++ lua_insert(L, -2);
++ return 2; /* return false + error message */
++ }
++ else {
++ lua_pushboolean(L, 1);
++ lua_insert(L, -(r + 1));
++ return r + 1; /* return true + `resume' returns */
++ }
++}
++
++
++static int luaB_auxwrap (lua_State *L) {
++ lua_State *co = lua_tothread(L, lua_upvalueindex(1));
++ int r = auxresume(L, co, lua_gettop(L));
++ if (r < 0) {
++ if (lua_isstring(L, -1)) { /* error object is a string? */
++ luaL_where(L, 1); /* add extra info */
++ lua_insert(L, -2);
++ lua_concat(L, 2);
++ }
++ lua_error(L); /* propagate error */
++ }
++ return r;
++}
++
++
++static int luaB_cocreate (lua_State *L) {
++ lua_State *NL = lua_newthread(L);
++ luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), 1,
++ "Lua function expected");
++ lua_pushvalue(L, 1); /* move function to top */
++ lua_xmove(L, NL, 1); /* move function from L to NL */
++ return 1;
++}
++
++
++static int luaB_cowrap (lua_State *L) {
++ luaB_cocreate(L);
++ lua_pushcclosure(L, luaB_auxwrap, 1);
++ return 1;
++}
++
++
++static int luaB_yield (lua_State *L) {
++ return lua_yield(L, lua_gettop(L));
++}
++
++
++static int luaB_corunning (lua_State *L) {
++ if (lua_pushthread(L))
++ lua_pushnil(L); /* main thread is not a coroutine */
++ return 1;
++}
++
++
++static const luaL_Reg co_funcs[] = {
++ {"create", luaB_cocreate},
++ {"resume", luaB_coresume},
++ {"running", luaB_corunning},
++ {"status", luaB_costatus},
++ {"wrap", luaB_cowrap},
++ {"yield", luaB_yield},
++ {NULL, NULL}
++};
++
++/* }====================================================== */
++
++
++static void auxopen (lua_State *L, const char *name,
++ lua_CFunction f, lua_CFunction u) {
++ lua_pushcfunction(L, u);
++ lua_pushcclosure(L, f, 1);
++ lua_setfield(L, -2, name);
++}
++
++
++static void base_open (lua_State *L) {
++ /* set global _G */
++ lua_pushvalue(L, LUA_GLOBALSINDEX);
++ lua_setglobal(L, "_G");
++ /* open lib into global table */
++ luaL_register(L, "_G", base_funcs);
++ lua_pushliteral(L, LUA_VERSION);
++ lua_setglobal(L, "_VERSION"); /* set global _VERSION */
++ /* `ipairs' and `pairs' need auxliliary functions as upvalues */
++ auxopen(L, "ipairs", luaB_ipairs, ipairsaux);
++ auxopen(L, "pairs", luaB_pairs, luaB_next);
++ /* `newproxy' needs a weaktable as upvalue */
++ lua_createtable(L, 0, 1); /* new table `w' */
++ lua_pushvalue(L, -1); /* `w' will be its own metatable */
++ lua_setmetatable(L, -2);
++ lua_pushliteral(L, "kv");
++ lua_setfield(L, -2, "__mode"); /* metatable(w).__mode = "kv" */
++ lua_pushcclosure(L, luaB_newproxy, 1);
++ lua_setglobal(L, "newproxy"); /* set global `newproxy' */
++}
++
++
++LUALIB_API int luaopen_base (lua_State *L) {
++ base_open(L);
++ luaL_register(L, LUA_COLIBNAME, co_funcs);
++ return 2;
++}
+--- /dev/null
++++ b/extensions/LUA/lua/lcode.c
+@@ -0,0 +1,838 @@
++/*
++** $Id: lcode.c,v 2.25.1.3 2007/12/28 15:32:23 roberto Exp $
++** Code generator for Lua
++** See Copyright Notice in lua.h
++*/
++
++#include <stdlib.h>
++
++#define lcode_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "lcode.h"
++#include "ldebug.h"
++#include "ldo.h"
++#include "lgc.h"
++#include "llex.h"
++#include "lmem.h"
++#include "lobject.h"
++#include "lopcodes.h"
++#include "lparser.h"
++#include "ltable.h"
++
++
++#define hasjumps(e) ((e)->t != (e)->f)
++
++
++static int isnumeral(expdesc *e) {
++ return (e->k == VKNUM && e->t == NO_JUMP && e->f == NO_JUMP);
++}
++
++
++void luaK_nil (FuncState *fs, int from, int n) {
++ Instruction *previous;
++ if (fs->pc > fs->lasttarget) { /* no jumps to current position? */
++ if (fs->pc == 0) { /* function start? */
++ if (from >= fs->nactvar)
++ return; /* positions are already clean */
++ }
++ else {
++ previous = &fs->f->code[fs->pc-1];
++ if (GET_OPCODE(*previous) == OP_LOADNIL) {
++ int pfrom = GETARG_A(*previous);
++ int pto = GETARG_B(*previous);
++ if (pfrom <= from && from <= pto+1) { /* can connect both? */
++ if (from+n-1 > pto)
++ SETARG_B(*previous, from+n-1);
++ return;
++ }
++ }
++ }
++ }
++ luaK_codeABC(fs, OP_LOADNIL, from, from+n-1, 0); /* else no optimization */
++}
++
++
++int luaK_jump (FuncState *fs) {
++ int jpc = fs->jpc; /* save list of jumps to here */
++ int j;
++ fs->jpc = NO_JUMP;
++ j = luaK_codeAsBx(fs, OP_JMP, 0, NO_JUMP);
++ luaK_concat(fs, &j, jpc); /* keep them on hold */
++ return j;
++}
++
++
++void luaK_ret (FuncState *fs, int first, int nret) {
++ luaK_codeABC(fs, OP_RETURN, first, nret+1, 0);
++}
++
++
++static int condjump (FuncState *fs, OpCode op, int A, int B, int C) {
++ luaK_codeABC(fs, op, A, B, C);
++ return luaK_jump(fs);
++}
++
++
++static void fixjump (FuncState *fs, int pc, int dest) {
++ Instruction *jmp = &fs->f->code[pc];
++ int offset = dest-(pc+1);
++ lua_assert(dest != NO_JUMP);
++ if (abs(offset) > MAXARG_sBx)
++ luaX_syntaxerror(fs->ls, "control structure too long");
++ SETARG_sBx(*jmp, offset);
++}
++
++
++/*
++** returns current `pc' and marks it as a jump target (to avoid wrong
++** optimizations with consecutive instructions not in the same basic block).
++*/
++int luaK_getlabel (FuncState *fs) {
++ fs->lasttarget = fs->pc;
++ return fs->pc;
++}
++
++
++static int getjump (FuncState *fs, int pc) {
++ int offset = GETARG_sBx(fs->f->code[pc]);
++ if (offset == NO_JUMP) /* point to itself represents end of list */
++ return NO_JUMP; /* end of list */
++ else
++ return (pc+1)+offset; /* turn offset into absolute position */
++}
++
++
++static Instruction *getjumpcontrol (FuncState *fs, int pc) {
++ Instruction *pi = &fs->f->code[pc];
++ if (pc >= 1 && testTMode(GET_OPCODE(*(pi-1))))
++ return pi-1;
++ else
++ return pi;
++}
++
++
++/*
++** check whether list has any jump that do not produce a value
++** (or produce an inverted value)
++*/
++static int need_value (FuncState *fs, int list) {
++ for (; list != NO_JUMP; list = getjump(fs, list)) {
++ Instruction i = *getjumpcontrol(fs, list);
++ if (GET_OPCODE(i) != OP_TESTSET) return 1;
++ }
++ return 0; /* not found */
++}
++
++
++static int patchtestreg (FuncState *fs, int node, int reg) {
++ Instruction *i = getjumpcontrol(fs, node);
++ if (GET_OPCODE(*i) != OP_TESTSET)
++ return 0; /* cannot patch other instructions */
++ if (reg != NO_REG && reg != GETARG_B(*i))
++ SETARG_A(*i, reg);
++ else /* no register to put value or register already has the value */
++ *i = CREATE_ABC(OP_TEST, GETARG_B(*i), 0, GETARG_C(*i));
++
++ return 1;
++}
++
++
++static void removevalues (FuncState *fs, int list) {
++ for (; list != NO_JUMP; list = getjump(fs, list))
++ patchtestreg(fs, list, NO_REG);
++}
++
++
++static void patchlistaux (FuncState *fs, int list, int vtarget, int reg,
++ int dtarget) {
++ while (list != NO_JUMP) {
++ int next = getjump(fs, list);
++ if (patchtestreg(fs, list, reg))
++ fixjump(fs, list, vtarget);
++ else
++ fixjump(fs, list, dtarget); /* jump to default target */
++ list = next;
++ }
++}
++
++
++static void dischargejpc (FuncState *fs) {
++ patchlistaux(fs, fs->jpc, fs->pc, NO_REG, fs->pc);
++ fs->jpc = NO_JUMP;
++}
++
++
++void luaK_patchlist (FuncState *fs, int list, int target) {
++ if (target == fs->pc)
++ luaK_patchtohere(fs, list);
++ else {
++ lua_assert(target < fs->pc);
++ patchlistaux(fs, list, target, NO_REG, target);
++ }
++}
++
++
++void luaK_patchtohere (FuncState *fs, int list) {
++ luaK_getlabel(fs);
++ luaK_concat(fs, &fs->jpc, list);
++}
++
++
++void luaK_concat (FuncState *fs, int *l1, int l2) {
++ if (l2 == NO_JUMP) return;
++ else if (*l1 == NO_JUMP)
++ *l1 = l2;
++ else {
++ int list = *l1;
++ int next;
++ while ((next = getjump(fs, list)) != NO_JUMP) /* find last element */
++ list = next;
++ fixjump(fs, list, l2);
++ }
++}
++
++
++void luaK_checkstack (FuncState *fs, int n) {
++ int newstack = fs->freereg + n;
++ if (newstack > fs->f->maxstacksize) {
++ if (newstack >= MAXSTACK)
++ luaX_syntaxerror(fs->ls, "function or expression too complex");
++ fs->f->maxstacksize = cast_byte(newstack);
++ }
++}
++
++
++void luaK_reserveregs (FuncState *fs, int n) {
++ luaK_checkstack(fs, n);
++ fs->freereg += n;
++}
++
++
++static void freereg (FuncState *fs, int reg) {
++ if (!ISK(reg) && reg >= fs->nactvar) {
++ fs->freereg--;
++ lua_assert(reg == fs->freereg);
++ }
++}
++
++
++static void freeexp (FuncState *fs, expdesc *e) {
++ if (e->k == VNONRELOC)
++ freereg(fs, e->u.s.info);
++}
++
++
++static int addk (FuncState *fs, TValue *k, TValue *v) {
++ lua_State *L = fs->L;
++ TValue *idx = luaH_set(L, fs->h, k);
++ Proto *f = fs->f;
++ int oldsize = f->sizek;
++ if (ttisnumber(idx)) {
++ lua_assert(luaO_rawequalObj(&fs->f->k[cast_int(nvalue(idx))], v));
++ return cast_int(nvalue(idx));
++ }
++ else { /* constant not found; create a new entry */
++ setnvalue(idx, cast_num(fs->nk));
++ luaM_growvector(L, f->k, fs->nk, f->sizek, TValue,
++ MAXARG_Bx, "constant table overflow");
++ while (oldsize < f->sizek) setnilvalue(&f->k[oldsize++]);
++ setobj(L, &f->k[fs->nk], v);
++ luaC_barrier(L, f, v);
++ return fs->nk++;
++ }
++}
++
++
++int luaK_stringK (FuncState *fs, TString *s) {
++ TValue o;
++ setsvalue(fs->L, &o, s);
++ return addk(fs, &o, &o);
++}
++
++
++int luaK_numberK (FuncState *fs, lua_Number r) {
++ TValue o;
++ setnvalue(&o, r);
++ return addk(fs, &o, &o);
++}
++
++
++static int boolK (FuncState *fs, int b) {
++ TValue o;
++ setbvalue(&o, b);
++ return addk(fs, &o, &o);
++}
++
++
++static int nilK (FuncState *fs) {
++ TValue k, v;
++ setnilvalue(&v);
++ /* cannot use nil as key; instead use table itself to represent nil */
++ sethvalue(fs->L, &k, fs->h);
++ return addk(fs, &k, &v);
++}
++
++
++void luaK_setreturns (FuncState *fs, expdesc *e, int nresults) {
++ if (e->k == VCALL) { /* expression is an open function call? */
++ SETARG_C(getcode(fs, e), nresults+1);
++ }
++ else if (e->k == VVARARG) {
++ SETARG_B(getcode(fs, e), nresults+1);
++ SETARG_A(getcode(fs, e), fs->freereg);
++ luaK_reserveregs(fs, 1);
++ }
++}
++
++
++void luaK_setoneret (FuncState *fs, expdesc *e) {
++ if (e->k == VCALL) { /* expression is an open function call? */
++ e->k = VNONRELOC;
++ e->u.s.info = GETARG_A(getcode(fs, e));
++ }
++ else if (e->k == VVARARG) {
++ SETARG_B(getcode(fs, e), 2);
++ e->k = VRELOCABLE; /* can relocate its simple result */
++ }
++}
++
++
++void luaK_dischargevars (FuncState *fs, expdesc *e) {
++ switch (e->k) {
++ case VLOCAL: {
++ e->k = VNONRELOC;
++ break;
++ }
++ case VUPVAL: {
++ e->u.s.info = luaK_codeABC(fs, OP_GETUPVAL, 0, e->u.s.info, 0);
++ e->k = VRELOCABLE;
++ break;
++ }
++ case VGLOBAL: {
++ e->u.s.info = luaK_codeABx(fs, OP_GETGLOBAL, 0, e->u.s.info);
++ e->k = VRELOCABLE;
++ break;
++ }
++ case VINDEXED: {
++ freereg(fs, e->u.s.aux);
++ freereg(fs, e->u.s.info);
++ e->u.s.info = luaK_codeABC(fs, OP_GETTABLE, 0, e->u.s.info, e->u.s.aux);
++ e->k = VRELOCABLE;
++ break;
++ }
++ case VVARARG:
++ case VCALL: {
++ luaK_setoneret(fs, e);
++ break;
++ }
++ default: break; /* there is one value available (somewhere) */
++ }
++}
++
++
++static int code_label (FuncState *fs, int A, int b, int jump) {
++ luaK_getlabel(fs); /* those instructions may be jump targets */
++ return luaK_codeABC(fs, OP_LOADBOOL, A, b, jump);
++}
++
++
++static void discharge2reg (FuncState *fs, expdesc *e, int reg) {
++ luaK_dischargevars(fs, e);
++ switch (e->k) {
++ case VNIL: {
++ luaK_nil(fs, reg, 1);
++ break;
++ }
++ case VFALSE: case VTRUE: {
++ luaK_codeABC(fs, OP_LOADBOOL, reg, e->k == VTRUE, 0);
++ break;
++ }
++ case VK: {
++ luaK_codeABx(fs, OP_LOADK, reg, e->u.s.info);
++ break;
++ }
++ case VKNUM: {
++ luaK_codeABx(fs, OP_LOADK, reg, luaK_numberK(fs, e->u.nval));
++ break;
++ }
++ case VRELOCABLE: {
++ Instruction *pc = &getcode(fs, e);
++ SETARG_A(*pc, reg);
++ break;
++ }
++ case VNONRELOC: {
++ if (reg != e->u.s.info)
++ luaK_codeABC(fs, OP_MOVE, reg, e->u.s.info, 0);
++ break;
++ }
++ default: {
++ lua_assert(e->k == VVOID || e->k == VJMP);
++ return; /* nothing to do... */
++ }
++ }
++ e->u.s.info = reg;
++ e->k = VNONRELOC;
++}
++
++
++static void discharge2anyreg (FuncState *fs, expdesc *e) {
++ if (e->k != VNONRELOC) {
++ luaK_reserveregs(fs, 1);
++ discharge2reg(fs, e, fs->freereg-1);
++ }
++}
++
++
++static void exp2reg (FuncState *fs, expdesc *e, int reg) {
++ discharge2reg(fs, e, reg);
++ if (e->k == VJMP)
++ luaK_concat(fs, &e->t, e->u.s.info); /* put this jump in `t' list */
++ if (hasjumps(e)) {
++ int final; /* position after whole expression */
++ int p_f = NO_JUMP; /* position of an eventual LOAD false */
++ int p_t = NO_JUMP; /* position of an eventual LOAD true */
++ if (need_value(fs, e->t) || need_value(fs, e->f)) {
++ int fj = (e->k == VJMP) ? NO_JUMP : luaK_jump(fs);
++ p_f = code_label(fs, reg, 0, 1);
++ p_t = code_label(fs, reg, 1, 0);
++ luaK_patchtohere(fs, fj);
++ }
++ final = luaK_getlabel(fs);
++ patchlistaux(fs, e->f, final, reg, p_f);
++ patchlistaux(fs, e->t, final, reg, p_t);
++ }
++ e->f = e->t = NO_JUMP;
++ e->u.s.info = reg;
++ e->k = VNONRELOC;
++}
++
++
++void luaK_exp2nextreg (FuncState *fs, expdesc *e) {
++ luaK_dischargevars(fs, e);
++ freeexp(fs, e);
++ luaK_reserveregs(fs, 1);
++ exp2reg(fs, e, fs->freereg - 1);
++}
++
++
++int luaK_exp2anyreg (FuncState *fs, expdesc *e) {
++ luaK_dischargevars(fs, e);
++ if (e->k == VNONRELOC) {
++ if (!hasjumps(e)) return e->u.s.info; /* exp is already in a register */
++ if (e->u.s.info >= fs->nactvar) { /* reg. is not a local? */
++ exp2reg(fs, e, e->u.s.info); /* put value on it */
++ return e->u.s.info;
++ }
++ }
++ luaK_exp2nextreg(fs, e); /* default */
++ return e->u.s.info;
++}
++
++
++void luaK_exp2val (FuncState *fs, expdesc *e) {
++ if (hasjumps(e))
++ luaK_exp2anyreg(fs, e);
++ else
++ luaK_dischargevars(fs, e);
++}
++
++
++int luaK_exp2RK (FuncState *fs, expdesc *e) {
++ luaK_exp2val(fs, e);
++ switch (e->k) {
++ case VKNUM:
++ case VTRUE:
++ case VFALSE:
++ case VNIL: {
++ if (fs->nk <= MAXINDEXRK) { /* constant fit in RK operand? */
++ e->u.s.info = (e->k == VNIL) ? nilK(fs) :
++ (e->k == VKNUM) ? luaK_numberK(fs, e->u.nval) :
++ boolK(fs, (e->k == VTRUE));
++ e->k = VK;
++ return RKASK(e->u.s.info);
++ }
++ else break;
++ }
++ case VK: {
++ if (e->u.s.info <= MAXINDEXRK) /* constant fit in argC? */
++ return RKASK(e->u.s.info);
++ else break;
++ }
++ default: break;
++ }
++ /* not a constant in the right range: put it in a register */
++ return luaK_exp2anyreg(fs, e);
++}
++
++
++void luaK_storevar (FuncState *fs, expdesc *var, expdesc *ex) {
++ switch (var->k) {
++ case VLOCAL: {
++ freeexp(fs, ex);
++ exp2reg(fs, ex, var->u.s.info);
++ return;
++ }
++ case VUPVAL: {
++ int e = luaK_exp2anyreg(fs, ex);
++ luaK_codeABC(fs, OP_SETUPVAL, e, var->u.s.info, 0);
++ break;
++ }
++ case VGLOBAL: {
++ int e = luaK_exp2anyreg(fs, ex);
++ luaK_codeABx(fs, OP_SETGLOBAL, e, var->u.s.info);
++ break;
++ }
++ case VINDEXED: {
++ int e = luaK_exp2RK(fs, ex);
++ luaK_codeABC(fs, OP_SETTABLE, var->u.s.info, var->u.s.aux, e);
++ break;
++ }
++ default: {
++ lua_assert(0); /* invalid var kind to store */
++ break;
++ }
++ }
++ freeexp(fs, ex);
++}
++
++
++void luaK_self (FuncState *fs, expdesc *e, expdesc *key) {
++ int func;
++ luaK_exp2anyreg(fs, e);
++ freeexp(fs, e);
++ func = fs->freereg;
++ luaK_reserveregs(fs, 2);
++ luaK_codeABC(fs, OP_SELF, func, e->u.s.info, luaK_exp2RK(fs, key));
++ freeexp(fs, key);
++ e->u.s.info = func;
++ e->k = VNONRELOC;
++}
++
++
++static void invertjump (FuncState *fs, expdesc *e) {
++ Instruction *pc = getjumpcontrol(fs, e->u.s.info);
++ lua_assert(testTMode(GET_OPCODE(*pc)) && GET_OPCODE(*pc) != OP_TESTSET &&
++ GET_OPCODE(*pc) != OP_TEST);
++ SETARG_A(*pc, !(GETARG_A(*pc)));
++}
++
++
++static int jumponcond (FuncState *fs, expdesc *e, int cond) {
++ if (e->k == VRELOCABLE) {
++ Instruction ie = getcode(fs, e);
++ if (GET_OPCODE(ie) == OP_NOT) {
++ fs->pc--; /* remove previous OP_NOT */
++ return condjump(fs, OP_TEST, GETARG_B(ie), 0, !cond);
++ }
++ /* else go through */
++ }
++ discharge2anyreg(fs, e);
++ freeexp(fs, e);
++ return condjump(fs, OP_TESTSET, NO_REG, e->u.s.info, cond);
++}
++
++
++void luaK_goiftrue (FuncState *fs, expdesc *e) {
++ int pc; /* pc of last jump */
++ luaK_dischargevars(fs, e);
++ switch (e->k) {
++ case VK: case VKNUM: case VTRUE: {
++ pc = NO_JUMP; /* always true; do nothing */
++ break;
++ }
++ case VFALSE: {
++ pc = luaK_jump(fs); /* always jump */
++ break;
++ }
++ case VJMP: {
++ invertjump(fs, e);
++ pc = e->u.s.info;
++ break;
++ }
++ default: {
++ pc = jumponcond(fs, e, 0);
++ break;
++ }
++ }
++ luaK_concat(fs, &e->f, pc); /* insert last jump in `f' list */
++ luaK_patchtohere(fs, e->t);
++ e->t = NO_JUMP;
++}
++
++
++static void luaK_goiffalse (FuncState *fs, expdesc *e) {
++ int pc; /* pc of last jump */
++ luaK_dischargevars(fs, e);
++ switch (e->k) {
++ case VNIL: case VFALSE: {
++ pc = NO_JUMP; /* always false; do nothing */
++ break;
++ }
++ case VTRUE: {
++ pc = luaK_jump(fs); /* always jump */
++ break;
++ }
++ case VJMP: {
++ pc = e->u.s.info;
++ break;
++ }
++ default: {
++ pc = jumponcond(fs, e, 1);
++ break;
++ }
++ }
++ luaK_concat(fs, &e->t, pc); /* insert last jump in `t' list */
++ luaK_patchtohere(fs, e->f);
++ e->f = NO_JUMP;
++}
++
++
++static void codenot (FuncState *fs, expdesc *e) {
++ luaK_dischargevars(fs, e);
++ switch (e->k) {
++ case VNIL: case VFALSE: {
++ e->k = VTRUE;
++ break;
++ }
++ case VK: case VKNUM: case VTRUE: {
++ e->k = VFALSE;
++ break;
++ }
++ case VJMP: {
++ invertjump(fs, e);
++ break;
++ }
++ case VRELOCABLE:
++ case VNONRELOC: {
++ discharge2anyreg(fs, e);
++ freeexp(fs, e);
++ e->u.s.info = luaK_codeABC(fs, OP_NOT, 0, e->u.s.info, 0);
++ e->k = VRELOCABLE;
++ break;
++ }
++ default: {
++ lua_assert(0); /* cannot happen */
++ break;
++ }
++ }
++ /* interchange true and false lists */
++ { int temp = e->f; e->f = e->t; e->t = temp; }
++ removevalues(fs, e->f);
++ removevalues(fs, e->t);
++}
++
++
++void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) {
++ t->u.s.aux = luaK_exp2RK(fs, k);
++ t->k = VINDEXED;
++}
++
++
++static int constfolding (OpCode op, expdesc *e1, expdesc *e2) {
++ lua_Number v1, v2, r;
++ if (!isnumeral(e1) || !isnumeral(e2)) return 0;
++ v1 = e1->u.nval;
++ v2 = e2->u.nval;
++ switch (op) {
++ case OP_ADD: r = luai_numadd(v1, v2); break;
++ case OP_SUB: r = luai_numsub(v1, v2); break;
++ case OP_MUL: r = luai_nummul(v1, v2); break;
++ case OP_DIV:
++ if (v2 == 0) return 0; /* do not attempt to divide by 0 */
++ r = luai_numdiv(v1, v2); break;
++ case OP_MOD:
++ if (v2 == 0) return 0; /* do not attempt to divide by 0 */
++ r = luai_nummod(v1, v2); break;
++ case OP_POW: r = luai_numpow(v1, v2); break;
++ case OP_UNM: r = luai_numunm(v1); break;
++ case OP_LEN: return 0; /* no constant folding for 'len' */
++ default: lua_assert(0); r = 0; break;
++ }
++ if (luai_numisnan(r)) return 0; /* do not attempt to produce NaN */
++ e1->u.nval = r;
++ return 1;
++}
++
++
++static void codearith (FuncState *fs, OpCode op, expdesc *e1, expdesc *e2) {
++ if (constfolding(op, e1, e2))
++ return;
++ else {
++ int o2 = (op != OP_UNM && op != OP_LEN) ? luaK_exp2RK(fs, e2) : 0;
++ int o1 = luaK_exp2RK(fs, e1);
++ if (o1 > o2) {
++ freeexp(fs, e1);
++ freeexp(fs, e2);
++ }
++ else {
++ freeexp(fs, e2);
++ freeexp(fs, e1);
++ }
++ e1->u.s.info = luaK_codeABC(fs, op, 0, o1, o2);
++ e1->k = VRELOCABLE;
++ }
++}
++
++
++static void codecomp (FuncState *fs, OpCode op, int cond, expdesc *e1,
++ expdesc *e2) {
++ int o1 = luaK_exp2RK(fs, e1);
++ int o2 = luaK_exp2RK(fs, e2);
++ freeexp(fs, e2);
++ freeexp(fs, e1);
++ if (cond == 0 && op != OP_EQ) {
++ int temp; /* exchange args to replace by `<' or `<=' */
++ temp = o1; o1 = o2; o2 = temp; /* o1 <==> o2 */
++ cond = 1;
++ }
++ e1->u.s.info = condjump(fs, op, cond, o1, o2);
++ e1->k = VJMP;
++}
++
++
++void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e) {
++ expdesc e2;
++ e2.t = e2.f = NO_JUMP; e2.k = VKNUM; e2.u.nval = 0;
++ switch (op) {
++ case OPR_MINUS: {
++ if (!isnumeral(e))
++ luaK_exp2anyreg(fs, e); /* cannot operate on non-numeric constants */
++ codearith(fs, OP_UNM, e, &e2);
++ break;
++ }
++ case OPR_NOT: codenot(fs, e); break;
++ case OPR_LEN: {
++ luaK_exp2anyreg(fs, e); /* cannot operate on constants */
++ codearith(fs, OP_LEN, e, &e2);
++ break;
++ }
++ default: lua_assert(0);
++ }
++}
++
++
++void luaK_infix (FuncState *fs, BinOpr op, expdesc *v) {
++ switch (op) {
++ case OPR_AND: {
++ luaK_goiftrue(fs, v);
++ break;
++ }
++ case OPR_OR: {
++ luaK_goiffalse(fs, v);
++ break;
++ }
++ case OPR_CONCAT: {
++ luaK_exp2nextreg(fs, v); /* operand must be on the `stack' */
++ break;
++ }
++ case OPR_ADD: case OPR_SUB: case OPR_MUL: case OPR_DIV:
++ case OPR_MOD: case OPR_POW: {
++ if (!isnumeral(v)) luaK_exp2RK(fs, v);
++ break;
++ }
++ default: {
++ luaK_exp2RK(fs, v);
++ break;
++ }
++ }
++}
++
++
++void luaK_posfix (FuncState *fs, BinOpr op, expdesc *e1, expdesc *e2) {
++ switch (op) {
++ case OPR_AND: {
++ lua_assert(e1->t == NO_JUMP); /* list must be closed */
++ luaK_dischargevars(fs, e2);
++ luaK_concat(fs, &e2->f, e1->f);
++ *e1 = *e2;
++ break;
++ }
++ case OPR_OR: {
++ lua_assert(e1->f == NO_JUMP); /* list must be closed */
++ luaK_dischargevars(fs, e2);
++ luaK_concat(fs, &e2->t, e1->t);
++ *e1 = *e2;
++ break;
++ }
++ case OPR_CONCAT: {
++ luaK_exp2val(fs, e2);
++ if (e2->k == VRELOCABLE && GET_OPCODE(getcode(fs, e2)) == OP_CONCAT) {
++ lua_assert(e1->u.s.info == GETARG_B(getcode(fs, e2))-1);
++ freeexp(fs, e1);
++ SETARG_B(getcode(fs, e2), e1->u.s.info);
++ e1->k = VRELOCABLE; e1->u.s.info = e2->u.s.info;
++ }
++ else {
++ luaK_exp2nextreg(fs, e2); /* operand must be on the 'stack' */
++ codearith(fs, OP_CONCAT, e1, e2);
++ }
++ break;
++ }
++ case OPR_ADD: codearith(fs, OP_ADD, e1, e2); break;
++ case OPR_SUB: codearith(fs, OP_SUB, e1, e2); break;
++ case OPR_MUL: codearith(fs, OP_MUL, e1, e2); break;
++ case OPR_DIV: codearith(fs, OP_DIV, e1, e2); break;
++ case OPR_MOD: codearith(fs, OP_MOD, e1, e2); break;
++ case OPR_POW: codearith(fs, OP_POW, e1, e2); break;
++ case OPR_EQ: codecomp(fs, OP_EQ, 1, e1, e2); break;
++ case OPR_NE: codecomp(fs, OP_EQ, 0, e1, e2); break;
++ case OPR_LT: codecomp(fs, OP_LT, 1, e1, e2); break;
++ case OPR_LE: codecomp(fs, OP_LE, 1, e1, e2); break;
++ case OPR_GT: codecomp(fs, OP_LT, 0, e1, e2); break;
++ case OPR_GE: codecomp(fs, OP_LE, 0, e1, e2); break;
++ default: lua_assert(0);
++ }
++}
++
++
++void luaK_fixline (FuncState *fs, int line) {
++ fs->f->lineinfo[fs->pc - 1] = line;
++}
++
++
++static int luaK_code (FuncState *fs, Instruction i, int line) {
++ Proto *f = fs->f;
++ dischargejpc(fs); /* `pc' will change */
++ /* put new instruction in code array */
++ luaM_growvector(fs->L, f->code, fs->pc, f->sizecode, Instruction,
++ MAX_INT, "code size overflow");
++ f->code[fs->pc] = i;
++ /* save corresponding line information */
++ luaM_growvector(fs->L, f->lineinfo, fs->pc, f->sizelineinfo, int,
++ MAX_INT, "code size overflow");
++ f->lineinfo[fs->pc] = line;
++ return fs->pc++;
++}
++
++
++int luaK_codeABC (FuncState *fs, OpCode o, int a, int b, int c) {
++ lua_assert(getOpMode(o) == iABC);
++ lua_assert(getBMode(o) != OpArgN || b == 0);
++ lua_assert(getCMode(o) != OpArgN || c == 0);
++ return luaK_code(fs, CREATE_ABC(o, a, b, c), fs->ls->lastline);
++}
++
++
++int luaK_codeABx (FuncState *fs, OpCode o, int a, unsigned int bc) {
++ lua_assert(getOpMode(o) == iABx || getOpMode(o) == iAsBx);
++ lua_assert(getCMode(o) == OpArgN);
++ return luaK_code(fs, CREATE_ABx(o, a, bc), fs->ls->lastline);
++}
++
++
++void luaK_setlist (FuncState *fs, int base, int nelems, int tostore) {
++ int c = (nelems - 1)/LFIELDS_PER_FLUSH + 1;
++ int b = (tostore == LUA_MULTRET) ? 0 : tostore;
++ lua_assert(tostore != 0);
++ if (c <= MAXARG_C)
++ luaK_codeABC(fs, OP_SETLIST, base, b, c);
++ else {
++ luaK_codeABC(fs, OP_SETLIST, base, b, 0);
++ luaK_code(fs, cast(Instruction, c), fs->ls->lastline);
++ }
++ fs->freereg = base + 1; /* free registers with list values */
++}
++
+--- /dev/null
++++ b/extensions/LUA/lua/lcode.h
+@@ -0,0 +1,76 @@
++/*
++** $Id: lcode.h,v 1.48.1.1 2007/12/27 13:02:25 roberto Exp $
++** Code generator for Lua
++** See Copyright Notice in lua.h
++*/
++
++#ifndef lcode_h
++#define lcode_h
++
++#include "llex.h"
++#include "lobject.h"
++#include "lopcodes.h"
++#include "lparser.h"
++
++
++/*
++** Marks the end of a patch list. It is an invalid value both as an absolute
++** address, and as a list link (would link an element to itself).
++*/
++#define NO_JUMP (-1)
++
++
++/*
++** grep "ORDER OPR" if you change these enums
++*/
++typedef enum BinOpr {
++ OPR_ADD, OPR_SUB, OPR_MUL, OPR_DIV, OPR_MOD, OPR_POW,
++ OPR_CONCAT,
++ OPR_NE, OPR_EQ,
++ OPR_LT, OPR_LE, OPR_GT, OPR_GE,
++ OPR_AND, OPR_OR,
++ OPR_NOBINOPR
++} BinOpr;
++
++
++typedef enum UnOpr { OPR_MINUS, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr;
++
++
++#define getcode(fs,e) ((fs)->f->code[(e)->u.s.info])
++
++#define luaK_codeAsBx(fs,o,A,sBx) luaK_codeABx(fs,o,A,(sBx)+MAXARG_sBx)
++
++#define luaK_setmultret(fs,e) luaK_setreturns(fs, e, LUA_MULTRET)
++
++LUAI_FUNC int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bx);
++LUAI_FUNC int luaK_codeABC (FuncState *fs, OpCode o, int A, int B, int C);
++LUAI_FUNC void luaK_fixline (FuncState *fs, int line);
++LUAI_FUNC void luaK_nil (FuncState *fs, int from, int n);
++LUAI_FUNC void luaK_reserveregs (FuncState *fs, int n);
++LUAI_FUNC void luaK_checkstack (FuncState *fs, int n);
++LUAI_FUNC int luaK_stringK (FuncState *fs, TString *s);
++LUAI_FUNC int luaK_numberK (FuncState *fs, lua_Number r);
++LUAI_FUNC void luaK_dischargevars (FuncState *fs, expdesc *e);
++LUAI_FUNC int luaK_exp2anyreg (FuncState *fs, expdesc *e);
++LUAI_FUNC void luaK_exp2nextreg (FuncState *fs, expdesc *e);
++LUAI_FUNC void luaK_exp2val (FuncState *fs, expdesc *e);
++LUAI_FUNC int luaK_exp2RK (FuncState *fs, expdesc *e);
++LUAI_FUNC void luaK_self (FuncState *fs, expdesc *e, expdesc *key);
++LUAI_FUNC void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k);
++LUAI_FUNC void luaK_goiftrue (FuncState *fs, expdesc *e);
++LUAI_FUNC void luaK_storevar (FuncState *fs, expdesc *var, expdesc *e);
++LUAI_FUNC void luaK_setreturns (FuncState *fs, expdesc *e, int nresults);
++LUAI_FUNC void luaK_setoneret (FuncState *fs, expdesc *e);
++LUAI_FUNC int luaK_jump (FuncState *fs);
++LUAI_FUNC void luaK_ret (FuncState *fs, int first, int nret);
++LUAI_FUNC void luaK_patchlist (FuncState *fs, int list, int target);
++LUAI_FUNC void luaK_patchtohere (FuncState *fs, int list);
++LUAI_FUNC void luaK_concat (FuncState *fs, int *l1, int l2);
++LUAI_FUNC int luaK_getlabel (FuncState *fs);
++LUAI_FUNC void luaK_prefix (FuncState *fs, UnOpr op, expdesc *v);
++LUAI_FUNC void luaK_infix (FuncState *fs, BinOpr op, expdesc *v);
++LUAI_FUNC void luaK_posfix (FuncState *fs, BinOpr op, expdesc *v1, expdesc *v2);
++LUAI_FUNC void luaK_setlist (FuncState *fs, int base, int nelems, int tostore);
++
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/ldebug.c
+@@ -0,0 +1,637 @@
++/*
++** $Id: ldebug.c,v 2.29.1.6 2008/05/08 16:56:26 roberto Exp $
++** Debug Interface
++** See Copyright Notice in lua.h
++*/
++
++
++#include <stdarg.h>
++#include <stddef.h>
++#include <string.h>
++
++#define ldebug_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "lapi.h"
++#include "lcode.h"
++#include "ldebug.h"
++#include "ldo.h"
++#include "lfunc.h"
++#include "lobject.h"
++#include "lopcodes.h"
++#include "lstate.h"
++#include "lstring.h"
++#include "ltable.h"
++#include "ltm.h"
++#include "lvm.h"
++
++
++
++static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name);
++
++
++static int currentpc (lua_State *L, CallInfo *ci) {
++ if (!isLua(ci)) return -1; /* function is not a Lua function? */
++ if (ci == L->ci)
++ ci->savedpc = L->savedpc;
++ return pcRel(ci->savedpc, ci_func(ci)->l.p);
++}
++
++
++static int currentline (lua_State *L, CallInfo *ci) {
++ int pc = currentpc(L, ci);
++ if (pc < 0)
++ return -1; /* only active lua functions have current-line information */
++ else
++ return getline(ci_func(ci)->l.p, pc);
++}
++
++
++/*
++** this function can be called asynchronous (e.g. during a signal)
++*/
++LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count) {
++ if (func == NULL || mask == 0) { /* turn off hooks? */
++ mask = 0;
++ func = NULL;
++ }
++ L->hook = func;
++ L->basehookcount = count;
++ resethookcount(L);
++ L->hookmask = cast_byte(mask);
++ return 1;
++}
++
++
++LUA_API lua_Hook lua_gethook (lua_State *L) {
++ return L->hook;
++}
++
++
++LUA_API int lua_gethookmask (lua_State *L) {
++ return L->hookmask;
++}
++
++
++LUA_API int lua_gethookcount (lua_State *L) {
++ return L->basehookcount;
++}
++
++
++LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar) {
++ int status;
++ CallInfo *ci;
++ lua_lock(L);
++ for (ci = L->ci; level > 0 && ci > L->base_ci; ci--) {
++ level--;
++ if (f_isLua(ci)) /* Lua function? */
++ level -= ci->tailcalls; /* skip lost tail calls */
++ }
++ if (level == 0 && ci > L->base_ci) { /* level found? */
++ status = 1;
++ ar->i_ci = cast_int(ci - L->base_ci);
++ }
++ else if (level < 0) { /* level is of a lost tail call? */
++ status = 1;
++ ar->i_ci = 0;
++ }
++ else status = 0; /* no such level */
++ lua_unlock(L);
++ return status;
++}
++
++
++static Proto *getluaproto (CallInfo *ci) {
++ return (isLua(ci) ? ci_func(ci)->l.p : NULL);
++}
++
++
++static const char *findlocal (lua_State *L, CallInfo *ci, int n) {
++ const char *name;
++ Proto *fp = getluaproto(ci);
++ if (fp && (name = luaF_getlocalname(fp, n, currentpc(L, ci))) != NULL)
++ return name; /* is a local variable in a Lua function */
++ else {
++ StkId limit = (ci == L->ci) ? L->top : (ci+1)->func;
++ if (limit - ci->base >= n && n > 0) /* is 'n' inside 'ci' stack? */
++ return "(*temporary)";
++ else
++ return NULL;
++ }
++}
++
++
++LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) {
++ CallInfo *ci = L->base_ci + ar->i_ci;
++ const char *name = findlocal(L, ci, n);
++ lua_lock(L);
++ if (name)
++ luaA_pushobject(L, ci->base + (n - 1));
++ lua_unlock(L);
++ return name;
++}
++
++
++LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) {
++ CallInfo *ci = L->base_ci + ar->i_ci;
++ const char *name = findlocal(L, ci, n);
++ lua_lock(L);
++ if (name)
++ setobjs2s(L, ci->base + (n - 1), L->top - 1);
++ L->top--; /* pop value */
++ lua_unlock(L);
++ return name;
++}
++
++
++static void funcinfo (lua_Debug *ar, Closure *cl) {
++ if (cl->c.isC) {
++ ar->source = "=[C]";
++ ar->linedefined = -1;
++ ar->lastlinedefined = -1;
++ ar->what = "C";
++ }
++ else {
++ ar->source = getstr(cl->l.p->source);
++ ar->linedefined = cl->l.p->linedefined;
++ ar->lastlinedefined = cl->l.p->lastlinedefined;
++ ar->what = (ar->linedefined == 0) ? "main" : "Lua";
++ }
++ luaO_chunkid(ar->short_src, ar->source, LUA_IDSIZE);
++}
++
++
++static void info_tailcall (lua_Debug *ar) {
++ ar->name = ar->namewhat = "";
++ ar->what = "tail";
++ ar->lastlinedefined = ar->linedefined = ar->currentline = -1;
++ ar->source = "=(tail call)";
++ luaO_chunkid(ar->short_src, ar->source, LUA_IDSIZE);
++ ar->nups = 0;
++}
++
++
++static void collectvalidlines (lua_State *L, Closure *f) {
++ if (f == NULL || f->c.isC) {
++ setnilvalue(L->top);
++ }
++ else {
++ Table *t = luaH_new(L, 0, 0);
++ int *lineinfo = f->l.p->lineinfo;
++ int i;
++ for (i=0; i<f->l.p->sizelineinfo; i++)
++ setbvalue(luaH_setnum(L, t, lineinfo[i]), 1);
++ sethvalue(L, L->top, t);
++ }
++ incr_top(L);
++}
++
++
++static int auxgetinfo (lua_State *L, const char *what, lua_Debug *ar,
++ Closure *f, CallInfo *ci) {
++ int status = 1;
++ if (f == NULL) {
++ info_tailcall(ar);
++ return status;
++ }
++ for (; *what; what++) {
++ switch (*what) {
++ case 'S': {
++ funcinfo(ar, f);
++ break;
++ }
++ case 'l': {
++ ar->currentline = (ci) ? currentline(L, ci) : -1;
++ break;
++ }
++ case 'u': {
++ ar->nups = f->c.nupvalues;
++ break;
++ }
++ case 'n': {
++ ar->namewhat = (ci) ? getfuncname(L, ci, &ar->name) : NULL;
++ if (ar->namewhat == NULL) {
++ ar->namewhat = ""; /* not found */
++ ar->name = NULL;
++ }
++ break;
++ }
++ case 'L':
++ case 'f': /* handled by lua_getinfo */
++ break;
++ default: status = 0; /* invalid option */
++ }
++ }
++ return status;
++}
++
++
++LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) {
++ int status;
++ Closure *f = NULL;
++ CallInfo *ci = NULL;
++ lua_lock(L);
++ if (*what == '>') {
++ StkId func = L->top - 1;
++ luai_apicheck(L, ttisfunction(func));
++ what++; /* skip the '>' */
++ f = clvalue(func);
++ L->top--; /* pop function */
++ }
++ else if (ar->i_ci != 0) { /* no tail call? */
++ ci = L->base_ci + ar->i_ci;
++ lua_assert(ttisfunction(ci->func));
++ f = clvalue(ci->func);
++ }
++ status = auxgetinfo(L, what, ar, f, ci);
++ if (strchr(what, 'f')) {
++ if (f == NULL) setnilvalue(L->top);
++ else setclvalue(L, L->top, f);
++ incr_top(L);
++ }
++ if (strchr(what, 'L'))
++ collectvalidlines(L, f);
++ lua_unlock(L);
++ return status;
++}
++
++
++/*
++** {======================================================
++** Symbolic Execution and code checker
++** =======================================================
++*/
++
++#define check(x) if (!(x)) return 0;
++
++#define checkjump(pt,pc) check(0 <= pc && pc < pt->sizecode)
++
++#define checkreg(pt,reg) check((reg) < (pt)->maxstacksize)
++
++
++
++static int precheck (const Proto *pt) {
++ check(pt->maxstacksize <= MAXSTACK);
++ check(pt->numparams+(pt->is_vararg & VARARG_HASARG) <= pt->maxstacksize);
++ check(!(pt->is_vararg & VARARG_NEEDSARG) ||
++ (pt->is_vararg & VARARG_HASARG));
++ check(pt->sizeupvalues <= pt->nups);
++ check(pt->sizelineinfo == pt->sizecode || pt->sizelineinfo == 0);
++ check(pt->sizecode > 0 && GET_OPCODE(pt->code[pt->sizecode-1]) == OP_RETURN);
++ return 1;
++}
++
++
++#define checkopenop(pt,pc) luaG_checkopenop((pt)->code[(pc)+1])
++
++int luaG_checkopenop (Instruction i) {
++ switch (GET_OPCODE(i)) {
++ case OP_CALL:
++ case OP_TAILCALL:
++ case OP_RETURN:
++ case OP_SETLIST: {
++ check(GETARG_B(i) == 0);
++ return 1;
++ }
++ default: return 0; /* invalid instruction after an open call */
++ }
++}
++
++
++static int checkArgMode (const Proto *pt, int r, enum OpArgMask mode) {
++ switch (mode) {
++ case OpArgN: check(r == 0); break;
++ case OpArgU: break;
++ case OpArgR: checkreg(pt, r); break;
++ case OpArgK:
++ check(ISK(r) ? INDEXK(r) < pt->sizek : r < pt->maxstacksize);
++ break;
++ }
++ return 1;
++}
++
++
++static Instruction symbexec (const Proto *pt, int lastpc, int reg) {
++ int pc;
++ int last; /* stores position of last instruction that changed `reg' */
++ last = pt->sizecode-1; /* points to final return (a `neutral' instruction) */
++ check(precheck(pt));
++ for (pc = 0; pc < lastpc; pc++) {
++ Instruction i = pt->code[pc];
++ OpCode op = GET_OPCODE(i);
++ int a = GETARG_A(i);
++ int b = 0;
++ int c = 0;
++ check(op < NUM_OPCODES);
++ checkreg(pt, a);
++ switch (getOpMode(op)) {
++ case iABC: {
++ b = GETARG_B(i);
++ c = GETARG_C(i);
++ check(checkArgMode(pt, b, getBMode(op)));
++ check(checkArgMode(pt, c, getCMode(op)));
++ break;
++ }
++ case iABx: {
++ b = GETARG_Bx(i);
++ if (getBMode(op) == OpArgK) check(b < pt->sizek);
++ break;
++ }
++ case iAsBx: {
++ b = GETARG_sBx(i);
++ if (getBMode(op) == OpArgR) {
++ int dest = pc+1+b;
++ check(0 <= dest && dest < pt->sizecode);
++ if (dest > 0) {
++ int j;
++ /* check that it does not jump to a setlist count; this
++ is tricky, because the count from a previous setlist may
++ have the same value of an invalid setlist; so, we must
++ go all the way back to the first of them (if any) */
++ for (j = 0; j < dest; j++) {
++ Instruction d = pt->code[dest-1-j];
++ if (!(GET_OPCODE(d) == OP_SETLIST && GETARG_C(d) == 0)) break;
++ }
++ /* if 'j' is even, previous value is not a setlist (even if
++ it looks like one) */
++ check((j&1) == 0);
++ }
++ }
++ break;
++ }
++ }
++ if (testAMode(op)) {
++ if (a == reg) last = pc; /* change register `a' */
++ }
++ if (testTMode(op)) {
++ check(pc+2 < pt->sizecode); /* check skip */
++ check(GET_OPCODE(pt->code[pc+1]) == OP_JMP);
++ }
++ switch (op) {
++ case OP_LOADBOOL: {
++ if (c == 1) { /* does it jump? */
++ check(pc+2 < pt->sizecode); /* check its jump */
++ check(GET_OPCODE(pt->code[pc+1]) != OP_SETLIST ||
++ GETARG_C(pt->code[pc+1]) != 0);
++ }
++ break;
++ }
++ case OP_LOADNIL: {
++ if (a <= reg && reg <= b)
++ last = pc; /* set registers from `a' to `b' */
++ break;
++ }
++ case OP_GETUPVAL:
++ case OP_SETUPVAL: {
++ check(b < pt->nups);
++ break;
++ }
++ case OP_GETGLOBAL:
++ case OP_SETGLOBAL: {
++ check(ttisstring(&pt->k[b]));
++ break;
++ }
++ case OP_SELF: {
++ checkreg(pt, a+1);
++ if (reg == a+1) last = pc;
++ break;
++ }
++ case OP_CONCAT: {
++ check(b < c); /* at least two operands */
++ break;
++ }
++ case OP_TFORLOOP: {
++ check(c >= 1); /* at least one result (control variable) */
++ checkreg(pt, a+2+c); /* space for results */
++ if (reg >= a+2) last = pc; /* affect all regs above its base */
++ break;
++ }
++ case OP_FORLOOP:
++ case OP_FORPREP:
++ checkreg(pt, a+3);
++ /* go through */
++ case OP_JMP: {
++ int dest = pc+1+b;
++ /* not full check and jump is forward and do not skip `lastpc'? */
++ if (reg != NO_REG && pc < dest && dest <= lastpc)
++ pc += b; /* do the jump */
++ break;
++ }
++ case OP_CALL:
++ case OP_TAILCALL: {
++ if (b != 0) {
++ checkreg(pt, a+b-1);
++ }
++ c--; /* c = num. returns */
++ if (c == LUA_MULTRET) {
++ check(checkopenop(pt, pc));
++ }
++ else if (c != 0)
++ checkreg(pt, a+c-1);
++ if (reg >= a) last = pc; /* affect all registers above base */
++ break;
++ }
++ case OP_RETURN: {
++ b--; /* b = num. returns */
++ if (b > 0) checkreg(pt, a+b-1);
++ break;
++ }
++ case OP_SETLIST: {
++ if (b > 0) checkreg(pt, a + b);
++ if (c == 0) {
++ pc++;
++ check(pc < pt->sizecode - 1);
++ }
++ break;
++ }
++ case OP_CLOSURE: {
++ int nup, j;
++ check(b < pt->sizep);
++ nup = pt->p[b]->nups;
++ check(pc + nup < pt->sizecode);
++ for (j = 1; j <= nup; j++) {
++ OpCode op1 = GET_OPCODE(pt->code[pc + j]);
++ check(op1 == OP_GETUPVAL || op1 == OP_MOVE);
++ }
++ if (reg != NO_REG) /* tracing? */
++ pc += nup; /* do not 'execute' these pseudo-instructions */
++ break;
++ }
++ case OP_VARARG: {
++ check((pt->is_vararg & VARARG_ISVARARG) &&
++ !(pt->is_vararg & VARARG_NEEDSARG));
++ b--;
++ if (b == LUA_MULTRET) check(checkopenop(pt, pc));
++ checkreg(pt, a+b-1);
++ break;
++ }
++ default: break;
++ }
++ }
++ return pt->code[last];
++}
++
++#undef check
++#undef checkjump
++#undef checkreg
++
++/* }====================================================== */
++
++
++int luaG_checkcode (const Proto *pt) {
++ return (symbexec(pt, pt->sizecode, NO_REG) != 0);
++}
++
++
++static const char *kname (Proto *p, int c) {
++ if (ISK(c) && ttisstring(&p->k[INDEXK(c)]))
++ return svalue(&p->k[INDEXK(c)]);
++ else
++ return "?";
++}
++
++
++static const char *getobjname (lua_State *L, CallInfo *ci, int stackpos,
++ const char **name) {
++ if (isLua(ci)) { /* a Lua function? */
++ Proto *p = ci_func(ci)->l.p;
++ int pc = currentpc(L, ci);
++ Instruction i;
++ *name = luaF_getlocalname(p, stackpos+1, pc);
++ if (*name) /* is a local? */
++ return "local";
++ i = symbexec(p, pc, stackpos); /* try symbolic execution */
++ lua_assert(pc != -1);
++ switch (GET_OPCODE(i)) {
++ case OP_GETGLOBAL: {
++ int g = GETARG_Bx(i); /* global index */
++ lua_assert(ttisstring(&p->k[g]));
++ *name = svalue(&p->k[g]);
++ return "global";
++ }
++ case OP_MOVE: {
++ int a = GETARG_A(i);
++ int b = GETARG_B(i); /* move from `b' to `a' */
++ if (b < a)
++ return getobjname(L, ci, b, name); /* get name for `b' */
++ break;
++ }
++ case OP_GETTABLE: {
++ int k = GETARG_C(i); /* key index */
++ *name = kname(p, k);
++ return "field";
++ }
++ case OP_GETUPVAL: {
++ int u = GETARG_B(i); /* upvalue index */
++ *name = p->upvalues ? getstr(p->upvalues[u]) : "?";
++ return "upvalue";
++ }
++ case OP_SELF: {
++ int k = GETARG_C(i); /* key index */
++ *name = kname(p, k);
++ return "method";
++ }
++ default: break;
++ }
++ }
++ return NULL; /* no useful name found */
++}
++
++
++static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name) {
++ Instruction i;
++ if ((isLua(ci) && ci->tailcalls > 0) || !isLua(ci - 1))
++ return NULL; /* calling function is not Lua (or is unknown) */
++ ci--; /* calling function */
++ i = ci_func(ci)->l.p->code[currentpc(L, ci)];
++ if (GET_OPCODE(i) == OP_CALL || GET_OPCODE(i) == OP_TAILCALL ||
++ GET_OPCODE(i) == OP_TFORLOOP)
++ return getobjname(L, ci, GETARG_A(i), name);
++ else
++ return NULL; /* no useful name can be found */
++}
++
++
++/* only ANSI way to check whether a pointer points to an array */
++static int isinstack (CallInfo *ci, const TValue *o) {
++ StkId p;
++ for (p = ci->base; p < ci->top; p++)
++ if (o == p) return 1;
++ return 0;
++}
++
++
++void luaG_typeerror (lua_State *L, const TValue *o, const char *op) {
++ const char *name = NULL;
++ const char *t = luaT_typenames[ttype(o)];
++ const char *kind = (isinstack(L->ci, o)) ?
++ getobjname(L, L->ci, cast_int(o - L->base), &name) :
++ NULL;
++ if (kind)
++ luaG_runerror(L, "attempt to %s %s " LUA_QS " (a %s value)",
++ op, kind, name, t);
++ else
++ luaG_runerror(L, "attempt to %s a %s value", op, t);
++}
++
++
++void luaG_concaterror (lua_State *L, StkId p1, StkId p2) {
++ if (ttisstring(p1) || ttisnumber(p1)) p1 = p2;
++ lua_assert(!ttisstring(p1) && !ttisnumber(p1));
++ luaG_typeerror(L, p1, "concatenate");
++}
++
++
++void luaG_aritherror (lua_State *L, const TValue *p1, const TValue *p2) {
++ TValue temp;
++ if (luaV_tonumber(p1, &temp) == NULL)
++ p2 = p1; /* first operand is wrong */
++ luaG_typeerror(L, p2, "perform arithmetic on");
++}
++
++
++int luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2) {
++ const char *t1 = luaT_typenames[ttype(p1)];
++ const char *t2 = luaT_typenames[ttype(p2)];
++ if (t1[2] == t2[2])
++ luaG_runerror(L, "attempt to compare two %s values", t1);
++ else
++ luaG_runerror(L, "attempt to compare %s with %s", t1, t2);
++ return 0;
++}
++
++
++static void addinfo (lua_State *L, const char *msg) {
++ CallInfo *ci = L->ci;
++ if (isLua(ci)) { /* is Lua code? */
++ char buff[LUA_IDSIZE]; /* add file:line information */
++ int line = currentline(L, ci);
++ luaO_chunkid(buff, getstr(getluaproto(ci)->source), LUA_IDSIZE);
++ luaO_pushfstring(L, "%s:%d: %s", buff, line, msg);
++ }
++}
++
++
++void luaG_errormsg (lua_State *L) {
++ if (L->errfunc != 0) { /* is there an error handling function? */
++ StkId errfunc = restorestack(L, L->errfunc);
++ if (!ttisfunction(errfunc)) luaD_throw(L, LUA_ERRERR);
++ setobjs2s(L, L->top, L->top - 1); /* move argument */
++ setobjs2s(L, L->top - 1, errfunc); /* push function */
++ incr_top(L);
++ luaD_call(L, L->top - 2, 1); /* call it */
++ }
++ luaD_throw(L, LUA_ERRRUN);
++}
++
++
++void luaG_runerror (lua_State *L, const char *fmt, ...) {
++ va_list argp;
++ va_start(argp, fmt);
++ addinfo(L, luaO_pushvfstring(L, fmt, argp));
++ va_end(argp);
++ luaG_errormsg(L);
++}
++
+--- /dev/null
++++ b/extensions/LUA/lua/ldebug.h
+@@ -0,0 +1,33 @@
++/*
++** $Id: ldebug.h,v 2.3.1.1 2007/12/27 13:02:25 roberto Exp $
++** Auxiliary functions from Debug Interface module
++** See Copyright Notice in lua.h
++*/
++
++#ifndef ldebug_h
++#define ldebug_h
++
++
++#include "lstate.h"
++
++
++#define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1)
++
++#define getline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : 0)
++
++#define resethookcount(L) (L->hookcount = L->basehookcount)
++
++
++LUAI_FUNC void luaG_typeerror (lua_State *L, const TValue *o,
++ const char *opname);
++LUAI_FUNC void luaG_concaterror (lua_State *L, StkId p1, StkId p2);
++LUAI_FUNC void luaG_aritherror (lua_State *L, const TValue *p1,
++ const TValue *p2);
++LUAI_FUNC int luaG_ordererror (lua_State *L, const TValue *p1,
++ const TValue *p2);
++LUAI_FUNC void luaG_runerror (lua_State *L, const char *fmt, ...);
++LUAI_FUNC void luaG_errormsg (lua_State *L);
++LUAI_FUNC int luaG_checkcode (const Proto *pt);
++LUAI_FUNC int luaG_checkopenop (Instruction i);
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/ldo.c
+@@ -0,0 +1,515 @@
++/*
++** $Id: ldo.c,v 2.38.1.3 2008/01/18 22:31:22 roberto Exp $
++** Stack and Call structure of Lua
++** See Copyright Notice in lua.h
++*/
++
++#include <setjmp.h>
++#include <stdlib.h>
++#include <string.h>
++
++#define ldo_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "ldebug.h"
++#include "ldo.h"
++#include "lfunc.h"
++#include "lgc.h"
++#include "lmem.h"
++#include "lobject.h"
++#include "lopcodes.h"
++#include "lparser.h"
++#include "lstate.h"
++#include "lstring.h"
++#include "ltable.h"
++#include "ltm.h"
++#include "lundump.h"
++#include "lvm.h"
++#include "lzio.h"
++
++
++
++/*
++** {======================================================
++** Error-recovery functions
++** =======================================================
++*/
++
++
++/* chain list of long jump buffers */
++struct lua_longjmp {
++ struct lua_longjmp *previous;
++ luai_jmpbuf b;
++ volatile int status; /* error code */
++};
++
++
++void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop) {
++ switch (errcode) {
++ case LUA_ERRMEM: {
++ setsvalue2s(L, oldtop, luaS_newliteral(L, MEMERRMSG));
++ break;
++ }
++ case LUA_ERRERR: {
++ setsvalue2s(L, oldtop, luaS_newliteral(L, "error in error handling"));
++ break;
++ }
++ case LUA_ERRSYNTAX:
++ case LUA_ERRRUN: {
++ setobjs2s(L, oldtop, L->top - 1); /* error message on current top */
++ break;
++ }
++ }
++ L->top = oldtop + 1;
++}
++
++
++static void restore_stack_limit (lua_State *L) {
++ lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK - 1);
++ if (L->size_ci > LUAI_MAXCALLS) { /* there was an overflow? */
++ int inuse = cast_int(L->ci - L->base_ci);
++ if (inuse + 1 < LUAI_MAXCALLS) /* can `undo' overflow? */
++ luaD_reallocCI(L, LUAI_MAXCALLS);
++ }
++}
++
++
++static void resetstack (lua_State *L, int status) {
++ L->ci = L->base_ci;
++ L->base = L->ci->base;
++ luaF_close(L, L->base); /* close eventual pending closures */
++ luaD_seterrorobj(L, status, L->base);
++ L->nCcalls = L->baseCcalls;
++ L->allowhook = 1;
++ restore_stack_limit(L);
++ L->errfunc = 0;
++ L->errorJmp = NULL;
++}
++
++
++void luaD_throw (lua_State *L, int errcode) {
++ if (L->errorJmp) {
++ L->errorJmp->status = errcode;
++ LUAI_THROW(L, L->errorJmp);
++ }
++ else {
++ L->status = cast_byte(errcode);
++ if (G(L)->panic) {
++ resetstack(L, errcode);
++ lua_unlock(L);
++ G(L)->panic(L);
++ }
++ exit(EXIT_FAILURE);
++ }
++}
++
++
++int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) {
++ struct lua_longjmp lj;
++ lj.status = 0;
++ lj.previous = L->errorJmp; /* chain new error handler */
++ L->errorJmp = &lj;
++ LUAI_TRY(L, &lj,
++ (*f)(L, ud);
++ );
++ L->errorJmp = lj.previous; /* restore old error handler */
++ return lj.status;
++}
++
++/* }====================================================== */
++
++
++static void correctstack (lua_State *L, TValue *oldstack) {
++ CallInfo *ci;
++ GCObject *up;
++ L->top = (L->top - oldstack) + L->stack;
++ for (up = L->openupval; up != NULL; up = up->gch.next)
++ gco2uv(up)->v = (gco2uv(up)->v - oldstack) + L->stack;
++ for (ci = L->base_ci; ci <= L->ci; ci++) {
++ ci->top = (ci->top - oldstack) + L->stack;
++ ci->base = (ci->base - oldstack) + L->stack;
++ ci->func = (ci->func - oldstack) + L->stack;
++ }
++ L->base = (L->base - oldstack) + L->stack;
++}
++
++
++void luaD_reallocstack (lua_State *L, int newsize) {
++ TValue *oldstack = L->stack;
++ int realsize = newsize + 1 + EXTRA_STACK;
++ lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK - 1);
++ luaM_reallocvector(L, L->stack, L->stacksize, realsize, TValue);
++ L->stacksize = realsize;
++ L->stack_last = L->stack+newsize;
++ correctstack(L, oldstack);
++}
++
++
++void luaD_reallocCI (lua_State *L, int newsize) {
++ CallInfo *oldci = L->base_ci;
++ luaM_reallocvector(L, L->base_ci, L->size_ci, newsize, CallInfo);
++ L->size_ci = newsize;
++ L->ci = (L->ci - oldci) + L->base_ci;
++ L->end_ci = L->base_ci + L->size_ci - 1;
++}
++
++
++void luaD_growstack (lua_State *L, int n) {
++ if (n <= L->stacksize) /* double size is enough? */
++ luaD_reallocstack(L, 2*L->stacksize);
++ else
++ luaD_reallocstack(L, L->stacksize + n);
++}
++
++
++static CallInfo *growCI (lua_State *L) {
++ if (L->size_ci > LUAI_MAXCALLS) /* overflow while handling overflow? */
++ luaD_throw(L, LUA_ERRERR);
++ else {
++ luaD_reallocCI(L, 2*L->size_ci);
++ if (L->size_ci > LUAI_MAXCALLS)
++ luaG_runerror(L, "stack overflow");
++ }
++ return ++L->ci;
++}
++
++
++void luaD_callhook (lua_State *L, int event, int line) {
++ lua_Hook hook = L->hook;
++ if (hook && L->allowhook) {
++ ptrdiff_t top = savestack(L, L->top);
++ ptrdiff_t ci_top = savestack(L, L->ci->top);
++ lua_Debug ar;
++ ar.event = event;
++ ar.currentline = line;
++ if (event == LUA_HOOKTAILRET)
++ ar.i_ci = 0; /* tail call; no debug information about it */
++ else
++ ar.i_ci = cast_int(L->ci - L->base_ci);
++ luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */
++ L->ci->top = L->top + LUA_MINSTACK;
++ lua_assert(L->ci->top <= L->stack_last);
++ L->allowhook = 0; /* cannot call hooks inside a hook */
++ lua_unlock(L);
++ (*hook)(L, &ar);
++ lua_lock(L);
++ lua_assert(!L->allowhook);
++ L->allowhook = 1;
++ L->ci->top = restorestack(L, ci_top);
++ L->top = restorestack(L, top);
++ }
++}
++
++
++static StkId adjust_varargs (lua_State *L, Proto *p, int actual) {
++ int i;
++ int nfixargs = p->numparams;
++ Table *htab = NULL;
++ StkId base, fixed;
++ for (; actual < nfixargs; ++actual)
++ setnilvalue(L->top++);
++#if defined(LUA_COMPAT_VARARG)
++ if (p->is_vararg & VARARG_NEEDSARG) { /* compat. with old-style vararg? */
++ int nvar = actual - nfixargs; /* number of extra arguments */
++ lua_assert(p->is_vararg & VARARG_HASARG);
++ luaC_checkGC(L);
++ htab = luaH_new(L, nvar, 1); /* create `arg' table */
++ for (i=0; i<nvar; i++) /* put extra arguments into `arg' table */
++ setobj2n(L, luaH_setnum(L, htab, i+1), L->top - nvar + i);
++ /* store counter in field `n' */
++ setnvalue(luaH_setstr(L, htab, luaS_newliteral(L, "n")), cast_num(nvar));
++ }
++#endif
++ /* move fixed parameters to final position */
++ fixed = L->top - actual; /* first fixed argument */
++ base = L->top; /* final position of first argument */
++ for (i=0; i<nfixargs; i++) {
++ setobjs2s(L, L->top++, fixed+i);
++ setnilvalue(fixed+i);
++ }
++ /* add `arg' parameter */
++ if (htab) {
++ sethvalue(L, L->top++, htab);
++ lua_assert(iswhite(obj2gco(htab)));
++ }
++ return base;
++}
++
++
++static StkId tryfuncTM (lua_State *L, StkId func) {
++ const TValue *tm = luaT_gettmbyobj(L, func, TM_CALL);
++ StkId p;
++ ptrdiff_t funcr = savestack(L, func);
++ if (!ttisfunction(tm))
++ luaG_typeerror(L, func, "call");
++ /* Open a hole inside the stack at `func' */
++ for (p = L->top; p > func; p--) setobjs2s(L, p, p-1);
++ incr_top(L);
++ func = restorestack(L, funcr); /* previous call may change stack */
++ setobj2s(L, func, tm); /* tag method is the new function to be called */
++ return func;
++}
++
++
++
++#define inc_ci(L) \
++ ((L->ci == L->end_ci) ? growCI(L) : \
++ (condhardstacktests(luaD_reallocCI(L, L->size_ci)), ++L->ci))
++
++
++int luaD_precall (lua_State *L, StkId func, int nresults) {
++ LClosure *cl;
++ ptrdiff_t funcr;
++ if (!ttisfunction(func)) /* `func' is not a function? */
++ func = tryfuncTM(L, func); /* check the `function' tag method */
++ funcr = savestack(L, func);
++ cl = &clvalue(func)->l;
++ L->ci->savedpc = L->savedpc;
++ if (!cl->isC) { /* Lua function? prepare its call */
++ CallInfo *ci;
++ StkId st, base;
++ Proto *p = cl->p;
++ luaD_checkstack(L, p->maxstacksize);
++ func = restorestack(L, funcr);
++ if (!p->is_vararg) { /* no varargs? */
++ base = func + 1;
++ if (L->top > base + p->numparams)
++ L->top = base + p->numparams;
++ }
++ else { /* vararg function */
++ int nargs = cast_int(L->top - func) - 1;
++ base = adjust_varargs(L, p, nargs);
++ func = restorestack(L, funcr); /* previous call may change the stack */
++ }
++ ci = inc_ci(L); /* now `enter' new function */
++ ci->func = func;
++ L->base = ci->base = base;
++ ci->top = L->base + p->maxstacksize;
++ lua_assert(ci->top <= L->stack_last);
++ L->savedpc = p->code; /* starting point */
++ ci->tailcalls = 0;
++ ci->nresults = nresults;
++ for (st = L->top; st < ci->top; st++)
++ setnilvalue(st);
++ L->top = ci->top;
++ if (L->hookmask & LUA_MASKCALL) {
++ L->savedpc++; /* hooks assume 'pc' is already incremented */
++ luaD_callhook(L, LUA_HOOKCALL, -1);
++ L->savedpc--; /* correct 'pc' */
++ }
++ return PCRLUA;
++ }
++ else { /* if is a C function, call it */
++ CallInfo *ci;
++ int n;
++ luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */
++ ci = inc_ci(L); /* now `enter' new function */
++ ci->func = restorestack(L, funcr);
++ L->base = ci->base = ci->func + 1;
++ ci->top = L->top + LUA_MINSTACK;
++ lua_assert(ci->top <= L->stack_last);
++ ci->nresults = nresults;
++ if (L->hookmask & LUA_MASKCALL)
++ luaD_callhook(L, LUA_HOOKCALL, -1);
++ lua_unlock(L);
++ n = (*curr_func(L)->c.f)(L); /* do the actual call */
++ lua_lock(L);
++ if (n < 0) /* yielding? */
++ return PCRYIELD;
++ else {
++ luaD_poscall(L, L->top - n);
++ return PCRC;
++ }
++ }
++}
++
++
++static StkId callrethooks (lua_State *L, StkId firstResult) {
++ ptrdiff_t fr = savestack(L, firstResult); /* next call may change stack */
++ luaD_callhook(L, LUA_HOOKRET, -1);
++ if (f_isLua(L->ci)) { /* Lua function? */
++ while ((L->hookmask & LUA_MASKRET) && L->ci->tailcalls--) /* tail calls */
++ luaD_callhook(L, LUA_HOOKTAILRET, -1);
++ }
++ return restorestack(L, fr);
++}
++
++
++int luaD_poscall (lua_State *L, StkId firstResult) {
++ StkId res;
++ int wanted, i;
++ CallInfo *ci;
++ if (L->hookmask & LUA_MASKRET)
++ firstResult = callrethooks(L, firstResult);
++ ci = L->ci--;
++ res = ci->func; /* res == final position of 1st result */
++ wanted = ci->nresults;
++ L->base = (ci - 1)->base; /* restore base */
++ L->savedpc = (ci - 1)->savedpc; /* restore savedpc */
++ /* move results to correct place */
++ for (i = wanted; i != 0 && firstResult < L->top; i--)
++ setobjs2s(L, res++, firstResult++);
++ while (i-- > 0)
++ setnilvalue(res++);
++ L->top = res;
++ return (wanted - LUA_MULTRET); /* 0 iff wanted == LUA_MULTRET */
++}
++
++
++/*
++** Call a function (C or Lua). The function to be called is at *func.
++** The arguments are on the stack, right after the function.
++** When returns, all the results are on the stack, starting at the original
++** function position.
++*/
++void luaD_call (lua_State *L, StkId func, int nResults) {
++ if (++L->nCcalls >= LUAI_MAXCCALLS) {
++ if (L->nCcalls == LUAI_MAXCCALLS)
++ luaG_runerror(L, "C stack overflow");
++ else if (L->nCcalls >= (LUAI_MAXCCALLS + (LUAI_MAXCCALLS>>3)))
++ luaD_throw(L, LUA_ERRERR); /* error while handing stack error */
++ }
++ if (luaD_precall(L, func, nResults) == PCRLUA) /* is a Lua function? */
++ luaV_execute(L, 1); /* call it */
++ L->nCcalls--;
++ luaC_checkGC(L);
++}
++
++
++static void resume (lua_State *L, void *ud) {
++ StkId firstArg = cast(StkId, ud);
++ CallInfo *ci = L->ci;
++ if (L->status == 0) { /* start coroutine? */
++ lua_assert(ci == L->base_ci && firstArg > L->base);
++ if (luaD_precall(L, firstArg - 1, LUA_MULTRET) != PCRLUA)
++ return;
++ }
++ else { /* resuming from previous yield */
++ lua_assert(L->status == LUA_YIELD);
++ L->status = 0;
++ if (!f_isLua(ci)) { /* `common' yield? */
++ /* finish interrupted execution of `OP_CALL' */
++ lua_assert(GET_OPCODE(*((ci-1)->savedpc - 1)) == OP_CALL ||
++ GET_OPCODE(*((ci-1)->savedpc - 1)) == OP_TAILCALL);
++ if (luaD_poscall(L, firstArg)) /* complete it... */
++ L->top = L->ci->top; /* and correct top if not multiple results */
++ }
++ else /* yielded inside a hook: just continue its execution */
++ L->base = L->ci->base;
++ }
++ luaV_execute(L, cast_int(L->ci - L->base_ci));
++}
++
++
++static int resume_error (lua_State *L, const char *msg) {
++ L->top = L->ci->base;
++ setsvalue2s(L, L->top, luaS_new(L, msg));
++ incr_top(L);
++ lua_unlock(L);
++ return LUA_ERRRUN;
++}
++
++
++LUA_API int lua_resume (lua_State *L, int nargs) {
++ int status;
++ lua_lock(L);
++ if (L->status != LUA_YIELD && (L->status != 0 || L->ci != L->base_ci))
++ return resume_error(L, "cannot resume non-suspended coroutine");
++ if (L->nCcalls >= LUAI_MAXCCALLS)
++ return resume_error(L, "C stack overflow");
++ luai_userstateresume(L, nargs);
++ lua_assert(L->errfunc == 0);
++ L->baseCcalls = ++L->nCcalls;
++ status = luaD_rawrunprotected(L, resume, L->top - nargs);
++ if (status != 0) { /* error? */
++ L->status = cast_byte(status); /* mark thread as `dead' */
++ luaD_seterrorobj(L, status, L->top);
++ L->ci->top = L->top;
++ }
++ else {
++ lua_assert(L->nCcalls == L->baseCcalls);
++ status = L->status;
++ }
++ --L->nCcalls;
++ lua_unlock(L);
++ return status;
++}
++
++
++LUA_API int lua_yield (lua_State *L, int nresults) {
++ luai_userstateyield(L, nresults);
++ lua_lock(L);
++ if (L->nCcalls > L->baseCcalls)
++ luaG_runerror(L, "attempt to yield across metamethod/C-call boundary");
++ L->base = L->top - nresults; /* protect stack slots below */
++ L->status = LUA_YIELD;
++ lua_unlock(L);
++ return -1;
++}
++
++
++int luaD_pcall (lua_State *L, Pfunc func, void *u,
++ ptrdiff_t old_top, ptrdiff_t ef) {
++ int status;
++ unsigned short oldnCcalls = L->nCcalls;
++ ptrdiff_t old_ci = saveci(L, L->ci);
++ lu_byte old_allowhooks = L->allowhook;
++ ptrdiff_t old_errfunc = L->errfunc;
++ L->errfunc = ef;
++ status = luaD_rawrunprotected(L, func, u);
++ if (status != 0) { /* an error occurred? */
++ StkId oldtop = restorestack(L, old_top);
++ luaF_close(L, oldtop); /* close eventual pending closures */
++ luaD_seterrorobj(L, status, oldtop);
++ L->nCcalls = oldnCcalls;
++ L->ci = restoreci(L, old_ci);
++ L->base = L->ci->base;
++ L->savedpc = L->ci->savedpc;
++ L->allowhook = old_allowhooks;
++ restore_stack_limit(L);
++ }
++ L->errfunc = old_errfunc;
++ return status;
++}
++
++
++
++/*
++** Execute a protected parser.
++*/
++struct SParser { /* data to `f_parser' */
++ ZIO *z;
++ Mbuffer buff; /* buffer to be used by the scanner */
++ const char *name;
++};
++
++static void f_parser (lua_State *L, void *ud) {
++ int i;
++ Proto *tf;
++ Closure *cl;
++ struct SParser *p = cast(struct SParser *, ud);
++ int c = luaZ_lookahead(p->z);
++ luaC_checkGC(L);
++ tf = ((c == LUA_SIGNATURE[0]) ? luaU_undump : luaY_parser)(L, p->z,
++ &p->buff, p->name);
++ cl = luaF_newLclosure(L, tf->nups, hvalue(gt(L)));
++ cl->l.p = tf;
++ for (i = 0; i < tf->nups; i++) /* initialize eventual upvalues */
++ cl->l.upvals[i] = luaF_newupval(L);
++ setclvalue(L, L->top, cl);
++ incr_top(L);
++}
++
++
++int luaD_protectedparser (lua_State *L, ZIO *z, const char *name) {
++ struct SParser p;
++ int status;
++ p.z = z; p.name = name;
++ luaZ_initbuffer(L, &p.buff);
++ status = luaD_pcall(L, f_parser, &p, savestack(L, L->top), L->errfunc);
++ luaZ_freebuffer(L, &p.buff);
++ return status;
++}
++
+--- /dev/null
++++ b/extensions/LUA/lua/ldo.h
+@@ -0,0 +1,57 @@
++/*
++** $Id: ldo.h,v 2.7.1.1 2007/12/27 13:02:25 roberto Exp $
++** Stack and Call structure of Lua
++** See Copyright Notice in lua.h
++*/
++
++#ifndef ldo_h
++#define ldo_h
++
++
++#include "lobject.h"
++#include "lstate.h"
++#include "lzio.h"
++
++
++#define luaD_checkstack(L,n) \
++ if ((char *)L->stack_last - (char *)L->top <= (n)*(int)sizeof(TValue)) \
++ luaD_growstack(L, n); \
++ else condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK - 1));
++
++
++#define incr_top(L) {luaD_checkstack(L,1); L->top++;}
++
++#define savestack(L,p) ((char *)(p) - (char *)L->stack)
++#define restorestack(L,n) ((TValue *)((char *)L->stack + (n)))
++
++#define saveci(L,p) ((char *)(p) - (char *)L->base_ci)
++#define restoreci(L,n) ((CallInfo *)((char *)L->base_ci + (n)))
++
++
++/* results from luaD_precall */
++#define PCRLUA 0 /* initiated a call to a Lua function */
++#define PCRC 1 /* did a call to a C function */
++#define PCRYIELD 2 /* C funtion yielded */
++
++
++/* type of protected functions, to be ran by `runprotected' */
++typedef void (*Pfunc) (lua_State *L, void *ud);
++
++LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name);
++LUAI_FUNC void luaD_callhook (lua_State *L, int event, int line);
++LUAI_FUNC int luaD_precall (lua_State *L, StkId func, int nresults);
++LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults);
++LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u,
++ ptrdiff_t oldtop, ptrdiff_t ef);
++LUAI_FUNC int luaD_poscall (lua_State *L, StkId firstResult);
++LUAI_FUNC void luaD_reallocCI (lua_State *L, int newsize);
++LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize);
++LUAI_FUNC void luaD_growstack (lua_State *L, int n);
++
++LUAI_FUNC void luaD_throw (lua_State *L, int errcode);
++LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud);
++
++LUAI_FUNC void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop);
++
++#endif
++
+--- /dev/null
++++ b/extensions/LUA/lua/ldump.c
+@@ -0,0 +1,164 @@
++/*
++** $Id: ldump.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $
++** save precompiled Lua chunks
++** See Copyright Notice in lua.h
++*/
++
++#include <stddef.h>
++
++#define ldump_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "lobject.h"
++#include "lstate.h"
++#include "lundump.h"
++
++typedef struct {
++ lua_State* L;
++ lua_Writer writer;
++ void* data;
++ int strip;
++ int status;
++} DumpState;
++
++#define DumpMem(b,n,size,D) DumpBlock(b,(n)*(size),D)
++#define DumpVar(x,D) DumpMem(&x,1,sizeof(x),D)
++
++static void DumpBlock(const void* b, size_t size, DumpState* D)
++{
++ if (D->status==0)
++ {
++ lua_unlock(D->L);
++ D->status=(*D->writer)(D->L,b,size,D->data);
++ lua_lock(D->L);
++ }
++}
++
++static void DumpChar(int y, DumpState* D)
++{
++ char x=(char)y;
++ DumpVar(x,D);
++}
++
++static void DumpInt(int x, DumpState* D)
++{
++ DumpVar(x,D);
++}
++
++static void DumpNumber(lua_Number x, DumpState* D)
++{
++ DumpVar(x,D);
++}
++
++static void DumpVector(const void* b, int n, size_t size, DumpState* D)
++{
++ DumpInt(n,D);
++ DumpMem(b,n,size,D);
++}
++
++static void DumpString(const TString* s, DumpState* D)
++{
++ if (s==NULL || getstr(s)==NULL)
++ {
++ size_t size=0;
++ DumpVar(size,D);
++ }
++ else
++ {
++ size_t size=s->tsv.len+1; /* include trailing '\0' */
++ DumpVar(size,D);
++ DumpBlock(getstr(s),size,D);
++ }
++}
++
++#define DumpCode(f,D) DumpVector(f->code,f->sizecode,sizeof(Instruction),D)
++
++static void DumpFunction(const Proto* f, const TString* p, DumpState* D);
++
++static void DumpConstants(const Proto* f, DumpState* D)
++{
++ int i,n=f->sizek;
++ DumpInt(n,D);
++ for (i=0; i<n; i++)
++ {
++ const TValue* o=&f->k[i];
++ DumpChar(ttype(o),D);
++ switch (ttype(o))
++ {
++ case LUA_TNIL:
++ break;
++ case LUA_TBOOLEAN:
++ DumpChar(bvalue(o),D);
++ break;
++ case LUA_TNUMBER:
++ DumpNumber(nvalue(o),D);
++ break;
++ case LUA_TSTRING:
++ DumpString(rawtsvalue(o),D);
++ break;
++ default:
++ lua_assert(0); /* cannot happen */
++ break;
++ }
++ }
++ n=f->sizep;
++ DumpInt(n,D);
++ for (i=0; i<n; i++) DumpFunction(f->p[i],f->source,D);
++}
++
++static void DumpDebug(const Proto* f, DumpState* D)
++{
++ int i,n;
++ n= (D->strip) ? 0 : f->sizelineinfo;
++ DumpVector(f->lineinfo,n,sizeof(int),D);
++ n= (D->strip) ? 0 : f->sizelocvars;
++ DumpInt(n,D);
++ for (i=0; i<n; i++)
++ {
++ DumpString(f->locvars[i].varname,D);
++ DumpInt(f->locvars[i].startpc,D);
++ DumpInt(f->locvars[i].endpc,D);
++ }
++ n= (D->strip) ? 0 : f->sizeupvalues;
++ DumpInt(n,D);
++ for (i=0; i<n; i++) DumpString(f->upvalues[i],D);
++}
++
++static void DumpFunction(const Proto* f, const TString* p, DumpState* D)
++{
++ DumpString((f->source==p || D->strip) ? NULL : f->source,D);
++ DumpInt(f->linedefined,D);
++ DumpInt(f->lastlinedefined,D);
++ DumpChar(f->nups,D);
++ DumpChar(f->numparams,D);
++ DumpChar(f->is_vararg,D);
++ DumpChar(f->maxstacksize,D);
++ DumpCode(f,D);
++ DumpConstants(f,D);
++ DumpDebug(f,D);
++}
++
++static void DumpHeader(DumpState* D)
++{
++ char h[LUAC_HEADERSIZE];
++ luaU_header(h);
++ DumpBlock(h,LUAC_HEADERSIZE,D);
++}
++
++/*
++** dump Lua function as precompiled chunk
++*/
++int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip)
++{
++ DumpState D;
++ D.L=L;
++ D.writer=w;
++ D.data=data;
++ D.strip=strip;
++ D.status=0;
++ DumpHeader(&D);
++ DumpFunction(f,NULL,&D);
++ return D.status;
++}
+--- /dev/null
++++ b/extensions/LUA/lua/lfunc.c
+@@ -0,0 +1,174 @@
++/*
++** $Id: lfunc.c,v 2.12.1.2 2007/12/28 14:58:43 roberto Exp $
++** Auxiliary functions to manipulate prototypes and closures
++** See Copyright Notice in lua.h
++*/
++
++
++#include <stddef.h>
++
++#define lfunc_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "lfunc.h"
++#include "lgc.h"
++#include "lmem.h"
++#include "lobject.h"
++#include "lstate.h"
++
++
++
++Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e) {
++ Closure *c = cast(Closure *, luaM_malloc(L, sizeCclosure(nelems)));
++ luaC_link(L, obj2gco(c), LUA_TFUNCTION);
++ c->c.isC = 1;
++ c->c.env = e;
++ c->c.nupvalues = cast_byte(nelems);
++ return c;
++}
++
++
++Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e) {
++ Closure *c = cast(Closure *, luaM_malloc(L, sizeLclosure(nelems)));
++ luaC_link(L, obj2gco(c), LUA_TFUNCTION);
++ c->l.isC = 0;
++ c->l.env = e;
++ c->l.nupvalues = cast_byte(nelems);
++ while (nelems--) c->l.upvals[nelems] = NULL;
++ return c;
++}
++
++
++UpVal *luaF_newupval (lua_State *L) {
++ UpVal *uv = luaM_new(L, UpVal);
++ luaC_link(L, obj2gco(uv), LUA_TUPVAL);
++ uv->v = &uv->u.value;
++ setnilvalue(uv->v);
++ return uv;
++}
++
++
++UpVal *luaF_findupval (lua_State *L, StkId level) {
++ global_State *g = G(L);
++ GCObject **pp = &L->openupval;
++ UpVal *p;
++ UpVal *uv;
++ while (*pp != NULL && (p = ngcotouv(*pp))->v >= level) {
++ lua_assert(p->v != &p->u.value);
++ if (p->v == level) { /* found a corresponding upvalue? */
++ if (isdead(g, obj2gco(p))) /* is it dead? */
++ changewhite(obj2gco(p)); /* ressurect it */
++ return p;
++ }
++ pp = &p->next;
++ }
++ uv = luaM_new(L, UpVal); /* not found: create a new one */
++ uv->tt = LUA_TUPVAL;
++ uv->marked = luaC_white(g);
++ uv->v = level; /* current value lives in the stack */
++ uv->next = *pp; /* chain it in the proper position */
++ *pp = obj2gco(uv);
++ uv->u.l.prev = &g->uvhead; /* double link it in `uvhead' list */
++ uv->u.l.next = g->uvhead.u.l.next;
++ uv->u.l.next->u.l.prev = uv;
++ g->uvhead.u.l.next = uv;
++ lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv);
++ return uv;
++}
++
++
++static void unlinkupval (UpVal *uv) {
++ lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv);
++ uv->u.l.next->u.l.prev = uv->u.l.prev; /* remove from `uvhead' list */
++ uv->u.l.prev->u.l.next = uv->u.l.next;
++}
++
++
++void luaF_freeupval (lua_State *L, UpVal *uv) {
++ if (uv->v != &uv->u.value) /* is it open? */
++ unlinkupval(uv); /* remove from open list */
++ luaM_free(L, uv); /* free upvalue */
++}
++
++
++void luaF_close (lua_State *L, StkId level) {
++ UpVal *uv;
++ global_State *g = G(L);
++ while (L->openupval != NULL && (uv = ngcotouv(L->openupval))->v >= level) {
++ GCObject *o = obj2gco(uv);
++ lua_assert(!isblack(o) && uv->v != &uv->u.value);
++ L->openupval = uv->next; /* remove from `open' list */
++ if (isdead(g, o))
++ luaF_freeupval(L, uv); /* free upvalue */
++ else {
++ unlinkupval(uv);
++ setobj(L, &uv->u.value, uv->v);
++ uv->v = &uv->u.value; /* now current value lives here */
++ luaC_linkupval(L, uv); /* link upvalue into `gcroot' list */
++ }
++ }
++}
++
++
++Proto *luaF_newproto (lua_State *L) {
++ Proto *f = luaM_new(L, Proto);
++ luaC_link(L, obj2gco(f), LUA_TPROTO);
++ f->k = NULL;
++ f->sizek = 0;
++ f->p = NULL;
++ f->sizep = 0;
++ f->code = NULL;
++ f->sizecode = 0;
++ f->sizelineinfo = 0;
++ f->sizeupvalues = 0;
++ f->nups = 0;
++ f->upvalues = NULL;
++ f->numparams = 0;
++ f->is_vararg = 0;
++ f->maxstacksize = 0;
++ f->lineinfo = NULL;
++ f->sizelocvars = 0;
++ f->locvars = NULL;
++ f->linedefined = 0;
++ f->lastlinedefined = 0;
++ f->source = NULL;
++ return f;
++}
++
++
++void luaF_freeproto (lua_State *L, Proto *f) {
++ luaM_freearray(L, f->code, f->sizecode, Instruction);
++ luaM_freearray(L, f->p, f->sizep, Proto *);
++ luaM_freearray(L, f->k, f->sizek, TValue);
++ luaM_freearray(L, f->lineinfo, f->sizelineinfo, int);
++ luaM_freearray(L, f->locvars, f->sizelocvars, struct LocVar);
++ luaM_freearray(L, f->upvalues, f->sizeupvalues, TString *);
++ luaM_free(L, f);
++}
++
++
++void luaF_freeclosure (lua_State *L, Closure *c) {
++ int size = (c->c.isC) ? sizeCclosure(c->c.nupvalues) :
++ sizeLclosure(c->l.nupvalues);
++ luaM_freemem(L, c, size);
++}
++
++
++/*
++** Look for n-th local variable at line `line' in function `func'.
++** Returns NULL if not found.
++*/
++const char *luaF_getlocalname (const Proto *f, int local_number, int pc) {
++ int i;
++ for (i = 0; i<f->sizelocvars && f->locvars[i].startpc <= pc; i++) {
++ if (pc < f->locvars[i].endpc) { /* is variable active? */
++ local_number--;
++ if (local_number == 0)
++ return getstr(f->locvars[i].varname);
++ }
++ }
++ return NULL; /* not found */
++}
++
+--- /dev/null
++++ b/extensions/LUA/lua/lfunc.h
+@@ -0,0 +1,34 @@
++/*
++** $Id: lfunc.h,v 2.4.1.1 2007/12/27 13:02:25 roberto Exp $
++** Auxiliary functions to manipulate prototypes and closures
++** See Copyright Notice in lua.h
++*/
++
++#ifndef lfunc_h
++#define lfunc_h
++
++
++#include "lobject.h"
++
++
++#define sizeCclosure(n) (cast(int, sizeof(CClosure)) + \
++ cast(int, sizeof(TValue)*((n)-1)))
++
++#define sizeLclosure(n) (cast(int, sizeof(LClosure)) + \
++ cast(int, sizeof(TValue *)*((n)-1)))
++
++
++LUAI_FUNC Proto *luaF_newproto (lua_State *L);
++LUAI_FUNC Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e);
++LUAI_FUNC Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e);
++LUAI_FUNC UpVal *luaF_newupval (lua_State *L);
++LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level);
++LUAI_FUNC void luaF_close (lua_State *L, StkId level);
++LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f);
++LUAI_FUNC void luaF_freeclosure (lua_State *L, Closure *c);
++LUAI_FUNC void luaF_freeupval (lua_State *L, UpVal *uv);
++LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number,
++ int pc);
++
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/lgc.c
+@@ -0,0 +1,711 @@
++/*
++** $Id: lgc.c,v 2.38.1.1 2007/12/27 13:02:25 roberto Exp $
++** Garbage Collector
++** See Copyright Notice in lua.h
++*/
++
++#include <string.h>
++
++#define lgc_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "ldebug.h"
++#include "ldo.h"
++#include "lfunc.h"
++#include "lgc.h"
++#include "lmem.h"
++#include "lobject.h"
++#include "lstate.h"
++#include "lstring.h"
++#include "ltable.h"
++#include "ltm.h"
++
++
++#define GCSTEPSIZE 1024u
++#define GCSWEEPMAX 40
++#define GCSWEEPCOST 10
++#define GCFINALIZECOST 100
++
++
++#define maskmarks cast_byte(~(bitmask(BLACKBIT)|WHITEBITS))
++
++#define makewhite(g,x) \
++ ((x)->gch.marked = cast_byte(((x)->gch.marked & maskmarks) | luaC_white(g)))
++
++#define white2gray(x) reset2bits((x)->gch.marked, WHITE0BIT, WHITE1BIT)
++#define black2gray(x) resetbit((x)->gch.marked, BLACKBIT)
++
++#define stringmark(s) reset2bits((s)->tsv.marked, WHITE0BIT, WHITE1BIT)
++
++
++#define isfinalized(u) testbit((u)->marked, FINALIZEDBIT)
++#define markfinalized(u) l_setbit((u)->marked, FINALIZEDBIT)
++
++
++#define KEYWEAK bitmask(KEYWEAKBIT)
++#define VALUEWEAK bitmask(VALUEWEAKBIT)
++
++
++
++#define markvalue(g,o) { checkconsistency(o); \
++ if (iscollectable(o) && iswhite(gcvalue(o))) reallymarkobject(g,gcvalue(o)); }
++
++#define markobject(g,t) { if (iswhite(obj2gco(t))) \
++ reallymarkobject(g, obj2gco(t)); }
++
++
++#define setthreshold(g) (g->GCthreshold = (g->estimate/100) * g->gcpause)
++
++
++static void removeentry (Node *n) {
++ lua_assert(ttisnil(gval(n)));
++ if (iscollectable(gkey(n)))
++ setttype(gkey(n), LUA_TDEADKEY); /* dead key; remove it */
++}
++
++
++static void reallymarkobject (global_State *g, GCObject *o) {
++ lua_assert(iswhite(o) && !isdead(g, o));
++ white2gray(o);
++ switch (o->gch.tt) {
++ case LUA_TSTRING: {
++ return;
++ }
++ case LUA_TUSERDATA: {
++ Table *mt = gco2u(o)->metatable;
++ gray2black(o); /* udata are never gray */
++ if (mt) markobject(g, mt);
++ markobject(g, gco2u(o)->env);
++ return;
++ }
++ case LUA_TUPVAL: {
++ UpVal *uv = gco2uv(o);
++ markvalue(g, uv->v);
++ if (uv->v == &uv->u.value) /* closed? */
++ gray2black(o); /* open upvalues are never black */
++ return;
++ }
++ case LUA_TFUNCTION: {
++ gco2cl(o)->c.gclist = g->gray;
++ g->gray = o;
++ break;
++ }
++ case LUA_TTABLE: {
++ gco2h(o)->gclist = g->gray;
++ g->gray = o;
++ break;
++ }
++ case LUA_TTHREAD: {
++ gco2th(o)->gclist = g->gray;
++ g->gray = o;
++ break;
++ }
++ case LUA_TPROTO: {
++ gco2p(o)->gclist = g->gray;
++ g->gray = o;
++ break;
++ }
++ default: lua_assert(0);
++ }
++}
++
++
++static void marktmu (global_State *g) {
++ GCObject *u = g->tmudata;
++ if (u) {
++ do {
++ u = u->gch.next;
++ makewhite(g, u); /* may be marked, if left from previous GC */
++ reallymarkobject(g, u);
++ } while (u != g->tmudata);
++ }
++}
++
++
++/* move `dead' udata that need finalization to list `tmudata' */
++size_t luaC_separateudata (lua_State *L, int all) {
++ global_State *g = G(L);
++ size_t deadmem = 0;
++ GCObject **p = &g->mainthread->next;
++ GCObject *curr;
++ while ((curr = *p) != NULL) {
++ if (!(iswhite(curr) || all) || isfinalized(gco2u(curr)))
++ p = &curr->gch.next; /* don't bother with them */
++ else if (fasttm(L, gco2u(curr)->metatable, TM_GC) == NULL) {
++ markfinalized(gco2u(curr)); /* don't need finalization */
++ p = &curr->gch.next;
++ }
++ else { /* must call its gc method */
++ deadmem += sizeudata(gco2u(curr));
++ markfinalized(gco2u(curr));
++ *p = curr->gch.next;
++ /* link `curr' at the end of `tmudata' list */
++ if (g->tmudata == NULL) /* list is empty? */
++ g->tmudata = curr->gch.next = curr; /* creates a circular list */
++ else {
++ curr->gch.next = g->tmudata->gch.next;
++ g->tmudata->gch.next = curr;
++ g->tmudata = curr;
++ }
++ }
++ }
++ return deadmem;
++}
++
++
++static int traversetable (global_State *g, Table *h) {
++ int i;
++ int weakkey = 0;
++ int weakvalue = 0;
++ const TValue *mode;
++ if (h->metatable)
++ markobject(g, h->metatable);
++ mode = gfasttm(g, h->metatable, TM_MODE);
++ if (mode && ttisstring(mode)) { /* is there a weak mode? */
++ weakkey = (strchr(svalue(mode), 'k') != NULL);
++ weakvalue = (strchr(svalue(mode), 'v') != NULL);
++ if (weakkey || weakvalue) { /* is really weak? */
++ h->marked &= ~(KEYWEAK | VALUEWEAK); /* clear bits */
++ h->marked |= cast_byte((weakkey << KEYWEAKBIT) |
++ (weakvalue << VALUEWEAKBIT));
++ h->gclist = g->weak; /* must be cleared after GC, ... */
++ g->weak = obj2gco(h); /* ... so put in the appropriate list */
++ }
++ }
++ if (weakkey && weakvalue) return 1;
++ if (!weakvalue) {
++ i = h->sizearray;
++ while (i--)
++ markvalue(g, &h->array[i]);
++ }
++ i = sizenode(h);
++ while (i--) {
++ Node *n = gnode(h, i);
++ lua_assert(ttype(gkey(n)) != LUA_TDEADKEY || ttisnil(gval(n)));
++ if (ttisnil(gval(n)))
++ removeentry(n); /* remove empty entries */
++ else {
++ lua_assert(!ttisnil(gkey(n)));
++ if (!weakkey) markvalue(g, gkey(n));
++ if (!weakvalue) markvalue(g, gval(n));
++ }
++ }
++ return weakkey || weakvalue;
++}
++
++
++/*
++** All marks are conditional because a GC may happen while the
++** prototype is still being created
++*/
++static void traverseproto (global_State *g, Proto *f) {
++ int i;
++ if (f->source) stringmark(f->source);
++ for (i=0; i<f->sizek; i++) /* mark literals */
++ markvalue(g, &f->k[i]);
++ for (i=0; i<f->sizeupvalues; i++) { /* mark upvalue names */
++ if (f->upvalues[i])
++ stringmark(f->upvalues[i]);
++ }
++ for (i=0; i<f->sizep; i++) { /* mark nested protos */
++ if (f->p[i])
++ markobject(g, f->p[i]);
++ }
++ for (i=0; i<f->sizelocvars; i++) { /* mark local-variable names */
++ if (f->locvars[i].varname)
++ stringmark(f->locvars[i].varname);
++ }
++}
++
++
++
++static void traverseclosure (global_State *g, Closure *cl) {
++ markobject(g, cl->c.env);
++ if (cl->c.isC) {
++ int i;
++ for (i=0; i<cl->c.nupvalues; i++) /* mark its upvalues */
++ markvalue(g, &cl->c.upvalue[i]);
++ }
++ else {
++ int i;
++ lua_assert(cl->l.nupvalues == cl->l.p->nups);
++ markobject(g, cl->l.p);
++ for (i=0; i<cl->l.nupvalues; i++) /* mark its upvalues */
++ markobject(g, cl->l.upvals[i]);
++ }
++}
++
++
++static void checkstacksizes (lua_State *L, StkId max) {
++ int ci_used = cast_int(L->ci - L->base_ci); /* number of `ci' in use */
++ int s_used = cast_int(max - L->stack); /* part of stack in use */
++ if (L->size_ci > LUAI_MAXCALLS) /* handling overflow? */
++ return; /* do not touch the stacks */
++ if (4*ci_used < L->size_ci && 2*BASIC_CI_SIZE < L->size_ci)
++ luaD_reallocCI(L, L->size_ci/2); /* still big enough... */
++ condhardstacktests(luaD_reallocCI(L, ci_used + 1));
++ if (4*s_used < L->stacksize &&
++ 2*(BASIC_STACK_SIZE+EXTRA_STACK) < L->stacksize)
++ luaD_reallocstack(L, L->stacksize/2); /* still big enough... */
++ condhardstacktests(luaD_reallocstack(L, s_used));
++}
++
++
++static void traversestack (global_State *g, lua_State *l) {
++ StkId o, lim;
++ CallInfo *ci;
++ markvalue(g, gt(l));
++ lim = l->top;
++ for (ci = l->base_ci; ci <= l->ci; ci++) {
++ lua_assert(ci->top <= l->stack_last);
++ if (lim < ci->top) lim = ci->top;
++ }
++ for (o = l->stack; o < l->top; o++)
++ markvalue(g, o);
++ for (; o <= lim; o++)
++ setnilvalue(o);
++ checkstacksizes(l, lim);
++}
++
++
++/*
++** traverse one gray object, turning it to black.
++** Returns `quantity' traversed.
++*/
++static l_mem propagatemark (global_State *g) {
++ GCObject *o = g->gray;
++ lua_assert(isgray(o));
++ gray2black(o);
++ switch (o->gch.tt) {
++ case LUA_TTABLE: {
++ Table *h = gco2h(o);
++ g->gray = h->gclist;
++ if (traversetable(g, h)) /* table is weak? */
++ black2gray(o); /* keep it gray */
++ return sizeof(Table) + sizeof(TValue) * h->sizearray +
++ sizeof(Node) * sizenode(h);
++ }
++ case LUA_TFUNCTION: {
++ Closure *cl = gco2cl(o);
++ g->gray = cl->c.gclist;
++ traverseclosure(g, cl);
++ return (cl->c.isC) ? sizeCclosure(cl->c.nupvalues) :
++ sizeLclosure(cl->l.nupvalues);
++ }
++ case LUA_TTHREAD: {
++ lua_State *th = gco2th(o);
++ g->gray = th->gclist;
++ th->gclist = g->grayagain;
++ g->grayagain = o;
++ black2gray(o);
++ traversestack(g, th);
++ return sizeof(lua_State) + sizeof(TValue) * th->stacksize +
++ sizeof(CallInfo) * th->size_ci;
++ }
++ case LUA_TPROTO: {
++ Proto *p = gco2p(o);
++ g->gray = p->gclist;
++ traverseproto(g, p);
++ return sizeof(Proto) + sizeof(Instruction) * p->sizecode +
++ sizeof(Proto *) * p->sizep +
++ sizeof(TValue) * p->sizek +
++ sizeof(int) * p->sizelineinfo +
++ sizeof(LocVar) * p->sizelocvars +
++ sizeof(TString *) * p->sizeupvalues;
++ }
++ default: lua_assert(0); return 0;
++ }
++}
++
++
++static size_t propagateall (global_State *g) {
++ size_t m = 0;
++ while (g->gray) m += propagatemark(g);
++ return m;
++}
++
++
++/*
++** The next function tells whether a key or value can be cleared from
++** a weak table. Non-collectable objects are never removed from weak
++** tables. Strings behave as `values', so are never removed too. for
++** other objects: if really collected, cannot keep them; for userdata
++** being finalized, keep them in keys, but not in values
++*/
++static int iscleared (const TValue *o, int iskey) {
++ if (!iscollectable(o)) return 0;
++ if (ttisstring(o)) {
++ stringmark(rawtsvalue(o)); /* strings are `values', so are never weak */
++ return 0;
++ }
++ return iswhite(gcvalue(o)) ||
++ (ttisuserdata(o) && (!iskey && isfinalized(uvalue(o))));
++}
++
++
++/*
++** clear collected entries from weaktables
++*/
++static void cleartable (GCObject *l) {
++ while (l) {
++ Table *h = gco2h(l);
++ int i = h->sizearray;
++ lua_assert(testbit(h->marked, VALUEWEAKBIT) ||
++ testbit(h->marked, KEYWEAKBIT));
++ if (testbit(h->marked, VALUEWEAKBIT)) {
++ while (i--) {
++ TValue *o = &h->array[i];
++ if (iscleared(o, 0)) /* value was collected? */
++ setnilvalue(o); /* remove value */
++ }
++ }
++ i = sizenode(h);
++ while (i--) {
++ Node *n = gnode(h, i);
++ if (!ttisnil(gval(n)) && /* non-empty entry? */
++ (iscleared(key2tval(n), 1) || iscleared(gval(n), 0))) {
++ setnilvalue(gval(n)); /* remove value ... */
++ removeentry(n); /* remove entry from table */
++ }
++ }
++ l = h->gclist;
++ }
++}
++
++
++static void freeobj (lua_State *L, GCObject *o) {
++ switch (o->gch.tt) {
++ case LUA_TPROTO: luaF_freeproto(L, gco2p(o)); break;
++ case LUA_TFUNCTION: luaF_freeclosure(L, gco2cl(o)); break;
++ case LUA_TUPVAL: luaF_freeupval(L, gco2uv(o)); break;
++ case LUA_TTABLE: luaH_free(L, gco2h(o)); break;
++ case LUA_TTHREAD: {
++ lua_assert(gco2th(o) != L && gco2th(o) != G(L)->mainthread);
++ luaE_freethread(L, gco2th(o));
++ break;
++ }
++ case LUA_TSTRING: {
++ G(L)->strt.nuse--;
++ luaM_freemem(L, o, sizestring(gco2ts(o)));
++ break;
++ }
++ case LUA_TUSERDATA: {
++ luaM_freemem(L, o, sizeudata(gco2u(o)));
++ break;
++ }
++ default: lua_assert(0);
++ }
++}
++
++
++
++#define sweepwholelist(L,p) sweeplist(L,p,MAX_LUMEM)
++
++
++static GCObject **sweeplist (lua_State *L, GCObject **p, lu_mem count) {
++ GCObject *curr;
++ global_State *g = G(L);
++ int deadmask = otherwhite(g);
++ while ((curr = *p) != NULL && count-- > 0) {
++ if (curr->gch.tt == LUA_TTHREAD) /* sweep open upvalues of each thread */
++ sweepwholelist(L, &gco2th(curr)->openupval);
++ if ((curr->gch.marked ^ WHITEBITS) & deadmask) { /* not dead? */
++ lua_assert(!isdead(g, curr) || testbit(curr->gch.marked, FIXEDBIT));
++ makewhite(g, curr); /* make it white (for next cycle) */
++ p = &curr->gch.next;
++ }
++ else { /* must erase `curr' */
++ lua_assert(isdead(g, curr) || deadmask == bitmask(SFIXEDBIT));
++ *p = curr->gch.next;
++ if (curr == g->rootgc) /* is the first element of the list? */
++ g->rootgc = curr->gch.next; /* adjust first */
++ freeobj(L, curr);
++ }
++ }
++ return p;
++}
++
++
++static void checkSizes (lua_State *L) {
++ global_State *g = G(L);
++ /* check size of string hash */
++ if (g->strt.nuse < cast(lu_int32, g->strt.size/4) &&
++ g->strt.size > MINSTRTABSIZE*2)
++ luaS_resize(L, g->strt.size/2); /* table is too big */
++ /* check size of buffer */
++ if (luaZ_sizebuffer(&g->buff) > LUA_MINBUFFER*2) { /* buffer too big? */
++ size_t newsize = luaZ_sizebuffer(&g->buff) / 2;
++ luaZ_resizebuffer(L, &g->buff, newsize);
++ }
++}
++
++
++static void GCTM (lua_State *L) {
++ global_State *g = G(L);
++ GCObject *o = g->tmudata->gch.next; /* get first element */
++ Udata *udata = rawgco2u(o);
++ const TValue *tm;
++ /* remove udata from `tmudata' */
++ if (o == g->tmudata) /* last element? */
++ g->tmudata = NULL;
++ else
++ g->tmudata->gch.next = udata->uv.next;
++ udata->uv.next = g->mainthread->next; /* return it to `root' list */
++ g->mainthread->next = o;
++ makewhite(g, o);
++ tm = fasttm(L, udata->uv.metatable, TM_GC);
++ if (tm != NULL) {
++ lu_byte oldah = L->allowhook;
++ lu_mem oldt = g->GCthreshold;
++ L->allowhook = 0; /* stop debug hooks during GC tag method */
++ g->GCthreshold = 2*g->totalbytes; /* avoid GC steps */
++ setobj2s(L, L->top, tm);
++ setuvalue(L, L->top+1, udata);
++ L->top += 2;
++ luaD_call(L, L->top - 2, 0);
++ L->allowhook = oldah; /* restore hooks */
++ g->GCthreshold = oldt; /* restore threshold */
++ }
++}
++
++
++/*
++** Call all GC tag methods
++*/
++void luaC_callGCTM (lua_State *L) {
++ while (G(L)->tmudata)
++ GCTM(L);
++}
++
++
++void luaC_freeall (lua_State *L) {
++ global_State *g = G(L);
++ int i;
++ g->currentwhite = WHITEBITS | bitmask(SFIXEDBIT); /* mask to collect all elements */
++ sweepwholelist(L, &g->rootgc);
++ for (i = 0; i < g->strt.size; i++) /* free all string lists */
++ sweepwholelist(L, &g->strt.hash[i]);
++}
++
++
++static void markmt (global_State *g) {
++ int i;
++ for (i=0; i<NUM_TAGS; i++)
++ if (g->mt[i]) markobject(g, g->mt[i]);
++}
++
++
++/* mark root set */
++static void markroot (lua_State *L) {
++ global_State *g = G(L);
++ g->gray = NULL;
++ g->grayagain = NULL;
++ g->weak = NULL;
++ markobject(g, g->mainthread);
++ /* make global table be traversed before main stack */
++ markvalue(g, gt(g->mainthread));
++ markvalue(g, registry(L));
++ markmt(g);
++ g->gcstate = GCSpropagate;
++}
++
++
++static void remarkupvals (global_State *g) {
++ UpVal *uv;
++ for (uv = g->uvhead.u.l.next; uv != &g->uvhead; uv = uv->u.l.next) {
++ lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv);
++ if (isgray(obj2gco(uv)))
++ markvalue(g, uv->v);
++ }
++}
++
++
++static void atomic (lua_State *L) {
++ global_State *g = G(L);
++ size_t udsize; /* total size of userdata to be finalized */
++ /* remark occasional upvalues of (maybe) dead threads */
++ remarkupvals(g);
++ /* traverse objects cautch by write barrier and by 'remarkupvals' */
++ propagateall(g);
++ /* remark weak tables */
++ g->gray = g->weak;
++ g->weak = NULL;
++ lua_assert(!iswhite(obj2gco(g->mainthread)));
++ markobject(g, L); /* mark running thread */
++ markmt(g); /* mark basic metatables (again) */
++ propagateall(g);
++ /* remark gray again */
++ g->gray = g->grayagain;
++ g->grayagain = NULL;
++ propagateall(g);
++ udsize = luaC_separateudata(L, 0); /* separate userdata to be finalized */
++ marktmu(g); /* mark `preserved' userdata */
++ udsize += propagateall(g); /* remark, to propagate `preserveness' */
++ cleartable(g->weak); /* remove collected objects from weak tables */
++ /* flip current white */
++ g->currentwhite = cast_byte(otherwhite(g));
++ g->sweepstrgc = 0;
++ g->sweepgc = &g->rootgc;
++ g->gcstate = GCSsweepstring;
++ g->estimate = g->totalbytes - udsize; /* first estimate */
++}
++
++
++static l_mem singlestep (lua_State *L) {
++ global_State *g = G(L);
++ /*lua_checkmemory(L);*/
++ switch (g->gcstate) {
++ case GCSpause: {
++ markroot(L); /* start a new collection */
++ return 0;
++ }
++ case GCSpropagate: {
++ if (g->gray)
++ return propagatemark(g);
++ else { /* no more `gray' objects */
++ atomic(L); /* finish mark phase */
++ return 0;
++ }
++ }
++ case GCSsweepstring: {
++ lu_mem old = g->totalbytes;
++ sweepwholelist(L, &g->strt.hash[g->sweepstrgc++]);
++ if (g->sweepstrgc >= g->strt.size) /* nothing more to sweep? */
++ g->gcstate = GCSsweep; /* end sweep-string phase */
++ lua_assert(old >= g->totalbytes);
++ g->estimate -= old - g->totalbytes;
++ return GCSWEEPCOST;
++ }
++ case GCSsweep: {
++ lu_mem old = g->totalbytes;
++ g->sweepgc = sweeplist(L, g->sweepgc, GCSWEEPMAX);
++ if (*g->sweepgc == NULL) { /* nothing more to sweep? */
++ checkSizes(L);
++ g->gcstate = GCSfinalize; /* end sweep phase */
++ }
++ lua_assert(old >= g->totalbytes);
++ g->estimate -= old - g->totalbytes;
++ return GCSWEEPMAX*GCSWEEPCOST;
++ }
++ case GCSfinalize: {
++ if (g->tmudata) {
++ GCTM(L);
++ if (g->estimate > GCFINALIZECOST)
++ g->estimate -= GCFINALIZECOST;
++ return GCFINALIZECOST;
++ }
++ else {
++ g->gcstate = GCSpause; /* end collection */
++ g->gcdept = 0;
++ return 0;
++ }
++ }
++ default: lua_assert(0); return 0;
++ }
++}
++
++
++void luaC_step (lua_State *L) {
++ global_State *g = G(L);
++ l_mem lim = (GCSTEPSIZE/100) * g->gcstepmul;
++ if (lim == 0)
++ lim = (MAX_LUMEM-1)/2; /* no limit */
++ g->gcdept += g->totalbytes - g->GCthreshold;
++ do {
++ lim -= singlestep(L);
++ if (g->gcstate == GCSpause)
++ break;
++ } while (lim > 0);
++ if (g->gcstate != GCSpause) {
++ if (g->gcdept < GCSTEPSIZE)
++ g->GCthreshold = g->totalbytes + GCSTEPSIZE; /* - lim/g->gcstepmul;*/
++ else {
++ g->gcdept -= GCSTEPSIZE;
++ g->GCthreshold = g->totalbytes;
++ }
++ }
++ else {
++ lua_assert(g->totalbytes >= g->estimate);
++ setthreshold(g);
++ }
++}
++
++
++void luaC_fullgc (lua_State *L) {
++ global_State *g = G(L);
++ if (g->gcstate <= GCSpropagate) {
++ /* reset sweep marks to sweep all elements (returning them to white) */
++ g->sweepstrgc = 0;
++ g->sweepgc = &g->rootgc;
++ /* reset other collector lists */
++ g->gray = NULL;
++ g->grayagain = NULL;
++ g->weak = NULL;
++ g->gcstate = GCSsweepstring;
++ }
++ lua_assert(g->gcstate != GCSpause && g->gcstate != GCSpropagate);
++ /* finish any pending sweep phase */
++ while (g->gcstate != GCSfinalize) {
++ lua_assert(g->gcstate == GCSsweepstring || g->gcstate == GCSsweep);
++ singlestep(L);
++ }
++ markroot(L);
++ while (g->gcstate != GCSpause) {
++ singlestep(L);
++ }
++ setthreshold(g);
++}
++
++
++void luaC_barrierf (lua_State *L, GCObject *o, GCObject *v) {
++ global_State *g = G(L);
++ lua_assert(isblack(o) && iswhite(v) && !isdead(g, v) && !isdead(g, o));
++ lua_assert(g->gcstate != GCSfinalize && g->gcstate != GCSpause);
++ lua_assert(ttype(&o->gch) != LUA_TTABLE);
++ /* must keep invariant? */
++ if (g->gcstate == GCSpropagate)
++ reallymarkobject(g, v); /* restore invariant */
++ else /* don't mind */
++ makewhite(g, o); /* mark as white just to avoid other barriers */
++}
++
++
++void luaC_barrierback (lua_State *L, Table *t) {
++ global_State *g = G(L);
++ GCObject *o = obj2gco(t);
++ lua_assert(isblack(o) && !isdead(g, o));
++ lua_assert(g->gcstate != GCSfinalize && g->gcstate != GCSpause);
++ black2gray(o); /* make table gray (again) */
++ t->gclist = g->grayagain;
++ g->grayagain = o;
++}
++
++
++void luaC_link (lua_State *L, GCObject *o, lu_byte tt) {
++ global_State *g = G(L);
++ o->gch.next = g->rootgc;
++ g->rootgc = o;
++ o->gch.marked = luaC_white(g);
++ o->gch.tt = tt;
++}
++
++
++void luaC_linkupval (lua_State *L, UpVal *uv) {
++ global_State *g = G(L);
++ GCObject *o = obj2gco(uv);
++ o->gch.next = g->rootgc; /* link upvalue into `rootgc' list */
++ g->rootgc = o;
++ if (isgray(o)) {
++ if (g->gcstate == GCSpropagate) {
++ gray2black(o); /* closed upvalues need barrier */
++ luaC_barrier(L, uv, uv->v);
++ }
++ else { /* sweep phase: sweep it (turning it into white) */
++ makewhite(g, o);
++ lua_assert(g->gcstate != GCSfinalize && g->gcstate != GCSpause);
++ }
++ }
++}
++
+--- /dev/null
++++ b/extensions/LUA/lua/lgc.h
+@@ -0,0 +1,110 @@
++/*
++** $Id: lgc.h,v 2.15.1.1 2007/12/27 13:02:25 roberto Exp $
++** Garbage Collector
++** See Copyright Notice in lua.h
++*/
++
++#ifndef lgc_h
++#define lgc_h
++
++
++#include "lobject.h"
++
++
++/*
++** Possible states of the Garbage Collector
++*/
++#define GCSpause 0
++#define GCSpropagate 1
++#define GCSsweepstring 2
++#define GCSsweep 3
++#define GCSfinalize 4
++
++
++/*
++** some userful bit tricks
++*/
++#define resetbits(x,m) ((x) &= cast(lu_byte, ~(m)))
++#define setbits(x,m) ((x) |= (m))
++#define testbits(x,m) ((x) & (m))
++#define bitmask(b) (1<<(b))
++#define bit2mask(b1,b2) (bitmask(b1) | bitmask(b2))
++#define l_setbit(x,b) setbits(x, bitmask(b))
++#define resetbit(x,b) resetbits(x, bitmask(b))
++#define testbit(x,b) testbits(x, bitmask(b))
++#define set2bits(x,b1,b2) setbits(x, (bit2mask(b1, b2)))
++#define reset2bits(x,b1,b2) resetbits(x, (bit2mask(b1, b2)))
++#define test2bits(x,b1,b2) testbits(x, (bit2mask(b1, b2)))
++
++
++
++/*
++** Layout for bit use in `marked' field:
++** bit 0 - object is white (type 0)
++** bit 1 - object is white (type 1)
++** bit 2 - object is black
++** bit 3 - for userdata: has been finalized
++** bit 3 - for tables: has weak keys
++** bit 4 - for tables: has weak values
++** bit 5 - object is fixed (should not be collected)
++** bit 6 - object is "super" fixed (only the main thread)
++*/
++
++
++#define WHITE0BIT 0
++#define WHITE1BIT 1
++#define BLACKBIT 2
++#define FINALIZEDBIT 3
++#define KEYWEAKBIT 3
++#define VALUEWEAKBIT 4
++#define FIXEDBIT 5
++#define SFIXEDBIT 6
++#define WHITEBITS bit2mask(WHITE0BIT, WHITE1BIT)
++
++
++#define iswhite(x) test2bits((x)->gch.marked, WHITE0BIT, WHITE1BIT)
++#define isblack(x) testbit((x)->gch.marked, BLACKBIT)
++#define isgray(x) (!isblack(x) && !iswhite(x))
++
++#define otherwhite(g) (g->currentwhite ^ WHITEBITS)
++#define isdead(g,v) ((v)->gch.marked & otherwhite(g) & WHITEBITS)
++
++#define changewhite(x) ((x)->gch.marked ^= WHITEBITS)
++#define gray2black(x) l_setbit((x)->gch.marked, BLACKBIT)
++
++#define valiswhite(x) (iscollectable(x) && iswhite(gcvalue(x)))
++
++#define luaC_white(g) cast(lu_byte, (g)->currentwhite & WHITEBITS)
++
++
++#define luaC_checkGC(L) { \
++ condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK - 1)); \
++ if (G(L)->totalbytes >= G(L)->GCthreshold) \
++ luaC_step(L); }
++
++
++#define luaC_barrier(L,p,v) { if (valiswhite(v) && isblack(obj2gco(p))) \
++ luaC_barrierf(L,obj2gco(p),gcvalue(v)); }
++
++#define luaC_barriert(L,t,v) { if (valiswhite(v) && isblack(obj2gco(t))) \
++ luaC_barrierback(L,t); }
++
++#define luaC_objbarrier(L,p,o) \
++ { if (iswhite(obj2gco(o)) && isblack(obj2gco(p))) \
++ luaC_barrierf(L,obj2gco(p),obj2gco(o)); }
++
++#define luaC_objbarriert(L,t,o) \
++ { if (iswhite(obj2gco(o)) && isblack(obj2gco(t))) luaC_barrierback(L,t); }
++
++LUAI_FUNC size_t luaC_separateudata (lua_State *L, int all);
++LUAI_FUNC void luaC_callGCTM (lua_State *L);
++LUAI_FUNC void luaC_freeall (lua_State *L);
++LUAI_FUNC void luaC_step (lua_State *L);
++LUAI_FUNC void luaC_fullgc (lua_State *L);
++LUAI_FUNC void luaC_link (lua_State *L, GCObject *o, lu_byte tt);
++LUAI_FUNC void luaC_linkupval (lua_State *L, UpVal *uv);
++LUAI_FUNC void luaC_barrierf (lua_State *L, GCObject *o, GCObject *v);
++LUAI_FUNC void luaC_barrierback (lua_State *L, Table *t);
++
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/llex.c
+@@ -0,0 +1,460 @@
++/*
++** $Id: llex.c,v 2.20.1.1 2007/12/27 13:02:25 roberto Exp $
++** Lexical Analyzer
++** See Copyright Notice in lua.h
++*/
++
++#include <ctype.h>
++#include <locale.h>
++#include <string.h>
++
++#define llex_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "ldo.h"
++#include "llex.h"
++#include "lobject.h"
++#include "lparser.h"
++#include "lstate.h"
++#include "lstring.h"
++#include "ltable.h"
++#include "lzio.h"
++
++
++
++#define next(ls) (ls->current = zgetc(ls->z))
++
++
++
++
++#define currIsNewline(ls) (ls->current == '\n' || ls->current == '\r')
++
++
++/* ORDER RESERVED */
++const char *const luaX_tokens [] = {
++ "and", "break", "do", "else", "elseif",
++ "end", "false", "for", "function", "if",
++ "in", "local", "nil", "not", "or", "repeat",
++ "return", "then", "true", "until", "while",
++ "..", "...", "==", ">=", "<=", "~=",
++ "<number>", "<name>", "<string>", "<eof>",
++ NULL
++};
++
++
++#define save_and_next(ls) (save(ls, ls->current), next(ls))
++
++
++static void save (LexState *ls, int c) {
++ Mbuffer *b = ls->buff;
++ if (b->n + 1 > b->buffsize) {
++ size_t newsize;
++ if (b->buffsize >= MAX_SIZET/2)
++ luaX_lexerror(ls, "lexical element too long", 0);
++ newsize = b->buffsize * 2;
++ luaZ_resizebuffer(ls->L, b, newsize);
++ }
++ b->buffer[b->n++] = cast(char, c);
++}
++
++
++void luaX_init (lua_State *L) {
++ int i;
++ for (i=0; i<NUM_RESERVED; i++) {
++ TString *ts = luaS_new(L, luaX_tokens[i]);
++ luaS_fix(ts); /* reserved words are never collected */
++ lua_assert(strlen(luaX_tokens[i])+1 <= TOKEN_LEN);
++ ts->tsv.reserved = cast_byte(i+1); /* reserved word */
++ }
++}
++
++
++#define MAXSRC 80
++
++
++const char *luaX_token2str (LexState *ls, int token) {
++ if (token < FIRST_RESERVED) {
++ lua_assert(token == cast(unsigned char, token));
++ return (iscntrl(token)) ? luaO_pushfstring(ls->L, "char(%d)", token) :
++ luaO_pushfstring(ls->L, "%c", token);
++ }
++ else
++ return luaX_tokens[token-FIRST_RESERVED];
++}
++
++
++static const char *txtToken (LexState *ls, int token) {
++ switch (token) {
++ case TK_NAME:
++ case TK_STRING:
++ case TK_NUMBER:
++ save(ls, '\0');
++ return luaZ_buffer(ls->buff);
++ default:
++ return luaX_token2str(ls, token);
++ }
++}
++
++
++void luaX_lexerror (LexState *ls, const char *msg, int token) {
++ char buff[MAXSRC];
++ luaO_chunkid(buff, getstr(ls->source), MAXSRC);
++ msg = luaO_pushfstring(ls->L, "%s:%d: %s", buff, ls->linenumber, msg);
++ if (token)
++ luaO_pushfstring(ls->L, "%s near " LUA_QS, msg, txtToken(ls, token));
++ luaD_throw(ls->L, LUA_ERRSYNTAX);
++}
++
++
++void luaX_syntaxerror (LexState *ls, const char *msg) {
++ luaX_lexerror(ls, msg, ls->t.token);
++}
++
++
++TString *luaX_newstring (LexState *ls, const char *str, size_t l) {
++ lua_State *L = ls->L;
++ TString *ts = luaS_newlstr(L, str, l);
++ TValue *o = luaH_setstr(L, ls->fs->h, ts); /* entry for `str' */
++ if (ttisnil(o))
++ setbvalue(o, 1); /* make sure `str' will not be collected */
++ return ts;
++}
++
++
++static void inclinenumber (LexState *ls) {
++ int old = ls->current;
++ lua_assert(currIsNewline(ls));
++ next(ls); /* skip `\n' or `\r' */
++ if (currIsNewline(ls) && ls->current != old)
++ next(ls); /* skip `\n\r' or `\r\n' */
++ if (++ls->linenumber >= MAX_INT)
++ luaX_syntaxerror(ls, "chunk has too many lines");
++}
++
++
++void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, TString *source) {
++ ls->decpoint = '.';
++ ls->L = L;
++ ls->lookahead.token = TK_EOS; /* no look-ahead token */
++ ls->z = z;
++ ls->fs = NULL;
++ ls->linenumber = 1;
++ ls->lastline = 1;
++ ls->source = source;
++ luaZ_resizebuffer(ls->L, ls->buff, LUA_MINBUFFER); /* initialize buffer */
++ next(ls); /* read first char */
++}
++
++
++
++/*
++** =======================================================
++** LEXICAL ANALYZER
++** =======================================================
++*/
++
++
++
++static int check_next (LexState *ls, const char *set) {
++ if (!strchr(set, ls->current))
++ return 0;
++ save_and_next(ls);
++ return 1;
++}
++
++
++static void buffreplace (LexState *ls, char from, char to) {
++ size_t n = luaZ_bufflen(ls->buff);
++ char *p = luaZ_buffer(ls->buff);
++ while (n--)
++ if (p[n] == from) p[n] = to;
++}
++
++
++static void trydecpoint (LexState *ls, SemInfo *seminfo) {
++ /* format error: try to update decimal point separator */
++ char old = ls->decpoint;
++ struct lconv *cv = localeconv();
++ ls->decpoint = (cv ? cv->decimal_point[0] : '.');
++ buffreplace(ls, old, ls->decpoint); /* try updated decimal separator */
++ if (!luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r)) {
++ /* format error with correct decimal point: no more options */
++ buffreplace(ls, ls->decpoint, '.'); /* undo change (for error message) */
++ luaX_lexerror(ls, "malformed number", TK_NUMBER);
++ }
++}
++
++
++/* LUA_NUMBER */
++static void read_numeral (LexState *ls, SemInfo *seminfo) {
++ lua_assert(isdigit(ls->current));
++ do {
++ save_and_next(ls);
++ } while (isdigit(ls->current) || ls->current == '.');
++ if (check_next(ls, "Ee")) /* `E'? */
++ check_next(ls, "+-"); /* optional exponent sign */
++ while (isalnum(ls->current) || ls->current == '_')
++ save_and_next(ls);
++ save(ls, '\0');
++ buffreplace(ls, '.', ls->decpoint); /* follow locale for decimal point */
++ if (!luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r)) /* format error? */
++ trydecpoint(ls, seminfo); /* try to update decimal point separator */
++}
++
++
++static int skip_sep (LexState *ls) {
++ int count = 0;
++ int s = ls->current;
++ lua_assert(s == '[' || s == ']');
++ save_and_next(ls);
++ while (ls->current == '=') {
++ save_and_next(ls);
++ count++;
++ }
++ return (ls->current == s) ? count : (-count) - 1;
++}
++
++
++static void read_long_string (LexState *ls, SemInfo *seminfo, int sep) {
++ int cont = 0;
++ (void)(cont); /* avoid warnings when `cont' is not used */
++ save_and_next(ls); /* skip 2nd `[' */
++ if (currIsNewline(ls)) /* string starts with a newline? */
++ inclinenumber(ls); /* skip it */
++ for (;;) {
++ switch (ls->current) {
++ case EOZ:
++ luaX_lexerror(ls, (seminfo) ? "unfinished long string" :
++ "unfinished long comment", TK_EOS);
++ break; /* to avoid warnings */
++#if defined(LUA_COMPAT_LSTR)
++ case '[': {
++ if (skip_sep(ls) == sep) {
++ save_and_next(ls); /* skip 2nd `[' */
++ cont++;
++#if LUA_COMPAT_LSTR == 1
++ if (sep == 0)
++ luaX_lexerror(ls, "nesting of [[...]] is deprecated", '[');
++#endif
++ }
++ break;
++ }
++#endif
++ case ']': {
++ if (skip_sep(ls) == sep) {
++ save_and_next(ls); /* skip 2nd `]' */
++#if defined(LUA_COMPAT_LSTR) && LUA_COMPAT_LSTR == 2
++ cont--;
++ if (sep == 0 && cont >= 0) break;
++#endif
++ goto endloop;
++ }
++ break;
++ }
++ case '\n':
++ case '\r': {
++ save(ls, '\n');
++ inclinenumber(ls);
++ if (!seminfo) luaZ_resetbuffer(ls->buff); /* avoid wasting space */
++ break;
++ }
++ default: {
++ if (seminfo) save_and_next(ls);
++ else next(ls);
++ }
++ }
++ } endloop:
++ if (seminfo)
++ seminfo->ts = luaX_newstring(ls, luaZ_buffer(ls->buff) + (2 + sep),
++ luaZ_bufflen(ls->buff) - 2*(2 + sep));
++}
++
++
++static void read_string (LexState *ls, int del, SemInfo *seminfo) {
++ save_and_next(ls);
++ while (ls->current != del) {
++ switch (ls->current) {
++ case EOZ:
++ luaX_lexerror(ls, "unfinished string", TK_EOS);
++ continue; /* to avoid warnings */
++ case '\n':
++ case '\r':
++ luaX_lexerror(ls, "unfinished string", TK_STRING);
++ continue; /* to avoid warnings */
++ case '\\': {
++ int c;
++ next(ls); /* do not save the `\' */
++ switch (ls->current) {
++ case 'a': c = '\a'; break;
++ case 'b': c = '\b'; break;
++ case 'f': c = '\f'; break;
++ case 'n': c = '\n'; break;
++ case 'r': c = '\r'; break;
++ case 't': c = '\t'; break;
++ case 'v': c = '\v'; break;
++ case '\n': /* go through */
++ case '\r': save(ls, '\n'); inclinenumber(ls); continue;
++ case EOZ: continue; /* will raise an error next loop */
++ default: {
++ if (!isdigit(ls->current))
++ save_and_next(ls); /* handles \\, \", \', and \? */
++ else { /* \xxx */
++ int i = 0;
++ c = 0;
++ do {
++ c = 10*c + (ls->current-'0');
++ next(ls);
++ } while (++i<3 && isdigit(ls->current));
++ if (c > UCHAR_MAX)
++ luaX_lexerror(ls, "escape sequence too large", TK_STRING);
++ save(ls, c);
++ }
++ continue;
++ }
++ }
++ save(ls, c);
++ next(ls);
++ continue;
++ }
++ default:
++ save_and_next(ls);
++ }
++ }
++ save_and_next(ls); /* skip delimiter */
++ seminfo->ts = luaX_newstring(ls, luaZ_buffer(ls->buff) + 1,
++ luaZ_bufflen(ls->buff) - 2);
++}
++
++
++static int llex (LexState *ls, SemInfo *seminfo) {
++ luaZ_resetbuffer(ls->buff);
++ for (;;) {
++ switch (ls->current) {
++ case '\n':
++ case '\r': {
++ inclinenumber(ls);
++ continue;
++ }
++ case '-': {
++ next(ls);
++ if (ls->current != '-') return '-';
++ /* else is a comment */
++ next(ls);
++ if (ls->current == '[') {
++ int sep = skip_sep(ls);
++ luaZ_resetbuffer(ls->buff); /* `skip_sep' may dirty the buffer */
++ if (sep >= 0) {
++ read_long_string(ls, NULL, sep); /* long comment */
++ luaZ_resetbuffer(ls->buff);
++ continue;
++ }
++ }
++ /* else short comment */
++ while (!currIsNewline(ls) && ls->current != EOZ)
++ next(ls);
++ continue;
++ }
++ case '[': {
++ int sep = skip_sep(ls);
++ if (sep >= 0) {
++ read_long_string(ls, seminfo, sep);
++ return TK_STRING;
++ }
++ else if (sep == -1) return '[';
++ else luaX_lexerror(ls, "invalid long string delimiter", TK_STRING);
++ }
++ case '=': {
++ next(ls);
++ if (ls->current != '=') return '=';
++ else { next(ls); return TK_EQ; }
++ }
++ case '<': {
++ next(ls);
++ if (ls->current != '=') return '<';
++ else { next(ls); return TK_LE; }
++ }
++ case '>': {
++ next(ls);
++ if (ls->current != '=') return '>';
++ else { next(ls); return TK_GE; }
++ }
++ case '~': {
++ next(ls);
++ if (ls->current != '=') return '~';
++ else { next(ls); return TK_NE; }
++ }
++ case '"':
++ case '\'': {
++ read_string(ls, ls->current, seminfo);
++ return TK_STRING;
++ }
++ case '.': {
++ save_and_next(ls);
++ if (check_next(ls, ".")) {
++ if (check_next(ls, "."))
++ return TK_DOTS; /* ... */
++ else return TK_CONCAT; /* .. */
++ }
++ else if (!isdigit(ls->current)) return '.';
++ else {
++ read_numeral(ls, seminfo);
++ return TK_NUMBER;
++ }
++ }
++ case EOZ: {
++ return TK_EOS;
++ }
++ default: {
++ if (isspace(ls->current)) {
++ lua_assert(!currIsNewline(ls));
++ next(ls);
++ continue;
++ }
++ else if (isdigit(ls->current)) {
++ read_numeral(ls, seminfo);
++ return TK_NUMBER;
++ }
++ else if (isalpha(ls->current) || ls->current == '_') {
++ /* identifier or reserved word */
++ TString *ts;
++ do {
++ save_and_next(ls);
++ } while (isalnum(ls->current) || ls->current == '_');
++ ts = luaX_newstring(ls, luaZ_buffer(ls->buff),
++ luaZ_bufflen(ls->buff));
++ if (ts->tsv.reserved > 0) /* reserved word? */
++ return ts->tsv.reserved - 1 + FIRST_RESERVED;
++ else {
++ seminfo->ts = ts;
++ return TK_NAME;
++ }
++ }
++ else {
++ int c = ls->current;
++ next(ls);
++ return c; /* single-char tokens (+ - / ...) */
++ }
++ }
++ }
++ }
++}
++
++
++void luaX_next (LexState *ls) {
++ ls->lastline = ls->linenumber;
++ if (ls->lookahead.token != TK_EOS) { /* is there a look-ahead token? */
++ ls->t = ls->lookahead; /* use this one */
++ ls->lookahead.token = TK_EOS; /* and discharge it */
++ }
++ else
++ ls->t.token = llex(ls, &ls->t.seminfo); /* read next token */
++}
++
++
++void luaX_lookahead (LexState *ls) {
++ lua_assert(ls->lookahead.token == TK_EOS);
++ ls->lookahead.token = llex(ls, &ls->lookahead.seminfo);
++}
++
+--- /dev/null
++++ b/extensions/LUA/lua/llex.h
+@@ -0,0 +1,81 @@
++/*
++** $Id: llex.h,v 1.58.1.1 2007/12/27 13:02:25 roberto Exp $
++** Lexical Analyzer
++** See Copyright Notice in lua.h
++*/
++
++#ifndef llex_h
++#define llex_h
++
++#include "lobject.h"
++#include "lzio.h"
++
++
++#define FIRST_RESERVED 257
++
++/* maximum length of a reserved word */
++#define TOKEN_LEN (sizeof("function")/sizeof(char))
++
++
++/*
++* WARNING: if you change the order of this enumeration,
++* grep "ORDER RESERVED"
++*/
++enum RESERVED {
++ /* terminal symbols denoted by reserved words */
++ TK_AND = FIRST_RESERVED, TK_BREAK,
++ TK_DO, TK_ELSE, TK_ELSEIF, TK_END, TK_FALSE, TK_FOR, TK_FUNCTION,
++ TK_IF, TK_IN, TK_LOCAL, TK_NIL, TK_NOT, TK_OR, TK_REPEAT,
++ TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE,
++ /* other terminal symbols */
++ TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, TK_NUMBER,
++ TK_NAME, TK_STRING, TK_EOS
++};
++
++/* number of reserved words */
++#define NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1))
++
++
++/* array with token `names' */
++LUAI_DATA const char *const luaX_tokens [];
++
++
++typedef union {
++ lua_Number r;
++ TString *ts;
++} SemInfo; /* semantics information */
++
++
++typedef struct Token {
++ int token;
++ SemInfo seminfo;
++} Token;
++
++
++typedef struct LexState {
++ int current; /* current character (charint) */
++ int linenumber; /* input line counter */
++ int lastline; /* line of last token `consumed' */
++ Token t; /* current token */
++ Token lookahead; /* look ahead token */
++ struct FuncState *fs; /* `FuncState' is private to the parser */
++ struct lua_State *L;
++ ZIO *z; /* input stream */
++ Mbuffer *buff; /* buffer for tokens */
++ TString *source; /* current source name */
++ char decpoint; /* locale decimal point */
++} LexState;
++
++
++LUAI_FUNC void luaX_init (lua_State *L);
++LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z,
++ TString *source);
++LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l);
++LUAI_FUNC void luaX_next (LexState *ls);
++LUAI_FUNC void luaX_lookahead (LexState *ls);
++LUAI_FUNC void luaX_lexerror (LexState *ls, const char *msg, int token);
++LUAI_FUNC void luaX_syntaxerror (LexState *ls, const char *s);
++LUAI_FUNC const char *luaX_token2str (LexState *ls, int token);
++
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/llimits.h
+@@ -0,0 +1,125 @@
++/*
++** $Id: llimits.h,v 1.69.1.1 2007/12/27 13:02:25 roberto Exp $
++** Limits, basic types, and some other `installation-dependent' definitions
++** See Copyright Notice in lua.h
++*/
++
++#ifndef llimits_h
++#define llimits_h
++
++#include <stddef.h>
++#include <limits.h>
++
++#include "lua.h"
++
++typedef LUAI_UINT32 lu_int32;
++
++typedef LUAI_UMEM lu_mem;
++
++typedef LUAI_MEM l_mem;
++
++
++
++/* chars used as small naturals (so that `char' is reserved for characters) */
++typedef unsigned char lu_byte;
++
++
++#define MAX_SIZET ((size_t)(~(size_t)0)-2)
++
++#define MAX_LUMEM ((lu_mem)(~(lu_mem)0)-2)
++
++
++#define MAX_INT (LUA_INT_MAX-2) /* maximum value of an int (-2 for safety) */
++
++/*
++** conversion of pointer to integer
++** this is for hashing only; there is no problem if the integer
++** cannot hold the whole pointer value
++*/
++#define IntPoint(p) ((unsigned int)(lu_mem)(p))
++
++
++
++/* type to ensure maximum alignment */
++typedef LUAI_USER_ALIGNMENT_T L_Umaxalign;
++
++
++/* result of a `usual argument conversion' over lua_Number */
++typedef LUAI_UACNUMBER l_uacNumber;
++
++
++/* internal assertions for in-house debugging */
++#ifdef lua_assert
++
++#define check_exp(c,e) (lua_assert(c), (e))
++#define api_check(l,e) lua_assert(e)
++
++#else
++
++#define lua_assert(c) ((void)0)
++#define check_exp(c,e) (e)
++#define api_check luai_apicheck
++
++#endif
++
++
++#ifndef UNUSED
++#define UNUSED(x) ((void)(x)) /* to avoid warnings */
++#endif
++
++
++#ifndef cast
++#define cast(t, exp) ((t)(exp))
++#endif
++
++#define cast_byte(i) cast(lu_byte, (i))
++#define cast_num(i) cast(lua_Number, (i))
++#define cast_int(i) cast(int, (i))
++
++
++
++/*
++** type for virtual-machine instructions
++** must be an unsigned with (at least) 4 bytes (see details in lopcodes.h)
++*/
++typedef lu_int32 Instruction;
++
++
++
++/* maximum stack for a Lua function */
++#define MAXSTACK 250
++
++
++
++/* minimum size for the string table (must be power of 2) */
++#ifndef MINSTRTABSIZE
++#define MINSTRTABSIZE 32
++#endif
++
++
++/* minimum size for string buffer */
++#ifndef LUA_MINBUFFER
++#define LUA_MINBUFFER 32
++#endif
++
++
++#ifndef lua_lock
++#define lua_lock(L) ((void) 0)
++#define lua_unlock(L) ((void) 0)
++#endif
++
++#ifndef luai_threadyield
++#define luai_threadyield(L) {lua_unlock(L); lua_lock(L);}
++#endif
++
++
++/*
++** macro to control inclusion of some hard tests on stack reallocation
++*/
++#ifndef HARDSTACKTESTS
++#define condhardstacktests(x) ((void)0)
++#else
++#define condhardstacktests(x) x
++#endif
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/lmem.c
+@@ -0,0 +1,86 @@
++/*
++** $Id: lmem.c,v 1.70.1.1 2007/12/27 13:02:25 roberto Exp $
++** Interface to Memory Manager
++** See Copyright Notice in lua.h
++*/
++
++
++#include <stddef.h>
++
++#define lmem_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "ldebug.h"
++#include "ldo.h"
++#include "lmem.h"
++#include "lobject.h"
++#include "lstate.h"
++
++
++
++/*
++** About the realloc function:
++** void * frealloc (void *ud, void *ptr, size_t osize, size_t nsize);
++** (`osize' is the old size, `nsize' is the new size)
++**
++** Lua ensures that (ptr == NULL) iff (osize == 0).
++**
++** * frealloc(ud, NULL, 0, x) creates a new block of size `x'
++**
++** * frealloc(ud, p, x, 0) frees the block `p'
++** (in this specific case, frealloc must return NULL).
++** particularly, frealloc(ud, NULL, 0, 0) does nothing
++** (which is equivalent to free(NULL) in ANSI C)
++**
++** frealloc returns NULL if it cannot create or reallocate the area
++** (any reallocation to an equal or smaller size cannot fail!)
++*/
++
++
++
++#define MINSIZEARRAY 4
++
++
++void *luaM_growaux_ (lua_State *L, void *block, int *size, size_t size_elems,
++ int limit, const char *errormsg) {
++ void *newblock;
++ int newsize;
++ if (*size >= limit/2) { /* cannot double it? */
++ if (*size >= limit) /* cannot grow even a little? */
++ luaG_runerror(L, errormsg);
++ newsize = limit; /* still have at least one free place */
++ }
++ else {
++ newsize = (*size)*2;
++ if (newsize < MINSIZEARRAY)
++ newsize = MINSIZEARRAY; /* minimum size */
++ }
++ newblock = luaM_reallocv(L, block, *size, newsize, size_elems);
++ *size = newsize; /* update only when everything else is OK */
++ return newblock;
++}
++
++
++void *luaM_toobig (lua_State *L) {
++ luaG_runerror(L, "memory allocation error: block too big");
++ return NULL; /* to avoid warnings */
++}
++
++
++
++/*
++** generic allocation routine.
++*/
++void *luaM_realloc_ (lua_State *L, void *block, size_t osize, size_t nsize) {
++ global_State *g = G(L);
++ lua_assert((osize == 0) == (block == NULL));
++ block = (*g->frealloc)(g->ud, block, osize, nsize);
++ if (block == NULL && nsize > 0)
++ luaD_throw(L, LUA_ERRMEM);
++ lua_assert((nsize == 0) == (block == NULL));
++ g->totalbytes = (g->totalbytes - osize) + nsize;
++ return block;
++}
++
+--- /dev/null
++++ b/extensions/LUA/lua/lmem.h
+@@ -0,0 +1,49 @@
++/*
++** $Id: lmem.h,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $
++** Interface to Memory Manager
++** See Copyright Notice in lua.h
++*/
++
++#ifndef lmem_h
++#define lmem_h
++
++
++#include <stddef.h>
++
++#include "llimits.h"
++#include "lua.h"
++
++#define MEMERRMSG "not enough memory"
++
++
++#define luaM_reallocv(L,b,on,n,e) \
++ ((cast(size_t, (n)+1) <= MAX_SIZET/(e)) ? /* +1 to avoid warnings */ \
++ luaM_realloc_(L, (b), (on)*(e), (n)*(e)) : \
++ luaM_toobig(L))
++
++#define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0)
++#define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0)
++#define luaM_freearray(L, b, n, t) luaM_reallocv(L, (b), n, 0, sizeof(t))
++
++#define luaM_malloc(L,t) luaM_realloc_(L, NULL, 0, (t))
++#define luaM_new(L,t) cast(t *, luaM_malloc(L, sizeof(t)))
++#define luaM_newvector(L,n,t) \
++ cast(t *, luaM_reallocv(L, NULL, 0, n, sizeof(t)))
++
++#define luaM_growvector(L,v,nelems,size,t,limit,e) \
++ if ((nelems)+1 > (size)) \
++ ((v)=cast(t *, luaM_growaux_(L,v,&(size),sizeof(t),limit,e)))
++
++#define luaM_reallocvector(L, v,oldn,n,t) \
++ ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t))))
++
++
++LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize,
++ size_t size);
++LUAI_FUNC void *luaM_toobig (lua_State *L);
++LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size,
++ size_t size_elem, int limit,
++ const char *errormsg);
++
++#endif
++
+--- /dev/null
++++ b/extensions/LUA/lua/lobject.c
+@@ -0,0 +1,215 @@
++/*
++** $Id: lobject.c,v 2.22.1.1 2007/12/27 13:02:25 roberto Exp $
++** Some generic functions over Lua objects
++** See Copyright Notice in lua.h
++*/
++
++#include <stdarg.h>
++
++#include <ctype.h>
++#include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
++
++#define lobject_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "ldo.h"
++#include "lmem.h"
++#include "lobject.h"
++#include "lstate.h"
++#include "lstring.h"
++#include "lvm.h"
++
++
++
++const TValue luaO_nilobject_ = {{NULL}, LUA_TNIL};
++
++
++/*
++** converts an integer to a "floating point byte", represented as
++** (eeeeexxx), where the real value is (1xxx) * 2^(eeeee - 1) if
++** eeeee != 0 and (xxx) otherwise.
++*/
++int luaO_int2fb (unsigned int x) {
++ int e = 0; /* expoent */
++ while (x >= 16) {
++ x = (x+1) >> 1;
++ e++;
++ }
++ if (x < 8) return x;
++ else return ((e+1) << 3) | (cast_int(x) - 8);
++}
++
++
++/* converts back */
++int luaO_fb2int (int x) {
++ int e = (x >> 3) & 31;
++ if (e == 0) return x;
++ else return ((x & 7)+8) << (e - 1);
++}
++
++
++int luaO_log2 (unsigned int x) {
++ static const lu_byte log_2[256] = {
++ 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
++ 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
++ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
++ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
++ 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
++ 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
++ 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
++ 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8
++ };
++ int l = -1;
++ while (x >= 256) { l += 8; x >>= 8; }
++ return l + log_2[x];
++
++}
++
++
++int luaO_rawequalObj (const TValue *t1, const TValue *t2) {
++ if (ttype(t1) != ttype(t2)) return 0;
++ else switch (ttype(t1)) {
++ case LUA_TNIL:
++ return 1;
++ case LUA_TNUMBER:
++ return luai_numeq(nvalue(t1), nvalue(t2));
++ case LUA_TBOOLEAN:
++ return bvalue(t1) == bvalue(t2); /* boolean true must be 1 !! */
++ case LUA_TLIGHTUSERDATA:
++ return pvalue(t1) == pvalue(t2);
++ default:
++ lua_assert(iscollectable(t1));
++ return gcvalue(t1) == gcvalue(t2);
++ }
++}
++
++
++int luaO_str2d (const char *s, lua_Number *result) {
++ char *endptr;
++ *result = lua_str2number(s, &endptr);
++ if (endptr == s) return 0; /* conversion failed */
++ if (*endptr == 'x' || *endptr == 'X') /* maybe an hexadecimal constant? */
++ *result = cast_num(strtoul(s, &endptr, 16));
++ if (*endptr == '\0') return 1; /* most common case */
++ while (isspace(cast(unsigned char, *endptr))) endptr++;
++ if (*endptr != '\0') return 0; /* invalid trailing characters? */
++ return 1;
++}
++
++
++
++static void pushstr (lua_State *L, const char *str) {
++ setsvalue2s(L, L->top, luaS_new(L, str));
++ incr_top(L);
++}
++
++
++/* this function handles only `%d', `%c', %f, %p, and `%s' formats */
++const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) {
++ int n = 1;
++ pushstr(L, "");
++ for (;;) {
++ const char *e = strchr(fmt, '%');
++ if (e == NULL) break;
++ setsvalue2s(L, L->top, luaS_newlstr(L, fmt, e-fmt));
++ incr_top(L);
++ switch (*(e+1)) {
++ case 's': {
++ const char *s = va_arg(argp, char *);
++ if (s == NULL) s = "(null)";
++ pushstr(L, s);
++ break;
++ }
++ case 'c': {
++ char buff[2];
++ buff[0] = cast(char, va_arg(argp, int));
++ buff[1] = '\0';
++ pushstr(L, buff);
++ break;
++ }
++ case 'd': {
++ setnvalue(L->top, cast_num(va_arg(argp, int)));
++ incr_top(L);
++ break;
++ }
++ case 'f': {
++ setnvalue(L->top, cast_num(va_arg(argp, l_uacNumber)));
++ incr_top(L);
++ break;
++ }
++ case 'p': {
++ char buff[4*sizeof(void *) + 8]; /* should be enough space for a `%p' */
++ sprintf(buff, "%p", va_arg(argp, void *));
++ pushstr(L, buff);
++ break;
++ }
++ case '%': {
++ pushstr(L, "%");
++ break;
++ }
++ default: {
++ char buff[3];
++ buff[0] = '%';
++ buff[1] = *(e+1);
++ buff[2] = '\0';
++ pushstr(L, buff);
++ break;
++ }
++ }
++ n += 2;
++ fmt = e+2;
++ }
++ pushstr(L, fmt);
++ luaV_concat(L, n+1, cast_int(L->top - L->base) - 1);
++ L->top -= n;
++ return svalue(L->top - 1);
++}
++
++
++const char *luaO_pushfstring (lua_State *L, const char *fmt, ...) {
++ const char *msg;
++ va_list argp;
++ va_start(argp, fmt);
++ msg = luaO_pushvfstring(L, fmt, argp);
++ va_end(argp);
++ return msg;
++}
++
++
++void luaO_chunkid (char *out, const char *source, size_t bufflen) {
++ if (*source == '=') {
++ strncpy(out, source+1, bufflen); /* remove first char */
++ out[bufflen-1] = '\0'; /* ensures null termination */
++ }
++ else { /* out = "source", or "...source" */
++ if (*source == '@') {
++ size_t l;
++ source++; /* skip the `@' */
++ bufflen -= sizeof(" '...' ");
++ l = strlen(source);
++ strcpy(out, "");
++ if (l > bufflen) {
++ source += (l-bufflen); /* get last part of file name */
++ strcat(out, "...");
++ }
++ strcat(out, source);
++ }
++ else { /* out = [string "string"] */
++ size_t len = strcspn(source, "\n\r"); /* stop at first newline */
++ bufflen -= sizeof(" [string \"...\"] ");
++ if (len > bufflen) len = bufflen;
++ strcpy(out, "[string \"");
++ if (source[len] != '\0') { /* must truncate? */
++ strncat(out, source, len);
++ strcat(out, "...");
++ }
++ else
++ strcat(out, source);
++ strcat(out, "\"]");
++ }
++ }
++}
+--- /dev/null
++++ b/extensions/LUA/lua/lobject.h
+@@ -0,0 +1,381 @@
++/*
++** $Id: lobject.h,v 2.20.1.2 2008/08/06 13:29:48 roberto Exp $
++** Type definitions for Lua objects
++** See Copyright Notice in lua.h
++*/
++
++
++#ifndef lobject_h
++#define lobject_h
++
++
++#include <stdarg.h>
++
++
++#include "llimits.h"
++#include "lua.h"
++
++
++/* tags for values visible from Lua */
++#define LAST_TAG LUA_TTHREAD
++
++#define NUM_TAGS (LAST_TAG+1)
++
++
++/*
++** Extra tags for non-values
++*/
++#define LUA_TPROTO (LAST_TAG+1)
++#define LUA_TUPVAL (LAST_TAG+2)
++#define LUA_TDEADKEY (LAST_TAG+3)
++
++
++/*
++** Union of all collectable objects
++*/
++typedef union GCObject GCObject;
++
++
++/*
++** Common Header for all collectable objects (in macro form, to be
++** included in other objects)
++*/
++#define CommonHeader GCObject *next; lu_byte tt; lu_byte marked
++
++
++/*
++** Common header in struct form
++*/
++typedef struct GCheader {
++ CommonHeader;
++} GCheader;
++
++
++
++
++/*
++** Union of all Lua values
++*/
++typedef union {
++ GCObject *gc;
++ void *p;
++ lua_Number n;
++ int b;
++} Value;
++
++
++/*
++** Tagged Values
++*/
++
++#define TValuefields Value value; int tt
++
++typedef struct lua_TValue {
++ TValuefields;
++} TValue;
++
++
++/* Macros to test type */
++#define ttisnil(o) (ttype(o) == LUA_TNIL)
++#define ttisnumber(o) (ttype(o) == LUA_TNUMBER)
++#define ttisstring(o) (ttype(o) == LUA_TSTRING)
++#define ttistable(o) (ttype(o) == LUA_TTABLE)
++#define ttisfunction(o) (ttype(o) == LUA_TFUNCTION)
++#define ttisboolean(o) (ttype(o) == LUA_TBOOLEAN)
++#define ttisuserdata(o) (ttype(o) == LUA_TUSERDATA)
++#define ttisthread(o) (ttype(o) == LUA_TTHREAD)
++#define ttislightuserdata(o) (ttype(o) == LUA_TLIGHTUSERDATA)
++
++/* Macros to access values */
++#define ttype(o) ((o)->tt)
++#define gcvalue(o) check_exp(iscollectable(o), (o)->value.gc)
++#define pvalue(o) check_exp(ttislightuserdata(o), (o)->value.p)
++#define nvalue(o) check_exp(ttisnumber(o), (o)->value.n)
++#define rawtsvalue(o) check_exp(ttisstring(o), &(o)->value.gc->ts)
++#define tsvalue(o) (&rawtsvalue(o)->tsv)
++#define rawuvalue(o) check_exp(ttisuserdata(o), &(o)->value.gc->u)
++#define uvalue(o) (&rawuvalue(o)->uv)
++#define clvalue(o) check_exp(ttisfunction(o), &(o)->value.gc->cl)
++#define hvalue(o) check_exp(ttistable(o), &(o)->value.gc->h)
++#define bvalue(o) check_exp(ttisboolean(o), (o)->value.b)
++#define thvalue(o) check_exp(ttisthread(o), &(o)->value.gc->th)
++
++#define l_isfalse(o) (ttisnil(o) || (ttisboolean(o) && bvalue(o) == 0))
++
++/*
++** for internal debug only
++*/
++#define checkconsistency(obj) \
++ lua_assert(!iscollectable(obj) || (ttype(obj) == (obj)->value.gc->gch.tt))
++
++#define checkliveness(g,obj) \
++ lua_assert(!iscollectable(obj) || \
++ ((ttype(obj) == (obj)->value.gc->gch.tt) && !isdead(g, (obj)->value.gc)))
++
++
++/* Macros to set values */
++#define setnilvalue(obj) ((obj)->tt=LUA_TNIL)
++
++#define setnvalue(obj,x) \
++ { TValue *i_o=(obj); i_o->value.n=(x); i_o->tt=LUA_TNUMBER; }
++
++#define setpvalue(obj,x) \
++ { TValue *i_o=(obj); i_o->value.p=(x); i_o->tt=LUA_TLIGHTUSERDATA; }
++
++#define setbvalue(obj,x) \
++ { TValue *i_o=(obj); i_o->value.b=(x); i_o->tt=LUA_TBOOLEAN; }
++
++#define setsvalue(L,obj,x) \
++ { TValue *i_o=(obj); \
++ i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TSTRING; \
++ checkliveness(G(L),i_o); }
++
++#define setuvalue(L,obj,x) \
++ { TValue *i_o=(obj); \
++ i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TUSERDATA; \
++ checkliveness(G(L),i_o); }
++
++#define setthvalue(L,obj,x) \
++ { TValue *i_o=(obj); \
++ i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TTHREAD; \
++ checkliveness(G(L),i_o); }
++
++#define setclvalue(L,obj,x) \
++ { TValue *i_o=(obj); \
++ i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TFUNCTION; \
++ checkliveness(G(L),i_o); }
++
++#define sethvalue(L,obj,x) \
++ { TValue *i_o=(obj); \
++ i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TTABLE; \
++ checkliveness(G(L),i_o); }
++
++#define setptvalue(L,obj,x) \
++ { TValue *i_o=(obj); \
++ i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TPROTO; \
++ checkliveness(G(L),i_o); }
++
++
++
++
++#define setobj(L,obj1,obj2) \
++ { const TValue *o2=(obj2); TValue *o1=(obj1); \
++ o1->value = o2->value; o1->tt=o2->tt; \
++ checkliveness(G(L),o1); }
++
++
++/*
++** different types of sets, according to destination
++*/
++
++/* from stack to (same) stack */
++#define setobjs2s setobj
++/* to stack (not from same stack) */
++#define setobj2s setobj
++#define setsvalue2s setsvalue
++#define sethvalue2s sethvalue
++#define setptvalue2s setptvalue
++/* from table to same table */
++#define setobjt2t setobj
++/* to table */
++#define setobj2t setobj
++/* to new object */
++#define setobj2n setobj
++#define setsvalue2n setsvalue
++
++#define setttype(obj, tt) (ttype(obj) = (tt))
++
++
++#define iscollectable(o) (ttype(o) >= LUA_TSTRING)
++
++
++
++typedef TValue *StkId; /* index to stack elements */
++
++
++/*
++** String headers for string table
++*/
++typedef union TString {
++ L_Umaxalign dummy; /* ensures maximum alignment for strings */
++ struct {
++ CommonHeader;
++ lu_byte reserved;
++ unsigned int hash;
++ size_t len;
++ } tsv;
++} TString;
++
++
++#define getstr(ts) cast(const char *, (ts) + 1)
++#define svalue(o) getstr(rawtsvalue(o))
++
++
++
++typedef union Udata {
++ L_Umaxalign dummy; /* ensures maximum alignment for `local' udata */
++ struct {
++ CommonHeader;
++ struct Table *metatable;
++ struct Table *env;
++ size_t len;
++ } uv;
++} Udata;
++
++
++
++
++/*
++** Function Prototypes
++*/
++typedef struct Proto {
++ CommonHeader;
++ TValue *k; /* constants used by the function */
++ Instruction *code;
++ struct Proto **p; /* functions defined inside the function */
++ int *lineinfo; /* map from opcodes to source lines */
++ struct LocVar *locvars; /* information about local variables */
++ TString **upvalues; /* upvalue names */
++ TString *source;
++ int sizeupvalues;
++ int sizek; /* size of `k' */
++ int sizecode;
++ int sizelineinfo;
++ int sizep; /* size of `p' */
++ int sizelocvars;
++ int linedefined;
++ int lastlinedefined;
++ GCObject *gclist;
++ lu_byte nups; /* number of upvalues */
++ lu_byte numparams;
++ lu_byte is_vararg;
++ lu_byte maxstacksize;
++} Proto;
++
++
++/* masks for new-style vararg */
++#define VARARG_HASARG 1
++#define VARARG_ISVARARG 2
++#define VARARG_NEEDSARG 4
++
++
++typedef struct LocVar {
++ TString *varname;
++ int startpc; /* first point where variable is active */
++ int endpc; /* first point where variable is dead */
++} LocVar;
++
++
++
++/*
++** Upvalues
++*/
++
++typedef struct UpVal {
++ CommonHeader;
++ TValue *v; /* points to stack or to its own value */
++ union {
++ TValue value; /* the value (when closed) */
++ struct { /* double linked list (when open) */
++ struct UpVal *prev;
++ struct UpVal *next;
++ } l;
++ } u;
++} UpVal;
++
++
++/*
++** Closures
++*/
++
++#define ClosureHeader \
++ CommonHeader; lu_byte isC; lu_byte nupvalues; GCObject *gclist; \
++ struct Table *env
++
++typedef struct CClosure {
++ ClosureHeader;
++ lua_CFunction f;
++ TValue upvalue[1];
++} CClosure;
++
++
++typedef struct LClosure {
++ ClosureHeader;
++ struct Proto *p;
++ UpVal *upvals[1];
++} LClosure;
++
++
++typedef union Closure {
++ CClosure c;
++ LClosure l;
++} Closure;
++
++
++#define iscfunction(o) (ttype(o) == LUA_TFUNCTION && clvalue(o)->c.isC)
++#define isLfunction(o) (ttype(o) == LUA_TFUNCTION && !clvalue(o)->c.isC)
++
++
++/*
++** Tables
++*/
++
++typedef union TKey {
++ struct {
++ TValuefields;
++ struct Node *next; /* for chaining */
++ } nk;
++ TValue tvk;
++} TKey;
++
++
++typedef struct Node {
++ TValue i_val;
++ TKey i_key;
++} Node;
++
++
++typedef struct Table {
++ CommonHeader;
++ lu_byte flags; /* 1<<p means tagmethod(p) is not present */
++ lu_byte lsizenode; /* log2 of size of `node' array */
++ struct Table *metatable;
++ TValue *array; /* array part */
++ Node *node;
++ Node *lastfree; /* any free position is before this position */
++ GCObject *gclist;
++ int sizearray; /* size of `array' array */
++} Table;
++
++
++
++/*
++** `module' operation for hashing (size is always a power of 2)
++*/
++#define lmod(s,size) \
++ (check_exp((size&(size-1))==0, (cast(int, (s) & ((size)-1)))))
++
++
++#define twoto(x) (1<<(x))
++#define sizenode(t) (twoto((t)->lsizenode))
++
++
++#define luaO_nilobject (&luaO_nilobject_)
++
++LUAI_DATA const TValue luaO_nilobject_;
++
++#define ceillog2(x) (luaO_log2((x)-1) + 1)
++
++LUAI_FUNC int luaO_log2 (unsigned int x);
++LUAI_FUNC int luaO_int2fb (unsigned int x);
++LUAI_FUNC int luaO_fb2int (int x);
++LUAI_FUNC int luaO_rawequalObj (const TValue *t1, const TValue *t2);
++LUAI_FUNC int luaO_str2d (const char *s, lua_Number *result);
++LUAI_FUNC const char *luaO_pushvfstring (lua_State *L, const char *fmt,
++ va_list argp);
++LUAI_FUNC const char *luaO_pushfstring (lua_State *L, const char *fmt, ...);
++LUAI_FUNC void luaO_chunkid (char *out, const char *source, size_t len);
++
++
++#endif
++
+--- /dev/null
++++ b/extensions/LUA/lua/lopcodes.c
+@@ -0,0 +1,102 @@
++/*
++** $Id: lopcodes.c,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $
++** See Copyright Notice in lua.h
++*/
++
++
++#define lopcodes_c
++#define LUA_CORE
++
++
++#include "lopcodes.h"
++
++
++/* ORDER OP */
++
++const char *const luaP_opnames[NUM_OPCODES+1] = {
++ "MOVE",
++ "LOADK",
++ "LOADBOOL",
++ "LOADNIL",
++ "GETUPVAL",
++ "GETGLOBAL",
++ "GETTABLE",
++ "SETGLOBAL",
++ "SETUPVAL",
++ "SETTABLE",
++ "NEWTABLE",
++ "SELF",
++ "ADD",
++ "SUB",
++ "MUL",
++ "DIV",
++ "MOD",
++ "POW",
++ "UNM",
++ "NOT",
++ "LEN",
++ "CONCAT",
++ "JMP",
++ "EQ",
++ "LT",
++ "LE",
++ "TEST",
++ "TESTSET",
++ "CALL",
++ "TAILCALL",
++ "RETURN",
++ "FORLOOP",
++ "FORPREP",
++ "TFORLOOP",
++ "SETLIST",
++ "CLOSE",
++ "CLOSURE",
++ "VARARG",
++ NULL
++};
++
++
++#define opmode(t,a,b,c,m) (((t)<<7) | ((a)<<6) | ((b)<<4) | ((c)<<2) | (m))
++
++const lu_byte luaP_opmodes[NUM_OPCODES] = {
++/* T A B C mode opcode */
++ opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_MOVE */
++ ,opmode(0, 1, OpArgK, OpArgN, iABx) /* OP_LOADK */
++ ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_LOADBOOL */
++ ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_LOADNIL */
++ ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_GETUPVAL */
++ ,opmode(0, 1, OpArgK, OpArgN, iABx) /* OP_GETGLOBAL */
++ ,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_GETTABLE */
++ ,opmode(0, 0, OpArgK, OpArgN, iABx) /* OP_SETGLOBAL */
++ ,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_SETUPVAL */
++ ,opmode(0, 0, OpArgK, OpArgK, iABC) /* OP_SETTABLE */
++ ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_NEWTABLE */
++ ,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_SELF */
++ ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_ADD */
++ ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_SUB */
++ ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MUL */
++ ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_DIV */
++ ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MOD */
++ ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_POW */
++ ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_UNM */
++ ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_NOT */
++ ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_LEN */
++ ,opmode(0, 1, OpArgR, OpArgR, iABC) /* OP_CONCAT */
++ ,opmode(0, 0, OpArgR, OpArgN, iAsBx) /* OP_JMP */
++ ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_EQ */
++ ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LT */
++ ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LE */
++ ,opmode(1, 1, OpArgR, OpArgU, iABC) /* OP_TEST */
++ ,opmode(1, 1, OpArgR, OpArgU, iABC) /* OP_TESTSET */
++ ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_CALL */
++ ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_TAILCALL */
++ ,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_RETURN */
++ ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORLOOP */
++ ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORPREP */
++ ,opmode(1, 0, OpArgN, OpArgU, iABC) /* OP_TFORLOOP */
++ ,opmode(0, 0, OpArgU, OpArgU, iABC) /* OP_SETLIST */
++ ,opmode(0, 0, OpArgN, OpArgN, iABC) /* OP_CLOSE */
++ ,opmode(0, 1, OpArgU, OpArgN, iABx) /* OP_CLOSURE */
++ ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_VARARG */
++};
++
+--- /dev/null
++++ b/extensions/LUA/lua/lopcodes.h
+@@ -0,0 +1,268 @@
++/*
++** $Id: lopcodes.h,v 1.125.1.1 2007/12/27 13:02:25 roberto Exp $
++** Opcodes for Lua virtual machine
++** See Copyright Notice in lua.h
++*/
++
++#ifndef lopcodes_h
++#define lopcodes_h
++
++#include "llimits.h"
++
++
++/*===========================================================================
++ We assume that instructions are unsigned numbers.
++ All instructions have an opcode in the first 6 bits.
++ Instructions can have the following fields:
++ `A' : 8 bits
++ `B' : 9 bits
++ `C' : 9 bits
++ `Bx' : 18 bits (`B' and `C' together)
++ `sBx' : signed Bx
++
++ A signed argument is represented in excess K; that is, the number
++ value is the unsigned value minus K. K is exactly the maximum value
++ for that argument (so that -max is represented by 0, and +max is
++ represented by 2*max), which is half the maximum for the corresponding
++ unsigned argument.
++===========================================================================*/
++
++
++enum OpMode {iABC, iABx, iAsBx}; /* basic instruction format */
++
++
++/*
++** size and position of opcode arguments.
++*/
++#define SIZE_C 9
++#define SIZE_B 9
++#define SIZE_Bx (SIZE_C + SIZE_B)
++#define SIZE_A 8
++
++#define SIZE_OP 6
++
++#define POS_OP 0
++#define POS_A (POS_OP + SIZE_OP)
++#define POS_C (POS_A + SIZE_A)
++#define POS_B (POS_C + SIZE_C)
++#define POS_Bx POS_C
++
++
++/*
++** limits for opcode arguments.
++** we use (signed) int to manipulate most arguments,
++** so they must fit in LUAI_BITSINT-1 bits (-1 for sign)
++*/
++#if SIZE_Bx < LUAI_BITSINT-1
++#define MAXARG_Bx ((1<<SIZE_Bx)-1)
++#define MAXARG_sBx (MAXARG_Bx>>1) /* `sBx' is signed */
++#else
++#define MAXARG_Bx MAX_INT
++#define MAXARG_sBx MAX_INT
++#endif
++
++
++#define MAXARG_A ((1<<SIZE_A)-1)
++#define MAXARG_B ((1<<SIZE_B)-1)
++#define MAXARG_C ((1<<SIZE_C)-1)
++
++
++/* creates a mask with `n' 1 bits at position `p' */
++#define MASK1(n,p) ((~((~(Instruction)0)<<n))<<p)
++
++/* creates a mask with `n' 0 bits at position `p' */
++#define MASK0(n,p) (~MASK1(n,p))
++
++/*
++** the following macros help to manipulate instructions
++*/
++
++#define GET_OPCODE(i) (cast(OpCode, ((i)>>POS_OP) & MASK1(SIZE_OP,0)))
++#define SET_OPCODE(i,o) ((i) = (((i)&MASK0(SIZE_OP,POS_OP)) | \
++ ((cast(Instruction, o)<<POS_OP)&MASK1(SIZE_OP,POS_OP))))
++
++#define GETARG_A(i) (cast(int, ((i)>>POS_A) & MASK1(SIZE_A,0)))
++#define SETARG_A(i,u) ((i) = (((i)&MASK0(SIZE_A,POS_A)) | \
++ ((cast(Instruction, u)<<POS_A)&MASK1(SIZE_A,POS_A))))
++
++#define GETARG_B(i) (cast(int, ((i)>>POS_B) & MASK1(SIZE_B,0)))
++#define SETARG_B(i,b) ((i) = (((i)&MASK0(SIZE_B,POS_B)) | \
++ ((cast(Instruction, b)<<POS_B)&MASK1(SIZE_B,POS_B))))
++
++#define GETARG_C(i) (cast(int, ((i)>>POS_C) & MASK1(SIZE_C,0)))
++#define SETARG_C(i,b) ((i) = (((i)&MASK0(SIZE_C,POS_C)) | \
++ ((cast(Instruction, b)<<POS_C)&MASK1(SIZE_C,POS_C))))
++
++#define GETARG_Bx(i) (cast(int, ((i)>>POS_Bx) & MASK1(SIZE_Bx,0)))
++#define SETARG_Bx(i,b) ((i) = (((i)&MASK0(SIZE_Bx,POS_Bx)) | \
++ ((cast(Instruction, b)<<POS_Bx)&MASK1(SIZE_Bx,POS_Bx))))
++
++#define GETARG_sBx(i) (GETARG_Bx(i)-MAXARG_sBx)
++#define SETARG_sBx(i,b) SETARG_Bx((i),cast(unsigned int, (b)+MAXARG_sBx))
++
++
++#define CREATE_ABC(o,a,b,c) ((cast(Instruction, o)<<POS_OP) \
++ | (cast(Instruction, a)<<POS_A) \
++ | (cast(Instruction, b)<<POS_B) \
++ | (cast(Instruction, c)<<POS_C))
++
++#define CREATE_ABx(o,a,bc) ((cast(Instruction, o)<<POS_OP) \
++ | (cast(Instruction, a)<<POS_A) \
++ | (cast(Instruction, bc)<<POS_Bx))
++
++
++/*
++** Macros to operate RK indices
++*/
++
++/* this bit 1 means constant (0 means register) */
++#define BITRK (1 << (SIZE_B - 1))
++
++/* test whether value is a constant */
++#define ISK(x) ((x) & BITRK)
++
++/* gets the index of the constant */
++#define INDEXK(r) ((int)(r) & ~BITRK)
++
++#define MAXINDEXRK (BITRK - 1)
++
++/* code a constant index as a RK value */
++#define RKASK(x) ((x) | BITRK)
++
++
++/*
++** invalid register that fits in 8 bits
++*/
++#define NO_REG MAXARG_A
++
++
++/*
++** R(x) - register
++** Kst(x) - constant (in constant table)
++** RK(x) == if ISK(x) then Kst(INDEXK(x)) else R(x)
++*/
++
++
++/*
++** grep "ORDER OP" if you change these enums
++*/
++
++typedef enum {
++/*----------------------------------------------------------------------
++name args description
++------------------------------------------------------------------------*/
++OP_MOVE,/* A B R(A) := R(B) */
++OP_LOADK,/* A Bx R(A) := Kst(Bx) */
++OP_LOADBOOL,/* A B C R(A) := (Bool)B; if (C) pc++ */
++OP_LOADNIL,/* A B R(A) := ... := R(B) := nil */
++OP_GETUPVAL,/* A B R(A) := UpValue[B] */
++
++OP_GETGLOBAL,/* A Bx R(A) := Gbl[Kst(Bx)] */
++OP_GETTABLE,/* A B C R(A) := R(B)[RK(C)] */
++
++OP_SETGLOBAL,/* A Bx Gbl[Kst(Bx)] := R(A) */
++OP_SETUPVAL,/* A B UpValue[B] := R(A) */
++OP_SETTABLE,/* A B C R(A)[RK(B)] := RK(C) */
++
++OP_NEWTABLE,/* A B C R(A) := {} (size = B,C) */
++
++OP_SELF,/* A B C R(A+1) := R(B); R(A) := R(B)[RK(C)] */
++
++OP_ADD,/* A B C R(A) := RK(B) + RK(C) */
++OP_SUB,/* A B C R(A) := RK(B) - RK(C) */
++OP_MUL,/* A B C R(A) := RK(B) * RK(C) */
++OP_DIV,/* A B C R(A) := RK(B) / RK(C) */
++OP_MOD,/* A B C R(A) := RK(B) % RK(C) */
++OP_POW,/* A B C R(A) := RK(B) ^ RK(C) */
++OP_UNM,/* A B R(A) := -R(B) */
++OP_NOT,/* A B R(A) := not R(B) */
++OP_LEN,/* A B R(A) := length of R(B) */
++
++OP_CONCAT,/* A B C R(A) := R(B).. ... ..R(C) */
++
++OP_JMP,/* sBx pc+=sBx */
++
++OP_EQ,/* A B C if ((RK(B) == RK(C)) ~= A) then pc++ */
++OP_LT,/* A B C if ((RK(B) < RK(C)) ~= A) then pc++ */
++OP_LE,/* A B C if ((RK(B) <= RK(C)) ~= A) then pc++ */
++
++OP_TEST,/* A C if not (R(A) <=> C) then pc++ */
++OP_TESTSET,/* A B C if (R(B) <=> C) then R(A) := R(B) else pc++ */
++
++OP_CALL,/* A B C R(A), ... ,R(A+C-2) := R(A)(R(A+1), ... ,R(A+B-1)) */
++OP_TAILCALL,/* A B C return R(A)(R(A+1), ... ,R(A+B-1)) */
++OP_RETURN,/* A B return R(A), ... ,R(A+B-2) (see note) */
++
++OP_FORLOOP,/* A sBx R(A)+=R(A+2);
++ if R(A) <?= R(A+1) then { pc+=sBx; R(A+3)=R(A) }*/
++OP_FORPREP,/* A sBx R(A)-=R(A+2); pc+=sBx */
++
++OP_TFORLOOP,/* A C R(A+3), ... ,R(A+2+C) := R(A)(R(A+1), R(A+2));
++ if R(A+3) ~= nil then R(A+2)=R(A+3) else pc++ */
++OP_SETLIST,/* A B C R(A)[(C-1)*FPF+i] := R(A+i), 1 <= i <= B */
++
++OP_CLOSE,/* A close all variables in the stack up to (>=) R(A)*/
++OP_CLOSURE,/* A Bx R(A) := closure(KPROTO[Bx], R(A), ... ,R(A+n)) */
++
++OP_VARARG/* A B R(A), R(A+1), ..., R(A+B-1) = vararg */
++} OpCode;
++
++
++#define NUM_OPCODES (cast(int, OP_VARARG) + 1)
++
++
++
++/*===========================================================================
++ Notes:
++ (*) In OP_CALL, if (B == 0) then B = top. C is the number of returns - 1,
++ and can be 0: OP_CALL then sets `top' to last_result+1, so
++ next open instruction (OP_CALL, OP_RETURN, OP_SETLIST) may use `top'.
++
++ (*) In OP_VARARG, if (B == 0) then use actual number of varargs and
++ set top (like in OP_CALL with C == 0).
++
++ (*) In OP_RETURN, if (B == 0) then return up to `top'
++
++ (*) In OP_SETLIST, if (B == 0) then B = `top';
++ if (C == 0) then next `instruction' is real C
++
++ (*) For comparisons, A specifies what condition the test should accept
++ (true or false).
++
++ (*) All `skips' (pc++) assume that next instruction is a jump
++===========================================================================*/
++
++
++/*
++** masks for instruction properties. The format is:
++** bits 0-1: op mode
++** bits 2-3: C arg mode
++** bits 4-5: B arg mode
++** bit 6: instruction set register A
++** bit 7: operator is a test
++*/
++
++enum OpArgMask {
++ OpArgN, /* argument is not used */
++ OpArgU, /* argument is used */
++ OpArgR, /* argument is a register or a jump offset */
++ OpArgK /* argument is a constant or register/constant */
++};
++
++LUAI_DATA const lu_byte luaP_opmodes[NUM_OPCODES];
++
++#define getOpMode(m) (cast(enum OpMode, luaP_opmodes[m] & 3))
++#define getBMode(m) (cast(enum OpArgMask, (luaP_opmodes[m] >> 4) & 3))
++#define getCMode(m) (cast(enum OpArgMask, (luaP_opmodes[m] >> 2) & 3))
++#define testAMode(m) (luaP_opmodes[m] & (1 << 6))
++#define testTMode(m) (luaP_opmodes[m] & (1 << 7))
++
++
++LUAI_DATA const char *const luaP_opnames[NUM_OPCODES+1]; /* opcode names */
++
++
++/* number of list items to accumulate before a SETLIST instruction */
++#define LFIELDS_PER_FLUSH 50
++
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/lparser.c
+@@ -0,0 +1,1339 @@
++/*
++** $Id: lparser.c,v 2.42.1.3 2007/12/28 15:32:23 roberto Exp $
++** Lua Parser
++** See Copyright Notice in lua.h
++*/
++
++
++#include <string.h>
++
++#define lparser_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "lcode.h"
++#include "ldebug.h"
++#include "ldo.h"
++#include "lfunc.h"
++#include "llex.h"
++#include "lmem.h"
++#include "lobject.h"
++#include "lopcodes.h"
++#include "lparser.h"
++#include "lstate.h"
++#include "lstring.h"
++#include "ltable.h"
++
++
++
++#define hasmultret(k) ((k) == VCALL || (k) == VVARARG)
++
++#define getlocvar(fs, i) ((fs)->f->locvars[(fs)->actvar[i]])
++
++#define luaY_checklimit(fs,v,l,m) if ((v)>(l)) errorlimit(fs,l,m)
++
++
++/*
++** nodes for block list (list of active blocks)
++*/
++typedef struct BlockCnt {
++ struct BlockCnt *previous; /* chain */
++ int breaklist; /* list of jumps out of this loop */
++ lu_byte nactvar; /* # active locals outside the breakable structure */
++ lu_byte upval; /* true if some variable in the block is an upvalue */
++ lu_byte isbreakable; /* true if `block' is a loop */
++} BlockCnt;
++
++
++
++/*
++** prototypes for recursive non-terminal functions
++*/
++static void chunk (LexState *ls);
++static void expr (LexState *ls, expdesc *v);
++
++
++static void anchor_token (LexState *ls) {
++ if (ls->t.token == TK_NAME || ls->t.token == TK_STRING) {
++ TString *ts = ls->t.seminfo.ts;
++ luaX_newstring(ls, getstr(ts), ts->tsv.len);
++ }
++}
++
++
++static void error_expected (LexState *ls, int token) {
++ luaX_syntaxerror(ls,
++ luaO_pushfstring(ls->L, LUA_QS " expected", luaX_token2str(ls, token)));
++}
++
++
++static void errorlimit (FuncState *fs, int limit, const char *what) {
++ const char *msg = (fs->f->linedefined == 0) ?
++ luaO_pushfstring(fs->L, "main function has more than %d %s", limit, what) :
++ luaO_pushfstring(fs->L, "function at line %d has more than %d %s",
++ fs->f->linedefined, limit, what);
++ luaX_lexerror(fs->ls, msg, 0);
++}
++
++
++static int testnext (LexState *ls, int c) {
++ if (ls->t.token == c) {
++ luaX_next(ls);
++ return 1;
++ }
++ else return 0;
++}
++
++
++static void check (LexState *ls, int c) {
++ if (ls->t.token != c)
++ error_expected(ls, c);
++}
++
++static void checknext (LexState *ls, int c) {
++ check(ls, c);
++ luaX_next(ls);
++}
++
++
++#define check_condition(ls,c,msg) { if (!(c)) luaX_syntaxerror(ls, msg); }
++
++
++
++static void check_match (LexState *ls, int what, int who, int where) {
++ if (!testnext(ls, what)) {
++ if (where == ls->linenumber)
++ error_expected(ls, what);
++ else {
++ luaX_syntaxerror(ls, luaO_pushfstring(ls->L,
++ LUA_QS " expected (to close " LUA_QS " at line %d)",
++ luaX_token2str(ls, what), luaX_token2str(ls, who), where));
++ }
++ }
++}
++
++
++static TString *str_checkname (LexState *ls) {
++ TString *ts;
++ check(ls, TK_NAME);
++ ts = ls->t.seminfo.ts;
++ luaX_next(ls);
++ return ts;
++}
++
++
++static void init_exp (expdesc *e, expkind k, int i) {
++ e->f = e->t = NO_JUMP;
++ e->k = k;
++ e->u.s.info = i;
++}
++
++
++static void codestring (LexState *ls, expdesc *e, TString *s) {
++ init_exp(e, VK, luaK_stringK(ls->fs, s));
++}
++
++
++static void checkname(LexState *ls, expdesc *e) {
++ codestring(ls, e, str_checkname(ls));
++}
++
++
++static int registerlocalvar (LexState *ls, TString *varname) {
++ FuncState *fs = ls->fs;
++ Proto *f = fs->f;
++ int oldsize = f->sizelocvars;
++ luaM_growvector(ls->L, f->locvars, fs->nlocvars, f->sizelocvars,
++ LocVar, SHRT_MAX, "too many local variables");
++ while (oldsize < f->sizelocvars) f->locvars[oldsize++].varname = NULL;
++ f->locvars[fs->nlocvars].varname = varname;
++ luaC_objbarrier(ls->L, f, varname);
++ return fs->nlocvars++;
++}
++
++
++#define new_localvarliteral(ls,v,n) \
++ new_localvar(ls, luaX_newstring(ls, "" v, (sizeof(v)/sizeof(char))-1), n)
++
++
++static void new_localvar (LexState *ls, TString *name, int n) {
++ FuncState *fs = ls->fs;
++ luaY_checklimit(fs, fs->nactvar+n+1, LUAI_MAXVARS, "local variables");
++ fs->actvar[fs->nactvar+n] = cast(unsigned short, registerlocalvar(ls, name));
++}
++
++
++static void adjustlocalvars (LexState *ls, int nvars) {
++ FuncState *fs = ls->fs;
++ fs->nactvar = cast_byte(fs->nactvar + nvars);
++ for (; nvars; nvars--) {
++ getlocvar(fs, fs->nactvar - nvars).startpc = fs->pc;
++ }
++}
++
++
++static void removevars (LexState *ls, int tolevel) {
++ FuncState *fs = ls->fs;
++ while (fs->nactvar > tolevel)
++ getlocvar(fs, --fs->nactvar).endpc = fs->pc;
++}
++
++
++static int indexupvalue (FuncState *fs, TString *name, expdesc *v) {
++ int i;
++ Proto *f = fs->f;
++ int oldsize = f->sizeupvalues;
++ for (i=0; i<f->nups; i++) {
++ if (fs->upvalues[i].k == v->k && fs->upvalues[i].info == v->u.s.info) {
++ lua_assert(f->upvalues[i] == name);
++ return i;
++ }
++ }
++ /* new one */
++ luaY_checklimit(fs, f->nups + 1, LUAI_MAXUPVALUES, "upvalues");
++ luaM_growvector(fs->L, f->upvalues, f->nups, f->sizeupvalues,
++ TString *, MAX_INT, "");
++ while (oldsize < f->sizeupvalues) f->upvalues[oldsize++] = NULL;
++ f->upvalues[f->nups] = name;
++ luaC_objbarrier(fs->L, f, name);
++ lua_assert(v->k == VLOCAL || v->k == VUPVAL);
++ fs->upvalues[f->nups].k = cast_byte(v->k);
++ fs->upvalues[f->nups].info = cast_byte(v->u.s.info);
++ return f->nups++;
++}
++
++
++static int searchvar (FuncState *fs, TString *n) {
++ int i;
++ for (i=fs->nactvar-1; i >= 0; i--) {
++ if (n == getlocvar(fs, i).varname)
++ return i;
++ }
++ return -1; /* not found */
++}
++
++
++static void markupval (FuncState *fs, int level) {
++ BlockCnt *bl = fs->bl;
++ while (bl && bl->nactvar > level) bl = bl->previous;
++ if (bl) bl->upval = 1;
++}
++
++
++static int singlevaraux (FuncState *fs, TString *n, expdesc *var, int base) {
++ if (fs == NULL) { /* no more levels? */
++ init_exp(var, VGLOBAL, NO_REG); /* default is global variable */
++ return VGLOBAL;
++ }
++ else {
++ int v = searchvar(fs, n); /* look up at current level */
++ if (v >= 0) {
++ init_exp(var, VLOCAL, v);
++ if (!base)
++ markupval(fs, v); /* local will be used as an upval */
++ return VLOCAL;
++ }
++ else { /* not found at current level; try upper one */
++ if (singlevaraux(fs->prev, n, var, 0) == VGLOBAL)
++ return VGLOBAL;
++ var->u.s.info = indexupvalue(fs, n, var); /* else was LOCAL or UPVAL */
++ var->k = VUPVAL; /* upvalue in this level */
++ return VUPVAL;
++ }
++ }
++}
++
++
++static void singlevar (LexState *ls, expdesc *var) {
++ TString *varname = str_checkname(ls);
++ FuncState *fs = ls->fs;
++ if (singlevaraux(fs, varname, var, 1) == VGLOBAL)
++ var->u.s.info = luaK_stringK(fs, varname); /* info points to global name */
++}
++
++
++static void adjust_assign (LexState *ls, int nvars, int nexps, expdesc *e) {
++ FuncState *fs = ls->fs;
++ int extra = nvars - nexps;
++ if (hasmultret(e->k)) {
++ extra++; /* includes call itself */
++ if (extra < 0) extra = 0;
++ luaK_setreturns(fs, e, extra); /* last exp. provides the difference */
++ if (extra > 1) luaK_reserveregs(fs, extra-1);
++ }
++ else {
++ if (e->k != VVOID) luaK_exp2nextreg(fs, e); /* close last expression */
++ if (extra > 0) {
++ int reg = fs->freereg;
++ luaK_reserveregs(fs, extra);
++ luaK_nil(fs, reg, extra);
++ }
++ }
++}
++
++
++static void enterlevel (LexState *ls) {
++ if (++ls->L->nCcalls > LUAI_MAXCCALLS)
++ luaX_lexerror(ls, "chunk has too many syntax levels", 0);
++}
++
++
++#define leavelevel(ls) ((ls)->L->nCcalls--)
++
++
++static void enterblock (FuncState *fs, BlockCnt *bl, lu_byte isbreakable) {
++ bl->breaklist = NO_JUMP;
++ bl->isbreakable = isbreakable;
++ bl->nactvar = fs->nactvar;
++ bl->upval = 0;
++ bl->previous = fs->bl;
++ fs->bl = bl;
++ lua_assert(fs->freereg == fs->nactvar);
++}
++
++
++static void leaveblock (FuncState *fs) {
++ BlockCnt *bl = fs->bl;
++ fs->bl = bl->previous;
++ removevars(fs->ls, bl->nactvar);
++ if (bl->upval)
++ luaK_codeABC(fs, OP_CLOSE, bl->nactvar, 0, 0);
++ /* a block either controls scope or breaks (never both) */
++ lua_assert(!bl->isbreakable || !bl->upval);
++ lua_assert(bl->nactvar == fs->nactvar);
++ fs->freereg = fs->nactvar; /* free registers */
++ luaK_patchtohere(fs, bl->breaklist);
++}
++
++
++static void pushclosure (LexState *ls, FuncState *func, expdesc *v) {
++ FuncState *fs = ls->fs;
++ Proto *f = fs->f;
++ int oldsize = f->sizep;
++ int i;
++ luaM_growvector(ls->L, f->p, fs->np, f->sizep, Proto *,
++ MAXARG_Bx, "constant table overflow");
++ while (oldsize < f->sizep) f->p[oldsize++] = NULL;
++ f->p[fs->np++] = func->f;
++ luaC_objbarrier(ls->L, f, func->f);
++ init_exp(v, VRELOCABLE, luaK_codeABx(fs, OP_CLOSURE, 0, fs->np-1));
++ for (i=0; i<func->f->nups; i++) {
++ OpCode o = (func->upvalues[i].k == VLOCAL) ? OP_MOVE : OP_GETUPVAL;
++ luaK_codeABC(fs, o, 0, func->upvalues[i].info, 0);
++ }
++}
++
++
++static void open_func (LexState *ls, FuncState *fs) {
++ lua_State *L = ls->L;
++ Proto *f = luaF_newproto(L);
++ fs->f = f;
++ fs->prev = ls->fs; /* linked list of funcstates */
++ fs->ls = ls;
++ fs->L = L;
++ ls->fs = fs;
++ fs->pc = 0;
++ fs->lasttarget = -1;
++ fs->jpc = NO_JUMP;
++ fs->freereg = 0;
++ fs->nk = 0;
++ fs->np = 0;
++ fs->nlocvars = 0;
++ fs->nactvar = 0;
++ fs->bl = NULL;
++ f->source = ls->source;
++ f->maxstacksize = 2; /* registers 0/1 are always valid */
++ fs->h = luaH_new(L, 0, 0);
++ /* anchor table of constants and prototype (to avoid being collected) */
++ sethvalue2s(L, L->top, fs->h);
++ incr_top(L);
++ setptvalue2s(L, L->top, f);
++ incr_top(L);
++}
++
++
++static void close_func (LexState *ls) {
++ lua_State *L = ls->L;
++ FuncState *fs = ls->fs;
++ Proto *f = fs->f;
++ removevars(ls, 0);
++ luaK_ret(fs, 0, 0); /* final return */
++ luaM_reallocvector(L, f->code, f->sizecode, fs->pc, Instruction);
++ f->sizecode = fs->pc;
++ luaM_reallocvector(L, f->lineinfo, f->sizelineinfo, fs->pc, int);
++ f->sizelineinfo = fs->pc;
++ luaM_reallocvector(L, f->k, f->sizek, fs->nk, TValue);
++ f->sizek = fs->nk;
++ luaM_reallocvector(L, f->p, f->sizep, fs->np, Proto *);
++ f->sizep = fs->np;
++ luaM_reallocvector(L, f->locvars, f->sizelocvars, fs->nlocvars, LocVar);
++ f->sizelocvars = fs->nlocvars;
++ luaM_reallocvector(L, f->upvalues, f->sizeupvalues, f->nups, TString *);
++ f->sizeupvalues = f->nups;
++ lua_assert(luaG_checkcode(f));
++ lua_assert(fs->bl == NULL);
++ ls->fs = fs->prev;
++ L->top -= 2; /* remove table and prototype from the stack */
++ /* last token read was anchored in defunct function; must reanchor it */
++ if (fs) anchor_token(ls);
++}
++
++
++Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, const char *name) {
++ struct LexState lexstate;
++ struct FuncState funcstate;
++ lexstate.buff = buff;
++ luaX_setinput(L, &lexstate, z, luaS_new(L, name));
++ open_func(&lexstate, &funcstate);
++ funcstate.f->is_vararg = VARARG_ISVARARG; /* main func. is always vararg */
++ luaX_next(&lexstate); /* read first token */
++ chunk(&lexstate);
++ check(&lexstate, TK_EOS);
++ close_func(&lexstate);
++ lua_assert(funcstate.prev == NULL);
++ lua_assert(funcstate.f->nups == 0);
++ lua_assert(lexstate.fs == NULL);
++ return funcstate.f;
++}
++
++
++
++/*============================================================*/
++/* GRAMMAR RULES */
++/*============================================================*/
++
++
++static void field (LexState *ls, expdesc *v) {
++ /* field -> ['.' | ':'] NAME */
++ FuncState *fs = ls->fs;
++ expdesc key;
++ luaK_exp2anyreg(fs, v);
++ luaX_next(ls); /* skip the dot or colon */
++ checkname(ls, &key);
++ luaK_indexed(fs, v, &key);
++}
++
++
++static void yindex (LexState *ls, expdesc *v) {
++ /* index -> '[' expr ']' */
++ luaX_next(ls); /* skip the '[' */
++ expr(ls, v);
++ luaK_exp2val(ls->fs, v);
++ checknext(ls, ']');
++}
++
++
++/*
++** {======================================================================
++** Rules for Constructors
++** =======================================================================
++*/
++
++
++struct ConsControl {
++ expdesc v; /* last list item read */
++ expdesc *t; /* table descriptor */
++ int nh; /* total number of `record' elements */
++ int na; /* total number of array elements */
++ int tostore; /* number of array elements pending to be stored */
++};
++
++
++static void recfield (LexState *ls, struct ConsControl *cc) {
++ /* recfield -> (NAME | `['exp1`]') = exp1 */
++ FuncState *fs = ls->fs;
++ int reg = ls->fs->freereg;
++ expdesc key, val;
++ int rkkey;
++ if (ls->t.token == TK_NAME) {
++ luaY_checklimit(fs, cc->nh, MAX_INT, "items in a constructor");
++ checkname(ls, &key);
++ }
++ else /* ls->t.token == '[' */
++ yindex(ls, &key);
++ cc->nh++;
++ checknext(ls, '=');
++ rkkey = luaK_exp2RK(fs, &key);
++ expr(ls, &val);
++ luaK_codeABC(fs, OP_SETTABLE, cc->t->u.s.info, rkkey, luaK_exp2RK(fs, &val));
++ fs->freereg = reg; /* free registers */
++}
++
++
++static void closelistfield (FuncState *fs, struct ConsControl *cc) {
++ if (cc->v.k == VVOID) return; /* there is no list item */
++ luaK_exp2nextreg(fs, &cc->v);
++ cc->v.k = VVOID;
++ if (cc->tostore == LFIELDS_PER_FLUSH) {
++ luaK_setlist(fs, cc->t->u.s.info, cc->na, cc->tostore); /* flush */
++ cc->tostore = 0; /* no more items pending */
++ }
++}
++
++
++static void lastlistfield (FuncState *fs, struct ConsControl *cc) {
++ if (cc->tostore == 0) return;
++ if (hasmultret(cc->v.k)) {
++ luaK_setmultret(fs, &cc->v);
++ luaK_setlist(fs, cc->t->u.s.info, cc->na, LUA_MULTRET);
++ cc->na--; /* do not count last expression (unknown number of elements) */
++ }
++ else {
++ if (cc->v.k != VVOID)
++ luaK_exp2nextreg(fs, &cc->v);
++ luaK_setlist(fs, cc->t->u.s.info, cc->na, cc->tostore);
++ }
++}
++
++
++static void listfield (LexState *ls, struct ConsControl *cc) {
++ expr(ls, &cc->v);
++ luaY_checklimit(ls->fs, cc->na, MAX_INT, "items in a constructor");
++ cc->na++;
++ cc->tostore++;
++}
++
++
++static void constructor (LexState *ls, expdesc *t) {
++ /* constructor -> ?? */
++ FuncState *fs = ls->fs;
++ int line = ls->linenumber;
++ int pc = luaK_codeABC(fs, OP_NEWTABLE, 0, 0, 0);
++ struct ConsControl cc;
++ cc.na = cc.nh = cc.tostore = 0;
++ cc.t = t;
++ init_exp(t, VRELOCABLE, pc);
++ init_exp(&cc.v, VVOID, 0); /* no value (yet) */
++ luaK_exp2nextreg(ls->fs, t); /* fix it at stack top (for gc) */
++ checknext(ls, '{');
++ do {
++ lua_assert(cc.v.k == VVOID || cc.tostore > 0);
++ if (ls->t.token == '}') break;
++ closelistfield(fs, &cc);
++ switch(ls->t.token) {
++ case TK_NAME: { /* may be listfields or recfields */
++ luaX_lookahead(ls);
++ if (ls->lookahead.token != '=') /* expression? */
++ listfield(ls, &cc);
++ else
++ recfield(ls, &cc);
++ break;
++ }
++ case '[': { /* constructor_item -> recfield */
++ recfield(ls, &cc);
++ break;
++ }
++ default: { /* constructor_part -> listfield */
++ listfield(ls, &cc);
++ break;
++ }
++ }
++ } while (testnext(ls, ',') || testnext(ls, ';'));
++ check_match(ls, '}', '{', line);
++ lastlistfield(fs, &cc);
++ SETARG_B(fs->f->code[pc], luaO_int2fb(cc.na)); /* set initial array size */
++ SETARG_C(fs->f->code[pc], luaO_int2fb(cc.nh)); /* set initial table size */
++}
++
++/* }====================================================================== */
++
++
++
++static void parlist (LexState *ls) {
++ /* parlist -> [ param { `,' param } ] */
++ FuncState *fs = ls->fs;
++ Proto *f = fs->f;
++ int nparams = 0;
++ f->is_vararg = 0;
++ if (ls->t.token != ')') { /* is `parlist' not empty? */
++ do {
++ switch (ls->t.token) {
++ case TK_NAME: { /* param -> NAME */
++ new_localvar(ls, str_checkname(ls), nparams++);
++ break;
++ }
++ case TK_DOTS: { /* param -> `...' */
++ luaX_next(ls);
++#if defined(LUA_COMPAT_VARARG)
++ /* use `arg' as default name */
++ new_localvarliteral(ls, "arg", nparams++);
++ f->is_vararg = VARARG_HASARG | VARARG_NEEDSARG;
++#endif
++ f->is_vararg |= VARARG_ISVARARG;
++ break;
++ }
++ default: luaX_syntaxerror(ls, "<name> or " LUA_QL("...") " expected");
++ }
++ } while (!f->is_vararg && testnext(ls, ','));
++ }
++ adjustlocalvars(ls, nparams);
++ f->numparams = cast_byte(fs->nactvar - (f->is_vararg & VARARG_HASARG));
++ luaK_reserveregs(fs, fs->nactvar); /* reserve register for parameters */
++}
++
++
++static void body (LexState *ls, expdesc *e, int needself, int line) {
++ /* body -> `(' parlist `)' chunk END */
++ FuncState new_fs;
++ open_func(ls, &new_fs);
++ new_fs.f->linedefined = line;
++ checknext(ls, '(');
++ if (needself) {
++ new_localvarliteral(ls, "self", 0);
++ adjustlocalvars(ls, 1);
++ }
++ parlist(ls);
++ checknext(ls, ')');
++ chunk(ls);
++ new_fs.f->lastlinedefined = ls->linenumber;
++ check_match(ls, TK_END, TK_FUNCTION, line);
++ close_func(ls);
++ pushclosure(ls, &new_fs, e);
++}
++
++
++static int explist1 (LexState *ls, expdesc *v) {
++ /* explist1 -> expr { `,' expr } */
++ int n = 1; /* at least one expression */
++ expr(ls, v);
++ while (testnext(ls, ',')) {
++ luaK_exp2nextreg(ls->fs, v);
++ expr(ls, v);
++ n++;
++ }
++ return n;
++}
++
++
++static void funcargs (LexState *ls, expdesc *f) {
++ FuncState *fs = ls->fs;
++ expdesc args;
++ int base, nparams;
++ int line = ls->linenumber;
++ switch (ls->t.token) {
++ case '(': { /* funcargs -> `(' [ explist1 ] `)' */
++ if (line != ls->lastline)
++ luaX_syntaxerror(ls,"ambiguous syntax (function call x new statement)");
++ luaX_next(ls);
++ if (ls->t.token == ')') /* arg list is empty? */
++ args.k = VVOID;
++ else {
++ explist1(ls, &args);
++ luaK_setmultret(fs, &args);
++ }
++ check_match(ls, ')', '(', line);
++ break;
++ }
++ case '{': { /* funcargs -> constructor */
++ constructor(ls, &args);
++ break;
++ }
++ case TK_STRING: { /* funcargs -> STRING */
++ codestring(ls, &args, ls->t.seminfo.ts);
++ luaX_next(ls); /* must use `seminfo' before `next' */
++ break;
++ }
++ default: {
++ luaX_syntaxerror(ls, "function arguments expected");
++ return;
++ }
++ }
++ lua_assert(f->k == VNONRELOC);
++ base = f->u.s.info; /* base register for call */
++ if (hasmultret(args.k))
++ nparams = LUA_MULTRET; /* open call */
++ else {
++ if (args.k != VVOID)
++ luaK_exp2nextreg(fs, &args); /* close last argument */
++ nparams = fs->freereg - (base+1);
++ }
++ init_exp(f, VCALL, luaK_codeABC(fs, OP_CALL, base, nparams+1, 2));
++ luaK_fixline(fs, line);
++ fs->freereg = base+1; /* call remove function and arguments and leaves
++ (unless changed) one result */
++}
++
++
++
++
++/*
++** {======================================================================
++** Expression parsing
++** =======================================================================
++*/
++
++
++static void prefixexp (LexState *ls, expdesc *v) {
++ /* prefixexp -> NAME | '(' expr ')' */
++ switch (ls->t.token) {
++ case '(': {
++ int line = ls->linenumber;
++ luaX_next(ls);
++ expr(ls, v);
++ check_match(ls, ')', '(', line);
++ luaK_dischargevars(ls->fs, v);
++ return;
++ }
++ case TK_NAME: {
++ singlevar(ls, v);
++ return;
++ }
++ default: {
++ luaX_syntaxerror(ls, "unexpected symbol");
++ return;
++ }
++ }
++}
++
++
++static void primaryexp (LexState *ls, expdesc *v) {
++ /* primaryexp ->
++ prefixexp { `.' NAME | `[' exp `]' | `:' NAME funcargs | funcargs } */
++ FuncState *fs = ls->fs;
++ prefixexp(ls, v);
++ for (;;) {
++ switch (ls->t.token) {
++ case '.': { /* field */
++ field(ls, v);
++ break;
++ }
++ case '[': { /* `[' exp1 `]' */
++ expdesc key;
++ luaK_exp2anyreg(fs, v);
++ yindex(ls, &key);
++ luaK_indexed(fs, v, &key);
++ break;
++ }
++ case ':': { /* `:' NAME funcargs */
++ expdesc key;
++ luaX_next(ls);
++ checkname(ls, &key);
++ luaK_self(fs, v, &key);
++ funcargs(ls, v);
++ break;
++ }
++ case '(': case TK_STRING: case '{': { /* funcargs */
++ luaK_exp2nextreg(fs, v);
++ funcargs(ls, v);
++ break;
++ }
++ default: return;
++ }
++ }
++}
++
++
++static void simpleexp (LexState *ls, expdesc *v) {
++ /* simpleexp -> NUMBER | STRING | NIL | true | false | ... |
++ constructor | FUNCTION body | primaryexp */
++ switch (ls->t.token) {
++ case TK_NUMBER: {
++ init_exp(v, VKNUM, 0);
++ v->u.nval = ls->t.seminfo.r;
++ break;
++ }
++ case TK_STRING: {
++ codestring(ls, v, ls->t.seminfo.ts);
++ break;
++ }
++ case TK_NIL: {
++ init_exp(v, VNIL, 0);
++ break;
++ }
++ case TK_TRUE: {
++ init_exp(v, VTRUE, 0);
++ break;
++ }
++ case TK_FALSE: {
++ init_exp(v, VFALSE, 0);
++ break;
++ }
++ case TK_DOTS: { /* vararg */
++ FuncState *fs = ls->fs;
++ check_condition(ls, fs->f->is_vararg,
++ "cannot use " LUA_QL("...") " outside a vararg function");
++ fs->f->is_vararg &= ~VARARG_NEEDSARG; /* don't need 'arg' */
++ init_exp(v, VVARARG, luaK_codeABC(fs, OP_VARARG, 0, 1, 0));
++ break;
++ }
++ case '{': { /* constructor */
++ constructor(ls, v);
++ return;
++ }
++ case TK_FUNCTION: {
++ luaX_next(ls);
++ body(ls, v, 0, ls->linenumber);
++ return;
++ }
++ default: {
++ primaryexp(ls, v);
++ return;
++ }
++ }
++ luaX_next(ls);
++}
++
++
++static UnOpr getunopr (int op) {
++ switch (op) {
++ case TK_NOT: return OPR_NOT;
++ case '-': return OPR_MINUS;
++ case '#': return OPR_LEN;
++ default: return OPR_NOUNOPR;
++ }
++}
++
++
++static BinOpr getbinopr (int op) {
++ switch (op) {
++ case '+': return OPR_ADD;
++ case '-': return OPR_SUB;
++ case '*': return OPR_MUL;
++ case '/': return OPR_DIV;
++ case '%': return OPR_MOD;
++ case '^': return OPR_POW;
++ case TK_CONCAT: return OPR_CONCAT;
++ case TK_NE: return OPR_NE;
++ case TK_EQ: return OPR_EQ;
++ case '<': return OPR_LT;
++ case TK_LE: return OPR_LE;
++ case '>': return OPR_GT;
++ case TK_GE: return OPR_GE;
++ case TK_AND: return OPR_AND;
++ case TK_OR: return OPR_OR;
++ default: return OPR_NOBINOPR;
++ }
++}
++
++
++static const struct {
++ lu_byte left; /* left priority for each binary operator */
++ lu_byte right; /* right priority */
++} priority[] = { /* ORDER OPR */
++ {6, 6}, {6, 6}, {7, 7}, {7, 7}, {7, 7}, /* `+' `-' `/' `%' */
++ {10, 9}, {5, 4}, /* power and concat (right associative) */
++ {3, 3}, {3, 3}, /* equality and inequality */
++ {3, 3}, {3, 3}, {3, 3}, {3, 3}, /* order */
++ {2, 2}, {1, 1} /* logical (and/or) */
++};
++
++#define UNARY_PRIORITY 8 /* priority for unary operators */
++
++
++/*
++** subexpr -> (simpleexp | unop subexpr) { binop subexpr }
++** where `binop' is any binary operator with a priority higher than `limit'
++*/
++static BinOpr subexpr (LexState *ls, expdesc *v, unsigned int limit) {
++ BinOpr op;
++ UnOpr uop;
++ enterlevel(ls);
++ uop = getunopr(ls->t.token);
++ if (uop != OPR_NOUNOPR) {
++ luaX_next(ls);
++ subexpr(ls, v, UNARY_PRIORITY);
++ luaK_prefix(ls->fs, uop, v);
++ }
++ else simpleexp(ls, v);
++ /* expand while operators have priorities higher than `limit' */
++ op = getbinopr(ls->t.token);
++ while (op != OPR_NOBINOPR && priority[op].left > limit) {
++ expdesc v2;
++ BinOpr nextop;
++ luaX_next(ls);
++ luaK_infix(ls->fs, op, v);
++ /* read sub-expression with higher priority */
++ nextop = subexpr(ls, &v2, priority[op].right);
++ luaK_posfix(ls->fs, op, v, &v2);
++ op = nextop;
++ }
++ leavelevel(ls);
++ return op; /* return first untreated operator */
++}
++
++
++static void expr (LexState *ls, expdesc *v) {
++ subexpr(ls, v, 0);
++}
++
++/* }==================================================================== */
++
++
++
++/*
++** {======================================================================
++** Rules for Statements
++** =======================================================================
++*/
++
++
++static int block_follow (int token) {
++ switch (token) {
++ case TK_ELSE: case TK_ELSEIF: case TK_END:
++ case TK_UNTIL: case TK_EOS:
++ return 1;
++ default: return 0;
++ }
++}
++
++
++static void block (LexState *ls) {
++ /* block -> chunk */
++ FuncState *fs = ls->fs;
++ BlockCnt bl;
++ enterblock(fs, &bl, 0);
++ chunk(ls);
++ lua_assert(bl.breaklist == NO_JUMP);
++ leaveblock(fs);
++}
++
++
++/*
++** structure to chain all variables in the left-hand side of an
++** assignment
++*/
++struct LHS_assign {
++ struct LHS_assign *prev;
++ expdesc v; /* variable (global, local, upvalue, or indexed) */
++};
++
++
++/*
++** check whether, in an assignment to a local variable, the local variable
++** is needed in a previous assignment (to a table). If so, save original
++** local value in a safe place and use this safe copy in the previous
++** assignment.
++*/
++static void check_conflict (LexState *ls, struct LHS_assign *lh, expdesc *v) {
++ FuncState *fs = ls->fs;
++ int extra = fs->freereg; /* eventual position to save local variable */
++ int conflict = 0;
++ for (; lh; lh = lh->prev) {
++ if (lh->v.k == VINDEXED) {
++ if (lh->v.u.s.info == v->u.s.info) { /* conflict? */
++ conflict = 1;
++ lh->v.u.s.info = extra; /* previous assignment will use safe copy */
++ }
++ if (lh->v.u.s.aux == v->u.s.info) { /* conflict? */
++ conflict = 1;
++ lh->v.u.s.aux = extra; /* previous assignment will use safe copy */
++ }
++ }
++ }
++ if (conflict) {
++ luaK_codeABC(fs, OP_MOVE, fs->freereg, v->u.s.info, 0); /* make copy */
++ luaK_reserveregs(fs, 1);
++ }
++}
++
++
++static void assignment (LexState *ls, struct LHS_assign *lh, int nvars) {
++ expdesc e;
++ check_condition(ls, VLOCAL <= lh->v.k && lh->v.k <= VINDEXED,
++ "syntax error");
++ if (testnext(ls, ',')) { /* assignment -> `,' primaryexp assignment */
++ struct LHS_assign nv;
++ nv.prev = lh;
++ primaryexp(ls, &nv.v);
++ if (nv.v.k == VLOCAL)
++ check_conflict(ls, lh, &nv.v);
++ luaY_checklimit(ls->fs, nvars, LUAI_MAXCCALLS - ls->L->nCcalls,
++ "variables in assignment");
++ assignment(ls, &nv, nvars+1);
++ }
++ else { /* assignment -> `=' explist1 */
++ int nexps;
++ checknext(ls, '=');
++ nexps = explist1(ls, &e);
++ if (nexps != nvars) {
++ adjust_assign(ls, nvars, nexps, &e);
++ if (nexps > nvars)
++ ls->fs->freereg -= nexps - nvars; /* remove extra values */
++ }
++ else {
++ luaK_setoneret(ls->fs, &e); /* close last expression */
++ luaK_storevar(ls->fs, &lh->v, &e);
++ return; /* avoid default */
++ }
++ }
++ init_exp(&e, VNONRELOC, ls->fs->freereg-1); /* default assignment */
++ luaK_storevar(ls->fs, &lh->v, &e);
++}
++
++
++static int cond (LexState *ls) {
++ /* cond -> exp */
++ expdesc v;
++ expr(ls, &v); /* read condition */
++ if (v.k == VNIL) v.k = VFALSE; /* `falses' are all equal here */
++ luaK_goiftrue(ls->fs, &v);
++ return v.f;
++}
++
++
++static void breakstat (LexState *ls) {
++ FuncState *fs = ls->fs;
++ BlockCnt *bl = fs->bl;
++ int upval = 0;
++ while (bl && !bl->isbreakable) {
++ upval |= bl->upval;
++ bl = bl->previous;
++ }
++ if (!bl)
++ luaX_syntaxerror(ls, "no loop to break");
++ if (upval)
++ luaK_codeABC(fs, OP_CLOSE, bl->nactvar, 0, 0);
++ luaK_concat(fs, &bl->breaklist, luaK_jump(fs));
++}
++
++
++static void whilestat (LexState *ls, int line) {
++ /* whilestat -> WHILE cond DO block END */
++ FuncState *fs = ls->fs;
++ int whileinit;
++ int condexit;
++ BlockCnt bl;
++ luaX_next(ls); /* skip WHILE */
++ whileinit = luaK_getlabel(fs);
++ condexit = cond(ls);
++ enterblock(fs, &bl, 1);
++ checknext(ls, TK_DO);
++ block(ls);
++ luaK_patchlist(fs, luaK_jump(fs), whileinit);
++ check_match(ls, TK_END, TK_WHILE, line);
++ leaveblock(fs);
++ luaK_patchtohere(fs, condexit); /* false conditions finish the loop */
++}
++
++
++static void repeatstat (LexState *ls, int line) {
++ /* repeatstat -> REPEAT block UNTIL cond */
++ int condexit;
++ FuncState *fs = ls->fs;
++ int repeat_init = luaK_getlabel(fs);
++ BlockCnt bl1, bl2;
++ enterblock(fs, &bl1, 1); /* loop block */
++ enterblock(fs, &bl2, 0); /* scope block */
++ luaX_next(ls); /* skip REPEAT */
++ chunk(ls);
++ check_match(ls, TK_UNTIL, TK_REPEAT, line);
++ condexit = cond(ls); /* read condition (inside scope block) */
++ if (!bl2.upval) { /* no upvalues? */
++ leaveblock(fs); /* finish scope */
++ luaK_patchlist(ls->fs, condexit, repeat_init); /* close the loop */
++ }
++ else { /* complete semantics when there are upvalues */
++ breakstat(ls); /* if condition then break */
++ luaK_patchtohere(ls->fs, condexit); /* else... */
++ leaveblock(fs); /* finish scope... */
++ luaK_patchlist(ls->fs, luaK_jump(fs), repeat_init); /* and repeat */
++ }
++ leaveblock(fs); /* finish loop */
++}
++
++
++static int exp1 (LexState *ls) {
++ expdesc e;
++ int k;
++ expr(ls, &e);
++ k = e.k;
++ luaK_exp2nextreg(ls->fs, &e);
++ return k;
++}
++
++
++static void forbody (LexState *ls, int base, int line, int nvars, int isnum) {
++ /* forbody -> DO block */
++ BlockCnt bl;
++ FuncState *fs = ls->fs;
++ int prep, endfor;
++ adjustlocalvars(ls, 3); /* control variables */
++ checknext(ls, TK_DO);
++ prep = isnum ? luaK_codeAsBx(fs, OP_FORPREP, base, NO_JUMP) : luaK_jump(fs);
++ enterblock(fs, &bl, 0); /* scope for declared variables */
++ adjustlocalvars(ls, nvars);
++ luaK_reserveregs(fs, nvars);
++ block(ls);
++ leaveblock(fs); /* end of scope for declared variables */
++ luaK_patchtohere(fs, prep);
++ endfor = (isnum) ? luaK_codeAsBx(fs, OP_FORLOOP, base, NO_JUMP) :
++ luaK_codeABC(fs, OP_TFORLOOP, base, 0, nvars);
++ luaK_fixline(fs, line); /* pretend that `OP_FOR' starts the loop */
++ luaK_patchlist(fs, (isnum ? endfor : luaK_jump(fs)), prep + 1);
++}
++
++
++static void fornum (LexState *ls, TString *varname, int line) {
++ /* fornum -> NAME = exp1,exp1[,exp1] forbody */
++ FuncState *fs = ls->fs;
++ int base = fs->freereg;
++ new_localvarliteral(ls, "(for index)", 0);
++ new_localvarliteral(ls, "(for limit)", 1);
++ new_localvarliteral(ls, "(for step)", 2);
++ new_localvar(ls, varname, 3);
++ checknext(ls, '=');
++ exp1(ls); /* initial value */
++ checknext(ls, ',');
++ exp1(ls); /* limit */
++ if (testnext(ls, ','))
++ exp1(ls); /* optional step */
++ else { /* default step = 1 */
++ luaK_codeABx(fs, OP_LOADK, fs->freereg, luaK_numberK(fs, 1));
++ luaK_reserveregs(fs, 1);
++ }
++ forbody(ls, base, line, 1, 1);
++}
++
++
++static void forlist (LexState *ls, TString *indexname) {
++ /* forlist -> NAME {,NAME} IN explist1 forbody */
++ FuncState *fs = ls->fs;
++ expdesc e;
++ int nvars = 0;
++ int line;
++ int base = fs->freereg;
++ /* create control variables */
++ new_localvarliteral(ls, "(for generator)", nvars++);
++ new_localvarliteral(ls, "(for state)", nvars++);
++ new_localvarliteral(ls, "(for control)", nvars++);
++ /* create declared variables */
++ new_localvar(ls, indexname, nvars++);
++ while (testnext(ls, ','))
++ new_localvar(ls, str_checkname(ls), nvars++);
++ checknext(ls, TK_IN);
++ line = ls->linenumber;
++ adjust_assign(ls, 3, explist1(ls, &e), &e);
++ luaK_checkstack(fs, 3); /* extra space to call generator */
++ forbody(ls, base, line, nvars - 3, 0);
++}
++
++
++static void forstat (LexState *ls, int line) {
++ /* forstat -> FOR (fornum | forlist) END */
++ FuncState *fs = ls->fs;
++ TString *varname;
++ BlockCnt bl;
++ enterblock(fs, &bl, 1); /* scope for loop and control variables */
++ luaX_next(ls); /* skip `for' */
++ varname = str_checkname(ls); /* first variable name */
++ switch (ls->t.token) {
++ case '=': fornum(ls, varname, line); break;
++ case ',': case TK_IN: forlist(ls, varname); break;
++ default: luaX_syntaxerror(ls, LUA_QL("=") " or " LUA_QL("in") " expected");
++ }
++ check_match(ls, TK_END, TK_FOR, line);
++ leaveblock(fs); /* loop scope (`break' jumps to this point) */
++}
++
++
++static int test_then_block (LexState *ls) {
++ /* test_then_block -> [IF | ELSEIF] cond THEN block */
++ int condexit;
++ luaX_next(ls); /* skip IF or ELSEIF */
++ condexit = cond(ls);
++ checknext(ls, TK_THEN);
++ block(ls); /* `then' part */
++ return condexit;
++}
++
++
++static void ifstat (LexState *ls, int line) {
++ /* ifstat -> IF cond THEN block {ELSEIF cond THEN block} [ELSE block] END */
++ FuncState *fs = ls->fs;
++ int flist;
++ int escapelist = NO_JUMP;
++ flist = test_then_block(ls); /* IF cond THEN block */
++ while (ls->t.token == TK_ELSEIF) {
++ luaK_concat(fs, &escapelist, luaK_jump(fs));
++ luaK_patchtohere(fs, flist);
++ flist = test_then_block(ls); /* ELSEIF cond THEN block */
++ }
++ if (ls->t.token == TK_ELSE) {
++ luaK_concat(fs, &escapelist, luaK_jump(fs));
++ luaK_patchtohere(fs, flist);
++ luaX_next(ls); /* skip ELSE (after patch, for correct line info) */
++ block(ls); /* `else' part */
++ }
++ else
++ luaK_concat(fs, &escapelist, flist);
++ luaK_patchtohere(fs, escapelist);
++ check_match(ls, TK_END, TK_IF, line);
++}
++
++
++static void localfunc (LexState *ls) {
++ expdesc v, b;
++ FuncState *fs = ls->fs;
++ new_localvar(ls, str_checkname(ls), 0);
++ init_exp(&v, VLOCAL, fs->freereg);
++ luaK_reserveregs(fs, 1);
++ adjustlocalvars(ls, 1);
++ body(ls, &b, 0, ls->linenumber);
++ luaK_storevar(fs, &v, &b);
++ /* debug information will only see the variable after this point! */
++ getlocvar(fs, fs->nactvar - 1).startpc = fs->pc;
++}
++
++
++static void localstat (LexState *ls) {
++ /* stat -> LOCAL NAME {`,' NAME} [`=' explist1] */
++ int nvars = 0;
++ int nexps;
++ expdesc e;
++ do {
++ new_localvar(ls, str_checkname(ls), nvars++);
++ } while (testnext(ls, ','));
++ if (testnext(ls, '='))
++ nexps = explist1(ls, &e);
++ else {
++ e.k = VVOID;
++ nexps = 0;
++ }
++ adjust_assign(ls, nvars, nexps, &e);
++ adjustlocalvars(ls, nvars);
++}
++
++
++static int funcname (LexState *ls, expdesc *v) {
++ /* funcname -> NAME {field} [`:' NAME] */
++ int needself = 0;
++ singlevar(ls, v);
++ while (ls->t.token == '.')
++ field(ls, v);
++ if (ls->t.token == ':') {
++ needself = 1;
++ field(ls, v);
++ }
++ return needself;
++}
++
++
++static void funcstat (LexState *ls, int line) {
++ /* funcstat -> FUNCTION funcname body */
++ int needself;
++ expdesc v, b;
++ luaX_next(ls); /* skip FUNCTION */
++ needself = funcname(ls, &v);
++ body(ls, &b, needself, line);
++ luaK_storevar(ls->fs, &v, &b);
++ luaK_fixline(ls->fs, line); /* definition `happens' in the first line */
++}
++
++
++static void exprstat (LexState *ls) {
++ /* stat -> func | assignment */
++ FuncState *fs = ls->fs;
++ struct LHS_assign v;
++ primaryexp(ls, &v.v);
++ if (v.v.k == VCALL) /* stat -> func */
++ SETARG_C(getcode(fs, &v.v), 1); /* call statement uses no results */
++ else { /* stat -> assignment */
++ v.prev = NULL;
++ assignment(ls, &v, 1);
++ }
++}
++
++
++static void retstat (LexState *ls) {
++ /* stat -> RETURN explist */
++ FuncState *fs = ls->fs;
++ expdesc e;
++ int first, nret; /* registers with returned values */
++ luaX_next(ls); /* skip RETURN */
++ if (block_follow(ls->t.token) || ls->t.token == ';')
++ first = nret = 0; /* return no values */
++ else {
++ nret = explist1(ls, &e); /* optional return values */
++ if (hasmultret(e.k)) {
++ luaK_setmultret(fs, &e);
++ if (e.k == VCALL && nret == 1) { /* tail call? */
++ SET_OPCODE(getcode(fs,&e), OP_TAILCALL);
++ lua_assert(GETARG_A(getcode(fs,&e)) == fs->nactvar);
++ }
++ first = fs->nactvar;
++ nret = LUA_MULTRET; /* return all values */
++ }
++ else {
++ if (nret == 1) /* only one single value? */
++ first = luaK_exp2anyreg(fs, &e);
++ else {
++ luaK_exp2nextreg(fs, &e); /* values must go to the `stack' */
++ first = fs->nactvar; /* return all `active' values */
++ lua_assert(nret == fs->freereg - first);
++ }
++ }
++ }
++ luaK_ret(fs, first, nret);
++}
++
++
++static int statement (LexState *ls) {
++ int line = ls->linenumber; /* may be needed for error messages */
++ switch (ls->t.token) {
++ case TK_IF: { /* stat -> ifstat */
++ ifstat(ls, line);
++ return 0;
++ }
++ case TK_WHILE: { /* stat -> whilestat */
++ whilestat(ls, line);
++ return 0;
++ }
++ case TK_DO: { /* stat -> DO block END */
++ luaX_next(ls); /* skip DO */
++ block(ls);
++ check_match(ls, TK_END, TK_DO, line);
++ return 0;
++ }
++ case TK_FOR: { /* stat -> forstat */
++ forstat(ls, line);
++ return 0;
++ }
++ case TK_REPEAT: { /* stat -> repeatstat */
++ repeatstat(ls, line);
++ return 0;
++ }
++ case TK_FUNCTION: {
++ funcstat(ls, line); /* stat -> funcstat */
++ return 0;
++ }
++ case TK_LOCAL: { /* stat -> localstat */
++ luaX_next(ls); /* skip LOCAL */
++ if (testnext(ls, TK_FUNCTION)) /* local function? */
++ localfunc(ls);
++ else
++ localstat(ls);
++ return 0;
++ }
++ case TK_RETURN: { /* stat -> retstat */
++ retstat(ls);
++ return 1; /* must be last statement */
++ }
++ case TK_BREAK: { /* stat -> breakstat */
++ luaX_next(ls); /* skip BREAK */
++ breakstat(ls);
++ return 1; /* must be last statement */
++ }
++ default: {
++ exprstat(ls);
++ return 0; /* to avoid warnings */
++ }
++ }
++}
++
++
++static void chunk (LexState *ls) {
++ /* chunk -> { stat [`;'] } */
++ int islast = 0;
++ enterlevel(ls);
++ while (!islast && !block_follow(ls->t.token)) {
++ islast = statement(ls);
++ testnext(ls, ';');
++ lua_assert(ls->fs->f->maxstacksize >= ls->fs->freereg &&
++ ls->fs->freereg >= ls->fs->nactvar);
++ ls->fs->freereg = ls->fs->nactvar; /* free registers */
++ }
++ leavelevel(ls);
++}
++
++/* }====================================================================== */
+--- /dev/null
++++ b/extensions/LUA/lua/lparser.h
+@@ -0,0 +1,82 @@
++/*
++** $Id: lparser.h,v 1.57.1.1 2007/12/27 13:02:25 roberto Exp $
++** Lua Parser
++** See Copyright Notice in lua.h
++*/
++
++#ifndef lparser_h
++#define lparser_h
++
++#include "llimits.h"
++#include "lobject.h"
++#include "lzio.h"
++
++
++/*
++** Expression descriptor
++*/
++
++typedef enum {
++ VVOID, /* no value */
++ VNIL,
++ VTRUE,
++ VFALSE,
++ VK, /* info = index of constant in `k' */
++ VKNUM, /* nval = numerical value */
++ VLOCAL, /* info = local register */
++ VUPVAL, /* info = index of upvalue in `upvalues' */
++ VGLOBAL, /* info = index of table; aux = index of global name in `k' */
++ VINDEXED, /* info = table register; aux = index register (or `k') */
++ VJMP, /* info = instruction pc */
++ VRELOCABLE, /* info = instruction pc */
++ VNONRELOC, /* info = result register */
++ VCALL, /* info = instruction pc */
++ VVARARG /* info = instruction pc */
++} expkind;
++
++typedef struct expdesc {
++ expkind k;
++ union {
++ struct { int info, aux; } s;
++ lua_Number nval;
++ } u;
++ int t; /* patch list of `exit when true' */
++ int f; /* patch list of `exit when false' */
++} expdesc;
++
++
++typedef struct upvaldesc {
++ lu_byte k;
++ lu_byte info;
++} upvaldesc;
++
++
++struct BlockCnt; /* defined in lparser.c */
++
++
++/* state needed to generate code for a given function */
++typedef struct FuncState {
++ Proto *f; /* current function header */
++ Table *h; /* table to find (and reuse) elements in `k' */
++ struct FuncState *prev; /* enclosing function */
++ struct LexState *ls; /* lexical state */
++ struct lua_State *L; /* copy of the Lua state */
++ struct BlockCnt *bl; /* chain of current blocks */
++ int pc; /* next position to code (equivalent to `ncode') */
++ int lasttarget; /* `pc' of last `jump target' */
++ int jpc; /* list of pending jumps to `pc' */
++ int freereg; /* first free register */
++ int nk; /* number of elements in `k' */
++ int np; /* number of elements in `p' */
++ short nlocvars; /* number of elements in `locvars' */
++ lu_byte nactvar; /* number of active local variables */
++ upvaldesc upvalues[LUAI_MAXUPVALUES]; /* upvalues */
++ unsigned short actvar[LUAI_MAXVARS]; /* declared-variable stack */
++} FuncState;
++
++
++LUAI_FUNC Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff,
++ const char *name);
++
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/lstate.c
+@@ -0,0 +1,214 @@
++/*
++** $Id: lstate.c,v 2.36.1.2 2008/01/03 15:20:39 roberto Exp $
++** Global State
++** See Copyright Notice in lua.h
++*/
++
++
++#include <stddef.h>
++
++#define lstate_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "ldebug.h"
++#include "ldo.h"
++#include "lfunc.h"
++#include "lgc.h"
++#include "llex.h"
++#include "lmem.h"
++#include "lstate.h"
++#include "lstring.h"
++#include "ltable.h"
++#include "ltm.h"
++
++
++#define state_size(x) (sizeof(x) + LUAI_EXTRASPACE)
++#define fromstate(l) (cast(lu_byte *, (l)) - LUAI_EXTRASPACE)
++#define tostate(l) (cast(lua_State *, cast(lu_byte *, l) + LUAI_EXTRASPACE))
++
++
++/*
++** Main thread combines a thread state and the global state
++*/
++typedef struct LG {
++ lua_State l;
++ global_State g;
++} LG;
++
++
++
++static void stack_init (lua_State *L1, lua_State *L) {
++ /* initialize CallInfo array */
++ L1->base_ci = luaM_newvector(L, BASIC_CI_SIZE, CallInfo);
++ L1->ci = L1->base_ci;
++ L1->size_ci = BASIC_CI_SIZE;
++ L1->end_ci = L1->base_ci + L1->size_ci - 1;
++ /* initialize stack array */
++ L1->stack = luaM_newvector(L, BASIC_STACK_SIZE + EXTRA_STACK, TValue);
++ L1->stacksize = BASIC_STACK_SIZE + EXTRA_STACK;
++ L1->top = L1->stack;
++ L1->stack_last = L1->stack+(L1->stacksize - EXTRA_STACK)-1;
++ /* initialize first ci */
++ L1->ci->func = L1->top;
++ setnilvalue(L1->top++); /* `function' entry for this `ci' */
++ L1->base = L1->ci->base = L1->top;
++ L1->ci->top = L1->top + LUA_MINSTACK;
++}
++
++
++static void freestack (lua_State *L, lua_State *L1) {
++ luaM_freearray(L, L1->base_ci, L1->size_ci, CallInfo);
++ luaM_freearray(L, L1->stack, L1->stacksize, TValue);
++}
++
++
++/*
++** open parts that may cause memory-allocation errors
++*/
++static void f_luaopen (lua_State *L, void *ud) {
++ global_State *g = G(L);
++ UNUSED(ud);
++ stack_init(L, L); /* init stack */
++ sethvalue(L, gt(L), luaH_new(L, 0, 2)); /* table of globals */
++ sethvalue(L, registry(L), luaH_new(L, 0, 2)); /* registry */
++ luaS_resize(L, MINSTRTABSIZE); /* initial size of string table */
++ luaT_init(L);
++ luaX_init(L);
++ luaS_fix(luaS_newliteral(L, MEMERRMSG));
++ g->GCthreshold = 4*g->totalbytes;
++}
++
++
++static void preinit_state (lua_State *L, global_State *g) {
++ G(L) = g;
++ L->stack = NULL;
++ L->stacksize = 0;
++ L->errorJmp = NULL;
++ L->hook = NULL;
++ L->hookmask = 0;
++ L->basehookcount = 0;
++ L->allowhook = 1;
++ resethookcount(L);
++ L->openupval = NULL;
++ L->size_ci = 0;
++ L->nCcalls = L->baseCcalls = 0;
++ L->status = 0;
++ L->base_ci = L->ci = NULL;
++ L->savedpc = NULL;
++ L->errfunc = 0;
++ setnilvalue(gt(L));
++}
++
++
++static void close_state (lua_State *L) {
++ global_State *g = G(L);
++ luaF_close(L, L->stack); /* close all upvalues for this thread */
++ luaC_freeall(L); /* collect all objects */
++ lua_assert(g->rootgc == obj2gco(L));
++ lua_assert(g->strt.nuse == 0);
++ luaM_freearray(L, G(L)->strt.hash, G(L)->strt.size, TString *);
++ luaZ_freebuffer(L, &g->buff);
++ freestack(L, L);
++ lua_assert(g->totalbytes == sizeof(LG));
++ (*g->frealloc)(g->ud, fromstate(L), state_size(LG), 0);
++}
++
++
++lua_State *luaE_newthread (lua_State *L) {
++ lua_State *L1 = tostate(luaM_malloc(L, state_size(lua_State)));
++ luaC_link(L, obj2gco(L1), LUA_TTHREAD);
++ preinit_state(L1, G(L));
++ stack_init(L1, L); /* init stack */
++ setobj2n(L, gt(L1), gt(L)); /* share table of globals */
++ L1->hookmask = L->hookmask;
++ L1->basehookcount = L->basehookcount;
++ L1->hook = L->hook;
++ resethookcount(L1);
++ lua_assert(iswhite(obj2gco(L1)));
++ return L1;
++}
++
++
++void luaE_freethread (lua_State *L, lua_State *L1) {
++ luaF_close(L1, L1->stack); /* close all upvalues for this thread */
++ lua_assert(L1->openupval == NULL);
++ luai_userstatefree(L1);
++ freestack(L, L1);
++ luaM_freemem(L, fromstate(L1), state_size(lua_State));
++}
++
++
++LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) {
++ int i;
++ lua_State *L;
++ global_State *g;
++ void *l = (*f)(ud, NULL, 0, state_size(LG));
++ if (l == NULL) return NULL;
++ L = tostate(l);
++ g = &((LG *)L)->g;
++ L->next = NULL;
++ L->tt = LUA_TTHREAD;
++ g->currentwhite = bit2mask(WHITE0BIT, FIXEDBIT);
++ L->marked = luaC_white(g);
++ set2bits(L->marked, FIXEDBIT, SFIXEDBIT);
++ preinit_state(L, g);
++ g->frealloc = f;
++ g->ud = ud;
++ g->mainthread = L;
++ g->uvhead.u.l.prev = &g->uvhead;
++ g->uvhead.u.l.next = &g->uvhead;
++ g->GCthreshold = 0; /* mark it as unfinished state */
++ g->strt.size = 0;
++ g->strt.nuse = 0;
++ g->strt.hash = NULL;
++ setnilvalue(registry(L));
++ luaZ_initbuffer(L, &g->buff);
++ g->panic = NULL;
++ g->gcstate = GCSpause;
++ g->rootgc = obj2gco(L);
++ g->sweepstrgc = 0;
++ g->sweepgc = &g->rootgc;
++ g->gray = NULL;
++ g->grayagain = NULL;
++ g->weak = NULL;
++ g->tmudata = NULL;
++ g->totalbytes = sizeof(LG);
++ g->gcpause = LUAI_GCPAUSE;
++ g->gcstepmul = LUAI_GCMUL;
++ g->gcdept = 0;
++ for (i=0; i<NUM_TAGS; i++) g->mt[i] = NULL;
++ if (luaD_rawrunprotected(L, f_luaopen, NULL) != 0) {
++ /* memory allocation error: free partial state */
++ close_state(L);
++ L = NULL;
++ }
++ else
++ luai_userstateopen(L);
++ return L;
++}
++
++
++static void callallgcTM (lua_State *L, void *ud) {
++ UNUSED(ud);
++ luaC_callGCTM(L); /* call GC metamethods for all udata */
++}
++
++
++LUA_API void lua_close (lua_State *L) {
++ L = G(L)->mainthread; /* only the main thread can be closed */
++ lua_lock(L);
++ luaF_close(L, L->stack); /* close all upvalues for this thread */
++ luaC_separateudata(L, 1); /* separate udata that have GC metamethods */
++ L->errfunc = 0; /* no error function during GC metamethods */
++ do { /* repeat until no more errors */
++ L->ci = L->base_ci;
++ L->base = L->top = L->ci->base;
++ L->nCcalls = L->baseCcalls = 0;
++ } while (luaD_rawrunprotected(L, callallgcTM, NULL) != 0);
++ lua_assert(G(L)->tmudata == NULL);
++ luai_userstateclose(L);
++ close_state(L);
++}
++
+--- /dev/null
++++ b/extensions/LUA/lua/lstate.h
+@@ -0,0 +1,169 @@
++/*
++** $Id: lstate.h,v 2.24.1.2 2008/01/03 15:20:39 roberto Exp $
++** Global State
++** See Copyright Notice in lua.h
++*/
++
++#ifndef lstate_h
++#define lstate_h
++
++#include "lua.h"
++
++#include "lobject.h"
++#include "ltm.h"
++#include "lzio.h"
++
++
++
++struct lua_longjmp; /* defined in ldo.c */
++
++
++/* table of globals */
++#define gt(L) (&L->l_gt)
++
++/* registry */
++#define registry(L) (&G(L)->l_registry)
++
++
++/* extra stack space to handle TM calls and some other extras */
++#define EXTRA_STACK 5
++
++
++#define BASIC_CI_SIZE 8
++
++#define BASIC_STACK_SIZE (2*LUA_MINSTACK)
++
++
++
++typedef struct stringtable {
++ GCObject **hash;
++ lu_int32 nuse; /* number of elements */
++ int size;
++} stringtable;
++
++
++/*
++** informations about a call
++*/
++typedef struct CallInfo {
++ StkId base; /* base for this function */
++ StkId func; /* function index in the stack */
++ StkId top; /* top for this function */
++ const Instruction *savedpc;
++ int nresults; /* expected number of results from this function */
++ int tailcalls; /* number of tail calls lost under this entry */
++} CallInfo;
++
++
++
++#define curr_func(L) (clvalue(L->ci->func))
++#define ci_func(ci) (clvalue((ci)->func))
++#define f_isLua(ci) (!ci_func(ci)->c.isC)
++#define isLua(ci) (ttisfunction((ci)->func) && f_isLua(ci))
++
++
++/*
++** `global state', shared by all threads of this state
++*/
++typedef struct global_State {
++ stringtable strt; /* hash table for strings */
++ lua_Alloc frealloc; /* function to reallocate memory */
++ void *ud; /* auxiliary data to `frealloc' */
++ lu_byte currentwhite;
++ lu_byte gcstate; /* state of garbage collector */
++ int sweepstrgc; /* position of sweep in `strt' */
++ GCObject *rootgc; /* list of all collectable objects */
++ GCObject **sweepgc; /* position of sweep in `rootgc' */
++ GCObject *gray; /* list of gray objects */
++ GCObject *grayagain; /* list of objects to be traversed atomically */
++ GCObject *weak; /* list of weak tables (to be cleared) */
++ GCObject *tmudata; /* last element of list of userdata to be GC */
++ Mbuffer buff; /* temporary buffer for string concatentation */
++ lu_mem GCthreshold;
++ lu_mem totalbytes; /* number of bytes currently allocated */
++ lu_mem estimate; /* an estimate of number of bytes actually in use */
++ lu_mem gcdept; /* how much GC is `behind schedule' */
++ int gcpause; /* size of pause between successive GCs */
++ int gcstepmul; /* GC `granularity' */
++ lua_CFunction panic; /* to be called in unprotected errors */
++ TValue l_registry;
++ struct lua_State *mainthread;
++ UpVal uvhead; /* head of double-linked list of all open upvalues */
++ struct Table *mt[NUM_TAGS]; /* metatables for basic types */
++ TString *tmname[TM_N]; /* array with tag-method names */
++} global_State;
++
++
++/*
++** `per thread' state
++*/
++struct lua_State {
++ CommonHeader;
++ lu_byte status;
++ StkId top; /* first free slot in the stack */
++ StkId base; /* base of current function */
++ global_State *l_G;
++ CallInfo *ci; /* call info for current function */
++ const Instruction *savedpc; /* `savedpc' of current function */
++ StkId stack_last; /* last free slot in the stack */
++ StkId stack; /* stack base */
++ CallInfo *end_ci; /* points after end of ci array*/
++ CallInfo *base_ci; /* array of CallInfo's */
++ int stacksize;
++ int size_ci; /* size of array `base_ci' */
++ unsigned short nCcalls; /* number of nested C calls */
++ unsigned short baseCcalls; /* nested C calls when resuming coroutine */
++ lu_byte hookmask;
++ lu_byte allowhook;
++ int basehookcount;
++ int hookcount;
++ lua_Hook hook;
++ TValue l_gt; /* table of globals */
++ TValue env; /* temporary place for environments */
++ GCObject *openupval; /* list of open upvalues in this stack */
++ GCObject *gclist;
++ struct lua_longjmp *errorJmp; /* current error recover point */
++ ptrdiff_t errfunc; /* current error handling function (stack index) */
++};
++
++
++#define G(L) (L->l_G)
++
++
++/*
++** Union of all collectable objects
++*/
++union GCObject {
++ GCheader gch;
++ union TString ts;
++ union Udata u;
++ union Closure cl;
++ struct Table h;
++ struct Proto p;
++ struct UpVal uv;
++ struct lua_State th; /* thread */
++};
++
++
++/* macros to convert a GCObject into a specific value */
++#define rawgco2ts(o) check_exp((o)->gch.tt == LUA_TSTRING, &((o)->ts))
++#define gco2ts(o) (&rawgco2ts(o)->tsv)
++#define rawgco2u(o) check_exp((o)->gch.tt == LUA_TUSERDATA, &((o)->u))
++#define gco2u(o) (&rawgco2u(o)->uv)
++#define gco2cl(o) check_exp((o)->gch.tt == LUA_TFUNCTION, &((o)->cl))
++#define gco2h(o) check_exp((o)->gch.tt == LUA_TTABLE, &((o)->h))
++#define gco2p(o) check_exp((o)->gch.tt == LUA_TPROTO, &((o)->p))
++#define gco2uv(o) check_exp((o)->gch.tt == LUA_TUPVAL, &((o)->uv))
++#define ngcotouv(o) \
++ check_exp((o) == NULL || (o)->gch.tt == LUA_TUPVAL, &((o)->uv))
++#define gco2th(o) check_exp((o)->gch.tt == LUA_TTHREAD, &((o)->th))
++
++/* macro to convert any Lua object into a GCObject */
++#define obj2gco(v) (cast(GCObject *, (v)))
++
++
++LUAI_FUNC lua_State *luaE_newthread (lua_State *L);
++LUAI_FUNC void luaE_freethread (lua_State *L, lua_State *L1);
++
++#endif
++
+--- /dev/null
++++ b/extensions/LUA/lua/lstring.c
+@@ -0,0 +1,110 @@
++/*
++** $Id: lstring.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $
++** String table (keeps all strings handled by Lua)
++** See Copyright Notice in lua.h
++*/
++
++#include <string.h>
++
++#define lstring_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "lmem.h"
++#include "lobject.h"
++#include "lstate.h"
++#include "lstring.h"
++
++
++
++void luaS_resize (lua_State *L, int newsize) {
++ GCObject **newhash;
++ stringtable *tb;
++ int i;
++ if (G(L)->gcstate == GCSsweepstring)
++ return; /* cannot resize during GC traverse */
++ newhash = luaM_newvector(L, newsize, GCObject *);
++ tb = &G(L)->strt;
++ for (i=0; i<newsize; i++) newhash[i] = NULL;
++ /* rehash */
++ for (i=0; i<tb->size; i++) {
++ GCObject *p = tb->hash[i];
++ while (p) { /* for each node in the list */
++ GCObject *next = p->gch.next; /* save next */
++ unsigned int h = gco2ts(p)->hash;
++ int h1 = lmod(h, newsize); /* new position */
++ lua_assert(cast_int(h%newsize) == lmod(h, newsize));
++ p->gch.next = newhash[h1]; /* chain it */
++ newhash[h1] = p;
++ p = next;
++ }
++ }
++ luaM_freearray(L, tb->hash, tb->size, TString *);
++ tb->size = newsize;
++ tb->hash = newhash;
++}
++
++
++static TString *newlstr (lua_State *L, const char *str, size_t l,
++ unsigned int h) {
++ TString *ts;
++ stringtable *tb;
++ if (l+1 > (MAX_SIZET - sizeof(TString))/sizeof(char))
++ luaM_toobig(L);
++ ts = cast(TString *, luaM_malloc(L, (l+1)*sizeof(char)+sizeof(TString)));
++ ts->tsv.len = l;
++ ts->tsv.hash = h;
++ ts->tsv.marked = luaC_white(G(L));
++ ts->tsv.tt = LUA_TSTRING;
++ ts->tsv.reserved = 0;
++ memcpy(ts+1, str, l*sizeof(char));
++ ((char *)(ts+1))[l] = '\0'; /* ending 0 */
++ tb = &G(L)->strt;
++ h = lmod(h, tb->size);
++ ts->tsv.next = tb->hash[h]; /* chain new entry */
++ tb->hash[h] = obj2gco(ts);
++ tb->nuse++;
++ if (tb->nuse > cast(lu_int32, tb->size) && tb->size <= MAX_INT/2)
++ luaS_resize(L, tb->size*2); /* too crowded */
++ return ts;
++}
++
++
++TString *luaS_newlstr (lua_State *L, const char *str, size_t l) {
++ GCObject *o;
++ unsigned int h = cast(unsigned int, l); /* seed */
++ size_t step = (l>>5)+1; /* if string is too long, don't hash all its chars */
++ size_t l1;
++ for (l1=l; l1>=step; l1-=step) /* compute hash */
++ h = h ^ ((h<<5)+(h>>2)+cast(unsigned char, str[l1-1]));
++ for (o = G(L)->strt.hash[lmod(h, G(L)->strt.size)];
++ o != NULL;
++ o = o->gch.next) {
++ TString *ts = rawgco2ts(o);
++ if (ts->tsv.len == l && (memcmp(str, getstr(ts), l) == 0)) {
++ /* string may be dead */
++ if (isdead(G(L), o)) changewhite(o);
++ return ts;
++ }
++ }
++ return newlstr(L, str, l, h); /* not found */
++}
++
++
++Udata *luaS_newudata (lua_State *L, size_t s, Table *e) {
++ Udata *u;
++ if (s > MAX_SIZET - sizeof(Udata))
++ luaM_toobig(L);
++ u = cast(Udata *, luaM_malloc(L, s + sizeof(Udata)));
++ u->uv.marked = luaC_white(G(L)); /* is not finalized */
++ u->uv.tt = LUA_TUSERDATA;
++ u->uv.len = s;
++ u->uv.metatable = NULL;
++ u->uv.env = e;
++ /* chain it on udata list (after main thread) */
++ u->uv.next = G(L)->mainthread->next;
++ G(L)->mainthread->next = obj2gco(u);
++ return u;
++}
++
+--- /dev/null
++++ b/extensions/LUA/lua/lstring.h
+@@ -0,0 +1,31 @@
++/*
++** $Id: lstring.h,v 1.43.1.1 2007/12/27 13:02:25 roberto Exp $
++** String table (keep all strings handled by Lua)
++** See Copyright Notice in lua.h
++*/
++
++#ifndef lstring_h
++#define lstring_h
++
++
++#include "lgc.h"
++#include "lobject.h"
++#include "lstate.h"
++
++
++#define sizestring(s) (sizeof(union TString)+((s)->len+1)*sizeof(char))
++
++#define sizeudata(u) (sizeof(union Udata)+(u)->len)
++
++#define luaS_new(L, s) (luaS_newlstr(L, s, strlen(s)))
++#define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \
++ (sizeof(s)/sizeof(char))-1))
++
++#define luaS_fix(s) l_setbit((s)->tsv.marked, FIXEDBIT)
++
++LUAI_FUNC void luaS_resize (lua_State *L, int newsize);
++LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, Table *e);
++LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l);
++
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/lstrlib.c
+@@ -0,0 +1,883 @@
++/*
++** $Id: lstrlib.c,v 1.132.1.4 2008/07/11 17:27:21 roberto Exp $
++** Standard library for string operations and pattern-matching
++** See Copyright Notice in lua.h
++*/
++
++
++#include <ctype.h>
++#include <stddef.h>
++#include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
++
++#define lstrlib_c
++#define LUA_LIB
++
++#include "lua.h"
++
++#include "lauxlib.h"
++#include "lualib.h"
++
++
++/* macro to `unsign' a character */
++#define uchar(c) ((unsigned char)(c))
++
++
++
++static int str_len (lua_State *L) {
++ size_t l;
++ luaL_checklstring(L, 1, &l);
++ lua_pushinteger(L, l);
++ return 1;
++}
++
++
++static ptrdiff_t posrelat (ptrdiff_t pos, size_t len) {
++ /* relative string position: negative means back from end */
++ if (pos < 0) pos += (ptrdiff_t)len + 1;
++ return (pos >= 0) ? pos : 0;
++}
++
++
++static int str_sub (lua_State *L) {
++ size_t l;
++ const char *s = luaL_checklstring(L, 1, &l);
++ ptrdiff_t start = posrelat(luaL_checkinteger(L, 2), l);
++ ptrdiff_t end = posrelat(luaL_optinteger(L, 3, -1), l);
++ if (start < 1) start = 1;
++ if (end > (ptrdiff_t)l) end = (ptrdiff_t)l;
++ if (start <= end)
++ lua_pushlstring(L, s+start-1, end-start+1);
++ else lua_pushliteral(L, "");
++ return 1;
++}
++
++
++static int str_reverse (lua_State *L) {
++ size_t l;
++ const char *s = luaL_checklstring(L, 1, &l);
++ luaL_Buffer *b = (luaL_Buffer *)kmalloc(sizeof(luaL_Buffer) + BUFSIZ, GFP_ATOMIC);
++ if(!b) luaL_error(L, "str_reverse: cannot allocate memory");
++ luaL_buffinit(L, b);
++ while (l--) luaL_addchar(b, s[l]);
++ luaL_pushresult(b);
++ kfree(b);
++ return 1;
++}
++
++
++static int str_lower (lua_State *L) {
++ size_t l;
++ size_t i;
++ const char *s = luaL_checklstring(L, 1, &l);
++ luaL_Buffer *b = (luaL_Buffer *)kmalloc(sizeof(luaL_Buffer) + BUFSIZ, GFP_ATOMIC);
++ if(!b) luaL_error(L, "str_lower: cannot allocate memory");
++ luaL_buffinit(L, b);
++ for (i=0; i<l; i++)
++ luaL_addchar(b, tolower(uchar(s[i])));
++ luaL_pushresult(b);
++ kfree(b);
++ return 1;
++}
++
++
++static int str_upper (lua_State *L) {
++ size_t l;
++ size_t i;
++ const char *s = luaL_checklstring(L, 1, &l);
++ luaL_Buffer *b = (luaL_Buffer *)kmalloc(sizeof(luaL_Buffer) + BUFSIZ, GFP_ATOMIC);
++ if(!b) luaL_error(L, "str_upper: cannot allocate memory");
++ luaL_buffinit(L, b);
++ for (i=0; i<l; i++)
++ luaL_addchar(b, toupper(uchar(s[i])));
++ luaL_pushresult(b);
++ kfree(b);
++ return 1;
++}
++
++static int str_rep (lua_State *L) {
++ size_t l;
++ const char *s = luaL_checklstring(L, 1, &l);
++ int n = luaL_checkint(L, 2);
++ luaL_Buffer *b = (luaL_Buffer *)kmalloc(sizeof(luaL_Buffer) + BUFSIZ, GFP_ATOMIC);
++ if(!b) luaL_error(L, "str_rep: cannot allocate memory");
++ luaL_buffinit(L, b);
++ while (n-- > 0)
++ luaL_addlstring(b, s, l);
++ luaL_pushresult(b);
++ kfree(b);
++ return 1;
++}
++
++
++static int str_byte (lua_State *L) {
++ size_t l;
++ const char *s = luaL_checklstring(L, 1, &l);
++ ptrdiff_t posi = posrelat(luaL_optinteger(L, 2, 1), l);
++ ptrdiff_t pose = posrelat(luaL_optinteger(L, 3, posi), l);
++ int n, i;
++ if (posi <= 0) posi = 1;
++ if ((size_t)pose > l) pose = l;
++ if (posi > pose) return 0; /* empty interval; return no values */
++ n = (int)(pose - posi + 1);
++ if (posi + n <= pose) /* overflow? */
++ luaL_error(L, "string slice too long");
++ luaL_checkstack(L, n, "string slice too long");
++ for (i=0; i<n; i++)
++ lua_pushinteger(L, uchar(s[posi+i-1]));
++ return n;
++}
++
++
++static int str_char (lua_State *L) {
++ int n = lua_gettop(L); /* number of arguments */
++ int i;
++ luaL_Buffer *b = (luaL_Buffer *)kmalloc(sizeof(luaL_Buffer) + BUFSIZ, GFP_ATOMIC);
++ if(!b) luaL_error(L, "str_char: cannot allocate memory");
++ luaL_buffinit(L, b);
++ for (i=1; i<=n; i++) {
++ int c = luaL_checkint(L, i);
++ luaL_argcheck(L, uchar(c) == c, i, "invalid value");
++ luaL_addchar(b, uchar(c));
++ }
++ luaL_pushresult(b);
++ kfree(b);
++ return 1;
++}
++
++
++static int writer (lua_State *L, const void* b, size_t size, void* B) {
++ (void)L;
++ luaL_addlstring((luaL_Buffer*) B, (const char *)b, size);
++ return 0;
++}
++
++
++static int str_dump (lua_State *L) {
++ luaL_Buffer *b = (luaL_Buffer *)kmalloc(sizeof(luaL_Buffer) + BUFSIZ, GFP_ATOMIC);
++ if(!b) luaL_error(L, "str_dump: cannot allocate memory");
++ luaL_checktype(L, 1, LUA_TFUNCTION);
++ lua_settop(L, 1);
++ luaL_buffinit(L,b);
++ if (lua_dump(L, writer, b) != 0){
++ kfree(b);
++ luaL_error(L, "unable to dump given function");
++ }
++
++ luaL_pushresult(b);
++ kfree(b);
++ return 1;
++}
++
++
++
++/*
++** {======================================================
++** PATTERN MATCHING
++** =======================================================
++*/
++
++
++#define CAP_UNFINISHED (-1)
++#define CAP_POSITION (-2)
++
++typedef struct MatchState {
++ const char *src_init; /* init of source string */
++ const char *src_end; /* end (`\0') of source string */
++ lua_State *L;
++ int level; /* total number of captures (finished or unfinished) */
++ struct {
++ const char *init;
++ ptrdiff_t len;
++ } capture[LUA_MAXCAPTURES];
++} MatchState;
++
++
++#define L_ESC '%'
++#define SPECIALS "^$*+?.([%-"
++
++
++static int check_capture (MatchState *ms, int l) {
++ l -= '1';
++ if (l < 0 || l >= ms->level || ms->capture[l].len == CAP_UNFINISHED)
++ return luaL_error(ms->L, "invalid capture index");
++ return l;
++}
++
++
++static int capture_to_close (MatchState *ms) {
++ int level = ms->level;
++ for (level--; level>=0; level--)
++ if (ms->capture[level].len == CAP_UNFINISHED) return level;
++ return luaL_error(ms->L, "invalid pattern capture");
++}
++
++
++static const char *classend (MatchState *ms, const char *p) {
++ switch (*p++) {
++ case L_ESC: {
++ if (*p == '\0')
++ luaL_error(ms->L, "malformed pattern (ends with " LUA_QL("%%") ")");
++ return p+1;
++ }
++ case '[': {
++ if (*p == '^') p++;
++ do { /* look for a `]' */
++ if (*p == '\0')
++ luaL_error(ms->L, "malformed pattern (missing " LUA_QL("]") ")");
++ if (*(p++) == L_ESC && *p != '\0')
++ p++; /* skip escapes (e.g. `%]') */
++ } while (*p != ']');
++ return p+1;
++ }
++ default: {
++ return p;
++ }
++ }
++}
++
++
++static int match_class (int c, int cl) {
++ int res;
++ switch (tolower(cl)) {
++ case 'a' : res = isalpha(c); break;
++ case 'c' : res = iscntrl(c); break;
++ case 'd' : res = isdigit(c); break;
++ case 'l' : res = islower(c); break;
++ case 'p' : res = ispunct(c); break;
++ case 's' : res = isspace(c); break;
++ case 'u' : res = isupper(c); break;
++ case 'w' : res = isalnum(c); break;
++ case 'x' : res = isxdigit(c); break;
++ case 'z' : res = (c == 0); break;
++ default: return (cl == c);
++ }
++ return (islower(cl) ? res : !res);
++}
++
++
++static int matchbracketclass (int c, const char *p, const char *ec) {
++ int sig = 1;
++ if (*(p+1) == '^') {
++ sig = 0;
++ p++; /* skip the `^' */
++ }
++ while (++p < ec) {
++ if (*p == L_ESC) {
++ p++;
++ if (match_class(c, uchar(*p)))
++ return sig;
++ }
++ else if ((*(p+1) == '-') && (p+2 < ec)) {
++ p+=2;
++ if (uchar(*(p-2)) <= c && c <= uchar(*p))
++ return sig;
++ }
++ else if (uchar(*p) == c) return sig;
++ }
++ return !sig;
++}
++
++
++static int singlematch (int c, const char *p, const char *ep) {
++ switch (*p) {
++ case '.': return 1; /* matches any char */
++ case L_ESC: return match_class(c, uchar(*(p+1)));
++ case '[': return matchbracketclass(c, p, ep-1);
++ default: return (uchar(*p) == c);
++ }
++}
++
++
++static const char *match (MatchState *ms, const char *s, const char *p);
++
++
++static const char *matchbalance (MatchState *ms, const char *s,
++ const char *p) {
++ if (*p == 0 || *(p+1) == 0)
++ luaL_error(ms->L, "unbalanced pattern");
++ if (*s != *p) return NULL;
++ else {
++ int b = *p;
++ int e = *(p+1);
++ int cont = 1;
++ while (++s < ms->src_end) {
++ if (*s == e) {
++ if (--cont == 0) return s+1;
++ }
++ else if (*s == b) cont++;
++ }
++ }
++ return NULL; /* string ends out of balance */
++}
++
++
++static const char *max_expand (MatchState *ms, const char *s,
++ const char *p, const char *ep) {
++ ptrdiff_t i = 0; /* counts maximum expand for item */
++ while ((s+i)<ms->src_end && singlematch(uchar(*(s+i)), p, ep))
++ i++;
++ /* keeps trying to match with the maximum repetitions */
++ while (i>=0) {
++ const char *res = match(ms, (s+i), ep+1);
++ if (res) return res;
++ i--; /* else didn't match; reduce 1 repetition to try again */
++ }
++ return NULL;
++}
++
++
++static const char *min_expand (MatchState *ms, const char *s,
++ const char *p, const char *ep) {
++ for (;;) {
++ const char *res = match(ms, s, ep+1);
++ if (res != NULL)
++ return res;
++ else if (s<ms->src_end && singlematch(uchar(*s), p, ep))
++ s++; /* try with one more repetition */
++ else return NULL;
++ }
++}
++
++
++static const char *start_capture (MatchState *ms, const char *s,
++ const char *p, int what) {
++ const char *res;
++ int level = ms->level;
++ if (level >= LUA_MAXCAPTURES) luaL_error(ms->L, "too many captures");
++ ms->capture[level].init = s;
++ ms->capture[level].len = what;
++ ms->level = level+1;
++ if ((res=match(ms, s, p)) == NULL) /* match failed? */
++ ms->level--; /* undo capture */
++ return res;
++}
++
++
++static const char *end_capture (MatchState *ms, const char *s,
++ const char *p) {
++ int l = capture_to_close(ms);
++ const char *res;
++ ms->capture[l].len = s - ms->capture[l].init; /* close capture */
++ if ((res = match(ms, s, p)) == NULL) /* match failed? */
++ ms->capture[l].len = CAP_UNFINISHED; /* undo capture */
++ return res;
++}
++
++
++static const char *match_capture (MatchState *ms, const char *s, int l) {
++ size_t len;
++ l = check_capture(ms, l);
++ len = ms->capture[l].len;
++ if ((size_t)(ms->src_end-s) >= len &&
++ memcmp(ms->capture[l].init, s, len) == 0)
++ return s+len;
++ else return NULL;
++}
++
++
++static const char *match (MatchState *ms, const char *s, const char *p) {
++ init: /* using goto's to optimize tail recursion */
++ switch (*p) {
++ case '(': { /* start capture */
++ if (*(p+1) == ')') /* position capture? */
++ return start_capture(ms, s, p+2, CAP_POSITION);
++ else
++ return start_capture(ms, s, p+1, CAP_UNFINISHED);
++ }
++ case ')': { /* end capture */
++ return end_capture(ms, s, p+1);
++ }
++ case L_ESC: {
++ switch (*(p+1)) {
++ case 'b': { /* balanced string? */
++ s = matchbalance(ms, s, p+2);
++ if (s == NULL) return NULL;
++ p+=4; goto init; /* else return match(ms, s, p+4); */
++ }
++ case 'f': { /* frontier? */
++ const char *ep; char previous;
++ p += 2;
++ if (*p != '[')
++ luaL_error(ms->L, "missing " LUA_QL("[") " after "
++ LUA_QL("%%f") " in pattern");
++ ep = classend(ms, p); /* points to what is next */
++ previous = (s == ms->src_init) ? '\0' : *(s-1);
++ if (matchbracketclass(uchar(previous), p, ep-1) ||
++ !matchbracketclass(uchar(*s), p, ep-1)) return NULL;
++ p=ep; goto init; /* else return match(ms, s, ep); */
++ }
++ default: {
++ if (isdigit(uchar(*(p+1)))) { /* capture results (%0-%9)? */
++ s = match_capture(ms, s, uchar(*(p+1)));
++ if (s == NULL) return NULL;
++ p+=2; goto init; /* else return match(ms, s, p+2) */
++ }
++ goto dflt; /* case default */
++ }
++ }
++ }
++ case '\0': { /* end of pattern */
++ return s; /* match succeeded */
++ }
++ case '$': {
++ if (*(p+1) == '\0') /* is the `$' the last char in pattern? */
++ return (s == ms->src_end) ? s : NULL; /* check end of string */
++ else goto dflt;
++ }
++ default: dflt: { /* it is a pattern item */
++ const char *ep = classend(ms, p); /* points to what is next */
++ int m = s<ms->src_end && singlematch(uchar(*s), p, ep);
++ switch (*ep) {
++ case '?': { /* optional */
++ const char *res;
++ if (m && ((res=match(ms, s+1, ep+1)) != NULL))
++ return res;
++ p=ep+1; goto init; /* else return match(ms, s, ep+1); */
++ }
++ case '*': { /* 0 or more repetitions */
++ return max_expand(ms, s, p, ep);
++ }
++ case '+': { /* 1 or more repetitions */
++ return (m ? max_expand(ms, s+1, p, ep) : NULL);
++ }
++ case '-': { /* 0 or more repetitions (minimum) */
++ return min_expand(ms, s, p, ep);
++ }
++ default: {
++ if (!m) return NULL;
++ s++; p=ep; goto init; /* else return match(ms, s+1, ep); */
++ }
++ }
++ }
++ }
++}
++
++
++
++static const char *lmemfind (const char *s1, size_t l1,
++ const char *s2, size_t l2) {
++ if (l2 == 0) return s1; /* empty strings are everywhere */
++ else if (l2 > l1) return NULL; /* avoids a negative `l1' */
++ else {
++ const char *init; /* to search for a `*s2' inside `s1' */
++ l2--; /* 1st char will be checked by `memchr' */
++ l1 = l1-l2; /* `s2' cannot be found after that */
++ while (l1 > 0 && (init = (const char *)memchr(s1, *s2, l1)) != NULL) {
++ init++; /* 1st char is already checked */
++ if (memcmp(init, s2+1, l2) == 0)
++ return init-1;
++ else { /* correct `l1' and `s1' to try again */
++ l1 -= init-s1;
++ s1 = init;
++ }
++ }
++ return NULL; /* not found */
++ }
++}
++
++
++static void push_onecapture (MatchState *ms, int i, const char *s,
++ const char *e) {
++ if (i >= ms->level) {
++ if (i == 0) /* ms->level == 0, too */
++ lua_pushlstring(ms->L, s, e - s); /* add whole match */
++ else
++ luaL_error(ms->L, "invalid capture index");
++ }
++ else {
++ ptrdiff_t l = ms->capture[i].len;
++ if (l == CAP_UNFINISHED) luaL_error(ms->L, "unfinished capture");
++ if (l == CAP_POSITION)
++ lua_pushinteger(ms->L, ms->capture[i].init - ms->src_init + 1);
++ else
++ lua_pushlstring(ms->L, ms->capture[i].init, l);
++ }
++}
++
++
++static int push_captures (MatchState *ms, const char *s, const char *e) {
++ int i;
++ int nlevels = (ms->level == 0 && s) ? 1 : ms->level;
++ luaL_checkstack(ms->L, nlevels, "too many captures");
++ for (i = 0; i < nlevels; i++)
++ push_onecapture(ms, i, s, e);
++ return nlevels; /* number of strings pushed */
++}
++
++
++static int str_find_aux (lua_State *L, int find) {
++ size_t l1, l2;
++ const char *s = luaL_checklstring(L, 1, &l1);
++ const char *p = luaL_checklstring(L, 2, &l2);
++ ptrdiff_t init = posrelat(luaL_optinteger(L, 3, 1), l1) - 1;
++ if (init < 0) init = 0;
++ else if ((size_t)(init) > l1) init = (ptrdiff_t)l1;
++ if (find && (lua_toboolean(L, 4) || /* explicit request? */
++ strpbrk(p, SPECIALS) == NULL)) { /* or no special characters? */
++ /* do a plain search */
++ const char *s2 = lmemfind(s+init, l1-init, p, l2);
++ if (s2) {
++ lua_pushinteger(L, s2-s+1);
++ lua_pushinteger(L, s2-s+l2);
++ return 2;
++ }
++ }
++ else {
++ MatchState ms;
++ int anchor = (*p == '^') ? (p++, 1) : 0;
++ const char *s1=s+init;
++ ms.L = L;
++ ms.src_init = s;
++ ms.src_end = s+l1;
++ do {
++ const char *res;
++ ms.level = 0;
++ if ((res=match(&ms, s1, p)) != NULL) {
++ if (find) {
++ lua_pushinteger(L, s1-s+1); /* start */
++ lua_pushinteger(L, res-s); /* end */
++ return push_captures(&ms, NULL, 0) + 2;
++ }
++ else
++ return push_captures(&ms, s1, res);
++ }
++ } while (s1++ < ms.src_end && !anchor);
++ }
++ lua_pushnil(L); /* not found */
++ return 1;
++}
++
++
++static int str_find (lua_State *L) {
++ return str_find_aux(L, 1);
++}
++
++
++static int str_match (lua_State *L) {
++ return str_find_aux(L, 0);
++}
++
++
++static int gmatch_aux (lua_State *L) {
++ MatchState ms;
++ size_t ls;
++ const char *s = lua_tolstring(L, lua_upvalueindex(1), &ls);
++ const char *p = lua_tostring(L, lua_upvalueindex(2));
++ const char *src;
++ ms.L = L;
++ ms.src_init = s;
++ ms.src_end = s+ls;
++ for (src = s + (size_t)lua_tointeger(L, lua_upvalueindex(3));
++ src <= ms.src_end;
++ src++) {
++ const char *e;
++ ms.level = 0;
++ if ((e = match(&ms, src, p)) != NULL) {
++ lua_Integer newstart = e-s;
++ if (e == src) newstart++; /* empty match? go at least one position */
++ lua_pushinteger(L, newstart);
++ lua_replace(L, lua_upvalueindex(3));
++ return push_captures(&ms, src, e);
++ }
++ }
++ return 0; /* not found */
++}
++
++
++static int gmatch (lua_State *L) {
++ luaL_checkstring(L, 1);
++ luaL_checkstring(L, 2);
++ lua_settop(L, 2);
++ lua_pushinteger(L, 0);
++ lua_pushcclosure(L, gmatch_aux, 3);
++ return 1;
++}
++
++
++static int gfind_nodef (lua_State *L) {
++ return luaL_error(L, LUA_QL("string.gfind") " was renamed to "
++ LUA_QL("string.gmatch"));
++}
++
++
++static void add_s (MatchState *ms, luaL_Buffer *b, const char *s,
++ const char *e) {
++ size_t l, i;
++ const char *news = lua_tolstring(ms->L, 3, &l);
++ for (i = 0; i < l; i++) {
++ if (news[i] != L_ESC)
++ luaL_addchar(b, news[i]);
++ else {
++ i++; /* skip ESC */
++ if (!isdigit(uchar(news[i])))
++ luaL_addchar(b, news[i]);
++ else if (news[i] == '0')
++ luaL_addlstring(b, s, e - s);
++ else {
++ push_onecapture(ms, news[i] - '1', s, e);
++ luaL_addvalue(b); /* add capture to accumulated result */
++ }
++ }
++ }
++}
++
++
++static void add_value (MatchState *ms, luaL_Buffer *b, const char *s,
++ const char *e) {
++ lua_State *L = ms->L;
++ switch (lua_type(L, 3)) {
++ case LUA_TNUMBER:
++ case LUA_TSTRING: {
++ add_s(ms, b, s, e);
++ return;
++ }
++ case LUA_TFUNCTION: {
++ int n;
++ lua_pushvalue(L, 3);
++ n = push_captures(ms, s, e);
++ lua_call(L, n, 1);
++ break;
++ }
++ case LUA_TTABLE: {
++ push_onecapture(ms, 0, s, e);
++ lua_gettable(L, 3);
++ break;
++ }
++ }
++ if (!lua_toboolean(L, -1)) { /* nil or false? */
++ lua_pop(L, 1);
++ lua_pushlstring(L, s, e - s); /* keep original text */
++ }
++ else if (!lua_isstring(L, -1))
++ luaL_error(L, "invalid replacement value (a %s)", luaL_typename(L, -1));
++ luaL_addvalue(b); /* add result to accumulator */
++}
++
++
++static int str_gsub (lua_State *L) {
++ size_t srcl;
++ const char *src = luaL_checklstring(L, 1, &srcl);
++ const char *p = luaL_checkstring(L, 2);
++ int tr = lua_type(L, 3);
++ int max_s = luaL_optint(L, 4, srcl+1);
++ int anchor = (*p == '^') ? (p++, 1) : 0;
++ int n = 0;
++ MatchState ms;
++ luaL_Buffer *b = (luaL_Buffer *)kmalloc(sizeof(luaL_Buffer) + BUFSIZ, GFP_ATOMIC);
++ if(!b) luaL_error(L, "str_gsub: cannot allocate memory");
++ luaL_argcheck(L, tr == LUA_TNUMBER || tr == LUA_TSTRING ||
++ tr == LUA_TFUNCTION || tr == LUA_TTABLE, 3,
++ "string/function/table expected");
++ luaL_buffinit(L, b);
++ ms.L = L;
++ ms.src_init = src;
++ ms.src_end = src+srcl;
++ while (n < max_s) {
++ const char *e;
++ ms.level = 0;
++ e = match(&ms, src, p);
++ if (e) {
++ n++;
++ add_value(&ms, b, src, e);
++ }
++ if (e && e>src) /* non empty match? */
++ src = e; /* skip it */
++ else if (src < ms.src_end)
++ luaL_addchar(b, *src++);
++ else break;
++ if (anchor) break;
++ }
++ luaL_addlstring(b, src, ms.src_end-src);
++ luaL_pushresult(b);
++ lua_pushinteger(L, n); /* number of substitutions */
++ kfree(b);
++ return 2;
++}
++
++/* }====================================================== */
++
++
++/* maximum size of each formatted item (> len(format('%99.99f', -1e308))) */
++#define MAX_ITEM 512
++/* valid flags in a format specification */
++#define FLAGS "-+ #0"
++/*
++** maximum size of each format specification (such as '%-099.99d')
++** (+10 accounts for %99.99x plus margin of error)
++*/
++#define MAX_FORMAT (sizeof(FLAGS) + sizeof(LUA_INTFRMLEN) + 10)
++
++
++static void addquoted (lua_State *L, luaL_Buffer *b, int arg) {
++ size_t l;
++ const char *s = luaL_checklstring(L, arg, &l);
++ luaL_addchar(b, '"');
++ while (l--) {
++ switch (*s) {
++ case '"': case '\\': case '\n': {
++ luaL_addchar(b, '\\');
++ luaL_addchar(b, *s);
++ break;
++ }
++ case '\r': {
++ luaL_addlstring(b, "\\r", 2);
++ break;
++ }
++ case '\0': {
++ luaL_addlstring(b, "\\000", 4);
++ break;
++ }
++ default: {
++ luaL_addchar(b, *s);
++ break;
++ }
++ }
++ s++;
++ }
++ luaL_addchar(b, '"');
++}
++
++static const char *scanformat (lua_State *L, const char *strfrmt, char *form) {
++ const char *p = strfrmt;
++ while (*p != '\0' && strchr(FLAGS, *p) != NULL) p++; /* skip flags */
++ if ((size_t)(p - strfrmt) >= sizeof(FLAGS))
++ luaL_error(L, "invalid format (repeated flags)");
++ if (isdigit(uchar(*p))) p++; /* skip width */
++ if (isdigit(uchar(*p))) p++; /* (2 digits at most) */
++ if (*p == '.') {
++ p++;
++ if (isdigit(uchar(*p))) p++; /* skip precision */
++ if (isdigit(uchar(*p))) p++; /* (2 digits at most) */
++ }
++ if (isdigit(uchar(*p)))
++ luaL_error(L, "invalid format (width or precision too long)");
++ *(form++) = '%';
++ strncpy(form, strfrmt, p - strfrmt + 1);
++ form += p - strfrmt + 1;
++ *form = '\0';
++ return p;
++}
++
++
++static void addintlen (char *form) {
++ size_t l = strlen(form);
++ char spec = form[l - 1];
++ strcpy(form + l - 1, LUA_INTFRMLEN);
++ form[l + sizeof(LUA_INTFRMLEN) - 2] = spec;
++ form[l + sizeof(LUA_INTFRMLEN) - 1] = '\0';
++}
++
++
++static int str_format (lua_State *L) {
++ int arg = 1;
++ size_t sfl;
++ const char *strfrmt = luaL_checklstring(L, arg, &sfl);
++ const char *strfrmt_end = strfrmt+sfl;
++ luaL_Buffer *b = (luaL_Buffer *)kmalloc(sizeof(luaL_Buffer) + BUFSIZ, GFP_ATOMIC);
++ if(!b) luaL_error(L, "str_format: cannot allocate memory");
++ luaL_buffinit(L, b);
++ while (strfrmt < strfrmt_end) {
++ if (*strfrmt != L_ESC)
++ luaL_addchar(b, *strfrmt++);
++ else if (*++strfrmt == L_ESC)
++ luaL_addchar(b, *strfrmt++); /* %% */
++ else { /* format item */
++ char form[MAX_FORMAT]; /* to store the format (`%...') */
++ char buff[MAX_ITEM]; /* to store the formatted item */
++ arg++;
++ strfrmt = scanformat(L, strfrmt, form);
++ switch (*strfrmt++) {
++ case 'c': {
++ sprintf(buff, form, (int)luaL_checknumber(L, arg));
++ break;
++ }
++ case 'd': case 'i': {
++ addintlen(form);
++ sprintf(buff, form, (LUA_INTFRM_T)luaL_checknumber(L, arg));
++ break;
++ }
++ case 'o': case 'u': case 'x': case 'X': {
++ addintlen(form);
++ sprintf(buff, form, (unsigned LUA_INTFRM_T)luaL_checknumber(L, arg));
++ break;
++ }
++ case 'q': {
++ addquoted(L, b, arg);
++ continue; /* skip the 'addsize' at the end */
++ }
++ case 's': {
++ size_t l;
++ const char *s = luaL_checklstring(L, arg, &l);
++ if (!strchr(form, '.') && l >= 100) {
++ /* no precision and string is too long to be formatted;
++ keep original string */
++ lua_pushvalue(L, arg);
++ luaL_addvalue(b);
++ continue; /* skip the `addsize' at the end */
++ }
++ else {
++ sprintf(buff, form, s);
++ break;
++ }
++ }
++ default: { /* also treat cases `pnLlh' */
++ kfree(b);
++ return luaL_error(L, "invalid option " LUA_QL("%%%c") " to "
++ LUA_QL("format"), *(strfrmt - 1));
++ }
++ }
++ luaL_addlstring(b, buff, strlen(buff));
++ }
++ }
++ luaL_pushresult(b);
++ kfree(b);
++ return 1;
++}
++
++
++static const luaL_Reg strlib[] = {
++ {"byte", str_byte},
++ {"char", str_char},
++ {"dump", str_dump},
++ {"find", str_find},
++ {"format", str_format},
++ {"gfind", gfind_nodef},
++ {"gmatch", gmatch},
++ {"gsub", str_gsub},
++ {"len", str_len},
++ {"lower", str_lower},
++ {"match", str_match},
++ {"rep", str_rep},
++ {"reverse", str_reverse},
++ {"sub", str_sub},
++ {"upper", str_upper},
++ {NULL, NULL}
++};
++
++
++static void createmetatable (lua_State *L) {
++ lua_createtable(L, 0, 1); /* create metatable for strings */
++ lua_pushliteral(L, ""); /* dummy string */
++ lua_pushvalue(L, -2);
++ lua_setmetatable(L, -2); /* set string metatable */
++ lua_pop(L, 1); /* pop dummy string */
++ lua_pushvalue(L, -2); /* string library... */
++ lua_setfield(L, -2, "__index"); /* ...is the __index metamethod */
++ lua_pop(L, 1); /* pop metatable */
++}
++
++
++/*
++** Open string library
++*/
++LUALIB_API int luaopen_string (lua_State *L) {
++ luaL_register(L, LUA_STRLIBNAME, strlib);
++#if defined(LUA_COMPAT_GFIND)
++ lua_getfield(L, -1, "gmatch");
++ lua_setfield(L, -2, "gfind");
++#endif
++ createmetatable(L);
++ return 1;
++}
+--- /dev/null
++++ b/extensions/LUA/lua/ltable.c
+@@ -0,0 +1,588 @@
++/*
++** $Id: ltable.c,v 2.32.1.2 2007/12/28 15:32:23 roberto Exp $
++** Lua tables (hash)
++** See Copyright Notice in lua.h
++*/
++
++
++/*
++** Implementation of tables (aka arrays, objects, or hash tables).
++** Tables keep its elements in two parts: an array part and a hash part.
++** Non-negative integer keys are all candidates to be kept in the array
++** part. The actual size of the array is the largest `n' such that at
++** least half the slots between 0 and n are in use.
++** Hash uses a mix of chained scatter table with Brent's variation.
++** A main invariant of these tables is that, if an element is not
++** in its main position (i.e. the `original' position that its hash gives
++** to it), then the colliding element is in its own main position.
++** Hence even when the load factor reaches 100%, performance remains good.
++*/
++
++#include <math.h>
++#include <string.h>
++
++#define ltable_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "ldebug.h"
++#include "ldo.h"
++#include "lgc.h"
++#include "lmem.h"
++#include "lobject.h"
++#include "lstate.h"
++#include "ltable.h"
++
++
++/*
++** max size of array part is 2^MAXBITS
++*/
++#if LUAI_BITSINT > 26
++#define MAXBITS 26
++#else
++#define MAXBITS (LUAI_BITSINT-2)
++#endif
++
++#define MAXASIZE (1 << MAXBITS)
++
++
++#define hashpow2(t,n) (gnode(t, lmod((n), sizenode(t))))
++
++#define hashstr(t,str) hashpow2(t, (str)->tsv.hash)
++#define hashboolean(t,p) hashpow2(t, p)
++
++
++/*
++** for some types, it is better to avoid modulus by power of 2, as
++** they tend to have many 2 factors.
++*/
++#define hashmod(t,n) (gnode(t, ((n) % ((sizenode(t)-1)|1))))
++
++
++#define hashpointer(t,p) hashmod(t, IntPoint(p))
++
++
++/*
++** number of ints inside a lua_Number
++*/
++#define numints cast_int(sizeof(lua_Number)/sizeof(int))
++
++
++
++#define dummynode (&dummynode_)
++
++static const Node dummynode_ = {
++ {{NULL}, LUA_TNIL}, /* value */
++ {{{NULL}, LUA_TNIL, NULL}} /* key */
++};
++
++
++/*
++** hash for lua_Numbers
++*/
++static Node *hashnum (const Table *t, lua_Number n) {
++ unsigned int a[numints];
++ int i;
++ if (luai_numeq(n, 0)) /* avoid problems with -0 */
++ return gnode(t, 0);
++ memcpy(a, &n, sizeof(a));
++ for (i = 1; i < numints; i++) a[0] += a[i];
++ return hashmod(t, a[0]);
++}
++
++
++
++/*
++** returns the `main' position of an element in a table (that is, the index
++** of its hash value)
++*/
++static Node *mainposition (const Table *t, const TValue *key) {
++ switch (ttype(key)) {
++ case LUA_TNUMBER:
++ return hashnum(t, nvalue(key));
++ case LUA_TSTRING:
++ return hashstr(t, rawtsvalue(key));
++ case LUA_TBOOLEAN:
++ return hashboolean(t, bvalue(key));
++ case LUA_TLIGHTUSERDATA:
++ return hashpointer(t, pvalue(key));
++ default:
++ return hashpointer(t, gcvalue(key));
++ }
++}
++
++
++/*
++** returns the index for `key' if `key' is an appropriate key to live in
++** the array part of the table, -1 otherwise.
++*/
++static int arrayindex (const TValue *key) {
++ if (ttisnumber(key)) {
++ lua_Number n = nvalue(key);
++ int k;
++ lua_number2int(k, n);
++ if (luai_numeq(cast_num(k), n))
++ return k;
++ }
++ return -1; /* `key' did not match some condition */
++}
++
++
++/*
++** returns the index of a `key' for table traversals. First goes all
++** elements in the array part, then elements in the hash part. The
++** beginning of a traversal is signalled by -1.
++*/
++static int findindex (lua_State *L, Table *t, StkId key) {
++ int i;
++ if (ttisnil(key)) return -1; /* first iteration */
++ i = arrayindex(key);
++ if (0 < i && i <= t->sizearray) /* is `key' inside array part? */
++ return i-1; /* yes; that's the index (corrected to C) */
++ else {
++ Node *n = mainposition(t, key);
++ do { /* check whether `key' is somewhere in the chain */
++ /* key may be dead already, but it is ok to use it in `next' */
++ if (luaO_rawequalObj(key2tval(n), key) ||
++ (ttype(gkey(n)) == LUA_TDEADKEY && iscollectable(key) &&
++ gcvalue(gkey(n)) == gcvalue(key))) {
++ i = cast_int(n - gnode(t, 0)); /* key index in hash table */
++ /* hash elements are numbered after array ones */
++ return i + t->sizearray;
++ }
++ else n = gnext(n);
++ } while (n);
++ luaG_runerror(L, "invalid key to " LUA_QL("next")); /* key not found */
++ return 0; /* to avoid warnings */
++ }
++}
++
++
++int luaH_next (lua_State *L, Table *t, StkId key) {
++ int i = findindex(L, t, key); /* find original element */
++ for (i++; i < t->sizearray; i++) { /* try first array part */
++ if (!ttisnil(&t->array[i])) { /* a non-nil value? */
++ setnvalue(key, cast_num(i+1));
++ setobj2s(L, key+1, &t->array[i]);
++ return 1;
++ }
++ }
++ for (i -= t->sizearray; i < sizenode(t); i++) { /* then hash part */
++ if (!ttisnil(gval(gnode(t, i)))) { /* a non-nil value? */
++ setobj2s(L, key, key2tval(gnode(t, i)));
++ setobj2s(L, key+1, gval(gnode(t, i)));
++ return 1;
++ }
++ }
++ return 0; /* no more elements */
++}
++
++
++/*
++** {=============================================================
++** Rehash
++** ==============================================================
++*/
++
++
++static int computesizes (int nums[], int *narray) {
++ int i;
++ int twotoi; /* 2^i */
++ int a = 0; /* number of elements smaller than 2^i */
++ int na = 0; /* number of elements to go to array part */
++ int n = 0; /* optimal size for array part */
++ for (i = 0, twotoi = 1; twotoi/2 < *narray; i++, twotoi *= 2) {
++ if (nums[i] > 0) {
++ a += nums[i];
++ if (a > twotoi/2) { /* more than half elements present? */
++ n = twotoi; /* optimal size (till now) */
++ na = a; /* all elements smaller than n will go to array part */
++ }
++ }
++ if (a == *narray) break; /* all elements already counted */
++ }
++ *narray = n;
++ lua_assert(*narray/2 <= na && na <= *narray);
++ return na;
++}
++
++
++static int countint (const TValue *key, int *nums) {
++ int k = arrayindex(key);
++ if (0 < k && k <= MAXASIZE) { /* is `key' an appropriate array index? */
++ nums[ceillog2(k)]++; /* count as such */
++ return 1;
++ }
++ else
++ return 0;
++}
++
++
++static int numusearray (const Table *t, int *nums) {
++ int lg;
++ int ttlg; /* 2^lg */
++ int ause = 0; /* summation of `nums' */
++ int i = 1; /* count to traverse all array keys */
++ for (lg=0, ttlg=1; lg<=MAXBITS; lg++, ttlg*=2) { /* for each slice */
++ int lc = 0; /* counter */
++ int lim = ttlg;
++ if (lim > t->sizearray) {
++ lim = t->sizearray; /* adjust upper limit */
++ if (i > lim)
++ break; /* no more elements to count */
++ }
++ /* count elements in range (2^(lg-1), 2^lg] */
++ for (; i <= lim; i++) {
++ if (!ttisnil(&t->array[i-1]))
++ lc++;
++ }
++ nums[lg] += lc;
++ ause += lc;
++ }
++ return ause;
++}
++
++
++static int numusehash (const Table *t, int *nums, int *pnasize) {
++ int totaluse = 0; /* total number of elements */
++ int ause = 0; /* summation of `nums' */
++ int i = sizenode(t);
++ while (i--) {
++ Node *n = &t->node[i];
++ if (!ttisnil(gval(n))) {
++ ause += countint(key2tval(n), nums);
++ totaluse++;
++ }
++ }
++ *pnasize += ause;
++ return totaluse;
++}
++
++
++static void setarrayvector (lua_State *L, Table *t, int size) {
++ int i;
++ luaM_reallocvector(L, t->array, t->sizearray, size, TValue);
++ for (i=t->sizearray; i<size; i++)
++ setnilvalue(&t->array[i]);
++ t->sizearray = size;
++}
++
++
++static void setnodevector (lua_State *L, Table *t, int size) {
++ int lsize;
++ if (size == 0) { /* no elements to hash part? */
++ t->node = cast(Node *, dummynode); /* use common `dummynode' */
++ lsize = 0;
++ }
++ else {
++ int i;
++ lsize = ceillog2(size);
++ if (lsize > MAXBITS)
++ luaG_runerror(L, "table overflow");
++ size = twoto(lsize);
++ t->node = luaM_newvector(L, size, Node);
++ for (i=0; i<size; i++) {
++ Node *n = gnode(t, i);
++ gnext(n) = NULL;
++ setnilvalue(gkey(n));
++ setnilvalue(gval(n));
++ }
++ }
++ t->lsizenode = cast_byte(lsize);
++ t->lastfree = gnode(t, size); /* all positions are free */
++}
++
++
++static void resize (lua_State *L, Table *t, int nasize, int nhsize) {
++ int i;
++ int oldasize = t->sizearray;
++ int oldhsize = t->lsizenode;
++ Node *nold = t->node; /* save old hash ... */
++ if (nasize > oldasize) /* array part must grow? */
++ setarrayvector(L, t, nasize);
++ /* create new hash part with appropriate size */
++ setnodevector(L, t, nhsize);
++ if (nasize < oldasize) { /* array part must shrink? */
++ t->sizearray = nasize;
++ /* re-insert elements from vanishing slice */
++ for (i=nasize; i<oldasize; i++) {
++ if (!ttisnil(&t->array[i]))
++ setobjt2t(L, luaH_setnum(L, t, i+1), &t->array[i]);
++ }
++ /* shrink array */
++ luaM_reallocvector(L, t->array, oldasize, nasize, TValue);
++ }
++ /* re-insert elements from hash part */
++ for (i = twoto(oldhsize) - 1; i >= 0; i--) {
++ Node *old = nold+i;
++ if (!ttisnil(gval(old)))
++ setobjt2t(L, luaH_set(L, t, key2tval(old)), gval(old));
++ }
++ if (nold != dummynode)
++ luaM_freearray(L, nold, twoto(oldhsize), Node); /* free old array */
++}
++
++
++void luaH_resizearray (lua_State *L, Table *t, int nasize) {
++ int nsize = (t->node == dummynode) ? 0 : sizenode(t);
++ resize(L, t, nasize, nsize);
++}
++
++
++static void rehash (lua_State *L, Table *t, const TValue *ek) {
++ int nasize, na;
++ int nums[MAXBITS+1]; /* nums[i] = number of keys between 2^(i-1) and 2^i */
++ int i;
++ int totaluse;
++ for (i=0; i<=MAXBITS; i++) nums[i] = 0; /* reset counts */
++ nasize = numusearray(t, nums); /* count keys in array part */
++ totaluse = nasize; /* all those keys are integer keys */
++ totaluse += numusehash(t, nums, &nasize); /* count keys in hash part */
++ /* count extra key */
++ nasize += countint(ek, nums);
++ totaluse++;
++ /* compute new size for array part */
++ na = computesizes(nums, &nasize);
++ /* resize the table to new computed sizes */
++ resize(L, t, nasize, totaluse - na);
++}
++
++
++
++/*
++** }=============================================================
++*/
++
++
++Table *luaH_new (lua_State *L, int narray, int nhash) {
++ Table *t = luaM_new(L, Table);
++ luaC_link(L, obj2gco(t), LUA_TTABLE);
++ t->metatable = NULL;
++ t->flags = cast_byte(~0);
++ /* temporary values (kept only if some malloc fails) */
++ t->array = NULL;
++ t->sizearray = 0;
++ t->lsizenode = 0;
++ t->node = cast(Node *, dummynode);
++ setarrayvector(L, t, narray);
++ setnodevector(L, t, nhash);
++ return t;
++}
++
++
++void luaH_free (lua_State *L, Table *t) {
++ if (t->node != dummynode)
++ luaM_freearray(L, t->node, sizenode(t), Node);
++ luaM_freearray(L, t->array, t->sizearray, TValue);
++ luaM_free(L, t);
++}
++
++
++static Node *getfreepos (Table *t) {
++ while (t->lastfree-- > t->node) {
++ if (ttisnil(gkey(t->lastfree)))
++ return t->lastfree;
++ }
++ return NULL; /* could not find a free place */
++}
++
++
++
++/*
++** inserts a new key into a hash table; first, check whether key's main
++** position is free. If not, check whether colliding node is in its main
++** position or not: if it is not, move colliding node to an empty place and
++** put new key in its main position; otherwise (colliding node is in its main
++** position), new key goes to an empty position.
++*/
++static TValue *newkey (lua_State *L, Table *t, const TValue *key) {
++ Node *mp = mainposition(t, key);
++ if (!ttisnil(gval(mp)) || mp == dummynode) {
++ Node *othern;
++ Node *n = getfreepos(t); /* get a free place */
++ if (n == NULL) { /* cannot find a free place? */
++ rehash(L, t, key); /* grow table */
++ return luaH_set(L, t, key); /* re-insert key into grown table */
++ }
++ lua_assert(n != dummynode);
++ othern = mainposition(t, key2tval(mp));
++ if (othern != mp) { /* is colliding node out of its main position? */
++ /* yes; move colliding node into free position */
++ while (gnext(othern) != mp) othern = gnext(othern); /* find previous */
++ gnext(othern) = n; /* redo the chain with `n' in place of `mp' */
++ *n = *mp; /* copy colliding node into free pos. (mp->next also goes) */
++ gnext(mp) = NULL; /* now `mp' is free */
++ setnilvalue(gval(mp));
++ }
++ else { /* colliding node is in its own main position */
++ /* new node will go into free position */
++ gnext(n) = gnext(mp); /* chain new position */
++ gnext(mp) = n;
++ mp = n;
++ }
++ }
++ gkey(mp)->value = key->value; gkey(mp)->tt = key->tt;
++ luaC_barriert(L, t, key);
++ lua_assert(ttisnil(gval(mp)));
++ return gval(mp);
++}
++
++
++/*
++** search function for integers
++*/
++const TValue *luaH_getnum (Table *t, int key) {
++ /* (1 <= key && key <= t->sizearray) */
++ if (cast(unsigned int, key-1) < cast(unsigned int, t->sizearray))
++ return &t->array[key-1];
++ else {
++ lua_Number nk = cast_num(key);
++ Node *n = hashnum(t, nk);
++ do { /* check whether `key' is somewhere in the chain */
++ if (ttisnumber(gkey(n)) && luai_numeq(nvalue(gkey(n)), nk))
++ return gval(n); /* that's it */
++ else n = gnext(n);
++ } while (n);
++ return luaO_nilobject;
++ }
++}
++
++
++/*
++** search function for strings
++*/
++const TValue *luaH_getstr (Table *t, TString *key) {
++ Node *n = hashstr(t, key);
++ do { /* check whether `key' is somewhere in the chain */
++ if (ttisstring(gkey(n)) && rawtsvalue(gkey(n)) == key)
++ return gval(n); /* that's it */
++ else n = gnext(n);
++ } while (n);
++ return luaO_nilobject;
++}
++
++
++/*
++** main search function
++*/
++const TValue *luaH_get (Table *t, const TValue *key) {
++ switch (ttype(key)) {
++ case LUA_TNIL: return luaO_nilobject;
++ case LUA_TSTRING: return luaH_getstr(t, rawtsvalue(key));
++ case LUA_TNUMBER: {
++ int k;
++ lua_Number n = nvalue(key);
++ lua_number2int(k, n);
++ if (luai_numeq(cast_num(k), nvalue(key))) /* index is int? */
++ return luaH_getnum(t, k); /* use specialized version */
++ /* else go through */
++ }
++ default: {
++ Node *n = mainposition(t, key);
++ do { /* check whether `key' is somewhere in the chain */
++ if (luaO_rawequalObj(key2tval(n), key))
++ return gval(n); /* that's it */
++ else n = gnext(n);
++ } while (n);
++ return luaO_nilobject;
++ }
++ }
++}
++
++
++TValue *luaH_set (lua_State *L, Table *t, const TValue *key) {
++ const TValue *p = luaH_get(t, key);
++ t->flags = 0;
++ if (p != luaO_nilobject)
++ return cast(TValue *, p);
++ else {
++ if (ttisnil(key)) luaG_runerror(L, "table index is nil");
++ else if (ttisnumber(key) && luai_numisnan(nvalue(key)))
++ luaG_runerror(L, "table index is NaN");
++ return newkey(L, t, key);
++ }
++}
++
++
++TValue *luaH_setnum (lua_State *L, Table *t, int key) {
++ const TValue *p = luaH_getnum(t, key);
++ if (p != luaO_nilobject)
++ return cast(TValue *, p);
++ else {
++ TValue k;
++ setnvalue(&k, cast_num(key));
++ return newkey(L, t, &k);
++ }
++}
++
++
++TValue *luaH_setstr (lua_State *L, Table *t, TString *key) {
++ const TValue *p = luaH_getstr(t, key);
++ if (p != luaO_nilobject)
++ return cast(TValue *, p);
++ else {
++ TValue k;
++ setsvalue(L, &k, key);
++ return newkey(L, t, &k);
++ }
++}
++
++
++static int unbound_search (Table *t, unsigned int j) {
++ unsigned int i = j; /* i is zero or a present index */
++ j++;
++ /* find `i' and `j' such that i is present and j is not */
++ while (!ttisnil(luaH_getnum(t, j))) {
++ i = j;
++ j *= 2;
++ if (j > cast(unsigned int, MAX_INT)) { /* overflow? */
++ /* table was built with bad purposes: resort to linear search */
++ i = 1;
++ while (!ttisnil(luaH_getnum(t, i))) i++;
++ return i - 1;
++ }
++ }
++ /* now do a binary search between them */
++ while (j - i > 1) {
++ unsigned int m = (i+j)/2;
++ if (ttisnil(luaH_getnum(t, m))) j = m;
++ else i = m;
++ }
++ return i;
++}
++
++
++/*
++** Try to find a boundary in table `t'. A `boundary' is an integer index
++** such that t[i] is non-nil and t[i+1] is nil (and 0 if t[1] is nil).
++*/
++int luaH_getn (Table *t) {
++ unsigned int j = t->sizearray;
++ if (j > 0 && ttisnil(&t->array[j - 1])) {
++ /* there is a boundary in the array part: (binary) search for it */
++ unsigned int i = 0;
++ while (j - i > 1) {
++ unsigned int m = (i+j)/2;
++ if (ttisnil(&t->array[m - 1])) j = m;
++ else i = m;
++ }
++ return i;
++ }
++ /* else must find a boundary in hash part */
++ else if (t->node == dummynode) /* hash part is empty? */
++ return j; /* that is easy... */
++ else return unbound_search(t, j);
++}
++
++
++
++#if defined(LUA_DEBUG)
++
++Node *luaH_mainposition (const Table *t, const TValue *key) {
++ return mainposition(t, key);
++}
++
++int luaH_isdummy (Node *n) { return n == dummynode; }
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/ltable.h
+@@ -0,0 +1,40 @@
++/*
++** $Id: ltable.h,v 2.10.1.1 2007/12/27 13:02:25 roberto Exp $
++** Lua tables (hash)
++** See Copyright Notice in lua.h
++*/
++
++#ifndef ltable_h
++#define ltable_h
++
++#include "lobject.h"
++
++
++#define gnode(t,i) (&(t)->node[i])
++#define gkey(n) (&(n)->i_key.nk)
++#define gval(n) (&(n)->i_val)
++#define gnext(n) ((n)->i_key.nk.next)
++
++#define key2tval(n) (&(n)->i_key.tvk)
++
++
++LUAI_FUNC const TValue *luaH_getnum (Table *t, int key);
++LUAI_FUNC TValue *luaH_setnum (lua_State *L, Table *t, int key);
++LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key);
++LUAI_FUNC TValue *luaH_setstr (lua_State *L, Table *t, TString *key);
++LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key);
++LUAI_FUNC TValue *luaH_set (lua_State *L, Table *t, const TValue *key);
++LUAI_FUNC Table *luaH_new (lua_State *L, int narray, int lnhash);
++LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, int nasize);
++LUAI_FUNC void luaH_free (lua_State *L, Table *t);
++LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key);
++LUAI_FUNC int luaH_getn (Table *t);
++
++
++#if defined(LUA_DEBUG)
++LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key);
++LUAI_FUNC int luaH_isdummy (Node *n);
++#endif
++
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/ltablib.c
+@@ -0,0 +1,288 @@
++/*
++** $Id: ltablib.c,v 1.38.1.3 2008/02/14 16:46:58 roberto Exp $
++** Library for Table Manipulation
++** See Copyright Notice in lua.h
++*/
++
++
++#include <stddef.h>
++
++#define ltablib_c
++#define LUA_LIB
++
++#include "lua.h"
++
++#include "lauxlib.h"
++#include "lualib.h"
++
++
++#define aux_getn(L,n) (luaL_checktype(L, n, LUA_TTABLE), luaL_getn(L, n))
++
++
++static int foreachi (lua_State *L) {
++ int i;
++ int n = aux_getn(L, 1);
++ luaL_checktype(L, 2, LUA_TFUNCTION);
++ for (i=1; i <= n; i++) {
++ lua_pushvalue(L, 2); /* function */
++ lua_pushinteger(L, i); /* 1st argument */
++ lua_rawgeti(L, 1, i); /* 2nd argument */
++ lua_call(L, 2, 1);
++ if (!lua_isnil(L, -1))
++ return 1;
++ lua_pop(L, 1); /* remove nil result */
++ }
++ return 0;
++}
++
++
++static int foreach (lua_State *L) {
++ luaL_checktype(L, 1, LUA_TTABLE);
++ luaL_checktype(L, 2, LUA_TFUNCTION);
++ lua_pushnil(L); /* first key */
++ while (lua_next(L, 1)) {
++ lua_pushvalue(L, 2); /* function */
++ lua_pushvalue(L, -3); /* key */
++ lua_pushvalue(L, -3); /* value */
++ lua_call(L, 2, 1);
++ if (!lua_isnil(L, -1))
++ return 1;
++ lua_pop(L, 2); /* remove value and result */
++ }
++ return 0;
++}
++
++
++static int maxn (lua_State *L) {
++ lua_Number max = 0;
++ luaL_checktype(L, 1, LUA_TTABLE);
++ lua_pushnil(L); /* first key */
++ while (lua_next(L, 1)) {
++ lua_pop(L, 1); /* remove value */
++ if (lua_type(L, -1) == LUA_TNUMBER) {
++ lua_Number v = lua_tonumber(L, -1);
++ if (v > max) max = v;
++ }
++ }
++ lua_pushnumber(L, max);
++ return 1;
++}
++
++
++static int getn (lua_State *L) {
++ lua_pushinteger(L, aux_getn(L, 1));
++ return 1;
++}
++
++
++static int setn (lua_State *L) {
++ luaL_checktype(L, 1, LUA_TTABLE);
++#ifndef luaL_setn
++ luaL_setn(L, 1, luaL_checkint(L, 2));
++#else
++ luaL_error(L, LUA_QL("setn") " is obsolete");
++#endif
++ lua_pushvalue(L, 1);
++ return 1;
++}
++
++
++static int tinsert (lua_State *L) {
++ int e = aux_getn(L, 1) + 1; /* first empty element */
++ int pos; /* where to insert new element */
++ switch (lua_gettop(L)) {
++ case 2: { /* called with only 2 arguments */
++ pos = e; /* insert new element at the end */
++ break;
++ }
++ case 3: {
++ int i;
++ pos = luaL_checkint(L, 2); /* 2nd argument is the position */
++ if (pos > e) e = pos; /* `grow' array if necessary */
++ for (i = e; i > pos; i--) { /* move up elements */
++ lua_rawgeti(L, 1, i-1);
++ lua_rawseti(L, 1, i); /* t[i] = t[i-1] */
++ }
++ break;
++ }
++ default: {
++ return luaL_error(L, "wrong number of arguments to " LUA_QL("insert"));
++ }
++ }
++ luaL_setn(L, 1, e); /* new size */
++ lua_rawseti(L, 1, pos); /* t[pos] = v */
++ return 0;
++}
++
++
++static int tremove (lua_State *L) {
++ int e = aux_getn(L, 1);
++ int pos = luaL_optint(L, 2, e);
++ if (!(1 <= pos && pos <= e)) /* position is outside bounds? */
++ return 0; /* nothing to remove */
++ luaL_setn(L, 1, e - 1); /* t.n = n-1 */
++ lua_rawgeti(L, 1, pos); /* result = t[pos] */
++ for ( ;pos<e; pos++) {
++ lua_rawgeti(L, 1, pos+1);
++ lua_rawseti(L, 1, pos); /* t[pos] = t[pos+1] */
++ }
++ lua_pushnil(L);
++ lua_rawseti(L, 1, e); /* t[e] = nil */
++ return 1;
++}
++
++
++static void addfield (lua_State *L, luaL_Buffer *b, int i) {
++ lua_rawgeti(L, 1, i);
++ if (!lua_isstring(L, -1))
++ luaL_error(L, "invalid value (%s) at index %d in table for "
++ LUA_QL("concat"), luaL_typename(L, -1), i);
++ luaL_addvalue(b);
++}
++
++
++static int tconcat (lua_State *L) {
++ size_t lsep;
++ int i, last;
++ const char *sep = luaL_optlstring(L, 2, "", &lsep);
++ luaL_Buffer *b = (luaL_Buffer *)kmalloc(sizeof(luaL_Buffer) + BUFSIZ, GFP_ATOMIC);
++ if(!b) luaL_error(L, "tconcat: cannot allocate memory");
++ luaL_checktype(L, 1, LUA_TTABLE);
++ i = luaL_optint(L, 3, 1);
++ last = luaL_opt(L, luaL_checkint, 4, luaL_getn(L, 1));
++ luaL_buffinit(L, b);
++ for (; i < last; i++) {
++ addfield(L, b, i);
++ luaL_addlstring(b, sep, lsep);
++ }
++ if (i == last) /* add last value (if interval was not empty) */
++ addfield(L, b, i);
++ luaL_pushresult(b);
++ kfree(b);
++ return 1;
++}
++
++
++
++/*
++** {======================================================
++** Quicksort
++** (based on `Algorithms in MODULA-3', Robert Sedgewick;
++** Addison-Wesley, 1993.)
++*/
++
++
++static void set2 (lua_State *L, int i, int j) {
++ lua_rawseti(L, 1, i);
++ lua_rawseti(L, 1, j);
++}
++
++static int sort_comp (lua_State *L, int a, int b) {
++ if (!lua_isnil(L, 2)) { /* function? */
++ int res;
++ lua_pushvalue(L, 2);
++ lua_pushvalue(L, a-1); /* -1 to compensate function */
++ lua_pushvalue(L, b-2); /* -2 to compensate function and `a' */
++ lua_call(L, 2, 1);
++ res = lua_toboolean(L, -1);
++ lua_pop(L, 1);
++ return res;
++ }
++ else /* a < b? */
++ return lua_lessthan(L, a, b);
++}
++
++static void auxsort (lua_State *L, int l, int u) {
++ while (l < u) { /* for tail recursion */
++ int i, j;
++ /* sort elements a[l], a[(l+u)/2] and a[u] */
++ lua_rawgeti(L, 1, l);
++ lua_rawgeti(L, 1, u);
++ if (sort_comp(L, -1, -2)) /* a[u] < a[l]? */
++ set2(L, l, u); /* swap a[l] - a[u] */
++ else
++ lua_pop(L, 2);
++ if (u-l == 1) break; /* only 2 elements */
++ i = (l+u)/2;
++ lua_rawgeti(L, 1, i);
++ lua_rawgeti(L, 1, l);
++ if (sort_comp(L, -2, -1)) /* a[i]<a[l]? */
++ set2(L, i, l);
++ else {
++ lua_pop(L, 1); /* remove a[l] */
++ lua_rawgeti(L, 1, u);
++ if (sort_comp(L, -1, -2)) /* a[u]<a[i]? */
++ set2(L, i, u);
++ else
++ lua_pop(L, 2);
++ }
++ if (u-l == 2) break; /* only 3 elements */
++ lua_rawgeti(L, 1, i); /* Pivot */
++ lua_pushvalue(L, -1);
++ lua_rawgeti(L, 1, u-1);
++ set2(L, i, u-1);
++ /* a[l] <= P == a[u-1] <= a[u], only need to sort from l+1 to u-2 */
++ i = l; j = u-1;
++ for (;;) { /* invariant: a[l..i] <= P <= a[j..u] */
++ /* repeat ++i until a[i] >= P */
++ while (lua_rawgeti(L, 1, ++i), sort_comp(L, -1, -2)) {
++ if (i>u) luaL_error(L, "invalid order function for sorting");
++ lua_pop(L, 1); /* remove a[i] */
++ }
++ /* repeat --j until a[j] <= P */
++ while (lua_rawgeti(L, 1, --j), sort_comp(L, -3, -1)) {
++ if (j<l) luaL_error(L, "invalid order function for sorting");
++ lua_pop(L, 1); /* remove a[j] */
++ }
++ if (j<i) {
++ lua_pop(L, 3); /* pop pivot, a[i], a[j] */
++ break;
++ }
++ set2(L, i, j);
++ }
++ lua_rawgeti(L, 1, u-1);
++ lua_rawgeti(L, 1, i);
++ set2(L, u-1, i); /* swap pivot (a[u-1]) with a[i] */
++ /* a[l..i-1] <= a[i] == P <= a[i+1..u] */
++ /* adjust so that smaller half is in [j..i] and larger one in [l..u] */
++ if (i-l < u-i) {
++ j=l; i=i-1; l=i+2;
++ }
++ else {
++ j=i+1; i=u; u=j-2;
++ }
++ auxsort(L, j, i); /* call recursively the smaller one */
++ } /* repeat the routine for the larger one */
++}
++
++static int sort (lua_State *L) {
++ int n = aux_getn(L, 1);
++ luaL_checkstack(L, 40, ""); /* assume array is smaller than 2^40 */
++ if (!lua_isnoneornil(L, 2)) /* is there a 2nd argument? */
++ luaL_checktype(L, 2, LUA_TFUNCTION);
++ lua_settop(L, 2); /* make sure there is two arguments */
++ auxsort(L, 1, n);
++ return 0;
++}
++
++/* }====================================================== */
++
++
++static const luaL_Reg tab_funcs[] = {
++ {"concat", tconcat},
++ {"foreach", foreach},
++ {"foreachi", foreachi},
++ {"getn", getn},
++ {"maxn", maxn},
++ {"insert", tinsert},
++ {"remove", tremove},
++ {"setn", setn},
++ {"sort", sort},
++ {NULL, NULL}
++};
++
++
++LUALIB_API int luaopen_table (lua_State *L) {
++ luaL_register(L, LUA_TABLIBNAME, tab_funcs);
++ return 1;
++}
+--- /dev/null
++++ b/extensions/LUA/lua/ltm.c
+@@ -0,0 +1,74 @@
++/*
++** $Id: ltm.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $
++** Tag methods
++** See Copyright Notice in lua.h
++*/
++
++#include <string.h>
++
++#define ltm_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "lobject.h"
++#include "lstate.h"
++#include "lstring.h"
++#include "ltable.h"
++#include "ltm.h"
++
++
++
++const char *const luaT_typenames[] = {
++ "nil", "boolean", "userdata", "number",
++ "string", "table", "function", "userdata", "thread",
++ "proto", "upval"
++};
++
++
++void luaT_init (lua_State *L) {
++ static const char *const luaT_eventname[] = { /* ORDER TM */
++ "__index", "__newindex",
++ "__gc", "__mode", "__eq",
++ "__add", "__sub", "__mul", "__div", "__mod",
++ "__pow", "__unm", "__len", "__lt", "__le",
++ "__concat", "__call"
++ };
++ int i;
++ for (i=0; i<TM_N; i++) {
++ G(L)->tmname[i] = luaS_new(L, luaT_eventname[i]);
++ luaS_fix(G(L)->tmname[i]); /* never collect these names */
++ }
++}
++
++
++/*
++** function to be used with macro "fasttm": optimized for absence of
++** tag methods
++*/
++const TValue *luaT_gettm (Table *events, TMS event, TString *ename) {
++ const TValue *tm = luaH_getstr(events, ename);
++ lua_assert(event <= TM_EQ);
++ if (ttisnil(tm)) { /* no tag method? */
++ events->flags |= cast_byte(1u<<event); /* cache this fact */
++ return NULL;
++ }
++ else return tm;
++}
++
++
++const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, TMS event) {
++ Table *mt;
++ switch (ttype(o)) {
++ case LUA_TTABLE:
++ mt = hvalue(o)->metatable;
++ break;
++ case LUA_TUSERDATA:
++ mt = uvalue(o)->metatable;
++ break;
++ default:
++ mt = G(L)->mt[ttype(o)];
++ }
++ return (mt ? luaH_getstr(mt, G(L)->tmname[event]) : luaO_nilobject);
++}
++
+--- /dev/null
++++ b/extensions/LUA/lua/ltm.h
+@@ -0,0 +1,54 @@
++/*
++** $Id: ltm.h,v 2.6.1.1 2007/12/27 13:02:25 roberto Exp $
++** Tag methods
++** See Copyright Notice in lua.h
++*/
++
++#ifndef ltm_h
++#define ltm_h
++
++
++#include "lobject.h"
++
++
++/*
++* WARNING: if you change the order of this enumeration,
++* grep "ORDER TM"
++*/
++typedef enum {
++ TM_INDEX,
++ TM_NEWINDEX,
++ TM_GC,
++ TM_MODE,
++ TM_EQ, /* last tag method with `fast' access */
++ TM_ADD,
++ TM_SUB,
++ TM_MUL,
++ TM_DIV,
++ TM_MOD,
++ TM_POW,
++ TM_UNM,
++ TM_LEN,
++ TM_LT,
++ TM_LE,
++ TM_CONCAT,
++ TM_CALL,
++ TM_N /* number of elements in the enum */
++} TMS;
++
++
++
++#define gfasttm(g,et,e) ((et) == NULL ? NULL : \
++ ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e]))
++
++#define fasttm(l,et,e) gfasttm(G(l), et, e)
++
++LUAI_DATA const char *const luaT_typenames[];
++
++
++LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename);
++LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o,
++ TMS event);
++LUAI_FUNC void luaT_init (lua_State *L);
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/luaconf.h
+@@ -0,0 +1,797 @@
++/*
++** $Id: luaconf.h,v 1.82.1.7 2008/02/11 16:25:08 roberto Exp $
++** Configuration file for Lua
++** See Copyright Notice in lua.h
++*/
++
++
++#ifndef lconfig_h
++#define lconfig_h
++
++#include <stddef.h>
++
++#if !defined(__KERNEL__)
++#include <limits.h>
++#else
++#define UCHAR_MAX 255
++#define SHRT_MAX 32767
++#define BUFSIZ 8192
++#define NO_FPU
++#endif
++
++/*
++** ==================================================================
++** Search for "@@" to find all configurable definitions.
++** ===================================================================
++*/
++
++
++/*
++@@ LUA_ANSI controls the use of non-ansi features.
++** CHANGE it (define it) if you want Lua to avoid the use of any
++** non-ansi feature or library.
++*/
++#if defined(__STRICT_ANSI__)
++#define LUA_ANSI
++#endif
++
++
++#if !defined(LUA_ANSI) && defined(_WIN32)
++#define LUA_WIN
++#endif
++
++#if defined(LUA_USE_LINUX)
++#define LUA_USE_POSIX
++#define LUA_USE_DLOPEN /* needs an extra library: -ldl */
++#define LUA_USE_READLINE /* needs some extra libraries */
++#endif
++
++#if defined(LUA_USE_MACOSX)
++#define LUA_USE_POSIX
++#define LUA_DL_DYLD /* does not need extra library */
++#endif
++
++
++
++/*
++@@ LUA_USE_POSIX includes all functionallity listed as X/Open System
++@* Interfaces Extension (XSI).
++** CHANGE it (define it) if your system is XSI compatible.
++*/
++#if defined(LUA_USE_POSIX)
++#define LUA_USE_MKSTEMP
++#define LUA_USE_ISATTY
++#define LUA_USE_POPEN
++#define LUA_USE_ULONGJMP
++#endif
++
++
++/*
++@@ LUA_PATH and LUA_CPATH are the names of the environment variables that
++@* Lua check to set its paths.
++@@ LUA_INIT is the name of the environment variable that Lua
++@* checks for initialization code.
++** CHANGE them if you want different names.
++*/
++#define LUA_PATH "LUA_PATH"
++#define LUA_CPATH "LUA_CPATH"
++#define LUA_INIT "LUA_INIT"
++
++
++/*
++@@ LUA_PATH_DEFAULT is the default path that Lua uses to look for
++@* Lua libraries.
++@@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for
++@* C libraries.
++** CHANGE them if your machine has a non-conventional directory
++** hierarchy or if you want to install your libraries in
++** non-conventional directories.
++*/
++#if defined(_WIN32)
++/*
++** In Windows, any exclamation mark ('!') in the path is replaced by the
++** path of the directory of the executable file of the current process.
++*/
++#define LUA_LDIR "!\\lua\\"
++#define LUA_CDIR "!\\"
++#define LUA_PATH_DEFAULT \
++ ".\\?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \
++ LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua"
++#define LUA_CPATH_DEFAULT \
++ ".\\?.dll;" LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll"
++
++#else
++#define LUA_ROOT "/usr/local/"
++#define LUA_LDIR LUA_ROOT "share/lua/5.1/"
++#define LUA_CDIR LUA_ROOT "lib/lua/5.1/"
++#define LUA_PATH_DEFAULT \
++ "./?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \
++ LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua"
++#define LUA_CPATH_DEFAULT \
++ "./?.so;" LUA_CDIR"?.so;" LUA_CDIR"loadall.so"
++#endif
++
++
++/*
++@@ LUA_DIRSEP is the directory separator (for submodules).
++** CHANGE it if your machine does not use "/" as the directory separator
++** and is not Windows. (On Windows Lua automatically uses "\".)
++*/
++#if defined(_WIN32)
++#define LUA_DIRSEP "\\"
++#else
++#define LUA_DIRSEP "/"
++#endif
++
++
++/*
++@@ LUA_PATHSEP is the character that separates templates in a path.
++@@ LUA_PATH_MARK is the string that marks the substitution points in a
++@* template.
++@@ LUA_EXECDIR in a Windows path is replaced by the executable's
++@* directory.
++@@ LUA_IGMARK is a mark to ignore all before it when bulding the
++@* luaopen_ function name.
++** CHANGE them if for some reason your system cannot use those
++** characters. (E.g., if one of those characters is a common character
++** in file/directory names.) Probably you do not need to change them.
++*/
++#define LUA_PATHSEP ";"
++#define LUA_PATH_MARK "?"
++#define LUA_EXECDIR "!"
++#define LUA_IGMARK "-"
++
++
++/*
++@@ LUA_INTEGER is the integral type used by lua_pushinteger/lua_tointeger.
++** CHANGE that if ptrdiff_t is not adequate on your machine. (On most
++** machines, ptrdiff_t gives a good choice between int or long.)
++*/
++#define LUA_INTEGER ptrdiff_t
++
++
++/*
++@@ LUA_API is a mark for all core API functions.
++@@ LUALIB_API is a mark for all standard library functions.
++** CHANGE them if you need to define those functions in some special way.
++** For instance, if you want to create one Windows DLL with the core and
++** the libraries, you may want to use the following definition (define
++** LUA_BUILD_AS_DLL to get it).
++*/
++#if defined(LUA_BUILD_AS_DLL)
++
++#if defined(LUA_CORE) || defined(LUA_LIB)
++#define LUA_API __declspec(dllexport)
++#else
++#define LUA_API __declspec(dllimport)
++#endif
++
++#else
++
++#define LUA_API extern
++
++#endif
++
++/* more often than not the libs go together with the core */
++#define LUALIB_API LUA_API
++
++
++/*
++@@ LUAI_FUNC is a mark for all extern functions that are not to be
++@* exported to outside modules.
++@@ LUAI_DATA is a mark for all extern (const) variables that are not to
++@* be exported to outside modules.
++** CHANGE them if you need to mark them in some special way. Elf/gcc
++** (versions 3.2 and later) mark them as "hidden" to optimize access
++** when Lua is compiled as a shared library.
++*/
++#if defined(luaall_c)
++#define LUAI_FUNC static
++#define LUAI_DATA /* empty */
++
++#elif defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \
++ defined(__ELF__)
++#define LUAI_FUNC __attribute__((visibility("hidden"))) extern
++#define LUAI_DATA LUAI_FUNC
++
++#else
++#define LUAI_FUNC extern
++#define LUAI_DATA extern
++#endif
++
++
++
++/*
++@@ LUA_QL describes how error messages quote program elements.
++** CHANGE it if you want a different appearance.
++*/
++#define LUA_QL(x) "'" x "'"
++#define LUA_QS LUA_QL("%s")
++
++
++/*
++@@ LUA_IDSIZE gives the maximum size for the description of the source
++@* of a function in debug information.
++** CHANGE it if you want a different size.
++*/
++#define LUA_IDSIZE 60
++
++
++/*
++** {==================================================================
++** Stand-alone configuration
++** ===================================================================
++*/
++
++#if defined(lua_c) || defined(luaall_c)
++
++/*
++@@ lua_stdin_is_tty detects whether the standard input is a 'tty' (that
++@* is, whether we're running lua interactively).
++** CHANGE it if you have a better definition for non-POSIX/non-Windows
++** systems.
++*/
++#if defined(LUA_USE_ISATTY)
++#include <unistd.h>
++#define lua_stdin_is_tty() isatty(0)
++#elif defined(LUA_WIN)
++#include <io.h>
++#include <stdio.h>
++#define lua_stdin_is_tty() _isatty(_fileno(stdin))
++#else
++#define lua_stdin_is_tty() 1 /* assume stdin is a tty */
++#endif
++
++
++/*
++@@ LUA_PROMPT is the default prompt used by stand-alone Lua.
++@@ LUA_PROMPT2 is the default continuation prompt used by stand-alone Lua.
++** CHANGE them if you want different prompts. (You can also change the
++** prompts dynamically, assigning to globals _PROMPT/_PROMPT2.)
++*/
++#define LUA_PROMPT "> "
++#define LUA_PROMPT2 ">> "
++
++
++/*
++@@ LUA_PROGNAME is the default name for the stand-alone Lua program.
++** CHANGE it if your stand-alone interpreter has a different name and
++** your system is not able to detect that name automatically.
++*/
++#define LUA_PROGNAME "lua"
++
++
++/*
++@@ LUA_MAXINPUT is the maximum length for an input line in the
++@* stand-alone interpreter.
++** CHANGE it if you need longer lines.
++*/
++#define LUA_MAXINPUT 512
++
++
++/*
++@@ lua_readline defines how to show a prompt and then read a line from
++@* the standard input.
++@@ lua_saveline defines how to "save" a read line in a "history".
++@@ lua_freeline defines how to free a line read by lua_readline.
++** CHANGE them if you want to improve this functionality (e.g., by using
++** GNU readline and history facilities).
++*/
++#if defined(LUA_USE_READLINE)
++#include <stdio.h>
++#include <readline/readline.h>
++#include <readline/history.h>
++#define lua_readline(L,b,p) ((void)L, ((b)=readline(p)) != NULL)
++#define lua_saveline(L,idx) \
++ if (lua_strlen(L,idx) > 0) /* non-empty line? */ \
++ add_history(lua_tostring(L, idx)); /* add it to history */
++#define lua_freeline(L,b) ((void)L, free(b))
++#else
++#define lua_readline(L,b,p) \
++ ((void)L, fputs(p, stdout), fflush(stdout), /* show prompt */ \
++ fgets(b, LUA_MAXINPUT, stdin) != NULL) /* get line */
++#define lua_saveline(L,idx) { (void)L; (void)idx; }
++#define lua_freeline(L,b) { (void)L; (void)b; }
++#endif
++
++#endif
++
++/* }================================================================== */
++
++
++/*
++@@ LUAI_GCPAUSE defines the default pause between garbage-collector cycles
++@* as a percentage.
++** CHANGE it if you want the GC to run faster or slower (higher values
++** mean larger pauses which mean slower collection.) You can also change
++** this value dynamically.
++*/
++#define LUAI_GCPAUSE 200 /* 200% (wait memory to double before next GC) */
++
++
++/*
++@@ LUAI_GCMUL defines the default speed of garbage collection relative to
++@* memory allocation as a percentage.
++** CHANGE it if you want to change the granularity of the garbage
++** collection. (Higher values mean coarser collections. 0 represents
++** infinity, where each step performs a full collection.) You can also
++** change this value dynamically.
++*/
++#define LUAI_GCMUL 200 /* GC runs 'twice the speed' of memory allocation */
++
++
++
++/*
++@@ LUA_COMPAT_GETN controls compatibility with old getn behavior.
++** CHANGE it (define it) if you want exact compatibility with the
++** behavior of setn/getn in Lua 5.0.
++*/
++#undef LUA_COMPAT_GETN
++
++/*
++@@ LUA_COMPAT_LOADLIB controls compatibility about global loadlib.
++** CHANGE it to undefined as soon as you do not need a global 'loadlib'
++** function (the function is still available as 'package.loadlib').
++*/
++#undef LUA_COMPAT_LOADLIB
++
++/*
++@@ LUA_COMPAT_VARARG controls compatibility with old vararg feature.
++** CHANGE it to undefined as soon as your programs use only '...' to
++** access vararg parameters (instead of the old 'arg' table).
++*/
++#define LUA_COMPAT_VARARG
++
++/*
++@@ LUA_COMPAT_MOD controls compatibility with old math.mod function.
++** CHANGE it to undefined as soon as your programs use 'math.fmod' or
++** the new '%' operator instead of 'math.mod'.
++*/
++#define LUA_COMPAT_MOD
++
++/*
++@@ LUA_COMPAT_LSTR controls compatibility with old long string nesting
++@* facility.
++** CHANGE it to 2 if you want the old behaviour, or undefine it to turn
++** off the advisory error when nesting [[...]].
++*/
++#define LUA_COMPAT_LSTR 1
++
++/*
++@@ LUA_COMPAT_GFIND controls compatibility with old 'string.gfind' name.
++** CHANGE it to undefined as soon as you rename 'string.gfind' to
++** 'string.gmatch'.
++*/
++#define LUA_COMPAT_GFIND
++
++/*
++@@ LUA_COMPAT_OPENLIB controls compatibility with old 'luaL_openlib'
++@* behavior.
++** CHANGE it to undefined as soon as you replace to 'luaL_register'
++** your uses of 'luaL_openlib'
++*/
++#define LUA_COMPAT_OPENLIB
++
++
++
++/*
++@@ luai_apicheck is the assert macro used by the Lua-C API.
++** CHANGE luai_apicheck if you want Lua to perform some checks in the
++** parameters it gets from API calls. This may slow down the interpreter
++** a bit, but may be quite useful when debugging C code that interfaces
++** with Lua. A useful redefinition is to use assert.h.
++*/
++#if defined(LUA_USE_APICHECK)
++#include <assert.h>
++#define luai_apicheck(L,o) { (void)L; assert(o); }
++#else
++#define luai_apicheck(L,o) { (void)L; }
++#endif
++
++
++/*
++@@ LUAI_BITSINT defines the number of bits in an int.
++** CHANGE here if Lua cannot automatically detect the number of bits of
++** your machine. Probably you do not need to change this.
++*/
++/* avoid overflows in comparison */
++#if !defined(__KERNEL__)
++#include <limits.h>
++#define LUA_INT_MAX INT_MAX
++#else
++#define LUA_INT_MAX (~0U>>1)
++#endif
++
++#if LUA_INT_MAX-20 < 32760
++#define LUAI_BITSINT 16
++#elif LUA_INT_MAX > 2147483640L
++/* int has at least 32 bits */
++#define LUAI_BITSINT 32
++#else
++#error "you must define LUA_BITSINT with number of bits in an integer"
++#endif
++
++
++/*
++@@ LUAI_UINT32 is an unsigned integer with at least 32 bits.
++@@ LUAI_INT32 is an signed integer with at least 32 bits.
++@@ LUAI_UMEM is an unsigned integer big enough to count the total
++@* memory used by Lua.
++@@ LUAI_MEM is a signed integer big enough to count the total memory
++@* used by Lua.
++** CHANGE here if for some weird reason the default definitions are not
++** good enough for your machine. (The definitions in the 'else'
++** part always works, but may waste space on machines with 64-bit
++** longs.) Probably you do not need to change this.
++*/
++#if LUAI_BITSINT >= 32
++#define LUAI_UINT32 unsigned int
++#define LUAI_INT32 int
++#define LUAI_MAXINT32 INT_MAX
++#define LUAI_UMEM size_t
++#define LUAI_MEM ptrdiff_t
++#else
++/* 16-bit ints */
++#define LUAI_UINT32 unsigned long
++#define LUAI_INT32 long
++#define LUAI_MAXINT32 LONG_MAX
++#define LUAI_UMEM unsigned long
++#define LUAI_MEM long
++#endif
++
++
++/*
++@@ LUAI_MAXCALLS limits the number of nested calls.
++** CHANGE it if you need really deep recursive calls. This limit is
++** arbitrary; its only purpose is to stop infinite recursion before
++** exhausting memory.
++*/
++#define LUAI_MAXCALLS 20000
++
++
++/*
++@@ LUAI_MAXCSTACK limits the number of Lua stack slots that a C function
++@* can use.
++** CHANGE it if you need lots of (Lua) stack space for your C
++** functions. This limit is arbitrary; its only purpose is to stop C
++** functions to consume unlimited stack space. (must be smaller than
++** -LUA_REGISTRYINDEX)
++*/
++#define LUAI_MAXCSTACK 8000
++
++
++
++/*
++** {==================================================================
++** CHANGE (to smaller values) the following definitions if your system
++** has a small C stack. (Or you may want to change them to larger
++** values if your system has a large C stack and these limits are
++** too rigid for you.) Some of these constants control the size of
++** stack-allocated arrays used by the compiler or the interpreter, while
++** others limit the maximum number of recursive calls that the compiler
++** or the interpreter can perform. Values too large may cause a C stack
++** overflow for some forms of deep constructs.
++** ===================================================================
++*/
++
++
++/*
++@@ LUAI_MAXCCALLS is the maximum depth for nested C calls (short) and
++@* syntactical nested non-terminals in a program.
++*/
++#define LUAI_MAXCCALLS 200
++
++
++/*
++@@ LUAI_MAXVARS is the maximum number of local variables per function
++@* (must be smaller than 250).
++*/
++#define LUAI_MAXVARS 200
++
++
++/*
++@@ LUAI_MAXUPVALUES is the maximum number of upvalues per function
++@* (must be smaller than 250).
++*/
++#define LUAI_MAXUPVALUES 60
++
++
++/*
++@@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system.
++*/
++#define LUAL_BUFFERSIZE BUFSIZ
++
++/* }================================================================== */
++
++
++
++
++/*
++** {==================================================================
++@@ LUA_NUMBER is the type of numbers in Lua.
++** CHANGE the following definitions only if you want to build Lua
++** with a number type different from double. You may also need to
++** change lua_number2int & lua_number2integer.
++** ===================================================================
++*/
++#if !defined(NO_FPU)
++#define LUA_NUMBER_DOUBLE
++#define LUA_NUMBER double
++#else
++#define LUA_NUMBER long
++#endif
++
++/*
++@@ LUAI_UACNUMBER is the result of an 'usual argument conversion'
++@* over a number.
++*/
++#define LUAI_UACNUMBER LUA_NUMBER
++
++
++/*
++@@ LUA_NUMBER_SCAN is the format for reading numbers.
++@@ LUA_NUMBER_FMT is the format for writing numbers.
++@@ lua_number2str converts a number to a string.
++@@ LUAI_MAXNUMBER2STR is maximum size of previous conversion.
++@@ lua_str2number converts a string to a number.
++*/
++#if !defined(NO_FPU)
++#define LUA_NUMBER_SCAN "%lf"
++#define LUA_NUMBER_FMT "%.14g"
++#define lua_str2number(s,p) strtod((s), (p))
++#else
++#define LUA_NUMBER_SCAN "%ld"
++#define LUA_NUMBER_FMT "%ld"
++#if !defined(__KERNEL__)
++#define lua_str2number(s,p) strtol((s), (p), 10)
++#else
++#define lua_str2number(s,p) simple_strtol((s), (p), 10)
++#endif
++#endif
++
++#define LUAI_MAXNUMBER2STR 32 /* 16 digits, sign, point, and \0 */
++#define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n))
++
++/*
++@@ The luai_num* macros define the primitive operations over numbers.
++*/
++#if defined(LUA_CORE)
++#define luai_numadd(a,b) ((a)+(b))
++#define luai_numsub(a,b) ((a)-(b))
++#define luai_nummul(a,b) ((a)*(b))
++#define luai_numdiv(a,b) ((a)/(b))
++#define luai_numunm(a) (-(a))
++#define luai_numeq(a,b) ((a)==(b))
++#define luai_numlt(a,b) ((a)<(b))
++#define luai_numle(a,b) ((a)<=(b))
++#define luai_numisnan(a) (!luai_numeq((a), (a)))
++#if !defined(NO_FPU)
++#include <math.h>
++#define luai_nummod(a,b) ((a) - floor((a)/(b))*(b))
++#define luai_numpow(a,b) (pow(a,b))
++#else
++#define luai_nummod(a,b) ((a)%(b))
++#define luai_numpow(a,b) luai_nummul(a,b)
++#endif
++#endif
++
++
++/*
++@@ lua_number2int is a macro to convert lua_Number to int.
++@@ lua_number2integer is a macro to convert lua_Number to lua_Integer.
++** CHANGE them if you know a faster way to convert a lua_Number to
++** int (with any rounding method and without throwing errors) in your
++** system. In Pentium machines, a naive typecast from double to int
++** in C is extremely slow, so any alternative is worth trying.
++*/
++
++/* On a Pentium, resort to a trick */
++#if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) && !defined(__SSE2__) && \
++ (defined(__i386) || defined (_M_IX86) || defined(__i386__))
++
++/* On a Microsoft compiler, use assembler */
++#if defined(_MSC_VER)
++
++#define lua_number2int(i,d) __asm fld d __asm fistp i
++#define lua_number2integer(i,n) lua_number2int(i, n)
++
++/* the next trick should work on any Pentium, but sometimes clashes
++ with a DirectX idiosyncrasy */
++#else
++
++union luai_Cast { double l_d; long l_l; };
++#define lua_number2int(i,d) \
++ { volatile union luai_Cast u; u.l_d = (d) + 6755399441055744.0; (i) = u.l_l; }
++#define lua_number2integer(i,n) lua_number2int(i, n)
++
++#endif
++
++
++/* this option always works, but may be slow */
++#else
++#define lua_number2int(i,d) ((i)=(int)(d))
++#define lua_number2integer(i,d) ((i)=(lua_Integer)(d))
++
++#endif
++
++/* }================================================================== */
++
++
++/*
++@@ LUAI_USER_ALIGNMENT_T is a type that requires maximum alignment.
++** CHANGE it if your system requires alignments larger than double. (For
++** instance, if your system supports long doubles and they must be
++** aligned in 16-byte boundaries, then you should add long double in the
++** union.) Probably you do not need to change this.
++*/
++#define LUAI_USER_ALIGNMENT_T union { double u; void *s; long l; }
++
++
++/*
++@@ LUAI_THROW/LUAI_TRY define how Lua does exception handling.
++** CHANGE them if you prefer to use longjmp/setjmp even with C++
++** or if want/don't to use _longjmp/_setjmp instead of regular
++** longjmp/setjmp. By default, Lua handles errors with exceptions when
++** compiling as C++ code, with _longjmp/_setjmp when asked to use them,
++** and with longjmp/setjmp otherwise.
++*/
++#if defined(__KERNEL__)
++#undef LUA_USE_ULONGJMP
++#endif
++
++#if defined(__cplusplus)
++/* C++ exceptions */
++#define LUAI_THROW(L,c) throw(c)
++#define LUAI_TRY(L,c,a) try { a } catch(...) \
++ { if ((c)->status == 0) (c)->status = -1; }
++#define luai_jmpbuf int /* dummy variable */
++
++#elif defined(LUA_USE_ULONGJMP)
++/* in Unix, try _longjmp/_setjmp (more efficient) */
++#define LUAI_THROW(L,c) _longjmp((c)->b, 1)
++#define LUAI_TRY(L,c,a) if (_setjmp((c)->b) == 0) { a }
++#define luai_jmpbuf jmp_buf
++
++#else
++/* default handling with long jumps */
++#define LUAI_THROW(L,c) longjmp((c)->b, 1)
++#define LUAI_TRY(L,c,a) if (setjmp((c)->b) == 0) { a }
++#define luai_jmpbuf jmp_buf
++
++#endif
++
++
++/*
++@@ LUA_MAXCAPTURES is the maximum number of captures that a pattern
++@* can do during pattern-matching.
++** CHANGE it if you need more captures. This limit is arbitrary.
++*/
++#define LUA_MAXCAPTURES 32
++
++
++/*
++@@ lua_tmpnam is the function that the OS library uses to create a
++@* temporary name.
++@@ LUA_TMPNAMBUFSIZE is the maximum size of a name created by lua_tmpnam.
++** CHANGE them if you have an alternative to tmpnam (which is considered
++** insecure) or if you want the original tmpnam anyway. By default, Lua
++** uses tmpnam except when POSIX is available, where it uses mkstemp.
++*/
++#if defined(loslib_c) || defined(luaall_c)
++
++#if defined(LUA_USE_MKSTEMP)
++#include <unistd.h>
++#define LUA_TMPNAMBUFSIZE 32
++#define lua_tmpnam(b,e) { \
++ strcpy(b, "/tmp/lua_XXXXXX"); \
++ e = mkstemp(b); \
++ if (e != -1) close(e); \
++ e = (e == -1); }
++
++#else
++#define LUA_TMPNAMBUFSIZE L_tmpnam
++#define lua_tmpnam(b,e) { e = (tmpnam(b) == NULL); }
++#endif
++
++#endif
++
++
++/*
++@@ lua_popen spawns a new process connected to the current one through
++@* the file streams.
++** CHANGE it if you have a way to implement it in your system.
++*/
++#if defined(LUA_USE_POPEN)
++
++#define lua_popen(L,c,m) ((void)L, fflush(NULL), popen(c,m))
++#define lua_pclose(L,file) ((void)L, (pclose(file) != -1))
++
++#elif defined(LUA_WIN)
++
++#define lua_popen(L,c,m) ((void)L, _popen(c,m))
++#define lua_pclose(L,file) ((void)L, (_pclose(file) != -1))
++
++#else
++
++#define lua_popen(L,c,m) ((void)((void)c, m), \
++ luaL_error(L, LUA_QL("popen") " not supported"), (FILE*)0)
++#define lua_pclose(L,file) ((void)((void)L, file), 0)
++
++#endif
++
++/*
++@@ LUA_DL_* define which dynamic-library system Lua should use.
++** CHANGE here if Lua has problems choosing the appropriate
++** dynamic-library system for your platform (either Windows' DLL, Mac's
++** dyld, or Unix's dlopen). If your system is some kind of Unix, there
++** is a good chance that it has dlopen, so LUA_DL_DLOPEN will work for
++** it. To use dlopen you also need to adapt the src/Makefile (probably
++** adding -ldl to the linker options), so Lua does not select it
++** automatically. (When you change the makefile to add -ldl, you must
++** also add -DLUA_USE_DLOPEN.)
++** If you do not want any kind of dynamic library, undefine all these
++** options.
++** By default, _WIN32 gets LUA_DL_DLL and MAC OS X gets LUA_DL_DYLD.
++*/
++#if defined(LUA_USE_DLOPEN)
++#define LUA_DL_DLOPEN
++#endif
++
++#if defined(LUA_WIN)
++#define LUA_DL_DLL
++#endif
++
++
++/*
++@@ LUAI_EXTRASPACE allows you to add user-specific data in a lua_State
++@* (the data goes just *before* the lua_State pointer).
++** CHANGE (define) this if you really need that. This value must be
++** a multiple of the maximum alignment required for your machine.
++*/
++#define LUAI_EXTRASPACE 0
++
++
++/*
++@@ luai_userstate* allow user-specific actions on threads.
++** CHANGE them if you defined LUAI_EXTRASPACE and need to do something
++** extra when a thread is created/deleted/resumed/yielded.
++*/
++#define luai_userstateopen(L) ((void)L)
++#define luai_userstateclose(L) ((void)L)
++#define luai_userstatethread(L,L1) ((void)L)
++#define luai_userstatefree(L) ((void)L)
++#define luai_userstateresume(L,n) ((void)L)
++#define luai_userstateyield(L,n) ((void)L)
++
++
++/*
++@@ LUA_INTFRMLEN is the length modifier for integer conversions
++@* in 'string.format'.
++@@ LUA_INTFRM_T is the integer type correspoding to the previous length
++@* modifier.
++** CHANGE them if your system supports long long or does not support long.
++*/
++
++#if defined(LUA_USELONGLONG)
++
++#define LUA_INTFRMLEN "ll"
++#define LUA_INTFRM_T long long
++
++#else
++
++#define LUA_INTFRMLEN "l"
++#define LUA_INTFRM_T long
++
++#endif
++
++/* =================================================================== */
++
++/*
++** Local configuration. You can use this space to add your redefinitions
++** without modifying the main part of the file.
++*/
++
++
++
++#endif
++
+--- /dev/null
++++ b/extensions/LUA/lua/lua.h
+@@ -0,0 +1,387 @@
++/*
++** $Id: lua.h,v 1.218.1.5 2008/08/06 13:30:12 roberto Exp $
++** Lua - An Extensible Extension Language
++** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
++** See Copyright Notice at the end of this file
++*/
++
++
++#ifndef lua_h
++#define lua_h
++
++#include <stdarg.h>
++#include <stddef.h>
++
++#include "luaconf.h"
++
++
++#define LUA_VERSION "Lua 5.1"
++#define LUA_RELEASE "Lua 5.1.4"
++#define LUA_VERSION_NUM 501
++#define LUA_COPYRIGHT "Copyright (C) 1994-2008 Lua.org, PUC-Rio"
++#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo & W. Celes"
++
++
++/* mark for precompiled code (`<esc>Lua') */
++#define LUA_SIGNATURE "\033Lua"
++
++/* option for multiple returns in `lua_pcall' and `lua_call' */
++#define LUA_MULTRET (-1)
++
++
++/*
++** pseudo-indices
++*/
++#define LUA_REGISTRYINDEX (-10000)
++#define LUA_ENVIRONINDEX (-10001)
++#define LUA_GLOBALSINDEX (-10002)
++#define lua_upvalueindex(i) (LUA_GLOBALSINDEX-(i))
++
++
++/* thread status; 0 is OK */
++#define LUA_YIELD 1
++#define LUA_ERRRUN 2
++#define LUA_ERRSYNTAX 3
++#define LUA_ERRMEM 4
++#define LUA_ERRERR 5
++
++
++typedef struct lua_State lua_State;
++
++typedef int (*lua_CFunction) (lua_State *L);
++
++
++/*
++** functions that read/write blocks when loading/dumping Lua chunks
++*/
++typedef const char * (*lua_Reader) (lua_State *L, void *ud, size_t *sz);
++
++typedef int (*lua_Writer) (lua_State *L, const void* p, size_t sz, void* ud);
++
++
++/*
++** prototype for memory-allocation functions
++*/
++typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize);
++
++
++/*
++** basic types
++*/
++#define LUA_TNONE (-1)
++
++#define LUA_TNIL 0
++#define LUA_TBOOLEAN 1
++#define LUA_TLIGHTUSERDATA 2
++#define LUA_TNUMBER 3
++#define LUA_TSTRING 4
++#define LUA_TTABLE 5
++#define LUA_TFUNCTION 6
++#define LUA_TUSERDATA 7
++#define LUA_TTHREAD 8
++
++
++
++/* minimum Lua stack available to a C function */
++#define LUA_MINSTACK 20
++
++
++/*
++** generic extra include file
++*/
++#if defined(LUA_USER_H)
++#include LUA_USER_H
++#endif
++
++
++/* type of numbers in Lua */
++typedef LUA_NUMBER lua_Number;
++
++
++/* type for integer functions */
++typedef LUA_INTEGER lua_Integer;
++
++
++
++/*
++** state manipulation
++*/
++LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud);
++LUA_API void (lua_close) (lua_State *L);
++LUA_API lua_State *(lua_newthread) (lua_State *L);
++
++LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf);
++
++
++/*
++** basic stack manipulation
++*/
++LUA_API int (lua_gettop) (lua_State *L);
++LUA_API void (lua_settop) (lua_State *L, int idx);
++LUA_API void (lua_pushvalue) (lua_State *L, int idx);
++LUA_API void (lua_remove) (lua_State *L, int idx);
++LUA_API void (lua_insert) (lua_State *L, int idx);
++LUA_API void (lua_replace) (lua_State *L, int idx);
++LUA_API int (lua_checkstack) (lua_State *L, int sz);
++
++LUA_API void (lua_xmove) (lua_State *from, lua_State *to, int n);
++
++
++/*
++** access functions (stack -> C)
++*/
++
++LUA_API int (lua_isnumber) (lua_State *L, int idx);
++LUA_API int (lua_isstring) (lua_State *L, int idx);
++LUA_API int (lua_iscfunction) (lua_State *L, int idx);
++LUA_API int (lua_isuserdata) (lua_State *L, int idx);
++LUA_API int (lua_type) (lua_State *L, int idx);
++LUA_API const char *(lua_typename) (lua_State *L, int tp);
++
++LUA_API int (lua_equal) (lua_State *L, int idx1, int idx2);
++LUA_API int (lua_rawequal) (lua_State *L, int idx1, int idx2);
++LUA_API int (lua_lessthan) (lua_State *L, int idx1, int idx2);
++
++LUA_API lua_Number (lua_tonumber) (lua_State *L, int idx);
++LUA_API lua_Integer (lua_tointeger) (lua_State *L, int idx);
++LUA_API int (lua_toboolean) (lua_State *L, int idx);
++LUA_API const char *(lua_tolstring) (lua_State *L, int idx, size_t *len);
++LUA_API size_t (lua_objlen) (lua_State *L, int idx);
++LUA_API lua_CFunction (lua_tocfunction) (lua_State *L, int idx);
++LUA_API void *(lua_touserdata) (lua_State *L, int idx);
++LUA_API lua_State *(lua_tothread) (lua_State *L, int idx);
++LUA_API const void *(lua_topointer) (lua_State *L, int idx);
++
++
++/*
++** push functions (C -> stack)
++*/
++LUA_API void (lua_pushnil) (lua_State *L);
++LUA_API void (lua_pushnumber) (lua_State *L, lua_Number n);
++LUA_API void (lua_pushinteger) (lua_State *L, lua_Integer n);
++LUA_API void (lua_pushlstring) (lua_State *L, const char *s, size_t l);
++LUA_API void (lua_pushstring) (lua_State *L, const char *s);
++LUA_API const char *(lua_pushvfstring) (lua_State *L, const char *fmt,
++ va_list argp);
++LUA_API const char *(lua_pushfstring) (lua_State *L, const char *fmt, ...);
++LUA_API void (lua_pushcclosure) (lua_State *L, lua_CFunction fn, int n);
++LUA_API void (lua_pushboolean) (lua_State *L, int b);
++LUA_API void (lua_pushlightuserdata) (lua_State *L, void *p);
++LUA_API int (lua_pushthread) (lua_State *L);
++
++
++/*
++** get functions (Lua -> stack)
++*/
++LUA_API void (lua_gettable) (lua_State *L, int idx);
++LUA_API void (lua_getfield) (lua_State *L, int idx, const char *k);
++LUA_API void (lua_rawget) (lua_State *L, int idx);
++LUA_API void (lua_rawgeti) (lua_State *L, int idx, int n);
++LUA_API void (lua_createtable) (lua_State *L, int narr, int nrec);
++LUA_API void *(lua_newuserdata) (lua_State *L, size_t sz);
++LUA_API int (lua_getmetatable) (lua_State *L, int objindex);
++LUA_API void (lua_getfenv) (lua_State *L, int idx);
++
++
++/*
++** set functions (stack -> Lua)
++*/
++LUA_API void (lua_settable) (lua_State *L, int idx);
++LUA_API void (lua_setfield) (lua_State *L, int idx, const char *k);
++LUA_API void (lua_rawset) (lua_State *L, int idx);
++LUA_API void (lua_rawseti) (lua_State *L, int idx, int n);
++LUA_API int (lua_setmetatable) (lua_State *L, int objindex);
++LUA_API int (lua_setfenv) (lua_State *L, int idx);
++
++
++/*
++** `load' and `call' functions (load and run Lua code)
++*/
++LUA_API void (lua_call) (lua_State *L, int nargs, int nresults);
++LUA_API int (lua_pcall) (lua_State *L, int nargs, int nresults, int errfunc);
++LUA_API int (lua_cpcall) (lua_State *L, lua_CFunction func, void *ud);
++LUA_API int (lua_load) (lua_State *L, lua_Reader reader, void *dt,
++ const char *chunkname);
++
++LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data);
++
++
++/*
++** coroutine functions
++*/
++LUA_API int (lua_yield) (lua_State *L, int nresults);
++LUA_API int (lua_resume) (lua_State *L, int narg);
++LUA_API int (lua_status) (lua_State *L);
++
++/*
++** garbage-collection function and options
++*/
++
++#define LUA_GCSTOP 0
++#define LUA_GCRESTART 1
++#define LUA_GCCOLLECT 2
++#define LUA_GCCOUNT 3
++#define LUA_GCCOUNTB 4
++#define LUA_GCSTEP 5
++#define LUA_GCSETPAUSE 6
++#define LUA_GCSETSTEPMUL 7
++
++LUA_API int (lua_gc) (lua_State *L, int what, int data);
++
++
++/*
++** miscellaneous functions
++*/
++
++LUA_API int (lua_error) (lua_State *L);
++
++LUA_API int (lua_next) (lua_State *L, int idx);
++
++LUA_API void (lua_concat) (lua_State *L, int n);
++
++LUA_API lua_Alloc (lua_getallocf) (lua_State *L, void **ud);
++LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud);
++
++
++
++/*
++** ===============================================================
++** some useful macros
++** ===============================================================
++*/
++
++#define lua_pop(L,n) lua_settop(L, -(n)-1)
++
++#define lua_newtable(L) lua_createtable(L, 0, 0)
++
++#define lua_register(L,n,f) (lua_pushcfunction(L, (f)), lua_setglobal(L, (n)))
++
++#define lua_pushcfunction(L,f) lua_pushcclosure(L, (f), 0)
++
++#define lua_strlen(L,i) lua_objlen(L, (i))
++
++#define lua_isfunction(L,n) (lua_type(L, (n)) == LUA_TFUNCTION)
++#define lua_istable(L,n) (lua_type(L, (n)) == LUA_TTABLE)
++#define lua_islightuserdata(L,n) (lua_type(L, (n)) == LUA_TLIGHTUSERDATA)
++#define lua_isnil(L,n) (lua_type(L, (n)) == LUA_TNIL)
++#define lua_isboolean(L,n) (lua_type(L, (n)) == LUA_TBOOLEAN)
++#define lua_isthread(L,n) (lua_type(L, (n)) == LUA_TTHREAD)
++#define lua_isnone(L,n) (lua_type(L, (n)) == LUA_TNONE)
++#define lua_isnoneornil(L, n) (lua_type(L, (n)) <= 0)
++
++#define lua_pushliteral(L, s) \
++ lua_pushlstring(L, "" s, (sizeof(s)/sizeof(char))-1)
++
++#define lua_setglobal(L,s) lua_setfield(L, LUA_GLOBALSINDEX, (s))
++#define lua_getglobal(L,s) lua_getfield(L, LUA_GLOBALSINDEX, (s))
++
++#define lua_tostring(L,i) lua_tolstring(L, (i), NULL)
++
++
++
++/*
++** compatibility macros and functions
++*/
++
++#define lua_open() luaL_newstate()
++
++#define lua_getregistry(L) lua_pushvalue(L, LUA_REGISTRYINDEX)
++
++#define lua_getgccount(L) lua_gc(L, LUA_GCCOUNT, 0)
++
++#define lua_Chunkreader lua_Reader
++#define lua_Chunkwriter lua_Writer
++
++
++/* hack */
++LUA_API void lua_setlevel (lua_State *from, lua_State *to);
++
++
++/*
++** {======================================================================
++** Debug API
++** =======================================================================
++*/
++
++
++/*
++** Event codes
++*/
++#define LUA_HOOKCALL 0
++#define LUA_HOOKRET 1
++#define LUA_HOOKLINE 2
++#define LUA_HOOKCOUNT 3
++#define LUA_HOOKTAILRET 4
++
++
++/*
++** Event masks
++*/
++#define LUA_MASKCALL (1 << LUA_HOOKCALL)
++#define LUA_MASKRET (1 << LUA_HOOKRET)
++#define LUA_MASKLINE (1 << LUA_HOOKLINE)
++#define LUA_MASKCOUNT (1 << LUA_HOOKCOUNT)
++
++typedef struct lua_Debug lua_Debug; /* activation record */
++
++
++/* Functions to be called by the debuger in specific events */
++typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar);
++
++
++LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar);
++LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar);
++LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n);
++LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n);
++LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n);
++LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n);
++
++LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count);
++LUA_API lua_Hook lua_gethook (lua_State *L);
++LUA_API int lua_gethookmask (lua_State *L);
++LUA_API int lua_gethookcount (lua_State *L);
++
++
++struct lua_Debug {
++ int event;
++ const char *name; /* (n) */
++ const char *namewhat; /* (n) `global', `local', `field', `method' */
++ const char *what; /* (S) `Lua', `C', `main', `tail' */
++ const char *source; /* (S) */
++ int currentline; /* (l) */
++ int nups; /* (u) number of upvalues */
++ int linedefined; /* (S) */
++ int lastlinedefined; /* (S) */
++ char short_src[LUA_IDSIZE]; /* (S) */
++ /* private part */
++ int i_ci; /* active function */
++};
++
++/* }====================================================================== */
++
++
++/******************************************************************************
++* Copyright (C) 1994-2008 Lua.org, PUC-Rio. All rights reserved.
++*
++* Permission is hereby granted, free of charge, to any person obtaining
++* a copy of this software and associated documentation files (the
++* "Software"), to deal in the Software without restriction, including
++* without limitation the rights to use, copy, modify, merge, publish,
++* distribute, sublicense, and/or sell copies of the Software, and to
++* permit persons to whom the Software is furnished to do so, subject to
++* the following conditions:
++*
++* The above copyright notice and this permission notice shall be
++* included in all copies or substantial portions of the Software.
++*
++* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
++* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
++* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
++* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
++* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
++* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
++* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++******************************************************************************/
++
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/lualib.h
+@@ -0,0 +1,55 @@
++/*
++** $Id: lualib.h,v 1.36.1.1 2007/12/27 13:02:25 roberto Exp $
++** Lua standard libraries
++** See Copyright Notice in lua.h
++*/
++
++
++#ifndef lualib_h
++#define lualib_h
++
++#include "lua.h"
++
++
++/* Key to file-handle type */
++#define LUA_FILEHANDLE "FILE*"
++
++
++#define LUA_COLIBNAME "coroutine"
++LUALIB_API int (luaopen_base) (lua_State *L);
++
++#define LUA_TABLIBNAME "table"
++LUALIB_API int (luaopen_table) (lua_State *L);
++/*
++#define LUA_IOLIBNAME "io"
++LUALIB_API int (luaopen_io) (lua_State *L);
++
++#define LUA_OSLIBNAME "os"
++LUALIB_API int (luaopen_os) (lua_State *L);
++*/
++
++#define LUA_STRLIBNAME "string"
++LUALIB_API int (luaopen_string) (lua_State *L);
++
++/*
++#define LUA_MATHLIBNAME "math"
++LUALIB_API int (luaopen_math) (lua_State *L);
++
++#define LUA_DBLIBNAME "debug"
++LUALIB_API int (luaopen_debug) (lua_State *L);
++
++#define LUA_LOADLIBNAME "package"
++LUALIB_API int (luaopen_package) (lua_State *L);
++*/
++
++/* open all previous libraries */
++LUALIB_API void (luaL_openlibs) (lua_State *L);
++
++
++
++#ifndef lua_assert
++#define lua_assert(x) ((void)0)
++#endif
++
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/lundump.c
+@@ -0,0 +1,227 @@
++/*
++** $Id: lundump.c,v 2.7.1.4 2008/04/04 19:51:41 roberto Exp $
++** load precompiled Lua chunks
++** See Copyright Notice in lua.h
++*/
++
++#include <string.h>
++
++#define lundump_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "ldebug.h"
++#include "ldo.h"
++#include "lfunc.h"
++#include "lmem.h"
++#include "lobject.h"
++#include "lstring.h"
++#include "lundump.h"
++#include "lzio.h"
++
++typedef struct {
++ lua_State* L;
++ ZIO* Z;
++ Mbuffer* b;
++ const char* name;
++} LoadState;
++
++#ifdef LUAC_TRUST_BINARIES
++#define IF(c,s)
++#define error(S,s)
++#else
++#define IF(c,s) if (c) error(S,s)
++
++static void error(LoadState* S, const char* why)
++{
++ luaO_pushfstring(S->L,"%s: %s in precompiled chunk",S->name,why);
++ luaD_throw(S->L,LUA_ERRSYNTAX);
++}
++#endif
++
++#define LoadMem(S,b,n,size) LoadBlock(S,b,(n)*(size))
++#define LoadByte(S) (lu_byte)LoadChar(S)
++#define LoadVar(S,x) LoadMem(S,&x,1,sizeof(x))
++#define LoadVector(S,b,n,size) LoadMem(S,b,n,size)
++
++static void LoadBlock(LoadState* S, void* b, size_t size)
++{
++ size_t r=luaZ_read(S->Z,b,size);
++ IF (r!=0, "unexpected end");
++}
++
++static int LoadChar(LoadState* S)
++{
++ char x;
++ LoadVar(S,x);
++ return x;
++}
++
++static int LoadInt(LoadState* S)
++{
++ int x;
++ LoadVar(S,x);
++ IF (x<0, "bad integer");
++ return x;
++}
++
++static lua_Number LoadNumber(LoadState* S)
++{
++ lua_Number x;
++ LoadVar(S,x);
++ return x;
++}
++
++static TString* LoadString(LoadState* S)
++{
++ size_t size;
++ LoadVar(S,size);
++ if (size==0)
++ return NULL;
++ else
++ {
++ char* s=luaZ_openspace(S->L,S->b,size);
++ LoadBlock(S,s,size);
++ return luaS_newlstr(S->L,s,size-1); /* remove trailing '\0' */
++ }
++}
++
++static void LoadCode(LoadState* S, Proto* f)
++{
++ int n=LoadInt(S);
++ f->code=luaM_newvector(S->L,n,Instruction);
++ f->sizecode=n;
++ LoadVector(S,f->code,n,sizeof(Instruction));
++}
++
++static Proto* LoadFunction(LoadState* S, TString* p);
++
++static void LoadConstants(LoadState* S, Proto* f)
++{
++ int i,n;
++ n=LoadInt(S);
++ f->k=luaM_newvector(S->L,n,TValue);
++ f->sizek=n;
++ for (i=0; i<n; i++) setnilvalue(&f->k[i]);
++ for (i=0; i<n; i++)
++ {
++ TValue* o=&f->k[i];
++ int t=LoadChar(S);
++ switch (t)
++ {
++ case LUA_TNIL:
++ setnilvalue(o);
++ break;
++ case LUA_TBOOLEAN:
++ setbvalue(o,LoadChar(S)!=0);
++ break;
++ case LUA_TNUMBER:
++ setnvalue(o,LoadNumber(S));
++ break;
++ case LUA_TSTRING:
++ setsvalue2n(S->L,o,LoadString(S));
++ break;
++ default:
++ error(S,"bad constant");
++ break;
++ }
++ }
++ n=LoadInt(S);
++ f->p=luaM_newvector(S->L,n,Proto*);
++ f->sizep=n;
++ for (i=0; i<n; i++) f->p[i]=NULL;
++ for (i=0; i<n; i++) f->p[i]=LoadFunction(S,f->source);
++}
++
++static void LoadDebug(LoadState* S, Proto* f)
++{
++ int i,n;
++ n=LoadInt(S);
++ f->lineinfo=luaM_newvector(S->L,n,int);
++ f->sizelineinfo=n;
++ LoadVector(S,f->lineinfo,n,sizeof(int));
++ n=LoadInt(S);
++ f->locvars=luaM_newvector(S->L,n,LocVar);
++ f->sizelocvars=n;
++ for (i=0; i<n; i++) f->locvars[i].varname=NULL;
++ for (i=0; i<n; i++)
++ {
++ f->locvars[i].varname=LoadString(S);
++ f->locvars[i].startpc=LoadInt(S);
++ f->locvars[i].endpc=LoadInt(S);
++ }
++ n=LoadInt(S);
++ f->upvalues=luaM_newvector(S->L,n,TString*);
++ f->sizeupvalues=n;
++ for (i=0; i<n; i++) f->upvalues[i]=NULL;
++ for (i=0; i<n; i++) f->upvalues[i]=LoadString(S);
++}
++
++static Proto* LoadFunction(LoadState* S, TString* p)
++{
++ Proto* f;
++ if (++S->L->nCcalls > LUAI_MAXCCALLS) error(S,"code too deep");
++ f=luaF_newproto(S->L);
++ setptvalue2s(S->L,S->L->top,f); incr_top(S->L);
++ f->source=LoadString(S); if (f->source==NULL) f->source=p;
++ f->linedefined=LoadInt(S);
++ f->lastlinedefined=LoadInt(S);
++ f->nups=LoadByte(S);
++ f->numparams=LoadByte(S);
++ f->is_vararg=LoadByte(S);
++ f->maxstacksize=LoadByte(S);
++ LoadCode(S,f);
++ LoadConstants(S,f);
++ LoadDebug(S,f);
++ IF (!luaG_checkcode(f), "bad code");
++ S->L->top--;
++ S->L->nCcalls--;
++ return f;
++}
++
++static void LoadHeader(LoadState* S)
++{
++ char h[LUAC_HEADERSIZE];
++ char s[LUAC_HEADERSIZE];
++ luaU_header(h);
++ LoadBlock(S,s,LUAC_HEADERSIZE);
++ IF (memcmp(h,s,LUAC_HEADERSIZE)!=0, "bad header");
++}
++
++/*
++** load precompiled chunk
++*/
++Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name)
++{
++ LoadState S;
++ if (*name=='@' || *name=='=')
++ S.name=name+1;
++ else if (*name==LUA_SIGNATURE[0])
++ S.name="binary string";
++ else
++ S.name=name;
++ S.L=L;
++ S.Z=Z;
++ S.b=buff;
++ LoadHeader(&S);
++ return LoadFunction(&S,luaS_newliteral(L,"=?"));
++}
++
++/*
++* make header
++*/
++void luaU_header (char* h)
++{
++ int x=1;
++ memcpy(h,LUA_SIGNATURE,sizeof(LUA_SIGNATURE)-1);
++ h+=sizeof(LUA_SIGNATURE)-1;
++ *h++=(char)LUAC_VERSION;
++ *h++=(char)LUAC_FORMAT;
++ *h++=(char)*(char*)&x; /* endianness */
++ *h++=(char)sizeof(int);
++ *h++=(char)sizeof(size_t);
++ *h++=(char)sizeof(Instruction);
++ *h++=(char)sizeof(lua_Number);
++ *h++=(char)(((lua_Number)0.5)==0); /* is lua_Number integral? */
++}
+--- /dev/null
++++ b/extensions/LUA/lua/lundump.h
+@@ -0,0 +1,36 @@
++/*
++** $Id: lundump.h,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $
++** load precompiled Lua chunks
++** See Copyright Notice in lua.h
++*/
++
++#ifndef lundump_h
++#define lundump_h
++
++#include "lobject.h"
++#include "lzio.h"
++
++/* load one chunk; from lundump.c */
++LUAI_FUNC Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name);
++
++/* make header; from lundump.c */
++LUAI_FUNC void luaU_header (char* h);
++
++/* dump one chunk; from ldump.c */
++LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip);
++
++#ifdef luac_c
++/* print one chunk; from print.c */
++LUAI_FUNC void luaU_print (const Proto* f, int full);
++#endif
++
++/* for header of binary files -- this is Lua 5.1 */
++#define LUAC_VERSION 0x51
++
++/* for header of binary files -- this is the official format */
++#define LUAC_FORMAT 0
++
++/* size of header of binary files */
++#define LUAC_HEADERSIZE 12
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/lvm.c
+@@ -0,0 +1,762 @@
++/*
++** $Id: lvm.c,v 2.63.1.3 2007/12/28 15:32:23 roberto Exp $
++** Lua virtual machine
++** See Copyright Notice in lua.h
++*/
++
++#include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
++
++#define lvm_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "ldebug.h"
++#include "ldo.h"
++#include "lfunc.h"
++#include "lgc.h"
++#include "lobject.h"
++#include "lopcodes.h"
++#include "lstate.h"
++#include "lstring.h"
++#include "ltable.h"
++#include "ltm.h"
++#include "lvm.h"
++
++
++
++/* limit for table tag-method chains (to avoid loops) */
++#define MAXTAGLOOP 100
++
++
++const TValue *luaV_tonumber (const TValue *obj, TValue *n) {
++ lua_Number num;
++ if (ttisnumber(obj)) return obj;
++ if (ttisstring(obj) && luaO_str2d(svalue(obj), &num)) {
++ setnvalue(n, num);
++ return n;
++ }
++ else
++ return NULL;
++}
++
++
++int luaV_tostring (lua_State *L, StkId obj) {
++ if (!ttisnumber(obj))
++ return 0;
++ else {
++ char s[LUAI_MAXNUMBER2STR];
++ lua_Number n = nvalue(obj);
++ lua_number2str(s, n);
++ setsvalue2s(L, obj, luaS_new(L, s));
++ return 1;
++ }
++}
++
++
++static void traceexec (lua_State *L, const Instruction *pc) {
++ lu_byte mask = L->hookmask;
++ const Instruction *oldpc = L->savedpc;
++ L->savedpc = pc;
++ if ((mask & LUA_MASKCOUNT) && L->hookcount == 0) {
++ resethookcount(L);
++ luaD_callhook(L, LUA_HOOKCOUNT, -1);
++ }
++ if (mask & LUA_MASKLINE) {
++ Proto *p = ci_func(L->ci)->l.p;
++ int npc = pcRel(pc, p);
++ int newline = getline(p, npc);
++ /* call linehook when enter a new function, when jump back (loop),
++ or when enter a new line */
++ if (npc == 0 || pc <= oldpc || newline != getline(p, pcRel(oldpc, p)))
++ luaD_callhook(L, LUA_HOOKLINE, newline);
++ }
++}
++
++
++static void callTMres (lua_State *L, StkId res, const TValue *f,
++ const TValue *p1, const TValue *p2) {
++ ptrdiff_t result = savestack(L, res);
++ setobj2s(L, L->top, f); /* push function */
++ setobj2s(L, L->top+1, p1); /* 1st argument */
++ setobj2s(L, L->top+2, p2); /* 2nd argument */
++ luaD_checkstack(L, 3);
++ L->top += 3;
++ luaD_call(L, L->top - 3, 1);
++ res = restorestack(L, result);
++ L->top--;
++ setobjs2s(L, res, L->top);
++}
++
++
++
++static void callTM (lua_State *L, const TValue *f, const TValue *p1,
++ const TValue *p2, const TValue *p3) {
++ setobj2s(L, L->top, f); /* push function */
++ setobj2s(L, L->top+1, p1); /* 1st argument */
++ setobj2s(L, L->top+2, p2); /* 2nd argument */
++ setobj2s(L, L->top+3, p3); /* 3th argument */
++ luaD_checkstack(L, 4);
++ L->top += 4;
++ luaD_call(L, L->top - 4, 0);
++}
++
++
++void luaV_gettable (lua_State *L, const TValue *t, TValue *key, StkId val) {
++ int loop;
++ for (loop = 0; loop < MAXTAGLOOP; loop++) {
++ const TValue *tm;
++ if (ttistable(t)) { /* `t' is a table? */
++ Table *h = hvalue(t);
++ const TValue *res = luaH_get(h, key); /* do a primitive get */
++ if (!ttisnil(res) || /* result is no nil? */
++ (tm = fasttm(L, h->metatable, TM_INDEX)) == NULL) { /* or no TM? */
++ setobj2s(L, val, res);
++ return;
++ }
++ /* else will try the tag method */
++ }
++ else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_INDEX)))
++ luaG_typeerror(L, t, "index");
++ if (ttisfunction(tm)) {
++ callTMres(L, val, tm, t, key);
++ return;
++ }
++ t = tm; /* else repeat with `tm' */
++ }
++ luaG_runerror(L, "loop in gettable");
++}
++
++
++void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val) {
++ int loop;
++ for (loop = 0; loop < MAXTAGLOOP; loop++) {
++ const TValue *tm;
++ if (ttistable(t)) { /* `t' is a table? */
++ Table *h = hvalue(t);
++ TValue *oldval = luaH_set(L, h, key); /* do a primitive set */
++ if (!ttisnil(oldval) || /* result is no nil? */
++ (tm = fasttm(L, h->metatable, TM_NEWINDEX)) == NULL) { /* or no TM? */
++ setobj2t(L, oldval, val);
++ luaC_barriert(L, h, val);
++ return;
++ }
++ /* else will try the tag method */
++ }
++ else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_NEWINDEX)))
++ luaG_typeerror(L, t, "index");
++ if (ttisfunction(tm)) {
++ callTM(L, tm, t, key, val);
++ return;
++ }
++ t = tm; /* else repeat with `tm' */
++ }
++ luaG_runerror(L, "loop in settable");
++}
++
++
++static int call_binTM (lua_State *L, const TValue *p1, const TValue *p2,
++ StkId res, TMS event) {
++ const TValue *tm = luaT_gettmbyobj(L, p1, event); /* try first operand */
++ if (ttisnil(tm))
++ tm = luaT_gettmbyobj(L, p2, event); /* try second operand */
++ if (ttisnil(tm)) return 0;
++ callTMres(L, res, tm, p1, p2);
++ return 1;
++}
++
++
++static const TValue *get_compTM (lua_State *L, Table *mt1, Table *mt2,
++ TMS event) {
++ const TValue *tm1 = fasttm(L, mt1, event);
++ const TValue *tm2;
++ if (tm1 == NULL) return NULL; /* no metamethod */
++ if (mt1 == mt2) return tm1; /* same metatables => same metamethods */
++ tm2 = fasttm(L, mt2, event);
++ if (tm2 == NULL) return NULL; /* no metamethod */
++ if (luaO_rawequalObj(tm1, tm2)) /* same metamethods? */
++ return tm1;
++ return NULL;
++}
++
++
++static int call_orderTM (lua_State *L, const TValue *p1, const TValue *p2,
++ TMS event) {
++ const TValue *tm1 = luaT_gettmbyobj(L, p1, event);
++ const TValue *tm2;
++ if (ttisnil(tm1)) return -1; /* no metamethod? */
++ tm2 = luaT_gettmbyobj(L, p2, event);
++ if (!luaO_rawequalObj(tm1, tm2)) /* different metamethods? */
++ return -1;
++ callTMres(L, L->top, tm1, p1, p2);
++ return !l_isfalse(L->top);
++}
++
++
++static int l_strcmp (const TString *ls, const TString *rs) {
++ const char *l = getstr(ls);
++ size_t ll = ls->tsv.len;
++ const char *r = getstr(rs);
++ size_t lr = rs->tsv.len;
++ for (;;) {
++ int temp = strcoll(l, r);
++ if (temp != 0) return temp;
++ else { /* strings are equal up to a `\0' */
++ size_t len = strlen(l); /* index of first `\0' in both strings */
++ if (len == lr) /* r is finished? */
++ return (len == ll) ? 0 : 1;
++ else if (len == ll) /* l is finished? */
++ return -1; /* l is smaller than r (because r is not finished) */
++ /* both strings longer than `len'; go on comparing (after the `\0') */
++ len++;
++ l += len; ll -= len; r += len; lr -= len;
++ }
++ }
++}
++
++
++int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r) {
++ int res;
++ if (ttype(l) != ttype(r))
++ return luaG_ordererror(L, l, r);
++ else if (ttisnumber(l))
++ return luai_numlt(nvalue(l), nvalue(r));
++ else if (ttisstring(l))
++ return l_strcmp(rawtsvalue(l), rawtsvalue(r)) < 0;
++ else if ((res = call_orderTM(L, l, r, TM_LT)) != -1)
++ return res;
++ return luaG_ordererror(L, l, r);
++}
++
++
++static int lessequal (lua_State *L, const TValue *l, const TValue *r) {
++ int res;
++ if (ttype(l) != ttype(r))
++ return luaG_ordererror(L, l, r);
++ else if (ttisnumber(l))
++ return luai_numle(nvalue(l), nvalue(r));
++ else if (ttisstring(l))
++ return l_strcmp(rawtsvalue(l), rawtsvalue(r)) <= 0;
++ else if ((res = call_orderTM(L, l, r, TM_LE)) != -1) /* first try `le' */
++ return res;
++ else if ((res = call_orderTM(L, r, l, TM_LT)) != -1) /* else try `lt' */
++ return !res;
++ return luaG_ordererror(L, l, r);
++}
++
++
++int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2) {
++ const TValue *tm;
++ lua_assert(ttype(t1) == ttype(t2));
++ switch (ttype(t1)) {
++ case LUA_TNIL: return 1;
++ case LUA_TNUMBER: return luai_numeq(nvalue(t1), nvalue(t2));
++ case LUA_TBOOLEAN: return bvalue(t1) == bvalue(t2); /* true must be 1 !! */
++ case LUA_TLIGHTUSERDATA: return pvalue(t1) == pvalue(t2);
++ case LUA_TUSERDATA: {
++ if (uvalue(t1) == uvalue(t2)) return 1;
++ tm = get_compTM(L, uvalue(t1)->metatable, uvalue(t2)->metatable,
++ TM_EQ);
++ break; /* will try TM */
++ }
++ case LUA_TTABLE: {
++ if (hvalue(t1) == hvalue(t2)) return 1;
++ tm = get_compTM(L, hvalue(t1)->metatable, hvalue(t2)->metatable, TM_EQ);
++ break; /* will try TM */
++ }
++ default: return gcvalue(t1) == gcvalue(t2);
++ }
++ if (tm == NULL) return 0; /* no TM? */
++ callTMres(L, L->top, tm, t1, t2); /* call TM */
++ return !l_isfalse(L->top);
++}
++
++
++void luaV_concat (lua_State *L, int total, int last) {
++ do {
++ StkId top = L->base + last + 1;
++ int n = 2; /* number of elements handled in this pass (at least 2) */
++ if (!(ttisstring(top-2) || ttisnumber(top-2)) || !tostring(L, top-1)) {
++ if (!call_binTM(L, top-2, top-1, top-2, TM_CONCAT))
++ luaG_concaterror(L, top-2, top-1);
++ } else if (tsvalue(top-1)->len == 0) /* second op is empty? */
++ (void)tostring(L, top - 2); /* result is first op (as string) */
++ else {
++ /* at least two string values; get as many as possible */
++ size_t tl = tsvalue(top-1)->len;
++ char *buffer;
++ int i;
++ /* collect total length */
++ for (n = 1; n < total && tostring(L, top-n-1); n++) {
++ size_t l = tsvalue(top-n-1)->len;
++ if (l >= MAX_SIZET - tl) luaG_runerror(L, "string length overflow");
++ tl += l;
++ }
++ buffer = luaZ_openspace(L, &G(L)->buff, tl);
++ tl = 0;
++ for (i=n; i>0; i--) { /* concat all strings */
++ size_t l = tsvalue(top-i)->len;
++ memcpy(buffer+tl, svalue(top-i), l);
++ tl += l;
++ }
++ setsvalue2s(L, top-n, luaS_newlstr(L, buffer, tl));
++ }
++ total -= n-1; /* got `n' strings to create 1 new */
++ last -= n-1;
++ } while (total > 1); /* repeat until only 1 result left */
++}
++
++
++static void Arith (lua_State *L, StkId ra, const TValue *rb,
++ const TValue *rc, TMS op) {
++ TValue tempb, tempc;
++ const TValue *b, *c;
++ if ((b = luaV_tonumber(rb, &tempb)) != NULL &&
++ (c = luaV_tonumber(rc, &tempc)) != NULL) {
++ lua_Number nb = nvalue(b), nc = nvalue(c);
++ switch (op) {
++ case TM_ADD: setnvalue(ra, luai_numadd(nb, nc)); break;
++ case TM_SUB: setnvalue(ra, luai_numsub(nb, nc)); break;
++ case TM_MUL: setnvalue(ra, luai_nummul(nb, nc)); break;
++ case TM_DIV: setnvalue(ra, luai_numdiv(nb, nc)); break;
++ case TM_MOD: setnvalue(ra, luai_nummod(nb, nc)); break;
++ case TM_POW: setnvalue(ra, luai_numpow(nb, nc)); break;
++ case TM_UNM: setnvalue(ra, luai_numunm(nb)); break;
++ default: lua_assert(0); break;
++ }
++ }
++ else if (!call_binTM(L, rb, rc, ra, op))
++ luaG_aritherror(L, rb, rc);
++}
++
++
++
++/*
++** some macros for common tasks in `luaV_execute'
++*/
++
++#define runtime_check(L, c) { if (!(c)) break; }
++
++#define RA(i) (base+GETARG_A(i))
++/* to be used after possible stack reallocation */
++#define RB(i) check_exp(getBMode(GET_OPCODE(i)) == OpArgR, base+GETARG_B(i))
++#define RC(i) check_exp(getCMode(GET_OPCODE(i)) == OpArgR, base+GETARG_C(i))
++#define RKB(i) check_exp(getBMode(GET_OPCODE(i)) == OpArgK, \
++ ISK(GETARG_B(i)) ? k+INDEXK(GETARG_B(i)) : base+GETARG_B(i))
++#define RKC(i) check_exp(getCMode(GET_OPCODE(i)) == OpArgK, \
++ ISK(GETARG_C(i)) ? k+INDEXK(GETARG_C(i)) : base+GETARG_C(i))
++#define KBx(i) check_exp(getBMode(GET_OPCODE(i)) == OpArgK, k+GETARG_Bx(i))
++
++
++#define dojump(L,pc,i) {(pc) += (i); luai_threadyield(L);}
++
++
++#define Protect(x) { L->savedpc = pc; {x;}; base = L->base; }
++
++
++#define arith_op(op,tm) { \
++ TValue *rb = RKB(i); \
++ TValue *rc = RKC(i); \
++ if (ttisnumber(rb) && ttisnumber(rc)) { \
++ lua_Number nb = nvalue(rb), nc = nvalue(rc); \
++ setnvalue(ra, op(nb, nc)); \
++ } \
++ else \
++ Protect(Arith(L, ra, rb, rc, tm)); \
++ }
++
++
++
++void luaV_execute (lua_State *L, int nexeccalls) {
++ LClosure *cl;
++ StkId base;
++ TValue *k;
++ const Instruction *pc;
++ reentry: /* entry point */
++ lua_assert(isLua(L->ci));
++ pc = L->savedpc;
++ cl = &clvalue(L->ci->func)->l;
++ base = L->base;
++ k = cl->p->k;
++ /* main loop of interpreter */
++ for (;;) {
++ const Instruction i = *pc++;
++ StkId ra;
++ if ((L->hookmask & (LUA_MASKLINE | LUA_MASKCOUNT)) &&
++ (--L->hookcount == 0 || L->hookmask & LUA_MASKLINE)) {
++ traceexec(L, pc);
++ if (L->status == LUA_YIELD) { /* did hook yield? */
++ L->savedpc = pc - 1;
++ return;
++ }
++ base = L->base;
++ }
++ /* warning!! several calls may realloc the stack and invalidate `ra' */
++ ra = RA(i);
++ lua_assert(base == L->base && L->base == L->ci->base);
++ lua_assert(base <= L->top && L->top <= L->stack + L->stacksize);
++ lua_assert(L->top == L->ci->top || luaG_checkopenop(i));
++ switch (GET_OPCODE(i)) {
++ case OP_MOVE: {
++ setobjs2s(L, ra, RB(i));
++ continue;
++ }
++ case OP_LOADK: {
++ setobj2s(L, ra, KBx(i));
++ continue;
++ }
++ case OP_LOADBOOL: {
++ setbvalue(ra, GETARG_B(i));
++ if (GETARG_C(i)) pc++; /* skip next instruction (if C) */
++ continue;
++ }
++ case OP_LOADNIL: {
++ TValue *rb = RB(i);
++ do {
++ setnilvalue(rb--);
++ } while (rb >= ra);
++ continue;
++ }
++ case OP_GETUPVAL: {
++ int b = GETARG_B(i);
++ setobj2s(L, ra, cl->upvals[b]->v);
++ continue;
++ }
++ case OP_GETGLOBAL: {
++ TValue g;
++ TValue *rb = KBx(i);
++ sethvalue(L, &g, cl->env);
++ lua_assert(ttisstring(rb));
++ Protect(luaV_gettable(L, &g, rb, ra));
++ continue;
++ }
++ case OP_GETTABLE: {
++ Protect(luaV_gettable(L, RB(i), RKC(i), ra));
++ continue;
++ }
++ case OP_SETGLOBAL: {
++ TValue g;
++ sethvalue(L, &g, cl->env);
++ lua_assert(ttisstring(KBx(i)));
++ Protect(luaV_settable(L, &g, KBx(i), ra));
++ continue;
++ }
++ case OP_SETUPVAL: {
++ UpVal *uv = cl->upvals[GETARG_B(i)];
++ setobj(L, uv->v, ra);
++ luaC_barrier(L, uv, ra);
++ continue;
++ }
++ case OP_SETTABLE: {
++ Protect(luaV_settable(L, ra, RKB(i), RKC(i)));
++ continue;
++ }
++ case OP_NEWTABLE: {
++ int b = GETARG_B(i);
++ int c = GETARG_C(i);
++ sethvalue(L, ra, luaH_new(L, luaO_fb2int(b), luaO_fb2int(c)));
++ Protect(luaC_checkGC(L));
++ continue;
++ }
++ case OP_SELF: {
++ StkId rb = RB(i);
++ setobjs2s(L, ra+1, rb);
++ Protect(luaV_gettable(L, rb, RKC(i), ra));
++ continue;
++ }
++ case OP_ADD: {
++ arith_op(luai_numadd, TM_ADD);
++ continue;
++ }
++ case OP_SUB: {
++ arith_op(luai_numsub, TM_SUB);
++ continue;
++ }
++ case OP_MUL: {
++ arith_op(luai_nummul, TM_MUL);
++ continue;
++ }
++ case OP_DIV: {
++ arith_op(luai_numdiv, TM_DIV);
++ continue;
++ }
++ case OP_MOD: {
++ arith_op(luai_nummod, TM_MOD);
++ continue;
++ }
++ case OP_POW: {
++ arith_op(luai_numpow, TM_POW);
++ continue;
++ }
++ case OP_UNM: {
++ TValue *rb = RB(i);
++ if (ttisnumber(rb)) {
++ lua_Number nb = nvalue(rb);
++ setnvalue(ra, luai_numunm(nb));
++ }
++ else {
++ Protect(Arith(L, ra, rb, rb, TM_UNM));
++ }
++ continue;
++ }
++ case OP_NOT: {
++ int res = l_isfalse(RB(i)); /* next assignment may change this value */
++ setbvalue(ra, res);
++ continue;
++ }
++ case OP_LEN: {
++ const TValue *rb = RB(i);
++ switch (ttype(rb)) {
++ case LUA_TTABLE: {
++ setnvalue(ra, cast_num(luaH_getn(hvalue(rb))));
++ break;
++ }
++ case LUA_TSTRING: {
++ setnvalue(ra, cast_num(tsvalue(rb)->len));
++ break;
++ }
++ default: { /* try metamethod */
++ Protect(
++ if (!call_binTM(L, rb, luaO_nilobject, ra, TM_LEN))
++ luaG_typeerror(L, rb, "get length of");
++ )
++ }
++ }
++ continue;
++ }
++ case OP_CONCAT: {
++ int b = GETARG_B(i);
++ int c = GETARG_C(i);
++ Protect(luaV_concat(L, c-b+1, c); luaC_checkGC(L));
++ setobjs2s(L, RA(i), base+b);
++ continue;
++ }
++ case OP_JMP: {
++ dojump(L, pc, GETARG_sBx(i));
++ continue;
++ }
++ case OP_EQ: {
++ TValue *rb = RKB(i);
++ TValue *rc = RKC(i);
++ Protect(
++ if (equalobj(L, rb, rc) == GETARG_A(i))
++ dojump(L, pc, GETARG_sBx(*pc));
++ )
++ pc++;
++ continue;
++ }
++ case OP_LT: {
++ Protect(
++ if (luaV_lessthan(L, RKB(i), RKC(i)) == GETARG_A(i))
++ dojump(L, pc, GETARG_sBx(*pc));
++ )
++ pc++;
++ continue;
++ }
++ case OP_LE: {
++ Protect(
++ if (lessequal(L, RKB(i), RKC(i)) == GETARG_A(i))
++ dojump(L, pc, GETARG_sBx(*pc));
++ )
++ pc++;
++ continue;
++ }
++ case OP_TEST: {
++ if (l_isfalse(ra) != GETARG_C(i))
++ dojump(L, pc, GETARG_sBx(*pc));
++ pc++;
++ continue;
++ }
++ case OP_TESTSET: {
++ TValue *rb = RB(i);
++ if (l_isfalse(rb) != GETARG_C(i)) {
++ setobjs2s(L, ra, rb);
++ dojump(L, pc, GETARG_sBx(*pc));
++ }
++ pc++;
++ continue;
++ }
++ case OP_CALL: {
++ int b = GETARG_B(i);
++ int nresults = GETARG_C(i) - 1;
++ if (b != 0) L->top = ra+b; /* else previous instruction set top */
++ L->savedpc = pc;
++ switch (luaD_precall(L, ra, nresults)) {
++ case PCRLUA: {
++ nexeccalls++;
++ goto reentry; /* restart luaV_execute over new Lua function */
++ }
++ case PCRC: {
++ /* it was a C function (`precall' called it); adjust results */
++ if (nresults >= 0) L->top = L->ci->top;
++ base = L->base;
++ continue;
++ }
++ default: {
++ return; /* yield */
++ }
++ }
++ }
++ case OP_TAILCALL: {
++ int b = GETARG_B(i);
++ if (b != 0) L->top = ra+b; /* else previous instruction set top */
++ L->savedpc = pc;
++ lua_assert(GETARG_C(i) - 1 == LUA_MULTRET);
++ switch (luaD_precall(L, ra, LUA_MULTRET)) {
++ case PCRLUA: {
++ /* tail call: put new frame in place of previous one */
++ CallInfo *ci = L->ci - 1; /* previous frame */
++ int aux;
++ StkId func = ci->func;
++ StkId pfunc = (ci+1)->func; /* previous function index */
++ if (L->openupval) luaF_close(L, ci->base);
++ L->base = ci->base = ci->func + ((ci+1)->base - pfunc);
++ for (aux = 0; pfunc+aux < L->top; aux++) /* move frame down */
++ setobjs2s(L, func+aux, pfunc+aux);
++ ci->top = L->top = func+aux; /* correct top */
++ lua_assert(L->top == L->base + clvalue(func)->l.p->maxstacksize);
++ ci->savedpc = L->savedpc;
++ ci->tailcalls++; /* one more call lost */
++ L->ci--; /* remove new frame */
++ goto reentry;
++ }
++ case PCRC: { /* it was a C function (`precall' called it) */
++ base = L->base;
++ continue;
++ }
++ default: {
++ return; /* yield */
++ }
++ }
++ }
++ case OP_RETURN: {
++ int b = GETARG_B(i);
++ if (b != 0) L->top = ra+b-1;
++ if (L->openupval) luaF_close(L, base);
++ L->savedpc = pc;
++ b = luaD_poscall(L, ra);
++ if (--nexeccalls == 0) /* was previous function running `here'? */
++ return; /* no: return */
++ else { /* yes: continue its execution */
++ if (b) L->top = L->ci->top;
++ lua_assert(isLua(L->ci));
++ lua_assert(GET_OPCODE(*((L->ci)->savedpc - 1)) == OP_CALL);
++ goto reentry;
++ }
++ }
++ case OP_FORLOOP: {
++ lua_Number step = nvalue(ra+2);
++ lua_Number idx = luai_numadd(nvalue(ra), step); /* increment index */
++ lua_Number limit = nvalue(ra+1);
++ if (luai_numlt(0, step) ? luai_numle(idx, limit)
++ : luai_numle(limit, idx)) {
++ dojump(L, pc, GETARG_sBx(i)); /* jump back */
++ setnvalue(ra, idx); /* update internal index... */
++ setnvalue(ra+3, idx); /* ...and external index */
++ }
++ continue;
++ }
++ case OP_FORPREP: {
++ const TValue *init = ra;
++ const TValue *plimit = ra+1;
++ const TValue *pstep = ra+2;
++ L->savedpc = pc; /* next steps may throw errors */
++ if (!tonumber(init, ra))
++ luaG_runerror(L, LUA_QL("for") " initial value must be a number");
++ else if (!tonumber(plimit, ra+1))
++ luaG_runerror(L, LUA_QL("for") " limit must be a number");
++ else if (!tonumber(pstep, ra+2))
++ luaG_runerror(L, LUA_QL("for") " step must be a number");
++ setnvalue(ra, luai_numsub(nvalue(ra), nvalue(pstep)));
++ dojump(L, pc, GETARG_sBx(i));
++ continue;
++ }
++ case OP_TFORLOOP: {
++ StkId cb = ra + 3; /* call base */
++ setobjs2s(L, cb+2, ra+2);
++ setobjs2s(L, cb+1, ra+1);
++ setobjs2s(L, cb, ra);
++ L->top = cb+3; /* func. + 2 args (state and index) */
++ Protect(luaD_call(L, cb, GETARG_C(i)));
++ L->top = L->ci->top;
++ cb = RA(i) + 3; /* previous call may change the stack */
++ if (!ttisnil(cb)) { /* continue loop? */
++ setobjs2s(L, cb-1, cb); /* save control variable */
++ dojump(L, pc, GETARG_sBx(*pc)); /* jump back */
++ }
++ pc++;
++ continue;
++ }
++ case OP_SETLIST: {
++ int n = GETARG_B(i);
++ int c = GETARG_C(i);
++ int last;
++ Table *h;
++ if (n == 0) {
++ n = cast_int(L->top - ra) - 1;
++ L->top = L->ci->top;
++ }
++ if (c == 0) c = cast_int(*pc++);
++ runtime_check(L, ttistable(ra));
++ h = hvalue(ra);
++ last = ((c-1)*LFIELDS_PER_FLUSH) + n;
++ if (last > h->sizearray) /* needs more space? */
++ luaH_resizearray(L, h, last); /* pre-alloc it at once */
++ for (; n > 0; n--) {
++ TValue *val = ra+n;
++ setobj2t(L, luaH_setnum(L, h, last--), val);
++ luaC_barriert(L, h, val);
++ }
++ continue;
++ }
++ case OP_CLOSE: {
++ luaF_close(L, ra);
++ continue;
++ }
++ case OP_CLOSURE: {
++ Proto *p;
++ Closure *ncl;
++ int nup, j;
++ p = cl->p->p[GETARG_Bx(i)];
++ nup = p->nups;
++ ncl = luaF_newLclosure(L, nup, cl->env);
++ ncl->l.p = p;
++ for (j=0; j<nup; j++, pc++) {
++ if (GET_OPCODE(*pc) == OP_GETUPVAL)
++ ncl->l.upvals[j] = cl->upvals[GETARG_B(*pc)];
++ else {
++ lua_assert(GET_OPCODE(*pc) == OP_MOVE);
++ ncl->l.upvals[j] = luaF_findupval(L, base + GETARG_B(*pc));
++ }
++ }
++ setclvalue(L, ra, ncl);
++ Protect(luaC_checkGC(L));
++ continue;
++ }
++ case OP_VARARG: {
++ int b = GETARG_B(i) - 1;
++ int j;
++ CallInfo *ci = L->ci;
++ int n = cast_int(ci->base - ci->func) - cl->p->numparams - 1;
++ if (b == LUA_MULTRET) {
++ Protect(luaD_checkstack(L, n));
++ ra = RA(i); /* previous call may change the stack */
++ b = n;
++ L->top = ra + n;
++ }
++ for (j = 0; j < b; j++) {
++ if (j < n) {
++ setobjs2s(L, ra + j, ci->base - n + j);
++ }
++ else {
++ setnilvalue(ra + j);
++ }
++ }
++ continue;
++ }
++ }
++ }
++}
++
+--- /dev/null
++++ b/extensions/LUA/lua/lvm.h
+@@ -0,0 +1,36 @@
++/*
++** $Id: lvm.h,v 2.5.1.1 2007/12/27 13:02:25 roberto Exp $
++** Lua virtual machine
++** See Copyright Notice in lua.h
++*/
++
++#ifndef lvm_h
++#define lvm_h
++
++
++#include "ldo.h"
++#include "lobject.h"
++#include "ltm.h"
++
++
++#define tostring(L,o) ((ttype(o) == LUA_TSTRING) || (luaV_tostring(L, o)))
++
++#define tonumber(o,n) (ttype(o) == LUA_TNUMBER || \
++ (((o) = luaV_tonumber(o,n)) != NULL))
++
++#define equalobj(L,o1,o2) \
++ (ttype(o1) == ttype(o2) && luaV_equalval(L, o1, o2))
++
++
++LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r);
++LUAI_FUNC int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2);
++LUAI_FUNC const TValue *luaV_tonumber (const TValue *obj, TValue *n);
++LUAI_FUNC int luaV_tostring (lua_State *L, StkId obj);
++LUAI_FUNC void luaV_gettable (lua_State *L, const TValue *t, TValue *key,
++ StkId val);
++LUAI_FUNC void luaV_settable (lua_State *L, const TValue *t, TValue *key,
++ StkId val);
++LUAI_FUNC void luaV_execute (lua_State *L, int nexeccalls);
++LUAI_FUNC void luaV_concat (lua_State *L, int total, int last);
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/lzio.c
+@@ -0,0 +1,81 @@
++/*
++** $Id: lzio.c,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $
++** a generic input stream interface
++** See Copyright Notice in lua.h
++*/
++
++#include <string.h>
++
++#define lzio_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "llimits.h"
++#include "lmem.h"
++#include "lstate.h"
++#include "lzio.h"
++
++
++int luaZ_fill (ZIO *z) {
++ size_t size;
++ lua_State *L = z->L;
++ const char *buff;
++ lua_unlock(L);
++ buff = z->reader(L, z->data, &size);
++ lua_lock(L);
++ if (buff == NULL || size == 0) return EOZ;
++ z->n = size - 1;
++ z->p = buff;
++ return char2int(*(z->p++));
++}
++
++
++int luaZ_lookahead (ZIO *z) {
++ if (z->n == 0) {
++ if (luaZ_fill(z) == EOZ)
++ return EOZ;
++ else {
++ z->n++; /* luaZ_fill removed first byte; put back it */
++ z->p--;
++ }
++ }
++ return char2int(*z->p);
++}
++
++
++void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) {
++ z->L = L;
++ z->reader = reader;
++ z->data = data;
++ z->n = 0;
++ z->p = NULL;
++}
++
++
++/* --------------------------------------------------------------- read --- */
++size_t luaZ_read (ZIO *z, void *b, size_t n) {
++ while (n) {
++ size_t m;
++ if (luaZ_lookahead(z) == EOZ)
++ return n; /* return number of missing bytes */
++ m = (n <= z->n) ? n : z->n; /* min. between n and z->n */
++ memcpy(b, z->p, m);
++ z->n -= m;
++ z->p += m;
++ b = (char *)b + m;
++ n -= m;
++ }
++ return 0;
++}
++
++/* ------------------------------------------------------------------------ */
++char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n) {
++ if (n > buff->buffsize) {
++ if (n < LUA_MINBUFFER) n = LUA_MINBUFFER;
++ luaZ_resizebuffer(L, buff, n);
++ }
++ return buff->buffer;
++}
++
++
+--- /dev/null
++++ b/extensions/LUA/lua/lzio.h
+@@ -0,0 +1,67 @@
++/*
++** $Id: lzio.h,v 1.21.1.1 2007/12/27 13:02:25 roberto Exp $
++** Buffered streams
++** See Copyright Notice in lua.h
++*/
++
++
++#ifndef lzio_h
++#define lzio_h
++
++#include "lua.h"
++
++#include "lmem.h"
++
++
++#define EOZ (-1) /* end of stream */
++
++typedef struct Zio ZIO;
++
++#define char2int(c) cast(int, cast(unsigned char, (c)))
++
++#define zgetc(z) (((z)->n--)>0 ? char2int(*(z)->p++) : luaZ_fill(z))
++
++typedef struct Mbuffer {
++ char *buffer;
++ size_t n;
++ size_t buffsize;
++} Mbuffer;
++
++#define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0)
++
++#define luaZ_buffer(buff) ((buff)->buffer)
++#define luaZ_sizebuffer(buff) ((buff)->buffsize)
++#define luaZ_bufflen(buff) ((buff)->n)
++
++#define luaZ_resetbuffer(buff) ((buff)->n = 0)
++
++
++#define luaZ_resizebuffer(L, buff, size) \
++ (luaM_reallocvector(L, (buff)->buffer, (buff)->buffsize, size, char), \
++ (buff)->buffsize = size)
++
++#define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0)
++
++
++LUAI_FUNC char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n);
++LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader,
++ void *data);
++LUAI_FUNC size_t luaZ_read (ZIO* z, void* b, size_t n); /* read next n bytes */
++LUAI_FUNC int luaZ_lookahead (ZIO *z);
++
++
++
++/* --------- Private Part ------------------ */
++
++struct Zio {
++ size_t n; /* bytes still unread */
++ const char *p; /* current position in buffer */
++ lua_Reader reader;
++ void* data; /* additional data */
++ lua_State *L; /* Lua state (for reader) */
++};
++
++
++LUAI_FUNC int luaZ_fill (ZIO *z);
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/Makefile
+@@ -0,0 +1,389 @@
++# Makefile.in generated by automake 1.11.1 from Makefile.am.
++# extensions/LUA/Makefile. Generated from Makefile.in by configure.
++
++# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
++# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
++# Inc.
++# This Makefile.in is free software; the Free Software Foundation
++# gives unlimited permission to copy and/or distribute it,
++# with or without modifications, as long as this notice is preserved.
++
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
++# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
++# PARTICULAR PURPOSE.
++
++
++
++# -*- Makefile -*-
++# AUTOMAKE
++
++pkgdatadir = $(datadir)/xtables-addons
++pkgincludedir = $(includedir)/xtables-addons
++pkglibdir = $(libdir)/xtables-addons
++pkglibexecdir = $(libexecdir)/xtables-addons
++am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
++install_sh_DATA = $(install_sh) -c -m 644
++install_sh_PROGRAM = $(install_sh) -c
++install_sh_SCRIPT = $(install_sh) -c
++INSTALL_HEADER = $(INSTALL_DATA)
++transform = $(program_transform_name)
++NORMAL_INSTALL = :
++PRE_INSTALL = :
++POST_INSTALL = :
++NORMAL_UNINSTALL = :
++PRE_UNINSTALL = :
++POST_UNINSTALL = :
++build_triplet = i686-pc-linux-gnu
++host_triplet = i686-pc-linux-gnu
++DIST_COMMON = $(srcdir)/../../Makefile.extra $(srcdir)/Makefile.am \
++ $(srcdir)/Makefile.in
++subdir = extensions/LUA
++ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
++am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
++ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
++ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
++ $(top_srcdir)/configure.ac
++am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
++ $(ACLOCAL_M4)
++mkinstalldirs = $(install_sh) -d
++CONFIG_HEADER = $(top_builddir)/config.h
++CONFIG_CLEAN_FILES =
++CONFIG_CLEAN_VPATH_FILES =
++SOURCES =
++DIST_SOURCES =
++DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
++ACLOCAL = ${SHELL} /home/andre/Dropbox/xtables-addons/missing --run aclocal-1.11
++AMTAR = ${SHELL} /home/andre/Dropbox/xtables-addons/missing --run tar
++AR = ar
++AUTOCONF = ${SHELL} /home/andre/Dropbox/xtables-addons/missing --run autoconf
++AUTOHEADER = ${SHELL} /home/andre/Dropbox/xtables-addons/missing --run autoheader
++AUTOMAKE = ${SHELL} /home/andre/Dropbox/xtables-addons/missing --run automake-1.11
++AWK = mawk
++CC = gcc
++CCDEPMODE = depmode=gcc3
++CFLAGS = -g -O2
++CPP = gcc -E
++CPPFLAGS =
++CYGPATH_W = echo
++DEFS = -DHAVE_CONFIG_H
++DEPDIR = .deps
++DSYMUTIL =
++DUMPBIN =
++ECHO_C =
++ECHO_N = -n
++ECHO_T =
++EGREP = /bin/grep -E
++EXEEXT =
++FGREP = /bin/grep -F
++GREP = /bin/grep
++INSTALL = /usr/bin/install -c
++INSTALL_DATA = ${INSTALL} -m 644
++INSTALL_PROGRAM = ${INSTALL}
++INSTALL_SCRIPT = ${INSTALL}
++INSTALL_STRIP_PROGRAM = $(install_sh) -c -s
++LD = /usr/bin/ld
++LDFLAGS =
++LIBOBJS =
++LIBS =
++LIBTOOL = $(SHELL) $(top_builddir)/libtool
++LIPO =
++LN_S = ln -s
++LTLIBOBJS =
++MAKEINFO = ${SHELL} /home/andre/Dropbox/xtables-addons/missing --run makeinfo
++MKDIR_P = /bin/mkdir -p
++NM = /usr/bin/nm -B
++NMEDIT =
++OBJDUMP = objdump
++OBJEXT = o
++OTOOL =
++OTOOL64 =
++PACKAGE = xtables-addons
++PACKAGE_BUGREPORT =
++PACKAGE_NAME = xtables-addons
++PACKAGE_STRING = xtables-addons 1.21
++PACKAGE_TARNAME = xtables-addons
++PACKAGE_URL =
++PACKAGE_VERSION = 1.21
++PATH_SEPARATOR = :
++PKG_CONFIG = /usr/bin/pkg-config
++RANLIB = ranlib
++SED = /bin/sed
++SET_MAKE =
++SHELL = /bin/bash
++STRIP = strip
++VERSION = 1.21
++abs_builddir = /home/andre/Dropbox/xtables-addons/extensions/LUA
++abs_srcdir = /home/andre/Dropbox/xtables-addons/extensions/LUA
++abs_top_builddir = /home/andre/Dropbox/xtables-addons
++abs_top_srcdir = /home/andre/Dropbox/xtables-addons
++ac_ct_CC = gcc
++ac_ct_DUMPBIN =
++am__include = include
++am__leading_dot = .
++am__quote =
++am__tar = ${AMTAR} chof - "$$tardir"
++am__untar = ${AMTAR} xf -
++bindir = ${exec_prefix}/bin
++build = i686-pc-linux-gnu
++build_alias =
++build_cpu = i686
++build_os = linux-gnu
++build_vendor = pc
++builddir = .
++datadir = ${datarootdir}
++datarootdir = ${prefix}/share
++docdir = ${datarootdir}/doc/${PACKAGE_TARNAME}
++dvidir = ${docdir}
++exec_prefix = ${prefix}
++host = i686-pc-linux-gnu
++host_alias =
++host_cpu = i686
++host_os = linux-gnu
++host_vendor = pc
++htmldir = ${docdir}
++includedir = ${prefix}/include
++infodir = ${datarootdir}/info
++install_sh = ${SHELL} /home/andre/Dropbox/xtables-addons/install-sh
++kbuilddir = /lib/modules/2.6.33-020633-generic/build
++kinclude_CFLAGS = -I /lib/modules/2.6.33-020633-generic/build/include
++ksourcedir =
++libdir = ${exec_prefix}/lib
++libexecdir = ${exec_prefix}/libexec
++libxtables_CFLAGS =
++libxtables_LIBS = -L/lib -lxtables
++localedir = ${datarootdir}/locale
++localstatedir = ${prefix}/var
++lt_ECHO = echo
++mandir = ${datarootdir}/man
++mkdir_p = /bin/mkdir -p
++oldincludedir = /usr/include
++pdfdir = ${docdir}
++prefix = /usr/local
++program_transform_name = s,x,x,
++psdir = ${docdir}
++regular_CFLAGS = -D_LARGEFILE_SOURCE=1 -D_LARGE_FILES -D_FILE_OFFSET_BITS=64 -D_REENTRANT -Wall -Waggregate-return -Wmissing-declarations -Wmissing-prototypes -Wredundant-decls -Wshadow -Wstrict-prototypes -Winline -pipe -DXTABLES_LIBDIR=\"${xtlibdir}\"
++sbindir = ${exec_prefix}/sbin
++sharedstatedir = ${prefix}/com
++srcdir = .
++sysconfdir = ${prefix}/etc
++target_alias =
++top_build_prefix = ../../
++top_builddir = ../..
++top_srcdir = ../..
++xtlibdir = ${libexecdir}/xtables
++XA_SRCDIR = ${srcdir}
++XA_TOPSRCDIR = ${top_srcdir}
++XA_ABSTOPSRCDIR = ${abs_top_srcdir}
++_mcall = -f ${top_builddir}/Makefile.iptrules
++all: all-am
++
++.SUFFIXES:
++$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(srcdir)/../../Makefile.extra $(am__configure_deps)
++ @for dep in $?; do \
++ case '$(am__configure_deps)' in \
++ *$$dep*) \
++ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
++ && { if test -f $@; then exit 0; else break; fi; }; \
++ exit 1;; \
++ esac; \
++ done; \
++ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign extensions/LUA/Makefile'; \
++ $(am__cd) $(top_srcdir) && \
++ $(AUTOMAKE) --foreign extensions/LUA/Makefile
++.PRECIOUS: Makefile
++Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
++ @case '$?' in \
++ *config.status*) \
++ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
++ *) \
++ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
++ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
++ esac;
++
++$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
++ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
++
++$(top_srcdir)/configure: $(am__configure_deps)
++ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
++$(ACLOCAL_M4): $(am__aclocal_m4_deps)
++ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
++$(am__aclocal_m4_deps):
++
++mostlyclean-libtool:
++ -rm -f *.lo
++
++clean-libtool:
++ -rm -rf .libs _libs
++tags: TAGS
++TAGS:
++
++ctags: CTAGS
++CTAGS:
++
++
++distdir: $(DISTFILES)
++ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
++ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
++ list='$(DISTFILES)'; \
++ dist_files=`for file in $$list; do echo $$file; done | \
++ sed -e "s|^$$srcdirstrip/||;t" \
++ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
++ case $$dist_files in \
++ */*) $(MKDIR_P) `echo "$$dist_files" | \
++ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
++ sort -u` ;; \
++ esac; \
++ for file in $$dist_files; do \
++ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
++ if test -d $$d/$$file; then \
++ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
++ if test -d "$(distdir)/$$file"; then \
++ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
++ fi; \
++ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
++ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
++ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
++ fi; \
++ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
++ else \
++ test -f "$(distdir)/$$file" \
++ || cp -p $$d/$$file "$(distdir)/$$file" \
++ || exit 1; \
++ fi; \
++ done
++check-am: all-am
++check: check-am
++all-am: Makefile all-local
++installdirs:
++install: install-am
++install-exec: install-exec-am
++install-data: install-data-am
++uninstall: uninstall-am
++
++install-am: all-am
++ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
++
++installcheck: installcheck-am
++install-strip:
++ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
++ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
++ `test -z '$(STRIP)' || \
++ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
++mostlyclean-generic:
++
++clean-generic:
++
++distclean-generic:
++ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
++ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
++
++maintainer-clean-generic:
++ @echo "This command is intended for maintainers to use"
++ @echo "it deletes files that may require special tools to rebuild."
++clean: clean-am
++
++clean-am: clean-generic clean-libtool clean-local mostlyclean-am
++
++distclean: distclean-am
++ -rm -f Makefile
++distclean-am: clean-am distclean-generic
++
++dvi: dvi-am
++
++dvi-am:
++
++html: html-am
++
++html-am:
++
++info: info-am
++
++info-am:
++
++install-data-am:
++
++install-dvi: install-dvi-am
++
++install-dvi-am:
++
++install-exec-am: install-exec-local
++
++install-html: install-html-am
++
++install-html-am:
++
++install-info: install-info-am
++
++install-info-am:
++
++install-man:
++
++install-pdf: install-pdf-am
++
++install-pdf-am:
++
++install-ps: install-ps-am
++
++install-ps-am:
++
++installcheck-am:
++
++maintainer-clean: maintainer-clean-am
++ -rm -f Makefile
++maintainer-clean-am: distclean-am maintainer-clean-generic
++
++mostlyclean: mostlyclean-am
++
++mostlyclean-am: mostlyclean-generic mostlyclean-libtool
++
++pdf: pdf-am
++
++pdf-am:
++
++ps: ps-am
++
++ps-am:
++
++uninstall-am:
++
++.MAKE: install-am install-strip
++
++.PHONY: all all-am all-local check check-am clean clean-generic \
++ clean-libtool clean-local distclean distclean-generic \
++ distclean-libtool distdir dvi dvi-am html html-am info info-am \
++ install install-am install-data install-data-am install-dvi \
++ install-dvi-am install-exec install-exec-am install-exec-local \
++ install-html install-html-am install-info install-info-am \
++ install-man install-pdf install-pdf-am install-ps \
++ install-ps-am install-strip installcheck installcheck-am \
++ installdirs maintainer-clean maintainer-clean-generic \
++ mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \
++ ps ps-am uninstall uninstall-am
++
++export XA_SRCDIR
++export XA_TOPSRCDIR
++export XA_ABSTOPSRCDIR
++
++all-local: user-all-local
++
++install-exec-local: user-install-local
++
++clean-local: user-clean-local
++
++user-all-local:
++ ${MAKE} ${_mcall} all;
++
++# Have no user-install-data-local ATM
++user-install-local: user-install-exec-local
++
++user-install-exec-local:
++ ${MAKE} ${_mcall} install;
++
++user-clean-local:
++ ${MAKE} ${_mcall} clean;
++
++# Tell versions [3.59,3.63) of GNU make to not export all variables.
++# Otherwise a system limit (for SysV at least) may be exceeded.
++.NOEXPORT:
++
+--- /dev/null
++++ b/extensions/LUA/Makefile.am
+@@ -0,0 +1 @@
++include ../../Makefile.extra
+--- /dev/null
++++ b/extensions/LUA/Makefile.in
+@@ -0,0 +1,389 @@
++# Makefile.in generated by automake 1.11.1 from Makefile.am.
++# @configure_input@
++
++# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
++# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
++# Inc.
++# This Makefile.in is free software; the Free Software Foundation
++# gives unlimited permission to copy and/or distribute it,
++# with or without modifications, as long as this notice is preserved.
++
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
++# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
++# PARTICULAR PURPOSE.
++
++@SET_MAKE@
++
++# -*- Makefile -*-
++# AUTOMAKE
++VPATH = @srcdir@
++pkgdatadir = $(datadir)/@PACKAGE@
++pkgincludedir = $(includedir)/@PACKAGE@
++pkglibdir = $(libdir)/@PACKAGE@
++pkglibexecdir = $(libexecdir)/@PACKAGE@
++am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
++install_sh_DATA = $(install_sh) -c -m 644
++install_sh_PROGRAM = $(install_sh) -c
++install_sh_SCRIPT = $(install_sh) -c
++INSTALL_HEADER = $(INSTALL_DATA)
++transform = $(program_transform_name)
++NORMAL_INSTALL = :
++PRE_INSTALL = :
++POST_INSTALL = :
++NORMAL_UNINSTALL = :
++PRE_UNINSTALL = :
++POST_UNINSTALL = :
++build_triplet = @build@
++host_triplet = @host@
++DIST_COMMON = $(srcdir)/../../Makefile.extra $(srcdir)/Makefile.am \
++ $(srcdir)/Makefile.in
++subdir = extensions/LUA
++ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
++am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
++ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
++ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
++ $(top_srcdir)/configure.ac
++am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
++ $(ACLOCAL_M4)
++mkinstalldirs = $(install_sh) -d
++CONFIG_HEADER = $(top_builddir)/config.h
++CONFIG_CLEAN_FILES =
++CONFIG_CLEAN_VPATH_FILES =
++SOURCES =
++DIST_SOURCES =
++DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
++ACLOCAL = @ACLOCAL@
++AMTAR = @AMTAR@
++AR = @AR@
++AUTOCONF = @AUTOCONF@
++AUTOHEADER = @AUTOHEADER@
++AUTOMAKE = @AUTOMAKE@
++AWK = @AWK@
++CC = @CC@
++CCDEPMODE = @CCDEPMODE@
++CFLAGS = @CFLAGS@
++CPP = @CPP@
++CPPFLAGS = @CPPFLAGS@
++CYGPATH_W = @CYGPATH_W@
++DEFS = @DEFS@
++DEPDIR = @DEPDIR@
++DSYMUTIL = @DSYMUTIL@
++DUMPBIN = @DUMPBIN@
++ECHO_C = @ECHO_C@
++ECHO_N = @ECHO_N@
++ECHO_T = @ECHO_T@
++EGREP = @EGREP@
++EXEEXT = @EXEEXT@
++FGREP = @FGREP@
++GREP = @GREP@
++INSTALL = @INSTALL@
++INSTALL_DATA = @INSTALL_DATA@
++INSTALL_PROGRAM = @INSTALL_PROGRAM@
++INSTALL_SCRIPT = @INSTALL_SCRIPT@
++INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
++LD = @LD@
++LDFLAGS = @LDFLAGS@
++LIBOBJS = @LIBOBJS@
++LIBS = @LIBS@
++LIBTOOL = @LIBTOOL@
++LIPO = @LIPO@
++LN_S = @LN_S@
++LTLIBOBJS = @LTLIBOBJS@
++MAKEINFO = @MAKEINFO@
++MKDIR_P = @MKDIR_P@
++NM = @NM@
++NMEDIT = @NMEDIT@
++OBJDUMP = @OBJDUMP@
++OBJEXT = @OBJEXT@
++OTOOL = @OTOOL@
++OTOOL64 = @OTOOL64@
++PACKAGE = @PACKAGE@
++PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
++PACKAGE_NAME = @PACKAGE_NAME@
++PACKAGE_STRING = @PACKAGE_STRING@
++PACKAGE_TARNAME = @PACKAGE_TARNAME@
++PACKAGE_URL = @PACKAGE_URL@
++PACKAGE_VERSION = @PACKAGE_VERSION@
++PATH_SEPARATOR = @PATH_SEPARATOR@
++PKG_CONFIG = @PKG_CONFIG@
++RANLIB = @RANLIB@
++SED = @SED@
++SET_MAKE = @SET_MAKE@
++SHELL = @SHELL@
++STRIP = @STRIP@
++VERSION = @VERSION@
++abs_builddir = @abs_builddir@
++abs_srcdir = @abs_srcdir@
++abs_top_builddir = @abs_top_builddir@
++abs_top_srcdir = @abs_top_srcdir@
++ac_ct_CC = @ac_ct_CC@
++ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
++am__include = @am__include@
++am__leading_dot = @am__leading_dot@
++am__quote = @am__quote@
++am__tar = @am__tar@
++am__untar = @am__untar@
++bindir = @bindir@
++build = @build@
++build_alias = @build_alias@
++build_cpu = @build_cpu@
++build_os = @build_os@
++build_vendor = @build_vendor@
++builddir = @builddir@
++datadir = @datadir@
++datarootdir = @datarootdir@
++docdir = @docdir@
++dvidir = @dvidir@
++exec_prefix = @exec_prefix@
++host = @host@
++host_alias = @host_alias@
++host_cpu = @host_cpu@
++host_os = @host_os@
++host_vendor = @host_vendor@
++htmldir = @htmldir@
++includedir = @includedir@
++infodir = @infodir@
++install_sh = @install_sh@
++kbuilddir = @kbuilddir@
++kinclude_CFLAGS = @kinclude_CFLAGS@
++ksourcedir = @ksourcedir@
++libdir = @libdir@
++libexecdir = @libexecdir@
++libxtables_CFLAGS = @libxtables_CFLAGS@
++libxtables_LIBS = @libxtables_LIBS@
++localedir = @localedir@
++localstatedir = @localstatedir@
++lt_ECHO = @lt_ECHO@
++mandir = @mandir@
++mkdir_p = @mkdir_p@
++oldincludedir = @oldincludedir@
++pdfdir = @pdfdir@
++prefix = @prefix@
++program_transform_name = @program_transform_name@
++psdir = @psdir@
++regular_CFLAGS = @regular_CFLAGS@
++sbindir = @sbindir@
++sharedstatedir = @sharedstatedir@
++srcdir = @srcdir@
++sysconfdir = @sysconfdir@
++target_alias = @target_alias@
++top_build_prefix = @top_build_prefix@
++top_builddir = @top_builddir@
++top_srcdir = @top_srcdir@
++xtlibdir = @xtlibdir@
++XA_SRCDIR = ${srcdir}
++XA_TOPSRCDIR = ${top_srcdir}
++XA_ABSTOPSRCDIR = ${abs_top_srcdir}
++_mcall = -f ${top_builddir}/Makefile.iptrules
++all: all-am
++
++.SUFFIXES:
++$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(srcdir)/../../Makefile.extra $(am__configure_deps)
++ @for dep in $?; do \
++ case '$(am__configure_deps)' in \
++ *$$dep*) \
++ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
++ && { if test -f $@; then exit 0; else break; fi; }; \
++ exit 1;; \
++ esac; \
++ done; \
++ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign extensions/LUA/Makefile'; \
++ $(am__cd) $(top_srcdir) && \
++ $(AUTOMAKE) --foreign extensions/LUA/Makefile
++.PRECIOUS: Makefile
++Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
++ @case '$?' in \
++ *config.status*) \
++ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
++ *) \
++ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
++ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
++ esac;
++
++$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
++ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
++
++$(top_srcdir)/configure: $(am__configure_deps)
++ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
++$(ACLOCAL_M4): $(am__aclocal_m4_deps)
++ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
++$(am__aclocal_m4_deps):
++
++mostlyclean-libtool:
++ -rm -f *.lo
++
++clean-libtool:
++ -rm -rf .libs _libs
++tags: TAGS
++TAGS:
++
++ctags: CTAGS
++CTAGS:
++
++
++distdir: $(DISTFILES)
++ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
++ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
++ list='$(DISTFILES)'; \
++ dist_files=`for file in $$list; do echo $$file; done | \
++ sed -e "s|^$$srcdirstrip/||;t" \
++ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
++ case $$dist_files in \
++ */*) $(MKDIR_P) `echo "$$dist_files" | \
++ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
++ sort -u` ;; \
++ esac; \
++ for file in $$dist_files; do \
++ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
++ if test -d $$d/$$file; then \
++ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
++ if test -d "$(distdir)/$$file"; then \
++ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
++ fi; \
++ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
++ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
++ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
++ fi; \
++ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
++ else \
++ test -f "$(distdir)/$$file" \
++ || cp -p $$d/$$file "$(distdir)/$$file" \
++ || exit 1; \
++ fi; \
++ done
++check-am: all-am
++check: check-am
++all-am: Makefile all-local
++installdirs:
++install: install-am
++install-exec: install-exec-am
++install-data: install-data-am
++uninstall: uninstall-am
++
++install-am: all-am
++ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
++
++installcheck: installcheck-am
++install-strip:
++ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
++ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
++ `test -z '$(STRIP)' || \
++ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
++mostlyclean-generic:
++
++clean-generic:
++
++distclean-generic:
++ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
++ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
++
++maintainer-clean-generic:
++ @echo "This command is intended for maintainers to use"
++ @echo "it deletes files that may require special tools to rebuild."
++clean: clean-am
++
++clean-am: clean-generic clean-libtool clean-local mostlyclean-am
++
++distclean: distclean-am
++ -rm -f Makefile
++distclean-am: clean-am distclean-generic
++
++dvi: dvi-am
++
++dvi-am:
++
++html: html-am
++
++html-am:
++
++info: info-am
++
++info-am:
++
++install-data-am:
++
++install-dvi: install-dvi-am
++
++install-dvi-am:
++
++install-exec-am: install-exec-local
++
++install-html: install-html-am
++
++install-html-am:
++
++install-info: install-info-am
++
++install-info-am:
++
++install-man:
++
++install-pdf: install-pdf-am
++
++install-pdf-am:
++
++install-ps: install-ps-am
++
++install-ps-am:
++
++installcheck-am:
++
++maintainer-clean: maintainer-clean-am
++ -rm -f Makefile
++maintainer-clean-am: distclean-am maintainer-clean-generic
++
++mostlyclean: mostlyclean-am
++
++mostlyclean-am: mostlyclean-generic mostlyclean-libtool
++
++pdf: pdf-am
++
++pdf-am:
++
++ps: ps-am
++
++ps-am:
++
++uninstall-am:
++
++.MAKE: install-am install-strip
++
++.PHONY: all all-am all-local check check-am clean clean-generic \
++ clean-libtool clean-local distclean distclean-generic \
++ distclean-libtool distdir dvi dvi-am html html-am info info-am \
++ install install-am install-data install-data-am install-dvi \
++ install-dvi-am install-exec install-exec-am install-exec-local \
++ install-html install-html-am install-info install-info-am \
++ install-man install-pdf install-pdf-am install-ps \
++ install-ps-am install-strip installcheck installcheck-am \
++ installdirs maintainer-clean maintainer-clean-generic \
++ mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \
++ ps ps-am uninstall uninstall-am
++
++export XA_SRCDIR
++export XA_TOPSRCDIR
++export XA_ABSTOPSRCDIR
++
++all-local: user-all-local
++
++install-exec-local: user-install-local
++
++clean-local: user-clean-local
++
++user-all-local:
++ ${MAKE} ${_mcall} all;
++
++# Have no user-install-data-local ATM
++user-install-local: user-install-exec-local
++
++user-install-exec-local:
++ ${MAKE} ${_mcall} install;
++
++user-clean-local:
++ ${MAKE} ${_mcall} clean;
++
++# Tell versions [3.59,3.63) of GNU make to not export all variables.
++# Otherwise a system limit (for SysV at least) may be exceeded.
++.NOEXPORT:
++
+--- /dev/null
++++ b/extensions/LUA/Mbuild
+@@ -0,0 +1,3 @@
++# -*- Makefile -*-
++
++obj-${build_LUA} += libxt_LUA.so
+--- /dev/null
++++ b/extensions/LUA/nf_lua.c
+@@ -0,0 +1,64 @@
++#if defined(__KERNEL__)
++
++#include <linux/kernel.h>
++#include <linux/slab.h>
++#include <linux/string.h>
++#include <linux/timer.h>
++#include <linux/random.h>
++#include <linux/netfilter/x_tables.h>
++
++#endif
++
++#include "lua.h"
++#include "lobject.h" /*sizeof(udata) */
++#include "lauxlib.h"
++#include "controller.h"
++
++#if defined(__KERNEL__) /* reachs until luaopen_nflib */
++
++
++static int32_t nf_get_random(lua_State *L)
++{
++ uint32_t rand = 0;
++
++ get_random_bytes(&rand, sizeof(uint32_t ));
++ lua_pushnumber(L, rand);
++ return 1;
++}
++
++static int32_t nf_get_time(lua_State *L)
++{
++ lua_pushnumber(L, jiffies_to_msecs(jiffies_64));
++ return 1;
++}
++
++static const struct luaL_Reg nf_lua_lib_f [] = {
++ { "get_random", nf_get_random },
++ { "get_time", nf_get_time },
++ { NULL, NULL }
++};
++
++void luaopen_nflib(lua_State *L)
++{
++ int32_t top;
++
++ luaL_register(L, NETFILTER_LIB, nf_lua_lib_f);
++ lua_pop(L, 1);
++
++ /* registering verdicts inside the _G */
++ lua_getglobal(L, "_G");
++ top = lua_gettop(L);
++
++ lua_pushinteger(L, XT_CONTINUE);
++ lua_setfield(L, top, "XT_CONTINUE"); /* continiue with next rule */
++
++ lua_pushinteger(L, NF_DROP);
++ lua_setfield(L, top, "NF_DROP"); /* stop traversal in the current table hook and drop packet */
++
++ lua_pushinteger(L, NF_ACCEPT);
++ lua_setfield(L, top, "NF_ACCEPT"); /* stop traversal in the current table hook and accept packet */
++
++ lua_pop(L, 1); /* pop _G */
++}
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/prot_buf_dynamic.c
+@@ -0,0 +1,486 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre@dergraf.org>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++
++#include "controller.h"
++
++
++
++struct protocol_buf * dyn_prot_buf_array[MAX_NR_OF_DYN_PROT_BUFS] = { NULL };
++
++
++/* LUA_API: the function 'field_dynamic_setter' acts as a wrapper around
++ * a given Lua field setter function of a dynamic protocol buffer. The
++ * string containing the lua function name was piggybacked in the 'set'
++ * member of the protocol_field. We call this function passing the actual
++ * segment as byte array and the set value.
++ *
++ * Paramters:
++ * 1. lua_packet_segment (implicit)
++ * 2. some lua value
++ *
++ * Upvalues:
++ * 1. pointer to the protocol buffer
++ * 2. field index
++ *
++ * Returns:
++ * 1. true or false if the 'set' was successful
++ */
++int32_t field_dynamic_setter(lua_State *L)
++{
++ size_t nbytes;
++ lua_packet_segment * array;
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ int32_t field_index = lua_tointeger(L, lua_upvalueindex(2));
++
++ /* the function name is piggybacked as a string */
++ lua_getglobal(L, (char *)prot_buf->protocol_fields[field_index].set);
++ if (!lua_isfunction(L, -1)) {
++ lua_pushboolean(L, 0);
++ return 1;
++ }
++
++ nbytes = sizeof(lua_packet_segment) + seg->length * sizeof(uint8_t);
++ array = (lua_packet_segment *)lua_newuserdata(L, nbytes);
++ array->length = seg->length;
++ array->start = seg->start + seg->offset;
++ array->changes = NULL;
++
++ luaL_getmetatable(L, LUA_BYTE_ARRAY);
++ lua_setmetatable(L, -2);
++ lua_pushvalue(L, 2); /* push value to set */
++ if (lua_pcall(L, 2, 1, 0) != 0) {
++ pr_debug("Error: %s \n", lua_tostring(L, -1));
++ lua_pop(L, 1);
++ lua_pushboolean(L, 0);
++ }
++ return 1;
++}
++
++/* LUA_API: the function 'field_dynamic_getter' acts as a wrapper around
++ * a given Lua field getter function of a dynamic protocol buffer. The
++ * string containing the lua function name was piggybacked in the 'get'
++ * member of the protocol_field. We call this function passing the actual
++ * segment as byte array.
++ *
++ * Paramters:
++ * 1. lua_packet_segment (implicit)
++ *
++ * Upvalues:
++ * 1. pointer to the protocol buffer
++ * 2. field index
++ *
++ * Returns:
++ * 1. true or false if the 'get' was successful
++ */
++int32_t field_dynamic_getter(lua_State *L)
++{
++ size_t nbytes;
++ lua_packet_segment * array;
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ int32_t field_index = lua_tointeger(L, lua_upvalueindex(2));
++
++ /* the function name is piggybacked as a string */
++ lua_getglobal(L, (char *)prot_buf->protocol_fields[field_index].get);
++ if (!lua_isfunction(L, -1)) {
++ lua_pushboolean(L, 0);
++ return 1;
++ }
++
++ nbytes = sizeof(lua_packet_segment) + seg->length * sizeof(uint8_t);
++ array = (lua_packet_segment *)lua_newuserdata(L, nbytes);
++ array->length = seg->length;
++ array->start = seg->start + seg->offset;
++ array->changes = NULL;
++
++ luaL_getmetatable(L, LUA_BYTE_ARRAY);
++ lua_setmetatable(L, -2);
++ if (lua_pcall(L, 1, 1, 0) != 0) {
++ pr_debug("Error: %s \n", luaL_checkstring(L, -1));
++ lua_pop(L, 1);
++ lua_pushboolean(L, 0);
++ }
++ return 1;
++}
++
++/* LUA_API: the function 'has_protocol_dynamic' acts as a wrapper around
++ * a given lua has_protocol function of a dynamic protocol buffer. The
++ * string containing the lua function name was piggybacked in the 'has_protocol'
++ * member of the protocol_buffer. We call this function passing the actual
++ * segment.
++ *
++ * Paramters:
++ * 1. lua_packet_segment
++ * 2. protocol type
++ *
++ * Returns:
++ * 1. true or false if the payload field contains the given protocol
++ */
++int32_t has_protocol_dynamic(lua_State *L, struct protocol_buf * prot_buf, lua_packet_segment * seg, int32_t type)
++{
++ lua_packet_segment *seg_new;
++ int32_t res = 0;
++
++ /* the function name is piggybacked as a string */
++ lua_getglobal(L, (char *)prot_buf->has_protocol);
++ seg_new = (lua_packet_segment *)lua_newuserdata(L, sizeof(lua_packet_segment));
++ seg_new->start = seg->start;
++ seg_new->offset = seg->offset;
++ seg_new->length = seg->length;
++ seg_new->changes = NULL;
++ luaL_getmetatable(L, prot_buf->name);
++ lua_setmetatable(L, -2);
++ lua_pushinteger(L, type); /* push the protocol type */
++ if (lua_pcall(L, 2, 1, 0) != 0) {
++ pr_debug("Error: %s \n", luaL_checkstring(L, -1));
++ lua_pop(L, 1);
++ return 0;
++ }
++ res = lua_toboolean(L, -1);
++ lua_pop(L, 1);
++
++ return res;
++}
++
++/* LUA_API: the function 'get_field_changes_dynamic' acts as a wrapper around
++ * a given lua get_field_changes function of a dynamic protocol buffer. The
++ * string containing the lua function name was piggybacked in the 'get_field_changes'
++ * member of the protocol_buffer. We call this function passing the actual
++ * segment. The lua function must return two lua table containing the offset
++ * and length changes (in bits).
++ *
++ * Paramters:
++ * 1. lua_packet_segment
++ *
++ * Returns:
++ * 1. new allocated field_changes struct
++ */
++struct field_changes * get_field_changes_dynamic(lua_State *L, struct protocol_buf *prot_buf, lua_packet_segment * seg)
++{
++ lua_packet_segment *seg_new;
++ struct field_changes * changes;
++ int32_t nr_of_changes, i;
++
++ lua_getglobal(L, (char *)prot_buf->get_field_changes);
++
++ seg_new = (lua_packet_segment *)lua_newuserdata(L, sizeof(lua_packet_segment));
++ seg_new->start = seg->start;
++ seg_new->offset = seg->offset;
++ seg_new->length = seg->length;
++ seg_new->changes = NULL;
++ luaL_getmetatable(L, prot_buf->name);
++ lua_setmetatable(L, -2);
++
++ if (lua_pcall(L, 1, 2, 0) != 0)
++ luaL_error(L, "inside get_field_changes_dynamic. %s\n", lua_tostring(L, -1));
++
++ /* the function call must return a table containing length changes */
++ luaL_checktype(L, -1, LUA_TTABLE);
++ /* the function call must return a table containing offset changes */
++ luaL_checktype(L, -2, LUA_TTABLE);
++ /* both tables have to be of same size */
++ if (lua_objlen(L, -1) != lua_objlen(L, -2))
++ luaL_error(L, "the provided tables are not of equal size");
++
++ nr_of_changes = lua_objlen(L, -1);
++ changes = get_allocated_field_changes(L, nr_of_changes);
++
++ /* loop over the tables */
++ for (i = 1; i < nr_of_changes; i++) {
++ lua_rawgeti(L, -1, i); /* push length value of field at index i */
++ changes->field_length_changes[i - 1] = luaL_checkinteger(L, -1);
++ lua_pop(L, 1); /* pop offset value */
++
++ lua_rawgeti(L, -2, i); /* push offset value of field at index i */
++ changes->field_offset_changes[i - 1] = luaL_checkinteger(L, -1);
++ lua_pop(L, 1); /* pop length value */
++ }
++
++ /* pop both tables */
++ lua_pop(L, 2);
++
++ return changes;
++}
++
++/* C_INT: 'get_free_protocol_index' is only used internally. This function
++ * gets a free slot inside the array holding all the protocol buffers.
++ * There are several ways to get to this information. In this case I take
++ * the way over the reflected array SUPPORTED_PROTOCOL_TABLE inside the
++ * Lua state. Since this function is called at laodtime, we do not have
++ * to care about performance.
++ */
++static int32_t get_free_protocol_index(lua_State *L)
++{
++ int32_t protocol_index;
++
++ lua_getglobal(L, SUPPORTED_PROTOCOL_TABLE);
++ protocol_index = lua_objlen(L, -1) + 1;
++ lua_pop(L, 1);
++ return protocol_index;
++}
++
++/* C_API: 'free_dynamic_prot_buf' frees the allocated memory of a given
++ * dynamic protocol buffer. this function is normally called inside a
++ * cleanup routine. Be aware, before running this function you must be
++ * sure that no references to the dynamic protocol buffers were available.
++ * It's recomended to close the Lua state before calling the function. */
++void free_dynamic_prot_buf(struct protocol_buf * prot_buf)
++{
++ struct protocol_field * field = prot_buf->protocol_fields;
++
++ for (; field->name != NULL; field++) {
++ if (field->get) kfree(field->get);
++ if (field->set) kfree(field->set);
++ if (field->name) kfree((char *)field->name);
++ }
++
++ if (prot_buf->payload_field) kfree(prot_buf->payload_field);
++ if (prot_buf->has_protocol) kfree(prot_buf->has_protocol);
++
++ if (prot_buf->get_field_changes) kfree(prot_buf->get_field_changes);
++ kfree((char *)prot_buf->name);
++ kfree(prot_buf);
++ return;
++}
++
++void cleanup_dynamic_prot_bufs(void)
++{
++ int32_t i;
++
++ for (i = 0; i < MAX_NR_OF_DYN_PROT_BUFS; i++) {
++ if (dyn_prot_buf_array[i]) {
++ free_dynamic_prot_buf(dyn_prot_buf_array[i]);
++ dyn_prot_buf_array[i] = NULL;
++ }
++ }
++ return;
++}
++
++
++/* C_INT: 'free_protocol_fields' is used internally as a helper function for
++ * 'register_dynamic_protbuf'. It is used when durin registration an error
++ * occurs and the afore allocated fields needed to be freed. */
++static inline void free_protocol_fields(struct protocol_field * prot_fields, int32_t i)
++{
++ struct protocol_field * f;
++
++ while (i >= 0) {
++ f = &prot_fields[i];
++ if (f->name) kfree((void *)f->name);
++ if (f->get) kfree((void *)f->get);
++ if (f->set) kfree((void *)f->set);
++ kfree((void *)f);
++ i--;
++ }
++}
++
++/* LUA_API: 'register_dynamic_protbuf' is called from within the Lua script.
++ * it takes a Lua table representing the dynamic protocol buffer as parameter.
++ * e.g.:
++ * eth_prot_buf = {
++ * name = "packet_eth_dyn",
++ * payload_field = "data",
++ * protocol_fields = {
++ * {"dmac", 0, 48, nil, nil },
++ * {"smac", 48, 48, nil, nil },
++ * {"type", 96, 16, nil, nil },
++ * {"data", 112, 0, nil, nil },
++ * },
++ * has_protocol = "eth_dyn_has_protocol",
++ * get_field_changes = "eth_dyn_get_field_changes"
++ * }
++ * register_dynamic_protbuf(eth_prot_buf)
++ *
++ * the table gets parsed and a new protocol_buf struct is allocated and
++ * initialized using 'register_protbuf', which is also used for the static
++ * protocol buffers. This enables an identical behavior like the static
++ * protocol buffers. The dynamic protocol buffers are not garbage collected,
++ * use 'free_dynamic_protbuf' to free them after closing the Lua state.
++ */
++static int32_t register_dynamic_protbuf(lua_State *L)
++{
++ struct protocol_buf *prot_buf;
++ struct protocol_field *field, sentinel = PROT_FIELD_SENTINEL;
++ int32_t nr_of_fields, i;
++
++ prot_buf = (struct protocol_buf *)kmalloc(sizeof(struct protocol_buf), GFP_KERNEL);
++ prot_buf->is_dynamic = 1;
++
++ /* check if parameter is a table */
++ luaL_checktype(L, 1, LUA_TTABLE);
++
++ /* initialize prot_buf.name */
++ lua_getfield(L, 1, "name");
++ prot_buf->name = kmalloc(lua_objlen(L, -1), GFP_KERNEL);
++ strcpy((char *)prot_buf->name, luaL_checkstring(L, -1));
++ lua_pop(L, 1); /* pop res from lua_getfield */
++
++ /* check if protocol buffer is already registered */
++ lua_getglobal(L, prot_buf->name);
++ if (!lua_isnil(L, -1)) {
++ lua_pop(L, 1); /* pop res from lua_getglobal */
++ pr_debug("protocol_buf '%s' already registered.\n", prot_buf->name);
++ goto free_prot_buf;
++ }
++ lua_pop(L, 1); /* pop res from lua_getglobal */
++
++ /* initialize payload field */
++ lua_getfield(L, 1, "payload_field");
++ if (lua_isstring(L, -1)) {
++ prot_buf->payload_field = kmalloc(lua_objlen(L, -1), GFP_KERNEL);
++ strcpy(prot_buf->payload_field, lua_tostring(L, -1));
++ }else
++ prot_buf->payload_field = NULL;
++ lua_pop(L, 1); /* pop res from lua_getfield */
++
++ /* initialize protocol_fields field*/
++ lua_getfield(L, 1, "protocol_fields");
++ if (!lua_istable(L, -1)) {
++ pr_debug("invalid protocol_fields table.\n");
++ goto err2;
++
++ }
++
++ nr_of_fields = lua_objlen(L, -1);
++ prot_buf->protocol_fields = (struct protocol_field *)kmalloc((nr_of_fields + 1) * sizeof(struct protocol_field), GFP_KERNEL);
++
++ for (i = 1; i <= nr_of_fields; i++) {
++ field = &prot_buf->protocol_fields[i - 1];
++ /* initialize protocol field */
++ lua_rawgeti(L, -1, i); /* push field-table */
++ if (!lua_istable(L, -1)) {
++ free_protocol_fields(prot_buf->protocol_fields, i);
++ pr_debug("invalid protocol_field at %i.\n", i);
++ goto err;
++ }
++
++ /* initialize protocol field name */
++ lua_rawgeti(L, -1, 1);
++ if (!lua_isstring(L, -1)) {
++ free_protocol_fields(prot_buf->protocol_fields, i);
++ pr_debug("invalid protocol_field name at %i.\n", i);
++ goto err;
++ }
++
++ field->name = kmalloc(lua_objlen(L, -1), GFP_KERNEL);
++ strcpy((char*)field->name, lua_tostring(L, -1));
++ lua_pop(L, 1); /* pop field name */
++
++ /* initialize protocol field offset */
++ lua_rawgeti(L, -1, 2);
++ if (!lua_isnumber(L, -1)) {
++ free_protocol_fields(prot_buf->protocol_fields, i);
++ pr_debug("invalid protocol_field offset at %i.\n", i);
++ goto err;
++ }
++ field->offset = lua_tointeger(L, -1);
++ lua_pop(L, 1); /* pop field offset */
++
++ /* initialize protocol field length */
++ lua_rawgeti(L, -1, 3);
++ if (!lua_isnumber(L, -1)) {
++ free_protocol_fields(prot_buf->protocol_fields, i);
++ pr_debug("invalid protocol_field length at %i.\n", i);
++ goto err;
++ }
++ field->length = lua_tointeger(L, -1);
++ lua_pop(L, 1); /* pop field length */
++
++ /* initialize protocol field getter */
++ lua_rawgeti(L, -1, 4);
++ if (lua_isstring(L, -1)) {
++ field->get = kmalloc(lua_objlen(L, -1), GFP_KERNEL);
++ strcpy((char *)field->get, lua_tostring(L, -1)); /* the get-wrapper knows about the piggybacked string */
++ }else
++ field->get = NULL;
++ lua_pop(L, 1); /* pop field getter */
++
++ /* initialize protocol field setter */
++ lua_rawgeti(L, -1, 5);
++ if (lua_isstring(L, -1)) {
++ field->set = kmalloc(lua_objlen(L, -1), GFP_KERNEL);
++ strcpy((char *)field->set, lua_tostring(L, -1)); /* the set-wrapper knows about the piggybacked string */
++ }else
++ field->set = NULL;
++ lua_pop(L, 1); /* pop field setter */
++
++ /* field initialization completed */
++ lua_pop(L, 1); /* pop field-table */
++ }
++
++ /* put sentinel at the end of protocol_fields */
++ memcpy(&prot_buf->protocol_fields[nr_of_fields], &sentinel, sizeof(sentinel));
++ lua_pop(L, 1); /* pop protocol-fields-table */
++
++ /* initialize has_protocol field */
++ lua_getfield(L, 1, "has_protocol");
++ if (lua_isstring(L, -1)) {
++ prot_buf->has_protocol = kmalloc(lua_objlen(L, -1), GFP_KERNEL);
++ strcpy((char *)prot_buf->has_protocol, lua_tostring(L, -1)); /* the has_protocol-wrapper knows about the piggybacked string */
++ }else
++ prot_buf->has_protocol = NULL;
++ lua_pop(L, 1); /* pop has_protocol */
++
++ /* initialize get_field_changes field */
++ lua_getfield(L, 1, "get_field_changes");
++ if (lua_isstring(L, -1)) {
++ prot_buf->get_field_changes = kmalloc(lua_objlen(L, -1), GFP_KERNEL);
++ strcpy((char *)prot_buf->get_field_changes, lua_tostring(L, -1)); /* the get_field_changes-wrapper knows about the piggybacked string */
++ }else
++ prot_buf->get_field_changes = NULL;
++ lua_pop(L, 1); /* pop get_field_changes */
++
++ /* Storing the pointer to the DYNAMIC protbuf within dyn_prot_buf_array, in order to free it at cleanup */
++ for (i = 0; i < MAX_NR_OF_DYN_PROT_BUFS; i++) {
++ if (!dyn_prot_buf_array[i]) {
++ dyn_prot_buf_array[i] = prot_buf;
++ break;
++ }else
++ goto err;
++ }
++
++ /* call the "common" register_protbuf */
++ register_protbuf(L, prot_buf, get_free_protocol_index(L)); /* register prot_buf as it is done with the static ones */
++
++ return 0;
++
++err:
++ kfree(prot_buf->protocol_fields);
++err2:
++ if (prot_buf->payload_field) kfree(prot_buf->payload_field);
++free_prot_buf:
++ kfree((void *)prot_buf->name);
++ kfree(prot_buf);
++
++ luaL_error(L, "one or more error happend while registering a dynamic protocol buffer, please consult the debug log");
++
++ return 0;
++
++}
++
++void luaopen_protbuf_dynamic(lua_State *L)
++{
++ lua_getglobal(L, "_G");
++ lua_pushcclosure(L, register_dynamic_protbuf, 0);
++ lua_setfield(L, -2, "register_dynamic_protbuf");
++ lua_pop(L, 1); /* pop _G */
++ return;
++}
+--- /dev/null
++++ b/extensions/LUA/prot_buf_ethernet.c
+@@ -0,0 +1,60 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre@dergraf.org>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++
++#include "controller.h"
++
++
++static int32_t eth_has_protocol(lua_State *L, struct protocol_buf * prot_buf, lua_packet_segment * seg, int32_t protocol_type)
++{
++ uint8_t *embedded_protocol = seg->start + seg->offset + 12 /*bytes*/;
++ unsigned short res = (unsigned short)((embedded_protocol[1] << CHAR_BIT) | (embedded_protocol[0] << CHAR_BIT));
++
++ switch (res) {
++ case 0x0800: /* 1: Internet Protocol (IP) */
++ if (protocol_type == PACKET_IP) return 1;
++ break;
++ default:
++ return 0;
++ }
++
++ return 0;
++}
++
++static const struct protocol_field eth_protocol_fields[] = {
++ /* field name offset length getter setter */
++ { "dmac", 0, 48, NULL, NULL },
++ { "smac", 48, 48, NULL, NULL },
++ { "type", 96, 16, NULL, NULL },
++ { "data", 112, 0, NULL, NULL },
++ PROT_FIELD_SENTINEL,
++};
++
++static const struct protocol_buf eth_protocol_buf = {
++ .is_dynamic = 0,
++ .name = LUA_PACKET_SEG_ETH,
++ .payload_field = "data",
++ .protocol_fields = (struct protocol_field *)&eth_protocol_fields,
++ .has_protocol = &eth_has_protocol,
++ .get_field_changes = NULL,
++};
++
++
++void luaopen_protbuf_eth(lua_State *L)
++{
++ register_protbuf(L, (struct protocol_buf *)&eth_protocol_buf, PACKET_ETH);
++}
+--- /dev/null
++++ b/extensions/LUA/prot_buf_helpers.c
+@@ -0,0 +1,216 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre@dergraf.org>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++
++#if defined(__KERNEL__)
++#include <linux/netfilter_ipv4.h>
++#include <linux/slab.h> /* kmalloc */
++#endif
++
++#include "controller.h"
++
++int32_t get_header_size(struct protocol_buf * prot_buf)
++{
++ int32_t bit_counter = 0;
++ struct protocol_field * field = prot_buf->protocol_fields;
++
++ for (; field->name; field++)
++ bit_counter += field->length;
++
++ return bit_counter >> 3;
++}
++
++
++int32_t set_32_bit_generic(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ *(uint32_t *)(seg->start + seg->offset) = (uint32_t )htonl(luaL_checkinteger(L, 2));
++ return 0;
++}
++int32_t get_32_bit_generic(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ lua_pushinteger(L, ntohl(*((uint32_t *)(seg->start + seg->offset))));
++ return 1;
++}
++
++int32_t set_16_bit_generic(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ *(uint16_t *)(seg->start + seg->offset) = (uint16_t)htons(luaL_checkinteger(L, 2));
++ return 0;
++}
++int32_t get_16_bit_generic(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ lua_pushinteger(L, ntohs(*((uint16_t *)(seg->start + seg->offset))));
++ return 1;
++}
++
++int32_t set_lower_4_bit_generic(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++ uint8_t b = (uint8_t)luaL_checkinteger(L, 2) << 4;
++ uint8_t * pos = (uint8_t *)(seg->start + seg->offset);
++
++ *pos &= 0x0F; /* reset lower 4 bits*/
++ *pos |= b;
++
++ return 0;
++}
++
++int32_t get_lower_4_bit_generic(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ lua_pushinteger(L, (*(uint8_t *)(seg->start + seg->offset)) >> 4);
++ return 1;
++}
++
++int32_t set_upper_4_bit_generic(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++ uint8_t b = (uint8_t)luaL_checkinteger(L, 2) << 4;
++ uint8_t * pos = (uint8_t *)(seg->start + seg->offset);
++
++ *pos &= 0xF0; /* reset upper 4 bits*/
++ *pos |= (b >> 4);
++
++ return 0;
++}
++
++int32_t get_upper_4_bit_generic(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ lua_pushinteger(L, (*(uint8_t *)(seg->start + seg->offset)) & 0x0F);
++ return 1;
++}
++
++
++int32_t set_8_bit_generic(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ *(uint8_t *)(seg->start + seg->offset) = (uint8_t)luaL_checkinteger(L, 2);
++ return 0;
++}
++
++int32_t get_8_bit_generic(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ lua_pushinteger(L, *(uint8_t *)(seg->start + seg->offset));
++ return 1;
++}
++
++int32_t set_1_bit_generic(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++ unsigned long l = 0;
++
++ memcpy(&l, (seg->start + seg->offset), seg->length);
++ l |= (1 << ((CHAR_BIT * seg->length) - luaL_checkinteger(L, 2)));
++ memcpy((seg->start + seg->offset), &l, seg->length);
++
++ return 0;
++}
++
++int32_t get_1_bit_generic(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++ unsigned long l = 0;
++ uint32_t bit = 0;
++
++ memcpy(&l, (seg->start + seg->offset), seg->length);
++ bit = l & (1 << ((CHAR_BIT * seg->length) - luaL_checkinteger(L, 2)));
++
++ lua_pushboolean(L, bit);
++ return 1;
++}
++
++int32_t get_string_generic(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ /* Warning we cast from uchar to char */
++ lua_pushlstring(L, (char *)seg->start + seg->offset, seg->length);
++ return 1;
++}
++
++int32_t set_data_generic(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++ lua_packet_segment * data = checkbytearray(L, 2);
++
++ pr_debug("seg->length %u, data->length %u\n", seg->length, data->length);
++
++ if (seg->length >= data->length)
++ memcpy((seg->start + seg->offset), data->start, data->length);
++ else
++ luaL_error(L, "provided byte array too big for given packet segment");
++ return 0;
++}
++
++struct field_changes * get_allocated_field_changes(lua_State *L, int32_t nr_of_fields)
++{
++ struct field_changes * changes;
++
++ changes = kmalloc(sizeof(struct field_changes), GFP_ATOMIC);
++
++ if (!changes)
++ goto failure;
++
++ changes->field_length_changes = kmalloc(nr_of_fields * sizeof(int), GFP_ATOMIC);
++ if (!changes->field_length_changes)
++ goto free1;
++
++ changes->field_offset_changes = kmalloc(nr_of_fields * sizeof(int), GFP_ATOMIC);
++ if (!changes->field_offset_changes)
++ goto free2;
++
++ memset(changes->field_length_changes, 0, nr_of_fields * sizeof(int));
++ memset(changes->field_offset_changes, 0, nr_of_fields * sizeof(int));
++
++ changes->ref_count = 1;
++
++ return changes;
++
++free2: kfree(changes->field_length_changes);
++free1: kfree(changes);
++failure:
++ if (!changes) luaL_error(L, "couldnt allocate memory inside 'get_allocated_field_changes'");
++ return NULL; /* only to omit warnings */
++}
+\ No newline at end of file
+--- /dev/null
++++ b/extensions/LUA/prot_buf_icmp.c
+@@ -0,0 +1,49 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre@dergraf.org>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++
++#include "controller.h"
++
++static int32_t icmp_has_protocol(lua_State *L, struct protocol_buf * prot_buf, lua_packet_segment * seg, int32_t protocol_type)
++{
++ return 0;
++}
++
++static const struct protocol_field icmp_protocol_fields[] = {
++ /* field name offset length getter setter */
++ { "type", 0, 8, NULL, NULL },
++ { "code", 8, 8, NULL, NULL },
++ { "checksum", 16, 16, NULL, NULL },
++ { "id", 32, 16, NULL, NULL },
++ { "sequence", 48, 16, NULL, NULL },
++ PROT_FIELD_SENTINEL,
++};
++
++static const struct protocol_buf icmp_protocol_buf = {
++ .is_dynamic = 0,
++ .name = LUA_PACKET_SEG_ICMP,
++ .payload_field = NULL,
++ .protocol_fields = (struct protocol_field *)&icmp_protocol_fields,
++ .has_protocol = &icmp_has_protocol,
++ .get_field_changes = NULL,
++};
++
++void luaopen_protbuf_icmp(lua_State *L)
++{
++ register_protbuf(L, (struct protocol_buf *)&icmp_protocol_buf, PACKET_ICMP);
++}
++
+--- /dev/null
++++ b/extensions/LUA/prot_buf_ip.c
+@@ -0,0 +1,209 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre@dergraf.org>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++
++#if defined(__KERNEL__)
++ #include <net/checksum.h>
++ #include <net/tcp.h>
++#endif
++
++#include "controller.h"
++
++
++#define IP_FMT "%u.%u.%u.%u"
++#define IP_ACC(buf) buf[0], buf[1], buf[2], buf[3]
++
++
++static int32_t ip_version_set(lua_State *L)
++{
++ uint8_t version_checked;
++ lua_packet_segment * seg = checkpacketseg(L, 1, LUA_PACKET_SEG_IP);
++ uint8_t *version_seg = seg->start + seg->offset;
++ int32_t version = luaL_checkinteger(L, 2);
++
++ luaL_argcheck(L, version >= 0 && version <= 15, 1, "version number invalid");
++
++ version_checked = (uint8_t)version;
++
++ version_seg[0] &= (uint8_t)0x0F; /* reset version bits */
++ version_seg[0] |= version_checked << 4;
++
++ return 0;
++}
++static int32_t ip_version_get(lua_State *L)
++{
++ lua_packet_segment * seg = checkpacketseg(L, 1, LUA_PACKET_SEG_IP);
++ uint8_t *version_seg = seg->start + seg->offset;
++ uint8_t v = version_seg[0] & 0xF0;
++
++ v >>= 4;
++
++ lua_pushinteger(L, v);
++ return 1;
++}
++
++static int32_t ip_ihl_set(lua_State *L)
++{
++ uint8_t ihl_checked;
++ lua_packet_segment * seg = checkpacketseg(L, 1, LUA_PACKET_SEG_IP);
++ uint8_t *ihl_seg = seg->start + seg->offset;
++ int32_t ihl = luaL_checkinteger(L, 2);
++
++ luaL_argcheck(L, ihl >= 5 && ihl <= 15, 1, "ip header length invalid"); // RFC 791 5x32 = 160 bits
++
++ ihl_checked = (uint8_t)ihl;
++
++ ihl_seg[0] &= (uint8_t)0xF0; /* reset ihl bits */
++ ihl_seg[0] |= ihl_checked;
++
++ return 0;
++}
++static int32_t ip_ihl_get(lua_State *L)
++{
++ lua_packet_segment * seg = checkpacketseg(L, 1, LUA_PACKET_SEG_IP);
++ uint8_t *ihl_seg = seg->start + seg->offset;
++ uint8_t v = ihl_seg[0] & 0x0F;
++
++ lua_pushinteger(L, v);
++ return 1;
++}
++
++static int32_t ip_addr_set(lua_State *L)
++{
++ int32_t field_id = lua_tointeger(L, lua_upvalueindex(2));
++ lua_packet_segment * seg = checkpacketseg(L, 1, LUA_PACKET_SEG_IP);
++ uint8_t *addr_seg = seg->start + seg->offset;
++ uint32_t old_addr;
++ char *ip = (char *)luaL_checkstring(L, 2);
++ uint32_t a, b, c, d;
++ struct sk_buff * skb = (struct sk_buff *)lua_touserdata(L, 3);
++
++ /* for tcp / udp checksumming*/
++ uint32_t prot_offset;
++ uint8_t *check, *protocol_seg;
++
++ /* end */
++
++ sscanf(ip, IP_FMT, &a, &b, &c, &d);
++
++ luaL_argcheck(L, a < 256 && b < 256 && c < 256 && d < 256, 1, "invalid ip addr");
++
++ old_addr = *((uint32_t *)addr_seg);
++ addr_seg[0] = (uint8_t)a;
++ addr_seg[1] = (uint8_t)b;
++ addr_seg[2] = (uint8_t)c;
++ addr_seg[3] = (uint8_t)d;
++
++#if defined(__KERNEL__)
++ if (old_addr != *(uint32_t *)addr_seg) {
++ int32_t offset = (field_id == 10) ? -2 : -6; /* offset from saddr or daddr */
++
++ csum_replace4((uint16_t *)(addr_seg + offset), old_addr, *(uint32_t *)addr_seg);
++
++ prot_offset = (field_id == 10) ? -3 : -7; /* offset from saddr or daddr */
++ protocol_seg = seg->start + seg->offset + prot_offset;
++
++ if (skb && (protocol_seg[0] == 0x06 || protocol_seg[0] == 0x11)) { /* is payload TCP or UDP ? */
++
++ check = seg->start + seg->offset; /* tmp res */
++ check += (field_id == 10) ? 8 : 16; /* the start of the payload, depending saddr or daddr */
++ check += (protocol_seg[0] == 0x06) ? 16 : 6; /* the start of the checksum, depending on TCP or UDP */
++
++ inet_proto_csum_replace4((__sum16 *)check, skb, old_addr, *(uint32_t *)addr_seg, 1);
++
++ lua_pop(L, 1);
++ }
++ }
++#endif
++ return 0;
++}
++
++
++
++
++
++static int32_t ip_addr_get(lua_State *L)
++{
++ lua_packet_segment * seg = checkpacketseg(L, 1, LUA_PACKET_SEG_IP);
++ uint8_t *addr_seg = seg->start + seg->offset;
++
++ char buf[16]; /*max: 255.255.255.255\0 --> 16 chars */
++
++ sprintf(buf, IP_FMT, IP_ACC(addr_seg));
++ lua_pushstring(L, buf);
++ return 1;
++}
++
++static int32_t ip_has_protocol(lua_State *L, struct protocol_buf * prot_buf, lua_packet_segment * seg, int32_t protocol_type)
++{
++ uint8_t * embedded_protocol = seg->start + seg->offset + 9 /*bytes*/;
++
++ switch (embedded_protocol[0]) {
++ case 0x01: /* 1: Internet Control Message Protocol (ICMP) */
++ if (protocol_type == PACKET_ICMP) return 1;
++ break;
++ case 0x02: /* 2: Internet Group Management Protocol (IGMP) */
++ break;
++ case 0x06: /* 6: Transmission Control Protocol (TCP) */
++ if (protocol_type == PACKET_TCP) return 1;
++ break;
++ case 0x11: /* 17: User Datagram Protocol (UDP) */
++ if (protocol_type == PACKET_UDP) return 1;
++ break;
++ case 0x59: /* 89: Open Shortest Path First (OSPF) */
++ break;
++ case 0x84: /* 132: Stream Control Transmission Protocol (SCTP) */
++ break;
++ default:
++ break;
++ }
++
++ return 0;
++}
++
++static const struct protocol_field ip_protocol_fields[] = {
++ /* field name offset length getter setter */
++ { "version", 0, 4, ip_version_get, ip_version_set },
++ { "ihl", 4, 4, ip_ihl_get, ip_ihl_set },
++ { "tos", 8, 8, get_8_bit_generic, set_8_bit_generic },
++ { "tot_len", 16, 16, get_16_bit_generic, set_16_bit_generic },
++ { "id", 32, 16, get_16_bit_generic, set_16_bit_generic },
++ { "flags", 48, 3, get_1_bit_generic, set_1_bit_generic },
++ { "frag_off", 51, 13, NULL, NULL },
++ { "ttl", 64, 8, get_8_bit_generic, set_8_bit_generic },
++ { "protocol", 72, 8, get_8_bit_generic, set_8_bit_generic },
++ { "check", 80, 16, get_16_bit_generic, set_16_bit_generic },
++ { "saddr", 96, 32, ip_addr_get, ip_addr_set },
++ { "daddr", 128, 32, ip_addr_get, ip_addr_set },
++ { "data", 160, 0, NULL, set_data_generic },
++ PROT_FIELD_SENTINEL,
++};
++
++static const struct protocol_buf ip_protocol_buf = {
++ .is_dynamic = 0,
++ .name = LUA_PACKET_SEG_IP,
++ .payload_field = "data",
++ .protocol_fields = (struct protocol_field *)&ip_protocol_fields,
++ .has_protocol = &ip_has_protocol,
++ .get_field_changes = NULL,
++};
++
++void luaopen_protbuf_ip(lua_State *L)
++{
++ register_protbuf(L, (struct protocol_buf *)&ip_protocol_buf, PACKET_IP);
++}
++
+--- /dev/null
++++ b/extensions/LUA/prot_buf_raw.c
+@@ -0,0 +1,43 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre@dergraf.org>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++
++#include "controller.h"
++static int32_t raw_has_protocol(lua_State *L, struct protocol_buf * prot_buf, lua_packet_segment * seg, int32_t protocol_type)
++{
++ return 1;
++}
++
++static const struct protocol_field raw_protocol_fields[] = {
++ /* field name offset length getter setter */
++ { "data", 0, 0, NULL, NULL },
++ PROT_FIELD_SENTINEL,
++};
++
++static const struct protocol_buf raw_protocol_buf = {
++ .is_dynamic = 0,
++ .name = LUA_PACKET_SEG_RAW,
++ .payload_field = "data",
++ .protocol_fields = (struct protocol_field *)&raw_protocol_fields,
++ .has_protocol = &raw_has_protocol,
++ .get_field_changes = NULL,
++};
++
++void luaopen_protbuf_raw(lua_State *L)
++{
++ register_protbuf(L, (struct protocol_buf *)&raw_protocol_buf, PACKET_RAW);
++}
+--- /dev/null
++++ b/extensions/LUA/prot_buf_tcp.c
+@@ -0,0 +1,188 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre@dergraf.org>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++
++#if defined(__KERNEL__)
++ #include <net/checksum.h>
++ #include <net/tcp.h>
++#endif
++#include "controller.h"
++
++
++static int32_t tcp_has_protocol(lua_State *L, struct protocol_buf * prot_buf, lua_packet_segment * seg, int32_t protocol_type)
++{
++ return 1;
++}
++
++static int32_t tcp_set_checksum(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++#if defined(__KERNEL__)
++ uint8_t * check_seg = seg->start + seg->offset;
++ uint8_t * tcp_hdr = check_seg - 16;
++ uint8_t * saddr = tcp_hdr - 8;
++ uint8_t * daddr = saddr + 4;
++ uint32_t len = 20 + (seg->changes->field_length_changes[11] / 8) + (seg->changes->field_length_changes[10] / 8);
++ unsigned short checksum = tcp_v4_check(len, *(uint32_t *)saddr, *(uint32_t *)daddr,
++ csum_partial(tcp_hdr, len, 0));
++
++ memcpy(check_seg, &checksum, sizeof(unsigned short));
++#endif
++ return 0;
++}
++
++
++static const struct protocol_field tcp_protocol_fields[] = {
++ /* field name offset length getter setter */
++ { "sport", 0, 16, get_16_bit_generic, set_16_bit_generic },
++ { "dport", 16, 16, get_16_bit_generic, set_16_bit_generic },
++ { "seq", 32, 32, get_32_bit_generic, set_32_bit_generic },
++ { "ack", 64, 32, get_32_bit_generic, set_32_bit_generic },
++ { "data_off", 96, 4, get_lower_4_bit_generic, set_lower_4_bit_generic },
++ { "reserved", 100, 4, get_upper_4_bit_generic, set_upper_4_bit_generic },
++ { "flags", 104, 8, get_1_bit_generic, set_1_bit_generic },
++ { "window_size", 112, 16, get_16_bit_generic, set_16_bit_generic },
++ { "check", 128, 16, get_16_bit_generic, tcp_set_checksum },
++ { "urgent", 144, 16, NULL, NULL },
++ { "options", 160, 0, NULL, set_data_generic },
++ { "data", 160, 0, NULL, set_data_generic }, /* begin of data depends on options */
++ PROT_FIELD_SENTINEL,
++};
++
++
++static const struct protocol_field tcp_options_and_data[] = {
++ /* field name offset length getter setter */
++ { "MSS", 0, 16, get_16_bit_generic, set_16_bit_generic },
++ { "WS", 0, 8, get_8_bit_generic, set_8_bit_generic },
++ { "SACK", 0, 16, get_16_bit_generic, set_16_bit_generic },
++ { "TSVAL", 0, 32, get_32_bit_generic, set_32_bit_generic },
++ { "TSER", 0, 32, get_32_bit_generic, set_32_bit_generic },
++ PROT_FIELD_SENTINEL,
++};
++
++
++static struct field_changes * tcp_get_field_changes(lua_State *L, lua_packet_segment * seg);
++
++static const struct protocol_buf tcp_protocol_buf = {
++ .is_dynamic = 0,
++ .name = LUA_PACKET_SEG_TCP,
++ .payload_field = "data",
++ .protocol_fields = (struct protocol_field *)&tcp_protocol_fields,
++ .has_protocol = &tcp_has_protocol,
++ .get_field_changes = &tcp_get_field_changes,
++};
++
++
++static struct field_changes * tcp_options_get_field_changes(lua_State *L, lua_packet_segment * seg);
++
++static const struct protocol_buf tcp_options_and_data_buf = {
++ .is_dynamic = 0,
++ .name = LUA_PACKET_SEG_TCP_OPT,
++ .payload_field = NULL,
++ .protocol_fields = (struct protocol_field *)&tcp_options_and_data,
++ .has_protocol = NULL,
++ .get_field_changes = &tcp_options_get_field_changes,
++};
++
++struct field_changes * tcp_get_field_changes(lua_State *L, lua_packet_segment * seg)
++{
++ /* depending on the value stored inside the 'data_off'-field, the length of
++ * the 'options' field has to be changed, as well as the length and offset
++ * of the 'data' field */
++ uint8_t *tcp_hdr = seg->start + seg->offset;
++
++ /* get the pointer to the 'data_off' field */
++ uint8_t * data_off_field = tcp_hdr + 12; /* 12 bytes offset */
++ /* extract the stored header length in bits */
++ uint32_t tcp_hdr_len = ((*(uint8_t *)data_off_field) >> 4) * 32;
++
++ /* get an allocated 'field_changes' structure */
++ struct field_changes * changes = get_allocated_field_changes(L, 12);
++
++ /* depending on the tcp header length, change the length of the options*/
++ changes->field_length_changes[10] = tcp_hdr_len - 160;
++ /* depending on the options length, change the offset of the data */
++ changes->field_offset_changes[11] = changes->field_length_changes[10];
++ changes->field_length_changes[11] = (seg->length * 8) - tcp_hdr_len;
++
++ return changes;
++
++}
++
++struct field_changes * tcp_options_get_field_changes(lua_State *L, lua_packet_segment * seg)
++{
++ /* depending on the value stored inside the 'data_off'-field, the length of
++ * the 'options' field has to be changed, as well as the length and offset
++ * of the 'data' field */
++ uint8_t *tcp_opt_hdr = seg->start + seg->offset;
++
++ /* get an allocated 'field_changes' structure */
++ struct field_changes * changes = get_allocated_field_changes(L, 5);
++
++ int32_t MSS = 0, WS = 0, SACK = 0, TS = 0, i;
++
++ uint8_t b1, b2;
++
++ for (i = 0; i < seg->length; i++) {
++ b1 = tcp_opt_hdr[i];
++ b2 = tcp_opt_hdr[i + 1];
++
++ if (b1 == 0x00)
++ break;
++
++ /* test for MSS */
++ if (!MSS && (b1 == 0x02 && b2 == 0x04)) {
++ changes->field_offset_changes[0] = (i + 2) * CHAR_BIT;
++ MSS = 1;
++ }
++
++ /* test for WS --- yet buggy somehow */
++ if (!WS && (b1 == 0x03 && b2 == 0x03)) {
++ changes->field_offset_changes[1] = (i + 2) * CHAR_BIT;
++ WS = 1;
++ }
++
++ /* test for SACK*/
++ if (!SACK && (b1 == 0x04 && b2 == 0x02)) {
++ changes->field_offset_changes[2] = i * CHAR_BIT; /* has no value */
++ SACK = 1;
++ }
++
++ /* test for TS */
++ if (!TS && (b1 == 0x08 && b2 == 0x0A)) {
++ changes->field_offset_changes[3] = (i + 2) * CHAR_BIT;
++ changes->field_offset_changes[4] = (i + 2 + 4) * CHAR_BIT;
++ TS = 1;
++ }
++ }
++
++ return changes;
++
++}
++
++void luaopen_protbuf_tcp(lua_State *L)
++{
++ register_protbuf(L, (struct protocol_buf *)&tcp_protocol_buf, PACKET_TCP);
++}
++void luaopen_protbuf_tcp_options(lua_State *L)
++{
++ register_protbuf(L, (struct protocol_buf *)&tcp_options_and_data_buf, PACKET_TCP_OPTIONS);
++}
++
++
+--- /dev/null
++++ b/extensions/LUA/prot_buf_tftp.c
+@@ -0,0 +1,87 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre@dergraf.org>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++#include "controller.h"
++
++static const struct protocol_field tftp_protocol_fields[] = {
++ /* field name offset length getter setter */
++ { "opcode", 0, 16, get_16_bit_generic, NULL},
++ { "filename", 0, 0, get_string_generic, NULL},
++ { "mode", 0, 0, get_string_generic, NULL},
++ { "block_nr", 0, 16, get_16_bit_generic, NULL},
++ { "data", 0, 0, NULL, NULL},
++ PROT_FIELD_SENTINEL,
++};
++
++struct field_changes * tftp_get_field_changes(lua_State *L, lua_packet_segment * seg)
++{
++ /* depending on the value stored inside the 'opcode'-field we have to change
++ * offsets and lengths */
++ uint8_t *tftp_hdr = seg->start + seg->offset;
++ short opcode = ntohs(*((uint16_t *)tftp_hdr));
++ /* get an allocated 'field_changes' structure */
++ struct field_changes * changes = get_allocated_field_changes(L, 5);
++ switch (opcode) {
++ case 1: /* Read Request (RRQ) */
++ /* setting offset and length of field 'filename' */
++ changes->field_offset_changes[1] = sizeof(unsigned short) << 3;
++ changes->field_length_changes[1] = strlen((char *)tftp_hdr + sizeof(unsigned short)) << 3;
++ /* setting offset and length of field 'mode' */
++ changes->field_offset_changes[2] = changes->field_offset_changes[1] + changes->field_length_changes[1];
++ changes->field_length_changes[2] = strlen((char *)tftp_hdr + (changes->field_offset_changes[2] >> 3));
++ break;
++ case 2: /* Write Request (WRQ) */
++ /* setting offset and length of field 'filename' */
++ changes->field_offset_changes[1] = sizeof(unsigned short) << 3;
++ changes->field_length_changes[1] = strlen((char *)tftp_hdr + sizeof(unsigned short)) << 3;
++ /* setting offset and length of field 'mode' */
++ changes->field_offset_changes[2] = changes->field_offset_changes[1] + changes->field_length_changes[1];
++ changes->field_length_changes[2] = strlen((char *)tftp_hdr + (changes->field_offset_changes[2] >> 3));
++ break;
++ case 3: /* Data (DATA) */
++ /* setting offset of field 'block_nr' */
++ changes->field_offset_changes[3] = sizeof(unsigned short) << 3;
++ /* setting offset of field 'data' */
++ changes->field_offset_changes[4] = changes->field_offset_changes[3] + (sizeof(unsigned short) << 3);
++ break;
++ case 4: /* Acknowledgment (ACK) */
++ /* setting offset of field 'block_nr' */
++ changes->field_offset_changes[3] = sizeof(unsigned short) << 3;
++ break;
++ case 5: /* Error (ERROR) */
++ /* we don't care ... yet */
++ break;
++ default:
++ break;
++ }
++
++ return changes;
++}
++
++static const struct protocol_buf tftp_protocol_buf = {
++ .is_dynamic = 0,
++ .name = LUA_PACKET_SEG_TFTP,
++ .payload_field = NULL,
++ .protocol_fields = (struct protocol_field *)&tftp_protocol_fields,
++ .has_protocol = NULL, /* we don't need it, since we don't provide a payload field */
++ .get_field_changes = tftp_get_field_changes,
++};
++
++void luaopen_protbuf_tftp(lua_State *L)
++{
++ register_protbuf(L, (struct protocol_buf *)&tftp_protocol_buf, PACKET_TFTP);
++}
+--- /dev/null
++++ b/extensions/LUA/prot_buf_udp.c
+@@ -0,0 +1,53 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre@dergraf.org>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++
++#if defined(__KERNEL__)
++ #include <net/checksum.h>
++#endif
++
++#include "controller.h"
++
++
++static int32_t udp_has_protocol(lua_State *L, struct protocol_buf * prot_buf, lua_packet_segment * seg, int32_t protocol_type)
++{
++ return 1;
++}
++
++static const struct protocol_field udp_protocol_fields[] = {
++ /* field name offset length getter setter */
++ { "sport", 0, 16, get_16_bit_generic, set_16_bit_generic },
++ { "dport", 16, 16, get_16_bit_generic, set_16_bit_generic },
++ { "length", 32, 16, get_16_bit_generic, set_16_bit_generic },
++ { "check", 48, 16, get_16_bit_generic, set_16_bit_generic },
++ { "data", 64, 0, NULL, NULL },
++ PROT_FIELD_SENTINEL,
++};
++
++static const struct protocol_buf udp_protocol_buf = {
++ .is_dynamic = 0,
++ .name = LUA_PACKET_SEG_UDP,
++ .payload_field = "data",
++ .protocol_fields = (struct protocol_field *)&udp_protocol_fields,
++ .has_protocol = &udp_has_protocol,
++ .get_field_changes = NULL,
++};
++
++void luaopen_protbuf_udp(lua_State *L)
++{
++ register_protbuf(L, (struct protocol_buf *)&udp_protocol_buf, PACKET_UDP);
++}
+--- /dev/null
++++ b/extensions/LUA/xt_LUA.h
+@@ -0,0 +1,36 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre.graf@stud.unibas.ch>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++
++#ifndef XT_LUA_H_
++#define XT_LUA_H_
++
++#define MAX_FILENAME_SIZE 256
++#define MAX_FUNCTION_SIZE 256
++#define MAX_SCRIPT_SIZE 32768
++#define LUA_STATE_ARRAY_SIZE 128
++
++/* the targetsize is stored in a u16, so max size of the xt_lua_tginfo cannot exceed 64K*/
++struct xt_lua_tginfo {
++ char buf[MAX_SCRIPT_SIZE];
++ char filename[MAX_FILENAME_SIZE];
++ char function[MAX_FUNCTION_SIZE];
++ __u64 script_size;
++ __u32 state_id;
++};
++
++#endif /* XT_LUA_H_ */
+--- /dev/null
++++ b/extensions/LUA/xt_LUA.mod.c
+@@ -0,0 +1,69 @@
++#include <linux/module.h>
++#include <linux/vermagic.h>
++#include <linux/compiler.h>
++
++MODULE_INFO(vermagic, VERMAGIC_STRING);
++
++struct module __this_module
++__attribute__((section(".gnu.linkonce.this_module"))) = {
++ .name = KBUILD_MODNAME,
++ .init = init_module,
++#ifdef CONFIG_MODULE_UNLOAD
++ .exit = cleanup_module,
++#endif
++ .arch = MODULE_ARCH_INIT,
++};
++
++static const struct modversion_info ____versions[]
++__used
++__attribute__((section("__versions"))) = {
++ { 0xa3379c4b, "module_layout" },
++ { 0x5cf97727, "xt_unregister_target" },
++ { 0x9a1dfd65, "strpbrk" },
++ { 0x56fb5417, "kmalloc_caches" },
++ { 0x12da5bb2, "__kmalloc" },
++ { 0xb85f3bbe, "pv_lock_ops" },
++ { 0x349cba85, "strchr" },
++ { 0xd0d8621b, "strlen" },
++ { 0x79aa04a2, "get_random_bytes" },
++ { 0x20000329, "simple_strtoul" },
++ { 0x105e2727, "__tracepoint_kmalloc" },
++ { 0xbf7e1481, "inet_proto_csum_replace4" },
++ { 0x6c1ce5ce, "strcspn" },
++ { 0x3c2c5af5, "sprintf" },
++ { 0xe2d5255a, "strcmp" },
++ { 0xe24d3a97, "jiffies_64" },
++ { 0x2bc95bd4, "memset" },
++ { 0x87fc9bcc, "kmem_cache_alloc_notrace" },
++ { 0x11089ac7, "_ctype" },
++ { 0x37befc70, "jiffies_to_msecs" },
++ { 0x70d1f8f3, "strncat" },
++ { 0xb72397d5, "printk" },
++ { 0x42224298, "sscanf" },
++ { 0x5152e605, "memcmp" },
++ { 0xb6ed1e53, "strncpy" },
++ { 0x1e6d26a8, "strstr" },
++ { 0xc3fa6a59, "memchr" },
++ { 0x61651be, "strcat" },
++ { 0x7d8c0d13, "xt_register_target" },
++ { 0x8ff4079b, "pv_irq_ops" },
++ { 0x93fca811, "__get_free_pages" },
++ { 0xf0fdf6cb, "__stack_chk_fail" },
++ { 0xbbe2391b, "kfree_skb" },
++ { 0xf333a2fb, "_raw_spin_lock_irq" },
++ { 0x37a0cba, "kfree" },
++ { 0x2e60bace, "memcpy" },
++ { 0x59e7cb79, "skb_make_writable" },
++ { 0xb742fd7, "simple_strtol" },
++ { 0x7d50a24, "csum_partial" },
++ { 0xc2d711e1, "krealloc" },
++ { 0xe914e41e, "strcpy" },
++};
++
++static const char __module_depends[]
++__used
++__attribute__((section(".modinfo"))) =
++"depends=x_tables";
++
++
++MODULE_INFO(srcversion, "33A1481C4AA71D1B5A8CA8A");
+--- /dev/null
++++ b/extensions/LUA/xt_LUA_target.c
+@@ -0,0 +1,286 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre@dergraf.org>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++
++#include <linux/kernel.h>
++#include <linux/slab.h>
++#include <linux/module.h>
++#include <asm/uaccess.h>
++#include <net/ip.h>
++#include <linux/netfilter/x_tables.h>
++#include "xt_LUA.h"
++
++#include "controller.h"
++
++/*::*
++ * lua_envs
++ * ----------
++ * This array holds a defined number of `lua_envs`_ structures.
++ * The used array index is also used as the Lua state identifier.
++ * The size of the array is defined in `LUA_STATE_ARRAY_SIZE`_.
++ */
++struct lua_env * lua_envs[LUA_STATE_ARRAY_SIZE];
++
++/*::*
++ * lua_state_refs
++ * --------------
++ * This array holds the reference counts of the several `lua_nf_state`_s
++ * which are stored inside the array `lua_states`_.
++ */
++uint32_t lua_state_refs[LUA_STATE_ARRAY_SIZE] = { 0 };
++
++/*::*
++ * lua_tg
++ * ------
++ * This function is called whenever a packet matches all matching conditions
++ * inside a rule. It is the target. It extracts the state identifier comming
++ * inside the *xt_target_param* structure and uses it to access the proper
++ * Lua state inside the `lua_states`_ array.
++ *
++ * It then constructs a new Lua userdata of type *lua_packet_segment* and
++ * initializes it with the lowest network header available. This userdata
++ * is annotated with the Lua metatable `LUA_PACKET_SEG_RAW`_ which converts
++ * the userdata to a raw lua packet having all raw functions available.
++ * This raw packet is the single parameter to the Lua function *process_packet*
++ * which must be defined inside the Lua script provided by the user. So far
++ * hardcoded, may be later configured by Lua - subject to change.
++ *
++ * The process_packet function must return an integer value, the verdict. For
++ * convenience reasons xt_LUA exports the verdicts NF_ACCEPT, NF_DROP and
++ * XT_CONTINUE inside the *register_lua_packet_lib* function.
++ */
++
++spinlock_t lock = SPIN_LOCK_UNLOCKED;
++
++static uint32_t
++lua_tg(struct sk_buff *pskb, const struct xt_target_param *par)
++{
++ uint32_t verdict;
++ lua_packet_segment *p;
++ const struct xt_lua_tginfo *info = par->targinfo;
++ lua_State * L;
++
++ /* START critical section on SMP, PacketScript is on the sequential trail at the moment TODO*/
++ spin_lock_irq(&lock);
++
++ L = lua_envs[info->state_id]->L;
++
++ if (!skb_make_writable(pskb, pskb->len))
++ return NF_DROP;
++
++ /* call the function provided by --function parameter or the default 'process_packet' defined in Lua */
++ lua_getglobal(L, info->function);
++
++ /* push the lua_packet_segment as a parameter */
++ p = (lua_packet_segment *)lua_newuserdata(L, sizeof(lua_packet_segment));
++ if (pskb->mac_header)
++ p->start = pskb->mac_header;
++ else if (pskb->network_header)
++ p->start = pskb->network_header;
++ else if (pskb->transport_header)
++ p->start = pskb->transport_header;
++ p->offset = 0;
++ p->length = (unsigned long)pskb->tail - (unsigned long)p->start;
++ p->changes = NULL;
++
++ /* marking userdata 'lua_packet_seg' with the corresponding metatable */
++ luaL_getmetatable(L, LUA_PACKET_SEG_RAW);
++ lua_setmetatable(L, -2);
++
++ /* push a reference to the skb as a parameter, needed at the moment for calculating TCP checksum, but I am not happy with it*/
++ lua_pushlightuserdata(L, (void *)skb_get(pskb));
++
++ /* do the function call (2 argument, 1 result) */
++ if (lua_pcall(L, 2, 1, 0) != 0) {
++ printk(KERN_ERR "LUA [%d]: pcall '%s' failed: %s\n", info->state_id, info->function, lua_tostring(L, -1));
++ lua_pop(L, 1);
++ return NF_DROP;
++ }
++
++ if (!lua_isnumber(L, -1)) {
++ printk(KERN_ERR "LUA [%d]: function '%s' must return a verdict\n", info->state_id, info->function);
++ lua_pop(L, 1);
++ return NF_DROP;
++ }
++
++ verdict = lua_tonumber(L, -1);
++ lua_pop(L, 1);
++
++ kfree_skb(pskb);
++
++ /* END critical section on SMP */
++ spin_unlock_irq(&lock);
++
++
++ return verdict;
++
++}
++/* Helper for checkentry */
++static bool load_script_into_state(uint32_t state_id, unsigned long script_size, char *script_buf)
++{
++ char *buf = kmalloc(script_size, GFP_KERNEL);
++ int32_t ret;
++ struct lua_env * env = kmalloc(sizeof(struct lua_env), GFP_KERNEL);
++
++ if (!script_size > 0) {
++ pr_debug("LUA [%d]: script_size %lu < 0\n", state_id, script_size);
++ return false;
++ }
++
++ env->L = lua_open();
++ luaopen_base(env->L);
++ luaopen_controller(env->L);
++
++ lua_getglobal(env->L, "_G");
++ lua_pushinteger(env->L, state_id);
++ lua_setfield(env->L, -2, "STATE_ID");
++ lua_pop(env->L, 1); /* pop _G */
++
++ strncpy(buf, script_buf, script_size);
++ ret = luaL_loadbuffer(env->L, buf, script_size, "PacketScript, loadbuffer") ||
++ lua_pcall(env->L, 0, 1, 0);
++
++ if (ret != 0) {
++ printk(KERN_ERR "LUA [%d]: failure loading script, error %s \n", state_id, lua_tostring(env->L, -1));
++ lua_pop(env->L, 1);
++ kfree(buf);
++ kfree(env);
++ return false;
++ }
++
++ lua_envs[state_id] = env;
++
++ kfree(buf);
++
++ return true;
++}
++/*::*
++ * lua_tg_checkentry
++ * -----------------
++ * This function is used as a kernel-side sanity check of the data comming
++ * from the iptables userspace program. Since this is the function which is
++ * called everytime a new rule (with -j xt_LUA) is injected, this function
++ * is used to do the bookkeeping work, such as counting the reference of
++ * several Lua states and the initialization of new states if needed. As an
++ * extra initialization step it loads the provided Lua script into the Lua
++ * state.
++ *
++ * Lua state initialization
++ * ~~~~~~~~~~~~~~~~~~~~~~~~
++ * 1. If a new rule is inserted and there is no existing state for the given
++ * state identifier (default state identifier is 0) a new Lua state is
++ * initialized using *lua_open*.
++ * 2. The Lua base library is registered inside the newly initialized state.
++ * Have a look at *lua/lbaselib.c* to see what functions of the Lua base
++ * library are available inside Lua.
++ * 3. The Lua packet library is registered inside the Lua state using the
++ * function *register_lua_packet_lib*. So far this function only registers
++ * the Netfilter verdicts NF_ACCEPT, NF_DROP and XT_CONTINUE inside the
++ * global environment of the given Lua state.
++ * 4. All the protocol Buffers, and the functions for accessing the bytes are
++ * registered using *register_protocols*.
++ *
++ * Lua state reference counting
++ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
++ * Bookkeeping of the Lua states inside the *lua_state_refs* array. The
++ * state identifier is mapped to the array index, which holds an integer
++ * counting the several initialized states.
++ *
++ * Loading the Lua script
++ * ~~~~~~~~~~~~~~~~~~~~~~
++ * Copying the buffer which was initialized by the userspace program to a
++ * buffer with the proper size. The script is then loaded by the function
++ * xt_LUA_loadcode, which wrapps the *luaL_loadbuffer* function and does
++ * some workqueue initialization. So far this is done each time this function
++ * is called, subject to change.
++ */
++static bool
++lua_tg_checkentry(const struct xt_tgchk_param *par)
++{
++ const struct xt_lua_tginfo *info = par->targinfo;
++
++ if (load_script_into_state(info->state_id, info->script_size, (char *)info->buf)) {
++ lua_state_refs[info->state_id]++;
++ return true;
++ }
++ return false;
++}
++
++/*::*
++ * lua_tg_destroy
++ * --------------
++ * This function is the counterpart of the `lua_tg_checkentry`_ function. It is
++ * responsible to free all the resources alocated inside the checkentry process.
++ * To be more specific it frees the Lua state using *lua_close* and kfree on all
++ * the dynamically allocated pointers to the registered dynamic protocol buffers.
++ *
++ * Additionally the function cares about decrementing the reference counters
++ * inside the array `lua_states`_.
++ */
++static void
++lua_tg_destroy(const struct xt_tgdtor_param *par)
++{
++ const struct xt_lua_tginfo *info = par->targinfo;
++ struct lua_env * env = lua_envs[info->state_id];
++
++ if (lua_state_refs[info->state_id] == 1) {
++ lua_close(env->L);
++ cleanup_dynamic_prot_bufs(); /* clean memory allocated by protocols defined in Lua */
++ kfree(env);
++ pr_debug("LUA [%d]: Rule removed, close Lua state\n", info->state_id);
++ } else
++ pr_debug("LUA [%d]: Rule removed, Lua state stays open, referenced %d time(s)\n",
++ info->state_id, lua_state_refs[info->state_id] - 1);
++
++ lua_state_refs[info->state_id]--;
++}
++
++static struct xt_target lua_tg_reg __read_mostly = {
++ .name = "LUA",
++ .revision = 0,
++ .family = NFPROTO_UNSPEC,
++ .targetsize = XT_ALIGN(sizeof(struct xt_lua_tginfo)),
++ .target = lua_tg,
++ .checkentry = lua_tg_checkentry,
++ .destroy = lua_tg_destroy,
++ .me = THIS_MODULE,
++};
++
++
++static int32_t lua_tg_init(void)
++{
++ return xt_register_target(&lua_tg_reg);
++}
++
++static void lua_tg_exit(void)
++{
++ xt_unregister_target(&lua_tg_reg);
++}
++
++module_init(lua_tg_init);
++module_exit(lua_tg_exit);
++
++MODULE_AUTHOR("Andre Graf <andre@dergraf.org>");
++MODULE_DESCRIPTION("Xtables: Processing of matched packets using the Lua scripting environment");
++MODULE_ALIAS("ipt_LUA");
++MODULE_ALIAS("ipt6t_LUA");
++MODULE_ALIAS("arpt_LUA");
++MODULE_ALIAS("ebt_LUA");
++MODULE_LICENSE("GPL");
++
++
++
+--- a/extensions/Kbuild
++++ b/extensions/Kbuild
+@@ -36,6 +36,7 @@ obj-${build_pknock} += pknock/
+ obj-${build_psd} += xt_psd.o
+ obj-${build_quota2} += xt_quota2.o
+ obj-${build_rtsp} += rtsp/
++obj-${build_LUA} += LUA/
+
+ -include ${M}/*.Kbuild
+ -include ${M}/Kbuild.*
+--- a/extensions/Mbuild
++++ b/extensions/Mbuild
+@@ -26,3 +26,4 @@ obj-${build_pknock} += pknock/
+ obj-${build_psd} += libxt_psd.so
+ obj-${build_quota2} += libxt_quota2.so
+ obj-${build_gradm} += libxt_gradm.so
++obj-${build_LUA} += LUA/
+--- a/mconfig
++++ b/mconfig
+@@ -27,3 +27,4 @@ build_pknock=m
+ build_psd=m
+ build_quota2=m
+ build_rtsp=m
++build_LUA=m
diff --git a/package/network/utils/xtables-addons/patches-1.x/.svn/text-base/201-fix-lua-packetscript.patch.svn-base b/package/network/utils/xtables-addons/patches-1.x/.svn/text-base/201-fix-lua-packetscript.patch.svn-base
new file mode 100644
index 0000000..966d29d
--- /dev/null
+++ b/package/network/utils/xtables-addons/patches-1.x/.svn/text-base/201-fix-lua-packetscript.patch.svn-base
@@ -0,0 +1,89 @@
+--- a/extensions/LUA/xt_LUA_target.c
++++ b/extensions/LUA/xt_LUA_target.c
+@@ -64,10 +64,10 @@ uint32_t lua_state_refs[LUA_STATE_ARRAY
+ * XT_CONTINUE inside the *register_lua_packet_lib* function.
+ */
+
+-spinlock_t lock = SPIN_LOCK_UNLOCKED;
++DEFINE_SPINLOCK(lock);
+
+ static uint32_t
+-lua_tg(struct sk_buff *pskb, const struct xt_target_param *par)
++lua_tg(struct sk_buff *pskb, const struct xt_action_param *par)
+ {
+ uint32_t verdict;
+ lua_packet_segment *p;
+@@ -208,16 +208,16 @@ static bool load_script_into_state(uint3
+ * some workqueue initialization. So far this is done each time this function
+ * is called, subject to change.
+ */
+-static bool
++static int
+ lua_tg_checkentry(const struct xt_tgchk_param *par)
+ {
+ const struct xt_lua_tginfo *info = par->targinfo;
+
+ if (load_script_into_state(info->state_id, info->script_size, (char *)info->buf)) {
+ lua_state_refs[info->state_id]++;
+- return true;
++ return 0;
+ }
+- return false;
++ return -EINVAL;
+ }
+
+ /*::*
+--- a/extensions/LUA/lua/llimits.h
++++ b/extensions/LUA/lua/llimits.h
+@@ -8,7 +8,6 @@
+ #define llimits_h
+
+ #include <stddef.h>
+-#include <limits.h>
+
+ #include "lua.h"
+
+--- a/extensions/LUA/lua/lapi.c
++++ b/extensions/LUA/lua/lapi.c
+@@ -4,9 +4,6 @@
+ ** See Copyright Notice in lua.h
+ */
+
+-#include <stdarg.h>
+-#include <math.h>
+-#include <assert.h>
+ #include <string.h>
+
+ #define lapi_c
+--- a/extensions/LUA/lua/ltable.c
++++ b/extensions/LUA/lua/ltable.c
+@@ -18,7 +18,6 @@
+ ** Hence even when the load factor reaches 100%, performance remains good.
+ */
+
+-#include <math.h>
+ #include <string.h>
+
+ #define ltable_c
+--- a/extensions/LUA/lua/luaconf.h
++++ b/extensions/LUA/lua/luaconf.h
+@@ -13,6 +13,10 @@
+ #if !defined(__KERNEL__)
+ #include <limits.h>
+ #else
++#undef UCHAR_MAX
++#undef SHRT_MAX
++#undef BUFSIZ
++#undef NO_FPU
+ #define UCHAR_MAX 255
+ #define SHRT_MAX 32767
+ #define BUFSIZ 8192
+@@ -637,6 +641,8 @@ union luai_Cast { double l_d; long l_l;
+ */
+ #if defined(__KERNEL__)
+ #undef LUA_USE_ULONGJMP
++#define setjmp __builtin_setjmp
++#define longjmp __builtin_longjmp
+ #endif
+
+ #if defined(__cplusplus)
diff --git a/package/network/utils/xtables-addons/patches-1.x/.svn/text-base/300-geoip-endian-detection.patch.svn-base b/package/network/utils/xtables-addons/patches-1.x/.svn/text-base/300-geoip-endian-detection.patch.svn-base
new file mode 100644
index 0000000..842e7af
--- /dev/null
+++ b/package/network/utils/xtables-addons/patches-1.x/.svn/text-base/300-geoip-endian-detection.patch.svn-base
@@ -0,0 +1,18 @@
+--- a/extensions/libxt_geoip.c
++++ b/extensions/libxt_geoip.c
+@@ -59,13 +59,13 @@ geoip_get_subnets(const char *code, uint
+
+ /* Use simple integer vector files */
+ if (nfproto == NFPROTO_IPV6) {
+-#if __BYTE_ORDER == _BIG_ENDIAN
++#if BYTE_ORDER == BIG_ENDIAN
+ snprintf(buf, sizeof(buf), GEOIP_DB_DIR "/BE/%s.iv6", code);
+ #else
+ snprintf(buf, sizeof(buf), GEOIP_DB_DIR "/LE/%s.iv6", code);
+ #endif
+ } else {
+-#if __BYTE_ORDER == _BIG_ENDIAN
++#if BYTE_ORDER == BIG_ENDIAN
+ snprintf(buf, sizeof(buf), GEOIP_DB_DIR "/BE/%s.iv4", code);
+ #else
+ snprintf(buf, sizeof(buf), GEOIP_DB_DIR "/LE/%s.iv4", code);
diff --git a/package/network/utils/xtables-addons/patches-1.x/001-no_depmod.patch b/package/network/utils/xtables-addons/patches-1.x/001-no_depmod.patch
new file mode 100644
index 0000000..9905af1
--- /dev/null
+++ b/package/network/utils/xtables-addons/patches-1.x/001-no_depmod.patch
@@ -0,0 +1,16 @@
+---
+ Makefile.in | 3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -11,9 +11,6 @@ FORCE:
+ xtables-addons.8: FORCE
+ ${MAKE} -f Makefile.mans all;
+
+-install-exec-hook:
+- depmod -a || :;
+-
+ config.status: Makefile.iptrules.in
+
+ tmpdir := $(shell mktemp -dtu)
diff --git a/package/network/utils/xtables-addons/patches-1.x/002-fix-kernel-version-detection.patch b/package/network/utils/xtables-addons/patches-1.x/002-fix-kernel-version-detection.patch
new file mode 100644
index 0000000..b31f9f1
--- /dev/null
+++ b/package/network/utils/xtables-addons/patches-1.x/002-fix-kernel-version-detection.patch
@@ -0,0 +1,22 @@
+--- a/configure
++++ b/configure
+@@ -11780,7 +11780,7 @@ regular_CFLAGS="-Wall -Waggregate-return
+ if test -n "$kbuilddir"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking kernel version that we will build against" >&5
+ $as_echo_n "checking kernel version that we will build against... " >&6; }
+- krel="$(make -sC "$kbuilddir" M=$PWD kernelrelease)";
++ krel="$(make -sC "$kbuilddir" M=$PWD kernelversion)";
+ kmajor="${krel%%[^0-9]*}";
+ kmajor="$(($kmajor+0))";
+ krel="${krel:${#kmajor}}";
+--- a/configure.ac
++++ b/configure.ac
+@@ -44,7 +44,7 @@ regular_CFLAGS="-Wall -Waggregate-return
+
+ if test -n "$kbuilddir"; then
+ AC_MSG_CHECKING([kernel version that we will build against])
+- krel="$(make -sC "$kbuilddir" M=$PWD kernelrelease)";
++ krel="$(make -sC "$kbuilddir" M=$PWD kernelversion)";
+ kmajor="${krel%%[[^0-9]]*}";
+ kmajor="$(($kmajor+0))";
+ krel="${krel:${#kmajor}}";
diff --git a/package/network/utils/xtables-addons/patches-1.x/003-redundant-bracket.patch b/package/network/utils/xtables-addons/patches-1.x/003-redundant-bracket.patch
new file mode 100644
index 0000000..ae3911a
--- /dev/null
+++ b/package/network/utils/xtables-addons/patches-1.x/003-redundant-bracket.patch
@@ -0,0 +1,11 @@
+--- a/configure.ac
++++ b/configure.ac
+@@ -31,7 +31,7 @@ xtlibdir="$(pkg-config --variable=xtlibd
+
+ AC_ARG_WITH([xtlibdir],
+ AS_HELP_STRING([--with-xtlibdir=PATH],
+- [Path where to install Xtables extensions [[autodetect]]]]),
++ [Path where to install Xtables extensions [[autodetect]]]),
+ [xtlibdir="$withval"])
+ AC_MSG_CHECKING([Xtables module directory])
+ AC_MSG_RESULT([$xtlibdir])
diff --git a/package/network/utils/xtables-addons/patches-1.x/100-add-rtsp-conntrack.patch b/package/network/utils/xtables-addons/patches-1.x/100-add-rtsp-conntrack.patch
new file mode 100644
index 0000000..34cdc8c
--- /dev/null
+++ b/package/network/utils/xtables-addons/patches-1.x/100-add-rtsp-conntrack.patch
@@ -0,0 +1,1334 @@
+--- /dev/null
++++ b/extensions/rtsp/Kbuild
+@@ -0,0 +1,4 @@
++# -*- Makefile -*-
++
++obj-m += nf_nat_rtsp.o
++obj-m += nf_conntrack_rtsp.o
+--- /dev/null
++++ b/extensions/rtsp/netfilter_helpers.h
+@@ -0,0 +1,133 @@
++/*
++ * Helpers for netfiler modules. This file provides implementations for basic
++ * functions such as strncasecmp(), etc.
++ *
++ * gcc will warn for defined but unused functions, so we only include the
++ * functions requested. The following macros are used:
++ * NF_NEED_STRNCASECMP nf_strncasecmp()
++ * NF_NEED_STRTOU16 nf_strtou16()
++ * NF_NEED_STRTOU32 nf_strtou32()
++ */
++#ifndef _NETFILTER_HELPERS_H
++#define _NETFILTER_HELPERS_H
++
++/* Only include these functions for kernel code. */
++#ifdef __KERNEL__
++
++#include <linux/ctype.h>
++#define iseol(c) ( (c) == '\r' || (c) == '\n' )
++
++/*
++ * The standard strncasecmp()
++ */
++#ifdef NF_NEED_STRNCASECMP
++static int
++nf_strncasecmp(const char* s1, const char* s2, u_int32_t len)
++{
++ if (s1 == NULL || s2 == NULL)
++ {
++ if (s1 == NULL && s2 == NULL)
++ {
++ return 0;
++ }
++ return (s1 == NULL) ? -1 : 1;
++ }
++ while (len > 0 && tolower(*s1) == tolower(*s2))
++ {
++ len--;
++ s1++;
++ s2++;
++ }
++ return ( (len == 0) ? 0 : (tolower(*s1) - tolower(*s2)) );
++}
++#endif /* NF_NEED_STRNCASECMP */
++
++/*
++ * Parse a string containing a 16-bit unsigned integer.
++ * Returns the number of chars used, or zero if no number is found.
++ */
++#ifdef NF_NEED_STRTOU16
++static int
++nf_strtou16(const char* pbuf, u_int16_t* pval)
++{
++ int n = 0;
++
++ *pval = 0;
++ while (isdigit(pbuf[n]))
++ {
++ *pval = (*pval * 10) + (pbuf[n] - '0');
++ n++;
++ }
++
++ return n;
++}
++#endif /* NF_NEED_STRTOU16 */
++
++/*
++ * Parse a string containing a 32-bit unsigned integer.
++ * Returns the number of chars used, or zero if no number is found.
++ */
++#ifdef NF_NEED_STRTOU32
++static int
++nf_strtou32(const char* pbuf, u_int32_t* pval)
++{
++ int n = 0;
++
++ *pval = 0;
++ while (pbuf[n] >= '0' && pbuf[n] <= '9')
++ {
++ *pval = (*pval * 10) + (pbuf[n] - '0');
++ n++;
++ }
++
++ return n;
++}
++#endif /* NF_NEED_STRTOU32 */
++
++/*
++ * Given a buffer and length, advance to the next line and mark the current
++ * line.
++ */
++#ifdef NF_NEED_NEXTLINE
++static int
++nf_nextline(char* p, uint len, uint* poff, uint* plineoff, uint* plinelen)
++{
++ uint off = *poff;
++ uint physlen = 0;
++
++ if (off >= len)
++ {
++ return 0;
++ }
++
++ while (p[off] != '\n')
++ {
++ if (len-off <= 1)
++ {
++ return 0;
++ }
++
++ physlen++;
++ off++;
++ }
++
++ /* if we saw a crlf, physlen needs adjusted */
++ if (physlen > 0 && p[off] == '\n' && p[off-1] == '\r')
++ {
++ physlen--;
++ }
++
++ /* advance past the newline */
++ off++;
++
++ *plineoff = *poff;
++ *plinelen = physlen;
++ *poff = off;
++
++ return 1;
++}
++#endif /* NF_NEED_NEXTLINE */
++
++#endif /* __KERNEL__ */
++
++#endif /* _NETFILTER_HELPERS_H */
+--- /dev/null
++++ b/extensions/rtsp/netfilter_mime.h
+@@ -0,0 +1,89 @@
++/*
++ * MIME functions for netfilter modules. This file provides implementations
++ * for basic MIME parsing. MIME headers are used in many protocols, such as
++ * HTTP, RTSP, SIP, etc.
++ *
++ * gcc will warn for defined but unused functions, so we only include the
++ * functions requested. The following macros are used:
++ * NF_NEED_MIME_NEXTLINE nf_mime_nextline()
++ */
++#ifndef _NETFILTER_MIME_H
++#define _NETFILTER_MIME_H
++
++/* Only include these functions for kernel code. */
++#ifdef __KERNEL__
++
++#include <linux/ctype.h>
++
++/*
++ * Given a buffer and length, advance to the next line and mark the current
++ * line. If the current line is empty, *plinelen will be set to zero. If
++ * not, it will be set to the actual line length (including CRLF).
++ *
++ * 'line' in this context means logical line (includes LWS continuations).
++ * Returns 1 on success, 0 on failure.
++ */
++#ifdef NF_NEED_MIME_NEXTLINE
++static int
++nf_mime_nextline(char* p, uint len, uint* poff, uint* plineoff, uint* plinelen)
++{
++ uint off = *poff;
++ uint physlen = 0;
++ int is_first_line = 1;
++
++ if (off >= len)
++ {
++ return 0;
++ }
++
++ do
++ {
++ while (p[off] != '\n')
++ {
++ if (len-off <= 1)
++ {
++ return 0;
++ }
++
++ physlen++;
++ off++;
++ }
++
++ /* if we saw a crlf, physlen needs adjusted */
++ if (physlen > 0 && p[off] == '\n' && p[off-1] == '\r')
++ {
++ physlen--;
++ }
++
++ /* advance past the newline */
++ off++;
++
++ /* check for an empty line */
++ if (physlen == 0)
++ {
++ break;
++ }
++
++ /* check for colon on the first physical line */
++ if (is_first_line)
++ {
++ is_first_line = 0;
++ if (memchr(p+(*poff), ':', physlen) == NULL)
++ {
++ return 0;
++ }
++ }
++ }
++ while (p[off] == ' ' || p[off] == '\t');
++
++ *plineoff = *poff;
++ *plinelen = (physlen == 0) ? 0 : (off - *poff);
++ *poff = off;
++
++ return 1;
++}
++#endif /* NF_NEED_MIME_NEXTLINE */
++
++#endif /* __KERNEL__ */
++
++#endif /* _NETFILTER_MIME_H */
+--- /dev/null
++++ b/extensions/rtsp/nf_conntrack_rtsp.c
+@@ -0,0 +1,519 @@
++/*
++ * RTSP extension for IP connection tracking
++ * (C) 2003 by Tom Marshall <tmarshall at real.com>
++ * based on ip_conntrack_irc.c
++ *
++ * 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 of the License, or (at your option) any later version.
++ *
++ * Module load syntax:
++ * insmod nf_conntrack_rtsp.o ports=port1,port2,...port<MAX_PORTS>
++ * max_outstanding=n setup_timeout=secs
++ *
++ * If no ports are specified, the default will be port 554.
++ *
++ * With max_outstanding you can define the maximum number of not yet
++ * answered SETUP requests per RTSP session (default 8).
++ * With setup_timeout you can specify how long the system waits for
++ * an expected data channel (default 300 seconds).
++ *
++ * 2005-02-13: Harald Welte <laforge at netfilter.org>
++ * - port to 2.6
++ * - update to recent post-2.6.11 api changes
++ * 2006-09-14: Steven Van Acker <deepstar at singularity.be>
++ * - removed calls to NAT code from conntrack helper: NAT no longer needed to use rtsp-conntrack
++ * 2007-04-18: Michael Guntsche <mike at it-loops.com>
++ * - Port to new NF API
++ */
++
++#include <linux/module.h>
++#include <linux/netfilter.h>
++#include <linux/ip.h>
++#include <linux/inet.h>
++#include <net/tcp.h>
++
++#include <net/netfilter/nf_conntrack.h>
++#include <net/netfilter/nf_conntrack_expect.h>
++#include <net/netfilter/nf_conntrack_helper.h>
++#include "nf_conntrack_rtsp.h"
++
++#define NF_NEED_STRNCASECMP
++#define NF_NEED_STRTOU16
++#define NF_NEED_STRTOU32
++#define NF_NEED_NEXTLINE
++#include "netfilter_helpers.h"
++#define NF_NEED_MIME_NEXTLINE
++#include "netfilter_mime.h"
++
++#include <linux/ctype.h>
++#define MAX_SIMUL_SETUP 8 /* XXX: use max_outstanding */
++
++#define MAX_PORTS 8
++static int ports[MAX_PORTS];
++static int num_ports = 0;
++static int max_outstanding = 8;
++static unsigned int setup_timeout = 300;
++
++MODULE_AUTHOR("Tom Marshall <tmarshall at real.com>");
++MODULE_DESCRIPTION("RTSP connection tracking module");
++MODULE_LICENSE("GPL");
++module_param_array(ports, int, &num_ports, 0400);
++MODULE_PARM_DESC(ports, "port numbers of RTSP servers");
++module_param(max_outstanding, int, 0400);
++MODULE_PARM_DESC(max_outstanding, "max number of outstanding SETUP requests per RTSP session");
++module_param(setup_timeout, int, 0400);
++MODULE_PARM_DESC(setup_timeout, "timeout on for unestablished data channels");
++
++static char *rtsp_buffer;
++static DEFINE_SPINLOCK(rtsp_buffer_lock);
++
++static struct nf_conntrack_expect_policy rtsp_exp_policy;
++
++unsigned int (*nf_nat_rtsp_hook)(struct sk_buff *skb,
++ enum ip_conntrack_info ctinfo,
++ unsigned int matchoff, unsigned int matchlen,struct ip_ct_rtsp_expect* prtspexp,
++ struct nf_conntrack_expect *exp);
++void (*nf_nat_rtsp_hook_expectfn)(struct nf_conn *ct, struct nf_conntrack_expect *exp);
++
++EXPORT_SYMBOL_GPL(nf_nat_rtsp_hook);
++
++/*
++ * Max mappings we will allow for one RTSP connection (for RTP, the number
++ * of allocated ports is twice this value). Note that SMIL burns a lot of
++ * ports so keep this reasonably high. If this is too low, you will see a
++ * lot of "no free client map entries" messages.
++ */
++#define MAX_PORT_MAPS 16
++
++/*** default port list was here in the masq code: 554, 3030, 4040 ***/
++
++#define SKIP_WSPACE(ptr,len,off) while(off < len && isspace(*(ptr+off))) { off++; }
++
++/*
++ * Parse an RTSP packet.
++ *
++ * Returns zero if parsing failed.
++ *
++ * Parameters:
++ * IN ptcp tcp data pointer
++ * IN tcplen tcp data len
++ * IN/OUT ptcpoff points to current tcp offset
++ * OUT phdrsoff set to offset of rtsp headers
++ * OUT phdrslen set to length of rtsp headers
++ * OUT pcseqoff set to offset of CSeq header
++ * OUT pcseqlen set to length of CSeq header
++ */
++static int
++rtsp_parse_message(char* ptcp, uint tcplen, uint* ptcpoff,
++ uint* phdrsoff, uint* phdrslen,
++ uint* pcseqoff, uint* pcseqlen,
++ uint* transoff, uint* translen)
++{
++ uint entitylen = 0;
++ uint lineoff;
++ uint linelen;
++
++ if (!nf_nextline(ptcp, tcplen, ptcpoff, &lineoff, &linelen))
++ return 0;
++
++ *phdrsoff = *ptcpoff;
++ while (nf_mime_nextline(ptcp, tcplen, ptcpoff, &lineoff, &linelen)) {
++ if (linelen == 0) {
++ if (entitylen > 0)
++ *ptcpoff += min(entitylen, tcplen - *ptcpoff);
++ break;
++ }
++ if (lineoff+linelen > tcplen) {
++ pr_info("!! overrun !!\n");
++ break;
++ }
++
++ if (nf_strncasecmp(ptcp+lineoff, "CSeq:", 5) == 0) {
++ *pcseqoff = lineoff;
++ *pcseqlen = linelen;
++ }
++
++ if (nf_strncasecmp(ptcp+lineoff, "Transport:", 10) == 0) {
++ *transoff = lineoff;
++ *translen = linelen;
++ }
++
++ if (nf_strncasecmp(ptcp+lineoff, "Content-Length:", 15) == 0) {
++ uint off = lineoff+15;
++ SKIP_WSPACE(ptcp+lineoff, linelen, off);
++ nf_strtou32(ptcp+off, &entitylen);
++ }
++ }
++ *phdrslen = (*ptcpoff) - (*phdrsoff);
++
++ return 1;
++}
++
++/*
++ * Find lo/hi client ports (if any) in transport header
++ * In:
++ * ptcp, tcplen = packet
++ * tranoff, tranlen = buffer to search
++ *
++ * Out:
++ * pport_lo, pport_hi = lo/hi ports (host endian)
++ *
++ * Returns nonzero if any client ports found
++ *
++ * Note: it is valid (and expected) for the client to request multiple
++ * transports, so we need to parse the entire line.
++ */
++static int
++rtsp_parse_transport(char* ptran, uint tranlen,
++ struct ip_ct_rtsp_expect* prtspexp)
++{
++ int rc = 0;
++ uint off = 0;
++
++ if (tranlen < 10 || !iseol(ptran[tranlen-1]) ||
++ nf_strncasecmp(ptran, "Transport:", 10) != 0) {
++ pr_info("sanity check failed\n");
++ return 0;
++ }
++
++ pr_debug("tran='%.*s'\n", (int)tranlen, ptran);
++ off += 10;
++ SKIP_WSPACE(ptran, tranlen, off);
++
++ /* Transport: tran;field;field=val,tran;field;field=val,... */
++ while (off < tranlen) {
++ const char* pparamend;
++ uint nextparamoff;
++
++ pparamend = memchr(ptran+off, ',', tranlen-off);
++ pparamend = (pparamend == NULL) ? ptran+tranlen : pparamend+1;
++ nextparamoff = pparamend-ptran;
++
++ while (off < nextparamoff) {
++ const char* pfieldend;
++ uint nextfieldoff;
++
++ pfieldend = memchr(ptran+off, ';', nextparamoff-off);
++ nextfieldoff = (pfieldend == NULL) ? nextparamoff : pfieldend-ptran+1;
++
++ if (strncmp(ptran+off, "client_port=", 12) == 0) {
++ u_int16_t port;
++ uint numlen;
++
++ off += 12;
++ numlen = nf_strtou16(ptran+off, &port);
++ off += numlen;
++ if (prtspexp->loport != 0 && prtspexp->loport != port)
++ pr_debug("multiple ports found, port %hu ignored\n", port);
++ else {
++ pr_debug("lo port found : %hu\n", port);
++ prtspexp->loport = prtspexp->hiport = port;
++ if (ptran[off] == '-') {
++ off++;
++ numlen = nf_strtou16(ptran+off, &port);
++ off += numlen;
++ prtspexp->pbtype = pb_range;
++ prtspexp->hiport = port;
++
++ // If we have a range, assume rtp:
++ // loport must be even, hiport must be loport+1
++ if ((prtspexp->loport & 0x0001) != 0 ||
++ prtspexp->hiport != prtspexp->loport+1) {
++ pr_debug("incorrect range: %hu-%hu, correcting\n",
++ prtspexp->loport, prtspexp->hiport);
++ prtspexp->loport &= 0xfffe;
++ prtspexp->hiport = prtspexp->loport+1;
++ }
++ } else if (ptran[off] == '/') {
++ off++;
++ numlen = nf_strtou16(ptran+off, &port);
++ off += numlen;
++ prtspexp->pbtype = pb_discon;
++ prtspexp->hiport = port;
++ }
++ rc = 1;
++ }
++ }
++
++ /*
++ * Note we don't look for the destination parameter here.
++ * If we are using NAT, the NAT module will handle it. If not,
++ * and the client is sending packets elsewhere, the expectation
++ * will quietly time out.
++ */
++
++ off = nextfieldoff;
++ }
++
++ off = nextparamoff;
++ }
++
++ return rc;
++}
++
++void expected(struct nf_conn *ct, struct nf_conntrack_expect *exp)
++{
++ typeof(nf_nat_rtsp_hook_expectfn) nf_nat_rtsp_expectfn;
++ nf_nat_rtsp_expectfn = rcu_dereference(nf_nat_rtsp_hook_expectfn);
++ if(nf_nat_rtsp_expectfn && ct->master->status & IPS_NAT_MASK) {
++ nf_nat_rtsp_expectfn(ct,exp);
++ }
++}
++
++/*** conntrack functions ***/
++
++/* outbound packet: client->server */
++
++static inline int
++help_out(struct sk_buff *skb, unsigned char *rb_ptr, unsigned int datalen,
++ struct nf_conn *ct, enum ip_conntrack_info ctinfo)
++{
++ struct ip_ct_rtsp_expect expinfo;
++
++ int dir = CTINFO2DIR(ctinfo); /* = IP_CT_DIR_ORIGINAL */
++ //struct tcphdr* tcph = (void*)iph + iph->ihl * 4;
++ //uint tcplen = pktlen - iph->ihl * 4;
++ char* pdata = rb_ptr;
++ //uint datalen = tcplen - tcph->doff * 4;
++ uint dataoff = 0;
++ int ret = NF_ACCEPT;
++
++ struct nf_conntrack_expect *exp;
++
++ __be16 be_loport;
++
++ typeof(nf_nat_rtsp_hook) nf_nat_rtsp;
++
++ memset(&expinfo, 0, sizeof(expinfo));
++
++ while (dataoff < datalen) {
++ uint cmdoff = dataoff;
++ uint hdrsoff = 0;
++ uint hdrslen = 0;
++ uint cseqoff = 0;
++ uint cseqlen = 0;
++ uint transoff = 0;
++ uint translen = 0;
++ uint off;
++
++ if (!rtsp_parse_message(pdata, datalen, &dataoff,
++ &hdrsoff, &hdrslen,
++ &cseqoff, &cseqlen,
++ &transoff, &translen))
++ break; /* not a valid message */
++
++ if (strncmp(pdata+cmdoff, "SETUP ", 6) != 0)
++ continue; /* not a SETUP message */
++ pr_debug("found a setup message\n");
++
++ off = 0;
++ if(translen) {
++ rtsp_parse_transport(pdata+transoff, translen, &expinfo);
++ }
++
++ if (expinfo.loport == 0) {
++ pr_debug("no udp transports found\n");
++ continue; /* no udp transports found */
++ }
++
++ pr_debug("udp transport found, ports=(%d,%hu,%hu)\n",
++ (int)expinfo.pbtype, expinfo.loport, expinfo.hiport);
++
++ exp = nf_ct_expect_alloc(ct);
++ if (!exp) {
++ ret = NF_DROP;
++ goto out;
++ }
++
++ be_loport = htons(expinfo.loport);
++
++ nf_ct_expect_init(exp, NF_CT_EXPECT_CLASS_DEFAULT, nf_ct_l3num(ct),
++ &ct->tuplehash[!dir].tuple.src.u3, &ct->tuplehash[!dir].tuple.dst.u3,
++ IPPROTO_UDP, NULL, &be_loport);
++
++ exp->master = ct;
++
++ exp->expectfn = expected;
++ exp->flags = 0;
++
++ if (expinfo.pbtype == pb_range) {
++ pr_debug("Changing expectation mask to handle multiple ports\n");
++ //exp->mask.dst.u.udp.port = 0xfffe;
++ }
++
++ pr_debug("expect_related %pI4:%u-%pI4:%u\n",
++ &exp->tuple.src.u3.ip,
++ ntohs(exp->tuple.src.u.udp.port),
++ &exp->tuple.dst.u3.ip,
++ ntohs(exp->tuple.dst.u.udp.port));
++
++ nf_nat_rtsp = rcu_dereference(nf_nat_rtsp_hook);
++ if (nf_nat_rtsp && ct->status & IPS_NAT_MASK)
++ /* pass the request off to the nat helper */
++ ret = nf_nat_rtsp(skb, ctinfo, hdrsoff, hdrslen, &expinfo, exp);
++ else if (nf_ct_expect_related(exp) != 0) {
++ pr_info("nf_conntrack_expect_related failed\n");
++ ret = NF_DROP;
++ }
++ nf_ct_expect_put(exp);
++ goto out;
++ }
++out:
++
++ return ret;
++}
++
++
++static inline int
++help_in(struct sk_buff *skb, size_t pktlen,
++ struct nf_conn* ct, enum ip_conntrack_info ctinfo)
++{
++ return NF_ACCEPT;
++}
++
++static int help(struct sk_buff *skb, unsigned int protoff,
++ struct nf_conn *ct, enum ip_conntrack_info ctinfo)
++{
++ struct tcphdr _tcph, *th;
++ unsigned int dataoff, datalen;
++ char *rb_ptr;
++ int ret = NF_DROP;
++
++ /* Until there's been traffic both ways, don't look in packets. */
++ if (ctinfo != IP_CT_ESTABLISHED &&
++ ctinfo != IP_CT_ESTABLISHED + IP_CT_IS_REPLY) {
++ pr_debug("conntrackinfo = %u\n", ctinfo);
++ return NF_ACCEPT;
++ }
++
++ /* Not whole TCP header? */
++ th = skb_header_pointer(skb,protoff, sizeof(_tcph), &_tcph);
++
++ if (!th)
++ return NF_ACCEPT;
++
++ /* No data ? */
++ dataoff = protoff + th->doff*4;
++ datalen = skb->len - dataoff;
++ if (dataoff >= skb->len)
++ return NF_ACCEPT;
++
++ spin_lock_bh(&rtsp_buffer_lock);
++ rb_ptr = skb_header_pointer(skb, dataoff,
++ skb->len - dataoff, rtsp_buffer);
++ BUG_ON(rb_ptr == NULL);
++
++#if 0
++ /* Checksum invalid? Ignore. */
++ /* FIXME: Source route IP option packets --RR */
++ if (tcp_v4_check(tcph, tcplen, iph->saddr, iph->daddr,
++ csum_partial((char*)tcph, tcplen, 0)))
++ {
++ DEBUGP("bad csum: %p %u %u.%u.%u.%u %u.%u.%u.%u\n",
++ tcph, tcplen, NIPQUAD(iph->saddr), NIPQUAD(iph->daddr));
++ return NF_ACCEPT;
++ }
++#endif
++
++ switch (CTINFO2DIR(ctinfo)) {
++ case IP_CT_DIR_ORIGINAL:
++ ret = help_out(skb, rb_ptr, datalen, ct, ctinfo);
++ break;
++ case IP_CT_DIR_REPLY:
++ pr_debug("IP_CT_DIR_REPLY\n");
++ /* inbound packet: server->client */
++ ret = NF_ACCEPT;
++ break;
++ }
++
++ spin_unlock_bh(&rtsp_buffer_lock);
++
++ return ret;
++}
++
++static struct nf_conntrack_helper rtsp_helpers[MAX_PORTS];
++static char rtsp_names[MAX_PORTS][10];
++
++/* This function is intentionally _NOT_ defined as __exit */
++static void
++fini(void)
++{
++ int i;
++ for (i = 0; i < num_ports; i++) {
++ pr_debug("unregistering port %d\n", ports[i]);
++ nf_conntrack_helper_unregister(&rtsp_helpers[i]);
++ }
++ kfree(rtsp_buffer);
++}
++
++static int __init
++init(void)
++{
++ int i, ret;
++ struct nf_conntrack_helper *hlpr;
++ char *tmpname;
++
++ printk("nf_conntrack_rtsp v" IP_NF_RTSP_VERSION " loading\n");
++
++ if (max_outstanding < 1) {
++ printk("nf_conntrack_rtsp: max_outstanding must be a positive integer\n");
++ return -EBUSY;
++ }
++ if (setup_timeout < 0) {
++ printk("nf_conntrack_rtsp: setup_timeout must be a positive integer\n");
++ return -EBUSY;
++ }
++
++ rtsp_exp_policy.max_expected = max_outstanding;
++ rtsp_exp_policy.timeout = setup_timeout;
++
++ rtsp_buffer = kmalloc(65536, GFP_KERNEL);
++ if (!rtsp_buffer)
++ return -ENOMEM;
++
++ /* If no port given, default to standard rtsp port */
++ if (ports[0] == 0) {
++ ports[0] = RTSP_PORT;
++ }
++
++ for (i = 0; (i < MAX_PORTS) && ports[i]; i++) {
++ hlpr = &rtsp_helpers[i];
++ memset(hlpr, 0, sizeof(struct nf_conntrack_helper));
++ hlpr->tuple.src.l3num = AF_INET;
++ hlpr->tuple.src.u.tcp.port = htons(ports[i]);
++ hlpr->tuple.dst.protonum = IPPROTO_TCP;
++ //hlpr->mask.src.u.tcp.port = 0xFFFF;
++ //hlpr->mask.dst.protonum = 0xFF;
++ hlpr->expect_policy = &rtsp_exp_policy;
++ hlpr->me = THIS_MODULE;
++ hlpr->help = help;
++
++ tmpname = &rtsp_names[i][0];
++ if (ports[i] == RTSP_PORT) {
++ sprintf(tmpname, "rtsp");
++ } else {
++ sprintf(tmpname, "rtsp-%d", i);
++ }
++ hlpr->name = tmpname;
++
++ pr_debug("port #%d: %d\n", i, ports[i]);
++
++ ret = nf_conntrack_helper_register(hlpr);
++
++ if (ret) {
++ printk("nf_conntrack_rtsp: ERROR registering port %d\n", ports[i]);
++ fini();
++ return -EBUSY;
++ }
++ num_ports++;
++ }
++ return 0;
++}
++
++module_init(init);
++module_exit(fini);
++
++EXPORT_SYMBOL(nf_nat_rtsp_hook_expectfn);
++
+--- /dev/null
++++ b/extensions/rtsp/nf_conntrack_rtsp.h
+@@ -0,0 +1,63 @@
++/*
++ * RTSP extension for IP connection tracking.
++ * (C) 2003 by Tom Marshall <tmarshall at real.com>
++ * based on ip_conntrack_irc.h
++ *
++ * 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 of the License, or (at your option) any later version.
++ */
++#ifndef _IP_CONNTRACK_RTSP_H
++#define _IP_CONNTRACK_RTSP_H
++
++//#define IP_NF_RTSP_DEBUG 1
++#define IP_NF_RTSP_VERSION "0.6.21"
++
++#ifdef __KERNEL__
++/* port block types */
++typedef enum {
++ pb_single, /* client_port=x */
++ pb_range, /* client_port=x-y */
++ pb_discon /* client_port=x/y (rtspbis) */
++} portblock_t;
++
++/* We record seq number and length of rtsp headers here, all in host order. */
++
++/*
++ * This structure is per expected connection. It is a member of struct
++ * ip_conntrack_expect. The TCP SEQ for the conntrack expect is stored
++ * there and we are expected to only store the length of the data which
++ * needs replaced. If a packet contains multiple RTSP messages, we create
++ * one expected connection per message.
++ *
++ * We use these variables to mark the entire header block. This may seem
++ * like overkill, but the nature of RTSP requires it. A header may appear
++ * multiple times in a message. We must treat two Transport headers the
++ * same as one Transport header with two entries.
++ */
++struct ip_ct_rtsp_expect
++{
++ u_int32_t len; /* length of header block */
++ portblock_t pbtype; /* Type of port block that was requested */
++ u_int16_t loport; /* Port that was requested, low or first */
++ u_int16_t hiport; /* Port that was requested, high or second */
++#if 0
++ uint method; /* RTSP method */
++ uint cseq; /* CSeq from request */
++#endif
++};
++
++extern unsigned int (*nf_nat_rtsp_hook)(struct sk_buff *skb,
++ enum ip_conntrack_info ctinfo,
++ unsigned int matchoff, unsigned int matchlen,
++ struct ip_ct_rtsp_expect *prtspexp,
++ struct nf_conntrack_expect *exp);
++
++extern void (*nf_nat_rtsp_hook_expectfn)(struct nf_conn *ct, struct nf_conntrack_expect *exp);
++
++#define RTSP_PORT 554
++
++#endif /* __KERNEL__ */
++
++#endif /* _IP_CONNTRACK_RTSP_H */
+--- /dev/null
++++ b/extensions/rtsp/nf_nat_rtsp.c
+@@ -0,0 +1,491 @@
++/*
++ * RTSP extension for TCP NAT alteration
++ * (C) 2003 by Tom Marshall <tmarshall at real.com>
++ * based on ip_nat_irc.c
++ *
++ * 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 of the License, or (at your option) any later version.
++ *
++ * Module load syntax:
++ * insmod nf_nat_rtsp.o ports=port1,port2,...port<MAX_PORTS>
++ * stunaddr=<address>
++ * destaction=[auto|strip|none]
++ *
++ * If no ports are specified, the default will be port 554 only.
++ *
++ * stunaddr specifies the address used to detect that a client is using STUN.
++ * If this address is seen in the destination parameter, it is assumed that
++ * the client has already punched a UDP hole in the firewall, so we don't
++ * mangle the client_port. If none is specified, it is autodetected. It
++ * only needs to be set if you have multiple levels of NAT. It should be
++ * set to the external address that the STUN clients detect. Note that in
++ * this case, it will not be possible for clients to use UDP with servers
++ * between the NATs.
++ *
++ * If no destaction is specified, auto is used.
++ * destaction=auto: strip destination parameter if it is not stunaddr.
++ * destaction=strip: always strip destination parameter (not recommended).
++ * destaction=none: do not touch destination parameter (not recommended).
++ */
++
++#include <linux/module.h>
++#include <net/tcp.h>
++#include <net/netfilter/nf_nat_helper.h>
++#include <net/netfilter/nf_nat_rule.h>
++#include "nf_conntrack_rtsp.h"
++#include <net/netfilter/nf_conntrack_expect.h>
++
++#include <linux/inet.h>
++#include <linux/ctype.h>
++#define NF_NEED_STRNCASECMP
++#define NF_NEED_STRTOU16
++#include "netfilter_helpers.h"
++#define NF_NEED_MIME_NEXTLINE
++#include "netfilter_mime.h"
++
++#include "../compat_xtables.h"
++
++#define MAX_PORTS 8
++#define DSTACT_AUTO 0
++#define DSTACT_STRIP 1
++#define DSTACT_NONE 2
++
++static char* stunaddr = NULL;
++static char* destaction = NULL;
++
++static u_int32_t extip = 0;
++static int dstact = 0;
++
++MODULE_AUTHOR("Tom Marshall <tmarshall at real.com>");
++MODULE_DESCRIPTION("RTSP network address translation module");
++MODULE_LICENSE("GPL");
++module_param(stunaddr, charp, 0644);
++MODULE_PARM_DESC(stunaddr, "Address for detecting STUN");
++module_param(destaction, charp, 0644);
++MODULE_PARM_DESC(destaction, "Action for destination parameter (auto/strip/none)");
++
++#define SKIP_WSPACE(ptr,len,off) while(off < len && isspace(*(ptr+off))) { off++; }
++
++/*** helper functions ***/
++
++static void
++get_skb_tcpdata(struct sk_buff* skb, char** pptcpdata, uint* ptcpdatalen)
++{
++ struct iphdr* iph = ip_hdr(skb);
++ struct tcphdr* tcph = (void *)iph + ip_hdrlen(skb);
++
++ *pptcpdata = (char*)tcph + tcph->doff*4;
++ *ptcpdatalen = ((char*)skb_transport_header(skb) + skb->len) - *pptcpdata;
++}
++
++/*** nat functions ***/
++
++/*
++ * Mangle the "Transport:" header:
++ * - Replace all occurences of "client_port=<spec>"
++ * - Handle destination parameter
++ *
++ * In:
++ * ct, ctinfo = conntrack context
++ * skb = packet
++ * tranoff = Transport header offset from TCP data
++ * tranlen = Transport header length (incl. CRLF)
++ * rport_lo = replacement low port (host endian)
++ * rport_hi = replacement high port (host endian)
++ *
++ * Returns packet size difference.
++ *
++ * Assumes that a complete transport header is present, ending with CR or LF
++ */
++static int
++rtsp_mangle_tran(enum ip_conntrack_info ctinfo,
++ struct nf_conntrack_expect* exp,
++ struct ip_ct_rtsp_expect* prtspexp,
++ struct sk_buff* skb, uint tranoff, uint tranlen)
++{
++ char* ptcp;
++ uint tcplen;
++ char* ptran;
++ char rbuf1[16]; /* Replacement buffer (one port) */
++ uint rbuf1len; /* Replacement len (one port) */
++ char rbufa[16]; /* Replacement buffer (all ports) */
++ uint rbufalen; /* Replacement len (all ports) */
++ u_int32_t newip;
++ u_int16_t loport, hiport;
++ uint off = 0;
++ uint diff; /* Number of bytes we removed */
++
++ struct nf_conn *ct = exp->master;
++ struct nf_conntrack_tuple *t;
++
++ char szextaddr[15+1];
++ uint extaddrlen;
++ int is_stun;
++
++ get_skb_tcpdata(skb, &ptcp, &tcplen);
++ ptran = ptcp+tranoff;
++
++ if (tranoff+tranlen > tcplen || tcplen-tranoff < tranlen ||
++ tranlen < 10 || !iseol(ptran[tranlen-1]) ||
++ nf_strncasecmp(ptran, "Transport:", 10) != 0)
++ {
++ pr_info("sanity check failed\n");
++ return 0;
++ }
++ off += 10;
++ SKIP_WSPACE(ptcp+tranoff, tranlen, off);
++
++ newip = ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u3.ip;
++ t = &exp->tuple;
++ t->dst.u3.ip = newip;
++
++ extaddrlen = extip ? sprintf(szextaddr, "%pI4", &extip)
++ : sprintf(szextaddr, "%pI4", &newip);
++ pr_debug("stunaddr=%s (%s)\n", szextaddr, (extip?"forced":"auto"));
++
++ rbuf1len = rbufalen = 0;
++ switch (prtspexp->pbtype)
++ {
++ case pb_single:
++ for (loport = prtspexp->loport; loport != 0; loport++) /* XXX: improper wrap? */
++ {
++ t->dst.u.udp.port = htons(loport);
++ if (nf_ct_expect_related(exp) == 0)
++ {
++ pr_debug("using port %hu\n", loport);
++ break;
++ }
++ }
++ if (loport != 0)
++ {
++ rbuf1len = sprintf(rbuf1, "%hu", loport);
++ rbufalen = sprintf(rbufa, "%hu", loport);
++ }
++ break;
++ case pb_range:
++ for (loport = prtspexp->loport; loport != 0; loport += 2) /* XXX: improper wrap? */
++ {
++ t->dst.u.udp.port = htons(loport);
++ if (nf_ct_expect_related(exp) == 0)
++ {
++ hiport = loport + 1; //~exp->mask.dst.u.udp.port;
++ pr_debug("using ports %hu-%hu\n", loport, hiport);
++ break;
++ }
++ }
++ if (loport != 0)
++ {
++ rbuf1len = sprintf(rbuf1, "%hu", loport);
++ rbufalen = sprintf(rbufa, "%hu-%hu", loport, loport+1);
++ }
++ break;
++ case pb_discon:
++ for (loport = prtspexp->loport; loport != 0; loport++) /* XXX: improper wrap? */
++ {
++ t->dst.u.udp.port = htons(loport);
++ if (nf_ct_expect_related(exp) == 0)
++ {
++ pr_debug("using port %hu (1 of 2)\n", loport);
++ break;
++ }
++ }
++ for (hiport = prtspexp->hiport; hiport != 0; hiport++) /* XXX: improper wrap? */
++ {
++ t->dst.u.udp.port = htons(hiport);
++ if (nf_ct_expect_related(exp) == 0)
++ {
++ pr_debug("using port %hu (2 of 2)\n", hiport);
++ break;
++ }
++ }
++ if (loport != 0 && hiport != 0)
++ {
++ rbuf1len = sprintf(rbuf1, "%hu", loport);
++ if (hiport == loport+1)
++ {
++ rbufalen = sprintf(rbufa, "%hu-%hu", loport, hiport);
++ }
++ else
++ {
++ rbufalen = sprintf(rbufa, "%hu/%hu", loport, hiport);
++ }
++ }
++ break;
++ }
++
++ if (rbuf1len == 0)
++ {
++ return 0; /* cannot get replacement port(s) */
++ }
++
++ /* Transport: tran;field;field=val,tran;field;field=val,... */
++ while (off < tranlen)
++ {
++ uint saveoff;
++ const char* pparamend;
++ uint nextparamoff;
++
++ pparamend = memchr(ptran+off, ',', tranlen-off);
++ pparamend = (pparamend == NULL) ? ptran+tranlen : pparamend+1;
++ nextparamoff = pparamend-ptcp;
++
++ /*
++ * We pass over each param twice. On the first pass, we look for a
++ * destination= field. It is handled by the security policy. If it
++ * is present, allowed, and equal to our external address, we assume
++ * that STUN is being used and we leave the client_port= field alone.
++ */
++ is_stun = 0;
++ saveoff = off;
++ while (off < nextparamoff)
++ {
++ const char* pfieldend;
++ uint nextfieldoff;
++
++ pfieldend = memchr(ptran+off, ';', nextparamoff-off);
++ nextfieldoff = (pfieldend == NULL) ? nextparamoff : pfieldend-ptran+1;
++
++ if (dstact != DSTACT_NONE && strncmp(ptran+off, "destination=", 12) == 0)
++ {
++ if (strncmp(ptran+off+12, szextaddr, extaddrlen) == 0)
++ {
++ is_stun = 1;
++ }
++ if (dstact == DSTACT_STRIP || (dstact == DSTACT_AUTO && !is_stun))
++ {
++ diff = nextfieldoff-off;
++ if (!nf_nat_mangle_tcp_packet(skb, ct, ctinfo,
++ off, diff, NULL, 0))
++ {
++ /* mangle failed, all we can do is bail */
++ nf_ct_unexpect_related(exp);
++ return 0;
++ }
++ get_skb_tcpdata(skb, &ptcp, &tcplen);
++ ptran = ptcp+tranoff;
++ tranlen -= diff;
++ nextparamoff -= diff;
++ nextfieldoff -= diff;
++ }
++ }
++
++ off = nextfieldoff;
++ }
++ if (is_stun)
++ {
++ continue;
++ }
++ off = saveoff;
++ while (off < nextparamoff)
++ {
++ const char* pfieldend;
++ uint nextfieldoff;
++
++ pfieldend = memchr(ptran+off, ';', nextparamoff-off);
++ nextfieldoff = (pfieldend == NULL) ? nextparamoff : pfieldend-ptran+1;
++
++ if (strncmp(ptran+off, "client_port=", 12) == 0)
++ {
++ u_int16_t port;
++ uint numlen;
++ uint origoff;
++ uint origlen;
++ char* rbuf = rbuf1;
++ uint rbuflen = rbuf1len;
++
++ off += 12;
++ origoff = (ptran-ptcp)+off;
++ origlen = 0;
++ numlen = nf_strtou16(ptran+off, &port);
++ off += numlen;
++ origlen += numlen;
++ if (port != prtspexp->loport)
++ {
++ pr_debug("multiple ports found, port %hu ignored\n", port);
++ }
++ else
++ {
++ if (ptran[off] == '-' || ptran[off] == '/')
++ {
++ off++;
++ origlen++;
++ numlen = nf_strtou16(ptran+off, &port);
++ off += numlen;
++ origlen += numlen;
++ rbuf = rbufa;
++ rbuflen = rbufalen;
++ }
++
++ /*
++ * note we cannot just memcpy() if the sizes are the same.
++ * the mangle function does skb resizing, checks for a
++ * cloned skb, and updates the checksums.
++ *
++ * parameter 4 below is offset from start of tcp data.
++ */
++ diff = origlen-rbuflen;
++ if (!nf_nat_mangle_tcp_packet(skb, ct, ctinfo,
++ origoff, origlen, rbuf, rbuflen))
++ {
++ /* mangle failed, all we can do is bail */
++ nf_ct_unexpect_related(exp);
++ return 0;
++ }
++ get_skb_tcpdata(skb, &ptcp, &tcplen);
++ ptran = ptcp+tranoff;
++ tranlen -= diff;
++ nextparamoff -= diff;
++ nextfieldoff -= diff;
++ }
++ }
++
++ off = nextfieldoff;
++ }
++
++ off = nextparamoff;
++ }
++
++ return 1;
++}
++
++static uint
++help_out(struct sk_buff *skb, enum ip_conntrack_info ctinfo,
++ unsigned int matchoff, unsigned int matchlen, struct ip_ct_rtsp_expect* prtspexp,
++ struct nf_conntrack_expect* exp)
++{
++ char* ptcp;
++ uint tcplen;
++ uint hdrsoff;
++ uint hdrslen;
++ uint lineoff;
++ uint linelen;
++ uint off;
++
++ //struct iphdr* iph = (struct iphdr*)(*pskb)->nh.iph;
++ //struct tcphdr* tcph = (struct tcphdr*)((void*)iph + iph->ihl*4);
++
++ get_skb_tcpdata(skb, &ptcp, &tcplen);
++ hdrsoff = matchoff;//exp->seq - ntohl(tcph->seq);
++ hdrslen = matchlen;
++ off = hdrsoff;
++ pr_debug("NAT rtsp help_out\n");
++
++ while (nf_mime_nextline(ptcp, hdrsoff+hdrslen, &off, &lineoff, &linelen))
++ {
++ if (linelen == 0)
++ {
++ break;
++ }
++ if (off > hdrsoff+hdrslen)
++ {
++ pr_info("!! overrun !!");
++ break;
++ }
++ pr_debug("hdr: len=%u, %.*s", linelen, (int)linelen, ptcp+lineoff);
++
++ if (nf_strncasecmp(ptcp+lineoff, "Transport:", 10) == 0)
++ {
++ uint oldtcplen = tcplen;
++ pr_debug("hdr: Transport\n");
++ if (!rtsp_mangle_tran(ctinfo, exp, prtspexp, skb, lineoff, linelen))
++ {
++ pr_debug("hdr: Transport mangle failed");
++ break;
++ }
++ get_skb_tcpdata(skb, &ptcp, &tcplen);
++ hdrslen -= (oldtcplen-tcplen);
++ off -= (oldtcplen-tcplen);
++ lineoff -= (oldtcplen-tcplen);
++ linelen -= (oldtcplen-tcplen);
++ pr_debug("rep: len=%u, %.*s", linelen, (int)linelen, ptcp+lineoff);
++ }
++ }
++
++ return NF_ACCEPT;
++}
++
++static unsigned int
++help(struct sk_buff *skb, enum ip_conntrack_info ctinfo,
++ unsigned int matchoff, unsigned int matchlen, struct ip_ct_rtsp_expect* prtspexp,
++ struct nf_conntrack_expect* exp)
++{
++ int dir = CTINFO2DIR(ctinfo);
++ int rc = NF_ACCEPT;
++
++ switch (dir)
++ {
++ case IP_CT_DIR_ORIGINAL:
++ rc = help_out(skb, ctinfo, matchoff, matchlen, prtspexp, exp);
++ break;
++ case IP_CT_DIR_REPLY:
++ pr_debug("unmangle ! %u\n", ctinfo);
++ /* XXX: unmangle */
++ rc = NF_ACCEPT;
++ break;
++ }
++ //UNLOCK_BH(&ip_rtsp_lock);
++
++ return rc;
++}
++
++static void expected(struct nf_conn* ct, struct nf_conntrack_expect *exp)
++{
++ struct nf_nat_ipv4_multi_range_compat mr;
++ u_int32_t newdstip, newsrcip, newip;
++
++ struct nf_conn *master = ct->master;
++
++ newdstip = master->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u3.ip;
++ newsrcip = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u3.ip;
++ //FIXME (how to port that ?)
++ //code from 2.4 : newip = (HOOK2MANIP(hooknum) == NF_NAT_MANIP_SRC) ? newsrcip : newdstip;
++ newip = newdstip;
++
++ pr_debug("newsrcip=%pI4, newdstip=%pI4, newip=%pI4\n",
++ &newsrcip, &newdstip, &newip);
++
++ mr.rangesize = 1;
++ // We don't want to manip the per-protocol, just the IPs.
++ mr.range[0].flags = NF_NAT_RANGE_MAP_IPS;
++ mr.range[0].min_ip = mr.range[0].max_ip = newip;
++
++ nf_nat_setup_info(ct, &mr.range[0], NF_NAT_MANIP_DST);
++}
++
++
++static void __exit fini(void)
++{
++ nf_nat_rtsp_hook = NULL;
++ nf_nat_rtsp_hook_expectfn = NULL;
++ synchronize_net();
++}
++
++static int __init init(void)
++{
++ printk("nf_nat_rtsp v" IP_NF_RTSP_VERSION " loading\n");
++
++ BUG_ON(nf_nat_rtsp_hook);
++ nf_nat_rtsp_hook = help;
++ nf_nat_rtsp_hook_expectfn = &expected;
++
++ if (stunaddr != NULL)
++ extip = in_aton(stunaddr);
++
++ if (destaction != NULL) {
++ if (strcmp(destaction, "auto") == 0)
++ dstact = DSTACT_AUTO;
++
++ if (strcmp(destaction, "strip") == 0)
++ dstact = DSTACT_STRIP;
++
++ if (strcmp(destaction, "none") == 0)
++ dstact = DSTACT_NONE;
++ }
++
++ return 0;
++}
++
++module_init(init);
++module_exit(fini);
+--- a/extensions/Kbuild
++++ b/extensions/Kbuild
+@@ -35,6 +35,7 @@ obj-${build_lscan} += xt_lscan.o
+ obj-${build_pknock} += pknock/
+ obj-${build_psd} += xt_psd.o
+ obj-${build_quota2} += xt_quota2.o
++obj-${build_rtsp} += rtsp/
+
+ -include ${M}/*.Kbuild
+ -include ${M}/Kbuild.*
+--- a/mconfig
++++ b/mconfig
+@@ -26,3 +26,4 @@ build_lscan=m
+ build_pknock=m
+ build_psd=m
+ build_quota2=m
++build_rtsp=m
diff --git a/package/network/utils/xtables-addons/patches-1.x/101-rtsp-linux-3.6-compat.patch b/package/network/utils/xtables-addons/patches-1.x/101-rtsp-linux-3.6-compat.patch
new file mode 100644
index 0000000..b8e08b3
--- /dev/null
+++ b/package/network/utils/xtables-addons/patches-1.x/101-rtsp-linux-3.6-compat.patch
@@ -0,0 +1,22 @@
+--- a/extensions/rtsp/nf_conntrack_rtsp.c
++++ b/extensions/rtsp/nf_conntrack_rtsp.c
+@@ -28,6 +28,7 @@
+ * - Port to new NF API
+ */
+
++#include <linux/version.h>
+ #include <linux/module.h>
+ #include <linux/netfilter.h>
+ #include <linux/ip.h>
+@@ -496,7 +497,11 @@ init(void)
+ } else {
+ sprintf(tmpname, "rtsp-%d", i);
+ }
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)
++ strncpy(hlpr->name, tmpname, sizeof(hlpr->name));
++#else
+ hlpr->name = tmpname;
++#endif
+
+ pr_debug("port #%d: %d\n", i, ports[i]);
+
diff --git a/package/network/utils/xtables-addons/patches-1.x/200-add-lua-packetscript.patch b/package/network/utils/xtables-addons/patches-1.x/200-add-lua-packetscript.patch
new file mode 100644
index 0000000..1717bf5
--- /dev/null
+++ b/package/network/utils/xtables-addons/patches-1.x/200-add-lua-packetscript.patch
@@ -0,0 +1,18230 @@
+--- /dev/null
++++ b/extensions/LUA/byte_array.c
+@@ -0,0 +1,145 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre@dergraf.org>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++#include "controller.h"
++
++/* Initialization helper function. This function should be used whenever
++ * a new byte array need to be initialized. Depending on the arguments it
++ * initializes the array in a different way. Have a look at the inline
++ * comments */
++lua_packet_segment * init_byte_array(lua_State *L, unsigned char * start, int length, int do_copy)
++{
++ lua_packet_segment *array;
++
++ if (length < 0)
++ luaL_error(L, "init_byte_array, requested size < 0");
++
++ if (start && do_copy) {
++ /* we have a start address where we copy from */
++ array = lua_newuserdata(L, sizeof(lua_packet_segment) + length);
++ array->start = (unsigned char *)array + sizeof(lua_packet_segment); /* aligning pointer */
++ memcpy(array->start, start, length);
++ }else if (start && !do_copy) {
++ /* just link the start pointer, in this case you have to free the memory yourself */
++ array = lua_newuserdata(L, sizeof(lua_packet_segment));
++ array->start = start;
++ }else{
++ /* create an empty array, fully managed by Lua */
++ array = lua_newuserdata(L, sizeof(lua_packet_segment) + length);
++ array->start = (unsigned char *)array + sizeof(lua_packet_segment); /* aligning pointer */
++ memset(array->start, 0, length);
++ }
++
++ array->length = length;
++ array->offset = 0;
++ array->changes = NULL;
++
++ luaL_getmetatable(L, LUA_BYTE_ARRAY);
++ lua_setmetatable(L, -2);
++
++ return array;
++}
++
++
++
++/* LUA_API: get one byte of the given byte array
++ * access-pattern: array[<index>] */
++static int32_t get_byte_array(lua_State *L)
++{
++ lua_packet_segment * array = checkbytearray(L, 1);
++ int32_t index = luaL_checkinteger(L, 2); /* array starts with index 0 (not 1 as usual in Lua) */
++
++ luaL_argcheck(L, 0 <= index && index < array->length, 1, "index out of range");
++ lua_pushinteger(L, (array->start + array->offset)[index]);
++
++ return 1;
++}
++
++/* LUA_API: set one byte of the given byte array
++ * access-pattern: array[<index>]= 0xFF */
++static int32_t set_byte_array(lua_State *L)
++{
++ lua_packet_segment * array = checkbytearray(L, 1);
++ uint8_t byte;
++ int32_t index = luaL_checkinteger(L, 2); /* array starts with index 0 (not 1 as usual in Lua) */
++ int32_t val = luaL_checkinteger(L, 3);
++ uint32_t nob = 1 << CHAR_BIT; /* we should use something like 1 << CHAR_BIT */
++
++ luaL_argcheck(L, 0 <= index && index < array->length, 1, "index out of range");
++ luaL_argcheck(L, 0 <= val && val < nob, 2, "cannot cast value to char");
++
++ byte = (uint8_t)val;
++
++ (array->start + array->offset)[index] = byte;
++
++ return 0;
++}
++
++/* LUA_API: get size of the given byte array
++ * access-pattern: #array (__length meta-method) */
++static int32_t get_byte_array_size(lua_State *L)
++{
++ lua_packet_segment * array = checkbytearray(L, 1);
++
++ lua_pushnumber(L, array->length);
++
++ return 1;
++}
++
++
++/* LUA_API: converts a given byte array to a string.
++ * access-pattern: implicit through functions calling the
++ * __to_string() metamethod , e.g. print32_t */
++static int32_t byte_array_to_string(lua_State *L)
++{
++ lua_packet_segment * array = checkbytearray(L, 1);
++ uint8_t buf[(array->length * 3) + 255];
++ uint8_t hexval[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
++ char res[255 + (array->length * 3)]; /* make sure the buffer is big enough*/
++ int32_t i, n;
++ uint8_t *ptr = array->start + array->offset;
++
++ for (i = 0; i < array->length; i++) {
++ buf[i * 3] = hexval[(ptr[i] >> 4) & 0xF];
++ buf[(i * 3) + 1] = hexval[ptr[i] & 0x0F];
++ buf[(i * 3) + 2] = ' '; /* seperator */
++ }
++
++ buf[array->length * 3] = '\0';
++ n = sprintf(res, "byte_array: length: %d value: %s", array->length, buf);
++
++ lua_pushlstring(L, res, n);
++
++ return 1;
++}
++
++static const struct luaL_Reg bytearray_lib_m [] = {
++ { "__len", get_byte_array_size },
++ { "__newindex", set_byte_array },
++ { "__index", get_byte_array },
++ { "__tostring", byte_array_to_string },
++ { NULL, NULL }
++};
++
++void luaopen_bytearraylib(lua_State *L)
++{
++ luaL_newmetatable(L, LUA_BYTE_ARRAY);
++ luaL_register(L, NULL, bytearray_lib_m);
++ lua_pop(L, 1);
++}
++
++
+--- /dev/null
++++ b/extensions/LUA/controller.c
+@@ -0,0 +1,604 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre@dergraf.org>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++
++#if defined(__KERNEL__)
++ #include <linux/mm.h>
++#endif
++#include "controller.h"
++
++/* the array 'supported_protocols' holds all pointers to the
++ * static and dynamic protocol buffers. It is filled by the
++ * call to register_protbuf */
++static struct protocol_buf * supported_protocols[MAX_NR_OF_PROTOCOLS];
++
++/* C_API: the function 'get_protocol_buf' returns the pointer
++ * to the protocol buffer of a given protocol id. */
++struct protocol_buf * get_protocol_buf(uint32_t protocol_id)
++{
++ return (struct protocol_buf *)supported_protocols[protocol_id];
++}
++
++
++/* LUA_INT: the function 'gc_packet_segment' is triggered by the
++ * garbage collector whenever a userdata annotated with one of
++ * the protocol buffer metatable should be collected. */
++static int32_t gc_packet_segment(lua_State *L)
++{
++ lua_packet_segment * seg = (lua_packet_segment *)lua_touserdata(L, 1);
++ if (seg && seg->changes) {
++ seg->changes->ref_count--;
++ if (seg->changes->ref_count <= 0) {
++ kfree(seg->changes->field_length_changes);
++ kfree(seg->changes->field_offset_changes);
++ kfree(seg->changes);
++ seg->changes = NULL;
++ }
++ }
++ return 0;
++}
++
++
++/* LUA_API: the function 'set_raw' is used to set the bytes of a segment
++ * in 'raw' mode. The function is per default available in each protocol
++ * buffer until it gets overridden by a specific setter function inside
++ * a protocol buffer.
++ *
++ * Parameters:
++ * 1. lua_packet_segment (implicit)
++ * 2. int32_t byte_value
++ *
++ * Upvalues:
++ * 1. struct protocol_buf*
++ * 2. int32_t field index, not used in this function
++ *
++ * Return: void
++ */
++static int32_t set_raw(lua_State *L)
++{
++ int32_t i;
++ uint32_t nob;
++ uint8_t byte;
++ uint8_t *ptr;
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ int32_t val = luaL_checkinteger(L, 2);
++
++ nob = 1 << CHAR_BIT;
++
++ luaL_argcheck(L, 0 <= val && val < nob, 2, "cannot cast value to char");
++
++ byte = (uint8_t)val;
++ ptr = seg->start + seg->offset;
++
++ for (i = 0; i < seg->length; i++)
++ ptr[i] = byte;
++
++ return 0;
++}
++
++/* LUA_API: the function 'get_raw' is used to get the bytes of a segment
++ * in 'raw' mode. The function is per default available in each protocol
++ * buffer until it gets overridden by a specific getter function inside
++ * a protocol buffer.
++ *
++ * Parameters:
++ * 1. lua_packet_segment (implicit)
++ * 2. uint32_t offset
++ * 3. uint32_t length
++ *
++ * Upvalues:
++ * 1. struct protocol_buf*
++ * 2. int32_t field index, not used in this function
++ *
++ * Return:
++ * the byte array representing the given array
++ */
++static int32_t get_raw(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ init_byte_array(L, seg->start + seg->offset, seg->length, 1);
++
++ return 1;
++}
++/* LUA_API: The function 'get_segment' is used to get a new segment in 'raw' mode.
++ * Typically this function is applied on another raw segment in order
++ * to extract a part of the segment as new segment.
++ *
++ * Parameters:
++ * 1. lua_packet_segment, implicit through object oriented access seg:raw(..)
++ * 2. uint32_t offset, this indicates where to start the new segment, see e.g below.
++ * 3. uint32_t length, this indicates the size of the new segment
++ *
++ * Upvalues:
++ * 1. struct protocol_buf*
++ * 2. int32_t field index, not used in this function
++ *
++ * Return:
++ * 1. A lua_packet_segment annotated with the according metatable or False in
++ * case the input data is not valid
++ *
++ * Example:
++ *
++ * +------------------------+---------------------------------------+
++ * | function call | resulting lua_packet_segment |
++ * +========================+===+===+===+===+===+===+===+===+===+===+
++ * | seg = packet:raw(0,10) | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
++ * +------------------------+---+---+---+---+---+---+---+---+---+---+
++ * | 1st_half = seg:raw(0,5)| 0 | 1 | 2 | 3 | 4 | |
++ * +------------------------+---+---+---+---+---+---+---+---+---+---+
++ * | 2nd_half = seg:raw(5,5)| | 5 | 6 | 7 | 8 | 9 |
++ * +------------------------+-------------------+---+---+---+---+---+
++ */
++static int32_t get_segment(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++ uint32_t offset = luaL_checkinteger(L, 2);
++ uint32_t length = luaL_checkinteger(L, 3);
++ lua_packet_segment * new = (lua_packet_segment *)lua_newuserdata(L, sizeof(lua_packet_segment));
++
++ new->start = seg->start;
++ new->offset = seg->offset + offset;
++ new->changes = NULL;
++ /* we allow a seg->length == 0 , this enables processing packets where the packetsize is not fixed (0 = not fixed)*/
++ if (seg->length != 0 && length > seg->length) {
++ lua_pushboolean(L, 0);
++ return 1;
++ }
++
++ new->length = length;
++ luaL_getmetatable(L, prot_buf->name);
++ lua_setmetatable(L, -2);
++
++ return 1;
++}
++
++/* LUA_API: the function 'get_segment_size' is used to get the size of a segment.
++ *
++ * Parameters:
++ * 1. lua_packet_segment, implicit through object oriented access seg:raw(..)
++ *
++ * Upvalues:
++ * 1. struct protocol_buf*
++ * 2. int32_t field index, not used in this function
++ *
++ * Return:
++ * 1. Size as lua_Number
++ */
++static int32_t get_segment_size(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ lua_pushnumber(L, seg->length);
++ return 1;
++}
++
++/* LUA_API: the function 'get_segment_offset' is used to get the real offset
++ * of a segment. This function returns the offset of the segment to the start
++ * of the buffer. This means the following
++ * seg1 = packet:raw(2,10)
++ * seg2 = seg1:raw(3,5)
++ * offset = seg2:get_offset()
++ *
++ * will give an offset of 5, since the seg1 starts at offset 2, and seg2 starts
++ * at offset (seg1:get_offset() + 3).
++ *
++ * Parameters:
++ * 1. lua_packet_segment, implicit through object oriented access seg:raw(..)
++ *
++ * Upvalues:
++ * 1. struct protocol_buf*
++ * 2. int32_t field index, not used in this function
++ *
++ * Return:
++ * 1. Offset as lua_Number
++ */
++static int32_t get_segment_offset(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ lua_pushnumber(L, seg->offset);
++ return 1;
++}
++
++/* LUA_API: overwrites the __tostring function of a lua_packet_segment.
++ * this will print32_t a nicely formated string, including length,
++ * offset and name of the protocol buffer.
++ *
++ * Parameters:
++ * 1. lua_packet_segment (implicit)
++ *
++ * Returns:
++ * 1. the representing string
++ */
++static int32_t packet_segment_tostring(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++ int32_t n;
++ char buf[128];
++
++ n = sprintf(buf, "type: %s, offset: %d, length: %d", prot_buf->name, seg->offset, seg->length);
++ lua_pushlstring(L, buf, n);
++
++ return 1;
++}
++
++
++static const struct luaL_Reg seg_access_functions [] = {
++ { "set", set_raw },
++ { "get", get_raw },
++ { "raw", get_segment },
++ { "get_offset", get_segment_offset },
++ { "get_size", get_segment_size },
++ { "to_bytes", get_raw },
++ { "__tostring", packet_segment_tostring },
++ { "__gc", gc_packet_segment },
++ { NULL, NULL }
++};
++
++/* C_API: the function 'get_metatable_from_protocol_type' is a helper
++ * used in controller.c as well as it may find usage in the static
++ * protocol buffers and byte array implementation. */
++void get_metatable_from_protocol_type(lua_State *L, int32_t type)
++{
++ char * table;
++ lua_getglobal(L, SUPPORTED_PROTOCOL_TABLE);
++ lua_rawgeti(L, -1, type);
++ table = (char *)luaL_checkstring(L, -1);
++ lua_pop(L, 2); /* pop the table SUPPORTED_PROTOCOL_TABLE and the string pushed by lua_gettable */
++ luaL_getmetatable(L, table);
++ return;
++}
++
++/* C_INT: the function 'payload_contains_protocol' is used internally.
++ * Depending if static or dynamic protocol buffer it calls the right
++ * validation function. */
++static int32_t payload_contains_protocol(lua_State *L, struct protocol_buf *prot_buf, lua_packet_segment *seg, uint32_t prot_type)
++{
++ if (prot_buf->is_dynamic)
++ return has_protocol_dynamic(L, prot_buf, seg, prot_type);
++ else
++ return prot_buf->has_protocol(L, prot_buf, seg, prot_type);
++}
++
++/* C_INT: the function 'protocol_get_field_changes' is used interally.
++ * It requests the field_changes struct calling the protocol buffers
++ * 'get_field_changes' function. This funciton is called, whenever
++ * the payload field with a given protocol type is requested inside
++ * the function 'get_protocol_field' */
++static struct field_changes * protocol_get_field_changes(lua_State *L, struct protocol_buf *prot_buf, lua_packet_segment * seg)
++{
++ struct field_changes * changes = NULL;
++
++ if (prot_buf->get_field_changes) {
++ if (prot_buf->is_dynamic)
++ changes = get_field_changes_dynamic(L, prot_buf, seg);
++ else
++ changes = prot_buf->get_field_changes(L, seg);
++ /* is already 1 when set by helper 'get_allocated_field_changes,
++ * since not every prot_buf may use this function we enforce it. */
++ changes->ref_count = 1;
++ }
++ return changes;
++}
++
++/* C_INT: the function 'get_field_offset_in_bytes' wrapps the logic of
++ * calculating the new length with considering the optional field_changes. */
++static int32_t get_field_offset_in_bytes(struct protocol_field * field, lua_packet_segment * seg, int32_t field_index)
++{
++ uint32_t nr_of_bits, nr_of_bytes, field_offset;
++
++ field_offset = field->offset;
++ /* do we need to manipulate the default values stored inside the protocol buffer ?? */
++ if (seg->changes)
++ field_offset += seg->changes->field_offset_changes[field_index];
++ /* how many bits remain */
++ nr_of_bits = field_offset & (CHAR_BIT - 1);
++ /* assuming CHAR_BIT == 2 ^ 3 */
++ nr_of_bytes = (field_offset - nr_of_bits) >> 3;
++
++ return seg->offset + nr_of_bytes;
++}
++
++/* C_INT: the function 'get_field_length_in_bytes' wrapps the logic of
++ * calculating the new offset with considering the optional field_changes. */
++static int32_t get_field_length_in_bytes(struct protocol_field * field, lua_packet_segment * seg, int32_t field_index)
++{
++ uint32_t nr_of_bits, nr_of_bytes, field_length;
++
++ field_length = field->length;
++ /* if the field length is smaller than 1 byte, we take the size of one byte
++ * we treat the case where field_length == 0 in a special way ...*/
++ if (field_length < CHAR_BIT && field_length > 0)
++ field_length = CHAR_BIT;
++
++ /* do we need to manipulate the default values stored inside the protocol buffer ?? */
++ if (seg->changes)
++ field_length += seg->changes->field_length_changes[field_index];
++ /* how many bits remain */
++ nr_of_bits = field_length & (CHAR_BIT - 1);
++ /* assuming CHAR_BIT == 2 ^ 3 */
++ nr_of_bytes = (field_length - nr_of_bits) >> 3;
++ return nr_of_bytes;
++}
++
++/* C_INT: the function 'initialize_field_getter_and_setter' initializes
++ * the setter and getter function of the field, considering the optional
++ * field manipulator functions defined inside the protocol buffers. */
++static void initialize_field_getter_and_setter(lua_State *L, struct protocol_buf *prot_buf, int32_t field_index)
++{
++ /* lets check if there is a metatable on top of the stack */
++ struct protocol_field * f = (struct protocol_field *)&prot_buf->protocol_fields[field_index];
++
++ if (!lua_istable(L, -1)) luaL_error(L, "cannot initialize getter and setter for field %s->%s, "
++ "not a table on top of the stack, is '%s'", prot_buf->name, f->name, lua_typename(L, lua_type(L, -1)));
++
++ /* is there a 'getter' to initialize ? */
++ lua_pushlightuserdata(L, prot_buf); /* push upvalue 1 */
++ lua_pushinteger(L, field_index); /* push upvalue 2 */
++ if (f->get) {
++ if (prot_buf->is_dynamic)
++ lua_pushcclosure(L, field_dynamic_getter, 2);
++ else
++ lua_pushcclosure(L, f->get, 2);
++ }else
++ /* there is no specific getter defined - fall back to 'get_raw' */
++ lua_pushcclosure(L, get_raw, 2);
++ /* set the metatable field 'get' */
++ lua_setfield(L, -2, "get");
++
++ /* is there a 'setter' to initialize ? */
++ lua_pushlightuserdata(L, prot_buf); /* push upvalue 1 */
++ lua_pushinteger(L, field_index); /* push upvalue 2 */
++ if (f->set) {
++ if (prot_buf->is_dynamic)
++ lua_pushcclosure(L, field_dynamic_setter, 2);
++ else
++ lua_pushcclosure(L, f->set, 2);
++ }else
++ /* there is no specific setter defined - fall back to 'set_raw' */
++ lua_pushcclosure(L, set_raw, 2);
++ /* set the metatable field 'set' */
++ lua_setfield(L, -2, "set");
++}
++
++/* LUA_API: 'get_protocol_field' is used in Lua as a closure for each field of a protocol
++ * buffer. E.g a call to ip = packet:data(packet_ip) will go to this function,
++ * and trigger the conversion of the raw packet to a ip packet. Each call
++ * to a field function of an IP packet, like ip:daddr() uses this function
++ * to to return the right data. In each case you will end up either with a
++ * new packet segment (annotated with the proper metatable) or a boolean
++ * value (False) if something went wrong. In the case everything went fine,
++ * the newly created lua_packet_segment is annotated with the proper
++ * metatable where the fields get and set also contain the specific getter
++ * and setter functions given by the protocol buffer. E.g. the function call
++ * ip:daddr():get() or ip:daddr():set(...) will call the proper function
++ * defined inside the corresponding field definition.
++ *
++ * Parameters:
++ * 1. lua_packet_segment, implicit through object oriented access seg:raw(..)
++ * 2. type of the protocol buffer, optional, and only used if the accessed
++ * field is the payload field. If a type is provided for the access of the
++ * payload field, the function tries to convert the data pointed to by the
++ * payload field to the given type. To check if such a conversion is
++ * possible, it calls the function pointed to by the protocol buffer member
++ * has_protocol. If this function returns True, the conversion takes place.
++ *
++ * Upvalues:
++ * 1. struct protocol_buf*
++ * 2. int32_t field index
++ *
++ * Return:
++ * 1. A lua_packet_segment annotated with the according metatable or False in
++ * case the input data is not valid
++ */
++static int32_t get_protocol_field(lua_State *L)
++{
++ int32_t prot_type;
++ lua_packet_segment * seg, *new;
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ int32_t field_index = lua_tointeger(L, lua_upvalueindex(2));
++ struct protocol_field * field = &prot_buf->protocol_fields[field_index];
++
++ /* get the current packet segment */
++ seg = checkpacketseg(L, 1, prot_buf->name);
++
++ /* initialize the new packet segment */
++ new = (lua_packet_segment *)lua_newuserdata(L, sizeof(lua_packet_segment));
++ new->start = seg->start; /* the start is unchanged */
++ new->offset = get_field_offset_in_bytes(field, seg, field_index);
++ new->length = get_field_length_in_bytes(field, seg, field_index);
++
++ /* if new->length == 0 then no configuration was done, we guess the size by subtracting the
++ * new offset from the packet length. since the old length is getting initialized by the
++ * netfilter extension this assumption holds for the very last field of the protocol.
++ * this 'feature' should be used by protocol buffers containing a payload, whereas the
++ * payload field is the last field of the buffer. However, at compile-time unknown field
++ * sizes (and offsets) of fields not being placed at the end of the protocol should be
++ * initialized using the 'get_field_changes' hook system. */
++ if (new->length == 0)
++ new->length = (seg->length + seg->offset) - (new->offset);
++ /*
++ printf("%s->%s:: seg->offset %i, seg->length %i, new->offset %i, new->length %i\n",
++ prot_buf->name, field->name, seg->offset, seg->length, new->offset, new->length);
++ */
++ /* special care for packet payload requests */
++ if (prot_buf->payload_field != NULL && strcmp(prot_buf->payload_field, field->name) == 0) {
++ /* we know the payload field is requested */
++ /* the requested payload can be delivered either as a common segment or as
++ * an other packet type, such a conversion needs an extra protocol parameter
++ * ... so lets check */
++
++ if (lua_isnumber(L, 2)) {
++ /* we have an extra parameter, ... lets see if it is a valid protocol
++ * the parameter is the index of the 'supported_protocols'-array member */
++ prot_type = lua_tointeger(L, 2);
++ if (prot_type >= 0 && prot_type < PACKET_SENTINEL) {
++ /* we are sure the purpose of the request is to get the payload data,
++ * converted to the given protocol. lets check if the payload contains
++ * data of the given protocol */
++ if (payload_contains_protocol(L, prot_buf, seg, prot_type)) {
++ /* success, we can push the metatable for the given protocol */
++ get_metatable_from_protocol_type(L, prot_type);
++ if (!lua_isnil(L, -1)) /* check if the metatable was found */
++ /* perhaps the field offsets and lengths of the containing protocol
++ * are not set correctly. request the optional 'field_changes' structure
++ * holding the changes for lengths and offsets. */
++ new->changes = protocol_get_field_changes(L, get_protocol_buf(prot_type), new);
++ else{
++ /* failed, the requested protocol is not available
++ * we push false and return */
++ lua_pop(L, 1); /* pop the userdata */
++ lua_pushboolean(L, 0);
++ return 1;
++ }
++ }else{
++ /* payload does not carry the provided protocol */
++ /* we push false and return */
++ lua_pop(L, 1); /* pop the userdata */
++ lua_pushboolean(L, 0);
++ return 1;
++ }
++ }else{
++ /* unknown protocol */
++ lua_pop(L, 1); /* pop the userdata */
++ luaL_error(L, "provided protocol is unknown");
++ }
++ }
++ }
++
++ /* if there is still the 'new' userdata on the top, we push our own metatable */
++ if (lua_isuserdata(L, -1)) {
++ luaL_getmetatable(L, prot_buf->name);
++ new->changes = seg->changes;
++ if (seg->changes)
++ new->changes->ref_count++;
++ }
++
++ /* a new packet segment is at index -2 , and the proper metatable at index -1 of the stack
++ * lets set the propper setter and getter function for the requested field */
++ initialize_field_getter_and_setter(L, prot_buf, field_index);
++
++ lua_setmetatable(L, -2);
++ return 1;
++}
++
++/* C_API: 'register_protbuf' is only used internally. This function takes a
++ * pointer to a fully initialized protocol buffer struct and registers it
++ * inside the Lua state. Registering means:
++ *
++ * 1. it creates a new metatable with the name of the protocol buffer.
++ * 2. it registers the default functions which are stored in the luaL_Reg
++ * array seg_access_functions.
++ * 3. it loops over the protocol fields stored at prot_buf->protocol_fields
++ * and registers a new function (using the field name) inside the
++ * metatable. Each field points to the function 'get_protocol_field'
++ * which acts as a closure taking a pointer to the protocol buffer as
++ * well as the index of the field as upvalues.
++ * 4. The protocol index, serves as numerical identifier of this protocol
++ * buffer or even of the protocol itself. This index is stored as a
++ * global value inside the Lua state as well as inside the Lua table
++ * 'supported_protocols'. Assuming the name of a procotol buffer is
++ * "packet_ip" the following statements are true:
++ *
++ * supported_protocols[protocol_index] == "packet_ip"
++ * packet_ip == protocol_index
++ *
++ * This allows you to get all registered protocols from within Lua. This
++ * is especially usefull for the dynamic protocol buffers where you have
++ * to provide your own "has_protocol"-function, which probably needs the
++ * information on which protocols it is able to contain.
++ */
++void register_protbuf(lua_State *L, struct protocol_buf * prot_buf, uint32_t protocol_index)
++{
++ int32_t field_index;
++ luaL_Reg *reg = (struct luaL_Reg *)seg_access_functions;
++ struct protocol_field * field = prot_buf->protocol_fields;
++
++ luaL_newmetatable(L, prot_buf->name);
++
++ /* metatable.__index = metatable */
++ lua_pushvalue(L, -1); /* duplicates the metatable */
++ lua_setfield(L, -2, "__index");
++
++ /* pushing default functions */
++ for (; reg->name; reg++) {
++ lua_pushlightuserdata(L, (void *)prot_buf);
++ lua_pushcclosure(L, reg->func, 1);
++ lua_setfield(L, -2, reg->name);
++ }
++
++ /* pushing functions specific to the protocol buffer */
++ for (field_index = 0; field->name; field++, field_index++) {
++ lua_pushlightuserdata(L, (void *)prot_buf); /* upvalue: prot_buf */
++ lua_pushinteger(L, field_index); /* upvalue: index of protocol field */
++ lua_pushcclosure(L, get_protocol_field, 2);
++ lua_setfield(L, -2, field->name);
++ }
++ /* pop the metatable */
++ lua_pop(L, 1);
++
++ /* registering the array-index as the protocol_id*/
++ lua_getglobal(L, "_G");
++ lua_pushinteger(L, protocol_index);
++ lua_setfield(L, -2, prot_buf->name);
++ lua_pop(L, 1); /* pop _G */
++
++ lua_getglobal(L, SUPPORTED_PROTOCOL_TABLE);
++ lua_pushstring(L, prot_buf->name);
++ lua_rawseti(L, -2, protocol_index);
++
++ lua_pop(L, 1); /* pop SUPPORTED_PROTOCOL_TABLE */
++
++ supported_protocols[protocol_index] = prot_buf;
++}
++
++void luaopen_controller(lua_State *L)
++{
++ /* registering a table inside the _G with table[protocol_index] = prot_buf->name */
++ lua_getglobal(L, "_G");
++ lua_newtable(L);
++ lua_setfield(L, -2, SUPPORTED_PROTOCOL_TABLE);
++ lua_pop(L, 1); /* pop _G */
++
++ luaopen_protbuf_raw(L);
++ luaopen_protbuf_eth(L);
++ luaopen_protbuf_ip(L);
++ luaopen_protbuf_icmp(L);
++ luaopen_protbuf_tcp(L);
++ luaopen_protbuf_tcp_options(L);
++ luaopen_protbuf_udp(L);
++ luaopen_protbuf_tftp(L);
++ luaopen_protbuf_dynamic(L);
++ /* should follow all other static buffers */
++#if defined(__KERNEL__)
++ luaopen_nflib(L);
++#endif
++
++ luaopen_bytearraylib(L);
++}
++
++
++
++
+--- /dev/null
++++ b/extensions/LUA/controller.h
+@@ -0,0 +1,264 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre@dergraf.org>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++
++#ifndef CONTROLLER_H_
++#define CONTROLLER_H_
++
++#include "stdlib.h" /* wrapper */
++#include "string.h" /* wrapper */
++#include "lua.h"
++#include "lualib.h"
++#include "lauxlib.h"
++
++#if defined(__KERNEL__)
++#include <linux/skbuff.h>
++#include <linux/slab.h>
++#include <linux/vmalloc.h>
++#endif
++
++
++/* to compile the stuff in userspace (for testing)*/
++#if !defined(__KERNEL__)
++#include <stdint.h>
++#define pr_debug printf;
++
++#define kmalloc(size, type) malloc(size)
++#define kfree(ptr) free(ptr)
++
++#endif
++
++
++/**********************************************************************/
++/* nf Lua configuration */
++/**********************************************************************/
++#define MAX_NR_OF_PROTOCOLS 16
++#define SUPPORTED_PROTOCOL_TABLE "supported_protocols"
++
++#define MAX_NR_OF_FIELDS_IN_DYN_PROT_BUF 32
++
++
++/**********************************************************************/
++/* Static Protocol Buffer configuration */
++/**********************************************************************/
++
++/* the definitions of the stringified expression of the prot_bufs...
++ * make sure all static prot_bufs are listed and are unique */
++#define LUA_PACKET_SEG_RAW "packet_raw"
++#define LUA_PACKET_SEG_ETH "packet_eth"
++#define LUA_PACKET_SEG_ICMP "packet_icmp"
++#define LUA_PACKET_SEG_IP "packet_ip"
++#define LUA_PACKET_SEG_TCP "packet_tcp"
++#define LUA_PACKET_SEG_TCP_OPT "packet_tcp_opt"
++#define LUA_PACKET_SEG_UDP "packet_udp"
++#define LUA_PACKET_SEG_TFTP "packet_tftp"
++
++/* the enum holding all static prot_bufs... make sure it contains all
++ * static prot_bufs */
++enum PROT_BUF {
++ PACKET_RAW,
++ PACKET_ETH,
++ PACKET_IP,
++ PACKET_ICMP,
++ PACKET_TCP,
++ PACKET_TCP_OPTIONS,
++ PACKET_UDP,
++ PACKET_TFTP,
++ PACKET_DYNAMIC,
++ PACKET_SENTINEL
++};
++
++/* the luaopen-function of the prot_bufs... make sure it is called
++ * inside luaopen_controller */
++void luaopen_protbuf_raw(lua_State *L);
++void luaopen_protbuf_eth(lua_State *L);
++void luaopen_protbuf_ip(lua_State *L);
++void luaopen_protbuf_icmp(lua_State *L);
++void luaopen_protbuf_tcp(lua_State *L);
++void luaopen_protbuf_tcp_options(lua_State *L);
++void luaopen_protbuf_udp(lua_State *L);
++void luaopen_protbuf_tftp(lua_State *L);
++void luaopen_protbuf_dynamic(lua_State *L);
++
++/**********************************************************************/
++/* field changes */
++/**********************************************************************/
++struct field_changes {
++ int ref_count;
++ int *field_length_changes;
++ int *field_offset_changes;
++};
++
++/**********************************************************************/
++/* lua packet segment */
++/* ------------------ */
++/* The struct lua_packet_segment is the integral part of a Lua packet.*/
++/* At the very beginning, when a new packet arrives in `lua_tg`_ such */
++/* a struct is initialized. The field start then points to the lowest */
++/* available header inside the sk_buff structure. During packet */
++/* processing the start pointer remains the same, only the offset and */
++/* length value change. */
++/**********************************************************************/
++#define checkpacketseg(L, i, seg_type) \
++ (lua_packet_segment *)luaL_checkudata(L, i, seg_type)
++
++typedef struct lua_packet_segment {
++ unsigned int offset;
++ unsigned int length;
++ struct field_changes * changes;
++ unsigned char * start; /* need to be at the end because of the memory alignment */
++} lua_packet_segment;
++
++/**********************************************************************/
++/* protocol field */
++/* -------------- */
++/* This structure is a container for the field definitions used by the*/
++/* protocol buffer. Each protocol field is expressed using this struct*/
++/* Have a look at the protocol buffers to see how the struct gets */
++/* initialized. */
++/* */
++/* name: */
++/* This member expresses the name of the field, ending */
++/* in its own Lua function to access the field. */
++/* offset / length: */
++/* These members do specify the position inside the protocol header */
++/* in bits (not bytes!). */
++/* get / set: */
++/* The get and set functions take a function pointer pointing to the*/
++/* specific getter and setter function for this field. */
++/**********************************************************************/
++struct protocol_field {
++ const char * name;
++ uint32_t offset;
++ uint32_t length;
++ lua_CFunction get;
++ lua_CFunction set;
++};
++#define PROT_FIELD_SENTINEL { NULL, 0, 0, NULL, NULL }
++
++
++/**********************************************************************/
++/* protocol_buf */
++/**********************************************************************/
++/* This structure is a container for all the information needed for a
++ * protocol buffer. It gets initialized in each protocol buffer header
++ * file or for the dynamic protocol buffers on runtime using the
++ * 'register_dynamic_protocol_buffer' function.
++ *
++ * name:
++ * This member is used throughout the system. It is also exported
++ * to Lua as a variable name holding the index of the 'supported_protocols'
++ * array. The name is also used as the name of the generated Lua
++ * metatable, that is why inside the macro checkpacketseg_ it
++ * is always the name of a protocol buffer that is passed as the
++ * second parameter.
++ * payload_field:
++ * This member holds the string of the field responsible for payload
++ * data. The payload field of a protocol has an extra property, since
++ * it can be used to invoke another protocol buffer that is applied to
++ * the payload content.
++ * has_protocol:
++ * This member is used together with the payload_field. Since we must
++ * be sure that the payload content does really contain a protocol
++ * of type X. The function pointed to by has_protocol checks if the
++ * protocol buffer X can be applied on the payload_data.
++ * protocol_fields:
++ * This member points to the array of 'protocol_field' structures
++ * get_field_changes:
++ * This member is optional. It is used to return a pointer to an initialized
++ * field_changes struct. The function is called, whenever the payload field
++ * is requested with a given protocol type. Usually this function will
++ * initialize the field_changes struct depending on the content of the
++ * payload data. e.g.
++ * tcp = ip:data(packet_tcp)
++ * such a request will call the 'get_field_changes' function of the tcp
++ * protocol buffer. This enables, that the tcp options field have the proper
++ * length as well as the tcp data start at the right offset.
++ */
++struct protocol_buf {
++ int is_dynamic;
++ const char * name;
++ char * payload_field;
++ int (*has_protocol)(lua_State *L, struct protocol_buf *prot_buf, lua_packet_segment * seg, int type);
++ struct protocol_field * protocol_fields;
++ struct field_changes * (*get_field_changes)(lua_State *L, lua_packet_segment * seg);
++};
++
++/**********************************************************************/
++/* lua byte array library */
++/**********************************************************************/
++#define LUA_BYTE_ARRAY "byte_array"
++#define checkbytearray(L, i) \
++ (lua_packet_segment *)luaL_checkudata(L, i, LUA_BYTE_ARRAY)
++lua_packet_segment * init_byte_array(lua_State *L, unsigned char * start, int length, int do_copy);
++void luaopen_bytearraylib(lua_State *L);
++
++
++/**********************************************************************/
++/* lua netfilter environment library */
++/**********************************************************************/
++#define NETFILTER_LIB "nf"
++#if defined(__KERNEL__)
++ struct lua_env {
++ lua_State *L;
++ /* perhaps more to come here (e.g. a state per CPU) */
++ };
++ #define LUA_ENV "lua_env"
++ #define checkluaenv(L, i) \
++ (struct lua_env *)luaL_checkudata(L, i, LUA_ENV)
++
++ void luaopen_nflib(lua_State *L);
++#endif
++
++void cleanup_dynamic_prot_bufs(void); /* freeing all dynamic prot bufs */
++/**********************************************************************/
++/* lua protbuf helpers */
++/**********************************************************************/
++int get_1_bit_generic(lua_State *L);
++int set_1_bit_generic(lua_State *L);
++int get_lower_4_bit_generic(lua_State *L);
++int set_lower_4_bit_generic(lua_State *L);
++int get_upper_4_bit_generic(lua_State *L);
++int set_upper_4_bit_generic(lua_State *L);
++int get_8_bit_generic(lua_State *L);
++int set_8_bit_generic(lua_State *L);
++int get_16_bit_generic(lua_State *L);
++int set_16_bit_generic(lua_State *L);
++int get_32_bit_generic(lua_State *L);
++int set_32_bit_generic(lua_State *L);
++int set_data_generic(lua_State *L);
++int get_string_generic(lua_State *L);
++int get_byte_generic_str(lua_State *L);
++struct field_changes * get_allocated_field_changes(lua_State *L, int nr_of_fields);
++
++/* only used by the dynamic prot buf subsystem */
++#define MAX_NR_OF_DYN_PROT_BUFS 16
++int field_dynamic_setter(lua_State *L);
++int field_dynamic_getter(lua_State *L);
++int has_protocol_dynamic(lua_State *L, struct protocol_buf * prot_buf, lua_packet_segment * seg, int type);
++struct field_changes * get_field_changes_dynamic(lua_State *L, struct protocol_buf *prot_buf, lua_packet_segment * seg);
++
++/**********************************************************************/
++/* lua controller API */
++/**********************************************************************/
++void luaopen_controller(lua_State *L);
++struct protocol_buf * get_protocol_buf(unsigned int protocol_id);
++void get_metatable_from_protocol_type(lua_State *L, int type);
++void register_protbuf(lua_State *L, struct protocol_buf * prot_buf, unsigned int protocol_index);
++
++
++#endif /* CONTROLLER_H_ */
+--- /dev/null
++++ b/extensions/LUA/Kbuild
+@@ -0,0 +1,49 @@
++# -*- Makefile -*-
++
++# Adding debug options
++EXTRA_CFLAGS += -DDEBUG
++
++obj-m += xt_LUA.o
++
++EXTRA_CFLAGS += -I$(src)/prot_buf_new
++xt_LUA-y += xt_LUA_target.o \
++
++xt_LUA-y += nf_lua.o \
++ prot_buf_helpers.o \
++ byte_array.o \
++ controller.o \
++ prot_buf_ethernet.o \
++ prot_buf_icmp.o \
++ prot_buf_ip.o \
++ prot_buf_raw.o \
++ prot_buf_tcp.o \
++ prot_buf_udp.o \
++ prot_buf_tftp.o \
++ prot_buf_dynamic.o \
++
++
++# Adding Lua Support
++EXTRA_CFLAGS += -I$(src)/lua -I$(src)/lua/include
++xt_LUA-y += lua/lapi.o \
++ lua/lbaselib.o \
++ lua/lcode.o \
++ lua/ldebug.o \
++ lua/ldo.o \
++ lua/ldump.o \
++ lua/lfunc.o \
++ lua/lgc.o \
++ lua/llex.o \
++ lua/lmem.o \
++ lua/lobject.o \
++ lua/lopcodes.o \
++ lua/lparser.o \
++ lua/lstate.o \
++ lua/lstring.o \
++ lua/lstrlib.o \
++ lua/ltable.o \
++ lua/ltablib.o \
++ lua/ltm.o \
++ lua/lundump.o \
++ lua/lvm.o \
++ lua/lzio.o \
++ lua/lauxlib.o \
+--- /dev/null
++++ b/extensions/LUA/libxt_LUA.c
+@@ -0,0 +1,191 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre@dergraf.org>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++
++#include <getopt.h>
++#include <stdio.h>
++#include <stdbool.h>
++#include <stdlib.h>
++#include <string.h>
++#include <xtables.h>
++#include <linux/netfilter.h>
++#include <linux/netfilter/x_tables.h>
++#include "xt_LUA.h"
++
++enum {
++ FLAG_SCRIPT = 1 << 0,
++ FLAG_STATE = 1 << 1,
++ FLAG_FUNCTION = 1 << 2,
++};
++
++static const struct option lua_tg_opts[] = {
++ { .name = "script", .has_arg = true, .val = 's' },
++ { .name = "state", .has_arg = true, .val = 'l' },
++ { .name = "function", .has_arg = true, .val = 'f' },
++ { NULL },
++};
++
++
++static void lua_tg_help(void)
++{
++ printf(
++ "LUA target options:\n"
++ " --script SCRIPT Process packet with the Lua script given by SCRIPT\n"
++ " \n"
++ " --state ID Process packet within the Lua state given by ID.\n"
++ " Omitting --state infers the ID 0, which can be\n"
++ " refered to the 'global' state.\n"
++ " \n"
++ " --function FUNCTION Name of the function that processes the Lua packet\n"
++ "\n");
++}
++
++static void
++lua_tg_init(struct xt_entry_target *target)
++{
++ struct xt_lua_tginfo *info = (void *)target->data;
++
++ info->state_id = 0;
++ strncpy(info->function, "process_packet\0", sizeof("process_packet\0"));
++}
++
++static int
++lua_tg_parse(int32_t c, char **argv, int32_t invert, uint32_t *flags,
++ const void *entry, struct xt_entry_target **target)
++{
++ struct xt_lua_tginfo *info = (void *)(*target)->data;
++ char buf[MAX_SCRIPT_SIZE];
++ long script_size;
++ uint32_t state_id;
++ FILE *file;
++
++ switch (c) {
++ case 's':
++ if (*flags & FLAG_SCRIPT)
++ xtables_error(PARAMETER_PROBLEM,
++ "LUA: Cannot specify --script more than once");
++
++ if (strlen(optarg) > sizeof(info->filename))
++ xtables_error(PARAMETER_PROBLEM,
++ "LUA: Maximum script length is %zu",
++ sizeof(info->filename));
++
++ if (strchr(optarg, '\n'))
++ xtables_error(PARAMETER_PROBLEM,
++ "LUA: Newlines not allowed in script name");
++ file = fopen(optarg, "rb");
++ if (file != NULL) {
++ fseek(file, 0, SEEK_END);
++ script_size = ftell(file);
++ if (script_size > MAX_SCRIPT_SIZE)
++ xtables_error(PARAMETER_PROBLEM,
++ "LUA: The size of the script is too big");
++
++ fseek(file, 0, SEEK_SET);
++ fread(buf, script_size, 1, file);
++ fclose(file);
++ } else
++ xtables_error(PARAMETER_PROBLEM,
++ "LUA: Cannot open script %s", optarg);
++
++ strncpy(info->filename, optarg, sizeof(info->filename));
++ strncpy(info->buf, buf, sizeof(info->buf));
++ info->script_size = script_size;
++
++ *flags |= FLAG_SCRIPT;
++ return true;
++
++ case 'l':
++ if (*flags & FLAG_STATE)
++ xtables_error(PARAMETER_PROBLEM,
++ "LUA: Cannot specify --state more than once");
++
++ if (!xtables_strtoui(optarg, NULL, &state_id, 0, 8))
++ xtables_error(PARAMETER_PROBLEM,
++ "LUA: Invalid --state %s", optarg);
++
++ info->state_id = state_id;
++ *flags |= FLAG_STATE;
++ return true;
++
++ case 'f':
++ if (*flags & FLAG_FUNCTION)
++ xtables_error(PARAMETER_PROBLEM,
++ "LUA: Cannot specify --function more than once");
++ if (strlen(optarg) > sizeof(info->function))
++ xtables_error(PARAMETER_PROBLEM,
++ "LUA: Maximum function length is %zu",
++ sizeof(info->function));
++
++ if (strchr(optarg, '\n'))
++ xtables_error(PARAMETER_PROBLEM,
++ "LUA: Newlines not allowed in function name");
++
++ strncpy(info->function, optarg, sizeof(info->function));
++
++ *flags |= FLAG_FUNCTION;
++ return true;
++ }
++
++ return false;
++}
++
++static void
++lua_tg_check(uint32_t flags)
++{
++ if (flags == 0)
++ xtables_error(PARAMETER_PROBLEM, "LUA: --script parameter required");
++}
++
++static void
++lua_tg_print(const void *entry, const struct xt_entry_target *target,
++ int32_t numeric)
++{
++ const struct xt_lua_tginfo *info = (const void *)target->data;
++
++ printf("LUA script: %s ", info->filename);
++}
++
++static void
++lua_tg_save(const void *entry, const struct xt_entry_target *target)
++{
++ const struct xt_lua_tginfo *info = (const void *)target->data;
++
++ printf("--script %s ", info->filename);
++}
++
++static struct xtables_target lua_tg_reg = {
++ .name = "LUA",
++ .version = XTABLES_VERSION,
++ .revision = 0,
++ .family = NFPROTO_UNSPEC,
++ .size = XT_ALIGN(sizeof(struct xt_lua_tginfo)),
++ .userspacesize = XT_ALIGN(sizeof(struct xt_lua_tginfo)),
++ .help = lua_tg_help,
++ .init = lua_tg_init,
++ .parse = lua_tg_parse,
++ .final_check = lua_tg_check,
++ .print = lua_tg_print,
++ .save = lua_tg_save,
++ .extra_opts = lua_tg_opts,
++};
++
++static __attribute__((constructor)) void lua_tg_ldr(void)
++{
++ xtables_register_target(&lua_tg_reg);
++}
++
+--- /dev/null
++++ b/extensions/LUA/libxt_LUA.man
+@@ -0,0 +1 @@
++Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
+--- /dev/null
++++ b/extensions/LUA/lua/include/ctype.h
+@@ -0,0 +1,11 @@
++#include <linux/ctype.h>
++#undef isalnum
++#define isalnum(c) (((__ismask(c)&(_U|_L|_D)) != 0) && (c > 0))
++#undef isalpha
++#define isalpha(c) (((__ismask(c)&(_U|_L)) != 0) && (c > 0))
++#undef iscntrl
++#define iscntrl(c) (((__ismask(c)&(_C)) != 0) && (c > 0))
++#undef isdigit
++#define isdigit(c) (((__ismask(c)&(_D)) != 0) && (c > 0))
++#undef isspace
++#define isspace(c) (((__ismask(c)&(_S)) != 0) && (c > 0))
+--- /dev/null
++++ b/extensions/LUA/lua/include/errno.h
+@@ -0,0 +1 @@
++#include <linux/errno.h>
+--- /dev/null
++++ b/extensions/LUA/lua/include/locale.h
+@@ -0,0 +1,5 @@
++struct lconv {
++ char * decimal_point ;
++} ;
++
++#define localeconv() NULL
+--- /dev/null
++++ b/extensions/LUA/lua/include/setjmp.h
+@@ -0,0 +1,26 @@
++/*
++ * arch/um/include/sysdep-i386/archsetjmp.h
++ */
++
++#ifndef _KLIBC_ARCHSETJMP_H
++#define _KLIBC_ARCHSETJMP_H
++
++struct __jmp_buf {
++ unsigned int __ebx;
++ unsigned int __esp;
++ unsigned int __ebp;
++ unsigned int __esi;
++ unsigned int __edi;
++ unsigned int __eip;
++};
++
++typedef struct __jmp_buf jmp_buf[1];
++
++#define JB_IP __eip
++#define JB_SP __esp
++
++int setjmp(jmp_buf);
++void longjmp(jmp_buf, int);
++
++#endif /* _SETJMP_H */
++
+--- /dev/null
++++ b/extensions/LUA/lua/include/stdio.h
+@@ -0,0 +1 @@
++#include <linux/kernel.h>
+--- /dev/null
++++ b/extensions/LUA/lua/include/stdlib.h
+@@ -0,0 +1,7 @@
++#include <linux/kernel.h>
++
++#define exit(E) return
++#define strtoul simple_strtoul
++#define strcoll strcmp
++
++#define CHAR_BIT 8
+--- /dev/null
++++ b/extensions/LUA/lua/include/string.h
+@@ -0,0 +1 @@
++#include <linux/string.h>
+--- /dev/null
++++ b/extensions/LUA/lua/lapi.c
+@@ -0,0 +1,1086 @@
++/*
++** $Id: lapi.c,v 2.55.1.5 2008/07/04 18:41:18 roberto Exp $
++** Lua API
++** See Copyright Notice in lua.h
++*/
++
++#include <stdarg.h>
++#include <math.h>
++#include <assert.h>
++#include <string.h>
++
++#define lapi_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "lapi.h"
++#include "ldebug.h"
++#include "ldo.h"
++#include "lfunc.h"
++#include "lgc.h"
++#include "lmem.h"
++#include "lobject.h"
++#include "lstate.h"
++#include "lstring.h"
++#include "ltable.h"
++#include "ltm.h"
++#include "lundump.h"
++#include "lvm.h"
++
++
++
++const char lua_ident[] =
++ "$Lua: " LUA_RELEASE " " LUA_COPYRIGHT " $\n"
++ "$Authors: " LUA_AUTHORS " $\n"
++ "$URL: www.lua.org $\n";
++
++
++
++#define api_checknelems(L, n) api_check(L, (n) <= (L->top - L->base))
++
++#define api_checkvalidindex(L, i) api_check(L, (i) != luaO_nilobject)
++
++#define api_incr_top(L) {api_check(L, L->top < L->ci->top); L->top++;}
++
++
++
++static TValue *index2adr (lua_State *L, int idx) {
++ if (idx > 0) {
++ TValue *o = L->base + (idx - 1);
++ api_check(L, idx <= L->ci->top - L->base);
++ if (o >= L->top) return cast(TValue *, luaO_nilobject);
++ else return o;
++ }
++ else if (idx > LUA_REGISTRYINDEX) {
++ api_check(L, idx != 0 && -idx <= L->top - L->base);
++ return L->top + idx;
++ }
++ else switch (idx) { /* pseudo-indices */
++ case LUA_REGISTRYINDEX: return registry(L);
++ case LUA_ENVIRONINDEX: {
++ Closure *func = curr_func(L);
++ sethvalue(L, &L->env, func->c.env);
++ return &L->env;
++ }
++ case LUA_GLOBALSINDEX: return gt(L);
++ default: {
++ Closure *func = curr_func(L);
++ idx = LUA_GLOBALSINDEX - idx;
++ return (idx <= func->c.nupvalues)
++ ? &func->c.upvalue[idx-1]
++ : cast(TValue *, luaO_nilobject);
++ }
++ }
++}
++
++
++static Table *getcurrenv (lua_State *L) {
++ if (L->ci == L->base_ci) /* no enclosing function? */
++ return hvalue(gt(L)); /* use global table as environment */
++ else {
++ Closure *func = curr_func(L);
++ return func->c.env;
++ }
++}
++
++
++void luaA_pushobject (lua_State *L, const TValue *o) {
++ setobj2s(L, L->top, o);
++ api_incr_top(L);
++}
++
++
++LUA_API int lua_checkstack (lua_State *L, int size) {
++ int res = 1;
++ lua_lock(L);
++ if (size > LUAI_MAXCSTACK || (L->top - L->base + size) > LUAI_MAXCSTACK)
++ res = 0; /* stack overflow */
++ else if (size > 0) {
++ luaD_checkstack(L, size);
++ if (L->ci->top < L->top + size)
++ L->ci->top = L->top + size;
++ }
++ lua_unlock(L);
++ return res;
++}
++
++
++LUA_API void lua_xmove (lua_State *from, lua_State *to, int n) {
++ int i;
++ if (from == to) return;
++ lua_lock(to);
++ api_checknelems(from, n);
++ api_check(from, G(from) == G(to));
++ api_check(from, to->ci->top - to->top >= n);
++ from->top -= n;
++ for (i = 0; i < n; i++) {
++ setobj2s(to, to->top++, from->top + i);
++ }
++ lua_unlock(to);
++}
++
++
++LUA_API void lua_setlevel (lua_State *from, lua_State *to) {
++ to->nCcalls = from->nCcalls;
++}
++
++
++LUA_API lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf) {
++ lua_CFunction old;
++ lua_lock(L);
++ old = G(L)->panic;
++ G(L)->panic = panicf;
++ lua_unlock(L);
++ return old;
++}
++
++
++LUA_API lua_State *lua_newthread (lua_State *L) {
++ lua_State *L1;
++ lua_lock(L);
++ luaC_checkGC(L);
++ L1 = luaE_newthread(L);
++ setthvalue(L, L->top, L1);
++ api_incr_top(L);
++ lua_unlock(L);
++ luai_userstatethread(L, L1);
++ return L1;
++}
++
++
++
++/*
++** basic stack manipulation
++*/
++
++
++LUA_API int lua_gettop (lua_State *L) {
++ return cast_int(L->top - L->base);
++}
++
++
++LUA_API void lua_settop (lua_State *L, int idx) {
++ lua_lock(L);
++ if (idx >= 0) {
++ api_check(L, idx <= L->stack_last - L->base);
++ while (L->top < L->base + idx)
++ setnilvalue(L->top++);
++ L->top = L->base + idx;
++ }
++ else {
++ api_check(L, -(idx+1) <= (L->top - L->base));
++ L->top += idx+1; /* `subtract' index (index is negative) */
++ }
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_remove (lua_State *L, int idx) {
++ StkId p;
++ lua_lock(L);
++ p = index2adr(L, idx);
++ api_checkvalidindex(L, p);
++ while (++p < L->top) setobjs2s(L, p-1, p);
++ L->top--;
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_insert (lua_State *L, int idx) {
++ StkId p;
++ StkId q;
++ lua_lock(L);
++ p = index2adr(L, idx);
++ api_checkvalidindex(L, p);
++ for (q = L->top; q>p; q--) setobjs2s(L, q, q-1);
++ setobjs2s(L, p, L->top);
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_replace (lua_State *L, int idx) {
++ StkId o;
++ lua_lock(L);
++ /* explicit test for incompatible code */
++ if (idx == LUA_ENVIRONINDEX && L->ci == L->base_ci)
++ luaG_runerror(L, "no calling environment");
++ api_checknelems(L, 1);
++ o = index2adr(L, idx);
++ api_checkvalidindex(L, o);
++ if (idx == LUA_ENVIRONINDEX) {
++ Closure *func = curr_func(L);
++ api_check(L, ttistable(L->top - 1));
++ func->c.env = hvalue(L->top - 1);
++ luaC_barrier(L, func, L->top - 1);
++ }
++ else {
++ setobj(L, o, L->top - 1);
++ if (idx < LUA_GLOBALSINDEX) /* function upvalue? */
++ luaC_barrier(L, curr_func(L), L->top - 1);
++ }
++ L->top--;
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_pushvalue (lua_State *L, int idx) {
++ lua_lock(L);
++ setobj2s(L, L->top, index2adr(L, idx));
++ api_incr_top(L);
++ lua_unlock(L);
++}
++
++
++
++/*
++** access functions (stack -> C)
++*/
++
++
++LUA_API int lua_type (lua_State *L, int idx) {
++ StkId o = index2adr(L, idx);
++ return (o == luaO_nilobject) ? LUA_TNONE : ttype(o);
++}
++
++
++LUA_API const char *lua_typename (lua_State *L, int t) {
++ UNUSED(L);
++ return (t == LUA_TNONE) ? "no value" : luaT_typenames[t];
++}
++
++
++LUA_API int lua_iscfunction (lua_State *L, int idx) {
++ StkId o = index2adr(L, idx);
++ return iscfunction(o);
++}
++
++
++LUA_API int lua_isnumber (lua_State *L, int idx) {
++ TValue n;
++ const TValue *o = index2adr(L, idx);
++ return tonumber(o, &n);
++}
++
++
++LUA_API int lua_isstring (lua_State *L, int idx) {
++ int t = lua_type(L, idx);
++ return (t == LUA_TSTRING || t == LUA_TNUMBER);
++}
++
++
++LUA_API int lua_isuserdata (lua_State *L, int idx) {
++ const TValue *o = index2adr(L, idx);
++ return (ttisuserdata(o) || ttislightuserdata(o));
++}
++
++
++LUA_API int lua_rawequal (lua_State *L, int index1, int index2) {
++ StkId o1 = index2adr(L, index1);
++ StkId o2 = index2adr(L, index2);
++ return (o1 == luaO_nilobject || o2 == luaO_nilobject) ? 0
++ : luaO_rawequalObj(o1, o2);
++}
++
++
++LUA_API int lua_equal (lua_State *L, int index1, int index2) {
++ StkId o1, o2;
++ int i;
++ lua_lock(L); /* may call tag method */
++ o1 = index2adr(L, index1);
++ o2 = index2adr(L, index2);
++ i = (o1 == luaO_nilobject || o2 == luaO_nilobject) ? 0 : equalobj(L, o1, o2);
++ lua_unlock(L);
++ return i;
++}
++
++
++LUA_API int lua_lessthan (lua_State *L, int index1, int index2) {
++ StkId o1, o2;
++ int i;
++ lua_lock(L); /* may call tag method */
++ o1 = index2adr(L, index1);
++ o2 = index2adr(L, index2);
++ i = (o1 == luaO_nilobject || o2 == luaO_nilobject) ? 0
++ : luaV_lessthan(L, o1, o2);
++ lua_unlock(L);
++ return i;
++}
++
++
++
++LUA_API lua_Number lua_tonumber (lua_State *L, int idx) {
++ TValue n;
++ const TValue *o = index2adr(L, idx);
++ if (tonumber(o, &n))
++ return nvalue(o);
++ else
++ return 0;
++}
++
++
++LUA_API lua_Integer lua_tointeger (lua_State *L, int idx) {
++ TValue n;
++ const TValue *o = index2adr(L, idx);
++ if (tonumber(o, &n)) {
++ lua_Integer res;
++ lua_Number num = nvalue(o);
++ lua_number2integer(res, num);
++ return res;
++ }
++ else
++ return 0;
++}
++
++
++LUA_API int lua_toboolean (lua_State *L, int idx) {
++ const TValue *o = index2adr(L, idx);
++ return !l_isfalse(o);
++}
++
++
++LUA_API const char *lua_tolstring (lua_State *L, int idx, size_t *len) {
++ StkId o = index2adr(L, idx);
++ if (!ttisstring(o)) {
++ lua_lock(L); /* `luaV_tostring' may create a new string */
++ if (!luaV_tostring(L, o)) { /* conversion failed? */
++ if (len != NULL) *len = 0;
++ lua_unlock(L);
++ return NULL;
++ }
++ luaC_checkGC(L);
++ o = index2adr(L, idx); /* previous call may reallocate the stack */
++ lua_unlock(L);
++ }
++ if (len != NULL) *len = tsvalue(o)->len;
++ return svalue(o);
++}
++
++
++LUA_API size_t lua_objlen (lua_State *L, int idx) {
++ StkId o = index2adr(L, idx);
++ switch (ttype(o)) {
++ case LUA_TSTRING: return tsvalue(o)->len;
++ case LUA_TUSERDATA: return uvalue(o)->len;
++ case LUA_TTABLE: return luaH_getn(hvalue(o));
++ case LUA_TNUMBER: {
++ size_t l;
++ lua_lock(L); /* `luaV_tostring' may create a new string */
++ l = (luaV_tostring(L, o) ? tsvalue(o)->len : 0);
++ lua_unlock(L);
++ return l;
++ }
++ default: return 0;
++ }
++}
++
++
++LUA_API lua_CFunction lua_tocfunction (lua_State *L, int idx) {
++ StkId o = index2adr(L, idx);
++ return (!iscfunction(o)) ? NULL : clvalue(o)->c.f;
++}
++
++
++LUA_API void *lua_touserdata (lua_State *L, int idx) {
++ StkId o = index2adr(L, idx);
++ switch (ttype(o)) {
++ case LUA_TUSERDATA: return (rawuvalue(o) + 1);
++ case LUA_TLIGHTUSERDATA: return pvalue(o);
++ default: return NULL;
++ }
++}
++
++
++LUA_API lua_State *lua_tothread (lua_State *L, int idx) {
++ StkId o = index2adr(L, idx);
++ return (!ttisthread(o)) ? NULL : thvalue(o);
++}
++
++
++LUA_API const void *lua_topointer (lua_State *L, int idx) {
++ StkId o = index2adr(L, idx);
++ switch (ttype(o)) {
++ case LUA_TTABLE: return hvalue(o);
++ case LUA_TFUNCTION: return clvalue(o);
++ case LUA_TTHREAD: return thvalue(o);
++ case LUA_TUSERDATA:
++ case LUA_TLIGHTUSERDATA:
++ return lua_touserdata(L, idx);
++ default: return NULL;
++ }
++}
++
++
++
++/*
++** push functions (C -> stack)
++*/
++
++
++LUA_API void lua_pushnil (lua_State *L) {
++ lua_lock(L);
++ setnilvalue(L->top);
++ api_incr_top(L);
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_pushnumber (lua_State *L, lua_Number n) {
++ lua_lock(L);
++ setnvalue(L->top, n);
++ api_incr_top(L);
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_pushinteger (lua_State *L, lua_Integer n) {
++ lua_lock(L);
++ setnvalue(L->top, cast_num(n));
++ api_incr_top(L);
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_pushlstring (lua_State *L, const char *s, size_t len) {
++ lua_lock(L);
++ luaC_checkGC(L);
++ setsvalue2s(L, L->top, luaS_newlstr(L, s, len));
++ api_incr_top(L);
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_pushstring (lua_State *L, const char *s) {
++ if (s == NULL)
++ lua_pushnil(L);
++ else
++ lua_pushlstring(L, s, strlen(s));
++}
++
++
++LUA_API const char *lua_pushvfstring (lua_State *L, const char *fmt,
++ va_list argp) {
++ const char *ret;
++ lua_lock(L);
++ luaC_checkGC(L);
++ ret = luaO_pushvfstring(L, fmt, argp);
++ lua_unlock(L);
++ return ret;
++}
++
++
++LUA_API const char *lua_pushfstring (lua_State *L, const char *fmt, ...) {
++ const char *ret;
++ va_list argp;
++ lua_lock(L);
++ luaC_checkGC(L);
++ va_start(argp, fmt);
++ ret = luaO_pushvfstring(L, fmt, argp);
++ va_end(argp);
++ lua_unlock(L);
++ return ret;
++}
++
++
++LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) {
++ Closure *cl;
++ lua_lock(L);
++ luaC_checkGC(L);
++ api_checknelems(L, n);
++ cl = luaF_newCclosure(L, n, getcurrenv(L));
++ cl->c.f = fn;
++ L->top -= n;
++ while (n--)
++ setobj2n(L, &cl->c.upvalue[n], L->top+n);
++ setclvalue(L, L->top, cl);
++ lua_assert(iswhite(obj2gco(cl)));
++ api_incr_top(L);
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_pushboolean (lua_State *L, int b) {
++ lua_lock(L);
++ setbvalue(L->top, (b != 0)); /* ensure that true is 1 */
++ api_incr_top(L);
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_pushlightuserdata (lua_State *L, void *p) {
++ lua_lock(L);
++ setpvalue(L->top, p);
++ api_incr_top(L);
++ lua_unlock(L);
++}
++
++
++LUA_API int lua_pushthread (lua_State *L) {
++ lua_lock(L);
++ setthvalue(L, L->top, L);
++ api_incr_top(L);
++ lua_unlock(L);
++ return (G(L)->mainthread == L);
++}
++
++
++
++/*
++** get functions (Lua -> stack)
++*/
++
++
++LUA_API void lua_gettable (lua_State *L, int idx) {
++ StkId t;
++ lua_lock(L);
++ t = index2adr(L, idx);
++ api_checkvalidindex(L, t);
++ luaV_gettable(L, t, L->top - 1, L->top - 1);
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_getfield (lua_State *L, int idx, const char *k) {
++ StkId t;
++ TValue key;
++ lua_lock(L);
++ t = index2adr(L, idx);
++ api_checkvalidindex(L, t);
++ setsvalue(L, &key, luaS_new(L, k));
++ luaV_gettable(L, t, &key, L->top);
++ api_incr_top(L);
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_rawget (lua_State *L, int idx) {
++ StkId t;
++ lua_lock(L);
++ t = index2adr(L, idx);
++ api_check(L, ttistable(t));
++ setobj2s(L, L->top - 1, luaH_get(hvalue(t), L->top - 1));
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_rawgeti (lua_State *L, int idx, int n) {
++ StkId o;
++ lua_lock(L);
++ o = index2adr(L, idx);
++ api_check(L, ttistable(o));
++ setobj2s(L, L->top, luaH_getnum(hvalue(o), n));
++ api_incr_top(L);
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_createtable (lua_State *L, int narray, int nrec) {
++ lua_lock(L);
++ luaC_checkGC(L);
++ sethvalue(L, L->top, luaH_new(L, narray, nrec));
++ api_incr_top(L);
++ lua_unlock(L);
++}
++
++
++LUA_API int lua_getmetatable (lua_State *L, int objindex) {
++ const TValue *obj;
++ Table *mt = NULL;
++ int res;
++ lua_lock(L);
++ obj = index2adr(L, objindex);
++ switch (ttype(obj)) {
++ case LUA_TTABLE:
++ mt = hvalue(obj)->metatable;
++ break;
++ case LUA_TUSERDATA:
++ mt = uvalue(obj)->metatable;
++ break;
++ default:
++ mt = G(L)->mt[ttype(obj)];
++ break;
++ }
++ if (mt == NULL)
++ res = 0;
++ else {
++ sethvalue(L, L->top, mt);
++ api_incr_top(L);
++ res = 1;
++ }
++ lua_unlock(L);
++ return res;
++}
++
++
++LUA_API void lua_getfenv (lua_State *L, int idx) {
++ StkId o;
++ lua_lock(L);
++ o = index2adr(L, idx);
++ api_checkvalidindex(L, o);
++ switch (ttype(o)) {
++ case LUA_TFUNCTION:
++ sethvalue(L, L->top, clvalue(o)->c.env);
++ break;
++ case LUA_TUSERDATA:
++ sethvalue(L, L->top, uvalue(o)->env);
++ break;
++ case LUA_TTHREAD:
++ setobj2s(L, L->top, gt(thvalue(o)));
++ break;
++ default:
++ setnilvalue(L->top);
++ break;
++ }
++ api_incr_top(L);
++ lua_unlock(L);
++}
++
++
++/*
++** set functions (stack -> Lua)
++*/
++
++
++LUA_API void lua_settable (lua_State *L, int idx) {
++ StkId t;
++ lua_lock(L);
++ api_checknelems(L, 2);
++ t = index2adr(L, idx);
++ api_checkvalidindex(L, t);
++ luaV_settable(L, t, L->top - 2, L->top - 1);
++ L->top -= 2; /* pop index and value */
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_setfield (lua_State *L, int idx, const char *k) {
++ StkId t;
++ TValue key;
++ lua_lock(L);
++ api_checknelems(L, 1);
++ t = index2adr(L, idx);
++ api_checkvalidindex(L, t);
++ setsvalue(L, &key, luaS_new(L, k));
++ luaV_settable(L, t, &key, L->top - 1);
++ L->top--; /* pop value */
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_rawset (lua_State *L, int idx) {
++ StkId t;
++ lua_lock(L);
++ api_checknelems(L, 2);
++ t = index2adr(L, idx);
++ api_check(L, ttistable(t));
++ setobj2t(L, luaH_set(L, hvalue(t), L->top-2), L->top-1);
++ luaC_barriert(L, hvalue(t), L->top-1);
++ L->top -= 2;
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_rawseti (lua_State *L, int idx, int n) {
++ StkId o;
++ lua_lock(L);
++ api_checknelems(L, 1);
++ o = index2adr(L, idx);
++ api_check(L, ttistable(o));
++ setobj2t(L, luaH_setnum(L, hvalue(o), n), L->top-1);
++ luaC_barriert(L, hvalue(o), L->top-1);
++ L->top--;
++ lua_unlock(L);
++}
++
++
++LUA_API int lua_setmetatable (lua_State *L, int objindex) {
++ TValue *obj;
++ Table *mt;
++ lua_lock(L);
++ api_checknelems(L, 1);
++ obj = index2adr(L, objindex);
++ api_checkvalidindex(L, obj);
++ if (ttisnil(L->top - 1))
++ mt = NULL;
++ else {
++ api_check(L, ttistable(L->top - 1));
++ mt = hvalue(L->top - 1);
++ }
++ switch (ttype(obj)) {
++ case LUA_TTABLE: {
++ hvalue(obj)->metatable = mt;
++ if (mt)
++ luaC_objbarriert(L, hvalue(obj), mt);
++ break;
++ }
++ case LUA_TUSERDATA: {
++ uvalue(obj)->metatable = mt;
++ if (mt)
++ luaC_objbarrier(L, rawuvalue(obj), mt);
++ break;
++ }
++ default: {
++ G(L)->mt[ttype(obj)] = mt;
++ break;
++ }
++ }
++ L->top--;
++ lua_unlock(L);
++ return 1;
++}
++
++
++LUA_API int lua_setfenv (lua_State *L, int idx) {
++ StkId o;
++ int res = 1;
++ lua_lock(L);
++ api_checknelems(L, 1);
++ o = index2adr(L, idx);
++ api_checkvalidindex(L, o);
++ api_check(L, ttistable(L->top - 1));
++ switch (ttype(o)) {
++ case LUA_TFUNCTION:
++ clvalue(o)->c.env = hvalue(L->top - 1);
++ break;
++ case LUA_TUSERDATA:
++ uvalue(o)->env = hvalue(L->top - 1);
++ break;
++ case LUA_TTHREAD:
++ sethvalue(L, gt(thvalue(o)), hvalue(L->top - 1));
++ break;
++ default:
++ res = 0;
++ break;
++ }
++ if (res) luaC_objbarrier(L, gcvalue(o), hvalue(L->top - 1));
++ L->top--;
++ lua_unlock(L);
++ return res;
++}
++
++
++/*
++** `load' and `call' functions (run Lua code)
++*/
++
++
++#define adjustresults(L,nres) \
++ { if (nres == LUA_MULTRET && L->top >= L->ci->top) L->ci->top = L->top; }
++
++
++#define checkresults(L,na,nr) \
++ api_check(L, (nr) == LUA_MULTRET || (L->ci->top - L->top >= (nr) - (na)))
++
++
++LUA_API void lua_call (lua_State *L, int nargs, int nresults) {
++ StkId func;
++ lua_lock(L);
++ api_checknelems(L, nargs+1);
++ checkresults(L, nargs, nresults);
++ func = L->top - (nargs+1);
++ luaD_call(L, func, nresults);
++ adjustresults(L, nresults);
++ lua_unlock(L);
++}
++
++
++
++/*
++** Execute a protected call.
++*/
++struct CallS { /* data to `f_call' */
++ StkId func;
++ int nresults;
++};
++
++
++static void f_call (lua_State *L, void *ud) {
++ struct CallS *c = cast(struct CallS *, ud);
++ luaD_call(L, c->func, c->nresults);
++}
++
++
++
++LUA_API int lua_pcall (lua_State *L, int nargs, int nresults, int errfunc) {
++ struct CallS c;
++ int status;
++ ptrdiff_t func;
++ lua_lock(L);
++ api_checknelems(L, nargs+1);
++ checkresults(L, nargs, nresults);
++ if (errfunc == 0)
++ func = 0;
++ else {
++ StkId o = index2adr(L, errfunc);
++ api_checkvalidindex(L, o);
++ func = savestack(L, o);
++ }
++ c.func = L->top - (nargs+1); /* function to be called */
++ c.nresults = nresults;
++ status = luaD_pcall(L, f_call, &c, savestack(L, c.func), func);
++ adjustresults(L, nresults);
++ lua_unlock(L);
++ return status;
++}
++
++
++/*
++** Execute a protected C call.
++*/
++struct CCallS { /* data to `f_Ccall' */
++ lua_CFunction func;
++ void *ud;
++};
++
++
++static void f_Ccall (lua_State *L, void *ud) {
++ struct CCallS *c = cast(struct CCallS *, ud);
++ Closure *cl;
++ cl = luaF_newCclosure(L, 0, getcurrenv(L));
++ cl->c.f = c->func;
++ setclvalue(L, L->top, cl); /* push function */
++ api_incr_top(L);
++ setpvalue(L->top, c->ud); /* push only argument */
++ api_incr_top(L);
++ luaD_call(L, L->top - 2, 0);
++}
++
++
++LUA_API int lua_cpcall (lua_State *L, lua_CFunction func, void *ud) {
++ struct CCallS c;
++ int status;
++ lua_lock(L);
++ c.func = func;
++ c.ud = ud;
++ status = luaD_pcall(L, f_Ccall, &c, savestack(L, L->top), 0);
++ lua_unlock(L);
++ return status;
++}
++
++
++LUA_API int lua_load (lua_State *L, lua_Reader reader, void *data,
++ const char *chunkname) {
++ ZIO z;
++ int status;
++ lua_lock(L);
++ if (!chunkname) chunkname = "?";
++ luaZ_init(L, &z, reader, data);
++ status = luaD_protectedparser(L, &z, chunkname);
++ lua_unlock(L);
++ return status;
++}
++
++
++LUA_API int lua_dump (lua_State *L, lua_Writer writer, void *data) {
++ int status;
++ TValue *o;
++ lua_lock(L);
++ api_checknelems(L, 1);
++ o = L->top - 1;
++ if (isLfunction(o))
++ status = luaU_dump(L, clvalue(o)->l.p, writer, data, 0);
++ else
++ status = 1;
++ lua_unlock(L);
++ return status;
++}
++
++
++LUA_API int lua_status (lua_State *L) {
++ return L->status;
++}
++
++
++/*
++** Garbage-collection function
++*/
++
++LUA_API int lua_gc (lua_State *L, int what, int data) {
++ int res = 0;
++ global_State *g;
++ lua_lock(L);
++ g = G(L);
++ switch (what) {
++ case LUA_GCSTOP: {
++ g->GCthreshold = MAX_LUMEM;
++ break;
++ }
++ case LUA_GCRESTART: {
++ g->GCthreshold = g->totalbytes;
++ break;
++ }
++ case LUA_GCCOLLECT: {
++ luaC_fullgc(L);
++ break;
++ }
++ case LUA_GCCOUNT: {
++ /* GC values are expressed in Kbytes: #bytes/2^10 */
++ res = cast_int(g->totalbytes >> 10);
++ break;
++ }
++ case LUA_GCCOUNTB: {
++ res = cast_int(g->totalbytes & 0x3ff);
++ break;
++ }
++ case LUA_GCSTEP: {
++ lu_mem a = (cast(lu_mem, data) << 10);
++ if (a <= g->totalbytes)
++ g->GCthreshold = g->totalbytes - a;
++ else
++ g->GCthreshold = 0;
++ while (g->GCthreshold <= g->totalbytes) {
++ luaC_step(L);
++ if (g->gcstate == GCSpause) { /* end of cycle? */
++ res = 1; /* signal it */
++ break;
++ }
++ }
++ break;
++ }
++ case LUA_GCSETPAUSE: {
++ res = g->gcpause;
++ g->gcpause = data;
++ break;
++ }
++ case LUA_GCSETSTEPMUL: {
++ res = g->gcstepmul;
++ g->gcstepmul = data;
++ break;
++ }
++ default: res = -1; /* invalid option */
++ }
++ lua_unlock(L);
++ return res;
++}
++
++
++
++/*
++** miscellaneous functions
++*/
++
++
++LUA_API int lua_error (lua_State *L) {
++ lua_lock(L);
++ api_checknelems(L, 1);
++ luaG_errormsg(L);
++ lua_unlock(L);
++ return 0; /* to avoid warnings */
++}
++
++
++LUA_API int lua_next (lua_State *L, int idx) {
++ StkId t;
++ int more;
++ lua_lock(L);
++ t = index2adr(L, idx);
++ api_check(L, ttistable(t));
++ more = luaH_next(L, hvalue(t), L->top - 1);
++ if (more) {
++ api_incr_top(L);
++ }
++ else /* no more elements */
++ L->top -= 1; /* remove key */
++ lua_unlock(L);
++ return more;
++}
++
++
++LUA_API void lua_concat (lua_State *L, int n) {
++ lua_lock(L);
++ api_checknelems(L, n);
++ if (n >= 2) {
++ luaC_checkGC(L);
++ luaV_concat(L, n, cast_int(L->top - L->base) - 1);
++ L->top -= (n-1);
++ }
++ else if (n == 0) { /* push empty string */
++ setsvalue2s(L, L->top, luaS_newlstr(L, "", 0));
++ api_incr_top(L);
++ }
++ /* else n == 1; nothing to do */
++ lua_unlock(L);
++}
++
++
++LUA_API lua_Alloc lua_getallocf (lua_State *L, void **ud) {
++ lua_Alloc f;
++ lua_lock(L);
++ if (ud) *ud = G(L)->ud;
++ f = G(L)->frealloc;
++ lua_unlock(L);
++ return f;
++}
++
++
++LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud) {
++ lua_lock(L);
++ G(L)->ud = ud;
++ G(L)->frealloc = f;
++ lua_unlock(L);
++}
++
++
++LUA_API void *lua_newuserdata (lua_State *L, size_t size) {
++ Udata *u;
++ lua_lock(L);
++ luaC_checkGC(L);
++ u = luaS_newudata(L, size, getcurrenv(L));
++ setuvalue(L, L->top, u);
++ api_incr_top(L);
++ lua_unlock(L);
++ return u + 1;
++}
++
++
++
++
++static const char *aux_upvalue (StkId fi, int n, TValue **val) {
++ Closure *f;
++ if (!ttisfunction(fi)) return NULL;
++ f = clvalue(fi);
++ if (f->c.isC) {
++ if (!(1 <= n && n <= f->c.nupvalues)) return NULL;
++ *val = &f->c.upvalue[n-1];
++ return "";
++ }
++ else {
++ Proto *p = f->l.p;
++ if (!(1 <= n && n <= p->sizeupvalues)) return NULL;
++ *val = f->l.upvals[n-1]->v;
++ return getstr(p->upvalues[n-1]);
++ }
++}
++
++
++LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n) {
++ const char *name;
++ TValue *val;
++ lua_lock(L);
++ name = aux_upvalue(index2adr(L, funcindex), n, &val);
++ if (name) {
++ setobj2s(L, L->top, val);
++ api_incr_top(L);
++ }
++ lua_unlock(L);
++ return name;
++}
++
++
++LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n) {
++ const char *name;
++ TValue *val;
++ StkId fi;
++ lua_lock(L);
++ fi = index2adr(L, funcindex);
++ api_checknelems(L, 1);
++ name = aux_upvalue(fi, n, &val);
++ if (name) {
++ L->top--;
++ setobj(L, val, L->top);
++ luaC_barrier(L, clvalue(fi), L->top);
++ }
++ lua_unlock(L);
++ return name;
++}
++
+--- /dev/null
++++ b/extensions/LUA/lua/lapi.h
+@@ -0,0 +1,16 @@
++/*
++** $Id: lapi.h,v 2.2.1.1 2007/12/27 13:02:25 roberto Exp $
++** Auxiliary functions from Lua API
++** See Copyright Notice in lua.h
++*/
++
++#ifndef lapi_h
++#define lapi_h
++
++
++#include "lobject.h"
++
++
++LUAI_FUNC void luaA_pushobject (lua_State *L, const TValue *o);
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/lauxlib.c
+@@ -0,0 +1,674 @@
++/*
++** $Id: lauxlib.c,v 1.159.1.3 2008/01/21 13:20:51 roberto Exp $
++** Auxiliary functions for building Lua libraries
++** See Copyright Notice in lua.h
++*/
++
++#include <stdarg.h>
++
++#if !defined(__KERNEL__)
++#include <ctype.h>
++#include <errno.h>
++#include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
++#else
++#include <linux/ctype.h>
++#include <linux/errno.h>
++#include <linux/kernel.h>
++#include <linux/slab.h>
++#include <linux/string.h>
++#endif
++
++/* This file uses only the official API of Lua.
++** Any function declared here could be written as an application function.
++*/
++
++#define lauxlib_c
++#define LUA_LIB
++
++#include "lua.h"
++
++#include "lauxlib.h"
++
++
++#define FREELIST_REF 0 /* free list of references */
++
++
++/* convert a stack index to positive */
++#define abs_index(L, i) ((i) > 0 || (i) <= LUA_REGISTRYINDEX ? (i) : \
++ lua_gettop(L) + (i) + 1)
++
++
++/*
++** {======================================================
++** Error-report functions
++** =======================================================
++*/
++
++
++LUALIB_API int luaL_argerror (lua_State *L, int narg, const char *extramsg) {
++ lua_Debug ar;
++ if (!lua_getstack(L, 0, &ar)) /* no stack frame? */
++ return luaL_error(L, "bad argument #%d (%s)", narg, extramsg);
++ lua_getinfo(L, "n", &ar);
++ if (strcmp(ar.namewhat, "method") == 0) {
++ narg--; /* do not count `self' */
++ if (narg == 0) /* error is in the self argument itself? */
++ return luaL_error(L, "calling " LUA_QS " on bad self (%s)",
++ ar.name, extramsg);
++ }
++ if (ar.name == NULL)
++ ar.name = "?";
++ return luaL_error(L, "bad argument #%d to " LUA_QS " (%s)",
++ narg, ar.name, extramsg);
++}
++
++
++LUALIB_API int luaL_typerror (lua_State *L, int narg, const char *tname) {
++ const char *msg = lua_pushfstring(L, "%s expected, got %s",
++ tname, luaL_typename(L, narg));
++ return luaL_argerror(L, narg, msg);
++}
++
++
++static void tag_error (lua_State *L, int narg, int tag) {
++ luaL_typerror(L, narg, lua_typename(L, tag));
++}
++
++
++LUALIB_API void luaL_where (lua_State *L, int level) {
++ lua_Debug ar;
++ if (lua_getstack(L, level, &ar)) { /* check function at level */
++ lua_getinfo(L, "Sl", &ar); /* get info about it */
++ if (ar.currentline > 0) { /* is there info? */
++ lua_pushfstring(L, "%s:%d: ", ar.short_src, ar.currentline);
++ return;
++ }
++ }
++ lua_pushliteral(L, ""); /* else, no information available... */
++}
++
++
++LUALIB_API int luaL_error (lua_State *L, const char *fmt, ...) {
++ va_list argp;
++ va_start(argp, fmt);
++ luaL_where(L, 1);
++ lua_pushvfstring(L, fmt, argp);
++ va_end(argp);
++ lua_concat(L, 2);
++ return lua_error(L);
++}
++
++/* }====================================================== */
++
++
++LUALIB_API int luaL_checkoption (lua_State *L, int narg, const char *def,
++ const char *const lst[]) {
++ const char *name = (def) ? luaL_optstring(L, narg, def) :
++ luaL_checkstring(L, narg);
++ int i;
++ for (i=0; lst[i]; i++)
++ if (strcmp(lst[i], name) == 0)
++ return i;
++ return luaL_argerror(L, narg,
++ lua_pushfstring(L, "invalid option " LUA_QS, name));
++}
++
++
++LUALIB_API int luaL_newmetatable (lua_State *L, const char *tname) {
++ lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get registry.name */
++ if (!lua_isnil(L, -1)) /* name already in use? */
++ return 0; /* leave previous value on top, but return 0 */
++ lua_pop(L, 1);
++ lua_newtable(L); /* create metatable */
++ lua_pushvalue(L, -1);
++ lua_setfield(L, LUA_REGISTRYINDEX, tname); /* registry.name = metatable */
++ return 1;
++}
++
++
++LUALIB_API void *luaL_checkudata (lua_State *L, int ud, const char *tname) {
++ void *p = lua_touserdata(L, ud);
++ if (p != NULL) { /* value is a userdata? */
++ if (lua_getmetatable(L, ud)) { /* does it have a metatable? */
++ lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get correct metatable */
++ if (lua_rawequal(L, -1, -2)) { /* does it have the correct mt? */
++ lua_pop(L, 2); /* remove both metatables */
++ return p;
++ }
++ }
++ }
++ luaL_typerror(L, ud, tname); /* else error */
++ return NULL; /* to avoid warnings */
++}
++
++
++LUALIB_API void luaL_checkstack (lua_State *L, int space, const char *mes) {
++ if (!lua_checkstack(L, space))
++ luaL_error(L, "stack overflow (%s)", mes);
++}
++
++
++LUALIB_API void luaL_checktype (lua_State *L, int narg, int t) {
++ if (lua_type(L, narg) != t)
++ tag_error(L, narg, t);
++}
++
++
++LUALIB_API void luaL_checkany (lua_State *L, int narg) {
++ if (lua_type(L, narg) == LUA_TNONE)
++ luaL_argerror(L, narg, "value expected");
++}
++
++
++LUALIB_API const char *luaL_checklstring (lua_State *L, int narg, size_t *len) {
++ const char *s = lua_tolstring(L, narg, len);
++ if (!s) tag_error(L, narg, LUA_TSTRING);
++ return s;
++}
++
++
++LUALIB_API const char *luaL_optlstring (lua_State *L, int narg,
++ const char *def, size_t *len) {
++ if (lua_isnoneornil(L, narg)) {
++ if (len)
++ *len = (def ? strlen(def) : 0);
++ return def;
++ }
++ else return luaL_checklstring(L, narg, len);
++}
++
++
++LUALIB_API lua_Number luaL_checknumber (lua_State *L, int narg) {
++ lua_Number d = lua_tonumber(L, narg);
++ if (d == 0 && !lua_isnumber(L, narg)) /* avoid extra test when d is not 0 */
++ tag_error(L, narg, LUA_TNUMBER);
++ return d;
++}
++
++
++LUALIB_API lua_Number luaL_optnumber (lua_State *L, int narg, lua_Number def) {
++ return luaL_opt(L, luaL_checknumber, narg, def);
++}
++
++
++LUALIB_API lua_Integer luaL_checkinteger (lua_State *L, int narg) {
++ lua_Integer d = lua_tointeger(L, narg);
++ if (d == 0 && !lua_isnumber(L, narg)) /* avoid extra test when d is not 0 */
++ tag_error(L, narg, LUA_TNUMBER);
++ return d;
++}
++
++
++LUALIB_API lua_Integer luaL_optinteger (lua_State *L, int narg,
++ lua_Integer def) {
++ return luaL_opt(L, luaL_checkinteger, narg, def);
++}
++
++
++LUALIB_API int luaL_getmetafield (lua_State *L, int obj, const char *event) {
++ if (!lua_getmetatable(L, obj)) /* no metatable? */
++ return 0;
++ lua_pushstring(L, event);
++ lua_rawget(L, -2);
++ if (lua_isnil(L, -1)) {
++ lua_pop(L, 2); /* remove metatable and metafield */
++ return 0;
++ }
++ else {
++ lua_remove(L, -2); /* remove only metatable */
++ return 1;
++ }
++}
++
++
++LUALIB_API int luaL_callmeta (lua_State *L, int obj, const char *event) {
++ obj = abs_index(L, obj);
++ if (!luaL_getmetafield(L, obj, event)) /* no metafield? */
++ return 0;
++ lua_pushvalue(L, obj);
++ lua_call(L, 1, 1);
++ return 1;
++}
++
++
++LUALIB_API void (luaL_register) (lua_State *L, const char *libname,
++ const luaL_Reg *l) {
++ luaI_openlib(L, libname, l, 0);
++}
++
++
++static int libsize (const luaL_Reg *l) {
++ int size = 0;
++ for (; l->name; l++) size++;
++ return size;
++}
++
++
++LUALIB_API void luaI_openlib (lua_State *L, const char *libname,
++ const luaL_Reg *l, int nup) {
++ if (libname) {
++ int size = libsize(l);
++ /* check whether lib already exists */
++ luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 1);
++ lua_getfield(L, -1, libname); /* get _LOADED[libname] */
++ if (!lua_istable(L, -1)) { /* not found? */
++ lua_pop(L, 1); /* remove previous result */
++ /* try global variable (and create one if it does not exist) */
++ if (luaL_findtable(L, LUA_GLOBALSINDEX, libname, size) != NULL)
++ luaL_error(L, "name conflict for module " LUA_QS, libname);
++ lua_pushvalue(L, -1);
++ lua_setfield(L, -3, libname); /* _LOADED[libname] = new table */
++ }
++ lua_remove(L, -2); /* remove _LOADED table */
++ lua_insert(L, -(nup+1)); /* move library table to below upvalues */
++ }
++ for (; l->name; l++) {
++ int i;
++ for (i=0; i<nup; i++) /* copy upvalues to the top */
++ lua_pushvalue(L, -nup);
++ lua_pushcclosure(L, l->func, nup);
++ lua_setfield(L, -(nup+2), l->name);
++ }
++ lua_pop(L, nup); /* remove upvalues */
++}
++
++
++
++/*
++** {======================================================
++** getn-setn: size for arrays
++** =======================================================
++*/
++
++#if defined(LUA_COMPAT_GETN)
++
++static int checkint (lua_State *L, int topop) {
++ int n = (lua_type(L, -1) == LUA_TNUMBER) ? lua_tointeger(L, -1) : -1;
++ lua_pop(L, topop);
++ return n;
++}
++
++
++static void getsizes (lua_State *L) {
++ lua_getfield(L, LUA_REGISTRYINDEX, "LUA_SIZES");
++ if (lua_isnil(L, -1)) { /* no `size' table? */
++ lua_pop(L, 1); /* remove nil */
++ lua_newtable(L); /* create it */
++ lua_pushvalue(L, -1); /* `size' will be its own metatable */
++ lua_setmetatable(L, -2);
++ lua_pushliteral(L, "kv");
++ lua_setfield(L, -2, "__mode"); /* metatable(N).__mode = "kv" */
++ lua_pushvalue(L, -1);
++ lua_setfield(L, LUA_REGISTRYINDEX, "LUA_SIZES"); /* store in register */
++ }
++}
++
++
++LUALIB_API void luaL_setn (lua_State *L, int t, int n) {
++ t = abs_index(L, t);
++ lua_pushliteral(L, "n");
++ lua_rawget(L, t);
++ if (checkint(L, 1) >= 0) { /* is there a numeric field `n'? */
++ lua_pushliteral(L, "n"); /* use it */
++ lua_pushinteger(L, n);
++ lua_rawset(L, t);
++ }
++ else { /* use `sizes' */
++ getsizes(L);
++ lua_pushvalue(L, t);
++ lua_pushinteger(L, n);
++ lua_rawset(L, -3); /* sizes[t] = n */
++ lua_pop(L, 1); /* remove `sizes' */
++ }
++}
++
++
++LUALIB_API int luaL_getn (lua_State *L, int t) {
++ int n;
++ t = abs_index(L, t);
++ lua_pushliteral(L, "n"); /* try t.n */
++ lua_rawget(L, t);
++ if ((n = checkint(L, 1)) >= 0) return n;
++ getsizes(L); /* else try sizes[t] */
++ lua_pushvalue(L, t);
++ lua_rawget(L, -2);
++ if ((n = checkint(L, 2)) >= 0) return n;
++ return (int)lua_objlen(L, t);
++}
++
++#endif
++
++/* }====================================================== */
++
++
++
++LUALIB_API const char *luaL_gsub (lua_State *L, const char *s, const char *p,
++ const char *r) {
++ const char *wild;
++ size_t l = strlen(p);
++ luaL_Buffer *b = (luaL_Buffer *)kmalloc(sizeof(luaL_Buffer) + BUFSIZ, GFP_ATOMIC);
++ if(!b) luaL_error(L, "luaL_gsub: cannot allocate memory");
++ luaL_buffinit(L, b);
++ while ((wild = strstr(s, p)) != NULL) {
++ luaL_addlstring(b, s, wild - s); /* push prefix */
++ luaL_addstring(b, r); /* push replacement in place of pattern */
++ s = wild + l; /* continue after `p' */
++ }
++ luaL_addstring(b, s); /* push last suffix */
++ luaL_pushresult(b);
++ kfree(b);
++ return lua_tostring(L, -1);
++}
++
++
++LUALIB_API const char *luaL_findtable (lua_State *L, int idx,
++ const char *fname, int szhint) {
++ const char *e;
++ lua_pushvalue(L, idx);
++ do {
++ e = strchr(fname, '.');
++ if (e == NULL) e = fname + strlen(fname);
++ lua_pushlstring(L, fname, e - fname);
++ lua_rawget(L, -2);
++ if (lua_isnil(L, -1)) { /* no such field? */
++ lua_pop(L, 1); /* remove this nil */
++ lua_createtable(L, 0, (*e == '.' ? 1 : szhint)); /* new table for field */
++ lua_pushlstring(L, fname, e - fname);
++ lua_pushvalue(L, -2);
++ lua_settable(L, -4); /* set new table into field */
++ }
++ else if (!lua_istable(L, -1)) { /* field has a non-table value? */
++ lua_pop(L, 2); /* remove table and value */
++ return fname; /* return problematic part of the name */
++ }
++ lua_remove(L, -2); /* remove previous table */
++ fname = e + 1;
++ } while (*e == '.');
++ return NULL;
++}
++
++
++
++/*
++** {======================================================
++** Generic Buffer manipulation
++** =======================================================
++*/
++
++
++#define bufflen(B) ((B)->p - (B)->buffer)
++#define bufffree(B) ((size_t)(LUAL_BUFFERSIZE - bufflen(B)))
++
++#define LIMIT (LUA_MINSTACK/2)
++
++
++static int emptybuffer (luaL_Buffer *B) {
++ size_t l = bufflen(B);
++ if (l == 0) return 0; /* put nothing on stack */
++ else {
++ lua_pushlstring(B->L, B->buffer, l);
++ B->p = B->buffer;
++ B->lvl++;
++ return 1;
++ }
++}
++
++
++static void adjuststack (luaL_Buffer *B) {
++ if (B->lvl > 1) {
++ lua_State *L = B->L;
++ int toget = 1; /* number of levels to concat */
++ size_t toplen = lua_strlen(L, -1);
++ do {
++ size_t l = lua_strlen(L, -(toget+1));
++ if (B->lvl - toget + 1 >= LIMIT || toplen > l) {
++ toplen += l;
++ toget++;
++ }
++ else break;
++ } while (toget < B->lvl);
++ lua_concat(L, toget);
++ B->lvl = B->lvl - toget + 1;
++ }
++}
++
++
++LUALIB_API char *luaL_prepbuffer (luaL_Buffer *B) {
++ if (emptybuffer(B))
++ adjuststack(B);
++ return B->buffer;
++}
++
++
++LUALIB_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) {
++ while (l--)
++ luaL_addchar(B, *s++);
++}
++
++
++LUALIB_API void luaL_addstring (luaL_Buffer *B, const char *s) {
++ luaL_addlstring(B, s, strlen(s));
++}
++
++
++LUALIB_API void luaL_pushresult (luaL_Buffer *B) {
++ emptybuffer(B);
++ lua_concat(B->L, B->lvl);
++ B->lvl = 1;
++}
++
++
++LUALIB_API void luaL_addvalue (luaL_Buffer *B) {
++ lua_State *L = B->L;
++ size_t vl;
++ const char *s = lua_tolstring(L, -1, &vl);
++ if (vl <= bufffree(B)) { /* fit into buffer? */
++ memcpy(B->p, s, vl); /* put it there */
++ B->p += vl;
++ lua_pop(L, 1); /* remove from stack */
++ }
++ else {
++ if (emptybuffer(B))
++ lua_insert(L, -2); /* put buffer before new value */
++ B->lvl++; /* add new value into B stack */
++ adjuststack(B);
++ }
++}
++
++
++LUALIB_API void luaL_buffinit (lua_State *L, luaL_Buffer *B) {
++ B->L = L;
++ B->p = B->buffer;
++ B->lvl = 0;
++}
++
++/* }====================================================== */
++
++
++LUALIB_API int luaL_ref (lua_State *L, int t) {
++ int ref;
++ t = abs_index(L, t);
++ if (lua_isnil(L, -1)) {
++ lua_pop(L, 1); /* remove from stack */
++ return LUA_REFNIL; /* `nil' has a unique fixed reference */
++ }
++ lua_rawgeti(L, t, FREELIST_REF); /* get first free element */
++ ref = (int)lua_tointeger(L, -1); /* ref = t[FREELIST_REF] */
++ lua_pop(L, 1); /* remove it from stack */
++ if (ref != 0) { /* any free element? */
++ lua_rawgeti(L, t, ref); /* remove it from list */
++ lua_rawseti(L, t, FREELIST_REF); /* (t[FREELIST_REF] = t[ref]) */
++ }
++ else { /* no free elements */
++ ref = (int)lua_objlen(L, t);
++ ref++; /* create new reference */
++ }
++ lua_rawseti(L, t, ref);
++ return ref;
++}
++
++
++LUALIB_API void luaL_unref (lua_State *L, int t, int ref) {
++ if (ref >= 0) {
++ t = abs_index(L, t);
++ lua_rawgeti(L, t, FREELIST_REF);
++ lua_rawseti(L, t, ref); /* t[ref] = t[FREELIST_REF] */
++ lua_pushinteger(L, ref);
++ lua_rawseti(L, t, FREELIST_REF); /* t[FREELIST_REF] = ref */
++ }
++}
++
++
++
++/*
++** {======================================================
++** Load functions
++** =======================================================
++*/
++
++#if !defined(__KERNEL__)
++typedef struct LoadF {
++ int extraline;
++ FILE *f;
++ char buff[LUAL_BUFFERSIZE];
++} LoadF;
++
++
++static const char *getF (lua_State *L, void *ud, size_t *size) {
++ LoadF *lf = (LoadF *)ud;
++ (void)L;
++ if (lf->extraline) {
++ lf->extraline = 0;
++ *size = 1;
++ return "\n";
++ }
++ if (feof(lf->f)) return NULL;
++ *size = fread(lf->buff, 1, sizeof(lf->buff), lf->f);
++ return (*size > 0) ? lf->buff : NULL;
++}
++
++
++static int errfile (lua_State *L, const char *what, int fnameindex) {
++ const char *serr = strerror(errno);
++ const char *filename = lua_tostring(L, fnameindex) + 1;
++ lua_pushfstring(L, "cannot %s %s: %s", what, filename, serr);
++ lua_remove(L, fnameindex);
++ return LUA_ERRFILE;
++}
++
++
++LUALIB_API int luaL_loadfile (lua_State *L, const char *filename) {
++ LoadF lf;
++ int status, readstatus;
++ int c;
++ int fnameindex = lua_gettop(L) + 1; /* index of filename on the stack */
++ lf.extraline = 0;
++ if (filename == NULL) {
++ lua_pushliteral(L, "=stdin");
++ lf.f = stdin;
++ }
++ else {
++ lua_pushfstring(L, "@%s", filename);
++ lf.f = fopen(filename, "r");
++ if (lf.f == NULL) return errfile(L, "open", fnameindex);
++ }
++ c = getc(lf.f);
++ if (c == '#') { /* Unix exec. file? */
++ lf.extraline = 1;
++ while ((c = getc(lf.f)) != EOF && c != '\n') ; /* skip first line */
++ if (c == '\n') c = getc(lf.f);
++ }
++ if (c == LUA_SIGNATURE[0] && filename) { /* binary file? */
++ lf.f = freopen(filename, "rb", lf.f); /* reopen in binary mode */
++ if (lf.f == NULL) return errfile(L, "reopen", fnameindex);
++ /* skip eventual `#!...' */
++ while ((c = getc(lf.f)) != EOF && c != LUA_SIGNATURE[0]) ;
++ lf.extraline = 0;
++ }
++ ungetc(c, lf.f);
++ status = lua_load(L, getF, &lf, lua_tostring(L, -1));
++ readstatus = ferror(lf.f);
++ if (filename) fclose(lf.f); /* close file (even in case of errors) */
++ if (readstatus) {
++ lua_settop(L, fnameindex); /* ignore results from `lua_load' */
++ return errfile(L, "read", fnameindex);
++ }
++ lua_remove(L, fnameindex);
++ return status;
++}
++#endif
++
++typedef struct LoadS {
++ const char *s;
++ size_t size;
++} LoadS;
++
++
++static const char *getS (lua_State *L, void *ud, size_t *size) {
++ LoadS *ls = (LoadS *)ud;
++ (void)L;
++ if (ls->size == 0) return NULL;
++ *size = ls->size;
++ ls->size = 0;
++ return ls->s;
++}
++
++
++LUALIB_API int luaL_loadbuffer (lua_State *L, const char *buff, size_t size,
++ const char *name) {
++ LoadS ls;
++ ls.s = buff;
++ ls.size = size;
++ return lua_load(L, getS, &ls, name);
++}
++
++
++LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s) {
++ return luaL_loadbuffer(L, s, strlen(s), s);
++}
++
++
++
++/* }====================================================== */
++
++
++static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) {
++ (void)ud;
++ (void)osize;
++ if (nsize == 0) {
++#if !defined(__KERNEL__)
++ free(ptr);
++#else
++ kfree(ptr);
++#endif
++ return NULL;
++ }
++ else
++#if !defined(__KERNEL__)
++ return realloc(ptr, nsize);
++#else
++ return krealloc(ptr, nsize, GFP_ATOMIC);
++#endif
++}
++
++
++static int lpanic (lua_State *L) {
++ (void)L; /* to avoid warnings */
++#if !defined(__KERNEL__)
++ fprintf(stderr, "PANIC: unprotected error in call to Lua API (%s)\n",
++#else
++ printk( "PANIC: unprotected error in call to Lua API (%s)\n",
++#endif
++ lua_tostring(L, -1));
++ return 0;
++}
++
++
++LUALIB_API lua_State *luaL_newstate (void) {
++ lua_State *L = lua_newstate(l_alloc, NULL);
++ if (L) lua_atpanic(L, &lpanic);
++ return L;
++}
++
+--- /dev/null
++++ b/extensions/LUA/lua/lauxlib.h
+@@ -0,0 +1,184 @@
++/*
++** $Id: lauxlib.h,v 1.88.1.1 2007/12/27 13:02:25 roberto Exp $
++** Auxiliary functions for building Lua libraries
++** See Copyright Notice in lua.h
++*/
++
++
++#ifndef lauxlib_h
++#define lauxlib_h
++
++
++#include <stddef.h>
++#include <linux/slab.h> /* for kmalloc and kfree when allocating luaL_Buffer */
++
++#if !defined(__KERNEL__)
++#include <stdio.h>
++#endif
++
++#include "lua.h"
++
++
++#if defined(LUA_COMPAT_GETN)
++LUALIB_API int (luaL_getn) (lua_State *L, int t);
++LUALIB_API void (luaL_setn) (lua_State *L, int t, int n);
++#else
++#define luaL_getn(L,i) ((int)lua_objlen(L, i))
++#define luaL_setn(L,i,j) ((void)0) /* no op! */
++#endif
++
++#if defined(LUA_COMPAT_OPENLIB)
++#define luaI_openlib luaL_openlib
++#endif
++
++
++/* extra error code for `luaL_load' */
++#define LUA_ERRFILE (LUA_ERRERR+1)
++
++
++typedef struct luaL_Reg {
++ const char *name;
++ lua_CFunction func;
++} luaL_Reg;
++
++
++
++LUALIB_API void (luaI_openlib) (lua_State *L, const char *libname,
++ const luaL_Reg *l, int nup);
++LUALIB_API void (luaL_register) (lua_State *L, const char *libname,
++ const luaL_Reg *l);
++LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e);
++LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e);
++LUALIB_API int (luaL_typerror) (lua_State *L, int narg, const char *tname);
++LUALIB_API int (luaL_argerror) (lua_State *L, int numarg, const char *extramsg);
++LUALIB_API const char *(luaL_checklstring) (lua_State *L, int numArg,
++ size_t *l);
++LUALIB_API const char *(luaL_optlstring) (lua_State *L, int numArg,
++ const char *def, size_t *l);
++LUALIB_API lua_Number (luaL_checknumber) (lua_State *L, int numArg);
++LUALIB_API lua_Number (luaL_optnumber) (lua_State *L, int nArg, lua_Number def);
++
++LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int numArg);
++LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int nArg,
++ lua_Integer def);
++
++LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg);
++LUALIB_API void (luaL_checktype) (lua_State *L, int narg, int t);
++LUALIB_API void (luaL_checkany) (lua_State *L, int narg);
++
++LUALIB_API int (luaL_newmetatable) (lua_State *L, const char *tname);
++LUALIB_API void *(luaL_checkudata) (lua_State *L, int ud, const char *tname);
++
++LUALIB_API void (luaL_where) (lua_State *L, int lvl);
++LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...);
++
++LUALIB_API int (luaL_checkoption) (lua_State *L, int narg, const char *def,
++ const char *const lst[]);
++
++LUALIB_API int (luaL_ref) (lua_State *L, int t);
++LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref);
++
++#if !defined(__KERNEL__)
++LUALIB_API int (luaL_loadfile) (lua_State *L, const char *filename);
++#endif
++
++LUALIB_API int (luaL_loadbuffer) (lua_State *L, const char *buff, size_t sz,
++ const char *name);
++LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s);
++
++LUALIB_API lua_State *(luaL_newstate) (void);
++
++
++LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s, const char *p,
++ const char *r);
++
++LUALIB_API const char *(luaL_findtable) (lua_State *L, int idx,
++ const char *fname, int szhint);
++
++
++
++
++/*
++** ===============================================================
++** some useful macros
++** ===============================================================
++*/
++
++#define luaL_argcheck(L, cond,numarg,extramsg) \
++ ((void)((cond) || luaL_argerror(L, (numarg), (extramsg))))
++#define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL))
++#define luaL_optstring(L,n,d) (luaL_optlstring(L, (n), (d), NULL))
++#define luaL_checkint(L,n) ((int)luaL_checkinteger(L, (n)))
++#define luaL_optint(L,n,d) ((int)luaL_optinteger(L, (n), (d)))
++#define luaL_checklong(L,n) ((long)luaL_checkinteger(L, (n)))
++#define luaL_optlong(L,n,d) ((long)luaL_optinteger(L, (n), (d)))
++
++#define luaL_typename(L,i) lua_typename(L, lua_type(L,(i)))
++
++#if !defined(__KERNEL__)
++#define luaL_dofile(L, fn) \
++ (luaL_loadfile(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0))
++#endif
++
++#define luaL_dostring(L, s) \
++ (luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0))
++
++#define luaL_getmetatable(L,n) (lua_getfield(L, LUA_REGISTRYINDEX, (n)))
++
++#define luaL_opt(L,f,n,d) (lua_isnoneornil(L,(n)) ? (d) : f(L,(n)))
++
++/*
++** {======================================================
++** Generic Buffer manipulation
++** =======================================================
++*/
++
++
++
++typedef struct luaL_Buffer {
++ char *p; /* current position in buffer */
++ int lvl; /* number of strings in the stack (level) */
++ lua_State *L;
++ char buffer[LUAL_BUFFERSIZE];
++} luaL_Buffer;
++
++#define luaL_addchar(B,c) \
++ ((void)((B)->p < ((B)->buffer+LUAL_BUFFERSIZE) || luaL_prepbuffer(B)), \
++ (*(B)->p++ = (char)(c)))
++
++/* compatibility only */
++#define luaL_putchar(B,c) luaL_addchar(B,c)
++
++#define luaL_addsize(B,n) ((B)->p += (n))
++
++
++LUALIB_API void (luaL_buffinit) (lua_State *L, luaL_Buffer *B);
++LUALIB_API char *(luaL_prepbuffer) (luaL_Buffer *B);
++LUALIB_API void (luaL_addlstring) (luaL_Buffer *B, const char *s, size_t l);
++LUALIB_API void (luaL_addstring) (luaL_Buffer *B, const char *s);
++LUALIB_API void (luaL_addvalue) (luaL_Buffer *B);
++LUALIB_API void (luaL_pushresult) (luaL_Buffer *B);
++
++
++/* }====================================================== */
++
++
++/* compatibility with ref system */
++
++/* pre-defined references */
++#define LUA_NOREF (-2)
++#define LUA_REFNIL (-1)
++
++#define lua_ref(L,lock) ((lock) ? luaL_ref(L, LUA_REGISTRYINDEX) : \
++ (lua_pushstring(L, "unlocked references are obsolete"), lua_error(L), 0))
++
++#define lua_unref(L,ref) luaL_unref(L, LUA_REGISTRYINDEX, (ref))
++
++#define lua_getref(L,ref) lua_rawgeti(L, LUA_REGISTRYINDEX, (ref))
++
++
++#define luaL_reg luaL_Reg
++
++#endif
++
++
+--- /dev/null
++++ b/extensions/LUA/lua/lbaselib.c
+@@ -0,0 +1,647 @@
++/*
++** $Id: lbaselib.c,v 1.191.1.6 2008/02/14 16:46:22 roberto Exp $
++** Basic library
++** See Copyright Notice in lua.h
++*/
++
++
++#include <linux/kernel.h>
++#include <linux/ctype.h>
++#include <linux/string.h>
++
++#define lbaselib_c
++#define LUA_LIB
++
++#include "lua.h"
++
++#include "lauxlib.h"
++#include "lualib.h"
++
++
++
++
++/*
++** If your system does not support `stdout', you can just remove this function.
++** If you need, you can define your own `print' function, following this
++** model but changing `fputs' to put the strings at a proper place
++** (a console window or a log file, for instance).
++*/
++static int luaB_print (lua_State *L) {
++ int n = lua_gettop(L); /* number of arguments */
++ int i;
++ lua_getglobal(L, "tostring");
++ for (i=1; i<=n; i++) {
++ const char *s;
++ lua_pushvalue(L, -1); /* function to be called */
++ lua_pushvalue(L, i); /* value to print */
++ lua_call(L, 1, 1);
++ s = lua_tostring(L, -1); /* get result */
++ if (s == NULL)
++ return luaL_error(L, LUA_QL("tostring") " must return a string to "
++ LUA_QL("print"));
++ printk(KERN_INFO "LUA[print]: %s", s);
++ lua_pop(L, 1); /* pop result */
++ }
++ return 0;
++}
++
++
++static int luaB_tonumber (lua_State *L) {
++ int base = luaL_optint(L, 2, 10);
++ if (base == 10) { /* standard conversion */
++ luaL_checkany(L, 1);
++ if (lua_isnumber(L, 1)) {
++ lua_pushnumber(L, lua_tonumber(L, 1));
++ return 1;
++ }
++ }
++ else {
++ const char *s1 = luaL_checkstring(L, 1);
++ char *s2;
++ unsigned long n;
++ luaL_argcheck(L, 2 <= base && base <= 36, 2, "base out of range");
++ n = simple_strtoul(s1, &s2, base);
++ if (s1 != s2) { /* at least one valid digit? */
++ while (isspace((unsigned char)(*s2))) s2++; /* skip trailing spaces */
++ if (*s2 == '\0') { /* no invalid trailing characters? */
++ lua_pushnumber(L, (lua_Number)n);
++ return 1;
++ }
++ }
++ }
++ lua_pushnil(L); /* else not a number */
++ return 1;
++}
++
++
++static int luaB_error (lua_State *L) {
++ int level = luaL_optint(L, 2, 1);
++ lua_settop(L, 1);
++ if (lua_isstring(L, 1) && level > 0) { /* add extra information? */
++ luaL_where(L, level);
++ lua_pushvalue(L, 1);
++ lua_concat(L, 2);
++ }
++ return lua_error(L);
++}
++
++
++static int luaB_getmetatable (lua_State *L) {
++ luaL_checkany(L, 1);
++ if (!lua_getmetatable(L, 1)) {
++ lua_pushnil(L);
++ return 1; /* no metatable */
++ }
++ luaL_getmetafield(L, 1, "__metatable");
++ return 1; /* returns either __metatable field (if present) or metatable */
++}
++
++
++static int luaB_setmetatable (lua_State *L) {
++ int t = lua_type(L, 2);
++ luaL_checktype(L, 1, LUA_TTABLE);
++ luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2,
++ "nil or table expected");
++ if (luaL_getmetafield(L, 1, "__metatable"))
++ luaL_error(L, "cannot change a protected metatable");
++ lua_settop(L, 2);
++ lua_setmetatable(L, 1);
++ return 1;
++}
++
++
++static void getfunc (lua_State *L, int opt) {
++ if (lua_isfunction(L, 1)) lua_pushvalue(L, 1);
++ else {
++ lua_Debug ar;
++ int level = opt ? luaL_optint(L, 1, 1) : luaL_checkint(L, 1);
++ luaL_argcheck(L, level >= 0, 1, "level must be non-negative");
++ if (lua_getstack(L, level, &ar) == 0)
++ luaL_argerror(L, 1, "invalid level");
++ lua_getinfo(L, "f", &ar);
++ if (lua_isnil(L, -1))
++ luaL_error(L, "no function environment for tail call at level %d",
++ level);
++ }
++}
++
++
++static int luaB_getfenv (lua_State *L) {
++ getfunc(L, 1);
++ if (lua_iscfunction(L, -1)) /* is a C function? */
++ lua_pushvalue(L, LUA_GLOBALSINDEX); /* return the thread's global env. */
++ else
++ lua_getfenv(L, -1);
++ return 1;
++}
++
++
++static int luaB_setfenv (lua_State *L) {
++ luaL_checktype(L, 2, LUA_TTABLE);
++ getfunc(L, 0);
++ lua_pushvalue(L, 2);
++ if (lua_isnumber(L, 1) && lua_tonumber(L, 1) == 0) {
++ /* change environment of current thread */
++ lua_pushthread(L);
++ lua_insert(L, -2);
++ lua_setfenv(L, -2);
++ return 0;
++ }
++ else if (lua_iscfunction(L, -2) || lua_setfenv(L, -2) == 0)
++ luaL_error(L,
++ LUA_QL("setfenv") " cannot change environment of given object");
++ return 1;
++}
++
++
++static int luaB_rawequal (lua_State *L) {
++ luaL_checkany(L, 1);
++ luaL_checkany(L, 2);
++ lua_pushboolean(L, lua_rawequal(L, 1, 2));
++ return 1;
++}
++
++
++static int luaB_rawget (lua_State *L) {
++ luaL_checktype(L, 1, LUA_TTABLE);
++ luaL_checkany(L, 2);
++ lua_settop(L, 2);
++ lua_rawget(L, 1);
++ return 1;
++}
++
++static int luaB_rawset (lua_State *L) {
++ luaL_checktype(L, 1, LUA_TTABLE);
++ luaL_checkany(L, 2);
++ luaL_checkany(L, 3);
++ lua_settop(L, 3);
++ lua_rawset(L, 1);
++ return 1;
++}
++
++
++static int luaB_gcinfo (lua_State *L) {
++ lua_pushinteger(L, lua_getgccount(L));
++ return 1;
++}
++
++static int luaB_collectgarbage (lua_State *L) {
++ static const char *const opts[] = {"stop", "restart", "collect",
++ "count", "step", "setpause", "setstepmul", NULL};
++ static const int optsnum[] = {LUA_GCSTOP, LUA_GCRESTART, LUA_GCCOLLECT,
++ LUA_GCCOUNT, LUA_GCSTEP, LUA_GCSETPAUSE, LUA_GCSETSTEPMUL};
++ int o = luaL_checkoption(L, 1, "collect", opts);
++ int ex = luaL_optint(L, 2, 0);
++ int res = lua_gc(L, optsnum[o], ex);
++ switch (optsnum[o]) {
++ case LUA_GCCOUNT: {
++ int b = lua_gc(L, LUA_GCCOUNTB, 0);
++ lua_pushnumber(L, res + ((lua_Number)b/1024));
++ return 1;
++ }
++ case LUA_GCSTEP: {
++ lua_pushboolean(L, res);
++ return 1;
++ }
++ default: {
++ lua_pushnumber(L, res);
++ return 1;
++ }
++ }
++}
++
++
++static int luaB_type (lua_State *L) {
++ luaL_checkany(L, 1);
++ lua_pushstring(L, luaL_typename(L, 1));
++ return 1;
++}
++
++
++static int luaB_next (lua_State *L) {
++ luaL_checktype(L, 1, LUA_TTABLE);
++ lua_settop(L, 2); /* create a 2nd argument if there isn't one */
++ if (lua_next(L, 1))
++ return 2;
++ else {
++ lua_pushnil(L);
++ return 1;
++ }
++}
++
++
++static int luaB_pairs (lua_State *L) {
++ luaL_checktype(L, 1, LUA_TTABLE);
++ lua_pushvalue(L, lua_upvalueindex(1)); /* return generator, */
++ lua_pushvalue(L, 1); /* state, */
++ lua_pushnil(L); /* and initial value */
++ return 3;
++}
++
++
++static int ipairsaux (lua_State *L) {
++ int i = luaL_checkint(L, 2);
++ luaL_checktype(L, 1, LUA_TTABLE);
++ i++; /* next value */
++ lua_pushinteger(L, i);
++ lua_rawgeti(L, 1, i);
++ return (lua_isnil(L, -1)) ? 0 : 2;
++}
++
++
++static int luaB_ipairs (lua_State *L) {
++ luaL_checktype(L, 1, LUA_TTABLE);
++ lua_pushvalue(L, lua_upvalueindex(1)); /* return generator, */
++ lua_pushvalue(L, 1); /* state, */
++ lua_pushinteger(L, 0); /* and initial value */
++ return 3;
++}
++
++
++static int load_aux (lua_State *L, int status) {
++ if (status == 0) /* OK? */
++ return 1;
++ else {
++ lua_pushnil(L);
++ lua_insert(L, -2); /* put before error message */
++ return 2; /* return nil plus error message */
++ }
++}
++
++
++static int luaB_loadstring (lua_State *L) {
++ size_t l;
++ const char *s = luaL_checklstring(L, 1, &l);
++ const char *chunkname = luaL_optstring(L, 2, s);
++ return load_aux(L, luaL_loadbuffer(L, s, l, chunkname));
++}
++
++/*
++static int luaB_loadfile (lua_State *L) {
++ const char *fname = luaL_optstring(L, 1, NULL);
++ return load_aux(L, luaL_loadfile(L, fname));
++}
++*/
++
++/*
++** Reader for generic `load' function: `lua_load' uses the
++** stack for internal stuff, so the reader cannot change the
++** stack top. Instead, it keeps its resulting string in a
++** reserved slot inside the stack.
++*/
++static const char *generic_reader (lua_State *L, void *ud, size_t *size) {
++ (void)ud; /* to avoid warnings */
++ luaL_checkstack(L, 2, "too many nested functions");
++ lua_pushvalue(L, 1); /* get function */
++ lua_call(L, 0, 1); /* call it */
++ if (lua_isnil(L, -1)) {
++ *size = 0;
++ return NULL;
++ }
++ else if (lua_isstring(L, -1)) {
++ lua_replace(L, 3); /* save string in a reserved stack slot */
++ return lua_tolstring(L, 3, size);
++ }
++ else luaL_error(L, "reader function must return a string");
++ return NULL; /* to avoid warnings */
++}
++
++
++static int luaB_load (lua_State *L) {
++ int status;
++ const char *cname = luaL_optstring(L, 2, "=(load)");
++ luaL_checktype(L, 1, LUA_TFUNCTION);
++ lua_settop(L, 3); /* function, eventual name, plus one reserved slot */
++ status = lua_load(L, generic_reader, NULL, cname);
++ return load_aux(L, status);
++}
++
++/*
++static int luaB_dofile (lua_State *L) {
++ const char *fname = luaL_optstring(L, 1, NULL);
++ int n = lua_gettop(L);
++ if (luaL_loadfile(L, fname) != 0) lua_error(L);
++ lua_call(L, 0, LUA_MULTRET);
++ return lua_gettop(L) - n;
++}
++*/
++
++static int luaB_assert (lua_State *L) {
++ luaL_checkany(L, 1);
++ if (!lua_toboolean(L, 1))
++ return luaL_error(L, "%s", luaL_optstring(L, 2, "assertion failed!"));
++ return lua_gettop(L);
++}
++
++
++static int luaB_unpack (lua_State *L) {
++ int i, e, n;
++ luaL_checktype(L, 1, LUA_TTABLE);
++ i = luaL_optint(L, 2, 1);
++ e = luaL_opt(L, luaL_checkint, 3, luaL_getn(L, 1));
++ if (i > e) return 0; /* empty range */
++ n = e - i + 1; /* number of elements */
++ if (n <= 0 || !lua_checkstack(L, n)) /* n <= 0 means arith. overflow */
++ return luaL_error(L, "too many results to unpack");
++ lua_rawgeti(L, 1, i); /* push arg[i] (avoiding overflow problems) */
++ while (i++ < e) /* push arg[i + 1...e] */
++ lua_rawgeti(L, 1, i);
++ return n;
++}
++
++
++static int luaB_select (lua_State *L) {
++ int n = lua_gettop(L);
++ if (lua_type(L, 1) == LUA_TSTRING && *lua_tostring(L, 1) == '#') {
++ lua_pushinteger(L, n-1);
++ return 1;
++ }
++ else {
++ int i = luaL_checkint(L, 1);
++ if (i < 0) i = n + i;
++ else if (i > n) i = n;
++ luaL_argcheck(L, 1 <= i, 1, "index out of range");
++ return n - i;
++ }
++}
++
++
++static int luaB_pcall (lua_State *L) {
++ int status;
++ luaL_checkany(L, 1);
++ status = lua_pcall(L, lua_gettop(L) - 1, LUA_MULTRET, 0);
++ lua_pushboolean(L, (status == 0));
++ lua_insert(L, 1);
++ return lua_gettop(L); /* return status + all results */
++}
++
++
++static int luaB_xpcall (lua_State *L) {
++ int status;
++ luaL_checkany(L, 2);
++ lua_settop(L, 2);
++ lua_insert(L, 1); /* put error function under function to be called */
++ status = lua_pcall(L, 0, LUA_MULTRET, 1);
++ lua_pushboolean(L, (status == 0));
++ lua_replace(L, 1);
++ return lua_gettop(L); /* return status + all results */
++}
++
++
++static int luaB_tostring (lua_State *L) {
++ luaL_checkany(L, 1);
++ if (luaL_callmeta(L, 1, "__tostring")) /* is there a metafield? */
++ return 1; /* use its value */
++ switch (lua_type(L, 1)) {
++ case LUA_TNUMBER:
++ lua_pushstring(L, lua_tostring(L, 1));
++ break;
++ case LUA_TSTRING:
++ lua_pushvalue(L, 1);
++ break;
++ case LUA_TBOOLEAN:
++ lua_pushstring(L, (lua_toboolean(L, 1) ? "true" : "false"));
++ break;
++ case LUA_TNIL:
++ lua_pushliteral(L, "nil");
++ break;
++ default:
++ lua_pushfstring(L, "%s: %p", luaL_typename(L, 1), lua_topointer(L, 1));
++ break;
++ }
++ return 1;
++}
++
++
++static int luaB_newproxy (lua_State *L) {
++ lua_settop(L, 1);
++ lua_newuserdata(L, 0); /* create proxy */
++ if (lua_toboolean(L, 1) == 0)
++ return 1; /* no metatable */
++ else if (lua_isboolean(L, 1)) {
++ lua_newtable(L); /* create a new metatable `m' ... */
++ lua_pushvalue(L, -1); /* ... and mark `m' as a valid metatable */
++ lua_pushboolean(L, 1);
++ lua_rawset(L, lua_upvalueindex(1)); /* weaktable[m] = true */
++ }
++ else {
++ int validproxy = 0; /* to check if weaktable[metatable(u)] == true */
++ if (lua_getmetatable(L, 1)) {
++ lua_rawget(L, lua_upvalueindex(1));
++ validproxy = lua_toboolean(L, -1);
++ lua_pop(L, 1); /* remove value */
++ }
++ luaL_argcheck(L, validproxy, 1, "boolean or proxy expected");
++ lua_getmetatable(L, 1); /* metatable is valid; get it */
++ }
++ lua_setmetatable(L, 2);
++ return 1;
++}
++
++
++static const luaL_Reg base_funcs[] = {
++ {"assert", luaB_assert},
++ {"collectgarbage", luaB_collectgarbage},
++// {"dofile", luaB_dofile},
++ {"error", luaB_error},
++ {"gcinfo", luaB_gcinfo},
++ {"getfenv", luaB_getfenv},
++ {"getmetatable", luaB_getmetatable},
++// {"loadfile", luaB_loadfile},
++ {"load", luaB_load},
++ {"loadstring", luaB_loadstring},
++ {"next", luaB_next},
++ {"pcall", luaB_pcall},
++ {"print", luaB_print},
++ {"rawequal", luaB_rawequal},
++ {"rawget", luaB_rawget},
++ {"rawset", luaB_rawset},
++ {"select", luaB_select},
++ {"setfenv", luaB_setfenv},
++ {"setmetatable", luaB_setmetatable},
++ {"tonumber", luaB_tonumber},
++ {"tostring", luaB_tostring},
++ {"type", luaB_type},
++ {"unpack", luaB_unpack},
++ {"xpcall", luaB_xpcall},
++ {NULL, NULL}
++};
++
++
++/*
++** {======================================================
++** Coroutine library
++** =======================================================
++*/
++
++#define CO_RUN 0 /* running */
++#define CO_SUS 1 /* suspended */
++#define CO_NOR 2 /* 'normal' (it resumed another coroutine) */
++#define CO_DEAD 3
++
++static const char *const statnames[] =
++ {"running", "suspended", "normal", "dead"};
++
++static int costatus (lua_State *L, lua_State *co) {
++ if (L == co) return CO_RUN;
++ switch (lua_status(co)) {
++ case LUA_YIELD:
++ return CO_SUS;
++ case 0: {
++ lua_Debug ar;
++ if (lua_getstack(co, 0, &ar) > 0) /* does it have frames? */
++ return CO_NOR; /* it is running */
++ else if (lua_gettop(co) == 0)
++ return CO_DEAD;
++ else
++ return CO_SUS; /* initial state */
++ }
++ default: /* some error occured */
++ return CO_DEAD;
++ }
++}
++
++
++static int luaB_costatus (lua_State *L) {
++ lua_State *co = lua_tothread(L, 1);
++ luaL_argcheck(L, co, 1, "coroutine expected");
++ lua_pushstring(L, statnames[costatus(L, co)]);
++ return 1;
++}
++
++
++static int auxresume (lua_State *L, lua_State *co, int narg) {
++ int status = costatus(L, co);
++ if (!lua_checkstack(co, narg))
++ luaL_error(L, "too many arguments to resume");
++ if (status != CO_SUS) {
++ lua_pushfstring(L, "cannot resume %s coroutine", statnames[status]);
++ return -1; /* error flag */
++ }
++ lua_xmove(L, co, narg);
++ lua_setlevel(L, co);
++ status = lua_resume(co, narg);
++ if (status == 0 || status == LUA_YIELD) {
++ int nres = lua_gettop(co);
++ if (!lua_checkstack(L, nres + 1))
++ luaL_error(L, "too many results to resume");
++ lua_xmove(co, L, nres); /* move yielded values */
++ return nres;
++ }
++ else {
++ lua_xmove(co, L, 1); /* move error message */
++ return -1; /* error flag */
++ }
++}
++
++
++static int luaB_coresume (lua_State *L) {
++ lua_State *co = lua_tothread(L, 1);
++ int r;
++ luaL_argcheck(L, co, 1, "coroutine expected");
++ r = auxresume(L, co, lua_gettop(L) - 1);
++ if (r < 0) {
++ lua_pushboolean(L, 0);
++ lua_insert(L, -2);
++ return 2; /* return false + error message */
++ }
++ else {
++ lua_pushboolean(L, 1);
++ lua_insert(L, -(r + 1));
++ return r + 1; /* return true + `resume' returns */
++ }
++}
++
++
++static int luaB_auxwrap (lua_State *L) {
++ lua_State *co = lua_tothread(L, lua_upvalueindex(1));
++ int r = auxresume(L, co, lua_gettop(L));
++ if (r < 0) {
++ if (lua_isstring(L, -1)) { /* error object is a string? */
++ luaL_where(L, 1); /* add extra info */
++ lua_insert(L, -2);
++ lua_concat(L, 2);
++ }
++ lua_error(L); /* propagate error */
++ }
++ return r;
++}
++
++
++static int luaB_cocreate (lua_State *L) {
++ lua_State *NL = lua_newthread(L);
++ luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), 1,
++ "Lua function expected");
++ lua_pushvalue(L, 1); /* move function to top */
++ lua_xmove(L, NL, 1); /* move function from L to NL */
++ return 1;
++}
++
++
++static int luaB_cowrap (lua_State *L) {
++ luaB_cocreate(L);
++ lua_pushcclosure(L, luaB_auxwrap, 1);
++ return 1;
++}
++
++
++static int luaB_yield (lua_State *L) {
++ return lua_yield(L, lua_gettop(L));
++}
++
++
++static int luaB_corunning (lua_State *L) {
++ if (lua_pushthread(L))
++ lua_pushnil(L); /* main thread is not a coroutine */
++ return 1;
++}
++
++
++static const luaL_Reg co_funcs[] = {
++ {"create", luaB_cocreate},
++ {"resume", luaB_coresume},
++ {"running", luaB_corunning},
++ {"status", luaB_costatus},
++ {"wrap", luaB_cowrap},
++ {"yield", luaB_yield},
++ {NULL, NULL}
++};
++
++/* }====================================================== */
++
++
++static void auxopen (lua_State *L, const char *name,
++ lua_CFunction f, lua_CFunction u) {
++ lua_pushcfunction(L, u);
++ lua_pushcclosure(L, f, 1);
++ lua_setfield(L, -2, name);
++}
++
++
++static void base_open (lua_State *L) {
++ /* set global _G */
++ lua_pushvalue(L, LUA_GLOBALSINDEX);
++ lua_setglobal(L, "_G");
++ /* open lib into global table */
++ luaL_register(L, "_G", base_funcs);
++ lua_pushliteral(L, LUA_VERSION);
++ lua_setglobal(L, "_VERSION"); /* set global _VERSION */
++ /* `ipairs' and `pairs' need auxliliary functions as upvalues */
++ auxopen(L, "ipairs", luaB_ipairs, ipairsaux);
++ auxopen(L, "pairs", luaB_pairs, luaB_next);
++ /* `newproxy' needs a weaktable as upvalue */
++ lua_createtable(L, 0, 1); /* new table `w' */
++ lua_pushvalue(L, -1); /* `w' will be its own metatable */
++ lua_setmetatable(L, -2);
++ lua_pushliteral(L, "kv");
++ lua_setfield(L, -2, "__mode"); /* metatable(w).__mode = "kv" */
++ lua_pushcclosure(L, luaB_newproxy, 1);
++ lua_setglobal(L, "newproxy"); /* set global `newproxy' */
++}
++
++
++LUALIB_API int luaopen_base (lua_State *L) {
++ base_open(L);
++ luaL_register(L, LUA_COLIBNAME, co_funcs);
++ return 2;
++}
+--- /dev/null
++++ b/extensions/LUA/lua/lcode.c
+@@ -0,0 +1,838 @@
++/*
++** $Id: lcode.c,v 2.25.1.3 2007/12/28 15:32:23 roberto Exp $
++** Code generator for Lua
++** See Copyright Notice in lua.h
++*/
++
++#include <stdlib.h>
++
++#define lcode_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "lcode.h"
++#include "ldebug.h"
++#include "ldo.h"
++#include "lgc.h"
++#include "llex.h"
++#include "lmem.h"
++#include "lobject.h"
++#include "lopcodes.h"
++#include "lparser.h"
++#include "ltable.h"
++
++
++#define hasjumps(e) ((e)->t != (e)->f)
++
++
++static int isnumeral(expdesc *e) {
++ return (e->k == VKNUM && e->t == NO_JUMP && e->f == NO_JUMP);
++}
++
++
++void luaK_nil (FuncState *fs, int from, int n) {
++ Instruction *previous;
++ if (fs->pc > fs->lasttarget) { /* no jumps to current position? */
++ if (fs->pc == 0) { /* function start? */
++ if (from >= fs->nactvar)
++ return; /* positions are already clean */
++ }
++ else {
++ previous = &fs->f->code[fs->pc-1];
++ if (GET_OPCODE(*previous) == OP_LOADNIL) {
++ int pfrom = GETARG_A(*previous);
++ int pto = GETARG_B(*previous);
++ if (pfrom <= from && from <= pto+1) { /* can connect both? */
++ if (from+n-1 > pto)
++ SETARG_B(*previous, from+n-1);
++ return;
++ }
++ }
++ }
++ }
++ luaK_codeABC(fs, OP_LOADNIL, from, from+n-1, 0); /* else no optimization */
++}
++
++
++int luaK_jump (FuncState *fs) {
++ int jpc = fs->jpc; /* save list of jumps to here */
++ int j;
++ fs->jpc = NO_JUMP;
++ j = luaK_codeAsBx(fs, OP_JMP, 0, NO_JUMP);
++ luaK_concat(fs, &j, jpc); /* keep them on hold */
++ return j;
++}
++
++
++void luaK_ret (FuncState *fs, int first, int nret) {
++ luaK_codeABC(fs, OP_RETURN, first, nret+1, 0);
++}
++
++
++static int condjump (FuncState *fs, OpCode op, int A, int B, int C) {
++ luaK_codeABC(fs, op, A, B, C);
++ return luaK_jump(fs);
++}
++
++
++static void fixjump (FuncState *fs, int pc, int dest) {
++ Instruction *jmp = &fs->f->code[pc];
++ int offset = dest-(pc+1);
++ lua_assert(dest != NO_JUMP);
++ if (abs(offset) > MAXARG_sBx)
++ luaX_syntaxerror(fs->ls, "control structure too long");
++ SETARG_sBx(*jmp, offset);
++}
++
++
++/*
++** returns current `pc' and marks it as a jump target (to avoid wrong
++** optimizations with consecutive instructions not in the same basic block).
++*/
++int luaK_getlabel (FuncState *fs) {
++ fs->lasttarget = fs->pc;
++ return fs->pc;
++}
++
++
++static int getjump (FuncState *fs, int pc) {
++ int offset = GETARG_sBx(fs->f->code[pc]);
++ if (offset == NO_JUMP) /* point to itself represents end of list */
++ return NO_JUMP; /* end of list */
++ else
++ return (pc+1)+offset; /* turn offset into absolute position */
++}
++
++
++static Instruction *getjumpcontrol (FuncState *fs, int pc) {
++ Instruction *pi = &fs->f->code[pc];
++ if (pc >= 1 && testTMode(GET_OPCODE(*(pi-1))))
++ return pi-1;
++ else
++ return pi;
++}
++
++
++/*
++** check whether list has any jump that do not produce a value
++** (or produce an inverted value)
++*/
++static int need_value (FuncState *fs, int list) {
++ for (; list != NO_JUMP; list = getjump(fs, list)) {
++ Instruction i = *getjumpcontrol(fs, list);
++ if (GET_OPCODE(i) != OP_TESTSET) return 1;
++ }
++ return 0; /* not found */
++}
++
++
++static int patchtestreg (FuncState *fs, int node, int reg) {
++ Instruction *i = getjumpcontrol(fs, node);
++ if (GET_OPCODE(*i) != OP_TESTSET)
++ return 0; /* cannot patch other instructions */
++ if (reg != NO_REG && reg != GETARG_B(*i))
++ SETARG_A(*i, reg);
++ else /* no register to put value or register already has the value */
++ *i = CREATE_ABC(OP_TEST, GETARG_B(*i), 0, GETARG_C(*i));
++
++ return 1;
++}
++
++
++static void removevalues (FuncState *fs, int list) {
++ for (; list != NO_JUMP; list = getjump(fs, list))
++ patchtestreg(fs, list, NO_REG);
++}
++
++
++static void patchlistaux (FuncState *fs, int list, int vtarget, int reg,
++ int dtarget) {
++ while (list != NO_JUMP) {
++ int next = getjump(fs, list);
++ if (patchtestreg(fs, list, reg))
++ fixjump(fs, list, vtarget);
++ else
++ fixjump(fs, list, dtarget); /* jump to default target */
++ list = next;
++ }
++}
++
++
++static void dischargejpc (FuncState *fs) {
++ patchlistaux(fs, fs->jpc, fs->pc, NO_REG, fs->pc);
++ fs->jpc = NO_JUMP;
++}
++
++
++void luaK_patchlist (FuncState *fs, int list, int target) {
++ if (target == fs->pc)
++ luaK_patchtohere(fs, list);
++ else {
++ lua_assert(target < fs->pc);
++ patchlistaux(fs, list, target, NO_REG, target);
++ }
++}
++
++
++void luaK_patchtohere (FuncState *fs, int list) {
++ luaK_getlabel(fs);
++ luaK_concat(fs, &fs->jpc, list);
++}
++
++
++void luaK_concat (FuncState *fs, int *l1, int l2) {
++ if (l2 == NO_JUMP) return;
++ else if (*l1 == NO_JUMP)
++ *l1 = l2;
++ else {
++ int list = *l1;
++ int next;
++ while ((next = getjump(fs, list)) != NO_JUMP) /* find last element */
++ list = next;
++ fixjump(fs, list, l2);
++ }
++}
++
++
++void luaK_checkstack (FuncState *fs, int n) {
++ int newstack = fs->freereg + n;
++ if (newstack > fs->f->maxstacksize) {
++ if (newstack >= MAXSTACK)
++ luaX_syntaxerror(fs->ls, "function or expression too complex");
++ fs->f->maxstacksize = cast_byte(newstack);
++ }
++}
++
++
++void luaK_reserveregs (FuncState *fs, int n) {
++ luaK_checkstack(fs, n);
++ fs->freereg += n;
++}
++
++
++static void freereg (FuncState *fs, int reg) {
++ if (!ISK(reg) && reg >= fs->nactvar) {
++ fs->freereg--;
++ lua_assert(reg == fs->freereg);
++ }
++}
++
++
++static void freeexp (FuncState *fs, expdesc *e) {
++ if (e->k == VNONRELOC)
++ freereg(fs, e->u.s.info);
++}
++
++
++static int addk (FuncState *fs, TValue *k, TValue *v) {
++ lua_State *L = fs->L;
++ TValue *idx = luaH_set(L, fs->h, k);
++ Proto *f = fs->f;
++ int oldsize = f->sizek;
++ if (ttisnumber(idx)) {
++ lua_assert(luaO_rawequalObj(&fs->f->k[cast_int(nvalue(idx))], v));
++ return cast_int(nvalue(idx));
++ }
++ else { /* constant not found; create a new entry */
++ setnvalue(idx, cast_num(fs->nk));
++ luaM_growvector(L, f->k, fs->nk, f->sizek, TValue,
++ MAXARG_Bx, "constant table overflow");
++ while (oldsize < f->sizek) setnilvalue(&f->k[oldsize++]);
++ setobj(L, &f->k[fs->nk], v);
++ luaC_barrier(L, f, v);
++ return fs->nk++;
++ }
++}
++
++
++int luaK_stringK (FuncState *fs, TString *s) {
++ TValue o;
++ setsvalue(fs->L, &o, s);
++ return addk(fs, &o, &o);
++}
++
++
++int luaK_numberK (FuncState *fs, lua_Number r) {
++ TValue o;
++ setnvalue(&o, r);
++ return addk(fs, &o, &o);
++}
++
++
++static int boolK (FuncState *fs, int b) {
++ TValue o;
++ setbvalue(&o, b);
++ return addk(fs, &o, &o);
++}
++
++
++static int nilK (FuncState *fs) {
++ TValue k, v;
++ setnilvalue(&v);
++ /* cannot use nil as key; instead use table itself to represent nil */
++ sethvalue(fs->L, &k, fs->h);
++ return addk(fs, &k, &v);
++}
++
++
++void luaK_setreturns (FuncState *fs, expdesc *e, int nresults) {
++ if (e->k == VCALL) { /* expression is an open function call? */
++ SETARG_C(getcode(fs, e), nresults+1);
++ }
++ else if (e->k == VVARARG) {
++ SETARG_B(getcode(fs, e), nresults+1);
++ SETARG_A(getcode(fs, e), fs->freereg);
++ luaK_reserveregs(fs, 1);
++ }
++}
++
++
++void luaK_setoneret (FuncState *fs, expdesc *e) {
++ if (e->k == VCALL) { /* expression is an open function call? */
++ e->k = VNONRELOC;
++ e->u.s.info = GETARG_A(getcode(fs, e));
++ }
++ else if (e->k == VVARARG) {
++ SETARG_B(getcode(fs, e), 2);
++ e->k = VRELOCABLE; /* can relocate its simple result */
++ }
++}
++
++
++void luaK_dischargevars (FuncState *fs, expdesc *e) {
++ switch (e->k) {
++ case VLOCAL: {
++ e->k = VNONRELOC;
++ break;
++ }
++ case VUPVAL: {
++ e->u.s.info = luaK_codeABC(fs, OP_GETUPVAL, 0, e->u.s.info, 0);
++ e->k = VRELOCABLE;
++ break;
++ }
++ case VGLOBAL: {
++ e->u.s.info = luaK_codeABx(fs, OP_GETGLOBAL, 0, e->u.s.info);
++ e->k = VRELOCABLE;
++ break;
++ }
++ case VINDEXED: {
++ freereg(fs, e->u.s.aux);
++ freereg(fs, e->u.s.info);
++ e->u.s.info = luaK_codeABC(fs, OP_GETTABLE, 0, e->u.s.info, e->u.s.aux);
++ e->k = VRELOCABLE;
++ break;
++ }
++ case VVARARG:
++ case VCALL: {
++ luaK_setoneret(fs, e);
++ break;
++ }
++ default: break; /* there is one value available (somewhere) */
++ }
++}
++
++
++static int code_label (FuncState *fs, int A, int b, int jump) {
++ luaK_getlabel(fs); /* those instructions may be jump targets */
++ return luaK_codeABC(fs, OP_LOADBOOL, A, b, jump);
++}
++
++
++static void discharge2reg (FuncState *fs, expdesc *e, int reg) {
++ luaK_dischargevars(fs, e);
++ switch (e->k) {
++ case VNIL: {
++ luaK_nil(fs, reg, 1);
++ break;
++ }
++ case VFALSE: case VTRUE: {
++ luaK_codeABC(fs, OP_LOADBOOL, reg, e->k == VTRUE, 0);
++ break;
++ }
++ case VK: {
++ luaK_codeABx(fs, OP_LOADK, reg, e->u.s.info);
++ break;
++ }
++ case VKNUM: {
++ luaK_codeABx(fs, OP_LOADK, reg, luaK_numberK(fs, e->u.nval));
++ break;
++ }
++ case VRELOCABLE: {
++ Instruction *pc = &getcode(fs, e);
++ SETARG_A(*pc, reg);
++ break;
++ }
++ case VNONRELOC: {
++ if (reg != e->u.s.info)
++ luaK_codeABC(fs, OP_MOVE, reg, e->u.s.info, 0);
++ break;
++ }
++ default: {
++ lua_assert(e->k == VVOID || e->k == VJMP);
++ return; /* nothing to do... */
++ }
++ }
++ e->u.s.info = reg;
++ e->k = VNONRELOC;
++}
++
++
++static void discharge2anyreg (FuncState *fs, expdesc *e) {
++ if (e->k != VNONRELOC) {
++ luaK_reserveregs(fs, 1);
++ discharge2reg(fs, e, fs->freereg-1);
++ }
++}
++
++
++static void exp2reg (FuncState *fs, expdesc *e, int reg) {
++ discharge2reg(fs, e, reg);
++ if (e->k == VJMP)
++ luaK_concat(fs, &e->t, e->u.s.info); /* put this jump in `t' list */
++ if (hasjumps(e)) {
++ int final; /* position after whole expression */
++ int p_f = NO_JUMP; /* position of an eventual LOAD false */
++ int p_t = NO_JUMP; /* position of an eventual LOAD true */
++ if (need_value(fs, e->t) || need_value(fs, e->f)) {
++ int fj = (e->k == VJMP) ? NO_JUMP : luaK_jump(fs);
++ p_f = code_label(fs, reg, 0, 1);
++ p_t = code_label(fs, reg, 1, 0);
++ luaK_patchtohere(fs, fj);
++ }
++ final = luaK_getlabel(fs);
++ patchlistaux(fs, e->f, final, reg, p_f);
++ patchlistaux(fs, e->t, final, reg, p_t);
++ }
++ e->f = e->t = NO_JUMP;
++ e->u.s.info = reg;
++ e->k = VNONRELOC;
++}
++
++
++void luaK_exp2nextreg (FuncState *fs, expdesc *e) {
++ luaK_dischargevars(fs, e);
++ freeexp(fs, e);
++ luaK_reserveregs(fs, 1);
++ exp2reg(fs, e, fs->freereg - 1);
++}
++
++
++int luaK_exp2anyreg (FuncState *fs, expdesc *e) {
++ luaK_dischargevars(fs, e);
++ if (e->k == VNONRELOC) {
++ if (!hasjumps(e)) return e->u.s.info; /* exp is already in a register */
++ if (e->u.s.info >= fs->nactvar) { /* reg. is not a local? */
++ exp2reg(fs, e, e->u.s.info); /* put value on it */
++ return e->u.s.info;
++ }
++ }
++ luaK_exp2nextreg(fs, e); /* default */
++ return e->u.s.info;
++}
++
++
++void luaK_exp2val (FuncState *fs, expdesc *e) {
++ if (hasjumps(e))
++ luaK_exp2anyreg(fs, e);
++ else
++ luaK_dischargevars(fs, e);
++}
++
++
++int luaK_exp2RK (FuncState *fs, expdesc *e) {
++ luaK_exp2val(fs, e);
++ switch (e->k) {
++ case VKNUM:
++ case VTRUE:
++ case VFALSE:
++ case VNIL: {
++ if (fs->nk <= MAXINDEXRK) { /* constant fit in RK operand? */
++ e->u.s.info = (e->k == VNIL) ? nilK(fs) :
++ (e->k == VKNUM) ? luaK_numberK(fs, e->u.nval) :
++ boolK(fs, (e->k == VTRUE));
++ e->k = VK;
++ return RKASK(e->u.s.info);
++ }
++ else break;
++ }
++ case VK: {
++ if (e->u.s.info <= MAXINDEXRK) /* constant fit in argC? */
++ return RKASK(e->u.s.info);
++ else break;
++ }
++ default: break;
++ }
++ /* not a constant in the right range: put it in a register */
++ return luaK_exp2anyreg(fs, e);
++}
++
++
++void luaK_storevar (FuncState *fs, expdesc *var, expdesc *ex) {
++ switch (var->k) {
++ case VLOCAL: {
++ freeexp(fs, ex);
++ exp2reg(fs, ex, var->u.s.info);
++ return;
++ }
++ case VUPVAL: {
++ int e = luaK_exp2anyreg(fs, ex);
++ luaK_codeABC(fs, OP_SETUPVAL, e, var->u.s.info, 0);
++ break;
++ }
++ case VGLOBAL: {
++ int e = luaK_exp2anyreg(fs, ex);
++ luaK_codeABx(fs, OP_SETGLOBAL, e, var->u.s.info);
++ break;
++ }
++ case VINDEXED: {
++ int e = luaK_exp2RK(fs, ex);
++ luaK_codeABC(fs, OP_SETTABLE, var->u.s.info, var->u.s.aux, e);
++ break;
++ }
++ default: {
++ lua_assert(0); /* invalid var kind to store */
++ break;
++ }
++ }
++ freeexp(fs, ex);
++}
++
++
++void luaK_self (FuncState *fs, expdesc *e, expdesc *key) {
++ int func;
++ luaK_exp2anyreg(fs, e);
++ freeexp(fs, e);
++ func = fs->freereg;
++ luaK_reserveregs(fs, 2);
++ luaK_codeABC(fs, OP_SELF, func, e->u.s.info, luaK_exp2RK(fs, key));
++ freeexp(fs, key);
++ e->u.s.info = func;
++ e->k = VNONRELOC;
++}
++
++
++static void invertjump (FuncState *fs, expdesc *e) {
++ Instruction *pc = getjumpcontrol(fs, e->u.s.info);
++ lua_assert(testTMode(GET_OPCODE(*pc)) && GET_OPCODE(*pc) != OP_TESTSET &&
++ GET_OPCODE(*pc) != OP_TEST);
++ SETARG_A(*pc, !(GETARG_A(*pc)));
++}
++
++
++static int jumponcond (FuncState *fs, expdesc *e, int cond) {
++ if (e->k == VRELOCABLE) {
++ Instruction ie = getcode(fs, e);
++ if (GET_OPCODE(ie) == OP_NOT) {
++ fs->pc--; /* remove previous OP_NOT */
++ return condjump(fs, OP_TEST, GETARG_B(ie), 0, !cond);
++ }
++ /* else go through */
++ }
++ discharge2anyreg(fs, e);
++ freeexp(fs, e);
++ return condjump(fs, OP_TESTSET, NO_REG, e->u.s.info, cond);
++}
++
++
++void luaK_goiftrue (FuncState *fs, expdesc *e) {
++ int pc; /* pc of last jump */
++ luaK_dischargevars(fs, e);
++ switch (e->k) {
++ case VK: case VKNUM: case VTRUE: {
++ pc = NO_JUMP; /* always true; do nothing */
++ break;
++ }
++ case VFALSE: {
++ pc = luaK_jump(fs); /* always jump */
++ break;
++ }
++ case VJMP: {
++ invertjump(fs, e);
++ pc = e->u.s.info;
++ break;
++ }
++ default: {
++ pc = jumponcond(fs, e, 0);
++ break;
++ }
++ }
++ luaK_concat(fs, &e->f, pc); /* insert last jump in `f' list */
++ luaK_patchtohere(fs, e->t);
++ e->t = NO_JUMP;
++}
++
++
++static void luaK_goiffalse (FuncState *fs, expdesc *e) {
++ int pc; /* pc of last jump */
++ luaK_dischargevars(fs, e);
++ switch (e->k) {
++ case VNIL: case VFALSE: {
++ pc = NO_JUMP; /* always false; do nothing */
++ break;
++ }
++ case VTRUE: {
++ pc = luaK_jump(fs); /* always jump */
++ break;
++ }
++ case VJMP: {
++ pc = e->u.s.info;
++ break;
++ }
++ default: {
++ pc = jumponcond(fs, e, 1);
++ break;
++ }
++ }
++ luaK_concat(fs, &e->t, pc); /* insert last jump in `t' list */
++ luaK_patchtohere(fs, e->f);
++ e->f = NO_JUMP;
++}
++
++
++static void codenot (FuncState *fs, expdesc *e) {
++ luaK_dischargevars(fs, e);
++ switch (e->k) {
++ case VNIL: case VFALSE: {
++ e->k = VTRUE;
++ break;
++ }
++ case VK: case VKNUM: case VTRUE: {
++ e->k = VFALSE;
++ break;
++ }
++ case VJMP: {
++ invertjump(fs, e);
++ break;
++ }
++ case VRELOCABLE:
++ case VNONRELOC: {
++ discharge2anyreg(fs, e);
++ freeexp(fs, e);
++ e->u.s.info = luaK_codeABC(fs, OP_NOT, 0, e->u.s.info, 0);
++ e->k = VRELOCABLE;
++ break;
++ }
++ default: {
++ lua_assert(0); /* cannot happen */
++ break;
++ }
++ }
++ /* interchange true and false lists */
++ { int temp = e->f; e->f = e->t; e->t = temp; }
++ removevalues(fs, e->f);
++ removevalues(fs, e->t);
++}
++
++
++void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) {
++ t->u.s.aux = luaK_exp2RK(fs, k);
++ t->k = VINDEXED;
++}
++
++
++static int constfolding (OpCode op, expdesc *e1, expdesc *e2) {
++ lua_Number v1, v2, r;
++ if (!isnumeral(e1) || !isnumeral(e2)) return 0;
++ v1 = e1->u.nval;
++ v2 = e2->u.nval;
++ switch (op) {
++ case OP_ADD: r = luai_numadd(v1, v2); break;
++ case OP_SUB: r = luai_numsub(v1, v2); break;
++ case OP_MUL: r = luai_nummul(v1, v2); break;
++ case OP_DIV:
++ if (v2 == 0) return 0; /* do not attempt to divide by 0 */
++ r = luai_numdiv(v1, v2); break;
++ case OP_MOD:
++ if (v2 == 0) return 0; /* do not attempt to divide by 0 */
++ r = luai_nummod(v1, v2); break;
++ case OP_POW: r = luai_numpow(v1, v2); break;
++ case OP_UNM: r = luai_numunm(v1); break;
++ case OP_LEN: return 0; /* no constant folding for 'len' */
++ default: lua_assert(0); r = 0; break;
++ }
++ if (luai_numisnan(r)) return 0; /* do not attempt to produce NaN */
++ e1->u.nval = r;
++ return 1;
++}
++
++
++static void codearith (FuncState *fs, OpCode op, expdesc *e1, expdesc *e2) {
++ if (constfolding(op, e1, e2))
++ return;
++ else {
++ int o2 = (op != OP_UNM && op != OP_LEN) ? luaK_exp2RK(fs, e2) : 0;
++ int o1 = luaK_exp2RK(fs, e1);
++ if (o1 > o2) {
++ freeexp(fs, e1);
++ freeexp(fs, e2);
++ }
++ else {
++ freeexp(fs, e2);
++ freeexp(fs, e1);
++ }
++ e1->u.s.info = luaK_codeABC(fs, op, 0, o1, o2);
++ e1->k = VRELOCABLE;
++ }
++}
++
++
++static void codecomp (FuncState *fs, OpCode op, int cond, expdesc *e1,
++ expdesc *e2) {
++ int o1 = luaK_exp2RK(fs, e1);
++ int o2 = luaK_exp2RK(fs, e2);
++ freeexp(fs, e2);
++ freeexp(fs, e1);
++ if (cond == 0 && op != OP_EQ) {
++ int temp; /* exchange args to replace by `<' or `<=' */
++ temp = o1; o1 = o2; o2 = temp; /* o1 <==> o2 */
++ cond = 1;
++ }
++ e1->u.s.info = condjump(fs, op, cond, o1, o2);
++ e1->k = VJMP;
++}
++
++
++void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e) {
++ expdesc e2;
++ e2.t = e2.f = NO_JUMP; e2.k = VKNUM; e2.u.nval = 0;
++ switch (op) {
++ case OPR_MINUS: {
++ if (!isnumeral(e))
++ luaK_exp2anyreg(fs, e); /* cannot operate on non-numeric constants */
++ codearith(fs, OP_UNM, e, &e2);
++ break;
++ }
++ case OPR_NOT: codenot(fs, e); break;
++ case OPR_LEN: {
++ luaK_exp2anyreg(fs, e); /* cannot operate on constants */
++ codearith(fs, OP_LEN, e, &e2);
++ break;
++ }
++ default: lua_assert(0);
++ }
++}
++
++
++void luaK_infix (FuncState *fs, BinOpr op, expdesc *v) {
++ switch (op) {
++ case OPR_AND: {
++ luaK_goiftrue(fs, v);
++ break;
++ }
++ case OPR_OR: {
++ luaK_goiffalse(fs, v);
++ break;
++ }
++ case OPR_CONCAT: {
++ luaK_exp2nextreg(fs, v); /* operand must be on the `stack' */
++ break;
++ }
++ case OPR_ADD: case OPR_SUB: case OPR_MUL: case OPR_DIV:
++ case OPR_MOD: case OPR_POW: {
++ if (!isnumeral(v)) luaK_exp2RK(fs, v);
++ break;
++ }
++ default: {
++ luaK_exp2RK(fs, v);
++ break;
++ }
++ }
++}
++
++
++void luaK_posfix (FuncState *fs, BinOpr op, expdesc *e1, expdesc *e2) {
++ switch (op) {
++ case OPR_AND: {
++ lua_assert(e1->t == NO_JUMP); /* list must be closed */
++ luaK_dischargevars(fs, e2);
++ luaK_concat(fs, &e2->f, e1->f);
++ *e1 = *e2;
++ break;
++ }
++ case OPR_OR: {
++ lua_assert(e1->f == NO_JUMP); /* list must be closed */
++ luaK_dischargevars(fs, e2);
++ luaK_concat(fs, &e2->t, e1->t);
++ *e1 = *e2;
++ break;
++ }
++ case OPR_CONCAT: {
++ luaK_exp2val(fs, e2);
++ if (e2->k == VRELOCABLE && GET_OPCODE(getcode(fs, e2)) == OP_CONCAT) {
++ lua_assert(e1->u.s.info == GETARG_B(getcode(fs, e2))-1);
++ freeexp(fs, e1);
++ SETARG_B(getcode(fs, e2), e1->u.s.info);
++ e1->k = VRELOCABLE; e1->u.s.info = e2->u.s.info;
++ }
++ else {
++ luaK_exp2nextreg(fs, e2); /* operand must be on the 'stack' */
++ codearith(fs, OP_CONCAT, e1, e2);
++ }
++ break;
++ }
++ case OPR_ADD: codearith(fs, OP_ADD, e1, e2); break;
++ case OPR_SUB: codearith(fs, OP_SUB, e1, e2); break;
++ case OPR_MUL: codearith(fs, OP_MUL, e1, e2); break;
++ case OPR_DIV: codearith(fs, OP_DIV, e1, e2); break;
++ case OPR_MOD: codearith(fs, OP_MOD, e1, e2); break;
++ case OPR_POW: codearith(fs, OP_POW, e1, e2); break;
++ case OPR_EQ: codecomp(fs, OP_EQ, 1, e1, e2); break;
++ case OPR_NE: codecomp(fs, OP_EQ, 0, e1, e2); break;
++ case OPR_LT: codecomp(fs, OP_LT, 1, e1, e2); break;
++ case OPR_LE: codecomp(fs, OP_LE, 1, e1, e2); break;
++ case OPR_GT: codecomp(fs, OP_LT, 0, e1, e2); break;
++ case OPR_GE: codecomp(fs, OP_LE, 0, e1, e2); break;
++ default: lua_assert(0);
++ }
++}
++
++
++void luaK_fixline (FuncState *fs, int line) {
++ fs->f->lineinfo[fs->pc - 1] = line;
++}
++
++
++static int luaK_code (FuncState *fs, Instruction i, int line) {
++ Proto *f = fs->f;
++ dischargejpc(fs); /* `pc' will change */
++ /* put new instruction in code array */
++ luaM_growvector(fs->L, f->code, fs->pc, f->sizecode, Instruction,
++ MAX_INT, "code size overflow");
++ f->code[fs->pc] = i;
++ /* save corresponding line information */
++ luaM_growvector(fs->L, f->lineinfo, fs->pc, f->sizelineinfo, int,
++ MAX_INT, "code size overflow");
++ f->lineinfo[fs->pc] = line;
++ return fs->pc++;
++}
++
++
++int luaK_codeABC (FuncState *fs, OpCode o, int a, int b, int c) {
++ lua_assert(getOpMode(o) == iABC);
++ lua_assert(getBMode(o) != OpArgN || b == 0);
++ lua_assert(getCMode(o) != OpArgN || c == 0);
++ return luaK_code(fs, CREATE_ABC(o, a, b, c), fs->ls->lastline);
++}
++
++
++int luaK_codeABx (FuncState *fs, OpCode o, int a, unsigned int bc) {
++ lua_assert(getOpMode(o) == iABx || getOpMode(o) == iAsBx);
++ lua_assert(getCMode(o) == OpArgN);
++ return luaK_code(fs, CREATE_ABx(o, a, bc), fs->ls->lastline);
++}
++
++
++void luaK_setlist (FuncState *fs, int base, int nelems, int tostore) {
++ int c = (nelems - 1)/LFIELDS_PER_FLUSH + 1;
++ int b = (tostore == LUA_MULTRET) ? 0 : tostore;
++ lua_assert(tostore != 0);
++ if (c <= MAXARG_C)
++ luaK_codeABC(fs, OP_SETLIST, base, b, c);
++ else {
++ luaK_codeABC(fs, OP_SETLIST, base, b, 0);
++ luaK_code(fs, cast(Instruction, c), fs->ls->lastline);
++ }
++ fs->freereg = base + 1; /* free registers with list values */
++}
++
+--- /dev/null
++++ b/extensions/LUA/lua/lcode.h
+@@ -0,0 +1,76 @@
++/*
++** $Id: lcode.h,v 1.48.1.1 2007/12/27 13:02:25 roberto Exp $
++** Code generator for Lua
++** See Copyright Notice in lua.h
++*/
++
++#ifndef lcode_h
++#define lcode_h
++
++#include "llex.h"
++#include "lobject.h"
++#include "lopcodes.h"
++#include "lparser.h"
++
++
++/*
++** Marks the end of a patch list. It is an invalid value both as an absolute
++** address, and as a list link (would link an element to itself).
++*/
++#define NO_JUMP (-1)
++
++
++/*
++** grep "ORDER OPR" if you change these enums
++*/
++typedef enum BinOpr {
++ OPR_ADD, OPR_SUB, OPR_MUL, OPR_DIV, OPR_MOD, OPR_POW,
++ OPR_CONCAT,
++ OPR_NE, OPR_EQ,
++ OPR_LT, OPR_LE, OPR_GT, OPR_GE,
++ OPR_AND, OPR_OR,
++ OPR_NOBINOPR
++} BinOpr;
++
++
++typedef enum UnOpr { OPR_MINUS, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr;
++
++
++#define getcode(fs,e) ((fs)->f->code[(e)->u.s.info])
++
++#define luaK_codeAsBx(fs,o,A,sBx) luaK_codeABx(fs,o,A,(sBx)+MAXARG_sBx)
++
++#define luaK_setmultret(fs,e) luaK_setreturns(fs, e, LUA_MULTRET)
++
++LUAI_FUNC int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bx);
++LUAI_FUNC int luaK_codeABC (FuncState *fs, OpCode o, int A, int B, int C);
++LUAI_FUNC void luaK_fixline (FuncState *fs, int line);
++LUAI_FUNC void luaK_nil (FuncState *fs, int from, int n);
++LUAI_FUNC void luaK_reserveregs (FuncState *fs, int n);
++LUAI_FUNC void luaK_checkstack (FuncState *fs, int n);
++LUAI_FUNC int luaK_stringK (FuncState *fs, TString *s);
++LUAI_FUNC int luaK_numberK (FuncState *fs, lua_Number r);
++LUAI_FUNC void luaK_dischargevars (FuncState *fs, expdesc *e);
++LUAI_FUNC int luaK_exp2anyreg (FuncState *fs, expdesc *e);
++LUAI_FUNC void luaK_exp2nextreg (FuncState *fs, expdesc *e);
++LUAI_FUNC void luaK_exp2val (FuncState *fs, expdesc *e);
++LUAI_FUNC int luaK_exp2RK (FuncState *fs, expdesc *e);
++LUAI_FUNC void luaK_self (FuncState *fs, expdesc *e, expdesc *key);
++LUAI_FUNC void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k);
++LUAI_FUNC void luaK_goiftrue (FuncState *fs, expdesc *e);
++LUAI_FUNC void luaK_storevar (FuncState *fs, expdesc *var, expdesc *e);
++LUAI_FUNC void luaK_setreturns (FuncState *fs, expdesc *e, int nresults);
++LUAI_FUNC void luaK_setoneret (FuncState *fs, expdesc *e);
++LUAI_FUNC int luaK_jump (FuncState *fs);
++LUAI_FUNC void luaK_ret (FuncState *fs, int first, int nret);
++LUAI_FUNC void luaK_patchlist (FuncState *fs, int list, int target);
++LUAI_FUNC void luaK_patchtohere (FuncState *fs, int list);
++LUAI_FUNC void luaK_concat (FuncState *fs, int *l1, int l2);
++LUAI_FUNC int luaK_getlabel (FuncState *fs);
++LUAI_FUNC void luaK_prefix (FuncState *fs, UnOpr op, expdesc *v);
++LUAI_FUNC void luaK_infix (FuncState *fs, BinOpr op, expdesc *v);
++LUAI_FUNC void luaK_posfix (FuncState *fs, BinOpr op, expdesc *v1, expdesc *v2);
++LUAI_FUNC void luaK_setlist (FuncState *fs, int base, int nelems, int tostore);
++
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/ldebug.c
+@@ -0,0 +1,637 @@
++/*
++** $Id: ldebug.c,v 2.29.1.6 2008/05/08 16:56:26 roberto Exp $
++** Debug Interface
++** See Copyright Notice in lua.h
++*/
++
++
++#include <stdarg.h>
++#include <stddef.h>
++#include <string.h>
++
++#define ldebug_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "lapi.h"
++#include "lcode.h"
++#include "ldebug.h"
++#include "ldo.h"
++#include "lfunc.h"
++#include "lobject.h"
++#include "lopcodes.h"
++#include "lstate.h"
++#include "lstring.h"
++#include "ltable.h"
++#include "ltm.h"
++#include "lvm.h"
++
++
++
++static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name);
++
++
++static int currentpc (lua_State *L, CallInfo *ci) {
++ if (!isLua(ci)) return -1; /* function is not a Lua function? */
++ if (ci == L->ci)
++ ci->savedpc = L->savedpc;
++ return pcRel(ci->savedpc, ci_func(ci)->l.p);
++}
++
++
++static int currentline (lua_State *L, CallInfo *ci) {
++ int pc = currentpc(L, ci);
++ if (pc < 0)
++ return -1; /* only active lua functions have current-line information */
++ else
++ return getline(ci_func(ci)->l.p, pc);
++}
++
++
++/*
++** this function can be called asynchronous (e.g. during a signal)
++*/
++LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count) {
++ if (func == NULL || mask == 0) { /* turn off hooks? */
++ mask = 0;
++ func = NULL;
++ }
++ L->hook = func;
++ L->basehookcount = count;
++ resethookcount(L);
++ L->hookmask = cast_byte(mask);
++ return 1;
++}
++
++
++LUA_API lua_Hook lua_gethook (lua_State *L) {
++ return L->hook;
++}
++
++
++LUA_API int lua_gethookmask (lua_State *L) {
++ return L->hookmask;
++}
++
++
++LUA_API int lua_gethookcount (lua_State *L) {
++ return L->basehookcount;
++}
++
++
++LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar) {
++ int status;
++ CallInfo *ci;
++ lua_lock(L);
++ for (ci = L->ci; level > 0 && ci > L->base_ci; ci--) {
++ level--;
++ if (f_isLua(ci)) /* Lua function? */
++ level -= ci->tailcalls; /* skip lost tail calls */
++ }
++ if (level == 0 && ci > L->base_ci) { /* level found? */
++ status = 1;
++ ar->i_ci = cast_int(ci - L->base_ci);
++ }
++ else if (level < 0) { /* level is of a lost tail call? */
++ status = 1;
++ ar->i_ci = 0;
++ }
++ else status = 0; /* no such level */
++ lua_unlock(L);
++ return status;
++}
++
++
++static Proto *getluaproto (CallInfo *ci) {
++ return (isLua(ci) ? ci_func(ci)->l.p : NULL);
++}
++
++
++static const char *findlocal (lua_State *L, CallInfo *ci, int n) {
++ const char *name;
++ Proto *fp = getluaproto(ci);
++ if (fp && (name = luaF_getlocalname(fp, n, currentpc(L, ci))) != NULL)
++ return name; /* is a local variable in a Lua function */
++ else {
++ StkId limit = (ci == L->ci) ? L->top : (ci+1)->func;
++ if (limit - ci->base >= n && n > 0) /* is 'n' inside 'ci' stack? */
++ return "(*temporary)";
++ else
++ return NULL;
++ }
++}
++
++
++LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) {
++ CallInfo *ci = L->base_ci + ar->i_ci;
++ const char *name = findlocal(L, ci, n);
++ lua_lock(L);
++ if (name)
++ luaA_pushobject(L, ci->base + (n - 1));
++ lua_unlock(L);
++ return name;
++}
++
++
++LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) {
++ CallInfo *ci = L->base_ci + ar->i_ci;
++ const char *name = findlocal(L, ci, n);
++ lua_lock(L);
++ if (name)
++ setobjs2s(L, ci->base + (n - 1), L->top - 1);
++ L->top--; /* pop value */
++ lua_unlock(L);
++ return name;
++}
++
++
++static void funcinfo (lua_Debug *ar, Closure *cl) {
++ if (cl->c.isC) {
++ ar->source = "=[C]";
++ ar->linedefined = -1;
++ ar->lastlinedefined = -1;
++ ar->what = "C";
++ }
++ else {
++ ar->source = getstr(cl->l.p->source);
++ ar->linedefined = cl->l.p->linedefined;
++ ar->lastlinedefined = cl->l.p->lastlinedefined;
++ ar->what = (ar->linedefined == 0) ? "main" : "Lua";
++ }
++ luaO_chunkid(ar->short_src, ar->source, LUA_IDSIZE);
++}
++
++
++static void info_tailcall (lua_Debug *ar) {
++ ar->name = ar->namewhat = "";
++ ar->what = "tail";
++ ar->lastlinedefined = ar->linedefined = ar->currentline = -1;
++ ar->source = "=(tail call)";
++ luaO_chunkid(ar->short_src, ar->source, LUA_IDSIZE);
++ ar->nups = 0;
++}
++
++
++static void collectvalidlines (lua_State *L, Closure *f) {
++ if (f == NULL || f->c.isC) {
++ setnilvalue(L->top);
++ }
++ else {
++ Table *t = luaH_new(L, 0, 0);
++ int *lineinfo = f->l.p->lineinfo;
++ int i;
++ for (i=0; i<f->l.p->sizelineinfo; i++)
++ setbvalue(luaH_setnum(L, t, lineinfo[i]), 1);
++ sethvalue(L, L->top, t);
++ }
++ incr_top(L);
++}
++
++
++static int auxgetinfo (lua_State *L, const char *what, lua_Debug *ar,
++ Closure *f, CallInfo *ci) {
++ int status = 1;
++ if (f == NULL) {
++ info_tailcall(ar);
++ return status;
++ }
++ for (; *what; what++) {
++ switch (*what) {
++ case 'S': {
++ funcinfo(ar, f);
++ break;
++ }
++ case 'l': {
++ ar->currentline = (ci) ? currentline(L, ci) : -1;
++ break;
++ }
++ case 'u': {
++ ar->nups = f->c.nupvalues;
++ break;
++ }
++ case 'n': {
++ ar->namewhat = (ci) ? getfuncname(L, ci, &ar->name) : NULL;
++ if (ar->namewhat == NULL) {
++ ar->namewhat = ""; /* not found */
++ ar->name = NULL;
++ }
++ break;
++ }
++ case 'L':
++ case 'f': /* handled by lua_getinfo */
++ break;
++ default: status = 0; /* invalid option */
++ }
++ }
++ return status;
++}
++
++
++LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) {
++ int status;
++ Closure *f = NULL;
++ CallInfo *ci = NULL;
++ lua_lock(L);
++ if (*what == '>') {
++ StkId func = L->top - 1;
++ luai_apicheck(L, ttisfunction(func));
++ what++; /* skip the '>' */
++ f = clvalue(func);
++ L->top--; /* pop function */
++ }
++ else if (ar->i_ci != 0) { /* no tail call? */
++ ci = L->base_ci + ar->i_ci;
++ lua_assert(ttisfunction(ci->func));
++ f = clvalue(ci->func);
++ }
++ status = auxgetinfo(L, what, ar, f, ci);
++ if (strchr(what, 'f')) {
++ if (f == NULL) setnilvalue(L->top);
++ else setclvalue(L, L->top, f);
++ incr_top(L);
++ }
++ if (strchr(what, 'L'))
++ collectvalidlines(L, f);
++ lua_unlock(L);
++ return status;
++}
++
++
++/*
++** {======================================================
++** Symbolic Execution and code checker
++** =======================================================
++*/
++
++#define check(x) if (!(x)) return 0;
++
++#define checkjump(pt,pc) check(0 <= pc && pc < pt->sizecode)
++
++#define checkreg(pt,reg) check((reg) < (pt)->maxstacksize)
++
++
++
++static int precheck (const Proto *pt) {
++ check(pt->maxstacksize <= MAXSTACK);
++ check(pt->numparams+(pt->is_vararg & VARARG_HASARG) <= pt->maxstacksize);
++ check(!(pt->is_vararg & VARARG_NEEDSARG) ||
++ (pt->is_vararg & VARARG_HASARG));
++ check(pt->sizeupvalues <= pt->nups);
++ check(pt->sizelineinfo == pt->sizecode || pt->sizelineinfo == 0);
++ check(pt->sizecode > 0 && GET_OPCODE(pt->code[pt->sizecode-1]) == OP_RETURN);
++ return 1;
++}
++
++
++#define checkopenop(pt,pc) luaG_checkopenop((pt)->code[(pc)+1])
++
++int luaG_checkopenop (Instruction i) {
++ switch (GET_OPCODE(i)) {
++ case OP_CALL:
++ case OP_TAILCALL:
++ case OP_RETURN:
++ case OP_SETLIST: {
++ check(GETARG_B(i) == 0);
++ return 1;
++ }
++ default: return 0; /* invalid instruction after an open call */
++ }
++}
++
++
++static int checkArgMode (const Proto *pt, int r, enum OpArgMask mode) {
++ switch (mode) {
++ case OpArgN: check(r == 0); break;
++ case OpArgU: break;
++ case OpArgR: checkreg(pt, r); break;
++ case OpArgK:
++ check(ISK(r) ? INDEXK(r) < pt->sizek : r < pt->maxstacksize);
++ break;
++ }
++ return 1;
++}
++
++
++static Instruction symbexec (const Proto *pt, int lastpc, int reg) {
++ int pc;
++ int last; /* stores position of last instruction that changed `reg' */
++ last = pt->sizecode-1; /* points to final return (a `neutral' instruction) */
++ check(precheck(pt));
++ for (pc = 0; pc < lastpc; pc++) {
++ Instruction i = pt->code[pc];
++ OpCode op = GET_OPCODE(i);
++ int a = GETARG_A(i);
++ int b = 0;
++ int c = 0;
++ check(op < NUM_OPCODES);
++ checkreg(pt, a);
++ switch (getOpMode(op)) {
++ case iABC: {
++ b = GETARG_B(i);
++ c = GETARG_C(i);
++ check(checkArgMode(pt, b, getBMode(op)));
++ check(checkArgMode(pt, c, getCMode(op)));
++ break;
++ }
++ case iABx: {
++ b = GETARG_Bx(i);
++ if (getBMode(op) == OpArgK) check(b < pt->sizek);
++ break;
++ }
++ case iAsBx: {
++ b = GETARG_sBx(i);
++ if (getBMode(op) == OpArgR) {
++ int dest = pc+1+b;
++ check(0 <= dest && dest < pt->sizecode);
++ if (dest > 0) {
++ int j;
++ /* check that it does not jump to a setlist count; this
++ is tricky, because the count from a previous setlist may
++ have the same value of an invalid setlist; so, we must
++ go all the way back to the first of them (if any) */
++ for (j = 0; j < dest; j++) {
++ Instruction d = pt->code[dest-1-j];
++ if (!(GET_OPCODE(d) == OP_SETLIST && GETARG_C(d) == 0)) break;
++ }
++ /* if 'j' is even, previous value is not a setlist (even if
++ it looks like one) */
++ check((j&1) == 0);
++ }
++ }
++ break;
++ }
++ }
++ if (testAMode(op)) {
++ if (a == reg) last = pc; /* change register `a' */
++ }
++ if (testTMode(op)) {
++ check(pc+2 < pt->sizecode); /* check skip */
++ check(GET_OPCODE(pt->code[pc+1]) == OP_JMP);
++ }
++ switch (op) {
++ case OP_LOADBOOL: {
++ if (c == 1) { /* does it jump? */
++ check(pc+2 < pt->sizecode); /* check its jump */
++ check(GET_OPCODE(pt->code[pc+1]) != OP_SETLIST ||
++ GETARG_C(pt->code[pc+1]) != 0);
++ }
++ break;
++ }
++ case OP_LOADNIL: {
++ if (a <= reg && reg <= b)
++ last = pc; /* set registers from `a' to `b' */
++ break;
++ }
++ case OP_GETUPVAL:
++ case OP_SETUPVAL: {
++ check(b < pt->nups);
++ break;
++ }
++ case OP_GETGLOBAL:
++ case OP_SETGLOBAL: {
++ check(ttisstring(&pt->k[b]));
++ break;
++ }
++ case OP_SELF: {
++ checkreg(pt, a+1);
++ if (reg == a+1) last = pc;
++ break;
++ }
++ case OP_CONCAT: {
++ check(b < c); /* at least two operands */
++ break;
++ }
++ case OP_TFORLOOP: {
++ check(c >= 1); /* at least one result (control variable) */
++ checkreg(pt, a+2+c); /* space for results */
++ if (reg >= a+2) last = pc; /* affect all regs above its base */
++ break;
++ }
++ case OP_FORLOOP:
++ case OP_FORPREP:
++ checkreg(pt, a+3);
++ /* go through */
++ case OP_JMP: {
++ int dest = pc+1+b;
++ /* not full check and jump is forward and do not skip `lastpc'? */
++ if (reg != NO_REG && pc < dest && dest <= lastpc)
++ pc += b; /* do the jump */
++ break;
++ }
++ case OP_CALL:
++ case OP_TAILCALL: {
++ if (b != 0) {
++ checkreg(pt, a+b-1);
++ }
++ c--; /* c = num. returns */
++ if (c == LUA_MULTRET) {
++ check(checkopenop(pt, pc));
++ }
++ else if (c != 0)
++ checkreg(pt, a+c-1);
++ if (reg >= a) last = pc; /* affect all registers above base */
++ break;
++ }
++ case OP_RETURN: {
++ b--; /* b = num. returns */
++ if (b > 0) checkreg(pt, a+b-1);
++ break;
++ }
++ case OP_SETLIST: {
++ if (b > 0) checkreg(pt, a + b);
++ if (c == 0) {
++ pc++;
++ check(pc < pt->sizecode - 1);
++ }
++ break;
++ }
++ case OP_CLOSURE: {
++ int nup, j;
++ check(b < pt->sizep);
++ nup = pt->p[b]->nups;
++ check(pc + nup < pt->sizecode);
++ for (j = 1; j <= nup; j++) {
++ OpCode op1 = GET_OPCODE(pt->code[pc + j]);
++ check(op1 == OP_GETUPVAL || op1 == OP_MOVE);
++ }
++ if (reg != NO_REG) /* tracing? */
++ pc += nup; /* do not 'execute' these pseudo-instructions */
++ break;
++ }
++ case OP_VARARG: {
++ check((pt->is_vararg & VARARG_ISVARARG) &&
++ !(pt->is_vararg & VARARG_NEEDSARG));
++ b--;
++ if (b == LUA_MULTRET) check(checkopenop(pt, pc));
++ checkreg(pt, a+b-1);
++ break;
++ }
++ default: break;
++ }
++ }
++ return pt->code[last];
++}
++
++#undef check
++#undef checkjump
++#undef checkreg
++
++/* }====================================================== */
++
++
++int luaG_checkcode (const Proto *pt) {
++ return (symbexec(pt, pt->sizecode, NO_REG) != 0);
++}
++
++
++static const char *kname (Proto *p, int c) {
++ if (ISK(c) && ttisstring(&p->k[INDEXK(c)]))
++ return svalue(&p->k[INDEXK(c)]);
++ else
++ return "?";
++}
++
++
++static const char *getobjname (lua_State *L, CallInfo *ci, int stackpos,
++ const char **name) {
++ if (isLua(ci)) { /* a Lua function? */
++ Proto *p = ci_func(ci)->l.p;
++ int pc = currentpc(L, ci);
++ Instruction i;
++ *name = luaF_getlocalname(p, stackpos+1, pc);
++ if (*name) /* is a local? */
++ return "local";
++ i = symbexec(p, pc, stackpos); /* try symbolic execution */
++ lua_assert(pc != -1);
++ switch (GET_OPCODE(i)) {
++ case OP_GETGLOBAL: {
++ int g = GETARG_Bx(i); /* global index */
++ lua_assert(ttisstring(&p->k[g]));
++ *name = svalue(&p->k[g]);
++ return "global";
++ }
++ case OP_MOVE: {
++ int a = GETARG_A(i);
++ int b = GETARG_B(i); /* move from `b' to `a' */
++ if (b < a)
++ return getobjname(L, ci, b, name); /* get name for `b' */
++ break;
++ }
++ case OP_GETTABLE: {
++ int k = GETARG_C(i); /* key index */
++ *name = kname(p, k);
++ return "field";
++ }
++ case OP_GETUPVAL: {
++ int u = GETARG_B(i); /* upvalue index */
++ *name = p->upvalues ? getstr(p->upvalues[u]) : "?";
++ return "upvalue";
++ }
++ case OP_SELF: {
++ int k = GETARG_C(i); /* key index */
++ *name = kname(p, k);
++ return "method";
++ }
++ default: break;
++ }
++ }
++ return NULL; /* no useful name found */
++}
++
++
++static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name) {
++ Instruction i;
++ if ((isLua(ci) && ci->tailcalls > 0) || !isLua(ci - 1))
++ return NULL; /* calling function is not Lua (or is unknown) */
++ ci--; /* calling function */
++ i = ci_func(ci)->l.p->code[currentpc(L, ci)];
++ if (GET_OPCODE(i) == OP_CALL || GET_OPCODE(i) == OP_TAILCALL ||
++ GET_OPCODE(i) == OP_TFORLOOP)
++ return getobjname(L, ci, GETARG_A(i), name);
++ else
++ return NULL; /* no useful name can be found */
++}
++
++
++/* only ANSI way to check whether a pointer points to an array */
++static int isinstack (CallInfo *ci, const TValue *o) {
++ StkId p;
++ for (p = ci->base; p < ci->top; p++)
++ if (o == p) return 1;
++ return 0;
++}
++
++
++void luaG_typeerror (lua_State *L, const TValue *o, const char *op) {
++ const char *name = NULL;
++ const char *t = luaT_typenames[ttype(o)];
++ const char *kind = (isinstack(L->ci, o)) ?
++ getobjname(L, L->ci, cast_int(o - L->base), &name) :
++ NULL;
++ if (kind)
++ luaG_runerror(L, "attempt to %s %s " LUA_QS " (a %s value)",
++ op, kind, name, t);
++ else
++ luaG_runerror(L, "attempt to %s a %s value", op, t);
++}
++
++
++void luaG_concaterror (lua_State *L, StkId p1, StkId p2) {
++ if (ttisstring(p1) || ttisnumber(p1)) p1 = p2;
++ lua_assert(!ttisstring(p1) && !ttisnumber(p1));
++ luaG_typeerror(L, p1, "concatenate");
++}
++
++
++void luaG_aritherror (lua_State *L, const TValue *p1, const TValue *p2) {
++ TValue temp;
++ if (luaV_tonumber(p1, &temp) == NULL)
++ p2 = p1; /* first operand is wrong */
++ luaG_typeerror(L, p2, "perform arithmetic on");
++}
++
++
++int luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2) {
++ const char *t1 = luaT_typenames[ttype(p1)];
++ const char *t2 = luaT_typenames[ttype(p2)];
++ if (t1[2] == t2[2])
++ luaG_runerror(L, "attempt to compare two %s values", t1);
++ else
++ luaG_runerror(L, "attempt to compare %s with %s", t1, t2);
++ return 0;
++}
++
++
++static void addinfo (lua_State *L, const char *msg) {
++ CallInfo *ci = L->ci;
++ if (isLua(ci)) { /* is Lua code? */
++ char buff[LUA_IDSIZE]; /* add file:line information */
++ int line = currentline(L, ci);
++ luaO_chunkid(buff, getstr(getluaproto(ci)->source), LUA_IDSIZE);
++ luaO_pushfstring(L, "%s:%d: %s", buff, line, msg);
++ }
++}
++
++
++void luaG_errormsg (lua_State *L) {
++ if (L->errfunc != 0) { /* is there an error handling function? */
++ StkId errfunc = restorestack(L, L->errfunc);
++ if (!ttisfunction(errfunc)) luaD_throw(L, LUA_ERRERR);
++ setobjs2s(L, L->top, L->top - 1); /* move argument */
++ setobjs2s(L, L->top - 1, errfunc); /* push function */
++ incr_top(L);
++ luaD_call(L, L->top - 2, 1); /* call it */
++ }
++ luaD_throw(L, LUA_ERRRUN);
++}
++
++
++void luaG_runerror (lua_State *L, const char *fmt, ...) {
++ va_list argp;
++ va_start(argp, fmt);
++ addinfo(L, luaO_pushvfstring(L, fmt, argp));
++ va_end(argp);
++ luaG_errormsg(L);
++}
++
+--- /dev/null
++++ b/extensions/LUA/lua/ldebug.h
+@@ -0,0 +1,33 @@
++/*
++** $Id: ldebug.h,v 2.3.1.1 2007/12/27 13:02:25 roberto Exp $
++** Auxiliary functions from Debug Interface module
++** See Copyright Notice in lua.h
++*/
++
++#ifndef ldebug_h
++#define ldebug_h
++
++
++#include "lstate.h"
++
++
++#define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1)
++
++#define getline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : 0)
++
++#define resethookcount(L) (L->hookcount = L->basehookcount)
++
++
++LUAI_FUNC void luaG_typeerror (lua_State *L, const TValue *o,
++ const char *opname);
++LUAI_FUNC void luaG_concaterror (lua_State *L, StkId p1, StkId p2);
++LUAI_FUNC void luaG_aritherror (lua_State *L, const TValue *p1,
++ const TValue *p2);
++LUAI_FUNC int luaG_ordererror (lua_State *L, const TValue *p1,
++ const TValue *p2);
++LUAI_FUNC void luaG_runerror (lua_State *L, const char *fmt, ...);
++LUAI_FUNC void luaG_errormsg (lua_State *L);
++LUAI_FUNC int luaG_checkcode (const Proto *pt);
++LUAI_FUNC int luaG_checkopenop (Instruction i);
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/ldo.c
+@@ -0,0 +1,515 @@
++/*
++** $Id: ldo.c,v 2.38.1.3 2008/01/18 22:31:22 roberto Exp $
++** Stack and Call structure of Lua
++** See Copyright Notice in lua.h
++*/
++
++#include <setjmp.h>
++#include <stdlib.h>
++#include <string.h>
++
++#define ldo_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "ldebug.h"
++#include "ldo.h"
++#include "lfunc.h"
++#include "lgc.h"
++#include "lmem.h"
++#include "lobject.h"
++#include "lopcodes.h"
++#include "lparser.h"
++#include "lstate.h"
++#include "lstring.h"
++#include "ltable.h"
++#include "ltm.h"
++#include "lundump.h"
++#include "lvm.h"
++#include "lzio.h"
++
++
++
++/*
++** {======================================================
++** Error-recovery functions
++** =======================================================
++*/
++
++
++/* chain list of long jump buffers */
++struct lua_longjmp {
++ struct lua_longjmp *previous;
++ luai_jmpbuf b;
++ volatile int status; /* error code */
++};
++
++
++void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop) {
++ switch (errcode) {
++ case LUA_ERRMEM: {
++ setsvalue2s(L, oldtop, luaS_newliteral(L, MEMERRMSG));
++ break;
++ }
++ case LUA_ERRERR: {
++ setsvalue2s(L, oldtop, luaS_newliteral(L, "error in error handling"));
++ break;
++ }
++ case LUA_ERRSYNTAX:
++ case LUA_ERRRUN: {
++ setobjs2s(L, oldtop, L->top - 1); /* error message on current top */
++ break;
++ }
++ }
++ L->top = oldtop + 1;
++}
++
++
++static void restore_stack_limit (lua_State *L) {
++ lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK - 1);
++ if (L->size_ci > LUAI_MAXCALLS) { /* there was an overflow? */
++ int inuse = cast_int(L->ci - L->base_ci);
++ if (inuse + 1 < LUAI_MAXCALLS) /* can `undo' overflow? */
++ luaD_reallocCI(L, LUAI_MAXCALLS);
++ }
++}
++
++
++static void resetstack (lua_State *L, int status) {
++ L->ci = L->base_ci;
++ L->base = L->ci->base;
++ luaF_close(L, L->base); /* close eventual pending closures */
++ luaD_seterrorobj(L, status, L->base);
++ L->nCcalls = L->baseCcalls;
++ L->allowhook = 1;
++ restore_stack_limit(L);
++ L->errfunc = 0;
++ L->errorJmp = NULL;
++}
++
++
++void luaD_throw (lua_State *L, int errcode) {
++ if (L->errorJmp) {
++ L->errorJmp->status = errcode;
++ LUAI_THROW(L, L->errorJmp);
++ }
++ else {
++ L->status = cast_byte(errcode);
++ if (G(L)->panic) {
++ resetstack(L, errcode);
++ lua_unlock(L);
++ G(L)->panic(L);
++ }
++ exit(EXIT_FAILURE);
++ }
++}
++
++
++int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) {
++ struct lua_longjmp lj;
++ lj.status = 0;
++ lj.previous = L->errorJmp; /* chain new error handler */
++ L->errorJmp = &lj;
++ LUAI_TRY(L, &lj,
++ (*f)(L, ud);
++ );
++ L->errorJmp = lj.previous; /* restore old error handler */
++ return lj.status;
++}
++
++/* }====================================================== */
++
++
++static void correctstack (lua_State *L, TValue *oldstack) {
++ CallInfo *ci;
++ GCObject *up;
++ L->top = (L->top - oldstack) + L->stack;
++ for (up = L->openupval; up != NULL; up = up->gch.next)
++ gco2uv(up)->v = (gco2uv(up)->v - oldstack) + L->stack;
++ for (ci = L->base_ci; ci <= L->ci; ci++) {
++ ci->top = (ci->top - oldstack) + L->stack;
++ ci->base = (ci->base - oldstack) + L->stack;
++ ci->func = (ci->func - oldstack) + L->stack;
++ }
++ L->base = (L->base - oldstack) + L->stack;
++}
++
++
++void luaD_reallocstack (lua_State *L, int newsize) {
++ TValue *oldstack = L->stack;
++ int realsize = newsize + 1 + EXTRA_STACK;
++ lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK - 1);
++ luaM_reallocvector(L, L->stack, L->stacksize, realsize, TValue);
++ L->stacksize = realsize;
++ L->stack_last = L->stack+newsize;
++ correctstack(L, oldstack);
++}
++
++
++void luaD_reallocCI (lua_State *L, int newsize) {
++ CallInfo *oldci = L->base_ci;
++ luaM_reallocvector(L, L->base_ci, L->size_ci, newsize, CallInfo);
++ L->size_ci = newsize;
++ L->ci = (L->ci - oldci) + L->base_ci;
++ L->end_ci = L->base_ci + L->size_ci - 1;
++}
++
++
++void luaD_growstack (lua_State *L, int n) {
++ if (n <= L->stacksize) /* double size is enough? */
++ luaD_reallocstack(L, 2*L->stacksize);
++ else
++ luaD_reallocstack(L, L->stacksize + n);
++}
++
++
++static CallInfo *growCI (lua_State *L) {
++ if (L->size_ci > LUAI_MAXCALLS) /* overflow while handling overflow? */
++ luaD_throw(L, LUA_ERRERR);
++ else {
++ luaD_reallocCI(L, 2*L->size_ci);
++ if (L->size_ci > LUAI_MAXCALLS)
++ luaG_runerror(L, "stack overflow");
++ }
++ return ++L->ci;
++}
++
++
++void luaD_callhook (lua_State *L, int event, int line) {
++ lua_Hook hook = L->hook;
++ if (hook && L->allowhook) {
++ ptrdiff_t top = savestack(L, L->top);
++ ptrdiff_t ci_top = savestack(L, L->ci->top);
++ lua_Debug ar;
++ ar.event = event;
++ ar.currentline = line;
++ if (event == LUA_HOOKTAILRET)
++ ar.i_ci = 0; /* tail call; no debug information about it */
++ else
++ ar.i_ci = cast_int(L->ci - L->base_ci);
++ luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */
++ L->ci->top = L->top + LUA_MINSTACK;
++ lua_assert(L->ci->top <= L->stack_last);
++ L->allowhook = 0; /* cannot call hooks inside a hook */
++ lua_unlock(L);
++ (*hook)(L, &ar);
++ lua_lock(L);
++ lua_assert(!L->allowhook);
++ L->allowhook = 1;
++ L->ci->top = restorestack(L, ci_top);
++ L->top = restorestack(L, top);
++ }
++}
++
++
++static StkId adjust_varargs (lua_State *L, Proto *p, int actual) {
++ int i;
++ int nfixargs = p->numparams;
++ Table *htab = NULL;
++ StkId base, fixed;
++ for (; actual < nfixargs; ++actual)
++ setnilvalue(L->top++);
++#if defined(LUA_COMPAT_VARARG)
++ if (p->is_vararg & VARARG_NEEDSARG) { /* compat. with old-style vararg? */
++ int nvar = actual - nfixargs; /* number of extra arguments */
++ lua_assert(p->is_vararg & VARARG_HASARG);
++ luaC_checkGC(L);
++ htab = luaH_new(L, nvar, 1); /* create `arg' table */
++ for (i=0; i<nvar; i++) /* put extra arguments into `arg' table */
++ setobj2n(L, luaH_setnum(L, htab, i+1), L->top - nvar + i);
++ /* store counter in field `n' */
++ setnvalue(luaH_setstr(L, htab, luaS_newliteral(L, "n")), cast_num(nvar));
++ }
++#endif
++ /* move fixed parameters to final position */
++ fixed = L->top - actual; /* first fixed argument */
++ base = L->top; /* final position of first argument */
++ for (i=0; i<nfixargs; i++) {
++ setobjs2s(L, L->top++, fixed+i);
++ setnilvalue(fixed+i);
++ }
++ /* add `arg' parameter */
++ if (htab) {
++ sethvalue(L, L->top++, htab);
++ lua_assert(iswhite(obj2gco(htab)));
++ }
++ return base;
++}
++
++
++static StkId tryfuncTM (lua_State *L, StkId func) {
++ const TValue *tm = luaT_gettmbyobj(L, func, TM_CALL);
++ StkId p;
++ ptrdiff_t funcr = savestack(L, func);
++ if (!ttisfunction(tm))
++ luaG_typeerror(L, func, "call");
++ /* Open a hole inside the stack at `func' */
++ for (p = L->top; p > func; p--) setobjs2s(L, p, p-1);
++ incr_top(L);
++ func = restorestack(L, funcr); /* previous call may change stack */
++ setobj2s(L, func, tm); /* tag method is the new function to be called */
++ return func;
++}
++
++
++
++#define inc_ci(L) \
++ ((L->ci == L->end_ci) ? growCI(L) : \
++ (condhardstacktests(luaD_reallocCI(L, L->size_ci)), ++L->ci))
++
++
++int luaD_precall (lua_State *L, StkId func, int nresults) {
++ LClosure *cl;
++ ptrdiff_t funcr;
++ if (!ttisfunction(func)) /* `func' is not a function? */
++ func = tryfuncTM(L, func); /* check the `function' tag method */
++ funcr = savestack(L, func);
++ cl = &clvalue(func)->l;
++ L->ci->savedpc = L->savedpc;
++ if (!cl->isC) { /* Lua function? prepare its call */
++ CallInfo *ci;
++ StkId st, base;
++ Proto *p = cl->p;
++ luaD_checkstack(L, p->maxstacksize);
++ func = restorestack(L, funcr);
++ if (!p->is_vararg) { /* no varargs? */
++ base = func + 1;
++ if (L->top > base + p->numparams)
++ L->top = base + p->numparams;
++ }
++ else { /* vararg function */
++ int nargs = cast_int(L->top - func) - 1;
++ base = adjust_varargs(L, p, nargs);
++ func = restorestack(L, funcr); /* previous call may change the stack */
++ }
++ ci = inc_ci(L); /* now `enter' new function */
++ ci->func = func;
++ L->base = ci->base = base;
++ ci->top = L->base + p->maxstacksize;
++ lua_assert(ci->top <= L->stack_last);
++ L->savedpc = p->code; /* starting point */
++ ci->tailcalls = 0;
++ ci->nresults = nresults;
++ for (st = L->top; st < ci->top; st++)
++ setnilvalue(st);
++ L->top = ci->top;
++ if (L->hookmask & LUA_MASKCALL) {
++ L->savedpc++; /* hooks assume 'pc' is already incremented */
++ luaD_callhook(L, LUA_HOOKCALL, -1);
++ L->savedpc--; /* correct 'pc' */
++ }
++ return PCRLUA;
++ }
++ else { /* if is a C function, call it */
++ CallInfo *ci;
++ int n;
++ luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */
++ ci = inc_ci(L); /* now `enter' new function */
++ ci->func = restorestack(L, funcr);
++ L->base = ci->base = ci->func + 1;
++ ci->top = L->top + LUA_MINSTACK;
++ lua_assert(ci->top <= L->stack_last);
++ ci->nresults = nresults;
++ if (L->hookmask & LUA_MASKCALL)
++ luaD_callhook(L, LUA_HOOKCALL, -1);
++ lua_unlock(L);
++ n = (*curr_func(L)->c.f)(L); /* do the actual call */
++ lua_lock(L);
++ if (n < 0) /* yielding? */
++ return PCRYIELD;
++ else {
++ luaD_poscall(L, L->top - n);
++ return PCRC;
++ }
++ }
++}
++
++
++static StkId callrethooks (lua_State *L, StkId firstResult) {
++ ptrdiff_t fr = savestack(L, firstResult); /* next call may change stack */
++ luaD_callhook(L, LUA_HOOKRET, -1);
++ if (f_isLua(L->ci)) { /* Lua function? */
++ while ((L->hookmask & LUA_MASKRET) && L->ci->tailcalls--) /* tail calls */
++ luaD_callhook(L, LUA_HOOKTAILRET, -1);
++ }
++ return restorestack(L, fr);
++}
++
++
++int luaD_poscall (lua_State *L, StkId firstResult) {
++ StkId res;
++ int wanted, i;
++ CallInfo *ci;
++ if (L->hookmask & LUA_MASKRET)
++ firstResult = callrethooks(L, firstResult);
++ ci = L->ci--;
++ res = ci->func; /* res == final position of 1st result */
++ wanted = ci->nresults;
++ L->base = (ci - 1)->base; /* restore base */
++ L->savedpc = (ci - 1)->savedpc; /* restore savedpc */
++ /* move results to correct place */
++ for (i = wanted; i != 0 && firstResult < L->top; i--)
++ setobjs2s(L, res++, firstResult++);
++ while (i-- > 0)
++ setnilvalue(res++);
++ L->top = res;
++ return (wanted - LUA_MULTRET); /* 0 iff wanted == LUA_MULTRET */
++}
++
++
++/*
++** Call a function (C or Lua). The function to be called is at *func.
++** The arguments are on the stack, right after the function.
++** When returns, all the results are on the stack, starting at the original
++** function position.
++*/
++void luaD_call (lua_State *L, StkId func, int nResults) {
++ if (++L->nCcalls >= LUAI_MAXCCALLS) {
++ if (L->nCcalls == LUAI_MAXCCALLS)
++ luaG_runerror(L, "C stack overflow");
++ else if (L->nCcalls >= (LUAI_MAXCCALLS + (LUAI_MAXCCALLS>>3)))
++ luaD_throw(L, LUA_ERRERR); /* error while handing stack error */
++ }
++ if (luaD_precall(L, func, nResults) == PCRLUA) /* is a Lua function? */
++ luaV_execute(L, 1); /* call it */
++ L->nCcalls--;
++ luaC_checkGC(L);
++}
++
++
++static void resume (lua_State *L, void *ud) {
++ StkId firstArg = cast(StkId, ud);
++ CallInfo *ci = L->ci;
++ if (L->status == 0) { /* start coroutine? */
++ lua_assert(ci == L->base_ci && firstArg > L->base);
++ if (luaD_precall(L, firstArg - 1, LUA_MULTRET) != PCRLUA)
++ return;
++ }
++ else { /* resuming from previous yield */
++ lua_assert(L->status == LUA_YIELD);
++ L->status = 0;
++ if (!f_isLua(ci)) { /* `common' yield? */
++ /* finish interrupted execution of `OP_CALL' */
++ lua_assert(GET_OPCODE(*((ci-1)->savedpc - 1)) == OP_CALL ||
++ GET_OPCODE(*((ci-1)->savedpc - 1)) == OP_TAILCALL);
++ if (luaD_poscall(L, firstArg)) /* complete it... */
++ L->top = L->ci->top; /* and correct top if not multiple results */
++ }
++ else /* yielded inside a hook: just continue its execution */
++ L->base = L->ci->base;
++ }
++ luaV_execute(L, cast_int(L->ci - L->base_ci));
++}
++
++
++static int resume_error (lua_State *L, const char *msg) {
++ L->top = L->ci->base;
++ setsvalue2s(L, L->top, luaS_new(L, msg));
++ incr_top(L);
++ lua_unlock(L);
++ return LUA_ERRRUN;
++}
++
++
++LUA_API int lua_resume (lua_State *L, int nargs) {
++ int status;
++ lua_lock(L);
++ if (L->status != LUA_YIELD && (L->status != 0 || L->ci != L->base_ci))
++ return resume_error(L, "cannot resume non-suspended coroutine");
++ if (L->nCcalls >= LUAI_MAXCCALLS)
++ return resume_error(L, "C stack overflow");
++ luai_userstateresume(L, nargs);
++ lua_assert(L->errfunc == 0);
++ L->baseCcalls = ++L->nCcalls;
++ status = luaD_rawrunprotected(L, resume, L->top - nargs);
++ if (status != 0) { /* error? */
++ L->status = cast_byte(status); /* mark thread as `dead' */
++ luaD_seterrorobj(L, status, L->top);
++ L->ci->top = L->top;
++ }
++ else {
++ lua_assert(L->nCcalls == L->baseCcalls);
++ status = L->status;
++ }
++ --L->nCcalls;
++ lua_unlock(L);
++ return status;
++}
++
++
++LUA_API int lua_yield (lua_State *L, int nresults) {
++ luai_userstateyield(L, nresults);
++ lua_lock(L);
++ if (L->nCcalls > L->baseCcalls)
++ luaG_runerror(L, "attempt to yield across metamethod/C-call boundary");
++ L->base = L->top - nresults; /* protect stack slots below */
++ L->status = LUA_YIELD;
++ lua_unlock(L);
++ return -1;
++}
++
++
++int luaD_pcall (lua_State *L, Pfunc func, void *u,
++ ptrdiff_t old_top, ptrdiff_t ef) {
++ int status;
++ unsigned short oldnCcalls = L->nCcalls;
++ ptrdiff_t old_ci = saveci(L, L->ci);
++ lu_byte old_allowhooks = L->allowhook;
++ ptrdiff_t old_errfunc = L->errfunc;
++ L->errfunc = ef;
++ status = luaD_rawrunprotected(L, func, u);
++ if (status != 0) { /* an error occurred? */
++ StkId oldtop = restorestack(L, old_top);
++ luaF_close(L, oldtop); /* close eventual pending closures */
++ luaD_seterrorobj(L, status, oldtop);
++ L->nCcalls = oldnCcalls;
++ L->ci = restoreci(L, old_ci);
++ L->base = L->ci->base;
++ L->savedpc = L->ci->savedpc;
++ L->allowhook = old_allowhooks;
++ restore_stack_limit(L);
++ }
++ L->errfunc = old_errfunc;
++ return status;
++}
++
++
++
++/*
++** Execute a protected parser.
++*/
++struct SParser { /* data to `f_parser' */
++ ZIO *z;
++ Mbuffer buff; /* buffer to be used by the scanner */
++ const char *name;
++};
++
++static void f_parser (lua_State *L, void *ud) {
++ int i;
++ Proto *tf;
++ Closure *cl;
++ struct SParser *p = cast(struct SParser *, ud);
++ int c = luaZ_lookahead(p->z);
++ luaC_checkGC(L);
++ tf = ((c == LUA_SIGNATURE[0]) ? luaU_undump : luaY_parser)(L, p->z,
++ &p->buff, p->name);
++ cl = luaF_newLclosure(L, tf->nups, hvalue(gt(L)));
++ cl->l.p = tf;
++ for (i = 0; i < tf->nups; i++) /* initialize eventual upvalues */
++ cl->l.upvals[i] = luaF_newupval(L);
++ setclvalue(L, L->top, cl);
++ incr_top(L);
++}
++
++
++int luaD_protectedparser (lua_State *L, ZIO *z, const char *name) {
++ struct SParser p;
++ int status;
++ p.z = z; p.name = name;
++ luaZ_initbuffer(L, &p.buff);
++ status = luaD_pcall(L, f_parser, &p, savestack(L, L->top), L->errfunc);
++ luaZ_freebuffer(L, &p.buff);
++ return status;
++}
++
+--- /dev/null
++++ b/extensions/LUA/lua/ldo.h
+@@ -0,0 +1,57 @@
++/*
++** $Id: ldo.h,v 2.7.1.1 2007/12/27 13:02:25 roberto Exp $
++** Stack and Call structure of Lua
++** See Copyright Notice in lua.h
++*/
++
++#ifndef ldo_h
++#define ldo_h
++
++
++#include "lobject.h"
++#include "lstate.h"
++#include "lzio.h"
++
++
++#define luaD_checkstack(L,n) \
++ if ((char *)L->stack_last - (char *)L->top <= (n)*(int)sizeof(TValue)) \
++ luaD_growstack(L, n); \
++ else condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK - 1));
++
++
++#define incr_top(L) {luaD_checkstack(L,1); L->top++;}
++
++#define savestack(L,p) ((char *)(p) - (char *)L->stack)
++#define restorestack(L,n) ((TValue *)((char *)L->stack + (n)))
++
++#define saveci(L,p) ((char *)(p) - (char *)L->base_ci)
++#define restoreci(L,n) ((CallInfo *)((char *)L->base_ci + (n)))
++
++
++/* results from luaD_precall */
++#define PCRLUA 0 /* initiated a call to a Lua function */
++#define PCRC 1 /* did a call to a C function */
++#define PCRYIELD 2 /* C funtion yielded */
++
++
++/* type of protected functions, to be ran by `runprotected' */
++typedef void (*Pfunc) (lua_State *L, void *ud);
++
++LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name);
++LUAI_FUNC void luaD_callhook (lua_State *L, int event, int line);
++LUAI_FUNC int luaD_precall (lua_State *L, StkId func, int nresults);
++LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults);
++LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u,
++ ptrdiff_t oldtop, ptrdiff_t ef);
++LUAI_FUNC int luaD_poscall (lua_State *L, StkId firstResult);
++LUAI_FUNC void luaD_reallocCI (lua_State *L, int newsize);
++LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize);
++LUAI_FUNC void luaD_growstack (lua_State *L, int n);
++
++LUAI_FUNC void luaD_throw (lua_State *L, int errcode);
++LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud);
++
++LUAI_FUNC void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop);
++
++#endif
++
+--- /dev/null
++++ b/extensions/LUA/lua/ldump.c
+@@ -0,0 +1,164 @@
++/*
++** $Id: ldump.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $
++** save precompiled Lua chunks
++** See Copyright Notice in lua.h
++*/
++
++#include <stddef.h>
++
++#define ldump_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "lobject.h"
++#include "lstate.h"
++#include "lundump.h"
++
++typedef struct {
++ lua_State* L;
++ lua_Writer writer;
++ void* data;
++ int strip;
++ int status;
++} DumpState;
++
++#define DumpMem(b,n,size,D) DumpBlock(b,(n)*(size),D)
++#define DumpVar(x,D) DumpMem(&x,1,sizeof(x),D)
++
++static void DumpBlock(const void* b, size_t size, DumpState* D)
++{
++ if (D->status==0)
++ {
++ lua_unlock(D->L);
++ D->status=(*D->writer)(D->L,b,size,D->data);
++ lua_lock(D->L);
++ }
++}
++
++static void DumpChar(int y, DumpState* D)
++{
++ char x=(char)y;
++ DumpVar(x,D);
++}
++
++static void DumpInt(int x, DumpState* D)
++{
++ DumpVar(x,D);
++}
++
++static void DumpNumber(lua_Number x, DumpState* D)
++{
++ DumpVar(x,D);
++}
++
++static void DumpVector(const void* b, int n, size_t size, DumpState* D)
++{
++ DumpInt(n,D);
++ DumpMem(b,n,size,D);
++}
++
++static void DumpString(const TString* s, DumpState* D)
++{
++ if (s==NULL || getstr(s)==NULL)
++ {
++ size_t size=0;
++ DumpVar(size,D);
++ }
++ else
++ {
++ size_t size=s->tsv.len+1; /* include trailing '\0' */
++ DumpVar(size,D);
++ DumpBlock(getstr(s),size,D);
++ }
++}
++
++#define DumpCode(f,D) DumpVector(f->code,f->sizecode,sizeof(Instruction),D)
++
++static void DumpFunction(const Proto* f, const TString* p, DumpState* D);
++
++static void DumpConstants(const Proto* f, DumpState* D)
++{
++ int i,n=f->sizek;
++ DumpInt(n,D);
++ for (i=0; i<n; i++)
++ {
++ const TValue* o=&f->k[i];
++ DumpChar(ttype(o),D);
++ switch (ttype(o))
++ {
++ case LUA_TNIL:
++ break;
++ case LUA_TBOOLEAN:
++ DumpChar(bvalue(o),D);
++ break;
++ case LUA_TNUMBER:
++ DumpNumber(nvalue(o),D);
++ break;
++ case LUA_TSTRING:
++ DumpString(rawtsvalue(o),D);
++ break;
++ default:
++ lua_assert(0); /* cannot happen */
++ break;
++ }
++ }
++ n=f->sizep;
++ DumpInt(n,D);
++ for (i=0; i<n; i++) DumpFunction(f->p[i],f->source,D);
++}
++
++static void DumpDebug(const Proto* f, DumpState* D)
++{
++ int i,n;
++ n= (D->strip) ? 0 : f->sizelineinfo;
++ DumpVector(f->lineinfo,n,sizeof(int),D);
++ n= (D->strip) ? 0 : f->sizelocvars;
++ DumpInt(n,D);
++ for (i=0; i<n; i++)
++ {
++ DumpString(f->locvars[i].varname,D);
++ DumpInt(f->locvars[i].startpc,D);
++ DumpInt(f->locvars[i].endpc,D);
++ }
++ n= (D->strip) ? 0 : f->sizeupvalues;
++ DumpInt(n,D);
++ for (i=0; i<n; i++) DumpString(f->upvalues[i],D);
++}
++
++static void DumpFunction(const Proto* f, const TString* p, DumpState* D)
++{
++ DumpString((f->source==p || D->strip) ? NULL : f->source,D);
++ DumpInt(f->linedefined,D);
++ DumpInt(f->lastlinedefined,D);
++ DumpChar(f->nups,D);
++ DumpChar(f->numparams,D);
++ DumpChar(f->is_vararg,D);
++ DumpChar(f->maxstacksize,D);
++ DumpCode(f,D);
++ DumpConstants(f,D);
++ DumpDebug(f,D);
++}
++
++static void DumpHeader(DumpState* D)
++{
++ char h[LUAC_HEADERSIZE];
++ luaU_header(h);
++ DumpBlock(h,LUAC_HEADERSIZE,D);
++}
++
++/*
++** dump Lua function as precompiled chunk
++*/
++int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip)
++{
++ DumpState D;
++ D.L=L;
++ D.writer=w;
++ D.data=data;
++ D.strip=strip;
++ D.status=0;
++ DumpHeader(&D);
++ DumpFunction(f,NULL,&D);
++ return D.status;
++}
+--- /dev/null
++++ b/extensions/LUA/lua/lfunc.c
+@@ -0,0 +1,174 @@
++/*
++** $Id: lfunc.c,v 2.12.1.2 2007/12/28 14:58:43 roberto Exp $
++** Auxiliary functions to manipulate prototypes and closures
++** See Copyright Notice in lua.h
++*/
++
++
++#include <stddef.h>
++
++#define lfunc_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "lfunc.h"
++#include "lgc.h"
++#include "lmem.h"
++#include "lobject.h"
++#include "lstate.h"
++
++
++
++Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e) {
++ Closure *c = cast(Closure *, luaM_malloc(L, sizeCclosure(nelems)));
++ luaC_link(L, obj2gco(c), LUA_TFUNCTION);
++ c->c.isC = 1;
++ c->c.env = e;
++ c->c.nupvalues = cast_byte(nelems);
++ return c;
++}
++
++
++Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e) {
++ Closure *c = cast(Closure *, luaM_malloc(L, sizeLclosure(nelems)));
++ luaC_link(L, obj2gco(c), LUA_TFUNCTION);
++ c->l.isC = 0;
++ c->l.env = e;
++ c->l.nupvalues = cast_byte(nelems);
++ while (nelems--) c->l.upvals[nelems] = NULL;
++ return c;
++}
++
++
++UpVal *luaF_newupval (lua_State *L) {
++ UpVal *uv = luaM_new(L, UpVal);
++ luaC_link(L, obj2gco(uv), LUA_TUPVAL);
++ uv->v = &uv->u.value;
++ setnilvalue(uv->v);
++ return uv;
++}
++
++
++UpVal *luaF_findupval (lua_State *L, StkId level) {
++ global_State *g = G(L);
++ GCObject **pp = &L->openupval;
++ UpVal *p;
++ UpVal *uv;
++ while (*pp != NULL && (p = ngcotouv(*pp))->v >= level) {
++ lua_assert(p->v != &p->u.value);
++ if (p->v == level) { /* found a corresponding upvalue? */
++ if (isdead(g, obj2gco(p))) /* is it dead? */
++ changewhite(obj2gco(p)); /* ressurect it */
++ return p;
++ }
++ pp = &p->next;
++ }
++ uv = luaM_new(L, UpVal); /* not found: create a new one */
++ uv->tt = LUA_TUPVAL;
++ uv->marked = luaC_white(g);
++ uv->v = level; /* current value lives in the stack */
++ uv->next = *pp; /* chain it in the proper position */
++ *pp = obj2gco(uv);
++ uv->u.l.prev = &g->uvhead; /* double link it in `uvhead' list */
++ uv->u.l.next = g->uvhead.u.l.next;
++ uv->u.l.next->u.l.prev = uv;
++ g->uvhead.u.l.next = uv;
++ lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv);
++ return uv;
++}
++
++
++static void unlinkupval (UpVal *uv) {
++ lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv);
++ uv->u.l.next->u.l.prev = uv->u.l.prev; /* remove from `uvhead' list */
++ uv->u.l.prev->u.l.next = uv->u.l.next;
++}
++
++
++void luaF_freeupval (lua_State *L, UpVal *uv) {
++ if (uv->v != &uv->u.value) /* is it open? */
++ unlinkupval(uv); /* remove from open list */
++ luaM_free(L, uv); /* free upvalue */
++}
++
++
++void luaF_close (lua_State *L, StkId level) {
++ UpVal *uv;
++ global_State *g = G(L);
++ while (L->openupval != NULL && (uv = ngcotouv(L->openupval))->v >= level) {
++ GCObject *o = obj2gco(uv);
++ lua_assert(!isblack(o) && uv->v != &uv->u.value);
++ L->openupval = uv->next; /* remove from `open' list */
++ if (isdead(g, o))
++ luaF_freeupval(L, uv); /* free upvalue */
++ else {
++ unlinkupval(uv);
++ setobj(L, &uv->u.value, uv->v);
++ uv->v = &uv->u.value; /* now current value lives here */
++ luaC_linkupval(L, uv); /* link upvalue into `gcroot' list */
++ }
++ }
++}
++
++
++Proto *luaF_newproto (lua_State *L) {
++ Proto *f = luaM_new(L, Proto);
++ luaC_link(L, obj2gco(f), LUA_TPROTO);
++ f->k = NULL;
++ f->sizek = 0;
++ f->p = NULL;
++ f->sizep = 0;
++ f->code = NULL;
++ f->sizecode = 0;
++ f->sizelineinfo = 0;
++ f->sizeupvalues = 0;
++ f->nups = 0;
++ f->upvalues = NULL;
++ f->numparams = 0;
++ f->is_vararg = 0;
++ f->maxstacksize = 0;
++ f->lineinfo = NULL;
++ f->sizelocvars = 0;
++ f->locvars = NULL;
++ f->linedefined = 0;
++ f->lastlinedefined = 0;
++ f->source = NULL;
++ return f;
++}
++
++
++void luaF_freeproto (lua_State *L, Proto *f) {
++ luaM_freearray(L, f->code, f->sizecode, Instruction);
++ luaM_freearray(L, f->p, f->sizep, Proto *);
++ luaM_freearray(L, f->k, f->sizek, TValue);
++ luaM_freearray(L, f->lineinfo, f->sizelineinfo, int);
++ luaM_freearray(L, f->locvars, f->sizelocvars, struct LocVar);
++ luaM_freearray(L, f->upvalues, f->sizeupvalues, TString *);
++ luaM_free(L, f);
++}
++
++
++void luaF_freeclosure (lua_State *L, Closure *c) {
++ int size = (c->c.isC) ? sizeCclosure(c->c.nupvalues) :
++ sizeLclosure(c->l.nupvalues);
++ luaM_freemem(L, c, size);
++}
++
++
++/*
++** Look for n-th local variable at line `line' in function `func'.
++** Returns NULL if not found.
++*/
++const char *luaF_getlocalname (const Proto *f, int local_number, int pc) {
++ int i;
++ for (i = 0; i<f->sizelocvars && f->locvars[i].startpc <= pc; i++) {
++ if (pc < f->locvars[i].endpc) { /* is variable active? */
++ local_number--;
++ if (local_number == 0)
++ return getstr(f->locvars[i].varname);
++ }
++ }
++ return NULL; /* not found */
++}
++
+--- /dev/null
++++ b/extensions/LUA/lua/lfunc.h
+@@ -0,0 +1,34 @@
++/*
++** $Id: lfunc.h,v 2.4.1.1 2007/12/27 13:02:25 roberto Exp $
++** Auxiliary functions to manipulate prototypes and closures
++** See Copyright Notice in lua.h
++*/
++
++#ifndef lfunc_h
++#define lfunc_h
++
++
++#include "lobject.h"
++
++
++#define sizeCclosure(n) (cast(int, sizeof(CClosure)) + \
++ cast(int, sizeof(TValue)*((n)-1)))
++
++#define sizeLclosure(n) (cast(int, sizeof(LClosure)) + \
++ cast(int, sizeof(TValue *)*((n)-1)))
++
++
++LUAI_FUNC Proto *luaF_newproto (lua_State *L);
++LUAI_FUNC Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e);
++LUAI_FUNC Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e);
++LUAI_FUNC UpVal *luaF_newupval (lua_State *L);
++LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level);
++LUAI_FUNC void luaF_close (lua_State *L, StkId level);
++LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f);
++LUAI_FUNC void luaF_freeclosure (lua_State *L, Closure *c);
++LUAI_FUNC void luaF_freeupval (lua_State *L, UpVal *uv);
++LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number,
++ int pc);
++
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/lgc.c
+@@ -0,0 +1,711 @@
++/*
++** $Id: lgc.c,v 2.38.1.1 2007/12/27 13:02:25 roberto Exp $
++** Garbage Collector
++** See Copyright Notice in lua.h
++*/
++
++#include <string.h>
++
++#define lgc_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "ldebug.h"
++#include "ldo.h"
++#include "lfunc.h"
++#include "lgc.h"
++#include "lmem.h"
++#include "lobject.h"
++#include "lstate.h"
++#include "lstring.h"
++#include "ltable.h"
++#include "ltm.h"
++
++
++#define GCSTEPSIZE 1024u
++#define GCSWEEPMAX 40
++#define GCSWEEPCOST 10
++#define GCFINALIZECOST 100
++
++
++#define maskmarks cast_byte(~(bitmask(BLACKBIT)|WHITEBITS))
++
++#define makewhite(g,x) \
++ ((x)->gch.marked = cast_byte(((x)->gch.marked & maskmarks) | luaC_white(g)))
++
++#define white2gray(x) reset2bits((x)->gch.marked, WHITE0BIT, WHITE1BIT)
++#define black2gray(x) resetbit((x)->gch.marked, BLACKBIT)
++
++#define stringmark(s) reset2bits((s)->tsv.marked, WHITE0BIT, WHITE1BIT)
++
++
++#define isfinalized(u) testbit((u)->marked, FINALIZEDBIT)
++#define markfinalized(u) l_setbit((u)->marked, FINALIZEDBIT)
++
++
++#define KEYWEAK bitmask(KEYWEAKBIT)
++#define VALUEWEAK bitmask(VALUEWEAKBIT)
++
++
++
++#define markvalue(g,o) { checkconsistency(o); \
++ if (iscollectable(o) && iswhite(gcvalue(o))) reallymarkobject(g,gcvalue(o)); }
++
++#define markobject(g,t) { if (iswhite(obj2gco(t))) \
++ reallymarkobject(g, obj2gco(t)); }
++
++
++#define setthreshold(g) (g->GCthreshold = (g->estimate/100) * g->gcpause)
++
++
++static void removeentry (Node *n) {
++ lua_assert(ttisnil(gval(n)));
++ if (iscollectable(gkey(n)))
++ setttype(gkey(n), LUA_TDEADKEY); /* dead key; remove it */
++}
++
++
++static void reallymarkobject (global_State *g, GCObject *o) {
++ lua_assert(iswhite(o) && !isdead(g, o));
++ white2gray(o);
++ switch (o->gch.tt) {
++ case LUA_TSTRING: {
++ return;
++ }
++ case LUA_TUSERDATA: {
++ Table *mt = gco2u(o)->metatable;
++ gray2black(o); /* udata are never gray */
++ if (mt) markobject(g, mt);
++ markobject(g, gco2u(o)->env);
++ return;
++ }
++ case LUA_TUPVAL: {
++ UpVal *uv = gco2uv(o);
++ markvalue(g, uv->v);
++ if (uv->v == &uv->u.value) /* closed? */
++ gray2black(o); /* open upvalues are never black */
++ return;
++ }
++ case LUA_TFUNCTION: {
++ gco2cl(o)->c.gclist = g->gray;
++ g->gray = o;
++ break;
++ }
++ case LUA_TTABLE: {
++ gco2h(o)->gclist = g->gray;
++ g->gray = o;
++ break;
++ }
++ case LUA_TTHREAD: {
++ gco2th(o)->gclist = g->gray;
++ g->gray = o;
++ break;
++ }
++ case LUA_TPROTO: {
++ gco2p(o)->gclist = g->gray;
++ g->gray = o;
++ break;
++ }
++ default: lua_assert(0);
++ }
++}
++
++
++static void marktmu (global_State *g) {
++ GCObject *u = g->tmudata;
++ if (u) {
++ do {
++ u = u->gch.next;
++ makewhite(g, u); /* may be marked, if left from previous GC */
++ reallymarkobject(g, u);
++ } while (u != g->tmudata);
++ }
++}
++
++
++/* move `dead' udata that need finalization to list `tmudata' */
++size_t luaC_separateudata (lua_State *L, int all) {
++ global_State *g = G(L);
++ size_t deadmem = 0;
++ GCObject **p = &g->mainthread->next;
++ GCObject *curr;
++ while ((curr = *p) != NULL) {
++ if (!(iswhite(curr) || all) || isfinalized(gco2u(curr)))
++ p = &curr->gch.next; /* don't bother with them */
++ else if (fasttm(L, gco2u(curr)->metatable, TM_GC) == NULL) {
++ markfinalized(gco2u(curr)); /* don't need finalization */
++ p = &curr->gch.next;
++ }
++ else { /* must call its gc method */
++ deadmem += sizeudata(gco2u(curr));
++ markfinalized(gco2u(curr));
++ *p = curr->gch.next;
++ /* link `curr' at the end of `tmudata' list */
++ if (g->tmudata == NULL) /* list is empty? */
++ g->tmudata = curr->gch.next = curr; /* creates a circular list */
++ else {
++ curr->gch.next = g->tmudata->gch.next;
++ g->tmudata->gch.next = curr;
++ g->tmudata = curr;
++ }
++ }
++ }
++ return deadmem;
++}
++
++
++static int traversetable (global_State *g, Table *h) {
++ int i;
++ int weakkey = 0;
++ int weakvalue = 0;
++ const TValue *mode;
++ if (h->metatable)
++ markobject(g, h->metatable);
++ mode = gfasttm(g, h->metatable, TM_MODE);
++ if (mode && ttisstring(mode)) { /* is there a weak mode? */
++ weakkey = (strchr(svalue(mode), 'k') != NULL);
++ weakvalue = (strchr(svalue(mode), 'v') != NULL);
++ if (weakkey || weakvalue) { /* is really weak? */
++ h->marked &= ~(KEYWEAK | VALUEWEAK); /* clear bits */
++ h->marked |= cast_byte((weakkey << KEYWEAKBIT) |
++ (weakvalue << VALUEWEAKBIT));
++ h->gclist = g->weak; /* must be cleared after GC, ... */
++ g->weak = obj2gco(h); /* ... so put in the appropriate list */
++ }
++ }
++ if (weakkey && weakvalue) return 1;
++ if (!weakvalue) {
++ i = h->sizearray;
++ while (i--)
++ markvalue(g, &h->array[i]);
++ }
++ i = sizenode(h);
++ while (i--) {
++ Node *n = gnode(h, i);
++ lua_assert(ttype(gkey(n)) != LUA_TDEADKEY || ttisnil(gval(n)));
++ if (ttisnil(gval(n)))
++ removeentry(n); /* remove empty entries */
++ else {
++ lua_assert(!ttisnil(gkey(n)));
++ if (!weakkey) markvalue(g, gkey(n));
++ if (!weakvalue) markvalue(g, gval(n));
++ }
++ }
++ return weakkey || weakvalue;
++}
++
++
++/*
++** All marks are conditional because a GC may happen while the
++** prototype is still being created
++*/
++static void traverseproto (global_State *g, Proto *f) {
++ int i;
++ if (f->source) stringmark(f->source);
++ for (i=0; i<f->sizek; i++) /* mark literals */
++ markvalue(g, &f->k[i]);
++ for (i=0; i<f->sizeupvalues; i++) { /* mark upvalue names */
++ if (f->upvalues[i])
++ stringmark(f->upvalues[i]);
++ }
++ for (i=0; i<f->sizep; i++) { /* mark nested protos */
++ if (f->p[i])
++ markobject(g, f->p[i]);
++ }
++ for (i=0; i<f->sizelocvars; i++) { /* mark local-variable names */
++ if (f->locvars[i].varname)
++ stringmark(f->locvars[i].varname);
++ }
++}
++
++
++
++static void traverseclosure (global_State *g, Closure *cl) {
++ markobject(g, cl->c.env);
++ if (cl->c.isC) {
++ int i;
++ for (i=0; i<cl->c.nupvalues; i++) /* mark its upvalues */
++ markvalue(g, &cl->c.upvalue[i]);
++ }
++ else {
++ int i;
++ lua_assert(cl->l.nupvalues == cl->l.p->nups);
++ markobject(g, cl->l.p);
++ for (i=0; i<cl->l.nupvalues; i++) /* mark its upvalues */
++ markobject(g, cl->l.upvals[i]);
++ }
++}
++
++
++static void checkstacksizes (lua_State *L, StkId max) {
++ int ci_used = cast_int(L->ci - L->base_ci); /* number of `ci' in use */
++ int s_used = cast_int(max - L->stack); /* part of stack in use */
++ if (L->size_ci > LUAI_MAXCALLS) /* handling overflow? */
++ return; /* do not touch the stacks */
++ if (4*ci_used < L->size_ci && 2*BASIC_CI_SIZE < L->size_ci)
++ luaD_reallocCI(L, L->size_ci/2); /* still big enough... */
++ condhardstacktests(luaD_reallocCI(L, ci_used + 1));
++ if (4*s_used < L->stacksize &&
++ 2*(BASIC_STACK_SIZE+EXTRA_STACK) < L->stacksize)
++ luaD_reallocstack(L, L->stacksize/2); /* still big enough... */
++ condhardstacktests(luaD_reallocstack(L, s_used));
++}
++
++
++static void traversestack (global_State *g, lua_State *l) {
++ StkId o, lim;
++ CallInfo *ci;
++ markvalue(g, gt(l));
++ lim = l->top;
++ for (ci = l->base_ci; ci <= l->ci; ci++) {
++ lua_assert(ci->top <= l->stack_last);
++ if (lim < ci->top) lim = ci->top;
++ }
++ for (o = l->stack; o < l->top; o++)
++ markvalue(g, o);
++ for (; o <= lim; o++)
++ setnilvalue(o);
++ checkstacksizes(l, lim);
++}
++
++
++/*
++** traverse one gray object, turning it to black.
++** Returns `quantity' traversed.
++*/
++static l_mem propagatemark (global_State *g) {
++ GCObject *o = g->gray;
++ lua_assert(isgray(o));
++ gray2black(o);
++ switch (o->gch.tt) {
++ case LUA_TTABLE: {
++ Table *h = gco2h(o);
++ g->gray = h->gclist;
++ if (traversetable(g, h)) /* table is weak? */
++ black2gray(o); /* keep it gray */
++ return sizeof(Table) + sizeof(TValue) * h->sizearray +
++ sizeof(Node) * sizenode(h);
++ }
++ case LUA_TFUNCTION: {
++ Closure *cl = gco2cl(o);
++ g->gray = cl->c.gclist;
++ traverseclosure(g, cl);
++ return (cl->c.isC) ? sizeCclosure(cl->c.nupvalues) :
++ sizeLclosure(cl->l.nupvalues);
++ }
++ case LUA_TTHREAD: {
++ lua_State *th = gco2th(o);
++ g->gray = th->gclist;
++ th->gclist = g->grayagain;
++ g->grayagain = o;
++ black2gray(o);
++ traversestack(g, th);
++ return sizeof(lua_State) + sizeof(TValue) * th->stacksize +
++ sizeof(CallInfo) * th->size_ci;
++ }
++ case LUA_TPROTO: {
++ Proto *p = gco2p(o);
++ g->gray = p->gclist;
++ traverseproto(g, p);
++ return sizeof(Proto) + sizeof(Instruction) * p->sizecode +
++ sizeof(Proto *) * p->sizep +
++ sizeof(TValue) * p->sizek +
++ sizeof(int) * p->sizelineinfo +
++ sizeof(LocVar) * p->sizelocvars +
++ sizeof(TString *) * p->sizeupvalues;
++ }
++ default: lua_assert(0); return 0;
++ }
++}
++
++
++static size_t propagateall (global_State *g) {
++ size_t m = 0;
++ while (g->gray) m += propagatemark(g);
++ return m;
++}
++
++
++/*
++** The next function tells whether a key or value can be cleared from
++** a weak table. Non-collectable objects are never removed from weak
++** tables. Strings behave as `values', so are never removed too. for
++** other objects: if really collected, cannot keep them; for userdata
++** being finalized, keep them in keys, but not in values
++*/
++static int iscleared (const TValue *o, int iskey) {
++ if (!iscollectable(o)) return 0;
++ if (ttisstring(o)) {
++ stringmark(rawtsvalue(o)); /* strings are `values', so are never weak */
++ return 0;
++ }
++ return iswhite(gcvalue(o)) ||
++ (ttisuserdata(o) && (!iskey && isfinalized(uvalue(o))));
++}
++
++
++/*
++** clear collected entries from weaktables
++*/
++static void cleartable (GCObject *l) {
++ while (l) {
++ Table *h = gco2h(l);
++ int i = h->sizearray;
++ lua_assert(testbit(h->marked, VALUEWEAKBIT) ||
++ testbit(h->marked, KEYWEAKBIT));
++ if (testbit(h->marked, VALUEWEAKBIT)) {
++ while (i--) {
++ TValue *o = &h->array[i];
++ if (iscleared(o, 0)) /* value was collected? */
++ setnilvalue(o); /* remove value */
++ }
++ }
++ i = sizenode(h);
++ while (i--) {
++ Node *n = gnode(h, i);
++ if (!ttisnil(gval(n)) && /* non-empty entry? */
++ (iscleared(key2tval(n), 1) || iscleared(gval(n), 0))) {
++ setnilvalue(gval(n)); /* remove value ... */
++ removeentry(n); /* remove entry from table */
++ }
++ }
++ l = h->gclist;
++ }
++}
++
++
++static void freeobj (lua_State *L, GCObject *o) {
++ switch (o->gch.tt) {
++ case LUA_TPROTO: luaF_freeproto(L, gco2p(o)); break;
++ case LUA_TFUNCTION: luaF_freeclosure(L, gco2cl(o)); break;
++ case LUA_TUPVAL: luaF_freeupval(L, gco2uv(o)); break;
++ case LUA_TTABLE: luaH_free(L, gco2h(o)); break;
++ case LUA_TTHREAD: {
++ lua_assert(gco2th(o) != L && gco2th(o) != G(L)->mainthread);
++ luaE_freethread(L, gco2th(o));
++ break;
++ }
++ case LUA_TSTRING: {
++ G(L)->strt.nuse--;
++ luaM_freemem(L, o, sizestring(gco2ts(o)));
++ break;
++ }
++ case LUA_TUSERDATA: {
++ luaM_freemem(L, o, sizeudata(gco2u(o)));
++ break;
++ }
++ default: lua_assert(0);
++ }
++}
++
++
++
++#define sweepwholelist(L,p) sweeplist(L,p,MAX_LUMEM)
++
++
++static GCObject **sweeplist (lua_State *L, GCObject **p, lu_mem count) {
++ GCObject *curr;
++ global_State *g = G(L);
++ int deadmask = otherwhite(g);
++ while ((curr = *p) != NULL && count-- > 0) {
++ if (curr->gch.tt == LUA_TTHREAD) /* sweep open upvalues of each thread */
++ sweepwholelist(L, &gco2th(curr)->openupval);
++ if ((curr->gch.marked ^ WHITEBITS) & deadmask) { /* not dead? */
++ lua_assert(!isdead(g, curr) || testbit(curr->gch.marked, FIXEDBIT));
++ makewhite(g, curr); /* make it white (for next cycle) */
++ p = &curr->gch.next;
++ }
++ else { /* must erase `curr' */
++ lua_assert(isdead(g, curr) || deadmask == bitmask(SFIXEDBIT));
++ *p = curr->gch.next;
++ if (curr == g->rootgc) /* is the first element of the list? */
++ g->rootgc = curr->gch.next; /* adjust first */
++ freeobj(L, curr);
++ }
++ }
++ return p;
++}
++
++
++static void checkSizes (lua_State *L) {
++ global_State *g = G(L);
++ /* check size of string hash */
++ if (g->strt.nuse < cast(lu_int32, g->strt.size/4) &&
++ g->strt.size > MINSTRTABSIZE*2)
++ luaS_resize(L, g->strt.size/2); /* table is too big */
++ /* check size of buffer */
++ if (luaZ_sizebuffer(&g->buff) > LUA_MINBUFFER*2) { /* buffer too big? */
++ size_t newsize = luaZ_sizebuffer(&g->buff) / 2;
++ luaZ_resizebuffer(L, &g->buff, newsize);
++ }
++}
++
++
++static void GCTM (lua_State *L) {
++ global_State *g = G(L);
++ GCObject *o = g->tmudata->gch.next; /* get first element */
++ Udata *udata = rawgco2u(o);
++ const TValue *tm;
++ /* remove udata from `tmudata' */
++ if (o == g->tmudata) /* last element? */
++ g->tmudata = NULL;
++ else
++ g->tmudata->gch.next = udata->uv.next;
++ udata->uv.next = g->mainthread->next; /* return it to `root' list */
++ g->mainthread->next = o;
++ makewhite(g, o);
++ tm = fasttm(L, udata->uv.metatable, TM_GC);
++ if (tm != NULL) {
++ lu_byte oldah = L->allowhook;
++ lu_mem oldt = g->GCthreshold;
++ L->allowhook = 0; /* stop debug hooks during GC tag method */
++ g->GCthreshold = 2*g->totalbytes; /* avoid GC steps */
++ setobj2s(L, L->top, tm);
++ setuvalue(L, L->top+1, udata);
++ L->top += 2;
++ luaD_call(L, L->top - 2, 0);
++ L->allowhook = oldah; /* restore hooks */
++ g->GCthreshold = oldt; /* restore threshold */
++ }
++}
++
++
++/*
++** Call all GC tag methods
++*/
++void luaC_callGCTM (lua_State *L) {
++ while (G(L)->tmudata)
++ GCTM(L);
++}
++
++
++void luaC_freeall (lua_State *L) {
++ global_State *g = G(L);
++ int i;
++ g->currentwhite = WHITEBITS | bitmask(SFIXEDBIT); /* mask to collect all elements */
++ sweepwholelist(L, &g->rootgc);
++ for (i = 0; i < g->strt.size; i++) /* free all string lists */
++ sweepwholelist(L, &g->strt.hash[i]);
++}
++
++
++static void markmt (global_State *g) {
++ int i;
++ for (i=0; i<NUM_TAGS; i++)
++ if (g->mt[i]) markobject(g, g->mt[i]);
++}
++
++
++/* mark root set */
++static void markroot (lua_State *L) {
++ global_State *g = G(L);
++ g->gray = NULL;
++ g->grayagain = NULL;
++ g->weak = NULL;
++ markobject(g, g->mainthread);
++ /* make global table be traversed before main stack */
++ markvalue(g, gt(g->mainthread));
++ markvalue(g, registry(L));
++ markmt(g);
++ g->gcstate = GCSpropagate;
++}
++
++
++static void remarkupvals (global_State *g) {
++ UpVal *uv;
++ for (uv = g->uvhead.u.l.next; uv != &g->uvhead; uv = uv->u.l.next) {
++ lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv);
++ if (isgray(obj2gco(uv)))
++ markvalue(g, uv->v);
++ }
++}
++
++
++static void atomic (lua_State *L) {
++ global_State *g = G(L);
++ size_t udsize; /* total size of userdata to be finalized */
++ /* remark occasional upvalues of (maybe) dead threads */
++ remarkupvals(g);
++ /* traverse objects cautch by write barrier and by 'remarkupvals' */
++ propagateall(g);
++ /* remark weak tables */
++ g->gray = g->weak;
++ g->weak = NULL;
++ lua_assert(!iswhite(obj2gco(g->mainthread)));
++ markobject(g, L); /* mark running thread */
++ markmt(g); /* mark basic metatables (again) */
++ propagateall(g);
++ /* remark gray again */
++ g->gray = g->grayagain;
++ g->grayagain = NULL;
++ propagateall(g);
++ udsize = luaC_separateudata(L, 0); /* separate userdata to be finalized */
++ marktmu(g); /* mark `preserved' userdata */
++ udsize += propagateall(g); /* remark, to propagate `preserveness' */
++ cleartable(g->weak); /* remove collected objects from weak tables */
++ /* flip current white */
++ g->currentwhite = cast_byte(otherwhite(g));
++ g->sweepstrgc = 0;
++ g->sweepgc = &g->rootgc;
++ g->gcstate = GCSsweepstring;
++ g->estimate = g->totalbytes - udsize; /* first estimate */
++}
++
++
++static l_mem singlestep (lua_State *L) {
++ global_State *g = G(L);
++ /*lua_checkmemory(L);*/
++ switch (g->gcstate) {
++ case GCSpause: {
++ markroot(L); /* start a new collection */
++ return 0;
++ }
++ case GCSpropagate: {
++ if (g->gray)
++ return propagatemark(g);
++ else { /* no more `gray' objects */
++ atomic(L); /* finish mark phase */
++ return 0;
++ }
++ }
++ case GCSsweepstring: {
++ lu_mem old = g->totalbytes;
++ sweepwholelist(L, &g->strt.hash[g->sweepstrgc++]);
++ if (g->sweepstrgc >= g->strt.size) /* nothing more to sweep? */
++ g->gcstate = GCSsweep; /* end sweep-string phase */
++ lua_assert(old >= g->totalbytes);
++ g->estimate -= old - g->totalbytes;
++ return GCSWEEPCOST;
++ }
++ case GCSsweep: {
++ lu_mem old = g->totalbytes;
++ g->sweepgc = sweeplist(L, g->sweepgc, GCSWEEPMAX);
++ if (*g->sweepgc == NULL) { /* nothing more to sweep? */
++ checkSizes(L);
++ g->gcstate = GCSfinalize; /* end sweep phase */
++ }
++ lua_assert(old >= g->totalbytes);
++ g->estimate -= old - g->totalbytes;
++ return GCSWEEPMAX*GCSWEEPCOST;
++ }
++ case GCSfinalize: {
++ if (g->tmudata) {
++ GCTM(L);
++ if (g->estimate > GCFINALIZECOST)
++ g->estimate -= GCFINALIZECOST;
++ return GCFINALIZECOST;
++ }
++ else {
++ g->gcstate = GCSpause; /* end collection */
++ g->gcdept = 0;
++ return 0;
++ }
++ }
++ default: lua_assert(0); return 0;
++ }
++}
++
++
++void luaC_step (lua_State *L) {
++ global_State *g = G(L);
++ l_mem lim = (GCSTEPSIZE/100) * g->gcstepmul;
++ if (lim == 0)
++ lim = (MAX_LUMEM-1)/2; /* no limit */
++ g->gcdept += g->totalbytes - g->GCthreshold;
++ do {
++ lim -= singlestep(L);
++ if (g->gcstate == GCSpause)
++ break;
++ } while (lim > 0);
++ if (g->gcstate != GCSpause) {
++ if (g->gcdept < GCSTEPSIZE)
++ g->GCthreshold = g->totalbytes + GCSTEPSIZE; /* - lim/g->gcstepmul;*/
++ else {
++ g->gcdept -= GCSTEPSIZE;
++ g->GCthreshold = g->totalbytes;
++ }
++ }
++ else {
++ lua_assert(g->totalbytes >= g->estimate);
++ setthreshold(g);
++ }
++}
++
++
++void luaC_fullgc (lua_State *L) {
++ global_State *g = G(L);
++ if (g->gcstate <= GCSpropagate) {
++ /* reset sweep marks to sweep all elements (returning them to white) */
++ g->sweepstrgc = 0;
++ g->sweepgc = &g->rootgc;
++ /* reset other collector lists */
++ g->gray = NULL;
++ g->grayagain = NULL;
++ g->weak = NULL;
++ g->gcstate = GCSsweepstring;
++ }
++ lua_assert(g->gcstate != GCSpause && g->gcstate != GCSpropagate);
++ /* finish any pending sweep phase */
++ while (g->gcstate != GCSfinalize) {
++ lua_assert(g->gcstate == GCSsweepstring || g->gcstate == GCSsweep);
++ singlestep(L);
++ }
++ markroot(L);
++ while (g->gcstate != GCSpause) {
++ singlestep(L);
++ }
++ setthreshold(g);
++}
++
++
++void luaC_barrierf (lua_State *L, GCObject *o, GCObject *v) {
++ global_State *g = G(L);
++ lua_assert(isblack(o) && iswhite(v) && !isdead(g, v) && !isdead(g, o));
++ lua_assert(g->gcstate != GCSfinalize && g->gcstate != GCSpause);
++ lua_assert(ttype(&o->gch) != LUA_TTABLE);
++ /* must keep invariant? */
++ if (g->gcstate == GCSpropagate)
++ reallymarkobject(g, v); /* restore invariant */
++ else /* don't mind */
++ makewhite(g, o); /* mark as white just to avoid other barriers */
++}
++
++
++void luaC_barrierback (lua_State *L, Table *t) {
++ global_State *g = G(L);
++ GCObject *o = obj2gco(t);
++ lua_assert(isblack(o) && !isdead(g, o));
++ lua_assert(g->gcstate != GCSfinalize && g->gcstate != GCSpause);
++ black2gray(o); /* make table gray (again) */
++ t->gclist = g->grayagain;
++ g->grayagain = o;
++}
++
++
++void luaC_link (lua_State *L, GCObject *o, lu_byte tt) {
++ global_State *g = G(L);
++ o->gch.next = g->rootgc;
++ g->rootgc = o;
++ o->gch.marked = luaC_white(g);
++ o->gch.tt = tt;
++}
++
++
++void luaC_linkupval (lua_State *L, UpVal *uv) {
++ global_State *g = G(L);
++ GCObject *o = obj2gco(uv);
++ o->gch.next = g->rootgc; /* link upvalue into `rootgc' list */
++ g->rootgc = o;
++ if (isgray(o)) {
++ if (g->gcstate == GCSpropagate) {
++ gray2black(o); /* closed upvalues need barrier */
++ luaC_barrier(L, uv, uv->v);
++ }
++ else { /* sweep phase: sweep it (turning it into white) */
++ makewhite(g, o);
++ lua_assert(g->gcstate != GCSfinalize && g->gcstate != GCSpause);
++ }
++ }
++}
++
+--- /dev/null
++++ b/extensions/LUA/lua/lgc.h
+@@ -0,0 +1,110 @@
++/*
++** $Id: lgc.h,v 2.15.1.1 2007/12/27 13:02:25 roberto Exp $
++** Garbage Collector
++** See Copyright Notice in lua.h
++*/
++
++#ifndef lgc_h
++#define lgc_h
++
++
++#include "lobject.h"
++
++
++/*
++** Possible states of the Garbage Collector
++*/
++#define GCSpause 0
++#define GCSpropagate 1
++#define GCSsweepstring 2
++#define GCSsweep 3
++#define GCSfinalize 4
++
++
++/*
++** some userful bit tricks
++*/
++#define resetbits(x,m) ((x) &= cast(lu_byte, ~(m)))
++#define setbits(x,m) ((x) |= (m))
++#define testbits(x,m) ((x) & (m))
++#define bitmask(b) (1<<(b))
++#define bit2mask(b1,b2) (bitmask(b1) | bitmask(b2))
++#define l_setbit(x,b) setbits(x, bitmask(b))
++#define resetbit(x,b) resetbits(x, bitmask(b))
++#define testbit(x,b) testbits(x, bitmask(b))
++#define set2bits(x,b1,b2) setbits(x, (bit2mask(b1, b2)))
++#define reset2bits(x,b1,b2) resetbits(x, (bit2mask(b1, b2)))
++#define test2bits(x,b1,b2) testbits(x, (bit2mask(b1, b2)))
++
++
++
++/*
++** Layout for bit use in `marked' field:
++** bit 0 - object is white (type 0)
++** bit 1 - object is white (type 1)
++** bit 2 - object is black
++** bit 3 - for userdata: has been finalized
++** bit 3 - for tables: has weak keys
++** bit 4 - for tables: has weak values
++** bit 5 - object is fixed (should not be collected)
++** bit 6 - object is "super" fixed (only the main thread)
++*/
++
++
++#define WHITE0BIT 0
++#define WHITE1BIT 1
++#define BLACKBIT 2
++#define FINALIZEDBIT 3
++#define KEYWEAKBIT 3
++#define VALUEWEAKBIT 4
++#define FIXEDBIT 5
++#define SFIXEDBIT 6
++#define WHITEBITS bit2mask(WHITE0BIT, WHITE1BIT)
++
++
++#define iswhite(x) test2bits((x)->gch.marked, WHITE0BIT, WHITE1BIT)
++#define isblack(x) testbit((x)->gch.marked, BLACKBIT)
++#define isgray(x) (!isblack(x) && !iswhite(x))
++
++#define otherwhite(g) (g->currentwhite ^ WHITEBITS)
++#define isdead(g,v) ((v)->gch.marked & otherwhite(g) & WHITEBITS)
++
++#define changewhite(x) ((x)->gch.marked ^= WHITEBITS)
++#define gray2black(x) l_setbit((x)->gch.marked, BLACKBIT)
++
++#define valiswhite(x) (iscollectable(x) && iswhite(gcvalue(x)))
++
++#define luaC_white(g) cast(lu_byte, (g)->currentwhite & WHITEBITS)
++
++
++#define luaC_checkGC(L) { \
++ condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK - 1)); \
++ if (G(L)->totalbytes >= G(L)->GCthreshold) \
++ luaC_step(L); }
++
++
++#define luaC_barrier(L,p,v) { if (valiswhite(v) && isblack(obj2gco(p))) \
++ luaC_barrierf(L,obj2gco(p),gcvalue(v)); }
++
++#define luaC_barriert(L,t,v) { if (valiswhite(v) && isblack(obj2gco(t))) \
++ luaC_barrierback(L,t); }
++
++#define luaC_objbarrier(L,p,o) \
++ { if (iswhite(obj2gco(o)) && isblack(obj2gco(p))) \
++ luaC_barrierf(L,obj2gco(p),obj2gco(o)); }
++
++#define luaC_objbarriert(L,t,o) \
++ { if (iswhite(obj2gco(o)) && isblack(obj2gco(t))) luaC_barrierback(L,t); }
++
++LUAI_FUNC size_t luaC_separateudata (lua_State *L, int all);
++LUAI_FUNC void luaC_callGCTM (lua_State *L);
++LUAI_FUNC void luaC_freeall (lua_State *L);
++LUAI_FUNC void luaC_step (lua_State *L);
++LUAI_FUNC void luaC_fullgc (lua_State *L);
++LUAI_FUNC void luaC_link (lua_State *L, GCObject *o, lu_byte tt);
++LUAI_FUNC void luaC_linkupval (lua_State *L, UpVal *uv);
++LUAI_FUNC void luaC_barrierf (lua_State *L, GCObject *o, GCObject *v);
++LUAI_FUNC void luaC_barrierback (lua_State *L, Table *t);
++
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/llex.c
+@@ -0,0 +1,460 @@
++/*
++** $Id: llex.c,v 2.20.1.1 2007/12/27 13:02:25 roberto Exp $
++** Lexical Analyzer
++** See Copyright Notice in lua.h
++*/
++
++#include <ctype.h>
++#include <locale.h>
++#include <string.h>
++
++#define llex_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "ldo.h"
++#include "llex.h"
++#include "lobject.h"
++#include "lparser.h"
++#include "lstate.h"
++#include "lstring.h"
++#include "ltable.h"
++#include "lzio.h"
++
++
++
++#define next(ls) (ls->current = zgetc(ls->z))
++
++
++
++
++#define currIsNewline(ls) (ls->current == '\n' || ls->current == '\r')
++
++
++/* ORDER RESERVED */
++const char *const luaX_tokens [] = {
++ "and", "break", "do", "else", "elseif",
++ "end", "false", "for", "function", "if",
++ "in", "local", "nil", "not", "or", "repeat",
++ "return", "then", "true", "until", "while",
++ "..", "...", "==", ">=", "<=", "~=",
++ "<number>", "<name>", "<string>", "<eof>",
++ NULL
++};
++
++
++#define save_and_next(ls) (save(ls, ls->current), next(ls))
++
++
++static void save (LexState *ls, int c) {
++ Mbuffer *b = ls->buff;
++ if (b->n + 1 > b->buffsize) {
++ size_t newsize;
++ if (b->buffsize >= MAX_SIZET/2)
++ luaX_lexerror(ls, "lexical element too long", 0);
++ newsize = b->buffsize * 2;
++ luaZ_resizebuffer(ls->L, b, newsize);
++ }
++ b->buffer[b->n++] = cast(char, c);
++}
++
++
++void luaX_init (lua_State *L) {
++ int i;
++ for (i=0; i<NUM_RESERVED; i++) {
++ TString *ts = luaS_new(L, luaX_tokens[i]);
++ luaS_fix(ts); /* reserved words are never collected */
++ lua_assert(strlen(luaX_tokens[i])+1 <= TOKEN_LEN);
++ ts->tsv.reserved = cast_byte(i+1); /* reserved word */
++ }
++}
++
++
++#define MAXSRC 80
++
++
++const char *luaX_token2str (LexState *ls, int token) {
++ if (token < FIRST_RESERVED) {
++ lua_assert(token == cast(unsigned char, token));
++ return (iscntrl(token)) ? luaO_pushfstring(ls->L, "char(%d)", token) :
++ luaO_pushfstring(ls->L, "%c", token);
++ }
++ else
++ return luaX_tokens[token-FIRST_RESERVED];
++}
++
++
++static const char *txtToken (LexState *ls, int token) {
++ switch (token) {
++ case TK_NAME:
++ case TK_STRING:
++ case TK_NUMBER:
++ save(ls, '\0');
++ return luaZ_buffer(ls->buff);
++ default:
++ return luaX_token2str(ls, token);
++ }
++}
++
++
++void luaX_lexerror (LexState *ls, const char *msg, int token) {
++ char buff[MAXSRC];
++ luaO_chunkid(buff, getstr(ls->source), MAXSRC);
++ msg = luaO_pushfstring(ls->L, "%s:%d: %s", buff, ls->linenumber, msg);
++ if (token)
++ luaO_pushfstring(ls->L, "%s near " LUA_QS, msg, txtToken(ls, token));
++ luaD_throw(ls->L, LUA_ERRSYNTAX);
++}
++
++
++void luaX_syntaxerror (LexState *ls, const char *msg) {
++ luaX_lexerror(ls, msg, ls->t.token);
++}
++
++
++TString *luaX_newstring (LexState *ls, const char *str, size_t l) {
++ lua_State *L = ls->L;
++ TString *ts = luaS_newlstr(L, str, l);
++ TValue *o = luaH_setstr(L, ls->fs->h, ts); /* entry for `str' */
++ if (ttisnil(o))
++ setbvalue(o, 1); /* make sure `str' will not be collected */
++ return ts;
++}
++
++
++static void inclinenumber (LexState *ls) {
++ int old = ls->current;
++ lua_assert(currIsNewline(ls));
++ next(ls); /* skip `\n' or `\r' */
++ if (currIsNewline(ls) && ls->current != old)
++ next(ls); /* skip `\n\r' or `\r\n' */
++ if (++ls->linenumber >= MAX_INT)
++ luaX_syntaxerror(ls, "chunk has too many lines");
++}
++
++
++void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, TString *source) {
++ ls->decpoint = '.';
++ ls->L = L;
++ ls->lookahead.token = TK_EOS; /* no look-ahead token */
++ ls->z = z;
++ ls->fs = NULL;
++ ls->linenumber = 1;
++ ls->lastline = 1;
++ ls->source = source;
++ luaZ_resizebuffer(ls->L, ls->buff, LUA_MINBUFFER); /* initialize buffer */
++ next(ls); /* read first char */
++}
++
++
++
++/*
++** =======================================================
++** LEXICAL ANALYZER
++** =======================================================
++*/
++
++
++
++static int check_next (LexState *ls, const char *set) {
++ if (!strchr(set, ls->current))
++ return 0;
++ save_and_next(ls);
++ return 1;
++}
++
++
++static void buffreplace (LexState *ls, char from, char to) {
++ size_t n = luaZ_bufflen(ls->buff);
++ char *p = luaZ_buffer(ls->buff);
++ while (n--)
++ if (p[n] == from) p[n] = to;
++}
++
++
++static void trydecpoint (LexState *ls, SemInfo *seminfo) {
++ /* format error: try to update decimal point separator */
++ char old = ls->decpoint;
++ struct lconv *cv = localeconv();
++ ls->decpoint = (cv ? cv->decimal_point[0] : '.');
++ buffreplace(ls, old, ls->decpoint); /* try updated decimal separator */
++ if (!luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r)) {
++ /* format error with correct decimal point: no more options */
++ buffreplace(ls, ls->decpoint, '.'); /* undo change (for error message) */
++ luaX_lexerror(ls, "malformed number", TK_NUMBER);
++ }
++}
++
++
++/* LUA_NUMBER */
++static void read_numeral (LexState *ls, SemInfo *seminfo) {
++ lua_assert(isdigit(ls->current));
++ do {
++ save_and_next(ls);
++ } while (isdigit(ls->current) || ls->current == '.');
++ if (check_next(ls, "Ee")) /* `E'? */
++ check_next(ls, "+-"); /* optional exponent sign */
++ while (isalnum(ls->current) || ls->current == '_')
++ save_and_next(ls);
++ save(ls, '\0');
++ buffreplace(ls, '.', ls->decpoint); /* follow locale for decimal point */
++ if (!luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r)) /* format error? */
++ trydecpoint(ls, seminfo); /* try to update decimal point separator */
++}
++
++
++static int skip_sep (LexState *ls) {
++ int count = 0;
++ int s = ls->current;
++ lua_assert(s == '[' || s == ']');
++ save_and_next(ls);
++ while (ls->current == '=') {
++ save_and_next(ls);
++ count++;
++ }
++ return (ls->current == s) ? count : (-count) - 1;
++}
++
++
++static void read_long_string (LexState *ls, SemInfo *seminfo, int sep) {
++ int cont = 0;
++ (void)(cont); /* avoid warnings when `cont' is not used */
++ save_and_next(ls); /* skip 2nd `[' */
++ if (currIsNewline(ls)) /* string starts with a newline? */
++ inclinenumber(ls); /* skip it */
++ for (;;) {
++ switch (ls->current) {
++ case EOZ:
++ luaX_lexerror(ls, (seminfo) ? "unfinished long string" :
++ "unfinished long comment", TK_EOS);
++ break; /* to avoid warnings */
++#if defined(LUA_COMPAT_LSTR)
++ case '[': {
++ if (skip_sep(ls) == sep) {
++ save_and_next(ls); /* skip 2nd `[' */
++ cont++;
++#if LUA_COMPAT_LSTR == 1
++ if (sep == 0)
++ luaX_lexerror(ls, "nesting of [[...]] is deprecated", '[');
++#endif
++ }
++ break;
++ }
++#endif
++ case ']': {
++ if (skip_sep(ls) == sep) {
++ save_and_next(ls); /* skip 2nd `]' */
++#if defined(LUA_COMPAT_LSTR) && LUA_COMPAT_LSTR == 2
++ cont--;
++ if (sep == 0 && cont >= 0) break;
++#endif
++ goto endloop;
++ }
++ break;
++ }
++ case '\n':
++ case '\r': {
++ save(ls, '\n');
++ inclinenumber(ls);
++ if (!seminfo) luaZ_resetbuffer(ls->buff); /* avoid wasting space */
++ break;
++ }
++ default: {
++ if (seminfo) save_and_next(ls);
++ else next(ls);
++ }
++ }
++ } endloop:
++ if (seminfo)
++ seminfo->ts = luaX_newstring(ls, luaZ_buffer(ls->buff) + (2 + sep),
++ luaZ_bufflen(ls->buff) - 2*(2 + sep));
++}
++
++
++static void read_string (LexState *ls, int del, SemInfo *seminfo) {
++ save_and_next(ls);
++ while (ls->current != del) {
++ switch (ls->current) {
++ case EOZ:
++ luaX_lexerror(ls, "unfinished string", TK_EOS);
++ continue; /* to avoid warnings */
++ case '\n':
++ case '\r':
++ luaX_lexerror(ls, "unfinished string", TK_STRING);
++ continue; /* to avoid warnings */
++ case '\\': {
++ int c;
++ next(ls); /* do not save the `\' */
++ switch (ls->current) {
++ case 'a': c = '\a'; break;
++ case 'b': c = '\b'; break;
++ case 'f': c = '\f'; break;
++ case 'n': c = '\n'; break;
++ case 'r': c = '\r'; break;
++ case 't': c = '\t'; break;
++ case 'v': c = '\v'; break;
++ case '\n': /* go through */
++ case '\r': save(ls, '\n'); inclinenumber(ls); continue;
++ case EOZ: continue; /* will raise an error next loop */
++ default: {
++ if (!isdigit(ls->current))
++ save_and_next(ls); /* handles \\, \", \', and \? */
++ else { /* \xxx */
++ int i = 0;
++ c = 0;
++ do {
++ c = 10*c + (ls->current-'0');
++ next(ls);
++ } while (++i<3 && isdigit(ls->current));
++ if (c > UCHAR_MAX)
++ luaX_lexerror(ls, "escape sequence too large", TK_STRING);
++ save(ls, c);
++ }
++ continue;
++ }
++ }
++ save(ls, c);
++ next(ls);
++ continue;
++ }
++ default:
++ save_and_next(ls);
++ }
++ }
++ save_and_next(ls); /* skip delimiter */
++ seminfo->ts = luaX_newstring(ls, luaZ_buffer(ls->buff) + 1,
++ luaZ_bufflen(ls->buff) - 2);
++}
++
++
++static int llex (LexState *ls, SemInfo *seminfo) {
++ luaZ_resetbuffer(ls->buff);
++ for (;;) {
++ switch (ls->current) {
++ case '\n':
++ case '\r': {
++ inclinenumber(ls);
++ continue;
++ }
++ case '-': {
++ next(ls);
++ if (ls->current != '-') return '-';
++ /* else is a comment */
++ next(ls);
++ if (ls->current == '[') {
++ int sep = skip_sep(ls);
++ luaZ_resetbuffer(ls->buff); /* `skip_sep' may dirty the buffer */
++ if (sep >= 0) {
++ read_long_string(ls, NULL, sep); /* long comment */
++ luaZ_resetbuffer(ls->buff);
++ continue;
++ }
++ }
++ /* else short comment */
++ while (!currIsNewline(ls) && ls->current != EOZ)
++ next(ls);
++ continue;
++ }
++ case '[': {
++ int sep = skip_sep(ls);
++ if (sep >= 0) {
++ read_long_string(ls, seminfo, sep);
++ return TK_STRING;
++ }
++ else if (sep == -1) return '[';
++ else luaX_lexerror(ls, "invalid long string delimiter", TK_STRING);
++ }
++ case '=': {
++ next(ls);
++ if (ls->current != '=') return '=';
++ else { next(ls); return TK_EQ; }
++ }
++ case '<': {
++ next(ls);
++ if (ls->current != '=') return '<';
++ else { next(ls); return TK_LE; }
++ }
++ case '>': {
++ next(ls);
++ if (ls->current != '=') return '>';
++ else { next(ls); return TK_GE; }
++ }
++ case '~': {
++ next(ls);
++ if (ls->current != '=') return '~';
++ else { next(ls); return TK_NE; }
++ }
++ case '"':
++ case '\'': {
++ read_string(ls, ls->current, seminfo);
++ return TK_STRING;
++ }
++ case '.': {
++ save_and_next(ls);
++ if (check_next(ls, ".")) {
++ if (check_next(ls, "."))
++ return TK_DOTS; /* ... */
++ else return TK_CONCAT; /* .. */
++ }
++ else if (!isdigit(ls->current)) return '.';
++ else {
++ read_numeral(ls, seminfo);
++ return TK_NUMBER;
++ }
++ }
++ case EOZ: {
++ return TK_EOS;
++ }
++ default: {
++ if (isspace(ls->current)) {
++ lua_assert(!currIsNewline(ls));
++ next(ls);
++ continue;
++ }
++ else if (isdigit(ls->current)) {
++ read_numeral(ls, seminfo);
++ return TK_NUMBER;
++ }
++ else if (isalpha(ls->current) || ls->current == '_') {
++ /* identifier or reserved word */
++ TString *ts;
++ do {
++ save_and_next(ls);
++ } while (isalnum(ls->current) || ls->current == '_');
++ ts = luaX_newstring(ls, luaZ_buffer(ls->buff),
++ luaZ_bufflen(ls->buff));
++ if (ts->tsv.reserved > 0) /* reserved word? */
++ return ts->tsv.reserved - 1 + FIRST_RESERVED;
++ else {
++ seminfo->ts = ts;
++ return TK_NAME;
++ }
++ }
++ else {
++ int c = ls->current;
++ next(ls);
++ return c; /* single-char tokens (+ - / ...) */
++ }
++ }
++ }
++ }
++}
++
++
++void luaX_next (LexState *ls) {
++ ls->lastline = ls->linenumber;
++ if (ls->lookahead.token != TK_EOS) { /* is there a look-ahead token? */
++ ls->t = ls->lookahead; /* use this one */
++ ls->lookahead.token = TK_EOS; /* and discharge it */
++ }
++ else
++ ls->t.token = llex(ls, &ls->t.seminfo); /* read next token */
++}
++
++
++void luaX_lookahead (LexState *ls) {
++ lua_assert(ls->lookahead.token == TK_EOS);
++ ls->lookahead.token = llex(ls, &ls->lookahead.seminfo);
++}
++
+--- /dev/null
++++ b/extensions/LUA/lua/llex.h
+@@ -0,0 +1,81 @@
++/*
++** $Id: llex.h,v 1.58.1.1 2007/12/27 13:02:25 roberto Exp $
++** Lexical Analyzer
++** See Copyright Notice in lua.h
++*/
++
++#ifndef llex_h
++#define llex_h
++
++#include "lobject.h"
++#include "lzio.h"
++
++
++#define FIRST_RESERVED 257
++
++/* maximum length of a reserved word */
++#define TOKEN_LEN (sizeof("function")/sizeof(char))
++
++
++/*
++* WARNING: if you change the order of this enumeration,
++* grep "ORDER RESERVED"
++*/
++enum RESERVED {
++ /* terminal symbols denoted by reserved words */
++ TK_AND = FIRST_RESERVED, TK_BREAK,
++ TK_DO, TK_ELSE, TK_ELSEIF, TK_END, TK_FALSE, TK_FOR, TK_FUNCTION,
++ TK_IF, TK_IN, TK_LOCAL, TK_NIL, TK_NOT, TK_OR, TK_REPEAT,
++ TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE,
++ /* other terminal symbols */
++ TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, TK_NUMBER,
++ TK_NAME, TK_STRING, TK_EOS
++};
++
++/* number of reserved words */
++#define NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1))
++
++
++/* array with token `names' */
++LUAI_DATA const char *const luaX_tokens [];
++
++
++typedef union {
++ lua_Number r;
++ TString *ts;
++} SemInfo; /* semantics information */
++
++
++typedef struct Token {
++ int token;
++ SemInfo seminfo;
++} Token;
++
++
++typedef struct LexState {
++ int current; /* current character (charint) */
++ int linenumber; /* input line counter */
++ int lastline; /* line of last token `consumed' */
++ Token t; /* current token */
++ Token lookahead; /* look ahead token */
++ struct FuncState *fs; /* `FuncState' is private to the parser */
++ struct lua_State *L;
++ ZIO *z; /* input stream */
++ Mbuffer *buff; /* buffer for tokens */
++ TString *source; /* current source name */
++ char decpoint; /* locale decimal point */
++} LexState;
++
++
++LUAI_FUNC void luaX_init (lua_State *L);
++LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z,
++ TString *source);
++LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l);
++LUAI_FUNC void luaX_next (LexState *ls);
++LUAI_FUNC void luaX_lookahead (LexState *ls);
++LUAI_FUNC void luaX_lexerror (LexState *ls, const char *msg, int token);
++LUAI_FUNC void luaX_syntaxerror (LexState *ls, const char *s);
++LUAI_FUNC const char *luaX_token2str (LexState *ls, int token);
++
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/llimits.h
+@@ -0,0 +1,125 @@
++/*
++** $Id: llimits.h,v 1.69.1.1 2007/12/27 13:02:25 roberto Exp $
++** Limits, basic types, and some other `installation-dependent' definitions
++** See Copyright Notice in lua.h
++*/
++
++#ifndef llimits_h
++#define llimits_h
++
++#include <stddef.h>
++#include <limits.h>
++
++#include "lua.h"
++
++typedef LUAI_UINT32 lu_int32;
++
++typedef LUAI_UMEM lu_mem;
++
++typedef LUAI_MEM l_mem;
++
++
++
++/* chars used as small naturals (so that `char' is reserved for characters) */
++typedef unsigned char lu_byte;
++
++
++#define MAX_SIZET ((size_t)(~(size_t)0)-2)
++
++#define MAX_LUMEM ((lu_mem)(~(lu_mem)0)-2)
++
++
++#define MAX_INT (LUA_INT_MAX-2) /* maximum value of an int (-2 for safety) */
++
++/*
++** conversion of pointer to integer
++** this is for hashing only; there is no problem if the integer
++** cannot hold the whole pointer value
++*/
++#define IntPoint(p) ((unsigned int)(lu_mem)(p))
++
++
++
++/* type to ensure maximum alignment */
++typedef LUAI_USER_ALIGNMENT_T L_Umaxalign;
++
++
++/* result of a `usual argument conversion' over lua_Number */
++typedef LUAI_UACNUMBER l_uacNumber;
++
++
++/* internal assertions for in-house debugging */
++#ifdef lua_assert
++
++#define check_exp(c,e) (lua_assert(c), (e))
++#define api_check(l,e) lua_assert(e)
++
++#else
++
++#define lua_assert(c) ((void)0)
++#define check_exp(c,e) (e)
++#define api_check luai_apicheck
++
++#endif
++
++
++#ifndef UNUSED
++#define UNUSED(x) ((void)(x)) /* to avoid warnings */
++#endif
++
++
++#ifndef cast
++#define cast(t, exp) ((t)(exp))
++#endif
++
++#define cast_byte(i) cast(lu_byte, (i))
++#define cast_num(i) cast(lua_Number, (i))
++#define cast_int(i) cast(int, (i))
++
++
++
++/*
++** type for virtual-machine instructions
++** must be an unsigned with (at least) 4 bytes (see details in lopcodes.h)
++*/
++typedef lu_int32 Instruction;
++
++
++
++/* maximum stack for a Lua function */
++#define MAXSTACK 250
++
++
++
++/* minimum size for the string table (must be power of 2) */
++#ifndef MINSTRTABSIZE
++#define MINSTRTABSIZE 32
++#endif
++
++
++/* minimum size for string buffer */
++#ifndef LUA_MINBUFFER
++#define LUA_MINBUFFER 32
++#endif
++
++
++#ifndef lua_lock
++#define lua_lock(L) ((void) 0)
++#define lua_unlock(L) ((void) 0)
++#endif
++
++#ifndef luai_threadyield
++#define luai_threadyield(L) {lua_unlock(L); lua_lock(L);}
++#endif
++
++
++/*
++** macro to control inclusion of some hard tests on stack reallocation
++*/
++#ifndef HARDSTACKTESTS
++#define condhardstacktests(x) ((void)0)
++#else
++#define condhardstacktests(x) x
++#endif
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/lmem.c
+@@ -0,0 +1,86 @@
++/*
++** $Id: lmem.c,v 1.70.1.1 2007/12/27 13:02:25 roberto Exp $
++** Interface to Memory Manager
++** See Copyright Notice in lua.h
++*/
++
++
++#include <stddef.h>
++
++#define lmem_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "ldebug.h"
++#include "ldo.h"
++#include "lmem.h"
++#include "lobject.h"
++#include "lstate.h"
++
++
++
++/*
++** About the realloc function:
++** void * frealloc (void *ud, void *ptr, size_t osize, size_t nsize);
++** (`osize' is the old size, `nsize' is the new size)
++**
++** Lua ensures that (ptr == NULL) iff (osize == 0).
++**
++** * frealloc(ud, NULL, 0, x) creates a new block of size `x'
++**
++** * frealloc(ud, p, x, 0) frees the block `p'
++** (in this specific case, frealloc must return NULL).
++** particularly, frealloc(ud, NULL, 0, 0) does nothing
++** (which is equivalent to free(NULL) in ANSI C)
++**
++** frealloc returns NULL if it cannot create or reallocate the area
++** (any reallocation to an equal or smaller size cannot fail!)
++*/
++
++
++
++#define MINSIZEARRAY 4
++
++
++void *luaM_growaux_ (lua_State *L, void *block, int *size, size_t size_elems,
++ int limit, const char *errormsg) {
++ void *newblock;
++ int newsize;
++ if (*size >= limit/2) { /* cannot double it? */
++ if (*size >= limit) /* cannot grow even a little? */
++ luaG_runerror(L, errormsg);
++ newsize = limit; /* still have at least one free place */
++ }
++ else {
++ newsize = (*size)*2;
++ if (newsize < MINSIZEARRAY)
++ newsize = MINSIZEARRAY; /* minimum size */
++ }
++ newblock = luaM_reallocv(L, block, *size, newsize, size_elems);
++ *size = newsize; /* update only when everything else is OK */
++ return newblock;
++}
++
++
++void *luaM_toobig (lua_State *L) {
++ luaG_runerror(L, "memory allocation error: block too big");
++ return NULL; /* to avoid warnings */
++}
++
++
++
++/*
++** generic allocation routine.
++*/
++void *luaM_realloc_ (lua_State *L, void *block, size_t osize, size_t nsize) {
++ global_State *g = G(L);
++ lua_assert((osize == 0) == (block == NULL));
++ block = (*g->frealloc)(g->ud, block, osize, nsize);
++ if (block == NULL && nsize > 0)
++ luaD_throw(L, LUA_ERRMEM);
++ lua_assert((nsize == 0) == (block == NULL));
++ g->totalbytes = (g->totalbytes - osize) + nsize;
++ return block;
++}
++
+--- /dev/null
++++ b/extensions/LUA/lua/lmem.h
+@@ -0,0 +1,49 @@
++/*
++** $Id: lmem.h,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $
++** Interface to Memory Manager
++** See Copyright Notice in lua.h
++*/
++
++#ifndef lmem_h
++#define lmem_h
++
++
++#include <stddef.h>
++
++#include "llimits.h"
++#include "lua.h"
++
++#define MEMERRMSG "not enough memory"
++
++
++#define luaM_reallocv(L,b,on,n,e) \
++ ((cast(size_t, (n)+1) <= MAX_SIZET/(e)) ? /* +1 to avoid warnings */ \
++ luaM_realloc_(L, (b), (on)*(e), (n)*(e)) : \
++ luaM_toobig(L))
++
++#define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0)
++#define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0)
++#define luaM_freearray(L, b, n, t) luaM_reallocv(L, (b), n, 0, sizeof(t))
++
++#define luaM_malloc(L,t) luaM_realloc_(L, NULL, 0, (t))
++#define luaM_new(L,t) cast(t *, luaM_malloc(L, sizeof(t)))
++#define luaM_newvector(L,n,t) \
++ cast(t *, luaM_reallocv(L, NULL, 0, n, sizeof(t)))
++
++#define luaM_growvector(L,v,nelems,size,t,limit,e) \
++ if ((nelems)+1 > (size)) \
++ ((v)=cast(t *, luaM_growaux_(L,v,&(size),sizeof(t),limit,e)))
++
++#define luaM_reallocvector(L, v,oldn,n,t) \
++ ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t))))
++
++
++LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize,
++ size_t size);
++LUAI_FUNC void *luaM_toobig (lua_State *L);
++LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size,
++ size_t size_elem, int limit,
++ const char *errormsg);
++
++#endif
++
+--- /dev/null
++++ b/extensions/LUA/lua/lobject.c
+@@ -0,0 +1,215 @@
++/*
++** $Id: lobject.c,v 2.22.1.1 2007/12/27 13:02:25 roberto Exp $
++** Some generic functions over Lua objects
++** See Copyright Notice in lua.h
++*/
++
++#include <stdarg.h>
++
++#include <ctype.h>
++#include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
++
++#define lobject_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "ldo.h"
++#include "lmem.h"
++#include "lobject.h"
++#include "lstate.h"
++#include "lstring.h"
++#include "lvm.h"
++
++
++
++const TValue luaO_nilobject_ = {{NULL}, LUA_TNIL};
++
++
++/*
++** converts an integer to a "floating point byte", represented as
++** (eeeeexxx), where the real value is (1xxx) * 2^(eeeee - 1) if
++** eeeee != 0 and (xxx) otherwise.
++*/
++int luaO_int2fb (unsigned int x) {
++ int e = 0; /* expoent */
++ while (x >= 16) {
++ x = (x+1) >> 1;
++ e++;
++ }
++ if (x < 8) return x;
++ else return ((e+1) << 3) | (cast_int(x) - 8);
++}
++
++
++/* converts back */
++int luaO_fb2int (int x) {
++ int e = (x >> 3) & 31;
++ if (e == 0) return x;
++ else return ((x & 7)+8) << (e - 1);
++}
++
++
++int luaO_log2 (unsigned int x) {
++ static const lu_byte log_2[256] = {
++ 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
++ 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
++ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
++ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
++ 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
++ 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
++ 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
++ 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8
++ };
++ int l = -1;
++ while (x >= 256) { l += 8; x >>= 8; }
++ return l + log_2[x];
++
++}
++
++
++int luaO_rawequalObj (const TValue *t1, const TValue *t2) {
++ if (ttype(t1) != ttype(t2)) return 0;
++ else switch (ttype(t1)) {
++ case LUA_TNIL:
++ return 1;
++ case LUA_TNUMBER:
++ return luai_numeq(nvalue(t1), nvalue(t2));
++ case LUA_TBOOLEAN:
++ return bvalue(t1) == bvalue(t2); /* boolean true must be 1 !! */
++ case LUA_TLIGHTUSERDATA:
++ return pvalue(t1) == pvalue(t2);
++ default:
++ lua_assert(iscollectable(t1));
++ return gcvalue(t1) == gcvalue(t2);
++ }
++}
++
++
++int luaO_str2d (const char *s, lua_Number *result) {
++ char *endptr;
++ *result = lua_str2number(s, &endptr);
++ if (endptr == s) return 0; /* conversion failed */
++ if (*endptr == 'x' || *endptr == 'X') /* maybe an hexadecimal constant? */
++ *result = cast_num(strtoul(s, &endptr, 16));
++ if (*endptr == '\0') return 1; /* most common case */
++ while (isspace(cast(unsigned char, *endptr))) endptr++;
++ if (*endptr != '\0') return 0; /* invalid trailing characters? */
++ return 1;
++}
++
++
++
++static void pushstr (lua_State *L, const char *str) {
++ setsvalue2s(L, L->top, luaS_new(L, str));
++ incr_top(L);
++}
++
++
++/* this function handles only `%d', `%c', %f, %p, and `%s' formats */
++const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) {
++ int n = 1;
++ pushstr(L, "");
++ for (;;) {
++ const char *e = strchr(fmt, '%');
++ if (e == NULL) break;
++ setsvalue2s(L, L->top, luaS_newlstr(L, fmt, e-fmt));
++ incr_top(L);
++ switch (*(e+1)) {
++ case 's': {
++ const char *s = va_arg(argp, char *);
++ if (s == NULL) s = "(null)";
++ pushstr(L, s);
++ break;
++ }
++ case 'c': {
++ char buff[2];
++ buff[0] = cast(char, va_arg(argp, int));
++ buff[1] = '\0';
++ pushstr(L, buff);
++ break;
++ }
++ case 'd': {
++ setnvalue(L->top, cast_num(va_arg(argp, int)));
++ incr_top(L);
++ break;
++ }
++ case 'f': {
++ setnvalue(L->top, cast_num(va_arg(argp, l_uacNumber)));
++ incr_top(L);
++ break;
++ }
++ case 'p': {
++ char buff[4*sizeof(void *) + 8]; /* should be enough space for a `%p' */
++ sprintf(buff, "%p", va_arg(argp, void *));
++ pushstr(L, buff);
++ break;
++ }
++ case '%': {
++ pushstr(L, "%");
++ break;
++ }
++ default: {
++ char buff[3];
++ buff[0] = '%';
++ buff[1] = *(e+1);
++ buff[2] = '\0';
++ pushstr(L, buff);
++ break;
++ }
++ }
++ n += 2;
++ fmt = e+2;
++ }
++ pushstr(L, fmt);
++ luaV_concat(L, n+1, cast_int(L->top - L->base) - 1);
++ L->top -= n;
++ return svalue(L->top - 1);
++}
++
++
++const char *luaO_pushfstring (lua_State *L, const char *fmt, ...) {
++ const char *msg;
++ va_list argp;
++ va_start(argp, fmt);
++ msg = luaO_pushvfstring(L, fmt, argp);
++ va_end(argp);
++ return msg;
++}
++
++
++void luaO_chunkid (char *out, const char *source, size_t bufflen) {
++ if (*source == '=') {
++ strncpy(out, source+1, bufflen); /* remove first char */
++ out[bufflen-1] = '\0'; /* ensures null termination */
++ }
++ else { /* out = "source", or "...source" */
++ if (*source == '@') {
++ size_t l;
++ source++; /* skip the `@' */
++ bufflen -= sizeof(" '...' ");
++ l = strlen(source);
++ strcpy(out, "");
++ if (l > bufflen) {
++ source += (l-bufflen); /* get last part of file name */
++ strcat(out, "...");
++ }
++ strcat(out, source);
++ }
++ else { /* out = [string "string"] */
++ size_t len = strcspn(source, "\n\r"); /* stop at first newline */
++ bufflen -= sizeof(" [string \"...\"] ");
++ if (len > bufflen) len = bufflen;
++ strcpy(out, "[string \"");
++ if (source[len] != '\0') { /* must truncate? */
++ strncat(out, source, len);
++ strcat(out, "...");
++ }
++ else
++ strcat(out, source);
++ strcat(out, "\"]");
++ }
++ }
++}
+--- /dev/null
++++ b/extensions/LUA/lua/lobject.h
+@@ -0,0 +1,381 @@
++/*
++** $Id: lobject.h,v 2.20.1.2 2008/08/06 13:29:48 roberto Exp $
++** Type definitions for Lua objects
++** See Copyright Notice in lua.h
++*/
++
++
++#ifndef lobject_h
++#define lobject_h
++
++
++#include <stdarg.h>
++
++
++#include "llimits.h"
++#include "lua.h"
++
++
++/* tags for values visible from Lua */
++#define LAST_TAG LUA_TTHREAD
++
++#define NUM_TAGS (LAST_TAG+1)
++
++
++/*
++** Extra tags for non-values
++*/
++#define LUA_TPROTO (LAST_TAG+1)
++#define LUA_TUPVAL (LAST_TAG+2)
++#define LUA_TDEADKEY (LAST_TAG+3)
++
++
++/*
++** Union of all collectable objects
++*/
++typedef union GCObject GCObject;
++
++
++/*
++** Common Header for all collectable objects (in macro form, to be
++** included in other objects)
++*/
++#define CommonHeader GCObject *next; lu_byte tt; lu_byte marked
++
++
++/*
++** Common header in struct form
++*/
++typedef struct GCheader {
++ CommonHeader;
++} GCheader;
++
++
++
++
++/*
++** Union of all Lua values
++*/
++typedef union {
++ GCObject *gc;
++ void *p;
++ lua_Number n;
++ int b;
++} Value;
++
++
++/*
++** Tagged Values
++*/
++
++#define TValuefields Value value; int tt
++
++typedef struct lua_TValue {
++ TValuefields;
++} TValue;
++
++
++/* Macros to test type */
++#define ttisnil(o) (ttype(o) == LUA_TNIL)
++#define ttisnumber(o) (ttype(o) == LUA_TNUMBER)
++#define ttisstring(o) (ttype(o) == LUA_TSTRING)
++#define ttistable(o) (ttype(o) == LUA_TTABLE)
++#define ttisfunction(o) (ttype(o) == LUA_TFUNCTION)
++#define ttisboolean(o) (ttype(o) == LUA_TBOOLEAN)
++#define ttisuserdata(o) (ttype(o) == LUA_TUSERDATA)
++#define ttisthread(o) (ttype(o) == LUA_TTHREAD)
++#define ttislightuserdata(o) (ttype(o) == LUA_TLIGHTUSERDATA)
++
++/* Macros to access values */
++#define ttype(o) ((o)->tt)
++#define gcvalue(o) check_exp(iscollectable(o), (o)->value.gc)
++#define pvalue(o) check_exp(ttislightuserdata(o), (o)->value.p)
++#define nvalue(o) check_exp(ttisnumber(o), (o)->value.n)
++#define rawtsvalue(o) check_exp(ttisstring(o), &(o)->value.gc->ts)
++#define tsvalue(o) (&rawtsvalue(o)->tsv)
++#define rawuvalue(o) check_exp(ttisuserdata(o), &(o)->value.gc->u)
++#define uvalue(o) (&rawuvalue(o)->uv)
++#define clvalue(o) check_exp(ttisfunction(o), &(o)->value.gc->cl)
++#define hvalue(o) check_exp(ttistable(o), &(o)->value.gc->h)
++#define bvalue(o) check_exp(ttisboolean(o), (o)->value.b)
++#define thvalue(o) check_exp(ttisthread(o), &(o)->value.gc->th)
++
++#define l_isfalse(o) (ttisnil(o) || (ttisboolean(o) && bvalue(o) == 0))
++
++/*
++** for internal debug only
++*/
++#define checkconsistency(obj) \
++ lua_assert(!iscollectable(obj) || (ttype(obj) == (obj)->value.gc->gch.tt))
++
++#define checkliveness(g,obj) \
++ lua_assert(!iscollectable(obj) || \
++ ((ttype(obj) == (obj)->value.gc->gch.tt) && !isdead(g, (obj)->value.gc)))
++
++
++/* Macros to set values */
++#define setnilvalue(obj) ((obj)->tt=LUA_TNIL)
++
++#define setnvalue(obj,x) \
++ { TValue *i_o=(obj); i_o->value.n=(x); i_o->tt=LUA_TNUMBER; }
++
++#define setpvalue(obj,x) \
++ { TValue *i_o=(obj); i_o->value.p=(x); i_o->tt=LUA_TLIGHTUSERDATA; }
++
++#define setbvalue(obj,x) \
++ { TValue *i_o=(obj); i_o->value.b=(x); i_o->tt=LUA_TBOOLEAN; }
++
++#define setsvalue(L,obj,x) \
++ { TValue *i_o=(obj); \
++ i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TSTRING; \
++ checkliveness(G(L),i_o); }
++
++#define setuvalue(L,obj,x) \
++ { TValue *i_o=(obj); \
++ i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TUSERDATA; \
++ checkliveness(G(L),i_o); }
++
++#define setthvalue(L,obj,x) \
++ { TValue *i_o=(obj); \
++ i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TTHREAD; \
++ checkliveness(G(L),i_o); }
++
++#define setclvalue(L,obj,x) \
++ { TValue *i_o=(obj); \
++ i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TFUNCTION; \
++ checkliveness(G(L),i_o); }
++
++#define sethvalue(L,obj,x) \
++ { TValue *i_o=(obj); \
++ i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TTABLE; \
++ checkliveness(G(L),i_o); }
++
++#define setptvalue(L,obj,x) \
++ { TValue *i_o=(obj); \
++ i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TPROTO; \
++ checkliveness(G(L),i_o); }
++
++
++
++
++#define setobj(L,obj1,obj2) \
++ { const TValue *o2=(obj2); TValue *o1=(obj1); \
++ o1->value = o2->value; o1->tt=o2->tt; \
++ checkliveness(G(L),o1); }
++
++
++/*
++** different types of sets, according to destination
++*/
++
++/* from stack to (same) stack */
++#define setobjs2s setobj
++/* to stack (not from same stack) */
++#define setobj2s setobj
++#define setsvalue2s setsvalue
++#define sethvalue2s sethvalue
++#define setptvalue2s setptvalue
++/* from table to same table */
++#define setobjt2t setobj
++/* to table */
++#define setobj2t setobj
++/* to new object */
++#define setobj2n setobj
++#define setsvalue2n setsvalue
++
++#define setttype(obj, tt) (ttype(obj) = (tt))
++
++
++#define iscollectable(o) (ttype(o) >= LUA_TSTRING)
++
++
++
++typedef TValue *StkId; /* index to stack elements */
++
++
++/*
++** String headers for string table
++*/
++typedef union TString {
++ L_Umaxalign dummy; /* ensures maximum alignment for strings */
++ struct {
++ CommonHeader;
++ lu_byte reserved;
++ unsigned int hash;
++ size_t len;
++ } tsv;
++} TString;
++
++
++#define getstr(ts) cast(const char *, (ts) + 1)
++#define svalue(o) getstr(rawtsvalue(o))
++
++
++
++typedef union Udata {
++ L_Umaxalign dummy; /* ensures maximum alignment for `local' udata */
++ struct {
++ CommonHeader;
++ struct Table *metatable;
++ struct Table *env;
++ size_t len;
++ } uv;
++} Udata;
++
++
++
++
++/*
++** Function Prototypes
++*/
++typedef struct Proto {
++ CommonHeader;
++ TValue *k; /* constants used by the function */
++ Instruction *code;
++ struct Proto **p; /* functions defined inside the function */
++ int *lineinfo; /* map from opcodes to source lines */
++ struct LocVar *locvars; /* information about local variables */
++ TString **upvalues; /* upvalue names */
++ TString *source;
++ int sizeupvalues;
++ int sizek; /* size of `k' */
++ int sizecode;
++ int sizelineinfo;
++ int sizep; /* size of `p' */
++ int sizelocvars;
++ int linedefined;
++ int lastlinedefined;
++ GCObject *gclist;
++ lu_byte nups; /* number of upvalues */
++ lu_byte numparams;
++ lu_byte is_vararg;
++ lu_byte maxstacksize;
++} Proto;
++
++
++/* masks for new-style vararg */
++#define VARARG_HASARG 1
++#define VARARG_ISVARARG 2
++#define VARARG_NEEDSARG 4
++
++
++typedef struct LocVar {
++ TString *varname;
++ int startpc; /* first point where variable is active */
++ int endpc; /* first point where variable is dead */
++} LocVar;
++
++
++
++/*
++** Upvalues
++*/
++
++typedef struct UpVal {
++ CommonHeader;
++ TValue *v; /* points to stack or to its own value */
++ union {
++ TValue value; /* the value (when closed) */
++ struct { /* double linked list (when open) */
++ struct UpVal *prev;
++ struct UpVal *next;
++ } l;
++ } u;
++} UpVal;
++
++
++/*
++** Closures
++*/
++
++#define ClosureHeader \
++ CommonHeader; lu_byte isC; lu_byte nupvalues; GCObject *gclist; \
++ struct Table *env
++
++typedef struct CClosure {
++ ClosureHeader;
++ lua_CFunction f;
++ TValue upvalue[1];
++} CClosure;
++
++
++typedef struct LClosure {
++ ClosureHeader;
++ struct Proto *p;
++ UpVal *upvals[1];
++} LClosure;
++
++
++typedef union Closure {
++ CClosure c;
++ LClosure l;
++} Closure;
++
++
++#define iscfunction(o) (ttype(o) == LUA_TFUNCTION && clvalue(o)->c.isC)
++#define isLfunction(o) (ttype(o) == LUA_TFUNCTION && !clvalue(o)->c.isC)
++
++
++/*
++** Tables
++*/
++
++typedef union TKey {
++ struct {
++ TValuefields;
++ struct Node *next; /* for chaining */
++ } nk;
++ TValue tvk;
++} TKey;
++
++
++typedef struct Node {
++ TValue i_val;
++ TKey i_key;
++} Node;
++
++
++typedef struct Table {
++ CommonHeader;
++ lu_byte flags; /* 1<<p means tagmethod(p) is not present */
++ lu_byte lsizenode; /* log2 of size of `node' array */
++ struct Table *metatable;
++ TValue *array; /* array part */
++ Node *node;
++ Node *lastfree; /* any free position is before this position */
++ GCObject *gclist;
++ int sizearray; /* size of `array' array */
++} Table;
++
++
++
++/*
++** `module' operation for hashing (size is always a power of 2)
++*/
++#define lmod(s,size) \
++ (check_exp((size&(size-1))==0, (cast(int, (s) & ((size)-1)))))
++
++
++#define twoto(x) (1<<(x))
++#define sizenode(t) (twoto((t)->lsizenode))
++
++
++#define luaO_nilobject (&luaO_nilobject_)
++
++LUAI_DATA const TValue luaO_nilobject_;
++
++#define ceillog2(x) (luaO_log2((x)-1) + 1)
++
++LUAI_FUNC int luaO_log2 (unsigned int x);
++LUAI_FUNC int luaO_int2fb (unsigned int x);
++LUAI_FUNC int luaO_fb2int (int x);
++LUAI_FUNC int luaO_rawequalObj (const TValue *t1, const TValue *t2);
++LUAI_FUNC int luaO_str2d (const char *s, lua_Number *result);
++LUAI_FUNC const char *luaO_pushvfstring (lua_State *L, const char *fmt,
++ va_list argp);
++LUAI_FUNC const char *luaO_pushfstring (lua_State *L, const char *fmt, ...);
++LUAI_FUNC void luaO_chunkid (char *out, const char *source, size_t len);
++
++
++#endif
++
+--- /dev/null
++++ b/extensions/LUA/lua/lopcodes.c
+@@ -0,0 +1,102 @@
++/*
++** $Id: lopcodes.c,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $
++** See Copyright Notice in lua.h
++*/
++
++
++#define lopcodes_c
++#define LUA_CORE
++
++
++#include "lopcodes.h"
++
++
++/* ORDER OP */
++
++const char *const luaP_opnames[NUM_OPCODES+1] = {
++ "MOVE",
++ "LOADK",
++ "LOADBOOL",
++ "LOADNIL",
++ "GETUPVAL",
++ "GETGLOBAL",
++ "GETTABLE",
++ "SETGLOBAL",
++ "SETUPVAL",
++ "SETTABLE",
++ "NEWTABLE",
++ "SELF",
++ "ADD",
++ "SUB",
++ "MUL",
++ "DIV",
++ "MOD",
++ "POW",
++ "UNM",
++ "NOT",
++ "LEN",
++ "CONCAT",
++ "JMP",
++ "EQ",
++ "LT",
++ "LE",
++ "TEST",
++ "TESTSET",
++ "CALL",
++ "TAILCALL",
++ "RETURN",
++ "FORLOOP",
++ "FORPREP",
++ "TFORLOOP",
++ "SETLIST",
++ "CLOSE",
++ "CLOSURE",
++ "VARARG",
++ NULL
++};
++
++
++#define opmode(t,a,b,c,m) (((t)<<7) | ((a)<<6) | ((b)<<4) | ((c)<<2) | (m))
++
++const lu_byte luaP_opmodes[NUM_OPCODES] = {
++/* T A B C mode opcode */
++ opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_MOVE */
++ ,opmode(0, 1, OpArgK, OpArgN, iABx) /* OP_LOADK */
++ ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_LOADBOOL */
++ ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_LOADNIL */
++ ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_GETUPVAL */
++ ,opmode(0, 1, OpArgK, OpArgN, iABx) /* OP_GETGLOBAL */
++ ,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_GETTABLE */
++ ,opmode(0, 0, OpArgK, OpArgN, iABx) /* OP_SETGLOBAL */
++ ,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_SETUPVAL */
++ ,opmode(0, 0, OpArgK, OpArgK, iABC) /* OP_SETTABLE */
++ ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_NEWTABLE */
++ ,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_SELF */
++ ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_ADD */
++ ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_SUB */
++ ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MUL */
++ ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_DIV */
++ ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MOD */
++ ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_POW */
++ ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_UNM */
++ ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_NOT */
++ ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_LEN */
++ ,opmode(0, 1, OpArgR, OpArgR, iABC) /* OP_CONCAT */
++ ,opmode(0, 0, OpArgR, OpArgN, iAsBx) /* OP_JMP */
++ ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_EQ */
++ ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LT */
++ ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LE */
++ ,opmode(1, 1, OpArgR, OpArgU, iABC) /* OP_TEST */
++ ,opmode(1, 1, OpArgR, OpArgU, iABC) /* OP_TESTSET */
++ ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_CALL */
++ ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_TAILCALL */
++ ,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_RETURN */
++ ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORLOOP */
++ ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORPREP */
++ ,opmode(1, 0, OpArgN, OpArgU, iABC) /* OP_TFORLOOP */
++ ,opmode(0, 0, OpArgU, OpArgU, iABC) /* OP_SETLIST */
++ ,opmode(0, 0, OpArgN, OpArgN, iABC) /* OP_CLOSE */
++ ,opmode(0, 1, OpArgU, OpArgN, iABx) /* OP_CLOSURE */
++ ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_VARARG */
++};
++
+--- /dev/null
++++ b/extensions/LUA/lua/lopcodes.h
+@@ -0,0 +1,268 @@
++/*
++** $Id: lopcodes.h,v 1.125.1.1 2007/12/27 13:02:25 roberto Exp $
++** Opcodes for Lua virtual machine
++** See Copyright Notice in lua.h
++*/
++
++#ifndef lopcodes_h
++#define lopcodes_h
++
++#include "llimits.h"
++
++
++/*===========================================================================
++ We assume that instructions are unsigned numbers.
++ All instructions have an opcode in the first 6 bits.
++ Instructions can have the following fields:
++ `A' : 8 bits
++ `B' : 9 bits
++ `C' : 9 bits
++ `Bx' : 18 bits (`B' and `C' together)
++ `sBx' : signed Bx
++
++ A signed argument is represented in excess K; that is, the number
++ value is the unsigned value minus K. K is exactly the maximum value
++ for that argument (so that -max is represented by 0, and +max is
++ represented by 2*max), which is half the maximum for the corresponding
++ unsigned argument.
++===========================================================================*/
++
++
++enum OpMode {iABC, iABx, iAsBx}; /* basic instruction format */
++
++
++/*
++** size and position of opcode arguments.
++*/
++#define SIZE_C 9
++#define SIZE_B 9
++#define SIZE_Bx (SIZE_C + SIZE_B)
++#define SIZE_A 8
++
++#define SIZE_OP 6
++
++#define POS_OP 0
++#define POS_A (POS_OP + SIZE_OP)
++#define POS_C (POS_A + SIZE_A)
++#define POS_B (POS_C + SIZE_C)
++#define POS_Bx POS_C
++
++
++/*
++** limits for opcode arguments.
++** we use (signed) int to manipulate most arguments,
++** so they must fit in LUAI_BITSINT-1 bits (-1 for sign)
++*/
++#if SIZE_Bx < LUAI_BITSINT-1
++#define MAXARG_Bx ((1<<SIZE_Bx)-1)
++#define MAXARG_sBx (MAXARG_Bx>>1) /* `sBx' is signed */
++#else
++#define MAXARG_Bx MAX_INT
++#define MAXARG_sBx MAX_INT
++#endif
++
++
++#define MAXARG_A ((1<<SIZE_A)-1)
++#define MAXARG_B ((1<<SIZE_B)-1)
++#define MAXARG_C ((1<<SIZE_C)-1)
++
++
++/* creates a mask with `n' 1 bits at position `p' */
++#define MASK1(n,p) ((~((~(Instruction)0)<<n))<<p)
++
++/* creates a mask with `n' 0 bits at position `p' */
++#define MASK0(n,p) (~MASK1(n,p))
++
++/*
++** the following macros help to manipulate instructions
++*/
++
++#define GET_OPCODE(i) (cast(OpCode, ((i)>>POS_OP) & MASK1(SIZE_OP,0)))
++#define SET_OPCODE(i,o) ((i) = (((i)&MASK0(SIZE_OP,POS_OP)) | \
++ ((cast(Instruction, o)<<POS_OP)&MASK1(SIZE_OP,POS_OP))))
++
++#define GETARG_A(i) (cast(int, ((i)>>POS_A) & MASK1(SIZE_A,0)))
++#define SETARG_A(i,u) ((i) = (((i)&MASK0(SIZE_A,POS_A)) | \
++ ((cast(Instruction, u)<<POS_A)&MASK1(SIZE_A,POS_A))))
++
++#define GETARG_B(i) (cast(int, ((i)>>POS_B) & MASK1(SIZE_B,0)))
++#define SETARG_B(i,b) ((i) = (((i)&MASK0(SIZE_B,POS_B)) | \
++ ((cast(Instruction, b)<<POS_B)&MASK1(SIZE_B,POS_B))))
++
++#define GETARG_C(i) (cast(int, ((i)>>POS_C) & MASK1(SIZE_C,0)))
++#define SETARG_C(i,b) ((i) = (((i)&MASK0(SIZE_C,POS_C)) | \
++ ((cast(Instruction, b)<<POS_C)&MASK1(SIZE_C,POS_C))))
++
++#define GETARG_Bx(i) (cast(int, ((i)>>POS_Bx) & MASK1(SIZE_Bx,0)))
++#define SETARG_Bx(i,b) ((i) = (((i)&MASK0(SIZE_Bx,POS_Bx)) | \
++ ((cast(Instruction, b)<<POS_Bx)&MASK1(SIZE_Bx,POS_Bx))))
++
++#define GETARG_sBx(i) (GETARG_Bx(i)-MAXARG_sBx)
++#define SETARG_sBx(i,b) SETARG_Bx((i),cast(unsigned int, (b)+MAXARG_sBx))
++
++
++#define CREATE_ABC(o,a,b,c) ((cast(Instruction, o)<<POS_OP) \
++ | (cast(Instruction, a)<<POS_A) \
++ | (cast(Instruction, b)<<POS_B) \
++ | (cast(Instruction, c)<<POS_C))
++
++#define CREATE_ABx(o,a,bc) ((cast(Instruction, o)<<POS_OP) \
++ | (cast(Instruction, a)<<POS_A) \
++ | (cast(Instruction, bc)<<POS_Bx))
++
++
++/*
++** Macros to operate RK indices
++*/
++
++/* this bit 1 means constant (0 means register) */
++#define BITRK (1 << (SIZE_B - 1))
++
++/* test whether value is a constant */
++#define ISK(x) ((x) & BITRK)
++
++/* gets the index of the constant */
++#define INDEXK(r) ((int)(r) & ~BITRK)
++
++#define MAXINDEXRK (BITRK - 1)
++
++/* code a constant index as a RK value */
++#define RKASK(x) ((x) | BITRK)
++
++
++/*
++** invalid register that fits in 8 bits
++*/
++#define NO_REG MAXARG_A
++
++
++/*
++** R(x) - register
++** Kst(x) - constant (in constant table)
++** RK(x) == if ISK(x) then Kst(INDEXK(x)) else R(x)
++*/
++
++
++/*
++** grep "ORDER OP" if you change these enums
++*/
++
++typedef enum {
++/*----------------------------------------------------------------------
++name args description
++------------------------------------------------------------------------*/
++OP_MOVE,/* A B R(A) := R(B) */
++OP_LOADK,/* A Bx R(A) := Kst(Bx) */
++OP_LOADBOOL,/* A B C R(A) := (Bool)B; if (C) pc++ */
++OP_LOADNIL,/* A B R(A) := ... := R(B) := nil */
++OP_GETUPVAL,/* A B R(A) := UpValue[B] */
++
++OP_GETGLOBAL,/* A Bx R(A) := Gbl[Kst(Bx)] */
++OP_GETTABLE,/* A B C R(A) := R(B)[RK(C)] */
++
++OP_SETGLOBAL,/* A Bx Gbl[Kst(Bx)] := R(A) */
++OP_SETUPVAL,/* A B UpValue[B] := R(A) */
++OP_SETTABLE,/* A B C R(A)[RK(B)] := RK(C) */
++
++OP_NEWTABLE,/* A B C R(A) := {} (size = B,C) */
++
++OP_SELF,/* A B C R(A+1) := R(B); R(A) := R(B)[RK(C)] */
++
++OP_ADD,/* A B C R(A) := RK(B) + RK(C) */
++OP_SUB,/* A B C R(A) := RK(B) - RK(C) */
++OP_MUL,/* A B C R(A) := RK(B) * RK(C) */
++OP_DIV,/* A B C R(A) := RK(B) / RK(C) */
++OP_MOD,/* A B C R(A) := RK(B) % RK(C) */
++OP_POW,/* A B C R(A) := RK(B) ^ RK(C) */
++OP_UNM,/* A B R(A) := -R(B) */
++OP_NOT,/* A B R(A) := not R(B) */
++OP_LEN,/* A B R(A) := length of R(B) */
++
++OP_CONCAT,/* A B C R(A) := R(B).. ... ..R(C) */
++
++OP_JMP,/* sBx pc+=sBx */
++
++OP_EQ,/* A B C if ((RK(B) == RK(C)) ~= A) then pc++ */
++OP_LT,/* A B C if ((RK(B) < RK(C)) ~= A) then pc++ */
++OP_LE,/* A B C if ((RK(B) <= RK(C)) ~= A) then pc++ */
++
++OP_TEST,/* A C if not (R(A) <=> C) then pc++ */
++OP_TESTSET,/* A B C if (R(B) <=> C) then R(A) := R(B) else pc++ */
++
++OP_CALL,/* A B C R(A), ... ,R(A+C-2) := R(A)(R(A+1), ... ,R(A+B-1)) */
++OP_TAILCALL,/* A B C return R(A)(R(A+1), ... ,R(A+B-1)) */
++OP_RETURN,/* A B return R(A), ... ,R(A+B-2) (see note) */
++
++OP_FORLOOP,/* A sBx R(A)+=R(A+2);
++ if R(A) <?= R(A+1) then { pc+=sBx; R(A+3)=R(A) }*/
++OP_FORPREP,/* A sBx R(A)-=R(A+2); pc+=sBx */
++
++OP_TFORLOOP,/* A C R(A+3), ... ,R(A+2+C) := R(A)(R(A+1), R(A+2));
++ if R(A+3) ~= nil then R(A+2)=R(A+3) else pc++ */
++OP_SETLIST,/* A B C R(A)[(C-1)*FPF+i] := R(A+i), 1 <= i <= B */
++
++OP_CLOSE,/* A close all variables in the stack up to (>=) R(A)*/
++OP_CLOSURE,/* A Bx R(A) := closure(KPROTO[Bx], R(A), ... ,R(A+n)) */
++
++OP_VARARG/* A B R(A), R(A+1), ..., R(A+B-1) = vararg */
++} OpCode;
++
++
++#define NUM_OPCODES (cast(int, OP_VARARG) + 1)
++
++
++
++/*===========================================================================
++ Notes:
++ (*) In OP_CALL, if (B == 0) then B = top. C is the number of returns - 1,
++ and can be 0: OP_CALL then sets `top' to last_result+1, so
++ next open instruction (OP_CALL, OP_RETURN, OP_SETLIST) may use `top'.
++
++ (*) In OP_VARARG, if (B == 0) then use actual number of varargs and
++ set top (like in OP_CALL with C == 0).
++
++ (*) In OP_RETURN, if (B == 0) then return up to `top'
++
++ (*) In OP_SETLIST, if (B == 0) then B = `top';
++ if (C == 0) then next `instruction' is real C
++
++ (*) For comparisons, A specifies what condition the test should accept
++ (true or false).
++
++ (*) All `skips' (pc++) assume that next instruction is a jump
++===========================================================================*/
++
++
++/*
++** masks for instruction properties. The format is:
++** bits 0-1: op mode
++** bits 2-3: C arg mode
++** bits 4-5: B arg mode
++** bit 6: instruction set register A
++** bit 7: operator is a test
++*/
++
++enum OpArgMask {
++ OpArgN, /* argument is not used */
++ OpArgU, /* argument is used */
++ OpArgR, /* argument is a register or a jump offset */
++ OpArgK /* argument is a constant or register/constant */
++};
++
++LUAI_DATA const lu_byte luaP_opmodes[NUM_OPCODES];
++
++#define getOpMode(m) (cast(enum OpMode, luaP_opmodes[m] & 3))
++#define getBMode(m) (cast(enum OpArgMask, (luaP_opmodes[m] >> 4) & 3))
++#define getCMode(m) (cast(enum OpArgMask, (luaP_opmodes[m] >> 2) & 3))
++#define testAMode(m) (luaP_opmodes[m] & (1 << 6))
++#define testTMode(m) (luaP_opmodes[m] & (1 << 7))
++
++
++LUAI_DATA const char *const luaP_opnames[NUM_OPCODES+1]; /* opcode names */
++
++
++/* number of list items to accumulate before a SETLIST instruction */
++#define LFIELDS_PER_FLUSH 50
++
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/lparser.c
+@@ -0,0 +1,1339 @@
++/*
++** $Id: lparser.c,v 2.42.1.3 2007/12/28 15:32:23 roberto Exp $
++** Lua Parser
++** See Copyright Notice in lua.h
++*/
++
++
++#include <string.h>
++
++#define lparser_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "lcode.h"
++#include "ldebug.h"
++#include "ldo.h"
++#include "lfunc.h"
++#include "llex.h"
++#include "lmem.h"
++#include "lobject.h"
++#include "lopcodes.h"
++#include "lparser.h"
++#include "lstate.h"
++#include "lstring.h"
++#include "ltable.h"
++
++
++
++#define hasmultret(k) ((k) == VCALL || (k) == VVARARG)
++
++#define getlocvar(fs, i) ((fs)->f->locvars[(fs)->actvar[i]])
++
++#define luaY_checklimit(fs,v,l,m) if ((v)>(l)) errorlimit(fs,l,m)
++
++
++/*
++** nodes for block list (list of active blocks)
++*/
++typedef struct BlockCnt {
++ struct BlockCnt *previous; /* chain */
++ int breaklist; /* list of jumps out of this loop */
++ lu_byte nactvar; /* # active locals outside the breakable structure */
++ lu_byte upval; /* true if some variable in the block is an upvalue */
++ lu_byte isbreakable; /* true if `block' is a loop */
++} BlockCnt;
++
++
++
++/*
++** prototypes for recursive non-terminal functions
++*/
++static void chunk (LexState *ls);
++static void expr (LexState *ls, expdesc *v);
++
++
++static void anchor_token (LexState *ls) {
++ if (ls->t.token == TK_NAME || ls->t.token == TK_STRING) {
++ TString *ts = ls->t.seminfo.ts;
++ luaX_newstring(ls, getstr(ts), ts->tsv.len);
++ }
++}
++
++
++static void error_expected (LexState *ls, int token) {
++ luaX_syntaxerror(ls,
++ luaO_pushfstring(ls->L, LUA_QS " expected", luaX_token2str(ls, token)));
++}
++
++
++static void errorlimit (FuncState *fs, int limit, const char *what) {
++ const char *msg = (fs->f->linedefined == 0) ?
++ luaO_pushfstring(fs->L, "main function has more than %d %s", limit, what) :
++ luaO_pushfstring(fs->L, "function at line %d has more than %d %s",
++ fs->f->linedefined, limit, what);
++ luaX_lexerror(fs->ls, msg, 0);
++}
++
++
++static int testnext (LexState *ls, int c) {
++ if (ls->t.token == c) {
++ luaX_next(ls);
++ return 1;
++ }
++ else return 0;
++}
++
++
++static void check (LexState *ls, int c) {
++ if (ls->t.token != c)
++ error_expected(ls, c);
++}
++
++static void checknext (LexState *ls, int c) {
++ check(ls, c);
++ luaX_next(ls);
++}
++
++
++#define check_condition(ls,c,msg) { if (!(c)) luaX_syntaxerror(ls, msg); }
++
++
++
++static void check_match (LexState *ls, int what, int who, int where) {
++ if (!testnext(ls, what)) {
++ if (where == ls->linenumber)
++ error_expected(ls, what);
++ else {
++ luaX_syntaxerror(ls, luaO_pushfstring(ls->L,
++ LUA_QS " expected (to close " LUA_QS " at line %d)",
++ luaX_token2str(ls, what), luaX_token2str(ls, who), where));
++ }
++ }
++}
++
++
++static TString *str_checkname (LexState *ls) {
++ TString *ts;
++ check(ls, TK_NAME);
++ ts = ls->t.seminfo.ts;
++ luaX_next(ls);
++ return ts;
++}
++
++
++static void init_exp (expdesc *e, expkind k, int i) {
++ e->f = e->t = NO_JUMP;
++ e->k = k;
++ e->u.s.info = i;
++}
++
++
++static void codestring (LexState *ls, expdesc *e, TString *s) {
++ init_exp(e, VK, luaK_stringK(ls->fs, s));
++}
++
++
++static void checkname(LexState *ls, expdesc *e) {
++ codestring(ls, e, str_checkname(ls));
++}
++
++
++static int registerlocalvar (LexState *ls, TString *varname) {
++ FuncState *fs = ls->fs;
++ Proto *f = fs->f;
++ int oldsize = f->sizelocvars;
++ luaM_growvector(ls->L, f->locvars, fs->nlocvars, f->sizelocvars,
++ LocVar, SHRT_MAX, "too many local variables");
++ while (oldsize < f->sizelocvars) f->locvars[oldsize++].varname = NULL;
++ f->locvars[fs->nlocvars].varname = varname;
++ luaC_objbarrier(ls->L, f, varname);
++ return fs->nlocvars++;
++}
++
++
++#define new_localvarliteral(ls,v,n) \
++ new_localvar(ls, luaX_newstring(ls, "" v, (sizeof(v)/sizeof(char))-1), n)
++
++
++static void new_localvar (LexState *ls, TString *name, int n) {
++ FuncState *fs = ls->fs;
++ luaY_checklimit(fs, fs->nactvar+n+1, LUAI_MAXVARS, "local variables");
++ fs->actvar[fs->nactvar+n] = cast(unsigned short, registerlocalvar(ls, name));
++}
++
++
++static void adjustlocalvars (LexState *ls, int nvars) {
++ FuncState *fs = ls->fs;
++ fs->nactvar = cast_byte(fs->nactvar + nvars);
++ for (; nvars; nvars--) {
++ getlocvar(fs, fs->nactvar - nvars).startpc = fs->pc;
++ }
++}
++
++
++static void removevars (LexState *ls, int tolevel) {
++ FuncState *fs = ls->fs;
++ while (fs->nactvar > tolevel)
++ getlocvar(fs, --fs->nactvar).endpc = fs->pc;
++}
++
++
++static int indexupvalue (FuncState *fs, TString *name, expdesc *v) {
++ int i;
++ Proto *f = fs->f;
++ int oldsize = f->sizeupvalues;
++ for (i=0; i<f->nups; i++) {
++ if (fs->upvalues[i].k == v->k && fs->upvalues[i].info == v->u.s.info) {
++ lua_assert(f->upvalues[i] == name);
++ return i;
++ }
++ }
++ /* new one */
++ luaY_checklimit(fs, f->nups + 1, LUAI_MAXUPVALUES, "upvalues");
++ luaM_growvector(fs->L, f->upvalues, f->nups, f->sizeupvalues,
++ TString *, MAX_INT, "");
++ while (oldsize < f->sizeupvalues) f->upvalues[oldsize++] = NULL;
++ f->upvalues[f->nups] = name;
++ luaC_objbarrier(fs->L, f, name);
++ lua_assert(v->k == VLOCAL || v->k == VUPVAL);
++ fs->upvalues[f->nups].k = cast_byte(v->k);
++ fs->upvalues[f->nups].info = cast_byte(v->u.s.info);
++ return f->nups++;
++}
++
++
++static int searchvar (FuncState *fs, TString *n) {
++ int i;
++ for (i=fs->nactvar-1; i >= 0; i--) {
++ if (n == getlocvar(fs, i).varname)
++ return i;
++ }
++ return -1; /* not found */
++}
++
++
++static void markupval (FuncState *fs, int level) {
++ BlockCnt *bl = fs->bl;
++ while (bl && bl->nactvar > level) bl = bl->previous;
++ if (bl) bl->upval = 1;
++}
++
++
++static int singlevaraux (FuncState *fs, TString *n, expdesc *var, int base) {
++ if (fs == NULL) { /* no more levels? */
++ init_exp(var, VGLOBAL, NO_REG); /* default is global variable */
++ return VGLOBAL;
++ }
++ else {
++ int v = searchvar(fs, n); /* look up at current level */
++ if (v >= 0) {
++ init_exp(var, VLOCAL, v);
++ if (!base)
++ markupval(fs, v); /* local will be used as an upval */
++ return VLOCAL;
++ }
++ else { /* not found at current level; try upper one */
++ if (singlevaraux(fs->prev, n, var, 0) == VGLOBAL)
++ return VGLOBAL;
++ var->u.s.info = indexupvalue(fs, n, var); /* else was LOCAL or UPVAL */
++ var->k = VUPVAL; /* upvalue in this level */
++ return VUPVAL;
++ }
++ }
++}
++
++
++static void singlevar (LexState *ls, expdesc *var) {
++ TString *varname = str_checkname(ls);
++ FuncState *fs = ls->fs;
++ if (singlevaraux(fs, varname, var, 1) == VGLOBAL)
++ var->u.s.info = luaK_stringK(fs, varname); /* info points to global name */
++}
++
++
++static void adjust_assign (LexState *ls, int nvars, int nexps, expdesc *e) {
++ FuncState *fs = ls->fs;
++ int extra = nvars - nexps;
++ if (hasmultret(e->k)) {
++ extra++; /* includes call itself */
++ if (extra < 0) extra = 0;
++ luaK_setreturns(fs, e, extra); /* last exp. provides the difference */
++ if (extra > 1) luaK_reserveregs(fs, extra-1);
++ }
++ else {
++ if (e->k != VVOID) luaK_exp2nextreg(fs, e); /* close last expression */
++ if (extra > 0) {
++ int reg = fs->freereg;
++ luaK_reserveregs(fs, extra);
++ luaK_nil(fs, reg, extra);
++ }
++ }
++}
++
++
++static void enterlevel (LexState *ls) {
++ if (++ls->L->nCcalls > LUAI_MAXCCALLS)
++ luaX_lexerror(ls, "chunk has too many syntax levels", 0);
++}
++
++
++#define leavelevel(ls) ((ls)->L->nCcalls--)
++
++
++static void enterblock (FuncState *fs, BlockCnt *bl, lu_byte isbreakable) {
++ bl->breaklist = NO_JUMP;
++ bl->isbreakable = isbreakable;
++ bl->nactvar = fs->nactvar;
++ bl->upval = 0;
++ bl->previous = fs->bl;
++ fs->bl = bl;
++ lua_assert(fs->freereg == fs->nactvar);
++}
++
++
++static void leaveblock (FuncState *fs) {
++ BlockCnt *bl = fs->bl;
++ fs->bl = bl->previous;
++ removevars(fs->ls, bl->nactvar);
++ if (bl->upval)
++ luaK_codeABC(fs, OP_CLOSE, bl->nactvar, 0, 0);
++ /* a block either controls scope or breaks (never both) */
++ lua_assert(!bl->isbreakable || !bl->upval);
++ lua_assert(bl->nactvar == fs->nactvar);
++ fs->freereg = fs->nactvar; /* free registers */
++ luaK_patchtohere(fs, bl->breaklist);
++}
++
++
++static void pushclosure (LexState *ls, FuncState *func, expdesc *v) {
++ FuncState *fs = ls->fs;
++ Proto *f = fs->f;
++ int oldsize = f->sizep;
++ int i;
++ luaM_growvector(ls->L, f->p, fs->np, f->sizep, Proto *,
++ MAXARG_Bx, "constant table overflow");
++ while (oldsize < f->sizep) f->p[oldsize++] = NULL;
++ f->p[fs->np++] = func->f;
++ luaC_objbarrier(ls->L, f, func->f);
++ init_exp(v, VRELOCABLE, luaK_codeABx(fs, OP_CLOSURE, 0, fs->np-1));
++ for (i=0; i<func->f->nups; i++) {
++ OpCode o = (func->upvalues[i].k == VLOCAL) ? OP_MOVE : OP_GETUPVAL;
++ luaK_codeABC(fs, o, 0, func->upvalues[i].info, 0);
++ }
++}
++
++
++static void open_func (LexState *ls, FuncState *fs) {
++ lua_State *L = ls->L;
++ Proto *f = luaF_newproto(L);
++ fs->f = f;
++ fs->prev = ls->fs; /* linked list of funcstates */
++ fs->ls = ls;
++ fs->L = L;
++ ls->fs = fs;
++ fs->pc = 0;
++ fs->lasttarget = -1;
++ fs->jpc = NO_JUMP;
++ fs->freereg = 0;
++ fs->nk = 0;
++ fs->np = 0;
++ fs->nlocvars = 0;
++ fs->nactvar = 0;
++ fs->bl = NULL;
++ f->source = ls->source;
++ f->maxstacksize = 2; /* registers 0/1 are always valid */
++ fs->h = luaH_new(L, 0, 0);
++ /* anchor table of constants and prototype (to avoid being collected) */
++ sethvalue2s(L, L->top, fs->h);
++ incr_top(L);
++ setptvalue2s(L, L->top, f);
++ incr_top(L);
++}
++
++
++static void close_func (LexState *ls) {
++ lua_State *L = ls->L;
++ FuncState *fs = ls->fs;
++ Proto *f = fs->f;
++ removevars(ls, 0);
++ luaK_ret(fs, 0, 0); /* final return */
++ luaM_reallocvector(L, f->code, f->sizecode, fs->pc, Instruction);
++ f->sizecode = fs->pc;
++ luaM_reallocvector(L, f->lineinfo, f->sizelineinfo, fs->pc, int);
++ f->sizelineinfo = fs->pc;
++ luaM_reallocvector(L, f->k, f->sizek, fs->nk, TValue);
++ f->sizek = fs->nk;
++ luaM_reallocvector(L, f->p, f->sizep, fs->np, Proto *);
++ f->sizep = fs->np;
++ luaM_reallocvector(L, f->locvars, f->sizelocvars, fs->nlocvars, LocVar);
++ f->sizelocvars = fs->nlocvars;
++ luaM_reallocvector(L, f->upvalues, f->sizeupvalues, f->nups, TString *);
++ f->sizeupvalues = f->nups;
++ lua_assert(luaG_checkcode(f));
++ lua_assert(fs->bl == NULL);
++ ls->fs = fs->prev;
++ L->top -= 2; /* remove table and prototype from the stack */
++ /* last token read was anchored in defunct function; must reanchor it */
++ if (fs) anchor_token(ls);
++}
++
++
++Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, const char *name) {
++ struct LexState lexstate;
++ struct FuncState funcstate;
++ lexstate.buff = buff;
++ luaX_setinput(L, &lexstate, z, luaS_new(L, name));
++ open_func(&lexstate, &funcstate);
++ funcstate.f->is_vararg = VARARG_ISVARARG; /* main func. is always vararg */
++ luaX_next(&lexstate); /* read first token */
++ chunk(&lexstate);
++ check(&lexstate, TK_EOS);
++ close_func(&lexstate);
++ lua_assert(funcstate.prev == NULL);
++ lua_assert(funcstate.f->nups == 0);
++ lua_assert(lexstate.fs == NULL);
++ return funcstate.f;
++}
++
++
++
++/*============================================================*/
++/* GRAMMAR RULES */
++/*============================================================*/
++
++
++static void field (LexState *ls, expdesc *v) {
++ /* field -> ['.' | ':'] NAME */
++ FuncState *fs = ls->fs;
++ expdesc key;
++ luaK_exp2anyreg(fs, v);
++ luaX_next(ls); /* skip the dot or colon */
++ checkname(ls, &key);
++ luaK_indexed(fs, v, &key);
++}
++
++
++static void yindex (LexState *ls, expdesc *v) {
++ /* index -> '[' expr ']' */
++ luaX_next(ls); /* skip the '[' */
++ expr(ls, v);
++ luaK_exp2val(ls->fs, v);
++ checknext(ls, ']');
++}
++
++
++/*
++** {======================================================================
++** Rules for Constructors
++** =======================================================================
++*/
++
++
++struct ConsControl {
++ expdesc v; /* last list item read */
++ expdesc *t; /* table descriptor */
++ int nh; /* total number of `record' elements */
++ int na; /* total number of array elements */
++ int tostore; /* number of array elements pending to be stored */
++};
++
++
++static void recfield (LexState *ls, struct ConsControl *cc) {
++ /* recfield -> (NAME | `['exp1`]') = exp1 */
++ FuncState *fs = ls->fs;
++ int reg = ls->fs->freereg;
++ expdesc key, val;
++ int rkkey;
++ if (ls->t.token == TK_NAME) {
++ luaY_checklimit(fs, cc->nh, MAX_INT, "items in a constructor");
++ checkname(ls, &key);
++ }
++ else /* ls->t.token == '[' */
++ yindex(ls, &key);
++ cc->nh++;
++ checknext(ls, '=');
++ rkkey = luaK_exp2RK(fs, &key);
++ expr(ls, &val);
++ luaK_codeABC(fs, OP_SETTABLE, cc->t->u.s.info, rkkey, luaK_exp2RK(fs, &val));
++ fs->freereg = reg; /* free registers */
++}
++
++
++static void closelistfield (FuncState *fs, struct ConsControl *cc) {
++ if (cc->v.k == VVOID) return; /* there is no list item */
++ luaK_exp2nextreg(fs, &cc->v);
++ cc->v.k = VVOID;
++ if (cc->tostore == LFIELDS_PER_FLUSH) {
++ luaK_setlist(fs, cc->t->u.s.info, cc->na, cc->tostore); /* flush */
++ cc->tostore = 0; /* no more items pending */
++ }
++}
++
++
++static void lastlistfield (FuncState *fs, struct ConsControl *cc) {
++ if (cc->tostore == 0) return;
++ if (hasmultret(cc->v.k)) {
++ luaK_setmultret(fs, &cc->v);
++ luaK_setlist(fs, cc->t->u.s.info, cc->na, LUA_MULTRET);
++ cc->na--; /* do not count last expression (unknown number of elements) */
++ }
++ else {
++ if (cc->v.k != VVOID)
++ luaK_exp2nextreg(fs, &cc->v);
++ luaK_setlist(fs, cc->t->u.s.info, cc->na, cc->tostore);
++ }
++}
++
++
++static void listfield (LexState *ls, struct ConsControl *cc) {
++ expr(ls, &cc->v);
++ luaY_checklimit(ls->fs, cc->na, MAX_INT, "items in a constructor");
++ cc->na++;
++ cc->tostore++;
++}
++
++
++static void constructor (LexState *ls, expdesc *t) {
++ /* constructor -> ?? */
++ FuncState *fs = ls->fs;
++ int line = ls->linenumber;
++ int pc = luaK_codeABC(fs, OP_NEWTABLE, 0, 0, 0);
++ struct ConsControl cc;
++ cc.na = cc.nh = cc.tostore = 0;
++ cc.t = t;
++ init_exp(t, VRELOCABLE, pc);
++ init_exp(&cc.v, VVOID, 0); /* no value (yet) */
++ luaK_exp2nextreg(ls->fs, t); /* fix it at stack top (for gc) */
++ checknext(ls, '{');
++ do {
++ lua_assert(cc.v.k == VVOID || cc.tostore > 0);
++ if (ls->t.token == '}') break;
++ closelistfield(fs, &cc);
++ switch(ls->t.token) {
++ case TK_NAME: { /* may be listfields or recfields */
++ luaX_lookahead(ls);
++ if (ls->lookahead.token != '=') /* expression? */
++ listfield(ls, &cc);
++ else
++ recfield(ls, &cc);
++ break;
++ }
++ case '[': { /* constructor_item -> recfield */
++ recfield(ls, &cc);
++ break;
++ }
++ default: { /* constructor_part -> listfield */
++ listfield(ls, &cc);
++ break;
++ }
++ }
++ } while (testnext(ls, ',') || testnext(ls, ';'));
++ check_match(ls, '}', '{', line);
++ lastlistfield(fs, &cc);
++ SETARG_B(fs->f->code[pc], luaO_int2fb(cc.na)); /* set initial array size */
++ SETARG_C(fs->f->code[pc], luaO_int2fb(cc.nh)); /* set initial table size */
++}
++
++/* }====================================================================== */
++
++
++
++static void parlist (LexState *ls) {
++ /* parlist -> [ param { `,' param } ] */
++ FuncState *fs = ls->fs;
++ Proto *f = fs->f;
++ int nparams = 0;
++ f->is_vararg = 0;
++ if (ls->t.token != ')') { /* is `parlist' not empty? */
++ do {
++ switch (ls->t.token) {
++ case TK_NAME: { /* param -> NAME */
++ new_localvar(ls, str_checkname(ls), nparams++);
++ break;
++ }
++ case TK_DOTS: { /* param -> `...' */
++ luaX_next(ls);
++#if defined(LUA_COMPAT_VARARG)
++ /* use `arg' as default name */
++ new_localvarliteral(ls, "arg", nparams++);
++ f->is_vararg = VARARG_HASARG | VARARG_NEEDSARG;
++#endif
++ f->is_vararg |= VARARG_ISVARARG;
++ break;
++ }
++ default: luaX_syntaxerror(ls, "<name> or " LUA_QL("...") " expected");
++ }
++ } while (!f->is_vararg && testnext(ls, ','));
++ }
++ adjustlocalvars(ls, nparams);
++ f->numparams = cast_byte(fs->nactvar - (f->is_vararg & VARARG_HASARG));
++ luaK_reserveregs(fs, fs->nactvar); /* reserve register for parameters */
++}
++
++
++static void body (LexState *ls, expdesc *e, int needself, int line) {
++ /* body -> `(' parlist `)' chunk END */
++ FuncState new_fs;
++ open_func(ls, &new_fs);
++ new_fs.f->linedefined = line;
++ checknext(ls, '(');
++ if (needself) {
++ new_localvarliteral(ls, "self", 0);
++ adjustlocalvars(ls, 1);
++ }
++ parlist(ls);
++ checknext(ls, ')');
++ chunk(ls);
++ new_fs.f->lastlinedefined = ls->linenumber;
++ check_match(ls, TK_END, TK_FUNCTION, line);
++ close_func(ls);
++ pushclosure(ls, &new_fs, e);
++}
++
++
++static int explist1 (LexState *ls, expdesc *v) {
++ /* explist1 -> expr { `,' expr } */
++ int n = 1; /* at least one expression */
++ expr(ls, v);
++ while (testnext(ls, ',')) {
++ luaK_exp2nextreg(ls->fs, v);
++ expr(ls, v);
++ n++;
++ }
++ return n;
++}
++
++
++static void funcargs (LexState *ls, expdesc *f) {
++ FuncState *fs = ls->fs;
++ expdesc args;
++ int base, nparams;
++ int line = ls->linenumber;
++ switch (ls->t.token) {
++ case '(': { /* funcargs -> `(' [ explist1 ] `)' */
++ if (line != ls->lastline)
++ luaX_syntaxerror(ls,"ambiguous syntax (function call x new statement)");
++ luaX_next(ls);
++ if (ls->t.token == ')') /* arg list is empty? */
++ args.k = VVOID;
++ else {
++ explist1(ls, &args);
++ luaK_setmultret(fs, &args);
++ }
++ check_match(ls, ')', '(', line);
++ break;
++ }
++ case '{': { /* funcargs -> constructor */
++ constructor(ls, &args);
++ break;
++ }
++ case TK_STRING: { /* funcargs -> STRING */
++ codestring(ls, &args, ls->t.seminfo.ts);
++ luaX_next(ls); /* must use `seminfo' before `next' */
++ break;
++ }
++ default: {
++ luaX_syntaxerror(ls, "function arguments expected");
++ return;
++ }
++ }
++ lua_assert(f->k == VNONRELOC);
++ base = f->u.s.info; /* base register for call */
++ if (hasmultret(args.k))
++ nparams = LUA_MULTRET; /* open call */
++ else {
++ if (args.k != VVOID)
++ luaK_exp2nextreg(fs, &args); /* close last argument */
++ nparams = fs->freereg - (base+1);
++ }
++ init_exp(f, VCALL, luaK_codeABC(fs, OP_CALL, base, nparams+1, 2));
++ luaK_fixline(fs, line);
++ fs->freereg = base+1; /* call remove function and arguments and leaves
++ (unless changed) one result */
++}
++
++
++
++
++/*
++** {======================================================================
++** Expression parsing
++** =======================================================================
++*/
++
++
++static void prefixexp (LexState *ls, expdesc *v) {
++ /* prefixexp -> NAME | '(' expr ')' */
++ switch (ls->t.token) {
++ case '(': {
++ int line = ls->linenumber;
++ luaX_next(ls);
++ expr(ls, v);
++ check_match(ls, ')', '(', line);
++ luaK_dischargevars(ls->fs, v);
++ return;
++ }
++ case TK_NAME: {
++ singlevar(ls, v);
++ return;
++ }
++ default: {
++ luaX_syntaxerror(ls, "unexpected symbol");
++ return;
++ }
++ }
++}
++
++
++static void primaryexp (LexState *ls, expdesc *v) {
++ /* primaryexp ->
++ prefixexp { `.' NAME | `[' exp `]' | `:' NAME funcargs | funcargs } */
++ FuncState *fs = ls->fs;
++ prefixexp(ls, v);
++ for (;;) {
++ switch (ls->t.token) {
++ case '.': { /* field */
++ field(ls, v);
++ break;
++ }
++ case '[': { /* `[' exp1 `]' */
++ expdesc key;
++ luaK_exp2anyreg(fs, v);
++ yindex(ls, &key);
++ luaK_indexed(fs, v, &key);
++ break;
++ }
++ case ':': { /* `:' NAME funcargs */
++ expdesc key;
++ luaX_next(ls);
++ checkname(ls, &key);
++ luaK_self(fs, v, &key);
++ funcargs(ls, v);
++ break;
++ }
++ case '(': case TK_STRING: case '{': { /* funcargs */
++ luaK_exp2nextreg(fs, v);
++ funcargs(ls, v);
++ break;
++ }
++ default: return;
++ }
++ }
++}
++
++
++static void simpleexp (LexState *ls, expdesc *v) {
++ /* simpleexp -> NUMBER | STRING | NIL | true | false | ... |
++ constructor | FUNCTION body | primaryexp */
++ switch (ls->t.token) {
++ case TK_NUMBER: {
++ init_exp(v, VKNUM, 0);
++ v->u.nval = ls->t.seminfo.r;
++ break;
++ }
++ case TK_STRING: {
++ codestring(ls, v, ls->t.seminfo.ts);
++ break;
++ }
++ case TK_NIL: {
++ init_exp(v, VNIL, 0);
++ break;
++ }
++ case TK_TRUE: {
++ init_exp(v, VTRUE, 0);
++ break;
++ }
++ case TK_FALSE: {
++ init_exp(v, VFALSE, 0);
++ break;
++ }
++ case TK_DOTS: { /* vararg */
++ FuncState *fs = ls->fs;
++ check_condition(ls, fs->f->is_vararg,
++ "cannot use " LUA_QL("...") " outside a vararg function");
++ fs->f->is_vararg &= ~VARARG_NEEDSARG; /* don't need 'arg' */
++ init_exp(v, VVARARG, luaK_codeABC(fs, OP_VARARG, 0, 1, 0));
++ break;
++ }
++ case '{': { /* constructor */
++ constructor(ls, v);
++ return;
++ }
++ case TK_FUNCTION: {
++ luaX_next(ls);
++ body(ls, v, 0, ls->linenumber);
++ return;
++ }
++ default: {
++ primaryexp(ls, v);
++ return;
++ }
++ }
++ luaX_next(ls);
++}
++
++
++static UnOpr getunopr (int op) {
++ switch (op) {
++ case TK_NOT: return OPR_NOT;
++ case '-': return OPR_MINUS;
++ case '#': return OPR_LEN;
++ default: return OPR_NOUNOPR;
++ }
++}
++
++
++static BinOpr getbinopr (int op) {
++ switch (op) {
++ case '+': return OPR_ADD;
++ case '-': return OPR_SUB;
++ case '*': return OPR_MUL;
++ case '/': return OPR_DIV;
++ case '%': return OPR_MOD;
++ case '^': return OPR_POW;
++ case TK_CONCAT: return OPR_CONCAT;
++ case TK_NE: return OPR_NE;
++ case TK_EQ: return OPR_EQ;
++ case '<': return OPR_LT;
++ case TK_LE: return OPR_LE;
++ case '>': return OPR_GT;
++ case TK_GE: return OPR_GE;
++ case TK_AND: return OPR_AND;
++ case TK_OR: return OPR_OR;
++ default: return OPR_NOBINOPR;
++ }
++}
++
++
++static const struct {
++ lu_byte left; /* left priority for each binary operator */
++ lu_byte right; /* right priority */
++} priority[] = { /* ORDER OPR */
++ {6, 6}, {6, 6}, {7, 7}, {7, 7}, {7, 7}, /* `+' `-' `/' `%' */
++ {10, 9}, {5, 4}, /* power and concat (right associative) */
++ {3, 3}, {3, 3}, /* equality and inequality */
++ {3, 3}, {3, 3}, {3, 3}, {3, 3}, /* order */
++ {2, 2}, {1, 1} /* logical (and/or) */
++};
++
++#define UNARY_PRIORITY 8 /* priority for unary operators */
++
++
++/*
++** subexpr -> (simpleexp | unop subexpr) { binop subexpr }
++** where `binop' is any binary operator with a priority higher than `limit'
++*/
++static BinOpr subexpr (LexState *ls, expdesc *v, unsigned int limit) {
++ BinOpr op;
++ UnOpr uop;
++ enterlevel(ls);
++ uop = getunopr(ls->t.token);
++ if (uop != OPR_NOUNOPR) {
++ luaX_next(ls);
++ subexpr(ls, v, UNARY_PRIORITY);
++ luaK_prefix(ls->fs, uop, v);
++ }
++ else simpleexp(ls, v);
++ /* expand while operators have priorities higher than `limit' */
++ op = getbinopr(ls->t.token);
++ while (op != OPR_NOBINOPR && priority[op].left > limit) {
++ expdesc v2;
++ BinOpr nextop;
++ luaX_next(ls);
++ luaK_infix(ls->fs, op, v);
++ /* read sub-expression with higher priority */
++ nextop = subexpr(ls, &v2, priority[op].right);
++ luaK_posfix(ls->fs, op, v, &v2);
++ op = nextop;
++ }
++ leavelevel(ls);
++ return op; /* return first untreated operator */
++}
++
++
++static void expr (LexState *ls, expdesc *v) {
++ subexpr(ls, v, 0);
++}
++
++/* }==================================================================== */
++
++
++
++/*
++** {======================================================================
++** Rules for Statements
++** =======================================================================
++*/
++
++
++static int block_follow (int token) {
++ switch (token) {
++ case TK_ELSE: case TK_ELSEIF: case TK_END:
++ case TK_UNTIL: case TK_EOS:
++ return 1;
++ default: return 0;
++ }
++}
++
++
++static void block (LexState *ls) {
++ /* block -> chunk */
++ FuncState *fs = ls->fs;
++ BlockCnt bl;
++ enterblock(fs, &bl, 0);
++ chunk(ls);
++ lua_assert(bl.breaklist == NO_JUMP);
++ leaveblock(fs);
++}
++
++
++/*
++** structure to chain all variables in the left-hand side of an
++** assignment
++*/
++struct LHS_assign {
++ struct LHS_assign *prev;
++ expdesc v; /* variable (global, local, upvalue, or indexed) */
++};
++
++
++/*
++** check whether, in an assignment to a local variable, the local variable
++** is needed in a previous assignment (to a table). If so, save original
++** local value in a safe place and use this safe copy in the previous
++** assignment.
++*/
++static void check_conflict (LexState *ls, struct LHS_assign *lh, expdesc *v) {
++ FuncState *fs = ls->fs;
++ int extra = fs->freereg; /* eventual position to save local variable */
++ int conflict = 0;
++ for (; lh; lh = lh->prev) {
++ if (lh->v.k == VINDEXED) {
++ if (lh->v.u.s.info == v->u.s.info) { /* conflict? */
++ conflict = 1;
++ lh->v.u.s.info = extra; /* previous assignment will use safe copy */
++ }
++ if (lh->v.u.s.aux == v->u.s.info) { /* conflict? */
++ conflict = 1;
++ lh->v.u.s.aux = extra; /* previous assignment will use safe copy */
++ }
++ }
++ }
++ if (conflict) {
++ luaK_codeABC(fs, OP_MOVE, fs->freereg, v->u.s.info, 0); /* make copy */
++ luaK_reserveregs(fs, 1);
++ }
++}
++
++
++static void assignment (LexState *ls, struct LHS_assign *lh, int nvars) {
++ expdesc e;
++ check_condition(ls, VLOCAL <= lh->v.k && lh->v.k <= VINDEXED,
++ "syntax error");
++ if (testnext(ls, ',')) { /* assignment -> `,' primaryexp assignment */
++ struct LHS_assign nv;
++ nv.prev = lh;
++ primaryexp(ls, &nv.v);
++ if (nv.v.k == VLOCAL)
++ check_conflict(ls, lh, &nv.v);
++ luaY_checklimit(ls->fs, nvars, LUAI_MAXCCALLS - ls->L->nCcalls,
++ "variables in assignment");
++ assignment(ls, &nv, nvars+1);
++ }
++ else { /* assignment -> `=' explist1 */
++ int nexps;
++ checknext(ls, '=');
++ nexps = explist1(ls, &e);
++ if (nexps != nvars) {
++ adjust_assign(ls, nvars, nexps, &e);
++ if (nexps > nvars)
++ ls->fs->freereg -= nexps - nvars; /* remove extra values */
++ }
++ else {
++ luaK_setoneret(ls->fs, &e); /* close last expression */
++ luaK_storevar(ls->fs, &lh->v, &e);
++ return; /* avoid default */
++ }
++ }
++ init_exp(&e, VNONRELOC, ls->fs->freereg-1); /* default assignment */
++ luaK_storevar(ls->fs, &lh->v, &e);
++}
++
++
++static int cond (LexState *ls) {
++ /* cond -> exp */
++ expdesc v;
++ expr(ls, &v); /* read condition */
++ if (v.k == VNIL) v.k = VFALSE; /* `falses' are all equal here */
++ luaK_goiftrue(ls->fs, &v);
++ return v.f;
++}
++
++
++static void breakstat (LexState *ls) {
++ FuncState *fs = ls->fs;
++ BlockCnt *bl = fs->bl;
++ int upval = 0;
++ while (bl && !bl->isbreakable) {
++ upval |= bl->upval;
++ bl = bl->previous;
++ }
++ if (!bl)
++ luaX_syntaxerror(ls, "no loop to break");
++ if (upval)
++ luaK_codeABC(fs, OP_CLOSE, bl->nactvar, 0, 0);
++ luaK_concat(fs, &bl->breaklist, luaK_jump(fs));
++}
++
++
++static void whilestat (LexState *ls, int line) {
++ /* whilestat -> WHILE cond DO block END */
++ FuncState *fs = ls->fs;
++ int whileinit;
++ int condexit;
++ BlockCnt bl;
++ luaX_next(ls); /* skip WHILE */
++ whileinit = luaK_getlabel(fs);
++ condexit = cond(ls);
++ enterblock(fs, &bl, 1);
++ checknext(ls, TK_DO);
++ block(ls);
++ luaK_patchlist(fs, luaK_jump(fs), whileinit);
++ check_match(ls, TK_END, TK_WHILE, line);
++ leaveblock(fs);
++ luaK_patchtohere(fs, condexit); /* false conditions finish the loop */
++}
++
++
++static void repeatstat (LexState *ls, int line) {
++ /* repeatstat -> REPEAT block UNTIL cond */
++ int condexit;
++ FuncState *fs = ls->fs;
++ int repeat_init = luaK_getlabel(fs);
++ BlockCnt bl1, bl2;
++ enterblock(fs, &bl1, 1); /* loop block */
++ enterblock(fs, &bl2, 0); /* scope block */
++ luaX_next(ls); /* skip REPEAT */
++ chunk(ls);
++ check_match(ls, TK_UNTIL, TK_REPEAT, line);
++ condexit = cond(ls); /* read condition (inside scope block) */
++ if (!bl2.upval) { /* no upvalues? */
++ leaveblock(fs); /* finish scope */
++ luaK_patchlist(ls->fs, condexit, repeat_init); /* close the loop */
++ }
++ else { /* complete semantics when there are upvalues */
++ breakstat(ls); /* if condition then break */
++ luaK_patchtohere(ls->fs, condexit); /* else... */
++ leaveblock(fs); /* finish scope... */
++ luaK_patchlist(ls->fs, luaK_jump(fs), repeat_init); /* and repeat */
++ }
++ leaveblock(fs); /* finish loop */
++}
++
++
++static int exp1 (LexState *ls) {
++ expdesc e;
++ int k;
++ expr(ls, &e);
++ k = e.k;
++ luaK_exp2nextreg(ls->fs, &e);
++ return k;
++}
++
++
++static void forbody (LexState *ls, int base, int line, int nvars, int isnum) {
++ /* forbody -> DO block */
++ BlockCnt bl;
++ FuncState *fs = ls->fs;
++ int prep, endfor;
++ adjustlocalvars(ls, 3); /* control variables */
++ checknext(ls, TK_DO);
++ prep = isnum ? luaK_codeAsBx(fs, OP_FORPREP, base, NO_JUMP) : luaK_jump(fs);
++ enterblock(fs, &bl, 0); /* scope for declared variables */
++ adjustlocalvars(ls, nvars);
++ luaK_reserveregs(fs, nvars);
++ block(ls);
++ leaveblock(fs); /* end of scope for declared variables */
++ luaK_patchtohere(fs, prep);
++ endfor = (isnum) ? luaK_codeAsBx(fs, OP_FORLOOP, base, NO_JUMP) :
++ luaK_codeABC(fs, OP_TFORLOOP, base, 0, nvars);
++ luaK_fixline(fs, line); /* pretend that `OP_FOR' starts the loop */
++ luaK_patchlist(fs, (isnum ? endfor : luaK_jump(fs)), prep + 1);
++}
++
++
++static void fornum (LexState *ls, TString *varname, int line) {
++ /* fornum -> NAME = exp1,exp1[,exp1] forbody */
++ FuncState *fs = ls->fs;
++ int base = fs->freereg;
++ new_localvarliteral(ls, "(for index)", 0);
++ new_localvarliteral(ls, "(for limit)", 1);
++ new_localvarliteral(ls, "(for step)", 2);
++ new_localvar(ls, varname, 3);
++ checknext(ls, '=');
++ exp1(ls); /* initial value */
++ checknext(ls, ',');
++ exp1(ls); /* limit */
++ if (testnext(ls, ','))
++ exp1(ls); /* optional step */
++ else { /* default step = 1 */
++ luaK_codeABx(fs, OP_LOADK, fs->freereg, luaK_numberK(fs, 1));
++ luaK_reserveregs(fs, 1);
++ }
++ forbody(ls, base, line, 1, 1);
++}
++
++
++static void forlist (LexState *ls, TString *indexname) {
++ /* forlist -> NAME {,NAME} IN explist1 forbody */
++ FuncState *fs = ls->fs;
++ expdesc e;
++ int nvars = 0;
++ int line;
++ int base = fs->freereg;
++ /* create control variables */
++ new_localvarliteral(ls, "(for generator)", nvars++);
++ new_localvarliteral(ls, "(for state)", nvars++);
++ new_localvarliteral(ls, "(for control)", nvars++);
++ /* create declared variables */
++ new_localvar(ls, indexname, nvars++);
++ while (testnext(ls, ','))
++ new_localvar(ls, str_checkname(ls), nvars++);
++ checknext(ls, TK_IN);
++ line = ls->linenumber;
++ adjust_assign(ls, 3, explist1(ls, &e), &e);
++ luaK_checkstack(fs, 3); /* extra space to call generator */
++ forbody(ls, base, line, nvars - 3, 0);
++}
++
++
++static void forstat (LexState *ls, int line) {
++ /* forstat -> FOR (fornum | forlist) END */
++ FuncState *fs = ls->fs;
++ TString *varname;
++ BlockCnt bl;
++ enterblock(fs, &bl, 1); /* scope for loop and control variables */
++ luaX_next(ls); /* skip `for' */
++ varname = str_checkname(ls); /* first variable name */
++ switch (ls->t.token) {
++ case '=': fornum(ls, varname, line); break;
++ case ',': case TK_IN: forlist(ls, varname); break;
++ default: luaX_syntaxerror(ls, LUA_QL("=") " or " LUA_QL("in") " expected");
++ }
++ check_match(ls, TK_END, TK_FOR, line);
++ leaveblock(fs); /* loop scope (`break' jumps to this point) */
++}
++
++
++static int test_then_block (LexState *ls) {
++ /* test_then_block -> [IF | ELSEIF] cond THEN block */
++ int condexit;
++ luaX_next(ls); /* skip IF or ELSEIF */
++ condexit = cond(ls);
++ checknext(ls, TK_THEN);
++ block(ls); /* `then' part */
++ return condexit;
++}
++
++
++static void ifstat (LexState *ls, int line) {
++ /* ifstat -> IF cond THEN block {ELSEIF cond THEN block} [ELSE block] END */
++ FuncState *fs = ls->fs;
++ int flist;
++ int escapelist = NO_JUMP;
++ flist = test_then_block(ls); /* IF cond THEN block */
++ while (ls->t.token == TK_ELSEIF) {
++ luaK_concat(fs, &escapelist, luaK_jump(fs));
++ luaK_patchtohere(fs, flist);
++ flist = test_then_block(ls); /* ELSEIF cond THEN block */
++ }
++ if (ls->t.token == TK_ELSE) {
++ luaK_concat(fs, &escapelist, luaK_jump(fs));
++ luaK_patchtohere(fs, flist);
++ luaX_next(ls); /* skip ELSE (after patch, for correct line info) */
++ block(ls); /* `else' part */
++ }
++ else
++ luaK_concat(fs, &escapelist, flist);
++ luaK_patchtohere(fs, escapelist);
++ check_match(ls, TK_END, TK_IF, line);
++}
++
++
++static void localfunc (LexState *ls) {
++ expdesc v, b;
++ FuncState *fs = ls->fs;
++ new_localvar(ls, str_checkname(ls), 0);
++ init_exp(&v, VLOCAL, fs->freereg);
++ luaK_reserveregs(fs, 1);
++ adjustlocalvars(ls, 1);
++ body(ls, &b, 0, ls->linenumber);
++ luaK_storevar(fs, &v, &b);
++ /* debug information will only see the variable after this point! */
++ getlocvar(fs, fs->nactvar - 1).startpc = fs->pc;
++}
++
++
++static void localstat (LexState *ls) {
++ /* stat -> LOCAL NAME {`,' NAME} [`=' explist1] */
++ int nvars = 0;
++ int nexps;
++ expdesc e;
++ do {
++ new_localvar(ls, str_checkname(ls), nvars++);
++ } while (testnext(ls, ','));
++ if (testnext(ls, '='))
++ nexps = explist1(ls, &e);
++ else {
++ e.k = VVOID;
++ nexps = 0;
++ }
++ adjust_assign(ls, nvars, nexps, &e);
++ adjustlocalvars(ls, nvars);
++}
++
++
++static int funcname (LexState *ls, expdesc *v) {
++ /* funcname -> NAME {field} [`:' NAME] */
++ int needself = 0;
++ singlevar(ls, v);
++ while (ls->t.token == '.')
++ field(ls, v);
++ if (ls->t.token == ':') {
++ needself = 1;
++ field(ls, v);
++ }
++ return needself;
++}
++
++
++static void funcstat (LexState *ls, int line) {
++ /* funcstat -> FUNCTION funcname body */
++ int needself;
++ expdesc v, b;
++ luaX_next(ls); /* skip FUNCTION */
++ needself = funcname(ls, &v);
++ body(ls, &b, needself, line);
++ luaK_storevar(ls->fs, &v, &b);
++ luaK_fixline(ls->fs, line); /* definition `happens' in the first line */
++}
++
++
++static void exprstat (LexState *ls) {
++ /* stat -> func | assignment */
++ FuncState *fs = ls->fs;
++ struct LHS_assign v;
++ primaryexp(ls, &v.v);
++ if (v.v.k == VCALL) /* stat -> func */
++ SETARG_C(getcode(fs, &v.v), 1); /* call statement uses no results */
++ else { /* stat -> assignment */
++ v.prev = NULL;
++ assignment(ls, &v, 1);
++ }
++}
++
++
++static void retstat (LexState *ls) {
++ /* stat -> RETURN explist */
++ FuncState *fs = ls->fs;
++ expdesc e;
++ int first, nret; /* registers with returned values */
++ luaX_next(ls); /* skip RETURN */
++ if (block_follow(ls->t.token) || ls->t.token == ';')
++ first = nret = 0; /* return no values */
++ else {
++ nret = explist1(ls, &e); /* optional return values */
++ if (hasmultret(e.k)) {
++ luaK_setmultret(fs, &e);
++ if (e.k == VCALL && nret == 1) { /* tail call? */
++ SET_OPCODE(getcode(fs,&e), OP_TAILCALL);
++ lua_assert(GETARG_A(getcode(fs,&e)) == fs->nactvar);
++ }
++ first = fs->nactvar;
++ nret = LUA_MULTRET; /* return all values */
++ }
++ else {
++ if (nret == 1) /* only one single value? */
++ first = luaK_exp2anyreg(fs, &e);
++ else {
++ luaK_exp2nextreg(fs, &e); /* values must go to the `stack' */
++ first = fs->nactvar; /* return all `active' values */
++ lua_assert(nret == fs->freereg - first);
++ }
++ }
++ }
++ luaK_ret(fs, first, nret);
++}
++
++
++static int statement (LexState *ls) {
++ int line = ls->linenumber; /* may be needed for error messages */
++ switch (ls->t.token) {
++ case TK_IF: { /* stat -> ifstat */
++ ifstat(ls, line);
++ return 0;
++ }
++ case TK_WHILE: { /* stat -> whilestat */
++ whilestat(ls, line);
++ return 0;
++ }
++ case TK_DO: { /* stat -> DO block END */
++ luaX_next(ls); /* skip DO */
++ block(ls);
++ check_match(ls, TK_END, TK_DO, line);
++ return 0;
++ }
++ case TK_FOR: { /* stat -> forstat */
++ forstat(ls, line);
++ return 0;
++ }
++ case TK_REPEAT: { /* stat -> repeatstat */
++ repeatstat(ls, line);
++ return 0;
++ }
++ case TK_FUNCTION: {
++ funcstat(ls, line); /* stat -> funcstat */
++ return 0;
++ }
++ case TK_LOCAL: { /* stat -> localstat */
++ luaX_next(ls); /* skip LOCAL */
++ if (testnext(ls, TK_FUNCTION)) /* local function? */
++ localfunc(ls);
++ else
++ localstat(ls);
++ return 0;
++ }
++ case TK_RETURN: { /* stat -> retstat */
++ retstat(ls);
++ return 1; /* must be last statement */
++ }
++ case TK_BREAK: { /* stat -> breakstat */
++ luaX_next(ls); /* skip BREAK */
++ breakstat(ls);
++ return 1; /* must be last statement */
++ }
++ default: {
++ exprstat(ls);
++ return 0; /* to avoid warnings */
++ }
++ }
++}
++
++
++static void chunk (LexState *ls) {
++ /* chunk -> { stat [`;'] } */
++ int islast = 0;
++ enterlevel(ls);
++ while (!islast && !block_follow(ls->t.token)) {
++ islast = statement(ls);
++ testnext(ls, ';');
++ lua_assert(ls->fs->f->maxstacksize >= ls->fs->freereg &&
++ ls->fs->freereg >= ls->fs->nactvar);
++ ls->fs->freereg = ls->fs->nactvar; /* free registers */
++ }
++ leavelevel(ls);
++}
++
++/* }====================================================================== */
+--- /dev/null
++++ b/extensions/LUA/lua/lparser.h
+@@ -0,0 +1,82 @@
++/*
++** $Id: lparser.h,v 1.57.1.1 2007/12/27 13:02:25 roberto Exp $
++** Lua Parser
++** See Copyright Notice in lua.h
++*/
++
++#ifndef lparser_h
++#define lparser_h
++
++#include "llimits.h"
++#include "lobject.h"
++#include "lzio.h"
++
++
++/*
++** Expression descriptor
++*/
++
++typedef enum {
++ VVOID, /* no value */
++ VNIL,
++ VTRUE,
++ VFALSE,
++ VK, /* info = index of constant in `k' */
++ VKNUM, /* nval = numerical value */
++ VLOCAL, /* info = local register */
++ VUPVAL, /* info = index of upvalue in `upvalues' */
++ VGLOBAL, /* info = index of table; aux = index of global name in `k' */
++ VINDEXED, /* info = table register; aux = index register (or `k') */
++ VJMP, /* info = instruction pc */
++ VRELOCABLE, /* info = instruction pc */
++ VNONRELOC, /* info = result register */
++ VCALL, /* info = instruction pc */
++ VVARARG /* info = instruction pc */
++} expkind;
++
++typedef struct expdesc {
++ expkind k;
++ union {
++ struct { int info, aux; } s;
++ lua_Number nval;
++ } u;
++ int t; /* patch list of `exit when true' */
++ int f; /* patch list of `exit when false' */
++} expdesc;
++
++
++typedef struct upvaldesc {
++ lu_byte k;
++ lu_byte info;
++} upvaldesc;
++
++
++struct BlockCnt; /* defined in lparser.c */
++
++
++/* state needed to generate code for a given function */
++typedef struct FuncState {
++ Proto *f; /* current function header */
++ Table *h; /* table to find (and reuse) elements in `k' */
++ struct FuncState *prev; /* enclosing function */
++ struct LexState *ls; /* lexical state */
++ struct lua_State *L; /* copy of the Lua state */
++ struct BlockCnt *bl; /* chain of current blocks */
++ int pc; /* next position to code (equivalent to `ncode') */
++ int lasttarget; /* `pc' of last `jump target' */
++ int jpc; /* list of pending jumps to `pc' */
++ int freereg; /* first free register */
++ int nk; /* number of elements in `k' */
++ int np; /* number of elements in `p' */
++ short nlocvars; /* number of elements in `locvars' */
++ lu_byte nactvar; /* number of active local variables */
++ upvaldesc upvalues[LUAI_MAXUPVALUES]; /* upvalues */
++ unsigned short actvar[LUAI_MAXVARS]; /* declared-variable stack */
++} FuncState;
++
++
++LUAI_FUNC Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff,
++ const char *name);
++
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/lstate.c
+@@ -0,0 +1,214 @@
++/*
++** $Id: lstate.c,v 2.36.1.2 2008/01/03 15:20:39 roberto Exp $
++** Global State
++** See Copyright Notice in lua.h
++*/
++
++
++#include <stddef.h>
++
++#define lstate_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "ldebug.h"
++#include "ldo.h"
++#include "lfunc.h"
++#include "lgc.h"
++#include "llex.h"
++#include "lmem.h"
++#include "lstate.h"
++#include "lstring.h"
++#include "ltable.h"
++#include "ltm.h"
++
++
++#define state_size(x) (sizeof(x) + LUAI_EXTRASPACE)
++#define fromstate(l) (cast(lu_byte *, (l)) - LUAI_EXTRASPACE)
++#define tostate(l) (cast(lua_State *, cast(lu_byte *, l) + LUAI_EXTRASPACE))
++
++
++/*
++** Main thread combines a thread state and the global state
++*/
++typedef struct LG {
++ lua_State l;
++ global_State g;
++} LG;
++
++
++
++static void stack_init (lua_State *L1, lua_State *L) {
++ /* initialize CallInfo array */
++ L1->base_ci = luaM_newvector(L, BASIC_CI_SIZE, CallInfo);
++ L1->ci = L1->base_ci;
++ L1->size_ci = BASIC_CI_SIZE;
++ L1->end_ci = L1->base_ci + L1->size_ci - 1;
++ /* initialize stack array */
++ L1->stack = luaM_newvector(L, BASIC_STACK_SIZE + EXTRA_STACK, TValue);
++ L1->stacksize = BASIC_STACK_SIZE + EXTRA_STACK;
++ L1->top = L1->stack;
++ L1->stack_last = L1->stack+(L1->stacksize - EXTRA_STACK)-1;
++ /* initialize first ci */
++ L1->ci->func = L1->top;
++ setnilvalue(L1->top++); /* `function' entry for this `ci' */
++ L1->base = L1->ci->base = L1->top;
++ L1->ci->top = L1->top + LUA_MINSTACK;
++}
++
++
++static void freestack (lua_State *L, lua_State *L1) {
++ luaM_freearray(L, L1->base_ci, L1->size_ci, CallInfo);
++ luaM_freearray(L, L1->stack, L1->stacksize, TValue);
++}
++
++
++/*
++** open parts that may cause memory-allocation errors
++*/
++static void f_luaopen (lua_State *L, void *ud) {
++ global_State *g = G(L);
++ UNUSED(ud);
++ stack_init(L, L); /* init stack */
++ sethvalue(L, gt(L), luaH_new(L, 0, 2)); /* table of globals */
++ sethvalue(L, registry(L), luaH_new(L, 0, 2)); /* registry */
++ luaS_resize(L, MINSTRTABSIZE); /* initial size of string table */
++ luaT_init(L);
++ luaX_init(L);
++ luaS_fix(luaS_newliteral(L, MEMERRMSG));
++ g->GCthreshold = 4*g->totalbytes;
++}
++
++
++static void preinit_state (lua_State *L, global_State *g) {
++ G(L) = g;
++ L->stack = NULL;
++ L->stacksize = 0;
++ L->errorJmp = NULL;
++ L->hook = NULL;
++ L->hookmask = 0;
++ L->basehookcount = 0;
++ L->allowhook = 1;
++ resethookcount(L);
++ L->openupval = NULL;
++ L->size_ci = 0;
++ L->nCcalls = L->baseCcalls = 0;
++ L->status = 0;
++ L->base_ci = L->ci = NULL;
++ L->savedpc = NULL;
++ L->errfunc = 0;
++ setnilvalue(gt(L));
++}
++
++
++static void close_state (lua_State *L) {
++ global_State *g = G(L);
++ luaF_close(L, L->stack); /* close all upvalues for this thread */
++ luaC_freeall(L); /* collect all objects */
++ lua_assert(g->rootgc == obj2gco(L));
++ lua_assert(g->strt.nuse == 0);
++ luaM_freearray(L, G(L)->strt.hash, G(L)->strt.size, TString *);
++ luaZ_freebuffer(L, &g->buff);
++ freestack(L, L);
++ lua_assert(g->totalbytes == sizeof(LG));
++ (*g->frealloc)(g->ud, fromstate(L), state_size(LG), 0);
++}
++
++
++lua_State *luaE_newthread (lua_State *L) {
++ lua_State *L1 = tostate(luaM_malloc(L, state_size(lua_State)));
++ luaC_link(L, obj2gco(L1), LUA_TTHREAD);
++ preinit_state(L1, G(L));
++ stack_init(L1, L); /* init stack */
++ setobj2n(L, gt(L1), gt(L)); /* share table of globals */
++ L1->hookmask = L->hookmask;
++ L1->basehookcount = L->basehookcount;
++ L1->hook = L->hook;
++ resethookcount(L1);
++ lua_assert(iswhite(obj2gco(L1)));
++ return L1;
++}
++
++
++void luaE_freethread (lua_State *L, lua_State *L1) {
++ luaF_close(L1, L1->stack); /* close all upvalues for this thread */
++ lua_assert(L1->openupval == NULL);
++ luai_userstatefree(L1);
++ freestack(L, L1);
++ luaM_freemem(L, fromstate(L1), state_size(lua_State));
++}
++
++
++LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) {
++ int i;
++ lua_State *L;
++ global_State *g;
++ void *l = (*f)(ud, NULL, 0, state_size(LG));
++ if (l == NULL) return NULL;
++ L = tostate(l);
++ g = &((LG *)L)->g;
++ L->next = NULL;
++ L->tt = LUA_TTHREAD;
++ g->currentwhite = bit2mask(WHITE0BIT, FIXEDBIT);
++ L->marked = luaC_white(g);
++ set2bits(L->marked, FIXEDBIT, SFIXEDBIT);
++ preinit_state(L, g);
++ g->frealloc = f;
++ g->ud = ud;
++ g->mainthread = L;
++ g->uvhead.u.l.prev = &g->uvhead;
++ g->uvhead.u.l.next = &g->uvhead;
++ g->GCthreshold = 0; /* mark it as unfinished state */
++ g->strt.size = 0;
++ g->strt.nuse = 0;
++ g->strt.hash = NULL;
++ setnilvalue(registry(L));
++ luaZ_initbuffer(L, &g->buff);
++ g->panic = NULL;
++ g->gcstate = GCSpause;
++ g->rootgc = obj2gco(L);
++ g->sweepstrgc = 0;
++ g->sweepgc = &g->rootgc;
++ g->gray = NULL;
++ g->grayagain = NULL;
++ g->weak = NULL;
++ g->tmudata = NULL;
++ g->totalbytes = sizeof(LG);
++ g->gcpause = LUAI_GCPAUSE;
++ g->gcstepmul = LUAI_GCMUL;
++ g->gcdept = 0;
++ for (i=0; i<NUM_TAGS; i++) g->mt[i] = NULL;
++ if (luaD_rawrunprotected(L, f_luaopen, NULL) != 0) {
++ /* memory allocation error: free partial state */
++ close_state(L);
++ L = NULL;
++ }
++ else
++ luai_userstateopen(L);
++ return L;
++}
++
++
++static void callallgcTM (lua_State *L, void *ud) {
++ UNUSED(ud);
++ luaC_callGCTM(L); /* call GC metamethods for all udata */
++}
++
++
++LUA_API void lua_close (lua_State *L) {
++ L = G(L)->mainthread; /* only the main thread can be closed */
++ lua_lock(L);
++ luaF_close(L, L->stack); /* close all upvalues for this thread */
++ luaC_separateudata(L, 1); /* separate udata that have GC metamethods */
++ L->errfunc = 0; /* no error function during GC metamethods */
++ do { /* repeat until no more errors */
++ L->ci = L->base_ci;
++ L->base = L->top = L->ci->base;
++ L->nCcalls = L->baseCcalls = 0;
++ } while (luaD_rawrunprotected(L, callallgcTM, NULL) != 0);
++ lua_assert(G(L)->tmudata == NULL);
++ luai_userstateclose(L);
++ close_state(L);
++}
++
+--- /dev/null
++++ b/extensions/LUA/lua/lstate.h
+@@ -0,0 +1,169 @@
++/*
++** $Id: lstate.h,v 2.24.1.2 2008/01/03 15:20:39 roberto Exp $
++** Global State
++** See Copyright Notice in lua.h
++*/
++
++#ifndef lstate_h
++#define lstate_h
++
++#include "lua.h"
++
++#include "lobject.h"
++#include "ltm.h"
++#include "lzio.h"
++
++
++
++struct lua_longjmp; /* defined in ldo.c */
++
++
++/* table of globals */
++#define gt(L) (&L->l_gt)
++
++/* registry */
++#define registry(L) (&G(L)->l_registry)
++
++
++/* extra stack space to handle TM calls and some other extras */
++#define EXTRA_STACK 5
++
++
++#define BASIC_CI_SIZE 8
++
++#define BASIC_STACK_SIZE (2*LUA_MINSTACK)
++
++
++
++typedef struct stringtable {
++ GCObject **hash;
++ lu_int32 nuse; /* number of elements */
++ int size;
++} stringtable;
++
++
++/*
++** informations about a call
++*/
++typedef struct CallInfo {
++ StkId base; /* base for this function */
++ StkId func; /* function index in the stack */
++ StkId top; /* top for this function */
++ const Instruction *savedpc;
++ int nresults; /* expected number of results from this function */
++ int tailcalls; /* number of tail calls lost under this entry */
++} CallInfo;
++
++
++
++#define curr_func(L) (clvalue(L->ci->func))
++#define ci_func(ci) (clvalue((ci)->func))
++#define f_isLua(ci) (!ci_func(ci)->c.isC)
++#define isLua(ci) (ttisfunction((ci)->func) && f_isLua(ci))
++
++
++/*
++** `global state', shared by all threads of this state
++*/
++typedef struct global_State {
++ stringtable strt; /* hash table for strings */
++ lua_Alloc frealloc; /* function to reallocate memory */
++ void *ud; /* auxiliary data to `frealloc' */
++ lu_byte currentwhite;
++ lu_byte gcstate; /* state of garbage collector */
++ int sweepstrgc; /* position of sweep in `strt' */
++ GCObject *rootgc; /* list of all collectable objects */
++ GCObject **sweepgc; /* position of sweep in `rootgc' */
++ GCObject *gray; /* list of gray objects */
++ GCObject *grayagain; /* list of objects to be traversed atomically */
++ GCObject *weak; /* list of weak tables (to be cleared) */
++ GCObject *tmudata; /* last element of list of userdata to be GC */
++ Mbuffer buff; /* temporary buffer for string concatentation */
++ lu_mem GCthreshold;
++ lu_mem totalbytes; /* number of bytes currently allocated */
++ lu_mem estimate; /* an estimate of number of bytes actually in use */
++ lu_mem gcdept; /* how much GC is `behind schedule' */
++ int gcpause; /* size of pause between successive GCs */
++ int gcstepmul; /* GC `granularity' */
++ lua_CFunction panic; /* to be called in unprotected errors */
++ TValue l_registry;
++ struct lua_State *mainthread;
++ UpVal uvhead; /* head of double-linked list of all open upvalues */
++ struct Table *mt[NUM_TAGS]; /* metatables for basic types */
++ TString *tmname[TM_N]; /* array with tag-method names */
++} global_State;
++
++
++/*
++** `per thread' state
++*/
++struct lua_State {
++ CommonHeader;
++ lu_byte status;
++ StkId top; /* first free slot in the stack */
++ StkId base; /* base of current function */
++ global_State *l_G;
++ CallInfo *ci; /* call info for current function */
++ const Instruction *savedpc; /* `savedpc' of current function */
++ StkId stack_last; /* last free slot in the stack */
++ StkId stack; /* stack base */
++ CallInfo *end_ci; /* points after end of ci array*/
++ CallInfo *base_ci; /* array of CallInfo's */
++ int stacksize;
++ int size_ci; /* size of array `base_ci' */
++ unsigned short nCcalls; /* number of nested C calls */
++ unsigned short baseCcalls; /* nested C calls when resuming coroutine */
++ lu_byte hookmask;
++ lu_byte allowhook;
++ int basehookcount;
++ int hookcount;
++ lua_Hook hook;
++ TValue l_gt; /* table of globals */
++ TValue env; /* temporary place for environments */
++ GCObject *openupval; /* list of open upvalues in this stack */
++ GCObject *gclist;
++ struct lua_longjmp *errorJmp; /* current error recover point */
++ ptrdiff_t errfunc; /* current error handling function (stack index) */
++};
++
++
++#define G(L) (L->l_G)
++
++
++/*
++** Union of all collectable objects
++*/
++union GCObject {
++ GCheader gch;
++ union TString ts;
++ union Udata u;
++ union Closure cl;
++ struct Table h;
++ struct Proto p;
++ struct UpVal uv;
++ struct lua_State th; /* thread */
++};
++
++
++/* macros to convert a GCObject into a specific value */
++#define rawgco2ts(o) check_exp((o)->gch.tt == LUA_TSTRING, &((o)->ts))
++#define gco2ts(o) (&rawgco2ts(o)->tsv)
++#define rawgco2u(o) check_exp((o)->gch.tt == LUA_TUSERDATA, &((o)->u))
++#define gco2u(o) (&rawgco2u(o)->uv)
++#define gco2cl(o) check_exp((o)->gch.tt == LUA_TFUNCTION, &((o)->cl))
++#define gco2h(o) check_exp((o)->gch.tt == LUA_TTABLE, &((o)->h))
++#define gco2p(o) check_exp((o)->gch.tt == LUA_TPROTO, &((o)->p))
++#define gco2uv(o) check_exp((o)->gch.tt == LUA_TUPVAL, &((o)->uv))
++#define ngcotouv(o) \
++ check_exp((o) == NULL || (o)->gch.tt == LUA_TUPVAL, &((o)->uv))
++#define gco2th(o) check_exp((o)->gch.tt == LUA_TTHREAD, &((o)->th))
++
++/* macro to convert any Lua object into a GCObject */
++#define obj2gco(v) (cast(GCObject *, (v)))
++
++
++LUAI_FUNC lua_State *luaE_newthread (lua_State *L);
++LUAI_FUNC void luaE_freethread (lua_State *L, lua_State *L1);
++
++#endif
++
+--- /dev/null
++++ b/extensions/LUA/lua/lstring.c
+@@ -0,0 +1,110 @@
++/*
++** $Id: lstring.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $
++** String table (keeps all strings handled by Lua)
++** See Copyright Notice in lua.h
++*/
++
++#include <string.h>
++
++#define lstring_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "lmem.h"
++#include "lobject.h"
++#include "lstate.h"
++#include "lstring.h"
++
++
++
++void luaS_resize (lua_State *L, int newsize) {
++ GCObject **newhash;
++ stringtable *tb;
++ int i;
++ if (G(L)->gcstate == GCSsweepstring)
++ return; /* cannot resize during GC traverse */
++ newhash = luaM_newvector(L, newsize, GCObject *);
++ tb = &G(L)->strt;
++ for (i=0; i<newsize; i++) newhash[i] = NULL;
++ /* rehash */
++ for (i=0; i<tb->size; i++) {
++ GCObject *p = tb->hash[i];
++ while (p) { /* for each node in the list */
++ GCObject *next = p->gch.next; /* save next */
++ unsigned int h = gco2ts(p)->hash;
++ int h1 = lmod(h, newsize); /* new position */
++ lua_assert(cast_int(h%newsize) == lmod(h, newsize));
++ p->gch.next = newhash[h1]; /* chain it */
++ newhash[h1] = p;
++ p = next;
++ }
++ }
++ luaM_freearray(L, tb->hash, tb->size, TString *);
++ tb->size = newsize;
++ tb->hash = newhash;
++}
++
++
++static TString *newlstr (lua_State *L, const char *str, size_t l,
++ unsigned int h) {
++ TString *ts;
++ stringtable *tb;
++ if (l+1 > (MAX_SIZET - sizeof(TString))/sizeof(char))
++ luaM_toobig(L);
++ ts = cast(TString *, luaM_malloc(L, (l+1)*sizeof(char)+sizeof(TString)));
++ ts->tsv.len = l;
++ ts->tsv.hash = h;
++ ts->tsv.marked = luaC_white(G(L));
++ ts->tsv.tt = LUA_TSTRING;
++ ts->tsv.reserved = 0;
++ memcpy(ts+1, str, l*sizeof(char));
++ ((char *)(ts+1))[l] = '\0'; /* ending 0 */
++ tb = &G(L)->strt;
++ h = lmod(h, tb->size);
++ ts->tsv.next = tb->hash[h]; /* chain new entry */
++ tb->hash[h] = obj2gco(ts);
++ tb->nuse++;
++ if (tb->nuse > cast(lu_int32, tb->size) && tb->size <= MAX_INT/2)
++ luaS_resize(L, tb->size*2); /* too crowded */
++ return ts;
++}
++
++
++TString *luaS_newlstr (lua_State *L, const char *str, size_t l) {
++ GCObject *o;
++ unsigned int h = cast(unsigned int, l); /* seed */
++ size_t step = (l>>5)+1; /* if string is too long, don't hash all its chars */
++ size_t l1;
++ for (l1=l; l1>=step; l1-=step) /* compute hash */
++ h = h ^ ((h<<5)+(h>>2)+cast(unsigned char, str[l1-1]));
++ for (o = G(L)->strt.hash[lmod(h, G(L)->strt.size)];
++ o != NULL;
++ o = o->gch.next) {
++ TString *ts = rawgco2ts(o);
++ if (ts->tsv.len == l && (memcmp(str, getstr(ts), l) == 0)) {
++ /* string may be dead */
++ if (isdead(G(L), o)) changewhite(o);
++ return ts;
++ }
++ }
++ return newlstr(L, str, l, h); /* not found */
++}
++
++
++Udata *luaS_newudata (lua_State *L, size_t s, Table *e) {
++ Udata *u;
++ if (s > MAX_SIZET - sizeof(Udata))
++ luaM_toobig(L);
++ u = cast(Udata *, luaM_malloc(L, s + sizeof(Udata)));
++ u->uv.marked = luaC_white(G(L)); /* is not finalized */
++ u->uv.tt = LUA_TUSERDATA;
++ u->uv.len = s;
++ u->uv.metatable = NULL;
++ u->uv.env = e;
++ /* chain it on udata list (after main thread) */
++ u->uv.next = G(L)->mainthread->next;
++ G(L)->mainthread->next = obj2gco(u);
++ return u;
++}
++
+--- /dev/null
++++ b/extensions/LUA/lua/lstring.h
+@@ -0,0 +1,31 @@
++/*
++** $Id: lstring.h,v 1.43.1.1 2007/12/27 13:02:25 roberto Exp $
++** String table (keep all strings handled by Lua)
++** See Copyright Notice in lua.h
++*/
++
++#ifndef lstring_h
++#define lstring_h
++
++
++#include "lgc.h"
++#include "lobject.h"
++#include "lstate.h"
++
++
++#define sizestring(s) (sizeof(union TString)+((s)->len+1)*sizeof(char))
++
++#define sizeudata(u) (sizeof(union Udata)+(u)->len)
++
++#define luaS_new(L, s) (luaS_newlstr(L, s, strlen(s)))
++#define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \
++ (sizeof(s)/sizeof(char))-1))
++
++#define luaS_fix(s) l_setbit((s)->tsv.marked, FIXEDBIT)
++
++LUAI_FUNC void luaS_resize (lua_State *L, int newsize);
++LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, Table *e);
++LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l);
++
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/lstrlib.c
+@@ -0,0 +1,883 @@
++/*
++** $Id: lstrlib.c,v 1.132.1.4 2008/07/11 17:27:21 roberto Exp $
++** Standard library for string operations and pattern-matching
++** See Copyright Notice in lua.h
++*/
++
++
++#include <ctype.h>
++#include <stddef.h>
++#include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
++
++#define lstrlib_c
++#define LUA_LIB
++
++#include "lua.h"
++
++#include "lauxlib.h"
++#include "lualib.h"
++
++
++/* macro to `unsign' a character */
++#define uchar(c) ((unsigned char)(c))
++
++
++
++static int str_len (lua_State *L) {
++ size_t l;
++ luaL_checklstring(L, 1, &l);
++ lua_pushinteger(L, l);
++ return 1;
++}
++
++
++static ptrdiff_t posrelat (ptrdiff_t pos, size_t len) {
++ /* relative string position: negative means back from end */
++ if (pos < 0) pos += (ptrdiff_t)len + 1;
++ return (pos >= 0) ? pos : 0;
++}
++
++
++static int str_sub (lua_State *L) {
++ size_t l;
++ const char *s = luaL_checklstring(L, 1, &l);
++ ptrdiff_t start = posrelat(luaL_checkinteger(L, 2), l);
++ ptrdiff_t end = posrelat(luaL_optinteger(L, 3, -1), l);
++ if (start < 1) start = 1;
++ if (end > (ptrdiff_t)l) end = (ptrdiff_t)l;
++ if (start <= end)
++ lua_pushlstring(L, s+start-1, end-start+1);
++ else lua_pushliteral(L, "");
++ return 1;
++}
++
++
++static int str_reverse (lua_State *L) {
++ size_t l;
++ const char *s = luaL_checklstring(L, 1, &l);
++ luaL_Buffer *b = (luaL_Buffer *)kmalloc(sizeof(luaL_Buffer) + BUFSIZ, GFP_ATOMIC);
++ if(!b) luaL_error(L, "str_reverse: cannot allocate memory");
++ luaL_buffinit(L, b);
++ while (l--) luaL_addchar(b, s[l]);
++ luaL_pushresult(b);
++ kfree(b);
++ return 1;
++}
++
++
++static int str_lower (lua_State *L) {
++ size_t l;
++ size_t i;
++ const char *s = luaL_checklstring(L, 1, &l);
++ luaL_Buffer *b = (luaL_Buffer *)kmalloc(sizeof(luaL_Buffer) + BUFSIZ, GFP_ATOMIC);
++ if(!b) luaL_error(L, "str_lower: cannot allocate memory");
++ luaL_buffinit(L, b);
++ for (i=0; i<l; i++)
++ luaL_addchar(b, tolower(uchar(s[i])));
++ luaL_pushresult(b);
++ kfree(b);
++ return 1;
++}
++
++
++static int str_upper (lua_State *L) {
++ size_t l;
++ size_t i;
++ const char *s = luaL_checklstring(L, 1, &l);
++ luaL_Buffer *b = (luaL_Buffer *)kmalloc(sizeof(luaL_Buffer) + BUFSIZ, GFP_ATOMIC);
++ if(!b) luaL_error(L, "str_upper: cannot allocate memory");
++ luaL_buffinit(L, b);
++ for (i=0; i<l; i++)
++ luaL_addchar(b, toupper(uchar(s[i])));
++ luaL_pushresult(b);
++ kfree(b);
++ return 1;
++}
++
++static int str_rep (lua_State *L) {
++ size_t l;
++ const char *s = luaL_checklstring(L, 1, &l);
++ int n = luaL_checkint(L, 2);
++ luaL_Buffer *b = (luaL_Buffer *)kmalloc(sizeof(luaL_Buffer) + BUFSIZ, GFP_ATOMIC);
++ if(!b) luaL_error(L, "str_rep: cannot allocate memory");
++ luaL_buffinit(L, b);
++ while (n-- > 0)
++ luaL_addlstring(b, s, l);
++ luaL_pushresult(b);
++ kfree(b);
++ return 1;
++}
++
++
++static int str_byte (lua_State *L) {
++ size_t l;
++ const char *s = luaL_checklstring(L, 1, &l);
++ ptrdiff_t posi = posrelat(luaL_optinteger(L, 2, 1), l);
++ ptrdiff_t pose = posrelat(luaL_optinteger(L, 3, posi), l);
++ int n, i;
++ if (posi <= 0) posi = 1;
++ if ((size_t)pose > l) pose = l;
++ if (posi > pose) return 0; /* empty interval; return no values */
++ n = (int)(pose - posi + 1);
++ if (posi + n <= pose) /* overflow? */
++ luaL_error(L, "string slice too long");
++ luaL_checkstack(L, n, "string slice too long");
++ for (i=0; i<n; i++)
++ lua_pushinteger(L, uchar(s[posi+i-1]));
++ return n;
++}
++
++
++static int str_char (lua_State *L) {
++ int n = lua_gettop(L); /* number of arguments */
++ int i;
++ luaL_Buffer *b = (luaL_Buffer *)kmalloc(sizeof(luaL_Buffer) + BUFSIZ, GFP_ATOMIC);
++ if(!b) luaL_error(L, "str_char: cannot allocate memory");
++ luaL_buffinit(L, b);
++ for (i=1; i<=n; i++) {
++ int c = luaL_checkint(L, i);
++ luaL_argcheck(L, uchar(c) == c, i, "invalid value");
++ luaL_addchar(b, uchar(c));
++ }
++ luaL_pushresult(b);
++ kfree(b);
++ return 1;
++}
++
++
++static int writer (lua_State *L, const void* b, size_t size, void* B) {
++ (void)L;
++ luaL_addlstring((luaL_Buffer*) B, (const char *)b, size);
++ return 0;
++}
++
++
++static int str_dump (lua_State *L) {
++ luaL_Buffer *b = (luaL_Buffer *)kmalloc(sizeof(luaL_Buffer) + BUFSIZ, GFP_ATOMIC);
++ if(!b) luaL_error(L, "str_dump: cannot allocate memory");
++ luaL_checktype(L, 1, LUA_TFUNCTION);
++ lua_settop(L, 1);
++ luaL_buffinit(L,b);
++ if (lua_dump(L, writer, b) != 0){
++ kfree(b);
++ luaL_error(L, "unable to dump given function");
++ }
++
++ luaL_pushresult(b);
++ kfree(b);
++ return 1;
++}
++
++
++
++/*
++** {======================================================
++** PATTERN MATCHING
++** =======================================================
++*/
++
++
++#define CAP_UNFINISHED (-1)
++#define CAP_POSITION (-2)
++
++typedef struct MatchState {
++ const char *src_init; /* init of source string */
++ const char *src_end; /* end (`\0') of source string */
++ lua_State *L;
++ int level; /* total number of captures (finished or unfinished) */
++ struct {
++ const char *init;
++ ptrdiff_t len;
++ } capture[LUA_MAXCAPTURES];
++} MatchState;
++
++
++#define L_ESC '%'
++#define SPECIALS "^$*+?.([%-"
++
++
++static int check_capture (MatchState *ms, int l) {
++ l -= '1';
++ if (l < 0 || l >= ms->level || ms->capture[l].len == CAP_UNFINISHED)
++ return luaL_error(ms->L, "invalid capture index");
++ return l;
++}
++
++
++static int capture_to_close (MatchState *ms) {
++ int level = ms->level;
++ for (level--; level>=0; level--)
++ if (ms->capture[level].len == CAP_UNFINISHED) return level;
++ return luaL_error(ms->L, "invalid pattern capture");
++}
++
++
++static const char *classend (MatchState *ms, const char *p) {
++ switch (*p++) {
++ case L_ESC: {
++ if (*p == '\0')
++ luaL_error(ms->L, "malformed pattern (ends with " LUA_QL("%%") ")");
++ return p+1;
++ }
++ case '[': {
++ if (*p == '^') p++;
++ do { /* look for a `]' */
++ if (*p == '\0')
++ luaL_error(ms->L, "malformed pattern (missing " LUA_QL("]") ")");
++ if (*(p++) == L_ESC && *p != '\0')
++ p++; /* skip escapes (e.g. `%]') */
++ } while (*p != ']');
++ return p+1;
++ }
++ default: {
++ return p;
++ }
++ }
++}
++
++
++static int match_class (int c, int cl) {
++ int res;
++ switch (tolower(cl)) {
++ case 'a' : res = isalpha(c); break;
++ case 'c' : res = iscntrl(c); break;
++ case 'd' : res = isdigit(c); break;
++ case 'l' : res = islower(c); break;
++ case 'p' : res = ispunct(c); break;
++ case 's' : res = isspace(c); break;
++ case 'u' : res = isupper(c); break;
++ case 'w' : res = isalnum(c); break;
++ case 'x' : res = isxdigit(c); break;
++ case 'z' : res = (c == 0); break;
++ default: return (cl == c);
++ }
++ return (islower(cl) ? res : !res);
++}
++
++
++static int matchbracketclass (int c, const char *p, const char *ec) {
++ int sig = 1;
++ if (*(p+1) == '^') {
++ sig = 0;
++ p++; /* skip the `^' */
++ }
++ while (++p < ec) {
++ if (*p == L_ESC) {
++ p++;
++ if (match_class(c, uchar(*p)))
++ return sig;
++ }
++ else if ((*(p+1) == '-') && (p+2 < ec)) {
++ p+=2;
++ if (uchar(*(p-2)) <= c && c <= uchar(*p))
++ return sig;
++ }
++ else if (uchar(*p) == c) return sig;
++ }
++ return !sig;
++}
++
++
++static int singlematch (int c, const char *p, const char *ep) {
++ switch (*p) {
++ case '.': return 1; /* matches any char */
++ case L_ESC: return match_class(c, uchar(*(p+1)));
++ case '[': return matchbracketclass(c, p, ep-1);
++ default: return (uchar(*p) == c);
++ }
++}
++
++
++static const char *match (MatchState *ms, const char *s, const char *p);
++
++
++static const char *matchbalance (MatchState *ms, const char *s,
++ const char *p) {
++ if (*p == 0 || *(p+1) == 0)
++ luaL_error(ms->L, "unbalanced pattern");
++ if (*s != *p) return NULL;
++ else {
++ int b = *p;
++ int e = *(p+1);
++ int cont = 1;
++ while (++s < ms->src_end) {
++ if (*s == e) {
++ if (--cont == 0) return s+1;
++ }
++ else if (*s == b) cont++;
++ }
++ }
++ return NULL; /* string ends out of balance */
++}
++
++
++static const char *max_expand (MatchState *ms, const char *s,
++ const char *p, const char *ep) {
++ ptrdiff_t i = 0; /* counts maximum expand for item */
++ while ((s+i)<ms->src_end && singlematch(uchar(*(s+i)), p, ep))
++ i++;
++ /* keeps trying to match with the maximum repetitions */
++ while (i>=0) {
++ const char *res = match(ms, (s+i), ep+1);
++ if (res) return res;
++ i--; /* else didn't match; reduce 1 repetition to try again */
++ }
++ return NULL;
++}
++
++
++static const char *min_expand (MatchState *ms, const char *s,
++ const char *p, const char *ep) {
++ for (;;) {
++ const char *res = match(ms, s, ep+1);
++ if (res != NULL)
++ return res;
++ else if (s<ms->src_end && singlematch(uchar(*s), p, ep))
++ s++; /* try with one more repetition */
++ else return NULL;
++ }
++}
++
++
++static const char *start_capture (MatchState *ms, const char *s,
++ const char *p, int what) {
++ const char *res;
++ int level = ms->level;
++ if (level >= LUA_MAXCAPTURES) luaL_error(ms->L, "too many captures");
++ ms->capture[level].init = s;
++ ms->capture[level].len = what;
++ ms->level = level+1;
++ if ((res=match(ms, s, p)) == NULL) /* match failed? */
++ ms->level--; /* undo capture */
++ return res;
++}
++
++
++static const char *end_capture (MatchState *ms, const char *s,
++ const char *p) {
++ int l = capture_to_close(ms);
++ const char *res;
++ ms->capture[l].len = s - ms->capture[l].init; /* close capture */
++ if ((res = match(ms, s, p)) == NULL) /* match failed? */
++ ms->capture[l].len = CAP_UNFINISHED; /* undo capture */
++ return res;
++}
++
++
++static const char *match_capture (MatchState *ms, const char *s, int l) {
++ size_t len;
++ l = check_capture(ms, l);
++ len = ms->capture[l].len;
++ if ((size_t)(ms->src_end-s) >= len &&
++ memcmp(ms->capture[l].init, s, len) == 0)
++ return s+len;
++ else return NULL;
++}
++
++
++static const char *match (MatchState *ms, const char *s, const char *p) {
++ init: /* using goto's to optimize tail recursion */
++ switch (*p) {
++ case '(': { /* start capture */
++ if (*(p+1) == ')') /* position capture? */
++ return start_capture(ms, s, p+2, CAP_POSITION);
++ else
++ return start_capture(ms, s, p+1, CAP_UNFINISHED);
++ }
++ case ')': { /* end capture */
++ return end_capture(ms, s, p+1);
++ }
++ case L_ESC: {
++ switch (*(p+1)) {
++ case 'b': { /* balanced string? */
++ s = matchbalance(ms, s, p+2);
++ if (s == NULL) return NULL;
++ p+=4; goto init; /* else return match(ms, s, p+4); */
++ }
++ case 'f': { /* frontier? */
++ const char *ep; char previous;
++ p += 2;
++ if (*p != '[')
++ luaL_error(ms->L, "missing " LUA_QL("[") " after "
++ LUA_QL("%%f") " in pattern");
++ ep = classend(ms, p); /* points to what is next */
++ previous = (s == ms->src_init) ? '\0' : *(s-1);
++ if (matchbracketclass(uchar(previous), p, ep-1) ||
++ !matchbracketclass(uchar(*s), p, ep-1)) return NULL;
++ p=ep; goto init; /* else return match(ms, s, ep); */
++ }
++ default: {
++ if (isdigit(uchar(*(p+1)))) { /* capture results (%0-%9)? */
++ s = match_capture(ms, s, uchar(*(p+1)));
++ if (s == NULL) return NULL;
++ p+=2; goto init; /* else return match(ms, s, p+2) */
++ }
++ goto dflt; /* case default */
++ }
++ }
++ }
++ case '\0': { /* end of pattern */
++ return s; /* match succeeded */
++ }
++ case '$': {
++ if (*(p+1) == '\0') /* is the `$' the last char in pattern? */
++ return (s == ms->src_end) ? s : NULL; /* check end of string */
++ else goto dflt;
++ }
++ default: dflt: { /* it is a pattern item */
++ const char *ep = classend(ms, p); /* points to what is next */
++ int m = s<ms->src_end && singlematch(uchar(*s), p, ep);
++ switch (*ep) {
++ case '?': { /* optional */
++ const char *res;
++ if (m && ((res=match(ms, s+1, ep+1)) != NULL))
++ return res;
++ p=ep+1; goto init; /* else return match(ms, s, ep+1); */
++ }
++ case '*': { /* 0 or more repetitions */
++ return max_expand(ms, s, p, ep);
++ }
++ case '+': { /* 1 or more repetitions */
++ return (m ? max_expand(ms, s+1, p, ep) : NULL);
++ }
++ case '-': { /* 0 or more repetitions (minimum) */
++ return min_expand(ms, s, p, ep);
++ }
++ default: {
++ if (!m) return NULL;
++ s++; p=ep; goto init; /* else return match(ms, s+1, ep); */
++ }
++ }
++ }
++ }
++}
++
++
++
++static const char *lmemfind (const char *s1, size_t l1,
++ const char *s2, size_t l2) {
++ if (l2 == 0) return s1; /* empty strings are everywhere */
++ else if (l2 > l1) return NULL; /* avoids a negative `l1' */
++ else {
++ const char *init; /* to search for a `*s2' inside `s1' */
++ l2--; /* 1st char will be checked by `memchr' */
++ l1 = l1-l2; /* `s2' cannot be found after that */
++ while (l1 > 0 && (init = (const char *)memchr(s1, *s2, l1)) != NULL) {
++ init++; /* 1st char is already checked */
++ if (memcmp(init, s2+1, l2) == 0)
++ return init-1;
++ else { /* correct `l1' and `s1' to try again */
++ l1 -= init-s1;
++ s1 = init;
++ }
++ }
++ return NULL; /* not found */
++ }
++}
++
++
++static void push_onecapture (MatchState *ms, int i, const char *s,
++ const char *e) {
++ if (i >= ms->level) {
++ if (i == 0) /* ms->level == 0, too */
++ lua_pushlstring(ms->L, s, e - s); /* add whole match */
++ else
++ luaL_error(ms->L, "invalid capture index");
++ }
++ else {
++ ptrdiff_t l = ms->capture[i].len;
++ if (l == CAP_UNFINISHED) luaL_error(ms->L, "unfinished capture");
++ if (l == CAP_POSITION)
++ lua_pushinteger(ms->L, ms->capture[i].init - ms->src_init + 1);
++ else
++ lua_pushlstring(ms->L, ms->capture[i].init, l);
++ }
++}
++
++
++static int push_captures (MatchState *ms, const char *s, const char *e) {
++ int i;
++ int nlevels = (ms->level == 0 && s) ? 1 : ms->level;
++ luaL_checkstack(ms->L, nlevels, "too many captures");
++ for (i = 0; i < nlevels; i++)
++ push_onecapture(ms, i, s, e);
++ return nlevels; /* number of strings pushed */
++}
++
++
++static int str_find_aux (lua_State *L, int find) {
++ size_t l1, l2;
++ const char *s = luaL_checklstring(L, 1, &l1);
++ const char *p = luaL_checklstring(L, 2, &l2);
++ ptrdiff_t init = posrelat(luaL_optinteger(L, 3, 1), l1) - 1;
++ if (init < 0) init = 0;
++ else if ((size_t)(init) > l1) init = (ptrdiff_t)l1;
++ if (find && (lua_toboolean(L, 4) || /* explicit request? */
++ strpbrk(p, SPECIALS) == NULL)) { /* or no special characters? */
++ /* do a plain search */
++ const char *s2 = lmemfind(s+init, l1-init, p, l2);
++ if (s2) {
++ lua_pushinteger(L, s2-s+1);
++ lua_pushinteger(L, s2-s+l2);
++ return 2;
++ }
++ }
++ else {
++ MatchState ms;
++ int anchor = (*p == '^') ? (p++, 1) : 0;
++ const char *s1=s+init;
++ ms.L = L;
++ ms.src_init = s;
++ ms.src_end = s+l1;
++ do {
++ const char *res;
++ ms.level = 0;
++ if ((res=match(&ms, s1, p)) != NULL) {
++ if (find) {
++ lua_pushinteger(L, s1-s+1); /* start */
++ lua_pushinteger(L, res-s); /* end */
++ return push_captures(&ms, NULL, 0) + 2;
++ }
++ else
++ return push_captures(&ms, s1, res);
++ }
++ } while (s1++ < ms.src_end && !anchor);
++ }
++ lua_pushnil(L); /* not found */
++ return 1;
++}
++
++
++static int str_find (lua_State *L) {
++ return str_find_aux(L, 1);
++}
++
++
++static int str_match (lua_State *L) {
++ return str_find_aux(L, 0);
++}
++
++
++static int gmatch_aux (lua_State *L) {
++ MatchState ms;
++ size_t ls;
++ const char *s = lua_tolstring(L, lua_upvalueindex(1), &ls);
++ const char *p = lua_tostring(L, lua_upvalueindex(2));
++ const char *src;
++ ms.L = L;
++ ms.src_init = s;
++ ms.src_end = s+ls;
++ for (src = s + (size_t)lua_tointeger(L, lua_upvalueindex(3));
++ src <= ms.src_end;
++ src++) {
++ const char *e;
++ ms.level = 0;
++ if ((e = match(&ms, src, p)) != NULL) {
++ lua_Integer newstart = e-s;
++ if (e == src) newstart++; /* empty match? go at least one position */
++ lua_pushinteger(L, newstart);
++ lua_replace(L, lua_upvalueindex(3));
++ return push_captures(&ms, src, e);
++ }
++ }
++ return 0; /* not found */
++}
++
++
++static int gmatch (lua_State *L) {
++ luaL_checkstring(L, 1);
++ luaL_checkstring(L, 2);
++ lua_settop(L, 2);
++ lua_pushinteger(L, 0);
++ lua_pushcclosure(L, gmatch_aux, 3);
++ return 1;
++}
++
++
++static int gfind_nodef (lua_State *L) {
++ return luaL_error(L, LUA_QL("string.gfind") " was renamed to "
++ LUA_QL("string.gmatch"));
++}
++
++
++static void add_s (MatchState *ms, luaL_Buffer *b, const char *s,
++ const char *e) {
++ size_t l, i;
++ const char *news = lua_tolstring(ms->L, 3, &l);
++ for (i = 0; i < l; i++) {
++ if (news[i] != L_ESC)
++ luaL_addchar(b, news[i]);
++ else {
++ i++; /* skip ESC */
++ if (!isdigit(uchar(news[i])))
++ luaL_addchar(b, news[i]);
++ else if (news[i] == '0')
++ luaL_addlstring(b, s, e - s);
++ else {
++ push_onecapture(ms, news[i] - '1', s, e);
++ luaL_addvalue(b); /* add capture to accumulated result */
++ }
++ }
++ }
++}
++
++
++static void add_value (MatchState *ms, luaL_Buffer *b, const char *s,
++ const char *e) {
++ lua_State *L = ms->L;
++ switch (lua_type(L, 3)) {
++ case LUA_TNUMBER:
++ case LUA_TSTRING: {
++ add_s(ms, b, s, e);
++ return;
++ }
++ case LUA_TFUNCTION: {
++ int n;
++ lua_pushvalue(L, 3);
++ n = push_captures(ms, s, e);
++ lua_call(L, n, 1);
++ break;
++ }
++ case LUA_TTABLE: {
++ push_onecapture(ms, 0, s, e);
++ lua_gettable(L, 3);
++ break;
++ }
++ }
++ if (!lua_toboolean(L, -1)) { /* nil or false? */
++ lua_pop(L, 1);
++ lua_pushlstring(L, s, e - s); /* keep original text */
++ }
++ else if (!lua_isstring(L, -1))
++ luaL_error(L, "invalid replacement value (a %s)", luaL_typename(L, -1));
++ luaL_addvalue(b); /* add result to accumulator */
++}
++
++
++static int str_gsub (lua_State *L) {
++ size_t srcl;
++ const char *src = luaL_checklstring(L, 1, &srcl);
++ const char *p = luaL_checkstring(L, 2);
++ int tr = lua_type(L, 3);
++ int max_s = luaL_optint(L, 4, srcl+1);
++ int anchor = (*p == '^') ? (p++, 1) : 0;
++ int n = 0;
++ MatchState ms;
++ luaL_Buffer *b = (luaL_Buffer *)kmalloc(sizeof(luaL_Buffer) + BUFSIZ, GFP_ATOMIC);
++ if(!b) luaL_error(L, "str_gsub: cannot allocate memory");
++ luaL_argcheck(L, tr == LUA_TNUMBER || tr == LUA_TSTRING ||
++ tr == LUA_TFUNCTION || tr == LUA_TTABLE, 3,
++ "string/function/table expected");
++ luaL_buffinit(L, b);
++ ms.L = L;
++ ms.src_init = src;
++ ms.src_end = src+srcl;
++ while (n < max_s) {
++ const char *e;
++ ms.level = 0;
++ e = match(&ms, src, p);
++ if (e) {
++ n++;
++ add_value(&ms, b, src, e);
++ }
++ if (e && e>src) /* non empty match? */
++ src = e; /* skip it */
++ else if (src < ms.src_end)
++ luaL_addchar(b, *src++);
++ else break;
++ if (anchor) break;
++ }
++ luaL_addlstring(b, src, ms.src_end-src);
++ luaL_pushresult(b);
++ lua_pushinteger(L, n); /* number of substitutions */
++ kfree(b);
++ return 2;
++}
++
++/* }====================================================== */
++
++
++/* maximum size of each formatted item (> len(format('%99.99f', -1e308))) */
++#define MAX_ITEM 512
++/* valid flags in a format specification */
++#define FLAGS "-+ #0"
++/*
++** maximum size of each format specification (such as '%-099.99d')
++** (+10 accounts for %99.99x plus margin of error)
++*/
++#define MAX_FORMAT (sizeof(FLAGS) + sizeof(LUA_INTFRMLEN) + 10)
++
++
++static void addquoted (lua_State *L, luaL_Buffer *b, int arg) {
++ size_t l;
++ const char *s = luaL_checklstring(L, arg, &l);
++ luaL_addchar(b, '"');
++ while (l--) {
++ switch (*s) {
++ case '"': case '\\': case '\n': {
++ luaL_addchar(b, '\\');
++ luaL_addchar(b, *s);
++ break;
++ }
++ case '\r': {
++ luaL_addlstring(b, "\\r", 2);
++ break;
++ }
++ case '\0': {
++ luaL_addlstring(b, "\\000", 4);
++ break;
++ }
++ default: {
++ luaL_addchar(b, *s);
++ break;
++ }
++ }
++ s++;
++ }
++ luaL_addchar(b, '"');
++}
++
++static const char *scanformat (lua_State *L, const char *strfrmt, char *form) {
++ const char *p = strfrmt;
++ while (*p != '\0' && strchr(FLAGS, *p) != NULL) p++; /* skip flags */
++ if ((size_t)(p - strfrmt) >= sizeof(FLAGS))
++ luaL_error(L, "invalid format (repeated flags)");
++ if (isdigit(uchar(*p))) p++; /* skip width */
++ if (isdigit(uchar(*p))) p++; /* (2 digits at most) */
++ if (*p == '.') {
++ p++;
++ if (isdigit(uchar(*p))) p++; /* skip precision */
++ if (isdigit(uchar(*p))) p++; /* (2 digits at most) */
++ }
++ if (isdigit(uchar(*p)))
++ luaL_error(L, "invalid format (width or precision too long)");
++ *(form++) = '%';
++ strncpy(form, strfrmt, p - strfrmt + 1);
++ form += p - strfrmt + 1;
++ *form = '\0';
++ return p;
++}
++
++
++static void addintlen (char *form) {
++ size_t l = strlen(form);
++ char spec = form[l - 1];
++ strcpy(form + l - 1, LUA_INTFRMLEN);
++ form[l + sizeof(LUA_INTFRMLEN) - 2] = spec;
++ form[l + sizeof(LUA_INTFRMLEN) - 1] = '\0';
++}
++
++
++static int str_format (lua_State *L) {
++ int arg = 1;
++ size_t sfl;
++ const char *strfrmt = luaL_checklstring(L, arg, &sfl);
++ const char *strfrmt_end = strfrmt+sfl;
++ luaL_Buffer *b = (luaL_Buffer *)kmalloc(sizeof(luaL_Buffer) + BUFSIZ, GFP_ATOMIC);
++ if(!b) luaL_error(L, "str_format: cannot allocate memory");
++ luaL_buffinit(L, b);
++ while (strfrmt < strfrmt_end) {
++ if (*strfrmt != L_ESC)
++ luaL_addchar(b, *strfrmt++);
++ else if (*++strfrmt == L_ESC)
++ luaL_addchar(b, *strfrmt++); /* %% */
++ else { /* format item */
++ char form[MAX_FORMAT]; /* to store the format (`%...') */
++ char buff[MAX_ITEM]; /* to store the formatted item */
++ arg++;
++ strfrmt = scanformat(L, strfrmt, form);
++ switch (*strfrmt++) {
++ case 'c': {
++ sprintf(buff, form, (int)luaL_checknumber(L, arg));
++ break;
++ }
++ case 'd': case 'i': {
++ addintlen(form);
++ sprintf(buff, form, (LUA_INTFRM_T)luaL_checknumber(L, arg));
++ break;
++ }
++ case 'o': case 'u': case 'x': case 'X': {
++ addintlen(form);
++ sprintf(buff, form, (unsigned LUA_INTFRM_T)luaL_checknumber(L, arg));
++ break;
++ }
++ case 'q': {
++ addquoted(L, b, arg);
++ continue; /* skip the 'addsize' at the end */
++ }
++ case 's': {
++ size_t l;
++ const char *s = luaL_checklstring(L, arg, &l);
++ if (!strchr(form, '.') && l >= 100) {
++ /* no precision and string is too long to be formatted;
++ keep original string */
++ lua_pushvalue(L, arg);
++ luaL_addvalue(b);
++ continue; /* skip the `addsize' at the end */
++ }
++ else {
++ sprintf(buff, form, s);
++ break;
++ }
++ }
++ default: { /* also treat cases `pnLlh' */
++ kfree(b);
++ return luaL_error(L, "invalid option " LUA_QL("%%%c") " to "
++ LUA_QL("format"), *(strfrmt - 1));
++ }
++ }
++ luaL_addlstring(b, buff, strlen(buff));
++ }
++ }
++ luaL_pushresult(b);
++ kfree(b);
++ return 1;
++}
++
++
++static const luaL_Reg strlib[] = {
++ {"byte", str_byte},
++ {"char", str_char},
++ {"dump", str_dump},
++ {"find", str_find},
++ {"format", str_format},
++ {"gfind", gfind_nodef},
++ {"gmatch", gmatch},
++ {"gsub", str_gsub},
++ {"len", str_len},
++ {"lower", str_lower},
++ {"match", str_match},
++ {"rep", str_rep},
++ {"reverse", str_reverse},
++ {"sub", str_sub},
++ {"upper", str_upper},
++ {NULL, NULL}
++};
++
++
++static void createmetatable (lua_State *L) {
++ lua_createtable(L, 0, 1); /* create metatable for strings */
++ lua_pushliteral(L, ""); /* dummy string */
++ lua_pushvalue(L, -2);
++ lua_setmetatable(L, -2); /* set string metatable */
++ lua_pop(L, 1); /* pop dummy string */
++ lua_pushvalue(L, -2); /* string library... */
++ lua_setfield(L, -2, "__index"); /* ...is the __index metamethod */
++ lua_pop(L, 1); /* pop metatable */
++}
++
++
++/*
++** Open string library
++*/
++LUALIB_API int luaopen_string (lua_State *L) {
++ luaL_register(L, LUA_STRLIBNAME, strlib);
++#if defined(LUA_COMPAT_GFIND)
++ lua_getfield(L, -1, "gmatch");
++ lua_setfield(L, -2, "gfind");
++#endif
++ createmetatable(L);
++ return 1;
++}
+--- /dev/null
++++ b/extensions/LUA/lua/ltable.c
+@@ -0,0 +1,588 @@
++/*
++** $Id: ltable.c,v 2.32.1.2 2007/12/28 15:32:23 roberto Exp $
++** Lua tables (hash)
++** See Copyright Notice in lua.h
++*/
++
++
++/*
++** Implementation of tables (aka arrays, objects, or hash tables).
++** Tables keep its elements in two parts: an array part and a hash part.
++** Non-negative integer keys are all candidates to be kept in the array
++** part. The actual size of the array is the largest `n' such that at
++** least half the slots between 0 and n are in use.
++** Hash uses a mix of chained scatter table with Brent's variation.
++** A main invariant of these tables is that, if an element is not
++** in its main position (i.e. the `original' position that its hash gives
++** to it), then the colliding element is in its own main position.
++** Hence even when the load factor reaches 100%, performance remains good.
++*/
++
++#include <math.h>
++#include <string.h>
++
++#define ltable_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "ldebug.h"
++#include "ldo.h"
++#include "lgc.h"
++#include "lmem.h"
++#include "lobject.h"
++#include "lstate.h"
++#include "ltable.h"
++
++
++/*
++** max size of array part is 2^MAXBITS
++*/
++#if LUAI_BITSINT > 26
++#define MAXBITS 26
++#else
++#define MAXBITS (LUAI_BITSINT-2)
++#endif
++
++#define MAXASIZE (1 << MAXBITS)
++
++
++#define hashpow2(t,n) (gnode(t, lmod((n), sizenode(t))))
++
++#define hashstr(t,str) hashpow2(t, (str)->tsv.hash)
++#define hashboolean(t,p) hashpow2(t, p)
++
++
++/*
++** for some types, it is better to avoid modulus by power of 2, as
++** they tend to have many 2 factors.
++*/
++#define hashmod(t,n) (gnode(t, ((n) % ((sizenode(t)-1)|1))))
++
++
++#define hashpointer(t,p) hashmod(t, IntPoint(p))
++
++
++/*
++** number of ints inside a lua_Number
++*/
++#define numints cast_int(sizeof(lua_Number)/sizeof(int))
++
++
++
++#define dummynode (&dummynode_)
++
++static const Node dummynode_ = {
++ {{NULL}, LUA_TNIL}, /* value */
++ {{{NULL}, LUA_TNIL, NULL}} /* key */
++};
++
++
++/*
++** hash for lua_Numbers
++*/
++static Node *hashnum (const Table *t, lua_Number n) {
++ unsigned int a[numints];
++ int i;
++ if (luai_numeq(n, 0)) /* avoid problems with -0 */
++ return gnode(t, 0);
++ memcpy(a, &n, sizeof(a));
++ for (i = 1; i < numints; i++) a[0] += a[i];
++ return hashmod(t, a[0]);
++}
++
++
++
++/*
++** returns the `main' position of an element in a table (that is, the index
++** of its hash value)
++*/
++static Node *mainposition (const Table *t, const TValue *key) {
++ switch (ttype(key)) {
++ case LUA_TNUMBER:
++ return hashnum(t, nvalue(key));
++ case LUA_TSTRING:
++ return hashstr(t, rawtsvalue(key));
++ case LUA_TBOOLEAN:
++ return hashboolean(t, bvalue(key));
++ case LUA_TLIGHTUSERDATA:
++ return hashpointer(t, pvalue(key));
++ default:
++ return hashpointer(t, gcvalue(key));
++ }
++}
++
++
++/*
++** returns the index for `key' if `key' is an appropriate key to live in
++** the array part of the table, -1 otherwise.
++*/
++static int arrayindex (const TValue *key) {
++ if (ttisnumber(key)) {
++ lua_Number n = nvalue(key);
++ int k;
++ lua_number2int(k, n);
++ if (luai_numeq(cast_num(k), n))
++ return k;
++ }
++ return -1; /* `key' did not match some condition */
++}
++
++
++/*
++** returns the index of a `key' for table traversals. First goes all
++** elements in the array part, then elements in the hash part. The
++** beginning of a traversal is signalled by -1.
++*/
++static int findindex (lua_State *L, Table *t, StkId key) {
++ int i;
++ if (ttisnil(key)) return -1; /* first iteration */
++ i = arrayindex(key);
++ if (0 < i && i <= t->sizearray) /* is `key' inside array part? */
++ return i-1; /* yes; that's the index (corrected to C) */
++ else {
++ Node *n = mainposition(t, key);
++ do { /* check whether `key' is somewhere in the chain */
++ /* key may be dead already, but it is ok to use it in `next' */
++ if (luaO_rawequalObj(key2tval(n), key) ||
++ (ttype(gkey(n)) == LUA_TDEADKEY && iscollectable(key) &&
++ gcvalue(gkey(n)) == gcvalue(key))) {
++ i = cast_int(n - gnode(t, 0)); /* key index in hash table */
++ /* hash elements are numbered after array ones */
++ return i + t->sizearray;
++ }
++ else n = gnext(n);
++ } while (n);
++ luaG_runerror(L, "invalid key to " LUA_QL("next")); /* key not found */
++ return 0; /* to avoid warnings */
++ }
++}
++
++
++int luaH_next (lua_State *L, Table *t, StkId key) {
++ int i = findindex(L, t, key); /* find original element */
++ for (i++; i < t->sizearray; i++) { /* try first array part */
++ if (!ttisnil(&t->array[i])) { /* a non-nil value? */
++ setnvalue(key, cast_num(i+1));
++ setobj2s(L, key+1, &t->array[i]);
++ return 1;
++ }
++ }
++ for (i -= t->sizearray; i < sizenode(t); i++) { /* then hash part */
++ if (!ttisnil(gval(gnode(t, i)))) { /* a non-nil value? */
++ setobj2s(L, key, key2tval(gnode(t, i)));
++ setobj2s(L, key+1, gval(gnode(t, i)));
++ return 1;
++ }
++ }
++ return 0; /* no more elements */
++}
++
++
++/*
++** {=============================================================
++** Rehash
++** ==============================================================
++*/
++
++
++static int computesizes (int nums[], int *narray) {
++ int i;
++ int twotoi; /* 2^i */
++ int a = 0; /* number of elements smaller than 2^i */
++ int na = 0; /* number of elements to go to array part */
++ int n = 0; /* optimal size for array part */
++ for (i = 0, twotoi = 1; twotoi/2 < *narray; i++, twotoi *= 2) {
++ if (nums[i] > 0) {
++ a += nums[i];
++ if (a > twotoi/2) { /* more than half elements present? */
++ n = twotoi; /* optimal size (till now) */
++ na = a; /* all elements smaller than n will go to array part */
++ }
++ }
++ if (a == *narray) break; /* all elements already counted */
++ }
++ *narray = n;
++ lua_assert(*narray/2 <= na && na <= *narray);
++ return na;
++}
++
++
++static int countint (const TValue *key, int *nums) {
++ int k = arrayindex(key);
++ if (0 < k && k <= MAXASIZE) { /* is `key' an appropriate array index? */
++ nums[ceillog2(k)]++; /* count as such */
++ return 1;
++ }
++ else
++ return 0;
++}
++
++
++static int numusearray (const Table *t, int *nums) {
++ int lg;
++ int ttlg; /* 2^lg */
++ int ause = 0; /* summation of `nums' */
++ int i = 1; /* count to traverse all array keys */
++ for (lg=0, ttlg=1; lg<=MAXBITS; lg++, ttlg*=2) { /* for each slice */
++ int lc = 0; /* counter */
++ int lim = ttlg;
++ if (lim > t->sizearray) {
++ lim = t->sizearray; /* adjust upper limit */
++ if (i > lim)
++ break; /* no more elements to count */
++ }
++ /* count elements in range (2^(lg-1), 2^lg] */
++ for (; i <= lim; i++) {
++ if (!ttisnil(&t->array[i-1]))
++ lc++;
++ }
++ nums[lg] += lc;
++ ause += lc;
++ }
++ return ause;
++}
++
++
++static int numusehash (const Table *t, int *nums, int *pnasize) {
++ int totaluse = 0; /* total number of elements */
++ int ause = 0; /* summation of `nums' */
++ int i = sizenode(t);
++ while (i--) {
++ Node *n = &t->node[i];
++ if (!ttisnil(gval(n))) {
++ ause += countint(key2tval(n), nums);
++ totaluse++;
++ }
++ }
++ *pnasize += ause;
++ return totaluse;
++}
++
++
++static void setarrayvector (lua_State *L, Table *t, int size) {
++ int i;
++ luaM_reallocvector(L, t->array, t->sizearray, size, TValue);
++ for (i=t->sizearray; i<size; i++)
++ setnilvalue(&t->array[i]);
++ t->sizearray = size;
++}
++
++
++static void setnodevector (lua_State *L, Table *t, int size) {
++ int lsize;
++ if (size == 0) { /* no elements to hash part? */
++ t->node = cast(Node *, dummynode); /* use common `dummynode' */
++ lsize = 0;
++ }
++ else {
++ int i;
++ lsize = ceillog2(size);
++ if (lsize > MAXBITS)
++ luaG_runerror(L, "table overflow");
++ size = twoto(lsize);
++ t->node = luaM_newvector(L, size, Node);
++ for (i=0; i<size; i++) {
++ Node *n = gnode(t, i);
++ gnext(n) = NULL;
++ setnilvalue(gkey(n));
++ setnilvalue(gval(n));
++ }
++ }
++ t->lsizenode = cast_byte(lsize);
++ t->lastfree = gnode(t, size); /* all positions are free */
++}
++
++
++static void resize (lua_State *L, Table *t, int nasize, int nhsize) {
++ int i;
++ int oldasize = t->sizearray;
++ int oldhsize = t->lsizenode;
++ Node *nold = t->node; /* save old hash ... */
++ if (nasize > oldasize) /* array part must grow? */
++ setarrayvector(L, t, nasize);
++ /* create new hash part with appropriate size */
++ setnodevector(L, t, nhsize);
++ if (nasize < oldasize) { /* array part must shrink? */
++ t->sizearray = nasize;
++ /* re-insert elements from vanishing slice */
++ for (i=nasize; i<oldasize; i++) {
++ if (!ttisnil(&t->array[i]))
++ setobjt2t(L, luaH_setnum(L, t, i+1), &t->array[i]);
++ }
++ /* shrink array */
++ luaM_reallocvector(L, t->array, oldasize, nasize, TValue);
++ }
++ /* re-insert elements from hash part */
++ for (i = twoto(oldhsize) - 1; i >= 0; i--) {
++ Node *old = nold+i;
++ if (!ttisnil(gval(old)))
++ setobjt2t(L, luaH_set(L, t, key2tval(old)), gval(old));
++ }
++ if (nold != dummynode)
++ luaM_freearray(L, nold, twoto(oldhsize), Node); /* free old array */
++}
++
++
++void luaH_resizearray (lua_State *L, Table *t, int nasize) {
++ int nsize = (t->node == dummynode) ? 0 : sizenode(t);
++ resize(L, t, nasize, nsize);
++}
++
++
++static void rehash (lua_State *L, Table *t, const TValue *ek) {
++ int nasize, na;
++ int nums[MAXBITS+1]; /* nums[i] = number of keys between 2^(i-1) and 2^i */
++ int i;
++ int totaluse;
++ for (i=0; i<=MAXBITS; i++) nums[i] = 0; /* reset counts */
++ nasize = numusearray(t, nums); /* count keys in array part */
++ totaluse = nasize; /* all those keys are integer keys */
++ totaluse += numusehash(t, nums, &nasize); /* count keys in hash part */
++ /* count extra key */
++ nasize += countint(ek, nums);
++ totaluse++;
++ /* compute new size for array part */
++ na = computesizes(nums, &nasize);
++ /* resize the table to new computed sizes */
++ resize(L, t, nasize, totaluse - na);
++}
++
++
++
++/*
++** }=============================================================
++*/
++
++
++Table *luaH_new (lua_State *L, int narray, int nhash) {
++ Table *t = luaM_new(L, Table);
++ luaC_link(L, obj2gco(t), LUA_TTABLE);
++ t->metatable = NULL;
++ t->flags = cast_byte(~0);
++ /* temporary values (kept only if some malloc fails) */
++ t->array = NULL;
++ t->sizearray = 0;
++ t->lsizenode = 0;
++ t->node = cast(Node *, dummynode);
++ setarrayvector(L, t, narray);
++ setnodevector(L, t, nhash);
++ return t;
++}
++
++
++void luaH_free (lua_State *L, Table *t) {
++ if (t->node != dummynode)
++ luaM_freearray(L, t->node, sizenode(t), Node);
++ luaM_freearray(L, t->array, t->sizearray, TValue);
++ luaM_free(L, t);
++}
++
++
++static Node *getfreepos (Table *t) {
++ while (t->lastfree-- > t->node) {
++ if (ttisnil(gkey(t->lastfree)))
++ return t->lastfree;
++ }
++ return NULL; /* could not find a free place */
++}
++
++
++
++/*
++** inserts a new key into a hash table; first, check whether key's main
++** position is free. If not, check whether colliding node is in its main
++** position or not: if it is not, move colliding node to an empty place and
++** put new key in its main position; otherwise (colliding node is in its main
++** position), new key goes to an empty position.
++*/
++static TValue *newkey (lua_State *L, Table *t, const TValue *key) {
++ Node *mp = mainposition(t, key);
++ if (!ttisnil(gval(mp)) || mp == dummynode) {
++ Node *othern;
++ Node *n = getfreepos(t); /* get a free place */
++ if (n == NULL) { /* cannot find a free place? */
++ rehash(L, t, key); /* grow table */
++ return luaH_set(L, t, key); /* re-insert key into grown table */
++ }
++ lua_assert(n != dummynode);
++ othern = mainposition(t, key2tval(mp));
++ if (othern != mp) { /* is colliding node out of its main position? */
++ /* yes; move colliding node into free position */
++ while (gnext(othern) != mp) othern = gnext(othern); /* find previous */
++ gnext(othern) = n; /* redo the chain with `n' in place of `mp' */
++ *n = *mp; /* copy colliding node into free pos. (mp->next also goes) */
++ gnext(mp) = NULL; /* now `mp' is free */
++ setnilvalue(gval(mp));
++ }
++ else { /* colliding node is in its own main position */
++ /* new node will go into free position */
++ gnext(n) = gnext(mp); /* chain new position */
++ gnext(mp) = n;
++ mp = n;
++ }
++ }
++ gkey(mp)->value = key->value; gkey(mp)->tt = key->tt;
++ luaC_barriert(L, t, key);
++ lua_assert(ttisnil(gval(mp)));
++ return gval(mp);
++}
++
++
++/*
++** search function for integers
++*/
++const TValue *luaH_getnum (Table *t, int key) {
++ /* (1 <= key && key <= t->sizearray) */
++ if (cast(unsigned int, key-1) < cast(unsigned int, t->sizearray))
++ return &t->array[key-1];
++ else {
++ lua_Number nk = cast_num(key);
++ Node *n = hashnum(t, nk);
++ do { /* check whether `key' is somewhere in the chain */
++ if (ttisnumber(gkey(n)) && luai_numeq(nvalue(gkey(n)), nk))
++ return gval(n); /* that's it */
++ else n = gnext(n);
++ } while (n);
++ return luaO_nilobject;
++ }
++}
++
++
++/*
++** search function for strings
++*/
++const TValue *luaH_getstr (Table *t, TString *key) {
++ Node *n = hashstr(t, key);
++ do { /* check whether `key' is somewhere in the chain */
++ if (ttisstring(gkey(n)) && rawtsvalue(gkey(n)) == key)
++ return gval(n); /* that's it */
++ else n = gnext(n);
++ } while (n);
++ return luaO_nilobject;
++}
++
++
++/*
++** main search function
++*/
++const TValue *luaH_get (Table *t, const TValue *key) {
++ switch (ttype(key)) {
++ case LUA_TNIL: return luaO_nilobject;
++ case LUA_TSTRING: return luaH_getstr(t, rawtsvalue(key));
++ case LUA_TNUMBER: {
++ int k;
++ lua_Number n = nvalue(key);
++ lua_number2int(k, n);
++ if (luai_numeq(cast_num(k), nvalue(key))) /* index is int? */
++ return luaH_getnum(t, k); /* use specialized version */
++ /* else go through */
++ }
++ default: {
++ Node *n = mainposition(t, key);
++ do { /* check whether `key' is somewhere in the chain */
++ if (luaO_rawequalObj(key2tval(n), key))
++ return gval(n); /* that's it */
++ else n = gnext(n);
++ } while (n);
++ return luaO_nilobject;
++ }
++ }
++}
++
++
++TValue *luaH_set (lua_State *L, Table *t, const TValue *key) {
++ const TValue *p = luaH_get(t, key);
++ t->flags = 0;
++ if (p != luaO_nilobject)
++ return cast(TValue *, p);
++ else {
++ if (ttisnil(key)) luaG_runerror(L, "table index is nil");
++ else if (ttisnumber(key) && luai_numisnan(nvalue(key)))
++ luaG_runerror(L, "table index is NaN");
++ return newkey(L, t, key);
++ }
++}
++
++
++TValue *luaH_setnum (lua_State *L, Table *t, int key) {
++ const TValue *p = luaH_getnum(t, key);
++ if (p != luaO_nilobject)
++ return cast(TValue *, p);
++ else {
++ TValue k;
++ setnvalue(&k, cast_num(key));
++ return newkey(L, t, &k);
++ }
++}
++
++
++TValue *luaH_setstr (lua_State *L, Table *t, TString *key) {
++ const TValue *p = luaH_getstr(t, key);
++ if (p != luaO_nilobject)
++ return cast(TValue *, p);
++ else {
++ TValue k;
++ setsvalue(L, &k, key);
++ return newkey(L, t, &k);
++ }
++}
++
++
++static int unbound_search (Table *t, unsigned int j) {
++ unsigned int i = j; /* i is zero or a present index */
++ j++;
++ /* find `i' and `j' such that i is present and j is not */
++ while (!ttisnil(luaH_getnum(t, j))) {
++ i = j;
++ j *= 2;
++ if (j > cast(unsigned int, MAX_INT)) { /* overflow? */
++ /* table was built with bad purposes: resort to linear search */
++ i = 1;
++ while (!ttisnil(luaH_getnum(t, i))) i++;
++ return i - 1;
++ }
++ }
++ /* now do a binary search between them */
++ while (j - i > 1) {
++ unsigned int m = (i+j)/2;
++ if (ttisnil(luaH_getnum(t, m))) j = m;
++ else i = m;
++ }
++ return i;
++}
++
++
++/*
++** Try to find a boundary in table `t'. A `boundary' is an integer index
++** such that t[i] is non-nil and t[i+1] is nil (and 0 if t[1] is nil).
++*/
++int luaH_getn (Table *t) {
++ unsigned int j = t->sizearray;
++ if (j > 0 && ttisnil(&t->array[j - 1])) {
++ /* there is a boundary in the array part: (binary) search for it */
++ unsigned int i = 0;
++ while (j - i > 1) {
++ unsigned int m = (i+j)/2;
++ if (ttisnil(&t->array[m - 1])) j = m;
++ else i = m;
++ }
++ return i;
++ }
++ /* else must find a boundary in hash part */
++ else if (t->node == dummynode) /* hash part is empty? */
++ return j; /* that is easy... */
++ else return unbound_search(t, j);
++}
++
++
++
++#if defined(LUA_DEBUG)
++
++Node *luaH_mainposition (const Table *t, const TValue *key) {
++ return mainposition(t, key);
++}
++
++int luaH_isdummy (Node *n) { return n == dummynode; }
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/ltable.h
+@@ -0,0 +1,40 @@
++/*
++** $Id: ltable.h,v 2.10.1.1 2007/12/27 13:02:25 roberto Exp $
++** Lua tables (hash)
++** See Copyright Notice in lua.h
++*/
++
++#ifndef ltable_h
++#define ltable_h
++
++#include "lobject.h"
++
++
++#define gnode(t,i) (&(t)->node[i])
++#define gkey(n) (&(n)->i_key.nk)
++#define gval(n) (&(n)->i_val)
++#define gnext(n) ((n)->i_key.nk.next)
++
++#define key2tval(n) (&(n)->i_key.tvk)
++
++
++LUAI_FUNC const TValue *luaH_getnum (Table *t, int key);
++LUAI_FUNC TValue *luaH_setnum (lua_State *L, Table *t, int key);
++LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key);
++LUAI_FUNC TValue *luaH_setstr (lua_State *L, Table *t, TString *key);
++LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key);
++LUAI_FUNC TValue *luaH_set (lua_State *L, Table *t, const TValue *key);
++LUAI_FUNC Table *luaH_new (lua_State *L, int narray, int lnhash);
++LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, int nasize);
++LUAI_FUNC void luaH_free (lua_State *L, Table *t);
++LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key);
++LUAI_FUNC int luaH_getn (Table *t);
++
++
++#if defined(LUA_DEBUG)
++LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key);
++LUAI_FUNC int luaH_isdummy (Node *n);
++#endif
++
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/ltablib.c
+@@ -0,0 +1,288 @@
++/*
++** $Id: ltablib.c,v 1.38.1.3 2008/02/14 16:46:58 roberto Exp $
++** Library for Table Manipulation
++** See Copyright Notice in lua.h
++*/
++
++
++#include <stddef.h>
++
++#define ltablib_c
++#define LUA_LIB
++
++#include "lua.h"
++
++#include "lauxlib.h"
++#include "lualib.h"
++
++
++#define aux_getn(L,n) (luaL_checktype(L, n, LUA_TTABLE), luaL_getn(L, n))
++
++
++static int foreachi (lua_State *L) {
++ int i;
++ int n = aux_getn(L, 1);
++ luaL_checktype(L, 2, LUA_TFUNCTION);
++ for (i=1; i <= n; i++) {
++ lua_pushvalue(L, 2); /* function */
++ lua_pushinteger(L, i); /* 1st argument */
++ lua_rawgeti(L, 1, i); /* 2nd argument */
++ lua_call(L, 2, 1);
++ if (!lua_isnil(L, -1))
++ return 1;
++ lua_pop(L, 1); /* remove nil result */
++ }
++ return 0;
++}
++
++
++static int foreach (lua_State *L) {
++ luaL_checktype(L, 1, LUA_TTABLE);
++ luaL_checktype(L, 2, LUA_TFUNCTION);
++ lua_pushnil(L); /* first key */
++ while (lua_next(L, 1)) {
++ lua_pushvalue(L, 2); /* function */
++ lua_pushvalue(L, -3); /* key */
++ lua_pushvalue(L, -3); /* value */
++ lua_call(L, 2, 1);
++ if (!lua_isnil(L, -1))
++ return 1;
++ lua_pop(L, 2); /* remove value and result */
++ }
++ return 0;
++}
++
++
++static int maxn (lua_State *L) {
++ lua_Number max = 0;
++ luaL_checktype(L, 1, LUA_TTABLE);
++ lua_pushnil(L); /* first key */
++ while (lua_next(L, 1)) {
++ lua_pop(L, 1); /* remove value */
++ if (lua_type(L, -1) == LUA_TNUMBER) {
++ lua_Number v = lua_tonumber(L, -1);
++ if (v > max) max = v;
++ }
++ }
++ lua_pushnumber(L, max);
++ return 1;
++}
++
++
++static int getn (lua_State *L) {
++ lua_pushinteger(L, aux_getn(L, 1));
++ return 1;
++}
++
++
++static int setn (lua_State *L) {
++ luaL_checktype(L, 1, LUA_TTABLE);
++#ifndef luaL_setn
++ luaL_setn(L, 1, luaL_checkint(L, 2));
++#else
++ luaL_error(L, LUA_QL("setn") " is obsolete");
++#endif
++ lua_pushvalue(L, 1);
++ return 1;
++}
++
++
++static int tinsert (lua_State *L) {
++ int e = aux_getn(L, 1) + 1; /* first empty element */
++ int pos; /* where to insert new element */
++ switch (lua_gettop(L)) {
++ case 2: { /* called with only 2 arguments */
++ pos = e; /* insert new element at the end */
++ break;
++ }
++ case 3: {
++ int i;
++ pos = luaL_checkint(L, 2); /* 2nd argument is the position */
++ if (pos > e) e = pos; /* `grow' array if necessary */
++ for (i = e; i > pos; i--) { /* move up elements */
++ lua_rawgeti(L, 1, i-1);
++ lua_rawseti(L, 1, i); /* t[i] = t[i-1] */
++ }
++ break;
++ }
++ default: {
++ return luaL_error(L, "wrong number of arguments to " LUA_QL("insert"));
++ }
++ }
++ luaL_setn(L, 1, e); /* new size */
++ lua_rawseti(L, 1, pos); /* t[pos] = v */
++ return 0;
++}
++
++
++static int tremove (lua_State *L) {
++ int e = aux_getn(L, 1);
++ int pos = luaL_optint(L, 2, e);
++ if (!(1 <= pos && pos <= e)) /* position is outside bounds? */
++ return 0; /* nothing to remove */
++ luaL_setn(L, 1, e - 1); /* t.n = n-1 */
++ lua_rawgeti(L, 1, pos); /* result = t[pos] */
++ for ( ;pos<e; pos++) {
++ lua_rawgeti(L, 1, pos+1);
++ lua_rawseti(L, 1, pos); /* t[pos] = t[pos+1] */
++ }
++ lua_pushnil(L);
++ lua_rawseti(L, 1, e); /* t[e] = nil */
++ return 1;
++}
++
++
++static void addfield (lua_State *L, luaL_Buffer *b, int i) {
++ lua_rawgeti(L, 1, i);
++ if (!lua_isstring(L, -1))
++ luaL_error(L, "invalid value (%s) at index %d in table for "
++ LUA_QL("concat"), luaL_typename(L, -1), i);
++ luaL_addvalue(b);
++}
++
++
++static int tconcat (lua_State *L) {
++ size_t lsep;
++ int i, last;
++ const char *sep = luaL_optlstring(L, 2, "", &lsep);
++ luaL_Buffer *b = (luaL_Buffer *)kmalloc(sizeof(luaL_Buffer) + BUFSIZ, GFP_ATOMIC);
++ if(!b) luaL_error(L, "tconcat: cannot allocate memory");
++ luaL_checktype(L, 1, LUA_TTABLE);
++ i = luaL_optint(L, 3, 1);
++ last = luaL_opt(L, luaL_checkint, 4, luaL_getn(L, 1));
++ luaL_buffinit(L, b);
++ for (; i < last; i++) {
++ addfield(L, b, i);
++ luaL_addlstring(b, sep, lsep);
++ }
++ if (i == last) /* add last value (if interval was not empty) */
++ addfield(L, b, i);
++ luaL_pushresult(b);
++ kfree(b);
++ return 1;
++}
++
++
++
++/*
++** {======================================================
++** Quicksort
++** (based on `Algorithms in MODULA-3', Robert Sedgewick;
++** Addison-Wesley, 1993.)
++*/
++
++
++static void set2 (lua_State *L, int i, int j) {
++ lua_rawseti(L, 1, i);
++ lua_rawseti(L, 1, j);
++}
++
++static int sort_comp (lua_State *L, int a, int b) {
++ if (!lua_isnil(L, 2)) { /* function? */
++ int res;
++ lua_pushvalue(L, 2);
++ lua_pushvalue(L, a-1); /* -1 to compensate function */
++ lua_pushvalue(L, b-2); /* -2 to compensate function and `a' */
++ lua_call(L, 2, 1);
++ res = lua_toboolean(L, -1);
++ lua_pop(L, 1);
++ return res;
++ }
++ else /* a < b? */
++ return lua_lessthan(L, a, b);
++}
++
++static void auxsort (lua_State *L, int l, int u) {
++ while (l < u) { /* for tail recursion */
++ int i, j;
++ /* sort elements a[l], a[(l+u)/2] and a[u] */
++ lua_rawgeti(L, 1, l);
++ lua_rawgeti(L, 1, u);
++ if (sort_comp(L, -1, -2)) /* a[u] < a[l]? */
++ set2(L, l, u); /* swap a[l] - a[u] */
++ else
++ lua_pop(L, 2);
++ if (u-l == 1) break; /* only 2 elements */
++ i = (l+u)/2;
++ lua_rawgeti(L, 1, i);
++ lua_rawgeti(L, 1, l);
++ if (sort_comp(L, -2, -1)) /* a[i]<a[l]? */
++ set2(L, i, l);
++ else {
++ lua_pop(L, 1); /* remove a[l] */
++ lua_rawgeti(L, 1, u);
++ if (sort_comp(L, -1, -2)) /* a[u]<a[i]? */
++ set2(L, i, u);
++ else
++ lua_pop(L, 2);
++ }
++ if (u-l == 2) break; /* only 3 elements */
++ lua_rawgeti(L, 1, i); /* Pivot */
++ lua_pushvalue(L, -1);
++ lua_rawgeti(L, 1, u-1);
++ set2(L, i, u-1);
++ /* a[l] <= P == a[u-1] <= a[u], only need to sort from l+1 to u-2 */
++ i = l; j = u-1;
++ for (;;) { /* invariant: a[l..i] <= P <= a[j..u] */
++ /* repeat ++i until a[i] >= P */
++ while (lua_rawgeti(L, 1, ++i), sort_comp(L, -1, -2)) {
++ if (i>u) luaL_error(L, "invalid order function for sorting");
++ lua_pop(L, 1); /* remove a[i] */
++ }
++ /* repeat --j until a[j] <= P */
++ while (lua_rawgeti(L, 1, --j), sort_comp(L, -3, -1)) {
++ if (j<l) luaL_error(L, "invalid order function for sorting");
++ lua_pop(L, 1); /* remove a[j] */
++ }
++ if (j<i) {
++ lua_pop(L, 3); /* pop pivot, a[i], a[j] */
++ break;
++ }
++ set2(L, i, j);
++ }
++ lua_rawgeti(L, 1, u-1);
++ lua_rawgeti(L, 1, i);
++ set2(L, u-1, i); /* swap pivot (a[u-1]) with a[i] */
++ /* a[l..i-1] <= a[i] == P <= a[i+1..u] */
++ /* adjust so that smaller half is in [j..i] and larger one in [l..u] */
++ if (i-l < u-i) {
++ j=l; i=i-1; l=i+2;
++ }
++ else {
++ j=i+1; i=u; u=j-2;
++ }
++ auxsort(L, j, i); /* call recursively the smaller one */
++ } /* repeat the routine for the larger one */
++}
++
++static int sort (lua_State *L) {
++ int n = aux_getn(L, 1);
++ luaL_checkstack(L, 40, ""); /* assume array is smaller than 2^40 */
++ if (!lua_isnoneornil(L, 2)) /* is there a 2nd argument? */
++ luaL_checktype(L, 2, LUA_TFUNCTION);
++ lua_settop(L, 2); /* make sure there is two arguments */
++ auxsort(L, 1, n);
++ return 0;
++}
++
++/* }====================================================== */
++
++
++static const luaL_Reg tab_funcs[] = {
++ {"concat", tconcat},
++ {"foreach", foreach},
++ {"foreachi", foreachi},
++ {"getn", getn},
++ {"maxn", maxn},
++ {"insert", tinsert},
++ {"remove", tremove},
++ {"setn", setn},
++ {"sort", sort},
++ {NULL, NULL}
++};
++
++
++LUALIB_API int luaopen_table (lua_State *L) {
++ luaL_register(L, LUA_TABLIBNAME, tab_funcs);
++ return 1;
++}
+--- /dev/null
++++ b/extensions/LUA/lua/ltm.c
+@@ -0,0 +1,74 @@
++/*
++** $Id: ltm.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $
++** Tag methods
++** See Copyright Notice in lua.h
++*/
++
++#include <string.h>
++
++#define ltm_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "lobject.h"
++#include "lstate.h"
++#include "lstring.h"
++#include "ltable.h"
++#include "ltm.h"
++
++
++
++const char *const luaT_typenames[] = {
++ "nil", "boolean", "userdata", "number",
++ "string", "table", "function", "userdata", "thread",
++ "proto", "upval"
++};
++
++
++void luaT_init (lua_State *L) {
++ static const char *const luaT_eventname[] = { /* ORDER TM */
++ "__index", "__newindex",
++ "__gc", "__mode", "__eq",
++ "__add", "__sub", "__mul", "__div", "__mod",
++ "__pow", "__unm", "__len", "__lt", "__le",
++ "__concat", "__call"
++ };
++ int i;
++ for (i=0; i<TM_N; i++) {
++ G(L)->tmname[i] = luaS_new(L, luaT_eventname[i]);
++ luaS_fix(G(L)->tmname[i]); /* never collect these names */
++ }
++}
++
++
++/*
++** function to be used with macro "fasttm": optimized for absence of
++** tag methods
++*/
++const TValue *luaT_gettm (Table *events, TMS event, TString *ename) {
++ const TValue *tm = luaH_getstr(events, ename);
++ lua_assert(event <= TM_EQ);
++ if (ttisnil(tm)) { /* no tag method? */
++ events->flags |= cast_byte(1u<<event); /* cache this fact */
++ return NULL;
++ }
++ else return tm;
++}
++
++
++const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, TMS event) {
++ Table *mt;
++ switch (ttype(o)) {
++ case LUA_TTABLE:
++ mt = hvalue(o)->metatable;
++ break;
++ case LUA_TUSERDATA:
++ mt = uvalue(o)->metatable;
++ break;
++ default:
++ mt = G(L)->mt[ttype(o)];
++ }
++ return (mt ? luaH_getstr(mt, G(L)->tmname[event]) : luaO_nilobject);
++}
++
+--- /dev/null
++++ b/extensions/LUA/lua/ltm.h
+@@ -0,0 +1,54 @@
++/*
++** $Id: ltm.h,v 2.6.1.1 2007/12/27 13:02:25 roberto Exp $
++** Tag methods
++** See Copyright Notice in lua.h
++*/
++
++#ifndef ltm_h
++#define ltm_h
++
++
++#include "lobject.h"
++
++
++/*
++* WARNING: if you change the order of this enumeration,
++* grep "ORDER TM"
++*/
++typedef enum {
++ TM_INDEX,
++ TM_NEWINDEX,
++ TM_GC,
++ TM_MODE,
++ TM_EQ, /* last tag method with `fast' access */
++ TM_ADD,
++ TM_SUB,
++ TM_MUL,
++ TM_DIV,
++ TM_MOD,
++ TM_POW,
++ TM_UNM,
++ TM_LEN,
++ TM_LT,
++ TM_LE,
++ TM_CONCAT,
++ TM_CALL,
++ TM_N /* number of elements in the enum */
++} TMS;
++
++
++
++#define gfasttm(g,et,e) ((et) == NULL ? NULL : \
++ ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e]))
++
++#define fasttm(l,et,e) gfasttm(G(l), et, e)
++
++LUAI_DATA const char *const luaT_typenames[];
++
++
++LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename);
++LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o,
++ TMS event);
++LUAI_FUNC void luaT_init (lua_State *L);
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/luaconf.h
+@@ -0,0 +1,797 @@
++/*
++** $Id: luaconf.h,v 1.82.1.7 2008/02/11 16:25:08 roberto Exp $
++** Configuration file for Lua
++** See Copyright Notice in lua.h
++*/
++
++
++#ifndef lconfig_h
++#define lconfig_h
++
++#include <stddef.h>
++
++#if !defined(__KERNEL__)
++#include <limits.h>
++#else
++#define UCHAR_MAX 255
++#define SHRT_MAX 32767
++#define BUFSIZ 8192
++#define NO_FPU
++#endif
++
++/*
++** ==================================================================
++** Search for "@@" to find all configurable definitions.
++** ===================================================================
++*/
++
++
++/*
++@@ LUA_ANSI controls the use of non-ansi features.
++** CHANGE it (define it) if you want Lua to avoid the use of any
++** non-ansi feature or library.
++*/
++#if defined(__STRICT_ANSI__)
++#define LUA_ANSI
++#endif
++
++
++#if !defined(LUA_ANSI) && defined(_WIN32)
++#define LUA_WIN
++#endif
++
++#if defined(LUA_USE_LINUX)
++#define LUA_USE_POSIX
++#define LUA_USE_DLOPEN /* needs an extra library: -ldl */
++#define LUA_USE_READLINE /* needs some extra libraries */
++#endif
++
++#if defined(LUA_USE_MACOSX)
++#define LUA_USE_POSIX
++#define LUA_DL_DYLD /* does not need extra library */
++#endif
++
++
++
++/*
++@@ LUA_USE_POSIX includes all functionallity listed as X/Open System
++@* Interfaces Extension (XSI).
++** CHANGE it (define it) if your system is XSI compatible.
++*/
++#if defined(LUA_USE_POSIX)
++#define LUA_USE_MKSTEMP
++#define LUA_USE_ISATTY
++#define LUA_USE_POPEN
++#define LUA_USE_ULONGJMP
++#endif
++
++
++/*
++@@ LUA_PATH and LUA_CPATH are the names of the environment variables that
++@* Lua check to set its paths.
++@@ LUA_INIT is the name of the environment variable that Lua
++@* checks for initialization code.
++** CHANGE them if you want different names.
++*/
++#define LUA_PATH "LUA_PATH"
++#define LUA_CPATH "LUA_CPATH"
++#define LUA_INIT "LUA_INIT"
++
++
++/*
++@@ LUA_PATH_DEFAULT is the default path that Lua uses to look for
++@* Lua libraries.
++@@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for
++@* C libraries.
++** CHANGE them if your machine has a non-conventional directory
++** hierarchy or if you want to install your libraries in
++** non-conventional directories.
++*/
++#if defined(_WIN32)
++/*
++** In Windows, any exclamation mark ('!') in the path is replaced by the
++** path of the directory of the executable file of the current process.
++*/
++#define LUA_LDIR "!\\lua\\"
++#define LUA_CDIR "!\\"
++#define LUA_PATH_DEFAULT \
++ ".\\?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \
++ LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua"
++#define LUA_CPATH_DEFAULT \
++ ".\\?.dll;" LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll"
++
++#else
++#define LUA_ROOT "/usr/local/"
++#define LUA_LDIR LUA_ROOT "share/lua/5.1/"
++#define LUA_CDIR LUA_ROOT "lib/lua/5.1/"
++#define LUA_PATH_DEFAULT \
++ "./?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \
++ LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua"
++#define LUA_CPATH_DEFAULT \
++ "./?.so;" LUA_CDIR"?.so;" LUA_CDIR"loadall.so"
++#endif
++
++
++/*
++@@ LUA_DIRSEP is the directory separator (for submodules).
++** CHANGE it if your machine does not use "/" as the directory separator
++** and is not Windows. (On Windows Lua automatically uses "\".)
++*/
++#if defined(_WIN32)
++#define LUA_DIRSEP "\\"
++#else
++#define LUA_DIRSEP "/"
++#endif
++
++
++/*
++@@ LUA_PATHSEP is the character that separates templates in a path.
++@@ LUA_PATH_MARK is the string that marks the substitution points in a
++@* template.
++@@ LUA_EXECDIR in a Windows path is replaced by the executable's
++@* directory.
++@@ LUA_IGMARK is a mark to ignore all before it when bulding the
++@* luaopen_ function name.
++** CHANGE them if for some reason your system cannot use those
++** characters. (E.g., if one of those characters is a common character
++** in file/directory names.) Probably you do not need to change them.
++*/
++#define LUA_PATHSEP ";"
++#define LUA_PATH_MARK "?"
++#define LUA_EXECDIR "!"
++#define LUA_IGMARK "-"
++
++
++/*
++@@ LUA_INTEGER is the integral type used by lua_pushinteger/lua_tointeger.
++** CHANGE that if ptrdiff_t is not adequate on your machine. (On most
++** machines, ptrdiff_t gives a good choice between int or long.)
++*/
++#define LUA_INTEGER ptrdiff_t
++
++
++/*
++@@ LUA_API is a mark for all core API functions.
++@@ LUALIB_API is a mark for all standard library functions.
++** CHANGE them if you need to define those functions in some special way.
++** For instance, if you want to create one Windows DLL with the core and
++** the libraries, you may want to use the following definition (define
++** LUA_BUILD_AS_DLL to get it).
++*/
++#if defined(LUA_BUILD_AS_DLL)
++
++#if defined(LUA_CORE) || defined(LUA_LIB)
++#define LUA_API __declspec(dllexport)
++#else
++#define LUA_API __declspec(dllimport)
++#endif
++
++#else
++
++#define LUA_API extern
++
++#endif
++
++/* more often than not the libs go together with the core */
++#define LUALIB_API LUA_API
++
++
++/*
++@@ LUAI_FUNC is a mark for all extern functions that are not to be
++@* exported to outside modules.
++@@ LUAI_DATA is a mark for all extern (const) variables that are not to
++@* be exported to outside modules.
++** CHANGE them if you need to mark them in some special way. Elf/gcc
++** (versions 3.2 and later) mark them as "hidden" to optimize access
++** when Lua is compiled as a shared library.
++*/
++#if defined(luaall_c)
++#define LUAI_FUNC static
++#define LUAI_DATA /* empty */
++
++#elif defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \
++ defined(__ELF__)
++#define LUAI_FUNC __attribute__((visibility("hidden"))) extern
++#define LUAI_DATA LUAI_FUNC
++
++#else
++#define LUAI_FUNC extern
++#define LUAI_DATA extern
++#endif
++
++
++
++/*
++@@ LUA_QL describes how error messages quote program elements.
++** CHANGE it if you want a different appearance.
++*/
++#define LUA_QL(x) "'" x "'"
++#define LUA_QS LUA_QL("%s")
++
++
++/*
++@@ LUA_IDSIZE gives the maximum size for the description of the source
++@* of a function in debug information.
++** CHANGE it if you want a different size.
++*/
++#define LUA_IDSIZE 60
++
++
++/*
++** {==================================================================
++** Stand-alone configuration
++** ===================================================================
++*/
++
++#if defined(lua_c) || defined(luaall_c)
++
++/*
++@@ lua_stdin_is_tty detects whether the standard input is a 'tty' (that
++@* is, whether we're running lua interactively).
++** CHANGE it if you have a better definition for non-POSIX/non-Windows
++** systems.
++*/
++#if defined(LUA_USE_ISATTY)
++#include <unistd.h>
++#define lua_stdin_is_tty() isatty(0)
++#elif defined(LUA_WIN)
++#include <io.h>
++#include <stdio.h>
++#define lua_stdin_is_tty() _isatty(_fileno(stdin))
++#else
++#define lua_stdin_is_tty() 1 /* assume stdin is a tty */
++#endif
++
++
++/*
++@@ LUA_PROMPT is the default prompt used by stand-alone Lua.
++@@ LUA_PROMPT2 is the default continuation prompt used by stand-alone Lua.
++** CHANGE them if you want different prompts. (You can also change the
++** prompts dynamically, assigning to globals _PROMPT/_PROMPT2.)
++*/
++#define LUA_PROMPT "> "
++#define LUA_PROMPT2 ">> "
++
++
++/*
++@@ LUA_PROGNAME is the default name for the stand-alone Lua program.
++** CHANGE it if your stand-alone interpreter has a different name and
++** your system is not able to detect that name automatically.
++*/
++#define LUA_PROGNAME "lua"
++
++
++/*
++@@ LUA_MAXINPUT is the maximum length for an input line in the
++@* stand-alone interpreter.
++** CHANGE it if you need longer lines.
++*/
++#define LUA_MAXINPUT 512
++
++
++/*
++@@ lua_readline defines how to show a prompt and then read a line from
++@* the standard input.
++@@ lua_saveline defines how to "save" a read line in a "history".
++@@ lua_freeline defines how to free a line read by lua_readline.
++** CHANGE them if you want to improve this functionality (e.g., by using
++** GNU readline and history facilities).
++*/
++#if defined(LUA_USE_READLINE)
++#include <stdio.h>
++#include <readline/readline.h>
++#include <readline/history.h>
++#define lua_readline(L,b,p) ((void)L, ((b)=readline(p)) != NULL)
++#define lua_saveline(L,idx) \
++ if (lua_strlen(L,idx) > 0) /* non-empty line? */ \
++ add_history(lua_tostring(L, idx)); /* add it to history */
++#define lua_freeline(L,b) ((void)L, free(b))
++#else
++#define lua_readline(L,b,p) \
++ ((void)L, fputs(p, stdout), fflush(stdout), /* show prompt */ \
++ fgets(b, LUA_MAXINPUT, stdin) != NULL) /* get line */
++#define lua_saveline(L,idx) { (void)L; (void)idx; }
++#define lua_freeline(L,b) { (void)L; (void)b; }
++#endif
++
++#endif
++
++/* }================================================================== */
++
++
++/*
++@@ LUAI_GCPAUSE defines the default pause between garbage-collector cycles
++@* as a percentage.
++** CHANGE it if you want the GC to run faster or slower (higher values
++** mean larger pauses which mean slower collection.) You can also change
++** this value dynamically.
++*/
++#define LUAI_GCPAUSE 200 /* 200% (wait memory to double before next GC) */
++
++
++/*
++@@ LUAI_GCMUL defines the default speed of garbage collection relative to
++@* memory allocation as a percentage.
++** CHANGE it if you want to change the granularity of the garbage
++** collection. (Higher values mean coarser collections. 0 represents
++** infinity, where each step performs a full collection.) You can also
++** change this value dynamically.
++*/
++#define LUAI_GCMUL 200 /* GC runs 'twice the speed' of memory allocation */
++
++
++
++/*
++@@ LUA_COMPAT_GETN controls compatibility with old getn behavior.
++** CHANGE it (define it) if you want exact compatibility with the
++** behavior of setn/getn in Lua 5.0.
++*/
++#undef LUA_COMPAT_GETN
++
++/*
++@@ LUA_COMPAT_LOADLIB controls compatibility about global loadlib.
++** CHANGE it to undefined as soon as you do not need a global 'loadlib'
++** function (the function is still available as 'package.loadlib').
++*/
++#undef LUA_COMPAT_LOADLIB
++
++/*
++@@ LUA_COMPAT_VARARG controls compatibility with old vararg feature.
++** CHANGE it to undefined as soon as your programs use only '...' to
++** access vararg parameters (instead of the old 'arg' table).
++*/
++#define LUA_COMPAT_VARARG
++
++/*
++@@ LUA_COMPAT_MOD controls compatibility with old math.mod function.
++** CHANGE it to undefined as soon as your programs use 'math.fmod' or
++** the new '%' operator instead of 'math.mod'.
++*/
++#define LUA_COMPAT_MOD
++
++/*
++@@ LUA_COMPAT_LSTR controls compatibility with old long string nesting
++@* facility.
++** CHANGE it to 2 if you want the old behaviour, or undefine it to turn
++** off the advisory error when nesting [[...]].
++*/
++#define LUA_COMPAT_LSTR 1
++
++/*
++@@ LUA_COMPAT_GFIND controls compatibility with old 'string.gfind' name.
++** CHANGE it to undefined as soon as you rename 'string.gfind' to
++** 'string.gmatch'.
++*/
++#define LUA_COMPAT_GFIND
++
++/*
++@@ LUA_COMPAT_OPENLIB controls compatibility with old 'luaL_openlib'
++@* behavior.
++** CHANGE it to undefined as soon as you replace to 'luaL_register'
++** your uses of 'luaL_openlib'
++*/
++#define LUA_COMPAT_OPENLIB
++
++
++
++/*
++@@ luai_apicheck is the assert macro used by the Lua-C API.
++** CHANGE luai_apicheck if you want Lua to perform some checks in the
++** parameters it gets from API calls. This may slow down the interpreter
++** a bit, but may be quite useful when debugging C code that interfaces
++** with Lua. A useful redefinition is to use assert.h.
++*/
++#if defined(LUA_USE_APICHECK)
++#include <assert.h>
++#define luai_apicheck(L,o) { (void)L; assert(o); }
++#else
++#define luai_apicheck(L,o) { (void)L; }
++#endif
++
++
++/*
++@@ LUAI_BITSINT defines the number of bits in an int.
++** CHANGE here if Lua cannot automatically detect the number of bits of
++** your machine. Probably you do not need to change this.
++*/
++/* avoid overflows in comparison */
++#if !defined(__KERNEL__)
++#include <limits.h>
++#define LUA_INT_MAX INT_MAX
++#else
++#define LUA_INT_MAX (~0U>>1)
++#endif
++
++#if LUA_INT_MAX-20 < 32760
++#define LUAI_BITSINT 16
++#elif LUA_INT_MAX > 2147483640L
++/* int has at least 32 bits */
++#define LUAI_BITSINT 32
++#else
++#error "you must define LUA_BITSINT with number of bits in an integer"
++#endif
++
++
++/*
++@@ LUAI_UINT32 is an unsigned integer with at least 32 bits.
++@@ LUAI_INT32 is an signed integer with at least 32 bits.
++@@ LUAI_UMEM is an unsigned integer big enough to count the total
++@* memory used by Lua.
++@@ LUAI_MEM is a signed integer big enough to count the total memory
++@* used by Lua.
++** CHANGE here if for some weird reason the default definitions are not
++** good enough for your machine. (The definitions in the 'else'
++** part always works, but may waste space on machines with 64-bit
++** longs.) Probably you do not need to change this.
++*/
++#if LUAI_BITSINT >= 32
++#define LUAI_UINT32 unsigned int
++#define LUAI_INT32 int
++#define LUAI_MAXINT32 INT_MAX
++#define LUAI_UMEM size_t
++#define LUAI_MEM ptrdiff_t
++#else
++/* 16-bit ints */
++#define LUAI_UINT32 unsigned long
++#define LUAI_INT32 long
++#define LUAI_MAXINT32 LONG_MAX
++#define LUAI_UMEM unsigned long
++#define LUAI_MEM long
++#endif
++
++
++/*
++@@ LUAI_MAXCALLS limits the number of nested calls.
++** CHANGE it if you need really deep recursive calls. This limit is
++** arbitrary; its only purpose is to stop infinite recursion before
++** exhausting memory.
++*/
++#define LUAI_MAXCALLS 20000
++
++
++/*
++@@ LUAI_MAXCSTACK limits the number of Lua stack slots that a C function
++@* can use.
++** CHANGE it if you need lots of (Lua) stack space for your C
++** functions. This limit is arbitrary; its only purpose is to stop C
++** functions to consume unlimited stack space. (must be smaller than
++** -LUA_REGISTRYINDEX)
++*/
++#define LUAI_MAXCSTACK 8000
++
++
++
++/*
++** {==================================================================
++** CHANGE (to smaller values) the following definitions if your system
++** has a small C stack. (Or you may want to change them to larger
++** values if your system has a large C stack and these limits are
++** too rigid for you.) Some of these constants control the size of
++** stack-allocated arrays used by the compiler or the interpreter, while
++** others limit the maximum number of recursive calls that the compiler
++** or the interpreter can perform. Values too large may cause a C stack
++** overflow for some forms of deep constructs.
++** ===================================================================
++*/
++
++
++/*
++@@ LUAI_MAXCCALLS is the maximum depth for nested C calls (short) and
++@* syntactical nested non-terminals in a program.
++*/
++#define LUAI_MAXCCALLS 200
++
++
++/*
++@@ LUAI_MAXVARS is the maximum number of local variables per function
++@* (must be smaller than 250).
++*/
++#define LUAI_MAXVARS 200
++
++
++/*
++@@ LUAI_MAXUPVALUES is the maximum number of upvalues per function
++@* (must be smaller than 250).
++*/
++#define LUAI_MAXUPVALUES 60
++
++
++/*
++@@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system.
++*/
++#define LUAL_BUFFERSIZE BUFSIZ
++
++/* }================================================================== */
++
++
++
++
++/*
++** {==================================================================
++@@ LUA_NUMBER is the type of numbers in Lua.
++** CHANGE the following definitions only if you want to build Lua
++** with a number type different from double. You may also need to
++** change lua_number2int & lua_number2integer.
++** ===================================================================
++*/
++#if !defined(NO_FPU)
++#define LUA_NUMBER_DOUBLE
++#define LUA_NUMBER double
++#else
++#define LUA_NUMBER long
++#endif
++
++/*
++@@ LUAI_UACNUMBER is the result of an 'usual argument conversion'
++@* over a number.
++*/
++#define LUAI_UACNUMBER LUA_NUMBER
++
++
++/*
++@@ LUA_NUMBER_SCAN is the format for reading numbers.
++@@ LUA_NUMBER_FMT is the format for writing numbers.
++@@ lua_number2str converts a number to a string.
++@@ LUAI_MAXNUMBER2STR is maximum size of previous conversion.
++@@ lua_str2number converts a string to a number.
++*/
++#if !defined(NO_FPU)
++#define LUA_NUMBER_SCAN "%lf"
++#define LUA_NUMBER_FMT "%.14g"
++#define lua_str2number(s,p) strtod((s), (p))
++#else
++#define LUA_NUMBER_SCAN "%ld"
++#define LUA_NUMBER_FMT "%ld"
++#if !defined(__KERNEL__)
++#define lua_str2number(s,p) strtol((s), (p), 10)
++#else
++#define lua_str2number(s,p) simple_strtol((s), (p), 10)
++#endif
++#endif
++
++#define LUAI_MAXNUMBER2STR 32 /* 16 digits, sign, point, and \0 */
++#define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n))
++
++/*
++@@ The luai_num* macros define the primitive operations over numbers.
++*/
++#if defined(LUA_CORE)
++#define luai_numadd(a,b) ((a)+(b))
++#define luai_numsub(a,b) ((a)-(b))
++#define luai_nummul(a,b) ((a)*(b))
++#define luai_numdiv(a,b) ((a)/(b))
++#define luai_numunm(a) (-(a))
++#define luai_numeq(a,b) ((a)==(b))
++#define luai_numlt(a,b) ((a)<(b))
++#define luai_numle(a,b) ((a)<=(b))
++#define luai_numisnan(a) (!luai_numeq((a), (a)))
++#if !defined(NO_FPU)
++#include <math.h>
++#define luai_nummod(a,b) ((a) - floor((a)/(b))*(b))
++#define luai_numpow(a,b) (pow(a,b))
++#else
++#define luai_nummod(a,b) ((a)%(b))
++#define luai_numpow(a,b) luai_nummul(a,b)
++#endif
++#endif
++
++
++/*
++@@ lua_number2int is a macro to convert lua_Number to int.
++@@ lua_number2integer is a macro to convert lua_Number to lua_Integer.
++** CHANGE them if you know a faster way to convert a lua_Number to
++** int (with any rounding method and without throwing errors) in your
++** system. In Pentium machines, a naive typecast from double to int
++** in C is extremely slow, so any alternative is worth trying.
++*/
++
++/* On a Pentium, resort to a trick */
++#if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) && !defined(__SSE2__) && \
++ (defined(__i386) || defined (_M_IX86) || defined(__i386__))
++
++/* On a Microsoft compiler, use assembler */
++#if defined(_MSC_VER)
++
++#define lua_number2int(i,d) __asm fld d __asm fistp i
++#define lua_number2integer(i,n) lua_number2int(i, n)
++
++/* the next trick should work on any Pentium, but sometimes clashes
++ with a DirectX idiosyncrasy */
++#else
++
++union luai_Cast { double l_d; long l_l; };
++#define lua_number2int(i,d) \
++ { volatile union luai_Cast u; u.l_d = (d) + 6755399441055744.0; (i) = u.l_l; }
++#define lua_number2integer(i,n) lua_number2int(i, n)
++
++#endif
++
++
++/* this option always works, but may be slow */
++#else
++#define lua_number2int(i,d) ((i)=(int)(d))
++#define lua_number2integer(i,d) ((i)=(lua_Integer)(d))
++
++#endif
++
++/* }================================================================== */
++
++
++/*
++@@ LUAI_USER_ALIGNMENT_T is a type that requires maximum alignment.
++** CHANGE it if your system requires alignments larger than double. (For
++** instance, if your system supports long doubles and they must be
++** aligned in 16-byte boundaries, then you should add long double in the
++** union.) Probably you do not need to change this.
++*/
++#define LUAI_USER_ALIGNMENT_T union { double u; void *s; long l; }
++
++
++/*
++@@ LUAI_THROW/LUAI_TRY define how Lua does exception handling.
++** CHANGE them if you prefer to use longjmp/setjmp even with C++
++** or if want/don't to use _longjmp/_setjmp instead of regular
++** longjmp/setjmp. By default, Lua handles errors with exceptions when
++** compiling as C++ code, with _longjmp/_setjmp when asked to use them,
++** and with longjmp/setjmp otherwise.
++*/
++#if defined(__KERNEL__)
++#undef LUA_USE_ULONGJMP
++#endif
++
++#if defined(__cplusplus)
++/* C++ exceptions */
++#define LUAI_THROW(L,c) throw(c)
++#define LUAI_TRY(L,c,a) try { a } catch(...) \
++ { if ((c)->status == 0) (c)->status = -1; }
++#define luai_jmpbuf int /* dummy variable */
++
++#elif defined(LUA_USE_ULONGJMP)
++/* in Unix, try _longjmp/_setjmp (more efficient) */
++#define LUAI_THROW(L,c) _longjmp((c)->b, 1)
++#define LUAI_TRY(L,c,a) if (_setjmp((c)->b) == 0) { a }
++#define luai_jmpbuf jmp_buf
++
++#else
++/* default handling with long jumps */
++#define LUAI_THROW(L,c) longjmp((c)->b, 1)
++#define LUAI_TRY(L,c,a) if (setjmp((c)->b) == 0) { a }
++#define luai_jmpbuf jmp_buf
++
++#endif
++
++
++/*
++@@ LUA_MAXCAPTURES is the maximum number of captures that a pattern
++@* can do during pattern-matching.
++** CHANGE it if you need more captures. This limit is arbitrary.
++*/
++#define LUA_MAXCAPTURES 32
++
++
++/*
++@@ lua_tmpnam is the function that the OS library uses to create a
++@* temporary name.
++@@ LUA_TMPNAMBUFSIZE is the maximum size of a name created by lua_tmpnam.
++** CHANGE them if you have an alternative to tmpnam (which is considered
++** insecure) or if you want the original tmpnam anyway. By default, Lua
++** uses tmpnam except when POSIX is available, where it uses mkstemp.
++*/
++#if defined(loslib_c) || defined(luaall_c)
++
++#if defined(LUA_USE_MKSTEMP)
++#include <unistd.h>
++#define LUA_TMPNAMBUFSIZE 32
++#define lua_tmpnam(b,e) { \
++ strcpy(b, "/tmp/lua_XXXXXX"); \
++ e = mkstemp(b); \
++ if (e != -1) close(e); \
++ e = (e == -1); }
++
++#else
++#define LUA_TMPNAMBUFSIZE L_tmpnam
++#define lua_tmpnam(b,e) { e = (tmpnam(b) == NULL); }
++#endif
++
++#endif
++
++
++/*
++@@ lua_popen spawns a new process connected to the current one through
++@* the file streams.
++** CHANGE it if you have a way to implement it in your system.
++*/
++#if defined(LUA_USE_POPEN)
++
++#define lua_popen(L,c,m) ((void)L, fflush(NULL), popen(c,m))
++#define lua_pclose(L,file) ((void)L, (pclose(file) != -1))
++
++#elif defined(LUA_WIN)
++
++#define lua_popen(L,c,m) ((void)L, _popen(c,m))
++#define lua_pclose(L,file) ((void)L, (_pclose(file) != -1))
++
++#else
++
++#define lua_popen(L,c,m) ((void)((void)c, m), \
++ luaL_error(L, LUA_QL("popen") " not supported"), (FILE*)0)
++#define lua_pclose(L,file) ((void)((void)L, file), 0)
++
++#endif
++
++/*
++@@ LUA_DL_* define which dynamic-library system Lua should use.
++** CHANGE here if Lua has problems choosing the appropriate
++** dynamic-library system for your platform (either Windows' DLL, Mac's
++** dyld, or Unix's dlopen). If your system is some kind of Unix, there
++** is a good chance that it has dlopen, so LUA_DL_DLOPEN will work for
++** it. To use dlopen you also need to adapt the src/Makefile (probably
++** adding -ldl to the linker options), so Lua does not select it
++** automatically. (When you change the makefile to add -ldl, you must
++** also add -DLUA_USE_DLOPEN.)
++** If you do not want any kind of dynamic library, undefine all these
++** options.
++** By default, _WIN32 gets LUA_DL_DLL and MAC OS X gets LUA_DL_DYLD.
++*/
++#if defined(LUA_USE_DLOPEN)
++#define LUA_DL_DLOPEN
++#endif
++
++#if defined(LUA_WIN)
++#define LUA_DL_DLL
++#endif
++
++
++/*
++@@ LUAI_EXTRASPACE allows you to add user-specific data in a lua_State
++@* (the data goes just *before* the lua_State pointer).
++** CHANGE (define) this if you really need that. This value must be
++** a multiple of the maximum alignment required for your machine.
++*/
++#define LUAI_EXTRASPACE 0
++
++
++/*
++@@ luai_userstate* allow user-specific actions on threads.
++** CHANGE them if you defined LUAI_EXTRASPACE and need to do something
++** extra when a thread is created/deleted/resumed/yielded.
++*/
++#define luai_userstateopen(L) ((void)L)
++#define luai_userstateclose(L) ((void)L)
++#define luai_userstatethread(L,L1) ((void)L)
++#define luai_userstatefree(L) ((void)L)
++#define luai_userstateresume(L,n) ((void)L)
++#define luai_userstateyield(L,n) ((void)L)
++
++
++/*
++@@ LUA_INTFRMLEN is the length modifier for integer conversions
++@* in 'string.format'.
++@@ LUA_INTFRM_T is the integer type correspoding to the previous length
++@* modifier.
++** CHANGE them if your system supports long long or does not support long.
++*/
++
++#if defined(LUA_USELONGLONG)
++
++#define LUA_INTFRMLEN "ll"
++#define LUA_INTFRM_T long long
++
++#else
++
++#define LUA_INTFRMLEN "l"
++#define LUA_INTFRM_T long
++
++#endif
++
++/* =================================================================== */
++
++/*
++** Local configuration. You can use this space to add your redefinitions
++** without modifying the main part of the file.
++*/
++
++
++
++#endif
++
+--- /dev/null
++++ b/extensions/LUA/lua/lua.h
+@@ -0,0 +1,387 @@
++/*
++** $Id: lua.h,v 1.218.1.5 2008/08/06 13:30:12 roberto Exp $
++** Lua - An Extensible Extension Language
++** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
++** See Copyright Notice at the end of this file
++*/
++
++
++#ifndef lua_h
++#define lua_h
++
++#include <stdarg.h>
++#include <stddef.h>
++
++#include "luaconf.h"
++
++
++#define LUA_VERSION "Lua 5.1"
++#define LUA_RELEASE "Lua 5.1.4"
++#define LUA_VERSION_NUM 501
++#define LUA_COPYRIGHT "Copyright (C) 1994-2008 Lua.org, PUC-Rio"
++#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo & W. Celes"
++
++
++/* mark for precompiled code (`<esc>Lua') */
++#define LUA_SIGNATURE "\033Lua"
++
++/* option for multiple returns in `lua_pcall' and `lua_call' */
++#define LUA_MULTRET (-1)
++
++
++/*
++** pseudo-indices
++*/
++#define LUA_REGISTRYINDEX (-10000)
++#define LUA_ENVIRONINDEX (-10001)
++#define LUA_GLOBALSINDEX (-10002)
++#define lua_upvalueindex(i) (LUA_GLOBALSINDEX-(i))
++
++
++/* thread status; 0 is OK */
++#define LUA_YIELD 1
++#define LUA_ERRRUN 2
++#define LUA_ERRSYNTAX 3
++#define LUA_ERRMEM 4
++#define LUA_ERRERR 5
++
++
++typedef struct lua_State lua_State;
++
++typedef int (*lua_CFunction) (lua_State *L);
++
++
++/*
++** functions that read/write blocks when loading/dumping Lua chunks
++*/
++typedef const char * (*lua_Reader) (lua_State *L, void *ud, size_t *sz);
++
++typedef int (*lua_Writer) (lua_State *L, const void* p, size_t sz, void* ud);
++
++
++/*
++** prototype for memory-allocation functions
++*/
++typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize);
++
++
++/*
++** basic types
++*/
++#define LUA_TNONE (-1)
++
++#define LUA_TNIL 0
++#define LUA_TBOOLEAN 1
++#define LUA_TLIGHTUSERDATA 2
++#define LUA_TNUMBER 3
++#define LUA_TSTRING 4
++#define LUA_TTABLE 5
++#define LUA_TFUNCTION 6
++#define LUA_TUSERDATA 7
++#define LUA_TTHREAD 8
++
++
++
++/* minimum Lua stack available to a C function */
++#define LUA_MINSTACK 20
++
++
++/*
++** generic extra include file
++*/
++#if defined(LUA_USER_H)
++#include LUA_USER_H
++#endif
++
++
++/* type of numbers in Lua */
++typedef LUA_NUMBER lua_Number;
++
++
++/* type for integer functions */
++typedef LUA_INTEGER lua_Integer;
++
++
++
++/*
++** state manipulation
++*/
++LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud);
++LUA_API void (lua_close) (lua_State *L);
++LUA_API lua_State *(lua_newthread) (lua_State *L);
++
++LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf);
++
++
++/*
++** basic stack manipulation
++*/
++LUA_API int (lua_gettop) (lua_State *L);
++LUA_API void (lua_settop) (lua_State *L, int idx);
++LUA_API void (lua_pushvalue) (lua_State *L, int idx);
++LUA_API void (lua_remove) (lua_State *L, int idx);
++LUA_API void (lua_insert) (lua_State *L, int idx);
++LUA_API void (lua_replace) (lua_State *L, int idx);
++LUA_API int (lua_checkstack) (lua_State *L, int sz);
++
++LUA_API void (lua_xmove) (lua_State *from, lua_State *to, int n);
++
++
++/*
++** access functions (stack -> C)
++*/
++
++LUA_API int (lua_isnumber) (lua_State *L, int idx);
++LUA_API int (lua_isstring) (lua_State *L, int idx);
++LUA_API int (lua_iscfunction) (lua_State *L, int idx);
++LUA_API int (lua_isuserdata) (lua_State *L, int idx);
++LUA_API int (lua_type) (lua_State *L, int idx);
++LUA_API const char *(lua_typename) (lua_State *L, int tp);
++
++LUA_API int (lua_equal) (lua_State *L, int idx1, int idx2);
++LUA_API int (lua_rawequal) (lua_State *L, int idx1, int idx2);
++LUA_API int (lua_lessthan) (lua_State *L, int idx1, int idx2);
++
++LUA_API lua_Number (lua_tonumber) (lua_State *L, int idx);
++LUA_API lua_Integer (lua_tointeger) (lua_State *L, int idx);
++LUA_API int (lua_toboolean) (lua_State *L, int idx);
++LUA_API const char *(lua_tolstring) (lua_State *L, int idx, size_t *len);
++LUA_API size_t (lua_objlen) (lua_State *L, int idx);
++LUA_API lua_CFunction (lua_tocfunction) (lua_State *L, int idx);
++LUA_API void *(lua_touserdata) (lua_State *L, int idx);
++LUA_API lua_State *(lua_tothread) (lua_State *L, int idx);
++LUA_API const void *(lua_topointer) (lua_State *L, int idx);
++
++
++/*
++** push functions (C -> stack)
++*/
++LUA_API void (lua_pushnil) (lua_State *L);
++LUA_API void (lua_pushnumber) (lua_State *L, lua_Number n);
++LUA_API void (lua_pushinteger) (lua_State *L, lua_Integer n);
++LUA_API void (lua_pushlstring) (lua_State *L, const char *s, size_t l);
++LUA_API void (lua_pushstring) (lua_State *L, const char *s);
++LUA_API const char *(lua_pushvfstring) (lua_State *L, const char *fmt,
++ va_list argp);
++LUA_API const char *(lua_pushfstring) (lua_State *L, const char *fmt, ...);
++LUA_API void (lua_pushcclosure) (lua_State *L, lua_CFunction fn, int n);
++LUA_API void (lua_pushboolean) (lua_State *L, int b);
++LUA_API void (lua_pushlightuserdata) (lua_State *L, void *p);
++LUA_API int (lua_pushthread) (lua_State *L);
++
++
++/*
++** get functions (Lua -> stack)
++*/
++LUA_API void (lua_gettable) (lua_State *L, int idx);
++LUA_API void (lua_getfield) (lua_State *L, int idx, const char *k);
++LUA_API void (lua_rawget) (lua_State *L, int idx);
++LUA_API void (lua_rawgeti) (lua_State *L, int idx, int n);
++LUA_API void (lua_createtable) (lua_State *L, int narr, int nrec);
++LUA_API void *(lua_newuserdata) (lua_State *L, size_t sz);
++LUA_API int (lua_getmetatable) (lua_State *L, int objindex);
++LUA_API void (lua_getfenv) (lua_State *L, int idx);
++
++
++/*
++** set functions (stack -> Lua)
++*/
++LUA_API void (lua_settable) (lua_State *L, int idx);
++LUA_API void (lua_setfield) (lua_State *L, int idx, const char *k);
++LUA_API void (lua_rawset) (lua_State *L, int idx);
++LUA_API void (lua_rawseti) (lua_State *L, int idx, int n);
++LUA_API int (lua_setmetatable) (lua_State *L, int objindex);
++LUA_API int (lua_setfenv) (lua_State *L, int idx);
++
++
++/*
++** `load' and `call' functions (load and run Lua code)
++*/
++LUA_API void (lua_call) (lua_State *L, int nargs, int nresults);
++LUA_API int (lua_pcall) (lua_State *L, int nargs, int nresults, int errfunc);
++LUA_API int (lua_cpcall) (lua_State *L, lua_CFunction func, void *ud);
++LUA_API int (lua_load) (lua_State *L, lua_Reader reader, void *dt,
++ const char *chunkname);
++
++LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data);
++
++
++/*
++** coroutine functions
++*/
++LUA_API int (lua_yield) (lua_State *L, int nresults);
++LUA_API int (lua_resume) (lua_State *L, int narg);
++LUA_API int (lua_status) (lua_State *L);
++
++/*
++** garbage-collection function and options
++*/
++
++#define LUA_GCSTOP 0
++#define LUA_GCRESTART 1
++#define LUA_GCCOLLECT 2
++#define LUA_GCCOUNT 3
++#define LUA_GCCOUNTB 4
++#define LUA_GCSTEP 5
++#define LUA_GCSETPAUSE 6
++#define LUA_GCSETSTEPMUL 7
++
++LUA_API int (lua_gc) (lua_State *L, int what, int data);
++
++
++/*
++** miscellaneous functions
++*/
++
++LUA_API int (lua_error) (lua_State *L);
++
++LUA_API int (lua_next) (lua_State *L, int idx);
++
++LUA_API void (lua_concat) (lua_State *L, int n);
++
++LUA_API lua_Alloc (lua_getallocf) (lua_State *L, void **ud);
++LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud);
++
++
++
++/*
++** ===============================================================
++** some useful macros
++** ===============================================================
++*/
++
++#define lua_pop(L,n) lua_settop(L, -(n)-1)
++
++#define lua_newtable(L) lua_createtable(L, 0, 0)
++
++#define lua_register(L,n,f) (lua_pushcfunction(L, (f)), lua_setglobal(L, (n)))
++
++#define lua_pushcfunction(L,f) lua_pushcclosure(L, (f), 0)
++
++#define lua_strlen(L,i) lua_objlen(L, (i))
++
++#define lua_isfunction(L,n) (lua_type(L, (n)) == LUA_TFUNCTION)
++#define lua_istable(L,n) (lua_type(L, (n)) == LUA_TTABLE)
++#define lua_islightuserdata(L,n) (lua_type(L, (n)) == LUA_TLIGHTUSERDATA)
++#define lua_isnil(L,n) (lua_type(L, (n)) == LUA_TNIL)
++#define lua_isboolean(L,n) (lua_type(L, (n)) == LUA_TBOOLEAN)
++#define lua_isthread(L,n) (lua_type(L, (n)) == LUA_TTHREAD)
++#define lua_isnone(L,n) (lua_type(L, (n)) == LUA_TNONE)
++#define lua_isnoneornil(L, n) (lua_type(L, (n)) <= 0)
++
++#define lua_pushliteral(L, s) \
++ lua_pushlstring(L, "" s, (sizeof(s)/sizeof(char))-1)
++
++#define lua_setglobal(L,s) lua_setfield(L, LUA_GLOBALSINDEX, (s))
++#define lua_getglobal(L,s) lua_getfield(L, LUA_GLOBALSINDEX, (s))
++
++#define lua_tostring(L,i) lua_tolstring(L, (i), NULL)
++
++
++
++/*
++** compatibility macros and functions
++*/
++
++#define lua_open() luaL_newstate()
++
++#define lua_getregistry(L) lua_pushvalue(L, LUA_REGISTRYINDEX)
++
++#define lua_getgccount(L) lua_gc(L, LUA_GCCOUNT, 0)
++
++#define lua_Chunkreader lua_Reader
++#define lua_Chunkwriter lua_Writer
++
++
++/* hack */
++LUA_API void lua_setlevel (lua_State *from, lua_State *to);
++
++
++/*
++** {======================================================================
++** Debug API
++** =======================================================================
++*/
++
++
++/*
++** Event codes
++*/
++#define LUA_HOOKCALL 0
++#define LUA_HOOKRET 1
++#define LUA_HOOKLINE 2
++#define LUA_HOOKCOUNT 3
++#define LUA_HOOKTAILRET 4
++
++
++/*
++** Event masks
++*/
++#define LUA_MASKCALL (1 << LUA_HOOKCALL)
++#define LUA_MASKRET (1 << LUA_HOOKRET)
++#define LUA_MASKLINE (1 << LUA_HOOKLINE)
++#define LUA_MASKCOUNT (1 << LUA_HOOKCOUNT)
++
++typedef struct lua_Debug lua_Debug; /* activation record */
++
++
++/* Functions to be called by the debuger in specific events */
++typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar);
++
++
++LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar);
++LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar);
++LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n);
++LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n);
++LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n);
++LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n);
++
++LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count);
++LUA_API lua_Hook lua_gethook (lua_State *L);
++LUA_API int lua_gethookmask (lua_State *L);
++LUA_API int lua_gethookcount (lua_State *L);
++
++
++struct lua_Debug {
++ int event;
++ const char *name; /* (n) */
++ const char *namewhat; /* (n) `global', `local', `field', `method' */
++ const char *what; /* (S) `Lua', `C', `main', `tail' */
++ const char *source; /* (S) */
++ int currentline; /* (l) */
++ int nups; /* (u) number of upvalues */
++ int linedefined; /* (S) */
++ int lastlinedefined; /* (S) */
++ char short_src[LUA_IDSIZE]; /* (S) */
++ /* private part */
++ int i_ci; /* active function */
++};
++
++/* }====================================================================== */
++
++
++/******************************************************************************
++* Copyright (C) 1994-2008 Lua.org, PUC-Rio. All rights reserved.
++*
++* Permission is hereby granted, free of charge, to any person obtaining
++* a copy of this software and associated documentation files (the
++* "Software"), to deal in the Software without restriction, including
++* without limitation the rights to use, copy, modify, merge, publish,
++* distribute, sublicense, and/or sell copies of the Software, and to
++* permit persons to whom the Software is furnished to do so, subject to
++* the following conditions:
++*
++* The above copyright notice and this permission notice shall be
++* included in all copies or substantial portions of the Software.
++*
++* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
++* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
++* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
++* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
++* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
++* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
++* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++******************************************************************************/
++
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/lualib.h
+@@ -0,0 +1,55 @@
++/*
++** $Id: lualib.h,v 1.36.1.1 2007/12/27 13:02:25 roberto Exp $
++** Lua standard libraries
++** See Copyright Notice in lua.h
++*/
++
++
++#ifndef lualib_h
++#define lualib_h
++
++#include "lua.h"
++
++
++/* Key to file-handle type */
++#define LUA_FILEHANDLE "FILE*"
++
++
++#define LUA_COLIBNAME "coroutine"
++LUALIB_API int (luaopen_base) (lua_State *L);
++
++#define LUA_TABLIBNAME "table"
++LUALIB_API int (luaopen_table) (lua_State *L);
++/*
++#define LUA_IOLIBNAME "io"
++LUALIB_API int (luaopen_io) (lua_State *L);
++
++#define LUA_OSLIBNAME "os"
++LUALIB_API int (luaopen_os) (lua_State *L);
++*/
++
++#define LUA_STRLIBNAME "string"
++LUALIB_API int (luaopen_string) (lua_State *L);
++
++/*
++#define LUA_MATHLIBNAME "math"
++LUALIB_API int (luaopen_math) (lua_State *L);
++
++#define LUA_DBLIBNAME "debug"
++LUALIB_API int (luaopen_debug) (lua_State *L);
++
++#define LUA_LOADLIBNAME "package"
++LUALIB_API int (luaopen_package) (lua_State *L);
++*/
++
++/* open all previous libraries */
++LUALIB_API void (luaL_openlibs) (lua_State *L);
++
++
++
++#ifndef lua_assert
++#define lua_assert(x) ((void)0)
++#endif
++
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/lundump.c
+@@ -0,0 +1,227 @@
++/*
++** $Id: lundump.c,v 2.7.1.4 2008/04/04 19:51:41 roberto Exp $
++** load precompiled Lua chunks
++** See Copyright Notice in lua.h
++*/
++
++#include <string.h>
++
++#define lundump_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "ldebug.h"
++#include "ldo.h"
++#include "lfunc.h"
++#include "lmem.h"
++#include "lobject.h"
++#include "lstring.h"
++#include "lundump.h"
++#include "lzio.h"
++
++typedef struct {
++ lua_State* L;
++ ZIO* Z;
++ Mbuffer* b;
++ const char* name;
++} LoadState;
++
++#ifdef LUAC_TRUST_BINARIES
++#define IF(c,s)
++#define error(S,s)
++#else
++#define IF(c,s) if (c) error(S,s)
++
++static void error(LoadState* S, const char* why)
++{
++ luaO_pushfstring(S->L,"%s: %s in precompiled chunk",S->name,why);
++ luaD_throw(S->L,LUA_ERRSYNTAX);
++}
++#endif
++
++#define LoadMem(S,b,n,size) LoadBlock(S,b,(n)*(size))
++#define LoadByte(S) (lu_byte)LoadChar(S)
++#define LoadVar(S,x) LoadMem(S,&x,1,sizeof(x))
++#define LoadVector(S,b,n,size) LoadMem(S,b,n,size)
++
++static void LoadBlock(LoadState* S, void* b, size_t size)
++{
++ size_t r=luaZ_read(S->Z,b,size);
++ IF (r!=0, "unexpected end");
++}
++
++static int LoadChar(LoadState* S)
++{
++ char x;
++ LoadVar(S,x);
++ return x;
++}
++
++static int LoadInt(LoadState* S)
++{
++ int x;
++ LoadVar(S,x);
++ IF (x<0, "bad integer");
++ return x;
++}
++
++static lua_Number LoadNumber(LoadState* S)
++{
++ lua_Number x;
++ LoadVar(S,x);
++ return x;
++}
++
++static TString* LoadString(LoadState* S)
++{
++ size_t size;
++ LoadVar(S,size);
++ if (size==0)
++ return NULL;
++ else
++ {
++ char* s=luaZ_openspace(S->L,S->b,size);
++ LoadBlock(S,s,size);
++ return luaS_newlstr(S->L,s,size-1); /* remove trailing '\0' */
++ }
++}
++
++static void LoadCode(LoadState* S, Proto* f)
++{
++ int n=LoadInt(S);
++ f->code=luaM_newvector(S->L,n,Instruction);
++ f->sizecode=n;
++ LoadVector(S,f->code,n,sizeof(Instruction));
++}
++
++static Proto* LoadFunction(LoadState* S, TString* p);
++
++static void LoadConstants(LoadState* S, Proto* f)
++{
++ int i,n;
++ n=LoadInt(S);
++ f->k=luaM_newvector(S->L,n,TValue);
++ f->sizek=n;
++ for (i=0; i<n; i++) setnilvalue(&f->k[i]);
++ for (i=0; i<n; i++)
++ {
++ TValue* o=&f->k[i];
++ int t=LoadChar(S);
++ switch (t)
++ {
++ case LUA_TNIL:
++ setnilvalue(o);
++ break;
++ case LUA_TBOOLEAN:
++ setbvalue(o,LoadChar(S)!=0);
++ break;
++ case LUA_TNUMBER:
++ setnvalue(o,LoadNumber(S));
++ break;
++ case LUA_TSTRING:
++ setsvalue2n(S->L,o,LoadString(S));
++ break;
++ default:
++ error(S,"bad constant");
++ break;
++ }
++ }
++ n=LoadInt(S);
++ f->p=luaM_newvector(S->L,n,Proto*);
++ f->sizep=n;
++ for (i=0; i<n; i++) f->p[i]=NULL;
++ for (i=0; i<n; i++) f->p[i]=LoadFunction(S,f->source);
++}
++
++static void LoadDebug(LoadState* S, Proto* f)
++{
++ int i,n;
++ n=LoadInt(S);
++ f->lineinfo=luaM_newvector(S->L,n,int);
++ f->sizelineinfo=n;
++ LoadVector(S,f->lineinfo,n,sizeof(int));
++ n=LoadInt(S);
++ f->locvars=luaM_newvector(S->L,n,LocVar);
++ f->sizelocvars=n;
++ for (i=0; i<n; i++) f->locvars[i].varname=NULL;
++ for (i=0; i<n; i++)
++ {
++ f->locvars[i].varname=LoadString(S);
++ f->locvars[i].startpc=LoadInt(S);
++ f->locvars[i].endpc=LoadInt(S);
++ }
++ n=LoadInt(S);
++ f->upvalues=luaM_newvector(S->L,n,TString*);
++ f->sizeupvalues=n;
++ for (i=0; i<n; i++) f->upvalues[i]=NULL;
++ for (i=0; i<n; i++) f->upvalues[i]=LoadString(S);
++}
++
++static Proto* LoadFunction(LoadState* S, TString* p)
++{
++ Proto* f;
++ if (++S->L->nCcalls > LUAI_MAXCCALLS) error(S,"code too deep");
++ f=luaF_newproto(S->L);
++ setptvalue2s(S->L,S->L->top,f); incr_top(S->L);
++ f->source=LoadString(S); if (f->source==NULL) f->source=p;
++ f->linedefined=LoadInt(S);
++ f->lastlinedefined=LoadInt(S);
++ f->nups=LoadByte(S);
++ f->numparams=LoadByte(S);
++ f->is_vararg=LoadByte(S);
++ f->maxstacksize=LoadByte(S);
++ LoadCode(S,f);
++ LoadConstants(S,f);
++ LoadDebug(S,f);
++ IF (!luaG_checkcode(f), "bad code");
++ S->L->top--;
++ S->L->nCcalls--;
++ return f;
++}
++
++static void LoadHeader(LoadState* S)
++{
++ char h[LUAC_HEADERSIZE];
++ char s[LUAC_HEADERSIZE];
++ luaU_header(h);
++ LoadBlock(S,s,LUAC_HEADERSIZE);
++ IF (memcmp(h,s,LUAC_HEADERSIZE)!=0, "bad header");
++}
++
++/*
++** load precompiled chunk
++*/
++Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name)
++{
++ LoadState S;
++ if (*name=='@' || *name=='=')
++ S.name=name+1;
++ else if (*name==LUA_SIGNATURE[0])
++ S.name="binary string";
++ else
++ S.name=name;
++ S.L=L;
++ S.Z=Z;
++ S.b=buff;
++ LoadHeader(&S);
++ return LoadFunction(&S,luaS_newliteral(L,"=?"));
++}
++
++/*
++* make header
++*/
++void luaU_header (char* h)
++{
++ int x=1;
++ memcpy(h,LUA_SIGNATURE,sizeof(LUA_SIGNATURE)-1);
++ h+=sizeof(LUA_SIGNATURE)-1;
++ *h++=(char)LUAC_VERSION;
++ *h++=(char)LUAC_FORMAT;
++ *h++=(char)*(char*)&x; /* endianness */
++ *h++=(char)sizeof(int);
++ *h++=(char)sizeof(size_t);
++ *h++=(char)sizeof(Instruction);
++ *h++=(char)sizeof(lua_Number);
++ *h++=(char)(((lua_Number)0.5)==0); /* is lua_Number integral? */
++}
+--- /dev/null
++++ b/extensions/LUA/lua/lundump.h
+@@ -0,0 +1,36 @@
++/*
++** $Id: lundump.h,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $
++** load precompiled Lua chunks
++** See Copyright Notice in lua.h
++*/
++
++#ifndef lundump_h
++#define lundump_h
++
++#include "lobject.h"
++#include "lzio.h"
++
++/* load one chunk; from lundump.c */
++LUAI_FUNC Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name);
++
++/* make header; from lundump.c */
++LUAI_FUNC void luaU_header (char* h);
++
++/* dump one chunk; from ldump.c */
++LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip);
++
++#ifdef luac_c
++/* print one chunk; from print.c */
++LUAI_FUNC void luaU_print (const Proto* f, int full);
++#endif
++
++/* for header of binary files -- this is Lua 5.1 */
++#define LUAC_VERSION 0x51
++
++/* for header of binary files -- this is the official format */
++#define LUAC_FORMAT 0
++
++/* size of header of binary files */
++#define LUAC_HEADERSIZE 12
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/lvm.c
+@@ -0,0 +1,762 @@
++/*
++** $Id: lvm.c,v 2.63.1.3 2007/12/28 15:32:23 roberto Exp $
++** Lua virtual machine
++** See Copyright Notice in lua.h
++*/
++
++#include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
++
++#define lvm_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "ldebug.h"
++#include "ldo.h"
++#include "lfunc.h"
++#include "lgc.h"
++#include "lobject.h"
++#include "lopcodes.h"
++#include "lstate.h"
++#include "lstring.h"
++#include "ltable.h"
++#include "ltm.h"
++#include "lvm.h"
++
++
++
++/* limit for table tag-method chains (to avoid loops) */
++#define MAXTAGLOOP 100
++
++
++const TValue *luaV_tonumber (const TValue *obj, TValue *n) {
++ lua_Number num;
++ if (ttisnumber(obj)) return obj;
++ if (ttisstring(obj) && luaO_str2d(svalue(obj), &num)) {
++ setnvalue(n, num);
++ return n;
++ }
++ else
++ return NULL;
++}
++
++
++int luaV_tostring (lua_State *L, StkId obj) {
++ if (!ttisnumber(obj))
++ return 0;
++ else {
++ char s[LUAI_MAXNUMBER2STR];
++ lua_Number n = nvalue(obj);
++ lua_number2str(s, n);
++ setsvalue2s(L, obj, luaS_new(L, s));
++ return 1;
++ }
++}
++
++
++static void traceexec (lua_State *L, const Instruction *pc) {
++ lu_byte mask = L->hookmask;
++ const Instruction *oldpc = L->savedpc;
++ L->savedpc = pc;
++ if ((mask & LUA_MASKCOUNT) && L->hookcount == 0) {
++ resethookcount(L);
++ luaD_callhook(L, LUA_HOOKCOUNT, -1);
++ }
++ if (mask & LUA_MASKLINE) {
++ Proto *p = ci_func(L->ci)->l.p;
++ int npc = pcRel(pc, p);
++ int newline = getline(p, npc);
++ /* call linehook when enter a new function, when jump back (loop),
++ or when enter a new line */
++ if (npc == 0 || pc <= oldpc || newline != getline(p, pcRel(oldpc, p)))
++ luaD_callhook(L, LUA_HOOKLINE, newline);
++ }
++}
++
++
++static void callTMres (lua_State *L, StkId res, const TValue *f,
++ const TValue *p1, const TValue *p2) {
++ ptrdiff_t result = savestack(L, res);
++ setobj2s(L, L->top, f); /* push function */
++ setobj2s(L, L->top+1, p1); /* 1st argument */
++ setobj2s(L, L->top+2, p2); /* 2nd argument */
++ luaD_checkstack(L, 3);
++ L->top += 3;
++ luaD_call(L, L->top - 3, 1);
++ res = restorestack(L, result);
++ L->top--;
++ setobjs2s(L, res, L->top);
++}
++
++
++
++static void callTM (lua_State *L, const TValue *f, const TValue *p1,
++ const TValue *p2, const TValue *p3) {
++ setobj2s(L, L->top, f); /* push function */
++ setobj2s(L, L->top+1, p1); /* 1st argument */
++ setobj2s(L, L->top+2, p2); /* 2nd argument */
++ setobj2s(L, L->top+3, p3); /* 3th argument */
++ luaD_checkstack(L, 4);
++ L->top += 4;
++ luaD_call(L, L->top - 4, 0);
++}
++
++
++void luaV_gettable (lua_State *L, const TValue *t, TValue *key, StkId val) {
++ int loop;
++ for (loop = 0; loop < MAXTAGLOOP; loop++) {
++ const TValue *tm;
++ if (ttistable(t)) { /* `t' is a table? */
++ Table *h = hvalue(t);
++ const TValue *res = luaH_get(h, key); /* do a primitive get */
++ if (!ttisnil(res) || /* result is no nil? */
++ (tm = fasttm(L, h->metatable, TM_INDEX)) == NULL) { /* or no TM? */
++ setobj2s(L, val, res);
++ return;
++ }
++ /* else will try the tag method */
++ }
++ else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_INDEX)))
++ luaG_typeerror(L, t, "index");
++ if (ttisfunction(tm)) {
++ callTMres(L, val, tm, t, key);
++ return;
++ }
++ t = tm; /* else repeat with `tm' */
++ }
++ luaG_runerror(L, "loop in gettable");
++}
++
++
++void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val) {
++ int loop;
++ for (loop = 0; loop < MAXTAGLOOP; loop++) {
++ const TValue *tm;
++ if (ttistable(t)) { /* `t' is a table? */
++ Table *h = hvalue(t);
++ TValue *oldval = luaH_set(L, h, key); /* do a primitive set */
++ if (!ttisnil(oldval) || /* result is no nil? */
++ (tm = fasttm(L, h->metatable, TM_NEWINDEX)) == NULL) { /* or no TM? */
++ setobj2t(L, oldval, val);
++ luaC_barriert(L, h, val);
++ return;
++ }
++ /* else will try the tag method */
++ }
++ else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_NEWINDEX)))
++ luaG_typeerror(L, t, "index");
++ if (ttisfunction(tm)) {
++ callTM(L, tm, t, key, val);
++ return;
++ }
++ t = tm; /* else repeat with `tm' */
++ }
++ luaG_runerror(L, "loop in settable");
++}
++
++
++static int call_binTM (lua_State *L, const TValue *p1, const TValue *p2,
++ StkId res, TMS event) {
++ const TValue *tm = luaT_gettmbyobj(L, p1, event); /* try first operand */
++ if (ttisnil(tm))
++ tm = luaT_gettmbyobj(L, p2, event); /* try second operand */
++ if (ttisnil(tm)) return 0;
++ callTMres(L, res, tm, p1, p2);
++ return 1;
++}
++
++
++static const TValue *get_compTM (lua_State *L, Table *mt1, Table *mt2,
++ TMS event) {
++ const TValue *tm1 = fasttm(L, mt1, event);
++ const TValue *tm2;
++ if (tm1 == NULL) return NULL; /* no metamethod */
++ if (mt1 == mt2) return tm1; /* same metatables => same metamethods */
++ tm2 = fasttm(L, mt2, event);
++ if (tm2 == NULL) return NULL; /* no metamethod */
++ if (luaO_rawequalObj(tm1, tm2)) /* same metamethods? */
++ return tm1;
++ return NULL;
++}
++
++
++static int call_orderTM (lua_State *L, const TValue *p1, const TValue *p2,
++ TMS event) {
++ const TValue *tm1 = luaT_gettmbyobj(L, p1, event);
++ const TValue *tm2;
++ if (ttisnil(tm1)) return -1; /* no metamethod? */
++ tm2 = luaT_gettmbyobj(L, p2, event);
++ if (!luaO_rawequalObj(tm1, tm2)) /* different metamethods? */
++ return -1;
++ callTMres(L, L->top, tm1, p1, p2);
++ return !l_isfalse(L->top);
++}
++
++
++static int l_strcmp (const TString *ls, const TString *rs) {
++ const char *l = getstr(ls);
++ size_t ll = ls->tsv.len;
++ const char *r = getstr(rs);
++ size_t lr = rs->tsv.len;
++ for (;;) {
++ int temp = strcoll(l, r);
++ if (temp != 0) return temp;
++ else { /* strings are equal up to a `\0' */
++ size_t len = strlen(l); /* index of first `\0' in both strings */
++ if (len == lr) /* r is finished? */
++ return (len == ll) ? 0 : 1;
++ else if (len == ll) /* l is finished? */
++ return -1; /* l is smaller than r (because r is not finished) */
++ /* both strings longer than `len'; go on comparing (after the `\0') */
++ len++;
++ l += len; ll -= len; r += len; lr -= len;
++ }
++ }
++}
++
++
++int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r) {
++ int res;
++ if (ttype(l) != ttype(r))
++ return luaG_ordererror(L, l, r);
++ else if (ttisnumber(l))
++ return luai_numlt(nvalue(l), nvalue(r));
++ else if (ttisstring(l))
++ return l_strcmp(rawtsvalue(l), rawtsvalue(r)) < 0;
++ else if ((res = call_orderTM(L, l, r, TM_LT)) != -1)
++ return res;
++ return luaG_ordererror(L, l, r);
++}
++
++
++static int lessequal (lua_State *L, const TValue *l, const TValue *r) {
++ int res;
++ if (ttype(l) != ttype(r))
++ return luaG_ordererror(L, l, r);
++ else if (ttisnumber(l))
++ return luai_numle(nvalue(l), nvalue(r));
++ else if (ttisstring(l))
++ return l_strcmp(rawtsvalue(l), rawtsvalue(r)) <= 0;
++ else if ((res = call_orderTM(L, l, r, TM_LE)) != -1) /* first try `le' */
++ return res;
++ else if ((res = call_orderTM(L, r, l, TM_LT)) != -1) /* else try `lt' */
++ return !res;
++ return luaG_ordererror(L, l, r);
++}
++
++
++int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2) {
++ const TValue *tm;
++ lua_assert(ttype(t1) == ttype(t2));
++ switch (ttype(t1)) {
++ case LUA_TNIL: return 1;
++ case LUA_TNUMBER: return luai_numeq(nvalue(t1), nvalue(t2));
++ case LUA_TBOOLEAN: return bvalue(t1) == bvalue(t2); /* true must be 1 !! */
++ case LUA_TLIGHTUSERDATA: return pvalue(t1) == pvalue(t2);
++ case LUA_TUSERDATA: {
++ if (uvalue(t1) == uvalue(t2)) return 1;
++ tm = get_compTM(L, uvalue(t1)->metatable, uvalue(t2)->metatable,
++ TM_EQ);
++ break; /* will try TM */
++ }
++ case LUA_TTABLE: {
++ if (hvalue(t1) == hvalue(t2)) return 1;
++ tm = get_compTM(L, hvalue(t1)->metatable, hvalue(t2)->metatable, TM_EQ);
++ break; /* will try TM */
++ }
++ default: return gcvalue(t1) == gcvalue(t2);
++ }
++ if (tm == NULL) return 0; /* no TM? */
++ callTMres(L, L->top, tm, t1, t2); /* call TM */
++ return !l_isfalse(L->top);
++}
++
++
++void luaV_concat (lua_State *L, int total, int last) {
++ do {
++ StkId top = L->base + last + 1;
++ int n = 2; /* number of elements handled in this pass (at least 2) */
++ if (!(ttisstring(top-2) || ttisnumber(top-2)) || !tostring(L, top-1)) {
++ if (!call_binTM(L, top-2, top-1, top-2, TM_CONCAT))
++ luaG_concaterror(L, top-2, top-1);
++ } else if (tsvalue(top-1)->len == 0) /* second op is empty? */
++ (void)tostring(L, top - 2); /* result is first op (as string) */
++ else {
++ /* at least two string values; get as many as possible */
++ size_t tl = tsvalue(top-1)->len;
++ char *buffer;
++ int i;
++ /* collect total length */
++ for (n = 1; n < total && tostring(L, top-n-1); n++) {
++ size_t l = tsvalue(top-n-1)->len;
++ if (l >= MAX_SIZET - tl) luaG_runerror(L, "string length overflow");
++ tl += l;
++ }
++ buffer = luaZ_openspace(L, &G(L)->buff, tl);
++ tl = 0;
++ for (i=n; i>0; i--) { /* concat all strings */
++ size_t l = tsvalue(top-i)->len;
++ memcpy(buffer+tl, svalue(top-i), l);
++ tl += l;
++ }
++ setsvalue2s(L, top-n, luaS_newlstr(L, buffer, tl));
++ }
++ total -= n-1; /* got `n' strings to create 1 new */
++ last -= n-1;
++ } while (total > 1); /* repeat until only 1 result left */
++}
++
++
++static void Arith (lua_State *L, StkId ra, const TValue *rb,
++ const TValue *rc, TMS op) {
++ TValue tempb, tempc;
++ const TValue *b, *c;
++ if ((b = luaV_tonumber(rb, &tempb)) != NULL &&
++ (c = luaV_tonumber(rc, &tempc)) != NULL) {
++ lua_Number nb = nvalue(b), nc = nvalue(c);
++ switch (op) {
++ case TM_ADD: setnvalue(ra, luai_numadd(nb, nc)); break;
++ case TM_SUB: setnvalue(ra, luai_numsub(nb, nc)); break;
++ case TM_MUL: setnvalue(ra, luai_nummul(nb, nc)); break;
++ case TM_DIV: setnvalue(ra, luai_numdiv(nb, nc)); break;
++ case TM_MOD: setnvalue(ra, luai_nummod(nb, nc)); break;
++ case TM_POW: setnvalue(ra, luai_numpow(nb, nc)); break;
++ case TM_UNM: setnvalue(ra, luai_numunm(nb)); break;
++ default: lua_assert(0); break;
++ }
++ }
++ else if (!call_binTM(L, rb, rc, ra, op))
++ luaG_aritherror(L, rb, rc);
++}
++
++
++
++/*
++** some macros for common tasks in `luaV_execute'
++*/
++
++#define runtime_check(L, c) { if (!(c)) break; }
++
++#define RA(i) (base+GETARG_A(i))
++/* to be used after possible stack reallocation */
++#define RB(i) check_exp(getBMode(GET_OPCODE(i)) == OpArgR, base+GETARG_B(i))
++#define RC(i) check_exp(getCMode(GET_OPCODE(i)) == OpArgR, base+GETARG_C(i))
++#define RKB(i) check_exp(getBMode(GET_OPCODE(i)) == OpArgK, \
++ ISK(GETARG_B(i)) ? k+INDEXK(GETARG_B(i)) : base+GETARG_B(i))
++#define RKC(i) check_exp(getCMode(GET_OPCODE(i)) == OpArgK, \
++ ISK(GETARG_C(i)) ? k+INDEXK(GETARG_C(i)) : base+GETARG_C(i))
++#define KBx(i) check_exp(getBMode(GET_OPCODE(i)) == OpArgK, k+GETARG_Bx(i))
++
++
++#define dojump(L,pc,i) {(pc) += (i); luai_threadyield(L);}
++
++
++#define Protect(x) { L->savedpc = pc; {x;}; base = L->base; }
++
++
++#define arith_op(op,tm) { \
++ TValue *rb = RKB(i); \
++ TValue *rc = RKC(i); \
++ if (ttisnumber(rb) && ttisnumber(rc)) { \
++ lua_Number nb = nvalue(rb), nc = nvalue(rc); \
++ setnvalue(ra, op(nb, nc)); \
++ } \
++ else \
++ Protect(Arith(L, ra, rb, rc, tm)); \
++ }
++
++
++
++void luaV_execute (lua_State *L, int nexeccalls) {
++ LClosure *cl;
++ StkId base;
++ TValue *k;
++ const Instruction *pc;
++ reentry: /* entry point */
++ lua_assert(isLua(L->ci));
++ pc = L->savedpc;
++ cl = &clvalue(L->ci->func)->l;
++ base = L->base;
++ k = cl->p->k;
++ /* main loop of interpreter */
++ for (;;) {
++ const Instruction i = *pc++;
++ StkId ra;
++ if ((L->hookmask & (LUA_MASKLINE | LUA_MASKCOUNT)) &&
++ (--L->hookcount == 0 || L->hookmask & LUA_MASKLINE)) {
++ traceexec(L, pc);
++ if (L->status == LUA_YIELD) { /* did hook yield? */
++ L->savedpc = pc - 1;
++ return;
++ }
++ base = L->base;
++ }
++ /* warning!! several calls may realloc the stack and invalidate `ra' */
++ ra = RA(i);
++ lua_assert(base == L->base && L->base == L->ci->base);
++ lua_assert(base <= L->top && L->top <= L->stack + L->stacksize);
++ lua_assert(L->top == L->ci->top || luaG_checkopenop(i));
++ switch (GET_OPCODE(i)) {
++ case OP_MOVE: {
++ setobjs2s(L, ra, RB(i));
++ continue;
++ }
++ case OP_LOADK: {
++ setobj2s(L, ra, KBx(i));
++ continue;
++ }
++ case OP_LOADBOOL: {
++ setbvalue(ra, GETARG_B(i));
++ if (GETARG_C(i)) pc++; /* skip next instruction (if C) */
++ continue;
++ }
++ case OP_LOADNIL: {
++ TValue *rb = RB(i);
++ do {
++ setnilvalue(rb--);
++ } while (rb >= ra);
++ continue;
++ }
++ case OP_GETUPVAL: {
++ int b = GETARG_B(i);
++ setobj2s(L, ra, cl->upvals[b]->v);
++ continue;
++ }
++ case OP_GETGLOBAL: {
++ TValue g;
++ TValue *rb = KBx(i);
++ sethvalue(L, &g, cl->env);
++ lua_assert(ttisstring(rb));
++ Protect(luaV_gettable(L, &g, rb, ra));
++ continue;
++ }
++ case OP_GETTABLE: {
++ Protect(luaV_gettable(L, RB(i), RKC(i), ra));
++ continue;
++ }
++ case OP_SETGLOBAL: {
++ TValue g;
++ sethvalue(L, &g, cl->env);
++ lua_assert(ttisstring(KBx(i)));
++ Protect(luaV_settable(L, &g, KBx(i), ra));
++ continue;
++ }
++ case OP_SETUPVAL: {
++ UpVal *uv = cl->upvals[GETARG_B(i)];
++ setobj(L, uv->v, ra);
++ luaC_barrier(L, uv, ra);
++ continue;
++ }
++ case OP_SETTABLE: {
++ Protect(luaV_settable(L, ra, RKB(i), RKC(i)));
++ continue;
++ }
++ case OP_NEWTABLE: {
++ int b = GETARG_B(i);
++ int c = GETARG_C(i);
++ sethvalue(L, ra, luaH_new(L, luaO_fb2int(b), luaO_fb2int(c)));
++ Protect(luaC_checkGC(L));
++ continue;
++ }
++ case OP_SELF: {
++ StkId rb = RB(i);
++ setobjs2s(L, ra+1, rb);
++ Protect(luaV_gettable(L, rb, RKC(i), ra));
++ continue;
++ }
++ case OP_ADD: {
++ arith_op(luai_numadd, TM_ADD);
++ continue;
++ }
++ case OP_SUB: {
++ arith_op(luai_numsub, TM_SUB);
++ continue;
++ }
++ case OP_MUL: {
++ arith_op(luai_nummul, TM_MUL);
++ continue;
++ }
++ case OP_DIV: {
++ arith_op(luai_numdiv, TM_DIV);
++ continue;
++ }
++ case OP_MOD: {
++ arith_op(luai_nummod, TM_MOD);
++ continue;
++ }
++ case OP_POW: {
++ arith_op(luai_numpow, TM_POW);
++ continue;
++ }
++ case OP_UNM: {
++ TValue *rb = RB(i);
++ if (ttisnumber(rb)) {
++ lua_Number nb = nvalue(rb);
++ setnvalue(ra, luai_numunm(nb));
++ }
++ else {
++ Protect(Arith(L, ra, rb, rb, TM_UNM));
++ }
++ continue;
++ }
++ case OP_NOT: {
++ int res = l_isfalse(RB(i)); /* next assignment may change this value */
++ setbvalue(ra, res);
++ continue;
++ }
++ case OP_LEN: {
++ const TValue *rb = RB(i);
++ switch (ttype(rb)) {
++ case LUA_TTABLE: {
++ setnvalue(ra, cast_num(luaH_getn(hvalue(rb))));
++ break;
++ }
++ case LUA_TSTRING: {
++ setnvalue(ra, cast_num(tsvalue(rb)->len));
++ break;
++ }
++ default: { /* try metamethod */
++ Protect(
++ if (!call_binTM(L, rb, luaO_nilobject, ra, TM_LEN))
++ luaG_typeerror(L, rb, "get length of");
++ )
++ }
++ }
++ continue;
++ }
++ case OP_CONCAT: {
++ int b = GETARG_B(i);
++ int c = GETARG_C(i);
++ Protect(luaV_concat(L, c-b+1, c); luaC_checkGC(L));
++ setobjs2s(L, RA(i), base+b);
++ continue;
++ }
++ case OP_JMP: {
++ dojump(L, pc, GETARG_sBx(i));
++ continue;
++ }
++ case OP_EQ: {
++ TValue *rb = RKB(i);
++ TValue *rc = RKC(i);
++ Protect(
++ if (equalobj(L, rb, rc) == GETARG_A(i))
++ dojump(L, pc, GETARG_sBx(*pc));
++ )
++ pc++;
++ continue;
++ }
++ case OP_LT: {
++ Protect(
++ if (luaV_lessthan(L, RKB(i), RKC(i)) == GETARG_A(i))
++ dojump(L, pc, GETARG_sBx(*pc));
++ )
++ pc++;
++ continue;
++ }
++ case OP_LE: {
++ Protect(
++ if (lessequal(L, RKB(i), RKC(i)) == GETARG_A(i))
++ dojump(L, pc, GETARG_sBx(*pc));
++ )
++ pc++;
++ continue;
++ }
++ case OP_TEST: {
++ if (l_isfalse(ra) != GETARG_C(i))
++ dojump(L, pc, GETARG_sBx(*pc));
++ pc++;
++ continue;
++ }
++ case OP_TESTSET: {
++ TValue *rb = RB(i);
++ if (l_isfalse(rb) != GETARG_C(i)) {
++ setobjs2s(L, ra, rb);
++ dojump(L, pc, GETARG_sBx(*pc));
++ }
++ pc++;
++ continue;
++ }
++ case OP_CALL: {
++ int b = GETARG_B(i);
++ int nresults = GETARG_C(i) - 1;
++ if (b != 0) L->top = ra+b; /* else previous instruction set top */
++ L->savedpc = pc;
++ switch (luaD_precall(L, ra, nresults)) {
++ case PCRLUA: {
++ nexeccalls++;
++ goto reentry; /* restart luaV_execute over new Lua function */
++ }
++ case PCRC: {
++ /* it was a C function (`precall' called it); adjust results */
++ if (nresults >= 0) L->top = L->ci->top;
++ base = L->base;
++ continue;
++ }
++ default: {
++ return; /* yield */
++ }
++ }
++ }
++ case OP_TAILCALL: {
++ int b = GETARG_B(i);
++ if (b != 0) L->top = ra+b; /* else previous instruction set top */
++ L->savedpc = pc;
++ lua_assert(GETARG_C(i) - 1 == LUA_MULTRET);
++ switch (luaD_precall(L, ra, LUA_MULTRET)) {
++ case PCRLUA: {
++ /* tail call: put new frame in place of previous one */
++ CallInfo *ci = L->ci - 1; /* previous frame */
++ int aux;
++ StkId func = ci->func;
++ StkId pfunc = (ci+1)->func; /* previous function index */
++ if (L->openupval) luaF_close(L, ci->base);
++ L->base = ci->base = ci->func + ((ci+1)->base - pfunc);
++ for (aux = 0; pfunc+aux < L->top; aux++) /* move frame down */
++ setobjs2s(L, func+aux, pfunc+aux);
++ ci->top = L->top = func+aux; /* correct top */
++ lua_assert(L->top == L->base + clvalue(func)->l.p->maxstacksize);
++ ci->savedpc = L->savedpc;
++ ci->tailcalls++; /* one more call lost */
++ L->ci--; /* remove new frame */
++ goto reentry;
++ }
++ case PCRC: { /* it was a C function (`precall' called it) */
++ base = L->base;
++ continue;
++ }
++ default: {
++ return; /* yield */
++ }
++ }
++ }
++ case OP_RETURN: {
++ int b = GETARG_B(i);
++ if (b != 0) L->top = ra+b-1;
++ if (L->openupval) luaF_close(L, base);
++ L->savedpc = pc;
++ b = luaD_poscall(L, ra);
++ if (--nexeccalls == 0) /* was previous function running `here'? */
++ return; /* no: return */
++ else { /* yes: continue its execution */
++ if (b) L->top = L->ci->top;
++ lua_assert(isLua(L->ci));
++ lua_assert(GET_OPCODE(*((L->ci)->savedpc - 1)) == OP_CALL);
++ goto reentry;
++ }
++ }
++ case OP_FORLOOP: {
++ lua_Number step = nvalue(ra+2);
++ lua_Number idx = luai_numadd(nvalue(ra), step); /* increment index */
++ lua_Number limit = nvalue(ra+1);
++ if (luai_numlt(0, step) ? luai_numle(idx, limit)
++ : luai_numle(limit, idx)) {
++ dojump(L, pc, GETARG_sBx(i)); /* jump back */
++ setnvalue(ra, idx); /* update internal index... */
++ setnvalue(ra+3, idx); /* ...and external index */
++ }
++ continue;
++ }
++ case OP_FORPREP: {
++ const TValue *init = ra;
++ const TValue *plimit = ra+1;
++ const TValue *pstep = ra+2;
++ L->savedpc = pc; /* next steps may throw errors */
++ if (!tonumber(init, ra))
++ luaG_runerror(L, LUA_QL("for") " initial value must be a number");
++ else if (!tonumber(plimit, ra+1))
++ luaG_runerror(L, LUA_QL("for") " limit must be a number");
++ else if (!tonumber(pstep, ra+2))
++ luaG_runerror(L, LUA_QL("for") " step must be a number");
++ setnvalue(ra, luai_numsub(nvalue(ra), nvalue(pstep)));
++ dojump(L, pc, GETARG_sBx(i));
++ continue;
++ }
++ case OP_TFORLOOP: {
++ StkId cb = ra + 3; /* call base */
++ setobjs2s(L, cb+2, ra+2);
++ setobjs2s(L, cb+1, ra+1);
++ setobjs2s(L, cb, ra);
++ L->top = cb+3; /* func. + 2 args (state and index) */
++ Protect(luaD_call(L, cb, GETARG_C(i)));
++ L->top = L->ci->top;
++ cb = RA(i) + 3; /* previous call may change the stack */
++ if (!ttisnil(cb)) { /* continue loop? */
++ setobjs2s(L, cb-1, cb); /* save control variable */
++ dojump(L, pc, GETARG_sBx(*pc)); /* jump back */
++ }
++ pc++;
++ continue;
++ }
++ case OP_SETLIST: {
++ int n = GETARG_B(i);
++ int c = GETARG_C(i);
++ int last;
++ Table *h;
++ if (n == 0) {
++ n = cast_int(L->top - ra) - 1;
++ L->top = L->ci->top;
++ }
++ if (c == 0) c = cast_int(*pc++);
++ runtime_check(L, ttistable(ra));
++ h = hvalue(ra);
++ last = ((c-1)*LFIELDS_PER_FLUSH) + n;
++ if (last > h->sizearray) /* needs more space? */
++ luaH_resizearray(L, h, last); /* pre-alloc it at once */
++ for (; n > 0; n--) {
++ TValue *val = ra+n;
++ setobj2t(L, luaH_setnum(L, h, last--), val);
++ luaC_barriert(L, h, val);
++ }
++ continue;
++ }
++ case OP_CLOSE: {
++ luaF_close(L, ra);
++ continue;
++ }
++ case OP_CLOSURE: {
++ Proto *p;
++ Closure *ncl;
++ int nup, j;
++ p = cl->p->p[GETARG_Bx(i)];
++ nup = p->nups;
++ ncl = luaF_newLclosure(L, nup, cl->env);
++ ncl->l.p = p;
++ for (j=0; j<nup; j++, pc++) {
++ if (GET_OPCODE(*pc) == OP_GETUPVAL)
++ ncl->l.upvals[j] = cl->upvals[GETARG_B(*pc)];
++ else {
++ lua_assert(GET_OPCODE(*pc) == OP_MOVE);
++ ncl->l.upvals[j] = luaF_findupval(L, base + GETARG_B(*pc));
++ }
++ }
++ setclvalue(L, ra, ncl);
++ Protect(luaC_checkGC(L));
++ continue;
++ }
++ case OP_VARARG: {
++ int b = GETARG_B(i) - 1;
++ int j;
++ CallInfo *ci = L->ci;
++ int n = cast_int(ci->base - ci->func) - cl->p->numparams - 1;
++ if (b == LUA_MULTRET) {
++ Protect(luaD_checkstack(L, n));
++ ra = RA(i); /* previous call may change the stack */
++ b = n;
++ L->top = ra + n;
++ }
++ for (j = 0; j < b; j++) {
++ if (j < n) {
++ setobjs2s(L, ra + j, ci->base - n + j);
++ }
++ else {
++ setnilvalue(ra + j);
++ }
++ }
++ continue;
++ }
++ }
++ }
++}
++
+--- /dev/null
++++ b/extensions/LUA/lua/lvm.h
+@@ -0,0 +1,36 @@
++/*
++** $Id: lvm.h,v 2.5.1.1 2007/12/27 13:02:25 roberto Exp $
++** Lua virtual machine
++** See Copyright Notice in lua.h
++*/
++
++#ifndef lvm_h
++#define lvm_h
++
++
++#include "ldo.h"
++#include "lobject.h"
++#include "ltm.h"
++
++
++#define tostring(L,o) ((ttype(o) == LUA_TSTRING) || (luaV_tostring(L, o)))
++
++#define tonumber(o,n) (ttype(o) == LUA_TNUMBER || \
++ (((o) = luaV_tonumber(o,n)) != NULL))
++
++#define equalobj(L,o1,o2) \
++ (ttype(o1) == ttype(o2) && luaV_equalval(L, o1, o2))
++
++
++LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r);
++LUAI_FUNC int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2);
++LUAI_FUNC const TValue *luaV_tonumber (const TValue *obj, TValue *n);
++LUAI_FUNC int luaV_tostring (lua_State *L, StkId obj);
++LUAI_FUNC void luaV_gettable (lua_State *L, const TValue *t, TValue *key,
++ StkId val);
++LUAI_FUNC void luaV_settable (lua_State *L, const TValue *t, TValue *key,
++ StkId val);
++LUAI_FUNC void luaV_execute (lua_State *L, int nexeccalls);
++LUAI_FUNC void luaV_concat (lua_State *L, int total, int last);
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/lzio.c
+@@ -0,0 +1,81 @@
++/*
++** $Id: lzio.c,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $
++** a generic input stream interface
++** See Copyright Notice in lua.h
++*/
++
++#include <string.h>
++
++#define lzio_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "llimits.h"
++#include "lmem.h"
++#include "lstate.h"
++#include "lzio.h"
++
++
++int luaZ_fill (ZIO *z) {
++ size_t size;
++ lua_State *L = z->L;
++ const char *buff;
++ lua_unlock(L);
++ buff = z->reader(L, z->data, &size);
++ lua_lock(L);
++ if (buff == NULL || size == 0) return EOZ;
++ z->n = size - 1;
++ z->p = buff;
++ return char2int(*(z->p++));
++}
++
++
++int luaZ_lookahead (ZIO *z) {
++ if (z->n == 0) {
++ if (luaZ_fill(z) == EOZ)
++ return EOZ;
++ else {
++ z->n++; /* luaZ_fill removed first byte; put back it */
++ z->p--;
++ }
++ }
++ return char2int(*z->p);
++}
++
++
++void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) {
++ z->L = L;
++ z->reader = reader;
++ z->data = data;
++ z->n = 0;
++ z->p = NULL;
++}
++
++
++/* --------------------------------------------------------------- read --- */
++size_t luaZ_read (ZIO *z, void *b, size_t n) {
++ while (n) {
++ size_t m;
++ if (luaZ_lookahead(z) == EOZ)
++ return n; /* return number of missing bytes */
++ m = (n <= z->n) ? n : z->n; /* min. between n and z->n */
++ memcpy(b, z->p, m);
++ z->n -= m;
++ z->p += m;
++ b = (char *)b + m;
++ n -= m;
++ }
++ return 0;
++}
++
++/* ------------------------------------------------------------------------ */
++char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n) {
++ if (n > buff->buffsize) {
++ if (n < LUA_MINBUFFER) n = LUA_MINBUFFER;
++ luaZ_resizebuffer(L, buff, n);
++ }
++ return buff->buffer;
++}
++
++
+--- /dev/null
++++ b/extensions/LUA/lua/lzio.h
+@@ -0,0 +1,67 @@
++/*
++** $Id: lzio.h,v 1.21.1.1 2007/12/27 13:02:25 roberto Exp $
++** Buffered streams
++** See Copyright Notice in lua.h
++*/
++
++
++#ifndef lzio_h
++#define lzio_h
++
++#include "lua.h"
++
++#include "lmem.h"
++
++
++#define EOZ (-1) /* end of stream */
++
++typedef struct Zio ZIO;
++
++#define char2int(c) cast(int, cast(unsigned char, (c)))
++
++#define zgetc(z) (((z)->n--)>0 ? char2int(*(z)->p++) : luaZ_fill(z))
++
++typedef struct Mbuffer {
++ char *buffer;
++ size_t n;
++ size_t buffsize;
++} Mbuffer;
++
++#define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0)
++
++#define luaZ_buffer(buff) ((buff)->buffer)
++#define luaZ_sizebuffer(buff) ((buff)->buffsize)
++#define luaZ_bufflen(buff) ((buff)->n)
++
++#define luaZ_resetbuffer(buff) ((buff)->n = 0)
++
++
++#define luaZ_resizebuffer(L, buff, size) \
++ (luaM_reallocvector(L, (buff)->buffer, (buff)->buffsize, size, char), \
++ (buff)->buffsize = size)
++
++#define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0)
++
++
++LUAI_FUNC char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n);
++LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader,
++ void *data);
++LUAI_FUNC size_t luaZ_read (ZIO* z, void* b, size_t n); /* read next n bytes */
++LUAI_FUNC int luaZ_lookahead (ZIO *z);
++
++
++
++/* --------- Private Part ------------------ */
++
++struct Zio {
++ size_t n; /* bytes still unread */
++ const char *p; /* current position in buffer */
++ lua_Reader reader;
++ void* data; /* additional data */
++ lua_State *L; /* Lua state (for reader) */
++};
++
++
++LUAI_FUNC int luaZ_fill (ZIO *z);
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/Makefile
+@@ -0,0 +1,389 @@
++# Makefile.in generated by automake 1.11.1 from Makefile.am.
++# extensions/LUA/Makefile. Generated from Makefile.in by configure.
++
++# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
++# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
++# Inc.
++# This Makefile.in is free software; the Free Software Foundation
++# gives unlimited permission to copy and/or distribute it,
++# with or without modifications, as long as this notice is preserved.
++
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
++# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
++# PARTICULAR PURPOSE.
++
++
++
++# -*- Makefile -*-
++# AUTOMAKE
++
++pkgdatadir = $(datadir)/xtables-addons
++pkgincludedir = $(includedir)/xtables-addons
++pkglibdir = $(libdir)/xtables-addons
++pkglibexecdir = $(libexecdir)/xtables-addons
++am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
++install_sh_DATA = $(install_sh) -c -m 644
++install_sh_PROGRAM = $(install_sh) -c
++install_sh_SCRIPT = $(install_sh) -c
++INSTALL_HEADER = $(INSTALL_DATA)
++transform = $(program_transform_name)
++NORMAL_INSTALL = :
++PRE_INSTALL = :
++POST_INSTALL = :
++NORMAL_UNINSTALL = :
++PRE_UNINSTALL = :
++POST_UNINSTALL = :
++build_triplet = i686-pc-linux-gnu
++host_triplet = i686-pc-linux-gnu
++DIST_COMMON = $(srcdir)/../../Makefile.extra $(srcdir)/Makefile.am \
++ $(srcdir)/Makefile.in
++subdir = extensions/LUA
++ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
++am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
++ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
++ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
++ $(top_srcdir)/configure.ac
++am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
++ $(ACLOCAL_M4)
++mkinstalldirs = $(install_sh) -d
++CONFIG_HEADER = $(top_builddir)/config.h
++CONFIG_CLEAN_FILES =
++CONFIG_CLEAN_VPATH_FILES =
++SOURCES =
++DIST_SOURCES =
++DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
++ACLOCAL = ${SHELL} /home/andre/Dropbox/xtables-addons/missing --run aclocal-1.11
++AMTAR = ${SHELL} /home/andre/Dropbox/xtables-addons/missing --run tar
++AR = ar
++AUTOCONF = ${SHELL} /home/andre/Dropbox/xtables-addons/missing --run autoconf
++AUTOHEADER = ${SHELL} /home/andre/Dropbox/xtables-addons/missing --run autoheader
++AUTOMAKE = ${SHELL} /home/andre/Dropbox/xtables-addons/missing --run automake-1.11
++AWK = mawk
++CC = gcc
++CCDEPMODE = depmode=gcc3
++CFLAGS = -g -O2
++CPP = gcc -E
++CPPFLAGS =
++CYGPATH_W = echo
++DEFS = -DHAVE_CONFIG_H
++DEPDIR = .deps
++DSYMUTIL =
++DUMPBIN =
++ECHO_C =
++ECHO_N = -n
++ECHO_T =
++EGREP = /bin/grep -E
++EXEEXT =
++FGREP = /bin/grep -F
++GREP = /bin/grep
++INSTALL = /usr/bin/install -c
++INSTALL_DATA = ${INSTALL} -m 644
++INSTALL_PROGRAM = ${INSTALL}
++INSTALL_SCRIPT = ${INSTALL}
++INSTALL_STRIP_PROGRAM = $(install_sh) -c -s
++LD = /usr/bin/ld
++LDFLAGS =
++LIBOBJS =
++LIBS =
++LIBTOOL = $(SHELL) $(top_builddir)/libtool
++LIPO =
++LN_S = ln -s
++LTLIBOBJS =
++MAKEINFO = ${SHELL} /home/andre/Dropbox/xtables-addons/missing --run makeinfo
++MKDIR_P = /bin/mkdir -p
++NM = /usr/bin/nm -B
++NMEDIT =
++OBJDUMP = objdump
++OBJEXT = o
++OTOOL =
++OTOOL64 =
++PACKAGE = xtables-addons
++PACKAGE_BUGREPORT =
++PACKAGE_NAME = xtables-addons
++PACKAGE_STRING = xtables-addons 1.21
++PACKAGE_TARNAME = xtables-addons
++PACKAGE_URL =
++PACKAGE_VERSION = 1.21
++PATH_SEPARATOR = :
++PKG_CONFIG = /usr/bin/pkg-config
++RANLIB = ranlib
++SED = /bin/sed
++SET_MAKE =
++SHELL = /bin/bash
++STRIP = strip
++VERSION = 1.21
++abs_builddir = /home/andre/Dropbox/xtables-addons/extensions/LUA
++abs_srcdir = /home/andre/Dropbox/xtables-addons/extensions/LUA
++abs_top_builddir = /home/andre/Dropbox/xtables-addons
++abs_top_srcdir = /home/andre/Dropbox/xtables-addons
++ac_ct_CC = gcc
++ac_ct_DUMPBIN =
++am__include = include
++am__leading_dot = .
++am__quote =
++am__tar = ${AMTAR} chof - "$$tardir"
++am__untar = ${AMTAR} xf -
++bindir = ${exec_prefix}/bin
++build = i686-pc-linux-gnu
++build_alias =
++build_cpu = i686
++build_os = linux-gnu
++build_vendor = pc
++builddir = .
++datadir = ${datarootdir}
++datarootdir = ${prefix}/share
++docdir = ${datarootdir}/doc/${PACKAGE_TARNAME}
++dvidir = ${docdir}
++exec_prefix = ${prefix}
++host = i686-pc-linux-gnu
++host_alias =
++host_cpu = i686
++host_os = linux-gnu
++host_vendor = pc
++htmldir = ${docdir}
++includedir = ${prefix}/include
++infodir = ${datarootdir}/info
++install_sh = ${SHELL} /home/andre/Dropbox/xtables-addons/install-sh
++kbuilddir = /lib/modules/2.6.33-020633-generic/build
++kinclude_CFLAGS = -I /lib/modules/2.6.33-020633-generic/build/include
++ksourcedir =
++libdir = ${exec_prefix}/lib
++libexecdir = ${exec_prefix}/libexec
++libxtables_CFLAGS =
++libxtables_LIBS = -L/lib -lxtables
++localedir = ${datarootdir}/locale
++localstatedir = ${prefix}/var
++lt_ECHO = echo
++mandir = ${datarootdir}/man
++mkdir_p = /bin/mkdir -p
++oldincludedir = /usr/include
++pdfdir = ${docdir}
++prefix = /usr/local
++program_transform_name = s,x,x,
++psdir = ${docdir}
++regular_CFLAGS = -D_LARGEFILE_SOURCE=1 -D_LARGE_FILES -D_FILE_OFFSET_BITS=64 -D_REENTRANT -Wall -Waggregate-return -Wmissing-declarations -Wmissing-prototypes -Wredundant-decls -Wshadow -Wstrict-prototypes -Winline -pipe -DXTABLES_LIBDIR=\"${xtlibdir}\"
++sbindir = ${exec_prefix}/sbin
++sharedstatedir = ${prefix}/com
++srcdir = .
++sysconfdir = ${prefix}/etc
++target_alias =
++top_build_prefix = ../../
++top_builddir = ../..
++top_srcdir = ../..
++xtlibdir = ${libexecdir}/xtables
++XA_SRCDIR = ${srcdir}
++XA_TOPSRCDIR = ${top_srcdir}
++XA_ABSTOPSRCDIR = ${abs_top_srcdir}
++_mcall = -f ${top_builddir}/Makefile.iptrules
++all: all-am
++
++.SUFFIXES:
++$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(srcdir)/../../Makefile.extra $(am__configure_deps)
++ @for dep in $?; do \
++ case '$(am__configure_deps)' in \
++ *$$dep*) \
++ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
++ && { if test -f $@; then exit 0; else break; fi; }; \
++ exit 1;; \
++ esac; \
++ done; \
++ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign extensions/LUA/Makefile'; \
++ $(am__cd) $(top_srcdir) && \
++ $(AUTOMAKE) --foreign extensions/LUA/Makefile
++.PRECIOUS: Makefile
++Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
++ @case '$?' in \
++ *config.status*) \
++ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
++ *) \
++ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
++ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
++ esac;
++
++$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
++ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
++
++$(top_srcdir)/configure: $(am__configure_deps)
++ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
++$(ACLOCAL_M4): $(am__aclocal_m4_deps)
++ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
++$(am__aclocal_m4_deps):
++
++mostlyclean-libtool:
++ -rm -f *.lo
++
++clean-libtool:
++ -rm -rf .libs _libs
++tags: TAGS
++TAGS:
++
++ctags: CTAGS
++CTAGS:
++
++
++distdir: $(DISTFILES)
++ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
++ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
++ list='$(DISTFILES)'; \
++ dist_files=`for file in $$list; do echo $$file; done | \
++ sed -e "s|^$$srcdirstrip/||;t" \
++ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
++ case $$dist_files in \
++ */*) $(MKDIR_P) `echo "$$dist_files" | \
++ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
++ sort -u` ;; \
++ esac; \
++ for file in $$dist_files; do \
++ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
++ if test -d $$d/$$file; then \
++ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
++ if test -d "$(distdir)/$$file"; then \
++ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
++ fi; \
++ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
++ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
++ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
++ fi; \
++ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
++ else \
++ test -f "$(distdir)/$$file" \
++ || cp -p $$d/$$file "$(distdir)/$$file" \
++ || exit 1; \
++ fi; \
++ done
++check-am: all-am
++check: check-am
++all-am: Makefile all-local
++installdirs:
++install: install-am
++install-exec: install-exec-am
++install-data: install-data-am
++uninstall: uninstall-am
++
++install-am: all-am
++ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
++
++installcheck: installcheck-am
++install-strip:
++ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
++ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
++ `test -z '$(STRIP)' || \
++ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
++mostlyclean-generic:
++
++clean-generic:
++
++distclean-generic:
++ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
++ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
++
++maintainer-clean-generic:
++ @echo "This command is intended for maintainers to use"
++ @echo "it deletes files that may require special tools to rebuild."
++clean: clean-am
++
++clean-am: clean-generic clean-libtool clean-local mostlyclean-am
++
++distclean: distclean-am
++ -rm -f Makefile
++distclean-am: clean-am distclean-generic
++
++dvi: dvi-am
++
++dvi-am:
++
++html: html-am
++
++html-am:
++
++info: info-am
++
++info-am:
++
++install-data-am:
++
++install-dvi: install-dvi-am
++
++install-dvi-am:
++
++install-exec-am: install-exec-local
++
++install-html: install-html-am
++
++install-html-am:
++
++install-info: install-info-am
++
++install-info-am:
++
++install-man:
++
++install-pdf: install-pdf-am
++
++install-pdf-am:
++
++install-ps: install-ps-am
++
++install-ps-am:
++
++installcheck-am:
++
++maintainer-clean: maintainer-clean-am
++ -rm -f Makefile
++maintainer-clean-am: distclean-am maintainer-clean-generic
++
++mostlyclean: mostlyclean-am
++
++mostlyclean-am: mostlyclean-generic mostlyclean-libtool
++
++pdf: pdf-am
++
++pdf-am:
++
++ps: ps-am
++
++ps-am:
++
++uninstall-am:
++
++.MAKE: install-am install-strip
++
++.PHONY: all all-am all-local check check-am clean clean-generic \
++ clean-libtool clean-local distclean distclean-generic \
++ distclean-libtool distdir dvi dvi-am html html-am info info-am \
++ install install-am install-data install-data-am install-dvi \
++ install-dvi-am install-exec install-exec-am install-exec-local \
++ install-html install-html-am install-info install-info-am \
++ install-man install-pdf install-pdf-am install-ps \
++ install-ps-am install-strip installcheck installcheck-am \
++ installdirs maintainer-clean maintainer-clean-generic \
++ mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \
++ ps ps-am uninstall uninstall-am
++
++export XA_SRCDIR
++export XA_TOPSRCDIR
++export XA_ABSTOPSRCDIR
++
++all-local: user-all-local
++
++install-exec-local: user-install-local
++
++clean-local: user-clean-local
++
++user-all-local:
++ ${MAKE} ${_mcall} all;
++
++# Have no user-install-data-local ATM
++user-install-local: user-install-exec-local
++
++user-install-exec-local:
++ ${MAKE} ${_mcall} install;
++
++user-clean-local:
++ ${MAKE} ${_mcall} clean;
++
++# Tell versions [3.59,3.63) of GNU make to not export all variables.
++# Otherwise a system limit (for SysV at least) may be exceeded.
++.NOEXPORT:
++
+--- /dev/null
++++ b/extensions/LUA/Makefile.am
+@@ -0,0 +1 @@
++include ../../Makefile.extra
+--- /dev/null
++++ b/extensions/LUA/Makefile.in
+@@ -0,0 +1,389 @@
++# Makefile.in generated by automake 1.11.1 from Makefile.am.
++# @configure_input@
++
++# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
++# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
++# Inc.
++# This Makefile.in is free software; the Free Software Foundation
++# gives unlimited permission to copy and/or distribute it,
++# with or without modifications, as long as this notice is preserved.
++
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
++# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
++# PARTICULAR PURPOSE.
++
++@SET_MAKE@
++
++# -*- Makefile -*-
++# AUTOMAKE
++VPATH = @srcdir@
++pkgdatadir = $(datadir)/@PACKAGE@
++pkgincludedir = $(includedir)/@PACKAGE@
++pkglibdir = $(libdir)/@PACKAGE@
++pkglibexecdir = $(libexecdir)/@PACKAGE@
++am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
++install_sh_DATA = $(install_sh) -c -m 644
++install_sh_PROGRAM = $(install_sh) -c
++install_sh_SCRIPT = $(install_sh) -c
++INSTALL_HEADER = $(INSTALL_DATA)
++transform = $(program_transform_name)
++NORMAL_INSTALL = :
++PRE_INSTALL = :
++POST_INSTALL = :
++NORMAL_UNINSTALL = :
++PRE_UNINSTALL = :
++POST_UNINSTALL = :
++build_triplet = @build@
++host_triplet = @host@
++DIST_COMMON = $(srcdir)/../../Makefile.extra $(srcdir)/Makefile.am \
++ $(srcdir)/Makefile.in
++subdir = extensions/LUA
++ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
++am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
++ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
++ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
++ $(top_srcdir)/configure.ac
++am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
++ $(ACLOCAL_M4)
++mkinstalldirs = $(install_sh) -d
++CONFIG_HEADER = $(top_builddir)/config.h
++CONFIG_CLEAN_FILES =
++CONFIG_CLEAN_VPATH_FILES =
++SOURCES =
++DIST_SOURCES =
++DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
++ACLOCAL = @ACLOCAL@
++AMTAR = @AMTAR@
++AR = @AR@
++AUTOCONF = @AUTOCONF@
++AUTOHEADER = @AUTOHEADER@
++AUTOMAKE = @AUTOMAKE@
++AWK = @AWK@
++CC = @CC@
++CCDEPMODE = @CCDEPMODE@
++CFLAGS = @CFLAGS@
++CPP = @CPP@
++CPPFLAGS = @CPPFLAGS@
++CYGPATH_W = @CYGPATH_W@
++DEFS = @DEFS@
++DEPDIR = @DEPDIR@
++DSYMUTIL = @DSYMUTIL@
++DUMPBIN = @DUMPBIN@
++ECHO_C = @ECHO_C@
++ECHO_N = @ECHO_N@
++ECHO_T = @ECHO_T@
++EGREP = @EGREP@
++EXEEXT = @EXEEXT@
++FGREP = @FGREP@
++GREP = @GREP@
++INSTALL = @INSTALL@
++INSTALL_DATA = @INSTALL_DATA@
++INSTALL_PROGRAM = @INSTALL_PROGRAM@
++INSTALL_SCRIPT = @INSTALL_SCRIPT@
++INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
++LD = @LD@
++LDFLAGS = @LDFLAGS@
++LIBOBJS = @LIBOBJS@
++LIBS = @LIBS@
++LIBTOOL = @LIBTOOL@
++LIPO = @LIPO@
++LN_S = @LN_S@
++LTLIBOBJS = @LTLIBOBJS@
++MAKEINFO = @MAKEINFO@
++MKDIR_P = @MKDIR_P@
++NM = @NM@
++NMEDIT = @NMEDIT@
++OBJDUMP = @OBJDUMP@
++OBJEXT = @OBJEXT@
++OTOOL = @OTOOL@
++OTOOL64 = @OTOOL64@
++PACKAGE = @PACKAGE@
++PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
++PACKAGE_NAME = @PACKAGE_NAME@
++PACKAGE_STRING = @PACKAGE_STRING@
++PACKAGE_TARNAME = @PACKAGE_TARNAME@
++PACKAGE_URL = @PACKAGE_URL@
++PACKAGE_VERSION = @PACKAGE_VERSION@
++PATH_SEPARATOR = @PATH_SEPARATOR@
++PKG_CONFIG = @PKG_CONFIG@
++RANLIB = @RANLIB@
++SED = @SED@
++SET_MAKE = @SET_MAKE@
++SHELL = @SHELL@
++STRIP = @STRIP@
++VERSION = @VERSION@
++abs_builddir = @abs_builddir@
++abs_srcdir = @abs_srcdir@
++abs_top_builddir = @abs_top_builddir@
++abs_top_srcdir = @abs_top_srcdir@
++ac_ct_CC = @ac_ct_CC@
++ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
++am__include = @am__include@
++am__leading_dot = @am__leading_dot@
++am__quote = @am__quote@
++am__tar = @am__tar@
++am__untar = @am__untar@
++bindir = @bindir@
++build = @build@
++build_alias = @build_alias@
++build_cpu = @build_cpu@
++build_os = @build_os@
++build_vendor = @build_vendor@
++builddir = @builddir@
++datadir = @datadir@
++datarootdir = @datarootdir@
++docdir = @docdir@
++dvidir = @dvidir@
++exec_prefix = @exec_prefix@
++host = @host@
++host_alias = @host_alias@
++host_cpu = @host_cpu@
++host_os = @host_os@
++host_vendor = @host_vendor@
++htmldir = @htmldir@
++includedir = @includedir@
++infodir = @infodir@
++install_sh = @install_sh@
++kbuilddir = @kbuilddir@
++kinclude_CFLAGS = @kinclude_CFLAGS@
++ksourcedir = @ksourcedir@
++libdir = @libdir@
++libexecdir = @libexecdir@
++libxtables_CFLAGS = @libxtables_CFLAGS@
++libxtables_LIBS = @libxtables_LIBS@
++localedir = @localedir@
++localstatedir = @localstatedir@
++lt_ECHO = @lt_ECHO@
++mandir = @mandir@
++mkdir_p = @mkdir_p@
++oldincludedir = @oldincludedir@
++pdfdir = @pdfdir@
++prefix = @prefix@
++program_transform_name = @program_transform_name@
++psdir = @psdir@
++regular_CFLAGS = @regular_CFLAGS@
++sbindir = @sbindir@
++sharedstatedir = @sharedstatedir@
++srcdir = @srcdir@
++sysconfdir = @sysconfdir@
++target_alias = @target_alias@
++top_build_prefix = @top_build_prefix@
++top_builddir = @top_builddir@
++top_srcdir = @top_srcdir@
++xtlibdir = @xtlibdir@
++XA_SRCDIR = ${srcdir}
++XA_TOPSRCDIR = ${top_srcdir}
++XA_ABSTOPSRCDIR = ${abs_top_srcdir}
++_mcall = -f ${top_builddir}/Makefile.iptrules
++all: all-am
++
++.SUFFIXES:
++$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(srcdir)/../../Makefile.extra $(am__configure_deps)
++ @for dep in $?; do \
++ case '$(am__configure_deps)' in \
++ *$$dep*) \
++ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
++ && { if test -f $@; then exit 0; else break; fi; }; \
++ exit 1;; \
++ esac; \
++ done; \
++ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign extensions/LUA/Makefile'; \
++ $(am__cd) $(top_srcdir) && \
++ $(AUTOMAKE) --foreign extensions/LUA/Makefile
++.PRECIOUS: Makefile
++Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
++ @case '$?' in \
++ *config.status*) \
++ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
++ *) \
++ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
++ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
++ esac;
++
++$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
++ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
++
++$(top_srcdir)/configure: $(am__configure_deps)
++ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
++$(ACLOCAL_M4): $(am__aclocal_m4_deps)
++ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
++$(am__aclocal_m4_deps):
++
++mostlyclean-libtool:
++ -rm -f *.lo
++
++clean-libtool:
++ -rm -rf .libs _libs
++tags: TAGS
++TAGS:
++
++ctags: CTAGS
++CTAGS:
++
++
++distdir: $(DISTFILES)
++ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
++ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
++ list='$(DISTFILES)'; \
++ dist_files=`for file in $$list; do echo $$file; done | \
++ sed -e "s|^$$srcdirstrip/||;t" \
++ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
++ case $$dist_files in \
++ */*) $(MKDIR_P) `echo "$$dist_files" | \
++ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
++ sort -u` ;; \
++ esac; \
++ for file in $$dist_files; do \
++ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
++ if test -d $$d/$$file; then \
++ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
++ if test -d "$(distdir)/$$file"; then \
++ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
++ fi; \
++ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
++ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
++ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
++ fi; \
++ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
++ else \
++ test -f "$(distdir)/$$file" \
++ || cp -p $$d/$$file "$(distdir)/$$file" \
++ || exit 1; \
++ fi; \
++ done
++check-am: all-am
++check: check-am
++all-am: Makefile all-local
++installdirs:
++install: install-am
++install-exec: install-exec-am
++install-data: install-data-am
++uninstall: uninstall-am
++
++install-am: all-am
++ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
++
++installcheck: installcheck-am
++install-strip:
++ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
++ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
++ `test -z '$(STRIP)' || \
++ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
++mostlyclean-generic:
++
++clean-generic:
++
++distclean-generic:
++ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
++ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
++
++maintainer-clean-generic:
++ @echo "This command is intended for maintainers to use"
++ @echo "it deletes files that may require special tools to rebuild."
++clean: clean-am
++
++clean-am: clean-generic clean-libtool clean-local mostlyclean-am
++
++distclean: distclean-am
++ -rm -f Makefile
++distclean-am: clean-am distclean-generic
++
++dvi: dvi-am
++
++dvi-am:
++
++html: html-am
++
++html-am:
++
++info: info-am
++
++info-am:
++
++install-data-am:
++
++install-dvi: install-dvi-am
++
++install-dvi-am:
++
++install-exec-am: install-exec-local
++
++install-html: install-html-am
++
++install-html-am:
++
++install-info: install-info-am
++
++install-info-am:
++
++install-man:
++
++install-pdf: install-pdf-am
++
++install-pdf-am:
++
++install-ps: install-ps-am
++
++install-ps-am:
++
++installcheck-am:
++
++maintainer-clean: maintainer-clean-am
++ -rm -f Makefile
++maintainer-clean-am: distclean-am maintainer-clean-generic
++
++mostlyclean: mostlyclean-am
++
++mostlyclean-am: mostlyclean-generic mostlyclean-libtool
++
++pdf: pdf-am
++
++pdf-am:
++
++ps: ps-am
++
++ps-am:
++
++uninstall-am:
++
++.MAKE: install-am install-strip
++
++.PHONY: all all-am all-local check check-am clean clean-generic \
++ clean-libtool clean-local distclean distclean-generic \
++ distclean-libtool distdir dvi dvi-am html html-am info info-am \
++ install install-am install-data install-data-am install-dvi \
++ install-dvi-am install-exec install-exec-am install-exec-local \
++ install-html install-html-am install-info install-info-am \
++ install-man install-pdf install-pdf-am install-ps \
++ install-ps-am install-strip installcheck installcheck-am \
++ installdirs maintainer-clean maintainer-clean-generic \
++ mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \
++ ps ps-am uninstall uninstall-am
++
++export XA_SRCDIR
++export XA_TOPSRCDIR
++export XA_ABSTOPSRCDIR
++
++all-local: user-all-local
++
++install-exec-local: user-install-local
++
++clean-local: user-clean-local
++
++user-all-local:
++ ${MAKE} ${_mcall} all;
++
++# Have no user-install-data-local ATM
++user-install-local: user-install-exec-local
++
++user-install-exec-local:
++ ${MAKE} ${_mcall} install;
++
++user-clean-local:
++ ${MAKE} ${_mcall} clean;
++
++# Tell versions [3.59,3.63) of GNU make to not export all variables.
++# Otherwise a system limit (for SysV at least) may be exceeded.
++.NOEXPORT:
++
+--- /dev/null
++++ b/extensions/LUA/Mbuild
+@@ -0,0 +1,3 @@
++# -*- Makefile -*-
++
++obj-${build_LUA} += libxt_LUA.so
+--- /dev/null
++++ b/extensions/LUA/nf_lua.c
+@@ -0,0 +1,64 @@
++#if defined(__KERNEL__)
++
++#include <linux/kernel.h>
++#include <linux/slab.h>
++#include <linux/string.h>
++#include <linux/timer.h>
++#include <linux/random.h>
++#include <linux/netfilter/x_tables.h>
++
++#endif
++
++#include "lua.h"
++#include "lobject.h" /*sizeof(udata) */
++#include "lauxlib.h"
++#include "controller.h"
++
++#if defined(__KERNEL__) /* reachs until luaopen_nflib */
++
++
++static int32_t nf_get_random(lua_State *L)
++{
++ uint32_t rand = 0;
++
++ get_random_bytes(&rand, sizeof(uint32_t ));
++ lua_pushnumber(L, rand);
++ return 1;
++}
++
++static int32_t nf_get_time(lua_State *L)
++{
++ lua_pushnumber(L, jiffies_to_msecs(jiffies_64));
++ return 1;
++}
++
++static const struct luaL_Reg nf_lua_lib_f [] = {
++ { "get_random", nf_get_random },
++ { "get_time", nf_get_time },
++ { NULL, NULL }
++};
++
++void luaopen_nflib(lua_State *L)
++{
++ int32_t top;
++
++ luaL_register(L, NETFILTER_LIB, nf_lua_lib_f);
++ lua_pop(L, 1);
++
++ /* registering verdicts inside the _G */
++ lua_getglobal(L, "_G");
++ top = lua_gettop(L);
++
++ lua_pushinteger(L, XT_CONTINUE);
++ lua_setfield(L, top, "XT_CONTINUE"); /* continiue with next rule */
++
++ lua_pushinteger(L, NF_DROP);
++ lua_setfield(L, top, "NF_DROP"); /* stop traversal in the current table hook and drop packet */
++
++ lua_pushinteger(L, NF_ACCEPT);
++ lua_setfield(L, top, "NF_ACCEPT"); /* stop traversal in the current table hook and accept packet */
++
++ lua_pop(L, 1); /* pop _G */
++}
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/prot_buf_dynamic.c
+@@ -0,0 +1,486 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre@dergraf.org>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++
++#include "controller.h"
++
++
++
++struct protocol_buf * dyn_prot_buf_array[MAX_NR_OF_DYN_PROT_BUFS] = { NULL };
++
++
++/* LUA_API: the function 'field_dynamic_setter' acts as a wrapper around
++ * a given Lua field setter function of a dynamic protocol buffer. The
++ * string containing the lua function name was piggybacked in the 'set'
++ * member of the protocol_field. We call this function passing the actual
++ * segment as byte array and the set value.
++ *
++ * Paramters:
++ * 1. lua_packet_segment (implicit)
++ * 2. some lua value
++ *
++ * Upvalues:
++ * 1. pointer to the protocol buffer
++ * 2. field index
++ *
++ * Returns:
++ * 1. true or false if the 'set' was successful
++ */
++int32_t field_dynamic_setter(lua_State *L)
++{
++ size_t nbytes;
++ lua_packet_segment * array;
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ int32_t field_index = lua_tointeger(L, lua_upvalueindex(2));
++
++ /* the function name is piggybacked as a string */
++ lua_getglobal(L, (char *)prot_buf->protocol_fields[field_index].set);
++ if (!lua_isfunction(L, -1)) {
++ lua_pushboolean(L, 0);
++ return 1;
++ }
++
++ nbytes = sizeof(lua_packet_segment) + seg->length * sizeof(uint8_t);
++ array = (lua_packet_segment *)lua_newuserdata(L, nbytes);
++ array->length = seg->length;
++ array->start = seg->start + seg->offset;
++ array->changes = NULL;
++
++ luaL_getmetatable(L, LUA_BYTE_ARRAY);
++ lua_setmetatable(L, -2);
++ lua_pushvalue(L, 2); /* push value to set */
++ if (lua_pcall(L, 2, 1, 0) != 0) {
++ pr_debug("Error: %s \n", lua_tostring(L, -1));
++ lua_pop(L, 1);
++ lua_pushboolean(L, 0);
++ }
++ return 1;
++}
++
++/* LUA_API: the function 'field_dynamic_getter' acts as a wrapper around
++ * a given Lua field getter function of a dynamic protocol buffer. The
++ * string containing the lua function name was piggybacked in the 'get'
++ * member of the protocol_field. We call this function passing the actual
++ * segment as byte array.
++ *
++ * Paramters:
++ * 1. lua_packet_segment (implicit)
++ *
++ * Upvalues:
++ * 1. pointer to the protocol buffer
++ * 2. field index
++ *
++ * Returns:
++ * 1. true or false if the 'get' was successful
++ */
++int32_t field_dynamic_getter(lua_State *L)
++{
++ size_t nbytes;
++ lua_packet_segment * array;
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ int32_t field_index = lua_tointeger(L, lua_upvalueindex(2));
++
++ /* the function name is piggybacked as a string */
++ lua_getglobal(L, (char *)prot_buf->protocol_fields[field_index].get);
++ if (!lua_isfunction(L, -1)) {
++ lua_pushboolean(L, 0);
++ return 1;
++ }
++
++ nbytes = sizeof(lua_packet_segment) + seg->length * sizeof(uint8_t);
++ array = (lua_packet_segment *)lua_newuserdata(L, nbytes);
++ array->length = seg->length;
++ array->start = seg->start + seg->offset;
++ array->changes = NULL;
++
++ luaL_getmetatable(L, LUA_BYTE_ARRAY);
++ lua_setmetatable(L, -2);
++ if (lua_pcall(L, 1, 1, 0) != 0) {
++ pr_debug("Error: %s \n", luaL_checkstring(L, -1));
++ lua_pop(L, 1);
++ lua_pushboolean(L, 0);
++ }
++ return 1;
++}
++
++/* LUA_API: the function 'has_protocol_dynamic' acts as a wrapper around
++ * a given lua has_protocol function of a dynamic protocol buffer. The
++ * string containing the lua function name was piggybacked in the 'has_protocol'
++ * member of the protocol_buffer. We call this function passing the actual
++ * segment.
++ *
++ * Paramters:
++ * 1. lua_packet_segment
++ * 2. protocol type
++ *
++ * Returns:
++ * 1. true or false if the payload field contains the given protocol
++ */
++int32_t has_protocol_dynamic(lua_State *L, struct protocol_buf * prot_buf, lua_packet_segment * seg, int32_t type)
++{
++ lua_packet_segment *seg_new;
++ int32_t res = 0;
++
++ /* the function name is piggybacked as a string */
++ lua_getglobal(L, (char *)prot_buf->has_protocol);
++ seg_new = (lua_packet_segment *)lua_newuserdata(L, sizeof(lua_packet_segment));
++ seg_new->start = seg->start;
++ seg_new->offset = seg->offset;
++ seg_new->length = seg->length;
++ seg_new->changes = NULL;
++ luaL_getmetatable(L, prot_buf->name);
++ lua_setmetatable(L, -2);
++ lua_pushinteger(L, type); /* push the protocol type */
++ if (lua_pcall(L, 2, 1, 0) != 0) {
++ pr_debug("Error: %s \n", luaL_checkstring(L, -1));
++ lua_pop(L, 1);
++ return 0;
++ }
++ res = lua_toboolean(L, -1);
++ lua_pop(L, 1);
++
++ return res;
++}
++
++/* LUA_API: the function 'get_field_changes_dynamic' acts as a wrapper around
++ * a given lua get_field_changes function of a dynamic protocol buffer. The
++ * string containing the lua function name was piggybacked in the 'get_field_changes'
++ * member of the protocol_buffer. We call this function passing the actual
++ * segment. The lua function must return two lua table containing the offset
++ * and length changes (in bits).
++ *
++ * Paramters:
++ * 1. lua_packet_segment
++ *
++ * Returns:
++ * 1. new allocated field_changes struct
++ */
++struct field_changes * get_field_changes_dynamic(lua_State *L, struct protocol_buf *prot_buf, lua_packet_segment * seg)
++{
++ lua_packet_segment *seg_new;
++ struct field_changes * changes;
++ int32_t nr_of_changes, i;
++
++ lua_getglobal(L, (char *)prot_buf->get_field_changes);
++
++ seg_new = (lua_packet_segment *)lua_newuserdata(L, sizeof(lua_packet_segment));
++ seg_new->start = seg->start;
++ seg_new->offset = seg->offset;
++ seg_new->length = seg->length;
++ seg_new->changes = NULL;
++ luaL_getmetatable(L, prot_buf->name);
++ lua_setmetatable(L, -2);
++
++ if (lua_pcall(L, 1, 2, 0) != 0)
++ luaL_error(L, "inside get_field_changes_dynamic. %s\n", lua_tostring(L, -1));
++
++ /* the function call must return a table containing length changes */
++ luaL_checktype(L, -1, LUA_TTABLE);
++ /* the function call must return a table containing offset changes */
++ luaL_checktype(L, -2, LUA_TTABLE);
++ /* both tables have to be of same size */
++ if (lua_objlen(L, -1) != lua_objlen(L, -2))
++ luaL_error(L, "the provided tables are not of equal size");
++
++ nr_of_changes = lua_objlen(L, -1);
++ changes = get_allocated_field_changes(L, nr_of_changes);
++
++ /* loop over the tables */
++ for (i = 1; i < nr_of_changes; i++) {
++ lua_rawgeti(L, -1, i); /* push length value of field at index i */
++ changes->field_length_changes[i - 1] = luaL_checkinteger(L, -1);
++ lua_pop(L, 1); /* pop offset value */
++
++ lua_rawgeti(L, -2, i); /* push offset value of field at index i */
++ changes->field_offset_changes[i - 1] = luaL_checkinteger(L, -1);
++ lua_pop(L, 1); /* pop length value */
++ }
++
++ /* pop both tables */
++ lua_pop(L, 2);
++
++ return changes;
++}
++
++/* C_INT: 'get_free_protocol_index' is only used internally. This function
++ * gets a free slot inside the array holding all the protocol buffers.
++ * There are several ways to get to this information. In this case I take
++ * the way over the reflected array SUPPORTED_PROTOCOL_TABLE inside the
++ * Lua state. Since this function is called at laodtime, we do not have
++ * to care about performance.
++ */
++static int32_t get_free_protocol_index(lua_State *L)
++{
++ int32_t protocol_index;
++
++ lua_getglobal(L, SUPPORTED_PROTOCOL_TABLE);
++ protocol_index = lua_objlen(L, -1) + 1;
++ lua_pop(L, 1);
++ return protocol_index;
++}
++
++/* C_API: 'free_dynamic_prot_buf' frees the allocated memory of a given
++ * dynamic protocol buffer. this function is normally called inside a
++ * cleanup routine. Be aware, before running this function you must be
++ * sure that no references to the dynamic protocol buffers were available.
++ * It's recomended to close the Lua state before calling the function. */
++void free_dynamic_prot_buf(struct protocol_buf * prot_buf)
++{
++ struct protocol_field * field = prot_buf->protocol_fields;
++
++ for (; field->name != NULL; field++) {
++ if (field->get) kfree(field->get);
++ if (field->set) kfree(field->set);
++ if (field->name) kfree((char *)field->name);
++ }
++
++ if (prot_buf->payload_field) kfree(prot_buf->payload_field);
++ if (prot_buf->has_protocol) kfree(prot_buf->has_protocol);
++
++ if (prot_buf->get_field_changes) kfree(prot_buf->get_field_changes);
++ kfree((char *)prot_buf->name);
++ kfree(prot_buf);
++ return;
++}
++
++void cleanup_dynamic_prot_bufs(void)
++{
++ int32_t i;
++
++ for (i = 0; i < MAX_NR_OF_DYN_PROT_BUFS; i++) {
++ if (dyn_prot_buf_array[i]) {
++ free_dynamic_prot_buf(dyn_prot_buf_array[i]);
++ dyn_prot_buf_array[i] = NULL;
++ }
++ }
++ return;
++}
++
++
++/* C_INT: 'free_protocol_fields' is used internally as a helper function for
++ * 'register_dynamic_protbuf'. It is used when durin registration an error
++ * occurs and the afore allocated fields needed to be freed. */
++static inline void free_protocol_fields(struct protocol_field * prot_fields, int32_t i)
++{
++ struct protocol_field * f;
++
++ while (i >= 0) {
++ f = &prot_fields[i];
++ if (f->name) kfree((void *)f->name);
++ if (f->get) kfree((void *)f->get);
++ if (f->set) kfree((void *)f->set);
++ kfree((void *)f);
++ i--;
++ }
++}
++
++/* LUA_API: 'register_dynamic_protbuf' is called from within the Lua script.
++ * it takes a Lua table representing the dynamic protocol buffer as parameter.
++ * e.g.:
++ * eth_prot_buf = {
++ * name = "packet_eth_dyn",
++ * payload_field = "data",
++ * protocol_fields = {
++ * {"dmac", 0, 48, nil, nil },
++ * {"smac", 48, 48, nil, nil },
++ * {"type", 96, 16, nil, nil },
++ * {"data", 112, 0, nil, nil },
++ * },
++ * has_protocol = "eth_dyn_has_protocol",
++ * get_field_changes = "eth_dyn_get_field_changes"
++ * }
++ * register_dynamic_protbuf(eth_prot_buf)
++ *
++ * the table gets parsed and a new protocol_buf struct is allocated and
++ * initialized using 'register_protbuf', which is also used for the static
++ * protocol buffers. This enables an identical behavior like the static
++ * protocol buffers. The dynamic protocol buffers are not garbage collected,
++ * use 'free_dynamic_protbuf' to free them after closing the Lua state.
++ */
++static int32_t register_dynamic_protbuf(lua_State *L)
++{
++ struct protocol_buf *prot_buf;
++ struct protocol_field *field, sentinel = PROT_FIELD_SENTINEL;
++ int32_t nr_of_fields, i;
++
++ prot_buf = (struct protocol_buf *)kmalloc(sizeof(struct protocol_buf), GFP_KERNEL);
++ prot_buf->is_dynamic = 1;
++
++ /* check if parameter is a table */
++ luaL_checktype(L, 1, LUA_TTABLE);
++
++ /* initialize prot_buf.name */
++ lua_getfield(L, 1, "name");
++ prot_buf->name = kmalloc(lua_objlen(L, -1), GFP_KERNEL);
++ strcpy((char *)prot_buf->name, luaL_checkstring(L, -1));
++ lua_pop(L, 1); /* pop res from lua_getfield */
++
++ /* check if protocol buffer is already registered */
++ lua_getglobal(L, prot_buf->name);
++ if (!lua_isnil(L, -1)) {
++ lua_pop(L, 1); /* pop res from lua_getglobal */
++ pr_debug("protocol_buf '%s' already registered.\n", prot_buf->name);
++ goto free_prot_buf;
++ }
++ lua_pop(L, 1); /* pop res from lua_getglobal */
++
++ /* initialize payload field */
++ lua_getfield(L, 1, "payload_field");
++ if (lua_isstring(L, -1)) {
++ prot_buf->payload_field = kmalloc(lua_objlen(L, -1), GFP_KERNEL);
++ strcpy(prot_buf->payload_field, lua_tostring(L, -1));
++ }else
++ prot_buf->payload_field = NULL;
++ lua_pop(L, 1); /* pop res from lua_getfield */
++
++ /* initialize protocol_fields field*/
++ lua_getfield(L, 1, "protocol_fields");
++ if (!lua_istable(L, -1)) {
++ pr_debug("invalid protocol_fields table.\n");
++ goto err2;
++
++ }
++
++ nr_of_fields = lua_objlen(L, -1);
++ prot_buf->protocol_fields = (struct protocol_field *)kmalloc((nr_of_fields + 1) * sizeof(struct protocol_field), GFP_KERNEL);
++
++ for (i = 1; i <= nr_of_fields; i++) {
++ field = &prot_buf->protocol_fields[i - 1];
++ /* initialize protocol field */
++ lua_rawgeti(L, -1, i); /* push field-table */
++ if (!lua_istable(L, -1)) {
++ free_protocol_fields(prot_buf->protocol_fields, i);
++ pr_debug("invalid protocol_field at %i.\n", i);
++ goto err;
++ }
++
++ /* initialize protocol field name */
++ lua_rawgeti(L, -1, 1);
++ if (!lua_isstring(L, -1)) {
++ free_protocol_fields(prot_buf->protocol_fields, i);
++ pr_debug("invalid protocol_field name at %i.\n", i);
++ goto err;
++ }
++
++ field->name = kmalloc(lua_objlen(L, -1), GFP_KERNEL);
++ strcpy((char*)field->name, lua_tostring(L, -1));
++ lua_pop(L, 1); /* pop field name */
++
++ /* initialize protocol field offset */
++ lua_rawgeti(L, -1, 2);
++ if (!lua_isnumber(L, -1)) {
++ free_protocol_fields(prot_buf->protocol_fields, i);
++ pr_debug("invalid protocol_field offset at %i.\n", i);
++ goto err;
++ }
++ field->offset = lua_tointeger(L, -1);
++ lua_pop(L, 1); /* pop field offset */
++
++ /* initialize protocol field length */
++ lua_rawgeti(L, -1, 3);
++ if (!lua_isnumber(L, -1)) {
++ free_protocol_fields(prot_buf->protocol_fields, i);
++ pr_debug("invalid protocol_field length at %i.\n", i);
++ goto err;
++ }
++ field->length = lua_tointeger(L, -1);
++ lua_pop(L, 1); /* pop field length */
++
++ /* initialize protocol field getter */
++ lua_rawgeti(L, -1, 4);
++ if (lua_isstring(L, -1)) {
++ field->get = kmalloc(lua_objlen(L, -1), GFP_KERNEL);
++ strcpy((char *)field->get, lua_tostring(L, -1)); /* the get-wrapper knows about the piggybacked string */
++ }else
++ field->get = NULL;
++ lua_pop(L, 1); /* pop field getter */
++
++ /* initialize protocol field setter */
++ lua_rawgeti(L, -1, 5);
++ if (lua_isstring(L, -1)) {
++ field->set = kmalloc(lua_objlen(L, -1), GFP_KERNEL);
++ strcpy((char *)field->set, lua_tostring(L, -1)); /* the set-wrapper knows about the piggybacked string */
++ }else
++ field->set = NULL;
++ lua_pop(L, 1); /* pop field setter */
++
++ /* field initialization completed */
++ lua_pop(L, 1); /* pop field-table */
++ }
++
++ /* put sentinel at the end of protocol_fields */
++ memcpy(&prot_buf->protocol_fields[nr_of_fields], &sentinel, sizeof(sentinel));
++ lua_pop(L, 1); /* pop protocol-fields-table */
++
++ /* initialize has_protocol field */
++ lua_getfield(L, 1, "has_protocol");
++ if (lua_isstring(L, -1)) {
++ prot_buf->has_protocol = kmalloc(lua_objlen(L, -1), GFP_KERNEL);
++ strcpy((char *)prot_buf->has_protocol, lua_tostring(L, -1)); /* the has_protocol-wrapper knows about the piggybacked string */
++ }else
++ prot_buf->has_protocol = NULL;
++ lua_pop(L, 1); /* pop has_protocol */
++
++ /* initialize get_field_changes field */
++ lua_getfield(L, 1, "get_field_changes");
++ if (lua_isstring(L, -1)) {
++ prot_buf->get_field_changes = kmalloc(lua_objlen(L, -1), GFP_KERNEL);
++ strcpy((char *)prot_buf->get_field_changes, lua_tostring(L, -1)); /* the get_field_changes-wrapper knows about the piggybacked string */
++ }else
++ prot_buf->get_field_changes = NULL;
++ lua_pop(L, 1); /* pop get_field_changes */
++
++ /* Storing the pointer to the DYNAMIC protbuf within dyn_prot_buf_array, in order to free it at cleanup */
++ for (i = 0; i < MAX_NR_OF_DYN_PROT_BUFS; i++) {
++ if (!dyn_prot_buf_array[i]) {
++ dyn_prot_buf_array[i] = prot_buf;
++ break;
++ }else
++ goto err;
++ }
++
++ /* call the "common" register_protbuf */
++ register_protbuf(L, prot_buf, get_free_protocol_index(L)); /* register prot_buf as it is done with the static ones */
++
++ return 0;
++
++err:
++ kfree(prot_buf->protocol_fields);
++err2:
++ if (prot_buf->payload_field) kfree(prot_buf->payload_field);
++free_prot_buf:
++ kfree((void *)prot_buf->name);
++ kfree(prot_buf);
++
++ luaL_error(L, "one or more error happend while registering a dynamic protocol buffer, please consult the debug log");
++
++ return 0;
++
++}
++
++void luaopen_protbuf_dynamic(lua_State *L)
++{
++ lua_getglobal(L, "_G");
++ lua_pushcclosure(L, register_dynamic_protbuf, 0);
++ lua_setfield(L, -2, "register_dynamic_protbuf");
++ lua_pop(L, 1); /* pop _G */
++ return;
++}
+--- /dev/null
++++ b/extensions/LUA/prot_buf_ethernet.c
+@@ -0,0 +1,60 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre@dergraf.org>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++
++#include "controller.h"
++
++
++static int32_t eth_has_protocol(lua_State *L, struct protocol_buf * prot_buf, lua_packet_segment * seg, int32_t protocol_type)
++{
++ uint8_t *embedded_protocol = seg->start + seg->offset + 12 /*bytes*/;
++ unsigned short res = (unsigned short)((embedded_protocol[1] << CHAR_BIT) | (embedded_protocol[0] << CHAR_BIT));
++
++ switch (res) {
++ case 0x0800: /* 1: Internet Protocol (IP) */
++ if (protocol_type == PACKET_IP) return 1;
++ break;
++ default:
++ return 0;
++ }
++
++ return 0;
++}
++
++static const struct protocol_field eth_protocol_fields[] = {
++ /* field name offset length getter setter */
++ { "dmac", 0, 48, NULL, NULL },
++ { "smac", 48, 48, NULL, NULL },
++ { "type", 96, 16, NULL, NULL },
++ { "data", 112, 0, NULL, NULL },
++ PROT_FIELD_SENTINEL,
++};
++
++static const struct protocol_buf eth_protocol_buf = {
++ .is_dynamic = 0,
++ .name = LUA_PACKET_SEG_ETH,
++ .payload_field = "data",
++ .protocol_fields = (struct protocol_field *)&eth_protocol_fields,
++ .has_protocol = &eth_has_protocol,
++ .get_field_changes = NULL,
++};
++
++
++void luaopen_protbuf_eth(lua_State *L)
++{
++ register_protbuf(L, (struct protocol_buf *)&eth_protocol_buf, PACKET_ETH);
++}
+--- /dev/null
++++ b/extensions/LUA/prot_buf_helpers.c
+@@ -0,0 +1,216 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre@dergraf.org>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++
++#if defined(__KERNEL__)
++#include <linux/netfilter_ipv4.h>
++#include <linux/slab.h> /* kmalloc */
++#endif
++
++#include "controller.h"
++
++int32_t get_header_size(struct protocol_buf * prot_buf)
++{
++ int32_t bit_counter = 0;
++ struct protocol_field * field = prot_buf->protocol_fields;
++
++ for (; field->name; field++)
++ bit_counter += field->length;
++
++ return bit_counter >> 3;
++}
++
++
++int32_t set_32_bit_generic(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ *(uint32_t *)(seg->start + seg->offset) = (uint32_t )htonl(luaL_checkinteger(L, 2));
++ return 0;
++}
++int32_t get_32_bit_generic(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ lua_pushinteger(L, ntohl(*((uint32_t *)(seg->start + seg->offset))));
++ return 1;
++}
++
++int32_t set_16_bit_generic(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ *(uint16_t *)(seg->start + seg->offset) = (uint16_t)htons(luaL_checkinteger(L, 2));
++ return 0;
++}
++int32_t get_16_bit_generic(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ lua_pushinteger(L, ntohs(*((uint16_t *)(seg->start + seg->offset))));
++ return 1;
++}
++
++int32_t set_lower_4_bit_generic(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++ uint8_t b = (uint8_t)luaL_checkinteger(L, 2) << 4;
++ uint8_t * pos = (uint8_t *)(seg->start + seg->offset);
++
++ *pos &= 0x0F; /* reset lower 4 bits*/
++ *pos |= b;
++
++ return 0;
++}
++
++int32_t get_lower_4_bit_generic(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ lua_pushinteger(L, (*(uint8_t *)(seg->start + seg->offset)) >> 4);
++ return 1;
++}
++
++int32_t set_upper_4_bit_generic(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++ uint8_t b = (uint8_t)luaL_checkinteger(L, 2) << 4;
++ uint8_t * pos = (uint8_t *)(seg->start + seg->offset);
++
++ *pos &= 0xF0; /* reset upper 4 bits*/
++ *pos |= (b >> 4);
++
++ return 0;
++}
++
++int32_t get_upper_4_bit_generic(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ lua_pushinteger(L, (*(uint8_t *)(seg->start + seg->offset)) & 0x0F);
++ return 1;
++}
++
++
++int32_t set_8_bit_generic(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ *(uint8_t *)(seg->start + seg->offset) = (uint8_t)luaL_checkinteger(L, 2);
++ return 0;
++}
++
++int32_t get_8_bit_generic(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ lua_pushinteger(L, *(uint8_t *)(seg->start + seg->offset));
++ return 1;
++}
++
++int32_t set_1_bit_generic(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++ unsigned long l = 0;
++
++ memcpy(&l, (seg->start + seg->offset), seg->length);
++ l |= (1 << ((CHAR_BIT * seg->length) - luaL_checkinteger(L, 2)));
++ memcpy((seg->start + seg->offset), &l, seg->length);
++
++ return 0;
++}
++
++int32_t get_1_bit_generic(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++ unsigned long l = 0;
++ uint32_t bit = 0;
++
++ memcpy(&l, (seg->start + seg->offset), seg->length);
++ bit = l & (1 << ((CHAR_BIT * seg->length) - luaL_checkinteger(L, 2)));
++
++ lua_pushboolean(L, bit);
++ return 1;
++}
++
++int32_t get_string_generic(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ /* Warning we cast from uchar to char */
++ lua_pushlstring(L, (char *)seg->start + seg->offset, seg->length);
++ return 1;
++}
++
++int32_t set_data_generic(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++ lua_packet_segment * data = checkbytearray(L, 2);
++
++ pr_debug("seg->length %u, data->length %u\n", seg->length, data->length);
++
++ if (seg->length >= data->length)
++ memcpy((seg->start + seg->offset), data->start, data->length);
++ else
++ luaL_error(L, "provided byte array too big for given packet segment");
++ return 0;
++}
++
++struct field_changes * get_allocated_field_changes(lua_State *L, int32_t nr_of_fields)
++{
++ struct field_changes * changes;
++
++ changes = kmalloc(sizeof(struct field_changes), GFP_ATOMIC);
++
++ if (!changes)
++ goto failure;
++
++ changes->field_length_changes = kmalloc(nr_of_fields * sizeof(int), GFP_ATOMIC);
++ if (!changes->field_length_changes)
++ goto free1;
++
++ changes->field_offset_changes = kmalloc(nr_of_fields * sizeof(int), GFP_ATOMIC);
++ if (!changes->field_offset_changes)
++ goto free2;
++
++ memset(changes->field_length_changes, 0, nr_of_fields * sizeof(int));
++ memset(changes->field_offset_changes, 0, nr_of_fields * sizeof(int));
++
++ changes->ref_count = 1;
++
++ return changes;
++
++free2: kfree(changes->field_length_changes);
++free1: kfree(changes);
++failure:
++ if (!changes) luaL_error(L, "couldnt allocate memory inside 'get_allocated_field_changes'");
++ return NULL; /* only to omit warnings */
++}
+\ No newline at end of file
+--- /dev/null
++++ b/extensions/LUA/prot_buf_icmp.c
+@@ -0,0 +1,49 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre@dergraf.org>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++
++#include "controller.h"
++
++static int32_t icmp_has_protocol(lua_State *L, struct protocol_buf * prot_buf, lua_packet_segment * seg, int32_t protocol_type)
++{
++ return 0;
++}
++
++static const struct protocol_field icmp_protocol_fields[] = {
++ /* field name offset length getter setter */
++ { "type", 0, 8, NULL, NULL },
++ { "code", 8, 8, NULL, NULL },
++ { "checksum", 16, 16, NULL, NULL },
++ { "id", 32, 16, NULL, NULL },
++ { "sequence", 48, 16, NULL, NULL },
++ PROT_FIELD_SENTINEL,
++};
++
++static const struct protocol_buf icmp_protocol_buf = {
++ .is_dynamic = 0,
++ .name = LUA_PACKET_SEG_ICMP,
++ .payload_field = NULL,
++ .protocol_fields = (struct protocol_field *)&icmp_protocol_fields,
++ .has_protocol = &icmp_has_protocol,
++ .get_field_changes = NULL,
++};
++
++void luaopen_protbuf_icmp(lua_State *L)
++{
++ register_protbuf(L, (struct protocol_buf *)&icmp_protocol_buf, PACKET_ICMP);
++}
++
+--- /dev/null
++++ b/extensions/LUA/prot_buf_ip.c
+@@ -0,0 +1,209 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre@dergraf.org>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++
++#if defined(__KERNEL__)
++ #include <net/checksum.h>
++ #include <net/tcp.h>
++#endif
++
++#include "controller.h"
++
++
++#define IP_FMT "%u.%u.%u.%u"
++#define IP_ACC(buf) buf[0], buf[1], buf[2], buf[3]
++
++
++static int32_t ip_version_set(lua_State *L)
++{
++ uint8_t version_checked;
++ lua_packet_segment * seg = checkpacketseg(L, 1, LUA_PACKET_SEG_IP);
++ uint8_t *version_seg = seg->start + seg->offset;
++ int32_t version = luaL_checkinteger(L, 2);
++
++ luaL_argcheck(L, version >= 0 && version <= 15, 1, "version number invalid");
++
++ version_checked = (uint8_t)version;
++
++ version_seg[0] &= (uint8_t)0x0F; /* reset version bits */
++ version_seg[0] |= version_checked << 4;
++
++ return 0;
++}
++static int32_t ip_version_get(lua_State *L)
++{
++ lua_packet_segment * seg = checkpacketseg(L, 1, LUA_PACKET_SEG_IP);
++ uint8_t *version_seg = seg->start + seg->offset;
++ uint8_t v = version_seg[0] & 0xF0;
++
++ v >>= 4;
++
++ lua_pushinteger(L, v);
++ return 1;
++}
++
++static int32_t ip_ihl_set(lua_State *L)
++{
++ uint8_t ihl_checked;
++ lua_packet_segment * seg = checkpacketseg(L, 1, LUA_PACKET_SEG_IP);
++ uint8_t *ihl_seg = seg->start + seg->offset;
++ int32_t ihl = luaL_checkinteger(L, 2);
++
++ luaL_argcheck(L, ihl >= 5 && ihl <= 15, 1, "ip header length invalid"); // RFC 791 5x32 = 160 bits
++
++ ihl_checked = (uint8_t)ihl;
++
++ ihl_seg[0] &= (uint8_t)0xF0; /* reset ihl bits */
++ ihl_seg[0] |= ihl_checked;
++
++ return 0;
++}
++static int32_t ip_ihl_get(lua_State *L)
++{
++ lua_packet_segment * seg = checkpacketseg(L, 1, LUA_PACKET_SEG_IP);
++ uint8_t *ihl_seg = seg->start + seg->offset;
++ uint8_t v = ihl_seg[0] & 0x0F;
++
++ lua_pushinteger(L, v);
++ return 1;
++}
++
++static int32_t ip_addr_set(lua_State *L)
++{
++ int32_t field_id = lua_tointeger(L, lua_upvalueindex(2));
++ lua_packet_segment * seg = checkpacketseg(L, 1, LUA_PACKET_SEG_IP);
++ uint8_t *addr_seg = seg->start + seg->offset;
++ uint32_t old_addr;
++ char *ip = (char *)luaL_checkstring(L, 2);
++ uint32_t a, b, c, d;
++ struct sk_buff * skb = (struct sk_buff *)lua_touserdata(L, 3);
++
++ /* for tcp / udp checksumming*/
++ uint32_t prot_offset;
++ uint8_t *check, *protocol_seg;
++
++ /* end */
++
++ sscanf(ip, IP_FMT, &a, &b, &c, &d);
++
++ luaL_argcheck(L, a < 256 && b < 256 && c < 256 && d < 256, 1, "invalid ip addr");
++
++ old_addr = *((uint32_t *)addr_seg);
++ addr_seg[0] = (uint8_t)a;
++ addr_seg[1] = (uint8_t)b;
++ addr_seg[2] = (uint8_t)c;
++ addr_seg[3] = (uint8_t)d;
++
++#if defined(__KERNEL__)
++ if (old_addr != *(uint32_t *)addr_seg) {
++ int32_t offset = (field_id == 10) ? -2 : -6; /* offset from saddr or daddr */
++
++ csum_replace4((uint16_t *)(addr_seg + offset), old_addr, *(uint32_t *)addr_seg);
++
++ prot_offset = (field_id == 10) ? -3 : -7; /* offset from saddr or daddr */
++ protocol_seg = seg->start + seg->offset + prot_offset;
++
++ if (skb && (protocol_seg[0] == 0x06 || protocol_seg[0] == 0x11)) { /* is payload TCP or UDP ? */
++
++ check = seg->start + seg->offset; /* tmp res */
++ check += (field_id == 10) ? 8 : 16; /* the start of the payload, depending saddr or daddr */
++ check += (protocol_seg[0] == 0x06) ? 16 : 6; /* the start of the checksum, depending on TCP or UDP */
++
++ inet_proto_csum_replace4((__sum16 *)check, skb, old_addr, *(uint32_t *)addr_seg, 1);
++
++ lua_pop(L, 1);
++ }
++ }
++#endif
++ return 0;
++}
++
++
++
++
++
++static int32_t ip_addr_get(lua_State *L)
++{
++ lua_packet_segment * seg = checkpacketseg(L, 1, LUA_PACKET_SEG_IP);
++ uint8_t *addr_seg = seg->start + seg->offset;
++
++ char buf[16]; /*max: 255.255.255.255\0 --> 16 chars */
++
++ sprintf(buf, IP_FMT, IP_ACC(addr_seg));
++ lua_pushstring(L, buf);
++ return 1;
++}
++
++static int32_t ip_has_protocol(lua_State *L, struct protocol_buf * prot_buf, lua_packet_segment * seg, int32_t protocol_type)
++{
++ uint8_t * embedded_protocol = seg->start + seg->offset + 9 /*bytes*/;
++
++ switch (embedded_protocol[0]) {
++ case 0x01: /* 1: Internet Control Message Protocol (ICMP) */
++ if (protocol_type == PACKET_ICMP) return 1;
++ break;
++ case 0x02: /* 2: Internet Group Management Protocol (IGMP) */
++ break;
++ case 0x06: /* 6: Transmission Control Protocol (TCP) */
++ if (protocol_type == PACKET_TCP) return 1;
++ break;
++ case 0x11: /* 17: User Datagram Protocol (UDP) */
++ if (protocol_type == PACKET_UDP) return 1;
++ break;
++ case 0x59: /* 89: Open Shortest Path First (OSPF) */
++ break;
++ case 0x84: /* 132: Stream Control Transmission Protocol (SCTP) */
++ break;
++ default:
++ break;
++ }
++
++ return 0;
++}
++
++static const struct protocol_field ip_protocol_fields[] = {
++ /* field name offset length getter setter */
++ { "version", 0, 4, ip_version_get, ip_version_set },
++ { "ihl", 4, 4, ip_ihl_get, ip_ihl_set },
++ { "tos", 8, 8, get_8_bit_generic, set_8_bit_generic },
++ { "tot_len", 16, 16, get_16_bit_generic, set_16_bit_generic },
++ { "id", 32, 16, get_16_bit_generic, set_16_bit_generic },
++ { "flags", 48, 3, get_1_bit_generic, set_1_bit_generic },
++ { "frag_off", 51, 13, NULL, NULL },
++ { "ttl", 64, 8, get_8_bit_generic, set_8_bit_generic },
++ { "protocol", 72, 8, get_8_bit_generic, set_8_bit_generic },
++ { "check", 80, 16, get_16_bit_generic, set_16_bit_generic },
++ { "saddr", 96, 32, ip_addr_get, ip_addr_set },
++ { "daddr", 128, 32, ip_addr_get, ip_addr_set },
++ { "data", 160, 0, NULL, set_data_generic },
++ PROT_FIELD_SENTINEL,
++};
++
++static const struct protocol_buf ip_protocol_buf = {
++ .is_dynamic = 0,
++ .name = LUA_PACKET_SEG_IP,
++ .payload_field = "data",
++ .protocol_fields = (struct protocol_field *)&ip_protocol_fields,
++ .has_protocol = &ip_has_protocol,
++ .get_field_changes = NULL,
++};
++
++void luaopen_protbuf_ip(lua_State *L)
++{
++ register_protbuf(L, (struct protocol_buf *)&ip_protocol_buf, PACKET_IP);
++}
++
+--- /dev/null
++++ b/extensions/LUA/prot_buf_raw.c
+@@ -0,0 +1,43 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre@dergraf.org>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++
++#include "controller.h"
++static int32_t raw_has_protocol(lua_State *L, struct protocol_buf * prot_buf, lua_packet_segment * seg, int32_t protocol_type)
++{
++ return 1;
++}
++
++static const struct protocol_field raw_protocol_fields[] = {
++ /* field name offset length getter setter */
++ { "data", 0, 0, NULL, NULL },
++ PROT_FIELD_SENTINEL,
++};
++
++static const struct protocol_buf raw_protocol_buf = {
++ .is_dynamic = 0,
++ .name = LUA_PACKET_SEG_RAW,
++ .payload_field = "data",
++ .protocol_fields = (struct protocol_field *)&raw_protocol_fields,
++ .has_protocol = &raw_has_protocol,
++ .get_field_changes = NULL,
++};
++
++void luaopen_protbuf_raw(lua_State *L)
++{
++ register_protbuf(L, (struct protocol_buf *)&raw_protocol_buf, PACKET_RAW);
++}
+--- /dev/null
++++ b/extensions/LUA/prot_buf_tcp.c
+@@ -0,0 +1,188 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre@dergraf.org>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++
++#if defined(__KERNEL__)
++ #include <net/checksum.h>
++ #include <net/tcp.h>
++#endif
++#include "controller.h"
++
++
++static int32_t tcp_has_protocol(lua_State *L, struct protocol_buf * prot_buf, lua_packet_segment * seg, int32_t protocol_type)
++{
++ return 1;
++}
++
++static int32_t tcp_set_checksum(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++#if defined(__KERNEL__)
++ uint8_t * check_seg = seg->start + seg->offset;
++ uint8_t * tcp_hdr = check_seg - 16;
++ uint8_t * saddr = tcp_hdr - 8;
++ uint8_t * daddr = saddr + 4;
++ uint32_t len = 20 + (seg->changes->field_length_changes[11] / 8) + (seg->changes->field_length_changes[10] / 8);
++ unsigned short checksum = tcp_v4_check(len, *(uint32_t *)saddr, *(uint32_t *)daddr,
++ csum_partial(tcp_hdr, len, 0));
++
++ memcpy(check_seg, &checksum, sizeof(unsigned short));
++#endif
++ return 0;
++}
++
++
++static const struct protocol_field tcp_protocol_fields[] = {
++ /* field name offset length getter setter */
++ { "sport", 0, 16, get_16_bit_generic, set_16_bit_generic },
++ { "dport", 16, 16, get_16_bit_generic, set_16_bit_generic },
++ { "seq", 32, 32, get_32_bit_generic, set_32_bit_generic },
++ { "ack", 64, 32, get_32_bit_generic, set_32_bit_generic },
++ { "data_off", 96, 4, get_lower_4_bit_generic, set_lower_4_bit_generic },
++ { "reserved", 100, 4, get_upper_4_bit_generic, set_upper_4_bit_generic },
++ { "flags", 104, 8, get_1_bit_generic, set_1_bit_generic },
++ { "window_size", 112, 16, get_16_bit_generic, set_16_bit_generic },
++ { "check", 128, 16, get_16_bit_generic, tcp_set_checksum },
++ { "urgent", 144, 16, NULL, NULL },
++ { "options", 160, 0, NULL, set_data_generic },
++ { "data", 160, 0, NULL, set_data_generic }, /* begin of data depends on options */
++ PROT_FIELD_SENTINEL,
++};
++
++
++static const struct protocol_field tcp_options_and_data[] = {
++ /* field name offset length getter setter */
++ { "MSS", 0, 16, get_16_bit_generic, set_16_bit_generic },
++ { "WS", 0, 8, get_8_bit_generic, set_8_bit_generic },
++ { "SACK", 0, 16, get_16_bit_generic, set_16_bit_generic },
++ { "TSVAL", 0, 32, get_32_bit_generic, set_32_bit_generic },
++ { "TSER", 0, 32, get_32_bit_generic, set_32_bit_generic },
++ PROT_FIELD_SENTINEL,
++};
++
++
++static struct field_changes * tcp_get_field_changes(lua_State *L, lua_packet_segment * seg);
++
++static const struct protocol_buf tcp_protocol_buf = {
++ .is_dynamic = 0,
++ .name = LUA_PACKET_SEG_TCP,
++ .payload_field = "data",
++ .protocol_fields = (struct protocol_field *)&tcp_protocol_fields,
++ .has_protocol = &tcp_has_protocol,
++ .get_field_changes = &tcp_get_field_changes,
++};
++
++
++static struct field_changes * tcp_options_get_field_changes(lua_State *L, lua_packet_segment * seg);
++
++static const struct protocol_buf tcp_options_and_data_buf = {
++ .is_dynamic = 0,
++ .name = LUA_PACKET_SEG_TCP_OPT,
++ .payload_field = NULL,
++ .protocol_fields = (struct protocol_field *)&tcp_options_and_data,
++ .has_protocol = NULL,
++ .get_field_changes = &tcp_options_get_field_changes,
++};
++
++struct field_changes * tcp_get_field_changes(lua_State *L, lua_packet_segment * seg)
++{
++ /* depending on the value stored inside the 'data_off'-field, the length of
++ * the 'options' field has to be changed, as well as the length and offset
++ * of the 'data' field */
++ uint8_t *tcp_hdr = seg->start + seg->offset;
++
++ /* get the pointer to the 'data_off' field */
++ uint8_t * data_off_field = tcp_hdr + 12; /* 12 bytes offset */
++ /* extract the stored header length in bits */
++ uint32_t tcp_hdr_len = ((*(uint8_t *)data_off_field) >> 4) * 32;
++
++ /* get an allocated 'field_changes' structure */
++ struct field_changes * changes = get_allocated_field_changes(L, 12);
++
++ /* depending on the tcp header length, change the length of the options*/
++ changes->field_length_changes[10] = tcp_hdr_len - 160;
++ /* depending on the options length, change the offset of the data */
++ changes->field_offset_changes[11] = changes->field_length_changes[10];
++ changes->field_length_changes[11] = (seg->length * 8) - tcp_hdr_len;
++
++ return changes;
++
++}
++
++struct field_changes * tcp_options_get_field_changes(lua_State *L, lua_packet_segment * seg)
++{
++ /* depending on the value stored inside the 'data_off'-field, the length of
++ * the 'options' field has to be changed, as well as the length and offset
++ * of the 'data' field */
++ uint8_t *tcp_opt_hdr = seg->start + seg->offset;
++
++ /* get an allocated 'field_changes' structure */
++ struct field_changes * changes = get_allocated_field_changes(L, 5);
++
++ int32_t MSS = 0, WS = 0, SACK = 0, TS = 0, i;
++
++ uint8_t b1, b2;
++
++ for (i = 0; i < seg->length; i++) {
++ b1 = tcp_opt_hdr[i];
++ b2 = tcp_opt_hdr[i + 1];
++
++ if (b1 == 0x00)
++ break;
++
++ /* test for MSS */
++ if (!MSS && (b1 == 0x02 && b2 == 0x04)) {
++ changes->field_offset_changes[0] = (i + 2) * CHAR_BIT;
++ MSS = 1;
++ }
++
++ /* test for WS --- yet buggy somehow */
++ if (!WS && (b1 == 0x03 && b2 == 0x03)) {
++ changes->field_offset_changes[1] = (i + 2) * CHAR_BIT;
++ WS = 1;
++ }
++
++ /* test for SACK*/
++ if (!SACK && (b1 == 0x04 && b2 == 0x02)) {
++ changes->field_offset_changes[2] = i * CHAR_BIT; /* has no value */
++ SACK = 1;
++ }
++
++ /* test for TS */
++ if (!TS && (b1 == 0x08 && b2 == 0x0A)) {
++ changes->field_offset_changes[3] = (i + 2) * CHAR_BIT;
++ changes->field_offset_changes[4] = (i + 2 + 4) * CHAR_BIT;
++ TS = 1;
++ }
++ }
++
++ return changes;
++
++}
++
++void luaopen_protbuf_tcp(lua_State *L)
++{
++ register_protbuf(L, (struct protocol_buf *)&tcp_protocol_buf, PACKET_TCP);
++}
++void luaopen_protbuf_tcp_options(lua_State *L)
++{
++ register_protbuf(L, (struct protocol_buf *)&tcp_options_and_data_buf, PACKET_TCP_OPTIONS);
++}
++
++
+--- /dev/null
++++ b/extensions/LUA/prot_buf_tftp.c
+@@ -0,0 +1,87 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre@dergraf.org>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++#include "controller.h"
++
++static const struct protocol_field tftp_protocol_fields[] = {
++ /* field name offset length getter setter */
++ { "opcode", 0, 16, get_16_bit_generic, NULL},
++ { "filename", 0, 0, get_string_generic, NULL},
++ { "mode", 0, 0, get_string_generic, NULL},
++ { "block_nr", 0, 16, get_16_bit_generic, NULL},
++ { "data", 0, 0, NULL, NULL},
++ PROT_FIELD_SENTINEL,
++};
++
++struct field_changes * tftp_get_field_changes(lua_State *L, lua_packet_segment * seg)
++{
++ /* depending on the value stored inside the 'opcode'-field we have to change
++ * offsets and lengths */
++ uint8_t *tftp_hdr = seg->start + seg->offset;
++ short opcode = ntohs(*((uint16_t *)tftp_hdr));
++ /* get an allocated 'field_changes' structure */
++ struct field_changes * changes = get_allocated_field_changes(L, 5);
++ switch (opcode) {
++ case 1: /* Read Request (RRQ) */
++ /* setting offset and length of field 'filename' */
++ changes->field_offset_changes[1] = sizeof(unsigned short) << 3;
++ changes->field_length_changes[1] = strlen((char *)tftp_hdr + sizeof(unsigned short)) << 3;
++ /* setting offset and length of field 'mode' */
++ changes->field_offset_changes[2] = changes->field_offset_changes[1] + changes->field_length_changes[1];
++ changes->field_length_changes[2] = strlen((char *)tftp_hdr + (changes->field_offset_changes[2] >> 3));
++ break;
++ case 2: /* Write Request (WRQ) */
++ /* setting offset and length of field 'filename' */
++ changes->field_offset_changes[1] = sizeof(unsigned short) << 3;
++ changes->field_length_changes[1] = strlen((char *)tftp_hdr + sizeof(unsigned short)) << 3;
++ /* setting offset and length of field 'mode' */
++ changes->field_offset_changes[2] = changes->field_offset_changes[1] + changes->field_length_changes[1];
++ changes->field_length_changes[2] = strlen((char *)tftp_hdr + (changes->field_offset_changes[2] >> 3));
++ break;
++ case 3: /* Data (DATA) */
++ /* setting offset of field 'block_nr' */
++ changes->field_offset_changes[3] = sizeof(unsigned short) << 3;
++ /* setting offset of field 'data' */
++ changes->field_offset_changes[4] = changes->field_offset_changes[3] + (sizeof(unsigned short) << 3);
++ break;
++ case 4: /* Acknowledgment (ACK) */
++ /* setting offset of field 'block_nr' */
++ changes->field_offset_changes[3] = sizeof(unsigned short) << 3;
++ break;
++ case 5: /* Error (ERROR) */
++ /* we don't care ... yet */
++ break;
++ default:
++ break;
++ }
++
++ return changes;
++}
++
++static const struct protocol_buf tftp_protocol_buf = {
++ .is_dynamic = 0,
++ .name = LUA_PACKET_SEG_TFTP,
++ .payload_field = NULL,
++ .protocol_fields = (struct protocol_field *)&tftp_protocol_fields,
++ .has_protocol = NULL, /* we don't need it, since we don't provide a payload field */
++ .get_field_changes = tftp_get_field_changes,
++};
++
++void luaopen_protbuf_tftp(lua_State *L)
++{
++ register_protbuf(L, (struct protocol_buf *)&tftp_protocol_buf, PACKET_TFTP);
++}
+--- /dev/null
++++ b/extensions/LUA/prot_buf_udp.c
+@@ -0,0 +1,53 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre@dergraf.org>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++
++#if defined(__KERNEL__)
++ #include <net/checksum.h>
++#endif
++
++#include "controller.h"
++
++
++static int32_t udp_has_protocol(lua_State *L, struct protocol_buf * prot_buf, lua_packet_segment * seg, int32_t protocol_type)
++{
++ return 1;
++}
++
++static const struct protocol_field udp_protocol_fields[] = {
++ /* field name offset length getter setter */
++ { "sport", 0, 16, get_16_bit_generic, set_16_bit_generic },
++ { "dport", 16, 16, get_16_bit_generic, set_16_bit_generic },
++ { "length", 32, 16, get_16_bit_generic, set_16_bit_generic },
++ { "check", 48, 16, get_16_bit_generic, set_16_bit_generic },
++ { "data", 64, 0, NULL, NULL },
++ PROT_FIELD_SENTINEL,
++};
++
++static const struct protocol_buf udp_protocol_buf = {
++ .is_dynamic = 0,
++ .name = LUA_PACKET_SEG_UDP,
++ .payload_field = "data",
++ .protocol_fields = (struct protocol_field *)&udp_protocol_fields,
++ .has_protocol = &udp_has_protocol,
++ .get_field_changes = NULL,
++};
++
++void luaopen_protbuf_udp(lua_State *L)
++{
++ register_protbuf(L, (struct protocol_buf *)&udp_protocol_buf, PACKET_UDP);
++}
+--- /dev/null
++++ b/extensions/LUA/xt_LUA.h
+@@ -0,0 +1,36 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre.graf@stud.unibas.ch>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++
++#ifndef XT_LUA_H_
++#define XT_LUA_H_
++
++#define MAX_FILENAME_SIZE 256
++#define MAX_FUNCTION_SIZE 256
++#define MAX_SCRIPT_SIZE 32768
++#define LUA_STATE_ARRAY_SIZE 128
++
++/* the targetsize is stored in a u16, so max size of the xt_lua_tginfo cannot exceed 64K*/
++struct xt_lua_tginfo {
++ char buf[MAX_SCRIPT_SIZE];
++ char filename[MAX_FILENAME_SIZE];
++ char function[MAX_FUNCTION_SIZE];
++ __u64 script_size;
++ __u32 state_id;
++};
++
++#endif /* XT_LUA_H_ */
+--- /dev/null
++++ b/extensions/LUA/xt_LUA.mod.c
+@@ -0,0 +1,69 @@
++#include <linux/module.h>
++#include <linux/vermagic.h>
++#include <linux/compiler.h>
++
++MODULE_INFO(vermagic, VERMAGIC_STRING);
++
++struct module __this_module
++__attribute__((section(".gnu.linkonce.this_module"))) = {
++ .name = KBUILD_MODNAME,
++ .init = init_module,
++#ifdef CONFIG_MODULE_UNLOAD
++ .exit = cleanup_module,
++#endif
++ .arch = MODULE_ARCH_INIT,
++};
++
++static const struct modversion_info ____versions[]
++__used
++__attribute__((section("__versions"))) = {
++ { 0xa3379c4b, "module_layout" },
++ { 0x5cf97727, "xt_unregister_target" },
++ { 0x9a1dfd65, "strpbrk" },
++ { 0x56fb5417, "kmalloc_caches" },
++ { 0x12da5bb2, "__kmalloc" },
++ { 0xb85f3bbe, "pv_lock_ops" },
++ { 0x349cba85, "strchr" },
++ { 0xd0d8621b, "strlen" },
++ { 0x79aa04a2, "get_random_bytes" },
++ { 0x20000329, "simple_strtoul" },
++ { 0x105e2727, "__tracepoint_kmalloc" },
++ { 0xbf7e1481, "inet_proto_csum_replace4" },
++ { 0x6c1ce5ce, "strcspn" },
++ { 0x3c2c5af5, "sprintf" },
++ { 0xe2d5255a, "strcmp" },
++ { 0xe24d3a97, "jiffies_64" },
++ { 0x2bc95bd4, "memset" },
++ { 0x87fc9bcc, "kmem_cache_alloc_notrace" },
++ { 0x11089ac7, "_ctype" },
++ { 0x37befc70, "jiffies_to_msecs" },
++ { 0x70d1f8f3, "strncat" },
++ { 0xb72397d5, "printk" },
++ { 0x42224298, "sscanf" },
++ { 0x5152e605, "memcmp" },
++ { 0xb6ed1e53, "strncpy" },
++ { 0x1e6d26a8, "strstr" },
++ { 0xc3fa6a59, "memchr" },
++ { 0x61651be, "strcat" },
++ { 0x7d8c0d13, "xt_register_target" },
++ { 0x8ff4079b, "pv_irq_ops" },
++ { 0x93fca811, "__get_free_pages" },
++ { 0xf0fdf6cb, "__stack_chk_fail" },
++ { 0xbbe2391b, "kfree_skb" },
++ { 0xf333a2fb, "_raw_spin_lock_irq" },
++ { 0x37a0cba, "kfree" },
++ { 0x2e60bace, "memcpy" },
++ { 0x59e7cb79, "skb_make_writable" },
++ { 0xb742fd7, "simple_strtol" },
++ { 0x7d50a24, "csum_partial" },
++ { 0xc2d711e1, "krealloc" },
++ { 0xe914e41e, "strcpy" },
++};
++
++static const char __module_depends[]
++__used
++__attribute__((section(".modinfo"))) =
++"depends=x_tables";
++
++
++MODULE_INFO(srcversion, "33A1481C4AA71D1B5A8CA8A");
+--- /dev/null
++++ b/extensions/LUA/xt_LUA_target.c
+@@ -0,0 +1,286 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre@dergraf.org>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++
++#include <linux/kernel.h>
++#include <linux/slab.h>
++#include <linux/module.h>
++#include <asm/uaccess.h>
++#include <net/ip.h>
++#include <linux/netfilter/x_tables.h>
++#include "xt_LUA.h"
++
++#include "controller.h"
++
++/*::*
++ * lua_envs
++ * ----------
++ * This array holds a defined number of `lua_envs`_ structures.
++ * The used array index is also used as the Lua state identifier.
++ * The size of the array is defined in `LUA_STATE_ARRAY_SIZE`_.
++ */
++struct lua_env * lua_envs[LUA_STATE_ARRAY_SIZE];
++
++/*::*
++ * lua_state_refs
++ * --------------
++ * This array holds the reference counts of the several `lua_nf_state`_s
++ * which are stored inside the array `lua_states`_.
++ */
++uint32_t lua_state_refs[LUA_STATE_ARRAY_SIZE] = { 0 };
++
++/*::*
++ * lua_tg
++ * ------
++ * This function is called whenever a packet matches all matching conditions
++ * inside a rule. It is the target. It extracts the state identifier comming
++ * inside the *xt_target_param* structure and uses it to access the proper
++ * Lua state inside the `lua_states`_ array.
++ *
++ * It then constructs a new Lua userdata of type *lua_packet_segment* and
++ * initializes it with the lowest network header available. This userdata
++ * is annotated with the Lua metatable `LUA_PACKET_SEG_RAW`_ which converts
++ * the userdata to a raw lua packet having all raw functions available.
++ * This raw packet is the single parameter to the Lua function *process_packet*
++ * which must be defined inside the Lua script provided by the user. So far
++ * hardcoded, may be later configured by Lua - subject to change.
++ *
++ * The process_packet function must return an integer value, the verdict. For
++ * convenience reasons xt_LUA exports the verdicts NF_ACCEPT, NF_DROP and
++ * XT_CONTINUE inside the *register_lua_packet_lib* function.
++ */
++
++spinlock_t lock = SPIN_LOCK_UNLOCKED;
++
++static uint32_t
++lua_tg(struct sk_buff *pskb, const struct xt_target_param *par)
++{
++ uint32_t verdict;
++ lua_packet_segment *p;
++ const struct xt_lua_tginfo *info = par->targinfo;
++ lua_State * L;
++
++ /* START critical section on SMP, PacketScript is on the sequential trail at the moment TODO*/
++ spin_lock_irq(&lock);
++
++ L = lua_envs[info->state_id]->L;
++
++ if (!skb_make_writable(pskb, pskb->len))
++ return NF_DROP;
++
++ /* call the function provided by --function parameter or the default 'process_packet' defined in Lua */
++ lua_getglobal(L, info->function);
++
++ /* push the lua_packet_segment as a parameter */
++ p = (lua_packet_segment *)lua_newuserdata(L, sizeof(lua_packet_segment));
++ if (pskb->mac_header)
++ p->start = pskb->mac_header;
++ else if (pskb->network_header)
++ p->start = pskb->network_header;
++ else if (pskb->transport_header)
++ p->start = pskb->transport_header;
++ p->offset = 0;
++ p->length = (unsigned long)pskb->tail - (unsigned long)p->start;
++ p->changes = NULL;
++
++ /* marking userdata 'lua_packet_seg' with the corresponding metatable */
++ luaL_getmetatable(L, LUA_PACKET_SEG_RAW);
++ lua_setmetatable(L, -2);
++
++ /* push a reference to the skb as a parameter, needed at the moment for calculating TCP checksum, but I am not happy with it*/
++ lua_pushlightuserdata(L, (void *)skb_get(pskb));
++
++ /* do the function call (2 argument, 1 result) */
++ if (lua_pcall(L, 2, 1, 0) != 0) {
++ printk(KERN_ERR "LUA [%d]: pcall '%s' failed: %s\n", info->state_id, info->function, lua_tostring(L, -1));
++ lua_pop(L, 1);
++ return NF_DROP;
++ }
++
++ if (!lua_isnumber(L, -1)) {
++ printk(KERN_ERR "LUA [%d]: function '%s' must return a verdict\n", info->state_id, info->function);
++ lua_pop(L, 1);
++ return NF_DROP;
++ }
++
++ verdict = lua_tonumber(L, -1);
++ lua_pop(L, 1);
++
++ kfree_skb(pskb);
++
++ /* END critical section on SMP */
++ spin_unlock_irq(&lock);
++
++
++ return verdict;
++
++}
++/* Helper for checkentry */
++static bool load_script_into_state(uint32_t state_id, unsigned long script_size, char *script_buf)
++{
++ char *buf = kmalloc(script_size, GFP_KERNEL);
++ int32_t ret;
++ struct lua_env * env = kmalloc(sizeof(struct lua_env), GFP_KERNEL);
++
++ if (!script_size > 0) {
++ pr_debug("LUA [%d]: script_size %lu < 0\n", state_id, script_size);
++ return false;
++ }
++
++ env->L = lua_open();
++ luaopen_base(env->L);
++ luaopen_controller(env->L);
++
++ lua_getglobal(env->L, "_G");
++ lua_pushinteger(env->L, state_id);
++ lua_setfield(env->L, -2, "STATE_ID");
++ lua_pop(env->L, 1); /* pop _G */
++
++ strncpy(buf, script_buf, script_size);
++ ret = luaL_loadbuffer(env->L, buf, script_size, "PacketScript, loadbuffer") ||
++ lua_pcall(env->L, 0, 1, 0);
++
++ if (ret != 0) {
++ printk(KERN_ERR "LUA [%d]: failure loading script, error %s \n", state_id, lua_tostring(env->L, -1));
++ lua_pop(env->L, 1);
++ kfree(buf);
++ kfree(env);
++ return false;
++ }
++
++ lua_envs[state_id] = env;
++
++ kfree(buf);
++
++ return true;
++}
++/*::*
++ * lua_tg_checkentry
++ * -----------------
++ * This function is used as a kernel-side sanity check of the data comming
++ * from the iptables userspace program. Since this is the function which is
++ * called everytime a new rule (with -j xt_LUA) is injected, this function
++ * is used to do the bookkeeping work, such as counting the reference of
++ * several Lua states and the initialization of new states if needed. As an
++ * extra initialization step it loads the provided Lua script into the Lua
++ * state.
++ *
++ * Lua state initialization
++ * ~~~~~~~~~~~~~~~~~~~~~~~~
++ * 1. If a new rule is inserted and there is no existing state for the given
++ * state identifier (default state identifier is 0) a new Lua state is
++ * initialized using *lua_open*.
++ * 2. The Lua base library is registered inside the newly initialized state.
++ * Have a look at *lua/lbaselib.c* to see what functions of the Lua base
++ * library are available inside Lua.
++ * 3. The Lua packet library is registered inside the Lua state using the
++ * function *register_lua_packet_lib*. So far this function only registers
++ * the Netfilter verdicts NF_ACCEPT, NF_DROP and XT_CONTINUE inside the
++ * global environment of the given Lua state.
++ * 4. All the protocol Buffers, and the functions for accessing the bytes are
++ * registered using *register_protocols*.
++ *
++ * Lua state reference counting
++ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
++ * Bookkeeping of the Lua states inside the *lua_state_refs* array. The
++ * state identifier is mapped to the array index, which holds an integer
++ * counting the several initialized states.
++ *
++ * Loading the Lua script
++ * ~~~~~~~~~~~~~~~~~~~~~~
++ * Copying the buffer which was initialized by the userspace program to a
++ * buffer with the proper size. The script is then loaded by the function
++ * xt_LUA_loadcode, which wrapps the *luaL_loadbuffer* function and does
++ * some workqueue initialization. So far this is done each time this function
++ * is called, subject to change.
++ */
++static bool
++lua_tg_checkentry(const struct xt_tgchk_param *par)
++{
++ const struct xt_lua_tginfo *info = par->targinfo;
++
++ if (load_script_into_state(info->state_id, info->script_size, (char *)info->buf)) {
++ lua_state_refs[info->state_id]++;
++ return true;
++ }
++ return false;
++}
++
++/*::*
++ * lua_tg_destroy
++ * --------------
++ * This function is the counterpart of the `lua_tg_checkentry`_ function. It is
++ * responsible to free all the resources alocated inside the checkentry process.
++ * To be more specific it frees the Lua state using *lua_close* and kfree on all
++ * the dynamically allocated pointers to the registered dynamic protocol buffers.
++ *
++ * Additionally the function cares about decrementing the reference counters
++ * inside the array `lua_states`_.
++ */
++static void
++lua_tg_destroy(const struct xt_tgdtor_param *par)
++{
++ const struct xt_lua_tginfo *info = par->targinfo;
++ struct lua_env * env = lua_envs[info->state_id];
++
++ if (lua_state_refs[info->state_id] == 1) {
++ lua_close(env->L);
++ cleanup_dynamic_prot_bufs(); /* clean memory allocated by protocols defined in Lua */
++ kfree(env);
++ pr_debug("LUA [%d]: Rule removed, close Lua state\n", info->state_id);
++ } else
++ pr_debug("LUA [%d]: Rule removed, Lua state stays open, referenced %d time(s)\n",
++ info->state_id, lua_state_refs[info->state_id] - 1);
++
++ lua_state_refs[info->state_id]--;
++}
++
++static struct xt_target lua_tg_reg __read_mostly = {
++ .name = "LUA",
++ .revision = 0,
++ .family = NFPROTO_UNSPEC,
++ .targetsize = XT_ALIGN(sizeof(struct xt_lua_tginfo)),
++ .target = lua_tg,
++ .checkentry = lua_tg_checkentry,
++ .destroy = lua_tg_destroy,
++ .me = THIS_MODULE,
++};
++
++
++static int32_t lua_tg_init(void)
++{
++ return xt_register_target(&lua_tg_reg);
++}
++
++static void lua_tg_exit(void)
++{
++ xt_unregister_target(&lua_tg_reg);
++}
++
++module_init(lua_tg_init);
++module_exit(lua_tg_exit);
++
++MODULE_AUTHOR("Andre Graf <andre@dergraf.org>");
++MODULE_DESCRIPTION("Xtables: Processing of matched packets using the Lua scripting environment");
++MODULE_ALIAS("ipt_LUA");
++MODULE_ALIAS("ipt6t_LUA");
++MODULE_ALIAS("arpt_LUA");
++MODULE_ALIAS("ebt_LUA");
++MODULE_LICENSE("GPL");
++
++
++
+--- a/extensions/Kbuild
++++ b/extensions/Kbuild
+@@ -36,6 +36,7 @@ obj-${build_pknock} += pknock/
+ obj-${build_psd} += xt_psd.o
+ obj-${build_quota2} += xt_quota2.o
+ obj-${build_rtsp} += rtsp/
++obj-${build_LUA} += LUA/
+
+ -include ${M}/*.Kbuild
+ -include ${M}/Kbuild.*
+--- a/extensions/Mbuild
++++ b/extensions/Mbuild
+@@ -26,3 +26,4 @@ obj-${build_pknock} += pknock/
+ obj-${build_psd} += libxt_psd.so
+ obj-${build_quota2} += libxt_quota2.so
+ obj-${build_gradm} += libxt_gradm.so
++obj-${build_LUA} += LUA/
+--- a/mconfig
++++ b/mconfig
+@@ -27,3 +27,4 @@ build_pknock=m
+ build_psd=m
+ build_quota2=m
+ build_rtsp=m
++build_LUA=m
diff --git a/package/network/utils/xtables-addons/patches-1.x/201-fix-lua-packetscript.patch b/package/network/utils/xtables-addons/patches-1.x/201-fix-lua-packetscript.patch
new file mode 100644
index 0000000..966d29d
--- /dev/null
+++ b/package/network/utils/xtables-addons/patches-1.x/201-fix-lua-packetscript.patch
@@ -0,0 +1,89 @@
+--- a/extensions/LUA/xt_LUA_target.c
++++ b/extensions/LUA/xt_LUA_target.c
+@@ -64,10 +64,10 @@ uint32_t lua_state_refs[LUA_STATE_ARRAY
+ * XT_CONTINUE inside the *register_lua_packet_lib* function.
+ */
+
+-spinlock_t lock = SPIN_LOCK_UNLOCKED;
++DEFINE_SPINLOCK(lock);
+
+ static uint32_t
+-lua_tg(struct sk_buff *pskb, const struct xt_target_param *par)
++lua_tg(struct sk_buff *pskb, const struct xt_action_param *par)
+ {
+ uint32_t verdict;
+ lua_packet_segment *p;
+@@ -208,16 +208,16 @@ static bool load_script_into_state(uint3
+ * some workqueue initialization. So far this is done each time this function
+ * is called, subject to change.
+ */
+-static bool
++static int
+ lua_tg_checkentry(const struct xt_tgchk_param *par)
+ {
+ const struct xt_lua_tginfo *info = par->targinfo;
+
+ if (load_script_into_state(info->state_id, info->script_size, (char *)info->buf)) {
+ lua_state_refs[info->state_id]++;
+- return true;
++ return 0;
+ }
+- return false;
++ return -EINVAL;
+ }
+
+ /*::*
+--- a/extensions/LUA/lua/llimits.h
++++ b/extensions/LUA/lua/llimits.h
+@@ -8,7 +8,6 @@
+ #define llimits_h
+
+ #include <stddef.h>
+-#include <limits.h>
+
+ #include "lua.h"
+
+--- a/extensions/LUA/lua/lapi.c
++++ b/extensions/LUA/lua/lapi.c
+@@ -4,9 +4,6 @@
+ ** See Copyright Notice in lua.h
+ */
+
+-#include <stdarg.h>
+-#include <math.h>
+-#include <assert.h>
+ #include <string.h>
+
+ #define lapi_c
+--- a/extensions/LUA/lua/ltable.c
++++ b/extensions/LUA/lua/ltable.c
+@@ -18,7 +18,6 @@
+ ** Hence even when the load factor reaches 100%, performance remains good.
+ */
+
+-#include <math.h>
+ #include <string.h>
+
+ #define ltable_c
+--- a/extensions/LUA/lua/luaconf.h
++++ b/extensions/LUA/lua/luaconf.h
+@@ -13,6 +13,10 @@
+ #if !defined(__KERNEL__)
+ #include <limits.h>
+ #else
++#undef UCHAR_MAX
++#undef SHRT_MAX
++#undef BUFSIZ
++#undef NO_FPU
+ #define UCHAR_MAX 255
+ #define SHRT_MAX 32767
+ #define BUFSIZ 8192
+@@ -637,6 +641,8 @@ union luai_Cast { double l_d; long l_l;
+ */
+ #if defined(__KERNEL__)
+ #undef LUA_USE_ULONGJMP
++#define setjmp __builtin_setjmp
++#define longjmp __builtin_longjmp
+ #endif
+
+ #if defined(__cplusplus)
diff --git a/package/network/utils/xtables-addons/patches-1.x/300-geoip-endian-detection.patch b/package/network/utils/xtables-addons/patches-1.x/300-geoip-endian-detection.patch
new file mode 100644
index 0000000..842e7af
--- /dev/null
+++ b/package/network/utils/xtables-addons/patches-1.x/300-geoip-endian-detection.patch
@@ -0,0 +1,18 @@
+--- a/extensions/libxt_geoip.c
++++ b/extensions/libxt_geoip.c
+@@ -59,13 +59,13 @@ geoip_get_subnets(const char *code, uint
+
+ /* Use simple integer vector files */
+ if (nfproto == NFPROTO_IPV6) {
+-#if __BYTE_ORDER == _BIG_ENDIAN
++#if BYTE_ORDER == BIG_ENDIAN
+ snprintf(buf, sizeof(buf), GEOIP_DB_DIR "/BE/%s.iv6", code);
+ #else
+ snprintf(buf, sizeof(buf), GEOIP_DB_DIR "/LE/%s.iv6", code);
+ #endif
+ } else {
+-#if __BYTE_ORDER == _BIG_ENDIAN
++#if BYTE_ORDER == BIG_ENDIAN
+ snprintf(buf, sizeof(buf), GEOIP_DB_DIR "/BE/%s.iv4", code);
+ #else
+ snprintf(buf, sizeof(buf), GEOIP_DB_DIR "/LE/%s.iv4", code);
diff --git a/package/network/utils/xtables-addons/patches/.svn/entries b/package/network/utils/xtables-addons/patches/.svn/entries
new file mode 100644
index 0000000..d24009d
--- /dev/null
+++ b/package/network/utils/xtables-addons/patches/.svn/entries
@@ -0,0 +1,334 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/network/utils/xtables-addons/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-17T16:05:30.871964Z
+35203
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+001-no_depmod.patch
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+a6181179fc21396ed4bf10271171fbe6
+2012-01-04T00:30:53.320775Z
+29644
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+308
+
+002-fix-kernel-version-detection.patch
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+337fce713d496e626bcba57403867674
+2013-01-17T11:20:51.292469Z
+35192
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+892
+
+400-uid-gid-linux-3.7-compat.patch
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+13c190389422ff4d81391a409831f7d0
+2013-01-17T16:05:30.871964Z
+35203
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2641
+
+101-rtsp-linux-3.6-compat.patch
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+3362b293109c48451514a8605a90b855
+2012-11-27T18:31:44.490937Z
+34391
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+520
+
+102-rtsp-linux-3.7-compat.patch
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+b9fbfa3f1559c14392884965be6d9e0b
+2013-01-17T11:20:51.292469Z
+35192
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+6391
+
+300-geoip-endian-detection.patch
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+d5908fec20ffc0a5a999d9291aa64263
+2012-11-27T18:31:44.490937Z
+34391
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+613
+
+100-add-rtsp-conntrack.patch
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+d516966741e331e697711500c7a56bbc
+2013-01-17T11:20:51.292469Z
+35192
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+39249
+
+201-fix-lua-packetscript.patch
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+26fe3500a0e2b0cc7321c5edd3a4f89b
+2012-11-27T18:31:44.490937Z
+34391
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2108
+
+200-add-lua-packetscript.patch
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+55fff25e11dac44df80cff9e36982a94
+2013-01-17T11:20:51.292469Z
+35192
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+527328
+
diff --git a/package/network/utils/xtables-addons/patches/.svn/text-base/001-no_depmod.patch.svn-base b/package/network/utils/xtables-addons/patches/.svn/text-base/001-no_depmod.patch.svn-base
new file mode 100644
index 0000000..9905af1
--- /dev/null
+++ b/package/network/utils/xtables-addons/patches/.svn/text-base/001-no_depmod.patch.svn-base
@@ -0,0 +1,16 @@
+---
+ Makefile.in | 3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -11,9 +11,6 @@ FORCE:
+ xtables-addons.8: FORCE
+ ${MAKE} -f Makefile.mans all;
+
+-install-exec-hook:
+- depmod -a || :;
+-
+ config.status: Makefile.iptrules.in
+
+ tmpdir := $(shell mktemp -dtu)
diff --git a/package/network/utils/xtables-addons/patches/.svn/text-base/002-fix-kernel-version-detection.patch.svn-base b/package/network/utils/xtables-addons/patches/.svn/text-base/002-fix-kernel-version-detection.patch.svn-base
new file mode 100644
index 0000000..8dc6384
--- /dev/null
+++ b/package/network/utils/xtables-addons/patches/.svn/text-base/002-fix-kernel-version-detection.patch.svn-base
@@ -0,0 +1,22 @@
+--- a/configure
++++ b/configure
+@@ -11892,7 +11892,7 @@ regular_CFLAGS="-Wall -Waggregate-return
+ if test -n "$kbuilddir"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking kernel version that we will build against" >&5
+ $as_echo_n "checking kernel version that we will build against... " >&6; }
+- krel="$(make -sC "$kbuilddir" M=$PWD kernelrelease)";
++ krel="$(make -sC "$kbuilddir" M=$PWD kernelversion)";
+ kmajor="${krel%%[^0-9]*}";
+ kmajor="$(($kmajor+0))";
+ krel="${krel:${#kmajor}}";
+--- a/configure.ac
++++ b/configure.ac
+@@ -44,7 +44,7 @@ regular_CFLAGS="-Wall -Waggregate-return
+
+ if test -n "$kbuilddir"; then
+ AC_MSG_CHECKING([kernel version that we will build against])
+- krel="$(make -sC "$kbuilddir" M=$PWD kernelrelease)";
++ krel="$(make -sC "$kbuilddir" M=$PWD kernelversion)";
+ kmajor="${krel%%[[^0-9]]*}";
+ kmajor="$(($kmajor+0))";
+ krel="${krel:${#kmajor}}";
diff --git a/package/network/utils/xtables-addons/patches/.svn/text-base/100-add-rtsp-conntrack.patch.svn-base b/package/network/utils/xtables-addons/patches/.svn/text-base/100-add-rtsp-conntrack.patch.svn-base
new file mode 100644
index 0000000..9e105b4
--- /dev/null
+++ b/package/network/utils/xtables-addons/patches/.svn/text-base/100-add-rtsp-conntrack.patch.svn-base
@@ -0,0 +1,1334 @@
+--- /dev/null
++++ b/extensions/rtsp/Kbuild
+@@ -0,0 +1,4 @@
++# -*- Makefile -*-
++
++obj-m += nf_nat_rtsp.o
++obj-m += nf_conntrack_rtsp.o
+--- /dev/null
++++ b/extensions/rtsp/netfilter_helpers.h
+@@ -0,0 +1,133 @@
++/*
++ * Helpers for netfiler modules. This file provides implementations for basic
++ * functions such as strncasecmp(), etc.
++ *
++ * gcc will warn for defined but unused functions, so we only include the
++ * functions requested. The following macros are used:
++ * NF_NEED_STRNCASECMP nf_strncasecmp()
++ * NF_NEED_STRTOU16 nf_strtou16()
++ * NF_NEED_STRTOU32 nf_strtou32()
++ */
++#ifndef _NETFILTER_HELPERS_H
++#define _NETFILTER_HELPERS_H
++
++/* Only include these functions for kernel code. */
++#ifdef __KERNEL__
++
++#include <linux/ctype.h>
++#define iseol(c) ( (c) == '\r' || (c) == '\n' )
++
++/*
++ * The standard strncasecmp()
++ */
++#ifdef NF_NEED_STRNCASECMP
++static int
++nf_strncasecmp(const char* s1, const char* s2, u_int32_t len)
++{
++ if (s1 == NULL || s2 == NULL)
++ {
++ if (s1 == NULL && s2 == NULL)
++ {
++ return 0;
++ }
++ return (s1 == NULL) ? -1 : 1;
++ }
++ while (len > 0 && tolower(*s1) == tolower(*s2))
++ {
++ len--;
++ s1++;
++ s2++;
++ }
++ return ( (len == 0) ? 0 : (tolower(*s1) - tolower(*s2)) );
++}
++#endif /* NF_NEED_STRNCASECMP */
++
++/*
++ * Parse a string containing a 16-bit unsigned integer.
++ * Returns the number of chars used, or zero if no number is found.
++ */
++#ifdef NF_NEED_STRTOU16
++static int
++nf_strtou16(const char* pbuf, u_int16_t* pval)
++{
++ int n = 0;
++
++ *pval = 0;
++ while (isdigit(pbuf[n]))
++ {
++ *pval = (*pval * 10) + (pbuf[n] - '0');
++ n++;
++ }
++
++ return n;
++}
++#endif /* NF_NEED_STRTOU16 */
++
++/*
++ * Parse a string containing a 32-bit unsigned integer.
++ * Returns the number of chars used, or zero if no number is found.
++ */
++#ifdef NF_NEED_STRTOU32
++static int
++nf_strtou32(const char* pbuf, u_int32_t* pval)
++{
++ int n = 0;
++
++ *pval = 0;
++ while (pbuf[n] >= '0' && pbuf[n] <= '9')
++ {
++ *pval = (*pval * 10) + (pbuf[n] - '0');
++ n++;
++ }
++
++ return n;
++}
++#endif /* NF_NEED_STRTOU32 */
++
++/*
++ * Given a buffer and length, advance to the next line and mark the current
++ * line.
++ */
++#ifdef NF_NEED_NEXTLINE
++static int
++nf_nextline(char* p, uint len, uint* poff, uint* plineoff, uint* plinelen)
++{
++ uint off = *poff;
++ uint physlen = 0;
++
++ if (off >= len)
++ {
++ return 0;
++ }
++
++ while (p[off] != '\n')
++ {
++ if (len-off <= 1)
++ {
++ return 0;
++ }
++
++ physlen++;
++ off++;
++ }
++
++ /* if we saw a crlf, physlen needs adjusted */
++ if (physlen > 0 && p[off] == '\n' && p[off-1] == '\r')
++ {
++ physlen--;
++ }
++
++ /* advance past the newline */
++ off++;
++
++ *plineoff = *poff;
++ *plinelen = physlen;
++ *poff = off;
++
++ return 1;
++}
++#endif /* NF_NEED_NEXTLINE */
++
++#endif /* __KERNEL__ */
++
++#endif /* _NETFILTER_HELPERS_H */
+--- /dev/null
++++ b/extensions/rtsp/netfilter_mime.h
+@@ -0,0 +1,89 @@
++/*
++ * MIME functions for netfilter modules. This file provides implementations
++ * for basic MIME parsing. MIME headers are used in many protocols, such as
++ * HTTP, RTSP, SIP, etc.
++ *
++ * gcc will warn for defined but unused functions, so we only include the
++ * functions requested. The following macros are used:
++ * NF_NEED_MIME_NEXTLINE nf_mime_nextline()
++ */
++#ifndef _NETFILTER_MIME_H
++#define _NETFILTER_MIME_H
++
++/* Only include these functions for kernel code. */
++#ifdef __KERNEL__
++
++#include <linux/ctype.h>
++
++/*
++ * Given a buffer and length, advance to the next line and mark the current
++ * line. If the current line is empty, *plinelen will be set to zero. If
++ * not, it will be set to the actual line length (including CRLF).
++ *
++ * 'line' in this context means logical line (includes LWS continuations).
++ * Returns 1 on success, 0 on failure.
++ */
++#ifdef NF_NEED_MIME_NEXTLINE
++static int
++nf_mime_nextline(char* p, uint len, uint* poff, uint* plineoff, uint* plinelen)
++{
++ uint off = *poff;
++ uint physlen = 0;
++ int is_first_line = 1;
++
++ if (off >= len)
++ {
++ return 0;
++ }
++
++ do
++ {
++ while (p[off] != '\n')
++ {
++ if (len-off <= 1)
++ {
++ return 0;
++ }
++
++ physlen++;
++ off++;
++ }
++
++ /* if we saw a crlf, physlen needs adjusted */
++ if (physlen > 0 && p[off] == '\n' && p[off-1] == '\r')
++ {
++ physlen--;
++ }
++
++ /* advance past the newline */
++ off++;
++
++ /* check for an empty line */
++ if (physlen == 0)
++ {
++ break;
++ }
++
++ /* check for colon on the first physical line */
++ if (is_first_line)
++ {
++ is_first_line = 0;
++ if (memchr(p+(*poff), ':', physlen) == NULL)
++ {
++ return 0;
++ }
++ }
++ }
++ while (p[off] == ' ' || p[off] == '\t');
++
++ *plineoff = *poff;
++ *plinelen = (physlen == 0) ? 0 : (off - *poff);
++ *poff = off;
++
++ return 1;
++}
++#endif /* NF_NEED_MIME_NEXTLINE */
++
++#endif /* __KERNEL__ */
++
++#endif /* _NETFILTER_MIME_H */
+--- /dev/null
++++ b/extensions/rtsp/nf_conntrack_rtsp.c
+@@ -0,0 +1,519 @@
++/*
++ * RTSP extension for IP connection tracking
++ * (C) 2003 by Tom Marshall <tmarshall at real.com>
++ * based on ip_conntrack_irc.c
++ *
++ * 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 of the License, or (at your option) any later version.
++ *
++ * Module load syntax:
++ * insmod nf_conntrack_rtsp.o ports=port1,port2,...port<MAX_PORTS>
++ * max_outstanding=n setup_timeout=secs
++ *
++ * If no ports are specified, the default will be port 554.
++ *
++ * With max_outstanding you can define the maximum number of not yet
++ * answered SETUP requests per RTSP session (default 8).
++ * With setup_timeout you can specify how long the system waits for
++ * an expected data channel (default 300 seconds).
++ *
++ * 2005-02-13: Harald Welte <laforge at netfilter.org>
++ * - port to 2.6
++ * - update to recent post-2.6.11 api changes
++ * 2006-09-14: Steven Van Acker <deepstar at singularity.be>
++ * - removed calls to NAT code from conntrack helper: NAT no longer needed to use rtsp-conntrack
++ * 2007-04-18: Michael Guntsche <mike at it-loops.com>
++ * - Port to new NF API
++ */
++
++#include <linux/module.h>
++#include <linux/netfilter.h>
++#include <linux/ip.h>
++#include <linux/inet.h>
++#include <net/tcp.h>
++
++#include <net/netfilter/nf_conntrack.h>
++#include <net/netfilter/nf_conntrack_expect.h>
++#include <net/netfilter/nf_conntrack_helper.h>
++#include "nf_conntrack_rtsp.h"
++
++#define NF_NEED_STRNCASECMP
++#define NF_NEED_STRTOU16
++#define NF_NEED_STRTOU32
++#define NF_NEED_NEXTLINE
++#include "netfilter_helpers.h"
++#define NF_NEED_MIME_NEXTLINE
++#include "netfilter_mime.h"
++
++#include <linux/ctype.h>
++#define MAX_SIMUL_SETUP 8 /* XXX: use max_outstanding */
++
++#define MAX_PORTS 8
++static int ports[MAX_PORTS];
++static int num_ports = 0;
++static int max_outstanding = 8;
++static unsigned int setup_timeout = 300;
++
++MODULE_AUTHOR("Tom Marshall <tmarshall at real.com>");
++MODULE_DESCRIPTION("RTSP connection tracking module");
++MODULE_LICENSE("GPL");
++module_param_array(ports, int, &num_ports, 0400);
++MODULE_PARM_DESC(ports, "port numbers of RTSP servers");
++module_param(max_outstanding, int, 0400);
++MODULE_PARM_DESC(max_outstanding, "max number of outstanding SETUP requests per RTSP session");
++module_param(setup_timeout, int, 0400);
++MODULE_PARM_DESC(setup_timeout, "timeout on for unestablished data channels");
++
++static char *rtsp_buffer;
++static DEFINE_SPINLOCK(rtsp_buffer_lock);
++
++static struct nf_conntrack_expect_policy rtsp_exp_policy;
++
++unsigned int (*nf_nat_rtsp_hook)(struct sk_buff *skb,
++ enum ip_conntrack_info ctinfo,
++ unsigned int matchoff, unsigned int matchlen,struct ip_ct_rtsp_expect* prtspexp,
++ struct nf_conntrack_expect *exp);
++void (*nf_nat_rtsp_hook_expectfn)(struct nf_conn *ct, struct nf_conntrack_expect *exp);
++
++EXPORT_SYMBOL_GPL(nf_nat_rtsp_hook);
++
++/*
++ * Max mappings we will allow for one RTSP connection (for RTP, the number
++ * of allocated ports is twice this value). Note that SMIL burns a lot of
++ * ports so keep this reasonably high. If this is too low, you will see a
++ * lot of "no free client map entries" messages.
++ */
++#define MAX_PORT_MAPS 16
++
++/*** default port list was here in the masq code: 554, 3030, 4040 ***/
++
++#define SKIP_WSPACE(ptr,len,off) while(off < len && isspace(*(ptr+off))) { off++; }
++
++/*
++ * Parse an RTSP packet.
++ *
++ * Returns zero if parsing failed.
++ *
++ * Parameters:
++ * IN ptcp tcp data pointer
++ * IN tcplen tcp data len
++ * IN/OUT ptcpoff points to current tcp offset
++ * OUT phdrsoff set to offset of rtsp headers
++ * OUT phdrslen set to length of rtsp headers
++ * OUT pcseqoff set to offset of CSeq header
++ * OUT pcseqlen set to length of CSeq header
++ */
++static int
++rtsp_parse_message(char* ptcp, uint tcplen, uint* ptcpoff,
++ uint* phdrsoff, uint* phdrslen,
++ uint* pcseqoff, uint* pcseqlen,
++ uint* transoff, uint* translen)
++{
++ uint entitylen = 0;
++ uint lineoff;
++ uint linelen;
++
++ if (!nf_nextline(ptcp, tcplen, ptcpoff, &lineoff, &linelen))
++ return 0;
++
++ *phdrsoff = *ptcpoff;
++ while (nf_mime_nextline(ptcp, tcplen, ptcpoff, &lineoff, &linelen)) {
++ if (linelen == 0) {
++ if (entitylen > 0)
++ *ptcpoff += min(entitylen, tcplen - *ptcpoff);
++ break;
++ }
++ if (lineoff+linelen > tcplen) {
++ pr_info("!! overrun !!\n");
++ break;
++ }
++
++ if (nf_strncasecmp(ptcp+lineoff, "CSeq:", 5) == 0) {
++ *pcseqoff = lineoff;
++ *pcseqlen = linelen;
++ }
++
++ if (nf_strncasecmp(ptcp+lineoff, "Transport:", 10) == 0) {
++ *transoff = lineoff;
++ *translen = linelen;
++ }
++
++ if (nf_strncasecmp(ptcp+lineoff, "Content-Length:", 15) == 0) {
++ uint off = lineoff+15;
++ SKIP_WSPACE(ptcp+lineoff, linelen, off);
++ nf_strtou32(ptcp+off, &entitylen);
++ }
++ }
++ *phdrslen = (*ptcpoff) - (*phdrsoff);
++
++ return 1;
++}
++
++/*
++ * Find lo/hi client ports (if any) in transport header
++ * In:
++ * ptcp, tcplen = packet
++ * tranoff, tranlen = buffer to search
++ *
++ * Out:
++ * pport_lo, pport_hi = lo/hi ports (host endian)
++ *
++ * Returns nonzero if any client ports found
++ *
++ * Note: it is valid (and expected) for the client to request multiple
++ * transports, so we need to parse the entire line.
++ */
++static int
++rtsp_parse_transport(char* ptran, uint tranlen,
++ struct ip_ct_rtsp_expect* prtspexp)
++{
++ int rc = 0;
++ uint off = 0;
++
++ if (tranlen < 10 || !iseol(ptran[tranlen-1]) ||
++ nf_strncasecmp(ptran, "Transport:", 10) != 0) {
++ pr_info("sanity check failed\n");
++ return 0;
++ }
++
++ pr_debug("tran='%.*s'\n", (int)tranlen, ptran);
++ off += 10;
++ SKIP_WSPACE(ptran, tranlen, off);
++
++ /* Transport: tran;field;field=val,tran;field;field=val,... */
++ while (off < tranlen) {
++ const char* pparamend;
++ uint nextparamoff;
++
++ pparamend = memchr(ptran+off, ',', tranlen-off);
++ pparamend = (pparamend == NULL) ? ptran+tranlen : pparamend+1;
++ nextparamoff = pparamend-ptran;
++
++ while (off < nextparamoff) {
++ const char* pfieldend;
++ uint nextfieldoff;
++
++ pfieldend = memchr(ptran+off, ';', nextparamoff-off);
++ nextfieldoff = (pfieldend == NULL) ? nextparamoff : pfieldend-ptran+1;
++
++ if (strncmp(ptran+off, "client_port=", 12) == 0) {
++ u_int16_t port;
++ uint numlen;
++
++ off += 12;
++ numlen = nf_strtou16(ptran+off, &port);
++ off += numlen;
++ if (prtspexp->loport != 0 && prtspexp->loport != port)
++ pr_debug("multiple ports found, port %hu ignored\n", port);
++ else {
++ pr_debug("lo port found : %hu\n", port);
++ prtspexp->loport = prtspexp->hiport = port;
++ if (ptran[off] == '-') {
++ off++;
++ numlen = nf_strtou16(ptran+off, &port);
++ off += numlen;
++ prtspexp->pbtype = pb_range;
++ prtspexp->hiport = port;
++
++ // If we have a range, assume rtp:
++ // loport must be even, hiport must be loport+1
++ if ((prtspexp->loport & 0x0001) != 0 ||
++ prtspexp->hiport != prtspexp->loport+1) {
++ pr_debug("incorrect range: %hu-%hu, correcting\n",
++ prtspexp->loport, prtspexp->hiport);
++ prtspexp->loport &= 0xfffe;
++ prtspexp->hiport = prtspexp->loport+1;
++ }
++ } else if (ptran[off] == '/') {
++ off++;
++ numlen = nf_strtou16(ptran+off, &port);
++ off += numlen;
++ prtspexp->pbtype = pb_discon;
++ prtspexp->hiport = port;
++ }
++ rc = 1;
++ }
++ }
++
++ /*
++ * Note we don't look for the destination parameter here.
++ * If we are using NAT, the NAT module will handle it. If not,
++ * and the client is sending packets elsewhere, the expectation
++ * will quietly time out.
++ */
++
++ off = nextfieldoff;
++ }
++
++ off = nextparamoff;
++ }
++
++ return rc;
++}
++
++void expected(struct nf_conn *ct, struct nf_conntrack_expect *exp)
++{
++ typeof(nf_nat_rtsp_hook_expectfn) nf_nat_rtsp_expectfn;
++ nf_nat_rtsp_expectfn = rcu_dereference(nf_nat_rtsp_hook_expectfn);
++ if(nf_nat_rtsp_expectfn && ct->master->status & IPS_NAT_MASK) {
++ nf_nat_rtsp_expectfn(ct,exp);
++ }
++}
++
++/*** conntrack functions ***/
++
++/* outbound packet: client->server */
++
++static inline int
++help_out(struct sk_buff *skb, unsigned char *rb_ptr, unsigned int datalen,
++ struct nf_conn *ct, enum ip_conntrack_info ctinfo)
++{
++ struct ip_ct_rtsp_expect expinfo;
++
++ int dir = CTINFO2DIR(ctinfo); /* = IP_CT_DIR_ORIGINAL */
++ //struct tcphdr* tcph = (void*)iph + iph->ihl * 4;
++ //uint tcplen = pktlen - iph->ihl * 4;
++ char* pdata = rb_ptr;
++ //uint datalen = tcplen - tcph->doff * 4;
++ uint dataoff = 0;
++ int ret = NF_ACCEPT;
++
++ struct nf_conntrack_expect *exp;
++
++ __be16 be_loport;
++
++ typeof(nf_nat_rtsp_hook) nf_nat_rtsp;
++
++ memset(&expinfo, 0, sizeof(expinfo));
++
++ while (dataoff < datalen) {
++ uint cmdoff = dataoff;
++ uint hdrsoff = 0;
++ uint hdrslen = 0;
++ uint cseqoff = 0;
++ uint cseqlen = 0;
++ uint transoff = 0;
++ uint translen = 0;
++ uint off;
++
++ if (!rtsp_parse_message(pdata, datalen, &dataoff,
++ &hdrsoff, &hdrslen,
++ &cseqoff, &cseqlen,
++ &transoff, &translen))
++ break; /* not a valid message */
++
++ if (strncmp(pdata+cmdoff, "SETUP ", 6) != 0)
++ continue; /* not a SETUP message */
++ pr_debug("found a setup message\n");
++
++ off = 0;
++ if(translen) {
++ rtsp_parse_transport(pdata+transoff, translen, &expinfo);
++ }
++
++ if (expinfo.loport == 0) {
++ pr_debug("no udp transports found\n");
++ continue; /* no udp transports found */
++ }
++
++ pr_debug("udp transport found, ports=(%d,%hu,%hu)\n",
++ (int)expinfo.pbtype, expinfo.loport, expinfo.hiport);
++
++ exp = nf_ct_expect_alloc(ct);
++ if (!exp) {
++ ret = NF_DROP;
++ goto out;
++ }
++
++ be_loport = htons(expinfo.loport);
++
++ nf_ct_expect_init(exp, NF_CT_EXPECT_CLASS_DEFAULT, nf_ct_l3num(ct),
++ &ct->tuplehash[!dir].tuple.src.u3, &ct->tuplehash[!dir].tuple.dst.u3,
++ IPPROTO_UDP, NULL, &be_loport);
++
++ exp->master = ct;
++
++ exp->expectfn = expected;
++ exp->flags = 0;
++
++ if (expinfo.pbtype == pb_range) {
++ pr_debug("Changing expectation mask to handle multiple ports\n");
++ //exp->mask.dst.u.udp.port = 0xfffe;
++ }
++
++ pr_debug("expect_related %pI4:%u-%pI4:%u\n",
++ &exp->tuple.src.u3.ip,
++ ntohs(exp->tuple.src.u.udp.port),
++ &exp->tuple.dst.u3.ip,
++ ntohs(exp->tuple.dst.u.udp.port));
++
++ nf_nat_rtsp = rcu_dereference(nf_nat_rtsp_hook);
++ if (nf_nat_rtsp && ct->status & IPS_NAT_MASK)
++ /* pass the request off to the nat helper */
++ ret = nf_nat_rtsp(skb, ctinfo, hdrsoff, hdrslen, &expinfo, exp);
++ else if (nf_ct_expect_related(exp) != 0) {
++ pr_info("nf_conntrack_expect_related failed\n");
++ ret = NF_DROP;
++ }
++ nf_ct_expect_put(exp);
++ goto out;
++ }
++out:
++
++ return ret;
++}
++
++
++static inline int
++help_in(struct sk_buff *skb, size_t pktlen,
++ struct nf_conn* ct, enum ip_conntrack_info ctinfo)
++{
++ return NF_ACCEPT;
++}
++
++static int help(struct sk_buff *skb, unsigned int protoff,
++ struct nf_conn *ct, enum ip_conntrack_info ctinfo)
++{
++ struct tcphdr _tcph, *th;
++ unsigned int dataoff, datalen;
++ char *rb_ptr;
++ int ret = NF_DROP;
++
++ /* Until there's been traffic both ways, don't look in packets. */
++ if (ctinfo != IP_CT_ESTABLISHED &&
++ ctinfo != IP_CT_ESTABLISHED + IP_CT_IS_REPLY) {
++ pr_debug("conntrackinfo = %u\n", ctinfo);
++ return NF_ACCEPT;
++ }
++
++ /* Not whole TCP header? */
++ th = skb_header_pointer(skb,protoff, sizeof(_tcph), &_tcph);
++
++ if (!th)
++ return NF_ACCEPT;
++
++ /* No data ? */
++ dataoff = protoff + th->doff*4;
++ datalen = skb->len - dataoff;
++ if (dataoff >= skb->len)
++ return NF_ACCEPT;
++
++ spin_lock_bh(&rtsp_buffer_lock);
++ rb_ptr = skb_header_pointer(skb, dataoff,
++ skb->len - dataoff, rtsp_buffer);
++ BUG_ON(rb_ptr == NULL);
++
++#if 0
++ /* Checksum invalid? Ignore. */
++ /* FIXME: Source route IP option packets --RR */
++ if (tcp_v4_check(tcph, tcplen, iph->saddr, iph->daddr,
++ csum_partial((char*)tcph, tcplen, 0)))
++ {
++ DEBUGP("bad csum: %p %u %u.%u.%u.%u %u.%u.%u.%u\n",
++ tcph, tcplen, NIPQUAD(iph->saddr), NIPQUAD(iph->daddr));
++ return NF_ACCEPT;
++ }
++#endif
++
++ switch (CTINFO2DIR(ctinfo)) {
++ case IP_CT_DIR_ORIGINAL:
++ ret = help_out(skb, rb_ptr, datalen, ct, ctinfo);
++ break;
++ case IP_CT_DIR_REPLY:
++ pr_debug("IP_CT_DIR_REPLY\n");
++ /* inbound packet: server->client */
++ ret = NF_ACCEPT;
++ break;
++ }
++
++ spin_unlock_bh(&rtsp_buffer_lock);
++
++ return ret;
++}
++
++static struct nf_conntrack_helper rtsp_helpers[MAX_PORTS];
++static char rtsp_names[MAX_PORTS][10];
++
++/* This function is intentionally _NOT_ defined as __exit */
++static void
++fini(void)
++{
++ int i;
++ for (i = 0; i < num_ports; i++) {
++ pr_debug("unregistering port %d\n", ports[i]);
++ nf_conntrack_helper_unregister(&rtsp_helpers[i]);
++ }
++ kfree(rtsp_buffer);
++}
++
++static int __init
++init(void)
++{
++ int i, ret;
++ struct nf_conntrack_helper *hlpr;
++ char *tmpname;
++
++ printk("nf_conntrack_rtsp v" IP_NF_RTSP_VERSION " loading\n");
++
++ if (max_outstanding < 1) {
++ printk("nf_conntrack_rtsp: max_outstanding must be a positive integer\n");
++ return -EBUSY;
++ }
++ if (setup_timeout < 0) {
++ printk("nf_conntrack_rtsp: setup_timeout must be a positive integer\n");
++ return -EBUSY;
++ }
++
++ rtsp_exp_policy.max_expected = max_outstanding;
++ rtsp_exp_policy.timeout = setup_timeout;
++
++ rtsp_buffer = kmalloc(65536, GFP_KERNEL);
++ if (!rtsp_buffer)
++ return -ENOMEM;
++
++ /* If no port given, default to standard rtsp port */
++ if (ports[0] == 0) {
++ ports[0] = RTSP_PORT;
++ }
++
++ for (i = 0; (i < MAX_PORTS) && ports[i]; i++) {
++ hlpr = &rtsp_helpers[i];
++ memset(hlpr, 0, sizeof(struct nf_conntrack_helper));
++ hlpr->tuple.src.l3num = AF_INET;
++ hlpr->tuple.src.u.tcp.port = htons(ports[i]);
++ hlpr->tuple.dst.protonum = IPPROTO_TCP;
++ //hlpr->mask.src.u.tcp.port = 0xFFFF;
++ //hlpr->mask.dst.protonum = 0xFF;
++ hlpr->expect_policy = &rtsp_exp_policy;
++ hlpr->me = THIS_MODULE;
++ hlpr->help = help;
++
++ tmpname = &rtsp_names[i][0];
++ if (ports[i] == RTSP_PORT) {
++ sprintf(tmpname, "rtsp");
++ } else {
++ sprintf(tmpname, "rtsp-%d", i);
++ }
++ hlpr->name = tmpname;
++
++ pr_debug("port #%d: %d\n", i, ports[i]);
++
++ ret = nf_conntrack_helper_register(hlpr);
++
++ if (ret) {
++ printk("nf_conntrack_rtsp: ERROR registering port %d\n", ports[i]);
++ fini();
++ return -EBUSY;
++ }
++ num_ports++;
++ }
++ return 0;
++}
++
++module_init(init);
++module_exit(fini);
++
++EXPORT_SYMBOL(nf_nat_rtsp_hook_expectfn);
++
+--- /dev/null
++++ b/extensions/rtsp/nf_conntrack_rtsp.h
+@@ -0,0 +1,63 @@
++/*
++ * RTSP extension for IP connection tracking.
++ * (C) 2003 by Tom Marshall <tmarshall at real.com>
++ * based on ip_conntrack_irc.h
++ *
++ * 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 of the License, or (at your option) any later version.
++ */
++#ifndef _IP_CONNTRACK_RTSP_H
++#define _IP_CONNTRACK_RTSP_H
++
++//#define IP_NF_RTSP_DEBUG 1
++#define IP_NF_RTSP_VERSION "0.6.21"
++
++#ifdef __KERNEL__
++/* port block types */
++typedef enum {
++ pb_single, /* client_port=x */
++ pb_range, /* client_port=x-y */
++ pb_discon /* client_port=x/y (rtspbis) */
++} portblock_t;
++
++/* We record seq number and length of rtsp headers here, all in host order. */
++
++/*
++ * This structure is per expected connection. It is a member of struct
++ * ip_conntrack_expect. The TCP SEQ for the conntrack expect is stored
++ * there and we are expected to only store the length of the data which
++ * needs replaced. If a packet contains multiple RTSP messages, we create
++ * one expected connection per message.
++ *
++ * We use these variables to mark the entire header block. This may seem
++ * like overkill, but the nature of RTSP requires it. A header may appear
++ * multiple times in a message. We must treat two Transport headers the
++ * same as one Transport header with two entries.
++ */
++struct ip_ct_rtsp_expect
++{
++ u_int32_t len; /* length of header block */
++ portblock_t pbtype; /* Type of port block that was requested */
++ u_int16_t loport; /* Port that was requested, low or first */
++ u_int16_t hiport; /* Port that was requested, high or second */
++#if 0
++ uint method; /* RTSP method */
++ uint cseq; /* CSeq from request */
++#endif
++};
++
++extern unsigned int (*nf_nat_rtsp_hook)(struct sk_buff *skb,
++ enum ip_conntrack_info ctinfo,
++ unsigned int matchoff, unsigned int matchlen,
++ struct ip_ct_rtsp_expect *prtspexp,
++ struct nf_conntrack_expect *exp);
++
++extern void (*nf_nat_rtsp_hook_expectfn)(struct nf_conn *ct, struct nf_conntrack_expect *exp);
++
++#define RTSP_PORT 554
++
++#endif /* __KERNEL__ */
++
++#endif /* _IP_CONNTRACK_RTSP_H */
+--- /dev/null
++++ b/extensions/rtsp/nf_nat_rtsp.c
+@@ -0,0 +1,491 @@
++/*
++ * RTSP extension for TCP NAT alteration
++ * (C) 2003 by Tom Marshall <tmarshall at real.com>
++ * based on ip_nat_irc.c
++ *
++ * 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 of the License, or (at your option) any later version.
++ *
++ * Module load syntax:
++ * insmod nf_nat_rtsp.o ports=port1,port2,...port<MAX_PORTS>
++ * stunaddr=<address>
++ * destaction=[auto|strip|none]
++ *
++ * If no ports are specified, the default will be port 554 only.
++ *
++ * stunaddr specifies the address used to detect that a client is using STUN.
++ * If this address is seen in the destination parameter, it is assumed that
++ * the client has already punched a UDP hole in the firewall, so we don't
++ * mangle the client_port. If none is specified, it is autodetected. It
++ * only needs to be set if you have multiple levels of NAT. It should be
++ * set to the external address that the STUN clients detect. Note that in
++ * this case, it will not be possible for clients to use UDP with servers
++ * between the NATs.
++ *
++ * If no destaction is specified, auto is used.
++ * destaction=auto: strip destination parameter if it is not stunaddr.
++ * destaction=strip: always strip destination parameter (not recommended).
++ * destaction=none: do not touch destination parameter (not recommended).
++ */
++
++#include <linux/module.h>
++#include <net/tcp.h>
++#include <net/netfilter/nf_nat_helper.h>
++#include <net/netfilter/nf_nat_rule.h>
++#include "nf_conntrack_rtsp.h"
++#include <net/netfilter/nf_conntrack_expect.h>
++
++#include <linux/inet.h>
++#include <linux/ctype.h>
++#define NF_NEED_STRNCASECMP
++#define NF_NEED_STRTOU16
++#include "netfilter_helpers.h"
++#define NF_NEED_MIME_NEXTLINE
++#include "netfilter_mime.h"
++
++#include "../compat_xtables.h"
++
++#define MAX_PORTS 8
++#define DSTACT_AUTO 0
++#define DSTACT_STRIP 1
++#define DSTACT_NONE 2
++
++static char* stunaddr = NULL;
++static char* destaction = NULL;
++
++static u_int32_t extip = 0;
++static int dstact = 0;
++
++MODULE_AUTHOR("Tom Marshall <tmarshall at real.com>");
++MODULE_DESCRIPTION("RTSP network address translation module");
++MODULE_LICENSE("GPL");
++module_param(stunaddr, charp, 0644);
++MODULE_PARM_DESC(stunaddr, "Address for detecting STUN");
++module_param(destaction, charp, 0644);
++MODULE_PARM_DESC(destaction, "Action for destination parameter (auto/strip/none)");
++
++#define SKIP_WSPACE(ptr,len,off) while(off < len && isspace(*(ptr+off))) { off++; }
++
++/*** helper functions ***/
++
++static void
++get_skb_tcpdata(struct sk_buff* skb, char** pptcpdata, uint* ptcpdatalen)
++{
++ struct iphdr* iph = ip_hdr(skb);
++ struct tcphdr* tcph = (void *)iph + ip_hdrlen(skb);
++
++ *pptcpdata = (char*)tcph + tcph->doff*4;
++ *ptcpdatalen = ((char*)skb_transport_header(skb) + skb->len) - *pptcpdata;
++}
++
++/*** nat functions ***/
++
++/*
++ * Mangle the "Transport:" header:
++ * - Replace all occurences of "client_port=<spec>"
++ * - Handle destination parameter
++ *
++ * In:
++ * ct, ctinfo = conntrack context
++ * skb = packet
++ * tranoff = Transport header offset from TCP data
++ * tranlen = Transport header length (incl. CRLF)
++ * rport_lo = replacement low port (host endian)
++ * rport_hi = replacement high port (host endian)
++ *
++ * Returns packet size difference.
++ *
++ * Assumes that a complete transport header is present, ending with CR or LF
++ */
++static int
++rtsp_mangle_tran(enum ip_conntrack_info ctinfo,
++ struct nf_conntrack_expect* exp,
++ struct ip_ct_rtsp_expect* prtspexp,
++ struct sk_buff* skb, uint tranoff, uint tranlen)
++{
++ char* ptcp;
++ uint tcplen;
++ char* ptran;
++ char rbuf1[16]; /* Replacement buffer (one port) */
++ uint rbuf1len; /* Replacement len (one port) */
++ char rbufa[16]; /* Replacement buffer (all ports) */
++ uint rbufalen; /* Replacement len (all ports) */
++ u_int32_t newip;
++ u_int16_t loport, hiport;
++ uint off = 0;
++ uint diff; /* Number of bytes we removed */
++
++ struct nf_conn *ct = exp->master;
++ struct nf_conntrack_tuple *t;
++
++ char szextaddr[15+1];
++ uint extaddrlen;
++ int is_stun;
++
++ get_skb_tcpdata(skb, &ptcp, &tcplen);
++ ptran = ptcp+tranoff;
++
++ if (tranoff+tranlen > tcplen || tcplen-tranoff < tranlen ||
++ tranlen < 10 || !iseol(ptran[tranlen-1]) ||
++ nf_strncasecmp(ptran, "Transport:", 10) != 0)
++ {
++ pr_info("sanity check failed\n");
++ return 0;
++ }
++ off += 10;
++ SKIP_WSPACE(ptcp+tranoff, tranlen, off);
++
++ newip = ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u3.ip;
++ t = &exp->tuple;
++ t->dst.u3.ip = newip;
++
++ extaddrlen = extip ? sprintf(szextaddr, "%pI4", &extip)
++ : sprintf(szextaddr, "%pI4", &newip);
++ pr_debug("stunaddr=%s (%s)\n", szextaddr, (extip?"forced":"auto"));
++
++ rbuf1len = rbufalen = 0;
++ switch (prtspexp->pbtype)
++ {
++ case pb_single:
++ for (loport = prtspexp->loport; loport != 0; loport++) /* XXX: improper wrap? */
++ {
++ t->dst.u.udp.port = htons(loport);
++ if (nf_ct_expect_related(exp) == 0)
++ {
++ pr_debug("using port %hu\n", loport);
++ break;
++ }
++ }
++ if (loport != 0)
++ {
++ rbuf1len = sprintf(rbuf1, "%hu", loport);
++ rbufalen = sprintf(rbufa, "%hu", loport);
++ }
++ break;
++ case pb_range:
++ for (loport = prtspexp->loport; loport != 0; loport += 2) /* XXX: improper wrap? */
++ {
++ t->dst.u.udp.port = htons(loport);
++ if (nf_ct_expect_related(exp) == 0)
++ {
++ hiport = loport + 1; //~exp->mask.dst.u.udp.port;
++ pr_debug("using ports %hu-%hu\n", loport, hiport);
++ break;
++ }
++ }
++ if (loport != 0)
++ {
++ rbuf1len = sprintf(rbuf1, "%hu", loport);
++ rbufalen = sprintf(rbufa, "%hu-%hu", loport, loport+1);
++ }
++ break;
++ case pb_discon:
++ for (loport = prtspexp->loport; loport != 0; loport++) /* XXX: improper wrap? */
++ {
++ t->dst.u.udp.port = htons(loport);
++ if (nf_ct_expect_related(exp) == 0)
++ {
++ pr_debug("using port %hu (1 of 2)\n", loport);
++ break;
++ }
++ }
++ for (hiport = prtspexp->hiport; hiport != 0; hiport++) /* XXX: improper wrap? */
++ {
++ t->dst.u.udp.port = htons(hiport);
++ if (nf_ct_expect_related(exp) == 0)
++ {
++ pr_debug("using port %hu (2 of 2)\n", hiport);
++ break;
++ }
++ }
++ if (loport != 0 && hiport != 0)
++ {
++ rbuf1len = sprintf(rbuf1, "%hu", loport);
++ if (hiport == loport+1)
++ {
++ rbufalen = sprintf(rbufa, "%hu-%hu", loport, hiport);
++ }
++ else
++ {
++ rbufalen = sprintf(rbufa, "%hu/%hu", loport, hiport);
++ }
++ }
++ break;
++ }
++
++ if (rbuf1len == 0)
++ {
++ return 0; /* cannot get replacement port(s) */
++ }
++
++ /* Transport: tran;field;field=val,tran;field;field=val,... */
++ while (off < tranlen)
++ {
++ uint saveoff;
++ const char* pparamend;
++ uint nextparamoff;
++
++ pparamend = memchr(ptran+off, ',', tranlen-off);
++ pparamend = (pparamend == NULL) ? ptran+tranlen : pparamend+1;
++ nextparamoff = pparamend-ptcp;
++
++ /*
++ * We pass over each param twice. On the first pass, we look for a
++ * destination= field. It is handled by the security policy. If it
++ * is present, allowed, and equal to our external address, we assume
++ * that STUN is being used and we leave the client_port= field alone.
++ */
++ is_stun = 0;
++ saveoff = off;
++ while (off < nextparamoff)
++ {
++ const char* pfieldend;
++ uint nextfieldoff;
++
++ pfieldend = memchr(ptran+off, ';', nextparamoff-off);
++ nextfieldoff = (pfieldend == NULL) ? nextparamoff : pfieldend-ptran+1;
++
++ if (dstact != DSTACT_NONE && strncmp(ptran+off, "destination=", 12) == 0)
++ {
++ if (strncmp(ptran+off+12, szextaddr, extaddrlen) == 0)
++ {
++ is_stun = 1;
++ }
++ if (dstact == DSTACT_STRIP || (dstact == DSTACT_AUTO && !is_stun))
++ {
++ diff = nextfieldoff-off;
++ if (!nf_nat_mangle_tcp_packet(skb, ct, ctinfo,
++ off, diff, NULL, 0))
++ {
++ /* mangle failed, all we can do is bail */
++ nf_ct_unexpect_related(exp);
++ return 0;
++ }
++ get_skb_tcpdata(skb, &ptcp, &tcplen);
++ ptran = ptcp+tranoff;
++ tranlen -= diff;
++ nextparamoff -= diff;
++ nextfieldoff -= diff;
++ }
++ }
++
++ off = nextfieldoff;
++ }
++ if (is_stun)
++ {
++ continue;
++ }
++ off = saveoff;
++ while (off < nextparamoff)
++ {
++ const char* pfieldend;
++ uint nextfieldoff;
++
++ pfieldend = memchr(ptran+off, ';', nextparamoff-off);
++ nextfieldoff = (pfieldend == NULL) ? nextparamoff : pfieldend-ptran+1;
++
++ if (strncmp(ptran+off, "client_port=", 12) == 0)
++ {
++ u_int16_t port;
++ uint numlen;
++ uint origoff;
++ uint origlen;
++ char* rbuf = rbuf1;
++ uint rbuflen = rbuf1len;
++
++ off += 12;
++ origoff = (ptran-ptcp)+off;
++ origlen = 0;
++ numlen = nf_strtou16(ptran+off, &port);
++ off += numlen;
++ origlen += numlen;
++ if (port != prtspexp->loport)
++ {
++ pr_debug("multiple ports found, port %hu ignored\n", port);
++ }
++ else
++ {
++ if (ptran[off] == '-' || ptran[off] == '/')
++ {
++ off++;
++ origlen++;
++ numlen = nf_strtou16(ptran+off, &port);
++ off += numlen;
++ origlen += numlen;
++ rbuf = rbufa;
++ rbuflen = rbufalen;
++ }
++
++ /*
++ * note we cannot just memcpy() if the sizes are the same.
++ * the mangle function does skb resizing, checks for a
++ * cloned skb, and updates the checksums.
++ *
++ * parameter 4 below is offset from start of tcp data.
++ */
++ diff = origlen-rbuflen;
++ if (!nf_nat_mangle_tcp_packet(skb, ct, ctinfo,
++ origoff, origlen, rbuf, rbuflen))
++ {
++ /* mangle failed, all we can do is bail */
++ nf_ct_unexpect_related(exp);
++ return 0;
++ }
++ get_skb_tcpdata(skb, &ptcp, &tcplen);
++ ptran = ptcp+tranoff;
++ tranlen -= diff;
++ nextparamoff -= diff;
++ nextfieldoff -= diff;
++ }
++ }
++
++ off = nextfieldoff;
++ }
++
++ off = nextparamoff;
++ }
++
++ return 1;
++}
++
++static uint
++help_out(struct sk_buff *skb, enum ip_conntrack_info ctinfo,
++ unsigned int matchoff, unsigned int matchlen, struct ip_ct_rtsp_expect* prtspexp,
++ struct nf_conntrack_expect* exp)
++{
++ char* ptcp;
++ uint tcplen;
++ uint hdrsoff;
++ uint hdrslen;
++ uint lineoff;
++ uint linelen;
++ uint off;
++
++ //struct iphdr* iph = (struct iphdr*)(*pskb)->nh.iph;
++ //struct tcphdr* tcph = (struct tcphdr*)((void*)iph + iph->ihl*4);
++
++ get_skb_tcpdata(skb, &ptcp, &tcplen);
++ hdrsoff = matchoff;//exp->seq - ntohl(tcph->seq);
++ hdrslen = matchlen;
++ off = hdrsoff;
++ pr_debug("NAT rtsp help_out\n");
++
++ while (nf_mime_nextline(ptcp, hdrsoff+hdrslen, &off, &lineoff, &linelen))
++ {
++ if (linelen == 0)
++ {
++ break;
++ }
++ if (off > hdrsoff+hdrslen)
++ {
++ pr_info("!! overrun !!");
++ break;
++ }
++ pr_debug("hdr: len=%u, %.*s", linelen, (int)linelen, ptcp+lineoff);
++
++ if (nf_strncasecmp(ptcp+lineoff, "Transport:", 10) == 0)
++ {
++ uint oldtcplen = tcplen;
++ pr_debug("hdr: Transport\n");
++ if (!rtsp_mangle_tran(ctinfo, exp, prtspexp, skb, lineoff, linelen))
++ {
++ pr_debug("hdr: Transport mangle failed");
++ break;
++ }
++ get_skb_tcpdata(skb, &ptcp, &tcplen);
++ hdrslen -= (oldtcplen-tcplen);
++ off -= (oldtcplen-tcplen);
++ lineoff -= (oldtcplen-tcplen);
++ linelen -= (oldtcplen-tcplen);
++ pr_debug("rep: len=%u, %.*s", linelen, (int)linelen, ptcp+lineoff);
++ }
++ }
++
++ return NF_ACCEPT;
++}
++
++static unsigned int
++help(struct sk_buff *skb, enum ip_conntrack_info ctinfo,
++ unsigned int matchoff, unsigned int matchlen, struct ip_ct_rtsp_expect* prtspexp,
++ struct nf_conntrack_expect* exp)
++{
++ int dir = CTINFO2DIR(ctinfo);
++ int rc = NF_ACCEPT;
++
++ switch (dir)
++ {
++ case IP_CT_DIR_ORIGINAL:
++ rc = help_out(skb, ctinfo, matchoff, matchlen, prtspexp, exp);
++ break;
++ case IP_CT_DIR_REPLY:
++ pr_debug("unmangle ! %u\n", ctinfo);
++ /* XXX: unmangle */
++ rc = NF_ACCEPT;
++ break;
++ }
++ //UNLOCK_BH(&ip_rtsp_lock);
++
++ return rc;
++}
++
++static void expected(struct nf_conn* ct, struct nf_conntrack_expect *exp)
++{
++ struct nf_nat_ipv4_multi_range_compat mr;
++ u_int32_t newdstip, newsrcip, newip;
++
++ struct nf_conn *master = ct->master;
++
++ newdstip = master->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u3.ip;
++ newsrcip = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u3.ip;
++ //FIXME (how to port that ?)
++ //code from 2.4 : newip = (HOOK2MANIP(hooknum) == NF_NAT_MANIP_SRC) ? newsrcip : newdstip;
++ newip = newdstip;
++
++ pr_debug("newsrcip=%pI4, newdstip=%pI4, newip=%pI4\n",
++ &newsrcip, &newdstip, &newip);
++
++ mr.rangesize = 1;
++ // We don't want to manip the per-protocol, just the IPs.
++ mr.range[0].flags = NF_NAT_RANGE_MAP_IPS;
++ mr.range[0].min_ip = mr.range[0].max_ip = newip;
++
++ nf_nat_setup_info(ct, &mr.range[0], NF_NAT_MANIP_DST);
++}
++
++
++static void __exit fini(void)
++{
++ nf_nat_rtsp_hook = NULL;
++ nf_nat_rtsp_hook_expectfn = NULL;
++ synchronize_net();
++}
++
++static int __init init(void)
++{
++ printk("nf_nat_rtsp v" IP_NF_RTSP_VERSION " loading\n");
++
++ BUG_ON(nf_nat_rtsp_hook);
++ nf_nat_rtsp_hook = help;
++ nf_nat_rtsp_hook_expectfn = &expected;
++
++ if (stunaddr != NULL)
++ extip = in_aton(stunaddr);
++
++ if (destaction != NULL) {
++ if (strcmp(destaction, "auto") == 0)
++ dstact = DSTACT_AUTO;
++
++ if (strcmp(destaction, "strip") == 0)
++ dstact = DSTACT_STRIP;
++
++ if (strcmp(destaction, "none") == 0)
++ dstact = DSTACT_NONE;
++ }
++
++ return 0;
++}
++
++module_init(init);
++module_exit(fini);
+--- a/extensions/Kbuild
++++ b/extensions/Kbuild
+@@ -33,6 +33,7 @@ obj-${build_lscan} += xt_lscan.o
+ obj-${build_pknock} += pknock/
+ obj-${build_psd} += xt_psd.o
+ obj-${build_quota2} += xt_quota2.o
++obj-${build_rtsp} += rtsp/
+
+ -include ${M}/*.Kbuild
+ -include ${M}/Kbuild.*
+--- a/mconfig
++++ b/mconfig
+@@ -24,3 +24,4 @@ build_lscan=m
+ build_pknock=m
+ build_psd=m
+ build_quota2=m
++build_rtsp=m
diff --git a/package/network/utils/xtables-addons/patches/.svn/text-base/101-rtsp-linux-3.6-compat.patch.svn-base b/package/network/utils/xtables-addons/patches/.svn/text-base/101-rtsp-linux-3.6-compat.patch.svn-base
new file mode 100644
index 0000000..b8e08b3
--- /dev/null
+++ b/package/network/utils/xtables-addons/patches/.svn/text-base/101-rtsp-linux-3.6-compat.patch.svn-base
@@ -0,0 +1,22 @@
+--- a/extensions/rtsp/nf_conntrack_rtsp.c
++++ b/extensions/rtsp/nf_conntrack_rtsp.c
+@@ -28,6 +28,7 @@
+ * - Port to new NF API
+ */
+
++#include <linux/version.h>
+ #include <linux/module.h>
+ #include <linux/netfilter.h>
+ #include <linux/ip.h>
+@@ -496,7 +497,11 @@ init(void)
+ } else {
+ sprintf(tmpname, "rtsp-%d", i);
+ }
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)
++ strncpy(hlpr->name, tmpname, sizeof(hlpr->name));
++#else
+ hlpr->name = tmpname;
++#endif
+
+ pr_debug("port #%d: %d\n", i, ports[i]);
+
diff --git a/package/network/utils/xtables-addons/patches/.svn/text-base/102-rtsp-linux-3.7-compat.patch.svn-base b/package/network/utils/xtables-addons/patches/.svn/text-base/102-rtsp-linux-3.7-compat.patch.svn-base
new file mode 100644
index 0000000..0fe7917
--- /dev/null
+++ b/package/network/utils/xtables-addons/patches/.svn/text-base/102-rtsp-linux-3.7-compat.patch.svn-base
@@ -0,0 +1,155 @@
+--- a/extensions/rtsp/nf_conntrack_rtsp.c
++++ b/extensions/rtsp/nf_conntrack_rtsp.c
+@@ -73,7 +73,7 @@ static DEFINE_SPINLOCK(rtsp_buffer_lock)
+ static struct nf_conntrack_expect_policy rtsp_exp_policy;
+
+ unsigned int (*nf_nat_rtsp_hook)(struct sk_buff *skb,
+- enum ip_conntrack_info ctinfo,
++ enum ip_conntrack_info ctinfo, unsigned int protoff,
+ unsigned int matchoff, unsigned int matchlen,struct ip_ct_rtsp_expect* prtspexp,
+ struct nf_conntrack_expect *exp);
+ void (*nf_nat_rtsp_hook_expectfn)(struct nf_conn *ct, struct nf_conntrack_expect *exp);
+@@ -269,7 +269,7 @@ void expected(struct nf_conn *ct, struct
+
+ static inline int
+ help_out(struct sk_buff *skb, unsigned char *rb_ptr, unsigned int datalen,
+- struct nf_conn *ct, enum ip_conntrack_info ctinfo)
++ struct nf_conn *ct, enum ip_conntrack_info ctinfo, unsigned int protoff)
+ {
+ struct ip_ct_rtsp_expect expinfo;
+
+@@ -353,7 +353,7 @@ help_out(struct sk_buff *skb, unsigned c
+ nf_nat_rtsp = rcu_dereference(nf_nat_rtsp_hook);
+ if (nf_nat_rtsp && ct->status & IPS_NAT_MASK)
+ /* pass the request off to the nat helper */
+- ret = nf_nat_rtsp(skb, ctinfo, hdrsoff, hdrslen, &expinfo, exp);
++ ret = nf_nat_rtsp(skb, ctinfo, protoff, hdrsoff, hdrslen, &expinfo, exp);
+ else if (nf_ct_expect_related(exp) != 0) {
+ pr_info("nf_conntrack_expect_related failed\n");
+ ret = NF_DROP;
+@@ -420,7 +420,7 @@ static int help(struct sk_buff *skb, uns
+
+ switch (CTINFO2DIR(ctinfo)) {
+ case IP_CT_DIR_ORIGINAL:
+- ret = help_out(skb, rb_ptr, datalen, ct, ctinfo);
++ ret = help_out(skb, rb_ptr, datalen, ct, ctinfo, protoff);
+ break;
+ case IP_CT_DIR_REPLY:
+ pr_debug("IP_CT_DIR_REPLY\n");
+--- a/extensions/rtsp/nf_conntrack_rtsp.h
++++ b/extensions/rtsp/nf_conntrack_rtsp.h
+@@ -50,6 +50,7 @@ struct ip_ct_rtsp_expect
+
+ extern unsigned int (*nf_nat_rtsp_hook)(struct sk_buff *skb,
+ enum ip_conntrack_info ctinfo,
++ unsigned int protoff,
+ unsigned int matchoff, unsigned int matchlen,
+ struct ip_ct_rtsp_expect *prtspexp,
+ struct nf_conntrack_expect *exp);
+--- a/extensions/rtsp/nf_nat_rtsp.c
++++ b/extensions/rtsp/nf_nat_rtsp.c
+@@ -32,10 +32,10 @@
+
+ #include <linux/module.h>
+ #include <net/tcp.h>
++#include <net/netfilter/nf_conntrack_expect.h>
+ #include <net/netfilter/nf_nat_helper.h>
+-#include <net/netfilter/nf_nat_rule.h>
++#include <net/netfilter/nf_nat.h>
+ #include "nf_conntrack_rtsp.h"
+-#include <net/netfilter/nf_conntrack_expect.h>
+
+ #include <linux/inet.h>
+ #include <linux/ctype.h>
+@@ -102,8 +102,8 @@ get_skb_tcpdata(struct sk_buff* skb, cha
+ static int
+ rtsp_mangle_tran(enum ip_conntrack_info ctinfo,
+ struct nf_conntrack_expect* exp,
+- struct ip_ct_rtsp_expect* prtspexp,
+- struct sk_buff* skb, uint tranoff, uint tranlen)
++ struct ip_ct_rtsp_expect* prtspexp,
++ struct sk_buff* skb, uint protoff, uint tranoff, uint tranlen)
+ {
+ char* ptcp;
+ uint tcplen;
+@@ -256,7 +256,7 @@ rtsp_mangle_tran(enum ip_conntrack_info
+ if (dstact == DSTACT_STRIP || (dstact == DSTACT_AUTO && !is_stun))
+ {
+ diff = nextfieldoff-off;
+- if (!nf_nat_mangle_tcp_packet(skb, ct, ctinfo,
++ if (!nf_nat_mangle_tcp_packet(skb, ct, ctinfo, protoff,
+ off, diff, NULL, 0))
+ {
+ /* mangle failed, all we can do is bail */
+@@ -326,7 +326,7 @@ rtsp_mangle_tran(enum ip_conntrack_info
+ * parameter 4 below is offset from start of tcp data.
+ */
+ diff = origlen-rbuflen;
+- if (!nf_nat_mangle_tcp_packet(skb, ct, ctinfo,
++ if (!nf_nat_mangle_tcp_packet(skb, ct, ctinfo, protoff,
+ origoff, origlen, rbuf, rbuflen))
+ {
+ /* mangle failed, all we can do is bail */
+@@ -351,7 +351,7 @@ rtsp_mangle_tran(enum ip_conntrack_info
+ }
+
+ static uint
+-help_out(struct sk_buff *skb, enum ip_conntrack_info ctinfo,
++help_out(struct sk_buff *skb, enum ip_conntrack_info ctinfo, unsigned int protoff,
+ unsigned int matchoff, unsigned int matchlen, struct ip_ct_rtsp_expect* prtspexp,
+ struct nf_conntrack_expect* exp)
+ {
+@@ -389,7 +389,7 @@ help_out(struct sk_buff *skb, enum ip_co
+ {
+ uint oldtcplen = tcplen;
+ pr_debug("hdr: Transport\n");
+- if (!rtsp_mangle_tran(ctinfo, exp, prtspexp, skb, lineoff, linelen))
++ if (!rtsp_mangle_tran(ctinfo, exp, prtspexp, skb, protoff, lineoff, linelen))
+ {
+ pr_debug("hdr: Transport mangle failed");
+ break;
+@@ -407,7 +407,7 @@ help_out(struct sk_buff *skb, enum ip_co
+ }
+
+ static unsigned int
+-help(struct sk_buff *skb, enum ip_conntrack_info ctinfo,
++help(struct sk_buff *skb, enum ip_conntrack_info ctinfo, unsigned int protoff,
+ unsigned int matchoff, unsigned int matchlen, struct ip_ct_rtsp_expect* prtspexp,
+ struct nf_conntrack_expect* exp)
+ {
+@@ -417,7 +417,7 @@ help(struct sk_buff *skb, enum ip_conntr
+ switch (dir)
+ {
+ case IP_CT_DIR_ORIGINAL:
+- rc = help_out(skb, ctinfo, matchoff, matchlen, prtspexp, exp);
++ rc = help_out(skb, ctinfo, protoff, matchoff, matchlen, prtspexp, exp);
+ break;
+ case IP_CT_DIR_REPLY:
+ pr_debug("unmangle ! %u\n", ctinfo);
+@@ -432,7 +432,7 @@ help(struct sk_buff *skb, enum ip_conntr
+
+ static void expected(struct nf_conn* ct, struct nf_conntrack_expect *exp)
+ {
+- struct nf_nat_ipv4_multi_range_compat mr;
++ struct nf_nat_range nr;
+ u_int32_t newdstip, newsrcip, newip;
+
+ struct nf_conn *master = ct->master;
+@@ -446,12 +446,13 @@ static void expected(struct nf_conn* ct,
+ pr_debug("newsrcip=%pI4, newdstip=%pI4, newip=%pI4\n",
+ &newsrcip, &newdstip, &newip);
+
+- mr.rangesize = 1;
++ memset(&nr, 0, sizeof(nr));
++
+ // We don't want to manip the per-protocol, just the IPs.
+- mr.range[0].flags = NF_NAT_RANGE_MAP_IPS;
+- mr.range[0].min_ip = mr.range[0].max_ip = newip;
++ nr.flags = NF_NAT_RANGE_MAP_IPS;
++ nr.min_addr.ip = nr.max_addr.ip = newip;
+
+- nf_nat_setup_info(ct, &mr.range[0], NF_NAT_MANIP_DST);
++ nf_nat_setup_info(ct, &nr, NF_NAT_MANIP_DST);
+ }
+
+
diff --git a/package/network/utils/xtables-addons/patches/.svn/text-base/200-add-lua-packetscript.patch.svn-base b/package/network/utils/xtables-addons/patches/.svn/text-base/200-add-lua-packetscript.patch.svn-base
new file mode 100644
index 0000000..c2731b7
--- /dev/null
+++ b/package/network/utils/xtables-addons/patches/.svn/text-base/200-add-lua-packetscript.patch.svn-base
@@ -0,0 +1,18230 @@
+--- /dev/null
++++ b/extensions/LUA/byte_array.c
+@@ -0,0 +1,145 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre@dergraf.org>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++#include "controller.h"
++
++/* Initialization helper function. This function should be used whenever
++ * a new byte array need to be initialized. Depending on the arguments it
++ * initializes the array in a different way. Have a look at the inline
++ * comments */
++lua_packet_segment * init_byte_array(lua_State *L, unsigned char * start, int length, int do_copy)
++{
++ lua_packet_segment *array;
++
++ if (length < 0)
++ luaL_error(L, "init_byte_array, requested size < 0");
++
++ if (start && do_copy) {
++ /* we have a start address where we copy from */
++ array = lua_newuserdata(L, sizeof(lua_packet_segment) + length);
++ array->start = (unsigned char *)array + sizeof(lua_packet_segment); /* aligning pointer */
++ memcpy(array->start, start, length);
++ }else if (start && !do_copy) {
++ /* just link the start pointer, in this case you have to free the memory yourself */
++ array = lua_newuserdata(L, sizeof(lua_packet_segment));
++ array->start = start;
++ }else{
++ /* create an empty array, fully managed by Lua */
++ array = lua_newuserdata(L, sizeof(lua_packet_segment) + length);
++ array->start = (unsigned char *)array + sizeof(lua_packet_segment); /* aligning pointer */
++ memset(array->start, 0, length);
++ }
++
++ array->length = length;
++ array->offset = 0;
++ array->changes = NULL;
++
++ luaL_getmetatable(L, LUA_BYTE_ARRAY);
++ lua_setmetatable(L, -2);
++
++ return array;
++}
++
++
++
++/* LUA_API: get one byte of the given byte array
++ * access-pattern: array[<index>] */
++static int32_t get_byte_array(lua_State *L)
++{
++ lua_packet_segment * array = checkbytearray(L, 1);
++ int32_t index = luaL_checkinteger(L, 2); /* array starts with index 0 (not 1 as usual in Lua) */
++
++ luaL_argcheck(L, 0 <= index && index < array->length, 1, "index out of range");
++ lua_pushinteger(L, (array->start + array->offset)[index]);
++
++ return 1;
++}
++
++/* LUA_API: set one byte of the given byte array
++ * access-pattern: array[<index>]= 0xFF */
++static int32_t set_byte_array(lua_State *L)
++{
++ lua_packet_segment * array = checkbytearray(L, 1);
++ uint8_t byte;
++ int32_t index = luaL_checkinteger(L, 2); /* array starts with index 0 (not 1 as usual in Lua) */
++ int32_t val = luaL_checkinteger(L, 3);
++ uint32_t nob = 1 << CHAR_BIT; /* we should use something like 1 << CHAR_BIT */
++
++ luaL_argcheck(L, 0 <= index && index < array->length, 1, "index out of range");
++ luaL_argcheck(L, 0 <= val && val < nob, 2, "cannot cast value to char");
++
++ byte = (uint8_t)val;
++
++ (array->start + array->offset)[index] = byte;
++
++ return 0;
++}
++
++/* LUA_API: get size of the given byte array
++ * access-pattern: #array (__length meta-method) */
++static int32_t get_byte_array_size(lua_State *L)
++{
++ lua_packet_segment * array = checkbytearray(L, 1);
++
++ lua_pushnumber(L, array->length);
++
++ return 1;
++}
++
++
++/* LUA_API: converts a given byte array to a string.
++ * access-pattern: implicit through functions calling the
++ * __to_string() metamethod , e.g. print32_t */
++static int32_t byte_array_to_string(lua_State *L)
++{
++ lua_packet_segment * array = checkbytearray(L, 1);
++ uint8_t buf[(array->length * 3) + 255];
++ uint8_t hexval[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
++ char res[255 + (array->length * 3)]; /* make sure the buffer is big enough*/
++ int32_t i, n;
++ uint8_t *ptr = array->start + array->offset;
++
++ for (i = 0; i < array->length; i++) {
++ buf[i * 3] = hexval[(ptr[i] >> 4) & 0xF];
++ buf[(i * 3) + 1] = hexval[ptr[i] & 0x0F];
++ buf[(i * 3) + 2] = ' '; /* seperator */
++ }
++
++ buf[array->length * 3] = '\0';
++ n = sprintf(res, "byte_array: length: %d value: %s", array->length, buf);
++
++ lua_pushlstring(L, res, n);
++
++ return 1;
++}
++
++static const struct luaL_Reg bytearray_lib_m [] = {
++ { "__len", get_byte_array_size },
++ { "__newindex", set_byte_array },
++ { "__index", get_byte_array },
++ { "__tostring", byte_array_to_string },
++ { NULL, NULL }
++};
++
++void luaopen_bytearraylib(lua_State *L)
++{
++ luaL_newmetatable(L, LUA_BYTE_ARRAY);
++ luaL_register(L, NULL, bytearray_lib_m);
++ lua_pop(L, 1);
++}
++
++
+--- /dev/null
++++ b/extensions/LUA/controller.c
+@@ -0,0 +1,604 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre@dergraf.org>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++
++#if defined(__KERNEL__)
++ #include <linux/mm.h>
++#endif
++#include "controller.h"
++
++/* the array 'supported_protocols' holds all pointers to the
++ * static and dynamic protocol buffers. It is filled by the
++ * call to register_protbuf */
++static struct protocol_buf * supported_protocols[MAX_NR_OF_PROTOCOLS];
++
++/* C_API: the function 'get_protocol_buf' returns the pointer
++ * to the protocol buffer of a given protocol id. */
++struct protocol_buf * get_protocol_buf(uint32_t protocol_id)
++{
++ return (struct protocol_buf *)supported_protocols[protocol_id];
++}
++
++
++/* LUA_INT: the function 'gc_packet_segment' is triggered by the
++ * garbage collector whenever a userdata annotated with one of
++ * the protocol buffer metatable should be collected. */
++static int32_t gc_packet_segment(lua_State *L)
++{
++ lua_packet_segment * seg = (lua_packet_segment *)lua_touserdata(L, 1);
++ if (seg && seg->changes) {
++ seg->changes->ref_count--;
++ if (seg->changes->ref_count <= 0) {
++ kfree(seg->changes->field_length_changes);
++ kfree(seg->changes->field_offset_changes);
++ kfree(seg->changes);
++ seg->changes = NULL;
++ }
++ }
++ return 0;
++}
++
++
++/* LUA_API: the function 'set_raw' is used to set the bytes of a segment
++ * in 'raw' mode. The function is per default available in each protocol
++ * buffer until it gets overridden by a specific setter function inside
++ * a protocol buffer.
++ *
++ * Parameters:
++ * 1. lua_packet_segment (implicit)
++ * 2. int32_t byte_value
++ *
++ * Upvalues:
++ * 1. struct protocol_buf*
++ * 2. int32_t field index, not used in this function
++ *
++ * Return: void
++ */
++static int32_t set_raw(lua_State *L)
++{
++ int32_t i;
++ uint32_t nob;
++ uint8_t byte;
++ uint8_t *ptr;
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ int32_t val = luaL_checkinteger(L, 2);
++
++ nob = 1 << CHAR_BIT;
++
++ luaL_argcheck(L, 0 <= val && val < nob, 2, "cannot cast value to char");
++
++ byte = (uint8_t)val;
++ ptr = seg->start + seg->offset;
++
++ for (i = 0; i < seg->length; i++)
++ ptr[i] = byte;
++
++ return 0;
++}
++
++/* LUA_API: the function 'get_raw' is used to get the bytes of a segment
++ * in 'raw' mode. The function is per default available in each protocol
++ * buffer until it gets overridden by a specific getter function inside
++ * a protocol buffer.
++ *
++ * Parameters:
++ * 1. lua_packet_segment (implicit)
++ * 2. uint32_t offset
++ * 3. uint32_t length
++ *
++ * Upvalues:
++ * 1. struct protocol_buf*
++ * 2. int32_t field index, not used in this function
++ *
++ * Return:
++ * the byte array representing the given array
++ */
++static int32_t get_raw(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ init_byte_array(L, seg->start + seg->offset, seg->length, 1);
++
++ return 1;
++}
++/* LUA_API: The function 'get_segment' is used to get a new segment in 'raw' mode.
++ * Typically this function is applied on another raw segment in order
++ * to extract a part of the segment as new segment.
++ *
++ * Parameters:
++ * 1. lua_packet_segment, implicit through object oriented access seg:raw(..)
++ * 2. uint32_t offset, this indicates where to start the new segment, see e.g below.
++ * 3. uint32_t length, this indicates the size of the new segment
++ *
++ * Upvalues:
++ * 1. struct protocol_buf*
++ * 2. int32_t field index, not used in this function
++ *
++ * Return:
++ * 1. A lua_packet_segment annotated with the according metatable or False in
++ * case the input data is not valid
++ *
++ * Example:
++ *
++ * +------------------------+---------------------------------------+
++ * | function call | resulting lua_packet_segment |
++ * +========================+===+===+===+===+===+===+===+===+===+===+
++ * | seg = packet:raw(0,10) | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
++ * +------------------------+---+---+---+---+---+---+---+---+---+---+
++ * | 1st_half = seg:raw(0,5)| 0 | 1 | 2 | 3 | 4 | |
++ * +------------------------+---+---+---+---+---+---+---+---+---+---+
++ * | 2nd_half = seg:raw(5,5)| | 5 | 6 | 7 | 8 | 9 |
++ * +------------------------+-------------------+---+---+---+---+---+
++ */
++static int32_t get_segment(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++ uint32_t offset = luaL_checkinteger(L, 2);
++ uint32_t length = luaL_checkinteger(L, 3);
++ lua_packet_segment * new = (lua_packet_segment *)lua_newuserdata(L, sizeof(lua_packet_segment));
++
++ new->start = seg->start;
++ new->offset = seg->offset + offset;
++ new->changes = NULL;
++ /* we allow a seg->length == 0 , this enables processing packets where the packetsize is not fixed (0 = not fixed)*/
++ if (seg->length != 0 && length > seg->length) {
++ lua_pushboolean(L, 0);
++ return 1;
++ }
++
++ new->length = length;
++ luaL_getmetatable(L, prot_buf->name);
++ lua_setmetatable(L, -2);
++
++ return 1;
++}
++
++/* LUA_API: the function 'get_segment_size' is used to get the size of a segment.
++ *
++ * Parameters:
++ * 1. lua_packet_segment, implicit through object oriented access seg:raw(..)
++ *
++ * Upvalues:
++ * 1. struct protocol_buf*
++ * 2. int32_t field index, not used in this function
++ *
++ * Return:
++ * 1. Size as lua_Number
++ */
++static int32_t get_segment_size(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ lua_pushnumber(L, seg->length);
++ return 1;
++}
++
++/* LUA_API: the function 'get_segment_offset' is used to get the real offset
++ * of a segment. This function returns the offset of the segment to the start
++ * of the buffer. This means the following
++ * seg1 = packet:raw(2,10)
++ * seg2 = seg1:raw(3,5)
++ * offset = seg2:get_offset()
++ *
++ * will give an offset of 5, since the seg1 starts at offset 2, and seg2 starts
++ * at offset (seg1:get_offset() + 3).
++ *
++ * Parameters:
++ * 1. lua_packet_segment, implicit through object oriented access seg:raw(..)
++ *
++ * Upvalues:
++ * 1. struct protocol_buf*
++ * 2. int32_t field index, not used in this function
++ *
++ * Return:
++ * 1. Offset as lua_Number
++ */
++static int32_t get_segment_offset(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ lua_pushnumber(L, seg->offset);
++ return 1;
++}
++
++/* LUA_API: overwrites the __tostring function of a lua_packet_segment.
++ * this will print32_t a nicely formated string, including length,
++ * offset and name of the protocol buffer.
++ *
++ * Parameters:
++ * 1. lua_packet_segment (implicit)
++ *
++ * Returns:
++ * 1. the representing string
++ */
++static int32_t packet_segment_tostring(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++ int32_t n;
++ char buf[128];
++
++ n = sprintf(buf, "type: %s, offset: %d, length: %d", prot_buf->name, seg->offset, seg->length);
++ lua_pushlstring(L, buf, n);
++
++ return 1;
++}
++
++
++static const struct luaL_Reg seg_access_functions [] = {
++ { "set", set_raw },
++ { "get", get_raw },
++ { "raw", get_segment },
++ { "get_offset", get_segment_offset },
++ { "get_size", get_segment_size },
++ { "to_bytes", get_raw },
++ { "__tostring", packet_segment_tostring },
++ { "__gc", gc_packet_segment },
++ { NULL, NULL }
++};
++
++/* C_API: the function 'get_metatable_from_protocol_type' is a helper
++ * used in controller.c as well as it may find usage in the static
++ * protocol buffers and byte array implementation. */
++void get_metatable_from_protocol_type(lua_State *L, int32_t type)
++{
++ char * table;
++ lua_getglobal(L, SUPPORTED_PROTOCOL_TABLE);
++ lua_rawgeti(L, -1, type);
++ table = (char *)luaL_checkstring(L, -1);
++ lua_pop(L, 2); /* pop the table SUPPORTED_PROTOCOL_TABLE and the string pushed by lua_gettable */
++ luaL_getmetatable(L, table);
++ return;
++}
++
++/* C_INT: the function 'payload_contains_protocol' is used internally.
++ * Depending if static or dynamic protocol buffer it calls the right
++ * validation function. */
++static int32_t payload_contains_protocol(lua_State *L, struct protocol_buf *prot_buf, lua_packet_segment *seg, uint32_t prot_type)
++{
++ if (prot_buf->is_dynamic)
++ return has_protocol_dynamic(L, prot_buf, seg, prot_type);
++ else
++ return prot_buf->has_protocol(L, prot_buf, seg, prot_type);
++}
++
++/* C_INT: the function 'protocol_get_field_changes' is used interally.
++ * It requests the field_changes struct calling the protocol buffers
++ * 'get_field_changes' function. This funciton is called, whenever
++ * the payload field with a given protocol type is requested inside
++ * the function 'get_protocol_field' */
++static struct field_changes * protocol_get_field_changes(lua_State *L, struct protocol_buf *prot_buf, lua_packet_segment * seg)
++{
++ struct field_changes * changes = NULL;
++
++ if (prot_buf->get_field_changes) {
++ if (prot_buf->is_dynamic)
++ changes = get_field_changes_dynamic(L, prot_buf, seg);
++ else
++ changes = prot_buf->get_field_changes(L, seg);
++ /* is already 1 when set by helper 'get_allocated_field_changes,
++ * since not every prot_buf may use this function we enforce it. */
++ changes->ref_count = 1;
++ }
++ return changes;
++}
++
++/* C_INT: the function 'get_field_offset_in_bytes' wrapps the logic of
++ * calculating the new length with considering the optional field_changes. */
++static int32_t get_field_offset_in_bytes(struct protocol_field * field, lua_packet_segment * seg, int32_t field_index)
++{
++ uint32_t nr_of_bits, nr_of_bytes, field_offset;
++
++ field_offset = field->offset;
++ /* do we need to manipulate the default values stored inside the protocol buffer ?? */
++ if (seg->changes)
++ field_offset += seg->changes->field_offset_changes[field_index];
++ /* how many bits remain */
++ nr_of_bits = field_offset & (CHAR_BIT - 1);
++ /* assuming CHAR_BIT == 2 ^ 3 */
++ nr_of_bytes = (field_offset - nr_of_bits) >> 3;
++
++ return seg->offset + nr_of_bytes;
++}
++
++/* C_INT: the function 'get_field_length_in_bytes' wrapps the logic of
++ * calculating the new offset with considering the optional field_changes. */
++static int32_t get_field_length_in_bytes(struct protocol_field * field, lua_packet_segment * seg, int32_t field_index)
++{
++ uint32_t nr_of_bits, nr_of_bytes, field_length;
++
++ field_length = field->length;
++ /* if the field length is smaller than 1 byte, we take the size of one byte
++ * we treat the case where field_length == 0 in a special way ...*/
++ if (field_length < CHAR_BIT && field_length > 0)
++ field_length = CHAR_BIT;
++
++ /* do we need to manipulate the default values stored inside the protocol buffer ?? */
++ if (seg->changes)
++ field_length += seg->changes->field_length_changes[field_index];
++ /* how many bits remain */
++ nr_of_bits = field_length & (CHAR_BIT - 1);
++ /* assuming CHAR_BIT == 2 ^ 3 */
++ nr_of_bytes = (field_length - nr_of_bits) >> 3;
++ return nr_of_bytes;
++}
++
++/* C_INT: the function 'initialize_field_getter_and_setter' initializes
++ * the setter and getter function of the field, considering the optional
++ * field manipulator functions defined inside the protocol buffers. */
++static void initialize_field_getter_and_setter(lua_State *L, struct protocol_buf *prot_buf, int32_t field_index)
++{
++ /* lets check if there is a metatable on top of the stack */
++ struct protocol_field * f = (struct protocol_field *)&prot_buf->protocol_fields[field_index];
++
++ if (!lua_istable(L, -1)) luaL_error(L, "cannot initialize getter and setter for field %s->%s, "
++ "not a table on top of the stack, is '%s'", prot_buf->name, f->name, lua_typename(L, lua_type(L, -1)));
++
++ /* is there a 'getter' to initialize ? */
++ lua_pushlightuserdata(L, prot_buf); /* push upvalue 1 */
++ lua_pushinteger(L, field_index); /* push upvalue 2 */
++ if (f->get) {
++ if (prot_buf->is_dynamic)
++ lua_pushcclosure(L, field_dynamic_getter, 2);
++ else
++ lua_pushcclosure(L, f->get, 2);
++ }else
++ /* there is no specific getter defined - fall back to 'get_raw' */
++ lua_pushcclosure(L, get_raw, 2);
++ /* set the metatable field 'get' */
++ lua_setfield(L, -2, "get");
++
++ /* is there a 'setter' to initialize ? */
++ lua_pushlightuserdata(L, prot_buf); /* push upvalue 1 */
++ lua_pushinteger(L, field_index); /* push upvalue 2 */
++ if (f->set) {
++ if (prot_buf->is_dynamic)
++ lua_pushcclosure(L, field_dynamic_setter, 2);
++ else
++ lua_pushcclosure(L, f->set, 2);
++ }else
++ /* there is no specific setter defined - fall back to 'set_raw' */
++ lua_pushcclosure(L, set_raw, 2);
++ /* set the metatable field 'set' */
++ lua_setfield(L, -2, "set");
++}
++
++/* LUA_API: 'get_protocol_field' is used in Lua as a closure for each field of a protocol
++ * buffer. E.g a call to ip = packet:data(packet_ip) will go to this function,
++ * and trigger the conversion of the raw packet to a ip packet. Each call
++ * to a field function of an IP packet, like ip:daddr() uses this function
++ * to to return the right data. In each case you will end up either with a
++ * new packet segment (annotated with the proper metatable) or a boolean
++ * value (False) if something went wrong. In the case everything went fine,
++ * the newly created lua_packet_segment is annotated with the proper
++ * metatable where the fields get and set also contain the specific getter
++ * and setter functions given by the protocol buffer. E.g. the function call
++ * ip:daddr():get() or ip:daddr():set(...) will call the proper function
++ * defined inside the corresponding field definition.
++ *
++ * Parameters:
++ * 1. lua_packet_segment, implicit through object oriented access seg:raw(..)
++ * 2. type of the protocol buffer, optional, and only used if the accessed
++ * field is the payload field. If a type is provided for the access of the
++ * payload field, the function tries to convert the data pointed to by the
++ * payload field to the given type. To check if such a conversion is
++ * possible, it calls the function pointed to by the protocol buffer member
++ * has_protocol. If this function returns True, the conversion takes place.
++ *
++ * Upvalues:
++ * 1. struct protocol_buf*
++ * 2. int32_t field index
++ *
++ * Return:
++ * 1. A lua_packet_segment annotated with the according metatable or False in
++ * case the input data is not valid
++ */
++static int32_t get_protocol_field(lua_State *L)
++{
++ int32_t prot_type;
++ lua_packet_segment * seg, *new;
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ int32_t field_index = lua_tointeger(L, lua_upvalueindex(2));
++ struct protocol_field * field = &prot_buf->protocol_fields[field_index];
++
++ /* get the current packet segment */
++ seg = checkpacketseg(L, 1, prot_buf->name);
++
++ /* initialize the new packet segment */
++ new = (lua_packet_segment *)lua_newuserdata(L, sizeof(lua_packet_segment));
++ new->start = seg->start; /* the start is unchanged */
++ new->offset = get_field_offset_in_bytes(field, seg, field_index);
++ new->length = get_field_length_in_bytes(field, seg, field_index);
++
++ /* if new->length == 0 then no configuration was done, we guess the size by subtracting the
++ * new offset from the packet length. since the old length is getting initialized by the
++ * netfilter extension this assumption holds for the very last field of the protocol.
++ * this 'feature' should be used by protocol buffers containing a payload, whereas the
++ * payload field is the last field of the buffer. However, at compile-time unknown field
++ * sizes (and offsets) of fields not being placed at the end of the protocol should be
++ * initialized using the 'get_field_changes' hook system. */
++ if (new->length == 0)
++ new->length = (seg->length + seg->offset) - (new->offset);
++ /*
++ printf("%s->%s:: seg->offset %i, seg->length %i, new->offset %i, new->length %i\n",
++ prot_buf->name, field->name, seg->offset, seg->length, new->offset, new->length);
++ */
++ /* special care for packet payload requests */
++ if (prot_buf->payload_field != NULL && strcmp(prot_buf->payload_field, field->name) == 0) {
++ /* we know the payload field is requested */
++ /* the requested payload can be delivered either as a common segment or as
++ * an other packet type, such a conversion needs an extra protocol parameter
++ * ... so lets check */
++
++ if (lua_isnumber(L, 2)) {
++ /* we have an extra parameter, ... lets see if it is a valid protocol
++ * the parameter is the index of the 'supported_protocols'-array member */
++ prot_type = lua_tointeger(L, 2);
++ if (prot_type >= 0 && prot_type < PACKET_SENTINEL) {
++ /* we are sure the purpose of the request is to get the payload data,
++ * converted to the given protocol. lets check if the payload contains
++ * data of the given protocol */
++ if (payload_contains_protocol(L, prot_buf, seg, prot_type)) {
++ /* success, we can push the metatable for the given protocol */
++ get_metatable_from_protocol_type(L, prot_type);
++ if (!lua_isnil(L, -1)) /* check if the metatable was found */
++ /* perhaps the field offsets and lengths of the containing protocol
++ * are not set correctly. request the optional 'field_changes' structure
++ * holding the changes for lengths and offsets. */
++ new->changes = protocol_get_field_changes(L, get_protocol_buf(prot_type), new);
++ else{
++ /* failed, the requested protocol is not available
++ * we push false and return */
++ lua_pop(L, 1); /* pop the userdata */
++ lua_pushboolean(L, 0);
++ return 1;
++ }
++ }else{
++ /* payload does not carry the provided protocol */
++ /* we push false and return */
++ lua_pop(L, 1); /* pop the userdata */
++ lua_pushboolean(L, 0);
++ return 1;
++ }
++ }else{
++ /* unknown protocol */
++ lua_pop(L, 1); /* pop the userdata */
++ luaL_error(L, "provided protocol is unknown");
++ }
++ }
++ }
++
++ /* if there is still the 'new' userdata on the top, we push our own metatable */
++ if (lua_isuserdata(L, -1)) {
++ luaL_getmetatable(L, prot_buf->name);
++ new->changes = seg->changes;
++ if (seg->changes)
++ new->changes->ref_count++;
++ }
++
++ /* a new packet segment is at index -2 , and the proper metatable at index -1 of the stack
++ * lets set the propper setter and getter function for the requested field */
++ initialize_field_getter_and_setter(L, prot_buf, field_index);
++
++ lua_setmetatable(L, -2);
++ return 1;
++}
++
++/* C_API: 'register_protbuf' is only used internally. This function takes a
++ * pointer to a fully initialized protocol buffer struct and registers it
++ * inside the Lua state. Registering means:
++ *
++ * 1. it creates a new metatable with the name of the protocol buffer.
++ * 2. it registers the default functions which are stored in the luaL_Reg
++ * array seg_access_functions.
++ * 3. it loops over the protocol fields stored at prot_buf->protocol_fields
++ * and registers a new function (using the field name) inside the
++ * metatable. Each field points to the function 'get_protocol_field'
++ * which acts as a closure taking a pointer to the protocol buffer as
++ * well as the index of the field as upvalues.
++ * 4. The protocol index, serves as numerical identifier of this protocol
++ * buffer or even of the protocol itself. This index is stored as a
++ * global value inside the Lua state as well as inside the Lua table
++ * 'supported_protocols'. Assuming the name of a procotol buffer is
++ * "packet_ip" the following statements are true:
++ *
++ * supported_protocols[protocol_index] == "packet_ip"
++ * packet_ip == protocol_index
++ *
++ * This allows you to get all registered protocols from within Lua. This
++ * is especially usefull for the dynamic protocol buffers where you have
++ * to provide your own "has_protocol"-function, which probably needs the
++ * information on which protocols it is able to contain.
++ */
++void register_protbuf(lua_State *L, struct protocol_buf * prot_buf, uint32_t protocol_index)
++{
++ int32_t field_index;
++ luaL_Reg *reg = (struct luaL_Reg *)seg_access_functions;
++ struct protocol_field * field = prot_buf->protocol_fields;
++
++ luaL_newmetatable(L, prot_buf->name);
++
++ /* metatable.__index = metatable */
++ lua_pushvalue(L, -1); /* duplicates the metatable */
++ lua_setfield(L, -2, "__index");
++
++ /* pushing default functions */
++ for (; reg->name; reg++) {
++ lua_pushlightuserdata(L, (void *)prot_buf);
++ lua_pushcclosure(L, reg->func, 1);
++ lua_setfield(L, -2, reg->name);
++ }
++
++ /* pushing functions specific to the protocol buffer */
++ for (field_index = 0; field->name; field++, field_index++) {
++ lua_pushlightuserdata(L, (void *)prot_buf); /* upvalue: prot_buf */
++ lua_pushinteger(L, field_index); /* upvalue: index of protocol field */
++ lua_pushcclosure(L, get_protocol_field, 2);
++ lua_setfield(L, -2, field->name);
++ }
++ /* pop the metatable */
++ lua_pop(L, 1);
++
++ /* registering the array-index as the protocol_id*/
++ lua_getglobal(L, "_G");
++ lua_pushinteger(L, protocol_index);
++ lua_setfield(L, -2, prot_buf->name);
++ lua_pop(L, 1); /* pop _G */
++
++ lua_getglobal(L, SUPPORTED_PROTOCOL_TABLE);
++ lua_pushstring(L, prot_buf->name);
++ lua_rawseti(L, -2, protocol_index);
++
++ lua_pop(L, 1); /* pop SUPPORTED_PROTOCOL_TABLE */
++
++ supported_protocols[protocol_index] = prot_buf;
++}
++
++void luaopen_controller(lua_State *L)
++{
++ /* registering a table inside the _G with table[protocol_index] = prot_buf->name */
++ lua_getglobal(L, "_G");
++ lua_newtable(L);
++ lua_setfield(L, -2, SUPPORTED_PROTOCOL_TABLE);
++ lua_pop(L, 1); /* pop _G */
++
++ luaopen_protbuf_raw(L);
++ luaopen_protbuf_eth(L);
++ luaopen_protbuf_ip(L);
++ luaopen_protbuf_icmp(L);
++ luaopen_protbuf_tcp(L);
++ luaopen_protbuf_tcp_options(L);
++ luaopen_protbuf_udp(L);
++ luaopen_protbuf_tftp(L);
++ luaopen_protbuf_dynamic(L);
++ /* should follow all other static buffers */
++#if defined(__KERNEL__)
++ luaopen_nflib(L);
++#endif
++
++ luaopen_bytearraylib(L);
++}
++
++
++
++
+--- /dev/null
++++ b/extensions/LUA/controller.h
+@@ -0,0 +1,264 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre@dergraf.org>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++
++#ifndef CONTROLLER_H_
++#define CONTROLLER_H_
++
++#include "stdlib.h" /* wrapper */
++#include "string.h" /* wrapper */
++#include "lua.h"
++#include "lualib.h"
++#include "lauxlib.h"
++
++#if defined(__KERNEL__)
++#include <linux/skbuff.h>
++#include <linux/slab.h>
++#include <linux/vmalloc.h>
++#endif
++
++
++/* to compile the stuff in userspace (for testing)*/
++#if !defined(__KERNEL__)
++#include <stdint.h>
++#define pr_debug printf;
++
++#define kmalloc(size, type) malloc(size)
++#define kfree(ptr) free(ptr)
++
++#endif
++
++
++/**********************************************************************/
++/* nf Lua configuration */
++/**********************************************************************/
++#define MAX_NR_OF_PROTOCOLS 16
++#define SUPPORTED_PROTOCOL_TABLE "supported_protocols"
++
++#define MAX_NR_OF_FIELDS_IN_DYN_PROT_BUF 32
++
++
++/**********************************************************************/
++/* Static Protocol Buffer configuration */
++/**********************************************************************/
++
++/* the definitions of the stringified expression of the prot_bufs...
++ * make sure all static prot_bufs are listed and are unique */
++#define LUA_PACKET_SEG_RAW "packet_raw"
++#define LUA_PACKET_SEG_ETH "packet_eth"
++#define LUA_PACKET_SEG_ICMP "packet_icmp"
++#define LUA_PACKET_SEG_IP "packet_ip"
++#define LUA_PACKET_SEG_TCP "packet_tcp"
++#define LUA_PACKET_SEG_TCP_OPT "packet_tcp_opt"
++#define LUA_PACKET_SEG_UDP "packet_udp"
++#define LUA_PACKET_SEG_TFTP "packet_tftp"
++
++/* the enum holding all static prot_bufs... make sure it contains all
++ * static prot_bufs */
++enum PROT_BUF {
++ PACKET_RAW,
++ PACKET_ETH,
++ PACKET_IP,
++ PACKET_ICMP,
++ PACKET_TCP,
++ PACKET_TCP_OPTIONS,
++ PACKET_UDP,
++ PACKET_TFTP,
++ PACKET_DYNAMIC,
++ PACKET_SENTINEL
++};
++
++/* the luaopen-function of the prot_bufs... make sure it is called
++ * inside luaopen_controller */
++void luaopen_protbuf_raw(lua_State *L);
++void luaopen_protbuf_eth(lua_State *L);
++void luaopen_protbuf_ip(lua_State *L);
++void luaopen_protbuf_icmp(lua_State *L);
++void luaopen_protbuf_tcp(lua_State *L);
++void luaopen_protbuf_tcp_options(lua_State *L);
++void luaopen_protbuf_udp(lua_State *L);
++void luaopen_protbuf_tftp(lua_State *L);
++void luaopen_protbuf_dynamic(lua_State *L);
++
++/**********************************************************************/
++/* field changes */
++/**********************************************************************/
++struct field_changes {
++ int ref_count;
++ int *field_length_changes;
++ int *field_offset_changes;
++};
++
++/**********************************************************************/
++/* lua packet segment */
++/* ------------------ */
++/* The struct lua_packet_segment is the integral part of a Lua packet.*/
++/* At the very beginning, when a new packet arrives in `lua_tg`_ such */
++/* a struct is initialized. The field start then points to the lowest */
++/* available header inside the sk_buff structure. During packet */
++/* processing the start pointer remains the same, only the offset and */
++/* length value change. */
++/**********************************************************************/
++#define checkpacketseg(L, i, seg_type) \
++ (lua_packet_segment *)luaL_checkudata(L, i, seg_type)
++
++typedef struct lua_packet_segment {
++ unsigned int offset;
++ unsigned int length;
++ struct field_changes * changes;
++ unsigned char * start; /* need to be at the end because of the memory alignment */
++} lua_packet_segment;
++
++/**********************************************************************/
++/* protocol field */
++/* -------------- */
++/* This structure is a container for the field definitions used by the*/
++/* protocol buffer. Each protocol field is expressed using this struct*/
++/* Have a look at the protocol buffers to see how the struct gets */
++/* initialized. */
++/* */
++/* name: */
++/* This member expresses the name of the field, ending */
++/* in its own Lua function to access the field. */
++/* offset / length: */
++/* These members do specify the position inside the protocol header */
++/* in bits (not bytes!). */
++/* get / set: */
++/* The get and set functions take a function pointer pointing to the*/
++/* specific getter and setter function for this field. */
++/**********************************************************************/
++struct protocol_field {
++ const char * name;
++ uint32_t offset;
++ uint32_t length;
++ lua_CFunction get;
++ lua_CFunction set;
++};
++#define PROT_FIELD_SENTINEL { NULL, 0, 0, NULL, NULL }
++
++
++/**********************************************************************/
++/* protocol_buf */
++/**********************************************************************/
++/* This structure is a container for all the information needed for a
++ * protocol buffer. It gets initialized in each protocol buffer header
++ * file or for the dynamic protocol buffers on runtime using the
++ * 'register_dynamic_protocol_buffer' function.
++ *
++ * name:
++ * This member is used throughout the system. It is also exported
++ * to Lua as a variable name holding the index of the 'supported_protocols'
++ * array. The name is also used as the name of the generated Lua
++ * metatable, that is why inside the macro checkpacketseg_ it
++ * is always the name of a protocol buffer that is passed as the
++ * second parameter.
++ * payload_field:
++ * This member holds the string of the field responsible for payload
++ * data. The payload field of a protocol has an extra property, since
++ * it can be used to invoke another protocol buffer that is applied to
++ * the payload content.
++ * has_protocol:
++ * This member is used together with the payload_field. Since we must
++ * be sure that the payload content does really contain a protocol
++ * of type X. The function pointed to by has_protocol checks if the
++ * protocol buffer X can be applied on the payload_data.
++ * protocol_fields:
++ * This member points to the array of 'protocol_field' structures
++ * get_field_changes:
++ * This member is optional. It is used to return a pointer to an initialized
++ * field_changes struct. The function is called, whenever the payload field
++ * is requested with a given protocol type. Usually this function will
++ * initialize the field_changes struct depending on the content of the
++ * payload data. e.g.
++ * tcp = ip:data(packet_tcp)
++ * such a request will call the 'get_field_changes' function of the tcp
++ * protocol buffer. This enables, that the tcp options field have the proper
++ * length as well as the tcp data start at the right offset.
++ */
++struct protocol_buf {
++ int is_dynamic;
++ const char * name;
++ char * payload_field;
++ int (*has_protocol)(lua_State *L, struct protocol_buf *prot_buf, lua_packet_segment * seg, int type);
++ struct protocol_field * protocol_fields;
++ struct field_changes * (*get_field_changes)(lua_State *L, lua_packet_segment * seg);
++};
++
++/**********************************************************************/
++/* lua byte array library */
++/**********************************************************************/
++#define LUA_BYTE_ARRAY "byte_array"
++#define checkbytearray(L, i) \
++ (lua_packet_segment *)luaL_checkudata(L, i, LUA_BYTE_ARRAY)
++lua_packet_segment * init_byte_array(lua_State *L, unsigned char * start, int length, int do_copy);
++void luaopen_bytearraylib(lua_State *L);
++
++
++/**********************************************************************/
++/* lua netfilter environment library */
++/**********************************************************************/
++#define NETFILTER_LIB "nf"
++#if defined(__KERNEL__)
++ struct lua_env {
++ lua_State *L;
++ /* perhaps more to come here (e.g. a state per CPU) */
++ };
++ #define LUA_ENV "lua_env"
++ #define checkluaenv(L, i) \
++ (struct lua_env *)luaL_checkudata(L, i, LUA_ENV)
++
++ void luaopen_nflib(lua_State *L);
++#endif
++
++void cleanup_dynamic_prot_bufs(void); /* freeing all dynamic prot bufs */
++/**********************************************************************/
++/* lua protbuf helpers */
++/**********************************************************************/
++int get_1_bit_generic(lua_State *L);
++int set_1_bit_generic(lua_State *L);
++int get_lower_4_bit_generic(lua_State *L);
++int set_lower_4_bit_generic(lua_State *L);
++int get_upper_4_bit_generic(lua_State *L);
++int set_upper_4_bit_generic(lua_State *L);
++int get_8_bit_generic(lua_State *L);
++int set_8_bit_generic(lua_State *L);
++int get_16_bit_generic(lua_State *L);
++int set_16_bit_generic(lua_State *L);
++int get_32_bit_generic(lua_State *L);
++int set_32_bit_generic(lua_State *L);
++int set_data_generic(lua_State *L);
++int get_string_generic(lua_State *L);
++int get_byte_generic_str(lua_State *L);
++struct field_changes * get_allocated_field_changes(lua_State *L, int nr_of_fields);
++
++/* only used by the dynamic prot buf subsystem */
++#define MAX_NR_OF_DYN_PROT_BUFS 16
++int field_dynamic_setter(lua_State *L);
++int field_dynamic_getter(lua_State *L);
++int has_protocol_dynamic(lua_State *L, struct protocol_buf * prot_buf, lua_packet_segment * seg, int type);
++struct field_changes * get_field_changes_dynamic(lua_State *L, struct protocol_buf *prot_buf, lua_packet_segment * seg);
++
++/**********************************************************************/
++/* lua controller API */
++/**********************************************************************/
++void luaopen_controller(lua_State *L);
++struct protocol_buf * get_protocol_buf(unsigned int protocol_id);
++void get_metatable_from_protocol_type(lua_State *L, int type);
++void register_protbuf(lua_State *L, struct protocol_buf * prot_buf, unsigned int protocol_index);
++
++
++#endif /* CONTROLLER_H_ */
+--- /dev/null
++++ b/extensions/LUA/Kbuild
+@@ -0,0 +1,49 @@
++# -*- Makefile -*-
++
++# Adding debug options
++EXTRA_CFLAGS += -DDEBUG
++
++obj-m += xt_LUA.o
++
++EXTRA_CFLAGS += -I$(src)/prot_buf_new
++xt_LUA-y += xt_LUA_target.o \
++
++xt_LUA-y += nf_lua.o \
++ prot_buf_helpers.o \
++ byte_array.o \
++ controller.o \
++ prot_buf_ethernet.o \
++ prot_buf_icmp.o \
++ prot_buf_ip.o \
++ prot_buf_raw.o \
++ prot_buf_tcp.o \
++ prot_buf_udp.o \
++ prot_buf_tftp.o \
++ prot_buf_dynamic.o \
++
++
++# Adding Lua Support
++EXTRA_CFLAGS += -I$(src)/lua -I$(src)/lua/include
++xt_LUA-y += lua/lapi.o \
++ lua/lbaselib.o \
++ lua/lcode.o \
++ lua/ldebug.o \
++ lua/ldo.o \
++ lua/ldump.o \
++ lua/lfunc.o \
++ lua/lgc.o \
++ lua/llex.o \
++ lua/lmem.o \
++ lua/lobject.o \
++ lua/lopcodes.o \
++ lua/lparser.o \
++ lua/lstate.o \
++ lua/lstring.o \
++ lua/lstrlib.o \
++ lua/ltable.o \
++ lua/ltablib.o \
++ lua/ltm.o \
++ lua/lundump.o \
++ lua/lvm.o \
++ lua/lzio.o \
++ lua/lauxlib.o \
+--- /dev/null
++++ b/extensions/LUA/libxt_LUA.c
+@@ -0,0 +1,191 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre@dergraf.org>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++
++#include <getopt.h>
++#include <stdio.h>
++#include <stdbool.h>
++#include <stdlib.h>
++#include <string.h>
++#include <xtables.h>
++#include <linux/netfilter.h>
++#include <linux/netfilter/x_tables.h>
++#include "xt_LUA.h"
++
++enum {
++ FLAG_SCRIPT = 1 << 0,
++ FLAG_STATE = 1 << 1,
++ FLAG_FUNCTION = 1 << 2,
++};
++
++static const struct option lua_tg_opts[] = {
++ { .name = "script", .has_arg = true, .val = 's' },
++ { .name = "state", .has_arg = true, .val = 'l' },
++ { .name = "function", .has_arg = true, .val = 'f' },
++ { NULL },
++};
++
++
++static void lua_tg_help(void)
++{
++ printf(
++ "LUA target options:\n"
++ " --script SCRIPT Process packet with the Lua script given by SCRIPT\n"
++ " \n"
++ " --state ID Process packet within the Lua state given by ID.\n"
++ " Omitting --state infers the ID 0, which can be\n"
++ " refered to the 'global' state.\n"
++ " \n"
++ " --function FUNCTION Name of the function that processes the Lua packet\n"
++ "\n");
++}
++
++static void
++lua_tg_init(struct xt_entry_target *target)
++{
++ struct xt_lua_tginfo *info = (void *)target->data;
++
++ info->state_id = 0;
++ strncpy(info->function, "process_packet\0", sizeof("process_packet\0"));
++}
++
++static int
++lua_tg_parse(int32_t c, char **argv, int32_t invert, uint32_t *flags,
++ const void *entry, struct xt_entry_target **target)
++{
++ struct xt_lua_tginfo *info = (void *)(*target)->data;
++ char buf[MAX_SCRIPT_SIZE];
++ long script_size;
++ uint32_t state_id;
++ FILE *file;
++
++ switch (c) {
++ case 's':
++ if (*flags & FLAG_SCRIPT)
++ xtables_error(PARAMETER_PROBLEM,
++ "LUA: Cannot specify --script more than once");
++
++ if (strlen(optarg) > sizeof(info->filename))
++ xtables_error(PARAMETER_PROBLEM,
++ "LUA: Maximum script length is %zu",
++ sizeof(info->filename));
++
++ if (strchr(optarg, '\n'))
++ xtables_error(PARAMETER_PROBLEM,
++ "LUA: Newlines not allowed in script name");
++ file = fopen(optarg, "rb");
++ if (file != NULL) {
++ fseek(file, 0, SEEK_END);
++ script_size = ftell(file);
++ if (script_size > MAX_SCRIPT_SIZE)
++ xtables_error(PARAMETER_PROBLEM,
++ "LUA: The size of the script is too big");
++
++ fseek(file, 0, SEEK_SET);
++ fread(buf, script_size, 1, file);
++ fclose(file);
++ } else
++ xtables_error(PARAMETER_PROBLEM,
++ "LUA: Cannot open script %s", optarg);
++
++ strncpy(info->filename, optarg, sizeof(info->filename));
++ strncpy(info->buf, buf, sizeof(info->buf));
++ info->script_size = script_size;
++
++ *flags |= FLAG_SCRIPT;
++ return true;
++
++ case 'l':
++ if (*flags & FLAG_STATE)
++ xtables_error(PARAMETER_PROBLEM,
++ "LUA: Cannot specify --state more than once");
++
++ if (!xtables_strtoui(optarg, NULL, &state_id, 0, 8))
++ xtables_error(PARAMETER_PROBLEM,
++ "LUA: Invalid --state %s", optarg);
++
++ info->state_id = state_id;
++ *flags |= FLAG_STATE;
++ return true;
++
++ case 'f':
++ if (*flags & FLAG_FUNCTION)
++ xtables_error(PARAMETER_PROBLEM,
++ "LUA: Cannot specify --function more than once");
++ if (strlen(optarg) > sizeof(info->function))
++ xtables_error(PARAMETER_PROBLEM,
++ "LUA: Maximum function length is %zu",
++ sizeof(info->function));
++
++ if (strchr(optarg, '\n'))
++ xtables_error(PARAMETER_PROBLEM,
++ "LUA: Newlines not allowed in function name");
++
++ strncpy(info->function, optarg, sizeof(info->function));
++
++ *flags |= FLAG_FUNCTION;
++ return true;
++ }
++
++ return false;
++}
++
++static void
++lua_tg_check(uint32_t flags)
++{
++ if (flags == 0)
++ xtables_error(PARAMETER_PROBLEM, "LUA: --script parameter required");
++}
++
++static void
++lua_tg_print(const void *entry, const struct xt_entry_target *target,
++ int32_t numeric)
++{
++ const struct xt_lua_tginfo *info = (const void *)target->data;
++
++ printf("LUA script: %s ", info->filename);
++}
++
++static void
++lua_tg_save(const void *entry, const struct xt_entry_target *target)
++{
++ const struct xt_lua_tginfo *info = (const void *)target->data;
++
++ printf("--script %s ", info->filename);
++}
++
++static struct xtables_target lua_tg_reg = {
++ .name = "LUA",
++ .version = XTABLES_VERSION,
++ .revision = 0,
++ .family = NFPROTO_UNSPEC,
++ .size = XT_ALIGN(sizeof(struct xt_lua_tginfo)),
++ .userspacesize = XT_ALIGN(sizeof(struct xt_lua_tginfo)),
++ .help = lua_tg_help,
++ .init = lua_tg_init,
++ .parse = lua_tg_parse,
++ .final_check = lua_tg_check,
++ .print = lua_tg_print,
++ .save = lua_tg_save,
++ .extra_opts = lua_tg_opts,
++};
++
++static __attribute__((constructor)) void lua_tg_ldr(void)
++{
++ xtables_register_target(&lua_tg_reg);
++}
++
+--- /dev/null
++++ b/extensions/LUA/libxt_LUA.man
+@@ -0,0 +1 @@
++Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
+--- /dev/null
++++ b/extensions/LUA/lua/include/ctype.h
+@@ -0,0 +1,11 @@
++#include <linux/ctype.h>
++#undef isalnum
++#define isalnum(c) (((__ismask(c)&(_U|_L|_D)) != 0) && (c > 0))
++#undef isalpha
++#define isalpha(c) (((__ismask(c)&(_U|_L)) != 0) && (c > 0))
++#undef iscntrl
++#define iscntrl(c) (((__ismask(c)&(_C)) != 0) && (c > 0))
++#undef isdigit
++#define isdigit(c) (((__ismask(c)&(_D)) != 0) && (c > 0))
++#undef isspace
++#define isspace(c) (((__ismask(c)&(_S)) != 0) && (c > 0))
+--- /dev/null
++++ b/extensions/LUA/lua/include/errno.h
+@@ -0,0 +1 @@
++#include <linux/errno.h>
+--- /dev/null
++++ b/extensions/LUA/lua/include/locale.h
+@@ -0,0 +1,5 @@
++struct lconv {
++ char * decimal_point ;
++} ;
++
++#define localeconv() NULL
+--- /dev/null
++++ b/extensions/LUA/lua/include/setjmp.h
+@@ -0,0 +1,26 @@
++/*
++ * arch/um/include/sysdep-i386/archsetjmp.h
++ */
++
++#ifndef _KLIBC_ARCHSETJMP_H
++#define _KLIBC_ARCHSETJMP_H
++
++struct __jmp_buf {
++ unsigned int __ebx;
++ unsigned int __esp;
++ unsigned int __ebp;
++ unsigned int __esi;
++ unsigned int __edi;
++ unsigned int __eip;
++};
++
++typedef struct __jmp_buf jmp_buf[1];
++
++#define JB_IP __eip
++#define JB_SP __esp
++
++int setjmp(jmp_buf);
++void longjmp(jmp_buf, int);
++
++#endif /* _SETJMP_H */
++
+--- /dev/null
++++ b/extensions/LUA/lua/include/stdio.h
+@@ -0,0 +1 @@
++#include <linux/kernel.h>
+--- /dev/null
++++ b/extensions/LUA/lua/include/stdlib.h
+@@ -0,0 +1,7 @@
++#include <linux/kernel.h>
++
++#define exit(E) return
++#define strtoul simple_strtoul
++#define strcoll strcmp
++
++#define CHAR_BIT 8
+--- /dev/null
++++ b/extensions/LUA/lua/include/string.h
+@@ -0,0 +1 @@
++#include <linux/string.h>
+--- /dev/null
++++ b/extensions/LUA/lua/lapi.c
+@@ -0,0 +1,1086 @@
++/*
++** $Id: lapi.c,v 2.55.1.5 2008/07/04 18:41:18 roberto Exp $
++** Lua API
++** See Copyright Notice in lua.h
++*/
++
++#include <stdarg.h>
++#include <math.h>
++#include <assert.h>
++#include <string.h>
++
++#define lapi_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "lapi.h"
++#include "ldebug.h"
++#include "ldo.h"
++#include "lfunc.h"
++#include "lgc.h"
++#include "lmem.h"
++#include "lobject.h"
++#include "lstate.h"
++#include "lstring.h"
++#include "ltable.h"
++#include "ltm.h"
++#include "lundump.h"
++#include "lvm.h"
++
++
++
++const char lua_ident[] =
++ "$Lua: " LUA_RELEASE " " LUA_COPYRIGHT " $\n"
++ "$Authors: " LUA_AUTHORS " $\n"
++ "$URL: www.lua.org $\n";
++
++
++
++#define api_checknelems(L, n) api_check(L, (n) <= (L->top - L->base))
++
++#define api_checkvalidindex(L, i) api_check(L, (i) != luaO_nilobject)
++
++#define api_incr_top(L) {api_check(L, L->top < L->ci->top); L->top++;}
++
++
++
++static TValue *index2adr (lua_State *L, int idx) {
++ if (idx > 0) {
++ TValue *o = L->base + (idx - 1);
++ api_check(L, idx <= L->ci->top - L->base);
++ if (o >= L->top) return cast(TValue *, luaO_nilobject);
++ else return o;
++ }
++ else if (idx > LUA_REGISTRYINDEX) {
++ api_check(L, idx != 0 && -idx <= L->top - L->base);
++ return L->top + idx;
++ }
++ else switch (idx) { /* pseudo-indices */
++ case LUA_REGISTRYINDEX: return registry(L);
++ case LUA_ENVIRONINDEX: {
++ Closure *func = curr_func(L);
++ sethvalue(L, &L->env, func->c.env);
++ return &L->env;
++ }
++ case LUA_GLOBALSINDEX: return gt(L);
++ default: {
++ Closure *func = curr_func(L);
++ idx = LUA_GLOBALSINDEX - idx;
++ return (idx <= func->c.nupvalues)
++ ? &func->c.upvalue[idx-1]
++ : cast(TValue *, luaO_nilobject);
++ }
++ }
++}
++
++
++static Table *getcurrenv (lua_State *L) {
++ if (L->ci == L->base_ci) /* no enclosing function? */
++ return hvalue(gt(L)); /* use global table as environment */
++ else {
++ Closure *func = curr_func(L);
++ return func->c.env;
++ }
++}
++
++
++void luaA_pushobject (lua_State *L, const TValue *o) {
++ setobj2s(L, L->top, o);
++ api_incr_top(L);
++}
++
++
++LUA_API int lua_checkstack (lua_State *L, int size) {
++ int res = 1;
++ lua_lock(L);
++ if (size > LUAI_MAXCSTACK || (L->top - L->base + size) > LUAI_MAXCSTACK)
++ res = 0; /* stack overflow */
++ else if (size > 0) {
++ luaD_checkstack(L, size);
++ if (L->ci->top < L->top + size)
++ L->ci->top = L->top + size;
++ }
++ lua_unlock(L);
++ return res;
++}
++
++
++LUA_API void lua_xmove (lua_State *from, lua_State *to, int n) {
++ int i;
++ if (from == to) return;
++ lua_lock(to);
++ api_checknelems(from, n);
++ api_check(from, G(from) == G(to));
++ api_check(from, to->ci->top - to->top >= n);
++ from->top -= n;
++ for (i = 0; i < n; i++) {
++ setobj2s(to, to->top++, from->top + i);
++ }
++ lua_unlock(to);
++}
++
++
++LUA_API void lua_setlevel (lua_State *from, lua_State *to) {
++ to->nCcalls = from->nCcalls;
++}
++
++
++LUA_API lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf) {
++ lua_CFunction old;
++ lua_lock(L);
++ old = G(L)->panic;
++ G(L)->panic = panicf;
++ lua_unlock(L);
++ return old;
++}
++
++
++LUA_API lua_State *lua_newthread (lua_State *L) {
++ lua_State *L1;
++ lua_lock(L);
++ luaC_checkGC(L);
++ L1 = luaE_newthread(L);
++ setthvalue(L, L->top, L1);
++ api_incr_top(L);
++ lua_unlock(L);
++ luai_userstatethread(L, L1);
++ return L1;
++}
++
++
++
++/*
++** basic stack manipulation
++*/
++
++
++LUA_API int lua_gettop (lua_State *L) {
++ return cast_int(L->top - L->base);
++}
++
++
++LUA_API void lua_settop (lua_State *L, int idx) {
++ lua_lock(L);
++ if (idx >= 0) {
++ api_check(L, idx <= L->stack_last - L->base);
++ while (L->top < L->base + idx)
++ setnilvalue(L->top++);
++ L->top = L->base + idx;
++ }
++ else {
++ api_check(L, -(idx+1) <= (L->top - L->base));
++ L->top += idx+1; /* `subtract' index (index is negative) */
++ }
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_remove (lua_State *L, int idx) {
++ StkId p;
++ lua_lock(L);
++ p = index2adr(L, idx);
++ api_checkvalidindex(L, p);
++ while (++p < L->top) setobjs2s(L, p-1, p);
++ L->top--;
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_insert (lua_State *L, int idx) {
++ StkId p;
++ StkId q;
++ lua_lock(L);
++ p = index2adr(L, idx);
++ api_checkvalidindex(L, p);
++ for (q = L->top; q>p; q--) setobjs2s(L, q, q-1);
++ setobjs2s(L, p, L->top);
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_replace (lua_State *L, int idx) {
++ StkId o;
++ lua_lock(L);
++ /* explicit test for incompatible code */
++ if (idx == LUA_ENVIRONINDEX && L->ci == L->base_ci)
++ luaG_runerror(L, "no calling environment");
++ api_checknelems(L, 1);
++ o = index2adr(L, idx);
++ api_checkvalidindex(L, o);
++ if (idx == LUA_ENVIRONINDEX) {
++ Closure *func = curr_func(L);
++ api_check(L, ttistable(L->top - 1));
++ func->c.env = hvalue(L->top - 1);
++ luaC_barrier(L, func, L->top - 1);
++ }
++ else {
++ setobj(L, o, L->top - 1);
++ if (idx < LUA_GLOBALSINDEX) /* function upvalue? */
++ luaC_barrier(L, curr_func(L), L->top - 1);
++ }
++ L->top--;
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_pushvalue (lua_State *L, int idx) {
++ lua_lock(L);
++ setobj2s(L, L->top, index2adr(L, idx));
++ api_incr_top(L);
++ lua_unlock(L);
++}
++
++
++
++/*
++** access functions (stack -> C)
++*/
++
++
++LUA_API int lua_type (lua_State *L, int idx) {
++ StkId o = index2adr(L, idx);
++ return (o == luaO_nilobject) ? LUA_TNONE : ttype(o);
++}
++
++
++LUA_API const char *lua_typename (lua_State *L, int t) {
++ UNUSED(L);
++ return (t == LUA_TNONE) ? "no value" : luaT_typenames[t];
++}
++
++
++LUA_API int lua_iscfunction (lua_State *L, int idx) {
++ StkId o = index2adr(L, idx);
++ return iscfunction(o);
++}
++
++
++LUA_API int lua_isnumber (lua_State *L, int idx) {
++ TValue n;
++ const TValue *o = index2adr(L, idx);
++ return tonumber(o, &n);
++}
++
++
++LUA_API int lua_isstring (lua_State *L, int idx) {
++ int t = lua_type(L, idx);
++ return (t == LUA_TSTRING || t == LUA_TNUMBER);
++}
++
++
++LUA_API int lua_isuserdata (lua_State *L, int idx) {
++ const TValue *o = index2adr(L, idx);
++ return (ttisuserdata(o) || ttislightuserdata(o));
++}
++
++
++LUA_API int lua_rawequal (lua_State *L, int index1, int index2) {
++ StkId o1 = index2adr(L, index1);
++ StkId o2 = index2adr(L, index2);
++ return (o1 == luaO_nilobject || o2 == luaO_nilobject) ? 0
++ : luaO_rawequalObj(o1, o2);
++}
++
++
++LUA_API int lua_equal (lua_State *L, int index1, int index2) {
++ StkId o1, o2;
++ int i;
++ lua_lock(L); /* may call tag method */
++ o1 = index2adr(L, index1);
++ o2 = index2adr(L, index2);
++ i = (o1 == luaO_nilobject || o2 == luaO_nilobject) ? 0 : equalobj(L, o1, o2);
++ lua_unlock(L);
++ return i;
++}
++
++
++LUA_API int lua_lessthan (lua_State *L, int index1, int index2) {
++ StkId o1, o2;
++ int i;
++ lua_lock(L); /* may call tag method */
++ o1 = index2adr(L, index1);
++ o2 = index2adr(L, index2);
++ i = (o1 == luaO_nilobject || o2 == luaO_nilobject) ? 0
++ : luaV_lessthan(L, o1, o2);
++ lua_unlock(L);
++ return i;
++}
++
++
++
++LUA_API lua_Number lua_tonumber (lua_State *L, int idx) {
++ TValue n;
++ const TValue *o = index2adr(L, idx);
++ if (tonumber(o, &n))
++ return nvalue(o);
++ else
++ return 0;
++}
++
++
++LUA_API lua_Integer lua_tointeger (lua_State *L, int idx) {
++ TValue n;
++ const TValue *o = index2adr(L, idx);
++ if (tonumber(o, &n)) {
++ lua_Integer res;
++ lua_Number num = nvalue(o);
++ lua_number2integer(res, num);
++ return res;
++ }
++ else
++ return 0;
++}
++
++
++LUA_API int lua_toboolean (lua_State *L, int idx) {
++ const TValue *o = index2adr(L, idx);
++ return !l_isfalse(o);
++}
++
++
++LUA_API const char *lua_tolstring (lua_State *L, int idx, size_t *len) {
++ StkId o = index2adr(L, idx);
++ if (!ttisstring(o)) {
++ lua_lock(L); /* `luaV_tostring' may create a new string */
++ if (!luaV_tostring(L, o)) { /* conversion failed? */
++ if (len != NULL) *len = 0;
++ lua_unlock(L);
++ return NULL;
++ }
++ luaC_checkGC(L);
++ o = index2adr(L, idx); /* previous call may reallocate the stack */
++ lua_unlock(L);
++ }
++ if (len != NULL) *len = tsvalue(o)->len;
++ return svalue(o);
++}
++
++
++LUA_API size_t lua_objlen (lua_State *L, int idx) {
++ StkId o = index2adr(L, idx);
++ switch (ttype(o)) {
++ case LUA_TSTRING: return tsvalue(o)->len;
++ case LUA_TUSERDATA: return uvalue(o)->len;
++ case LUA_TTABLE: return luaH_getn(hvalue(o));
++ case LUA_TNUMBER: {
++ size_t l;
++ lua_lock(L); /* `luaV_tostring' may create a new string */
++ l = (luaV_tostring(L, o) ? tsvalue(o)->len : 0);
++ lua_unlock(L);
++ return l;
++ }
++ default: return 0;
++ }
++}
++
++
++LUA_API lua_CFunction lua_tocfunction (lua_State *L, int idx) {
++ StkId o = index2adr(L, idx);
++ return (!iscfunction(o)) ? NULL : clvalue(o)->c.f;
++}
++
++
++LUA_API void *lua_touserdata (lua_State *L, int idx) {
++ StkId o = index2adr(L, idx);
++ switch (ttype(o)) {
++ case LUA_TUSERDATA: return (rawuvalue(o) + 1);
++ case LUA_TLIGHTUSERDATA: return pvalue(o);
++ default: return NULL;
++ }
++}
++
++
++LUA_API lua_State *lua_tothread (lua_State *L, int idx) {
++ StkId o = index2adr(L, idx);
++ return (!ttisthread(o)) ? NULL : thvalue(o);
++}
++
++
++LUA_API const void *lua_topointer (lua_State *L, int idx) {
++ StkId o = index2adr(L, idx);
++ switch (ttype(o)) {
++ case LUA_TTABLE: return hvalue(o);
++ case LUA_TFUNCTION: return clvalue(o);
++ case LUA_TTHREAD: return thvalue(o);
++ case LUA_TUSERDATA:
++ case LUA_TLIGHTUSERDATA:
++ return lua_touserdata(L, idx);
++ default: return NULL;
++ }
++}
++
++
++
++/*
++** push functions (C -> stack)
++*/
++
++
++LUA_API void lua_pushnil (lua_State *L) {
++ lua_lock(L);
++ setnilvalue(L->top);
++ api_incr_top(L);
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_pushnumber (lua_State *L, lua_Number n) {
++ lua_lock(L);
++ setnvalue(L->top, n);
++ api_incr_top(L);
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_pushinteger (lua_State *L, lua_Integer n) {
++ lua_lock(L);
++ setnvalue(L->top, cast_num(n));
++ api_incr_top(L);
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_pushlstring (lua_State *L, const char *s, size_t len) {
++ lua_lock(L);
++ luaC_checkGC(L);
++ setsvalue2s(L, L->top, luaS_newlstr(L, s, len));
++ api_incr_top(L);
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_pushstring (lua_State *L, const char *s) {
++ if (s == NULL)
++ lua_pushnil(L);
++ else
++ lua_pushlstring(L, s, strlen(s));
++}
++
++
++LUA_API const char *lua_pushvfstring (lua_State *L, const char *fmt,
++ va_list argp) {
++ const char *ret;
++ lua_lock(L);
++ luaC_checkGC(L);
++ ret = luaO_pushvfstring(L, fmt, argp);
++ lua_unlock(L);
++ return ret;
++}
++
++
++LUA_API const char *lua_pushfstring (lua_State *L, const char *fmt, ...) {
++ const char *ret;
++ va_list argp;
++ lua_lock(L);
++ luaC_checkGC(L);
++ va_start(argp, fmt);
++ ret = luaO_pushvfstring(L, fmt, argp);
++ va_end(argp);
++ lua_unlock(L);
++ return ret;
++}
++
++
++LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) {
++ Closure *cl;
++ lua_lock(L);
++ luaC_checkGC(L);
++ api_checknelems(L, n);
++ cl = luaF_newCclosure(L, n, getcurrenv(L));
++ cl->c.f = fn;
++ L->top -= n;
++ while (n--)
++ setobj2n(L, &cl->c.upvalue[n], L->top+n);
++ setclvalue(L, L->top, cl);
++ lua_assert(iswhite(obj2gco(cl)));
++ api_incr_top(L);
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_pushboolean (lua_State *L, int b) {
++ lua_lock(L);
++ setbvalue(L->top, (b != 0)); /* ensure that true is 1 */
++ api_incr_top(L);
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_pushlightuserdata (lua_State *L, void *p) {
++ lua_lock(L);
++ setpvalue(L->top, p);
++ api_incr_top(L);
++ lua_unlock(L);
++}
++
++
++LUA_API int lua_pushthread (lua_State *L) {
++ lua_lock(L);
++ setthvalue(L, L->top, L);
++ api_incr_top(L);
++ lua_unlock(L);
++ return (G(L)->mainthread == L);
++}
++
++
++
++/*
++** get functions (Lua -> stack)
++*/
++
++
++LUA_API void lua_gettable (lua_State *L, int idx) {
++ StkId t;
++ lua_lock(L);
++ t = index2adr(L, idx);
++ api_checkvalidindex(L, t);
++ luaV_gettable(L, t, L->top - 1, L->top - 1);
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_getfield (lua_State *L, int idx, const char *k) {
++ StkId t;
++ TValue key;
++ lua_lock(L);
++ t = index2adr(L, idx);
++ api_checkvalidindex(L, t);
++ setsvalue(L, &key, luaS_new(L, k));
++ luaV_gettable(L, t, &key, L->top);
++ api_incr_top(L);
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_rawget (lua_State *L, int idx) {
++ StkId t;
++ lua_lock(L);
++ t = index2adr(L, idx);
++ api_check(L, ttistable(t));
++ setobj2s(L, L->top - 1, luaH_get(hvalue(t), L->top - 1));
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_rawgeti (lua_State *L, int idx, int n) {
++ StkId o;
++ lua_lock(L);
++ o = index2adr(L, idx);
++ api_check(L, ttistable(o));
++ setobj2s(L, L->top, luaH_getnum(hvalue(o), n));
++ api_incr_top(L);
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_createtable (lua_State *L, int narray, int nrec) {
++ lua_lock(L);
++ luaC_checkGC(L);
++ sethvalue(L, L->top, luaH_new(L, narray, nrec));
++ api_incr_top(L);
++ lua_unlock(L);
++}
++
++
++LUA_API int lua_getmetatable (lua_State *L, int objindex) {
++ const TValue *obj;
++ Table *mt = NULL;
++ int res;
++ lua_lock(L);
++ obj = index2adr(L, objindex);
++ switch (ttype(obj)) {
++ case LUA_TTABLE:
++ mt = hvalue(obj)->metatable;
++ break;
++ case LUA_TUSERDATA:
++ mt = uvalue(obj)->metatable;
++ break;
++ default:
++ mt = G(L)->mt[ttype(obj)];
++ break;
++ }
++ if (mt == NULL)
++ res = 0;
++ else {
++ sethvalue(L, L->top, mt);
++ api_incr_top(L);
++ res = 1;
++ }
++ lua_unlock(L);
++ return res;
++}
++
++
++LUA_API void lua_getfenv (lua_State *L, int idx) {
++ StkId o;
++ lua_lock(L);
++ o = index2adr(L, idx);
++ api_checkvalidindex(L, o);
++ switch (ttype(o)) {
++ case LUA_TFUNCTION:
++ sethvalue(L, L->top, clvalue(o)->c.env);
++ break;
++ case LUA_TUSERDATA:
++ sethvalue(L, L->top, uvalue(o)->env);
++ break;
++ case LUA_TTHREAD:
++ setobj2s(L, L->top, gt(thvalue(o)));
++ break;
++ default:
++ setnilvalue(L->top);
++ break;
++ }
++ api_incr_top(L);
++ lua_unlock(L);
++}
++
++
++/*
++** set functions (stack -> Lua)
++*/
++
++
++LUA_API void lua_settable (lua_State *L, int idx) {
++ StkId t;
++ lua_lock(L);
++ api_checknelems(L, 2);
++ t = index2adr(L, idx);
++ api_checkvalidindex(L, t);
++ luaV_settable(L, t, L->top - 2, L->top - 1);
++ L->top -= 2; /* pop index and value */
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_setfield (lua_State *L, int idx, const char *k) {
++ StkId t;
++ TValue key;
++ lua_lock(L);
++ api_checknelems(L, 1);
++ t = index2adr(L, idx);
++ api_checkvalidindex(L, t);
++ setsvalue(L, &key, luaS_new(L, k));
++ luaV_settable(L, t, &key, L->top - 1);
++ L->top--; /* pop value */
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_rawset (lua_State *L, int idx) {
++ StkId t;
++ lua_lock(L);
++ api_checknelems(L, 2);
++ t = index2adr(L, idx);
++ api_check(L, ttistable(t));
++ setobj2t(L, luaH_set(L, hvalue(t), L->top-2), L->top-1);
++ luaC_barriert(L, hvalue(t), L->top-1);
++ L->top -= 2;
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_rawseti (lua_State *L, int idx, int n) {
++ StkId o;
++ lua_lock(L);
++ api_checknelems(L, 1);
++ o = index2adr(L, idx);
++ api_check(L, ttistable(o));
++ setobj2t(L, luaH_setnum(L, hvalue(o), n), L->top-1);
++ luaC_barriert(L, hvalue(o), L->top-1);
++ L->top--;
++ lua_unlock(L);
++}
++
++
++LUA_API int lua_setmetatable (lua_State *L, int objindex) {
++ TValue *obj;
++ Table *mt;
++ lua_lock(L);
++ api_checknelems(L, 1);
++ obj = index2adr(L, objindex);
++ api_checkvalidindex(L, obj);
++ if (ttisnil(L->top - 1))
++ mt = NULL;
++ else {
++ api_check(L, ttistable(L->top - 1));
++ mt = hvalue(L->top - 1);
++ }
++ switch (ttype(obj)) {
++ case LUA_TTABLE: {
++ hvalue(obj)->metatable = mt;
++ if (mt)
++ luaC_objbarriert(L, hvalue(obj), mt);
++ break;
++ }
++ case LUA_TUSERDATA: {
++ uvalue(obj)->metatable = mt;
++ if (mt)
++ luaC_objbarrier(L, rawuvalue(obj), mt);
++ break;
++ }
++ default: {
++ G(L)->mt[ttype(obj)] = mt;
++ break;
++ }
++ }
++ L->top--;
++ lua_unlock(L);
++ return 1;
++}
++
++
++LUA_API int lua_setfenv (lua_State *L, int idx) {
++ StkId o;
++ int res = 1;
++ lua_lock(L);
++ api_checknelems(L, 1);
++ o = index2adr(L, idx);
++ api_checkvalidindex(L, o);
++ api_check(L, ttistable(L->top - 1));
++ switch (ttype(o)) {
++ case LUA_TFUNCTION:
++ clvalue(o)->c.env = hvalue(L->top - 1);
++ break;
++ case LUA_TUSERDATA:
++ uvalue(o)->env = hvalue(L->top - 1);
++ break;
++ case LUA_TTHREAD:
++ sethvalue(L, gt(thvalue(o)), hvalue(L->top - 1));
++ break;
++ default:
++ res = 0;
++ break;
++ }
++ if (res) luaC_objbarrier(L, gcvalue(o), hvalue(L->top - 1));
++ L->top--;
++ lua_unlock(L);
++ return res;
++}
++
++
++/*
++** `load' and `call' functions (run Lua code)
++*/
++
++
++#define adjustresults(L,nres) \
++ { if (nres == LUA_MULTRET && L->top >= L->ci->top) L->ci->top = L->top; }
++
++
++#define checkresults(L,na,nr) \
++ api_check(L, (nr) == LUA_MULTRET || (L->ci->top - L->top >= (nr) - (na)))
++
++
++LUA_API void lua_call (lua_State *L, int nargs, int nresults) {
++ StkId func;
++ lua_lock(L);
++ api_checknelems(L, nargs+1);
++ checkresults(L, nargs, nresults);
++ func = L->top - (nargs+1);
++ luaD_call(L, func, nresults);
++ adjustresults(L, nresults);
++ lua_unlock(L);
++}
++
++
++
++/*
++** Execute a protected call.
++*/
++struct CallS { /* data to `f_call' */
++ StkId func;
++ int nresults;
++};
++
++
++static void f_call (lua_State *L, void *ud) {
++ struct CallS *c = cast(struct CallS *, ud);
++ luaD_call(L, c->func, c->nresults);
++}
++
++
++
++LUA_API int lua_pcall (lua_State *L, int nargs, int nresults, int errfunc) {
++ struct CallS c;
++ int status;
++ ptrdiff_t func;
++ lua_lock(L);
++ api_checknelems(L, nargs+1);
++ checkresults(L, nargs, nresults);
++ if (errfunc == 0)
++ func = 0;
++ else {
++ StkId o = index2adr(L, errfunc);
++ api_checkvalidindex(L, o);
++ func = savestack(L, o);
++ }
++ c.func = L->top - (nargs+1); /* function to be called */
++ c.nresults = nresults;
++ status = luaD_pcall(L, f_call, &c, savestack(L, c.func), func);
++ adjustresults(L, nresults);
++ lua_unlock(L);
++ return status;
++}
++
++
++/*
++** Execute a protected C call.
++*/
++struct CCallS { /* data to `f_Ccall' */
++ lua_CFunction func;
++ void *ud;
++};
++
++
++static void f_Ccall (lua_State *L, void *ud) {
++ struct CCallS *c = cast(struct CCallS *, ud);
++ Closure *cl;
++ cl = luaF_newCclosure(L, 0, getcurrenv(L));
++ cl->c.f = c->func;
++ setclvalue(L, L->top, cl); /* push function */
++ api_incr_top(L);
++ setpvalue(L->top, c->ud); /* push only argument */
++ api_incr_top(L);
++ luaD_call(L, L->top - 2, 0);
++}
++
++
++LUA_API int lua_cpcall (lua_State *L, lua_CFunction func, void *ud) {
++ struct CCallS c;
++ int status;
++ lua_lock(L);
++ c.func = func;
++ c.ud = ud;
++ status = luaD_pcall(L, f_Ccall, &c, savestack(L, L->top), 0);
++ lua_unlock(L);
++ return status;
++}
++
++
++LUA_API int lua_load (lua_State *L, lua_Reader reader, void *data,
++ const char *chunkname) {
++ ZIO z;
++ int status;
++ lua_lock(L);
++ if (!chunkname) chunkname = "?";
++ luaZ_init(L, &z, reader, data);
++ status = luaD_protectedparser(L, &z, chunkname);
++ lua_unlock(L);
++ return status;
++}
++
++
++LUA_API int lua_dump (lua_State *L, lua_Writer writer, void *data) {
++ int status;
++ TValue *o;
++ lua_lock(L);
++ api_checknelems(L, 1);
++ o = L->top - 1;
++ if (isLfunction(o))
++ status = luaU_dump(L, clvalue(o)->l.p, writer, data, 0);
++ else
++ status = 1;
++ lua_unlock(L);
++ return status;
++}
++
++
++LUA_API int lua_status (lua_State *L) {
++ return L->status;
++}
++
++
++/*
++** Garbage-collection function
++*/
++
++LUA_API int lua_gc (lua_State *L, int what, int data) {
++ int res = 0;
++ global_State *g;
++ lua_lock(L);
++ g = G(L);
++ switch (what) {
++ case LUA_GCSTOP: {
++ g->GCthreshold = MAX_LUMEM;
++ break;
++ }
++ case LUA_GCRESTART: {
++ g->GCthreshold = g->totalbytes;
++ break;
++ }
++ case LUA_GCCOLLECT: {
++ luaC_fullgc(L);
++ break;
++ }
++ case LUA_GCCOUNT: {
++ /* GC values are expressed in Kbytes: #bytes/2^10 */
++ res = cast_int(g->totalbytes >> 10);
++ break;
++ }
++ case LUA_GCCOUNTB: {
++ res = cast_int(g->totalbytes & 0x3ff);
++ break;
++ }
++ case LUA_GCSTEP: {
++ lu_mem a = (cast(lu_mem, data) << 10);
++ if (a <= g->totalbytes)
++ g->GCthreshold = g->totalbytes - a;
++ else
++ g->GCthreshold = 0;
++ while (g->GCthreshold <= g->totalbytes) {
++ luaC_step(L);
++ if (g->gcstate == GCSpause) { /* end of cycle? */
++ res = 1; /* signal it */
++ break;
++ }
++ }
++ break;
++ }
++ case LUA_GCSETPAUSE: {
++ res = g->gcpause;
++ g->gcpause = data;
++ break;
++ }
++ case LUA_GCSETSTEPMUL: {
++ res = g->gcstepmul;
++ g->gcstepmul = data;
++ break;
++ }
++ default: res = -1; /* invalid option */
++ }
++ lua_unlock(L);
++ return res;
++}
++
++
++
++/*
++** miscellaneous functions
++*/
++
++
++LUA_API int lua_error (lua_State *L) {
++ lua_lock(L);
++ api_checknelems(L, 1);
++ luaG_errormsg(L);
++ lua_unlock(L);
++ return 0; /* to avoid warnings */
++}
++
++
++LUA_API int lua_next (lua_State *L, int idx) {
++ StkId t;
++ int more;
++ lua_lock(L);
++ t = index2adr(L, idx);
++ api_check(L, ttistable(t));
++ more = luaH_next(L, hvalue(t), L->top - 1);
++ if (more) {
++ api_incr_top(L);
++ }
++ else /* no more elements */
++ L->top -= 1; /* remove key */
++ lua_unlock(L);
++ return more;
++}
++
++
++LUA_API void lua_concat (lua_State *L, int n) {
++ lua_lock(L);
++ api_checknelems(L, n);
++ if (n >= 2) {
++ luaC_checkGC(L);
++ luaV_concat(L, n, cast_int(L->top - L->base) - 1);
++ L->top -= (n-1);
++ }
++ else if (n == 0) { /* push empty string */
++ setsvalue2s(L, L->top, luaS_newlstr(L, "", 0));
++ api_incr_top(L);
++ }
++ /* else n == 1; nothing to do */
++ lua_unlock(L);
++}
++
++
++LUA_API lua_Alloc lua_getallocf (lua_State *L, void **ud) {
++ lua_Alloc f;
++ lua_lock(L);
++ if (ud) *ud = G(L)->ud;
++ f = G(L)->frealloc;
++ lua_unlock(L);
++ return f;
++}
++
++
++LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud) {
++ lua_lock(L);
++ G(L)->ud = ud;
++ G(L)->frealloc = f;
++ lua_unlock(L);
++}
++
++
++LUA_API void *lua_newuserdata (lua_State *L, size_t size) {
++ Udata *u;
++ lua_lock(L);
++ luaC_checkGC(L);
++ u = luaS_newudata(L, size, getcurrenv(L));
++ setuvalue(L, L->top, u);
++ api_incr_top(L);
++ lua_unlock(L);
++ return u + 1;
++}
++
++
++
++
++static const char *aux_upvalue (StkId fi, int n, TValue **val) {
++ Closure *f;
++ if (!ttisfunction(fi)) return NULL;
++ f = clvalue(fi);
++ if (f->c.isC) {
++ if (!(1 <= n && n <= f->c.nupvalues)) return NULL;
++ *val = &f->c.upvalue[n-1];
++ return "";
++ }
++ else {
++ Proto *p = f->l.p;
++ if (!(1 <= n && n <= p->sizeupvalues)) return NULL;
++ *val = f->l.upvals[n-1]->v;
++ return getstr(p->upvalues[n-1]);
++ }
++}
++
++
++LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n) {
++ const char *name;
++ TValue *val;
++ lua_lock(L);
++ name = aux_upvalue(index2adr(L, funcindex), n, &val);
++ if (name) {
++ setobj2s(L, L->top, val);
++ api_incr_top(L);
++ }
++ lua_unlock(L);
++ return name;
++}
++
++
++LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n) {
++ const char *name;
++ TValue *val;
++ StkId fi;
++ lua_lock(L);
++ fi = index2adr(L, funcindex);
++ api_checknelems(L, 1);
++ name = aux_upvalue(fi, n, &val);
++ if (name) {
++ L->top--;
++ setobj(L, val, L->top);
++ luaC_barrier(L, clvalue(fi), L->top);
++ }
++ lua_unlock(L);
++ return name;
++}
++
+--- /dev/null
++++ b/extensions/LUA/lua/lapi.h
+@@ -0,0 +1,16 @@
++/*
++** $Id: lapi.h,v 2.2.1.1 2007/12/27 13:02:25 roberto Exp $
++** Auxiliary functions from Lua API
++** See Copyright Notice in lua.h
++*/
++
++#ifndef lapi_h
++#define lapi_h
++
++
++#include "lobject.h"
++
++
++LUAI_FUNC void luaA_pushobject (lua_State *L, const TValue *o);
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/lauxlib.c
+@@ -0,0 +1,674 @@
++/*
++** $Id: lauxlib.c,v 1.159.1.3 2008/01/21 13:20:51 roberto Exp $
++** Auxiliary functions for building Lua libraries
++** See Copyright Notice in lua.h
++*/
++
++#include <stdarg.h>
++
++#if !defined(__KERNEL__)
++#include <ctype.h>
++#include <errno.h>
++#include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
++#else
++#include <linux/ctype.h>
++#include <linux/errno.h>
++#include <linux/kernel.h>
++#include <linux/slab.h>
++#include <linux/string.h>
++#endif
++
++/* This file uses only the official API of Lua.
++** Any function declared here could be written as an application function.
++*/
++
++#define lauxlib_c
++#define LUA_LIB
++
++#include "lua.h"
++
++#include "lauxlib.h"
++
++
++#define FREELIST_REF 0 /* free list of references */
++
++
++/* convert a stack index to positive */
++#define abs_index(L, i) ((i) > 0 || (i) <= LUA_REGISTRYINDEX ? (i) : \
++ lua_gettop(L) + (i) + 1)
++
++
++/*
++** {======================================================
++** Error-report functions
++** =======================================================
++*/
++
++
++LUALIB_API int luaL_argerror (lua_State *L, int narg, const char *extramsg) {
++ lua_Debug ar;
++ if (!lua_getstack(L, 0, &ar)) /* no stack frame? */
++ return luaL_error(L, "bad argument #%d (%s)", narg, extramsg);
++ lua_getinfo(L, "n", &ar);
++ if (strcmp(ar.namewhat, "method") == 0) {
++ narg--; /* do not count `self' */
++ if (narg == 0) /* error is in the self argument itself? */
++ return luaL_error(L, "calling " LUA_QS " on bad self (%s)",
++ ar.name, extramsg);
++ }
++ if (ar.name == NULL)
++ ar.name = "?";
++ return luaL_error(L, "bad argument #%d to " LUA_QS " (%s)",
++ narg, ar.name, extramsg);
++}
++
++
++LUALIB_API int luaL_typerror (lua_State *L, int narg, const char *tname) {
++ const char *msg = lua_pushfstring(L, "%s expected, got %s",
++ tname, luaL_typename(L, narg));
++ return luaL_argerror(L, narg, msg);
++}
++
++
++static void tag_error (lua_State *L, int narg, int tag) {
++ luaL_typerror(L, narg, lua_typename(L, tag));
++}
++
++
++LUALIB_API void luaL_where (lua_State *L, int level) {
++ lua_Debug ar;
++ if (lua_getstack(L, level, &ar)) { /* check function at level */
++ lua_getinfo(L, "Sl", &ar); /* get info about it */
++ if (ar.currentline > 0) { /* is there info? */
++ lua_pushfstring(L, "%s:%d: ", ar.short_src, ar.currentline);
++ return;
++ }
++ }
++ lua_pushliteral(L, ""); /* else, no information available... */
++}
++
++
++LUALIB_API int luaL_error (lua_State *L, const char *fmt, ...) {
++ va_list argp;
++ va_start(argp, fmt);
++ luaL_where(L, 1);
++ lua_pushvfstring(L, fmt, argp);
++ va_end(argp);
++ lua_concat(L, 2);
++ return lua_error(L);
++}
++
++/* }====================================================== */
++
++
++LUALIB_API int luaL_checkoption (lua_State *L, int narg, const char *def,
++ const char *const lst[]) {
++ const char *name = (def) ? luaL_optstring(L, narg, def) :
++ luaL_checkstring(L, narg);
++ int i;
++ for (i=0; lst[i]; i++)
++ if (strcmp(lst[i], name) == 0)
++ return i;
++ return luaL_argerror(L, narg,
++ lua_pushfstring(L, "invalid option " LUA_QS, name));
++}
++
++
++LUALIB_API int luaL_newmetatable (lua_State *L, const char *tname) {
++ lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get registry.name */
++ if (!lua_isnil(L, -1)) /* name already in use? */
++ return 0; /* leave previous value on top, but return 0 */
++ lua_pop(L, 1);
++ lua_newtable(L); /* create metatable */
++ lua_pushvalue(L, -1);
++ lua_setfield(L, LUA_REGISTRYINDEX, tname); /* registry.name = metatable */
++ return 1;
++}
++
++
++LUALIB_API void *luaL_checkudata (lua_State *L, int ud, const char *tname) {
++ void *p = lua_touserdata(L, ud);
++ if (p != NULL) { /* value is a userdata? */
++ if (lua_getmetatable(L, ud)) { /* does it have a metatable? */
++ lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get correct metatable */
++ if (lua_rawequal(L, -1, -2)) { /* does it have the correct mt? */
++ lua_pop(L, 2); /* remove both metatables */
++ return p;
++ }
++ }
++ }
++ luaL_typerror(L, ud, tname); /* else error */
++ return NULL; /* to avoid warnings */
++}
++
++
++LUALIB_API void luaL_checkstack (lua_State *L, int space, const char *mes) {
++ if (!lua_checkstack(L, space))
++ luaL_error(L, "stack overflow (%s)", mes);
++}
++
++
++LUALIB_API void luaL_checktype (lua_State *L, int narg, int t) {
++ if (lua_type(L, narg) != t)
++ tag_error(L, narg, t);
++}
++
++
++LUALIB_API void luaL_checkany (lua_State *L, int narg) {
++ if (lua_type(L, narg) == LUA_TNONE)
++ luaL_argerror(L, narg, "value expected");
++}
++
++
++LUALIB_API const char *luaL_checklstring (lua_State *L, int narg, size_t *len) {
++ const char *s = lua_tolstring(L, narg, len);
++ if (!s) tag_error(L, narg, LUA_TSTRING);
++ return s;
++}
++
++
++LUALIB_API const char *luaL_optlstring (lua_State *L, int narg,
++ const char *def, size_t *len) {
++ if (lua_isnoneornil(L, narg)) {
++ if (len)
++ *len = (def ? strlen(def) : 0);
++ return def;
++ }
++ else return luaL_checklstring(L, narg, len);
++}
++
++
++LUALIB_API lua_Number luaL_checknumber (lua_State *L, int narg) {
++ lua_Number d = lua_tonumber(L, narg);
++ if (d == 0 && !lua_isnumber(L, narg)) /* avoid extra test when d is not 0 */
++ tag_error(L, narg, LUA_TNUMBER);
++ return d;
++}
++
++
++LUALIB_API lua_Number luaL_optnumber (lua_State *L, int narg, lua_Number def) {
++ return luaL_opt(L, luaL_checknumber, narg, def);
++}
++
++
++LUALIB_API lua_Integer luaL_checkinteger (lua_State *L, int narg) {
++ lua_Integer d = lua_tointeger(L, narg);
++ if (d == 0 && !lua_isnumber(L, narg)) /* avoid extra test when d is not 0 */
++ tag_error(L, narg, LUA_TNUMBER);
++ return d;
++}
++
++
++LUALIB_API lua_Integer luaL_optinteger (lua_State *L, int narg,
++ lua_Integer def) {
++ return luaL_opt(L, luaL_checkinteger, narg, def);
++}
++
++
++LUALIB_API int luaL_getmetafield (lua_State *L, int obj, const char *event) {
++ if (!lua_getmetatable(L, obj)) /* no metatable? */
++ return 0;
++ lua_pushstring(L, event);
++ lua_rawget(L, -2);
++ if (lua_isnil(L, -1)) {
++ lua_pop(L, 2); /* remove metatable and metafield */
++ return 0;
++ }
++ else {
++ lua_remove(L, -2); /* remove only metatable */
++ return 1;
++ }
++}
++
++
++LUALIB_API int luaL_callmeta (lua_State *L, int obj, const char *event) {
++ obj = abs_index(L, obj);
++ if (!luaL_getmetafield(L, obj, event)) /* no metafield? */
++ return 0;
++ lua_pushvalue(L, obj);
++ lua_call(L, 1, 1);
++ return 1;
++}
++
++
++LUALIB_API void (luaL_register) (lua_State *L, const char *libname,
++ const luaL_Reg *l) {
++ luaI_openlib(L, libname, l, 0);
++}
++
++
++static int libsize (const luaL_Reg *l) {
++ int size = 0;
++ for (; l->name; l++) size++;
++ return size;
++}
++
++
++LUALIB_API void luaI_openlib (lua_State *L, const char *libname,
++ const luaL_Reg *l, int nup) {
++ if (libname) {
++ int size = libsize(l);
++ /* check whether lib already exists */
++ luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 1);
++ lua_getfield(L, -1, libname); /* get _LOADED[libname] */
++ if (!lua_istable(L, -1)) { /* not found? */
++ lua_pop(L, 1); /* remove previous result */
++ /* try global variable (and create one if it does not exist) */
++ if (luaL_findtable(L, LUA_GLOBALSINDEX, libname, size) != NULL)
++ luaL_error(L, "name conflict for module " LUA_QS, libname);
++ lua_pushvalue(L, -1);
++ lua_setfield(L, -3, libname); /* _LOADED[libname] = new table */
++ }
++ lua_remove(L, -2); /* remove _LOADED table */
++ lua_insert(L, -(nup+1)); /* move library table to below upvalues */
++ }
++ for (; l->name; l++) {
++ int i;
++ for (i=0; i<nup; i++) /* copy upvalues to the top */
++ lua_pushvalue(L, -nup);
++ lua_pushcclosure(L, l->func, nup);
++ lua_setfield(L, -(nup+2), l->name);
++ }
++ lua_pop(L, nup); /* remove upvalues */
++}
++
++
++
++/*
++** {======================================================
++** getn-setn: size for arrays
++** =======================================================
++*/
++
++#if defined(LUA_COMPAT_GETN)
++
++static int checkint (lua_State *L, int topop) {
++ int n = (lua_type(L, -1) == LUA_TNUMBER) ? lua_tointeger(L, -1) : -1;
++ lua_pop(L, topop);
++ return n;
++}
++
++
++static void getsizes (lua_State *L) {
++ lua_getfield(L, LUA_REGISTRYINDEX, "LUA_SIZES");
++ if (lua_isnil(L, -1)) { /* no `size' table? */
++ lua_pop(L, 1); /* remove nil */
++ lua_newtable(L); /* create it */
++ lua_pushvalue(L, -1); /* `size' will be its own metatable */
++ lua_setmetatable(L, -2);
++ lua_pushliteral(L, "kv");
++ lua_setfield(L, -2, "__mode"); /* metatable(N).__mode = "kv" */
++ lua_pushvalue(L, -1);
++ lua_setfield(L, LUA_REGISTRYINDEX, "LUA_SIZES"); /* store in register */
++ }
++}
++
++
++LUALIB_API void luaL_setn (lua_State *L, int t, int n) {
++ t = abs_index(L, t);
++ lua_pushliteral(L, "n");
++ lua_rawget(L, t);
++ if (checkint(L, 1) >= 0) { /* is there a numeric field `n'? */
++ lua_pushliteral(L, "n"); /* use it */
++ lua_pushinteger(L, n);
++ lua_rawset(L, t);
++ }
++ else { /* use `sizes' */
++ getsizes(L);
++ lua_pushvalue(L, t);
++ lua_pushinteger(L, n);
++ lua_rawset(L, -3); /* sizes[t] = n */
++ lua_pop(L, 1); /* remove `sizes' */
++ }
++}
++
++
++LUALIB_API int luaL_getn (lua_State *L, int t) {
++ int n;
++ t = abs_index(L, t);
++ lua_pushliteral(L, "n"); /* try t.n */
++ lua_rawget(L, t);
++ if ((n = checkint(L, 1)) >= 0) return n;
++ getsizes(L); /* else try sizes[t] */
++ lua_pushvalue(L, t);
++ lua_rawget(L, -2);
++ if ((n = checkint(L, 2)) >= 0) return n;
++ return (int)lua_objlen(L, t);
++}
++
++#endif
++
++/* }====================================================== */
++
++
++
++LUALIB_API const char *luaL_gsub (lua_State *L, const char *s, const char *p,
++ const char *r) {
++ const char *wild;
++ size_t l = strlen(p);
++ luaL_Buffer *b = (luaL_Buffer *)kmalloc(sizeof(luaL_Buffer) + BUFSIZ, GFP_ATOMIC);
++ if(!b) luaL_error(L, "luaL_gsub: cannot allocate memory");
++ luaL_buffinit(L, b);
++ while ((wild = strstr(s, p)) != NULL) {
++ luaL_addlstring(b, s, wild - s); /* push prefix */
++ luaL_addstring(b, r); /* push replacement in place of pattern */
++ s = wild + l; /* continue after `p' */
++ }
++ luaL_addstring(b, s); /* push last suffix */
++ luaL_pushresult(b);
++ kfree(b);
++ return lua_tostring(L, -1);
++}
++
++
++LUALIB_API const char *luaL_findtable (lua_State *L, int idx,
++ const char *fname, int szhint) {
++ const char *e;
++ lua_pushvalue(L, idx);
++ do {
++ e = strchr(fname, '.');
++ if (e == NULL) e = fname + strlen(fname);
++ lua_pushlstring(L, fname, e - fname);
++ lua_rawget(L, -2);
++ if (lua_isnil(L, -1)) { /* no such field? */
++ lua_pop(L, 1); /* remove this nil */
++ lua_createtable(L, 0, (*e == '.' ? 1 : szhint)); /* new table for field */
++ lua_pushlstring(L, fname, e - fname);
++ lua_pushvalue(L, -2);
++ lua_settable(L, -4); /* set new table into field */
++ }
++ else if (!lua_istable(L, -1)) { /* field has a non-table value? */
++ lua_pop(L, 2); /* remove table and value */
++ return fname; /* return problematic part of the name */
++ }
++ lua_remove(L, -2); /* remove previous table */
++ fname = e + 1;
++ } while (*e == '.');
++ return NULL;
++}
++
++
++
++/*
++** {======================================================
++** Generic Buffer manipulation
++** =======================================================
++*/
++
++
++#define bufflen(B) ((B)->p - (B)->buffer)
++#define bufffree(B) ((size_t)(LUAL_BUFFERSIZE - bufflen(B)))
++
++#define LIMIT (LUA_MINSTACK/2)
++
++
++static int emptybuffer (luaL_Buffer *B) {
++ size_t l = bufflen(B);
++ if (l == 0) return 0; /* put nothing on stack */
++ else {
++ lua_pushlstring(B->L, B->buffer, l);
++ B->p = B->buffer;
++ B->lvl++;
++ return 1;
++ }
++}
++
++
++static void adjuststack (luaL_Buffer *B) {
++ if (B->lvl > 1) {
++ lua_State *L = B->L;
++ int toget = 1; /* number of levels to concat */
++ size_t toplen = lua_strlen(L, -1);
++ do {
++ size_t l = lua_strlen(L, -(toget+1));
++ if (B->lvl - toget + 1 >= LIMIT || toplen > l) {
++ toplen += l;
++ toget++;
++ }
++ else break;
++ } while (toget < B->lvl);
++ lua_concat(L, toget);
++ B->lvl = B->lvl - toget + 1;
++ }
++}
++
++
++LUALIB_API char *luaL_prepbuffer (luaL_Buffer *B) {
++ if (emptybuffer(B))
++ adjuststack(B);
++ return B->buffer;
++}
++
++
++LUALIB_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) {
++ while (l--)
++ luaL_addchar(B, *s++);
++}
++
++
++LUALIB_API void luaL_addstring (luaL_Buffer *B, const char *s) {
++ luaL_addlstring(B, s, strlen(s));
++}
++
++
++LUALIB_API void luaL_pushresult (luaL_Buffer *B) {
++ emptybuffer(B);
++ lua_concat(B->L, B->lvl);
++ B->lvl = 1;
++}
++
++
++LUALIB_API void luaL_addvalue (luaL_Buffer *B) {
++ lua_State *L = B->L;
++ size_t vl;
++ const char *s = lua_tolstring(L, -1, &vl);
++ if (vl <= bufffree(B)) { /* fit into buffer? */
++ memcpy(B->p, s, vl); /* put it there */
++ B->p += vl;
++ lua_pop(L, 1); /* remove from stack */
++ }
++ else {
++ if (emptybuffer(B))
++ lua_insert(L, -2); /* put buffer before new value */
++ B->lvl++; /* add new value into B stack */
++ adjuststack(B);
++ }
++}
++
++
++LUALIB_API void luaL_buffinit (lua_State *L, luaL_Buffer *B) {
++ B->L = L;
++ B->p = B->buffer;
++ B->lvl = 0;
++}
++
++/* }====================================================== */
++
++
++LUALIB_API int luaL_ref (lua_State *L, int t) {
++ int ref;
++ t = abs_index(L, t);
++ if (lua_isnil(L, -1)) {
++ lua_pop(L, 1); /* remove from stack */
++ return LUA_REFNIL; /* `nil' has a unique fixed reference */
++ }
++ lua_rawgeti(L, t, FREELIST_REF); /* get first free element */
++ ref = (int)lua_tointeger(L, -1); /* ref = t[FREELIST_REF] */
++ lua_pop(L, 1); /* remove it from stack */
++ if (ref != 0) { /* any free element? */
++ lua_rawgeti(L, t, ref); /* remove it from list */
++ lua_rawseti(L, t, FREELIST_REF); /* (t[FREELIST_REF] = t[ref]) */
++ }
++ else { /* no free elements */
++ ref = (int)lua_objlen(L, t);
++ ref++; /* create new reference */
++ }
++ lua_rawseti(L, t, ref);
++ return ref;
++}
++
++
++LUALIB_API void luaL_unref (lua_State *L, int t, int ref) {
++ if (ref >= 0) {
++ t = abs_index(L, t);
++ lua_rawgeti(L, t, FREELIST_REF);
++ lua_rawseti(L, t, ref); /* t[ref] = t[FREELIST_REF] */
++ lua_pushinteger(L, ref);
++ lua_rawseti(L, t, FREELIST_REF); /* t[FREELIST_REF] = ref */
++ }
++}
++
++
++
++/*
++** {======================================================
++** Load functions
++** =======================================================
++*/
++
++#if !defined(__KERNEL__)
++typedef struct LoadF {
++ int extraline;
++ FILE *f;
++ char buff[LUAL_BUFFERSIZE];
++} LoadF;
++
++
++static const char *getF (lua_State *L, void *ud, size_t *size) {
++ LoadF *lf = (LoadF *)ud;
++ (void)L;
++ if (lf->extraline) {
++ lf->extraline = 0;
++ *size = 1;
++ return "\n";
++ }
++ if (feof(lf->f)) return NULL;
++ *size = fread(lf->buff, 1, sizeof(lf->buff), lf->f);
++ return (*size > 0) ? lf->buff : NULL;
++}
++
++
++static int errfile (lua_State *L, const char *what, int fnameindex) {
++ const char *serr = strerror(errno);
++ const char *filename = lua_tostring(L, fnameindex) + 1;
++ lua_pushfstring(L, "cannot %s %s: %s", what, filename, serr);
++ lua_remove(L, fnameindex);
++ return LUA_ERRFILE;
++}
++
++
++LUALIB_API int luaL_loadfile (lua_State *L, const char *filename) {
++ LoadF lf;
++ int status, readstatus;
++ int c;
++ int fnameindex = lua_gettop(L) + 1; /* index of filename on the stack */
++ lf.extraline = 0;
++ if (filename == NULL) {
++ lua_pushliteral(L, "=stdin");
++ lf.f = stdin;
++ }
++ else {
++ lua_pushfstring(L, "@%s", filename);
++ lf.f = fopen(filename, "r");
++ if (lf.f == NULL) return errfile(L, "open", fnameindex);
++ }
++ c = getc(lf.f);
++ if (c == '#') { /* Unix exec. file? */
++ lf.extraline = 1;
++ while ((c = getc(lf.f)) != EOF && c != '\n') ; /* skip first line */
++ if (c == '\n') c = getc(lf.f);
++ }
++ if (c == LUA_SIGNATURE[0] && filename) { /* binary file? */
++ lf.f = freopen(filename, "rb", lf.f); /* reopen in binary mode */
++ if (lf.f == NULL) return errfile(L, "reopen", fnameindex);
++ /* skip eventual `#!...' */
++ while ((c = getc(lf.f)) != EOF && c != LUA_SIGNATURE[0]) ;
++ lf.extraline = 0;
++ }
++ ungetc(c, lf.f);
++ status = lua_load(L, getF, &lf, lua_tostring(L, -1));
++ readstatus = ferror(lf.f);
++ if (filename) fclose(lf.f); /* close file (even in case of errors) */
++ if (readstatus) {
++ lua_settop(L, fnameindex); /* ignore results from `lua_load' */
++ return errfile(L, "read", fnameindex);
++ }
++ lua_remove(L, fnameindex);
++ return status;
++}
++#endif
++
++typedef struct LoadS {
++ const char *s;
++ size_t size;
++} LoadS;
++
++
++static const char *getS (lua_State *L, void *ud, size_t *size) {
++ LoadS *ls = (LoadS *)ud;
++ (void)L;
++ if (ls->size == 0) return NULL;
++ *size = ls->size;
++ ls->size = 0;
++ return ls->s;
++}
++
++
++LUALIB_API int luaL_loadbuffer (lua_State *L, const char *buff, size_t size,
++ const char *name) {
++ LoadS ls;
++ ls.s = buff;
++ ls.size = size;
++ return lua_load(L, getS, &ls, name);
++}
++
++
++LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s) {
++ return luaL_loadbuffer(L, s, strlen(s), s);
++}
++
++
++
++/* }====================================================== */
++
++
++static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) {
++ (void)ud;
++ (void)osize;
++ if (nsize == 0) {
++#if !defined(__KERNEL__)
++ free(ptr);
++#else
++ kfree(ptr);
++#endif
++ return NULL;
++ }
++ else
++#if !defined(__KERNEL__)
++ return realloc(ptr, nsize);
++#else
++ return krealloc(ptr, nsize, GFP_ATOMIC);
++#endif
++}
++
++
++static int lpanic (lua_State *L) {
++ (void)L; /* to avoid warnings */
++#if !defined(__KERNEL__)
++ fprintf(stderr, "PANIC: unprotected error in call to Lua API (%s)\n",
++#else
++ printk( "PANIC: unprotected error in call to Lua API (%s)\n",
++#endif
++ lua_tostring(L, -1));
++ return 0;
++}
++
++
++LUALIB_API lua_State *luaL_newstate (void) {
++ lua_State *L = lua_newstate(l_alloc, NULL);
++ if (L) lua_atpanic(L, &lpanic);
++ return L;
++}
++
+--- /dev/null
++++ b/extensions/LUA/lua/lauxlib.h
+@@ -0,0 +1,184 @@
++/*
++** $Id: lauxlib.h,v 1.88.1.1 2007/12/27 13:02:25 roberto Exp $
++** Auxiliary functions for building Lua libraries
++** See Copyright Notice in lua.h
++*/
++
++
++#ifndef lauxlib_h
++#define lauxlib_h
++
++
++#include <stddef.h>
++#include <linux/slab.h> /* for kmalloc and kfree when allocating luaL_Buffer */
++
++#if !defined(__KERNEL__)
++#include <stdio.h>
++#endif
++
++#include "lua.h"
++
++
++#if defined(LUA_COMPAT_GETN)
++LUALIB_API int (luaL_getn) (lua_State *L, int t);
++LUALIB_API void (luaL_setn) (lua_State *L, int t, int n);
++#else
++#define luaL_getn(L,i) ((int)lua_objlen(L, i))
++#define luaL_setn(L,i,j) ((void)0) /* no op! */
++#endif
++
++#if defined(LUA_COMPAT_OPENLIB)
++#define luaI_openlib luaL_openlib
++#endif
++
++
++/* extra error code for `luaL_load' */
++#define LUA_ERRFILE (LUA_ERRERR+1)
++
++
++typedef struct luaL_Reg {
++ const char *name;
++ lua_CFunction func;
++} luaL_Reg;
++
++
++
++LUALIB_API void (luaI_openlib) (lua_State *L, const char *libname,
++ const luaL_Reg *l, int nup);
++LUALIB_API void (luaL_register) (lua_State *L, const char *libname,
++ const luaL_Reg *l);
++LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e);
++LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e);
++LUALIB_API int (luaL_typerror) (lua_State *L, int narg, const char *tname);
++LUALIB_API int (luaL_argerror) (lua_State *L, int numarg, const char *extramsg);
++LUALIB_API const char *(luaL_checklstring) (lua_State *L, int numArg,
++ size_t *l);
++LUALIB_API const char *(luaL_optlstring) (lua_State *L, int numArg,
++ const char *def, size_t *l);
++LUALIB_API lua_Number (luaL_checknumber) (lua_State *L, int numArg);
++LUALIB_API lua_Number (luaL_optnumber) (lua_State *L, int nArg, lua_Number def);
++
++LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int numArg);
++LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int nArg,
++ lua_Integer def);
++
++LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg);
++LUALIB_API void (luaL_checktype) (lua_State *L, int narg, int t);
++LUALIB_API void (luaL_checkany) (lua_State *L, int narg);
++
++LUALIB_API int (luaL_newmetatable) (lua_State *L, const char *tname);
++LUALIB_API void *(luaL_checkudata) (lua_State *L, int ud, const char *tname);
++
++LUALIB_API void (luaL_where) (lua_State *L, int lvl);
++LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...);
++
++LUALIB_API int (luaL_checkoption) (lua_State *L, int narg, const char *def,
++ const char *const lst[]);
++
++LUALIB_API int (luaL_ref) (lua_State *L, int t);
++LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref);
++
++#if !defined(__KERNEL__)
++LUALIB_API int (luaL_loadfile) (lua_State *L, const char *filename);
++#endif
++
++LUALIB_API int (luaL_loadbuffer) (lua_State *L, const char *buff, size_t sz,
++ const char *name);
++LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s);
++
++LUALIB_API lua_State *(luaL_newstate) (void);
++
++
++LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s, const char *p,
++ const char *r);
++
++LUALIB_API const char *(luaL_findtable) (lua_State *L, int idx,
++ const char *fname, int szhint);
++
++
++
++
++/*
++** ===============================================================
++** some useful macros
++** ===============================================================
++*/
++
++#define luaL_argcheck(L, cond,numarg,extramsg) \
++ ((void)((cond) || luaL_argerror(L, (numarg), (extramsg))))
++#define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL))
++#define luaL_optstring(L,n,d) (luaL_optlstring(L, (n), (d), NULL))
++#define luaL_checkint(L,n) ((int)luaL_checkinteger(L, (n)))
++#define luaL_optint(L,n,d) ((int)luaL_optinteger(L, (n), (d)))
++#define luaL_checklong(L,n) ((long)luaL_checkinteger(L, (n)))
++#define luaL_optlong(L,n,d) ((long)luaL_optinteger(L, (n), (d)))
++
++#define luaL_typename(L,i) lua_typename(L, lua_type(L,(i)))
++
++#if !defined(__KERNEL__)
++#define luaL_dofile(L, fn) \
++ (luaL_loadfile(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0))
++#endif
++
++#define luaL_dostring(L, s) \
++ (luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0))
++
++#define luaL_getmetatable(L,n) (lua_getfield(L, LUA_REGISTRYINDEX, (n)))
++
++#define luaL_opt(L,f,n,d) (lua_isnoneornil(L,(n)) ? (d) : f(L,(n)))
++
++/*
++** {======================================================
++** Generic Buffer manipulation
++** =======================================================
++*/
++
++
++
++typedef struct luaL_Buffer {
++ char *p; /* current position in buffer */
++ int lvl; /* number of strings in the stack (level) */
++ lua_State *L;
++ char buffer[LUAL_BUFFERSIZE];
++} luaL_Buffer;
++
++#define luaL_addchar(B,c) \
++ ((void)((B)->p < ((B)->buffer+LUAL_BUFFERSIZE) || luaL_prepbuffer(B)), \
++ (*(B)->p++ = (char)(c)))
++
++/* compatibility only */
++#define luaL_putchar(B,c) luaL_addchar(B,c)
++
++#define luaL_addsize(B,n) ((B)->p += (n))
++
++
++LUALIB_API void (luaL_buffinit) (lua_State *L, luaL_Buffer *B);
++LUALIB_API char *(luaL_prepbuffer) (luaL_Buffer *B);
++LUALIB_API void (luaL_addlstring) (luaL_Buffer *B, const char *s, size_t l);
++LUALIB_API void (luaL_addstring) (luaL_Buffer *B, const char *s);
++LUALIB_API void (luaL_addvalue) (luaL_Buffer *B);
++LUALIB_API void (luaL_pushresult) (luaL_Buffer *B);
++
++
++/* }====================================================== */
++
++
++/* compatibility with ref system */
++
++/* pre-defined references */
++#define LUA_NOREF (-2)
++#define LUA_REFNIL (-1)
++
++#define lua_ref(L,lock) ((lock) ? luaL_ref(L, LUA_REGISTRYINDEX) : \
++ (lua_pushstring(L, "unlocked references are obsolete"), lua_error(L), 0))
++
++#define lua_unref(L,ref) luaL_unref(L, LUA_REGISTRYINDEX, (ref))
++
++#define lua_getref(L,ref) lua_rawgeti(L, LUA_REGISTRYINDEX, (ref))
++
++
++#define luaL_reg luaL_Reg
++
++#endif
++
++
+--- /dev/null
++++ b/extensions/LUA/lua/lbaselib.c
+@@ -0,0 +1,647 @@
++/*
++** $Id: lbaselib.c,v 1.191.1.6 2008/02/14 16:46:22 roberto Exp $
++** Basic library
++** See Copyright Notice in lua.h
++*/
++
++
++#include <linux/kernel.h>
++#include <linux/ctype.h>
++#include <linux/string.h>
++
++#define lbaselib_c
++#define LUA_LIB
++
++#include "lua.h"
++
++#include "lauxlib.h"
++#include "lualib.h"
++
++
++
++
++/*
++** If your system does not support `stdout', you can just remove this function.
++** If you need, you can define your own `print' function, following this
++** model but changing `fputs' to put the strings at a proper place
++** (a console window or a log file, for instance).
++*/
++static int luaB_print (lua_State *L) {
++ int n = lua_gettop(L); /* number of arguments */
++ int i;
++ lua_getglobal(L, "tostring");
++ for (i=1; i<=n; i++) {
++ const char *s;
++ lua_pushvalue(L, -1); /* function to be called */
++ lua_pushvalue(L, i); /* value to print */
++ lua_call(L, 1, 1);
++ s = lua_tostring(L, -1); /* get result */
++ if (s == NULL)
++ return luaL_error(L, LUA_QL("tostring") " must return a string to "
++ LUA_QL("print"));
++ printk(KERN_INFO "LUA[print]: %s", s);
++ lua_pop(L, 1); /* pop result */
++ }
++ return 0;
++}
++
++
++static int luaB_tonumber (lua_State *L) {
++ int base = luaL_optint(L, 2, 10);
++ if (base == 10) { /* standard conversion */
++ luaL_checkany(L, 1);
++ if (lua_isnumber(L, 1)) {
++ lua_pushnumber(L, lua_tonumber(L, 1));
++ return 1;
++ }
++ }
++ else {
++ const char *s1 = luaL_checkstring(L, 1);
++ char *s2;
++ unsigned long n;
++ luaL_argcheck(L, 2 <= base && base <= 36, 2, "base out of range");
++ n = simple_strtoul(s1, &s2, base);
++ if (s1 != s2) { /* at least one valid digit? */
++ while (isspace((unsigned char)(*s2))) s2++; /* skip trailing spaces */
++ if (*s2 == '\0') { /* no invalid trailing characters? */
++ lua_pushnumber(L, (lua_Number)n);
++ return 1;
++ }
++ }
++ }
++ lua_pushnil(L); /* else not a number */
++ return 1;
++}
++
++
++static int luaB_error (lua_State *L) {
++ int level = luaL_optint(L, 2, 1);
++ lua_settop(L, 1);
++ if (lua_isstring(L, 1) && level > 0) { /* add extra information? */
++ luaL_where(L, level);
++ lua_pushvalue(L, 1);
++ lua_concat(L, 2);
++ }
++ return lua_error(L);
++}
++
++
++static int luaB_getmetatable (lua_State *L) {
++ luaL_checkany(L, 1);
++ if (!lua_getmetatable(L, 1)) {
++ lua_pushnil(L);
++ return 1; /* no metatable */
++ }
++ luaL_getmetafield(L, 1, "__metatable");
++ return 1; /* returns either __metatable field (if present) or metatable */
++}
++
++
++static int luaB_setmetatable (lua_State *L) {
++ int t = lua_type(L, 2);
++ luaL_checktype(L, 1, LUA_TTABLE);
++ luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2,
++ "nil or table expected");
++ if (luaL_getmetafield(L, 1, "__metatable"))
++ luaL_error(L, "cannot change a protected metatable");
++ lua_settop(L, 2);
++ lua_setmetatable(L, 1);
++ return 1;
++}
++
++
++static void getfunc (lua_State *L, int opt) {
++ if (lua_isfunction(L, 1)) lua_pushvalue(L, 1);
++ else {
++ lua_Debug ar;
++ int level = opt ? luaL_optint(L, 1, 1) : luaL_checkint(L, 1);
++ luaL_argcheck(L, level >= 0, 1, "level must be non-negative");
++ if (lua_getstack(L, level, &ar) == 0)
++ luaL_argerror(L, 1, "invalid level");
++ lua_getinfo(L, "f", &ar);
++ if (lua_isnil(L, -1))
++ luaL_error(L, "no function environment for tail call at level %d",
++ level);
++ }
++}
++
++
++static int luaB_getfenv (lua_State *L) {
++ getfunc(L, 1);
++ if (lua_iscfunction(L, -1)) /* is a C function? */
++ lua_pushvalue(L, LUA_GLOBALSINDEX); /* return the thread's global env. */
++ else
++ lua_getfenv(L, -1);
++ return 1;
++}
++
++
++static int luaB_setfenv (lua_State *L) {
++ luaL_checktype(L, 2, LUA_TTABLE);
++ getfunc(L, 0);
++ lua_pushvalue(L, 2);
++ if (lua_isnumber(L, 1) && lua_tonumber(L, 1) == 0) {
++ /* change environment of current thread */
++ lua_pushthread(L);
++ lua_insert(L, -2);
++ lua_setfenv(L, -2);
++ return 0;
++ }
++ else if (lua_iscfunction(L, -2) || lua_setfenv(L, -2) == 0)
++ luaL_error(L,
++ LUA_QL("setfenv") " cannot change environment of given object");
++ return 1;
++}
++
++
++static int luaB_rawequal (lua_State *L) {
++ luaL_checkany(L, 1);
++ luaL_checkany(L, 2);
++ lua_pushboolean(L, lua_rawequal(L, 1, 2));
++ return 1;
++}
++
++
++static int luaB_rawget (lua_State *L) {
++ luaL_checktype(L, 1, LUA_TTABLE);
++ luaL_checkany(L, 2);
++ lua_settop(L, 2);
++ lua_rawget(L, 1);
++ return 1;
++}
++
++static int luaB_rawset (lua_State *L) {
++ luaL_checktype(L, 1, LUA_TTABLE);
++ luaL_checkany(L, 2);
++ luaL_checkany(L, 3);
++ lua_settop(L, 3);
++ lua_rawset(L, 1);
++ return 1;
++}
++
++
++static int luaB_gcinfo (lua_State *L) {
++ lua_pushinteger(L, lua_getgccount(L));
++ return 1;
++}
++
++static int luaB_collectgarbage (lua_State *L) {
++ static const char *const opts[] = {"stop", "restart", "collect",
++ "count", "step", "setpause", "setstepmul", NULL};
++ static const int optsnum[] = {LUA_GCSTOP, LUA_GCRESTART, LUA_GCCOLLECT,
++ LUA_GCCOUNT, LUA_GCSTEP, LUA_GCSETPAUSE, LUA_GCSETSTEPMUL};
++ int o = luaL_checkoption(L, 1, "collect", opts);
++ int ex = luaL_optint(L, 2, 0);
++ int res = lua_gc(L, optsnum[o], ex);
++ switch (optsnum[o]) {
++ case LUA_GCCOUNT: {
++ int b = lua_gc(L, LUA_GCCOUNTB, 0);
++ lua_pushnumber(L, res + ((lua_Number)b/1024));
++ return 1;
++ }
++ case LUA_GCSTEP: {
++ lua_pushboolean(L, res);
++ return 1;
++ }
++ default: {
++ lua_pushnumber(L, res);
++ return 1;
++ }
++ }
++}
++
++
++static int luaB_type (lua_State *L) {
++ luaL_checkany(L, 1);
++ lua_pushstring(L, luaL_typename(L, 1));
++ return 1;
++}
++
++
++static int luaB_next (lua_State *L) {
++ luaL_checktype(L, 1, LUA_TTABLE);
++ lua_settop(L, 2); /* create a 2nd argument if there isn't one */
++ if (lua_next(L, 1))
++ return 2;
++ else {
++ lua_pushnil(L);
++ return 1;
++ }
++}
++
++
++static int luaB_pairs (lua_State *L) {
++ luaL_checktype(L, 1, LUA_TTABLE);
++ lua_pushvalue(L, lua_upvalueindex(1)); /* return generator, */
++ lua_pushvalue(L, 1); /* state, */
++ lua_pushnil(L); /* and initial value */
++ return 3;
++}
++
++
++static int ipairsaux (lua_State *L) {
++ int i = luaL_checkint(L, 2);
++ luaL_checktype(L, 1, LUA_TTABLE);
++ i++; /* next value */
++ lua_pushinteger(L, i);
++ lua_rawgeti(L, 1, i);
++ return (lua_isnil(L, -1)) ? 0 : 2;
++}
++
++
++static int luaB_ipairs (lua_State *L) {
++ luaL_checktype(L, 1, LUA_TTABLE);
++ lua_pushvalue(L, lua_upvalueindex(1)); /* return generator, */
++ lua_pushvalue(L, 1); /* state, */
++ lua_pushinteger(L, 0); /* and initial value */
++ return 3;
++}
++
++
++static int load_aux (lua_State *L, int status) {
++ if (status == 0) /* OK? */
++ return 1;
++ else {
++ lua_pushnil(L);
++ lua_insert(L, -2); /* put before error message */
++ return 2; /* return nil plus error message */
++ }
++}
++
++
++static int luaB_loadstring (lua_State *L) {
++ size_t l;
++ const char *s = luaL_checklstring(L, 1, &l);
++ const char *chunkname = luaL_optstring(L, 2, s);
++ return load_aux(L, luaL_loadbuffer(L, s, l, chunkname));
++}
++
++/*
++static int luaB_loadfile (lua_State *L) {
++ const char *fname = luaL_optstring(L, 1, NULL);
++ return load_aux(L, luaL_loadfile(L, fname));
++}
++*/
++
++/*
++** Reader for generic `load' function: `lua_load' uses the
++** stack for internal stuff, so the reader cannot change the
++** stack top. Instead, it keeps its resulting string in a
++** reserved slot inside the stack.
++*/
++static const char *generic_reader (lua_State *L, void *ud, size_t *size) {
++ (void)ud; /* to avoid warnings */
++ luaL_checkstack(L, 2, "too many nested functions");
++ lua_pushvalue(L, 1); /* get function */
++ lua_call(L, 0, 1); /* call it */
++ if (lua_isnil(L, -1)) {
++ *size = 0;
++ return NULL;
++ }
++ else if (lua_isstring(L, -1)) {
++ lua_replace(L, 3); /* save string in a reserved stack slot */
++ return lua_tolstring(L, 3, size);
++ }
++ else luaL_error(L, "reader function must return a string");
++ return NULL; /* to avoid warnings */
++}
++
++
++static int luaB_load (lua_State *L) {
++ int status;
++ const char *cname = luaL_optstring(L, 2, "=(load)");
++ luaL_checktype(L, 1, LUA_TFUNCTION);
++ lua_settop(L, 3); /* function, eventual name, plus one reserved slot */
++ status = lua_load(L, generic_reader, NULL, cname);
++ return load_aux(L, status);
++}
++
++/*
++static int luaB_dofile (lua_State *L) {
++ const char *fname = luaL_optstring(L, 1, NULL);
++ int n = lua_gettop(L);
++ if (luaL_loadfile(L, fname) != 0) lua_error(L);
++ lua_call(L, 0, LUA_MULTRET);
++ return lua_gettop(L) - n;
++}
++*/
++
++static int luaB_assert (lua_State *L) {
++ luaL_checkany(L, 1);
++ if (!lua_toboolean(L, 1))
++ return luaL_error(L, "%s", luaL_optstring(L, 2, "assertion failed!"));
++ return lua_gettop(L);
++}
++
++
++static int luaB_unpack (lua_State *L) {
++ int i, e, n;
++ luaL_checktype(L, 1, LUA_TTABLE);
++ i = luaL_optint(L, 2, 1);
++ e = luaL_opt(L, luaL_checkint, 3, luaL_getn(L, 1));
++ if (i > e) return 0; /* empty range */
++ n = e - i + 1; /* number of elements */
++ if (n <= 0 || !lua_checkstack(L, n)) /* n <= 0 means arith. overflow */
++ return luaL_error(L, "too many results to unpack");
++ lua_rawgeti(L, 1, i); /* push arg[i] (avoiding overflow problems) */
++ while (i++ < e) /* push arg[i + 1...e] */
++ lua_rawgeti(L, 1, i);
++ return n;
++}
++
++
++static int luaB_select (lua_State *L) {
++ int n = lua_gettop(L);
++ if (lua_type(L, 1) == LUA_TSTRING && *lua_tostring(L, 1) == '#') {
++ lua_pushinteger(L, n-1);
++ return 1;
++ }
++ else {
++ int i = luaL_checkint(L, 1);
++ if (i < 0) i = n + i;
++ else if (i > n) i = n;
++ luaL_argcheck(L, 1 <= i, 1, "index out of range");
++ return n - i;
++ }
++}
++
++
++static int luaB_pcall (lua_State *L) {
++ int status;
++ luaL_checkany(L, 1);
++ status = lua_pcall(L, lua_gettop(L) - 1, LUA_MULTRET, 0);
++ lua_pushboolean(L, (status == 0));
++ lua_insert(L, 1);
++ return lua_gettop(L); /* return status + all results */
++}
++
++
++static int luaB_xpcall (lua_State *L) {
++ int status;
++ luaL_checkany(L, 2);
++ lua_settop(L, 2);
++ lua_insert(L, 1); /* put error function under function to be called */
++ status = lua_pcall(L, 0, LUA_MULTRET, 1);
++ lua_pushboolean(L, (status == 0));
++ lua_replace(L, 1);
++ return lua_gettop(L); /* return status + all results */
++}
++
++
++static int luaB_tostring (lua_State *L) {
++ luaL_checkany(L, 1);
++ if (luaL_callmeta(L, 1, "__tostring")) /* is there a metafield? */
++ return 1; /* use its value */
++ switch (lua_type(L, 1)) {
++ case LUA_TNUMBER:
++ lua_pushstring(L, lua_tostring(L, 1));
++ break;
++ case LUA_TSTRING:
++ lua_pushvalue(L, 1);
++ break;
++ case LUA_TBOOLEAN:
++ lua_pushstring(L, (lua_toboolean(L, 1) ? "true" : "false"));
++ break;
++ case LUA_TNIL:
++ lua_pushliteral(L, "nil");
++ break;
++ default:
++ lua_pushfstring(L, "%s: %p", luaL_typename(L, 1), lua_topointer(L, 1));
++ break;
++ }
++ return 1;
++}
++
++
++static int luaB_newproxy (lua_State *L) {
++ lua_settop(L, 1);
++ lua_newuserdata(L, 0); /* create proxy */
++ if (lua_toboolean(L, 1) == 0)
++ return 1; /* no metatable */
++ else if (lua_isboolean(L, 1)) {
++ lua_newtable(L); /* create a new metatable `m' ... */
++ lua_pushvalue(L, -1); /* ... and mark `m' as a valid metatable */
++ lua_pushboolean(L, 1);
++ lua_rawset(L, lua_upvalueindex(1)); /* weaktable[m] = true */
++ }
++ else {
++ int validproxy = 0; /* to check if weaktable[metatable(u)] == true */
++ if (lua_getmetatable(L, 1)) {
++ lua_rawget(L, lua_upvalueindex(1));
++ validproxy = lua_toboolean(L, -1);
++ lua_pop(L, 1); /* remove value */
++ }
++ luaL_argcheck(L, validproxy, 1, "boolean or proxy expected");
++ lua_getmetatable(L, 1); /* metatable is valid; get it */
++ }
++ lua_setmetatable(L, 2);
++ return 1;
++}
++
++
++static const luaL_Reg base_funcs[] = {
++ {"assert", luaB_assert},
++ {"collectgarbage", luaB_collectgarbage},
++// {"dofile", luaB_dofile},
++ {"error", luaB_error},
++ {"gcinfo", luaB_gcinfo},
++ {"getfenv", luaB_getfenv},
++ {"getmetatable", luaB_getmetatable},
++// {"loadfile", luaB_loadfile},
++ {"load", luaB_load},
++ {"loadstring", luaB_loadstring},
++ {"next", luaB_next},
++ {"pcall", luaB_pcall},
++ {"print", luaB_print},
++ {"rawequal", luaB_rawequal},
++ {"rawget", luaB_rawget},
++ {"rawset", luaB_rawset},
++ {"select", luaB_select},
++ {"setfenv", luaB_setfenv},
++ {"setmetatable", luaB_setmetatable},
++ {"tonumber", luaB_tonumber},
++ {"tostring", luaB_tostring},
++ {"type", luaB_type},
++ {"unpack", luaB_unpack},
++ {"xpcall", luaB_xpcall},
++ {NULL, NULL}
++};
++
++
++/*
++** {======================================================
++** Coroutine library
++** =======================================================
++*/
++
++#define CO_RUN 0 /* running */
++#define CO_SUS 1 /* suspended */
++#define CO_NOR 2 /* 'normal' (it resumed another coroutine) */
++#define CO_DEAD 3
++
++static const char *const statnames[] =
++ {"running", "suspended", "normal", "dead"};
++
++static int costatus (lua_State *L, lua_State *co) {
++ if (L == co) return CO_RUN;
++ switch (lua_status(co)) {
++ case LUA_YIELD:
++ return CO_SUS;
++ case 0: {
++ lua_Debug ar;
++ if (lua_getstack(co, 0, &ar) > 0) /* does it have frames? */
++ return CO_NOR; /* it is running */
++ else if (lua_gettop(co) == 0)
++ return CO_DEAD;
++ else
++ return CO_SUS; /* initial state */
++ }
++ default: /* some error occured */
++ return CO_DEAD;
++ }
++}
++
++
++static int luaB_costatus (lua_State *L) {
++ lua_State *co = lua_tothread(L, 1);
++ luaL_argcheck(L, co, 1, "coroutine expected");
++ lua_pushstring(L, statnames[costatus(L, co)]);
++ return 1;
++}
++
++
++static int auxresume (lua_State *L, lua_State *co, int narg) {
++ int status = costatus(L, co);
++ if (!lua_checkstack(co, narg))
++ luaL_error(L, "too many arguments to resume");
++ if (status != CO_SUS) {
++ lua_pushfstring(L, "cannot resume %s coroutine", statnames[status]);
++ return -1; /* error flag */
++ }
++ lua_xmove(L, co, narg);
++ lua_setlevel(L, co);
++ status = lua_resume(co, narg);
++ if (status == 0 || status == LUA_YIELD) {
++ int nres = lua_gettop(co);
++ if (!lua_checkstack(L, nres + 1))
++ luaL_error(L, "too many results to resume");
++ lua_xmove(co, L, nres); /* move yielded values */
++ return nres;
++ }
++ else {
++ lua_xmove(co, L, 1); /* move error message */
++ return -1; /* error flag */
++ }
++}
++
++
++static int luaB_coresume (lua_State *L) {
++ lua_State *co = lua_tothread(L, 1);
++ int r;
++ luaL_argcheck(L, co, 1, "coroutine expected");
++ r = auxresume(L, co, lua_gettop(L) - 1);
++ if (r < 0) {
++ lua_pushboolean(L, 0);
++ lua_insert(L, -2);
++ return 2; /* return false + error message */
++ }
++ else {
++ lua_pushboolean(L, 1);
++ lua_insert(L, -(r + 1));
++ return r + 1; /* return true + `resume' returns */
++ }
++}
++
++
++static int luaB_auxwrap (lua_State *L) {
++ lua_State *co = lua_tothread(L, lua_upvalueindex(1));
++ int r = auxresume(L, co, lua_gettop(L));
++ if (r < 0) {
++ if (lua_isstring(L, -1)) { /* error object is a string? */
++ luaL_where(L, 1); /* add extra info */
++ lua_insert(L, -2);
++ lua_concat(L, 2);
++ }
++ lua_error(L); /* propagate error */
++ }
++ return r;
++}
++
++
++static int luaB_cocreate (lua_State *L) {
++ lua_State *NL = lua_newthread(L);
++ luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), 1,
++ "Lua function expected");
++ lua_pushvalue(L, 1); /* move function to top */
++ lua_xmove(L, NL, 1); /* move function from L to NL */
++ return 1;
++}
++
++
++static int luaB_cowrap (lua_State *L) {
++ luaB_cocreate(L);
++ lua_pushcclosure(L, luaB_auxwrap, 1);
++ return 1;
++}
++
++
++static int luaB_yield (lua_State *L) {
++ return lua_yield(L, lua_gettop(L));
++}
++
++
++static int luaB_corunning (lua_State *L) {
++ if (lua_pushthread(L))
++ lua_pushnil(L); /* main thread is not a coroutine */
++ return 1;
++}
++
++
++static const luaL_Reg co_funcs[] = {
++ {"create", luaB_cocreate},
++ {"resume", luaB_coresume},
++ {"running", luaB_corunning},
++ {"status", luaB_costatus},
++ {"wrap", luaB_cowrap},
++ {"yield", luaB_yield},
++ {NULL, NULL}
++};
++
++/* }====================================================== */
++
++
++static void auxopen (lua_State *L, const char *name,
++ lua_CFunction f, lua_CFunction u) {
++ lua_pushcfunction(L, u);
++ lua_pushcclosure(L, f, 1);
++ lua_setfield(L, -2, name);
++}
++
++
++static void base_open (lua_State *L) {
++ /* set global _G */
++ lua_pushvalue(L, LUA_GLOBALSINDEX);
++ lua_setglobal(L, "_G");
++ /* open lib into global table */
++ luaL_register(L, "_G", base_funcs);
++ lua_pushliteral(L, LUA_VERSION);
++ lua_setglobal(L, "_VERSION"); /* set global _VERSION */
++ /* `ipairs' and `pairs' need auxliliary functions as upvalues */
++ auxopen(L, "ipairs", luaB_ipairs, ipairsaux);
++ auxopen(L, "pairs", luaB_pairs, luaB_next);
++ /* `newproxy' needs a weaktable as upvalue */
++ lua_createtable(L, 0, 1); /* new table `w' */
++ lua_pushvalue(L, -1); /* `w' will be its own metatable */
++ lua_setmetatable(L, -2);
++ lua_pushliteral(L, "kv");
++ lua_setfield(L, -2, "__mode"); /* metatable(w).__mode = "kv" */
++ lua_pushcclosure(L, luaB_newproxy, 1);
++ lua_setglobal(L, "newproxy"); /* set global `newproxy' */
++}
++
++
++LUALIB_API int luaopen_base (lua_State *L) {
++ base_open(L);
++ luaL_register(L, LUA_COLIBNAME, co_funcs);
++ return 2;
++}
+--- /dev/null
++++ b/extensions/LUA/lua/lcode.c
+@@ -0,0 +1,838 @@
++/*
++** $Id: lcode.c,v 2.25.1.3 2007/12/28 15:32:23 roberto Exp $
++** Code generator for Lua
++** See Copyright Notice in lua.h
++*/
++
++#include <stdlib.h>
++
++#define lcode_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "lcode.h"
++#include "ldebug.h"
++#include "ldo.h"
++#include "lgc.h"
++#include "llex.h"
++#include "lmem.h"
++#include "lobject.h"
++#include "lopcodes.h"
++#include "lparser.h"
++#include "ltable.h"
++
++
++#define hasjumps(e) ((e)->t != (e)->f)
++
++
++static int isnumeral(expdesc *e) {
++ return (e->k == VKNUM && e->t == NO_JUMP && e->f == NO_JUMP);
++}
++
++
++void luaK_nil (FuncState *fs, int from, int n) {
++ Instruction *previous;
++ if (fs->pc > fs->lasttarget) { /* no jumps to current position? */
++ if (fs->pc == 0) { /* function start? */
++ if (from >= fs->nactvar)
++ return; /* positions are already clean */
++ }
++ else {
++ previous = &fs->f->code[fs->pc-1];
++ if (GET_OPCODE(*previous) == OP_LOADNIL) {
++ int pfrom = GETARG_A(*previous);
++ int pto = GETARG_B(*previous);
++ if (pfrom <= from && from <= pto+1) { /* can connect both? */
++ if (from+n-1 > pto)
++ SETARG_B(*previous, from+n-1);
++ return;
++ }
++ }
++ }
++ }
++ luaK_codeABC(fs, OP_LOADNIL, from, from+n-1, 0); /* else no optimization */
++}
++
++
++int luaK_jump (FuncState *fs) {
++ int jpc = fs->jpc; /* save list of jumps to here */
++ int j;
++ fs->jpc = NO_JUMP;
++ j = luaK_codeAsBx(fs, OP_JMP, 0, NO_JUMP);
++ luaK_concat(fs, &j, jpc); /* keep them on hold */
++ return j;
++}
++
++
++void luaK_ret (FuncState *fs, int first, int nret) {
++ luaK_codeABC(fs, OP_RETURN, first, nret+1, 0);
++}
++
++
++static int condjump (FuncState *fs, OpCode op, int A, int B, int C) {
++ luaK_codeABC(fs, op, A, B, C);
++ return luaK_jump(fs);
++}
++
++
++static void fixjump (FuncState *fs, int pc, int dest) {
++ Instruction *jmp = &fs->f->code[pc];
++ int offset = dest-(pc+1);
++ lua_assert(dest != NO_JUMP);
++ if (abs(offset) > MAXARG_sBx)
++ luaX_syntaxerror(fs->ls, "control structure too long");
++ SETARG_sBx(*jmp, offset);
++}
++
++
++/*
++** returns current `pc' and marks it as a jump target (to avoid wrong
++** optimizations with consecutive instructions not in the same basic block).
++*/
++int luaK_getlabel (FuncState *fs) {
++ fs->lasttarget = fs->pc;
++ return fs->pc;
++}
++
++
++static int getjump (FuncState *fs, int pc) {
++ int offset = GETARG_sBx(fs->f->code[pc]);
++ if (offset == NO_JUMP) /* point to itself represents end of list */
++ return NO_JUMP; /* end of list */
++ else
++ return (pc+1)+offset; /* turn offset into absolute position */
++}
++
++
++static Instruction *getjumpcontrol (FuncState *fs, int pc) {
++ Instruction *pi = &fs->f->code[pc];
++ if (pc >= 1 && testTMode(GET_OPCODE(*(pi-1))))
++ return pi-1;
++ else
++ return pi;
++}
++
++
++/*
++** check whether list has any jump that do not produce a value
++** (or produce an inverted value)
++*/
++static int need_value (FuncState *fs, int list) {
++ for (; list != NO_JUMP; list = getjump(fs, list)) {
++ Instruction i = *getjumpcontrol(fs, list);
++ if (GET_OPCODE(i) != OP_TESTSET) return 1;
++ }
++ return 0; /* not found */
++}
++
++
++static int patchtestreg (FuncState *fs, int node, int reg) {
++ Instruction *i = getjumpcontrol(fs, node);
++ if (GET_OPCODE(*i) != OP_TESTSET)
++ return 0; /* cannot patch other instructions */
++ if (reg != NO_REG && reg != GETARG_B(*i))
++ SETARG_A(*i, reg);
++ else /* no register to put value or register already has the value */
++ *i = CREATE_ABC(OP_TEST, GETARG_B(*i), 0, GETARG_C(*i));
++
++ return 1;
++}
++
++
++static void removevalues (FuncState *fs, int list) {
++ for (; list != NO_JUMP; list = getjump(fs, list))
++ patchtestreg(fs, list, NO_REG);
++}
++
++
++static void patchlistaux (FuncState *fs, int list, int vtarget, int reg,
++ int dtarget) {
++ while (list != NO_JUMP) {
++ int next = getjump(fs, list);
++ if (patchtestreg(fs, list, reg))
++ fixjump(fs, list, vtarget);
++ else
++ fixjump(fs, list, dtarget); /* jump to default target */
++ list = next;
++ }
++}
++
++
++static void dischargejpc (FuncState *fs) {
++ patchlistaux(fs, fs->jpc, fs->pc, NO_REG, fs->pc);
++ fs->jpc = NO_JUMP;
++}
++
++
++void luaK_patchlist (FuncState *fs, int list, int target) {
++ if (target == fs->pc)
++ luaK_patchtohere(fs, list);
++ else {
++ lua_assert(target < fs->pc);
++ patchlistaux(fs, list, target, NO_REG, target);
++ }
++}
++
++
++void luaK_patchtohere (FuncState *fs, int list) {
++ luaK_getlabel(fs);
++ luaK_concat(fs, &fs->jpc, list);
++}
++
++
++void luaK_concat (FuncState *fs, int *l1, int l2) {
++ if (l2 == NO_JUMP) return;
++ else if (*l1 == NO_JUMP)
++ *l1 = l2;
++ else {
++ int list = *l1;
++ int next;
++ while ((next = getjump(fs, list)) != NO_JUMP) /* find last element */
++ list = next;
++ fixjump(fs, list, l2);
++ }
++}
++
++
++void luaK_checkstack (FuncState *fs, int n) {
++ int newstack = fs->freereg + n;
++ if (newstack > fs->f->maxstacksize) {
++ if (newstack >= MAXSTACK)
++ luaX_syntaxerror(fs->ls, "function or expression too complex");
++ fs->f->maxstacksize = cast_byte(newstack);
++ }
++}
++
++
++void luaK_reserveregs (FuncState *fs, int n) {
++ luaK_checkstack(fs, n);
++ fs->freereg += n;
++}
++
++
++static void freereg (FuncState *fs, int reg) {
++ if (!ISK(reg) && reg >= fs->nactvar) {
++ fs->freereg--;
++ lua_assert(reg == fs->freereg);
++ }
++}
++
++
++static void freeexp (FuncState *fs, expdesc *e) {
++ if (e->k == VNONRELOC)
++ freereg(fs, e->u.s.info);
++}
++
++
++static int addk (FuncState *fs, TValue *k, TValue *v) {
++ lua_State *L = fs->L;
++ TValue *idx = luaH_set(L, fs->h, k);
++ Proto *f = fs->f;
++ int oldsize = f->sizek;
++ if (ttisnumber(idx)) {
++ lua_assert(luaO_rawequalObj(&fs->f->k[cast_int(nvalue(idx))], v));
++ return cast_int(nvalue(idx));
++ }
++ else { /* constant not found; create a new entry */
++ setnvalue(idx, cast_num(fs->nk));
++ luaM_growvector(L, f->k, fs->nk, f->sizek, TValue,
++ MAXARG_Bx, "constant table overflow");
++ while (oldsize < f->sizek) setnilvalue(&f->k[oldsize++]);
++ setobj(L, &f->k[fs->nk], v);
++ luaC_barrier(L, f, v);
++ return fs->nk++;
++ }
++}
++
++
++int luaK_stringK (FuncState *fs, TString *s) {
++ TValue o;
++ setsvalue(fs->L, &o, s);
++ return addk(fs, &o, &o);
++}
++
++
++int luaK_numberK (FuncState *fs, lua_Number r) {
++ TValue o;
++ setnvalue(&o, r);
++ return addk(fs, &o, &o);
++}
++
++
++static int boolK (FuncState *fs, int b) {
++ TValue o;
++ setbvalue(&o, b);
++ return addk(fs, &o, &o);
++}
++
++
++static int nilK (FuncState *fs) {
++ TValue k, v;
++ setnilvalue(&v);
++ /* cannot use nil as key; instead use table itself to represent nil */
++ sethvalue(fs->L, &k, fs->h);
++ return addk(fs, &k, &v);
++}
++
++
++void luaK_setreturns (FuncState *fs, expdesc *e, int nresults) {
++ if (e->k == VCALL) { /* expression is an open function call? */
++ SETARG_C(getcode(fs, e), nresults+1);
++ }
++ else if (e->k == VVARARG) {
++ SETARG_B(getcode(fs, e), nresults+1);
++ SETARG_A(getcode(fs, e), fs->freereg);
++ luaK_reserveregs(fs, 1);
++ }
++}
++
++
++void luaK_setoneret (FuncState *fs, expdesc *e) {
++ if (e->k == VCALL) { /* expression is an open function call? */
++ e->k = VNONRELOC;
++ e->u.s.info = GETARG_A(getcode(fs, e));
++ }
++ else if (e->k == VVARARG) {
++ SETARG_B(getcode(fs, e), 2);
++ e->k = VRELOCABLE; /* can relocate its simple result */
++ }
++}
++
++
++void luaK_dischargevars (FuncState *fs, expdesc *e) {
++ switch (e->k) {
++ case VLOCAL: {
++ e->k = VNONRELOC;
++ break;
++ }
++ case VUPVAL: {
++ e->u.s.info = luaK_codeABC(fs, OP_GETUPVAL, 0, e->u.s.info, 0);
++ e->k = VRELOCABLE;
++ break;
++ }
++ case VGLOBAL: {
++ e->u.s.info = luaK_codeABx(fs, OP_GETGLOBAL, 0, e->u.s.info);
++ e->k = VRELOCABLE;
++ break;
++ }
++ case VINDEXED: {
++ freereg(fs, e->u.s.aux);
++ freereg(fs, e->u.s.info);
++ e->u.s.info = luaK_codeABC(fs, OP_GETTABLE, 0, e->u.s.info, e->u.s.aux);
++ e->k = VRELOCABLE;
++ break;
++ }
++ case VVARARG:
++ case VCALL: {
++ luaK_setoneret(fs, e);
++ break;
++ }
++ default: break; /* there is one value available (somewhere) */
++ }
++}
++
++
++static int code_label (FuncState *fs, int A, int b, int jump) {
++ luaK_getlabel(fs); /* those instructions may be jump targets */
++ return luaK_codeABC(fs, OP_LOADBOOL, A, b, jump);
++}
++
++
++static void discharge2reg (FuncState *fs, expdesc *e, int reg) {
++ luaK_dischargevars(fs, e);
++ switch (e->k) {
++ case VNIL: {
++ luaK_nil(fs, reg, 1);
++ break;
++ }
++ case VFALSE: case VTRUE: {
++ luaK_codeABC(fs, OP_LOADBOOL, reg, e->k == VTRUE, 0);
++ break;
++ }
++ case VK: {
++ luaK_codeABx(fs, OP_LOADK, reg, e->u.s.info);
++ break;
++ }
++ case VKNUM: {
++ luaK_codeABx(fs, OP_LOADK, reg, luaK_numberK(fs, e->u.nval));
++ break;
++ }
++ case VRELOCABLE: {
++ Instruction *pc = &getcode(fs, e);
++ SETARG_A(*pc, reg);
++ break;
++ }
++ case VNONRELOC: {
++ if (reg != e->u.s.info)
++ luaK_codeABC(fs, OP_MOVE, reg, e->u.s.info, 0);
++ break;
++ }
++ default: {
++ lua_assert(e->k == VVOID || e->k == VJMP);
++ return; /* nothing to do... */
++ }
++ }
++ e->u.s.info = reg;
++ e->k = VNONRELOC;
++}
++
++
++static void discharge2anyreg (FuncState *fs, expdesc *e) {
++ if (e->k != VNONRELOC) {
++ luaK_reserveregs(fs, 1);
++ discharge2reg(fs, e, fs->freereg-1);
++ }
++}
++
++
++static void exp2reg (FuncState *fs, expdesc *e, int reg) {
++ discharge2reg(fs, e, reg);
++ if (e->k == VJMP)
++ luaK_concat(fs, &e->t, e->u.s.info); /* put this jump in `t' list */
++ if (hasjumps(e)) {
++ int final; /* position after whole expression */
++ int p_f = NO_JUMP; /* position of an eventual LOAD false */
++ int p_t = NO_JUMP; /* position of an eventual LOAD true */
++ if (need_value(fs, e->t) || need_value(fs, e->f)) {
++ int fj = (e->k == VJMP) ? NO_JUMP : luaK_jump(fs);
++ p_f = code_label(fs, reg, 0, 1);
++ p_t = code_label(fs, reg, 1, 0);
++ luaK_patchtohere(fs, fj);
++ }
++ final = luaK_getlabel(fs);
++ patchlistaux(fs, e->f, final, reg, p_f);
++ patchlistaux(fs, e->t, final, reg, p_t);
++ }
++ e->f = e->t = NO_JUMP;
++ e->u.s.info = reg;
++ e->k = VNONRELOC;
++}
++
++
++void luaK_exp2nextreg (FuncState *fs, expdesc *e) {
++ luaK_dischargevars(fs, e);
++ freeexp(fs, e);
++ luaK_reserveregs(fs, 1);
++ exp2reg(fs, e, fs->freereg - 1);
++}
++
++
++int luaK_exp2anyreg (FuncState *fs, expdesc *e) {
++ luaK_dischargevars(fs, e);
++ if (e->k == VNONRELOC) {
++ if (!hasjumps(e)) return e->u.s.info; /* exp is already in a register */
++ if (e->u.s.info >= fs->nactvar) { /* reg. is not a local? */
++ exp2reg(fs, e, e->u.s.info); /* put value on it */
++ return e->u.s.info;
++ }
++ }
++ luaK_exp2nextreg(fs, e); /* default */
++ return e->u.s.info;
++}
++
++
++void luaK_exp2val (FuncState *fs, expdesc *e) {
++ if (hasjumps(e))
++ luaK_exp2anyreg(fs, e);
++ else
++ luaK_dischargevars(fs, e);
++}
++
++
++int luaK_exp2RK (FuncState *fs, expdesc *e) {
++ luaK_exp2val(fs, e);
++ switch (e->k) {
++ case VKNUM:
++ case VTRUE:
++ case VFALSE:
++ case VNIL: {
++ if (fs->nk <= MAXINDEXRK) { /* constant fit in RK operand? */
++ e->u.s.info = (e->k == VNIL) ? nilK(fs) :
++ (e->k == VKNUM) ? luaK_numberK(fs, e->u.nval) :
++ boolK(fs, (e->k == VTRUE));
++ e->k = VK;
++ return RKASK(e->u.s.info);
++ }
++ else break;
++ }
++ case VK: {
++ if (e->u.s.info <= MAXINDEXRK) /* constant fit in argC? */
++ return RKASK(e->u.s.info);
++ else break;
++ }
++ default: break;
++ }
++ /* not a constant in the right range: put it in a register */
++ return luaK_exp2anyreg(fs, e);
++}
++
++
++void luaK_storevar (FuncState *fs, expdesc *var, expdesc *ex) {
++ switch (var->k) {
++ case VLOCAL: {
++ freeexp(fs, ex);
++ exp2reg(fs, ex, var->u.s.info);
++ return;
++ }
++ case VUPVAL: {
++ int e = luaK_exp2anyreg(fs, ex);
++ luaK_codeABC(fs, OP_SETUPVAL, e, var->u.s.info, 0);
++ break;
++ }
++ case VGLOBAL: {
++ int e = luaK_exp2anyreg(fs, ex);
++ luaK_codeABx(fs, OP_SETGLOBAL, e, var->u.s.info);
++ break;
++ }
++ case VINDEXED: {
++ int e = luaK_exp2RK(fs, ex);
++ luaK_codeABC(fs, OP_SETTABLE, var->u.s.info, var->u.s.aux, e);
++ break;
++ }
++ default: {
++ lua_assert(0); /* invalid var kind to store */
++ break;
++ }
++ }
++ freeexp(fs, ex);
++}
++
++
++void luaK_self (FuncState *fs, expdesc *e, expdesc *key) {
++ int func;
++ luaK_exp2anyreg(fs, e);
++ freeexp(fs, e);
++ func = fs->freereg;
++ luaK_reserveregs(fs, 2);
++ luaK_codeABC(fs, OP_SELF, func, e->u.s.info, luaK_exp2RK(fs, key));
++ freeexp(fs, key);
++ e->u.s.info = func;
++ e->k = VNONRELOC;
++}
++
++
++static void invertjump (FuncState *fs, expdesc *e) {
++ Instruction *pc = getjumpcontrol(fs, e->u.s.info);
++ lua_assert(testTMode(GET_OPCODE(*pc)) && GET_OPCODE(*pc) != OP_TESTSET &&
++ GET_OPCODE(*pc) != OP_TEST);
++ SETARG_A(*pc, !(GETARG_A(*pc)));
++}
++
++
++static int jumponcond (FuncState *fs, expdesc *e, int cond) {
++ if (e->k == VRELOCABLE) {
++ Instruction ie = getcode(fs, e);
++ if (GET_OPCODE(ie) == OP_NOT) {
++ fs->pc--; /* remove previous OP_NOT */
++ return condjump(fs, OP_TEST, GETARG_B(ie), 0, !cond);
++ }
++ /* else go through */
++ }
++ discharge2anyreg(fs, e);
++ freeexp(fs, e);
++ return condjump(fs, OP_TESTSET, NO_REG, e->u.s.info, cond);
++}
++
++
++void luaK_goiftrue (FuncState *fs, expdesc *e) {
++ int pc; /* pc of last jump */
++ luaK_dischargevars(fs, e);
++ switch (e->k) {
++ case VK: case VKNUM: case VTRUE: {
++ pc = NO_JUMP; /* always true; do nothing */
++ break;
++ }
++ case VFALSE: {
++ pc = luaK_jump(fs); /* always jump */
++ break;
++ }
++ case VJMP: {
++ invertjump(fs, e);
++ pc = e->u.s.info;
++ break;
++ }
++ default: {
++ pc = jumponcond(fs, e, 0);
++ break;
++ }
++ }
++ luaK_concat(fs, &e->f, pc); /* insert last jump in `f' list */
++ luaK_patchtohere(fs, e->t);
++ e->t = NO_JUMP;
++}
++
++
++static void luaK_goiffalse (FuncState *fs, expdesc *e) {
++ int pc; /* pc of last jump */
++ luaK_dischargevars(fs, e);
++ switch (e->k) {
++ case VNIL: case VFALSE: {
++ pc = NO_JUMP; /* always false; do nothing */
++ break;
++ }
++ case VTRUE: {
++ pc = luaK_jump(fs); /* always jump */
++ break;
++ }
++ case VJMP: {
++ pc = e->u.s.info;
++ break;
++ }
++ default: {
++ pc = jumponcond(fs, e, 1);
++ break;
++ }
++ }
++ luaK_concat(fs, &e->t, pc); /* insert last jump in `t' list */
++ luaK_patchtohere(fs, e->f);
++ e->f = NO_JUMP;
++}
++
++
++static void codenot (FuncState *fs, expdesc *e) {
++ luaK_dischargevars(fs, e);
++ switch (e->k) {
++ case VNIL: case VFALSE: {
++ e->k = VTRUE;
++ break;
++ }
++ case VK: case VKNUM: case VTRUE: {
++ e->k = VFALSE;
++ break;
++ }
++ case VJMP: {
++ invertjump(fs, e);
++ break;
++ }
++ case VRELOCABLE:
++ case VNONRELOC: {
++ discharge2anyreg(fs, e);
++ freeexp(fs, e);
++ e->u.s.info = luaK_codeABC(fs, OP_NOT, 0, e->u.s.info, 0);
++ e->k = VRELOCABLE;
++ break;
++ }
++ default: {
++ lua_assert(0); /* cannot happen */
++ break;
++ }
++ }
++ /* interchange true and false lists */
++ { int temp = e->f; e->f = e->t; e->t = temp; }
++ removevalues(fs, e->f);
++ removevalues(fs, e->t);
++}
++
++
++void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) {
++ t->u.s.aux = luaK_exp2RK(fs, k);
++ t->k = VINDEXED;
++}
++
++
++static int constfolding (OpCode op, expdesc *e1, expdesc *e2) {
++ lua_Number v1, v2, r;
++ if (!isnumeral(e1) || !isnumeral(e2)) return 0;
++ v1 = e1->u.nval;
++ v2 = e2->u.nval;
++ switch (op) {
++ case OP_ADD: r = luai_numadd(v1, v2); break;
++ case OP_SUB: r = luai_numsub(v1, v2); break;
++ case OP_MUL: r = luai_nummul(v1, v2); break;
++ case OP_DIV:
++ if (v2 == 0) return 0; /* do not attempt to divide by 0 */
++ r = luai_numdiv(v1, v2); break;
++ case OP_MOD:
++ if (v2 == 0) return 0; /* do not attempt to divide by 0 */
++ r = luai_nummod(v1, v2); break;
++ case OP_POW: r = luai_numpow(v1, v2); break;
++ case OP_UNM: r = luai_numunm(v1); break;
++ case OP_LEN: return 0; /* no constant folding for 'len' */
++ default: lua_assert(0); r = 0; break;
++ }
++ if (luai_numisnan(r)) return 0; /* do not attempt to produce NaN */
++ e1->u.nval = r;
++ return 1;
++}
++
++
++static void codearith (FuncState *fs, OpCode op, expdesc *e1, expdesc *e2) {
++ if (constfolding(op, e1, e2))
++ return;
++ else {
++ int o2 = (op != OP_UNM && op != OP_LEN) ? luaK_exp2RK(fs, e2) : 0;
++ int o1 = luaK_exp2RK(fs, e1);
++ if (o1 > o2) {
++ freeexp(fs, e1);
++ freeexp(fs, e2);
++ }
++ else {
++ freeexp(fs, e2);
++ freeexp(fs, e1);
++ }
++ e1->u.s.info = luaK_codeABC(fs, op, 0, o1, o2);
++ e1->k = VRELOCABLE;
++ }
++}
++
++
++static void codecomp (FuncState *fs, OpCode op, int cond, expdesc *e1,
++ expdesc *e2) {
++ int o1 = luaK_exp2RK(fs, e1);
++ int o2 = luaK_exp2RK(fs, e2);
++ freeexp(fs, e2);
++ freeexp(fs, e1);
++ if (cond == 0 && op != OP_EQ) {
++ int temp; /* exchange args to replace by `<' or `<=' */
++ temp = o1; o1 = o2; o2 = temp; /* o1 <==> o2 */
++ cond = 1;
++ }
++ e1->u.s.info = condjump(fs, op, cond, o1, o2);
++ e1->k = VJMP;
++}
++
++
++void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e) {
++ expdesc e2;
++ e2.t = e2.f = NO_JUMP; e2.k = VKNUM; e2.u.nval = 0;
++ switch (op) {
++ case OPR_MINUS: {
++ if (!isnumeral(e))
++ luaK_exp2anyreg(fs, e); /* cannot operate on non-numeric constants */
++ codearith(fs, OP_UNM, e, &e2);
++ break;
++ }
++ case OPR_NOT: codenot(fs, e); break;
++ case OPR_LEN: {
++ luaK_exp2anyreg(fs, e); /* cannot operate on constants */
++ codearith(fs, OP_LEN, e, &e2);
++ break;
++ }
++ default: lua_assert(0);
++ }
++}
++
++
++void luaK_infix (FuncState *fs, BinOpr op, expdesc *v) {
++ switch (op) {
++ case OPR_AND: {
++ luaK_goiftrue(fs, v);
++ break;
++ }
++ case OPR_OR: {
++ luaK_goiffalse(fs, v);
++ break;
++ }
++ case OPR_CONCAT: {
++ luaK_exp2nextreg(fs, v); /* operand must be on the `stack' */
++ break;
++ }
++ case OPR_ADD: case OPR_SUB: case OPR_MUL: case OPR_DIV:
++ case OPR_MOD: case OPR_POW: {
++ if (!isnumeral(v)) luaK_exp2RK(fs, v);
++ break;
++ }
++ default: {
++ luaK_exp2RK(fs, v);
++ break;
++ }
++ }
++}
++
++
++void luaK_posfix (FuncState *fs, BinOpr op, expdesc *e1, expdesc *e2) {
++ switch (op) {
++ case OPR_AND: {
++ lua_assert(e1->t == NO_JUMP); /* list must be closed */
++ luaK_dischargevars(fs, e2);
++ luaK_concat(fs, &e2->f, e1->f);
++ *e1 = *e2;
++ break;
++ }
++ case OPR_OR: {
++ lua_assert(e1->f == NO_JUMP); /* list must be closed */
++ luaK_dischargevars(fs, e2);
++ luaK_concat(fs, &e2->t, e1->t);
++ *e1 = *e2;
++ break;
++ }
++ case OPR_CONCAT: {
++ luaK_exp2val(fs, e2);
++ if (e2->k == VRELOCABLE && GET_OPCODE(getcode(fs, e2)) == OP_CONCAT) {
++ lua_assert(e1->u.s.info == GETARG_B(getcode(fs, e2))-1);
++ freeexp(fs, e1);
++ SETARG_B(getcode(fs, e2), e1->u.s.info);
++ e1->k = VRELOCABLE; e1->u.s.info = e2->u.s.info;
++ }
++ else {
++ luaK_exp2nextreg(fs, e2); /* operand must be on the 'stack' */
++ codearith(fs, OP_CONCAT, e1, e2);
++ }
++ break;
++ }
++ case OPR_ADD: codearith(fs, OP_ADD, e1, e2); break;
++ case OPR_SUB: codearith(fs, OP_SUB, e1, e2); break;
++ case OPR_MUL: codearith(fs, OP_MUL, e1, e2); break;
++ case OPR_DIV: codearith(fs, OP_DIV, e1, e2); break;
++ case OPR_MOD: codearith(fs, OP_MOD, e1, e2); break;
++ case OPR_POW: codearith(fs, OP_POW, e1, e2); break;
++ case OPR_EQ: codecomp(fs, OP_EQ, 1, e1, e2); break;
++ case OPR_NE: codecomp(fs, OP_EQ, 0, e1, e2); break;
++ case OPR_LT: codecomp(fs, OP_LT, 1, e1, e2); break;
++ case OPR_LE: codecomp(fs, OP_LE, 1, e1, e2); break;
++ case OPR_GT: codecomp(fs, OP_LT, 0, e1, e2); break;
++ case OPR_GE: codecomp(fs, OP_LE, 0, e1, e2); break;
++ default: lua_assert(0);
++ }
++}
++
++
++void luaK_fixline (FuncState *fs, int line) {
++ fs->f->lineinfo[fs->pc - 1] = line;
++}
++
++
++static int luaK_code (FuncState *fs, Instruction i, int line) {
++ Proto *f = fs->f;
++ dischargejpc(fs); /* `pc' will change */
++ /* put new instruction in code array */
++ luaM_growvector(fs->L, f->code, fs->pc, f->sizecode, Instruction,
++ MAX_INT, "code size overflow");
++ f->code[fs->pc] = i;
++ /* save corresponding line information */
++ luaM_growvector(fs->L, f->lineinfo, fs->pc, f->sizelineinfo, int,
++ MAX_INT, "code size overflow");
++ f->lineinfo[fs->pc] = line;
++ return fs->pc++;
++}
++
++
++int luaK_codeABC (FuncState *fs, OpCode o, int a, int b, int c) {
++ lua_assert(getOpMode(o) == iABC);
++ lua_assert(getBMode(o) != OpArgN || b == 0);
++ lua_assert(getCMode(o) != OpArgN || c == 0);
++ return luaK_code(fs, CREATE_ABC(o, a, b, c), fs->ls->lastline);
++}
++
++
++int luaK_codeABx (FuncState *fs, OpCode o, int a, unsigned int bc) {
++ lua_assert(getOpMode(o) == iABx || getOpMode(o) == iAsBx);
++ lua_assert(getCMode(o) == OpArgN);
++ return luaK_code(fs, CREATE_ABx(o, a, bc), fs->ls->lastline);
++}
++
++
++void luaK_setlist (FuncState *fs, int base, int nelems, int tostore) {
++ int c = (nelems - 1)/LFIELDS_PER_FLUSH + 1;
++ int b = (tostore == LUA_MULTRET) ? 0 : tostore;
++ lua_assert(tostore != 0);
++ if (c <= MAXARG_C)
++ luaK_codeABC(fs, OP_SETLIST, base, b, c);
++ else {
++ luaK_codeABC(fs, OP_SETLIST, base, b, 0);
++ luaK_code(fs, cast(Instruction, c), fs->ls->lastline);
++ }
++ fs->freereg = base + 1; /* free registers with list values */
++}
++
+--- /dev/null
++++ b/extensions/LUA/lua/lcode.h
+@@ -0,0 +1,76 @@
++/*
++** $Id: lcode.h,v 1.48.1.1 2007/12/27 13:02:25 roberto Exp $
++** Code generator for Lua
++** See Copyright Notice in lua.h
++*/
++
++#ifndef lcode_h
++#define lcode_h
++
++#include "llex.h"
++#include "lobject.h"
++#include "lopcodes.h"
++#include "lparser.h"
++
++
++/*
++** Marks the end of a patch list. It is an invalid value both as an absolute
++** address, and as a list link (would link an element to itself).
++*/
++#define NO_JUMP (-1)
++
++
++/*
++** grep "ORDER OPR" if you change these enums
++*/
++typedef enum BinOpr {
++ OPR_ADD, OPR_SUB, OPR_MUL, OPR_DIV, OPR_MOD, OPR_POW,
++ OPR_CONCAT,
++ OPR_NE, OPR_EQ,
++ OPR_LT, OPR_LE, OPR_GT, OPR_GE,
++ OPR_AND, OPR_OR,
++ OPR_NOBINOPR
++} BinOpr;
++
++
++typedef enum UnOpr { OPR_MINUS, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr;
++
++
++#define getcode(fs,e) ((fs)->f->code[(e)->u.s.info])
++
++#define luaK_codeAsBx(fs,o,A,sBx) luaK_codeABx(fs,o,A,(sBx)+MAXARG_sBx)
++
++#define luaK_setmultret(fs,e) luaK_setreturns(fs, e, LUA_MULTRET)
++
++LUAI_FUNC int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bx);
++LUAI_FUNC int luaK_codeABC (FuncState *fs, OpCode o, int A, int B, int C);
++LUAI_FUNC void luaK_fixline (FuncState *fs, int line);
++LUAI_FUNC void luaK_nil (FuncState *fs, int from, int n);
++LUAI_FUNC void luaK_reserveregs (FuncState *fs, int n);
++LUAI_FUNC void luaK_checkstack (FuncState *fs, int n);
++LUAI_FUNC int luaK_stringK (FuncState *fs, TString *s);
++LUAI_FUNC int luaK_numberK (FuncState *fs, lua_Number r);
++LUAI_FUNC void luaK_dischargevars (FuncState *fs, expdesc *e);
++LUAI_FUNC int luaK_exp2anyreg (FuncState *fs, expdesc *e);
++LUAI_FUNC void luaK_exp2nextreg (FuncState *fs, expdesc *e);
++LUAI_FUNC void luaK_exp2val (FuncState *fs, expdesc *e);
++LUAI_FUNC int luaK_exp2RK (FuncState *fs, expdesc *e);
++LUAI_FUNC void luaK_self (FuncState *fs, expdesc *e, expdesc *key);
++LUAI_FUNC void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k);
++LUAI_FUNC void luaK_goiftrue (FuncState *fs, expdesc *e);
++LUAI_FUNC void luaK_storevar (FuncState *fs, expdesc *var, expdesc *e);
++LUAI_FUNC void luaK_setreturns (FuncState *fs, expdesc *e, int nresults);
++LUAI_FUNC void luaK_setoneret (FuncState *fs, expdesc *e);
++LUAI_FUNC int luaK_jump (FuncState *fs);
++LUAI_FUNC void luaK_ret (FuncState *fs, int first, int nret);
++LUAI_FUNC void luaK_patchlist (FuncState *fs, int list, int target);
++LUAI_FUNC void luaK_patchtohere (FuncState *fs, int list);
++LUAI_FUNC void luaK_concat (FuncState *fs, int *l1, int l2);
++LUAI_FUNC int luaK_getlabel (FuncState *fs);
++LUAI_FUNC void luaK_prefix (FuncState *fs, UnOpr op, expdesc *v);
++LUAI_FUNC void luaK_infix (FuncState *fs, BinOpr op, expdesc *v);
++LUAI_FUNC void luaK_posfix (FuncState *fs, BinOpr op, expdesc *v1, expdesc *v2);
++LUAI_FUNC void luaK_setlist (FuncState *fs, int base, int nelems, int tostore);
++
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/ldebug.c
+@@ -0,0 +1,637 @@
++/*
++** $Id: ldebug.c,v 2.29.1.6 2008/05/08 16:56:26 roberto Exp $
++** Debug Interface
++** See Copyright Notice in lua.h
++*/
++
++
++#include <stdarg.h>
++#include <stddef.h>
++#include <string.h>
++
++#define ldebug_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "lapi.h"
++#include "lcode.h"
++#include "ldebug.h"
++#include "ldo.h"
++#include "lfunc.h"
++#include "lobject.h"
++#include "lopcodes.h"
++#include "lstate.h"
++#include "lstring.h"
++#include "ltable.h"
++#include "ltm.h"
++#include "lvm.h"
++
++
++
++static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name);
++
++
++static int currentpc (lua_State *L, CallInfo *ci) {
++ if (!isLua(ci)) return -1; /* function is not a Lua function? */
++ if (ci == L->ci)
++ ci->savedpc = L->savedpc;
++ return pcRel(ci->savedpc, ci_func(ci)->l.p);
++}
++
++
++static int currentline (lua_State *L, CallInfo *ci) {
++ int pc = currentpc(L, ci);
++ if (pc < 0)
++ return -1; /* only active lua functions have current-line information */
++ else
++ return getline(ci_func(ci)->l.p, pc);
++}
++
++
++/*
++** this function can be called asynchronous (e.g. during a signal)
++*/
++LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count) {
++ if (func == NULL || mask == 0) { /* turn off hooks? */
++ mask = 0;
++ func = NULL;
++ }
++ L->hook = func;
++ L->basehookcount = count;
++ resethookcount(L);
++ L->hookmask = cast_byte(mask);
++ return 1;
++}
++
++
++LUA_API lua_Hook lua_gethook (lua_State *L) {
++ return L->hook;
++}
++
++
++LUA_API int lua_gethookmask (lua_State *L) {
++ return L->hookmask;
++}
++
++
++LUA_API int lua_gethookcount (lua_State *L) {
++ return L->basehookcount;
++}
++
++
++LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar) {
++ int status;
++ CallInfo *ci;
++ lua_lock(L);
++ for (ci = L->ci; level > 0 && ci > L->base_ci; ci--) {
++ level--;
++ if (f_isLua(ci)) /* Lua function? */
++ level -= ci->tailcalls; /* skip lost tail calls */
++ }
++ if (level == 0 && ci > L->base_ci) { /* level found? */
++ status = 1;
++ ar->i_ci = cast_int(ci - L->base_ci);
++ }
++ else if (level < 0) { /* level is of a lost tail call? */
++ status = 1;
++ ar->i_ci = 0;
++ }
++ else status = 0; /* no such level */
++ lua_unlock(L);
++ return status;
++}
++
++
++static Proto *getluaproto (CallInfo *ci) {
++ return (isLua(ci) ? ci_func(ci)->l.p : NULL);
++}
++
++
++static const char *findlocal (lua_State *L, CallInfo *ci, int n) {
++ const char *name;
++ Proto *fp = getluaproto(ci);
++ if (fp && (name = luaF_getlocalname(fp, n, currentpc(L, ci))) != NULL)
++ return name; /* is a local variable in a Lua function */
++ else {
++ StkId limit = (ci == L->ci) ? L->top : (ci+1)->func;
++ if (limit - ci->base >= n && n > 0) /* is 'n' inside 'ci' stack? */
++ return "(*temporary)";
++ else
++ return NULL;
++ }
++}
++
++
++LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) {
++ CallInfo *ci = L->base_ci + ar->i_ci;
++ const char *name = findlocal(L, ci, n);
++ lua_lock(L);
++ if (name)
++ luaA_pushobject(L, ci->base + (n - 1));
++ lua_unlock(L);
++ return name;
++}
++
++
++LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) {
++ CallInfo *ci = L->base_ci + ar->i_ci;
++ const char *name = findlocal(L, ci, n);
++ lua_lock(L);
++ if (name)
++ setobjs2s(L, ci->base + (n - 1), L->top - 1);
++ L->top--; /* pop value */
++ lua_unlock(L);
++ return name;
++}
++
++
++static void funcinfo (lua_Debug *ar, Closure *cl) {
++ if (cl->c.isC) {
++ ar->source = "=[C]";
++ ar->linedefined = -1;
++ ar->lastlinedefined = -1;
++ ar->what = "C";
++ }
++ else {
++ ar->source = getstr(cl->l.p->source);
++ ar->linedefined = cl->l.p->linedefined;
++ ar->lastlinedefined = cl->l.p->lastlinedefined;
++ ar->what = (ar->linedefined == 0) ? "main" : "Lua";
++ }
++ luaO_chunkid(ar->short_src, ar->source, LUA_IDSIZE);
++}
++
++
++static void info_tailcall (lua_Debug *ar) {
++ ar->name = ar->namewhat = "";
++ ar->what = "tail";
++ ar->lastlinedefined = ar->linedefined = ar->currentline = -1;
++ ar->source = "=(tail call)";
++ luaO_chunkid(ar->short_src, ar->source, LUA_IDSIZE);
++ ar->nups = 0;
++}
++
++
++static void collectvalidlines (lua_State *L, Closure *f) {
++ if (f == NULL || f->c.isC) {
++ setnilvalue(L->top);
++ }
++ else {
++ Table *t = luaH_new(L, 0, 0);
++ int *lineinfo = f->l.p->lineinfo;
++ int i;
++ for (i=0; i<f->l.p->sizelineinfo; i++)
++ setbvalue(luaH_setnum(L, t, lineinfo[i]), 1);
++ sethvalue(L, L->top, t);
++ }
++ incr_top(L);
++}
++
++
++static int auxgetinfo (lua_State *L, const char *what, lua_Debug *ar,
++ Closure *f, CallInfo *ci) {
++ int status = 1;
++ if (f == NULL) {
++ info_tailcall(ar);
++ return status;
++ }
++ for (; *what; what++) {
++ switch (*what) {
++ case 'S': {
++ funcinfo(ar, f);
++ break;
++ }
++ case 'l': {
++ ar->currentline = (ci) ? currentline(L, ci) : -1;
++ break;
++ }
++ case 'u': {
++ ar->nups = f->c.nupvalues;
++ break;
++ }
++ case 'n': {
++ ar->namewhat = (ci) ? getfuncname(L, ci, &ar->name) : NULL;
++ if (ar->namewhat == NULL) {
++ ar->namewhat = ""; /* not found */
++ ar->name = NULL;
++ }
++ break;
++ }
++ case 'L':
++ case 'f': /* handled by lua_getinfo */
++ break;
++ default: status = 0; /* invalid option */
++ }
++ }
++ return status;
++}
++
++
++LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) {
++ int status;
++ Closure *f = NULL;
++ CallInfo *ci = NULL;
++ lua_lock(L);
++ if (*what == '>') {
++ StkId func = L->top - 1;
++ luai_apicheck(L, ttisfunction(func));
++ what++; /* skip the '>' */
++ f = clvalue(func);
++ L->top--; /* pop function */
++ }
++ else if (ar->i_ci != 0) { /* no tail call? */
++ ci = L->base_ci + ar->i_ci;
++ lua_assert(ttisfunction(ci->func));
++ f = clvalue(ci->func);
++ }
++ status = auxgetinfo(L, what, ar, f, ci);
++ if (strchr(what, 'f')) {
++ if (f == NULL) setnilvalue(L->top);
++ else setclvalue(L, L->top, f);
++ incr_top(L);
++ }
++ if (strchr(what, 'L'))
++ collectvalidlines(L, f);
++ lua_unlock(L);
++ return status;
++}
++
++
++/*
++** {======================================================
++** Symbolic Execution and code checker
++** =======================================================
++*/
++
++#define check(x) if (!(x)) return 0;
++
++#define checkjump(pt,pc) check(0 <= pc && pc < pt->sizecode)
++
++#define checkreg(pt,reg) check((reg) < (pt)->maxstacksize)
++
++
++
++static int precheck (const Proto *pt) {
++ check(pt->maxstacksize <= MAXSTACK);
++ check(pt->numparams+(pt->is_vararg & VARARG_HASARG) <= pt->maxstacksize);
++ check(!(pt->is_vararg & VARARG_NEEDSARG) ||
++ (pt->is_vararg & VARARG_HASARG));
++ check(pt->sizeupvalues <= pt->nups);
++ check(pt->sizelineinfo == pt->sizecode || pt->sizelineinfo == 0);
++ check(pt->sizecode > 0 && GET_OPCODE(pt->code[pt->sizecode-1]) == OP_RETURN);
++ return 1;
++}
++
++
++#define checkopenop(pt,pc) luaG_checkopenop((pt)->code[(pc)+1])
++
++int luaG_checkopenop (Instruction i) {
++ switch (GET_OPCODE(i)) {
++ case OP_CALL:
++ case OP_TAILCALL:
++ case OP_RETURN:
++ case OP_SETLIST: {
++ check(GETARG_B(i) == 0);
++ return 1;
++ }
++ default: return 0; /* invalid instruction after an open call */
++ }
++}
++
++
++static int checkArgMode (const Proto *pt, int r, enum OpArgMask mode) {
++ switch (mode) {
++ case OpArgN: check(r == 0); break;
++ case OpArgU: break;
++ case OpArgR: checkreg(pt, r); break;
++ case OpArgK:
++ check(ISK(r) ? INDEXK(r) < pt->sizek : r < pt->maxstacksize);
++ break;
++ }
++ return 1;
++}
++
++
++static Instruction symbexec (const Proto *pt, int lastpc, int reg) {
++ int pc;
++ int last; /* stores position of last instruction that changed `reg' */
++ last = pt->sizecode-1; /* points to final return (a `neutral' instruction) */
++ check(precheck(pt));
++ for (pc = 0; pc < lastpc; pc++) {
++ Instruction i = pt->code[pc];
++ OpCode op = GET_OPCODE(i);
++ int a = GETARG_A(i);
++ int b = 0;
++ int c = 0;
++ check(op < NUM_OPCODES);
++ checkreg(pt, a);
++ switch (getOpMode(op)) {
++ case iABC: {
++ b = GETARG_B(i);
++ c = GETARG_C(i);
++ check(checkArgMode(pt, b, getBMode(op)));
++ check(checkArgMode(pt, c, getCMode(op)));
++ break;
++ }
++ case iABx: {
++ b = GETARG_Bx(i);
++ if (getBMode(op) == OpArgK) check(b < pt->sizek);
++ break;
++ }
++ case iAsBx: {
++ b = GETARG_sBx(i);
++ if (getBMode(op) == OpArgR) {
++ int dest = pc+1+b;
++ check(0 <= dest && dest < pt->sizecode);
++ if (dest > 0) {
++ int j;
++ /* check that it does not jump to a setlist count; this
++ is tricky, because the count from a previous setlist may
++ have the same value of an invalid setlist; so, we must
++ go all the way back to the first of them (if any) */
++ for (j = 0; j < dest; j++) {
++ Instruction d = pt->code[dest-1-j];
++ if (!(GET_OPCODE(d) == OP_SETLIST && GETARG_C(d) == 0)) break;
++ }
++ /* if 'j' is even, previous value is not a setlist (even if
++ it looks like one) */
++ check((j&1) == 0);
++ }
++ }
++ break;
++ }
++ }
++ if (testAMode(op)) {
++ if (a == reg) last = pc; /* change register `a' */
++ }
++ if (testTMode(op)) {
++ check(pc+2 < pt->sizecode); /* check skip */
++ check(GET_OPCODE(pt->code[pc+1]) == OP_JMP);
++ }
++ switch (op) {
++ case OP_LOADBOOL: {
++ if (c == 1) { /* does it jump? */
++ check(pc+2 < pt->sizecode); /* check its jump */
++ check(GET_OPCODE(pt->code[pc+1]) != OP_SETLIST ||
++ GETARG_C(pt->code[pc+1]) != 0);
++ }
++ break;
++ }
++ case OP_LOADNIL: {
++ if (a <= reg && reg <= b)
++ last = pc; /* set registers from `a' to `b' */
++ break;
++ }
++ case OP_GETUPVAL:
++ case OP_SETUPVAL: {
++ check(b < pt->nups);
++ break;
++ }
++ case OP_GETGLOBAL:
++ case OP_SETGLOBAL: {
++ check(ttisstring(&pt->k[b]));
++ break;
++ }
++ case OP_SELF: {
++ checkreg(pt, a+1);
++ if (reg == a+1) last = pc;
++ break;
++ }
++ case OP_CONCAT: {
++ check(b < c); /* at least two operands */
++ break;
++ }
++ case OP_TFORLOOP: {
++ check(c >= 1); /* at least one result (control variable) */
++ checkreg(pt, a+2+c); /* space for results */
++ if (reg >= a+2) last = pc; /* affect all regs above its base */
++ break;
++ }
++ case OP_FORLOOP:
++ case OP_FORPREP:
++ checkreg(pt, a+3);
++ /* go through */
++ case OP_JMP: {
++ int dest = pc+1+b;
++ /* not full check and jump is forward and do not skip `lastpc'? */
++ if (reg != NO_REG && pc < dest && dest <= lastpc)
++ pc += b; /* do the jump */
++ break;
++ }
++ case OP_CALL:
++ case OP_TAILCALL: {
++ if (b != 0) {
++ checkreg(pt, a+b-1);
++ }
++ c--; /* c = num. returns */
++ if (c == LUA_MULTRET) {
++ check(checkopenop(pt, pc));
++ }
++ else if (c != 0)
++ checkreg(pt, a+c-1);
++ if (reg >= a) last = pc; /* affect all registers above base */
++ break;
++ }
++ case OP_RETURN: {
++ b--; /* b = num. returns */
++ if (b > 0) checkreg(pt, a+b-1);
++ break;
++ }
++ case OP_SETLIST: {
++ if (b > 0) checkreg(pt, a + b);
++ if (c == 0) {
++ pc++;
++ check(pc < pt->sizecode - 1);
++ }
++ break;
++ }
++ case OP_CLOSURE: {
++ int nup, j;
++ check(b < pt->sizep);
++ nup = pt->p[b]->nups;
++ check(pc + nup < pt->sizecode);
++ for (j = 1; j <= nup; j++) {
++ OpCode op1 = GET_OPCODE(pt->code[pc + j]);
++ check(op1 == OP_GETUPVAL || op1 == OP_MOVE);
++ }
++ if (reg != NO_REG) /* tracing? */
++ pc += nup; /* do not 'execute' these pseudo-instructions */
++ break;
++ }
++ case OP_VARARG: {
++ check((pt->is_vararg & VARARG_ISVARARG) &&
++ !(pt->is_vararg & VARARG_NEEDSARG));
++ b--;
++ if (b == LUA_MULTRET) check(checkopenop(pt, pc));
++ checkreg(pt, a+b-1);
++ break;
++ }
++ default: break;
++ }
++ }
++ return pt->code[last];
++}
++
++#undef check
++#undef checkjump
++#undef checkreg
++
++/* }====================================================== */
++
++
++int luaG_checkcode (const Proto *pt) {
++ return (symbexec(pt, pt->sizecode, NO_REG) != 0);
++}
++
++
++static const char *kname (Proto *p, int c) {
++ if (ISK(c) && ttisstring(&p->k[INDEXK(c)]))
++ return svalue(&p->k[INDEXK(c)]);
++ else
++ return "?";
++}
++
++
++static const char *getobjname (lua_State *L, CallInfo *ci, int stackpos,
++ const char **name) {
++ if (isLua(ci)) { /* a Lua function? */
++ Proto *p = ci_func(ci)->l.p;
++ int pc = currentpc(L, ci);
++ Instruction i;
++ *name = luaF_getlocalname(p, stackpos+1, pc);
++ if (*name) /* is a local? */
++ return "local";
++ i = symbexec(p, pc, stackpos); /* try symbolic execution */
++ lua_assert(pc != -1);
++ switch (GET_OPCODE(i)) {
++ case OP_GETGLOBAL: {
++ int g = GETARG_Bx(i); /* global index */
++ lua_assert(ttisstring(&p->k[g]));
++ *name = svalue(&p->k[g]);
++ return "global";
++ }
++ case OP_MOVE: {
++ int a = GETARG_A(i);
++ int b = GETARG_B(i); /* move from `b' to `a' */
++ if (b < a)
++ return getobjname(L, ci, b, name); /* get name for `b' */
++ break;
++ }
++ case OP_GETTABLE: {
++ int k = GETARG_C(i); /* key index */
++ *name = kname(p, k);
++ return "field";
++ }
++ case OP_GETUPVAL: {
++ int u = GETARG_B(i); /* upvalue index */
++ *name = p->upvalues ? getstr(p->upvalues[u]) : "?";
++ return "upvalue";
++ }
++ case OP_SELF: {
++ int k = GETARG_C(i); /* key index */
++ *name = kname(p, k);
++ return "method";
++ }
++ default: break;
++ }
++ }
++ return NULL; /* no useful name found */
++}
++
++
++static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name) {
++ Instruction i;
++ if ((isLua(ci) && ci->tailcalls > 0) || !isLua(ci - 1))
++ return NULL; /* calling function is not Lua (or is unknown) */
++ ci--; /* calling function */
++ i = ci_func(ci)->l.p->code[currentpc(L, ci)];
++ if (GET_OPCODE(i) == OP_CALL || GET_OPCODE(i) == OP_TAILCALL ||
++ GET_OPCODE(i) == OP_TFORLOOP)
++ return getobjname(L, ci, GETARG_A(i), name);
++ else
++ return NULL; /* no useful name can be found */
++}
++
++
++/* only ANSI way to check whether a pointer points to an array */
++static int isinstack (CallInfo *ci, const TValue *o) {
++ StkId p;
++ for (p = ci->base; p < ci->top; p++)
++ if (o == p) return 1;
++ return 0;
++}
++
++
++void luaG_typeerror (lua_State *L, const TValue *o, const char *op) {
++ const char *name = NULL;
++ const char *t = luaT_typenames[ttype(o)];
++ const char *kind = (isinstack(L->ci, o)) ?
++ getobjname(L, L->ci, cast_int(o - L->base), &name) :
++ NULL;
++ if (kind)
++ luaG_runerror(L, "attempt to %s %s " LUA_QS " (a %s value)",
++ op, kind, name, t);
++ else
++ luaG_runerror(L, "attempt to %s a %s value", op, t);
++}
++
++
++void luaG_concaterror (lua_State *L, StkId p1, StkId p2) {
++ if (ttisstring(p1) || ttisnumber(p1)) p1 = p2;
++ lua_assert(!ttisstring(p1) && !ttisnumber(p1));
++ luaG_typeerror(L, p1, "concatenate");
++}
++
++
++void luaG_aritherror (lua_State *L, const TValue *p1, const TValue *p2) {
++ TValue temp;
++ if (luaV_tonumber(p1, &temp) == NULL)
++ p2 = p1; /* first operand is wrong */
++ luaG_typeerror(L, p2, "perform arithmetic on");
++}
++
++
++int luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2) {
++ const char *t1 = luaT_typenames[ttype(p1)];
++ const char *t2 = luaT_typenames[ttype(p2)];
++ if (t1[2] == t2[2])
++ luaG_runerror(L, "attempt to compare two %s values", t1);
++ else
++ luaG_runerror(L, "attempt to compare %s with %s", t1, t2);
++ return 0;
++}
++
++
++static void addinfo (lua_State *L, const char *msg) {
++ CallInfo *ci = L->ci;
++ if (isLua(ci)) { /* is Lua code? */
++ char buff[LUA_IDSIZE]; /* add file:line information */
++ int line = currentline(L, ci);
++ luaO_chunkid(buff, getstr(getluaproto(ci)->source), LUA_IDSIZE);
++ luaO_pushfstring(L, "%s:%d: %s", buff, line, msg);
++ }
++}
++
++
++void luaG_errormsg (lua_State *L) {
++ if (L->errfunc != 0) { /* is there an error handling function? */
++ StkId errfunc = restorestack(L, L->errfunc);
++ if (!ttisfunction(errfunc)) luaD_throw(L, LUA_ERRERR);
++ setobjs2s(L, L->top, L->top - 1); /* move argument */
++ setobjs2s(L, L->top - 1, errfunc); /* push function */
++ incr_top(L);
++ luaD_call(L, L->top - 2, 1); /* call it */
++ }
++ luaD_throw(L, LUA_ERRRUN);
++}
++
++
++void luaG_runerror (lua_State *L, const char *fmt, ...) {
++ va_list argp;
++ va_start(argp, fmt);
++ addinfo(L, luaO_pushvfstring(L, fmt, argp));
++ va_end(argp);
++ luaG_errormsg(L);
++}
++
+--- /dev/null
++++ b/extensions/LUA/lua/ldebug.h
+@@ -0,0 +1,33 @@
++/*
++** $Id: ldebug.h,v 2.3.1.1 2007/12/27 13:02:25 roberto Exp $
++** Auxiliary functions from Debug Interface module
++** See Copyright Notice in lua.h
++*/
++
++#ifndef ldebug_h
++#define ldebug_h
++
++
++#include "lstate.h"
++
++
++#define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1)
++
++#define getline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : 0)
++
++#define resethookcount(L) (L->hookcount = L->basehookcount)
++
++
++LUAI_FUNC void luaG_typeerror (lua_State *L, const TValue *o,
++ const char *opname);
++LUAI_FUNC void luaG_concaterror (lua_State *L, StkId p1, StkId p2);
++LUAI_FUNC void luaG_aritherror (lua_State *L, const TValue *p1,
++ const TValue *p2);
++LUAI_FUNC int luaG_ordererror (lua_State *L, const TValue *p1,
++ const TValue *p2);
++LUAI_FUNC void luaG_runerror (lua_State *L, const char *fmt, ...);
++LUAI_FUNC void luaG_errormsg (lua_State *L);
++LUAI_FUNC int luaG_checkcode (const Proto *pt);
++LUAI_FUNC int luaG_checkopenop (Instruction i);
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/ldo.c
+@@ -0,0 +1,515 @@
++/*
++** $Id: ldo.c,v 2.38.1.3 2008/01/18 22:31:22 roberto Exp $
++** Stack and Call structure of Lua
++** See Copyright Notice in lua.h
++*/
++
++#include <setjmp.h>
++#include <stdlib.h>
++#include <string.h>
++
++#define ldo_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "ldebug.h"
++#include "ldo.h"
++#include "lfunc.h"
++#include "lgc.h"
++#include "lmem.h"
++#include "lobject.h"
++#include "lopcodes.h"
++#include "lparser.h"
++#include "lstate.h"
++#include "lstring.h"
++#include "ltable.h"
++#include "ltm.h"
++#include "lundump.h"
++#include "lvm.h"
++#include "lzio.h"
++
++
++
++/*
++** {======================================================
++** Error-recovery functions
++** =======================================================
++*/
++
++
++/* chain list of long jump buffers */
++struct lua_longjmp {
++ struct lua_longjmp *previous;
++ luai_jmpbuf b;
++ volatile int status; /* error code */
++};
++
++
++void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop) {
++ switch (errcode) {
++ case LUA_ERRMEM: {
++ setsvalue2s(L, oldtop, luaS_newliteral(L, MEMERRMSG));
++ break;
++ }
++ case LUA_ERRERR: {
++ setsvalue2s(L, oldtop, luaS_newliteral(L, "error in error handling"));
++ break;
++ }
++ case LUA_ERRSYNTAX:
++ case LUA_ERRRUN: {
++ setobjs2s(L, oldtop, L->top - 1); /* error message on current top */
++ break;
++ }
++ }
++ L->top = oldtop + 1;
++}
++
++
++static void restore_stack_limit (lua_State *L) {
++ lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK - 1);
++ if (L->size_ci > LUAI_MAXCALLS) { /* there was an overflow? */
++ int inuse = cast_int(L->ci - L->base_ci);
++ if (inuse + 1 < LUAI_MAXCALLS) /* can `undo' overflow? */
++ luaD_reallocCI(L, LUAI_MAXCALLS);
++ }
++}
++
++
++static void resetstack (lua_State *L, int status) {
++ L->ci = L->base_ci;
++ L->base = L->ci->base;
++ luaF_close(L, L->base); /* close eventual pending closures */
++ luaD_seterrorobj(L, status, L->base);
++ L->nCcalls = L->baseCcalls;
++ L->allowhook = 1;
++ restore_stack_limit(L);
++ L->errfunc = 0;
++ L->errorJmp = NULL;
++}
++
++
++void luaD_throw (lua_State *L, int errcode) {
++ if (L->errorJmp) {
++ L->errorJmp->status = errcode;
++ LUAI_THROW(L, L->errorJmp);
++ }
++ else {
++ L->status = cast_byte(errcode);
++ if (G(L)->panic) {
++ resetstack(L, errcode);
++ lua_unlock(L);
++ G(L)->panic(L);
++ }
++ exit(EXIT_FAILURE);
++ }
++}
++
++
++int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) {
++ struct lua_longjmp lj;
++ lj.status = 0;
++ lj.previous = L->errorJmp; /* chain new error handler */
++ L->errorJmp = &lj;
++ LUAI_TRY(L, &lj,
++ (*f)(L, ud);
++ );
++ L->errorJmp = lj.previous; /* restore old error handler */
++ return lj.status;
++}
++
++/* }====================================================== */
++
++
++static void correctstack (lua_State *L, TValue *oldstack) {
++ CallInfo *ci;
++ GCObject *up;
++ L->top = (L->top - oldstack) + L->stack;
++ for (up = L->openupval; up != NULL; up = up->gch.next)
++ gco2uv(up)->v = (gco2uv(up)->v - oldstack) + L->stack;
++ for (ci = L->base_ci; ci <= L->ci; ci++) {
++ ci->top = (ci->top - oldstack) + L->stack;
++ ci->base = (ci->base - oldstack) + L->stack;
++ ci->func = (ci->func - oldstack) + L->stack;
++ }
++ L->base = (L->base - oldstack) + L->stack;
++}
++
++
++void luaD_reallocstack (lua_State *L, int newsize) {
++ TValue *oldstack = L->stack;
++ int realsize = newsize + 1 + EXTRA_STACK;
++ lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK - 1);
++ luaM_reallocvector(L, L->stack, L->stacksize, realsize, TValue);
++ L->stacksize = realsize;
++ L->stack_last = L->stack+newsize;
++ correctstack(L, oldstack);
++}
++
++
++void luaD_reallocCI (lua_State *L, int newsize) {
++ CallInfo *oldci = L->base_ci;
++ luaM_reallocvector(L, L->base_ci, L->size_ci, newsize, CallInfo);
++ L->size_ci = newsize;
++ L->ci = (L->ci - oldci) + L->base_ci;
++ L->end_ci = L->base_ci + L->size_ci - 1;
++}
++
++
++void luaD_growstack (lua_State *L, int n) {
++ if (n <= L->stacksize) /* double size is enough? */
++ luaD_reallocstack(L, 2*L->stacksize);
++ else
++ luaD_reallocstack(L, L->stacksize + n);
++}
++
++
++static CallInfo *growCI (lua_State *L) {
++ if (L->size_ci > LUAI_MAXCALLS) /* overflow while handling overflow? */
++ luaD_throw(L, LUA_ERRERR);
++ else {
++ luaD_reallocCI(L, 2*L->size_ci);
++ if (L->size_ci > LUAI_MAXCALLS)
++ luaG_runerror(L, "stack overflow");
++ }
++ return ++L->ci;
++}
++
++
++void luaD_callhook (lua_State *L, int event, int line) {
++ lua_Hook hook = L->hook;
++ if (hook && L->allowhook) {
++ ptrdiff_t top = savestack(L, L->top);
++ ptrdiff_t ci_top = savestack(L, L->ci->top);
++ lua_Debug ar;
++ ar.event = event;
++ ar.currentline = line;
++ if (event == LUA_HOOKTAILRET)
++ ar.i_ci = 0; /* tail call; no debug information about it */
++ else
++ ar.i_ci = cast_int(L->ci - L->base_ci);
++ luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */
++ L->ci->top = L->top + LUA_MINSTACK;
++ lua_assert(L->ci->top <= L->stack_last);
++ L->allowhook = 0; /* cannot call hooks inside a hook */
++ lua_unlock(L);
++ (*hook)(L, &ar);
++ lua_lock(L);
++ lua_assert(!L->allowhook);
++ L->allowhook = 1;
++ L->ci->top = restorestack(L, ci_top);
++ L->top = restorestack(L, top);
++ }
++}
++
++
++static StkId adjust_varargs (lua_State *L, Proto *p, int actual) {
++ int i;
++ int nfixargs = p->numparams;
++ Table *htab = NULL;
++ StkId base, fixed;
++ for (; actual < nfixargs; ++actual)
++ setnilvalue(L->top++);
++#if defined(LUA_COMPAT_VARARG)
++ if (p->is_vararg & VARARG_NEEDSARG) { /* compat. with old-style vararg? */
++ int nvar = actual - nfixargs; /* number of extra arguments */
++ lua_assert(p->is_vararg & VARARG_HASARG);
++ luaC_checkGC(L);
++ htab = luaH_new(L, nvar, 1); /* create `arg' table */
++ for (i=0; i<nvar; i++) /* put extra arguments into `arg' table */
++ setobj2n(L, luaH_setnum(L, htab, i+1), L->top - nvar + i);
++ /* store counter in field `n' */
++ setnvalue(luaH_setstr(L, htab, luaS_newliteral(L, "n")), cast_num(nvar));
++ }
++#endif
++ /* move fixed parameters to final position */
++ fixed = L->top - actual; /* first fixed argument */
++ base = L->top; /* final position of first argument */
++ for (i=0; i<nfixargs; i++) {
++ setobjs2s(L, L->top++, fixed+i);
++ setnilvalue(fixed+i);
++ }
++ /* add `arg' parameter */
++ if (htab) {
++ sethvalue(L, L->top++, htab);
++ lua_assert(iswhite(obj2gco(htab)));
++ }
++ return base;
++}
++
++
++static StkId tryfuncTM (lua_State *L, StkId func) {
++ const TValue *tm = luaT_gettmbyobj(L, func, TM_CALL);
++ StkId p;
++ ptrdiff_t funcr = savestack(L, func);
++ if (!ttisfunction(tm))
++ luaG_typeerror(L, func, "call");
++ /* Open a hole inside the stack at `func' */
++ for (p = L->top; p > func; p--) setobjs2s(L, p, p-1);
++ incr_top(L);
++ func = restorestack(L, funcr); /* previous call may change stack */
++ setobj2s(L, func, tm); /* tag method is the new function to be called */
++ return func;
++}
++
++
++
++#define inc_ci(L) \
++ ((L->ci == L->end_ci) ? growCI(L) : \
++ (condhardstacktests(luaD_reallocCI(L, L->size_ci)), ++L->ci))
++
++
++int luaD_precall (lua_State *L, StkId func, int nresults) {
++ LClosure *cl;
++ ptrdiff_t funcr;
++ if (!ttisfunction(func)) /* `func' is not a function? */
++ func = tryfuncTM(L, func); /* check the `function' tag method */
++ funcr = savestack(L, func);
++ cl = &clvalue(func)->l;
++ L->ci->savedpc = L->savedpc;
++ if (!cl->isC) { /* Lua function? prepare its call */
++ CallInfo *ci;
++ StkId st, base;
++ Proto *p = cl->p;
++ luaD_checkstack(L, p->maxstacksize);
++ func = restorestack(L, funcr);
++ if (!p->is_vararg) { /* no varargs? */
++ base = func + 1;
++ if (L->top > base + p->numparams)
++ L->top = base + p->numparams;
++ }
++ else { /* vararg function */
++ int nargs = cast_int(L->top - func) - 1;
++ base = adjust_varargs(L, p, nargs);
++ func = restorestack(L, funcr); /* previous call may change the stack */
++ }
++ ci = inc_ci(L); /* now `enter' new function */
++ ci->func = func;
++ L->base = ci->base = base;
++ ci->top = L->base + p->maxstacksize;
++ lua_assert(ci->top <= L->stack_last);
++ L->savedpc = p->code; /* starting point */
++ ci->tailcalls = 0;
++ ci->nresults = nresults;
++ for (st = L->top; st < ci->top; st++)
++ setnilvalue(st);
++ L->top = ci->top;
++ if (L->hookmask & LUA_MASKCALL) {
++ L->savedpc++; /* hooks assume 'pc' is already incremented */
++ luaD_callhook(L, LUA_HOOKCALL, -1);
++ L->savedpc--; /* correct 'pc' */
++ }
++ return PCRLUA;
++ }
++ else { /* if is a C function, call it */
++ CallInfo *ci;
++ int n;
++ luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */
++ ci = inc_ci(L); /* now `enter' new function */
++ ci->func = restorestack(L, funcr);
++ L->base = ci->base = ci->func + 1;
++ ci->top = L->top + LUA_MINSTACK;
++ lua_assert(ci->top <= L->stack_last);
++ ci->nresults = nresults;
++ if (L->hookmask & LUA_MASKCALL)
++ luaD_callhook(L, LUA_HOOKCALL, -1);
++ lua_unlock(L);
++ n = (*curr_func(L)->c.f)(L); /* do the actual call */
++ lua_lock(L);
++ if (n < 0) /* yielding? */
++ return PCRYIELD;
++ else {
++ luaD_poscall(L, L->top - n);
++ return PCRC;
++ }
++ }
++}
++
++
++static StkId callrethooks (lua_State *L, StkId firstResult) {
++ ptrdiff_t fr = savestack(L, firstResult); /* next call may change stack */
++ luaD_callhook(L, LUA_HOOKRET, -1);
++ if (f_isLua(L->ci)) { /* Lua function? */
++ while ((L->hookmask & LUA_MASKRET) && L->ci->tailcalls--) /* tail calls */
++ luaD_callhook(L, LUA_HOOKTAILRET, -1);
++ }
++ return restorestack(L, fr);
++}
++
++
++int luaD_poscall (lua_State *L, StkId firstResult) {
++ StkId res;
++ int wanted, i;
++ CallInfo *ci;
++ if (L->hookmask & LUA_MASKRET)
++ firstResult = callrethooks(L, firstResult);
++ ci = L->ci--;
++ res = ci->func; /* res == final position of 1st result */
++ wanted = ci->nresults;
++ L->base = (ci - 1)->base; /* restore base */
++ L->savedpc = (ci - 1)->savedpc; /* restore savedpc */
++ /* move results to correct place */
++ for (i = wanted; i != 0 && firstResult < L->top; i--)
++ setobjs2s(L, res++, firstResult++);
++ while (i-- > 0)
++ setnilvalue(res++);
++ L->top = res;
++ return (wanted - LUA_MULTRET); /* 0 iff wanted == LUA_MULTRET */
++}
++
++
++/*
++** Call a function (C or Lua). The function to be called is at *func.
++** The arguments are on the stack, right after the function.
++** When returns, all the results are on the stack, starting at the original
++** function position.
++*/
++void luaD_call (lua_State *L, StkId func, int nResults) {
++ if (++L->nCcalls >= LUAI_MAXCCALLS) {
++ if (L->nCcalls == LUAI_MAXCCALLS)
++ luaG_runerror(L, "C stack overflow");
++ else if (L->nCcalls >= (LUAI_MAXCCALLS + (LUAI_MAXCCALLS>>3)))
++ luaD_throw(L, LUA_ERRERR); /* error while handing stack error */
++ }
++ if (luaD_precall(L, func, nResults) == PCRLUA) /* is a Lua function? */
++ luaV_execute(L, 1); /* call it */
++ L->nCcalls--;
++ luaC_checkGC(L);
++}
++
++
++static void resume (lua_State *L, void *ud) {
++ StkId firstArg = cast(StkId, ud);
++ CallInfo *ci = L->ci;
++ if (L->status == 0) { /* start coroutine? */
++ lua_assert(ci == L->base_ci && firstArg > L->base);
++ if (luaD_precall(L, firstArg - 1, LUA_MULTRET) != PCRLUA)
++ return;
++ }
++ else { /* resuming from previous yield */
++ lua_assert(L->status == LUA_YIELD);
++ L->status = 0;
++ if (!f_isLua(ci)) { /* `common' yield? */
++ /* finish interrupted execution of `OP_CALL' */
++ lua_assert(GET_OPCODE(*((ci-1)->savedpc - 1)) == OP_CALL ||
++ GET_OPCODE(*((ci-1)->savedpc - 1)) == OP_TAILCALL);
++ if (luaD_poscall(L, firstArg)) /* complete it... */
++ L->top = L->ci->top; /* and correct top if not multiple results */
++ }
++ else /* yielded inside a hook: just continue its execution */
++ L->base = L->ci->base;
++ }
++ luaV_execute(L, cast_int(L->ci - L->base_ci));
++}
++
++
++static int resume_error (lua_State *L, const char *msg) {
++ L->top = L->ci->base;
++ setsvalue2s(L, L->top, luaS_new(L, msg));
++ incr_top(L);
++ lua_unlock(L);
++ return LUA_ERRRUN;
++}
++
++
++LUA_API int lua_resume (lua_State *L, int nargs) {
++ int status;
++ lua_lock(L);
++ if (L->status != LUA_YIELD && (L->status != 0 || L->ci != L->base_ci))
++ return resume_error(L, "cannot resume non-suspended coroutine");
++ if (L->nCcalls >= LUAI_MAXCCALLS)
++ return resume_error(L, "C stack overflow");
++ luai_userstateresume(L, nargs);
++ lua_assert(L->errfunc == 0);
++ L->baseCcalls = ++L->nCcalls;
++ status = luaD_rawrunprotected(L, resume, L->top - nargs);
++ if (status != 0) { /* error? */
++ L->status = cast_byte(status); /* mark thread as `dead' */
++ luaD_seterrorobj(L, status, L->top);
++ L->ci->top = L->top;
++ }
++ else {
++ lua_assert(L->nCcalls == L->baseCcalls);
++ status = L->status;
++ }
++ --L->nCcalls;
++ lua_unlock(L);
++ return status;
++}
++
++
++LUA_API int lua_yield (lua_State *L, int nresults) {
++ luai_userstateyield(L, nresults);
++ lua_lock(L);
++ if (L->nCcalls > L->baseCcalls)
++ luaG_runerror(L, "attempt to yield across metamethod/C-call boundary");
++ L->base = L->top - nresults; /* protect stack slots below */
++ L->status = LUA_YIELD;
++ lua_unlock(L);
++ return -1;
++}
++
++
++int luaD_pcall (lua_State *L, Pfunc func, void *u,
++ ptrdiff_t old_top, ptrdiff_t ef) {
++ int status;
++ unsigned short oldnCcalls = L->nCcalls;
++ ptrdiff_t old_ci = saveci(L, L->ci);
++ lu_byte old_allowhooks = L->allowhook;
++ ptrdiff_t old_errfunc = L->errfunc;
++ L->errfunc = ef;
++ status = luaD_rawrunprotected(L, func, u);
++ if (status != 0) { /* an error occurred? */
++ StkId oldtop = restorestack(L, old_top);
++ luaF_close(L, oldtop); /* close eventual pending closures */
++ luaD_seterrorobj(L, status, oldtop);
++ L->nCcalls = oldnCcalls;
++ L->ci = restoreci(L, old_ci);
++ L->base = L->ci->base;
++ L->savedpc = L->ci->savedpc;
++ L->allowhook = old_allowhooks;
++ restore_stack_limit(L);
++ }
++ L->errfunc = old_errfunc;
++ return status;
++}
++
++
++
++/*
++** Execute a protected parser.
++*/
++struct SParser { /* data to `f_parser' */
++ ZIO *z;
++ Mbuffer buff; /* buffer to be used by the scanner */
++ const char *name;
++};
++
++static void f_parser (lua_State *L, void *ud) {
++ int i;
++ Proto *tf;
++ Closure *cl;
++ struct SParser *p = cast(struct SParser *, ud);
++ int c = luaZ_lookahead(p->z);
++ luaC_checkGC(L);
++ tf = ((c == LUA_SIGNATURE[0]) ? luaU_undump : luaY_parser)(L, p->z,
++ &p->buff, p->name);
++ cl = luaF_newLclosure(L, tf->nups, hvalue(gt(L)));
++ cl->l.p = tf;
++ for (i = 0; i < tf->nups; i++) /* initialize eventual upvalues */
++ cl->l.upvals[i] = luaF_newupval(L);
++ setclvalue(L, L->top, cl);
++ incr_top(L);
++}
++
++
++int luaD_protectedparser (lua_State *L, ZIO *z, const char *name) {
++ struct SParser p;
++ int status;
++ p.z = z; p.name = name;
++ luaZ_initbuffer(L, &p.buff);
++ status = luaD_pcall(L, f_parser, &p, savestack(L, L->top), L->errfunc);
++ luaZ_freebuffer(L, &p.buff);
++ return status;
++}
++
+--- /dev/null
++++ b/extensions/LUA/lua/ldo.h
+@@ -0,0 +1,57 @@
++/*
++** $Id: ldo.h,v 2.7.1.1 2007/12/27 13:02:25 roberto Exp $
++** Stack and Call structure of Lua
++** See Copyright Notice in lua.h
++*/
++
++#ifndef ldo_h
++#define ldo_h
++
++
++#include "lobject.h"
++#include "lstate.h"
++#include "lzio.h"
++
++
++#define luaD_checkstack(L,n) \
++ if ((char *)L->stack_last - (char *)L->top <= (n)*(int)sizeof(TValue)) \
++ luaD_growstack(L, n); \
++ else condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK - 1));
++
++
++#define incr_top(L) {luaD_checkstack(L,1); L->top++;}
++
++#define savestack(L,p) ((char *)(p) - (char *)L->stack)
++#define restorestack(L,n) ((TValue *)((char *)L->stack + (n)))
++
++#define saveci(L,p) ((char *)(p) - (char *)L->base_ci)
++#define restoreci(L,n) ((CallInfo *)((char *)L->base_ci + (n)))
++
++
++/* results from luaD_precall */
++#define PCRLUA 0 /* initiated a call to a Lua function */
++#define PCRC 1 /* did a call to a C function */
++#define PCRYIELD 2 /* C funtion yielded */
++
++
++/* type of protected functions, to be ran by `runprotected' */
++typedef void (*Pfunc) (lua_State *L, void *ud);
++
++LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name);
++LUAI_FUNC void luaD_callhook (lua_State *L, int event, int line);
++LUAI_FUNC int luaD_precall (lua_State *L, StkId func, int nresults);
++LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults);
++LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u,
++ ptrdiff_t oldtop, ptrdiff_t ef);
++LUAI_FUNC int luaD_poscall (lua_State *L, StkId firstResult);
++LUAI_FUNC void luaD_reallocCI (lua_State *L, int newsize);
++LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize);
++LUAI_FUNC void luaD_growstack (lua_State *L, int n);
++
++LUAI_FUNC void luaD_throw (lua_State *L, int errcode);
++LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud);
++
++LUAI_FUNC void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop);
++
++#endif
++
+--- /dev/null
++++ b/extensions/LUA/lua/ldump.c
+@@ -0,0 +1,164 @@
++/*
++** $Id: ldump.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $
++** save precompiled Lua chunks
++** See Copyright Notice in lua.h
++*/
++
++#include <stddef.h>
++
++#define ldump_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "lobject.h"
++#include "lstate.h"
++#include "lundump.h"
++
++typedef struct {
++ lua_State* L;
++ lua_Writer writer;
++ void* data;
++ int strip;
++ int status;
++} DumpState;
++
++#define DumpMem(b,n,size,D) DumpBlock(b,(n)*(size),D)
++#define DumpVar(x,D) DumpMem(&x,1,sizeof(x),D)
++
++static void DumpBlock(const void* b, size_t size, DumpState* D)
++{
++ if (D->status==0)
++ {
++ lua_unlock(D->L);
++ D->status=(*D->writer)(D->L,b,size,D->data);
++ lua_lock(D->L);
++ }
++}
++
++static void DumpChar(int y, DumpState* D)
++{
++ char x=(char)y;
++ DumpVar(x,D);
++}
++
++static void DumpInt(int x, DumpState* D)
++{
++ DumpVar(x,D);
++}
++
++static void DumpNumber(lua_Number x, DumpState* D)
++{
++ DumpVar(x,D);
++}
++
++static void DumpVector(const void* b, int n, size_t size, DumpState* D)
++{
++ DumpInt(n,D);
++ DumpMem(b,n,size,D);
++}
++
++static void DumpString(const TString* s, DumpState* D)
++{
++ if (s==NULL || getstr(s)==NULL)
++ {
++ size_t size=0;
++ DumpVar(size,D);
++ }
++ else
++ {
++ size_t size=s->tsv.len+1; /* include trailing '\0' */
++ DumpVar(size,D);
++ DumpBlock(getstr(s),size,D);
++ }
++}
++
++#define DumpCode(f,D) DumpVector(f->code,f->sizecode,sizeof(Instruction),D)
++
++static void DumpFunction(const Proto* f, const TString* p, DumpState* D);
++
++static void DumpConstants(const Proto* f, DumpState* D)
++{
++ int i,n=f->sizek;
++ DumpInt(n,D);
++ for (i=0; i<n; i++)
++ {
++ const TValue* o=&f->k[i];
++ DumpChar(ttype(o),D);
++ switch (ttype(o))
++ {
++ case LUA_TNIL:
++ break;
++ case LUA_TBOOLEAN:
++ DumpChar(bvalue(o),D);
++ break;
++ case LUA_TNUMBER:
++ DumpNumber(nvalue(o),D);
++ break;
++ case LUA_TSTRING:
++ DumpString(rawtsvalue(o),D);
++ break;
++ default:
++ lua_assert(0); /* cannot happen */
++ break;
++ }
++ }
++ n=f->sizep;
++ DumpInt(n,D);
++ for (i=0; i<n; i++) DumpFunction(f->p[i],f->source,D);
++}
++
++static void DumpDebug(const Proto* f, DumpState* D)
++{
++ int i,n;
++ n= (D->strip) ? 0 : f->sizelineinfo;
++ DumpVector(f->lineinfo,n,sizeof(int),D);
++ n= (D->strip) ? 0 : f->sizelocvars;
++ DumpInt(n,D);
++ for (i=0; i<n; i++)
++ {
++ DumpString(f->locvars[i].varname,D);
++ DumpInt(f->locvars[i].startpc,D);
++ DumpInt(f->locvars[i].endpc,D);
++ }
++ n= (D->strip) ? 0 : f->sizeupvalues;
++ DumpInt(n,D);
++ for (i=0; i<n; i++) DumpString(f->upvalues[i],D);
++}
++
++static void DumpFunction(const Proto* f, const TString* p, DumpState* D)
++{
++ DumpString((f->source==p || D->strip) ? NULL : f->source,D);
++ DumpInt(f->linedefined,D);
++ DumpInt(f->lastlinedefined,D);
++ DumpChar(f->nups,D);
++ DumpChar(f->numparams,D);
++ DumpChar(f->is_vararg,D);
++ DumpChar(f->maxstacksize,D);
++ DumpCode(f,D);
++ DumpConstants(f,D);
++ DumpDebug(f,D);
++}
++
++static void DumpHeader(DumpState* D)
++{
++ char h[LUAC_HEADERSIZE];
++ luaU_header(h);
++ DumpBlock(h,LUAC_HEADERSIZE,D);
++}
++
++/*
++** dump Lua function as precompiled chunk
++*/
++int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip)
++{
++ DumpState D;
++ D.L=L;
++ D.writer=w;
++ D.data=data;
++ D.strip=strip;
++ D.status=0;
++ DumpHeader(&D);
++ DumpFunction(f,NULL,&D);
++ return D.status;
++}
+--- /dev/null
++++ b/extensions/LUA/lua/lfunc.c
+@@ -0,0 +1,174 @@
++/*
++** $Id: lfunc.c,v 2.12.1.2 2007/12/28 14:58:43 roberto Exp $
++** Auxiliary functions to manipulate prototypes and closures
++** See Copyright Notice in lua.h
++*/
++
++
++#include <stddef.h>
++
++#define lfunc_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "lfunc.h"
++#include "lgc.h"
++#include "lmem.h"
++#include "lobject.h"
++#include "lstate.h"
++
++
++
++Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e) {
++ Closure *c = cast(Closure *, luaM_malloc(L, sizeCclosure(nelems)));
++ luaC_link(L, obj2gco(c), LUA_TFUNCTION);
++ c->c.isC = 1;
++ c->c.env = e;
++ c->c.nupvalues = cast_byte(nelems);
++ return c;
++}
++
++
++Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e) {
++ Closure *c = cast(Closure *, luaM_malloc(L, sizeLclosure(nelems)));
++ luaC_link(L, obj2gco(c), LUA_TFUNCTION);
++ c->l.isC = 0;
++ c->l.env = e;
++ c->l.nupvalues = cast_byte(nelems);
++ while (nelems--) c->l.upvals[nelems] = NULL;
++ return c;
++}
++
++
++UpVal *luaF_newupval (lua_State *L) {
++ UpVal *uv = luaM_new(L, UpVal);
++ luaC_link(L, obj2gco(uv), LUA_TUPVAL);
++ uv->v = &uv->u.value;
++ setnilvalue(uv->v);
++ return uv;
++}
++
++
++UpVal *luaF_findupval (lua_State *L, StkId level) {
++ global_State *g = G(L);
++ GCObject **pp = &L->openupval;
++ UpVal *p;
++ UpVal *uv;
++ while (*pp != NULL && (p = ngcotouv(*pp))->v >= level) {
++ lua_assert(p->v != &p->u.value);
++ if (p->v == level) { /* found a corresponding upvalue? */
++ if (isdead(g, obj2gco(p))) /* is it dead? */
++ changewhite(obj2gco(p)); /* ressurect it */
++ return p;
++ }
++ pp = &p->next;
++ }
++ uv = luaM_new(L, UpVal); /* not found: create a new one */
++ uv->tt = LUA_TUPVAL;
++ uv->marked = luaC_white(g);
++ uv->v = level; /* current value lives in the stack */
++ uv->next = *pp; /* chain it in the proper position */
++ *pp = obj2gco(uv);
++ uv->u.l.prev = &g->uvhead; /* double link it in `uvhead' list */
++ uv->u.l.next = g->uvhead.u.l.next;
++ uv->u.l.next->u.l.prev = uv;
++ g->uvhead.u.l.next = uv;
++ lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv);
++ return uv;
++}
++
++
++static void unlinkupval (UpVal *uv) {
++ lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv);
++ uv->u.l.next->u.l.prev = uv->u.l.prev; /* remove from `uvhead' list */
++ uv->u.l.prev->u.l.next = uv->u.l.next;
++}
++
++
++void luaF_freeupval (lua_State *L, UpVal *uv) {
++ if (uv->v != &uv->u.value) /* is it open? */
++ unlinkupval(uv); /* remove from open list */
++ luaM_free(L, uv); /* free upvalue */
++}
++
++
++void luaF_close (lua_State *L, StkId level) {
++ UpVal *uv;
++ global_State *g = G(L);
++ while (L->openupval != NULL && (uv = ngcotouv(L->openupval))->v >= level) {
++ GCObject *o = obj2gco(uv);
++ lua_assert(!isblack(o) && uv->v != &uv->u.value);
++ L->openupval = uv->next; /* remove from `open' list */
++ if (isdead(g, o))
++ luaF_freeupval(L, uv); /* free upvalue */
++ else {
++ unlinkupval(uv);
++ setobj(L, &uv->u.value, uv->v);
++ uv->v = &uv->u.value; /* now current value lives here */
++ luaC_linkupval(L, uv); /* link upvalue into `gcroot' list */
++ }
++ }
++}
++
++
++Proto *luaF_newproto (lua_State *L) {
++ Proto *f = luaM_new(L, Proto);
++ luaC_link(L, obj2gco(f), LUA_TPROTO);
++ f->k = NULL;
++ f->sizek = 0;
++ f->p = NULL;
++ f->sizep = 0;
++ f->code = NULL;
++ f->sizecode = 0;
++ f->sizelineinfo = 0;
++ f->sizeupvalues = 0;
++ f->nups = 0;
++ f->upvalues = NULL;
++ f->numparams = 0;
++ f->is_vararg = 0;
++ f->maxstacksize = 0;
++ f->lineinfo = NULL;
++ f->sizelocvars = 0;
++ f->locvars = NULL;
++ f->linedefined = 0;
++ f->lastlinedefined = 0;
++ f->source = NULL;
++ return f;
++}
++
++
++void luaF_freeproto (lua_State *L, Proto *f) {
++ luaM_freearray(L, f->code, f->sizecode, Instruction);
++ luaM_freearray(L, f->p, f->sizep, Proto *);
++ luaM_freearray(L, f->k, f->sizek, TValue);
++ luaM_freearray(L, f->lineinfo, f->sizelineinfo, int);
++ luaM_freearray(L, f->locvars, f->sizelocvars, struct LocVar);
++ luaM_freearray(L, f->upvalues, f->sizeupvalues, TString *);
++ luaM_free(L, f);
++}
++
++
++void luaF_freeclosure (lua_State *L, Closure *c) {
++ int size = (c->c.isC) ? sizeCclosure(c->c.nupvalues) :
++ sizeLclosure(c->l.nupvalues);
++ luaM_freemem(L, c, size);
++}
++
++
++/*
++** Look for n-th local variable at line `line' in function `func'.
++** Returns NULL if not found.
++*/
++const char *luaF_getlocalname (const Proto *f, int local_number, int pc) {
++ int i;
++ for (i = 0; i<f->sizelocvars && f->locvars[i].startpc <= pc; i++) {
++ if (pc < f->locvars[i].endpc) { /* is variable active? */
++ local_number--;
++ if (local_number == 0)
++ return getstr(f->locvars[i].varname);
++ }
++ }
++ return NULL; /* not found */
++}
++
+--- /dev/null
++++ b/extensions/LUA/lua/lfunc.h
+@@ -0,0 +1,34 @@
++/*
++** $Id: lfunc.h,v 2.4.1.1 2007/12/27 13:02:25 roberto Exp $
++** Auxiliary functions to manipulate prototypes and closures
++** See Copyright Notice in lua.h
++*/
++
++#ifndef lfunc_h
++#define lfunc_h
++
++
++#include "lobject.h"
++
++
++#define sizeCclosure(n) (cast(int, sizeof(CClosure)) + \
++ cast(int, sizeof(TValue)*((n)-1)))
++
++#define sizeLclosure(n) (cast(int, sizeof(LClosure)) + \
++ cast(int, sizeof(TValue *)*((n)-1)))
++
++
++LUAI_FUNC Proto *luaF_newproto (lua_State *L);
++LUAI_FUNC Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e);
++LUAI_FUNC Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e);
++LUAI_FUNC UpVal *luaF_newupval (lua_State *L);
++LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level);
++LUAI_FUNC void luaF_close (lua_State *L, StkId level);
++LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f);
++LUAI_FUNC void luaF_freeclosure (lua_State *L, Closure *c);
++LUAI_FUNC void luaF_freeupval (lua_State *L, UpVal *uv);
++LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number,
++ int pc);
++
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/lgc.c
+@@ -0,0 +1,711 @@
++/*
++** $Id: lgc.c,v 2.38.1.1 2007/12/27 13:02:25 roberto Exp $
++** Garbage Collector
++** See Copyright Notice in lua.h
++*/
++
++#include <string.h>
++
++#define lgc_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "ldebug.h"
++#include "ldo.h"
++#include "lfunc.h"
++#include "lgc.h"
++#include "lmem.h"
++#include "lobject.h"
++#include "lstate.h"
++#include "lstring.h"
++#include "ltable.h"
++#include "ltm.h"
++
++
++#define GCSTEPSIZE 1024u
++#define GCSWEEPMAX 40
++#define GCSWEEPCOST 10
++#define GCFINALIZECOST 100
++
++
++#define maskmarks cast_byte(~(bitmask(BLACKBIT)|WHITEBITS))
++
++#define makewhite(g,x) \
++ ((x)->gch.marked = cast_byte(((x)->gch.marked & maskmarks) | luaC_white(g)))
++
++#define white2gray(x) reset2bits((x)->gch.marked, WHITE0BIT, WHITE1BIT)
++#define black2gray(x) resetbit((x)->gch.marked, BLACKBIT)
++
++#define stringmark(s) reset2bits((s)->tsv.marked, WHITE0BIT, WHITE1BIT)
++
++
++#define isfinalized(u) testbit((u)->marked, FINALIZEDBIT)
++#define markfinalized(u) l_setbit((u)->marked, FINALIZEDBIT)
++
++
++#define KEYWEAK bitmask(KEYWEAKBIT)
++#define VALUEWEAK bitmask(VALUEWEAKBIT)
++
++
++
++#define markvalue(g,o) { checkconsistency(o); \
++ if (iscollectable(o) && iswhite(gcvalue(o))) reallymarkobject(g,gcvalue(o)); }
++
++#define markobject(g,t) { if (iswhite(obj2gco(t))) \
++ reallymarkobject(g, obj2gco(t)); }
++
++
++#define setthreshold(g) (g->GCthreshold = (g->estimate/100) * g->gcpause)
++
++
++static void removeentry (Node *n) {
++ lua_assert(ttisnil(gval(n)));
++ if (iscollectable(gkey(n)))
++ setttype(gkey(n), LUA_TDEADKEY); /* dead key; remove it */
++}
++
++
++static void reallymarkobject (global_State *g, GCObject *o) {
++ lua_assert(iswhite(o) && !isdead(g, o));
++ white2gray(o);
++ switch (o->gch.tt) {
++ case LUA_TSTRING: {
++ return;
++ }
++ case LUA_TUSERDATA: {
++ Table *mt = gco2u(o)->metatable;
++ gray2black(o); /* udata are never gray */
++ if (mt) markobject(g, mt);
++ markobject(g, gco2u(o)->env);
++ return;
++ }
++ case LUA_TUPVAL: {
++ UpVal *uv = gco2uv(o);
++ markvalue(g, uv->v);
++ if (uv->v == &uv->u.value) /* closed? */
++ gray2black(o); /* open upvalues are never black */
++ return;
++ }
++ case LUA_TFUNCTION: {
++ gco2cl(o)->c.gclist = g->gray;
++ g->gray = o;
++ break;
++ }
++ case LUA_TTABLE: {
++ gco2h(o)->gclist = g->gray;
++ g->gray = o;
++ break;
++ }
++ case LUA_TTHREAD: {
++ gco2th(o)->gclist = g->gray;
++ g->gray = o;
++ break;
++ }
++ case LUA_TPROTO: {
++ gco2p(o)->gclist = g->gray;
++ g->gray = o;
++ break;
++ }
++ default: lua_assert(0);
++ }
++}
++
++
++static void marktmu (global_State *g) {
++ GCObject *u = g->tmudata;
++ if (u) {
++ do {
++ u = u->gch.next;
++ makewhite(g, u); /* may be marked, if left from previous GC */
++ reallymarkobject(g, u);
++ } while (u != g->tmudata);
++ }
++}
++
++
++/* move `dead' udata that need finalization to list `tmudata' */
++size_t luaC_separateudata (lua_State *L, int all) {
++ global_State *g = G(L);
++ size_t deadmem = 0;
++ GCObject **p = &g->mainthread->next;
++ GCObject *curr;
++ while ((curr = *p) != NULL) {
++ if (!(iswhite(curr) || all) || isfinalized(gco2u(curr)))
++ p = &curr->gch.next; /* don't bother with them */
++ else if (fasttm(L, gco2u(curr)->metatable, TM_GC) == NULL) {
++ markfinalized(gco2u(curr)); /* don't need finalization */
++ p = &curr->gch.next;
++ }
++ else { /* must call its gc method */
++ deadmem += sizeudata(gco2u(curr));
++ markfinalized(gco2u(curr));
++ *p = curr->gch.next;
++ /* link `curr' at the end of `tmudata' list */
++ if (g->tmudata == NULL) /* list is empty? */
++ g->tmudata = curr->gch.next = curr; /* creates a circular list */
++ else {
++ curr->gch.next = g->tmudata->gch.next;
++ g->tmudata->gch.next = curr;
++ g->tmudata = curr;
++ }
++ }
++ }
++ return deadmem;
++}
++
++
++static int traversetable (global_State *g, Table *h) {
++ int i;
++ int weakkey = 0;
++ int weakvalue = 0;
++ const TValue *mode;
++ if (h->metatable)
++ markobject(g, h->metatable);
++ mode = gfasttm(g, h->metatable, TM_MODE);
++ if (mode && ttisstring(mode)) { /* is there a weak mode? */
++ weakkey = (strchr(svalue(mode), 'k') != NULL);
++ weakvalue = (strchr(svalue(mode), 'v') != NULL);
++ if (weakkey || weakvalue) { /* is really weak? */
++ h->marked &= ~(KEYWEAK | VALUEWEAK); /* clear bits */
++ h->marked |= cast_byte((weakkey << KEYWEAKBIT) |
++ (weakvalue << VALUEWEAKBIT));
++ h->gclist = g->weak; /* must be cleared after GC, ... */
++ g->weak = obj2gco(h); /* ... so put in the appropriate list */
++ }
++ }
++ if (weakkey && weakvalue) return 1;
++ if (!weakvalue) {
++ i = h->sizearray;
++ while (i--)
++ markvalue(g, &h->array[i]);
++ }
++ i = sizenode(h);
++ while (i--) {
++ Node *n = gnode(h, i);
++ lua_assert(ttype(gkey(n)) != LUA_TDEADKEY || ttisnil(gval(n)));
++ if (ttisnil(gval(n)))
++ removeentry(n); /* remove empty entries */
++ else {
++ lua_assert(!ttisnil(gkey(n)));
++ if (!weakkey) markvalue(g, gkey(n));
++ if (!weakvalue) markvalue(g, gval(n));
++ }
++ }
++ return weakkey || weakvalue;
++}
++
++
++/*
++** All marks are conditional because a GC may happen while the
++** prototype is still being created
++*/
++static void traverseproto (global_State *g, Proto *f) {
++ int i;
++ if (f->source) stringmark(f->source);
++ for (i=0; i<f->sizek; i++) /* mark literals */
++ markvalue(g, &f->k[i]);
++ for (i=0; i<f->sizeupvalues; i++) { /* mark upvalue names */
++ if (f->upvalues[i])
++ stringmark(f->upvalues[i]);
++ }
++ for (i=0; i<f->sizep; i++) { /* mark nested protos */
++ if (f->p[i])
++ markobject(g, f->p[i]);
++ }
++ for (i=0; i<f->sizelocvars; i++) { /* mark local-variable names */
++ if (f->locvars[i].varname)
++ stringmark(f->locvars[i].varname);
++ }
++}
++
++
++
++static void traverseclosure (global_State *g, Closure *cl) {
++ markobject(g, cl->c.env);
++ if (cl->c.isC) {
++ int i;
++ for (i=0; i<cl->c.nupvalues; i++) /* mark its upvalues */
++ markvalue(g, &cl->c.upvalue[i]);
++ }
++ else {
++ int i;
++ lua_assert(cl->l.nupvalues == cl->l.p->nups);
++ markobject(g, cl->l.p);
++ for (i=0; i<cl->l.nupvalues; i++) /* mark its upvalues */
++ markobject(g, cl->l.upvals[i]);
++ }
++}
++
++
++static void checkstacksizes (lua_State *L, StkId max) {
++ int ci_used = cast_int(L->ci - L->base_ci); /* number of `ci' in use */
++ int s_used = cast_int(max - L->stack); /* part of stack in use */
++ if (L->size_ci > LUAI_MAXCALLS) /* handling overflow? */
++ return; /* do not touch the stacks */
++ if (4*ci_used < L->size_ci && 2*BASIC_CI_SIZE < L->size_ci)
++ luaD_reallocCI(L, L->size_ci/2); /* still big enough... */
++ condhardstacktests(luaD_reallocCI(L, ci_used + 1));
++ if (4*s_used < L->stacksize &&
++ 2*(BASIC_STACK_SIZE+EXTRA_STACK) < L->stacksize)
++ luaD_reallocstack(L, L->stacksize/2); /* still big enough... */
++ condhardstacktests(luaD_reallocstack(L, s_used));
++}
++
++
++static void traversestack (global_State *g, lua_State *l) {
++ StkId o, lim;
++ CallInfo *ci;
++ markvalue(g, gt(l));
++ lim = l->top;
++ for (ci = l->base_ci; ci <= l->ci; ci++) {
++ lua_assert(ci->top <= l->stack_last);
++ if (lim < ci->top) lim = ci->top;
++ }
++ for (o = l->stack; o < l->top; o++)
++ markvalue(g, o);
++ for (; o <= lim; o++)
++ setnilvalue(o);
++ checkstacksizes(l, lim);
++}
++
++
++/*
++** traverse one gray object, turning it to black.
++** Returns `quantity' traversed.
++*/
++static l_mem propagatemark (global_State *g) {
++ GCObject *o = g->gray;
++ lua_assert(isgray(o));
++ gray2black(o);
++ switch (o->gch.tt) {
++ case LUA_TTABLE: {
++ Table *h = gco2h(o);
++ g->gray = h->gclist;
++ if (traversetable(g, h)) /* table is weak? */
++ black2gray(o); /* keep it gray */
++ return sizeof(Table) + sizeof(TValue) * h->sizearray +
++ sizeof(Node) * sizenode(h);
++ }
++ case LUA_TFUNCTION: {
++ Closure *cl = gco2cl(o);
++ g->gray = cl->c.gclist;
++ traverseclosure(g, cl);
++ return (cl->c.isC) ? sizeCclosure(cl->c.nupvalues) :
++ sizeLclosure(cl->l.nupvalues);
++ }
++ case LUA_TTHREAD: {
++ lua_State *th = gco2th(o);
++ g->gray = th->gclist;
++ th->gclist = g->grayagain;
++ g->grayagain = o;
++ black2gray(o);
++ traversestack(g, th);
++ return sizeof(lua_State) + sizeof(TValue) * th->stacksize +
++ sizeof(CallInfo) * th->size_ci;
++ }
++ case LUA_TPROTO: {
++ Proto *p = gco2p(o);
++ g->gray = p->gclist;
++ traverseproto(g, p);
++ return sizeof(Proto) + sizeof(Instruction) * p->sizecode +
++ sizeof(Proto *) * p->sizep +
++ sizeof(TValue) * p->sizek +
++ sizeof(int) * p->sizelineinfo +
++ sizeof(LocVar) * p->sizelocvars +
++ sizeof(TString *) * p->sizeupvalues;
++ }
++ default: lua_assert(0); return 0;
++ }
++}
++
++
++static size_t propagateall (global_State *g) {
++ size_t m = 0;
++ while (g->gray) m += propagatemark(g);
++ return m;
++}
++
++
++/*
++** The next function tells whether a key or value can be cleared from
++** a weak table. Non-collectable objects are never removed from weak
++** tables. Strings behave as `values', so are never removed too. for
++** other objects: if really collected, cannot keep them; for userdata
++** being finalized, keep them in keys, but not in values
++*/
++static int iscleared (const TValue *o, int iskey) {
++ if (!iscollectable(o)) return 0;
++ if (ttisstring(o)) {
++ stringmark(rawtsvalue(o)); /* strings are `values', so are never weak */
++ return 0;
++ }
++ return iswhite(gcvalue(o)) ||
++ (ttisuserdata(o) && (!iskey && isfinalized(uvalue(o))));
++}
++
++
++/*
++** clear collected entries from weaktables
++*/
++static void cleartable (GCObject *l) {
++ while (l) {
++ Table *h = gco2h(l);
++ int i = h->sizearray;
++ lua_assert(testbit(h->marked, VALUEWEAKBIT) ||
++ testbit(h->marked, KEYWEAKBIT));
++ if (testbit(h->marked, VALUEWEAKBIT)) {
++ while (i--) {
++ TValue *o = &h->array[i];
++ if (iscleared(o, 0)) /* value was collected? */
++ setnilvalue(o); /* remove value */
++ }
++ }
++ i = sizenode(h);
++ while (i--) {
++ Node *n = gnode(h, i);
++ if (!ttisnil(gval(n)) && /* non-empty entry? */
++ (iscleared(key2tval(n), 1) || iscleared(gval(n), 0))) {
++ setnilvalue(gval(n)); /* remove value ... */
++ removeentry(n); /* remove entry from table */
++ }
++ }
++ l = h->gclist;
++ }
++}
++
++
++static void freeobj (lua_State *L, GCObject *o) {
++ switch (o->gch.tt) {
++ case LUA_TPROTO: luaF_freeproto(L, gco2p(o)); break;
++ case LUA_TFUNCTION: luaF_freeclosure(L, gco2cl(o)); break;
++ case LUA_TUPVAL: luaF_freeupval(L, gco2uv(o)); break;
++ case LUA_TTABLE: luaH_free(L, gco2h(o)); break;
++ case LUA_TTHREAD: {
++ lua_assert(gco2th(o) != L && gco2th(o) != G(L)->mainthread);
++ luaE_freethread(L, gco2th(o));
++ break;
++ }
++ case LUA_TSTRING: {
++ G(L)->strt.nuse--;
++ luaM_freemem(L, o, sizestring(gco2ts(o)));
++ break;
++ }
++ case LUA_TUSERDATA: {
++ luaM_freemem(L, o, sizeudata(gco2u(o)));
++ break;
++ }
++ default: lua_assert(0);
++ }
++}
++
++
++
++#define sweepwholelist(L,p) sweeplist(L,p,MAX_LUMEM)
++
++
++static GCObject **sweeplist (lua_State *L, GCObject **p, lu_mem count) {
++ GCObject *curr;
++ global_State *g = G(L);
++ int deadmask = otherwhite(g);
++ while ((curr = *p) != NULL && count-- > 0) {
++ if (curr->gch.tt == LUA_TTHREAD) /* sweep open upvalues of each thread */
++ sweepwholelist(L, &gco2th(curr)->openupval);
++ if ((curr->gch.marked ^ WHITEBITS) & deadmask) { /* not dead? */
++ lua_assert(!isdead(g, curr) || testbit(curr->gch.marked, FIXEDBIT));
++ makewhite(g, curr); /* make it white (for next cycle) */
++ p = &curr->gch.next;
++ }
++ else { /* must erase `curr' */
++ lua_assert(isdead(g, curr) || deadmask == bitmask(SFIXEDBIT));
++ *p = curr->gch.next;
++ if (curr == g->rootgc) /* is the first element of the list? */
++ g->rootgc = curr->gch.next; /* adjust first */
++ freeobj(L, curr);
++ }
++ }
++ return p;
++}
++
++
++static void checkSizes (lua_State *L) {
++ global_State *g = G(L);
++ /* check size of string hash */
++ if (g->strt.nuse < cast(lu_int32, g->strt.size/4) &&
++ g->strt.size > MINSTRTABSIZE*2)
++ luaS_resize(L, g->strt.size/2); /* table is too big */
++ /* check size of buffer */
++ if (luaZ_sizebuffer(&g->buff) > LUA_MINBUFFER*2) { /* buffer too big? */
++ size_t newsize = luaZ_sizebuffer(&g->buff) / 2;
++ luaZ_resizebuffer(L, &g->buff, newsize);
++ }
++}
++
++
++static void GCTM (lua_State *L) {
++ global_State *g = G(L);
++ GCObject *o = g->tmudata->gch.next; /* get first element */
++ Udata *udata = rawgco2u(o);
++ const TValue *tm;
++ /* remove udata from `tmudata' */
++ if (o == g->tmudata) /* last element? */
++ g->tmudata = NULL;
++ else
++ g->tmudata->gch.next = udata->uv.next;
++ udata->uv.next = g->mainthread->next; /* return it to `root' list */
++ g->mainthread->next = o;
++ makewhite(g, o);
++ tm = fasttm(L, udata->uv.metatable, TM_GC);
++ if (tm != NULL) {
++ lu_byte oldah = L->allowhook;
++ lu_mem oldt = g->GCthreshold;
++ L->allowhook = 0; /* stop debug hooks during GC tag method */
++ g->GCthreshold = 2*g->totalbytes; /* avoid GC steps */
++ setobj2s(L, L->top, tm);
++ setuvalue(L, L->top+1, udata);
++ L->top += 2;
++ luaD_call(L, L->top - 2, 0);
++ L->allowhook = oldah; /* restore hooks */
++ g->GCthreshold = oldt; /* restore threshold */
++ }
++}
++
++
++/*
++** Call all GC tag methods
++*/
++void luaC_callGCTM (lua_State *L) {
++ while (G(L)->tmudata)
++ GCTM(L);
++}
++
++
++void luaC_freeall (lua_State *L) {
++ global_State *g = G(L);
++ int i;
++ g->currentwhite = WHITEBITS | bitmask(SFIXEDBIT); /* mask to collect all elements */
++ sweepwholelist(L, &g->rootgc);
++ for (i = 0; i < g->strt.size; i++) /* free all string lists */
++ sweepwholelist(L, &g->strt.hash[i]);
++}
++
++
++static void markmt (global_State *g) {
++ int i;
++ for (i=0; i<NUM_TAGS; i++)
++ if (g->mt[i]) markobject(g, g->mt[i]);
++}
++
++
++/* mark root set */
++static void markroot (lua_State *L) {
++ global_State *g = G(L);
++ g->gray = NULL;
++ g->grayagain = NULL;
++ g->weak = NULL;
++ markobject(g, g->mainthread);
++ /* make global table be traversed before main stack */
++ markvalue(g, gt(g->mainthread));
++ markvalue(g, registry(L));
++ markmt(g);
++ g->gcstate = GCSpropagate;
++}
++
++
++static void remarkupvals (global_State *g) {
++ UpVal *uv;
++ for (uv = g->uvhead.u.l.next; uv != &g->uvhead; uv = uv->u.l.next) {
++ lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv);
++ if (isgray(obj2gco(uv)))
++ markvalue(g, uv->v);
++ }
++}
++
++
++static void atomic (lua_State *L) {
++ global_State *g = G(L);
++ size_t udsize; /* total size of userdata to be finalized */
++ /* remark occasional upvalues of (maybe) dead threads */
++ remarkupvals(g);
++ /* traverse objects cautch by write barrier and by 'remarkupvals' */
++ propagateall(g);
++ /* remark weak tables */
++ g->gray = g->weak;
++ g->weak = NULL;
++ lua_assert(!iswhite(obj2gco(g->mainthread)));
++ markobject(g, L); /* mark running thread */
++ markmt(g); /* mark basic metatables (again) */
++ propagateall(g);
++ /* remark gray again */
++ g->gray = g->grayagain;
++ g->grayagain = NULL;
++ propagateall(g);
++ udsize = luaC_separateudata(L, 0); /* separate userdata to be finalized */
++ marktmu(g); /* mark `preserved' userdata */
++ udsize += propagateall(g); /* remark, to propagate `preserveness' */
++ cleartable(g->weak); /* remove collected objects from weak tables */
++ /* flip current white */
++ g->currentwhite = cast_byte(otherwhite(g));
++ g->sweepstrgc = 0;
++ g->sweepgc = &g->rootgc;
++ g->gcstate = GCSsweepstring;
++ g->estimate = g->totalbytes - udsize; /* first estimate */
++}
++
++
++static l_mem singlestep (lua_State *L) {
++ global_State *g = G(L);
++ /*lua_checkmemory(L);*/
++ switch (g->gcstate) {
++ case GCSpause: {
++ markroot(L); /* start a new collection */
++ return 0;
++ }
++ case GCSpropagate: {
++ if (g->gray)
++ return propagatemark(g);
++ else { /* no more `gray' objects */
++ atomic(L); /* finish mark phase */
++ return 0;
++ }
++ }
++ case GCSsweepstring: {
++ lu_mem old = g->totalbytes;
++ sweepwholelist(L, &g->strt.hash[g->sweepstrgc++]);
++ if (g->sweepstrgc >= g->strt.size) /* nothing more to sweep? */
++ g->gcstate = GCSsweep; /* end sweep-string phase */
++ lua_assert(old >= g->totalbytes);
++ g->estimate -= old - g->totalbytes;
++ return GCSWEEPCOST;
++ }
++ case GCSsweep: {
++ lu_mem old = g->totalbytes;
++ g->sweepgc = sweeplist(L, g->sweepgc, GCSWEEPMAX);
++ if (*g->sweepgc == NULL) { /* nothing more to sweep? */
++ checkSizes(L);
++ g->gcstate = GCSfinalize; /* end sweep phase */
++ }
++ lua_assert(old >= g->totalbytes);
++ g->estimate -= old - g->totalbytes;
++ return GCSWEEPMAX*GCSWEEPCOST;
++ }
++ case GCSfinalize: {
++ if (g->tmudata) {
++ GCTM(L);
++ if (g->estimate > GCFINALIZECOST)
++ g->estimate -= GCFINALIZECOST;
++ return GCFINALIZECOST;
++ }
++ else {
++ g->gcstate = GCSpause; /* end collection */
++ g->gcdept = 0;
++ return 0;
++ }
++ }
++ default: lua_assert(0); return 0;
++ }
++}
++
++
++void luaC_step (lua_State *L) {
++ global_State *g = G(L);
++ l_mem lim = (GCSTEPSIZE/100) * g->gcstepmul;
++ if (lim == 0)
++ lim = (MAX_LUMEM-1)/2; /* no limit */
++ g->gcdept += g->totalbytes - g->GCthreshold;
++ do {
++ lim -= singlestep(L);
++ if (g->gcstate == GCSpause)
++ break;
++ } while (lim > 0);
++ if (g->gcstate != GCSpause) {
++ if (g->gcdept < GCSTEPSIZE)
++ g->GCthreshold = g->totalbytes + GCSTEPSIZE; /* - lim/g->gcstepmul;*/
++ else {
++ g->gcdept -= GCSTEPSIZE;
++ g->GCthreshold = g->totalbytes;
++ }
++ }
++ else {
++ lua_assert(g->totalbytes >= g->estimate);
++ setthreshold(g);
++ }
++}
++
++
++void luaC_fullgc (lua_State *L) {
++ global_State *g = G(L);
++ if (g->gcstate <= GCSpropagate) {
++ /* reset sweep marks to sweep all elements (returning them to white) */
++ g->sweepstrgc = 0;
++ g->sweepgc = &g->rootgc;
++ /* reset other collector lists */
++ g->gray = NULL;
++ g->grayagain = NULL;
++ g->weak = NULL;
++ g->gcstate = GCSsweepstring;
++ }
++ lua_assert(g->gcstate != GCSpause && g->gcstate != GCSpropagate);
++ /* finish any pending sweep phase */
++ while (g->gcstate != GCSfinalize) {
++ lua_assert(g->gcstate == GCSsweepstring || g->gcstate == GCSsweep);
++ singlestep(L);
++ }
++ markroot(L);
++ while (g->gcstate != GCSpause) {
++ singlestep(L);
++ }
++ setthreshold(g);
++}
++
++
++void luaC_barrierf (lua_State *L, GCObject *o, GCObject *v) {
++ global_State *g = G(L);
++ lua_assert(isblack(o) && iswhite(v) && !isdead(g, v) && !isdead(g, o));
++ lua_assert(g->gcstate != GCSfinalize && g->gcstate != GCSpause);
++ lua_assert(ttype(&o->gch) != LUA_TTABLE);
++ /* must keep invariant? */
++ if (g->gcstate == GCSpropagate)
++ reallymarkobject(g, v); /* restore invariant */
++ else /* don't mind */
++ makewhite(g, o); /* mark as white just to avoid other barriers */
++}
++
++
++void luaC_barrierback (lua_State *L, Table *t) {
++ global_State *g = G(L);
++ GCObject *o = obj2gco(t);
++ lua_assert(isblack(o) && !isdead(g, o));
++ lua_assert(g->gcstate != GCSfinalize && g->gcstate != GCSpause);
++ black2gray(o); /* make table gray (again) */
++ t->gclist = g->grayagain;
++ g->grayagain = o;
++}
++
++
++void luaC_link (lua_State *L, GCObject *o, lu_byte tt) {
++ global_State *g = G(L);
++ o->gch.next = g->rootgc;
++ g->rootgc = o;
++ o->gch.marked = luaC_white(g);
++ o->gch.tt = tt;
++}
++
++
++void luaC_linkupval (lua_State *L, UpVal *uv) {
++ global_State *g = G(L);
++ GCObject *o = obj2gco(uv);
++ o->gch.next = g->rootgc; /* link upvalue into `rootgc' list */
++ g->rootgc = o;
++ if (isgray(o)) {
++ if (g->gcstate == GCSpropagate) {
++ gray2black(o); /* closed upvalues need barrier */
++ luaC_barrier(L, uv, uv->v);
++ }
++ else { /* sweep phase: sweep it (turning it into white) */
++ makewhite(g, o);
++ lua_assert(g->gcstate != GCSfinalize && g->gcstate != GCSpause);
++ }
++ }
++}
++
+--- /dev/null
++++ b/extensions/LUA/lua/lgc.h
+@@ -0,0 +1,110 @@
++/*
++** $Id: lgc.h,v 2.15.1.1 2007/12/27 13:02:25 roberto Exp $
++** Garbage Collector
++** See Copyright Notice in lua.h
++*/
++
++#ifndef lgc_h
++#define lgc_h
++
++
++#include "lobject.h"
++
++
++/*
++** Possible states of the Garbage Collector
++*/
++#define GCSpause 0
++#define GCSpropagate 1
++#define GCSsweepstring 2
++#define GCSsweep 3
++#define GCSfinalize 4
++
++
++/*
++** some userful bit tricks
++*/
++#define resetbits(x,m) ((x) &= cast(lu_byte, ~(m)))
++#define setbits(x,m) ((x) |= (m))
++#define testbits(x,m) ((x) & (m))
++#define bitmask(b) (1<<(b))
++#define bit2mask(b1,b2) (bitmask(b1) | bitmask(b2))
++#define l_setbit(x,b) setbits(x, bitmask(b))
++#define resetbit(x,b) resetbits(x, bitmask(b))
++#define testbit(x,b) testbits(x, bitmask(b))
++#define set2bits(x,b1,b2) setbits(x, (bit2mask(b1, b2)))
++#define reset2bits(x,b1,b2) resetbits(x, (bit2mask(b1, b2)))
++#define test2bits(x,b1,b2) testbits(x, (bit2mask(b1, b2)))
++
++
++
++/*
++** Layout for bit use in `marked' field:
++** bit 0 - object is white (type 0)
++** bit 1 - object is white (type 1)
++** bit 2 - object is black
++** bit 3 - for userdata: has been finalized
++** bit 3 - for tables: has weak keys
++** bit 4 - for tables: has weak values
++** bit 5 - object is fixed (should not be collected)
++** bit 6 - object is "super" fixed (only the main thread)
++*/
++
++
++#define WHITE0BIT 0
++#define WHITE1BIT 1
++#define BLACKBIT 2
++#define FINALIZEDBIT 3
++#define KEYWEAKBIT 3
++#define VALUEWEAKBIT 4
++#define FIXEDBIT 5
++#define SFIXEDBIT 6
++#define WHITEBITS bit2mask(WHITE0BIT, WHITE1BIT)
++
++
++#define iswhite(x) test2bits((x)->gch.marked, WHITE0BIT, WHITE1BIT)
++#define isblack(x) testbit((x)->gch.marked, BLACKBIT)
++#define isgray(x) (!isblack(x) && !iswhite(x))
++
++#define otherwhite(g) (g->currentwhite ^ WHITEBITS)
++#define isdead(g,v) ((v)->gch.marked & otherwhite(g) & WHITEBITS)
++
++#define changewhite(x) ((x)->gch.marked ^= WHITEBITS)
++#define gray2black(x) l_setbit((x)->gch.marked, BLACKBIT)
++
++#define valiswhite(x) (iscollectable(x) && iswhite(gcvalue(x)))
++
++#define luaC_white(g) cast(lu_byte, (g)->currentwhite & WHITEBITS)
++
++
++#define luaC_checkGC(L) { \
++ condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK - 1)); \
++ if (G(L)->totalbytes >= G(L)->GCthreshold) \
++ luaC_step(L); }
++
++
++#define luaC_barrier(L,p,v) { if (valiswhite(v) && isblack(obj2gco(p))) \
++ luaC_barrierf(L,obj2gco(p),gcvalue(v)); }
++
++#define luaC_barriert(L,t,v) { if (valiswhite(v) && isblack(obj2gco(t))) \
++ luaC_barrierback(L,t); }
++
++#define luaC_objbarrier(L,p,o) \
++ { if (iswhite(obj2gco(o)) && isblack(obj2gco(p))) \
++ luaC_barrierf(L,obj2gco(p),obj2gco(o)); }
++
++#define luaC_objbarriert(L,t,o) \
++ { if (iswhite(obj2gco(o)) && isblack(obj2gco(t))) luaC_barrierback(L,t); }
++
++LUAI_FUNC size_t luaC_separateudata (lua_State *L, int all);
++LUAI_FUNC void luaC_callGCTM (lua_State *L);
++LUAI_FUNC void luaC_freeall (lua_State *L);
++LUAI_FUNC void luaC_step (lua_State *L);
++LUAI_FUNC void luaC_fullgc (lua_State *L);
++LUAI_FUNC void luaC_link (lua_State *L, GCObject *o, lu_byte tt);
++LUAI_FUNC void luaC_linkupval (lua_State *L, UpVal *uv);
++LUAI_FUNC void luaC_barrierf (lua_State *L, GCObject *o, GCObject *v);
++LUAI_FUNC void luaC_barrierback (lua_State *L, Table *t);
++
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/llex.c
+@@ -0,0 +1,460 @@
++/*
++** $Id: llex.c,v 2.20.1.1 2007/12/27 13:02:25 roberto Exp $
++** Lexical Analyzer
++** See Copyright Notice in lua.h
++*/
++
++#include <ctype.h>
++#include <locale.h>
++#include <string.h>
++
++#define llex_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "ldo.h"
++#include "llex.h"
++#include "lobject.h"
++#include "lparser.h"
++#include "lstate.h"
++#include "lstring.h"
++#include "ltable.h"
++#include "lzio.h"
++
++
++
++#define next(ls) (ls->current = zgetc(ls->z))
++
++
++
++
++#define currIsNewline(ls) (ls->current == '\n' || ls->current == '\r')
++
++
++/* ORDER RESERVED */
++const char *const luaX_tokens [] = {
++ "and", "break", "do", "else", "elseif",
++ "end", "false", "for", "function", "if",
++ "in", "local", "nil", "not", "or", "repeat",
++ "return", "then", "true", "until", "while",
++ "..", "...", "==", ">=", "<=", "~=",
++ "<number>", "<name>", "<string>", "<eof>",
++ NULL
++};
++
++
++#define save_and_next(ls) (save(ls, ls->current), next(ls))
++
++
++static void save (LexState *ls, int c) {
++ Mbuffer *b = ls->buff;
++ if (b->n + 1 > b->buffsize) {
++ size_t newsize;
++ if (b->buffsize >= MAX_SIZET/2)
++ luaX_lexerror(ls, "lexical element too long", 0);
++ newsize = b->buffsize * 2;
++ luaZ_resizebuffer(ls->L, b, newsize);
++ }
++ b->buffer[b->n++] = cast(char, c);
++}
++
++
++void luaX_init (lua_State *L) {
++ int i;
++ for (i=0; i<NUM_RESERVED; i++) {
++ TString *ts = luaS_new(L, luaX_tokens[i]);
++ luaS_fix(ts); /* reserved words are never collected */
++ lua_assert(strlen(luaX_tokens[i])+1 <= TOKEN_LEN);
++ ts->tsv.reserved = cast_byte(i+1); /* reserved word */
++ }
++}
++
++
++#define MAXSRC 80
++
++
++const char *luaX_token2str (LexState *ls, int token) {
++ if (token < FIRST_RESERVED) {
++ lua_assert(token == cast(unsigned char, token));
++ return (iscntrl(token)) ? luaO_pushfstring(ls->L, "char(%d)", token) :
++ luaO_pushfstring(ls->L, "%c", token);
++ }
++ else
++ return luaX_tokens[token-FIRST_RESERVED];
++}
++
++
++static const char *txtToken (LexState *ls, int token) {
++ switch (token) {
++ case TK_NAME:
++ case TK_STRING:
++ case TK_NUMBER:
++ save(ls, '\0');
++ return luaZ_buffer(ls->buff);
++ default:
++ return luaX_token2str(ls, token);
++ }
++}
++
++
++void luaX_lexerror (LexState *ls, const char *msg, int token) {
++ char buff[MAXSRC];
++ luaO_chunkid(buff, getstr(ls->source), MAXSRC);
++ msg = luaO_pushfstring(ls->L, "%s:%d: %s", buff, ls->linenumber, msg);
++ if (token)
++ luaO_pushfstring(ls->L, "%s near " LUA_QS, msg, txtToken(ls, token));
++ luaD_throw(ls->L, LUA_ERRSYNTAX);
++}
++
++
++void luaX_syntaxerror (LexState *ls, const char *msg) {
++ luaX_lexerror(ls, msg, ls->t.token);
++}
++
++
++TString *luaX_newstring (LexState *ls, const char *str, size_t l) {
++ lua_State *L = ls->L;
++ TString *ts = luaS_newlstr(L, str, l);
++ TValue *o = luaH_setstr(L, ls->fs->h, ts); /* entry for `str' */
++ if (ttisnil(o))
++ setbvalue(o, 1); /* make sure `str' will not be collected */
++ return ts;
++}
++
++
++static void inclinenumber (LexState *ls) {
++ int old = ls->current;
++ lua_assert(currIsNewline(ls));
++ next(ls); /* skip `\n' or `\r' */
++ if (currIsNewline(ls) && ls->current != old)
++ next(ls); /* skip `\n\r' or `\r\n' */
++ if (++ls->linenumber >= MAX_INT)
++ luaX_syntaxerror(ls, "chunk has too many lines");
++}
++
++
++void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, TString *source) {
++ ls->decpoint = '.';
++ ls->L = L;
++ ls->lookahead.token = TK_EOS; /* no look-ahead token */
++ ls->z = z;
++ ls->fs = NULL;
++ ls->linenumber = 1;
++ ls->lastline = 1;
++ ls->source = source;
++ luaZ_resizebuffer(ls->L, ls->buff, LUA_MINBUFFER); /* initialize buffer */
++ next(ls); /* read first char */
++}
++
++
++
++/*
++** =======================================================
++** LEXICAL ANALYZER
++** =======================================================
++*/
++
++
++
++static int check_next (LexState *ls, const char *set) {
++ if (!strchr(set, ls->current))
++ return 0;
++ save_and_next(ls);
++ return 1;
++}
++
++
++static void buffreplace (LexState *ls, char from, char to) {
++ size_t n = luaZ_bufflen(ls->buff);
++ char *p = luaZ_buffer(ls->buff);
++ while (n--)
++ if (p[n] == from) p[n] = to;
++}
++
++
++static void trydecpoint (LexState *ls, SemInfo *seminfo) {
++ /* format error: try to update decimal point separator */
++ char old = ls->decpoint;
++ struct lconv *cv = localeconv();
++ ls->decpoint = (cv ? cv->decimal_point[0] : '.');
++ buffreplace(ls, old, ls->decpoint); /* try updated decimal separator */
++ if (!luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r)) {
++ /* format error with correct decimal point: no more options */
++ buffreplace(ls, ls->decpoint, '.'); /* undo change (for error message) */
++ luaX_lexerror(ls, "malformed number", TK_NUMBER);
++ }
++}
++
++
++/* LUA_NUMBER */
++static void read_numeral (LexState *ls, SemInfo *seminfo) {
++ lua_assert(isdigit(ls->current));
++ do {
++ save_and_next(ls);
++ } while (isdigit(ls->current) || ls->current == '.');
++ if (check_next(ls, "Ee")) /* `E'? */
++ check_next(ls, "+-"); /* optional exponent sign */
++ while (isalnum(ls->current) || ls->current == '_')
++ save_and_next(ls);
++ save(ls, '\0');
++ buffreplace(ls, '.', ls->decpoint); /* follow locale for decimal point */
++ if (!luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r)) /* format error? */
++ trydecpoint(ls, seminfo); /* try to update decimal point separator */
++}
++
++
++static int skip_sep (LexState *ls) {
++ int count = 0;
++ int s = ls->current;
++ lua_assert(s == '[' || s == ']');
++ save_and_next(ls);
++ while (ls->current == '=') {
++ save_and_next(ls);
++ count++;
++ }
++ return (ls->current == s) ? count : (-count) - 1;
++}
++
++
++static void read_long_string (LexState *ls, SemInfo *seminfo, int sep) {
++ int cont = 0;
++ (void)(cont); /* avoid warnings when `cont' is not used */
++ save_and_next(ls); /* skip 2nd `[' */
++ if (currIsNewline(ls)) /* string starts with a newline? */
++ inclinenumber(ls); /* skip it */
++ for (;;) {
++ switch (ls->current) {
++ case EOZ:
++ luaX_lexerror(ls, (seminfo) ? "unfinished long string" :
++ "unfinished long comment", TK_EOS);
++ break; /* to avoid warnings */
++#if defined(LUA_COMPAT_LSTR)
++ case '[': {
++ if (skip_sep(ls) == sep) {
++ save_and_next(ls); /* skip 2nd `[' */
++ cont++;
++#if LUA_COMPAT_LSTR == 1
++ if (sep == 0)
++ luaX_lexerror(ls, "nesting of [[...]] is deprecated", '[');
++#endif
++ }
++ break;
++ }
++#endif
++ case ']': {
++ if (skip_sep(ls) == sep) {
++ save_and_next(ls); /* skip 2nd `]' */
++#if defined(LUA_COMPAT_LSTR) && LUA_COMPAT_LSTR == 2
++ cont--;
++ if (sep == 0 && cont >= 0) break;
++#endif
++ goto endloop;
++ }
++ break;
++ }
++ case '\n':
++ case '\r': {
++ save(ls, '\n');
++ inclinenumber(ls);
++ if (!seminfo) luaZ_resetbuffer(ls->buff); /* avoid wasting space */
++ break;
++ }
++ default: {
++ if (seminfo) save_and_next(ls);
++ else next(ls);
++ }
++ }
++ } endloop:
++ if (seminfo)
++ seminfo->ts = luaX_newstring(ls, luaZ_buffer(ls->buff) + (2 + sep),
++ luaZ_bufflen(ls->buff) - 2*(2 + sep));
++}
++
++
++static void read_string (LexState *ls, int del, SemInfo *seminfo) {
++ save_and_next(ls);
++ while (ls->current != del) {
++ switch (ls->current) {
++ case EOZ:
++ luaX_lexerror(ls, "unfinished string", TK_EOS);
++ continue; /* to avoid warnings */
++ case '\n':
++ case '\r':
++ luaX_lexerror(ls, "unfinished string", TK_STRING);
++ continue; /* to avoid warnings */
++ case '\\': {
++ int c;
++ next(ls); /* do not save the `\' */
++ switch (ls->current) {
++ case 'a': c = '\a'; break;
++ case 'b': c = '\b'; break;
++ case 'f': c = '\f'; break;
++ case 'n': c = '\n'; break;
++ case 'r': c = '\r'; break;
++ case 't': c = '\t'; break;
++ case 'v': c = '\v'; break;
++ case '\n': /* go through */
++ case '\r': save(ls, '\n'); inclinenumber(ls); continue;
++ case EOZ: continue; /* will raise an error next loop */
++ default: {
++ if (!isdigit(ls->current))
++ save_and_next(ls); /* handles \\, \", \', and \? */
++ else { /* \xxx */
++ int i = 0;
++ c = 0;
++ do {
++ c = 10*c + (ls->current-'0');
++ next(ls);
++ } while (++i<3 && isdigit(ls->current));
++ if (c > UCHAR_MAX)
++ luaX_lexerror(ls, "escape sequence too large", TK_STRING);
++ save(ls, c);
++ }
++ continue;
++ }
++ }
++ save(ls, c);
++ next(ls);
++ continue;
++ }
++ default:
++ save_and_next(ls);
++ }
++ }
++ save_and_next(ls); /* skip delimiter */
++ seminfo->ts = luaX_newstring(ls, luaZ_buffer(ls->buff) + 1,
++ luaZ_bufflen(ls->buff) - 2);
++}
++
++
++static int llex (LexState *ls, SemInfo *seminfo) {
++ luaZ_resetbuffer(ls->buff);
++ for (;;) {
++ switch (ls->current) {
++ case '\n':
++ case '\r': {
++ inclinenumber(ls);
++ continue;
++ }
++ case '-': {
++ next(ls);
++ if (ls->current != '-') return '-';
++ /* else is a comment */
++ next(ls);
++ if (ls->current == '[') {
++ int sep = skip_sep(ls);
++ luaZ_resetbuffer(ls->buff); /* `skip_sep' may dirty the buffer */
++ if (sep >= 0) {
++ read_long_string(ls, NULL, sep); /* long comment */
++ luaZ_resetbuffer(ls->buff);
++ continue;
++ }
++ }
++ /* else short comment */
++ while (!currIsNewline(ls) && ls->current != EOZ)
++ next(ls);
++ continue;
++ }
++ case '[': {
++ int sep = skip_sep(ls);
++ if (sep >= 0) {
++ read_long_string(ls, seminfo, sep);
++ return TK_STRING;
++ }
++ else if (sep == -1) return '[';
++ else luaX_lexerror(ls, "invalid long string delimiter", TK_STRING);
++ }
++ case '=': {
++ next(ls);
++ if (ls->current != '=') return '=';
++ else { next(ls); return TK_EQ; }
++ }
++ case '<': {
++ next(ls);
++ if (ls->current != '=') return '<';
++ else { next(ls); return TK_LE; }
++ }
++ case '>': {
++ next(ls);
++ if (ls->current != '=') return '>';
++ else { next(ls); return TK_GE; }
++ }
++ case '~': {
++ next(ls);
++ if (ls->current != '=') return '~';
++ else { next(ls); return TK_NE; }
++ }
++ case '"':
++ case '\'': {
++ read_string(ls, ls->current, seminfo);
++ return TK_STRING;
++ }
++ case '.': {
++ save_and_next(ls);
++ if (check_next(ls, ".")) {
++ if (check_next(ls, "."))
++ return TK_DOTS; /* ... */
++ else return TK_CONCAT; /* .. */
++ }
++ else if (!isdigit(ls->current)) return '.';
++ else {
++ read_numeral(ls, seminfo);
++ return TK_NUMBER;
++ }
++ }
++ case EOZ: {
++ return TK_EOS;
++ }
++ default: {
++ if (isspace(ls->current)) {
++ lua_assert(!currIsNewline(ls));
++ next(ls);
++ continue;
++ }
++ else if (isdigit(ls->current)) {
++ read_numeral(ls, seminfo);
++ return TK_NUMBER;
++ }
++ else if (isalpha(ls->current) || ls->current == '_') {
++ /* identifier or reserved word */
++ TString *ts;
++ do {
++ save_and_next(ls);
++ } while (isalnum(ls->current) || ls->current == '_');
++ ts = luaX_newstring(ls, luaZ_buffer(ls->buff),
++ luaZ_bufflen(ls->buff));
++ if (ts->tsv.reserved > 0) /* reserved word? */
++ return ts->tsv.reserved - 1 + FIRST_RESERVED;
++ else {
++ seminfo->ts = ts;
++ return TK_NAME;
++ }
++ }
++ else {
++ int c = ls->current;
++ next(ls);
++ return c; /* single-char tokens (+ - / ...) */
++ }
++ }
++ }
++ }
++}
++
++
++void luaX_next (LexState *ls) {
++ ls->lastline = ls->linenumber;
++ if (ls->lookahead.token != TK_EOS) { /* is there a look-ahead token? */
++ ls->t = ls->lookahead; /* use this one */
++ ls->lookahead.token = TK_EOS; /* and discharge it */
++ }
++ else
++ ls->t.token = llex(ls, &ls->t.seminfo); /* read next token */
++}
++
++
++void luaX_lookahead (LexState *ls) {
++ lua_assert(ls->lookahead.token == TK_EOS);
++ ls->lookahead.token = llex(ls, &ls->lookahead.seminfo);
++}
++
+--- /dev/null
++++ b/extensions/LUA/lua/llex.h
+@@ -0,0 +1,81 @@
++/*
++** $Id: llex.h,v 1.58.1.1 2007/12/27 13:02:25 roberto Exp $
++** Lexical Analyzer
++** See Copyright Notice in lua.h
++*/
++
++#ifndef llex_h
++#define llex_h
++
++#include "lobject.h"
++#include "lzio.h"
++
++
++#define FIRST_RESERVED 257
++
++/* maximum length of a reserved word */
++#define TOKEN_LEN (sizeof("function")/sizeof(char))
++
++
++/*
++* WARNING: if you change the order of this enumeration,
++* grep "ORDER RESERVED"
++*/
++enum RESERVED {
++ /* terminal symbols denoted by reserved words */
++ TK_AND = FIRST_RESERVED, TK_BREAK,
++ TK_DO, TK_ELSE, TK_ELSEIF, TK_END, TK_FALSE, TK_FOR, TK_FUNCTION,
++ TK_IF, TK_IN, TK_LOCAL, TK_NIL, TK_NOT, TK_OR, TK_REPEAT,
++ TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE,
++ /* other terminal symbols */
++ TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, TK_NUMBER,
++ TK_NAME, TK_STRING, TK_EOS
++};
++
++/* number of reserved words */
++#define NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1))
++
++
++/* array with token `names' */
++LUAI_DATA const char *const luaX_tokens [];
++
++
++typedef union {
++ lua_Number r;
++ TString *ts;
++} SemInfo; /* semantics information */
++
++
++typedef struct Token {
++ int token;
++ SemInfo seminfo;
++} Token;
++
++
++typedef struct LexState {
++ int current; /* current character (charint) */
++ int linenumber; /* input line counter */
++ int lastline; /* line of last token `consumed' */
++ Token t; /* current token */
++ Token lookahead; /* look ahead token */
++ struct FuncState *fs; /* `FuncState' is private to the parser */
++ struct lua_State *L;
++ ZIO *z; /* input stream */
++ Mbuffer *buff; /* buffer for tokens */
++ TString *source; /* current source name */
++ char decpoint; /* locale decimal point */
++} LexState;
++
++
++LUAI_FUNC void luaX_init (lua_State *L);
++LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z,
++ TString *source);
++LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l);
++LUAI_FUNC void luaX_next (LexState *ls);
++LUAI_FUNC void luaX_lookahead (LexState *ls);
++LUAI_FUNC void luaX_lexerror (LexState *ls, const char *msg, int token);
++LUAI_FUNC void luaX_syntaxerror (LexState *ls, const char *s);
++LUAI_FUNC const char *luaX_token2str (LexState *ls, int token);
++
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/llimits.h
+@@ -0,0 +1,125 @@
++/*
++** $Id: llimits.h,v 1.69.1.1 2007/12/27 13:02:25 roberto Exp $
++** Limits, basic types, and some other `installation-dependent' definitions
++** See Copyright Notice in lua.h
++*/
++
++#ifndef llimits_h
++#define llimits_h
++
++#include <stddef.h>
++#include <limits.h>
++
++#include "lua.h"
++
++typedef LUAI_UINT32 lu_int32;
++
++typedef LUAI_UMEM lu_mem;
++
++typedef LUAI_MEM l_mem;
++
++
++
++/* chars used as small naturals (so that `char' is reserved for characters) */
++typedef unsigned char lu_byte;
++
++
++#define MAX_SIZET ((size_t)(~(size_t)0)-2)
++
++#define MAX_LUMEM ((lu_mem)(~(lu_mem)0)-2)
++
++
++#define MAX_INT (LUA_INT_MAX-2) /* maximum value of an int (-2 for safety) */
++
++/*
++** conversion of pointer to integer
++** this is for hashing only; there is no problem if the integer
++** cannot hold the whole pointer value
++*/
++#define IntPoint(p) ((unsigned int)(lu_mem)(p))
++
++
++
++/* type to ensure maximum alignment */
++typedef LUAI_USER_ALIGNMENT_T L_Umaxalign;
++
++
++/* result of a `usual argument conversion' over lua_Number */
++typedef LUAI_UACNUMBER l_uacNumber;
++
++
++/* internal assertions for in-house debugging */
++#ifdef lua_assert
++
++#define check_exp(c,e) (lua_assert(c), (e))
++#define api_check(l,e) lua_assert(e)
++
++#else
++
++#define lua_assert(c) ((void)0)
++#define check_exp(c,e) (e)
++#define api_check luai_apicheck
++
++#endif
++
++
++#ifndef UNUSED
++#define UNUSED(x) ((void)(x)) /* to avoid warnings */
++#endif
++
++
++#ifndef cast
++#define cast(t, exp) ((t)(exp))
++#endif
++
++#define cast_byte(i) cast(lu_byte, (i))
++#define cast_num(i) cast(lua_Number, (i))
++#define cast_int(i) cast(int, (i))
++
++
++
++/*
++** type for virtual-machine instructions
++** must be an unsigned with (at least) 4 bytes (see details in lopcodes.h)
++*/
++typedef lu_int32 Instruction;
++
++
++
++/* maximum stack for a Lua function */
++#define MAXSTACK 250
++
++
++
++/* minimum size for the string table (must be power of 2) */
++#ifndef MINSTRTABSIZE
++#define MINSTRTABSIZE 32
++#endif
++
++
++/* minimum size for string buffer */
++#ifndef LUA_MINBUFFER
++#define LUA_MINBUFFER 32
++#endif
++
++
++#ifndef lua_lock
++#define lua_lock(L) ((void) 0)
++#define lua_unlock(L) ((void) 0)
++#endif
++
++#ifndef luai_threadyield
++#define luai_threadyield(L) {lua_unlock(L); lua_lock(L);}
++#endif
++
++
++/*
++** macro to control inclusion of some hard tests on stack reallocation
++*/
++#ifndef HARDSTACKTESTS
++#define condhardstacktests(x) ((void)0)
++#else
++#define condhardstacktests(x) x
++#endif
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/lmem.c
+@@ -0,0 +1,86 @@
++/*
++** $Id: lmem.c,v 1.70.1.1 2007/12/27 13:02:25 roberto Exp $
++** Interface to Memory Manager
++** See Copyright Notice in lua.h
++*/
++
++
++#include <stddef.h>
++
++#define lmem_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "ldebug.h"
++#include "ldo.h"
++#include "lmem.h"
++#include "lobject.h"
++#include "lstate.h"
++
++
++
++/*
++** About the realloc function:
++** void * frealloc (void *ud, void *ptr, size_t osize, size_t nsize);
++** (`osize' is the old size, `nsize' is the new size)
++**
++** Lua ensures that (ptr == NULL) iff (osize == 0).
++**
++** * frealloc(ud, NULL, 0, x) creates a new block of size `x'
++**
++** * frealloc(ud, p, x, 0) frees the block `p'
++** (in this specific case, frealloc must return NULL).
++** particularly, frealloc(ud, NULL, 0, 0) does nothing
++** (which is equivalent to free(NULL) in ANSI C)
++**
++** frealloc returns NULL if it cannot create or reallocate the area
++** (any reallocation to an equal or smaller size cannot fail!)
++*/
++
++
++
++#define MINSIZEARRAY 4
++
++
++void *luaM_growaux_ (lua_State *L, void *block, int *size, size_t size_elems,
++ int limit, const char *errormsg) {
++ void *newblock;
++ int newsize;
++ if (*size >= limit/2) { /* cannot double it? */
++ if (*size >= limit) /* cannot grow even a little? */
++ luaG_runerror(L, errormsg);
++ newsize = limit; /* still have at least one free place */
++ }
++ else {
++ newsize = (*size)*2;
++ if (newsize < MINSIZEARRAY)
++ newsize = MINSIZEARRAY; /* minimum size */
++ }
++ newblock = luaM_reallocv(L, block, *size, newsize, size_elems);
++ *size = newsize; /* update only when everything else is OK */
++ return newblock;
++}
++
++
++void *luaM_toobig (lua_State *L) {
++ luaG_runerror(L, "memory allocation error: block too big");
++ return NULL; /* to avoid warnings */
++}
++
++
++
++/*
++** generic allocation routine.
++*/
++void *luaM_realloc_ (lua_State *L, void *block, size_t osize, size_t nsize) {
++ global_State *g = G(L);
++ lua_assert((osize == 0) == (block == NULL));
++ block = (*g->frealloc)(g->ud, block, osize, nsize);
++ if (block == NULL && nsize > 0)
++ luaD_throw(L, LUA_ERRMEM);
++ lua_assert((nsize == 0) == (block == NULL));
++ g->totalbytes = (g->totalbytes - osize) + nsize;
++ return block;
++}
++
+--- /dev/null
++++ b/extensions/LUA/lua/lmem.h
+@@ -0,0 +1,49 @@
++/*
++** $Id: lmem.h,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $
++** Interface to Memory Manager
++** See Copyright Notice in lua.h
++*/
++
++#ifndef lmem_h
++#define lmem_h
++
++
++#include <stddef.h>
++
++#include "llimits.h"
++#include "lua.h"
++
++#define MEMERRMSG "not enough memory"
++
++
++#define luaM_reallocv(L,b,on,n,e) \
++ ((cast(size_t, (n)+1) <= MAX_SIZET/(e)) ? /* +1 to avoid warnings */ \
++ luaM_realloc_(L, (b), (on)*(e), (n)*(e)) : \
++ luaM_toobig(L))
++
++#define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0)
++#define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0)
++#define luaM_freearray(L, b, n, t) luaM_reallocv(L, (b), n, 0, sizeof(t))
++
++#define luaM_malloc(L,t) luaM_realloc_(L, NULL, 0, (t))
++#define luaM_new(L,t) cast(t *, luaM_malloc(L, sizeof(t)))
++#define luaM_newvector(L,n,t) \
++ cast(t *, luaM_reallocv(L, NULL, 0, n, sizeof(t)))
++
++#define luaM_growvector(L,v,nelems,size,t,limit,e) \
++ if ((nelems)+1 > (size)) \
++ ((v)=cast(t *, luaM_growaux_(L,v,&(size),sizeof(t),limit,e)))
++
++#define luaM_reallocvector(L, v,oldn,n,t) \
++ ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t))))
++
++
++LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize,
++ size_t size);
++LUAI_FUNC void *luaM_toobig (lua_State *L);
++LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size,
++ size_t size_elem, int limit,
++ const char *errormsg);
++
++#endif
++
+--- /dev/null
++++ b/extensions/LUA/lua/lobject.c
+@@ -0,0 +1,215 @@
++/*
++** $Id: lobject.c,v 2.22.1.1 2007/12/27 13:02:25 roberto Exp $
++** Some generic functions over Lua objects
++** See Copyright Notice in lua.h
++*/
++
++#include <stdarg.h>
++
++#include <ctype.h>
++#include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
++
++#define lobject_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "ldo.h"
++#include "lmem.h"
++#include "lobject.h"
++#include "lstate.h"
++#include "lstring.h"
++#include "lvm.h"
++
++
++
++const TValue luaO_nilobject_ = {{NULL}, LUA_TNIL};
++
++
++/*
++** converts an integer to a "floating point byte", represented as
++** (eeeeexxx), where the real value is (1xxx) * 2^(eeeee - 1) if
++** eeeee != 0 and (xxx) otherwise.
++*/
++int luaO_int2fb (unsigned int x) {
++ int e = 0; /* expoent */
++ while (x >= 16) {
++ x = (x+1) >> 1;
++ e++;
++ }
++ if (x < 8) return x;
++ else return ((e+1) << 3) | (cast_int(x) - 8);
++}
++
++
++/* converts back */
++int luaO_fb2int (int x) {
++ int e = (x >> 3) & 31;
++ if (e == 0) return x;
++ else return ((x & 7)+8) << (e - 1);
++}
++
++
++int luaO_log2 (unsigned int x) {
++ static const lu_byte log_2[256] = {
++ 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
++ 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
++ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
++ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
++ 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
++ 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
++ 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
++ 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8
++ };
++ int l = -1;
++ while (x >= 256) { l += 8; x >>= 8; }
++ return l + log_2[x];
++
++}
++
++
++int luaO_rawequalObj (const TValue *t1, const TValue *t2) {
++ if (ttype(t1) != ttype(t2)) return 0;
++ else switch (ttype(t1)) {
++ case LUA_TNIL:
++ return 1;
++ case LUA_TNUMBER:
++ return luai_numeq(nvalue(t1), nvalue(t2));
++ case LUA_TBOOLEAN:
++ return bvalue(t1) == bvalue(t2); /* boolean true must be 1 !! */
++ case LUA_TLIGHTUSERDATA:
++ return pvalue(t1) == pvalue(t2);
++ default:
++ lua_assert(iscollectable(t1));
++ return gcvalue(t1) == gcvalue(t2);
++ }
++}
++
++
++int luaO_str2d (const char *s, lua_Number *result) {
++ char *endptr;
++ *result = lua_str2number(s, &endptr);
++ if (endptr == s) return 0; /* conversion failed */
++ if (*endptr == 'x' || *endptr == 'X') /* maybe an hexadecimal constant? */
++ *result = cast_num(strtoul(s, &endptr, 16));
++ if (*endptr == '\0') return 1; /* most common case */
++ while (isspace(cast(unsigned char, *endptr))) endptr++;
++ if (*endptr != '\0') return 0; /* invalid trailing characters? */
++ return 1;
++}
++
++
++
++static void pushstr (lua_State *L, const char *str) {
++ setsvalue2s(L, L->top, luaS_new(L, str));
++ incr_top(L);
++}
++
++
++/* this function handles only `%d', `%c', %f, %p, and `%s' formats */
++const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) {
++ int n = 1;
++ pushstr(L, "");
++ for (;;) {
++ const char *e = strchr(fmt, '%');
++ if (e == NULL) break;
++ setsvalue2s(L, L->top, luaS_newlstr(L, fmt, e-fmt));
++ incr_top(L);
++ switch (*(e+1)) {
++ case 's': {
++ const char *s = va_arg(argp, char *);
++ if (s == NULL) s = "(null)";
++ pushstr(L, s);
++ break;
++ }
++ case 'c': {
++ char buff[2];
++ buff[0] = cast(char, va_arg(argp, int));
++ buff[1] = '\0';
++ pushstr(L, buff);
++ break;
++ }
++ case 'd': {
++ setnvalue(L->top, cast_num(va_arg(argp, int)));
++ incr_top(L);
++ break;
++ }
++ case 'f': {
++ setnvalue(L->top, cast_num(va_arg(argp, l_uacNumber)));
++ incr_top(L);
++ break;
++ }
++ case 'p': {
++ char buff[4*sizeof(void *) + 8]; /* should be enough space for a `%p' */
++ sprintf(buff, "%p", va_arg(argp, void *));
++ pushstr(L, buff);
++ break;
++ }
++ case '%': {
++ pushstr(L, "%");
++ break;
++ }
++ default: {
++ char buff[3];
++ buff[0] = '%';
++ buff[1] = *(e+1);
++ buff[2] = '\0';
++ pushstr(L, buff);
++ break;
++ }
++ }
++ n += 2;
++ fmt = e+2;
++ }
++ pushstr(L, fmt);
++ luaV_concat(L, n+1, cast_int(L->top - L->base) - 1);
++ L->top -= n;
++ return svalue(L->top - 1);
++}
++
++
++const char *luaO_pushfstring (lua_State *L, const char *fmt, ...) {
++ const char *msg;
++ va_list argp;
++ va_start(argp, fmt);
++ msg = luaO_pushvfstring(L, fmt, argp);
++ va_end(argp);
++ return msg;
++}
++
++
++void luaO_chunkid (char *out, const char *source, size_t bufflen) {
++ if (*source == '=') {
++ strncpy(out, source+1, bufflen); /* remove first char */
++ out[bufflen-1] = '\0'; /* ensures null termination */
++ }
++ else { /* out = "source", or "...source" */
++ if (*source == '@') {
++ size_t l;
++ source++; /* skip the `@' */
++ bufflen -= sizeof(" '...' ");
++ l = strlen(source);
++ strcpy(out, "");
++ if (l > bufflen) {
++ source += (l-bufflen); /* get last part of file name */
++ strcat(out, "...");
++ }
++ strcat(out, source);
++ }
++ else { /* out = [string "string"] */
++ size_t len = strcspn(source, "\n\r"); /* stop at first newline */
++ bufflen -= sizeof(" [string \"...\"] ");
++ if (len > bufflen) len = bufflen;
++ strcpy(out, "[string \"");
++ if (source[len] != '\0') { /* must truncate? */
++ strncat(out, source, len);
++ strcat(out, "...");
++ }
++ else
++ strcat(out, source);
++ strcat(out, "\"]");
++ }
++ }
++}
+--- /dev/null
++++ b/extensions/LUA/lua/lobject.h
+@@ -0,0 +1,381 @@
++/*
++** $Id: lobject.h,v 2.20.1.2 2008/08/06 13:29:48 roberto Exp $
++** Type definitions for Lua objects
++** See Copyright Notice in lua.h
++*/
++
++
++#ifndef lobject_h
++#define lobject_h
++
++
++#include <stdarg.h>
++
++
++#include "llimits.h"
++#include "lua.h"
++
++
++/* tags for values visible from Lua */
++#define LAST_TAG LUA_TTHREAD
++
++#define NUM_TAGS (LAST_TAG+1)
++
++
++/*
++** Extra tags for non-values
++*/
++#define LUA_TPROTO (LAST_TAG+1)
++#define LUA_TUPVAL (LAST_TAG+2)
++#define LUA_TDEADKEY (LAST_TAG+3)
++
++
++/*
++** Union of all collectable objects
++*/
++typedef union GCObject GCObject;
++
++
++/*
++** Common Header for all collectable objects (in macro form, to be
++** included in other objects)
++*/
++#define CommonHeader GCObject *next; lu_byte tt; lu_byte marked
++
++
++/*
++** Common header in struct form
++*/
++typedef struct GCheader {
++ CommonHeader;
++} GCheader;
++
++
++
++
++/*
++** Union of all Lua values
++*/
++typedef union {
++ GCObject *gc;
++ void *p;
++ lua_Number n;
++ int b;
++} Value;
++
++
++/*
++** Tagged Values
++*/
++
++#define TValuefields Value value; int tt
++
++typedef struct lua_TValue {
++ TValuefields;
++} TValue;
++
++
++/* Macros to test type */
++#define ttisnil(o) (ttype(o) == LUA_TNIL)
++#define ttisnumber(o) (ttype(o) == LUA_TNUMBER)
++#define ttisstring(o) (ttype(o) == LUA_TSTRING)
++#define ttistable(o) (ttype(o) == LUA_TTABLE)
++#define ttisfunction(o) (ttype(o) == LUA_TFUNCTION)
++#define ttisboolean(o) (ttype(o) == LUA_TBOOLEAN)
++#define ttisuserdata(o) (ttype(o) == LUA_TUSERDATA)
++#define ttisthread(o) (ttype(o) == LUA_TTHREAD)
++#define ttislightuserdata(o) (ttype(o) == LUA_TLIGHTUSERDATA)
++
++/* Macros to access values */
++#define ttype(o) ((o)->tt)
++#define gcvalue(o) check_exp(iscollectable(o), (o)->value.gc)
++#define pvalue(o) check_exp(ttislightuserdata(o), (o)->value.p)
++#define nvalue(o) check_exp(ttisnumber(o), (o)->value.n)
++#define rawtsvalue(o) check_exp(ttisstring(o), &(o)->value.gc->ts)
++#define tsvalue(o) (&rawtsvalue(o)->tsv)
++#define rawuvalue(o) check_exp(ttisuserdata(o), &(o)->value.gc->u)
++#define uvalue(o) (&rawuvalue(o)->uv)
++#define clvalue(o) check_exp(ttisfunction(o), &(o)->value.gc->cl)
++#define hvalue(o) check_exp(ttistable(o), &(o)->value.gc->h)
++#define bvalue(o) check_exp(ttisboolean(o), (o)->value.b)
++#define thvalue(o) check_exp(ttisthread(o), &(o)->value.gc->th)
++
++#define l_isfalse(o) (ttisnil(o) || (ttisboolean(o) && bvalue(o) == 0))
++
++/*
++** for internal debug only
++*/
++#define checkconsistency(obj) \
++ lua_assert(!iscollectable(obj) || (ttype(obj) == (obj)->value.gc->gch.tt))
++
++#define checkliveness(g,obj) \
++ lua_assert(!iscollectable(obj) || \
++ ((ttype(obj) == (obj)->value.gc->gch.tt) && !isdead(g, (obj)->value.gc)))
++
++
++/* Macros to set values */
++#define setnilvalue(obj) ((obj)->tt=LUA_TNIL)
++
++#define setnvalue(obj,x) \
++ { TValue *i_o=(obj); i_o->value.n=(x); i_o->tt=LUA_TNUMBER; }
++
++#define setpvalue(obj,x) \
++ { TValue *i_o=(obj); i_o->value.p=(x); i_o->tt=LUA_TLIGHTUSERDATA; }
++
++#define setbvalue(obj,x) \
++ { TValue *i_o=(obj); i_o->value.b=(x); i_o->tt=LUA_TBOOLEAN; }
++
++#define setsvalue(L,obj,x) \
++ { TValue *i_o=(obj); \
++ i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TSTRING; \
++ checkliveness(G(L),i_o); }
++
++#define setuvalue(L,obj,x) \
++ { TValue *i_o=(obj); \
++ i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TUSERDATA; \
++ checkliveness(G(L),i_o); }
++
++#define setthvalue(L,obj,x) \
++ { TValue *i_o=(obj); \
++ i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TTHREAD; \
++ checkliveness(G(L),i_o); }
++
++#define setclvalue(L,obj,x) \
++ { TValue *i_o=(obj); \
++ i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TFUNCTION; \
++ checkliveness(G(L),i_o); }
++
++#define sethvalue(L,obj,x) \
++ { TValue *i_o=(obj); \
++ i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TTABLE; \
++ checkliveness(G(L),i_o); }
++
++#define setptvalue(L,obj,x) \
++ { TValue *i_o=(obj); \
++ i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TPROTO; \
++ checkliveness(G(L),i_o); }
++
++
++
++
++#define setobj(L,obj1,obj2) \
++ { const TValue *o2=(obj2); TValue *o1=(obj1); \
++ o1->value = o2->value; o1->tt=o2->tt; \
++ checkliveness(G(L),o1); }
++
++
++/*
++** different types of sets, according to destination
++*/
++
++/* from stack to (same) stack */
++#define setobjs2s setobj
++/* to stack (not from same stack) */
++#define setobj2s setobj
++#define setsvalue2s setsvalue
++#define sethvalue2s sethvalue
++#define setptvalue2s setptvalue
++/* from table to same table */
++#define setobjt2t setobj
++/* to table */
++#define setobj2t setobj
++/* to new object */
++#define setobj2n setobj
++#define setsvalue2n setsvalue
++
++#define setttype(obj, tt) (ttype(obj) = (tt))
++
++
++#define iscollectable(o) (ttype(o) >= LUA_TSTRING)
++
++
++
++typedef TValue *StkId; /* index to stack elements */
++
++
++/*
++** String headers for string table
++*/
++typedef union TString {
++ L_Umaxalign dummy; /* ensures maximum alignment for strings */
++ struct {
++ CommonHeader;
++ lu_byte reserved;
++ unsigned int hash;
++ size_t len;
++ } tsv;
++} TString;
++
++
++#define getstr(ts) cast(const char *, (ts) + 1)
++#define svalue(o) getstr(rawtsvalue(o))
++
++
++
++typedef union Udata {
++ L_Umaxalign dummy; /* ensures maximum alignment for `local' udata */
++ struct {
++ CommonHeader;
++ struct Table *metatable;
++ struct Table *env;
++ size_t len;
++ } uv;
++} Udata;
++
++
++
++
++/*
++** Function Prototypes
++*/
++typedef struct Proto {
++ CommonHeader;
++ TValue *k; /* constants used by the function */
++ Instruction *code;
++ struct Proto **p; /* functions defined inside the function */
++ int *lineinfo; /* map from opcodes to source lines */
++ struct LocVar *locvars; /* information about local variables */
++ TString **upvalues; /* upvalue names */
++ TString *source;
++ int sizeupvalues;
++ int sizek; /* size of `k' */
++ int sizecode;
++ int sizelineinfo;
++ int sizep; /* size of `p' */
++ int sizelocvars;
++ int linedefined;
++ int lastlinedefined;
++ GCObject *gclist;
++ lu_byte nups; /* number of upvalues */
++ lu_byte numparams;
++ lu_byte is_vararg;
++ lu_byte maxstacksize;
++} Proto;
++
++
++/* masks for new-style vararg */
++#define VARARG_HASARG 1
++#define VARARG_ISVARARG 2
++#define VARARG_NEEDSARG 4
++
++
++typedef struct LocVar {
++ TString *varname;
++ int startpc; /* first point where variable is active */
++ int endpc; /* first point where variable is dead */
++} LocVar;
++
++
++
++/*
++** Upvalues
++*/
++
++typedef struct UpVal {
++ CommonHeader;
++ TValue *v; /* points to stack or to its own value */
++ union {
++ TValue value; /* the value (when closed) */
++ struct { /* double linked list (when open) */
++ struct UpVal *prev;
++ struct UpVal *next;
++ } l;
++ } u;
++} UpVal;
++
++
++/*
++** Closures
++*/
++
++#define ClosureHeader \
++ CommonHeader; lu_byte isC; lu_byte nupvalues; GCObject *gclist; \
++ struct Table *env
++
++typedef struct CClosure {
++ ClosureHeader;
++ lua_CFunction f;
++ TValue upvalue[1];
++} CClosure;
++
++
++typedef struct LClosure {
++ ClosureHeader;
++ struct Proto *p;
++ UpVal *upvals[1];
++} LClosure;
++
++
++typedef union Closure {
++ CClosure c;
++ LClosure l;
++} Closure;
++
++
++#define iscfunction(o) (ttype(o) == LUA_TFUNCTION && clvalue(o)->c.isC)
++#define isLfunction(o) (ttype(o) == LUA_TFUNCTION && !clvalue(o)->c.isC)
++
++
++/*
++** Tables
++*/
++
++typedef union TKey {
++ struct {
++ TValuefields;
++ struct Node *next; /* for chaining */
++ } nk;
++ TValue tvk;
++} TKey;
++
++
++typedef struct Node {
++ TValue i_val;
++ TKey i_key;
++} Node;
++
++
++typedef struct Table {
++ CommonHeader;
++ lu_byte flags; /* 1<<p means tagmethod(p) is not present */
++ lu_byte lsizenode; /* log2 of size of `node' array */
++ struct Table *metatable;
++ TValue *array; /* array part */
++ Node *node;
++ Node *lastfree; /* any free position is before this position */
++ GCObject *gclist;
++ int sizearray; /* size of `array' array */
++} Table;
++
++
++
++/*
++** `module' operation for hashing (size is always a power of 2)
++*/
++#define lmod(s,size) \
++ (check_exp((size&(size-1))==0, (cast(int, (s) & ((size)-1)))))
++
++
++#define twoto(x) (1<<(x))
++#define sizenode(t) (twoto((t)->lsizenode))
++
++
++#define luaO_nilobject (&luaO_nilobject_)
++
++LUAI_DATA const TValue luaO_nilobject_;
++
++#define ceillog2(x) (luaO_log2((x)-1) + 1)
++
++LUAI_FUNC int luaO_log2 (unsigned int x);
++LUAI_FUNC int luaO_int2fb (unsigned int x);
++LUAI_FUNC int luaO_fb2int (int x);
++LUAI_FUNC int luaO_rawequalObj (const TValue *t1, const TValue *t2);
++LUAI_FUNC int luaO_str2d (const char *s, lua_Number *result);
++LUAI_FUNC const char *luaO_pushvfstring (lua_State *L, const char *fmt,
++ va_list argp);
++LUAI_FUNC const char *luaO_pushfstring (lua_State *L, const char *fmt, ...);
++LUAI_FUNC void luaO_chunkid (char *out, const char *source, size_t len);
++
++
++#endif
++
+--- /dev/null
++++ b/extensions/LUA/lua/lopcodes.c
+@@ -0,0 +1,102 @@
++/*
++** $Id: lopcodes.c,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $
++** See Copyright Notice in lua.h
++*/
++
++
++#define lopcodes_c
++#define LUA_CORE
++
++
++#include "lopcodes.h"
++
++
++/* ORDER OP */
++
++const char *const luaP_opnames[NUM_OPCODES+1] = {
++ "MOVE",
++ "LOADK",
++ "LOADBOOL",
++ "LOADNIL",
++ "GETUPVAL",
++ "GETGLOBAL",
++ "GETTABLE",
++ "SETGLOBAL",
++ "SETUPVAL",
++ "SETTABLE",
++ "NEWTABLE",
++ "SELF",
++ "ADD",
++ "SUB",
++ "MUL",
++ "DIV",
++ "MOD",
++ "POW",
++ "UNM",
++ "NOT",
++ "LEN",
++ "CONCAT",
++ "JMP",
++ "EQ",
++ "LT",
++ "LE",
++ "TEST",
++ "TESTSET",
++ "CALL",
++ "TAILCALL",
++ "RETURN",
++ "FORLOOP",
++ "FORPREP",
++ "TFORLOOP",
++ "SETLIST",
++ "CLOSE",
++ "CLOSURE",
++ "VARARG",
++ NULL
++};
++
++
++#define opmode(t,a,b,c,m) (((t)<<7) | ((a)<<6) | ((b)<<4) | ((c)<<2) | (m))
++
++const lu_byte luaP_opmodes[NUM_OPCODES] = {
++/* T A B C mode opcode */
++ opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_MOVE */
++ ,opmode(0, 1, OpArgK, OpArgN, iABx) /* OP_LOADK */
++ ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_LOADBOOL */
++ ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_LOADNIL */
++ ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_GETUPVAL */
++ ,opmode(0, 1, OpArgK, OpArgN, iABx) /* OP_GETGLOBAL */
++ ,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_GETTABLE */
++ ,opmode(0, 0, OpArgK, OpArgN, iABx) /* OP_SETGLOBAL */
++ ,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_SETUPVAL */
++ ,opmode(0, 0, OpArgK, OpArgK, iABC) /* OP_SETTABLE */
++ ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_NEWTABLE */
++ ,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_SELF */
++ ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_ADD */
++ ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_SUB */
++ ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MUL */
++ ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_DIV */
++ ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MOD */
++ ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_POW */
++ ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_UNM */
++ ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_NOT */
++ ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_LEN */
++ ,opmode(0, 1, OpArgR, OpArgR, iABC) /* OP_CONCAT */
++ ,opmode(0, 0, OpArgR, OpArgN, iAsBx) /* OP_JMP */
++ ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_EQ */
++ ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LT */
++ ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LE */
++ ,opmode(1, 1, OpArgR, OpArgU, iABC) /* OP_TEST */
++ ,opmode(1, 1, OpArgR, OpArgU, iABC) /* OP_TESTSET */
++ ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_CALL */
++ ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_TAILCALL */
++ ,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_RETURN */
++ ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORLOOP */
++ ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORPREP */
++ ,opmode(1, 0, OpArgN, OpArgU, iABC) /* OP_TFORLOOP */
++ ,opmode(0, 0, OpArgU, OpArgU, iABC) /* OP_SETLIST */
++ ,opmode(0, 0, OpArgN, OpArgN, iABC) /* OP_CLOSE */
++ ,opmode(0, 1, OpArgU, OpArgN, iABx) /* OP_CLOSURE */
++ ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_VARARG */
++};
++
+--- /dev/null
++++ b/extensions/LUA/lua/lopcodes.h
+@@ -0,0 +1,268 @@
++/*
++** $Id: lopcodes.h,v 1.125.1.1 2007/12/27 13:02:25 roberto Exp $
++** Opcodes for Lua virtual machine
++** See Copyright Notice in lua.h
++*/
++
++#ifndef lopcodes_h
++#define lopcodes_h
++
++#include "llimits.h"
++
++
++/*===========================================================================
++ We assume that instructions are unsigned numbers.
++ All instructions have an opcode in the first 6 bits.
++ Instructions can have the following fields:
++ `A' : 8 bits
++ `B' : 9 bits
++ `C' : 9 bits
++ `Bx' : 18 bits (`B' and `C' together)
++ `sBx' : signed Bx
++
++ A signed argument is represented in excess K; that is, the number
++ value is the unsigned value minus K. K is exactly the maximum value
++ for that argument (so that -max is represented by 0, and +max is
++ represented by 2*max), which is half the maximum for the corresponding
++ unsigned argument.
++===========================================================================*/
++
++
++enum OpMode {iABC, iABx, iAsBx}; /* basic instruction format */
++
++
++/*
++** size and position of opcode arguments.
++*/
++#define SIZE_C 9
++#define SIZE_B 9
++#define SIZE_Bx (SIZE_C + SIZE_B)
++#define SIZE_A 8
++
++#define SIZE_OP 6
++
++#define POS_OP 0
++#define POS_A (POS_OP + SIZE_OP)
++#define POS_C (POS_A + SIZE_A)
++#define POS_B (POS_C + SIZE_C)
++#define POS_Bx POS_C
++
++
++/*
++** limits for opcode arguments.
++** we use (signed) int to manipulate most arguments,
++** so they must fit in LUAI_BITSINT-1 bits (-1 for sign)
++*/
++#if SIZE_Bx < LUAI_BITSINT-1
++#define MAXARG_Bx ((1<<SIZE_Bx)-1)
++#define MAXARG_sBx (MAXARG_Bx>>1) /* `sBx' is signed */
++#else
++#define MAXARG_Bx MAX_INT
++#define MAXARG_sBx MAX_INT
++#endif
++
++
++#define MAXARG_A ((1<<SIZE_A)-1)
++#define MAXARG_B ((1<<SIZE_B)-1)
++#define MAXARG_C ((1<<SIZE_C)-1)
++
++
++/* creates a mask with `n' 1 bits at position `p' */
++#define MASK1(n,p) ((~((~(Instruction)0)<<n))<<p)
++
++/* creates a mask with `n' 0 bits at position `p' */
++#define MASK0(n,p) (~MASK1(n,p))
++
++/*
++** the following macros help to manipulate instructions
++*/
++
++#define GET_OPCODE(i) (cast(OpCode, ((i)>>POS_OP) & MASK1(SIZE_OP,0)))
++#define SET_OPCODE(i,o) ((i) = (((i)&MASK0(SIZE_OP,POS_OP)) | \
++ ((cast(Instruction, o)<<POS_OP)&MASK1(SIZE_OP,POS_OP))))
++
++#define GETARG_A(i) (cast(int, ((i)>>POS_A) & MASK1(SIZE_A,0)))
++#define SETARG_A(i,u) ((i) = (((i)&MASK0(SIZE_A,POS_A)) | \
++ ((cast(Instruction, u)<<POS_A)&MASK1(SIZE_A,POS_A))))
++
++#define GETARG_B(i) (cast(int, ((i)>>POS_B) & MASK1(SIZE_B,0)))
++#define SETARG_B(i,b) ((i) = (((i)&MASK0(SIZE_B,POS_B)) | \
++ ((cast(Instruction, b)<<POS_B)&MASK1(SIZE_B,POS_B))))
++
++#define GETARG_C(i) (cast(int, ((i)>>POS_C) & MASK1(SIZE_C,0)))
++#define SETARG_C(i,b) ((i) = (((i)&MASK0(SIZE_C,POS_C)) | \
++ ((cast(Instruction, b)<<POS_C)&MASK1(SIZE_C,POS_C))))
++
++#define GETARG_Bx(i) (cast(int, ((i)>>POS_Bx) & MASK1(SIZE_Bx,0)))
++#define SETARG_Bx(i,b) ((i) = (((i)&MASK0(SIZE_Bx,POS_Bx)) | \
++ ((cast(Instruction, b)<<POS_Bx)&MASK1(SIZE_Bx,POS_Bx))))
++
++#define GETARG_sBx(i) (GETARG_Bx(i)-MAXARG_sBx)
++#define SETARG_sBx(i,b) SETARG_Bx((i),cast(unsigned int, (b)+MAXARG_sBx))
++
++
++#define CREATE_ABC(o,a,b,c) ((cast(Instruction, o)<<POS_OP) \
++ | (cast(Instruction, a)<<POS_A) \
++ | (cast(Instruction, b)<<POS_B) \
++ | (cast(Instruction, c)<<POS_C))
++
++#define CREATE_ABx(o,a,bc) ((cast(Instruction, o)<<POS_OP) \
++ | (cast(Instruction, a)<<POS_A) \
++ | (cast(Instruction, bc)<<POS_Bx))
++
++
++/*
++** Macros to operate RK indices
++*/
++
++/* this bit 1 means constant (0 means register) */
++#define BITRK (1 << (SIZE_B - 1))
++
++/* test whether value is a constant */
++#define ISK(x) ((x) & BITRK)
++
++/* gets the index of the constant */
++#define INDEXK(r) ((int)(r) & ~BITRK)
++
++#define MAXINDEXRK (BITRK - 1)
++
++/* code a constant index as a RK value */
++#define RKASK(x) ((x) | BITRK)
++
++
++/*
++** invalid register that fits in 8 bits
++*/
++#define NO_REG MAXARG_A
++
++
++/*
++** R(x) - register
++** Kst(x) - constant (in constant table)
++** RK(x) == if ISK(x) then Kst(INDEXK(x)) else R(x)
++*/
++
++
++/*
++** grep "ORDER OP" if you change these enums
++*/
++
++typedef enum {
++/*----------------------------------------------------------------------
++name args description
++------------------------------------------------------------------------*/
++OP_MOVE,/* A B R(A) := R(B) */
++OP_LOADK,/* A Bx R(A) := Kst(Bx) */
++OP_LOADBOOL,/* A B C R(A) := (Bool)B; if (C) pc++ */
++OP_LOADNIL,/* A B R(A) := ... := R(B) := nil */
++OP_GETUPVAL,/* A B R(A) := UpValue[B] */
++
++OP_GETGLOBAL,/* A Bx R(A) := Gbl[Kst(Bx)] */
++OP_GETTABLE,/* A B C R(A) := R(B)[RK(C)] */
++
++OP_SETGLOBAL,/* A Bx Gbl[Kst(Bx)] := R(A) */
++OP_SETUPVAL,/* A B UpValue[B] := R(A) */
++OP_SETTABLE,/* A B C R(A)[RK(B)] := RK(C) */
++
++OP_NEWTABLE,/* A B C R(A) := {} (size = B,C) */
++
++OP_SELF,/* A B C R(A+1) := R(B); R(A) := R(B)[RK(C)] */
++
++OP_ADD,/* A B C R(A) := RK(B) + RK(C) */
++OP_SUB,/* A B C R(A) := RK(B) - RK(C) */
++OP_MUL,/* A B C R(A) := RK(B) * RK(C) */
++OP_DIV,/* A B C R(A) := RK(B) / RK(C) */
++OP_MOD,/* A B C R(A) := RK(B) % RK(C) */
++OP_POW,/* A B C R(A) := RK(B) ^ RK(C) */
++OP_UNM,/* A B R(A) := -R(B) */
++OP_NOT,/* A B R(A) := not R(B) */
++OP_LEN,/* A B R(A) := length of R(B) */
++
++OP_CONCAT,/* A B C R(A) := R(B).. ... ..R(C) */
++
++OP_JMP,/* sBx pc+=sBx */
++
++OP_EQ,/* A B C if ((RK(B) == RK(C)) ~= A) then pc++ */
++OP_LT,/* A B C if ((RK(B) < RK(C)) ~= A) then pc++ */
++OP_LE,/* A B C if ((RK(B) <= RK(C)) ~= A) then pc++ */
++
++OP_TEST,/* A C if not (R(A) <=> C) then pc++ */
++OP_TESTSET,/* A B C if (R(B) <=> C) then R(A) := R(B) else pc++ */
++
++OP_CALL,/* A B C R(A), ... ,R(A+C-2) := R(A)(R(A+1), ... ,R(A+B-1)) */
++OP_TAILCALL,/* A B C return R(A)(R(A+1), ... ,R(A+B-1)) */
++OP_RETURN,/* A B return R(A), ... ,R(A+B-2) (see note) */
++
++OP_FORLOOP,/* A sBx R(A)+=R(A+2);
++ if R(A) <?= R(A+1) then { pc+=sBx; R(A+3)=R(A) }*/
++OP_FORPREP,/* A sBx R(A)-=R(A+2); pc+=sBx */
++
++OP_TFORLOOP,/* A C R(A+3), ... ,R(A+2+C) := R(A)(R(A+1), R(A+2));
++ if R(A+3) ~= nil then R(A+2)=R(A+3) else pc++ */
++OP_SETLIST,/* A B C R(A)[(C-1)*FPF+i] := R(A+i), 1 <= i <= B */
++
++OP_CLOSE,/* A close all variables in the stack up to (>=) R(A)*/
++OP_CLOSURE,/* A Bx R(A) := closure(KPROTO[Bx], R(A), ... ,R(A+n)) */
++
++OP_VARARG/* A B R(A), R(A+1), ..., R(A+B-1) = vararg */
++} OpCode;
++
++
++#define NUM_OPCODES (cast(int, OP_VARARG) + 1)
++
++
++
++/*===========================================================================
++ Notes:
++ (*) In OP_CALL, if (B == 0) then B = top. C is the number of returns - 1,
++ and can be 0: OP_CALL then sets `top' to last_result+1, so
++ next open instruction (OP_CALL, OP_RETURN, OP_SETLIST) may use `top'.
++
++ (*) In OP_VARARG, if (B == 0) then use actual number of varargs and
++ set top (like in OP_CALL with C == 0).
++
++ (*) In OP_RETURN, if (B == 0) then return up to `top'
++
++ (*) In OP_SETLIST, if (B == 0) then B = `top';
++ if (C == 0) then next `instruction' is real C
++
++ (*) For comparisons, A specifies what condition the test should accept
++ (true or false).
++
++ (*) All `skips' (pc++) assume that next instruction is a jump
++===========================================================================*/
++
++
++/*
++** masks for instruction properties. The format is:
++** bits 0-1: op mode
++** bits 2-3: C arg mode
++** bits 4-5: B arg mode
++** bit 6: instruction set register A
++** bit 7: operator is a test
++*/
++
++enum OpArgMask {
++ OpArgN, /* argument is not used */
++ OpArgU, /* argument is used */
++ OpArgR, /* argument is a register or a jump offset */
++ OpArgK /* argument is a constant or register/constant */
++};
++
++LUAI_DATA const lu_byte luaP_opmodes[NUM_OPCODES];
++
++#define getOpMode(m) (cast(enum OpMode, luaP_opmodes[m] & 3))
++#define getBMode(m) (cast(enum OpArgMask, (luaP_opmodes[m] >> 4) & 3))
++#define getCMode(m) (cast(enum OpArgMask, (luaP_opmodes[m] >> 2) & 3))
++#define testAMode(m) (luaP_opmodes[m] & (1 << 6))
++#define testTMode(m) (luaP_opmodes[m] & (1 << 7))
++
++
++LUAI_DATA const char *const luaP_opnames[NUM_OPCODES+1]; /* opcode names */
++
++
++/* number of list items to accumulate before a SETLIST instruction */
++#define LFIELDS_PER_FLUSH 50
++
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/lparser.c
+@@ -0,0 +1,1339 @@
++/*
++** $Id: lparser.c,v 2.42.1.3 2007/12/28 15:32:23 roberto Exp $
++** Lua Parser
++** See Copyright Notice in lua.h
++*/
++
++
++#include <string.h>
++
++#define lparser_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "lcode.h"
++#include "ldebug.h"
++#include "ldo.h"
++#include "lfunc.h"
++#include "llex.h"
++#include "lmem.h"
++#include "lobject.h"
++#include "lopcodes.h"
++#include "lparser.h"
++#include "lstate.h"
++#include "lstring.h"
++#include "ltable.h"
++
++
++
++#define hasmultret(k) ((k) == VCALL || (k) == VVARARG)
++
++#define getlocvar(fs, i) ((fs)->f->locvars[(fs)->actvar[i]])
++
++#define luaY_checklimit(fs,v,l,m) if ((v)>(l)) errorlimit(fs,l,m)
++
++
++/*
++** nodes for block list (list of active blocks)
++*/
++typedef struct BlockCnt {
++ struct BlockCnt *previous; /* chain */
++ int breaklist; /* list of jumps out of this loop */
++ lu_byte nactvar; /* # active locals outside the breakable structure */
++ lu_byte upval; /* true if some variable in the block is an upvalue */
++ lu_byte isbreakable; /* true if `block' is a loop */
++} BlockCnt;
++
++
++
++/*
++** prototypes for recursive non-terminal functions
++*/
++static void chunk (LexState *ls);
++static void expr (LexState *ls, expdesc *v);
++
++
++static void anchor_token (LexState *ls) {
++ if (ls->t.token == TK_NAME || ls->t.token == TK_STRING) {
++ TString *ts = ls->t.seminfo.ts;
++ luaX_newstring(ls, getstr(ts), ts->tsv.len);
++ }
++}
++
++
++static void error_expected (LexState *ls, int token) {
++ luaX_syntaxerror(ls,
++ luaO_pushfstring(ls->L, LUA_QS " expected", luaX_token2str(ls, token)));
++}
++
++
++static void errorlimit (FuncState *fs, int limit, const char *what) {
++ const char *msg = (fs->f->linedefined == 0) ?
++ luaO_pushfstring(fs->L, "main function has more than %d %s", limit, what) :
++ luaO_pushfstring(fs->L, "function at line %d has more than %d %s",
++ fs->f->linedefined, limit, what);
++ luaX_lexerror(fs->ls, msg, 0);
++}
++
++
++static int testnext (LexState *ls, int c) {
++ if (ls->t.token == c) {
++ luaX_next(ls);
++ return 1;
++ }
++ else return 0;
++}
++
++
++static void check (LexState *ls, int c) {
++ if (ls->t.token != c)
++ error_expected(ls, c);
++}
++
++static void checknext (LexState *ls, int c) {
++ check(ls, c);
++ luaX_next(ls);
++}
++
++
++#define check_condition(ls,c,msg) { if (!(c)) luaX_syntaxerror(ls, msg); }
++
++
++
++static void check_match (LexState *ls, int what, int who, int where) {
++ if (!testnext(ls, what)) {
++ if (where == ls->linenumber)
++ error_expected(ls, what);
++ else {
++ luaX_syntaxerror(ls, luaO_pushfstring(ls->L,
++ LUA_QS " expected (to close " LUA_QS " at line %d)",
++ luaX_token2str(ls, what), luaX_token2str(ls, who), where));
++ }
++ }
++}
++
++
++static TString *str_checkname (LexState *ls) {
++ TString *ts;
++ check(ls, TK_NAME);
++ ts = ls->t.seminfo.ts;
++ luaX_next(ls);
++ return ts;
++}
++
++
++static void init_exp (expdesc *e, expkind k, int i) {
++ e->f = e->t = NO_JUMP;
++ e->k = k;
++ e->u.s.info = i;
++}
++
++
++static void codestring (LexState *ls, expdesc *e, TString *s) {
++ init_exp(e, VK, luaK_stringK(ls->fs, s));
++}
++
++
++static void checkname(LexState *ls, expdesc *e) {
++ codestring(ls, e, str_checkname(ls));
++}
++
++
++static int registerlocalvar (LexState *ls, TString *varname) {
++ FuncState *fs = ls->fs;
++ Proto *f = fs->f;
++ int oldsize = f->sizelocvars;
++ luaM_growvector(ls->L, f->locvars, fs->nlocvars, f->sizelocvars,
++ LocVar, SHRT_MAX, "too many local variables");
++ while (oldsize < f->sizelocvars) f->locvars[oldsize++].varname = NULL;
++ f->locvars[fs->nlocvars].varname = varname;
++ luaC_objbarrier(ls->L, f, varname);
++ return fs->nlocvars++;
++}
++
++
++#define new_localvarliteral(ls,v,n) \
++ new_localvar(ls, luaX_newstring(ls, "" v, (sizeof(v)/sizeof(char))-1), n)
++
++
++static void new_localvar (LexState *ls, TString *name, int n) {
++ FuncState *fs = ls->fs;
++ luaY_checklimit(fs, fs->nactvar+n+1, LUAI_MAXVARS, "local variables");
++ fs->actvar[fs->nactvar+n] = cast(unsigned short, registerlocalvar(ls, name));
++}
++
++
++static void adjustlocalvars (LexState *ls, int nvars) {
++ FuncState *fs = ls->fs;
++ fs->nactvar = cast_byte(fs->nactvar + nvars);
++ for (; nvars; nvars--) {
++ getlocvar(fs, fs->nactvar - nvars).startpc = fs->pc;
++ }
++}
++
++
++static void removevars (LexState *ls, int tolevel) {
++ FuncState *fs = ls->fs;
++ while (fs->nactvar > tolevel)
++ getlocvar(fs, --fs->nactvar).endpc = fs->pc;
++}
++
++
++static int indexupvalue (FuncState *fs, TString *name, expdesc *v) {
++ int i;
++ Proto *f = fs->f;
++ int oldsize = f->sizeupvalues;
++ for (i=0; i<f->nups; i++) {
++ if (fs->upvalues[i].k == v->k && fs->upvalues[i].info == v->u.s.info) {
++ lua_assert(f->upvalues[i] == name);
++ return i;
++ }
++ }
++ /* new one */
++ luaY_checklimit(fs, f->nups + 1, LUAI_MAXUPVALUES, "upvalues");
++ luaM_growvector(fs->L, f->upvalues, f->nups, f->sizeupvalues,
++ TString *, MAX_INT, "");
++ while (oldsize < f->sizeupvalues) f->upvalues[oldsize++] = NULL;
++ f->upvalues[f->nups] = name;
++ luaC_objbarrier(fs->L, f, name);
++ lua_assert(v->k == VLOCAL || v->k == VUPVAL);
++ fs->upvalues[f->nups].k = cast_byte(v->k);
++ fs->upvalues[f->nups].info = cast_byte(v->u.s.info);
++ return f->nups++;
++}
++
++
++static int searchvar (FuncState *fs, TString *n) {
++ int i;
++ for (i=fs->nactvar-1; i >= 0; i--) {
++ if (n == getlocvar(fs, i).varname)
++ return i;
++ }
++ return -1; /* not found */
++}
++
++
++static void markupval (FuncState *fs, int level) {
++ BlockCnt *bl = fs->bl;
++ while (bl && bl->nactvar > level) bl = bl->previous;
++ if (bl) bl->upval = 1;
++}
++
++
++static int singlevaraux (FuncState *fs, TString *n, expdesc *var, int base) {
++ if (fs == NULL) { /* no more levels? */
++ init_exp(var, VGLOBAL, NO_REG); /* default is global variable */
++ return VGLOBAL;
++ }
++ else {
++ int v = searchvar(fs, n); /* look up at current level */
++ if (v >= 0) {
++ init_exp(var, VLOCAL, v);
++ if (!base)
++ markupval(fs, v); /* local will be used as an upval */
++ return VLOCAL;
++ }
++ else { /* not found at current level; try upper one */
++ if (singlevaraux(fs->prev, n, var, 0) == VGLOBAL)
++ return VGLOBAL;
++ var->u.s.info = indexupvalue(fs, n, var); /* else was LOCAL or UPVAL */
++ var->k = VUPVAL; /* upvalue in this level */
++ return VUPVAL;
++ }
++ }
++}
++
++
++static void singlevar (LexState *ls, expdesc *var) {
++ TString *varname = str_checkname(ls);
++ FuncState *fs = ls->fs;
++ if (singlevaraux(fs, varname, var, 1) == VGLOBAL)
++ var->u.s.info = luaK_stringK(fs, varname); /* info points to global name */
++}
++
++
++static void adjust_assign (LexState *ls, int nvars, int nexps, expdesc *e) {
++ FuncState *fs = ls->fs;
++ int extra = nvars - nexps;
++ if (hasmultret(e->k)) {
++ extra++; /* includes call itself */
++ if (extra < 0) extra = 0;
++ luaK_setreturns(fs, e, extra); /* last exp. provides the difference */
++ if (extra > 1) luaK_reserveregs(fs, extra-1);
++ }
++ else {
++ if (e->k != VVOID) luaK_exp2nextreg(fs, e); /* close last expression */
++ if (extra > 0) {
++ int reg = fs->freereg;
++ luaK_reserveregs(fs, extra);
++ luaK_nil(fs, reg, extra);
++ }
++ }
++}
++
++
++static void enterlevel (LexState *ls) {
++ if (++ls->L->nCcalls > LUAI_MAXCCALLS)
++ luaX_lexerror(ls, "chunk has too many syntax levels", 0);
++}
++
++
++#define leavelevel(ls) ((ls)->L->nCcalls--)
++
++
++static void enterblock (FuncState *fs, BlockCnt *bl, lu_byte isbreakable) {
++ bl->breaklist = NO_JUMP;
++ bl->isbreakable = isbreakable;
++ bl->nactvar = fs->nactvar;
++ bl->upval = 0;
++ bl->previous = fs->bl;
++ fs->bl = bl;
++ lua_assert(fs->freereg == fs->nactvar);
++}
++
++
++static void leaveblock (FuncState *fs) {
++ BlockCnt *bl = fs->bl;
++ fs->bl = bl->previous;
++ removevars(fs->ls, bl->nactvar);
++ if (bl->upval)
++ luaK_codeABC(fs, OP_CLOSE, bl->nactvar, 0, 0);
++ /* a block either controls scope or breaks (never both) */
++ lua_assert(!bl->isbreakable || !bl->upval);
++ lua_assert(bl->nactvar == fs->nactvar);
++ fs->freereg = fs->nactvar; /* free registers */
++ luaK_patchtohere(fs, bl->breaklist);
++}
++
++
++static void pushclosure (LexState *ls, FuncState *func, expdesc *v) {
++ FuncState *fs = ls->fs;
++ Proto *f = fs->f;
++ int oldsize = f->sizep;
++ int i;
++ luaM_growvector(ls->L, f->p, fs->np, f->sizep, Proto *,
++ MAXARG_Bx, "constant table overflow");
++ while (oldsize < f->sizep) f->p[oldsize++] = NULL;
++ f->p[fs->np++] = func->f;
++ luaC_objbarrier(ls->L, f, func->f);
++ init_exp(v, VRELOCABLE, luaK_codeABx(fs, OP_CLOSURE, 0, fs->np-1));
++ for (i=0; i<func->f->nups; i++) {
++ OpCode o = (func->upvalues[i].k == VLOCAL) ? OP_MOVE : OP_GETUPVAL;
++ luaK_codeABC(fs, o, 0, func->upvalues[i].info, 0);
++ }
++}
++
++
++static void open_func (LexState *ls, FuncState *fs) {
++ lua_State *L = ls->L;
++ Proto *f = luaF_newproto(L);
++ fs->f = f;
++ fs->prev = ls->fs; /* linked list of funcstates */
++ fs->ls = ls;
++ fs->L = L;
++ ls->fs = fs;
++ fs->pc = 0;
++ fs->lasttarget = -1;
++ fs->jpc = NO_JUMP;
++ fs->freereg = 0;
++ fs->nk = 0;
++ fs->np = 0;
++ fs->nlocvars = 0;
++ fs->nactvar = 0;
++ fs->bl = NULL;
++ f->source = ls->source;
++ f->maxstacksize = 2; /* registers 0/1 are always valid */
++ fs->h = luaH_new(L, 0, 0);
++ /* anchor table of constants and prototype (to avoid being collected) */
++ sethvalue2s(L, L->top, fs->h);
++ incr_top(L);
++ setptvalue2s(L, L->top, f);
++ incr_top(L);
++}
++
++
++static void close_func (LexState *ls) {
++ lua_State *L = ls->L;
++ FuncState *fs = ls->fs;
++ Proto *f = fs->f;
++ removevars(ls, 0);
++ luaK_ret(fs, 0, 0); /* final return */
++ luaM_reallocvector(L, f->code, f->sizecode, fs->pc, Instruction);
++ f->sizecode = fs->pc;
++ luaM_reallocvector(L, f->lineinfo, f->sizelineinfo, fs->pc, int);
++ f->sizelineinfo = fs->pc;
++ luaM_reallocvector(L, f->k, f->sizek, fs->nk, TValue);
++ f->sizek = fs->nk;
++ luaM_reallocvector(L, f->p, f->sizep, fs->np, Proto *);
++ f->sizep = fs->np;
++ luaM_reallocvector(L, f->locvars, f->sizelocvars, fs->nlocvars, LocVar);
++ f->sizelocvars = fs->nlocvars;
++ luaM_reallocvector(L, f->upvalues, f->sizeupvalues, f->nups, TString *);
++ f->sizeupvalues = f->nups;
++ lua_assert(luaG_checkcode(f));
++ lua_assert(fs->bl == NULL);
++ ls->fs = fs->prev;
++ L->top -= 2; /* remove table and prototype from the stack */
++ /* last token read was anchored in defunct function; must reanchor it */
++ if (fs) anchor_token(ls);
++}
++
++
++Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, const char *name) {
++ struct LexState lexstate;
++ struct FuncState funcstate;
++ lexstate.buff = buff;
++ luaX_setinput(L, &lexstate, z, luaS_new(L, name));
++ open_func(&lexstate, &funcstate);
++ funcstate.f->is_vararg = VARARG_ISVARARG; /* main func. is always vararg */
++ luaX_next(&lexstate); /* read first token */
++ chunk(&lexstate);
++ check(&lexstate, TK_EOS);
++ close_func(&lexstate);
++ lua_assert(funcstate.prev == NULL);
++ lua_assert(funcstate.f->nups == 0);
++ lua_assert(lexstate.fs == NULL);
++ return funcstate.f;
++}
++
++
++
++/*============================================================*/
++/* GRAMMAR RULES */
++/*============================================================*/
++
++
++static void field (LexState *ls, expdesc *v) {
++ /* field -> ['.' | ':'] NAME */
++ FuncState *fs = ls->fs;
++ expdesc key;
++ luaK_exp2anyreg(fs, v);
++ luaX_next(ls); /* skip the dot or colon */
++ checkname(ls, &key);
++ luaK_indexed(fs, v, &key);
++}
++
++
++static void yindex (LexState *ls, expdesc *v) {
++ /* index -> '[' expr ']' */
++ luaX_next(ls); /* skip the '[' */
++ expr(ls, v);
++ luaK_exp2val(ls->fs, v);
++ checknext(ls, ']');
++}
++
++
++/*
++** {======================================================================
++** Rules for Constructors
++** =======================================================================
++*/
++
++
++struct ConsControl {
++ expdesc v; /* last list item read */
++ expdesc *t; /* table descriptor */
++ int nh; /* total number of `record' elements */
++ int na; /* total number of array elements */
++ int tostore; /* number of array elements pending to be stored */
++};
++
++
++static void recfield (LexState *ls, struct ConsControl *cc) {
++ /* recfield -> (NAME | `['exp1`]') = exp1 */
++ FuncState *fs = ls->fs;
++ int reg = ls->fs->freereg;
++ expdesc key, val;
++ int rkkey;
++ if (ls->t.token == TK_NAME) {
++ luaY_checklimit(fs, cc->nh, MAX_INT, "items in a constructor");
++ checkname(ls, &key);
++ }
++ else /* ls->t.token == '[' */
++ yindex(ls, &key);
++ cc->nh++;
++ checknext(ls, '=');
++ rkkey = luaK_exp2RK(fs, &key);
++ expr(ls, &val);
++ luaK_codeABC(fs, OP_SETTABLE, cc->t->u.s.info, rkkey, luaK_exp2RK(fs, &val));
++ fs->freereg = reg; /* free registers */
++}
++
++
++static void closelistfield (FuncState *fs, struct ConsControl *cc) {
++ if (cc->v.k == VVOID) return; /* there is no list item */
++ luaK_exp2nextreg(fs, &cc->v);
++ cc->v.k = VVOID;
++ if (cc->tostore == LFIELDS_PER_FLUSH) {
++ luaK_setlist(fs, cc->t->u.s.info, cc->na, cc->tostore); /* flush */
++ cc->tostore = 0; /* no more items pending */
++ }
++}
++
++
++static void lastlistfield (FuncState *fs, struct ConsControl *cc) {
++ if (cc->tostore == 0) return;
++ if (hasmultret(cc->v.k)) {
++ luaK_setmultret(fs, &cc->v);
++ luaK_setlist(fs, cc->t->u.s.info, cc->na, LUA_MULTRET);
++ cc->na--; /* do not count last expression (unknown number of elements) */
++ }
++ else {
++ if (cc->v.k != VVOID)
++ luaK_exp2nextreg(fs, &cc->v);
++ luaK_setlist(fs, cc->t->u.s.info, cc->na, cc->tostore);
++ }
++}
++
++
++static void listfield (LexState *ls, struct ConsControl *cc) {
++ expr(ls, &cc->v);
++ luaY_checklimit(ls->fs, cc->na, MAX_INT, "items in a constructor");
++ cc->na++;
++ cc->tostore++;
++}
++
++
++static void constructor (LexState *ls, expdesc *t) {
++ /* constructor -> ?? */
++ FuncState *fs = ls->fs;
++ int line = ls->linenumber;
++ int pc = luaK_codeABC(fs, OP_NEWTABLE, 0, 0, 0);
++ struct ConsControl cc;
++ cc.na = cc.nh = cc.tostore = 0;
++ cc.t = t;
++ init_exp(t, VRELOCABLE, pc);
++ init_exp(&cc.v, VVOID, 0); /* no value (yet) */
++ luaK_exp2nextreg(ls->fs, t); /* fix it at stack top (for gc) */
++ checknext(ls, '{');
++ do {
++ lua_assert(cc.v.k == VVOID || cc.tostore > 0);
++ if (ls->t.token == '}') break;
++ closelistfield(fs, &cc);
++ switch(ls->t.token) {
++ case TK_NAME: { /* may be listfields or recfields */
++ luaX_lookahead(ls);
++ if (ls->lookahead.token != '=') /* expression? */
++ listfield(ls, &cc);
++ else
++ recfield(ls, &cc);
++ break;
++ }
++ case '[': { /* constructor_item -> recfield */
++ recfield(ls, &cc);
++ break;
++ }
++ default: { /* constructor_part -> listfield */
++ listfield(ls, &cc);
++ break;
++ }
++ }
++ } while (testnext(ls, ',') || testnext(ls, ';'));
++ check_match(ls, '}', '{', line);
++ lastlistfield(fs, &cc);
++ SETARG_B(fs->f->code[pc], luaO_int2fb(cc.na)); /* set initial array size */
++ SETARG_C(fs->f->code[pc], luaO_int2fb(cc.nh)); /* set initial table size */
++}
++
++/* }====================================================================== */
++
++
++
++static void parlist (LexState *ls) {
++ /* parlist -> [ param { `,' param } ] */
++ FuncState *fs = ls->fs;
++ Proto *f = fs->f;
++ int nparams = 0;
++ f->is_vararg = 0;
++ if (ls->t.token != ')') { /* is `parlist' not empty? */
++ do {
++ switch (ls->t.token) {
++ case TK_NAME: { /* param -> NAME */
++ new_localvar(ls, str_checkname(ls), nparams++);
++ break;
++ }
++ case TK_DOTS: { /* param -> `...' */
++ luaX_next(ls);
++#if defined(LUA_COMPAT_VARARG)
++ /* use `arg' as default name */
++ new_localvarliteral(ls, "arg", nparams++);
++ f->is_vararg = VARARG_HASARG | VARARG_NEEDSARG;
++#endif
++ f->is_vararg |= VARARG_ISVARARG;
++ break;
++ }
++ default: luaX_syntaxerror(ls, "<name> or " LUA_QL("...") " expected");
++ }
++ } while (!f->is_vararg && testnext(ls, ','));
++ }
++ adjustlocalvars(ls, nparams);
++ f->numparams = cast_byte(fs->nactvar - (f->is_vararg & VARARG_HASARG));
++ luaK_reserveregs(fs, fs->nactvar); /* reserve register for parameters */
++}
++
++
++static void body (LexState *ls, expdesc *e, int needself, int line) {
++ /* body -> `(' parlist `)' chunk END */
++ FuncState new_fs;
++ open_func(ls, &new_fs);
++ new_fs.f->linedefined = line;
++ checknext(ls, '(');
++ if (needself) {
++ new_localvarliteral(ls, "self", 0);
++ adjustlocalvars(ls, 1);
++ }
++ parlist(ls);
++ checknext(ls, ')');
++ chunk(ls);
++ new_fs.f->lastlinedefined = ls->linenumber;
++ check_match(ls, TK_END, TK_FUNCTION, line);
++ close_func(ls);
++ pushclosure(ls, &new_fs, e);
++}
++
++
++static int explist1 (LexState *ls, expdesc *v) {
++ /* explist1 -> expr { `,' expr } */
++ int n = 1; /* at least one expression */
++ expr(ls, v);
++ while (testnext(ls, ',')) {
++ luaK_exp2nextreg(ls->fs, v);
++ expr(ls, v);
++ n++;
++ }
++ return n;
++}
++
++
++static void funcargs (LexState *ls, expdesc *f) {
++ FuncState *fs = ls->fs;
++ expdesc args;
++ int base, nparams;
++ int line = ls->linenumber;
++ switch (ls->t.token) {
++ case '(': { /* funcargs -> `(' [ explist1 ] `)' */
++ if (line != ls->lastline)
++ luaX_syntaxerror(ls,"ambiguous syntax (function call x new statement)");
++ luaX_next(ls);
++ if (ls->t.token == ')') /* arg list is empty? */
++ args.k = VVOID;
++ else {
++ explist1(ls, &args);
++ luaK_setmultret(fs, &args);
++ }
++ check_match(ls, ')', '(', line);
++ break;
++ }
++ case '{': { /* funcargs -> constructor */
++ constructor(ls, &args);
++ break;
++ }
++ case TK_STRING: { /* funcargs -> STRING */
++ codestring(ls, &args, ls->t.seminfo.ts);
++ luaX_next(ls); /* must use `seminfo' before `next' */
++ break;
++ }
++ default: {
++ luaX_syntaxerror(ls, "function arguments expected");
++ return;
++ }
++ }
++ lua_assert(f->k == VNONRELOC);
++ base = f->u.s.info; /* base register for call */
++ if (hasmultret(args.k))
++ nparams = LUA_MULTRET; /* open call */
++ else {
++ if (args.k != VVOID)
++ luaK_exp2nextreg(fs, &args); /* close last argument */
++ nparams = fs->freereg - (base+1);
++ }
++ init_exp(f, VCALL, luaK_codeABC(fs, OP_CALL, base, nparams+1, 2));
++ luaK_fixline(fs, line);
++ fs->freereg = base+1; /* call remove function and arguments and leaves
++ (unless changed) one result */
++}
++
++
++
++
++/*
++** {======================================================================
++** Expression parsing
++** =======================================================================
++*/
++
++
++static void prefixexp (LexState *ls, expdesc *v) {
++ /* prefixexp -> NAME | '(' expr ')' */
++ switch (ls->t.token) {
++ case '(': {
++ int line = ls->linenumber;
++ luaX_next(ls);
++ expr(ls, v);
++ check_match(ls, ')', '(', line);
++ luaK_dischargevars(ls->fs, v);
++ return;
++ }
++ case TK_NAME: {
++ singlevar(ls, v);
++ return;
++ }
++ default: {
++ luaX_syntaxerror(ls, "unexpected symbol");
++ return;
++ }
++ }
++}
++
++
++static void primaryexp (LexState *ls, expdesc *v) {
++ /* primaryexp ->
++ prefixexp { `.' NAME | `[' exp `]' | `:' NAME funcargs | funcargs } */
++ FuncState *fs = ls->fs;
++ prefixexp(ls, v);
++ for (;;) {
++ switch (ls->t.token) {
++ case '.': { /* field */
++ field(ls, v);
++ break;
++ }
++ case '[': { /* `[' exp1 `]' */
++ expdesc key;
++ luaK_exp2anyreg(fs, v);
++ yindex(ls, &key);
++ luaK_indexed(fs, v, &key);
++ break;
++ }
++ case ':': { /* `:' NAME funcargs */
++ expdesc key;
++ luaX_next(ls);
++ checkname(ls, &key);
++ luaK_self(fs, v, &key);
++ funcargs(ls, v);
++ break;
++ }
++ case '(': case TK_STRING: case '{': { /* funcargs */
++ luaK_exp2nextreg(fs, v);
++ funcargs(ls, v);
++ break;
++ }
++ default: return;
++ }
++ }
++}
++
++
++static void simpleexp (LexState *ls, expdesc *v) {
++ /* simpleexp -> NUMBER | STRING | NIL | true | false | ... |
++ constructor | FUNCTION body | primaryexp */
++ switch (ls->t.token) {
++ case TK_NUMBER: {
++ init_exp(v, VKNUM, 0);
++ v->u.nval = ls->t.seminfo.r;
++ break;
++ }
++ case TK_STRING: {
++ codestring(ls, v, ls->t.seminfo.ts);
++ break;
++ }
++ case TK_NIL: {
++ init_exp(v, VNIL, 0);
++ break;
++ }
++ case TK_TRUE: {
++ init_exp(v, VTRUE, 0);
++ break;
++ }
++ case TK_FALSE: {
++ init_exp(v, VFALSE, 0);
++ break;
++ }
++ case TK_DOTS: { /* vararg */
++ FuncState *fs = ls->fs;
++ check_condition(ls, fs->f->is_vararg,
++ "cannot use " LUA_QL("...") " outside a vararg function");
++ fs->f->is_vararg &= ~VARARG_NEEDSARG; /* don't need 'arg' */
++ init_exp(v, VVARARG, luaK_codeABC(fs, OP_VARARG, 0, 1, 0));
++ break;
++ }
++ case '{': { /* constructor */
++ constructor(ls, v);
++ return;
++ }
++ case TK_FUNCTION: {
++ luaX_next(ls);
++ body(ls, v, 0, ls->linenumber);
++ return;
++ }
++ default: {
++ primaryexp(ls, v);
++ return;
++ }
++ }
++ luaX_next(ls);
++}
++
++
++static UnOpr getunopr (int op) {
++ switch (op) {
++ case TK_NOT: return OPR_NOT;
++ case '-': return OPR_MINUS;
++ case '#': return OPR_LEN;
++ default: return OPR_NOUNOPR;
++ }
++}
++
++
++static BinOpr getbinopr (int op) {
++ switch (op) {
++ case '+': return OPR_ADD;
++ case '-': return OPR_SUB;
++ case '*': return OPR_MUL;
++ case '/': return OPR_DIV;
++ case '%': return OPR_MOD;
++ case '^': return OPR_POW;
++ case TK_CONCAT: return OPR_CONCAT;
++ case TK_NE: return OPR_NE;
++ case TK_EQ: return OPR_EQ;
++ case '<': return OPR_LT;
++ case TK_LE: return OPR_LE;
++ case '>': return OPR_GT;
++ case TK_GE: return OPR_GE;
++ case TK_AND: return OPR_AND;
++ case TK_OR: return OPR_OR;
++ default: return OPR_NOBINOPR;
++ }
++}
++
++
++static const struct {
++ lu_byte left; /* left priority for each binary operator */
++ lu_byte right; /* right priority */
++} priority[] = { /* ORDER OPR */
++ {6, 6}, {6, 6}, {7, 7}, {7, 7}, {7, 7}, /* `+' `-' `/' `%' */
++ {10, 9}, {5, 4}, /* power and concat (right associative) */
++ {3, 3}, {3, 3}, /* equality and inequality */
++ {3, 3}, {3, 3}, {3, 3}, {3, 3}, /* order */
++ {2, 2}, {1, 1} /* logical (and/or) */
++};
++
++#define UNARY_PRIORITY 8 /* priority for unary operators */
++
++
++/*
++** subexpr -> (simpleexp | unop subexpr) { binop subexpr }
++** where `binop' is any binary operator with a priority higher than `limit'
++*/
++static BinOpr subexpr (LexState *ls, expdesc *v, unsigned int limit) {
++ BinOpr op;
++ UnOpr uop;
++ enterlevel(ls);
++ uop = getunopr(ls->t.token);
++ if (uop != OPR_NOUNOPR) {
++ luaX_next(ls);
++ subexpr(ls, v, UNARY_PRIORITY);
++ luaK_prefix(ls->fs, uop, v);
++ }
++ else simpleexp(ls, v);
++ /* expand while operators have priorities higher than `limit' */
++ op = getbinopr(ls->t.token);
++ while (op != OPR_NOBINOPR && priority[op].left > limit) {
++ expdesc v2;
++ BinOpr nextop;
++ luaX_next(ls);
++ luaK_infix(ls->fs, op, v);
++ /* read sub-expression with higher priority */
++ nextop = subexpr(ls, &v2, priority[op].right);
++ luaK_posfix(ls->fs, op, v, &v2);
++ op = nextop;
++ }
++ leavelevel(ls);
++ return op; /* return first untreated operator */
++}
++
++
++static void expr (LexState *ls, expdesc *v) {
++ subexpr(ls, v, 0);
++}
++
++/* }==================================================================== */
++
++
++
++/*
++** {======================================================================
++** Rules for Statements
++** =======================================================================
++*/
++
++
++static int block_follow (int token) {
++ switch (token) {
++ case TK_ELSE: case TK_ELSEIF: case TK_END:
++ case TK_UNTIL: case TK_EOS:
++ return 1;
++ default: return 0;
++ }
++}
++
++
++static void block (LexState *ls) {
++ /* block -> chunk */
++ FuncState *fs = ls->fs;
++ BlockCnt bl;
++ enterblock(fs, &bl, 0);
++ chunk(ls);
++ lua_assert(bl.breaklist == NO_JUMP);
++ leaveblock(fs);
++}
++
++
++/*
++** structure to chain all variables in the left-hand side of an
++** assignment
++*/
++struct LHS_assign {
++ struct LHS_assign *prev;
++ expdesc v; /* variable (global, local, upvalue, or indexed) */
++};
++
++
++/*
++** check whether, in an assignment to a local variable, the local variable
++** is needed in a previous assignment (to a table). If so, save original
++** local value in a safe place and use this safe copy in the previous
++** assignment.
++*/
++static void check_conflict (LexState *ls, struct LHS_assign *lh, expdesc *v) {
++ FuncState *fs = ls->fs;
++ int extra = fs->freereg; /* eventual position to save local variable */
++ int conflict = 0;
++ for (; lh; lh = lh->prev) {
++ if (lh->v.k == VINDEXED) {
++ if (lh->v.u.s.info == v->u.s.info) { /* conflict? */
++ conflict = 1;
++ lh->v.u.s.info = extra; /* previous assignment will use safe copy */
++ }
++ if (lh->v.u.s.aux == v->u.s.info) { /* conflict? */
++ conflict = 1;
++ lh->v.u.s.aux = extra; /* previous assignment will use safe copy */
++ }
++ }
++ }
++ if (conflict) {
++ luaK_codeABC(fs, OP_MOVE, fs->freereg, v->u.s.info, 0); /* make copy */
++ luaK_reserveregs(fs, 1);
++ }
++}
++
++
++static void assignment (LexState *ls, struct LHS_assign *lh, int nvars) {
++ expdesc e;
++ check_condition(ls, VLOCAL <= lh->v.k && lh->v.k <= VINDEXED,
++ "syntax error");
++ if (testnext(ls, ',')) { /* assignment -> `,' primaryexp assignment */
++ struct LHS_assign nv;
++ nv.prev = lh;
++ primaryexp(ls, &nv.v);
++ if (nv.v.k == VLOCAL)
++ check_conflict(ls, lh, &nv.v);
++ luaY_checklimit(ls->fs, nvars, LUAI_MAXCCALLS - ls->L->nCcalls,
++ "variables in assignment");
++ assignment(ls, &nv, nvars+1);
++ }
++ else { /* assignment -> `=' explist1 */
++ int nexps;
++ checknext(ls, '=');
++ nexps = explist1(ls, &e);
++ if (nexps != nvars) {
++ adjust_assign(ls, nvars, nexps, &e);
++ if (nexps > nvars)
++ ls->fs->freereg -= nexps - nvars; /* remove extra values */
++ }
++ else {
++ luaK_setoneret(ls->fs, &e); /* close last expression */
++ luaK_storevar(ls->fs, &lh->v, &e);
++ return; /* avoid default */
++ }
++ }
++ init_exp(&e, VNONRELOC, ls->fs->freereg-1); /* default assignment */
++ luaK_storevar(ls->fs, &lh->v, &e);
++}
++
++
++static int cond (LexState *ls) {
++ /* cond -> exp */
++ expdesc v;
++ expr(ls, &v); /* read condition */
++ if (v.k == VNIL) v.k = VFALSE; /* `falses' are all equal here */
++ luaK_goiftrue(ls->fs, &v);
++ return v.f;
++}
++
++
++static void breakstat (LexState *ls) {
++ FuncState *fs = ls->fs;
++ BlockCnt *bl = fs->bl;
++ int upval = 0;
++ while (bl && !bl->isbreakable) {
++ upval |= bl->upval;
++ bl = bl->previous;
++ }
++ if (!bl)
++ luaX_syntaxerror(ls, "no loop to break");
++ if (upval)
++ luaK_codeABC(fs, OP_CLOSE, bl->nactvar, 0, 0);
++ luaK_concat(fs, &bl->breaklist, luaK_jump(fs));
++}
++
++
++static void whilestat (LexState *ls, int line) {
++ /* whilestat -> WHILE cond DO block END */
++ FuncState *fs = ls->fs;
++ int whileinit;
++ int condexit;
++ BlockCnt bl;
++ luaX_next(ls); /* skip WHILE */
++ whileinit = luaK_getlabel(fs);
++ condexit = cond(ls);
++ enterblock(fs, &bl, 1);
++ checknext(ls, TK_DO);
++ block(ls);
++ luaK_patchlist(fs, luaK_jump(fs), whileinit);
++ check_match(ls, TK_END, TK_WHILE, line);
++ leaveblock(fs);
++ luaK_patchtohere(fs, condexit); /* false conditions finish the loop */
++}
++
++
++static void repeatstat (LexState *ls, int line) {
++ /* repeatstat -> REPEAT block UNTIL cond */
++ int condexit;
++ FuncState *fs = ls->fs;
++ int repeat_init = luaK_getlabel(fs);
++ BlockCnt bl1, bl2;
++ enterblock(fs, &bl1, 1); /* loop block */
++ enterblock(fs, &bl2, 0); /* scope block */
++ luaX_next(ls); /* skip REPEAT */
++ chunk(ls);
++ check_match(ls, TK_UNTIL, TK_REPEAT, line);
++ condexit = cond(ls); /* read condition (inside scope block) */
++ if (!bl2.upval) { /* no upvalues? */
++ leaveblock(fs); /* finish scope */
++ luaK_patchlist(ls->fs, condexit, repeat_init); /* close the loop */
++ }
++ else { /* complete semantics when there are upvalues */
++ breakstat(ls); /* if condition then break */
++ luaK_patchtohere(ls->fs, condexit); /* else... */
++ leaveblock(fs); /* finish scope... */
++ luaK_patchlist(ls->fs, luaK_jump(fs), repeat_init); /* and repeat */
++ }
++ leaveblock(fs); /* finish loop */
++}
++
++
++static int exp1 (LexState *ls) {
++ expdesc e;
++ int k;
++ expr(ls, &e);
++ k = e.k;
++ luaK_exp2nextreg(ls->fs, &e);
++ return k;
++}
++
++
++static void forbody (LexState *ls, int base, int line, int nvars, int isnum) {
++ /* forbody -> DO block */
++ BlockCnt bl;
++ FuncState *fs = ls->fs;
++ int prep, endfor;
++ adjustlocalvars(ls, 3); /* control variables */
++ checknext(ls, TK_DO);
++ prep = isnum ? luaK_codeAsBx(fs, OP_FORPREP, base, NO_JUMP) : luaK_jump(fs);
++ enterblock(fs, &bl, 0); /* scope for declared variables */
++ adjustlocalvars(ls, nvars);
++ luaK_reserveregs(fs, nvars);
++ block(ls);
++ leaveblock(fs); /* end of scope for declared variables */
++ luaK_patchtohere(fs, prep);
++ endfor = (isnum) ? luaK_codeAsBx(fs, OP_FORLOOP, base, NO_JUMP) :
++ luaK_codeABC(fs, OP_TFORLOOP, base, 0, nvars);
++ luaK_fixline(fs, line); /* pretend that `OP_FOR' starts the loop */
++ luaK_patchlist(fs, (isnum ? endfor : luaK_jump(fs)), prep + 1);
++}
++
++
++static void fornum (LexState *ls, TString *varname, int line) {
++ /* fornum -> NAME = exp1,exp1[,exp1] forbody */
++ FuncState *fs = ls->fs;
++ int base = fs->freereg;
++ new_localvarliteral(ls, "(for index)", 0);
++ new_localvarliteral(ls, "(for limit)", 1);
++ new_localvarliteral(ls, "(for step)", 2);
++ new_localvar(ls, varname, 3);
++ checknext(ls, '=');
++ exp1(ls); /* initial value */
++ checknext(ls, ',');
++ exp1(ls); /* limit */
++ if (testnext(ls, ','))
++ exp1(ls); /* optional step */
++ else { /* default step = 1 */
++ luaK_codeABx(fs, OP_LOADK, fs->freereg, luaK_numberK(fs, 1));
++ luaK_reserveregs(fs, 1);
++ }
++ forbody(ls, base, line, 1, 1);
++}
++
++
++static void forlist (LexState *ls, TString *indexname) {
++ /* forlist -> NAME {,NAME} IN explist1 forbody */
++ FuncState *fs = ls->fs;
++ expdesc e;
++ int nvars = 0;
++ int line;
++ int base = fs->freereg;
++ /* create control variables */
++ new_localvarliteral(ls, "(for generator)", nvars++);
++ new_localvarliteral(ls, "(for state)", nvars++);
++ new_localvarliteral(ls, "(for control)", nvars++);
++ /* create declared variables */
++ new_localvar(ls, indexname, nvars++);
++ while (testnext(ls, ','))
++ new_localvar(ls, str_checkname(ls), nvars++);
++ checknext(ls, TK_IN);
++ line = ls->linenumber;
++ adjust_assign(ls, 3, explist1(ls, &e), &e);
++ luaK_checkstack(fs, 3); /* extra space to call generator */
++ forbody(ls, base, line, nvars - 3, 0);
++}
++
++
++static void forstat (LexState *ls, int line) {
++ /* forstat -> FOR (fornum | forlist) END */
++ FuncState *fs = ls->fs;
++ TString *varname;
++ BlockCnt bl;
++ enterblock(fs, &bl, 1); /* scope for loop and control variables */
++ luaX_next(ls); /* skip `for' */
++ varname = str_checkname(ls); /* first variable name */
++ switch (ls->t.token) {
++ case '=': fornum(ls, varname, line); break;
++ case ',': case TK_IN: forlist(ls, varname); break;
++ default: luaX_syntaxerror(ls, LUA_QL("=") " or " LUA_QL("in") " expected");
++ }
++ check_match(ls, TK_END, TK_FOR, line);
++ leaveblock(fs); /* loop scope (`break' jumps to this point) */
++}
++
++
++static int test_then_block (LexState *ls) {
++ /* test_then_block -> [IF | ELSEIF] cond THEN block */
++ int condexit;
++ luaX_next(ls); /* skip IF or ELSEIF */
++ condexit = cond(ls);
++ checknext(ls, TK_THEN);
++ block(ls); /* `then' part */
++ return condexit;
++}
++
++
++static void ifstat (LexState *ls, int line) {
++ /* ifstat -> IF cond THEN block {ELSEIF cond THEN block} [ELSE block] END */
++ FuncState *fs = ls->fs;
++ int flist;
++ int escapelist = NO_JUMP;
++ flist = test_then_block(ls); /* IF cond THEN block */
++ while (ls->t.token == TK_ELSEIF) {
++ luaK_concat(fs, &escapelist, luaK_jump(fs));
++ luaK_patchtohere(fs, flist);
++ flist = test_then_block(ls); /* ELSEIF cond THEN block */
++ }
++ if (ls->t.token == TK_ELSE) {
++ luaK_concat(fs, &escapelist, luaK_jump(fs));
++ luaK_patchtohere(fs, flist);
++ luaX_next(ls); /* skip ELSE (after patch, for correct line info) */
++ block(ls); /* `else' part */
++ }
++ else
++ luaK_concat(fs, &escapelist, flist);
++ luaK_patchtohere(fs, escapelist);
++ check_match(ls, TK_END, TK_IF, line);
++}
++
++
++static void localfunc (LexState *ls) {
++ expdesc v, b;
++ FuncState *fs = ls->fs;
++ new_localvar(ls, str_checkname(ls), 0);
++ init_exp(&v, VLOCAL, fs->freereg);
++ luaK_reserveregs(fs, 1);
++ adjustlocalvars(ls, 1);
++ body(ls, &b, 0, ls->linenumber);
++ luaK_storevar(fs, &v, &b);
++ /* debug information will only see the variable after this point! */
++ getlocvar(fs, fs->nactvar - 1).startpc = fs->pc;
++}
++
++
++static void localstat (LexState *ls) {
++ /* stat -> LOCAL NAME {`,' NAME} [`=' explist1] */
++ int nvars = 0;
++ int nexps;
++ expdesc e;
++ do {
++ new_localvar(ls, str_checkname(ls), nvars++);
++ } while (testnext(ls, ','));
++ if (testnext(ls, '='))
++ nexps = explist1(ls, &e);
++ else {
++ e.k = VVOID;
++ nexps = 0;
++ }
++ adjust_assign(ls, nvars, nexps, &e);
++ adjustlocalvars(ls, nvars);
++}
++
++
++static int funcname (LexState *ls, expdesc *v) {
++ /* funcname -> NAME {field} [`:' NAME] */
++ int needself = 0;
++ singlevar(ls, v);
++ while (ls->t.token == '.')
++ field(ls, v);
++ if (ls->t.token == ':') {
++ needself = 1;
++ field(ls, v);
++ }
++ return needself;
++}
++
++
++static void funcstat (LexState *ls, int line) {
++ /* funcstat -> FUNCTION funcname body */
++ int needself;
++ expdesc v, b;
++ luaX_next(ls); /* skip FUNCTION */
++ needself = funcname(ls, &v);
++ body(ls, &b, needself, line);
++ luaK_storevar(ls->fs, &v, &b);
++ luaK_fixline(ls->fs, line); /* definition `happens' in the first line */
++}
++
++
++static void exprstat (LexState *ls) {
++ /* stat -> func | assignment */
++ FuncState *fs = ls->fs;
++ struct LHS_assign v;
++ primaryexp(ls, &v.v);
++ if (v.v.k == VCALL) /* stat -> func */
++ SETARG_C(getcode(fs, &v.v), 1); /* call statement uses no results */
++ else { /* stat -> assignment */
++ v.prev = NULL;
++ assignment(ls, &v, 1);
++ }
++}
++
++
++static void retstat (LexState *ls) {
++ /* stat -> RETURN explist */
++ FuncState *fs = ls->fs;
++ expdesc e;
++ int first, nret; /* registers with returned values */
++ luaX_next(ls); /* skip RETURN */
++ if (block_follow(ls->t.token) || ls->t.token == ';')
++ first = nret = 0; /* return no values */
++ else {
++ nret = explist1(ls, &e); /* optional return values */
++ if (hasmultret(e.k)) {
++ luaK_setmultret(fs, &e);
++ if (e.k == VCALL && nret == 1) { /* tail call? */
++ SET_OPCODE(getcode(fs,&e), OP_TAILCALL);
++ lua_assert(GETARG_A(getcode(fs,&e)) == fs->nactvar);
++ }
++ first = fs->nactvar;
++ nret = LUA_MULTRET; /* return all values */
++ }
++ else {
++ if (nret == 1) /* only one single value? */
++ first = luaK_exp2anyreg(fs, &e);
++ else {
++ luaK_exp2nextreg(fs, &e); /* values must go to the `stack' */
++ first = fs->nactvar; /* return all `active' values */
++ lua_assert(nret == fs->freereg - first);
++ }
++ }
++ }
++ luaK_ret(fs, first, nret);
++}
++
++
++static int statement (LexState *ls) {
++ int line = ls->linenumber; /* may be needed for error messages */
++ switch (ls->t.token) {
++ case TK_IF: { /* stat -> ifstat */
++ ifstat(ls, line);
++ return 0;
++ }
++ case TK_WHILE: { /* stat -> whilestat */
++ whilestat(ls, line);
++ return 0;
++ }
++ case TK_DO: { /* stat -> DO block END */
++ luaX_next(ls); /* skip DO */
++ block(ls);
++ check_match(ls, TK_END, TK_DO, line);
++ return 0;
++ }
++ case TK_FOR: { /* stat -> forstat */
++ forstat(ls, line);
++ return 0;
++ }
++ case TK_REPEAT: { /* stat -> repeatstat */
++ repeatstat(ls, line);
++ return 0;
++ }
++ case TK_FUNCTION: {
++ funcstat(ls, line); /* stat -> funcstat */
++ return 0;
++ }
++ case TK_LOCAL: { /* stat -> localstat */
++ luaX_next(ls); /* skip LOCAL */
++ if (testnext(ls, TK_FUNCTION)) /* local function? */
++ localfunc(ls);
++ else
++ localstat(ls);
++ return 0;
++ }
++ case TK_RETURN: { /* stat -> retstat */
++ retstat(ls);
++ return 1; /* must be last statement */
++ }
++ case TK_BREAK: { /* stat -> breakstat */
++ luaX_next(ls); /* skip BREAK */
++ breakstat(ls);
++ return 1; /* must be last statement */
++ }
++ default: {
++ exprstat(ls);
++ return 0; /* to avoid warnings */
++ }
++ }
++}
++
++
++static void chunk (LexState *ls) {
++ /* chunk -> { stat [`;'] } */
++ int islast = 0;
++ enterlevel(ls);
++ while (!islast && !block_follow(ls->t.token)) {
++ islast = statement(ls);
++ testnext(ls, ';');
++ lua_assert(ls->fs->f->maxstacksize >= ls->fs->freereg &&
++ ls->fs->freereg >= ls->fs->nactvar);
++ ls->fs->freereg = ls->fs->nactvar; /* free registers */
++ }
++ leavelevel(ls);
++}
++
++/* }====================================================================== */
+--- /dev/null
++++ b/extensions/LUA/lua/lparser.h
+@@ -0,0 +1,82 @@
++/*
++** $Id: lparser.h,v 1.57.1.1 2007/12/27 13:02:25 roberto Exp $
++** Lua Parser
++** See Copyright Notice in lua.h
++*/
++
++#ifndef lparser_h
++#define lparser_h
++
++#include "llimits.h"
++#include "lobject.h"
++#include "lzio.h"
++
++
++/*
++** Expression descriptor
++*/
++
++typedef enum {
++ VVOID, /* no value */
++ VNIL,
++ VTRUE,
++ VFALSE,
++ VK, /* info = index of constant in `k' */
++ VKNUM, /* nval = numerical value */
++ VLOCAL, /* info = local register */
++ VUPVAL, /* info = index of upvalue in `upvalues' */
++ VGLOBAL, /* info = index of table; aux = index of global name in `k' */
++ VINDEXED, /* info = table register; aux = index register (or `k') */
++ VJMP, /* info = instruction pc */
++ VRELOCABLE, /* info = instruction pc */
++ VNONRELOC, /* info = result register */
++ VCALL, /* info = instruction pc */
++ VVARARG /* info = instruction pc */
++} expkind;
++
++typedef struct expdesc {
++ expkind k;
++ union {
++ struct { int info, aux; } s;
++ lua_Number nval;
++ } u;
++ int t; /* patch list of `exit when true' */
++ int f; /* patch list of `exit when false' */
++} expdesc;
++
++
++typedef struct upvaldesc {
++ lu_byte k;
++ lu_byte info;
++} upvaldesc;
++
++
++struct BlockCnt; /* defined in lparser.c */
++
++
++/* state needed to generate code for a given function */
++typedef struct FuncState {
++ Proto *f; /* current function header */
++ Table *h; /* table to find (and reuse) elements in `k' */
++ struct FuncState *prev; /* enclosing function */
++ struct LexState *ls; /* lexical state */
++ struct lua_State *L; /* copy of the Lua state */
++ struct BlockCnt *bl; /* chain of current blocks */
++ int pc; /* next position to code (equivalent to `ncode') */
++ int lasttarget; /* `pc' of last `jump target' */
++ int jpc; /* list of pending jumps to `pc' */
++ int freereg; /* first free register */
++ int nk; /* number of elements in `k' */
++ int np; /* number of elements in `p' */
++ short nlocvars; /* number of elements in `locvars' */
++ lu_byte nactvar; /* number of active local variables */
++ upvaldesc upvalues[LUAI_MAXUPVALUES]; /* upvalues */
++ unsigned short actvar[LUAI_MAXVARS]; /* declared-variable stack */
++} FuncState;
++
++
++LUAI_FUNC Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff,
++ const char *name);
++
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/lstate.c
+@@ -0,0 +1,214 @@
++/*
++** $Id: lstate.c,v 2.36.1.2 2008/01/03 15:20:39 roberto Exp $
++** Global State
++** See Copyright Notice in lua.h
++*/
++
++
++#include <stddef.h>
++
++#define lstate_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "ldebug.h"
++#include "ldo.h"
++#include "lfunc.h"
++#include "lgc.h"
++#include "llex.h"
++#include "lmem.h"
++#include "lstate.h"
++#include "lstring.h"
++#include "ltable.h"
++#include "ltm.h"
++
++
++#define state_size(x) (sizeof(x) + LUAI_EXTRASPACE)
++#define fromstate(l) (cast(lu_byte *, (l)) - LUAI_EXTRASPACE)
++#define tostate(l) (cast(lua_State *, cast(lu_byte *, l) + LUAI_EXTRASPACE))
++
++
++/*
++** Main thread combines a thread state and the global state
++*/
++typedef struct LG {
++ lua_State l;
++ global_State g;
++} LG;
++
++
++
++static void stack_init (lua_State *L1, lua_State *L) {
++ /* initialize CallInfo array */
++ L1->base_ci = luaM_newvector(L, BASIC_CI_SIZE, CallInfo);
++ L1->ci = L1->base_ci;
++ L1->size_ci = BASIC_CI_SIZE;
++ L1->end_ci = L1->base_ci + L1->size_ci - 1;
++ /* initialize stack array */
++ L1->stack = luaM_newvector(L, BASIC_STACK_SIZE + EXTRA_STACK, TValue);
++ L1->stacksize = BASIC_STACK_SIZE + EXTRA_STACK;
++ L1->top = L1->stack;
++ L1->stack_last = L1->stack+(L1->stacksize - EXTRA_STACK)-1;
++ /* initialize first ci */
++ L1->ci->func = L1->top;
++ setnilvalue(L1->top++); /* `function' entry for this `ci' */
++ L1->base = L1->ci->base = L1->top;
++ L1->ci->top = L1->top + LUA_MINSTACK;
++}
++
++
++static void freestack (lua_State *L, lua_State *L1) {
++ luaM_freearray(L, L1->base_ci, L1->size_ci, CallInfo);
++ luaM_freearray(L, L1->stack, L1->stacksize, TValue);
++}
++
++
++/*
++** open parts that may cause memory-allocation errors
++*/
++static void f_luaopen (lua_State *L, void *ud) {
++ global_State *g = G(L);
++ UNUSED(ud);
++ stack_init(L, L); /* init stack */
++ sethvalue(L, gt(L), luaH_new(L, 0, 2)); /* table of globals */
++ sethvalue(L, registry(L), luaH_new(L, 0, 2)); /* registry */
++ luaS_resize(L, MINSTRTABSIZE); /* initial size of string table */
++ luaT_init(L);
++ luaX_init(L);
++ luaS_fix(luaS_newliteral(L, MEMERRMSG));
++ g->GCthreshold = 4*g->totalbytes;
++}
++
++
++static void preinit_state (lua_State *L, global_State *g) {
++ G(L) = g;
++ L->stack = NULL;
++ L->stacksize = 0;
++ L->errorJmp = NULL;
++ L->hook = NULL;
++ L->hookmask = 0;
++ L->basehookcount = 0;
++ L->allowhook = 1;
++ resethookcount(L);
++ L->openupval = NULL;
++ L->size_ci = 0;
++ L->nCcalls = L->baseCcalls = 0;
++ L->status = 0;
++ L->base_ci = L->ci = NULL;
++ L->savedpc = NULL;
++ L->errfunc = 0;
++ setnilvalue(gt(L));
++}
++
++
++static void close_state (lua_State *L) {
++ global_State *g = G(L);
++ luaF_close(L, L->stack); /* close all upvalues for this thread */
++ luaC_freeall(L); /* collect all objects */
++ lua_assert(g->rootgc == obj2gco(L));
++ lua_assert(g->strt.nuse == 0);
++ luaM_freearray(L, G(L)->strt.hash, G(L)->strt.size, TString *);
++ luaZ_freebuffer(L, &g->buff);
++ freestack(L, L);
++ lua_assert(g->totalbytes == sizeof(LG));
++ (*g->frealloc)(g->ud, fromstate(L), state_size(LG), 0);
++}
++
++
++lua_State *luaE_newthread (lua_State *L) {
++ lua_State *L1 = tostate(luaM_malloc(L, state_size(lua_State)));
++ luaC_link(L, obj2gco(L1), LUA_TTHREAD);
++ preinit_state(L1, G(L));
++ stack_init(L1, L); /* init stack */
++ setobj2n(L, gt(L1), gt(L)); /* share table of globals */
++ L1->hookmask = L->hookmask;
++ L1->basehookcount = L->basehookcount;
++ L1->hook = L->hook;
++ resethookcount(L1);
++ lua_assert(iswhite(obj2gco(L1)));
++ return L1;
++}
++
++
++void luaE_freethread (lua_State *L, lua_State *L1) {
++ luaF_close(L1, L1->stack); /* close all upvalues for this thread */
++ lua_assert(L1->openupval == NULL);
++ luai_userstatefree(L1);
++ freestack(L, L1);
++ luaM_freemem(L, fromstate(L1), state_size(lua_State));
++}
++
++
++LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) {
++ int i;
++ lua_State *L;
++ global_State *g;
++ void *l = (*f)(ud, NULL, 0, state_size(LG));
++ if (l == NULL) return NULL;
++ L = tostate(l);
++ g = &((LG *)L)->g;
++ L->next = NULL;
++ L->tt = LUA_TTHREAD;
++ g->currentwhite = bit2mask(WHITE0BIT, FIXEDBIT);
++ L->marked = luaC_white(g);
++ set2bits(L->marked, FIXEDBIT, SFIXEDBIT);
++ preinit_state(L, g);
++ g->frealloc = f;
++ g->ud = ud;
++ g->mainthread = L;
++ g->uvhead.u.l.prev = &g->uvhead;
++ g->uvhead.u.l.next = &g->uvhead;
++ g->GCthreshold = 0; /* mark it as unfinished state */
++ g->strt.size = 0;
++ g->strt.nuse = 0;
++ g->strt.hash = NULL;
++ setnilvalue(registry(L));
++ luaZ_initbuffer(L, &g->buff);
++ g->panic = NULL;
++ g->gcstate = GCSpause;
++ g->rootgc = obj2gco(L);
++ g->sweepstrgc = 0;
++ g->sweepgc = &g->rootgc;
++ g->gray = NULL;
++ g->grayagain = NULL;
++ g->weak = NULL;
++ g->tmudata = NULL;
++ g->totalbytes = sizeof(LG);
++ g->gcpause = LUAI_GCPAUSE;
++ g->gcstepmul = LUAI_GCMUL;
++ g->gcdept = 0;
++ for (i=0; i<NUM_TAGS; i++) g->mt[i] = NULL;
++ if (luaD_rawrunprotected(L, f_luaopen, NULL) != 0) {
++ /* memory allocation error: free partial state */
++ close_state(L);
++ L = NULL;
++ }
++ else
++ luai_userstateopen(L);
++ return L;
++}
++
++
++static void callallgcTM (lua_State *L, void *ud) {
++ UNUSED(ud);
++ luaC_callGCTM(L); /* call GC metamethods for all udata */
++}
++
++
++LUA_API void lua_close (lua_State *L) {
++ L = G(L)->mainthread; /* only the main thread can be closed */
++ lua_lock(L);
++ luaF_close(L, L->stack); /* close all upvalues for this thread */
++ luaC_separateudata(L, 1); /* separate udata that have GC metamethods */
++ L->errfunc = 0; /* no error function during GC metamethods */
++ do { /* repeat until no more errors */
++ L->ci = L->base_ci;
++ L->base = L->top = L->ci->base;
++ L->nCcalls = L->baseCcalls = 0;
++ } while (luaD_rawrunprotected(L, callallgcTM, NULL) != 0);
++ lua_assert(G(L)->tmudata == NULL);
++ luai_userstateclose(L);
++ close_state(L);
++}
++
+--- /dev/null
++++ b/extensions/LUA/lua/lstate.h
+@@ -0,0 +1,169 @@
++/*
++** $Id: lstate.h,v 2.24.1.2 2008/01/03 15:20:39 roberto Exp $
++** Global State
++** See Copyright Notice in lua.h
++*/
++
++#ifndef lstate_h
++#define lstate_h
++
++#include "lua.h"
++
++#include "lobject.h"
++#include "ltm.h"
++#include "lzio.h"
++
++
++
++struct lua_longjmp; /* defined in ldo.c */
++
++
++/* table of globals */
++#define gt(L) (&L->l_gt)
++
++/* registry */
++#define registry(L) (&G(L)->l_registry)
++
++
++/* extra stack space to handle TM calls and some other extras */
++#define EXTRA_STACK 5
++
++
++#define BASIC_CI_SIZE 8
++
++#define BASIC_STACK_SIZE (2*LUA_MINSTACK)
++
++
++
++typedef struct stringtable {
++ GCObject **hash;
++ lu_int32 nuse; /* number of elements */
++ int size;
++} stringtable;
++
++
++/*
++** informations about a call
++*/
++typedef struct CallInfo {
++ StkId base; /* base for this function */
++ StkId func; /* function index in the stack */
++ StkId top; /* top for this function */
++ const Instruction *savedpc;
++ int nresults; /* expected number of results from this function */
++ int tailcalls; /* number of tail calls lost under this entry */
++} CallInfo;
++
++
++
++#define curr_func(L) (clvalue(L->ci->func))
++#define ci_func(ci) (clvalue((ci)->func))
++#define f_isLua(ci) (!ci_func(ci)->c.isC)
++#define isLua(ci) (ttisfunction((ci)->func) && f_isLua(ci))
++
++
++/*
++** `global state', shared by all threads of this state
++*/
++typedef struct global_State {
++ stringtable strt; /* hash table for strings */
++ lua_Alloc frealloc; /* function to reallocate memory */
++ void *ud; /* auxiliary data to `frealloc' */
++ lu_byte currentwhite;
++ lu_byte gcstate; /* state of garbage collector */
++ int sweepstrgc; /* position of sweep in `strt' */
++ GCObject *rootgc; /* list of all collectable objects */
++ GCObject **sweepgc; /* position of sweep in `rootgc' */
++ GCObject *gray; /* list of gray objects */
++ GCObject *grayagain; /* list of objects to be traversed atomically */
++ GCObject *weak; /* list of weak tables (to be cleared) */
++ GCObject *tmudata; /* last element of list of userdata to be GC */
++ Mbuffer buff; /* temporary buffer for string concatentation */
++ lu_mem GCthreshold;
++ lu_mem totalbytes; /* number of bytes currently allocated */
++ lu_mem estimate; /* an estimate of number of bytes actually in use */
++ lu_mem gcdept; /* how much GC is `behind schedule' */
++ int gcpause; /* size of pause between successive GCs */
++ int gcstepmul; /* GC `granularity' */
++ lua_CFunction panic; /* to be called in unprotected errors */
++ TValue l_registry;
++ struct lua_State *mainthread;
++ UpVal uvhead; /* head of double-linked list of all open upvalues */
++ struct Table *mt[NUM_TAGS]; /* metatables for basic types */
++ TString *tmname[TM_N]; /* array with tag-method names */
++} global_State;
++
++
++/*
++** `per thread' state
++*/
++struct lua_State {
++ CommonHeader;
++ lu_byte status;
++ StkId top; /* first free slot in the stack */
++ StkId base; /* base of current function */
++ global_State *l_G;
++ CallInfo *ci; /* call info for current function */
++ const Instruction *savedpc; /* `savedpc' of current function */
++ StkId stack_last; /* last free slot in the stack */
++ StkId stack; /* stack base */
++ CallInfo *end_ci; /* points after end of ci array*/
++ CallInfo *base_ci; /* array of CallInfo's */
++ int stacksize;
++ int size_ci; /* size of array `base_ci' */
++ unsigned short nCcalls; /* number of nested C calls */
++ unsigned short baseCcalls; /* nested C calls when resuming coroutine */
++ lu_byte hookmask;
++ lu_byte allowhook;
++ int basehookcount;
++ int hookcount;
++ lua_Hook hook;
++ TValue l_gt; /* table of globals */
++ TValue env; /* temporary place for environments */
++ GCObject *openupval; /* list of open upvalues in this stack */
++ GCObject *gclist;
++ struct lua_longjmp *errorJmp; /* current error recover point */
++ ptrdiff_t errfunc; /* current error handling function (stack index) */
++};
++
++
++#define G(L) (L->l_G)
++
++
++/*
++** Union of all collectable objects
++*/
++union GCObject {
++ GCheader gch;
++ union TString ts;
++ union Udata u;
++ union Closure cl;
++ struct Table h;
++ struct Proto p;
++ struct UpVal uv;
++ struct lua_State th; /* thread */
++};
++
++
++/* macros to convert a GCObject into a specific value */
++#define rawgco2ts(o) check_exp((o)->gch.tt == LUA_TSTRING, &((o)->ts))
++#define gco2ts(o) (&rawgco2ts(o)->tsv)
++#define rawgco2u(o) check_exp((o)->gch.tt == LUA_TUSERDATA, &((o)->u))
++#define gco2u(o) (&rawgco2u(o)->uv)
++#define gco2cl(o) check_exp((o)->gch.tt == LUA_TFUNCTION, &((o)->cl))
++#define gco2h(o) check_exp((o)->gch.tt == LUA_TTABLE, &((o)->h))
++#define gco2p(o) check_exp((o)->gch.tt == LUA_TPROTO, &((o)->p))
++#define gco2uv(o) check_exp((o)->gch.tt == LUA_TUPVAL, &((o)->uv))
++#define ngcotouv(o) \
++ check_exp((o) == NULL || (o)->gch.tt == LUA_TUPVAL, &((o)->uv))
++#define gco2th(o) check_exp((o)->gch.tt == LUA_TTHREAD, &((o)->th))
++
++/* macro to convert any Lua object into a GCObject */
++#define obj2gco(v) (cast(GCObject *, (v)))
++
++
++LUAI_FUNC lua_State *luaE_newthread (lua_State *L);
++LUAI_FUNC void luaE_freethread (lua_State *L, lua_State *L1);
++
++#endif
++
+--- /dev/null
++++ b/extensions/LUA/lua/lstring.c
+@@ -0,0 +1,110 @@
++/*
++** $Id: lstring.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $
++** String table (keeps all strings handled by Lua)
++** See Copyright Notice in lua.h
++*/
++
++#include <string.h>
++
++#define lstring_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "lmem.h"
++#include "lobject.h"
++#include "lstate.h"
++#include "lstring.h"
++
++
++
++void luaS_resize (lua_State *L, int newsize) {
++ GCObject **newhash;
++ stringtable *tb;
++ int i;
++ if (G(L)->gcstate == GCSsweepstring)
++ return; /* cannot resize during GC traverse */
++ newhash = luaM_newvector(L, newsize, GCObject *);
++ tb = &G(L)->strt;
++ for (i=0; i<newsize; i++) newhash[i] = NULL;
++ /* rehash */
++ for (i=0; i<tb->size; i++) {
++ GCObject *p = tb->hash[i];
++ while (p) { /* for each node in the list */
++ GCObject *next = p->gch.next; /* save next */
++ unsigned int h = gco2ts(p)->hash;
++ int h1 = lmod(h, newsize); /* new position */
++ lua_assert(cast_int(h%newsize) == lmod(h, newsize));
++ p->gch.next = newhash[h1]; /* chain it */
++ newhash[h1] = p;
++ p = next;
++ }
++ }
++ luaM_freearray(L, tb->hash, tb->size, TString *);
++ tb->size = newsize;
++ tb->hash = newhash;
++}
++
++
++static TString *newlstr (lua_State *L, const char *str, size_t l,
++ unsigned int h) {
++ TString *ts;
++ stringtable *tb;
++ if (l+1 > (MAX_SIZET - sizeof(TString))/sizeof(char))
++ luaM_toobig(L);
++ ts = cast(TString *, luaM_malloc(L, (l+1)*sizeof(char)+sizeof(TString)));
++ ts->tsv.len = l;
++ ts->tsv.hash = h;
++ ts->tsv.marked = luaC_white(G(L));
++ ts->tsv.tt = LUA_TSTRING;
++ ts->tsv.reserved = 0;
++ memcpy(ts+1, str, l*sizeof(char));
++ ((char *)(ts+1))[l] = '\0'; /* ending 0 */
++ tb = &G(L)->strt;
++ h = lmod(h, tb->size);
++ ts->tsv.next = tb->hash[h]; /* chain new entry */
++ tb->hash[h] = obj2gco(ts);
++ tb->nuse++;
++ if (tb->nuse > cast(lu_int32, tb->size) && tb->size <= MAX_INT/2)
++ luaS_resize(L, tb->size*2); /* too crowded */
++ return ts;
++}
++
++
++TString *luaS_newlstr (lua_State *L, const char *str, size_t l) {
++ GCObject *o;
++ unsigned int h = cast(unsigned int, l); /* seed */
++ size_t step = (l>>5)+1; /* if string is too long, don't hash all its chars */
++ size_t l1;
++ for (l1=l; l1>=step; l1-=step) /* compute hash */
++ h = h ^ ((h<<5)+(h>>2)+cast(unsigned char, str[l1-1]));
++ for (o = G(L)->strt.hash[lmod(h, G(L)->strt.size)];
++ o != NULL;
++ o = o->gch.next) {
++ TString *ts = rawgco2ts(o);
++ if (ts->tsv.len == l && (memcmp(str, getstr(ts), l) == 0)) {
++ /* string may be dead */
++ if (isdead(G(L), o)) changewhite(o);
++ return ts;
++ }
++ }
++ return newlstr(L, str, l, h); /* not found */
++}
++
++
++Udata *luaS_newudata (lua_State *L, size_t s, Table *e) {
++ Udata *u;
++ if (s > MAX_SIZET - sizeof(Udata))
++ luaM_toobig(L);
++ u = cast(Udata *, luaM_malloc(L, s + sizeof(Udata)));
++ u->uv.marked = luaC_white(G(L)); /* is not finalized */
++ u->uv.tt = LUA_TUSERDATA;
++ u->uv.len = s;
++ u->uv.metatable = NULL;
++ u->uv.env = e;
++ /* chain it on udata list (after main thread) */
++ u->uv.next = G(L)->mainthread->next;
++ G(L)->mainthread->next = obj2gco(u);
++ return u;
++}
++
+--- /dev/null
++++ b/extensions/LUA/lua/lstring.h
+@@ -0,0 +1,31 @@
++/*
++** $Id: lstring.h,v 1.43.1.1 2007/12/27 13:02:25 roberto Exp $
++** String table (keep all strings handled by Lua)
++** See Copyright Notice in lua.h
++*/
++
++#ifndef lstring_h
++#define lstring_h
++
++
++#include "lgc.h"
++#include "lobject.h"
++#include "lstate.h"
++
++
++#define sizestring(s) (sizeof(union TString)+((s)->len+1)*sizeof(char))
++
++#define sizeudata(u) (sizeof(union Udata)+(u)->len)
++
++#define luaS_new(L, s) (luaS_newlstr(L, s, strlen(s)))
++#define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \
++ (sizeof(s)/sizeof(char))-1))
++
++#define luaS_fix(s) l_setbit((s)->tsv.marked, FIXEDBIT)
++
++LUAI_FUNC void luaS_resize (lua_State *L, int newsize);
++LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, Table *e);
++LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l);
++
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/lstrlib.c
+@@ -0,0 +1,883 @@
++/*
++** $Id: lstrlib.c,v 1.132.1.4 2008/07/11 17:27:21 roberto Exp $
++** Standard library for string operations and pattern-matching
++** See Copyright Notice in lua.h
++*/
++
++
++#include <ctype.h>
++#include <stddef.h>
++#include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
++
++#define lstrlib_c
++#define LUA_LIB
++
++#include "lua.h"
++
++#include "lauxlib.h"
++#include "lualib.h"
++
++
++/* macro to `unsign' a character */
++#define uchar(c) ((unsigned char)(c))
++
++
++
++static int str_len (lua_State *L) {
++ size_t l;
++ luaL_checklstring(L, 1, &l);
++ lua_pushinteger(L, l);
++ return 1;
++}
++
++
++static ptrdiff_t posrelat (ptrdiff_t pos, size_t len) {
++ /* relative string position: negative means back from end */
++ if (pos < 0) pos += (ptrdiff_t)len + 1;
++ return (pos >= 0) ? pos : 0;
++}
++
++
++static int str_sub (lua_State *L) {
++ size_t l;
++ const char *s = luaL_checklstring(L, 1, &l);
++ ptrdiff_t start = posrelat(luaL_checkinteger(L, 2), l);
++ ptrdiff_t end = posrelat(luaL_optinteger(L, 3, -1), l);
++ if (start < 1) start = 1;
++ if (end > (ptrdiff_t)l) end = (ptrdiff_t)l;
++ if (start <= end)
++ lua_pushlstring(L, s+start-1, end-start+1);
++ else lua_pushliteral(L, "");
++ return 1;
++}
++
++
++static int str_reverse (lua_State *L) {
++ size_t l;
++ const char *s = luaL_checklstring(L, 1, &l);
++ luaL_Buffer *b = (luaL_Buffer *)kmalloc(sizeof(luaL_Buffer) + BUFSIZ, GFP_ATOMIC);
++ if(!b) luaL_error(L, "str_reverse: cannot allocate memory");
++ luaL_buffinit(L, b);
++ while (l--) luaL_addchar(b, s[l]);
++ luaL_pushresult(b);
++ kfree(b);
++ return 1;
++}
++
++
++static int str_lower (lua_State *L) {
++ size_t l;
++ size_t i;
++ const char *s = luaL_checklstring(L, 1, &l);
++ luaL_Buffer *b = (luaL_Buffer *)kmalloc(sizeof(luaL_Buffer) + BUFSIZ, GFP_ATOMIC);
++ if(!b) luaL_error(L, "str_lower: cannot allocate memory");
++ luaL_buffinit(L, b);
++ for (i=0; i<l; i++)
++ luaL_addchar(b, tolower(uchar(s[i])));
++ luaL_pushresult(b);
++ kfree(b);
++ return 1;
++}
++
++
++static int str_upper (lua_State *L) {
++ size_t l;
++ size_t i;
++ const char *s = luaL_checklstring(L, 1, &l);
++ luaL_Buffer *b = (luaL_Buffer *)kmalloc(sizeof(luaL_Buffer) + BUFSIZ, GFP_ATOMIC);
++ if(!b) luaL_error(L, "str_upper: cannot allocate memory");
++ luaL_buffinit(L, b);
++ for (i=0; i<l; i++)
++ luaL_addchar(b, toupper(uchar(s[i])));
++ luaL_pushresult(b);
++ kfree(b);
++ return 1;
++}
++
++static int str_rep (lua_State *L) {
++ size_t l;
++ const char *s = luaL_checklstring(L, 1, &l);
++ int n = luaL_checkint(L, 2);
++ luaL_Buffer *b = (luaL_Buffer *)kmalloc(sizeof(luaL_Buffer) + BUFSIZ, GFP_ATOMIC);
++ if(!b) luaL_error(L, "str_rep: cannot allocate memory");
++ luaL_buffinit(L, b);
++ while (n-- > 0)
++ luaL_addlstring(b, s, l);
++ luaL_pushresult(b);
++ kfree(b);
++ return 1;
++}
++
++
++static int str_byte (lua_State *L) {
++ size_t l;
++ const char *s = luaL_checklstring(L, 1, &l);
++ ptrdiff_t posi = posrelat(luaL_optinteger(L, 2, 1), l);
++ ptrdiff_t pose = posrelat(luaL_optinteger(L, 3, posi), l);
++ int n, i;
++ if (posi <= 0) posi = 1;
++ if ((size_t)pose > l) pose = l;
++ if (posi > pose) return 0; /* empty interval; return no values */
++ n = (int)(pose - posi + 1);
++ if (posi + n <= pose) /* overflow? */
++ luaL_error(L, "string slice too long");
++ luaL_checkstack(L, n, "string slice too long");
++ for (i=0; i<n; i++)
++ lua_pushinteger(L, uchar(s[posi+i-1]));
++ return n;
++}
++
++
++static int str_char (lua_State *L) {
++ int n = lua_gettop(L); /* number of arguments */
++ int i;
++ luaL_Buffer *b = (luaL_Buffer *)kmalloc(sizeof(luaL_Buffer) + BUFSIZ, GFP_ATOMIC);
++ if(!b) luaL_error(L, "str_char: cannot allocate memory");
++ luaL_buffinit(L, b);
++ for (i=1; i<=n; i++) {
++ int c = luaL_checkint(L, i);
++ luaL_argcheck(L, uchar(c) == c, i, "invalid value");
++ luaL_addchar(b, uchar(c));
++ }
++ luaL_pushresult(b);
++ kfree(b);
++ return 1;
++}
++
++
++static int writer (lua_State *L, const void* b, size_t size, void* B) {
++ (void)L;
++ luaL_addlstring((luaL_Buffer*) B, (const char *)b, size);
++ return 0;
++}
++
++
++static int str_dump (lua_State *L) {
++ luaL_Buffer *b = (luaL_Buffer *)kmalloc(sizeof(luaL_Buffer) + BUFSIZ, GFP_ATOMIC);
++ if(!b) luaL_error(L, "str_dump: cannot allocate memory");
++ luaL_checktype(L, 1, LUA_TFUNCTION);
++ lua_settop(L, 1);
++ luaL_buffinit(L,b);
++ if (lua_dump(L, writer, b) != 0){
++ kfree(b);
++ luaL_error(L, "unable to dump given function");
++ }
++
++ luaL_pushresult(b);
++ kfree(b);
++ return 1;
++}
++
++
++
++/*
++** {======================================================
++** PATTERN MATCHING
++** =======================================================
++*/
++
++
++#define CAP_UNFINISHED (-1)
++#define CAP_POSITION (-2)
++
++typedef struct MatchState {
++ const char *src_init; /* init of source string */
++ const char *src_end; /* end (`\0') of source string */
++ lua_State *L;
++ int level; /* total number of captures (finished or unfinished) */
++ struct {
++ const char *init;
++ ptrdiff_t len;
++ } capture[LUA_MAXCAPTURES];
++} MatchState;
++
++
++#define L_ESC '%'
++#define SPECIALS "^$*+?.([%-"
++
++
++static int check_capture (MatchState *ms, int l) {
++ l -= '1';
++ if (l < 0 || l >= ms->level || ms->capture[l].len == CAP_UNFINISHED)
++ return luaL_error(ms->L, "invalid capture index");
++ return l;
++}
++
++
++static int capture_to_close (MatchState *ms) {
++ int level = ms->level;
++ for (level--; level>=0; level--)
++ if (ms->capture[level].len == CAP_UNFINISHED) return level;
++ return luaL_error(ms->L, "invalid pattern capture");
++}
++
++
++static const char *classend (MatchState *ms, const char *p) {
++ switch (*p++) {
++ case L_ESC: {
++ if (*p == '\0')
++ luaL_error(ms->L, "malformed pattern (ends with " LUA_QL("%%") ")");
++ return p+1;
++ }
++ case '[': {
++ if (*p == '^') p++;
++ do { /* look for a `]' */
++ if (*p == '\0')
++ luaL_error(ms->L, "malformed pattern (missing " LUA_QL("]") ")");
++ if (*(p++) == L_ESC && *p != '\0')
++ p++; /* skip escapes (e.g. `%]') */
++ } while (*p != ']');
++ return p+1;
++ }
++ default: {
++ return p;
++ }
++ }
++}
++
++
++static int match_class (int c, int cl) {
++ int res;
++ switch (tolower(cl)) {
++ case 'a' : res = isalpha(c); break;
++ case 'c' : res = iscntrl(c); break;
++ case 'd' : res = isdigit(c); break;
++ case 'l' : res = islower(c); break;
++ case 'p' : res = ispunct(c); break;
++ case 's' : res = isspace(c); break;
++ case 'u' : res = isupper(c); break;
++ case 'w' : res = isalnum(c); break;
++ case 'x' : res = isxdigit(c); break;
++ case 'z' : res = (c == 0); break;
++ default: return (cl == c);
++ }
++ return (islower(cl) ? res : !res);
++}
++
++
++static int matchbracketclass (int c, const char *p, const char *ec) {
++ int sig = 1;
++ if (*(p+1) == '^') {
++ sig = 0;
++ p++; /* skip the `^' */
++ }
++ while (++p < ec) {
++ if (*p == L_ESC) {
++ p++;
++ if (match_class(c, uchar(*p)))
++ return sig;
++ }
++ else if ((*(p+1) == '-') && (p+2 < ec)) {
++ p+=2;
++ if (uchar(*(p-2)) <= c && c <= uchar(*p))
++ return sig;
++ }
++ else if (uchar(*p) == c) return sig;
++ }
++ return !sig;
++}
++
++
++static int singlematch (int c, const char *p, const char *ep) {
++ switch (*p) {
++ case '.': return 1; /* matches any char */
++ case L_ESC: return match_class(c, uchar(*(p+1)));
++ case '[': return matchbracketclass(c, p, ep-1);
++ default: return (uchar(*p) == c);
++ }
++}
++
++
++static const char *match (MatchState *ms, const char *s, const char *p);
++
++
++static const char *matchbalance (MatchState *ms, const char *s,
++ const char *p) {
++ if (*p == 0 || *(p+1) == 0)
++ luaL_error(ms->L, "unbalanced pattern");
++ if (*s != *p) return NULL;
++ else {
++ int b = *p;
++ int e = *(p+1);
++ int cont = 1;
++ while (++s < ms->src_end) {
++ if (*s == e) {
++ if (--cont == 0) return s+1;
++ }
++ else if (*s == b) cont++;
++ }
++ }
++ return NULL; /* string ends out of balance */
++}
++
++
++static const char *max_expand (MatchState *ms, const char *s,
++ const char *p, const char *ep) {
++ ptrdiff_t i = 0; /* counts maximum expand for item */
++ while ((s+i)<ms->src_end && singlematch(uchar(*(s+i)), p, ep))
++ i++;
++ /* keeps trying to match with the maximum repetitions */
++ while (i>=0) {
++ const char *res = match(ms, (s+i), ep+1);
++ if (res) return res;
++ i--; /* else didn't match; reduce 1 repetition to try again */
++ }
++ return NULL;
++}
++
++
++static const char *min_expand (MatchState *ms, const char *s,
++ const char *p, const char *ep) {
++ for (;;) {
++ const char *res = match(ms, s, ep+1);
++ if (res != NULL)
++ return res;
++ else if (s<ms->src_end && singlematch(uchar(*s), p, ep))
++ s++; /* try with one more repetition */
++ else return NULL;
++ }
++}
++
++
++static const char *start_capture (MatchState *ms, const char *s,
++ const char *p, int what) {
++ const char *res;
++ int level = ms->level;
++ if (level >= LUA_MAXCAPTURES) luaL_error(ms->L, "too many captures");
++ ms->capture[level].init = s;
++ ms->capture[level].len = what;
++ ms->level = level+1;
++ if ((res=match(ms, s, p)) == NULL) /* match failed? */
++ ms->level--; /* undo capture */
++ return res;
++}
++
++
++static const char *end_capture (MatchState *ms, const char *s,
++ const char *p) {
++ int l = capture_to_close(ms);
++ const char *res;
++ ms->capture[l].len = s - ms->capture[l].init; /* close capture */
++ if ((res = match(ms, s, p)) == NULL) /* match failed? */
++ ms->capture[l].len = CAP_UNFINISHED; /* undo capture */
++ return res;
++}
++
++
++static const char *match_capture (MatchState *ms, const char *s, int l) {
++ size_t len;
++ l = check_capture(ms, l);
++ len = ms->capture[l].len;
++ if ((size_t)(ms->src_end-s) >= len &&
++ memcmp(ms->capture[l].init, s, len) == 0)
++ return s+len;
++ else return NULL;
++}
++
++
++static const char *match (MatchState *ms, const char *s, const char *p) {
++ init: /* using goto's to optimize tail recursion */
++ switch (*p) {
++ case '(': { /* start capture */
++ if (*(p+1) == ')') /* position capture? */
++ return start_capture(ms, s, p+2, CAP_POSITION);
++ else
++ return start_capture(ms, s, p+1, CAP_UNFINISHED);
++ }
++ case ')': { /* end capture */
++ return end_capture(ms, s, p+1);
++ }
++ case L_ESC: {
++ switch (*(p+1)) {
++ case 'b': { /* balanced string? */
++ s = matchbalance(ms, s, p+2);
++ if (s == NULL) return NULL;
++ p+=4; goto init; /* else return match(ms, s, p+4); */
++ }
++ case 'f': { /* frontier? */
++ const char *ep; char previous;
++ p += 2;
++ if (*p != '[')
++ luaL_error(ms->L, "missing " LUA_QL("[") " after "
++ LUA_QL("%%f") " in pattern");
++ ep = classend(ms, p); /* points to what is next */
++ previous = (s == ms->src_init) ? '\0' : *(s-1);
++ if (matchbracketclass(uchar(previous), p, ep-1) ||
++ !matchbracketclass(uchar(*s), p, ep-1)) return NULL;
++ p=ep; goto init; /* else return match(ms, s, ep); */
++ }
++ default: {
++ if (isdigit(uchar(*(p+1)))) { /* capture results (%0-%9)? */
++ s = match_capture(ms, s, uchar(*(p+1)));
++ if (s == NULL) return NULL;
++ p+=2; goto init; /* else return match(ms, s, p+2) */
++ }
++ goto dflt; /* case default */
++ }
++ }
++ }
++ case '\0': { /* end of pattern */
++ return s; /* match succeeded */
++ }
++ case '$': {
++ if (*(p+1) == '\0') /* is the `$' the last char in pattern? */
++ return (s == ms->src_end) ? s : NULL; /* check end of string */
++ else goto dflt;
++ }
++ default: dflt: { /* it is a pattern item */
++ const char *ep = classend(ms, p); /* points to what is next */
++ int m = s<ms->src_end && singlematch(uchar(*s), p, ep);
++ switch (*ep) {
++ case '?': { /* optional */
++ const char *res;
++ if (m && ((res=match(ms, s+1, ep+1)) != NULL))
++ return res;
++ p=ep+1; goto init; /* else return match(ms, s, ep+1); */
++ }
++ case '*': { /* 0 or more repetitions */
++ return max_expand(ms, s, p, ep);
++ }
++ case '+': { /* 1 or more repetitions */
++ return (m ? max_expand(ms, s+1, p, ep) : NULL);
++ }
++ case '-': { /* 0 or more repetitions (minimum) */
++ return min_expand(ms, s, p, ep);
++ }
++ default: {
++ if (!m) return NULL;
++ s++; p=ep; goto init; /* else return match(ms, s+1, ep); */
++ }
++ }
++ }
++ }
++}
++
++
++
++static const char *lmemfind (const char *s1, size_t l1,
++ const char *s2, size_t l2) {
++ if (l2 == 0) return s1; /* empty strings are everywhere */
++ else if (l2 > l1) return NULL; /* avoids a negative `l1' */
++ else {
++ const char *init; /* to search for a `*s2' inside `s1' */
++ l2--; /* 1st char will be checked by `memchr' */
++ l1 = l1-l2; /* `s2' cannot be found after that */
++ while (l1 > 0 && (init = (const char *)memchr(s1, *s2, l1)) != NULL) {
++ init++; /* 1st char is already checked */
++ if (memcmp(init, s2+1, l2) == 0)
++ return init-1;
++ else { /* correct `l1' and `s1' to try again */
++ l1 -= init-s1;
++ s1 = init;
++ }
++ }
++ return NULL; /* not found */
++ }
++}
++
++
++static void push_onecapture (MatchState *ms, int i, const char *s,
++ const char *e) {
++ if (i >= ms->level) {
++ if (i == 0) /* ms->level == 0, too */
++ lua_pushlstring(ms->L, s, e - s); /* add whole match */
++ else
++ luaL_error(ms->L, "invalid capture index");
++ }
++ else {
++ ptrdiff_t l = ms->capture[i].len;
++ if (l == CAP_UNFINISHED) luaL_error(ms->L, "unfinished capture");
++ if (l == CAP_POSITION)
++ lua_pushinteger(ms->L, ms->capture[i].init - ms->src_init + 1);
++ else
++ lua_pushlstring(ms->L, ms->capture[i].init, l);
++ }
++}
++
++
++static int push_captures (MatchState *ms, const char *s, const char *e) {
++ int i;
++ int nlevels = (ms->level == 0 && s) ? 1 : ms->level;
++ luaL_checkstack(ms->L, nlevels, "too many captures");
++ for (i = 0; i < nlevels; i++)
++ push_onecapture(ms, i, s, e);
++ return nlevels; /* number of strings pushed */
++}
++
++
++static int str_find_aux (lua_State *L, int find) {
++ size_t l1, l2;
++ const char *s = luaL_checklstring(L, 1, &l1);
++ const char *p = luaL_checklstring(L, 2, &l2);
++ ptrdiff_t init = posrelat(luaL_optinteger(L, 3, 1), l1) - 1;
++ if (init < 0) init = 0;
++ else if ((size_t)(init) > l1) init = (ptrdiff_t)l1;
++ if (find && (lua_toboolean(L, 4) || /* explicit request? */
++ strpbrk(p, SPECIALS) == NULL)) { /* or no special characters? */
++ /* do a plain search */
++ const char *s2 = lmemfind(s+init, l1-init, p, l2);
++ if (s2) {
++ lua_pushinteger(L, s2-s+1);
++ lua_pushinteger(L, s2-s+l2);
++ return 2;
++ }
++ }
++ else {
++ MatchState ms;
++ int anchor = (*p == '^') ? (p++, 1) : 0;
++ const char *s1=s+init;
++ ms.L = L;
++ ms.src_init = s;
++ ms.src_end = s+l1;
++ do {
++ const char *res;
++ ms.level = 0;
++ if ((res=match(&ms, s1, p)) != NULL) {
++ if (find) {
++ lua_pushinteger(L, s1-s+1); /* start */
++ lua_pushinteger(L, res-s); /* end */
++ return push_captures(&ms, NULL, 0) + 2;
++ }
++ else
++ return push_captures(&ms, s1, res);
++ }
++ } while (s1++ < ms.src_end && !anchor);
++ }
++ lua_pushnil(L); /* not found */
++ return 1;
++}
++
++
++static int str_find (lua_State *L) {
++ return str_find_aux(L, 1);
++}
++
++
++static int str_match (lua_State *L) {
++ return str_find_aux(L, 0);
++}
++
++
++static int gmatch_aux (lua_State *L) {
++ MatchState ms;
++ size_t ls;
++ const char *s = lua_tolstring(L, lua_upvalueindex(1), &ls);
++ const char *p = lua_tostring(L, lua_upvalueindex(2));
++ const char *src;
++ ms.L = L;
++ ms.src_init = s;
++ ms.src_end = s+ls;
++ for (src = s + (size_t)lua_tointeger(L, lua_upvalueindex(3));
++ src <= ms.src_end;
++ src++) {
++ const char *e;
++ ms.level = 0;
++ if ((e = match(&ms, src, p)) != NULL) {
++ lua_Integer newstart = e-s;
++ if (e == src) newstart++; /* empty match? go at least one position */
++ lua_pushinteger(L, newstart);
++ lua_replace(L, lua_upvalueindex(3));
++ return push_captures(&ms, src, e);
++ }
++ }
++ return 0; /* not found */
++}
++
++
++static int gmatch (lua_State *L) {
++ luaL_checkstring(L, 1);
++ luaL_checkstring(L, 2);
++ lua_settop(L, 2);
++ lua_pushinteger(L, 0);
++ lua_pushcclosure(L, gmatch_aux, 3);
++ return 1;
++}
++
++
++static int gfind_nodef (lua_State *L) {
++ return luaL_error(L, LUA_QL("string.gfind") " was renamed to "
++ LUA_QL("string.gmatch"));
++}
++
++
++static void add_s (MatchState *ms, luaL_Buffer *b, const char *s,
++ const char *e) {
++ size_t l, i;
++ const char *news = lua_tolstring(ms->L, 3, &l);
++ for (i = 0; i < l; i++) {
++ if (news[i] != L_ESC)
++ luaL_addchar(b, news[i]);
++ else {
++ i++; /* skip ESC */
++ if (!isdigit(uchar(news[i])))
++ luaL_addchar(b, news[i]);
++ else if (news[i] == '0')
++ luaL_addlstring(b, s, e - s);
++ else {
++ push_onecapture(ms, news[i] - '1', s, e);
++ luaL_addvalue(b); /* add capture to accumulated result */
++ }
++ }
++ }
++}
++
++
++static void add_value (MatchState *ms, luaL_Buffer *b, const char *s,
++ const char *e) {
++ lua_State *L = ms->L;
++ switch (lua_type(L, 3)) {
++ case LUA_TNUMBER:
++ case LUA_TSTRING: {
++ add_s(ms, b, s, e);
++ return;
++ }
++ case LUA_TFUNCTION: {
++ int n;
++ lua_pushvalue(L, 3);
++ n = push_captures(ms, s, e);
++ lua_call(L, n, 1);
++ break;
++ }
++ case LUA_TTABLE: {
++ push_onecapture(ms, 0, s, e);
++ lua_gettable(L, 3);
++ break;
++ }
++ }
++ if (!lua_toboolean(L, -1)) { /* nil or false? */
++ lua_pop(L, 1);
++ lua_pushlstring(L, s, e - s); /* keep original text */
++ }
++ else if (!lua_isstring(L, -1))
++ luaL_error(L, "invalid replacement value (a %s)", luaL_typename(L, -1));
++ luaL_addvalue(b); /* add result to accumulator */
++}
++
++
++static int str_gsub (lua_State *L) {
++ size_t srcl;
++ const char *src = luaL_checklstring(L, 1, &srcl);
++ const char *p = luaL_checkstring(L, 2);
++ int tr = lua_type(L, 3);
++ int max_s = luaL_optint(L, 4, srcl+1);
++ int anchor = (*p == '^') ? (p++, 1) : 0;
++ int n = 0;
++ MatchState ms;
++ luaL_Buffer *b = (luaL_Buffer *)kmalloc(sizeof(luaL_Buffer) + BUFSIZ, GFP_ATOMIC);
++ if(!b) luaL_error(L, "str_gsub: cannot allocate memory");
++ luaL_argcheck(L, tr == LUA_TNUMBER || tr == LUA_TSTRING ||
++ tr == LUA_TFUNCTION || tr == LUA_TTABLE, 3,
++ "string/function/table expected");
++ luaL_buffinit(L, b);
++ ms.L = L;
++ ms.src_init = src;
++ ms.src_end = src+srcl;
++ while (n < max_s) {
++ const char *e;
++ ms.level = 0;
++ e = match(&ms, src, p);
++ if (e) {
++ n++;
++ add_value(&ms, b, src, e);
++ }
++ if (e && e>src) /* non empty match? */
++ src = e; /* skip it */
++ else if (src < ms.src_end)
++ luaL_addchar(b, *src++);
++ else break;
++ if (anchor) break;
++ }
++ luaL_addlstring(b, src, ms.src_end-src);
++ luaL_pushresult(b);
++ lua_pushinteger(L, n); /* number of substitutions */
++ kfree(b);
++ return 2;
++}
++
++/* }====================================================== */
++
++
++/* maximum size of each formatted item (> len(format('%99.99f', -1e308))) */
++#define MAX_ITEM 512
++/* valid flags in a format specification */
++#define FLAGS "-+ #0"
++/*
++** maximum size of each format specification (such as '%-099.99d')
++** (+10 accounts for %99.99x plus margin of error)
++*/
++#define MAX_FORMAT (sizeof(FLAGS) + sizeof(LUA_INTFRMLEN) + 10)
++
++
++static void addquoted (lua_State *L, luaL_Buffer *b, int arg) {
++ size_t l;
++ const char *s = luaL_checklstring(L, arg, &l);
++ luaL_addchar(b, '"');
++ while (l--) {
++ switch (*s) {
++ case '"': case '\\': case '\n': {
++ luaL_addchar(b, '\\');
++ luaL_addchar(b, *s);
++ break;
++ }
++ case '\r': {
++ luaL_addlstring(b, "\\r", 2);
++ break;
++ }
++ case '\0': {
++ luaL_addlstring(b, "\\000", 4);
++ break;
++ }
++ default: {
++ luaL_addchar(b, *s);
++ break;
++ }
++ }
++ s++;
++ }
++ luaL_addchar(b, '"');
++}
++
++static const char *scanformat (lua_State *L, const char *strfrmt, char *form) {
++ const char *p = strfrmt;
++ while (*p != '\0' && strchr(FLAGS, *p) != NULL) p++; /* skip flags */
++ if ((size_t)(p - strfrmt) >= sizeof(FLAGS))
++ luaL_error(L, "invalid format (repeated flags)");
++ if (isdigit(uchar(*p))) p++; /* skip width */
++ if (isdigit(uchar(*p))) p++; /* (2 digits at most) */
++ if (*p == '.') {
++ p++;
++ if (isdigit(uchar(*p))) p++; /* skip precision */
++ if (isdigit(uchar(*p))) p++; /* (2 digits at most) */
++ }
++ if (isdigit(uchar(*p)))
++ luaL_error(L, "invalid format (width or precision too long)");
++ *(form++) = '%';
++ strncpy(form, strfrmt, p - strfrmt + 1);
++ form += p - strfrmt + 1;
++ *form = '\0';
++ return p;
++}
++
++
++static void addintlen (char *form) {
++ size_t l = strlen(form);
++ char spec = form[l - 1];
++ strcpy(form + l - 1, LUA_INTFRMLEN);
++ form[l + sizeof(LUA_INTFRMLEN) - 2] = spec;
++ form[l + sizeof(LUA_INTFRMLEN) - 1] = '\0';
++}
++
++
++static int str_format (lua_State *L) {
++ int arg = 1;
++ size_t sfl;
++ const char *strfrmt = luaL_checklstring(L, arg, &sfl);
++ const char *strfrmt_end = strfrmt+sfl;
++ luaL_Buffer *b = (luaL_Buffer *)kmalloc(sizeof(luaL_Buffer) + BUFSIZ, GFP_ATOMIC);
++ if(!b) luaL_error(L, "str_format: cannot allocate memory");
++ luaL_buffinit(L, b);
++ while (strfrmt < strfrmt_end) {
++ if (*strfrmt != L_ESC)
++ luaL_addchar(b, *strfrmt++);
++ else if (*++strfrmt == L_ESC)
++ luaL_addchar(b, *strfrmt++); /* %% */
++ else { /* format item */
++ char form[MAX_FORMAT]; /* to store the format (`%...') */
++ char buff[MAX_ITEM]; /* to store the formatted item */
++ arg++;
++ strfrmt = scanformat(L, strfrmt, form);
++ switch (*strfrmt++) {
++ case 'c': {
++ sprintf(buff, form, (int)luaL_checknumber(L, arg));
++ break;
++ }
++ case 'd': case 'i': {
++ addintlen(form);
++ sprintf(buff, form, (LUA_INTFRM_T)luaL_checknumber(L, arg));
++ break;
++ }
++ case 'o': case 'u': case 'x': case 'X': {
++ addintlen(form);
++ sprintf(buff, form, (unsigned LUA_INTFRM_T)luaL_checknumber(L, arg));
++ break;
++ }
++ case 'q': {
++ addquoted(L, b, arg);
++ continue; /* skip the 'addsize' at the end */
++ }
++ case 's': {
++ size_t l;
++ const char *s = luaL_checklstring(L, arg, &l);
++ if (!strchr(form, '.') && l >= 100) {
++ /* no precision and string is too long to be formatted;
++ keep original string */
++ lua_pushvalue(L, arg);
++ luaL_addvalue(b);
++ continue; /* skip the `addsize' at the end */
++ }
++ else {
++ sprintf(buff, form, s);
++ break;
++ }
++ }
++ default: { /* also treat cases `pnLlh' */
++ kfree(b);
++ return luaL_error(L, "invalid option " LUA_QL("%%%c") " to "
++ LUA_QL("format"), *(strfrmt - 1));
++ }
++ }
++ luaL_addlstring(b, buff, strlen(buff));
++ }
++ }
++ luaL_pushresult(b);
++ kfree(b);
++ return 1;
++}
++
++
++static const luaL_Reg strlib[] = {
++ {"byte", str_byte},
++ {"char", str_char},
++ {"dump", str_dump},
++ {"find", str_find},
++ {"format", str_format},
++ {"gfind", gfind_nodef},
++ {"gmatch", gmatch},
++ {"gsub", str_gsub},
++ {"len", str_len},
++ {"lower", str_lower},
++ {"match", str_match},
++ {"rep", str_rep},
++ {"reverse", str_reverse},
++ {"sub", str_sub},
++ {"upper", str_upper},
++ {NULL, NULL}
++};
++
++
++static void createmetatable (lua_State *L) {
++ lua_createtable(L, 0, 1); /* create metatable for strings */
++ lua_pushliteral(L, ""); /* dummy string */
++ lua_pushvalue(L, -2);
++ lua_setmetatable(L, -2); /* set string metatable */
++ lua_pop(L, 1); /* pop dummy string */
++ lua_pushvalue(L, -2); /* string library... */
++ lua_setfield(L, -2, "__index"); /* ...is the __index metamethod */
++ lua_pop(L, 1); /* pop metatable */
++}
++
++
++/*
++** Open string library
++*/
++LUALIB_API int luaopen_string (lua_State *L) {
++ luaL_register(L, LUA_STRLIBNAME, strlib);
++#if defined(LUA_COMPAT_GFIND)
++ lua_getfield(L, -1, "gmatch");
++ lua_setfield(L, -2, "gfind");
++#endif
++ createmetatable(L);
++ return 1;
++}
+--- /dev/null
++++ b/extensions/LUA/lua/ltable.c
+@@ -0,0 +1,588 @@
++/*
++** $Id: ltable.c,v 2.32.1.2 2007/12/28 15:32:23 roberto Exp $
++** Lua tables (hash)
++** See Copyright Notice in lua.h
++*/
++
++
++/*
++** Implementation of tables (aka arrays, objects, or hash tables).
++** Tables keep its elements in two parts: an array part and a hash part.
++** Non-negative integer keys are all candidates to be kept in the array
++** part. The actual size of the array is the largest `n' such that at
++** least half the slots between 0 and n are in use.
++** Hash uses a mix of chained scatter table with Brent's variation.
++** A main invariant of these tables is that, if an element is not
++** in its main position (i.e. the `original' position that its hash gives
++** to it), then the colliding element is in its own main position.
++** Hence even when the load factor reaches 100%, performance remains good.
++*/
++
++#include <math.h>
++#include <string.h>
++
++#define ltable_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "ldebug.h"
++#include "ldo.h"
++#include "lgc.h"
++#include "lmem.h"
++#include "lobject.h"
++#include "lstate.h"
++#include "ltable.h"
++
++
++/*
++** max size of array part is 2^MAXBITS
++*/
++#if LUAI_BITSINT > 26
++#define MAXBITS 26
++#else
++#define MAXBITS (LUAI_BITSINT-2)
++#endif
++
++#define MAXASIZE (1 << MAXBITS)
++
++
++#define hashpow2(t,n) (gnode(t, lmod((n), sizenode(t))))
++
++#define hashstr(t,str) hashpow2(t, (str)->tsv.hash)
++#define hashboolean(t,p) hashpow2(t, p)
++
++
++/*
++** for some types, it is better to avoid modulus by power of 2, as
++** they tend to have many 2 factors.
++*/
++#define hashmod(t,n) (gnode(t, ((n) % ((sizenode(t)-1)|1))))
++
++
++#define hashpointer(t,p) hashmod(t, IntPoint(p))
++
++
++/*
++** number of ints inside a lua_Number
++*/
++#define numints cast_int(sizeof(lua_Number)/sizeof(int))
++
++
++
++#define dummynode (&dummynode_)
++
++static const Node dummynode_ = {
++ {{NULL}, LUA_TNIL}, /* value */
++ {{{NULL}, LUA_TNIL, NULL}} /* key */
++};
++
++
++/*
++** hash for lua_Numbers
++*/
++static Node *hashnum (const Table *t, lua_Number n) {
++ unsigned int a[numints];
++ int i;
++ if (luai_numeq(n, 0)) /* avoid problems with -0 */
++ return gnode(t, 0);
++ memcpy(a, &n, sizeof(a));
++ for (i = 1; i < numints; i++) a[0] += a[i];
++ return hashmod(t, a[0]);
++}
++
++
++
++/*
++** returns the `main' position of an element in a table (that is, the index
++** of its hash value)
++*/
++static Node *mainposition (const Table *t, const TValue *key) {
++ switch (ttype(key)) {
++ case LUA_TNUMBER:
++ return hashnum(t, nvalue(key));
++ case LUA_TSTRING:
++ return hashstr(t, rawtsvalue(key));
++ case LUA_TBOOLEAN:
++ return hashboolean(t, bvalue(key));
++ case LUA_TLIGHTUSERDATA:
++ return hashpointer(t, pvalue(key));
++ default:
++ return hashpointer(t, gcvalue(key));
++ }
++}
++
++
++/*
++** returns the index for `key' if `key' is an appropriate key to live in
++** the array part of the table, -1 otherwise.
++*/
++static int arrayindex (const TValue *key) {
++ if (ttisnumber(key)) {
++ lua_Number n = nvalue(key);
++ int k;
++ lua_number2int(k, n);
++ if (luai_numeq(cast_num(k), n))
++ return k;
++ }
++ return -1; /* `key' did not match some condition */
++}
++
++
++/*
++** returns the index of a `key' for table traversals. First goes all
++** elements in the array part, then elements in the hash part. The
++** beginning of a traversal is signalled by -1.
++*/
++static int findindex (lua_State *L, Table *t, StkId key) {
++ int i;
++ if (ttisnil(key)) return -1; /* first iteration */
++ i = arrayindex(key);
++ if (0 < i && i <= t->sizearray) /* is `key' inside array part? */
++ return i-1; /* yes; that's the index (corrected to C) */
++ else {
++ Node *n = mainposition(t, key);
++ do { /* check whether `key' is somewhere in the chain */
++ /* key may be dead already, but it is ok to use it in `next' */
++ if (luaO_rawequalObj(key2tval(n), key) ||
++ (ttype(gkey(n)) == LUA_TDEADKEY && iscollectable(key) &&
++ gcvalue(gkey(n)) == gcvalue(key))) {
++ i = cast_int(n - gnode(t, 0)); /* key index in hash table */
++ /* hash elements are numbered after array ones */
++ return i + t->sizearray;
++ }
++ else n = gnext(n);
++ } while (n);
++ luaG_runerror(L, "invalid key to " LUA_QL("next")); /* key not found */
++ return 0; /* to avoid warnings */
++ }
++}
++
++
++int luaH_next (lua_State *L, Table *t, StkId key) {
++ int i = findindex(L, t, key); /* find original element */
++ for (i++; i < t->sizearray; i++) { /* try first array part */
++ if (!ttisnil(&t->array[i])) { /* a non-nil value? */
++ setnvalue(key, cast_num(i+1));
++ setobj2s(L, key+1, &t->array[i]);
++ return 1;
++ }
++ }
++ for (i -= t->sizearray; i < sizenode(t); i++) { /* then hash part */
++ if (!ttisnil(gval(gnode(t, i)))) { /* a non-nil value? */
++ setobj2s(L, key, key2tval(gnode(t, i)));
++ setobj2s(L, key+1, gval(gnode(t, i)));
++ return 1;
++ }
++ }
++ return 0; /* no more elements */
++}
++
++
++/*
++** {=============================================================
++** Rehash
++** ==============================================================
++*/
++
++
++static int computesizes (int nums[], int *narray) {
++ int i;
++ int twotoi; /* 2^i */
++ int a = 0; /* number of elements smaller than 2^i */
++ int na = 0; /* number of elements to go to array part */
++ int n = 0; /* optimal size for array part */
++ for (i = 0, twotoi = 1; twotoi/2 < *narray; i++, twotoi *= 2) {
++ if (nums[i] > 0) {
++ a += nums[i];
++ if (a > twotoi/2) { /* more than half elements present? */
++ n = twotoi; /* optimal size (till now) */
++ na = a; /* all elements smaller than n will go to array part */
++ }
++ }
++ if (a == *narray) break; /* all elements already counted */
++ }
++ *narray = n;
++ lua_assert(*narray/2 <= na && na <= *narray);
++ return na;
++}
++
++
++static int countint (const TValue *key, int *nums) {
++ int k = arrayindex(key);
++ if (0 < k && k <= MAXASIZE) { /* is `key' an appropriate array index? */
++ nums[ceillog2(k)]++; /* count as such */
++ return 1;
++ }
++ else
++ return 0;
++}
++
++
++static int numusearray (const Table *t, int *nums) {
++ int lg;
++ int ttlg; /* 2^lg */
++ int ause = 0; /* summation of `nums' */
++ int i = 1; /* count to traverse all array keys */
++ for (lg=0, ttlg=1; lg<=MAXBITS; lg++, ttlg*=2) { /* for each slice */
++ int lc = 0; /* counter */
++ int lim = ttlg;
++ if (lim > t->sizearray) {
++ lim = t->sizearray; /* adjust upper limit */
++ if (i > lim)
++ break; /* no more elements to count */
++ }
++ /* count elements in range (2^(lg-1), 2^lg] */
++ for (; i <= lim; i++) {
++ if (!ttisnil(&t->array[i-1]))
++ lc++;
++ }
++ nums[lg] += lc;
++ ause += lc;
++ }
++ return ause;
++}
++
++
++static int numusehash (const Table *t, int *nums, int *pnasize) {
++ int totaluse = 0; /* total number of elements */
++ int ause = 0; /* summation of `nums' */
++ int i = sizenode(t);
++ while (i--) {
++ Node *n = &t->node[i];
++ if (!ttisnil(gval(n))) {
++ ause += countint(key2tval(n), nums);
++ totaluse++;
++ }
++ }
++ *pnasize += ause;
++ return totaluse;
++}
++
++
++static void setarrayvector (lua_State *L, Table *t, int size) {
++ int i;
++ luaM_reallocvector(L, t->array, t->sizearray, size, TValue);
++ for (i=t->sizearray; i<size; i++)
++ setnilvalue(&t->array[i]);
++ t->sizearray = size;
++}
++
++
++static void setnodevector (lua_State *L, Table *t, int size) {
++ int lsize;
++ if (size == 0) { /* no elements to hash part? */
++ t->node = cast(Node *, dummynode); /* use common `dummynode' */
++ lsize = 0;
++ }
++ else {
++ int i;
++ lsize = ceillog2(size);
++ if (lsize > MAXBITS)
++ luaG_runerror(L, "table overflow");
++ size = twoto(lsize);
++ t->node = luaM_newvector(L, size, Node);
++ for (i=0; i<size; i++) {
++ Node *n = gnode(t, i);
++ gnext(n) = NULL;
++ setnilvalue(gkey(n));
++ setnilvalue(gval(n));
++ }
++ }
++ t->lsizenode = cast_byte(lsize);
++ t->lastfree = gnode(t, size); /* all positions are free */
++}
++
++
++static void resize (lua_State *L, Table *t, int nasize, int nhsize) {
++ int i;
++ int oldasize = t->sizearray;
++ int oldhsize = t->lsizenode;
++ Node *nold = t->node; /* save old hash ... */
++ if (nasize > oldasize) /* array part must grow? */
++ setarrayvector(L, t, nasize);
++ /* create new hash part with appropriate size */
++ setnodevector(L, t, nhsize);
++ if (nasize < oldasize) { /* array part must shrink? */
++ t->sizearray = nasize;
++ /* re-insert elements from vanishing slice */
++ for (i=nasize; i<oldasize; i++) {
++ if (!ttisnil(&t->array[i]))
++ setobjt2t(L, luaH_setnum(L, t, i+1), &t->array[i]);
++ }
++ /* shrink array */
++ luaM_reallocvector(L, t->array, oldasize, nasize, TValue);
++ }
++ /* re-insert elements from hash part */
++ for (i = twoto(oldhsize) - 1; i >= 0; i--) {
++ Node *old = nold+i;
++ if (!ttisnil(gval(old)))
++ setobjt2t(L, luaH_set(L, t, key2tval(old)), gval(old));
++ }
++ if (nold != dummynode)
++ luaM_freearray(L, nold, twoto(oldhsize), Node); /* free old array */
++}
++
++
++void luaH_resizearray (lua_State *L, Table *t, int nasize) {
++ int nsize = (t->node == dummynode) ? 0 : sizenode(t);
++ resize(L, t, nasize, nsize);
++}
++
++
++static void rehash (lua_State *L, Table *t, const TValue *ek) {
++ int nasize, na;
++ int nums[MAXBITS+1]; /* nums[i] = number of keys between 2^(i-1) and 2^i */
++ int i;
++ int totaluse;
++ for (i=0; i<=MAXBITS; i++) nums[i] = 0; /* reset counts */
++ nasize = numusearray(t, nums); /* count keys in array part */
++ totaluse = nasize; /* all those keys are integer keys */
++ totaluse += numusehash(t, nums, &nasize); /* count keys in hash part */
++ /* count extra key */
++ nasize += countint(ek, nums);
++ totaluse++;
++ /* compute new size for array part */
++ na = computesizes(nums, &nasize);
++ /* resize the table to new computed sizes */
++ resize(L, t, nasize, totaluse - na);
++}
++
++
++
++/*
++** }=============================================================
++*/
++
++
++Table *luaH_new (lua_State *L, int narray, int nhash) {
++ Table *t = luaM_new(L, Table);
++ luaC_link(L, obj2gco(t), LUA_TTABLE);
++ t->metatable = NULL;
++ t->flags = cast_byte(~0);
++ /* temporary values (kept only if some malloc fails) */
++ t->array = NULL;
++ t->sizearray = 0;
++ t->lsizenode = 0;
++ t->node = cast(Node *, dummynode);
++ setarrayvector(L, t, narray);
++ setnodevector(L, t, nhash);
++ return t;
++}
++
++
++void luaH_free (lua_State *L, Table *t) {
++ if (t->node != dummynode)
++ luaM_freearray(L, t->node, sizenode(t), Node);
++ luaM_freearray(L, t->array, t->sizearray, TValue);
++ luaM_free(L, t);
++}
++
++
++static Node *getfreepos (Table *t) {
++ while (t->lastfree-- > t->node) {
++ if (ttisnil(gkey(t->lastfree)))
++ return t->lastfree;
++ }
++ return NULL; /* could not find a free place */
++}
++
++
++
++/*
++** inserts a new key into a hash table; first, check whether key's main
++** position is free. If not, check whether colliding node is in its main
++** position or not: if it is not, move colliding node to an empty place and
++** put new key in its main position; otherwise (colliding node is in its main
++** position), new key goes to an empty position.
++*/
++static TValue *newkey (lua_State *L, Table *t, const TValue *key) {
++ Node *mp = mainposition(t, key);
++ if (!ttisnil(gval(mp)) || mp == dummynode) {
++ Node *othern;
++ Node *n = getfreepos(t); /* get a free place */
++ if (n == NULL) { /* cannot find a free place? */
++ rehash(L, t, key); /* grow table */
++ return luaH_set(L, t, key); /* re-insert key into grown table */
++ }
++ lua_assert(n != dummynode);
++ othern = mainposition(t, key2tval(mp));
++ if (othern != mp) { /* is colliding node out of its main position? */
++ /* yes; move colliding node into free position */
++ while (gnext(othern) != mp) othern = gnext(othern); /* find previous */
++ gnext(othern) = n; /* redo the chain with `n' in place of `mp' */
++ *n = *mp; /* copy colliding node into free pos. (mp->next also goes) */
++ gnext(mp) = NULL; /* now `mp' is free */
++ setnilvalue(gval(mp));
++ }
++ else { /* colliding node is in its own main position */
++ /* new node will go into free position */
++ gnext(n) = gnext(mp); /* chain new position */
++ gnext(mp) = n;
++ mp = n;
++ }
++ }
++ gkey(mp)->value = key->value; gkey(mp)->tt = key->tt;
++ luaC_barriert(L, t, key);
++ lua_assert(ttisnil(gval(mp)));
++ return gval(mp);
++}
++
++
++/*
++** search function for integers
++*/
++const TValue *luaH_getnum (Table *t, int key) {
++ /* (1 <= key && key <= t->sizearray) */
++ if (cast(unsigned int, key-1) < cast(unsigned int, t->sizearray))
++ return &t->array[key-1];
++ else {
++ lua_Number nk = cast_num(key);
++ Node *n = hashnum(t, nk);
++ do { /* check whether `key' is somewhere in the chain */
++ if (ttisnumber(gkey(n)) && luai_numeq(nvalue(gkey(n)), nk))
++ return gval(n); /* that's it */
++ else n = gnext(n);
++ } while (n);
++ return luaO_nilobject;
++ }
++}
++
++
++/*
++** search function for strings
++*/
++const TValue *luaH_getstr (Table *t, TString *key) {
++ Node *n = hashstr(t, key);
++ do { /* check whether `key' is somewhere in the chain */
++ if (ttisstring(gkey(n)) && rawtsvalue(gkey(n)) == key)
++ return gval(n); /* that's it */
++ else n = gnext(n);
++ } while (n);
++ return luaO_nilobject;
++}
++
++
++/*
++** main search function
++*/
++const TValue *luaH_get (Table *t, const TValue *key) {
++ switch (ttype(key)) {
++ case LUA_TNIL: return luaO_nilobject;
++ case LUA_TSTRING: return luaH_getstr(t, rawtsvalue(key));
++ case LUA_TNUMBER: {
++ int k;
++ lua_Number n = nvalue(key);
++ lua_number2int(k, n);
++ if (luai_numeq(cast_num(k), nvalue(key))) /* index is int? */
++ return luaH_getnum(t, k); /* use specialized version */
++ /* else go through */
++ }
++ default: {
++ Node *n = mainposition(t, key);
++ do { /* check whether `key' is somewhere in the chain */
++ if (luaO_rawequalObj(key2tval(n), key))
++ return gval(n); /* that's it */
++ else n = gnext(n);
++ } while (n);
++ return luaO_nilobject;
++ }
++ }
++}
++
++
++TValue *luaH_set (lua_State *L, Table *t, const TValue *key) {
++ const TValue *p = luaH_get(t, key);
++ t->flags = 0;
++ if (p != luaO_nilobject)
++ return cast(TValue *, p);
++ else {
++ if (ttisnil(key)) luaG_runerror(L, "table index is nil");
++ else if (ttisnumber(key) && luai_numisnan(nvalue(key)))
++ luaG_runerror(L, "table index is NaN");
++ return newkey(L, t, key);
++ }
++}
++
++
++TValue *luaH_setnum (lua_State *L, Table *t, int key) {
++ const TValue *p = luaH_getnum(t, key);
++ if (p != luaO_nilobject)
++ return cast(TValue *, p);
++ else {
++ TValue k;
++ setnvalue(&k, cast_num(key));
++ return newkey(L, t, &k);
++ }
++}
++
++
++TValue *luaH_setstr (lua_State *L, Table *t, TString *key) {
++ const TValue *p = luaH_getstr(t, key);
++ if (p != luaO_nilobject)
++ return cast(TValue *, p);
++ else {
++ TValue k;
++ setsvalue(L, &k, key);
++ return newkey(L, t, &k);
++ }
++}
++
++
++static int unbound_search (Table *t, unsigned int j) {
++ unsigned int i = j; /* i is zero or a present index */
++ j++;
++ /* find `i' and `j' such that i is present and j is not */
++ while (!ttisnil(luaH_getnum(t, j))) {
++ i = j;
++ j *= 2;
++ if (j > cast(unsigned int, MAX_INT)) { /* overflow? */
++ /* table was built with bad purposes: resort to linear search */
++ i = 1;
++ while (!ttisnil(luaH_getnum(t, i))) i++;
++ return i - 1;
++ }
++ }
++ /* now do a binary search between them */
++ while (j - i > 1) {
++ unsigned int m = (i+j)/2;
++ if (ttisnil(luaH_getnum(t, m))) j = m;
++ else i = m;
++ }
++ return i;
++}
++
++
++/*
++** Try to find a boundary in table `t'. A `boundary' is an integer index
++** such that t[i] is non-nil and t[i+1] is nil (and 0 if t[1] is nil).
++*/
++int luaH_getn (Table *t) {
++ unsigned int j = t->sizearray;
++ if (j > 0 && ttisnil(&t->array[j - 1])) {
++ /* there is a boundary in the array part: (binary) search for it */
++ unsigned int i = 0;
++ while (j - i > 1) {
++ unsigned int m = (i+j)/2;
++ if (ttisnil(&t->array[m - 1])) j = m;
++ else i = m;
++ }
++ return i;
++ }
++ /* else must find a boundary in hash part */
++ else if (t->node == dummynode) /* hash part is empty? */
++ return j; /* that is easy... */
++ else return unbound_search(t, j);
++}
++
++
++
++#if defined(LUA_DEBUG)
++
++Node *luaH_mainposition (const Table *t, const TValue *key) {
++ return mainposition(t, key);
++}
++
++int luaH_isdummy (Node *n) { return n == dummynode; }
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/ltable.h
+@@ -0,0 +1,40 @@
++/*
++** $Id: ltable.h,v 2.10.1.1 2007/12/27 13:02:25 roberto Exp $
++** Lua tables (hash)
++** See Copyright Notice in lua.h
++*/
++
++#ifndef ltable_h
++#define ltable_h
++
++#include "lobject.h"
++
++
++#define gnode(t,i) (&(t)->node[i])
++#define gkey(n) (&(n)->i_key.nk)
++#define gval(n) (&(n)->i_val)
++#define gnext(n) ((n)->i_key.nk.next)
++
++#define key2tval(n) (&(n)->i_key.tvk)
++
++
++LUAI_FUNC const TValue *luaH_getnum (Table *t, int key);
++LUAI_FUNC TValue *luaH_setnum (lua_State *L, Table *t, int key);
++LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key);
++LUAI_FUNC TValue *luaH_setstr (lua_State *L, Table *t, TString *key);
++LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key);
++LUAI_FUNC TValue *luaH_set (lua_State *L, Table *t, const TValue *key);
++LUAI_FUNC Table *luaH_new (lua_State *L, int narray, int lnhash);
++LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, int nasize);
++LUAI_FUNC void luaH_free (lua_State *L, Table *t);
++LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key);
++LUAI_FUNC int luaH_getn (Table *t);
++
++
++#if defined(LUA_DEBUG)
++LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key);
++LUAI_FUNC int luaH_isdummy (Node *n);
++#endif
++
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/ltablib.c
+@@ -0,0 +1,288 @@
++/*
++** $Id: ltablib.c,v 1.38.1.3 2008/02/14 16:46:58 roberto Exp $
++** Library for Table Manipulation
++** See Copyright Notice in lua.h
++*/
++
++
++#include <stddef.h>
++
++#define ltablib_c
++#define LUA_LIB
++
++#include "lua.h"
++
++#include "lauxlib.h"
++#include "lualib.h"
++
++
++#define aux_getn(L,n) (luaL_checktype(L, n, LUA_TTABLE), luaL_getn(L, n))
++
++
++static int foreachi (lua_State *L) {
++ int i;
++ int n = aux_getn(L, 1);
++ luaL_checktype(L, 2, LUA_TFUNCTION);
++ for (i=1; i <= n; i++) {
++ lua_pushvalue(L, 2); /* function */
++ lua_pushinteger(L, i); /* 1st argument */
++ lua_rawgeti(L, 1, i); /* 2nd argument */
++ lua_call(L, 2, 1);
++ if (!lua_isnil(L, -1))
++ return 1;
++ lua_pop(L, 1); /* remove nil result */
++ }
++ return 0;
++}
++
++
++static int foreach (lua_State *L) {
++ luaL_checktype(L, 1, LUA_TTABLE);
++ luaL_checktype(L, 2, LUA_TFUNCTION);
++ lua_pushnil(L); /* first key */
++ while (lua_next(L, 1)) {
++ lua_pushvalue(L, 2); /* function */
++ lua_pushvalue(L, -3); /* key */
++ lua_pushvalue(L, -3); /* value */
++ lua_call(L, 2, 1);
++ if (!lua_isnil(L, -1))
++ return 1;
++ lua_pop(L, 2); /* remove value and result */
++ }
++ return 0;
++}
++
++
++static int maxn (lua_State *L) {
++ lua_Number max = 0;
++ luaL_checktype(L, 1, LUA_TTABLE);
++ lua_pushnil(L); /* first key */
++ while (lua_next(L, 1)) {
++ lua_pop(L, 1); /* remove value */
++ if (lua_type(L, -1) == LUA_TNUMBER) {
++ lua_Number v = lua_tonumber(L, -1);
++ if (v > max) max = v;
++ }
++ }
++ lua_pushnumber(L, max);
++ return 1;
++}
++
++
++static int getn (lua_State *L) {
++ lua_pushinteger(L, aux_getn(L, 1));
++ return 1;
++}
++
++
++static int setn (lua_State *L) {
++ luaL_checktype(L, 1, LUA_TTABLE);
++#ifndef luaL_setn
++ luaL_setn(L, 1, luaL_checkint(L, 2));
++#else
++ luaL_error(L, LUA_QL("setn") " is obsolete");
++#endif
++ lua_pushvalue(L, 1);
++ return 1;
++}
++
++
++static int tinsert (lua_State *L) {
++ int e = aux_getn(L, 1) + 1; /* first empty element */
++ int pos; /* where to insert new element */
++ switch (lua_gettop(L)) {
++ case 2: { /* called with only 2 arguments */
++ pos = e; /* insert new element at the end */
++ break;
++ }
++ case 3: {
++ int i;
++ pos = luaL_checkint(L, 2); /* 2nd argument is the position */
++ if (pos > e) e = pos; /* `grow' array if necessary */
++ for (i = e; i > pos; i--) { /* move up elements */
++ lua_rawgeti(L, 1, i-1);
++ lua_rawseti(L, 1, i); /* t[i] = t[i-1] */
++ }
++ break;
++ }
++ default: {
++ return luaL_error(L, "wrong number of arguments to " LUA_QL("insert"));
++ }
++ }
++ luaL_setn(L, 1, e); /* new size */
++ lua_rawseti(L, 1, pos); /* t[pos] = v */
++ return 0;
++}
++
++
++static int tremove (lua_State *L) {
++ int e = aux_getn(L, 1);
++ int pos = luaL_optint(L, 2, e);
++ if (!(1 <= pos && pos <= e)) /* position is outside bounds? */
++ return 0; /* nothing to remove */
++ luaL_setn(L, 1, e - 1); /* t.n = n-1 */
++ lua_rawgeti(L, 1, pos); /* result = t[pos] */
++ for ( ;pos<e; pos++) {
++ lua_rawgeti(L, 1, pos+1);
++ lua_rawseti(L, 1, pos); /* t[pos] = t[pos+1] */
++ }
++ lua_pushnil(L);
++ lua_rawseti(L, 1, e); /* t[e] = nil */
++ return 1;
++}
++
++
++static void addfield (lua_State *L, luaL_Buffer *b, int i) {
++ lua_rawgeti(L, 1, i);
++ if (!lua_isstring(L, -1))
++ luaL_error(L, "invalid value (%s) at index %d in table for "
++ LUA_QL("concat"), luaL_typename(L, -1), i);
++ luaL_addvalue(b);
++}
++
++
++static int tconcat (lua_State *L) {
++ size_t lsep;
++ int i, last;
++ const char *sep = luaL_optlstring(L, 2, "", &lsep);
++ luaL_Buffer *b = (luaL_Buffer *)kmalloc(sizeof(luaL_Buffer) + BUFSIZ, GFP_ATOMIC);
++ if(!b) luaL_error(L, "tconcat: cannot allocate memory");
++ luaL_checktype(L, 1, LUA_TTABLE);
++ i = luaL_optint(L, 3, 1);
++ last = luaL_opt(L, luaL_checkint, 4, luaL_getn(L, 1));
++ luaL_buffinit(L, b);
++ for (; i < last; i++) {
++ addfield(L, b, i);
++ luaL_addlstring(b, sep, lsep);
++ }
++ if (i == last) /* add last value (if interval was not empty) */
++ addfield(L, b, i);
++ luaL_pushresult(b);
++ kfree(b);
++ return 1;
++}
++
++
++
++/*
++** {======================================================
++** Quicksort
++** (based on `Algorithms in MODULA-3', Robert Sedgewick;
++** Addison-Wesley, 1993.)
++*/
++
++
++static void set2 (lua_State *L, int i, int j) {
++ lua_rawseti(L, 1, i);
++ lua_rawseti(L, 1, j);
++}
++
++static int sort_comp (lua_State *L, int a, int b) {
++ if (!lua_isnil(L, 2)) { /* function? */
++ int res;
++ lua_pushvalue(L, 2);
++ lua_pushvalue(L, a-1); /* -1 to compensate function */
++ lua_pushvalue(L, b-2); /* -2 to compensate function and `a' */
++ lua_call(L, 2, 1);
++ res = lua_toboolean(L, -1);
++ lua_pop(L, 1);
++ return res;
++ }
++ else /* a < b? */
++ return lua_lessthan(L, a, b);
++}
++
++static void auxsort (lua_State *L, int l, int u) {
++ while (l < u) { /* for tail recursion */
++ int i, j;
++ /* sort elements a[l], a[(l+u)/2] and a[u] */
++ lua_rawgeti(L, 1, l);
++ lua_rawgeti(L, 1, u);
++ if (sort_comp(L, -1, -2)) /* a[u] < a[l]? */
++ set2(L, l, u); /* swap a[l] - a[u] */
++ else
++ lua_pop(L, 2);
++ if (u-l == 1) break; /* only 2 elements */
++ i = (l+u)/2;
++ lua_rawgeti(L, 1, i);
++ lua_rawgeti(L, 1, l);
++ if (sort_comp(L, -2, -1)) /* a[i]<a[l]? */
++ set2(L, i, l);
++ else {
++ lua_pop(L, 1); /* remove a[l] */
++ lua_rawgeti(L, 1, u);
++ if (sort_comp(L, -1, -2)) /* a[u]<a[i]? */
++ set2(L, i, u);
++ else
++ lua_pop(L, 2);
++ }
++ if (u-l == 2) break; /* only 3 elements */
++ lua_rawgeti(L, 1, i); /* Pivot */
++ lua_pushvalue(L, -1);
++ lua_rawgeti(L, 1, u-1);
++ set2(L, i, u-1);
++ /* a[l] <= P == a[u-1] <= a[u], only need to sort from l+1 to u-2 */
++ i = l; j = u-1;
++ for (;;) { /* invariant: a[l..i] <= P <= a[j..u] */
++ /* repeat ++i until a[i] >= P */
++ while (lua_rawgeti(L, 1, ++i), sort_comp(L, -1, -2)) {
++ if (i>u) luaL_error(L, "invalid order function for sorting");
++ lua_pop(L, 1); /* remove a[i] */
++ }
++ /* repeat --j until a[j] <= P */
++ while (lua_rawgeti(L, 1, --j), sort_comp(L, -3, -1)) {
++ if (j<l) luaL_error(L, "invalid order function for sorting");
++ lua_pop(L, 1); /* remove a[j] */
++ }
++ if (j<i) {
++ lua_pop(L, 3); /* pop pivot, a[i], a[j] */
++ break;
++ }
++ set2(L, i, j);
++ }
++ lua_rawgeti(L, 1, u-1);
++ lua_rawgeti(L, 1, i);
++ set2(L, u-1, i); /* swap pivot (a[u-1]) with a[i] */
++ /* a[l..i-1] <= a[i] == P <= a[i+1..u] */
++ /* adjust so that smaller half is in [j..i] and larger one in [l..u] */
++ if (i-l < u-i) {
++ j=l; i=i-1; l=i+2;
++ }
++ else {
++ j=i+1; i=u; u=j-2;
++ }
++ auxsort(L, j, i); /* call recursively the smaller one */
++ } /* repeat the routine for the larger one */
++}
++
++static int sort (lua_State *L) {
++ int n = aux_getn(L, 1);
++ luaL_checkstack(L, 40, ""); /* assume array is smaller than 2^40 */
++ if (!lua_isnoneornil(L, 2)) /* is there a 2nd argument? */
++ luaL_checktype(L, 2, LUA_TFUNCTION);
++ lua_settop(L, 2); /* make sure there is two arguments */
++ auxsort(L, 1, n);
++ return 0;
++}
++
++/* }====================================================== */
++
++
++static const luaL_Reg tab_funcs[] = {
++ {"concat", tconcat},
++ {"foreach", foreach},
++ {"foreachi", foreachi},
++ {"getn", getn},
++ {"maxn", maxn},
++ {"insert", tinsert},
++ {"remove", tremove},
++ {"setn", setn},
++ {"sort", sort},
++ {NULL, NULL}
++};
++
++
++LUALIB_API int luaopen_table (lua_State *L) {
++ luaL_register(L, LUA_TABLIBNAME, tab_funcs);
++ return 1;
++}
+--- /dev/null
++++ b/extensions/LUA/lua/ltm.c
+@@ -0,0 +1,74 @@
++/*
++** $Id: ltm.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $
++** Tag methods
++** See Copyright Notice in lua.h
++*/
++
++#include <string.h>
++
++#define ltm_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "lobject.h"
++#include "lstate.h"
++#include "lstring.h"
++#include "ltable.h"
++#include "ltm.h"
++
++
++
++const char *const luaT_typenames[] = {
++ "nil", "boolean", "userdata", "number",
++ "string", "table", "function", "userdata", "thread",
++ "proto", "upval"
++};
++
++
++void luaT_init (lua_State *L) {
++ static const char *const luaT_eventname[] = { /* ORDER TM */
++ "__index", "__newindex",
++ "__gc", "__mode", "__eq",
++ "__add", "__sub", "__mul", "__div", "__mod",
++ "__pow", "__unm", "__len", "__lt", "__le",
++ "__concat", "__call"
++ };
++ int i;
++ for (i=0; i<TM_N; i++) {
++ G(L)->tmname[i] = luaS_new(L, luaT_eventname[i]);
++ luaS_fix(G(L)->tmname[i]); /* never collect these names */
++ }
++}
++
++
++/*
++** function to be used with macro "fasttm": optimized for absence of
++** tag methods
++*/
++const TValue *luaT_gettm (Table *events, TMS event, TString *ename) {
++ const TValue *tm = luaH_getstr(events, ename);
++ lua_assert(event <= TM_EQ);
++ if (ttisnil(tm)) { /* no tag method? */
++ events->flags |= cast_byte(1u<<event); /* cache this fact */
++ return NULL;
++ }
++ else return tm;
++}
++
++
++const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, TMS event) {
++ Table *mt;
++ switch (ttype(o)) {
++ case LUA_TTABLE:
++ mt = hvalue(o)->metatable;
++ break;
++ case LUA_TUSERDATA:
++ mt = uvalue(o)->metatable;
++ break;
++ default:
++ mt = G(L)->mt[ttype(o)];
++ }
++ return (mt ? luaH_getstr(mt, G(L)->tmname[event]) : luaO_nilobject);
++}
++
+--- /dev/null
++++ b/extensions/LUA/lua/ltm.h
+@@ -0,0 +1,54 @@
++/*
++** $Id: ltm.h,v 2.6.1.1 2007/12/27 13:02:25 roberto Exp $
++** Tag methods
++** See Copyright Notice in lua.h
++*/
++
++#ifndef ltm_h
++#define ltm_h
++
++
++#include "lobject.h"
++
++
++/*
++* WARNING: if you change the order of this enumeration,
++* grep "ORDER TM"
++*/
++typedef enum {
++ TM_INDEX,
++ TM_NEWINDEX,
++ TM_GC,
++ TM_MODE,
++ TM_EQ, /* last tag method with `fast' access */
++ TM_ADD,
++ TM_SUB,
++ TM_MUL,
++ TM_DIV,
++ TM_MOD,
++ TM_POW,
++ TM_UNM,
++ TM_LEN,
++ TM_LT,
++ TM_LE,
++ TM_CONCAT,
++ TM_CALL,
++ TM_N /* number of elements in the enum */
++} TMS;
++
++
++
++#define gfasttm(g,et,e) ((et) == NULL ? NULL : \
++ ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e]))
++
++#define fasttm(l,et,e) gfasttm(G(l), et, e)
++
++LUAI_DATA const char *const luaT_typenames[];
++
++
++LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename);
++LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o,
++ TMS event);
++LUAI_FUNC void luaT_init (lua_State *L);
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/luaconf.h
+@@ -0,0 +1,797 @@
++/*
++** $Id: luaconf.h,v 1.82.1.7 2008/02/11 16:25:08 roberto Exp $
++** Configuration file for Lua
++** See Copyright Notice in lua.h
++*/
++
++
++#ifndef lconfig_h
++#define lconfig_h
++
++#include <stddef.h>
++
++#if !defined(__KERNEL__)
++#include <limits.h>
++#else
++#define UCHAR_MAX 255
++#define SHRT_MAX 32767
++#define BUFSIZ 8192
++#define NO_FPU
++#endif
++
++/*
++** ==================================================================
++** Search for "@@" to find all configurable definitions.
++** ===================================================================
++*/
++
++
++/*
++@@ LUA_ANSI controls the use of non-ansi features.
++** CHANGE it (define it) if you want Lua to avoid the use of any
++** non-ansi feature or library.
++*/
++#if defined(__STRICT_ANSI__)
++#define LUA_ANSI
++#endif
++
++
++#if !defined(LUA_ANSI) && defined(_WIN32)
++#define LUA_WIN
++#endif
++
++#if defined(LUA_USE_LINUX)
++#define LUA_USE_POSIX
++#define LUA_USE_DLOPEN /* needs an extra library: -ldl */
++#define LUA_USE_READLINE /* needs some extra libraries */
++#endif
++
++#if defined(LUA_USE_MACOSX)
++#define LUA_USE_POSIX
++#define LUA_DL_DYLD /* does not need extra library */
++#endif
++
++
++
++/*
++@@ LUA_USE_POSIX includes all functionallity listed as X/Open System
++@* Interfaces Extension (XSI).
++** CHANGE it (define it) if your system is XSI compatible.
++*/
++#if defined(LUA_USE_POSIX)
++#define LUA_USE_MKSTEMP
++#define LUA_USE_ISATTY
++#define LUA_USE_POPEN
++#define LUA_USE_ULONGJMP
++#endif
++
++
++/*
++@@ LUA_PATH and LUA_CPATH are the names of the environment variables that
++@* Lua check to set its paths.
++@@ LUA_INIT is the name of the environment variable that Lua
++@* checks for initialization code.
++** CHANGE them if you want different names.
++*/
++#define LUA_PATH "LUA_PATH"
++#define LUA_CPATH "LUA_CPATH"
++#define LUA_INIT "LUA_INIT"
++
++
++/*
++@@ LUA_PATH_DEFAULT is the default path that Lua uses to look for
++@* Lua libraries.
++@@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for
++@* C libraries.
++** CHANGE them if your machine has a non-conventional directory
++** hierarchy or if you want to install your libraries in
++** non-conventional directories.
++*/
++#if defined(_WIN32)
++/*
++** In Windows, any exclamation mark ('!') in the path is replaced by the
++** path of the directory of the executable file of the current process.
++*/
++#define LUA_LDIR "!\\lua\\"
++#define LUA_CDIR "!\\"
++#define LUA_PATH_DEFAULT \
++ ".\\?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \
++ LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua"
++#define LUA_CPATH_DEFAULT \
++ ".\\?.dll;" LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll"
++
++#else
++#define LUA_ROOT "/usr/local/"
++#define LUA_LDIR LUA_ROOT "share/lua/5.1/"
++#define LUA_CDIR LUA_ROOT "lib/lua/5.1/"
++#define LUA_PATH_DEFAULT \
++ "./?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \
++ LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua"
++#define LUA_CPATH_DEFAULT \
++ "./?.so;" LUA_CDIR"?.so;" LUA_CDIR"loadall.so"
++#endif
++
++
++/*
++@@ LUA_DIRSEP is the directory separator (for submodules).
++** CHANGE it if your machine does not use "/" as the directory separator
++** and is not Windows. (On Windows Lua automatically uses "\".)
++*/
++#if defined(_WIN32)
++#define LUA_DIRSEP "\\"
++#else
++#define LUA_DIRSEP "/"
++#endif
++
++
++/*
++@@ LUA_PATHSEP is the character that separates templates in a path.
++@@ LUA_PATH_MARK is the string that marks the substitution points in a
++@* template.
++@@ LUA_EXECDIR in a Windows path is replaced by the executable's
++@* directory.
++@@ LUA_IGMARK is a mark to ignore all before it when bulding the
++@* luaopen_ function name.
++** CHANGE them if for some reason your system cannot use those
++** characters. (E.g., if one of those characters is a common character
++** in file/directory names.) Probably you do not need to change them.
++*/
++#define LUA_PATHSEP ";"
++#define LUA_PATH_MARK "?"
++#define LUA_EXECDIR "!"
++#define LUA_IGMARK "-"
++
++
++/*
++@@ LUA_INTEGER is the integral type used by lua_pushinteger/lua_tointeger.
++** CHANGE that if ptrdiff_t is not adequate on your machine. (On most
++** machines, ptrdiff_t gives a good choice between int or long.)
++*/
++#define LUA_INTEGER ptrdiff_t
++
++
++/*
++@@ LUA_API is a mark for all core API functions.
++@@ LUALIB_API is a mark for all standard library functions.
++** CHANGE them if you need to define those functions in some special way.
++** For instance, if you want to create one Windows DLL with the core and
++** the libraries, you may want to use the following definition (define
++** LUA_BUILD_AS_DLL to get it).
++*/
++#if defined(LUA_BUILD_AS_DLL)
++
++#if defined(LUA_CORE) || defined(LUA_LIB)
++#define LUA_API __declspec(dllexport)
++#else
++#define LUA_API __declspec(dllimport)
++#endif
++
++#else
++
++#define LUA_API extern
++
++#endif
++
++/* more often than not the libs go together with the core */
++#define LUALIB_API LUA_API
++
++
++/*
++@@ LUAI_FUNC is a mark for all extern functions that are not to be
++@* exported to outside modules.
++@@ LUAI_DATA is a mark for all extern (const) variables that are not to
++@* be exported to outside modules.
++** CHANGE them if you need to mark them in some special way. Elf/gcc
++** (versions 3.2 and later) mark them as "hidden" to optimize access
++** when Lua is compiled as a shared library.
++*/
++#if defined(luaall_c)
++#define LUAI_FUNC static
++#define LUAI_DATA /* empty */
++
++#elif defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \
++ defined(__ELF__)
++#define LUAI_FUNC __attribute__((visibility("hidden"))) extern
++#define LUAI_DATA LUAI_FUNC
++
++#else
++#define LUAI_FUNC extern
++#define LUAI_DATA extern
++#endif
++
++
++
++/*
++@@ LUA_QL describes how error messages quote program elements.
++** CHANGE it if you want a different appearance.
++*/
++#define LUA_QL(x) "'" x "'"
++#define LUA_QS LUA_QL("%s")
++
++
++/*
++@@ LUA_IDSIZE gives the maximum size for the description of the source
++@* of a function in debug information.
++** CHANGE it if you want a different size.
++*/
++#define LUA_IDSIZE 60
++
++
++/*
++** {==================================================================
++** Stand-alone configuration
++** ===================================================================
++*/
++
++#if defined(lua_c) || defined(luaall_c)
++
++/*
++@@ lua_stdin_is_tty detects whether the standard input is a 'tty' (that
++@* is, whether we're running lua interactively).
++** CHANGE it if you have a better definition for non-POSIX/non-Windows
++** systems.
++*/
++#if defined(LUA_USE_ISATTY)
++#include <unistd.h>
++#define lua_stdin_is_tty() isatty(0)
++#elif defined(LUA_WIN)
++#include <io.h>
++#include <stdio.h>
++#define lua_stdin_is_tty() _isatty(_fileno(stdin))
++#else
++#define lua_stdin_is_tty() 1 /* assume stdin is a tty */
++#endif
++
++
++/*
++@@ LUA_PROMPT is the default prompt used by stand-alone Lua.
++@@ LUA_PROMPT2 is the default continuation prompt used by stand-alone Lua.
++** CHANGE them if you want different prompts. (You can also change the
++** prompts dynamically, assigning to globals _PROMPT/_PROMPT2.)
++*/
++#define LUA_PROMPT "> "
++#define LUA_PROMPT2 ">> "
++
++
++/*
++@@ LUA_PROGNAME is the default name for the stand-alone Lua program.
++** CHANGE it if your stand-alone interpreter has a different name and
++** your system is not able to detect that name automatically.
++*/
++#define LUA_PROGNAME "lua"
++
++
++/*
++@@ LUA_MAXINPUT is the maximum length for an input line in the
++@* stand-alone interpreter.
++** CHANGE it if you need longer lines.
++*/
++#define LUA_MAXINPUT 512
++
++
++/*
++@@ lua_readline defines how to show a prompt and then read a line from
++@* the standard input.
++@@ lua_saveline defines how to "save" a read line in a "history".
++@@ lua_freeline defines how to free a line read by lua_readline.
++** CHANGE them if you want to improve this functionality (e.g., by using
++** GNU readline and history facilities).
++*/
++#if defined(LUA_USE_READLINE)
++#include <stdio.h>
++#include <readline/readline.h>
++#include <readline/history.h>
++#define lua_readline(L,b,p) ((void)L, ((b)=readline(p)) != NULL)
++#define lua_saveline(L,idx) \
++ if (lua_strlen(L,idx) > 0) /* non-empty line? */ \
++ add_history(lua_tostring(L, idx)); /* add it to history */
++#define lua_freeline(L,b) ((void)L, free(b))
++#else
++#define lua_readline(L,b,p) \
++ ((void)L, fputs(p, stdout), fflush(stdout), /* show prompt */ \
++ fgets(b, LUA_MAXINPUT, stdin) != NULL) /* get line */
++#define lua_saveline(L,idx) { (void)L; (void)idx; }
++#define lua_freeline(L,b) { (void)L; (void)b; }
++#endif
++
++#endif
++
++/* }================================================================== */
++
++
++/*
++@@ LUAI_GCPAUSE defines the default pause between garbage-collector cycles
++@* as a percentage.
++** CHANGE it if you want the GC to run faster or slower (higher values
++** mean larger pauses which mean slower collection.) You can also change
++** this value dynamically.
++*/
++#define LUAI_GCPAUSE 200 /* 200% (wait memory to double before next GC) */
++
++
++/*
++@@ LUAI_GCMUL defines the default speed of garbage collection relative to
++@* memory allocation as a percentage.
++** CHANGE it if you want to change the granularity of the garbage
++** collection. (Higher values mean coarser collections. 0 represents
++** infinity, where each step performs a full collection.) You can also
++** change this value dynamically.
++*/
++#define LUAI_GCMUL 200 /* GC runs 'twice the speed' of memory allocation */
++
++
++
++/*
++@@ LUA_COMPAT_GETN controls compatibility with old getn behavior.
++** CHANGE it (define it) if you want exact compatibility with the
++** behavior of setn/getn in Lua 5.0.
++*/
++#undef LUA_COMPAT_GETN
++
++/*
++@@ LUA_COMPAT_LOADLIB controls compatibility about global loadlib.
++** CHANGE it to undefined as soon as you do not need a global 'loadlib'
++** function (the function is still available as 'package.loadlib').
++*/
++#undef LUA_COMPAT_LOADLIB
++
++/*
++@@ LUA_COMPAT_VARARG controls compatibility with old vararg feature.
++** CHANGE it to undefined as soon as your programs use only '...' to
++** access vararg parameters (instead of the old 'arg' table).
++*/
++#define LUA_COMPAT_VARARG
++
++/*
++@@ LUA_COMPAT_MOD controls compatibility with old math.mod function.
++** CHANGE it to undefined as soon as your programs use 'math.fmod' or
++** the new '%' operator instead of 'math.mod'.
++*/
++#define LUA_COMPAT_MOD
++
++/*
++@@ LUA_COMPAT_LSTR controls compatibility with old long string nesting
++@* facility.
++** CHANGE it to 2 if you want the old behaviour, or undefine it to turn
++** off the advisory error when nesting [[...]].
++*/
++#define LUA_COMPAT_LSTR 1
++
++/*
++@@ LUA_COMPAT_GFIND controls compatibility with old 'string.gfind' name.
++** CHANGE it to undefined as soon as you rename 'string.gfind' to
++** 'string.gmatch'.
++*/
++#define LUA_COMPAT_GFIND
++
++/*
++@@ LUA_COMPAT_OPENLIB controls compatibility with old 'luaL_openlib'
++@* behavior.
++** CHANGE it to undefined as soon as you replace to 'luaL_register'
++** your uses of 'luaL_openlib'
++*/
++#define LUA_COMPAT_OPENLIB
++
++
++
++/*
++@@ luai_apicheck is the assert macro used by the Lua-C API.
++** CHANGE luai_apicheck if you want Lua to perform some checks in the
++** parameters it gets from API calls. This may slow down the interpreter
++** a bit, but may be quite useful when debugging C code that interfaces
++** with Lua. A useful redefinition is to use assert.h.
++*/
++#if defined(LUA_USE_APICHECK)
++#include <assert.h>
++#define luai_apicheck(L,o) { (void)L; assert(o); }
++#else
++#define luai_apicheck(L,o) { (void)L; }
++#endif
++
++
++/*
++@@ LUAI_BITSINT defines the number of bits in an int.
++** CHANGE here if Lua cannot automatically detect the number of bits of
++** your machine. Probably you do not need to change this.
++*/
++/* avoid overflows in comparison */
++#if !defined(__KERNEL__)
++#include <limits.h>
++#define LUA_INT_MAX INT_MAX
++#else
++#define LUA_INT_MAX (~0U>>1)
++#endif
++
++#if LUA_INT_MAX-20 < 32760
++#define LUAI_BITSINT 16
++#elif LUA_INT_MAX > 2147483640L
++/* int has at least 32 bits */
++#define LUAI_BITSINT 32
++#else
++#error "you must define LUA_BITSINT with number of bits in an integer"
++#endif
++
++
++/*
++@@ LUAI_UINT32 is an unsigned integer with at least 32 bits.
++@@ LUAI_INT32 is an signed integer with at least 32 bits.
++@@ LUAI_UMEM is an unsigned integer big enough to count the total
++@* memory used by Lua.
++@@ LUAI_MEM is a signed integer big enough to count the total memory
++@* used by Lua.
++** CHANGE here if for some weird reason the default definitions are not
++** good enough for your machine. (The definitions in the 'else'
++** part always works, but may waste space on machines with 64-bit
++** longs.) Probably you do not need to change this.
++*/
++#if LUAI_BITSINT >= 32
++#define LUAI_UINT32 unsigned int
++#define LUAI_INT32 int
++#define LUAI_MAXINT32 INT_MAX
++#define LUAI_UMEM size_t
++#define LUAI_MEM ptrdiff_t
++#else
++/* 16-bit ints */
++#define LUAI_UINT32 unsigned long
++#define LUAI_INT32 long
++#define LUAI_MAXINT32 LONG_MAX
++#define LUAI_UMEM unsigned long
++#define LUAI_MEM long
++#endif
++
++
++/*
++@@ LUAI_MAXCALLS limits the number of nested calls.
++** CHANGE it if you need really deep recursive calls. This limit is
++** arbitrary; its only purpose is to stop infinite recursion before
++** exhausting memory.
++*/
++#define LUAI_MAXCALLS 20000
++
++
++/*
++@@ LUAI_MAXCSTACK limits the number of Lua stack slots that a C function
++@* can use.
++** CHANGE it if you need lots of (Lua) stack space for your C
++** functions. This limit is arbitrary; its only purpose is to stop C
++** functions to consume unlimited stack space. (must be smaller than
++** -LUA_REGISTRYINDEX)
++*/
++#define LUAI_MAXCSTACK 8000
++
++
++
++/*
++** {==================================================================
++** CHANGE (to smaller values) the following definitions if your system
++** has a small C stack. (Or you may want to change them to larger
++** values if your system has a large C stack and these limits are
++** too rigid for you.) Some of these constants control the size of
++** stack-allocated arrays used by the compiler or the interpreter, while
++** others limit the maximum number of recursive calls that the compiler
++** or the interpreter can perform. Values too large may cause a C stack
++** overflow for some forms of deep constructs.
++** ===================================================================
++*/
++
++
++/*
++@@ LUAI_MAXCCALLS is the maximum depth for nested C calls (short) and
++@* syntactical nested non-terminals in a program.
++*/
++#define LUAI_MAXCCALLS 200
++
++
++/*
++@@ LUAI_MAXVARS is the maximum number of local variables per function
++@* (must be smaller than 250).
++*/
++#define LUAI_MAXVARS 200
++
++
++/*
++@@ LUAI_MAXUPVALUES is the maximum number of upvalues per function
++@* (must be smaller than 250).
++*/
++#define LUAI_MAXUPVALUES 60
++
++
++/*
++@@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system.
++*/
++#define LUAL_BUFFERSIZE BUFSIZ
++
++/* }================================================================== */
++
++
++
++
++/*
++** {==================================================================
++@@ LUA_NUMBER is the type of numbers in Lua.
++** CHANGE the following definitions only if you want to build Lua
++** with a number type different from double. You may also need to
++** change lua_number2int & lua_number2integer.
++** ===================================================================
++*/
++#if !defined(NO_FPU)
++#define LUA_NUMBER_DOUBLE
++#define LUA_NUMBER double
++#else
++#define LUA_NUMBER long
++#endif
++
++/*
++@@ LUAI_UACNUMBER is the result of an 'usual argument conversion'
++@* over a number.
++*/
++#define LUAI_UACNUMBER LUA_NUMBER
++
++
++/*
++@@ LUA_NUMBER_SCAN is the format for reading numbers.
++@@ LUA_NUMBER_FMT is the format for writing numbers.
++@@ lua_number2str converts a number to a string.
++@@ LUAI_MAXNUMBER2STR is maximum size of previous conversion.
++@@ lua_str2number converts a string to a number.
++*/
++#if !defined(NO_FPU)
++#define LUA_NUMBER_SCAN "%lf"
++#define LUA_NUMBER_FMT "%.14g"
++#define lua_str2number(s,p) strtod((s), (p))
++#else
++#define LUA_NUMBER_SCAN "%ld"
++#define LUA_NUMBER_FMT "%ld"
++#if !defined(__KERNEL__)
++#define lua_str2number(s,p) strtol((s), (p), 10)
++#else
++#define lua_str2number(s,p) simple_strtol((s), (p), 10)
++#endif
++#endif
++
++#define LUAI_MAXNUMBER2STR 32 /* 16 digits, sign, point, and \0 */
++#define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n))
++
++/*
++@@ The luai_num* macros define the primitive operations over numbers.
++*/
++#if defined(LUA_CORE)
++#define luai_numadd(a,b) ((a)+(b))
++#define luai_numsub(a,b) ((a)-(b))
++#define luai_nummul(a,b) ((a)*(b))
++#define luai_numdiv(a,b) ((a)/(b))
++#define luai_numunm(a) (-(a))
++#define luai_numeq(a,b) ((a)==(b))
++#define luai_numlt(a,b) ((a)<(b))
++#define luai_numle(a,b) ((a)<=(b))
++#define luai_numisnan(a) (!luai_numeq((a), (a)))
++#if !defined(NO_FPU)
++#include <math.h>
++#define luai_nummod(a,b) ((a) - floor((a)/(b))*(b))
++#define luai_numpow(a,b) (pow(a,b))
++#else
++#define luai_nummod(a,b) ((a)%(b))
++#define luai_numpow(a,b) luai_nummul(a,b)
++#endif
++#endif
++
++
++/*
++@@ lua_number2int is a macro to convert lua_Number to int.
++@@ lua_number2integer is a macro to convert lua_Number to lua_Integer.
++** CHANGE them if you know a faster way to convert a lua_Number to
++** int (with any rounding method and without throwing errors) in your
++** system. In Pentium machines, a naive typecast from double to int
++** in C is extremely slow, so any alternative is worth trying.
++*/
++
++/* On a Pentium, resort to a trick */
++#if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) && !defined(__SSE2__) && \
++ (defined(__i386) || defined (_M_IX86) || defined(__i386__))
++
++/* On a Microsoft compiler, use assembler */
++#if defined(_MSC_VER)
++
++#define lua_number2int(i,d) __asm fld d __asm fistp i
++#define lua_number2integer(i,n) lua_number2int(i, n)
++
++/* the next trick should work on any Pentium, but sometimes clashes
++ with a DirectX idiosyncrasy */
++#else
++
++union luai_Cast { double l_d; long l_l; };
++#define lua_number2int(i,d) \
++ { volatile union luai_Cast u; u.l_d = (d) + 6755399441055744.0; (i) = u.l_l; }
++#define lua_number2integer(i,n) lua_number2int(i, n)
++
++#endif
++
++
++/* this option always works, but may be slow */
++#else
++#define lua_number2int(i,d) ((i)=(int)(d))
++#define lua_number2integer(i,d) ((i)=(lua_Integer)(d))
++
++#endif
++
++/* }================================================================== */
++
++
++/*
++@@ LUAI_USER_ALIGNMENT_T is a type that requires maximum alignment.
++** CHANGE it if your system requires alignments larger than double. (For
++** instance, if your system supports long doubles and they must be
++** aligned in 16-byte boundaries, then you should add long double in the
++** union.) Probably you do not need to change this.
++*/
++#define LUAI_USER_ALIGNMENT_T union { double u; void *s; long l; }
++
++
++/*
++@@ LUAI_THROW/LUAI_TRY define how Lua does exception handling.
++** CHANGE them if you prefer to use longjmp/setjmp even with C++
++** or if want/don't to use _longjmp/_setjmp instead of regular
++** longjmp/setjmp. By default, Lua handles errors with exceptions when
++** compiling as C++ code, with _longjmp/_setjmp when asked to use them,
++** and with longjmp/setjmp otherwise.
++*/
++#if defined(__KERNEL__)
++#undef LUA_USE_ULONGJMP
++#endif
++
++#if defined(__cplusplus)
++/* C++ exceptions */
++#define LUAI_THROW(L,c) throw(c)
++#define LUAI_TRY(L,c,a) try { a } catch(...) \
++ { if ((c)->status == 0) (c)->status = -1; }
++#define luai_jmpbuf int /* dummy variable */
++
++#elif defined(LUA_USE_ULONGJMP)
++/* in Unix, try _longjmp/_setjmp (more efficient) */
++#define LUAI_THROW(L,c) _longjmp((c)->b, 1)
++#define LUAI_TRY(L,c,a) if (_setjmp((c)->b) == 0) { a }
++#define luai_jmpbuf jmp_buf
++
++#else
++/* default handling with long jumps */
++#define LUAI_THROW(L,c) longjmp((c)->b, 1)
++#define LUAI_TRY(L,c,a) if (setjmp((c)->b) == 0) { a }
++#define luai_jmpbuf jmp_buf
++
++#endif
++
++
++/*
++@@ LUA_MAXCAPTURES is the maximum number of captures that a pattern
++@* can do during pattern-matching.
++** CHANGE it if you need more captures. This limit is arbitrary.
++*/
++#define LUA_MAXCAPTURES 32
++
++
++/*
++@@ lua_tmpnam is the function that the OS library uses to create a
++@* temporary name.
++@@ LUA_TMPNAMBUFSIZE is the maximum size of a name created by lua_tmpnam.
++** CHANGE them if you have an alternative to tmpnam (which is considered
++** insecure) or if you want the original tmpnam anyway. By default, Lua
++** uses tmpnam except when POSIX is available, where it uses mkstemp.
++*/
++#if defined(loslib_c) || defined(luaall_c)
++
++#if defined(LUA_USE_MKSTEMP)
++#include <unistd.h>
++#define LUA_TMPNAMBUFSIZE 32
++#define lua_tmpnam(b,e) { \
++ strcpy(b, "/tmp/lua_XXXXXX"); \
++ e = mkstemp(b); \
++ if (e != -1) close(e); \
++ e = (e == -1); }
++
++#else
++#define LUA_TMPNAMBUFSIZE L_tmpnam
++#define lua_tmpnam(b,e) { e = (tmpnam(b) == NULL); }
++#endif
++
++#endif
++
++
++/*
++@@ lua_popen spawns a new process connected to the current one through
++@* the file streams.
++** CHANGE it if you have a way to implement it in your system.
++*/
++#if defined(LUA_USE_POPEN)
++
++#define lua_popen(L,c,m) ((void)L, fflush(NULL), popen(c,m))
++#define lua_pclose(L,file) ((void)L, (pclose(file) != -1))
++
++#elif defined(LUA_WIN)
++
++#define lua_popen(L,c,m) ((void)L, _popen(c,m))
++#define lua_pclose(L,file) ((void)L, (_pclose(file) != -1))
++
++#else
++
++#define lua_popen(L,c,m) ((void)((void)c, m), \
++ luaL_error(L, LUA_QL("popen") " not supported"), (FILE*)0)
++#define lua_pclose(L,file) ((void)((void)L, file), 0)
++
++#endif
++
++/*
++@@ LUA_DL_* define which dynamic-library system Lua should use.
++** CHANGE here if Lua has problems choosing the appropriate
++** dynamic-library system for your platform (either Windows' DLL, Mac's
++** dyld, or Unix's dlopen). If your system is some kind of Unix, there
++** is a good chance that it has dlopen, so LUA_DL_DLOPEN will work for
++** it. To use dlopen you also need to adapt the src/Makefile (probably
++** adding -ldl to the linker options), so Lua does not select it
++** automatically. (When you change the makefile to add -ldl, you must
++** also add -DLUA_USE_DLOPEN.)
++** If you do not want any kind of dynamic library, undefine all these
++** options.
++** By default, _WIN32 gets LUA_DL_DLL and MAC OS X gets LUA_DL_DYLD.
++*/
++#if defined(LUA_USE_DLOPEN)
++#define LUA_DL_DLOPEN
++#endif
++
++#if defined(LUA_WIN)
++#define LUA_DL_DLL
++#endif
++
++
++/*
++@@ LUAI_EXTRASPACE allows you to add user-specific data in a lua_State
++@* (the data goes just *before* the lua_State pointer).
++** CHANGE (define) this if you really need that. This value must be
++** a multiple of the maximum alignment required for your machine.
++*/
++#define LUAI_EXTRASPACE 0
++
++
++/*
++@@ luai_userstate* allow user-specific actions on threads.
++** CHANGE them if you defined LUAI_EXTRASPACE and need to do something
++** extra when a thread is created/deleted/resumed/yielded.
++*/
++#define luai_userstateopen(L) ((void)L)
++#define luai_userstateclose(L) ((void)L)
++#define luai_userstatethread(L,L1) ((void)L)
++#define luai_userstatefree(L) ((void)L)
++#define luai_userstateresume(L,n) ((void)L)
++#define luai_userstateyield(L,n) ((void)L)
++
++
++/*
++@@ LUA_INTFRMLEN is the length modifier for integer conversions
++@* in 'string.format'.
++@@ LUA_INTFRM_T is the integer type correspoding to the previous length
++@* modifier.
++** CHANGE them if your system supports long long or does not support long.
++*/
++
++#if defined(LUA_USELONGLONG)
++
++#define LUA_INTFRMLEN "ll"
++#define LUA_INTFRM_T long long
++
++#else
++
++#define LUA_INTFRMLEN "l"
++#define LUA_INTFRM_T long
++
++#endif
++
++/* =================================================================== */
++
++/*
++** Local configuration. You can use this space to add your redefinitions
++** without modifying the main part of the file.
++*/
++
++
++
++#endif
++
+--- /dev/null
++++ b/extensions/LUA/lua/lua.h
+@@ -0,0 +1,387 @@
++/*
++** $Id: lua.h,v 1.218.1.5 2008/08/06 13:30:12 roberto Exp $
++** Lua - An Extensible Extension Language
++** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
++** See Copyright Notice at the end of this file
++*/
++
++
++#ifndef lua_h
++#define lua_h
++
++#include <stdarg.h>
++#include <stddef.h>
++
++#include "luaconf.h"
++
++
++#define LUA_VERSION "Lua 5.1"
++#define LUA_RELEASE "Lua 5.1.4"
++#define LUA_VERSION_NUM 501
++#define LUA_COPYRIGHT "Copyright (C) 1994-2008 Lua.org, PUC-Rio"
++#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo & W. Celes"
++
++
++/* mark for precompiled code (`<esc>Lua') */
++#define LUA_SIGNATURE "\033Lua"
++
++/* option for multiple returns in `lua_pcall' and `lua_call' */
++#define LUA_MULTRET (-1)
++
++
++/*
++** pseudo-indices
++*/
++#define LUA_REGISTRYINDEX (-10000)
++#define LUA_ENVIRONINDEX (-10001)
++#define LUA_GLOBALSINDEX (-10002)
++#define lua_upvalueindex(i) (LUA_GLOBALSINDEX-(i))
++
++
++/* thread status; 0 is OK */
++#define LUA_YIELD 1
++#define LUA_ERRRUN 2
++#define LUA_ERRSYNTAX 3
++#define LUA_ERRMEM 4
++#define LUA_ERRERR 5
++
++
++typedef struct lua_State lua_State;
++
++typedef int (*lua_CFunction) (lua_State *L);
++
++
++/*
++** functions that read/write blocks when loading/dumping Lua chunks
++*/
++typedef const char * (*lua_Reader) (lua_State *L, void *ud, size_t *sz);
++
++typedef int (*lua_Writer) (lua_State *L, const void* p, size_t sz, void* ud);
++
++
++/*
++** prototype for memory-allocation functions
++*/
++typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize);
++
++
++/*
++** basic types
++*/
++#define LUA_TNONE (-1)
++
++#define LUA_TNIL 0
++#define LUA_TBOOLEAN 1
++#define LUA_TLIGHTUSERDATA 2
++#define LUA_TNUMBER 3
++#define LUA_TSTRING 4
++#define LUA_TTABLE 5
++#define LUA_TFUNCTION 6
++#define LUA_TUSERDATA 7
++#define LUA_TTHREAD 8
++
++
++
++/* minimum Lua stack available to a C function */
++#define LUA_MINSTACK 20
++
++
++/*
++** generic extra include file
++*/
++#if defined(LUA_USER_H)
++#include LUA_USER_H
++#endif
++
++
++/* type of numbers in Lua */
++typedef LUA_NUMBER lua_Number;
++
++
++/* type for integer functions */
++typedef LUA_INTEGER lua_Integer;
++
++
++
++/*
++** state manipulation
++*/
++LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud);
++LUA_API void (lua_close) (lua_State *L);
++LUA_API lua_State *(lua_newthread) (lua_State *L);
++
++LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf);
++
++
++/*
++** basic stack manipulation
++*/
++LUA_API int (lua_gettop) (lua_State *L);
++LUA_API void (lua_settop) (lua_State *L, int idx);
++LUA_API void (lua_pushvalue) (lua_State *L, int idx);
++LUA_API void (lua_remove) (lua_State *L, int idx);
++LUA_API void (lua_insert) (lua_State *L, int idx);
++LUA_API void (lua_replace) (lua_State *L, int idx);
++LUA_API int (lua_checkstack) (lua_State *L, int sz);
++
++LUA_API void (lua_xmove) (lua_State *from, lua_State *to, int n);
++
++
++/*
++** access functions (stack -> C)
++*/
++
++LUA_API int (lua_isnumber) (lua_State *L, int idx);
++LUA_API int (lua_isstring) (lua_State *L, int idx);
++LUA_API int (lua_iscfunction) (lua_State *L, int idx);
++LUA_API int (lua_isuserdata) (lua_State *L, int idx);
++LUA_API int (lua_type) (lua_State *L, int idx);
++LUA_API const char *(lua_typename) (lua_State *L, int tp);
++
++LUA_API int (lua_equal) (lua_State *L, int idx1, int idx2);
++LUA_API int (lua_rawequal) (lua_State *L, int idx1, int idx2);
++LUA_API int (lua_lessthan) (lua_State *L, int idx1, int idx2);
++
++LUA_API lua_Number (lua_tonumber) (lua_State *L, int idx);
++LUA_API lua_Integer (lua_tointeger) (lua_State *L, int idx);
++LUA_API int (lua_toboolean) (lua_State *L, int idx);
++LUA_API const char *(lua_tolstring) (lua_State *L, int idx, size_t *len);
++LUA_API size_t (lua_objlen) (lua_State *L, int idx);
++LUA_API lua_CFunction (lua_tocfunction) (lua_State *L, int idx);
++LUA_API void *(lua_touserdata) (lua_State *L, int idx);
++LUA_API lua_State *(lua_tothread) (lua_State *L, int idx);
++LUA_API const void *(lua_topointer) (lua_State *L, int idx);
++
++
++/*
++** push functions (C -> stack)
++*/
++LUA_API void (lua_pushnil) (lua_State *L);
++LUA_API void (lua_pushnumber) (lua_State *L, lua_Number n);
++LUA_API void (lua_pushinteger) (lua_State *L, lua_Integer n);
++LUA_API void (lua_pushlstring) (lua_State *L, const char *s, size_t l);
++LUA_API void (lua_pushstring) (lua_State *L, const char *s);
++LUA_API const char *(lua_pushvfstring) (lua_State *L, const char *fmt,
++ va_list argp);
++LUA_API const char *(lua_pushfstring) (lua_State *L, const char *fmt, ...);
++LUA_API void (lua_pushcclosure) (lua_State *L, lua_CFunction fn, int n);
++LUA_API void (lua_pushboolean) (lua_State *L, int b);
++LUA_API void (lua_pushlightuserdata) (lua_State *L, void *p);
++LUA_API int (lua_pushthread) (lua_State *L);
++
++
++/*
++** get functions (Lua -> stack)
++*/
++LUA_API void (lua_gettable) (lua_State *L, int idx);
++LUA_API void (lua_getfield) (lua_State *L, int idx, const char *k);
++LUA_API void (lua_rawget) (lua_State *L, int idx);
++LUA_API void (lua_rawgeti) (lua_State *L, int idx, int n);
++LUA_API void (lua_createtable) (lua_State *L, int narr, int nrec);
++LUA_API void *(lua_newuserdata) (lua_State *L, size_t sz);
++LUA_API int (lua_getmetatable) (lua_State *L, int objindex);
++LUA_API void (lua_getfenv) (lua_State *L, int idx);
++
++
++/*
++** set functions (stack -> Lua)
++*/
++LUA_API void (lua_settable) (lua_State *L, int idx);
++LUA_API void (lua_setfield) (lua_State *L, int idx, const char *k);
++LUA_API void (lua_rawset) (lua_State *L, int idx);
++LUA_API void (lua_rawseti) (lua_State *L, int idx, int n);
++LUA_API int (lua_setmetatable) (lua_State *L, int objindex);
++LUA_API int (lua_setfenv) (lua_State *L, int idx);
++
++
++/*
++** `load' and `call' functions (load and run Lua code)
++*/
++LUA_API void (lua_call) (lua_State *L, int nargs, int nresults);
++LUA_API int (lua_pcall) (lua_State *L, int nargs, int nresults, int errfunc);
++LUA_API int (lua_cpcall) (lua_State *L, lua_CFunction func, void *ud);
++LUA_API int (lua_load) (lua_State *L, lua_Reader reader, void *dt,
++ const char *chunkname);
++
++LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data);
++
++
++/*
++** coroutine functions
++*/
++LUA_API int (lua_yield) (lua_State *L, int nresults);
++LUA_API int (lua_resume) (lua_State *L, int narg);
++LUA_API int (lua_status) (lua_State *L);
++
++/*
++** garbage-collection function and options
++*/
++
++#define LUA_GCSTOP 0
++#define LUA_GCRESTART 1
++#define LUA_GCCOLLECT 2
++#define LUA_GCCOUNT 3
++#define LUA_GCCOUNTB 4
++#define LUA_GCSTEP 5
++#define LUA_GCSETPAUSE 6
++#define LUA_GCSETSTEPMUL 7
++
++LUA_API int (lua_gc) (lua_State *L, int what, int data);
++
++
++/*
++** miscellaneous functions
++*/
++
++LUA_API int (lua_error) (lua_State *L);
++
++LUA_API int (lua_next) (lua_State *L, int idx);
++
++LUA_API void (lua_concat) (lua_State *L, int n);
++
++LUA_API lua_Alloc (lua_getallocf) (lua_State *L, void **ud);
++LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud);
++
++
++
++/*
++** ===============================================================
++** some useful macros
++** ===============================================================
++*/
++
++#define lua_pop(L,n) lua_settop(L, -(n)-1)
++
++#define lua_newtable(L) lua_createtable(L, 0, 0)
++
++#define lua_register(L,n,f) (lua_pushcfunction(L, (f)), lua_setglobal(L, (n)))
++
++#define lua_pushcfunction(L,f) lua_pushcclosure(L, (f), 0)
++
++#define lua_strlen(L,i) lua_objlen(L, (i))
++
++#define lua_isfunction(L,n) (lua_type(L, (n)) == LUA_TFUNCTION)
++#define lua_istable(L,n) (lua_type(L, (n)) == LUA_TTABLE)
++#define lua_islightuserdata(L,n) (lua_type(L, (n)) == LUA_TLIGHTUSERDATA)
++#define lua_isnil(L,n) (lua_type(L, (n)) == LUA_TNIL)
++#define lua_isboolean(L,n) (lua_type(L, (n)) == LUA_TBOOLEAN)
++#define lua_isthread(L,n) (lua_type(L, (n)) == LUA_TTHREAD)
++#define lua_isnone(L,n) (lua_type(L, (n)) == LUA_TNONE)
++#define lua_isnoneornil(L, n) (lua_type(L, (n)) <= 0)
++
++#define lua_pushliteral(L, s) \
++ lua_pushlstring(L, "" s, (sizeof(s)/sizeof(char))-1)
++
++#define lua_setglobal(L,s) lua_setfield(L, LUA_GLOBALSINDEX, (s))
++#define lua_getglobal(L,s) lua_getfield(L, LUA_GLOBALSINDEX, (s))
++
++#define lua_tostring(L,i) lua_tolstring(L, (i), NULL)
++
++
++
++/*
++** compatibility macros and functions
++*/
++
++#define lua_open() luaL_newstate()
++
++#define lua_getregistry(L) lua_pushvalue(L, LUA_REGISTRYINDEX)
++
++#define lua_getgccount(L) lua_gc(L, LUA_GCCOUNT, 0)
++
++#define lua_Chunkreader lua_Reader
++#define lua_Chunkwriter lua_Writer
++
++
++/* hack */
++LUA_API void lua_setlevel (lua_State *from, lua_State *to);
++
++
++/*
++** {======================================================================
++** Debug API
++** =======================================================================
++*/
++
++
++/*
++** Event codes
++*/
++#define LUA_HOOKCALL 0
++#define LUA_HOOKRET 1
++#define LUA_HOOKLINE 2
++#define LUA_HOOKCOUNT 3
++#define LUA_HOOKTAILRET 4
++
++
++/*
++** Event masks
++*/
++#define LUA_MASKCALL (1 << LUA_HOOKCALL)
++#define LUA_MASKRET (1 << LUA_HOOKRET)
++#define LUA_MASKLINE (1 << LUA_HOOKLINE)
++#define LUA_MASKCOUNT (1 << LUA_HOOKCOUNT)
++
++typedef struct lua_Debug lua_Debug; /* activation record */
++
++
++/* Functions to be called by the debuger in specific events */
++typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar);
++
++
++LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar);
++LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar);
++LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n);
++LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n);
++LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n);
++LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n);
++
++LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count);
++LUA_API lua_Hook lua_gethook (lua_State *L);
++LUA_API int lua_gethookmask (lua_State *L);
++LUA_API int lua_gethookcount (lua_State *L);
++
++
++struct lua_Debug {
++ int event;
++ const char *name; /* (n) */
++ const char *namewhat; /* (n) `global', `local', `field', `method' */
++ const char *what; /* (S) `Lua', `C', `main', `tail' */
++ const char *source; /* (S) */
++ int currentline; /* (l) */
++ int nups; /* (u) number of upvalues */
++ int linedefined; /* (S) */
++ int lastlinedefined; /* (S) */
++ char short_src[LUA_IDSIZE]; /* (S) */
++ /* private part */
++ int i_ci; /* active function */
++};
++
++/* }====================================================================== */
++
++
++/******************************************************************************
++* Copyright (C) 1994-2008 Lua.org, PUC-Rio. All rights reserved.
++*
++* Permission is hereby granted, free of charge, to any person obtaining
++* a copy of this software and associated documentation files (the
++* "Software"), to deal in the Software without restriction, including
++* without limitation the rights to use, copy, modify, merge, publish,
++* distribute, sublicense, and/or sell copies of the Software, and to
++* permit persons to whom the Software is furnished to do so, subject to
++* the following conditions:
++*
++* The above copyright notice and this permission notice shall be
++* included in all copies or substantial portions of the Software.
++*
++* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
++* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
++* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
++* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
++* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
++* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
++* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++******************************************************************************/
++
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/lualib.h
+@@ -0,0 +1,55 @@
++/*
++** $Id: lualib.h,v 1.36.1.1 2007/12/27 13:02:25 roberto Exp $
++** Lua standard libraries
++** See Copyright Notice in lua.h
++*/
++
++
++#ifndef lualib_h
++#define lualib_h
++
++#include "lua.h"
++
++
++/* Key to file-handle type */
++#define LUA_FILEHANDLE "FILE*"
++
++
++#define LUA_COLIBNAME "coroutine"
++LUALIB_API int (luaopen_base) (lua_State *L);
++
++#define LUA_TABLIBNAME "table"
++LUALIB_API int (luaopen_table) (lua_State *L);
++/*
++#define LUA_IOLIBNAME "io"
++LUALIB_API int (luaopen_io) (lua_State *L);
++
++#define LUA_OSLIBNAME "os"
++LUALIB_API int (luaopen_os) (lua_State *L);
++*/
++
++#define LUA_STRLIBNAME "string"
++LUALIB_API int (luaopen_string) (lua_State *L);
++
++/*
++#define LUA_MATHLIBNAME "math"
++LUALIB_API int (luaopen_math) (lua_State *L);
++
++#define LUA_DBLIBNAME "debug"
++LUALIB_API int (luaopen_debug) (lua_State *L);
++
++#define LUA_LOADLIBNAME "package"
++LUALIB_API int (luaopen_package) (lua_State *L);
++*/
++
++/* open all previous libraries */
++LUALIB_API void (luaL_openlibs) (lua_State *L);
++
++
++
++#ifndef lua_assert
++#define lua_assert(x) ((void)0)
++#endif
++
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/lundump.c
+@@ -0,0 +1,227 @@
++/*
++** $Id: lundump.c,v 2.7.1.4 2008/04/04 19:51:41 roberto Exp $
++** load precompiled Lua chunks
++** See Copyright Notice in lua.h
++*/
++
++#include <string.h>
++
++#define lundump_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "ldebug.h"
++#include "ldo.h"
++#include "lfunc.h"
++#include "lmem.h"
++#include "lobject.h"
++#include "lstring.h"
++#include "lundump.h"
++#include "lzio.h"
++
++typedef struct {
++ lua_State* L;
++ ZIO* Z;
++ Mbuffer* b;
++ const char* name;
++} LoadState;
++
++#ifdef LUAC_TRUST_BINARIES
++#define IF(c,s)
++#define error(S,s)
++#else
++#define IF(c,s) if (c) error(S,s)
++
++static void error(LoadState* S, const char* why)
++{
++ luaO_pushfstring(S->L,"%s: %s in precompiled chunk",S->name,why);
++ luaD_throw(S->L,LUA_ERRSYNTAX);
++}
++#endif
++
++#define LoadMem(S,b,n,size) LoadBlock(S,b,(n)*(size))
++#define LoadByte(S) (lu_byte)LoadChar(S)
++#define LoadVar(S,x) LoadMem(S,&x,1,sizeof(x))
++#define LoadVector(S,b,n,size) LoadMem(S,b,n,size)
++
++static void LoadBlock(LoadState* S, void* b, size_t size)
++{
++ size_t r=luaZ_read(S->Z,b,size);
++ IF (r!=0, "unexpected end");
++}
++
++static int LoadChar(LoadState* S)
++{
++ char x;
++ LoadVar(S,x);
++ return x;
++}
++
++static int LoadInt(LoadState* S)
++{
++ int x;
++ LoadVar(S,x);
++ IF (x<0, "bad integer");
++ return x;
++}
++
++static lua_Number LoadNumber(LoadState* S)
++{
++ lua_Number x;
++ LoadVar(S,x);
++ return x;
++}
++
++static TString* LoadString(LoadState* S)
++{
++ size_t size;
++ LoadVar(S,size);
++ if (size==0)
++ return NULL;
++ else
++ {
++ char* s=luaZ_openspace(S->L,S->b,size);
++ LoadBlock(S,s,size);
++ return luaS_newlstr(S->L,s,size-1); /* remove trailing '\0' */
++ }
++}
++
++static void LoadCode(LoadState* S, Proto* f)
++{
++ int n=LoadInt(S);
++ f->code=luaM_newvector(S->L,n,Instruction);
++ f->sizecode=n;
++ LoadVector(S,f->code,n,sizeof(Instruction));
++}
++
++static Proto* LoadFunction(LoadState* S, TString* p);
++
++static void LoadConstants(LoadState* S, Proto* f)
++{
++ int i,n;
++ n=LoadInt(S);
++ f->k=luaM_newvector(S->L,n,TValue);
++ f->sizek=n;
++ for (i=0; i<n; i++) setnilvalue(&f->k[i]);
++ for (i=0; i<n; i++)
++ {
++ TValue* o=&f->k[i];
++ int t=LoadChar(S);
++ switch (t)
++ {
++ case LUA_TNIL:
++ setnilvalue(o);
++ break;
++ case LUA_TBOOLEAN:
++ setbvalue(o,LoadChar(S)!=0);
++ break;
++ case LUA_TNUMBER:
++ setnvalue(o,LoadNumber(S));
++ break;
++ case LUA_TSTRING:
++ setsvalue2n(S->L,o,LoadString(S));
++ break;
++ default:
++ error(S,"bad constant");
++ break;
++ }
++ }
++ n=LoadInt(S);
++ f->p=luaM_newvector(S->L,n,Proto*);
++ f->sizep=n;
++ for (i=0; i<n; i++) f->p[i]=NULL;
++ for (i=0; i<n; i++) f->p[i]=LoadFunction(S,f->source);
++}
++
++static void LoadDebug(LoadState* S, Proto* f)
++{
++ int i,n;
++ n=LoadInt(S);
++ f->lineinfo=luaM_newvector(S->L,n,int);
++ f->sizelineinfo=n;
++ LoadVector(S,f->lineinfo,n,sizeof(int));
++ n=LoadInt(S);
++ f->locvars=luaM_newvector(S->L,n,LocVar);
++ f->sizelocvars=n;
++ for (i=0; i<n; i++) f->locvars[i].varname=NULL;
++ for (i=0; i<n; i++)
++ {
++ f->locvars[i].varname=LoadString(S);
++ f->locvars[i].startpc=LoadInt(S);
++ f->locvars[i].endpc=LoadInt(S);
++ }
++ n=LoadInt(S);
++ f->upvalues=luaM_newvector(S->L,n,TString*);
++ f->sizeupvalues=n;
++ for (i=0; i<n; i++) f->upvalues[i]=NULL;
++ for (i=0; i<n; i++) f->upvalues[i]=LoadString(S);
++}
++
++static Proto* LoadFunction(LoadState* S, TString* p)
++{
++ Proto* f;
++ if (++S->L->nCcalls > LUAI_MAXCCALLS) error(S,"code too deep");
++ f=luaF_newproto(S->L);
++ setptvalue2s(S->L,S->L->top,f); incr_top(S->L);
++ f->source=LoadString(S); if (f->source==NULL) f->source=p;
++ f->linedefined=LoadInt(S);
++ f->lastlinedefined=LoadInt(S);
++ f->nups=LoadByte(S);
++ f->numparams=LoadByte(S);
++ f->is_vararg=LoadByte(S);
++ f->maxstacksize=LoadByte(S);
++ LoadCode(S,f);
++ LoadConstants(S,f);
++ LoadDebug(S,f);
++ IF (!luaG_checkcode(f), "bad code");
++ S->L->top--;
++ S->L->nCcalls--;
++ return f;
++}
++
++static void LoadHeader(LoadState* S)
++{
++ char h[LUAC_HEADERSIZE];
++ char s[LUAC_HEADERSIZE];
++ luaU_header(h);
++ LoadBlock(S,s,LUAC_HEADERSIZE);
++ IF (memcmp(h,s,LUAC_HEADERSIZE)!=0, "bad header");
++}
++
++/*
++** load precompiled chunk
++*/
++Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name)
++{
++ LoadState S;
++ if (*name=='@' || *name=='=')
++ S.name=name+1;
++ else if (*name==LUA_SIGNATURE[0])
++ S.name="binary string";
++ else
++ S.name=name;
++ S.L=L;
++ S.Z=Z;
++ S.b=buff;
++ LoadHeader(&S);
++ return LoadFunction(&S,luaS_newliteral(L,"=?"));
++}
++
++/*
++* make header
++*/
++void luaU_header (char* h)
++{
++ int x=1;
++ memcpy(h,LUA_SIGNATURE,sizeof(LUA_SIGNATURE)-1);
++ h+=sizeof(LUA_SIGNATURE)-1;
++ *h++=(char)LUAC_VERSION;
++ *h++=(char)LUAC_FORMAT;
++ *h++=(char)*(char*)&x; /* endianness */
++ *h++=(char)sizeof(int);
++ *h++=(char)sizeof(size_t);
++ *h++=(char)sizeof(Instruction);
++ *h++=(char)sizeof(lua_Number);
++ *h++=(char)(((lua_Number)0.5)==0); /* is lua_Number integral? */
++}
+--- /dev/null
++++ b/extensions/LUA/lua/lundump.h
+@@ -0,0 +1,36 @@
++/*
++** $Id: lundump.h,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $
++** load precompiled Lua chunks
++** See Copyright Notice in lua.h
++*/
++
++#ifndef lundump_h
++#define lundump_h
++
++#include "lobject.h"
++#include "lzio.h"
++
++/* load one chunk; from lundump.c */
++LUAI_FUNC Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name);
++
++/* make header; from lundump.c */
++LUAI_FUNC void luaU_header (char* h);
++
++/* dump one chunk; from ldump.c */
++LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip);
++
++#ifdef luac_c
++/* print one chunk; from print.c */
++LUAI_FUNC void luaU_print (const Proto* f, int full);
++#endif
++
++/* for header of binary files -- this is Lua 5.1 */
++#define LUAC_VERSION 0x51
++
++/* for header of binary files -- this is the official format */
++#define LUAC_FORMAT 0
++
++/* size of header of binary files */
++#define LUAC_HEADERSIZE 12
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/lvm.c
+@@ -0,0 +1,762 @@
++/*
++** $Id: lvm.c,v 2.63.1.3 2007/12/28 15:32:23 roberto Exp $
++** Lua virtual machine
++** See Copyright Notice in lua.h
++*/
++
++#include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
++
++#define lvm_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "ldebug.h"
++#include "ldo.h"
++#include "lfunc.h"
++#include "lgc.h"
++#include "lobject.h"
++#include "lopcodes.h"
++#include "lstate.h"
++#include "lstring.h"
++#include "ltable.h"
++#include "ltm.h"
++#include "lvm.h"
++
++
++
++/* limit for table tag-method chains (to avoid loops) */
++#define MAXTAGLOOP 100
++
++
++const TValue *luaV_tonumber (const TValue *obj, TValue *n) {
++ lua_Number num;
++ if (ttisnumber(obj)) return obj;
++ if (ttisstring(obj) && luaO_str2d(svalue(obj), &num)) {
++ setnvalue(n, num);
++ return n;
++ }
++ else
++ return NULL;
++}
++
++
++int luaV_tostring (lua_State *L, StkId obj) {
++ if (!ttisnumber(obj))
++ return 0;
++ else {
++ char s[LUAI_MAXNUMBER2STR];
++ lua_Number n = nvalue(obj);
++ lua_number2str(s, n);
++ setsvalue2s(L, obj, luaS_new(L, s));
++ return 1;
++ }
++}
++
++
++static void traceexec (lua_State *L, const Instruction *pc) {
++ lu_byte mask = L->hookmask;
++ const Instruction *oldpc = L->savedpc;
++ L->savedpc = pc;
++ if ((mask & LUA_MASKCOUNT) && L->hookcount == 0) {
++ resethookcount(L);
++ luaD_callhook(L, LUA_HOOKCOUNT, -1);
++ }
++ if (mask & LUA_MASKLINE) {
++ Proto *p = ci_func(L->ci)->l.p;
++ int npc = pcRel(pc, p);
++ int newline = getline(p, npc);
++ /* call linehook when enter a new function, when jump back (loop),
++ or when enter a new line */
++ if (npc == 0 || pc <= oldpc || newline != getline(p, pcRel(oldpc, p)))
++ luaD_callhook(L, LUA_HOOKLINE, newline);
++ }
++}
++
++
++static void callTMres (lua_State *L, StkId res, const TValue *f,
++ const TValue *p1, const TValue *p2) {
++ ptrdiff_t result = savestack(L, res);
++ setobj2s(L, L->top, f); /* push function */
++ setobj2s(L, L->top+1, p1); /* 1st argument */
++ setobj2s(L, L->top+2, p2); /* 2nd argument */
++ luaD_checkstack(L, 3);
++ L->top += 3;
++ luaD_call(L, L->top - 3, 1);
++ res = restorestack(L, result);
++ L->top--;
++ setobjs2s(L, res, L->top);
++}
++
++
++
++static void callTM (lua_State *L, const TValue *f, const TValue *p1,
++ const TValue *p2, const TValue *p3) {
++ setobj2s(L, L->top, f); /* push function */
++ setobj2s(L, L->top+1, p1); /* 1st argument */
++ setobj2s(L, L->top+2, p2); /* 2nd argument */
++ setobj2s(L, L->top+3, p3); /* 3th argument */
++ luaD_checkstack(L, 4);
++ L->top += 4;
++ luaD_call(L, L->top - 4, 0);
++}
++
++
++void luaV_gettable (lua_State *L, const TValue *t, TValue *key, StkId val) {
++ int loop;
++ for (loop = 0; loop < MAXTAGLOOP; loop++) {
++ const TValue *tm;
++ if (ttistable(t)) { /* `t' is a table? */
++ Table *h = hvalue(t);
++ const TValue *res = luaH_get(h, key); /* do a primitive get */
++ if (!ttisnil(res) || /* result is no nil? */
++ (tm = fasttm(L, h->metatable, TM_INDEX)) == NULL) { /* or no TM? */
++ setobj2s(L, val, res);
++ return;
++ }
++ /* else will try the tag method */
++ }
++ else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_INDEX)))
++ luaG_typeerror(L, t, "index");
++ if (ttisfunction(tm)) {
++ callTMres(L, val, tm, t, key);
++ return;
++ }
++ t = tm; /* else repeat with `tm' */
++ }
++ luaG_runerror(L, "loop in gettable");
++}
++
++
++void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val) {
++ int loop;
++ for (loop = 0; loop < MAXTAGLOOP; loop++) {
++ const TValue *tm;
++ if (ttistable(t)) { /* `t' is a table? */
++ Table *h = hvalue(t);
++ TValue *oldval = luaH_set(L, h, key); /* do a primitive set */
++ if (!ttisnil(oldval) || /* result is no nil? */
++ (tm = fasttm(L, h->metatable, TM_NEWINDEX)) == NULL) { /* or no TM? */
++ setobj2t(L, oldval, val);
++ luaC_barriert(L, h, val);
++ return;
++ }
++ /* else will try the tag method */
++ }
++ else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_NEWINDEX)))
++ luaG_typeerror(L, t, "index");
++ if (ttisfunction(tm)) {
++ callTM(L, tm, t, key, val);
++ return;
++ }
++ t = tm; /* else repeat with `tm' */
++ }
++ luaG_runerror(L, "loop in settable");
++}
++
++
++static int call_binTM (lua_State *L, const TValue *p1, const TValue *p2,
++ StkId res, TMS event) {
++ const TValue *tm = luaT_gettmbyobj(L, p1, event); /* try first operand */
++ if (ttisnil(tm))
++ tm = luaT_gettmbyobj(L, p2, event); /* try second operand */
++ if (ttisnil(tm)) return 0;
++ callTMres(L, res, tm, p1, p2);
++ return 1;
++}
++
++
++static const TValue *get_compTM (lua_State *L, Table *mt1, Table *mt2,
++ TMS event) {
++ const TValue *tm1 = fasttm(L, mt1, event);
++ const TValue *tm2;
++ if (tm1 == NULL) return NULL; /* no metamethod */
++ if (mt1 == mt2) return tm1; /* same metatables => same metamethods */
++ tm2 = fasttm(L, mt2, event);
++ if (tm2 == NULL) return NULL; /* no metamethod */
++ if (luaO_rawequalObj(tm1, tm2)) /* same metamethods? */
++ return tm1;
++ return NULL;
++}
++
++
++static int call_orderTM (lua_State *L, const TValue *p1, const TValue *p2,
++ TMS event) {
++ const TValue *tm1 = luaT_gettmbyobj(L, p1, event);
++ const TValue *tm2;
++ if (ttisnil(tm1)) return -1; /* no metamethod? */
++ tm2 = luaT_gettmbyobj(L, p2, event);
++ if (!luaO_rawequalObj(tm1, tm2)) /* different metamethods? */
++ return -1;
++ callTMres(L, L->top, tm1, p1, p2);
++ return !l_isfalse(L->top);
++}
++
++
++static int l_strcmp (const TString *ls, const TString *rs) {
++ const char *l = getstr(ls);
++ size_t ll = ls->tsv.len;
++ const char *r = getstr(rs);
++ size_t lr = rs->tsv.len;
++ for (;;) {
++ int temp = strcoll(l, r);
++ if (temp != 0) return temp;
++ else { /* strings are equal up to a `\0' */
++ size_t len = strlen(l); /* index of first `\0' in both strings */
++ if (len == lr) /* r is finished? */
++ return (len == ll) ? 0 : 1;
++ else if (len == ll) /* l is finished? */
++ return -1; /* l is smaller than r (because r is not finished) */
++ /* both strings longer than `len'; go on comparing (after the `\0') */
++ len++;
++ l += len; ll -= len; r += len; lr -= len;
++ }
++ }
++}
++
++
++int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r) {
++ int res;
++ if (ttype(l) != ttype(r))
++ return luaG_ordererror(L, l, r);
++ else if (ttisnumber(l))
++ return luai_numlt(nvalue(l), nvalue(r));
++ else if (ttisstring(l))
++ return l_strcmp(rawtsvalue(l), rawtsvalue(r)) < 0;
++ else if ((res = call_orderTM(L, l, r, TM_LT)) != -1)
++ return res;
++ return luaG_ordererror(L, l, r);
++}
++
++
++static int lessequal (lua_State *L, const TValue *l, const TValue *r) {
++ int res;
++ if (ttype(l) != ttype(r))
++ return luaG_ordererror(L, l, r);
++ else if (ttisnumber(l))
++ return luai_numle(nvalue(l), nvalue(r));
++ else if (ttisstring(l))
++ return l_strcmp(rawtsvalue(l), rawtsvalue(r)) <= 0;
++ else if ((res = call_orderTM(L, l, r, TM_LE)) != -1) /* first try `le' */
++ return res;
++ else if ((res = call_orderTM(L, r, l, TM_LT)) != -1) /* else try `lt' */
++ return !res;
++ return luaG_ordererror(L, l, r);
++}
++
++
++int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2) {
++ const TValue *tm;
++ lua_assert(ttype(t1) == ttype(t2));
++ switch (ttype(t1)) {
++ case LUA_TNIL: return 1;
++ case LUA_TNUMBER: return luai_numeq(nvalue(t1), nvalue(t2));
++ case LUA_TBOOLEAN: return bvalue(t1) == bvalue(t2); /* true must be 1 !! */
++ case LUA_TLIGHTUSERDATA: return pvalue(t1) == pvalue(t2);
++ case LUA_TUSERDATA: {
++ if (uvalue(t1) == uvalue(t2)) return 1;
++ tm = get_compTM(L, uvalue(t1)->metatable, uvalue(t2)->metatable,
++ TM_EQ);
++ break; /* will try TM */
++ }
++ case LUA_TTABLE: {
++ if (hvalue(t1) == hvalue(t2)) return 1;
++ tm = get_compTM(L, hvalue(t1)->metatable, hvalue(t2)->metatable, TM_EQ);
++ break; /* will try TM */
++ }
++ default: return gcvalue(t1) == gcvalue(t2);
++ }
++ if (tm == NULL) return 0; /* no TM? */
++ callTMres(L, L->top, tm, t1, t2); /* call TM */
++ return !l_isfalse(L->top);
++}
++
++
++void luaV_concat (lua_State *L, int total, int last) {
++ do {
++ StkId top = L->base + last + 1;
++ int n = 2; /* number of elements handled in this pass (at least 2) */
++ if (!(ttisstring(top-2) || ttisnumber(top-2)) || !tostring(L, top-1)) {
++ if (!call_binTM(L, top-2, top-1, top-2, TM_CONCAT))
++ luaG_concaterror(L, top-2, top-1);
++ } else if (tsvalue(top-1)->len == 0) /* second op is empty? */
++ (void)tostring(L, top - 2); /* result is first op (as string) */
++ else {
++ /* at least two string values; get as many as possible */
++ size_t tl = tsvalue(top-1)->len;
++ char *buffer;
++ int i;
++ /* collect total length */
++ for (n = 1; n < total && tostring(L, top-n-1); n++) {
++ size_t l = tsvalue(top-n-1)->len;
++ if (l >= MAX_SIZET - tl) luaG_runerror(L, "string length overflow");
++ tl += l;
++ }
++ buffer = luaZ_openspace(L, &G(L)->buff, tl);
++ tl = 0;
++ for (i=n; i>0; i--) { /* concat all strings */
++ size_t l = tsvalue(top-i)->len;
++ memcpy(buffer+tl, svalue(top-i), l);
++ tl += l;
++ }
++ setsvalue2s(L, top-n, luaS_newlstr(L, buffer, tl));
++ }
++ total -= n-1; /* got `n' strings to create 1 new */
++ last -= n-1;
++ } while (total > 1); /* repeat until only 1 result left */
++}
++
++
++static void Arith (lua_State *L, StkId ra, const TValue *rb,
++ const TValue *rc, TMS op) {
++ TValue tempb, tempc;
++ const TValue *b, *c;
++ if ((b = luaV_tonumber(rb, &tempb)) != NULL &&
++ (c = luaV_tonumber(rc, &tempc)) != NULL) {
++ lua_Number nb = nvalue(b), nc = nvalue(c);
++ switch (op) {
++ case TM_ADD: setnvalue(ra, luai_numadd(nb, nc)); break;
++ case TM_SUB: setnvalue(ra, luai_numsub(nb, nc)); break;
++ case TM_MUL: setnvalue(ra, luai_nummul(nb, nc)); break;
++ case TM_DIV: setnvalue(ra, luai_numdiv(nb, nc)); break;
++ case TM_MOD: setnvalue(ra, luai_nummod(nb, nc)); break;
++ case TM_POW: setnvalue(ra, luai_numpow(nb, nc)); break;
++ case TM_UNM: setnvalue(ra, luai_numunm(nb)); break;
++ default: lua_assert(0); break;
++ }
++ }
++ else if (!call_binTM(L, rb, rc, ra, op))
++ luaG_aritherror(L, rb, rc);
++}
++
++
++
++/*
++** some macros for common tasks in `luaV_execute'
++*/
++
++#define runtime_check(L, c) { if (!(c)) break; }
++
++#define RA(i) (base+GETARG_A(i))
++/* to be used after possible stack reallocation */
++#define RB(i) check_exp(getBMode(GET_OPCODE(i)) == OpArgR, base+GETARG_B(i))
++#define RC(i) check_exp(getCMode(GET_OPCODE(i)) == OpArgR, base+GETARG_C(i))
++#define RKB(i) check_exp(getBMode(GET_OPCODE(i)) == OpArgK, \
++ ISK(GETARG_B(i)) ? k+INDEXK(GETARG_B(i)) : base+GETARG_B(i))
++#define RKC(i) check_exp(getCMode(GET_OPCODE(i)) == OpArgK, \
++ ISK(GETARG_C(i)) ? k+INDEXK(GETARG_C(i)) : base+GETARG_C(i))
++#define KBx(i) check_exp(getBMode(GET_OPCODE(i)) == OpArgK, k+GETARG_Bx(i))
++
++
++#define dojump(L,pc,i) {(pc) += (i); luai_threadyield(L);}
++
++
++#define Protect(x) { L->savedpc = pc; {x;}; base = L->base; }
++
++
++#define arith_op(op,tm) { \
++ TValue *rb = RKB(i); \
++ TValue *rc = RKC(i); \
++ if (ttisnumber(rb) && ttisnumber(rc)) { \
++ lua_Number nb = nvalue(rb), nc = nvalue(rc); \
++ setnvalue(ra, op(nb, nc)); \
++ } \
++ else \
++ Protect(Arith(L, ra, rb, rc, tm)); \
++ }
++
++
++
++void luaV_execute (lua_State *L, int nexeccalls) {
++ LClosure *cl;
++ StkId base;
++ TValue *k;
++ const Instruction *pc;
++ reentry: /* entry point */
++ lua_assert(isLua(L->ci));
++ pc = L->savedpc;
++ cl = &clvalue(L->ci->func)->l;
++ base = L->base;
++ k = cl->p->k;
++ /* main loop of interpreter */
++ for (;;) {
++ const Instruction i = *pc++;
++ StkId ra;
++ if ((L->hookmask & (LUA_MASKLINE | LUA_MASKCOUNT)) &&
++ (--L->hookcount == 0 || L->hookmask & LUA_MASKLINE)) {
++ traceexec(L, pc);
++ if (L->status == LUA_YIELD) { /* did hook yield? */
++ L->savedpc = pc - 1;
++ return;
++ }
++ base = L->base;
++ }
++ /* warning!! several calls may realloc the stack and invalidate `ra' */
++ ra = RA(i);
++ lua_assert(base == L->base && L->base == L->ci->base);
++ lua_assert(base <= L->top && L->top <= L->stack + L->stacksize);
++ lua_assert(L->top == L->ci->top || luaG_checkopenop(i));
++ switch (GET_OPCODE(i)) {
++ case OP_MOVE: {
++ setobjs2s(L, ra, RB(i));
++ continue;
++ }
++ case OP_LOADK: {
++ setobj2s(L, ra, KBx(i));
++ continue;
++ }
++ case OP_LOADBOOL: {
++ setbvalue(ra, GETARG_B(i));
++ if (GETARG_C(i)) pc++; /* skip next instruction (if C) */
++ continue;
++ }
++ case OP_LOADNIL: {
++ TValue *rb = RB(i);
++ do {
++ setnilvalue(rb--);
++ } while (rb >= ra);
++ continue;
++ }
++ case OP_GETUPVAL: {
++ int b = GETARG_B(i);
++ setobj2s(L, ra, cl->upvals[b]->v);
++ continue;
++ }
++ case OP_GETGLOBAL: {
++ TValue g;
++ TValue *rb = KBx(i);
++ sethvalue(L, &g, cl->env);
++ lua_assert(ttisstring(rb));
++ Protect(luaV_gettable(L, &g, rb, ra));
++ continue;
++ }
++ case OP_GETTABLE: {
++ Protect(luaV_gettable(L, RB(i), RKC(i), ra));
++ continue;
++ }
++ case OP_SETGLOBAL: {
++ TValue g;
++ sethvalue(L, &g, cl->env);
++ lua_assert(ttisstring(KBx(i)));
++ Protect(luaV_settable(L, &g, KBx(i), ra));
++ continue;
++ }
++ case OP_SETUPVAL: {
++ UpVal *uv = cl->upvals[GETARG_B(i)];
++ setobj(L, uv->v, ra);
++ luaC_barrier(L, uv, ra);
++ continue;
++ }
++ case OP_SETTABLE: {
++ Protect(luaV_settable(L, ra, RKB(i), RKC(i)));
++ continue;
++ }
++ case OP_NEWTABLE: {
++ int b = GETARG_B(i);
++ int c = GETARG_C(i);
++ sethvalue(L, ra, luaH_new(L, luaO_fb2int(b), luaO_fb2int(c)));
++ Protect(luaC_checkGC(L));
++ continue;
++ }
++ case OP_SELF: {
++ StkId rb = RB(i);
++ setobjs2s(L, ra+1, rb);
++ Protect(luaV_gettable(L, rb, RKC(i), ra));
++ continue;
++ }
++ case OP_ADD: {
++ arith_op(luai_numadd, TM_ADD);
++ continue;
++ }
++ case OP_SUB: {
++ arith_op(luai_numsub, TM_SUB);
++ continue;
++ }
++ case OP_MUL: {
++ arith_op(luai_nummul, TM_MUL);
++ continue;
++ }
++ case OP_DIV: {
++ arith_op(luai_numdiv, TM_DIV);
++ continue;
++ }
++ case OP_MOD: {
++ arith_op(luai_nummod, TM_MOD);
++ continue;
++ }
++ case OP_POW: {
++ arith_op(luai_numpow, TM_POW);
++ continue;
++ }
++ case OP_UNM: {
++ TValue *rb = RB(i);
++ if (ttisnumber(rb)) {
++ lua_Number nb = nvalue(rb);
++ setnvalue(ra, luai_numunm(nb));
++ }
++ else {
++ Protect(Arith(L, ra, rb, rb, TM_UNM));
++ }
++ continue;
++ }
++ case OP_NOT: {
++ int res = l_isfalse(RB(i)); /* next assignment may change this value */
++ setbvalue(ra, res);
++ continue;
++ }
++ case OP_LEN: {
++ const TValue *rb = RB(i);
++ switch (ttype(rb)) {
++ case LUA_TTABLE: {
++ setnvalue(ra, cast_num(luaH_getn(hvalue(rb))));
++ break;
++ }
++ case LUA_TSTRING: {
++ setnvalue(ra, cast_num(tsvalue(rb)->len));
++ break;
++ }
++ default: { /* try metamethod */
++ Protect(
++ if (!call_binTM(L, rb, luaO_nilobject, ra, TM_LEN))
++ luaG_typeerror(L, rb, "get length of");
++ )
++ }
++ }
++ continue;
++ }
++ case OP_CONCAT: {
++ int b = GETARG_B(i);
++ int c = GETARG_C(i);
++ Protect(luaV_concat(L, c-b+1, c); luaC_checkGC(L));
++ setobjs2s(L, RA(i), base+b);
++ continue;
++ }
++ case OP_JMP: {
++ dojump(L, pc, GETARG_sBx(i));
++ continue;
++ }
++ case OP_EQ: {
++ TValue *rb = RKB(i);
++ TValue *rc = RKC(i);
++ Protect(
++ if (equalobj(L, rb, rc) == GETARG_A(i))
++ dojump(L, pc, GETARG_sBx(*pc));
++ )
++ pc++;
++ continue;
++ }
++ case OP_LT: {
++ Protect(
++ if (luaV_lessthan(L, RKB(i), RKC(i)) == GETARG_A(i))
++ dojump(L, pc, GETARG_sBx(*pc));
++ )
++ pc++;
++ continue;
++ }
++ case OP_LE: {
++ Protect(
++ if (lessequal(L, RKB(i), RKC(i)) == GETARG_A(i))
++ dojump(L, pc, GETARG_sBx(*pc));
++ )
++ pc++;
++ continue;
++ }
++ case OP_TEST: {
++ if (l_isfalse(ra) != GETARG_C(i))
++ dojump(L, pc, GETARG_sBx(*pc));
++ pc++;
++ continue;
++ }
++ case OP_TESTSET: {
++ TValue *rb = RB(i);
++ if (l_isfalse(rb) != GETARG_C(i)) {
++ setobjs2s(L, ra, rb);
++ dojump(L, pc, GETARG_sBx(*pc));
++ }
++ pc++;
++ continue;
++ }
++ case OP_CALL: {
++ int b = GETARG_B(i);
++ int nresults = GETARG_C(i) - 1;
++ if (b != 0) L->top = ra+b; /* else previous instruction set top */
++ L->savedpc = pc;
++ switch (luaD_precall(L, ra, nresults)) {
++ case PCRLUA: {
++ nexeccalls++;
++ goto reentry; /* restart luaV_execute over new Lua function */
++ }
++ case PCRC: {
++ /* it was a C function (`precall' called it); adjust results */
++ if (nresults >= 0) L->top = L->ci->top;
++ base = L->base;
++ continue;
++ }
++ default: {
++ return; /* yield */
++ }
++ }
++ }
++ case OP_TAILCALL: {
++ int b = GETARG_B(i);
++ if (b != 0) L->top = ra+b; /* else previous instruction set top */
++ L->savedpc = pc;
++ lua_assert(GETARG_C(i) - 1 == LUA_MULTRET);
++ switch (luaD_precall(L, ra, LUA_MULTRET)) {
++ case PCRLUA: {
++ /* tail call: put new frame in place of previous one */
++ CallInfo *ci = L->ci - 1; /* previous frame */
++ int aux;
++ StkId func = ci->func;
++ StkId pfunc = (ci+1)->func; /* previous function index */
++ if (L->openupval) luaF_close(L, ci->base);
++ L->base = ci->base = ci->func + ((ci+1)->base - pfunc);
++ for (aux = 0; pfunc+aux < L->top; aux++) /* move frame down */
++ setobjs2s(L, func+aux, pfunc+aux);
++ ci->top = L->top = func+aux; /* correct top */
++ lua_assert(L->top == L->base + clvalue(func)->l.p->maxstacksize);
++ ci->savedpc = L->savedpc;
++ ci->tailcalls++; /* one more call lost */
++ L->ci--; /* remove new frame */
++ goto reentry;
++ }
++ case PCRC: { /* it was a C function (`precall' called it) */
++ base = L->base;
++ continue;
++ }
++ default: {
++ return; /* yield */
++ }
++ }
++ }
++ case OP_RETURN: {
++ int b = GETARG_B(i);
++ if (b != 0) L->top = ra+b-1;
++ if (L->openupval) luaF_close(L, base);
++ L->savedpc = pc;
++ b = luaD_poscall(L, ra);
++ if (--nexeccalls == 0) /* was previous function running `here'? */
++ return; /* no: return */
++ else { /* yes: continue its execution */
++ if (b) L->top = L->ci->top;
++ lua_assert(isLua(L->ci));
++ lua_assert(GET_OPCODE(*((L->ci)->savedpc - 1)) == OP_CALL);
++ goto reentry;
++ }
++ }
++ case OP_FORLOOP: {
++ lua_Number step = nvalue(ra+2);
++ lua_Number idx = luai_numadd(nvalue(ra), step); /* increment index */
++ lua_Number limit = nvalue(ra+1);
++ if (luai_numlt(0, step) ? luai_numle(idx, limit)
++ : luai_numle(limit, idx)) {
++ dojump(L, pc, GETARG_sBx(i)); /* jump back */
++ setnvalue(ra, idx); /* update internal index... */
++ setnvalue(ra+3, idx); /* ...and external index */
++ }
++ continue;
++ }
++ case OP_FORPREP: {
++ const TValue *init = ra;
++ const TValue *plimit = ra+1;
++ const TValue *pstep = ra+2;
++ L->savedpc = pc; /* next steps may throw errors */
++ if (!tonumber(init, ra))
++ luaG_runerror(L, LUA_QL("for") " initial value must be a number");
++ else if (!tonumber(plimit, ra+1))
++ luaG_runerror(L, LUA_QL("for") " limit must be a number");
++ else if (!tonumber(pstep, ra+2))
++ luaG_runerror(L, LUA_QL("for") " step must be a number");
++ setnvalue(ra, luai_numsub(nvalue(ra), nvalue(pstep)));
++ dojump(L, pc, GETARG_sBx(i));
++ continue;
++ }
++ case OP_TFORLOOP: {
++ StkId cb = ra + 3; /* call base */
++ setobjs2s(L, cb+2, ra+2);
++ setobjs2s(L, cb+1, ra+1);
++ setobjs2s(L, cb, ra);
++ L->top = cb+3; /* func. + 2 args (state and index) */
++ Protect(luaD_call(L, cb, GETARG_C(i)));
++ L->top = L->ci->top;
++ cb = RA(i) + 3; /* previous call may change the stack */
++ if (!ttisnil(cb)) { /* continue loop? */
++ setobjs2s(L, cb-1, cb); /* save control variable */
++ dojump(L, pc, GETARG_sBx(*pc)); /* jump back */
++ }
++ pc++;
++ continue;
++ }
++ case OP_SETLIST: {
++ int n = GETARG_B(i);
++ int c = GETARG_C(i);
++ int last;
++ Table *h;
++ if (n == 0) {
++ n = cast_int(L->top - ra) - 1;
++ L->top = L->ci->top;
++ }
++ if (c == 0) c = cast_int(*pc++);
++ runtime_check(L, ttistable(ra));
++ h = hvalue(ra);
++ last = ((c-1)*LFIELDS_PER_FLUSH) + n;
++ if (last > h->sizearray) /* needs more space? */
++ luaH_resizearray(L, h, last); /* pre-alloc it at once */
++ for (; n > 0; n--) {
++ TValue *val = ra+n;
++ setobj2t(L, luaH_setnum(L, h, last--), val);
++ luaC_barriert(L, h, val);
++ }
++ continue;
++ }
++ case OP_CLOSE: {
++ luaF_close(L, ra);
++ continue;
++ }
++ case OP_CLOSURE: {
++ Proto *p;
++ Closure *ncl;
++ int nup, j;
++ p = cl->p->p[GETARG_Bx(i)];
++ nup = p->nups;
++ ncl = luaF_newLclosure(L, nup, cl->env);
++ ncl->l.p = p;
++ for (j=0; j<nup; j++, pc++) {
++ if (GET_OPCODE(*pc) == OP_GETUPVAL)
++ ncl->l.upvals[j] = cl->upvals[GETARG_B(*pc)];
++ else {
++ lua_assert(GET_OPCODE(*pc) == OP_MOVE);
++ ncl->l.upvals[j] = luaF_findupval(L, base + GETARG_B(*pc));
++ }
++ }
++ setclvalue(L, ra, ncl);
++ Protect(luaC_checkGC(L));
++ continue;
++ }
++ case OP_VARARG: {
++ int b = GETARG_B(i) - 1;
++ int j;
++ CallInfo *ci = L->ci;
++ int n = cast_int(ci->base - ci->func) - cl->p->numparams - 1;
++ if (b == LUA_MULTRET) {
++ Protect(luaD_checkstack(L, n));
++ ra = RA(i); /* previous call may change the stack */
++ b = n;
++ L->top = ra + n;
++ }
++ for (j = 0; j < b; j++) {
++ if (j < n) {
++ setobjs2s(L, ra + j, ci->base - n + j);
++ }
++ else {
++ setnilvalue(ra + j);
++ }
++ }
++ continue;
++ }
++ }
++ }
++}
++
+--- /dev/null
++++ b/extensions/LUA/lua/lvm.h
+@@ -0,0 +1,36 @@
++/*
++** $Id: lvm.h,v 2.5.1.1 2007/12/27 13:02:25 roberto Exp $
++** Lua virtual machine
++** See Copyright Notice in lua.h
++*/
++
++#ifndef lvm_h
++#define lvm_h
++
++
++#include "ldo.h"
++#include "lobject.h"
++#include "ltm.h"
++
++
++#define tostring(L,o) ((ttype(o) == LUA_TSTRING) || (luaV_tostring(L, o)))
++
++#define tonumber(o,n) (ttype(o) == LUA_TNUMBER || \
++ (((o) = luaV_tonumber(o,n)) != NULL))
++
++#define equalobj(L,o1,o2) \
++ (ttype(o1) == ttype(o2) && luaV_equalval(L, o1, o2))
++
++
++LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r);
++LUAI_FUNC int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2);
++LUAI_FUNC const TValue *luaV_tonumber (const TValue *obj, TValue *n);
++LUAI_FUNC int luaV_tostring (lua_State *L, StkId obj);
++LUAI_FUNC void luaV_gettable (lua_State *L, const TValue *t, TValue *key,
++ StkId val);
++LUAI_FUNC void luaV_settable (lua_State *L, const TValue *t, TValue *key,
++ StkId val);
++LUAI_FUNC void luaV_execute (lua_State *L, int nexeccalls);
++LUAI_FUNC void luaV_concat (lua_State *L, int total, int last);
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/lzio.c
+@@ -0,0 +1,81 @@
++/*
++** $Id: lzio.c,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $
++** a generic input stream interface
++** See Copyright Notice in lua.h
++*/
++
++#include <string.h>
++
++#define lzio_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "llimits.h"
++#include "lmem.h"
++#include "lstate.h"
++#include "lzio.h"
++
++
++int luaZ_fill (ZIO *z) {
++ size_t size;
++ lua_State *L = z->L;
++ const char *buff;
++ lua_unlock(L);
++ buff = z->reader(L, z->data, &size);
++ lua_lock(L);
++ if (buff == NULL || size == 0) return EOZ;
++ z->n = size - 1;
++ z->p = buff;
++ return char2int(*(z->p++));
++}
++
++
++int luaZ_lookahead (ZIO *z) {
++ if (z->n == 0) {
++ if (luaZ_fill(z) == EOZ)
++ return EOZ;
++ else {
++ z->n++; /* luaZ_fill removed first byte; put back it */
++ z->p--;
++ }
++ }
++ return char2int(*z->p);
++}
++
++
++void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) {
++ z->L = L;
++ z->reader = reader;
++ z->data = data;
++ z->n = 0;
++ z->p = NULL;
++}
++
++
++/* --------------------------------------------------------------- read --- */
++size_t luaZ_read (ZIO *z, void *b, size_t n) {
++ while (n) {
++ size_t m;
++ if (luaZ_lookahead(z) == EOZ)
++ return n; /* return number of missing bytes */
++ m = (n <= z->n) ? n : z->n; /* min. between n and z->n */
++ memcpy(b, z->p, m);
++ z->n -= m;
++ z->p += m;
++ b = (char *)b + m;
++ n -= m;
++ }
++ return 0;
++}
++
++/* ------------------------------------------------------------------------ */
++char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n) {
++ if (n > buff->buffsize) {
++ if (n < LUA_MINBUFFER) n = LUA_MINBUFFER;
++ luaZ_resizebuffer(L, buff, n);
++ }
++ return buff->buffer;
++}
++
++
+--- /dev/null
++++ b/extensions/LUA/lua/lzio.h
+@@ -0,0 +1,67 @@
++/*
++** $Id: lzio.h,v 1.21.1.1 2007/12/27 13:02:25 roberto Exp $
++** Buffered streams
++** See Copyright Notice in lua.h
++*/
++
++
++#ifndef lzio_h
++#define lzio_h
++
++#include "lua.h"
++
++#include "lmem.h"
++
++
++#define EOZ (-1) /* end of stream */
++
++typedef struct Zio ZIO;
++
++#define char2int(c) cast(int, cast(unsigned char, (c)))
++
++#define zgetc(z) (((z)->n--)>0 ? char2int(*(z)->p++) : luaZ_fill(z))
++
++typedef struct Mbuffer {
++ char *buffer;
++ size_t n;
++ size_t buffsize;
++} Mbuffer;
++
++#define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0)
++
++#define luaZ_buffer(buff) ((buff)->buffer)
++#define luaZ_sizebuffer(buff) ((buff)->buffsize)
++#define luaZ_bufflen(buff) ((buff)->n)
++
++#define luaZ_resetbuffer(buff) ((buff)->n = 0)
++
++
++#define luaZ_resizebuffer(L, buff, size) \
++ (luaM_reallocvector(L, (buff)->buffer, (buff)->buffsize, size, char), \
++ (buff)->buffsize = size)
++
++#define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0)
++
++
++LUAI_FUNC char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n);
++LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader,
++ void *data);
++LUAI_FUNC size_t luaZ_read (ZIO* z, void* b, size_t n); /* read next n bytes */
++LUAI_FUNC int luaZ_lookahead (ZIO *z);
++
++
++
++/* --------- Private Part ------------------ */
++
++struct Zio {
++ size_t n; /* bytes still unread */
++ const char *p; /* current position in buffer */
++ lua_Reader reader;
++ void* data; /* additional data */
++ lua_State *L; /* Lua state (for reader) */
++};
++
++
++LUAI_FUNC int luaZ_fill (ZIO *z);
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/Makefile
+@@ -0,0 +1,389 @@
++# Makefile.in generated by automake 1.11.1 from Makefile.am.
++# extensions/LUA/Makefile. Generated from Makefile.in by configure.
++
++# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
++# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
++# Inc.
++# This Makefile.in is free software; the Free Software Foundation
++# gives unlimited permission to copy and/or distribute it,
++# with or without modifications, as long as this notice is preserved.
++
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
++# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
++# PARTICULAR PURPOSE.
++
++
++
++# -*- Makefile -*-
++# AUTOMAKE
++
++pkgdatadir = $(datadir)/xtables-addons
++pkgincludedir = $(includedir)/xtables-addons
++pkglibdir = $(libdir)/xtables-addons
++pkglibexecdir = $(libexecdir)/xtables-addons
++am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
++install_sh_DATA = $(install_sh) -c -m 644
++install_sh_PROGRAM = $(install_sh) -c
++install_sh_SCRIPT = $(install_sh) -c
++INSTALL_HEADER = $(INSTALL_DATA)
++transform = $(program_transform_name)
++NORMAL_INSTALL = :
++PRE_INSTALL = :
++POST_INSTALL = :
++NORMAL_UNINSTALL = :
++PRE_UNINSTALL = :
++POST_UNINSTALL = :
++build_triplet = i686-pc-linux-gnu
++host_triplet = i686-pc-linux-gnu
++DIST_COMMON = $(srcdir)/../../Makefile.extra $(srcdir)/Makefile.am \
++ $(srcdir)/Makefile.in
++subdir = extensions/LUA
++ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
++am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
++ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
++ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
++ $(top_srcdir)/configure.ac
++am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
++ $(ACLOCAL_M4)
++mkinstalldirs = $(install_sh) -d
++CONFIG_HEADER = $(top_builddir)/config.h
++CONFIG_CLEAN_FILES =
++CONFIG_CLEAN_VPATH_FILES =
++SOURCES =
++DIST_SOURCES =
++DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
++ACLOCAL = ${SHELL} /home/andre/Dropbox/xtables-addons/missing --run aclocal-1.11
++AMTAR = ${SHELL} /home/andre/Dropbox/xtables-addons/missing --run tar
++AR = ar
++AUTOCONF = ${SHELL} /home/andre/Dropbox/xtables-addons/missing --run autoconf
++AUTOHEADER = ${SHELL} /home/andre/Dropbox/xtables-addons/missing --run autoheader
++AUTOMAKE = ${SHELL} /home/andre/Dropbox/xtables-addons/missing --run automake-1.11
++AWK = mawk
++CC = gcc
++CCDEPMODE = depmode=gcc3
++CFLAGS = -g -O2
++CPP = gcc -E
++CPPFLAGS =
++CYGPATH_W = echo
++DEFS = -DHAVE_CONFIG_H
++DEPDIR = .deps
++DSYMUTIL =
++DUMPBIN =
++ECHO_C =
++ECHO_N = -n
++ECHO_T =
++EGREP = /bin/grep -E
++EXEEXT =
++FGREP = /bin/grep -F
++GREP = /bin/grep
++INSTALL = /usr/bin/install -c
++INSTALL_DATA = ${INSTALL} -m 644
++INSTALL_PROGRAM = ${INSTALL}
++INSTALL_SCRIPT = ${INSTALL}
++INSTALL_STRIP_PROGRAM = $(install_sh) -c -s
++LD = /usr/bin/ld
++LDFLAGS =
++LIBOBJS =
++LIBS =
++LIBTOOL = $(SHELL) $(top_builddir)/libtool
++LIPO =
++LN_S = ln -s
++LTLIBOBJS =
++MAKEINFO = ${SHELL} /home/andre/Dropbox/xtables-addons/missing --run makeinfo
++MKDIR_P = /bin/mkdir -p
++NM = /usr/bin/nm -B
++NMEDIT =
++OBJDUMP = objdump
++OBJEXT = o
++OTOOL =
++OTOOL64 =
++PACKAGE = xtables-addons
++PACKAGE_BUGREPORT =
++PACKAGE_NAME = xtables-addons
++PACKAGE_STRING = xtables-addons 1.21
++PACKAGE_TARNAME = xtables-addons
++PACKAGE_URL =
++PACKAGE_VERSION = 1.21
++PATH_SEPARATOR = :
++PKG_CONFIG = /usr/bin/pkg-config
++RANLIB = ranlib
++SED = /bin/sed
++SET_MAKE =
++SHELL = /bin/bash
++STRIP = strip
++VERSION = 1.21
++abs_builddir = /home/andre/Dropbox/xtables-addons/extensions/LUA
++abs_srcdir = /home/andre/Dropbox/xtables-addons/extensions/LUA
++abs_top_builddir = /home/andre/Dropbox/xtables-addons
++abs_top_srcdir = /home/andre/Dropbox/xtables-addons
++ac_ct_CC = gcc
++ac_ct_DUMPBIN =
++am__include = include
++am__leading_dot = .
++am__quote =
++am__tar = ${AMTAR} chof - "$$tardir"
++am__untar = ${AMTAR} xf -
++bindir = ${exec_prefix}/bin
++build = i686-pc-linux-gnu
++build_alias =
++build_cpu = i686
++build_os = linux-gnu
++build_vendor = pc
++builddir = .
++datadir = ${datarootdir}
++datarootdir = ${prefix}/share
++docdir = ${datarootdir}/doc/${PACKAGE_TARNAME}
++dvidir = ${docdir}
++exec_prefix = ${prefix}
++host = i686-pc-linux-gnu
++host_alias =
++host_cpu = i686
++host_os = linux-gnu
++host_vendor = pc
++htmldir = ${docdir}
++includedir = ${prefix}/include
++infodir = ${datarootdir}/info
++install_sh = ${SHELL} /home/andre/Dropbox/xtables-addons/install-sh
++kbuilddir = /lib/modules/2.6.33-020633-generic/build
++kinclude_CFLAGS = -I /lib/modules/2.6.33-020633-generic/build/include
++ksourcedir =
++libdir = ${exec_prefix}/lib
++libexecdir = ${exec_prefix}/libexec
++libxtables_CFLAGS =
++libxtables_LIBS = -L/lib -lxtables
++localedir = ${datarootdir}/locale
++localstatedir = ${prefix}/var
++lt_ECHO = echo
++mandir = ${datarootdir}/man
++mkdir_p = /bin/mkdir -p
++oldincludedir = /usr/include
++pdfdir = ${docdir}
++prefix = /usr/local
++program_transform_name = s,x,x,
++psdir = ${docdir}
++regular_CFLAGS = -D_LARGEFILE_SOURCE=1 -D_LARGE_FILES -D_FILE_OFFSET_BITS=64 -D_REENTRANT -Wall -Waggregate-return -Wmissing-declarations -Wmissing-prototypes -Wredundant-decls -Wshadow -Wstrict-prototypes -Winline -pipe -DXTABLES_LIBDIR=\"${xtlibdir}\"
++sbindir = ${exec_prefix}/sbin
++sharedstatedir = ${prefix}/com
++srcdir = .
++sysconfdir = ${prefix}/etc
++target_alias =
++top_build_prefix = ../../
++top_builddir = ../..
++top_srcdir = ../..
++xtlibdir = ${libexecdir}/xtables
++XA_SRCDIR = ${srcdir}
++XA_TOPSRCDIR = ${top_srcdir}
++XA_ABSTOPSRCDIR = ${abs_top_srcdir}
++_mcall = -f ${top_builddir}/Makefile.iptrules
++all: all-am
++
++.SUFFIXES:
++$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(srcdir)/../../Makefile.extra $(am__configure_deps)
++ @for dep in $?; do \
++ case '$(am__configure_deps)' in \
++ *$$dep*) \
++ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
++ && { if test -f $@; then exit 0; else break; fi; }; \
++ exit 1;; \
++ esac; \
++ done; \
++ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign extensions/LUA/Makefile'; \
++ $(am__cd) $(top_srcdir) && \
++ $(AUTOMAKE) --foreign extensions/LUA/Makefile
++.PRECIOUS: Makefile
++Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
++ @case '$?' in \
++ *config.status*) \
++ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
++ *) \
++ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
++ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
++ esac;
++
++$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
++ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
++
++$(top_srcdir)/configure: $(am__configure_deps)
++ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
++$(ACLOCAL_M4): $(am__aclocal_m4_deps)
++ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
++$(am__aclocal_m4_deps):
++
++mostlyclean-libtool:
++ -rm -f *.lo
++
++clean-libtool:
++ -rm -rf .libs _libs
++tags: TAGS
++TAGS:
++
++ctags: CTAGS
++CTAGS:
++
++
++distdir: $(DISTFILES)
++ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
++ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
++ list='$(DISTFILES)'; \
++ dist_files=`for file in $$list; do echo $$file; done | \
++ sed -e "s|^$$srcdirstrip/||;t" \
++ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
++ case $$dist_files in \
++ */*) $(MKDIR_P) `echo "$$dist_files" | \
++ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
++ sort -u` ;; \
++ esac; \
++ for file in $$dist_files; do \
++ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
++ if test -d $$d/$$file; then \
++ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
++ if test -d "$(distdir)/$$file"; then \
++ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
++ fi; \
++ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
++ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
++ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
++ fi; \
++ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
++ else \
++ test -f "$(distdir)/$$file" \
++ || cp -p $$d/$$file "$(distdir)/$$file" \
++ || exit 1; \
++ fi; \
++ done
++check-am: all-am
++check: check-am
++all-am: Makefile all-local
++installdirs:
++install: install-am
++install-exec: install-exec-am
++install-data: install-data-am
++uninstall: uninstall-am
++
++install-am: all-am
++ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
++
++installcheck: installcheck-am
++install-strip:
++ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
++ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
++ `test -z '$(STRIP)' || \
++ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
++mostlyclean-generic:
++
++clean-generic:
++
++distclean-generic:
++ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
++ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
++
++maintainer-clean-generic:
++ @echo "This command is intended for maintainers to use"
++ @echo "it deletes files that may require special tools to rebuild."
++clean: clean-am
++
++clean-am: clean-generic clean-libtool clean-local mostlyclean-am
++
++distclean: distclean-am
++ -rm -f Makefile
++distclean-am: clean-am distclean-generic
++
++dvi: dvi-am
++
++dvi-am:
++
++html: html-am
++
++html-am:
++
++info: info-am
++
++info-am:
++
++install-data-am:
++
++install-dvi: install-dvi-am
++
++install-dvi-am:
++
++install-exec-am: install-exec-local
++
++install-html: install-html-am
++
++install-html-am:
++
++install-info: install-info-am
++
++install-info-am:
++
++install-man:
++
++install-pdf: install-pdf-am
++
++install-pdf-am:
++
++install-ps: install-ps-am
++
++install-ps-am:
++
++installcheck-am:
++
++maintainer-clean: maintainer-clean-am
++ -rm -f Makefile
++maintainer-clean-am: distclean-am maintainer-clean-generic
++
++mostlyclean: mostlyclean-am
++
++mostlyclean-am: mostlyclean-generic mostlyclean-libtool
++
++pdf: pdf-am
++
++pdf-am:
++
++ps: ps-am
++
++ps-am:
++
++uninstall-am:
++
++.MAKE: install-am install-strip
++
++.PHONY: all all-am all-local check check-am clean clean-generic \
++ clean-libtool clean-local distclean distclean-generic \
++ distclean-libtool distdir dvi dvi-am html html-am info info-am \
++ install install-am install-data install-data-am install-dvi \
++ install-dvi-am install-exec install-exec-am install-exec-local \
++ install-html install-html-am install-info install-info-am \
++ install-man install-pdf install-pdf-am install-ps \
++ install-ps-am install-strip installcheck installcheck-am \
++ installdirs maintainer-clean maintainer-clean-generic \
++ mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \
++ ps ps-am uninstall uninstall-am
++
++export XA_SRCDIR
++export XA_TOPSRCDIR
++export XA_ABSTOPSRCDIR
++
++all-local: user-all-local
++
++install-exec-local: user-install-local
++
++clean-local: user-clean-local
++
++user-all-local:
++ ${MAKE} ${_mcall} all;
++
++# Have no user-install-data-local ATM
++user-install-local: user-install-exec-local
++
++user-install-exec-local:
++ ${MAKE} ${_mcall} install;
++
++user-clean-local:
++ ${MAKE} ${_mcall} clean;
++
++# Tell versions [3.59,3.63) of GNU make to not export all variables.
++# Otherwise a system limit (for SysV at least) may be exceeded.
++.NOEXPORT:
++
+--- /dev/null
++++ b/extensions/LUA/Makefile.am
+@@ -0,0 +1 @@
++include ../../Makefile.extra
+--- /dev/null
++++ b/extensions/LUA/Makefile.in
+@@ -0,0 +1,389 @@
++# Makefile.in generated by automake 1.11.1 from Makefile.am.
++# @configure_input@
++
++# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
++# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
++# Inc.
++# This Makefile.in is free software; the Free Software Foundation
++# gives unlimited permission to copy and/or distribute it,
++# with or without modifications, as long as this notice is preserved.
++
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
++# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
++# PARTICULAR PURPOSE.
++
++@SET_MAKE@
++
++# -*- Makefile -*-
++# AUTOMAKE
++VPATH = @srcdir@
++pkgdatadir = $(datadir)/@PACKAGE@
++pkgincludedir = $(includedir)/@PACKAGE@
++pkglibdir = $(libdir)/@PACKAGE@
++pkglibexecdir = $(libexecdir)/@PACKAGE@
++am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
++install_sh_DATA = $(install_sh) -c -m 644
++install_sh_PROGRAM = $(install_sh) -c
++install_sh_SCRIPT = $(install_sh) -c
++INSTALL_HEADER = $(INSTALL_DATA)
++transform = $(program_transform_name)
++NORMAL_INSTALL = :
++PRE_INSTALL = :
++POST_INSTALL = :
++NORMAL_UNINSTALL = :
++PRE_UNINSTALL = :
++POST_UNINSTALL = :
++build_triplet = @build@
++host_triplet = @host@
++DIST_COMMON = $(srcdir)/../../Makefile.extra $(srcdir)/Makefile.am \
++ $(srcdir)/Makefile.in
++subdir = extensions/LUA
++ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
++am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
++ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
++ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
++ $(top_srcdir)/configure.ac
++am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
++ $(ACLOCAL_M4)
++mkinstalldirs = $(install_sh) -d
++CONFIG_HEADER = $(top_builddir)/config.h
++CONFIG_CLEAN_FILES =
++CONFIG_CLEAN_VPATH_FILES =
++SOURCES =
++DIST_SOURCES =
++DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
++ACLOCAL = @ACLOCAL@
++AMTAR = @AMTAR@
++AR = @AR@
++AUTOCONF = @AUTOCONF@
++AUTOHEADER = @AUTOHEADER@
++AUTOMAKE = @AUTOMAKE@
++AWK = @AWK@
++CC = @CC@
++CCDEPMODE = @CCDEPMODE@
++CFLAGS = @CFLAGS@
++CPP = @CPP@
++CPPFLAGS = @CPPFLAGS@
++CYGPATH_W = @CYGPATH_W@
++DEFS = @DEFS@
++DEPDIR = @DEPDIR@
++DSYMUTIL = @DSYMUTIL@
++DUMPBIN = @DUMPBIN@
++ECHO_C = @ECHO_C@
++ECHO_N = @ECHO_N@
++ECHO_T = @ECHO_T@
++EGREP = @EGREP@
++EXEEXT = @EXEEXT@
++FGREP = @FGREP@
++GREP = @GREP@
++INSTALL = @INSTALL@
++INSTALL_DATA = @INSTALL_DATA@
++INSTALL_PROGRAM = @INSTALL_PROGRAM@
++INSTALL_SCRIPT = @INSTALL_SCRIPT@
++INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
++LD = @LD@
++LDFLAGS = @LDFLAGS@
++LIBOBJS = @LIBOBJS@
++LIBS = @LIBS@
++LIBTOOL = @LIBTOOL@
++LIPO = @LIPO@
++LN_S = @LN_S@
++LTLIBOBJS = @LTLIBOBJS@
++MAKEINFO = @MAKEINFO@
++MKDIR_P = @MKDIR_P@
++NM = @NM@
++NMEDIT = @NMEDIT@
++OBJDUMP = @OBJDUMP@
++OBJEXT = @OBJEXT@
++OTOOL = @OTOOL@
++OTOOL64 = @OTOOL64@
++PACKAGE = @PACKAGE@
++PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
++PACKAGE_NAME = @PACKAGE_NAME@
++PACKAGE_STRING = @PACKAGE_STRING@
++PACKAGE_TARNAME = @PACKAGE_TARNAME@
++PACKAGE_URL = @PACKAGE_URL@
++PACKAGE_VERSION = @PACKAGE_VERSION@
++PATH_SEPARATOR = @PATH_SEPARATOR@
++PKG_CONFIG = @PKG_CONFIG@
++RANLIB = @RANLIB@
++SED = @SED@
++SET_MAKE = @SET_MAKE@
++SHELL = @SHELL@
++STRIP = @STRIP@
++VERSION = @VERSION@
++abs_builddir = @abs_builddir@
++abs_srcdir = @abs_srcdir@
++abs_top_builddir = @abs_top_builddir@
++abs_top_srcdir = @abs_top_srcdir@
++ac_ct_CC = @ac_ct_CC@
++ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
++am__include = @am__include@
++am__leading_dot = @am__leading_dot@
++am__quote = @am__quote@
++am__tar = @am__tar@
++am__untar = @am__untar@
++bindir = @bindir@
++build = @build@
++build_alias = @build_alias@
++build_cpu = @build_cpu@
++build_os = @build_os@
++build_vendor = @build_vendor@
++builddir = @builddir@
++datadir = @datadir@
++datarootdir = @datarootdir@
++docdir = @docdir@
++dvidir = @dvidir@
++exec_prefix = @exec_prefix@
++host = @host@
++host_alias = @host_alias@
++host_cpu = @host_cpu@
++host_os = @host_os@
++host_vendor = @host_vendor@
++htmldir = @htmldir@
++includedir = @includedir@
++infodir = @infodir@
++install_sh = @install_sh@
++kbuilddir = @kbuilddir@
++kinclude_CFLAGS = @kinclude_CFLAGS@
++ksourcedir = @ksourcedir@
++libdir = @libdir@
++libexecdir = @libexecdir@
++libxtables_CFLAGS = @libxtables_CFLAGS@
++libxtables_LIBS = @libxtables_LIBS@
++localedir = @localedir@
++localstatedir = @localstatedir@
++lt_ECHO = @lt_ECHO@
++mandir = @mandir@
++mkdir_p = @mkdir_p@
++oldincludedir = @oldincludedir@
++pdfdir = @pdfdir@
++prefix = @prefix@
++program_transform_name = @program_transform_name@
++psdir = @psdir@
++regular_CFLAGS = @regular_CFLAGS@
++sbindir = @sbindir@
++sharedstatedir = @sharedstatedir@
++srcdir = @srcdir@
++sysconfdir = @sysconfdir@
++target_alias = @target_alias@
++top_build_prefix = @top_build_prefix@
++top_builddir = @top_builddir@
++top_srcdir = @top_srcdir@
++xtlibdir = @xtlibdir@
++XA_SRCDIR = ${srcdir}
++XA_TOPSRCDIR = ${top_srcdir}
++XA_ABSTOPSRCDIR = ${abs_top_srcdir}
++_mcall = -f ${top_builddir}/Makefile.iptrules
++all: all-am
++
++.SUFFIXES:
++$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(srcdir)/../../Makefile.extra $(am__configure_deps)
++ @for dep in $?; do \
++ case '$(am__configure_deps)' in \
++ *$$dep*) \
++ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
++ && { if test -f $@; then exit 0; else break; fi; }; \
++ exit 1;; \
++ esac; \
++ done; \
++ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign extensions/LUA/Makefile'; \
++ $(am__cd) $(top_srcdir) && \
++ $(AUTOMAKE) --foreign extensions/LUA/Makefile
++.PRECIOUS: Makefile
++Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
++ @case '$?' in \
++ *config.status*) \
++ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
++ *) \
++ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
++ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
++ esac;
++
++$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
++ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
++
++$(top_srcdir)/configure: $(am__configure_deps)
++ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
++$(ACLOCAL_M4): $(am__aclocal_m4_deps)
++ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
++$(am__aclocal_m4_deps):
++
++mostlyclean-libtool:
++ -rm -f *.lo
++
++clean-libtool:
++ -rm -rf .libs _libs
++tags: TAGS
++TAGS:
++
++ctags: CTAGS
++CTAGS:
++
++
++distdir: $(DISTFILES)
++ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
++ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
++ list='$(DISTFILES)'; \
++ dist_files=`for file in $$list; do echo $$file; done | \
++ sed -e "s|^$$srcdirstrip/||;t" \
++ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
++ case $$dist_files in \
++ */*) $(MKDIR_P) `echo "$$dist_files" | \
++ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
++ sort -u` ;; \
++ esac; \
++ for file in $$dist_files; do \
++ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
++ if test -d $$d/$$file; then \
++ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
++ if test -d "$(distdir)/$$file"; then \
++ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
++ fi; \
++ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
++ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
++ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
++ fi; \
++ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
++ else \
++ test -f "$(distdir)/$$file" \
++ || cp -p $$d/$$file "$(distdir)/$$file" \
++ || exit 1; \
++ fi; \
++ done
++check-am: all-am
++check: check-am
++all-am: Makefile all-local
++installdirs:
++install: install-am
++install-exec: install-exec-am
++install-data: install-data-am
++uninstall: uninstall-am
++
++install-am: all-am
++ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
++
++installcheck: installcheck-am
++install-strip:
++ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
++ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
++ `test -z '$(STRIP)' || \
++ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
++mostlyclean-generic:
++
++clean-generic:
++
++distclean-generic:
++ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
++ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
++
++maintainer-clean-generic:
++ @echo "This command is intended for maintainers to use"
++ @echo "it deletes files that may require special tools to rebuild."
++clean: clean-am
++
++clean-am: clean-generic clean-libtool clean-local mostlyclean-am
++
++distclean: distclean-am
++ -rm -f Makefile
++distclean-am: clean-am distclean-generic
++
++dvi: dvi-am
++
++dvi-am:
++
++html: html-am
++
++html-am:
++
++info: info-am
++
++info-am:
++
++install-data-am:
++
++install-dvi: install-dvi-am
++
++install-dvi-am:
++
++install-exec-am: install-exec-local
++
++install-html: install-html-am
++
++install-html-am:
++
++install-info: install-info-am
++
++install-info-am:
++
++install-man:
++
++install-pdf: install-pdf-am
++
++install-pdf-am:
++
++install-ps: install-ps-am
++
++install-ps-am:
++
++installcheck-am:
++
++maintainer-clean: maintainer-clean-am
++ -rm -f Makefile
++maintainer-clean-am: distclean-am maintainer-clean-generic
++
++mostlyclean: mostlyclean-am
++
++mostlyclean-am: mostlyclean-generic mostlyclean-libtool
++
++pdf: pdf-am
++
++pdf-am:
++
++ps: ps-am
++
++ps-am:
++
++uninstall-am:
++
++.MAKE: install-am install-strip
++
++.PHONY: all all-am all-local check check-am clean clean-generic \
++ clean-libtool clean-local distclean distclean-generic \
++ distclean-libtool distdir dvi dvi-am html html-am info info-am \
++ install install-am install-data install-data-am install-dvi \
++ install-dvi-am install-exec install-exec-am install-exec-local \
++ install-html install-html-am install-info install-info-am \
++ install-man install-pdf install-pdf-am install-ps \
++ install-ps-am install-strip installcheck installcheck-am \
++ installdirs maintainer-clean maintainer-clean-generic \
++ mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \
++ ps ps-am uninstall uninstall-am
++
++export XA_SRCDIR
++export XA_TOPSRCDIR
++export XA_ABSTOPSRCDIR
++
++all-local: user-all-local
++
++install-exec-local: user-install-local
++
++clean-local: user-clean-local
++
++user-all-local:
++ ${MAKE} ${_mcall} all;
++
++# Have no user-install-data-local ATM
++user-install-local: user-install-exec-local
++
++user-install-exec-local:
++ ${MAKE} ${_mcall} install;
++
++user-clean-local:
++ ${MAKE} ${_mcall} clean;
++
++# Tell versions [3.59,3.63) of GNU make to not export all variables.
++# Otherwise a system limit (for SysV at least) may be exceeded.
++.NOEXPORT:
++
+--- /dev/null
++++ b/extensions/LUA/Mbuild
+@@ -0,0 +1,3 @@
++# -*- Makefile -*-
++
++obj-${build_LUA} += libxt_LUA.so
+--- /dev/null
++++ b/extensions/LUA/nf_lua.c
+@@ -0,0 +1,64 @@
++#if defined(__KERNEL__)
++
++#include <linux/kernel.h>
++#include <linux/slab.h>
++#include <linux/string.h>
++#include <linux/timer.h>
++#include <linux/random.h>
++#include <linux/netfilter/x_tables.h>
++
++#endif
++
++#include "lua.h"
++#include "lobject.h" /*sizeof(udata) */
++#include "lauxlib.h"
++#include "controller.h"
++
++#if defined(__KERNEL__) /* reachs until luaopen_nflib */
++
++
++static int32_t nf_get_random(lua_State *L)
++{
++ uint32_t rand = 0;
++
++ get_random_bytes(&rand, sizeof(uint32_t ));
++ lua_pushnumber(L, rand);
++ return 1;
++}
++
++static int32_t nf_get_time(lua_State *L)
++{
++ lua_pushnumber(L, jiffies_to_msecs(jiffies_64));
++ return 1;
++}
++
++static const struct luaL_Reg nf_lua_lib_f [] = {
++ { "get_random", nf_get_random },
++ { "get_time", nf_get_time },
++ { NULL, NULL }
++};
++
++void luaopen_nflib(lua_State *L)
++{
++ int32_t top;
++
++ luaL_register(L, NETFILTER_LIB, nf_lua_lib_f);
++ lua_pop(L, 1);
++
++ /* registering verdicts inside the _G */
++ lua_getglobal(L, "_G");
++ top = lua_gettop(L);
++
++ lua_pushinteger(L, XT_CONTINUE);
++ lua_setfield(L, top, "XT_CONTINUE"); /* continiue with next rule */
++
++ lua_pushinteger(L, NF_DROP);
++ lua_setfield(L, top, "NF_DROP"); /* stop traversal in the current table hook and drop packet */
++
++ lua_pushinteger(L, NF_ACCEPT);
++ lua_setfield(L, top, "NF_ACCEPT"); /* stop traversal in the current table hook and accept packet */
++
++ lua_pop(L, 1); /* pop _G */
++}
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/prot_buf_dynamic.c
+@@ -0,0 +1,486 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre@dergraf.org>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++
++#include "controller.h"
++
++
++
++struct protocol_buf * dyn_prot_buf_array[MAX_NR_OF_DYN_PROT_BUFS] = { NULL };
++
++
++/* LUA_API: the function 'field_dynamic_setter' acts as a wrapper around
++ * a given Lua field setter function of a dynamic protocol buffer. The
++ * string containing the lua function name was piggybacked in the 'set'
++ * member of the protocol_field. We call this function passing the actual
++ * segment as byte array and the set value.
++ *
++ * Paramters:
++ * 1. lua_packet_segment (implicit)
++ * 2. some lua value
++ *
++ * Upvalues:
++ * 1. pointer to the protocol buffer
++ * 2. field index
++ *
++ * Returns:
++ * 1. true or false if the 'set' was successful
++ */
++int32_t field_dynamic_setter(lua_State *L)
++{
++ size_t nbytes;
++ lua_packet_segment * array;
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ int32_t field_index = lua_tointeger(L, lua_upvalueindex(2));
++
++ /* the function name is piggybacked as a string */
++ lua_getglobal(L, (char *)prot_buf->protocol_fields[field_index].set);
++ if (!lua_isfunction(L, -1)) {
++ lua_pushboolean(L, 0);
++ return 1;
++ }
++
++ nbytes = sizeof(lua_packet_segment) + seg->length * sizeof(uint8_t);
++ array = (lua_packet_segment *)lua_newuserdata(L, nbytes);
++ array->length = seg->length;
++ array->start = seg->start + seg->offset;
++ array->changes = NULL;
++
++ luaL_getmetatable(L, LUA_BYTE_ARRAY);
++ lua_setmetatable(L, -2);
++ lua_pushvalue(L, 2); /* push value to set */
++ if (lua_pcall(L, 2, 1, 0) != 0) {
++ pr_debug("Error: %s \n", lua_tostring(L, -1));
++ lua_pop(L, 1);
++ lua_pushboolean(L, 0);
++ }
++ return 1;
++}
++
++/* LUA_API: the function 'field_dynamic_getter' acts as a wrapper around
++ * a given Lua field getter function of a dynamic protocol buffer. The
++ * string containing the lua function name was piggybacked in the 'get'
++ * member of the protocol_field. We call this function passing the actual
++ * segment as byte array.
++ *
++ * Paramters:
++ * 1. lua_packet_segment (implicit)
++ *
++ * Upvalues:
++ * 1. pointer to the protocol buffer
++ * 2. field index
++ *
++ * Returns:
++ * 1. true or false if the 'get' was successful
++ */
++int32_t field_dynamic_getter(lua_State *L)
++{
++ size_t nbytes;
++ lua_packet_segment * array;
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ int32_t field_index = lua_tointeger(L, lua_upvalueindex(2));
++
++ /* the function name is piggybacked as a string */
++ lua_getglobal(L, (char *)prot_buf->protocol_fields[field_index].get);
++ if (!lua_isfunction(L, -1)) {
++ lua_pushboolean(L, 0);
++ return 1;
++ }
++
++ nbytes = sizeof(lua_packet_segment) + seg->length * sizeof(uint8_t);
++ array = (lua_packet_segment *)lua_newuserdata(L, nbytes);
++ array->length = seg->length;
++ array->start = seg->start + seg->offset;
++ array->changes = NULL;
++
++ luaL_getmetatable(L, LUA_BYTE_ARRAY);
++ lua_setmetatable(L, -2);
++ if (lua_pcall(L, 1, 1, 0) != 0) {
++ pr_debug("Error: %s \n", luaL_checkstring(L, -1));
++ lua_pop(L, 1);
++ lua_pushboolean(L, 0);
++ }
++ return 1;
++}
++
++/* LUA_API: the function 'has_protocol_dynamic' acts as a wrapper around
++ * a given lua has_protocol function of a dynamic protocol buffer. The
++ * string containing the lua function name was piggybacked in the 'has_protocol'
++ * member of the protocol_buffer. We call this function passing the actual
++ * segment.
++ *
++ * Paramters:
++ * 1. lua_packet_segment
++ * 2. protocol type
++ *
++ * Returns:
++ * 1. true or false if the payload field contains the given protocol
++ */
++int32_t has_protocol_dynamic(lua_State *L, struct protocol_buf * prot_buf, lua_packet_segment * seg, int32_t type)
++{
++ lua_packet_segment *seg_new;
++ int32_t res = 0;
++
++ /* the function name is piggybacked as a string */
++ lua_getglobal(L, (char *)prot_buf->has_protocol);
++ seg_new = (lua_packet_segment *)lua_newuserdata(L, sizeof(lua_packet_segment));
++ seg_new->start = seg->start;
++ seg_new->offset = seg->offset;
++ seg_new->length = seg->length;
++ seg_new->changes = NULL;
++ luaL_getmetatable(L, prot_buf->name);
++ lua_setmetatable(L, -2);
++ lua_pushinteger(L, type); /* push the protocol type */
++ if (lua_pcall(L, 2, 1, 0) != 0) {
++ pr_debug("Error: %s \n", luaL_checkstring(L, -1));
++ lua_pop(L, 1);
++ return 0;
++ }
++ res = lua_toboolean(L, -1);
++ lua_pop(L, 1);
++
++ return res;
++}
++
++/* LUA_API: the function 'get_field_changes_dynamic' acts as a wrapper around
++ * a given lua get_field_changes function of a dynamic protocol buffer. The
++ * string containing the lua function name was piggybacked in the 'get_field_changes'
++ * member of the protocol_buffer. We call this function passing the actual
++ * segment. The lua function must return two lua table containing the offset
++ * and length changes (in bits).
++ *
++ * Paramters:
++ * 1. lua_packet_segment
++ *
++ * Returns:
++ * 1. new allocated field_changes struct
++ */
++struct field_changes * get_field_changes_dynamic(lua_State *L, struct protocol_buf *prot_buf, lua_packet_segment * seg)
++{
++ lua_packet_segment *seg_new;
++ struct field_changes * changes;
++ int32_t nr_of_changes, i;
++
++ lua_getglobal(L, (char *)prot_buf->get_field_changes);
++
++ seg_new = (lua_packet_segment *)lua_newuserdata(L, sizeof(lua_packet_segment));
++ seg_new->start = seg->start;
++ seg_new->offset = seg->offset;
++ seg_new->length = seg->length;
++ seg_new->changes = NULL;
++ luaL_getmetatable(L, prot_buf->name);
++ lua_setmetatable(L, -2);
++
++ if (lua_pcall(L, 1, 2, 0) != 0)
++ luaL_error(L, "inside get_field_changes_dynamic. %s\n", lua_tostring(L, -1));
++
++ /* the function call must return a table containing length changes */
++ luaL_checktype(L, -1, LUA_TTABLE);
++ /* the function call must return a table containing offset changes */
++ luaL_checktype(L, -2, LUA_TTABLE);
++ /* both tables have to be of same size */
++ if (lua_objlen(L, -1) != lua_objlen(L, -2))
++ luaL_error(L, "the provided tables are not of equal size");
++
++ nr_of_changes = lua_objlen(L, -1);
++ changes = get_allocated_field_changes(L, nr_of_changes);
++
++ /* loop over the tables */
++ for (i = 1; i < nr_of_changes; i++) {
++ lua_rawgeti(L, -1, i); /* push length value of field at index i */
++ changes->field_length_changes[i - 1] = luaL_checkinteger(L, -1);
++ lua_pop(L, 1); /* pop offset value */
++
++ lua_rawgeti(L, -2, i); /* push offset value of field at index i */
++ changes->field_offset_changes[i - 1] = luaL_checkinteger(L, -1);
++ lua_pop(L, 1); /* pop length value */
++ }
++
++ /* pop both tables */
++ lua_pop(L, 2);
++
++ return changes;
++}
++
++/* C_INT: 'get_free_protocol_index' is only used internally. This function
++ * gets a free slot inside the array holding all the protocol buffers.
++ * There are several ways to get to this information. In this case I take
++ * the way over the reflected array SUPPORTED_PROTOCOL_TABLE inside the
++ * Lua state. Since this function is called at laodtime, we do not have
++ * to care about performance.
++ */
++static int32_t get_free_protocol_index(lua_State *L)
++{
++ int32_t protocol_index;
++
++ lua_getglobal(L, SUPPORTED_PROTOCOL_TABLE);
++ protocol_index = lua_objlen(L, -1) + 1;
++ lua_pop(L, 1);
++ return protocol_index;
++}
++
++/* C_API: 'free_dynamic_prot_buf' frees the allocated memory of a given
++ * dynamic protocol buffer. this function is normally called inside a
++ * cleanup routine. Be aware, before running this function you must be
++ * sure that no references to the dynamic protocol buffers were available.
++ * It's recomended to close the Lua state before calling the function. */
++void free_dynamic_prot_buf(struct protocol_buf * prot_buf)
++{
++ struct protocol_field * field = prot_buf->protocol_fields;
++
++ for (; field->name != NULL; field++) {
++ if (field->get) kfree(field->get);
++ if (field->set) kfree(field->set);
++ if (field->name) kfree((char *)field->name);
++ }
++
++ if (prot_buf->payload_field) kfree(prot_buf->payload_field);
++ if (prot_buf->has_protocol) kfree(prot_buf->has_protocol);
++
++ if (prot_buf->get_field_changes) kfree(prot_buf->get_field_changes);
++ kfree((char *)prot_buf->name);
++ kfree(prot_buf);
++ return;
++}
++
++void cleanup_dynamic_prot_bufs(void)
++{
++ int32_t i;
++
++ for (i = 0; i < MAX_NR_OF_DYN_PROT_BUFS; i++) {
++ if (dyn_prot_buf_array[i]) {
++ free_dynamic_prot_buf(dyn_prot_buf_array[i]);
++ dyn_prot_buf_array[i] = NULL;
++ }
++ }
++ return;
++}
++
++
++/* C_INT: 'free_protocol_fields' is used internally as a helper function for
++ * 'register_dynamic_protbuf'. It is used when durin registration an error
++ * occurs and the afore allocated fields needed to be freed. */
++static inline void free_protocol_fields(struct protocol_field * prot_fields, int32_t i)
++{
++ struct protocol_field * f;
++
++ while (i >= 0) {
++ f = &prot_fields[i];
++ if (f->name) kfree((void *)f->name);
++ if (f->get) kfree((void *)f->get);
++ if (f->set) kfree((void *)f->set);
++ kfree((void *)f);
++ i--;
++ }
++}
++
++/* LUA_API: 'register_dynamic_protbuf' is called from within the Lua script.
++ * it takes a Lua table representing the dynamic protocol buffer as parameter.
++ * e.g.:
++ * eth_prot_buf = {
++ * name = "packet_eth_dyn",
++ * payload_field = "data",
++ * protocol_fields = {
++ * {"dmac", 0, 48, nil, nil },
++ * {"smac", 48, 48, nil, nil },
++ * {"type", 96, 16, nil, nil },
++ * {"data", 112, 0, nil, nil },
++ * },
++ * has_protocol = "eth_dyn_has_protocol",
++ * get_field_changes = "eth_dyn_get_field_changes"
++ * }
++ * register_dynamic_protbuf(eth_prot_buf)
++ *
++ * the table gets parsed and a new protocol_buf struct is allocated and
++ * initialized using 'register_protbuf', which is also used for the static
++ * protocol buffers. This enables an identical behavior like the static
++ * protocol buffers. The dynamic protocol buffers are not garbage collected,
++ * use 'free_dynamic_protbuf' to free them after closing the Lua state.
++ */
++static int32_t register_dynamic_protbuf(lua_State *L)
++{
++ struct protocol_buf *prot_buf;
++ struct protocol_field *field, sentinel = PROT_FIELD_SENTINEL;
++ int32_t nr_of_fields, i;
++
++ prot_buf = (struct protocol_buf *)kmalloc(sizeof(struct protocol_buf), GFP_KERNEL);
++ prot_buf->is_dynamic = 1;
++
++ /* check if parameter is a table */
++ luaL_checktype(L, 1, LUA_TTABLE);
++
++ /* initialize prot_buf.name */
++ lua_getfield(L, 1, "name");
++ prot_buf->name = kmalloc(lua_objlen(L, -1), GFP_KERNEL);
++ strcpy((char *)prot_buf->name, luaL_checkstring(L, -1));
++ lua_pop(L, 1); /* pop res from lua_getfield */
++
++ /* check if protocol buffer is already registered */
++ lua_getglobal(L, prot_buf->name);
++ if (!lua_isnil(L, -1)) {
++ lua_pop(L, 1); /* pop res from lua_getglobal */
++ pr_debug("protocol_buf '%s' already registered.\n", prot_buf->name);
++ goto free_prot_buf;
++ }
++ lua_pop(L, 1); /* pop res from lua_getglobal */
++
++ /* initialize payload field */
++ lua_getfield(L, 1, "payload_field");
++ if (lua_isstring(L, -1)) {
++ prot_buf->payload_field = kmalloc(lua_objlen(L, -1), GFP_KERNEL);
++ strcpy(prot_buf->payload_field, lua_tostring(L, -1));
++ }else
++ prot_buf->payload_field = NULL;
++ lua_pop(L, 1); /* pop res from lua_getfield */
++
++ /* initialize protocol_fields field*/
++ lua_getfield(L, 1, "protocol_fields");
++ if (!lua_istable(L, -1)) {
++ pr_debug("invalid protocol_fields table.\n");
++ goto err2;
++
++ }
++
++ nr_of_fields = lua_objlen(L, -1);
++ prot_buf->protocol_fields = (struct protocol_field *)kmalloc((nr_of_fields + 1) * sizeof(struct protocol_field), GFP_KERNEL);
++
++ for (i = 1; i <= nr_of_fields; i++) {
++ field = &prot_buf->protocol_fields[i - 1];
++ /* initialize protocol field */
++ lua_rawgeti(L, -1, i); /* push field-table */
++ if (!lua_istable(L, -1)) {
++ free_protocol_fields(prot_buf->protocol_fields, i);
++ pr_debug("invalid protocol_field at %i.\n", i);
++ goto err;
++ }
++
++ /* initialize protocol field name */
++ lua_rawgeti(L, -1, 1);
++ if (!lua_isstring(L, -1)) {
++ free_protocol_fields(prot_buf->protocol_fields, i);
++ pr_debug("invalid protocol_field name at %i.\n", i);
++ goto err;
++ }
++
++ field->name = kmalloc(lua_objlen(L, -1), GFP_KERNEL);
++ strcpy((char*)field->name, lua_tostring(L, -1));
++ lua_pop(L, 1); /* pop field name */
++
++ /* initialize protocol field offset */
++ lua_rawgeti(L, -1, 2);
++ if (!lua_isnumber(L, -1)) {
++ free_protocol_fields(prot_buf->protocol_fields, i);
++ pr_debug("invalid protocol_field offset at %i.\n", i);
++ goto err;
++ }
++ field->offset = lua_tointeger(L, -1);
++ lua_pop(L, 1); /* pop field offset */
++
++ /* initialize protocol field length */
++ lua_rawgeti(L, -1, 3);
++ if (!lua_isnumber(L, -1)) {
++ free_protocol_fields(prot_buf->protocol_fields, i);
++ pr_debug("invalid protocol_field length at %i.\n", i);
++ goto err;
++ }
++ field->length = lua_tointeger(L, -1);
++ lua_pop(L, 1); /* pop field length */
++
++ /* initialize protocol field getter */
++ lua_rawgeti(L, -1, 4);
++ if (lua_isstring(L, -1)) {
++ field->get = kmalloc(lua_objlen(L, -1), GFP_KERNEL);
++ strcpy((char *)field->get, lua_tostring(L, -1)); /* the get-wrapper knows about the piggybacked string */
++ }else
++ field->get = NULL;
++ lua_pop(L, 1); /* pop field getter */
++
++ /* initialize protocol field setter */
++ lua_rawgeti(L, -1, 5);
++ if (lua_isstring(L, -1)) {
++ field->set = kmalloc(lua_objlen(L, -1), GFP_KERNEL);
++ strcpy((char *)field->set, lua_tostring(L, -1)); /* the set-wrapper knows about the piggybacked string */
++ }else
++ field->set = NULL;
++ lua_pop(L, 1); /* pop field setter */
++
++ /* field initialization completed */
++ lua_pop(L, 1); /* pop field-table */
++ }
++
++ /* put sentinel at the end of protocol_fields */
++ memcpy(&prot_buf->protocol_fields[nr_of_fields], &sentinel, sizeof(sentinel));
++ lua_pop(L, 1); /* pop protocol-fields-table */
++
++ /* initialize has_protocol field */
++ lua_getfield(L, 1, "has_protocol");
++ if (lua_isstring(L, -1)) {
++ prot_buf->has_protocol = kmalloc(lua_objlen(L, -1), GFP_KERNEL);
++ strcpy((char *)prot_buf->has_protocol, lua_tostring(L, -1)); /* the has_protocol-wrapper knows about the piggybacked string */
++ }else
++ prot_buf->has_protocol = NULL;
++ lua_pop(L, 1); /* pop has_protocol */
++
++ /* initialize get_field_changes field */
++ lua_getfield(L, 1, "get_field_changes");
++ if (lua_isstring(L, -1)) {
++ prot_buf->get_field_changes = kmalloc(lua_objlen(L, -1), GFP_KERNEL);
++ strcpy((char *)prot_buf->get_field_changes, lua_tostring(L, -1)); /* the get_field_changes-wrapper knows about the piggybacked string */
++ }else
++ prot_buf->get_field_changes = NULL;
++ lua_pop(L, 1); /* pop get_field_changes */
++
++ /* Storing the pointer to the DYNAMIC protbuf within dyn_prot_buf_array, in order to free it at cleanup */
++ for (i = 0; i < MAX_NR_OF_DYN_PROT_BUFS; i++) {
++ if (!dyn_prot_buf_array[i]) {
++ dyn_prot_buf_array[i] = prot_buf;
++ break;
++ }else
++ goto err;
++ }
++
++ /* call the "common" register_protbuf */
++ register_protbuf(L, prot_buf, get_free_protocol_index(L)); /* register prot_buf as it is done with the static ones */
++
++ return 0;
++
++err:
++ kfree(prot_buf->protocol_fields);
++err2:
++ if (prot_buf->payload_field) kfree(prot_buf->payload_field);
++free_prot_buf:
++ kfree((void *)prot_buf->name);
++ kfree(prot_buf);
++
++ luaL_error(L, "one or more error happend while registering a dynamic protocol buffer, please consult the debug log");
++
++ return 0;
++
++}
++
++void luaopen_protbuf_dynamic(lua_State *L)
++{
++ lua_getglobal(L, "_G");
++ lua_pushcclosure(L, register_dynamic_protbuf, 0);
++ lua_setfield(L, -2, "register_dynamic_protbuf");
++ lua_pop(L, 1); /* pop _G */
++ return;
++}
+--- /dev/null
++++ b/extensions/LUA/prot_buf_ethernet.c
+@@ -0,0 +1,60 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre@dergraf.org>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++
++#include "controller.h"
++
++
++static int32_t eth_has_protocol(lua_State *L, struct protocol_buf * prot_buf, lua_packet_segment * seg, int32_t protocol_type)
++{
++ uint8_t *embedded_protocol = seg->start + seg->offset + 12 /*bytes*/;
++ unsigned short res = (unsigned short)((embedded_protocol[1] << CHAR_BIT) | (embedded_protocol[0] << CHAR_BIT));
++
++ switch (res) {
++ case 0x0800: /* 1: Internet Protocol (IP) */
++ if (protocol_type == PACKET_IP) return 1;
++ break;
++ default:
++ return 0;
++ }
++
++ return 0;
++}
++
++static const struct protocol_field eth_protocol_fields[] = {
++ /* field name offset length getter setter */
++ { "dmac", 0, 48, NULL, NULL },
++ { "smac", 48, 48, NULL, NULL },
++ { "type", 96, 16, NULL, NULL },
++ { "data", 112, 0, NULL, NULL },
++ PROT_FIELD_SENTINEL,
++};
++
++static const struct protocol_buf eth_protocol_buf = {
++ .is_dynamic = 0,
++ .name = LUA_PACKET_SEG_ETH,
++ .payload_field = "data",
++ .protocol_fields = (struct protocol_field *)&eth_protocol_fields,
++ .has_protocol = &eth_has_protocol,
++ .get_field_changes = NULL,
++};
++
++
++void luaopen_protbuf_eth(lua_State *L)
++{
++ register_protbuf(L, (struct protocol_buf *)&eth_protocol_buf, PACKET_ETH);
++}
+--- /dev/null
++++ b/extensions/LUA/prot_buf_helpers.c
+@@ -0,0 +1,216 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre@dergraf.org>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++
++#if defined(__KERNEL__)
++#include <linux/netfilter_ipv4.h>
++#include <linux/slab.h> /* kmalloc */
++#endif
++
++#include "controller.h"
++
++int32_t get_header_size(struct protocol_buf * prot_buf)
++{
++ int32_t bit_counter = 0;
++ struct protocol_field * field = prot_buf->protocol_fields;
++
++ for (; field->name; field++)
++ bit_counter += field->length;
++
++ return bit_counter >> 3;
++}
++
++
++int32_t set_32_bit_generic(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ *(uint32_t *)(seg->start + seg->offset) = (uint32_t )htonl(luaL_checkinteger(L, 2));
++ return 0;
++}
++int32_t get_32_bit_generic(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ lua_pushinteger(L, ntohl(*((uint32_t *)(seg->start + seg->offset))));
++ return 1;
++}
++
++int32_t set_16_bit_generic(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ *(uint16_t *)(seg->start + seg->offset) = (uint16_t)htons(luaL_checkinteger(L, 2));
++ return 0;
++}
++int32_t get_16_bit_generic(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ lua_pushinteger(L, ntohs(*((uint16_t *)(seg->start + seg->offset))));
++ return 1;
++}
++
++int32_t set_lower_4_bit_generic(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++ uint8_t b = (uint8_t)luaL_checkinteger(L, 2) << 4;
++ uint8_t * pos = (uint8_t *)(seg->start + seg->offset);
++
++ *pos &= 0x0F; /* reset lower 4 bits*/
++ *pos |= b;
++
++ return 0;
++}
++
++int32_t get_lower_4_bit_generic(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ lua_pushinteger(L, (*(uint8_t *)(seg->start + seg->offset)) >> 4);
++ return 1;
++}
++
++int32_t set_upper_4_bit_generic(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++ uint8_t b = (uint8_t)luaL_checkinteger(L, 2) << 4;
++ uint8_t * pos = (uint8_t *)(seg->start + seg->offset);
++
++ *pos &= 0xF0; /* reset upper 4 bits*/
++ *pos |= (b >> 4);
++
++ return 0;
++}
++
++int32_t get_upper_4_bit_generic(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ lua_pushinteger(L, (*(uint8_t *)(seg->start + seg->offset)) & 0x0F);
++ return 1;
++}
++
++
++int32_t set_8_bit_generic(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ *(uint8_t *)(seg->start + seg->offset) = (uint8_t)luaL_checkinteger(L, 2);
++ return 0;
++}
++
++int32_t get_8_bit_generic(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ lua_pushinteger(L, *(uint8_t *)(seg->start + seg->offset));
++ return 1;
++}
++
++int32_t set_1_bit_generic(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++ unsigned long l = 0;
++
++ memcpy(&l, (seg->start + seg->offset), seg->length);
++ l |= (1 << ((CHAR_BIT * seg->length) - luaL_checkinteger(L, 2)));
++ memcpy((seg->start + seg->offset), &l, seg->length);
++
++ return 0;
++}
++
++int32_t get_1_bit_generic(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++ unsigned long l = 0;
++ uint32_t bit = 0;
++
++ memcpy(&l, (seg->start + seg->offset), seg->length);
++ bit = l & (1 << ((CHAR_BIT * seg->length) - luaL_checkinteger(L, 2)));
++
++ lua_pushboolean(L, bit);
++ return 1;
++}
++
++int32_t get_string_generic(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ /* Warning we cast from uchar to char */
++ lua_pushlstring(L, (char *)seg->start + seg->offset, seg->length);
++ return 1;
++}
++
++int32_t set_data_generic(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++ lua_packet_segment * data = checkbytearray(L, 2);
++
++ pr_debug("seg->length %u, data->length %u\n", seg->length, data->length);
++
++ if (seg->length >= data->length)
++ memcpy((seg->start + seg->offset), data->start, data->length);
++ else
++ luaL_error(L, "provided byte array too big for given packet segment");
++ return 0;
++}
++
++struct field_changes * get_allocated_field_changes(lua_State *L, int32_t nr_of_fields)
++{
++ struct field_changes * changes;
++
++ changes = kmalloc(sizeof(struct field_changes), GFP_ATOMIC);
++
++ if (!changes)
++ goto failure;
++
++ changes->field_length_changes = kmalloc(nr_of_fields * sizeof(int), GFP_ATOMIC);
++ if (!changes->field_length_changes)
++ goto free1;
++
++ changes->field_offset_changes = kmalloc(nr_of_fields * sizeof(int), GFP_ATOMIC);
++ if (!changes->field_offset_changes)
++ goto free2;
++
++ memset(changes->field_length_changes, 0, nr_of_fields * sizeof(int));
++ memset(changes->field_offset_changes, 0, nr_of_fields * sizeof(int));
++
++ changes->ref_count = 1;
++
++ return changes;
++
++free2: kfree(changes->field_length_changes);
++free1: kfree(changes);
++failure:
++ if (!changes) luaL_error(L, "couldnt allocate memory inside 'get_allocated_field_changes'");
++ return NULL; /* only to omit warnings */
++}
+\ No newline at end of file
+--- /dev/null
++++ b/extensions/LUA/prot_buf_icmp.c
+@@ -0,0 +1,49 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre@dergraf.org>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++
++#include "controller.h"
++
++static int32_t icmp_has_protocol(lua_State *L, struct protocol_buf * prot_buf, lua_packet_segment * seg, int32_t protocol_type)
++{
++ return 0;
++}
++
++static const struct protocol_field icmp_protocol_fields[] = {
++ /* field name offset length getter setter */
++ { "type", 0, 8, NULL, NULL },
++ { "code", 8, 8, NULL, NULL },
++ { "checksum", 16, 16, NULL, NULL },
++ { "id", 32, 16, NULL, NULL },
++ { "sequence", 48, 16, NULL, NULL },
++ PROT_FIELD_SENTINEL,
++};
++
++static const struct protocol_buf icmp_protocol_buf = {
++ .is_dynamic = 0,
++ .name = LUA_PACKET_SEG_ICMP,
++ .payload_field = NULL,
++ .protocol_fields = (struct protocol_field *)&icmp_protocol_fields,
++ .has_protocol = &icmp_has_protocol,
++ .get_field_changes = NULL,
++};
++
++void luaopen_protbuf_icmp(lua_State *L)
++{
++ register_protbuf(L, (struct protocol_buf *)&icmp_protocol_buf, PACKET_ICMP);
++}
++
+--- /dev/null
++++ b/extensions/LUA/prot_buf_ip.c
+@@ -0,0 +1,209 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre@dergraf.org>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++
++#if defined(__KERNEL__)
++ #include <net/checksum.h>
++ #include <net/tcp.h>
++#endif
++
++#include "controller.h"
++
++
++#define IP_FMT "%u.%u.%u.%u"
++#define IP_ACC(buf) buf[0], buf[1], buf[2], buf[3]
++
++
++static int32_t ip_version_set(lua_State *L)
++{
++ uint8_t version_checked;
++ lua_packet_segment * seg = checkpacketseg(L, 1, LUA_PACKET_SEG_IP);
++ uint8_t *version_seg = seg->start + seg->offset;
++ int32_t version = luaL_checkinteger(L, 2);
++
++ luaL_argcheck(L, version >= 0 && version <= 15, 1, "version number invalid");
++
++ version_checked = (uint8_t)version;
++
++ version_seg[0] &= (uint8_t)0x0F; /* reset version bits */
++ version_seg[0] |= version_checked << 4;
++
++ return 0;
++}
++static int32_t ip_version_get(lua_State *L)
++{
++ lua_packet_segment * seg = checkpacketseg(L, 1, LUA_PACKET_SEG_IP);
++ uint8_t *version_seg = seg->start + seg->offset;
++ uint8_t v = version_seg[0] & 0xF0;
++
++ v >>= 4;
++
++ lua_pushinteger(L, v);
++ return 1;
++}
++
++static int32_t ip_ihl_set(lua_State *L)
++{
++ uint8_t ihl_checked;
++ lua_packet_segment * seg = checkpacketseg(L, 1, LUA_PACKET_SEG_IP);
++ uint8_t *ihl_seg = seg->start + seg->offset;
++ int32_t ihl = luaL_checkinteger(L, 2);
++
++ luaL_argcheck(L, ihl >= 5 && ihl <= 15, 1, "ip header length invalid"); // RFC 791 5x32 = 160 bits
++
++ ihl_checked = (uint8_t)ihl;
++
++ ihl_seg[0] &= (uint8_t)0xF0; /* reset ihl bits */
++ ihl_seg[0] |= ihl_checked;
++
++ return 0;
++}
++static int32_t ip_ihl_get(lua_State *L)
++{
++ lua_packet_segment * seg = checkpacketseg(L, 1, LUA_PACKET_SEG_IP);
++ uint8_t *ihl_seg = seg->start + seg->offset;
++ uint8_t v = ihl_seg[0] & 0x0F;
++
++ lua_pushinteger(L, v);
++ return 1;
++}
++
++static int32_t ip_addr_set(lua_State *L)
++{
++ int32_t field_id = lua_tointeger(L, lua_upvalueindex(2));
++ lua_packet_segment * seg = checkpacketseg(L, 1, LUA_PACKET_SEG_IP);
++ uint8_t *addr_seg = seg->start + seg->offset;
++ uint32_t old_addr;
++ char *ip = (char *)luaL_checkstring(L, 2);
++ uint32_t a, b, c, d;
++ struct sk_buff * skb = (struct sk_buff *)lua_touserdata(L, 3);
++
++ /* for tcp / udp checksumming*/
++ uint32_t prot_offset;
++ uint8_t *check, *protocol_seg;
++
++ /* end */
++
++ sscanf(ip, IP_FMT, &a, &b, &c, &d);
++
++ luaL_argcheck(L, a < 256 && b < 256 && c < 256 && d < 256, 1, "invalid ip addr");
++
++ old_addr = *((uint32_t *)addr_seg);
++ addr_seg[0] = (uint8_t)a;
++ addr_seg[1] = (uint8_t)b;
++ addr_seg[2] = (uint8_t)c;
++ addr_seg[3] = (uint8_t)d;
++
++#if defined(__KERNEL__)
++ if (old_addr != *(uint32_t *)addr_seg) {
++ int32_t offset = (field_id == 10) ? -2 : -6; /* offset from saddr or daddr */
++
++ csum_replace4((uint16_t *)(addr_seg + offset), old_addr, *(uint32_t *)addr_seg);
++
++ prot_offset = (field_id == 10) ? -3 : -7; /* offset from saddr or daddr */
++ protocol_seg = seg->start + seg->offset + prot_offset;
++
++ if (skb && (protocol_seg[0] == 0x06 || protocol_seg[0] == 0x11)) { /* is payload TCP or UDP ? */
++
++ check = seg->start + seg->offset; /* tmp res */
++ check += (field_id == 10) ? 8 : 16; /* the start of the payload, depending saddr or daddr */
++ check += (protocol_seg[0] == 0x06) ? 16 : 6; /* the start of the checksum, depending on TCP or UDP */
++
++ inet_proto_csum_replace4((__sum16 *)check, skb, old_addr, *(uint32_t *)addr_seg, 1);
++
++ lua_pop(L, 1);
++ }
++ }
++#endif
++ return 0;
++}
++
++
++
++
++
++static int32_t ip_addr_get(lua_State *L)
++{
++ lua_packet_segment * seg = checkpacketseg(L, 1, LUA_PACKET_SEG_IP);
++ uint8_t *addr_seg = seg->start + seg->offset;
++
++ char buf[16]; /*max: 255.255.255.255\0 --> 16 chars */
++
++ sprintf(buf, IP_FMT, IP_ACC(addr_seg));
++ lua_pushstring(L, buf);
++ return 1;
++}
++
++static int32_t ip_has_protocol(lua_State *L, struct protocol_buf * prot_buf, lua_packet_segment * seg, int32_t protocol_type)
++{
++ uint8_t * embedded_protocol = seg->start + seg->offset + 9 /*bytes*/;
++
++ switch (embedded_protocol[0]) {
++ case 0x01: /* 1: Internet Control Message Protocol (ICMP) */
++ if (protocol_type == PACKET_ICMP) return 1;
++ break;
++ case 0x02: /* 2: Internet Group Management Protocol (IGMP) */
++ break;
++ case 0x06: /* 6: Transmission Control Protocol (TCP) */
++ if (protocol_type == PACKET_TCP) return 1;
++ break;
++ case 0x11: /* 17: User Datagram Protocol (UDP) */
++ if (protocol_type == PACKET_UDP) return 1;
++ break;
++ case 0x59: /* 89: Open Shortest Path First (OSPF) */
++ break;
++ case 0x84: /* 132: Stream Control Transmission Protocol (SCTP) */
++ break;
++ default:
++ break;
++ }
++
++ return 0;
++}
++
++static const struct protocol_field ip_protocol_fields[] = {
++ /* field name offset length getter setter */
++ { "version", 0, 4, ip_version_get, ip_version_set },
++ { "ihl", 4, 4, ip_ihl_get, ip_ihl_set },
++ { "tos", 8, 8, get_8_bit_generic, set_8_bit_generic },
++ { "tot_len", 16, 16, get_16_bit_generic, set_16_bit_generic },
++ { "id", 32, 16, get_16_bit_generic, set_16_bit_generic },
++ { "flags", 48, 3, get_1_bit_generic, set_1_bit_generic },
++ { "frag_off", 51, 13, NULL, NULL },
++ { "ttl", 64, 8, get_8_bit_generic, set_8_bit_generic },
++ { "protocol", 72, 8, get_8_bit_generic, set_8_bit_generic },
++ { "check", 80, 16, get_16_bit_generic, set_16_bit_generic },
++ { "saddr", 96, 32, ip_addr_get, ip_addr_set },
++ { "daddr", 128, 32, ip_addr_get, ip_addr_set },
++ { "data", 160, 0, NULL, set_data_generic },
++ PROT_FIELD_SENTINEL,
++};
++
++static const struct protocol_buf ip_protocol_buf = {
++ .is_dynamic = 0,
++ .name = LUA_PACKET_SEG_IP,
++ .payload_field = "data",
++ .protocol_fields = (struct protocol_field *)&ip_protocol_fields,
++ .has_protocol = &ip_has_protocol,
++ .get_field_changes = NULL,
++};
++
++void luaopen_protbuf_ip(lua_State *L)
++{
++ register_protbuf(L, (struct protocol_buf *)&ip_protocol_buf, PACKET_IP);
++}
++
+--- /dev/null
++++ b/extensions/LUA/prot_buf_raw.c
+@@ -0,0 +1,43 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre@dergraf.org>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++
++#include "controller.h"
++static int32_t raw_has_protocol(lua_State *L, struct protocol_buf * prot_buf, lua_packet_segment * seg, int32_t protocol_type)
++{
++ return 1;
++}
++
++static const struct protocol_field raw_protocol_fields[] = {
++ /* field name offset length getter setter */
++ { "data", 0, 0, NULL, NULL },
++ PROT_FIELD_SENTINEL,
++};
++
++static const struct protocol_buf raw_protocol_buf = {
++ .is_dynamic = 0,
++ .name = LUA_PACKET_SEG_RAW,
++ .payload_field = "data",
++ .protocol_fields = (struct protocol_field *)&raw_protocol_fields,
++ .has_protocol = &raw_has_protocol,
++ .get_field_changes = NULL,
++};
++
++void luaopen_protbuf_raw(lua_State *L)
++{
++ register_protbuf(L, (struct protocol_buf *)&raw_protocol_buf, PACKET_RAW);
++}
+--- /dev/null
++++ b/extensions/LUA/prot_buf_tcp.c
+@@ -0,0 +1,188 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre@dergraf.org>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++
++#if defined(__KERNEL__)
++ #include <net/checksum.h>
++ #include <net/tcp.h>
++#endif
++#include "controller.h"
++
++
++static int32_t tcp_has_protocol(lua_State *L, struct protocol_buf * prot_buf, lua_packet_segment * seg, int32_t protocol_type)
++{
++ return 1;
++}
++
++static int32_t tcp_set_checksum(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++#if defined(__KERNEL__)
++ uint8_t * check_seg = seg->start + seg->offset;
++ uint8_t * tcp_hdr = check_seg - 16;
++ uint8_t * saddr = tcp_hdr - 8;
++ uint8_t * daddr = saddr + 4;
++ uint32_t len = 20 + (seg->changes->field_length_changes[11] / 8) + (seg->changes->field_length_changes[10] / 8);
++ unsigned short checksum = tcp_v4_check(len, *(uint32_t *)saddr, *(uint32_t *)daddr,
++ csum_partial(tcp_hdr, len, 0));
++
++ memcpy(check_seg, &checksum, sizeof(unsigned short));
++#endif
++ return 0;
++}
++
++
++static const struct protocol_field tcp_protocol_fields[] = {
++ /* field name offset length getter setter */
++ { "sport", 0, 16, get_16_bit_generic, set_16_bit_generic },
++ { "dport", 16, 16, get_16_bit_generic, set_16_bit_generic },
++ { "seq", 32, 32, get_32_bit_generic, set_32_bit_generic },
++ { "ack", 64, 32, get_32_bit_generic, set_32_bit_generic },
++ { "data_off", 96, 4, get_lower_4_bit_generic, set_lower_4_bit_generic },
++ { "reserved", 100, 4, get_upper_4_bit_generic, set_upper_4_bit_generic },
++ { "flags", 104, 8, get_1_bit_generic, set_1_bit_generic },
++ { "window_size", 112, 16, get_16_bit_generic, set_16_bit_generic },
++ { "check", 128, 16, get_16_bit_generic, tcp_set_checksum },
++ { "urgent", 144, 16, NULL, NULL },
++ { "options", 160, 0, NULL, set_data_generic },
++ { "data", 160, 0, NULL, set_data_generic }, /* begin of data depends on options */
++ PROT_FIELD_SENTINEL,
++};
++
++
++static const struct protocol_field tcp_options_and_data[] = {
++ /* field name offset length getter setter */
++ { "MSS", 0, 16, get_16_bit_generic, set_16_bit_generic },
++ { "WS", 0, 8, get_8_bit_generic, set_8_bit_generic },
++ { "SACK", 0, 16, get_16_bit_generic, set_16_bit_generic },
++ { "TSVAL", 0, 32, get_32_bit_generic, set_32_bit_generic },
++ { "TSER", 0, 32, get_32_bit_generic, set_32_bit_generic },
++ PROT_FIELD_SENTINEL,
++};
++
++
++static struct field_changes * tcp_get_field_changes(lua_State *L, lua_packet_segment * seg);
++
++static const struct protocol_buf tcp_protocol_buf = {
++ .is_dynamic = 0,
++ .name = LUA_PACKET_SEG_TCP,
++ .payload_field = "data",
++ .protocol_fields = (struct protocol_field *)&tcp_protocol_fields,
++ .has_protocol = &tcp_has_protocol,
++ .get_field_changes = &tcp_get_field_changes,
++};
++
++
++static struct field_changes * tcp_options_get_field_changes(lua_State *L, lua_packet_segment * seg);
++
++static const struct protocol_buf tcp_options_and_data_buf = {
++ .is_dynamic = 0,
++ .name = LUA_PACKET_SEG_TCP_OPT,
++ .payload_field = NULL,
++ .protocol_fields = (struct protocol_field *)&tcp_options_and_data,
++ .has_protocol = NULL,
++ .get_field_changes = &tcp_options_get_field_changes,
++};
++
++struct field_changes * tcp_get_field_changes(lua_State *L, lua_packet_segment * seg)
++{
++ /* depending on the value stored inside the 'data_off'-field, the length of
++ * the 'options' field has to be changed, as well as the length and offset
++ * of the 'data' field */
++ uint8_t *tcp_hdr = seg->start + seg->offset;
++
++ /* get the pointer to the 'data_off' field */
++ uint8_t * data_off_field = tcp_hdr + 12; /* 12 bytes offset */
++ /* extract the stored header length in bits */
++ uint32_t tcp_hdr_len = ((*(uint8_t *)data_off_field) >> 4) * 32;
++
++ /* get an allocated 'field_changes' structure */
++ struct field_changes * changes = get_allocated_field_changes(L, 12);
++
++ /* depending on the tcp header length, change the length of the options*/
++ changes->field_length_changes[10] = tcp_hdr_len - 160;
++ /* depending on the options length, change the offset of the data */
++ changes->field_offset_changes[11] = changes->field_length_changes[10];
++ changes->field_length_changes[11] = (seg->length * 8) - tcp_hdr_len;
++
++ return changes;
++
++}
++
++struct field_changes * tcp_options_get_field_changes(lua_State *L, lua_packet_segment * seg)
++{
++ /* depending on the value stored inside the 'data_off'-field, the length of
++ * the 'options' field has to be changed, as well as the length and offset
++ * of the 'data' field */
++ uint8_t *tcp_opt_hdr = seg->start + seg->offset;
++
++ /* get an allocated 'field_changes' structure */
++ struct field_changes * changes = get_allocated_field_changes(L, 5);
++
++ int32_t MSS = 0, WS = 0, SACK = 0, TS = 0, i;
++
++ uint8_t b1, b2;
++
++ for (i = 0; i < seg->length; i++) {
++ b1 = tcp_opt_hdr[i];
++ b2 = tcp_opt_hdr[i + 1];
++
++ if (b1 == 0x00)
++ break;
++
++ /* test for MSS */
++ if (!MSS && (b1 == 0x02 && b2 == 0x04)) {
++ changes->field_offset_changes[0] = (i + 2) * CHAR_BIT;
++ MSS = 1;
++ }
++
++ /* test for WS --- yet buggy somehow */
++ if (!WS && (b1 == 0x03 && b2 == 0x03)) {
++ changes->field_offset_changes[1] = (i + 2) * CHAR_BIT;
++ WS = 1;
++ }
++
++ /* test for SACK*/
++ if (!SACK && (b1 == 0x04 && b2 == 0x02)) {
++ changes->field_offset_changes[2] = i * CHAR_BIT; /* has no value */
++ SACK = 1;
++ }
++
++ /* test for TS */
++ if (!TS && (b1 == 0x08 && b2 == 0x0A)) {
++ changes->field_offset_changes[3] = (i + 2) * CHAR_BIT;
++ changes->field_offset_changes[4] = (i + 2 + 4) * CHAR_BIT;
++ TS = 1;
++ }
++ }
++
++ return changes;
++
++}
++
++void luaopen_protbuf_tcp(lua_State *L)
++{
++ register_protbuf(L, (struct protocol_buf *)&tcp_protocol_buf, PACKET_TCP);
++}
++void luaopen_protbuf_tcp_options(lua_State *L)
++{
++ register_protbuf(L, (struct protocol_buf *)&tcp_options_and_data_buf, PACKET_TCP_OPTIONS);
++}
++
++
+--- /dev/null
++++ b/extensions/LUA/prot_buf_tftp.c
+@@ -0,0 +1,87 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre@dergraf.org>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++#include "controller.h"
++
++static const struct protocol_field tftp_protocol_fields[] = {
++ /* field name offset length getter setter */
++ { "opcode", 0, 16, get_16_bit_generic, NULL},
++ { "filename", 0, 0, get_string_generic, NULL},
++ { "mode", 0, 0, get_string_generic, NULL},
++ { "block_nr", 0, 16, get_16_bit_generic, NULL},
++ { "data", 0, 0, NULL, NULL},
++ PROT_FIELD_SENTINEL,
++};
++
++struct field_changes * tftp_get_field_changes(lua_State *L, lua_packet_segment * seg)
++{
++ /* depending on the value stored inside the 'opcode'-field we have to change
++ * offsets and lengths */
++ uint8_t *tftp_hdr = seg->start + seg->offset;
++ short opcode = ntohs(*((uint16_t *)tftp_hdr));
++ /* get an allocated 'field_changes' structure */
++ struct field_changes * changes = get_allocated_field_changes(L, 5);
++ switch (opcode) {
++ case 1: /* Read Request (RRQ) */
++ /* setting offset and length of field 'filename' */
++ changes->field_offset_changes[1] = sizeof(unsigned short) << 3;
++ changes->field_length_changes[1] = strlen((char *)tftp_hdr + sizeof(unsigned short)) << 3;
++ /* setting offset and length of field 'mode' */
++ changes->field_offset_changes[2] = changes->field_offset_changes[1] + changes->field_length_changes[1];
++ changes->field_length_changes[2] = strlen((char *)tftp_hdr + (changes->field_offset_changes[2] >> 3));
++ break;
++ case 2: /* Write Request (WRQ) */
++ /* setting offset and length of field 'filename' */
++ changes->field_offset_changes[1] = sizeof(unsigned short) << 3;
++ changes->field_length_changes[1] = strlen((char *)tftp_hdr + sizeof(unsigned short)) << 3;
++ /* setting offset and length of field 'mode' */
++ changes->field_offset_changes[2] = changes->field_offset_changes[1] + changes->field_length_changes[1];
++ changes->field_length_changes[2] = strlen((char *)tftp_hdr + (changes->field_offset_changes[2] >> 3));
++ break;
++ case 3: /* Data (DATA) */
++ /* setting offset of field 'block_nr' */
++ changes->field_offset_changes[3] = sizeof(unsigned short) << 3;
++ /* setting offset of field 'data' */
++ changes->field_offset_changes[4] = changes->field_offset_changes[3] + (sizeof(unsigned short) << 3);
++ break;
++ case 4: /* Acknowledgment (ACK) */
++ /* setting offset of field 'block_nr' */
++ changes->field_offset_changes[3] = sizeof(unsigned short) << 3;
++ break;
++ case 5: /* Error (ERROR) */
++ /* we don't care ... yet */
++ break;
++ default:
++ break;
++ }
++
++ return changes;
++}
++
++static const struct protocol_buf tftp_protocol_buf = {
++ .is_dynamic = 0,
++ .name = LUA_PACKET_SEG_TFTP,
++ .payload_field = NULL,
++ .protocol_fields = (struct protocol_field *)&tftp_protocol_fields,
++ .has_protocol = NULL, /* we don't need it, since we don't provide a payload field */
++ .get_field_changes = tftp_get_field_changes,
++};
++
++void luaopen_protbuf_tftp(lua_State *L)
++{
++ register_protbuf(L, (struct protocol_buf *)&tftp_protocol_buf, PACKET_TFTP);
++}
+--- /dev/null
++++ b/extensions/LUA/prot_buf_udp.c
+@@ -0,0 +1,53 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre@dergraf.org>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++
++#if defined(__KERNEL__)
++ #include <net/checksum.h>
++#endif
++
++#include "controller.h"
++
++
++static int32_t udp_has_protocol(lua_State *L, struct protocol_buf * prot_buf, lua_packet_segment * seg, int32_t protocol_type)
++{
++ return 1;
++}
++
++static const struct protocol_field udp_protocol_fields[] = {
++ /* field name offset length getter setter */
++ { "sport", 0, 16, get_16_bit_generic, set_16_bit_generic },
++ { "dport", 16, 16, get_16_bit_generic, set_16_bit_generic },
++ { "length", 32, 16, get_16_bit_generic, set_16_bit_generic },
++ { "check", 48, 16, get_16_bit_generic, set_16_bit_generic },
++ { "data", 64, 0, NULL, NULL },
++ PROT_FIELD_SENTINEL,
++};
++
++static const struct protocol_buf udp_protocol_buf = {
++ .is_dynamic = 0,
++ .name = LUA_PACKET_SEG_UDP,
++ .payload_field = "data",
++ .protocol_fields = (struct protocol_field *)&udp_protocol_fields,
++ .has_protocol = &udp_has_protocol,
++ .get_field_changes = NULL,
++};
++
++void luaopen_protbuf_udp(lua_State *L)
++{
++ register_protbuf(L, (struct protocol_buf *)&udp_protocol_buf, PACKET_UDP);
++}
+--- /dev/null
++++ b/extensions/LUA/xt_LUA.h
+@@ -0,0 +1,36 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre.graf@stud.unibas.ch>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++
++#ifndef XT_LUA_H_
++#define XT_LUA_H_
++
++#define MAX_FILENAME_SIZE 256
++#define MAX_FUNCTION_SIZE 256
++#define MAX_SCRIPT_SIZE 32768
++#define LUA_STATE_ARRAY_SIZE 128
++
++/* the targetsize is stored in a u16, so max size of the xt_lua_tginfo cannot exceed 64K*/
++struct xt_lua_tginfo {
++ char buf[MAX_SCRIPT_SIZE];
++ char filename[MAX_FILENAME_SIZE];
++ char function[MAX_FUNCTION_SIZE];
++ __u64 script_size;
++ __u32 state_id;
++};
++
++#endif /* XT_LUA_H_ */
+--- /dev/null
++++ b/extensions/LUA/xt_LUA.mod.c
+@@ -0,0 +1,69 @@
++#include <linux/module.h>
++#include <linux/vermagic.h>
++#include <linux/compiler.h>
++
++MODULE_INFO(vermagic, VERMAGIC_STRING);
++
++struct module __this_module
++__attribute__((section(".gnu.linkonce.this_module"))) = {
++ .name = KBUILD_MODNAME,
++ .init = init_module,
++#ifdef CONFIG_MODULE_UNLOAD
++ .exit = cleanup_module,
++#endif
++ .arch = MODULE_ARCH_INIT,
++};
++
++static const struct modversion_info ____versions[]
++__used
++__attribute__((section("__versions"))) = {
++ { 0xa3379c4b, "module_layout" },
++ { 0x5cf97727, "xt_unregister_target" },
++ { 0x9a1dfd65, "strpbrk" },
++ { 0x56fb5417, "kmalloc_caches" },
++ { 0x12da5bb2, "__kmalloc" },
++ { 0xb85f3bbe, "pv_lock_ops" },
++ { 0x349cba85, "strchr" },
++ { 0xd0d8621b, "strlen" },
++ { 0x79aa04a2, "get_random_bytes" },
++ { 0x20000329, "simple_strtoul" },
++ { 0x105e2727, "__tracepoint_kmalloc" },
++ { 0xbf7e1481, "inet_proto_csum_replace4" },
++ { 0x6c1ce5ce, "strcspn" },
++ { 0x3c2c5af5, "sprintf" },
++ { 0xe2d5255a, "strcmp" },
++ { 0xe24d3a97, "jiffies_64" },
++ { 0x2bc95bd4, "memset" },
++ { 0x87fc9bcc, "kmem_cache_alloc_notrace" },
++ { 0x11089ac7, "_ctype" },
++ { 0x37befc70, "jiffies_to_msecs" },
++ { 0x70d1f8f3, "strncat" },
++ { 0xb72397d5, "printk" },
++ { 0x42224298, "sscanf" },
++ { 0x5152e605, "memcmp" },
++ { 0xb6ed1e53, "strncpy" },
++ { 0x1e6d26a8, "strstr" },
++ { 0xc3fa6a59, "memchr" },
++ { 0x61651be, "strcat" },
++ { 0x7d8c0d13, "xt_register_target" },
++ { 0x8ff4079b, "pv_irq_ops" },
++ { 0x93fca811, "__get_free_pages" },
++ { 0xf0fdf6cb, "__stack_chk_fail" },
++ { 0xbbe2391b, "kfree_skb" },
++ { 0xf333a2fb, "_raw_spin_lock_irq" },
++ { 0x37a0cba, "kfree" },
++ { 0x2e60bace, "memcpy" },
++ { 0x59e7cb79, "skb_make_writable" },
++ { 0xb742fd7, "simple_strtol" },
++ { 0x7d50a24, "csum_partial" },
++ { 0xc2d711e1, "krealloc" },
++ { 0xe914e41e, "strcpy" },
++};
++
++static const char __module_depends[]
++__used
++__attribute__((section(".modinfo"))) =
++"depends=x_tables";
++
++
++MODULE_INFO(srcversion, "33A1481C4AA71D1B5A8CA8A");
+--- /dev/null
++++ b/extensions/LUA/xt_LUA_target.c
+@@ -0,0 +1,286 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre@dergraf.org>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++
++#include <linux/kernel.h>
++#include <linux/slab.h>
++#include <linux/module.h>
++#include <asm/uaccess.h>
++#include <net/ip.h>
++#include <linux/netfilter/x_tables.h>
++#include "xt_LUA.h"
++
++#include "controller.h"
++
++/*::*
++ * lua_envs
++ * ----------
++ * This array holds a defined number of `lua_envs`_ structures.
++ * The used array index is also used as the Lua state identifier.
++ * The size of the array is defined in `LUA_STATE_ARRAY_SIZE`_.
++ */
++struct lua_env * lua_envs[LUA_STATE_ARRAY_SIZE];
++
++/*::*
++ * lua_state_refs
++ * --------------
++ * This array holds the reference counts of the several `lua_nf_state`_s
++ * which are stored inside the array `lua_states`_.
++ */
++uint32_t lua_state_refs[LUA_STATE_ARRAY_SIZE] = { 0 };
++
++/*::*
++ * lua_tg
++ * ------
++ * This function is called whenever a packet matches all matching conditions
++ * inside a rule. It is the target. It extracts the state identifier comming
++ * inside the *xt_target_param* structure and uses it to access the proper
++ * Lua state inside the `lua_states`_ array.
++ *
++ * It then constructs a new Lua userdata of type *lua_packet_segment* and
++ * initializes it with the lowest network header available. This userdata
++ * is annotated with the Lua metatable `LUA_PACKET_SEG_RAW`_ which converts
++ * the userdata to a raw lua packet having all raw functions available.
++ * This raw packet is the single parameter to the Lua function *process_packet*
++ * which must be defined inside the Lua script provided by the user. So far
++ * hardcoded, may be later configured by Lua - subject to change.
++ *
++ * The process_packet function must return an integer value, the verdict. For
++ * convenience reasons xt_LUA exports the verdicts NF_ACCEPT, NF_DROP and
++ * XT_CONTINUE inside the *register_lua_packet_lib* function.
++ */
++
++spinlock_t lock = SPIN_LOCK_UNLOCKED;
++
++static uint32_t
++lua_tg(struct sk_buff *pskb, const struct xt_target_param *par)
++{
++ uint32_t verdict;
++ lua_packet_segment *p;
++ const struct xt_lua_tginfo *info = par->targinfo;
++ lua_State * L;
++
++ /* START critical section on SMP, PacketScript is on the sequential trail at the moment TODO*/
++ spin_lock_irq(&lock);
++
++ L = lua_envs[info->state_id]->L;
++
++ if (!skb_make_writable(pskb, pskb->len))
++ return NF_DROP;
++
++ /* call the function provided by --function parameter or the default 'process_packet' defined in Lua */
++ lua_getglobal(L, info->function);
++
++ /* push the lua_packet_segment as a parameter */
++ p = (lua_packet_segment *)lua_newuserdata(L, sizeof(lua_packet_segment));
++ if (pskb->mac_header)
++ p->start = pskb->mac_header;
++ else if (pskb->network_header)
++ p->start = pskb->network_header;
++ else if (pskb->transport_header)
++ p->start = pskb->transport_header;
++ p->offset = 0;
++ p->length = (unsigned long)pskb->tail - (unsigned long)p->start;
++ p->changes = NULL;
++
++ /* marking userdata 'lua_packet_seg' with the corresponding metatable */
++ luaL_getmetatable(L, LUA_PACKET_SEG_RAW);
++ lua_setmetatable(L, -2);
++
++ /* push a reference to the skb as a parameter, needed at the moment for calculating TCP checksum, but I am not happy with it*/
++ lua_pushlightuserdata(L, (void *)skb_get(pskb));
++
++ /* do the function call (2 argument, 1 result) */
++ if (lua_pcall(L, 2, 1, 0) != 0) {
++ printk(KERN_ERR "LUA [%d]: pcall '%s' failed: %s\n", info->state_id, info->function, lua_tostring(L, -1));
++ lua_pop(L, 1);
++ return NF_DROP;
++ }
++
++ if (!lua_isnumber(L, -1)) {
++ printk(KERN_ERR "LUA [%d]: function '%s' must return a verdict\n", info->state_id, info->function);
++ lua_pop(L, 1);
++ return NF_DROP;
++ }
++
++ verdict = lua_tonumber(L, -1);
++ lua_pop(L, 1);
++
++ kfree_skb(pskb);
++
++ /* END critical section on SMP */
++ spin_unlock_irq(&lock);
++
++
++ return verdict;
++
++}
++/* Helper for checkentry */
++static bool load_script_into_state(uint32_t state_id, unsigned long script_size, char *script_buf)
++{
++ char *buf = kmalloc(script_size, GFP_KERNEL);
++ int32_t ret;
++ struct lua_env * env = kmalloc(sizeof(struct lua_env), GFP_KERNEL);
++
++ if (!script_size > 0) {
++ pr_debug("LUA [%d]: script_size %lu < 0\n", state_id, script_size);
++ return false;
++ }
++
++ env->L = lua_open();
++ luaopen_base(env->L);
++ luaopen_controller(env->L);
++
++ lua_getglobal(env->L, "_G");
++ lua_pushinteger(env->L, state_id);
++ lua_setfield(env->L, -2, "STATE_ID");
++ lua_pop(env->L, 1); /* pop _G */
++
++ strncpy(buf, script_buf, script_size);
++ ret = luaL_loadbuffer(env->L, buf, script_size, "PacketScript, loadbuffer") ||
++ lua_pcall(env->L, 0, 1, 0);
++
++ if (ret != 0) {
++ printk(KERN_ERR "LUA [%d]: failure loading script, error %s \n", state_id, lua_tostring(env->L, -1));
++ lua_pop(env->L, 1);
++ kfree(buf);
++ kfree(env);
++ return false;
++ }
++
++ lua_envs[state_id] = env;
++
++ kfree(buf);
++
++ return true;
++}
++/*::*
++ * lua_tg_checkentry
++ * -----------------
++ * This function is used as a kernel-side sanity check of the data comming
++ * from the iptables userspace program. Since this is the function which is
++ * called everytime a new rule (with -j xt_LUA) is injected, this function
++ * is used to do the bookkeeping work, such as counting the reference of
++ * several Lua states and the initialization of new states if needed. As an
++ * extra initialization step it loads the provided Lua script into the Lua
++ * state.
++ *
++ * Lua state initialization
++ * ~~~~~~~~~~~~~~~~~~~~~~~~
++ * 1. If a new rule is inserted and there is no existing state for the given
++ * state identifier (default state identifier is 0) a new Lua state is
++ * initialized using *lua_open*.
++ * 2. The Lua base library is registered inside the newly initialized state.
++ * Have a look at *lua/lbaselib.c* to see what functions of the Lua base
++ * library are available inside Lua.
++ * 3. The Lua packet library is registered inside the Lua state using the
++ * function *register_lua_packet_lib*. So far this function only registers
++ * the Netfilter verdicts NF_ACCEPT, NF_DROP and XT_CONTINUE inside the
++ * global environment of the given Lua state.
++ * 4. All the protocol Buffers, and the functions for accessing the bytes are
++ * registered using *register_protocols*.
++ *
++ * Lua state reference counting
++ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
++ * Bookkeeping of the Lua states inside the *lua_state_refs* array. The
++ * state identifier is mapped to the array index, which holds an integer
++ * counting the several initialized states.
++ *
++ * Loading the Lua script
++ * ~~~~~~~~~~~~~~~~~~~~~~
++ * Copying the buffer which was initialized by the userspace program to a
++ * buffer with the proper size. The script is then loaded by the function
++ * xt_LUA_loadcode, which wrapps the *luaL_loadbuffer* function and does
++ * some workqueue initialization. So far this is done each time this function
++ * is called, subject to change.
++ */
++static bool
++lua_tg_checkentry(const struct xt_tgchk_param *par)
++{
++ const struct xt_lua_tginfo *info = par->targinfo;
++
++ if (load_script_into_state(info->state_id, info->script_size, (char *)info->buf)) {
++ lua_state_refs[info->state_id]++;
++ return true;
++ }
++ return false;
++}
++
++/*::*
++ * lua_tg_destroy
++ * --------------
++ * This function is the counterpart of the `lua_tg_checkentry`_ function. It is
++ * responsible to free all the resources alocated inside the checkentry process.
++ * To be more specific it frees the Lua state using *lua_close* and kfree on all
++ * the dynamically allocated pointers to the registered dynamic protocol buffers.
++ *
++ * Additionally the function cares about decrementing the reference counters
++ * inside the array `lua_states`_.
++ */
++static void
++lua_tg_destroy(const struct xt_tgdtor_param *par)
++{
++ const struct xt_lua_tginfo *info = par->targinfo;
++ struct lua_env * env = lua_envs[info->state_id];
++
++ if (lua_state_refs[info->state_id] == 1) {
++ lua_close(env->L);
++ cleanup_dynamic_prot_bufs(); /* clean memory allocated by protocols defined in Lua */
++ kfree(env);
++ pr_debug("LUA [%d]: Rule removed, close Lua state\n", info->state_id);
++ } else
++ pr_debug("LUA [%d]: Rule removed, Lua state stays open, referenced %d time(s)\n",
++ info->state_id, lua_state_refs[info->state_id] - 1);
++
++ lua_state_refs[info->state_id]--;
++}
++
++static struct xt_target lua_tg_reg __read_mostly = {
++ .name = "LUA",
++ .revision = 0,
++ .family = NFPROTO_UNSPEC,
++ .targetsize = XT_ALIGN(sizeof(struct xt_lua_tginfo)),
++ .target = lua_tg,
++ .checkentry = lua_tg_checkentry,
++ .destroy = lua_tg_destroy,
++ .me = THIS_MODULE,
++};
++
++
++static int32_t lua_tg_init(void)
++{
++ return xt_register_target(&lua_tg_reg);
++}
++
++static void lua_tg_exit(void)
++{
++ xt_unregister_target(&lua_tg_reg);
++}
++
++module_init(lua_tg_init);
++module_exit(lua_tg_exit);
++
++MODULE_AUTHOR("Andre Graf <andre@dergraf.org>");
++MODULE_DESCRIPTION("Xtables: Processing of matched packets using the Lua scripting environment");
++MODULE_ALIAS("ipt_LUA");
++MODULE_ALIAS("ipt6t_LUA");
++MODULE_ALIAS("arpt_LUA");
++MODULE_ALIAS("ebt_LUA");
++MODULE_LICENSE("GPL");
++
++
++
+--- a/extensions/Kbuild
++++ b/extensions/Kbuild
+@@ -34,6 +34,7 @@ obj-${build_pknock} += pknock/
+ obj-${build_psd} += xt_psd.o
+ obj-${build_quota2} += xt_quota2.o
+ obj-${build_rtsp} += rtsp/
++obj-${build_LUA} += LUA/
+
+ -include ${M}/*.Kbuild
+ -include ${M}/Kbuild.*
+--- a/extensions/Mbuild
++++ b/extensions/Mbuild
+@@ -24,3 +24,4 @@ obj-${build_pknock} += pknock/
+ obj-${build_psd} += libxt_psd.so
+ obj-${build_quota2} += libxt_quota2.so
+ obj-${build_gradm} += libxt_gradm.so
++obj-${build_LUA} += LUA/
+--- a/mconfig
++++ b/mconfig
+@@ -25,3 +25,4 @@ build_pknock=m
+ build_psd=m
+ build_quota2=m
+ build_rtsp=m
++build_LUA=m
diff --git a/package/network/utils/xtables-addons/patches/.svn/text-base/201-fix-lua-packetscript.patch.svn-base b/package/network/utils/xtables-addons/patches/.svn/text-base/201-fix-lua-packetscript.patch.svn-base
new file mode 100644
index 0000000..966d29d
--- /dev/null
+++ b/package/network/utils/xtables-addons/patches/.svn/text-base/201-fix-lua-packetscript.patch.svn-base
@@ -0,0 +1,89 @@
+--- a/extensions/LUA/xt_LUA_target.c
++++ b/extensions/LUA/xt_LUA_target.c
+@@ -64,10 +64,10 @@ uint32_t lua_state_refs[LUA_STATE_ARRAY
+ * XT_CONTINUE inside the *register_lua_packet_lib* function.
+ */
+
+-spinlock_t lock = SPIN_LOCK_UNLOCKED;
++DEFINE_SPINLOCK(lock);
+
+ static uint32_t
+-lua_tg(struct sk_buff *pskb, const struct xt_target_param *par)
++lua_tg(struct sk_buff *pskb, const struct xt_action_param *par)
+ {
+ uint32_t verdict;
+ lua_packet_segment *p;
+@@ -208,16 +208,16 @@ static bool load_script_into_state(uint3
+ * some workqueue initialization. So far this is done each time this function
+ * is called, subject to change.
+ */
+-static bool
++static int
+ lua_tg_checkentry(const struct xt_tgchk_param *par)
+ {
+ const struct xt_lua_tginfo *info = par->targinfo;
+
+ if (load_script_into_state(info->state_id, info->script_size, (char *)info->buf)) {
+ lua_state_refs[info->state_id]++;
+- return true;
++ return 0;
+ }
+- return false;
++ return -EINVAL;
+ }
+
+ /*::*
+--- a/extensions/LUA/lua/llimits.h
++++ b/extensions/LUA/lua/llimits.h
+@@ -8,7 +8,6 @@
+ #define llimits_h
+
+ #include <stddef.h>
+-#include <limits.h>
+
+ #include "lua.h"
+
+--- a/extensions/LUA/lua/lapi.c
++++ b/extensions/LUA/lua/lapi.c
+@@ -4,9 +4,6 @@
+ ** See Copyright Notice in lua.h
+ */
+
+-#include <stdarg.h>
+-#include <math.h>
+-#include <assert.h>
+ #include <string.h>
+
+ #define lapi_c
+--- a/extensions/LUA/lua/ltable.c
++++ b/extensions/LUA/lua/ltable.c
+@@ -18,7 +18,6 @@
+ ** Hence even when the load factor reaches 100%, performance remains good.
+ */
+
+-#include <math.h>
+ #include <string.h>
+
+ #define ltable_c
+--- a/extensions/LUA/lua/luaconf.h
++++ b/extensions/LUA/lua/luaconf.h
+@@ -13,6 +13,10 @@
+ #if !defined(__KERNEL__)
+ #include <limits.h>
+ #else
++#undef UCHAR_MAX
++#undef SHRT_MAX
++#undef BUFSIZ
++#undef NO_FPU
+ #define UCHAR_MAX 255
+ #define SHRT_MAX 32767
+ #define BUFSIZ 8192
+@@ -637,6 +641,8 @@ union luai_Cast { double l_d; long l_l;
+ */
+ #if defined(__KERNEL__)
+ #undef LUA_USE_ULONGJMP
++#define setjmp __builtin_setjmp
++#define longjmp __builtin_longjmp
+ #endif
+
+ #if defined(__cplusplus)
diff --git a/package/network/utils/xtables-addons/patches/.svn/text-base/300-geoip-endian-detection.patch.svn-base b/package/network/utils/xtables-addons/patches/.svn/text-base/300-geoip-endian-detection.patch.svn-base
new file mode 100644
index 0000000..842e7af
--- /dev/null
+++ b/package/network/utils/xtables-addons/patches/.svn/text-base/300-geoip-endian-detection.patch.svn-base
@@ -0,0 +1,18 @@
+--- a/extensions/libxt_geoip.c
++++ b/extensions/libxt_geoip.c
+@@ -59,13 +59,13 @@ geoip_get_subnets(const char *code, uint
+
+ /* Use simple integer vector files */
+ if (nfproto == NFPROTO_IPV6) {
+-#if __BYTE_ORDER == _BIG_ENDIAN
++#if BYTE_ORDER == BIG_ENDIAN
+ snprintf(buf, sizeof(buf), GEOIP_DB_DIR "/BE/%s.iv6", code);
+ #else
+ snprintf(buf, sizeof(buf), GEOIP_DB_DIR "/LE/%s.iv6", code);
+ #endif
+ } else {
+-#if __BYTE_ORDER == _BIG_ENDIAN
++#if BYTE_ORDER == BIG_ENDIAN
+ snprintf(buf, sizeof(buf), GEOIP_DB_DIR "/BE/%s.iv4", code);
+ #else
+ snprintf(buf, sizeof(buf), GEOIP_DB_DIR "/LE/%s.iv4", code);
diff --git a/package/network/utils/xtables-addons/patches/.svn/text-base/400-uid-gid-linux-3.7-compat.patch.svn-base b/package/network/utils/xtables-addons/patches/.svn/text-base/400-uid-gid-linux-3.7-compat.patch.svn-base
new file mode 100644
index 0000000..8a5be0d
--- /dev/null
+++ b/package/network/utils/xtables-addons/patches/.svn/text-base/400-uid-gid-linux-3.7-compat.patch.svn-base
@@ -0,0 +1,83 @@
+--- a/extensions/xt_DNETMAP.c
++++ b/extensions/xt_DNETMAP.c
+@@ -21,6 +21,7 @@
+ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+ #include <linux/inet.h>
+ #include <linux/ip.h>
++#include <linux/version.h>
+ #include <linux/module.h>
+ #include <linux/netdevice.h>
+ #include <linux/netfilter.h>
+@@ -328,8 +329,8 @@ static int dnetmap_tg_check(const struct
+ ret = -ENOMEM;
+ goto out;
+ }
+- pde_data->uid = proc_uid;
+- pde_data->gid = proc_gid;
++ pde_data->uid = XT_UID(proc_uid);
++ pde_data->gid = XT_GID(proc_gid);
+
+ /* statistics */
+ pde_stat = create_proc_entry(p->proc_str_stat, proc_perms,
+@@ -341,8 +342,8 @@ static int dnetmap_tg_check(const struct
+ }
+ pde_stat->data = p;
+ pde_stat->read_proc = dnetmap_stat_proc_read;
+- pde_stat->uid = proc_uid;
+- pde_stat->gid = proc_gid;
++ pde_stat->uid = XT_UID(proc_uid);
++ pde_stat->gid = XT_GID(proc_gid);
+ #endif
+
+ spin_lock_bh(&dnetmap_lock);
+--- a/extensions/xt_condition.c
++++ b/extensions/xt_condition.c
+@@ -14,6 +14,7 @@
+ */
+ #include <linux/kernel.h>
+ #include <linux/list.h>
++#include <linux/version.h>
+ #include <linux/module.h>
+ #include <linux/proc_fs.h>
+ #include <linux/spinlock.h>
+@@ -155,8 +156,8 @@ static int condition_mt_check(const stru
+ var->status_proc->read_proc = condition_proc_read;
+ var->status_proc->write_proc = condition_proc_write;
+ list_add(&var->list, &conditions_list);
+- var->status_proc->uid = condition_uid_perms;
+- var->status_proc->gid = condition_gid_perms;
++ var->status_proc->uid = XT_UID(condition_uid_perms);
++ var->status_proc->gid = XT_GID(condition_gid_perms);
+ mutex_unlock(&proc_lock);
+ info->condvar = var;
+ return 0;
+--- a/extensions/compat_xtables.h
++++ b/extensions/compat_xtables.h
+@@ -12,6 +12,14 @@
+ # warning Kernels below 3.7 not supported.
+ #endif
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 7, 0)
++# define XT_UID(x) KUIDT_INIT(x)
++# define XT_GID(x) KGIDT_INIT(x)
++#else
++# define XT_UID(x) (x)
++# define XT_GID(x) (x)
++#endif
++
+ #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
+ # if !defined(CONFIG_NF_CONNTRACK_MARK)
+ # warning You have CONFIG_NF_CONNTRACK enabled, but CONFIG_NF_CONNTRACK_MARK is not (please enable).
+--- a/extensions/xt_quota2.c
++++ b/extensions/xt_quota2.c
+@@ -131,8 +131,8 @@ q2_get_counter(const struct xt_quota_mti
+ p->data = e;
+ p->read_proc = quota_proc_read;
+ p->write_proc = quota_proc_write;
+- p->uid = quota_list_uid;
+- p->gid = quota_list_gid;
++ p->uid = XT_UID(quota_list_uid);
++ p->gid = XT_GID(quota_list_gid);
+ list_add_tail(&e->list, &counter_list);
+ spin_unlock_bh(&counter_list_lock);
+ return e;
diff --git a/package/network/utils/xtables-addons/patches/001-no_depmod.patch b/package/network/utils/xtables-addons/patches/001-no_depmod.patch
new file mode 100644
index 0000000..9905af1
--- /dev/null
+++ b/package/network/utils/xtables-addons/patches/001-no_depmod.patch
@@ -0,0 +1,16 @@
+---
+ Makefile.in | 3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -11,9 +11,6 @@ FORCE:
+ xtables-addons.8: FORCE
+ ${MAKE} -f Makefile.mans all;
+
+-install-exec-hook:
+- depmod -a || :;
+-
+ config.status: Makefile.iptrules.in
+
+ tmpdir := $(shell mktemp -dtu)
diff --git a/package/network/utils/xtables-addons/patches/002-fix-kernel-version-detection.patch b/package/network/utils/xtables-addons/patches/002-fix-kernel-version-detection.patch
new file mode 100644
index 0000000..8dc6384
--- /dev/null
+++ b/package/network/utils/xtables-addons/patches/002-fix-kernel-version-detection.patch
@@ -0,0 +1,22 @@
+--- a/configure
++++ b/configure
+@@ -11892,7 +11892,7 @@ regular_CFLAGS="-Wall -Waggregate-return
+ if test -n "$kbuilddir"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking kernel version that we will build against" >&5
+ $as_echo_n "checking kernel version that we will build against... " >&6; }
+- krel="$(make -sC "$kbuilddir" M=$PWD kernelrelease)";
++ krel="$(make -sC "$kbuilddir" M=$PWD kernelversion)";
+ kmajor="${krel%%[^0-9]*}";
+ kmajor="$(($kmajor+0))";
+ krel="${krel:${#kmajor}}";
+--- a/configure.ac
++++ b/configure.ac
+@@ -44,7 +44,7 @@ regular_CFLAGS="-Wall -Waggregate-return
+
+ if test -n "$kbuilddir"; then
+ AC_MSG_CHECKING([kernel version that we will build against])
+- krel="$(make -sC "$kbuilddir" M=$PWD kernelrelease)";
++ krel="$(make -sC "$kbuilddir" M=$PWD kernelversion)";
+ kmajor="${krel%%[[^0-9]]*}";
+ kmajor="$(($kmajor+0))";
+ krel="${krel:${#kmajor}}";
diff --git a/package/network/utils/xtables-addons/patches/100-add-rtsp-conntrack.patch b/package/network/utils/xtables-addons/patches/100-add-rtsp-conntrack.patch
new file mode 100644
index 0000000..9e105b4
--- /dev/null
+++ b/package/network/utils/xtables-addons/patches/100-add-rtsp-conntrack.patch
@@ -0,0 +1,1334 @@
+--- /dev/null
++++ b/extensions/rtsp/Kbuild
+@@ -0,0 +1,4 @@
++# -*- Makefile -*-
++
++obj-m += nf_nat_rtsp.o
++obj-m += nf_conntrack_rtsp.o
+--- /dev/null
++++ b/extensions/rtsp/netfilter_helpers.h
+@@ -0,0 +1,133 @@
++/*
++ * Helpers for netfiler modules. This file provides implementations for basic
++ * functions such as strncasecmp(), etc.
++ *
++ * gcc will warn for defined but unused functions, so we only include the
++ * functions requested. The following macros are used:
++ * NF_NEED_STRNCASECMP nf_strncasecmp()
++ * NF_NEED_STRTOU16 nf_strtou16()
++ * NF_NEED_STRTOU32 nf_strtou32()
++ */
++#ifndef _NETFILTER_HELPERS_H
++#define _NETFILTER_HELPERS_H
++
++/* Only include these functions for kernel code. */
++#ifdef __KERNEL__
++
++#include <linux/ctype.h>
++#define iseol(c) ( (c) == '\r' || (c) == '\n' )
++
++/*
++ * The standard strncasecmp()
++ */
++#ifdef NF_NEED_STRNCASECMP
++static int
++nf_strncasecmp(const char* s1, const char* s2, u_int32_t len)
++{
++ if (s1 == NULL || s2 == NULL)
++ {
++ if (s1 == NULL && s2 == NULL)
++ {
++ return 0;
++ }
++ return (s1 == NULL) ? -1 : 1;
++ }
++ while (len > 0 && tolower(*s1) == tolower(*s2))
++ {
++ len--;
++ s1++;
++ s2++;
++ }
++ return ( (len == 0) ? 0 : (tolower(*s1) - tolower(*s2)) );
++}
++#endif /* NF_NEED_STRNCASECMP */
++
++/*
++ * Parse a string containing a 16-bit unsigned integer.
++ * Returns the number of chars used, or zero if no number is found.
++ */
++#ifdef NF_NEED_STRTOU16
++static int
++nf_strtou16(const char* pbuf, u_int16_t* pval)
++{
++ int n = 0;
++
++ *pval = 0;
++ while (isdigit(pbuf[n]))
++ {
++ *pval = (*pval * 10) + (pbuf[n] - '0');
++ n++;
++ }
++
++ return n;
++}
++#endif /* NF_NEED_STRTOU16 */
++
++/*
++ * Parse a string containing a 32-bit unsigned integer.
++ * Returns the number of chars used, or zero if no number is found.
++ */
++#ifdef NF_NEED_STRTOU32
++static int
++nf_strtou32(const char* pbuf, u_int32_t* pval)
++{
++ int n = 0;
++
++ *pval = 0;
++ while (pbuf[n] >= '0' && pbuf[n] <= '9')
++ {
++ *pval = (*pval * 10) + (pbuf[n] - '0');
++ n++;
++ }
++
++ return n;
++}
++#endif /* NF_NEED_STRTOU32 */
++
++/*
++ * Given a buffer and length, advance to the next line and mark the current
++ * line.
++ */
++#ifdef NF_NEED_NEXTLINE
++static int
++nf_nextline(char* p, uint len, uint* poff, uint* plineoff, uint* plinelen)
++{
++ uint off = *poff;
++ uint physlen = 0;
++
++ if (off >= len)
++ {
++ return 0;
++ }
++
++ while (p[off] != '\n')
++ {
++ if (len-off <= 1)
++ {
++ return 0;
++ }
++
++ physlen++;
++ off++;
++ }
++
++ /* if we saw a crlf, physlen needs adjusted */
++ if (physlen > 0 && p[off] == '\n' && p[off-1] == '\r')
++ {
++ physlen--;
++ }
++
++ /* advance past the newline */
++ off++;
++
++ *plineoff = *poff;
++ *plinelen = physlen;
++ *poff = off;
++
++ return 1;
++}
++#endif /* NF_NEED_NEXTLINE */
++
++#endif /* __KERNEL__ */
++
++#endif /* _NETFILTER_HELPERS_H */
+--- /dev/null
++++ b/extensions/rtsp/netfilter_mime.h
+@@ -0,0 +1,89 @@
++/*
++ * MIME functions for netfilter modules. This file provides implementations
++ * for basic MIME parsing. MIME headers are used in many protocols, such as
++ * HTTP, RTSP, SIP, etc.
++ *
++ * gcc will warn for defined but unused functions, so we only include the
++ * functions requested. The following macros are used:
++ * NF_NEED_MIME_NEXTLINE nf_mime_nextline()
++ */
++#ifndef _NETFILTER_MIME_H
++#define _NETFILTER_MIME_H
++
++/* Only include these functions for kernel code. */
++#ifdef __KERNEL__
++
++#include <linux/ctype.h>
++
++/*
++ * Given a buffer and length, advance to the next line and mark the current
++ * line. If the current line is empty, *plinelen will be set to zero. If
++ * not, it will be set to the actual line length (including CRLF).
++ *
++ * 'line' in this context means logical line (includes LWS continuations).
++ * Returns 1 on success, 0 on failure.
++ */
++#ifdef NF_NEED_MIME_NEXTLINE
++static int
++nf_mime_nextline(char* p, uint len, uint* poff, uint* plineoff, uint* plinelen)
++{
++ uint off = *poff;
++ uint physlen = 0;
++ int is_first_line = 1;
++
++ if (off >= len)
++ {
++ return 0;
++ }
++
++ do
++ {
++ while (p[off] != '\n')
++ {
++ if (len-off <= 1)
++ {
++ return 0;
++ }
++
++ physlen++;
++ off++;
++ }
++
++ /* if we saw a crlf, physlen needs adjusted */
++ if (physlen > 0 && p[off] == '\n' && p[off-1] == '\r')
++ {
++ physlen--;
++ }
++
++ /* advance past the newline */
++ off++;
++
++ /* check for an empty line */
++ if (physlen == 0)
++ {
++ break;
++ }
++
++ /* check for colon on the first physical line */
++ if (is_first_line)
++ {
++ is_first_line = 0;
++ if (memchr(p+(*poff), ':', physlen) == NULL)
++ {
++ return 0;
++ }
++ }
++ }
++ while (p[off] == ' ' || p[off] == '\t');
++
++ *plineoff = *poff;
++ *plinelen = (physlen == 0) ? 0 : (off - *poff);
++ *poff = off;
++
++ return 1;
++}
++#endif /* NF_NEED_MIME_NEXTLINE */
++
++#endif /* __KERNEL__ */
++
++#endif /* _NETFILTER_MIME_H */
+--- /dev/null
++++ b/extensions/rtsp/nf_conntrack_rtsp.c
+@@ -0,0 +1,519 @@
++/*
++ * RTSP extension for IP connection tracking
++ * (C) 2003 by Tom Marshall <tmarshall at real.com>
++ * based on ip_conntrack_irc.c
++ *
++ * 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 of the License, or (at your option) any later version.
++ *
++ * Module load syntax:
++ * insmod nf_conntrack_rtsp.o ports=port1,port2,...port<MAX_PORTS>
++ * max_outstanding=n setup_timeout=secs
++ *
++ * If no ports are specified, the default will be port 554.
++ *
++ * With max_outstanding you can define the maximum number of not yet
++ * answered SETUP requests per RTSP session (default 8).
++ * With setup_timeout you can specify how long the system waits for
++ * an expected data channel (default 300 seconds).
++ *
++ * 2005-02-13: Harald Welte <laforge at netfilter.org>
++ * - port to 2.6
++ * - update to recent post-2.6.11 api changes
++ * 2006-09-14: Steven Van Acker <deepstar at singularity.be>
++ * - removed calls to NAT code from conntrack helper: NAT no longer needed to use rtsp-conntrack
++ * 2007-04-18: Michael Guntsche <mike at it-loops.com>
++ * - Port to new NF API
++ */
++
++#include <linux/module.h>
++#include <linux/netfilter.h>
++#include <linux/ip.h>
++#include <linux/inet.h>
++#include <net/tcp.h>
++
++#include <net/netfilter/nf_conntrack.h>
++#include <net/netfilter/nf_conntrack_expect.h>
++#include <net/netfilter/nf_conntrack_helper.h>
++#include "nf_conntrack_rtsp.h"
++
++#define NF_NEED_STRNCASECMP
++#define NF_NEED_STRTOU16
++#define NF_NEED_STRTOU32
++#define NF_NEED_NEXTLINE
++#include "netfilter_helpers.h"
++#define NF_NEED_MIME_NEXTLINE
++#include "netfilter_mime.h"
++
++#include <linux/ctype.h>
++#define MAX_SIMUL_SETUP 8 /* XXX: use max_outstanding */
++
++#define MAX_PORTS 8
++static int ports[MAX_PORTS];
++static int num_ports = 0;
++static int max_outstanding = 8;
++static unsigned int setup_timeout = 300;
++
++MODULE_AUTHOR("Tom Marshall <tmarshall at real.com>");
++MODULE_DESCRIPTION("RTSP connection tracking module");
++MODULE_LICENSE("GPL");
++module_param_array(ports, int, &num_ports, 0400);
++MODULE_PARM_DESC(ports, "port numbers of RTSP servers");
++module_param(max_outstanding, int, 0400);
++MODULE_PARM_DESC(max_outstanding, "max number of outstanding SETUP requests per RTSP session");
++module_param(setup_timeout, int, 0400);
++MODULE_PARM_DESC(setup_timeout, "timeout on for unestablished data channels");
++
++static char *rtsp_buffer;
++static DEFINE_SPINLOCK(rtsp_buffer_lock);
++
++static struct nf_conntrack_expect_policy rtsp_exp_policy;
++
++unsigned int (*nf_nat_rtsp_hook)(struct sk_buff *skb,
++ enum ip_conntrack_info ctinfo,
++ unsigned int matchoff, unsigned int matchlen,struct ip_ct_rtsp_expect* prtspexp,
++ struct nf_conntrack_expect *exp);
++void (*nf_nat_rtsp_hook_expectfn)(struct nf_conn *ct, struct nf_conntrack_expect *exp);
++
++EXPORT_SYMBOL_GPL(nf_nat_rtsp_hook);
++
++/*
++ * Max mappings we will allow for one RTSP connection (for RTP, the number
++ * of allocated ports is twice this value). Note that SMIL burns a lot of
++ * ports so keep this reasonably high. If this is too low, you will see a
++ * lot of "no free client map entries" messages.
++ */
++#define MAX_PORT_MAPS 16
++
++/*** default port list was here in the masq code: 554, 3030, 4040 ***/
++
++#define SKIP_WSPACE(ptr,len,off) while(off < len && isspace(*(ptr+off))) { off++; }
++
++/*
++ * Parse an RTSP packet.
++ *
++ * Returns zero if parsing failed.
++ *
++ * Parameters:
++ * IN ptcp tcp data pointer
++ * IN tcplen tcp data len
++ * IN/OUT ptcpoff points to current tcp offset
++ * OUT phdrsoff set to offset of rtsp headers
++ * OUT phdrslen set to length of rtsp headers
++ * OUT pcseqoff set to offset of CSeq header
++ * OUT pcseqlen set to length of CSeq header
++ */
++static int
++rtsp_parse_message(char* ptcp, uint tcplen, uint* ptcpoff,
++ uint* phdrsoff, uint* phdrslen,
++ uint* pcseqoff, uint* pcseqlen,
++ uint* transoff, uint* translen)
++{
++ uint entitylen = 0;
++ uint lineoff;
++ uint linelen;
++
++ if (!nf_nextline(ptcp, tcplen, ptcpoff, &lineoff, &linelen))
++ return 0;
++
++ *phdrsoff = *ptcpoff;
++ while (nf_mime_nextline(ptcp, tcplen, ptcpoff, &lineoff, &linelen)) {
++ if (linelen == 0) {
++ if (entitylen > 0)
++ *ptcpoff += min(entitylen, tcplen - *ptcpoff);
++ break;
++ }
++ if (lineoff+linelen > tcplen) {
++ pr_info("!! overrun !!\n");
++ break;
++ }
++
++ if (nf_strncasecmp(ptcp+lineoff, "CSeq:", 5) == 0) {
++ *pcseqoff = lineoff;
++ *pcseqlen = linelen;
++ }
++
++ if (nf_strncasecmp(ptcp+lineoff, "Transport:", 10) == 0) {
++ *transoff = lineoff;
++ *translen = linelen;
++ }
++
++ if (nf_strncasecmp(ptcp+lineoff, "Content-Length:", 15) == 0) {
++ uint off = lineoff+15;
++ SKIP_WSPACE(ptcp+lineoff, linelen, off);
++ nf_strtou32(ptcp+off, &entitylen);
++ }
++ }
++ *phdrslen = (*ptcpoff) - (*phdrsoff);
++
++ return 1;
++}
++
++/*
++ * Find lo/hi client ports (if any) in transport header
++ * In:
++ * ptcp, tcplen = packet
++ * tranoff, tranlen = buffer to search
++ *
++ * Out:
++ * pport_lo, pport_hi = lo/hi ports (host endian)
++ *
++ * Returns nonzero if any client ports found
++ *
++ * Note: it is valid (and expected) for the client to request multiple
++ * transports, so we need to parse the entire line.
++ */
++static int
++rtsp_parse_transport(char* ptran, uint tranlen,
++ struct ip_ct_rtsp_expect* prtspexp)
++{
++ int rc = 0;
++ uint off = 0;
++
++ if (tranlen < 10 || !iseol(ptran[tranlen-1]) ||
++ nf_strncasecmp(ptran, "Transport:", 10) != 0) {
++ pr_info("sanity check failed\n");
++ return 0;
++ }
++
++ pr_debug("tran='%.*s'\n", (int)tranlen, ptran);
++ off += 10;
++ SKIP_WSPACE(ptran, tranlen, off);
++
++ /* Transport: tran;field;field=val,tran;field;field=val,... */
++ while (off < tranlen) {
++ const char* pparamend;
++ uint nextparamoff;
++
++ pparamend = memchr(ptran+off, ',', tranlen-off);
++ pparamend = (pparamend == NULL) ? ptran+tranlen : pparamend+1;
++ nextparamoff = pparamend-ptran;
++
++ while (off < nextparamoff) {
++ const char* pfieldend;
++ uint nextfieldoff;
++
++ pfieldend = memchr(ptran+off, ';', nextparamoff-off);
++ nextfieldoff = (pfieldend == NULL) ? nextparamoff : pfieldend-ptran+1;
++
++ if (strncmp(ptran+off, "client_port=", 12) == 0) {
++ u_int16_t port;
++ uint numlen;
++
++ off += 12;
++ numlen = nf_strtou16(ptran+off, &port);
++ off += numlen;
++ if (prtspexp->loport != 0 && prtspexp->loport != port)
++ pr_debug("multiple ports found, port %hu ignored\n", port);
++ else {
++ pr_debug("lo port found : %hu\n", port);
++ prtspexp->loport = prtspexp->hiport = port;
++ if (ptran[off] == '-') {
++ off++;
++ numlen = nf_strtou16(ptran+off, &port);
++ off += numlen;
++ prtspexp->pbtype = pb_range;
++ prtspexp->hiport = port;
++
++ // If we have a range, assume rtp:
++ // loport must be even, hiport must be loport+1
++ if ((prtspexp->loport & 0x0001) != 0 ||
++ prtspexp->hiport != prtspexp->loport+1) {
++ pr_debug("incorrect range: %hu-%hu, correcting\n",
++ prtspexp->loport, prtspexp->hiport);
++ prtspexp->loport &= 0xfffe;
++ prtspexp->hiport = prtspexp->loport+1;
++ }
++ } else if (ptran[off] == '/') {
++ off++;
++ numlen = nf_strtou16(ptran+off, &port);
++ off += numlen;
++ prtspexp->pbtype = pb_discon;
++ prtspexp->hiport = port;
++ }
++ rc = 1;
++ }
++ }
++
++ /*
++ * Note we don't look for the destination parameter here.
++ * If we are using NAT, the NAT module will handle it. If not,
++ * and the client is sending packets elsewhere, the expectation
++ * will quietly time out.
++ */
++
++ off = nextfieldoff;
++ }
++
++ off = nextparamoff;
++ }
++
++ return rc;
++}
++
++void expected(struct nf_conn *ct, struct nf_conntrack_expect *exp)
++{
++ typeof(nf_nat_rtsp_hook_expectfn) nf_nat_rtsp_expectfn;
++ nf_nat_rtsp_expectfn = rcu_dereference(nf_nat_rtsp_hook_expectfn);
++ if(nf_nat_rtsp_expectfn && ct->master->status & IPS_NAT_MASK) {
++ nf_nat_rtsp_expectfn(ct,exp);
++ }
++}
++
++/*** conntrack functions ***/
++
++/* outbound packet: client->server */
++
++static inline int
++help_out(struct sk_buff *skb, unsigned char *rb_ptr, unsigned int datalen,
++ struct nf_conn *ct, enum ip_conntrack_info ctinfo)
++{
++ struct ip_ct_rtsp_expect expinfo;
++
++ int dir = CTINFO2DIR(ctinfo); /* = IP_CT_DIR_ORIGINAL */
++ //struct tcphdr* tcph = (void*)iph + iph->ihl * 4;
++ //uint tcplen = pktlen - iph->ihl * 4;
++ char* pdata = rb_ptr;
++ //uint datalen = tcplen - tcph->doff * 4;
++ uint dataoff = 0;
++ int ret = NF_ACCEPT;
++
++ struct nf_conntrack_expect *exp;
++
++ __be16 be_loport;
++
++ typeof(nf_nat_rtsp_hook) nf_nat_rtsp;
++
++ memset(&expinfo, 0, sizeof(expinfo));
++
++ while (dataoff < datalen) {
++ uint cmdoff = dataoff;
++ uint hdrsoff = 0;
++ uint hdrslen = 0;
++ uint cseqoff = 0;
++ uint cseqlen = 0;
++ uint transoff = 0;
++ uint translen = 0;
++ uint off;
++
++ if (!rtsp_parse_message(pdata, datalen, &dataoff,
++ &hdrsoff, &hdrslen,
++ &cseqoff, &cseqlen,
++ &transoff, &translen))
++ break; /* not a valid message */
++
++ if (strncmp(pdata+cmdoff, "SETUP ", 6) != 0)
++ continue; /* not a SETUP message */
++ pr_debug("found a setup message\n");
++
++ off = 0;
++ if(translen) {
++ rtsp_parse_transport(pdata+transoff, translen, &expinfo);
++ }
++
++ if (expinfo.loport == 0) {
++ pr_debug("no udp transports found\n");
++ continue; /* no udp transports found */
++ }
++
++ pr_debug("udp transport found, ports=(%d,%hu,%hu)\n",
++ (int)expinfo.pbtype, expinfo.loport, expinfo.hiport);
++
++ exp = nf_ct_expect_alloc(ct);
++ if (!exp) {
++ ret = NF_DROP;
++ goto out;
++ }
++
++ be_loport = htons(expinfo.loport);
++
++ nf_ct_expect_init(exp, NF_CT_EXPECT_CLASS_DEFAULT, nf_ct_l3num(ct),
++ &ct->tuplehash[!dir].tuple.src.u3, &ct->tuplehash[!dir].tuple.dst.u3,
++ IPPROTO_UDP, NULL, &be_loport);
++
++ exp->master = ct;
++
++ exp->expectfn = expected;
++ exp->flags = 0;
++
++ if (expinfo.pbtype == pb_range) {
++ pr_debug("Changing expectation mask to handle multiple ports\n");
++ //exp->mask.dst.u.udp.port = 0xfffe;
++ }
++
++ pr_debug("expect_related %pI4:%u-%pI4:%u\n",
++ &exp->tuple.src.u3.ip,
++ ntohs(exp->tuple.src.u.udp.port),
++ &exp->tuple.dst.u3.ip,
++ ntohs(exp->tuple.dst.u.udp.port));
++
++ nf_nat_rtsp = rcu_dereference(nf_nat_rtsp_hook);
++ if (nf_nat_rtsp && ct->status & IPS_NAT_MASK)
++ /* pass the request off to the nat helper */
++ ret = nf_nat_rtsp(skb, ctinfo, hdrsoff, hdrslen, &expinfo, exp);
++ else if (nf_ct_expect_related(exp) != 0) {
++ pr_info("nf_conntrack_expect_related failed\n");
++ ret = NF_DROP;
++ }
++ nf_ct_expect_put(exp);
++ goto out;
++ }
++out:
++
++ return ret;
++}
++
++
++static inline int
++help_in(struct sk_buff *skb, size_t pktlen,
++ struct nf_conn* ct, enum ip_conntrack_info ctinfo)
++{
++ return NF_ACCEPT;
++}
++
++static int help(struct sk_buff *skb, unsigned int protoff,
++ struct nf_conn *ct, enum ip_conntrack_info ctinfo)
++{
++ struct tcphdr _tcph, *th;
++ unsigned int dataoff, datalen;
++ char *rb_ptr;
++ int ret = NF_DROP;
++
++ /* Until there's been traffic both ways, don't look in packets. */
++ if (ctinfo != IP_CT_ESTABLISHED &&
++ ctinfo != IP_CT_ESTABLISHED + IP_CT_IS_REPLY) {
++ pr_debug("conntrackinfo = %u\n", ctinfo);
++ return NF_ACCEPT;
++ }
++
++ /* Not whole TCP header? */
++ th = skb_header_pointer(skb,protoff, sizeof(_tcph), &_tcph);
++
++ if (!th)
++ return NF_ACCEPT;
++
++ /* No data ? */
++ dataoff = protoff + th->doff*4;
++ datalen = skb->len - dataoff;
++ if (dataoff >= skb->len)
++ return NF_ACCEPT;
++
++ spin_lock_bh(&rtsp_buffer_lock);
++ rb_ptr = skb_header_pointer(skb, dataoff,
++ skb->len - dataoff, rtsp_buffer);
++ BUG_ON(rb_ptr == NULL);
++
++#if 0
++ /* Checksum invalid? Ignore. */
++ /* FIXME: Source route IP option packets --RR */
++ if (tcp_v4_check(tcph, tcplen, iph->saddr, iph->daddr,
++ csum_partial((char*)tcph, tcplen, 0)))
++ {
++ DEBUGP("bad csum: %p %u %u.%u.%u.%u %u.%u.%u.%u\n",
++ tcph, tcplen, NIPQUAD(iph->saddr), NIPQUAD(iph->daddr));
++ return NF_ACCEPT;
++ }
++#endif
++
++ switch (CTINFO2DIR(ctinfo)) {
++ case IP_CT_DIR_ORIGINAL:
++ ret = help_out(skb, rb_ptr, datalen, ct, ctinfo);
++ break;
++ case IP_CT_DIR_REPLY:
++ pr_debug("IP_CT_DIR_REPLY\n");
++ /* inbound packet: server->client */
++ ret = NF_ACCEPT;
++ break;
++ }
++
++ spin_unlock_bh(&rtsp_buffer_lock);
++
++ return ret;
++}
++
++static struct nf_conntrack_helper rtsp_helpers[MAX_PORTS];
++static char rtsp_names[MAX_PORTS][10];
++
++/* This function is intentionally _NOT_ defined as __exit */
++static void
++fini(void)
++{
++ int i;
++ for (i = 0; i < num_ports; i++) {
++ pr_debug("unregistering port %d\n", ports[i]);
++ nf_conntrack_helper_unregister(&rtsp_helpers[i]);
++ }
++ kfree(rtsp_buffer);
++}
++
++static int __init
++init(void)
++{
++ int i, ret;
++ struct nf_conntrack_helper *hlpr;
++ char *tmpname;
++
++ printk("nf_conntrack_rtsp v" IP_NF_RTSP_VERSION " loading\n");
++
++ if (max_outstanding < 1) {
++ printk("nf_conntrack_rtsp: max_outstanding must be a positive integer\n");
++ return -EBUSY;
++ }
++ if (setup_timeout < 0) {
++ printk("nf_conntrack_rtsp: setup_timeout must be a positive integer\n");
++ return -EBUSY;
++ }
++
++ rtsp_exp_policy.max_expected = max_outstanding;
++ rtsp_exp_policy.timeout = setup_timeout;
++
++ rtsp_buffer = kmalloc(65536, GFP_KERNEL);
++ if (!rtsp_buffer)
++ return -ENOMEM;
++
++ /* If no port given, default to standard rtsp port */
++ if (ports[0] == 0) {
++ ports[0] = RTSP_PORT;
++ }
++
++ for (i = 0; (i < MAX_PORTS) && ports[i]; i++) {
++ hlpr = &rtsp_helpers[i];
++ memset(hlpr, 0, sizeof(struct nf_conntrack_helper));
++ hlpr->tuple.src.l3num = AF_INET;
++ hlpr->tuple.src.u.tcp.port = htons(ports[i]);
++ hlpr->tuple.dst.protonum = IPPROTO_TCP;
++ //hlpr->mask.src.u.tcp.port = 0xFFFF;
++ //hlpr->mask.dst.protonum = 0xFF;
++ hlpr->expect_policy = &rtsp_exp_policy;
++ hlpr->me = THIS_MODULE;
++ hlpr->help = help;
++
++ tmpname = &rtsp_names[i][0];
++ if (ports[i] == RTSP_PORT) {
++ sprintf(tmpname, "rtsp");
++ } else {
++ sprintf(tmpname, "rtsp-%d", i);
++ }
++ hlpr->name = tmpname;
++
++ pr_debug("port #%d: %d\n", i, ports[i]);
++
++ ret = nf_conntrack_helper_register(hlpr);
++
++ if (ret) {
++ printk("nf_conntrack_rtsp: ERROR registering port %d\n", ports[i]);
++ fini();
++ return -EBUSY;
++ }
++ num_ports++;
++ }
++ return 0;
++}
++
++module_init(init);
++module_exit(fini);
++
++EXPORT_SYMBOL(nf_nat_rtsp_hook_expectfn);
++
+--- /dev/null
++++ b/extensions/rtsp/nf_conntrack_rtsp.h
+@@ -0,0 +1,63 @@
++/*
++ * RTSP extension for IP connection tracking.
++ * (C) 2003 by Tom Marshall <tmarshall at real.com>
++ * based on ip_conntrack_irc.h
++ *
++ * 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 of the License, or (at your option) any later version.
++ */
++#ifndef _IP_CONNTRACK_RTSP_H
++#define _IP_CONNTRACK_RTSP_H
++
++//#define IP_NF_RTSP_DEBUG 1
++#define IP_NF_RTSP_VERSION "0.6.21"
++
++#ifdef __KERNEL__
++/* port block types */
++typedef enum {
++ pb_single, /* client_port=x */
++ pb_range, /* client_port=x-y */
++ pb_discon /* client_port=x/y (rtspbis) */
++} portblock_t;
++
++/* We record seq number and length of rtsp headers here, all in host order. */
++
++/*
++ * This structure is per expected connection. It is a member of struct
++ * ip_conntrack_expect. The TCP SEQ for the conntrack expect is stored
++ * there and we are expected to only store the length of the data which
++ * needs replaced. If a packet contains multiple RTSP messages, we create
++ * one expected connection per message.
++ *
++ * We use these variables to mark the entire header block. This may seem
++ * like overkill, but the nature of RTSP requires it. A header may appear
++ * multiple times in a message. We must treat two Transport headers the
++ * same as one Transport header with two entries.
++ */
++struct ip_ct_rtsp_expect
++{
++ u_int32_t len; /* length of header block */
++ portblock_t pbtype; /* Type of port block that was requested */
++ u_int16_t loport; /* Port that was requested, low or first */
++ u_int16_t hiport; /* Port that was requested, high or second */
++#if 0
++ uint method; /* RTSP method */
++ uint cseq; /* CSeq from request */
++#endif
++};
++
++extern unsigned int (*nf_nat_rtsp_hook)(struct sk_buff *skb,
++ enum ip_conntrack_info ctinfo,
++ unsigned int matchoff, unsigned int matchlen,
++ struct ip_ct_rtsp_expect *prtspexp,
++ struct nf_conntrack_expect *exp);
++
++extern void (*nf_nat_rtsp_hook_expectfn)(struct nf_conn *ct, struct nf_conntrack_expect *exp);
++
++#define RTSP_PORT 554
++
++#endif /* __KERNEL__ */
++
++#endif /* _IP_CONNTRACK_RTSP_H */
+--- /dev/null
++++ b/extensions/rtsp/nf_nat_rtsp.c
+@@ -0,0 +1,491 @@
++/*
++ * RTSP extension for TCP NAT alteration
++ * (C) 2003 by Tom Marshall <tmarshall at real.com>
++ * based on ip_nat_irc.c
++ *
++ * 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 of the License, or (at your option) any later version.
++ *
++ * Module load syntax:
++ * insmod nf_nat_rtsp.o ports=port1,port2,...port<MAX_PORTS>
++ * stunaddr=<address>
++ * destaction=[auto|strip|none]
++ *
++ * If no ports are specified, the default will be port 554 only.
++ *
++ * stunaddr specifies the address used to detect that a client is using STUN.
++ * If this address is seen in the destination parameter, it is assumed that
++ * the client has already punched a UDP hole in the firewall, so we don't
++ * mangle the client_port. If none is specified, it is autodetected. It
++ * only needs to be set if you have multiple levels of NAT. It should be
++ * set to the external address that the STUN clients detect. Note that in
++ * this case, it will not be possible for clients to use UDP with servers
++ * between the NATs.
++ *
++ * If no destaction is specified, auto is used.
++ * destaction=auto: strip destination parameter if it is not stunaddr.
++ * destaction=strip: always strip destination parameter (not recommended).
++ * destaction=none: do not touch destination parameter (not recommended).
++ */
++
++#include <linux/module.h>
++#include <net/tcp.h>
++#include <net/netfilter/nf_nat_helper.h>
++#include <net/netfilter/nf_nat_rule.h>
++#include "nf_conntrack_rtsp.h"
++#include <net/netfilter/nf_conntrack_expect.h>
++
++#include <linux/inet.h>
++#include <linux/ctype.h>
++#define NF_NEED_STRNCASECMP
++#define NF_NEED_STRTOU16
++#include "netfilter_helpers.h"
++#define NF_NEED_MIME_NEXTLINE
++#include "netfilter_mime.h"
++
++#include "../compat_xtables.h"
++
++#define MAX_PORTS 8
++#define DSTACT_AUTO 0
++#define DSTACT_STRIP 1
++#define DSTACT_NONE 2
++
++static char* stunaddr = NULL;
++static char* destaction = NULL;
++
++static u_int32_t extip = 0;
++static int dstact = 0;
++
++MODULE_AUTHOR("Tom Marshall <tmarshall at real.com>");
++MODULE_DESCRIPTION("RTSP network address translation module");
++MODULE_LICENSE("GPL");
++module_param(stunaddr, charp, 0644);
++MODULE_PARM_DESC(stunaddr, "Address for detecting STUN");
++module_param(destaction, charp, 0644);
++MODULE_PARM_DESC(destaction, "Action for destination parameter (auto/strip/none)");
++
++#define SKIP_WSPACE(ptr,len,off) while(off < len && isspace(*(ptr+off))) { off++; }
++
++/*** helper functions ***/
++
++static void
++get_skb_tcpdata(struct sk_buff* skb, char** pptcpdata, uint* ptcpdatalen)
++{
++ struct iphdr* iph = ip_hdr(skb);
++ struct tcphdr* tcph = (void *)iph + ip_hdrlen(skb);
++
++ *pptcpdata = (char*)tcph + tcph->doff*4;
++ *ptcpdatalen = ((char*)skb_transport_header(skb) + skb->len) - *pptcpdata;
++}
++
++/*** nat functions ***/
++
++/*
++ * Mangle the "Transport:" header:
++ * - Replace all occurences of "client_port=<spec>"
++ * - Handle destination parameter
++ *
++ * In:
++ * ct, ctinfo = conntrack context
++ * skb = packet
++ * tranoff = Transport header offset from TCP data
++ * tranlen = Transport header length (incl. CRLF)
++ * rport_lo = replacement low port (host endian)
++ * rport_hi = replacement high port (host endian)
++ *
++ * Returns packet size difference.
++ *
++ * Assumes that a complete transport header is present, ending with CR or LF
++ */
++static int
++rtsp_mangle_tran(enum ip_conntrack_info ctinfo,
++ struct nf_conntrack_expect* exp,
++ struct ip_ct_rtsp_expect* prtspexp,
++ struct sk_buff* skb, uint tranoff, uint tranlen)
++{
++ char* ptcp;
++ uint tcplen;
++ char* ptran;
++ char rbuf1[16]; /* Replacement buffer (one port) */
++ uint rbuf1len; /* Replacement len (one port) */
++ char rbufa[16]; /* Replacement buffer (all ports) */
++ uint rbufalen; /* Replacement len (all ports) */
++ u_int32_t newip;
++ u_int16_t loport, hiport;
++ uint off = 0;
++ uint diff; /* Number of bytes we removed */
++
++ struct nf_conn *ct = exp->master;
++ struct nf_conntrack_tuple *t;
++
++ char szextaddr[15+1];
++ uint extaddrlen;
++ int is_stun;
++
++ get_skb_tcpdata(skb, &ptcp, &tcplen);
++ ptran = ptcp+tranoff;
++
++ if (tranoff+tranlen > tcplen || tcplen-tranoff < tranlen ||
++ tranlen < 10 || !iseol(ptran[tranlen-1]) ||
++ nf_strncasecmp(ptran, "Transport:", 10) != 0)
++ {
++ pr_info("sanity check failed\n");
++ return 0;
++ }
++ off += 10;
++ SKIP_WSPACE(ptcp+tranoff, tranlen, off);
++
++ newip = ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u3.ip;
++ t = &exp->tuple;
++ t->dst.u3.ip = newip;
++
++ extaddrlen = extip ? sprintf(szextaddr, "%pI4", &extip)
++ : sprintf(szextaddr, "%pI4", &newip);
++ pr_debug("stunaddr=%s (%s)\n", szextaddr, (extip?"forced":"auto"));
++
++ rbuf1len = rbufalen = 0;
++ switch (prtspexp->pbtype)
++ {
++ case pb_single:
++ for (loport = prtspexp->loport; loport != 0; loport++) /* XXX: improper wrap? */
++ {
++ t->dst.u.udp.port = htons(loport);
++ if (nf_ct_expect_related(exp) == 0)
++ {
++ pr_debug("using port %hu\n", loport);
++ break;
++ }
++ }
++ if (loport != 0)
++ {
++ rbuf1len = sprintf(rbuf1, "%hu", loport);
++ rbufalen = sprintf(rbufa, "%hu", loport);
++ }
++ break;
++ case pb_range:
++ for (loport = prtspexp->loport; loport != 0; loport += 2) /* XXX: improper wrap? */
++ {
++ t->dst.u.udp.port = htons(loport);
++ if (nf_ct_expect_related(exp) == 0)
++ {
++ hiport = loport + 1; //~exp->mask.dst.u.udp.port;
++ pr_debug("using ports %hu-%hu\n", loport, hiport);
++ break;
++ }
++ }
++ if (loport != 0)
++ {
++ rbuf1len = sprintf(rbuf1, "%hu", loport);
++ rbufalen = sprintf(rbufa, "%hu-%hu", loport, loport+1);
++ }
++ break;
++ case pb_discon:
++ for (loport = prtspexp->loport; loport != 0; loport++) /* XXX: improper wrap? */
++ {
++ t->dst.u.udp.port = htons(loport);
++ if (nf_ct_expect_related(exp) == 0)
++ {
++ pr_debug("using port %hu (1 of 2)\n", loport);
++ break;
++ }
++ }
++ for (hiport = prtspexp->hiport; hiport != 0; hiport++) /* XXX: improper wrap? */
++ {
++ t->dst.u.udp.port = htons(hiport);
++ if (nf_ct_expect_related(exp) == 0)
++ {
++ pr_debug("using port %hu (2 of 2)\n", hiport);
++ break;
++ }
++ }
++ if (loport != 0 && hiport != 0)
++ {
++ rbuf1len = sprintf(rbuf1, "%hu", loport);
++ if (hiport == loport+1)
++ {
++ rbufalen = sprintf(rbufa, "%hu-%hu", loport, hiport);
++ }
++ else
++ {
++ rbufalen = sprintf(rbufa, "%hu/%hu", loport, hiport);
++ }
++ }
++ break;
++ }
++
++ if (rbuf1len == 0)
++ {
++ return 0; /* cannot get replacement port(s) */
++ }
++
++ /* Transport: tran;field;field=val,tran;field;field=val,... */
++ while (off < tranlen)
++ {
++ uint saveoff;
++ const char* pparamend;
++ uint nextparamoff;
++
++ pparamend = memchr(ptran+off, ',', tranlen-off);
++ pparamend = (pparamend == NULL) ? ptran+tranlen : pparamend+1;
++ nextparamoff = pparamend-ptcp;
++
++ /*
++ * We pass over each param twice. On the first pass, we look for a
++ * destination= field. It is handled by the security policy. If it
++ * is present, allowed, and equal to our external address, we assume
++ * that STUN is being used and we leave the client_port= field alone.
++ */
++ is_stun = 0;
++ saveoff = off;
++ while (off < nextparamoff)
++ {
++ const char* pfieldend;
++ uint nextfieldoff;
++
++ pfieldend = memchr(ptran+off, ';', nextparamoff-off);
++ nextfieldoff = (pfieldend == NULL) ? nextparamoff : pfieldend-ptran+1;
++
++ if (dstact != DSTACT_NONE && strncmp(ptran+off, "destination=", 12) == 0)
++ {
++ if (strncmp(ptran+off+12, szextaddr, extaddrlen) == 0)
++ {
++ is_stun = 1;
++ }
++ if (dstact == DSTACT_STRIP || (dstact == DSTACT_AUTO && !is_stun))
++ {
++ diff = nextfieldoff-off;
++ if (!nf_nat_mangle_tcp_packet(skb, ct, ctinfo,
++ off, diff, NULL, 0))
++ {
++ /* mangle failed, all we can do is bail */
++ nf_ct_unexpect_related(exp);
++ return 0;
++ }
++ get_skb_tcpdata(skb, &ptcp, &tcplen);
++ ptran = ptcp+tranoff;
++ tranlen -= diff;
++ nextparamoff -= diff;
++ nextfieldoff -= diff;
++ }
++ }
++
++ off = nextfieldoff;
++ }
++ if (is_stun)
++ {
++ continue;
++ }
++ off = saveoff;
++ while (off < nextparamoff)
++ {
++ const char* pfieldend;
++ uint nextfieldoff;
++
++ pfieldend = memchr(ptran+off, ';', nextparamoff-off);
++ nextfieldoff = (pfieldend == NULL) ? nextparamoff : pfieldend-ptran+1;
++
++ if (strncmp(ptran+off, "client_port=", 12) == 0)
++ {
++ u_int16_t port;
++ uint numlen;
++ uint origoff;
++ uint origlen;
++ char* rbuf = rbuf1;
++ uint rbuflen = rbuf1len;
++
++ off += 12;
++ origoff = (ptran-ptcp)+off;
++ origlen = 0;
++ numlen = nf_strtou16(ptran+off, &port);
++ off += numlen;
++ origlen += numlen;
++ if (port != prtspexp->loport)
++ {
++ pr_debug("multiple ports found, port %hu ignored\n", port);
++ }
++ else
++ {
++ if (ptran[off] == '-' || ptran[off] == '/')
++ {
++ off++;
++ origlen++;
++ numlen = nf_strtou16(ptran+off, &port);
++ off += numlen;
++ origlen += numlen;
++ rbuf = rbufa;
++ rbuflen = rbufalen;
++ }
++
++ /*
++ * note we cannot just memcpy() if the sizes are the same.
++ * the mangle function does skb resizing, checks for a
++ * cloned skb, and updates the checksums.
++ *
++ * parameter 4 below is offset from start of tcp data.
++ */
++ diff = origlen-rbuflen;
++ if (!nf_nat_mangle_tcp_packet(skb, ct, ctinfo,
++ origoff, origlen, rbuf, rbuflen))
++ {
++ /* mangle failed, all we can do is bail */
++ nf_ct_unexpect_related(exp);
++ return 0;
++ }
++ get_skb_tcpdata(skb, &ptcp, &tcplen);
++ ptran = ptcp+tranoff;
++ tranlen -= diff;
++ nextparamoff -= diff;
++ nextfieldoff -= diff;
++ }
++ }
++
++ off = nextfieldoff;
++ }
++
++ off = nextparamoff;
++ }
++
++ return 1;
++}
++
++static uint
++help_out(struct sk_buff *skb, enum ip_conntrack_info ctinfo,
++ unsigned int matchoff, unsigned int matchlen, struct ip_ct_rtsp_expect* prtspexp,
++ struct nf_conntrack_expect* exp)
++{
++ char* ptcp;
++ uint tcplen;
++ uint hdrsoff;
++ uint hdrslen;
++ uint lineoff;
++ uint linelen;
++ uint off;
++
++ //struct iphdr* iph = (struct iphdr*)(*pskb)->nh.iph;
++ //struct tcphdr* tcph = (struct tcphdr*)((void*)iph + iph->ihl*4);
++
++ get_skb_tcpdata(skb, &ptcp, &tcplen);
++ hdrsoff = matchoff;//exp->seq - ntohl(tcph->seq);
++ hdrslen = matchlen;
++ off = hdrsoff;
++ pr_debug("NAT rtsp help_out\n");
++
++ while (nf_mime_nextline(ptcp, hdrsoff+hdrslen, &off, &lineoff, &linelen))
++ {
++ if (linelen == 0)
++ {
++ break;
++ }
++ if (off > hdrsoff+hdrslen)
++ {
++ pr_info("!! overrun !!");
++ break;
++ }
++ pr_debug("hdr: len=%u, %.*s", linelen, (int)linelen, ptcp+lineoff);
++
++ if (nf_strncasecmp(ptcp+lineoff, "Transport:", 10) == 0)
++ {
++ uint oldtcplen = tcplen;
++ pr_debug("hdr: Transport\n");
++ if (!rtsp_mangle_tran(ctinfo, exp, prtspexp, skb, lineoff, linelen))
++ {
++ pr_debug("hdr: Transport mangle failed");
++ break;
++ }
++ get_skb_tcpdata(skb, &ptcp, &tcplen);
++ hdrslen -= (oldtcplen-tcplen);
++ off -= (oldtcplen-tcplen);
++ lineoff -= (oldtcplen-tcplen);
++ linelen -= (oldtcplen-tcplen);
++ pr_debug("rep: len=%u, %.*s", linelen, (int)linelen, ptcp+lineoff);
++ }
++ }
++
++ return NF_ACCEPT;
++}
++
++static unsigned int
++help(struct sk_buff *skb, enum ip_conntrack_info ctinfo,
++ unsigned int matchoff, unsigned int matchlen, struct ip_ct_rtsp_expect* prtspexp,
++ struct nf_conntrack_expect* exp)
++{
++ int dir = CTINFO2DIR(ctinfo);
++ int rc = NF_ACCEPT;
++
++ switch (dir)
++ {
++ case IP_CT_DIR_ORIGINAL:
++ rc = help_out(skb, ctinfo, matchoff, matchlen, prtspexp, exp);
++ break;
++ case IP_CT_DIR_REPLY:
++ pr_debug("unmangle ! %u\n", ctinfo);
++ /* XXX: unmangle */
++ rc = NF_ACCEPT;
++ break;
++ }
++ //UNLOCK_BH(&ip_rtsp_lock);
++
++ return rc;
++}
++
++static void expected(struct nf_conn* ct, struct nf_conntrack_expect *exp)
++{
++ struct nf_nat_ipv4_multi_range_compat mr;
++ u_int32_t newdstip, newsrcip, newip;
++
++ struct nf_conn *master = ct->master;
++
++ newdstip = master->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u3.ip;
++ newsrcip = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u3.ip;
++ //FIXME (how to port that ?)
++ //code from 2.4 : newip = (HOOK2MANIP(hooknum) == NF_NAT_MANIP_SRC) ? newsrcip : newdstip;
++ newip = newdstip;
++
++ pr_debug("newsrcip=%pI4, newdstip=%pI4, newip=%pI4\n",
++ &newsrcip, &newdstip, &newip);
++
++ mr.rangesize = 1;
++ // We don't want to manip the per-protocol, just the IPs.
++ mr.range[0].flags = NF_NAT_RANGE_MAP_IPS;
++ mr.range[0].min_ip = mr.range[0].max_ip = newip;
++
++ nf_nat_setup_info(ct, &mr.range[0], NF_NAT_MANIP_DST);
++}
++
++
++static void __exit fini(void)
++{
++ nf_nat_rtsp_hook = NULL;
++ nf_nat_rtsp_hook_expectfn = NULL;
++ synchronize_net();
++}
++
++static int __init init(void)
++{
++ printk("nf_nat_rtsp v" IP_NF_RTSP_VERSION " loading\n");
++
++ BUG_ON(nf_nat_rtsp_hook);
++ nf_nat_rtsp_hook = help;
++ nf_nat_rtsp_hook_expectfn = &expected;
++
++ if (stunaddr != NULL)
++ extip = in_aton(stunaddr);
++
++ if (destaction != NULL) {
++ if (strcmp(destaction, "auto") == 0)
++ dstact = DSTACT_AUTO;
++
++ if (strcmp(destaction, "strip") == 0)
++ dstact = DSTACT_STRIP;
++
++ if (strcmp(destaction, "none") == 0)
++ dstact = DSTACT_NONE;
++ }
++
++ return 0;
++}
++
++module_init(init);
++module_exit(fini);
+--- a/extensions/Kbuild
++++ b/extensions/Kbuild
+@@ -33,6 +33,7 @@ obj-${build_lscan} += xt_lscan.o
+ obj-${build_pknock} += pknock/
+ obj-${build_psd} += xt_psd.o
+ obj-${build_quota2} += xt_quota2.o
++obj-${build_rtsp} += rtsp/
+
+ -include ${M}/*.Kbuild
+ -include ${M}/Kbuild.*
+--- a/mconfig
++++ b/mconfig
+@@ -24,3 +24,4 @@ build_lscan=m
+ build_pknock=m
+ build_psd=m
+ build_quota2=m
++build_rtsp=m
diff --git a/package/network/utils/xtables-addons/patches/101-rtsp-linux-3.6-compat.patch b/package/network/utils/xtables-addons/patches/101-rtsp-linux-3.6-compat.patch
new file mode 100644
index 0000000..b8e08b3
--- /dev/null
+++ b/package/network/utils/xtables-addons/patches/101-rtsp-linux-3.6-compat.patch
@@ -0,0 +1,22 @@
+--- a/extensions/rtsp/nf_conntrack_rtsp.c
++++ b/extensions/rtsp/nf_conntrack_rtsp.c
+@@ -28,6 +28,7 @@
+ * - Port to new NF API
+ */
+
++#include <linux/version.h>
+ #include <linux/module.h>
+ #include <linux/netfilter.h>
+ #include <linux/ip.h>
+@@ -496,7 +497,11 @@ init(void)
+ } else {
+ sprintf(tmpname, "rtsp-%d", i);
+ }
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)
++ strncpy(hlpr->name, tmpname, sizeof(hlpr->name));
++#else
+ hlpr->name = tmpname;
++#endif
+
+ pr_debug("port #%d: %d\n", i, ports[i]);
+
diff --git a/package/network/utils/xtables-addons/patches/102-rtsp-linux-3.7-compat.patch b/package/network/utils/xtables-addons/patches/102-rtsp-linux-3.7-compat.patch
new file mode 100644
index 0000000..0fe7917
--- /dev/null
+++ b/package/network/utils/xtables-addons/patches/102-rtsp-linux-3.7-compat.patch
@@ -0,0 +1,155 @@
+--- a/extensions/rtsp/nf_conntrack_rtsp.c
++++ b/extensions/rtsp/nf_conntrack_rtsp.c
+@@ -73,7 +73,7 @@ static DEFINE_SPINLOCK(rtsp_buffer_lock)
+ static struct nf_conntrack_expect_policy rtsp_exp_policy;
+
+ unsigned int (*nf_nat_rtsp_hook)(struct sk_buff *skb,
+- enum ip_conntrack_info ctinfo,
++ enum ip_conntrack_info ctinfo, unsigned int protoff,
+ unsigned int matchoff, unsigned int matchlen,struct ip_ct_rtsp_expect* prtspexp,
+ struct nf_conntrack_expect *exp);
+ void (*nf_nat_rtsp_hook_expectfn)(struct nf_conn *ct, struct nf_conntrack_expect *exp);
+@@ -269,7 +269,7 @@ void expected(struct nf_conn *ct, struct
+
+ static inline int
+ help_out(struct sk_buff *skb, unsigned char *rb_ptr, unsigned int datalen,
+- struct nf_conn *ct, enum ip_conntrack_info ctinfo)
++ struct nf_conn *ct, enum ip_conntrack_info ctinfo, unsigned int protoff)
+ {
+ struct ip_ct_rtsp_expect expinfo;
+
+@@ -353,7 +353,7 @@ help_out(struct sk_buff *skb, unsigned c
+ nf_nat_rtsp = rcu_dereference(nf_nat_rtsp_hook);
+ if (nf_nat_rtsp && ct->status & IPS_NAT_MASK)
+ /* pass the request off to the nat helper */
+- ret = nf_nat_rtsp(skb, ctinfo, hdrsoff, hdrslen, &expinfo, exp);
++ ret = nf_nat_rtsp(skb, ctinfo, protoff, hdrsoff, hdrslen, &expinfo, exp);
+ else if (nf_ct_expect_related(exp) != 0) {
+ pr_info("nf_conntrack_expect_related failed\n");
+ ret = NF_DROP;
+@@ -420,7 +420,7 @@ static int help(struct sk_buff *skb, uns
+
+ switch (CTINFO2DIR(ctinfo)) {
+ case IP_CT_DIR_ORIGINAL:
+- ret = help_out(skb, rb_ptr, datalen, ct, ctinfo);
++ ret = help_out(skb, rb_ptr, datalen, ct, ctinfo, protoff);
+ break;
+ case IP_CT_DIR_REPLY:
+ pr_debug("IP_CT_DIR_REPLY\n");
+--- a/extensions/rtsp/nf_conntrack_rtsp.h
++++ b/extensions/rtsp/nf_conntrack_rtsp.h
+@@ -50,6 +50,7 @@ struct ip_ct_rtsp_expect
+
+ extern unsigned int (*nf_nat_rtsp_hook)(struct sk_buff *skb,
+ enum ip_conntrack_info ctinfo,
++ unsigned int protoff,
+ unsigned int matchoff, unsigned int matchlen,
+ struct ip_ct_rtsp_expect *prtspexp,
+ struct nf_conntrack_expect *exp);
+--- a/extensions/rtsp/nf_nat_rtsp.c
++++ b/extensions/rtsp/nf_nat_rtsp.c
+@@ -32,10 +32,10 @@
+
+ #include <linux/module.h>
+ #include <net/tcp.h>
++#include <net/netfilter/nf_conntrack_expect.h>
+ #include <net/netfilter/nf_nat_helper.h>
+-#include <net/netfilter/nf_nat_rule.h>
++#include <net/netfilter/nf_nat.h>
+ #include "nf_conntrack_rtsp.h"
+-#include <net/netfilter/nf_conntrack_expect.h>
+
+ #include <linux/inet.h>
+ #include <linux/ctype.h>
+@@ -102,8 +102,8 @@ get_skb_tcpdata(struct sk_buff* skb, cha
+ static int
+ rtsp_mangle_tran(enum ip_conntrack_info ctinfo,
+ struct nf_conntrack_expect* exp,
+- struct ip_ct_rtsp_expect* prtspexp,
+- struct sk_buff* skb, uint tranoff, uint tranlen)
++ struct ip_ct_rtsp_expect* prtspexp,
++ struct sk_buff* skb, uint protoff, uint tranoff, uint tranlen)
+ {
+ char* ptcp;
+ uint tcplen;
+@@ -256,7 +256,7 @@ rtsp_mangle_tran(enum ip_conntrack_info
+ if (dstact == DSTACT_STRIP || (dstact == DSTACT_AUTO && !is_stun))
+ {
+ diff = nextfieldoff-off;
+- if (!nf_nat_mangle_tcp_packet(skb, ct, ctinfo,
++ if (!nf_nat_mangle_tcp_packet(skb, ct, ctinfo, protoff,
+ off, diff, NULL, 0))
+ {
+ /* mangle failed, all we can do is bail */
+@@ -326,7 +326,7 @@ rtsp_mangle_tran(enum ip_conntrack_info
+ * parameter 4 below is offset from start of tcp data.
+ */
+ diff = origlen-rbuflen;
+- if (!nf_nat_mangle_tcp_packet(skb, ct, ctinfo,
++ if (!nf_nat_mangle_tcp_packet(skb, ct, ctinfo, protoff,
+ origoff, origlen, rbuf, rbuflen))
+ {
+ /* mangle failed, all we can do is bail */
+@@ -351,7 +351,7 @@ rtsp_mangle_tran(enum ip_conntrack_info
+ }
+
+ static uint
+-help_out(struct sk_buff *skb, enum ip_conntrack_info ctinfo,
++help_out(struct sk_buff *skb, enum ip_conntrack_info ctinfo, unsigned int protoff,
+ unsigned int matchoff, unsigned int matchlen, struct ip_ct_rtsp_expect* prtspexp,
+ struct nf_conntrack_expect* exp)
+ {
+@@ -389,7 +389,7 @@ help_out(struct sk_buff *skb, enum ip_co
+ {
+ uint oldtcplen = tcplen;
+ pr_debug("hdr: Transport\n");
+- if (!rtsp_mangle_tran(ctinfo, exp, prtspexp, skb, lineoff, linelen))
++ if (!rtsp_mangle_tran(ctinfo, exp, prtspexp, skb, protoff, lineoff, linelen))
+ {
+ pr_debug("hdr: Transport mangle failed");
+ break;
+@@ -407,7 +407,7 @@ help_out(struct sk_buff *skb, enum ip_co
+ }
+
+ static unsigned int
+-help(struct sk_buff *skb, enum ip_conntrack_info ctinfo,
++help(struct sk_buff *skb, enum ip_conntrack_info ctinfo, unsigned int protoff,
+ unsigned int matchoff, unsigned int matchlen, struct ip_ct_rtsp_expect* prtspexp,
+ struct nf_conntrack_expect* exp)
+ {
+@@ -417,7 +417,7 @@ help(struct sk_buff *skb, enum ip_conntr
+ switch (dir)
+ {
+ case IP_CT_DIR_ORIGINAL:
+- rc = help_out(skb, ctinfo, matchoff, matchlen, prtspexp, exp);
++ rc = help_out(skb, ctinfo, protoff, matchoff, matchlen, prtspexp, exp);
+ break;
+ case IP_CT_DIR_REPLY:
+ pr_debug("unmangle ! %u\n", ctinfo);
+@@ -432,7 +432,7 @@ help(struct sk_buff *skb, enum ip_conntr
+
+ static void expected(struct nf_conn* ct, struct nf_conntrack_expect *exp)
+ {
+- struct nf_nat_ipv4_multi_range_compat mr;
++ struct nf_nat_range nr;
+ u_int32_t newdstip, newsrcip, newip;
+
+ struct nf_conn *master = ct->master;
+@@ -446,12 +446,13 @@ static void expected(struct nf_conn* ct,
+ pr_debug("newsrcip=%pI4, newdstip=%pI4, newip=%pI4\n",
+ &newsrcip, &newdstip, &newip);
+
+- mr.rangesize = 1;
++ memset(&nr, 0, sizeof(nr));
++
+ // We don't want to manip the per-protocol, just the IPs.
+- mr.range[0].flags = NF_NAT_RANGE_MAP_IPS;
+- mr.range[0].min_ip = mr.range[0].max_ip = newip;
++ nr.flags = NF_NAT_RANGE_MAP_IPS;
++ nr.min_addr.ip = nr.max_addr.ip = newip;
+
+- nf_nat_setup_info(ct, &mr.range[0], NF_NAT_MANIP_DST);
++ nf_nat_setup_info(ct, &nr, NF_NAT_MANIP_DST);
+ }
+
+
diff --git a/package/network/utils/xtables-addons/patches/200-add-lua-packetscript.patch b/package/network/utils/xtables-addons/patches/200-add-lua-packetscript.patch
new file mode 100644
index 0000000..c2731b7
--- /dev/null
+++ b/package/network/utils/xtables-addons/patches/200-add-lua-packetscript.patch
@@ -0,0 +1,18230 @@
+--- /dev/null
++++ b/extensions/LUA/byte_array.c
+@@ -0,0 +1,145 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre@dergraf.org>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++#include "controller.h"
++
++/* Initialization helper function. This function should be used whenever
++ * a new byte array need to be initialized. Depending on the arguments it
++ * initializes the array in a different way. Have a look at the inline
++ * comments */
++lua_packet_segment * init_byte_array(lua_State *L, unsigned char * start, int length, int do_copy)
++{
++ lua_packet_segment *array;
++
++ if (length < 0)
++ luaL_error(L, "init_byte_array, requested size < 0");
++
++ if (start && do_copy) {
++ /* we have a start address where we copy from */
++ array = lua_newuserdata(L, sizeof(lua_packet_segment) + length);
++ array->start = (unsigned char *)array + sizeof(lua_packet_segment); /* aligning pointer */
++ memcpy(array->start, start, length);
++ }else if (start && !do_copy) {
++ /* just link the start pointer, in this case you have to free the memory yourself */
++ array = lua_newuserdata(L, sizeof(lua_packet_segment));
++ array->start = start;
++ }else{
++ /* create an empty array, fully managed by Lua */
++ array = lua_newuserdata(L, sizeof(lua_packet_segment) + length);
++ array->start = (unsigned char *)array + sizeof(lua_packet_segment); /* aligning pointer */
++ memset(array->start, 0, length);
++ }
++
++ array->length = length;
++ array->offset = 0;
++ array->changes = NULL;
++
++ luaL_getmetatable(L, LUA_BYTE_ARRAY);
++ lua_setmetatable(L, -2);
++
++ return array;
++}
++
++
++
++/* LUA_API: get one byte of the given byte array
++ * access-pattern: array[<index>] */
++static int32_t get_byte_array(lua_State *L)
++{
++ lua_packet_segment * array = checkbytearray(L, 1);
++ int32_t index = luaL_checkinteger(L, 2); /* array starts with index 0 (not 1 as usual in Lua) */
++
++ luaL_argcheck(L, 0 <= index && index < array->length, 1, "index out of range");
++ lua_pushinteger(L, (array->start + array->offset)[index]);
++
++ return 1;
++}
++
++/* LUA_API: set one byte of the given byte array
++ * access-pattern: array[<index>]= 0xFF */
++static int32_t set_byte_array(lua_State *L)
++{
++ lua_packet_segment * array = checkbytearray(L, 1);
++ uint8_t byte;
++ int32_t index = luaL_checkinteger(L, 2); /* array starts with index 0 (not 1 as usual in Lua) */
++ int32_t val = luaL_checkinteger(L, 3);
++ uint32_t nob = 1 << CHAR_BIT; /* we should use something like 1 << CHAR_BIT */
++
++ luaL_argcheck(L, 0 <= index && index < array->length, 1, "index out of range");
++ luaL_argcheck(L, 0 <= val && val < nob, 2, "cannot cast value to char");
++
++ byte = (uint8_t)val;
++
++ (array->start + array->offset)[index] = byte;
++
++ return 0;
++}
++
++/* LUA_API: get size of the given byte array
++ * access-pattern: #array (__length meta-method) */
++static int32_t get_byte_array_size(lua_State *L)
++{
++ lua_packet_segment * array = checkbytearray(L, 1);
++
++ lua_pushnumber(L, array->length);
++
++ return 1;
++}
++
++
++/* LUA_API: converts a given byte array to a string.
++ * access-pattern: implicit through functions calling the
++ * __to_string() metamethod , e.g. print32_t */
++static int32_t byte_array_to_string(lua_State *L)
++{
++ lua_packet_segment * array = checkbytearray(L, 1);
++ uint8_t buf[(array->length * 3) + 255];
++ uint8_t hexval[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
++ char res[255 + (array->length * 3)]; /* make sure the buffer is big enough*/
++ int32_t i, n;
++ uint8_t *ptr = array->start + array->offset;
++
++ for (i = 0; i < array->length; i++) {
++ buf[i * 3] = hexval[(ptr[i] >> 4) & 0xF];
++ buf[(i * 3) + 1] = hexval[ptr[i] & 0x0F];
++ buf[(i * 3) + 2] = ' '; /* seperator */
++ }
++
++ buf[array->length * 3] = '\0';
++ n = sprintf(res, "byte_array: length: %d value: %s", array->length, buf);
++
++ lua_pushlstring(L, res, n);
++
++ return 1;
++}
++
++static const struct luaL_Reg bytearray_lib_m [] = {
++ { "__len", get_byte_array_size },
++ { "__newindex", set_byte_array },
++ { "__index", get_byte_array },
++ { "__tostring", byte_array_to_string },
++ { NULL, NULL }
++};
++
++void luaopen_bytearraylib(lua_State *L)
++{
++ luaL_newmetatable(L, LUA_BYTE_ARRAY);
++ luaL_register(L, NULL, bytearray_lib_m);
++ lua_pop(L, 1);
++}
++
++
+--- /dev/null
++++ b/extensions/LUA/controller.c
+@@ -0,0 +1,604 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre@dergraf.org>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++
++#if defined(__KERNEL__)
++ #include <linux/mm.h>
++#endif
++#include "controller.h"
++
++/* the array 'supported_protocols' holds all pointers to the
++ * static and dynamic protocol buffers. It is filled by the
++ * call to register_protbuf */
++static struct protocol_buf * supported_protocols[MAX_NR_OF_PROTOCOLS];
++
++/* C_API: the function 'get_protocol_buf' returns the pointer
++ * to the protocol buffer of a given protocol id. */
++struct protocol_buf * get_protocol_buf(uint32_t protocol_id)
++{
++ return (struct protocol_buf *)supported_protocols[protocol_id];
++}
++
++
++/* LUA_INT: the function 'gc_packet_segment' is triggered by the
++ * garbage collector whenever a userdata annotated with one of
++ * the protocol buffer metatable should be collected. */
++static int32_t gc_packet_segment(lua_State *L)
++{
++ lua_packet_segment * seg = (lua_packet_segment *)lua_touserdata(L, 1);
++ if (seg && seg->changes) {
++ seg->changes->ref_count--;
++ if (seg->changes->ref_count <= 0) {
++ kfree(seg->changes->field_length_changes);
++ kfree(seg->changes->field_offset_changes);
++ kfree(seg->changes);
++ seg->changes = NULL;
++ }
++ }
++ return 0;
++}
++
++
++/* LUA_API: the function 'set_raw' is used to set the bytes of a segment
++ * in 'raw' mode. The function is per default available in each protocol
++ * buffer until it gets overridden by a specific setter function inside
++ * a protocol buffer.
++ *
++ * Parameters:
++ * 1. lua_packet_segment (implicit)
++ * 2. int32_t byte_value
++ *
++ * Upvalues:
++ * 1. struct protocol_buf*
++ * 2. int32_t field index, not used in this function
++ *
++ * Return: void
++ */
++static int32_t set_raw(lua_State *L)
++{
++ int32_t i;
++ uint32_t nob;
++ uint8_t byte;
++ uint8_t *ptr;
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ int32_t val = luaL_checkinteger(L, 2);
++
++ nob = 1 << CHAR_BIT;
++
++ luaL_argcheck(L, 0 <= val && val < nob, 2, "cannot cast value to char");
++
++ byte = (uint8_t)val;
++ ptr = seg->start + seg->offset;
++
++ for (i = 0; i < seg->length; i++)
++ ptr[i] = byte;
++
++ return 0;
++}
++
++/* LUA_API: the function 'get_raw' is used to get the bytes of a segment
++ * in 'raw' mode. The function is per default available in each protocol
++ * buffer until it gets overridden by a specific getter function inside
++ * a protocol buffer.
++ *
++ * Parameters:
++ * 1. lua_packet_segment (implicit)
++ * 2. uint32_t offset
++ * 3. uint32_t length
++ *
++ * Upvalues:
++ * 1. struct protocol_buf*
++ * 2. int32_t field index, not used in this function
++ *
++ * Return:
++ * the byte array representing the given array
++ */
++static int32_t get_raw(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ init_byte_array(L, seg->start + seg->offset, seg->length, 1);
++
++ return 1;
++}
++/* LUA_API: The function 'get_segment' is used to get a new segment in 'raw' mode.
++ * Typically this function is applied on another raw segment in order
++ * to extract a part of the segment as new segment.
++ *
++ * Parameters:
++ * 1. lua_packet_segment, implicit through object oriented access seg:raw(..)
++ * 2. uint32_t offset, this indicates where to start the new segment, see e.g below.
++ * 3. uint32_t length, this indicates the size of the new segment
++ *
++ * Upvalues:
++ * 1. struct protocol_buf*
++ * 2. int32_t field index, not used in this function
++ *
++ * Return:
++ * 1. A lua_packet_segment annotated with the according metatable or False in
++ * case the input data is not valid
++ *
++ * Example:
++ *
++ * +------------------------+---------------------------------------+
++ * | function call | resulting lua_packet_segment |
++ * +========================+===+===+===+===+===+===+===+===+===+===+
++ * | seg = packet:raw(0,10) | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
++ * +------------------------+---+---+---+---+---+---+---+---+---+---+
++ * | 1st_half = seg:raw(0,5)| 0 | 1 | 2 | 3 | 4 | |
++ * +------------------------+---+---+---+---+---+---+---+---+---+---+
++ * | 2nd_half = seg:raw(5,5)| | 5 | 6 | 7 | 8 | 9 |
++ * +------------------------+-------------------+---+---+---+---+---+
++ */
++static int32_t get_segment(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++ uint32_t offset = luaL_checkinteger(L, 2);
++ uint32_t length = luaL_checkinteger(L, 3);
++ lua_packet_segment * new = (lua_packet_segment *)lua_newuserdata(L, sizeof(lua_packet_segment));
++
++ new->start = seg->start;
++ new->offset = seg->offset + offset;
++ new->changes = NULL;
++ /* we allow a seg->length == 0 , this enables processing packets where the packetsize is not fixed (0 = not fixed)*/
++ if (seg->length != 0 && length > seg->length) {
++ lua_pushboolean(L, 0);
++ return 1;
++ }
++
++ new->length = length;
++ luaL_getmetatable(L, prot_buf->name);
++ lua_setmetatable(L, -2);
++
++ return 1;
++}
++
++/* LUA_API: the function 'get_segment_size' is used to get the size of a segment.
++ *
++ * Parameters:
++ * 1. lua_packet_segment, implicit through object oriented access seg:raw(..)
++ *
++ * Upvalues:
++ * 1. struct protocol_buf*
++ * 2. int32_t field index, not used in this function
++ *
++ * Return:
++ * 1. Size as lua_Number
++ */
++static int32_t get_segment_size(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ lua_pushnumber(L, seg->length);
++ return 1;
++}
++
++/* LUA_API: the function 'get_segment_offset' is used to get the real offset
++ * of a segment. This function returns the offset of the segment to the start
++ * of the buffer. This means the following
++ * seg1 = packet:raw(2,10)
++ * seg2 = seg1:raw(3,5)
++ * offset = seg2:get_offset()
++ *
++ * will give an offset of 5, since the seg1 starts at offset 2, and seg2 starts
++ * at offset (seg1:get_offset() + 3).
++ *
++ * Parameters:
++ * 1. lua_packet_segment, implicit through object oriented access seg:raw(..)
++ *
++ * Upvalues:
++ * 1. struct protocol_buf*
++ * 2. int32_t field index, not used in this function
++ *
++ * Return:
++ * 1. Offset as lua_Number
++ */
++static int32_t get_segment_offset(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ lua_pushnumber(L, seg->offset);
++ return 1;
++}
++
++/* LUA_API: overwrites the __tostring function of a lua_packet_segment.
++ * this will print32_t a nicely formated string, including length,
++ * offset and name of the protocol buffer.
++ *
++ * Parameters:
++ * 1. lua_packet_segment (implicit)
++ *
++ * Returns:
++ * 1. the representing string
++ */
++static int32_t packet_segment_tostring(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++ int32_t n;
++ char buf[128];
++
++ n = sprintf(buf, "type: %s, offset: %d, length: %d", prot_buf->name, seg->offset, seg->length);
++ lua_pushlstring(L, buf, n);
++
++ return 1;
++}
++
++
++static const struct luaL_Reg seg_access_functions [] = {
++ { "set", set_raw },
++ { "get", get_raw },
++ { "raw", get_segment },
++ { "get_offset", get_segment_offset },
++ { "get_size", get_segment_size },
++ { "to_bytes", get_raw },
++ { "__tostring", packet_segment_tostring },
++ { "__gc", gc_packet_segment },
++ { NULL, NULL }
++};
++
++/* C_API: the function 'get_metatable_from_protocol_type' is a helper
++ * used in controller.c as well as it may find usage in the static
++ * protocol buffers and byte array implementation. */
++void get_metatable_from_protocol_type(lua_State *L, int32_t type)
++{
++ char * table;
++ lua_getglobal(L, SUPPORTED_PROTOCOL_TABLE);
++ lua_rawgeti(L, -1, type);
++ table = (char *)luaL_checkstring(L, -1);
++ lua_pop(L, 2); /* pop the table SUPPORTED_PROTOCOL_TABLE and the string pushed by lua_gettable */
++ luaL_getmetatable(L, table);
++ return;
++}
++
++/* C_INT: the function 'payload_contains_protocol' is used internally.
++ * Depending if static or dynamic protocol buffer it calls the right
++ * validation function. */
++static int32_t payload_contains_protocol(lua_State *L, struct protocol_buf *prot_buf, lua_packet_segment *seg, uint32_t prot_type)
++{
++ if (prot_buf->is_dynamic)
++ return has_protocol_dynamic(L, prot_buf, seg, prot_type);
++ else
++ return prot_buf->has_protocol(L, prot_buf, seg, prot_type);
++}
++
++/* C_INT: the function 'protocol_get_field_changes' is used interally.
++ * It requests the field_changes struct calling the protocol buffers
++ * 'get_field_changes' function. This funciton is called, whenever
++ * the payload field with a given protocol type is requested inside
++ * the function 'get_protocol_field' */
++static struct field_changes * protocol_get_field_changes(lua_State *L, struct protocol_buf *prot_buf, lua_packet_segment * seg)
++{
++ struct field_changes * changes = NULL;
++
++ if (prot_buf->get_field_changes) {
++ if (prot_buf->is_dynamic)
++ changes = get_field_changes_dynamic(L, prot_buf, seg);
++ else
++ changes = prot_buf->get_field_changes(L, seg);
++ /* is already 1 when set by helper 'get_allocated_field_changes,
++ * since not every prot_buf may use this function we enforce it. */
++ changes->ref_count = 1;
++ }
++ return changes;
++}
++
++/* C_INT: the function 'get_field_offset_in_bytes' wrapps the logic of
++ * calculating the new length with considering the optional field_changes. */
++static int32_t get_field_offset_in_bytes(struct protocol_field * field, lua_packet_segment * seg, int32_t field_index)
++{
++ uint32_t nr_of_bits, nr_of_bytes, field_offset;
++
++ field_offset = field->offset;
++ /* do we need to manipulate the default values stored inside the protocol buffer ?? */
++ if (seg->changes)
++ field_offset += seg->changes->field_offset_changes[field_index];
++ /* how many bits remain */
++ nr_of_bits = field_offset & (CHAR_BIT - 1);
++ /* assuming CHAR_BIT == 2 ^ 3 */
++ nr_of_bytes = (field_offset - nr_of_bits) >> 3;
++
++ return seg->offset + nr_of_bytes;
++}
++
++/* C_INT: the function 'get_field_length_in_bytes' wrapps the logic of
++ * calculating the new offset with considering the optional field_changes. */
++static int32_t get_field_length_in_bytes(struct protocol_field * field, lua_packet_segment * seg, int32_t field_index)
++{
++ uint32_t nr_of_bits, nr_of_bytes, field_length;
++
++ field_length = field->length;
++ /* if the field length is smaller than 1 byte, we take the size of one byte
++ * we treat the case where field_length == 0 in a special way ...*/
++ if (field_length < CHAR_BIT && field_length > 0)
++ field_length = CHAR_BIT;
++
++ /* do we need to manipulate the default values stored inside the protocol buffer ?? */
++ if (seg->changes)
++ field_length += seg->changes->field_length_changes[field_index];
++ /* how many bits remain */
++ nr_of_bits = field_length & (CHAR_BIT - 1);
++ /* assuming CHAR_BIT == 2 ^ 3 */
++ nr_of_bytes = (field_length - nr_of_bits) >> 3;
++ return nr_of_bytes;
++}
++
++/* C_INT: the function 'initialize_field_getter_and_setter' initializes
++ * the setter and getter function of the field, considering the optional
++ * field manipulator functions defined inside the protocol buffers. */
++static void initialize_field_getter_and_setter(lua_State *L, struct protocol_buf *prot_buf, int32_t field_index)
++{
++ /* lets check if there is a metatable on top of the stack */
++ struct protocol_field * f = (struct protocol_field *)&prot_buf->protocol_fields[field_index];
++
++ if (!lua_istable(L, -1)) luaL_error(L, "cannot initialize getter and setter for field %s->%s, "
++ "not a table on top of the stack, is '%s'", prot_buf->name, f->name, lua_typename(L, lua_type(L, -1)));
++
++ /* is there a 'getter' to initialize ? */
++ lua_pushlightuserdata(L, prot_buf); /* push upvalue 1 */
++ lua_pushinteger(L, field_index); /* push upvalue 2 */
++ if (f->get) {
++ if (prot_buf->is_dynamic)
++ lua_pushcclosure(L, field_dynamic_getter, 2);
++ else
++ lua_pushcclosure(L, f->get, 2);
++ }else
++ /* there is no specific getter defined - fall back to 'get_raw' */
++ lua_pushcclosure(L, get_raw, 2);
++ /* set the metatable field 'get' */
++ lua_setfield(L, -2, "get");
++
++ /* is there a 'setter' to initialize ? */
++ lua_pushlightuserdata(L, prot_buf); /* push upvalue 1 */
++ lua_pushinteger(L, field_index); /* push upvalue 2 */
++ if (f->set) {
++ if (prot_buf->is_dynamic)
++ lua_pushcclosure(L, field_dynamic_setter, 2);
++ else
++ lua_pushcclosure(L, f->set, 2);
++ }else
++ /* there is no specific setter defined - fall back to 'set_raw' */
++ lua_pushcclosure(L, set_raw, 2);
++ /* set the metatable field 'set' */
++ lua_setfield(L, -2, "set");
++}
++
++/* LUA_API: 'get_protocol_field' is used in Lua as a closure for each field of a protocol
++ * buffer. E.g a call to ip = packet:data(packet_ip) will go to this function,
++ * and trigger the conversion of the raw packet to a ip packet. Each call
++ * to a field function of an IP packet, like ip:daddr() uses this function
++ * to to return the right data. In each case you will end up either with a
++ * new packet segment (annotated with the proper metatable) or a boolean
++ * value (False) if something went wrong. In the case everything went fine,
++ * the newly created lua_packet_segment is annotated with the proper
++ * metatable where the fields get and set also contain the specific getter
++ * and setter functions given by the protocol buffer. E.g. the function call
++ * ip:daddr():get() or ip:daddr():set(...) will call the proper function
++ * defined inside the corresponding field definition.
++ *
++ * Parameters:
++ * 1. lua_packet_segment, implicit through object oriented access seg:raw(..)
++ * 2. type of the protocol buffer, optional, and only used if the accessed
++ * field is the payload field. If a type is provided for the access of the
++ * payload field, the function tries to convert the data pointed to by the
++ * payload field to the given type. To check if such a conversion is
++ * possible, it calls the function pointed to by the protocol buffer member
++ * has_protocol. If this function returns True, the conversion takes place.
++ *
++ * Upvalues:
++ * 1. struct protocol_buf*
++ * 2. int32_t field index
++ *
++ * Return:
++ * 1. A lua_packet_segment annotated with the according metatable or False in
++ * case the input data is not valid
++ */
++static int32_t get_protocol_field(lua_State *L)
++{
++ int32_t prot_type;
++ lua_packet_segment * seg, *new;
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ int32_t field_index = lua_tointeger(L, lua_upvalueindex(2));
++ struct protocol_field * field = &prot_buf->protocol_fields[field_index];
++
++ /* get the current packet segment */
++ seg = checkpacketseg(L, 1, prot_buf->name);
++
++ /* initialize the new packet segment */
++ new = (lua_packet_segment *)lua_newuserdata(L, sizeof(lua_packet_segment));
++ new->start = seg->start; /* the start is unchanged */
++ new->offset = get_field_offset_in_bytes(field, seg, field_index);
++ new->length = get_field_length_in_bytes(field, seg, field_index);
++
++ /* if new->length == 0 then no configuration was done, we guess the size by subtracting the
++ * new offset from the packet length. since the old length is getting initialized by the
++ * netfilter extension this assumption holds for the very last field of the protocol.
++ * this 'feature' should be used by protocol buffers containing a payload, whereas the
++ * payload field is the last field of the buffer. However, at compile-time unknown field
++ * sizes (and offsets) of fields not being placed at the end of the protocol should be
++ * initialized using the 'get_field_changes' hook system. */
++ if (new->length == 0)
++ new->length = (seg->length + seg->offset) - (new->offset);
++ /*
++ printf("%s->%s:: seg->offset %i, seg->length %i, new->offset %i, new->length %i\n",
++ prot_buf->name, field->name, seg->offset, seg->length, new->offset, new->length);
++ */
++ /* special care for packet payload requests */
++ if (prot_buf->payload_field != NULL && strcmp(prot_buf->payload_field, field->name) == 0) {
++ /* we know the payload field is requested */
++ /* the requested payload can be delivered either as a common segment or as
++ * an other packet type, such a conversion needs an extra protocol parameter
++ * ... so lets check */
++
++ if (lua_isnumber(L, 2)) {
++ /* we have an extra parameter, ... lets see if it is a valid protocol
++ * the parameter is the index of the 'supported_protocols'-array member */
++ prot_type = lua_tointeger(L, 2);
++ if (prot_type >= 0 && prot_type < PACKET_SENTINEL) {
++ /* we are sure the purpose of the request is to get the payload data,
++ * converted to the given protocol. lets check if the payload contains
++ * data of the given protocol */
++ if (payload_contains_protocol(L, prot_buf, seg, prot_type)) {
++ /* success, we can push the metatable for the given protocol */
++ get_metatable_from_protocol_type(L, prot_type);
++ if (!lua_isnil(L, -1)) /* check if the metatable was found */
++ /* perhaps the field offsets and lengths of the containing protocol
++ * are not set correctly. request the optional 'field_changes' structure
++ * holding the changes for lengths and offsets. */
++ new->changes = protocol_get_field_changes(L, get_protocol_buf(prot_type), new);
++ else{
++ /* failed, the requested protocol is not available
++ * we push false and return */
++ lua_pop(L, 1); /* pop the userdata */
++ lua_pushboolean(L, 0);
++ return 1;
++ }
++ }else{
++ /* payload does not carry the provided protocol */
++ /* we push false and return */
++ lua_pop(L, 1); /* pop the userdata */
++ lua_pushboolean(L, 0);
++ return 1;
++ }
++ }else{
++ /* unknown protocol */
++ lua_pop(L, 1); /* pop the userdata */
++ luaL_error(L, "provided protocol is unknown");
++ }
++ }
++ }
++
++ /* if there is still the 'new' userdata on the top, we push our own metatable */
++ if (lua_isuserdata(L, -1)) {
++ luaL_getmetatable(L, prot_buf->name);
++ new->changes = seg->changes;
++ if (seg->changes)
++ new->changes->ref_count++;
++ }
++
++ /* a new packet segment is at index -2 , and the proper metatable at index -1 of the stack
++ * lets set the propper setter and getter function for the requested field */
++ initialize_field_getter_and_setter(L, prot_buf, field_index);
++
++ lua_setmetatable(L, -2);
++ return 1;
++}
++
++/* C_API: 'register_protbuf' is only used internally. This function takes a
++ * pointer to a fully initialized protocol buffer struct and registers it
++ * inside the Lua state. Registering means:
++ *
++ * 1. it creates a new metatable with the name of the protocol buffer.
++ * 2. it registers the default functions which are stored in the luaL_Reg
++ * array seg_access_functions.
++ * 3. it loops over the protocol fields stored at prot_buf->protocol_fields
++ * and registers a new function (using the field name) inside the
++ * metatable. Each field points to the function 'get_protocol_field'
++ * which acts as a closure taking a pointer to the protocol buffer as
++ * well as the index of the field as upvalues.
++ * 4. The protocol index, serves as numerical identifier of this protocol
++ * buffer or even of the protocol itself. This index is stored as a
++ * global value inside the Lua state as well as inside the Lua table
++ * 'supported_protocols'. Assuming the name of a procotol buffer is
++ * "packet_ip" the following statements are true:
++ *
++ * supported_protocols[protocol_index] == "packet_ip"
++ * packet_ip == protocol_index
++ *
++ * This allows you to get all registered protocols from within Lua. This
++ * is especially usefull for the dynamic protocol buffers where you have
++ * to provide your own "has_protocol"-function, which probably needs the
++ * information on which protocols it is able to contain.
++ */
++void register_protbuf(lua_State *L, struct protocol_buf * prot_buf, uint32_t protocol_index)
++{
++ int32_t field_index;
++ luaL_Reg *reg = (struct luaL_Reg *)seg_access_functions;
++ struct protocol_field * field = prot_buf->protocol_fields;
++
++ luaL_newmetatable(L, prot_buf->name);
++
++ /* metatable.__index = metatable */
++ lua_pushvalue(L, -1); /* duplicates the metatable */
++ lua_setfield(L, -2, "__index");
++
++ /* pushing default functions */
++ for (; reg->name; reg++) {
++ lua_pushlightuserdata(L, (void *)prot_buf);
++ lua_pushcclosure(L, reg->func, 1);
++ lua_setfield(L, -2, reg->name);
++ }
++
++ /* pushing functions specific to the protocol buffer */
++ for (field_index = 0; field->name; field++, field_index++) {
++ lua_pushlightuserdata(L, (void *)prot_buf); /* upvalue: prot_buf */
++ lua_pushinteger(L, field_index); /* upvalue: index of protocol field */
++ lua_pushcclosure(L, get_protocol_field, 2);
++ lua_setfield(L, -2, field->name);
++ }
++ /* pop the metatable */
++ lua_pop(L, 1);
++
++ /* registering the array-index as the protocol_id*/
++ lua_getglobal(L, "_G");
++ lua_pushinteger(L, protocol_index);
++ lua_setfield(L, -2, prot_buf->name);
++ lua_pop(L, 1); /* pop _G */
++
++ lua_getglobal(L, SUPPORTED_PROTOCOL_TABLE);
++ lua_pushstring(L, prot_buf->name);
++ lua_rawseti(L, -2, protocol_index);
++
++ lua_pop(L, 1); /* pop SUPPORTED_PROTOCOL_TABLE */
++
++ supported_protocols[protocol_index] = prot_buf;
++}
++
++void luaopen_controller(lua_State *L)
++{
++ /* registering a table inside the _G with table[protocol_index] = prot_buf->name */
++ lua_getglobal(L, "_G");
++ lua_newtable(L);
++ lua_setfield(L, -2, SUPPORTED_PROTOCOL_TABLE);
++ lua_pop(L, 1); /* pop _G */
++
++ luaopen_protbuf_raw(L);
++ luaopen_protbuf_eth(L);
++ luaopen_protbuf_ip(L);
++ luaopen_protbuf_icmp(L);
++ luaopen_protbuf_tcp(L);
++ luaopen_protbuf_tcp_options(L);
++ luaopen_protbuf_udp(L);
++ luaopen_protbuf_tftp(L);
++ luaopen_protbuf_dynamic(L);
++ /* should follow all other static buffers */
++#if defined(__KERNEL__)
++ luaopen_nflib(L);
++#endif
++
++ luaopen_bytearraylib(L);
++}
++
++
++
++
+--- /dev/null
++++ b/extensions/LUA/controller.h
+@@ -0,0 +1,264 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre@dergraf.org>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++
++#ifndef CONTROLLER_H_
++#define CONTROLLER_H_
++
++#include "stdlib.h" /* wrapper */
++#include "string.h" /* wrapper */
++#include "lua.h"
++#include "lualib.h"
++#include "lauxlib.h"
++
++#if defined(__KERNEL__)
++#include <linux/skbuff.h>
++#include <linux/slab.h>
++#include <linux/vmalloc.h>
++#endif
++
++
++/* to compile the stuff in userspace (for testing)*/
++#if !defined(__KERNEL__)
++#include <stdint.h>
++#define pr_debug printf;
++
++#define kmalloc(size, type) malloc(size)
++#define kfree(ptr) free(ptr)
++
++#endif
++
++
++/**********************************************************************/
++/* nf Lua configuration */
++/**********************************************************************/
++#define MAX_NR_OF_PROTOCOLS 16
++#define SUPPORTED_PROTOCOL_TABLE "supported_protocols"
++
++#define MAX_NR_OF_FIELDS_IN_DYN_PROT_BUF 32
++
++
++/**********************************************************************/
++/* Static Protocol Buffer configuration */
++/**********************************************************************/
++
++/* the definitions of the stringified expression of the prot_bufs...
++ * make sure all static prot_bufs are listed and are unique */
++#define LUA_PACKET_SEG_RAW "packet_raw"
++#define LUA_PACKET_SEG_ETH "packet_eth"
++#define LUA_PACKET_SEG_ICMP "packet_icmp"
++#define LUA_PACKET_SEG_IP "packet_ip"
++#define LUA_PACKET_SEG_TCP "packet_tcp"
++#define LUA_PACKET_SEG_TCP_OPT "packet_tcp_opt"
++#define LUA_PACKET_SEG_UDP "packet_udp"
++#define LUA_PACKET_SEG_TFTP "packet_tftp"
++
++/* the enum holding all static prot_bufs... make sure it contains all
++ * static prot_bufs */
++enum PROT_BUF {
++ PACKET_RAW,
++ PACKET_ETH,
++ PACKET_IP,
++ PACKET_ICMP,
++ PACKET_TCP,
++ PACKET_TCP_OPTIONS,
++ PACKET_UDP,
++ PACKET_TFTP,
++ PACKET_DYNAMIC,
++ PACKET_SENTINEL
++};
++
++/* the luaopen-function of the prot_bufs... make sure it is called
++ * inside luaopen_controller */
++void luaopen_protbuf_raw(lua_State *L);
++void luaopen_protbuf_eth(lua_State *L);
++void luaopen_protbuf_ip(lua_State *L);
++void luaopen_protbuf_icmp(lua_State *L);
++void luaopen_protbuf_tcp(lua_State *L);
++void luaopen_protbuf_tcp_options(lua_State *L);
++void luaopen_protbuf_udp(lua_State *L);
++void luaopen_protbuf_tftp(lua_State *L);
++void luaopen_protbuf_dynamic(lua_State *L);
++
++/**********************************************************************/
++/* field changes */
++/**********************************************************************/
++struct field_changes {
++ int ref_count;
++ int *field_length_changes;
++ int *field_offset_changes;
++};
++
++/**********************************************************************/
++/* lua packet segment */
++/* ------------------ */
++/* The struct lua_packet_segment is the integral part of a Lua packet.*/
++/* At the very beginning, when a new packet arrives in `lua_tg`_ such */
++/* a struct is initialized. The field start then points to the lowest */
++/* available header inside the sk_buff structure. During packet */
++/* processing the start pointer remains the same, only the offset and */
++/* length value change. */
++/**********************************************************************/
++#define checkpacketseg(L, i, seg_type) \
++ (lua_packet_segment *)luaL_checkudata(L, i, seg_type)
++
++typedef struct lua_packet_segment {
++ unsigned int offset;
++ unsigned int length;
++ struct field_changes * changes;
++ unsigned char * start; /* need to be at the end because of the memory alignment */
++} lua_packet_segment;
++
++/**********************************************************************/
++/* protocol field */
++/* -------------- */
++/* This structure is a container for the field definitions used by the*/
++/* protocol buffer. Each protocol field is expressed using this struct*/
++/* Have a look at the protocol buffers to see how the struct gets */
++/* initialized. */
++/* */
++/* name: */
++/* This member expresses the name of the field, ending */
++/* in its own Lua function to access the field. */
++/* offset / length: */
++/* These members do specify the position inside the protocol header */
++/* in bits (not bytes!). */
++/* get / set: */
++/* The get and set functions take a function pointer pointing to the*/
++/* specific getter and setter function for this field. */
++/**********************************************************************/
++struct protocol_field {
++ const char * name;
++ uint32_t offset;
++ uint32_t length;
++ lua_CFunction get;
++ lua_CFunction set;
++};
++#define PROT_FIELD_SENTINEL { NULL, 0, 0, NULL, NULL }
++
++
++/**********************************************************************/
++/* protocol_buf */
++/**********************************************************************/
++/* This structure is a container for all the information needed for a
++ * protocol buffer. It gets initialized in each protocol buffer header
++ * file or for the dynamic protocol buffers on runtime using the
++ * 'register_dynamic_protocol_buffer' function.
++ *
++ * name:
++ * This member is used throughout the system. It is also exported
++ * to Lua as a variable name holding the index of the 'supported_protocols'
++ * array. The name is also used as the name of the generated Lua
++ * metatable, that is why inside the macro checkpacketseg_ it
++ * is always the name of a protocol buffer that is passed as the
++ * second parameter.
++ * payload_field:
++ * This member holds the string of the field responsible for payload
++ * data. The payload field of a protocol has an extra property, since
++ * it can be used to invoke another protocol buffer that is applied to
++ * the payload content.
++ * has_protocol:
++ * This member is used together with the payload_field. Since we must
++ * be sure that the payload content does really contain a protocol
++ * of type X. The function pointed to by has_protocol checks if the
++ * protocol buffer X can be applied on the payload_data.
++ * protocol_fields:
++ * This member points to the array of 'protocol_field' structures
++ * get_field_changes:
++ * This member is optional. It is used to return a pointer to an initialized
++ * field_changes struct. The function is called, whenever the payload field
++ * is requested with a given protocol type. Usually this function will
++ * initialize the field_changes struct depending on the content of the
++ * payload data. e.g.
++ * tcp = ip:data(packet_tcp)
++ * such a request will call the 'get_field_changes' function of the tcp
++ * protocol buffer. This enables, that the tcp options field have the proper
++ * length as well as the tcp data start at the right offset.
++ */
++struct protocol_buf {
++ int is_dynamic;
++ const char * name;
++ char * payload_field;
++ int (*has_protocol)(lua_State *L, struct protocol_buf *prot_buf, lua_packet_segment * seg, int type);
++ struct protocol_field * protocol_fields;
++ struct field_changes * (*get_field_changes)(lua_State *L, lua_packet_segment * seg);
++};
++
++/**********************************************************************/
++/* lua byte array library */
++/**********************************************************************/
++#define LUA_BYTE_ARRAY "byte_array"
++#define checkbytearray(L, i) \
++ (lua_packet_segment *)luaL_checkudata(L, i, LUA_BYTE_ARRAY)
++lua_packet_segment * init_byte_array(lua_State *L, unsigned char * start, int length, int do_copy);
++void luaopen_bytearraylib(lua_State *L);
++
++
++/**********************************************************************/
++/* lua netfilter environment library */
++/**********************************************************************/
++#define NETFILTER_LIB "nf"
++#if defined(__KERNEL__)
++ struct lua_env {
++ lua_State *L;
++ /* perhaps more to come here (e.g. a state per CPU) */
++ };
++ #define LUA_ENV "lua_env"
++ #define checkluaenv(L, i) \
++ (struct lua_env *)luaL_checkudata(L, i, LUA_ENV)
++
++ void luaopen_nflib(lua_State *L);
++#endif
++
++void cleanup_dynamic_prot_bufs(void); /* freeing all dynamic prot bufs */
++/**********************************************************************/
++/* lua protbuf helpers */
++/**********************************************************************/
++int get_1_bit_generic(lua_State *L);
++int set_1_bit_generic(lua_State *L);
++int get_lower_4_bit_generic(lua_State *L);
++int set_lower_4_bit_generic(lua_State *L);
++int get_upper_4_bit_generic(lua_State *L);
++int set_upper_4_bit_generic(lua_State *L);
++int get_8_bit_generic(lua_State *L);
++int set_8_bit_generic(lua_State *L);
++int get_16_bit_generic(lua_State *L);
++int set_16_bit_generic(lua_State *L);
++int get_32_bit_generic(lua_State *L);
++int set_32_bit_generic(lua_State *L);
++int set_data_generic(lua_State *L);
++int get_string_generic(lua_State *L);
++int get_byte_generic_str(lua_State *L);
++struct field_changes * get_allocated_field_changes(lua_State *L, int nr_of_fields);
++
++/* only used by the dynamic prot buf subsystem */
++#define MAX_NR_OF_DYN_PROT_BUFS 16
++int field_dynamic_setter(lua_State *L);
++int field_dynamic_getter(lua_State *L);
++int has_protocol_dynamic(lua_State *L, struct protocol_buf * prot_buf, lua_packet_segment * seg, int type);
++struct field_changes * get_field_changes_dynamic(lua_State *L, struct protocol_buf *prot_buf, lua_packet_segment * seg);
++
++/**********************************************************************/
++/* lua controller API */
++/**********************************************************************/
++void luaopen_controller(lua_State *L);
++struct protocol_buf * get_protocol_buf(unsigned int protocol_id);
++void get_metatable_from_protocol_type(lua_State *L, int type);
++void register_protbuf(lua_State *L, struct protocol_buf * prot_buf, unsigned int protocol_index);
++
++
++#endif /* CONTROLLER_H_ */
+--- /dev/null
++++ b/extensions/LUA/Kbuild
+@@ -0,0 +1,49 @@
++# -*- Makefile -*-
++
++# Adding debug options
++EXTRA_CFLAGS += -DDEBUG
++
++obj-m += xt_LUA.o
++
++EXTRA_CFLAGS += -I$(src)/prot_buf_new
++xt_LUA-y += xt_LUA_target.o \
++
++xt_LUA-y += nf_lua.o \
++ prot_buf_helpers.o \
++ byte_array.o \
++ controller.o \
++ prot_buf_ethernet.o \
++ prot_buf_icmp.o \
++ prot_buf_ip.o \
++ prot_buf_raw.o \
++ prot_buf_tcp.o \
++ prot_buf_udp.o \
++ prot_buf_tftp.o \
++ prot_buf_dynamic.o \
++
++
++# Adding Lua Support
++EXTRA_CFLAGS += -I$(src)/lua -I$(src)/lua/include
++xt_LUA-y += lua/lapi.o \
++ lua/lbaselib.o \
++ lua/lcode.o \
++ lua/ldebug.o \
++ lua/ldo.o \
++ lua/ldump.o \
++ lua/lfunc.o \
++ lua/lgc.o \
++ lua/llex.o \
++ lua/lmem.o \
++ lua/lobject.o \
++ lua/lopcodes.o \
++ lua/lparser.o \
++ lua/lstate.o \
++ lua/lstring.o \
++ lua/lstrlib.o \
++ lua/ltable.o \
++ lua/ltablib.o \
++ lua/ltm.o \
++ lua/lundump.o \
++ lua/lvm.o \
++ lua/lzio.o \
++ lua/lauxlib.o \
+--- /dev/null
++++ b/extensions/LUA/libxt_LUA.c
+@@ -0,0 +1,191 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre@dergraf.org>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++
++#include <getopt.h>
++#include <stdio.h>
++#include <stdbool.h>
++#include <stdlib.h>
++#include <string.h>
++#include <xtables.h>
++#include <linux/netfilter.h>
++#include <linux/netfilter/x_tables.h>
++#include "xt_LUA.h"
++
++enum {
++ FLAG_SCRIPT = 1 << 0,
++ FLAG_STATE = 1 << 1,
++ FLAG_FUNCTION = 1 << 2,
++};
++
++static const struct option lua_tg_opts[] = {
++ { .name = "script", .has_arg = true, .val = 's' },
++ { .name = "state", .has_arg = true, .val = 'l' },
++ { .name = "function", .has_arg = true, .val = 'f' },
++ { NULL },
++};
++
++
++static void lua_tg_help(void)
++{
++ printf(
++ "LUA target options:\n"
++ " --script SCRIPT Process packet with the Lua script given by SCRIPT\n"
++ " \n"
++ " --state ID Process packet within the Lua state given by ID.\n"
++ " Omitting --state infers the ID 0, which can be\n"
++ " refered to the 'global' state.\n"
++ " \n"
++ " --function FUNCTION Name of the function that processes the Lua packet\n"
++ "\n");
++}
++
++static void
++lua_tg_init(struct xt_entry_target *target)
++{
++ struct xt_lua_tginfo *info = (void *)target->data;
++
++ info->state_id = 0;
++ strncpy(info->function, "process_packet\0", sizeof("process_packet\0"));
++}
++
++static int
++lua_tg_parse(int32_t c, char **argv, int32_t invert, uint32_t *flags,
++ const void *entry, struct xt_entry_target **target)
++{
++ struct xt_lua_tginfo *info = (void *)(*target)->data;
++ char buf[MAX_SCRIPT_SIZE];
++ long script_size;
++ uint32_t state_id;
++ FILE *file;
++
++ switch (c) {
++ case 's':
++ if (*flags & FLAG_SCRIPT)
++ xtables_error(PARAMETER_PROBLEM,
++ "LUA: Cannot specify --script more than once");
++
++ if (strlen(optarg) > sizeof(info->filename))
++ xtables_error(PARAMETER_PROBLEM,
++ "LUA: Maximum script length is %zu",
++ sizeof(info->filename));
++
++ if (strchr(optarg, '\n'))
++ xtables_error(PARAMETER_PROBLEM,
++ "LUA: Newlines not allowed in script name");
++ file = fopen(optarg, "rb");
++ if (file != NULL) {
++ fseek(file, 0, SEEK_END);
++ script_size = ftell(file);
++ if (script_size > MAX_SCRIPT_SIZE)
++ xtables_error(PARAMETER_PROBLEM,
++ "LUA: The size of the script is too big");
++
++ fseek(file, 0, SEEK_SET);
++ fread(buf, script_size, 1, file);
++ fclose(file);
++ } else
++ xtables_error(PARAMETER_PROBLEM,
++ "LUA: Cannot open script %s", optarg);
++
++ strncpy(info->filename, optarg, sizeof(info->filename));
++ strncpy(info->buf, buf, sizeof(info->buf));
++ info->script_size = script_size;
++
++ *flags |= FLAG_SCRIPT;
++ return true;
++
++ case 'l':
++ if (*flags & FLAG_STATE)
++ xtables_error(PARAMETER_PROBLEM,
++ "LUA: Cannot specify --state more than once");
++
++ if (!xtables_strtoui(optarg, NULL, &state_id, 0, 8))
++ xtables_error(PARAMETER_PROBLEM,
++ "LUA: Invalid --state %s", optarg);
++
++ info->state_id = state_id;
++ *flags |= FLAG_STATE;
++ return true;
++
++ case 'f':
++ if (*flags & FLAG_FUNCTION)
++ xtables_error(PARAMETER_PROBLEM,
++ "LUA: Cannot specify --function more than once");
++ if (strlen(optarg) > sizeof(info->function))
++ xtables_error(PARAMETER_PROBLEM,
++ "LUA: Maximum function length is %zu",
++ sizeof(info->function));
++
++ if (strchr(optarg, '\n'))
++ xtables_error(PARAMETER_PROBLEM,
++ "LUA: Newlines not allowed in function name");
++
++ strncpy(info->function, optarg, sizeof(info->function));
++
++ *flags |= FLAG_FUNCTION;
++ return true;
++ }
++
++ return false;
++}
++
++static void
++lua_tg_check(uint32_t flags)
++{
++ if (flags == 0)
++ xtables_error(PARAMETER_PROBLEM, "LUA: --script parameter required");
++}
++
++static void
++lua_tg_print(const void *entry, const struct xt_entry_target *target,
++ int32_t numeric)
++{
++ const struct xt_lua_tginfo *info = (const void *)target->data;
++
++ printf("LUA script: %s ", info->filename);
++}
++
++static void
++lua_tg_save(const void *entry, const struct xt_entry_target *target)
++{
++ const struct xt_lua_tginfo *info = (const void *)target->data;
++
++ printf("--script %s ", info->filename);
++}
++
++static struct xtables_target lua_tg_reg = {
++ .name = "LUA",
++ .version = XTABLES_VERSION,
++ .revision = 0,
++ .family = NFPROTO_UNSPEC,
++ .size = XT_ALIGN(sizeof(struct xt_lua_tginfo)),
++ .userspacesize = XT_ALIGN(sizeof(struct xt_lua_tginfo)),
++ .help = lua_tg_help,
++ .init = lua_tg_init,
++ .parse = lua_tg_parse,
++ .final_check = lua_tg_check,
++ .print = lua_tg_print,
++ .save = lua_tg_save,
++ .extra_opts = lua_tg_opts,
++};
++
++static __attribute__((constructor)) void lua_tg_ldr(void)
++{
++ xtables_register_target(&lua_tg_reg);
++}
++
+--- /dev/null
++++ b/extensions/LUA/libxt_LUA.man
+@@ -0,0 +1 @@
++Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
+--- /dev/null
++++ b/extensions/LUA/lua/include/ctype.h
+@@ -0,0 +1,11 @@
++#include <linux/ctype.h>
++#undef isalnum
++#define isalnum(c) (((__ismask(c)&(_U|_L|_D)) != 0) && (c > 0))
++#undef isalpha
++#define isalpha(c) (((__ismask(c)&(_U|_L)) != 0) && (c > 0))
++#undef iscntrl
++#define iscntrl(c) (((__ismask(c)&(_C)) != 0) && (c > 0))
++#undef isdigit
++#define isdigit(c) (((__ismask(c)&(_D)) != 0) && (c > 0))
++#undef isspace
++#define isspace(c) (((__ismask(c)&(_S)) != 0) && (c > 0))
+--- /dev/null
++++ b/extensions/LUA/lua/include/errno.h
+@@ -0,0 +1 @@
++#include <linux/errno.h>
+--- /dev/null
++++ b/extensions/LUA/lua/include/locale.h
+@@ -0,0 +1,5 @@
++struct lconv {
++ char * decimal_point ;
++} ;
++
++#define localeconv() NULL
+--- /dev/null
++++ b/extensions/LUA/lua/include/setjmp.h
+@@ -0,0 +1,26 @@
++/*
++ * arch/um/include/sysdep-i386/archsetjmp.h
++ */
++
++#ifndef _KLIBC_ARCHSETJMP_H
++#define _KLIBC_ARCHSETJMP_H
++
++struct __jmp_buf {
++ unsigned int __ebx;
++ unsigned int __esp;
++ unsigned int __ebp;
++ unsigned int __esi;
++ unsigned int __edi;
++ unsigned int __eip;
++};
++
++typedef struct __jmp_buf jmp_buf[1];
++
++#define JB_IP __eip
++#define JB_SP __esp
++
++int setjmp(jmp_buf);
++void longjmp(jmp_buf, int);
++
++#endif /* _SETJMP_H */
++
+--- /dev/null
++++ b/extensions/LUA/lua/include/stdio.h
+@@ -0,0 +1 @@
++#include <linux/kernel.h>
+--- /dev/null
++++ b/extensions/LUA/lua/include/stdlib.h
+@@ -0,0 +1,7 @@
++#include <linux/kernel.h>
++
++#define exit(E) return
++#define strtoul simple_strtoul
++#define strcoll strcmp
++
++#define CHAR_BIT 8
+--- /dev/null
++++ b/extensions/LUA/lua/include/string.h
+@@ -0,0 +1 @@
++#include <linux/string.h>
+--- /dev/null
++++ b/extensions/LUA/lua/lapi.c
+@@ -0,0 +1,1086 @@
++/*
++** $Id: lapi.c,v 2.55.1.5 2008/07/04 18:41:18 roberto Exp $
++** Lua API
++** See Copyright Notice in lua.h
++*/
++
++#include <stdarg.h>
++#include <math.h>
++#include <assert.h>
++#include <string.h>
++
++#define lapi_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "lapi.h"
++#include "ldebug.h"
++#include "ldo.h"
++#include "lfunc.h"
++#include "lgc.h"
++#include "lmem.h"
++#include "lobject.h"
++#include "lstate.h"
++#include "lstring.h"
++#include "ltable.h"
++#include "ltm.h"
++#include "lundump.h"
++#include "lvm.h"
++
++
++
++const char lua_ident[] =
++ "$Lua: " LUA_RELEASE " " LUA_COPYRIGHT " $\n"
++ "$Authors: " LUA_AUTHORS " $\n"
++ "$URL: www.lua.org $\n";
++
++
++
++#define api_checknelems(L, n) api_check(L, (n) <= (L->top - L->base))
++
++#define api_checkvalidindex(L, i) api_check(L, (i) != luaO_nilobject)
++
++#define api_incr_top(L) {api_check(L, L->top < L->ci->top); L->top++;}
++
++
++
++static TValue *index2adr (lua_State *L, int idx) {
++ if (idx > 0) {
++ TValue *o = L->base + (idx - 1);
++ api_check(L, idx <= L->ci->top - L->base);
++ if (o >= L->top) return cast(TValue *, luaO_nilobject);
++ else return o;
++ }
++ else if (idx > LUA_REGISTRYINDEX) {
++ api_check(L, idx != 0 && -idx <= L->top - L->base);
++ return L->top + idx;
++ }
++ else switch (idx) { /* pseudo-indices */
++ case LUA_REGISTRYINDEX: return registry(L);
++ case LUA_ENVIRONINDEX: {
++ Closure *func = curr_func(L);
++ sethvalue(L, &L->env, func->c.env);
++ return &L->env;
++ }
++ case LUA_GLOBALSINDEX: return gt(L);
++ default: {
++ Closure *func = curr_func(L);
++ idx = LUA_GLOBALSINDEX - idx;
++ return (idx <= func->c.nupvalues)
++ ? &func->c.upvalue[idx-1]
++ : cast(TValue *, luaO_nilobject);
++ }
++ }
++}
++
++
++static Table *getcurrenv (lua_State *L) {
++ if (L->ci == L->base_ci) /* no enclosing function? */
++ return hvalue(gt(L)); /* use global table as environment */
++ else {
++ Closure *func = curr_func(L);
++ return func->c.env;
++ }
++}
++
++
++void luaA_pushobject (lua_State *L, const TValue *o) {
++ setobj2s(L, L->top, o);
++ api_incr_top(L);
++}
++
++
++LUA_API int lua_checkstack (lua_State *L, int size) {
++ int res = 1;
++ lua_lock(L);
++ if (size > LUAI_MAXCSTACK || (L->top - L->base + size) > LUAI_MAXCSTACK)
++ res = 0; /* stack overflow */
++ else if (size > 0) {
++ luaD_checkstack(L, size);
++ if (L->ci->top < L->top + size)
++ L->ci->top = L->top + size;
++ }
++ lua_unlock(L);
++ return res;
++}
++
++
++LUA_API void lua_xmove (lua_State *from, lua_State *to, int n) {
++ int i;
++ if (from == to) return;
++ lua_lock(to);
++ api_checknelems(from, n);
++ api_check(from, G(from) == G(to));
++ api_check(from, to->ci->top - to->top >= n);
++ from->top -= n;
++ for (i = 0; i < n; i++) {
++ setobj2s(to, to->top++, from->top + i);
++ }
++ lua_unlock(to);
++}
++
++
++LUA_API void lua_setlevel (lua_State *from, lua_State *to) {
++ to->nCcalls = from->nCcalls;
++}
++
++
++LUA_API lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf) {
++ lua_CFunction old;
++ lua_lock(L);
++ old = G(L)->panic;
++ G(L)->panic = panicf;
++ lua_unlock(L);
++ return old;
++}
++
++
++LUA_API lua_State *lua_newthread (lua_State *L) {
++ lua_State *L1;
++ lua_lock(L);
++ luaC_checkGC(L);
++ L1 = luaE_newthread(L);
++ setthvalue(L, L->top, L1);
++ api_incr_top(L);
++ lua_unlock(L);
++ luai_userstatethread(L, L1);
++ return L1;
++}
++
++
++
++/*
++** basic stack manipulation
++*/
++
++
++LUA_API int lua_gettop (lua_State *L) {
++ return cast_int(L->top - L->base);
++}
++
++
++LUA_API void lua_settop (lua_State *L, int idx) {
++ lua_lock(L);
++ if (idx >= 0) {
++ api_check(L, idx <= L->stack_last - L->base);
++ while (L->top < L->base + idx)
++ setnilvalue(L->top++);
++ L->top = L->base + idx;
++ }
++ else {
++ api_check(L, -(idx+1) <= (L->top - L->base));
++ L->top += idx+1; /* `subtract' index (index is negative) */
++ }
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_remove (lua_State *L, int idx) {
++ StkId p;
++ lua_lock(L);
++ p = index2adr(L, idx);
++ api_checkvalidindex(L, p);
++ while (++p < L->top) setobjs2s(L, p-1, p);
++ L->top--;
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_insert (lua_State *L, int idx) {
++ StkId p;
++ StkId q;
++ lua_lock(L);
++ p = index2adr(L, idx);
++ api_checkvalidindex(L, p);
++ for (q = L->top; q>p; q--) setobjs2s(L, q, q-1);
++ setobjs2s(L, p, L->top);
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_replace (lua_State *L, int idx) {
++ StkId o;
++ lua_lock(L);
++ /* explicit test for incompatible code */
++ if (idx == LUA_ENVIRONINDEX && L->ci == L->base_ci)
++ luaG_runerror(L, "no calling environment");
++ api_checknelems(L, 1);
++ o = index2adr(L, idx);
++ api_checkvalidindex(L, o);
++ if (idx == LUA_ENVIRONINDEX) {
++ Closure *func = curr_func(L);
++ api_check(L, ttistable(L->top - 1));
++ func->c.env = hvalue(L->top - 1);
++ luaC_barrier(L, func, L->top - 1);
++ }
++ else {
++ setobj(L, o, L->top - 1);
++ if (idx < LUA_GLOBALSINDEX) /* function upvalue? */
++ luaC_barrier(L, curr_func(L), L->top - 1);
++ }
++ L->top--;
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_pushvalue (lua_State *L, int idx) {
++ lua_lock(L);
++ setobj2s(L, L->top, index2adr(L, idx));
++ api_incr_top(L);
++ lua_unlock(L);
++}
++
++
++
++/*
++** access functions (stack -> C)
++*/
++
++
++LUA_API int lua_type (lua_State *L, int idx) {
++ StkId o = index2adr(L, idx);
++ return (o == luaO_nilobject) ? LUA_TNONE : ttype(o);
++}
++
++
++LUA_API const char *lua_typename (lua_State *L, int t) {
++ UNUSED(L);
++ return (t == LUA_TNONE) ? "no value" : luaT_typenames[t];
++}
++
++
++LUA_API int lua_iscfunction (lua_State *L, int idx) {
++ StkId o = index2adr(L, idx);
++ return iscfunction(o);
++}
++
++
++LUA_API int lua_isnumber (lua_State *L, int idx) {
++ TValue n;
++ const TValue *o = index2adr(L, idx);
++ return tonumber(o, &n);
++}
++
++
++LUA_API int lua_isstring (lua_State *L, int idx) {
++ int t = lua_type(L, idx);
++ return (t == LUA_TSTRING || t == LUA_TNUMBER);
++}
++
++
++LUA_API int lua_isuserdata (lua_State *L, int idx) {
++ const TValue *o = index2adr(L, idx);
++ return (ttisuserdata(o) || ttislightuserdata(o));
++}
++
++
++LUA_API int lua_rawequal (lua_State *L, int index1, int index2) {
++ StkId o1 = index2adr(L, index1);
++ StkId o2 = index2adr(L, index2);
++ return (o1 == luaO_nilobject || o2 == luaO_nilobject) ? 0
++ : luaO_rawequalObj(o1, o2);
++}
++
++
++LUA_API int lua_equal (lua_State *L, int index1, int index2) {
++ StkId o1, o2;
++ int i;
++ lua_lock(L); /* may call tag method */
++ o1 = index2adr(L, index1);
++ o2 = index2adr(L, index2);
++ i = (o1 == luaO_nilobject || o2 == luaO_nilobject) ? 0 : equalobj(L, o1, o2);
++ lua_unlock(L);
++ return i;
++}
++
++
++LUA_API int lua_lessthan (lua_State *L, int index1, int index2) {
++ StkId o1, o2;
++ int i;
++ lua_lock(L); /* may call tag method */
++ o1 = index2adr(L, index1);
++ o2 = index2adr(L, index2);
++ i = (o1 == luaO_nilobject || o2 == luaO_nilobject) ? 0
++ : luaV_lessthan(L, o1, o2);
++ lua_unlock(L);
++ return i;
++}
++
++
++
++LUA_API lua_Number lua_tonumber (lua_State *L, int idx) {
++ TValue n;
++ const TValue *o = index2adr(L, idx);
++ if (tonumber(o, &n))
++ return nvalue(o);
++ else
++ return 0;
++}
++
++
++LUA_API lua_Integer lua_tointeger (lua_State *L, int idx) {
++ TValue n;
++ const TValue *o = index2adr(L, idx);
++ if (tonumber(o, &n)) {
++ lua_Integer res;
++ lua_Number num = nvalue(o);
++ lua_number2integer(res, num);
++ return res;
++ }
++ else
++ return 0;
++}
++
++
++LUA_API int lua_toboolean (lua_State *L, int idx) {
++ const TValue *o = index2adr(L, idx);
++ return !l_isfalse(o);
++}
++
++
++LUA_API const char *lua_tolstring (lua_State *L, int idx, size_t *len) {
++ StkId o = index2adr(L, idx);
++ if (!ttisstring(o)) {
++ lua_lock(L); /* `luaV_tostring' may create a new string */
++ if (!luaV_tostring(L, o)) { /* conversion failed? */
++ if (len != NULL) *len = 0;
++ lua_unlock(L);
++ return NULL;
++ }
++ luaC_checkGC(L);
++ o = index2adr(L, idx); /* previous call may reallocate the stack */
++ lua_unlock(L);
++ }
++ if (len != NULL) *len = tsvalue(o)->len;
++ return svalue(o);
++}
++
++
++LUA_API size_t lua_objlen (lua_State *L, int idx) {
++ StkId o = index2adr(L, idx);
++ switch (ttype(o)) {
++ case LUA_TSTRING: return tsvalue(o)->len;
++ case LUA_TUSERDATA: return uvalue(o)->len;
++ case LUA_TTABLE: return luaH_getn(hvalue(o));
++ case LUA_TNUMBER: {
++ size_t l;
++ lua_lock(L); /* `luaV_tostring' may create a new string */
++ l = (luaV_tostring(L, o) ? tsvalue(o)->len : 0);
++ lua_unlock(L);
++ return l;
++ }
++ default: return 0;
++ }
++}
++
++
++LUA_API lua_CFunction lua_tocfunction (lua_State *L, int idx) {
++ StkId o = index2adr(L, idx);
++ return (!iscfunction(o)) ? NULL : clvalue(o)->c.f;
++}
++
++
++LUA_API void *lua_touserdata (lua_State *L, int idx) {
++ StkId o = index2adr(L, idx);
++ switch (ttype(o)) {
++ case LUA_TUSERDATA: return (rawuvalue(o) + 1);
++ case LUA_TLIGHTUSERDATA: return pvalue(o);
++ default: return NULL;
++ }
++}
++
++
++LUA_API lua_State *lua_tothread (lua_State *L, int idx) {
++ StkId o = index2adr(L, idx);
++ return (!ttisthread(o)) ? NULL : thvalue(o);
++}
++
++
++LUA_API const void *lua_topointer (lua_State *L, int idx) {
++ StkId o = index2adr(L, idx);
++ switch (ttype(o)) {
++ case LUA_TTABLE: return hvalue(o);
++ case LUA_TFUNCTION: return clvalue(o);
++ case LUA_TTHREAD: return thvalue(o);
++ case LUA_TUSERDATA:
++ case LUA_TLIGHTUSERDATA:
++ return lua_touserdata(L, idx);
++ default: return NULL;
++ }
++}
++
++
++
++/*
++** push functions (C -> stack)
++*/
++
++
++LUA_API void lua_pushnil (lua_State *L) {
++ lua_lock(L);
++ setnilvalue(L->top);
++ api_incr_top(L);
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_pushnumber (lua_State *L, lua_Number n) {
++ lua_lock(L);
++ setnvalue(L->top, n);
++ api_incr_top(L);
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_pushinteger (lua_State *L, lua_Integer n) {
++ lua_lock(L);
++ setnvalue(L->top, cast_num(n));
++ api_incr_top(L);
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_pushlstring (lua_State *L, const char *s, size_t len) {
++ lua_lock(L);
++ luaC_checkGC(L);
++ setsvalue2s(L, L->top, luaS_newlstr(L, s, len));
++ api_incr_top(L);
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_pushstring (lua_State *L, const char *s) {
++ if (s == NULL)
++ lua_pushnil(L);
++ else
++ lua_pushlstring(L, s, strlen(s));
++}
++
++
++LUA_API const char *lua_pushvfstring (lua_State *L, const char *fmt,
++ va_list argp) {
++ const char *ret;
++ lua_lock(L);
++ luaC_checkGC(L);
++ ret = luaO_pushvfstring(L, fmt, argp);
++ lua_unlock(L);
++ return ret;
++}
++
++
++LUA_API const char *lua_pushfstring (lua_State *L, const char *fmt, ...) {
++ const char *ret;
++ va_list argp;
++ lua_lock(L);
++ luaC_checkGC(L);
++ va_start(argp, fmt);
++ ret = luaO_pushvfstring(L, fmt, argp);
++ va_end(argp);
++ lua_unlock(L);
++ return ret;
++}
++
++
++LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) {
++ Closure *cl;
++ lua_lock(L);
++ luaC_checkGC(L);
++ api_checknelems(L, n);
++ cl = luaF_newCclosure(L, n, getcurrenv(L));
++ cl->c.f = fn;
++ L->top -= n;
++ while (n--)
++ setobj2n(L, &cl->c.upvalue[n], L->top+n);
++ setclvalue(L, L->top, cl);
++ lua_assert(iswhite(obj2gco(cl)));
++ api_incr_top(L);
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_pushboolean (lua_State *L, int b) {
++ lua_lock(L);
++ setbvalue(L->top, (b != 0)); /* ensure that true is 1 */
++ api_incr_top(L);
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_pushlightuserdata (lua_State *L, void *p) {
++ lua_lock(L);
++ setpvalue(L->top, p);
++ api_incr_top(L);
++ lua_unlock(L);
++}
++
++
++LUA_API int lua_pushthread (lua_State *L) {
++ lua_lock(L);
++ setthvalue(L, L->top, L);
++ api_incr_top(L);
++ lua_unlock(L);
++ return (G(L)->mainthread == L);
++}
++
++
++
++/*
++** get functions (Lua -> stack)
++*/
++
++
++LUA_API void lua_gettable (lua_State *L, int idx) {
++ StkId t;
++ lua_lock(L);
++ t = index2adr(L, idx);
++ api_checkvalidindex(L, t);
++ luaV_gettable(L, t, L->top - 1, L->top - 1);
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_getfield (lua_State *L, int idx, const char *k) {
++ StkId t;
++ TValue key;
++ lua_lock(L);
++ t = index2adr(L, idx);
++ api_checkvalidindex(L, t);
++ setsvalue(L, &key, luaS_new(L, k));
++ luaV_gettable(L, t, &key, L->top);
++ api_incr_top(L);
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_rawget (lua_State *L, int idx) {
++ StkId t;
++ lua_lock(L);
++ t = index2adr(L, idx);
++ api_check(L, ttistable(t));
++ setobj2s(L, L->top - 1, luaH_get(hvalue(t), L->top - 1));
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_rawgeti (lua_State *L, int idx, int n) {
++ StkId o;
++ lua_lock(L);
++ o = index2adr(L, idx);
++ api_check(L, ttistable(o));
++ setobj2s(L, L->top, luaH_getnum(hvalue(o), n));
++ api_incr_top(L);
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_createtable (lua_State *L, int narray, int nrec) {
++ lua_lock(L);
++ luaC_checkGC(L);
++ sethvalue(L, L->top, luaH_new(L, narray, nrec));
++ api_incr_top(L);
++ lua_unlock(L);
++}
++
++
++LUA_API int lua_getmetatable (lua_State *L, int objindex) {
++ const TValue *obj;
++ Table *mt = NULL;
++ int res;
++ lua_lock(L);
++ obj = index2adr(L, objindex);
++ switch (ttype(obj)) {
++ case LUA_TTABLE:
++ mt = hvalue(obj)->metatable;
++ break;
++ case LUA_TUSERDATA:
++ mt = uvalue(obj)->metatable;
++ break;
++ default:
++ mt = G(L)->mt[ttype(obj)];
++ break;
++ }
++ if (mt == NULL)
++ res = 0;
++ else {
++ sethvalue(L, L->top, mt);
++ api_incr_top(L);
++ res = 1;
++ }
++ lua_unlock(L);
++ return res;
++}
++
++
++LUA_API void lua_getfenv (lua_State *L, int idx) {
++ StkId o;
++ lua_lock(L);
++ o = index2adr(L, idx);
++ api_checkvalidindex(L, o);
++ switch (ttype(o)) {
++ case LUA_TFUNCTION:
++ sethvalue(L, L->top, clvalue(o)->c.env);
++ break;
++ case LUA_TUSERDATA:
++ sethvalue(L, L->top, uvalue(o)->env);
++ break;
++ case LUA_TTHREAD:
++ setobj2s(L, L->top, gt(thvalue(o)));
++ break;
++ default:
++ setnilvalue(L->top);
++ break;
++ }
++ api_incr_top(L);
++ lua_unlock(L);
++}
++
++
++/*
++** set functions (stack -> Lua)
++*/
++
++
++LUA_API void lua_settable (lua_State *L, int idx) {
++ StkId t;
++ lua_lock(L);
++ api_checknelems(L, 2);
++ t = index2adr(L, idx);
++ api_checkvalidindex(L, t);
++ luaV_settable(L, t, L->top - 2, L->top - 1);
++ L->top -= 2; /* pop index and value */
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_setfield (lua_State *L, int idx, const char *k) {
++ StkId t;
++ TValue key;
++ lua_lock(L);
++ api_checknelems(L, 1);
++ t = index2adr(L, idx);
++ api_checkvalidindex(L, t);
++ setsvalue(L, &key, luaS_new(L, k));
++ luaV_settable(L, t, &key, L->top - 1);
++ L->top--; /* pop value */
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_rawset (lua_State *L, int idx) {
++ StkId t;
++ lua_lock(L);
++ api_checknelems(L, 2);
++ t = index2adr(L, idx);
++ api_check(L, ttistable(t));
++ setobj2t(L, luaH_set(L, hvalue(t), L->top-2), L->top-1);
++ luaC_barriert(L, hvalue(t), L->top-1);
++ L->top -= 2;
++ lua_unlock(L);
++}
++
++
++LUA_API void lua_rawseti (lua_State *L, int idx, int n) {
++ StkId o;
++ lua_lock(L);
++ api_checknelems(L, 1);
++ o = index2adr(L, idx);
++ api_check(L, ttistable(o));
++ setobj2t(L, luaH_setnum(L, hvalue(o), n), L->top-1);
++ luaC_barriert(L, hvalue(o), L->top-1);
++ L->top--;
++ lua_unlock(L);
++}
++
++
++LUA_API int lua_setmetatable (lua_State *L, int objindex) {
++ TValue *obj;
++ Table *mt;
++ lua_lock(L);
++ api_checknelems(L, 1);
++ obj = index2adr(L, objindex);
++ api_checkvalidindex(L, obj);
++ if (ttisnil(L->top - 1))
++ mt = NULL;
++ else {
++ api_check(L, ttistable(L->top - 1));
++ mt = hvalue(L->top - 1);
++ }
++ switch (ttype(obj)) {
++ case LUA_TTABLE: {
++ hvalue(obj)->metatable = mt;
++ if (mt)
++ luaC_objbarriert(L, hvalue(obj), mt);
++ break;
++ }
++ case LUA_TUSERDATA: {
++ uvalue(obj)->metatable = mt;
++ if (mt)
++ luaC_objbarrier(L, rawuvalue(obj), mt);
++ break;
++ }
++ default: {
++ G(L)->mt[ttype(obj)] = mt;
++ break;
++ }
++ }
++ L->top--;
++ lua_unlock(L);
++ return 1;
++}
++
++
++LUA_API int lua_setfenv (lua_State *L, int idx) {
++ StkId o;
++ int res = 1;
++ lua_lock(L);
++ api_checknelems(L, 1);
++ o = index2adr(L, idx);
++ api_checkvalidindex(L, o);
++ api_check(L, ttistable(L->top - 1));
++ switch (ttype(o)) {
++ case LUA_TFUNCTION:
++ clvalue(o)->c.env = hvalue(L->top - 1);
++ break;
++ case LUA_TUSERDATA:
++ uvalue(o)->env = hvalue(L->top - 1);
++ break;
++ case LUA_TTHREAD:
++ sethvalue(L, gt(thvalue(o)), hvalue(L->top - 1));
++ break;
++ default:
++ res = 0;
++ break;
++ }
++ if (res) luaC_objbarrier(L, gcvalue(o), hvalue(L->top - 1));
++ L->top--;
++ lua_unlock(L);
++ return res;
++}
++
++
++/*
++** `load' and `call' functions (run Lua code)
++*/
++
++
++#define adjustresults(L,nres) \
++ { if (nres == LUA_MULTRET && L->top >= L->ci->top) L->ci->top = L->top; }
++
++
++#define checkresults(L,na,nr) \
++ api_check(L, (nr) == LUA_MULTRET || (L->ci->top - L->top >= (nr) - (na)))
++
++
++LUA_API void lua_call (lua_State *L, int nargs, int nresults) {
++ StkId func;
++ lua_lock(L);
++ api_checknelems(L, nargs+1);
++ checkresults(L, nargs, nresults);
++ func = L->top - (nargs+1);
++ luaD_call(L, func, nresults);
++ adjustresults(L, nresults);
++ lua_unlock(L);
++}
++
++
++
++/*
++** Execute a protected call.
++*/
++struct CallS { /* data to `f_call' */
++ StkId func;
++ int nresults;
++};
++
++
++static void f_call (lua_State *L, void *ud) {
++ struct CallS *c = cast(struct CallS *, ud);
++ luaD_call(L, c->func, c->nresults);
++}
++
++
++
++LUA_API int lua_pcall (lua_State *L, int nargs, int nresults, int errfunc) {
++ struct CallS c;
++ int status;
++ ptrdiff_t func;
++ lua_lock(L);
++ api_checknelems(L, nargs+1);
++ checkresults(L, nargs, nresults);
++ if (errfunc == 0)
++ func = 0;
++ else {
++ StkId o = index2adr(L, errfunc);
++ api_checkvalidindex(L, o);
++ func = savestack(L, o);
++ }
++ c.func = L->top - (nargs+1); /* function to be called */
++ c.nresults = nresults;
++ status = luaD_pcall(L, f_call, &c, savestack(L, c.func), func);
++ adjustresults(L, nresults);
++ lua_unlock(L);
++ return status;
++}
++
++
++/*
++** Execute a protected C call.
++*/
++struct CCallS { /* data to `f_Ccall' */
++ lua_CFunction func;
++ void *ud;
++};
++
++
++static void f_Ccall (lua_State *L, void *ud) {
++ struct CCallS *c = cast(struct CCallS *, ud);
++ Closure *cl;
++ cl = luaF_newCclosure(L, 0, getcurrenv(L));
++ cl->c.f = c->func;
++ setclvalue(L, L->top, cl); /* push function */
++ api_incr_top(L);
++ setpvalue(L->top, c->ud); /* push only argument */
++ api_incr_top(L);
++ luaD_call(L, L->top - 2, 0);
++}
++
++
++LUA_API int lua_cpcall (lua_State *L, lua_CFunction func, void *ud) {
++ struct CCallS c;
++ int status;
++ lua_lock(L);
++ c.func = func;
++ c.ud = ud;
++ status = luaD_pcall(L, f_Ccall, &c, savestack(L, L->top), 0);
++ lua_unlock(L);
++ return status;
++}
++
++
++LUA_API int lua_load (lua_State *L, lua_Reader reader, void *data,
++ const char *chunkname) {
++ ZIO z;
++ int status;
++ lua_lock(L);
++ if (!chunkname) chunkname = "?";
++ luaZ_init(L, &z, reader, data);
++ status = luaD_protectedparser(L, &z, chunkname);
++ lua_unlock(L);
++ return status;
++}
++
++
++LUA_API int lua_dump (lua_State *L, lua_Writer writer, void *data) {
++ int status;
++ TValue *o;
++ lua_lock(L);
++ api_checknelems(L, 1);
++ o = L->top - 1;
++ if (isLfunction(o))
++ status = luaU_dump(L, clvalue(o)->l.p, writer, data, 0);
++ else
++ status = 1;
++ lua_unlock(L);
++ return status;
++}
++
++
++LUA_API int lua_status (lua_State *L) {
++ return L->status;
++}
++
++
++/*
++** Garbage-collection function
++*/
++
++LUA_API int lua_gc (lua_State *L, int what, int data) {
++ int res = 0;
++ global_State *g;
++ lua_lock(L);
++ g = G(L);
++ switch (what) {
++ case LUA_GCSTOP: {
++ g->GCthreshold = MAX_LUMEM;
++ break;
++ }
++ case LUA_GCRESTART: {
++ g->GCthreshold = g->totalbytes;
++ break;
++ }
++ case LUA_GCCOLLECT: {
++ luaC_fullgc(L);
++ break;
++ }
++ case LUA_GCCOUNT: {
++ /* GC values are expressed in Kbytes: #bytes/2^10 */
++ res = cast_int(g->totalbytes >> 10);
++ break;
++ }
++ case LUA_GCCOUNTB: {
++ res = cast_int(g->totalbytes & 0x3ff);
++ break;
++ }
++ case LUA_GCSTEP: {
++ lu_mem a = (cast(lu_mem, data) << 10);
++ if (a <= g->totalbytes)
++ g->GCthreshold = g->totalbytes - a;
++ else
++ g->GCthreshold = 0;
++ while (g->GCthreshold <= g->totalbytes) {
++ luaC_step(L);
++ if (g->gcstate == GCSpause) { /* end of cycle? */
++ res = 1; /* signal it */
++ break;
++ }
++ }
++ break;
++ }
++ case LUA_GCSETPAUSE: {
++ res = g->gcpause;
++ g->gcpause = data;
++ break;
++ }
++ case LUA_GCSETSTEPMUL: {
++ res = g->gcstepmul;
++ g->gcstepmul = data;
++ break;
++ }
++ default: res = -1; /* invalid option */
++ }
++ lua_unlock(L);
++ return res;
++}
++
++
++
++/*
++** miscellaneous functions
++*/
++
++
++LUA_API int lua_error (lua_State *L) {
++ lua_lock(L);
++ api_checknelems(L, 1);
++ luaG_errormsg(L);
++ lua_unlock(L);
++ return 0; /* to avoid warnings */
++}
++
++
++LUA_API int lua_next (lua_State *L, int idx) {
++ StkId t;
++ int more;
++ lua_lock(L);
++ t = index2adr(L, idx);
++ api_check(L, ttistable(t));
++ more = luaH_next(L, hvalue(t), L->top - 1);
++ if (more) {
++ api_incr_top(L);
++ }
++ else /* no more elements */
++ L->top -= 1; /* remove key */
++ lua_unlock(L);
++ return more;
++}
++
++
++LUA_API void lua_concat (lua_State *L, int n) {
++ lua_lock(L);
++ api_checknelems(L, n);
++ if (n >= 2) {
++ luaC_checkGC(L);
++ luaV_concat(L, n, cast_int(L->top - L->base) - 1);
++ L->top -= (n-1);
++ }
++ else if (n == 0) { /* push empty string */
++ setsvalue2s(L, L->top, luaS_newlstr(L, "", 0));
++ api_incr_top(L);
++ }
++ /* else n == 1; nothing to do */
++ lua_unlock(L);
++}
++
++
++LUA_API lua_Alloc lua_getallocf (lua_State *L, void **ud) {
++ lua_Alloc f;
++ lua_lock(L);
++ if (ud) *ud = G(L)->ud;
++ f = G(L)->frealloc;
++ lua_unlock(L);
++ return f;
++}
++
++
++LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud) {
++ lua_lock(L);
++ G(L)->ud = ud;
++ G(L)->frealloc = f;
++ lua_unlock(L);
++}
++
++
++LUA_API void *lua_newuserdata (lua_State *L, size_t size) {
++ Udata *u;
++ lua_lock(L);
++ luaC_checkGC(L);
++ u = luaS_newudata(L, size, getcurrenv(L));
++ setuvalue(L, L->top, u);
++ api_incr_top(L);
++ lua_unlock(L);
++ return u + 1;
++}
++
++
++
++
++static const char *aux_upvalue (StkId fi, int n, TValue **val) {
++ Closure *f;
++ if (!ttisfunction(fi)) return NULL;
++ f = clvalue(fi);
++ if (f->c.isC) {
++ if (!(1 <= n && n <= f->c.nupvalues)) return NULL;
++ *val = &f->c.upvalue[n-1];
++ return "";
++ }
++ else {
++ Proto *p = f->l.p;
++ if (!(1 <= n && n <= p->sizeupvalues)) return NULL;
++ *val = f->l.upvals[n-1]->v;
++ return getstr(p->upvalues[n-1]);
++ }
++}
++
++
++LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n) {
++ const char *name;
++ TValue *val;
++ lua_lock(L);
++ name = aux_upvalue(index2adr(L, funcindex), n, &val);
++ if (name) {
++ setobj2s(L, L->top, val);
++ api_incr_top(L);
++ }
++ lua_unlock(L);
++ return name;
++}
++
++
++LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n) {
++ const char *name;
++ TValue *val;
++ StkId fi;
++ lua_lock(L);
++ fi = index2adr(L, funcindex);
++ api_checknelems(L, 1);
++ name = aux_upvalue(fi, n, &val);
++ if (name) {
++ L->top--;
++ setobj(L, val, L->top);
++ luaC_barrier(L, clvalue(fi), L->top);
++ }
++ lua_unlock(L);
++ return name;
++}
++
+--- /dev/null
++++ b/extensions/LUA/lua/lapi.h
+@@ -0,0 +1,16 @@
++/*
++** $Id: lapi.h,v 2.2.1.1 2007/12/27 13:02:25 roberto Exp $
++** Auxiliary functions from Lua API
++** See Copyright Notice in lua.h
++*/
++
++#ifndef lapi_h
++#define lapi_h
++
++
++#include "lobject.h"
++
++
++LUAI_FUNC void luaA_pushobject (lua_State *L, const TValue *o);
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/lauxlib.c
+@@ -0,0 +1,674 @@
++/*
++** $Id: lauxlib.c,v 1.159.1.3 2008/01/21 13:20:51 roberto Exp $
++** Auxiliary functions for building Lua libraries
++** See Copyright Notice in lua.h
++*/
++
++#include <stdarg.h>
++
++#if !defined(__KERNEL__)
++#include <ctype.h>
++#include <errno.h>
++#include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
++#else
++#include <linux/ctype.h>
++#include <linux/errno.h>
++#include <linux/kernel.h>
++#include <linux/slab.h>
++#include <linux/string.h>
++#endif
++
++/* This file uses only the official API of Lua.
++** Any function declared here could be written as an application function.
++*/
++
++#define lauxlib_c
++#define LUA_LIB
++
++#include "lua.h"
++
++#include "lauxlib.h"
++
++
++#define FREELIST_REF 0 /* free list of references */
++
++
++/* convert a stack index to positive */
++#define abs_index(L, i) ((i) > 0 || (i) <= LUA_REGISTRYINDEX ? (i) : \
++ lua_gettop(L) + (i) + 1)
++
++
++/*
++** {======================================================
++** Error-report functions
++** =======================================================
++*/
++
++
++LUALIB_API int luaL_argerror (lua_State *L, int narg, const char *extramsg) {
++ lua_Debug ar;
++ if (!lua_getstack(L, 0, &ar)) /* no stack frame? */
++ return luaL_error(L, "bad argument #%d (%s)", narg, extramsg);
++ lua_getinfo(L, "n", &ar);
++ if (strcmp(ar.namewhat, "method") == 0) {
++ narg--; /* do not count `self' */
++ if (narg == 0) /* error is in the self argument itself? */
++ return luaL_error(L, "calling " LUA_QS " on bad self (%s)",
++ ar.name, extramsg);
++ }
++ if (ar.name == NULL)
++ ar.name = "?";
++ return luaL_error(L, "bad argument #%d to " LUA_QS " (%s)",
++ narg, ar.name, extramsg);
++}
++
++
++LUALIB_API int luaL_typerror (lua_State *L, int narg, const char *tname) {
++ const char *msg = lua_pushfstring(L, "%s expected, got %s",
++ tname, luaL_typename(L, narg));
++ return luaL_argerror(L, narg, msg);
++}
++
++
++static void tag_error (lua_State *L, int narg, int tag) {
++ luaL_typerror(L, narg, lua_typename(L, tag));
++}
++
++
++LUALIB_API void luaL_where (lua_State *L, int level) {
++ lua_Debug ar;
++ if (lua_getstack(L, level, &ar)) { /* check function at level */
++ lua_getinfo(L, "Sl", &ar); /* get info about it */
++ if (ar.currentline > 0) { /* is there info? */
++ lua_pushfstring(L, "%s:%d: ", ar.short_src, ar.currentline);
++ return;
++ }
++ }
++ lua_pushliteral(L, ""); /* else, no information available... */
++}
++
++
++LUALIB_API int luaL_error (lua_State *L, const char *fmt, ...) {
++ va_list argp;
++ va_start(argp, fmt);
++ luaL_where(L, 1);
++ lua_pushvfstring(L, fmt, argp);
++ va_end(argp);
++ lua_concat(L, 2);
++ return lua_error(L);
++}
++
++/* }====================================================== */
++
++
++LUALIB_API int luaL_checkoption (lua_State *L, int narg, const char *def,
++ const char *const lst[]) {
++ const char *name = (def) ? luaL_optstring(L, narg, def) :
++ luaL_checkstring(L, narg);
++ int i;
++ for (i=0; lst[i]; i++)
++ if (strcmp(lst[i], name) == 0)
++ return i;
++ return luaL_argerror(L, narg,
++ lua_pushfstring(L, "invalid option " LUA_QS, name));
++}
++
++
++LUALIB_API int luaL_newmetatable (lua_State *L, const char *tname) {
++ lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get registry.name */
++ if (!lua_isnil(L, -1)) /* name already in use? */
++ return 0; /* leave previous value on top, but return 0 */
++ lua_pop(L, 1);
++ lua_newtable(L); /* create metatable */
++ lua_pushvalue(L, -1);
++ lua_setfield(L, LUA_REGISTRYINDEX, tname); /* registry.name = metatable */
++ return 1;
++}
++
++
++LUALIB_API void *luaL_checkudata (lua_State *L, int ud, const char *tname) {
++ void *p = lua_touserdata(L, ud);
++ if (p != NULL) { /* value is a userdata? */
++ if (lua_getmetatable(L, ud)) { /* does it have a metatable? */
++ lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get correct metatable */
++ if (lua_rawequal(L, -1, -2)) { /* does it have the correct mt? */
++ lua_pop(L, 2); /* remove both metatables */
++ return p;
++ }
++ }
++ }
++ luaL_typerror(L, ud, tname); /* else error */
++ return NULL; /* to avoid warnings */
++}
++
++
++LUALIB_API void luaL_checkstack (lua_State *L, int space, const char *mes) {
++ if (!lua_checkstack(L, space))
++ luaL_error(L, "stack overflow (%s)", mes);
++}
++
++
++LUALIB_API void luaL_checktype (lua_State *L, int narg, int t) {
++ if (lua_type(L, narg) != t)
++ tag_error(L, narg, t);
++}
++
++
++LUALIB_API void luaL_checkany (lua_State *L, int narg) {
++ if (lua_type(L, narg) == LUA_TNONE)
++ luaL_argerror(L, narg, "value expected");
++}
++
++
++LUALIB_API const char *luaL_checklstring (lua_State *L, int narg, size_t *len) {
++ const char *s = lua_tolstring(L, narg, len);
++ if (!s) tag_error(L, narg, LUA_TSTRING);
++ return s;
++}
++
++
++LUALIB_API const char *luaL_optlstring (lua_State *L, int narg,
++ const char *def, size_t *len) {
++ if (lua_isnoneornil(L, narg)) {
++ if (len)
++ *len = (def ? strlen(def) : 0);
++ return def;
++ }
++ else return luaL_checklstring(L, narg, len);
++}
++
++
++LUALIB_API lua_Number luaL_checknumber (lua_State *L, int narg) {
++ lua_Number d = lua_tonumber(L, narg);
++ if (d == 0 && !lua_isnumber(L, narg)) /* avoid extra test when d is not 0 */
++ tag_error(L, narg, LUA_TNUMBER);
++ return d;
++}
++
++
++LUALIB_API lua_Number luaL_optnumber (lua_State *L, int narg, lua_Number def) {
++ return luaL_opt(L, luaL_checknumber, narg, def);
++}
++
++
++LUALIB_API lua_Integer luaL_checkinteger (lua_State *L, int narg) {
++ lua_Integer d = lua_tointeger(L, narg);
++ if (d == 0 && !lua_isnumber(L, narg)) /* avoid extra test when d is not 0 */
++ tag_error(L, narg, LUA_TNUMBER);
++ return d;
++}
++
++
++LUALIB_API lua_Integer luaL_optinteger (lua_State *L, int narg,
++ lua_Integer def) {
++ return luaL_opt(L, luaL_checkinteger, narg, def);
++}
++
++
++LUALIB_API int luaL_getmetafield (lua_State *L, int obj, const char *event) {
++ if (!lua_getmetatable(L, obj)) /* no metatable? */
++ return 0;
++ lua_pushstring(L, event);
++ lua_rawget(L, -2);
++ if (lua_isnil(L, -1)) {
++ lua_pop(L, 2); /* remove metatable and metafield */
++ return 0;
++ }
++ else {
++ lua_remove(L, -2); /* remove only metatable */
++ return 1;
++ }
++}
++
++
++LUALIB_API int luaL_callmeta (lua_State *L, int obj, const char *event) {
++ obj = abs_index(L, obj);
++ if (!luaL_getmetafield(L, obj, event)) /* no metafield? */
++ return 0;
++ lua_pushvalue(L, obj);
++ lua_call(L, 1, 1);
++ return 1;
++}
++
++
++LUALIB_API void (luaL_register) (lua_State *L, const char *libname,
++ const luaL_Reg *l) {
++ luaI_openlib(L, libname, l, 0);
++}
++
++
++static int libsize (const luaL_Reg *l) {
++ int size = 0;
++ for (; l->name; l++) size++;
++ return size;
++}
++
++
++LUALIB_API void luaI_openlib (lua_State *L, const char *libname,
++ const luaL_Reg *l, int nup) {
++ if (libname) {
++ int size = libsize(l);
++ /* check whether lib already exists */
++ luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 1);
++ lua_getfield(L, -1, libname); /* get _LOADED[libname] */
++ if (!lua_istable(L, -1)) { /* not found? */
++ lua_pop(L, 1); /* remove previous result */
++ /* try global variable (and create one if it does not exist) */
++ if (luaL_findtable(L, LUA_GLOBALSINDEX, libname, size) != NULL)
++ luaL_error(L, "name conflict for module " LUA_QS, libname);
++ lua_pushvalue(L, -1);
++ lua_setfield(L, -3, libname); /* _LOADED[libname] = new table */
++ }
++ lua_remove(L, -2); /* remove _LOADED table */
++ lua_insert(L, -(nup+1)); /* move library table to below upvalues */
++ }
++ for (; l->name; l++) {
++ int i;
++ for (i=0; i<nup; i++) /* copy upvalues to the top */
++ lua_pushvalue(L, -nup);
++ lua_pushcclosure(L, l->func, nup);
++ lua_setfield(L, -(nup+2), l->name);
++ }
++ lua_pop(L, nup); /* remove upvalues */
++}
++
++
++
++/*
++** {======================================================
++** getn-setn: size for arrays
++** =======================================================
++*/
++
++#if defined(LUA_COMPAT_GETN)
++
++static int checkint (lua_State *L, int topop) {
++ int n = (lua_type(L, -1) == LUA_TNUMBER) ? lua_tointeger(L, -1) : -1;
++ lua_pop(L, topop);
++ return n;
++}
++
++
++static void getsizes (lua_State *L) {
++ lua_getfield(L, LUA_REGISTRYINDEX, "LUA_SIZES");
++ if (lua_isnil(L, -1)) { /* no `size' table? */
++ lua_pop(L, 1); /* remove nil */
++ lua_newtable(L); /* create it */
++ lua_pushvalue(L, -1); /* `size' will be its own metatable */
++ lua_setmetatable(L, -2);
++ lua_pushliteral(L, "kv");
++ lua_setfield(L, -2, "__mode"); /* metatable(N).__mode = "kv" */
++ lua_pushvalue(L, -1);
++ lua_setfield(L, LUA_REGISTRYINDEX, "LUA_SIZES"); /* store in register */
++ }
++}
++
++
++LUALIB_API void luaL_setn (lua_State *L, int t, int n) {
++ t = abs_index(L, t);
++ lua_pushliteral(L, "n");
++ lua_rawget(L, t);
++ if (checkint(L, 1) >= 0) { /* is there a numeric field `n'? */
++ lua_pushliteral(L, "n"); /* use it */
++ lua_pushinteger(L, n);
++ lua_rawset(L, t);
++ }
++ else { /* use `sizes' */
++ getsizes(L);
++ lua_pushvalue(L, t);
++ lua_pushinteger(L, n);
++ lua_rawset(L, -3); /* sizes[t] = n */
++ lua_pop(L, 1); /* remove `sizes' */
++ }
++}
++
++
++LUALIB_API int luaL_getn (lua_State *L, int t) {
++ int n;
++ t = abs_index(L, t);
++ lua_pushliteral(L, "n"); /* try t.n */
++ lua_rawget(L, t);
++ if ((n = checkint(L, 1)) >= 0) return n;
++ getsizes(L); /* else try sizes[t] */
++ lua_pushvalue(L, t);
++ lua_rawget(L, -2);
++ if ((n = checkint(L, 2)) >= 0) return n;
++ return (int)lua_objlen(L, t);
++}
++
++#endif
++
++/* }====================================================== */
++
++
++
++LUALIB_API const char *luaL_gsub (lua_State *L, const char *s, const char *p,
++ const char *r) {
++ const char *wild;
++ size_t l = strlen(p);
++ luaL_Buffer *b = (luaL_Buffer *)kmalloc(sizeof(luaL_Buffer) + BUFSIZ, GFP_ATOMIC);
++ if(!b) luaL_error(L, "luaL_gsub: cannot allocate memory");
++ luaL_buffinit(L, b);
++ while ((wild = strstr(s, p)) != NULL) {
++ luaL_addlstring(b, s, wild - s); /* push prefix */
++ luaL_addstring(b, r); /* push replacement in place of pattern */
++ s = wild + l; /* continue after `p' */
++ }
++ luaL_addstring(b, s); /* push last suffix */
++ luaL_pushresult(b);
++ kfree(b);
++ return lua_tostring(L, -1);
++}
++
++
++LUALIB_API const char *luaL_findtable (lua_State *L, int idx,
++ const char *fname, int szhint) {
++ const char *e;
++ lua_pushvalue(L, idx);
++ do {
++ e = strchr(fname, '.');
++ if (e == NULL) e = fname + strlen(fname);
++ lua_pushlstring(L, fname, e - fname);
++ lua_rawget(L, -2);
++ if (lua_isnil(L, -1)) { /* no such field? */
++ lua_pop(L, 1); /* remove this nil */
++ lua_createtable(L, 0, (*e == '.' ? 1 : szhint)); /* new table for field */
++ lua_pushlstring(L, fname, e - fname);
++ lua_pushvalue(L, -2);
++ lua_settable(L, -4); /* set new table into field */
++ }
++ else if (!lua_istable(L, -1)) { /* field has a non-table value? */
++ lua_pop(L, 2); /* remove table and value */
++ return fname; /* return problematic part of the name */
++ }
++ lua_remove(L, -2); /* remove previous table */
++ fname = e + 1;
++ } while (*e == '.');
++ return NULL;
++}
++
++
++
++/*
++** {======================================================
++** Generic Buffer manipulation
++** =======================================================
++*/
++
++
++#define bufflen(B) ((B)->p - (B)->buffer)
++#define bufffree(B) ((size_t)(LUAL_BUFFERSIZE - bufflen(B)))
++
++#define LIMIT (LUA_MINSTACK/2)
++
++
++static int emptybuffer (luaL_Buffer *B) {
++ size_t l = bufflen(B);
++ if (l == 0) return 0; /* put nothing on stack */
++ else {
++ lua_pushlstring(B->L, B->buffer, l);
++ B->p = B->buffer;
++ B->lvl++;
++ return 1;
++ }
++}
++
++
++static void adjuststack (luaL_Buffer *B) {
++ if (B->lvl > 1) {
++ lua_State *L = B->L;
++ int toget = 1; /* number of levels to concat */
++ size_t toplen = lua_strlen(L, -1);
++ do {
++ size_t l = lua_strlen(L, -(toget+1));
++ if (B->lvl - toget + 1 >= LIMIT || toplen > l) {
++ toplen += l;
++ toget++;
++ }
++ else break;
++ } while (toget < B->lvl);
++ lua_concat(L, toget);
++ B->lvl = B->lvl - toget + 1;
++ }
++}
++
++
++LUALIB_API char *luaL_prepbuffer (luaL_Buffer *B) {
++ if (emptybuffer(B))
++ adjuststack(B);
++ return B->buffer;
++}
++
++
++LUALIB_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) {
++ while (l--)
++ luaL_addchar(B, *s++);
++}
++
++
++LUALIB_API void luaL_addstring (luaL_Buffer *B, const char *s) {
++ luaL_addlstring(B, s, strlen(s));
++}
++
++
++LUALIB_API void luaL_pushresult (luaL_Buffer *B) {
++ emptybuffer(B);
++ lua_concat(B->L, B->lvl);
++ B->lvl = 1;
++}
++
++
++LUALIB_API void luaL_addvalue (luaL_Buffer *B) {
++ lua_State *L = B->L;
++ size_t vl;
++ const char *s = lua_tolstring(L, -1, &vl);
++ if (vl <= bufffree(B)) { /* fit into buffer? */
++ memcpy(B->p, s, vl); /* put it there */
++ B->p += vl;
++ lua_pop(L, 1); /* remove from stack */
++ }
++ else {
++ if (emptybuffer(B))
++ lua_insert(L, -2); /* put buffer before new value */
++ B->lvl++; /* add new value into B stack */
++ adjuststack(B);
++ }
++}
++
++
++LUALIB_API void luaL_buffinit (lua_State *L, luaL_Buffer *B) {
++ B->L = L;
++ B->p = B->buffer;
++ B->lvl = 0;
++}
++
++/* }====================================================== */
++
++
++LUALIB_API int luaL_ref (lua_State *L, int t) {
++ int ref;
++ t = abs_index(L, t);
++ if (lua_isnil(L, -1)) {
++ lua_pop(L, 1); /* remove from stack */
++ return LUA_REFNIL; /* `nil' has a unique fixed reference */
++ }
++ lua_rawgeti(L, t, FREELIST_REF); /* get first free element */
++ ref = (int)lua_tointeger(L, -1); /* ref = t[FREELIST_REF] */
++ lua_pop(L, 1); /* remove it from stack */
++ if (ref != 0) { /* any free element? */
++ lua_rawgeti(L, t, ref); /* remove it from list */
++ lua_rawseti(L, t, FREELIST_REF); /* (t[FREELIST_REF] = t[ref]) */
++ }
++ else { /* no free elements */
++ ref = (int)lua_objlen(L, t);
++ ref++; /* create new reference */
++ }
++ lua_rawseti(L, t, ref);
++ return ref;
++}
++
++
++LUALIB_API void luaL_unref (lua_State *L, int t, int ref) {
++ if (ref >= 0) {
++ t = abs_index(L, t);
++ lua_rawgeti(L, t, FREELIST_REF);
++ lua_rawseti(L, t, ref); /* t[ref] = t[FREELIST_REF] */
++ lua_pushinteger(L, ref);
++ lua_rawseti(L, t, FREELIST_REF); /* t[FREELIST_REF] = ref */
++ }
++}
++
++
++
++/*
++** {======================================================
++** Load functions
++** =======================================================
++*/
++
++#if !defined(__KERNEL__)
++typedef struct LoadF {
++ int extraline;
++ FILE *f;
++ char buff[LUAL_BUFFERSIZE];
++} LoadF;
++
++
++static const char *getF (lua_State *L, void *ud, size_t *size) {
++ LoadF *lf = (LoadF *)ud;
++ (void)L;
++ if (lf->extraline) {
++ lf->extraline = 0;
++ *size = 1;
++ return "\n";
++ }
++ if (feof(lf->f)) return NULL;
++ *size = fread(lf->buff, 1, sizeof(lf->buff), lf->f);
++ return (*size > 0) ? lf->buff : NULL;
++}
++
++
++static int errfile (lua_State *L, const char *what, int fnameindex) {
++ const char *serr = strerror(errno);
++ const char *filename = lua_tostring(L, fnameindex) + 1;
++ lua_pushfstring(L, "cannot %s %s: %s", what, filename, serr);
++ lua_remove(L, fnameindex);
++ return LUA_ERRFILE;
++}
++
++
++LUALIB_API int luaL_loadfile (lua_State *L, const char *filename) {
++ LoadF lf;
++ int status, readstatus;
++ int c;
++ int fnameindex = lua_gettop(L) + 1; /* index of filename on the stack */
++ lf.extraline = 0;
++ if (filename == NULL) {
++ lua_pushliteral(L, "=stdin");
++ lf.f = stdin;
++ }
++ else {
++ lua_pushfstring(L, "@%s", filename);
++ lf.f = fopen(filename, "r");
++ if (lf.f == NULL) return errfile(L, "open", fnameindex);
++ }
++ c = getc(lf.f);
++ if (c == '#') { /* Unix exec. file? */
++ lf.extraline = 1;
++ while ((c = getc(lf.f)) != EOF && c != '\n') ; /* skip first line */
++ if (c == '\n') c = getc(lf.f);
++ }
++ if (c == LUA_SIGNATURE[0] && filename) { /* binary file? */
++ lf.f = freopen(filename, "rb", lf.f); /* reopen in binary mode */
++ if (lf.f == NULL) return errfile(L, "reopen", fnameindex);
++ /* skip eventual `#!...' */
++ while ((c = getc(lf.f)) != EOF && c != LUA_SIGNATURE[0]) ;
++ lf.extraline = 0;
++ }
++ ungetc(c, lf.f);
++ status = lua_load(L, getF, &lf, lua_tostring(L, -1));
++ readstatus = ferror(lf.f);
++ if (filename) fclose(lf.f); /* close file (even in case of errors) */
++ if (readstatus) {
++ lua_settop(L, fnameindex); /* ignore results from `lua_load' */
++ return errfile(L, "read", fnameindex);
++ }
++ lua_remove(L, fnameindex);
++ return status;
++}
++#endif
++
++typedef struct LoadS {
++ const char *s;
++ size_t size;
++} LoadS;
++
++
++static const char *getS (lua_State *L, void *ud, size_t *size) {
++ LoadS *ls = (LoadS *)ud;
++ (void)L;
++ if (ls->size == 0) return NULL;
++ *size = ls->size;
++ ls->size = 0;
++ return ls->s;
++}
++
++
++LUALIB_API int luaL_loadbuffer (lua_State *L, const char *buff, size_t size,
++ const char *name) {
++ LoadS ls;
++ ls.s = buff;
++ ls.size = size;
++ return lua_load(L, getS, &ls, name);
++}
++
++
++LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s) {
++ return luaL_loadbuffer(L, s, strlen(s), s);
++}
++
++
++
++/* }====================================================== */
++
++
++static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) {
++ (void)ud;
++ (void)osize;
++ if (nsize == 0) {
++#if !defined(__KERNEL__)
++ free(ptr);
++#else
++ kfree(ptr);
++#endif
++ return NULL;
++ }
++ else
++#if !defined(__KERNEL__)
++ return realloc(ptr, nsize);
++#else
++ return krealloc(ptr, nsize, GFP_ATOMIC);
++#endif
++}
++
++
++static int lpanic (lua_State *L) {
++ (void)L; /* to avoid warnings */
++#if !defined(__KERNEL__)
++ fprintf(stderr, "PANIC: unprotected error in call to Lua API (%s)\n",
++#else
++ printk( "PANIC: unprotected error in call to Lua API (%s)\n",
++#endif
++ lua_tostring(L, -1));
++ return 0;
++}
++
++
++LUALIB_API lua_State *luaL_newstate (void) {
++ lua_State *L = lua_newstate(l_alloc, NULL);
++ if (L) lua_atpanic(L, &lpanic);
++ return L;
++}
++
+--- /dev/null
++++ b/extensions/LUA/lua/lauxlib.h
+@@ -0,0 +1,184 @@
++/*
++** $Id: lauxlib.h,v 1.88.1.1 2007/12/27 13:02:25 roberto Exp $
++** Auxiliary functions for building Lua libraries
++** See Copyright Notice in lua.h
++*/
++
++
++#ifndef lauxlib_h
++#define lauxlib_h
++
++
++#include <stddef.h>
++#include <linux/slab.h> /* for kmalloc and kfree when allocating luaL_Buffer */
++
++#if !defined(__KERNEL__)
++#include <stdio.h>
++#endif
++
++#include "lua.h"
++
++
++#if defined(LUA_COMPAT_GETN)
++LUALIB_API int (luaL_getn) (lua_State *L, int t);
++LUALIB_API void (luaL_setn) (lua_State *L, int t, int n);
++#else
++#define luaL_getn(L,i) ((int)lua_objlen(L, i))
++#define luaL_setn(L,i,j) ((void)0) /* no op! */
++#endif
++
++#if defined(LUA_COMPAT_OPENLIB)
++#define luaI_openlib luaL_openlib
++#endif
++
++
++/* extra error code for `luaL_load' */
++#define LUA_ERRFILE (LUA_ERRERR+1)
++
++
++typedef struct luaL_Reg {
++ const char *name;
++ lua_CFunction func;
++} luaL_Reg;
++
++
++
++LUALIB_API void (luaI_openlib) (lua_State *L, const char *libname,
++ const luaL_Reg *l, int nup);
++LUALIB_API void (luaL_register) (lua_State *L, const char *libname,
++ const luaL_Reg *l);
++LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e);
++LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e);
++LUALIB_API int (luaL_typerror) (lua_State *L, int narg, const char *tname);
++LUALIB_API int (luaL_argerror) (lua_State *L, int numarg, const char *extramsg);
++LUALIB_API const char *(luaL_checklstring) (lua_State *L, int numArg,
++ size_t *l);
++LUALIB_API const char *(luaL_optlstring) (lua_State *L, int numArg,
++ const char *def, size_t *l);
++LUALIB_API lua_Number (luaL_checknumber) (lua_State *L, int numArg);
++LUALIB_API lua_Number (luaL_optnumber) (lua_State *L, int nArg, lua_Number def);
++
++LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int numArg);
++LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int nArg,
++ lua_Integer def);
++
++LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg);
++LUALIB_API void (luaL_checktype) (lua_State *L, int narg, int t);
++LUALIB_API void (luaL_checkany) (lua_State *L, int narg);
++
++LUALIB_API int (luaL_newmetatable) (lua_State *L, const char *tname);
++LUALIB_API void *(luaL_checkudata) (lua_State *L, int ud, const char *tname);
++
++LUALIB_API void (luaL_where) (lua_State *L, int lvl);
++LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...);
++
++LUALIB_API int (luaL_checkoption) (lua_State *L, int narg, const char *def,
++ const char *const lst[]);
++
++LUALIB_API int (luaL_ref) (lua_State *L, int t);
++LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref);
++
++#if !defined(__KERNEL__)
++LUALIB_API int (luaL_loadfile) (lua_State *L, const char *filename);
++#endif
++
++LUALIB_API int (luaL_loadbuffer) (lua_State *L, const char *buff, size_t sz,
++ const char *name);
++LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s);
++
++LUALIB_API lua_State *(luaL_newstate) (void);
++
++
++LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s, const char *p,
++ const char *r);
++
++LUALIB_API const char *(luaL_findtable) (lua_State *L, int idx,
++ const char *fname, int szhint);
++
++
++
++
++/*
++** ===============================================================
++** some useful macros
++** ===============================================================
++*/
++
++#define luaL_argcheck(L, cond,numarg,extramsg) \
++ ((void)((cond) || luaL_argerror(L, (numarg), (extramsg))))
++#define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL))
++#define luaL_optstring(L,n,d) (luaL_optlstring(L, (n), (d), NULL))
++#define luaL_checkint(L,n) ((int)luaL_checkinteger(L, (n)))
++#define luaL_optint(L,n,d) ((int)luaL_optinteger(L, (n), (d)))
++#define luaL_checklong(L,n) ((long)luaL_checkinteger(L, (n)))
++#define luaL_optlong(L,n,d) ((long)luaL_optinteger(L, (n), (d)))
++
++#define luaL_typename(L,i) lua_typename(L, lua_type(L,(i)))
++
++#if !defined(__KERNEL__)
++#define luaL_dofile(L, fn) \
++ (luaL_loadfile(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0))
++#endif
++
++#define luaL_dostring(L, s) \
++ (luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0))
++
++#define luaL_getmetatable(L,n) (lua_getfield(L, LUA_REGISTRYINDEX, (n)))
++
++#define luaL_opt(L,f,n,d) (lua_isnoneornil(L,(n)) ? (d) : f(L,(n)))
++
++/*
++** {======================================================
++** Generic Buffer manipulation
++** =======================================================
++*/
++
++
++
++typedef struct luaL_Buffer {
++ char *p; /* current position in buffer */
++ int lvl; /* number of strings in the stack (level) */
++ lua_State *L;
++ char buffer[LUAL_BUFFERSIZE];
++} luaL_Buffer;
++
++#define luaL_addchar(B,c) \
++ ((void)((B)->p < ((B)->buffer+LUAL_BUFFERSIZE) || luaL_prepbuffer(B)), \
++ (*(B)->p++ = (char)(c)))
++
++/* compatibility only */
++#define luaL_putchar(B,c) luaL_addchar(B,c)
++
++#define luaL_addsize(B,n) ((B)->p += (n))
++
++
++LUALIB_API void (luaL_buffinit) (lua_State *L, luaL_Buffer *B);
++LUALIB_API char *(luaL_prepbuffer) (luaL_Buffer *B);
++LUALIB_API void (luaL_addlstring) (luaL_Buffer *B, const char *s, size_t l);
++LUALIB_API void (luaL_addstring) (luaL_Buffer *B, const char *s);
++LUALIB_API void (luaL_addvalue) (luaL_Buffer *B);
++LUALIB_API void (luaL_pushresult) (luaL_Buffer *B);
++
++
++/* }====================================================== */
++
++
++/* compatibility with ref system */
++
++/* pre-defined references */
++#define LUA_NOREF (-2)
++#define LUA_REFNIL (-1)
++
++#define lua_ref(L,lock) ((lock) ? luaL_ref(L, LUA_REGISTRYINDEX) : \
++ (lua_pushstring(L, "unlocked references are obsolete"), lua_error(L), 0))
++
++#define lua_unref(L,ref) luaL_unref(L, LUA_REGISTRYINDEX, (ref))
++
++#define lua_getref(L,ref) lua_rawgeti(L, LUA_REGISTRYINDEX, (ref))
++
++
++#define luaL_reg luaL_Reg
++
++#endif
++
++
+--- /dev/null
++++ b/extensions/LUA/lua/lbaselib.c
+@@ -0,0 +1,647 @@
++/*
++** $Id: lbaselib.c,v 1.191.1.6 2008/02/14 16:46:22 roberto Exp $
++** Basic library
++** See Copyright Notice in lua.h
++*/
++
++
++#include <linux/kernel.h>
++#include <linux/ctype.h>
++#include <linux/string.h>
++
++#define lbaselib_c
++#define LUA_LIB
++
++#include "lua.h"
++
++#include "lauxlib.h"
++#include "lualib.h"
++
++
++
++
++/*
++** If your system does not support `stdout', you can just remove this function.
++** If you need, you can define your own `print' function, following this
++** model but changing `fputs' to put the strings at a proper place
++** (a console window or a log file, for instance).
++*/
++static int luaB_print (lua_State *L) {
++ int n = lua_gettop(L); /* number of arguments */
++ int i;
++ lua_getglobal(L, "tostring");
++ for (i=1; i<=n; i++) {
++ const char *s;
++ lua_pushvalue(L, -1); /* function to be called */
++ lua_pushvalue(L, i); /* value to print */
++ lua_call(L, 1, 1);
++ s = lua_tostring(L, -1); /* get result */
++ if (s == NULL)
++ return luaL_error(L, LUA_QL("tostring") " must return a string to "
++ LUA_QL("print"));
++ printk(KERN_INFO "LUA[print]: %s", s);
++ lua_pop(L, 1); /* pop result */
++ }
++ return 0;
++}
++
++
++static int luaB_tonumber (lua_State *L) {
++ int base = luaL_optint(L, 2, 10);
++ if (base == 10) { /* standard conversion */
++ luaL_checkany(L, 1);
++ if (lua_isnumber(L, 1)) {
++ lua_pushnumber(L, lua_tonumber(L, 1));
++ return 1;
++ }
++ }
++ else {
++ const char *s1 = luaL_checkstring(L, 1);
++ char *s2;
++ unsigned long n;
++ luaL_argcheck(L, 2 <= base && base <= 36, 2, "base out of range");
++ n = simple_strtoul(s1, &s2, base);
++ if (s1 != s2) { /* at least one valid digit? */
++ while (isspace((unsigned char)(*s2))) s2++; /* skip trailing spaces */
++ if (*s2 == '\0') { /* no invalid trailing characters? */
++ lua_pushnumber(L, (lua_Number)n);
++ return 1;
++ }
++ }
++ }
++ lua_pushnil(L); /* else not a number */
++ return 1;
++}
++
++
++static int luaB_error (lua_State *L) {
++ int level = luaL_optint(L, 2, 1);
++ lua_settop(L, 1);
++ if (lua_isstring(L, 1) && level > 0) { /* add extra information? */
++ luaL_where(L, level);
++ lua_pushvalue(L, 1);
++ lua_concat(L, 2);
++ }
++ return lua_error(L);
++}
++
++
++static int luaB_getmetatable (lua_State *L) {
++ luaL_checkany(L, 1);
++ if (!lua_getmetatable(L, 1)) {
++ lua_pushnil(L);
++ return 1; /* no metatable */
++ }
++ luaL_getmetafield(L, 1, "__metatable");
++ return 1; /* returns either __metatable field (if present) or metatable */
++}
++
++
++static int luaB_setmetatable (lua_State *L) {
++ int t = lua_type(L, 2);
++ luaL_checktype(L, 1, LUA_TTABLE);
++ luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2,
++ "nil or table expected");
++ if (luaL_getmetafield(L, 1, "__metatable"))
++ luaL_error(L, "cannot change a protected metatable");
++ lua_settop(L, 2);
++ lua_setmetatable(L, 1);
++ return 1;
++}
++
++
++static void getfunc (lua_State *L, int opt) {
++ if (lua_isfunction(L, 1)) lua_pushvalue(L, 1);
++ else {
++ lua_Debug ar;
++ int level = opt ? luaL_optint(L, 1, 1) : luaL_checkint(L, 1);
++ luaL_argcheck(L, level >= 0, 1, "level must be non-negative");
++ if (lua_getstack(L, level, &ar) == 0)
++ luaL_argerror(L, 1, "invalid level");
++ lua_getinfo(L, "f", &ar);
++ if (lua_isnil(L, -1))
++ luaL_error(L, "no function environment for tail call at level %d",
++ level);
++ }
++}
++
++
++static int luaB_getfenv (lua_State *L) {
++ getfunc(L, 1);
++ if (lua_iscfunction(L, -1)) /* is a C function? */
++ lua_pushvalue(L, LUA_GLOBALSINDEX); /* return the thread's global env. */
++ else
++ lua_getfenv(L, -1);
++ return 1;
++}
++
++
++static int luaB_setfenv (lua_State *L) {
++ luaL_checktype(L, 2, LUA_TTABLE);
++ getfunc(L, 0);
++ lua_pushvalue(L, 2);
++ if (lua_isnumber(L, 1) && lua_tonumber(L, 1) == 0) {
++ /* change environment of current thread */
++ lua_pushthread(L);
++ lua_insert(L, -2);
++ lua_setfenv(L, -2);
++ return 0;
++ }
++ else if (lua_iscfunction(L, -2) || lua_setfenv(L, -2) == 0)
++ luaL_error(L,
++ LUA_QL("setfenv") " cannot change environment of given object");
++ return 1;
++}
++
++
++static int luaB_rawequal (lua_State *L) {
++ luaL_checkany(L, 1);
++ luaL_checkany(L, 2);
++ lua_pushboolean(L, lua_rawequal(L, 1, 2));
++ return 1;
++}
++
++
++static int luaB_rawget (lua_State *L) {
++ luaL_checktype(L, 1, LUA_TTABLE);
++ luaL_checkany(L, 2);
++ lua_settop(L, 2);
++ lua_rawget(L, 1);
++ return 1;
++}
++
++static int luaB_rawset (lua_State *L) {
++ luaL_checktype(L, 1, LUA_TTABLE);
++ luaL_checkany(L, 2);
++ luaL_checkany(L, 3);
++ lua_settop(L, 3);
++ lua_rawset(L, 1);
++ return 1;
++}
++
++
++static int luaB_gcinfo (lua_State *L) {
++ lua_pushinteger(L, lua_getgccount(L));
++ return 1;
++}
++
++static int luaB_collectgarbage (lua_State *L) {
++ static const char *const opts[] = {"stop", "restart", "collect",
++ "count", "step", "setpause", "setstepmul", NULL};
++ static const int optsnum[] = {LUA_GCSTOP, LUA_GCRESTART, LUA_GCCOLLECT,
++ LUA_GCCOUNT, LUA_GCSTEP, LUA_GCSETPAUSE, LUA_GCSETSTEPMUL};
++ int o = luaL_checkoption(L, 1, "collect", opts);
++ int ex = luaL_optint(L, 2, 0);
++ int res = lua_gc(L, optsnum[o], ex);
++ switch (optsnum[o]) {
++ case LUA_GCCOUNT: {
++ int b = lua_gc(L, LUA_GCCOUNTB, 0);
++ lua_pushnumber(L, res + ((lua_Number)b/1024));
++ return 1;
++ }
++ case LUA_GCSTEP: {
++ lua_pushboolean(L, res);
++ return 1;
++ }
++ default: {
++ lua_pushnumber(L, res);
++ return 1;
++ }
++ }
++}
++
++
++static int luaB_type (lua_State *L) {
++ luaL_checkany(L, 1);
++ lua_pushstring(L, luaL_typename(L, 1));
++ return 1;
++}
++
++
++static int luaB_next (lua_State *L) {
++ luaL_checktype(L, 1, LUA_TTABLE);
++ lua_settop(L, 2); /* create a 2nd argument if there isn't one */
++ if (lua_next(L, 1))
++ return 2;
++ else {
++ lua_pushnil(L);
++ return 1;
++ }
++}
++
++
++static int luaB_pairs (lua_State *L) {
++ luaL_checktype(L, 1, LUA_TTABLE);
++ lua_pushvalue(L, lua_upvalueindex(1)); /* return generator, */
++ lua_pushvalue(L, 1); /* state, */
++ lua_pushnil(L); /* and initial value */
++ return 3;
++}
++
++
++static int ipairsaux (lua_State *L) {
++ int i = luaL_checkint(L, 2);
++ luaL_checktype(L, 1, LUA_TTABLE);
++ i++; /* next value */
++ lua_pushinteger(L, i);
++ lua_rawgeti(L, 1, i);
++ return (lua_isnil(L, -1)) ? 0 : 2;
++}
++
++
++static int luaB_ipairs (lua_State *L) {
++ luaL_checktype(L, 1, LUA_TTABLE);
++ lua_pushvalue(L, lua_upvalueindex(1)); /* return generator, */
++ lua_pushvalue(L, 1); /* state, */
++ lua_pushinteger(L, 0); /* and initial value */
++ return 3;
++}
++
++
++static int load_aux (lua_State *L, int status) {
++ if (status == 0) /* OK? */
++ return 1;
++ else {
++ lua_pushnil(L);
++ lua_insert(L, -2); /* put before error message */
++ return 2; /* return nil plus error message */
++ }
++}
++
++
++static int luaB_loadstring (lua_State *L) {
++ size_t l;
++ const char *s = luaL_checklstring(L, 1, &l);
++ const char *chunkname = luaL_optstring(L, 2, s);
++ return load_aux(L, luaL_loadbuffer(L, s, l, chunkname));
++}
++
++/*
++static int luaB_loadfile (lua_State *L) {
++ const char *fname = luaL_optstring(L, 1, NULL);
++ return load_aux(L, luaL_loadfile(L, fname));
++}
++*/
++
++/*
++** Reader for generic `load' function: `lua_load' uses the
++** stack for internal stuff, so the reader cannot change the
++** stack top. Instead, it keeps its resulting string in a
++** reserved slot inside the stack.
++*/
++static const char *generic_reader (lua_State *L, void *ud, size_t *size) {
++ (void)ud; /* to avoid warnings */
++ luaL_checkstack(L, 2, "too many nested functions");
++ lua_pushvalue(L, 1); /* get function */
++ lua_call(L, 0, 1); /* call it */
++ if (lua_isnil(L, -1)) {
++ *size = 0;
++ return NULL;
++ }
++ else if (lua_isstring(L, -1)) {
++ lua_replace(L, 3); /* save string in a reserved stack slot */
++ return lua_tolstring(L, 3, size);
++ }
++ else luaL_error(L, "reader function must return a string");
++ return NULL; /* to avoid warnings */
++}
++
++
++static int luaB_load (lua_State *L) {
++ int status;
++ const char *cname = luaL_optstring(L, 2, "=(load)");
++ luaL_checktype(L, 1, LUA_TFUNCTION);
++ lua_settop(L, 3); /* function, eventual name, plus one reserved slot */
++ status = lua_load(L, generic_reader, NULL, cname);
++ return load_aux(L, status);
++}
++
++/*
++static int luaB_dofile (lua_State *L) {
++ const char *fname = luaL_optstring(L, 1, NULL);
++ int n = lua_gettop(L);
++ if (luaL_loadfile(L, fname) != 0) lua_error(L);
++ lua_call(L, 0, LUA_MULTRET);
++ return lua_gettop(L) - n;
++}
++*/
++
++static int luaB_assert (lua_State *L) {
++ luaL_checkany(L, 1);
++ if (!lua_toboolean(L, 1))
++ return luaL_error(L, "%s", luaL_optstring(L, 2, "assertion failed!"));
++ return lua_gettop(L);
++}
++
++
++static int luaB_unpack (lua_State *L) {
++ int i, e, n;
++ luaL_checktype(L, 1, LUA_TTABLE);
++ i = luaL_optint(L, 2, 1);
++ e = luaL_opt(L, luaL_checkint, 3, luaL_getn(L, 1));
++ if (i > e) return 0; /* empty range */
++ n = e - i + 1; /* number of elements */
++ if (n <= 0 || !lua_checkstack(L, n)) /* n <= 0 means arith. overflow */
++ return luaL_error(L, "too many results to unpack");
++ lua_rawgeti(L, 1, i); /* push arg[i] (avoiding overflow problems) */
++ while (i++ < e) /* push arg[i + 1...e] */
++ lua_rawgeti(L, 1, i);
++ return n;
++}
++
++
++static int luaB_select (lua_State *L) {
++ int n = lua_gettop(L);
++ if (lua_type(L, 1) == LUA_TSTRING && *lua_tostring(L, 1) == '#') {
++ lua_pushinteger(L, n-1);
++ return 1;
++ }
++ else {
++ int i = luaL_checkint(L, 1);
++ if (i < 0) i = n + i;
++ else if (i > n) i = n;
++ luaL_argcheck(L, 1 <= i, 1, "index out of range");
++ return n - i;
++ }
++}
++
++
++static int luaB_pcall (lua_State *L) {
++ int status;
++ luaL_checkany(L, 1);
++ status = lua_pcall(L, lua_gettop(L) - 1, LUA_MULTRET, 0);
++ lua_pushboolean(L, (status == 0));
++ lua_insert(L, 1);
++ return lua_gettop(L); /* return status + all results */
++}
++
++
++static int luaB_xpcall (lua_State *L) {
++ int status;
++ luaL_checkany(L, 2);
++ lua_settop(L, 2);
++ lua_insert(L, 1); /* put error function under function to be called */
++ status = lua_pcall(L, 0, LUA_MULTRET, 1);
++ lua_pushboolean(L, (status == 0));
++ lua_replace(L, 1);
++ return lua_gettop(L); /* return status + all results */
++}
++
++
++static int luaB_tostring (lua_State *L) {
++ luaL_checkany(L, 1);
++ if (luaL_callmeta(L, 1, "__tostring")) /* is there a metafield? */
++ return 1; /* use its value */
++ switch (lua_type(L, 1)) {
++ case LUA_TNUMBER:
++ lua_pushstring(L, lua_tostring(L, 1));
++ break;
++ case LUA_TSTRING:
++ lua_pushvalue(L, 1);
++ break;
++ case LUA_TBOOLEAN:
++ lua_pushstring(L, (lua_toboolean(L, 1) ? "true" : "false"));
++ break;
++ case LUA_TNIL:
++ lua_pushliteral(L, "nil");
++ break;
++ default:
++ lua_pushfstring(L, "%s: %p", luaL_typename(L, 1), lua_topointer(L, 1));
++ break;
++ }
++ return 1;
++}
++
++
++static int luaB_newproxy (lua_State *L) {
++ lua_settop(L, 1);
++ lua_newuserdata(L, 0); /* create proxy */
++ if (lua_toboolean(L, 1) == 0)
++ return 1; /* no metatable */
++ else if (lua_isboolean(L, 1)) {
++ lua_newtable(L); /* create a new metatable `m' ... */
++ lua_pushvalue(L, -1); /* ... and mark `m' as a valid metatable */
++ lua_pushboolean(L, 1);
++ lua_rawset(L, lua_upvalueindex(1)); /* weaktable[m] = true */
++ }
++ else {
++ int validproxy = 0; /* to check if weaktable[metatable(u)] == true */
++ if (lua_getmetatable(L, 1)) {
++ lua_rawget(L, lua_upvalueindex(1));
++ validproxy = lua_toboolean(L, -1);
++ lua_pop(L, 1); /* remove value */
++ }
++ luaL_argcheck(L, validproxy, 1, "boolean or proxy expected");
++ lua_getmetatable(L, 1); /* metatable is valid; get it */
++ }
++ lua_setmetatable(L, 2);
++ return 1;
++}
++
++
++static const luaL_Reg base_funcs[] = {
++ {"assert", luaB_assert},
++ {"collectgarbage", luaB_collectgarbage},
++// {"dofile", luaB_dofile},
++ {"error", luaB_error},
++ {"gcinfo", luaB_gcinfo},
++ {"getfenv", luaB_getfenv},
++ {"getmetatable", luaB_getmetatable},
++// {"loadfile", luaB_loadfile},
++ {"load", luaB_load},
++ {"loadstring", luaB_loadstring},
++ {"next", luaB_next},
++ {"pcall", luaB_pcall},
++ {"print", luaB_print},
++ {"rawequal", luaB_rawequal},
++ {"rawget", luaB_rawget},
++ {"rawset", luaB_rawset},
++ {"select", luaB_select},
++ {"setfenv", luaB_setfenv},
++ {"setmetatable", luaB_setmetatable},
++ {"tonumber", luaB_tonumber},
++ {"tostring", luaB_tostring},
++ {"type", luaB_type},
++ {"unpack", luaB_unpack},
++ {"xpcall", luaB_xpcall},
++ {NULL, NULL}
++};
++
++
++/*
++** {======================================================
++** Coroutine library
++** =======================================================
++*/
++
++#define CO_RUN 0 /* running */
++#define CO_SUS 1 /* suspended */
++#define CO_NOR 2 /* 'normal' (it resumed another coroutine) */
++#define CO_DEAD 3
++
++static const char *const statnames[] =
++ {"running", "suspended", "normal", "dead"};
++
++static int costatus (lua_State *L, lua_State *co) {
++ if (L == co) return CO_RUN;
++ switch (lua_status(co)) {
++ case LUA_YIELD:
++ return CO_SUS;
++ case 0: {
++ lua_Debug ar;
++ if (lua_getstack(co, 0, &ar) > 0) /* does it have frames? */
++ return CO_NOR; /* it is running */
++ else if (lua_gettop(co) == 0)
++ return CO_DEAD;
++ else
++ return CO_SUS; /* initial state */
++ }
++ default: /* some error occured */
++ return CO_DEAD;
++ }
++}
++
++
++static int luaB_costatus (lua_State *L) {
++ lua_State *co = lua_tothread(L, 1);
++ luaL_argcheck(L, co, 1, "coroutine expected");
++ lua_pushstring(L, statnames[costatus(L, co)]);
++ return 1;
++}
++
++
++static int auxresume (lua_State *L, lua_State *co, int narg) {
++ int status = costatus(L, co);
++ if (!lua_checkstack(co, narg))
++ luaL_error(L, "too many arguments to resume");
++ if (status != CO_SUS) {
++ lua_pushfstring(L, "cannot resume %s coroutine", statnames[status]);
++ return -1; /* error flag */
++ }
++ lua_xmove(L, co, narg);
++ lua_setlevel(L, co);
++ status = lua_resume(co, narg);
++ if (status == 0 || status == LUA_YIELD) {
++ int nres = lua_gettop(co);
++ if (!lua_checkstack(L, nres + 1))
++ luaL_error(L, "too many results to resume");
++ lua_xmove(co, L, nres); /* move yielded values */
++ return nres;
++ }
++ else {
++ lua_xmove(co, L, 1); /* move error message */
++ return -1; /* error flag */
++ }
++}
++
++
++static int luaB_coresume (lua_State *L) {
++ lua_State *co = lua_tothread(L, 1);
++ int r;
++ luaL_argcheck(L, co, 1, "coroutine expected");
++ r = auxresume(L, co, lua_gettop(L) - 1);
++ if (r < 0) {
++ lua_pushboolean(L, 0);
++ lua_insert(L, -2);
++ return 2; /* return false + error message */
++ }
++ else {
++ lua_pushboolean(L, 1);
++ lua_insert(L, -(r + 1));
++ return r + 1; /* return true + `resume' returns */
++ }
++}
++
++
++static int luaB_auxwrap (lua_State *L) {
++ lua_State *co = lua_tothread(L, lua_upvalueindex(1));
++ int r = auxresume(L, co, lua_gettop(L));
++ if (r < 0) {
++ if (lua_isstring(L, -1)) { /* error object is a string? */
++ luaL_where(L, 1); /* add extra info */
++ lua_insert(L, -2);
++ lua_concat(L, 2);
++ }
++ lua_error(L); /* propagate error */
++ }
++ return r;
++}
++
++
++static int luaB_cocreate (lua_State *L) {
++ lua_State *NL = lua_newthread(L);
++ luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), 1,
++ "Lua function expected");
++ lua_pushvalue(L, 1); /* move function to top */
++ lua_xmove(L, NL, 1); /* move function from L to NL */
++ return 1;
++}
++
++
++static int luaB_cowrap (lua_State *L) {
++ luaB_cocreate(L);
++ lua_pushcclosure(L, luaB_auxwrap, 1);
++ return 1;
++}
++
++
++static int luaB_yield (lua_State *L) {
++ return lua_yield(L, lua_gettop(L));
++}
++
++
++static int luaB_corunning (lua_State *L) {
++ if (lua_pushthread(L))
++ lua_pushnil(L); /* main thread is not a coroutine */
++ return 1;
++}
++
++
++static const luaL_Reg co_funcs[] = {
++ {"create", luaB_cocreate},
++ {"resume", luaB_coresume},
++ {"running", luaB_corunning},
++ {"status", luaB_costatus},
++ {"wrap", luaB_cowrap},
++ {"yield", luaB_yield},
++ {NULL, NULL}
++};
++
++/* }====================================================== */
++
++
++static void auxopen (lua_State *L, const char *name,
++ lua_CFunction f, lua_CFunction u) {
++ lua_pushcfunction(L, u);
++ lua_pushcclosure(L, f, 1);
++ lua_setfield(L, -2, name);
++}
++
++
++static void base_open (lua_State *L) {
++ /* set global _G */
++ lua_pushvalue(L, LUA_GLOBALSINDEX);
++ lua_setglobal(L, "_G");
++ /* open lib into global table */
++ luaL_register(L, "_G", base_funcs);
++ lua_pushliteral(L, LUA_VERSION);
++ lua_setglobal(L, "_VERSION"); /* set global _VERSION */
++ /* `ipairs' and `pairs' need auxliliary functions as upvalues */
++ auxopen(L, "ipairs", luaB_ipairs, ipairsaux);
++ auxopen(L, "pairs", luaB_pairs, luaB_next);
++ /* `newproxy' needs a weaktable as upvalue */
++ lua_createtable(L, 0, 1); /* new table `w' */
++ lua_pushvalue(L, -1); /* `w' will be its own metatable */
++ lua_setmetatable(L, -2);
++ lua_pushliteral(L, "kv");
++ lua_setfield(L, -2, "__mode"); /* metatable(w).__mode = "kv" */
++ lua_pushcclosure(L, luaB_newproxy, 1);
++ lua_setglobal(L, "newproxy"); /* set global `newproxy' */
++}
++
++
++LUALIB_API int luaopen_base (lua_State *L) {
++ base_open(L);
++ luaL_register(L, LUA_COLIBNAME, co_funcs);
++ return 2;
++}
+--- /dev/null
++++ b/extensions/LUA/lua/lcode.c
+@@ -0,0 +1,838 @@
++/*
++** $Id: lcode.c,v 2.25.1.3 2007/12/28 15:32:23 roberto Exp $
++** Code generator for Lua
++** See Copyright Notice in lua.h
++*/
++
++#include <stdlib.h>
++
++#define lcode_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "lcode.h"
++#include "ldebug.h"
++#include "ldo.h"
++#include "lgc.h"
++#include "llex.h"
++#include "lmem.h"
++#include "lobject.h"
++#include "lopcodes.h"
++#include "lparser.h"
++#include "ltable.h"
++
++
++#define hasjumps(e) ((e)->t != (e)->f)
++
++
++static int isnumeral(expdesc *e) {
++ return (e->k == VKNUM && e->t == NO_JUMP && e->f == NO_JUMP);
++}
++
++
++void luaK_nil (FuncState *fs, int from, int n) {
++ Instruction *previous;
++ if (fs->pc > fs->lasttarget) { /* no jumps to current position? */
++ if (fs->pc == 0) { /* function start? */
++ if (from >= fs->nactvar)
++ return; /* positions are already clean */
++ }
++ else {
++ previous = &fs->f->code[fs->pc-1];
++ if (GET_OPCODE(*previous) == OP_LOADNIL) {
++ int pfrom = GETARG_A(*previous);
++ int pto = GETARG_B(*previous);
++ if (pfrom <= from && from <= pto+1) { /* can connect both? */
++ if (from+n-1 > pto)
++ SETARG_B(*previous, from+n-1);
++ return;
++ }
++ }
++ }
++ }
++ luaK_codeABC(fs, OP_LOADNIL, from, from+n-1, 0); /* else no optimization */
++}
++
++
++int luaK_jump (FuncState *fs) {
++ int jpc = fs->jpc; /* save list of jumps to here */
++ int j;
++ fs->jpc = NO_JUMP;
++ j = luaK_codeAsBx(fs, OP_JMP, 0, NO_JUMP);
++ luaK_concat(fs, &j, jpc); /* keep them on hold */
++ return j;
++}
++
++
++void luaK_ret (FuncState *fs, int first, int nret) {
++ luaK_codeABC(fs, OP_RETURN, first, nret+1, 0);
++}
++
++
++static int condjump (FuncState *fs, OpCode op, int A, int B, int C) {
++ luaK_codeABC(fs, op, A, B, C);
++ return luaK_jump(fs);
++}
++
++
++static void fixjump (FuncState *fs, int pc, int dest) {
++ Instruction *jmp = &fs->f->code[pc];
++ int offset = dest-(pc+1);
++ lua_assert(dest != NO_JUMP);
++ if (abs(offset) > MAXARG_sBx)
++ luaX_syntaxerror(fs->ls, "control structure too long");
++ SETARG_sBx(*jmp, offset);
++}
++
++
++/*
++** returns current `pc' and marks it as a jump target (to avoid wrong
++** optimizations with consecutive instructions not in the same basic block).
++*/
++int luaK_getlabel (FuncState *fs) {
++ fs->lasttarget = fs->pc;
++ return fs->pc;
++}
++
++
++static int getjump (FuncState *fs, int pc) {
++ int offset = GETARG_sBx(fs->f->code[pc]);
++ if (offset == NO_JUMP) /* point to itself represents end of list */
++ return NO_JUMP; /* end of list */
++ else
++ return (pc+1)+offset; /* turn offset into absolute position */
++}
++
++
++static Instruction *getjumpcontrol (FuncState *fs, int pc) {
++ Instruction *pi = &fs->f->code[pc];
++ if (pc >= 1 && testTMode(GET_OPCODE(*(pi-1))))
++ return pi-1;
++ else
++ return pi;
++}
++
++
++/*
++** check whether list has any jump that do not produce a value
++** (or produce an inverted value)
++*/
++static int need_value (FuncState *fs, int list) {
++ for (; list != NO_JUMP; list = getjump(fs, list)) {
++ Instruction i = *getjumpcontrol(fs, list);
++ if (GET_OPCODE(i) != OP_TESTSET) return 1;
++ }
++ return 0; /* not found */
++}
++
++
++static int patchtestreg (FuncState *fs, int node, int reg) {
++ Instruction *i = getjumpcontrol(fs, node);
++ if (GET_OPCODE(*i) != OP_TESTSET)
++ return 0; /* cannot patch other instructions */
++ if (reg != NO_REG && reg != GETARG_B(*i))
++ SETARG_A(*i, reg);
++ else /* no register to put value or register already has the value */
++ *i = CREATE_ABC(OP_TEST, GETARG_B(*i), 0, GETARG_C(*i));
++
++ return 1;
++}
++
++
++static void removevalues (FuncState *fs, int list) {
++ for (; list != NO_JUMP; list = getjump(fs, list))
++ patchtestreg(fs, list, NO_REG);
++}
++
++
++static void patchlistaux (FuncState *fs, int list, int vtarget, int reg,
++ int dtarget) {
++ while (list != NO_JUMP) {
++ int next = getjump(fs, list);
++ if (patchtestreg(fs, list, reg))
++ fixjump(fs, list, vtarget);
++ else
++ fixjump(fs, list, dtarget); /* jump to default target */
++ list = next;
++ }
++}
++
++
++static void dischargejpc (FuncState *fs) {
++ patchlistaux(fs, fs->jpc, fs->pc, NO_REG, fs->pc);
++ fs->jpc = NO_JUMP;
++}
++
++
++void luaK_patchlist (FuncState *fs, int list, int target) {
++ if (target == fs->pc)
++ luaK_patchtohere(fs, list);
++ else {
++ lua_assert(target < fs->pc);
++ patchlistaux(fs, list, target, NO_REG, target);
++ }
++}
++
++
++void luaK_patchtohere (FuncState *fs, int list) {
++ luaK_getlabel(fs);
++ luaK_concat(fs, &fs->jpc, list);
++}
++
++
++void luaK_concat (FuncState *fs, int *l1, int l2) {
++ if (l2 == NO_JUMP) return;
++ else if (*l1 == NO_JUMP)
++ *l1 = l2;
++ else {
++ int list = *l1;
++ int next;
++ while ((next = getjump(fs, list)) != NO_JUMP) /* find last element */
++ list = next;
++ fixjump(fs, list, l2);
++ }
++}
++
++
++void luaK_checkstack (FuncState *fs, int n) {
++ int newstack = fs->freereg + n;
++ if (newstack > fs->f->maxstacksize) {
++ if (newstack >= MAXSTACK)
++ luaX_syntaxerror(fs->ls, "function or expression too complex");
++ fs->f->maxstacksize = cast_byte(newstack);
++ }
++}
++
++
++void luaK_reserveregs (FuncState *fs, int n) {
++ luaK_checkstack(fs, n);
++ fs->freereg += n;
++}
++
++
++static void freereg (FuncState *fs, int reg) {
++ if (!ISK(reg) && reg >= fs->nactvar) {
++ fs->freereg--;
++ lua_assert(reg == fs->freereg);
++ }
++}
++
++
++static void freeexp (FuncState *fs, expdesc *e) {
++ if (e->k == VNONRELOC)
++ freereg(fs, e->u.s.info);
++}
++
++
++static int addk (FuncState *fs, TValue *k, TValue *v) {
++ lua_State *L = fs->L;
++ TValue *idx = luaH_set(L, fs->h, k);
++ Proto *f = fs->f;
++ int oldsize = f->sizek;
++ if (ttisnumber(idx)) {
++ lua_assert(luaO_rawequalObj(&fs->f->k[cast_int(nvalue(idx))], v));
++ return cast_int(nvalue(idx));
++ }
++ else { /* constant not found; create a new entry */
++ setnvalue(idx, cast_num(fs->nk));
++ luaM_growvector(L, f->k, fs->nk, f->sizek, TValue,
++ MAXARG_Bx, "constant table overflow");
++ while (oldsize < f->sizek) setnilvalue(&f->k[oldsize++]);
++ setobj(L, &f->k[fs->nk], v);
++ luaC_barrier(L, f, v);
++ return fs->nk++;
++ }
++}
++
++
++int luaK_stringK (FuncState *fs, TString *s) {
++ TValue o;
++ setsvalue(fs->L, &o, s);
++ return addk(fs, &o, &o);
++}
++
++
++int luaK_numberK (FuncState *fs, lua_Number r) {
++ TValue o;
++ setnvalue(&o, r);
++ return addk(fs, &o, &o);
++}
++
++
++static int boolK (FuncState *fs, int b) {
++ TValue o;
++ setbvalue(&o, b);
++ return addk(fs, &o, &o);
++}
++
++
++static int nilK (FuncState *fs) {
++ TValue k, v;
++ setnilvalue(&v);
++ /* cannot use nil as key; instead use table itself to represent nil */
++ sethvalue(fs->L, &k, fs->h);
++ return addk(fs, &k, &v);
++}
++
++
++void luaK_setreturns (FuncState *fs, expdesc *e, int nresults) {
++ if (e->k == VCALL) { /* expression is an open function call? */
++ SETARG_C(getcode(fs, e), nresults+1);
++ }
++ else if (e->k == VVARARG) {
++ SETARG_B(getcode(fs, e), nresults+1);
++ SETARG_A(getcode(fs, e), fs->freereg);
++ luaK_reserveregs(fs, 1);
++ }
++}
++
++
++void luaK_setoneret (FuncState *fs, expdesc *e) {
++ if (e->k == VCALL) { /* expression is an open function call? */
++ e->k = VNONRELOC;
++ e->u.s.info = GETARG_A(getcode(fs, e));
++ }
++ else if (e->k == VVARARG) {
++ SETARG_B(getcode(fs, e), 2);
++ e->k = VRELOCABLE; /* can relocate its simple result */
++ }
++}
++
++
++void luaK_dischargevars (FuncState *fs, expdesc *e) {
++ switch (e->k) {
++ case VLOCAL: {
++ e->k = VNONRELOC;
++ break;
++ }
++ case VUPVAL: {
++ e->u.s.info = luaK_codeABC(fs, OP_GETUPVAL, 0, e->u.s.info, 0);
++ e->k = VRELOCABLE;
++ break;
++ }
++ case VGLOBAL: {
++ e->u.s.info = luaK_codeABx(fs, OP_GETGLOBAL, 0, e->u.s.info);
++ e->k = VRELOCABLE;
++ break;
++ }
++ case VINDEXED: {
++ freereg(fs, e->u.s.aux);
++ freereg(fs, e->u.s.info);
++ e->u.s.info = luaK_codeABC(fs, OP_GETTABLE, 0, e->u.s.info, e->u.s.aux);
++ e->k = VRELOCABLE;
++ break;
++ }
++ case VVARARG:
++ case VCALL: {
++ luaK_setoneret(fs, e);
++ break;
++ }
++ default: break; /* there is one value available (somewhere) */
++ }
++}
++
++
++static int code_label (FuncState *fs, int A, int b, int jump) {
++ luaK_getlabel(fs); /* those instructions may be jump targets */
++ return luaK_codeABC(fs, OP_LOADBOOL, A, b, jump);
++}
++
++
++static void discharge2reg (FuncState *fs, expdesc *e, int reg) {
++ luaK_dischargevars(fs, e);
++ switch (e->k) {
++ case VNIL: {
++ luaK_nil(fs, reg, 1);
++ break;
++ }
++ case VFALSE: case VTRUE: {
++ luaK_codeABC(fs, OP_LOADBOOL, reg, e->k == VTRUE, 0);
++ break;
++ }
++ case VK: {
++ luaK_codeABx(fs, OP_LOADK, reg, e->u.s.info);
++ break;
++ }
++ case VKNUM: {
++ luaK_codeABx(fs, OP_LOADK, reg, luaK_numberK(fs, e->u.nval));
++ break;
++ }
++ case VRELOCABLE: {
++ Instruction *pc = &getcode(fs, e);
++ SETARG_A(*pc, reg);
++ break;
++ }
++ case VNONRELOC: {
++ if (reg != e->u.s.info)
++ luaK_codeABC(fs, OP_MOVE, reg, e->u.s.info, 0);
++ break;
++ }
++ default: {
++ lua_assert(e->k == VVOID || e->k == VJMP);
++ return; /* nothing to do... */
++ }
++ }
++ e->u.s.info = reg;
++ e->k = VNONRELOC;
++}
++
++
++static void discharge2anyreg (FuncState *fs, expdesc *e) {
++ if (e->k != VNONRELOC) {
++ luaK_reserveregs(fs, 1);
++ discharge2reg(fs, e, fs->freereg-1);
++ }
++}
++
++
++static void exp2reg (FuncState *fs, expdesc *e, int reg) {
++ discharge2reg(fs, e, reg);
++ if (e->k == VJMP)
++ luaK_concat(fs, &e->t, e->u.s.info); /* put this jump in `t' list */
++ if (hasjumps(e)) {
++ int final; /* position after whole expression */
++ int p_f = NO_JUMP; /* position of an eventual LOAD false */
++ int p_t = NO_JUMP; /* position of an eventual LOAD true */
++ if (need_value(fs, e->t) || need_value(fs, e->f)) {
++ int fj = (e->k == VJMP) ? NO_JUMP : luaK_jump(fs);
++ p_f = code_label(fs, reg, 0, 1);
++ p_t = code_label(fs, reg, 1, 0);
++ luaK_patchtohere(fs, fj);
++ }
++ final = luaK_getlabel(fs);
++ patchlistaux(fs, e->f, final, reg, p_f);
++ patchlistaux(fs, e->t, final, reg, p_t);
++ }
++ e->f = e->t = NO_JUMP;
++ e->u.s.info = reg;
++ e->k = VNONRELOC;
++}
++
++
++void luaK_exp2nextreg (FuncState *fs, expdesc *e) {
++ luaK_dischargevars(fs, e);
++ freeexp(fs, e);
++ luaK_reserveregs(fs, 1);
++ exp2reg(fs, e, fs->freereg - 1);
++}
++
++
++int luaK_exp2anyreg (FuncState *fs, expdesc *e) {
++ luaK_dischargevars(fs, e);
++ if (e->k == VNONRELOC) {
++ if (!hasjumps(e)) return e->u.s.info; /* exp is already in a register */
++ if (e->u.s.info >= fs->nactvar) { /* reg. is not a local? */
++ exp2reg(fs, e, e->u.s.info); /* put value on it */
++ return e->u.s.info;
++ }
++ }
++ luaK_exp2nextreg(fs, e); /* default */
++ return e->u.s.info;
++}
++
++
++void luaK_exp2val (FuncState *fs, expdesc *e) {
++ if (hasjumps(e))
++ luaK_exp2anyreg(fs, e);
++ else
++ luaK_dischargevars(fs, e);
++}
++
++
++int luaK_exp2RK (FuncState *fs, expdesc *e) {
++ luaK_exp2val(fs, e);
++ switch (e->k) {
++ case VKNUM:
++ case VTRUE:
++ case VFALSE:
++ case VNIL: {
++ if (fs->nk <= MAXINDEXRK) { /* constant fit in RK operand? */
++ e->u.s.info = (e->k == VNIL) ? nilK(fs) :
++ (e->k == VKNUM) ? luaK_numberK(fs, e->u.nval) :
++ boolK(fs, (e->k == VTRUE));
++ e->k = VK;
++ return RKASK(e->u.s.info);
++ }
++ else break;
++ }
++ case VK: {
++ if (e->u.s.info <= MAXINDEXRK) /* constant fit in argC? */
++ return RKASK(e->u.s.info);
++ else break;
++ }
++ default: break;
++ }
++ /* not a constant in the right range: put it in a register */
++ return luaK_exp2anyreg(fs, e);
++}
++
++
++void luaK_storevar (FuncState *fs, expdesc *var, expdesc *ex) {
++ switch (var->k) {
++ case VLOCAL: {
++ freeexp(fs, ex);
++ exp2reg(fs, ex, var->u.s.info);
++ return;
++ }
++ case VUPVAL: {
++ int e = luaK_exp2anyreg(fs, ex);
++ luaK_codeABC(fs, OP_SETUPVAL, e, var->u.s.info, 0);
++ break;
++ }
++ case VGLOBAL: {
++ int e = luaK_exp2anyreg(fs, ex);
++ luaK_codeABx(fs, OP_SETGLOBAL, e, var->u.s.info);
++ break;
++ }
++ case VINDEXED: {
++ int e = luaK_exp2RK(fs, ex);
++ luaK_codeABC(fs, OP_SETTABLE, var->u.s.info, var->u.s.aux, e);
++ break;
++ }
++ default: {
++ lua_assert(0); /* invalid var kind to store */
++ break;
++ }
++ }
++ freeexp(fs, ex);
++}
++
++
++void luaK_self (FuncState *fs, expdesc *e, expdesc *key) {
++ int func;
++ luaK_exp2anyreg(fs, e);
++ freeexp(fs, e);
++ func = fs->freereg;
++ luaK_reserveregs(fs, 2);
++ luaK_codeABC(fs, OP_SELF, func, e->u.s.info, luaK_exp2RK(fs, key));
++ freeexp(fs, key);
++ e->u.s.info = func;
++ e->k = VNONRELOC;
++}
++
++
++static void invertjump (FuncState *fs, expdesc *e) {
++ Instruction *pc = getjumpcontrol(fs, e->u.s.info);
++ lua_assert(testTMode(GET_OPCODE(*pc)) && GET_OPCODE(*pc) != OP_TESTSET &&
++ GET_OPCODE(*pc) != OP_TEST);
++ SETARG_A(*pc, !(GETARG_A(*pc)));
++}
++
++
++static int jumponcond (FuncState *fs, expdesc *e, int cond) {
++ if (e->k == VRELOCABLE) {
++ Instruction ie = getcode(fs, e);
++ if (GET_OPCODE(ie) == OP_NOT) {
++ fs->pc--; /* remove previous OP_NOT */
++ return condjump(fs, OP_TEST, GETARG_B(ie), 0, !cond);
++ }
++ /* else go through */
++ }
++ discharge2anyreg(fs, e);
++ freeexp(fs, e);
++ return condjump(fs, OP_TESTSET, NO_REG, e->u.s.info, cond);
++}
++
++
++void luaK_goiftrue (FuncState *fs, expdesc *e) {
++ int pc; /* pc of last jump */
++ luaK_dischargevars(fs, e);
++ switch (e->k) {
++ case VK: case VKNUM: case VTRUE: {
++ pc = NO_JUMP; /* always true; do nothing */
++ break;
++ }
++ case VFALSE: {
++ pc = luaK_jump(fs); /* always jump */
++ break;
++ }
++ case VJMP: {
++ invertjump(fs, e);
++ pc = e->u.s.info;
++ break;
++ }
++ default: {
++ pc = jumponcond(fs, e, 0);
++ break;
++ }
++ }
++ luaK_concat(fs, &e->f, pc); /* insert last jump in `f' list */
++ luaK_patchtohere(fs, e->t);
++ e->t = NO_JUMP;
++}
++
++
++static void luaK_goiffalse (FuncState *fs, expdesc *e) {
++ int pc; /* pc of last jump */
++ luaK_dischargevars(fs, e);
++ switch (e->k) {
++ case VNIL: case VFALSE: {
++ pc = NO_JUMP; /* always false; do nothing */
++ break;
++ }
++ case VTRUE: {
++ pc = luaK_jump(fs); /* always jump */
++ break;
++ }
++ case VJMP: {
++ pc = e->u.s.info;
++ break;
++ }
++ default: {
++ pc = jumponcond(fs, e, 1);
++ break;
++ }
++ }
++ luaK_concat(fs, &e->t, pc); /* insert last jump in `t' list */
++ luaK_patchtohere(fs, e->f);
++ e->f = NO_JUMP;
++}
++
++
++static void codenot (FuncState *fs, expdesc *e) {
++ luaK_dischargevars(fs, e);
++ switch (e->k) {
++ case VNIL: case VFALSE: {
++ e->k = VTRUE;
++ break;
++ }
++ case VK: case VKNUM: case VTRUE: {
++ e->k = VFALSE;
++ break;
++ }
++ case VJMP: {
++ invertjump(fs, e);
++ break;
++ }
++ case VRELOCABLE:
++ case VNONRELOC: {
++ discharge2anyreg(fs, e);
++ freeexp(fs, e);
++ e->u.s.info = luaK_codeABC(fs, OP_NOT, 0, e->u.s.info, 0);
++ e->k = VRELOCABLE;
++ break;
++ }
++ default: {
++ lua_assert(0); /* cannot happen */
++ break;
++ }
++ }
++ /* interchange true and false lists */
++ { int temp = e->f; e->f = e->t; e->t = temp; }
++ removevalues(fs, e->f);
++ removevalues(fs, e->t);
++}
++
++
++void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) {
++ t->u.s.aux = luaK_exp2RK(fs, k);
++ t->k = VINDEXED;
++}
++
++
++static int constfolding (OpCode op, expdesc *e1, expdesc *e2) {
++ lua_Number v1, v2, r;
++ if (!isnumeral(e1) || !isnumeral(e2)) return 0;
++ v1 = e1->u.nval;
++ v2 = e2->u.nval;
++ switch (op) {
++ case OP_ADD: r = luai_numadd(v1, v2); break;
++ case OP_SUB: r = luai_numsub(v1, v2); break;
++ case OP_MUL: r = luai_nummul(v1, v2); break;
++ case OP_DIV:
++ if (v2 == 0) return 0; /* do not attempt to divide by 0 */
++ r = luai_numdiv(v1, v2); break;
++ case OP_MOD:
++ if (v2 == 0) return 0; /* do not attempt to divide by 0 */
++ r = luai_nummod(v1, v2); break;
++ case OP_POW: r = luai_numpow(v1, v2); break;
++ case OP_UNM: r = luai_numunm(v1); break;
++ case OP_LEN: return 0; /* no constant folding for 'len' */
++ default: lua_assert(0); r = 0; break;
++ }
++ if (luai_numisnan(r)) return 0; /* do not attempt to produce NaN */
++ e1->u.nval = r;
++ return 1;
++}
++
++
++static void codearith (FuncState *fs, OpCode op, expdesc *e1, expdesc *e2) {
++ if (constfolding(op, e1, e2))
++ return;
++ else {
++ int o2 = (op != OP_UNM && op != OP_LEN) ? luaK_exp2RK(fs, e2) : 0;
++ int o1 = luaK_exp2RK(fs, e1);
++ if (o1 > o2) {
++ freeexp(fs, e1);
++ freeexp(fs, e2);
++ }
++ else {
++ freeexp(fs, e2);
++ freeexp(fs, e1);
++ }
++ e1->u.s.info = luaK_codeABC(fs, op, 0, o1, o2);
++ e1->k = VRELOCABLE;
++ }
++}
++
++
++static void codecomp (FuncState *fs, OpCode op, int cond, expdesc *e1,
++ expdesc *e2) {
++ int o1 = luaK_exp2RK(fs, e1);
++ int o2 = luaK_exp2RK(fs, e2);
++ freeexp(fs, e2);
++ freeexp(fs, e1);
++ if (cond == 0 && op != OP_EQ) {
++ int temp; /* exchange args to replace by `<' or `<=' */
++ temp = o1; o1 = o2; o2 = temp; /* o1 <==> o2 */
++ cond = 1;
++ }
++ e1->u.s.info = condjump(fs, op, cond, o1, o2);
++ e1->k = VJMP;
++}
++
++
++void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e) {
++ expdesc e2;
++ e2.t = e2.f = NO_JUMP; e2.k = VKNUM; e2.u.nval = 0;
++ switch (op) {
++ case OPR_MINUS: {
++ if (!isnumeral(e))
++ luaK_exp2anyreg(fs, e); /* cannot operate on non-numeric constants */
++ codearith(fs, OP_UNM, e, &e2);
++ break;
++ }
++ case OPR_NOT: codenot(fs, e); break;
++ case OPR_LEN: {
++ luaK_exp2anyreg(fs, e); /* cannot operate on constants */
++ codearith(fs, OP_LEN, e, &e2);
++ break;
++ }
++ default: lua_assert(0);
++ }
++}
++
++
++void luaK_infix (FuncState *fs, BinOpr op, expdesc *v) {
++ switch (op) {
++ case OPR_AND: {
++ luaK_goiftrue(fs, v);
++ break;
++ }
++ case OPR_OR: {
++ luaK_goiffalse(fs, v);
++ break;
++ }
++ case OPR_CONCAT: {
++ luaK_exp2nextreg(fs, v); /* operand must be on the `stack' */
++ break;
++ }
++ case OPR_ADD: case OPR_SUB: case OPR_MUL: case OPR_DIV:
++ case OPR_MOD: case OPR_POW: {
++ if (!isnumeral(v)) luaK_exp2RK(fs, v);
++ break;
++ }
++ default: {
++ luaK_exp2RK(fs, v);
++ break;
++ }
++ }
++}
++
++
++void luaK_posfix (FuncState *fs, BinOpr op, expdesc *e1, expdesc *e2) {
++ switch (op) {
++ case OPR_AND: {
++ lua_assert(e1->t == NO_JUMP); /* list must be closed */
++ luaK_dischargevars(fs, e2);
++ luaK_concat(fs, &e2->f, e1->f);
++ *e1 = *e2;
++ break;
++ }
++ case OPR_OR: {
++ lua_assert(e1->f == NO_JUMP); /* list must be closed */
++ luaK_dischargevars(fs, e2);
++ luaK_concat(fs, &e2->t, e1->t);
++ *e1 = *e2;
++ break;
++ }
++ case OPR_CONCAT: {
++ luaK_exp2val(fs, e2);
++ if (e2->k == VRELOCABLE && GET_OPCODE(getcode(fs, e2)) == OP_CONCAT) {
++ lua_assert(e1->u.s.info == GETARG_B(getcode(fs, e2))-1);
++ freeexp(fs, e1);
++ SETARG_B(getcode(fs, e2), e1->u.s.info);
++ e1->k = VRELOCABLE; e1->u.s.info = e2->u.s.info;
++ }
++ else {
++ luaK_exp2nextreg(fs, e2); /* operand must be on the 'stack' */
++ codearith(fs, OP_CONCAT, e1, e2);
++ }
++ break;
++ }
++ case OPR_ADD: codearith(fs, OP_ADD, e1, e2); break;
++ case OPR_SUB: codearith(fs, OP_SUB, e1, e2); break;
++ case OPR_MUL: codearith(fs, OP_MUL, e1, e2); break;
++ case OPR_DIV: codearith(fs, OP_DIV, e1, e2); break;
++ case OPR_MOD: codearith(fs, OP_MOD, e1, e2); break;
++ case OPR_POW: codearith(fs, OP_POW, e1, e2); break;
++ case OPR_EQ: codecomp(fs, OP_EQ, 1, e1, e2); break;
++ case OPR_NE: codecomp(fs, OP_EQ, 0, e1, e2); break;
++ case OPR_LT: codecomp(fs, OP_LT, 1, e1, e2); break;
++ case OPR_LE: codecomp(fs, OP_LE, 1, e1, e2); break;
++ case OPR_GT: codecomp(fs, OP_LT, 0, e1, e2); break;
++ case OPR_GE: codecomp(fs, OP_LE, 0, e1, e2); break;
++ default: lua_assert(0);
++ }
++}
++
++
++void luaK_fixline (FuncState *fs, int line) {
++ fs->f->lineinfo[fs->pc - 1] = line;
++}
++
++
++static int luaK_code (FuncState *fs, Instruction i, int line) {
++ Proto *f = fs->f;
++ dischargejpc(fs); /* `pc' will change */
++ /* put new instruction in code array */
++ luaM_growvector(fs->L, f->code, fs->pc, f->sizecode, Instruction,
++ MAX_INT, "code size overflow");
++ f->code[fs->pc] = i;
++ /* save corresponding line information */
++ luaM_growvector(fs->L, f->lineinfo, fs->pc, f->sizelineinfo, int,
++ MAX_INT, "code size overflow");
++ f->lineinfo[fs->pc] = line;
++ return fs->pc++;
++}
++
++
++int luaK_codeABC (FuncState *fs, OpCode o, int a, int b, int c) {
++ lua_assert(getOpMode(o) == iABC);
++ lua_assert(getBMode(o) != OpArgN || b == 0);
++ lua_assert(getCMode(o) != OpArgN || c == 0);
++ return luaK_code(fs, CREATE_ABC(o, a, b, c), fs->ls->lastline);
++}
++
++
++int luaK_codeABx (FuncState *fs, OpCode o, int a, unsigned int bc) {
++ lua_assert(getOpMode(o) == iABx || getOpMode(o) == iAsBx);
++ lua_assert(getCMode(o) == OpArgN);
++ return luaK_code(fs, CREATE_ABx(o, a, bc), fs->ls->lastline);
++}
++
++
++void luaK_setlist (FuncState *fs, int base, int nelems, int tostore) {
++ int c = (nelems - 1)/LFIELDS_PER_FLUSH + 1;
++ int b = (tostore == LUA_MULTRET) ? 0 : tostore;
++ lua_assert(tostore != 0);
++ if (c <= MAXARG_C)
++ luaK_codeABC(fs, OP_SETLIST, base, b, c);
++ else {
++ luaK_codeABC(fs, OP_SETLIST, base, b, 0);
++ luaK_code(fs, cast(Instruction, c), fs->ls->lastline);
++ }
++ fs->freereg = base + 1; /* free registers with list values */
++}
++
+--- /dev/null
++++ b/extensions/LUA/lua/lcode.h
+@@ -0,0 +1,76 @@
++/*
++** $Id: lcode.h,v 1.48.1.1 2007/12/27 13:02:25 roberto Exp $
++** Code generator for Lua
++** See Copyright Notice in lua.h
++*/
++
++#ifndef lcode_h
++#define lcode_h
++
++#include "llex.h"
++#include "lobject.h"
++#include "lopcodes.h"
++#include "lparser.h"
++
++
++/*
++** Marks the end of a patch list. It is an invalid value both as an absolute
++** address, and as a list link (would link an element to itself).
++*/
++#define NO_JUMP (-1)
++
++
++/*
++** grep "ORDER OPR" if you change these enums
++*/
++typedef enum BinOpr {
++ OPR_ADD, OPR_SUB, OPR_MUL, OPR_DIV, OPR_MOD, OPR_POW,
++ OPR_CONCAT,
++ OPR_NE, OPR_EQ,
++ OPR_LT, OPR_LE, OPR_GT, OPR_GE,
++ OPR_AND, OPR_OR,
++ OPR_NOBINOPR
++} BinOpr;
++
++
++typedef enum UnOpr { OPR_MINUS, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr;
++
++
++#define getcode(fs,e) ((fs)->f->code[(e)->u.s.info])
++
++#define luaK_codeAsBx(fs,o,A,sBx) luaK_codeABx(fs,o,A,(sBx)+MAXARG_sBx)
++
++#define luaK_setmultret(fs,e) luaK_setreturns(fs, e, LUA_MULTRET)
++
++LUAI_FUNC int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bx);
++LUAI_FUNC int luaK_codeABC (FuncState *fs, OpCode o, int A, int B, int C);
++LUAI_FUNC void luaK_fixline (FuncState *fs, int line);
++LUAI_FUNC void luaK_nil (FuncState *fs, int from, int n);
++LUAI_FUNC void luaK_reserveregs (FuncState *fs, int n);
++LUAI_FUNC void luaK_checkstack (FuncState *fs, int n);
++LUAI_FUNC int luaK_stringK (FuncState *fs, TString *s);
++LUAI_FUNC int luaK_numberK (FuncState *fs, lua_Number r);
++LUAI_FUNC void luaK_dischargevars (FuncState *fs, expdesc *e);
++LUAI_FUNC int luaK_exp2anyreg (FuncState *fs, expdesc *e);
++LUAI_FUNC void luaK_exp2nextreg (FuncState *fs, expdesc *e);
++LUAI_FUNC void luaK_exp2val (FuncState *fs, expdesc *e);
++LUAI_FUNC int luaK_exp2RK (FuncState *fs, expdesc *e);
++LUAI_FUNC void luaK_self (FuncState *fs, expdesc *e, expdesc *key);
++LUAI_FUNC void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k);
++LUAI_FUNC void luaK_goiftrue (FuncState *fs, expdesc *e);
++LUAI_FUNC void luaK_storevar (FuncState *fs, expdesc *var, expdesc *e);
++LUAI_FUNC void luaK_setreturns (FuncState *fs, expdesc *e, int nresults);
++LUAI_FUNC void luaK_setoneret (FuncState *fs, expdesc *e);
++LUAI_FUNC int luaK_jump (FuncState *fs);
++LUAI_FUNC void luaK_ret (FuncState *fs, int first, int nret);
++LUAI_FUNC void luaK_patchlist (FuncState *fs, int list, int target);
++LUAI_FUNC void luaK_patchtohere (FuncState *fs, int list);
++LUAI_FUNC void luaK_concat (FuncState *fs, int *l1, int l2);
++LUAI_FUNC int luaK_getlabel (FuncState *fs);
++LUAI_FUNC void luaK_prefix (FuncState *fs, UnOpr op, expdesc *v);
++LUAI_FUNC void luaK_infix (FuncState *fs, BinOpr op, expdesc *v);
++LUAI_FUNC void luaK_posfix (FuncState *fs, BinOpr op, expdesc *v1, expdesc *v2);
++LUAI_FUNC void luaK_setlist (FuncState *fs, int base, int nelems, int tostore);
++
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/ldebug.c
+@@ -0,0 +1,637 @@
++/*
++** $Id: ldebug.c,v 2.29.1.6 2008/05/08 16:56:26 roberto Exp $
++** Debug Interface
++** See Copyright Notice in lua.h
++*/
++
++
++#include <stdarg.h>
++#include <stddef.h>
++#include <string.h>
++
++#define ldebug_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "lapi.h"
++#include "lcode.h"
++#include "ldebug.h"
++#include "ldo.h"
++#include "lfunc.h"
++#include "lobject.h"
++#include "lopcodes.h"
++#include "lstate.h"
++#include "lstring.h"
++#include "ltable.h"
++#include "ltm.h"
++#include "lvm.h"
++
++
++
++static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name);
++
++
++static int currentpc (lua_State *L, CallInfo *ci) {
++ if (!isLua(ci)) return -1; /* function is not a Lua function? */
++ if (ci == L->ci)
++ ci->savedpc = L->savedpc;
++ return pcRel(ci->savedpc, ci_func(ci)->l.p);
++}
++
++
++static int currentline (lua_State *L, CallInfo *ci) {
++ int pc = currentpc(L, ci);
++ if (pc < 0)
++ return -1; /* only active lua functions have current-line information */
++ else
++ return getline(ci_func(ci)->l.p, pc);
++}
++
++
++/*
++** this function can be called asynchronous (e.g. during a signal)
++*/
++LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count) {
++ if (func == NULL || mask == 0) { /* turn off hooks? */
++ mask = 0;
++ func = NULL;
++ }
++ L->hook = func;
++ L->basehookcount = count;
++ resethookcount(L);
++ L->hookmask = cast_byte(mask);
++ return 1;
++}
++
++
++LUA_API lua_Hook lua_gethook (lua_State *L) {
++ return L->hook;
++}
++
++
++LUA_API int lua_gethookmask (lua_State *L) {
++ return L->hookmask;
++}
++
++
++LUA_API int lua_gethookcount (lua_State *L) {
++ return L->basehookcount;
++}
++
++
++LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar) {
++ int status;
++ CallInfo *ci;
++ lua_lock(L);
++ for (ci = L->ci; level > 0 && ci > L->base_ci; ci--) {
++ level--;
++ if (f_isLua(ci)) /* Lua function? */
++ level -= ci->tailcalls; /* skip lost tail calls */
++ }
++ if (level == 0 && ci > L->base_ci) { /* level found? */
++ status = 1;
++ ar->i_ci = cast_int(ci - L->base_ci);
++ }
++ else if (level < 0) { /* level is of a lost tail call? */
++ status = 1;
++ ar->i_ci = 0;
++ }
++ else status = 0; /* no such level */
++ lua_unlock(L);
++ return status;
++}
++
++
++static Proto *getluaproto (CallInfo *ci) {
++ return (isLua(ci) ? ci_func(ci)->l.p : NULL);
++}
++
++
++static const char *findlocal (lua_State *L, CallInfo *ci, int n) {
++ const char *name;
++ Proto *fp = getluaproto(ci);
++ if (fp && (name = luaF_getlocalname(fp, n, currentpc(L, ci))) != NULL)
++ return name; /* is a local variable in a Lua function */
++ else {
++ StkId limit = (ci == L->ci) ? L->top : (ci+1)->func;
++ if (limit - ci->base >= n && n > 0) /* is 'n' inside 'ci' stack? */
++ return "(*temporary)";
++ else
++ return NULL;
++ }
++}
++
++
++LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) {
++ CallInfo *ci = L->base_ci + ar->i_ci;
++ const char *name = findlocal(L, ci, n);
++ lua_lock(L);
++ if (name)
++ luaA_pushobject(L, ci->base + (n - 1));
++ lua_unlock(L);
++ return name;
++}
++
++
++LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) {
++ CallInfo *ci = L->base_ci + ar->i_ci;
++ const char *name = findlocal(L, ci, n);
++ lua_lock(L);
++ if (name)
++ setobjs2s(L, ci->base + (n - 1), L->top - 1);
++ L->top--; /* pop value */
++ lua_unlock(L);
++ return name;
++}
++
++
++static void funcinfo (lua_Debug *ar, Closure *cl) {
++ if (cl->c.isC) {
++ ar->source = "=[C]";
++ ar->linedefined = -1;
++ ar->lastlinedefined = -1;
++ ar->what = "C";
++ }
++ else {
++ ar->source = getstr(cl->l.p->source);
++ ar->linedefined = cl->l.p->linedefined;
++ ar->lastlinedefined = cl->l.p->lastlinedefined;
++ ar->what = (ar->linedefined == 0) ? "main" : "Lua";
++ }
++ luaO_chunkid(ar->short_src, ar->source, LUA_IDSIZE);
++}
++
++
++static void info_tailcall (lua_Debug *ar) {
++ ar->name = ar->namewhat = "";
++ ar->what = "tail";
++ ar->lastlinedefined = ar->linedefined = ar->currentline = -1;
++ ar->source = "=(tail call)";
++ luaO_chunkid(ar->short_src, ar->source, LUA_IDSIZE);
++ ar->nups = 0;
++}
++
++
++static void collectvalidlines (lua_State *L, Closure *f) {
++ if (f == NULL || f->c.isC) {
++ setnilvalue(L->top);
++ }
++ else {
++ Table *t = luaH_new(L, 0, 0);
++ int *lineinfo = f->l.p->lineinfo;
++ int i;
++ for (i=0; i<f->l.p->sizelineinfo; i++)
++ setbvalue(luaH_setnum(L, t, lineinfo[i]), 1);
++ sethvalue(L, L->top, t);
++ }
++ incr_top(L);
++}
++
++
++static int auxgetinfo (lua_State *L, const char *what, lua_Debug *ar,
++ Closure *f, CallInfo *ci) {
++ int status = 1;
++ if (f == NULL) {
++ info_tailcall(ar);
++ return status;
++ }
++ for (; *what; what++) {
++ switch (*what) {
++ case 'S': {
++ funcinfo(ar, f);
++ break;
++ }
++ case 'l': {
++ ar->currentline = (ci) ? currentline(L, ci) : -1;
++ break;
++ }
++ case 'u': {
++ ar->nups = f->c.nupvalues;
++ break;
++ }
++ case 'n': {
++ ar->namewhat = (ci) ? getfuncname(L, ci, &ar->name) : NULL;
++ if (ar->namewhat == NULL) {
++ ar->namewhat = ""; /* not found */
++ ar->name = NULL;
++ }
++ break;
++ }
++ case 'L':
++ case 'f': /* handled by lua_getinfo */
++ break;
++ default: status = 0; /* invalid option */
++ }
++ }
++ return status;
++}
++
++
++LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) {
++ int status;
++ Closure *f = NULL;
++ CallInfo *ci = NULL;
++ lua_lock(L);
++ if (*what == '>') {
++ StkId func = L->top - 1;
++ luai_apicheck(L, ttisfunction(func));
++ what++; /* skip the '>' */
++ f = clvalue(func);
++ L->top--; /* pop function */
++ }
++ else if (ar->i_ci != 0) { /* no tail call? */
++ ci = L->base_ci + ar->i_ci;
++ lua_assert(ttisfunction(ci->func));
++ f = clvalue(ci->func);
++ }
++ status = auxgetinfo(L, what, ar, f, ci);
++ if (strchr(what, 'f')) {
++ if (f == NULL) setnilvalue(L->top);
++ else setclvalue(L, L->top, f);
++ incr_top(L);
++ }
++ if (strchr(what, 'L'))
++ collectvalidlines(L, f);
++ lua_unlock(L);
++ return status;
++}
++
++
++/*
++** {======================================================
++** Symbolic Execution and code checker
++** =======================================================
++*/
++
++#define check(x) if (!(x)) return 0;
++
++#define checkjump(pt,pc) check(0 <= pc && pc < pt->sizecode)
++
++#define checkreg(pt,reg) check((reg) < (pt)->maxstacksize)
++
++
++
++static int precheck (const Proto *pt) {
++ check(pt->maxstacksize <= MAXSTACK);
++ check(pt->numparams+(pt->is_vararg & VARARG_HASARG) <= pt->maxstacksize);
++ check(!(pt->is_vararg & VARARG_NEEDSARG) ||
++ (pt->is_vararg & VARARG_HASARG));
++ check(pt->sizeupvalues <= pt->nups);
++ check(pt->sizelineinfo == pt->sizecode || pt->sizelineinfo == 0);
++ check(pt->sizecode > 0 && GET_OPCODE(pt->code[pt->sizecode-1]) == OP_RETURN);
++ return 1;
++}
++
++
++#define checkopenop(pt,pc) luaG_checkopenop((pt)->code[(pc)+1])
++
++int luaG_checkopenop (Instruction i) {
++ switch (GET_OPCODE(i)) {
++ case OP_CALL:
++ case OP_TAILCALL:
++ case OP_RETURN:
++ case OP_SETLIST: {
++ check(GETARG_B(i) == 0);
++ return 1;
++ }
++ default: return 0; /* invalid instruction after an open call */
++ }
++}
++
++
++static int checkArgMode (const Proto *pt, int r, enum OpArgMask mode) {
++ switch (mode) {
++ case OpArgN: check(r == 0); break;
++ case OpArgU: break;
++ case OpArgR: checkreg(pt, r); break;
++ case OpArgK:
++ check(ISK(r) ? INDEXK(r) < pt->sizek : r < pt->maxstacksize);
++ break;
++ }
++ return 1;
++}
++
++
++static Instruction symbexec (const Proto *pt, int lastpc, int reg) {
++ int pc;
++ int last; /* stores position of last instruction that changed `reg' */
++ last = pt->sizecode-1; /* points to final return (a `neutral' instruction) */
++ check(precheck(pt));
++ for (pc = 0; pc < lastpc; pc++) {
++ Instruction i = pt->code[pc];
++ OpCode op = GET_OPCODE(i);
++ int a = GETARG_A(i);
++ int b = 0;
++ int c = 0;
++ check(op < NUM_OPCODES);
++ checkreg(pt, a);
++ switch (getOpMode(op)) {
++ case iABC: {
++ b = GETARG_B(i);
++ c = GETARG_C(i);
++ check(checkArgMode(pt, b, getBMode(op)));
++ check(checkArgMode(pt, c, getCMode(op)));
++ break;
++ }
++ case iABx: {
++ b = GETARG_Bx(i);
++ if (getBMode(op) == OpArgK) check(b < pt->sizek);
++ break;
++ }
++ case iAsBx: {
++ b = GETARG_sBx(i);
++ if (getBMode(op) == OpArgR) {
++ int dest = pc+1+b;
++ check(0 <= dest && dest < pt->sizecode);
++ if (dest > 0) {
++ int j;
++ /* check that it does not jump to a setlist count; this
++ is tricky, because the count from a previous setlist may
++ have the same value of an invalid setlist; so, we must
++ go all the way back to the first of them (if any) */
++ for (j = 0; j < dest; j++) {
++ Instruction d = pt->code[dest-1-j];
++ if (!(GET_OPCODE(d) == OP_SETLIST && GETARG_C(d) == 0)) break;
++ }
++ /* if 'j' is even, previous value is not a setlist (even if
++ it looks like one) */
++ check((j&1) == 0);
++ }
++ }
++ break;
++ }
++ }
++ if (testAMode(op)) {
++ if (a == reg) last = pc; /* change register `a' */
++ }
++ if (testTMode(op)) {
++ check(pc+2 < pt->sizecode); /* check skip */
++ check(GET_OPCODE(pt->code[pc+1]) == OP_JMP);
++ }
++ switch (op) {
++ case OP_LOADBOOL: {
++ if (c == 1) { /* does it jump? */
++ check(pc+2 < pt->sizecode); /* check its jump */
++ check(GET_OPCODE(pt->code[pc+1]) != OP_SETLIST ||
++ GETARG_C(pt->code[pc+1]) != 0);
++ }
++ break;
++ }
++ case OP_LOADNIL: {
++ if (a <= reg && reg <= b)
++ last = pc; /* set registers from `a' to `b' */
++ break;
++ }
++ case OP_GETUPVAL:
++ case OP_SETUPVAL: {
++ check(b < pt->nups);
++ break;
++ }
++ case OP_GETGLOBAL:
++ case OP_SETGLOBAL: {
++ check(ttisstring(&pt->k[b]));
++ break;
++ }
++ case OP_SELF: {
++ checkreg(pt, a+1);
++ if (reg == a+1) last = pc;
++ break;
++ }
++ case OP_CONCAT: {
++ check(b < c); /* at least two operands */
++ break;
++ }
++ case OP_TFORLOOP: {
++ check(c >= 1); /* at least one result (control variable) */
++ checkreg(pt, a+2+c); /* space for results */
++ if (reg >= a+2) last = pc; /* affect all regs above its base */
++ break;
++ }
++ case OP_FORLOOP:
++ case OP_FORPREP:
++ checkreg(pt, a+3);
++ /* go through */
++ case OP_JMP: {
++ int dest = pc+1+b;
++ /* not full check and jump is forward and do not skip `lastpc'? */
++ if (reg != NO_REG && pc < dest && dest <= lastpc)
++ pc += b; /* do the jump */
++ break;
++ }
++ case OP_CALL:
++ case OP_TAILCALL: {
++ if (b != 0) {
++ checkreg(pt, a+b-1);
++ }
++ c--; /* c = num. returns */
++ if (c == LUA_MULTRET) {
++ check(checkopenop(pt, pc));
++ }
++ else if (c != 0)
++ checkreg(pt, a+c-1);
++ if (reg >= a) last = pc; /* affect all registers above base */
++ break;
++ }
++ case OP_RETURN: {
++ b--; /* b = num. returns */
++ if (b > 0) checkreg(pt, a+b-1);
++ break;
++ }
++ case OP_SETLIST: {
++ if (b > 0) checkreg(pt, a + b);
++ if (c == 0) {
++ pc++;
++ check(pc < pt->sizecode - 1);
++ }
++ break;
++ }
++ case OP_CLOSURE: {
++ int nup, j;
++ check(b < pt->sizep);
++ nup = pt->p[b]->nups;
++ check(pc + nup < pt->sizecode);
++ for (j = 1; j <= nup; j++) {
++ OpCode op1 = GET_OPCODE(pt->code[pc + j]);
++ check(op1 == OP_GETUPVAL || op1 == OP_MOVE);
++ }
++ if (reg != NO_REG) /* tracing? */
++ pc += nup; /* do not 'execute' these pseudo-instructions */
++ break;
++ }
++ case OP_VARARG: {
++ check((pt->is_vararg & VARARG_ISVARARG) &&
++ !(pt->is_vararg & VARARG_NEEDSARG));
++ b--;
++ if (b == LUA_MULTRET) check(checkopenop(pt, pc));
++ checkreg(pt, a+b-1);
++ break;
++ }
++ default: break;
++ }
++ }
++ return pt->code[last];
++}
++
++#undef check
++#undef checkjump
++#undef checkreg
++
++/* }====================================================== */
++
++
++int luaG_checkcode (const Proto *pt) {
++ return (symbexec(pt, pt->sizecode, NO_REG) != 0);
++}
++
++
++static const char *kname (Proto *p, int c) {
++ if (ISK(c) && ttisstring(&p->k[INDEXK(c)]))
++ return svalue(&p->k[INDEXK(c)]);
++ else
++ return "?";
++}
++
++
++static const char *getobjname (lua_State *L, CallInfo *ci, int stackpos,
++ const char **name) {
++ if (isLua(ci)) { /* a Lua function? */
++ Proto *p = ci_func(ci)->l.p;
++ int pc = currentpc(L, ci);
++ Instruction i;
++ *name = luaF_getlocalname(p, stackpos+1, pc);
++ if (*name) /* is a local? */
++ return "local";
++ i = symbexec(p, pc, stackpos); /* try symbolic execution */
++ lua_assert(pc != -1);
++ switch (GET_OPCODE(i)) {
++ case OP_GETGLOBAL: {
++ int g = GETARG_Bx(i); /* global index */
++ lua_assert(ttisstring(&p->k[g]));
++ *name = svalue(&p->k[g]);
++ return "global";
++ }
++ case OP_MOVE: {
++ int a = GETARG_A(i);
++ int b = GETARG_B(i); /* move from `b' to `a' */
++ if (b < a)
++ return getobjname(L, ci, b, name); /* get name for `b' */
++ break;
++ }
++ case OP_GETTABLE: {
++ int k = GETARG_C(i); /* key index */
++ *name = kname(p, k);
++ return "field";
++ }
++ case OP_GETUPVAL: {
++ int u = GETARG_B(i); /* upvalue index */
++ *name = p->upvalues ? getstr(p->upvalues[u]) : "?";
++ return "upvalue";
++ }
++ case OP_SELF: {
++ int k = GETARG_C(i); /* key index */
++ *name = kname(p, k);
++ return "method";
++ }
++ default: break;
++ }
++ }
++ return NULL; /* no useful name found */
++}
++
++
++static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name) {
++ Instruction i;
++ if ((isLua(ci) && ci->tailcalls > 0) || !isLua(ci - 1))
++ return NULL; /* calling function is not Lua (or is unknown) */
++ ci--; /* calling function */
++ i = ci_func(ci)->l.p->code[currentpc(L, ci)];
++ if (GET_OPCODE(i) == OP_CALL || GET_OPCODE(i) == OP_TAILCALL ||
++ GET_OPCODE(i) == OP_TFORLOOP)
++ return getobjname(L, ci, GETARG_A(i), name);
++ else
++ return NULL; /* no useful name can be found */
++}
++
++
++/* only ANSI way to check whether a pointer points to an array */
++static int isinstack (CallInfo *ci, const TValue *o) {
++ StkId p;
++ for (p = ci->base; p < ci->top; p++)
++ if (o == p) return 1;
++ return 0;
++}
++
++
++void luaG_typeerror (lua_State *L, const TValue *o, const char *op) {
++ const char *name = NULL;
++ const char *t = luaT_typenames[ttype(o)];
++ const char *kind = (isinstack(L->ci, o)) ?
++ getobjname(L, L->ci, cast_int(o - L->base), &name) :
++ NULL;
++ if (kind)
++ luaG_runerror(L, "attempt to %s %s " LUA_QS " (a %s value)",
++ op, kind, name, t);
++ else
++ luaG_runerror(L, "attempt to %s a %s value", op, t);
++}
++
++
++void luaG_concaterror (lua_State *L, StkId p1, StkId p2) {
++ if (ttisstring(p1) || ttisnumber(p1)) p1 = p2;
++ lua_assert(!ttisstring(p1) && !ttisnumber(p1));
++ luaG_typeerror(L, p1, "concatenate");
++}
++
++
++void luaG_aritherror (lua_State *L, const TValue *p1, const TValue *p2) {
++ TValue temp;
++ if (luaV_tonumber(p1, &temp) == NULL)
++ p2 = p1; /* first operand is wrong */
++ luaG_typeerror(L, p2, "perform arithmetic on");
++}
++
++
++int luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2) {
++ const char *t1 = luaT_typenames[ttype(p1)];
++ const char *t2 = luaT_typenames[ttype(p2)];
++ if (t1[2] == t2[2])
++ luaG_runerror(L, "attempt to compare two %s values", t1);
++ else
++ luaG_runerror(L, "attempt to compare %s with %s", t1, t2);
++ return 0;
++}
++
++
++static void addinfo (lua_State *L, const char *msg) {
++ CallInfo *ci = L->ci;
++ if (isLua(ci)) { /* is Lua code? */
++ char buff[LUA_IDSIZE]; /* add file:line information */
++ int line = currentline(L, ci);
++ luaO_chunkid(buff, getstr(getluaproto(ci)->source), LUA_IDSIZE);
++ luaO_pushfstring(L, "%s:%d: %s", buff, line, msg);
++ }
++}
++
++
++void luaG_errormsg (lua_State *L) {
++ if (L->errfunc != 0) { /* is there an error handling function? */
++ StkId errfunc = restorestack(L, L->errfunc);
++ if (!ttisfunction(errfunc)) luaD_throw(L, LUA_ERRERR);
++ setobjs2s(L, L->top, L->top - 1); /* move argument */
++ setobjs2s(L, L->top - 1, errfunc); /* push function */
++ incr_top(L);
++ luaD_call(L, L->top - 2, 1); /* call it */
++ }
++ luaD_throw(L, LUA_ERRRUN);
++}
++
++
++void luaG_runerror (lua_State *L, const char *fmt, ...) {
++ va_list argp;
++ va_start(argp, fmt);
++ addinfo(L, luaO_pushvfstring(L, fmt, argp));
++ va_end(argp);
++ luaG_errormsg(L);
++}
++
+--- /dev/null
++++ b/extensions/LUA/lua/ldebug.h
+@@ -0,0 +1,33 @@
++/*
++** $Id: ldebug.h,v 2.3.1.1 2007/12/27 13:02:25 roberto Exp $
++** Auxiliary functions from Debug Interface module
++** See Copyright Notice in lua.h
++*/
++
++#ifndef ldebug_h
++#define ldebug_h
++
++
++#include "lstate.h"
++
++
++#define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1)
++
++#define getline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : 0)
++
++#define resethookcount(L) (L->hookcount = L->basehookcount)
++
++
++LUAI_FUNC void luaG_typeerror (lua_State *L, const TValue *o,
++ const char *opname);
++LUAI_FUNC void luaG_concaterror (lua_State *L, StkId p1, StkId p2);
++LUAI_FUNC void luaG_aritherror (lua_State *L, const TValue *p1,
++ const TValue *p2);
++LUAI_FUNC int luaG_ordererror (lua_State *L, const TValue *p1,
++ const TValue *p2);
++LUAI_FUNC void luaG_runerror (lua_State *L, const char *fmt, ...);
++LUAI_FUNC void luaG_errormsg (lua_State *L);
++LUAI_FUNC int luaG_checkcode (const Proto *pt);
++LUAI_FUNC int luaG_checkopenop (Instruction i);
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/ldo.c
+@@ -0,0 +1,515 @@
++/*
++** $Id: ldo.c,v 2.38.1.3 2008/01/18 22:31:22 roberto Exp $
++** Stack and Call structure of Lua
++** See Copyright Notice in lua.h
++*/
++
++#include <setjmp.h>
++#include <stdlib.h>
++#include <string.h>
++
++#define ldo_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "ldebug.h"
++#include "ldo.h"
++#include "lfunc.h"
++#include "lgc.h"
++#include "lmem.h"
++#include "lobject.h"
++#include "lopcodes.h"
++#include "lparser.h"
++#include "lstate.h"
++#include "lstring.h"
++#include "ltable.h"
++#include "ltm.h"
++#include "lundump.h"
++#include "lvm.h"
++#include "lzio.h"
++
++
++
++/*
++** {======================================================
++** Error-recovery functions
++** =======================================================
++*/
++
++
++/* chain list of long jump buffers */
++struct lua_longjmp {
++ struct lua_longjmp *previous;
++ luai_jmpbuf b;
++ volatile int status; /* error code */
++};
++
++
++void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop) {
++ switch (errcode) {
++ case LUA_ERRMEM: {
++ setsvalue2s(L, oldtop, luaS_newliteral(L, MEMERRMSG));
++ break;
++ }
++ case LUA_ERRERR: {
++ setsvalue2s(L, oldtop, luaS_newliteral(L, "error in error handling"));
++ break;
++ }
++ case LUA_ERRSYNTAX:
++ case LUA_ERRRUN: {
++ setobjs2s(L, oldtop, L->top - 1); /* error message on current top */
++ break;
++ }
++ }
++ L->top = oldtop + 1;
++}
++
++
++static void restore_stack_limit (lua_State *L) {
++ lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK - 1);
++ if (L->size_ci > LUAI_MAXCALLS) { /* there was an overflow? */
++ int inuse = cast_int(L->ci - L->base_ci);
++ if (inuse + 1 < LUAI_MAXCALLS) /* can `undo' overflow? */
++ luaD_reallocCI(L, LUAI_MAXCALLS);
++ }
++}
++
++
++static void resetstack (lua_State *L, int status) {
++ L->ci = L->base_ci;
++ L->base = L->ci->base;
++ luaF_close(L, L->base); /* close eventual pending closures */
++ luaD_seterrorobj(L, status, L->base);
++ L->nCcalls = L->baseCcalls;
++ L->allowhook = 1;
++ restore_stack_limit(L);
++ L->errfunc = 0;
++ L->errorJmp = NULL;
++}
++
++
++void luaD_throw (lua_State *L, int errcode) {
++ if (L->errorJmp) {
++ L->errorJmp->status = errcode;
++ LUAI_THROW(L, L->errorJmp);
++ }
++ else {
++ L->status = cast_byte(errcode);
++ if (G(L)->panic) {
++ resetstack(L, errcode);
++ lua_unlock(L);
++ G(L)->panic(L);
++ }
++ exit(EXIT_FAILURE);
++ }
++}
++
++
++int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) {
++ struct lua_longjmp lj;
++ lj.status = 0;
++ lj.previous = L->errorJmp; /* chain new error handler */
++ L->errorJmp = &lj;
++ LUAI_TRY(L, &lj,
++ (*f)(L, ud);
++ );
++ L->errorJmp = lj.previous; /* restore old error handler */
++ return lj.status;
++}
++
++/* }====================================================== */
++
++
++static void correctstack (lua_State *L, TValue *oldstack) {
++ CallInfo *ci;
++ GCObject *up;
++ L->top = (L->top - oldstack) + L->stack;
++ for (up = L->openupval; up != NULL; up = up->gch.next)
++ gco2uv(up)->v = (gco2uv(up)->v - oldstack) + L->stack;
++ for (ci = L->base_ci; ci <= L->ci; ci++) {
++ ci->top = (ci->top - oldstack) + L->stack;
++ ci->base = (ci->base - oldstack) + L->stack;
++ ci->func = (ci->func - oldstack) + L->stack;
++ }
++ L->base = (L->base - oldstack) + L->stack;
++}
++
++
++void luaD_reallocstack (lua_State *L, int newsize) {
++ TValue *oldstack = L->stack;
++ int realsize = newsize + 1 + EXTRA_STACK;
++ lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK - 1);
++ luaM_reallocvector(L, L->stack, L->stacksize, realsize, TValue);
++ L->stacksize = realsize;
++ L->stack_last = L->stack+newsize;
++ correctstack(L, oldstack);
++}
++
++
++void luaD_reallocCI (lua_State *L, int newsize) {
++ CallInfo *oldci = L->base_ci;
++ luaM_reallocvector(L, L->base_ci, L->size_ci, newsize, CallInfo);
++ L->size_ci = newsize;
++ L->ci = (L->ci - oldci) + L->base_ci;
++ L->end_ci = L->base_ci + L->size_ci - 1;
++}
++
++
++void luaD_growstack (lua_State *L, int n) {
++ if (n <= L->stacksize) /* double size is enough? */
++ luaD_reallocstack(L, 2*L->stacksize);
++ else
++ luaD_reallocstack(L, L->stacksize + n);
++}
++
++
++static CallInfo *growCI (lua_State *L) {
++ if (L->size_ci > LUAI_MAXCALLS) /* overflow while handling overflow? */
++ luaD_throw(L, LUA_ERRERR);
++ else {
++ luaD_reallocCI(L, 2*L->size_ci);
++ if (L->size_ci > LUAI_MAXCALLS)
++ luaG_runerror(L, "stack overflow");
++ }
++ return ++L->ci;
++}
++
++
++void luaD_callhook (lua_State *L, int event, int line) {
++ lua_Hook hook = L->hook;
++ if (hook && L->allowhook) {
++ ptrdiff_t top = savestack(L, L->top);
++ ptrdiff_t ci_top = savestack(L, L->ci->top);
++ lua_Debug ar;
++ ar.event = event;
++ ar.currentline = line;
++ if (event == LUA_HOOKTAILRET)
++ ar.i_ci = 0; /* tail call; no debug information about it */
++ else
++ ar.i_ci = cast_int(L->ci - L->base_ci);
++ luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */
++ L->ci->top = L->top + LUA_MINSTACK;
++ lua_assert(L->ci->top <= L->stack_last);
++ L->allowhook = 0; /* cannot call hooks inside a hook */
++ lua_unlock(L);
++ (*hook)(L, &ar);
++ lua_lock(L);
++ lua_assert(!L->allowhook);
++ L->allowhook = 1;
++ L->ci->top = restorestack(L, ci_top);
++ L->top = restorestack(L, top);
++ }
++}
++
++
++static StkId adjust_varargs (lua_State *L, Proto *p, int actual) {
++ int i;
++ int nfixargs = p->numparams;
++ Table *htab = NULL;
++ StkId base, fixed;
++ for (; actual < nfixargs; ++actual)
++ setnilvalue(L->top++);
++#if defined(LUA_COMPAT_VARARG)
++ if (p->is_vararg & VARARG_NEEDSARG) { /* compat. with old-style vararg? */
++ int nvar = actual - nfixargs; /* number of extra arguments */
++ lua_assert(p->is_vararg & VARARG_HASARG);
++ luaC_checkGC(L);
++ htab = luaH_new(L, nvar, 1); /* create `arg' table */
++ for (i=0; i<nvar; i++) /* put extra arguments into `arg' table */
++ setobj2n(L, luaH_setnum(L, htab, i+1), L->top - nvar + i);
++ /* store counter in field `n' */
++ setnvalue(luaH_setstr(L, htab, luaS_newliteral(L, "n")), cast_num(nvar));
++ }
++#endif
++ /* move fixed parameters to final position */
++ fixed = L->top - actual; /* first fixed argument */
++ base = L->top; /* final position of first argument */
++ for (i=0; i<nfixargs; i++) {
++ setobjs2s(L, L->top++, fixed+i);
++ setnilvalue(fixed+i);
++ }
++ /* add `arg' parameter */
++ if (htab) {
++ sethvalue(L, L->top++, htab);
++ lua_assert(iswhite(obj2gco(htab)));
++ }
++ return base;
++}
++
++
++static StkId tryfuncTM (lua_State *L, StkId func) {
++ const TValue *tm = luaT_gettmbyobj(L, func, TM_CALL);
++ StkId p;
++ ptrdiff_t funcr = savestack(L, func);
++ if (!ttisfunction(tm))
++ luaG_typeerror(L, func, "call");
++ /* Open a hole inside the stack at `func' */
++ for (p = L->top; p > func; p--) setobjs2s(L, p, p-1);
++ incr_top(L);
++ func = restorestack(L, funcr); /* previous call may change stack */
++ setobj2s(L, func, tm); /* tag method is the new function to be called */
++ return func;
++}
++
++
++
++#define inc_ci(L) \
++ ((L->ci == L->end_ci) ? growCI(L) : \
++ (condhardstacktests(luaD_reallocCI(L, L->size_ci)), ++L->ci))
++
++
++int luaD_precall (lua_State *L, StkId func, int nresults) {
++ LClosure *cl;
++ ptrdiff_t funcr;
++ if (!ttisfunction(func)) /* `func' is not a function? */
++ func = tryfuncTM(L, func); /* check the `function' tag method */
++ funcr = savestack(L, func);
++ cl = &clvalue(func)->l;
++ L->ci->savedpc = L->savedpc;
++ if (!cl->isC) { /* Lua function? prepare its call */
++ CallInfo *ci;
++ StkId st, base;
++ Proto *p = cl->p;
++ luaD_checkstack(L, p->maxstacksize);
++ func = restorestack(L, funcr);
++ if (!p->is_vararg) { /* no varargs? */
++ base = func + 1;
++ if (L->top > base + p->numparams)
++ L->top = base + p->numparams;
++ }
++ else { /* vararg function */
++ int nargs = cast_int(L->top - func) - 1;
++ base = adjust_varargs(L, p, nargs);
++ func = restorestack(L, funcr); /* previous call may change the stack */
++ }
++ ci = inc_ci(L); /* now `enter' new function */
++ ci->func = func;
++ L->base = ci->base = base;
++ ci->top = L->base + p->maxstacksize;
++ lua_assert(ci->top <= L->stack_last);
++ L->savedpc = p->code; /* starting point */
++ ci->tailcalls = 0;
++ ci->nresults = nresults;
++ for (st = L->top; st < ci->top; st++)
++ setnilvalue(st);
++ L->top = ci->top;
++ if (L->hookmask & LUA_MASKCALL) {
++ L->savedpc++; /* hooks assume 'pc' is already incremented */
++ luaD_callhook(L, LUA_HOOKCALL, -1);
++ L->savedpc--; /* correct 'pc' */
++ }
++ return PCRLUA;
++ }
++ else { /* if is a C function, call it */
++ CallInfo *ci;
++ int n;
++ luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */
++ ci = inc_ci(L); /* now `enter' new function */
++ ci->func = restorestack(L, funcr);
++ L->base = ci->base = ci->func + 1;
++ ci->top = L->top + LUA_MINSTACK;
++ lua_assert(ci->top <= L->stack_last);
++ ci->nresults = nresults;
++ if (L->hookmask & LUA_MASKCALL)
++ luaD_callhook(L, LUA_HOOKCALL, -1);
++ lua_unlock(L);
++ n = (*curr_func(L)->c.f)(L); /* do the actual call */
++ lua_lock(L);
++ if (n < 0) /* yielding? */
++ return PCRYIELD;
++ else {
++ luaD_poscall(L, L->top - n);
++ return PCRC;
++ }
++ }
++}
++
++
++static StkId callrethooks (lua_State *L, StkId firstResult) {
++ ptrdiff_t fr = savestack(L, firstResult); /* next call may change stack */
++ luaD_callhook(L, LUA_HOOKRET, -1);
++ if (f_isLua(L->ci)) { /* Lua function? */
++ while ((L->hookmask & LUA_MASKRET) && L->ci->tailcalls--) /* tail calls */
++ luaD_callhook(L, LUA_HOOKTAILRET, -1);
++ }
++ return restorestack(L, fr);
++}
++
++
++int luaD_poscall (lua_State *L, StkId firstResult) {
++ StkId res;
++ int wanted, i;
++ CallInfo *ci;
++ if (L->hookmask & LUA_MASKRET)
++ firstResult = callrethooks(L, firstResult);
++ ci = L->ci--;
++ res = ci->func; /* res == final position of 1st result */
++ wanted = ci->nresults;
++ L->base = (ci - 1)->base; /* restore base */
++ L->savedpc = (ci - 1)->savedpc; /* restore savedpc */
++ /* move results to correct place */
++ for (i = wanted; i != 0 && firstResult < L->top; i--)
++ setobjs2s(L, res++, firstResult++);
++ while (i-- > 0)
++ setnilvalue(res++);
++ L->top = res;
++ return (wanted - LUA_MULTRET); /* 0 iff wanted == LUA_MULTRET */
++}
++
++
++/*
++** Call a function (C or Lua). The function to be called is at *func.
++** The arguments are on the stack, right after the function.
++** When returns, all the results are on the stack, starting at the original
++** function position.
++*/
++void luaD_call (lua_State *L, StkId func, int nResults) {
++ if (++L->nCcalls >= LUAI_MAXCCALLS) {
++ if (L->nCcalls == LUAI_MAXCCALLS)
++ luaG_runerror(L, "C stack overflow");
++ else if (L->nCcalls >= (LUAI_MAXCCALLS + (LUAI_MAXCCALLS>>3)))
++ luaD_throw(L, LUA_ERRERR); /* error while handing stack error */
++ }
++ if (luaD_precall(L, func, nResults) == PCRLUA) /* is a Lua function? */
++ luaV_execute(L, 1); /* call it */
++ L->nCcalls--;
++ luaC_checkGC(L);
++}
++
++
++static void resume (lua_State *L, void *ud) {
++ StkId firstArg = cast(StkId, ud);
++ CallInfo *ci = L->ci;
++ if (L->status == 0) { /* start coroutine? */
++ lua_assert(ci == L->base_ci && firstArg > L->base);
++ if (luaD_precall(L, firstArg - 1, LUA_MULTRET) != PCRLUA)
++ return;
++ }
++ else { /* resuming from previous yield */
++ lua_assert(L->status == LUA_YIELD);
++ L->status = 0;
++ if (!f_isLua(ci)) { /* `common' yield? */
++ /* finish interrupted execution of `OP_CALL' */
++ lua_assert(GET_OPCODE(*((ci-1)->savedpc - 1)) == OP_CALL ||
++ GET_OPCODE(*((ci-1)->savedpc - 1)) == OP_TAILCALL);
++ if (luaD_poscall(L, firstArg)) /* complete it... */
++ L->top = L->ci->top; /* and correct top if not multiple results */
++ }
++ else /* yielded inside a hook: just continue its execution */
++ L->base = L->ci->base;
++ }
++ luaV_execute(L, cast_int(L->ci - L->base_ci));
++}
++
++
++static int resume_error (lua_State *L, const char *msg) {
++ L->top = L->ci->base;
++ setsvalue2s(L, L->top, luaS_new(L, msg));
++ incr_top(L);
++ lua_unlock(L);
++ return LUA_ERRRUN;
++}
++
++
++LUA_API int lua_resume (lua_State *L, int nargs) {
++ int status;
++ lua_lock(L);
++ if (L->status != LUA_YIELD && (L->status != 0 || L->ci != L->base_ci))
++ return resume_error(L, "cannot resume non-suspended coroutine");
++ if (L->nCcalls >= LUAI_MAXCCALLS)
++ return resume_error(L, "C stack overflow");
++ luai_userstateresume(L, nargs);
++ lua_assert(L->errfunc == 0);
++ L->baseCcalls = ++L->nCcalls;
++ status = luaD_rawrunprotected(L, resume, L->top - nargs);
++ if (status != 0) { /* error? */
++ L->status = cast_byte(status); /* mark thread as `dead' */
++ luaD_seterrorobj(L, status, L->top);
++ L->ci->top = L->top;
++ }
++ else {
++ lua_assert(L->nCcalls == L->baseCcalls);
++ status = L->status;
++ }
++ --L->nCcalls;
++ lua_unlock(L);
++ return status;
++}
++
++
++LUA_API int lua_yield (lua_State *L, int nresults) {
++ luai_userstateyield(L, nresults);
++ lua_lock(L);
++ if (L->nCcalls > L->baseCcalls)
++ luaG_runerror(L, "attempt to yield across metamethod/C-call boundary");
++ L->base = L->top - nresults; /* protect stack slots below */
++ L->status = LUA_YIELD;
++ lua_unlock(L);
++ return -1;
++}
++
++
++int luaD_pcall (lua_State *L, Pfunc func, void *u,
++ ptrdiff_t old_top, ptrdiff_t ef) {
++ int status;
++ unsigned short oldnCcalls = L->nCcalls;
++ ptrdiff_t old_ci = saveci(L, L->ci);
++ lu_byte old_allowhooks = L->allowhook;
++ ptrdiff_t old_errfunc = L->errfunc;
++ L->errfunc = ef;
++ status = luaD_rawrunprotected(L, func, u);
++ if (status != 0) { /* an error occurred? */
++ StkId oldtop = restorestack(L, old_top);
++ luaF_close(L, oldtop); /* close eventual pending closures */
++ luaD_seterrorobj(L, status, oldtop);
++ L->nCcalls = oldnCcalls;
++ L->ci = restoreci(L, old_ci);
++ L->base = L->ci->base;
++ L->savedpc = L->ci->savedpc;
++ L->allowhook = old_allowhooks;
++ restore_stack_limit(L);
++ }
++ L->errfunc = old_errfunc;
++ return status;
++}
++
++
++
++/*
++** Execute a protected parser.
++*/
++struct SParser { /* data to `f_parser' */
++ ZIO *z;
++ Mbuffer buff; /* buffer to be used by the scanner */
++ const char *name;
++};
++
++static void f_parser (lua_State *L, void *ud) {
++ int i;
++ Proto *tf;
++ Closure *cl;
++ struct SParser *p = cast(struct SParser *, ud);
++ int c = luaZ_lookahead(p->z);
++ luaC_checkGC(L);
++ tf = ((c == LUA_SIGNATURE[0]) ? luaU_undump : luaY_parser)(L, p->z,
++ &p->buff, p->name);
++ cl = luaF_newLclosure(L, tf->nups, hvalue(gt(L)));
++ cl->l.p = tf;
++ for (i = 0; i < tf->nups; i++) /* initialize eventual upvalues */
++ cl->l.upvals[i] = luaF_newupval(L);
++ setclvalue(L, L->top, cl);
++ incr_top(L);
++}
++
++
++int luaD_protectedparser (lua_State *L, ZIO *z, const char *name) {
++ struct SParser p;
++ int status;
++ p.z = z; p.name = name;
++ luaZ_initbuffer(L, &p.buff);
++ status = luaD_pcall(L, f_parser, &p, savestack(L, L->top), L->errfunc);
++ luaZ_freebuffer(L, &p.buff);
++ return status;
++}
++
+--- /dev/null
++++ b/extensions/LUA/lua/ldo.h
+@@ -0,0 +1,57 @@
++/*
++** $Id: ldo.h,v 2.7.1.1 2007/12/27 13:02:25 roberto Exp $
++** Stack and Call structure of Lua
++** See Copyright Notice in lua.h
++*/
++
++#ifndef ldo_h
++#define ldo_h
++
++
++#include "lobject.h"
++#include "lstate.h"
++#include "lzio.h"
++
++
++#define luaD_checkstack(L,n) \
++ if ((char *)L->stack_last - (char *)L->top <= (n)*(int)sizeof(TValue)) \
++ luaD_growstack(L, n); \
++ else condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK - 1));
++
++
++#define incr_top(L) {luaD_checkstack(L,1); L->top++;}
++
++#define savestack(L,p) ((char *)(p) - (char *)L->stack)
++#define restorestack(L,n) ((TValue *)((char *)L->stack + (n)))
++
++#define saveci(L,p) ((char *)(p) - (char *)L->base_ci)
++#define restoreci(L,n) ((CallInfo *)((char *)L->base_ci + (n)))
++
++
++/* results from luaD_precall */
++#define PCRLUA 0 /* initiated a call to a Lua function */
++#define PCRC 1 /* did a call to a C function */
++#define PCRYIELD 2 /* C funtion yielded */
++
++
++/* type of protected functions, to be ran by `runprotected' */
++typedef void (*Pfunc) (lua_State *L, void *ud);
++
++LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name);
++LUAI_FUNC void luaD_callhook (lua_State *L, int event, int line);
++LUAI_FUNC int luaD_precall (lua_State *L, StkId func, int nresults);
++LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults);
++LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u,
++ ptrdiff_t oldtop, ptrdiff_t ef);
++LUAI_FUNC int luaD_poscall (lua_State *L, StkId firstResult);
++LUAI_FUNC void luaD_reallocCI (lua_State *L, int newsize);
++LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize);
++LUAI_FUNC void luaD_growstack (lua_State *L, int n);
++
++LUAI_FUNC void luaD_throw (lua_State *L, int errcode);
++LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud);
++
++LUAI_FUNC void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop);
++
++#endif
++
+--- /dev/null
++++ b/extensions/LUA/lua/ldump.c
+@@ -0,0 +1,164 @@
++/*
++** $Id: ldump.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $
++** save precompiled Lua chunks
++** See Copyright Notice in lua.h
++*/
++
++#include <stddef.h>
++
++#define ldump_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "lobject.h"
++#include "lstate.h"
++#include "lundump.h"
++
++typedef struct {
++ lua_State* L;
++ lua_Writer writer;
++ void* data;
++ int strip;
++ int status;
++} DumpState;
++
++#define DumpMem(b,n,size,D) DumpBlock(b,(n)*(size),D)
++#define DumpVar(x,D) DumpMem(&x,1,sizeof(x),D)
++
++static void DumpBlock(const void* b, size_t size, DumpState* D)
++{
++ if (D->status==0)
++ {
++ lua_unlock(D->L);
++ D->status=(*D->writer)(D->L,b,size,D->data);
++ lua_lock(D->L);
++ }
++}
++
++static void DumpChar(int y, DumpState* D)
++{
++ char x=(char)y;
++ DumpVar(x,D);
++}
++
++static void DumpInt(int x, DumpState* D)
++{
++ DumpVar(x,D);
++}
++
++static void DumpNumber(lua_Number x, DumpState* D)
++{
++ DumpVar(x,D);
++}
++
++static void DumpVector(const void* b, int n, size_t size, DumpState* D)
++{
++ DumpInt(n,D);
++ DumpMem(b,n,size,D);
++}
++
++static void DumpString(const TString* s, DumpState* D)
++{
++ if (s==NULL || getstr(s)==NULL)
++ {
++ size_t size=0;
++ DumpVar(size,D);
++ }
++ else
++ {
++ size_t size=s->tsv.len+1; /* include trailing '\0' */
++ DumpVar(size,D);
++ DumpBlock(getstr(s),size,D);
++ }
++}
++
++#define DumpCode(f,D) DumpVector(f->code,f->sizecode,sizeof(Instruction),D)
++
++static void DumpFunction(const Proto* f, const TString* p, DumpState* D);
++
++static void DumpConstants(const Proto* f, DumpState* D)
++{
++ int i,n=f->sizek;
++ DumpInt(n,D);
++ for (i=0; i<n; i++)
++ {
++ const TValue* o=&f->k[i];
++ DumpChar(ttype(o),D);
++ switch (ttype(o))
++ {
++ case LUA_TNIL:
++ break;
++ case LUA_TBOOLEAN:
++ DumpChar(bvalue(o),D);
++ break;
++ case LUA_TNUMBER:
++ DumpNumber(nvalue(o),D);
++ break;
++ case LUA_TSTRING:
++ DumpString(rawtsvalue(o),D);
++ break;
++ default:
++ lua_assert(0); /* cannot happen */
++ break;
++ }
++ }
++ n=f->sizep;
++ DumpInt(n,D);
++ for (i=0; i<n; i++) DumpFunction(f->p[i],f->source,D);
++}
++
++static void DumpDebug(const Proto* f, DumpState* D)
++{
++ int i,n;
++ n= (D->strip) ? 0 : f->sizelineinfo;
++ DumpVector(f->lineinfo,n,sizeof(int),D);
++ n= (D->strip) ? 0 : f->sizelocvars;
++ DumpInt(n,D);
++ for (i=0; i<n; i++)
++ {
++ DumpString(f->locvars[i].varname,D);
++ DumpInt(f->locvars[i].startpc,D);
++ DumpInt(f->locvars[i].endpc,D);
++ }
++ n= (D->strip) ? 0 : f->sizeupvalues;
++ DumpInt(n,D);
++ for (i=0; i<n; i++) DumpString(f->upvalues[i],D);
++}
++
++static void DumpFunction(const Proto* f, const TString* p, DumpState* D)
++{
++ DumpString((f->source==p || D->strip) ? NULL : f->source,D);
++ DumpInt(f->linedefined,D);
++ DumpInt(f->lastlinedefined,D);
++ DumpChar(f->nups,D);
++ DumpChar(f->numparams,D);
++ DumpChar(f->is_vararg,D);
++ DumpChar(f->maxstacksize,D);
++ DumpCode(f,D);
++ DumpConstants(f,D);
++ DumpDebug(f,D);
++}
++
++static void DumpHeader(DumpState* D)
++{
++ char h[LUAC_HEADERSIZE];
++ luaU_header(h);
++ DumpBlock(h,LUAC_HEADERSIZE,D);
++}
++
++/*
++** dump Lua function as precompiled chunk
++*/
++int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip)
++{
++ DumpState D;
++ D.L=L;
++ D.writer=w;
++ D.data=data;
++ D.strip=strip;
++ D.status=0;
++ DumpHeader(&D);
++ DumpFunction(f,NULL,&D);
++ return D.status;
++}
+--- /dev/null
++++ b/extensions/LUA/lua/lfunc.c
+@@ -0,0 +1,174 @@
++/*
++** $Id: lfunc.c,v 2.12.1.2 2007/12/28 14:58:43 roberto Exp $
++** Auxiliary functions to manipulate prototypes and closures
++** See Copyright Notice in lua.h
++*/
++
++
++#include <stddef.h>
++
++#define lfunc_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "lfunc.h"
++#include "lgc.h"
++#include "lmem.h"
++#include "lobject.h"
++#include "lstate.h"
++
++
++
++Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e) {
++ Closure *c = cast(Closure *, luaM_malloc(L, sizeCclosure(nelems)));
++ luaC_link(L, obj2gco(c), LUA_TFUNCTION);
++ c->c.isC = 1;
++ c->c.env = e;
++ c->c.nupvalues = cast_byte(nelems);
++ return c;
++}
++
++
++Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e) {
++ Closure *c = cast(Closure *, luaM_malloc(L, sizeLclosure(nelems)));
++ luaC_link(L, obj2gco(c), LUA_TFUNCTION);
++ c->l.isC = 0;
++ c->l.env = e;
++ c->l.nupvalues = cast_byte(nelems);
++ while (nelems--) c->l.upvals[nelems] = NULL;
++ return c;
++}
++
++
++UpVal *luaF_newupval (lua_State *L) {
++ UpVal *uv = luaM_new(L, UpVal);
++ luaC_link(L, obj2gco(uv), LUA_TUPVAL);
++ uv->v = &uv->u.value;
++ setnilvalue(uv->v);
++ return uv;
++}
++
++
++UpVal *luaF_findupval (lua_State *L, StkId level) {
++ global_State *g = G(L);
++ GCObject **pp = &L->openupval;
++ UpVal *p;
++ UpVal *uv;
++ while (*pp != NULL && (p = ngcotouv(*pp))->v >= level) {
++ lua_assert(p->v != &p->u.value);
++ if (p->v == level) { /* found a corresponding upvalue? */
++ if (isdead(g, obj2gco(p))) /* is it dead? */
++ changewhite(obj2gco(p)); /* ressurect it */
++ return p;
++ }
++ pp = &p->next;
++ }
++ uv = luaM_new(L, UpVal); /* not found: create a new one */
++ uv->tt = LUA_TUPVAL;
++ uv->marked = luaC_white(g);
++ uv->v = level; /* current value lives in the stack */
++ uv->next = *pp; /* chain it in the proper position */
++ *pp = obj2gco(uv);
++ uv->u.l.prev = &g->uvhead; /* double link it in `uvhead' list */
++ uv->u.l.next = g->uvhead.u.l.next;
++ uv->u.l.next->u.l.prev = uv;
++ g->uvhead.u.l.next = uv;
++ lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv);
++ return uv;
++}
++
++
++static void unlinkupval (UpVal *uv) {
++ lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv);
++ uv->u.l.next->u.l.prev = uv->u.l.prev; /* remove from `uvhead' list */
++ uv->u.l.prev->u.l.next = uv->u.l.next;
++}
++
++
++void luaF_freeupval (lua_State *L, UpVal *uv) {
++ if (uv->v != &uv->u.value) /* is it open? */
++ unlinkupval(uv); /* remove from open list */
++ luaM_free(L, uv); /* free upvalue */
++}
++
++
++void luaF_close (lua_State *L, StkId level) {
++ UpVal *uv;
++ global_State *g = G(L);
++ while (L->openupval != NULL && (uv = ngcotouv(L->openupval))->v >= level) {
++ GCObject *o = obj2gco(uv);
++ lua_assert(!isblack(o) && uv->v != &uv->u.value);
++ L->openupval = uv->next; /* remove from `open' list */
++ if (isdead(g, o))
++ luaF_freeupval(L, uv); /* free upvalue */
++ else {
++ unlinkupval(uv);
++ setobj(L, &uv->u.value, uv->v);
++ uv->v = &uv->u.value; /* now current value lives here */
++ luaC_linkupval(L, uv); /* link upvalue into `gcroot' list */
++ }
++ }
++}
++
++
++Proto *luaF_newproto (lua_State *L) {
++ Proto *f = luaM_new(L, Proto);
++ luaC_link(L, obj2gco(f), LUA_TPROTO);
++ f->k = NULL;
++ f->sizek = 0;
++ f->p = NULL;
++ f->sizep = 0;
++ f->code = NULL;
++ f->sizecode = 0;
++ f->sizelineinfo = 0;
++ f->sizeupvalues = 0;
++ f->nups = 0;
++ f->upvalues = NULL;
++ f->numparams = 0;
++ f->is_vararg = 0;
++ f->maxstacksize = 0;
++ f->lineinfo = NULL;
++ f->sizelocvars = 0;
++ f->locvars = NULL;
++ f->linedefined = 0;
++ f->lastlinedefined = 0;
++ f->source = NULL;
++ return f;
++}
++
++
++void luaF_freeproto (lua_State *L, Proto *f) {
++ luaM_freearray(L, f->code, f->sizecode, Instruction);
++ luaM_freearray(L, f->p, f->sizep, Proto *);
++ luaM_freearray(L, f->k, f->sizek, TValue);
++ luaM_freearray(L, f->lineinfo, f->sizelineinfo, int);
++ luaM_freearray(L, f->locvars, f->sizelocvars, struct LocVar);
++ luaM_freearray(L, f->upvalues, f->sizeupvalues, TString *);
++ luaM_free(L, f);
++}
++
++
++void luaF_freeclosure (lua_State *L, Closure *c) {
++ int size = (c->c.isC) ? sizeCclosure(c->c.nupvalues) :
++ sizeLclosure(c->l.nupvalues);
++ luaM_freemem(L, c, size);
++}
++
++
++/*
++** Look for n-th local variable at line `line' in function `func'.
++** Returns NULL if not found.
++*/
++const char *luaF_getlocalname (const Proto *f, int local_number, int pc) {
++ int i;
++ for (i = 0; i<f->sizelocvars && f->locvars[i].startpc <= pc; i++) {
++ if (pc < f->locvars[i].endpc) { /* is variable active? */
++ local_number--;
++ if (local_number == 0)
++ return getstr(f->locvars[i].varname);
++ }
++ }
++ return NULL; /* not found */
++}
++
+--- /dev/null
++++ b/extensions/LUA/lua/lfunc.h
+@@ -0,0 +1,34 @@
++/*
++** $Id: lfunc.h,v 2.4.1.1 2007/12/27 13:02:25 roberto Exp $
++** Auxiliary functions to manipulate prototypes and closures
++** See Copyright Notice in lua.h
++*/
++
++#ifndef lfunc_h
++#define lfunc_h
++
++
++#include "lobject.h"
++
++
++#define sizeCclosure(n) (cast(int, sizeof(CClosure)) + \
++ cast(int, sizeof(TValue)*((n)-1)))
++
++#define sizeLclosure(n) (cast(int, sizeof(LClosure)) + \
++ cast(int, sizeof(TValue *)*((n)-1)))
++
++
++LUAI_FUNC Proto *luaF_newproto (lua_State *L);
++LUAI_FUNC Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e);
++LUAI_FUNC Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e);
++LUAI_FUNC UpVal *luaF_newupval (lua_State *L);
++LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level);
++LUAI_FUNC void luaF_close (lua_State *L, StkId level);
++LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f);
++LUAI_FUNC void luaF_freeclosure (lua_State *L, Closure *c);
++LUAI_FUNC void luaF_freeupval (lua_State *L, UpVal *uv);
++LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number,
++ int pc);
++
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/lgc.c
+@@ -0,0 +1,711 @@
++/*
++** $Id: lgc.c,v 2.38.1.1 2007/12/27 13:02:25 roberto Exp $
++** Garbage Collector
++** See Copyright Notice in lua.h
++*/
++
++#include <string.h>
++
++#define lgc_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "ldebug.h"
++#include "ldo.h"
++#include "lfunc.h"
++#include "lgc.h"
++#include "lmem.h"
++#include "lobject.h"
++#include "lstate.h"
++#include "lstring.h"
++#include "ltable.h"
++#include "ltm.h"
++
++
++#define GCSTEPSIZE 1024u
++#define GCSWEEPMAX 40
++#define GCSWEEPCOST 10
++#define GCFINALIZECOST 100
++
++
++#define maskmarks cast_byte(~(bitmask(BLACKBIT)|WHITEBITS))
++
++#define makewhite(g,x) \
++ ((x)->gch.marked = cast_byte(((x)->gch.marked & maskmarks) | luaC_white(g)))
++
++#define white2gray(x) reset2bits((x)->gch.marked, WHITE0BIT, WHITE1BIT)
++#define black2gray(x) resetbit((x)->gch.marked, BLACKBIT)
++
++#define stringmark(s) reset2bits((s)->tsv.marked, WHITE0BIT, WHITE1BIT)
++
++
++#define isfinalized(u) testbit((u)->marked, FINALIZEDBIT)
++#define markfinalized(u) l_setbit((u)->marked, FINALIZEDBIT)
++
++
++#define KEYWEAK bitmask(KEYWEAKBIT)
++#define VALUEWEAK bitmask(VALUEWEAKBIT)
++
++
++
++#define markvalue(g,o) { checkconsistency(o); \
++ if (iscollectable(o) && iswhite(gcvalue(o))) reallymarkobject(g,gcvalue(o)); }
++
++#define markobject(g,t) { if (iswhite(obj2gco(t))) \
++ reallymarkobject(g, obj2gco(t)); }
++
++
++#define setthreshold(g) (g->GCthreshold = (g->estimate/100) * g->gcpause)
++
++
++static void removeentry (Node *n) {
++ lua_assert(ttisnil(gval(n)));
++ if (iscollectable(gkey(n)))
++ setttype(gkey(n), LUA_TDEADKEY); /* dead key; remove it */
++}
++
++
++static void reallymarkobject (global_State *g, GCObject *o) {
++ lua_assert(iswhite(o) && !isdead(g, o));
++ white2gray(o);
++ switch (o->gch.tt) {
++ case LUA_TSTRING: {
++ return;
++ }
++ case LUA_TUSERDATA: {
++ Table *mt = gco2u(o)->metatable;
++ gray2black(o); /* udata are never gray */
++ if (mt) markobject(g, mt);
++ markobject(g, gco2u(o)->env);
++ return;
++ }
++ case LUA_TUPVAL: {
++ UpVal *uv = gco2uv(o);
++ markvalue(g, uv->v);
++ if (uv->v == &uv->u.value) /* closed? */
++ gray2black(o); /* open upvalues are never black */
++ return;
++ }
++ case LUA_TFUNCTION: {
++ gco2cl(o)->c.gclist = g->gray;
++ g->gray = o;
++ break;
++ }
++ case LUA_TTABLE: {
++ gco2h(o)->gclist = g->gray;
++ g->gray = o;
++ break;
++ }
++ case LUA_TTHREAD: {
++ gco2th(o)->gclist = g->gray;
++ g->gray = o;
++ break;
++ }
++ case LUA_TPROTO: {
++ gco2p(o)->gclist = g->gray;
++ g->gray = o;
++ break;
++ }
++ default: lua_assert(0);
++ }
++}
++
++
++static void marktmu (global_State *g) {
++ GCObject *u = g->tmudata;
++ if (u) {
++ do {
++ u = u->gch.next;
++ makewhite(g, u); /* may be marked, if left from previous GC */
++ reallymarkobject(g, u);
++ } while (u != g->tmudata);
++ }
++}
++
++
++/* move `dead' udata that need finalization to list `tmudata' */
++size_t luaC_separateudata (lua_State *L, int all) {
++ global_State *g = G(L);
++ size_t deadmem = 0;
++ GCObject **p = &g->mainthread->next;
++ GCObject *curr;
++ while ((curr = *p) != NULL) {
++ if (!(iswhite(curr) || all) || isfinalized(gco2u(curr)))
++ p = &curr->gch.next; /* don't bother with them */
++ else if (fasttm(L, gco2u(curr)->metatable, TM_GC) == NULL) {
++ markfinalized(gco2u(curr)); /* don't need finalization */
++ p = &curr->gch.next;
++ }
++ else { /* must call its gc method */
++ deadmem += sizeudata(gco2u(curr));
++ markfinalized(gco2u(curr));
++ *p = curr->gch.next;
++ /* link `curr' at the end of `tmudata' list */
++ if (g->tmudata == NULL) /* list is empty? */
++ g->tmudata = curr->gch.next = curr; /* creates a circular list */
++ else {
++ curr->gch.next = g->tmudata->gch.next;
++ g->tmudata->gch.next = curr;
++ g->tmudata = curr;
++ }
++ }
++ }
++ return deadmem;
++}
++
++
++static int traversetable (global_State *g, Table *h) {
++ int i;
++ int weakkey = 0;
++ int weakvalue = 0;
++ const TValue *mode;
++ if (h->metatable)
++ markobject(g, h->metatable);
++ mode = gfasttm(g, h->metatable, TM_MODE);
++ if (mode && ttisstring(mode)) { /* is there a weak mode? */
++ weakkey = (strchr(svalue(mode), 'k') != NULL);
++ weakvalue = (strchr(svalue(mode), 'v') != NULL);
++ if (weakkey || weakvalue) { /* is really weak? */
++ h->marked &= ~(KEYWEAK | VALUEWEAK); /* clear bits */
++ h->marked |= cast_byte((weakkey << KEYWEAKBIT) |
++ (weakvalue << VALUEWEAKBIT));
++ h->gclist = g->weak; /* must be cleared after GC, ... */
++ g->weak = obj2gco(h); /* ... so put in the appropriate list */
++ }
++ }
++ if (weakkey && weakvalue) return 1;
++ if (!weakvalue) {
++ i = h->sizearray;
++ while (i--)
++ markvalue(g, &h->array[i]);
++ }
++ i = sizenode(h);
++ while (i--) {
++ Node *n = gnode(h, i);
++ lua_assert(ttype(gkey(n)) != LUA_TDEADKEY || ttisnil(gval(n)));
++ if (ttisnil(gval(n)))
++ removeentry(n); /* remove empty entries */
++ else {
++ lua_assert(!ttisnil(gkey(n)));
++ if (!weakkey) markvalue(g, gkey(n));
++ if (!weakvalue) markvalue(g, gval(n));
++ }
++ }
++ return weakkey || weakvalue;
++}
++
++
++/*
++** All marks are conditional because a GC may happen while the
++** prototype is still being created
++*/
++static void traverseproto (global_State *g, Proto *f) {
++ int i;
++ if (f->source) stringmark(f->source);
++ for (i=0; i<f->sizek; i++) /* mark literals */
++ markvalue(g, &f->k[i]);
++ for (i=0; i<f->sizeupvalues; i++) { /* mark upvalue names */
++ if (f->upvalues[i])
++ stringmark(f->upvalues[i]);
++ }
++ for (i=0; i<f->sizep; i++) { /* mark nested protos */
++ if (f->p[i])
++ markobject(g, f->p[i]);
++ }
++ for (i=0; i<f->sizelocvars; i++) { /* mark local-variable names */
++ if (f->locvars[i].varname)
++ stringmark(f->locvars[i].varname);
++ }
++}
++
++
++
++static void traverseclosure (global_State *g, Closure *cl) {
++ markobject(g, cl->c.env);
++ if (cl->c.isC) {
++ int i;
++ for (i=0; i<cl->c.nupvalues; i++) /* mark its upvalues */
++ markvalue(g, &cl->c.upvalue[i]);
++ }
++ else {
++ int i;
++ lua_assert(cl->l.nupvalues == cl->l.p->nups);
++ markobject(g, cl->l.p);
++ for (i=0; i<cl->l.nupvalues; i++) /* mark its upvalues */
++ markobject(g, cl->l.upvals[i]);
++ }
++}
++
++
++static void checkstacksizes (lua_State *L, StkId max) {
++ int ci_used = cast_int(L->ci - L->base_ci); /* number of `ci' in use */
++ int s_used = cast_int(max - L->stack); /* part of stack in use */
++ if (L->size_ci > LUAI_MAXCALLS) /* handling overflow? */
++ return; /* do not touch the stacks */
++ if (4*ci_used < L->size_ci && 2*BASIC_CI_SIZE < L->size_ci)
++ luaD_reallocCI(L, L->size_ci/2); /* still big enough... */
++ condhardstacktests(luaD_reallocCI(L, ci_used + 1));
++ if (4*s_used < L->stacksize &&
++ 2*(BASIC_STACK_SIZE+EXTRA_STACK) < L->stacksize)
++ luaD_reallocstack(L, L->stacksize/2); /* still big enough... */
++ condhardstacktests(luaD_reallocstack(L, s_used));
++}
++
++
++static void traversestack (global_State *g, lua_State *l) {
++ StkId o, lim;
++ CallInfo *ci;
++ markvalue(g, gt(l));
++ lim = l->top;
++ for (ci = l->base_ci; ci <= l->ci; ci++) {
++ lua_assert(ci->top <= l->stack_last);
++ if (lim < ci->top) lim = ci->top;
++ }
++ for (o = l->stack; o < l->top; o++)
++ markvalue(g, o);
++ for (; o <= lim; o++)
++ setnilvalue(o);
++ checkstacksizes(l, lim);
++}
++
++
++/*
++** traverse one gray object, turning it to black.
++** Returns `quantity' traversed.
++*/
++static l_mem propagatemark (global_State *g) {
++ GCObject *o = g->gray;
++ lua_assert(isgray(o));
++ gray2black(o);
++ switch (o->gch.tt) {
++ case LUA_TTABLE: {
++ Table *h = gco2h(o);
++ g->gray = h->gclist;
++ if (traversetable(g, h)) /* table is weak? */
++ black2gray(o); /* keep it gray */
++ return sizeof(Table) + sizeof(TValue) * h->sizearray +
++ sizeof(Node) * sizenode(h);
++ }
++ case LUA_TFUNCTION: {
++ Closure *cl = gco2cl(o);
++ g->gray = cl->c.gclist;
++ traverseclosure(g, cl);
++ return (cl->c.isC) ? sizeCclosure(cl->c.nupvalues) :
++ sizeLclosure(cl->l.nupvalues);
++ }
++ case LUA_TTHREAD: {
++ lua_State *th = gco2th(o);
++ g->gray = th->gclist;
++ th->gclist = g->grayagain;
++ g->grayagain = o;
++ black2gray(o);
++ traversestack(g, th);
++ return sizeof(lua_State) + sizeof(TValue) * th->stacksize +
++ sizeof(CallInfo) * th->size_ci;
++ }
++ case LUA_TPROTO: {
++ Proto *p = gco2p(o);
++ g->gray = p->gclist;
++ traverseproto(g, p);
++ return sizeof(Proto) + sizeof(Instruction) * p->sizecode +
++ sizeof(Proto *) * p->sizep +
++ sizeof(TValue) * p->sizek +
++ sizeof(int) * p->sizelineinfo +
++ sizeof(LocVar) * p->sizelocvars +
++ sizeof(TString *) * p->sizeupvalues;
++ }
++ default: lua_assert(0); return 0;
++ }
++}
++
++
++static size_t propagateall (global_State *g) {
++ size_t m = 0;
++ while (g->gray) m += propagatemark(g);
++ return m;
++}
++
++
++/*
++** The next function tells whether a key or value can be cleared from
++** a weak table. Non-collectable objects are never removed from weak
++** tables. Strings behave as `values', so are never removed too. for
++** other objects: if really collected, cannot keep them; for userdata
++** being finalized, keep them in keys, but not in values
++*/
++static int iscleared (const TValue *o, int iskey) {
++ if (!iscollectable(o)) return 0;
++ if (ttisstring(o)) {
++ stringmark(rawtsvalue(o)); /* strings are `values', so are never weak */
++ return 0;
++ }
++ return iswhite(gcvalue(o)) ||
++ (ttisuserdata(o) && (!iskey && isfinalized(uvalue(o))));
++}
++
++
++/*
++** clear collected entries from weaktables
++*/
++static void cleartable (GCObject *l) {
++ while (l) {
++ Table *h = gco2h(l);
++ int i = h->sizearray;
++ lua_assert(testbit(h->marked, VALUEWEAKBIT) ||
++ testbit(h->marked, KEYWEAKBIT));
++ if (testbit(h->marked, VALUEWEAKBIT)) {
++ while (i--) {
++ TValue *o = &h->array[i];
++ if (iscleared(o, 0)) /* value was collected? */
++ setnilvalue(o); /* remove value */
++ }
++ }
++ i = sizenode(h);
++ while (i--) {
++ Node *n = gnode(h, i);
++ if (!ttisnil(gval(n)) && /* non-empty entry? */
++ (iscleared(key2tval(n), 1) || iscleared(gval(n), 0))) {
++ setnilvalue(gval(n)); /* remove value ... */
++ removeentry(n); /* remove entry from table */
++ }
++ }
++ l = h->gclist;
++ }
++}
++
++
++static void freeobj (lua_State *L, GCObject *o) {
++ switch (o->gch.tt) {
++ case LUA_TPROTO: luaF_freeproto(L, gco2p(o)); break;
++ case LUA_TFUNCTION: luaF_freeclosure(L, gco2cl(o)); break;
++ case LUA_TUPVAL: luaF_freeupval(L, gco2uv(o)); break;
++ case LUA_TTABLE: luaH_free(L, gco2h(o)); break;
++ case LUA_TTHREAD: {
++ lua_assert(gco2th(o) != L && gco2th(o) != G(L)->mainthread);
++ luaE_freethread(L, gco2th(o));
++ break;
++ }
++ case LUA_TSTRING: {
++ G(L)->strt.nuse--;
++ luaM_freemem(L, o, sizestring(gco2ts(o)));
++ break;
++ }
++ case LUA_TUSERDATA: {
++ luaM_freemem(L, o, sizeudata(gco2u(o)));
++ break;
++ }
++ default: lua_assert(0);
++ }
++}
++
++
++
++#define sweepwholelist(L,p) sweeplist(L,p,MAX_LUMEM)
++
++
++static GCObject **sweeplist (lua_State *L, GCObject **p, lu_mem count) {
++ GCObject *curr;
++ global_State *g = G(L);
++ int deadmask = otherwhite(g);
++ while ((curr = *p) != NULL && count-- > 0) {
++ if (curr->gch.tt == LUA_TTHREAD) /* sweep open upvalues of each thread */
++ sweepwholelist(L, &gco2th(curr)->openupval);
++ if ((curr->gch.marked ^ WHITEBITS) & deadmask) { /* not dead? */
++ lua_assert(!isdead(g, curr) || testbit(curr->gch.marked, FIXEDBIT));
++ makewhite(g, curr); /* make it white (for next cycle) */
++ p = &curr->gch.next;
++ }
++ else { /* must erase `curr' */
++ lua_assert(isdead(g, curr) || deadmask == bitmask(SFIXEDBIT));
++ *p = curr->gch.next;
++ if (curr == g->rootgc) /* is the first element of the list? */
++ g->rootgc = curr->gch.next; /* adjust first */
++ freeobj(L, curr);
++ }
++ }
++ return p;
++}
++
++
++static void checkSizes (lua_State *L) {
++ global_State *g = G(L);
++ /* check size of string hash */
++ if (g->strt.nuse < cast(lu_int32, g->strt.size/4) &&
++ g->strt.size > MINSTRTABSIZE*2)
++ luaS_resize(L, g->strt.size/2); /* table is too big */
++ /* check size of buffer */
++ if (luaZ_sizebuffer(&g->buff) > LUA_MINBUFFER*2) { /* buffer too big? */
++ size_t newsize = luaZ_sizebuffer(&g->buff) / 2;
++ luaZ_resizebuffer(L, &g->buff, newsize);
++ }
++}
++
++
++static void GCTM (lua_State *L) {
++ global_State *g = G(L);
++ GCObject *o = g->tmudata->gch.next; /* get first element */
++ Udata *udata = rawgco2u(o);
++ const TValue *tm;
++ /* remove udata from `tmudata' */
++ if (o == g->tmudata) /* last element? */
++ g->tmudata = NULL;
++ else
++ g->tmudata->gch.next = udata->uv.next;
++ udata->uv.next = g->mainthread->next; /* return it to `root' list */
++ g->mainthread->next = o;
++ makewhite(g, o);
++ tm = fasttm(L, udata->uv.metatable, TM_GC);
++ if (tm != NULL) {
++ lu_byte oldah = L->allowhook;
++ lu_mem oldt = g->GCthreshold;
++ L->allowhook = 0; /* stop debug hooks during GC tag method */
++ g->GCthreshold = 2*g->totalbytes; /* avoid GC steps */
++ setobj2s(L, L->top, tm);
++ setuvalue(L, L->top+1, udata);
++ L->top += 2;
++ luaD_call(L, L->top - 2, 0);
++ L->allowhook = oldah; /* restore hooks */
++ g->GCthreshold = oldt; /* restore threshold */
++ }
++}
++
++
++/*
++** Call all GC tag methods
++*/
++void luaC_callGCTM (lua_State *L) {
++ while (G(L)->tmudata)
++ GCTM(L);
++}
++
++
++void luaC_freeall (lua_State *L) {
++ global_State *g = G(L);
++ int i;
++ g->currentwhite = WHITEBITS | bitmask(SFIXEDBIT); /* mask to collect all elements */
++ sweepwholelist(L, &g->rootgc);
++ for (i = 0; i < g->strt.size; i++) /* free all string lists */
++ sweepwholelist(L, &g->strt.hash[i]);
++}
++
++
++static void markmt (global_State *g) {
++ int i;
++ for (i=0; i<NUM_TAGS; i++)
++ if (g->mt[i]) markobject(g, g->mt[i]);
++}
++
++
++/* mark root set */
++static void markroot (lua_State *L) {
++ global_State *g = G(L);
++ g->gray = NULL;
++ g->grayagain = NULL;
++ g->weak = NULL;
++ markobject(g, g->mainthread);
++ /* make global table be traversed before main stack */
++ markvalue(g, gt(g->mainthread));
++ markvalue(g, registry(L));
++ markmt(g);
++ g->gcstate = GCSpropagate;
++}
++
++
++static void remarkupvals (global_State *g) {
++ UpVal *uv;
++ for (uv = g->uvhead.u.l.next; uv != &g->uvhead; uv = uv->u.l.next) {
++ lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv);
++ if (isgray(obj2gco(uv)))
++ markvalue(g, uv->v);
++ }
++}
++
++
++static void atomic (lua_State *L) {
++ global_State *g = G(L);
++ size_t udsize; /* total size of userdata to be finalized */
++ /* remark occasional upvalues of (maybe) dead threads */
++ remarkupvals(g);
++ /* traverse objects cautch by write barrier and by 'remarkupvals' */
++ propagateall(g);
++ /* remark weak tables */
++ g->gray = g->weak;
++ g->weak = NULL;
++ lua_assert(!iswhite(obj2gco(g->mainthread)));
++ markobject(g, L); /* mark running thread */
++ markmt(g); /* mark basic metatables (again) */
++ propagateall(g);
++ /* remark gray again */
++ g->gray = g->grayagain;
++ g->grayagain = NULL;
++ propagateall(g);
++ udsize = luaC_separateudata(L, 0); /* separate userdata to be finalized */
++ marktmu(g); /* mark `preserved' userdata */
++ udsize += propagateall(g); /* remark, to propagate `preserveness' */
++ cleartable(g->weak); /* remove collected objects from weak tables */
++ /* flip current white */
++ g->currentwhite = cast_byte(otherwhite(g));
++ g->sweepstrgc = 0;
++ g->sweepgc = &g->rootgc;
++ g->gcstate = GCSsweepstring;
++ g->estimate = g->totalbytes - udsize; /* first estimate */
++}
++
++
++static l_mem singlestep (lua_State *L) {
++ global_State *g = G(L);
++ /*lua_checkmemory(L);*/
++ switch (g->gcstate) {
++ case GCSpause: {
++ markroot(L); /* start a new collection */
++ return 0;
++ }
++ case GCSpropagate: {
++ if (g->gray)
++ return propagatemark(g);
++ else { /* no more `gray' objects */
++ atomic(L); /* finish mark phase */
++ return 0;
++ }
++ }
++ case GCSsweepstring: {
++ lu_mem old = g->totalbytes;
++ sweepwholelist(L, &g->strt.hash[g->sweepstrgc++]);
++ if (g->sweepstrgc >= g->strt.size) /* nothing more to sweep? */
++ g->gcstate = GCSsweep; /* end sweep-string phase */
++ lua_assert(old >= g->totalbytes);
++ g->estimate -= old - g->totalbytes;
++ return GCSWEEPCOST;
++ }
++ case GCSsweep: {
++ lu_mem old = g->totalbytes;
++ g->sweepgc = sweeplist(L, g->sweepgc, GCSWEEPMAX);
++ if (*g->sweepgc == NULL) { /* nothing more to sweep? */
++ checkSizes(L);
++ g->gcstate = GCSfinalize; /* end sweep phase */
++ }
++ lua_assert(old >= g->totalbytes);
++ g->estimate -= old - g->totalbytes;
++ return GCSWEEPMAX*GCSWEEPCOST;
++ }
++ case GCSfinalize: {
++ if (g->tmudata) {
++ GCTM(L);
++ if (g->estimate > GCFINALIZECOST)
++ g->estimate -= GCFINALIZECOST;
++ return GCFINALIZECOST;
++ }
++ else {
++ g->gcstate = GCSpause; /* end collection */
++ g->gcdept = 0;
++ return 0;
++ }
++ }
++ default: lua_assert(0); return 0;
++ }
++}
++
++
++void luaC_step (lua_State *L) {
++ global_State *g = G(L);
++ l_mem lim = (GCSTEPSIZE/100) * g->gcstepmul;
++ if (lim == 0)
++ lim = (MAX_LUMEM-1)/2; /* no limit */
++ g->gcdept += g->totalbytes - g->GCthreshold;
++ do {
++ lim -= singlestep(L);
++ if (g->gcstate == GCSpause)
++ break;
++ } while (lim > 0);
++ if (g->gcstate != GCSpause) {
++ if (g->gcdept < GCSTEPSIZE)
++ g->GCthreshold = g->totalbytes + GCSTEPSIZE; /* - lim/g->gcstepmul;*/
++ else {
++ g->gcdept -= GCSTEPSIZE;
++ g->GCthreshold = g->totalbytes;
++ }
++ }
++ else {
++ lua_assert(g->totalbytes >= g->estimate);
++ setthreshold(g);
++ }
++}
++
++
++void luaC_fullgc (lua_State *L) {
++ global_State *g = G(L);
++ if (g->gcstate <= GCSpropagate) {
++ /* reset sweep marks to sweep all elements (returning them to white) */
++ g->sweepstrgc = 0;
++ g->sweepgc = &g->rootgc;
++ /* reset other collector lists */
++ g->gray = NULL;
++ g->grayagain = NULL;
++ g->weak = NULL;
++ g->gcstate = GCSsweepstring;
++ }
++ lua_assert(g->gcstate != GCSpause && g->gcstate != GCSpropagate);
++ /* finish any pending sweep phase */
++ while (g->gcstate != GCSfinalize) {
++ lua_assert(g->gcstate == GCSsweepstring || g->gcstate == GCSsweep);
++ singlestep(L);
++ }
++ markroot(L);
++ while (g->gcstate != GCSpause) {
++ singlestep(L);
++ }
++ setthreshold(g);
++}
++
++
++void luaC_barrierf (lua_State *L, GCObject *o, GCObject *v) {
++ global_State *g = G(L);
++ lua_assert(isblack(o) && iswhite(v) && !isdead(g, v) && !isdead(g, o));
++ lua_assert(g->gcstate != GCSfinalize && g->gcstate != GCSpause);
++ lua_assert(ttype(&o->gch) != LUA_TTABLE);
++ /* must keep invariant? */
++ if (g->gcstate == GCSpropagate)
++ reallymarkobject(g, v); /* restore invariant */
++ else /* don't mind */
++ makewhite(g, o); /* mark as white just to avoid other barriers */
++}
++
++
++void luaC_barrierback (lua_State *L, Table *t) {
++ global_State *g = G(L);
++ GCObject *o = obj2gco(t);
++ lua_assert(isblack(o) && !isdead(g, o));
++ lua_assert(g->gcstate != GCSfinalize && g->gcstate != GCSpause);
++ black2gray(o); /* make table gray (again) */
++ t->gclist = g->grayagain;
++ g->grayagain = o;
++}
++
++
++void luaC_link (lua_State *L, GCObject *o, lu_byte tt) {
++ global_State *g = G(L);
++ o->gch.next = g->rootgc;
++ g->rootgc = o;
++ o->gch.marked = luaC_white(g);
++ o->gch.tt = tt;
++}
++
++
++void luaC_linkupval (lua_State *L, UpVal *uv) {
++ global_State *g = G(L);
++ GCObject *o = obj2gco(uv);
++ o->gch.next = g->rootgc; /* link upvalue into `rootgc' list */
++ g->rootgc = o;
++ if (isgray(o)) {
++ if (g->gcstate == GCSpropagate) {
++ gray2black(o); /* closed upvalues need barrier */
++ luaC_barrier(L, uv, uv->v);
++ }
++ else { /* sweep phase: sweep it (turning it into white) */
++ makewhite(g, o);
++ lua_assert(g->gcstate != GCSfinalize && g->gcstate != GCSpause);
++ }
++ }
++}
++
+--- /dev/null
++++ b/extensions/LUA/lua/lgc.h
+@@ -0,0 +1,110 @@
++/*
++** $Id: lgc.h,v 2.15.1.1 2007/12/27 13:02:25 roberto Exp $
++** Garbage Collector
++** See Copyright Notice in lua.h
++*/
++
++#ifndef lgc_h
++#define lgc_h
++
++
++#include "lobject.h"
++
++
++/*
++** Possible states of the Garbage Collector
++*/
++#define GCSpause 0
++#define GCSpropagate 1
++#define GCSsweepstring 2
++#define GCSsweep 3
++#define GCSfinalize 4
++
++
++/*
++** some userful bit tricks
++*/
++#define resetbits(x,m) ((x) &= cast(lu_byte, ~(m)))
++#define setbits(x,m) ((x) |= (m))
++#define testbits(x,m) ((x) & (m))
++#define bitmask(b) (1<<(b))
++#define bit2mask(b1,b2) (bitmask(b1) | bitmask(b2))
++#define l_setbit(x,b) setbits(x, bitmask(b))
++#define resetbit(x,b) resetbits(x, bitmask(b))
++#define testbit(x,b) testbits(x, bitmask(b))
++#define set2bits(x,b1,b2) setbits(x, (bit2mask(b1, b2)))
++#define reset2bits(x,b1,b2) resetbits(x, (bit2mask(b1, b2)))
++#define test2bits(x,b1,b2) testbits(x, (bit2mask(b1, b2)))
++
++
++
++/*
++** Layout for bit use in `marked' field:
++** bit 0 - object is white (type 0)
++** bit 1 - object is white (type 1)
++** bit 2 - object is black
++** bit 3 - for userdata: has been finalized
++** bit 3 - for tables: has weak keys
++** bit 4 - for tables: has weak values
++** bit 5 - object is fixed (should not be collected)
++** bit 6 - object is "super" fixed (only the main thread)
++*/
++
++
++#define WHITE0BIT 0
++#define WHITE1BIT 1
++#define BLACKBIT 2
++#define FINALIZEDBIT 3
++#define KEYWEAKBIT 3
++#define VALUEWEAKBIT 4
++#define FIXEDBIT 5
++#define SFIXEDBIT 6
++#define WHITEBITS bit2mask(WHITE0BIT, WHITE1BIT)
++
++
++#define iswhite(x) test2bits((x)->gch.marked, WHITE0BIT, WHITE1BIT)
++#define isblack(x) testbit((x)->gch.marked, BLACKBIT)
++#define isgray(x) (!isblack(x) && !iswhite(x))
++
++#define otherwhite(g) (g->currentwhite ^ WHITEBITS)
++#define isdead(g,v) ((v)->gch.marked & otherwhite(g) & WHITEBITS)
++
++#define changewhite(x) ((x)->gch.marked ^= WHITEBITS)
++#define gray2black(x) l_setbit((x)->gch.marked, BLACKBIT)
++
++#define valiswhite(x) (iscollectable(x) && iswhite(gcvalue(x)))
++
++#define luaC_white(g) cast(lu_byte, (g)->currentwhite & WHITEBITS)
++
++
++#define luaC_checkGC(L) { \
++ condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK - 1)); \
++ if (G(L)->totalbytes >= G(L)->GCthreshold) \
++ luaC_step(L); }
++
++
++#define luaC_barrier(L,p,v) { if (valiswhite(v) && isblack(obj2gco(p))) \
++ luaC_barrierf(L,obj2gco(p),gcvalue(v)); }
++
++#define luaC_barriert(L,t,v) { if (valiswhite(v) && isblack(obj2gco(t))) \
++ luaC_barrierback(L,t); }
++
++#define luaC_objbarrier(L,p,o) \
++ { if (iswhite(obj2gco(o)) && isblack(obj2gco(p))) \
++ luaC_barrierf(L,obj2gco(p),obj2gco(o)); }
++
++#define luaC_objbarriert(L,t,o) \
++ { if (iswhite(obj2gco(o)) && isblack(obj2gco(t))) luaC_barrierback(L,t); }
++
++LUAI_FUNC size_t luaC_separateudata (lua_State *L, int all);
++LUAI_FUNC void luaC_callGCTM (lua_State *L);
++LUAI_FUNC void luaC_freeall (lua_State *L);
++LUAI_FUNC void luaC_step (lua_State *L);
++LUAI_FUNC void luaC_fullgc (lua_State *L);
++LUAI_FUNC void luaC_link (lua_State *L, GCObject *o, lu_byte tt);
++LUAI_FUNC void luaC_linkupval (lua_State *L, UpVal *uv);
++LUAI_FUNC void luaC_barrierf (lua_State *L, GCObject *o, GCObject *v);
++LUAI_FUNC void luaC_barrierback (lua_State *L, Table *t);
++
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/llex.c
+@@ -0,0 +1,460 @@
++/*
++** $Id: llex.c,v 2.20.1.1 2007/12/27 13:02:25 roberto Exp $
++** Lexical Analyzer
++** See Copyright Notice in lua.h
++*/
++
++#include <ctype.h>
++#include <locale.h>
++#include <string.h>
++
++#define llex_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "ldo.h"
++#include "llex.h"
++#include "lobject.h"
++#include "lparser.h"
++#include "lstate.h"
++#include "lstring.h"
++#include "ltable.h"
++#include "lzio.h"
++
++
++
++#define next(ls) (ls->current = zgetc(ls->z))
++
++
++
++
++#define currIsNewline(ls) (ls->current == '\n' || ls->current == '\r')
++
++
++/* ORDER RESERVED */
++const char *const luaX_tokens [] = {
++ "and", "break", "do", "else", "elseif",
++ "end", "false", "for", "function", "if",
++ "in", "local", "nil", "not", "or", "repeat",
++ "return", "then", "true", "until", "while",
++ "..", "...", "==", ">=", "<=", "~=",
++ "<number>", "<name>", "<string>", "<eof>",
++ NULL
++};
++
++
++#define save_and_next(ls) (save(ls, ls->current), next(ls))
++
++
++static void save (LexState *ls, int c) {
++ Mbuffer *b = ls->buff;
++ if (b->n + 1 > b->buffsize) {
++ size_t newsize;
++ if (b->buffsize >= MAX_SIZET/2)
++ luaX_lexerror(ls, "lexical element too long", 0);
++ newsize = b->buffsize * 2;
++ luaZ_resizebuffer(ls->L, b, newsize);
++ }
++ b->buffer[b->n++] = cast(char, c);
++}
++
++
++void luaX_init (lua_State *L) {
++ int i;
++ for (i=0; i<NUM_RESERVED; i++) {
++ TString *ts = luaS_new(L, luaX_tokens[i]);
++ luaS_fix(ts); /* reserved words are never collected */
++ lua_assert(strlen(luaX_tokens[i])+1 <= TOKEN_LEN);
++ ts->tsv.reserved = cast_byte(i+1); /* reserved word */
++ }
++}
++
++
++#define MAXSRC 80
++
++
++const char *luaX_token2str (LexState *ls, int token) {
++ if (token < FIRST_RESERVED) {
++ lua_assert(token == cast(unsigned char, token));
++ return (iscntrl(token)) ? luaO_pushfstring(ls->L, "char(%d)", token) :
++ luaO_pushfstring(ls->L, "%c", token);
++ }
++ else
++ return luaX_tokens[token-FIRST_RESERVED];
++}
++
++
++static const char *txtToken (LexState *ls, int token) {
++ switch (token) {
++ case TK_NAME:
++ case TK_STRING:
++ case TK_NUMBER:
++ save(ls, '\0');
++ return luaZ_buffer(ls->buff);
++ default:
++ return luaX_token2str(ls, token);
++ }
++}
++
++
++void luaX_lexerror (LexState *ls, const char *msg, int token) {
++ char buff[MAXSRC];
++ luaO_chunkid(buff, getstr(ls->source), MAXSRC);
++ msg = luaO_pushfstring(ls->L, "%s:%d: %s", buff, ls->linenumber, msg);
++ if (token)
++ luaO_pushfstring(ls->L, "%s near " LUA_QS, msg, txtToken(ls, token));
++ luaD_throw(ls->L, LUA_ERRSYNTAX);
++}
++
++
++void luaX_syntaxerror (LexState *ls, const char *msg) {
++ luaX_lexerror(ls, msg, ls->t.token);
++}
++
++
++TString *luaX_newstring (LexState *ls, const char *str, size_t l) {
++ lua_State *L = ls->L;
++ TString *ts = luaS_newlstr(L, str, l);
++ TValue *o = luaH_setstr(L, ls->fs->h, ts); /* entry for `str' */
++ if (ttisnil(o))
++ setbvalue(o, 1); /* make sure `str' will not be collected */
++ return ts;
++}
++
++
++static void inclinenumber (LexState *ls) {
++ int old = ls->current;
++ lua_assert(currIsNewline(ls));
++ next(ls); /* skip `\n' or `\r' */
++ if (currIsNewline(ls) && ls->current != old)
++ next(ls); /* skip `\n\r' or `\r\n' */
++ if (++ls->linenumber >= MAX_INT)
++ luaX_syntaxerror(ls, "chunk has too many lines");
++}
++
++
++void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, TString *source) {
++ ls->decpoint = '.';
++ ls->L = L;
++ ls->lookahead.token = TK_EOS; /* no look-ahead token */
++ ls->z = z;
++ ls->fs = NULL;
++ ls->linenumber = 1;
++ ls->lastline = 1;
++ ls->source = source;
++ luaZ_resizebuffer(ls->L, ls->buff, LUA_MINBUFFER); /* initialize buffer */
++ next(ls); /* read first char */
++}
++
++
++
++/*
++** =======================================================
++** LEXICAL ANALYZER
++** =======================================================
++*/
++
++
++
++static int check_next (LexState *ls, const char *set) {
++ if (!strchr(set, ls->current))
++ return 0;
++ save_and_next(ls);
++ return 1;
++}
++
++
++static void buffreplace (LexState *ls, char from, char to) {
++ size_t n = luaZ_bufflen(ls->buff);
++ char *p = luaZ_buffer(ls->buff);
++ while (n--)
++ if (p[n] == from) p[n] = to;
++}
++
++
++static void trydecpoint (LexState *ls, SemInfo *seminfo) {
++ /* format error: try to update decimal point separator */
++ char old = ls->decpoint;
++ struct lconv *cv = localeconv();
++ ls->decpoint = (cv ? cv->decimal_point[0] : '.');
++ buffreplace(ls, old, ls->decpoint); /* try updated decimal separator */
++ if (!luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r)) {
++ /* format error with correct decimal point: no more options */
++ buffreplace(ls, ls->decpoint, '.'); /* undo change (for error message) */
++ luaX_lexerror(ls, "malformed number", TK_NUMBER);
++ }
++}
++
++
++/* LUA_NUMBER */
++static void read_numeral (LexState *ls, SemInfo *seminfo) {
++ lua_assert(isdigit(ls->current));
++ do {
++ save_and_next(ls);
++ } while (isdigit(ls->current) || ls->current == '.');
++ if (check_next(ls, "Ee")) /* `E'? */
++ check_next(ls, "+-"); /* optional exponent sign */
++ while (isalnum(ls->current) || ls->current == '_')
++ save_and_next(ls);
++ save(ls, '\0');
++ buffreplace(ls, '.', ls->decpoint); /* follow locale for decimal point */
++ if (!luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r)) /* format error? */
++ trydecpoint(ls, seminfo); /* try to update decimal point separator */
++}
++
++
++static int skip_sep (LexState *ls) {
++ int count = 0;
++ int s = ls->current;
++ lua_assert(s == '[' || s == ']');
++ save_and_next(ls);
++ while (ls->current == '=') {
++ save_and_next(ls);
++ count++;
++ }
++ return (ls->current == s) ? count : (-count) - 1;
++}
++
++
++static void read_long_string (LexState *ls, SemInfo *seminfo, int sep) {
++ int cont = 0;
++ (void)(cont); /* avoid warnings when `cont' is not used */
++ save_and_next(ls); /* skip 2nd `[' */
++ if (currIsNewline(ls)) /* string starts with a newline? */
++ inclinenumber(ls); /* skip it */
++ for (;;) {
++ switch (ls->current) {
++ case EOZ:
++ luaX_lexerror(ls, (seminfo) ? "unfinished long string" :
++ "unfinished long comment", TK_EOS);
++ break; /* to avoid warnings */
++#if defined(LUA_COMPAT_LSTR)
++ case '[': {
++ if (skip_sep(ls) == sep) {
++ save_and_next(ls); /* skip 2nd `[' */
++ cont++;
++#if LUA_COMPAT_LSTR == 1
++ if (sep == 0)
++ luaX_lexerror(ls, "nesting of [[...]] is deprecated", '[');
++#endif
++ }
++ break;
++ }
++#endif
++ case ']': {
++ if (skip_sep(ls) == sep) {
++ save_and_next(ls); /* skip 2nd `]' */
++#if defined(LUA_COMPAT_LSTR) && LUA_COMPAT_LSTR == 2
++ cont--;
++ if (sep == 0 && cont >= 0) break;
++#endif
++ goto endloop;
++ }
++ break;
++ }
++ case '\n':
++ case '\r': {
++ save(ls, '\n');
++ inclinenumber(ls);
++ if (!seminfo) luaZ_resetbuffer(ls->buff); /* avoid wasting space */
++ break;
++ }
++ default: {
++ if (seminfo) save_and_next(ls);
++ else next(ls);
++ }
++ }
++ } endloop:
++ if (seminfo)
++ seminfo->ts = luaX_newstring(ls, luaZ_buffer(ls->buff) + (2 + sep),
++ luaZ_bufflen(ls->buff) - 2*(2 + sep));
++}
++
++
++static void read_string (LexState *ls, int del, SemInfo *seminfo) {
++ save_and_next(ls);
++ while (ls->current != del) {
++ switch (ls->current) {
++ case EOZ:
++ luaX_lexerror(ls, "unfinished string", TK_EOS);
++ continue; /* to avoid warnings */
++ case '\n':
++ case '\r':
++ luaX_lexerror(ls, "unfinished string", TK_STRING);
++ continue; /* to avoid warnings */
++ case '\\': {
++ int c;
++ next(ls); /* do not save the `\' */
++ switch (ls->current) {
++ case 'a': c = '\a'; break;
++ case 'b': c = '\b'; break;
++ case 'f': c = '\f'; break;
++ case 'n': c = '\n'; break;
++ case 'r': c = '\r'; break;
++ case 't': c = '\t'; break;
++ case 'v': c = '\v'; break;
++ case '\n': /* go through */
++ case '\r': save(ls, '\n'); inclinenumber(ls); continue;
++ case EOZ: continue; /* will raise an error next loop */
++ default: {
++ if (!isdigit(ls->current))
++ save_and_next(ls); /* handles \\, \", \', and \? */
++ else { /* \xxx */
++ int i = 0;
++ c = 0;
++ do {
++ c = 10*c + (ls->current-'0');
++ next(ls);
++ } while (++i<3 && isdigit(ls->current));
++ if (c > UCHAR_MAX)
++ luaX_lexerror(ls, "escape sequence too large", TK_STRING);
++ save(ls, c);
++ }
++ continue;
++ }
++ }
++ save(ls, c);
++ next(ls);
++ continue;
++ }
++ default:
++ save_and_next(ls);
++ }
++ }
++ save_and_next(ls); /* skip delimiter */
++ seminfo->ts = luaX_newstring(ls, luaZ_buffer(ls->buff) + 1,
++ luaZ_bufflen(ls->buff) - 2);
++}
++
++
++static int llex (LexState *ls, SemInfo *seminfo) {
++ luaZ_resetbuffer(ls->buff);
++ for (;;) {
++ switch (ls->current) {
++ case '\n':
++ case '\r': {
++ inclinenumber(ls);
++ continue;
++ }
++ case '-': {
++ next(ls);
++ if (ls->current != '-') return '-';
++ /* else is a comment */
++ next(ls);
++ if (ls->current == '[') {
++ int sep = skip_sep(ls);
++ luaZ_resetbuffer(ls->buff); /* `skip_sep' may dirty the buffer */
++ if (sep >= 0) {
++ read_long_string(ls, NULL, sep); /* long comment */
++ luaZ_resetbuffer(ls->buff);
++ continue;
++ }
++ }
++ /* else short comment */
++ while (!currIsNewline(ls) && ls->current != EOZ)
++ next(ls);
++ continue;
++ }
++ case '[': {
++ int sep = skip_sep(ls);
++ if (sep >= 0) {
++ read_long_string(ls, seminfo, sep);
++ return TK_STRING;
++ }
++ else if (sep == -1) return '[';
++ else luaX_lexerror(ls, "invalid long string delimiter", TK_STRING);
++ }
++ case '=': {
++ next(ls);
++ if (ls->current != '=') return '=';
++ else { next(ls); return TK_EQ; }
++ }
++ case '<': {
++ next(ls);
++ if (ls->current != '=') return '<';
++ else { next(ls); return TK_LE; }
++ }
++ case '>': {
++ next(ls);
++ if (ls->current != '=') return '>';
++ else { next(ls); return TK_GE; }
++ }
++ case '~': {
++ next(ls);
++ if (ls->current != '=') return '~';
++ else { next(ls); return TK_NE; }
++ }
++ case '"':
++ case '\'': {
++ read_string(ls, ls->current, seminfo);
++ return TK_STRING;
++ }
++ case '.': {
++ save_and_next(ls);
++ if (check_next(ls, ".")) {
++ if (check_next(ls, "."))
++ return TK_DOTS; /* ... */
++ else return TK_CONCAT; /* .. */
++ }
++ else if (!isdigit(ls->current)) return '.';
++ else {
++ read_numeral(ls, seminfo);
++ return TK_NUMBER;
++ }
++ }
++ case EOZ: {
++ return TK_EOS;
++ }
++ default: {
++ if (isspace(ls->current)) {
++ lua_assert(!currIsNewline(ls));
++ next(ls);
++ continue;
++ }
++ else if (isdigit(ls->current)) {
++ read_numeral(ls, seminfo);
++ return TK_NUMBER;
++ }
++ else if (isalpha(ls->current) || ls->current == '_') {
++ /* identifier or reserved word */
++ TString *ts;
++ do {
++ save_and_next(ls);
++ } while (isalnum(ls->current) || ls->current == '_');
++ ts = luaX_newstring(ls, luaZ_buffer(ls->buff),
++ luaZ_bufflen(ls->buff));
++ if (ts->tsv.reserved > 0) /* reserved word? */
++ return ts->tsv.reserved - 1 + FIRST_RESERVED;
++ else {
++ seminfo->ts = ts;
++ return TK_NAME;
++ }
++ }
++ else {
++ int c = ls->current;
++ next(ls);
++ return c; /* single-char tokens (+ - / ...) */
++ }
++ }
++ }
++ }
++}
++
++
++void luaX_next (LexState *ls) {
++ ls->lastline = ls->linenumber;
++ if (ls->lookahead.token != TK_EOS) { /* is there a look-ahead token? */
++ ls->t = ls->lookahead; /* use this one */
++ ls->lookahead.token = TK_EOS; /* and discharge it */
++ }
++ else
++ ls->t.token = llex(ls, &ls->t.seminfo); /* read next token */
++}
++
++
++void luaX_lookahead (LexState *ls) {
++ lua_assert(ls->lookahead.token == TK_EOS);
++ ls->lookahead.token = llex(ls, &ls->lookahead.seminfo);
++}
++
+--- /dev/null
++++ b/extensions/LUA/lua/llex.h
+@@ -0,0 +1,81 @@
++/*
++** $Id: llex.h,v 1.58.1.1 2007/12/27 13:02:25 roberto Exp $
++** Lexical Analyzer
++** See Copyright Notice in lua.h
++*/
++
++#ifndef llex_h
++#define llex_h
++
++#include "lobject.h"
++#include "lzio.h"
++
++
++#define FIRST_RESERVED 257
++
++/* maximum length of a reserved word */
++#define TOKEN_LEN (sizeof("function")/sizeof(char))
++
++
++/*
++* WARNING: if you change the order of this enumeration,
++* grep "ORDER RESERVED"
++*/
++enum RESERVED {
++ /* terminal symbols denoted by reserved words */
++ TK_AND = FIRST_RESERVED, TK_BREAK,
++ TK_DO, TK_ELSE, TK_ELSEIF, TK_END, TK_FALSE, TK_FOR, TK_FUNCTION,
++ TK_IF, TK_IN, TK_LOCAL, TK_NIL, TK_NOT, TK_OR, TK_REPEAT,
++ TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE,
++ /* other terminal symbols */
++ TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, TK_NUMBER,
++ TK_NAME, TK_STRING, TK_EOS
++};
++
++/* number of reserved words */
++#define NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1))
++
++
++/* array with token `names' */
++LUAI_DATA const char *const luaX_tokens [];
++
++
++typedef union {
++ lua_Number r;
++ TString *ts;
++} SemInfo; /* semantics information */
++
++
++typedef struct Token {
++ int token;
++ SemInfo seminfo;
++} Token;
++
++
++typedef struct LexState {
++ int current; /* current character (charint) */
++ int linenumber; /* input line counter */
++ int lastline; /* line of last token `consumed' */
++ Token t; /* current token */
++ Token lookahead; /* look ahead token */
++ struct FuncState *fs; /* `FuncState' is private to the parser */
++ struct lua_State *L;
++ ZIO *z; /* input stream */
++ Mbuffer *buff; /* buffer for tokens */
++ TString *source; /* current source name */
++ char decpoint; /* locale decimal point */
++} LexState;
++
++
++LUAI_FUNC void luaX_init (lua_State *L);
++LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z,
++ TString *source);
++LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l);
++LUAI_FUNC void luaX_next (LexState *ls);
++LUAI_FUNC void luaX_lookahead (LexState *ls);
++LUAI_FUNC void luaX_lexerror (LexState *ls, const char *msg, int token);
++LUAI_FUNC void luaX_syntaxerror (LexState *ls, const char *s);
++LUAI_FUNC const char *luaX_token2str (LexState *ls, int token);
++
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/llimits.h
+@@ -0,0 +1,125 @@
++/*
++** $Id: llimits.h,v 1.69.1.1 2007/12/27 13:02:25 roberto Exp $
++** Limits, basic types, and some other `installation-dependent' definitions
++** See Copyright Notice in lua.h
++*/
++
++#ifndef llimits_h
++#define llimits_h
++
++#include <stddef.h>
++#include <limits.h>
++
++#include "lua.h"
++
++typedef LUAI_UINT32 lu_int32;
++
++typedef LUAI_UMEM lu_mem;
++
++typedef LUAI_MEM l_mem;
++
++
++
++/* chars used as small naturals (so that `char' is reserved for characters) */
++typedef unsigned char lu_byte;
++
++
++#define MAX_SIZET ((size_t)(~(size_t)0)-2)
++
++#define MAX_LUMEM ((lu_mem)(~(lu_mem)0)-2)
++
++
++#define MAX_INT (LUA_INT_MAX-2) /* maximum value of an int (-2 for safety) */
++
++/*
++** conversion of pointer to integer
++** this is for hashing only; there is no problem if the integer
++** cannot hold the whole pointer value
++*/
++#define IntPoint(p) ((unsigned int)(lu_mem)(p))
++
++
++
++/* type to ensure maximum alignment */
++typedef LUAI_USER_ALIGNMENT_T L_Umaxalign;
++
++
++/* result of a `usual argument conversion' over lua_Number */
++typedef LUAI_UACNUMBER l_uacNumber;
++
++
++/* internal assertions for in-house debugging */
++#ifdef lua_assert
++
++#define check_exp(c,e) (lua_assert(c), (e))
++#define api_check(l,e) lua_assert(e)
++
++#else
++
++#define lua_assert(c) ((void)0)
++#define check_exp(c,e) (e)
++#define api_check luai_apicheck
++
++#endif
++
++
++#ifndef UNUSED
++#define UNUSED(x) ((void)(x)) /* to avoid warnings */
++#endif
++
++
++#ifndef cast
++#define cast(t, exp) ((t)(exp))
++#endif
++
++#define cast_byte(i) cast(lu_byte, (i))
++#define cast_num(i) cast(lua_Number, (i))
++#define cast_int(i) cast(int, (i))
++
++
++
++/*
++** type for virtual-machine instructions
++** must be an unsigned with (at least) 4 bytes (see details in lopcodes.h)
++*/
++typedef lu_int32 Instruction;
++
++
++
++/* maximum stack for a Lua function */
++#define MAXSTACK 250
++
++
++
++/* minimum size for the string table (must be power of 2) */
++#ifndef MINSTRTABSIZE
++#define MINSTRTABSIZE 32
++#endif
++
++
++/* minimum size for string buffer */
++#ifndef LUA_MINBUFFER
++#define LUA_MINBUFFER 32
++#endif
++
++
++#ifndef lua_lock
++#define lua_lock(L) ((void) 0)
++#define lua_unlock(L) ((void) 0)
++#endif
++
++#ifndef luai_threadyield
++#define luai_threadyield(L) {lua_unlock(L); lua_lock(L);}
++#endif
++
++
++/*
++** macro to control inclusion of some hard tests on stack reallocation
++*/
++#ifndef HARDSTACKTESTS
++#define condhardstacktests(x) ((void)0)
++#else
++#define condhardstacktests(x) x
++#endif
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/lmem.c
+@@ -0,0 +1,86 @@
++/*
++** $Id: lmem.c,v 1.70.1.1 2007/12/27 13:02:25 roberto Exp $
++** Interface to Memory Manager
++** See Copyright Notice in lua.h
++*/
++
++
++#include <stddef.h>
++
++#define lmem_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "ldebug.h"
++#include "ldo.h"
++#include "lmem.h"
++#include "lobject.h"
++#include "lstate.h"
++
++
++
++/*
++** About the realloc function:
++** void * frealloc (void *ud, void *ptr, size_t osize, size_t nsize);
++** (`osize' is the old size, `nsize' is the new size)
++**
++** Lua ensures that (ptr == NULL) iff (osize == 0).
++**
++** * frealloc(ud, NULL, 0, x) creates a new block of size `x'
++**
++** * frealloc(ud, p, x, 0) frees the block `p'
++** (in this specific case, frealloc must return NULL).
++** particularly, frealloc(ud, NULL, 0, 0) does nothing
++** (which is equivalent to free(NULL) in ANSI C)
++**
++** frealloc returns NULL if it cannot create or reallocate the area
++** (any reallocation to an equal or smaller size cannot fail!)
++*/
++
++
++
++#define MINSIZEARRAY 4
++
++
++void *luaM_growaux_ (lua_State *L, void *block, int *size, size_t size_elems,
++ int limit, const char *errormsg) {
++ void *newblock;
++ int newsize;
++ if (*size >= limit/2) { /* cannot double it? */
++ if (*size >= limit) /* cannot grow even a little? */
++ luaG_runerror(L, errormsg);
++ newsize = limit; /* still have at least one free place */
++ }
++ else {
++ newsize = (*size)*2;
++ if (newsize < MINSIZEARRAY)
++ newsize = MINSIZEARRAY; /* minimum size */
++ }
++ newblock = luaM_reallocv(L, block, *size, newsize, size_elems);
++ *size = newsize; /* update only when everything else is OK */
++ return newblock;
++}
++
++
++void *luaM_toobig (lua_State *L) {
++ luaG_runerror(L, "memory allocation error: block too big");
++ return NULL; /* to avoid warnings */
++}
++
++
++
++/*
++** generic allocation routine.
++*/
++void *luaM_realloc_ (lua_State *L, void *block, size_t osize, size_t nsize) {
++ global_State *g = G(L);
++ lua_assert((osize == 0) == (block == NULL));
++ block = (*g->frealloc)(g->ud, block, osize, nsize);
++ if (block == NULL && nsize > 0)
++ luaD_throw(L, LUA_ERRMEM);
++ lua_assert((nsize == 0) == (block == NULL));
++ g->totalbytes = (g->totalbytes - osize) + nsize;
++ return block;
++}
++
+--- /dev/null
++++ b/extensions/LUA/lua/lmem.h
+@@ -0,0 +1,49 @@
++/*
++** $Id: lmem.h,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $
++** Interface to Memory Manager
++** See Copyright Notice in lua.h
++*/
++
++#ifndef lmem_h
++#define lmem_h
++
++
++#include <stddef.h>
++
++#include "llimits.h"
++#include "lua.h"
++
++#define MEMERRMSG "not enough memory"
++
++
++#define luaM_reallocv(L,b,on,n,e) \
++ ((cast(size_t, (n)+1) <= MAX_SIZET/(e)) ? /* +1 to avoid warnings */ \
++ luaM_realloc_(L, (b), (on)*(e), (n)*(e)) : \
++ luaM_toobig(L))
++
++#define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0)
++#define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0)
++#define luaM_freearray(L, b, n, t) luaM_reallocv(L, (b), n, 0, sizeof(t))
++
++#define luaM_malloc(L,t) luaM_realloc_(L, NULL, 0, (t))
++#define luaM_new(L,t) cast(t *, luaM_malloc(L, sizeof(t)))
++#define luaM_newvector(L,n,t) \
++ cast(t *, luaM_reallocv(L, NULL, 0, n, sizeof(t)))
++
++#define luaM_growvector(L,v,nelems,size,t,limit,e) \
++ if ((nelems)+1 > (size)) \
++ ((v)=cast(t *, luaM_growaux_(L,v,&(size),sizeof(t),limit,e)))
++
++#define luaM_reallocvector(L, v,oldn,n,t) \
++ ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t))))
++
++
++LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize,
++ size_t size);
++LUAI_FUNC void *luaM_toobig (lua_State *L);
++LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size,
++ size_t size_elem, int limit,
++ const char *errormsg);
++
++#endif
++
+--- /dev/null
++++ b/extensions/LUA/lua/lobject.c
+@@ -0,0 +1,215 @@
++/*
++** $Id: lobject.c,v 2.22.1.1 2007/12/27 13:02:25 roberto Exp $
++** Some generic functions over Lua objects
++** See Copyright Notice in lua.h
++*/
++
++#include <stdarg.h>
++
++#include <ctype.h>
++#include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
++
++#define lobject_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "ldo.h"
++#include "lmem.h"
++#include "lobject.h"
++#include "lstate.h"
++#include "lstring.h"
++#include "lvm.h"
++
++
++
++const TValue luaO_nilobject_ = {{NULL}, LUA_TNIL};
++
++
++/*
++** converts an integer to a "floating point byte", represented as
++** (eeeeexxx), where the real value is (1xxx) * 2^(eeeee - 1) if
++** eeeee != 0 and (xxx) otherwise.
++*/
++int luaO_int2fb (unsigned int x) {
++ int e = 0; /* expoent */
++ while (x >= 16) {
++ x = (x+1) >> 1;
++ e++;
++ }
++ if (x < 8) return x;
++ else return ((e+1) << 3) | (cast_int(x) - 8);
++}
++
++
++/* converts back */
++int luaO_fb2int (int x) {
++ int e = (x >> 3) & 31;
++ if (e == 0) return x;
++ else return ((x & 7)+8) << (e - 1);
++}
++
++
++int luaO_log2 (unsigned int x) {
++ static const lu_byte log_2[256] = {
++ 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
++ 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
++ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
++ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
++ 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
++ 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
++ 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
++ 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8
++ };
++ int l = -1;
++ while (x >= 256) { l += 8; x >>= 8; }
++ return l + log_2[x];
++
++}
++
++
++int luaO_rawequalObj (const TValue *t1, const TValue *t2) {
++ if (ttype(t1) != ttype(t2)) return 0;
++ else switch (ttype(t1)) {
++ case LUA_TNIL:
++ return 1;
++ case LUA_TNUMBER:
++ return luai_numeq(nvalue(t1), nvalue(t2));
++ case LUA_TBOOLEAN:
++ return bvalue(t1) == bvalue(t2); /* boolean true must be 1 !! */
++ case LUA_TLIGHTUSERDATA:
++ return pvalue(t1) == pvalue(t2);
++ default:
++ lua_assert(iscollectable(t1));
++ return gcvalue(t1) == gcvalue(t2);
++ }
++}
++
++
++int luaO_str2d (const char *s, lua_Number *result) {
++ char *endptr;
++ *result = lua_str2number(s, &endptr);
++ if (endptr == s) return 0; /* conversion failed */
++ if (*endptr == 'x' || *endptr == 'X') /* maybe an hexadecimal constant? */
++ *result = cast_num(strtoul(s, &endptr, 16));
++ if (*endptr == '\0') return 1; /* most common case */
++ while (isspace(cast(unsigned char, *endptr))) endptr++;
++ if (*endptr != '\0') return 0; /* invalid trailing characters? */
++ return 1;
++}
++
++
++
++static void pushstr (lua_State *L, const char *str) {
++ setsvalue2s(L, L->top, luaS_new(L, str));
++ incr_top(L);
++}
++
++
++/* this function handles only `%d', `%c', %f, %p, and `%s' formats */
++const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) {
++ int n = 1;
++ pushstr(L, "");
++ for (;;) {
++ const char *e = strchr(fmt, '%');
++ if (e == NULL) break;
++ setsvalue2s(L, L->top, luaS_newlstr(L, fmt, e-fmt));
++ incr_top(L);
++ switch (*(e+1)) {
++ case 's': {
++ const char *s = va_arg(argp, char *);
++ if (s == NULL) s = "(null)";
++ pushstr(L, s);
++ break;
++ }
++ case 'c': {
++ char buff[2];
++ buff[0] = cast(char, va_arg(argp, int));
++ buff[1] = '\0';
++ pushstr(L, buff);
++ break;
++ }
++ case 'd': {
++ setnvalue(L->top, cast_num(va_arg(argp, int)));
++ incr_top(L);
++ break;
++ }
++ case 'f': {
++ setnvalue(L->top, cast_num(va_arg(argp, l_uacNumber)));
++ incr_top(L);
++ break;
++ }
++ case 'p': {
++ char buff[4*sizeof(void *) + 8]; /* should be enough space for a `%p' */
++ sprintf(buff, "%p", va_arg(argp, void *));
++ pushstr(L, buff);
++ break;
++ }
++ case '%': {
++ pushstr(L, "%");
++ break;
++ }
++ default: {
++ char buff[3];
++ buff[0] = '%';
++ buff[1] = *(e+1);
++ buff[2] = '\0';
++ pushstr(L, buff);
++ break;
++ }
++ }
++ n += 2;
++ fmt = e+2;
++ }
++ pushstr(L, fmt);
++ luaV_concat(L, n+1, cast_int(L->top - L->base) - 1);
++ L->top -= n;
++ return svalue(L->top - 1);
++}
++
++
++const char *luaO_pushfstring (lua_State *L, const char *fmt, ...) {
++ const char *msg;
++ va_list argp;
++ va_start(argp, fmt);
++ msg = luaO_pushvfstring(L, fmt, argp);
++ va_end(argp);
++ return msg;
++}
++
++
++void luaO_chunkid (char *out, const char *source, size_t bufflen) {
++ if (*source == '=') {
++ strncpy(out, source+1, bufflen); /* remove first char */
++ out[bufflen-1] = '\0'; /* ensures null termination */
++ }
++ else { /* out = "source", or "...source" */
++ if (*source == '@') {
++ size_t l;
++ source++; /* skip the `@' */
++ bufflen -= sizeof(" '...' ");
++ l = strlen(source);
++ strcpy(out, "");
++ if (l > bufflen) {
++ source += (l-bufflen); /* get last part of file name */
++ strcat(out, "...");
++ }
++ strcat(out, source);
++ }
++ else { /* out = [string "string"] */
++ size_t len = strcspn(source, "\n\r"); /* stop at first newline */
++ bufflen -= sizeof(" [string \"...\"] ");
++ if (len > bufflen) len = bufflen;
++ strcpy(out, "[string \"");
++ if (source[len] != '\0') { /* must truncate? */
++ strncat(out, source, len);
++ strcat(out, "...");
++ }
++ else
++ strcat(out, source);
++ strcat(out, "\"]");
++ }
++ }
++}
+--- /dev/null
++++ b/extensions/LUA/lua/lobject.h
+@@ -0,0 +1,381 @@
++/*
++** $Id: lobject.h,v 2.20.1.2 2008/08/06 13:29:48 roberto Exp $
++** Type definitions for Lua objects
++** See Copyright Notice in lua.h
++*/
++
++
++#ifndef lobject_h
++#define lobject_h
++
++
++#include <stdarg.h>
++
++
++#include "llimits.h"
++#include "lua.h"
++
++
++/* tags for values visible from Lua */
++#define LAST_TAG LUA_TTHREAD
++
++#define NUM_TAGS (LAST_TAG+1)
++
++
++/*
++** Extra tags for non-values
++*/
++#define LUA_TPROTO (LAST_TAG+1)
++#define LUA_TUPVAL (LAST_TAG+2)
++#define LUA_TDEADKEY (LAST_TAG+3)
++
++
++/*
++** Union of all collectable objects
++*/
++typedef union GCObject GCObject;
++
++
++/*
++** Common Header for all collectable objects (in macro form, to be
++** included in other objects)
++*/
++#define CommonHeader GCObject *next; lu_byte tt; lu_byte marked
++
++
++/*
++** Common header in struct form
++*/
++typedef struct GCheader {
++ CommonHeader;
++} GCheader;
++
++
++
++
++/*
++** Union of all Lua values
++*/
++typedef union {
++ GCObject *gc;
++ void *p;
++ lua_Number n;
++ int b;
++} Value;
++
++
++/*
++** Tagged Values
++*/
++
++#define TValuefields Value value; int tt
++
++typedef struct lua_TValue {
++ TValuefields;
++} TValue;
++
++
++/* Macros to test type */
++#define ttisnil(o) (ttype(o) == LUA_TNIL)
++#define ttisnumber(o) (ttype(o) == LUA_TNUMBER)
++#define ttisstring(o) (ttype(o) == LUA_TSTRING)
++#define ttistable(o) (ttype(o) == LUA_TTABLE)
++#define ttisfunction(o) (ttype(o) == LUA_TFUNCTION)
++#define ttisboolean(o) (ttype(o) == LUA_TBOOLEAN)
++#define ttisuserdata(o) (ttype(o) == LUA_TUSERDATA)
++#define ttisthread(o) (ttype(o) == LUA_TTHREAD)
++#define ttislightuserdata(o) (ttype(o) == LUA_TLIGHTUSERDATA)
++
++/* Macros to access values */
++#define ttype(o) ((o)->tt)
++#define gcvalue(o) check_exp(iscollectable(o), (o)->value.gc)
++#define pvalue(o) check_exp(ttislightuserdata(o), (o)->value.p)
++#define nvalue(o) check_exp(ttisnumber(o), (o)->value.n)
++#define rawtsvalue(o) check_exp(ttisstring(o), &(o)->value.gc->ts)
++#define tsvalue(o) (&rawtsvalue(o)->tsv)
++#define rawuvalue(o) check_exp(ttisuserdata(o), &(o)->value.gc->u)
++#define uvalue(o) (&rawuvalue(o)->uv)
++#define clvalue(o) check_exp(ttisfunction(o), &(o)->value.gc->cl)
++#define hvalue(o) check_exp(ttistable(o), &(o)->value.gc->h)
++#define bvalue(o) check_exp(ttisboolean(o), (o)->value.b)
++#define thvalue(o) check_exp(ttisthread(o), &(o)->value.gc->th)
++
++#define l_isfalse(o) (ttisnil(o) || (ttisboolean(o) && bvalue(o) == 0))
++
++/*
++** for internal debug only
++*/
++#define checkconsistency(obj) \
++ lua_assert(!iscollectable(obj) || (ttype(obj) == (obj)->value.gc->gch.tt))
++
++#define checkliveness(g,obj) \
++ lua_assert(!iscollectable(obj) || \
++ ((ttype(obj) == (obj)->value.gc->gch.tt) && !isdead(g, (obj)->value.gc)))
++
++
++/* Macros to set values */
++#define setnilvalue(obj) ((obj)->tt=LUA_TNIL)
++
++#define setnvalue(obj,x) \
++ { TValue *i_o=(obj); i_o->value.n=(x); i_o->tt=LUA_TNUMBER; }
++
++#define setpvalue(obj,x) \
++ { TValue *i_o=(obj); i_o->value.p=(x); i_o->tt=LUA_TLIGHTUSERDATA; }
++
++#define setbvalue(obj,x) \
++ { TValue *i_o=(obj); i_o->value.b=(x); i_o->tt=LUA_TBOOLEAN; }
++
++#define setsvalue(L,obj,x) \
++ { TValue *i_o=(obj); \
++ i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TSTRING; \
++ checkliveness(G(L),i_o); }
++
++#define setuvalue(L,obj,x) \
++ { TValue *i_o=(obj); \
++ i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TUSERDATA; \
++ checkliveness(G(L),i_o); }
++
++#define setthvalue(L,obj,x) \
++ { TValue *i_o=(obj); \
++ i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TTHREAD; \
++ checkliveness(G(L),i_o); }
++
++#define setclvalue(L,obj,x) \
++ { TValue *i_o=(obj); \
++ i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TFUNCTION; \
++ checkliveness(G(L),i_o); }
++
++#define sethvalue(L,obj,x) \
++ { TValue *i_o=(obj); \
++ i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TTABLE; \
++ checkliveness(G(L),i_o); }
++
++#define setptvalue(L,obj,x) \
++ { TValue *i_o=(obj); \
++ i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TPROTO; \
++ checkliveness(G(L),i_o); }
++
++
++
++
++#define setobj(L,obj1,obj2) \
++ { const TValue *o2=(obj2); TValue *o1=(obj1); \
++ o1->value = o2->value; o1->tt=o2->tt; \
++ checkliveness(G(L),o1); }
++
++
++/*
++** different types of sets, according to destination
++*/
++
++/* from stack to (same) stack */
++#define setobjs2s setobj
++/* to stack (not from same stack) */
++#define setobj2s setobj
++#define setsvalue2s setsvalue
++#define sethvalue2s sethvalue
++#define setptvalue2s setptvalue
++/* from table to same table */
++#define setobjt2t setobj
++/* to table */
++#define setobj2t setobj
++/* to new object */
++#define setobj2n setobj
++#define setsvalue2n setsvalue
++
++#define setttype(obj, tt) (ttype(obj) = (tt))
++
++
++#define iscollectable(o) (ttype(o) >= LUA_TSTRING)
++
++
++
++typedef TValue *StkId; /* index to stack elements */
++
++
++/*
++** String headers for string table
++*/
++typedef union TString {
++ L_Umaxalign dummy; /* ensures maximum alignment for strings */
++ struct {
++ CommonHeader;
++ lu_byte reserved;
++ unsigned int hash;
++ size_t len;
++ } tsv;
++} TString;
++
++
++#define getstr(ts) cast(const char *, (ts) + 1)
++#define svalue(o) getstr(rawtsvalue(o))
++
++
++
++typedef union Udata {
++ L_Umaxalign dummy; /* ensures maximum alignment for `local' udata */
++ struct {
++ CommonHeader;
++ struct Table *metatable;
++ struct Table *env;
++ size_t len;
++ } uv;
++} Udata;
++
++
++
++
++/*
++** Function Prototypes
++*/
++typedef struct Proto {
++ CommonHeader;
++ TValue *k; /* constants used by the function */
++ Instruction *code;
++ struct Proto **p; /* functions defined inside the function */
++ int *lineinfo; /* map from opcodes to source lines */
++ struct LocVar *locvars; /* information about local variables */
++ TString **upvalues; /* upvalue names */
++ TString *source;
++ int sizeupvalues;
++ int sizek; /* size of `k' */
++ int sizecode;
++ int sizelineinfo;
++ int sizep; /* size of `p' */
++ int sizelocvars;
++ int linedefined;
++ int lastlinedefined;
++ GCObject *gclist;
++ lu_byte nups; /* number of upvalues */
++ lu_byte numparams;
++ lu_byte is_vararg;
++ lu_byte maxstacksize;
++} Proto;
++
++
++/* masks for new-style vararg */
++#define VARARG_HASARG 1
++#define VARARG_ISVARARG 2
++#define VARARG_NEEDSARG 4
++
++
++typedef struct LocVar {
++ TString *varname;
++ int startpc; /* first point where variable is active */
++ int endpc; /* first point where variable is dead */
++} LocVar;
++
++
++
++/*
++** Upvalues
++*/
++
++typedef struct UpVal {
++ CommonHeader;
++ TValue *v; /* points to stack or to its own value */
++ union {
++ TValue value; /* the value (when closed) */
++ struct { /* double linked list (when open) */
++ struct UpVal *prev;
++ struct UpVal *next;
++ } l;
++ } u;
++} UpVal;
++
++
++/*
++** Closures
++*/
++
++#define ClosureHeader \
++ CommonHeader; lu_byte isC; lu_byte nupvalues; GCObject *gclist; \
++ struct Table *env
++
++typedef struct CClosure {
++ ClosureHeader;
++ lua_CFunction f;
++ TValue upvalue[1];
++} CClosure;
++
++
++typedef struct LClosure {
++ ClosureHeader;
++ struct Proto *p;
++ UpVal *upvals[1];
++} LClosure;
++
++
++typedef union Closure {
++ CClosure c;
++ LClosure l;
++} Closure;
++
++
++#define iscfunction(o) (ttype(o) == LUA_TFUNCTION && clvalue(o)->c.isC)
++#define isLfunction(o) (ttype(o) == LUA_TFUNCTION && !clvalue(o)->c.isC)
++
++
++/*
++** Tables
++*/
++
++typedef union TKey {
++ struct {
++ TValuefields;
++ struct Node *next; /* for chaining */
++ } nk;
++ TValue tvk;
++} TKey;
++
++
++typedef struct Node {
++ TValue i_val;
++ TKey i_key;
++} Node;
++
++
++typedef struct Table {
++ CommonHeader;
++ lu_byte flags; /* 1<<p means tagmethod(p) is not present */
++ lu_byte lsizenode; /* log2 of size of `node' array */
++ struct Table *metatable;
++ TValue *array; /* array part */
++ Node *node;
++ Node *lastfree; /* any free position is before this position */
++ GCObject *gclist;
++ int sizearray; /* size of `array' array */
++} Table;
++
++
++
++/*
++** `module' operation for hashing (size is always a power of 2)
++*/
++#define lmod(s,size) \
++ (check_exp((size&(size-1))==0, (cast(int, (s) & ((size)-1)))))
++
++
++#define twoto(x) (1<<(x))
++#define sizenode(t) (twoto((t)->lsizenode))
++
++
++#define luaO_nilobject (&luaO_nilobject_)
++
++LUAI_DATA const TValue luaO_nilobject_;
++
++#define ceillog2(x) (luaO_log2((x)-1) + 1)
++
++LUAI_FUNC int luaO_log2 (unsigned int x);
++LUAI_FUNC int luaO_int2fb (unsigned int x);
++LUAI_FUNC int luaO_fb2int (int x);
++LUAI_FUNC int luaO_rawequalObj (const TValue *t1, const TValue *t2);
++LUAI_FUNC int luaO_str2d (const char *s, lua_Number *result);
++LUAI_FUNC const char *luaO_pushvfstring (lua_State *L, const char *fmt,
++ va_list argp);
++LUAI_FUNC const char *luaO_pushfstring (lua_State *L, const char *fmt, ...);
++LUAI_FUNC void luaO_chunkid (char *out, const char *source, size_t len);
++
++
++#endif
++
+--- /dev/null
++++ b/extensions/LUA/lua/lopcodes.c
+@@ -0,0 +1,102 @@
++/*
++** $Id: lopcodes.c,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $
++** See Copyright Notice in lua.h
++*/
++
++
++#define lopcodes_c
++#define LUA_CORE
++
++
++#include "lopcodes.h"
++
++
++/* ORDER OP */
++
++const char *const luaP_opnames[NUM_OPCODES+1] = {
++ "MOVE",
++ "LOADK",
++ "LOADBOOL",
++ "LOADNIL",
++ "GETUPVAL",
++ "GETGLOBAL",
++ "GETTABLE",
++ "SETGLOBAL",
++ "SETUPVAL",
++ "SETTABLE",
++ "NEWTABLE",
++ "SELF",
++ "ADD",
++ "SUB",
++ "MUL",
++ "DIV",
++ "MOD",
++ "POW",
++ "UNM",
++ "NOT",
++ "LEN",
++ "CONCAT",
++ "JMP",
++ "EQ",
++ "LT",
++ "LE",
++ "TEST",
++ "TESTSET",
++ "CALL",
++ "TAILCALL",
++ "RETURN",
++ "FORLOOP",
++ "FORPREP",
++ "TFORLOOP",
++ "SETLIST",
++ "CLOSE",
++ "CLOSURE",
++ "VARARG",
++ NULL
++};
++
++
++#define opmode(t,a,b,c,m) (((t)<<7) | ((a)<<6) | ((b)<<4) | ((c)<<2) | (m))
++
++const lu_byte luaP_opmodes[NUM_OPCODES] = {
++/* T A B C mode opcode */
++ opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_MOVE */
++ ,opmode(0, 1, OpArgK, OpArgN, iABx) /* OP_LOADK */
++ ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_LOADBOOL */
++ ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_LOADNIL */
++ ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_GETUPVAL */
++ ,opmode(0, 1, OpArgK, OpArgN, iABx) /* OP_GETGLOBAL */
++ ,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_GETTABLE */
++ ,opmode(0, 0, OpArgK, OpArgN, iABx) /* OP_SETGLOBAL */
++ ,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_SETUPVAL */
++ ,opmode(0, 0, OpArgK, OpArgK, iABC) /* OP_SETTABLE */
++ ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_NEWTABLE */
++ ,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_SELF */
++ ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_ADD */
++ ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_SUB */
++ ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MUL */
++ ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_DIV */
++ ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MOD */
++ ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_POW */
++ ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_UNM */
++ ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_NOT */
++ ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_LEN */
++ ,opmode(0, 1, OpArgR, OpArgR, iABC) /* OP_CONCAT */
++ ,opmode(0, 0, OpArgR, OpArgN, iAsBx) /* OP_JMP */
++ ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_EQ */
++ ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LT */
++ ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LE */
++ ,opmode(1, 1, OpArgR, OpArgU, iABC) /* OP_TEST */
++ ,opmode(1, 1, OpArgR, OpArgU, iABC) /* OP_TESTSET */
++ ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_CALL */
++ ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_TAILCALL */
++ ,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_RETURN */
++ ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORLOOP */
++ ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORPREP */
++ ,opmode(1, 0, OpArgN, OpArgU, iABC) /* OP_TFORLOOP */
++ ,opmode(0, 0, OpArgU, OpArgU, iABC) /* OP_SETLIST */
++ ,opmode(0, 0, OpArgN, OpArgN, iABC) /* OP_CLOSE */
++ ,opmode(0, 1, OpArgU, OpArgN, iABx) /* OP_CLOSURE */
++ ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_VARARG */
++};
++
+--- /dev/null
++++ b/extensions/LUA/lua/lopcodes.h
+@@ -0,0 +1,268 @@
++/*
++** $Id: lopcodes.h,v 1.125.1.1 2007/12/27 13:02:25 roberto Exp $
++** Opcodes for Lua virtual machine
++** See Copyright Notice in lua.h
++*/
++
++#ifndef lopcodes_h
++#define lopcodes_h
++
++#include "llimits.h"
++
++
++/*===========================================================================
++ We assume that instructions are unsigned numbers.
++ All instructions have an opcode in the first 6 bits.
++ Instructions can have the following fields:
++ `A' : 8 bits
++ `B' : 9 bits
++ `C' : 9 bits
++ `Bx' : 18 bits (`B' and `C' together)
++ `sBx' : signed Bx
++
++ A signed argument is represented in excess K; that is, the number
++ value is the unsigned value minus K. K is exactly the maximum value
++ for that argument (so that -max is represented by 0, and +max is
++ represented by 2*max), which is half the maximum for the corresponding
++ unsigned argument.
++===========================================================================*/
++
++
++enum OpMode {iABC, iABx, iAsBx}; /* basic instruction format */
++
++
++/*
++** size and position of opcode arguments.
++*/
++#define SIZE_C 9
++#define SIZE_B 9
++#define SIZE_Bx (SIZE_C + SIZE_B)
++#define SIZE_A 8
++
++#define SIZE_OP 6
++
++#define POS_OP 0
++#define POS_A (POS_OP + SIZE_OP)
++#define POS_C (POS_A + SIZE_A)
++#define POS_B (POS_C + SIZE_C)
++#define POS_Bx POS_C
++
++
++/*
++** limits for opcode arguments.
++** we use (signed) int to manipulate most arguments,
++** so they must fit in LUAI_BITSINT-1 bits (-1 for sign)
++*/
++#if SIZE_Bx < LUAI_BITSINT-1
++#define MAXARG_Bx ((1<<SIZE_Bx)-1)
++#define MAXARG_sBx (MAXARG_Bx>>1) /* `sBx' is signed */
++#else
++#define MAXARG_Bx MAX_INT
++#define MAXARG_sBx MAX_INT
++#endif
++
++
++#define MAXARG_A ((1<<SIZE_A)-1)
++#define MAXARG_B ((1<<SIZE_B)-1)
++#define MAXARG_C ((1<<SIZE_C)-1)
++
++
++/* creates a mask with `n' 1 bits at position `p' */
++#define MASK1(n,p) ((~((~(Instruction)0)<<n))<<p)
++
++/* creates a mask with `n' 0 bits at position `p' */
++#define MASK0(n,p) (~MASK1(n,p))
++
++/*
++** the following macros help to manipulate instructions
++*/
++
++#define GET_OPCODE(i) (cast(OpCode, ((i)>>POS_OP) & MASK1(SIZE_OP,0)))
++#define SET_OPCODE(i,o) ((i) = (((i)&MASK0(SIZE_OP,POS_OP)) | \
++ ((cast(Instruction, o)<<POS_OP)&MASK1(SIZE_OP,POS_OP))))
++
++#define GETARG_A(i) (cast(int, ((i)>>POS_A) & MASK1(SIZE_A,0)))
++#define SETARG_A(i,u) ((i) = (((i)&MASK0(SIZE_A,POS_A)) | \
++ ((cast(Instruction, u)<<POS_A)&MASK1(SIZE_A,POS_A))))
++
++#define GETARG_B(i) (cast(int, ((i)>>POS_B) & MASK1(SIZE_B,0)))
++#define SETARG_B(i,b) ((i) = (((i)&MASK0(SIZE_B,POS_B)) | \
++ ((cast(Instruction, b)<<POS_B)&MASK1(SIZE_B,POS_B))))
++
++#define GETARG_C(i) (cast(int, ((i)>>POS_C) & MASK1(SIZE_C,0)))
++#define SETARG_C(i,b) ((i) = (((i)&MASK0(SIZE_C,POS_C)) | \
++ ((cast(Instruction, b)<<POS_C)&MASK1(SIZE_C,POS_C))))
++
++#define GETARG_Bx(i) (cast(int, ((i)>>POS_Bx) & MASK1(SIZE_Bx,0)))
++#define SETARG_Bx(i,b) ((i) = (((i)&MASK0(SIZE_Bx,POS_Bx)) | \
++ ((cast(Instruction, b)<<POS_Bx)&MASK1(SIZE_Bx,POS_Bx))))
++
++#define GETARG_sBx(i) (GETARG_Bx(i)-MAXARG_sBx)
++#define SETARG_sBx(i,b) SETARG_Bx((i),cast(unsigned int, (b)+MAXARG_sBx))
++
++
++#define CREATE_ABC(o,a,b,c) ((cast(Instruction, o)<<POS_OP) \
++ | (cast(Instruction, a)<<POS_A) \
++ | (cast(Instruction, b)<<POS_B) \
++ | (cast(Instruction, c)<<POS_C))
++
++#define CREATE_ABx(o,a,bc) ((cast(Instruction, o)<<POS_OP) \
++ | (cast(Instruction, a)<<POS_A) \
++ | (cast(Instruction, bc)<<POS_Bx))
++
++
++/*
++** Macros to operate RK indices
++*/
++
++/* this bit 1 means constant (0 means register) */
++#define BITRK (1 << (SIZE_B - 1))
++
++/* test whether value is a constant */
++#define ISK(x) ((x) & BITRK)
++
++/* gets the index of the constant */
++#define INDEXK(r) ((int)(r) & ~BITRK)
++
++#define MAXINDEXRK (BITRK - 1)
++
++/* code a constant index as a RK value */
++#define RKASK(x) ((x) | BITRK)
++
++
++/*
++** invalid register that fits in 8 bits
++*/
++#define NO_REG MAXARG_A
++
++
++/*
++** R(x) - register
++** Kst(x) - constant (in constant table)
++** RK(x) == if ISK(x) then Kst(INDEXK(x)) else R(x)
++*/
++
++
++/*
++** grep "ORDER OP" if you change these enums
++*/
++
++typedef enum {
++/*----------------------------------------------------------------------
++name args description
++------------------------------------------------------------------------*/
++OP_MOVE,/* A B R(A) := R(B) */
++OP_LOADK,/* A Bx R(A) := Kst(Bx) */
++OP_LOADBOOL,/* A B C R(A) := (Bool)B; if (C) pc++ */
++OP_LOADNIL,/* A B R(A) := ... := R(B) := nil */
++OP_GETUPVAL,/* A B R(A) := UpValue[B] */
++
++OP_GETGLOBAL,/* A Bx R(A) := Gbl[Kst(Bx)] */
++OP_GETTABLE,/* A B C R(A) := R(B)[RK(C)] */
++
++OP_SETGLOBAL,/* A Bx Gbl[Kst(Bx)] := R(A) */
++OP_SETUPVAL,/* A B UpValue[B] := R(A) */
++OP_SETTABLE,/* A B C R(A)[RK(B)] := RK(C) */
++
++OP_NEWTABLE,/* A B C R(A) := {} (size = B,C) */
++
++OP_SELF,/* A B C R(A+1) := R(B); R(A) := R(B)[RK(C)] */
++
++OP_ADD,/* A B C R(A) := RK(B) + RK(C) */
++OP_SUB,/* A B C R(A) := RK(B) - RK(C) */
++OP_MUL,/* A B C R(A) := RK(B) * RK(C) */
++OP_DIV,/* A B C R(A) := RK(B) / RK(C) */
++OP_MOD,/* A B C R(A) := RK(B) % RK(C) */
++OP_POW,/* A B C R(A) := RK(B) ^ RK(C) */
++OP_UNM,/* A B R(A) := -R(B) */
++OP_NOT,/* A B R(A) := not R(B) */
++OP_LEN,/* A B R(A) := length of R(B) */
++
++OP_CONCAT,/* A B C R(A) := R(B).. ... ..R(C) */
++
++OP_JMP,/* sBx pc+=sBx */
++
++OP_EQ,/* A B C if ((RK(B) == RK(C)) ~= A) then pc++ */
++OP_LT,/* A B C if ((RK(B) < RK(C)) ~= A) then pc++ */
++OP_LE,/* A B C if ((RK(B) <= RK(C)) ~= A) then pc++ */
++
++OP_TEST,/* A C if not (R(A) <=> C) then pc++ */
++OP_TESTSET,/* A B C if (R(B) <=> C) then R(A) := R(B) else pc++ */
++
++OP_CALL,/* A B C R(A), ... ,R(A+C-2) := R(A)(R(A+1), ... ,R(A+B-1)) */
++OP_TAILCALL,/* A B C return R(A)(R(A+1), ... ,R(A+B-1)) */
++OP_RETURN,/* A B return R(A), ... ,R(A+B-2) (see note) */
++
++OP_FORLOOP,/* A sBx R(A)+=R(A+2);
++ if R(A) <?= R(A+1) then { pc+=sBx; R(A+3)=R(A) }*/
++OP_FORPREP,/* A sBx R(A)-=R(A+2); pc+=sBx */
++
++OP_TFORLOOP,/* A C R(A+3), ... ,R(A+2+C) := R(A)(R(A+1), R(A+2));
++ if R(A+3) ~= nil then R(A+2)=R(A+3) else pc++ */
++OP_SETLIST,/* A B C R(A)[(C-1)*FPF+i] := R(A+i), 1 <= i <= B */
++
++OP_CLOSE,/* A close all variables in the stack up to (>=) R(A)*/
++OP_CLOSURE,/* A Bx R(A) := closure(KPROTO[Bx], R(A), ... ,R(A+n)) */
++
++OP_VARARG/* A B R(A), R(A+1), ..., R(A+B-1) = vararg */
++} OpCode;
++
++
++#define NUM_OPCODES (cast(int, OP_VARARG) + 1)
++
++
++
++/*===========================================================================
++ Notes:
++ (*) In OP_CALL, if (B == 0) then B = top. C is the number of returns - 1,
++ and can be 0: OP_CALL then sets `top' to last_result+1, so
++ next open instruction (OP_CALL, OP_RETURN, OP_SETLIST) may use `top'.
++
++ (*) In OP_VARARG, if (B == 0) then use actual number of varargs and
++ set top (like in OP_CALL with C == 0).
++
++ (*) In OP_RETURN, if (B == 0) then return up to `top'
++
++ (*) In OP_SETLIST, if (B == 0) then B = `top';
++ if (C == 0) then next `instruction' is real C
++
++ (*) For comparisons, A specifies what condition the test should accept
++ (true or false).
++
++ (*) All `skips' (pc++) assume that next instruction is a jump
++===========================================================================*/
++
++
++/*
++** masks for instruction properties. The format is:
++** bits 0-1: op mode
++** bits 2-3: C arg mode
++** bits 4-5: B arg mode
++** bit 6: instruction set register A
++** bit 7: operator is a test
++*/
++
++enum OpArgMask {
++ OpArgN, /* argument is not used */
++ OpArgU, /* argument is used */
++ OpArgR, /* argument is a register or a jump offset */
++ OpArgK /* argument is a constant or register/constant */
++};
++
++LUAI_DATA const lu_byte luaP_opmodes[NUM_OPCODES];
++
++#define getOpMode(m) (cast(enum OpMode, luaP_opmodes[m] & 3))
++#define getBMode(m) (cast(enum OpArgMask, (luaP_opmodes[m] >> 4) & 3))
++#define getCMode(m) (cast(enum OpArgMask, (luaP_opmodes[m] >> 2) & 3))
++#define testAMode(m) (luaP_opmodes[m] & (1 << 6))
++#define testTMode(m) (luaP_opmodes[m] & (1 << 7))
++
++
++LUAI_DATA const char *const luaP_opnames[NUM_OPCODES+1]; /* opcode names */
++
++
++/* number of list items to accumulate before a SETLIST instruction */
++#define LFIELDS_PER_FLUSH 50
++
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/lparser.c
+@@ -0,0 +1,1339 @@
++/*
++** $Id: lparser.c,v 2.42.1.3 2007/12/28 15:32:23 roberto Exp $
++** Lua Parser
++** See Copyright Notice in lua.h
++*/
++
++
++#include <string.h>
++
++#define lparser_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "lcode.h"
++#include "ldebug.h"
++#include "ldo.h"
++#include "lfunc.h"
++#include "llex.h"
++#include "lmem.h"
++#include "lobject.h"
++#include "lopcodes.h"
++#include "lparser.h"
++#include "lstate.h"
++#include "lstring.h"
++#include "ltable.h"
++
++
++
++#define hasmultret(k) ((k) == VCALL || (k) == VVARARG)
++
++#define getlocvar(fs, i) ((fs)->f->locvars[(fs)->actvar[i]])
++
++#define luaY_checklimit(fs,v,l,m) if ((v)>(l)) errorlimit(fs,l,m)
++
++
++/*
++** nodes for block list (list of active blocks)
++*/
++typedef struct BlockCnt {
++ struct BlockCnt *previous; /* chain */
++ int breaklist; /* list of jumps out of this loop */
++ lu_byte nactvar; /* # active locals outside the breakable structure */
++ lu_byte upval; /* true if some variable in the block is an upvalue */
++ lu_byte isbreakable; /* true if `block' is a loop */
++} BlockCnt;
++
++
++
++/*
++** prototypes for recursive non-terminal functions
++*/
++static void chunk (LexState *ls);
++static void expr (LexState *ls, expdesc *v);
++
++
++static void anchor_token (LexState *ls) {
++ if (ls->t.token == TK_NAME || ls->t.token == TK_STRING) {
++ TString *ts = ls->t.seminfo.ts;
++ luaX_newstring(ls, getstr(ts), ts->tsv.len);
++ }
++}
++
++
++static void error_expected (LexState *ls, int token) {
++ luaX_syntaxerror(ls,
++ luaO_pushfstring(ls->L, LUA_QS " expected", luaX_token2str(ls, token)));
++}
++
++
++static void errorlimit (FuncState *fs, int limit, const char *what) {
++ const char *msg = (fs->f->linedefined == 0) ?
++ luaO_pushfstring(fs->L, "main function has more than %d %s", limit, what) :
++ luaO_pushfstring(fs->L, "function at line %d has more than %d %s",
++ fs->f->linedefined, limit, what);
++ luaX_lexerror(fs->ls, msg, 0);
++}
++
++
++static int testnext (LexState *ls, int c) {
++ if (ls->t.token == c) {
++ luaX_next(ls);
++ return 1;
++ }
++ else return 0;
++}
++
++
++static void check (LexState *ls, int c) {
++ if (ls->t.token != c)
++ error_expected(ls, c);
++}
++
++static void checknext (LexState *ls, int c) {
++ check(ls, c);
++ luaX_next(ls);
++}
++
++
++#define check_condition(ls,c,msg) { if (!(c)) luaX_syntaxerror(ls, msg); }
++
++
++
++static void check_match (LexState *ls, int what, int who, int where) {
++ if (!testnext(ls, what)) {
++ if (where == ls->linenumber)
++ error_expected(ls, what);
++ else {
++ luaX_syntaxerror(ls, luaO_pushfstring(ls->L,
++ LUA_QS " expected (to close " LUA_QS " at line %d)",
++ luaX_token2str(ls, what), luaX_token2str(ls, who), where));
++ }
++ }
++}
++
++
++static TString *str_checkname (LexState *ls) {
++ TString *ts;
++ check(ls, TK_NAME);
++ ts = ls->t.seminfo.ts;
++ luaX_next(ls);
++ return ts;
++}
++
++
++static void init_exp (expdesc *e, expkind k, int i) {
++ e->f = e->t = NO_JUMP;
++ e->k = k;
++ e->u.s.info = i;
++}
++
++
++static void codestring (LexState *ls, expdesc *e, TString *s) {
++ init_exp(e, VK, luaK_stringK(ls->fs, s));
++}
++
++
++static void checkname(LexState *ls, expdesc *e) {
++ codestring(ls, e, str_checkname(ls));
++}
++
++
++static int registerlocalvar (LexState *ls, TString *varname) {
++ FuncState *fs = ls->fs;
++ Proto *f = fs->f;
++ int oldsize = f->sizelocvars;
++ luaM_growvector(ls->L, f->locvars, fs->nlocvars, f->sizelocvars,
++ LocVar, SHRT_MAX, "too many local variables");
++ while (oldsize < f->sizelocvars) f->locvars[oldsize++].varname = NULL;
++ f->locvars[fs->nlocvars].varname = varname;
++ luaC_objbarrier(ls->L, f, varname);
++ return fs->nlocvars++;
++}
++
++
++#define new_localvarliteral(ls,v,n) \
++ new_localvar(ls, luaX_newstring(ls, "" v, (sizeof(v)/sizeof(char))-1), n)
++
++
++static void new_localvar (LexState *ls, TString *name, int n) {
++ FuncState *fs = ls->fs;
++ luaY_checklimit(fs, fs->nactvar+n+1, LUAI_MAXVARS, "local variables");
++ fs->actvar[fs->nactvar+n] = cast(unsigned short, registerlocalvar(ls, name));
++}
++
++
++static void adjustlocalvars (LexState *ls, int nvars) {
++ FuncState *fs = ls->fs;
++ fs->nactvar = cast_byte(fs->nactvar + nvars);
++ for (; nvars; nvars--) {
++ getlocvar(fs, fs->nactvar - nvars).startpc = fs->pc;
++ }
++}
++
++
++static void removevars (LexState *ls, int tolevel) {
++ FuncState *fs = ls->fs;
++ while (fs->nactvar > tolevel)
++ getlocvar(fs, --fs->nactvar).endpc = fs->pc;
++}
++
++
++static int indexupvalue (FuncState *fs, TString *name, expdesc *v) {
++ int i;
++ Proto *f = fs->f;
++ int oldsize = f->sizeupvalues;
++ for (i=0; i<f->nups; i++) {
++ if (fs->upvalues[i].k == v->k && fs->upvalues[i].info == v->u.s.info) {
++ lua_assert(f->upvalues[i] == name);
++ return i;
++ }
++ }
++ /* new one */
++ luaY_checklimit(fs, f->nups + 1, LUAI_MAXUPVALUES, "upvalues");
++ luaM_growvector(fs->L, f->upvalues, f->nups, f->sizeupvalues,
++ TString *, MAX_INT, "");
++ while (oldsize < f->sizeupvalues) f->upvalues[oldsize++] = NULL;
++ f->upvalues[f->nups] = name;
++ luaC_objbarrier(fs->L, f, name);
++ lua_assert(v->k == VLOCAL || v->k == VUPVAL);
++ fs->upvalues[f->nups].k = cast_byte(v->k);
++ fs->upvalues[f->nups].info = cast_byte(v->u.s.info);
++ return f->nups++;
++}
++
++
++static int searchvar (FuncState *fs, TString *n) {
++ int i;
++ for (i=fs->nactvar-1; i >= 0; i--) {
++ if (n == getlocvar(fs, i).varname)
++ return i;
++ }
++ return -1; /* not found */
++}
++
++
++static void markupval (FuncState *fs, int level) {
++ BlockCnt *bl = fs->bl;
++ while (bl && bl->nactvar > level) bl = bl->previous;
++ if (bl) bl->upval = 1;
++}
++
++
++static int singlevaraux (FuncState *fs, TString *n, expdesc *var, int base) {
++ if (fs == NULL) { /* no more levels? */
++ init_exp(var, VGLOBAL, NO_REG); /* default is global variable */
++ return VGLOBAL;
++ }
++ else {
++ int v = searchvar(fs, n); /* look up at current level */
++ if (v >= 0) {
++ init_exp(var, VLOCAL, v);
++ if (!base)
++ markupval(fs, v); /* local will be used as an upval */
++ return VLOCAL;
++ }
++ else { /* not found at current level; try upper one */
++ if (singlevaraux(fs->prev, n, var, 0) == VGLOBAL)
++ return VGLOBAL;
++ var->u.s.info = indexupvalue(fs, n, var); /* else was LOCAL or UPVAL */
++ var->k = VUPVAL; /* upvalue in this level */
++ return VUPVAL;
++ }
++ }
++}
++
++
++static void singlevar (LexState *ls, expdesc *var) {
++ TString *varname = str_checkname(ls);
++ FuncState *fs = ls->fs;
++ if (singlevaraux(fs, varname, var, 1) == VGLOBAL)
++ var->u.s.info = luaK_stringK(fs, varname); /* info points to global name */
++}
++
++
++static void adjust_assign (LexState *ls, int nvars, int nexps, expdesc *e) {
++ FuncState *fs = ls->fs;
++ int extra = nvars - nexps;
++ if (hasmultret(e->k)) {
++ extra++; /* includes call itself */
++ if (extra < 0) extra = 0;
++ luaK_setreturns(fs, e, extra); /* last exp. provides the difference */
++ if (extra > 1) luaK_reserveregs(fs, extra-1);
++ }
++ else {
++ if (e->k != VVOID) luaK_exp2nextreg(fs, e); /* close last expression */
++ if (extra > 0) {
++ int reg = fs->freereg;
++ luaK_reserveregs(fs, extra);
++ luaK_nil(fs, reg, extra);
++ }
++ }
++}
++
++
++static void enterlevel (LexState *ls) {
++ if (++ls->L->nCcalls > LUAI_MAXCCALLS)
++ luaX_lexerror(ls, "chunk has too many syntax levels", 0);
++}
++
++
++#define leavelevel(ls) ((ls)->L->nCcalls--)
++
++
++static void enterblock (FuncState *fs, BlockCnt *bl, lu_byte isbreakable) {
++ bl->breaklist = NO_JUMP;
++ bl->isbreakable = isbreakable;
++ bl->nactvar = fs->nactvar;
++ bl->upval = 0;
++ bl->previous = fs->bl;
++ fs->bl = bl;
++ lua_assert(fs->freereg == fs->nactvar);
++}
++
++
++static void leaveblock (FuncState *fs) {
++ BlockCnt *bl = fs->bl;
++ fs->bl = bl->previous;
++ removevars(fs->ls, bl->nactvar);
++ if (bl->upval)
++ luaK_codeABC(fs, OP_CLOSE, bl->nactvar, 0, 0);
++ /* a block either controls scope or breaks (never both) */
++ lua_assert(!bl->isbreakable || !bl->upval);
++ lua_assert(bl->nactvar == fs->nactvar);
++ fs->freereg = fs->nactvar; /* free registers */
++ luaK_patchtohere(fs, bl->breaklist);
++}
++
++
++static void pushclosure (LexState *ls, FuncState *func, expdesc *v) {
++ FuncState *fs = ls->fs;
++ Proto *f = fs->f;
++ int oldsize = f->sizep;
++ int i;
++ luaM_growvector(ls->L, f->p, fs->np, f->sizep, Proto *,
++ MAXARG_Bx, "constant table overflow");
++ while (oldsize < f->sizep) f->p[oldsize++] = NULL;
++ f->p[fs->np++] = func->f;
++ luaC_objbarrier(ls->L, f, func->f);
++ init_exp(v, VRELOCABLE, luaK_codeABx(fs, OP_CLOSURE, 0, fs->np-1));
++ for (i=0; i<func->f->nups; i++) {
++ OpCode o = (func->upvalues[i].k == VLOCAL) ? OP_MOVE : OP_GETUPVAL;
++ luaK_codeABC(fs, o, 0, func->upvalues[i].info, 0);
++ }
++}
++
++
++static void open_func (LexState *ls, FuncState *fs) {
++ lua_State *L = ls->L;
++ Proto *f = luaF_newproto(L);
++ fs->f = f;
++ fs->prev = ls->fs; /* linked list of funcstates */
++ fs->ls = ls;
++ fs->L = L;
++ ls->fs = fs;
++ fs->pc = 0;
++ fs->lasttarget = -1;
++ fs->jpc = NO_JUMP;
++ fs->freereg = 0;
++ fs->nk = 0;
++ fs->np = 0;
++ fs->nlocvars = 0;
++ fs->nactvar = 0;
++ fs->bl = NULL;
++ f->source = ls->source;
++ f->maxstacksize = 2; /* registers 0/1 are always valid */
++ fs->h = luaH_new(L, 0, 0);
++ /* anchor table of constants and prototype (to avoid being collected) */
++ sethvalue2s(L, L->top, fs->h);
++ incr_top(L);
++ setptvalue2s(L, L->top, f);
++ incr_top(L);
++}
++
++
++static void close_func (LexState *ls) {
++ lua_State *L = ls->L;
++ FuncState *fs = ls->fs;
++ Proto *f = fs->f;
++ removevars(ls, 0);
++ luaK_ret(fs, 0, 0); /* final return */
++ luaM_reallocvector(L, f->code, f->sizecode, fs->pc, Instruction);
++ f->sizecode = fs->pc;
++ luaM_reallocvector(L, f->lineinfo, f->sizelineinfo, fs->pc, int);
++ f->sizelineinfo = fs->pc;
++ luaM_reallocvector(L, f->k, f->sizek, fs->nk, TValue);
++ f->sizek = fs->nk;
++ luaM_reallocvector(L, f->p, f->sizep, fs->np, Proto *);
++ f->sizep = fs->np;
++ luaM_reallocvector(L, f->locvars, f->sizelocvars, fs->nlocvars, LocVar);
++ f->sizelocvars = fs->nlocvars;
++ luaM_reallocvector(L, f->upvalues, f->sizeupvalues, f->nups, TString *);
++ f->sizeupvalues = f->nups;
++ lua_assert(luaG_checkcode(f));
++ lua_assert(fs->bl == NULL);
++ ls->fs = fs->prev;
++ L->top -= 2; /* remove table and prototype from the stack */
++ /* last token read was anchored in defunct function; must reanchor it */
++ if (fs) anchor_token(ls);
++}
++
++
++Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, const char *name) {
++ struct LexState lexstate;
++ struct FuncState funcstate;
++ lexstate.buff = buff;
++ luaX_setinput(L, &lexstate, z, luaS_new(L, name));
++ open_func(&lexstate, &funcstate);
++ funcstate.f->is_vararg = VARARG_ISVARARG; /* main func. is always vararg */
++ luaX_next(&lexstate); /* read first token */
++ chunk(&lexstate);
++ check(&lexstate, TK_EOS);
++ close_func(&lexstate);
++ lua_assert(funcstate.prev == NULL);
++ lua_assert(funcstate.f->nups == 0);
++ lua_assert(lexstate.fs == NULL);
++ return funcstate.f;
++}
++
++
++
++/*============================================================*/
++/* GRAMMAR RULES */
++/*============================================================*/
++
++
++static void field (LexState *ls, expdesc *v) {
++ /* field -> ['.' | ':'] NAME */
++ FuncState *fs = ls->fs;
++ expdesc key;
++ luaK_exp2anyreg(fs, v);
++ luaX_next(ls); /* skip the dot or colon */
++ checkname(ls, &key);
++ luaK_indexed(fs, v, &key);
++}
++
++
++static void yindex (LexState *ls, expdesc *v) {
++ /* index -> '[' expr ']' */
++ luaX_next(ls); /* skip the '[' */
++ expr(ls, v);
++ luaK_exp2val(ls->fs, v);
++ checknext(ls, ']');
++}
++
++
++/*
++** {======================================================================
++** Rules for Constructors
++** =======================================================================
++*/
++
++
++struct ConsControl {
++ expdesc v; /* last list item read */
++ expdesc *t; /* table descriptor */
++ int nh; /* total number of `record' elements */
++ int na; /* total number of array elements */
++ int tostore; /* number of array elements pending to be stored */
++};
++
++
++static void recfield (LexState *ls, struct ConsControl *cc) {
++ /* recfield -> (NAME | `['exp1`]') = exp1 */
++ FuncState *fs = ls->fs;
++ int reg = ls->fs->freereg;
++ expdesc key, val;
++ int rkkey;
++ if (ls->t.token == TK_NAME) {
++ luaY_checklimit(fs, cc->nh, MAX_INT, "items in a constructor");
++ checkname(ls, &key);
++ }
++ else /* ls->t.token == '[' */
++ yindex(ls, &key);
++ cc->nh++;
++ checknext(ls, '=');
++ rkkey = luaK_exp2RK(fs, &key);
++ expr(ls, &val);
++ luaK_codeABC(fs, OP_SETTABLE, cc->t->u.s.info, rkkey, luaK_exp2RK(fs, &val));
++ fs->freereg = reg; /* free registers */
++}
++
++
++static void closelistfield (FuncState *fs, struct ConsControl *cc) {
++ if (cc->v.k == VVOID) return; /* there is no list item */
++ luaK_exp2nextreg(fs, &cc->v);
++ cc->v.k = VVOID;
++ if (cc->tostore == LFIELDS_PER_FLUSH) {
++ luaK_setlist(fs, cc->t->u.s.info, cc->na, cc->tostore); /* flush */
++ cc->tostore = 0; /* no more items pending */
++ }
++}
++
++
++static void lastlistfield (FuncState *fs, struct ConsControl *cc) {
++ if (cc->tostore == 0) return;
++ if (hasmultret(cc->v.k)) {
++ luaK_setmultret(fs, &cc->v);
++ luaK_setlist(fs, cc->t->u.s.info, cc->na, LUA_MULTRET);
++ cc->na--; /* do not count last expression (unknown number of elements) */
++ }
++ else {
++ if (cc->v.k != VVOID)
++ luaK_exp2nextreg(fs, &cc->v);
++ luaK_setlist(fs, cc->t->u.s.info, cc->na, cc->tostore);
++ }
++}
++
++
++static void listfield (LexState *ls, struct ConsControl *cc) {
++ expr(ls, &cc->v);
++ luaY_checklimit(ls->fs, cc->na, MAX_INT, "items in a constructor");
++ cc->na++;
++ cc->tostore++;
++}
++
++
++static void constructor (LexState *ls, expdesc *t) {
++ /* constructor -> ?? */
++ FuncState *fs = ls->fs;
++ int line = ls->linenumber;
++ int pc = luaK_codeABC(fs, OP_NEWTABLE, 0, 0, 0);
++ struct ConsControl cc;
++ cc.na = cc.nh = cc.tostore = 0;
++ cc.t = t;
++ init_exp(t, VRELOCABLE, pc);
++ init_exp(&cc.v, VVOID, 0); /* no value (yet) */
++ luaK_exp2nextreg(ls->fs, t); /* fix it at stack top (for gc) */
++ checknext(ls, '{');
++ do {
++ lua_assert(cc.v.k == VVOID || cc.tostore > 0);
++ if (ls->t.token == '}') break;
++ closelistfield(fs, &cc);
++ switch(ls->t.token) {
++ case TK_NAME: { /* may be listfields or recfields */
++ luaX_lookahead(ls);
++ if (ls->lookahead.token != '=') /* expression? */
++ listfield(ls, &cc);
++ else
++ recfield(ls, &cc);
++ break;
++ }
++ case '[': { /* constructor_item -> recfield */
++ recfield(ls, &cc);
++ break;
++ }
++ default: { /* constructor_part -> listfield */
++ listfield(ls, &cc);
++ break;
++ }
++ }
++ } while (testnext(ls, ',') || testnext(ls, ';'));
++ check_match(ls, '}', '{', line);
++ lastlistfield(fs, &cc);
++ SETARG_B(fs->f->code[pc], luaO_int2fb(cc.na)); /* set initial array size */
++ SETARG_C(fs->f->code[pc], luaO_int2fb(cc.nh)); /* set initial table size */
++}
++
++/* }====================================================================== */
++
++
++
++static void parlist (LexState *ls) {
++ /* parlist -> [ param { `,' param } ] */
++ FuncState *fs = ls->fs;
++ Proto *f = fs->f;
++ int nparams = 0;
++ f->is_vararg = 0;
++ if (ls->t.token != ')') { /* is `parlist' not empty? */
++ do {
++ switch (ls->t.token) {
++ case TK_NAME: { /* param -> NAME */
++ new_localvar(ls, str_checkname(ls), nparams++);
++ break;
++ }
++ case TK_DOTS: { /* param -> `...' */
++ luaX_next(ls);
++#if defined(LUA_COMPAT_VARARG)
++ /* use `arg' as default name */
++ new_localvarliteral(ls, "arg", nparams++);
++ f->is_vararg = VARARG_HASARG | VARARG_NEEDSARG;
++#endif
++ f->is_vararg |= VARARG_ISVARARG;
++ break;
++ }
++ default: luaX_syntaxerror(ls, "<name> or " LUA_QL("...") " expected");
++ }
++ } while (!f->is_vararg && testnext(ls, ','));
++ }
++ adjustlocalvars(ls, nparams);
++ f->numparams = cast_byte(fs->nactvar - (f->is_vararg & VARARG_HASARG));
++ luaK_reserveregs(fs, fs->nactvar); /* reserve register for parameters */
++}
++
++
++static void body (LexState *ls, expdesc *e, int needself, int line) {
++ /* body -> `(' parlist `)' chunk END */
++ FuncState new_fs;
++ open_func(ls, &new_fs);
++ new_fs.f->linedefined = line;
++ checknext(ls, '(');
++ if (needself) {
++ new_localvarliteral(ls, "self", 0);
++ adjustlocalvars(ls, 1);
++ }
++ parlist(ls);
++ checknext(ls, ')');
++ chunk(ls);
++ new_fs.f->lastlinedefined = ls->linenumber;
++ check_match(ls, TK_END, TK_FUNCTION, line);
++ close_func(ls);
++ pushclosure(ls, &new_fs, e);
++}
++
++
++static int explist1 (LexState *ls, expdesc *v) {
++ /* explist1 -> expr { `,' expr } */
++ int n = 1; /* at least one expression */
++ expr(ls, v);
++ while (testnext(ls, ',')) {
++ luaK_exp2nextreg(ls->fs, v);
++ expr(ls, v);
++ n++;
++ }
++ return n;
++}
++
++
++static void funcargs (LexState *ls, expdesc *f) {
++ FuncState *fs = ls->fs;
++ expdesc args;
++ int base, nparams;
++ int line = ls->linenumber;
++ switch (ls->t.token) {
++ case '(': { /* funcargs -> `(' [ explist1 ] `)' */
++ if (line != ls->lastline)
++ luaX_syntaxerror(ls,"ambiguous syntax (function call x new statement)");
++ luaX_next(ls);
++ if (ls->t.token == ')') /* arg list is empty? */
++ args.k = VVOID;
++ else {
++ explist1(ls, &args);
++ luaK_setmultret(fs, &args);
++ }
++ check_match(ls, ')', '(', line);
++ break;
++ }
++ case '{': { /* funcargs -> constructor */
++ constructor(ls, &args);
++ break;
++ }
++ case TK_STRING: { /* funcargs -> STRING */
++ codestring(ls, &args, ls->t.seminfo.ts);
++ luaX_next(ls); /* must use `seminfo' before `next' */
++ break;
++ }
++ default: {
++ luaX_syntaxerror(ls, "function arguments expected");
++ return;
++ }
++ }
++ lua_assert(f->k == VNONRELOC);
++ base = f->u.s.info; /* base register for call */
++ if (hasmultret(args.k))
++ nparams = LUA_MULTRET; /* open call */
++ else {
++ if (args.k != VVOID)
++ luaK_exp2nextreg(fs, &args); /* close last argument */
++ nparams = fs->freereg - (base+1);
++ }
++ init_exp(f, VCALL, luaK_codeABC(fs, OP_CALL, base, nparams+1, 2));
++ luaK_fixline(fs, line);
++ fs->freereg = base+1; /* call remove function and arguments and leaves
++ (unless changed) one result */
++}
++
++
++
++
++/*
++** {======================================================================
++** Expression parsing
++** =======================================================================
++*/
++
++
++static void prefixexp (LexState *ls, expdesc *v) {
++ /* prefixexp -> NAME | '(' expr ')' */
++ switch (ls->t.token) {
++ case '(': {
++ int line = ls->linenumber;
++ luaX_next(ls);
++ expr(ls, v);
++ check_match(ls, ')', '(', line);
++ luaK_dischargevars(ls->fs, v);
++ return;
++ }
++ case TK_NAME: {
++ singlevar(ls, v);
++ return;
++ }
++ default: {
++ luaX_syntaxerror(ls, "unexpected symbol");
++ return;
++ }
++ }
++}
++
++
++static void primaryexp (LexState *ls, expdesc *v) {
++ /* primaryexp ->
++ prefixexp { `.' NAME | `[' exp `]' | `:' NAME funcargs | funcargs } */
++ FuncState *fs = ls->fs;
++ prefixexp(ls, v);
++ for (;;) {
++ switch (ls->t.token) {
++ case '.': { /* field */
++ field(ls, v);
++ break;
++ }
++ case '[': { /* `[' exp1 `]' */
++ expdesc key;
++ luaK_exp2anyreg(fs, v);
++ yindex(ls, &key);
++ luaK_indexed(fs, v, &key);
++ break;
++ }
++ case ':': { /* `:' NAME funcargs */
++ expdesc key;
++ luaX_next(ls);
++ checkname(ls, &key);
++ luaK_self(fs, v, &key);
++ funcargs(ls, v);
++ break;
++ }
++ case '(': case TK_STRING: case '{': { /* funcargs */
++ luaK_exp2nextreg(fs, v);
++ funcargs(ls, v);
++ break;
++ }
++ default: return;
++ }
++ }
++}
++
++
++static void simpleexp (LexState *ls, expdesc *v) {
++ /* simpleexp -> NUMBER | STRING | NIL | true | false | ... |
++ constructor | FUNCTION body | primaryexp */
++ switch (ls->t.token) {
++ case TK_NUMBER: {
++ init_exp(v, VKNUM, 0);
++ v->u.nval = ls->t.seminfo.r;
++ break;
++ }
++ case TK_STRING: {
++ codestring(ls, v, ls->t.seminfo.ts);
++ break;
++ }
++ case TK_NIL: {
++ init_exp(v, VNIL, 0);
++ break;
++ }
++ case TK_TRUE: {
++ init_exp(v, VTRUE, 0);
++ break;
++ }
++ case TK_FALSE: {
++ init_exp(v, VFALSE, 0);
++ break;
++ }
++ case TK_DOTS: { /* vararg */
++ FuncState *fs = ls->fs;
++ check_condition(ls, fs->f->is_vararg,
++ "cannot use " LUA_QL("...") " outside a vararg function");
++ fs->f->is_vararg &= ~VARARG_NEEDSARG; /* don't need 'arg' */
++ init_exp(v, VVARARG, luaK_codeABC(fs, OP_VARARG, 0, 1, 0));
++ break;
++ }
++ case '{': { /* constructor */
++ constructor(ls, v);
++ return;
++ }
++ case TK_FUNCTION: {
++ luaX_next(ls);
++ body(ls, v, 0, ls->linenumber);
++ return;
++ }
++ default: {
++ primaryexp(ls, v);
++ return;
++ }
++ }
++ luaX_next(ls);
++}
++
++
++static UnOpr getunopr (int op) {
++ switch (op) {
++ case TK_NOT: return OPR_NOT;
++ case '-': return OPR_MINUS;
++ case '#': return OPR_LEN;
++ default: return OPR_NOUNOPR;
++ }
++}
++
++
++static BinOpr getbinopr (int op) {
++ switch (op) {
++ case '+': return OPR_ADD;
++ case '-': return OPR_SUB;
++ case '*': return OPR_MUL;
++ case '/': return OPR_DIV;
++ case '%': return OPR_MOD;
++ case '^': return OPR_POW;
++ case TK_CONCAT: return OPR_CONCAT;
++ case TK_NE: return OPR_NE;
++ case TK_EQ: return OPR_EQ;
++ case '<': return OPR_LT;
++ case TK_LE: return OPR_LE;
++ case '>': return OPR_GT;
++ case TK_GE: return OPR_GE;
++ case TK_AND: return OPR_AND;
++ case TK_OR: return OPR_OR;
++ default: return OPR_NOBINOPR;
++ }
++}
++
++
++static const struct {
++ lu_byte left; /* left priority for each binary operator */
++ lu_byte right; /* right priority */
++} priority[] = { /* ORDER OPR */
++ {6, 6}, {6, 6}, {7, 7}, {7, 7}, {7, 7}, /* `+' `-' `/' `%' */
++ {10, 9}, {5, 4}, /* power and concat (right associative) */
++ {3, 3}, {3, 3}, /* equality and inequality */
++ {3, 3}, {3, 3}, {3, 3}, {3, 3}, /* order */
++ {2, 2}, {1, 1} /* logical (and/or) */
++};
++
++#define UNARY_PRIORITY 8 /* priority for unary operators */
++
++
++/*
++** subexpr -> (simpleexp | unop subexpr) { binop subexpr }
++** where `binop' is any binary operator with a priority higher than `limit'
++*/
++static BinOpr subexpr (LexState *ls, expdesc *v, unsigned int limit) {
++ BinOpr op;
++ UnOpr uop;
++ enterlevel(ls);
++ uop = getunopr(ls->t.token);
++ if (uop != OPR_NOUNOPR) {
++ luaX_next(ls);
++ subexpr(ls, v, UNARY_PRIORITY);
++ luaK_prefix(ls->fs, uop, v);
++ }
++ else simpleexp(ls, v);
++ /* expand while operators have priorities higher than `limit' */
++ op = getbinopr(ls->t.token);
++ while (op != OPR_NOBINOPR && priority[op].left > limit) {
++ expdesc v2;
++ BinOpr nextop;
++ luaX_next(ls);
++ luaK_infix(ls->fs, op, v);
++ /* read sub-expression with higher priority */
++ nextop = subexpr(ls, &v2, priority[op].right);
++ luaK_posfix(ls->fs, op, v, &v2);
++ op = nextop;
++ }
++ leavelevel(ls);
++ return op; /* return first untreated operator */
++}
++
++
++static void expr (LexState *ls, expdesc *v) {
++ subexpr(ls, v, 0);
++}
++
++/* }==================================================================== */
++
++
++
++/*
++** {======================================================================
++** Rules for Statements
++** =======================================================================
++*/
++
++
++static int block_follow (int token) {
++ switch (token) {
++ case TK_ELSE: case TK_ELSEIF: case TK_END:
++ case TK_UNTIL: case TK_EOS:
++ return 1;
++ default: return 0;
++ }
++}
++
++
++static void block (LexState *ls) {
++ /* block -> chunk */
++ FuncState *fs = ls->fs;
++ BlockCnt bl;
++ enterblock(fs, &bl, 0);
++ chunk(ls);
++ lua_assert(bl.breaklist == NO_JUMP);
++ leaveblock(fs);
++}
++
++
++/*
++** structure to chain all variables in the left-hand side of an
++** assignment
++*/
++struct LHS_assign {
++ struct LHS_assign *prev;
++ expdesc v; /* variable (global, local, upvalue, or indexed) */
++};
++
++
++/*
++** check whether, in an assignment to a local variable, the local variable
++** is needed in a previous assignment (to a table). If so, save original
++** local value in a safe place and use this safe copy in the previous
++** assignment.
++*/
++static void check_conflict (LexState *ls, struct LHS_assign *lh, expdesc *v) {
++ FuncState *fs = ls->fs;
++ int extra = fs->freereg; /* eventual position to save local variable */
++ int conflict = 0;
++ for (; lh; lh = lh->prev) {
++ if (lh->v.k == VINDEXED) {
++ if (lh->v.u.s.info == v->u.s.info) { /* conflict? */
++ conflict = 1;
++ lh->v.u.s.info = extra; /* previous assignment will use safe copy */
++ }
++ if (lh->v.u.s.aux == v->u.s.info) { /* conflict? */
++ conflict = 1;
++ lh->v.u.s.aux = extra; /* previous assignment will use safe copy */
++ }
++ }
++ }
++ if (conflict) {
++ luaK_codeABC(fs, OP_MOVE, fs->freereg, v->u.s.info, 0); /* make copy */
++ luaK_reserveregs(fs, 1);
++ }
++}
++
++
++static void assignment (LexState *ls, struct LHS_assign *lh, int nvars) {
++ expdesc e;
++ check_condition(ls, VLOCAL <= lh->v.k && lh->v.k <= VINDEXED,
++ "syntax error");
++ if (testnext(ls, ',')) { /* assignment -> `,' primaryexp assignment */
++ struct LHS_assign nv;
++ nv.prev = lh;
++ primaryexp(ls, &nv.v);
++ if (nv.v.k == VLOCAL)
++ check_conflict(ls, lh, &nv.v);
++ luaY_checklimit(ls->fs, nvars, LUAI_MAXCCALLS - ls->L->nCcalls,
++ "variables in assignment");
++ assignment(ls, &nv, nvars+1);
++ }
++ else { /* assignment -> `=' explist1 */
++ int nexps;
++ checknext(ls, '=');
++ nexps = explist1(ls, &e);
++ if (nexps != nvars) {
++ adjust_assign(ls, nvars, nexps, &e);
++ if (nexps > nvars)
++ ls->fs->freereg -= nexps - nvars; /* remove extra values */
++ }
++ else {
++ luaK_setoneret(ls->fs, &e); /* close last expression */
++ luaK_storevar(ls->fs, &lh->v, &e);
++ return; /* avoid default */
++ }
++ }
++ init_exp(&e, VNONRELOC, ls->fs->freereg-1); /* default assignment */
++ luaK_storevar(ls->fs, &lh->v, &e);
++}
++
++
++static int cond (LexState *ls) {
++ /* cond -> exp */
++ expdesc v;
++ expr(ls, &v); /* read condition */
++ if (v.k == VNIL) v.k = VFALSE; /* `falses' are all equal here */
++ luaK_goiftrue(ls->fs, &v);
++ return v.f;
++}
++
++
++static void breakstat (LexState *ls) {
++ FuncState *fs = ls->fs;
++ BlockCnt *bl = fs->bl;
++ int upval = 0;
++ while (bl && !bl->isbreakable) {
++ upval |= bl->upval;
++ bl = bl->previous;
++ }
++ if (!bl)
++ luaX_syntaxerror(ls, "no loop to break");
++ if (upval)
++ luaK_codeABC(fs, OP_CLOSE, bl->nactvar, 0, 0);
++ luaK_concat(fs, &bl->breaklist, luaK_jump(fs));
++}
++
++
++static void whilestat (LexState *ls, int line) {
++ /* whilestat -> WHILE cond DO block END */
++ FuncState *fs = ls->fs;
++ int whileinit;
++ int condexit;
++ BlockCnt bl;
++ luaX_next(ls); /* skip WHILE */
++ whileinit = luaK_getlabel(fs);
++ condexit = cond(ls);
++ enterblock(fs, &bl, 1);
++ checknext(ls, TK_DO);
++ block(ls);
++ luaK_patchlist(fs, luaK_jump(fs), whileinit);
++ check_match(ls, TK_END, TK_WHILE, line);
++ leaveblock(fs);
++ luaK_patchtohere(fs, condexit); /* false conditions finish the loop */
++}
++
++
++static void repeatstat (LexState *ls, int line) {
++ /* repeatstat -> REPEAT block UNTIL cond */
++ int condexit;
++ FuncState *fs = ls->fs;
++ int repeat_init = luaK_getlabel(fs);
++ BlockCnt bl1, bl2;
++ enterblock(fs, &bl1, 1); /* loop block */
++ enterblock(fs, &bl2, 0); /* scope block */
++ luaX_next(ls); /* skip REPEAT */
++ chunk(ls);
++ check_match(ls, TK_UNTIL, TK_REPEAT, line);
++ condexit = cond(ls); /* read condition (inside scope block) */
++ if (!bl2.upval) { /* no upvalues? */
++ leaveblock(fs); /* finish scope */
++ luaK_patchlist(ls->fs, condexit, repeat_init); /* close the loop */
++ }
++ else { /* complete semantics when there are upvalues */
++ breakstat(ls); /* if condition then break */
++ luaK_patchtohere(ls->fs, condexit); /* else... */
++ leaveblock(fs); /* finish scope... */
++ luaK_patchlist(ls->fs, luaK_jump(fs), repeat_init); /* and repeat */
++ }
++ leaveblock(fs); /* finish loop */
++}
++
++
++static int exp1 (LexState *ls) {
++ expdesc e;
++ int k;
++ expr(ls, &e);
++ k = e.k;
++ luaK_exp2nextreg(ls->fs, &e);
++ return k;
++}
++
++
++static void forbody (LexState *ls, int base, int line, int nvars, int isnum) {
++ /* forbody -> DO block */
++ BlockCnt bl;
++ FuncState *fs = ls->fs;
++ int prep, endfor;
++ adjustlocalvars(ls, 3); /* control variables */
++ checknext(ls, TK_DO);
++ prep = isnum ? luaK_codeAsBx(fs, OP_FORPREP, base, NO_JUMP) : luaK_jump(fs);
++ enterblock(fs, &bl, 0); /* scope for declared variables */
++ adjustlocalvars(ls, nvars);
++ luaK_reserveregs(fs, nvars);
++ block(ls);
++ leaveblock(fs); /* end of scope for declared variables */
++ luaK_patchtohere(fs, prep);
++ endfor = (isnum) ? luaK_codeAsBx(fs, OP_FORLOOP, base, NO_JUMP) :
++ luaK_codeABC(fs, OP_TFORLOOP, base, 0, nvars);
++ luaK_fixline(fs, line); /* pretend that `OP_FOR' starts the loop */
++ luaK_patchlist(fs, (isnum ? endfor : luaK_jump(fs)), prep + 1);
++}
++
++
++static void fornum (LexState *ls, TString *varname, int line) {
++ /* fornum -> NAME = exp1,exp1[,exp1] forbody */
++ FuncState *fs = ls->fs;
++ int base = fs->freereg;
++ new_localvarliteral(ls, "(for index)", 0);
++ new_localvarliteral(ls, "(for limit)", 1);
++ new_localvarliteral(ls, "(for step)", 2);
++ new_localvar(ls, varname, 3);
++ checknext(ls, '=');
++ exp1(ls); /* initial value */
++ checknext(ls, ',');
++ exp1(ls); /* limit */
++ if (testnext(ls, ','))
++ exp1(ls); /* optional step */
++ else { /* default step = 1 */
++ luaK_codeABx(fs, OP_LOADK, fs->freereg, luaK_numberK(fs, 1));
++ luaK_reserveregs(fs, 1);
++ }
++ forbody(ls, base, line, 1, 1);
++}
++
++
++static void forlist (LexState *ls, TString *indexname) {
++ /* forlist -> NAME {,NAME} IN explist1 forbody */
++ FuncState *fs = ls->fs;
++ expdesc e;
++ int nvars = 0;
++ int line;
++ int base = fs->freereg;
++ /* create control variables */
++ new_localvarliteral(ls, "(for generator)", nvars++);
++ new_localvarliteral(ls, "(for state)", nvars++);
++ new_localvarliteral(ls, "(for control)", nvars++);
++ /* create declared variables */
++ new_localvar(ls, indexname, nvars++);
++ while (testnext(ls, ','))
++ new_localvar(ls, str_checkname(ls), nvars++);
++ checknext(ls, TK_IN);
++ line = ls->linenumber;
++ adjust_assign(ls, 3, explist1(ls, &e), &e);
++ luaK_checkstack(fs, 3); /* extra space to call generator */
++ forbody(ls, base, line, nvars - 3, 0);
++}
++
++
++static void forstat (LexState *ls, int line) {
++ /* forstat -> FOR (fornum | forlist) END */
++ FuncState *fs = ls->fs;
++ TString *varname;
++ BlockCnt bl;
++ enterblock(fs, &bl, 1); /* scope for loop and control variables */
++ luaX_next(ls); /* skip `for' */
++ varname = str_checkname(ls); /* first variable name */
++ switch (ls->t.token) {
++ case '=': fornum(ls, varname, line); break;
++ case ',': case TK_IN: forlist(ls, varname); break;
++ default: luaX_syntaxerror(ls, LUA_QL("=") " or " LUA_QL("in") " expected");
++ }
++ check_match(ls, TK_END, TK_FOR, line);
++ leaveblock(fs); /* loop scope (`break' jumps to this point) */
++}
++
++
++static int test_then_block (LexState *ls) {
++ /* test_then_block -> [IF | ELSEIF] cond THEN block */
++ int condexit;
++ luaX_next(ls); /* skip IF or ELSEIF */
++ condexit = cond(ls);
++ checknext(ls, TK_THEN);
++ block(ls); /* `then' part */
++ return condexit;
++}
++
++
++static void ifstat (LexState *ls, int line) {
++ /* ifstat -> IF cond THEN block {ELSEIF cond THEN block} [ELSE block] END */
++ FuncState *fs = ls->fs;
++ int flist;
++ int escapelist = NO_JUMP;
++ flist = test_then_block(ls); /* IF cond THEN block */
++ while (ls->t.token == TK_ELSEIF) {
++ luaK_concat(fs, &escapelist, luaK_jump(fs));
++ luaK_patchtohere(fs, flist);
++ flist = test_then_block(ls); /* ELSEIF cond THEN block */
++ }
++ if (ls->t.token == TK_ELSE) {
++ luaK_concat(fs, &escapelist, luaK_jump(fs));
++ luaK_patchtohere(fs, flist);
++ luaX_next(ls); /* skip ELSE (after patch, for correct line info) */
++ block(ls); /* `else' part */
++ }
++ else
++ luaK_concat(fs, &escapelist, flist);
++ luaK_patchtohere(fs, escapelist);
++ check_match(ls, TK_END, TK_IF, line);
++}
++
++
++static void localfunc (LexState *ls) {
++ expdesc v, b;
++ FuncState *fs = ls->fs;
++ new_localvar(ls, str_checkname(ls), 0);
++ init_exp(&v, VLOCAL, fs->freereg);
++ luaK_reserveregs(fs, 1);
++ adjustlocalvars(ls, 1);
++ body(ls, &b, 0, ls->linenumber);
++ luaK_storevar(fs, &v, &b);
++ /* debug information will only see the variable after this point! */
++ getlocvar(fs, fs->nactvar - 1).startpc = fs->pc;
++}
++
++
++static void localstat (LexState *ls) {
++ /* stat -> LOCAL NAME {`,' NAME} [`=' explist1] */
++ int nvars = 0;
++ int nexps;
++ expdesc e;
++ do {
++ new_localvar(ls, str_checkname(ls), nvars++);
++ } while (testnext(ls, ','));
++ if (testnext(ls, '='))
++ nexps = explist1(ls, &e);
++ else {
++ e.k = VVOID;
++ nexps = 0;
++ }
++ adjust_assign(ls, nvars, nexps, &e);
++ adjustlocalvars(ls, nvars);
++}
++
++
++static int funcname (LexState *ls, expdesc *v) {
++ /* funcname -> NAME {field} [`:' NAME] */
++ int needself = 0;
++ singlevar(ls, v);
++ while (ls->t.token == '.')
++ field(ls, v);
++ if (ls->t.token == ':') {
++ needself = 1;
++ field(ls, v);
++ }
++ return needself;
++}
++
++
++static void funcstat (LexState *ls, int line) {
++ /* funcstat -> FUNCTION funcname body */
++ int needself;
++ expdesc v, b;
++ luaX_next(ls); /* skip FUNCTION */
++ needself = funcname(ls, &v);
++ body(ls, &b, needself, line);
++ luaK_storevar(ls->fs, &v, &b);
++ luaK_fixline(ls->fs, line); /* definition `happens' in the first line */
++}
++
++
++static void exprstat (LexState *ls) {
++ /* stat -> func | assignment */
++ FuncState *fs = ls->fs;
++ struct LHS_assign v;
++ primaryexp(ls, &v.v);
++ if (v.v.k == VCALL) /* stat -> func */
++ SETARG_C(getcode(fs, &v.v), 1); /* call statement uses no results */
++ else { /* stat -> assignment */
++ v.prev = NULL;
++ assignment(ls, &v, 1);
++ }
++}
++
++
++static void retstat (LexState *ls) {
++ /* stat -> RETURN explist */
++ FuncState *fs = ls->fs;
++ expdesc e;
++ int first, nret; /* registers with returned values */
++ luaX_next(ls); /* skip RETURN */
++ if (block_follow(ls->t.token) || ls->t.token == ';')
++ first = nret = 0; /* return no values */
++ else {
++ nret = explist1(ls, &e); /* optional return values */
++ if (hasmultret(e.k)) {
++ luaK_setmultret(fs, &e);
++ if (e.k == VCALL && nret == 1) { /* tail call? */
++ SET_OPCODE(getcode(fs,&e), OP_TAILCALL);
++ lua_assert(GETARG_A(getcode(fs,&e)) == fs->nactvar);
++ }
++ first = fs->nactvar;
++ nret = LUA_MULTRET; /* return all values */
++ }
++ else {
++ if (nret == 1) /* only one single value? */
++ first = luaK_exp2anyreg(fs, &e);
++ else {
++ luaK_exp2nextreg(fs, &e); /* values must go to the `stack' */
++ first = fs->nactvar; /* return all `active' values */
++ lua_assert(nret == fs->freereg - first);
++ }
++ }
++ }
++ luaK_ret(fs, first, nret);
++}
++
++
++static int statement (LexState *ls) {
++ int line = ls->linenumber; /* may be needed for error messages */
++ switch (ls->t.token) {
++ case TK_IF: { /* stat -> ifstat */
++ ifstat(ls, line);
++ return 0;
++ }
++ case TK_WHILE: { /* stat -> whilestat */
++ whilestat(ls, line);
++ return 0;
++ }
++ case TK_DO: { /* stat -> DO block END */
++ luaX_next(ls); /* skip DO */
++ block(ls);
++ check_match(ls, TK_END, TK_DO, line);
++ return 0;
++ }
++ case TK_FOR: { /* stat -> forstat */
++ forstat(ls, line);
++ return 0;
++ }
++ case TK_REPEAT: { /* stat -> repeatstat */
++ repeatstat(ls, line);
++ return 0;
++ }
++ case TK_FUNCTION: {
++ funcstat(ls, line); /* stat -> funcstat */
++ return 0;
++ }
++ case TK_LOCAL: { /* stat -> localstat */
++ luaX_next(ls); /* skip LOCAL */
++ if (testnext(ls, TK_FUNCTION)) /* local function? */
++ localfunc(ls);
++ else
++ localstat(ls);
++ return 0;
++ }
++ case TK_RETURN: { /* stat -> retstat */
++ retstat(ls);
++ return 1; /* must be last statement */
++ }
++ case TK_BREAK: { /* stat -> breakstat */
++ luaX_next(ls); /* skip BREAK */
++ breakstat(ls);
++ return 1; /* must be last statement */
++ }
++ default: {
++ exprstat(ls);
++ return 0; /* to avoid warnings */
++ }
++ }
++}
++
++
++static void chunk (LexState *ls) {
++ /* chunk -> { stat [`;'] } */
++ int islast = 0;
++ enterlevel(ls);
++ while (!islast && !block_follow(ls->t.token)) {
++ islast = statement(ls);
++ testnext(ls, ';');
++ lua_assert(ls->fs->f->maxstacksize >= ls->fs->freereg &&
++ ls->fs->freereg >= ls->fs->nactvar);
++ ls->fs->freereg = ls->fs->nactvar; /* free registers */
++ }
++ leavelevel(ls);
++}
++
++/* }====================================================================== */
+--- /dev/null
++++ b/extensions/LUA/lua/lparser.h
+@@ -0,0 +1,82 @@
++/*
++** $Id: lparser.h,v 1.57.1.1 2007/12/27 13:02:25 roberto Exp $
++** Lua Parser
++** See Copyright Notice in lua.h
++*/
++
++#ifndef lparser_h
++#define lparser_h
++
++#include "llimits.h"
++#include "lobject.h"
++#include "lzio.h"
++
++
++/*
++** Expression descriptor
++*/
++
++typedef enum {
++ VVOID, /* no value */
++ VNIL,
++ VTRUE,
++ VFALSE,
++ VK, /* info = index of constant in `k' */
++ VKNUM, /* nval = numerical value */
++ VLOCAL, /* info = local register */
++ VUPVAL, /* info = index of upvalue in `upvalues' */
++ VGLOBAL, /* info = index of table; aux = index of global name in `k' */
++ VINDEXED, /* info = table register; aux = index register (or `k') */
++ VJMP, /* info = instruction pc */
++ VRELOCABLE, /* info = instruction pc */
++ VNONRELOC, /* info = result register */
++ VCALL, /* info = instruction pc */
++ VVARARG /* info = instruction pc */
++} expkind;
++
++typedef struct expdesc {
++ expkind k;
++ union {
++ struct { int info, aux; } s;
++ lua_Number nval;
++ } u;
++ int t; /* patch list of `exit when true' */
++ int f; /* patch list of `exit when false' */
++} expdesc;
++
++
++typedef struct upvaldesc {
++ lu_byte k;
++ lu_byte info;
++} upvaldesc;
++
++
++struct BlockCnt; /* defined in lparser.c */
++
++
++/* state needed to generate code for a given function */
++typedef struct FuncState {
++ Proto *f; /* current function header */
++ Table *h; /* table to find (and reuse) elements in `k' */
++ struct FuncState *prev; /* enclosing function */
++ struct LexState *ls; /* lexical state */
++ struct lua_State *L; /* copy of the Lua state */
++ struct BlockCnt *bl; /* chain of current blocks */
++ int pc; /* next position to code (equivalent to `ncode') */
++ int lasttarget; /* `pc' of last `jump target' */
++ int jpc; /* list of pending jumps to `pc' */
++ int freereg; /* first free register */
++ int nk; /* number of elements in `k' */
++ int np; /* number of elements in `p' */
++ short nlocvars; /* number of elements in `locvars' */
++ lu_byte nactvar; /* number of active local variables */
++ upvaldesc upvalues[LUAI_MAXUPVALUES]; /* upvalues */
++ unsigned short actvar[LUAI_MAXVARS]; /* declared-variable stack */
++} FuncState;
++
++
++LUAI_FUNC Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff,
++ const char *name);
++
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/lstate.c
+@@ -0,0 +1,214 @@
++/*
++** $Id: lstate.c,v 2.36.1.2 2008/01/03 15:20:39 roberto Exp $
++** Global State
++** See Copyright Notice in lua.h
++*/
++
++
++#include <stddef.h>
++
++#define lstate_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "ldebug.h"
++#include "ldo.h"
++#include "lfunc.h"
++#include "lgc.h"
++#include "llex.h"
++#include "lmem.h"
++#include "lstate.h"
++#include "lstring.h"
++#include "ltable.h"
++#include "ltm.h"
++
++
++#define state_size(x) (sizeof(x) + LUAI_EXTRASPACE)
++#define fromstate(l) (cast(lu_byte *, (l)) - LUAI_EXTRASPACE)
++#define tostate(l) (cast(lua_State *, cast(lu_byte *, l) + LUAI_EXTRASPACE))
++
++
++/*
++** Main thread combines a thread state and the global state
++*/
++typedef struct LG {
++ lua_State l;
++ global_State g;
++} LG;
++
++
++
++static void stack_init (lua_State *L1, lua_State *L) {
++ /* initialize CallInfo array */
++ L1->base_ci = luaM_newvector(L, BASIC_CI_SIZE, CallInfo);
++ L1->ci = L1->base_ci;
++ L1->size_ci = BASIC_CI_SIZE;
++ L1->end_ci = L1->base_ci + L1->size_ci - 1;
++ /* initialize stack array */
++ L1->stack = luaM_newvector(L, BASIC_STACK_SIZE + EXTRA_STACK, TValue);
++ L1->stacksize = BASIC_STACK_SIZE + EXTRA_STACK;
++ L1->top = L1->stack;
++ L1->stack_last = L1->stack+(L1->stacksize - EXTRA_STACK)-1;
++ /* initialize first ci */
++ L1->ci->func = L1->top;
++ setnilvalue(L1->top++); /* `function' entry for this `ci' */
++ L1->base = L1->ci->base = L1->top;
++ L1->ci->top = L1->top + LUA_MINSTACK;
++}
++
++
++static void freestack (lua_State *L, lua_State *L1) {
++ luaM_freearray(L, L1->base_ci, L1->size_ci, CallInfo);
++ luaM_freearray(L, L1->stack, L1->stacksize, TValue);
++}
++
++
++/*
++** open parts that may cause memory-allocation errors
++*/
++static void f_luaopen (lua_State *L, void *ud) {
++ global_State *g = G(L);
++ UNUSED(ud);
++ stack_init(L, L); /* init stack */
++ sethvalue(L, gt(L), luaH_new(L, 0, 2)); /* table of globals */
++ sethvalue(L, registry(L), luaH_new(L, 0, 2)); /* registry */
++ luaS_resize(L, MINSTRTABSIZE); /* initial size of string table */
++ luaT_init(L);
++ luaX_init(L);
++ luaS_fix(luaS_newliteral(L, MEMERRMSG));
++ g->GCthreshold = 4*g->totalbytes;
++}
++
++
++static void preinit_state (lua_State *L, global_State *g) {
++ G(L) = g;
++ L->stack = NULL;
++ L->stacksize = 0;
++ L->errorJmp = NULL;
++ L->hook = NULL;
++ L->hookmask = 0;
++ L->basehookcount = 0;
++ L->allowhook = 1;
++ resethookcount(L);
++ L->openupval = NULL;
++ L->size_ci = 0;
++ L->nCcalls = L->baseCcalls = 0;
++ L->status = 0;
++ L->base_ci = L->ci = NULL;
++ L->savedpc = NULL;
++ L->errfunc = 0;
++ setnilvalue(gt(L));
++}
++
++
++static void close_state (lua_State *L) {
++ global_State *g = G(L);
++ luaF_close(L, L->stack); /* close all upvalues for this thread */
++ luaC_freeall(L); /* collect all objects */
++ lua_assert(g->rootgc == obj2gco(L));
++ lua_assert(g->strt.nuse == 0);
++ luaM_freearray(L, G(L)->strt.hash, G(L)->strt.size, TString *);
++ luaZ_freebuffer(L, &g->buff);
++ freestack(L, L);
++ lua_assert(g->totalbytes == sizeof(LG));
++ (*g->frealloc)(g->ud, fromstate(L), state_size(LG), 0);
++}
++
++
++lua_State *luaE_newthread (lua_State *L) {
++ lua_State *L1 = tostate(luaM_malloc(L, state_size(lua_State)));
++ luaC_link(L, obj2gco(L1), LUA_TTHREAD);
++ preinit_state(L1, G(L));
++ stack_init(L1, L); /* init stack */
++ setobj2n(L, gt(L1), gt(L)); /* share table of globals */
++ L1->hookmask = L->hookmask;
++ L1->basehookcount = L->basehookcount;
++ L1->hook = L->hook;
++ resethookcount(L1);
++ lua_assert(iswhite(obj2gco(L1)));
++ return L1;
++}
++
++
++void luaE_freethread (lua_State *L, lua_State *L1) {
++ luaF_close(L1, L1->stack); /* close all upvalues for this thread */
++ lua_assert(L1->openupval == NULL);
++ luai_userstatefree(L1);
++ freestack(L, L1);
++ luaM_freemem(L, fromstate(L1), state_size(lua_State));
++}
++
++
++LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) {
++ int i;
++ lua_State *L;
++ global_State *g;
++ void *l = (*f)(ud, NULL, 0, state_size(LG));
++ if (l == NULL) return NULL;
++ L = tostate(l);
++ g = &((LG *)L)->g;
++ L->next = NULL;
++ L->tt = LUA_TTHREAD;
++ g->currentwhite = bit2mask(WHITE0BIT, FIXEDBIT);
++ L->marked = luaC_white(g);
++ set2bits(L->marked, FIXEDBIT, SFIXEDBIT);
++ preinit_state(L, g);
++ g->frealloc = f;
++ g->ud = ud;
++ g->mainthread = L;
++ g->uvhead.u.l.prev = &g->uvhead;
++ g->uvhead.u.l.next = &g->uvhead;
++ g->GCthreshold = 0; /* mark it as unfinished state */
++ g->strt.size = 0;
++ g->strt.nuse = 0;
++ g->strt.hash = NULL;
++ setnilvalue(registry(L));
++ luaZ_initbuffer(L, &g->buff);
++ g->panic = NULL;
++ g->gcstate = GCSpause;
++ g->rootgc = obj2gco(L);
++ g->sweepstrgc = 0;
++ g->sweepgc = &g->rootgc;
++ g->gray = NULL;
++ g->grayagain = NULL;
++ g->weak = NULL;
++ g->tmudata = NULL;
++ g->totalbytes = sizeof(LG);
++ g->gcpause = LUAI_GCPAUSE;
++ g->gcstepmul = LUAI_GCMUL;
++ g->gcdept = 0;
++ for (i=0; i<NUM_TAGS; i++) g->mt[i] = NULL;
++ if (luaD_rawrunprotected(L, f_luaopen, NULL) != 0) {
++ /* memory allocation error: free partial state */
++ close_state(L);
++ L = NULL;
++ }
++ else
++ luai_userstateopen(L);
++ return L;
++}
++
++
++static void callallgcTM (lua_State *L, void *ud) {
++ UNUSED(ud);
++ luaC_callGCTM(L); /* call GC metamethods for all udata */
++}
++
++
++LUA_API void lua_close (lua_State *L) {
++ L = G(L)->mainthread; /* only the main thread can be closed */
++ lua_lock(L);
++ luaF_close(L, L->stack); /* close all upvalues for this thread */
++ luaC_separateudata(L, 1); /* separate udata that have GC metamethods */
++ L->errfunc = 0; /* no error function during GC metamethods */
++ do { /* repeat until no more errors */
++ L->ci = L->base_ci;
++ L->base = L->top = L->ci->base;
++ L->nCcalls = L->baseCcalls = 0;
++ } while (luaD_rawrunprotected(L, callallgcTM, NULL) != 0);
++ lua_assert(G(L)->tmudata == NULL);
++ luai_userstateclose(L);
++ close_state(L);
++}
++
+--- /dev/null
++++ b/extensions/LUA/lua/lstate.h
+@@ -0,0 +1,169 @@
++/*
++** $Id: lstate.h,v 2.24.1.2 2008/01/03 15:20:39 roberto Exp $
++** Global State
++** See Copyright Notice in lua.h
++*/
++
++#ifndef lstate_h
++#define lstate_h
++
++#include "lua.h"
++
++#include "lobject.h"
++#include "ltm.h"
++#include "lzio.h"
++
++
++
++struct lua_longjmp; /* defined in ldo.c */
++
++
++/* table of globals */
++#define gt(L) (&L->l_gt)
++
++/* registry */
++#define registry(L) (&G(L)->l_registry)
++
++
++/* extra stack space to handle TM calls and some other extras */
++#define EXTRA_STACK 5
++
++
++#define BASIC_CI_SIZE 8
++
++#define BASIC_STACK_SIZE (2*LUA_MINSTACK)
++
++
++
++typedef struct stringtable {
++ GCObject **hash;
++ lu_int32 nuse; /* number of elements */
++ int size;
++} stringtable;
++
++
++/*
++** informations about a call
++*/
++typedef struct CallInfo {
++ StkId base; /* base for this function */
++ StkId func; /* function index in the stack */
++ StkId top; /* top for this function */
++ const Instruction *savedpc;
++ int nresults; /* expected number of results from this function */
++ int tailcalls; /* number of tail calls lost under this entry */
++} CallInfo;
++
++
++
++#define curr_func(L) (clvalue(L->ci->func))
++#define ci_func(ci) (clvalue((ci)->func))
++#define f_isLua(ci) (!ci_func(ci)->c.isC)
++#define isLua(ci) (ttisfunction((ci)->func) && f_isLua(ci))
++
++
++/*
++** `global state', shared by all threads of this state
++*/
++typedef struct global_State {
++ stringtable strt; /* hash table for strings */
++ lua_Alloc frealloc; /* function to reallocate memory */
++ void *ud; /* auxiliary data to `frealloc' */
++ lu_byte currentwhite;
++ lu_byte gcstate; /* state of garbage collector */
++ int sweepstrgc; /* position of sweep in `strt' */
++ GCObject *rootgc; /* list of all collectable objects */
++ GCObject **sweepgc; /* position of sweep in `rootgc' */
++ GCObject *gray; /* list of gray objects */
++ GCObject *grayagain; /* list of objects to be traversed atomically */
++ GCObject *weak; /* list of weak tables (to be cleared) */
++ GCObject *tmudata; /* last element of list of userdata to be GC */
++ Mbuffer buff; /* temporary buffer for string concatentation */
++ lu_mem GCthreshold;
++ lu_mem totalbytes; /* number of bytes currently allocated */
++ lu_mem estimate; /* an estimate of number of bytes actually in use */
++ lu_mem gcdept; /* how much GC is `behind schedule' */
++ int gcpause; /* size of pause between successive GCs */
++ int gcstepmul; /* GC `granularity' */
++ lua_CFunction panic; /* to be called in unprotected errors */
++ TValue l_registry;
++ struct lua_State *mainthread;
++ UpVal uvhead; /* head of double-linked list of all open upvalues */
++ struct Table *mt[NUM_TAGS]; /* metatables for basic types */
++ TString *tmname[TM_N]; /* array with tag-method names */
++} global_State;
++
++
++/*
++** `per thread' state
++*/
++struct lua_State {
++ CommonHeader;
++ lu_byte status;
++ StkId top; /* first free slot in the stack */
++ StkId base; /* base of current function */
++ global_State *l_G;
++ CallInfo *ci; /* call info for current function */
++ const Instruction *savedpc; /* `savedpc' of current function */
++ StkId stack_last; /* last free slot in the stack */
++ StkId stack; /* stack base */
++ CallInfo *end_ci; /* points after end of ci array*/
++ CallInfo *base_ci; /* array of CallInfo's */
++ int stacksize;
++ int size_ci; /* size of array `base_ci' */
++ unsigned short nCcalls; /* number of nested C calls */
++ unsigned short baseCcalls; /* nested C calls when resuming coroutine */
++ lu_byte hookmask;
++ lu_byte allowhook;
++ int basehookcount;
++ int hookcount;
++ lua_Hook hook;
++ TValue l_gt; /* table of globals */
++ TValue env; /* temporary place for environments */
++ GCObject *openupval; /* list of open upvalues in this stack */
++ GCObject *gclist;
++ struct lua_longjmp *errorJmp; /* current error recover point */
++ ptrdiff_t errfunc; /* current error handling function (stack index) */
++};
++
++
++#define G(L) (L->l_G)
++
++
++/*
++** Union of all collectable objects
++*/
++union GCObject {
++ GCheader gch;
++ union TString ts;
++ union Udata u;
++ union Closure cl;
++ struct Table h;
++ struct Proto p;
++ struct UpVal uv;
++ struct lua_State th; /* thread */
++};
++
++
++/* macros to convert a GCObject into a specific value */
++#define rawgco2ts(o) check_exp((o)->gch.tt == LUA_TSTRING, &((o)->ts))
++#define gco2ts(o) (&rawgco2ts(o)->tsv)
++#define rawgco2u(o) check_exp((o)->gch.tt == LUA_TUSERDATA, &((o)->u))
++#define gco2u(o) (&rawgco2u(o)->uv)
++#define gco2cl(o) check_exp((o)->gch.tt == LUA_TFUNCTION, &((o)->cl))
++#define gco2h(o) check_exp((o)->gch.tt == LUA_TTABLE, &((o)->h))
++#define gco2p(o) check_exp((o)->gch.tt == LUA_TPROTO, &((o)->p))
++#define gco2uv(o) check_exp((o)->gch.tt == LUA_TUPVAL, &((o)->uv))
++#define ngcotouv(o) \
++ check_exp((o) == NULL || (o)->gch.tt == LUA_TUPVAL, &((o)->uv))
++#define gco2th(o) check_exp((o)->gch.tt == LUA_TTHREAD, &((o)->th))
++
++/* macro to convert any Lua object into a GCObject */
++#define obj2gco(v) (cast(GCObject *, (v)))
++
++
++LUAI_FUNC lua_State *luaE_newthread (lua_State *L);
++LUAI_FUNC void luaE_freethread (lua_State *L, lua_State *L1);
++
++#endif
++
+--- /dev/null
++++ b/extensions/LUA/lua/lstring.c
+@@ -0,0 +1,110 @@
++/*
++** $Id: lstring.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $
++** String table (keeps all strings handled by Lua)
++** See Copyright Notice in lua.h
++*/
++
++#include <string.h>
++
++#define lstring_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "lmem.h"
++#include "lobject.h"
++#include "lstate.h"
++#include "lstring.h"
++
++
++
++void luaS_resize (lua_State *L, int newsize) {
++ GCObject **newhash;
++ stringtable *tb;
++ int i;
++ if (G(L)->gcstate == GCSsweepstring)
++ return; /* cannot resize during GC traverse */
++ newhash = luaM_newvector(L, newsize, GCObject *);
++ tb = &G(L)->strt;
++ for (i=0; i<newsize; i++) newhash[i] = NULL;
++ /* rehash */
++ for (i=0; i<tb->size; i++) {
++ GCObject *p = tb->hash[i];
++ while (p) { /* for each node in the list */
++ GCObject *next = p->gch.next; /* save next */
++ unsigned int h = gco2ts(p)->hash;
++ int h1 = lmod(h, newsize); /* new position */
++ lua_assert(cast_int(h%newsize) == lmod(h, newsize));
++ p->gch.next = newhash[h1]; /* chain it */
++ newhash[h1] = p;
++ p = next;
++ }
++ }
++ luaM_freearray(L, tb->hash, tb->size, TString *);
++ tb->size = newsize;
++ tb->hash = newhash;
++}
++
++
++static TString *newlstr (lua_State *L, const char *str, size_t l,
++ unsigned int h) {
++ TString *ts;
++ stringtable *tb;
++ if (l+1 > (MAX_SIZET - sizeof(TString))/sizeof(char))
++ luaM_toobig(L);
++ ts = cast(TString *, luaM_malloc(L, (l+1)*sizeof(char)+sizeof(TString)));
++ ts->tsv.len = l;
++ ts->tsv.hash = h;
++ ts->tsv.marked = luaC_white(G(L));
++ ts->tsv.tt = LUA_TSTRING;
++ ts->tsv.reserved = 0;
++ memcpy(ts+1, str, l*sizeof(char));
++ ((char *)(ts+1))[l] = '\0'; /* ending 0 */
++ tb = &G(L)->strt;
++ h = lmod(h, tb->size);
++ ts->tsv.next = tb->hash[h]; /* chain new entry */
++ tb->hash[h] = obj2gco(ts);
++ tb->nuse++;
++ if (tb->nuse > cast(lu_int32, tb->size) && tb->size <= MAX_INT/2)
++ luaS_resize(L, tb->size*2); /* too crowded */
++ return ts;
++}
++
++
++TString *luaS_newlstr (lua_State *L, const char *str, size_t l) {
++ GCObject *o;
++ unsigned int h = cast(unsigned int, l); /* seed */
++ size_t step = (l>>5)+1; /* if string is too long, don't hash all its chars */
++ size_t l1;
++ for (l1=l; l1>=step; l1-=step) /* compute hash */
++ h = h ^ ((h<<5)+(h>>2)+cast(unsigned char, str[l1-1]));
++ for (o = G(L)->strt.hash[lmod(h, G(L)->strt.size)];
++ o != NULL;
++ o = o->gch.next) {
++ TString *ts = rawgco2ts(o);
++ if (ts->tsv.len == l && (memcmp(str, getstr(ts), l) == 0)) {
++ /* string may be dead */
++ if (isdead(G(L), o)) changewhite(o);
++ return ts;
++ }
++ }
++ return newlstr(L, str, l, h); /* not found */
++}
++
++
++Udata *luaS_newudata (lua_State *L, size_t s, Table *e) {
++ Udata *u;
++ if (s > MAX_SIZET - sizeof(Udata))
++ luaM_toobig(L);
++ u = cast(Udata *, luaM_malloc(L, s + sizeof(Udata)));
++ u->uv.marked = luaC_white(G(L)); /* is not finalized */
++ u->uv.tt = LUA_TUSERDATA;
++ u->uv.len = s;
++ u->uv.metatable = NULL;
++ u->uv.env = e;
++ /* chain it on udata list (after main thread) */
++ u->uv.next = G(L)->mainthread->next;
++ G(L)->mainthread->next = obj2gco(u);
++ return u;
++}
++
+--- /dev/null
++++ b/extensions/LUA/lua/lstring.h
+@@ -0,0 +1,31 @@
++/*
++** $Id: lstring.h,v 1.43.1.1 2007/12/27 13:02:25 roberto Exp $
++** String table (keep all strings handled by Lua)
++** See Copyright Notice in lua.h
++*/
++
++#ifndef lstring_h
++#define lstring_h
++
++
++#include "lgc.h"
++#include "lobject.h"
++#include "lstate.h"
++
++
++#define sizestring(s) (sizeof(union TString)+((s)->len+1)*sizeof(char))
++
++#define sizeudata(u) (sizeof(union Udata)+(u)->len)
++
++#define luaS_new(L, s) (luaS_newlstr(L, s, strlen(s)))
++#define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \
++ (sizeof(s)/sizeof(char))-1))
++
++#define luaS_fix(s) l_setbit((s)->tsv.marked, FIXEDBIT)
++
++LUAI_FUNC void luaS_resize (lua_State *L, int newsize);
++LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, Table *e);
++LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l);
++
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/lstrlib.c
+@@ -0,0 +1,883 @@
++/*
++** $Id: lstrlib.c,v 1.132.1.4 2008/07/11 17:27:21 roberto Exp $
++** Standard library for string operations and pattern-matching
++** See Copyright Notice in lua.h
++*/
++
++
++#include <ctype.h>
++#include <stddef.h>
++#include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
++
++#define lstrlib_c
++#define LUA_LIB
++
++#include "lua.h"
++
++#include "lauxlib.h"
++#include "lualib.h"
++
++
++/* macro to `unsign' a character */
++#define uchar(c) ((unsigned char)(c))
++
++
++
++static int str_len (lua_State *L) {
++ size_t l;
++ luaL_checklstring(L, 1, &l);
++ lua_pushinteger(L, l);
++ return 1;
++}
++
++
++static ptrdiff_t posrelat (ptrdiff_t pos, size_t len) {
++ /* relative string position: negative means back from end */
++ if (pos < 0) pos += (ptrdiff_t)len + 1;
++ return (pos >= 0) ? pos : 0;
++}
++
++
++static int str_sub (lua_State *L) {
++ size_t l;
++ const char *s = luaL_checklstring(L, 1, &l);
++ ptrdiff_t start = posrelat(luaL_checkinteger(L, 2), l);
++ ptrdiff_t end = posrelat(luaL_optinteger(L, 3, -1), l);
++ if (start < 1) start = 1;
++ if (end > (ptrdiff_t)l) end = (ptrdiff_t)l;
++ if (start <= end)
++ lua_pushlstring(L, s+start-1, end-start+1);
++ else lua_pushliteral(L, "");
++ return 1;
++}
++
++
++static int str_reverse (lua_State *L) {
++ size_t l;
++ const char *s = luaL_checklstring(L, 1, &l);
++ luaL_Buffer *b = (luaL_Buffer *)kmalloc(sizeof(luaL_Buffer) + BUFSIZ, GFP_ATOMIC);
++ if(!b) luaL_error(L, "str_reverse: cannot allocate memory");
++ luaL_buffinit(L, b);
++ while (l--) luaL_addchar(b, s[l]);
++ luaL_pushresult(b);
++ kfree(b);
++ return 1;
++}
++
++
++static int str_lower (lua_State *L) {
++ size_t l;
++ size_t i;
++ const char *s = luaL_checklstring(L, 1, &l);
++ luaL_Buffer *b = (luaL_Buffer *)kmalloc(sizeof(luaL_Buffer) + BUFSIZ, GFP_ATOMIC);
++ if(!b) luaL_error(L, "str_lower: cannot allocate memory");
++ luaL_buffinit(L, b);
++ for (i=0; i<l; i++)
++ luaL_addchar(b, tolower(uchar(s[i])));
++ luaL_pushresult(b);
++ kfree(b);
++ return 1;
++}
++
++
++static int str_upper (lua_State *L) {
++ size_t l;
++ size_t i;
++ const char *s = luaL_checklstring(L, 1, &l);
++ luaL_Buffer *b = (luaL_Buffer *)kmalloc(sizeof(luaL_Buffer) + BUFSIZ, GFP_ATOMIC);
++ if(!b) luaL_error(L, "str_upper: cannot allocate memory");
++ luaL_buffinit(L, b);
++ for (i=0; i<l; i++)
++ luaL_addchar(b, toupper(uchar(s[i])));
++ luaL_pushresult(b);
++ kfree(b);
++ return 1;
++}
++
++static int str_rep (lua_State *L) {
++ size_t l;
++ const char *s = luaL_checklstring(L, 1, &l);
++ int n = luaL_checkint(L, 2);
++ luaL_Buffer *b = (luaL_Buffer *)kmalloc(sizeof(luaL_Buffer) + BUFSIZ, GFP_ATOMIC);
++ if(!b) luaL_error(L, "str_rep: cannot allocate memory");
++ luaL_buffinit(L, b);
++ while (n-- > 0)
++ luaL_addlstring(b, s, l);
++ luaL_pushresult(b);
++ kfree(b);
++ return 1;
++}
++
++
++static int str_byte (lua_State *L) {
++ size_t l;
++ const char *s = luaL_checklstring(L, 1, &l);
++ ptrdiff_t posi = posrelat(luaL_optinteger(L, 2, 1), l);
++ ptrdiff_t pose = posrelat(luaL_optinteger(L, 3, posi), l);
++ int n, i;
++ if (posi <= 0) posi = 1;
++ if ((size_t)pose > l) pose = l;
++ if (posi > pose) return 0; /* empty interval; return no values */
++ n = (int)(pose - posi + 1);
++ if (posi + n <= pose) /* overflow? */
++ luaL_error(L, "string slice too long");
++ luaL_checkstack(L, n, "string slice too long");
++ for (i=0; i<n; i++)
++ lua_pushinteger(L, uchar(s[posi+i-1]));
++ return n;
++}
++
++
++static int str_char (lua_State *L) {
++ int n = lua_gettop(L); /* number of arguments */
++ int i;
++ luaL_Buffer *b = (luaL_Buffer *)kmalloc(sizeof(luaL_Buffer) + BUFSIZ, GFP_ATOMIC);
++ if(!b) luaL_error(L, "str_char: cannot allocate memory");
++ luaL_buffinit(L, b);
++ for (i=1; i<=n; i++) {
++ int c = luaL_checkint(L, i);
++ luaL_argcheck(L, uchar(c) == c, i, "invalid value");
++ luaL_addchar(b, uchar(c));
++ }
++ luaL_pushresult(b);
++ kfree(b);
++ return 1;
++}
++
++
++static int writer (lua_State *L, const void* b, size_t size, void* B) {
++ (void)L;
++ luaL_addlstring((luaL_Buffer*) B, (const char *)b, size);
++ return 0;
++}
++
++
++static int str_dump (lua_State *L) {
++ luaL_Buffer *b = (luaL_Buffer *)kmalloc(sizeof(luaL_Buffer) + BUFSIZ, GFP_ATOMIC);
++ if(!b) luaL_error(L, "str_dump: cannot allocate memory");
++ luaL_checktype(L, 1, LUA_TFUNCTION);
++ lua_settop(L, 1);
++ luaL_buffinit(L,b);
++ if (lua_dump(L, writer, b) != 0){
++ kfree(b);
++ luaL_error(L, "unable to dump given function");
++ }
++
++ luaL_pushresult(b);
++ kfree(b);
++ return 1;
++}
++
++
++
++/*
++** {======================================================
++** PATTERN MATCHING
++** =======================================================
++*/
++
++
++#define CAP_UNFINISHED (-1)
++#define CAP_POSITION (-2)
++
++typedef struct MatchState {
++ const char *src_init; /* init of source string */
++ const char *src_end; /* end (`\0') of source string */
++ lua_State *L;
++ int level; /* total number of captures (finished or unfinished) */
++ struct {
++ const char *init;
++ ptrdiff_t len;
++ } capture[LUA_MAXCAPTURES];
++} MatchState;
++
++
++#define L_ESC '%'
++#define SPECIALS "^$*+?.([%-"
++
++
++static int check_capture (MatchState *ms, int l) {
++ l -= '1';
++ if (l < 0 || l >= ms->level || ms->capture[l].len == CAP_UNFINISHED)
++ return luaL_error(ms->L, "invalid capture index");
++ return l;
++}
++
++
++static int capture_to_close (MatchState *ms) {
++ int level = ms->level;
++ for (level--; level>=0; level--)
++ if (ms->capture[level].len == CAP_UNFINISHED) return level;
++ return luaL_error(ms->L, "invalid pattern capture");
++}
++
++
++static const char *classend (MatchState *ms, const char *p) {
++ switch (*p++) {
++ case L_ESC: {
++ if (*p == '\0')
++ luaL_error(ms->L, "malformed pattern (ends with " LUA_QL("%%") ")");
++ return p+1;
++ }
++ case '[': {
++ if (*p == '^') p++;
++ do { /* look for a `]' */
++ if (*p == '\0')
++ luaL_error(ms->L, "malformed pattern (missing " LUA_QL("]") ")");
++ if (*(p++) == L_ESC && *p != '\0')
++ p++; /* skip escapes (e.g. `%]') */
++ } while (*p != ']');
++ return p+1;
++ }
++ default: {
++ return p;
++ }
++ }
++}
++
++
++static int match_class (int c, int cl) {
++ int res;
++ switch (tolower(cl)) {
++ case 'a' : res = isalpha(c); break;
++ case 'c' : res = iscntrl(c); break;
++ case 'd' : res = isdigit(c); break;
++ case 'l' : res = islower(c); break;
++ case 'p' : res = ispunct(c); break;
++ case 's' : res = isspace(c); break;
++ case 'u' : res = isupper(c); break;
++ case 'w' : res = isalnum(c); break;
++ case 'x' : res = isxdigit(c); break;
++ case 'z' : res = (c == 0); break;
++ default: return (cl == c);
++ }
++ return (islower(cl) ? res : !res);
++}
++
++
++static int matchbracketclass (int c, const char *p, const char *ec) {
++ int sig = 1;
++ if (*(p+1) == '^') {
++ sig = 0;
++ p++; /* skip the `^' */
++ }
++ while (++p < ec) {
++ if (*p == L_ESC) {
++ p++;
++ if (match_class(c, uchar(*p)))
++ return sig;
++ }
++ else if ((*(p+1) == '-') && (p+2 < ec)) {
++ p+=2;
++ if (uchar(*(p-2)) <= c && c <= uchar(*p))
++ return sig;
++ }
++ else if (uchar(*p) == c) return sig;
++ }
++ return !sig;
++}
++
++
++static int singlematch (int c, const char *p, const char *ep) {
++ switch (*p) {
++ case '.': return 1; /* matches any char */
++ case L_ESC: return match_class(c, uchar(*(p+1)));
++ case '[': return matchbracketclass(c, p, ep-1);
++ default: return (uchar(*p) == c);
++ }
++}
++
++
++static const char *match (MatchState *ms, const char *s, const char *p);
++
++
++static const char *matchbalance (MatchState *ms, const char *s,
++ const char *p) {
++ if (*p == 0 || *(p+1) == 0)
++ luaL_error(ms->L, "unbalanced pattern");
++ if (*s != *p) return NULL;
++ else {
++ int b = *p;
++ int e = *(p+1);
++ int cont = 1;
++ while (++s < ms->src_end) {
++ if (*s == e) {
++ if (--cont == 0) return s+1;
++ }
++ else if (*s == b) cont++;
++ }
++ }
++ return NULL; /* string ends out of balance */
++}
++
++
++static const char *max_expand (MatchState *ms, const char *s,
++ const char *p, const char *ep) {
++ ptrdiff_t i = 0; /* counts maximum expand for item */
++ while ((s+i)<ms->src_end && singlematch(uchar(*(s+i)), p, ep))
++ i++;
++ /* keeps trying to match with the maximum repetitions */
++ while (i>=0) {
++ const char *res = match(ms, (s+i), ep+1);
++ if (res) return res;
++ i--; /* else didn't match; reduce 1 repetition to try again */
++ }
++ return NULL;
++}
++
++
++static const char *min_expand (MatchState *ms, const char *s,
++ const char *p, const char *ep) {
++ for (;;) {
++ const char *res = match(ms, s, ep+1);
++ if (res != NULL)
++ return res;
++ else if (s<ms->src_end && singlematch(uchar(*s), p, ep))
++ s++; /* try with one more repetition */
++ else return NULL;
++ }
++}
++
++
++static const char *start_capture (MatchState *ms, const char *s,
++ const char *p, int what) {
++ const char *res;
++ int level = ms->level;
++ if (level >= LUA_MAXCAPTURES) luaL_error(ms->L, "too many captures");
++ ms->capture[level].init = s;
++ ms->capture[level].len = what;
++ ms->level = level+1;
++ if ((res=match(ms, s, p)) == NULL) /* match failed? */
++ ms->level--; /* undo capture */
++ return res;
++}
++
++
++static const char *end_capture (MatchState *ms, const char *s,
++ const char *p) {
++ int l = capture_to_close(ms);
++ const char *res;
++ ms->capture[l].len = s - ms->capture[l].init; /* close capture */
++ if ((res = match(ms, s, p)) == NULL) /* match failed? */
++ ms->capture[l].len = CAP_UNFINISHED; /* undo capture */
++ return res;
++}
++
++
++static const char *match_capture (MatchState *ms, const char *s, int l) {
++ size_t len;
++ l = check_capture(ms, l);
++ len = ms->capture[l].len;
++ if ((size_t)(ms->src_end-s) >= len &&
++ memcmp(ms->capture[l].init, s, len) == 0)
++ return s+len;
++ else return NULL;
++}
++
++
++static const char *match (MatchState *ms, const char *s, const char *p) {
++ init: /* using goto's to optimize tail recursion */
++ switch (*p) {
++ case '(': { /* start capture */
++ if (*(p+1) == ')') /* position capture? */
++ return start_capture(ms, s, p+2, CAP_POSITION);
++ else
++ return start_capture(ms, s, p+1, CAP_UNFINISHED);
++ }
++ case ')': { /* end capture */
++ return end_capture(ms, s, p+1);
++ }
++ case L_ESC: {
++ switch (*(p+1)) {
++ case 'b': { /* balanced string? */
++ s = matchbalance(ms, s, p+2);
++ if (s == NULL) return NULL;
++ p+=4; goto init; /* else return match(ms, s, p+4); */
++ }
++ case 'f': { /* frontier? */
++ const char *ep; char previous;
++ p += 2;
++ if (*p != '[')
++ luaL_error(ms->L, "missing " LUA_QL("[") " after "
++ LUA_QL("%%f") " in pattern");
++ ep = classend(ms, p); /* points to what is next */
++ previous = (s == ms->src_init) ? '\0' : *(s-1);
++ if (matchbracketclass(uchar(previous), p, ep-1) ||
++ !matchbracketclass(uchar(*s), p, ep-1)) return NULL;
++ p=ep; goto init; /* else return match(ms, s, ep); */
++ }
++ default: {
++ if (isdigit(uchar(*(p+1)))) { /* capture results (%0-%9)? */
++ s = match_capture(ms, s, uchar(*(p+1)));
++ if (s == NULL) return NULL;
++ p+=2; goto init; /* else return match(ms, s, p+2) */
++ }
++ goto dflt; /* case default */
++ }
++ }
++ }
++ case '\0': { /* end of pattern */
++ return s; /* match succeeded */
++ }
++ case '$': {
++ if (*(p+1) == '\0') /* is the `$' the last char in pattern? */
++ return (s == ms->src_end) ? s : NULL; /* check end of string */
++ else goto dflt;
++ }
++ default: dflt: { /* it is a pattern item */
++ const char *ep = classend(ms, p); /* points to what is next */
++ int m = s<ms->src_end && singlematch(uchar(*s), p, ep);
++ switch (*ep) {
++ case '?': { /* optional */
++ const char *res;
++ if (m && ((res=match(ms, s+1, ep+1)) != NULL))
++ return res;
++ p=ep+1; goto init; /* else return match(ms, s, ep+1); */
++ }
++ case '*': { /* 0 or more repetitions */
++ return max_expand(ms, s, p, ep);
++ }
++ case '+': { /* 1 or more repetitions */
++ return (m ? max_expand(ms, s+1, p, ep) : NULL);
++ }
++ case '-': { /* 0 or more repetitions (minimum) */
++ return min_expand(ms, s, p, ep);
++ }
++ default: {
++ if (!m) return NULL;
++ s++; p=ep; goto init; /* else return match(ms, s+1, ep); */
++ }
++ }
++ }
++ }
++}
++
++
++
++static const char *lmemfind (const char *s1, size_t l1,
++ const char *s2, size_t l2) {
++ if (l2 == 0) return s1; /* empty strings are everywhere */
++ else if (l2 > l1) return NULL; /* avoids a negative `l1' */
++ else {
++ const char *init; /* to search for a `*s2' inside `s1' */
++ l2--; /* 1st char will be checked by `memchr' */
++ l1 = l1-l2; /* `s2' cannot be found after that */
++ while (l1 > 0 && (init = (const char *)memchr(s1, *s2, l1)) != NULL) {
++ init++; /* 1st char is already checked */
++ if (memcmp(init, s2+1, l2) == 0)
++ return init-1;
++ else { /* correct `l1' and `s1' to try again */
++ l1 -= init-s1;
++ s1 = init;
++ }
++ }
++ return NULL; /* not found */
++ }
++}
++
++
++static void push_onecapture (MatchState *ms, int i, const char *s,
++ const char *e) {
++ if (i >= ms->level) {
++ if (i == 0) /* ms->level == 0, too */
++ lua_pushlstring(ms->L, s, e - s); /* add whole match */
++ else
++ luaL_error(ms->L, "invalid capture index");
++ }
++ else {
++ ptrdiff_t l = ms->capture[i].len;
++ if (l == CAP_UNFINISHED) luaL_error(ms->L, "unfinished capture");
++ if (l == CAP_POSITION)
++ lua_pushinteger(ms->L, ms->capture[i].init - ms->src_init + 1);
++ else
++ lua_pushlstring(ms->L, ms->capture[i].init, l);
++ }
++}
++
++
++static int push_captures (MatchState *ms, const char *s, const char *e) {
++ int i;
++ int nlevels = (ms->level == 0 && s) ? 1 : ms->level;
++ luaL_checkstack(ms->L, nlevels, "too many captures");
++ for (i = 0; i < nlevels; i++)
++ push_onecapture(ms, i, s, e);
++ return nlevels; /* number of strings pushed */
++}
++
++
++static int str_find_aux (lua_State *L, int find) {
++ size_t l1, l2;
++ const char *s = luaL_checklstring(L, 1, &l1);
++ const char *p = luaL_checklstring(L, 2, &l2);
++ ptrdiff_t init = posrelat(luaL_optinteger(L, 3, 1), l1) - 1;
++ if (init < 0) init = 0;
++ else if ((size_t)(init) > l1) init = (ptrdiff_t)l1;
++ if (find && (lua_toboolean(L, 4) || /* explicit request? */
++ strpbrk(p, SPECIALS) == NULL)) { /* or no special characters? */
++ /* do a plain search */
++ const char *s2 = lmemfind(s+init, l1-init, p, l2);
++ if (s2) {
++ lua_pushinteger(L, s2-s+1);
++ lua_pushinteger(L, s2-s+l2);
++ return 2;
++ }
++ }
++ else {
++ MatchState ms;
++ int anchor = (*p == '^') ? (p++, 1) : 0;
++ const char *s1=s+init;
++ ms.L = L;
++ ms.src_init = s;
++ ms.src_end = s+l1;
++ do {
++ const char *res;
++ ms.level = 0;
++ if ((res=match(&ms, s1, p)) != NULL) {
++ if (find) {
++ lua_pushinteger(L, s1-s+1); /* start */
++ lua_pushinteger(L, res-s); /* end */
++ return push_captures(&ms, NULL, 0) + 2;
++ }
++ else
++ return push_captures(&ms, s1, res);
++ }
++ } while (s1++ < ms.src_end && !anchor);
++ }
++ lua_pushnil(L); /* not found */
++ return 1;
++}
++
++
++static int str_find (lua_State *L) {
++ return str_find_aux(L, 1);
++}
++
++
++static int str_match (lua_State *L) {
++ return str_find_aux(L, 0);
++}
++
++
++static int gmatch_aux (lua_State *L) {
++ MatchState ms;
++ size_t ls;
++ const char *s = lua_tolstring(L, lua_upvalueindex(1), &ls);
++ const char *p = lua_tostring(L, lua_upvalueindex(2));
++ const char *src;
++ ms.L = L;
++ ms.src_init = s;
++ ms.src_end = s+ls;
++ for (src = s + (size_t)lua_tointeger(L, lua_upvalueindex(3));
++ src <= ms.src_end;
++ src++) {
++ const char *e;
++ ms.level = 0;
++ if ((e = match(&ms, src, p)) != NULL) {
++ lua_Integer newstart = e-s;
++ if (e == src) newstart++; /* empty match? go at least one position */
++ lua_pushinteger(L, newstart);
++ lua_replace(L, lua_upvalueindex(3));
++ return push_captures(&ms, src, e);
++ }
++ }
++ return 0; /* not found */
++}
++
++
++static int gmatch (lua_State *L) {
++ luaL_checkstring(L, 1);
++ luaL_checkstring(L, 2);
++ lua_settop(L, 2);
++ lua_pushinteger(L, 0);
++ lua_pushcclosure(L, gmatch_aux, 3);
++ return 1;
++}
++
++
++static int gfind_nodef (lua_State *L) {
++ return luaL_error(L, LUA_QL("string.gfind") " was renamed to "
++ LUA_QL("string.gmatch"));
++}
++
++
++static void add_s (MatchState *ms, luaL_Buffer *b, const char *s,
++ const char *e) {
++ size_t l, i;
++ const char *news = lua_tolstring(ms->L, 3, &l);
++ for (i = 0; i < l; i++) {
++ if (news[i] != L_ESC)
++ luaL_addchar(b, news[i]);
++ else {
++ i++; /* skip ESC */
++ if (!isdigit(uchar(news[i])))
++ luaL_addchar(b, news[i]);
++ else if (news[i] == '0')
++ luaL_addlstring(b, s, e - s);
++ else {
++ push_onecapture(ms, news[i] - '1', s, e);
++ luaL_addvalue(b); /* add capture to accumulated result */
++ }
++ }
++ }
++}
++
++
++static void add_value (MatchState *ms, luaL_Buffer *b, const char *s,
++ const char *e) {
++ lua_State *L = ms->L;
++ switch (lua_type(L, 3)) {
++ case LUA_TNUMBER:
++ case LUA_TSTRING: {
++ add_s(ms, b, s, e);
++ return;
++ }
++ case LUA_TFUNCTION: {
++ int n;
++ lua_pushvalue(L, 3);
++ n = push_captures(ms, s, e);
++ lua_call(L, n, 1);
++ break;
++ }
++ case LUA_TTABLE: {
++ push_onecapture(ms, 0, s, e);
++ lua_gettable(L, 3);
++ break;
++ }
++ }
++ if (!lua_toboolean(L, -1)) { /* nil or false? */
++ lua_pop(L, 1);
++ lua_pushlstring(L, s, e - s); /* keep original text */
++ }
++ else if (!lua_isstring(L, -1))
++ luaL_error(L, "invalid replacement value (a %s)", luaL_typename(L, -1));
++ luaL_addvalue(b); /* add result to accumulator */
++}
++
++
++static int str_gsub (lua_State *L) {
++ size_t srcl;
++ const char *src = luaL_checklstring(L, 1, &srcl);
++ const char *p = luaL_checkstring(L, 2);
++ int tr = lua_type(L, 3);
++ int max_s = luaL_optint(L, 4, srcl+1);
++ int anchor = (*p == '^') ? (p++, 1) : 0;
++ int n = 0;
++ MatchState ms;
++ luaL_Buffer *b = (luaL_Buffer *)kmalloc(sizeof(luaL_Buffer) + BUFSIZ, GFP_ATOMIC);
++ if(!b) luaL_error(L, "str_gsub: cannot allocate memory");
++ luaL_argcheck(L, tr == LUA_TNUMBER || tr == LUA_TSTRING ||
++ tr == LUA_TFUNCTION || tr == LUA_TTABLE, 3,
++ "string/function/table expected");
++ luaL_buffinit(L, b);
++ ms.L = L;
++ ms.src_init = src;
++ ms.src_end = src+srcl;
++ while (n < max_s) {
++ const char *e;
++ ms.level = 0;
++ e = match(&ms, src, p);
++ if (e) {
++ n++;
++ add_value(&ms, b, src, e);
++ }
++ if (e && e>src) /* non empty match? */
++ src = e; /* skip it */
++ else if (src < ms.src_end)
++ luaL_addchar(b, *src++);
++ else break;
++ if (anchor) break;
++ }
++ luaL_addlstring(b, src, ms.src_end-src);
++ luaL_pushresult(b);
++ lua_pushinteger(L, n); /* number of substitutions */
++ kfree(b);
++ return 2;
++}
++
++/* }====================================================== */
++
++
++/* maximum size of each formatted item (> len(format('%99.99f', -1e308))) */
++#define MAX_ITEM 512
++/* valid flags in a format specification */
++#define FLAGS "-+ #0"
++/*
++** maximum size of each format specification (such as '%-099.99d')
++** (+10 accounts for %99.99x plus margin of error)
++*/
++#define MAX_FORMAT (sizeof(FLAGS) + sizeof(LUA_INTFRMLEN) + 10)
++
++
++static void addquoted (lua_State *L, luaL_Buffer *b, int arg) {
++ size_t l;
++ const char *s = luaL_checklstring(L, arg, &l);
++ luaL_addchar(b, '"');
++ while (l--) {
++ switch (*s) {
++ case '"': case '\\': case '\n': {
++ luaL_addchar(b, '\\');
++ luaL_addchar(b, *s);
++ break;
++ }
++ case '\r': {
++ luaL_addlstring(b, "\\r", 2);
++ break;
++ }
++ case '\0': {
++ luaL_addlstring(b, "\\000", 4);
++ break;
++ }
++ default: {
++ luaL_addchar(b, *s);
++ break;
++ }
++ }
++ s++;
++ }
++ luaL_addchar(b, '"');
++}
++
++static const char *scanformat (lua_State *L, const char *strfrmt, char *form) {
++ const char *p = strfrmt;
++ while (*p != '\0' && strchr(FLAGS, *p) != NULL) p++; /* skip flags */
++ if ((size_t)(p - strfrmt) >= sizeof(FLAGS))
++ luaL_error(L, "invalid format (repeated flags)");
++ if (isdigit(uchar(*p))) p++; /* skip width */
++ if (isdigit(uchar(*p))) p++; /* (2 digits at most) */
++ if (*p == '.') {
++ p++;
++ if (isdigit(uchar(*p))) p++; /* skip precision */
++ if (isdigit(uchar(*p))) p++; /* (2 digits at most) */
++ }
++ if (isdigit(uchar(*p)))
++ luaL_error(L, "invalid format (width or precision too long)");
++ *(form++) = '%';
++ strncpy(form, strfrmt, p - strfrmt + 1);
++ form += p - strfrmt + 1;
++ *form = '\0';
++ return p;
++}
++
++
++static void addintlen (char *form) {
++ size_t l = strlen(form);
++ char spec = form[l - 1];
++ strcpy(form + l - 1, LUA_INTFRMLEN);
++ form[l + sizeof(LUA_INTFRMLEN) - 2] = spec;
++ form[l + sizeof(LUA_INTFRMLEN) - 1] = '\0';
++}
++
++
++static int str_format (lua_State *L) {
++ int arg = 1;
++ size_t sfl;
++ const char *strfrmt = luaL_checklstring(L, arg, &sfl);
++ const char *strfrmt_end = strfrmt+sfl;
++ luaL_Buffer *b = (luaL_Buffer *)kmalloc(sizeof(luaL_Buffer) + BUFSIZ, GFP_ATOMIC);
++ if(!b) luaL_error(L, "str_format: cannot allocate memory");
++ luaL_buffinit(L, b);
++ while (strfrmt < strfrmt_end) {
++ if (*strfrmt != L_ESC)
++ luaL_addchar(b, *strfrmt++);
++ else if (*++strfrmt == L_ESC)
++ luaL_addchar(b, *strfrmt++); /* %% */
++ else { /* format item */
++ char form[MAX_FORMAT]; /* to store the format (`%...') */
++ char buff[MAX_ITEM]; /* to store the formatted item */
++ arg++;
++ strfrmt = scanformat(L, strfrmt, form);
++ switch (*strfrmt++) {
++ case 'c': {
++ sprintf(buff, form, (int)luaL_checknumber(L, arg));
++ break;
++ }
++ case 'd': case 'i': {
++ addintlen(form);
++ sprintf(buff, form, (LUA_INTFRM_T)luaL_checknumber(L, arg));
++ break;
++ }
++ case 'o': case 'u': case 'x': case 'X': {
++ addintlen(form);
++ sprintf(buff, form, (unsigned LUA_INTFRM_T)luaL_checknumber(L, arg));
++ break;
++ }
++ case 'q': {
++ addquoted(L, b, arg);
++ continue; /* skip the 'addsize' at the end */
++ }
++ case 's': {
++ size_t l;
++ const char *s = luaL_checklstring(L, arg, &l);
++ if (!strchr(form, '.') && l >= 100) {
++ /* no precision and string is too long to be formatted;
++ keep original string */
++ lua_pushvalue(L, arg);
++ luaL_addvalue(b);
++ continue; /* skip the `addsize' at the end */
++ }
++ else {
++ sprintf(buff, form, s);
++ break;
++ }
++ }
++ default: { /* also treat cases `pnLlh' */
++ kfree(b);
++ return luaL_error(L, "invalid option " LUA_QL("%%%c") " to "
++ LUA_QL("format"), *(strfrmt - 1));
++ }
++ }
++ luaL_addlstring(b, buff, strlen(buff));
++ }
++ }
++ luaL_pushresult(b);
++ kfree(b);
++ return 1;
++}
++
++
++static const luaL_Reg strlib[] = {
++ {"byte", str_byte},
++ {"char", str_char},
++ {"dump", str_dump},
++ {"find", str_find},
++ {"format", str_format},
++ {"gfind", gfind_nodef},
++ {"gmatch", gmatch},
++ {"gsub", str_gsub},
++ {"len", str_len},
++ {"lower", str_lower},
++ {"match", str_match},
++ {"rep", str_rep},
++ {"reverse", str_reverse},
++ {"sub", str_sub},
++ {"upper", str_upper},
++ {NULL, NULL}
++};
++
++
++static void createmetatable (lua_State *L) {
++ lua_createtable(L, 0, 1); /* create metatable for strings */
++ lua_pushliteral(L, ""); /* dummy string */
++ lua_pushvalue(L, -2);
++ lua_setmetatable(L, -2); /* set string metatable */
++ lua_pop(L, 1); /* pop dummy string */
++ lua_pushvalue(L, -2); /* string library... */
++ lua_setfield(L, -2, "__index"); /* ...is the __index metamethod */
++ lua_pop(L, 1); /* pop metatable */
++}
++
++
++/*
++** Open string library
++*/
++LUALIB_API int luaopen_string (lua_State *L) {
++ luaL_register(L, LUA_STRLIBNAME, strlib);
++#if defined(LUA_COMPAT_GFIND)
++ lua_getfield(L, -1, "gmatch");
++ lua_setfield(L, -2, "gfind");
++#endif
++ createmetatable(L);
++ return 1;
++}
+--- /dev/null
++++ b/extensions/LUA/lua/ltable.c
+@@ -0,0 +1,588 @@
++/*
++** $Id: ltable.c,v 2.32.1.2 2007/12/28 15:32:23 roberto Exp $
++** Lua tables (hash)
++** See Copyright Notice in lua.h
++*/
++
++
++/*
++** Implementation of tables (aka arrays, objects, or hash tables).
++** Tables keep its elements in two parts: an array part and a hash part.
++** Non-negative integer keys are all candidates to be kept in the array
++** part. The actual size of the array is the largest `n' such that at
++** least half the slots between 0 and n are in use.
++** Hash uses a mix of chained scatter table with Brent's variation.
++** A main invariant of these tables is that, if an element is not
++** in its main position (i.e. the `original' position that its hash gives
++** to it), then the colliding element is in its own main position.
++** Hence even when the load factor reaches 100%, performance remains good.
++*/
++
++#include <math.h>
++#include <string.h>
++
++#define ltable_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "ldebug.h"
++#include "ldo.h"
++#include "lgc.h"
++#include "lmem.h"
++#include "lobject.h"
++#include "lstate.h"
++#include "ltable.h"
++
++
++/*
++** max size of array part is 2^MAXBITS
++*/
++#if LUAI_BITSINT > 26
++#define MAXBITS 26
++#else
++#define MAXBITS (LUAI_BITSINT-2)
++#endif
++
++#define MAXASIZE (1 << MAXBITS)
++
++
++#define hashpow2(t,n) (gnode(t, lmod((n), sizenode(t))))
++
++#define hashstr(t,str) hashpow2(t, (str)->tsv.hash)
++#define hashboolean(t,p) hashpow2(t, p)
++
++
++/*
++** for some types, it is better to avoid modulus by power of 2, as
++** they tend to have many 2 factors.
++*/
++#define hashmod(t,n) (gnode(t, ((n) % ((sizenode(t)-1)|1))))
++
++
++#define hashpointer(t,p) hashmod(t, IntPoint(p))
++
++
++/*
++** number of ints inside a lua_Number
++*/
++#define numints cast_int(sizeof(lua_Number)/sizeof(int))
++
++
++
++#define dummynode (&dummynode_)
++
++static const Node dummynode_ = {
++ {{NULL}, LUA_TNIL}, /* value */
++ {{{NULL}, LUA_TNIL, NULL}} /* key */
++};
++
++
++/*
++** hash for lua_Numbers
++*/
++static Node *hashnum (const Table *t, lua_Number n) {
++ unsigned int a[numints];
++ int i;
++ if (luai_numeq(n, 0)) /* avoid problems with -0 */
++ return gnode(t, 0);
++ memcpy(a, &n, sizeof(a));
++ for (i = 1; i < numints; i++) a[0] += a[i];
++ return hashmod(t, a[0]);
++}
++
++
++
++/*
++** returns the `main' position of an element in a table (that is, the index
++** of its hash value)
++*/
++static Node *mainposition (const Table *t, const TValue *key) {
++ switch (ttype(key)) {
++ case LUA_TNUMBER:
++ return hashnum(t, nvalue(key));
++ case LUA_TSTRING:
++ return hashstr(t, rawtsvalue(key));
++ case LUA_TBOOLEAN:
++ return hashboolean(t, bvalue(key));
++ case LUA_TLIGHTUSERDATA:
++ return hashpointer(t, pvalue(key));
++ default:
++ return hashpointer(t, gcvalue(key));
++ }
++}
++
++
++/*
++** returns the index for `key' if `key' is an appropriate key to live in
++** the array part of the table, -1 otherwise.
++*/
++static int arrayindex (const TValue *key) {
++ if (ttisnumber(key)) {
++ lua_Number n = nvalue(key);
++ int k;
++ lua_number2int(k, n);
++ if (luai_numeq(cast_num(k), n))
++ return k;
++ }
++ return -1; /* `key' did not match some condition */
++}
++
++
++/*
++** returns the index of a `key' for table traversals. First goes all
++** elements in the array part, then elements in the hash part. The
++** beginning of a traversal is signalled by -1.
++*/
++static int findindex (lua_State *L, Table *t, StkId key) {
++ int i;
++ if (ttisnil(key)) return -1; /* first iteration */
++ i = arrayindex(key);
++ if (0 < i && i <= t->sizearray) /* is `key' inside array part? */
++ return i-1; /* yes; that's the index (corrected to C) */
++ else {
++ Node *n = mainposition(t, key);
++ do { /* check whether `key' is somewhere in the chain */
++ /* key may be dead already, but it is ok to use it in `next' */
++ if (luaO_rawequalObj(key2tval(n), key) ||
++ (ttype(gkey(n)) == LUA_TDEADKEY && iscollectable(key) &&
++ gcvalue(gkey(n)) == gcvalue(key))) {
++ i = cast_int(n - gnode(t, 0)); /* key index in hash table */
++ /* hash elements are numbered after array ones */
++ return i + t->sizearray;
++ }
++ else n = gnext(n);
++ } while (n);
++ luaG_runerror(L, "invalid key to " LUA_QL("next")); /* key not found */
++ return 0; /* to avoid warnings */
++ }
++}
++
++
++int luaH_next (lua_State *L, Table *t, StkId key) {
++ int i = findindex(L, t, key); /* find original element */
++ for (i++; i < t->sizearray; i++) { /* try first array part */
++ if (!ttisnil(&t->array[i])) { /* a non-nil value? */
++ setnvalue(key, cast_num(i+1));
++ setobj2s(L, key+1, &t->array[i]);
++ return 1;
++ }
++ }
++ for (i -= t->sizearray; i < sizenode(t); i++) { /* then hash part */
++ if (!ttisnil(gval(gnode(t, i)))) { /* a non-nil value? */
++ setobj2s(L, key, key2tval(gnode(t, i)));
++ setobj2s(L, key+1, gval(gnode(t, i)));
++ return 1;
++ }
++ }
++ return 0; /* no more elements */
++}
++
++
++/*
++** {=============================================================
++** Rehash
++** ==============================================================
++*/
++
++
++static int computesizes (int nums[], int *narray) {
++ int i;
++ int twotoi; /* 2^i */
++ int a = 0; /* number of elements smaller than 2^i */
++ int na = 0; /* number of elements to go to array part */
++ int n = 0; /* optimal size for array part */
++ for (i = 0, twotoi = 1; twotoi/2 < *narray; i++, twotoi *= 2) {
++ if (nums[i] > 0) {
++ a += nums[i];
++ if (a > twotoi/2) { /* more than half elements present? */
++ n = twotoi; /* optimal size (till now) */
++ na = a; /* all elements smaller than n will go to array part */
++ }
++ }
++ if (a == *narray) break; /* all elements already counted */
++ }
++ *narray = n;
++ lua_assert(*narray/2 <= na && na <= *narray);
++ return na;
++}
++
++
++static int countint (const TValue *key, int *nums) {
++ int k = arrayindex(key);
++ if (0 < k && k <= MAXASIZE) { /* is `key' an appropriate array index? */
++ nums[ceillog2(k)]++; /* count as such */
++ return 1;
++ }
++ else
++ return 0;
++}
++
++
++static int numusearray (const Table *t, int *nums) {
++ int lg;
++ int ttlg; /* 2^lg */
++ int ause = 0; /* summation of `nums' */
++ int i = 1; /* count to traverse all array keys */
++ for (lg=0, ttlg=1; lg<=MAXBITS; lg++, ttlg*=2) { /* for each slice */
++ int lc = 0; /* counter */
++ int lim = ttlg;
++ if (lim > t->sizearray) {
++ lim = t->sizearray; /* adjust upper limit */
++ if (i > lim)
++ break; /* no more elements to count */
++ }
++ /* count elements in range (2^(lg-1), 2^lg] */
++ for (; i <= lim; i++) {
++ if (!ttisnil(&t->array[i-1]))
++ lc++;
++ }
++ nums[lg] += lc;
++ ause += lc;
++ }
++ return ause;
++}
++
++
++static int numusehash (const Table *t, int *nums, int *pnasize) {
++ int totaluse = 0; /* total number of elements */
++ int ause = 0; /* summation of `nums' */
++ int i = sizenode(t);
++ while (i--) {
++ Node *n = &t->node[i];
++ if (!ttisnil(gval(n))) {
++ ause += countint(key2tval(n), nums);
++ totaluse++;
++ }
++ }
++ *pnasize += ause;
++ return totaluse;
++}
++
++
++static void setarrayvector (lua_State *L, Table *t, int size) {
++ int i;
++ luaM_reallocvector(L, t->array, t->sizearray, size, TValue);
++ for (i=t->sizearray; i<size; i++)
++ setnilvalue(&t->array[i]);
++ t->sizearray = size;
++}
++
++
++static void setnodevector (lua_State *L, Table *t, int size) {
++ int lsize;
++ if (size == 0) { /* no elements to hash part? */
++ t->node = cast(Node *, dummynode); /* use common `dummynode' */
++ lsize = 0;
++ }
++ else {
++ int i;
++ lsize = ceillog2(size);
++ if (lsize > MAXBITS)
++ luaG_runerror(L, "table overflow");
++ size = twoto(lsize);
++ t->node = luaM_newvector(L, size, Node);
++ for (i=0; i<size; i++) {
++ Node *n = gnode(t, i);
++ gnext(n) = NULL;
++ setnilvalue(gkey(n));
++ setnilvalue(gval(n));
++ }
++ }
++ t->lsizenode = cast_byte(lsize);
++ t->lastfree = gnode(t, size); /* all positions are free */
++}
++
++
++static void resize (lua_State *L, Table *t, int nasize, int nhsize) {
++ int i;
++ int oldasize = t->sizearray;
++ int oldhsize = t->lsizenode;
++ Node *nold = t->node; /* save old hash ... */
++ if (nasize > oldasize) /* array part must grow? */
++ setarrayvector(L, t, nasize);
++ /* create new hash part with appropriate size */
++ setnodevector(L, t, nhsize);
++ if (nasize < oldasize) { /* array part must shrink? */
++ t->sizearray = nasize;
++ /* re-insert elements from vanishing slice */
++ for (i=nasize; i<oldasize; i++) {
++ if (!ttisnil(&t->array[i]))
++ setobjt2t(L, luaH_setnum(L, t, i+1), &t->array[i]);
++ }
++ /* shrink array */
++ luaM_reallocvector(L, t->array, oldasize, nasize, TValue);
++ }
++ /* re-insert elements from hash part */
++ for (i = twoto(oldhsize) - 1; i >= 0; i--) {
++ Node *old = nold+i;
++ if (!ttisnil(gval(old)))
++ setobjt2t(L, luaH_set(L, t, key2tval(old)), gval(old));
++ }
++ if (nold != dummynode)
++ luaM_freearray(L, nold, twoto(oldhsize), Node); /* free old array */
++}
++
++
++void luaH_resizearray (lua_State *L, Table *t, int nasize) {
++ int nsize = (t->node == dummynode) ? 0 : sizenode(t);
++ resize(L, t, nasize, nsize);
++}
++
++
++static void rehash (lua_State *L, Table *t, const TValue *ek) {
++ int nasize, na;
++ int nums[MAXBITS+1]; /* nums[i] = number of keys between 2^(i-1) and 2^i */
++ int i;
++ int totaluse;
++ for (i=0; i<=MAXBITS; i++) nums[i] = 0; /* reset counts */
++ nasize = numusearray(t, nums); /* count keys in array part */
++ totaluse = nasize; /* all those keys are integer keys */
++ totaluse += numusehash(t, nums, &nasize); /* count keys in hash part */
++ /* count extra key */
++ nasize += countint(ek, nums);
++ totaluse++;
++ /* compute new size for array part */
++ na = computesizes(nums, &nasize);
++ /* resize the table to new computed sizes */
++ resize(L, t, nasize, totaluse - na);
++}
++
++
++
++/*
++** }=============================================================
++*/
++
++
++Table *luaH_new (lua_State *L, int narray, int nhash) {
++ Table *t = luaM_new(L, Table);
++ luaC_link(L, obj2gco(t), LUA_TTABLE);
++ t->metatable = NULL;
++ t->flags = cast_byte(~0);
++ /* temporary values (kept only if some malloc fails) */
++ t->array = NULL;
++ t->sizearray = 0;
++ t->lsizenode = 0;
++ t->node = cast(Node *, dummynode);
++ setarrayvector(L, t, narray);
++ setnodevector(L, t, nhash);
++ return t;
++}
++
++
++void luaH_free (lua_State *L, Table *t) {
++ if (t->node != dummynode)
++ luaM_freearray(L, t->node, sizenode(t), Node);
++ luaM_freearray(L, t->array, t->sizearray, TValue);
++ luaM_free(L, t);
++}
++
++
++static Node *getfreepos (Table *t) {
++ while (t->lastfree-- > t->node) {
++ if (ttisnil(gkey(t->lastfree)))
++ return t->lastfree;
++ }
++ return NULL; /* could not find a free place */
++}
++
++
++
++/*
++** inserts a new key into a hash table; first, check whether key's main
++** position is free. If not, check whether colliding node is in its main
++** position or not: if it is not, move colliding node to an empty place and
++** put new key in its main position; otherwise (colliding node is in its main
++** position), new key goes to an empty position.
++*/
++static TValue *newkey (lua_State *L, Table *t, const TValue *key) {
++ Node *mp = mainposition(t, key);
++ if (!ttisnil(gval(mp)) || mp == dummynode) {
++ Node *othern;
++ Node *n = getfreepos(t); /* get a free place */
++ if (n == NULL) { /* cannot find a free place? */
++ rehash(L, t, key); /* grow table */
++ return luaH_set(L, t, key); /* re-insert key into grown table */
++ }
++ lua_assert(n != dummynode);
++ othern = mainposition(t, key2tval(mp));
++ if (othern != mp) { /* is colliding node out of its main position? */
++ /* yes; move colliding node into free position */
++ while (gnext(othern) != mp) othern = gnext(othern); /* find previous */
++ gnext(othern) = n; /* redo the chain with `n' in place of `mp' */
++ *n = *mp; /* copy colliding node into free pos. (mp->next also goes) */
++ gnext(mp) = NULL; /* now `mp' is free */
++ setnilvalue(gval(mp));
++ }
++ else { /* colliding node is in its own main position */
++ /* new node will go into free position */
++ gnext(n) = gnext(mp); /* chain new position */
++ gnext(mp) = n;
++ mp = n;
++ }
++ }
++ gkey(mp)->value = key->value; gkey(mp)->tt = key->tt;
++ luaC_barriert(L, t, key);
++ lua_assert(ttisnil(gval(mp)));
++ return gval(mp);
++}
++
++
++/*
++** search function for integers
++*/
++const TValue *luaH_getnum (Table *t, int key) {
++ /* (1 <= key && key <= t->sizearray) */
++ if (cast(unsigned int, key-1) < cast(unsigned int, t->sizearray))
++ return &t->array[key-1];
++ else {
++ lua_Number nk = cast_num(key);
++ Node *n = hashnum(t, nk);
++ do { /* check whether `key' is somewhere in the chain */
++ if (ttisnumber(gkey(n)) && luai_numeq(nvalue(gkey(n)), nk))
++ return gval(n); /* that's it */
++ else n = gnext(n);
++ } while (n);
++ return luaO_nilobject;
++ }
++}
++
++
++/*
++** search function for strings
++*/
++const TValue *luaH_getstr (Table *t, TString *key) {
++ Node *n = hashstr(t, key);
++ do { /* check whether `key' is somewhere in the chain */
++ if (ttisstring(gkey(n)) && rawtsvalue(gkey(n)) == key)
++ return gval(n); /* that's it */
++ else n = gnext(n);
++ } while (n);
++ return luaO_nilobject;
++}
++
++
++/*
++** main search function
++*/
++const TValue *luaH_get (Table *t, const TValue *key) {
++ switch (ttype(key)) {
++ case LUA_TNIL: return luaO_nilobject;
++ case LUA_TSTRING: return luaH_getstr(t, rawtsvalue(key));
++ case LUA_TNUMBER: {
++ int k;
++ lua_Number n = nvalue(key);
++ lua_number2int(k, n);
++ if (luai_numeq(cast_num(k), nvalue(key))) /* index is int? */
++ return luaH_getnum(t, k); /* use specialized version */
++ /* else go through */
++ }
++ default: {
++ Node *n = mainposition(t, key);
++ do { /* check whether `key' is somewhere in the chain */
++ if (luaO_rawequalObj(key2tval(n), key))
++ return gval(n); /* that's it */
++ else n = gnext(n);
++ } while (n);
++ return luaO_nilobject;
++ }
++ }
++}
++
++
++TValue *luaH_set (lua_State *L, Table *t, const TValue *key) {
++ const TValue *p = luaH_get(t, key);
++ t->flags = 0;
++ if (p != luaO_nilobject)
++ return cast(TValue *, p);
++ else {
++ if (ttisnil(key)) luaG_runerror(L, "table index is nil");
++ else if (ttisnumber(key) && luai_numisnan(nvalue(key)))
++ luaG_runerror(L, "table index is NaN");
++ return newkey(L, t, key);
++ }
++}
++
++
++TValue *luaH_setnum (lua_State *L, Table *t, int key) {
++ const TValue *p = luaH_getnum(t, key);
++ if (p != luaO_nilobject)
++ return cast(TValue *, p);
++ else {
++ TValue k;
++ setnvalue(&k, cast_num(key));
++ return newkey(L, t, &k);
++ }
++}
++
++
++TValue *luaH_setstr (lua_State *L, Table *t, TString *key) {
++ const TValue *p = luaH_getstr(t, key);
++ if (p != luaO_nilobject)
++ return cast(TValue *, p);
++ else {
++ TValue k;
++ setsvalue(L, &k, key);
++ return newkey(L, t, &k);
++ }
++}
++
++
++static int unbound_search (Table *t, unsigned int j) {
++ unsigned int i = j; /* i is zero or a present index */
++ j++;
++ /* find `i' and `j' such that i is present and j is not */
++ while (!ttisnil(luaH_getnum(t, j))) {
++ i = j;
++ j *= 2;
++ if (j > cast(unsigned int, MAX_INT)) { /* overflow? */
++ /* table was built with bad purposes: resort to linear search */
++ i = 1;
++ while (!ttisnil(luaH_getnum(t, i))) i++;
++ return i - 1;
++ }
++ }
++ /* now do a binary search between them */
++ while (j - i > 1) {
++ unsigned int m = (i+j)/2;
++ if (ttisnil(luaH_getnum(t, m))) j = m;
++ else i = m;
++ }
++ return i;
++}
++
++
++/*
++** Try to find a boundary in table `t'. A `boundary' is an integer index
++** such that t[i] is non-nil and t[i+1] is nil (and 0 if t[1] is nil).
++*/
++int luaH_getn (Table *t) {
++ unsigned int j = t->sizearray;
++ if (j > 0 && ttisnil(&t->array[j - 1])) {
++ /* there is a boundary in the array part: (binary) search for it */
++ unsigned int i = 0;
++ while (j - i > 1) {
++ unsigned int m = (i+j)/2;
++ if (ttisnil(&t->array[m - 1])) j = m;
++ else i = m;
++ }
++ return i;
++ }
++ /* else must find a boundary in hash part */
++ else if (t->node == dummynode) /* hash part is empty? */
++ return j; /* that is easy... */
++ else return unbound_search(t, j);
++}
++
++
++
++#if defined(LUA_DEBUG)
++
++Node *luaH_mainposition (const Table *t, const TValue *key) {
++ return mainposition(t, key);
++}
++
++int luaH_isdummy (Node *n) { return n == dummynode; }
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/ltable.h
+@@ -0,0 +1,40 @@
++/*
++** $Id: ltable.h,v 2.10.1.1 2007/12/27 13:02:25 roberto Exp $
++** Lua tables (hash)
++** See Copyright Notice in lua.h
++*/
++
++#ifndef ltable_h
++#define ltable_h
++
++#include "lobject.h"
++
++
++#define gnode(t,i) (&(t)->node[i])
++#define gkey(n) (&(n)->i_key.nk)
++#define gval(n) (&(n)->i_val)
++#define gnext(n) ((n)->i_key.nk.next)
++
++#define key2tval(n) (&(n)->i_key.tvk)
++
++
++LUAI_FUNC const TValue *luaH_getnum (Table *t, int key);
++LUAI_FUNC TValue *luaH_setnum (lua_State *L, Table *t, int key);
++LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key);
++LUAI_FUNC TValue *luaH_setstr (lua_State *L, Table *t, TString *key);
++LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key);
++LUAI_FUNC TValue *luaH_set (lua_State *L, Table *t, const TValue *key);
++LUAI_FUNC Table *luaH_new (lua_State *L, int narray, int lnhash);
++LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, int nasize);
++LUAI_FUNC void luaH_free (lua_State *L, Table *t);
++LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key);
++LUAI_FUNC int luaH_getn (Table *t);
++
++
++#if defined(LUA_DEBUG)
++LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key);
++LUAI_FUNC int luaH_isdummy (Node *n);
++#endif
++
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/ltablib.c
+@@ -0,0 +1,288 @@
++/*
++** $Id: ltablib.c,v 1.38.1.3 2008/02/14 16:46:58 roberto Exp $
++** Library for Table Manipulation
++** See Copyright Notice in lua.h
++*/
++
++
++#include <stddef.h>
++
++#define ltablib_c
++#define LUA_LIB
++
++#include "lua.h"
++
++#include "lauxlib.h"
++#include "lualib.h"
++
++
++#define aux_getn(L,n) (luaL_checktype(L, n, LUA_TTABLE), luaL_getn(L, n))
++
++
++static int foreachi (lua_State *L) {
++ int i;
++ int n = aux_getn(L, 1);
++ luaL_checktype(L, 2, LUA_TFUNCTION);
++ for (i=1; i <= n; i++) {
++ lua_pushvalue(L, 2); /* function */
++ lua_pushinteger(L, i); /* 1st argument */
++ lua_rawgeti(L, 1, i); /* 2nd argument */
++ lua_call(L, 2, 1);
++ if (!lua_isnil(L, -1))
++ return 1;
++ lua_pop(L, 1); /* remove nil result */
++ }
++ return 0;
++}
++
++
++static int foreach (lua_State *L) {
++ luaL_checktype(L, 1, LUA_TTABLE);
++ luaL_checktype(L, 2, LUA_TFUNCTION);
++ lua_pushnil(L); /* first key */
++ while (lua_next(L, 1)) {
++ lua_pushvalue(L, 2); /* function */
++ lua_pushvalue(L, -3); /* key */
++ lua_pushvalue(L, -3); /* value */
++ lua_call(L, 2, 1);
++ if (!lua_isnil(L, -1))
++ return 1;
++ lua_pop(L, 2); /* remove value and result */
++ }
++ return 0;
++}
++
++
++static int maxn (lua_State *L) {
++ lua_Number max = 0;
++ luaL_checktype(L, 1, LUA_TTABLE);
++ lua_pushnil(L); /* first key */
++ while (lua_next(L, 1)) {
++ lua_pop(L, 1); /* remove value */
++ if (lua_type(L, -1) == LUA_TNUMBER) {
++ lua_Number v = lua_tonumber(L, -1);
++ if (v > max) max = v;
++ }
++ }
++ lua_pushnumber(L, max);
++ return 1;
++}
++
++
++static int getn (lua_State *L) {
++ lua_pushinteger(L, aux_getn(L, 1));
++ return 1;
++}
++
++
++static int setn (lua_State *L) {
++ luaL_checktype(L, 1, LUA_TTABLE);
++#ifndef luaL_setn
++ luaL_setn(L, 1, luaL_checkint(L, 2));
++#else
++ luaL_error(L, LUA_QL("setn") " is obsolete");
++#endif
++ lua_pushvalue(L, 1);
++ return 1;
++}
++
++
++static int tinsert (lua_State *L) {
++ int e = aux_getn(L, 1) + 1; /* first empty element */
++ int pos; /* where to insert new element */
++ switch (lua_gettop(L)) {
++ case 2: { /* called with only 2 arguments */
++ pos = e; /* insert new element at the end */
++ break;
++ }
++ case 3: {
++ int i;
++ pos = luaL_checkint(L, 2); /* 2nd argument is the position */
++ if (pos > e) e = pos; /* `grow' array if necessary */
++ for (i = e; i > pos; i--) { /* move up elements */
++ lua_rawgeti(L, 1, i-1);
++ lua_rawseti(L, 1, i); /* t[i] = t[i-1] */
++ }
++ break;
++ }
++ default: {
++ return luaL_error(L, "wrong number of arguments to " LUA_QL("insert"));
++ }
++ }
++ luaL_setn(L, 1, e); /* new size */
++ lua_rawseti(L, 1, pos); /* t[pos] = v */
++ return 0;
++}
++
++
++static int tremove (lua_State *L) {
++ int e = aux_getn(L, 1);
++ int pos = luaL_optint(L, 2, e);
++ if (!(1 <= pos && pos <= e)) /* position is outside bounds? */
++ return 0; /* nothing to remove */
++ luaL_setn(L, 1, e - 1); /* t.n = n-1 */
++ lua_rawgeti(L, 1, pos); /* result = t[pos] */
++ for ( ;pos<e; pos++) {
++ lua_rawgeti(L, 1, pos+1);
++ lua_rawseti(L, 1, pos); /* t[pos] = t[pos+1] */
++ }
++ lua_pushnil(L);
++ lua_rawseti(L, 1, e); /* t[e] = nil */
++ return 1;
++}
++
++
++static void addfield (lua_State *L, luaL_Buffer *b, int i) {
++ lua_rawgeti(L, 1, i);
++ if (!lua_isstring(L, -1))
++ luaL_error(L, "invalid value (%s) at index %d in table for "
++ LUA_QL("concat"), luaL_typename(L, -1), i);
++ luaL_addvalue(b);
++}
++
++
++static int tconcat (lua_State *L) {
++ size_t lsep;
++ int i, last;
++ const char *sep = luaL_optlstring(L, 2, "", &lsep);
++ luaL_Buffer *b = (luaL_Buffer *)kmalloc(sizeof(luaL_Buffer) + BUFSIZ, GFP_ATOMIC);
++ if(!b) luaL_error(L, "tconcat: cannot allocate memory");
++ luaL_checktype(L, 1, LUA_TTABLE);
++ i = luaL_optint(L, 3, 1);
++ last = luaL_opt(L, luaL_checkint, 4, luaL_getn(L, 1));
++ luaL_buffinit(L, b);
++ for (; i < last; i++) {
++ addfield(L, b, i);
++ luaL_addlstring(b, sep, lsep);
++ }
++ if (i == last) /* add last value (if interval was not empty) */
++ addfield(L, b, i);
++ luaL_pushresult(b);
++ kfree(b);
++ return 1;
++}
++
++
++
++/*
++** {======================================================
++** Quicksort
++** (based on `Algorithms in MODULA-3', Robert Sedgewick;
++** Addison-Wesley, 1993.)
++*/
++
++
++static void set2 (lua_State *L, int i, int j) {
++ lua_rawseti(L, 1, i);
++ lua_rawseti(L, 1, j);
++}
++
++static int sort_comp (lua_State *L, int a, int b) {
++ if (!lua_isnil(L, 2)) { /* function? */
++ int res;
++ lua_pushvalue(L, 2);
++ lua_pushvalue(L, a-1); /* -1 to compensate function */
++ lua_pushvalue(L, b-2); /* -2 to compensate function and `a' */
++ lua_call(L, 2, 1);
++ res = lua_toboolean(L, -1);
++ lua_pop(L, 1);
++ return res;
++ }
++ else /* a < b? */
++ return lua_lessthan(L, a, b);
++}
++
++static void auxsort (lua_State *L, int l, int u) {
++ while (l < u) { /* for tail recursion */
++ int i, j;
++ /* sort elements a[l], a[(l+u)/2] and a[u] */
++ lua_rawgeti(L, 1, l);
++ lua_rawgeti(L, 1, u);
++ if (sort_comp(L, -1, -2)) /* a[u] < a[l]? */
++ set2(L, l, u); /* swap a[l] - a[u] */
++ else
++ lua_pop(L, 2);
++ if (u-l == 1) break; /* only 2 elements */
++ i = (l+u)/2;
++ lua_rawgeti(L, 1, i);
++ lua_rawgeti(L, 1, l);
++ if (sort_comp(L, -2, -1)) /* a[i]<a[l]? */
++ set2(L, i, l);
++ else {
++ lua_pop(L, 1); /* remove a[l] */
++ lua_rawgeti(L, 1, u);
++ if (sort_comp(L, -1, -2)) /* a[u]<a[i]? */
++ set2(L, i, u);
++ else
++ lua_pop(L, 2);
++ }
++ if (u-l == 2) break; /* only 3 elements */
++ lua_rawgeti(L, 1, i); /* Pivot */
++ lua_pushvalue(L, -1);
++ lua_rawgeti(L, 1, u-1);
++ set2(L, i, u-1);
++ /* a[l] <= P == a[u-1] <= a[u], only need to sort from l+1 to u-2 */
++ i = l; j = u-1;
++ for (;;) { /* invariant: a[l..i] <= P <= a[j..u] */
++ /* repeat ++i until a[i] >= P */
++ while (lua_rawgeti(L, 1, ++i), sort_comp(L, -1, -2)) {
++ if (i>u) luaL_error(L, "invalid order function for sorting");
++ lua_pop(L, 1); /* remove a[i] */
++ }
++ /* repeat --j until a[j] <= P */
++ while (lua_rawgeti(L, 1, --j), sort_comp(L, -3, -1)) {
++ if (j<l) luaL_error(L, "invalid order function for sorting");
++ lua_pop(L, 1); /* remove a[j] */
++ }
++ if (j<i) {
++ lua_pop(L, 3); /* pop pivot, a[i], a[j] */
++ break;
++ }
++ set2(L, i, j);
++ }
++ lua_rawgeti(L, 1, u-1);
++ lua_rawgeti(L, 1, i);
++ set2(L, u-1, i); /* swap pivot (a[u-1]) with a[i] */
++ /* a[l..i-1] <= a[i] == P <= a[i+1..u] */
++ /* adjust so that smaller half is in [j..i] and larger one in [l..u] */
++ if (i-l < u-i) {
++ j=l; i=i-1; l=i+2;
++ }
++ else {
++ j=i+1; i=u; u=j-2;
++ }
++ auxsort(L, j, i); /* call recursively the smaller one */
++ } /* repeat the routine for the larger one */
++}
++
++static int sort (lua_State *L) {
++ int n = aux_getn(L, 1);
++ luaL_checkstack(L, 40, ""); /* assume array is smaller than 2^40 */
++ if (!lua_isnoneornil(L, 2)) /* is there a 2nd argument? */
++ luaL_checktype(L, 2, LUA_TFUNCTION);
++ lua_settop(L, 2); /* make sure there is two arguments */
++ auxsort(L, 1, n);
++ return 0;
++}
++
++/* }====================================================== */
++
++
++static const luaL_Reg tab_funcs[] = {
++ {"concat", tconcat},
++ {"foreach", foreach},
++ {"foreachi", foreachi},
++ {"getn", getn},
++ {"maxn", maxn},
++ {"insert", tinsert},
++ {"remove", tremove},
++ {"setn", setn},
++ {"sort", sort},
++ {NULL, NULL}
++};
++
++
++LUALIB_API int luaopen_table (lua_State *L) {
++ luaL_register(L, LUA_TABLIBNAME, tab_funcs);
++ return 1;
++}
+--- /dev/null
++++ b/extensions/LUA/lua/ltm.c
+@@ -0,0 +1,74 @@
++/*
++** $Id: ltm.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $
++** Tag methods
++** See Copyright Notice in lua.h
++*/
++
++#include <string.h>
++
++#define ltm_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "lobject.h"
++#include "lstate.h"
++#include "lstring.h"
++#include "ltable.h"
++#include "ltm.h"
++
++
++
++const char *const luaT_typenames[] = {
++ "nil", "boolean", "userdata", "number",
++ "string", "table", "function", "userdata", "thread",
++ "proto", "upval"
++};
++
++
++void luaT_init (lua_State *L) {
++ static const char *const luaT_eventname[] = { /* ORDER TM */
++ "__index", "__newindex",
++ "__gc", "__mode", "__eq",
++ "__add", "__sub", "__mul", "__div", "__mod",
++ "__pow", "__unm", "__len", "__lt", "__le",
++ "__concat", "__call"
++ };
++ int i;
++ for (i=0; i<TM_N; i++) {
++ G(L)->tmname[i] = luaS_new(L, luaT_eventname[i]);
++ luaS_fix(G(L)->tmname[i]); /* never collect these names */
++ }
++}
++
++
++/*
++** function to be used with macro "fasttm": optimized for absence of
++** tag methods
++*/
++const TValue *luaT_gettm (Table *events, TMS event, TString *ename) {
++ const TValue *tm = luaH_getstr(events, ename);
++ lua_assert(event <= TM_EQ);
++ if (ttisnil(tm)) { /* no tag method? */
++ events->flags |= cast_byte(1u<<event); /* cache this fact */
++ return NULL;
++ }
++ else return tm;
++}
++
++
++const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, TMS event) {
++ Table *mt;
++ switch (ttype(o)) {
++ case LUA_TTABLE:
++ mt = hvalue(o)->metatable;
++ break;
++ case LUA_TUSERDATA:
++ mt = uvalue(o)->metatable;
++ break;
++ default:
++ mt = G(L)->mt[ttype(o)];
++ }
++ return (mt ? luaH_getstr(mt, G(L)->tmname[event]) : luaO_nilobject);
++}
++
+--- /dev/null
++++ b/extensions/LUA/lua/ltm.h
+@@ -0,0 +1,54 @@
++/*
++** $Id: ltm.h,v 2.6.1.1 2007/12/27 13:02:25 roberto Exp $
++** Tag methods
++** See Copyright Notice in lua.h
++*/
++
++#ifndef ltm_h
++#define ltm_h
++
++
++#include "lobject.h"
++
++
++/*
++* WARNING: if you change the order of this enumeration,
++* grep "ORDER TM"
++*/
++typedef enum {
++ TM_INDEX,
++ TM_NEWINDEX,
++ TM_GC,
++ TM_MODE,
++ TM_EQ, /* last tag method with `fast' access */
++ TM_ADD,
++ TM_SUB,
++ TM_MUL,
++ TM_DIV,
++ TM_MOD,
++ TM_POW,
++ TM_UNM,
++ TM_LEN,
++ TM_LT,
++ TM_LE,
++ TM_CONCAT,
++ TM_CALL,
++ TM_N /* number of elements in the enum */
++} TMS;
++
++
++
++#define gfasttm(g,et,e) ((et) == NULL ? NULL : \
++ ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e]))
++
++#define fasttm(l,et,e) gfasttm(G(l), et, e)
++
++LUAI_DATA const char *const luaT_typenames[];
++
++
++LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename);
++LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o,
++ TMS event);
++LUAI_FUNC void luaT_init (lua_State *L);
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/luaconf.h
+@@ -0,0 +1,797 @@
++/*
++** $Id: luaconf.h,v 1.82.1.7 2008/02/11 16:25:08 roberto Exp $
++** Configuration file for Lua
++** See Copyright Notice in lua.h
++*/
++
++
++#ifndef lconfig_h
++#define lconfig_h
++
++#include <stddef.h>
++
++#if !defined(__KERNEL__)
++#include <limits.h>
++#else
++#define UCHAR_MAX 255
++#define SHRT_MAX 32767
++#define BUFSIZ 8192
++#define NO_FPU
++#endif
++
++/*
++** ==================================================================
++** Search for "@@" to find all configurable definitions.
++** ===================================================================
++*/
++
++
++/*
++@@ LUA_ANSI controls the use of non-ansi features.
++** CHANGE it (define it) if you want Lua to avoid the use of any
++** non-ansi feature or library.
++*/
++#if defined(__STRICT_ANSI__)
++#define LUA_ANSI
++#endif
++
++
++#if !defined(LUA_ANSI) && defined(_WIN32)
++#define LUA_WIN
++#endif
++
++#if defined(LUA_USE_LINUX)
++#define LUA_USE_POSIX
++#define LUA_USE_DLOPEN /* needs an extra library: -ldl */
++#define LUA_USE_READLINE /* needs some extra libraries */
++#endif
++
++#if defined(LUA_USE_MACOSX)
++#define LUA_USE_POSIX
++#define LUA_DL_DYLD /* does not need extra library */
++#endif
++
++
++
++/*
++@@ LUA_USE_POSIX includes all functionallity listed as X/Open System
++@* Interfaces Extension (XSI).
++** CHANGE it (define it) if your system is XSI compatible.
++*/
++#if defined(LUA_USE_POSIX)
++#define LUA_USE_MKSTEMP
++#define LUA_USE_ISATTY
++#define LUA_USE_POPEN
++#define LUA_USE_ULONGJMP
++#endif
++
++
++/*
++@@ LUA_PATH and LUA_CPATH are the names of the environment variables that
++@* Lua check to set its paths.
++@@ LUA_INIT is the name of the environment variable that Lua
++@* checks for initialization code.
++** CHANGE them if you want different names.
++*/
++#define LUA_PATH "LUA_PATH"
++#define LUA_CPATH "LUA_CPATH"
++#define LUA_INIT "LUA_INIT"
++
++
++/*
++@@ LUA_PATH_DEFAULT is the default path that Lua uses to look for
++@* Lua libraries.
++@@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for
++@* C libraries.
++** CHANGE them if your machine has a non-conventional directory
++** hierarchy or if you want to install your libraries in
++** non-conventional directories.
++*/
++#if defined(_WIN32)
++/*
++** In Windows, any exclamation mark ('!') in the path is replaced by the
++** path of the directory of the executable file of the current process.
++*/
++#define LUA_LDIR "!\\lua\\"
++#define LUA_CDIR "!\\"
++#define LUA_PATH_DEFAULT \
++ ".\\?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \
++ LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua"
++#define LUA_CPATH_DEFAULT \
++ ".\\?.dll;" LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll"
++
++#else
++#define LUA_ROOT "/usr/local/"
++#define LUA_LDIR LUA_ROOT "share/lua/5.1/"
++#define LUA_CDIR LUA_ROOT "lib/lua/5.1/"
++#define LUA_PATH_DEFAULT \
++ "./?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \
++ LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua"
++#define LUA_CPATH_DEFAULT \
++ "./?.so;" LUA_CDIR"?.so;" LUA_CDIR"loadall.so"
++#endif
++
++
++/*
++@@ LUA_DIRSEP is the directory separator (for submodules).
++** CHANGE it if your machine does not use "/" as the directory separator
++** and is not Windows. (On Windows Lua automatically uses "\".)
++*/
++#if defined(_WIN32)
++#define LUA_DIRSEP "\\"
++#else
++#define LUA_DIRSEP "/"
++#endif
++
++
++/*
++@@ LUA_PATHSEP is the character that separates templates in a path.
++@@ LUA_PATH_MARK is the string that marks the substitution points in a
++@* template.
++@@ LUA_EXECDIR in a Windows path is replaced by the executable's
++@* directory.
++@@ LUA_IGMARK is a mark to ignore all before it when bulding the
++@* luaopen_ function name.
++** CHANGE them if for some reason your system cannot use those
++** characters. (E.g., if one of those characters is a common character
++** in file/directory names.) Probably you do not need to change them.
++*/
++#define LUA_PATHSEP ";"
++#define LUA_PATH_MARK "?"
++#define LUA_EXECDIR "!"
++#define LUA_IGMARK "-"
++
++
++/*
++@@ LUA_INTEGER is the integral type used by lua_pushinteger/lua_tointeger.
++** CHANGE that if ptrdiff_t is not adequate on your machine. (On most
++** machines, ptrdiff_t gives a good choice between int or long.)
++*/
++#define LUA_INTEGER ptrdiff_t
++
++
++/*
++@@ LUA_API is a mark for all core API functions.
++@@ LUALIB_API is a mark for all standard library functions.
++** CHANGE them if you need to define those functions in some special way.
++** For instance, if you want to create one Windows DLL with the core and
++** the libraries, you may want to use the following definition (define
++** LUA_BUILD_AS_DLL to get it).
++*/
++#if defined(LUA_BUILD_AS_DLL)
++
++#if defined(LUA_CORE) || defined(LUA_LIB)
++#define LUA_API __declspec(dllexport)
++#else
++#define LUA_API __declspec(dllimport)
++#endif
++
++#else
++
++#define LUA_API extern
++
++#endif
++
++/* more often than not the libs go together with the core */
++#define LUALIB_API LUA_API
++
++
++/*
++@@ LUAI_FUNC is a mark for all extern functions that are not to be
++@* exported to outside modules.
++@@ LUAI_DATA is a mark for all extern (const) variables that are not to
++@* be exported to outside modules.
++** CHANGE them if you need to mark them in some special way. Elf/gcc
++** (versions 3.2 and later) mark them as "hidden" to optimize access
++** when Lua is compiled as a shared library.
++*/
++#if defined(luaall_c)
++#define LUAI_FUNC static
++#define LUAI_DATA /* empty */
++
++#elif defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \
++ defined(__ELF__)
++#define LUAI_FUNC __attribute__((visibility("hidden"))) extern
++#define LUAI_DATA LUAI_FUNC
++
++#else
++#define LUAI_FUNC extern
++#define LUAI_DATA extern
++#endif
++
++
++
++/*
++@@ LUA_QL describes how error messages quote program elements.
++** CHANGE it if you want a different appearance.
++*/
++#define LUA_QL(x) "'" x "'"
++#define LUA_QS LUA_QL("%s")
++
++
++/*
++@@ LUA_IDSIZE gives the maximum size for the description of the source
++@* of a function in debug information.
++** CHANGE it if you want a different size.
++*/
++#define LUA_IDSIZE 60
++
++
++/*
++** {==================================================================
++** Stand-alone configuration
++** ===================================================================
++*/
++
++#if defined(lua_c) || defined(luaall_c)
++
++/*
++@@ lua_stdin_is_tty detects whether the standard input is a 'tty' (that
++@* is, whether we're running lua interactively).
++** CHANGE it if you have a better definition for non-POSIX/non-Windows
++** systems.
++*/
++#if defined(LUA_USE_ISATTY)
++#include <unistd.h>
++#define lua_stdin_is_tty() isatty(0)
++#elif defined(LUA_WIN)
++#include <io.h>
++#include <stdio.h>
++#define lua_stdin_is_tty() _isatty(_fileno(stdin))
++#else
++#define lua_stdin_is_tty() 1 /* assume stdin is a tty */
++#endif
++
++
++/*
++@@ LUA_PROMPT is the default prompt used by stand-alone Lua.
++@@ LUA_PROMPT2 is the default continuation prompt used by stand-alone Lua.
++** CHANGE them if you want different prompts. (You can also change the
++** prompts dynamically, assigning to globals _PROMPT/_PROMPT2.)
++*/
++#define LUA_PROMPT "> "
++#define LUA_PROMPT2 ">> "
++
++
++/*
++@@ LUA_PROGNAME is the default name for the stand-alone Lua program.
++** CHANGE it if your stand-alone interpreter has a different name and
++** your system is not able to detect that name automatically.
++*/
++#define LUA_PROGNAME "lua"
++
++
++/*
++@@ LUA_MAXINPUT is the maximum length for an input line in the
++@* stand-alone interpreter.
++** CHANGE it if you need longer lines.
++*/
++#define LUA_MAXINPUT 512
++
++
++/*
++@@ lua_readline defines how to show a prompt and then read a line from
++@* the standard input.
++@@ lua_saveline defines how to "save" a read line in a "history".
++@@ lua_freeline defines how to free a line read by lua_readline.
++** CHANGE them if you want to improve this functionality (e.g., by using
++** GNU readline and history facilities).
++*/
++#if defined(LUA_USE_READLINE)
++#include <stdio.h>
++#include <readline/readline.h>
++#include <readline/history.h>
++#define lua_readline(L,b,p) ((void)L, ((b)=readline(p)) != NULL)
++#define lua_saveline(L,idx) \
++ if (lua_strlen(L,idx) > 0) /* non-empty line? */ \
++ add_history(lua_tostring(L, idx)); /* add it to history */
++#define lua_freeline(L,b) ((void)L, free(b))
++#else
++#define lua_readline(L,b,p) \
++ ((void)L, fputs(p, stdout), fflush(stdout), /* show prompt */ \
++ fgets(b, LUA_MAXINPUT, stdin) != NULL) /* get line */
++#define lua_saveline(L,idx) { (void)L; (void)idx; }
++#define lua_freeline(L,b) { (void)L; (void)b; }
++#endif
++
++#endif
++
++/* }================================================================== */
++
++
++/*
++@@ LUAI_GCPAUSE defines the default pause between garbage-collector cycles
++@* as a percentage.
++** CHANGE it if you want the GC to run faster or slower (higher values
++** mean larger pauses which mean slower collection.) You can also change
++** this value dynamically.
++*/
++#define LUAI_GCPAUSE 200 /* 200% (wait memory to double before next GC) */
++
++
++/*
++@@ LUAI_GCMUL defines the default speed of garbage collection relative to
++@* memory allocation as a percentage.
++** CHANGE it if you want to change the granularity of the garbage
++** collection. (Higher values mean coarser collections. 0 represents
++** infinity, where each step performs a full collection.) You can also
++** change this value dynamically.
++*/
++#define LUAI_GCMUL 200 /* GC runs 'twice the speed' of memory allocation */
++
++
++
++/*
++@@ LUA_COMPAT_GETN controls compatibility with old getn behavior.
++** CHANGE it (define it) if you want exact compatibility with the
++** behavior of setn/getn in Lua 5.0.
++*/
++#undef LUA_COMPAT_GETN
++
++/*
++@@ LUA_COMPAT_LOADLIB controls compatibility about global loadlib.
++** CHANGE it to undefined as soon as you do not need a global 'loadlib'
++** function (the function is still available as 'package.loadlib').
++*/
++#undef LUA_COMPAT_LOADLIB
++
++/*
++@@ LUA_COMPAT_VARARG controls compatibility with old vararg feature.
++** CHANGE it to undefined as soon as your programs use only '...' to
++** access vararg parameters (instead of the old 'arg' table).
++*/
++#define LUA_COMPAT_VARARG
++
++/*
++@@ LUA_COMPAT_MOD controls compatibility with old math.mod function.
++** CHANGE it to undefined as soon as your programs use 'math.fmod' or
++** the new '%' operator instead of 'math.mod'.
++*/
++#define LUA_COMPAT_MOD
++
++/*
++@@ LUA_COMPAT_LSTR controls compatibility with old long string nesting
++@* facility.
++** CHANGE it to 2 if you want the old behaviour, or undefine it to turn
++** off the advisory error when nesting [[...]].
++*/
++#define LUA_COMPAT_LSTR 1
++
++/*
++@@ LUA_COMPAT_GFIND controls compatibility with old 'string.gfind' name.
++** CHANGE it to undefined as soon as you rename 'string.gfind' to
++** 'string.gmatch'.
++*/
++#define LUA_COMPAT_GFIND
++
++/*
++@@ LUA_COMPAT_OPENLIB controls compatibility with old 'luaL_openlib'
++@* behavior.
++** CHANGE it to undefined as soon as you replace to 'luaL_register'
++** your uses of 'luaL_openlib'
++*/
++#define LUA_COMPAT_OPENLIB
++
++
++
++/*
++@@ luai_apicheck is the assert macro used by the Lua-C API.
++** CHANGE luai_apicheck if you want Lua to perform some checks in the
++** parameters it gets from API calls. This may slow down the interpreter
++** a bit, but may be quite useful when debugging C code that interfaces
++** with Lua. A useful redefinition is to use assert.h.
++*/
++#if defined(LUA_USE_APICHECK)
++#include <assert.h>
++#define luai_apicheck(L,o) { (void)L; assert(o); }
++#else
++#define luai_apicheck(L,o) { (void)L; }
++#endif
++
++
++/*
++@@ LUAI_BITSINT defines the number of bits in an int.
++** CHANGE here if Lua cannot automatically detect the number of bits of
++** your machine. Probably you do not need to change this.
++*/
++/* avoid overflows in comparison */
++#if !defined(__KERNEL__)
++#include <limits.h>
++#define LUA_INT_MAX INT_MAX
++#else
++#define LUA_INT_MAX (~0U>>1)
++#endif
++
++#if LUA_INT_MAX-20 < 32760
++#define LUAI_BITSINT 16
++#elif LUA_INT_MAX > 2147483640L
++/* int has at least 32 bits */
++#define LUAI_BITSINT 32
++#else
++#error "you must define LUA_BITSINT with number of bits in an integer"
++#endif
++
++
++/*
++@@ LUAI_UINT32 is an unsigned integer with at least 32 bits.
++@@ LUAI_INT32 is an signed integer with at least 32 bits.
++@@ LUAI_UMEM is an unsigned integer big enough to count the total
++@* memory used by Lua.
++@@ LUAI_MEM is a signed integer big enough to count the total memory
++@* used by Lua.
++** CHANGE here if for some weird reason the default definitions are not
++** good enough for your machine. (The definitions in the 'else'
++** part always works, but may waste space on machines with 64-bit
++** longs.) Probably you do not need to change this.
++*/
++#if LUAI_BITSINT >= 32
++#define LUAI_UINT32 unsigned int
++#define LUAI_INT32 int
++#define LUAI_MAXINT32 INT_MAX
++#define LUAI_UMEM size_t
++#define LUAI_MEM ptrdiff_t
++#else
++/* 16-bit ints */
++#define LUAI_UINT32 unsigned long
++#define LUAI_INT32 long
++#define LUAI_MAXINT32 LONG_MAX
++#define LUAI_UMEM unsigned long
++#define LUAI_MEM long
++#endif
++
++
++/*
++@@ LUAI_MAXCALLS limits the number of nested calls.
++** CHANGE it if you need really deep recursive calls. This limit is
++** arbitrary; its only purpose is to stop infinite recursion before
++** exhausting memory.
++*/
++#define LUAI_MAXCALLS 20000
++
++
++/*
++@@ LUAI_MAXCSTACK limits the number of Lua stack slots that a C function
++@* can use.
++** CHANGE it if you need lots of (Lua) stack space for your C
++** functions. This limit is arbitrary; its only purpose is to stop C
++** functions to consume unlimited stack space. (must be smaller than
++** -LUA_REGISTRYINDEX)
++*/
++#define LUAI_MAXCSTACK 8000
++
++
++
++/*
++** {==================================================================
++** CHANGE (to smaller values) the following definitions if your system
++** has a small C stack. (Or you may want to change them to larger
++** values if your system has a large C stack and these limits are
++** too rigid for you.) Some of these constants control the size of
++** stack-allocated arrays used by the compiler or the interpreter, while
++** others limit the maximum number of recursive calls that the compiler
++** or the interpreter can perform. Values too large may cause a C stack
++** overflow for some forms of deep constructs.
++** ===================================================================
++*/
++
++
++/*
++@@ LUAI_MAXCCALLS is the maximum depth for nested C calls (short) and
++@* syntactical nested non-terminals in a program.
++*/
++#define LUAI_MAXCCALLS 200
++
++
++/*
++@@ LUAI_MAXVARS is the maximum number of local variables per function
++@* (must be smaller than 250).
++*/
++#define LUAI_MAXVARS 200
++
++
++/*
++@@ LUAI_MAXUPVALUES is the maximum number of upvalues per function
++@* (must be smaller than 250).
++*/
++#define LUAI_MAXUPVALUES 60
++
++
++/*
++@@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system.
++*/
++#define LUAL_BUFFERSIZE BUFSIZ
++
++/* }================================================================== */
++
++
++
++
++/*
++** {==================================================================
++@@ LUA_NUMBER is the type of numbers in Lua.
++** CHANGE the following definitions only if you want to build Lua
++** with a number type different from double. You may also need to
++** change lua_number2int & lua_number2integer.
++** ===================================================================
++*/
++#if !defined(NO_FPU)
++#define LUA_NUMBER_DOUBLE
++#define LUA_NUMBER double
++#else
++#define LUA_NUMBER long
++#endif
++
++/*
++@@ LUAI_UACNUMBER is the result of an 'usual argument conversion'
++@* over a number.
++*/
++#define LUAI_UACNUMBER LUA_NUMBER
++
++
++/*
++@@ LUA_NUMBER_SCAN is the format for reading numbers.
++@@ LUA_NUMBER_FMT is the format for writing numbers.
++@@ lua_number2str converts a number to a string.
++@@ LUAI_MAXNUMBER2STR is maximum size of previous conversion.
++@@ lua_str2number converts a string to a number.
++*/
++#if !defined(NO_FPU)
++#define LUA_NUMBER_SCAN "%lf"
++#define LUA_NUMBER_FMT "%.14g"
++#define lua_str2number(s,p) strtod((s), (p))
++#else
++#define LUA_NUMBER_SCAN "%ld"
++#define LUA_NUMBER_FMT "%ld"
++#if !defined(__KERNEL__)
++#define lua_str2number(s,p) strtol((s), (p), 10)
++#else
++#define lua_str2number(s,p) simple_strtol((s), (p), 10)
++#endif
++#endif
++
++#define LUAI_MAXNUMBER2STR 32 /* 16 digits, sign, point, and \0 */
++#define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n))
++
++/*
++@@ The luai_num* macros define the primitive operations over numbers.
++*/
++#if defined(LUA_CORE)
++#define luai_numadd(a,b) ((a)+(b))
++#define luai_numsub(a,b) ((a)-(b))
++#define luai_nummul(a,b) ((a)*(b))
++#define luai_numdiv(a,b) ((a)/(b))
++#define luai_numunm(a) (-(a))
++#define luai_numeq(a,b) ((a)==(b))
++#define luai_numlt(a,b) ((a)<(b))
++#define luai_numle(a,b) ((a)<=(b))
++#define luai_numisnan(a) (!luai_numeq((a), (a)))
++#if !defined(NO_FPU)
++#include <math.h>
++#define luai_nummod(a,b) ((a) - floor((a)/(b))*(b))
++#define luai_numpow(a,b) (pow(a,b))
++#else
++#define luai_nummod(a,b) ((a)%(b))
++#define luai_numpow(a,b) luai_nummul(a,b)
++#endif
++#endif
++
++
++/*
++@@ lua_number2int is a macro to convert lua_Number to int.
++@@ lua_number2integer is a macro to convert lua_Number to lua_Integer.
++** CHANGE them if you know a faster way to convert a lua_Number to
++** int (with any rounding method and without throwing errors) in your
++** system. In Pentium machines, a naive typecast from double to int
++** in C is extremely slow, so any alternative is worth trying.
++*/
++
++/* On a Pentium, resort to a trick */
++#if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) && !defined(__SSE2__) && \
++ (defined(__i386) || defined (_M_IX86) || defined(__i386__))
++
++/* On a Microsoft compiler, use assembler */
++#if defined(_MSC_VER)
++
++#define lua_number2int(i,d) __asm fld d __asm fistp i
++#define lua_number2integer(i,n) lua_number2int(i, n)
++
++/* the next trick should work on any Pentium, but sometimes clashes
++ with a DirectX idiosyncrasy */
++#else
++
++union luai_Cast { double l_d; long l_l; };
++#define lua_number2int(i,d) \
++ { volatile union luai_Cast u; u.l_d = (d) + 6755399441055744.0; (i) = u.l_l; }
++#define lua_number2integer(i,n) lua_number2int(i, n)
++
++#endif
++
++
++/* this option always works, but may be slow */
++#else
++#define lua_number2int(i,d) ((i)=(int)(d))
++#define lua_number2integer(i,d) ((i)=(lua_Integer)(d))
++
++#endif
++
++/* }================================================================== */
++
++
++/*
++@@ LUAI_USER_ALIGNMENT_T is a type that requires maximum alignment.
++** CHANGE it if your system requires alignments larger than double. (For
++** instance, if your system supports long doubles and they must be
++** aligned in 16-byte boundaries, then you should add long double in the
++** union.) Probably you do not need to change this.
++*/
++#define LUAI_USER_ALIGNMENT_T union { double u; void *s; long l; }
++
++
++/*
++@@ LUAI_THROW/LUAI_TRY define how Lua does exception handling.
++** CHANGE them if you prefer to use longjmp/setjmp even with C++
++** or if want/don't to use _longjmp/_setjmp instead of regular
++** longjmp/setjmp. By default, Lua handles errors with exceptions when
++** compiling as C++ code, with _longjmp/_setjmp when asked to use them,
++** and with longjmp/setjmp otherwise.
++*/
++#if defined(__KERNEL__)
++#undef LUA_USE_ULONGJMP
++#endif
++
++#if defined(__cplusplus)
++/* C++ exceptions */
++#define LUAI_THROW(L,c) throw(c)
++#define LUAI_TRY(L,c,a) try { a } catch(...) \
++ { if ((c)->status == 0) (c)->status = -1; }
++#define luai_jmpbuf int /* dummy variable */
++
++#elif defined(LUA_USE_ULONGJMP)
++/* in Unix, try _longjmp/_setjmp (more efficient) */
++#define LUAI_THROW(L,c) _longjmp((c)->b, 1)
++#define LUAI_TRY(L,c,a) if (_setjmp((c)->b) == 0) { a }
++#define luai_jmpbuf jmp_buf
++
++#else
++/* default handling with long jumps */
++#define LUAI_THROW(L,c) longjmp((c)->b, 1)
++#define LUAI_TRY(L,c,a) if (setjmp((c)->b) == 0) { a }
++#define luai_jmpbuf jmp_buf
++
++#endif
++
++
++/*
++@@ LUA_MAXCAPTURES is the maximum number of captures that a pattern
++@* can do during pattern-matching.
++** CHANGE it if you need more captures. This limit is arbitrary.
++*/
++#define LUA_MAXCAPTURES 32
++
++
++/*
++@@ lua_tmpnam is the function that the OS library uses to create a
++@* temporary name.
++@@ LUA_TMPNAMBUFSIZE is the maximum size of a name created by lua_tmpnam.
++** CHANGE them if you have an alternative to tmpnam (which is considered
++** insecure) or if you want the original tmpnam anyway. By default, Lua
++** uses tmpnam except when POSIX is available, where it uses mkstemp.
++*/
++#if defined(loslib_c) || defined(luaall_c)
++
++#if defined(LUA_USE_MKSTEMP)
++#include <unistd.h>
++#define LUA_TMPNAMBUFSIZE 32
++#define lua_tmpnam(b,e) { \
++ strcpy(b, "/tmp/lua_XXXXXX"); \
++ e = mkstemp(b); \
++ if (e != -1) close(e); \
++ e = (e == -1); }
++
++#else
++#define LUA_TMPNAMBUFSIZE L_tmpnam
++#define lua_tmpnam(b,e) { e = (tmpnam(b) == NULL); }
++#endif
++
++#endif
++
++
++/*
++@@ lua_popen spawns a new process connected to the current one through
++@* the file streams.
++** CHANGE it if you have a way to implement it in your system.
++*/
++#if defined(LUA_USE_POPEN)
++
++#define lua_popen(L,c,m) ((void)L, fflush(NULL), popen(c,m))
++#define lua_pclose(L,file) ((void)L, (pclose(file) != -1))
++
++#elif defined(LUA_WIN)
++
++#define lua_popen(L,c,m) ((void)L, _popen(c,m))
++#define lua_pclose(L,file) ((void)L, (_pclose(file) != -1))
++
++#else
++
++#define lua_popen(L,c,m) ((void)((void)c, m), \
++ luaL_error(L, LUA_QL("popen") " not supported"), (FILE*)0)
++#define lua_pclose(L,file) ((void)((void)L, file), 0)
++
++#endif
++
++/*
++@@ LUA_DL_* define which dynamic-library system Lua should use.
++** CHANGE here if Lua has problems choosing the appropriate
++** dynamic-library system for your platform (either Windows' DLL, Mac's
++** dyld, or Unix's dlopen). If your system is some kind of Unix, there
++** is a good chance that it has dlopen, so LUA_DL_DLOPEN will work for
++** it. To use dlopen you also need to adapt the src/Makefile (probably
++** adding -ldl to the linker options), so Lua does not select it
++** automatically. (When you change the makefile to add -ldl, you must
++** also add -DLUA_USE_DLOPEN.)
++** If you do not want any kind of dynamic library, undefine all these
++** options.
++** By default, _WIN32 gets LUA_DL_DLL and MAC OS X gets LUA_DL_DYLD.
++*/
++#if defined(LUA_USE_DLOPEN)
++#define LUA_DL_DLOPEN
++#endif
++
++#if defined(LUA_WIN)
++#define LUA_DL_DLL
++#endif
++
++
++/*
++@@ LUAI_EXTRASPACE allows you to add user-specific data in a lua_State
++@* (the data goes just *before* the lua_State pointer).
++** CHANGE (define) this if you really need that. This value must be
++** a multiple of the maximum alignment required for your machine.
++*/
++#define LUAI_EXTRASPACE 0
++
++
++/*
++@@ luai_userstate* allow user-specific actions on threads.
++** CHANGE them if you defined LUAI_EXTRASPACE and need to do something
++** extra when a thread is created/deleted/resumed/yielded.
++*/
++#define luai_userstateopen(L) ((void)L)
++#define luai_userstateclose(L) ((void)L)
++#define luai_userstatethread(L,L1) ((void)L)
++#define luai_userstatefree(L) ((void)L)
++#define luai_userstateresume(L,n) ((void)L)
++#define luai_userstateyield(L,n) ((void)L)
++
++
++/*
++@@ LUA_INTFRMLEN is the length modifier for integer conversions
++@* in 'string.format'.
++@@ LUA_INTFRM_T is the integer type correspoding to the previous length
++@* modifier.
++** CHANGE them if your system supports long long or does not support long.
++*/
++
++#if defined(LUA_USELONGLONG)
++
++#define LUA_INTFRMLEN "ll"
++#define LUA_INTFRM_T long long
++
++#else
++
++#define LUA_INTFRMLEN "l"
++#define LUA_INTFRM_T long
++
++#endif
++
++/* =================================================================== */
++
++/*
++** Local configuration. You can use this space to add your redefinitions
++** without modifying the main part of the file.
++*/
++
++
++
++#endif
++
+--- /dev/null
++++ b/extensions/LUA/lua/lua.h
+@@ -0,0 +1,387 @@
++/*
++** $Id: lua.h,v 1.218.1.5 2008/08/06 13:30:12 roberto Exp $
++** Lua - An Extensible Extension Language
++** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
++** See Copyright Notice at the end of this file
++*/
++
++
++#ifndef lua_h
++#define lua_h
++
++#include <stdarg.h>
++#include <stddef.h>
++
++#include "luaconf.h"
++
++
++#define LUA_VERSION "Lua 5.1"
++#define LUA_RELEASE "Lua 5.1.4"
++#define LUA_VERSION_NUM 501
++#define LUA_COPYRIGHT "Copyright (C) 1994-2008 Lua.org, PUC-Rio"
++#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo & W. Celes"
++
++
++/* mark for precompiled code (`<esc>Lua') */
++#define LUA_SIGNATURE "\033Lua"
++
++/* option for multiple returns in `lua_pcall' and `lua_call' */
++#define LUA_MULTRET (-1)
++
++
++/*
++** pseudo-indices
++*/
++#define LUA_REGISTRYINDEX (-10000)
++#define LUA_ENVIRONINDEX (-10001)
++#define LUA_GLOBALSINDEX (-10002)
++#define lua_upvalueindex(i) (LUA_GLOBALSINDEX-(i))
++
++
++/* thread status; 0 is OK */
++#define LUA_YIELD 1
++#define LUA_ERRRUN 2
++#define LUA_ERRSYNTAX 3
++#define LUA_ERRMEM 4
++#define LUA_ERRERR 5
++
++
++typedef struct lua_State lua_State;
++
++typedef int (*lua_CFunction) (lua_State *L);
++
++
++/*
++** functions that read/write blocks when loading/dumping Lua chunks
++*/
++typedef const char * (*lua_Reader) (lua_State *L, void *ud, size_t *sz);
++
++typedef int (*lua_Writer) (lua_State *L, const void* p, size_t sz, void* ud);
++
++
++/*
++** prototype for memory-allocation functions
++*/
++typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize);
++
++
++/*
++** basic types
++*/
++#define LUA_TNONE (-1)
++
++#define LUA_TNIL 0
++#define LUA_TBOOLEAN 1
++#define LUA_TLIGHTUSERDATA 2
++#define LUA_TNUMBER 3
++#define LUA_TSTRING 4
++#define LUA_TTABLE 5
++#define LUA_TFUNCTION 6
++#define LUA_TUSERDATA 7
++#define LUA_TTHREAD 8
++
++
++
++/* minimum Lua stack available to a C function */
++#define LUA_MINSTACK 20
++
++
++/*
++** generic extra include file
++*/
++#if defined(LUA_USER_H)
++#include LUA_USER_H
++#endif
++
++
++/* type of numbers in Lua */
++typedef LUA_NUMBER lua_Number;
++
++
++/* type for integer functions */
++typedef LUA_INTEGER lua_Integer;
++
++
++
++/*
++** state manipulation
++*/
++LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud);
++LUA_API void (lua_close) (lua_State *L);
++LUA_API lua_State *(lua_newthread) (lua_State *L);
++
++LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf);
++
++
++/*
++** basic stack manipulation
++*/
++LUA_API int (lua_gettop) (lua_State *L);
++LUA_API void (lua_settop) (lua_State *L, int idx);
++LUA_API void (lua_pushvalue) (lua_State *L, int idx);
++LUA_API void (lua_remove) (lua_State *L, int idx);
++LUA_API void (lua_insert) (lua_State *L, int idx);
++LUA_API void (lua_replace) (lua_State *L, int idx);
++LUA_API int (lua_checkstack) (lua_State *L, int sz);
++
++LUA_API void (lua_xmove) (lua_State *from, lua_State *to, int n);
++
++
++/*
++** access functions (stack -> C)
++*/
++
++LUA_API int (lua_isnumber) (lua_State *L, int idx);
++LUA_API int (lua_isstring) (lua_State *L, int idx);
++LUA_API int (lua_iscfunction) (lua_State *L, int idx);
++LUA_API int (lua_isuserdata) (lua_State *L, int idx);
++LUA_API int (lua_type) (lua_State *L, int idx);
++LUA_API const char *(lua_typename) (lua_State *L, int tp);
++
++LUA_API int (lua_equal) (lua_State *L, int idx1, int idx2);
++LUA_API int (lua_rawequal) (lua_State *L, int idx1, int idx2);
++LUA_API int (lua_lessthan) (lua_State *L, int idx1, int idx2);
++
++LUA_API lua_Number (lua_tonumber) (lua_State *L, int idx);
++LUA_API lua_Integer (lua_tointeger) (lua_State *L, int idx);
++LUA_API int (lua_toboolean) (lua_State *L, int idx);
++LUA_API const char *(lua_tolstring) (lua_State *L, int idx, size_t *len);
++LUA_API size_t (lua_objlen) (lua_State *L, int idx);
++LUA_API lua_CFunction (lua_tocfunction) (lua_State *L, int idx);
++LUA_API void *(lua_touserdata) (lua_State *L, int idx);
++LUA_API lua_State *(lua_tothread) (lua_State *L, int idx);
++LUA_API const void *(lua_topointer) (lua_State *L, int idx);
++
++
++/*
++** push functions (C -> stack)
++*/
++LUA_API void (lua_pushnil) (lua_State *L);
++LUA_API void (lua_pushnumber) (lua_State *L, lua_Number n);
++LUA_API void (lua_pushinteger) (lua_State *L, lua_Integer n);
++LUA_API void (lua_pushlstring) (lua_State *L, const char *s, size_t l);
++LUA_API void (lua_pushstring) (lua_State *L, const char *s);
++LUA_API const char *(lua_pushvfstring) (lua_State *L, const char *fmt,
++ va_list argp);
++LUA_API const char *(lua_pushfstring) (lua_State *L, const char *fmt, ...);
++LUA_API void (lua_pushcclosure) (lua_State *L, lua_CFunction fn, int n);
++LUA_API void (lua_pushboolean) (lua_State *L, int b);
++LUA_API void (lua_pushlightuserdata) (lua_State *L, void *p);
++LUA_API int (lua_pushthread) (lua_State *L);
++
++
++/*
++** get functions (Lua -> stack)
++*/
++LUA_API void (lua_gettable) (lua_State *L, int idx);
++LUA_API void (lua_getfield) (lua_State *L, int idx, const char *k);
++LUA_API void (lua_rawget) (lua_State *L, int idx);
++LUA_API void (lua_rawgeti) (lua_State *L, int idx, int n);
++LUA_API void (lua_createtable) (lua_State *L, int narr, int nrec);
++LUA_API void *(lua_newuserdata) (lua_State *L, size_t sz);
++LUA_API int (lua_getmetatable) (lua_State *L, int objindex);
++LUA_API void (lua_getfenv) (lua_State *L, int idx);
++
++
++/*
++** set functions (stack -> Lua)
++*/
++LUA_API void (lua_settable) (lua_State *L, int idx);
++LUA_API void (lua_setfield) (lua_State *L, int idx, const char *k);
++LUA_API void (lua_rawset) (lua_State *L, int idx);
++LUA_API void (lua_rawseti) (lua_State *L, int idx, int n);
++LUA_API int (lua_setmetatable) (lua_State *L, int objindex);
++LUA_API int (lua_setfenv) (lua_State *L, int idx);
++
++
++/*
++** `load' and `call' functions (load and run Lua code)
++*/
++LUA_API void (lua_call) (lua_State *L, int nargs, int nresults);
++LUA_API int (lua_pcall) (lua_State *L, int nargs, int nresults, int errfunc);
++LUA_API int (lua_cpcall) (lua_State *L, lua_CFunction func, void *ud);
++LUA_API int (lua_load) (lua_State *L, lua_Reader reader, void *dt,
++ const char *chunkname);
++
++LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data);
++
++
++/*
++** coroutine functions
++*/
++LUA_API int (lua_yield) (lua_State *L, int nresults);
++LUA_API int (lua_resume) (lua_State *L, int narg);
++LUA_API int (lua_status) (lua_State *L);
++
++/*
++** garbage-collection function and options
++*/
++
++#define LUA_GCSTOP 0
++#define LUA_GCRESTART 1
++#define LUA_GCCOLLECT 2
++#define LUA_GCCOUNT 3
++#define LUA_GCCOUNTB 4
++#define LUA_GCSTEP 5
++#define LUA_GCSETPAUSE 6
++#define LUA_GCSETSTEPMUL 7
++
++LUA_API int (lua_gc) (lua_State *L, int what, int data);
++
++
++/*
++** miscellaneous functions
++*/
++
++LUA_API int (lua_error) (lua_State *L);
++
++LUA_API int (lua_next) (lua_State *L, int idx);
++
++LUA_API void (lua_concat) (lua_State *L, int n);
++
++LUA_API lua_Alloc (lua_getallocf) (lua_State *L, void **ud);
++LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud);
++
++
++
++/*
++** ===============================================================
++** some useful macros
++** ===============================================================
++*/
++
++#define lua_pop(L,n) lua_settop(L, -(n)-1)
++
++#define lua_newtable(L) lua_createtable(L, 0, 0)
++
++#define lua_register(L,n,f) (lua_pushcfunction(L, (f)), lua_setglobal(L, (n)))
++
++#define lua_pushcfunction(L,f) lua_pushcclosure(L, (f), 0)
++
++#define lua_strlen(L,i) lua_objlen(L, (i))
++
++#define lua_isfunction(L,n) (lua_type(L, (n)) == LUA_TFUNCTION)
++#define lua_istable(L,n) (lua_type(L, (n)) == LUA_TTABLE)
++#define lua_islightuserdata(L,n) (lua_type(L, (n)) == LUA_TLIGHTUSERDATA)
++#define lua_isnil(L,n) (lua_type(L, (n)) == LUA_TNIL)
++#define lua_isboolean(L,n) (lua_type(L, (n)) == LUA_TBOOLEAN)
++#define lua_isthread(L,n) (lua_type(L, (n)) == LUA_TTHREAD)
++#define lua_isnone(L,n) (lua_type(L, (n)) == LUA_TNONE)
++#define lua_isnoneornil(L, n) (lua_type(L, (n)) <= 0)
++
++#define lua_pushliteral(L, s) \
++ lua_pushlstring(L, "" s, (sizeof(s)/sizeof(char))-1)
++
++#define lua_setglobal(L,s) lua_setfield(L, LUA_GLOBALSINDEX, (s))
++#define lua_getglobal(L,s) lua_getfield(L, LUA_GLOBALSINDEX, (s))
++
++#define lua_tostring(L,i) lua_tolstring(L, (i), NULL)
++
++
++
++/*
++** compatibility macros and functions
++*/
++
++#define lua_open() luaL_newstate()
++
++#define lua_getregistry(L) lua_pushvalue(L, LUA_REGISTRYINDEX)
++
++#define lua_getgccount(L) lua_gc(L, LUA_GCCOUNT, 0)
++
++#define lua_Chunkreader lua_Reader
++#define lua_Chunkwriter lua_Writer
++
++
++/* hack */
++LUA_API void lua_setlevel (lua_State *from, lua_State *to);
++
++
++/*
++** {======================================================================
++** Debug API
++** =======================================================================
++*/
++
++
++/*
++** Event codes
++*/
++#define LUA_HOOKCALL 0
++#define LUA_HOOKRET 1
++#define LUA_HOOKLINE 2
++#define LUA_HOOKCOUNT 3
++#define LUA_HOOKTAILRET 4
++
++
++/*
++** Event masks
++*/
++#define LUA_MASKCALL (1 << LUA_HOOKCALL)
++#define LUA_MASKRET (1 << LUA_HOOKRET)
++#define LUA_MASKLINE (1 << LUA_HOOKLINE)
++#define LUA_MASKCOUNT (1 << LUA_HOOKCOUNT)
++
++typedef struct lua_Debug lua_Debug; /* activation record */
++
++
++/* Functions to be called by the debuger in specific events */
++typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar);
++
++
++LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar);
++LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar);
++LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n);
++LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n);
++LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n);
++LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n);
++
++LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count);
++LUA_API lua_Hook lua_gethook (lua_State *L);
++LUA_API int lua_gethookmask (lua_State *L);
++LUA_API int lua_gethookcount (lua_State *L);
++
++
++struct lua_Debug {
++ int event;
++ const char *name; /* (n) */
++ const char *namewhat; /* (n) `global', `local', `field', `method' */
++ const char *what; /* (S) `Lua', `C', `main', `tail' */
++ const char *source; /* (S) */
++ int currentline; /* (l) */
++ int nups; /* (u) number of upvalues */
++ int linedefined; /* (S) */
++ int lastlinedefined; /* (S) */
++ char short_src[LUA_IDSIZE]; /* (S) */
++ /* private part */
++ int i_ci; /* active function */
++};
++
++/* }====================================================================== */
++
++
++/******************************************************************************
++* Copyright (C) 1994-2008 Lua.org, PUC-Rio. All rights reserved.
++*
++* Permission is hereby granted, free of charge, to any person obtaining
++* a copy of this software and associated documentation files (the
++* "Software"), to deal in the Software without restriction, including
++* without limitation the rights to use, copy, modify, merge, publish,
++* distribute, sublicense, and/or sell copies of the Software, and to
++* permit persons to whom the Software is furnished to do so, subject to
++* the following conditions:
++*
++* The above copyright notice and this permission notice shall be
++* included in all copies or substantial portions of the Software.
++*
++* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
++* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
++* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
++* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
++* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
++* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
++* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++******************************************************************************/
++
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/lualib.h
+@@ -0,0 +1,55 @@
++/*
++** $Id: lualib.h,v 1.36.1.1 2007/12/27 13:02:25 roberto Exp $
++** Lua standard libraries
++** See Copyright Notice in lua.h
++*/
++
++
++#ifndef lualib_h
++#define lualib_h
++
++#include "lua.h"
++
++
++/* Key to file-handle type */
++#define LUA_FILEHANDLE "FILE*"
++
++
++#define LUA_COLIBNAME "coroutine"
++LUALIB_API int (luaopen_base) (lua_State *L);
++
++#define LUA_TABLIBNAME "table"
++LUALIB_API int (luaopen_table) (lua_State *L);
++/*
++#define LUA_IOLIBNAME "io"
++LUALIB_API int (luaopen_io) (lua_State *L);
++
++#define LUA_OSLIBNAME "os"
++LUALIB_API int (luaopen_os) (lua_State *L);
++*/
++
++#define LUA_STRLIBNAME "string"
++LUALIB_API int (luaopen_string) (lua_State *L);
++
++/*
++#define LUA_MATHLIBNAME "math"
++LUALIB_API int (luaopen_math) (lua_State *L);
++
++#define LUA_DBLIBNAME "debug"
++LUALIB_API int (luaopen_debug) (lua_State *L);
++
++#define LUA_LOADLIBNAME "package"
++LUALIB_API int (luaopen_package) (lua_State *L);
++*/
++
++/* open all previous libraries */
++LUALIB_API void (luaL_openlibs) (lua_State *L);
++
++
++
++#ifndef lua_assert
++#define lua_assert(x) ((void)0)
++#endif
++
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/lundump.c
+@@ -0,0 +1,227 @@
++/*
++** $Id: lundump.c,v 2.7.1.4 2008/04/04 19:51:41 roberto Exp $
++** load precompiled Lua chunks
++** See Copyright Notice in lua.h
++*/
++
++#include <string.h>
++
++#define lundump_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "ldebug.h"
++#include "ldo.h"
++#include "lfunc.h"
++#include "lmem.h"
++#include "lobject.h"
++#include "lstring.h"
++#include "lundump.h"
++#include "lzio.h"
++
++typedef struct {
++ lua_State* L;
++ ZIO* Z;
++ Mbuffer* b;
++ const char* name;
++} LoadState;
++
++#ifdef LUAC_TRUST_BINARIES
++#define IF(c,s)
++#define error(S,s)
++#else
++#define IF(c,s) if (c) error(S,s)
++
++static void error(LoadState* S, const char* why)
++{
++ luaO_pushfstring(S->L,"%s: %s in precompiled chunk",S->name,why);
++ luaD_throw(S->L,LUA_ERRSYNTAX);
++}
++#endif
++
++#define LoadMem(S,b,n,size) LoadBlock(S,b,(n)*(size))
++#define LoadByte(S) (lu_byte)LoadChar(S)
++#define LoadVar(S,x) LoadMem(S,&x,1,sizeof(x))
++#define LoadVector(S,b,n,size) LoadMem(S,b,n,size)
++
++static void LoadBlock(LoadState* S, void* b, size_t size)
++{
++ size_t r=luaZ_read(S->Z,b,size);
++ IF (r!=0, "unexpected end");
++}
++
++static int LoadChar(LoadState* S)
++{
++ char x;
++ LoadVar(S,x);
++ return x;
++}
++
++static int LoadInt(LoadState* S)
++{
++ int x;
++ LoadVar(S,x);
++ IF (x<0, "bad integer");
++ return x;
++}
++
++static lua_Number LoadNumber(LoadState* S)
++{
++ lua_Number x;
++ LoadVar(S,x);
++ return x;
++}
++
++static TString* LoadString(LoadState* S)
++{
++ size_t size;
++ LoadVar(S,size);
++ if (size==0)
++ return NULL;
++ else
++ {
++ char* s=luaZ_openspace(S->L,S->b,size);
++ LoadBlock(S,s,size);
++ return luaS_newlstr(S->L,s,size-1); /* remove trailing '\0' */
++ }
++}
++
++static void LoadCode(LoadState* S, Proto* f)
++{
++ int n=LoadInt(S);
++ f->code=luaM_newvector(S->L,n,Instruction);
++ f->sizecode=n;
++ LoadVector(S,f->code,n,sizeof(Instruction));
++}
++
++static Proto* LoadFunction(LoadState* S, TString* p);
++
++static void LoadConstants(LoadState* S, Proto* f)
++{
++ int i,n;
++ n=LoadInt(S);
++ f->k=luaM_newvector(S->L,n,TValue);
++ f->sizek=n;
++ for (i=0; i<n; i++) setnilvalue(&f->k[i]);
++ for (i=0; i<n; i++)
++ {
++ TValue* o=&f->k[i];
++ int t=LoadChar(S);
++ switch (t)
++ {
++ case LUA_TNIL:
++ setnilvalue(o);
++ break;
++ case LUA_TBOOLEAN:
++ setbvalue(o,LoadChar(S)!=0);
++ break;
++ case LUA_TNUMBER:
++ setnvalue(o,LoadNumber(S));
++ break;
++ case LUA_TSTRING:
++ setsvalue2n(S->L,o,LoadString(S));
++ break;
++ default:
++ error(S,"bad constant");
++ break;
++ }
++ }
++ n=LoadInt(S);
++ f->p=luaM_newvector(S->L,n,Proto*);
++ f->sizep=n;
++ for (i=0; i<n; i++) f->p[i]=NULL;
++ for (i=0; i<n; i++) f->p[i]=LoadFunction(S,f->source);
++}
++
++static void LoadDebug(LoadState* S, Proto* f)
++{
++ int i,n;
++ n=LoadInt(S);
++ f->lineinfo=luaM_newvector(S->L,n,int);
++ f->sizelineinfo=n;
++ LoadVector(S,f->lineinfo,n,sizeof(int));
++ n=LoadInt(S);
++ f->locvars=luaM_newvector(S->L,n,LocVar);
++ f->sizelocvars=n;
++ for (i=0; i<n; i++) f->locvars[i].varname=NULL;
++ for (i=0; i<n; i++)
++ {
++ f->locvars[i].varname=LoadString(S);
++ f->locvars[i].startpc=LoadInt(S);
++ f->locvars[i].endpc=LoadInt(S);
++ }
++ n=LoadInt(S);
++ f->upvalues=luaM_newvector(S->L,n,TString*);
++ f->sizeupvalues=n;
++ for (i=0; i<n; i++) f->upvalues[i]=NULL;
++ for (i=0; i<n; i++) f->upvalues[i]=LoadString(S);
++}
++
++static Proto* LoadFunction(LoadState* S, TString* p)
++{
++ Proto* f;
++ if (++S->L->nCcalls > LUAI_MAXCCALLS) error(S,"code too deep");
++ f=luaF_newproto(S->L);
++ setptvalue2s(S->L,S->L->top,f); incr_top(S->L);
++ f->source=LoadString(S); if (f->source==NULL) f->source=p;
++ f->linedefined=LoadInt(S);
++ f->lastlinedefined=LoadInt(S);
++ f->nups=LoadByte(S);
++ f->numparams=LoadByte(S);
++ f->is_vararg=LoadByte(S);
++ f->maxstacksize=LoadByte(S);
++ LoadCode(S,f);
++ LoadConstants(S,f);
++ LoadDebug(S,f);
++ IF (!luaG_checkcode(f), "bad code");
++ S->L->top--;
++ S->L->nCcalls--;
++ return f;
++}
++
++static void LoadHeader(LoadState* S)
++{
++ char h[LUAC_HEADERSIZE];
++ char s[LUAC_HEADERSIZE];
++ luaU_header(h);
++ LoadBlock(S,s,LUAC_HEADERSIZE);
++ IF (memcmp(h,s,LUAC_HEADERSIZE)!=0, "bad header");
++}
++
++/*
++** load precompiled chunk
++*/
++Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name)
++{
++ LoadState S;
++ if (*name=='@' || *name=='=')
++ S.name=name+1;
++ else if (*name==LUA_SIGNATURE[0])
++ S.name="binary string";
++ else
++ S.name=name;
++ S.L=L;
++ S.Z=Z;
++ S.b=buff;
++ LoadHeader(&S);
++ return LoadFunction(&S,luaS_newliteral(L,"=?"));
++}
++
++/*
++* make header
++*/
++void luaU_header (char* h)
++{
++ int x=1;
++ memcpy(h,LUA_SIGNATURE,sizeof(LUA_SIGNATURE)-1);
++ h+=sizeof(LUA_SIGNATURE)-1;
++ *h++=(char)LUAC_VERSION;
++ *h++=(char)LUAC_FORMAT;
++ *h++=(char)*(char*)&x; /* endianness */
++ *h++=(char)sizeof(int);
++ *h++=(char)sizeof(size_t);
++ *h++=(char)sizeof(Instruction);
++ *h++=(char)sizeof(lua_Number);
++ *h++=(char)(((lua_Number)0.5)==0); /* is lua_Number integral? */
++}
+--- /dev/null
++++ b/extensions/LUA/lua/lundump.h
+@@ -0,0 +1,36 @@
++/*
++** $Id: lundump.h,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $
++** load precompiled Lua chunks
++** See Copyright Notice in lua.h
++*/
++
++#ifndef lundump_h
++#define lundump_h
++
++#include "lobject.h"
++#include "lzio.h"
++
++/* load one chunk; from lundump.c */
++LUAI_FUNC Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name);
++
++/* make header; from lundump.c */
++LUAI_FUNC void luaU_header (char* h);
++
++/* dump one chunk; from ldump.c */
++LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip);
++
++#ifdef luac_c
++/* print one chunk; from print.c */
++LUAI_FUNC void luaU_print (const Proto* f, int full);
++#endif
++
++/* for header of binary files -- this is Lua 5.1 */
++#define LUAC_VERSION 0x51
++
++/* for header of binary files -- this is the official format */
++#define LUAC_FORMAT 0
++
++/* size of header of binary files */
++#define LUAC_HEADERSIZE 12
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/lvm.c
+@@ -0,0 +1,762 @@
++/*
++** $Id: lvm.c,v 2.63.1.3 2007/12/28 15:32:23 roberto Exp $
++** Lua virtual machine
++** See Copyright Notice in lua.h
++*/
++
++#include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
++
++#define lvm_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "ldebug.h"
++#include "ldo.h"
++#include "lfunc.h"
++#include "lgc.h"
++#include "lobject.h"
++#include "lopcodes.h"
++#include "lstate.h"
++#include "lstring.h"
++#include "ltable.h"
++#include "ltm.h"
++#include "lvm.h"
++
++
++
++/* limit for table tag-method chains (to avoid loops) */
++#define MAXTAGLOOP 100
++
++
++const TValue *luaV_tonumber (const TValue *obj, TValue *n) {
++ lua_Number num;
++ if (ttisnumber(obj)) return obj;
++ if (ttisstring(obj) && luaO_str2d(svalue(obj), &num)) {
++ setnvalue(n, num);
++ return n;
++ }
++ else
++ return NULL;
++}
++
++
++int luaV_tostring (lua_State *L, StkId obj) {
++ if (!ttisnumber(obj))
++ return 0;
++ else {
++ char s[LUAI_MAXNUMBER2STR];
++ lua_Number n = nvalue(obj);
++ lua_number2str(s, n);
++ setsvalue2s(L, obj, luaS_new(L, s));
++ return 1;
++ }
++}
++
++
++static void traceexec (lua_State *L, const Instruction *pc) {
++ lu_byte mask = L->hookmask;
++ const Instruction *oldpc = L->savedpc;
++ L->savedpc = pc;
++ if ((mask & LUA_MASKCOUNT) && L->hookcount == 0) {
++ resethookcount(L);
++ luaD_callhook(L, LUA_HOOKCOUNT, -1);
++ }
++ if (mask & LUA_MASKLINE) {
++ Proto *p = ci_func(L->ci)->l.p;
++ int npc = pcRel(pc, p);
++ int newline = getline(p, npc);
++ /* call linehook when enter a new function, when jump back (loop),
++ or when enter a new line */
++ if (npc == 0 || pc <= oldpc || newline != getline(p, pcRel(oldpc, p)))
++ luaD_callhook(L, LUA_HOOKLINE, newline);
++ }
++}
++
++
++static void callTMres (lua_State *L, StkId res, const TValue *f,
++ const TValue *p1, const TValue *p2) {
++ ptrdiff_t result = savestack(L, res);
++ setobj2s(L, L->top, f); /* push function */
++ setobj2s(L, L->top+1, p1); /* 1st argument */
++ setobj2s(L, L->top+2, p2); /* 2nd argument */
++ luaD_checkstack(L, 3);
++ L->top += 3;
++ luaD_call(L, L->top - 3, 1);
++ res = restorestack(L, result);
++ L->top--;
++ setobjs2s(L, res, L->top);
++}
++
++
++
++static void callTM (lua_State *L, const TValue *f, const TValue *p1,
++ const TValue *p2, const TValue *p3) {
++ setobj2s(L, L->top, f); /* push function */
++ setobj2s(L, L->top+1, p1); /* 1st argument */
++ setobj2s(L, L->top+2, p2); /* 2nd argument */
++ setobj2s(L, L->top+3, p3); /* 3th argument */
++ luaD_checkstack(L, 4);
++ L->top += 4;
++ luaD_call(L, L->top - 4, 0);
++}
++
++
++void luaV_gettable (lua_State *L, const TValue *t, TValue *key, StkId val) {
++ int loop;
++ for (loop = 0; loop < MAXTAGLOOP; loop++) {
++ const TValue *tm;
++ if (ttistable(t)) { /* `t' is a table? */
++ Table *h = hvalue(t);
++ const TValue *res = luaH_get(h, key); /* do a primitive get */
++ if (!ttisnil(res) || /* result is no nil? */
++ (tm = fasttm(L, h->metatable, TM_INDEX)) == NULL) { /* or no TM? */
++ setobj2s(L, val, res);
++ return;
++ }
++ /* else will try the tag method */
++ }
++ else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_INDEX)))
++ luaG_typeerror(L, t, "index");
++ if (ttisfunction(tm)) {
++ callTMres(L, val, tm, t, key);
++ return;
++ }
++ t = tm; /* else repeat with `tm' */
++ }
++ luaG_runerror(L, "loop in gettable");
++}
++
++
++void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val) {
++ int loop;
++ for (loop = 0; loop < MAXTAGLOOP; loop++) {
++ const TValue *tm;
++ if (ttistable(t)) { /* `t' is a table? */
++ Table *h = hvalue(t);
++ TValue *oldval = luaH_set(L, h, key); /* do a primitive set */
++ if (!ttisnil(oldval) || /* result is no nil? */
++ (tm = fasttm(L, h->metatable, TM_NEWINDEX)) == NULL) { /* or no TM? */
++ setobj2t(L, oldval, val);
++ luaC_barriert(L, h, val);
++ return;
++ }
++ /* else will try the tag method */
++ }
++ else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_NEWINDEX)))
++ luaG_typeerror(L, t, "index");
++ if (ttisfunction(tm)) {
++ callTM(L, tm, t, key, val);
++ return;
++ }
++ t = tm; /* else repeat with `tm' */
++ }
++ luaG_runerror(L, "loop in settable");
++}
++
++
++static int call_binTM (lua_State *L, const TValue *p1, const TValue *p2,
++ StkId res, TMS event) {
++ const TValue *tm = luaT_gettmbyobj(L, p1, event); /* try first operand */
++ if (ttisnil(tm))
++ tm = luaT_gettmbyobj(L, p2, event); /* try second operand */
++ if (ttisnil(tm)) return 0;
++ callTMres(L, res, tm, p1, p2);
++ return 1;
++}
++
++
++static const TValue *get_compTM (lua_State *L, Table *mt1, Table *mt2,
++ TMS event) {
++ const TValue *tm1 = fasttm(L, mt1, event);
++ const TValue *tm2;
++ if (tm1 == NULL) return NULL; /* no metamethod */
++ if (mt1 == mt2) return tm1; /* same metatables => same metamethods */
++ tm2 = fasttm(L, mt2, event);
++ if (tm2 == NULL) return NULL; /* no metamethod */
++ if (luaO_rawequalObj(tm1, tm2)) /* same metamethods? */
++ return tm1;
++ return NULL;
++}
++
++
++static int call_orderTM (lua_State *L, const TValue *p1, const TValue *p2,
++ TMS event) {
++ const TValue *tm1 = luaT_gettmbyobj(L, p1, event);
++ const TValue *tm2;
++ if (ttisnil(tm1)) return -1; /* no metamethod? */
++ tm2 = luaT_gettmbyobj(L, p2, event);
++ if (!luaO_rawequalObj(tm1, tm2)) /* different metamethods? */
++ return -1;
++ callTMres(L, L->top, tm1, p1, p2);
++ return !l_isfalse(L->top);
++}
++
++
++static int l_strcmp (const TString *ls, const TString *rs) {
++ const char *l = getstr(ls);
++ size_t ll = ls->tsv.len;
++ const char *r = getstr(rs);
++ size_t lr = rs->tsv.len;
++ for (;;) {
++ int temp = strcoll(l, r);
++ if (temp != 0) return temp;
++ else { /* strings are equal up to a `\0' */
++ size_t len = strlen(l); /* index of first `\0' in both strings */
++ if (len == lr) /* r is finished? */
++ return (len == ll) ? 0 : 1;
++ else if (len == ll) /* l is finished? */
++ return -1; /* l is smaller than r (because r is not finished) */
++ /* both strings longer than `len'; go on comparing (after the `\0') */
++ len++;
++ l += len; ll -= len; r += len; lr -= len;
++ }
++ }
++}
++
++
++int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r) {
++ int res;
++ if (ttype(l) != ttype(r))
++ return luaG_ordererror(L, l, r);
++ else if (ttisnumber(l))
++ return luai_numlt(nvalue(l), nvalue(r));
++ else if (ttisstring(l))
++ return l_strcmp(rawtsvalue(l), rawtsvalue(r)) < 0;
++ else if ((res = call_orderTM(L, l, r, TM_LT)) != -1)
++ return res;
++ return luaG_ordererror(L, l, r);
++}
++
++
++static int lessequal (lua_State *L, const TValue *l, const TValue *r) {
++ int res;
++ if (ttype(l) != ttype(r))
++ return luaG_ordererror(L, l, r);
++ else if (ttisnumber(l))
++ return luai_numle(nvalue(l), nvalue(r));
++ else if (ttisstring(l))
++ return l_strcmp(rawtsvalue(l), rawtsvalue(r)) <= 0;
++ else if ((res = call_orderTM(L, l, r, TM_LE)) != -1) /* first try `le' */
++ return res;
++ else if ((res = call_orderTM(L, r, l, TM_LT)) != -1) /* else try `lt' */
++ return !res;
++ return luaG_ordererror(L, l, r);
++}
++
++
++int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2) {
++ const TValue *tm;
++ lua_assert(ttype(t1) == ttype(t2));
++ switch (ttype(t1)) {
++ case LUA_TNIL: return 1;
++ case LUA_TNUMBER: return luai_numeq(nvalue(t1), nvalue(t2));
++ case LUA_TBOOLEAN: return bvalue(t1) == bvalue(t2); /* true must be 1 !! */
++ case LUA_TLIGHTUSERDATA: return pvalue(t1) == pvalue(t2);
++ case LUA_TUSERDATA: {
++ if (uvalue(t1) == uvalue(t2)) return 1;
++ tm = get_compTM(L, uvalue(t1)->metatable, uvalue(t2)->metatable,
++ TM_EQ);
++ break; /* will try TM */
++ }
++ case LUA_TTABLE: {
++ if (hvalue(t1) == hvalue(t2)) return 1;
++ tm = get_compTM(L, hvalue(t1)->metatable, hvalue(t2)->metatable, TM_EQ);
++ break; /* will try TM */
++ }
++ default: return gcvalue(t1) == gcvalue(t2);
++ }
++ if (tm == NULL) return 0; /* no TM? */
++ callTMres(L, L->top, tm, t1, t2); /* call TM */
++ return !l_isfalse(L->top);
++}
++
++
++void luaV_concat (lua_State *L, int total, int last) {
++ do {
++ StkId top = L->base + last + 1;
++ int n = 2; /* number of elements handled in this pass (at least 2) */
++ if (!(ttisstring(top-2) || ttisnumber(top-2)) || !tostring(L, top-1)) {
++ if (!call_binTM(L, top-2, top-1, top-2, TM_CONCAT))
++ luaG_concaterror(L, top-2, top-1);
++ } else if (tsvalue(top-1)->len == 0) /* second op is empty? */
++ (void)tostring(L, top - 2); /* result is first op (as string) */
++ else {
++ /* at least two string values; get as many as possible */
++ size_t tl = tsvalue(top-1)->len;
++ char *buffer;
++ int i;
++ /* collect total length */
++ for (n = 1; n < total && tostring(L, top-n-1); n++) {
++ size_t l = tsvalue(top-n-1)->len;
++ if (l >= MAX_SIZET - tl) luaG_runerror(L, "string length overflow");
++ tl += l;
++ }
++ buffer = luaZ_openspace(L, &G(L)->buff, tl);
++ tl = 0;
++ for (i=n; i>0; i--) { /* concat all strings */
++ size_t l = tsvalue(top-i)->len;
++ memcpy(buffer+tl, svalue(top-i), l);
++ tl += l;
++ }
++ setsvalue2s(L, top-n, luaS_newlstr(L, buffer, tl));
++ }
++ total -= n-1; /* got `n' strings to create 1 new */
++ last -= n-1;
++ } while (total > 1); /* repeat until only 1 result left */
++}
++
++
++static void Arith (lua_State *L, StkId ra, const TValue *rb,
++ const TValue *rc, TMS op) {
++ TValue tempb, tempc;
++ const TValue *b, *c;
++ if ((b = luaV_tonumber(rb, &tempb)) != NULL &&
++ (c = luaV_tonumber(rc, &tempc)) != NULL) {
++ lua_Number nb = nvalue(b), nc = nvalue(c);
++ switch (op) {
++ case TM_ADD: setnvalue(ra, luai_numadd(nb, nc)); break;
++ case TM_SUB: setnvalue(ra, luai_numsub(nb, nc)); break;
++ case TM_MUL: setnvalue(ra, luai_nummul(nb, nc)); break;
++ case TM_DIV: setnvalue(ra, luai_numdiv(nb, nc)); break;
++ case TM_MOD: setnvalue(ra, luai_nummod(nb, nc)); break;
++ case TM_POW: setnvalue(ra, luai_numpow(nb, nc)); break;
++ case TM_UNM: setnvalue(ra, luai_numunm(nb)); break;
++ default: lua_assert(0); break;
++ }
++ }
++ else if (!call_binTM(L, rb, rc, ra, op))
++ luaG_aritherror(L, rb, rc);
++}
++
++
++
++/*
++** some macros for common tasks in `luaV_execute'
++*/
++
++#define runtime_check(L, c) { if (!(c)) break; }
++
++#define RA(i) (base+GETARG_A(i))
++/* to be used after possible stack reallocation */
++#define RB(i) check_exp(getBMode(GET_OPCODE(i)) == OpArgR, base+GETARG_B(i))
++#define RC(i) check_exp(getCMode(GET_OPCODE(i)) == OpArgR, base+GETARG_C(i))
++#define RKB(i) check_exp(getBMode(GET_OPCODE(i)) == OpArgK, \
++ ISK(GETARG_B(i)) ? k+INDEXK(GETARG_B(i)) : base+GETARG_B(i))
++#define RKC(i) check_exp(getCMode(GET_OPCODE(i)) == OpArgK, \
++ ISK(GETARG_C(i)) ? k+INDEXK(GETARG_C(i)) : base+GETARG_C(i))
++#define KBx(i) check_exp(getBMode(GET_OPCODE(i)) == OpArgK, k+GETARG_Bx(i))
++
++
++#define dojump(L,pc,i) {(pc) += (i); luai_threadyield(L);}
++
++
++#define Protect(x) { L->savedpc = pc; {x;}; base = L->base; }
++
++
++#define arith_op(op,tm) { \
++ TValue *rb = RKB(i); \
++ TValue *rc = RKC(i); \
++ if (ttisnumber(rb) && ttisnumber(rc)) { \
++ lua_Number nb = nvalue(rb), nc = nvalue(rc); \
++ setnvalue(ra, op(nb, nc)); \
++ } \
++ else \
++ Protect(Arith(L, ra, rb, rc, tm)); \
++ }
++
++
++
++void luaV_execute (lua_State *L, int nexeccalls) {
++ LClosure *cl;
++ StkId base;
++ TValue *k;
++ const Instruction *pc;
++ reentry: /* entry point */
++ lua_assert(isLua(L->ci));
++ pc = L->savedpc;
++ cl = &clvalue(L->ci->func)->l;
++ base = L->base;
++ k = cl->p->k;
++ /* main loop of interpreter */
++ for (;;) {
++ const Instruction i = *pc++;
++ StkId ra;
++ if ((L->hookmask & (LUA_MASKLINE | LUA_MASKCOUNT)) &&
++ (--L->hookcount == 0 || L->hookmask & LUA_MASKLINE)) {
++ traceexec(L, pc);
++ if (L->status == LUA_YIELD) { /* did hook yield? */
++ L->savedpc = pc - 1;
++ return;
++ }
++ base = L->base;
++ }
++ /* warning!! several calls may realloc the stack and invalidate `ra' */
++ ra = RA(i);
++ lua_assert(base == L->base && L->base == L->ci->base);
++ lua_assert(base <= L->top && L->top <= L->stack + L->stacksize);
++ lua_assert(L->top == L->ci->top || luaG_checkopenop(i));
++ switch (GET_OPCODE(i)) {
++ case OP_MOVE: {
++ setobjs2s(L, ra, RB(i));
++ continue;
++ }
++ case OP_LOADK: {
++ setobj2s(L, ra, KBx(i));
++ continue;
++ }
++ case OP_LOADBOOL: {
++ setbvalue(ra, GETARG_B(i));
++ if (GETARG_C(i)) pc++; /* skip next instruction (if C) */
++ continue;
++ }
++ case OP_LOADNIL: {
++ TValue *rb = RB(i);
++ do {
++ setnilvalue(rb--);
++ } while (rb >= ra);
++ continue;
++ }
++ case OP_GETUPVAL: {
++ int b = GETARG_B(i);
++ setobj2s(L, ra, cl->upvals[b]->v);
++ continue;
++ }
++ case OP_GETGLOBAL: {
++ TValue g;
++ TValue *rb = KBx(i);
++ sethvalue(L, &g, cl->env);
++ lua_assert(ttisstring(rb));
++ Protect(luaV_gettable(L, &g, rb, ra));
++ continue;
++ }
++ case OP_GETTABLE: {
++ Protect(luaV_gettable(L, RB(i), RKC(i), ra));
++ continue;
++ }
++ case OP_SETGLOBAL: {
++ TValue g;
++ sethvalue(L, &g, cl->env);
++ lua_assert(ttisstring(KBx(i)));
++ Protect(luaV_settable(L, &g, KBx(i), ra));
++ continue;
++ }
++ case OP_SETUPVAL: {
++ UpVal *uv = cl->upvals[GETARG_B(i)];
++ setobj(L, uv->v, ra);
++ luaC_barrier(L, uv, ra);
++ continue;
++ }
++ case OP_SETTABLE: {
++ Protect(luaV_settable(L, ra, RKB(i), RKC(i)));
++ continue;
++ }
++ case OP_NEWTABLE: {
++ int b = GETARG_B(i);
++ int c = GETARG_C(i);
++ sethvalue(L, ra, luaH_new(L, luaO_fb2int(b), luaO_fb2int(c)));
++ Protect(luaC_checkGC(L));
++ continue;
++ }
++ case OP_SELF: {
++ StkId rb = RB(i);
++ setobjs2s(L, ra+1, rb);
++ Protect(luaV_gettable(L, rb, RKC(i), ra));
++ continue;
++ }
++ case OP_ADD: {
++ arith_op(luai_numadd, TM_ADD);
++ continue;
++ }
++ case OP_SUB: {
++ arith_op(luai_numsub, TM_SUB);
++ continue;
++ }
++ case OP_MUL: {
++ arith_op(luai_nummul, TM_MUL);
++ continue;
++ }
++ case OP_DIV: {
++ arith_op(luai_numdiv, TM_DIV);
++ continue;
++ }
++ case OP_MOD: {
++ arith_op(luai_nummod, TM_MOD);
++ continue;
++ }
++ case OP_POW: {
++ arith_op(luai_numpow, TM_POW);
++ continue;
++ }
++ case OP_UNM: {
++ TValue *rb = RB(i);
++ if (ttisnumber(rb)) {
++ lua_Number nb = nvalue(rb);
++ setnvalue(ra, luai_numunm(nb));
++ }
++ else {
++ Protect(Arith(L, ra, rb, rb, TM_UNM));
++ }
++ continue;
++ }
++ case OP_NOT: {
++ int res = l_isfalse(RB(i)); /* next assignment may change this value */
++ setbvalue(ra, res);
++ continue;
++ }
++ case OP_LEN: {
++ const TValue *rb = RB(i);
++ switch (ttype(rb)) {
++ case LUA_TTABLE: {
++ setnvalue(ra, cast_num(luaH_getn(hvalue(rb))));
++ break;
++ }
++ case LUA_TSTRING: {
++ setnvalue(ra, cast_num(tsvalue(rb)->len));
++ break;
++ }
++ default: { /* try metamethod */
++ Protect(
++ if (!call_binTM(L, rb, luaO_nilobject, ra, TM_LEN))
++ luaG_typeerror(L, rb, "get length of");
++ )
++ }
++ }
++ continue;
++ }
++ case OP_CONCAT: {
++ int b = GETARG_B(i);
++ int c = GETARG_C(i);
++ Protect(luaV_concat(L, c-b+1, c); luaC_checkGC(L));
++ setobjs2s(L, RA(i), base+b);
++ continue;
++ }
++ case OP_JMP: {
++ dojump(L, pc, GETARG_sBx(i));
++ continue;
++ }
++ case OP_EQ: {
++ TValue *rb = RKB(i);
++ TValue *rc = RKC(i);
++ Protect(
++ if (equalobj(L, rb, rc) == GETARG_A(i))
++ dojump(L, pc, GETARG_sBx(*pc));
++ )
++ pc++;
++ continue;
++ }
++ case OP_LT: {
++ Protect(
++ if (luaV_lessthan(L, RKB(i), RKC(i)) == GETARG_A(i))
++ dojump(L, pc, GETARG_sBx(*pc));
++ )
++ pc++;
++ continue;
++ }
++ case OP_LE: {
++ Protect(
++ if (lessequal(L, RKB(i), RKC(i)) == GETARG_A(i))
++ dojump(L, pc, GETARG_sBx(*pc));
++ )
++ pc++;
++ continue;
++ }
++ case OP_TEST: {
++ if (l_isfalse(ra) != GETARG_C(i))
++ dojump(L, pc, GETARG_sBx(*pc));
++ pc++;
++ continue;
++ }
++ case OP_TESTSET: {
++ TValue *rb = RB(i);
++ if (l_isfalse(rb) != GETARG_C(i)) {
++ setobjs2s(L, ra, rb);
++ dojump(L, pc, GETARG_sBx(*pc));
++ }
++ pc++;
++ continue;
++ }
++ case OP_CALL: {
++ int b = GETARG_B(i);
++ int nresults = GETARG_C(i) - 1;
++ if (b != 0) L->top = ra+b; /* else previous instruction set top */
++ L->savedpc = pc;
++ switch (luaD_precall(L, ra, nresults)) {
++ case PCRLUA: {
++ nexeccalls++;
++ goto reentry; /* restart luaV_execute over new Lua function */
++ }
++ case PCRC: {
++ /* it was a C function (`precall' called it); adjust results */
++ if (nresults >= 0) L->top = L->ci->top;
++ base = L->base;
++ continue;
++ }
++ default: {
++ return; /* yield */
++ }
++ }
++ }
++ case OP_TAILCALL: {
++ int b = GETARG_B(i);
++ if (b != 0) L->top = ra+b; /* else previous instruction set top */
++ L->savedpc = pc;
++ lua_assert(GETARG_C(i) - 1 == LUA_MULTRET);
++ switch (luaD_precall(L, ra, LUA_MULTRET)) {
++ case PCRLUA: {
++ /* tail call: put new frame in place of previous one */
++ CallInfo *ci = L->ci - 1; /* previous frame */
++ int aux;
++ StkId func = ci->func;
++ StkId pfunc = (ci+1)->func; /* previous function index */
++ if (L->openupval) luaF_close(L, ci->base);
++ L->base = ci->base = ci->func + ((ci+1)->base - pfunc);
++ for (aux = 0; pfunc+aux < L->top; aux++) /* move frame down */
++ setobjs2s(L, func+aux, pfunc+aux);
++ ci->top = L->top = func+aux; /* correct top */
++ lua_assert(L->top == L->base + clvalue(func)->l.p->maxstacksize);
++ ci->savedpc = L->savedpc;
++ ci->tailcalls++; /* one more call lost */
++ L->ci--; /* remove new frame */
++ goto reentry;
++ }
++ case PCRC: { /* it was a C function (`precall' called it) */
++ base = L->base;
++ continue;
++ }
++ default: {
++ return; /* yield */
++ }
++ }
++ }
++ case OP_RETURN: {
++ int b = GETARG_B(i);
++ if (b != 0) L->top = ra+b-1;
++ if (L->openupval) luaF_close(L, base);
++ L->savedpc = pc;
++ b = luaD_poscall(L, ra);
++ if (--nexeccalls == 0) /* was previous function running `here'? */
++ return; /* no: return */
++ else { /* yes: continue its execution */
++ if (b) L->top = L->ci->top;
++ lua_assert(isLua(L->ci));
++ lua_assert(GET_OPCODE(*((L->ci)->savedpc - 1)) == OP_CALL);
++ goto reentry;
++ }
++ }
++ case OP_FORLOOP: {
++ lua_Number step = nvalue(ra+2);
++ lua_Number idx = luai_numadd(nvalue(ra), step); /* increment index */
++ lua_Number limit = nvalue(ra+1);
++ if (luai_numlt(0, step) ? luai_numle(idx, limit)
++ : luai_numle(limit, idx)) {
++ dojump(L, pc, GETARG_sBx(i)); /* jump back */
++ setnvalue(ra, idx); /* update internal index... */
++ setnvalue(ra+3, idx); /* ...and external index */
++ }
++ continue;
++ }
++ case OP_FORPREP: {
++ const TValue *init = ra;
++ const TValue *plimit = ra+1;
++ const TValue *pstep = ra+2;
++ L->savedpc = pc; /* next steps may throw errors */
++ if (!tonumber(init, ra))
++ luaG_runerror(L, LUA_QL("for") " initial value must be a number");
++ else if (!tonumber(plimit, ra+1))
++ luaG_runerror(L, LUA_QL("for") " limit must be a number");
++ else if (!tonumber(pstep, ra+2))
++ luaG_runerror(L, LUA_QL("for") " step must be a number");
++ setnvalue(ra, luai_numsub(nvalue(ra), nvalue(pstep)));
++ dojump(L, pc, GETARG_sBx(i));
++ continue;
++ }
++ case OP_TFORLOOP: {
++ StkId cb = ra + 3; /* call base */
++ setobjs2s(L, cb+2, ra+2);
++ setobjs2s(L, cb+1, ra+1);
++ setobjs2s(L, cb, ra);
++ L->top = cb+3; /* func. + 2 args (state and index) */
++ Protect(luaD_call(L, cb, GETARG_C(i)));
++ L->top = L->ci->top;
++ cb = RA(i) + 3; /* previous call may change the stack */
++ if (!ttisnil(cb)) { /* continue loop? */
++ setobjs2s(L, cb-1, cb); /* save control variable */
++ dojump(L, pc, GETARG_sBx(*pc)); /* jump back */
++ }
++ pc++;
++ continue;
++ }
++ case OP_SETLIST: {
++ int n = GETARG_B(i);
++ int c = GETARG_C(i);
++ int last;
++ Table *h;
++ if (n == 0) {
++ n = cast_int(L->top - ra) - 1;
++ L->top = L->ci->top;
++ }
++ if (c == 0) c = cast_int(*pc++);
++ runtime_check(L, ttistable(ra));
++ h = hvalue(ra);
++ last = ((c-1)*LFIELDS_PER_FLUSH) + n;
++ if (last > h->sizearray) /* needs more space? */
++ luaH_resizearray(L, h, last); /* pre-alloc it at once */
++ for (; n > 0; n--) {
++ TValue *val = ra+n;
++ setobj2t(L, luaH_setnum(L, h, last--), val);
++ luaC_barriert(L, h, val);
++ }
++ continue;
++ }
++ case OP_CLOSE: {
++ luaF_close(L, ra);
++ continue;
++ }
++ case OP_CLOSURE: {
++ Proto *p;
++ Closure *ncl;
++ int nup, j;
++ p = cl->p->p[GETARG_Bx(i)];
++ nup = p->nups;
++ ncl = luaF_newLclosure(L, nup, cl->env);
++ ncl->l.p = p;
++ for (j=0; j<nup; j++, pc++) {
++ if (GET_OPCODE(*pc) == OP_GETUPVAL)
++ ncl->l.upvals[j] = cl->upvals[GETARG_B(*pc)];
++ else {
++ lua_assert(GET_OPCODE(*pc) == OP_MOVE);
++ ncl->l.upvals[j] = luaF_findupval(L, base + GETARG_B(*pc));
++ }
++ }
++ setclvalue(L, ra, ncl);
++ Protect(luaC_checkGC(L));
++ continue;
++ }
++ case OP_VARARG: {
++ int b = GETARG_B(i) - 1;
++ int j;
++ CallInfo *ci = L->ci;
++ int n = cast_int(ci->base - ci->func) - cl->p->numparams - 1;
++ if (b == LUA_MULTRET) {
++ Protect(luaD_checkstack(L, n));
++ ra = RA(i); /* previous call may change the stack */
++ b = n;
++ L->top = ra + n;
++ }
++ for (j = 0; j < b; j++) {
++ if (j < n) {
++ setobjs2s(L, ra + j, ci->base - n + j);
++ }
++ else {
++ setnilvalue(ra + j);
++ }
++ }
++ continue;
++ }
++ }
++ }
++}
++
+--- /dev/null
++++ b/extensions/LUA/lua/lvm.h
+@@ -0,0 +1,36 @@
++/*
++** $Id: lvm.h,v 2.5.1.1 2007/12/27 13:02:25 roberto Exp $
++** Lua virtual machine
++** See Copyright Notice in lua.h
++*/
++
++#ifndef lvm_h
++#define lvm_h
++
++
++#include "ldo.h"
++#include "lobject.h"
++#include "ltm.h"
++
++
++#define tostring(L,o) ((ttype(o) == LUA_TSTRING) || (luaV_tostring(L, o)))
++
++#define tonumber(o,n) (ttype(o) == LUA_TNUMBER || \
++ (((o) = luaV_tonumber(o,n)) != NULL))
++
++#define equalobj(L,o1,o2) \
++ (ttype(o1) == ttype(o2) && luaV_equalval(L, o1, o2))
++
++
++LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r);
++LUAI_FUNC int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2);
++LUAI_FUNC const TValue *luaV_tonumber (const TValue *obj, TValue *n);
++LUAI_FUNC int luaV_tostring (lua_State *L, StkId obj);
++LUAI_FUNC void luaV_gettable (lua_State *L, const TValue *t, TValue *key,
++ StkId val);
++LUAI_FUNC void luaV_settable (lua_State *L, const TValue *t, TValue *key,
++ StkId val);
++LUAI_FUNC void luaV_execute (lua_State *L, int nexeccalls);
++LUAI_FUNC void luaV_concat (lua_State *L, int total, int last);
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/lua/lzio.c
+@@ -0,0 +1,81 @@
++/*
++** $Id: lzio.c,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $
++** a generic input stream interface
++** See Copyright Notice in lua.h
++*/
++
++#include <string.h>
++
++#define lzio_c
++#define LUA_CORE
++
++#include "lua.h"
++
++#include "llimits.h"
++#include "lmem.h"
++#include "lstate.h"
++#include "lzio.h"
++
++
++int luaZ_fill (ZIO *z) {
++ size_t size;
++ lua_State *L = z->L;
++ const char *buff;
++ lua_unlock(L);
++ buff = z->reader(L, z->data, &size);
++ lua_lock(L);
++ if (buff == NULL || size == 0) return EOZ;
++ z->n = size - 1;
++ z->p = buff;
++ return char2int(*(z->p++));
++}
++
++
++int luaZ_lookahead (ZIO *z) {
++ if (z->n == 0) {
++ if (luaZ_fill(z) == EOZ)
++ return EOZ;
++ else {
++ z->n++; /* luaZ_fill removed first byte; put back it */
++ z->p--;
++ }
++ }
++ return char2int(*z->p);
++}
++
++
++void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) {
++ z->L = L;
++ z->reader = reader;
++ z->data = data;
++ z->n = 0;
++ z->p = NULL;
++}
++
++
++/* --------------------------------------------------------------- read --- */
++size_t luaZ_read (ZIO *z, void *b, size_t n) {
++ while (n) {
++ size_t m;
++ if (luaZ_lookahead(z) == EOZ)
++ return n; /* return number of missing bytes */
++ m = (n <= z->n) ? n : z->n; /* min. between n and z->n */
++ memcpy(b, z->p, m);
++ z->n -= m;
++ z->p += m;
++ b = (char *)b + m;
++ n -= m;
++ }
++ return 0;
++}
++
++/* ------------------------------------------------------------------------ */
++char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n) {
++ if (n > buff->buffsize) {
++ if (n < LUA_MINBUFFER) n = LUA_MINBUFFER;
++ luaZ_resizebuffer(L, buff, n);
++ }
++ return buff->buffer;
++}
++
++
+--- /dev/null
++++ b/extensions/LUA/lua/lzio.h
+@@ -0,0 +1,67 @@
++/*
++** $Id: lzio.h,v 1.21.1.1 2007/12/27 13:02:25 roberto Exp $
++** Buffered streams
++** See Copyright Notice in lua.h
++*/
++
++
++#ifndef lzio_h
++#define lzio_h
++
++#include "lua.h"
++
++#include "lmem.h"
++
++
++#define EOZ (-1) /* end of stream */
++
++typedef struct Zio ZIO;
++
++#define char2int(c) cast(int, cast(unsigned char, (c)))
++
++#define zgetc(z) (((z)->n--)>0 ? char2int(*(z)->p++) : luaZ_fill(z))
++
++typedef struct Mbuffer {
++ char *buffer;
++ size_t n;
++ size_t buffsize;
++} Mbuffer;
++
++#define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0)
++
++#define luaZ_buffer(buff) ((buff)->buffer)
++#define luaZ_sizebuffer(buff) ((buff)->buffsize)
++#define luaZ_bufflen(buff) ((buff)->n)
++
++#define luaZ_resetbuffer(buff) ((buff)->n = 0)
++
++
++#define luaZ_resizebuffer(L, buff, size) \
++ (luaM_reallocvector(L, (buff)->buffer, (buff)->buffsize, size, char), \
++ (buff)->buffsize = size)
++
++#define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0)
++
++
++LUAI_FUNC char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n);
++LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader,
++ void *data);
++LUAI_FUNC size_t luaZ_read (ZIO* z, void* b, size_t n); /* read next n bytes */
++LUAI_FUNC int luaZ_lookahead (ZIO *z);
++
++
++
++/* --------- Private Part ------------------ */
++
++struct Zio {
++ size_t n; /* bytes still unread */
++ const char *p; /* current position in buffer */
++ lua_Reader reader;
++ void* data; /* additional data */
++ lua_State *L; /* Lua state (for reader) */
++};
++
++
++LUAI_FUNC int luaZ_fill (ZIO *z);
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/Makefile
+@@ -0,0 +1,389 @@
++# Makefile.in generated by automake 1.11.1 from Makefile.am.
++# extensions/LUA/Makefile. Generated from Makefile.in by configure.
++
++# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
++# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
++# Inc.
++# This Makefile.in is free software; the Free Software Foundation
++# gives unlimited permission to copy and/or distribute it,
++# with or without modifications, as long as this notice is preserved.
++
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
++# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
++# PARTICULAR PURPOSE.
++
++
++
++# -*- Makefile -*-
++# AUTOMAKE
++
++pkgdatadir = $(datadir)/xtables-addons
++pkgincludedir = $(includedir)/xtables-addons
++pkglibdir = $(libdir)/xtables-addons
++pkglibexecdir = $(libexecdir)/xtables-addons
++am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
++install_sh_DATA = $(install_sh) -c -m 644
++install_sh_PROGRAM = $(install_sh) -c
++install_sh_SCRIPT = $(install_sh) -c
++INSTALL_HEADER = $(INSTALL_DATA)
++transform = $(program_transform_name)
++NORMAL_INSTALL = :
++PRE_INSTALL = :
++POST_INSTALL = :
++NORMAL_UNINSTALL = :
++PRE_UNINSTALL = :
++POST_UNINSTALL = :
++build_triplet = i686-pc-linux-gnu
++host_triplet = i686-pc-linux-gnu
++DIST_COMMON = $(srcdir)/../../Makefile.extra $(srcdir)/Makefile.am \
++ $(srcdir)/Makefile.in
++subdir = extensions/LUA
++ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
++am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
++ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
++ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
++ $(top_srcdir)/configure.ac
++am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
++ $(ACLOCAL_M4)
++mkinstalldirs = $(install_sh) -d
++CONFIG_HEADER = $(top_builddir)/config.h
++CONFIG_CLEAN_FILES =
++CONFIG_CLEAN_VPATH_FILES =
++SOURCES =
++DIST_SOURCES =
++DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
++ACLOCAL = ${SHELL} /home/andre/Dropbox/xtables-addons/missing --run aclocal-1.11
++AMTAR = ${SHELL} /home/andre/Dropbox/xtables-addons/missing --run tar
++AR = ar
++AUTOCONF = ${SHELL} /home/andre/Dropbox/xtables-addons/missing --run autoconf
++AUTOHEADER = ${SHELL} /home/andre/Dropbox/xtables-addons/missing --run autoheader
++AUTOMAKE = ${SHELL} /home/andre/Dropbox/xtables-addons/missing --run automake-1.11
++AWK = mawk
++CC = gcc
++CCDEPMODE = depmode=gcc3
++CFLAGS = -g -O2
++CPP = gcc -E
++CPPFLAGS =
++CYGPATH_W = echo
++DEFS = -DHAVE_CONFIG_H
++DEPDIR = .deps
++DSYMUTIL =
++DUMPBIN =
++ECHO_C =
++ECHO_N = -n
++ECHO_T =
++EGREP = /bin/grep -E
++EXEEXT =
++FGREP = /bin/grep -F
++GREP = /bin/grep
++INSTALL = /usr/bin/install -c
++INSTALL_DATA = ${INSTALL} -m 644
++INSTALL_PROGRAM = ${INSTALL}
++INSTALL_SCRIPT = ${INSTALL}
++INSTALL_STRIP_PROGRAM = $(install_sh) -c -s
++LD = /usr/bin/ld
++LDFLAGS =
++LIBOBJS =
++LIBS =
++LIBTOOL = $(SHELL) $(top_builddir)/libtool
++LIPO =
++LN_S = ln -s
++LTLIBOBJS =
++MAKEINFO = ${SHELL} /home/andre/Dropbox/xtables-addons/missing --run makeinfo
++MKDIR_P = /bin/mkdir -p
++NM = /usr/bin/nm -B
++NMEDIT =
++OBJDUMP = objdump
++OBJEXT = o
++OTOOL =
++OTOOL64 =
++PACKAGE = xtables-addons
++PACKAGE_BUGREPORT =
++PACKAGE_NAME = xtables-addons
++PACKAGE_STRING = xtables-addons 1.21
++PACKAGE_TARNAME = xtables-addons
++PACKAGE_URL =
++PACKAGE_VERSION = 1.21
++PATH_SEPARATOR = :
++PKG_CONFIG = /usr/bin/pkg-config
++RANLIB = ranlib
++SED = /bin/sed
++SET_MAKE =
++SHELL = /bin/bash
++STRIP = strip
++VERSION = 1.21
++abs_builddir = /home/andre/Dropbox/xtables-addons/extensions/LUA
++abs_srcdir = /home/andre/Dropbox/xtables-addons/extensions/LUA
++abs_top_builddir = /home/andre/Dropbox/xtables-addons
++abs_top_srcdir = /home/andre/Dropbox/xtables-addons
++ac_ct_CC = gcc
++ac_ct_DUMPBIN =
++am__include = include
++am__leading_dot = .
++am__quote =
++am__tar = ${AMTAR} chof - "$$tardir"
++am__untar = ${AMTAR} xf -
++bindir = ${exec_prefix}/bin
++build = i686-pc-linux-gnu
++build_alias =
++build_cpu = i686
++build_os = linux-gnu
++build_vendor = pc
++builddir = .
++datadir = ${datarootdir}
++datarootdir = ${prefix}/share
++docdir = ${datarootdir}/doc/${PACKAGE_TARNAME}
++dvidir = ${docdir}
++exec_prefix = ${prefix}
++host = i686-pc-linux-gnu
++host_alias =
++host_cpu = i686
++host_os = linux-gnu
++host_vendor = pc
++htmldir = ${docdir}
++includedir = ${prefix}/include
++infodir = ${datarootdir}/info
++install_sh = ${SHELL} /home/andre/Dropbox/xtables-addons/install-sh
++kbuilddir = /lib/modules/2.6.33-020633-generic/build
++kinclude_CFLAGS = -I /lib/modules/2.6.33-020633-generic/build/include
++ksourcedir =
++libdir = ${exec_prefix}/lib
++libexecdir = ${exec_prefix}/libexec
++libxtables_CFLAGS =
++libxtables_LIBS = -L/lib -lxtables
++localedir = ${datarootdir}/locale
++localstatedir = ${prefix}/var
++lt_ECHO = echo
++mandir = ${datarootdir}/man
++mkdir_p = /bin/mkdir -p
++oldincludedir = /usr/include
++pdfdir = ${docdir}
++prefix = /usr/local
++program_transform_name = s,x,x,
++psdir = ${docdir}
++regular_CFLAGS = -D_LARGEFILE_SOURCE=1 -D_LARGE_FILES -D_FILE_OFFSET_BITS=64 -D_REENTRANT -Wall -Waggregate-return -Wmissing-declarations -Wmissing-prototypes -Wredundant-decls -Wshadow -Wstrict-prototypes -Winline -pipe -DXTABLES_LIBDIR=\"${xtlibdir}\"
++sbindir = ${exec_prefix}/sbin
++sharedstatedir = ${prefix}/com
++srcdir = .
++sysconfdir = ${prefix}/etc
++target_alias =
++top_build_prefix = ../../
++top_builddir = ../..
++top_srcdir = ../..
++xtlibdir = ${libexecdir}/xtables
++XA_SRCDIR = ${srcdir}
++XA_TOPSRCDIR = ${top_srcdir}
++XA_ABSTOPSRCDIR = ${abs_top_srcdir}
++_mcall = -f ${top_builddir}/Makefile.iptrules
++all: all-am
++
++.SUFFIXES:
++$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(srcdir)/../../Makefile.extra $(am__configure_deps)
++ @for dep in $?; do \
++ case '$(am__configure_deps)' in \
++ *$$dep*) \
++ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
++ && { if test -f $@; then exit 0; else break; fi; }; \
++ exit 1;; \
++ esac; \
++ done; \
++ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign extensions/LUA/Makefile'; \
++ $(am__cd) $(top_srcdir) && \
++ $(AUTOMAKE) --foreign extensions/LUA/Makefile
++.PRECIOUS: Makefile
++Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
++ @case '$?' in \
++ *config.status*) \
++ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
++ *) \
++ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
++ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
++ esac;
++
++$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
++ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
++
++$(top_srcdir)/configure: $(am__configure_deps)
++ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
++$(ACLOCAL_M4): $(am__aclocal_m4_deps)
++ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
++$(am__aclocal_m4_deps):
++
++mostlyclean-libtool:
++ -rm -f *.lo
++
++clean-libtool:
++ -rm -rf .libs _libs
++tags: TAGS
++TAGS:
++
++ctags: CTAGS
++CTAGS:
++
++
++distdir: $(DISTFILES)
++ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
++ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
++ list='$(DISTFILES)'; \
++ dist_files=`for file in $$list; do echo $$file; done | \
++ sed -e "s|^$$srcdirstrip/||;t" \
++ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
++ case $$dist_files in \
++ */*) $(MKDIR_P) `echo "$$dist_files" | \
++ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
++ sort -u` ;; \
++ esac; \
++ for file in $$dist_files; do \
++ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
++ if test -d $$d/$$file; then \
++ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
++ if test -d "$(distdir)/$$file"; then \
++ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
++ fi; \
++ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
++ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
++ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
++ fi; \
++ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
++ else \
++ test -f "$(distdir)/$$file" \
++ || cp -p $$d/$$file "$(distdir)/$$file" \
++ || exit 1; \
++ fi; \
++ done
++check-am: all-am
++check: check-am
++all-am: Makefile all-local
++installdirs:
++install: install-am
++install-exec: install-exec-am
++install-data: install-data-am
++uninstall: uninstall-am
++
++install-am: all-am
++ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
++
++installcheck: installcheck-am
++install-strip:
++ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
++ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
++ `test -z '$(STRIP)' || \
++ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
++mostlyclean-generic:
++
++clean-generic:
++
++distclean-generic:
++ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
++ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
++
++maintainer-clean-generic:
++ @echo "This command is intended for maintainers to use"
++ @echo "it deletes files that may require special tools to rebuild."
++clean: clean-am
++
++clean-am: clean-generic clean-libtool clean-local mostlyclean-am
++
++distclean: distclean-am
++ -rm -f Makefile
++distclean-am: clean-am distclean-generic
++
++dvi: dvi-am
++
++dvi-am:
++
++html: html-am
++
++html-am:
++
++info: info-am
++
++info-am:
++
++install-data-am:
++
++install-dvi: install-dvi-am
++
++install-dvi-am:
++
++install-exec-am: install-exec-local
++
++install-html: install-html-am
++
++install-html-am:
++
++install-info: install-info-am
++
++install-info-am:
++
++install-man:
++
++install-pdf: install-pdf-am
++
++install-pdf-am:
++
++install-ps: install-ps-am
++
++install-ps-am:
++
++installcheck-am:
++
++maintainer-clean: maintainer-clean-am
++ -rm -f Makefile
++maintainer-clean-am: distclean-am maintainer-clean-generic
++
++mostlyclean: mostlyclean-am
++
++mostlyclean-am: mostlyclean-generic mostlyclean-libtool
++
++pdf: pdf-am
++
++pdf-am:
++
++ps: ps-am
++
++ps-am:
++
++uninstall-am:
++
++.MAKE: install-am install-strip
++
++.PHONY: all all-am all-local check check-am clean clean-generic \
++ clean-libtool clean-local distclean distclean-generic \
++ distclean-libtool distdir dvi dvi-am html html-am info info-am \
++ install install-am install-data install-data-am install-dvi \
++ install-dvi-am install-exec install-exec-am install-exec-local \
++ install-html install-html-am install-info install-info-am \
++ install-man install-pdf install-pdf-am install-ps \
++ install-ps-am install-strip installcheck installcheck-am \
++ installdirs maintainer-clean maintainer-clean-generic \
++ mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \
++ ps ps-am uninstall uninstall-am
++
++export XA_SRCDIR
++export XA_TOPSRCDIR
++export XA_ABSTOPSRCDIR
++
++all-local: user-all-local
++
++install-exec-local: user-install-local
++
++clean-local: user-clean-local
++
++user-all-local:
++ ${MAKE} ${_mcall} all;
++
++# Have no user-install-data-local ATM
++user-install-local: user-install-exec-local
++
++user-install-exec-local:
++ ${MAKE} ${_mcall} install;
++
++user-clean-local:
++ ${MAKE} ${_mcall} clean;
++
++# Tell versions [3.59,3.63) of GNU make to not export all variables.
++# Otherwise a system limit (for SysV at least) may be exceeded.
++.NOEXPORT:
++
+--- /dev/null
++++ b/extensions/LUA/Makefile.am
+@@ -0,0 +1 @@
++include ../../Makefile.extra
+--- /dev/null
++++ b/extensions/LUA/Makefile.in
+@@ -0,0 +1,389 @@
++# Makefile.in generated by automake 1.11.1 from Makefile.am.
++# @configure_input@
++
++# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
++# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
++# Inc.
++# This Makefile.in is free software; the Free Software Foundation
++# gives unlimited permission to copy and/or distribute it,
++# with or without modifications, as long as this notice is preserved.
++
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
++# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
++# PARTICULAR PURPOSE.
++
++@SET_MAKE@
++
++# -*- Makefile -*-
++# AUTOMAKE
++VPATH = @srcdir@
++pkgdatadir = $(datadir)/@PACKAGE@
++pkgincludedir = $(includedir)/@PACKAGE@
++pkglibdir = $(libdir)/@PACKAGE@
++pkglibexecdir = $(libexecdir)/@PACKAGE@
++am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
++install_sh_DATA = $(install_sh) -c -m 644
++install_sh_PROGRAM = $(install_sh) -c
++install_sh_SCRIPT = $(install_sh) -c
++INSTALL_HEADER = $(INSTALL_DATA)
++transform = $(program_transform_name)
++NORMAL_INSTALL = :
++PRE_INSTALL = :
++POST_INSTALL = :
++NORMAL_UNINSTALL = :
++PRE_UNINSTALL = :
++POST_UNINSTALL = :
++build_triplet = @build@
++host_triplet = @host@
++DIST_COMMON = $(srcdir)/../../Makefile.extra $(srcdir)/Makefile.am \
++ $(srcdir)/Makefile.in
++subdir = extensions/LUA
++ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
++am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
++ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
++ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
++ $(top_srcdir)/configure.ac
++am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
++ $(ACLOCAL_M4)
++mkinstalldirs = $(install_sh) -d
++CONFIG_HEADER = $(top_builddir)/config.h
++CONFIG_CLEAN_FILES =
++CONFIG_CLEAN_VPATH_FILES =
++SOURCES =
++DIST_SOURCES =
++DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
++ACLOCAL = @ACLOCAL@
++AMTAR = @AMTAR@
++AR = @AR@
++AUTOCONF = @AUTOCONF@
++AUTOHEADER = @AUTOHEADER@
++AUTOMAKE = @AUTOMAKE@
++AWK = @AWK@
++CC = @CC@
++CCDEPMODE = @CCDEPMODE@
++CFLAGS = @CFLAGS@
++CPP = @CPP@
++CPPFLAGS = @CPPFLAGS@
++CYGPATH_W = @CYGPATH_W@
++DEFS = @DEFS@
++DEPDIR = @DEPDIR@
++DSYMUTIL = @DSYMUTIL@
++DUMPBIN = @DUMPBIN@
++ECHO_C = @ECHO_C@
++ECHO_N = @ECHO_N@
++ECHO_T = @ECHO_T@
++EGREP = @EGREP@
++EXEEXT = @EXEEXT@
++FGREP = @FGREP@
++GREP = @GREP@
++INSTALL = @INSTALL@
++INSTALL_DATA = @INSTALL_DATA@
++INSTALL_PROGRAM = @INSTALL_PROGRAM@
++INSTALL_SCRIPT = @INSTALL_SCRIPT@
++INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
++LD = @LD@
++LDFLAGS = @LDFLAGS@
++LIBOBJS = @LIBOBJS@
++LIBS = @LIBS@
++LIBTOOL = @LIBTOOL@
++LIPO = @LIPO@
++LN_S = @LN_S@
++LTLIBOBJS = @LTLIBOBJS@
++MAKEINFO = @MAKEINFO@
++MKDIR_P = @MKDIR_P@
++NM = @NM@
++NMEDIT = @NMEDIT@
++OBJDUMP = @OBJDUMP@
++OBJEXT = @OBJEXT@
++OTOOL = @OTOOL@
++OTOOL64 = @OTOOL64@
++PACKAGE = @PACKAGE@
++PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
++PACKAGE_NAME = @PACKAGE_NAME@
++PACKAGE_STRING = @PACKAGE_STRING@
++PACKAGE_TARNAME = @PACKAGE_TARNAME@
++PACKAGE_URL = @PACKAGE_URL@
++PACKAGE_VERSION = @PACKAGE_VERSION@
++PATH_SEPARATOR = @PATH_SEPARATOR@
++PKG_CONFIG = @PKG_CONFIG@
++RANLIB = @RANLIB@
++SED = @SED@
++SET_MAKE = @SET_MAKE@
++SHELL = @SHELL@
++STRIP = @STRIP@
++VERSION = @VERSION@
++abs_builddir = @abs_builddir@
++abs_srcdir = @abs_srcdir@
++abs_top_builddir = @abs_top_builddir@
++abs_top_srcdir = @abs_top_srcdir@
++ac_ct_CC = @ac_ct_CC@
++ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
++am__include = @am__include@
++am__leading_dot = @am__leading_dot@
++am__quote = @am__quote@
++am__tar = @am__tar@
++am__untar = @am__untar@
++bindir = @bindir@
++build = @build@
++build_alias = @build_alias@
++build_cpu = @build_cpu@
++build_os = @build_os@
++build_vendor = @build_vendor@
++builddir = @builddir@
++datadir = @datadir@
++datarootdir = @datarootdir@
++docdir = @docdir@
++dvidir = @dvidir@
++exec_prefix = @exec_prefix@
++host = @host@
++host_alias = @host_alias@
++host_cpu = @host_cpu@
++host_os = @host_os@
++host_vendor = @host_vendor@
++htmldir = @htmldir@
++includedir = @includedir@
++infodir = @infodir@
++install_sh = @install_sh@
++kbuilddir = @kbuilddir@
++kinclude_CFLAGS = @kinclude_CFLAGS@
++ksourcedir = @ksourcedir@
++libdir = @libdir@
++libexecdir = @libexecdir@
++libxtables_CFLAGS = @libxtables_CFLAGS@
++libxtables_LIBS = @libxtables_LIBS@
++localedir = @localedir@
++localstatedir = @localstatedir@
++lt_ECHO = @lt_ECHO@
++mandir = @mandir@
++mkdir_p = @mkdir_p@
++oldincludedir = @oldincludedir@
++pdfdir = @pdfdir@
++prefix = @prefix@
++program_transform_name = @program_transform_name@
++psdir = @psdir@
++regular_CFLAGS = @regular_CFLAGS@
++sbindir = @sbindir@
++sharedstatedir = @sharedstatedir@
++srcdir = @srcdir@
++sysconfdir = @sysconfdir@
++target_alias = @target_alias@
++top_build_prefix = @top_build_prefix@
++top_builddir = @top_builddir@
++top_srcdir = @top_srcdir@
++xtlibdir = @xtlibdir@
++XA_SRCDIR = ${srcdir}
++XA_TOPSRCDIR = ${top_srcdir}
++XA_ABSTOPSRCDIR = ${abs_top_srcdir}
++_mcall = -f ${top_builddir}/Makefile.iptrules
++all: all-am
++
++.SUFFIXES:
++$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(srcdir)/../../Makefile.extra $(am__configure_deps)
++ @for dep in $?; do \
++ case '$(am__configure_deps)' in \
++ *$$dep*) \
++ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
++ && { if test -f $@; then exit 0; else break; fi; }; \
++ exit 1;; \
++ esac; \
++ done; \
++ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign extensions/LUA/Makefile'; \
++ $(am__cd) $(top_srcdir) && \
++ $(AUTOMAKE) --foreign extensions/LUA/Makefile
++.PRECIOUS: Makefile
++Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
++ @case '$?' in \
++ *config.status*) \
++ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
++ *) \
++ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
++ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
++ esac;
++
++$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
++ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
++
++$(top_srcdir)/configure: $(am__configure_deps)
++ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
++$(ACLOCAL_M4): $(am__aclocal_m4_deps)
++ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
++$(am__aclocal_m4_deps):
++
++mostlyclean-libtool:
++ -rm -f *.lo
++
++clean-libtool:
++ -rm -rf .libs _libs
++tags: TAGS
++TAGS:
++
++ctags: CTAGS
++CTAGS:
++
++
++distdir: $(DISTFILES)
++ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
++ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
++ list='$(DISTFILES)'; \
++ dist_files=`for file in $$list; do echo $$file; done | \
++ sed -e "s|^$$srcdirstrip/||;t" \
++ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
++ case $$dist_files in \
++ */*) $(MKDIR_P) `echo "$$dist_files" | \
++ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
++ sort -u` ;; \
++ esac; \
++ for file in $$dist_files; do \
++ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
++ if test -d $$d/$$file; then \
++ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
++ if test -d "$(distdir)/$$file"; then \
++ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
++ fi; \
++ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
++ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
++ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
++ fi; \
++ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
++ else \
++ test -f "$(distdir)/$$file" \
++ || cp -p $$d/$$file "$(distdir)/$$file" \
++ || exit 1; \
++ fi; \
++ done
++check-am: all-am
++check: check-am
++all-am: Makefile all-local
++installdirs:
++install: install-am
++install-exec: install-exec-am
++install-data: install-data-am
++uninstall: uninstall-am
++
++install-am: all-am
++ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
++
++installcheck: installcheck-am
++install-strip:
++ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
++ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
++ `test -z '$(STRIP)' || \
++ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
++mostlyclean-generic:
++
++clean-generic:
++
++distclean-generic:
++ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
++ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
++
++maintainer-clean-generic:
++ @echo "This command is intended for maintainers to use"
++ @echo "it deletes files that may require special tools to rebuild."
++clean: clean-am
++
++clean-am: clean-generic clean-libtool clean-local mostlyclean-am
++
++distclean: distclean-am
++ -rm -f Makefile
++distclean-am: clean-am distclean-generic
++
++dvi: dvi-am
++
++dvi-am:
++
++html: html-am
++
++html-am:
++
++info: info-am
++
++info-am:
++
++install-data-am:
++
++install-dvi: install-dvi-am
++
++install-dvi-am:
++
++install-exec-am: install-exec-local
++
++install-html: install-html-am
++
++install-html-am:
++
++install-info: install-info-am
++
++install-info-am:
++
++install-man:
++
++install-pdf: install-pdf-am
++
++install-pdf-am:
++
++install-ps: install-ps-am
++
++install-ps-am:
++
++installcheck-am:
++
++maintainer-clean: maintainer-clean-am
++ -rm -f Makefile
++maintainer-clean-am: distclean-am maintainer-clean-generic
++
++mostlyclean: mostlyclean-am
++
++mostlyclean-am: mostlyclean-generic mostlyclean-libtool
++
++pdf: pdf-am
++
++pdf-am:
++
++ps: ps-am
++
++ps-am:
++
++uninstall-am:
++
++.MAKE: install-am install-strip
++
++.PHONY: all all-am all-local check check-am clean clean-generic \
++ clean-libtool clean-local distclean distclean-generic \
++ distclean-libtool distdir dvi dvi-am html html-am info info-am \
++ install install-am install-data install-data-am install-dvi \
++ install-dvi-am install-exec install-exec-am install-exec-local \
++ install-html install-html-am install-info install-info-am \
++ install-man install-pdf install-pdf-am install-ps \
++ install-ps-am install-strip installcheck installcheck-am \
++ installdirs maintainer-clean maintainer-clean-generic \
++ mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \
++ ps ps-am uninstall uninstall-am
++
++export XA_SRCDIR
++export XA_TOPSRCDIR
++export XA_ABSTOPSRCDIR
++
++all-local: user-all-local
++
++install-exec-local: user-install-local
++
++clean-local: user-clean-local
++
++user-all-local:
++ ${MAKE} ${_mcall} all;
++
++# Have no user-install-data-local ATM
++user-install-local: user-install-exec-local
++
++user-install-exec-local:
++ ${MAKE} ${_mcall} install;
++
++user-clean-local:
++ ${MAKE} ${_mcall} clean;
++
++# Tell versions [3.59,3.63) of GNU make to not export all variables.
++# Otherwise a system limit (for SysV at least) may be exceeded.
++.NOEXPORT:
++
+--- /dev/null
++++ b/extensions/LUA/Mbuild
+@@ -0,0 +1,3 @@
++# -*- Makefile -*-
++
++obj-${build_LUA} += libxt_LUA.so
+--- /dev/null
++++ b/extensions/LUA/nf_lua.c
+@@ -0,0 +1,64 @@
++#if defined(__KERNEL__)
++
++#include <linux/kernel.h>
++#include <linux/slab.h>
++#include <linux/string.h>
++#include <linux/timer.h>
++#include <linux/random.h>
++#include <linux/netfilter/x_tables.h>
++
++#endif
++
++#include "lua.h"
++#include "lobject.h" /*sizeof(udata) */
++#include "lauxlib.h"
++#include "controller.h"
++
++#if defined(__KERNEL__) /* reachs until luaopen_nflib */
++
++
++static int32_t nf_get_random(lua_State *L)
++{
++ uint32_t rand = 0;
++
++ get_random_bytes(&rand, sizeof(uint32_t ));
++ lua_pushnumber(L, rand);
++ return 1;
++}
++
++static int32_t nf_get_time(lua_State *L)
++{
++ lua_pushnumber(L, jiffies_to_msecs(jiffies_64));
++ return 1;
++}
++
++static const struct luaL_Reg nf_lua_lib_f [] = {
++ { "get_random", nf_get_random },
++ { "get_time", nf_get_time },
++ { NULL, NULL }
++};
++
++void luaopen_nflib(lua_State *L)
++{
++ int32_t top;
++
++ luaL_register(L, NETFILTER_LIB, nf_lua_lib_f);
++ lua_pop(L, 1);
++
++ /* registering verdicts inside the _G */
++ lua_getglobal(L, "_G");
++ top = lua_gettop(L);
++
++ lua_pushinteger(L, XT_CONTINUE);
++ lua_setfield(L, top, "XT_CONTINUE"); /* continiue with next rule */
++
++ lua_pushinteger(L, NF_DROP);
++ lua_setfield(L, top, "NF_DROP"); /* stop traversal in the current table hook and drop packet */
++
++ lua_pushinteger(L, NF_ACCEPT);
++ lua_setfield(L, top, "NF_ACCEPT"); /* stop traversal in the current table hook and accept packet */
++
++ lua_pop(L, 1); /* pop _G */
++}
++
++#endif
+--- /dev/null
++++ b/extensions/LUA/prot_buf_dynamic.c
+@@ -0,0 +1,486 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre@dergraf.org>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++
++#include "controller.h"
++
++
++
++struct protocol_buf * dyn_prot_buf_array[MAX_NR_OF_DYN_PROT_BUFS] = { NULL };
++
++
++/* LUA_API: the function 'field_dynamic_setter' acts as a wrapper around
++ * a given Lua field setter function of a dynamic protocol buffer. The
++ * string containing the lua function name was piggybacked in the 'set'
++ * member of the protocol_field. We call this function passing the actual
++ * segment as byte array and the set value.
++ *
++ * Paramters:
++ * 1. lua_packet_segment (implicit)
++ * 2. some lua value
++ *
++ * Upvalues:
++ * 1. pointer to the protocol buffer
++ * 2. field index
++ *
++ * Returns:
++ * 1. true or false if the 'set' was successful
++ */
++int32_t field_dynamic_setter(lua_State *L)
++{
++ size_t nbytes;
++ lua_packet_segment * array;
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ int32_t field_index = lua_tointeger(L, lua_upvalueindex(2));
++
++ /* the function name is piggybacked as a string */
++ lua_getglobal(L, (char *)prot_buf->protocol_fields[field_index].set);
++ if (!lua_isfunction(L, -1)) {
++ lua_pushboolean(L, 0);
++ return 1;
++ }
++
++ nbytes = sizeof(lua_packet_segment) + seg->length * sizeof(uint8_t);
++ array = (lua_packet_segment *)lua_newuserdata(L, nbytes);
++ array->length = seg->length;
++ array->start = seg->start + seg->offset;
++ array->changes = NULL;
++
++ luaL_getmetatable(L, LUA_BYTE_ARRAY);
++ lua_setmetatable(L, -2);
++ lua_pushvalue(L, 2); /* push value to set */
++ if (lua_pcall(L, 2, 1, 0) != 0) {
++ pr_debug("Error: %s \n", lua_tostring(L, -1));
++ lua_pop(L, 1);
++ lua_pushboolean(L, 0);
++ }
++ return 1;
++}
++
++/* LUA_API: the function 'field_dynamic_getter' acts as a wrapper around
++ * a given Lua field getter function of a dynamic protocol buffer. The
++ * string containing the lua function name was piggybacked in the 'get'
++ * member of the protocol_field. We call this function passing the actual
++ * segment as byte array.
++ *
++ * Paramters:
++ * 1. lua_packet_segment (implicit)
++ *
++ * Upvalues:
++ * 1. pointer to the protocol buffer
++ * 2. field index
++ *
++ * Returns:
++ * 1. true or false if the 'get' was successful
++ */
++int32_t field_dynamic_getter(lua_State *L)
++{
++ size_t nbytes;
++ lua_packet_segment * array;
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ int32_t field_index = lua_tointeger(L, lua_upvalueindex(2));
++
++ /* the function name is piggybacked as a string */
++ lua_getglobal(L, (char *)prot_buf->protocol_fields[field_index].get);
++ if (!lua_isfunction(L, -1)) {
++ lua_pushboolean(L, 0);
++ return 1;
++ }
++
++ nbytes = sizeof(lua_packet_segment) + seg->length * sizeof(uint8_t);
++ array = (lua_packet_segment *)lua_newuserdata(L, nbytes);
++ array->length = seg->length;
++ array->start = seg->start + seg->offset;
++ array->changes = NULL;
++
++ luaL_getmetatable(L, LUA_BYTE_ARRAY);
++ lua_setmetatable(L, -2);
++ if (lua_pcall(L, 1, 1, 0) != 0) {
++ pr_debug("Error: %s \n", luaL_checkstring(L, -1));
++ lua_pop(L, 1);
++ lua_pushboolean(L, 0);
++ }
++ return 1;
++}
++
++/* LUA_API: the function 'has_protocol_dynamic' acts as a wrapper around
++ * a given lua has_protocol function of a dynamic protocol buffer. The
++ * string containing the lua function name was piggybacked in the 'has_protocol'
++ * member of the protocol_buffer. We call this function passing the actual
++ * segment.
++ *
++ * Paramters:
++ * 1. lua_packet_segment
++ * 2. protocol type
++ *
++ * Returns:
++ * 1. true or false if the payload field contains the given protocol
++ */
++int32_t has_protocol_dynamic(lua_State *L, struct protocol_buf * prot_buf, lua_packet_segment * seg, int32_t type)
++{
++ lua_packet_segment *seg_new;
++ int32_t res = 0;
++
++ /* the function name is piggybacked as a string */
++ lua_getglobal(L, (char *)prot_buf->has_protocol);
++ seg_new = (lua_packet_segment *)lua_newuserdata(L, sizeof(lua_packet_segment));
++ seg_new->start = seg->start;
++ seg_new->offset = seg->offset;
++ seg_new->length = seg->length;
++ seg_new->changes = NULL;
++ luaL_getmetatable(L, prot_buf->name);
++ lua_setmetatable(L, -2);
++ lua_pushinteger(L, type); /* push the protocol type */
++ if (lua_pcall(L, 2, 1, 0) != 0) {
++ pr_debug("Error: %s \n", luaL_checkstring(L, -1));
++ lua_pop(L, 1);
++ return 0;
++ }
++ res = lua_toboolean(L, -1);
++ lua_pop(L, 1);
++
++ return res;
++}
++
++/* LUA_API: the function 'get_field_changes_dynamic' acts as a wrapper around
++ * a given lua get_field_changes function of a dynamic protocol buffer. The
++ * string containing the lua function name was piggybacked in the 'get_field_changes'
++ * member of the protocol_buffer. We call this function passing the actual
++ * segment. The lua function must return two lua table containing the offset
++ * and length changes (in bits).
++ *
++ * Paramters:
++ * 1. lua_packet_segment
++ *
++ * Returns:
++ * 1. new allocated field_changes struct
++ */
++struct field_changes * get_field_changes_dynamic(lua_State *L, struct protocol_buf *prot_buf, lua_packet_segment * seg)
++{
++ lua_packet_segment *seg_new;
++ struct field_changes * changes;
++ int32_t nr_of_changes, i;
++
++ lua_getglobal(L, (char *)prot_buf->get_field_changes);
++
++ seg_new = (lua_packet_segment *)lua_newuserdata(L, sizeof(lua_packet_segment));
++ seg_new->start = seg->start;
++ seg_new->offset = seg->offset;
++ seg_new->length = seg->length;
++ seg_new->changes = NULL;
++ luaL_getmetatable(L, prot_buf->name);
++ lua_setmetatable(L, -2);
++
++ if (lua_pcall(L, 1, 2, 0) != 0)
++ luaL_error(L, "inside get_field_changes_dynamic. %s\n", lua_tostring(L, -1));
++
++ /* the function call must return a table containing length changes */
++ luaL_checktype(L, -1, LUA_TTABLE);
++ /* the function call must return a table containing offset changes */
++ luaL_checktype(L, -2, LUA_TTABLE);
++ /* both tables have to be of same size */
++ if (lua_objlen(L, -1) != lua_objlen(L, -2))
++ luaL_error(L, "the provided tables are not of equal size");
++
++ nr_of_changes = lua_objlen(L, -1);
++ changes = get_allocated_field_changes(L, nr_of_changes);
++
++ /* loop over the tables */
++ for (i = 1; i < nr_of_changes; i++) {
++ lua_rawgeti(L, -1, i); /* push length value of field at index i */
++ changes->field_length_changes[i - 1] = luaL_checkinteger(L, -1);
++ lua_pop(L, 1); /* pop offset value */
++
++ lua_rawgeti(L, -2, i); /* push offset value of field at index i */
++ changes->field_offset_changes[i - 1] = luaL_checkinteger(L, -1);
++ lua_pop(L, 1); /* pop length value */
++ }
++
++ /* pop both tables */
++ lua_pop(L, 2);
++
++ return changes;
++}
++
++/* C_INT: 'get_free_protocol_index' is only used internally. This function
++ * gets a free slot inside the array holding all the protocol buffers.
++ * There are several ways to get to this information. In this case I take
++ * the way over the reflected array SUPPORTED_PROTOCOL_TABLE inside the
++ * Lua state. Since this function is called at laodtime, we do not have
++ * to care about performance.
++ */
++static int32_t get_free_protocol_index(lua_State *L)
++{
++ int32_t protocol_index;
++
++ lua_getglobal(L, SUPPORTED_PROTOCOL_TABLE);
++ protocol_index = lua_objlen(L, -1) + 1;
++ lua_pop(L, 1);
++ return protocol_index;
++}
++
++/* C_API: 'free_dynamic_prot_buf' frees the allocated memory of a given
++ * dynamic protocol buffer. this function is normally called inside a
++ * cleanup routine. Be aware, before running this function you must be
++ * sure that no references to the dynamic protocol buffers were available.
++ * It's recomended to close the Lua state before calling the function. */
++void free_dynamic_prot_buf(struct protocol_buf * prot_buf)
++{
++ struct protocol_field * field = prot_buf->protocol_fields;
++
++ for (; field->name != NULL; field++) {
++ if (field->get) kfree(field->get);
++ if (field->set) kfree(field->set);
++ if (field->name) kfree((char *)field->name);
++ }
++
++ if (prot_buf->payload_field) kfree(prot_buf->payload_field);
++ if (prot_buf->has_protocol) kfree(prot_buf->has_protocol);
++
++ if (prot_buf->get_field_changes) kfree(prot_buf->get_field_changes);
++ kfree((char *)prot_buf->name);
++ kfree(prot_buf);
++ return;
++}
++
++void cleanup_dynamic_prot_bufs(void)
++{
++ int32_t i;
++
++ for (i = 0; i < MAX_NR_OF_DYN_PROT_BUFS; i++) {
++ if (dyn_prot_buf_array[i]) {
++ free_dynamic_prot_buf(dyn_prot_buf_array[i]);
++ dyn_prot_buf_array[i] = NULL;
++ }
++ }
++ return;
++}
++
++
++/* C_INT: 'free_protocol_fields' is used internally as a helper function for
++ * 'register_dynamic_protbuf'. It is used when durin registration an error
++ * occurs and the afore allocated fields needed to be freed. */
++static inline void free_protocol_fields(struct protocol_field * prot_fields, int32_t i)
++{
++ struct protocol_field * f;
++
++ while (i >= 0) {
++ f = &prot_fields[i];
++ if (f->name) kfree((void *)f->name);
++ if (f->get) kfree((void *)f->get);
++ if (f->set) kfree((void *)f->set);
++ kfree((void *)f);
++ i--;
++ }
++}
++
++/* LUA_API: 'register_dynamic_protbuf' is called from within the Lua script.
++ * it takes a Lua table representing the dynamic protocol buffer as parameter.
++ * e.g.:
++ * eth_prot_buf = {
++ * name = "packet_eth_dyn",
++ * payload_field = "data",
++ * protocol_fields = {
++ * {"dmac", 0, 48, nil, nil },
++ * {"smac", 48, 48, nil, nil },
++ * {"type", 96, 16, nil, nil },
++ * {"data", 112, 0, nil, nil },
++ * },
++ * has_protocol = "eth_dyn_has_protocol",
++ * get_field_changes = "eth_dyn_get_field_changes"
++ * }
++ * register_dynamic_protbuf(eth_prot_buf)
++ *
++ * the table gets parsed and a new protocol_buf struct is allocated and
++ * initialized using 'register_protbuf', which is also used for the static
++ * protocol buffers. This enables an identical behavior like the static
++ * protocol buffers. The dynamic protocol buffers are not garbage collected,
++ * use 'free_dynamic_protbuf' to free them after closing the Lua state.
++ */
++static int32_t register_dynamic_protbuf(lua_State *L)
++{
++ struct protocol_buf *prot_buf;
++ struct protocol_field *field, sentinel = PROT_FIELD_SENTINEL;
++ int32_t nr_of_fields, i;
++
++ prot_buf = (struct protocol_buf *)kmalloc(sizeof(struct protocol_buf), GFP_KERNEL);
++ prot_buf->is_dynamic = 1;
++
++ /* check if parameter is a table */
++ luaL_checktype(L, 1, LUA_TTABLE);
++
++ /* initialize prot_buf.name */
++ lua_getfield(L, 1, "name");
++ prot_buf->name = kmalloc(lua_objlen(L, -1), GFP_KERNEL);
++ strcpy((char *)prot_buf->name, luaL_checkstring(L, -1));
++ lua_pop(L, 1); /* pop res from lua_getfield */
++
++ /* check if protocol buffer is already registered */
++ lua_getglobal(L, prot_buf->name);
++ if (!lua_isnil(L, -1)) {
++ lua_pop(L, 1); /* pop res from lua_getglobal */
++ pr_debug("protocol_buf '%s' already registered.\n", prot_buf->name);
++ goto free_prot_buf;
++ }
++ lua_pop(L, 1); /* pop res from lua_getglobal */
++
++ /* initialize payload field */
++ lua_getfield(L, 1, "payload_field");
++ if (lua_isstring(L, -1)) {
++ prot_buf->payload_field = kmalloc(lua_objlen(L, -1), GFP_KERNEL);
++ strcpy(prot_buf->payload_field, lua_tostring(L, -1));
++ }else
++ prot_buf->payload_field = NULL;
++ lua_pop(L, 1); /* pop res from lua_getfield */
++
++ /* initialize protocol_fields field*/
++ lua_getfield(L, 1, "protocol_fields");
++ if (!lua_istable(L, -1)) {
++ pr_debug("invalid protocol_fields table.\n");
++ goto err2;
++
++ }
++
++ nr_of_fields = lua_objlen(L, -1);
++ prot_buf->protocol_fields = (struct protocol_field *)kmalloc((nr_of_fields + 1) * sizeof(struct protocol_field), GFP_KERNEL);
++
++ for (i = 1; i <= nr_of_fields; i++) {
++ field = &prot_buf->protocol_fields[i - 1];
++ /* initialize protocol field */
++ lua_rawgeti(L, -1, i); /* push field-table */
++ if (!lua_istable(L, -1)) {
++ free_protocol_fields(prot_buf->protocol_fields, i);
++ pr_debug("invalid protocol_field at %i.\n", i);
++ goto err;
++ }
++
++ /* initialize protocol field name */
++ lua_rawgeti(L, -1, 1);
++ if (!lua_isstring(L, -1)) {
++ free_protocol_fields(prot_buf->protocol_fields, i);
++ pr_debug("invalid protocol_field name at %i.\n", i);
++ goto err;
++ }
++
++ field->name = kmalloc(lua_objlen(L, -1), GFP_KERNEL);
++ strcpy((char*)field->name, lua_tostring(L, -1));
++ lua_pop(L, 1); /* pop field name */
++
++ /* initialize protocol field offset */
++ lua_rawgeti(L, -1, 2);
++ if (!lua_isnumber(L, -1)) {
++ free_protocol_fields(prot_buf->protocol_fields, i);
++ pr_debug("invalid protocol_field offset at %i.\n", i);
++ goto err;
++ }
++ field->offset = lua_tointeger(L, -1);
++ lua_pop(L, 1); /* pop field offset */
++
++ /* initialize protocol field length */
++ lua_rawgeti(L, -1, 3);
++ if (!lua_isnumber(L, -1)) {
++ free_protocol_fields(prot_buf->protocol_fields, i);
++ pr_debug("invalid protocol_field length at %i.\n", i);
++ goto err;
++ }
++ field->length = lua_tointeger(L, -1);
++ lua_pop(L, 1); /* pop field length */
++
++ /* initialize protocol field getter */
++ lua_rawgeti(L, -1, 4);
++ if (lua_isstring(L, -1)) {
++ field->get = kmalloc(lua_objlen(L, -1), GFP_KERNEL);
++ strcpy((char *)field->get, lua_tostring(L, -1)); /* the get-wrapper knows about the piggybacked string */
++ }else
++ field->get = NULL;
++ lua_pop(L, 1); /* pop field getter */
++
++ /* initialize protocol field setter */
++ lua_rawgeti(L, -1, 5);
++ if (lua_isstring(L, -1)) {
++ field->set = kmalloc(lua_objlen(L, -1), GFP_KERNEL);
++ strcpy((char *)field->set, lua_tostring(L, -1)); /* the set-wrapper knows about the piggybacked string */
++ }else
++ field->set = NULL;
++ lua_pop(L, 1); /* pop field setter */
++
++ /* field initialization completed */
++ lua_pop(L, 1); /* pop field-table */
++ }
++
++ /* put sentinel at the end of protocol_fields */
++ memcpy(&prot_buf->protocol_fields[nr_of_fields], &sentinel, sizeof(sentinel));
++ lua_pop(L, 1); /* pop protocol-fields-table */
++
++ /* initialize has_protocol field */
++ lua_getfield(L, 1, "has_protocol");
++ if (lua_isstring(L, -1)) {
++ prot_buf->has_protocol = kmalloc(lua_objlen(L, -1), GFP_KERNEL);
++ strcpy((char *)prot_buf->has_protocol, lua_tostring(L, -1)); /* the has_protocol-wrapper knows about the piggybacked string */
++ }else
++ prot_buf->has_protocol = NULL;
++ lua_pop(L, 1); /* pop has_protocol */
++
++ /* initialize get_field_changes field */
++ lua_getfield(L, 1, "get_field_changes");
++ if (lua_isstring(L, -1)) {
++ prot_buf->get_field_changes = kmalloc(lua_objlen(L, -1), GFP_KERNEL);
++ strcpy((char *)prot_buf->get_field_changes, lua_tostring(L, -1)); /* the get_field_changes-wrapper knows about the piggybacked string */
++ }else
++ prot_buf->get_field_changes = NULL;
++ lua_pop(L, 1); /* pop get_field_changes */
++
++ /* Storing the pointer to the DYNAMIC protbuf within dyn_prot_buf_array, in order to free it at cleanup */
++ for (i = 0; i < MAX_NR_OF_DYN_PROT_BUFS; i++) {
++ if (!dyn_prot_buf_array[i]) {
++ dyn_prot_buf_array[i] = prot_buf;
++ break;
++ }else
++ goto err;
++ }
++
++ /* call the "common" register_protbuf */
++ register_protbuf(L, prot_buf, get_free_protocol_index(L)); /* register prot_buf as it is done with the static ones */
++
++ return 0;
++
++err:
++ kfree(prot_buf->protocol_fields);
++err2:
++ if (prot_buf->payload_field) kfree(prot_buf->payload_field);
++free_prot_buf:
++ kfree((void *)prot_buf->name);
++ kfree(prot_buf);
++
++ luaL_error(L, "one or more error happend while registering a dynamic protocol buffer, please consult the debug log");
++
++ return 0;
++
++}
++
++void luaopen_protbuf_dynamic(lua_State *L)
++{
++ lua_getglobal(L, "_G");
++ lua_pushcclosure(L, register_dynamic_protbuf, 0);
++ lua_setfield(L, -2, "register_dynamic_protbuf");
++ lua_pop(L, 1); /* pop _G */
++ return;
++}
+--- /dev/null
++++ b/extensions/LUA/prot_buf_ethernet.c
+@@ -0,0 +1,60 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre@dergraf.org>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++
++#include "controller.h"
++
++
++static int32_t eth_has_protocol(lua_State *L, struct protocol_buf * prot_buf, lua_packet_segment * seg, int32_t protocol_type)
++{
++ uint8_t *embedded_protocol = seg->start + seg->offset + 12 /*bytes*/;
++ unsigned short res = (unsigned short)((embedded_protocol[1] << CHAR_BIT) | (embedded_protocol[0] << CHAR_BIT));
++
++ switch (res) {
++ case 0x0800: /* 1: Internet Protocol (IP) */
++ if (protocol_type == PACKET_IP) return 1;
++ break;
++ default:
++ return 0;
++ }
++
++ return 0;
++}
++
++static const struct protocol_field eth_protocol_fields[] = {
++ /* field name offset length getter setter */
++ { "dmac", 0, 48, NULL, NULL },
++ { "smac", 48, 48, NULL, NULL },
++ { "type", 96, 16, NULL, NULL },
++ { "data", 112, 0, NULL, NULL },
++ PROT_FIELD_SENTINEL,
++};
++
++static const struct protocol_buf eth_protocol_buf = {
++ .is_dynamic = 0,
++ .name = LUA_PACKET_SEG_ETH,
++ .payload_field = "data",
++ .protocol_fields = (struct protocol_field *)&eth_protocol_fields,
++ .has_protocol = &eth_has_protocol,
++ .get_field_changes = NULL,
++};
++
++
++void luaopen_protbuf_eth(lua_State *L)
++{
++ register_protbuf(L, (struct protocol_buf *)&eth_protocol_buf, PACKET_ETH);
++}
+--- /dev/null
++++ b/extensions/LUA/prot_buf_helpers.c
+@@ -0,0 +1,216 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre@dergraf.org>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++
++#if defined(__KERNEL__)
++#include <linux/netfilter_ipv4.h>
++#include <linux/slab.h> /* kmalloc */
++#endif
++
++#include "controller.h"
++
++int32_t get_header_size(struct protocol_buf * prot_buf)
++{
++ int32_t bit_counter = 0;
++ struct protocol_field * field = prot_buf->protocol_fields;
++
++ for (; field->name; field++)
++ bit_counter += field->length;
++
++ return bit_counter >> 3;
++}
++
++
++int32_t set_32_bit_generic(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ *(uint32_t *)(seg->start + seg->offset) = (uint32_t )htonl(luaL_checkinteger(L, 2));
++ return 0;
++}
++int32_t get_32_bit_generic(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ lua_pushinteger(L, ntohl(*((uint32_t *)(seg->start + seg->offset))));
++ return 1;
++}
++
++int32_t set_16_bit_generic(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ *(uint16_t *)(seg->start + seg->offset) = (uint16_t)htons(luaL_checkinteger(L, 2));
++ return 0;
++}
++int32_t get_16_bit_generic(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ lua_pushinteger(L, ntohs(*((uint16_t *)(seg->start + seg->offset))));
++ return 1;
++}
++
++int32_t set_lower_4_bit_generic(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++ uint8_t b = (uint8_t)luaL_checkinteger(L, 2) << 4;
++ uint8_t * pos = (uint8_t *)(seg->start + seg->offset);
++
++ *pos &= 0x0F; /* reset lower 4 bits*/
++ *pos |= b;
++
++ return 0;
++}
++
++int32_t get_lower_4_bit_generic(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ lua_pushinteger(L, (*(uint8_t *)(seg->start + seg->offset)) >> 4);
++ return 1;
++}
++
++int32_t set_upper_4_bit_generic(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++ uint8_t b = (uint8_t)luaL_checkinteger(L, 2) << 4;
++ uint8_t * pos = (uint8_t *)(seg->start + seg->offset);
++
++ *pos &= 0xF0; /* reset upper 4 bits*/
++ *pos |= (b >> 4);
++
++ return 0;
++}
++
++int32_t get_upper_4_bit_generic(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ lua_pushinteger(L, (*(uint8_t *)(seg->start + seg->offset)) & 0x0F);
++ return 1;
++}
++
++
++int32_t set_8_bit_generic(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ *(uint8_t *)(seg->start + seg->offset) = (uint8_t)luaL_checkinteger(L, 2);
++ return 0;
++}
++
++int32_t get_8_bit_generic(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ lua_pushinteger(L, *(uint8_t *)(seg->start + seg->offset));
++ return 1;
++}
++
++int32_t set_1_bit_generic(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++ unsigned long l = 0;
++
++ memcpy(&l, (seg->start + seg->offset), seg->length);
++ l |= (1 << ((CHAR_BIT * seg->length) - luaL_checkinteger(L, 2)));
++ memcpy((seg->start + seg->offset), &l, seg->length);
++
++ return 0;
++}
++
++int32_t get_1_bit_generic(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++ unsigned long l = 0;
++ uint32_t bit = 0;
++
++ memcpy(&l, (seg->start + seg->offset), seg->length);
++ bit = l & (1 << ((CHAR_BIT * seg->length) - luaL_checkinteger(L, 2)));
++
++ lua_pushboolean(L, bit);
++ return 1;
++}
++
++int32_t get_string_generic(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++ /* Warning we cast from uchar to char */
++ lua_pushlstring(L, (char *)seg->start + seg->offset, seg->length);
++ return 1;
++}
++
++int32_t set_data_generic(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++ lua_packet_segment * data = checkbytearray(L, 2);
++
++ pr_debug("seg->length %u, data->length %u\n", seg->length, data->length);
++
++ if (seg->length >= data->length)
++ memcpy((seg->start + seg->offset), data->start, data->length);
++ else
++ luaL_error(L, "provided byte array too big for given packet segment");
++ return 0;
++}
++
++struct field_changes * get_allocated_field_changes(lua_State *L, int32_t nr_of_fields)
++{
++ struct field_changes * changes;
++
++ changes = kmalloc(sizeof(struct field_changes), GFP_ATOMIC);
++
++ if (!changes)
++ goto failure;
++
++ changes->field_length_changes = kmalloc(nr_of_fields * sizeof(int), GFP_ATOMIC);
++ if (!changes->field_length_changes)
++ goto free1;
++
++ changes->field_offset_changes = kmalloc(nr_of_fields * sizeof(int), GFP_ATOMIC);
++ if (!changes->field_offset_changes)
++ goto free2;
++
++ memset(changes->field_length_changes, 0, nr_of_fields * sizeof(int));
++ memset(changes->field_offset_changes, 0, nr_of_fields * sizeof(int));
++
++ changes->ref_count = 1;
++
++ return changes;
++
++free2: kfree(changes->field_length_changes);
++free1: kfree(changes);
++failure:
++ if (!changes) luaL_error(L, "couldnt allocate memory inside 'get_allocated_field_changes'");
++ return NULL; /* only to omit warnings */
++}
+\ No newline at end of file
+--- /dev/null
++++ b/extensions/LUA/prot_buf_icmp.c
+@@ -0,0 +1,49 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre@dergraf.org>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++
++#include "controller.h"
++
++static int32_t icmp_has_protocol(lua_State *L, struct protocol_buf * prot_buf, lua_packet_segment * seg, int32_t protocol_type)
++{
++ return 0;
++}
++
++static const struct protocol_field icmp_protocol_fields[] = {
++ /* field name offset length getter setter */
++ { "type", 0, 8, NULL, NULL },
++ { "code", 8, 8, NULL, NULL },
++ { "checksum", 16, 16, NULL, NULL },
++ { "id", 32, 16, NULL, NULL },
++ { "sequence", 48, 16, NULL, NULL },
++ PROT_FIELD_SENTINEL,
++};
++
++static const struct protocol_buf icmp_protocol_buf = {
++ .is_dynamic = 0,
++ .name = LUA_PACKET_SEG_ICMP,
++ .payload_field = NULL,
++ .protocol_fields = (struct protocol_field *)&icmp_protocol_fields,
++ .has_protocol = &icmp_has_protocol,
++ .get_field_changes = NULL,
++};
++
++void luaopen_protbuf_icmp(lua_State *L)
++{
++ register_protbuf(L, (struct protocol_buf *)&icmp_protocol_buf, PACKET_ICMP);
++}
++
+--- /dev/null
++++ b/extensions/LUA/prot_buf_ip.c
+@@ -0,0 +1,209 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre@dergraf.org>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++
++#if defined(__KERNEL__)
++ #include <net/checksum.h>
++ #include <net/tcp.h>
++#endif
++
++#include "controller.h"
++
++
++#define IP_FMT "%u.%u.%u.%u"
++#define IP_ACC(buf) buf[0], buf[1], buf[2], buf[3]
++
++
++static int32_t ip_version_set(lua_State *L)
++{
++ uint8_t version_checked;
++ lua_packet_segment * seg = checkpacketseg(L, 1, LUA_PACKET_SEG_IP);
++ uint8_t *version_seg = seg->start + seg->offset;
++ int32_t version = luaL_checkinteger(L, 2);
++
++ luaL_argcheck(L, version >= 0 && version <= 15, 1, "version number invalid");
++
++ version_checked = (uint8_t)version;
++
++ version_seg[0] &= (uint8_t)0x0F; /* reset version bits */
++ version_seg[0] |= version_checked << 4;
++
++ return 0;
++}
++static int32_t ip_version_get(lua_State *L)
++{
++ lua_packet_segment * seg = checkpacketseg(L, 1, LUA_PACKET_SEG_IP);
++ uint8_t *version_seg = seg->start + seg->offset;
++ uint8_t v = version_seg[0] & 0xF0;
++
++ v >>= 4;
++
++ lua_pushinteger(L, v);
++ return 1;
++}
++
++static int32_t ip_ihl_set(lua_State *L)
++{
++ uint8_t ihl_checked;
++ lua_packet_segment * seg = checkpacketseg(L, 1, LUA_PACKET_SEG_IP);
++ uint8_t *ihl_seg = seg->start + seg->offset;
++ int32_t ihl = luaL_checkinteger(L, 2);
++
++ luaL_argcheck(L, ihl >= 5 && ihl <= 15, 1, "ip header length invalid"); // RFC 791 5x32 = 160 bits
++
++ ihl_checked = (uint8_t)ihl;
++
++ ihl_seg[0] &= (uint8_t)0xF0; /* reset ihl bits */
++ ihl_seg[0] |= ihl_checked;
++
++ return 0;
++}
++static int32_t ip_ihl_get(lua_State *L)
++{
++ lua_packet_segment * seg = checkpacketseg(L, 1, LUA_PACKET_SEG_IP);
++ uint8_t *ihl_seg = seg->start + seg->offset;
++ uint8_t v = ihl_seg[0] & 0x0F;
++
++ lua_pushinteger(L, v);
++ return 1;
++}
++
++static int32_t ip_addr_set(lua_State *L)
++{
++ int32_t field_id = lua_tointeger(L, lua_upvalueindex(2));
++ lua_packet_segment * seg = checkpacketseg(L, 1, LUA_PACKET_SEG_IP);
++ uint8_t *addr_seg = seg->start + seg->offset;
++ uint32_t old_addr;
++ char *ip = (char *)luaL_checkstring(L, 2);
++ uint32_t a, b, c, d;
++ struct sk_buff * skb = (struct sk_buff *)lua_touserdata(L, 3);
++
++ /* for tcp / udp checksumming*/
++ uint32_t prot_offset;
++ uint8_t *check, *protocol_seg;
++
++ /* end */
++
++ sscanf(ip, IP_FMT, &a, &b, &c, &d);
++
++ luaL_argcheck(L, a < 256 && b < 256 && c < 256 && d < 256, 1, "invalid ip addr");
++
++ old_addr = *((uint32_t *)addr_seg);
++ addr_seg[0] = (uint8_t)a;
++ addr_seg[1] = (uint8_t)b;
++ addr_seg[2] = (uint8_t)c;
++ addr_seg[3] = (uint8_t)d;
++
++#if defined(__KERNEL__)
++ if (old_addr != *(uint32_t *)addr_seg) {
++ int32_t offset = (field_id == 10) ? -2 : -6; /* offset from saddr or daddr */
++
++ csum_replace4((uint16_t *)(addr_seg + offset), old_addr, *(uint32_t *)addr_seg);
++
++ prot_offset = (field_id == 10) ? -3 : -7; /* offset from saddr or daddr */
++ protocol_seg = seg->start + seg->offset + prot_offset;
++
++ if (skb && (protocol_seg[0] == 0x06 || protocol_seg[0] == 0x11)) { /* is payload TCP or UDP ? */
++
++ check = seg->start + seg->offset; /* tmp res */
++ check += (field_id == 10) ? 8 : 16; /* the start of the payload, depending saddr or daddr */
++ check += (protocol_seg[0] == 0x06) ? 16 : 6; /* the start of the checksum, depending on TCP or UDP */
++
++ inet_proto_csum_replace4((__sum16 *)check, skb, old_addr, *(uint32_t *)addr_seg, 1);
++
++ lua_pop(L, 1);
++ }
++ }
++#endif
++ return 0;
++}
++
++
++
++
++
++static int32_t ip_addr_get(lua_State *L)
++{
++ lua_packet_segment * seg = checkpacketseg(L, 1, LUA_PACKET_SEG_IP);
++ uint8_t *addr_seg = seg->start + seg->offset;
++
++ char buf[16]; /*max: 255.255.255.255\0 --> 16 chars */
++
++ sprintf(buf, IP_FMT, IP_ACC(addr_seg));
++ lua_pushstring(L, buf);
++ return 1;
++}
++
++static int32_t ip_has_protocol(lua_State *L, struct protocol_buf * prot_buf, lua_packet_segment * seg, int32_t protocol_type)
++{
++ uint8_t * embedded_protocol = seg->start + seg->offset + 9 /*bytes*/;
++
++ switch (embedded_protocol[0]) {
++ case 0x01: /* 1: Internet Control Message Protocol (ICMP) */
++ if (protocol_type == PACKET_ICMP) return 1;
++ break;
++ case 0x02: /* 2: Internet Group Management Protocol (IGMP) */
++ break;
++ case 0x06: /* 6: Transmission Control Protocol (TCP) */
++ if (protocol_type == PACKET_TCP) return 1;
++ break;
++ case 0x11: /* 17: User Datagram Protocol (UDP) */
++ if (protocol_type == PACKET_UDP) return 1;
++ break;
++ case 0x59: /* 89: Open Shortest Path First (OSPF) */
++ break;
++ case 0x84: /* 132: Stream Control Transmission Protocol (SCTP) */
++ break;
++ default:
++ break;
++ }
++
++ return 0;
++}
++
++static const struct protocol_field ip_protocol_fields[] = {
++ /* field name offset length getter setter */
++ { "version", 0, 4, ip_version_get, ip_version_set },
++ { "ihl", 4, 4, ip_ihl_get, ip_ihl_set },
++ { "tos", 8, 8, get_8_bit_generic, set_8_bit_generic },
++ { "tot_len", 16, 16, get_16_bit_generic, set_16_bit_generic },
++ { "id", 32, 16, get_16_bit_generic, set_16_bit_generic },
++ { "flags", 48, 3, get_1_bit_generic, set_1_bit_generic },
++ { "frag_off", 51, 13, NULL, NULL },
++ { "ttl", 64, 8, get_8_bit_generic, set_8_bit_generic },
++ { "protocol", 72, 8, get_8_bit_generic, set_8_bit_generic },
++ { "check", 80, 16, get_16_bit_generic, set_16_bit_generic },
++ { "saddr", 96, 32, ip_addr_get, ip_addr_set },
++ { "daddr", 128, 32, ip_addr_get, ip_addr_set },
++ { "data", 160, 0, NULL, set_data_generic },
++ PROT_FIELD_SENTINEL,
++};
++
++static const struct protocol_buf ip_protocol_buf = {
++ .is_dynamic = 0,
++ .name = LUA_PACKET_SEG_IP,
++ .payload_field = "data",
++ .protocol_fields = (struct protocol_field *)&ip_protocol_fields,
++ .has_protocol = &ip_has_protocol,
++ .get_field_changes = NULL,
++};
++
++void luaopen_protbuf_ip(lua_State *L)
++{
++ register_protbuf(L, (struct protocol_buf *)&ip_protocol_buf, PACKET_IP);
++}
++
+--- /dev/null
++++ b/extensions/LUA/prot_buf_raw.c
+@@ -0,0 +1,43 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre@dergraf.org>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++
++#include "controller.h"
++static int32_t raw_has_protocol(lua_State *L, struct protocol_buf * prot_buf, lua_packet_segment * seg, int32_t protocol_type)
++{
++ return 1;
++}
++
++static const struct protocol_field raw_protocol_fields[] = {
++ /* field name offset length getter setter */
++ { "data", 0, 0, NULL, NULL },
++ PROT_FIELD_SENTINEL,
++};
++
++static const struct protocol_buf raw_protocol_buf = {
++ .is_dynamic = 0,
++ .name = LUA_PACKET_SEG_RAW,
++ .payload_field = "data",
++ .protocol_fields = (struct protocol_field *)&raw_protocol_fields,
++ .has_protocol = &raw_has_protocol,
++ .get_field_changes = NULL,
++};
++
++void luaopen_protbuf_raw(lua_State *L)
++{
++ register_protbuf(L, (struct protocol_buf *)&raw_protocol_buf, PACKET_RAW);
++}
+--- /dev/null
++++ b/extensions/LUA/prot_buf_tcp.c
+@@ -0,0 +1,188 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre@dergraf.org>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++
++#if defined(__KERNEL__)
++ #include <net/checksum.h>
++ #include <net/tcp.h>
++#endif
++#include "controller.h"
++
++
++static int32_t tcp_has_protocol(lua_State *L, struct protocol_buf * prot_buf, lua_packet_segment * seg, int32_t protocol_type)
++{
++ return 1;
++}
++
++static int32_t tcp_set_checksum(lua_State *L)
++{
++ struct protocol_buf * prot_buf = (struct protocol_buf *)lua_topointer(L, lua_upvalueindex(1));
++ lua_packet_segment * seg = checkpacketseg(L, 1, prot_buf->name);
++
++#if defined(__KERNEL__)
++ uint8_t * check_seg = seg->start + seg->offset;
++ uint8_t * tcp_hdr = check_seg - 16;
++ uint8_t * saddr = tcp_hdr - 8;
++ uint8_t * daddr = saddr + 4;
++ uint32_t len = 20 + (seg->changes->field_length_changes[11] / 8) + (seg->changes->field_length_changes[10] / 8);
++ unsigned short checksum = tcp_v4_check(len, *(uint32_t *)saddr, *(uint32_t *)daddr,
++ csum_partial(tcp_hdr, len, 0));
++
++ memcpy(check_seg, &checksum, sizeof(unsigned short));
++#endif
++ return 0;
++}
++
++
++static const struct protocol_field tcp_protocol_fields[] = {
++ /* field name offset length getter setter */
++ { "sport", 0, 16, get_16_bit_generic, set_16_bit_generic },
++ { "dport", 16, 16, get_16_bit_generic, set_16_bit_generic },
++ { "seq", 32, 32, get_32_bit_generic, set_32_bit_generic },
++ { "ack", 64, 32, get_32_bit_generic, set_32_bit_generic },
++ { "data_off", 96, 4, get_lower_4_bit_generic, set_lower_4_bit_generic },
++ { "reserved", 100, 4, get_upper_4_bit_generic, set_upper_4_bit_generic },
++ { "flags", 104, 8, get_1_bit_generic, set_1_bit_generic },
++ { "window_size", 112, 16, get_16_bit_generic, set_16_bit_generic },
++ { "check", 128, 16, get_16_bit_generic, tcp_set_checksum },
++ { "urgent", 144, 16, NULL, NULL },
++ { "options", 160, 0, NULL, set_data_generic },
++ { "data", 160, 0, NULL, set_data_generic }, /* begin of data depends on options */
++ PROT_FIELD_SENTINEL,
++};
++
++
++static const struct protocol_field tcp_options_and_data[] = {
++ /* field name offset length getter setter */
++ { "MSS", 0, 16, get_16_bit_generic, set_16_bit_generic },
++ { "WS", 0, 8, get_8_bit_generic, set_8_bit_generic },
++ { "SACK", 0, 16, get_16_bit_generic, set_16_bit_generic },
++ { "TSVAL", 0, 32, get_32_bit_generic, set_32_bit_generic },
++ { "TSER", 0, 32, get_32_bit_generic, set_32_bit_generic },
++ PROT_FIELD_SENTINEL,
++};
++
++
++static struct field_changes * tcp_get_field_changes(lua_State *L, lua_packet_segment * seg);
++
++static const struct protocol_buf tcp_protocol_buf = {
++ .is_dynamic = 0,
++ .name = LUA_PACKET_SEG_TCP,
++ .payload_field = "data",
++ .protocol_fields = (struct protocol_field *)&tcp_protocol_fields,
++ .has_protocol = &tcp_has_protocol,
++ .get_field_changes = &tcp_get_field_changes,
++};
++
++
++static struct field_changes * tcp_options_get_field_changes(lua_State *L, lua_packet_segment * seg);
++
++static const struct protocol_buf tcp_options_and_data_buf = {
++ .is_dynamic = 0,
++ .name = LUA_PACKET_SEG_TCP_OPT,
++ .payload_field = NULL,
++ .protocol_fields = (struct protocol_field *)&tcp_options_and_data,
++ .has_protocol = NULL,
++ .get_field_changes = &tcp_options_get_field_changes,
++};
++
++struct field_changes * tcp_get_field_changes(lua_State *L, lua_packet_segment * seg)
++{
++ /* depending on the value stored inside the 'data_off'-field, the length of
++ * the 'options' field has to be changed, as well as the length and offset
++ * of the 'data' field */
++ uint8_t *tcp_hdr = seg->start + seg->offset;
++
++ /* get the pointer to the 'data_off' field */
++ uint8_t * data_off_field = tcp_hdr + 12; /* 12 bytes offset */
++ /* extract the stored header length in bits */
++ uint32_t tcp_hdr_len = ((*(uint8_t *)data_off_field) >> 4) * 32;
++
++ /* get an allocated 'field_changes' structure */
++ struct field_changes * changes = get_allocated_field_changes(L, 12);
++
++ /* depending on the tcp header length, change the length of the options*/
++ changes->field_length_changes[10] = tcp_hdr_len - 160;
++ /* depending on the options length, change the offset of the data */
++ changes->field_offset_changes[11] = changes->field_length_changes[10];
++ changes->field_length_changes[11] = (seg->length * 8) - tcp_hdr_len;
++
++ return changes;
++
++}
++
++struct field_changes * tcp_options_get_field_changes(lua_State *L, lua_packet_segment * seg)
++{
++ /* depending on the value stored inside the 'data_off'-field, the length of
++ * the 'options' field has to be changed, as well as the length and offset
++ * of the 'data' field */
++ uint8_t *tcp_opt_hdr = seg->start + seg->offset;
++
++ /* get an allocated 'field_changes' structure */
++ struct field_changes * changes = get_allocated_field_changes(L, 5);
++
++ int32_t MSS = 0, WS = 0, SACK = 0, TS = 0, i;
++
++ uint8_t b1, b2;
++
++ for (i = 0; i < seg->length; i++) {
++ b1 = tcp_opt_hdr[i];
++ b2 = tcp_opt_hdr[i + 1];
++
++ if (b1 == 0x00)
++ break;
++
++ /* test for MSS */
++ if (!MSS && (b1 == 0x02 && b2 == 0x04)) {
++ changes->field_offset_changes[0] = (i + 2) * CHAR_BIT;
++ MSS = 1;
++ }
++
++ /* test for WS --- yet buggy somehow */
++ if (!WS && (b1 == 0x03 && b2 == 0x03)) {
++ changes->field_offset_changes[1] = (i + 2) * CHAR_BIT;
++ WS = 1;
++ }
++
++ /* test for SACK*/
++ if (!SACK && (b1 == 0x04 && b2 == 0x02)) {
++ changes->field_offset_changes[2] = i * CHAR_BIT; /* has no value */
++ SACK = 1;
++ }
++
++ /* test for TS */
++ if (!TS && (b1 == 0x08 && b2 == 0x0A)) {
++ changes->field_offset_changes[3] = (i + 2) * CHAR_BIT;
++ changes->field_offset_changes[4] = (i + 2 + 4) * CHAR_BIT;
++ TS = 1;
++ }
++ }
++
++ return changes;
++
++}
++
++void luaopen_protbuf_tcp(lua_State *L)
++{
++ register_protbuf(L, (struct protocol_buf *)&tcp_protocol_buf, PACKET_TCP);
++}
++void luaopen_protbuf_tcp_options(lua_State *L)
++{
++ register_protbuf(L, (struct protocol_buf *)&tcp_options_and_data_buf, PACKET_TCP_OPTIONS);
++}
++
++
+--- /dev/null
++++ b/extensions/LUA/prot_buf_tftp.c
+@@ -0,0 +1,87 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre@dergraf.org>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++#include "controller.h"
++
++static const struct protocol_field tftp_protocol_fields[] = {
++ /* field name offset length getter setter */
++ { "opcode", 0, 16, get_16_bit_generic, NULL},
++ { "filename", 0, 0, get_string_generic, NULL},
++ { "mode", 0, 0, get_string_generic, NULL},
++ { "block_nr", 0, 16, get_16_bit_generic, NULL},
++ { "data", 0, 0, NULL, NULL},
++ PROT_FIELD_SENTINEL,
++};
++
++struct field_changes * tftp_get_field_changes(lua_State *L, lua_packet_segment * seg)
++{
++ /* depending on the value stored inside the 'opcode'-field we have to change
++ * offsets and lengths */
++ uint8_t *tftp_hdr = seg->start + seg->offset;
++ short opcode = ntohs(*((uint16_t *)tftp_hdr));
++ /* get an allocated 'field_changes' structure */
++ struct field_changes * changes = get_allocated_field_changes(L, 5);
++ switch (opcode) {
++ case 1: /* Read Request (RRQ) */
++ /* setting offset and length of field 'filename' */
++ changes->field_offset_changes[1] = sizeof(unsigned short) << 3;
++ changes->field_length_changes[1] = strlen((char *)tftp_hdr + sizeof(unsigned short)) << 3;
++ /* setting offset and length of field 'mode' */
++ changes->field_offset_changes[2] = changes->field_offset_changes[1] + changes->field_length_changes[1];
++ changes->field_length_changes[2] = strlen((char *)tftp_hdr + (changes->field_offset_changes[2] >> 3));
++ break;
++ case 2: /* Write Request (WRQ) */
++ /* setting offset and length of field 'filename' */
++ changes->field_offset_changes[1] = sizeof(unsigned short) << 3;
++ changes->field_length_changes[1] = strlen((char *)tftp_hdr + sizeof(unsigned short)) << 3;
++ /* setting offset and length of field 'mode' */
++ changes->field_offset_changes[2] = changes->field_offset_changes[1] + changes->field_length_changes[1];
++ changes->field_length_changes[2] = strlen((char *)tftp_hdr + (changes->field_offset_changes[2] >> 3));
++ break;
++ case 3: /* Data (DATA) */
++ /* setting offset of field 'block_nr' */
++ changes->field_offset_changes[3] = sizeof(unsigned short) << 3;
++ /* setting offset of field 'data' */
++ changes->field_offset_changes[4] = changes->field_offset_changes[3] + (sizeof(unsigned short) << 3);
++ break;
++ case 4: /* Acknowledgment (ACK) */
++ /* setting offset of field 'block_nr' */
++ changes->field_offset_changes[3] = sizeof(unsigned short) << 3;
++ break;
++ case 5: /* Error (ERROR) */
++ /* we don't care ... yet */
++ break;
++ default:
++ break;
++ }
++
++ return changes;
++}
++
++static const struct protocol_buf tftp_protocol_buf = {
++ .is_dynamic = 0,
++ .name = LUA_PACKET_SEG_TFTP,
++ .payload_field = NULL,
++ .protocol_fields = (struct protocol_field *)&tftp_protocol_fields,
++ .has_protocol = NULL, /* we don't need it, since we don't provide a payload field */
++ .get_field_changes = tftp_get_field_changes,
++};
++
++void luaopen_protbuf_tftp(lua_State *L)
++{
++ register_protbuf(L, (struct protocol_buf *)&tftp_protocol_buf, PACKET_TFTP);
++}
+--- /dev/null
++++ b/extensions/LUA/prot_buf_udp.c
+@@ -0,0 +1,53 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre@dergraf.org>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++
++#if defined(__KERNEL__)
++ #include <net/checksum.h>
++#endif
++
++#include "controller.h"
++
++
++static int32_t udp_has_protocol(lua_State *L, struct protocol_buf * prot_buf, lua_packet_segment * seg, int32_t protocol_type)
++{
++ return 1;
++}
++
++static const struct protocol_field udp_protocol_fields[] = {
++ /* field name offset length getter setter */
++ { "sport", 0, 16, get_16_bit_generic, set_16_bit_generic },
++ { "dport", 16, 16, get_16_bit_generic, set_16_bit_generic },
++ { "length", 32, 16, get_16_bit_generic, set_16_bit_generic },
++ { "check", 48, 16, get_16_bit_generic, set_16_bit_generic },
++ { "data", 64, 0, NULL, NULL },
++ PROT_FIELD_SENTINEL,
++};
++
++static const struct protocol_buf udp_protocol_buf = {
++ .is_dynamic = 0,
++ .name = LUA_PACKET_SEG_UDP,
++ .payload_field = "data",
++ .protocol_fields = (struct protocol_field *)&udp_protocol_fields,
++ .has_protocol = &udp_has_protocol,
++ .get_field_changes = NULL,
++};
++
++void luaopen_protbuf_udp(lua_State *L)
++{
++ register_protbuf(L, (struct protocol_buf *)&udp_protocol_buf, PACKET_UDP);
++}
+--- /dev/null
++++ b/extensions/LUA/xt_LUA.h
+@@ -0,0 +1,36 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre.graf@stud.unibas.ch>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++
++#ifndef XT_LUA_H_
++#define XT_LUA_H_
++
++#define MAX_FILENAME_SIZE 256
++#define MAX_FUNCTION_SIZE 256
++#define MAX_SCRIPT_SIZE 32768
++#define LUA_STATE_ARRAY_SIZE 128
++
++/* the targetsize is stored in a u16, so max size of the xt_lua_tginfo cannot exceed 64K*/
++struct xt_lua_tginfo {
++ char buf[MAX_SCRIPT_SIZE];
++ char filename[MAX_FILENAME_SIZE];
++ char function[MAX_FUNCTION_SIZE];
++ __u64 script_size;
++ __u32 state_id;
++};
++
++#endif /* XT_LUA_H_ */
+--- /dev/null
++++ b/extensions/LUA/xt_LUA.mod.c
+@@ -0,0 +1,69 @@
++#include <linux/module.h>
++#include <linux/vermagic.h>
++#include <linux/compiler.h>
++
++MODULE_INFO(vermagic, VERMAGIC_STRING);
++
++struct module __this_module
++__attribute__((section(".gnu.linkonce.this_module"))) = {
++ .name = KBUILD_MODNAME,
++ .init = init_module,
++#ifdef CONFIG_MODULE_UNLOAD
++ .exit = cleanup_module,
++#endif
++ .arch = MODULE_ARCH_INIT,
++};
++
++static const struct modversion_info ____versions[]
++__used
++__attribute__((section("__versions"))) = {
++ { 0xa3379c4b, "module_layout" },
++ { 0x5cf97727, "xt_unregister_target" },
++ { 0x9a1dfd65, "strpbrk" },
++ { 0x56fb5417, "kmalloc_caches" },
++ { 0x12da5bb2, "__kmalloc" },
++ { 0xb85f3bbe, "pv_lock_ops" },
++ { 0x349cba85, "strchr" },
++ { 0xd0d8621b, "strlen" },
++ { 0x79aa04a2, "get_random_bytes" },
++ { 0x20000329, "simple_strtoul" },
++ { 0x105e2727, "__tracepoint_kmalloc" },
++ { 0xbf7e1481, "inet_proto_csum_replace4" },
++ { 0x6c1ce5ce, "strcspn" },
++ { 0x3c2c5af5, "sprintf" },
++ { 0xe2d5255a, "strcmp" },
++ { 0xe24d3a97, "jiffies_64" },
++ { 0x2bc95bd4, "memset" },
++ { 0x87fc9bcc, "kmem_cache_alloc_notrace" },
++ { 0x11089ac7, "_ctype" },
++ { 0x37befc70, "jiffies_to_msecs" },
++ { 0x70d1f8f3, "strncat" },
++ { 0xb72397d5, "printk" },
++ { 0x42224298, "sscanf" },
++ { 0x5152e605, "memcmp" },
++ { 0xb6ed1e53, "strncpy" },
++ { 0x1e6d26a8, "strstr" },
++ { 0xc3fa6a59, "memchr" },
++ { 0x61651be, "strcat" },
++ { 0x7d8c0d13, "xt_register_target" },
++ { 0x8ff4079b, "pv_irq_ops" },
++ { 0x93fca811, "__get_free_pages" },
++ { 0xf0fdf6cb, "__stack_chk_fail" },
++ { 0xbbe2391b, "kfree_skb" },
++ { 0xf333a2fb, "_raw_spin_lock_irq" },
++ { 0x37a0cba, "kfree" },
++ { 0x2e60bace, "memcpy" },
++ { 0x59e7cb79, "skb_make_writable" },
++ { 0xb742fd7, "simple_strtol" },
++ { 0x7d50a24, "csum_partial" },
++ { 0xc2d711e1, "krealloc" },
++ { 0xe914e41e, "strcpy" },
++};
++
++static const char __module_depends[]
++__used
++__attribute__((section(".modinfo"))) =
++"depends=x_tables";
++
++
++MODULE_INFO(srcversion, "33A1481C4AA71D1B5A8CA8A");
+--- /dev/null
++++ b/extensions/LUA/xt_LUA_target.c
+@@ -0,0 +1,286 @@
++/*
++ * Copyright (C) 2010 University of Basel <http://cn.cs.unibas.ch/>
++ * by Andre Graf <andre@dergraf.org>
++ *
++ * 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 of the License, 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; if not, see <http://www.gnu.org/licenses/>.
++ */
++
++#include <linux/kernel.h>
++#include <linux/slab.h>
++#include <linux/module.h>
++#include <asm/uaccess.h>
++#include <net/ip.h>
++#include <linux/netfilter/x_tables.h>
++#include "xt_LUA.h"
++
++#include "controller.h"
++
++/*::*
++ * lua_envs
++ * ----------
++ * This array holds a defined number of `lua_envs`_ structures.
++ * The used array index is also used as the Lua state identifier.
++ * The size of the array is defined in `LUA_STATE_ARRAY_SIZE`_.
++ */
++struct lua_env * lua_envs[LUA_STATE_ARRAY_SIZE];
++
++/*::*
++ * lua_state_refs
++ * --------------
++ * This array holds the reference counts of the several `lua_nf_state`_s
++ * which are stored inside the array `lua_states`_.
++ */
++uint32_t lua_state_refs[LUA_STATE_ARRAY_SIZE] = { 0 };
++
++/*::*
++ * lua_tg
++ * ------
++ * This function is called whenever a packet matches all matching conditions
++ * inside a rule. It is the target. It extracts the state identifier comming
++ * inside the *xt_target_param* structure and uses it to access the proper
++ * Lua state inside the `lua_states`_ array.
++ *
++ * It then constructs a new Lua userdata of type *lua_packet_segment* and
++ * initializes it with the lowest network header available. This userdata
++ * is annotated with the Lua metatable `LUA_PACKET_SEG_RAW`_ which converts
++ * the userdata to a raw lua packet having all raw functions available.
++ * This raw packet is the single parameter to the Lua function *process_packet*
++ * which must be defined inside the Lua script provided by the user. So far
++ * hardcoded, may be later configured by Lua - subject to change.
++ *
++ * The process_packet function must return an integer value, the verdict. For
++ * convenience reasons xt_LUA exports the verdicts NF_ACCEPT, NF_DROP and
++ * XT_CONTINUE inside the *register_lua_packet_lib* function.
++ */
++
++spinlock_t lock = SPIN_LOCK_UNLOCKED;
++
++static uint32_t
++lua_tg(struct sk_buff *pskb, const struct xt_target_param *par)
++{
++ uint32_t verdict;
++ lua_packet_segment *p;
++ const struct xt_lua_tginfo *info = par->targinfo;
++ lua_State * L;
++
++ /* START critical section on SMP, PacketScript is on the sequential trail at the moment TODO*/
++ spin_lock_irq(&lock);
++
++ L = lua_envs[info->state_id]->L;
++
++ if (!skb_make_writable(pskb, pskb->len))
++ return NF_DROP;
++
++ /* call the function provided by --function parameter or the default 'process_packet' defined in Lua */
++ lua_getglobal(L, info->function);
++
++ /* push the lua_packet_segment as a parameter */
++ p = (lua_packet_segment *)lua_newuserdata(L, sizeof(lua_packet_segment));
++ if (pskb->mac_header)
++ p->start = pskb->mac_header;
++ else if (pskb->network_header)
++ p->start = pskb->network_header;
++ else if (pskb->transport_header)
++ p->start = pskb->transport_header;
++ p->offset = 0;
++ p->length = (unsigned long)pskb->tail - (unsigned long)p->start;
++ p->changes = NULL;
++
++ /* marking userdata 'lua_packet_seg' with the corresponding metatable */
++ luaL_getmetatable(L, LUA_PACKET_SEG_RAW);
++ lua_setmetatable(L, -2);
++
++ /* push a reference to the skb as a parameter, needed at the moment for calculating TCP checksum, but I am not happy with it*/
++ lua_pushlightuserdata(L, (void *)skb_get(pskb));
++
++ /* do the function call (2 argument, 1 result) */
++ if (lua_pcall(L, 2, 1, 0) != 0) {
++ printk(KERN_ERR "LUA [%d]: pcall '%s' failed: %s\n", info->state_id, info->function, lua_tostring(L, -1));
++ lua_pop(L, 1);
++ return NF_DROP;
++ }
++
++ if (!lua_isnumber(L, -1)) {
++ printk(KERN_ERR "LUA [%d]: function '%s' must return a verdict\n", info->state_id, info->function);
++ lua_pop(L, 1);
++ return NF_DROP;
++ }
++
++ verdict = lua_tonumber(L, -1);
++ lua_pop(L, 1);
++
++ kfree_skb(pskb);
++
++ /* END critical section on SMP */
++ spin_unlock_irq(&lock);
++
++
++ return verdict;
++
++}
++/* Helper for checkentry */
++static bool load_script_into_state(uint32_t state_id, unsigned long script_size, char *script_buf)
++{
++ char *buf = kmalloc(script_size, GFP_KERNEL);
++ int32_t ret;
++ struct lua_env * env = kmalloc(sizeof(struct lua_env), GFP_KERNEL);
++
++ if (!script_size > 0) {
++ pr_debug("LUA [%d]: script_size %lu < 0\n", state_id, script_size);
++ return false;
++ }
++
++ env->L = lua_open();
++ luaopen_base(env->L);
++ luaopen_controller(env->L);
++
++ lua_getglobal(env->L, "_G");
++ lua_pushinteger(env->L, state_id);
++ lua_setfield(env->L, -2, "STATE_ID");
++ lua_pop(env->L, 1); /* pop _G */
++
++ strncpy(buf, script_buf, script_size);
++ ret = luaL_loadbuffer(env->L, buf, script_size, "PacketScript, loadbuffer") ||
++ lua_pcall(env->L, 0, 1, 0);
++
++ if (ret != 0) {
++ printk(KERN_ERR "LUA [%d]: failure loading script, error %s \n", state_id, lua_tostring(env->L, -1));
++ lua_pop(env->L, 1);
++ kfree(buf);
++ kfree(env);
++ return false;
++ }
++
++ lua_envs[state_id] = env;
++
++ kfree(buf);
++
++ return true;
++}
++/*::*
++ * lua_tg_checkentry
++ * -----------------
++ * This function is used as a kernel-side sanity check of the data comming
++ * from the iptables userspace program. Since this is the function which is
++ * called everytime a new rule (with -j xt_LUA) is injected, this function
++ * is used to do the bookkeeping work, such as counting the reference of
++ * several Lua states and the initialization of new states if needed. As an
++ * extra initialization step it loads the provided Lua script into the Lua
++ * state.
++ *
++ * Lua state initialization
++ * ~~~~~~~~~~~~~~~~~~~~~~~~
++ * 1. If a new rule is inserted and there is no existing state for the given
++ * state identifier (default state identifier is 0) a new Lua state is
++ * initialized using *lua_open*.
++ * 2. The Lua base library is registered inside the newly initialized state.
++ * Have a look at *lua/lbaselib.c* to see what functions of the Lua base
++ * library are available inside Lua.
++ * 3. The Lua packet library is registered inside the Lua state using the
++ * function *register_lua_packet_lib*. So far this function only registers
++ * the Netfilter verdicts NF_ACCEPT, NF_DROP and XT_CONTINUE inside the
++ * global environment of the given Lua state.
++ * 4. All the protocol Buffers, and the functions for accessing the bytes are
++ * registered using *register_protocols*.
++ *
++ * Lua state reference counting
++ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
++ * Bookkeeping of the Lua states inside the *lua_state_refs* array. The
++ * state identifier is mapped to the array index, which holds an integer
++ * counting the several initialized states.
++ *
++ * Loading the Lua script
++ * ~~~~~~~~~~~~~~~~~~~~~~
++ * Copying the buffer which was initialized by the userspace program to a
++ * buffer with the proper size. The script is then loaded by the function
++ * xt_LUA_loadcode, which wrapps the *luaL_loadbuffer* function and does
++ * some workqueue initialization. So far this is done each time this function
++ * is called, subject to change.
++ */
++static bool
++lua_tg_checkentry(const struct xt_tgchk_param *par)
++{
++ const struct xt_lua_tginfo *info = par->targinfo;
++
++ if (load_script_into_state(info->state_id, info->script_size, (char *)info->buf)) {
++ lua_state_refs[info->state_id]++;
++ return true;
++ }
++ return false;
++}
++
++/*::*
++ * lua_tg_destroy
++ * --------------
++ * This function is the counterpart of the `lua_tg_checkentry`_ function. It is
++ * responsible to free all the resources alocated inside the checkentry process.
++ * To be more specific it frees the Lua state using *lua_close* and kfree on all
++ * the dynamically allocated pointers to the registered dynamic protocol buffers.
++ *
++ * Additionally the function cares about decrementing the reference counters
++ * inside the array `lua_states`_.
++ */
++static void
++lua_tg_destroy(const struct xt_tgdtor_param *par)
++{
++ const struct xt_lua_tginfo *info = par->targinfo;
++ struct lua_env * env = lua_envs[info->state_id];
++
++ if (lua_state_refs[info->state_id] == 1) {
++ lua_close(env->L);
++ cleanup_dynamic_prot_bufs(); /* clean memory allocated by protocols defined in Lua */
++ kfree(env);
++ pr_debug("LUA [%d]: Rule removed, close Lua state\n", info->state_id);
++ } else
++ pr_debug("LUA [%d]: Rule removed, Lua state stays open, referenced %d time(s)\n",
++ info->state_id, lua_state_refs[info->state_id] - 1);
++
++ lua_state_refs[info->state_id]--;
++}
++
++static struct xt_target lua_tg_reg __read_mostly = {
++ .name = "LUA",
++ .revision = 0,
++ .family = NFPROTO_UNSPEC,
++ .targetsize = XT_ALIGN(sizeof(struct xt_lua_tginfo)),
++ .target = lua_tg,
++ .checkentry = lua_tg_checkentry,
++ .destroy = lua_tg_destroy,
++ .me = THIS_MODULE,
++};
++
++
++static int32_t lua_tg_init(void)
++{
++ return xt_register_target(&lua_tg_reg);
++}
++
++static void lua_tg_exit(void)
++{
++ xt_unregister_target(&lua_tg_reg);
++}
++
++module_init(lua_tg_init);
++module_exit(lua_tg_exit);
++
++MODULE_AUTHOR("Andre Graf <andre@dergraf.org>");
++MODULE_DESCRIPTION("Xtables: Processing of matched packets using the Lua scripting environment");
++MODULE_ALIAS("ipt_LUA");
++MODULE_ALIAS("ipt6t_LUA");
++MODULE_ALIAS("arpt_LUA");
++MODULE_ALIAS("ebt_LUA");
++MODULE_LICENSE("GPL");
++
++
++
+--- a/extensions/Kbuild
++++ b/extensions/Kbuild
+@@ -34,6 +34,7 @@ obj-${build_pknock} += pknock/
+ obj-${build_psd} += xt_psd.o
+ obj-${build_quota2} += xt_quota2.o
+ obj-${build_rtsp} += rtsp/
++obj-${build_LUA} += LUA/
+
+ -include ${M}/*.Kbuild
+ -include ${M}/Kbuild.*
+--- a/extensions/Mbuild
++++ b/extensions/Mbuild
+@@ -24,3 +24,4 @@ obj-${build_pknock} += pknock/
+ obj-${build_psd} += libxt_psd.so
+ obj-${build_quota2} += libxt_quota2.so
+ obj-${build_gradm} += libxt_gradm.so
++obj-${build_LUA} += LUA/
+--- a/mconfig
++++ b/mconfig
+@@ -25,3 +25,4 @@ build_pknock=m
+ build_psd=m
+ build_quota2=m
+ build_rtsp=m
++build_LUA=m
diff --git a/package/network/utils/xtables-addons/patches/201-fix-lua-packetscript.patch b/package/network/utils/xtables-addons/patches/201-fix-lua-packetscript.patch
new file mode 100644
index 0000000..966d29d
--- /dev/null
+++ b/package/network/utils/xtables-addons/patches/201-fix-lua-packetscript.patch
@@ -0,0 +1,89 @@
+--- a/extensions/LUA/xt_LUA_target.c
++++ b/extensions/LUA/xt_LUA_target.c
+@@ -64,10 +64,10 @@ uint32_t lua_state_refs[LUA_STATE_ARRAY
+ * XT_CONTINUE inside the *register_lua_packet_lib* function.
+ */
+
+-spinlock_t lock = SPIN_LOCK_UNLOCKED;
++DEFINE_SPINLOCK(lock);
+
+ static uint32_t
+-lua_tg(struct sk_buff *pskb, const struct xt_target_param *par)
++lua_tg(struct sk_buff *pskb, const struct xt_action_param *par)
+ {
+ uint32_t verdict;
+ lua_packet_segment *p;
+@@ -208,16 +208,16 @@ static bool load_script_into_state(uint3
+ * some workqueue initialization. So far this is done each time this function
+ * is called, subject to change.
+ */
+-static bool
++static int
+ lua_tg_checkentry(const struct xt_tgchk_param *par)
+ {
+ const struct xt_lua_tginfo *info = par->targinfo;
+
+ if (load_script_into_state(info->state_id, info->script_size, (char *)info->buf)) {
+ lua_state_refs[info->state_id]++;
+- return true;
++ return 0;
+ }
+- return false;
++ return -EINVAL;
+ }
+
+ /*::*
+--- a/extensions/LUA/lua/llimits.h
++++ b/extensions/LUA/lua/llimits.h
+@@ -8,7 +8,6 @@
+ #define llimits_h
+
+ #include <stddef.h>
+-#include <limits.h>
+
+ #include "lua.h"
+
+--- a/extensions/LUA/lua/lapi.c
++++ b/extensions/LUA/lua/lapi.c
+@@ -4,9 +4,6 @@
+ ** See Copyright Notice in lua.h
+ */
+
+-#include <stdarg.h>
+-#include <math.h>
+-#include <assert.h>
+ #include <string.h>
+
+ #define lapi_c
+--- a/extensions/LUA/lua/ltable.c
++++ b/extensions/LUA/lua/ltable.c
+@@ -18,7 +18,6 @@
+ ** Hence even when the load factor reaches 100%, performance remains good.
+ */
+
+-#include <math.h>
+ #include <string.h>
+
+ #define ltable_c
+--- a/extensions/LUA/lua/luaconf.h
++++ b/extensions/LUA/lua/luaconf.h
+@@ -13,6 +13,10 @@
+ #if !defined(__KERNEL__)
+ #include <limits.h>
+ #else
++#undef UCHAR_MAX
++#undef SHRT_MAX
++#undef BUFSIZ
++#undef NO_FPU
+ #define UCHAR_MAX 255
+ #define SHRT_MAX 32767
+ #define BUFSIZ 8192
+@@ -637,6 +641,8 @@ union luai_Cast { double l_d; long l_l;
+ */
+ #if defined(__KERNEL__)
+ #undef LUA_USE_ULONGJMP
++#define setjmp __builtin_setjmp
++#define longjmp __builtin_longjmp
+ #endif
+
+ #if defined(__cplusplus)
diff --git a/package/network/utils/xtables-addons/patches/300-geoip-endian-detection.patch b/package/network/utils/xtables-addons/patches/300-geoip-endian-detection.patch
new file mode 100644
index 0000000..842e7af
--- /dev/null
+++ b/package/network/utils/xtables-addons/patches/300-geoip-endian-detection.patch
@@ -0,0 +1,18 @@
+--- a/extensions/libxt_geoip.c
++++ b/extensions/libxt_geoip.c
+@@ -59,13 +59,13 @@ geoip_get_subnets(const char *code, uint
+
+ /* Use simple integer vector files */
+ if (nfproto == NFPROTO_IPV6) {
+-#if __BYTE_ORDER == _BIG_ENDIAN
++#if BYTE_ORDER == BIG_ENDIAN
+ snprintf(buf, sizeof(buf), GEOIP_DB_DIR "/BE/%s.iv6", code);
+ #else
+ snprintf(buf, sizeof(buf), GEOIP_DB_DIR "/LE/%s.iv6", code);
+ #endif
+ } else {
+-#if __BYTE_ORDER == _BIG_ENDIAN
++#if BYTE_ORDER == BIG_ENDIAN
+ snprintf(buf, sizeof(buf), GEOIP_DB_DIR "/BE/%s.iv4", code);
+ #else
+ snprintf(buf, sizeof(buf), GEOIP_DB_DIR "/LE/%s.iv4", code);
diff --git a/package/network/utils/xtables-addons/patches/400-uid-gid-linux-3.7-compat.patch b/package/network/utils/xtables-addons/patches/400-uid-gid-linux-3.7-compat.patch
new file mode 100644
index 0000000..8a5be0d
--- /dev/null
+++ b/package/network/utils/xtables-addons/patches/400-uid-gid-linux-3.7-compat.patch
@@ -0,0 +1,83 @@
+--- a/extensions/xt_DNETMAP.c
++++ b/extensions/xt_DNETMAP.c
+@@ -21,6 +21,7 @@
+ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+ #include <linux/inet.h>
+ #include <linux/ip.h>
++#include <linux/version.h>
+ #include <linux/module.h>
+ #include <linux/netdevice.h>
+ #include <linux/netfilter.h>
+@@ -328,8 +329,8 @@ static int dnetmap_tg_check(const struct
+ ret = -ENOMEM;
+ goto out;
+ }
+- pde_data->uid = proc_uid;
+- pde_data->gid = proc_gid;
++ pde_data->uid = XT_UID(proc_uid);
++ pde_data->gid = XT_GID(proc_gid);
+
+ /* statistics */
+ pde_stat = create_proc_entry(p->proc_str_stat, proc_perms,
+@@ -341,8 +342,8 @@ static int dnetmap_tg_check(const struct
+ }
+ pde_stat->data = p;
+ pde_stat->read_proc = dnetmap_stat_proc_read;
+- pde_stat->uid = proc_uid;
+- pde_stat->gid = proc_gid;
++ pde_stat->uid = XT_UID(proc_uid);
++ pde_stat->gid = XT_GID(proc_gid);
+ #endif
+
+ spin_lock_bh(&dnetmap_lock);
+--- a/extensions/xt_condition.c
++++ b/extensions/xt_condition.c
+@@ -14,6 +14,7 @@
+ */
+ #include <linux/kernel.h>
+ #include <linux/list.h>
++#include <linux/version.h>
+ #include <linux/module.h>
+ #include <linux/proc_fs.h>
+ #include <linux/spinlock.h>
+@@ -155,8 +156,8 @@ static int condition_mt_check(const stru
+ var->status_proc->read_proc = condition_proc_read;
+ var->status_proc->write_proc = condition_proc_write;
+ list_add(&var->list, &conditions_list);
+- var->status_proc->uid = condition_uid_perms;
+- var->status_proc->gid = condition_gid_perms;
++ var->status_proc->uid = XT_UID(condition_uid_perms);
++ var->status_proc->gid = XT_GID(condition_gid_perms);
+ mutex_unlock(&proc_lock);
+ info->condvar = var;
+ return 0;
+--- a/extensions/compat_xtables.h
++++ b/extensions/compat_xtables.h
+@@ -12,6 +12,14 @@
+ # warning Kernels below 3.7 not supported.
+ #endif
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 7, 0)
++# define XT_UID(x) KUIDT_INIT(x)
++# define XT_GID(x) KGIDT_INIT(x)
++#else
++# define XT_UID(x) (x)
++# define XT_GID(x) (x)
++#endif
++
+ #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
+ # if !defined(CONFIG_NF_CONNTRACK_MARK)
+ # warning You have CONFIG_NF_CONNTRACK enabled, but CONFIG_NF_CONNTRACK_MARK is not (please enable).
+--- a/extensions/xt_quota2.c
++++ b/extensions/xt_quota2.c
+@@ -131,8 +131,8 @@ q2_get_counter(const struct xt_quota_mti
+ p->data = e;
+ p->read_proc = quota_proc_read;
+ p->write_proc = quota_proc_write;
+- p->uid = quota_list_uid;
+- p->gid = quota_list_gid;
++ p->uid = XT_UID(quota_list_uid);
++ p->gid = XT_GID(quota_list_gid);
+ list_add_tail(&e->list, &counter_list);
+ spin_unlock_bh(&counter_list_lock);
+ return e;
diff --git a/package/opkg/.svn/entries b/package/opkg/.svn/entries
new file mode 100644
index 0000000..e60de66
--- /dev/null
+++ b/package/opkg/.svn/entries
@@ -0,0 +1,68 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/opkg
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-12-22T19:31:37.739976Z
+34869
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+files
+dir
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+4b67d1b434c4c1d5445e71ef55035d53
+2012-11-15T20:17:49.369348Z
+34202
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2552
+
diff --git a/package/opkg/.svn/text-base/Makefile.svn-base b/package/opkg/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..6407ab4
--- /dev/null
+++ b/package/opkg/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,102 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+include $(INCLUDE_DIR)/version.mk
+
+PKG_NAME:=opkg
+PKG_REV:=618
+PKG_VERSION:=$(PKG_REV)
+PKG_RELEASE:=3
+
+PKG_SOURCE_PROTO:=svn
+PKG_SOURCE_VERSION:=$(PKG_REV)
+PKG_SOURCE_SUBDIR:=opkg-$(PKG_VERSION)
+PKG_SOURCE_URL:=http://opkg.googlecode.com/svn/trunk/
+PKG_SOURCE:=$(PKG_SOURCE_SUBDIR).tar.gz
+PKG_FIXUP:=autoreconf
+PKG_REMOVE_FILES = autogen.sh aclocal.m4
+
+PKG_LICENSE:=GPLv2
+PKG_LICENSE_FILES:=COPYING
+
+PKG_BUILD_PARALLEL:=1
+HOST_BUILD_PARALLEL:=1
+PKG_INSTALL:=1
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/host-build.mk
+
+define Package/opkg
+ SECTION:=base
+ CATEGORY:=Base system
+ TITLE:=opkg package management system
+ MAINTAINER:=Jo-Philipp Wich <xm@subsignal.org>
+ URL:=http://wiki.openmoko.org/wiki/Opkg
+endef
+
+define Package/opkg/description
+ Lightweight package management system
+ opkg is the opkg Package Management System, for handling
+ installation and removal of packages on a system. It can
+ recursively follow dependencies and download all packages
+ necessary to install a particular package.
+
+ opkg knows how to install both .ipk and .deb packages.
+endef
+
+define Package/opkg/conffiles
+/etc/opkg.conf
+endef
+
+TARGET_CFLAGS += $(if $(CONFIG_GCC_VERSION_4_3)$(CONFIG_GCC_VERSION_4_4),-Wno-array-bounds)
+TARGET_CFLAGS += -ffunction-sections -fdata-sections
+EXTRA_CFLAGS += $(TARGET_CPPFLAGS)
+
+CONFIGURE_ARGS += \
+ --disable-curl \
+ --disable-gpg \
+ --with-opkgetcdir=/etc \
+ --with-opkglockfile=/var/lock/opkg.lock
+
+MAKE_FLAGS = \
+ CC="$(TARGET_CC)" \
+ DESTDIR="$(PKG_INSTALL_DIR)" \
+ HOST_CPU="$(PKGARCH)" \
+ LDFLAGS="-Wl,--gc-sections" \
+
+define Package/opkg/install
+ $(INSTALL_DIR) $(1)/usr/lib/opkg
+ $(INSTALL_DIR) $(1)/bin
+ $(INSTALL_DIR) $(1)/etc
+ $(INSTALL_DATA) ./files/opkg.conf $(1)/etc/
+ $(VERSION_SED) $(1)/etc/opkg.conf
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/opkg-cl $(1)/bin/opkg
+endef
+
+define Build/InstallDev
+ mkdir -p $(1)/usr/include
+ $(CP) $(PKG_INSTALL_DIR)/usr/include/libopkg $(1)/usr/include/
+endef
+
+
+HOST_CONFIGURE_ARGS+= \
+ --disable-curl \
+ --disable-gpg \
+ --with-opkgetcdir=/etc \
+ --with-opkglockfile=/tmp/opkg.lock
+
+define Host/Compile
+ +$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) CC="$(HOSTCC)" all
+endef
+
+define Host/Install
+ $(INSTALL_BIN) $(HOST_BUILD_DIR)/src/opkg-cl $(STAGING_DIR_HOST)/bin/opkg
+endef
+
+$(eval $(call BuildPackage,opkg))
+$(eval $(call HostBuild))
diff --git a/package/opkg/Makefile b/package/opkg/Makefile
new file mode 100644
index 0000000..6407ab4
--- /dev/null
+++ b/package/opkg/Makefile
@@ -0,0 +1,102 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+include $(INCLUDE_DIR)/version.mk
+
+PKG_NAME:=opkg
+PKG_REV:=618
+PKG_VERSION:=$(PKG_REV)
+PKG_RELEASE:=3
+
+PKG_SOURCE_PROTO:=svn
+PKG_SOURCE_VERSION:=$(PKG_REV)
+PKG_SOURCE_SUBDIR:=opkg-$(PKG_VERSION)
+PKG_SOURCE_URL:=http://opkg.googlecode.com/svn/trunk/
+PKG_SOURCE:=$(PKG_SOURCE_SUBDIR).tar.gz
+PKG_FIXUP:=autoreconf
+PKG_REMOVE_FILES = autogen.sh aclocal.m4
+
+PKG_LICENSE:=GPLv2
+PKG_LICENSE_FILES:=COPYING
+
+PKG_BUILD_PARALLEL:=1
+HOST_BUILD_PARALLEL:=1
+PKG_INSTALL:=1
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/host-build.mk
+
+define Package/opkg
+ SECTION:=base
+ CATEGORY:=Base system
+ TITLE:=opkg package management system
+ MAINTAINER:=Jo-Philipp Wich <xm@subsignal.org>
+ URL:=http://wiki.openmoko.org/wiki/Opkg
+endef
+
+define Package/opkg/description
+ Lightweight package management system
+ opkg is the opkg Package Management System, for handling
+ installation and removal of packages on a system. It can
+ recursively follow dependencies and download all packages
+ necessary to install a particular package.
+
+ opkg knows how to install both .ipk and .deb packages.
+endef
+
+define Package/opkg/conffiles
+/etc/opkg.conf
+endef
+
+TARGET_CFLAGS += $(if $(CONFIG_GCC_VERSION_4_3)$(CONFIG_GCC_VERSION_4_4),-Wno-array-bounds)
+TARGET_CFLAGS += -ffunction-sections -fdata-sections
+EXTRA_CFLAGS += $(TARGET_CPPFLAGS)
+
+CONFIGURE_ARGS += \
+ --disable-curl \
+ --disable-gpg \
+ --with-opkgetcdir=/etc \
+ --with-opkglockfile=/var/lock/opkg.lock
+
+MAKE_FLAGS = \
+ CC="$(TARGET_CC)" \
+ DESTDIR="$(PKG_INSTALL_DIR)" \
+ HOST_CPU="$(PKGARCH)" \
+ LDFLAGS="-Wl,--gc-sections" \
+
+define Package/opkg/install
+ $(INSTALL_DIR) $(1)/usr/lib/opkg
+ $(INSTALL_DIR) $(1)/bin
+ $(INSTALL_DIR) $(1)/etc
+ $(INSTALL_DATA) ./files/opkg.conf $(1)/etc/
+ $(VERSION_SED) $(1)/etc/opkg.conf
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/opkg-cl $(1)/bin/opkg
+endef
+
+define Build/InstallDev
+ mkdir -p $(1)/usr/include
+ $(CP) $(PKG_INSTALL_DIR)/usr/include/libopkg $(1)/usr/include/
+endef
+
+
+HOST_CONFIGURE_ARGS+= \
+ --disable-curl \
+ --disable-gpg \
+ --with-opkgetcdir=/etc \
+ --with-opkglockfile=/tmp/opkg.lock
+
+define Host/Compile
+ +$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) CC="$(HOSTCC)" all
+endef
+
+define Host/Install
+ $(INSTALL_BIN) $(HOST_BUILD_DIR)/src/opkg-cl $(STAGING_DIR_HOST)/bin/opkg
+endef
+
+$(eval $(call BuildPackage,opkg))
+$(eval $(call HostBuild))
diff --git a/package/opkg/files/.svn/entries b/package/opkg/files/.svn/entries
new file mode 100644
index 0000000..12bc552
--- /dev/null
+++ b/package/opkg/files/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/opkg/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-04-12T17:31:16.941025Z
+31262
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+opkg.conf
+file
+
+
+
+
+2013-03-17T12:13:09.000000Z
+de1bcf097253334b8283a2eda1d490b8
+2012-04-12T17:31:16.941025Z
+31262
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+98
+
diff --git a/package/opkg/files/.svn/text-base/opkg.conf.svn-base b/package/opkg/files/.svn/text-base/opkg.conf.svn-base
new file mode 100644
index 0000000..6fb42b7
--- /dev/null
+++ b/package/opkg/files/.svn/text-base/opkg.conf.svn-base
@@ -0,0 +1,5 @@
+src/gz %n %U
+dest root /
+dest ram /tmp
+lists_dir ext /var/opkg-lists
+option overlay_root /overlay
diff --git a/package/opkg/files/opkg.conf b/package/opkg/files/opkg.conf
new file mode 100644
index 0000000..6fb42b7
--- /dev/null
+++ b/package/opkg/files/opkg.conf
@@ -0,0 +1,5 @@
+src/gz %n %U
+dest root /
+dest ram /tmp
+lists_dir ext /var/opkg-lists
+option overlay_root /overlay
diff --git a/package/opkg/patches/.svn/entries b/package/opkg/patches/.svn/entries
new file mode 100644
index 0000000..18e3be5
--- /dev/null
+++ b/package/opkg/patches/.svn/entries
@@ -0,0 +1,504 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/opkg/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-12-22T19:31:37.739976Z
+34869
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+004-host_cpu.patch
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+3e09d6fa2843d5e4a5deb95643ea2278
+2010-01-07T12:37:49.342833Z
+19061
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1064
+
+060-add-find-command.patch
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+8786a9b188412b7d6989ce8f89bcb745
+2012-11-15T20:53:51.041187Z
+34203
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2316
+
+011-old-config-location.patch
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+c32ac99f21d96a78fa97ae251ed49832
+2011-04-11T22:08:43.350392Z
+26598
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+247
+
+012-strip-trailing-conffiles-whitespace.patch
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+c31bc55bd41a9355a0a2de89e79de6ae
+2010-10-02T03:25:35.961553Z
+23174
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+635
+
+020-avoid_getline.patch
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+178f7ffafcd7b02b97cc3d2bbe19efba
+2011-04-15T16:18:11.094030Z
+26684
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+7405
+
+040-wrap-descriptions-only-on-ttys.patch
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+26d02029d4276575af845fb168950312
+2012-11-15T20:17:49.369348Z
+34202
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+896
+
+050-add-case-insensitive-flag.patch
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+0a918e8934f2da447ee9de8b7d8e7a74
+2012-11-15T20:17:49.369348Z
+34202
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+6199
+
+007-force_static.patch
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+26324bcdd562f63bde45e5ba3dce5b5b
+2011-04-11T22:08:43.350392Z
+26598
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2580
+
+030-fix-double-free.patch
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+7d8325a9a7efb38f3eda7a6827ad4379
+2011-10-15T01:05:25.150578Z
+28458
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+319
+
+001-ship-pkg-m4.patch
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+860cbdb5514b03348395d7e22a71edcf
+2010-11-25T18:02:36.191290Z
+24145
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5589
+
+009-remove-upgrade-all.patch
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+582f06882d4c5a63af3db4852c3a1653
+2011-04-11T22:08:43.350392Z
+26598
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1564
+
+070-use_gzipped_pkg_list.patch
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+c563e16c32a6e2c274a01a5c1880f39b
+2012-12-22T19:31:37.739976Z
+34869
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3181
+
+002-no-shave.patch
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+7340b808d476ec745e22bfc557b72b7b
+2010-12-13T20:52:57.653422Z
+24553
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+787
+
+014-errors-to-stderr.patch
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+b83bc3fa45fa52b7da9f0a71e39b8f8b
+2010-11-24T14:54:26.511352Z
+24133
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+428
+
diff --git a/package/opkg/patches/.svn/text-base/001-ship-pkg-m4.patch.svn-base b/package/opkg/patches/.svn/text-base/001-ship-pkg-m4.patch.svn-base
new file mode 100644
index 0000000..4ca0f88
--- /dev/null
+++ b/package/opkg/patches/.svn/text-base/001-ship-pkg-m4.patch.svn-base
@@ -0,0 +1,168 @@
+--- /dev/null
++++ b/m4/pkg.m4
+@@ -0,0 +1,157 @@
++# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
++#
++# Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
++#
++# 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 of the License, 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; if not, write to the Free Software
++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
++#
++# As a special exception to the GNU General Public License, if you
++# distribute this file as part of a program that contains a
++# configuration script generated by Autoconf, you may include it under
++# the same distribution terms that you use for the rest of that program.
++
++# PKG_PROG_PKG_CONFIG([MIN-VERSION])
++# ----------------------------------
++AC_DEFUN([PKG_PROG_PKG_CONFIG],
++[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
++m4_pattern_allow([^PKG_CONFIG(_PATH)?$])
++AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])dnl
++if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
++ AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
++fi
++if test -n "$PKG_CONFIG"; then
++ _pkg_min_version=m4_default([$1], [0.9.0])
++ AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
++ if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
++ AC_MSG_RESULT([yes])
++ else
++ AC_MSG_RESULT([no])
++ PKG_CONFIG=""
++ fi
++
++fi[]dnl
++])# PKG_PROG_PKG_CONFIG
++
++# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
++#
++# Check to see whether a particular set of modules exists. Similar
++# to PKG_CHECK_MODULES(), but does not set variables or print errors.
++#
++#
++# Similar to PKG_CHECK_MODULES, make sure that the first instance of
++# this or PKG_CHECK_MODULES is called, or make sure to call
++# PKG_CHECK_EXISTS manually
++# --------------------------------------------------------------
++AC_DEFUN([PKG_CHECK_EXISTS],
++[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
++if test -n "$PKG_CONFIG" && \
++ AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
++ m4_ifval([$2], [$2], [:])
++m4_ifvaln([$3], [else
++ $3])dnl
++fi])
++
++
++# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
++# ---------------------------------------------
++m4_define([_PKG_CONFIG],
++[if test -n "$PKG_CONFIG"; then
++ if test -n "$$1"; then
++ pkg_cv_[]$1="$$1"
++ else
++ PKG_CHECK_EXISTS([$3],
++ [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`],
++ [pkg_failed=yes])
++ fi
++else
++ pkg_failed=untried
++fi[]dnl
++])# _PKG_CONFIG
++
++# _PKG_SHORT_ERRORS_SUPPORTED
++# -----------------------------
++AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
++[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
++if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
++ _pkg_short_errors_supported=yes
++else
++ _pkg_short_errors_supported=no
++fi[]dnl
++])# _PKG_SHORT_ERRORS_SUPPORTED
++
++
++# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
++# [ACTION-IF-NOT-FOUND])
++#
++#
++# Note that if there is a possibility the first call to
++# PKG_CHECK_MODULES might not happen, you should be sure to include an
++# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
++#
++#
++# --------------------------------------------------------------
++AC_DEFUN([PKG_CHECK_MODULES],
++[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
++AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
++AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
++
++pkg_failed=no
++AC_MSG_CHECKING([for $1])
++
++_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
++_PKG_CONFIG([$1][_LIBS], [libs], [$2])
++
++m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
++and $1[]_LIBS to avoid the need to call pkg-config.
++See the pkg-config man page for more details.])
++
++if test $pkg_failed = yes; then
++ _PKG_SHORT_ERRORS_SUPPORTED
++ if test $_pkg_short_errors_supported = yes; then
++ $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "$2"`
++ else
++ $1[]_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"`
++ fi
++ # Put the nasty error message in config.log where it belongs
++ echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
++
++ ifelse([$4], , [AC_MSG_ERROR(dnl
++[Package requirements ($2) were not met:
++
++$$1_PKG_ERRORS
++
++Consider adjusting the PKG_CONFIG_PATH environment variable if you
++installed software in a non-standard prefix.
++
++_PKG_TEXT
++])],
++ [AC_MSG_RESULT([no])
++ $4])
++elif test $pkg_failed = untried; then
++ ifelse([$4], , [AC_MSG_FAILURE(dnl
++[The pkg-config script could not be found or is too old. Make sure it
++is in your PATH or set the PKG_CONFIG environment variable to the full
++path to pkg-config.
++
++_PKG_TEXT
++
++To get pkg-config, see <http://pkg-config.freedesktop.org/>.])],
++ [$4])
++else
++ $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
++ $1[]_LIBS=$pkg_cv_[]$1[]_LIBS
++ AC_MSG_RESULT([yes])
++ ifelse([$3], , :, [$3])
++fi[]dnl
++])# PKG_CHECK_MODULES
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -1,4 +1,4 @@
+-ACLOCAL_AMFLAGS = -I shave
++ACLOCAL_AMFLAGS = -I shave -I m4
+
+ SUBDIRS = libbb libopkg src tests utils man
+
diff --git a/package/opkg/patches/.svn/text-base/002-no-shave.patch.svn-base b/package/opkg/patches/.svn/text-base/002-no-shave.patch.svn-base
new file mode 100644
index 0000000..313aa71
--- /dev/null
+++ b/package/opkg/patches/.svn/text-base/002-no-shave.patch.svn-base
@@ -0,0 +1,37 @@
+--- a/configure.ac
++++ b/configure.ac
+@@ -4,7 +4,6 @@ AC_CONFIG_SRCDIR([libopkg/pkg.c])
+
+ AC_CONFIG_AUX_DIR([conf])
+ AC_CONFIG_MACRO_DIR([m4])
+-AC_CONFIG_MACRO_DIR([shave])
+
+ AM_INIT_AUTOMAKE
+ AM_CONFIG_HEADER(libopkg/config.h)
+@@ -277,9 +276,6 @@ AC_SUBST(opkgetcdir)
+ AC_SUBST(opkglockfile)
+ AC_SUBST([CLEAN_DATE])
+
+-# Setup output beautifier.
+-SHAVE_INIT([shave], [enable])
+-
+ AC_OUTPUT(
+ Makefile
+ libopkg/Makefile
+@@ -289,8 +285,6 @@ AC_OUTPUT(
+ utils/Makefile
+ utils/update-alternatives
+ libopkg.pc
+- shave/shave
+- shave/shave-libtool
+ man/Makefile
+ man/opkg-cl.1
+ man/opkg-key.1
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -1,4 +1,4 @@
+-ACLOCAL_AMFLAGS = -I shave -I m4
++ACLOCAL_AMFLAGS = -I m4
+
+ SUBDIRS = libbb libopkg src tests utils man
+
diff --git a/package/opkg/patches/.svn/text-base/004-host_cpu.patch.svn-base b/package/opkg/patches/.svn/text-base/004-host_cpu.patch.svn-base
new file mode 100644
index 0000000..d500d60
--- /dev/null
+++ b/package/opkg/patches/.svn/text-base/004-host_cpu.patch.svn-base
@@ -0,0 +1,20 @@
+--- a/libbb/Makefile.am
++++ b/libbb/Makefile.am
+@@ -1,6 +1,6 @@
+ HOST_CPU=@host_cpu@
+ BUILD_CPU=@build_cpu@
+-ALL_CFLAGS=-g -O -Wall -DHOST_CPU_STR=\"@host_cpu@\" -DBUILD_CPU=@build_cpu@
++ALL_CFLAGS=-g -O -Wall -DHOST_CPU_STR=\"$(HOST_CPU)\" -DBUILD_CPU=@build_cpu@
+
+ noinst_LTLIBRARIES = libbb.la
+
+--- a/libopkg/Makefile.am
++++ b/libopkg/Makefile.am
+@@ -1,5 +1,5 @@
+-
+-AM_CFLAGS=-Wall -DHOST_CPU_STR=\"@host_cpu@\" -DBUILD_CPU=@build_cpu@ -DLIBDIR=\"@libdir@\" -DOPKGLIBDIR=\"@opkglibdir@\" -DOPKGETCDIR=\"@opkgetcdir@\" -DOPKGLOCKFILE=\"@opkglockfile@\" -DDATADIR=\"@datadir@\" -I$(top_srcdir) $(BIGENDIAN_CFLAGS) $(CURL_CFLAGS) $(GPGME_CFLAGS) $(PATHFINDER_CFLAGS)
++HOST_CPU=@host_cpu@
++AM_CFLAGS=-Wall -DHOST_CPU_STR=\"$(HOST_CPU)\" -DBUILD_CPU=@build_cpu@ -DLIBDIR=\"@libdir@\" -DOPKGLIBDIR=\"@opkglibdir@\" -DOPKGETCDIR=\"@opkgetcdir@\" -DOPKGLOCKFILE=\"@opkglockfile@\" -DDATADIR=\"@datadir@\" -I$(top_srcdir) $(BIGENDIAN_CFLAGS) $(CURL_CFLAGS) $(GPGME_CFLAGS) $(PATHFINDER_CFLAGS)
+
+ libopkg_includedir=$(includedir)/libopkg
+ libopkg_include_HEADERS= *.h
diff --git a/package/opkg/patches/.svn/text-base/007-force_static.patch.svn-base b/package/opkg/patches/.svn/text-base/007-force_static.patch.svn-base
new file mode 100644
index 0000000..80a9815
--- /dev/null
+++ b/package/opkg/patches/.svn/text-base/007-force_static.patch.svn-base
@@ -0,0 +1,71 @@
+--- a/libopkg/Makefile.am
++++ b/libopkg/Makefile.am
+@@ -38,16 +38,10 @@ if HAVE_SHA256
+ opkg_util_sources += sha256.c sha256.h
+ endif
+
+-lib_LTLIBRARIES = libopkg.la
+-libopkg_la_SOURCES = \
++noinst_LIBRARIES = libopkg.a
++libopkg_a_SOURCES = \
+ $(opkg_libcore_sources) \
+ $(opkg_cmd_sources) $(opkg_db_sources) \
+ $(opkg_util_sources) $(opkg_list_sources)
+
+-libopkg_la_LIBADD = $(top_builddir)/libbb/libbb.la $(CURL_LIBS) $(GPGME_LIBS) $(OPENSSL_LIBS) $(PATHFINDER_LIBS)
+-
+-# make sure we only export symbols that are for public use
+-#libopkg_la_LDFLAGS = -export-symbols-regex "^opkg_.*"
+-
+-
+-
++libopkg_a_LIBADD = $(top_builddir)/libbb/libbb.a $(CURL_LIBS) $(GPGME_LIBS) $(OPENSSL_LIBS) $(PATHFINDER_LIBS)
+--- a/libbb/Makefile.am
++++ b/libbb/Makefile.am
+@@ -2,9 +2,9 @@ HOST_CPU=@host_cpu@
+ BUILD_CPU=@build_cpu@
+ ALL_CFLAGS=-g -O -Wall -DHOST_CPU_STR=\"$(HOST_CPU)\" -DBUILD_CPU=@build_cpu@
+
+-noinst_LTLIBRARIES = libbb.la
++noinst_LIBRARIES = libbb.a
+
+-libbb_la_SOURCES = gz_open.c \
++libbb_a_SOURCES = gz_open.c \
+ libbb.h \
+ unzip.c \
+ wfopen.c \
+--- a/tests/Makefile.am
++++ b/tests/Makefile.am
+@@ -4,11 +4,11 @@ AM_CFLAGS = $(ALL_CFLAGS) -Wall -g -O3 -
+ #noinst_PROGRAMS = libopkg_test opkg_active_list_test
+ noinst_PROGRAMS = libopkg_test
+
+-#opkg_hash_test_LDADD = $(top_builddir)/libbb/libbb.la $(top_builddir)/libopkg/libopkg.la
++#opkg_hash_test_LDADD = $(top_builddir)/libbb/libbb.a $(top_builddir)/libopkg/libopkg.a
+ #opkg_hash_test_SOURCES = opkg_hash_test.c
+ #opkg_hash_test_CFLAGS = $(ALL_CFLAGS) -I$(top_srcdir)
+
+-#opkg_extract_test_LDADD = $(top_builddir)/libbb/libbb.la $(top_builddir)/libopkg/libopkg.la
++#opkg_extract_test_LDADD = $(top_builddir)/libbb/libbb.a $(top_builddir)/libopkg/libopkg.a
+ #opkg_extract_test_SOURCES = opkg_extract_test.c
+ #opkg_extract_test_CFLAGS = $(ALL_CFLAGS) -I$(top_srcdir)
+
+@@ -16,7 +16,7 @@ noinst_PROGRAMS = libopkg_test
+ #opkg_active_list_test_SOURCES = opkg_active_list_test.c
+ #opkg_active_list_test_CFLAGS = $(ALL_CFLAGS) -I$(top_srcdir)
+
+-libopkg_test_LDADD = $(top_builddir)/libopkg/libopkg.la
++libopkg_test_LDADD = $(top_builddir)/libopkg/libopkg.a $(top_builddir)/libbb/libbb.a
+ libopkg_test_SOURCE = libopkg_test.c
+ libopkg_test_LDFLAGS = -static
+
+--- a/src/Makefile.am
++++ b/src/Makefile.am
+@@ -2,5 +2,5 @@ AM_CFLAGS = -I${top_srcdir}/libopkg ${AL
+ bin_PROGRAMS = opkg-cl
+
+ opkg_cl_SOURCES = opkg-cl.c
+-opkg_cl_LDADD = $(top_builddir)/libopkg/libopkg.la \
+- $(top_builddir)/libbb/libbb.la
++opkg_cl_LDADD = $(top_builddir)/libopkg/libopkg.a \
++ $(top_builddir)/libbb/libbb.a
diff --git a/package/opkg/patches/.svn/text-base/009-remove-upgrade-all.patch.svn-base b/package/opkg/patches/.svn/text-base/009-remove-upgrade-all.patch.svn-base
new file mode 100644
index 0000000..395a2a6
--- /dev/null
+++ b/package/opkg/patches/.svn/text-base/009-remove-upgrade-all.patch.svn-base
@@ -0,0 +1,41 @@
+--- a/libopkg/opkg_cmd.c
++++ b/libopkg/opkg_cmd.c
+@@ -551,18 +551,6 @@ opkg_upgrade_cmd(int argc, char **argv)
+ err = -1;
+ }
+ }
+- } else {
+- pkg_vec_t *installed = pkg_vec_alloc();
+-
+- pkg_info_preinstall_check();
+-
+- pkg_hash_fetch_all_installed(installed);
+- for (i = 0; i < installed->len; i++) {
+- pkg = installed->pkgs[i];
+- if (opkg_upgrade_pkg(pkg))
+- err = -1;
+- }
+- pkg_vec_free(installed);
+ }
+
+ if (opkg_configure_packages(NULL))
+@@ -1258,7 +1246,7 @@ opkg_print_architecture_cmd(int argc, ch
+ array for easier maintenance */
+ static opkg_cmd_t cmds[] = {
+ {"update", 0, (opkg_cmd_fun_t)opkg_update_cmd, PFM_DESCRIPTION|PFM_SOURCE},
+- {"upgrade", 0, (opkg_cmd_fun_t)opkg_upgrade_cmd, PFM_DESCRIPTION|PFM_SOURCE},
++ {"upgrade", 1, (opkg_cmd_fun_t)opkg_upgrade_cmd, PFM_DESCRIPTION|PFM_SOURCE},
+ {"list", 0, (opkg_cmd_fun_t)opkg_list_cmd, PFM_SOURCE},
+ {"list_installed", 0, (opkg_cmd_fun_t)opkg_list_installed_cmd, PFM_SOURCE},
+ {"list-installed", 0, (opkg_cmd_fun_t)opkg_list_installed_cmd, PFM_SOURCE},
+--- a/src/opkg-cl.c
++++ b/src/opkg-cl.c
+@@ -221,7 +221,7 @@ usage()
+
+ printf("\nPackage Manipulation:\n");
+ printf("\tupdate Update list of available packages\n");
+- printf("\tupgrade Upgrade installed packages\n");
++ printf("\tupgrade <pkgs> Upgrade packages\n");
+ printf("\tinstall <pkgs> Install package(s)\n");
+ printf("\tconfigure <pkgs> Configure unpacked package(s)\n");
+ printf("\tremove <pkgs|regexp> Remove package(s)\n");
diff --git a/package/opkg/patches/.svn/text-base/011-old-config-location.patch.svn-base b/package/opkg/patches/.svn/text-base/011-old-config-location.patch.svn-base
new file mode 100644
index 0000000..0555926
--- /dev/null
+++ b/package/opkg/patches/.svn/text-base/011-old-config-location.patch.svn-base
@@ -0,0 +1,12 @@
+--- a/src/opkg-cl.c
++++ b/src/opkg-cl.c
+@@ -207,6 +207,9 @@ args_parse(int argc, char *argv[])
+ }
+ }
+
++ if(!conf->conf_file && !conf->offline_root)
++ conf->conf_file = xstrdup("/etc/opkg.conf");
++
+ if (parse_err)
+ return parse_err;
+ else
diff --git a/package/opkg/patches/.svn/text-base/012-strip-trailing-conffiles-whitespace.patch.svn-base b/package/opkg/patches/.svn/text-base/012-strip-trailing-conffiles-whitespace.patch.svn-base
new file mode 100644
index 0000000..a47ae77
--- /dev/null
+++ b/package/opkg/patches/.svn/text-base/012-strip-trailing-conffiles-whitespace.patch.svn-base
@@ -0,0 +1,23 @@
+--- a/libopkg/opkg_install.c
++++ b/libopkg/opkg_install.c
+@@ -274,6 +274,7 @@ unpack_pkg_control_files(pkg_t *pkg)
+ while (1) {
+ char *cf_name;
+ char *cf_name_in_dest;
++ int i;
+
+ cf_name = file_read_line_alloc(conffiles_file);
+ if (cf_name == NULL) {
+@@ -282,6 +283,12 @@ unpack_pkg_control_files(pkg_t *pkg)
+ if (cf_name[0] == '\0') {
+ continue;
+ }
++ for (i = strlen(cf_name) - 1;
++ (i >= 0) && (cf_name[i] == ' ' || cf_name[i] == '\t');
++ i--
++ ) {
++ cf_name[i] = '\0';
++ }
+
+ /* Prepend dest->root_dir to conffile name.
+ Take pains to avoid multiple slashes. */
diff --git a/package/opkg/patches/.svn/text-base/014-errors-to-stderr.patch.svn-base b/package/opkg/patches/.svn/text-base/014-errors-to-stderr.patch.svn-base
new file mode 100644
index 0000000..f0a93a8
--- /dev/null
+++ b/package/opkg/patches/.svn/text-base/014-errors-to-stderr.patch.svn-base
@@ -0,0 +1,15 @@
+--- a/libopkg/opkg_message.c
++++ b/libopkg/opkg_message.c
+@@ -64,10 +64,10 @@ print_error_list(void)
+ struct errlist *err = error_list_head;
+
+ if (err) {
+- printf("Collected errors:\n");
++ fprintf(stderr, "Collected errors:\n");
+ /* Here we print the errors collected and free the list */
+ while (err != NULL) {
+- printf(" * %s", err->errmsg);
++ fprintf(stderr, " * %s", err->errmsg);
+ err = err->next;
+ }
+ }
diff --git a/package/opkg/patches/.svn/text-base/020-avoid_getline.patch.svn-base b/package/opkg/patches/.svn/text-base/020-avoid_getline.patch.svn-base
new file mode 100644
index 0000000..8a1a8f6
--- /dev/null
+++ b/package/opkg/patches/.svn/text-base/020-avoid_getline.patch.svn-base
@@ -0,0 +1,317 @@
+--- a/libopkg/parse_util.c
++++ b/libopkg/parse_util.c
+@@ -22,6 +22,7 @@
+ #include "libbb/libbb.h"
+
+ #include "parse_util.h"
++#include "pkg_parse.h"
+
+ int
+ is_field(const char *type, const char *line)
+@@ -86,3 +87,84 @@ parse_list(const char *raw, unsigned int
+ *count = line_count;
+ return depends;
+ }
++
++int
++parse_from_stream_nomalloc(parse_line_t parse_line, void *item, FILE *fp, uint mask,
++ char **buf0, size_t buf0len)
++{
++ int ret, lineno;
++ char *buf, *nl;
++ size_t buflen;
++
++ lineno = 1;
++ ret = 0;
++
++ buflen = buf0len;
++ buf = *buf0;
++ buf[0] = '\0';
++
++ while (1) {
++ if (fgets(buf, (int)buflen, fp) == NULL) {
++ if (ferror(fp)) {
++ opkg_perror(ERROR, "fgets");
++ ret = -1;
++ } else if (strlen(*buf0) == buf0len-1) {
++ opkg_msg(ERROR, "Missing new line character"
++ " at end of file!\n");
++ parse_line(item, *buf0, mask);
++ }
++ break;
++ }
++
++ nl = strchr(buf, '\n');
++ if (nl == NULL) {
++ if (strlen(buf) < buflen-1) {
++ /*
++ * Line could be exactly buflen-1 long and
++ * missing a newline, but we won't know until
++ * fgets fails to read more data.
++ */
++ opkg_msg(ERROR, "Missing new line character"
++ " at end of file!\n");
++ parse_line(item, *buf0, mask);
++ break;
++ }
++ if (buf0len >= EXCESSIVE_LINE_LEN) {
++ opkg_msg(ERROR, "Excessively long line at "
++ "%d. Corrupt file?\n",
++ lineno);
++ ret = -1;
++ break;
++ }
++
++ /*
++ * Realloc and point buf past the data already read,
++ * at the NULL terminator inserted by fgets.
++ * |<--------------- buf0len ----------------->|
++ * | |<------- buflen ---->|
++ * |---------------------|---------------------|
++ * buf0 buf
++ */
++ buflen = buf0len +1;
++ buf0len *= 2;
++ *buf0 = xrealloc(*buf0, buf0len);
++ buf = *buf0 + buflen -2;
++
++ continue;
++ }
++
++ *nl = '\0';
++
++ lineno++;
++
++ if (parse_line(item, *buf0, mask))
++ break;
++
++ buf = *buf0;
++ buflen = buf0len;
++ buf[0] = '\0';
++ }
++
++ return ret;
++}
++
+--- a/libopkg/parse_util.h
++++ b/libopkg/parse_util.h
+@@ -22,4 +22,8 @@ int is_field(const char *type, const cha
+ char *parse_simple(const char *type, const char *line);
+ char **parse_list(const char *raw, unsigned int *count, const char sep, int skip_field);
+
++typedef int (*parse_line_t)(void *, const char *, uint);
++int parse_from_stream_nomalloc(parse_line_t parse_line, void *item, FILE *fp, uint mask,
++ char **buf0, size_t buf0len);
++
+ #endif
+--- a/libopkg/pkg_hash.c
++++ b/libopkg/pkg_hash.c
+@@ -23,6 +23,7 @@
+ #include "opkg_message.h"
+ #include "pkg_vec.h"
+ #include "pkg_hash.h"
++#include "parse_util.h"
+ #include "pkg_parse.h"
+ #include "opkg_utils.h"
+ #include "sprintf_alloc.h"
+@@ -119,8 +120,14 @@ pkg_hash_add_from_file(const char *file_
+ pkg->src = src;
+ pkg->dest = dest;
+
+- ret = pkg_parse_from_stream_nomalloc(pkg, fp, 0,
++ ret = parse_from_stream_nomalloc(pkg_parse_line, pkg, fp, 0,
+ &buf, len);
++
++ if (pkg->name == NULL) {
++ /* probably just a blank line */
++ ret = 1;
++ }
++
+ if (ret) {
+ pkg_deinit (pkg);
+ free(pkg);
+--- a/libopkg/pkg_parse.c
++++ b/libopkg/pkg_parse.c
+@@ -104,9 +104,11 @@ get_arch_priority(const char *arch)
+ return 0;
+ }
+
+-static int
+-pkg_parse_line(pkg_t *pkg, const char *line, uint mask)
++int
++pkg_parse_line(void *ptr, const char *line, uint mask)
+ {
++ pkg_t *pkg = (pkg_t *) ptr;
++
+ /* these flags are a bit hackish... */
+ static int reading_conffiles = 0, reading_description = 0;
+ int ret = 0;
+@@ -266,91 +268,6 @@ dont_reset_flags:
+ }
+
+ int
+-pkg_parse_from_stream_nomalloc(pkg_t *pkg, FILE *fp, uint mask,
+- char **buf0, size_t buf0len)
+-{
+- int ret, lineno;
+- char *buf, *nl;
+- size_t buflen;
+-
+- lineno = 1;
+- ret = 0;
+-
+- buflen = buf0len;
+- buf = *buf0;
+- buf[0] = '\0';
+-
+- while (1) {
+- if (fgets(buf, (int)buflen, fp) == NULL) {
+- if (ferror(fp)) {
+- opkg_perror(ERROR, "fgets");
+- ret = -1;
+- } else if (strlen(*buf0) == buf0len-1) {
+- opkg_msg(ERROR, "Missing new line character"
+- " at end of file!\n");
+- pkg_parse_line(pkg, *buf0, mask);
+- }
+- break;
+- }
+-
+- nl = strchr(buf, '\n');
+- if (nl == NULL) {
+- if (strlen(buf) < buflen-1) {
+- /*
+- * Line could be exactly buflen-1 long and
+- * missing a newline, but we won't know until
+- * fgets fails to read more data.
+- */
+- opkg_msg(ERROR, "Missing new line character"
+- " at end of file!\n");
+- pkg_parse_line(pkg, *buf0, mask);
+- break;
+- }
+- if (buf0len >= EXCESSIVE_LINE_LEN) {
+- opkg_msg(ERROR, "Excessively long line at "
+- "%d. Corrupt file?\n",
+- lineno);
+- ret = -1;
+- break;
+- }
+-
+- /*
+- * Realloc and point buf past the data already read,
+- * at the NULL terminator inserted by fgets.
+- * |<--------------- buf0len ----------------->|
+- * | |<------- buflen ---->|
+- * |---------------------|---------------------|
+- * buf0 buf
+- */
+- buflen = buf0len +1;
+- buf0len *= 2;
+- *buf0 = xrealloc(*buf0, buf0len);
+- buf = *buf0 + buflen -2;
+-
+- continue;
+- }
+-
+- *nl = '\0';
+-
+- lineno++;
+-
+- if (pkg_parse_line(pkg, *buf0, mask))
+- break;
+-
+- buf = *buf0;
+- buflen = buf0len;
+- buf[0] = '\0';
+- }
+-
+- if (pkg->name == NULL) {
+- /* probably just a blank line */
+- ret = 1;
+- }
+-
+- return ret;
+-}
+-
+-int
+ pkg_parse_from_stream(pkg_t *pkg, FILE *fp, uint mask)
+ {
+ int ret;
+@@ -358,8 +275,13 @@ pkg_parse_from_stream(pkg_t *pkg, FILE *
+ const size_t len = 4096;
+
+ buf = xmalloc(len);
+- ret = pkg_parse_from_stream_nomalloc(pkg, fp, mask, &buf, len);
++ ret = parse_from_stream_nomalloc(pkg_parse_line, pkg, fp, mask, &buf, len);
+ free(buf);
+
++ if (pkg->name == NULL) {
++ /* probably just a blank line */
++ ret = 1;
++ }
++
+ return ret;
+ }
+--- a/libopkg/pkg_parse.h
++++ b/libopkg/pkg_parse.h
+@@ -18,10 +18,11 @@
+ #ifndef PKG_PARSE_H
+ #define PKG_PARSE_H
+
++#include "pkg.h"
++
+ int parse_version(pkg_t *pkg, const char *raw);
+ int pkg_parse_from_stream(pkg_t *pkg, FILE *fp, uint mask);
+-int pkg_parse_from_stream_nomalloc(pkg_t *pkg, FILE *fp, uint mask,
+- char **buf0, size_t buf0len);
++int pkg_parse_line(void *ptr, const char *line, uint mask);
+
+ #define EXCESSIVE_LINE_LEN (4096 << 8)
+
+--- a/libopkg/release_parse.c
++++ b/libopkg/release_parse.c
+@@ -23,8 +23,10 @@
+ #include "parse_util.h"
+
+ static int
+-release_parse_line(release_t *release, const char *line)
++release_parse_line(void *ptr, const char *line, uint mask)
+ {
++ release_t *release = (release_t *) ptr;
++
+ int ret = 0;
+ unsigned int count = 0;
+ char **list = 0;
+@@ -111,25 +113,14 @@ dont_reset_flags:
+ int
+ release_parse_from_stream(release_t *release, FILE *fp)
+ {
+- int ret = 0;
+- char *buf = NULL;
+- size_t buflen, nread;
+-
+- nread = getline(&buf, &buflen, fp);
+- while ( nread != -1 ) {
+- if (buf[nread-1] == '\n') buf[nread-1] = '\0';
+- if (release_parse_line(release, buf))
+- opkg_msg(DEBUG, "Failed to parse release line for %s:\n\t%s\n",
+- release->name, buf);
+- nread = getline(&buf, &buflen, fp);
+- }
+-
+- if (!feof(fp)) {
+- opkg_perror(ERROR, "Problems reading Release file for %sd\n", release->name);
+- ret = -1;
+- }
++ int ret;
++ char *buf;
++ const size_t len = 4096;
+
++ buf = xmalloc(len);
++ ret = parse_from_stream_nomalloc(release_parse_line, release, fp, 0, &buf, len);
+ free(buf);
++
+ return ret;
+ }
+
diff --git a/package/opkg/patches/.svn/text-base/030-fix-double-free.patch.svn-base b/package/opkg/patches/.svn/text-base/030-fix-double-free.patch.svn-base
new file mode 100644
index 0000000..312e06c
--- /dev/null
+++ b/package/opkg/patches/.svn/text-base/030-fix-double-free.patch.svn-base
@@ -0,0 +1,10 @@
+--- a/libopkg/opkg_remove.c
++++ b/libopkg/opkg_remove.c
+@@ -138,7 +138,6 @@ opkg_remove_dependent_pkgs(pkg_t *pkg, a
+ for (i = 0; i < dependent_pkgs->len; i++) {
+ err = opkg_remove_pkg(dependent_pkgs->pkgs[i],0);
+ if (err) {
+- pkg_vec_free(dependent_pkgs);
+ break;
+ }
+ }
diff --git a/package/opkg/patches/.svn/text-base/040-wrap-descriptions-only-on-ttys.patch.svn-base b/package/opkg/patches/.svn/text-base/040-wrap-descriptions-only-on-ttys.patch.svn-base
new file mode 100644
index 0000000..9540668
--- /dev/null
+++ b/package/opkg/patches/.svn/text-base/040-wrap-descriptions-only-on-ttys.patch.svn-base
@@ -0,0 +1,31 @@
+--- a/libopkg/pkg_parse.c
++++ b/libopkg/pkg_parse.c
+@@ -20,6 +20,7 @@
+
+ #include <stdio.h>
+ #include <ctype.h>
++#include <unistd.h>
+
+ #include "pkg.h"
+ #include "opkg_utils.h"
+@@ -239,10 +240,16 @@ pkg_parse_line(void *ptr, const char *li
+
+ case ' ':
+ if ((mask & PFM_DESCRIPTION) && reading_description) {
+- pkg->description = xrealloc(pkg->description,
+- strlen(pkg->description)
+- + 1 + strlen(line) + 1);
+- strcat(pkg->description, "\n");
++ if (isatty(1)) {
++ pkg->description = xrealloc(pkg->description,
++ strlen(pkg->description)
++ + 1 + strlen(line) + 1);
++ strcat(pkg->description, "\n");
++ } else {
++ pkg->description = xrealloc(pkg->description,
++ strlen(pkg->description)
++ + 1 + strlen(line));
++ }
+ strcat(pkg->description, (line));
+ goto dont_reset_flags;
+ } else if ((mask & PFM_CONFFILES) && reading_conffiles) {
diff --git a/package/opkg/patches/.svn/text-base/050-add-case-insensitive-flag.patch.svn-base b/package/opkg/patches/.svn/text-base/050-add-case-insensitive-flag.patch.svn-base
new file mode 100644
index 0000000..4b9215b
--- /dev/null
+++ b/package/opkg/patches/.svn/text-base/050-add-case-insensitive-flag.patch.svn-base
@@ -0,0 +1,169 @@
+--- a/libopkg/opkg_cmd.c
++++ b/libopkg/opkg_cmd.c
+@@ -436,7 +436,7 @@ opkg_configure_packages(char *pkg_name)
+ for(i = 0; i < ordered->len; i++) {
+ pkg = ordered->pkgs[i];
+
+- if (pkg_name && fnmatch(pkg_name, pkg->name, 0))
++ if (pkg_name && fnmatch(pkg_name, pkg->name, conf->nocase))
+ continue;
+
+ if (pkg->state_status == SS_UNPACKED) {
+@@ -610,7 +610,7 @@ opkg_list_cmd(int argc, char **argv)
+ for (i=0; i < available->len; i++) {
+ pkg = available->pkgs[i];
+ /* if we have package name or pattern and pkg does not match, then skip it */
+- if (pkg_name && fnmatch(pkg_name, pkg->name, 0))
++ if (pkg_name && fnmatch(pkg_name, pkg->name, conf->nocase))
+ continue;
+ print_pkg(pkg);
+ }
+@@ -637,7 +637,7 @@ opkg_list_installed_cmd(int argc, char *
+ for (i=0; i < available->len; i++) {
+ pkg = available->pkgs[i];
+ /* if we have package name or pattern and pkg does not match, then skip it */
+- if (pkg_name && fnmatch(pkg_name, pkg->name, 0))
++ if (pkg_name && fnmatch(pkg_name, pkg->name, conf->nocase))
+ continue;
+ print_pkg(pkg);
+ }
+@@ -666,7 +666,7 @@ opkg_list_changed_conffiles_cmd(int argc
+ for (i=0; i < available->len; i++) {
+ pkg = available->pkgs[i];
+ /* if we have package name or pattern and pkg does not match, then skip it */
+- if (pkg_name && fnmatch(pkg_name, pkg->name, 0))
++ if (pkg_name && fnmatch(pkg_name, pkg->name, conf->nocase))
+ continue;
+ if (nv_pair_list_empty(&pkg->conffiles))
+ continue;
+@@ -722,7 +722,7 @@ opkg_info_status_cmd(int argc, char **ar
+
+ for (i=0; i < available->len; i++) {
+ pkg = available->pkgs[i];
+- if (pkg_name && fnmatch(pkg_name, pkg->name, 0)) {
++ if (pkg_name && fnmatch(pkg_name, pkg->name, conf->nocase)) {
+ continue;
+ }
+
+@@ -792,7 +792,7 @@ opkg_remove_cmd(int argc, char **argv)
+ for (i=0; i<argc; i++) {
+ for (a=0; a<available->len; a++) {
+ pkg = available->pkgs[a];
+- if (fnmatch(argv[i], pkg->name, 0)) {
++ if (fnmatch(argv[i], pkg->name, conf->nocase)) {
+ continue;
+ }
+ if (conf->restrict_to_default_dest) {
+@@ -926,7 +926,7 @@ opkg_depends_cmd(int argc, char **argv)
+ for (j=0; j<available_pkgs->len; j++) {
+ pkg = available_pkgs->pkgs[j];
+
+- if (fnmatch(argv[i], pkg->name, 0) != 0)
++ if (fnmatch(argv[i], pkg->name, conf->nocase) != 0)
+ continue;
+
+ depends_count = pkg->depends_count +
+@@ -1147,9 +1147,9 @@ opkg_what_provides_replaces_cmd(enum wha
+ ((what_field_type == WHATPROVIDES)
+ ? pkg->provides[k]
+ : pkg->replaces[k]);
+- if (fnmatch(target, apkg->name, 0) == 0) {
++ if (fnmatch(target, apkg->name, conf->nocase) == 0) {
+ opkg_msg(NOTICE, " %s", pkg->name);
+- if (strcmp(target, apkg->name) != 0)
++ if ((conf->nocase ? strcasecmp(target, apkg->name) : strcmp(target, apkg->name)) != 0)
+ opkg_msg(NOTICE, "\t%s %s\n",
+ rel_str, apkg->name);
+ opkg_message(NOTICE, "\n");
+@@ -1200,7 +1200,7 @@ opkg_search_cmd(int argc, char **argv)
+
+ for (iter = str_list_first(installed_files); iter; iter = str_list_next(installed_files, iter)) {
+ installed_file = (char *)iter->data;
+- if (fnmatch(argv[0], installed_file, 0)==0)
++ if (fnmatch(argv[0], installed_file, conf->nocase)==0)
+ print_pkg(pkg);
+ }
+
+--- a/libopkg/opkg_conf.c
++++ b/libopkg/opkg_conf.c
+@@ -62,6 +62,7 @@ opkg_option_t options[] = {
+ { "noaction", OPKG_OPT_TYPE_BOOL, &_conf.noaction },
+ { "download_only", OPKG_OPT_TYPE_BOOL, &_conf.download_only },
+ { "nodeps", OPKG_OPT_TYPE_BOOL, &_conf.nodeps },
++ { "nocase", OPKG_OPT_TYPE_BOOL, &_conf.nocase },
+ { "offline_root", OPKG_OPT_TYPE_STRING, &_conf.offline_root },
+ { "overlay_root", OPKG_OPT_TYPE_STRING, &_conf.overlay_root },
+ { "proxy_passwd", OPKG_OPT_TYPE_STRING, &_conf.proxy_passwd },
+--- a/libopkg/opkg_conf.h
++++ b/libopkg/opkg_conf.h
+@@ -24,6 +24,7 @@ extern opkg_conf_t *conf;
+ #include "config.h"
+
+ #include <stdarg.h>
++#include <fnmatch.h> /* FNM_CASEFOLD */
+
+ #include "hash_table.h"
+ #include "pkg_src_list.h"
+@@ -79,6 +80,7 @@ struct opkg_conf
+ int force_remove;
+ int check_signature;
+ int nodeps; /* do not follow dependencies */
++ int nocase; /* perform case insensitive matching */
+ char *offline_root;
+ char *overlay_root;
+ int query_all;
+--- a/src/opkg-cl.c
++++ b/src/opkg-cl.c
+@@ -47,6 +47,7 @@ enum {
+ ARGS_OPT_NOACTION,
+ ARGS_OPT_DOWNLOAD_ONLY,
+ ARGS_OPT_NODEPS,
++ ARGS_OPT_NOCASE,
+ ARGS_OPT_AUTOREMOVE,
+ ARGS_OPT_CACHE,
+ };
+@@ -86,6 +87,7 @@ static struct option long_options[] = {
+ {"noaction", 0, 0, ARGS_OPT_NOACTION},
+ {"download-only", 0, 0, ARGS_OPT_DOWNLOAD_ONLY},
+ {"nodeps", 0, 0, ARGS_OPT_NODEPS},
++ {"nocase", 0, 0, ARGS_OPT_NOCASE},
+ {"offline", 1, 0, 'o'},
+ {"offline-root", 1, 0, 'o'},
+ {"add-arch", 1, 0, ARGS_OPT_ADD_ARCH},
+@@ -107,7 +109,7 @@ args_parse(int argc, char *argv[])
+ char *tuple, *targ;
+
+ while (1) {
+- c = getopt_long_only(argc, argv, "Ad:f:no:p:t:vV::",
++ c = getopt_long_only(argc, argv, "Ad:f:ino:p:t:vV::",
+ long_options, &option_index);
+ if (c == -1)
+ break;
+@@ -122,6 +124,9 @@ args_parse(int argc, char *argv[])
+ case 'f':
+ conf->conf_file = xstrdup(optarg);
+ break;
++ case 'i':
++ conf->nocase = FNM_CASEFOLD;
++ break;
+ case 'o':
+ conf->offline_root = xstrdup(optarg);
+ break;
+@@ -176,6 +181,9 @@ args_parse(int argc, char *argv[])
+ case ARGS_OPT_NODEPS:
+ conf->nodeps = 1;
+ break;
++ case ARGS_OPT_NOCASE:
++ conf->nocase = FNM_CASEFOLD;
++ break;
+ case ARGS_OPT_ADD_ARCH:
+ case ARGS_OPT_ADD_DEST:
+ tuple = xstrdup(optarg);
+@@ -287,6 +295,7 @@ usage()
+ printf("\t--noaction No action -- test only\n");
+ printf("\t--download-only No action -- download only\n");
+ printf("\t--nodeps Do not follow dependencies\n");
++ printf("\t--nocase Perform case insensitive pattern matching\n");
+ printf("\t--force-removal-of-dependent-packages\n");
+ printf("\t Remove package and all dependencies\n");
+ printf("\t--autoremove Remove packages that were installed\n");
diff --git a/package/opkg/patches/.svn/text-base/060-add-find-command.patch.svn-base b/package/opkg/patches/.svn/text-base/060-add-find-command.patch.svn-base
new file mode 100644
index 0000000..1762534
--- /dev/null
+++ b/package/opkg/patches/.svn/text-base/060-add-find-command.patch.svn-base
@@ -0,0 +1,58 @@
+--- a/libopkg/opkg_cmd.c
++++ b/libopkg/opkg_cmd.c
+@@ -594,7 +594,7 @@ opkg_download_cmd(int argc, char **argv)
+
+
+ static int
+-opkg_list_cmd(int argc, char **argv)
++opkg_list_find_cmd(int argc, char **argv, int use_desc)
+ {
+ int i;
+ pkg_vec_t *available;
+@@ -610,7 +610,8 @@ opkg_list_cmd(int argc, char **argv)
+ for (i=0; i < available->len; i++) {
+ pkg = available->pkgs[i];
+ /* if we have package name or pattern and pkg does not match, then skip it */
+- if (pkg_name && fnmatch(pkg_name, pkg->name, conf->nocase))
++ if (pkg_name && fnmatch(pkg_name, pkg->name, conf->nocase) &&
++ (!use_desc || !pkg->description || fnmatch(pkg_name, pkg->description, conf->nocase)))
+ continue;
+ print_pkg(pkg);
+ }
+@@ -619,6 +620,18 @@ opkg_list_cmd(int argc, char **argv)
+ return 0;
+ }
+
++static int
++opkg_list_cmd(int argc, char **argv)
++{
++ return opkg_list_find_cmd(argc, argv, 0);
++}
++
++static int
++opkg_find_cmd(int argc, char **argv)
++{
++ return opkg_list_find_cmd(argc, argv, 1);
++}
++
+
+ static int
+ opkg_list_installed_cmd(int argc, char **argv)
+@@ -1262,6 +1275,7 @@ static opkg_cmd_t cmds[] = {
+ {"configure", 0, (opkg_cmd_fun_t)opkg_configure_cmd, PFM_DESCRIPTION|PFM_SOURCE},
+ {"files", 1, (opkg_cmd_fun_t)opkg_files_cmd, PFM_DESCRIPTION|PFM_SOURCE},
+ {"search", 1, (opkg_cmd_fun_t)opkg_search_cmd, PFM_DESCRIPTION|PFM_SOURCE},
++ {"find", 1, (opkg_cmd_fun_t)opkg_find_cmd, PFM_SOURCE},
+ {"download", 1, (opkg_cmd_fun_t)opkg_download_cmd, PFM_DESCRIPTION|PFM_SOURCE},
+ {"compare_versions", 1, (opkg_cmd_fun_t)opkg_compare_versions_cmd, PFM_DESCRIPTION|PFM_SOURCE},
+ {"compare-versions", 1, (opkg_cmd_fun_t)opkg_compare_versions_cmd, PFM_DESCRIPTION|PFM_SOURCE},
+--- a/src/opkg-cl.c
++++ b/src/opkg-cl.c
+@@ -246,6 +246,7 @@ usage()
+ printf("\tlist-changed-conffiles List user modified configuration files\n");
+ printf("\tfiles <pkg> List files belonging to <pkg>\n");
+ printf("\tsearch <file|regexp> List package providing <file>\n");
++ printf("\tfind <regexp> List packages whose name or description matches <regexp>\n");
+ printf("\tinfo [pkg|regexp] Display all info for <pkg>\n");
+ printf("\tstatus [pkg|regexp] Display all status for <pkg>\n");
+ printf("\tdownload <pkg> Download <pkg> to current directory\n");
diff --git a/package/opkg/patches/.svn/text-base/070-use_gzipped_pkg_list.patch.svn-base b/package/opkg/patches/.svn/text-base/070-use_gzipped_pkg_list.patch.svn-base
new file mode 100644
index 0000000..d32b519
--- /dev/null
+++ b/package/opkg/patches/.svn/text-base/070-use_gzipped_pkg_list.patch.svn-base
@@ -0,0 +1,120 @@
+--- a/libopkg/opkg.c
++++ b/libopkg/opkg.c
+@@ -592,49 +592,8 @@ opkg_update_package_lists(opkg_progress_
+ src->gzip ? "Packages.gz" : "Packages");
+
+ sprintf_alloc(&list_file_name, "%s/%s", lists_dir, src->name);
+- if (src->gzip) {
+- FILE *in, *out;
+- struct _curl_cb_data cb_data;
+- char *tmp_file_name = NULL;
+
+- sprintf_alloc(&tmp_file_name, "%s/%s.gz", tmp,
+- src->name);
+-
+- opkg_msg(INFO, "Downloading %s to %s...\n", url,
+- tmp_file_name);
+-
+- cb_data.cb = progress_callback;
+- cb_data.progress_data = &pdata;
+- cb_data.user_data = user_data;
+- cb_data.start_range =
+- 100 * sources_done / sources_list_count;
+- cb_data.finish_range =
+- 100 * (sources_done + 1) / sources_list_count;
+-
+- err = opkg_download(url, tmp_file_name,
+- (curl_progress_func) curl_progress_cb,
+- &cb_data, 0);
+-
+- if (err == 0) {
+- opkg_msg(INFO, "Inflating %s...\n",
+- tmp_file_name);
+- in = fopen(tmp_file_name, "r");
+- out = fopen(list_file_name, "w");
+- if (in && out)
+- unzip(in, out);
+- else
+- err = 1;
+- if (in)
+- fclose(in);
+- if (out)
+- fclose(out);
+- unlink(tmp_file_name);
+- }
+- free(tmp_file_name);
+- } else
+- err = opkg_download(url, list_file_name, NULL, NULL, 0);
+-
+- if (err) {
++ if (opkg_download(url, list_file_name, NULL, NULL, 0)) {
+ opkg_msg(ERROR, "Couldn't retrieve %s\n", url);
+ result = -1;
+ }
+--- a/libopkg/opkg_cmd.c
++++ b/libopkg/opkg_cmd.c
+@@ -162,30 +162,7 @@ opkg_update_cmd(int argc, char **argv)
+ sprintf_alloc(&url, "%s/%s", src->value, src->gzip ? "Packages.gz" : "Packages");
+
+ sprintf_alloc(&list_file_name, "%s/%s", lists_dir, src->name);
+- if (src->gzip) {
+- char *tmp_file_name;
+- FILE *in, *out;
+-
+- sprintf_alloc (&tmp_file_name, "%s/%s.gz", tmp, src->name);
+- err = opkg_download(url, tmp_file_name, NULL, NULL, 0);
+- if (err == 0) {
+- opkg_msg(NOTICE, "Inflating %s.\n", url);
+- in = fopen (tmp_file_name, "r");
+- out = fopen (list_file_name, "w");
+- if (in && out)
+- unzip (in, out);
+- else
+- err = 1;
+- if (in)
+- fclose (in);
+- if (out)
+- fclose (out);
+- unlink (tmp_file_name);
+- }
+- free(tmp_file_name);
+- } else
+- err = opkg_download(url, list_file_name, NULL, NULL, 0);
+- if (err) {
++ if (opkg_download(url, list_file_name, NULL, NULL, 0)) {
+ failures++;
+ } else {
+ opkg_msg(NOTICE, "Updated list of available packages in %s.\n",
+--- a/libopkg/pkg_hash.c
++++ b/libopkg/pkg_hash.c
+@@ -102,12 +102,18 @@ pkg_hash_add_from_file(const char *file_
+ pkg_src_t *src, pkg_dest_t *dest, int is_status_file)
+ {
+ pkg_t *pkg;
+- FILE *fp;
++ FILE *fp, *fp_c = NULL;
+ char *buf;
+ const size_t len = 4096;
+ int ret = 0;
++ int pid;
+
+ fp = fopen(file_name, "r");
++ if (fp && src && src->gzip) {
++ fp_c = fp;
++ fp = gz_open(fp_c, &pid);
++ }
++
+ if (fp == NULL) {
+ opkg_perror(ERROR, "Failed to open %s", file_name);
+ return -1;
+@@ -154,6 +160,10 @@ pkg_hash_add_from_file(const char *file_
+
+ free(buf);
+ fclose(fp);
++ if (fp_c) {
++ fclose(fp_c);
++ gz_close(pid);
++ }
+
+ return ret;
+ }
diff --git a/package/opkg/patches/001-ship-pkg-m4.patch b/package/opkg/patches/001-ship-pkg-m4.patch
new file mode 100644
index 0000000..4ca0f88
--- /dev/null
+++ b/package/opkg/patches/001-ship-pkg-m4.patch
@@ -0,0 +1,168 @@
+--- /dev/null
++++ b/m4/pkg.m4
+@@ -0,0 +1,157 @@
++# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
++#
++# Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
++#
++# 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 of the License, 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; if not, write to the Free Software
++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
++#
++# As a special exception to the GNU General Public License, if you
++# distribute this file as part of a program that contains a
++# configuration script generated by Autoconf, you may include it under
++# the same distribution terms that you use for the rest of that program.
++
++# PKG_PROG_PKG_CONFIG([MIN-VERSION])
++# ----------------------------------
++AC_DEFUN([PKG_PROG_PKG_CONFIG],
++[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
++m4_pattern_allow([^PKG_CONFIG(_PATH)?$])
++AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])dnl
++if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
++ AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
++fi
++if test -n "$PKG_CONFIG"; then
++ _pkg_min_version=m4_default([$1], [0.9.0])
++ AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
++ if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
++ AC_MSG_RESULT([yes])
++ else
++ AC_MSG_RESULT([no])
++ PKG_CONFIG=""
++ fi
++
++fi[]dnl
++])# PKG_PROG_PKG_CONFIG
++
++# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
++#
++# Check to see whether a particular set of modules exists. Similar
++# to PKG_CHECK_MODULES(), but does not set variables or print errors.
++#
++#
++# Similar to PKG_CHECK_MODULES, make sure that the first instance of
++# this or PKG_CHECK_MODULES is called, or make sure to call
++# PKG_CHECK_EXISTS manually
++# --------------------------------------------------------------
++AC_DEFUN([PKG_CHECK_EXISTS],
++[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
++if test -n "$PKG_CONFIG" && \
++ AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
++ m4_ifval([$2], [$2], [:])
++m4_ifvaln([$3], [else
++ $3])dnl
++fi])
++
++
++# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
++# ---------------------------------------------
++m4_define([_PKG_CONFIG],
++[if test -n "$PKG_CONFIG"; then
++ if test -n "$$1"; then
++ pkg_cv_[]$1="$$1"
++ else
++ PKG_CHECK_EXISTS([$3],
++ [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`],
++ [pkg_failed=yes])
++ fi
++else
++ pkg_failed=untried
++fi[]dnl
++])# _PKG_CONFIG
++
++# _PKG_SHORT_ERRORS_SUPPORTED
++# -----------------------------
++AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
++[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
++if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
++ _pkg_short_errors_supported=yes
++else
++ _pkg_short_errors_supported=no
++fi[]dnl
++])# _PKG_SHORT_ERRORS_SUPPORTED
++
++
++# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
++# [ACTION-IF-NOT-FOUND])
++#
++#
++# Note that if there is a possibility the first call to
++# PKG_CHECK_MODULES might not happen, you should be sure to include an
++# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
++#
++#
++# --------------------------------------------------------------
++AC_DEFUN([PKG_CHECK_MODULES],
++[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
++AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
++AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
++
++pkg_failed=no
++AC_MSG_CHECKING([for $1])
++
++_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
++_PKG_CONFIG([$1][_LIBS], [libs], [$2])
++
++m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
++and $1[]_LIBS to avoid the need to call pkg-config.
++See the pkg-config man page for more details.])
++
++if test $pkg_failed = yes; then
++ _PKG_SHORT_ERRORS_SUPPORTED
++ if test $_pkg_short_errors_supported = yes; then
++ $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "$2"`
++ else
++ $1[]_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"`
++ fi
++ # Put the nasty error message in config.log where it belongs
++ echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
++
++ ifelse([$4], , [AC_MSG_ERROR(dnl
++[Package requirements ($2) were not met:
++
++$$1_PKG_ERRORS
++
++Consider adjusting the PKG_CONFIG_PATH environment variable if you
++installed software in a non-standard prefix.
++
++_PKG_TEXT
++])],
++ [AC_MSG_RESULT([no])
++ $4])
++elif test $pkg_failed = untried; then
++ ifelse([$4], , [AC_MSG_FAILURE(dnl
++[The pkg-config script could not be found or is too old. Make sure it
++is in your PATH or set the PKG_CONFIG environment variable to the full
++path to pkg-config.
++
++_PKG_TEXT
++
++To get pkg-config, see <http://pkg-config.freedesktop.org/>.])],
++ [$4])
++else
++ $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
++ $1[]_LIBS=$pkg_cv_[]$1[]_LIBS
++ AC_MSG_RESULT([yes])
++ ifelse([$3], , :, [$3])
++fi[]dnl
++])# PKG_CHECK_MODULES
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -1,4 +1,4 @@
+-ACLOCAL_AMFLAGS = -I shave
++ACLOCAL_AMFLAGS = -I shave -I m4
+
+ SUBDIRS = libbb libopkg src tests utils man
+
diff --git a/package/opkg/patches/002-no-shave.patch b/package/opkg/patches/002-no-shave.patch
new file mode 100644
index 0000000..313aa71
--- /dev/null
+++ b/package/opkg/patches/002-no-shave.patch
@@ -0,0 +1,37 @@
+--- a/configure.ac
++++ b/configure.ac
+@@ -4,7 +4,6 @@ AC_CONFIG_SRCDIR([libopkg/pkg.c])
+
+ AC_CONFIG_AUX_DIR([conf])
+ AC_CONFIG_MACRO_DIR([m4])
+-AC_CONFIG_MACRO_DIR([shave])
+
+ AM_INIT_AUTOMAKE
+ AM_CONFIG_HEADER(libopkg/config.h)
+@@ -277,9 +276,6 @@ AC_SUBST(opkgetcdir)
+ AC_SUBST(opkglockfile)
+ AC_SUBST([CLEAN_DATE])
+
+-# Setup output beautifier.
+-SHAVE_INIT([shave], [enable])
+-
+ AC_OUTPUT(
+ Makefile
+ libopkg/Makefile
+@@ -289,8 +285,6 @@ AC_OUTPUT(
+ utils/Makefile
+ utils/update-alternatives
+ libopkg.pc
+- shave/shave
+- shave/shave-libtool
+ man/Makefile
+ man/opkg-cl.1
+ man/opkg-key.1
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -1,4 +1,4 @@
+-ACLOCAL_AMFLAGS = -I shave -I m4
++ACLOCAL_AMFLAGS = -I m4
+
+ SUBDIRS = libbb libopkg src tests utils man
+
diff --git a/package/opkg/patches/004-host_cpu.patch b/package/opkg/patches/004-host_cpu.patch
new file mode 100644
index 0000000..d500d60
--- /dev/null
+++ b/package/opkg/patches/004-host_cpu.patch
@@ -0,0 +1,20 @@
+--- a/libbb/Makefile.am
++++ b/libbb/Makefile.am
+@@ -1,6 +1,6 @@
+ HOST_CPU=@host_cpu@
+ BUILD_CPU=@build_cpu@
+-ALL_CFLAGS=-g -O -Wall -DHOST_CPU_STR=\"@host_cpu@\" -DBUILD_CPU=@build_cpu@
++ALL_CFLAGS=-g -O -Wall -DHOST_CPU_STR=\"$(HOST_CPU)\" -DBUILD_CPU=@build_cpu@
+
+ noinst_LTLIBRARIES = libbb.la
+
+--- a/libopkg/Makefile.am
++++ b/libopkg/Makefile.am
+@@ -1,5 +1,5 @@
+-
+-AM_CFLAGS=-Wall -DHOST_CPU_STR=\"@host_cpu@\" -DBUILD_CPU=@build_cpu@ -DLIBDIR=\"@libdir@\" -DOPKGLIBDIR=\"@opkglibdir@\" -DOPKGETCDIR=\"@opkgetcdir@\" -DOPKGLOCKFILE=\"@opkglockfile@\" -DDATADIR=\"@datadir@\" -I$(top_srcdir) $(BIGENDIAN_CFLAGS) $(CURL_CFLAGS) $(GPGME_CFLAGS) $(PATHFINDER_CFLAGS)
++HOST_CPU=@host_cpu@
++AM_CFLAGS=-Wall -DHOST_CPU_STR=\"$(HOST_CPU)\" -DBUILD_CPU=@build_cpu@ -DLIBDIR=\"@libdir@\" -DOPKGLIBDIR=\"@opkglibdir@\" -DOPKGETCDIR=\"@opkgetcdir@\" -DOPKGLOCKFILE=\"@opkglockfile@\" -DDATADIR=\"@datadir@\" -I$(top_srcdir) $(BIGENDIAN_CFLAGS) $(CURL_CFLAGS) $(GPGME_CFLAGS) $(PATHFINDER_CFLAGS)
+
+ libopkg_includedir=$(includedir)/libopkg
+ libopkg_include_HEADERS= *.h
diff --git a/package/opkg/patches/007-force_static.patch b/package/opkg/patches/007-force_static.patch
new file mode 100644
index 0000000..80a9815
--- /dev/null
+++ b/package/opkg/patches/007-force_static.patch
@@ -0,0 +1,71 @@
+--- a/libopkg/Makefile.am
++++ b/libopkg/Makefile.am
+@@ -38,16 +38,10 @@ if HAVE_SHA256
+ opkg_util_sources += sha256.c sha256.h
+ endif
+
+-lib_LTLIBRARIES = libopkg.la
+-libopkg_la_SOURCES = \
++noinst_LIBRARIES = libopkg.a
++libopkg_a_SOURCES = \
+ $(opkg_libcore_sources) \
+ $(opkg_cmd_sources) $(opkg_db_sources) \
+ $(opkg_util_sources) $(opkg_list_sources)
+
+-libopkg_la_LIBADD = $(top_builddir)/libbb/libbb.la $(CURL_LIBS) $(GPGME_LIBS) $(OPENSSL_LIBS) $(PATHFINDER_LIBS)
+-
+-# make sure we only export symbols that are for public use
+-#libopkg_la_LDFLAGS = -export-symbols-regex "^opkg_.*"
+-
+-
+-
++libopkg_a_LIBADD = $(top_builddir)/libbb/libbb.a $(CURL_LIBS) $(GPGME_LIBS) $(OPENSSL_LIBS) $(PATHFINDER_LIBS)
+--- a/libbb/Makefile.am
++++ b/libbb/Makefile.am
+@@ -2,9 +2,9 @@ HOST_CPU=@host_cpu@
+ BUILD_CPU=@build_cpu@
+ ALL_CFLAGS=-g -O -Wall -DHOST_CPU_STR=\"$(HOST_CPU)\" -DBUILD_CPU=@build_cpu@
+
+-noinst_LTLIBRARIES = libbb.la
++noinst_LIBRARIES = libbb.a
+
+-libbb_la_SOURCES = gz_open.c \
++libbb_a_SOURCES = gz_open.c \
+ libbb.h \
+ unzip.c \
+ wfopen.c \
+--- a/tests/Makefile.am
++++ b/tests/Makefile.am
+@@ -4,11 +4,11 @@ AM_CFLAGS = $(ALL_CFLAGS) -Wall -g -O3 -
+ #noinst_PROGRAMS = libopkg_test opkg_active_list_test
+ noinst_PROGRAMS = libopkg_test
+
+-#opkg_hash_test_LDADD = $(top_builddir)/libbb/libbb.la $(top_builddir)/libopkg/libopkg.la
++#opkg_hash_test_LDADD = $(top_builddir)/libbb/libbb.a $(top_builddir)/libopkg/libopkg.a
+ #opkg_hash_test_SOURCES = opkg_hash_test.c
+ #opkg_hash_test_CFLAGS = $(ALL_CFLAGS) -I$(top_srcdir)
+
+-#opkg_extract_test_LDADD = $(top_builddir)/libbb/libbb.la $(top_builddir)/libopkg/libopkg.la
++#opkg_extract_test_LDADD = $(top_builddir)/libbb/libbb.a $(top_builddir)/libopkg/libopkg.a
+ #opkg_extract_test_SOURCES = opkg_extract_test.c
+ #opkg_extract_test_CFLAGS = $(ALL_CFLAGS) -I$(top_srcdir)
+
+@@ -16,7 +16,7 @@ noinst_PROGRAMS = libopkg_test
+ #opkg_active_list_test_SOURCES = opkg_active_list_test.c
+ #opkg_active_list_test_CFLAGS = $(ALL_CFLAGS) -I$(top_srcdir)
+
+-libopkg_test_LDADD = $(top_builddir)/libopkg/libopkg.la
++libopkg_test_LDADD = $(top_builddir)/libopkg/libopkg.a $(top_builddir)/libbb/libbb.a
+ libopkg_test_SOURCE = libopkg_test.c
+ libopkg_test_LDFLAGS = -static
+
+--- a/src/Makefile.am
++++ b/src/Makefile.am
+@@ -2,5 +2,5 @@ AM_CFLAGS = -I${top_srcdir}/libopkg ${AL
+ bin_PROGRAMS = opkg-cl
+
+ opkg_cl_SOURCES = opkg-cl.c
+-opkg_cl_LDADD = $(top_builddir)/libopkg/libopkg.la \
+- $(top_builddir)/libbb/libbb.la
++opkg_cl_LDADD = $(top_builddir)/libopkg/libopkg.a \
++ $(top_builddir)/libbb/libbb.a
diff --git a/package/opkg/patches/009-remove-upgrade-all.patch b/package/opkg/patches/009-remove-upgrade-all.patch
new file mode 100644
index 0000000..395a2a6
--- /dev/null
+++ b/package/opkg/patches/009-remove-upgrade-all.patch
@@ -0,0 +1,41 @@
+--- a/libopkg/opkg_cmd.c
++++ b/libopkg/opkg_cmd.c
+@@ -551,18 +551,6 @@ opkg_upgrade_cmd(int argc, char **argv)
+ err = -1;
+ }
+ }
+- } else {
+- pkg_vec_t *installed = pkg_vec_alloc();
+-
+- pkg_info_preinstall_check();
+-
+- pkg_hash_fetch_all_installed(installed);
+- for (i = 0; i < installed->len; i++) {
+- pkg = installed->pkgs[i];
+- if (opkg_upgrade_pkg(pkg))
+- err = -1;
+- }
+- pkg_vec_free(installed);
+ }
+
+ if (opkg_configure_packages(NULL))
+@@ -1258,7 +1246,7 @@ opkg_print_architecture_cmd(int argc, ch
+ array for easier maintenance */
+ static opkg_cmd_t cmds[] = {
+ {"update", 0, (opkg_cmd_fun_t)opkg_update_cmd, PFM_DESCRIPTION|PFM_SOURCE},
+- {"upgrade", 0, (opkg_cmd_fun_t)opkg_upgrade_cmd, PFM_DESCRIPTION|PFM_SOURCE},
++ {"upgrade", 1, (opkg_cmd_fun_t)opkg_upgrade_cmd, PFM_DESCRIPTION|PFM_SOURCE},
+ {"list", 0, (opkg_cmd_fun_t)opkg_list_cmd, PFM_SOURCE},
+ {"list_installed", 0, (opkg_cmd_fun_t)opkg_list_installed_cmd, PFM_SOURCE},
+ {"list-installed", 0, (opkg_cmd_fun_t)opkg_list_installed_cmd, PFM_SOURCE},
+--- a/src/opkg-cl.c
++++ b/src/opkg-cl.c
+@@ -221,7 +221,7 @@ usage()
+
+ printf("\nPackage Manipulation:\n");
+ printf("\tupdate Update list of available packages\n");
+- printf("\tupgrade Upgrade installed packages\n");
++ printf("\tupgrade <pkgs> Upgrade packages\n");
+ printf("\tinstall <pkgs> Install package(s)\n");
+ printf("\tconfigure <pkgs> Configure unpacked package(s)\n");
+ printf("\tremove <pkgs|regexp> Remove package(s)\n");
diff --git a/package/opkg/patches/011-old-config-location.patch b/package/opkg/patches/011-old-config-location.patch
new file mode 100644
index 0000000..0555926
--- /dev/null
+++ b/package/opkg/patches/011-old-config-location.patch
@@ -0,0 +1,12 @@
+--- a/src/opkg-cl.c
++++ b/src/opkg-cl.c
+@@ -207,6 +207,9 @@ args_parse(int argc, char *argv[])
+ }
+ }
+
++ if(!conf->conf_file && !conf->offline_root)
++ conf->conf_file = xstrdup("/etc/opkg.conf");
++
+ if (parse_err)
+ return parse_err;
+ else
diff --git a/package/opkg/patches/012-strip-trailing-conffiles-whitespace.patch b/package/opkg/patches/012-strip-trailing-conffiles-whitespace.patch
new file mode 100644
index 0000000..a47ae77
--- /dev/null
+++ b/package/opkg/patches/012-strip-trailing-conffiles-whitespace.patch
@@ -0,0 +1,23 @@
+--- a/libopkg/opkg_install.c
++++ b/libopkg/opkg_install.c
+@@ -274,6 +274,7 @@ unpack_pkg_control_files(pkg_t *pkg)
+ while (1) {
+ char *cf_name;
+ char *cf_name_in_dest;
++ int i;
+
+ cf_name = file_read_line_alloc(conffiles_file);
+ if (cf_name == NULL) {
+@@ -282,6 +283,12 @@ unpack_pkg_control_files(pkg_t *pkg)
+ if (cf_name[0] == '\0') {
+ continue;
+ }
++ for (i = strlen(cf_name) - 1;
++ (i >= 0) && (cf_name[i] == ' ' || cf_name[i] == '\t');
++ i--
++ ) {
++ cf_name[i] = '\0';
++ }
+
+ /* Prepend dest->root_dir to conffile name.
+ Take pains to avoid multiple slashes. */
diff --git a/package/opkg/patches/014-errors-to-stderr.patch b/package/opkg/patches/014-errors-to-stderr.patch
new file mode 100644
index 0000000..f0a93a8
--- /dev/null
+++ b/package/opkg/patches/014-errors-to-stderr.patch
@@ -0,0 +1,15 @@
+--- a/libopkg/opkg_message.c
++++ b/libopkg/opkg_message.c
+@@ -64,10 +64,10 @@ print_error_list(void)
+ struct errlist *err = error_list_head;
+
+ if (err) {
+- printf("Collected errors:\n");
++ fprintf(stderr, "Collected errors:\n");
+ /* Here we print the errors collected and free the list */
+ while (err != NULL) {
+- printf(" * %s", err->errmsg);
++ fprintf(stderr, " * %s", err->errmsg);
+ err = err->next;
+ }
+ }
diff --git a/package/opkg/patches/020-avoid_getline.patch b/package/opkg/patches/020-avoid_getline.patch
new file mode 100644
index 0000000..8a1a8f6
--- /dev/null
+++ b/package/opkg/patches/020-avoid_getline.patch
@@ -0,0 +1,317 @@
+--- a/libopkg/parse_util.c
++++ b/libopkg/parse_util.c
+@@ -22,6 +22,7 @@
+ #include "libbb/libbb.h"
+
+ #include "parse_util.h"
++#include "pkg_parse.h"
+
+ int
+ is_field(const char *type, const char *line)
+@@ -86,3 +87,84 @@ parse_list(const char *raw, unsigned int
+ *count = line_count;
+ return depends;
+ }
++
++int
++parse_from_stream_nomalloc(parse_line_t parse_line, void *item, FILE *fp, uint mask,
++ char **buf0, size_t buf0len)
++{
++ int ret, lineno;
++ char *buf, *nl;
++ size_t buflen;
++
++ lineno = 1;
++ ret = 0;
++
++ buflen = buf0len;
++ buf = *buf0;
++ buf[0] = '\0';
++
++ while (1) {
++ if (fgets(buf, (int)buflen, fp) == NULL) {
++ if (ferror(fp)) {
++ opkg_perror(ERROR, "fgets");
++ ret = -1;
++ } else if (strlen(*buf0) == buf0len-1) {
++ opkg_msg(ERROR, "Missing new line character"
++ " at end of file!\n");
++ parse_line(item, *buf0, mask);
++ }
++ break;
++ }
++
++ nl = strchr(buf, '\n');
++ if (nl == NULL) {
++ if (strlen(buf) < buflen-1) {
++ /*
++ * Line could be exactly buflen-1 long and
++ * missing a newline, but we won't know until
++ * fgets fails to read more data.
++ */
++ opkg_msg(ERROR, "Missing new line character"
++ " at end of file!\n");
++ parse_line(item, *buf0, mask);
++ break;
++ }
++ if (buf0len >= EXCESSIVE_LINE_LEN) {
++ opkg_msg(ERROR, "Excessively long line at "
++ "%d. Corrupt file?\n",
++ lineno);
++ ret = -1;
++ break;
++ }
++
++ /*
++ * Realloc and point buf past the data already read,
++ * at the NULL terminator inserted by fgets.
++ * |<--------------- buf0len ----------------->|
++ * | |<------- buflen ---->|
++ * |---------------------|---------------------|
++ * buf0 buf
++ */
++ buflen = buf0len +1;
++ buf0len *= 2;
++ *buf0 = xrealloc(*buf0, buf0len);
++ buf = *buf0 + buflen -2;
++
++ continue;
++ }
++
++ *nl = '\0';
++
++ lineno++;
++
++ if (parse_line(item, *buf0, mask))
++ break;
++
++ buf = *buf0;
++ buflen = buf0len;
++ buf[0] = '\0';
++ }
++
++ return ret;
++}
++
+--- a/libopkg/parse_util.h
++++ b/libopkg/parse_util.h
+@@ -22,4 +22,8 @@ int is_field(const char *type, const cha
+ char *parse_simple(const char *type, const char *line);
+ char **parse_list(const char *raw, unsigned int *count, const char sep, int skip_field);
+
++typedef int (*parse_line_t)(void *, const char *, uint);
++int parse_from_stream_nomalloc(parse_line_t parse_line, void *item, FILE *fp, uint mask,
++ char **buf0, size_t buf0len);
++
+ #endif
+--- a/libopkg/pkg_hash.c
++++ b/libopkg/pkg_hash.c
+@@ -23,6 +23,7 @@
+ #include "opkg_message.h"
+ #include "pkg_vec.h"
+ #include "pkg_hash.h"
++#include "parse_util.h"
+ #include "pkg_parse.h"
+ #include "opkg_utils.h"
+ #include "sprintf_alloc.h"
+@@ -119,8 +120,14 @@ pkg_hash_add_from_file(const char *file_
+ pkg->src = src;
+ pkg->dest = dest;
+
+- ret = pkg_parse_from_stream_nomalloc(pkg, fp, 0,
++ ret = parse_from_stream_nomalloc(pkg_parse_line, pkg, fp, 0,
+ &buf, len);
++
++ if (pkg->name == NULL) {
++ /* probably just a blank line */
++ ret = 1;
++ }
++
+ if (ret) {
+ pkg_deinit (pkg);
+ free(pkg);
+--- a/libopkg/pkg_parse.c
++++ b/libopkg/pkg_parse.c
+@@ -104,9 +104,11 @@ get_arch_priority(const char *arch)
+ return 0;
+ }
+
+-static int
+-pkg_parse_line(pkg_t *pkg, const char *line, uint mask)
++int
++pkg_parse_line(void *ptr, const char *line, uint mask)
+ {
++ pkg_t *pkg = (pkg_t *) ptr;
++
+ /* these flags are a bit hackish... */
+ static int reading_conffiles = 0, reading_description = 0;
+ int ret = 0;
+@@ -266,91 +268,6 @@ dont_reset_flags:
+ }
+
+ int
+-pkg_parse_from_stream_nomalloc(pkg_t *pkg, FILE *fp, uint mask,
+- char **buf0, size_t buf0len)
+-{
+- int ret, lineno;
+- char *buf, *nl;
+- size_t buflen;
+-
+- lineno = 1;
+- ret = 0;
+-
+- buflen = buf0len;
+- buf = *buf0;
+- buf[0] = '\0';
+-
+- while (1) {
+- if (fgets(buf, (int)buflen, fp) == NULL) {
+- if (ferror(fp)) {
+- opkg_perror(ERROR, "fgets");
+- ret = -1;
+- } else if (strlen(*buf0) == buf0len-1) {
+- opkg_msg(ERROR, "Missing new line character"
+- " at end of file!\n");
+- pkg_parse_line(pkg, *buf0, mask);
+- }
+- break;
+- }
+-
+- nl = strchr(buf, '\n');
+- if (nl == NULL) {
+- if (strlen(buf) < buflen-1) {
+- /*
+- * Line could be exactly buflen-1 long and
+- * missing a newline, but we won't know until
+- * fgets fails to read more data.
+- */
+- opkg_msg(ERROR, "Missing new line character"
+- " at end of file!\n");
+- pkg_parse_line(pkg, *buf0, mask);
+- break;
+- }
+- if (buf0len >= EXCESSIVE_LINE_LEN) {
+- opkg_msg(ERROR, "Excessively long line at "
+- "%d. Corrupt file?\n",
+- lineno);
+- ret = -1;
+- break;
+- }
+-
+- /*
+- * Realloc and point buf past the data already read,
+- * at the NULL terminator inserted by fgets.
+- * |<--------------- buf0len ----------------->|
+- * | |<------- buflen ---->|
+- * |---------------------|---------------------|
+- * buf0 buf
+- */
+- buflen = buf0len +1;
+- buf0len *= 2;
+- *buf0 = xrealloc(*buf0, buf0len);
+- buf = *buf0 + buflen -2;
+-
+- continue;
+- }
+-
+- *nl = '\0';
+-
+- lineno++;
+-
+- if (pkg_parse_line(pkg, *buf0, mask))
+- break;
+-
+- buf = *buf0;
+- buflen = buf0len;
+- buf[0] = '\0';
+- }
+-
+- if (pkg->name == NULL) {
+- /* probably just a blank line */
+- ret = 1;
+- }
+-
+- return ret;
+-}
+-
+-int
+ pkg_parse_from_stream(pkg_t *pkg, FILE *fp, uint mask)
+ {
+ int ret;
+@@ -358,8 +275,13 @@ pkg_parse_from_stream(pkg_t *pkg, FILE *
+ const size_t len = 4096;
+
+ buf = xmalloc(len);
+- ret = pkg_parse_from_stream_nomalloc(pkg, fp, mask, &buf, len);
++ ret = parse_from_stream_nomalloc(pkg_parse_line, pkg, fp, mask, &buf, len);
+ free(buf);
+
++ if (pkg->name == NULL) {
++ /* probably just a blank line */
++ ret = 1;
++ }
++
+ return ret;
+ }
+--- a/libopkg/pkg_parse.h
++++ b/libopkg/pkg_parse.h
+@@ -18,10 +18,11 @@
+ #ifndef PKG_PARSE_H
+ #define PKG_PARSE_H
+
++#include "pkg.h"
++
+ int parse_version(pkg_t *pkg, const char *raw);
+ int pkg_parse_from_stream(pkg_t *pkg, FILE *fp, uint mask);
+-int pkg_parse_from_stream_nomalloc(pkg_t *pkg, FILE *fp, uint mask,
+- char **buf0, size_t buf0len);
++int pkg_parse_line(void *ptr, const char *line, uint mask);
+
+ #define EXCESSIVE_LINE_LEN (4096 << 8)
+
+--- a/libopkg/release_parse.c
++++ b/libopkg/release_parse.c
+@@ -23,8 +23,10 @@
+ #include "parse_util.h"
+
+ static int
+-release_parse_line(release_t *release, const char *line)
++release_parse_line(void *ptr, const char *line, uint mask)
+ {
++ release_t *release = (release_t *) ptr;
++
+ int ret = 0;
+ unsigned int count = 0;
+ char **list = 0;
+@@ -111,25 +113,14 @@ dont_reset_flags:
+ int
+ release_parse_from_stream(release_t *release, FILE *fp)
+ {
+- int ret = 0;
+- char *buf = NULL;
+- size_t buflen, nread;
+-
+- nread = getline(&buf, &buflen, fp);
+- while ( nread != -1 ) {
+- if (buf[nread-1] == '\n') buf[nread-1] = '\0';
+- if (release_parse_line(release, buf))
+- opkg_msg(DEBUG, "Failed to parse release line for %s:\n\t%s\n",
+- release->name, buf);
+- nread = getline(&buf, &buflen, fp);
+- }
+-
+- if (!feof(fp)) {
+- opkg_perror(ERROR, "Problems reading Release file for %sd\n", release->name);
+- ret = -1;
+- }
++ int ret;
++ char *buf;
++ const size_t len = 4096;
+
++ buf = xmalloc(len);
++ ret = parse_from_stream_nomalloc(release_parse_line, release, fp, 0, &buf, len);
+ free(buf);
++
+ return ret;
+ }
+
diff --git a/package/opkg/patches/030-fix-double-free.patch b/package/opkg/patches/030-fix-double-free.patch
new file mode 100644
index 0000000..312e06c
--- /dev/null
+++ b/package/opkg/patches/030-fix-double-free.patch
@@ -0,0 +1,10 @@
+--- a/libopkg/opkg_remove.c
++++ b/libopkg/opkg_remove.c
+@@ -138,7 +138,6 @@ opkg_remove_dependent_pkgs(pkg_t *pkg, a
+ for (i = 0; i < dependent_pkgs->len; i++) {
+ err = opkg_remove_pkg(dependent_pkgs->pkgs[i],0);
+ if (err) {
+- pkg_vec_free(dependent_pkgs);
+ break;
+ }
+ }
diff --git a/package/opkg/patches/040-wrap-descriptions-only-on-ttys.patch b/package/opkg/patches/040-wrap-descriptions-only-on-ttys.patch
new file mode 100644
index 0000000..9540668
--- /dev/null
+++ b/package/opkg/patches/040-wrap-descriptions-only-on-ttys.patch
@@ -0,0 +1,31 @@
+--- a/libopkg/pkg_parse.c
++++ b/libopkg/pkg_parse.c
+@@ -20,6 +20,7 @@
+
+ #include <stdio.h>
+ #include <ctype.h>
++#include <unistd.h>
+
+ #include "pkg.h"
+ #include "opkg_utils.h"
+@@ -239,10 +240,16 @@ pkg_parse_line(void *ptr, const char *li
+
+ case ' ':
+ if ((mask & PFM_DESCRIPTION) && reading_description) {
+- pkg->description = xrealloc(pkg->description,
+- strlen(pkg->description)
+- + 1 + strlen(line) + 1);
+- strcat(pkg->description, "\n");
++ if (isatty(1)) {
++ pkg->description = xrealloc(pkg->description,
++ strlen(pkg->description)
++ + 1 + strlen(line) + 1);
++ strcat(pkg->description, "\n");
++ } else {
++ pkg->description = xrealloc(pkg->description,
++ strlen(pkg->description)
++ + 1 + strlen(line));
++ }
+ strcat(pkg->description, (line));
+ goto dont_reset_flags;
+ } else if ((mask & PFM_CONFFILES) && reading_conffiles) {
diff --git a/package/opkg/patches/050-add-case-insensitive-flag.patch b/package/opkg/patches/050-add-case-insensitive-flag.patch
new file mode 100644
index 0000000..4b9215b
--- /dev/null
+++ b/package/opkg/patches/050-add-case-insensitive-flag.patch
@@ -0,0 +1,169 @@
+--- a/libopkg/opkg_cmd.c
++++ b/libopkg/opkg_cmd.c
+@@ -436,7 +436,7 @@ opkg_configure_packages(char *pkg_name)
+ for(i = 0; i < ordered->len; i++) {
+ pkg = ordered->pkgs[i];
+
+- if (pkg_name && fnmatch(pkg_name, pkg->name, 0))
++ if (pkg_name && fnmatch(pkg_name, pkg->name, conf->nocase))
+ continue;
+
+ if (pkg->state_status == SS_UNPACKED) {
+@@ -610,7 +610,7 @@ opkg_list_cmd(int argc, char **argv)
+ for (i=0; i < available->len; i++) {
+ pkg = available->pkgs[i];
+ /* if we have package name or pattern and pkg does not match, then skip it */
+- if (pkg_name && fnmatch(pkg_name, pkg->name, 0))
++ if (pkg_name && fnmatch(pkg_name, pkg->name, conf->nocase))
+ continue;
+ print_pkg(pkg);
+ }
+@@ -637,7 +637,7 @@ opkg_list_installed_cmd(int argc, char *
+ for (i=0; i < available->len; i++) {
+ pkg = available->pkgs[i];
+ /* if we have package name or pattern and pkg does not match, then skip it */
+- if (pkg_name && fnmatch(pkg_name, pkg->name, 0))
++ if (pkg_name && fnmatch(pkg_name, pkg->name, conf->nocase))
+ continue;
+ print_pkg(pkg);
+ }
+@@ -666,7 +666,7 @@ opkg_list_changed_conffiles_cmd(int argc
+ for (i=0; i < available->len; i++) {
+ pkg = available->pkgs[i];
+ /* if we have package name or pattern and pkg does not match, then skip it */
+- if (pkg_name && fnmatch(pkg_name, pkg->name, 0))
++ if (pkg_name && fnmatch(pkg_name, pkg->name, conf->nocase))
+ continue;
+ if (nv_pair_list_empty(&pkg->conffiles))
+ continue;
+@@ -722,7 +722,7 @@ opkg_info_status_cmd(int argc, char **ar
+
+ for (i=0; i < available->len; i++) {
+ pkg = available->pkgs[i];
+- if (pkg_name && fnmatch(pkg_name, pkg->name, 0)) {
++ if (pkg_name && fnmatch(pkg_name, pkg->name, conf->nocase)) {
+ continue;
+ }
+
+@@ -792,7 +792,7 @@ opkg_remove_cmd(int argc, char **argv)
+ for (i=0; i<argc; i++) {
+ for (a=0; a<available->len; a++) {
+ pkg = available->pkgs[a];
+- if (fnmatch(argv[i], pkg->name, 0)) {
++ if (fnmatch(argv[i], pkg->name, conf->nocase)) {
+ continue;
+ }
+ if (conf->restrict_to_default_dest) {
+@@ -926,7 +926,7 @@ opkg_depends_cmd(int argc, char **argv)
+ for (j=0; j<available_pkgs->len; j++) {
+ pkg = available_pkgs->pkgs[j];
+
+- if (fnmatch(argv[i], pkg->name, 0) != 0)
++ if (fnmatch(argv[i], pkg->name, conf->nocase) != 0)
+ continue;
+
+ depends_count = pkg->depends_count +
+@@ -1147,9 +1147,9 @@ opkg_what_provides_replaces_cmd(enum wha
+ ((what_field_type == WHATPROVIDES)
+ ? pkg->provides[k]
+ : pkg->replaces[k]);
+- if (fnmatch(target, apkg->name, 0) == 0) {
++ if (fnmatch(target, apkg->name, conf->nocase) == 0) {
+ opkg_msg(NOTICE, " %s", pkg->name);
+- if (strcmp(target, apkg->name) != 0)
++ if ((conf->nocase ? strcasecmp(target, apkg->name) : strcmp(target, apkg->name)) != 0)
+ opkg_msg(NOTICE, "\t%s %s\n",
+ rel_str, apkg->name);
+ opkg_message(NOTICE, "\n");
+@@ -1200,7 +1200,7 @@ opkg_search_cmd(int argc, char **argv)
+
+ for (iter = str_list_first(installed_files); iter; iter = str_list_next(installed_files, iter)) {
+ installed_file = (char *)iter->data;
+- if (fnmatch(argv[0], installed_file, 0)==0)
++ if (fnmatch(argv[0], installed_file, conf->nocase)==0)
+ print_pkg(pkg);
+ }
+
+--- a/libopkg/opkg_conf.c
++++ b/libopkg/opkg_conf.c
+@@ -62,6 +62,7 @@ opkg_option_t options[] = {
+ { "noaction", OPKG_OPT_TYPE_BOOL, &_conf.noaction },
+ { "download_only", OPKG_OPT_TYPE_BOOL, &_conf.download_only },
+ { "nodeps", OPKG_OPT_TYPE_BOOL, &_conf.nodeps },
++ { "nocase", OPKG_OPT_TYPE_BOOL, &_conf.nocase },
+ { "offline_root", OPKG_OPT_TYPE_STRING, &_conf.offline_root },
+ { "overlay_root", OPKG_OPT_TYPE_STRING, &_conf.overlay_root },
+ { "proxy_passwd", OPKG_OPT_TYPE_STRING, &_conf.proxy_passwd },
+--- a/libopkg/opkg_conf.h
++++ b/libopkg/opkg_conf.h
+@@ -24,6 +24,7 @@ extern opkg_conf_t *conf;
+ #include "config.h"
+
+ #include <stdarg.h>
++#include <fnmatch.h> /* FNM_CASEFOLD */
+
+ #include "hash_table.h"
+ #include "pkg_src_list.h"
+@@ -79,6 +80,7 @@ struct opkg_conf
+ int force_remove;
+ int check_signature;
+ int nodeps; /* do not follow dependencies */
++ int nocase; /* perform case insensitive matching */
+ char *offline_root;
+ char *overlay_root;
+ int query_all;
+--- a/src/opkg-cl.c
++++ b/src/opkg-cl.c
+@@ -47,6 +47,7 @@ enum {
+ ARGS_OPT_NOACTION,
+ ARGS_OPT_DOWNLOAD_ONLY,
+ ARGS_OPT_NODEPS,
++ ARGS_OPT_NOCASE,
+ ARGS_OPT_AUTOREMOVE,
+ ARGS_OPT_CACHE,
+ };
+@@ -86,6 +87,7 @@ static struct option long_options[] = {
+ {"noaction", 0, 0, ARGS_OPT_NOACTION},
+ {"download-only", 0, 0, ARGS_OPT_DOWNLOAD_ONLY},
+ {"nodeps", 0, 0, ARGS_OPT_NODEPS},
++ {"nocase", 0, 0, ARGS_OPT_NOCASE},
+ {"offline", 1, 0, 'o'},
+ {"offline-root", 1, 0, 'o'},
+ {"add-arch", 1, 0, ARGS_OPT_ADD_ARCH},
+@@ -107,7 +109,7 @@ args_parse(int argc, char *argv[])
+ char *tuple, *targ;
+
+ while (1) {
+- c = getopt_long_only(argc, argv, "Ad:f:no:p:t:vV::",
++ c = getopt_long_only(argc, argv, "Ad:f:ino:p:t:vV::",
+ long_options, &option_index);
+ if (c == -1)
+ break;
+@@ -122,6 +124,9 @@ args_parse(int argc, char *argv[])
+ case 'f':
+ conf->conf_file = xstrdup(optarg);
+ break;
++ case 'i':
++ conf->nocase = FNM_CASEFOLD;
++ break;
+ case 'o':
+ conf->offline_root = xstrdup(optarg);
+ break;
+@@ -176,6 +181,9 @@ args_parse(int argc, char *argv[])
+ case ARGS_OPT_NODEPS:
+ conf->nodeps = 1;
+ break;
++ case ARGS_OPT_NOCASE:
++ conf->nocase = FNM_CASEFOLD;
++ break;
+ case ARGS_OPT_ADD_ARCH:
+ case ARGS_OPT_ADD_DEST:
+ tuple = xstrdup(optarg);
+@@ -287,6 +295,7 @@ usage()
+ printf("\t--noaction No action -- test only\n");
+ printf("\t--download-only No action -- download only\n");
+ printf("\t--nodeps Do not follow dependencies\n");
++ printf("\t--nocase Perform case insensitive pattern matching\n");
+ printf("\t--force-removal-of-dependent-packages\n");
+ printf("\t Remove package and all dependencies\n");
+ printf("\t--autoremove Remove packages that were installed\n");
diff --git a/package/opkg/patches/060-add-find-command.patch b/package/opkg/patches/060-add-find-command.patch
new file mode 100644
index 0000000..1762534
--- /dev/null
+++ b/package/opkg/patches/060-add-find-command.patch
@@ -0,0 +1,58 @@
+--- a/libopkg/opkg_cmd.c
++++ b/libopkg/opkg_cmd.c
+@@ -594,7 +594,7 @@ opkg_download_cmd(int argc, char **argv)
+
+
+ static int
+-opkg_list_cmd(int argc, char **argv)
++opkg_list_find_cmd(int argc, char **argv, int use_desc)
+ {
+ int i;
+ pkg_vec_t *available;
+@@ -610,7 +610,8 @@ opkg_list_cmd(int argc, char **argv)
+ for (i=0; i < available->len; i++) {
+ pkg = available->pkgs[i];
+ /* if we have package name or pattern and pkg does not match, then skip it */
+- if (pkg_name && fnmatch(pkg_name, pkg->name, conf->nocase))
++ if (pkg_name && fnmatch(pkg_name, pkg->name, conf->nocase) &&
++ (!use_desc || !pkg->description || fnmatch(pkg_name, pkg->description, conf->nocase)))
+ continue;
+ print_pkg(pkg);
+ }
+@@ -619,6 +620,18 @@ opkg_list_cmd(int argc, char **argv)
+ return 0;
+ }
+
++static int
++opkg_list_cmd(int argc, char **argv)
++{
++ return opkg_list_find_cmd(argc, argv, 0);
++}
++
++static int
++opkg_find_cmd(int argc, char **argv)
++{
++ return opkg_list_find_cmd(argc, argv, 1);
++}
++
+
+ static int
+ opkg_list_installed_cmd(int argc, char **argv)
+@@ -1262,6 +1275,7 @@ static opkg_cmd_t cmds[] = {
+ {"configure", 0, (opkg_cmd_fun_t)opkg_configure_cmd, PFM_DESCRIPTION|PFM_SOURCE},
+ {"files", 1, (opkg_cmd_fun_t)opkg_files_cmd, PFM_DESCRIPTION|PFM_SOURCE},
+ {"search", 1, (opkg_cmd_fun_t)opkg_search_cmd, PFM_DESCRIPTION|PFM_SOURCE},
++ {"find", 1, (opkg_cmd_fun_t)opkg_find_cmd, PFM_SOURCE},
+ {"download", 1, (opkg_cmd_fun_t)opkg_download_cmd, PFM_DESCRIPTION|PFM_SOURCE},
+ {"compare_versions", 1, (opkg_cmd_fun_t)opkg_compare_versions_cmd, PFM_DESCRIPTION|PFM_SOURCE},
+ {"compare-versions", 1, (opkg_cmd_fun_t)opkg_compare_versions_cmd, PFM_DESCRIPTION|PFM_SOURCE},
+--- a/src/opkg-cl.c
++++ b/src/opkg-cl.c
+@@ -246,6 +246,7 @@ usage()
+ printf("\tlist-changed-conffiles List user modified configuration files\n");
+ printf("\tfiles <pkg> List files belonging to <pkg>\n");
+ printf("\tsearch <file|regexp> List package providing <file>\n");
++ printf("\tfind <regexp> List packages whose name or description matches <regexp>\n");
+ printf("\tinfo [pkg|regexp] Display all info for <pkg>\n");
+ printf("\tstatus [pkg|regexp] Display all status for <pkg>\n");
+ printf("\tdownload <pkg> Download <pkg> to current directory\n");
diff --git a/package/opkg/patches/070-use_gzipped_pkg_list.patch b/package/opkg/patches/070-use_gzipped_pkg_list.patch
new file mode 100644
index 0000000..d32b519
--- /dev/null
+++ b/package/opkg/patches/070-use_gzipped_pkg_list.patch
@@ -0,0 +1,120 @@
+--- a/libopkg/opkg.c
++++ b/libopkg/opkg.c
+@@ -592,49 +592,8 @@ opkg_update_package_lists(opkg_progress_
+ src->gzip ? "Packages.gz" : "Packages");
+
+ sprintf_alloc(&list_file_name, "%s/%s", lists_dir, src->name);
+- if (src->gzip) {
+- FILE *in, *out;
+- struct _curl_cb_data cb_data;
+- char *tmp_file_name = NULL;
+
+- sprintf_alloc(&tmp_file_name, "%s/%s.gz", tmp,
+- src->name);
+-
+- opkg_msg(INFO, "Downloading %s to %s...\n", url,
+- tmp_file_name);
+-
+- cb_data.cb = progress_callback;
+- cb_data.progress_data = &pdata;
+- cb_data.user_data = user_data;
+- cb_data.start_range =
+- 100 * sources_done / sources_list_count;
+- cb_data.finish_range =
+- 100 * (sources_done + 1) / sources_list_count;
+-
+- err = opkg_download(url, tmp_file_name,
+- (curl_progress_func) curl_progress_cb,
+- &cb_data, 0);
+-
+- if (err == 0) {
+- opkg_msg(INFO, "Inflating %s...\n",
+- tmp_file_name);
+- in = fopen(tmp_file_name, "r");
+- out = fopen(list_file_name, "w");
+- if (in && out)
+- unzip(in, out);
+- else
+- err = 1;
+- if (in)
+- fclose(in);
+- if (out)
+- fclose(out);
+- unlink(tmp_file_name);
+- }
+- free(tmp_file_name);
+- } else
+- err = opkg_download(url, list_file_name, NULL, NULL, 0);
+-
+- if (err) {
++ if (opkg_download(url, list_file_name, NULL, NULL, 0)) {
+ opkg_msg(ERROR, "Couldn't retrieve %s\n", url);
+ result = -1;
+ }
+--- a/libopkg/opkg_cmd.c
++++ b/libopkg/opkg_cmd.c
+@@ -162,30 +162,7 @@ opkg_update_cmd(int argc, char **argv)
+ sprintf_alloc(&url, "%s/%s", src->value, src->gzip ? "Packages.gz" : "Packages");
+
+ sprintf_alloc(&list_file_name, "%s/%s", lists_dir, src->name);
+- if (src->gzip) {
+- char *tmp_file_name;
+- FILE *in, *out;
+-
+- sprintf_alloc (&tmp_file_name, "%s/%s.gz", tmp, src->name);
+- err = opkg_download(url, tmp_file_name, NULL, NULL, 0);
+- if (err == 0) {
+- opkg_msg(NOTICE, "Inflating %s.\n", url);
+- in = fopen (tmp_file_name, "r");
+- out = fopen (list_file_name, "w");
+- if (in && out)
+- unzip (in, out);
+- else
+- err = 1;
+- if (in)
+- fclose (in);
+- if (out)
+- fclose (out);
+- unlink (tmp_file_name);
+- }
+- free(tmp_file_name);
+- } else
+- err = opkg_download(url, list_file_name, NULL, NULL, 0);
+- if (err) {
++ if (opkg_download(url, list_file_name, NULL, NULL, 0)) {
+ failures++;
+ } else {
+ opkg_msg(NOTICE, "Updated list of available packages in %s.\n",
+--- a/libopkg/pkg_hash.c
++++ b/libopkg/pkg_hash.c
+@@ -102,12 +102,18 @@ pkg_hash_add_from_file(const char *file_
+ pkg_src_t *src, pkg_dest_t *dest, int is_status_file)
+ {
+ pkg_t *pkg;
+- FILE *fp;
++ FILE *fp, *fp_c = NULL;
+ char *buf;
+ const size_t len = 4096;
+ int ret = 0;
++ int pid;
+
+ fp = fopen(file_name, "r");
++ if (fp && src && src->gzip) {
++ fp_c = fp;
++ fp = gz_open(fp_c, &pid);
++ }
++
+ if (fp == NULL) {
+ opkg_perror(ERROR, "Failed to open %s", file_name);
+ return -1;
+@@ -154,6 +160,10 @@ pkg_hash_add_from_file(const char *file_
+
+ free(buf);
+ fclose(fp);
++ if (fp_c) {
++ fclose(fp_c);
++ gz_close(pid);
++ }
+
+ return ret;
+ }
diff --git a/package/platform/.svn/entries b/package/platform/.svn/entries
new file mode 100644
index 0000000..e24e3bd
--- /dev/null
+++ b/package/platform/.svn/entries
@@ -0,0 +1,31 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/platform
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-14T18:43:29.116646Z
+36025
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+lantiq
+dir
+
diff --git a/package/platform/lantiq/.svn/entries b/package/platform/lantiq/.svn/entries
new file mode 100644
index 0000000..ee7f919
--- /dev/null
+++ b/package/platform/lantiq/.svn/entries
@@ -0,0 +1,73 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/platform/lantiq
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-14T18:43:29.116646Z
+36025
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+ltq-atm
+dir
+
+ltq-vdsl-fw
+dir
+
+ltq-adsl
+dir
+
+ltq-vdsl-app
+dir
+
+ltq-ifxos
+dir
+
+ltq-adsl-mei
+dir
+
+ltq-tapi
+dir
+
+ltq-adsl-fw
+dir
+
+ltq-hcd
+dir
+
+ltq-ptm
+dir
+
+ltq-adsl-app
+dir
+
+ltq-vmmc
+dir
+
+ltq-vdsl
+dir
+
+ltq-deu
+dir
+
+ltq-vdsl-mei
+dir
+
diff --git a/package/platform/lantiq/ltq-adsl-app/.svn/entries b/package/platform/lantiq/ltq-adsl-app/.svn/entries
new file mode 100644
index 0000000..1fef17e
--- /dev/null
+++ b/package/platform/lantiq/ltq-adsl-app/.svn/entries
@@ -0,0 +1,99 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/platform/lantiq/ltq-adsl-app
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-12-21T13:47:25.499676Z
+34818
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+files
+dir
+
+Config.in
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+6dd12ecbeb4480e456ee3ff8c16b3018
+2012-12-15T02:00:39.596852Z
+34694
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+220
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+3c1580e91b167dbb9375cc12167f205e
+2012-12-15T02:00:39.596852Z
+34694
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2640
+
diff --git a/package/platform/lantiq/ltq-adsl-app/.svn/text-base/Config.in.svn-base b/package/platform/lantiq/ltq-adsl-app/.svn/text-base/Config.in.svn-base
new file mode 100644
index 0000000..728fe65
--- /dev/null
+++ b/package/platform/lantiq/ltq-adsl-app/.svn/text-base/Config.in.svn-base
@@ -0,0 +1,9 @@
+config LTQ_DSL_ENABLE_SOAP
+ bool "Enable SOAP support"
+ depends on PACKAGE_ltq-dsl-app
+ default n
+
+config LTQ_DSL_ENABLE_DSL_EVENT_POLLING
+ bool "Include Event Polling support"
+ depends on PACKAGE_ltq-dsl-app
+ default n
diff --git a/package/platform/lantiq/ltq-adsl-app/.svn/text-base/Makefile.svn-base b/package/platform/lantiq/ltq-adsl-app/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..92445e5
--- /dev/null
+++ b/package/platform/lantiq/ltq-adsl-app/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,98 @@
+#
+# Copyright (C) 2011-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=dsl_cpe_control_danube
+PKG_VERSION:=3.24.4.4
+PKG_RELEASE:=2
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_BUILD_DIR:=$(BUILD_DIR)/dsl_cpe_control-$(PKG_VERSION)
+PKG_SOURCE_URL:=http://mirror2.openwrt.org/sources/
+PKG_MD5SUM:=ee315306626b68794d3d3636dabfe161
+PKG_MAINTAINER:=John Crispin <blogic@openwrt.org>
+
+PKG_FIXUP:=autoreconf
+
+PKG_CONFIG_DEPENDS:=\
+ CONFIG_LTQ_DSL_ENABLE_SOAP \
+ CONFIG_LTQ_DSL_ENABLE_DSL_EVENT_POLLING
+
+PKG_BUILD_DEPENDS:=TARGET_lantiq_xway:kmod-ltq-adsl-danube TARGET_lantiq_ase:kmod-ltq-adsl-ase
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/ltq-adsl-app
+ SECTION:=net
+ CATEGORY:=Network
+ TITLE:=Lantiq DSL userland tool
+ URL:=http://www.lantiq.com/
+ DEPENDS:=@(TARGET_lantiq_xway||TARGET_lantiq_ase) +libpthread
+ MENU:=1
+endef
+
+define Package/ltq-adsl-app/description
+ Infineon DSL CPE API for Amazon SE, Danube and Vinax.
+endef
+
+define Package/ltq-adsl-app/config
+ source "$(SOURCE)/Config.in"
+endef
+
+LTQ_DSL_MAX_DEVICE=1
+LTQ_DSL_LINES_PER_DEVICE=1
+LTQ_DSL_CHANNELS_PER_LINE=1
+
+CONFIGURE_ARGS += \
+ --with-max-device="$(LTQ_DSL_MAX_DEVICE)" \
+ --with-lines-per-device="$(LTQ_DSL_LINES_PER_DEVICE)" \
+ --with-channels-per-line="$(LTQ_DSL_CHANNELS_PER_LINE)" \
+ --enable-danube \
+ --enable-driver-include="-I$(STAGING_DIR)/usr/include/adsl/" \
+ --enable-debug-prints \
+ --enable-add-appl-cflags="-DMAX_CLI_PIPES=2" \
+ --enable-cli-support \
+ --enable-cmv-scripts \
+ --enable-debug-tool-interface \
+ --enable-adsl-led \
+ --enable-dsl-ceoc \
+ --enable-script-notification \
+ --enable-dsl-pm \
+ --enable-dsl-pm-total \
+ --enable-dsl-pm-history \
+ --enable-dsl-pm-showtime \
+ --enable-dsl-pm-channel-counters \
+ --enable-dsl-pm-datapath-counters \
+ --enable-dsl-pm-line-counters \
+ --enable-dsl-pm-channel-thresholds \
+ --enable-dsl-pm-datapath-thresholds \
+ --enable-dsl-pm-line-thresholds \
+ --enable-dsl-pm-optional-parameters
+
+ifeq ($(CONFIG_LTQ_DSL_ENABLE_SOAP),y)
+CONFIGURE_ARGS += \
+ --enable-soap-support
+endif
+
+ifeq ($(CONFIG_LTQ_DSL_ENABLE_DSL_EVENT_POLLING),y)
+CONFIGURE_ARGS += \
+ --enable-dsl-event-polling
+endif
+
+TARGET_CFLAGS += -I$(LINUX_DIR)/include
+
+define Package/ltq-adsl-app/install
+ $(INSTALL_DIR) $(1)/etc/init.d
+ $(INSTALL_BIN) ./files/dsl_control $(1)/etc/init.d/
+
+ $(INSTALL_DIR) $(1)/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/dsl_cpe_control $(1)/sbin
+ $(INSTALL_BIN) ./files/dsl_notify.sh $(1)/sbin
+endef
+
+$(eval $(call BuildPackage,ltq-adsl-app))
diff --git a/package/platform/lantiq/ltq-adsl-app/Config.in b/package/platform/lantiq/ltq-adsl-app/Config.in
new file mode 100644
index 0000000..728fe65
--- /dev/null
+++ b/package/platform/lantiq/ltq-adsl-app/Config.in
@@ -0,0 +1,9 @@
+config LTQ_DSL_ENABLE_SOAP
+ bool "Enable SOAP support"
+ depends on PACKAGE_ltq-dsl-app
+ default n
+
+config LTQ_DSL_ENABLE_DSL_EVENT_POLLING
+ bool "Include Event Polling support"
+ depends on PACKAGE_ltq-dsl-app
+ default n
diff --git a/package/platform/lantiq/ltq-adsl-app/Makefile b/package/platform/lantiq/ltq-adsl-app/Makefile
new file mode 100644
index 0000000..92445e5
--- /dev/null
+++ b/package/platform/lantiq/ltq-adsl-app/Makefile
@@ -0,0 +1,98 @@
+#
+# Copyright (C) 2011-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=dsl_cpe_control_danube
+PKG_VERSION:=3.24.4.4
+PKG_RELEASE:=2
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_BUILD_DIR:=$(BUILD_DIR)/dsl_cpe_control-$(PKG_VERSION)
+PKG_SOURCE_URL:=http://mirror2.openwrt.org/sources/
+PKG_MD5SUM:=ee315306626b68794d3d3636dabfe161
+PKG_MAINTAINER:=John Crispin <blogic@openwrt.org>
+
+PKG_FIXUP:=autoreconf
+
+PKG_CONFIG_DEPENDS:=\
+ CONFIG_LTQ_DSL_ENABLE_SOAP \
+ CONFIG_LTQ_DSL_ENABLE_DSL_EVENT_POLLING
+
+PKG_BUILD_DEPENDS:=TARGET_lantiq_xway:kmod-ltq-adsl-danube TARGET_lantiq_ase:kmod-ltq-adsl-ase
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/ltq-adsl-app
+ SECTION:=net
+ CATEGORY:=Network
+ TITLE:=Lantiq DSL userland tool
+ URL:=http://www.lantiq.com/
+ DEPENDS:=@(TARGET_lantiq_xway||TARGET_lantiq_ase) +libpthread
+ MENU:=1
+endef
+
+define Package/ltq-adsl-app/description
+ Infineon DSL CPE API for Amazon SE, Danube and Vinax.
+endef
+
+define Package/ltq-adsl-app/config
+ source "$(SOURCE)/Config.in"
+endef
+
+LTQ_DSL_MAX_DEVICE=1
+LTQ_DSL_LINES_PER_DEVICE=1
+LTQ_DSL_CHANNELS_PER_LINE=1
+
+CONFIGURE_ARGS += \
+ --with-max-device="$(LTQ_DSL_MAX_DEVICE)" \
+ --with-lines-per-device="$(LTQ_DSL_LINES_PER_DEVICE)" \
+ --with-channels-per-line="$(LTQ_DSL_CHANNELS_PER_LINE)" \
+ --enable-danube \
+ --enable-driver-include="-I$(STAGING_DIR)/usr/include/adsl/" \
+ --enable-debug-prints \
+ --enable-add-appl-cflags="-DMAX_CLI_PIPES=2" \
+ --enable-cli-support \
+ --enable-cmv-scripts \
+ --enable-debug-tool-interface \
+ --enable-adsl-led \
+ --enable-dsl-ceoc \
+ --enable-script-notification \
+ --enable-dsl-pm \
+ --enable-dsl-pm-total \
+ --enable-dsl-pm-history \
+ --enable-dsl-pm-showtime \
+ --enable-dsl-pm-channel-counters \
+ --enable-dsl-pm-datapath-counters \
+ --enable-dsl-pm-line-counters \
+ --enable-dsl-pm-channel-thresholds \
+ --enable-dsl-pm-datapath-thresholds \
+ --enable-dsl-pm-line-thresholds \
+ --enable-dsl-pm-optional-parameters
+
+ifeq ($(CONFIG_LTQ_DSL_ENABLE_SOAP),y)
+CONFIGURE_ARGS += \
+ --enable-soap-support
+endif
+
+ifeq ($(CONFIG_LTQ_DSL_ENABLE_DSL_EVENT_POLLING),y)
+CONFIGURE_ARGS += \
+ --enable-dsl-event-polling
+endif
+
+TARGET_CFLAGS += -I$(LINUX_DIR)/include
+
+define Package/ltq-adsl-app/install
+ $(INSTALL_DIR) $(1)/etc/init.d
+ $(INSTALL_BIN) ./files/dsl_control $(1)/etc/init.d/
+
+ $(INSTALL_DIR) $(1)/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/dsl_cpe_control $(1)/sbin
+ $(INSTALL_BIN) ./files/dsl_notify.sh $(1)/sbin
+endef
+
+$(eval $(call BuildPackage,ltq-adsl-app))
diff --git a/package/platform/lantiq/ltq-adsl-app/files/.svn/entries b/package/platform/lantiq/ltq-adsl-app/files/.svn/entries
new file mode 100644
index 0000000..1db231e
--- /dev/null
+++ b/package/platform/lantiq/ltq-adsl-app/files/.svn/entries
@@ -0,0 +1,96 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/platform/lantiq/ltq-adsl-app/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-12-21T13:47:25.499676Z
+34818
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+dsl_control
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+d3df0f8c6e1d3d3654c58528fec37023
+2012-12-21T13:47:25.499676Z
+34818
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+6038
+
+dsl_notify.sh
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+40eca6e336903e2776949907def9a02c
+2012-12-15T02:00:39.596852Z
+34694
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1004
+
diff --git a/package/platform/lantiq/ltq-adsl-app/files/.svn/text-base/dsl_control.svn-base b/package/platform/lantiq/ltq-adsl-app/files/.svn/text-base/dsl_control.svn-base
new file mode 100644
index 0000000..e8a286f
--- /dev/null
+++ b/package/platform/lantiq/ltq-adsl-app/files/.svn/text-base/dsl_control.svn-base
@@ -0,0 +1,311 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2012 OpenWrt.org
+
+START=99
+
+EXTRA_COMMANDS="status lucistat"
+EXTRA_HELP=" status Get DSL status information
+ lucistat Get status information if lua friendly format"
+
+SERVICE_DAEMONIZE=1
+SERVICE_WRITE_PID=1
+
+#
+# Basic functions to send CLI commands to the dsl_cpe_control daemon
+#
+dsl_cmd() {
+ killall -0 dsl_cpe_control && (
+ echo "$@" > /tmp/pipe/dsl_cpe0_cmd
+ cat /tmp/pipe/dsl_cpe0_ack
+ )
+}
+dsl_val() {
+ echo $(expr "$1" : '.*'$2'=\([-\.[:alnum:]]*\).*')
+}
+
+#
+# Simple divide by 10 routine to cope with one decimal place
+#
+dbt() {
+ local a=$(expr $1 / 10)
+ local b=$(expr $1 % 10)
+ echo "${a}.${b}"
+}
+#
+# Take a number and convert to k or meg
+#
+scale() {
+ local val=$1
+ local a
+ local b
+
+ if [ "$val" -gt 1000000 ]; then
+ a=$(expr $val / 1000)
+ b=$(expr $a % 1000)
+ a=$(expr $a / 1000)
+ printf "%d.%03d Mb" ${a} ${b}
+ elif [ "$val" -gt 1000 ]; then
+ a=$(expr $val / 1000)
+ printf "%d Kb" ${a}
+ else
+ echo "${val} b"
+ fi
+}
+
+#
+# Read the data rates for both directions
+#
+data_rates() {
+ local csg
+ local dru
+ local drd
+ local sdru
+ local sdrd
+
+ csg=$(dsl_cmd g997csg 0 1)
+ drd=$(dsl_val "$csg" ActualDataRate)
+
+ csg=$(dsl_cmd g997csg 0 0)
+ dru=$(dsl_val "$csg" ActualDataRate)
+
+ [ -z "$drd" ] && drd=0
+ [ -z "$dru" ] && dru=0
+
+ sdrd=$(scale $drd)
+ sdru=$(scale $dru)
+
+ if [ "$action" = "lucistat" ]; then
+ echo "dsl.data_rate_down=$drd"
+ echo "dsl.data_rate_up=$dru"
+ echo "dsl.data_rate_down_s=\"$sdrd\""
+ echo "dsl.data_rate_up_s=\"$sdru\""
+ else
+ echo "Data Rate: ${sdrd}/s / ${sdru}/s"
+ fi
+}
+
+#
+# Chipset
+#
+chipset() {
+ local vig
+ local cs
+ local csv
+
+ vig=$(dsl_cmd vig)
+ cs=$(dsl_val "$vig" DSL_ChipSetType)
+ csv=$(dsl_val "$vig" DSL_ChipSetHWVersion)
+
+ if [ "$action" = "lucistat" ]; then
+ echo "dsl.chipset=\"${cs} ${csv}\""
+ else
+ echo "Chipset: ${cs} ${csv}"
+ fi
+}
+
+#
+# Work out how long the line has been up
+#
+line_uptime() {
+ local ccsg
+ local et
+ local etr
+ local d
+ local h
+ local m
+ local s
+ local rc=""
+
+ ccsg=$(dsl_cmd pmccsg 0 0 0)
+ et=$(dsl_val "$ccsg" nElapsedTime)
+
+ [ -z "$et" ] && et=0
+
+ if [ "$action" = "lucistat" ]; then
+ echo "dsl.line_uptime=${et}"
+ return
+ fi
+
+ d=$(expr $et / 86400)
+ etr=$(expr $et % 86400)
+ h=$(expr $etr / 3600)
+ etr=$(expr $etr % 3600)
+ m=$(expr $etr / 60)
+ s=$(expr $etr % 60)
+
+
+ [ "${d}${h}${m}${s}" -ne 0 ] && rc="${s}s"
+ [ "${d}${h}${m}" -ne 0 ] && rc="${m}m ${rc}"
+ [ "${d}${h}" -ne 0 ] && rc="${h}h ${rc}"
+ [ "${d}" -ne 0 ] && rc="${d}d ${rc}"
+
+ [ -z "$rc" ] && rc="down"
+ echo "Line Uptime: ${rc}"
+}
+
+#
+# Get noise and attenuation figures
+#
+line_data() {
+ local lsg
+ local latnu
+ local latnd
+ local snru
+ local snrd
+
+ lsg=$(dsl_cmd g997lsg 1 1)
+ latnd=$(dsl_val "$lsg" LATN)
+ snrd=$(dsl_val "$lsg" SNR)
+
+ lsg=$(dsl_cmd g997lsg 0 1)
+ latnu=$(dsl_val "$lsg" LATN)
+ snru=$(dsl_val "$lsg" SNR)
+
+ [ -z "$latnd" ] && latnd=0
+ [ -z "$latnu" ] && latnu=0
+ [ -z "$snrd" ] && snrd=0
+ [ -z "$snru" ] && snru=0
+
+ latnd=$(dbt $latnd)
+ latnu=$(dbt $latnu)
+ snrd=$(dbt $snrd)
+ snru=$(dbt $snru)
+
+ if [ "$action" = "lucistat" ]; then
+ echo "dsl.line_attenuation_down=$latnd"
+ echo "dsl.line_attenuation_up=$latnu"
+ echo "dsl.noise_margin_down=$snrd"
+ echo "dsl.noise_margin_up=$snru"
+ else
+ echo "Line Attenuation: ${latnd}dB / ${latnu}dB"
+ echo "Noise Margin: ${snrd}dB / ${snru}dB"
+ fi
+}
+
+#
+# Is the line up? Or what state is it in?
+#
+line_state() {
+ local lsg=$(dsl_cmd lsg)
+ local ls=$(dsl_val "$lsg" nLineState);
+ local s;
+
+ case "$ls" in
+ "0x0") s="not initialized" ;;
+ "0x1") s="exception" ;;
+ "0x10") s="not updated" ;;
+ "0xff") s="idle request" ;;
+ "0x100") s="idle" ;;
+ "0x1ff") s="silent request" ;;
+ "0x200") s="silent" ;;
+ "0x300") s="handshake" ;;
+ "0x380") s="full_init" ;;
+ "0x400") s="discovery" ;;
+ "0x500") s="training" ;;
+ "0x600") s="analysis" ;;
+ "0x700") s="exchange" ;;
+ "0x800") s="showtime_no_sync" ;;
+ "0x801") s="showtime_tc_sync" ;;
+ "0x900") s="fastretrain" ;;
+ "0xa00") s="lowpower_l2" ;;
+ "0xb00") s="loopdiagnostic active" ;;
+ "0xb10") s="loopdiagnostic data exchange" ;;
+ "0xb20") s="loopdiagnostic data request" ;;
+ "0xc00") s="loopdiagnostic complete" ;;
+ "0x1000000") s="test" ;;
+ "0xd00") s="resync" ;;
+ "0x3c0") s="short init entry" ;;
+ "") s="not running daemon"; ls="0xfff" ;;
+ *) s="unknown" ;;
+ esac
+
+ if [ $action = "lucistat" ]; then
+ echo "dsl.line_state_num=$ls"
+ echo "dsl.line_state_detail=\"$s\""
+ if [ "$ls" = "0x801" ]; then
+ echo "dsl.line_state=\"UP\""
+ else
+ echo "dsl.line_state=\"DOWN\""
+ fi
+ else
+ if [ "$ls" = "0x801" ]; then
+ echo "Line State: UP [$ls: $s]"
+ else
+ echo "Line State: DOWN [$ls: $s]"
+ fi
+ fi
+}
+
+#
+# Main status routine
+#
+status() {
+ chipset
+ line_state
+ data_rates
+ line_data
+ line_uptime
+}
+
+#
+# Luci (lua) compatible version that's easy to parse
+#
+lucistat() {
+ echo "local dsl={}"
+ status
+ echo "return dsl"
+}
+
+
+annex_b=10_00_10_00_00_04_00_00
+annex_bdmt=10_00_00_00_00_00_00_00
+annex_b2=00_00_10_00_00_00_00_00
+annex_b2p=00_00_00_00_00_04_00_00
+annex_a=04_01_04_00_00_01_00_00
+annex_at1=01_00_00_00_00_00_00_00
+annex_alite=00_01_00_00_00_00_00_00
+annex_admt=04_00_00_00_00_00_00_00
+annex_a2=00_00_04_00_00_00_00_00
+annex_a2p=00_00_00_00_00_01_00_00
+annex_l=00_00_00_00_04_00_00_00
+annex_m=00_00_00_00_40_00_04_00
+annex_m2=00_00_00_00_40_00_00_00
+annex_m2p=00_00_00_00_00_00_04_00
+
+#
+# Simple start routine
+#
+start() {
+ local annex
+ local firmware
+ local xtu
+ config_load network
+ config_get annex wan annex
+ config_get firmware wan firmware
+
+ # get xtu
+ eval "xtu=\"\${annex_$annex}\""
+
+ # check for firmware
+ [ -z "${firmware}" ] &&
+ firmware=adsl.bin
+
+ # start CPE dsl daemon in the background
+ service_start /sbin/dsl_cpe_control -i${xtu} \
+ -n /sbin/dsl_notify.sh \
+ -f /lib/firmware/${firmware}
+}
+
+#
+# For stop we want to simulate the notification call for when
+# the line goes down, so that we can stop the ppp link before
+# we die.
+#
+stop() {
+ DSL_NOTIFICATION_TYPE="DSL_INTERFACE_STATUS" \
+ DSL_INTERFACE_STATUS="DOWN" \
+ /sbin/dsl_notify.sh
+
+ service_stop /sbin/dsl_cpe_control
+}
+
diff --git a/package/platform/lantiq/ltq-adsl-app/files/.svn/text-base/dsl_notify.sh.svn-base b/package/platform/lantiq/ltq-adsl-app/files/.svn/text-base/dsl_notify.sh.svn-base
new file mode 100644
index 0000000..5e9f396
--- /dev/null
+++ b/package/platform/lantiq/ltq-adsl-app/files/.svn/text-base/dsl_notify.sh.svn-base
@@ -0,0 +1,44 @@
+#!/bin/sh
+#
+# This script is called by dsl_cpe_control whenever there is a DSL event,
+# we only actually care about the DSL_INTERFACE_STATUS events as these
+# tell us the line has either come up or gone down.
+#
+# The rest of the code is basically the same at the atm hotplug code
+#
+
+[ "$DSL_NOTIFICATION_TYPE" = "DSL_INTERFACE_STATUS" ] || exit 0
+
+. /lib/functions.sh
+
+include /lib/network
+scan_interfaces
+
+local found=0
+local ifc
+for ifc in $interfaces; do
+ local up
+ config_get_bool up "$ifc" up 0
+
+ local auto
+ config_get_bool auto "$ifc" auto 1
+
+ local proto
+ config_get proto "$ifc" proto
+
+ if [ "$DSL_INTERFACE_STATUS" = "UP" ]; then
+ if [ "$proto" = "pppoa" ] && [ "$up" != 1 ] && [ "$auto" = 1 ]; then
+ found=1
+ ( sleep 1; ifup "$ifc" ) &
+ fi
+ else
+ if [ "$proto" = "pppoa" ] && [ "$up" = 1 ] && [ "$auto" = 1 ]; then
+ found=1
+ ( sleep 1; ifdown "$ifc" ) &
+ fi
+ fi
+done
+
+if [ "$found" != 1 ]; then
+ logger "Found no matching interface for DSL notification ($DSL_INTERFACE_STATUS)"
+fi
diff --git a/package/platform/lantiq/ltq-adsl-app/files/dsl_control b/package/platform/lantiq/ltq-adsl-app/files/dsl_control
new file mode 100644
index 0000000..e8a286f
--- /dev/null
+++ b/package/platform/lantiq/ltq-adsl-app/files/dsl_control
@@ -0,0 +1,311 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2012 OpenWrt.org
+
+START=99
+
+EXTRA_COMMANDS="status lucistat"
+EXTRA_HELP=" status Get DSL status information
+ lucistat Get status information if lua friendly format"
+
+SERVICE_DAEMONIZE=1
+SERVICE_WRITE_PID=1
+
+#
+# Basic functions to send CLI commands to the dsl_cpe_control daemon
+#
+dsl_cmd() {
+ killall -0 dsl_cpe_control && (
+ echo "$@" > /tmp/pipe/dsl_cpe0_cmd
+ cat /tmp/pipe/dsl_cpe0_ack
+ )
+}
+dsl_val() {
+ echo $(expr "$1" : '.*'$2'=\([-\.[:alnum:]]*\).*')
+}
+
+#
+# Simple divide by 10 routine to cope with one decimal place
+#
+dbt() {
+ local a=$(expr $1 / 10)
+ local b=$(expr $1 % 10)
+ echo "${a}.${b}"
+}
+#
+# Take a number and convert to k or meg
+#
+scale() {
+ local val=$1
+ local a
+ local b
+
+ if [ "$val" -gt 1000000 ]; then
+ a=$(expr $val / 1000)
+ b=$(expr $a % 1000)
+ a=$(expr $a / 1000)
+ printf "%d.%03d Mb" ${a} ${b}
+ elif [ "$val" -gt 1000 ]; then
+ a=$(expr $val / 1000)
+ printf "%d Kb" ${a}
+ else
+ echo "${val} b"
+ fi
+}
+
+#
+# Read the data rates for both directions
+#
+data_rates() {
+ local csg
+ local dru
+ local drd
+ local sdru
+ local sdrd
+
+ csg=$(dsl_cmd g997csg 0 1)
+ drd=$(dsl_val "$csg" ActualDataRate)
+
+ csg=$(dsl_cmd g997csg 0 0)
+ dru=$(dsl_val "$csg" ActualDataRate)
+
+ [ -z "$drd" ] && drd=0
+ [ -z "$dru" ] && dru=0
+
+ sdrd=$(scale $drd)
+ sdru=$(scale $dru)
+
+ if [ "$action" = "lucistat" ]; then
+ echo "dsl.data_rate_down=$drd"
+ echo "dsl.data_rate_up=$dru"
+ echo "dsl.data_rate_down_s=\"$sdrd\""
+ echo "dsl.data_rate_up_s=\"$sdru\""
+ else
+ echo "Data Rate: ${sdrd}/s / ${sdru}/s"
+ fi
+}
+
+#
+# Chipset
+#
+chipset() {
+ local vig
+ local cs
+ local csv
+
+ vig=$(dsl_cmd vig)
+ cs=$(dsl_val "$vig" DSL_ChipSetType)
+ csv=$(dsl_val "$vig" DSL_ChipSetHWVersion)
+
+ if [ "$action" = "lucistat" ]; then
+ echo "dsl.chipset=\"${cs} ${csv}\""
+ else
+ echo "Chipset: ${cs} ${csv}"
+ fi
+}
+
+#
+# Work out how long the line has been up
+#
+line_uptime() {
+ local ccsg
+ local et
+ local etr
+ local d
+ local h
+ local m
+ local s
+ local rc=""
+
+ ccsg=$(dsl_cmd pmccsg 0 0 0)
+ et=$(dsl_val "$ccsg" nElapsedTime)
+
+ [ -z "$et" ] && et=0
+
+ if [ "$action" = "lucistat" ]; then
+ echo "dsl.line_uptime=${et}"
+ return
+ fi
+
+ d=$(expr $et / 86400)
+ etr=$(expr $et % 86400)
+ h=$(expr $etr / 3600)
+ etr=$(expr $etr % 3600)
+ m=$(expr $etr / 60)
+ s=$(expr $etr % 60)
+
+
+ [ "${d}${h}${m}${s}" -ne 0 ] && rc="${s}s"
+ [ "${d}${h}${m}" -ne 0 ] && rc="${m}m ${rc}"
+ [ "${d}${h}" -ne 0 ] && rc="${h}h ${rc}"
+ [ "${d}" -ne 0 ] && rc="${d}d ${rc}"
+
+ [ -z "$rc" ] && rc="down"
+ echo "Line Uptime: ${rc}"
+}
+
+#
+# Get noise and attenuation figures
+#
+line_data() {
+ local lsg
+ local latnu
+ local latnd
+ local snru
+ local snrd
+
+ lsg=$(dsl_cmd g997lsg 1 1)
+ latnd=$(dsl_val "$lsg" LATN)
+ snrd=$(dsl_val "$lsg" SNR)
+
+ lsg=$(dsl_cmd g997lsg 0 1)
+ latnu=$(dsl_val "$lsg" LATN)
+ snru=$(dsl_val "$lsg" SNR)
+
+ [ -z "$latnd" ] && latnd=0
+ [ -z "$latnu" ] && latnu=0
+ [ -z "$snrd" ] && snrd=0
+ [ -z "$snru" ] && snru=0
+
+ latnd=$(dbt $latnd)
+ latnu=$(dbt $latnu)
+ snrd=$(dbt $snrd)
+ snru=$(dbt $snru)
+
+ if [ "$action" = "lucistat" ]; then
+ echo "dsl.line_attenuation_down=$latnd"
+ echo "dsl.line_attenuation_up=$latnu"
+ echo "dsl.noise_margin_down=$snrd"
+ echo "dsl.noise_margin_up=$snru"
+ else
+ echo "Line Attenuation: ${latnd}dB / ${latnu}dB"
+ echo "Noise Margin: ${snrd}dB / ${snru}dB"
+ fi
+}
+
+#
+# Is the line up? Or what state is it in?
+#
+line_state() {
+ local lsg=$(dsl_cmd lsg)
+ local ls=$(dsl_val "$lsg" nLineState);
+ local s;
+
+ case "$ls" in
+ "0x0") s="not initialized" ;;
+ "0x1") s="exception" ;;
+ "0x10") s="not updated" ;;
+ "0xff") s="idle request" ;;
+ "0x100") s="idle" ;;
+ "0x1ff") s="silent request" ;;
+ "0x200") s="silent" ;;
+ "0x300") s="handshake" ;;
+ "0x380") s="full_init" ;;
+ "0x400") s="discovery" ;;
+ "0x500") s="training" ;;
+ "0x600") s="analysis" ;;
+ "0x700") s="exchange" ;;
+ "0x800") s="showtime_no_sync" ;;
+ "0x801") s="showtime_tc_sync" ;;
+ "0x900") s="fastretrain" ;;
+ "0xa00") s="lowpower_l2" ;;
+ "0xb00") s="loopdiagnostic active" ;;
+ "0xb10") s="loopdiagnostic data exchange" ;;
+ "0xb20") s="loopdiagnostic data request" ;;
+ "0xc00") s="loopdiagnostic complete" ;;
+ "0x1000000") s="test" ;;
+ "0xd00") s="resync" ;;
+ "0x3c0") s="short init entry" ;;
+ "") s="not running daemon"; ls="0xfff" ;;
+ *) s="unknown" ;;
+ esac
+
+ if [ $action = "lucistat" ]; then
+ echo "dsl.line_state_num=$ls"
+ echo "dsl.line_state_detail=\"$s\""
+ if [ "$ls" = "0x801" ]; then
+ echo "dsl.line_state=\"UP\""
+ else
+ echo "dsl.line_state=\"DOWN\""
+ fi
+ else
+ if [ "$ls" = "0x801" ]; then
+ echo "Line State: UP [$ls: $s]"
+ else
+ echo "Line State: DOWN [$ls: $s]"
+ fi
+ fi
+}
+
+#
+# Main status routine
+#
+status() {
+ chipset
+ line_state
+ data_rates
+ line_data
+ line_uptime
+}
+
+#
+# Luci (lua) compatible version that's easy to parse
+#
+lucistat() {
+ echo "local dsl={}"
+ status
+ echo "return dsl"
+}
+
+
+annex_b=10_00_10_00_00_04_00_00
+annex_bdmt=10_00_00_00_00_00_00_00
+annex_b2=00_00_10_00_00_00_00_00
+annex_b2p=00_00_00_00_00_04_00_00
+annex_a=04_01_04_00_00_01_00_00
+annex_at1=01_00_00_00_00_00_00_00
+annex_alite=00_01_00_00_00_00_00_00
+annex_admt=04_00_00_00_00_00_00_00
+annex_a2=00_00_04_00_00_00_00_00
+annex_a2p=00_00_00_00_00_01_00_00
+annex_l=00_00_00_00_04_00_00_00
+annex_m=00_00_00_00_40_00_04_00
+annex_m2=00_00_00_00_40_00_00_00
+annex_m2p=00_00_00_00_00_00_04_00
+
+#
+# Simple start routine
+#
+start() {
+ local annex
+ local firmware
+ local xtu
+ config_load network
+ config_get annex wan annex
+ config_get firmware wan firmware
+
+ # get xtu
+ eval "xtu=\"\${annex_$annex}\""
+
+ # check for firmware
+ [ -z "${firmware}" ] &&
+ firmware=adsl.bin
+
+ # start CPE dsl daemon in the background
+ service_start /sbin/dsl_cpe_control -i${xtu} \
+ -n /sbin/dsl_notify.sh \
+ -f /lib/firmware/${firmware}
+}
+
+#
+# For stop we want to simulate the notification call for when
+# the line goes down, so that we can stop the ppp link before
+# we die.
+#
+stop() {
+ DSL_NOTIFICATION_TYPE="DSL_INTERFACE_STATUS" \
+ DSL_INTERFACE_STATUS="DOWN" \
+ /sbin/dsl_notify.sh
+
+ service_stop /sbin/dsl_cpe_control
+}
+
diff --git a/package/platform/lantiq/ltq-adsl-app/files/dsl_notify.sh b/package/platform/lantiq/ltq-adsl-app/files/dsl_notify.sh
new file mode 100644
index 0000000..5e9f396
--- /dev/null
+++ b/package/platform/lantiq/ltq-adsl-app/files/dsl_notify.sh
@@ -0,0 +1,44 @@
+#!/bin/sh
+#
+# This script is called by dsl_cpe_control whenever there is a DSL event,
+# we only actually care about the DSL_INTERFACE_STATUS events as these
+# tell us the line has either come up or gone down.
+#
+# The rest of the code is basically the same at the atm hotplug code
+#
+
+[ "$DSL_NOTIFICATION_TYPE" = "DSL_INTERFACE_STATUS" ] || exit 0
+
+. /lib/functions.sh
+
+include /lib/network
+scan_interfaces
+
+local found=0
+local ifc
+for ifc in $interfaces; do
+ local up
+ config_get_bool up "$ifc" up 0
+
+ local auto
+ config_get_bool auto "$ifc" auto 1
+
+ local proto
+ config_get proto "$ifc" proto
+
+ if [ "$DSL_INTERFACE_STATUS" = "UP" ]; then
+ if [ "$proto" = "pppoa" ] && [ "$up" != 1 ] && [ "$auto" = 1 ]; then
+ found=1
+ ( sleep 1; ifup "$ifc" ) &
+ fi
+ else
+ if [ "$proto" = "pppoa" ] && [ "$up" = 1 ] && [ "$auto" = 1 ]; then
+ found=1
+ ( sleep 1; ifdown "$ifc" ) &
+ fi
+ fi
+done
+
+if [ "$found" != 1 ]; then
+ logger "Found no matching interface for DSL notification ($DSL_INTERFACE_STATUS)"
+fi
diff --git a/package/platform/lantiq/ltq-adsl-fw/.svn/entries b/package/platform/lantiq/ltq-adsl-fw/.svn/entries
new file mode 100644
index 0000000..0fde760
--- /dev/null
+++ b/package/platform/lantiq/ltq-adsl-fw/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/platform/lantiq/ltq-adsl-fw
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-12-21T13:47:30.344360Z
+34819
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+ef4affa51098e25df0358946c3dc703c
+2012-12-21T13:47:30.344360Z
+34819
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1933
+
diff --git a/package/platform/lantiq/ltq-adsl-fw/.svn/text-base/Makefile.svn-base b/package/platform/lantiq/ltq-adsl-fw/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..53d223b
--- /dev/null
+++ b/package/platform/lantiq/ltq-adsl-fw/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,55 @@
+#
+# Copyright (C) 2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=ltq-adsl-fw
+PKG_VERSION:=0.1
+PKG_RELEASE:=1
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/ltq-dsl-fw-$(PKG_VERSION)
+PKG_SOURCE:=ltq-dsl-fw-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=http://mirror2.openwrt.org/sources/
+PKG_MD5SUM:=4700a36b66b955b4c5544227267356f4
+PKG_MAINTAINER:=John Crispin <blogic@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/kmod-ltq-adsl-fw-template
+ TITLE+=Firmware Annex-$(1) $(2)
+ SECTION:=sys
+ CATEGORY:=Kernel modules
+ SUBMENU:=Network Devices
+ VARIANT:= $(2)-fw-$(1)
+ SOC:=$(2)
+ ANNEX:=$(1)
+ URL:=http://www.lantiq.com/
+ DEPENDS:=@TARGET_lantiq_$(3) +kmod-ltq-adsl-$(2)
+endef
+
+Package/kmod-ltq-adsl-danube-fw-a=$(call Package/kmod-ltq-adsl-fw-template,a,danube,xway)
+Package/kmod-ltq-adsl-danube-fw-b=$(call Package/kmod-ltq-adsl-fw-template,b,danube,xway)
+Package/kmod-ltq-adsl-ar9-fw-a=$(call Package/kmod-ltq-adsl-fw-template,a,ar9,xway)
+Package/kmod-ltq-adsl-ar9-fw-b=$(call Package/kmod-ltq-adsl-fw-template,b,ar9,xway)
+Package/kmod-ltq-adsl-ase-fw-a=$(call Package/kmod-ltq-adsl-fw-template,a,ase,ase)
+Package/kmod-ltq-adsl-ase-fw-b=$(call Package/kmod-ltq-adsl-fw-template,b,ase,ase)
+
+define Build/Compile
+endef
+
+define Package/kmod-ltq-adsl-$(BUILD_VARIANT)/install
+ $(INSTALL_DIR) $(1)/lib/firmware/
+ $(CP) $(PKG_BUILD_DIR)/$(FW_NAME)/ltq-dsl-fw-$(ANNEX)-$(SOC).bin $(1)/lib/firmware/
+ ln -s /lib/firmware/$(FW_NAME)/ltq-dsl-fw-$(ANNEX)-$(SOC).bin $(1)/lib/firmware/adsl.bin
+endef
+
+$(eval $(call BuildPackage,kmod-ltq-adsl-danube-fw-a))
+$(eval $(call BuildPackage,kmod-ltq-adsl-danube-fw-b))
+$(eval $(call BuildPackage,kmod-ltq-adsl-ase-fw-a))
+$(eval $(call BuildPackage,kmod-ltq-adsl-ase-fw-b))
+$(eval $(call BuildPackage,kmod-ltq-adsl-ar9-fw-a))
+$(eval $(call BuildPackage,kmod-ltq-adsl-ar9-fw-b))
diff --git a/package/platform/lantiq/ltq-adsl-fw/Makefile b/package/platform/lantiq/ltq-adsl-fw/Makefile
new file mode 100644
index 0000000..53d223b
--- /dev/null
+++ b/package/platform/lantiq/ltq-adsl-fw/Makefile
@@ -0,0 +1,55 @@
+#
+# Copyright (C) 2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=ltq-adsl-fw
+PKG_VERSION:=0.1
+PKG_RELEASE:=1
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/ltq-dsl-fw-$(PKG_VERSION)
+PKG_SOURCE:=ltq-dsl-fw-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=http://mirror2.openwrt.org/sources/
+PKG_MD5SUM:=4700a36b66b955b4c5544227267356f4
+PKG_MAINTAINER:=John Crispin <blogic@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/kmod-ltq-adsl-fw-template
+ TITLE+=Firmware Annex-$(1) $(2)
+ SECTION:=sys
+ CATEGORY:=Kernel modules
+ SUBMENU:=Network Devices
+ VARIANT:= $(2)-fw-$(1)
+ SOC:=$(2)
+ ANNEX:=$(1)
+ URL:=http://www.lantiq.com/
+ DEPENDS:=@TARGET_lantiq_$(3) +kmod-ltq-adsl-$(2)
+endef
+
+Package/kmod-ltq-adsl-danube-fw-a=$(call Package/kmod-ltq-adsl-fw-template,a,danube,xway)
+Package/kmod-ltq-adsl-danube-fw-b=$(call Package/kmod-ltq-adsl-fw-template,b,danube,xway)
+Package/kmod-ltq-adsl-ar9-fw-a=$(call Package/kmod-ltq-adsl-fw-template,a,ar9,xway)
+Package/kmod-ltq-adsl-ar9-fw-b=$(call Package/kmod-ltq-adsl-fw-template,b,ar9,xway)
+Package/kmod-ltq-adsl-ase-fw-a=$(call Package/kmod-ltq-adsl-fw-template,a,ase,ase)
+Package/kmod-ltq-adsl-ase-fw-b=$(call Package/kmod-ltq-adsl-fw-template,b,ase,ase)
+
+define Build/Compile
+endef
+
+define Package/kmod-ltq-adsl-$(BUILD_VARIANT)/install
+ $(INSTALL_DIR) $(1)/lib/firmware/
+ $(CP) $(PKG_BUILD_DIR)/$(FW_NAME)/ltq-dsl-fw-$(ANNEX)-$(SOC).bin $(1)/lib/firmware/
+ ln -s /lib/firmware/$(FW_NAME)/ltq-dsl-fw-$(ANNEX)-$(SOC).bin $(1)/lib/firmware/adsl.bin
+endef
+
+$(eval $(call BuildPackage,kmod-ltq-adsl-danube-fw-a))
+$(eval $(call BuildPackage,kmod-ltq-adsl-danube-fw-b))
+$(eval $(call BuildPackage,kmod-ltq-adsl-ase-fw-a))
+$(eval $(call BuildPackage,kmod-ltq-adsl-ase-fw-b))
+$(eval $(call BuildPackage,kmod-ltq-adsl-ar9-fw-a))
+$(eval $(call BuildPackage,kmod-ltq-adsl-ar9-fw-b))
diff --git a/package/platform/lantiq/ltq-adsl-mei/.svn/entries b/package/platform/lantiq/ltq-adsl-mei/.svn/entries
new file mode 100644
index 0000000..7a3db05
--- /dev/null
+++ b/package/platform/lantiq/ltq-adsl-mei/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/platform/lantiq/ltq-adsl-mei
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-14T18:42:38.226997Z
+36015
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+src
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+098440d44cb0457698e3913e3d6c9e43
+2012-12-15T02:00:33.317354Z
+34693
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1406
+
diff --git a/package/platform/lantiq/ltq-adsl-mei/.svn/text-base/Makefile.svn-base b/package/platform/lantiq/ltq-adsl-mei/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..790b891
--- /dev/null
+++ b/package/platform/lantiq/ltq-adsl-mei/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,49 @@
+# Copyright (C) 2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=ltq-adsl-mei
+PKG_RELEASE:=1
+PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/ltq-adsl-mei-$(BUILD_VARIANT)/
+
+PKG_MAINTAINER:=John Crispin <blogic@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/ltq-adsl-mei-template
+ SECTION:=sys
+ CATEGORY:=Kernel modules
+ SUBMENU:=Network Devices
+ TITLE:=mei driver for $(1)
+ URL:=http://www.lantiq.com/
+ VARIANT:=$(1)
+ DEPENDS:=@TARGET_lantiq_$(2)
+ FILES:=$(PKG_BUILD_DIR)/ltq_mei_$(1).ko
+ AUTOLOAD:=$(call AutoLoad,50,ltq_mei_$(1))
+endef
+
+KernelPackage/ltq-adsl-danube-mei=$(call KernelPackage/ltq-adsl-mei-template,danube,xway)
+KernelPackage/ltq-adsl-ar9-mei=$(call KernelPackage/ltq-adsl-mei-template,ar9,xway)
+KernelPackage/ltq-adsl-ase-mei=$(call KernelPackage/ltq-adsl-mei-template,ase,ase)
+
+define Build/Prepare
+ $(INSTALL_DIR) $(PKG_BUILD_DIR)/
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+ cd $(LINUX_DIR); \
+ ARCH=mips CROSS_COMPILE="$(KERNEL_CROSS)" \
+ $(MAKE) BUILD_VARIANT=$(BUILD_VARIANT) M=$(PKG_BUILD_DIR)/ V=1 modules
+endef
+
+$(eval $(call KernelPackage,ltq-adsl-danube-mei))
+$(eval $(call KernelPackage,ltq-adsl-ase-mei))
+$(eval $(call KernelPackage,ltq-adsl-ar9-mei))
diff --git a/package/platform/lantiq/ltq-adsl-mei/Makefile b/package/platform/lantiq/ltq-adsl-mei/Makefile
new file mode 100644
index 0000000..790b891
--- /dev/null
+++ b/package/platform/lantiq/ltq-adsl-mei/Makefile
@@ -0,0 +1,49 @@
+# Copyright (C) 2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=ltq-adsl-mei
+PKG_RELEASE:=1
+PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/ltq-adsl-mei-$(BUILD_VARIANT)/
+
+PKG_MAINTAINER:=John Crispin <blogic@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/ltq-adsl-mei-template
+ SECTION:=sys
+ CATEGORY:=Kernel modules
+ SUBMENU:=Network Devices
+ TITLE:=mei driver for $(1)
+ URL:=http://www.lantiq.com/
+ VARIANT:=$(1)
+ DEPENDS:=@TARGET_lantiq_$(2)
+ FILES:=$(PKG_BUILD_DIR)/ltq_mei_$(1).ko
+ AUTOLOAD:=$(call AutoLoad,50,ltq_mei_$(1))
+endef
+
+KernelPackage/ltq-adsl-danube-mei=$(call KernelPackage/ltq-adsl-mei-template,danube,xway)
+KernelPackage/ltq-adsl-ar9-mei=$(call KernelPackage/ltq-adsl-mei-template,ar9,xway)
+KernelPackage/ltq-adsl-ase-mei=$(call KernelPackage/ltq-adsl-mei-template,ase,ase)
+
+define Build/Prepare
+ $(INSTALL_DIR) $(PKG_BUILD_DIR)/
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+ cd $(LINUX_DIR); \
+ ARCH=mips CROSS_COMPILE="$(KERNEL_CROSS)" \
+ $(MAKE) BUILD_VARIANT=$(BUILD_VARIANT) M=$(PKG_BUILD_DIR)/ V=1 modules
+endef
+
+$(eval $(call KernelPackage,ltq-adsl-danube-mei))
+$(eval $(call KernelPackage,ltq-adsl-ase-mei))
+$(eval $(call KernelPackage,ltq-adsl-ar9-mei))
diff --git a/package/platform/lantiq/ltq-adsl-mei/src/.svn/entries b/package/platform/lantiq/ltq-adsl-mei/src/.svn/entries
new file mode 100644
index 0000000..ec113cb
--- /dev/null
+++ b/package/platform/lantiq/ltq-adsl-mei/src/.svn/entries
@@ -0,0 +1,130 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/platform/lantiq/ltq-adsl-mei/src
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-14T18:42:38.226997Z
+36015
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+ifxmips_mei_interface.h
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+16dff76185ea728bfa41823f23637692
+2012-12-15T02:00:33.317354Z
+34693
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+21931
+
+lantiq_mei.c
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+3540bf9d10ebf8ab496d48b9c6afe85b
+2013-03-14T18:42:38.226997Z
+36015
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+80262
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+a357954403da4749150a7a040cbbae13
+2012-12-15T02:00:33.317354Z
+34693
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+476
+
diff --git a/package/platform/lantiq/ltq-adsl-mei/src/.svn/text-base/Makefile.svn-base b/package/platform/lantiq/ltq-adsl-mei/src/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..2d8645f
--- /dev/null
+++ b/package/platform/lantiq/ltq-adsl-mei/src/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,17 @@
+ifeq ($(BUILD_VARIANT),danube)
+ CFLAGS_MODULE = -DCONFIG_DANUBE -DCONFIG_IFXMIPS_DSL_CPE_MEI
+ obj-m = ltq_mei_danube.o
+ ltq_mei_danube-objs = lantiq_mei.o
+endif
+
+ifeq ($(BUILD_VARIANT),ase)
+ CFLAGS_MODULE = -DCONFIG_AMAZON_SE -DCONFIG_IFXMIPS_DSL_CPE_MEI
+ obj-m = ltq_mei_ase.o
+ ltq_mei_ase-objs = lantiq_mei.o
+endif
+
+ifeq ($(BUILD_VARIANT),ar9)
+ CFLAGS_MODULE = -DCONFIG_AR9 -DCONFIG_IFXMIPS_DSL_CPE_MEI
+ obj-m = ltq_mei_ar9.o
+ ltq_mei_ar9-objs = lantiq_mei.o
+endif
diff --git a/package/platform/lantiq/ltq-adsl-mei/src/.svn/text-base/ifxmips_mei_interface.h.svn-base b/package/platform/lantiq/ltq-adsl-mei/src/.svn/text-base/ifxmips_mei_interface.h.svn-base
new file mode 100644
index 0000000..4ddc4c6
--- /dev/null
+++ b/package/platform/lantiq/ltq-adsl-mei/src/.svn/text-base/ifxmips_mei_interface.h.svn-base
@@ -0,0 +1,702 @@
+/******************************************************************************
+
+ Copyright (c) 2009
+ Infineon Technologies AG
+ Am Campeon 1-12; 81726 Munich, Germany
+
+ For licensing information, see the file 'LICENSE' in the root folder of
+ this software module.
+
+******************************************************************************/
+
+#ifndef IFXMIPS_MEI_H
+#define IFXMIPS_MEI_H
+
+//#define CONFIG_AMAZON_SE 1
+//#define CONFIG_DANUBE 1
+//#define CONFIG_AR9 1
+
+#if !defined(CONFIG_DANUBE) && !defined(CONFIG_AMAZON_SE) && !defined(CONFIG_AR9) && !defined(CONFIG_VR9)
+#error Platform undefined!!!
+#endif
+
+#ifdef IFX_MEI_BSP
+/** This is the character datatype. */
+typedef char DSL_char_t;
+/** This is the unsigned 8-bit datatype. */
+typedef unsigned char DSL_uint8_t;
+/** This is the signed 8-bit datatype. */
+typedef signed char DSL_int8_t;
+/** This is the unsigned 16-bit datatype. */
+typedef unsigned short DSL_uint16_t;
+/** This is the signed 16-bit datatype. */
+typedef signed short DSL_int16_t;
+/** This is the unsigned 32-bit datatype. */
+typedef unsigned long DSL_uint32_t;
+/** This is the signed 32-bit datatype. */
+typedef signed long DSL_int32_t;
+/** This is the float datatype. */
+typedef float DSL_float_t;
+/** This is the void datatype. */
+typedef void DSL_void_t;
+/** integer type, width is depending on processor arch */
+typedef int DSL_int_t;
+/** unsigned integer type, width is depending on processor arch */
+typedef unsigned int DSL_uint_t;
+typedef struct file DSL_DRV_file_t;
+typedef struct inode DSL_DRV_inode_t;
+
+/**
+ * Defines all possible CMV groups
+ * */
+typedef enum {
+ DSL_CMV_GROUP_CNTL = 1,
+ DSL_CMV_GROUP_STAT = 2,
+ DSL_CMV_GROUP_INFO = 3,
+ DSL_CMV_GROUP_TEST = 4,
+ DSL_CMV_GROUP_OPTN = 5,
+ DSL_CMV_GROUP_RATE = 6,
+ DSL_CMV_GROUP_PLAM = 7,
+ DSL_CMV_GROUP_CNFG = 8
+} DSL_CmvGroup_t;
+/**
+ * Defines all opcode types
+ * */
+typedef enum {
+ H2D_CMV_READ = 0x00,
+ H2D_CMV_WRITE = 0x04,
+ H2D_CMV_INDICATE_REPLY = 0x10,
+ H2D_ERROR_OPCODE_UNKNOWN =0x20,
+ H2D_ERROR_CMV_UNKNOWN =0x30,
+
+ D2H_CMV_READ_REPLY =0x01,
+ D2H_CMV_WRITE_REPLY = 0x05,
+ D2H_CMV_INDICATE = 0x11,
+ D2H_ERROR_OPCODE_UNKNOWN = 0x21,
+ D2H_ERROR_CMV_UNKNOWN = 0x31,
+ D2H_ERROR_CMV_READ_NOT_AVAILABLE = 0x41,
+ D2H_ERROR_CMV_WRITE_ONLY = 0x51,
+ D2H_ERROR_CMV_READ_ONLY = 0x61,
+
+ H2D_DEBUG_READ_DM = 0x02,
+ H2D_DEBUG_READ_PM = 0x06,
+ H2D_DEBUG_WRITE_DM = 0x0a,
+ H2D_DEBUG_WRITE_PM = 0x0e,
+
+ D2H_DEBUG_READ_DM_REPLY = 0x03,
+ D2H_DEBUG_READ_FM_REPLY = 0x07,
+ D2H_DEBUG_WRITE_DM_REPLY = 0x0b,
+ D2H_DEBUG_WRITE_FM_REPLY = 0x0f,
+ D2H_ERROR_ADDR_UNKNOWN = 0x33,
+
+ D2H_AUTONOMOUS_MODEM_READY_MSG = 0xf1
+} DSL_CmvOpcode_t;
+
+/* mutex macros */
+#define MEI_MUTEX_INIT(id,flag) \
+ sema_init(&id,flag)
+#define MEI_MUTEX_LOCK(id) \
+ down_interruptible(&id)
+#define MEI_MUTEX_UNLOCK(id) \
+ up(&id)
+#define MEI_WAIT(ms) \
+ {\
+ set_current_state(TASK_INTERRUPTIBLE);\
+ schedule_timeout(ms);\
+ }
+#define MEI_INIT_WAKELIST(name,queue) \
+ init_waitqueue_head(&queue)
+
+/* wait for an event, timeout is measured in ms */
+#define MEI_WAIT_EVENT_TIMEOUT(ev,timeout)\
+ interruptible_sleep_on_timeout(&ev,timeout * HZ / 1000)
+#define MEI_WAKEUP_EVENT(ev)\
+ wake_up_interruptible(&ev)
+#endif /* IFX_MEI_BSP */
+
+/*** Register address offsets, relative to MEI_SPACE_ADDRESS ***/
+#define ME_DX_DATA (0x0000)
+#define ME_VERSION (0x0004)
+#define ME_ARC_GP_STAT (0x0008)
+#define ME_DX_STAT (0x000C)
+#define ME_DX_AD (0x0010)
+#define ME_DX_MWS (0x0014)
+#define ME_ME2ARC_INT (0x0018)
+#define ME_ARC2ME_STAT (0x001C)
+#define ME_ARC2ME_MASK (0x0020)
+#define ME_DBG_WR_AD (0x0024)
+#define ME_DBG_RD_AD (0x0028)
+#define ME_DBG_DATA (0x002C)
+#define ME_DBG_DECODE (0x0030)
+#define ME_CONFIG (0x0034)
+#define ME_RST_CTRL (0x0038)
+#define ME_DBG_MASTER (0x003C)
+#define ME_CLK_CTRL (0x0040)
+#define ME_BIST_CTRL (0x0044)
+#define ME_BIST_STAT (0x0048)
+#define ME_XDATA_BASE_SH (0x004c)
+#define ME_XDATA_BASE (0x0050)
+#define ME_XMEM_BAR_BASE (0x0054)
+#define ME_XMEM_BAR0 (0x0054)
+#define ME_XMEM_BAR1 (0x0058)
+#define ME_XMEM_BAR2 (0x005C)
+#define ME_XMEM_BAR3 (0x0060)
+#define ME_XMEM_BAR4 (0x0064)
+#define ME_XMEM_BAR5 (0x0068)
+#define ME_XMEM_BAR6 (0x006C)
+#define ME_XMEM_BAR7 (0x0070)
+#define ME_XMEM_BAR8 (0x0074)
+#define ME_XMEM_BAR9 (0x0078)
+#define ME_XMEM_BAR10 (0x007C)
+#define ME_XMEM_BAR11 (0x0080)
+#define ME_XMEM_BAR12 (0x0084)
+#define ME_XMEM_BAR13 (0x0088)
+#define ME_XMEM_BAR14 (0x008C)
+#define ME_XMEM_BAR15 (0x0090)
+#define ME_XMEM_BAR16 (0x0094)
+
+#define WHILE_DELAY 20000
+/*
+** Define where in ME Processor's memory map the Stratify chip lives
+*/
+
+#define MAXSWAPSIZE (8 * 1024) //8k *(32bits)
+
+// Mailboxes
+#define MSG_LENGTH 16 // x16 bits
+#define YES_REPLY 1
+#define NO_REPLY 0
+
+#define CMV_TIMEOUT 1000 //jiffies
+
+// Block size per BAR
+#define SDRAM_SEGMENT_SIZE (64*1024)
+// Number of Bar registers
+#define MAX_BAR_REGISTERS (17)
+
+#define XDATA_REGISTER (15)
+
+// ARC register addresss
+#define ARC_STATUS 0x0
+#define ARC_LP_START 0x2
+#define ARC_LP_END 0x3
+#define ARC_DEBUG 0x5
+#define ARC_INT_MASK 0x10A
+
+#define IRAM0_BASE (0x00000)
+#define IRAM1_BASE (0x04000)
+#if defined(CONFIG_DANUBE)
+#define BRAM_BASE (0x0A000)
+#elif defined(CONFIG_AMAZON_SE) || defined(CONFIG_AR9) || defined(CONFIG_VR9)
+#define BRAM_BASE (0x08000)
+#endif
+#define XRAM_BASE (0x18000)
+#define YRAM_BASE (0x1A000)
+#define EXT_MEM_BASE (0x80000)
+#define ARC_GPIO_CTRL (0xC030)
+#define ARC_GPIO_DATA (0xC034)
+
+#define IRAM0_SIZE (16*1024)
+#define IRAM1_SIZE (16*1024)
+#define BRAM_SIZE (12*1024)
+#define XRAM_SIZE (8*1024)
+#define YRAM_SIZE (8*1024)
+#define EXT_MEM_SIZE (1536*1024)
+
+#define ADSL_BASE (0x20000)
+#define CRI_BASE (ADSL_BASE + 0x11F00)
+#define CRI_CCR0 (CRI_BASE + 0x00)
+#define CRI_RST (CRI_BASE + 0x04*4)
+#define ADSL_DILV_BASE (ADSL_BASE+0x20000)
+
+//
+#define IRAM0_ADDR_BIT_MASK 0xFFF
+#define IRAM1_ADDR_BIT_MASK 0xFFF
+#define BRAM_ADDR_BIT_MASK 0xFFF
+#define RX_DILV_ADDR_BIT_MASK 0x1FFF
+
+/*** Bit definitions ***/
+#define ARC_AUX_HALT (1 << 25)
+#define ARC_DEBUG_HALT (1 << 1)
+#define FALSE 0
+#define TRUE 1
+#define BIT0 (1<<0)
+#define BIT1 (1<<1)
+#define BIT2 (1<<2)
+#define BIT3 (1<<3)
+#define BIT4 (1<<4)
+#define BIT5 (1<<5)
+#define BIT6 (1<<6)
+#define BIT7 (1<<7)
+#define BIT8 (1<<8)
+#define BIT9 (1<<9)
+#define BIT10 (1<<10)
+#define BIT11 (1<<11)
+#define BIT12 (1<<12)
+#define BIT13 (1<<13)
+#define BIT14 (1<<14)
+#define BIT15 (1<<15)
+#define BIT16 (1<<16)
+#define BIT17 (1<<17)
+#define BIT18 (1<<18)
+#define BIT19 (1<<19)
+#define BIT20 (1<<20)
+#define BIT21 (1<<21)
+#define BIT22 (1<<22)
+#define BIT23 (1<<23)
+#define BIT24 (1<<24)
+#define BIT25 (1<<25)
+#define BIT26 (1<<26)
+#define BIT27 (1<<27)
+#define BIT28 (1<<28)
+#define BIT29 (1<<29)
+#define BIT30 (1<<30)
+#define BIT31 (1<<31)
+
+// CRI_CCR0 Register definitions
+#define CLK_2M_MODE_ENABLE BIT6
+#define ACL_CLK_MODE_ENABLE BIT4
+#define FDF_CLK_MODE_ENABLE BIT2
+#define STM_CLK_MODE_ENABLE BIT0
+
+// CRI_RST Register definitions
+#define FDF_SRST BIT3
+#define MTE_SRST BIT2
+#define FCI_SRST BIT1
+#define AAI_SRST BIT0
+
+// MEI_TO_ARC_INTERRUPT Register definitions
+#define MEI_TO_ARC_INT1 BIT3
+#define MEI_TO_ARC_INT0 BIT2
+#define MEI_TO_ARC_CS_DONE BIT1 //need to check
+#define MEI_TO_ARC_MSGAV BIT0
+
+// ARC_TO_MEI_INTERRUPT Register definitions
+#define ARC_TO_MEI_INT1 BIT8
+#define ARC_TO_MEI_INT0 BIT7
+#define ARC_TO_MEI_CS_REQ BIT6
+#define ARC_TO_MEI_DBG_DONE BIT5
+#define ARC_TO_MEI_MSGACK BIT4
+#define ARC_TO_MEI_NO_ACCESS BIT3
+#define ARC_TO_MEI_CHECK_AAITX BIT2
+#define ARC_TO_MEI_CHECK_AAIRX BIT1
+#define ARC_TO_MEI_MSGAV BIT0
+
+// ARC_TO_MEI_INTERRUPT_MASK Register definitions
+#define GP_INT1_EN BIT8
+#define GP_INT0_EN BIT7
+#define CS_REQ_EN BIT6
+#define DBG_DONE_EN BIT5
+#define MSGACK_EN BIT4
+#define NO_ACC_EN BIT3
+#define AAITX_EN BIT2
+#define AAIRX_EN BIT1
+#define MSGAV_EN BIT0
+
+#define MEI_SOFT_RESET BIT0
+
+#define HOST_MSTR BIT0
+
+#define JTAG_MASTER_MODE 0x0
+#define MEI_MASTER_MODE HOST_MSTR
+
+// MEI_DEBUG_DECODE Register definitions
+#define MEI_DEBUG_DEC_MASK (0x3)
+#define MEI_DEBUG_DEC_AUX_MASK (0x0)
+#define ME_DBG_DECODE_DMP1_MASK (0x1)
+#define MEI_DEBUG_DEC_DMP2_MASK (0x2)
+#define MEI_DEBUG_DEC_CORE_MASK (0x3)
+
+#define AUX_STATUS (0x0)
+#define AUX_ARC_GPIO_CTRL (0x10C)
+#define AUX_ARC_GPIO_DATA (0x10D)
+// ARC_TO_MEI_MAILBOX[11] is a special location used to indicate
+// page swap requests.
+#if defined(CONFIG_DANUBE)
+#define OMBOX_BASE 0xDF80
+#define ARC_TO_MEI_MAILBOX 0xDFA0
+#define IMBOX_BASE 0xDFC0
+#define MEI_TO_ARC_MAILBOX 0xDFD0
+#elif defined(CONFIG_AMAZON_SE) || defined(CONFIG_AR9) || defined(CONFIG_VR9)
+#define OMBOX_BASE 0xAF80
+#define ARC_TO_MEI_MAILBOX 0xAFA0
+#define IMBOX_BASE 0xAFC0
+#define MEI_TO_ARC_MAILBOX 0xAFD0
+#endif
+
+#define MEI_TO_ARC_MAILBOXR (MEI_TO_ARC_MAILBOX + 0x2C)
+#define ARC_MEI_MAILBOXR (ARC_TO_MEI_MAILBOX + 0x2C)
+#define OMBOX1 (OMBOX_BASE+0x4)
+
+// Codeswap request messages are indicated by setting BIT31
+#define OMB_CODESWAP_MESSAGE_MSG_TYPE_MASK (0x80000000)
+
+// Clear Eoc messages received are indicated by setting BIT17
+#define OMB_CLEAREOC_INTERRUPT_CODE (0x00020000)
+#define OMB_REBOOT_INTERRUPT_CODE (1 << 18)
+
+/*
+** Swap page header
+*/
+// Page must be loaded at boot time if size field has BIT31 set
+#define BOOT_FLAG (BIT31)
+#define BOOT_FLAG_MASK ~BOOT_FLAG
+
+#define FREE_RELOAD 1
+#define FREE_SHOWTIME 2
+#define FREE_ALL 3
+
+// marcos
+#define IFX_MEI_WRITE_REGISTER_L(data,addr) *((volatile u32*)(addr)) = (u32)(data)
+#define IFX_MEI_READ_REGISTER_L(addr) (*((volatile u32*)(addr)))
+#define SET_BIT(reg, mask) reg |= (mask)
+#define CLEAR_BIT(reg, mask) reg &= (~mask)
+#define CLEAR_BITS(reg, mask) CLEAR_BIT(reg, mask)
+//#define SET_BITS(reg, mask) SET_BIT(reg, mask)
+#define SET_BITFIELD(reg, mask, off, val) {reg &= (~mask); reg |= (val << off);}
+
+#define ALIGN_SIZE ( 1L<<10 ) //1K size align
+#define MEM_ALIGN(addr) (((addr) + ALIGN_SIZE - 1) & ~ (ALIGN_SIZE -1) )
+
+// swap marco
+#define MEI_HALF_WORD_SWAP(data) {data = ((data & 0xffff)<<16) + ((data & 0xffff0000)>>16);}
+#define MEI_BYTE_SWAP(data) {data = ((data & 0xff)<<24) + ((data & 0xff00)<<8)+ ((data & 0xff0000)>>8)+ ((data & 0xff000000)>>24);}
+
+
+#ifdef CONFIG_PROC_FS
+typedef struct reg_entry
+{
+ int *flag;
+ char name[30]; /* big enough to hold names */
+ char description[100]; /* big enough to hold description */
+ unsigned short low_ino;
+} reg_entry_t;
+#endif
+// Swap page header describes size in 32-bit words, load location, and image offset
+// for program and/or data segments
+typedef struct _arc_swp_page_hdr {
+ u32 p_offset; //Offset bytes of progseg from beginning of image
+ u32 p_dest; //Destination addr of progseg on processor
+ u32 p_size; //Size in 32-bitwords of program segment
+ u32 d_offset; //Offset bytes of dataseg from beginning of image
+ u32 d_dest; //Destination addr of dataseg on processor
+ u32 d_size; //Size in 32-bitwords of data segment
+} ARC_SWP_PAGE_HDR;
+
+/*
+** Swap image header
+*/
+#define GET_PROG 0 // Flag used for program mem segment
+#define GET_DATA 1 // Flag used for data mem segment
+
+// Image header contains size of image, checksum for image, and count of
+// page headers. Following that are 'count' page headers followed by
+// the code and/or data segments to be loaded
+typedef struct _arc_img_hdr {
+ u32 size; // Size of binary image in bytes
+ u32 checksum; // Checksum for image
+ u32 count; // Count of swp pages in image
+ ARC_SWP_PAGE_HDR page[1]; // Should be "count" pages - '1' to make compiler happy
+} ARC_IMG_HDR;
+
+typedef struct smmu_mem_info {
+ int type;
+ int boot;
+ unsigned long nCopy;
+ unsigned long size;
+ unsigned char *address;
+ unsigned char *org_address;
+} smmu_mem_info_t;
+
+#ifdef __KERNEL__
+typedef struct ifx_mei_device_private {
+ int modem_ready;
+ int arcmsgav;
+ int cmv_reply;
+ int cmv_waiting;
+ // Mei to ARC CMV count, reply count, ARC Indicator count
+ int modem_ready_cnt;
+ int cmv_count;
+ int reply_count;
+ unsigned long image_size;
+ int nBar;
+ u16 Recent_indicator[MSG_LENGTH];
+
+ u16 CMV_RxMsg[MSG_LENGTH] __attribute__ ((aligned (4)));
+
+ smmu_mem_info_t adsl_mem_info[MAX_BAR_REGISTERS];
+ ARC_IMG_HDR *img_hdr;
+ // to wait for arc cmv reply, sleep on wait_queue_arcmsgav;
+ wait_queue_head_t wait_queue_arcmsgav;
+ wait_queue_head_t wait_queue_modemready;
+ struct semaphore mei_cmv_sema;
+} ifx_mei_device_private_t;
+#endif
+typedef struct winhost_message {
+ union {
+ u16 RxMessage[MSG_LENGTH] __attribute__ ((aligned (4)));
+ u16 TxMessage[MSG_LENGTH] __attribute__ ((aligned (4)));
+ } msg;
+} DSL_DEV_WinHost_Message_t;
+/********************************************************************************************************
+ * DSL CPE API Driver Stack Interface Definitions
+ * *****************************************************************************************************/
+/** IOCTL codes for bsp driver */
+#define DSL_IOC_MEI_BSP_MAGIC 's'
+
+#define DSL_FIO_BSP_DSL_START _IO (DSL_IOC_MEI_BSP_MAGIC, 0)
+#define DSL_FIO_BSP_RUN _IO (DSL_IOC_MEI_BSP_MAGIC, 1)
+#define DSL_FIO_BSP_FREE_RESOURCE _IO (DSL_IOC_MEI_BSP_MAGIC, 2)
+#define DSL_FIO_BSP_RESET _IO (DSL_IOC_MEI_BSP_MAGIC, 3)
+#define DSL_FIO_BSP_REBOOT _IO (DSL_IOC_MEI_BSP_MAGIC, 4)
+#define DSL_FIO_BSP_HALT _IO (DSL_IOC_MEI_BSP_MAGIC, 5)
+#define DSL_FIO_BSP_BOOTDOWNLOAD _IO (DSL_IOC_MEI_BSP_MAGIC, 6)
+#define DSL_FIO_BSP_JTAG_ENABLE _IO (DSL_IOC_MEI_BSP_MAGIC, 7)
+#define DSL_FIO_FREE_RESOURCE _IO (DSL_IOC_MEI_BSP_MAGIC, 8)
+#define DSL_FIO_ARC_MUX_TEST _IO (DSL_IOC_MEI_BSP_MAGIC, 9)
+#define DSL_FIO_BSP_REMOTE _IOW (DSL_IOC_MEI_BSP_MAGIC, 10, u32)
+#define DSL_FIO_BSP_GET_BASE_ADDRESS _IOR (DSL_IOC_MEI_BSP_MAGIC, 11, u32)
+#define DSL_FIO_BSP_IS_MODEM_READY _IOR (DSL_IOC_MEI_BSP_MAGIC, 12, u32)
+#define DSL_FIO_BSP_GET_VERSION _IOR (DSL_IOC_MEI_BSP_MAGIC, 13, DSL_DEV_Version_t)
+#define DSL_FIO_BSP_CMV_WINHOST _IOWR(DSL_IOC_MEI_BSP_MAGIC, 14, DSL_DEV_WinHost_Message_t)
+#define DSL_FIO_BSP_CMV_READ _IOWR(DSL_IOC_MEI_BSP_MAGIC, 15, DSL_DEV_MeiReg_t)
+#define DSL_FIO_BSP_CMV_WRITE _IOW (DSL_IOC_MEI_BSP_MAGIC, 16, DSL_DEV_MeiReg_t)
+#define DSL_FIO_BSP_DEBUG_READ _IOWR(DSL_IOC_MEI_BSP_MAGIC, 17, DSL_DEV_MeiDebug_t)
+#define DSL_FIO_BSP_DEBUG_WRITE _IOWR(DSL_IOC_MEI_BSP_MAGIC, 18, DSL_DEV_MeiDebug_t)
+#define DSL_FIO_BSP_GET_CHIP_INFO _IOR (DSL_IOC_MEI_BSP_MAGIC, 19, DSL_DEV_HwVersion_t)
+
+#define DSL_DEV_MEIDEBUG_BUFFER_SIZES 512
+
+typedef struct DSL_DEV_MeiDebug
+{
+ DSL_uint32_t iAddress;
+ DSL_uint32_t iCount;
+ DSL_uint32_t buffer[DSL_DEV_MEIDEBUG_BUFFER_SIZES];
+} DSL_DEV_MeiDebug_t; /* meidebug */
+
+/**
+ * Structure is used for debug access only.
+ * Refer to configure option INCLUDE_ADSL_WINHOST_DEBUG */
+typedef struct struct_meireg
+{
+ /*
+ * Specifies that address for debug access */
+ unsigned long iAddress;
+ /*
+ * Specifies the pointer to the data that has to be written or returns a
+ * pointer to the data that has been read out*/
+ unsigned long iData;
+} DSL_DEV_MeiReg_t; /* meireg */
+
+typedef struct DSL_DEV_Device
+{
+ DSL_int_t nInUse; /* modem state, update by bsp driver, */
+ DSL_void_t *pPriv;
+ DSL_uint32_t base_address; /* mei base address */
+ DSL_int_t nIrq[2]; /* irq number */
+#define IFX_DFEIR 0
+#define IFX_DYING_GASP 1
+ DSL_DEV_MeiDebug_t lop_debugwr; /* dying gasp */
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,0))
+ struct module *owner;
+#endif
+} DSL_DEV_Device_t; /* ifx_adsl_device_t */
+
+#define DSL_DEV_PRIVATE(dev) ((ifx_mei_device_private_t*)(dev->pPriv))
+
+typedef struct DSL_DEV_Version /* ifx_adsl_bsp_version */
+{
+ unsigned long major;
+ unsigned long minor;
+ unsigned long revision;
+} DSL_DEV_Version_t; /* ifx_adsl_bsp_version_t */
+
+typedef struct DSL_DEV_ChipInfo
+{
+ unsigned long major;
+ unsigned long minor;
+} DSL_DEV_HwVersion_t;
+
+typedef struct
+{
+ DSL_uint8_t dummy;
+} DSL_DEV_DeviceConfig_t;
+
+/** error code definitions */
+typedef enum DSL_DEV_MeiError
+{
+ DSL_DEV_MEI_ERR_SUCCESS = 0,
+ DSL_DEV_MEI_ERR_FAILURE = -1,
+ DSL_DEV_MEI_ERR_MAILBOX_FULL = -2,
+ DSL_DEV_MEI_ERR_MAILBOX_EMPTY = -3,
+ DSL_DEV_MEI_ERR_MAILBOX_TIMEOUT = -4
+} DSL_DEV_MeiError_t; /* MEI_ERROR */
+
+typedef enum {
+ DSL_BSP_MEMORY_READ=0,
+ DSL_BSP_MEMORY_WRITE,
+} DSL_BSP_MemoryAccessType_t; /* ifx_adsl_memory_access_type_t */
+
+typedef enum
+{
+ DSL_LED_LINK_ID=0,
+ DSL_LED_DATA_ID
+} DSL_DEV_LedId_t; /* ifx_adsl_led_id_t */
+
+typedef enum
+{
+ DSL_LED_LINK_TYPE=0,
+ DSL_LED_DATA_TYPE
+} DSL_DEV_LedType_t; /* ifx_adsl_led_type_t */
+
+typedef enum
+{
+ DSL_LED_HD_CPU=0,
+ DSL_LED_HD_FW
+} DSL_DEV_LedHandler_t; /* ifx_adsl_led_handler_t */
+
+typedef enum {
+ DSL_LED_ON=0,
+ DSL_LED_OFF,
+ DSL_LED_FLASH,
+} DSL_DEV_LedMode_t; /* ifx_adsl_led_mode_t */
+
+typedef enum {
+ DSL_CPU_HALT=0,
+ DSL_CPU_RUN,
+ DSL_CPU_RESET,
+} DSL_DEV_CpuMode_t; /* ifx_adsl_cpu_mode_t */
+
+#if 0
+typedef enum {
+ DSL_BSP_EVENT_DYING_GASP = 0,
+ DSL_BSP_EVENT_CEOC_IRQ,
+} DSL_BSP_Event_id_t; /* ifx_adsl_event_id_t */
+
+typedef union DSL_BSP_CB_Param
+{
+ DSL_uint32_t nIrqMessage;
+} DSL_BSP_CB_Param_t; /* ifx_adsl_cbparam_t */
+
+typedef struct DSL_BSP_CB_Event
+{
+ DSL_BSP_Event_id_t nID;
+ DSL_DEV_Device_t *pDev;
+ DSL_BSP_CB_Param_t *pParam;
+} DSL_BSP_CB_Event_t; /* ifx_adsl_cb_event_t */
+#endif
+
+/* external functions (from the BSP Driver) */
+extern DSL_DEV_Device_t* DSL_BSP_DriverHandleGet(int, int);
+extern DSL_int_t DSL_BSP_DriverHandleDelete(DSL_DEV_Device_t *);
+extern DSL_DEV_MeiError_t DSL_BSP_FWDownload(DSL_DEV_Device_t *, const DSL_char_t *, DSL_uint32_t, DSL_int32_t *, DSL_int32_t *);
+extern int DSL_BSP_KernelIoctls(DSL_DEV_Device_t *, unsigned int, unsigned long);
+extern DSL_DEV_MeiError_t DSL_BSP_SendCMV(DSL_DEV_Device_t *, DSL_uint16_t *, DSL_int_t, DSL_uint16_t *);
+extern DSL_DEV_MeiError_t DSL_BSP_AdslLedInit(DSL_DEV_Device_t *, DSL_DEV_LedId_t, DSL_DEV_LedType_t, DSL_DEV_LedHandler_t);
+extern DSL_DEV_MeiError_t DSL_BSP_Showtime(DSL_DEV_Device_t *, DSL_uint32_t, DSL_uint32_t);
+extern int DSL_BSP_ATMLedCBRegister( int (*ifx_adsl_ledcallback)(void));
+extern DSL_DEV_MeiError_t DSL_BSP_MemoryDebugAccess(DSL_DEV_Device_t *, DSL_BSP_MemoryAccessType_t, DSL_uint32_t, DSL_uint32_t *, DSL_uint32_t);
+extern volatile DSL_DEV_Device_t *adsl_dev;
+
+/**
+ * Dummy structure by now to show mechanism of extended data that will be
+ * provided within event callback itself.
+ * */
+typedef struct
+{
+ /**
+ * Dummy value */
+ DSL_uint32_t nDummy1;
+} DSL_BSP_CB_Event1DataDummy_t;
+
+/**
+ * Dummy structure by now to show mechanism of extended data that will be
+ * provided within event callback itself.
+ * */
+typedef struct
+{
+ /**
+ * Dummy value */
+ DSL_uint32_t nDummy2;
+} DSL_BSP_CB_Event2DataDummy_t;
+
+/**
+ * encapsulate all data structures that are necessary for status event
+ * callbacks.
+ * */
+typedef union
+{
+ DSL_BSP_CB_Event1DataDummy_t dataEvent1;
+ DSL_BSP_CB_Event2DataDummy_t dataEvent2;
+} DSL_BSP_CB_DATA_Union_t;
+
+
+typedef enum
+{
+ /**
+ * Informs the upper layer driver (DSL CPE API) about a reboot request from the
+ * firmware.
+ * \note This event does NOT include any additional data.
+ * More detailed information upon reboot reason has to be requested from
+ * upper layer software via CMV (INFO 109) if necessary. */
+ DSL_BSP_CB_FIRST = 0,
+ DSL_BSP_CB_DYING_GASP,
+ DSL_BSP_CB_CEOC_IRQ,
+ DSL_BSP_CB_FIRMWARE_REBOOT,
+ /**
+ * Delimiter only */
+ DSL_BSP_CB_LAST
+} DSL_BSP_CB_Type_t;
+
+/**
+ * Specifies the common event type that has to be used for registering and
+ * signalling of interrupts/autonomous status events from MEI BSP Driver.
+ *
+ * \param pDev
+ * Context pointer from MEI BSP Driver.
+ *
+ * \param IFX_ADSL_BSP_CallbackType_t
+ * Specifies the event callback type (reason of callback). Regrading to the
+ * setting of this value the data which is included in the following union
+ * might have different meanings.
+ * Please refer to the description of the union to get information about the
+ * meaning of the included data.
+ *
+ * \param pData
+ * Data according to \ref DSL_BSP_CB_DATA_Union_t.
+ * If this pointer is NULL there is no additional data available.
+ *
+ * \return depending on event
+ */
+typedef int (*DSL_BSP_EventCallback_t)
+(
+ DSL_DEV_Device_t *pDev,
+ DSL_BSP_CB_Type_t nCallbackType,
+ DSL_BSP_CB_DATA_Union_t *pData
+);
+
+typedef struct {
+ DSL_BSP_EventCallback_t function;
+ DSL_BSP_CB_Type_t event;
+ DSL_BSP_CB_DATA_Union_t *pData;
+} DSL_BSP_EventCallBack_t;
+
+extern int DSL_BSP_EventCBRegister(DSL_BSP_EventCallBack_t *);
+extern int DSL_BSP_EventCBUnregister(DSL_BSP_EventCallBack_t *);
+
+/** Modem states */
+#define DSL_DEV_STAT_InitState 0x0000
+#define DSL_DEV_STAT_ReadyState 0x0001
+#define DSL_DEV_STAT_FailState 0x0002
+#define DSL_DEV_STAT_IdleState 0x0003
+#define DSL_DEV_STAT_QuietState 0x0004
+#define DSL_DEV_STAT_GhsState 0x0005
+#define DSL_DEV_STAT_FullInitState 0x0006
+#define DSL_DEV_STAT_ShowTimeState 0x0007
+#define DSL_DEV_STAT_FastRetrainState 0x0008
+#define DSL_DEV_STAT_LoopDiagMode 0x0009
+#define DSL_DEV_STAT_ShortInit 0x000A /* Bis short initialization */
+
+#define DSL_DEV_STAT_CODESWAP_COMPLETE 0x0002
+
+#endif //IFXMIPS_MEI_H
diff --git a/package/platform/lantiq/ltq-adsl-mei/src/.svn/text-base/lantiq_mei.c.svn-base b/package/platform/lantiq/ltq-adsl-mei/src/.svn/text-base/lantiq_mei.c.svn-base
new file mode 100644
index 0000000..443b9d9
--- /dev/null
+++ b/package/platform/lantiq/ltq-adsl-mei/src/.svn/text-base/lantiq_mei.c.svn-base
@@ -0,0 +1,2805 @@
+/******************************************************************************
+
+ Copyright (c) 2009
+ Infineon Technologies AG
+ Am Campeon 1-12; 81726 Munich, Germany
+
+ For licensing information, see the file 'LICENSE' in the root folder of
+ this software module.
+
+******************************************************************************/
+
+/*!
+ \defgroup AMAZON_S_MEI Amazon-S MEI Driver Module
+ \brief Amazon-S MEI driver module
+ */
+
+/*!
+ \defgroup Internal Compile Parametere
+ \ingroup AMAZON_S_MEI
+ \brief exported functions for other driver use
+ */
+
+/*!
+ \file amazon_s_mei_bsp.c
+ \ingroup AMAZON_S_MEI
+ \brief Amazon-S MEI driver file
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/version.h>
+#include <generated/utsrelease.h>
+#include <linux/types.h>
+#include <linux/fs.h>
+#include <linux/mm.h>
+#include <linux/errno.h>
+#include <linux/interrupt.h>
+#include <linux/netdevice.h>
+#include <linux/etherdevice.h>
+#include <linux/proc_fs.h>
+#include <linux/init.h>
+#include <linux/ioport.h>
+#include <linux/delay.h>
+#include <linux/device.h>
+#include <linux/sched.h>
+#include <linux/platform_device.h>
+#include <asm/uaccess.h>
+#include <asm/hardirq.h>
+
+#include "lantiq_atm.h"
+#include <lantiq_soc.h>
+//#include "ifxmips_atm.h"
+#define IFX_MEI_BSP
+#include "ifxmips_mei_interface.h"
+
+/*#define LTQ_RCU_RST IFX_RCU_RST_REQ
+#define LTQ_RCU_RST_REQ_ARC_JTAG IFX_RCU_RST_REQ_ARC_JTAG
+#define LTQ_RCU_RST_REQ_DFE IFX_RCU_RST_REQ_DFE
+#define LTQ_RCU_RST_REQ_AFE IFX_RCU_RST_REQ_AFE
+#define IFXMIPS_FUSE_BASE_ADDR IFX_FUSE_BASE_ADDR
+#define IFXMIPS_ICU_IM0_IER IFX_ICU_IM0_IER
+#define IFXMIPS_ICU_IM2_IER IFX_ICU_IM2_IER
+#define LTQ_MEI_INT IFX_MEI_INT
+#define LTQ_MEI_DYING_GASP_INT IFX_MEI_DYING_GASP_INT
+#define LTQ_MEI_BASE_ADDR IFX_MEI_SPACE_ACCESS
+#define IFXMIPS_PMU_PWDCR IFX_PMU_PWDCR
+#define IFXMIPS_MPS_CHIPID IFX_MPS_CHIPID
+
+#define ifxmips_port_reserve_pin ifx_gpio_pin_reserve
+#define ifxmips_port_set_dir_in ifx_gpio_dir_in_set
+#define ifxmips_port_clear_altsel0 ifx_gpio_altsel0_set
+#define ifxmips_port_clear_altsel1 ifx_gpio_altsel1_clear
+#define ifxmips_port_set_open_drain ifx_gpio_open_drain_clear
+#define ifxmips_port_free_pin ifx_gpio_pin_free
+#define ifxmips_mask_and_ack_irq bsp_mask_and_ack_irq
+#define IFXMIPS_MPS_CHIPID_VERSION_GET IFX_MCD_CHIPID_VERSION_GET
+#define ltq_r32(reg) __raw_readl(reg)
+#define ltq_w32(val, reg) __raw_writel(val, reg)
+#define ltq_w32_mask(clear, set, reg) ltq_w32((ltq_r32(reg) & ~clear) | set, reg)
+*/
+
+#define LTQ_RCU_BASE_ADDR 0x1F203000
+#define LTQ_ICU_BASE_ADDR 0x1F880200
+#define LTQ_MEI_BASE_ADDR 0x1E116000
+#define LTQ_PMU_BASE_ADDR 0x1F102000
+#define LTQ_MEI_DYING_GASP_INT (INT_NUM_IM1_IRL0 + 21)
+#define LTQ_USB_OC_INT (INT_NUM_IM4_IRL0 + 23)
+#define LTQ_MEI_INT (INT_NUM_IM1_IRL0 + 23)
+
+#define LTQ_RCU_RST_REQ_DFE (1 << 7)
+#define LTQ_RCU_RST_REQ_AFE (1 << 11)
+
+#define LTQ_PMU_BASE (KSEG1 + LTQ_PMU_BASE_ADDR)
+#define LTQ_RCU_BASE (KSEG1 + LTQ_RCU_BASE_ADDR)
+#define LTQ_ICU_BASE (KSEG1 + LTQ_ICU_BASE_ADDR)
+
+#define LTQ_PMU_PWDCR ((u32 *)(LTQ_PMU_BASE + 0x001C))
+#define LTQ_PMU_PWDSR ((u32 *)(LTQ_PMU_BASE + 0x0020))
+#define LTQ_RCU_RST ((u32 *)(LTQ_RCU_BASE + 0x0010))
+#define LTQ_RCU_RST_ALL 0x40000000
+
+#define LTQ_ICU_IM0_ISR ((u32 *)(LTQ_ICU_BASE + 0x0000))
+#define LTQ_ICU_IM0_IER ((u32 *)(LTQ_ICU_BASE + 0x0008))
+#define LTQ_ICU_IM0_IOSR ((u32 *)(LTQ_ICU_BASE + 0x0010))
+#define LTQ_ICU_IM0_IRSR ((u32 *)(LTQ_ICU_BASE + 0x0018))
+#define LTQ_ICU_IM0_IMR ((u32 *)(LTQ_ICU_BASE + 0x0020))
+
+
+#define LTQ_ICU_IM1_ISR ((u32 *)(LTQ_ICU_BASE + 0x0028))
+#define LTQ_ICU_IM2_ISR ((u32 *)(LTQ_ICU_BASE + 0x0050))
+#define LTQ_ICU_IM3_ISR ((u32 *)(LTQ_ICU_BASE + 0x0078))
+#define LTQ_ICU_IM4_ISR ((u32 *)(LTQ_ICU_BASE + 0x00A0))
+
+#define LTQ_ICU_OFFSET (LTQ_ICU_IM1_ISR - LTQ_ICU_IM0_ISR)
+#define LTQ_ICU_IM2_IER (LTQ_ICU_IM0_IER + LTQ_ICU_OFFSET)
+
+#define IFX_MEI_EMSG(fmt, args...) pr_err("[%s %d]: " fmt,__FUNCTION__, __LINE__, ## args)
+#define IFX_MEI_DMSG(fmt, args...) pr_debug("[%s %d]: " fmt,__FUNCTION__, __LINE__, ## args)
+
+#define LTQ_FUSE_BASE (KSEG1 + 0x1F107354)
+
+#ifdef CONFIG_LTQ_MEI_FW_LOOPBACK
+//#define DFE_MEM_TEST
+//#define DFE_PING_TEST
+#define DFE_ATM_LOOPBACK
+
+
+#ifdef DFE_ATM_LOOPBACK
+#include <asm/ifxmips/ifxmips_mei_fw_loopback.h>
+#endif
+
+void dfe_loopback_irq_handler (DSL_DEV_Device_t *pDev);
+
+#endif //CONFIG_AMAZON_S_MEI_FW_LOOPBACK
+
+DSL_DEV_Version_t bsp_mei_version = {
+ major: 5,
+ minor: 0,
+ revision:0
+};
+DSL_DEV_HwVersion_t bsp_chip_info;
+
+#define IFX_MEI_DEVNAME "ifx_mei"
+#define BSP_MAX_DEVICES 1
+#define MEI_DIRNAME "ifxmips_mei"
+
+DSL_DEV_MeiError_t DSL_BSP_FWDownload (DSL_DEV_Device_t *, const char *, unsigned long, long *, long *);
+DSL_DEV_MeiError_t DSL_BSP_Showtime (DSL_DEV_Device_t *, DSL_uint32_t, DSL_uint32_t);
+DSL_DEV_MeiError_t DSL_BSP_AdslLedInit (DSL_DEV_Device_t *, DSL_DEV_LedId_t, DSL_DEV_LedType_t, DSL_DEV_LedHandler_t);
+//DSL_DEV_MeiError_t DSL_BSP_AdslLedSet (DSL_DEV_Device_t *, DSL_DEV_LedId_t, DSL_DEV_LedMode_t);
+DSL_DEV_MeiError_t DSL_BSP_MemoryDebugAccess (DSL_DEV_Device_t *, DSL_BSP_MemoryAccessType_t, DSL_uint32_t, DSL_uint32_t*, DSL_uint32_t);
+DSL_DEV_MeiError_t DSL_BSP_SendCMV (DSL_DEV_Device_t *, u16 *, int, u16 *);
+
+int DSL_BSP_KernelIoctls (DSL_DEV_Device_t *, unsigned int, unsigned long);
+
+static DSL_DEV_MeiError_t IFX_MEI_RunAdslModem (DSL_DEV_Device_t *);
+static DSL_DEV_MeiError_t IFX_MEI_CpuModeSet (DSL_DEV_Device_t *, DSL_DEV_CpuMode_t);
+static DSL_DEV_MeiError_t IFX_MEI_DownloadBootCode (DSL_DEV_Device_t *);
+static DSL_DEV_MeiError_t IFX_MEI_ArcJtagEnable (DSL_DEV_Device_t *, int);
+static DSL_DEV_MeiError_t IFX_MEI_AdslMailboxIRQEnable (DSL_DEV_Device_t *, int);
+
+static int IFX_MEI_GetPage (DSL_DEV_Device_t *, u32, u32, u32, u32 *, u32 *);
+static int IFX_MEI_BarUpdate (DSL_DEV_Device_t *, int);
+
+static ssize_t IFX_MEI_Write (DSL_DRV_file_t *, const char *, size_t, loff_t *);
+static long IFX_MEI_UserIoctls (DSL_DRV_file_t *, unsigned int, unsigned long);
+static int IFX_MEI_Open (DSL_DRV_inode_t *, DSL_DRV_file_t *);
+static int IFX_MEI_Release (DSL_DRV_inode_t *, DSL_DRV_file_t *);
+
+void AMAZON_SE_MEI_ARC_MUX_Test(void);
+
+void IFX_MEI_ARC_MUX_Test(void);
+
+static int adsl_dummy_ledcallback(void);
+
+int (*ifx_mei_atm_showtime_enter)(struct port_cell_info *, void *) = NULL;
+EXPORT_SYMBOL(ifx_mei_atm_showtime_enter);
+
+int (*ifx_mei_atm_showtime_exit)(void) = NULL;
+EXPORT_SYMBOL(ifx_mei_atm_showtime_exit);
+
+static int (*g_adsl_ledcallback)(void) = adsl_dummy_ledcallback;
+
+static unsigned int g_tx_link_rate[2] = {0};
+
+static void *g_xdata_addr = NULL;
+
+static u32 *mei_arc_swap_buff = NULL; // holding swap pages
+
+extern void ltq_mask_and_ack_irq(struct irq_data *d);
+static void inline MEI_MASK_AND_ACK_IRQ(int x)
+{
+ struct irq_data d;
+ d.hwirq = x;
+ ltq_mask_and_ack_irq(&d);
+}
+#define MEI_MAJOR 105
+static int dev_major = MEI_MAJOR;
+
+static struct file_operations bsp_mei_operations = {
+ owner:THIS_MODULE,
+ open:IFX_MEI_Open,
+ release:IFX_MEI_Release,
+ write:IFX_MEI_Write,
+ unlocked_ioctl:IFX_MEI_UserIoctls,
+};
+
+static DSL_DEV_Device_t dsl_devices[BSP_MAX_DEVICES];
+
+static ifx_mei_device_private_t
+ sDanube_Mei_Private[BSP_MAX_DEVICES];
+
+static DSL_BSP_EventCallBack_t dsl_bsp_event_callback[DSL_BSP_CB_LAST + 1];
+
+/**
+ * Write a value to register
+ * This function writes a value to danube register
+ *
+ * \param ul_address The address to write
+ * \param ul_data The value to write
+ * \ingroup Internal
+ */
+static void
+IFX_MEI_LongWordWrite (u32 ul_address, u32 ul_data)
+{
+ IFX_MEI_WRITE_REGISTER_L (ul_data, ul_address);
+ wmb();
+ return;
+}
+
+/**
+ * Write a value to register
+ * This function writes a value to danube register
+ *
+ * \param pDev the device pointer
+ * \param ul_address The address to write
+ * \param ul_data The value to write
+ * \ingroup Internal
+ */
+static void
+IFX_MEI_LongWordWriteOffset (DSL_DEV_Device_t * pDev, u32 ul_address,
+ u32 ul_data)
+{
+ IFX_MEI_WRITE_REGISTER_L (ul_data, pDev->base_address + ul_address);
+ wmb();
+ return;
+}
+
+/**
+ * Read the danube register
+ * This function read the value from danube register
+ *
+ * \param ul_address The address to write
+ * \param pul_data Pointer to the data
+ * \ingroup Internal
+ */
+static void
+IFX_MEI_LongWordRead (u32 ul_address, u32 * pul_data)
+{
+ *pul_data = IFX_MEI_READ_REGISTER_L (ul_address);
+ rmb();
+ return;
+}
+
+/**
+ * Read the danube register
+ * This function read the value from danube register
+ *
+ * \param pDev the device pointer
+ * \param ul_address The address to write
+ * \param pul_data Pointer to the data
+ * \ingroup Internal
+ */
+static void
+IFX_MEI_LongWordReadOffset (DSL_DEV_Device_t * pDev, u32 ul_address,
+ u32 * pul_data)
+{
+ *pul_data = IFX_MEI_READ_REGISTER_L (pDev->base_address + ul_address);
+ rmb();
+ return;
+}
+
+/**
+ * Write several DWORD datas to ARC memory via ARC DMA interface
+ * This function writes several DWORD datas to ARC memory via DMA interface.
+ *
+ * \param pDev the device pointer
+ * \param destaddr The address to write
+ * \param databuff Pointer to the data buffer
+ * \param databuffsize Number of DWORDs to write
+ * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
+ * \ingroup Internal
+ */
+static DSL_DEV_MeiError_t
+IFX_MEI_DMAWrite (DSL_DEV_Device_t * pDev, u32 destaddr,
+ u32 * databuff, u32 databuffsize)
+{
+ u32 *p = databuff;
+ u32 temp;
+
+ if (destaddr & 3)
+ return DSL_DEV_MEI_ERR_FAILURE;
+
+ // Set the write transfer address
+ IFX_MEI_LongWordWriteOffset (pDev, ME_DX_AD, destaddr);
+
+ // Write the data pushed across DMA
+ while (databuffsize--) {
+ temp = *p;
+ if (destaddr == MEI_TO_ARC_MAILBOX)
+ MEI_HALF_WORD_SWAP (temp);
+ IFX_MEI_LongWordWriteOffset (pDev, (u32) ME_DX_DATA, temp);
+ p++;
+ }
+
+ return DSL_DEV_MEI_ERR_SUCCESS;
+
+}
+
+/**
+ * Read several DWORD datas from ARC memory via ARC DMA interface
+ * This function reads several DWORD datas from ARC memory via DMA interface.
+ *
+ * \param pDev the device pointer
+ * \param srcaddr The address to read
+ * \param databuff Pointer to the data buffer
+ * \param databuffsize Number of DWORDs to read
+ * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
+ * \ingroup Internal
+ */
+static DSL_DEV_MeiError_t
+IFX_MEI_DMARead (DSL_DEV_Device_t * pDev, u32 srcaddr, u32 * databuff,
+ u32 databuffsize)
+{
+ u32 *p = databuff;
+ u32 temp;
+
+ if (srcaddr & 3)
+ return DSL_DEV_MEI_ERR_FAILURE;
+
+ // Set the read transfer address
+ IFX_MEI_LongWordWriteOffset (pDev, (u32) ME_DX_AD, srcaddr);
+
+ // Read the data popped across DMA
+ while (databuffsize--) {
+ IFX_MEI_LongWordReadOffset (pDev, (u32) ME_DX_DATA, &temp);
+ if (databuff == (u32 *) DSL_DEV_PRIVATE(pDev)->CMV_RxMsg) // swap half word
+ MEI_HALF_WORD_SWAP (temp);
+ *p = temp;
+ p++;
+ }
+
+ return DSL_DEV_MEI_ERR_SUCCESS;
+
+}
+
+/**
+ * Switch the ARC control mode
+ * This function switchs the ARC control mode to JTAG mode or MEI mode
+ *
+ * \param pDev the device pointer
+ * \param mode The mode want to switch: JTAG_MASTER_MODE or MEI_MASTER_MODE.
+ * \ingroup Internal
+ */
+static void
+IFX_MEI_ControlModeSet (DSL_DEV_Device_t * pDev, int mode)
+{
+ u32 temp = 0x0;
+
+ IFX_MEI_LongWordReadOffset (pDev, (u32) ME_DBG_MASTER, &temp);
+ switch (mode) {
+ case JTAG_MASTER_MODE:
+ temp &= ~(HOST_MSTR);
+ break;
+ case MEI_MASTER_MODE:
+ temp |= (HOST_MSTR);
+ break;
+ default:
+ IFX_MEI_EMSG ("IFX_MEI_ControlModeSet: unkonwn mode [%d]\n", mode);
+ return;
+ }
+ IFX_MEI_LongWordWriteOffset (pDev, (u32) ME_DBG_MASTER, temp);
+}
+
+/**
+ * Disable ARC to MEI interrupt
+ *
+ * \param pDev the device pointer
+ * \ingroup Internal
+ */
+static void
+IFX_MEI_IRQDisable (DSL_DEV_Device_t * pDev)
+{
+ IFX_MEI_LongWordWriteOffset (pDev, (u32) ME_ARC2ME_MASK, 0x0);
+}
+
+/**
+ * Eable ARC to MEI interrupt
+ *
+ * \param pDev the device pointer
+ * \ingroup Internal
+ */
+static void
+IFX_MEI_IRQEnable (DSL_DEV_Device_t * pDev)
+{
+ IFX_MEI_LongWordWriteOffset (pDev, (u32) ME_ARC2ME_MASK, MSGAV_EN);
+}
+
+/**
+ * Poll for transaction complete signal
+ * This function polls and waits for transaction complete signal.
+ *
+ * \param pDev the device pointer
+ * \ingroup Internal
+ */
+static void
+meiPollForDbgDone (DSL_DEV_Device_t * pDev)
+{
+ u32 query = 0;
+ int i = 0;
+
+ while (i < WHILE_DELAY) {
+ IFX_MEI_LongWordReadOffset (pDev, (u32) ME_ARC2ME_STAT, &query);
+ query &= (ARC_TO_MEI_DBG_DONE);
+ if (query)
+ break;
+ i++;
+ if (i == WHILE_DELAY) {
+ IFX_MEI_EMSG ("PollforDbg fail!\n");
+ }
+ }
+ IFX_MEI_LongWordWriteOffset (pDev, (u32) ME_ARC2ME_STAT, ARC_TO_MEI_DBG_DONE); // to clear this interrupt
+}
+
+/**
+ * ARC Debug Memory Access for a single DWORD reading.
+ * This function used for direct, address-based access to ARC memory.
+ *
+ * \param pDev the device pointer
+ * \param DEC_mode ARC memory space to used
+ * \param address Address to read
+ * \param data Pointer to data
+ * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
+ * \ingroup Internal
+ */
+static DSL_DEV_MeiError_t
+_IFX_MEI_DBGLongWordRead (DSL_DEV_Device_t * pDev, u32 DEC_mode,
+ u32 address, u32 * data)
+{
+ IFX_MEI_LongWordWriteOffset (pDev, (u32) ME_DBG_DECODE, DEC_mode);
+ IFX_MEI_LongWordWriteOffset (pDev, (u32) ME_DBG_RD_AD, address);
+ meiPollForDbgDone (pDev);
+ IFX_MEI_LongWordReadOffset (pDev, (u32) ME_DBG_DATA, data);
+ return DSL_DEV_MEI_ERR_SUCCESS;
+}
+
+/**
+ * ARC Debug Memory Access for a single DWORD writing.
+ * This function used for direct, address-based access to ARC memory.
+ *
+ * \param pDev the device pointer
+ * \param DEC_mode ARC memory space to used
+ * \param address The address to write
+ * \param data The data to write
+ * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
+ * \ingroup Internal
+ */
+static DSL_DEV_MeiError_t
+_IFX_MEI_DBGLongWordWrite (DSL_DEV_Device_t * pDev, u32 DEC_mode,
+ u32 address, u32 data)
+{
+ IFX_MEI_LongWordWriteOffset (pDev, (u32) ME_DBG_DECODE, DEC_mode);
+ IFX_MEI_LongWordWriteOffset (pDev, (u32) ME_DBG_WR_AD, address);
+ IFX_MEI_LongWordWriteOffset (pDev, (u32) ME_DBG_DATA, data);
+ meiPollForDbgDone (pDev);
+ return DSL_DEV_MEI_ERR_SUCCESS;
+}
+
+/**
+ * ARC Debug Memory Access for writing.
+ * This function used for direct, address-based access to ARC memory.
+ *
+ * \param pDev the device pointer
+ * \param destaddr The address to read
+ * \param databuffer Pointer to data
+ * \param databuffsize The number of DWORDs to read
+ * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
+ * \ingroup Internal
+ */
+
+static DSL_DEV_MeiError_t
+IFX_MEI_DebugWrite (DSL_DEV_Device_t * pDev, u32 destaddr,
+ u32 * databuff, u32 databuffsize)
+{
+ u32 i;
+ u32 temp = 0x0;
+ u32 address = 0x0;
+ u32 *buffer = 0x0;
+
+ // Open the debug port before DMP memory write
+ IFX_MEI_ControlModeSet (pDev, MEI_MASTER_MODE);
+
+ // For the requested length, write the address and write the data
+ address = destaddr;
+ buffer = databuff;
+ for (i = 0; i < databuffsize; i++) {
+ temp = *buffer;
+ _IFX_MEI_DBGLongWordWrite (pDev, ME_DBG_DECODE_DMP1_MASK, address, temp);
+ address += 4;
+ buffer++;
+ }
+
+ // Close the debug port after DMP memory write
+ IFX_MEI_ControlModeSet (pDev, JTAG_MASTER_MODE);
+
+ return DSL_DEV_MEI_ERR_SUCCESS;
+}
+
+/**
+ * ARC Debug Memory Access for reading.
+ * This function used for direct, address-based access to ARC memory.
+ *
+ * \param pDev the device pointer
+ * \param srcaddr The address to read
+ * \param databuffer Pointer to data
+ * \param databuffsize The number of DWORDs to read
+ * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
+ * \ingroup Internal
+ */
+static DSL_DEV_MeiError_t
+IFX_MEI_DebugRead (DSL_DEV_Device_t * pDev, u32 srcaddr, u32 * databuff, u32 databuffsize)
+{
+ u32 i;
+ u32 temp = 0x0;
+ u32 address = 0x0;
+ u32 *buffer = 0x0;
+
+ // Open the debug port before DMP memory read
+ IFX_MEI_ControlModeSet (pDev, MEI_MASTER_MODE);
+
+ // For the requested length, write the address and read the data
+ address = srcaddr;
+ buffer = databuff;
+ for (i = 0; i < databuffsize; i++) {
+ _IFX_MEI_DBGLongWordRead (pDev, ME_DBG_DECODE_DMP1_MASK, address, &temp);
+ *buffer = temp;
+ address += 4;
+ buffer++;
+ }
+
+ // Close the debug port after DMP memory read
+ IFX_MEI_ControlModeSet (pDev, JTAG_MASTER_MODE);
+
+ return DSL_DEV_MEI_ERR_SUCCESS;
+}
+
+/**
+ * Send a message to ARC MailBox.
+ * This function sends a message to ARC Mailbox via ARC DMA interface.
+ *
+ * \param pDev the device pointer
+ * \param msgsrcbuffer Pointer to message.
+ * \param msgsize The number of words to write.
+ * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
+ * \ingroup Internal
+ */
+static DSL_DEV_MeiError_t
+IFX_MEI_MailboxWrite (DSL_DEV_Device_t * pDev, u16 * msgsrcbuffer,
+ u16 msgsize)
+{
+ int i;
+ u32 arc_mailbox_status = 0x0;
+ u32 temp = 0;
+ DSL_DEV_MeiError_t meiMailboxError = DSL_DEV_MEI_ERR_SUCCESS;
+
+ // Write to mailbox
+ meiMailboxError =
+ IFX_MEI_DMAWrite (pDev, MEI_TO_ARC_MAILBOX, (u32 *) msgsrcbuffer, msgsize / 2);
+ meiMailboxError =
+ IFX_MEI_DMAWrite (pDev, MEI_TO_ARC_MAILBOXR, (u32 *) (&temp), 1);
+
+ // Notify arc that mailbox write completed
+ DSL_DEV_PRIVATE(pDev)->cmv_waiting = 1;
+ IFX_MEI_LongWordWriteOffset (pDev, (u32) ME_ME2ARC_INT, MEI_TO_ARC_MSGAV);
+
+ i = 0;
+ while (i < WHILE_DELAY) { // wait for ARC to clear the bit
+ IFX_MEI_LongWordReadOffset (pDev, (u32) ME_ME2ARC_INT, &arc_mailbox_status);
+ if ((arc_mailbox_status & MEI_TO_ARC_MSGAV) != MEI_TO_ARC_MSGAV)
+ break;
+ i++;
+ if (i == WHILE_DELAY) {
+ IFX_MEI_EMSG (">>> Timeout waiting for ARC to clear MEI_TO_ARC_MSGAV!!!"
+ " MEI_TO_ARC message size = %d DWORDs <<<\n", msgsize/2);
+ meiMailboxError = DSL_DEV_MEI_ERR_FAILURE;
+ }
+ }
+
+ return meiMailboxError;
+}
+
+/**
+ * Read a message from ARC MailBox.
+ * This function reads a message from ARC Mailbox via ARC DMA interface.
+ *
+ * \param pDev the device pointer
+ * \param msgsrcbuffer Pointer to message.
+ * \param msgsize The number of words to read
+ * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
+ * \ingroup Internal
+ */
+static DSL_DEV_MeiError_t
+IFX_MEI_MailboxRead (DSL_DEV_Device_t * pDev, u16 * msgdestbuffer,
+ u16 msgsize)
+{
+ DSL_DEV_MeiError_t meiMailboxError = DSL_DEV_MEI_ERR_SUCCESS;
+ // Read from mailbox
+ meiMailboxError =
+ IFX_MEI_DMARead (pDev, ARC_TO_MEI_MAILBOX, (u32 *) msgdestbuffer, msgsize / 2);
+
+ // Notify arc that mailbox read completed
+ IFX_MEI_LongWordWriteOffset (pDev, (u32) ME_ARC2ME_STAT, ARC_TO_MEI_MSGAV);
+
+ return meiMailboxError;
+}
+
+/**
+ * Download boot pages to ARC.
+ * This function downloads boot pages to ARC.
+ *
+ * \param pDev the device pointer
+ * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
+ * \ingroup Internal
+ */
+static DSL_DEV_MeiError_t
+IFX_MEI_DownloadBootPages (DSL_DEV_Device_t * pDev)
+{
+ int boot_loop;
+ int page_size;
+ u32 dest_addr;
+
+ /*
+ ** DMA the boot code page(s)
+ */
+
+ for (boot_loop = 1;
+ boot_loop <
+ (DSL_DEV_PRIVATE(pDev)->img_hdr-> count); boot_loop++) {
+ if ((DSL_DEV_PRIVATE(pDev)-> img_hdr->page[boot_loop].p_size) & BOOT_FLAG) {
+ page_size = IFX_MEI_GetPage (pDev, boot_loop,
+ GET_PROG, MAXSWAPSIZE,
+ mei_arc_swap_buff,
+ &dest_addr);
+ if (page_size > 0) {
+ IFX_MEI_DMAWrite (pDev, dest_addr,
+ mei_arc_swap_buff,
+ page_size);
+ }
+ }
+ if ((DSL_DEV_PRIVATE(pDev)-> img_hdr->page[boot_loop].d_size) & BOOT_FLAG) {
+ page_size = IFX_MEI_GetPage (pDev, boot_loop,
+ GET_DATA, MAXSWAPSIZE,
+ mei_arc_swap_buff,
+ &dest_addr);
+ if (page_size > 0) {
+ IFX_MEI_DMAWrite (pDev, dest_addr,
+ mei_arc_swap_buff,
+ page_size);
+ }
+ }
+ }
+ return DSL_DEV_MEI_ERR_SUCCESS;
+}
+
+/**
+ * Initial efuse rar.
+ **/
+static void
+IFX_MEI_FuseInit (DSL_DEV_Device_t * pDev)
+{
+ u32 data = 0;
+ IFX_MEI_DMAWrite (pDev, IRAM0_BASE, &data, 1);
+ IFX_MEI_DMAWrite (pDev, IRAM0_BASE + 4, &data, 1);
+ IFX_MEI_DMAWrite (pDev, IRAM1_BASE, &data, 1);
+ IFX_MEI_DMAWrite (pDev, IRAM1_BASE + 4, &data, 1);
+ IFX_MEI_DMAWrite (pDev, BRAM_BASE, &data, 1);
+ IFX_MEI_DMAWrite (pDev, BRAM_BASE + 4, &data, 1);
+ IFX_MEI_DMAWrite (pDev, ADSL_DILV_BASE, &data, 1);
+ IFX_MEI_DMAWrite (pDev, ADSL_DILV_BASE + 4, &data, 1);
+}
+
+/**
+ * efuse rar program
+ **/
+static void
+IFX_MEI_FuseProg (DSL_DEV_Device_t * pDev)
+{
+ u32 reg_data, fuse_value;
+ int i = 0;
+
+ IFX_MEI_LongWordRead ((u32) LTQ_RCU_RST, &reg_data);
+ while ((reg_data & 0x10000000) == 0) {
+ IFX_MEI_LongWordRead ((u32) LTQ_RCU_RST, &reg_data);
+ i++;
+ /* 0x4000 translate to about 16 ms@111M, so should be enough */
+ if (i == 0x4000)
+ return;
+ }
+ // STEP a: Prepare memory for external accesses
+ // Write fuse_en bit24
+ IFX_MEI_LongWordRead ((u32) LTQ_RCU_RST, &reg_data);
+ IFX_MEI_LongWordWrite ((u32) LTQ_RCU_RST, reg_data | (1 << 24));
+
+ IFX_MEI_FuseInit (pDev);
+ for (i = 0; i < 4; i++) {
+ IFX_MEI_LongWordRead ((u32) (LTQ_FUSE_BASE) + i * 4, &fuse_value);
+ switch (fuse_value & 0xF0000) {
+ case 0x80000:
+ reg_data = ((fuse_value & RX_DILV_ADDR_BIT_MASK) |
+ (RX_DILV_ADDR_BIT_MASK + 0x1));
+ IFX_MEI_DMAWrite (pDev, ADSL_DILV_BASE, &reg_data, 1);
+ break;
+ case 0x90000:
+ reg_data = ((fuse_value & RX_DILV_ADDR_BIT_MASK) |
+ (RX_DILV_ADDR_BIT_MASK + 0x1));
+ IFX_MEI_DMAWrite (pDev, ADSL_DILV_BASE + 4, &reg_data, 1);
+ break;
+ case 0xA0000:
+ reg_data = ((fuse_value & IRAM0_ADDR_BIT_MASK) |
+ (IRAM0_ADDR_BIT_MASK + 0x1));
+ IFX_MEI_DMAWrite (pDev, IRAM0_BASE, &reg_data, 1);
+ break;
+ case 0xB0000:
+ reg_data = ((fuse_value & IRAM0_ADDR_BIT_MASK) |
+ (IRAM0_ADDR_BIT_MASK + 0x1));
+ IFX_MEI_DMAWrite (pDev, IRAM0_BASE + 4, &reg_data, 1);
+ break;
+ case 0xC0000:
+ reg_data = ((fuse_value & IRAM1_ADDR_BIT_MASK) |
+ (IRAM1_ADDR_BIT_MASK + 0x1));
+ IFX_MEI_DMAWrite (pDev, IRAM1_BASE, &reg_data, 1);
+ break;
+ case 0xD0000:
+ reg_data = ((fuse_value & IRAM1_ADDR_BIT_MASK) |
+ (IRAM1_ADDR_BIT_MASK + 0x1));
+ IFX_MEI_DMAWrite (pDev, IRAM1_BASE + 4, &reg_data, 1);
+ break;
+ case 0xE0000:
+ reg_data = ((fuse_value & BRAM_ADDR_BIT_MASK) |
+ (BRAM_ADDR_BIT_MASK + 0x1));
+ IFX_MEI_DMAWrite (pDev, BRAM_BASE, &reg_data, 1);
+ break;
+ case 0xF0000:
+ reg_data = ((fuse_value & BRAM_ADDR_BIT_MASK) |
+ (BRAM_ADDR_BIT_MASK + 0x1));
+ IFX_MEI_DMAWrite (pDev, BRAM_BASE + 4, &reg_data, 1);
+ break;
+ default: // PPE efuse
+ break;
+ }
+ }
+ IFX_MEI_LongWordRead ((u32) LTQ_RCU_RST, &reg_data);
+ IFX_MEI_LongWordWrite ((u32) LTQ_RCU_RST, reg_data & ~(1 << 24));
+ IFX_MEI_LongWordRead ((u32) LTQ_RCU_RST, &reg_data);
+}
+
+/**
+ * Enable DFE Clock
+ * This function enables DFE Clock
+ *
+ * \param pDev the device pointer
+ * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
+ * \ingroup Internal
+ */
+static DSL_DEV_MeiError_t
+IFX_MEI_EnableCLK (DSL_DEV_Device_t * pDev)
+{
+ u32 arc_debug_data = 0;
+ IFX_MEI_ControlModeSet (pDev, MEI_MASTER_MODE);
+ //enable ac_clk signal
+ _IFX_MEI_DBGLongWordRead (pDev, ME_DBG_DECODE_DMP1_MASK,
+ CRI_CCR0, &arc_debug_data);
+ arc_debug_data |= ACL_CLK_MODE_ENABLE;
+ _IFX_MEI_DBGLongWordWrite (pDev, ME_DBG_DECODE_DMP1_MASK,
+ CRI_CCR0, arc_debug_data);
+ IFX_MEI_ControlModeSet (pDev, JTAG_MASTER_MODE);
+ return DSL_DEV_MEI_ERR_SUCCESS;
+}
+
+/**
+ * Halt the ARC.
+ * This function halts the ARC.
+ *
+ * \param pDev the device pointer
+ * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
+ * \ingroup Internal
+ */
+static DSL_DEV_MeiError_t
+IFX_MEI_HaltArc (DSL_DEV_Device_t * pDev)
+{
+ u32 arc_debug_data = 0x0;
+
+ // Switch arc control from JTAG mode to MEI mode
+ IFX_MEI_ControlModeSet (pDev, MEI_MASTER_MODE);
+ _IFX_MEI_DBGLongWordRead (pDev, MEI_DEBUG_DEC_AUX_MASK,
+ ARC_DEBUG, &arc_debug_data);
+ arc_debug_data |= ARC_DEBUG_HALT;
+ _IFX_MEI_DBGLongWordWrite (pDev, MEI_DEBUG_DEC_AUX_MASK,
+ ARC_DEBUG, arc_debug_data);
+ // Switch arc control from MEI mode to JTAG mode
+ IFX_MEI_ControlModeSet (pDev, JTAG_MASTER_MODE);
+
+ MEI_WAIT (10);
+
+ return DSL_DEV_MEI_ERR_SUCCESS;
+}
+
+/**
+ * Run the ARC.
+ * This function runs the ARC.
+ *
+ * \param pDev the device pointer
+ * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
+ * \ingroup Internal
+ */
+static DSL_DEV_MeiError_t
+IFX_MEI_RunArc (DSL_DEV_Device_t * pDev)
+{
+ u32 arc_debug_data = 0x0;
+
+ // Switch arc control from JTAG mode to MEI mode- write '1' to bit0
+ IFX_MEI_ControlModeSet (pDev, MEI_MASTER_MODE);
+ _IFX_MEI_DBGLongWordRead (pDev, MEI_DEBUG_DEC_AUX_MASK,
+ AUX_STATUS, &arc_debug_data);
+
+ // Write debug data reg with content ANDd with 0xFDFFFFFF (halt bit cleared)
+ arc_debug_data &= ~ARC_AUX_HALT;
+ _IFX_MEI_DBGLongWordWrite (pDev, MEI_DEBUG_DEC_AUX_MASK,
+ AUX_STATUS, arc_debug_data);
+
+ // Switch arc control from MEI mode to JTAG mode- write '0' to bit0
+ IFX_MEI_ControlModeSet (pDev, JTAG_MASTER_MODE);
+ // Enable mask for arc codeswap interrupts
+ IFX_MEI_IRQEnable (pDev);
+
+ return DSL_DEV_MEI_ERR_SUCCESS;
+
+}
+
+/**
+ * Reset the ARC.
+ * This function resets the ARC.
+ *
+ * \param pDev the device pointer
+ * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
+ * \ingroup Internal
+ */
+static DSL_DEV_MeiError_t
+IFX_MEI_ResetARC (DSL_DEV_Device_t * pDev)
+{
+ u32 arc_debug_data = 0;
+
+ IFX_MEI_HaltArc (pDev);
+
+ IFX_MEI_LongWordRead ((u32) LTQ_RCU_RST, &arc_debug_data);
+ IFX_MEI_LongWordWrite ((u32) LTQ_RCU_RST,
+ arc_debug_data | LTQ_RCU_RST_REQ_DFE | LTQ_RCU_RST_REQ_AFE);
+
+ // reset ARC
+ IFX_MEI_LongWordWriteOffset (pDev, (u32) ME_RST_CTRL, MEI_SOFT_RESET);
+ IFX_MEI_LongWordWriteOffset (pDev, (u32) ME_RST_CTRL, 0);
+
+ IFX_MEI_IRQDisable (pDev);
+
+ IFX_MEI_EnableCLK (pDev);
+
+#if 0
+ // reset part of PPE
+ *(unsigned long *) (BSP_PPE32_SRST) = 0xC30;
+ *(unsigned long *) (BSP_PPE32_SRST) = 0xFFF;
+#endif
+
+ DSL_DEV_PRIVATE(pDev)->modem_ready = 0;
+
+ return DSL_DEV_MEI_ERR_SUCCESS;
+}
+
+DSL_DEV_MeiError_t
+DSL_BSP_Showtime (DSL_DEV_Device_t * dev, DSL_uint32_t rate_fast, DSL_uint32_t rate_intl)
+{
+ struct port_cell_info port_cell = {0};
+
+ IFX_MEI_EMSG ("Datarate US intl = %d, fast = %d\n", (int)rate_intl,
+ (int)rate_fast);
+
+ if ( rate_fast )
+ g_tx_link_rate[0] = rate_fast / (53 * 8);
+ if ( rate_intl )
+ g_tx_link_rate[1] = rate_intl / (53 * 8);
+
+ if ( g_tx_link_rate[0] == 0 && g_tx_link_rate[1] == 0 ) {
+ IFX_MEI_EMSG ("Got rate fail.\n");
+ }
+
+ if ( ifx_mei_atm_showtime_enter )
+ {
+ port_cell.port_num = 2;
+ port_cell.tx_link_rate[0] = g_tx_link_rate[0];
+ port_cell.tx_link_rate[1] = g_tx_link_rate[1];
+ ifx_mei_atm_showtime_enter(&port_cell, g_xdata_addr);
+ }
+ else
+ {
+ IFX_MEI_EMSG("no hookup from ATM driver to set cell rate\n");
+ }
+
+ return DSL_DEV_MEI_ERR_SUCCESS;
+};
+
+/**
+ * Reset/halt/run the DFE.
+ * This function provide operations to reset/halt/run the DFE.
+ *
+ * \param pDev the device pointer
+ * \param mode which operation want to do
+ * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
+ * \ingroup Internal
+ */
+static DSL_DEV_MeiError_t
+IFX_MEI_CpuModeSet (DSL_DEV_Device_t *pDev,
+ DSL_DEV_CpuMode_t mode)
+{
+ DSL_DEV_MeiError_t err_ret = DSL_DEV_MEI_ERR_FAILURE;
+ switch (mode) {
+ case DSL_CPU_HALT:
+ err_ret = IFX_MEI_HaltArc (pDev);
+ break;
+ case DSL_CPU_RUN:
+ err_ret = IFX_MEI_RunArc (pDev);
+ break;
+ case DSL_CPU_RESET:
+ err_ret = IFX_MEI_ResetARC (pDev);
+ break;
+ default:
+ break;
+ }
+ return err_ret;
+}
+
+/**
+ * Accress DFE memory.
+ * This function provide a way to access DFE memory;
+ *
+ * \param pDev the device pointer
+ * \param type read or write
+ * \param destaddr destination address
+ * \param databuff pointer to hold data
+ * \param databuffsize size want to read/write
+ * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
+ * \ingroup Internal
+ */
+DSL_DEV_MeiError_t
+DSL_BSP_MemoryDebugAccess (DSL_DEV_Device_t * pDev,
+ DSL_BSP_MemoryAccessType_t type,
+ DSL_uint32_t destaddr, DSL_uint32_t *databuff,
+ DSL_uint32_t databuffsize)
+{
+ DSL_DEV_MeiError_t meierr = DSL_DEV_MEI_ERR_SUCCESS;
+ switch (type) {
+ case DSL_BSP_MEMORY_READ:
+ meierr = IFX_MEI_DebugRead (pDev, (u32)destaddr, (u32*)databuff, (u32)databuffsize);
+ break;
+ case DSL_BSP_MEMORY_WRITE:
+ meierr = IFX_MEI_DebugWrite (pDev, (u32)destaddr, (u32*)databuff, (u32)databuffsize);
+ break;
+ }
+ return DSL_DEV_MEI_ERR_SUCCESS;
+};
+
+/**
+ * Download boot code to ARC.
+ * This function downloads boot code to ARC.
+ *
+ * \param pDev the device pointer
+ * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
+ * \ingroup Internal
+ */
+static DSL_DEV_MeiError_t
+IFX_MEI_DownloadBootCode (DSL_DEV_Device_t *pDev)
+{
+ IFX_MEI_IRQDisable (pDev);
+
+ IFX_MEI_EnableCLK (pDev);
+
+ IFX_MEI_FuseProg (pDev); //program fuse rar
+
+ IFX_MEI_DownloadBootPages (pDev);
+
+ return DSL_DEV_MEI_ERR_SUCCESS;
+};
+
+/**
+ * Enable Jtag debugger interface
+ * This function setups mips gpio to enable jtag debugger
+ *
+ * \param pDev the device pointer
+ * \param enable enable or disable
+ * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
+ * \ingroup Internal
+ */
+static DSL_DEV_MeiError_t
+IFX_MEI_ArcJtagEnable (DSL_DEV_Device_t *dev, int enable)
+{
+ /*
+ int meierr=0;
+ u32 reg_data;
+ switch (enable) {
+ case 1:
+ //reserve gpio 9, 10, 11, 14, 19 for ARC JTAG
+ ifxmips_port_reserve_pin (0, 9);
+ ifxmips_port_reserve_pin (0, 10);
+ ifxmips_port_reserve_pin (0, 11);
+ ifxmips_port_reserve_pin (0, 14);
+ ifxmips_port_reserve_pin (1, 3);
+
+ ifxmips_port_set_dir_in(0, 11);
+ ifxmips_port_clear_altsel0(0, 11);
+ ifxmips_port_clear_altsel1(0, 11);
+ ifxmips_port_set_open_drain(0, 11);
+ //enable ARC JTAG
+ IFX_MEI_LongWordRead ((u32) LTQ_RCU_RST, &reg_data);
+ IFX_MEI_LongWordWrite ((u32) LTQ_RCU_RST, reg_data | LTQ_RCU_RST_REQ_ARC_JTAG);
+ break;
+ case 0:
+ default:
+ break;
+ }
+jtag_end:
+ if (meierr)
+ return DSL_DEV_MEI_ERR_FAILURE;
+*/
+
+ return DSL_DEV_MEI_ERR_SUCCESS;
+};
+
+/**
+ * Enable DFE to MIPS interrupt
+ * This function enable DFE to MIPS interrupt
+ *
+ * \param pDev the device pointer
+ * \param enable enable or disable
+ * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
+ * \ingroup Internal
+ */
+static DSL_DEV_MeiError_t
+IFX_MEI_AdslMailboxIRQEnable (DSL_DEV_Device_t *pDev, int enable)
+{
+ DSL_DEV_MeiError_t meierr;
+ switch (enable) {
+ case 0:
+ meierr = DSL_DEV_MEI_ERR_SUCCESS;
+ IFX_MEI_IRQDisable (pDev);
+ break;
+ case 1:
+ IFX_MEI_IRQEnable (pDev);
+ meierr = DSL_DEV_MEI_ERR_SUCCESS;
+ break;
+ default:
+ meierr = DSL_DEV_MEI_ERR_FAILURE;
+ break;
+
+ }
+ return meierr;
+}
+
+/**
+ * Get the modem status
+ * This function return the modem status
+ *
+ * \param pDev the device pointer
+ * \return 1: modem ready 0: not ready
+ * \ingroup Internal
+ */
+static int
+IFX_MEI_IsModemReady (DSL_DEV_Device_t * pDev)
+{
+ return DSL_DEV_PRIVATE(pDev)->modem_ready;
+}
+
+DSL_DEV_MeiError_t
+DSL_BSP_AdslLedInit (DSL_DEV_Device_t * dev,
+ DSL_DEV_LedId_t led_number,
+ DSL_DEV_LedType_t type,
+ DSL_DEV_LedHandler_t handler)
+{
+#if 0
+ struct led_config_param param;
+ if (led_number == DSL_LED_LINK_ID && type == DSL_LED_LINK_TYPE && handler == /*DSL_LED_HD_CPU*/DSL_LED_HD_FW) {
+ param.operation_mask = CONFIG_OPERATION_UPDATE_SOURCE;
+ param.led = 0x01;
+ param.source = 0x01;
+// bsp_led_config (&param);
+
+ } else if (led_number == DSL_LED_DATA_ID && type == DSL_LED_DATA_TYPE && (handler == DSL_LED_HD_FW)) {
+ param.operation_mask = CONFIG_OPERATION_UPDATE_SOURCE;
+ param.led = 0x02;
+ param.source = 0x02;
+// bsp_led_config (&param);
+ }
+#endif
+ return DSL_DEV_MEI_ERR_SUCCESS;
+};
+#if 0
+DSL_DEV_MeiError_t
+DSL_BSP_AdslLedSet (DSL_DEV_Device_t * dev, DSL_DEV_LedId_t led_number, DSL_DEV_LedMode_t mode)
+{
+ printk(KERN_INFO "[%s %d]: mode = %#x, led_number = %d\n", __func__, __LINE__, mode, led_number);
+ switch (mode) {
+ case DSL_LED_OFF:
+ switch (led_number) {
+ case DSL_LED_LINK_ID:
+#ifdef CONFIG_BSP_LED
+ bsp_led_set_blink (1, 0);
+ bsp_led_set_data (1, 0);
+#endif
+ break;
+ case DSL_LED_DATA_ID:
+#ifdef CONFIG_BSP_LED
+ bsp_led_set_blink (0, 0);
+ bsp_led_set_data (0, 0);
+#endif
+ break;
+ }
+ break;
+ case DSL_LED_FLASH:
+ switch (led_number) {
+ case DSL_LED_LINK_ID:
+#ifdef CONFIG_BSP_LED
+ bsp_led_set_blink (1, 1); // data
+#endif
+ break;
+ case DSL_LED_DATA_ID:
+#ifdef CONFIG_BSP_LED
+ bsp_led_set_blink (0, 1); // data
+#endif
+ break;
+ }
+ break;
+ case DSL_LED_ON:
+ switch (led_number) {
+ case DSL_LED_LINK_ID:
+#ifdef CONFIG_BSP_LED
+ bsp_led_set_blink (1, 0);
+ bsp_led_set_data (1, 1);
+#endif
+ break;
+ case DSL_LED_DATA_ID:
+#ifdef CONFIG_BSP_LED
+ bsp_led_set_blink (0, 0);
+ bsp_led_set_data (0, 1);
+#endif
+ break;
+ }
+ break;
+ }
+ return DSL_DEV_MEI_ERR_SUCCESS;
+};
+
+#endif
+
+/**
+* Compose a message.
+* This function compose a message from opcode, group, address, index, size, and data
+*
+* \param opcode The message opcode
+* \param group The message group number
+* \param address The message address.
+* \param index The message index.
+* \param size The number of words to read/write.
+* \param data The pointer to data.
+* \param CMVMSG The pointer to message buffer.
+* \ingroup Internal
+*/
+void
+makeCMV (u8 opcode, u8 group, u16 address, u16 index, int size, u16 * data, u16 *CMVMSG)
+{
+ memset (CMVMSG, 0, MSG_LENGTH * 2);
+ CMVMSG[0] = (opcode << 4) + (size & 0xf);
+ CMVMSG[1] = (((index == 0) ? 0 : 1) << 7) + (group & 0x7f);
+ CMVMSG[2] = address;
+ CMVMSG[3] = index;
+ if (opcode == H2D_CMV_WRITE)
+ memcpy (CMVMSG + 4, data, size * 2);
+ return;
+}
+
+/**
+ * Send a message to ARC and read the response
+ * This function sends a message to arc, waits the response, and reads the responses.
+ *
+ * \param pDev the device pointer
+ * \param request Pointer to the request
+ * \param reply Wait reply or not.
+ * \param response Pointer to the response
+ * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
+ * \ingroup Internal
+ */
+DSL_DEV_MeiError_t
+DSL_BSP_SendCMV (DSL_DEV_Device_t * pDev, u16 * request, int reply, u16 * response) // write cmv to arc, if reply needed, wait for reply
+{
+ DSL_DEV_MeiError_t meierror;
+#if defined(BSP_PORT_RTEMS)
+ int delay_counter = 0;
+#endif
+
+ if (MEI_MUTEX_LOCK (DSL_DEV_PRIVATE(pDev)->mei_cmv_sema))
+ return -ERESTARTSYS;
+
+ DSL_DEV_PRIVATE(pDev)->cmv_reply = reply;
+ memset (DSL_DEV_PRIVATE(pDev)->CMV_RxMsg, 0,
+ sizeof (DSL_DEV_PRIVATE(pDev)->
+ CMV_RxMsg));
+ DSL_DEV_PRIVATE(pDev)->arcmsgav = 0;
+
+ meierror = IFX_MEI_MailboxWrite (pDev, request, MSG_LENGTH);
+
+ if (meierror != DSL_DEV_MEI_ERR_SUCCESS) {
+ DSL_DEV_PRIVATE(pDev)->cmv_waiting = 0;
+ DSL_DEV_PRIVATE(pDev)->arcmsgav = 0;
+ IFX_MEI_EMSG ("MailboxWrite Fail!\n");
+ IFX_MEI_EMSG ("Resetting ARC...\n");
+ IFX_MEI_ResetARC(pDev);
+ MEI_MUTEX_UNLOCK (DSL_DEV_PRIVATE(pDev)->mei_cmv_sema);
+ return meierror;
+ }
+ else {
+ DSL_DEV_PRIVATE(pDev)->cmv_count++;
+ }
+
+ if (DSL_DEV_PRIVATE(pDev)->cmv_reply ==
+ NO_REPLY) {
+ MEI_MUTEX_UNLOCK (DSL_DEV_PRIVATE(pDev)->mei_cmv_sema);
+ return DSL_DEV_MEI_ERR_SUCCESS;
+ }
+
+#if !defined(BSP_PORT_RTEMS)
+ if (DSL_DEV_PRIVATE(pDev)->arcmsgav == 0)
+ MEI_WAIT_EVENT_TIMEOUT (DSL_DEV_PRIVATE(pDev)->wait_queue_arcmsgav, CMV_TIMEOUT);
+#else
+ while (DSL_DEV_PRIVATE(pDev)->arcmsgav == 0 && delay_counter < CMV_TIMEOUT / 5) {
+ MEI_WAIT (5);
+ delay_counter++;
+ }
+#endif
+
+ DSL_DEV_PRIVATE(pDev)->cmv_waiting = 0;
+ if (DSL_DEV_PRIVATE(pDev)->arcmsgav == 0) { //CMV_timeout
+ DSL_DEV_PRIVATE(pDev)->arcmsgav = 0;
+ IFX_MEI_EMSG ("\%s: DSL_DEV_MEI_ERR_MAILBOX_TIMEOUT\n",
+ __FUNCTION__);
+ MEI_MUTEX_UNLOCK (DSL_DEV_PRIVATE(pDev)->mei_cmv_sema);
+ return DSL_DEV_MEI_ERR_MAILBOX_TIMEOUT;
+ }
+ else {
+ DSL_DEV_PRIVATE(pDev)->arcmsgav = 0;
+ DSL_DEV_PRIVATE(pDev)->
+ reply_count++;
+ memcpy (response, DSL_DEV_PRIVATE(pDev)->CMV_RxMsg, MSG_LENGTH * 2);
+ MEI_MUTEX_UNLOCK (DSL_DEV_PRIVATE(pDev)->mei_cmv_sema);
+ return DSL_DEV_MEI_ERR_SUCCESS;
+ }
+ MEI_MUTEX_UNLOCK (DSL_DEV_PRIVATE(pDev)->mei_cmv_sema);
+ return DSL_DEV_MEI_ERR_SUCCESS;
+}
+
+/**
+ * Reset the ARC, download boot codes, and run the ARC.
+ * This function resets the ARC, downloads boot codes to ARC, and runs the ARC.
+ *
+ * \param pDev the device pointer
+ * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
+ * \ingroup Internal
+ */
+static DSL_DEV_MeiError_t
+IFX_MEI_RunAdslModem (DSL_DEV_Device_t *pDev)
+{
+ int nSize = 0, idx = 0;
+ uint32_t im0_register, im2_register;
+// DSL_DEV_WinHost_Message_t m;
+
+ if (mei_arc_swap_buff == NULL) {
+ mei_arc_swap_buff =
+ (u32 *) kmalloc (MAXSWAPSIZE * 4, GFP_KERNEL);
+ if (mei_arc_swap_buff == NULL) {
+ IFX_MEI_EMSG (">>> malloc fail for codeswap buff!!! <<<\n");
+ return DSL_DEV_MEI_ERR_FAILURE;
+ }
+ IFX_MEI_DMSG("allocate %dKB swap buff memory at: 0x%p\n", ksize(mei_arc_swap_buff)/1024, mei_arc_swap_buff);
+ }
+
+ DSL_DEV_PRIVATE(pDev)->img_hdr =
+ (ARC_IMG_HDR *) DSL_DEV_PRIVATE(pDev)->adsl_mem_info[0].address;
+ if ((DSL_DEV_PRIVATE(pDev)->img_hdr->
+ count) * sizeof (ARC_SWP_PAGE_HDR) > SDRAM_SEGMENT_SIZE) {
+ IFX_MEI_EMSG ("firmware header size is bigger than 64K segment size\n");
+ return DSL_DEV_MEI_ERR_FAILURE;
+ }
+ // check image size
+ for (idx = 0; idx < MAX_BAR_REGISTERS; idx++) {
+ nSize += DSL_DEV_PRIVATE(pDev)->adsl_mem_info[idx].nCopy;
+ }
+ if (nSize !=
+ DSL_DEV_PRIVATE(pDev)->image_size) {
+ IFX_MEI_EMSG ("Firmware download is not completed. Please download firmware again!\n");
+ return DSL_DEV_MEI_ERR_FAILURE;
+ }
+ // TODO: check crc
+ ///
+
+ IFX_MEI_ResetARC (pDev);
+ IFX_MEI_HaltArc (pDev);
+ IFX_MEI_BarUpdate (pDev, DSL_DEV_PRIVATE(pDev)->nBar);
+
+ //IFX_MEI_DMSG("Starting to meiDownloadBootCode\n");
+
+ IFX_MEI_DownloadBootCode (pDev);
+
+ im0_register = (*LTQ_ICU_IM0_IER) & (1 << 20);
+ im2_register = (*LTQ_ICU_IM2_IER) & (1 << 20);
+ /* Turn off irq */
+ #ifdef CONFIG_SOC_AMAZON_SE
+#define IFXMIPS_USB_OC_INT0 (INT_NUM_IM4_IRL0 + 23)
+ disable_irq (IFXMIPS_USB_OC_INT0);
+// disable_irq (IFXMIPS_USB_OC_INT2);
+ #elif defined(CONFIG_SOC_AR9)
+#define IFXMIPS_USB_OC_INT0 (INT_NUM_IM4_IRL1 + 28)
+ disable_irq (IFXMIPS_USB_OC_INT0);
+// disable_irq (IFXMIPS_USB_OC_INT2);
+ #elif defined(CONFIG_SOC_XWAY)
+ disable_irq (LTQ_USB_OC_INT);
+ #else
+ #error unkonwn arch
+ #endif
+ disable_irq (pDev->nIrq[IFX_DYING_GASP]);
+
+ IFX_MEI_RunArc (pDev);
+
+ MEI_WAIT_EVENT_TIMEOUT (DSL_DEV_PRIVATE(pDev)->wait_queue_modemready, 1000);
+
+ #ifdef CONFIG_SOC_AMAZON_SE
+ MEI_MASK_AND_ACK_IRQ (IFXMIPS_USB_OC_INT0);
+// MEI_MASK_AND_ACK_IRQ (IFXMIPS_USB_OC_INT2);
+ #elif defined(CONFIG_SOC_AR9)
+ MEI_MASK_AND_ACK_IRQ (IFXMIPS_USB_OC_INT0);
+// MEI_MASK_AND_ACK_IRQ (IFXMIPS_USB_OC_INT2);
+ #elif defined(CONFIG_SOC_XWAY)
+ MEI_MASK_AND_ACK_IRQ (LTQ_USB_OC_INT);
+ #else
+ #error unkonwn arch
+ #endif
+ MEI_MASK_AND_ACK_IRQ (pDev->nIrq[IFX_DYING_GASP]);
+
+ /* Re-enable irq */
+ enable_irq(pDev->nIrq[IFX_DYING_GASP]);
+ *LTQ_ICU_IM0_IER |= im0_register;
+ *LTQ_ICU_IM2_IER |= im2_register;
+
+ if (DSL_DEV_PRIVATE(pDev)->modem_ready != 1) {
+ IFX_MEI_EMSG ("Modem failed to be ready!\n");
+ return DSL_DEV_MEI_ERR_FAILURE;
+ } else {
+ IFX_MEI_DMSG("Modem is ready.\n");
+ return DSL_DEV_MEI_ERR_SUCCESS;
+ }
+}
+
+/**
+ * Get the page's data pointer
+ * This function caculats the data address from the firmware header.
+ *
+ * \param pDev the device pointer
+ * \param Page The page number.
+ * \param data Data page or program page.
+ * \param MaxSize The maximum size to read.
+ * \param Buffer Pointer to data.
+ * \param Dest Pointer to the destination address.
+ * \return The number of bytes to read.
+ * \ingroup Internal
+ */
+static int
+IFX_MEI_GetPage (DSL_DEV_Device_t * pDev, u32 Page, u32 data,
+ u32 MaxSize, u32 * Buffer, u32 * Dest)
+{
+ u32 size;
+ u32 i;
+ u32 *p;
+ u32 idx, offset, nBar = 0;
+
+ if (Page > DSL_DEV_PRIVATE(pDev)->img_hdr->count)
+ return -2;
+ /*
+ ** Get program or data size, depending on "data" flag
+ */
+ size = (data == GET_DATA) ? (DSL_DEV_PRIVATE(pDev)->img_hdr->page[Page].d_size) :
+ (DSL_DEV_PRIVATE(pDev)->img_hdr->page[Page].p_size);
+ size &= BOOT_FLAG_MASK; // Clear boot bit!
+ if (size > MaxSize)
+ return -1;
+
+ if (size == 0)
+ return 0;
+ /*
+ ** Get program or data offset, depending on "data" flag
+ */
+ i = data ? (DSL_DEV_PRIVATE(pDev)->img_hdr->page[Page].d_offset) :
+ (DSL_DEV_PRIVATE(pDev)->img_hdr->page[Page].p_offset);
+
+ /*
+ ** Copy data/program to buffer
+ */
+
+ idx = i / SDRAM_SEGMENT_SIZE;
+ offset = i % SDRAM_SEGMENT_SIZE;
+ p = (u32 *) ((u8 *) DSL_DEV_PRIVATE(pDev)->adsl_mem_info[idx].address + offset);
+
+ for (i = 0; i < size; i++) {
+ if (offset + i * 4 - (nBar * SDRAM_SEGMENT_SIZE) >= SDRAM_SEGMENT_SIZE) {
+ idx++;
+ nBar++;
+ p = (u32 *) ((u8 *) KSEG1ADDR ((u32)DSL_DEV_PRIVATE(pDev)->adsl_mem_info[idx].address));
+ }
+ Buffer[i] = *p++;
+ }
+
+ /*
+ ** Pass back data/program destination address
+ */
+ *Dest = data ? (DSL_DEV_PRIVATE(pDev)-> img_hdr->page[Page].d_dest) :
+ (DSL_DEV_PRIVATE(pDev)->img_hdr->page[Page].p_dest);
+
+ return size;
+}
+
+/**
+ * Free the memory for ARC firmware
+ *
+ * \param pDev the device pointer
+ * \param type Free all memory or free the unused memory after showtime
+ * \ingroup Internal
+ */
+const char *free_str[4] = {"Invalid", "Free_Reload", "Free_Showtime", "Free_All"};
+static int
+IFX_MEI_DFEMemoryFree (DSL_DEV_Device_t * pDev, int type)
+{
+ int idx = 0;
+ smmu_mem_info_t *adsl_mem_info =
+ DSL_DEV_PRIVATE(pDev)->adsl_mem_info;
+
+ for (idx = 0; idx < MAX_BAR_REGISTERS; idx++) {
+ if (type == FREE_ALL ||adsl_mem_info[idx].type == type) {
+ if (adsl_mem_info[idx].size > 0) {
+ IFX_MEI_DMSG ("Freeing memory %p (%s)\n", adsl_mem_info[idx].org_address, free_str[adsl_mem_info[idx].type]);
+ if ( idx == XDATA_REGISTER ) {
+ g_xdata_addr = NULL;
+ if ( ifx_mei_atm_showtime_exit )
+ ifx_mei_atm_showtime_exit();
+ }
+ kfree (adsl_mem_info[idx].org_address);
+ adsl_mem_info[idx].org_address = 0;
+ adsl_mem_info[idx].address = 0;
+ adsl_mem_info[idx].size = 0;
+ adsl_mem_info[idx].type = 0;
+ adsl_mem_info[idx].nCopy = 0;
+ }
+ }
+ }
+
+ if(mei_arc_swap_buff != NULL){
+ IFX_MEI_DMSG("free %dKB swap buff memory at: 0x%p\n", ksize(mei_arc_swap_buff)/1024, mei_arc_swap_buff);
+ kfree(mei_arc_swap_buff);
+ mei_arc_swap_buff=NULL;
+ }
+
+ return 0;
+}
+static int
+IFX_MEI_DFEMemoryAlloc (DSL_DEV_Device_t * pDev, long size)
+{
+ unsigned long mem_ptr;
+ char *org_mem_ptr = NULL;
+ int idx = 0;
+ long total_size = 0;
+ int err = 0;
+ smmu_mem_info_t *adsl_mem_info =
+ ((ifx_mei_device_private_t *) pDev->pPriv)->adsl_mem_info;
+// DSL_DEV_PRIVATE(pDev)->adsl_mem_info;
+ int allocate_size = SDRAM_SEGMENT_SIZE;
+
+ IFX_MEI_DMSG("image_size = %ld\n", size);
+ // Alloc Swap Pages
+ for (idx = 0; size > 0 && idx < MAX_BAR_REGISTERS; idx++) {
+ // skip bar15 for XDATA usage.
+ if (idx == XDATA_REGISTER)
+ continue;
+#if 0
+ if (size < SDRAM_SEGMENT_SIZE) {
+ allocate_size = size;
+ if (allocate_size < 1024)
+ allocate_size = 1024;
+ }
+#endif
+ if (idx == (MAX_BAR_REGISTERS - 1))
+ allocate_size = size;
+ else
+ allocate_size = SDRAM_SEGMENT_SIZE;
+ org_mem_ptr = kmalloc (allocate_size + 1024, GFP_KERNEL);
+ if (org_mem_ptr == NULL) {
+ IFX_MEI_EMSG ("%d: kmalloc %d bytes memory fail!\n", idx, allocate_size);
+ err = -ENOMEM;
+ goto allocate_error;
+ }
+ mem_ptr = (unsigned long) (org_mem_ptr + 1023) & ~(1024 -1);
+ adsl_mem_info[idx].address = (char *) mem_ptr;
+ adsl_mem_info[idx].org_address = org_mem_ptr;
+ adsl_mem_info[idx].size = allocate_size;
+ size -= allocate_size;
+ total_size += allocate_size;
+ }
+ if (size > 0) {
+ IFX_MEI_EMSG ("Image size is too large!\n");
+ err = -EFBIG;
+ goto allocate_error;
+ }
+ err = idx;
+ return err;
+
+ allocate_error:
+ IFX_MEI_DFEMemoryFree (pDev, FREE_ALL);
+ return err;
+}
+
+/**
+ * Program the BAR registers
+ *
+ * \param pDev the device pointer
+ * \param nTotalBar The number of bar to program.
+ * \ingroup Internal
+ */
+static int
+IFX_MEI_BarUpdate (DSL_DEV_Device_t * pDev, int nTotalBar)
+{
+ int idx = 0;
+ smmu_mem_info_t *adsl_mem_info =
+ DSL_DEV_PRIVATE(pDev)->adsl_mem_info;
+
+ for (idx = 0; idx < nTotalBar; idx++) {
+ //skip XDATA register
+ if (idx == XDATA_REGISTER)
+ continue;
+ IFX_MEI_LongWordWriteOffset (pDev, (u32) ME_XMEM_BAR_BASE + idx * 4,
+ (((uint32_t) adsl_mem_info[idx].address) & 0x0FFFFFFF));
+ }
+ for (idx = nTotalBar; idx < MAX_BAR_REGISTERS; idx++) {
+ if (idx == XDATA_REGISTER)
+ continue;
+ IFX_MEI_LongWordWriteOffset (pDev, (u32) ME_XMEM_BAR_BASE + idx * 4,
+ (((uint32_t)adsl_mem_info[nTotalBar - 1].address) & 0x0FFFFFFF));
+ /* These are for /proc/danube_mei/meminfo purpose */
+ adsl_mem_info[idx].address = adsl_mem_info[nTotalBar - 1].address;
+ adsl_mem_info[idx].org_address = adsl_mem_info[nTotalBar - 1].org_address;
+ adsl_mem_info[idx].size = 0; /* Prevent it from being freed */
+ }
+
+ g_xdata_addr = adsl_mem_info[XDATA_REGISTER].address;
+ IFX_MEI_LongWordWriteOffset (pDev, (u32) ME_XMEM_BAR_BASE + XDATA_REGISTER * 4,
+ (((uint32_t) adsl_mem_info [XDATA_REGISTER].address) & 0x0FFFFFFF));
+ // update MEI_XDATA_BASE_SH
+ IFX_MEI_LongWordWriteOffset (pDev, (u32) ME_XDATA_BASE_SH,
+ ((unsigned long)adsl_mem_info[XDATA_REGISTER].address) & 0x0FFFFFFF);
+
+ return DSL_DEV_MEI_ERR_SUCCESS;
+}
+
+/* This copies the firmware from secondary storage to 64k memory segment in SDRAM */
+DSL_DEV_MeiError_t
+DSL_BSP_FWDownload (DSL_DEV_Device_t * pDev, const char *buf,
+ unsigned long size, long *loff, long *current_offset)
+{
+ ARC_IMG_HDR img_hdr_tmp;
+ smmu_mem_info_t *adsl_mem_info = DSL_DEV_PRIVATE(pDev)->adsl_mem_info;
+
+ size_t nRead = 0, nCopy = 0;
+ char *mem_ptr;
+ ssize_t retval = -ENOMEM;
+ int idx = 0;
+
+ IFX_MEI_DMSG("\n");
+
+ if (*loff == 0) {
+ if (size < sizeof (img_hdr_tmp)) {
+ IFX_MEI_EMSG ("Firmware size is too small!\n");
+ return retval;
+ }
+ copy_from_user ((char *) &img_hdr_tmp, buf, sizeof (img_hdr_tmp));
+ // header of image_size and crc are not included.
+ DSL_DEV_PRIVATE(pDev)->image_size = le32_to_cpu (img_hdr_tmp.size) + 8;
+
+ if (DSL_DEV_PRIVATE(pDev)->image_size > 1024 * 1024) {
+ IFX_MEI_EMSG ("Firmware size is too large!\n");
+ return retval;
+ }
+ // check if arc is halt
+ IFX_MEI_ResetARC (pDev);
+ IFX_MEI_HaltArc (pDev);
+
+ IFX_MEI_DFEMemoryFree (pDev, FREE_ALL); //free all
+
+ retval = IFX_MEI_DFEMemoryAlloc (pDev, DSL_DEV_PRIVATE(pDev)->image_size);
+ if (retval < 0) {
+ IFX_MEI_EMSG ("Error: No memory space left.\n");
+ goto error;
+ }
+ for (idx = 0; idx < retval; idx++) {
+ //skip XDATA register
+ if (idx == XDATA_REGISTER)
+ continue;
+ if (idx * SDRAM_SEGMENT_SIZE < le32_to_cpu (img_hdr_tmp.page[0].p_offset))
+ adsl_mem_info[idx].type = FREE_RELOAD;
+ else
+ adsl_mem_info[idx].type = FREE_SHOWTIME;
+ }
+ DSL_DEV_PRIVATE(pDev)->nBar = retval;
+
+ DSL_DEV_PRIVATE(pDev)->img_hdr =
+ (ARC_IMG_HDR *) adsl_mem_info[0].address;
+
+ adsl_mem_info[XDATA_REGISTER].org_address = kmalloc (SDRAM_SEGMENT_SIZE + 1024, GFP_KERNEL);
+ adsl_mem_info[XDATA_REGISTER].address =
+ (char *) ((unsigned long) (adsl_mem_info[XDATA_REGISTER].org_address + 1023) & 0xFFFFFC00);
+
+ adsl_mem_info[XDATA_REGISTER].size = SDRAM_SEGMENT_SIZE;
+
+ if (adsl_mem_info[XDATA_REGISTER].address == NULL) {
+ IFX_MEI_EMSG ("kmalloc memory fail!\n");
+ retval = -ENOMEM;
+ goto error;
+ }
+ adsl_mem_info[XDATA_REGISTER].type = FREE_RELOAD;
+ IFX_MEI_DMSG("-> IFX_MEI_BarUpdate()\n");
+ IFX_MEI_BarUpdate (pDev, (DSL_DEV_PRIVATE(pDev)->nBar));
+ }
+ else if (DSL_DEV_PRIVATE(pDev)-> image_size == 0) {
+ IFX_MEI_EMSG ("Error: Firmware size=0! \n");
+ goto error;
+ }
+
+ nRead = 0;
+ while (nRead < size) {
+ long offset = ((long) (*loff) + nRead) % SDRAM_SEGMENT_SIZE;
+ idx = (((long) (*loff)) + nRead) / SDRAM_SEGMENT_SIZE;
+ mem_ptr = (char *) KSEG1ADDR ((unsigned long) (adsl_mem_info[idx].address) + offset);
+ if ((size - nRead + offset) > SDRAM_SEGMENT_SIZE)
+ nCopy = SDRAM_SEGMENT_SIZE - offset;
+ else
+ nCopy = size - nRead;
+ copy_from_user (mem_ptr, buf + nRead, nCopy);
+ for (offset = 0; offset < (nCopy / 4); offset++) {
+ ((unsigned long *) mem_ptr)[offset] = le32_to_cpu (((unsigned long *) mem_ptr)[offset]);
+ }
+ nRead += nCopy;
+ adsl_mem_info[idx].nCopy += nCopy;
+ }
+
+ *loff += size;
+ *current_offset = size;
+ return DSL_DEV_MEI_ERR_SUCCESS;
+error:
+ IFX_MEI_DFEMemoryFree (pDev, FREE_ALL);
+ return DSL_DEV_MEI_ERR_FAILURE;
+}
+/*
+ * Register a callback event.
+ * Return:
+ * -1 if the event already has a callback function registered.
+ * 0 success
+ */
+int DSL_BSP_EventCBRegister(DSL_BSP_EventCallBack_t *p)
+{
+ if (!p) {
+ IFX_MEI_EMSG("Invalid parameter!\n");
+ return -EINVAL;
+ }
+ if (p->event > DSL_BSP_CB_LAST || p->event < DSL_BSP_CB_FIRST) {
+ IFX_MEI_EMSG("Invalid Event %d\n", p->event);
+ return -EINVAL;
+ }
+ if (dsl_bsp_event_callback[p->event].function) {
+ IFX_MEI_EMSG("Event %d already has a callback function registered!\n", p->event);
+ return -1;
+ } else {
+ dsl_bsp_event_callback[p->event].function = p->function;
+ dsl_bsp_event_callback[p->event].event = p->event;
+ dsl_bsp_event_callback[p->event].pData = p->pData;
+ }
+ return 0;
+}
+int DSL_BSP_EventCBUnregister(DSL_BSP_EventCallBack_t *p)
+{
+ if (!p) {
+ IFX_MEI_EMSG("Invalid parameter!\n");
+ return -EINVAL;
+ }
+ if (p->event > DSL_BSP_CB_LAST || p->event < DSL_BSP_CB_FIRST) {
+ IFX_MEI_EMSG("Invalid Event %d\n", p->event);
+ return -EINVAL;
+ }
+ if (dsl_bsp_event_callback[p->event].function) {
+ IFX_MEI_EMSG("Unregistering Event %d...\n", p->event);
+ dsl_bsp_event_callback[p->event].function = NULL;
+ dsl_bsp_event_callback[p->event].pData = NULL;
+ } else {
+ IFX_MEI_EMSG("Event %d is not registered!\n", p->event);
+ return -1;
+ }
+ return 0;
+}
+
+/**
+ * MEI Dying Gasp interrupt handler
+ *
+ * \param int1
+ * \param void0
+ * \param regs Pointer to the structure of danube mips registers
+ * \ingroup Internal
+ */
+/*static irqreturn_t IFX_MEI_Dying_Gasp_IrqHandle (int int1, void *void0)
+{
+ DSL_DEV_Device_t *pDev = (DSL_DEV_Device_t *) void0;
+ DSL_BSP_CB_Type_t event;
+
+ if (pDev == NULL)
+ IFX_MEI_EMSG("Error: Got Interrupt but pDev is NULL!!!!\n");
+
+#ifndef CONFIG_SMP
+ disable_irq (pDev->nIrq[IFX_DYING_GASP]);
+#else
+ disable_irq_nosync(pDev->nIrq[IFX_DYING_GASP]);
+#endif
+ event = DSL_BSP_CB_DYING_GASP;
+
+ if (dsl_bsp_event_callback[event].function)
+ (*dsl_bsp_event_callback[event].function)(pDev, event, dsl_bsp_event_callback[event].pData);
+
+#ifdef CONFIG_USE_EMULATOR
+ IFX_MEI_EMSG("Dying Gasp! Shutting Down... (Work around for Amazon-S Venus emulator)\n");
+#else
+ IFX_MEI_EMSG("Dying Gasp! Shutting Down...\n");
+// kill_proc (1, SIGINT, 1);
+#endif
+ return IRQ_HANDLED;
+}
+*/
+extern void ifx_usb_enable_afe_oc(void);
+
+/**
+ * MEI interrupt handler
+ *
+ * \param int1
+ * \param void0
+ * \param regs Pointer to the structure of danube mips registers
+ * \ingroup Internal
+ */
+static irqreturn_t IFX_MEI_IrqHandle (int int1, void *void0)
+{
+ u32 scratch;
+ DSL_DEV_Device_t *pDev = (DSL_DEV_Device_t *) void0;
+#if defined(CONFIG_LTQ_MEI_FW_LOOPBACK) && defined(DFE_PING_TEST)
+ dfe_loopback_irq_handler (pDev);
+ return IRQ_HANDLED;
+#endif //CONFIG_AMAZON_S_MEI_FW_LOOPBACK
+ DSL_BSP_CB_Type_t event;
+
+ if (pDev == NULL)
+ IFX_MEI_EMSG("Error: Got Interrupt but pDev is NULL!!!!\n");
+
+ IFX_MEI_DebugRead (pDev, ARC_MEI_MAILBOXR, &scratch, 1);
+ if (scratch & OMB_CODESWAP_MESSAGE_MSG_TYPE_MASK) {
+ IFX_MEI_EMSG("Receive Code Swap Request interrupt!!!\n");
+ return IRQ_HANDLED;
+ }
+ else if (scratch & OMB_CLEAREOC_INTERRUPT_CODE) {
+ // clear eoc message interrupt
+ IFX_MEI_DMSG("OMB_CLEAREOC_INTERRUPT_CODE\n");
+ event = DSL_BSP_CB_CEOC_IRQ;
+ IFX_MEI_LongWordWriteOffset (pDev, (u32) ME_ARC2ME_STAT, ARC_TO_MEI_MSGAV);
+ if (dsl_bsp_event_callback[event].function)
+ (*dsl_bsp_event_callback[event].function)(pDev, event, dsl_bsp_event_callback[event].pData);
+ } else if (scratch & OMB_REBOOT_INTERRUPT_CODE) {
+ // Reboot
+ IFX_MEI_DMSG("OMB_REBOOT_INTERRUPT_CODE\n");
+ event = DSL_BSP_CB_FIRMWARE_REBOOT;
+
+ IFX_MEI_LongWordWriteOffset (pDev, (u32) ME_ARC2ME_STAT, ARC_TO_MEI_MSGAV);
+
+ if (dsl_bsp_event_callback[event].function)
+ (*dsl_bsp_event_callback[event].function)(pDev, event, dsl_bsp_event_callback[event].pData);
+ } else { // normal message
+ IFX_MEI_MailboxRead (pDev, DSL_DEV_PRIVATE(pDev)->CMV_RxMsg, MSG_LENGTH);
+ if (DSL_DEV_PRIVATE(pDev)-> cmv_waiting == 1) {
+ DSL_DEV_PRIVATE(pDev)-> arcmsgav = 1;
+ DSL_DEV_PRIVATE(pDev)-> cmv_waiting = 0;
+#if !defined(BSP_PORT_RTEMS)
+ MEI_WAKEUP_EVENT (DSL_DEV_PRIVATE(pDev)->wait_queue_arcmsgav);
+#endif
+ }
+ else {
+ DSL_DEV_PRIVATE(pDev)-> modem_ready_cnt++;
+ memcpy ((char *) DSL_DEV_PRIVATE(pDev)->Recent_indicator,
+ (char *) DSL_DEV_PRIVATE(pDev)->CMV_RxMsg, MSG_LENGTH * 2);
+ if (((DSL_DEV_PRIVATE(pDev)->CMV_RxMsg[0] & 0xff0) >> 4) == D2H_AUTONOMOUS_MODEM_READY_MSG) {
+ //check ARC ready message
+ IFX_MEI_DMSG ("Got MODEM_READY_MSG\n");
+ DSL_DEV_PRIVATE(pDev)->modem_ready = 1;
+ MEI_WAKEUP_EVENT (DSL_DEV_PRIVATE(pDev)->wait_queue_modemready);
+ }
+ }
+ }
+
+ return IRQ_HANDLED;
+}
+
+int
+DSL_BSP_ATMLedCBRegister (int (*ifx_adsl_ledcallback) (void))
+{
+ g_adsl_ledcallback = ifx_adsl_ledcallback;
+ return 0;
+}
+
+int
+DSL_BSP_ATMLedCBUnregister (int (*ifx_adsl_ledcallback) (void))
+{
+ g_adsl_ledcallback = adsl_dummy_ledcallback;
+ return 0;
+}
+
+#if 0
+int
+DSL_BSP_EventCBRegister (int (*ifx_adsl_callback)
+ (DSL_BSP_CB_Event_t * param))
+{
+ int error = 0;
+
+ if (DSL_EventCB == NULL) {
+ DSL_EventCB = ifx_adsl_callback;
+ }
+ else {
+ error = -EIO;
+ }
+ return error;
+}
+
+int
+DSL_BSP_EventCBUnregister (int (*ifx_adsl_callback)
+ (DSL_BSP_CB_Event_t * param))
+{
+ int error = 0;
+
+ if (DSL_EventCB == ifx_adsl_callback) {
+ DSL_EventCB = NULL;
+ }
+ else {
+ error = -EIO;
+ }
+ return error;
+}
+
+static int
+DSL_BSP_GetEventCB (int (**ifx_adsl_callback)
+ (DSL_BSP_CB_Event_t * param))
+{
+ *ifx_adsl_callback = DSL_EventCB;
+ return 0;
+}
+#endif
+
+#ifdef CONFIG_LTQ_MEI_FW_LOOPBACK
+#define mte_reg_base (0x4800*4+0x20000)
+
+/* Iridia Registers Address Constants */
+#define MTE_Reg(r) (int)(mte_reg_base + (r*4))
+
+#define IT_AMODE MTE_Reg(0x0004)
+
+#define TIMER_DELAY (1024)
+#define BC0_BYTES (32)
+#define BC1_BYTES (30)
+#define NUM_MB (12)
+#define TIMEOUT_VALUE 2000
+
+static void
+BFMWait (u32 cycle)
+{
+ u32 i;
+ for (i = 0; i < cycle; i++);
+}
+
+static void
+WriteRegLong (u32 addr, u32 data)
+{
+ //*((volatile u32 *)(addr)) = data;
+ IFX_MEI_WRITE_REGISTER_L (data, addr);
+}
+
+static u32
+ReadRegLong (u32 addr)
+{
+ // u32 rd_val;
+ //rd_val = *((volatile u32 *)(addr));
+ // return rd_val;
+ return IFX_MEI_READ_REGISTER_L (addr);
+}
+
+/* This routine writes the mailbox with the data in an input array */
+static void
+WriteMbox (u32 * mboxarray, u32 size)
+{
+ IFX_MEI_DebugWrite (&dsl_devices[0], IMBOX_BASE, mboxarray, size);
+ IFX_MEI_DMSG("write to %X\n", IMBOX_BASE);
+ IFX_MEI_LongWordWriteOffset (&dsl_devices[0], (u32) ME_ME2ARC_INT, MEI_TO_ARC_MSGAV);
+}
+
+/* This routine reads the output mailbox and places the results into an array */
+static void
+ReadMbox (u32 * mboxarray, u32 size)
+{
+ IFX_MEI_DebugRead (&dsl_devices[0], OMBOX_BASE, mboxarray, size);
+ IFX_MEI_DMSG("read from %X\n", OMBOX_BASE);
+}
+
+static void
+MEIWriteARCValue (u32 address, u32 value)
+{
+ u32 i, check = 0;
+
+ /* Write address register */
+ IFX_MEI_WRITE_REGISTER_L (address, ME_DBG_WR_AD + LTQ_MEI_BASE_ADDR);
+
+ /* Write data register */
+ IFX_MEI_WRITE_REGISTER_L (value, ME_DBG_DATA + LTQ_MEI_BASE_ADDR);
+
+ /* wait until complete - timeout at 40 */
+ for (i = 0; i < 40; i++) {
+ check = IFX_MEI_READ_REGISTER_L (ME_ARC2ME_STAT + LTQ_MEI_BASE_ADDR);
+
+ if ((check & ARC_TO_MEI_DBG_DONE))
+ break;
+ }
+ /* clear the flag */
+ IFX_MEI_WRITE_REGISTER_L (ARC_TO_MEI_DBG_DONE, ME_ARC2ME_STAT + LTQ_MEI_BASE_ADDR);
+}
+
+void
+arc_code_page_download (uint32_t arc_code_length, uint32_t * start_address)
+{
+ int count;
+
+ IFX_MEI_DMSG("try to download pages,size=%d\n", arc_code_length);
+ IFX_MEI_ControlModeSet (&dsl_devices[0], MEI_MASTER_MODE);
+ IFX_MEI_HaltArc (&dsl_devices[0]);
+ IFX_MEI_LongWordWriteOffset (&dsl_devices[0], (u32) ME_DX_AD, 0);
+ for (count = 0; count < arc_code_length; count++) {
+ IFX_MEI_LongWordWriteOffset (&dsl_devices[0], (u32) ME_DX_DATA,
+ *(start_address + count));
+ }
+ IFX_MEI_ControlModeSet (&dsl_devices[0], JTAG_MASTER_MODE);
+}
+static int
+load_jump_table (unsigned long addr)
+{
+ int i;
+ uint32_t addr_le, addr_be;
+ uint32_t jump_table[32];
+
+ for (i = 0; i < 16; i++) {
+ addr_le = i * 8 + addr;
+ addr_be = ((addr_le >> 16) & 0xffff);
+ addr_be |= ((addr_le & 0xffff) << 16);
+ jump_table[i * 2 + 0] = 0x0f802020;
+ jump_table[i * 2 + 1] = addr_be;
+ //printk("jt %X %08X %08X\n",i,jump_table[i*2+0],jump_table[i*2+1]);
+ }
+ arc_code_page_download (32, &jump_table[0]);
+return 0;
+}
+
+int got_int = 0;
+
+void
+dfe_loopback_irq_handler (DSL_DEV_Device_t *pDev)
+{
+ uint32_t rd_mbox[10];
+
+ memset (&rd_mbox[0], 0, 10 * 4);
+ ReadMbox (&rd_mbox[0], 6);
+ if (rd_mbox[0] == 0x0) {
+ FX_MEI_DMSG("Get ARC_ACK\n");
+ got_int = 1;
+ }
+ else if (rd_mbox[0] == 0x5) {
+ IFX_MEI_DMSG("Get ARC_BUSY\n");
+ got_int = 2;
+ }
+ else if (rd_mbox[0] == 0x3) {
+ IFX_MEI_DMSG("Get ARC_EDONE\n");
+ if (rd_mbox[1] == 0x0) {
+ got_int = 3;
+ IFX_MEI_DMSG("Get E_MEMTEST\n");
+ if (rd_mbox[2] != 0x1) {
+ got_int = 4;
+ IFX_MEI_DMSG("Get Result %X\n", rd_mbox[2]);
+ }
+ }
+ }
+ IFX_MEI_LongWordWriteOffset (&dsl_devices[0], (u32) ME_ARC2ME_STAT,
+ ARC_TO_MEI_DBG_DONE);
+ MEI_MASK_AND_ACK_IRQ (pDev->nIrq[IFX_DFEIR]);
+ disable_irq (pDev->nIrq[IFX_DFEIR]);
+ //got_int = 1;
+ return;
+}
+
+static void
+wait_mem_test_result (void)
+{
+ uint32_t mbox[5];
+ mbox[0] = 0;
+
+ IFX_MEI_DMSG("Waiting Starting\n");
+ while (mbox[0] == 0) {
+ ReadMbox (&mbox[0], 5);
+ }
+ IFX_MEI_DMSG("Try to get mem test result.\n");
+ ReadMbox (&mbox[0], 5);
+ if (mbox[0] == 0xA) {
+ IFX_MEI_DMSG("Success.\n");
+ }
+ else if (mbox[0] == 0xA) {
+ IFX_MEI_EMSG("Fail,address %X,except data %X,receive data %X\n",
+ mbox[1], mbox[2], mbox[3]);
+ }
+ else {
+ IFX_MEI_EMSG("Fail\n");
+ }
+}
+
+static int
+arc_ping_testing (DSL_DEV_Device_t *pDev)
+{
+#define MEI_PING 0x00000001
+ uint32_t wr_mbox[10], rd_mbox[10];
+ int i;
+
+ for (i = 0; i < 10; i++) {
+ wr_mbox[i] = 0;
+ rd_mbox[i] = 0;
+ }
+
+ FX_MEI_DMSG("send ping msg\n");
+ wr_mbox[0] = MEI_PING;
+ WriteMbox (&wr_mbox[0], 10);
+
+ while (got_int == 0) {
+ MEI_WAIT (100);
+ }
+
+ IFX_MEI_DMSG("send start event\n");
+ got_int = 0;
+
+ wr_mbox[0] = 0x4;
+ wr_mbox[1] = 0;
+ wr_mbox[2] = 0;
+ wr_mbox[3] = (uint32_t) 0xf5acc307e;
+ wr_mbox[4] = 5;
+ wr_mbox[5] = 2;
+ wr_mbox[6] = 0x1c000;
+ wr_mbox[7] = 64;
+ wr_mbox[8] = 0;
+ wr_mbox[9] = 0;
+ WriteMbox (&wr_mbox[0], 10);
+ DSL_ENABLE_IRQ (pDev->nIrq[IFX_DFEIR]);
+ //printk("IFX_MEI_MailboxWrite ret=%d\n",i);
+ IFX_MEI_LongWordWriteOffset (&dsl_devices[0],
+ (u32) ME_ME2ARC_INT,
+ MEI_TO_ARC_MSGAV);
+ IFX_MEI_DMSG("sleeping\n");
+ while (1) {
+ if (got_int > 0) {
+
+ if (got_int > 3)
+ IFX_MEI_DMSG("got_int >>>> 3\n");
+ else
+ IFX_MEI_DMSG("got int = %d\n", got_int);
+ got_int = 0;
+ //schedule();
+ DSL_ENABLE_IRQ (pDev->nIrq[IFX_DFEIR]);
+ }
+ //mbox_read(&rd_mbox[0],6);
+ MEI_WAIT (100);
+ }
+ return 0;
+}
+
+static DSL_DEV_MeiError_t
+DFE_Loopback_Test (void)
+{
+ int i = 0;
+ u32 arc_debug_data = 0, temp;
+ DSL_DEV_Device_t *pDev = &dsl_devices[0];
+ uint32_t wr_mbox[10];
+
+ IFX_MEI_ResetARC (pDev);
+ // start the clock
+ arc_debug_data = ACL_CLK_MODE_ENABLE;
+ IFX_MEI_DebugWrite (pDev, CRI_CCR0, &arc_debug_data, 1);
+
+#if defined( DFE_PING_TEST )|| defined( DFE_ATM_LOOPBACK)
+ // WriteARCreg(AUX_XMEM_LTEST,0);
+ IFX_MEI_ControlModeSet (pDev, MEI_MASTER_MODE);
+#define AUX_XMEM_LTEST 0x128
+ _IFX_MEI_DBGLongWordWrite (pDev, MEI_DEBUG_DEC_AUX_MASK, AUX_XMEM_LTEST, 0);
+ IFX_MEI_ControlModeSet (pDev, JTAG_MASTER_MODE);
+
+ // WriteARCreg(AUX_XDMA_GAP,0);
+ IFX_MEI_ControlModeSet (pDev, MEI_MASTER_MODE);
+#define AUX_XDMA_GAP 0x114
+ _IFX_MEI_DBGLongWordWrite (pDev, MEI_DEBUG_DEC_AUX_MASK, AUX_XDMA_GAP, 0);
+ IFX_MEI_ControlModeSet (pDev, JTAG_MASTER_MODE);
+
+ IFX_MEI_ControlModeSet (pDev, MEI_MASTER_MODE);
+ temp = 0;
+ _IFX_MEI_DBGLongWordWrite (pDev, MEI_DEBUG_DEC_AUX_MASK,
+ (u32) ME_XDATA_BASE_SH + LTQ_MEI_BASE_ADDR, temp);
+ IFX_MEI_ControlModeSet (pDev, JTAG_MASTER_MODE);
+
+ i = IFX_MEI_DFEMemoryAlloc (pDev, SDRAM_SEGMENT_SIZE * 16);
+ if (i >= 0) {
+ int idx;
+
+ for (idx = 0; idx < i; idx++) {
+ DSL_DEV_PRIVATE(pDev)->adsl_mem_info[idx].type = FREE_RELOAD;
+ IFX_MEI_WRITE_REGISTER_L ((((uint32_t) DSL_DEV_PRIVATE(pDev)->adsl_mem_info[idx].address) & 0x0fffffff),
+ LTQ_MEI_BASE_ADDR + ME_XMEM_BAR_BASE + idx * 4);
+ IFX_MEI_DMSG("bar%d(%X)=%X\n", idx,
+ LTQ_MEI_BASE_ADDR + ME_XMEM_BAR_BASE +
+ idx * 4, (((uint32_t)
+ ((ifx_mei_device_private_t *)
+ pDev->pPriv)->adsl_mem_info[idx].
+ address) & 0x0fffffff));
+ memset ((u8 *) DSL_DEV_PRIVATE(pDev)->adsl_mem_info[idx].address, 0, SDRAM_SEGMENT_SIZE);
+ }
+
+ IFX_MEI_LongWordWriteOffset (pDev, (u32) ME_XDATA_BASE_SH,
+ ((unsigned long) DSL_DEV_PRIVATE(pDev)->adsl_mem_info[XDATA_REGISTER].address) & 0x0FFFFFFF);
+ }
+ else {
+ IFX_MEI_EMSG ("cannot load image: no memory\n");
+ return DSL_DEV_MEI_ERR_FAILURE;
+ }
+ //WriteARCreg(AUX_IC_CTRL,2);
+ IFX_MEI_DMSG("Setting MEI_MASTER_MODE..\n");
+ IFX_MEI_ControlModeSet (pDev, MEI_MASTER_MODE);
+#define AUX_IC_CTRL 0x11
+ _IFX_MEI_DBGLongWordWrite (pDev, MEI_DEBUG_DEC_AUX_MASK,
+ AUX_IC_CTRL, 2);
+ IFX_MEI_DMSG("Setting JTAG_MASTER_MODE..\n");
+ IFX_MEI_ControlModeSet (pDev, JTAG_MASTER_MODE);
+
+ IFX_MEI_DMSG("Halting ARC...\n");
+ IFX_MEI_HaltArc (&dsl_devices[0]);
+
+#ifdef DFE_PING_TEST
+
+ IFX_MEI_DMSG("ping test image size=%d\n", sizeof (arc_ahb_access_code));
+ memcpy ((u8 *) (DSL_DEV_PRIVATE(pDev)->
+ adsl_mem_info[0].address + 0x1004),
+ &arc_ahb_access_code[0], sizeof (arc_ahb_access_code));
+ load_jump_table (0x80000 + 0x1004);
+
+#endif //DFE_PING_TEST
+
+ IFX_MEI_DMSG("ARC ping test code download complete\n");
+#endif //defined( DFE_PING_TEST )|| defined( DFE_ATM_LOOPBACK)
+#ifdef DFE_MEM_TEST
+ IFX_MEI_LongWordWriteOffset (&dsl_devices[0], (u32) ME_ARC2ME_MASK, MSGAV_EN);
+
+ arc_code_page_download (1537, &code_array[0]);
+ IFX_MEI_DMSG("ARC mem test code download complete\n");
+#endif //DFE_MEM_TEST
+#ifdef DFE_ATM_LOOPBACK
+ arc_debug_data = 0xf;
+ arc_code_page_download (sizeof(code_array) / sizeof(*code_array), &code_array[0]);
+ wr_mbox[0] = 0; //TIMER_DELAY - org: 1024
+ wr_mbox[1] = 0; //TXFB_START0
+ wr_mbox[2] = 0x7f; //TXFB_END0 - org: 49
+ wr_mbox[3] = 0x80; //TXFB_START1 - org: 80
+ wr_mbox[4] = 0xff; //TXFB_END1 - org: 109
+ wr_mbox[5] = 0x100; //RXFB_START0 - org: 0
+ wr_mbox[6] = 0x17f; //RXFB_END0 - org: 49
+ wr_mbox[7] = 0x180; //RXFB_START1 - org: 256
+ wr_mbox[8] = 0x1ff; //RXFB_END1 - org: 315
+ WriteMbox (&wr_mbox[0], 9);
+ // Start Iridia IT_AMODE (in dmp access) why is it required?
+ IFX_MEI_DebugWrite (&dsl_devices[0], 0x32010, &arc_debug_data, 1);
+#endif //DFE_ATM_LOOPBACK
+ IFX_MEI_IRQEnable (pDev);
+ IFX_MEI_DMSG("run ARC...\n");
+ IFX_MEI_RunArc (&dsl_devices[0]);
+
+#ifdef DFE_PING_TEST
+ arc_ping_testing (pDev);
+#endif //DFE_PING_TEST
+#ifdef DFE_MEM_TEST
+ wait_mem_test_result ();
+#endif //DFE_MEM_TEST
+
+ IFX_MEI_DFEMemoryFree (pDev, FREE_ALL);
+ return DSL_DEV_MEI_ERR_SUCCESS;
+}
+
+#endif //CONFIG_AMAZON_S_MEI_FW_LOOPBACK
+
+static int
+IFX_MEI_InitDevNode (int num)
+{
+ if (num == 0) {
+ if ((dev_major = register_chrdev (dev_major, IFX_MEI_DEVNAME, &bsp_mei_operations)) < 0) {
+ IFX_MEI_EMSG ("register_chrdev(%d %s) failed!\n", dev_major, IFX_MEI_DEVNAME);
+ return -ENODEV;
+ }
+ }
+ return 0;
+}
+
+static int
+IFX_MEI_CleanUpDevNode (int num)
+{
+ if (num == 0)
+ unregister_chrdev (dev_major, MEI_DIRNAME);
+ return 0;
+}
+
+static int
+IFX_MEI_InitDevice (int num)
+{
+ DSL_DEV_Device_t *pDev;
+ u32 temp;
+ pDev = &dsl_devices[num];
+ if (pDev == NULL)
+ return -ENOMEM;
+ pDev->pPriv = &sDanube_Mei_Private[num];
+ memset (pDev->pPriv, 0, sizeof (ifx_mei_device_private_t));
+
+ memset (&DSL_DEV_PRIVATE(pDev)->
+ adsl_mem_info[0], 0,
+ sizeof (smmu_mem_info_t) * MAX_BAR_REGISTERS);
+
+ if (num == 0) {
+ pDev->nIrq[IFX_DFEIR] = LTQ_MEI_INT;
+ pDev->nIrq[IFX_DYING_GASP] = LTQ_MEI_DYING_GASP_INT;
+ pDev->base_address = KSEG1 + LTQ_MEI_BASE_ADDR;
+
+ /* Power up MEI */
+#ifdef CONFIG_LANTIQ_AMAZON_SE
+ *LTQ_PMU_PWDCR &= ~(1 << 9); // enable dsl
+ *LTQ_PMU_PWDCR &= ~(1 << 15); // enable AHB base
+#else
+ temp = ltq_r32(LTQ_PMU_PWDCR);
+ temp &= 0xffff7dbe;
+ ltq_w32(temp, LTQ_PMU_PWDCR);
+#endif
+ }
+ pDev->nInUse = 0;
+ DSL_DEV_PRIVATE(pDev)->modem_ready = 0;
+ DSL_DEV_PRIVATE(pDev)->arcmsgav = 0;
+
+ MEI_INIT_WAKELIST ("arcq", DSL_DEV_PRIVATE(pDev)->wait_queue_arcmsgav); // for ARCMSGAV
+ MEI_INIT_WAKELIST ("arcr", DSL_DEV_PRIVATE(pDev)->wait_queue_modemready); // for arc modem ready
+
+ MEI_MUTEX_INIT (DSL_DEV_PRIVATE(pDev)->mei_cmv_sema, 1); // semaphore initialization, mutex
+#if 0
+ MEI_MASK_AND_ACK_IRQ (pDev->nIrq[IFX_DFEIR]);
+ MEI_MASK_AND_ACK_IRQ (pDev->nIrq[IFX_DYING_GASP]);
+#endif
+ if (request_irq (pDev->nIrq[IFX_DFEIR], IFX_MEI_IrqHandle, 0, "DFEIR", pDev) != 0) {
+ IFX_MEI_EMSG ("request_irq %d failed!\n", pDev->nIrq[IFX_DFEIR]);
+ return -1;
+ }
+ /*if (request_irq (pDev->nIrq[IFX_DYING_GASP], IFX_MEI_Dying_Gasp_IrqHandle, 0, "DYING_GASP", pDev) != 0) {
+ IFX_MEI_EMSG ("request_irq %d failed!\n", pDev->nIrq[IFX_DYING_GASP]);
+ return -1;
+ }*/
+// IFX_MEI_DMSG("Device %d initialized. IER %#x\n", num, bsp_get_irq_ier(pDev->nIrq[IFX_DYING_GASP]));
+ return 0;
+}
+
+static int
+IFX_MEI_ExitDevice (int num)
+{
+ DSL_DEV_Device_t *pDev;
+ pDev = &dsl_devices[num];
+
+ if (pDev == NULL)
+ return -EIO;
+
+ disable_irq (pDev->nIrq[IFX_DFEIR]);
+ disable_irq (pDev->nIrq[IFX_DYING_GASP]);
+
+ free_irq(pDev->nIrq[IFX_DFEIR], pDev);
+ free_irq(pDev->nIrq[IFX_DYING_GASP], pDev);
+
+ return 0;
+}
+
+static DSL_DEV_Device_t *
+IFX_BSP_HandleGet (int maj, int num)
+{
+ if (num > BSP_MAX_DEVICES)
+ return NULL;
+ return &dsl_devices[num];
+}
+
+DSL_DEV_Device_t *
+DSL_BSP_DriverHandleGet (int maj, int num)
+{
+ DSL_DEV_Device_t *pDev;
+
+ if (num > BSP_MAX_DEVICES)
+ return NULL;
+
+ pDev = &dsl_devices[num];
+ if (!try_module_get(pDev->owner))
+ return NULL;
+
+ pDev->nInUse++;
+ return pDev;
+}
+
+int
+DSL_BSP_DriverHandleDelete (DSL_DEV_Device_t * nHandle)
+{
+ DSL_DEV_Device_t *pDev = (DSL_DEV_Device_t *) nHandle;
+ if (pDev->nInUse)
+ pDev->nInUse--;
+ module_put(pDev->owner);
+ return 0;
+}
+
+static int
+IFX_MEI_Open (DSL_DRV_inode_t * ino, DSL_DRV_file_t * fil)
+{
+ int maj = MAJOR (ino->i_rdev);
+ int num = MINOR (ino->i_rdev);
+
+ DSL_DEV_Device_t *pDev = NULL;
+ if ((pDev = DSL_BSP_DriverHandleGet (maj, num)) == NULL) {
+ IFX_MEI_EMSG("open(%d:%d) fail!\n", maj, num);
+ return -EIO;
+ }
+ fil->private_data = pDev;
+ return 0;
+}
+
+static int
+IFX_MEI_Release (DSL_DRV_inode_t * ino, DSL_DRV_file_t * fil)
+{
+ //int maj = MAJOR(ino->i_rdev);
+ int num = MINOR (ino->i_rdev);
+ DSL_DEV_Device_t *pDev;
+
+ pDev = &dsl_devices[num];
+ if (pDev == NULL)
+ return -EIO;
+ DSL_BSP_DriverHandleDelete (pDev);
+ return 0;
+}
+
+/**
+ * Callback function for linux userspace program writing
+ */
+static ssize_t
+IFX_MEI_Write (DSL_DRV_file_t * filp, const char *buf, size_t size, loff_t * loff)
+{
+ DSL_DEV_MeiError_t mei_error = DSL_DEV_MEI_ERR_FAILURE;
+ long offset = 0;
+ DSL_DEV_Device_t *pDev = (DSL_DEV_Device_t *) filp->private_data;
+
+ if (pDev == NULL)
+ return -EIO;
+
+ mei_error =
+ DSL_BSP_FWDownload (pDev, buf, size, (long *) loff, &offset);
+
+ if (mei_error == DSL_DEV_MEI_ERR_FAILURE)
+ return -EIO;
+ return (ssize_t) offset;
+}
+
+/**
+ * Callback function for linux userspace program ioctling
+ */
+static int
+IFX_MEI_IoctlCopyFrom (int from_kernel, char *dest, char *from, int size)
+{
+ int ret = 0;
+
+ if (!from_kernel)
+ ret = copy_from_user ((char *) dest, (char *) from, size);
+ else
+ ret = (int)memcpy ((char *) dest, (char *) from, size);
+ return ret;
+}
+
+static int
+IFX_MEI_IoctlCopyTo (int from_kernel, char *dest, char *from, int size)
+{
+ int ret = 0;
+
+ if (!from_kernel)
+ ret = copy_to_user ((char *) dest, (char *) from, size);
+ else
+ ret = (int)memcpy ((char *) dest, (char *) from, size);
+ return ret;
+}
+
+int
+IFX_MEI_Ioctls (DSL_DEV_Device_t * pDev, int from_kernel, unsigned int command, unsigned long lon)
+{
+ int i = 0;
+ int meierr = DSL_DEV_MEI_ERR_SUCCESS;
+ u32 base_address = LTQ_MEI_BASE_ADDR;
+ DSL_DEV_WinHost_Message_t winhost_msg, m;
+// DSL_DEV_MeiDebug_t debugrdwr;
+ DSL_DEV_MeiReg_t regrdwr;
+
+ switch (command) {
+
+ case DSL_FIO_BSP_CMV_WINHOST:
+ IFX_MEI_IoctlCopyFrom (from_kernel, (char *) winhost_msg.msg.TxMessage,
+ (char *) lon, MSG_LENGTH * 2);
+
+ if ((meierr = DSL_BSP_SendCMV (pDev, winhost_msg.msg.TxMessage, YES_REPLY,
+ winhost_msg.msg.RxMessage)) != DSL_DEV_MEI_ERR_SUCCESS) {
+ IFX_MEI_EMSG ("WINHOST CMV fail :TxMessage:%X %X %X %X, RxMessage:%X %X %X %X %X\n",
+ winhost_msg.msg.TxMessage[0], winhost_msg.msg.TxMessage[1], winhost_msg.msg.TxMessage[2], winhost_msg.msg.TxMessage[3],
+ winhost_msg.msg.RxMessage[0], winhost_msg.msg.RxMessage[1], winhost_msg.msg.RxMessage[2], winhost_msg.msg.RxMessage[3],
+ winhost_msg.msg.RxMessage[4]);
+ meierr = DSL_DEV_MEI_ERR_FAILURE;
+ }
+ else {
+ IFX_MEI_IoctlCopyTo (from_kernel, (char *) lon,
+ (char *) winhost_msg.msg.RxMessage,
+ MSG_LENGTH * 2);
+ }
+ break;
+
+ case DSL_FIO_BSP_CMV_READ:
+ IFX_MEI_IoctlCopyFrom (from_kernel, (char *) (&regrdwr),
+ (char *) lon, sizeof (DSL_DEV_MeiReg_t));
+
+ IFX_MEI_LongWordRead ((u32) regrdwr.iAddress,
+ (u32 *) & (regrdwr.iData));
+
+ IFX_MEI_IoctlCopyTo (from_kernel, (char *) lon,
+ (char *) (&regrdwr),
+ sizeof (DSL_DEV_MeiReg_t));
+
+ break;
+
+ case DSL_FIO_BSP_CMV_WRITE:
+ IFX_MEI_IoctlCopyFrom (from_kernel, (char *) (&regrdwr),
+ (char *) lon, sizeof (DSL_DEV_MeiReg_t));
+
+ IFX_MEI_LongWordWrite ((u32) regrdwr.iAddress,
+ regrdwr.iData);
+ break;
+
+ case DSL_FIO_BSP_GET_BASE_ADDRESS:
+ IFX_MEI_IoctlCopyTo (from_kernel, (char *) lon,
+ (char *) (&base_address),
+ sizeof (base_address));
+ break;
+
+ case DSL_FIO_BSP_IS_MODEM_READY:
+ i = IFX_MEI_IsModemReady (pDev);
+ IFX_MEI_IoctlCopyTo (from_kernel, (char *) lon,
+ (char *) (&i), sizeof (int));
+ meierr = DSL_DEV_MEI_ERR_SUCCESS;
+ break;
+ case DSL_FIO_BSP_RESET:
+ case DSL_FIO_BSP_REBOOT:
+ meierr = IFX_MEI_CpuModeSet (pDev, DSL_CPU_RESET);
+ meierr = IFX_MEI_CpuModeSet (pDev, DSL_CPU_HALT);
+ break;
+
+ case DSL_FIO_BSP_HALT:
+ meierr = IFX_MEI_CpuModeSet (pDev, DSL_CPU_HALT);
+ break;
+
+ case DSL_FIO_BSP_RUN:
+ meierr = IFX_MEI_CpuModeSet (pDev, DSL_CPU_RUN);
+ break;
+ case DSL_FIO_BSP_BOOTDOWNLOAD:
+ meierr = IFX_MEI_DownloadBootCode (pDev);
+ break;
+ case DSL_FIO_BSP_JTAG_ENABLE:
+ meierr = IFX_MEI_ArcJtagEnable (pDev, 1);
+ break;
+
+ case DSL_FIO_BSP_REMOTE:
+ IFX_MEI_IoctlCopyFrom (from_kernel, (char *) (&i),
+ (char *) lon, sizeof (int));
+
+ meierr = IFX_MEI_AdslMailboxIRQEnable (pDev, i);
+ break;
+
+ case DSL_FIO_BSP_DSL_START:
+ IFX_MEI_DMSG("DSL_FIO_BSP_DSL_START\n");
+ if ((meierr = IFX_MEI_RunAdslModem (pDev)) != DSL_DEV_MEI_ERR_SUCCESS) {
+ IFX_MEI_EMSG ("IFX_MEI_RunAdslModem() error...");
+ meierr = DSL_DEV_MEI_ERR_FAILURE;
+ }
+ break;
+
+/* case DSL_FIO_BSP_DEBUG_READ:
+ case DSL_FIO_BSP_DEBUG_WRITE:
+ IFX_MEI_IoctlCopyFrom (from_kernel,
+ (char *) (&debugrdwr),
+ (char *) lon,
+ sizeof (debugrdwr));
+
+ if (command == DSL_FIO_BSP_DEBUG_READ)
+ meierr = DSL_BSP_MemoryDebugAccess (pDev,
+ DSL_BSP_MEMORY_READ,
+ debugrdwr.
+ iAddress,
+ debugrdwr.
+ buffer,
+ debugrdwr.
+ iCount);
+ else
+ meierr = DSL_BSP_MemoryDebugAccess (pDev,
+ DSL_BSP_MEMORY_WRITE,
+ debugrdwr.
+ iAddress,
+ debugrdwr.
+ buffer,
+ debugrdwr.
+ iCount);
+
+ IFX_MEI_IoctlCopyTo (from_kernel, (char *) lon, (char *) (&debugrdwr), sizeof (debugrdwr));
+ break;*/
+ case DSL_FIO_BSP_GET_VERSION:
+ IFX_MEI_IoctlCopyTo (from_kernel, (char *) lon, (char *) (&bsp_mei_version), sizeof (DSL_DEV_Version_t));
+ break;
+
+#define LTQ_MPS_CHIPID_VERSION_GET(value) (((value) >> 28) & ((1 << 4) - 1))
+ case DSL_FIO_BSP_GET_CHIP_INFO:
+ bsp_chip_info.major = 1;
+ bsp_chip_info.minor = LTQ_MPS_CHIPID_VERSION_GET(*LTQ_MPS_CHIPID);
+ IFX_MEI_IoctlCopyTo (from_kernel, (char *) lon, (char *) (&bsp_chip_info), sizeof (DSL_DEV_HwVersion_t));
+ meierr = DSL_DEV_MEI_ERR_SUCCESS;
+ break;
+
+ case DSL_FIO_BSP_FREE_RESOURCE:
+ makeCMV (H2D_CMV_READ, DSL_CMV_GROUP_STAT, 4, 0, 1, NULL, m.msg.TxMessage);
+ if (DSL_BSP_SendCMV (pDev, m.msg.TxMessage, YES_REPLY, m.msg.RxMessage) != DSL_DEV_MEI_ERR_SUCCESS) {
+ meierr = DSL_DEV_MEI_ERR_FAILURE;
+ return -EIO;
+ }
+ IFX_MEI_DMSG("RxMessage[4] = %#x\n", m.msg.RxMessage[4]);
+ if (!(m.msg.RxMessage[4] & DSL_DEV_STAT_CODESWAP_COMPLETE)) {
+ meierr = DSL_DEV_MEI_ERR_FAILURE;
+ return -EAGAIN;
+ }
+ IFX_MEI_DMSG("Freeing all memories marked FREE_SHOWTIME\n");
+ IFX_MEI_DFEMemoryFree (pDev, FREE_SHOWTIME);
+ meierr = DSL_DEV_MEI_ERR_SUCCESS;
+ break;
+#ifdef CONFIG_IFXMIPS_AMAZON_SE
+ case DSL_FIO_ARC_MUX_TEST:
+ AMAZON_SE_MEI_ARC_MUX_Test();
+ break;
+#endif
+ default:
+// IFX_MEI_EMSG("Invalid IOCTL command: %d\n");
+ break;
+ }
+ return meierr;
+}
+
+#ifdef CONFIG_IFXMIPS_AMAZON_SE
+void AMAZON_SE_MEI_ARC_MUX_Test(void)
+{
+ u32 *p, i;
+ *LTQ_RCU_RST |= LTQ_RCU_RST_REQ_MUX_ARC;
+
+ p = (u32*)(DFE_LDST_BASE_ADDR + IRAM0_BASE);
+ IFX_MEI_EMSG("Writing to IRAM0(%p)...\n", p);
+ for (i = 0; i < IRAM0_SIZE/sizeof(u32); i++, p++) {
+ *p = 0xdeadbeef;
+ if (*p != 0xdeadbeef)
+ IFX_MEI_EMSG("%p: %#x\n", p, *p);
+ }
+
+ p = (u32*)(DFE_LDST_BASE_ADDR + IRAM1_BASE);
+ IFX_MEI_EMSG("Writing to IRAM1(%p)...\n", p);
+ for (i = 0; i < IRAM1_SIZE/sizeof(u32); i++, p++) {
+ *p = 0xdeadbeef;
+ if (*p != 0xdeadbeef)
+ IFX_MEI_EMSG("%p: %#x\n", p, *p);
+ }
+
+ p = (u32*)(DFE_LDST_BASE_ADDR + BRAM_BASE);
+ IFX_MEI_EMSG("Writing to BRAM(%p)...\n", p);
+ for (i = 0; i < BRAM_SIZE/sizeof(u32); i++, p++) {
+ *p = 0xdeadbeef;
+ if (*p != 0xdeadbeef)
+ IFX_MEI_EMSG("%p: %#x\n", p, *p);
+ }
+
+ p = (u32*)(DFE_LDST_BASE_ADDR + XRAM_BASE);
+ IFX_MEI_EMSG("Writing to XRAM(%p)...\n", p);
+ for (i = 0; i < XRAM_SIZE/sizeof(u32); i++, p++) {
+ *p = 0xdeadbeef;
+ if (*p != 0xdeadbeef)
+ IFX_MEI_EMSG("%p: %#x\n", p, *p);
+ }
+
+ p = (u32*)(DFE_LDST_BASE_ADDR + YRAM_BASE);
+ IFX_MEI_EMSG("Writing to YRAM(%p)...\n", p);
+ for (i = 0; i < YRAM_SIZE/sizeof(u32); i++, p++) {
+ *p = 0xdeadbeef;
+ if (*p != 0xdeadbeef)
+ IFX_MEI_EMSG("%p: %#x\n", p, *p);
+ }
+
+ p = (u32*)(DFE_LDST_BASE_ADDR + EXT_MEM_BASE);
+ IFX_MEI_EMSG("Writing to EXT_MEM(%p)...\n", p);
+ for (i = 0; i < EXT_MEM_SIZE/sizeof(u32); i++, p++) {
+ *p = 0xdeadbeef;
+ if (*p != 0xdeadbeef)
+ IFX_MEI_EMSG("%p: %#x\n", p, *p);
+ }
+ *LTQ_RCU_RST &= ~LTQ_RCU_RST_REQ_MUX_ARC;
+}
+#endif
+int
+DSL_BSP_KernelIoctls (DSL_DEV_Device_t * pDev, unsigned int command,
+ unsigned long lon)
+{
+ int error = 0;
+
+ error = IFX_MEI_Ioctls (pDev, 1, command, lon);
+ return error;
+}
+
+static long
+IFX_MEI_UserIoctls (DSL_DRV_file_t * fil,
+ unsigned int command, unsigned long lon)
+{
+ int error = 0;
+ DSL_DEV_Device_t *pDev;
+
+ pDev = IFX_BSP_HandleGet (0, 0);
+ if (pDev == NULL)
+ return -EIO;
+
+ error = IFX_MEI_Ioctls (pDev, 0, command, lon);
+ return error;
+}
+
+static int adsl_dummy_ledcallback(void)
+{
+ return 0;
+}
+
+int ifx_mei_atm_led_blink(void)
+{
+ return g_adsl_ledcallback();
+}
+EXPORT_SYMBOL(ifx_mei_atm_led_blink);
+
+int ifx_mei_atm_showtime_check(int *is_showtime, struct port_cell_info *port_cell, void **xdata_addr)
+{
+ int i;
+
+ if ( is_showtime ) {
+ *is_showtime = g_tx_link_rate[0] == 0 && g_tx_link_rate[1] == 0 ? 0 : 1;
+ }
+
+ if ( port_cell ) {
+ for ( i = 0; i < port_cell->port_num && i < 2; i++ )
+ port_cell->tx_link_rate[i] = g_tx_link_rate[i];
+ }
+
+ if ( xdata_addr ) {
+ if ( g_tx_link_rate[0] == 0 && g_tx_link_rate[1] == 0 )
+ *xdata_addr = NULL;
+ else
+ *xdata_addr = g_xdata_addr;
+ }
+
+ return 0;
+}
+EXPORT_SYMBOL(ifx_mei_atm_showtime_check);
+
+/*
+ * Writing function for linux proc filesystem
+ */
+static int ltq_mei_probe(struct platform_device *pdev)
+{
+ int i = 0;
+ static struct class *dsl_class;
+
+ pr_info("IFX MEI Version %ld.%02ld.%02ld\n", bsp_mei_version.major, bsp_mei_version.minor, bsp_mei_version.revision);
+
+ for (i = 0; i < BSP_MAX_DEVICES; i++) {
+ if (IFX_MEI_InitDevice (i) != 0) {
+ IFX_MEI_EMSG("Init device fail!\n");
+ return -EIO;
+ }
+ IFX_MEI_InitDevNode (i);
+ }
+ for (i = 0; i <= DSL_BSP_CB_LAST ; i++)
+ dsl_bsp_event_callback[i].function = NULL;
+
+#ifdef CONFIG_LTQ_MEI_FW_LOOPBACK
+ IFX_MEI_DMSG("Start loopback test...\n");
+ DFE_Loopback_Test ();
+#endif
+ dsl_class = class_create(THIS_MODULE, "ifx_mei");
+ device_create(dsl_class, NULL, MKDEV(MEI_MAJOR, 0), NULL, "ifx_mei");
+ return 0;
+}
+
+static int ltq_mei_remove(struct platform_device *pdev)
+{
+ int i = 0;
+ int num;
+
+ for (num = 0; num < BSP_MAX_DEVICES; num++) {
+ IFX_MEI_CleanUpDevNode (num);
+ }
+
+ for (i = 0; i < BSP_MAX_DEVICES; i++) {
+ for (i = 0; i < BSP_MAX_DEVICES; i++) {
+ IFX_MEI_ExitDevice (i);
+ }
+ }
+ return 0;
+}
+
+static const struct of_device_id ltq_mei_match[] = {
+ { .compatible = "lantiq,mei-xway"},
+ {},
+};
+
+static struct platform_driver ltq_mei_driver = {
+ .probe = ltq_mei_probe,
+ .remove = ltq_mei_remove,
+ .driver = {
+ .name = "lantiq,mei-xway",
+ .owner = THIS_MODULE,
+ .of_match_table = ltq_mei_match,
+ },
+};
+
+module_platform_driver(ltq_mei_driver);
+
+/* export function for DSL Driver */
+
+/* The functions of MEI_DriverHandleGet and MEI_DriverHandleDelete are
+something like open/close in kernel space , where the open could be used
+to register a callback for autonomous messages and returns a mei driver context pointer (comparable to the file descriptor in user space)
+ The context will be required for the multi line chips future! */
+
+EXPORT_SYMBOL (DSL_BSP_DriverHandleGet);
+EXPORT_SYMBOL (DSL_BSP_DriverHandleDelete);
+
+EXPORT_SYMBOL (DSL_BSP_ATMLedCBRegister);
+EXPORT_SYMBOL (DSL_BSP_ATMLedCBUnregister);
+EXPORT_SYMBOL (DSL_BSP_KernelIoctls);
+EXPORT_SYMBOL (DSL_BSP_AdslLedInit);
+//EXPORT_SYMBOL (DSL_BSP_AdslLedSet);
+EXPORT_SYMBOL (DSL_BSP_FWDownload);
+EXPORT_SYMBOL (DSL_BSP_Showtime);
+
+EXPORT_SYMBOL (DSL_BSP_MemoryDebugAccess);
+EXPORT_SYMBOL (DSL_BSP_SendCMV);
+
+// provide a register/unregister function for DSL driver to register a event callback function
+EXPORT_SYMBOL (DSL_BSP_EventCBRegister);
+EXPORT_SYMBOL (DSL_BSP_EventCBUnregister);
+
+MODULE_LICENSE("Dual BSD/GPL");
diff --git a/package/platform/lantiq/ltq-adsl-mei/src/Makefile b/package/platform/lantiq/ltq-adsl-mei/src/Makefile
new file mode 100644
index 0000000..2d8645f
--- /dev/null
+++ b/package/platform/lantiq/ltq-adsl-mei/src/Makefile
@@ -0,0 +1,17 @@
+ifeq ($(BUILD_VARIANT),danube)
+ CFLAGS_MODULE = -DCONFIG_DANUBE -DCONFIG_IFXMIPS_DSL_CPE_MEI
+ obj-m = ltq_mei_danube.o
+ ltq_mei_danube-objs = lantiq_mei.o
+endif
+
+ifeq ($(BUILD_VARIANT),ase)
+ CFLAGS_MODULE = -DCONFIG_AMAZON_SE -DCONFIG_IFXMIPS_DSL_CPE_MEI
+ obj-m = ltq_mei_ase.o
+ ltq_mei_ase-objs = lantiq_mei.o
+endif
+
+ifeq ($(BUILD_VARIANT),ar9)
+ CFLAGS_MODULE = -DCONFIG_AR9 -DCONFIG_IFXMIPS_DSL_CPE_MEI
+ obj-m = ltq_mei_ar9.o
+ ltq_mei_ar9-objs = lantiq_mei.o
+endif
diff --git a/package/platform/lantiq/ltq-adsl-mei/src/ifxmips_mei_interface.h b/package/platform/lantiq/ltq-adsl-mei/src/ifxmips_mei_interface.h
new file mode 100644
index 0000000..4ddc4c6
--- /dev/null
+++ b/package/platform/lantiq/ltq-adsl-mei/src/ifxmips_mei_interface.h
@@ -0,0 +1,702 @@
+/******************************************************************************
+
+ Copyright (c) 2009
+ Infineon Technologies AG
+ Am Campeon 1-12; 81726 Munich, Germany
+
+ For licensing information, see the file 'LICENSE' in the root folder of
+ this software module.
+
+******************************************************************************/
+
+#ifndef IFXMIPS_MEI_H
+#define IFXMIPS_MEI_H
+
+//#define CONFIG_AMAZON_SE 1
+//#define CONFIG_DANUBE 1
+//#define CONFIG_AR9 1
+
+#if !defined(CONFIG_DANUBE) && !defined(CONFIG_AMAZON_SE) && !defined(CONFIG_AR9) && !defined(CONFIG_VR9)
+#error Platform undefined!!!
+#endif
+
+#ifdef IFX_MEI_BSP
+/** This is the character datatype. */
+typedef char DSL_char_t;
+/** This is the unsigned 8-bit datatype. */
+typedef unsigned char DSL_uint8_t;
+/** This is the signed 8-bit datatype. */
+typedef signed char DSL_int8_t;
+/** This is the unsigned 16-bit datatype. */
+typedef unsigned short DSL_uint16_t;
+/** This is the signed 16-bit datatype. */
+typedef signed short DSL_int16_t;
+/** This is the unsigned 32-bit datatype. */
+typedef unsigned long DSL_uint32_t;
+/** This is the signed 32-bit datatype. */
+typedef signed long DSL_int32_t;
+/** This is the float datatype. */
+typedef float DSL_float_t;
+/** This is the void datatype. */
+typedef void DSL_void_t;
+/** integer type, width is depending on processor arch */
+typedef int DSL_int_t;
+/** unsigned integer type, width is depending on processor arch */
+typedef unsigned int DSL_uint_t;
+typedef struct file DSL_DRV_file_t;
+typedef struct inode DSL_DRV_inode_t;
+
+/**
+ * Defines all possible CMV groups
+ * */
+typedef enum {
+ DSL_CMV_GROUP_CNTL = 1,
+ DSL_CMV_GROUP_STAT = 2,
+ DSL_CMV_GROUP_INFO = 3,
+ DSL_CMV_GROUP_TEST = 4,
+ DSL_CMV_GROUP_OPTN = 5,
+ DSL_CMV_GROUP_RATE = 6,
+ DSL_CMV_GROUP_PLAM = 7,
+ DSL_CMV_GROUP_CNFG = 8
+} DSL_CmvGroup_t;
+/**
+ * Defines all opcode types
+ * */
+typedef enum {
+ H2D_CMV_READ = 0x00,
+ H2D_CMV_WRITE = 0x04,
+ H2D_CMV_INDICATE_REPLY = 0x10,
+ H2D_ERROR_OPCODE_UNKNOWN =0x20,
+ H2D_ERROR_CMV_UNKNOWN =0x30,
+
+ D2H_CMV_READ_REPLY =0x01,
+ D2H_CMV_WRITE_REPLY = 0x05,
+ D2H_CMV_INDICATE = 0x11,
+ D2H_ERROR_OPCODE_UNKNOWN = 0x21,
+ D2H_ERROR_CMV_UNKNOWN = 0x31,
+ D2H_ERROR_CMV_READ_NOT_AVAILABLE = 0x41,
+ D2H_ERROR_CMV_WRITE_ONLY = 0x51,
+ D2H_ERROR_CMV_READ_ONLY = 0x61,
+
+ H2D_DEBUG_READ_DM = 0x02,
+ H2D_DEBUG_READ_PM = 0x06,
+ H2D_DEBUG_WRITE_DM = 0x0a,
+ H2D_DEBUG_WRITE_PM = 0x0e,
+
+ D2H_DEBUG_READ_DM_REPLY = 0x03,
+ D2H_DEBUG_READ_FM_REPLY = 0x07,
+ D2H_DEBUG_WRITE_DM_REPLY = 0x0b,
+ D2H_DEBUG_WRITE_FM_REPLY = 0x0f,
+ D2H_ERROR_ADDR_UNKNOWN = 0x33,
+
+ D2H_AUTONOMOUS_MODEM_READY_MSG = 0xf1
+} DSL_CmvOpcode_t;
+
+/* mutex macros */
+#define MEI_MUTEX_INIT(id,flag) \
+ sema_init(&id,flag)
+#define MEI_MUTEX_LOCK(id) \
+ down_interruptible(&id)
+#define MEI_MUTEX_UNLOCK(id) \
+ up(&id)
+#define MEI_WAIT(ms) \
+ {\
+ set_current_state(TASK_INTERRUPTIBLE);\
+ schedule_timeout(ms);\
+ }
+#define MEI_INIT_WAKELIST(name,queue) \
+ init_waitqueue_head(&queue)
+
+/* wait for an event, timeout is measured in ms */
+#define MEI_WAIT_EVENT_TIMEOUT(ev,timeout)\
+ interruptible_sleep_on_timeout(&ev,timeout * HZ / 1000)
+#define MEI_WAKEUP_EVENT(ev)\
+ wake_up_interruptible(&ev)
+#endif /* IFX_MEI_BSP */
+
+/*** Register address offsets, relative to MEI_SPACE_ADDRESS ***/
+#define ME_DX_DATA (0x0000)
+#define ME_VERSION (0x0004)
+#define ME_ARC_GP_STAT (0x0008)
+#define ME_DX_STAT (0x000C)
+#define ME_DX_AD (0x0010)
+#define ME_DX_MWS (0x0014)
+#define ME_ME2ARC_INT (0x0018)
+#define ME_ARC2ME_STAT (0x001C)
+#define ME_ARC2ME_MASK (0x0020)
+#define ME_DBG_WR_AD (0x0024)
+#define ME_DBG_RD_AD (0x0028)
+#define ME_DBG_DATA (0x002C)
+#define ME_DBG_DECODE (0x0030)
+#define ME_CONFIG (0x0034)
+#define ME_RST_CTRL (0x0038)
+#define ME_DBG_MASTER (0x003C)
+#define ME_CLK_CTRL (0x0040)
+#define ME_BIST_CTRL (0x0044)
+#define ME_BIST_STAT (0x0048)
+#define ME_XDATA_BASE_SH (0x004c)
+#define ME_XDATA_BASE (0x0050)
+#define ME_XMEM_BAR_BASE (0x0054)
+#define ME_XMEM_BAR0 (0x0054)
+#define ME_XMEM_BAR1 (0x0058)
+#define ME_XMEM_BAR2 (0x005C)
+#define ME_XMEM_BAR3 (0x0060)
+#define ME_XMEM_BAR4 (0x0064)
+#define ME_XMEM_BAR5 (0x0068)
+#define ME_XMEM_BAR6 (0x006C)
+#define ME_XMEM_BAR7 (0x0070)
+#define ME_XMEM_BAR8 (0x0074)
+#define ME_XMEM_BAR9 (0x0078)
+#define ME_XMEM_BAR10 (0x007C)
+#define ME_XMEM_BAR11 (0x0080)
+#define ME_XMEM_BAR12 (0x0084)
+#define ME_XMEM_BAR13 (0x0088)
+#define ME_XMEM_BAR14 (0x008C)
+#define ME_XMEM_BAR15 (0x0090)
+#define ME_XMEM_BAR16 (0x0094)
+
+#define WHILE_DELAY 20000
+/*
+** Define where in ME Processor's memory map the Stratify chip lives
+*/
+
+#define MAXSWAPSIZE (8 * 1024) //8k *(32bits)
+
+// Mailboxes
+#define MSG_LENGTH 16 // x16 bits
+#define YES_REPLY 1
+#define NO_REPLY 0
+
+#define CMV_TIMEOUT 1000 //jiffies
+
+// Block size per BAR
+#define SDRAM_SEGMENT_SIZE (64*1024)
+// Number of Bar registers
+#define MAX_BAR_REGISTERS (17)
+
+#define XDATA_REGISTER (15)
+
+// ARC register addresss
+#define ARC_STATUS 0x0
+#define ARC_LP_START 0x2
+#define ARC_LP_END 0x3
+#define ARC_DEBUG 0x5
+#define ARC_INT_MASK 0x10A
+
+#define IRAM0_BASE (0x00000)
+#define IRAM1_BASE (0x04000)
+#if defined(CONFIG_DANUBE)
+#define BRAM_BASE (0x0A000)
+#elif defined(CONFIG_AMAZON_SE) || defined(CONFIG_AR9) || defined(CONFIG_VR9)
+#define BRAM_BASE (0x08000)
+#endif
+#define XRAM_BASE (0x18000)
+#define YRAM_BASE (0x1A000)
+#define EXT_MEM_BASE (0x80000)
+#define ARC_GPIO_CTRL (0xC030)
+#define ARC_GPIO_DATA (0xC034)
+
+#define IRAM0_SIZE (16*1024)
+#define IRAM1_SIZE (16*1024)
+#define BRAM_SIZE (12*1024)
+#define XRAM_SIZE (8*1024)
+#define YRAM_SIZE (8*1024)
+#define EXT_MEM_SIZE (1536*1024)
+
+#define ADSL_BASE (0x20000)
+#define CRI_BASE (ADSL_BASE + 0x11F00)
+#define CRI_CCR0 (CRI_BASE + 0x00)
+#define CRI_RST (CRI_BASE + 0x04*4)
+#define ADSL_DILV_BASE (ADSL_BASE+0x20000)
+
+//
+#define IRAM0_ADDR_BIT_MASK 0xFFF
+#define IRAM1_ADDR_BIT_MASK 0xFFF
+#define BRAM_ADDR_BIT_MASK 0xFFF
+#define RX_DILV_ADDR_BIT_MASK 0x1FFF
+
+/*** Bit definitions ***/
+#define ARC_AUX_HALT (1 << 25)
+#define ARC_DEBUG_HALT (1 << 1)
+#define FALSE 0
+#define TRUE 1
+#define BIT0 (1<<0)
+#define BIT1 (1<<1)
+#define BIT2 (1<<2)
+#define BIT3 (1<<3)
+#define BIT4 (1<<4)
+#define BIT5 (1<<5)
+#define BIT6 (1<<6)
+#define BIT7 (1<<7)
+#define BIT8 (1<<8)
+#define BIT9 (1<<9)
+#define BIT10 (1<<10)
+#define BIT11 (1<<11)
+#define BIT12 (1<<12)
+#define BIT13 (1<<13)
+#define BIT14 (1<<14)
+#define BIT15 (1<<15)
+#define BIT16 (1<<16)
+#define BIT17 (1<<17)
+#define BIT18 (1<<18)
+#define BIT19 (1<<19)
+#define BIT20 (1<<20)
+#define BIT21 (1<<21)
+#define BIT22 (1<<22)
+#define BIT23 (1<<23)
+#define BIT24 (1<<24)
+#define BIT25 (1<<25)
+#define BIT26 (1<<26)
+#define BIT27 (1<<27)
+#define BIT28 (1<<28)
+#define BIT29 (1<<29)
+#define BIT30 (1<<30)
+#define BIT31 (1<<31)
+
+// CRI_CCR0 Register definitions
+#define CLK_2M_MODE_ENABLE BIT6
+#define ACL_CLK_MODE_ENABLE BIT4
+#define FDF_CLK_MODE_ENABLE BIT2
+#define STM_CLK_MODE_ENABLE BIT0
+
+// CRI_RST Register definitions
+#define FDF_SRST BIT3
+#define MTE_SRST BIT2
+#define FCI_SRST BIT1
+#define AAI_SRST BIT0
+
+// MEI_TO_ARC_INTERRUPT Register definitions
+#define MEI_TO_ARC_INT1 BIT3
+#define MEI_TO_ARC_INT0 BIT2
+#define MEI_TO_ARC_CS_DONE BIT1 //need to check
+#define MEI_TO_ARC_MSGAV BIT0
+
+// ARC_TO_MEI_INTERRUPT Register definitions
+#define ARC_TO_MEI_INT1 BIT8
+#define ARC_TO_MEI_INT0 BIT7
+#define ARC_TO_MEI_CS_REQ BIT6
+#define ARC_TO_MEI_DBG_DONE BIT5
+#define ARC_TO_MEI_MSGACK BIT4
+#define ARC_TO_MEI_NO_ACCESS BIT3
+#define ARC_TO_MEI_CHECK_AAITX BIT2
+#define ARC_TO_MEI_CHECK_AAIRX BIT1
+#define ARC_TO_MEI_MSGAV BIT0
+
+// ARC_TO_MEI_INTERRUPT_MASK Register definitions
+#define GP_INT1_EN BIT8
+#define GP_INT0_EN BIT7
+#define CS_REQ_EN BIT6
+#define DBG_DONE_EN BIT5
+#define MSGACK_EN BIT4
+#define NO_ACC_EN BIT3
+#define AAITX_EN BIT2
+#define AAIRX_EN BIT1
+#define MSGAV_EN BIT0
+
+#define MEI_SOFT_RESET BIT0
+
+#define HOST_MSTR BIT0
+
+#define JTAG_MASTER_MODE 0x0
+#define MEI_MASTER_MODE HOST_MSTR
+
+// MEI_DEBUG_DECODE Register definitions
+#define MEI_DEBUG_DEC_MASK (0x3)
+#define MEI_DEBUG_DEC_AUX_MASK (0x0)
+#define ME_DBG_DECODE_DMP1_MASK (0x1)
+#define MEI_DEBUG_DEC_DMP2_MASK (0x2)
+#define MEI_DEBUG_DEC_CORE_MASK (0x3)
+
+#define AUX_STATUS (0x0)
+#define AUX_ARC_GPIO_CTRL (0x10C)
+#define AUX_ARC_GPIO_DATA (0x10D)
+// ARC_TO_MEI_MAILBOX[11] is a special location used to indicate
+// page swap requests.
+#if defined(CONFIG_DANUBE)
+#define OMBOX_BASE 0xDF80
+#define ARC_TO_MEI_MAILBOX 0xDFA0
+#define IMBOX_BASE 0xDFC0
+#define MEI_TO_ARC_MAILBOX 0xDFD0
+#elif defined(CONFIG_AMAZON_SE) || defined(CONFIG_AR9) || defined(CONFIG_VR9)
+#define OMBOX_BASE 0xAF80
+#define ARC_TO_MEI_MAILBOX 0xAFA0
+#define IMBOX_BASE 0xAFC0
+#define MEI_TO_ARC_MAILBOX 0xAFD0
+#endif
+
+#define MEI_TO_ARC_MAILBOXR (MEI_TO_ARC_MAILBOX + 0x2C)
+#define ARC_MEI_MAILBOXR (ARC_TO_MEI_MAILBOX + 0x2C)
+#define OMBOX1 (OMBOX_BASE+0x4)
+
+// Codeswap request messages are indicated by setting BIT31
+#define OMB_CODESWAP_MESSAGE_MSG_TYPE_MASK (0x80000000)
+
+// Clear Eoc messages received are indicated by setting BIT17
+#define OMB_CLEAREOC_INTERRUPT_CODE (0x00020000)
+#define OMB_REBOOT_INTERRUPT_CODE (1 << 18)
+
+/*
+** Swap page header
+*/
+// Page must be loaded at boot time if size field has BIT31 set
+#define BOOT_FLAG (BIT31)
+#define BOOT_FLAG_MASK ~BOOT_FLAG
+
+#define FREE_RELOAD 1
+#define FREE_SHOWTIME 2
+#define FREE_ALL 3
+
+// marcos
+#define IFX_MEI_WRITE_REGISTER_L(data,addr) *((volatile u32*)(addr)) = (u32)(data)
+#define IFX_MEI_READ_REGISTER_L(addr) (*((volatile u32*)(addr)))
+#define SET_BIT(reg, mask) reg |= (mask)
+#define CLEAR_BIT(reg, mask) reg &= (~mask)
+#define CLEAR_BITS(reg, mask) CLEAR_BIT(reg, mask)
+//#define SET_BITS(reg, mask) SET_BIT(reg, mask)
+#define SET_BITFIELD(reg, mask, off, val) {reg &= (~mask); reg |= (val << off);}
+
+#define ALIGN_SIZE ( 1L<<10 ) //1K size align
+#define MEM_ALIGN(addr) (((addr) + ALIGN_SIZE - 1) & ~ (ALIGN_SIZE -1) )
+
+// swap marco
+#define MEI_HALF_WORD_SWAP(data) {data = ((data & 0xffff)<<16) + ((data & 0xffff0000)>>16);}
+#define MEI_BYTE_SWAP(data) {data = ((data & 0xff)<<24) + ((data & 0xff00)<<8)+ ((data & 0xff0000)>>8)+ ((data & 0xff000000)>>24);}
+
+
+#ifdef CONFIG_PROC_FS
+typedef struct reg_entry
+{
+ int *flag;
+ char name[30]; /* big enough to hold names */
+ char description[100]; /* big enough to hold description */
+ unsigned short low_ino;
+} reg_entry_t;
+#endif
+// Swap page header describes size in 32-bit words, load location, and image offset
+// for program and/or data segments
+typedef struct _arc_swp_page_hdr {
+ u32 p_offset; //Offset bytes of progseg from beginning of image
+ u32 p_dest; //Destination addr of progseg on processor
+ u32 p_size; //Size in 32-bitwords of program segment
+ u32 d_offset; //Offset bytes of dataseg from beginning of image
+ u32 d_dest; //Destination addr of dataseg on processor
+ u32 d_size; //Size in 32-bitwords of data segment
+} ARC_SWP_PAGE_HDR;
+
+/*
+** Swap image header
+*/
+#define GET_PROG 0 // Flag used for program mem segment
+#define GET_DATA 1 // Flag used for data mem segment
+
+// Image header contains size of image, checksum for image, and count of
+// page headers. Following that are 'count' page headers followed by
+// the code and/or data segments to be loaded
+typedef struct _arc_img_hdr {
+ u32 size; // Size of binary image in bytes
+ u32 checksum; // Checksum for image
+ u32 count; // Count of swp pages in image
+ ARC_SWP_PAGE_HDR page[1]; // Should be "count" pages - '1' to make compiler happy
+} ARC_IMG_HDR;
+
+typedef struct smmu_mem_info {
+ int type;
+ int boot;
+ unsigned long nCopy;
+ unsigned long size;
+ unsigned char *address;
+ unsigned char *org_address;
+} smmu_mem_info_t;
+
+#ifdef __KERNEL__
+typedef struct ifx_mei_device_private {
+ int modem_ready;
+ int arcmsgav;
+ int cmv_reply;
+ int cmv_waiting;
+ // Mei to ARC CMV count, reply count, ARC Indicator count
+ int modem_ready_cnt;
+ int cmv_count;
+ int reply_count;
+ unsigned long image_size;
+ int nBar;
+ u16 Recent_indicator[MSG_LENGTH];
+
+ u16 CMV_RxMsg[MSG_LENGTH] __attribute__ ((aligned (4)));
+
+ smmu_mem_info_t adsl_mem_info[MAX_BAR_REGISTERS];
+ ARC_IMG_HDR *img_hdr;
+ // to wait for arc cmv reply, sleep on wait_queue_arcmsgav;
+ wait_queue_head_t wait_queue_arcmsgav;
+ wait_queue_head_t wait_queue_modemready;
+ struct semaphore mei_cmv_sema;
+} ifx_mei_device_private_t;
+#endif
+typedef struct winhost_message {
+ union {
+ u16 RxMessage[MSG_LENGTH] __attribute__ ((aligned (4)));
+ u16 TxMessage[MSG_LENGTH] __attribute__ ((aligned (4)));
+ } msg;
+} DSL_DEV_WinHost_Message_t;
+/********************************************************************************************************
+ * DSL CPE API Driver Stack Interface Definitions
+ * *****************************************************************************************************/
+/** IOCTL codes for bsp driver */
+#define DSL_IOC_MEI_BSP_MAGIC 's'
+
+#define DSL_FIO_BSP_DSL_START _IO (DSL_IOC_MEI_BSP_MAGIC, 0)
+#define DSL_FIO_BSP_RUN _IO (DSL_IOC_MEI_BSP_MAGIC, 1)
+#define DSL_FIO_BSP_FREE_RESOURCE _IO (DSL_IOC_MEI_BSP_MAGIC, 2)
+#define DSL_FIO_BSP_RESET _IO (DSL_IOC_MEI_BSP_MAGIC, 3)
+#define DSL_FIO_BSP_REBOOT _IO (DSL_IOC_MEI_BSP_MAGIC, 4)
+#define DSL_FIO_BSP_HALT _IO (DSL_IOC_MEI_BSP_MAGIC, 5)
+#define DSL_FIO_BSP_BOOTDOWNLOAD _IO (DSL_IOC_MEI_BSP_MAGIC, 6)
+#define DSL_FIO_BSP_JTAG_ENABLE _IO (DSL_IOC_MEI_BSP_MAGIC, 7)
+#define DSL_FIO_FREE_RESOURCE _IO (DSL_IOC_MEI_BSP_MAGIC, 8)
+#define DSL_FIO_ARC_MUX_TEST _IO (DSL_IOC_MEI_BSP_MAGIC, 9)
+#define DSL_FIO_BSP_REMOTE _IOW (DSL_IOC_MEI_BSP_MAGIC, 10, u32)
+#define DSL_FIO_BSP_GET_BASE_ADDRESS _IOR (DSL_IOC_MEI_BSP_MAGIC, 11, u32)
+#define DSL_FIO_BSP_IS_MODEM_READY _IOR (DSL_IOC_MEI_BSP_MAGIC, 12, u32)
+#define DSL_FIO_BSP_GET_VERSION _IOR (DSL_IOC_MEI_BSP_MAGIC, 13, DSL_DEV_Version_t)
+#define DSL_FIO_BSP_CMV_WINHOST _IOWR(DSL_IOC_MEI_BSP_MAGIC, 14, DSL_DEV_WinHost_Message_t)
+#define DSL_FIO_BSP_CMV_READ _IOWR(DSL_IOC_MEI_BSP_MAGIC, 15, DSL_DEV_MeiReg_t)
+#define DSL_FIO_BSP_CMV_WRITE _IOW (DSL_IOC_MEI_BSP_MAGIC, 16, DSL_DEV_MeiReg_t)
+#define DSL_FIO_BSP_DEBUG_READ _IOWR(DSL_IOC_MEI_BSP_MAGIC, 17, DSL_DEV_MeiDebug_t)
+#define DSL_FIO_BSP_DEBUG_WRITE _IOWR(DSL_IOC_MEI_BSP_MAGIC, 18, DSL_DEV_MeiDebug_t)
+#define DSL_FIO_BSP_GET_CHIP_INFO _IOR (DSL_IOC_MEI_BSP_MAGIC, 19, DSL_DEV_HwVersion_t)
+
+#define DSL_DEV_MEIDEBUG_BUFFER_SIZES 512
+
+typedef struct DSL_DEV_MeiDebug
+{
+ DSL_uint32_t iAddress;
+ DSL_uint32_t iCount;
+ DSL_uint32_t buffer[DSL_DEV_MEIDEBUG_BUFFER_SIZES];
+} DSL_DEV_MeiDebug_t; /* meidebug */
+
+/**
+ * Structure is used for debug access only.
+ * Refer to configure option INCLUDE_ADSL_WINHOST_DEBUG */
+typedef struct struct_meireg
+{
+ /*
+ * Specifies that address for debug access */
+ unsigned long iAddress;
+ /*
+ * Specifies the pointer to the data that has to be written or returns a
+ * pointer to the data that has been read out*/
+ unsigned long iData;
+} DSL_DEV_MeiReg_t; /* meireg */
+
+typedef struct DSL_DEV_Device
+{
+ DSL_int_t nInUse; /* modem state, update by bsp driver, */
+ DSL_void_t *pPriv;
+ DSL_uint32_t base_address; /* mei base address */
+ DSL_int_t nIrq[2]; /* irq number */
+#define IFX_DFEIR 0
+#define IFX_DYING_GASP 1
+ DSL_DEV_MeiDebug_t lop_debugwr; /* dying gasp */
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,0))
+ struct module *owner;
+#endif
+} DSL_DEV_Device_t; /* ifx_adsl_device_t */
+
+#define DSL_DEV_PRIVATE(dev) ((ifx_mei_device_private_t*)(dev->pPriv))
+
+typedef struct DSL_DEV_Version /* ifx_adsl_bsp_version */
+{
+ unsigned long major;
+ unsigned long minor;
+ unsigned long revision;
+} DSL_DEV_Version_t; /* ifx_adsl_bsp_version_t */
+
+typedef struct DSL_DEV_ChipInfo
+{
+ unsigned long major;
+ unsigned long minor;
+} DSL_DEV_HwVersion_t;
+
+typedef struct
+{
+ DSL_uint8_t dummy;
+} DSL_DEV_DeviceConfig_t;
+
+/** error code definitions */
+typedef enum DSL_DEV_MeiError
+{
+ DSL_DEV_MEI_ERR_SUCCESS = 0,
+ DSL_DEV_MEI_ERR_FAILURE = -1,
+ DSL_DEV_MEI_ERR_MAILBOX_FULL = -2,
+ DSL_DEV_MEI_ERR_MAILBOX_EMPTY = -3,
+ DSL_DEV_MEI_ERR_MAILBOX_TIMEOUT = -4
+} DSL_DEV_MeiError_t; /* MEI_ERROR */
+
+typedef enum {
+ DSL_BSP_MEMORY_READ=0,
+ DSL_BSP_MEMORY_WRITE,
+} DSL_BSP_MemoryAccessType_t; /* ifx_adsl_memory_access_type_t */
+
+typedef enum
+{
+ DSL_LED_LINK_ID=0,
+ DSL_LED_DATA_ID
+} DSL_DEV_LedId_t; /* ifx_adsl_led_id_t */
+
+typedef enum
+{
+ DSL_LED_LINK_TYPE=0,
+ DSL_LED_DATA_TYPE
+} DSL_DEV_LedType_t; /* ifx_adsl_led_type_t */
+
+typedef enum
+{
+ DSL_LED_HD_CPU=0,
+ DSL_LED_HD_FW
+} DSL_DEV_LedHandler_t; /* ifx_adsl_led_handler_t */
+
+typedef enum {
+ DSL_LED_ON=0,
+ DSL_LED_OFF,
+ DSL_LED_FLASH,
+} DSL_DEV_LedMode_t; /* ifx_adsl_led_mode_t */
+
+typedef enum {
+ DSL_CPU_HALT=0,
+ DSL_CPU_RUN,
+ DSL_CPU_RESET,
+} DSL_DEV_CpuMode_t; /* ifx_adsl_cpu_mode_t */
+
+#if 0
+typedef enum {
+ DSL_BSP_EVENT_DYING_GASP = 0,
+ DSL_BSP_EVENT_CEOC_IRQ,
+} DSL_BSP_Event_id_t; /* ifx_adsl_event_id_t */
+
+typedef union DSL_BSP_CB_Param
+{
+ DSL_uint32_t nIrqMessage;
+} DSL_BSP_CB_Param_t; /* ifx_adsl_cbparam_t */
+
+typedef struct DSL_BSP_CB_Event
+{
+ DSL_BSP_Event_id_t nID;
+ DSL_DEV_Device_t *pDev;
+ DSL_BSP_CB_Param_t *pParam;
+} DSL_BSP_CB_Event_t; /* ifx_adsl_cb_event_t */
+#endif
+
+/* external functions (from the BSP Driver) */
+extern DSL_DEV_Device_t* DSL_BSP_DriverHandleGet(int, int);
+extern DSL_int_t DSL_BSP_DriverHandleDelete(DSL_DEV_Device_t *);
+extern DSL_DEV_MeiError_t DSL_BSP_FWDownload(DSL_DEV_Device_t *, const DSL_char_t *, DSL_uint32_t, DSL_int32_t *, DSL_int32_t *);
+extern int DSL_BSP_KernelIoctls(DSL_DEV_Device_t *, unsigned int, unsigned long);
+extern DSL_DEV_MeiError_t DSL_BSP_SendCMV(DSL_DEV_Device_t *, DSL_uint16_t *, DSL_int_t, DSL_uint16_t *);
+extern DSL_DEV_MeiError_t DSL_BSP_AdslLedInit(DSL_DEV_Device_t *, DSL_DEV_LedId_t, DSL_DEV_LedType_t, DSL_DEV_LedHandler_t);
+extern DSL_DEV_MeiError_t DSL_BSP_Showtime(DSL_DEV_Device_t *, DSL_uint32_t, DSL_uint32_t);
+extern int DSL_BSP_ATMLedCBRegister( int (*ifx_adsl_ledcallback)(void));
+extern DSL_DEV_MeiError_t DSL_BSP_MemoryDebugAccess(DSL_DEV_Device_t *, DSL_BSP_MemoryAccessType_t, DSL_uint32_t, DSL_uint32_t *, DSL_uint32_t);
+extern volatile DSL_DEV_Device_t *adsl_dev;
+
+/**
+ * Dummy structure by now to show mechanism of extended data that will be
+ * provided within event callback itself.
+ * */
+typedef struct
+{
+ /**
+ * Dummy value */
+ DSL_uint32_t nDummy1;
+} DSL_BSP_CB_Event1DataDummy_t;
+
+/**
+ * Dummy structure by now to show mechanism of extended data that will be
+ * provided within event callback itself.
+ * */
+typedef struct
+{
+ /**
+ * Dummy value */
+ DSL_uint32_t nDummy2;
+} DSL_BSP_CB_Event2DataDummy_t;
+
+/**
+ * encapsulate all data structures that are necessary for status event
+ * callbacks.
+ * */
+typedef union
+{
+ DSL_BSP_CB_Event1DataDummy_t dataEvent1;
+ DSL_BSP_CB_Event2DataDummy_t dataEvent2;
+} DSL_BSP_CB_DATA_Union_t;
+
+
+typedef enum
+{
+ /**
+ * Informs the upper layer driver (DSL CPE API) about a reboot request from the
+ * firmware.
+ * \note This event does NOT include any additional data.
+ * More detailed information upon reboot reason has to be requested from
+ * upper layer software via CMV (INFO 109) if necessary. */
+ DSL_BSP_CB_FIRST = 0,
+ DSL_BSP_CB_DYING_GASP,
+ DSL_BSP_CB_CEOC_IRQ,
+ DSL_BSP_CB_FIRMWARE_REBOOT,
+ /**
+ * Delimiter only */
+ DSL_BSP_CB_LAST
+} DSL_BSP_CB_Type_t;
+
+/**
+ * Specifies the common event type that has to be used for registering and
+ * signalling of interrupts/autonomous status events from MEI BSP Driver.
+ *
+ * \param pDev
+ * Context pointer from MEI BSP Driver.
+ *
+ * \param IFX_ADSL_BSP_CallbackType_t
+ * Specifies the event callback type (reason of callback). Regrading to the
+ * setting of this value the data which is included in the following union
+ * might have different meanings.
+ * Please refer to the description of the union to get information about the
+ * meaning of the included data.
+ *
+ * \param pData
+ * Data according to \ref DSL_BSP_CB_DATA_Union_t.
+ * If this pointer is NULL there is no additional data available.
+ *
+ * \return depending on event
+ */
+typedef int (*DSL_BSP_EventCallback_t)
+(
+ DSL_DEV_Device_t *pDev,
+ DSL_BSP_CB_Type_t nCallbackType,
+ DSL_BSP_CB_DATA_Union_t *pData
+);
+
+typedef struct {
+ DSL_BSP_EventCallback_t function;
+ DSL_BSP_CB_Type_t event;
+ DSL_BSP_CB_DATA_Union_t *pData;
+} DSL_BSP_EventCallBack_t;
+
+extern int DSL_BSP_EventCBRegister(DSL_BSP_EventCallBack_t *);
+extern int DSL_BSP_EventCBUnregister(DSL_BSP_EventCallBack_t *);
+
+/** Modem states */
+#define DSL_DEV_STAT_InitState 0x0000
+#define DSL_DEV_STAT_ReadyState 0x0001
+#define DSL_DEV_STAT_FailState 0x0002
+#define DSL_DEV_STAT_IdleState 0x0003
+#define DSL_DEV_STAT_QuietState 0x0004
+#define DSL_DEV_STAT_GhsState 0x0005
+#define DSL_DEV_STAT_FullInitState 0x0006
+#define DSL_DEV_STAT_ShowTimeState 0x0007
+#define DSL_DEV_STAT_FastRetrainState 0x0008
+#define DSL_DEV_STAT_LoopDiagMode 0x0009
+#define DSL_DEV_STAT_ShortInit 0x000A /* Bis short initialization */
+
+#define DSL_DEV_STAT_CODESWAP_COMPLETE 0x0002
+
+#endif //IFXMIPS_MEI_H
diff --git a/package/platform/lantiq/ltq-adsl-mei/src/lantiq_mei.c b/package/platform/lantiq/ltq-adsl-mei/src/lantiq_mei.c
new file mode 100644
index 0000000..443b9d9
--- /dev/null
+++ b/package/platform/lantiq/ltq-adsl-mei/src/lantiq_mei.c
@@ -0,0 +1,2805 @@
+/******************************************************************************
+
+ Copyright (c) 2009
+ Infineon Technologies AG
+ Am Campeon 1-12; 81726 Munich, Germany
+
+ For licensing information, see the file 'LICENSE' in the root folder of
+ this software module.
+
+******************************************************************************/
+
+/*!
+ \defgroup AMAZON_S_MEI Amazon-S MEI Driver Module
+ \brief Amazon-S MEI driver module
+ */
+
+/*!
+ \defgroup Internal Compile Parametere
+ \ingroup AMAZON_S_MEI
+ \brief exported functions for other driver use
+ */
+
+/*!
+ \file amazon_s_mei_bsp.c
+ \ingroup AMAZON_S_MEI
+ \brief Amazon-S MEI driver file
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/version.h>
+#include <generated/utsrelease.h>
+#include <linux/types.h>
+#include <linux/fs.h>
+#include <linux/mm.h>
+#include <linux/errno.h>
+#include <linux/interrupt.h>
+#include <linux/netdevice.h>
+#include <linux/etherdevice.h>
+#include <linux/proc_fs.h>
+#include <linux/init.h>
+#include <linux/ioport.h>
+#include <linux/delay.h>
+#include <linux/device.h>
+#include <linux/sched.h>
+#include <linux/platform_device.h>
+#include <asm/uaccess.h>
+#include <asm/hardirq.h>
+
+#include "lantiq_atm.h"
+#include <lantiq_soc.h>
+//#include "ifxmips_atm.h"
+#define IFX_MEI_BSP
+#include "ifxmips_mei_interface.h"
+
+/*#define LTQ_RCU_RST IFX_RCU_RST_REQ
+#define LTQ_RCU_RST_REQ_ARC_JTAG IFX_RCU_RST_REQ_ARC_JTAG
+#define LTQ_RCU_RST_REQ_DFE IFX_RCU_RST_REQ_DFE
+#define LTQ_RCU_RST_REQ_AFE IFX_RCU_RST_REQ_AFE
+#define IFXMIPS_FUSE_BASE_ADDR IFX_FUSE_BASE_ADDR
+#define IFXMIPS_ICU_IM0_IER IFX_ICU_IM0_IER
+#define IFXMIPS_ICU_IM2_IER IFX_ICU_IM2_IER
+#define LTQ_MEI_INT IFX_MEI_INT
+#define LTQ_MEI_DYING_GASP_INT IFX_MEI_DYING_GASP_INT
+#define LTQ_MEI_BASE_ADDR IFX_MEI_SPACE_ACCESS
+#define IFXMIPS_PMU_PWDCR IFX_PMU_PWDCR
+#define IFXMIPS_MPS_CHIPID IFX_MPS_CHIPID
+
+#define ifxmips_port_reserve_pin ifx_gpio_pin_reserve
+#define ifxmips_port_set_dir_in ifx_gpio_dir_in_set
+#define ifxmips_port_clear_altsel0 ifx_gpio_altsel0_set
+#define ifxmips_port_clear_altsel1 ifx_gpio_altsel1_clear
+#define ifxmips_port_set_open_drain ifx_gpio_open_drain_clear
+#define ifxmips_port_free_pin ifx_gpio_pin_free
+#define ifxmips_mask_and_ack_irq bsp_mask_and_ack_irq
+#define IFXMIPS_MPS_CHIPID_VERSION_GET IFX_MCD_CHIPID_VERSION_GET
+#define ltq_r32(reg) __raw_readl(reg)
+#define ltq_w32(val, reg) __raw_writel(val, reg)
+#define ltq_w32_mask(clear, set, reg) ltq_w32((ltq_r32(reg) & ~clear) | set, reg)
+*/
+
+#define LTQ_RCU_BASE_ADDR 0x1F203000
+#define LTQ_ICU_BASE_ADDR 0x1F880200
+#define LTQ_MEI_BASE_ADDR 0x1E116000
+#define LTQ_PMU_BASE_ADDR 0x1F102000
+#define LTQ_MEI_DYING_GASP_INT (INT_NUM_IM1_IRL0 + 21)
+#define LTQ_USB_OC_INT (INT_NUM_IM4_IRL0 + 23)
+#define LTQ_MEI_INT (INT_NUM_IM1_IRL0 + 23)
+
+#define LTQ_RCU_RST_REQ_DFE (1 << 7)
+#define LTQ_RCU_RST_REQ_AFE (1 << 11)
+
+#define LTQ_PMU_BASE (KSEG1 + LTQ_PMU_BASE_ADDR)
+#define LTQ_RCU_BASE (KSEG1 + LTQ_RCU_BASE_ADDR)
+#define LTQ_ICU_BASE (KSEG1 + LTQ_ICU_BASE_ADDR)
+
+#define LTQ_PMU_PWDCR ((u32 *)(LTQ_PMU_BASE + 0x001C))
+#define LTQ_PMU_PWDSR ((u32 *)(LTQ_PMU_BASE + 0x0020))
+#define LTQ_RCU_RST ((u32 *)(LTQ_RCU_BASE + 0x0010))
+#define LTQ_RCU_RST_ALL 0x40000000
+
+#define LTQ_ICU_IM0_ISR ((u32 *)(LTQ_ICU_BASE + 0x0000))
+#define LTQ_ICU_IM0_IER ((u32 *)(LTQ_ICU_BASE + 0x0008))
+#define LTQ_ICU_IM0_IOSR ((u32 *)(LTQ_ICU_BASE + 0x0010))
+#define LTQ_ICU_IM0_IRSR ((u32 *)(LTQ_ICU_BASE + 0x0018))
+#define LTQ_ICU_IM0_IMR ((u32 *)(LTQ_ICU_BASE + 0x0020))
+
+
+#define LTQ_ICU_IM1_ISR ((u32 *)(LTQ_ICU_BASE + 0x0028))
+#define LTQ_ICU_IM2_ISR ((u32 *)(LTQ_ICU_BASE + 0x0050))
+#define LTQ_ICU_IM3_ISR ((u32 *)(LTQ_ICU_BASE + 0x0078))
+#define LTQ_ICU_IM4_ISR ((u32 *)(LTQ_ICU_BASE + 0x00A0))
+
+#define LTQ_ICU_OFFSET (LTQ_ICU_IM1_ISR - LTQ_ICU_IM0_ISR)
+#define LTQ_ICU_IM2_IER (LTQ_ICU_IM0_IER + LTQ_ICU_OFFSET)
+
+#define IFX_MEI_EMSG(fmt, args...) pr_err("[%s %d]: " fmt,__FUNCTION__, __LINE__, ## args)
+#define IFX_MEI_DMSG(fmt, args...) pr_debug("[%s %d]: " fmt,__FUNCTION__, __LINE__, ## args)
+
+#define LTQ_FUSE_BASE (KSEG1 + 0x1F107354)
+
+#ifdef CONFIG_LTQ_MEI_FW_LOOPBACK
+//#define DFE_MEM_TEST
+//#define DFE_PING_TEST
+#define DFE_ATM_LOOPBACK
+
+
+#ifdef DFE_ATM_LOOPBACK
+#include <asm/ifxmips/ifxmips_mei_fw_loopback.h>
+#endif
+
+void dfe_loopback_irq_handler (DSL_DEV_Device_t *pDev);
+
+#endif //CONFIG_AMAZON_S_MEI_FW_LOOPBACK
+
+DSL_DEV_Version_t bsp_mei_version = {
+ major: 5,
+ minor: 0,
+ revision:0
+};
+DSL_DEV_HwVersion_t bsp_chip_info;
+
+#define IFX_MEI_DEVNAME "ifx_mei"
+#define BSP_MAX_DEVICES 1
+#define MEI_DIRNAME "ifxmips_mei"
+
+DSL_DEV_MeiError_t DSL_BSP_FWDownload (DSL_DEV_Device_t *, const char *, unsigned long, long *, long *);
+DSL_DEV_MeiError_t DSL_BSP_Showtime (DSL_DEV_Device_t *, DSL_uint32_t, DSL_uint32_t);
+DSL_DEV_MeiError_t DSL_BSP_AdslLedInit (DSL_DEV_Device_t *, DSL_DEV_LedId_t, DSL_DEV_LedType_t, DSL_DEV_LedHandler_t);
+//DSL_DEV_MeiError_t DSL_BSP_AdslLedSet (DSL_DEV_Device_t *, DSL_DEV_LedId_t, DSL_DEV_LedMode_t);
+DSL_DEV_MeiError_t DSL_BSP_MemoryDebugAccess (DSL_DEV_Device_t *, DSL_BSP_MemoryAccessType_t, DSL_uint32_t, DSL_uint32_t*, DSL_uint32_t);
+DSL_DEV_MeiError_t DSL_BSP_SendCMV (DSL_DEV_Device_t *, u16 *, int, u16 *);
+
+int DSL_BSP_KernelIoctls (DSL_DEV_Device_t *, unsigned int, unsigned long);
+
+static DSL_DEV_MeiError_t IFX_MEI_RunAdslModem (DSL_DEV_Device_t *);
+static DSL_DEV_MeiError_t IFX_MEI_CpuModeSet (DSL_DEV_Device_t *, DSL_DEV_CpuMode_t);
+static DSL_DEV_MeiError_t IFX_MEI_DownloadBootCode (DSL_DEV_Device_t *);
+static DSL_DEV_MeiError_t IFX_MEI_ArcJtagEnable (DSL_DEV_Device_t *, int);
+static DSL_DEV_MeiError_t IFX_MEI_AdslMailboxIRQEnable (DSL_DEV_Device_t *, int);
+
+static int IFX_MEI_GetPage (DSL_DEV_Device_t *, u32, u32, u32, u32 *, u32 *);
+static int IFX_MEI_BarUpdate (DSL_DEV_Device_t *, int);
+
+static ssize_t IFX_MEI_Write (DSL_DRV_file_t *, const char *, size_t, loff_t *);
+static long IFX_MEI_UserIoctls (DSL_DRV_file_t *, unsigned int, unsigned long);
+static int IFX_MEI_Open (DSL_DRV_inode_t *, DSL_DRV_file_t *);
+static int IFX_MEI_Release (DSL_DRV_inode_t *, DSL_DRV_file_t *);
+
+void AMAZON_SE_MEI_ARC_MUX_Test(void);
+
+void IFX_MEI_ARC_MUX_Test(void);
+
+static int adsl_dummy_ledcallback(void);
+
+int (*ifx_mei_atm_showtime_enter)(struct port_cell_info *, void *) = NULL;
+EXPORT_SYMBOL(ifx_mei_atm_showtime_enter);
+
+int (*ifx_mei_atm_showtime_exit)(void) = NULL;
+EXPORT_SYMBOL(ifx_mei_atm_showtime_exit);
+
+static int (*g_adsl_ledcallback)(void) = adsl_dummy_ledcallback;
+
+static unsigned int g_tx_link_rate[2] = {0};
+
+static void *g_xdata_addr = NULL;
+
+static u32 *mei_arc_swap_buff = NULL; // holding swap pages
+
+extern void ltq_mask_and_ack_irq(struct irq_data *d);
+static void inline MEI_MASK_AND_ACK_IRQ(int x)
+{
+ struct irq_data d;
+ d.hwirq = x;
+ ltq_mask_and_ack_irq(&d);
+}
+#define MEI_MAJOR 105
+static int dev_major = MEI_MAJOR;
+
+static struct file_operations bsp_mei_operations = {
+ owner:THIS_MODULE,
+ open:IFX_MEI_Open,
+ release:IFX_MEI_Release,
+ write:IFX_MEI_Write,
+ unlocked_ioctl:IFX_MEI_UserIoctls,
+};
+
+static DSL_DEV_Device_t dsl_devices[BSP_MAX_DEVICES];
+
+static ifx_mei_device_private_t
+ sDanube_Mei_Private[BSP_MAX_DEVICES];
+
+static DSL_BSP_EventCallBack_t dsl_bsp_event_callback[DSL_BSP_CB_LAST + 1];
+
+/**
+ * Write a value to register
+ * This function writes a value to danube register
+ *
+ * \param ul_address The address to write
+ * \param ul_data The value to write
+ * \ingroup Internal
+ */
+static void
+IFX_MEI_LongWordWrite (u32 ul_address, u32 ul_data)
+{
+ IFX_MEI_WRITE_REGISTER_L (ul_data, ul_address);
+ wmb();
+ return;
+}
+
+/**
+ * Write a value to register
+ * This function writes a value to danube register
+ *
+ * \param pDev the device pointer
+ * \param ul_address The address to write
+ * \param ul_data The value to write
+ * \ingroup Internal
+ */
+static void
+IFX_MEI_LongWordWriteOffset (DSL_DEV_Device_t * pDev, u32 ul_address,
+ u32 ul_data)
+{
+ IFX_MEI_WRITE_REGISTER_L (ul_data, pDev->base_address + ul_address);
+ wmb();
+ return;
+}
+
+/**
+ * Read the danube register
+ * This function read the value from danube register
+ *
+ * \param ul_address The address to write
+ * \param pul_data Pointer to the data
+ * \ingroup Internal
+ */
+static void
+IFX_MEI_LongWordRead (u32 ul_address, u32 * pul_data)
+{
+ *pul_data = IFX_MEI_READ_REGISTER_L (ul_address);
+ rmb();
+ return;
+}
+
+/**
+ * Read the danube register
+ * This function read the value from danube register
+ *
+ * \param pDev the device pointer
+ * \param ul_address The address to write
+ * \param pul_data Pointer to the data
+ * \ingroup Internal
+ */
+static void
+IFX_MEI_LongWordReadOffset (DSL_DEV_Device_t * pDev, u32 ul_address,
+ u32 * pul_data)
+{
+ *pul_data = IFX_MEI_READ_REGISTER_L (pDev->base_address + ul_address);
+ rmb();
+ return;
+}
+
+/**
+ * Write several DWORD datas to ARC memory via ARC DMA interface
+ * This function writes several DWORD datas to ARC memory via DMA interface.
+ *
+ * \param pDev the device pointer
+ * \param destaddr The address to write
+ * \param databuff Pointer to the data buffer
+ * \param databuffsize Number of DWORDs to write
+ * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
+ * \ingroup Internal
+ */
+static DSL_DEV_MeiError_t
+IFX_MEI_DMAWrite (DSL_DEV_Device_t * pDev, u32 destaddr,
+ u32 * databuff, u32 databuffsize)
+{
+ u32 *p = databuff;
+ u32 temp;
+
+ if (destaddr & 3)
+ return DSL_DEV_MEI_ERR_FAILURE;
+
+ // Set the write transfer address
+ IFX_MEI_LongWordWriteOffset (pDev, ME_DX_AD, destaddr);
+
+ // Write the data pushed across DMA
+ while (databuffsize--) {
+ temp = *p;
+ if (destaddr == MEI_TO_ARC_MAILBOX)
+ MEI_HALF_WORD_SWAP (temp);
+ IFX_MEI_LongWordWriteOffset (pDev, (u32) ME_DX_DATA, temp);
+ p++;
+ }
+
+ return DSL_DEV_MEI_ERR_SUCCESS;
+
+}
+
+/**
+ * Read several DWORD datas from ARC memory via ARC DMA interface
+ * This function reads several DWORD datas from ARC memory via DMA interface.
+ *
+ * \param pDev the device pointer
+ * \param srcaddr The address to read
+ * \param databuff Pointer to the data buffer
+ * \param databuffsize Number of DWORDs to read
+ * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
+ * \ingroup Internal
+ */
+static DSL_DEV_MeiError_t
+IFX_MEI_DMARead (DSL_DEV_Device_t * pDev, u32 srcaddr, u32 * databuff,
+ u32 databuffsize)
+{
+ u32 *p = databuff;
+ u32 temp;
+
+ if (srcaddr & 3)
+ return DSL_DEV_MEI_ERR_FAILURE;
+
+ // Set the read transfer address
+ IFX_MEI_LongWordWriteOffset (pDev, (u32) ME_DX_AD, srcaddr);
+
+ // Read the data popped across DMA
+ while (databuffsize--) {
+ IFX_MEI_LongWordReadOffset (pDev, (u32) ME_DX_DATA, &temp);
+ if (databuff == (u32 *) DSL_DEV_PRIVATE(pDev)->CMV_RxMsg) // swap half word
+ MEI_HALF_WORD_SWAP (temp);
+ *p = temp;
+ p++;
+ }
+
+ return DSL_DEV_MEI_ERR_SUCCESS;
+
+}
+
+/**
+ * Switch the ARC control mode
+ * This function switchs the ARC control mode to JTAG mode or MEI mode
+ *
+ * \param pDev the device pointer
+ * \param mode The mode want to switch: JTAG_MASTER_MODE or MEI_MASTER_MODE.
+ * \ingroup Internal
+ */
+static void
+IFX_MEI_ControlModeSet (DSL_DEV_Device_t * pDev, int mode)
+{
+ u32 temp = 0x0;
+
+ IFX_MEI_LongWordReadOffset (pDev, (u32) ME_DBG_MASTER, &temp);
+ switch (mode) {
+ case JTAG_MASTER_MODE:
+ temp &= ~(HOST_MSTR);
+ break;
+ case MEI_MASTER_MODE:
+ temp |= (HOST_MSTR);
+ break;
+ default:
+ IFX_MEI_EMSG ("IFX_MEI_ControlModeSet: unkonwn mode [%d]\n", mode);
+ return;
+ }
+ IFX_MEI_LongWordWriteOffset (pDev, (u32) ME_DBG_MASTER, temp);
+}
+
+/**
+ * Disable ARC to MEI interrupt
+ *
+ * \param pDev the device pointer
+ * \ingroup Internal
+ */
+static void
+IFX_MEI_IRQDisable (DSL_DEV_Device_t * pDev)
+{
+ IFX_MEI_LongWordWriteOffset (pDev, (u32) ME_ARC2ME_MASK, 0x0);
+}
+
+/**
+ * Eable ARC to MEI interrupt
+ *
+ * \param pDev the device pointer
+ * \ingroup Internal
+ */
+static void
+IFX_MEI_IRQEnable (DSL_DEV_Device_t * pDev)
+{
+ IFX_MEI_LongWordWriteOffset (pDev, (u32) ME_ARC2ME_MASK, MSGAV_EN);
+}
+
+/**
+ * Poll for transaction complete signal
+ * This function polls and waits for transaction complete signal.
+ *
+ * \param pDev the device pointer
+ * \ingroup Internal
+ */
+static void
+meiPollForDbgDone (DSL_DEV_Device_t * pDev)
+{
+ u32 query = 0;
+ int i = 0;
+
+ while (i < WHILE_DELAY) {
+ IFX_MEI_LongWordReadOffset (pDev, (u32) ME_ARC2ME_STAT, &query);
+ query &= (ARC_TO_MEI_DBG_DONE);
+ if (query)
+ break;
+ i++;
+ if (i == WHILE_DELAY) {
+ IFX_MEI_EMSG ("PollforDbg fail!\n");
+ }
+ }
+ IFX_MEI_LongWordWriteOffset (pDev, (u32) ME_ARC2ME_STAT, ARC_TO_MEI_DBG_DONE); // to clear this interrupt
+}
+
+/**
+ * ARC Debug Memory Access for a single DWORD reading.
+ * This function used for direct, address-based access to ARC memory.
+ *
+ * \param pDev the device pointer
+ * \param DEC_mode ARC memory space to used
+ * \param address Address to read
+ * \param data Pointer to data
+ * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
+ * \ingroup Internal
+ */
+static DSL_DEV_MeiError_t
+_IFX_MEI_DBGLongWordRead (DSL_DEV_Device_t * pDev, u32 DEC_mode,
+ u32 address, u32 * data)
+{
+ IFX_MEI_LongWordWriteOffset (pDev, (u32) ME_DBG_DECODE, DEC_mode);
+ IFX_MEI_LongWordWriteOffset (pDev, (u32) ME_DBG_RD_AD, address);
+ meiPollForDbgDone (pDev);
+ IFX_MEI_LongWordReadOffset (pDev, (u32) ME_DBG_DATA, data);
+ return DSL_DEV_MEI_ERR_SUCCESS;
+}
+
+/**
+ * ARC Debug Memory Access for a single DWORD writing.
+ * This function used for direct, address-based access to ARC memory.
+ *
+ * \param pDev the device pointer
+ * \param DEC_mode ARC memory space to used
+ * \param address The address to write
+ * \param data The data to write
+ * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
+ * \ingroup Internal
+ */
+static DSL_DEV_MeiError_t
+_IFX_MEI_DBGLongWordWrite (DSL_DEV_Device_t * pDev, u32 DEC_mode,
+ u32 address, u32 data)
+{
+ IFX_MEI_LongWordWriteOffset (pDev, (u32) ME_DBG_DECODE, DEC_mode);
+ IFX_MEI_LongWordWriteOffset (pDev, (u32) ME_DBG_WR_AD, address);
+ IFX_MEI_LongWordWriteOffset (pDev, (u32) ME_DBG_DATA, data);
+ meiPollForDbgDone (pDev);
+ return DSL_DEV_MEI_ERR_SUCCESS;
+}
+
+/**
+ * ARC Debug Memory Access for writing.
+ * This function used for direct, address-based access to ARC memory.
+ *
+ * \param pDev the device pointer
+ * \param destaddr The address to read
+ * \param databuffer Pointer to data
+ * \param databuffsize The number of DWORDs to read
+ * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
+ * \ingroup Internal
+ */
+
+static DSL_DEV_MeiError_t
+IFX_MEI_DebugWrite (DSL_DEV_Device_t * pDev, u32 destaddr,
+ u32 * databuff, u32 databuffsize)
+{
+ u32 i;
+ u32 temp = 0x0;
+ u32 address = 0x0;
+ u32 *buffer = 0x0;
+
+ // Open the debug port before DMP memory write
+ IFX_MEI_ControlModeSet (pDev, MEI_MASTER_MODE);
+
+ // For the requested length, write the address and write the data
+ address = destaddr;
+ buffer = databuff;
+ for (i = 0; i < databuffsize; i++) {
+ temp = *buffer;
+ _IFX_MEI_DBGLongWordWrite (pDev, ME_DBG_DECODE_DMP1_MASK, address, temp);
+ address += 4;
+ buffer++;
+ }
+
+ // Close the debug port after DMP memory write
+ IFX_MEI_ControlModeSet (pDev, JTAG_MASTER_MODE);
+
+ return DSL_DEV_MEI_ERR_SUCCESS;
+}
+
+/**
+ * ARC Debug Memory Access for reading.
+ * This function used for direct, address-based access to ARC memory.
+ *
+ * \param pDev the device pointer
+ * \param srcaddr The address to read
+ * \param databuffer Pointer to data
+ * \param databuffsize The number of DWORDs to read
+ * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
+ * \ingroup Internal
+ */
+static DSL_DEV_MeiError_t
+IFX_MEI_DebugRead (DSL_DEV_Device_t * pDev, u32 srcaddr, u32 * databuff, u32 databuffsize)
+{
+ u32 i;
+ u32 temp = 0x0;
+ u32 address = 0x0;
+ u32 *buffer = 0x0;
+
+ // Open the debug port before DMP memory read
+ IFX_MEI_ControlModeSet (pDev, MEI_MASTER_MODE);
+
+ // For the requested length, write the address and read the data
+ address = srcaddr;
+ buffer = databuff;
+ for (i = 0; i < databuffsize; i++) {
+ _IFX_MEI_DBGLongWordRead (pDev, ME_DBG_DECODE_DMP1_MASK, address, &temp);
+ *buffer = temp;
+ address += 4;
+ buffer++;
+ }
+
+ // Close the debug port after DMP memory read
+ IFX_MEI_ControlModeSet (pDev, JTAG_MASTER_MODE);
+
+ return DSL_DEV_MEI_ERR_SUCCESS;
+}
+
+/**
+ * Send a message to ARC MailBox.
+ * This function sends a message to ARC Mailbox via ARC DMA interface.
+ *
+ * \param pDev the device pointer
+ * \param msgsrcbuffer Pointer to message.
+ * \param msgsize The number of words to write.
+ * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
+ * \ingroup Internal
+ */
+static DSL_DEV_MeiError_t
+IFX_MEI_MailboxWrite (DSL_DEV_Device_t * pDev, u16 * msgsrcbuffer,
+ u16 msgsize)
+{
+ int i;
+ u32 arc_mailbox_status = 0x0;
+ u32 temp = 0;
+ DSL_DEV_MeiError_t meiMailboxError = DSL_DEV_MEI_ERR_SUCCESS;
+
+ // Write to mailbox
+ meiMailboxError =
+ IFX_MEI_DMAWrite (pDev, MEI_TO_ARC_MAILBOX, (u32 *) msgsrcbuffer, msgsize / 2);
+ meiMailboxError =
+ IFX_MEI_DMAWrite (pDev, MEI_TO_ARC_MAILBOXR, (u32 *) (&temp), 1);
+
+ // Notify arc that mailbox write completed
+ DSL_DEV_PRIVATE(pDev)->cmv_waiting = 1;
+ IFX_MEI_LongWordWriteOffset (pDev, (u32) ME_ME2ARC_INT, MEI_TO_ARC_MSGAV);
+
+ i = 0;
+ while (i < WHILE_DELAY) { // wait for ARC to clear the bit
+ IFX_MEI_LongWordReadOffset (pDev, (u32) ME_ME2ARC_INT, &arc_mailbox_status);
+ if ((arc_mailbox_status & MEI_TO_ARC_MSGAV) != MEI_TO_ARC_MSGAV)
+ break;
+ i++;
+ if (i == WHILE_DELAY) {
+ IFX_MEI_EMSG (">>> Timeout waiting for ARC to clear MEI_TO_ARC_MSGAV!!!"
+ " MEI_TO_ARC message size = %d DWORDs <<<\n", msgsize/2);
+ meiMailboxError = DSL_DEV_MEI_ERR_FAILURE;
+ }
+ }
+
+ return meiMailboxError;
+}
+
+/**
+ * Read a message from ARC MailBox.
+ * This function reads a message from ARC Mailbox via ARC DMA interface.
+ *
+ * \param pDev the device pointer
+ * \param msgsrcbuffer Pointer to message.
+ * \param msgsize The number of words to read
+ * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
+ * \ingroup Internal
+ */
+static DSL_DEV_MeiError_t
+IFX_MEI_MailboxRead (DSL_DEV_Device_t * pDev, u16 * msgdestbuffer,
+ u16 msgsize)
+{
+ DSL_DEV_MeiError_t meiMailboxError = DSL_DEV_MEI_ERR_SUCCESS;
+ // Read from mailbox
+ meiMailboxError =
+ IFX_MEI_DMARead (pDev, ARC_TO_MEI_MAILBOX, (u32 *) msgdestbuffer, msgsize / 2);
+
+ // Notify arc that mailbox read completed
+ IFX_MEI_LongWordWriteOffset (pDev, (u32) ME_ARC2ME_STAT, ARC_TO_MEI_MSGAV);
+
+ return meiMailboxError;
+}
+
+/**
+ * Download boot pages to ARC.
+ * This function downloads boot pages to ARC.
+ *
+ * \param pDev the device pointer
+ * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
+ * \ingroup Internal
+ */
+static DSL_DEV_MeiError_t
+IFX_MEI_DownloadBootPages (DSL_DEV_Device_t * pDev)
+{
+ int boot_loop;
+ int page_size;
+ u32 dest_addr;
+
+ /*
+ ** DMA the boot code page(s)
+ */
+
+ for (boot_loop = 1;
+ boot_loop <
+ (DSL_DEV_PRIVATE(pDev)->img_hdr-> count); boot_loop++) {
+ if ((DSL_DEV_PRIVATE(pDev)-> img_hdr->page[boot_loop].p_size) & BOOT_FLAG) {
+ page_size = IFX_MEI_GetPage (pDev, boot_loop,
+ GET_PROG, MAXSWAPSIZE,
+ mei_arc_swap_buff,
+ &dest_addr);
+ if (page_size > 0) {
+ IFX_MEI_DMAWrite (pDev, dest_addr,
+ mei_arc_swap_buff,
+ page_size);
+ }
+ }
+ if ((DSL_DEV_PRIVATE(pDev)-> img_hdr->page[boot_loop].d_size) & BOOT_FLAG) {
+ page_size = IFX_MEI_GetPage (pDev, boot_loop,
+ GET_DATA, MAXSWAPSIZE,
+ mei_arc_swap_buff,
+ &dest_addr);
+ if (page_size > 0) {
+ IFX_MEI_DMAWrite (pDev, dest_addr,
+ mei_arc_swap_buff,
+ page_size);
+ }
+ }
+ }
+ return DSL_DEV_MEI_ERR_SUCCESS;
+}
+
+/**
+ * Initial efuse rar.
+ **/
+static void
+IFX_MEI_FuseInit (DSL_DEV_Device_t * pDev)
+{
+ u32 data = 0;
+ IFX_MEI_DMAWrite (pDev, IRAM0_BASE, &data, 1);
+ IFX_MEI_DMAWrite (pDev, IRAM0_BASE + 4, &data, 1);
+ IFX_MEI_DMAWrite (pDev, IRAM1_BASE, &data, 1);
+ IFX_MEI_DMAWrite (pDev, IRAM1_BASE + 4, &data, 1);
+ IFX_MEI_DMAWrite (pDev, BRAM_BASE, &data, 1);
+ IFX_MEI_DMAWrite (pDev, BRAM_BASE + 4, &data, 1);
+ IFX_MEI_DMAWrite (pDev, ADSL_DILV_BASE, &data, 1);
+ IFX_MEI_DMAWrite (pDev, ADSL_DILV_BASE + 4, &data, 1);
+}
+
+/**
+ * efuse rar program
+ **/
+static void
+IFX_MEI_FuseProg (DSL_DEV_Device_t * pDev)
+{
+ u32 reg_data, fuse_value;
+ int i = 0;
+
+ IFX_MEI_LongWordRead ((u32) LTQ_RCU_RST, &reg_data);
+ while ((reg_data & 0x10000000) == 0) {
+ IFX_MEI_LongWordRead ((u32) LTQ_RCU_RST, &reg_data);
+ i++;
+ /* 0x4000 translate to about 16 ms@111M, so should be enough */
+ if (i == 0x4000)
+ return;
+ }
+ // STEP a: Prepare memory for external accesses
+ // Write fuse_en bit24
+ IFX_MEI_LongWordRead ((u32) LTQ_RCU_RST, &reg_data);
+ IFX_MEI_LongWordWrite ((u32) LTQ_RCU_RST, reg_data | (1 << 24));
+
+ IFX_MEI_FuseInit (pDev);
+ for (i = 0; i < 4; i++) {
+ IFX_MEI_LongWordRead ((u32) (LTQ_FUSE_BASE) + i * 4, &fuse_value);
+ switch (fuse_value & 0xF0000) {
+ case 0x80000:
+ reg_data = ((fuse_value & RX_DILV_ADDR_BIT_MASK) |
+ (RX_DILV_ADDR_BIT_MASK + 0x1));
+ IFX_MEI_DMAWrite (pDev, ADSL_DILV_BASE, &reg_data, 1);
+ break;
+ case 0x90000:
+ reg_data = ((fuse_value & RX_DILV_ADDR_BIT_MASK) |
+ (RX_DILV_ADDR_BIT_MASK + 0x1));
+ IFX_MEI_DMAWrite (pDev, ADSL_DILV_BASE + 4, &reg_data, 1);
+ break;
+ case 0xA0000:
+ reg_data = ((fuse_value & IRAM0_ADDR_BIT_MASK) |
+ (IRAM0_ADDR_BIT_MASK + 0x1));
+ IFX_MEI_DMAWrite (pDev, IRAM0_BASE, &reg_data, 1);
+ break;
+ case 0xB0000:
+ reg_data = ((fuse_value & IRAM0_ADDR_BIT_MASK) |
+ (IRAM0_ADDR_BIT_MASK + 0x1));
+ IFX_MEI_DMAWrite (pDev, IRAM0_BASE + 4, &reg_data, 1);
+ break;
+ case 0xC0000:
+ reg_data = ((fuse_value & IRAM1_ADDR_BIT_MASK) |
+ (IRAM1_ADDR_BIT_MASK + 0x1));
+ IFX_MEI_DMAWrite (pDev, IRAM1_BASE, &reg_data, 1);
+ break;
+ case 0xD0000:
+ reg_data = ((fuse_value & IRAM1_ADDR_BIT_MASK) |
+ (IRAM1_ADDR_BIT_MASK + 0x1));
+ IFX_MEI_DMAWrite (pDev, IRAM1_BASE + 4, &reg_data, 1);
+ break;
+ case 0xE0000:
+ reg_data = ((fuse_value & BRAM_ADDR_BIT_MASK) |
+ (BRAM_ADDR_BIT_MASK + 0x1));
+ IFX_MEI_DMAWrite (pDev, BRAM_BASE, &reg_data, 1);
+ break;
+ case 0xF0000:
+ reg_data = ((fuse_value & BRAM_ADDR_BIT_MASK) |
+ (BRAM_ADDR_BIT_MASK + 0x1));
+ IFX_MEI_DMAWrite (pDev, BRAM_BASE + 4, &reg_data, 1);
+ break;
+ default: // PPE efuse
+ break;
+ }
+ }
+ IFX_MEI_LongWordRead ((u32) LTQ_RCU_RST, &reg_data);
+ IFX_MEI_LongWordWrite ((u32) LTQ_RCU_RST, reg_data & ~(1 << 24));
+ IFX_MEI_LongWordRead ((u32) LTQ_RCU_RST, &reg_data);
+}
+
+/**
+ * Enable DFE Clock
+ * This function enables DFE Clock
+ *
+ * \param pDev the device pointer
+ * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
+ * \ingroup Internal
+ */
+static DSL_DEV_MeiError_t
+IFX_MEI_EnableCLK (DSL_DEV_Device_t * pDev)
+{
+ u32 arc_debug_data = 0;
+ IFX_MEI_ControlModeSet (pDev, MEI_MASTER_MODE);
+ //enable ac_clk signal
+ _IFX_MEI_DBGLongWordRead (pDev, ME_DBG_DECODE_DMP1_MASK,
+ CRI_CCR0, &arc_debug_data);
+ arc_debug_data |= ACL_CLK_MODE_ENABLE;
+ _IFX_MEI_DBGLongWordWrite (pDev, ME_DBG_DECODE_DMP1_MASK,
+ CRI_CCR0, arc_debug_data);
+ IFX_MEI_ControlModeSet (pDev, JTAG_MASTER_MODE);
+ return DSL_DEV_MEI_ERR_SUCCESS;
+}
+
+/**
+ * Halt the ARC.
+ * This function halts the ARC.
+ *
+ * \param pDev the device pointer
+ * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
+ * \ingroup Internal
+ */
+static DSL_DEV_MeiError_t
+IFX_MEI_HaltArc (DSL_DEV_Device_t * pDev)
+{
+ u32 arc_debug_data = 0x0;
+
+ // Switch arc control from JTAG mode to MEI mode
+ IFX_MEI_ControlModeSet (pDev, MEI_MASTER_MODE);
+ _IFX_MEI_DBGLongWordRead (pDev, MEI_DEBUG_DEC_AUX_MASK,
+ ARC_DEBUG, &arc_debug_data);
+ arc_debug_data |= ARC_DEBUG_HALT;
+ _IFX_MEI_DBGLongWordWrite (pDev, MEI_DEBUG_DEC_AUX_MASK,
+ ARC_DEBUG, arc_debug_data);
+ // Switch arc control from MEI mode to JTAG mode
+ IFX_MEI_ControlModeSet (pDev, JTAG_MASTER_MODE);
+
+ MEI_WAIT (10);
+
+ return DSL_DEV_MEI_ERR_SUCCESS;
+}
+
+/**
+ * Run the ARC.
+ * This function runs the ARC.
+ *
+ * \param pDev the device pointer
+ * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
+ * \ingroup Internal
+ */
+static DSL_DEV_MeiError_t
+IFX_MEI_RunArc (DSL_DEV_Device_t * pDev)
+{
+ u32 arc_debug_data = 0x0;
+
+ // Switch arc control from JTAG mode to MEI mode- write '1' to bit0
+ IFX_MEI_ControlModeSet (pDev, MEI_MASTER_MODE);
+ _IFX_MEI_DBGLongWordRead (pDev, MEI_DEBUG_DEC_AUX_MASK,
+ AUX_STATUS, &arc_debug_data);
+
+ // Write debug data reg with content ANDd with 0xFDFFFFFF (halt bit cleared)
+ arc_debug_data &= ~ARC_AUX_HALT;
+ _IFX_MEI_DBGLongWordWrite (pDev, MEI_DEBUG_DEC_AUX_MASK,
+ AUX_STATUS, arc_debug_data);
+
+ // Switch arc control from MEI mode to JTAG mode- write '0' to bit0
+ IFX_MEI_ControlModeSet (pDev, JTAG_MASTER_MODE);
+ // Enable mask for arc codeswap interrupts
+ IFX_MEI_IRQEnable (pDev);
+
+ return DSL_DEV_MEI_ERR_SUCCESS;
+
+}
+
+/**
+ * Reset the ARC.
+ * This function resets the ARC.
+ *
+ * \param pDev the device pointer
+ * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
+ * \ingroup Internal
+ */
+static DSL_DEV_MeiError_t
+IFX_MEI_ResetARC (DSL_DEV_Device_t * pDev)
+{
+ u32 arc_debug_data = 0;
+
+ IFX_MEI_HaltArc (pDev);
+
+ IFX_MEI_LongWordRead ((u32) LTQ_RCU_RST, &arc_debug_data);
+ IFX_MEI_LongWordWrite ((u32) LTQ_RCU_RST,
+ arc_debug_data | LTQ_RCU_RST_REQ_DFE | LTQ_RCU_RST_REQ_AFE);
+
+ // reset ARC
+ IFX_MEI_LongWordWriteOffset (pDev, (u32) ME_RST_CTRL, MEI_SOFT_RESET);
+ IFX_MEI_LongWordWriteOffset (pDev, (u32) ME_RST_CTRL, 0);
+
+ IFX_MEI_IRQDisable (pDev);
+
+ IFX_MEI_EnableCLK (pDev);
+
+#if 0
+ // reset part of PPE
+ *(unsigned long *) (BSP_PPE32_SRST) = 0xC30;
+ *(unsigned long *) (BSP_PPE32_SRST) = 0xFFF;
+#endif
+
+ DSL_DEV_PRIVATE(pDev)->modem_ready = 0;
+
+ return DSL_DEV_MEI_ERR_SUCCESS;
+}
+
+DSL_DEV_MeiError_t
+DSL_BSP_Showtime (DSL_DEV_Device_t * dev, DSL_uint32_t rate_fast, DSL_uint32_t rate_intl)
+{
+ struct port_cell_info port_cell = {0};
+
+ IFX_MEI_EMSG ("Datarate US intl = %d, fast = %d\n", (int)rate_intl,
+ (int)rate_fast);
+
+ if ( rate_fast )
+ g_tx_link_rate[0] = rate_fast / (53 * 8);
+ if ( rate_intl )
+ g_tx_link_rate[1] = rate_intl / (53 * 8);
+
+ if ( g_tx_link_rate[0] == 0 && g_tx_link_rate[1] == 0 ) {
+ IFX_MEI_EMSG ("Got rate fail.\n");
+ }
+
+ if ( ifx_mei_atm_showtime_enter )
+ {
+ port_cell.port_num = 2;
+ port_cell.tx_link_rate[0] = g_tx_link_rate[0];
+ port_cell.tx_link_rate[1] = g_tx_link_rate[1];
+ ifx_mei_atm_showtime_enter(&port_cell, g_xdata_addr);
+ }
+ else
+ {
+ IFX_MEI_EMSG("no hookup from ATM driver to set cell rate\n");
+ }
+
+ return DSL_DEV_MEI_ERR_SUCCESS;
+};
+
+/**
+ * Reset/halt/run the DFE.
+ * This function provide operations to reset/halt/run the DFE.
+ *
+ * \param pDev the device pointer
+ * \param mode which operation want to do
+ * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
+ * \ingroup Internal
+ */
+static DSL_DEV_MeiError_t
+IFX_MEI_CpuModeSet (DSL_DEV_Device_t *pDev,
+ DSL_DEV_CpuMode_t mode)
+{
+ DSL_DEV_MeiError_t err_ret = DSL_DEV_MEI_ERR_FAILURE;
+ switch (mode) {
+ case DSL_CPU_HALT:
+ err_ret = IFX_MEI_HaltArc (pDev);
+ break;
+ case DSL_CPU_RUN:
+ err_ret = IFX_MEI_RunArc (pDev);
+ break;
+ case DSL_CPU_RESET:
+ err_ret = IFX_MEI_ResetARC (pDev);
+ break;
+ default:
+ break;
+ }
+ return err_ret;
+}
+
+/**
+ * Accress DFE memory.
+ * This function provide a way to access DFE memory;
+ *
+ * \param pDev the device pointer
+ * \param type read or write
+ * \param destaddr destination address
+ * \param databuff pointer to hold data
+ * \param databuffsize size want to read/write
+ * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
+ * \ingroup Internal
+ */
+DSL_DEV_MeiError_t
+DSL_BSP_MemoryDebugAccess (DSL_DEV_Device_t * pDev,
+ DSL_BSP_MemoryAccessType_t type,
+ DSL_uint32_t destaddr, DSL_uint32_t *databuff,
+ DSL_uint32_t databuffsize)
+{
+ DSL_DEV_MeiError_t meierr = DSL_DEV_MEI_ERR_SUCCESS;
+ switch (type) {
+ case DSL_BSP_MEMORY_READ:
+ meierr = IFX_MEI_DebugRead (pDev, (u32)destaddr, (u32*)databuff, (u32)databuffsize);
+ break;
+ case DSL_BSP_MEMORY_WRITE:
+ meierr = IFX_MEI_DebugWrite (pDev, (u32)destaddr, (u32*)databuff, (u32)databuffsize);
+ break;
+ }
+ return DSL_DEV_MEI_ERR_SUCCESS;
+};
+
+/**
+ * Download boot code to ARC.
+ * This function downloads boot code to ARC.
+ *
+ * \param pDev the device pointer
+ * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
+ * \ingroup Internal
+ */
+static DSL_DEV_MeiError_t
+IFX_MEI_DownloadBootCode (DSL_DEV_Device_t *pDev)
+{
+ IFX_MEI_IRQDisable (pDev);
+
+ IFX_MEI_EnableCLK (pDev);
+
+ IFX_MEI_FuseProg (pDev); //program fuse rar
+
+ IFX_MEI_DownloadBootPages (pDev);
+
+ return DSL_DEV_MEI_ERR_SUCCESS;
+};
+
+/**
+ * Enable Jtag debugger interface
+ * This function setups mips gpio to enable jtag debugger
+ *
+ * \param pDev the device pointer
+ * \param enable enable or disable
+ * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
+ * \ingroup Internal
+ */
+static DSL_DEV_MeiError_t
+IFX_MEI_ArcJtagEnable (DSL_DEV_Device_t *dev, int enable)
+{
+ /*
+ int meierr=0;
+ u32 reg_data;
+ switch (enable) {
+ case 1:
+ //reserve gpio 9, 10, 11, 14, 19 for ARC JTAG
+ ifxmips_port_reserve_pin (0, 9);
+ ifxmips_port_reserve_pin (0, 10);
+ ifxmips_port_reserve_pin (0, 11);
+ ifxmips_port_reserve_pin (0, 14);
+ ifxmips_port_reserve_pin (1, 3);
+
+ ifxmips_port_set_dir_in(0, 11);
+ ifxmips_port_clear_altsel0(0, 11);
+ ifxmips_port_clear_altsel1(0, 11);
+ ifxmips_port_set_open_drain(0, 11);
+ //enable ARC JTAG
+ IFX_MEI_LongWordRead ((u32) LTQ_RCU_RST, &reg_data);
+ IFX_MEI_LongWordWrite ((u32) LTQ_RCU_RST, reg_data | LTQ_RCU_RST_REQ_ARC_JTAG);
+ break;
+ case 0:
+ default:
+ break;
+ }
+jtag_end:
+ if (meierr)
+ return DSL_DEV_MEI_ERR_FAILURE;
+*/
+
+ return DSL_DEV_MEI_ERR_SUCCESS;
+};
+
+/**
+ * Enable DFE to MIPS interrupt
+ * This function enable DFE to MIPS interrupt
+ *
+ * \param pDev the device pointer
+ * \param enable enable or disable
+ * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
+ * \ingroup Internal
+ */
+static DSL_DEV_MeiError_t
+IFX_MEI_AdslMailboxIRQEnable (DSL_DEV_Device_t *pDev, int enable)
+{
+ DSL_DEV_MeiError_t meierr;
+ switch (enable) {
+ case 0:
+ meierr = DSL_DEV_MEI_ERR_SUCCESS;
+ IFX_MEI_IRQDisable (pDev);
+ break;
+ case 1:
+ IFX_MEI_IRQEnable (pDev);
+ meierr = DSL_DEV_MEI_ERR_SUCCESS;
+ break;
+ default:
+ meierr = DSL_DEV_MEI_ERR_FAILURE;
+ break;
+
+ }
+ return meierr;
+}
+
+/**
+ * Get the modem status
+ * This function return the modem status
+ *
+ * \param pDev the device pointer
+ * \return 1: modem ready 0: not ready
+ * \ingroup Internal
+ */
+static int
+IFX_MEI_IsModemReady (DSL_DEV_Device_t * pDev)
+{
+ return DSL_DEV_PRIVATE(pDev)->modem_ready;
+}
+
+DSL_DEV_MeiError_t
+DSL_BSP_AdslLedInit (DSL_DEV_Device_t * dev,
+ DSL_DEV_LedId_t led_number,
+ DSL_DEV_LedType_t type,
+ DSL_DEV_LedHandler_t handler)
+{
+#if 0
+ struct led_config_param param;
+ if (led_number == DSL_LED_LINK_ID && type == DSL_LED_LINK_TYPE && handler == /*DSL_LED_HD_CPU*/DSL_LED_HD_FW) {
+ param.operation_mask = CONFIG_OPERATION_UPDATE_SOURCE;
+ param.led = 0x01;
+ param.source = 0x01;
+// bsp_led_config (&param);
+
+ } else if (led_number == DSL_LED_DATA_ID && type == DSL_LED_DATA_TYPE && (handler == DSL_LED_HD_FW)) {
+ param.operation_mask = CONFIG_OPERATION_UPDATE_SOURCE;
+ param.led = 0x02;
+ param.source = 0x02;
+// bsp_led_config (&param);
+ }
+#endif
+ return DSL_DEV_MEI_ERR_SUCCESS;
+};
+#if 0
+DSL_DEV_MeiError_t
+DSL_BSP_AdslLedSet (DSL_DEV_Device_t * dev, DSL_DEV_LedId_t led_number, DSL_DEV_LedMode_t mode)
+{
+ printk(KERN_INFO "[%s %d]: mode = %#x, led_number = %d\n", __func__, __LINE__, mode, led_number);
+ switch (mode) {
+ case DSL_LED_OFF:
+ switch (led_number) {
+ case DSL_LED_LINK_ID:
+#ifdef CONFIG_BSP_LED
+ bsp_led_set_blink (1, 0);
+ bsp_led_set_data (1, 0);
+#endif
+ break;
+ case DSL_LED_DATA_ID:
+#ifdef CONFIG_BSP_LED
+ bsp_led_set_blink (0, 0);
+ bsp_led_set_data (0, 0);
+#endif
+ break;
+ }
+ break;
+ case DSL_LED_FLASH:
+ switch (led_number) {
+ case DSL_LED_LINK_ID:
+#ifdef CONFIG_BSP_LED
+ bsp_led_set_blink (1, 1); // data
+#endif
+ break;
+ case DSL_LED_DATA_ID:
+#ifdef CONFIG_BSP_LED
+ bsp_led_set_blink (0, 1); // data
+#endif
+ break;
+ }
+ break;
+ case DSL_LED_ON:
+ switch (led_number) {
+ case DSL_LED_LINK_ID:
+#ifdef CONFIG_BSP_LED
+ bsp_led_set_blink (1, 0);
+ bsp_led_set_data (1, 1);
+#endif
+ break;
+ case DSL_LED_DATA_ID:
+#ifdef CONFIG_BSP_LED
+ bsp_led_set_blink (0, 0);
+ bsp_led_set_data (0, 1);
+#endif
+ break;
+ }
+ break;
+ }
+ return DSL_DEV_MEI_ERR_SUCCESS;
+};
+
+#endif
+
+/**
+* Compose a message.
+* This function compose a message from opcode, group, address, index, size, and data
+*
+* \param opcode The message opcode
+* \param group The message group number
+* \param address The message address.
+* \param index The message index.
+* \param size The number of words to read/write.
+* \param data The pointer to data.
+* \param CMVMSG The pointer to message buffer.
+* \ingroup Internal
+*/
+void
+makeCMV (u8 opcode, u8 group, u16 address, u16 index, int size, u16 * data, u16 *CMVMSG)
+{
+ memset (CMVMSG, 0, MSG_LENGTH * 2);
+ CMVMSG[0] = (opcode << 4) + (size & 0xf);
+ CMVMSG[1] = (((index == 0) ? 0 : 1) << 7) + (group & 0x7f);
+ CMVMSG[2] = address;
+ CMVMSG[3] = index;
+ if (opcode == H2D_CMV_WRITE)
+ memcpy (CMVMSG + 4, data, size * 2);
+ return;
+}
+
+/**
+ * Send a message to ARC and read the response
+ * This function sends a message to arc, waits the response, and reads the responses.
+ *
+ * \param pDev the device pointer
+ * \param request Pointer to the request
+ * \param reply Wait reply or not.
+ * \param response Pointer to the response
+ * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
+ * \ingroup Internal
+ */
+DSL_DEV_MeiError_t
+DSL_BSP_SendCMV (DSL_DEV_Device_t * pDev, u16 * request, int reply, u16 * response) // write cmv to arc, if reply needed, wait for reply
+{
+ DSL_DEV_MeiError_t meierror;
+#if defined(BSP_PORT_RTEMS)
+ int delay_counter = 0;
+#endif
+
+ if (MEI_MUTEX_LOCK (DSL_DEV_PRIVATE(pDev)->mei_cmv_sema))
+ return -ERESTARTSYS;
+
+ DSL_DEV_PRIVATE(pDev)->cmv_reply = reply;
+ memset (DSL_DEV_PRIVATE(pDev)->CMV_RxMsg, 0,
+ sizeof (DSL_DEV_PRIVATE(pDev)->
+ CMV_RxMsg));
+ DSL_DEV_PRIVATE(pDev)->arcmsgav = 0;
+
+ meierror = IFX_MEI_MailboxWrite (pDev, request, MSG_LENGTH);
+
+ if (meierror != DSL_DEV_MEI_ERR_SUCCESS) {
+ DSL_DEV_PRIVATE(pDev)->cmv_waiting = 0;
+ DSL_DEV_PRIVATE(pDev)->arcmsgav = 0;
+ IFX_MEI_EMSG ("MailboxWrite Fail!\n");
+ IFX_MEI_EMSG ("Resetting ARC...\n");
+ IFX_MEI_ResetARC(pDev);
+ MEI_MUTEX_UNLOCK (DSL_DEV_PRIVATE(pDev)->mei_cmv_sema);
+ return meierror;
+ }
+ else {
+ DSL_DEV_PRIVATE(pDev)->cmv_count++;
+ }
+
+ if (DSL_DEV_PRIVATE(pDev)->cmv_reply ==
+ NO_REPLY) {
+ MEI_MUTEX_UNLOCK (DSL_DEV_PRIVATE(pDev)->mei_cmv_sema);
+ return DSL_DEV_MEI_ERR_SUCCESS;
+ }
+
+#if !defined(BSP_PORT_RTEMS)
+ if (DSL_DEV_PRIVATE(pDev)->arcmsgav == 0)
+ MEI_WAIT_EVENT_TIMEOUT (DSL_DEV_PRIVATE(pDev)->wait_queue_arcmsgav, CMV_TIMEOUT);
+#else
+ while (DSL_DEV_PRIVATE(pDev)->arcmsgav == 0 && delay_counter < CMV_TIMEOUT / 5) {
+ MEI_WAIT (5);
+ delay_counter++;
+ }
+#endif
+
+ DSL_DEV_PRIVATE(pDev)->cmv_waiting = 0;
+ if (DSL_DEV_PRIVATE(pDev)->arcmsgav == 0) { //CMV_timeout
+ DSL_DEV_PRIVATE(pDev)->arcmsgav = 0;
+ IFX_MEI_EMSG ("\%s: DSL_DEV_MEI_ERR_MAILBOX_TIMEOUT\n",
+ __FUNCTION__);
+ MEI_MUTEX_UNLOCK (DSL_DEV_PRIVATE(pDev)->mei_cmv_sema);
+ return DSL_DEV_MEI_ERR_MAILBOX_TIMEOUT;
+ }
+ else {
+ DSL_DEV_PRIVATE(pDev)->arcmsgav = 0;
+ DSL_DEV_PRIVATE(pDev)->
+ reply_count++;
+ memcpy (response, DSL_DEV_PRIVATE(pDev)->CMV_RxMsg, MSG_LENGTH * 2);
+ MEI_MUTEX_UNLOCK (DSL_DEV_PRIVATE(pDev)->mei_cmv_sema);
+ return DSL_DEV_MEI_ERR_SUCCESS;
+ }
+ MEI_MUTEX_UNLOCK (DSL_DEV_PRIVATE(pDev)->mei_cmv_sema);
+ return DSL_DEV_MEI_ERR_SUCCESS;
+}
+
+/**
+ * Reset the ARC, download boot codes, and run the ARC.
+ * This function resets the ARC, downloads boot codes to ARC, and runs the ARC.
+ *
+ * \param pDev the device pointer
+ * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
+ * \ingroup Internal
+ */
+static DSL_DEV_MeiError_t
+IFX_MEI_RunAdslModem (DSL_DEV_Device_t *pDev)
+{
+ int nSize = 0, idx = 0;
+ uint32_t im0_register, im2_register;
+// DSL_DEV_WinHost_Message_t m;
+
+ if (mei_arc_swap_buff == NULL) {
+ mei_arc_swap_buff =
+ (u32 *) kmalloc (MAXSWAPSIZE * 4, GFP_KERNEL);
+ if (mei_arc_swap_buff == NULL) {
+ IFX_MEI_EMSG (">>> malloc fail for codeswap buff!!! <<<\n");
+ return DSL_DEV_MEI_ERR_FAILURE;
+ }
+ IFX_MEI_DMSG("allocate %dKB swap buff memory at: 0x%p\n", ksize(mei_arc_swap_buff)/1024, mei_arc_swap_buff);
+ }
+
+ DSL_DEV_PRIVATE(pDev)->img_hdr =
+ (ARC_IMG_HDR *) DSL_DEV_PRIVATE(pDev)->adsl_mem_info[0].address;
+ if ((DSL_DEV_PRIVATE(pDev)->img_hdr->
+ count) * sizeof (ARC_SWP_PAGE_HDR) > SDRAM_SEGMENT_SIZE) {
+ IFX_MEI_EMSG ("firmware header size is bigger than 64K segment size\n");
+ return DSL_DEV_MEI_ERR_FAILURE;
+ }
+ // check image size
+ for (idx = 0; idx < MAX_BAR_REGISTERS; idx++) {
+ nSize += DSL_DEV_PRIVATE(pDev)->adsl_mem_info[idx].nCopy;
+ }
+ if (nSize !=
+ DSL_DEV_PRIVATE(pDev)->image_size) {
+ IFX_MEI_EMSG ("Firmware download is not completed. Please download firmware again!\n");
+ return DSL_DEV_MEI_ERR_FAILURE;
+ }
+ // TODO: check crc
+ ///
+
+ IFX_MEI_ResetARC (pDev);
+ IFX_MEI_HaltArc (pDev);
+ IFX_MEI_BarUpdate (pDev, DSL_DEV_PRIVATE(pDev)->nBar);
+
+ //IFX_MEI_DMSG("Starting to meiDownloadBootCode\n");
+
+ IFX_MEI_DownloadBootCode (pDev);
+
+ im0_register = (*LTQ_ICU_IM0_IER) & (1 << 20);
+ im2_register = (*LTQ_ICU_IM2_IER) & (1 << 20);
+ /* Turn off irq */
+ #ifdef CONFIG_SOC_AMAZON_SE
+#define IFXMIPS_USB_OC_INT0 (INT_NUM_IM4_IRL0 + 23)
+ disable_irq (IFXMIPS_USB_OC_INT0);
+// disable_irq (IFXMIPS_USB_OC_INT2);
+ #elif defined(CONFIG_SOC_AR9)
+#define IFXMIPS_USB_OC_INT0 (INT_NUM_IM4_IRL1 + 28)
+ disable_irq (IFXMIPS_USB_OC_INT0);
+// disable_irq (IFXMIPS_USB_OC_INT2);
+ #elif defined(CONFIG_SOC_XWAY)
+ disable_irq (LTQ_USB_OC_INT);
+ #else
+ #error unkonwn arch
+ #endif
+ disable_irq (pDev->nIrq[IFX_DYING_GASP]);
+
+ IFX_MEI_RunArc (pDev);
+
+ MEI_WAIT_EVENT_TIMEOUT (DSL_DEV_PRIVATE(pDev)->wait_queue_modemready, 1000);
+
+ #ifdef CONFIG_SOC_AMAZON_SE
+ MEI_MASK_AND_ACK_IRQ (IFXMIPS_USB_OC_INT0);
+// MEI_MASK_AND_ACK_IRQ (IFXMIPS_USB_OC_INT2);
+ #elif defined(CONFIG_SOC_AR9)
+ MEI_MASK_AND_ACK_IRQ (IFXMIPS_USB_OC_INT0);
+// MEI_MASK_AND_ACK_IRQ (IFXMIPS_USB_OC_INT2);
+ #elif defined(CONFIG_SOC_XWAY)
+ MEI_MASK_AND_ACK_IRQ (LTQ_USB_OC_INT);
+ #else
+ #error unkonwn arch
+ #endif
+ MEI_MASK_AND_ACK_IRQ (pDev->nIrq[IFX_DYING_GASP]);
+
+ /* Re-enable irq */
+ enable_irq(pDev->nIrq[IFX_DYING_GASP]);
+ *LTQ_ICU_IM0_IER |= im0_register;
+ *LTQ_ICU_IM2_IER |= im2_register;
+
+ if (DSL_DEV_PRIVATE(pDev)->modem_ready != 1) {
+ IFX_MEI_EMSG ("Modem failed to be ready!\n");
+ return DSL_DEV_MEI_ERR_FAILURE;
+ } else {
+ IFX_MEI_DMSG("Modem is ready.\n");
+ return DSL_DEV_MEI_ERR_SUCCESS;
+ }
+}
+
+/**
+ * Get the page's data pointer
+ * This function caculats the data address from the firmware header.
+ *
+ * \param pDev the device pointer
+ * \param Page The page number.
+ * \param data Data page or program page.
+ * \param MaxSize The maximum size to read.
+ * \param Buffer Pointer to data.
+ * \param Dest Pointer to the destination address.
+ * \return The number of bytes to read.
+ * \ingroup Internal
+ */
+static int
+IFX_MEI_GetPage (DSL_DEV_Device_t * pDev, u32 Page, u32 data,
+ u32 MaxSize, u32 * Buffer, u32 * Dest)
+{
+ u32 size;
+ u32 i;
+ u32 *p;
+ u32 idx, offset, nBar = 0;
+
+ if (Page > DSL_DEV_PRIVATE(pDev)->img_hdr->count)
+ return -2;
+ /*
+ ** Get program or data size, depending on "data" flag
+ */
+ size = (data == GET_DATA) ? (DSL_DEV_PRIVATE(pDev)->img_hdr->page[Page].d_size) :
+ (DSL_DEV_PRIVATE(pDev)->img_hdr->page[Page].p_size);
+ size &= BOOT_FLAG_MASK; // Clear boot bit!
+ if (size > MaxSize)
+ return -1;
+
+ if (size == 0)
+ return 0;
+ /*
+ ** Get program or data offset, depending on "data" flag
+ */
+ i = data ? (DSL_DEV_PRIVATE(pDev)->img_hdr->page[Page].d_offset) :
+ (DSL_DEV_PRIVATE(pDev)->img_hdr->page[Page].p_offset);
+
+ /*
+ ** Copy data/program to buffer
+ */
+
+ idx = i / SDRAM_SEGMENT_SIZE;
+ offset = i % SDRAM_SEGMENT_SIZE;
+ p = (u32 *) ((u8 *) DSL_DEV_PRIVATE(pDev)->adsl_mem_info[idx].address + offset);
+
+ for (i = 0; i < size; i++) {
+ if (offset + i * 4 - (nBar * SDRAM_SEGMENT_SIZE) >= SDRAM_SEGMENT_SIZE) {
+ idx++;
+ nBar++;
+ p = (u32 *) ((u8 *) KSEG1ADDR ((u32)DSL_DEV_PRIVATE(pDev)->adsl_mem_info[idx].address));
+ }
+ Buffer[i] = *p++;
+ }
+
+ /*
+ ** Pass back data/program destination address
+ */
+ *Dest = data ? (DSL_DEV_PRIVATE(pDev)-> img_hdr->page[Page].d_dest) :
+ (DSL_DEV_PRIVATE(pDev)->img_hdr->page[Page].p_dest);
+
+ return size;
+}
+
+/**
+ * Free the memory for ARC firmware
+ *
+ * \param pDev the device pointer
+ * \param type Free all memory or free the unused memory after showtime
+ * \ingroup Internal
+ */
+const char *free_str[4] = {"Invalid", "Free_Reload", "Free_Showtime", "Free_All"};
+static int
+IFX_MEI_DFEMemoryFree (DSL_DEV_Device_t * pDev, int type)
+{
+ int idx = 0;
+ smmu_mem_info_t *adsl_mem_info =
+ DSL_DEV_PRIVATE(pDev)->adsl_mem_info;
+
+ for (idx = 0; idx < MAX_BAR_REGISTERS; idx++) {
+ if (type == FREE_ALL ||adsl_mem_info[idx].type == type) {
+ if (adsl_mem_info[idx].size > 0) {
+ IFX_MEI_DMSG ("Freeing memory %p (%s)\n", adsl_mem_info[idx].org_address, free_str[adsl_mem_info[idx].type]);
+ if ( idx == XDATA_REGISTER ) {
+ g_xdata_addr = NULL;
+ if ( ifx_mei_atm_showtime_exit )
+ ifx_mei_atm_showtime_exit();
+ }
+ kfree (adsl_mem_info[idx].org_address);
+ adsl_mem_info[idx].org_address = 0;
+ adsl_mem_info[idx].address = 0;
+ adsl_mem_info[idx].size = 0;
+ adsl_mem_info[idx].type = 0;
+ adsl_mem_info[idx].nCopy = 0;
+ }
+ }
+ }
+
+ if(mei_arc_swap_buff != NULL){
+ IFX_MEI_DMSG("free %dKB swap buff memory at: 0x%p\n", ksize(mei_arc_swap_buff)/1024, mei_arc_swap_buff);
+ kfree(mei_arc_swap_buff);
+ mei_arc_swap_buff=NULL;
+ }
+
+ return 0;
+}
+static int
+IFX_MEI_DFEMemoryAlloc (DSL_DEV_Device_t * pDev, long size)
+{
+ unsigned long mem_ptr;
+ char *org_mem_ptr = NULL;
+ int idx = 0;
+ long total_size = 0;
+ int err = 0;
+ smmu_mem_info_t *adsl_mem_info =
+ ((ifx_mei_device_private_t *) pDev->pPriv)->adsl_mem_info;
+// DSL_DEV_PRIVATE(pDev)->adsl_mem_info;
+ int allocate_size = SDRAM_SEGMENT_SIZE;
+
+ IFX_MEI_DMSG("image_size = %ld\n", size);
+ // Alloc Swap Pages
+ for (idx = 0; size > 0 && idx < MAX_BAR_REGISTERS; idx++) {
+ // skip bar15 for XDATA usage.
+ if (idx == XDATA_REGISTER)
+ continue;
+#if 0
+ if (size < SDRAM_SEGMENT_SIZE) {
+ allocate_size = size;
+ if (allocate_size < 1024)
+ allocate_size = 1024;
+ }
+#endif
+ if (idx == (MAX_BAR_REGISTERS - 1))
+ allocate_size = size;
+ else
+ allocate_size = SDRAM_SEGMENT_SIZE;
+ org_mem_ptr = kmalloc (allocate_size + 1024, GFP_KERNEL);
+ if (org_mem_ptr == NULL) {
+ IFX_MEI_EMSG ("%d: kmalloc %d bytes memory fail!\n", idx, allocate_size);
+ err = -ENOMEM;
+ goto allocate_error;
+ }
+ mem_ptr = (unsigned long) (org_mem_ptr + 1023) & ~(1024 -1);
+ adsl_mem_info[idx].address = (char *) mem_ptr;
+ adsl_mem_info[idx].org_address = org_mem_ptr;
+ adsl_mem_info[idx].size = allocate_size;
+ size -= allocate_size;
+ total_size += allocate_size;
+ }
+ if (size > 0) {
+ IFX_MEI_EMSG ("Image size is too large!\n");
+ err = -EFBIG;
+ goto allocate_error;
+ }
+ err = idx;
+ return err;
+
+ allocate_error:
+ IFX_MEI_DFEMemoryFree (pDev, FREE_ALL);
+ return err;
+}
+
+/**
+ * Program the BAR registers
+ *
+ * \param pDev the device pointer
+ * \param nTotalBar The number of bar to program.
+ * \ingroup Internal
+ */
+static int
+IFX_MEI_BarUpdate (DSL_DEV_Device_t * pDev, int nTotalBar)
+{
+ int idx = 0;
+ smmu_mem_info_t *adsl_mem_info =
+ DSL_DEV_PRIVATE(pDev)->adsl_mem_info;
+
+ for (idx = 0; idx < nTotalBar; idx++) {
+ //skip XDATA register
+ if (idx == XDATA_REGISTER)
+ continue;
+ IFX_MEI_LongWordWriteOffset (pDev, (u32) ME_XMEM_BAR_BASE + idx * 4,
+ (((uint32_t) adsl_mem_info[idx].address) & 0x0FFFFFFF));
+ }
+ for (idx = nTotalBar; idx < MAX_BAR_REGISTERS; idx++) {
+ if (idx == XDATA_REGISTER)
+ continue;
+ IFX_MEI_LongWordWriteOffset (pDev, (u32) ME_XMEM_BAR_BASE + idx * 4,
+ (((uint32_t)adsl_mem_info[nTotalBar - 1].address) & 0x0FFFFFFF));
+ /* These are for /proc/danube_mei/meminfo purpose */
+ adsl_mem_info[idx].address = adsl_mem_info[nTotalBar - 1].address;
+ adsl_mem_info[idx].org_address = adsl_mem_info[nTotalBar - 1].org_address;
+ adsl_mem_info[idx].size = 0; /* Prevent it from being freed */
+ }
+
+ g_xdata_addr = adsl_mem_info[XDATA_REGISTER].address;
+ IFX_MEI_LongWordWriteOffset (pDev, (u32) ME_XMEM_BAR_BASE + XDATA_REGISTER * 4,
+ (((uint32_t) adsl_mem_info [XDATA_REGISTER].address) & 0x0FFFFFFF));
+ // update MEI_XDATA_BASE_SH
+ IFX_MEI_LongWordWriteOffset (pDev, (u32) ME_XDATA_BASE_SH,
+ ((unsigned long)adsl_mem_info[XDATA_REGISTER].address) & 0x0FFFFFFF);
+
+ return DSL_DEV_MEI_ERR_SUCCESS;
+}
+
+/* This copies the firmware from secondary storage to 64k memory segment in SDRAM */
+DSL_DEV_MeiError_t
+DSL_BSP_FWDownload (DSL_DEV_Device_t * pDev, const char *buf,
+ unsigned long size, long *loff, long *current_offset)
+{
+ ARC_IMG_HDR img_hdr_tmp;
+ smmu_mem_info_t *adsl_mem_info = DSL_DEV_PRIVATE(pDev)->adsl_mem_info;
+
+ size_t nRead = 0, nCopy = 0;
+ char *mem_ptr;
+ ssize_t retval = -ENOMEM;
+ int idx = 0;
+
+ IFX_MEI_DMSG("\n");
+
+ if (*loff == 0) {
+ if (size < sizeof (img_hdr_tmp)) {
+ IFX_MEI_EMSG ("Firmware size is too small!\n");
+ return retval;
+ }
+ copy_from_user ((char *) &img_hdr_tmp, buf, sizeof (img_hdr_tmp));
+ // header of image_size and crc are not included.
+ DSL_DEV_PRIVATE(pDev)->image_size = le32_to_cpu (img_hdr_tmp.size) + 8;
+
+ if (DSL_DEV_PRIVATE(pDev)->image_size > 1024 * 1024) {
+ IFX_MEI_EMSG ("Firmware size is too large!\n");
+ return retval;
+ }
+ // check if arc is halt
+ IFX_MEI_ResetARC (pDev);
+ IFX_MEI_HaltArc (pDev);
+
+ IFX_MEI_DFEMemoryFree (pDev, FREE_ALL); //free all
+
+ retval = IFX_MEI_DFEMemoryAlloc (pDev, DSL_DEV_PRIVATE(pDev)->image_size);
+ if (retval < 0) {
+ IFX_MEI_EMSG ("Error: No memory space left.\n");
+ goto error;
+ }
+ for (idx = 0; idx < retval; idx++) {
+ //skip XDATA register
+ if (idx == XDATA_REGISTER)
+ continue;
+ if (idx * SDRAM_SEGMENT_SIZE < le32_to_cpu (img_hdr_tmp.page[0].p_offset))
+ adsl_mem_info[idx].type = FREE_RELOAD;
+ else
+ adsl_mem_info[idx].type = FREE_SHOWTIME;
+ }
+ DSL_DEV_PRIVATE(pDev)->nBar = retval;
+
+ DSL_DEV_PRIVATE(pDev)->img_hdr =
+ (ARC_IMG_HDR *) adsl_mem_info[0].address;
+
+ adsl_mem_info[XDATA_REGISTER].org_address = kmalloc (SDRAM_SEGMENT_SIZE + 1024, GFP_KERNEL);
+ adsl_mem_info[XDATA_REGISTER].address =
+ (char *) ((unsigned long) (adsl_mem_info[XDATA_REGISTER].org_address + 1023) & 0xFFFFFC00);
+
+ adsl_mem_info[XDATA_REGISTER].size = SDRAM_SEGMENT_SIZE;
+
+ if (adsl_mem_info[XDATA_REGISTER].address == NULL) {
+ IFX_MEI_EMSG ("kmalloc memory fail!\n");
+ retval = -ENOMEM;
+ goto error;
+ }
+ adsl_mem_info[XDATA_REGISTER].type = FREE_RELOAD;
+ IFX_MEI_DMSG("-> IFX_MEI_BarUpdate()\n");
+ IFX_MEI_BarUpdate (pDev, (DSL_DEV_PRIVATE(pDev)->nBar));
+ }
+ else if (DSL_DEV_PRIVATE(pDev)-> image_size == 0) {
+ IFX_MEI_EMSG ("Error: Firmware size=0! \n");
+ goto error;
+ }
+
+ nRead = 0;
+ while (nRead < size) {
+ long offset = ((long) (*loff) + nRead) % SDRAM_SEGMENT_SIZE;
+ idx = (((long) (*loff)) + nRead) / SDRAM_SEGMENT_SIZE;
+ mem_ptr = (char *) KSEG1ADDR ((unsigned long) (adsl_mem_info[idx].address) + offset);
+ if ((size - nRead + offset) > SDRAM_SEGMENT_SIZE)
+ nCopy = SDRAM_SEGMENT_SIZE - offset;
+ else
+ nCopy = size - nRead;
+ copy_from_user (mem_ptr, buf + nRead, nCopy);
+ for (offset = 0; offset < (nCopy / 4); offset++) {
+ ((unsigned long *) mem_ptr)[offset] = le32_to_cpu (((unsigned long *) mem_ptr)[offset]);
+ }
+ nRead += nCopy;
+ adsl_mem_info[idx].nCopy += nCopy;
+ }
+
+ *loff += size;
+ *current_offset = size;
+ return DSL_DEV_MEI_ERR_SUCCESS;
+error:
+ IFX_MEI_DFEMemoryFree (pDev, FREE_ALL);
+ return DSL_DEV_MEI_ERR_FAILURE;
+}
+/*
+ * Register a callback event.
+ * Return:
+ * -1 if the event already has a callback function registered.
+ * 0 success
+ */
+int DSL_BSP_EventCBRegister(DSL_BSP_EventCallBack_t *p)
+{
+ if (!p) {
+ IFX_MEI_EMSG("Invalid parameter!\n");
+ return -EINVAL;
+ }
+ if (p->event > DSL_BSP_CB_LAST || p->event < DSL_BSP_CB_FIRST) {
+ IFX_MEI_EMSG("Invalid Event %d\n", p->event);
+ return -EINVAL;
+ }
+ if (dsl_bsp_event_callback[p->event].function) {
+ IFX_MEI_EMSG("Event %d already has a callback function registered!\n", p->event);
+ return -1;
+ } else {
+ dsl_bsp_event_callback[p->event].function = p->function;
+ dsl_bsp_event_callback[p->event].event = p->event;
+ dsl_bsp_event_callback[p->event].pData = p->pData;
+ }
+ return 0;
+}
+int DSL_BSP_EventCBUnregister(DSL_BSP_EventCallBack_t *p)
+{
+ if (!p) {
+ IFX_MEI_EMSG("Invalid parameter!\n");
+ return -EINVAL;
+ }
+ if (p->event > DSL_BSP_CB_LAST || p->event < DSL_BSP_CB_FIRST) {
+ IFX_MEI_EMSG("Invalid Event %d\n", p->event);
+ return -EINVAL;
+ }
+ if (dsl_bsp_event_callback[p->event].function) {
+ IFX_MEI_EMSG("Unregistering Event %d...\n", p->event);
+ dsl_bsp_event_callback[p->event].function = NULL;
+ dsl_bsp_event_callback[p->event].pData = NULL;
+ } else {
+ IFX_MEI_EMSG("Event %d is not registered!\n", p->event);
+ return -1;
+ }
+ return 0;
+}
+
+/**
+ * MEI Dying Gasp interrupt handler
+ *
+ * \param int1
+ * \param void0
+ * \param regs Pointer to the structure of danube mips registers
+ * \ingroup Internal
+ */
+/*static irqreturn_t IFX_MEI_Dying_Gasp_IrqHandle (int int1, void *void0)
+{
+ DSL_DEV_Device_t *pDev = (DSL_DEV_Device_t *) void0;
+ DSL_BSP_CB_Type_t event;
+
+ if (pDev == NULL)
+ IFX_MEI_EMSG("Error: Got Interrupt but pDev is NULL!!!!\n");
+
+#ifndef CONFIG_SMP
+ disable_irq (pDev->nIrq[IFX_DYING_GASP]);
+#else
+ disable_irq_nosync(pDev->nIrq[IFX_DYING_GASP]);
+#endif
+ event = DSL_BSP_CB_DYING_GASP;
+
+ if (dsl_bsp_event_callback[event].function)
+ (*dsl_bsp_event_callback[event].function)(pDev, event, dsl_bsp_event_callback[event].pData);
+
+#ifdef CONFIG_USE_EMULATOR
+ IFX_MEI_EMSG("Dying Gasp! Shutting Down... (Work around for Amazon-S Venus emulator)\n");
+#else
+ IFX_MEI_EMSG("Dying Gasp! Shutting Down...\n");
+// kill_proc (1, SIGINT, 1);
+#endif
+ return IRQ_HANDLED;
+}
+*/
+extern void ifx_usb_enable_afe_oc(void);
+
+/**
+ * MEI interrupt handler
+ *
+ * \param int1
+ * \param void0
+ * \param regs Pointer to the structure of danube mips registers
+ * \ingroup Internal
+ */
+static irqreturn_t IFX_MEI_IrqHandle (int int1, void *void0)
+{
+ u32 scratch;
+ DSL_DEV_Device_t *pDev = (DSL_DEV_Device_t *) void0;
+#if defined(CONFIG_LTQ_MEI_FW_LOOPBACK) && defined(DFE_PING_TEST)
+ dfe_loopback_irq_handler (pDev);
+ return IRQ_HANDLED;
+#endif //CONFIG_AMAZON_S_MEI_FW_LOOPBACK
+ DSL_BSP_CB_Type_t event;
+
+ if (pDev == NULL)
+ IFX_MEI_EMSG("Error: Got Interrupt but pDev is NULL!!!!\n");
+
+ IFX_MEI_DebugRead (pDev, ARC_MEI_MAILBOXR, &scratch, 1);
+ if (scratch & OMB_CODESWAP_MESSAGE_MSG_TYPE_MASK) {
+ IFX_MEI_EMSG("Receive Code Swap Request interrupt!!!\n");
+ return IRQ_HANDLED;
+ }
+ else if (scratch & OMB_CLEAREOC_INTERRUPT_CODE) {
+ // clear eoc message interrupt
+ IFX_MEI_DMSG("OMB_CLEAREOC_INTERRUPT_CODE\n");
+ event = DSL_BSP_CB_CEOC_IRQ;
+ IFX_MEI_LongWordWriteOffset (pDev, (u32) ME_ARC2ME_STAT, ARC_TO_MEI_MSGAV);
+ if (dsl_bsp_event_callback[event].function)
+ (*dsl_bsp_event_callback[event].function)(pDev, event, dsl_bsp_event_callback[event].pData);
+ } else if (scratch & OMB_REBOOT_INTERRUPT_CODE) {
+ // Reboot
+ IFX_MEI_DMSG("OMB_REBOOT_INTERRUPT_CODE\n");
+ event = DSL_BSP_CB_FIRMWARE_REBOOT;
+
+ IFX_MEI_LongWordWriteOffset (pDev, (u32) ME_ARC2ME_STAT, ARC_TO_MEI_MSGAV);
+
+ if (dsl_bsp_event_callback[event].function)
+ (*dsl_bsp_event_callback[event].function)(pDev, event, dsl_bsp_event_callback[event].pData);
+ } else { // normal message
+ IFX_MEI_MailboxRead (pDev, DSL_DEV_PRIVATE(pDev)->CMV_RxMsg, MSG_LENGTH);
+ if (DSL_DEV_PRIVATE(pDev)-> cmv_waiting == 1) {
+ DSL_DEV_PRIVATE(pDev)-> arcmsgav = 1;
+ DSL_DEV_PRIVATE(pDev)-> cmv_waiting = 0;
+#if !defined(BSP_PORT_RTEMS)
+ MEI_WAKEUP_EVENT (DSL_DEV_PRIVATE(pDev)->wait_queue_arcmsgav);
+#endif
+ }
+ else {
+ DSL_DEV_PRIVATE(pDev)-> modem_ready_cnt++;
+ memcpy ((char *) DSL_DEV_PRIVATE(pDev)->Recent_indicator,
+ (char *) DSL_DEV_PRIVATE(pDev)->CMV_RxMsg, MSG_LENGTH * 2);
+ if (((DSL_DEV_PRIVATE(pDev)->CMV_RxMsg[0] & 0xff0) >> 4) == D2H_AUTONOMOUS_MODEM_READY_MSG) {
+ //check ARC ready message
+ IFX_MEI_DMSG ("Got MODEM_READY_MSG\n");
+ DSL_DEV_PRIVATE(pDev)->modem_ready = 1;
+ MEI_WAKEUP_EVENT (DSL_DEV_PRIVATE(pDev)->wait_queue_modemready);
+ }
+ }
+ }
+
+ return IRQ_HANDLED;
+}
+
+int
+DSL_BSP_ATMLedCBRegister (int (*ifx_adsl_ledcallback) (void))
+{
+ g_adsl_ledcallback = ifx_adsl_ledcallback;
+ return 0;
+}
+
+int
+DSL_BSP_ATMLedCBUnregister (int (*ifx_adsl_ledcallback) (void))
+{
+ g_adsl_ledcallback = adsl_dummy_ledcallback;
+ return 0;
+}
+
+#if 0
+int
+DSL_BSP_EventCBRegister (int (*ifx_adsl_callback)
+ (DSL_BSP_CB_Event_t * param))
+{
+ int error = 0;
+
+ if (DSL_EventCB == NULL) {
+ DSL_EventCB = ifx_adsl_callback;
+ }
+ else {
+ error = -EIO;
+ }
+ return error;
+}
+
+int
+DSL_BSP_EventCBUnregister (int (*ifx_adsl_callback)
+ (DSL_BSP_CB_Event_t * param))
+{
+ int error = 0;
+
+ if (DSL_EventCB == ifx_adsl_callback) {
+ DSL_EventCB = NULL;
+ }
+ else {
+ error = -EIO;
+ }
+ return error;
+}
+
+static int
+DSL_BSP_GetEventCB (int (**ifx_adsl_callback)
+ (DSL_BSP_CB_Event_t * param))
+{
+ *ifx_adsl_callback = DSL_EventCB;
+ return 0;
+}
+#endif
+
+#ifdef CONFIG_LTQ_MEI_FW_LOOPBACK
+#define mte_reg_base (0x4800*4+0x20000)
+
+/* Iridia Registers Address Constants */
+#define MTE_Reg(r) (int)(mte_reg_base + (r*4))
+
+#define IT_AMODE MTE_Reg(0x0004)
+
+#define TIMER_DELAY (1024)
+#define BC0_BYTES (32)
+#define BC1_BYTES (30)
+#define NUM_MB (12)
+#define TIMEOUT_VALUE 2000
+
+static void
+BFMWait (u32 cycle)
+{
+ u32 i;
+ for (i = 0; i < cycle; i++);
+}
+
+static void
+WriteRegLong (u32 addr, u32 data)
+{
+ //*((volatile u32 *)(addr)) = data;
+ IFX_MEI_WRITE_REGISTER_L (data, addr);
+}
+
+static u32
+ReadRegLong (u32 addr)
+{
+ // u32 rd_val;
+ //rd_val = *((volatile u32 *)(addr));
+ // return rd_val;
+ return IFX_MEI_READ_REGISTER_L (addr);
+}
+
+/* This routine writes the mailbox with the data in an input array */
+static void
+WriteMbox (u32 * mboxarray, u32 size)
+{
+ IFX_MEI_DebugWrite (&dsl_devices[0], IMBOX_BASE, mboxarray, size);
+ IFX_MEI_DMSG("write to %X\n", IMBOX_BASE);
+ IFX_MEI_LongWordWriteOffset (&dsl_devices[0], (u32) ME_ME2ARC_INT, MEI_TO_ARC_MSGAV);
+}
+
+/* This routine reads the output mailbox and places the results into an array */
+static void
+ReadMbox (u32 * mboxarray, u32 size)
+{
+ IFX_MEI_DebugRead (&dsl_devices[0], OMBOX_BASE, mboxarray, size);
+ IFX_MEI_DMSG("read from %X\n", OMBOX_BASE);
+}
+
+static void
+MEIWriteARCValue (u32 address, u32 value)
+{
+ u32 i, check = 0;
+
+ /* Write address register */
+ IFX_MEI_WRITE_REGISTER_L (address, ME_DBG_WR_AD + LTQ_MEI_BASE_ADDR);
+
+ /* Write data register */
+ IFX_MEI_WRITE_REGISTER_L (value, ME_DBG_DATA + LTQ_MEI_BASE_ADDR);
+
+ /* wait until complete - timeout at 40 */
+ for (i = 0; i < 40; i++) {
+ check = IFX_MEI_READ_REGISTER_L (ME_ARC2ME_STAT + LTQ_MEI_BASE_ADDR);
+
+ if ((check & ARC_TO_MEI_DBG_DONE))
+ break;
+ }
+ /* clear the flag */
+ IFX_MEI_WRITE_REGISTER_L (ARC_TO_MEI_DBG_DONE, ME_ARC2ME_STAT + LTQ_MEI_BASE_ADDR);
+}
+
+void
+arc_code_page_download (uint32_t arc_code_length, uint32_t * start_address)
+{
+ int count;
+
+ IFX_MEI_DMSG("try to download pages,size=%d\n", arc_code_length);
+ IFX_MEI_ControlModeSet (&dsl_devices[0], MEI_MASTER_MODE);
+ IFX_MEI_HaltArc (&dsl_devices[0]);
+ IFX_MEI_LongWordWriteOffset (&dsl_devices[0], (u32) ME_DX_AD, 0);
+ for (count = 0; count < arc_code_length; count++) {
+ IFX_MEI_LongWordWriteOffset (&dsl_devices[0], (u32) ME_DX_DATA,
+ *(start_address + count));
+ }
+ IFX_MEI_ControlModeSet (&dsl_devices[0], JTAG_MASTER_MODE);
+}
+static int
+load_jump_table (unsigned long addr)
+{
+ int i;
+ uint32_t addr_le, addr_be;
+ uint32_t jump_table[32];
+
+ for (i = 0; i < 16; i++) {
+ addr_le = i * 8 + addr;
+ addr_be = ((addr_le >> 16) & 0xffff);
+ addr_be |= ((addr_le & 0xffff) << 16);
+ jump_table[i * 2 + 0] = 0x0f802020;
+ jump_table[i * 2 + 1] = addr_be;
+ //printk("jt %X %08X %08X\n",i,jump_table[i*2+0],jump_table[i*2+1]);
+ }
+ arc_code_page_download (32, &jump_table[0]);
+return 0;
+}
+
+int got_int = 0;
+
+void
+dfe_loopback_irq_handler (DSL_DEV_Device_t *pDev)
+{
+ uint32_t rd_mbox[10];
+
+ memset (&rd_mbox[0], 0, 10 * 4);
+ ReadMbox (&rd_mbox[0], 6);
+ if (rd_mbox[0] == 0x0) {
+ FX_MEI_DMSG("Get ARC_ACK\n");
+ got_int = 1;
+ }
+ else if (rd_mbox[0] == 0x5) {
+ IFX_MEI_DMSG("Get ARC_BUSY\n");
+ got_int = 2;
+ }
+ else if (rd_mbox[0] == 0x3) {
+ IFX_MEI_DMSG("Get ARC_EDONE\n");
+ if (rd_mbox[1] == 0x0) {
+ got_int = 3;
+ IFX_MEI_DMSG("Get E_MEMTEST\n");
+ if (rd_mbox[2] != 0x1) {
+ got_int = 4;
+ IFX_MEI_DMSG("Get Result %X\n", rd_mbox[2]);
+ }
+ }
+ }
+ IFX_MEI_LongWordWriteOffset (&dsl_devices[0], (u32) ME_ARC2ME_STAT,
+ ARC_TO_MEI_DBG_DONE);
+ MEI_MASK_AND_ACK_IRQ (pDev->nIrq[IFX_DFEIR]);
+ disable_irq (pDev->nIrq[IFX_DFEIR]);
+ //got_int = 1;
+ return;
+}
+
+static void
+wait_mem_test_result (void)
+{
+ uint32_t mbox[5];
+ mbox[0] = 0;
+
+ IFX_MEI_DMSG("Waiting Starting\n");
+ while (mbox[0] == 0) {
+ ReadMbox (&mbox[0], 5);
+ }
+ IFX_MEI_DMSG("Try to get mem test result.\n");
+ ReadMbox (&mbox[0], 5);
+ if (mbox[0] == 0xA) {
+ IFX_MEI_DMSG("Success.\n");
+ }
+ else if (mbox[0] == 0xA) {
+ IFX_MEI_EMSG("Fail,address %X,except data %X,receive data %X\n",
+ mbox[1], mbox[2], mbox[3]);
+ }
+ else {
+ IFX_MEI_EMSG("Fail\n");
+ }
+}
+
+static int
+arc_ping_testing (DSL_DEV_Device_t *pDev)
+{
+#define MEI_PING 0x00000001
+ uint32_t wr_mbox[10], rd_mbox[10];
+ int i;
+
+ for (i = 0; i < 10; i++) {
+ wr_mbox[i] = 0;
+ rd_mbox[i] = 0;
+ }
+
+ FX_MEI_DMSG("send ping msg\n");
+ wr_mbox[0] = MEI_PING;
+ WriteMbox (&wr_mbox[0], 10);
+
+ while (got_int == 0) {
+ MEI_WAIT (100);
+ }
+
+ IFX_MEI_DMSG("send start event\n");
+ got_int = 0;
+
+ wr_mbox[0] = 0x4;
+ wr_mbox[1] = 0;
+ wr_mbox[2] = 0;
+ wr_mbox[3] = (uint32_t) 0xf5acc307e;
+ wr_mbox[4] = 5;
+ wr_mbox[5] = 2;
+ wr_mbox[6] = 0x1c000;
+ wr_mbox[7] = 64;
+ wr_mbox[8] = 0;
+ wr_mbox[9] = 0;
+ WriteMbox (&wr_mbox[0], 10);
+ DSL_ENABLE_IRQ (pDev->nIrq[IFX_DFEIR]);
+ //printk("IFX_MEI_MailboxWrite ret=%d\n",i);
+ IFX_MEI_LongWordWriteOffset (&dsl_devices[0],
+ (u32) ME_ME2ARC_INT,
+ MEI_TO_ARC_MSGAV);
+ IFX_MEI_DMSG("sleeping\n");
+ while (1) {
+ if (got_int > 0) {
+
+ if (got_int > 3)
+ IFX_MEI_DMSG("got_int >>>> 3\n");
+ else
+ IFX_MEI_DMSG("got int = %d\n", got_int);
+ got_int = 0;
+ //schedule();
+ DSL_ENABLE_IRQ (pDev->nIrq[IFX_DFEIR]);
+ }
+ //mbox_read(&rd_mbox[0],6);
+ MEI_WAIT (100);
+ }
+ return 0;
+}
+
+static DSL_DEV_MeiError_t
+DFE_Loopback_Test (void)
+{
+ int i = 0;
+ u32 arc_debug_data = 0, temp;
+ DSL_DEV_Device_t *pDev = &dsl_devices[0];
+ uint32_t wr_mbox[10];
+
+ IFX_MEI_ResetARC (pDev);
+ // start the clock
+ arc_debug_data = ACL_CLK_MODE_ENABLE;
+ IFX_MEI_DebugWrite (pDev, CRI_CCR0, &arc_debug_data, 1);
+
+#if defined( DFE_PING_TEST )|| defined( DFE_ATM_LOOPBACK)
+ // WriteARCreg(AUX_XMEM_LTEST,0);
+ IFX_MEI_ControlModeSet (pDev, MEI_MASTER_MODE);
+#define AUX_XMEM_LTEST 0x128
+ _IFX_MEI_DBGLongWordWrite (pDev, MEI_DEBUG_DEC_AUX_MASK, AUX_XMEM_LTEST, 0);
+ IFX_MEI_ControlModeSet (pDev, JTAG_MASTER_MODE);
+
+ // WriteARCreg(AUX_XDMA_GAP,0);
+ IFX_MEI_ControlModeSet (pDev, MEI_MASTER_MODE);
+#define AUX_XDMA_GAP 0x114
+ _IFX_MEI_DBGLongWordWrite (pDev, MEI_DEBUG_DEC_AUX_MASK, AUX_XDMA_GAP, 0);
+ IFX_MEI_ControlModeSet (pDev, JTAG_MASTER_MODE);
+
+ IFX_MEI_ControlModeSet (pDev, MEI_MASTER_MODE);
+ temp = 0;
+ _IFX_MEI_DBGLongWordWrite (pDev, MEI_DEBUG_DEC_AUX_MASK,
+ (u32) ME_XDATA_BASE_SH + LTQ_MEI_BASE_ADDR, temp);
+ IFX_MEI_ControlModeSet (pDev, JTAG_MASTER_MODE);
+
+ i = IFX_MEI_DFEMemoryAlloc (pDev, SDRAM_SEGMENT_SIZE * 16);
+ if (i >= 0) {
+ int idx;
+
+ for (idx = 0; idx < i; idx++) {
+ DSL_DEV_PRIVATE(pDev)->adsl_mem_info[idx].type = FREE_RELOAD;
+ IFX_MEI_WRITE_REGISTER_L ((((uint32_t) DSL_DEV_PRIVATE(pDev)->adsl_mem_info[idx].address) & 0x0fffffff),
+ LTQ_MEI_BASE_ADDR + ME_XMEM_BAR_BASE + idx * 4);
+ IFX_MEI_DMSG("bar%d(%X)=%X\n", idx,
+ LTQ_MEI_BASE_ADDR + ME_XMEM_BAR_BASE +
+ idx * 4, (((uint32_t)
+ ((ifx_mei_device_private_t *)
+ pDev->pPriv)->adsl_mem_info[idx].
+ address) & 0x0fffffff));
+ memset ((u8 *) DSL_DEV_PRIVATE(pDev)->adsl_mem_info[idx].address, 0, SDRAM_SEGMENT_SIZE);
+ }
+
+ IFX_MEI_LongWordWriteOffset (pDev, (u32) ME_XDATA_BASE_SH,
+ ((unsigned long) DSL_DEV_PRIVATE(pDev)->adsl_mem_info[XDATA_REGISTER].address) & 0x0FFFFFFF);
+ }
+ else {
+ IFX_MEI_EMSG ("cannot load image: no memory\n");
+ return DSL_DEV_MEI_ERR_FAILURE;
+ }
+ //WriteARCreg(AUX_IC_CTRL,2);
+ IFX_MEI_DMSG("Setting MEI_MASTER_MODE..\n");
+ IFX_MEI_ControlModeSet (pDev, MEI_MASTER_MODE);
+#define AUX_IC_CTRL 0x11
+ _IFX_MEI_DBGLongWordWrite (pDev, MEI_DEBUG_DEC_AUX_MASK,
+ AUX_IC_CTRL, 2);
+ IFX_MEI_DMSG("Setting JTAG_MASTER_MODE..\n");
+ IFX_MEI_ControlModeSet (pDev, JTAG_MASTER_MODE);
+
+ IFX_MEI_DMSG("Halting ARC...\n");
+ IFX_MEI_HaltArc (&dsl_devices[0]);
+
+#ifdef DFE_PING_TEST
+
+ IFX_MEI_DMSG("ping test image size=%d\n", sizeof (arc_ahb_access_code));
+ memcpy ((u8 *) (DSL_DEV_PRIVATE(pDev)->
+ adsl_mem_info[0].address + 0x1004),
+ &arc_ahb_access_code[0], sizeof (arc_ahb_access_code));
+ load_jump_table (0x80000 + 0x1004);
+
+#endif //DFE_PING_TEST
+
+ IFX_MEI_DMSG("ARC ping test code download complete\n");
+#endif //defined( DFE_PING_TEST )|| defined( DFE_ATM_LOOPBACK)
+#ifdef DFE_MEM_TEST
+ IFX_MEI_LongWordWriteOffset (&dsl_devices[0], (u32) ME_ARC2ME_MASK, MSGAV_EN);
+
+ arc_code_page_download (1537, &code_array[0]);
+ IFX_MEI_DMSG("ARC mem test code download complete\n");
+#endif //DFE_MEM_TEST
+#ifdef DFE_ATM_LOOPBACK
+ arc_debug_data = 0xf;
+ arc_code_page_download (sizeof(code_array) / sizeof(*code_array), &code_array[0]);
+ wr_mbox[0] = 0; //TIMER_DELAY - org: 1024
+ wr_mbox[1] = 0; //TXFB_START0
+ wr_mbox[2] = 0x7f; //TXFB_END0 - org: 49
+ wr_mbox[3] = 0x80; //TXFB_START1 - org: 80
+ wr_mbox[4] = 0xff; //TXFB_END1 - org: 109
+ wr_mbox[5] = 0x100; //RXFB_START0 - org: 0
+ wr_mbox[6] = 0x17f; //RXFB_END0 - org: 49
+ wr_mbox[7] = 0x180; //RXFB_START1 - org: 256
+ wr_mbox[8] = 0x1ff; //RXFB_END1 - org: 315
+ WriteMbox (&wr_mbox[0], 9);
+ // Start Iridia IT_AMODE (in dmp access) why is it required?
+ IFX_MEI_DebugWrite (&dsl_devices[0], 0x32010, &arc_debug_data, 1);
+#endif //DFE_ATM_LOOPBACK
+ IFX_MEI_IRQEnable (pDev);
+ IFX_MEI_DMSG("run ARC...\n");
+ IFX_MEI_RunArc (&dsl_devices[0]);
+
+#ifdef DFE_PING_TEST
+ arc_ping_testing (pDev);
+#endif //DFE_PING_TEST
+#ifdef DFE_MEM_TEST
+ wait_mem_test_result ();
+#endif //DFE_MEM_TEST
+
+ IFX_MEI_DFEMemoryFree (pDev, FREE_ALL);
+ return DSL_DEV_MEI_ERR_SUCCESS;
+}
+
+#endif //CONFIG_AMAZON_S_MEI_FW_LOOPBACK
+
+static int
+IFX_MEI_InitDevNode (int num)
+{
+ if (num == 0) {
+ if ((dev_major = register_chrdev (dev_major, IFX_MEI_DEVNAME, &bsp_mei_operations)) < 0) {
+ IFX_MEI_EMSG ("register_chrdev(%d %s) failed!\n", dev_major, IFX_MEI_DEVNAME);
+ return -ENODEV;
+ }
+ }
+ return 0;
+}
+
+static int
+IFX_MEI_CleanUpDevNode (int num)
+{
+ if (num == 0)
+ unregister_chrdev (dev_major, MEI_DIRNAME);
+ return 0;
+}
+
+static int
+IFX_MEI_InitDevice (int num)
+{
+ DSL_DEV_Device_t *pDev;
+ u32 temp;
+ pDev = &dsl_devices[num];
+ if (pDev == NULL)
+ return -ENOMEM;
+ pDev->pPriv = &sDanube_Mei_Private[num];
+ memset (pDev->pPriv, 0, sizeof (ifx_mei_device_private_t));
+
+ memset (&DSL_DEV_PRIVATE(pDev)->
+ adsl_mem_info[0], 0,
+ sizeof (smmu_mem_info_t) * MAX_BAR_REGISTERS);
+
+ if (num == 0) {
+ pDev->nIrq[IFX_DFEIR] = LTQ_MEI_INT;
+ pDev->nIrq[IFX_DYING_GASP] = LTQ_MEI_DYING_GASP_INT;
+ pDev->base_address = KSEG1 + LTQ_MEI_BASE_ADDR;
+
+ /* Power up MEI */
+#ifdef CONFIG_LANTIQ_AMAZON_SE
+ *LTQ_PMU_PWDCR &= ~(1 << 9); // enable dsl
+ *LTQ_PMU_PWDCR &= ~(1 << 15); // enable AHB base
+#else
+ temp = ltq_r32(LTQ_PMU_PWDCR);
+ temp &= 0xffff7dbe;
+ ltq_w32(temp, LTQ_PMU_PWDCR);
+#endif
+ }
+ pDev->nInUse = 0;
+ DSL_DEV_PRIVATE(pDev)->modem_ready = 0;
+ DSL_DEV_PRIVATE(pDev)->arcmsgav = 0;
+
+ MEI_INIT_WAKELIST ("arcq", DSL_DEV_PRIVATE(pDev)->wait_queue_arcmsgav); // for ARCMSGAV
+ MEI_INIT_WAKELIST ("arcr", DSL_DEV_PRIVATE(pDev)->wait_queue_modemready); // for arc modem ready
+
+ MEI_MUTEX_INIT (DSL_DEV_PRIVATE(pDev)->mei_cmv_sema, 1); // semaphore initialization, mutex
+#if 0
+ MEI_MASK_AND_ACK_IRQ (pDev->nIrq[IFX_DFEIR]);
+ MEI_MASK_AND_ACK_IRQ (pDev->nIrq[IFX_DYING_GASP]);
+#endif
+ if (request_irq (pDev->nIrq[IFX_DFEIR], IFX_MEI_IrqHandle, 0, "DFEIR", pDev) != 0) {
+ IFX_MEI_EMSG ("request_irq %d failed!\n", pDev->nIrq[IFX_DFEIR]);
+ return -1;
+ }
+ /*if (request_irq (pDev->nIrq[IFX_DYING_GASP], IFX_MEI_Dying_Gasp_IrqHandle, 0, "DYING_GASP", pDev) != 0) {
+ IFX_MEI_EMSG ("request_irq %d failed!\n", pDev->nIrq[IFX_DYING_GASP]);
+ return -1;
+ }*/
+// IFX_MEI_DMSG("Device %d initialized. IER %#x\n", num, bsp_get_irq_ier(pDev->nIrq[IFX_DYING_GASP]));
+ return 0;
+}
+
+static int
+IFX_MEI_ExitDevice (int num)
+{
+ DSL_DEV_Device_t *pDev;
+ pDev = &dsl_devices[num];
+
+ if (pDev == NULL)
+ return -EIO;
+
+ disable_irq (pDev->nIrq[IFX_DFEIR]);
+ disable_irq (pDev->nIrq[IFX_DYING_GASP]);
+
+ free_irq(pDev->nIrq[IFX_DFEIR], pDev);
+ free_irq(pDev->nIrq[IFX_DYING_GASP], pDev);
+
+ return 0;
+}
+
+static DSL_DEV_Device_t *
+IFX_BSP_HandleGet (int maj, int num)
+{
+ if (num > BSP_MAX_DEVICES)
+ return NULL;
+ return &dsl_devices[num];
+}
+
+DSL_DEV_Device_t *
+DSL_BSP_DriverHandleGet (int maj, int num)
+{
+ DSL_DEV_Device_t *pDev;
+
+ if (num > BSP_MAX_DEVICES)
+ return NULL;
+
+ pDev = &dsl_devices[num];
+ if (!try_module_get(pDev->owner))
+ return NULL;
+
+ pDev->nInUse++;
+ return pDev;
+}
+
+int
+DSL_BSP_DriverHandleDelete (DSL_DEV_Device_t * nHandle)
+{
+ DSL_DEV_Device_t *pDev = (DSL_DEV_Device_t *) nHandle;
+ if (pDev->nInUse)
+ pDev->nInUse--;
+ module_put(pDev->owner);
+ return 0;
+}
+
+static int
+IFX_MEI_Open (DSL_DRV_inode_t * ino, DSL_DRV_file_t * fil)
+{
+ int maj = MAJOR (ino->i_rdev);
+ int num = MINOR (ino->i_rdev);
+
+ DSL_DEV_Device_t *pDev = NULL;
+ if ((pDev = DSL_BSP_DriverHandleGet (maj, num)) == NULL) {
+ IFX_MEI_EMSG("open(%d:%d) fail!\n", maj, num);
+ return -EIO;
+ }
+ fil->private_data = pDev;
+ return 0;
+}
+
+static int
+IFX_MEI_Release (DSL_DRV_inode_t * ino, DSL_DRV_file_t * fil)
+{
+ //int maj = MAJOR(ino->i_rdev);
+ int num = MINOR (ino->i_rdev);
+ DSL_DEV_Device_t *pDev;
+
+ pDev = &dsl_devices[num];
+ if (pDev == NULL)
+ return -EIO;
+ DSL_BSP_DriverHandleDelete (pDev);
+ return 0;
+}
+
+/**
+ * Callback function for linux userspace program writing
+ */
+static ssize_t
+IFX_MEI_Write (DSL_DRV_file_t * filp, const char *buf, size_t size, loff_t * loff)
+{
+ DSL_DEV_MeiError_t mei_error = DSL_DEV_MEI_ERR_FAILURE;
+ long offset = 0;
+ DSL_DEV_Device_t *pDev = (DSL_DEV_Device_t *) filp->private_data;
+
+ if (pDev == NULL)
+ return -EIO;
+
+ mei_error =
+ DSL_BSP_FWDownload (pDev, buf, size, (long *) loff, &offset);
+
+ if (mei_error == DSL_DEV_MEI_ERR_FAILURE)
+ return -EIO;
+ return (ssize_t) offset;
+}
+
+/**
+ * Callback function for linux userspace program ioctling
+ */
+static int
+IFX_MEI_IoctlCopyFrom (int from_kernel, char *dest, char *from, int size)
+{
+ int ret = 0;
+
+ if (!from_kernel)
+ ret = copy_from_user ((char *) dest, (char *) from, size);
+ else
+ ret = (int)memcpy ((char *) dest, (char *) from, size);
+ return ret;
+}
+
+static int
+IFX_MEI_IoctlCopyTo (int from_kernel, char *dest, char *from, int size)
+{
+ int ret = 0;
+
+ if (!from_kernel)
+ ret = copy_to_user ((char *) dest, (char *) from, size);
+ else
+ ret = (int)memcpy ((char *) dest, (char *) from, size);
+ return ret;
+}
+
+int
+IFX_MEI_Ioctls (DSL_DEV_Device_t * pDev, int from_kernel, unsigned int command, unsigned long lon)
+{
+ int i = 0;
+ int meierr = DSL_DEV_MEI_ERR_SUCCESS;
+ u32 base_address = LTQ_MEI_BASE_ADDR;
+ DSL_DEV_WinHost_Message_t winhost_msg, m;
+// DSL_DEV_MeiDebug_t debugrdwr;
+ DSL_DEV_MeiReg_t regrdwr;
+
+ switch (command) {
+
+ case DSL_FIO_BSP_CMV_WINHOST:
+ IFX_MEI_IoctlCopyFrom (from_kernel, (char *) winhost_msg.msg.TxMessage,
+ (char *) lon, MSG_LENGTH * 2);
+
+ if ((meierr = DSL_BSP_SendCMV (pDev, winhost_msg.msg.TxMessage, YES_REPLY,
+ winhost_msg.msg.RxMessage)) != DSL_DEV_MEI_ERR_SUCCESS) {
+ IFX_MEI_EMSG ("WINHOST CMV fail :TxMessage:%X %X %X %X, RxMessage:%X %X %X %X %X\n",
+ winhost_msg.msg.TxMessage[0], winhost_msg.msg.TxMessage[1], winhost_msg.msg.TxMessage[2], winhost_msg.msg.TxMessage[3],
+ winhost_msg.msg.RxMessage[0], winhost_msg.msg.RxMessage[1], winhost_msg.msg.RxMessage[2], winhost_msg.msg.RxMessage[3],
+ winhost_msg.msg.RxMessage[4]);
+ meierr = DSL_DEV_MEI_ERR_FAILURE;
+ }
+ else {
+ IFX_MEI_IoctlCopyTo (from_kernel, (char *) lon,
+ (char *) winhost_msg.msg.RxMessage,
+ MSG_LENGTH * 2);
+ }
+ break;
+
+ case DSL_FIO_BSP_CMV_READ:
+ IFX_MEI_IoctlCopyFrom (from_kernel, (char *) (&regrdwr),
+ (char *) lon, sizeof (DSL_DEV_MeiReg_t));
+
+ IFX_MEI_LongWordRead ((u32) regrdwr.iAddress,
+ (u32 *) & (regrdwr.iData));
+
+ IFX_MEI_IoctlCopyTo (from_kernel, (char *) lon,
+ (char *) (&regrdwr),
+ sizeof (DSL_DEV_MeiReg_t));
+
+ break;
+
+ case DSL_FIO_BSP_CMV_WRITE:
+ IFX_MEI_IoctlCopyFrom (from_kernel, (char *) (&regrdwr),
+ (char *) lon, sizeof (DSL_DEV_MeiReg_t));
+
+ IFX_MEI_LongWordWrite ((u32) regrdwr.iAddress,
+ regrdwr.iData);
+ break;
+
+ case DSL_FIO_BSP_GET_BASE_ADDRESS:
+ IFX_MEI_IoctlCopyTo (from_kernel, (char *) lon,
+ (char *) (&base_address),
+ sizeof (base_address));
+ break;
+
+ case DSL_FIO_BSP_IS_MODEM_READY:
+ i = IFX_MEI_IsModemReady (pDev);
+ IFX_MEI_IoctlCopyTo (from_kernel, (char *) lon,
+ (char *) (&i), sizeof (int));
+ meierr = DSL_DEV_MEI_ERR_SUCCESS;
+ break;
+ case DSL_FIO_BSP_RESET:
+ case DSL_FIO_BSP_REBOOT:
+ meierr = IFX_MEI_CpuModeSet (pDev, DSL_CPU_RESET);
+ meierr = IFX_MEI_CpuModeSet (pDev, DSL_CPU_HALT);
+ break;
+
+ case DSL_FIO_BSP_HALT:
+ meierr = IFX_MEI_CpuModeSet (pDev, DSL_CPU_HALT);
+ break;
+
+ case DSL_FIO_BSP_RUN:
+ meierr = IFX_MEI_CpuModeSet (pDev, DSL_CPU_RUN);
+ break;
+ case DSL_FIO_BSP_BOOTDOWNLOAD:
+ meierr = IFX_MEI_DownloadBootCode (pDev);
+ break;
+ case DSL_FIO_BSP_JTAG_ENABLE:
+ meierr = IFX_MEI_ArcJtagEnable (pDev, 1);
+ break;
+
+ case DSL_FIO_BSP_REMOTE:
+ IFX_MEI_IoctlCopyFrom (from_kernel, (char *) (&i),
+ (char *) lon, sizeof (int));
+
+ meierr = IFX_MEI_AdslMailboxIRQEnable (pDev, i);
+ break;
+
+ case DSL_FIO_BSP_DSL_START:
+ IFX_MEI_DMSG("DSL_FIO_BSP_DSL_START\n");
+ if ((meierr = IFX_MEI_RunAdslModem (pDev)) != DSL_DEV_MEI_ERR_SUCCESS) {
+ IFX_MEI_EMSG ("IFX_MEI_RunAdslModem() error...");
+ meierr = DSL_DEV_MEI_ERR_FAILURE;
+ }
+ break;
+
+/* case DSL_FIO_BSP_DEBUG_READ:
+ case DSL_FIO_BSP_DEBUG_WRITE:
+ IFX_MEI_IoctlCopyFrom (from_kernel,
+ (char *) (&debugrdwr),
+ (char *) lon,
+ sizeof (debugrdwr));
+
+ if (command == DSL_FIO_BSP_DEBUG_READ)
+ meierr = DSL_BSP_MemoryDebugAccess (pDev,
+ DSL_BSP_MEMORY_READ,
+ debugrdwr.
+ iAddress,
+ debugrdwr.
+ buffer,
+ debugrdwr.
+ iCount);
+ else
+ meierr = DSL_BSP_MemoryDebugAccess (pDev,
+ DSL_BSP_MEMORY_WRITE,
+ debugrdwr.
+ iAddress,
+ debugrdwr.
+ buffer,
+ debugrdwr.
+ iCount);
+
+ IFX_MEI_IoctlCopyTo (from_kernel, (char *) lon, (char *) (&debugrdwr), sizeof (debugrdwr));
+ break;*/
+ case DSL_FIO_BSP_GET_VERSION:
+ IFX_MEI_IoctlCopyTo (from_kernel, (char *) lon, (char *) (&bsp_mei_version), sizeof (DSL_DEV_Version_t));
+ break;
+
+#define LTQ_MPS_CHIPID_VERSION_GET(value) (((value) >> 28) & ((1 << 4) - 1))
+ case DSL_FIO_BSP_GET_CHIP_INFO:
+ bsp_chip_info.major = 1;
+ bsp_chip_info.minor = LTQ_MPS_CHIPID_VERSION_GET(*LTQ_MPS_CHIPID);
+ IFX_MEI_IoctlCopyTo (from_kernel, (char *) lon, (char *) (&bsp_chip_info), sizeof (DSL_DEV_HwVersion_t));
+ meierr = DSL_DEV_MEI_ERR_SUCCESS;
+ break;
+
+ case DSL_FIO_BSP_FREE_RESOURCE:
+ makeCMV (H2D_CMV_READ, DSL_CMV_GROUP_STAT, 4, 0, 1, NULL, m.msg.TxMessage);
+ if (DSL_BSP_SendCMV (pDev, m.msg.TxMessage, YES_REPLY, m.msg.RxMessage) != DSL_DEV_MEI_ERR_SUCCESS) {
+ meierr = DSL_DEV_MEI_ERR_FAILURE;
+ return -EIO;
+ }
+ IFX_MEI_DMSG("RxMessage[4] = %#x\n", m.msg.RxMessage[4]);
+ if (!(m.msg.RxMessage[4] & DSL_DEV_STAT_CODESWAP_COMPLETE)) {
+ meierr = DSL_DEV_MEI_ERR_FAILURE;
+ return -EAGAIN;
+ }
+ IFX_MEI_DMSG("Freeing all memories marked FREE_SHOWTIME\n");
+ IFX_MEI_DFEMemoryFree (pDev, FREE_SHOWTIME);
+ meierr = DSL_DEV_MEI_ERR_SUCCESS;
+ break;
+#ifdef CONFIG_IFXMIPS_AMAZON_SE
+ case DSL_FIO_ARC_MUX_TEST:
+ AMAZON_SE_MEI_ARC_MUX_Test();
+ break;
+#endif
+ default:
+// IFX_MEI_EMSG("Invalid IOCTL command: %d\n");
+ break;
+ }
+ return meierr;
+}
+
+#ifdef CONFIG_IFXMIPS_AMAZON_SE
+void AMAZON_SE_MEI_ARC_MUX_Test(void)
+{
+ u32 *p, i;
+ *LTQ_RCU_RST |= LTQ_RCU_RST_REQ_MUX_ARC;
+
+ p = (u32*)(DFE_LDST_BASE_ADDR + IRAM0_BASE);
+ IFX_MEI_EMSG("Writing to IRAM0(%p)...\n", p);
+ for (i = 0; i < IRAM0_SIZE/sizeof(u32); i++, p++) {
+ *p = 0xdeadbeef;
+ if (*p != 0xdeadbeef)
+ IFX_MEI_EMSG("%p: %#x\n", p, *p);
+ }
+
+ p = (u32*)(DFE_LDST_BASE_ADDR + IRAM1_BASE);
+ IFX_MEI_EMSG("Writing to IRAM1(%p)...\n", p);
+ for (i = 0; i < IRAM1_SIZE/sizeof(u32); i++, p++) {
+ *p = 0xdeadbeef;
+ if (*p != 0xdeadbeef)
+ IFX_MEI_EMSG("%p: %#x\n", p, *p);
+ }
+
+ p = (u32*)(DFE_LDST_BASE_ADDR + BRAM_BASE);
+ IFX_MEI_EMSG("Writing to BRAM(%p)...\n", p);
+ for (i = 0; i < BRAM_SIZE/sizeof(u32); i++, p++) {
+ *p = 0xdeadbeef;
+ if (*p != 0xdeadbeef)
+ IFX_MEI_EMSG("%p: %#x\n", p, *p);
+ }
+
+ p = (u32*)(DFE_LDST_BASE_ADDR + XRAM_BASE);
+ IFX_MEI_EMSG("Writing to XRAM(%p)...\n", p);
+ for (i = 0; i < XRAM_SIZE/sizeof(u32); i++, p++) {
+ *p = 0xdeadbeef;
+ if (*p != 0xdeadbeef)
+ IFX_MEI_EMSG("%p: %#x\n", p, *p);
+ }
+
+ p = (u32*)(DFE_LDST_BASE_ADDR + YRAM_BASE);
+ IFX_MEI_EMSG("Writing to YRAM(%p)...\n", p);
+ for (i = 0; i < YRAM_SIZE/sizeof(u32); i++, p++) {
+ *p = 0xdeadbeef;
+ if (*p != 0xdeadbeef)
+ IFX_MEI_EMSG("%p: %#x\n", p, *p);
+ }
+
+ p = (u32*)(DFE_LDST_BASE_ADDR + EXT_MEM_BASE);
+ IFX_MEI_EMSG("Writing to EXT_MEM(%p)...\n", p);
+ for (i = 0; i < EXT_MEM_SIZE/sizeof(u32); i++, p++) {
+ *p = 0xdeadbeef;
+ if (*p != 0xdeadbeef)
+ IFX_MEI_EMSG("%p: %#x\n", p, *p);
+ }
+ *LTQ_RCU_RST &= ~LTQ_RCU_RST_REQ_MUX_ARC;
+}
+#endif
+int
+DSL_BSP_KernelIoctls (DSL_DEV_Device_t * pDev, unsigned int command,
+ unsigned long lon)
+{
+ int error = 0;
+
+ error = IFX_MEI_Ioctls (pDev, 1, command, lon);
+ return error;
+}
+
+static long
+IFX_MEI_UserIoctls (DSL_DRV_file_t * fil,
+ unsigned int command, unsigned long lon)
+{
+ int error = 0;
+ DSL_DEV_Device_t *pDev;
+
+ pDev = IFX_BSP_HandleGet (0, 0);
+ if (pDev == NULL)
+ return -EIO;
+
+ error = IFX_MEI_Ioctls (pDev, 0, command, lon);
+ return error;
+}
+
+static int adsl_dummy_ledcallback(void)
+{
+ return 0;
+}
+
+int ifx_mei_atm_led_blink(void)
+{
+ return g_adsl_ledcallback();
+}
+EXPORT_SYMBOL(ifx_mei_atm_led_blink);
+
+int ifx_mei_atm_showtime_check(int *is_showtime, struct port_cell_info *port_cell, void **xdata_addr)
+{
+ int i;
+
+ if ( is_showtime ) {
+ *is_showtime = g_tx_link_rate[0] == 0 && g_tx_link_rate[1] == 0 ? 0 : 1;
+ }
+
+ if ( port_cell ) {
+ for ( i = 0; i < port_cell->port_num && i < 2; i++ )
+ port_cell->tx_link_rate[i] = g_tx_link_rate[i];
+ }
+
+ if ( xdata_addr ) {
+ if ( g_tx_link_rate[0] == 0 && g_tx_link_rate[1] == 0 )
+ *xdata_addr = NULL;
+ else
+ *xdata_addr = g_xdata_addr;
+ }
+
+ return 0;
+}
+EXPORT_SYMBOL(ifx_mei_atm_showtime_check);
+
+/*
+ * Writing function for linux proc filesystem
+ */
+static int ltq_mei_probe(struct platform_device *pdev)
+{
+ int i = 0;
+ static struct class *dsl_class;
+
+ pr_info("IFX MEI Version %ld.%02ld.%02ld\n", bsp_mei_version.major, bsp_mei_version.minor, bsp_mei_version.revision);
+
+ for (i = 0; i < BSP_MAX_DEVICES; i++) {
+ if (IFX_MEI_InitDevice (i) != 0) {
+ IFX_MEI_EMSG("Init device fail!\n");
+ return -EIO;
+ }
+ IFX_MEI_InitDevNode (i);
+ }
+ for (i = 0; i <= DSL_BSP_CB_LAST ; i++)
+ dsl_bsp_event_callback[i].function = NULL;
+
+#ifdef CONFIG_LTQ_MEI_FW_LOOPBACK
+ IFX_MEI_DMSG("Start loopback test...\n");
+ DFE_Loopback_Test ();
+#endif
+ dsl_class = class_create(THIS_MODULE, "ifx_mei");
+ device_create(dsl_class, NULL, MKDEV(MEI_MAJOR, 0), NULL, "ifx_mei");
+ return 0;
+}
+
+static int ltq_mei_remove(struct platform_device *pdev)
+{
+ int i = 0;
+ int num;
+
+ for (num = 0; num < BSP_MAX_DEVICES; num++) {
+ IFX_MEI_CleanUpDevNode (num);
+ }
+
+ for (i = 0; i < BSP_MAX_DEVICES; i++) {
+ for (i = 0; i < BSP_MAX_DEVICES; i++) {
+ IFX_MEI_ExitDevice (i);
+ }
+ }
+ return 0;
+}
+
+static const struct of_device_id ltq_mei_match[] = {
+ { .compatible = "lantiq,mei-xway"},
+ {},
+};
+
+static struct platform_driver ltq_mei_driver = {
+ .probe = ltq_mei_probe,
+ .remove = ltq_mei_remove,
+ .driver = {
+ .name = "lantiq,mei-xway",
+ .owner = THIS_MODULE,
+ .of_match_table = ltq_mei_match,
+ },
+};
+
+module_platform_driver(ltq_mei_driver);
+
+/* export function for DSL Driver */
+
+/* The functions of MEI_DriverHandleGet and MEI_DriverHandleDelete are
+something like open/close in kernel space , where the open could be used
+to register a callback for autonomous messages and returns a mei driver context pointer (comparable to the file descriptor in user space)
+ The context will be required for the multi line chips future! */
+
+EXPORT_SYMBOL (DSL_BSP_DriverHandleGet);
+EXPORT_SYMBOL (DSL_BSP_DriverHandleDelete);
+
+EXPORT_SYMBOL (DSL_BSP_ATMLedCBRegister);
+EXPORT_SYMBOL (DSL_BSP_ATMLedCBUnregister);
+EXPORT_SYMBOL (DSL_BSP_KernelIoctls);
+EXPORT_SYMBOL (DSL_BSP_AdslLedInit);
+//EXPORT_SYMBOL (DSL_BSP_AdslLedSet);
+EXPORT_SYMBOL (DSL_BSP_FWDownload);
+EXPORT_SYMBOL (DSL_BSP_Showtime);
+
+EXPORT_SYMBOL (DSL_BSP_MemoryDebugAccess);
+EXPORT_SYMBOL (DSL_BSP_SendCMV);
+
+// provide a register/unregister function for DSL driver to register a event callback function
+EXPORT_SYMBOL (DSL_BSP_EventCBRegister);
+EXPORT_SYMBOL (DSL_BSP_EventCBUnregister);
+
+MODULE_LICENSE("Dual BSD/GPL");
diff --git a/package/platform/lantiq/ltq-adsl/.svn/entries b/package/platform/lantiq/ltq-adsl/.svn/entries
new file mode 100644
index 0000000..e1bb431
--- /dev/null
+++ b/package/platform/lantiq/ltq-adsl/.svn/entries
@@ -0,0 +1,99 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/platform/lantiq/ltq-adsl
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-14T18:42:43.242073Z
+36016
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+patches
+dir
+
+Config.in
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+833f3682d1d35f93fd5a62b84316fa05
+2012-12-15T02:00:33.317354Z
+34693
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+146
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+4b30593a1228787514147d9bdb161c57
+2012-12-15T02:00:33.317354Z
+34693
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2854
+
diff --git a/package/platform/lantiq/ltq-adsl/.svn/text-base/Config.in.svn-base b/package/platform/lantiq/ltq-adsl/.svn/text-base/Config.in.svn-base
new file mode 100644
index 0000000..6d9caf4
--- /dev/null
+++ b/package/platform/lantiq/ltq-adsl/.svn/text-base/Config.in.svn-base
@@ -0,0 +1,5 @@
+config LANTIQ_DSL_DEBUG
+ bool "verbose debugging"
+ depends on PACKAGE_kmod-ltq-dsl
+ help
+ Say Y, if you need ltq-dsl to display debug messages.
diff --git a/package/platform/lantiq/ltq-adsl/.svn/text-base/Makefile.svn-base b/package/platform/lantiq/ltq-adsl/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..6a0daa2
--- /dev/null
+++ b/package/platform/lantiq/ltq-adsl/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,96 @@
+#
+# Copyright (C) 2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=ltq-adsl
+PKG_VERSION:=3.24.4.4
+PKG_RELEASE:=1
+PKG_SOURCE:=drv_dsl_cpe_api_danube-$(PKG_VERSION).tar.gz
+PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/ltq-dsl-$(BUILD_VARIANT)/drv_dsl_cpe_api-$(PKG_VERSION)
+PKG_SOURCE_URL:=http://mirror2.openwrt.org/sources/
+PKG_MD5SUM:=c45bc531c1ed2ac80f68fb986b63bb87
+PKG_MAINTAINER:=John Crispin <blogic@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/ltq-adsl-template
+ SECTION:=sys
+ CATEGORY:=Kernel modules
+ SUBMENU:=Network Devices
+ TITLE:=adsl driver for $(1)
+ URL:=http://www.lantiq.com/
+ VARIANT:=$(1)
+ DEPENDS:=@TARGET_lantiq_$(2) +kmod-ltq-adsl-$(1)-mei
+ FILES:=$(PKG_BUILD_DIR)/src/drv_dsl_cpe_api.ko
+ AUTOLOAD:=$(call AutoLoad,51,drv_dsl_cpe_api)
+endef
+
+KernelPackage/ltq-adsl-danube=$(call KernelPackage/ltq-adsl-template,danube,xway)
+KernelPackage/ltq-adsl-ar9=$(call KernelPackage/ltq-adsl-template,ar9,xway)
+KernelPackage/ltq-adsl-ase=$(call KernelPackage/ltq-adsl-template,ase,ase)
+
+define KernelPackage/ltq-dsl/config
+ source "$(SOURCE)/Config.in"
+endef
+
+IFX_DSL_MAX_DEVICE=1
+IFX_DSL_LINES_PER_DEVICE=1
+IFX_DSL_CHANNELS_PER_LINE=1
+
+CONFIGURE_ARGS += --enable-kernel-include="$(LINUX_DIR)/include" \
+ --with-max-device="$(IFX_DSL_MAX_DEVICE)" \
+ --with-lines-per-device="$(IFX_DSL_LINES_PER_DEVICE)" \
+ --with-channels-per-line="$(IFX_DSL_CHANNELS_PER_LINE)" \
+ --disable-dsl-delt-static \
+ --disable-adsl-led \
+ --enable-dsl-ceoc \
+ --enable-dsl-pm \
+ --enable-dsl-pm-total \
+ --enable-dsl-pm-history \
+ --enable-dsl-pm-showtime \
+ --enable-dsl-pm-channel-counters \
+ --enable-dsl-pm-datapath-counters \
+ --enable-dsl-pm-line-counters \
+ --enable-dsl-pm-channel-thresholds \
+ --enable-dsl-pm-datapath-thresholds \
+ --enable-dsl-pm-line-thresholds \
+ --enable-dsl-pm-optional-parameters \
+ --enable-linux-26 \
+ --enable-kernelbuild="$(LINUX_DIR)" \
+ ARCH=$(LINUX_KARCH)
+
+CONFIG_TAG_danube:=DANUBE
+CONFIG_TAG_ase:=AMAZON_SE
+CONFIG_TAG_ar9:=AR9
+CONFIGURE_ARGS += --enable-add-drv-cflags="-DMODULE -DCONFIG_$(CONFIG_TAG_$(BUILD_VARIANT))"
+
+CONFIGURE_ARGS += --enable-danube
+
+ifeq ($(CONFIG_LANTIQ_DSL_DEBUG),y)
+CONFIGURE_ARGS += \
+ --enable-debug=yes \
+ --enable-debug-prints=yes
+EXTRA_CFLAGS += -DDEBUG
+endif
+
+EXTRA_CFLAGS = -fno-pic -mno-abicalls -mlong-calls -G 0
+
+define Build/Configure
+ (cd $(PKG_BUILD_DIR); aclocal && autoconf && automake)
+ $(call Build/Configure/Default)
+endef
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include/adsl
+ $(CP) $(PKG_BUILD_DIR)/src/include/drv_dsl_cpe_*.h $(1)/usr/include/adsl/
+endef
+
+$(eval $(call KernelPackage,ltq-adsl-danube))
+$(eval $(call KernelPackage,ltq-adsl-ase))
+$(eval $(call KernelPackage,ltq-adsl-ar9))
diff --git a/package/platform/lantiq/ltq-adsl/Config.in b/package/platform/lantiq/ltq-adsl/Config.in
new file mode 100644
index 0000000..6d9caf4
--- /dev/null
+++ b/package/platform/lantiq/ltq-adsl/Config.in
@@ -0,0 +1,5 @@
+config LANTIQ_DSL_DEBUG
+ bool "verbose debugging"
+ depends on PACKAGE_kmod-ltq-dsl
+ help
+ Say Y, if you need ltq-dsl to display debug messages.
diff --git a/package/platform/lantiq/ltq-adsl/Makefile b/package/platform/lantiq/ltq-adsl/Makefile
new file mode 100644
index 0000000..6a0daa2
--- /dev/null
+++ b/package/platform/lantiq/ltq-adsl/Makefile
@@ -0,0 +1,96 @@
+#
+# Copyright (C) 2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=ltq-adsl
+PKG_VERSION:=3.24.4.4
+PKG_RELEASE:=1
+PKG_SOURCE:=drv_dsl_cpe_api_danube-$(PKG_VERSION).tar.gz
+PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/ltq-dsl-$(BUILD_VARIANT)/drv_dsl_cpe_api-$(PKG_VERSION)
+PKG_SOURCE_URL:=http://mirror2.openwrt.org/sources/
+PKG_MD5SUM:=c45bc531c1ed2ac80f68fb986b63bb87
+PKG_MAINTAINER:=John Crispin <blogic@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/ltq-adsl-template
+ SECTION:=sys
+ CATEGORY:=Kernel modules
+ SUBMENU:=Network Devices
+ TITLE:=adsl driver for $(1)
+ URL:=http://www.lantiq.com/
+ VARIANT:=$(1)
+ DEPENDS:=@TARGET_lantiq_$(2) +kmod-ltq-adsl-$(1)-mei
+ FILES:=$(PKG_BUILD_DIR)/src/drv_dsl_cpe_api.ko
+ AUTOLOAD:=$(call AutoLoad,51,drv_dsl_cpe_api)
+endef
+
+KernelPackage/ltq-adsl-danube=$(call KernelPackage/ltq-adsl-template,danube,xway)
+KernelPackage/ltq-adsl-ar9=$(call KernelPackage/ltq-adsl-template,ar9,xway)
+KernelPackage/ltq-adsl-ase=$(call KernelPackage/ltq-adsl-template,ase,ase)
+
+define KernelPackage/ltq-dsl/config
+ source "$(SOURCE)/Config.in"
+endef
+
+IFX_DSL_MAX_DEVICE=1
+IFX_DSL_LINES_PER_DEVICE=1
+IFX_DSL_CHANNELS_PER_LINE=1
+
+CONFIGURE_ARGS += --enable-kernel-include="$(LINUX_DIR)/include" \
+ --with-max-device="$(IFX_DSL_MAX_DEVICE)" \
+ --with-lines-per-device="$(IFX_DSL_LINES_PER_DEVICE)" \
+ --with-channels-per-line="$(IFX_DSL_CHANNELS_PER_LINE)" \
+ --disable-dsl-delt-static \
+ --disable-adsl-led \
+ --enable-dsl-ceoc \
+ --enable-dsl-pm \
+ --enable-dsl-pm-total \
+ --enable-dsl-pm-history \
+ --enable-dsl-pm-showtime \
+ --enable-dsl-pm-channel-counters \
+ --enable-dsl-pm-datapath-counters \
+ --enable-dsl-pm-line-counters \
+ --enable-dsl-pm-channel-thresholds \
+ --enable-dsl-pm-datapath-thresholds \
+ --enable-dsl-pm-line-thresholds \
+ --enable-dsl-pm-optional-parameters \
+ --enable-linux-26 \
+ --enable-kernelbuild="$(LINUX_DIR)" \
+ ARCH=$(LINUX_KARCH)
+
+CONFIG_TAG_danube:=DANUBE
+CONFIG_TAG_ase:=AMAZON_SE
+CONFIG_TAG_ar9:=AR9
+CONFIGURE_ARGS += --enable-add-drv-cflags="-DMODULE -DCONFIG_$(CONFIG_TAG_$(BUILD_VARIANT))"
+
+CONFIGURE_ARGS += --enable-danube
+
+ifeq ($(CONFIG_LANTIQ_DSL_DEBUG),y)
+CONFIGURE_ARGS += \
+ --enable-debug=yes \
+ --enable-debug-prints=yes
+EXTRA_CFLAGS += -DDEBUG
+endif
+
+EXTRA_CFLAGS = -fno-pic -mno-abicalls -mlong-calls -G 0
+
+define Build/Configure
+ (cd $(PKG_BUILD_DIR); aclocal && autoconf && automake)
+ $(call Build/Configure/Default)
+endef
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include/adsl
+ $(CP) $(PKG_BUILD_DIR)/src/include/drv_dsl_cpe_*.h $(1)/usr/include/adsl/
+endef
+
+$(eval $(call KernelPackage,ltq-adsl-danube))
+$(eval $(call KernelPackage,ltq-adsl-ase))
+$(eval $(call KernelPackage,ltq-adsl-ar9))
diff --git a/package/platform/lantiq/ltq-adsl/patches/.svn/entries b/package/platform/lantiq/ltq-adsl/patches/.svn/entries
new file mode 100644
index 0000000..63d30ac
--- /dev/null
+++ b/package/platform/lantiq/ltq-adsl/patches/.svn/entries
@@ -0,0 +1,164 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/platform/lantiq/ltq-adsl/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-14T18:42:43.242073Z
+36016
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+100-dsl_compat.patch
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+e207e53dfa474f9c0e0f19804c2db10e
+2012-12-15T02:00:33.317354Z
+34693
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+40271
+
+120-platform.patch
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+3ffb5d277fe104f2ba235d8283b26000
+2012-12-15T02:00:33.317354Z
+34693
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1977
+
+110-fix_status_polling_loop.patch
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+06a7980b1333caff7b111cc741c485ba
+2012-12-15T02:00:33.317354Z
+34693
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+439
+
+130-linux3.8.patch
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+764100ca9c78b328479c475e035e55d8
+2013-03-14T18:42:43.242073Z
+36016
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5449
+
diff --git a/package/platform/lantiq/ltq-adsl/patches/.svn/text-base/100-dsl_compat.patch.svn-base b/package/platform/lantiq/ltq-adsl/patches/.svn/text-base/100-dsl_compat.patch.svn-base
new file mode 100644
index 0000000..f2ed230
--- /dev/null
+++ b/package/platform/lantiq/ltq-adsl/patches/.svn/text-base/100-dsl_compat.patch.svn-base
@@ -0,0 +1,1065 @@
+Index: drv_dsl_cpe_api-3.24.4.4/src/include/drv_dsl_cpe_device_danube.h
+===================================================================
+--- drv_dsl_cpe_api-3.24.4.4.orig/src/include/drv_dsl_cpe_device_danube.h 2009-05-12 20:02:16.000000000 +0200
++++ drv_dsl_cpe_api-3.24.4.4/src/include/drv_dsl_cpe_device_danube.h 2012-11-29 19:47:21.060210322 +0100
+@@ -24,7 +24,7 @@
+ #include "drv_dsl_cpe_simulator_danube.h"
+ #else
+ /* Include for the low level driver interface header file */
+-#include "asm/ifx/ifx_mei_bsp.h"
++#include "ifxmips_mei_interface.h"
+ #endif /* defined(DSL_CPE_SIMULATOR_DRIVER) && defined(WIN32)*/
+
+ #define DSL_MAX_LINE_NUMBER 1
+Index: drv_dsl_cpe_api-3.24.4.4/src/common/drv_dsl_cpe_os_linux.c
+===================================================================
+--- drv_dsl_cpe_api-3.24.4.4.orig/src/common/drv_dsl_cpe_os_linux.c 2009-07-13 11:33:43.000000000 +0200
++++ drv_dsl_cpe_api-3.24.4.4/src/common/drv_dsl_cpe_os_linux.c 2012-11-29 19:46:32.700209112 +0100
+@@ -11,6 +11,7 @@
+ #ifdef __LINUX__
+
+ #define DSL_INTERN
++#include <linux/device.h>
+
+ #include "drv_dsl_cpe_api.h"
+ #include "drv_dsl_cpe_api_ioctl.h"
+@@ -34,9 +35,13 @@
+ static DSL_ssize_t DSL_DRV_Write(DSL_DRV_file_t *pFile, const DSL_char_t * pBuf,
+ DSL_DRV_size_t nSize, DSL_DRV_offset_t * pLoff);
+
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36))
+ static DSL_int_t DSL_DRV_Ioctls(DSL_DRV_inode_t * pINode, DSL_DRV_file_t * pFile,
+ DSL_uint_t nCommand, unsigned long nArg);
+-
++#else
++static DSL_int_t DSL_DRV_Ioctls(DSL_DRV_file_t * pFile,
++ DSL_uint_t nCommand, unsigned long nArg);
++#endif
+ static int DSL_DRV_Open(DSL_DRV_inode_t * ino, DSL_DRV_file_t * fil);
+
+ static int DSL_DRV_Release(DSL_DRV_inode_t * ino, DSL_DRV_file_t * fil);
+@@ -72,7 +77,11 @@
+ open: DSL_DRV_Open,
+ release: DSL_DRV_Release,
+ write: DSL_DRV_Write,
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36))
+ ioctl: DSL_DRV_Ioctls,
++#else
++ unlocked_ioctl: DSL_DRV_Ioctls,
++#endif
+ poll: DSL_DRV_Poll
+ };
+ #else
+@@ -168,10 +177,17 @@
+ \return Success or failure.
+ \ingroup Internal
+ */
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36))
+ static DSL_int_t DSL_DRV_Ioctls(DSL_DRV_inode_t * pINode,
+ DSL_DRV_file_t * pFile,
+ DSL_uint_t nCommand,
+ unsigned long nArg)
++#else
++static DSL_int_t DSL_DRV_Ioctls(
++ DSL_DRV_file_t * pFile,
++ DSL_uint_t nCommand,
++ unsigned long nArg)
++#endif
+ {
+ DSL_int_t nErr=0;
+ DSL_boolean_t bIsInKernel;
+@@ -216,16 +232,7 @@
+ }
+ }
+ }
+-
+- if (pINode == DSL_NULL)
+- {
+- bIsInKernel = DSL_TRUE;
+- }
+- else
+- {
+- bIsInKernel = DSL_FALSE;
+- }
+-
++ bIsInKernel = DSL_FALSE;
+ if ( (_IOC_TYPE(nCommand) == DSL_IOC_MAGIC_CPE_API) ||
+ (_IOC_TYPE(nCommand) == DSL_IOC_MAGIC_CPE_API_G997) ||
+ (_IOC_TYPE(nCommand) == DSL_IOC_MAGIC_CPE_API_PM) ||
+@@ -1058,6 +1065,7 @@
+ /* Entry point of driver */
+ int __init DSL_ModuleInit(void)
+ {
++ struct class *dsl_class;
+ DSL_int_t i;
+
+ printk(DSL_DRV_CRLF DSL_DRV_CRLF "Infineon CPE API Driver version: %s" DSL_DRV_CRLF,
+@@ -1104,7 +1112,8 @@
+ }
+
+ DSL_DRV_DevNodeInit();
+-
++ dsl_class = class_create(THIS_MODULE, "dsl_cpe_api");
++ device_create(dsl_class, NULL, MKDEV(DRV_DSL_CPE_API_DEV_MAJOR, 0), NULL, "dsl_cpe_api");
+ return 0;
+ }
+
+Index: drv_dsl_cpe_api-3.24.4.4/src/include/drv_dsl_cpe_os_linux.h
+===================================================================
+--- drv_dsl_cpe_api-3.24.4.4.orig/src/include/drv_dsl_cpe_os_linux.h 2009-07-03 17:04:51.000000000 +0200
++++ drv_dsl_cpe_api-3.24.4.4/src/include/drv_dsl_cpe_os_linux.h 2012-11-29 19:47:23.092210377 +0100
+@@ -17,17 +17,17 @@
+ #endif
+
+ #include <asm/ioctl.h>
+-#include <linux/autoconf.h>
++#include <generated/autoconf.h>
+ #include <linux/module.h>
+ #include <linux/kernel.h>
+ #include <linux/init.h>
+ #include <linux/ctype.h>
+ #include <linux/version.h>
+ #include <linux/spinlock.h>
+-
++#include <linux/sched.h>
+
+ #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17))
+- #include <linux/utsrelease.h>
++ #include <generated/utsrelease.h>
+ #endif
+
+ #include <linux/types.h>
+Index: drv_dsl_cpe_api-3.24.4.4/src/ifxmips_mei_interface.h
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ drv_dsl_cpe_api-3.24.4.4/src/ifxmips_mei_interface.h 2012-11-29 19:47:54.972211177 +0100
+@@ -0,0 +1,702 @@
++/******************************************************************************
++
++ Copyright (c) 2009
++ Infineon Technologies AG
++ Am Campeon 1-12; 81726 Munich, Germany
++
++ For licensing information, see the file 'LICENSE' in the root folder of
++ this software module.
++
++******************************************************************************/
++
++#ifndef IFXMIPS_MEI_H
++#define IFXMIPS_MEI_H
++
++//#define CONFIG_AMAZON_SE 1
++//#define CONFIG_DANUBE 1
++//#define CONFIG_AR9 1
++
++#if !defined(CONFIG_DANUBE) && !defined(CONFIG_AMAZON_SE) && !defined(CONFIG_AR9) && !defined(CONFIG_VR9)
++#error Platform undefined!!!
++#endif
++
++#ifdef IFX_MEI_BSP
++/** This is the character datatype. */
++typedef char DSL_char_t;
++/** This is the unsigned 8-bit datatype. */
++typedef unsigned char DSL_uint8_t;
++/** This is the signed 8-bit datatype. */
++typedef signed char DSL_int8_t;
++/** This is the unsigned 16-bit datatype. */
++typedef unsigned short DSL_uint16_t;
++/** This is the signed 16-bit datatype. */
++typedef signed short DSL_int16_t;
++/** This is the unsigned 32-bit datatype. */
++typedef unsigned long DSL_uint32_t;
++/** This is the signed 32-bit datatype. */
++typedef signed long DSL_int32_t;
++/** This is the float datatype. */
++typedef float DSL_float_t;
++/** This is the void datatype. */
++typedef void DSL_void_t;
++/** integer type, width is depending on processor arch */
++typedef int DSL_int_t;
++/** unsigned integer type, width is depending on processor arch */
++typedef unsigned int DSL_uint_t;
++typedef struct file DSL_DRV_file_t;
++typedef struct inode DSL_DRV_inode_t;
++
++/**
++ * Defines all possible CMV groups
++ * */
++typedef enum {
++ DSL_CMV_GROUP_CNTL = 1,
++ DSL_CMV_GROUP_STAT = 2,
++ DSL_CMV_GROUP_INFO = 3,
++ DSL_CMV_GROUP_TEST = 4,
++ DSL_CMV_GROUP_OPTN = 5,
++ DSL_CMV_GROUP_RATE = 6,
++ DSL_CMV_GROUP_PLAM = 7,
++ DSL_CMV_GROUP_CNFG = 8
++} DSL_CmvGroup_t;
++/**
++ * Defines all opcode types
++ * */
++typedef enum {
++ H2D_CMV_READ = 0x00,
++ H2D_CMV_WRITE = 0x04,
++ H2D_CMV_INDICATE_REPLY = 0x10,
++ H2D_ERROR_OPCODE_UNKNOWN =0x20,
++ H2D_ERROR_CMV_UNKNOWN =0x30,
++
++ D2H_CMV_READ_REPLY =0x01,
++ D2H_CMV_WRITE_REPLY = 0x05,
++ D2H_CMV_INDICATE = 0x11,
++ D2H_ERROR_OPCODE_UNKNOWN = 0x21,
++ D2H_ERROR_CMV_UNKNOWN = 0x31,
++ D2H_ERROR_CMV_READ_NOT_AVAILABLE = 0x41,
++ D2H_ERROR_CMV_WRITE_ONLY = 0x51,
++ D2H_ERROR_CMV_READ_ONLY = 0x61,
++
++ H2D_DEBUG_READ_DM = 0x02,
++ H2D_DEBUG_READ_PM = 0x06,
++ H2D_DEBUG_WRITE_DM = 0x0a,
++ H2D_DEBUG_WRITE_PM = 0x0e,
++
++ D2H_DEBUG_READ_DM_REPLY = 0x03,
++ D2H_DEBUG_READ_FM_REPLY = 0x07,
++ D2H_DEBUG_WRITE_DM_REPLY = 0x0b,
++ D2H_DEBUG_WRITE_FM_REPLY = 0x0f,
++ D2H_ERROR_ADDR_UNKNOWN = 0x33,
++
++ D2H_AUTONOMOUS_MODEM_READY_MSG = 0xf1
++} DSL_CmvOpcode_t;
++
++/* mutex macros */
++#define MEI_MUTEX_INIT(id,flag) \
++ sema_init(&id,flag)
++#define MEI_MUTEX_LOCK(id) \
++ down_interruptible(&id)
++#define MEI_MUTEX_UNLOCK(id) \
++ up(&id)
++#define MEI_WAIT(ms) \
++ {\
++ set_current_state(TASK_INTERRUPTIBLE);\
++ schedule_timeout(ms);\
++ }
++#define MEI_INIT_WAKELIST(name,queue) \
++ init_waitqueue_head(&queue)
++
++/* wait for an event, timeout is measured in ms */
++#define MEI_WAIT_EVENT_TIMEOUT(ev,timeout)\
++ interruptible_sleep_on_timeout(&ev,timeout * HZ / 1000)
++#define MEI_WAKEUP_EVENT(ev)\
++ wake_up_interruptible(&ev)
++#endif /* IFX_MEI_BSP */
++
++/*** Register address offsets, relative to MEI_SPACE_ADDRESS ***/
++#define ME_DX_DATA (0x0000)
++#define ME_VERSION (0x0004)
++#define ME_ARC_GP_STAT (0x0008)
++#define ME_DX_STAT (0x000C)
++#define ME_DX_AD (0x0010)
++#define ME_DX_MWS (0x0014)
++#define ME_ME2ARC_INT (0x0018)
++#define ME_ARC2ME_STAT (0x001C)
++#define ME_ARC2ME_MASK (0x0020)
++#define ME_DBG_WR_AD (0x0024)
++#define ME_DBG_RD_AD (0x0028)
++#define ME_DBG_DATA (0x002C)
++#define ME_DBG_DECODE (0x0030)
++#define ME_CONFIG (0x0034)
++#define ME_RST_CTRL (0x0038)
++#define ME_DBG_MASTER (0x003C)
++#define ME_CLK_CTRL (0x0040)
++#define ME_BIST_CTRL (0x0044)
++#define ME_BIST_STAT (0x0048)
++#define ME_XDATA_BASE_SH (0x004c)
++#define ME_XDATA_BASE (0x0050)
++#define ME_XMEM_BAR_BASE (0x0054)
++#define ME_XMEM_BAR0 (0x0054)
++#define ME_XMEM_BAR1 (0x0058)
++#define ME_XMEM_BAR2 (0x005C)
++#define ME_XMEM_BAR3 (0x0060)
++#define ME_XMEM_BAR4 (0x0064)
++#define ME_XMEM_BAR5 (0x0068)
++#define ME_XMEM_BAR6 (0x006C)
++#define ME_XMEM_BAR7 (0x0070)
++#define ME_XMEM_BAR8 (0x0074)
++#define ME_XMEM_BAR9 (0x0078)
++#define ME_XMEM_BAR10 (0x007C)
++#define ME_XMEM_BAR11 (0x0080)
++#define ME_XMEM_BAR12 (0x0084)
++#define ME_XMEM_BAR13 (0x0088)
++#define ME_XMEM_BAR14 (0x008C)
++#define ME_XMEM_BAR15 (0x0090)
++#define ME_XMEM_BAR16 (0x0094)
++
++#define WHILE_DELAY 20000
++/*
++** Define where in ME Processor's memory map the Stratify chip lives
++*/
++
++#define MAXSWAPSIZE (8 * 1024) //8k *(32bits)
++
++// Mailboxes
++#define MSG_LENGTH 16 // x16 bits
++#define YES_REPLY 1
++#define NO_REPLY 0
++
++#define CMV_TIMEOUT 1000 //jiffies
++
++// Block size per BAR
++#define SDRAM_SEGMENT_SIZE (64*1024)
++// Number of Bar registers
++#define MAX_BAR_REGISTERS (17)
++
++#define XDATA_REGISTER (15)
++
++// ARC register addresss
++#define ARC_STATUS 0x0
++#define ARC_LP_START 0x2
++#define ARC_LP_END 0x3
++#define ARC_DEBUG 0x5
++#define ARC_INT_MASK 0x10A
++
++#define IRAM0_BASE (0x00000)
++#define IRAM1_BASE (0x04000)
++#if defined(CONFIG_DANUBE)
++#define BRAM_BASE (0x0A000)
++#elif defined(CONFIG_AMAZON_SE) || defined(CONFIG_AR9) || defined(CONFIG_VR9)
++#define BRAM_BASE (0x08000)
++#endif
++#define XRAM_BASE (0x18000)
++#define YRAM_BASE (0x1A000)
++#define EXT_MEM_BASE (0x80000)
++#define ARC_GPIO_CTRL (0xC030)
++#define ARC_GPIO_DATA (0xC034)
++
++#define IRAM0_SIZE (16*1024)
++#define IRAM1_SIZE (16*1024)
++#define BRAM_SIZE (12*1024)
++#define XRAM_SIZE (8*1024)
++#define YRAM_SIZE (8*1024)
++#define EXT_MEM_SIZE (1536*1024)
++
++#define ADSL_BASE (0x20000)
++#define CRI_BASE (ADSL_BASE + 0x11F00)
++#define CRI_CCR0 (CRI_BASE + 0x00)
++#define CRI_RST (CRI_BASE + 0x04*4)
++#define ADSL_DILV_BASE (ADSL_BASE+0x20000)
++
++//
++#define IRAM0_ADDR_BIT_MASK 0xFFF
++#define IRAM1_ADDR_BIT_MASK 0xFFF
++#define BRAM_ADDR_BIT_MASK 0xFFF
++#define RX_DILV_ADDR_BIT_MASK 0x1FFF
++
++/*** Bit definitions ***/
++#define ARC_AUX_HALT (1 << 25)
++#define ARC_DEBUG_HALT (1 << 1)
++#define FALSE 0
++#define TRUE 1
++#define BIT0 (1<<0)
++#define BIT1 (1<<1)
++#define BIT2 (1<<2)
++#define BIT3 (1<<3)
++#define BIT4 (1<<4)
++#define BIT5 (1<<5)
++#define BIT6 (1<<6)
++#define BIT7 (1<<7)
++#define BIT8 (1<<8)
++#define BIT9 (1<<9)
++#define BIT10 (1<<10)
++#define BIT11 (1<<11)
++#define BIT12 (1<<12)
++#define BIT13 (1<<13)
++#define BIT14 (1<<14)
++#define BIT15 (1<<15)
++#define BIT16 (1<<16)
++#define BIT17 (1<<17)
++#define BIT18 (1<<18)
++#define BIT19 (1<<19)
++#define BIT20 (1<<20)
++#define BIT21 (1<<21)
++#define BIT22 (1<<22)
++#define BIT23 (1<<23)
++#define BIT24 (1<<24)
++#define BIT25 (1<<25)
++#define BIT26 (1<<26)
++#define BIT27 (1<<27)
++#define BIT28 (1<<28)
++#define BIT29 (1<<29)
++#define BIT30 (1<<30)
++#define BIT31 (1<<31)
++
++// CRI_CCR0 Register definitions
++#define CLK_2M_MODE_ENABLE BIT6
++#define ACL_CLK_MODE_ENABLE BIT4
++#define FDF_CLK_MODE_ENABLE BIT2
++#define STM_CLK_MODE_ENABLE BIT0
++
++// CRI_RST Register definitions
++#define FDF_SRST BIT3
++#define MTE_SRST BIT2
++#define FCI_SRST BIT1
++#define AAI_SRST BIT0
++
++// MEI_TO_ARC_INTERRUPT Register definitions
++#define MEI_TO_ARC_INT1 BIT3
++#define MEI_TO_ARC_INT0 BIT2
++#define MEI_TO_ARC_CS_DONE BIT1 //need to check
++#define MEI_TO_ARC_MSGAV BIT0
++
++// ARC_TO_MEI_INTERRUPT Register definitions
++#define ARC_TO_MEI_INT1 BIT8
++#define ARC_TO_MEI_INT0 BIT7
++#define ARC_TO_MEI_CS_REQ BIT6
++#define ARC_TO_MEI_DBG_DONE BIT5
++#define ARC_TO_MEI_MSGACK BIT4
++#define ARC_TO_MEI_NO_ACCESS BIT3
++#define ARC_TO_MEI_CHECK_AAITX BIT2
++#define ARC_TO_MEI_CHECK_AAIRX BIT1
++#define ARC_TO_MEI_MSGAV BIT0
++
++// ARC_TO_MEI_INTERRUPT_MASK Register definitions
++#define GP_INT1_EN BIT8
++#define GP_INT0_EN BIT7
++#define CS_REQ_EN BIT6
++#define DBG_DONE_EN BIT5
++#define MSGACK_EN BIT4
++#define NO_ACC_EN BIT3
++#define AAITX_EN BIT2
++#define AAIRX_EN BIT1
++#define MSGAV_EN BIT0
++
++#define MEI_SOFT_RESET BIT0
++
++#define HOST_MSTR BIT0
++
++#define JTAG_MASTER_MODE 0x0
++#define MEI_MASTER_MODE HOST_MSTR
++
++// MEI_DEBUG_DECODE Register definitions
++#define MEI_DEBUG_DEC_MASK (0x3)
++#define MEI_DEBUG_DEC_AUX_MASK (0x0)
++#define ME_DBG_DECODE_DMP1_MASK (0x1)
++#define MEI_DEBUG_DEC_DMP2_MASK (0x2)
++#define MEI_DEBUG_DEC_CORE_MASK (0x3)
++
++#define AUX_STATUS (0x0)
++#define AUX_ARC_GPIO_CTRL (0x10C)
++#define AUX_ARC_GPIO_DATA (0x10D)
++// ARC_TO_MEI_MAILBOX[11] is a special location used to indicate
++// page swap requests.
++#if defined(CONFIG_DANUBE)
++#define OMBOX_BASE 0xDF80
++#define ARC_TO_MEI_MAILBOX 0xDFA0
++#define IMBOX_BASE 0xDFC0
++#define MEI_TO_ARC_MAILBOX 0xDFD0
++#elif defined(CONFIG_AMAZON_SE) || defined(CONFIG_AR9) || defined(CONFIG_VR9)
++#define OMBOX_BASE 0xAF80
++#define ARC_TO_MEI_MAILBOX 0xAFA0
++#define IMBOX_BASE 0xAFC0
++#define MEI_TO_ARC_MAILBOX 0xAFD0
++#endif
++
++#define MEI_TO_ARC_MAILBOXR (MEI_TO_ARC_MAILBOX + 0x2C)
++#define ARC_MEI_MAILBOXR (ARC_TO_MEI_MAILBOX + 0x2C)
++#define OMBOX1 (OMBOX_BASE+0x4)
++
++// Codeswap request messages are indicated by setting BIT31
++#define OMB_CODESWAP_MESSAGE_MSG_TYPE_MASK (0x80000000)
++
++// Clear Eoc messages received are indicated by setting BIT17
++#define OMB_CLEAREOC_INTERRUPT_CODE (0x00020000)
++#define OMB_REBOOT_INTERRUPT_CODE (1 << 18)
++
++/*
++** Swap page header
++*/
++// Page must be loaded at boot time if size field has BIT31 set
++#define BOOT_FLAG (BIT31)
++#define BOOT_FLAG_MASK ~BOOT_FLAG
++
++#define FREE_RELOAD 1
++#define FREE_SHOWTIME 2
++#define FREE_ALL 3
++
++// marcos
++#define IFX_MEI_WRITE_REGISTER_L(data,addr) *((volatile u32*)(addr)) = (u32)(data)
++#define IFX_MEI_READ_REGISTER_L(addr) (*((volatile u32*)(addr)))
++#define SET_BIT(reg, mask) reg |= (mask)
++#define CLEAR_BIT(reg, mask) reg &= (~mask)
++#define CLEAR_BITS(reg, mask) CLEAR_BIT(reg, mask)
++//#define SET_BITS(reg, mask) SET_BIT(reg, mask)
++#define SET_BITFIELD(reg, mask, off, val) {reg &= (~mask); reg |= (val << off);}
++
++#define ALIGN_SIZE ( 1L<<10 ) //1K size align
++#define MEM_ALIGN(addr) (((addr) + ALIGN_SIZE - 1) & ~ (ALIGN_SIZE -1) )
++
++// swap marco
++#define MEI_HALF_WORD_SWAP(data) {data = ((data & 0xffff)<<16) + ((data & 0xffff0000)>>16);}
++#define MEI_BYTE_SWAP(data) {data = ((data & 0xff)<<24) + ((data & 0xff00)<<8)+ ((data & 0xff0000)>>8)+ ((data & 0xff000000)>>24);}
++
++
++#ifdef CONFIG_PROC_FS
++typedef struct reg_entry
++{
++ int *flag;
++ char name[30]; /* big enough to hold names */
++ char description[100]; /* big enough to hold description */
++ unsigned short low_ino;
++} reg_entry_t;
++#endif
++// Swap page header describes size in 32-bit words, load location, and image offset
++// for program and/or data segments
++typedef struct _arc_swp_page_hdr {
++ u32 p_offset; //Offset bytes of progseg from beginning of image
++ u32 p_dest; //Destination addr of progseg on processor
++ u32 p_size; //Size in 32-bitwords of program segment
++ u32 d_offset; //Offset bytes of dataseg from beginning of image
++ u32 d_dest; //Destination addr of dataseg on processor
++ u32 d_size; //Size in 32-bitwords of data segment
++} ARC_SWP_PAGE_HDR;
++
++/*
++** Swap image header
++*/
++#define GET_PROG 0 // Flag used for program mem segment
++#define GET_DATA 1 // Flag used for data mem segment
++
++// Image header contains size of image, checksum for image, and count of
++// page headers. Following that are 'count' page headers followed by
++// the code and/or data segments to be loaded
++typedef struct _arc_img_hdr {
++ u32 size; // Size of binary image in bytes
++ u32 checksum; // Checksum for image
++ u32 count; // Count of swp pages in image
++ ARC_SWP_PAGE_HDR page[1]; // Should be "count" pages - '1' to make compiler happy
++} ARC_IMG_HDR;
++
++typedef struct smmu_mem_info {
++ int type;
++ int boot;
++ unsigned long nCopy;
++ unsigned long size;
++ unsigned char *address;
++ unsigned char *org_address;
++} smmu_mem_info_t;
++
++#ifdef __KERNEL__
++typedef struct ifx_mei_device_private {
++ int modem_ready;
++ int arcmsgav;
++ int cmv_reply;
++ int cmv_waiting;
++ // Mei to ARC CMV count, reply count, ARC Indicator count
++ int modem_ready_cnt;
++ int cmv_count;
++ int reply_count;
++ unsigned long image_size;
++ int nBar;
++ u16 Recent_indicator[MSG_LENGTH];
++
++ u16 CMV_RxMsg[MSG_LENGTH] __attribute__ ((aligned (4)));
++
++ smmu_mem_info_t adsl_mem_info[MAX_BAR_REGISTERS];
++ ARC_IMG_HDR *img_hdr;
++ // to wait for arc cmv reply, sleep on wait_queue_arcmsgav;
++ wait_queue_head_t wait_queue_arcmsgav;
++ wait_queue_head_t wait_queue_modemready;
++ struct semaphore mei_cmv_sema;
++} ifx_mei_device_private_t;
++#endif
++typedef struct winhost_message {
++ union {
++ u16 RxMessage[MSG_LENGTH] __attribute__ ((aligned (4)));
++ u16 TxMessage[MSG_LENGTH] __attribute__ ((aligned (4)));
++ } msg;
++} DSL_DEV_WinHost_Message_t;
++/********************************************************************************************************
++ * DSL CPE API Driver Stack Interface Definitions
++ * *****************************************************************************************************/
++/** IOCTL codes for bsp driver */
++#define DSL_IOC_MEI_BSP_MAGIC 's'
++
++#define DSL_FIO_BSP_DSL_START _IO (DSL_IOC_MEI_BSP_MAGIC, 0)
++#define DSL_FIO_BSP_RUN _IO (DSL_IOC_MEI_BSP_MAGIC, 1)
++#define DSL_FIO_BSP_FREE_RESOURCE _IO (DSL_IOC_MEI_BSP_MAGIC, 2)
++#define DSL_FIO_BSP_RESET _IO (DSL_IOC_MEI_BSP_MAGIC, 3)
++#define DSL_FIO_BSP_REBOOT _IO (DSL_IOC_MEI_BSP_MAGIC, 4)
++#define DSL_FIO_BSP_HALT _IO (DSL_IOC_MEI_BSP_MAGIC, 5)
++#define DSL_FIO_BSP_BOOTDOWNLOAD _IO (DSL_IOC_MEI_BSP_MAGIC, 6)
++#define DSL_FIO_BSP_JTAG_ENABLE _IO (DSL_IOC_MEI_BSP_MAGIC, 7)
++#define DSL_FIO_FREE_RESOURCE _IO (DSL_IOC_MEI_BSP_MAGIC, 8)
++#define DSL_FIO_ARC_MUX_TEST _IO (DSL_IOC_MEI_BSP_MAGIC, 9)
++#define DSL_FIO_BSP_REMOTE _IOW (DSL_IOC_MEI_BSP_MAGIC, 10, u32)
++#define DSL_FIO_BSP_GET_BASE_ADDRESS _IOR (DSL_IOC_MEI_BSP_MAGIC, 11, u32)
++#define DSL_FIO_BSP_IS_MODEM_READY _IOR (DSL_IOC_MEI_BSP_MAGIC, 12, u32)
++#define DSL_FIO_BSP_GET_VERSION _IOR (DSL_IOC_MEI_BSP_MAGIC, 13, DSL_DEV_Version_t)
++#define DSL_FIO_BSP_CMV_WINHOST _IOWR(DSL_IOC_MEI_BSP_MAGIC, 14, DSL_DEV_WinHost_Message_t)
++#define DSL_FIO_BSP_CMV_READ _IOWR(DSL_IOC_MEI_BSP_MAGIC, 15, DSL_DEV_MeiReg_t)
++#define DSL_FIO_BSP_CMV_WRITE _IOW (DSL_IOC_MEI_BSP_MAGIC, 16, DSL_DEV_MeiReg_t)
++#define DSL_FIO_BSP_DEBUG_READ _IOWR(DSL_IOC_MEI_BSP_MAGIC, 17, DSL_DEV_MeiDebug_t)
++#define DSL_FIO_BSP_DEBUG_WRITE _IOWR(DSL_IOC_MEI_BSP_MAGIC, 18, DSL_DEV_MeiDebug_t)
++#define DSL_FIO_BSP_GET_CHIP_INFO _IOR (DSL_IOC_MEI_BSP_MAGIC, 19, DSL_DEV_HwVersion_t)
++
++#define DSL_DEV_MEIDEBUG_BUFFER_SIZES 512
++
++typedef struct DSL_DEV_MeiDebug
++{
++ DSL_uint32_t iAddress;
++ DSL_uint32_t iCount;
++ DSL_uint32_t buffer[DSL_DEV_MEIDEBUG_BUFFER_SIZES];
++} DSL_DEV_MeiDebug_t; /* meidebug */
++
++/**
++ * Structure is used for debug access only.
++ * Refer to configure option INCLUDE_ADSL_WINHOST_DEBUG */
++typedef struct struct_meireg
++{
++ /*
++ * Specifies that address for debug access */
++ unsigned long iAddress;
++ /*
++ * Specifies the pointer to the data that has to be written or returns a
++ * pointer to the data that has been read out*/
++ unsigned long iData;
++} DSL_DEV_MeiReg_t; /* meireg */
++
++typedef struct DSL_DEV_Device
++{
++ DSL_int_t nInUse; /* modem state, update by bsp driver, */
++ DSL_void_t *pPriv;
++ DSL_uint32_t base_address; /* mei base address */
++ DSL_int_t nIrq[2]; /* irq number */
++#define IFX_DFEIR 0
++#define IFX_DYING_GASP 1
++ DSL_DEV_MeiDebug_t lop_debugwr; /* dying gasp */
++#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,0))
++ struct module *owner;
++#endif
++} DSL_DEV_Device_t; /* ifx_adsl_device_t */
++
++#define DSL_DEV_PRIVATE(dev) ((ifx_mei_device_private_t*)(dev->pPriv))
++
++typedef struct DSL_DEV_Version /* ifx_adsl_bsp_version */
++{
++ unsigned long major;
++ unsigned long minor;
++ unsigned long revision;
++} DSL_DEV_Version_t; /* ifx_adsl_bsp_version_t */
++
++typedef struct DSL_DEV_ChipInfo
++{
++ unsigned long major;
++ unsigned long minor;
++} DSL_DEV_HwVersion_t;
++
++typedef struct
++{
++ DSL_uint8_t dummy;
++} DSL_DEV_DeviceConfig_t;
++
++/** error code definitions */
++typedef enum DSL_DEV_MeiError
++{
++ DSL_DEV_MEI_ERR_SUCCESS = 0,
++ DSL_DEV_MEI_ERR_FAILURE = -1,
++ DSL_DEV_MEI_ERR_MAILBOX_FULL = -2,
++ DSL_DEV_MEI_ERR_MAILBOX_EMPTY = -3,
++ DSL_DEV_MEI_ERR_MAILBOX_TIMEOUT = -4
++} DSL_DEV_MeiError_t; /* MEI_ERROR */
++
++typedef enum {
++ DSL_BSP_MEMORY_READ=0,
++ DSL_BSP_MEMORY_WRITE,
++} DSL_BSP_MemoryAccessType_t; /* ifx_adsl_memory_access_type_t */
++
++typedef enum
++{
++ DSL_LED_LINK_ID=0,
++ DSL_LED_DATA_ID
++} DSL_DEV_LedId_t; /* ifx_adsl_led_id_t */
++
++typedef enum
++{
++ DSL_LED_LINK_TYPE=0,
++ DSL_LED_DATA_TYPE
++} DSL_DEV_LedType_t; /* ifx_adsl_led_type_t */
++
++typedef enum
++{
++ DSL_LED_HD_CPU=0,
++ DSL_LED_HD_FW
++} DSL_DEV_LedHandler_t; /* ifx_adsl_led_handler_t */
++
++typedef enum {
++ DSL_LED_ON=0,
++ DSL_LED_OFF,
++ DSL_LED_FLASH,
++} DSL_DEV_LedMode_t; /* ifx_adsl_led_mode_t */
++
++typedef enum {
++ DSL_CPU_HALT=0,
++ DSL_CPU_RUN,
++ DSL_CPU_RESET,
++} DSL_DEV_CpuMode_t; /* ifx_adsl_cpu_mode_t */
++
++#if 0
++typedef enum {
++ DSL_BSP_EVENT_DYING_GASP = 0,
++ DSL_BSP_EVENT_CEOC_IRQ,
++} DSL_BSP_Event_id_t; /* ifx_adsl_event_id_t */
++
++typedef union DSL_BSP_CB_Param
++{
++ DSL_uint32_t nIrqMessage;
++} DSL_BSP_CB_Param_t; /* ifx_adsl_cbparam_t */
++
++typedef struct DSL_BSP_CB_Event
++{
++ DSL_BSP_Event_id_t nID;
++ DSL_DEV_Device_t *pDev;
++ DSL_BSP_CB_Param_t *pParam;
++} DSL_BSP_CB_Event_t; /* ifx_adsl_cb_event_t */
++#endif
++
++/* external functions (from the BSP Driver) */
++extern DSL_DEV_Device_t* DSL_BSP_DriverHandleGet(int, int);
++extern DSL_int_t DSL_BSP_DriverHandleDelete(DSL_DEV_Device_t *);
++extern DSL_DEV_MeiError_t DSL_BSP_FWDownload(DSL_DEV_Device_t *, const DSL_char_t *, DSL_uint32_t, DSL_int32_t *, DSL_int32_t *);
++extern int DSL_BSP_KernelIoctls(DSL_DEV_Device_t *, unsigned int, unsigned long);
++extern DSL_DEV_MeiError_t DSL_BSP_SendCMV(DSL_DEV_Device_t *, DSL_uint16_t *, DSL_int_t, DSL_uint16_t *);
++extern DSL_DEV_MeiError_t DSL_BSP_AdslLedInit(DSL_DEV_Device_t *, DSL_DEV_LedId_t, DSL_DEV_LedType_t, DSL_DEV_LedHandler_t);
++extern DSL_DEV_MeiError_t DSL_BSP_Showtime(DSL_DEV_Device_t *, DSL_uint32_t, DSL_uint32_t);
++extern int DSL_BSP_ATMLedCBRegister( int (*ifx_adsl_ledcallback)(void));
++extern DSL_DEV_MeiError_t DSL_BSP_MemoryDebugAccess(DSL_DEV_Device_t *, DSL_BSP_MemoryAccessType_t, DSL_uint32_t, DSL_uint32_t *, DSL_uint32_t);
++extern volatile DSL_DEV_Device_t *adsl_dev;
++
++/**
++ * Dummy structure by now to show mechanism of extended data that will be
++ * provided within event callback itself.
++ * */
++typedef struct
++{
++ /**
++ * Dummy value */
++ DSL_uint32_t nDummy1;
++} DSL_BSP_CB_Event1DataDummy_t;
++
++/**
++ * Dummy structure by now to show mechanism of extended data that will be
++ * provided within event callback itself.
++ * */
++typedef struct
++{
++ /**
++ * Dummy value */
++ DSL_uint32_t nDummy2;
++} DSL_BSP_CB_Event2DataDummy_t;
++
++/**
++ * encapsulate all data structures that are necessary for status event
++ * callbacks.
++ * */
++typedef union
++{
++ DSL_BSP_CB_Event1DataDummy_t dataEvent1;
++ DSL_BSP_CB_Event2DataDummy_t dataEvent2;
++} DSL_BSP_CB_DATA_Union_t;
++
++
++typedef enum
++{
++ /**
++ * Informs the upper layer driver (DSL CPE API) about a reboot request from the
++ * firmware.
++ * \note This event does NOT include any additional data.
++ * More detailed information upon reboot reason has to be requested from
++ * upper layer software via CMV (INFO 109) if necessary. */
++ DSL_BSP_CB_FIRST = 0,
++ DSL_BSP_CB_DYING_GASP,
++ DSL_BSP_CB_CEOC_IRQ,
++ DSL_BSP_CB_FIRMWARE_REBOOT,
++ /**
++ * Delimiter only */
++ DSL_BSP_CB_LAST
++} DSL_BSP_CB_Type_t;
++
++/**
++ * Specifies the common event type that has to be used for registering and
++ * signalling of interrupts/autonomous status events from MEI BSP Driver.
++ *
++ * \param pDev
++ * Context pointer from MEI BSP Driver.
++ *
++ * \param IFX_ADSL_BSP_CallbackType_t
++ * Specifies the event callback type (reason of callback). Regrading to the
++ * setting of this value the data which is included in the following union
++ * might have different meanings.
++ * Please refer to the description of the union to get information about the
++ * meaning of the included data.
++ *
++ * \param pData
++ * Data according to \ref DSL_BSP_CB_DATA_Union_t.
++ * If this pointer is NULL there is no additional data available.
++ *
++ * \return depending on event
++ */
++typedef int (*DSL_BSP_EventCallback_t)
++(
++ DSL_DEV_Device_t *pDev,
++ DSL_BSP_CB_Type_t nCallbackType,
++ DSL_BSP_CB_DATA_Union_t *pData
++);
++
++typedef struct {
++ DSL_BSP_EventCallback_t function;
++ DSL_BSP_CB_Type_t event;
++ DSL_BSP_CB_DATA_Union_t *pData;
++} DSL_BSP_EventCallBack_t;
++
++extern int DSL_BSP_EventCBRegister(DSL_BSP_EventCallBack_t *);
++extern int DSL_BSP_EventCBUnregister(DSL_BSP_EventCallBack_t *);
++
++/** Modem states */
++#define DSL_DEV_STAT_InitState 0x0000
++#define DSL_DEV_STAT_ReadyState 0x0001
++#define DSL_DEV_STAT_FailState 0x0002
++#define DSL_DEV_STAT_IdleState 0x0003
++#define DSL_DEV_STAT_QuietState 0x0004
++#define DSL_DEV_STAT_GhsState 0x0005
++#define DSL_DEV_STAT_FullInitState 0x0006
++#define DSL_DEV_STAT_ShowTimeState 0x0007
++#define DSL_DEV_STAT_FastRetrainState 0x0008
++#define DSL_DEV_STAT_LoopDiagMode 0x0009
++#define DSL_DEV_STAT_ShortInit 0x000A /* Bis short initialization */
++
++#define DSL_DEV_STAT_CODESWAP_COMPLETE 0x0002
++
++#endif //IFXMIPS_MEI_H
+--- a/configure.in
++++ b/configure.in
+@@ -310,7 +310,7 @@
+ AC_ARG_ENABLE(kernelbuild,
+ AC_HELP_STRING(--enable-kernel-build=x,Set the target kernel build path),
+ [
+- if test -e $enableval/include/linux/autoconf.h; then
++ if test -e $enableval/include/linux/autoconf.h -o -e $enableval/include/generated/autoconf.h; then
+ AC_SUBST([KERNEL_BUILD_PATH],[$enableval])
+ else
+ AC_MSG_ERROR([The kernel build directory is not valid or not configured!])
+@@ -333,12 +333,12 @@
+ echo Set the lib_ifxos include path $enableval
+ AC_SUBST([IFXOS_INCLUDE_PATH],[$enableval])
+ else
+- echo -e Set the default lib_ifxos include path $DEFAULT_IFXOS_INCLUDE_PATH
++ echo Set the default lib_ifxos include path $DEFAULT_IFXOS_INCLUDE_PATH
+ AC_SUBST([IFXOS_INCLUDE_PATH],[$DEFAULT_IFXOS_INCLUDE_PATH])
+ fi
+ ],
+ [
+- echo -e Set the default lib_ifxos include path $DEFAULT_IFXOS_INCLUDE_PATH
++ echo Set the default lib_ifxos include path $DEFAULT_IFXOS_INCLUDE_PATH
+ AC_SUBST([IFXOS_INCLUDE_PATH],[$DEFAULT_IFXOS_INCLUDE_PATH])
+ ]
+ )
+@@ -1702,73 +1702,73 @@
+ AC_SUBST([DISTCHECK_CONFIGURE_PARAMS],[$CONFIGURE_OPTIONS])
+
+ AC_CONFIG_COMMANDS_PRE([
+-echo -e "------------------------------------------------------------------------"
+-echo -e " Configuration for drv_dsl_cpe_api:"
+-echo -e " Configure model type: $DSL_CONFIG_MODEL_TYPE"
+-echo -e " Source code location: $srcdir"
+-echo -e " Compiler: $CC"
+-echo -e " Compiler c-flags: $CFLAGS"
+-echo -e " Extra compiler c-flags: $EXTRA_DRV_CFLAGS"
+-echo -e " Host System Type: $host"
+-echo -e " Install path: $prefix"
+-echo -e " Linux kernel include path: $KERNEL_INCL_PATH"
+-echo -e " Linux kernel build path: $KERNEL_BUILD_PATH"
+-echo -e " Linux kernel architecture: $KERNEL_ARCH"
+-echo -e " Include IFXOS: $INCLUDE_DSL_CPE_API_IFXOS_SUPPORT"
+-echo -e " IFXOS include path: $IFXOS_INCLUDE_PATH"
+-echo -e " Driver Include Path $DSL_DRIVER_INCL_PATH"
+-echo -e " DSL device: $DSL_DEVICE_NAME"
+-echo -e " Max device number: $DSL_DRV_MAX_DEVICE_NUMBER"
+-echo -e " Channels per line: $DSL_CHANNELS_PER_LINE"
+-echo -e " Build lib (only for kernel 2.6) $DSL_CPE_API_LIBRARY_BUILD_2_6"
+-echo -e " DSL data led flash frequency: $DSL_DATA_LED_FLASH_FREQUENCY Hz"
+-echo -e " Disable debug prints: $DSL_DEBUG_DISABLE"
+-echo -e " Preselection of max. debug level: $DSL_DBG_MAX_LEVEL_SET"
+-echo -e " Preselected max. debug level: $DSL_DBG_MAX_LEVEL_PRE"
+-echo -e " Include deprecated functions: $INCLUDE_DEPRECATED"
+-echo -e " Include Device Exception Codes: $INCLUDE_DEVICE_EXCEPTION_CODES"
+-echo -e " Include FW request support: $INCLUDE_FW_REQUEST_SUPPORT"
+-echo -e " Include ADSL trace buffer: $INCLUDE_DSL_CPE_TRACE_BUFFER"
+-echo -e " Include ADSL MIB: $INCLUDE_DSL_ADSL_MIB"
+-echo -e " Include ADSL LED: $INCLUDE_ADSL_LED"
+-echo -e " Include CEOC: $INCLUDE_DSL_CEOC"
+-echo -e " Include config get support: $INCLUDE_DSL_CONFIG_GET"
+-echo -e " Include System i/f configuration: $INCLUDE_DSL_SYSTEM_INTERFACE"
+-echo -e " Include Resource Statistics: $INCLUDE_DSL_RESOURCE_STATISTICS"
+-echo -e " Include Framing Parameters: $INCLUDE_DSL_FRAMING_PARAMETERS"
+-echo -e " Include G997 Line Inventory: $INCLUDE_DSL_G997_LINE_INVENTORY"
+-echo -e " Include G997 Framing Parameters: $INCLUDE_DSL_G997_FRAMING_PARAMETERS"
+-echo -e " Include G997 per tone data: $INCLUDE_DSL_G997_PER_TONE"
+-echo -e " Include G997 status: $INCLUDE_DSL_G997_STATUS"
+-echo -e " Include G997 alarm: $INCLUDE_DSL_G997_ALARM"
+-echo -e " Include DSL Bonding: $INCLUDE_DSL_BONDING"
+-echo -e " Include Misc Line Status $INCLUDE_DSL_CPE_MISC_LINE_STATUS"
+-echo -e " Include DELT: $INCLUDE_DSL_DELT"
+-echo -e " Include DELT data static storage: $DSL_CPE_STATIC_DELT_DATA"
+-echo -e " Include PM: $INCLUDE_DSL_PM"
+-echo -e " Include PM config: $INCLUDE_DSL_CPE_PM_CONFIG"
+-echo -e " Include PM total: $INCLUDE_DSL_CPE_PM_TOTAL_COUNTERS"
+-echo -e " Include PM history: $INCLUDE_DSL_CPE_PM_HISTORY"
+-echo -e " Include PM showtime: $INCLUDE_DSL_CPE_PM_SHOWTIME_COUNTERS"
+-echo -e " Include PM optional: $INCLUDE_DSL_CPE_PM_OPTIONAL_PARAMETERS"
+-echo -e " Include PM line: $INCLUDE_DSL_CPE_PM_LINE_COUNTERS"
+-echo -e " Include PM line event showtime: $INCLUDE_DSL_CPE_PM_LINE_EVENT_SHOWTIME_COUNTERS"
+-echo -e " Include PM channel: $INCLUDE_DSL_CPE_PM_CHANNEL_COUNTERS"
+-echo -e " Include PM channel extended: $INCLUDE_DSL_CPE_PM_CHANNEL_EXT_COUNTERS"
+-echo -e " Include PM data path: $INCLUDE_DSL_CPE_PM_DATA_PATH_COUNTERS"
+-echo -e " Include PM data path failure: $INCLUDE_DSL_CPE_PM_DATA_PATH_FAILURE_COUNTERS"
+-echo -e " Include PM ReTx: $INCLUDE_DSL_CPE_PM_RETX_COUNTERS"
+-echo -e " Include PM line threshold: $INCLUDE_DSL_CPE_PM_LINE_THRESHOLDS"
+-echo -e " Include PM channel threshold: $INCLUDE_DSL_CPE_PM_CHANNEL_THRESHOLDS"
+-echo -e " Include PM data path threshold: $INCLUDE_DSL_CPE_PM_DATA_PATH_THRESHOLDS"
+-echo -e " Include PM ReTx threshold: $INCLUDE_DSL_CPE_PM_RETX_THRESHOLDS"
+-echo -e " Include FW memory free support: $INCLUDE_DSL_FIRMWARE_MEMORY_FREE"
+-echo -e "----------------------- deprectated ! ----------------------------------"
+-echo -e " Include PM line failure: $INCLUDE_DSL_CPE_PM_LINE_FAILURE_COUNTERS"
+-echo -e ""
+-echo -e " Settings:"
+-echo -e " Configure options: $CONFIGURE_OPTIONS"
+-echo -e "------------------------------------------------------------------------"
++echo "------------------------------------------------------------------------"
++echo " Configuration for drv_dsl_cpe_api:"
++echo " Configure model type: $DSL_CONFIG_MODEL_TYPE"
++echo " Source code location: $srcdir"
++echo " Compiler: $CC"
++echo " Compiler c-flags: $CFLAGS"
++echo " Extra compiler c-flags: $EXTRA_DRV_CFLAGS"
++echo " Host System Type: $host"
++echo " Install path: $prefix"
++echo " Linux kernel include path: $KERNEL_INCL_PATH"
++echo " Linux kernel build path: $KERNEL_BUILD_PATH"
++echo " Linux kernel architecture: $KERNEL_ARCH"
++echo " Include IFXOS: $INCLUDE_DSL_CPE_API_IFXOS_SUPPORT"
++echo " IFXOS include path: $IFXOS_INCLUDE_PATH"
++echo " Driver Include Path $DSL_DRIVER_INCL_PATH"
++echo " DSL device: $DSL_DEVICE_NAME"
++echo " Max device number: $DSL_DRV_MAX_DEVICE_NUMBER"
++echo " Channels per line: $DSL_CHANNELS_PER_LINE"
++echo " Build lib (only for kernel 2.6) $DSL_CPE_API_LIBRARY_BUILD_2_6"
++echo " DSL data led flash frequency: $DSL_DATA_LED_FLASH_FREQUENCY Hz"
++echo " Disable debug prints: $DSL_DEBUG_DISABLE"
++echo " Preselection of max. debug level: $DSL_DBG_MAX_LEVEL_SET"
++echo " Preselected max. debug level: $DSL_DBG_MAX_LEVEL_PRE"
++echo " Include deprecated functions: $INCLUDE_DEPRECATED"
++echo " Include Device Exception Codes: $INCLUDE_DEVICE_EXCEPTION_CODES"
++echo " Include FW request support: $INCLUDE_FW_REQUEST_SUPPORT"
++echo " Include ADSL trace buffer: $INCLUDE_DSL_CPE_TRACE_BUFFER"
++echo " Include ADSL MIB: $INCLUDE_DSL_ADSL_MIB"
++echo " Include ADSL LED: $INCLUDE_ADSL_LED"
++echo " Include CEOC: $INCLUDE_DSL_CEOC"
++echo " Include config get support: $INCLUDE_DSL_CONFIG_GET"
++echo " Include System i/f configuration: $INCLUDE_DSL_SYSTEM_INTERFACE"
++echo " Include Resource Statistics: $INCLUDE_DSL_RESOURCE_STATISTICS"
++echo " Include Framing Parameters: $INCLUDE_DSL_FRAMING_PARAMETERS"
++echo " Include G997 Line Inventory: $INCLUDE_DSL_G997_LINE_INVENTORY"
++echo " Include G997 Framing Parameters: $INCLUDE_DSL_G997_FRAMING_PARAMETERS"
++echo " Include G997 per tone data: $INCLUDE_DSL_G997_PER_TONE"
++echo " Include G997 status: $INCLUDE_DSL_G997_STATUS"
++echo " Include G997 alarm: $INCLUDE_DSL_G997_ALARM"
++echo " Include DSL Bonding: $INCLUDE_DSL_BONDING"
++echo " Include Misc Line Status $INCLUDE_DSL_CPE_MISC_LINE_STATUS"
++echo " Include DELT: $INCLUDE_DSL_DELT"
++echo " Include DELT data static storage: $DSL_CPE_STATIC_DELT_DATA"
++echo " Include PM: $INCLUDE_DSL_PM"
++echo " Include PM config: $INCLUDE_DSL_CPE_PM_CONFIG"
++echo " Include PM total: $INCLUDE_DSL_CPE_PM_TOTAL_COUNTERS"
++echo " Include PM history: $INCLUDE_DSL_CPE_PM_HISTORY"
++echo " Include PM showtime: $INCLUDE_DSL_CPE_PM_SHOWTIME_COUNTERS"
++echo " Include PM optional: $INCLUDE_DSL_CPE_PM_OPTIONAL_PARAMETERS"
++echo " Include PM line: $INCLUDE_DSL_CPE_PM_LINE_COUNTERS"
++echo " Include PM line event showtime: $INCLUDE_DSL_CPE_PM_LINE_EVENT_SHOWTIME_COUNTERS"
++echo " Include PM channel: $INCLUDE_DSL_CPE_PM_CHANNEL_COUNTERS"
++echo " Include PM channel extended: $INCLUDE_DSL_CPE_PM_CHANNEL_EXT_COUNTERS"
++echo " Include PM data path: $INCLUDE_DSL_CPE_PM_DATA_PATH_COUNTERS"
++echo " Include PM data path failure: $INCLUDE_DSL_CPE_PM_DATA_PATH_FAILURE_COUNTERS"
++echo " Include PM ReTx: $INCLUDE_DSL_CPE_PM_RETX_COUNTERS"
++echo " Include PM line threshold: $INCLUDE_DSL_CPE_PM_LINE_THRESHOLDS"
++echo " Include PM channel threshold: $INCLUDE_DSL_CPE_PM_CHANNEL_THRESHOLDS"
++echo " Include PM data path threshold: $INCLUDE_DSL_CPE_PM_DATA_PATH_THRESHOLDS"
++echo " Include PM ReTx threshold: $INCLUDE_DSL_CPE_PM_RETX_THRESHOLDS"
++echo " Include FW memory free support: $INCLUDE_DSL_FIRMWARE_MEMORY_FREE"
++echo "----------------------- deprectated ! ----------------------------------"
++echo " Include PM line failure: $INCLUDE_DSL_CPE_PM_LINE_FAILURE_COUNTERS"
++echo ""
++echo " Settings:"
++echo " Configure options: $CONFIGURE_OPTIONS"
++echo "------------------------------------------------------------------------"
+ ])
+
+ AC_CONFIG_FILES([Makefile src/Makefile])
+--- a/src/Makefile.am
++++ b/src/Makefile.am
+@@ -303,7 +303,7 @@
+ drv_dsl_cpe_api_OBJS = "$(subst .c,.o,$(filter %.c,$(drv_dsl_cpe_api_SOURCES)))"
+
+ drv_dsl_cpe_api.ko: $(drv_dsl_cpe_api_SOURCES)
+- @echo -e "drv_dsl_cpe_api: Making Linux 2.6.x kernel object"
++ @echo "drv_dsl_cpe_api: Making Linux 2.6.x kernel object"
+ if test ! -e common/drv_dsl_cpe_api.c ; then \
+ echo "copy source files (as links only!)"; \
+ for f in $(filter %.c,$(drv_dsl_cpe_api_SOURCES)); do \
+@@ -311,10 +311,10 @@
+ cp -s $(addprefix @abs_srcdir@/,$$f) $(PWD)/`dirname $$f`/ ; \
+ done \
+ fi
+- @echo -e "# drv_dsl_cpe_api: Generated to build Linux 2.6.x kernel object" > $(PWD)/Kbuild
+- @echo -e "obj-m := $(subst .ko,.o,$@)" >> $(PWD)/Kbuild
+- @echo -e "$(subst .ko,,$@)-y := $(drv_dsl_cpe_api_OBJS)" >> $(PWD)/Kbuild
+- @echo -e "EXTRA_CFLAGS := $(CFLAGS) -DHAVE_CONFIG_H $(drv_dsl_cpe_api_CFLAGS) $(DSL_DRIVER_INCL_PATH) $(IFXOS_INCLUDE_PATH) -I@abs_srcdir@/include -I$(PWD)/include" >> $(PWD)/Kbuild
++ @echo "# drv_dsl_cpe_api: Generated to build Linux 2.6.x kernel object" > $(PWD)/Kbuild
++ @echo "obj-m := $(subst .ko,.o,$@)" >> $(PWD)/Kbuild
++ @echo "$(subst .ko,,$@)-y := $(drv_dsl_cpe_api_OBJS)" >> $(PWD)/Kbuild
++ @echo "EXTRA_CFLAGS := $(CFLAGS) -DHAVE_CONFIG_H $(drv_dsl_cpe_api_CFLAGS) $(DSL_DRIVER_INCL_PATH) $(IFXOS_INCLUDE_PATH) -I@abs_srcdir@/include -I$(PWD)/include" >> $(PWD)/Kbuild
+ $(MAKE) ARCH=@KERNEL_ARCH@ -C @KERNEL_BUILD_PATH@ O=@KERNEL_BUILD_PATH@ M=$(PWD) modules
+
+ clean-generic:
+--- a/src/include/drv_dsl_cpe_os_linux.h
++++ b/src/include/drv_dsl_cpe_os_linux.h
+@@ -16,8 +16,6 @@
+ extern "C" {
+ #endif
+
+-#include <asm/ioctl.h>
+-#include <generated/autoconf.h>
+ #include <linux/module.h>
+ #include <linux/kernel.h>
+ #include <linux/init.h>
+@@ -26,8 +24,10 @@
+ #include <linux/spinlock.h>
+ #include <linux/sched.h>
+
+-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17))
+- #include <generated/utsrelease.h>
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33))
++#include <linux/utsrelease.h>
++#else
++#include <generated/utsrelease.h>
+ #endif
+
+ #include <linux/types.h>
+@@ -39,7 +39,8 @@
+ #include <linux/delay.h>
+ #include <linux/poll.h>
+ #include <asm/uaccess.h>
+-#include <linux/smp_lock.h>
++//#include <linux/smp_lock.h>
++#include <asm/ioctl.h>
+
+ #ifdef INCLUDE_DSL_CPE_API_IFXOS_SUPPORT
+ /** IFXOS includes*/
diff --git a/package/platform/lantiq/ltq-adsl/patches/.svn/text-base/110-fix_status_polling_loop.patch.svn-base b/package/platform/lantiq/ltq-adsl/patches/.svn/text-base/110-fix_status_polling_loop.patch.svn-base
new file mode 100644
index 0000000..870943d
--- /dev/null
+++ b/package/platform/lantiq/ltq-adsl/patches/.svn/text-base/110-fix_status_polling_loop.patch.svn-base
@@ -0,0 +1,11 @@
+--- a/src/device/drv_dsl_cpe_device_danube.c
++++ b/src/device/drv_dsl_cpe_device_danube.c
+@@ -4069,7 +4069,7 @@ static DSL_Error_t DSL_DRV_DANUBE_XTUSys
+
+ DSL_CTX_WRITE(pContext, nErrCode, xtseCurr, xtseCurr);
+
+- for (nRetry = 0; nRetry < 20; nRetry++)
++ for (nRetry = 0; nRetry < 20 && bStatusUpdated == DSL_FALSE; nRetry++)
+ {
+ /* Get STAT1 info*/
+ nErrCode = DSL_DRV_DANUBE_CmvRead(pContext, DSL_CMV_GROUP_STAT,
diff --git a/package/platform/lantiq/ltq-adsl/patches/.svn/text-base/120-platform.patch.svn-base b/package/platform/lantiq/ltq-adsl/patches/.svn/text-base/120-platform.patch.svn-base
new file mode 100644
index 0000000..48c7581
--- /dev/null
+++ b/package/platform/lantiq/ltq-adsl/patches/.svn/text-base/120-platform.patch.svn-base
@@ -0,0 +1,72 @@
+Index: drv_dsl_cpe_api-3.24.4.4/src/common/drv_dsl_cpe_os_linux.c
+===================================================================
+--- drv_dsl_cpe_api-3.24.4.4.orig/src/common/drv_dsl_cpe_os_linux.c 2012-12-07 21:22:58.020256076 +0100
++++ drv_dsl_cpe_api-3.24.4.4/src/common/drv_dsl_cpe_os_linux.c 2012-12-07 21:31:13.156268489 +0100
+@@ -12,6 +12,7 @@
+
+ #define DSL_INTERN
+ #include <linux/device.h>
++#include <linux/platform_device.h>
+
+ #include "drv_dsl_cpe_api.h"
+ #include "drv_dsl_cpe_api_ioctl.h"
+@@ -1063,7 +1064,7 @@
+ #endif
+
+ /* Entry point of driver */
+-int __init DSL_ModuleInit(void)
++static int __devinit ltq_adsl_probe(struct platform_device *pdev)
+ {
+ struct class *dsl_class;
+ DSL_int_t i;
+@@ -1117,7 +1118,7 @@
+ return 0;
+ }
+
+-void __exit DSL_ModuleCleanup(void)
++static int __devexit ltq_adsl_remove(struct platform_device *pdev)
+ {
+ printk("Module will be unloaded"DSL_DRV_CRLF);
+
+@@ -1132,7 +1133,7 @@
+ (DSL_uint8_t**)&g_BndFpgaBase);
+ #endif /* defined(INCLUDE_DSL_CPE_API_VINAX) && defined(INCLUDE_DSL_BONDING)*/
+
+- return;
++ return 0;
+ }
+
+ #ifndef _lint
+@@ -1148,8 +1149,30 @@
+ MODULE_PARM_DESC(debug_level, "set to get more (1) or fewer (4) debug outputs");
+ #endif /* #ifndef DSL_DEBUG_DISABLE*/
+
+-module_init(DSL_ModuleInit);
+-module_exit(DSL_ModuleCleanup);
++static const struct of_device_id ltq_adsl_match[] = {
++#ifdef CONFIG_DANUBE
++ { .compatible = "lantiq,adsl-danube"},
++#elif defined CONFIG_AMAZON_SE
++ { .compatible = "lantiq,adsl-ase"},
++#elif defined CONFIG_AR9
++ { .compatible = "lantiq,adsl-arx100"},
++#endif
++ {},
++};
++MODULE_DEVICE_TABLE(of, ltq_adsl_match);
++
++static struct platform_driver ltq_adsl_driver = {
++ .probe = ltq_adsl_probe,
++ .remove = __devexit_p(ltq_adsl_remove),
++ .driver = {
++ .name = "adsl",
++ .owner = THIS_MODULE,
++ .of_match_table = ltq_adsl_match,
++ },
++};
++
++module_platform_driver(ltq_adsl_driver);
++
+ #endif /* #ifndef _lint*/
+
+ //EXPORT_SYMBOL(DSL_ModuleInit);
diff --git a/package/platform/lantiq/ltq-adsl/patches/.svn/text-base/130-linux3.8.patch.svn-base b/package/platform/lantiq/ltq-adsl/patches/.svn/text-base/130-linux3.8.patch.svn-base
new file mode 100644
index 0000000..21dbe6b
--- /dev/null
+++ b/package/platform/lantiq/ltq-adsl/patches/.svn/text-base/130-linux3.8.patch.svn-base
@@ -0,0 +1,152 @@
+Index: drv_dsl_cpe_api-3.24.4.4/src/common/drv_dsl_cpe_os_linux.c
+===================================================================
+--- drv_dsl_cpe_api-3.24.4.4.orig/src/common/drv_dsl_cpe_os_linux.c 2013-03-14 11:44:50.318326078 +0100
++++ drv_dsl_cpe_api-3.24.4.4/src/common/drv_dsl_cpe_os_linux.c 2013-03-14 11:46:08.562329425 +0100
+@@ -11,6 +11,7 @@
+ #ifdef __LINUX__
+
+ #define DSL_INTERN
++#include <linux/kthread.h>
+ #include <linux/device.h>
+ #include <linux/platform_device.h>
+
+@@ -40,7 +41,7 @@
+ static DSL_int_t DSL_DRV_Ioctls(DSL_DRV_inode_t * pINode, DSL_DRV_file_t * pFile,
+ DSL_uint_t nCommand, unsigned long nArg);
+ #else
+-static DSL_int_t DSL_DRV_Ioctls(DSL_DRV_file_t * pFile,
++static long DSL_DRV_Ioctls(DSL_DRV_file_t * pFile,
+ DSL_uint_t nCommand, unsigned long nArg);
+ #endif
+ static int DSL_DRV_Open(DSL_DRV_inode_t * ino, DSL_DRV_file_t * fil);
+@@ -184,7 +185,7 @@
+ DSL_uint_t nCommand,
+ unsigned long nArg)
+ #else
+-static DSL_int_t DSL_DRV_Ioctls(
++static long DSL_DRV_Ioctls(
+ DSL_DRV_file_t * pFile,
+ DSL_uint_t nCommand,
+ unsigned long nArg)
+@@ -521,9 +522,9 @@
+ - IFX_SUCCESS on success
+ - IFX_ERROR on error
+ */
+-DSL_DRV_STATIC DSL_int32_t DSL_DRV_KernelThreadStartup(
+- DSL_DRV_ThreadCtrl_t *pThrCntrl)
++static int DSL_DRV_KernelThreadStartup(void *data)
+ {
++ DSL_DRV_ThreadCtrl_t *pThrCntrl = (DSL_DRV_ThreadCtrl_t*) data;
+ DSL_int32_t retVal = -1;
+ #ifndef _lint
+
+@@ -546,30 +547,6 @@
+ (DSL_NULL, "ENTER - Kernel Thread Startup <%s>" DSL_DRV_CRLF,
+ pThrCntrl->thrParams.pName));
+
+- /* do LINUX specific setup */
+-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
+- daemonize();
+- reparent_to_init();
+-
+- /* lock the kernel. A new kernel thread starts without
+- the big kernel lock, regardless of the lock state
+- of the creator (the lock level is *not* inheritated)
+- */
+- lock_kernel();
+-
+- /* Don't care about any signals. */
+- siginitsetinv(&current->blocked, 0);
+-
+- /* set name of this process */
+- strcpy(kthread->comm, pThrCntrl->thrParams.pName);
+-
+- /* let others run */
+- unlock_kernel();
+-#else
+- daemonize(pThrCntrl->thrParams.pName);
+-
+-#endif
+-
+ /*DSL_DRV_ThreadPriorityModify(pThrCntrl->nPriority);*/
+
+ pThrCntrl->thrParams.bRunning = 1;
+@@ -629,7 +606,7 @@
+ if (DSL_DRV_THREAD_INIT_VALID(pThrCntrl) == DSL_FALSE)
+ {
+ /* set thread function arguments */
+- strcpy(pThrCntrl->thrParams.pName, pName);
++ snprintf(pThrCntrl->thrParams.pName, DSL_DRV_THREAD_NAME_LEN, "adsl - %s", pName);
+ pThrCntrl->nPriority = nPriority;
+ pThrCntrl->thrParams.nArg1 = nArg1;
+ pThrCntrl->thrParams.nArg2 = nArg2;
+@@ -639,9 +616,7 @@
+ init_completion(&pThrCntrl->thrCompletion);
+
+ /* start kernel thread via the wrapper function */
+- pThrCntrl->pid = kernel_thread( (DSL_DRV_KERNEL_THREAD_StartRoutine)DSL_DRV_KernelThreadStartup,
+- (void *)pThrCntrl,
+- DSL_DRV_DRV_THREAD_OPTIONS);
++ pThrCntrl->pid = kthread_run(DSL_DRV_KernelThreadStartup, (void *)pThrCntrl, pThrCntrl->thrParams.pName);
+
+ pThrCntrl->bValid = DSL_TRUE;
+
+@@ -1064,12 +1039,12 @@
+ #endif
+
+ /* Entry point of driver */
+-static int __devinit ltq_adsl_probe(struct platform_device *pdev)
++static int ltq_adsl_probe(struct platform_device *pdev)
+ {
+ struct class *dsl_class;
+ DSL_int_t i;
+
+- printk(DSL_DRV_CRLF DSL_DRV_CRLF "Infineon CPE API Driver version: %s" DSL_DRV_CRLF,
++ printk("Infineon CPE API Driver version: %s" DSL_DRV_CRLF,
+ &(dsl_cpe_api_version[4]));
+
+ DSL_DRV_MemSet( ifxDevices, 0, sizeof(DSL_devCtx_t) * DSL_DRV_MAX_DEVICE_NUMBER );
+@@ -1118,7 +1093,7 @@
+ return 0;
+ }
+
+-static int __devexit ltq_adsl_remove(struct platform_device *pdev)
++static int ltq_adsl_remove(struct platform_device *pdev)
+ {
+ printk("Module will be unloaded"DSL_DRV_CRLF);
+
+@@ -1163,7 +1138,7 @@
+
+ static struct platform_driver ltq_adsl_driver = {
+ .probe = ltq_adsl_probe,
+- .remove = __devexit_p(ltq_adsl_remove),
++ .remove = ltq_adsl_remove,
+ .driver = {
+ .name = "adsl",
+ .owner = THIS_MODULE,
+Index: drv_dsl_cpe_api-3.24.4.4/src/include/drv_dsl_cpe_os_lint_map.h
+===================================================================
+--- drv_dsl_cpe_api-3.24.4.4.orig/src/include/drv_dsl_cpe_os_lint_map.h 2009-02-24 21:44:54.000000000 +0100
++++ drv_dsl_cpe_api-3.24.4.4/src/include/drv_dsl_cpe_os_lint_map.h 2013-03-14 11:44:50.330326079 +0100
+@@ -247,7 +247,7 @@
+ DSL_DRV_ThreadFunction_t pThrFct;
+
+ /** Kernel thread process ID */
+- DSL_int32_t pid;
++ struct task_struct *pid;
+
+ /** requested kernel thread priority */
+ DSL_int32_t nPriority;
+Index: drv_dsl_cpe_api-3.24.4.4/src/include/drv_dsl_cpe_os_linux.h
+===================================================================
+--- drv_dsl_cpe_api-3.24.4.4.orig/src/include/drv_dsl_cpe_os_linux.h 2013-03-14 11:44:50.298326077 +0100
++++ drv_dsl_cpe_api-3.24.4.4/src/include/drv_dsl_cpe_os_linux.h 2013-03-14 11:44:50.330326079 +0100
+@@ -288,7 +288,7 @@
+ DSL_DRV_ThreadFunction_t pThrFct;
+
+ /** Kernel thread process ID */
+- DSL_int32_t pid;
++ struct task_struct *pid;
+
+ /** requested kernel thread priority */
+ DSL_int32_t nPriority;
diff --git a/package/platform/lantiq/ltq-adsl/patches/100-dsl_compat.patch b/package/platform/lantiq/ltq-adsl/patches/100-dsl_compat.patch
new file mode 100644
index 0000000..f2ed230
--- /dev/null
+++ b/package/platform/lantiq/ltq-adsl/patches/100-dsl_compat.patch
@@ -0,0 +1,1065 @@
+Index: drv_dsl_cpe_api-3.24.4.4/src/include/drv_dsl_cpe_device_danube.h
+===================================================================
+--- drv_dsl_cpe_api-3.24.4.4.orig/src/include/drv_dsl_cpe_device_danube.h 2009-05-12 20:02:16.000000000 +0200
++++ drv_dsl_cpe_api-3.24.4.4/src/include/drv_dsl_cpe_device_danube.h 2012-11-29 19:47:21.060210322 +0100
+@@ -24,7 +24,7 @@
+ #include "drv_dsl_cpe_simulator_danube.h"
+ #else
+ /* Include for the low level driver interface header file */
+-#include "asm/ifx/ifx_mei_bsp.h"
++#include "ifxmips_mei_interface.h"
+ #endif /* defined(DSL_CPE_SIMULATOR_DRIVER) && defined(WIN32)*/
+
+ #define DSL_MAX_LINE_NUMBER 1
+Index: drv_dsl_cpe_api-3.24.4.4/src/common/drv_dsl_cpe_os_linux.c
+===================================================================
+--- drv_dsl_cpe_api-3.24.4.4.orig/src/common/drv_dsl_cpe_os_linux.c 2009-07-13 11:33:43.000000000 +0200
++++ drv_dsl_cpe_api-3.24.4.4/src/common/drv_dsl_cpe_os_linux.c 2012-11-29 19:46:32.700209112 +0100
+@@ -11,6 +11,7 @@
+ #ifdef __LINUX__
+
+ #define DSL_INTERN
++#include <linux/device.h>
+
+ #include "drv_dsl_cpe_api.h"
+ #include "drv_dsl_cpe_api_ioctl.h"
+@@ -34,9 +35,13 @@
+ static DSL_ssize_t DSL_DRV_Write(DSL_DRV_file_t *pFile, const DSL_char_t * pBuf,
+ DSL_DRV_size_t nSize, DSL_DRV_offset_t * pLoff);
+
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36))
+ static DSL_int_t DSL_DRV_Ioctls(DSL_DRV_inode_t * pINode, DSL_DRV_file_t * pFile,
+ DSL_uint_t nCommand, unsigned long nArg);
+-
++#else
++static DSL_int_t DSL_DRV_Ioctls(DSL_DRV_file_t * pFile,
++ DSL_uint_t nCommand, unsigned long nArg);
++#endif
+ static int DSL_DRV_Open(DSL_DRV_inode_t * ino, DSL_DRV_file_t * fil);
+
+ static int DSL_DRV_Release(DSL_DRV_inode_t * ino, DSL_DRV_file_t * fil);
+@@ -72,7 +77,11 @@
+ open: DSL_DRV_Open,
+ release: DSL_DRV_Release,
+ write: DSL_DRV_Write,
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36))
+ ioctl: DSL_DRV_Ioctls,
++#else
++ unlocked_ioctl: DSL_DRV_Ioctls,
++#endif
+ poll: DSL_DRV_Poll
+ };
+ #else
+@@ -168,10 +177,17 @@
+ \return Success or failure.
+ \ingroup Internal
+ */
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36))
+ static DSL_int_t DSL_DRV_Ioctls(DSL_DRV_inode_t * pINode,
+ DSL_DRV_file_t * pFile,
+ DSL_uint_t nCommand,
+ unsigned long nArg)
++#else
++static DSL_int_t DSL_DRV_Ioctls(
++ DSL_DRV_file_t * pFile,
++ DSL_uint_t nCommand,
++ unsigned long nArg)
++#endif
+ {
+ DSL_int_t nErr=0;
+ DSL_boolean_t bIsInKernel;
+@@ -216,16 +232,7 @@
+ }
+ }
+ }
+-
+- if (pINode == DSL_NULL)
+- {
+- bIsInKernel = DSL_TRUE;
+- }
+- else
+- {
+- bIsInKernel = DSL_FALSE;
+- }
+-
++ bIsInKernel = DSL_FALSE;
+ if ( (_IOC_TYPE(nCommand) == DSL_IOC_MAGIC_CPE_API) ||
+ (_IOC_TYPE(nCommand) == DSL_IOC_MAGIC_CPE_API_G997) ||
+ (_IOC_TYPE(nCommand) == DSL_IOC_MAGIC_CPE_API_PM) ||
+@@ -1058,6 +1065,7 @@
+ /* Entry point of driver */
+ int __init DSL_ModuleInit(void)
+ {
++ struct class *dsl_class;
+ DSL_int_t i;
+
+ printk(DSL_DRV_CRLF DSL_DRV_CRLF "Infineon CPE API Driver version: %s" DSL_DRV_CRLF,
+@@ -1104,7 +1112,8 @@
+ }
+
+ DSL_DRV_DevNodeInit();
+-
++ dsl_class = class_create(THIS_MODULE, "dsl_cpe_api");
++ device_create(dsl_class, NULL, MKDEV(DRV_DSL_CPE_API_DEV_MAJOR, 0), NULL, "dsl_cpe_api");
+ return 0;
+ }
+
+Index: drv_dsl_cpe_api-3.24.4.4/src/include/drv_dsl_cpe_os_linux.h
+===================================================================
+--- drv_dsl_cpe_api-3.24.4.4.orig/src/include/drv_dsl_cpe_os_linux.h 2009-07-03 17:04:51.000000000 +0200
++++ drv_dsl_cpe_api-3.24.4.4/src/include/drv_dsl_cpe_os_linux.h 2012-11-29 19:47:23.092210377 +0100
+@@ -17,17 +17,17 @@
+ #endif
+
+ #include <asm/ioctl.h>
+-#include <linux/autoconf.h>
++#include <generated/autoconf.h>
+ #include <linux/module.h>
+ #include <linux/kernel.h>
+ #include <linux/init.h>
+ #include <linux/ctype.h>
+ #include <linux/version.h>
+ #include <linux/spinlock.h>
+-
++#include <linux/sched.h>
+
+ #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17))
+- #include <linux/utsrelease.h>
++ #include <generated/utsrelease.h>
+ #endif
+
+ #include <linux/types.h>
+Index: drv_dsl_cpe_api-3.24.4.4/src/ifxmips_mei_interface.h
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ drv_dsl_cpe_api-3.24.4.4/src/ifxmips_mei_interface.h 2012-11-29 19:47:54.972211177 +0100
+@@ -0,0 +1,702 @@
++/******************************************************************************
++
++ Copyright (c) 2009
++ Infineon Technologies AG
++ Am Campeon 1-12; 81726 Munich, Germany
++
++ For licensing information, see the file 'LICENSE' in the root folder of
++ this software module.
++
++******************************************************************************/
++
++#ifndef IFXMIPS_MEI_H
++#define IFXMIPS_MEI_H
++
++//#define CONFIG_AMAZON_SE 1
++//#define CONFIG_DANUBE 1
++//#define CONFIG_AR9 1
++
++#if !defined(CONFIG_DANUBE) && !defined(CONFIG_AMAZON_SE) && !defined(CONFIG_AR9) && !defined(CONFIG_VR9)
++#error Platform undefined!!!
++#endif
++
++#ifdef IFX_MEI_BSP
++/** This is the character datatype. */
++typedef char DSL_char_t;
++/** This is the unsigned 8-bit datatype. */
++typedef unsigned char DSL_uint8_t;
++/** This is the signed 8-bit datatype. */
++typedef signed char DSL_int8_t;
++/** This is the unsigned 16-bit datatype. */
++typedef unsigned short DSL_uint16_t;
++/** This is the signed 16-bit datatype. */
++typedef signed short DSL_int16_t;
++/** This is the unsigned 32-bit datatype. */
++typedef unsigned long DSL_uint32_t;
++/** This is the signed 32-bit datatype. */
++typedef signed long DSL_int32_t;
++/** This is the float datatype. */
++typedef float DSL_float_t;
++/** This is the void datatype. */
++typedef void DSL_void_t;
++/** integer type, width is depending on processor arch */
++typedef int DSL_int_t;
++/** unsigned integer type, width is depending on processor arch */
++typedef unsigned int DSL_uint_t;
++typedef struct file DSL_DRV_file_t;
++typedef struct inode DSL_DRV_inode_t;
++
++/**
++ * Defines all possible CMV groups
++ * */
++typedef enum {
++ DSL_CMV_GROUP_CNTL = 1,
++ DSL_CMV_GROUP_STAT = 2,
++ DSL_CMV_GROUP_INFO = 3,
++ DSL_CMV_GROUP_TEST = 4,
++ DSL_CMV_GROUP_OPTN = 5,
++ DSL_CMV_GROUP_RATE = 6,
++ DSL_CMV_GROUP_PLAM = 7,
++ DSL_CMV_GROUP_CNFG = 8
++} DSL_CmvGroup_t;
++/**
++ * Defines all opcode types
++ * */
++typedef enum {
++ H2D_CMV_READ = 0x00,
++ H2D_CMV_WRITE = 0x04,
++ H2D_CMV_INDICATE_REPLY = 0x10,
++ H2D_ERROR_OPCODE_UNKNOWN =0x20,
++ H2D_ERROR_CMV_UNKNOWN =0x30,
++
++ D2H_CMV_READ_REPLY =0x01,
++ D2H_CMV_WRITE_REPLY = 0x05,
++ D2H_CMV_INDICATE = 0x11,
++ D2H_ERROR_OPCODE_UNKNOWN = 0x21,
++ D2H_ERROR_CMV_UNKNOWN = 0x31,
++ D2H_ERROR_CMV_READ_NOT_AVAILABLE = 0x41,
++ D2H_ERROR_CMV_WRITE_ONLY = 0x51,
++ D2H_ERROR_CMV_READ_ONLY = 0x61,
++
++ H2D_DEBUG_READ_DM = 0x02,
++ H2D_DEBUG_READ_PM = 0x06,
++ H2D_DEBUG_WRITE_DM = 0x0a,
++ H2D_DEBUG_WRITE_PM = 0x0e,
++
++ D2H_DEBUG_READ_DM_REPLY = 0x03,
++ D2H_DEBUG_READ_FM_REPLY = 0x07,
++ D2H_DEBUG_WRITE_DM_REPLY = 0x0b,
++ D2H_DEBUG_WRITE_FM_REPLY = 0x0f,
++ D2H_ERROR_ADDR_UNKNOWN = 0x33,
++
++ D2H_AUTONOMOUS_MODEM_READY_MSG = 0xf1
++} DSL_CmvOpcode_t;
++
++/* mutex macros */
++#define MEI_MUTEX_INIT(id,flag) \
++ sema_init(&id,flag)
++#define MEI_MUTEX_LOCK(id) \
++ down_interruptible(&id)
++#define MEI_MUTEX_UNLOCK(id) \
++ up(&id)
++#define MEI_WAIT(ms) \
++ {\
++ set_current_state(TASK_INTERRUPTIBLE);\
++ schedule_timeout(ms);\
++ }
++#define MEI_INIT_WAKELIST(name,queue) \
++ init_waitqueue_head(&queue)
++
++/* wait for an event, timeout is measured in ms */
++#define MEI_WAIT_EVENT_TIMEOUT(ev,timeout)\
++ interruptible_sleep_on_timeout(&ev,timeout * HZ / 1000)
++#define MEI_WAKEUP_EVENT(ev)\
++ wake_up_interruptible(&ev)
++#endif /* IFX_MEI_BSP */
++
++/*** Register address offsets, relative to MEI_SPACE_ADDRESS ***/
++#define ME_DX_DATA (0x0000)
++#define ME_VERSION (0x0004)
++#define ME_ARC_GP_STAT (0x0008)
++#define ME_DX_STAT (0x000C)
++#define ME_DX_AD (0x0010)
++#define ME_DX_MWS (0x0014)
++#define ME_ME2ARC_INT (0x0018)
++#define ME_ARC2ME_STAT (0x001C)
++#define ME_ARC2ME_MASK (0x0020)
++#define ME_DBG_WR_AD (0x0024)
++#define ME_DBG_RD_AD (0x0028)
++#define ME_DBG_DATA (0x002C)
++#define ME_DBG_DECODE (0x0030)
++#define ME_CONFIG (0x0034)
++#define ME_RST_CTRL (0x0038)
++#define ME_DBG_MASTER (0x003C)
++#define ME_CLK_CTRL (0x0040)
++#define ME_BIST_CTRL (0x0044)
++#define ME_BIST_STAT (0x0048)
++#define ME_XDATA_BASE_SH (0x004c)
++#define ME_XDATA_BASE (0x0050)
++#define ME_XMEM_BAR_BASE (0x0054)
++#define ME_XMEM_BAR0 (0x0054)
++#define ME_XMEM_BAR1 (0x0058)
++#define ME_XMEM_BAR2 (0x005C)
++#define ME_XMEM_BAR3 (0x0060)
++#define ME_XMEM_BAR4 (0x0064)
++#define ME_XMEM_BAR5 (0x0068)
++#define ME_XMEM_BAR6 (0x006C)
++#define ME_XMEM_BAR7 (0x0070)
++#define ME_XMEM_BAR8 (0x0074)
++#define ME_XMEM_BAR9 (0x0078)
++#define ME_XMEM_BAR10 (0x007C)
++#define ME_XMEM_BAR11 (0x0080)
++#define ME_XMEM_BAR12 (0x0084)
++#define ME_XMEM_BAR13 (0x0088)
++#define ME_XMEM_BAR14 (0x008C)
++#define ME_XMEM_BAR15 (0x0090)
++#define ME_XMEM_BAR16 (0x0094)
++
++#define WHILE_DELAY 20000
++/*
++** Define where in ME Processor's memory map the Stratify chip lives
++*/
++
++#define MAXSWAPSIZE (8 * 1024) //8k *(32bits)
++
++// Mailboxes
++#define MSG_LENGTH 16 // x16 bits
++#define YES_REPLY 1
++#define NO_REPLY 0
++
++#define CMV_TIMEOUT 1000 //jiffies
++
++// Block size per BAR
++#define SDRAM_SEGMENT_SIZE (64*1024)
++// Number of Bar registers
++#define MAX_BAR_REGISTERS (17)
++
++#define XDATA_REGISTER (15)
++
++// ARC register addresss
++#define ARC_STATUS 0x0
++#define ARC_LP_START 0x2
++#define ARC_LP_END 0x3
++#define ARC_DEBUG 0x5
++#define ARC_INT_MASK 0x10A
++
++#define IRAM0_BASE (0x00000)
++#define IRAM1_BASE (0x04000)
++#if defined(CONFIG_DANUBE)
++#define BRAM_BASE (0x0A000)
++#elif defined(CONFIG_AMAZON_SE) || defined(CONFIG_AR9) || defined(CONFIG_VR9)
++#define BRAM_BASE (0x08000)
++#endif
++#define XRAM_BASE (0x18000)
++#define YRAM_BASE (0x1A000)
++#define EXT_MEM_BASE (0x80000)
++#define ARC_GPIO_CTRL (0xC030)
++#define ARC_GPIO_DATA (0xC034)
++
++#define IRAM0_SIZE (16*1024)
++#define IRAM1_SIZE (16*1024)
++#define BRAM_SIZE (12*1024)
++#define XRAM_SIZE (8*1024)
++#define YRAM_SIZE (8*1024)
++#define EXT_MEM_SIZE (1536*1024)
++
++#define ADSL_BASE (0x20000)
++#define CRI_BASE (ADSL_BASE + 0x11F00)
++#define CRI_CCR0 (CRI_BASE + 0x00)
++#define CRI_RST (CRI_BASE + 0x04*4)
++#define ADSL_DILV_BASE (ADSL_BASE+0x20000)
++
++//
++#define IRAM0_ADDR_BIT_MASK 0xFFF
++#define IRAM1_ADDR_BIT_MASK 0xFFF
++#define BRAM_ADDR_BIT_MASK 0xFFF
++#define RX_DILV_ADDR_BIT_MASK 0x1FFF
++
++/*** Bit definitions ***/
++#define ARC_AUX_HALT (1 << 25)
++#define ARC_DEBUG_HALT (1 << 1)
++#define FALSE 0
++#define TRUE 1
++#define BIT0 (1<<0)
++#define BIT1 (1<<1)
++#define BIT2 (1<<2)
++#define BIT3 (1<<3)
++#define BIT4 (1<<4)
++#define BIT5 (1<<5)
++#define BIT6 (1<<6)
++#define BIT7 (1<<7)
++#define BIT8 (1<<8)
++#define BIT9 (1<<9)
++#define BIT10 (1<<10)
++#define BIT11 (1<<11)
++#define BIT12 (1<<12)
++#define BIT13 (1<<13)
++#define BIT14 (1<<14)
++#define BIT15 (1<<15)
++#define BIT16 (1<<16)
++#define BIT17 (1<<17)
++#define BIT18 (1<<18)
++#define BIT19 (1<<19)
++#define BIT20 (1<<20)
++#define BIT21 (1<<21)
++#define BIT22 (1<<22)
++#define BIT23 (1<<23)
++#define BIT24 (1<<24)
++#define BIT25 (1<<25)
++#define BIT26 (1<<26)
++#define BIT27 (1<<27)
++#define BIT28 (1<<28)
++#define BIT29 (1<<29)
++#define BIT30 (1<<30)
++#define BIT31 (1<<31)
++
++// CRI_CCR0 Register definitions
++#define CLK_2M_MODE_ENABLE BIT6
++#define ACL_CLK_MODE_ENABLE BIT4
++#define FDF_CLK_MODE_ENABLE BIT2
++#define STM_CLK_MODE_ENABLE BIT0
++
++// CRI_RST Register definitions
++#define FDF_SRST BIT3
++#define MTE_SRST BIT2
++#define FCI_SRST BIT1
++#define AAI_SRST BIT0
++
++// MEI_TO_ARC_INTERRUPT Register definitions
++#define MEI_TO_ARC_INT1 BIT3
++#define MEI_TO_ARC_INT0 BIT2
++#define MEI_TO_ARC_CS_DONE BIT1 //need to check
++#define MEI_TO_ARC_MSGAV BIT0
++
++// ARC_TO_MEI_INTERRUPT Register definitions
++#define ARC_TO_MEI_INT1 BIT8
++#define ARC_TO_MEI_INT0 BIT7
++#define ARC_TO_MEI_CS_REQ BIT6
++#define ARC_TO_MEI_DBG_DONE BIT5
++#define ARC_TO_MEI_MSGACK BIT4
++#define ARC_TO_MEI_NO_ACCESS BIT3
++#define ARC_TO_MEI_CHECK_AAITX BIT2
++#define ARC_TO_MEI_CHECK_AAIRX BIT1
++#define ARC_TO_MEI_MSGAV BIT0
++
++// ARC_TO_MEI_INTERRUPT_MASK Register definitions
++#define GP_INT1_EN BIT8
++#define GP_INT0_EN BIT7
++#define CS_REQ_EN BIT6
++#define DBG_DONE_EN BIT5
++#define MSGACK_EN BIT4
++#define NO_ACC_EN BIT3
++#define AAITX_EN BIT2
++#define AAIRX_EN BIT1
++#define MSGAV_EN BIT0
++
++#define MEI_SOFT_RESET BIT0
++
++#define HOST_MSTR BIT0
++
++#define JTAG_MASTER_MODE 0x0
++#define MEI_MASTER_MODE HOST_MSTR
++
++// MEI_DEBUG_DECODE Register definitions
++#define MEI_DEBUG_DEC_MASK (0x3)
++#define MEI_DEBUG_DEC_AUX_MASK (0x0)
++#define ME_DBG_DECODE_DMP1_MASK (0x1)
++#define MEI_DEBUG_DEC_DMP2_MASK (0x2)
++#define MEI_DEBUG_DEC_CORE_MASK (0x3)
++
++#define AUX_STATUS (0x0)
++#define AUX_ARC_GPIO_CTRL (0x10C)
++#define AUX_ARC_GPIO_DATA (0x10D)
++// ARC_TO_MEI_MAILBOX[11] is a special location used to indicate
++// page swap requests.
++#if defined(CONFIG_DANUBE)
++#define OMBOX_BASE 0xDF80
++#define ARC_TO_MEI_MAILBOX 0xDFA0
++#define IMBOX_BASE 0xDFC0
++#define MEI_TO_ARC_MAILBOX 0xDFD0
++#elif defined(CONFIG_AMAZON_SE) || defined(CONFIG_AR9) || defined(CONFIG_VR9)
++#define OMBOX_BASE 0xAF80
++#define ARC_TO_MEI_MAILBOX 0xAFA0
++#define IMBOX_BASE 0xAFC0
++#define MEI_TO_ARC_MAILBOX 0xAFD0
++#endif
++
++#define MEI_TO_ARC_MAILBOXR (MEI_TO_ARC_MAILBOX + 0x2C)
++#define ARC_MEI_MAILBOXR (ARC_TO_MEI_MAILBOX + 0x2C)
++#define OMBOX1 (OMBOX_BASE+0x4)
++
++// Codeswap request messages are indicated by setting BIT31
++#define OMB_CODESWAP_MESSAGE_MSG_TYPE_MASK (0x80000000)
++
++// Clear Eoc messages received are indicated by setting BIT17
++#define OMB_CLEAREOC_INTERRUPT_CODE (0x00020000)
++#define OMB_REBOOT_INTERRUPT_CODE (1 << 18)
++
++/*
++** Swap page header
++*/
++// Page must be loaded at boot time if size field has BIT31 set
++#define BOOT_FLAG (BIT31)
++#define BOOT_FLAG_MASK ~BOOT_FLAG
++
++#define FREE_RELOAD 1
++#define FREE_SHOWTIME 2
++#define FREE_ALL 3
++
++// marcos
++#define IFX_MEI_WRITE_REGISTER_L(data,addr) *((volatile u32*)(addr)) = (u32)(data)
++#define IFX_MEI_READ_REGISTER_L(addr) (*((volatile u32*)(addr)))
++#define SET_BIT(reg, mask) reg |= (mask)
++#define CLEAR_BIT(reg, mask) reg &= (~mask)
++#define CLEAR_BITS(reg, mask) CLEAR_BIT(reg, mask)
++//#define SET_BITS(reg, mask) SET_BIT(reg, mask)
++#define SET_BITFIELD(reg, mask, off, val) {reg &= (~mask); reg |= (val << off);}
++
++#define ALIGN_SIZE ( 1L<<10 ) //1K size align
++#define MEM_ALIGN(addr) (((addr) + ALIGN_SIZE - 1) & ~ (ALIGN_SIZE -1) )
++
++// swap marco
++#define MEI_HALF_WORD_SWAP(data) {data = ((data & 0xffff)<<16) + ((data & 0xffff0000)>>16);}
++#define MEI_BYTE_SWAP(data) {data = ((data & 0xff)<<24) + ((data & 0xff00)<<8)+ ((data & 0xff0000)>>8)+ ((data & 0xff000000)>>24);}
++
++
++#ifdef CONFIG_PROC_FS
++typedef struct reg_entry
++{
++ int *flag;
++ char name[30]; /* big enough to hold names */
++ char description[100]; /* big enough to hold description */
++ unsigned short low_ino;
++} reg_entry_t;
++#endif
++// Swap page header describes size in 32-bit words, load location, and image offset
++// for program and/or data segments
++typedef struct _arc_swp_page_hdr {
++ u32 p_offset; //Offset bytes of progseg from beginning of image
++ u32 p_dest; //Destination addr of progseg on processor
++ u32 p_size; //Size in 32-bitwords of program segment
++ u32 d_offset; //Offset bytes of dataseg from beginning of image
++ u32 d_dest; //Destination addr of dataseg on processor
++ u32 d_size; //Size in 32-bitwords of data segment
++} ARC_SWP_PAGE_HDR;
++
++/*
++** Swap image header
++*/
++#define GET_PROG 0 // Flag used for program mem segment
++#define GET_DATA 1 // Flag used for data mem segment
++
++// Image header contains size of image, checksum for image, and count of
++// page headers. Following that are 'count' page headers followed by
++// the code and/or data segments to be loaded
++typedef struct _arc_img_hdr {
++ u32 size; // Size of binary image in bytes
++ u32 checksum; // Checksum for image
++ u32 count; // Count of swp pages in image
++ ARC_SWP_PAGE_HDR page[1]; // Should be "count" pages - '1' to make compiler happy
++} ARC_IMG_HDR;
++
++typedef struct smmu_mem_info {
++ int type;
++ int boot;
++ unsigned long nCopy;
++ unsigned long size;
++ unsigned char *address;
++ unsigned char *org_address;
++} smmu_mem_info_t;
++
++#ifdef __KERNEL__
++typedef struct ifx_mei_device_private {
++ int modem_ready;
++ int arcmsgav;
++ int cmv_reply;
++ int cmv_waiting;
++ // Mei to ARC CMV count, reply count, ARC Indicator count
++ int modem_ready_cnt;
++ int cmv_count;
++ int reply_count;
++ unsigned long image_size;
++ int nBar;
++ u16 Recent_indicator[MSG_LENGTH];
++
++ u16 CMV_RxMsg[MSG_LENGTH] __attribute__ ((aligned (4)));
++
++ smmu_mem_info_t adsl_mem_info[MAX_BAR_REGISTERS];
++ ARC_IMG_HDR *img_hdr;
++ // to wait for arc cmv reply, sleep on wait_queue_arcmsgav;
++ wait_queue_head_t wait_queue_arcmsgav;
++ wait_queue_head_t wait_queue_modemready;
++ struct semaphore mei_cmv_sema;
++} ifx_mei_device_private_t;
++#endif
++typedef struct winhost_message {
++ union {
++ u16 RxMessage[MSG_LENGTH] __attribute__ ((aligned (4)));
++ u16 TxMessage[MSG_LENGTH] __attribute__ ((aligned (4)));
++ } msg;
++} DSL_DEV_WinHost_Message_t;
++/********************************************************************************************************
++ * DSL CPE API Driver Stack Interface Definitions
++ * *****************************************************************************************************/
++/** IOCTL codes for bsp driver */
++#define DSL_IOC_MEI_BSP_MAGIC 's'
++
++#define DSL_FIO_BSP_DSL_START _IO (DSL_IOC_MEI_BSP_MAGIC, 0)
++#define DSL_FIO_BSP_RUN _IO (DSL_IOC_MEI_BSP_MAGIC, 1)
++#define DSL_FIO_BSP_FREE_RESOURCE _IO (DSL_IOC_MEI_BSP_MAGIC, 2)
++#define DSL_FIO_BSP_RESET _IO (DSL_IOC_MEI_BSP_MAGIC, 3)
++#define DSL_FIO_BSP_REBOOT _IO (DSL_IOC_MEI_BSP_MAGIC, 4)
++#define DSL_FIO_BSP_HALT _IO (DSL_IOC_MEI_BSP_MAGIC, 5)
++#define DSL_FIO_BSP_BOOTDOWNLOAD _IO (DSL_IOC_MEI_BSP_MAGIC, 6)
++#define DSL_FIO_BSP_JTAG_ENABLE _IO (DSL_IOC_MEI_BSP_MAGIC, 7)
++#define DSL_FIO_FREE_RESOURCE _IO (DSL_IOC_MEI_BSP_MAGIC, 8)
++#define DSL_FIO_ARC_MUX_TEST _IO (DSL_IOC_MEI_BSP_MAGIC, 9)
++#define DSL_FIO_BSP_REMOTE _IOW (DSL_IOC_MEI_BSP_MAGIC, 10, u32)
++#define DSL_FIO_BSP_GET_BASE_ADDRESS _IOR (DSL_IOC_MEI_BSP_MAGIC, 11, u32)
++#define DSL_FIO_BSP_IS_MODEM_READY _IOR (DSL_IOC_MEI_BSP_MAGIC, 12, u32)
++#define DSL_FIO_BSP_GET_VERSION _IOR (DSL_IOC_MEI_BSP_MAGIC, 13, DSL_DEV_Version_t)
++#define DSL_FIO_BSP_CMV_WINHOST _IOWR(DSL_IOC_MEI_BSP_MAGIC, 14, DSL_DEV_WinHost_Message_t)
++#define DSL_FIO_BSP_CMV_READ _IOWR(DSL_IOC_MEI_BSP_MAGIC, 15, DSL_DEV_MeiReg_t)
++#define DSL_FIO_BSP_CMV_WRITE _IOW (DSL_IOC_MEI_BSP_MAGIC, 16, DSL_DEV_MeiReg_t)
++#define DSL_FIO_BSP_DEBUG_READ _IOWR(DSL_IOC_MEI_BSP_MAGIC, 17, DSL_DEV_MeiDebug_t)
++#define DSL_FIO_BSP_DEBUG_WRITE _IOWR(DSL_IOC_MEI_BSP_MAGIC, 18, DSL_DEV_MeiDebug_t)
++#define DSL_FIO_BSP_GET_CHIP_INFO _IOR (DSL_IOC_MEI_BSP_MAGIC, 19, DSL_DEV_HwVersion_t)
++
++#define DSL_DEV_MEIDEBUG_BUFFER_SIZES 512
++
++typedef struct DSL_DEV_MeiDebug
++{
++ DSL_uint32_t iAddress;
++ DSL_uint32_t iCount;
++ DSL_uint32_t buffer[DSL_DEV_MEIDEBUG_BUFFER_SIZES];
++} DSL_DEV_MeiDebug_t; /* meidebug */
++
++/**
++ * Structure is used for debug access only.
++ * Refer to configure option INCLUDE_ADSL_WINHOST_DEBUG */
++typedef struct struct_meireg
++{
++ /*
++ * Specifies that address for debug access */
++ unsigned long iAddress;
++ /*
++ * Specifies the pointer to the data that has to be written or returns a
++ * pointer to the data that has been read out*/
++ unsigned long iData;
++} DSL_DEV_MeiReg_t; /* meireg */
++
++typedef struct DSL_DEV_Device
++{
++ DSL_int_t nInUse; /* modem state, update by bsp driver, */
++ DSL_void_t *pPriv;
++ DSL_uint32_t base_address; /* mei base address */
++ DSL_int_t nIrq[2]; /* irq number */
++#define IFX_DFEIR 0
++#define IFX_DYING_GASP 1
++ DSL_DEV_MeiDebug_t lop_debugwr; /* dying gasp */
++#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,0))
++ struct module *owner;
++#endif
++} DSL_DEV_Device_t; /* ifx_adsl_device_t */
++
++#define DSL_DEV_PRIVATE(dev) ((ifx_mei_device_private_t*)(dev->pPriv))
++
++typedef struct DSL_DEV_Version /* ifx_adsl_bsp_version */
++{
++ unsigned long major;
++ unsigned long minor;
++ unsigned long revision;
++} DSL_DEV_Version_t; /* ifx_adsl_bsp_version_t */
++
++typedef struct DSL_DEV_ChipInfo
++{
++ unsigned long major;
++ unsigned long minor;
++} DSL_DEV_HwVersion_t;
++
++typedef struct
++{
++ DSL_uint8_t dummy;
++} DSL_DEV_DeviceConfig_t;
++
++/** error code definitions */
++typedef enum DSL_DEV_MeiError
++{
++ DSL_DEV_MEI_ERR_SUCCESS = 0,
++ DSL_DEV_MEI_ERR_FAILURE = -1,
++ DSL_DEV_MEI_ERR_MAILBOX_FULL = -2,
++ DSL_DEV_MEI_ERR_MAILBOX_EMPTY = -3,
++ DSL_DEV_MEI_ERR_MAILBOX_TIMEOUT = -4
++} DSL_DEV_MeiError_t; /* MEI_ERROR */
++
++typedef enum {
++ DSL_BSP_MEMORY_READ=0,
++ DSL_BSP_MEMORY_WRITE,
++} DSL_BSP_MemoryAccessType_t; /* ifx_adsl_memory_access_type_t */
++
++typedef enum
++{
++ DSL_LED_LINK_ID=0,
++ DSL_LED_DATA_ID
++} DSL_DEV_LedId_t; /* ifx_adsl_led_id_t */
++
++typedef enum
++{
++ DSL_LED_LINK_TYPE=0,
++ DSL_LED_DATA_TYPE
++} DSL_DEV_LedType_t; /* ifx_adsl_led_type_t */
++
++typedef enum
++{
++ DSL_LED_HD_CPU=0,
++ DSL_LED_HD_FW
++} DSL_DEV_LedHandler_t; /* ifx_adsl_led_handler_t */
++
++typedef enum {
++ DSL_LED_ON=0,
++ DSL_LED_OFF,
++ DSL_LED_FLASH,
++} DSL_DEV_LedMode_t; /* ifx_adsl_led_mode_t */
++
++typedef enum {
++ DSL_CPU_HALT=0,
++ DSL_CPU_RUN,
++ DSL_CPU_RESET,
++} DSL_DEV_CpuMode_t; /* ifx_adsl_cpu_mode_t */
++
++#if 0
++typedef enum {
++ DSL_BSP_EVENT_DYING_GASP = 0,
++ DSL_BSP_EVENT_CEOC_IRQ,
++} DSL_BSP_Event_id_t; /* ifx_adsl_event_id_t */
++
++typedef union DSL_BSP_CB_Param
++{
++ DSL_uint32_t nIrqMessage;
++} DSL_BSP_CB_Param_t; /* ifx_adsl_cbparam_t */
++
++typedef struct DSL_BSP_CB_Event
++{
++ DSL_BSP_Event_id_t nID;
++ DSL_DEV_Device_t *pDev;
++ DSL_BSP_CB_Param_t *pParam;
++} DSL_BSP_CB_Event_t; /* ifx_adsl_cb_event_t */
++#endif
++
++/* external functions (from the BSP Driver) */
++extern DSL_DEV_Device_t* DSL_BSP_DriverHandleGet(int, int);
++extern DSL_int_t DSL_BSP_DriverHandleDelete(DSL_DEV_Device_t *);
++extern DSL_DEV_MeiError_t DSL_BSP_FWDownload(DSL_DEV_Device_t *, const DSL_char_t *, DSL_uint32_t, DSL_int32_t *, DSL_int32_t *);
++extern int DSL_BSP_KernelIoctls(DSL_DEV_Device_t *, unsigned int, unsigned long);
++extern DSL_DEV_MeiError_t DSL_BSP_SendCMV(DSL_DEV_Device_t *, DSL_uint16_t *, DSL_int_t, DSL_uint16_t *);
++extern DSL_DEV_MeiError_t DSL_BSP_AdslLedInit(DSL_DEV_Device_t *, DSL_DEV_LedId_t, DSL_DEV_LedType_t, DSL_DEV_LedHandler_t);
++extern DSL_DEV_MeiError_t DSL_BSP_Showtime(DSL_DEV_Device_t *, DSL_uint32_t, DSL_uint32_t);
++extern int DSL_BSP_ATMLedCBRegister( int (*ifx_adsl_ledcallback)(void));
++extern DSL_DEV_MeiError_t DSL_BSP_MemoryDebugAccess(DSL_DEV_Device_t *, DSL_BSP_MemoryAccessType_t, DSL_uint32_t, DSL_uint32_t *, DSL_uint32_t);
++extern volatile DSL_DEV_Device_t *adsl_dev;
++
++/**
++ * Dummy structure by now to show mechanism of extended data that will be
++ * provided within event callback itself.
++ * */
++typedef struct
++{
++ /**
++ * Dummy value */
++ DSL_uint32_t nDummy1;
++} DSL_BSP_CB_Event1DataDummy_t;
++
++/**
++ * Dummy structure by now to show mechanism of extended data that will be
++ * provided within event callback itself.
++ * */
++typedef struct
++{
++ /**
++ * Dummy value */
++ DSL_uint32_t nDummy2;
++} DSL_BSP_CB_Event2DataDummy_t;
++
++/**
++ * encapsulate all data structures that are necessary for status event
++ * callbacks.
++ * */
++typedef union
++{
++ DSL_BSP_CB_Event1DataDummy_t dataEvent1;
++ DSL_BSP_CB_Event2DataDummy_t dataEvent2;
++} DSL_BSP_CB_DATA_Union_t;
++
++
++typedef enum
++{
++ /**
++ * Informs the upper layer driver (DSL CPE API) about a reboot request from the
++ * firmware.
++ * \note This event does NOT include any additional data.
++ * More detailed information upon reboot reason has to be requested from
++ * upper layer software via CMV (INFO 109) if necessary. */
++ DSL_BSP_CB_FIRST = 0,
++ DSL_BSP_CB_DYING_GASP,
++ DSL_BSP_CB_CEOC_IRQ,
++ DSL_BSP_CB_FIRMWARE_REBOOT,
++ /**
++ * Delimiter only */
++ DSL_BSP_CB_LAST
++} DSL_BSP_CB_Type_t;
++
++/**
++ * Specifies the common event type that has to be used for registering and
++ * signalling of interrupts/autonomous status events from MEI BSP Driver.
++ *
++ * \param pDev
++ * Context pointer from MEI BSP Driver.
++ *
++ * \param IFX_ADSL_BSP_CallbackType_t
++ * Specifies the event callback type (reason of callback). Regrading to the
++ * setting of this value the data which is included in the following union
++ * might have different meanings.
++ * Please refer to the description of the union to get information about the
++ * meaning of the included data.
++ *
++ * \param pData
++ * Data according to \ref DSL_BSP_CB_DATA_Union_t.
++ * If this pointer is NULL there is no additional data available.
++ *
++ * \return depending on event
++ */
++typedef int (*DSL_BSP_EventCallback_t)
++(
++ DSL_DEV_Device_t *pDev,
++ DSL_BSP_CB_Type_t nCallbackType,
++ DSL_BSP_CB_DATA_Union_t *pData
++);
++
++typedef struct {
++ DSL_BSP_EventCallback_t function;
++ DSL_BSP_CB_Type_t event;
++ DSL_BSP_CB_DATA_Union_t *pData;
++} DSL_BSP_EventCallBack_t;
++
++extern int DSL_BSP_EventCBRegister(DSL_BSP_EventCallBack_t *);
++extern int DSL_BSP_EventCBUnregister(DSL_BSP_EventCallBack_t *);
++
++/** Modem states */
++#define DSL_DEV_STAT_InitState 0x0000
++#define DSL_DEV_STAT_ReadyState 0x0001
++#define DSL_DEV_STAT_FailState 0x0002
++#define DSL_DEV_STAT_IdleState 0x0003
++#define DSL_DEV_STAT_QuietState 0x0004
++#define DSL_DEV_STAT_GhsState 0x0005
++#define DSL_DEV_STAT_FullInitState 0x0006
++#define DSL_DEV_STAT_ShowTimeState 0x0007
++#define DSL_DEV_STAT_FastRetrainState 0x0008
++#define DSL_DEV_STAT_LoopDiagMode 0x0009
++#define DSL_DEV_STAT_ShortInit 0x000A /* Bis short initialization */
++
++#define DSL_DEV_STAT_CODESWAP_COMPLETE 0x0002
++
++#endif //IFXMIPS_MEI_H
+--- a/configure.in
++++ b/configure.in
+@@ -310,7 +310,7 @@
+ AC_ARG_ENABLE(kernelbuild,
+ AC_HELP_STRING(--enable-kernel-build=x,Set the target kernel build path),
+ [
+- if test -e $enableval/include/linux/autoconf.h; then
++ if test -e $enableval/include/linux/autoconf.h -o -e $enableval/include/generated/autoconf.h; then
+ AC_SUBST([KERNEL_BUILD_PATH],[$enableval])
+ else
+ AC_MSG_ERROR([The kernel build directory is not valid or not configured!])
+@@ -333,12 +333,12 @@
+ echo Set the lib_ifxos include path $enableval
+ AC_SUBST([IFXOS_INCLUDE_PATH],[$enableval])
+ else
+- echo -e Set the default lib_ifxos include path $DEFAULT_IFXOS_INCLUDE_PATH
++ echo Set the default lib_ifxos include path $DEFAULT_IFXOS_INCLUDE_PATH
+ AC_SUBST([IFXOS_INCLUDE_PATH],[$DEFAULT_IFXOS_INCLUDE_PATH])
+ fi
+ ],
+ [
+- echo -e Set the default lib_ifxos include path $DEFAULT_IFXOS_INCLUDE_PATH
++ echo Set the default lib_ifxos include path $DEFAULT_IFXOS_INCLUDE_PATH
+ AC_SUBST([IFXOS_INCLUDE_PATH],[$DEFAULT_IFXOS_INCLUDE_PATH])
+ ]
+ )
+@@ -1702,73 +1702,73 @@
+ AC_SUBST([DISTCHECK_CONFIGURE_PARAMS],[$CONFIGURE_OPTIONS])
+
+ AC_CONFIG_COMMANDS_PRE([
+-echo -e "------------------------------------------------------------------------"
+-echo -e " Configuration for drv_dsl_cpe_api:"
+-echo -e " Configure model type: $DSL_CONFIG_MODEL_TYPE"
+-echo -e " Source code location: $srcdir"
+-echo -e " Compiler: $CC"
+-echo -e " Compiler c-flags: $CFLAGS"
+-echo -e " Extra compiler c-flags: $EXTRA_DRV_CFLAGS"
+-echo -e " Host System Type: $host"
+-echo -e " Install path: $prefix"
+-echo -e " Linux kernel include path: $KERNEL_INCL_PATH"
+-echo -e " Linux kernel build path: $KERNEL_BUILD_PATH"
+-echo -e " Linux kernel architecture: $KERNEL_ARCH"
+-echo -e " Include IFXOS: $INCLUDE_DSL_CPE_API_IFXOS_SUPPORT"
+-echo -e " IFXOS include path: $IFXOS_INCLUDE_PATH"
+-echo -e " Driver Include Path $DSL_DRIVER_INCL_PATH"
+-echo -e " DSL device: $DSL_DEVICE_NAME"
+-echo -e " Max device number: $DSL_DRV_MAX_DEVICE_NUMBER"
+-echo -e " Channels per line: $DSL_CHANNELS_PER_LINE"
+-echo -e " Build lib (only for kernel 2.6) $DSL_CPE_API_LIBRARY_BUILD_2_6"
+-echo -e " DSL data led flash frequency: $DSL_DATA_LED_FLASH_FREQUENCY Hz"
+-echo -e " Disable debug prints: $DSL_DEBUG_DISABLE"
+-echo -e " Preselection of max. debug level: $DSL_DBG_MAX_LEVEL_SET"
+-echo -e " Preselected max. debug level: $DSL_DBG_MAX_LEVEL_PRE"
+-echo -e " Include deprecated functions: $INCLUDE_DEPRECATED"
+-echo -e " Include Device Exception Codes: $INCLUDE_DEVICE_EXCEPTION_CODES"
+-echo -e " Include FW request support: $INCLUDE_FW_REQUEST_SUPPORT"
+-echo -e " Include ADSL trace buffer: $INCLUDE_DSL_CPE_TRACE_BUFFER"
+-echo -e " Include ADSL MIB: $INCLUDE_DSL_ADSL_MIB"
+-echo -e " Include ADSL LED: $INCLUDE_ADSL_LED"
+-echo -e " Include CEOC: $INCLUDE_DSL_CEOC"
+-echo -e " Include config get support: $INCLUDE_DSL_CONFIG_GET"
+-echo -e " Include System i/f configuration: $INCLUDE_DSL_SYSTEM_INTERFACE"
+-echo -e " Include Resource Statistics: $INCLUDE_DSL_RESOURCE_STATISTICS"
+-echo -e " Include Framing Parameters: $INCLUDE_DSL_FRAMING_PARAMETERS"
+-echo -e " Include G997 Line Inventory: $INCLUDE_DSL_G997_LINE_INVENTORY"
+-echo -e " Include G997 Framing Parameters: $INCLUDE_DSL_G997_FRAMING_PARAMETERS"
+-echo -e " Include G997 per tone data: $INCLUDE_DSL_G997_PER_TONE"
+-echo -e " Include G997 status: $INCLUDE_DSL_G997_STATUS"
+-echo -e " Include G997 alarm: $INCLUDE_DSL_G997_ALARM"
+-echo -e " Include DSL Bonding: $INCLUDE_DSL_BONDING"
+-echo -e " Include Misc Line Status $INCLUDE_DSL_CPE_MISC_LINE_STATUS"
+-echo -e " Include DELT: $INCLUDE_DSL_DELT"
+-echo -e " Include DELT data static storage: $DSL_CPE_STATIC_DELT_DATA"
+-echo -e " Include PM: $INCLUDE_DSL_PM"
+-echo -e " Include PM config: $INCLUDE_DSL_CPE_PM_CONFIG"
+-echo -e " Include PM total: $INCLUDE_DSL_CPE_PM_TOTAL_COUNTERS"
+-echo -e " Include PM history: $INCLUDE_DSL_CPE_PM_HISTORY"
+-echo -e " Include PM showtime: $INCLUDE_DSL_CPE_PM_SHOWTIME_COUNTERS"
+-echo -e " Include PM optional: $INCLUDE_DSL_CPE_PM_OPTIONAL_PARAMETERS"
+-echo -e " Include PM line: $INCLUDE_DSL_CPE_PM_LINE_COUNTERS"
+-echo -e " Include PM line event showtime: $INCLUDE_DSL_CPE_PM_LINE_EVENT_SHOWTIME_COUNTERS"
+-echo -e " Include PM channel: $INCLUDE_DSL_CPE_PM_CHANNEL_COUNTERS"
+-echo -e " Include PM channel extended: $INCLUDE_DSL_CPE_PM_CHANNEL_EXT_COUNTERS"
+-echo -e " Include PM data path: $INCLUDE_DSL_CPE_PM_DATA_PATH_COUNTERS"
+-echo -e " Include PM data path failure: $INCLUDE_DSL_CPE_PM_DATA_PATH_FAILURE_COUNTERS"
+-echo -e " Include PM ReTx: $INCLUDE_DSL_CPE_PM_RETX_COUNTERS"
+-echo -e " Include PM line threshold: $INCLUDE_DSL_CPE_PM_LINE_THRESHOLDS"
+-echo -e " Include PM channel threshold: $INCLUDE_DSL_CPE_PM_CHANNEL_THRESHOLDS"
+-echo -e " Include PM data path threshold: $INCLUDE_DSL_CPE_PM_DATA_PATH_THRESHOLDS"
+-echo -e " Include PM ReTx threshold: $INCLUDE_DSL_CPE_PM_RETX_THRESHOLDS"
+-echo -e " Include FW memory free support: $INCLUDE_DSL_FIRMWARE_MEMORY_FREE"
+-echo -e "----------------------- deprectated ! ----------------------------------"
+-echo -e " Include PM line failure: $INCLUDE_DSL_CPE_PM_LINE_FAILURE_COUNTERS"
+-echo -e ""
+-echo -e " Settings:"
+-echo -e " Configure options: $CONFIGURE_OPTIONS"
+-echo -e "------------------------------------------------------------------------"
++echo "------------------------------------------------------------------------"
++echo " Configuration for drv_dsl_cpe_api:"
++echo " Configure model type: $DSL_CONFIG_MODEL_TYPE"
++echo " Source code location: $srcdir"
++echo " Compiler: $CC"
++echo " Compiler c-flags: $CFLAGS"
++echo " Extra compiler c-flags: $EXTRA_DRV_CFLAGS"
++echo " Host System Type: $host"
++echo " Install path: $prefix"
++echo " Linux kernel include path: $KERNEL_INCL_PATH"
++echo " Linux kernel build path: $KERNEL_BUILD_PATH"
++echo " Linux kernel architecture: $KERNEL_ARCH"
++echo " Include IFXOS: $INCLUDE_DSL_CPE_API_IFXOS_SUPPORT"
++echo " IFXOS include path: $IFXOS_INCLUDE_PATH"
++echo " Driver Include Path $DSL_DRIVER_INCL_PATH"
++echo " DSL device: $DSL_DEVICE_NAME"
++echo " Max device number: $DSL_DRV_MAX_DEVICE_NUMBER"
++echo " Channels per line: $DSL_CHANNELS_PER_LINE"
++echo " Build lib (only for kernel 2.6) $DSL_CPE_API_LIBRARY_BUILD_2_6"
++echo " DSL data led flash frequency: $DSL_DATA_LED_FLASH_FREQUENCY Hz"
++echo " Disable debug prints: $DSL_DEBUG_DISABLE"
++echo " Preselection of max. debug level: $DSL_DBG_MAX_LEVEL_SET"
++echo " Preselected max. debug level: $DSL_DBG_MAX_LEVEL_PRE"
++echo " Include deprecated functions: $INCLUDE_DEPRECATED"
++echo " Include Device Exception Codes: $INCLUDE_DEVICE_EXCEPTION_CODES"
++echo " Include FW request support: $INCLUDE_FW_REQUEST_SUPPORT"
++echo " Include ADSL trace buffer: $INCLUDE_DSL_CPE_TRACE_BUFFER"
++echo " Include ADSL MIB: $INCLUDE_DSL_ADSL_MIB"
++echo " Include ADSL LED: $INCLUDE_ADSL_LED"
++echo " Include CEOC: $INCLUDE_DSL_CEOC"
++echo " Include config get support: $INCLUDE_DSL_CONFIG_GET"
++echo " Include System i/f configuration: $INCLUDE_DSL_SYSTEM_INTERFACE"
++echo " Include Resource Statistics: $INCLUDE_DSL_RESOURCE_STATISTICS"
++echo " Include Framing Parameters: $INCLUDE_DSL_FRAMING_PARAMETERS"
++echo " Include G997 Line Inventory: $INCLUDE_DSL_G997_LINE_INVENTORY"
++echo " Include G997 Framing Parameters: $INCLUDE_DSL_G997_FRAMING_PARAMETERS"
++echo " Include G997 per tone data: $INCLUDE_DSL_G997_PER_TONE"
++echo " Include G997 status: $INCLUDE_DSL_G997_STATUS"
++echo " Include G997 alarm: $INCLUDE_DSL_G997_ALARM"
++echo " Include DSL Bonding: $INCLUDE_DSL_BONDING"
++echo " Include Misc Line Status $INCLUDE_DSL_CPE_MISC_LINE_STATUS"
++echo " Include DELT: $INCLUDE_DSL_DELT"
++echo " Include DELT data static storage: $DSL_CPE_STATIC_DELT_DATA"
++echo " Include PM: $INCLUDE_DSL_PM"
++echo " Include PM config: $INCLUDE_DSL_CPE_PM_CONFIG"
++echo " Include PM total: $INCLUDE_DSL_CPE_PM_TOTAL_COUNTERS"
++echo " Include PM history: $INCLUDE_DSL_CPE_PM_HISTORY"
++echo " Include PM showtime: $INCLUDE_DSL_CPE_PM_SHOWTIME_COUNTERS"
++echo " Include PM optional: $INCLUDE_DSL_CPE_PM_OPTIONAL_PARAMETERS"
++echo " Include PM line: $INCLUDE_DSL_CPE_PM_LINE_COUNTERS"
++echo " Include PM line event showtime: $INCLUDE_DSL_CPE_PM_LINE_EVENT_SHOWTIME_COUNTERS"
++echo " Include PM channel: $INCLUDE_DSL_CPE_PM_CHANNEL_COUNTERS"
++echo " Include PM channel extended: $INCLUDE_DSL_CPE_PM_CHANNEL_EXT_COUNTERS"
++echo " Include PM data path: $INCLUDE_DSL_CPE_PM_DATA_PATH_COUNTERS"
++echo " Include PM data path failure: $INCLUDE_DSL_CPE_PM_DATA_PATH_FAILURE_COUNTERS"
++echo " Include PM ReTx: $INCLUDE_DSL_CPE_PM_RETX_COUNTERS"
++echo " Include PM line threshold: $INCLUDE_DSL_CPE_PM_LINE_THRESHOLDS"
++echo " Include PM channel threshold: $INCLUDE_DSL_CPE_PM_CHANNEL_THRESHOLDS"
++echo " Include PM data path threshold: $INCLUDE_DSL_CPE_PM_DATA_PATH_THRESHOLDS"
++echo " Include PM ReTx threshold: $INCLUDE_DSL_CPE_PM_RETX_THRESHOLDS"
++echo " Include FW memory free support: $INCLUDE_DSL_FIRMWARE_MEMORY_FREE"
++echo "----------------------- deprectated ! ----------------------------------"
++echo " Include PM line failure: $INCLUDE_DSL_CPE_PM_LINE_FAILURE_COUNTERS"
++echo ""
++echo " Settings:"
++echo " Configure options: $CONFIGURE_OPTIONS"
++echo "------------------------------------------------------------------------"
+ ])
+
+ AC_CONFIG_FILES([Makefile src/Makefile])
+--- a/src/Makefile.am
++++ b/src/Makefile.am
+@@ -303,7 +303,7 @@
+ drv_dsl_cpe_api_OBJS = "$(subst .c,.o,$(filter %.c,$(drv_dsl_cpe_api_SOURCES)))"
+
+ drv_dsl_cpe_api.ko: $(drv_dsl_cpe_api_SOURCES)
+- @echo -e "drv_dsl_cpe_api: Making Linux 2.6.x kernel object"
++ @echo "drv_dsl_cpe_api: Making Linux 2.6.x kernel object"
+ if test ! -e common/drv_dsl_cpe_api.c ; then \
+ echo "copy source files (as links only!)"; \
+ for f in $(filter %.c,$(drv_dsl_cpe_api_SOURCES)); do \
+@@ -311,10 +311,10 @@
+ cp -s $(addprefix @abs_srcdir@/,$$f) $(PWD)/`dirname $$f`/ ; \
+ done \
+ fi
+- @echo -e "# drv_dsl_cpe_api: Generated to build Linux 2.6.x kernel object" > $(PWD)/Kbuild
+- @echo -e "obj-m := $(subst .ko,.o,$@)" >> $(PWD)/Kbuild
+- @echo -e "$(subst .ko,,$@)-y := $(drv_dsl_cpe_api_OBJS)" >> $(PWD)/Kbuild
+- @echo -e "EXTRA_CFLAGS := $(CFLAGS) -DHAVE_CONFIG_H $(drv_dsl_cpe_api_CFLAGS) $(DSL_DRIVER_INCL_PATH) $(IFXOS_INCLUDE_PATH) -I@abs_srcdir@/include -I$(PWD)/include" >> $(PWD)/Kbuild
++ @echo "# drv_dsl_cpe_api: Generated to build Linux 2.6.x kernel object" > $(PWD)/Kbuild
++ @echo "obj-m := $(subst .ko,.o,$@)" >> $(PWD)/Kbuild
++ @echo "$(subst .ko,,$@)-y := $(drv_dsl_cpe_api_OBJS)" >> $(PWD)/Kbuild
++ @echo "EXTRA_CFLAGS := $(CFLAGS) -DHAVE_CONFIG_H $(drv_dsl_cpe_api_CFLAGS) $(DSL_DRIVER_INCL_PATH) $(IFXOS_INCLUDE_PATH) -I@abs_srcdir@/include -I$(PWD)/include" >> $(PWD)/Kbuild
+ $(MAKE) ARCH=@KERNEL_ARCH@ -C @KERNEL_BUILD_PATH@ O=@KERNEL_BUILD_PATH@ M=$(PWD) modules
+
+ clean-generic:
+--- a/src/include/drv_dsl_cpe_os_linux.h
++++ b/src/include/drv_dsl_cpe_os_linux.h
+@@ -16,8 +16,6 @@
+ extern "C" {
+ #endif
+
+-#include <asm/ioctl.h>
+-#include <generated/autoconf.h>
+ #include <linux/module.h>
+ #include <linux/kernel.h>
+ #include <linux/init.h>
+@@ -26,8 +24,10 @@
+ #include <linux/spinlock.h>
+ #include <linux/sched.h>
+
+-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17))
+- #include <generated/utsrelease.h>
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33))
++#include <linux/utsrelease.h>
++#else
++#include <generated/utsrelease.h>
+ #endif
+
+ #include <linux/types.h>
+@@ -39,7 +39,8 @@
+ #include <linux/delay.h>
+ #include <linux/poll.h>
+ #include <asm/uaccess.h>
+-#include <linux/smp_lock.h>
++//#include <linux/smp_lock.h>
++#include <asm/ioctl.h>
+
+ #ifdef INCLUDE_DSL_CPE_API_IFXOS_SUPPORT
+ /** IFXOS includes*/
diff --git a/package/platform/lantiq/ltq-adsl/patches/110-fix_status_polling_loop.patch b/package/platform/lantiq/ltq-adsl/patches/110-fix_status_polling_loop.patch
new file mode 100644
index 0000000..870943d
--- /dev/null
+++ b/package/platform/lantiq/ltq-adsl/patches/110-fix_status_polling_loop.patch
@@ -0,0 +1,11 @@
+--- a/src/device/drv_dsl_cpe_device_danube.c
++++ b/src/device/drv_dsl_cpe_device_danube.c
+@@ -4069,7 +4069,7 @@ static DSL_Error_t DSL_DRV_DANUBE_XTUSys
+
+ DSL_CTX_WRITE(pContext, nErrCode, xtseCurr, xtseCurr);
+
+- for (nRetry = 0; nRetry < 20; nRetry++)
++ for (nRetry = 0; nRetry < 20 && bStatusUpdated == DSL_FALSE; nRetry++)
+ {
+ /* Get STAT1 info*/
+ nErrCode = DSL_DRV_DANUBE_CmvRead(pContext, DSL_CMV_GROUP_STAT,
diff --git a/package/platform/lantiq/ltq-adsl/patches/120-platform.patch b/package/platform/lantiq/ltq-adsl/patches/120-platform.patch
new file mode 100644
index 0000000..48c7581
--- /dev/null
+++ b/package/platform/lantiq/ltq-adsl/patches/120-platform.patch
@@ -0,0 +1,72 @@
+Index: drv_dsl_cpe_api-3.24.4.4/src/common/drv_dsl_cpe_os_linux.c
+===================================================================
+--- drv_dsl_cpe_api-3.24.4.4.orig/src/common/drv_dsl_cpe_os_linux.c 2012-12-07 21:22:58.020256076 +0100
++++ drv_dsl_cpe_api-3.24.4.4/src/common/drv_dsl_cpe_os_linux.c 2012-12-07 21:31:13.156268489 +0100
+@@ -12,6 +12,7 @@
+
+ #define DSL_INTERN
+ #include <linux/device.h>
++#include <linux/platform_device.h>
+
+ #include "drv_dsl_cpe_api.h"
+ #include "drv_dsl_cpe_api_ioctl.h"
+@@ -1063,7 +1064,7 @@
+ #endif
+
+ /* Entry point of driver */
+-int __init DSL_ModuleInit(void)
++static int __devinit ltq_adsl_probe(struct platform_device *pdev)
+ {
+ struct class *dsl_class;
+ DSL_int_t i;
+@@ -1117,7 +1118,7 @@
+ return 0;
+ }
+
+-void __exit DSL_ModuleCleanup(void)
++static int __devexit ltq_adsl_remove(struct platform_device *pdev)
+ {
+ printk("Module will be unloaded"DSL_DRV_CRLF);
+
+@@ -1132,7 +1133,7 @@
+ (DSL_uint8_t**)&g_BndFpgaBase);
+ #endif /* defined(INCLUDE_DSL_CPE_API_VINAX) && defined(INCLUDE_DSL_BONDING)*/
+
+- return;
++ return 0;
+ }
+
+ #ifndef _lint
+@@ -1148,8 +1149,30 @@
+ MODULE_PARM_DESC(debug_level, "set to get more (1) or fewer (4) debug outputs");
+ #endif /* #ifndef DSL_DEBUG_DISABLE*/
+
+-module_init(DSL_ModuleInit);
+-module_exit(DSL_ModuleCleanup);
++static const struct of_device_id ltq_adsl_match[] = {
++#ifdef CONFIG_DANUBE
++ { .compatible = "lantiq,adsl-danube"},
++#elif defined CONFIG_AMAZON_SE
++ { .compatible = "lantiq,adsl-ase"},
++#elif defined CONFIG_AR9
++ { .compatible = "lantiq,adsl-arx100"},
++#endif
++ {},
++};
++MODULE_DEVICE_TABLE(of, ltq_adsl_match);
++
++static struct platform_driver ltq_adsl_driver = {
++ .probe = ltq_adsl_probe,
++ .remove = __devexit_p(ltq_adsl_remove),
++ .driver = {
++ .name = "adsl",
++ .owner = THIS_MODULE,
++ .of_match_table = ltq_adsl_match,
++ },
++};
++
++module_platform_driver(ltq_adsl_driver);
++
+ #endif /* #ifndef _lint*/
+
+ //EXPORT_SYMBOL(DSL_ModuleInit);
diff --git a/package/platform/lantiq/ltq-adsl/patches/130-linux3.8.patch b/package/platform/lantiq/ltq-adsl/patches/130-linux3.8.patch
new file mode 100644
index 0000000..21dbe6b
--- /dev/null
+++ b/package/platform/lantiq/ltq-adsl/patches/130-linux3.8.patch
@@ -0,0 +1,152 @@
+Index: drv_dsl_cpe_api-3.24.4.4/src/common/drv_dsl_cpe_os_linux.c
+===================================================================
+--- drv_dsl_cpe_api-3.24.4.4.orig/src/common/drv_dsl_cpe_os_linux.c 2013-03-14 11:44:50.318326078 +0100
++++ drv_dsl_cpe_api-3.24.4.4/src/common/drv_dsl_cpe_os_linux.c 2013-03-14 11:46:08.562329425 +0100
+@@ -11,6 +11,7 @@
+ #ifdef __LINUX__
+
+ #define DSL_INTERN
++#include <linux/kthread.h>
+ #include <linux/device.h>
+ #include <linux/platform_device.h>
+
+@@ -40,7 +41,7 @@
+ static DSL_int_t DSL_DRV_Ioctls(DSL_DRV_inode_t * pINode, DSL_DRV_file_t * pFile,
+ DSL_uint_t nCommand, unsigned long nArg);
+ #else
+-static DSL_int_t DSL_DRV_Ioctls(DSL_DRV_file_t * pFile,
++static long DSL_DRV_Ioctls(DSL_DRV_file_t * pFile,
+ DSL_uint_t nCommand, unsigned long nArg);
+ #endif
+ static int DSL_DRV_Open(DSL_DRV_inode_t * ino, DSL_DRV_file_t * fil);
+@@ -184,7 +185,7 @@
+ DSL_uint_t nCommand,
+ unsigned long nArg)
+ #else
+-static DSL_int_t DSL_DRV_Ioctls(
++static long DSL_DRV_Ioctls(
+ DSL_DRV_file_t * pFile,
+ DSL_uint_t nCommand,
+ unsigned long nArg)
+@@ -521,9 +522,9 @@
+ - IFX_SUCCESS on success
+ - IFX_ERROR on error
+ */
+-DSL_DRV_STATIC DSL_int32_t DSL_DRV_KernelThreadStartup(
+- DSL_DRV_ThreadCtrl_t *pThrCntrl)
++static int DSL_DRV_KernelThreadStartup(void *data)
+ {
++ DSL_DRV_ThreadCtrl_t *pThrCntrl = (DSL_DRV_ThreadCtrl_t*) data;
+ DSL_int32_t retVal = -1;
+ #ifndef _lint
+
+@@ -546,30 +547,6 @@
+ (DSL_NULL, "ENTER - Kernel Thread Startup <%s>" DSL_DRV_CRLF,
+ pThrCntrl->thrParams.pName));
+
+- /* do LINUX specific setup */
+-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
+- daemonize();
+- reparent_to_init();
+-
+- /* lock the kernel. A new kernel thread starts without
+- the big kernel lock, regardless of the lock state
+- of the creator (the lock level is *not* inheritated)
+- */
+- lock_kernel();
+-
+- /* Don't care about any signals. */
+- siginitsetinv(&current->blocked, 0);
+-
+- /* set name of this process */
+- strcpy(kthread->comm, pThrCntrl->thrParams.pName);
+-
+- /* let others run */
+- unlock_kernel();
+-#else
+- daemonize(pThrCntrl->thrParams.pName);
+-
+-#endif
+-
+ /*DSL_DRV_ThreadPriorityModify(pThrCntrl->nPriority);*/
+
+ pThrCntrl->thrParams.bRunning = 1;
+@@ -629,7 +606,7 @@
+ if (DSL_DRV_THREAD_INIT_VALID(pThrCntrl) == DSL_FALSE)
+ {
+ /* set thread function arguments */
+- strcpy(pThrCntrl->thrParams.pName, pName);
++ snprintf(pThrCntrl->thrParams.pName, DSL_DRV_THREAD_NAME_LEN, "adsl - %s", pName);
+ pThrCntrl->nPriority = nPriority;
+ pThrCntrl->thrParams.nArg1 = nArg1;
+ pThrCntrl->thrParams.nArg2 = nArg2;
+@@ -639,9 +616,7 @@
+ init_completion(&pThrCntrl->thrCompletion);
+
+ /* start kernel thread via the wrapper function */
+- pThrCntrl->pid = kernel_thread( (DSL_DRV_KERNEL_THREAD_StartRoutine)DSL_DRV_KernelThreadStartup,
+- (void *)pThrCntrl,
+- DSL_DRV_DRV_THREAD_OPTIONS);
++ pThrCntrl->pid = kthread_run(DSL_DRV_KernelThreadStartup, (void *)pThrCntrl, pThrCntrl->thrParams.pName);
+
+ pThrCntrl->bValid = DSL_TRUE;
+
+@@ -1064,12 +1039,12 @@
+ #endif
+
+ /* Entry point of driver */
+-static int __devinit ltq_adsl_probe(struct platform_device *pdev)
++static int ltq_adsl_probe(struct platform_device *pdev)
+ {
+ struct class *dsl_class;
+ DSL_int_t i;
+
+- printk(DSL_DRV_CRLF DSL_DRV_CRLF "Infineon CPE API Driver version: %s" DSL_DRV_CRLF,
++ printk("Infineon CPE API Driver version: %s" DSL_DRV_CRLF,
+ &(dsl_cpe_api_version[4]));
+
+ DSL_DRV_MemSet( ifxDevices, 0, sizeof(DSL_devCtx_t) * DSL_DRV_MAX_DEVICE_NUMBER );
+@@ -1118,7 +1093,7 @@
+ return 0;
+ }
+
+-static int __devexit ltq_adsl_remove(struct platform_device *pdev)
++static int ltq_adsl_remove(struct platform_device *pdev)
+ {
+ printk("Module will be unloaded"DSL_DRV_CRLF);
+
+@@ -1163,7 +1138,7 @@
+
+ static struct platform_driver ltq_adsl_driver = {
+ .probe = ltq_adsl_probe,
+- .remove = __devexit_p(ltq_adsl_remove),
++ .remove = ltq_adsl_remove,
+ .driver = {
+ .name = "adsl",
+ .owner = THIS_MODULE,
+Index: drv_dsl_cpe_api-3.24.4.4/src/include/drv_dsl_cpe_os_lint_map.h
+===================================================================
+--- drv_dsl_cpe_api-3.24.4.4.orig/src/include/drv_dsl_cpe_os_lint_map.h 2009-02-24 21:44:54.000000000 +0100
++++ drv_dsl_cpe_api-3.24.4.4/src/include/drv_dsl_cpe_os_lint_map.h 2013-03-14 11:44:50.330326079 +0100
+@@ -247,7 +247,7 @@
+ DSL_DRV_ThreadFunction_t pThrFct;
+
+ /** Kernel thread process ID */
+- DSL_int32_t pid;
++ struct task_struct *pid;
+
+ /** requested kernel thread priority */
+ DSL_int32_t nPriority;
+Index: drv_dsl_cpe_api-3.24.4.4/src/include/drv_dsl_cpe_os_linux.h
+===================================================================
+--- drv_dsl_cpe_api-3.24.4.4.orig/src/include/drv_dsl_cpe_os_linux.h 2013-03-14 11:44:50.298326077 +0100
++++ drv_dsl_cpe_api-3.24.4.4/src/include/drv_dsl_cpe_os_linux.h 2013-03-14 11:44:50.330326079 +0100
+@@ -288,7 +288,7 @@
+ DSL_DRV_ThreadFunction_t pThrFct;
+
+ /** Kernel thread process ID */
+- DSL_int32_t pid;
++ struct task_struct *pid;
+
+ /** requested kernel thread priority */
+ DSL_int32_t nPriority;
diff --git a/package/platform/lantiq/ltq-atm/.svn/entries b/package/platform/lantiq/ltq-atm/.svn/entries
new file mode 100644
index 0000000..c5f2cec
--- /dev/null
+++ b/package/platform/lantiq/ltq-atm/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/platform/lantiq/ltq-atm
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-14T18:42:47.996516Z
+36017
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+src
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+4598cc65b4343c363919703ffeac8bf5
+2012-12-15T02:00:33.317354Z
+34693
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1480
+
diff --git a/package/platform/lantiq/ltq-atm/.svn/text-base/Makefile.svn-base b/package/platform/lantiq/ltq-atm/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..e6e0059
--- /dev/null
+++ b/package/platform/lantiq/ltq-atm/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,51 @@
+# Copyright (C) 2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=ltq-atm
+PKG_RELEASE:=1
+PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/ltq-atm-$(BUILD_VARIANT)
+
+PKG_MAINTAINER:=John Crispin <blogic@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/ltq-atm-template
+ SECTION:=sys
+ CATEGORY:=Kernel modules
+ SUBMENU:=Network Devices
+ TITLE:=atm driver for $(1)
+ URL:=http://www.lantiq.com/
+ VARIANT:=$(1)
+ DEPENDS:=@TARGET_lantiq_$(2) +kmod-atm +br2684ctl
+ FILES:=$(PKG_BUILD_DIR)/ltq_atm_$(1).ko
+ AUTOLOAD:=$(call AutoLoad,52,ltq_atm_$(1))
+endef
+
+KernelPackage/ltq-atm-danube=$(call KernelPackage/ltq-atm-template,danube,xway)
+KernelPackage/ltq-atm-ar9=$(call KernelPackage/ltq-atm-template,ar9,xway)
+KernelPackage/ltq-atm-ase=$(call KernelPackage/ltq-atm-template,ase,ase)
+KernelPackage/ltq-atm-vr9=$(call KernelPackage/ltq-atm-template,vr9,xway)
+
+define Build/Prepare
+ $(INSTALL_DIR) $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+ cd $(LINUX_DIR); \
+ ARCH=mips CROSS_COMPILE="$(KERNEL_CROSS)" \
+ $(MAKE) BUILD_VARIANT=$(BUILD_VARIANT) M=$(PKG_BUILD_DIR) V=1 modules
+endef
+
+$(eval $(call KernelPackage,ltq-atm-danube))
+$(eval $(call KernelPackage,ltq-atm-ase))
+$(eval $(call KernelPackage,ltq-atm-ar9))
+$(eval $(call KernelPackage,ltq-atm-vr9))
diff --git a/package/platform/lantiq/ltq-atm/Makefile b/package/platform/lantiq/ltq-atm/Makefile
new file mode 100644
index 0000000..e6e0059
--- /dev/null
+++ b/package/platform/lantiq/ltq-atm/Makefile
@@ -0,0 +1,51 @@
+# Copyright (C) 2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=ltq-atm
+PKG_RELEASE:=1
+PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/ltq-atm-$(BUILD_VARIANT)
+
+PKG_MAINTAINER:=John Crispin <blogic@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/ltq-atm-template
+ SECTION:=sys
+ CATEGORY:=Kernel modules
+ SUBMENU:=Network Devices
+ TITLE:=atm driver for $(1)
+ URL:=http://www.lantiq.com/
+ VARIANT:=$(1)
+ DEPENDS:=@TARGET_lantiq_$(2) +kmod-atm +br2684ctl
+ FILES:=$(PKG_BUILD_DIR)/ltq_atm_$(1).ko
+ AUTOLOAD:=$(call AutoLoad,52,ltq_atm_$(1))
+endef
+
+KernelPackage/ltq-atm-danube=$(call KernelPackage/ltq-atm-template,danube,xway)
+KernelPackage/ltq-atm-ar9=$(call KernelPackage/ltq-atm-template,ar9,xway)
+KernelPackage/ltq-atm-ase=$(call KernelPackage/ltq-atm-template,ase,ase)
+KernelPackage/ltq-atm-vr9=$(call KernelPackage/ltq-atm-template,vr9,xway)
+
+define Build/Prepare
+ $(INSTALL_DIR) $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+ cd $(LINUX_DIR); \
+ ARCH=mips CROSS_COMPILE="$(KERNEL_CROSS)" \
+ $(MAKE) BUILD_VARIANT=$(BUILD_VARIANT) M=$(PKG_BUILD_DIR) V=1 modules
+endef
+
+$(eval $(call KernelPackage,ltq-atm-danube))
+$(eval $(call KernelPackage,ltq-atm-ase))
+$(eval $(call KernelPackage,ltq-atm-ar9))
+$(eval $(call KernelPackage,ltq-atm-vr9))
diff --git a/package/platform/lantiq/ltq-atm/src/.svn/entries b/package/platform/lantiq/ltq-atm/src/.svn/entries
new file mode 100644
index 0000000..4ed6b5e
--- /dev/null
+++ b/package/platform/lantiq/ltq-atm/src/.svn/entries
@@ -0,0 +1,810 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/platform/lantiq/ltq-atm/src
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-14T18:42:47.996516Z
+36017
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+ifxmips_atm_danube.c
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+7b27dad18d78aeb89e6c68e86f8ef0af
+2012-12-15T02:00:33.317354Z
+34693
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+6279
+
+ifxmips_atm_fw_ar9_retx.h
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+8ae394bc4b692cb5ea43bf6f45972a02
+2012-12-15T02:00:33.317354Z
+34693
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+58657
+
+ifxmips_atm_fw_danube.h
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+37e562d37f0de7e25d4c24e2a9753066
+2012-12-15T02:00:33.317354Z
+34693
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+40915
+
+ifxmips_atm_fw_regs_vr9.h
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+57a3455f2f0d4e15c0c4fb22861caf6d
+2012-12-15T02:00:33.317354Z
+34693
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3036
+
+ifxmips_atm_fw_danube_retx.h
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+d678f20fba9e26e8ebf3dfa49498a311
+2012-12-15T02:00:33.317354Z
+34693
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+58711
+
+ifxmips_atm_ppe_common.h
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+fa4b7ce9aa6b5d938501efb4551eee42
+2012-12-15T02:00:33.317354Z
+34693
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+13371
+
+ltq_atm.c
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+65ffc36ab285f00c9c1a52b2244f355b
+2013-03-14T18:42:47.996516Z
+36017
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+57038
+
+ifxmips_atm_ppe_ar9.h
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+514d25738adac1cec7e0189d5ef3a465
+2012-12-15T02:00:33.317354Z
+34693
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+10796
+
+ifxmips_atm_ppe_danube.h
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+5abfc92a8f61b1aa4c15c107684afaac
+2012-12-15T02:00:33.317354Z
+34693
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+6129
+
+ifxmips_atm_fw_regs_common.h
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+b65f000315984e966c3d90a7695ac5e7
+2012-12-15T02:00:33.317354Z
+34693
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+17785
+
+ifxmips_atm_amazon_se.c
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+5d9b6d4c791603d14e8a51faf7db0032
+2012-12-15T02:00:33.317354Z
+34693
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+8602
+
+ifxmips_atm_fw_regs_ar9.h
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+04dd763b241748721d6a3d7926b58ba9
+2012-12-15T02:00:33.317354Z
+34693
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+9378
+
+ifxmips_atm_fw_amazon_se.h
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+e86818a16b96909bdbe142223893191b
+2012-12-15T02:00:33.317354Z
+34693
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+41357
+
+ifxmips_atm_fw_regs_danube.h
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+3cc96b2c02cd1496030c76acf917c907
+2012-12-15T02:00:33.317354Z
+34693
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3167
+
+ifxmips_atm_vr9.c
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+c0bd4ce35ec2429dde5d883a84ca2cee
+2012-12-15T02:00:33.317354Z
+34693
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4539
+
+ifxmips_atm_fw_vr9.h
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+2a4c5e069d270ce9675e900791b74cb9
+2012-12-15T02:00:33.317354Z
+34693
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+39936
+
+ifxmips_atm_ppe_amazon_se.h
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+2c1192b817165c331e000aa91cb3a913
+2012-12-15T02:00:33.317354Z
+34693
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5153
+
+ifxmips_atm_ppe_vr9.h
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+0a3c92f66e19c84c34b294f1bafca6e9
+2012-12-15T02:00:33.317354Z
+34693
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+10974
+
+ifxmips_atm_ar9.c
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+8ff2ecf9c23486eb62789a51b066cfcd
+2012-12-15T02:00:33.317354Z
+34693
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5608
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+b3d96dabc4948bbb59645ab49ddda3b4
+2012-12-15T02:00:33.317354Z
+34693
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+582
+
+ifxmips_atm_fw_ar9.h
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+ae270ff2a6a75b56841b2718b35e6f90
+2012-12-15T02:00:33.317354Z
+34693
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+39576
+
+ifxmips_atm_core.h
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+22aea4f83adf62d988f076ef2a00991b
+2012-12-15T02:00:33.317354Z
+34693
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+7847
+
+ifxmips_atm_fw_regs_amazon_se.h
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+9f85b50f2e1436fc91e6cf59e1677298
+2012-12-15T02:00:33.317354Z
+34693
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3307
+
diff --git a/package/platform/lantiq/ltq-atm/src/.svn/text-base/Makefile.svn-base b/package/platform/lantiq/ltq-atm/src/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..3d68c8f
--- /dev/null
+++ b/package/platform/lantiq/ltq-atm/src/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,23 @@
+ifeq ($(BUILD_VARIANT),danube)
+ CFLAGS_MODULE = -DCONFIG_DANUBE
+ obj-m = ltq_atm_danube.o
+ ltq_atm_danube-objs = ltq_atm.o ifxmips_atm_danube.o
+endif
+
+ifeq ($(BUILD_VARIANT),ase)
+ CFLAGS_MODULE = -DCONFIG_AMAZON_SE
+ obj-m = ltq_atm_ase.o
+ ltq_atm_ase-objs = ltq_atm.o ifxmips_atm_amazon_se.o
+endif
+
+ifeq ($(BUILD_VARIANT),ar9)
+ CFLAGS_MODULE = -DCONFIG_AR9
+ obj-m = ltq_atm_ar9.o
+ ltq_atm_ar9-objs = ltq_atm.o ifxmips_atm_ar9.o
+endif
+
+ifeq ($(BUILD_VARIANT),vr9)
+ CFLAGS_MODULE = -DCONFIG_VR9
+ obj-m = ltq_atm_vr9.o
+ ltq_atm_vr9-objs = ltq_atm.o ifxmips_atm_vr9.o
+endif
diff --git a/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_amazon_se.c.svn-base b/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_amazon_se.c.svn-base
new file mode 100644
index 0000000..6e8975b
--- /dev/null
+++ b/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_amazon_se.c.svn-base
@@ -0,0 +1,341 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_atm_amazon_se.c
+** PROJECT : UEIP
+** MODULES : ATM
+**
+** DATE : 7 Jul 2009
+** AUTHOR : Xu Liang
+** DESCRIPTION : ATM driver common source file (core functions)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 07 JUL 2009 Xu Liang Init Version
+*******************************************************************************/
+
+
+
+/*
+ * ####################################
+ * Head File
+ * ####################################
+ */
+
+/*
+ * Common Head File
+ */
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/version.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/proc_fs.h>
+#include <linux/init.h>
+#include <linux/ioctl.h>
+#include <asm/delay.h>
+
+/*
+ * Chip Specific Head File
+ */
+#include "ifxmips_atm_core.h"
+#include "ifxmips_atm_fw_amazon_se.h"
+
+#include <lantiq_soc.h>
+
+#define EMA_CMD_BUF_LEN 0x0040
+#define EMA_CMD_BASE_ADDR (0x00001580 << 2)
+#define EMA_DATA_BUF_LEN 0x0100
+#define EMA_DATA_BASE_ADDR (0x00001900 << 2)
+#define EMA_WRITE_BURST 0x2
+#define EMA_READ_BURST 0x2
+
+
+
+/*
+ * ####################################
+ * Definition
+ * ####################################
+ */
+
+/*
+ * EMA Settings
+ */
+#define EMA_CMD_BUF_LEN 0x0040
+#define EMA_CMD_BASE_ADDR (0x00001580 << 2)
+#define EMA_DATA_BUF_LEN 0x0100
+#define EMA_DATA_BASE_ADDR (0x00000B00 << 2)
+#define EMA_WRITE_BURST 0x2
+#define EMA_READ_BURST 0x2
+
+
+
+/*
+ * ####################################
+ * Declaration
+ * ####################################
+ */
+
+/*
+ * Hardware Init/Uninit Functions
+ */
+static inline void init_pmu(void);
+static inline void uninit_pmu(void);
+static inline void reset_ppe(void);
+static inline void init_ema(void);
+static inline void init_mailbox(void);
+static inline void init_atm_tc(void);
+static inline void clear_share_buffer(void);
+
+
+
+/*
+ * ####################################
+ * Local Variable
+ * ####################################
+ */
+
+
+
+/*
+ * ####################################
+ * Local Function
+ * ####################################
+ */
+#define IFX_PMU_MODULE_PPE_SLL01 BIT(19)
+#define IFX_PMU_MODULE_PPE_TC BIT(21)
+#define IFX_PMU_MODULE_PPE_EMA BIT(22)
+#define IFX_PMU_MODULE_PPE_QSB BIT(18)
+#define IFX_PMU_MODULE_TPE BIT(13)
+#define IFX_PMU_MODULE_DSL_DFE BIT(9)
+
+static inline void init_pmu(void)
+{
+ //*(unsigned long *)0xBF10201C &= ~((1 << 15) | (1 << 13) | (1 << 9));
+ //PPE_TOP_PMU_SETUP(IFX_PMU_ENABLE);
+/* PPE_SLL01_PMU_SETUP(IFX_PMU_ENABLE);
+ PPE_TC_PMU_SETUP(IFX_PMU_ENABLE);
+ PPE_EMA_PMU_SETUP(IFX_PMU_ENABLE);
+ //PPE_QSB_PMU_SETUP(IFX_PMU_ENABLE);
+ PPE_TPE_PMU_SETUP(IFX_PMU_ENABLE);
+ DSL_DFE_PMU_SETUP(IFX_PMU_ENABLE);*/
+ ltq_pmu_enable(IFX_PMU_MODULE_PPE_SLL01 |
+ IFX_PMU_MODULE_PPE_TC |
+ IFX_PMU_MODULE_PPE_EMA |
+ IFX_PMU_MODULE_TPE |
+ IFX_PMU_MODULE_DSL_DFE);
+}
+
+static inline void uninit_pmu(void)
+{
+ /*PPE_SLL01_PMU_SETUP(IFX_PMU_DISABLE);
+ PPE_TC_PMU_SETUP(IFX_PMU_DISABLE);
+ PPE_EMA_PMU_SETUP(IFX_PMU_DISABLE);
+ //PPE_QSB_PMU_SETUP(IFX_PMU_DISABLE);
+ PPE_TPE_PMU_SETUP(IFX_PMU_DISABLE);
+ DSL_DFE_PMU_SETUP(IFX_PMU_DISABLE);
+ //PPE_TOP_PMU_SETUP(IFX_PMU_DISABLE);*/
+}
+
+static inline void reset_ppe(void)
+{
+#if 0 //MODULE
+ unsigned int etop_cfg;
+ unsigned int etop_mdio_cfg;
+ unsigned int etop_ig_plen_ctrl;
+ unsigned int enet_mac_cfg;
+
+ etop_cfg = *IFX_PP32_ETOP_CFG;
+ etop_mdio_cfg = *IFX_PP32_ETOP_MDIO_CFG;
+ etop_ig_plen_ctrl = *IFX_PP32_ETOP_IG_PLEN_CTRL;
+ enet_mac_cfg = *IFX_PP32_ENET_MAC_CFG;
+
+ *IFX_PP32_ETOP_CFG = (*IFX_PP32_ETOP_CFG & ~0x03C0) | 0x0001;
+
+ // reset PPE
+ ifx_rcu_rst(IFX_RCU_DOMAIN_PPE, IFX_RCU_MODULE_ATM);
+
+ *IFX_PP32_ETOP_MDIO_CFG = etop_mdio_cfg;
+ *IFX_PP32_ETOP_IG_PLEN_CTRL = etop_ig_plen_ctrl;
+ *IFX_PP32_ENET_MAC_CFG = enet_mac_cfg;
+ *IFX_PP32_ETOP_CFG = etop_cfg;
+#endif
+}
+
+static inline void init_ema(void)
+{
+ IFX_REG_W32((EMA_CMD_BUF_LEN << 16) | (EMA_CMD_BASE_ADDR >> 2), EMA_CMDCFG);
+ IFX_REG_W32((EMA_DATA_BUF_LEN << 16) | (EMA_DATA_BASE_ADDR >> 2), EMA_DATACFG);
+ IFX_REG_W32(0x000000FF, EMA_IER);
+ IFX_REG_W32(EMA_READ_BURST | (EMA_WRITE_BURST << 2), EMA_CFG);
+}
+
+static inline void init_mailbox(void)
+{
+ IFX_REG_W32(0xFFFFFFFF, MBOX_IGU1_ISRC);
+ IFX_REG_W32(0x00000000, MBOX_IGU1_IER);
+ IFX_REG_W32(0xFFFFFFFF, MBOX_IGU3_ISRC);
+ IFX_REG_W32(0x00000000, MBOX_IGU3_IER);
+}
+
+static inline void init_atm_tc(void)
+{
+ IFX_REG_W32(0x0000, DREG_AT_CTRL);
+ IFX_REG_W32(0x0000, DREG_AR_CTRL);
+ IFX_REG_W32(0x0, DREG_AT_IDLE0);
+ IFX_REG_W32(0x0, DREG_AT_IDLE1);
+ IFX_REG_W32(0x0, DREG_AR_IDLE0);
+ IFX_REG_W32(0x0, DREG_AR_IDLE1);
+ IFX_REG_W32(0x40, RFBI_CFG);
+ IFX_REG_W32(0x0700, SFSM_DBA0);
+ IFX_REG_W32(0x0818, SFSM_DBA1);
+ IFX_REG_W32(0x0930, SFSM_CBA0);
+ IFX_REG_W32(0x0944, SFSM_CBA1);
+ IFX_REG_W32(0x14014, SFSM_CFG0);
+ IFX_REG_W32(0x14014, SFSM_CFG1);
+ IFX_REG_W32(0x0958, FFSM_DBA0);
+ IFX_REG_W32(0x09AC, FFSM_DBA1);
+ IFX_REG_W32(0x10006, FFSM_CFG0);
+ IFX_REG_W32(0x10006, FFSM_CFG1);
+ IFX_REG_W32(0x00000001, FFSM_IDLE_HEAD_BC0);
+ IFX_REG_W32(0x00000001, FFSM_IDLE_HEAD_BC1);
+}
+
+static inline void clear_share_buffer(void)
+{
+ volatile u32 *p = SB_RAM0_ADDR(0);
+ unsigned int i;
+
+ for ( i = 0; i < SB_RAM0_DWLEN + SB_RAM1_DWLEN; i++ )
+ IFX_REG_W32(0, p++);
+}
+
+/*
+ * Description:
+ * Download PPE firmware binary code.
+ * Input:
+ * src --- u32 *, binary code buffer
+ * dword_len --- unsigned int, binary code length in DWORD (32-bit)
+ * Output:
+ * int --- 0: Success
+ * else: Error Code
+ */
+static inline int pp32_download_code(u32 *code_src, unsigned int code_dword_len, u32 *data_src, unsigned int data_dword_len)
+{
+ volatile u32 *dest;
+
+ if ( code_src == 0 || ((unsigned long)code_src & 0x03) != 0
+ || data_src == 0 || ((unsigned long)data_src & 0x03) != 0 )
+ return -1;
+
+ if ( code_dword_len <= CDM_CODE_MEMORYn_DWLEN(0) )
+ IFX_REG_W32(0x00, CDM_CFG);
+ else
+ IFX_REG_W32(0x04, CDM_CFG);
+
+ /* copy code */
+ dest = CDM_CODE_MEMORY(0, 0);
+ while ( code_dword_len-- > 0 )
+ IFX_REG_W32(*code_src++, dest++);
+
+ /* copy data */
+ dest = CDM_DATA_MEMORY(0, 0);
+ while ( data_dword_len-- > 0 )
+ IFX_REG_W32(*data_src++, dest++);
+
+ return 0;
+}
+
+
+
+/*
+ * ####################################
+ * Global Function
+ * ####################################
+ */
+
+extern void ase_fw_ver(unsigned int *major, unsigned int *minor)
+{
+ ASSERT(major != NULL, "pointer is NULL");
+ ASSERT(minor != NULL, "pointer is NULL");
+
+ *major = FW_VER_ID->major;
+ *minor = FW_VER_ID->minor;
+}
+
+void ase_init(void)
+{
+ init_pmu();
+
+ reset_ppe();
+
+ init_ema();
+
+ init_mailbox();
+
+ init_atm_tc();
+
+ clear_share_buffer();
+}
+
+void ase_shutdown(void)
+{
+ uninit_pmu();
+}
+
+/*
+ * Description:
+ * Initialize and start up PP32.
+ * Input:
+ * none
+ * Output:
+ * int --- 0: Success
+ * else: Error Code
+ */
+int ase_start(int pp32)
+{
+ int ret;
+
+ /* download firmware */
+ ret = pp32_download_code(firmware_binary_code, sizeof(firmware_binary_code) / sizeof(*firmware_binary_code), firmware_binary_data, sizeof(firmware_binary_data) / sizeof(*firmware_binary_data));
+ if ( ret != 0 )
+ return ret;
+
+ /* run PP32 */
+ IFX_REG_W32(DBG_CTRL_RESTART, PP32_DBG_CTRL);
+
+ /* idle for a while to let PP32 init itself */
+ udelay(10);
+
+ return 0;
+}
+
+/*
+ * Description:
+ * Halt PP32.
+ * Input:
+ * none
+ * Output:
+ * none
+ */
+void ase_stop(int pp32)
+{
+ /* halt PP32 */
+ IFX_REG_W32(DBG_CTRL_STOP, PP32_DBG_CTRL);
+}
+
+struct ltq_atm_ops ase_ops = {
+ .init = ase_init,
+ .shutdown = ase_shutdown,
+ .start = ase_start,
+ .stop = ase_stop,
+ .fw_ver = ase_fw_ver,
+};
+
diff --git a/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_ar9.c.svn-base b/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_ar9.c.svn-base
new file mode 100644
index 0000000..b68848b
--- /dev/null
+++ b/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_ar9.c.svn-base
@@ -0,0 +1,244 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_atm_ar9.c
+** PROJECT : UEIP
+** MODULES : ATM
+**
+** DATE : 7 Jul 2009
+** AUTHOR : Xu Liang
+** DESCRIPTION : ATM driver common source file (core functions)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 07 JUL 2009 Xu Liang Init Version
+*******************************************************************************/
+
+
+
+/*
+ * ####################################
+ * Head File
+ * ####################################
+ */
+
+/*
+ * Common Head File
+ */
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/version.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/proc_fs.h>
+#include <linux/init.h>
+#include <linux/ioctl.h>
+#include <asm/delay.h>
+
+/*
+ * Chip Specific Head File
+ */
+#include "ifxmips_atm_core.h"
+
+#include "ifxmips_atm_fw_ar9.h"
+#include "ifxmips_atm_fw_regs_ar9.h"
+
+#include <lantiq_soc.h>
+
+
+
+/*
+ * ####################################
+ * Definition
+ * ####################################
+ */
+
+/*
+ * EMA Settings
+ */
+#define EMA_CMD_BUF_LEN 0x0040
+#define EMA_CMD_BASE_ADDR (0x00003B80 << 2)
+#define EMA_DATA_BUF_LEN 0x0100
+#define EMA_DATA_BASE_ADDR (0x00003C00 << 2)
+#define EMA_WRITE_BURST 0x2
+#define EMA_READ_BURST 0x2
+
+
+
+/*
+ * ####################################
+ * Declaration
+ * ####################################
+ */
+
+/*
+ * Hardware Init/Uninit Functions
+ */
+static inline void init_pmu(void);
+static inline void uninit_pmu(void);
+static inline void reset_ppe(void);
+static inline void init_ema(void);
+static inline void init_mailbox(void);
+static inline void clear_share_buffer(void);
+
+
+
+/*
+ * ####################################
+ * Local Variable
+ * ####################################
+ */
+
+
+
+/*
+ * ####################################
+ * Local Function
+ * ####################################
+ */
+
+#define IFX_PMU_MODULE_PPE_SLL01 BIT(19)
+#define IFX_PMU_MODULE_PPE_TC BIT(21)
+#define IFX_PMU_MODULE_PPE_EMA BIT(22)
+#define IFX_PMU_MODULE_PPE_QSB BIT(18)
+#define IFX_PMU_MODULE_TPE BIT(13)
+#define IFX_PMU_MODULE_DSL_DFE BIT(9)
+
+static inline void init_pmu(void)
+{
+ ltq_pmu_enable(IFX_PMU_MODULE_PPE_SLL01 |
+ IFX_PMU_MODULE_PPE_TC |
+ IFX_PMU_MODULE_PPE_EMA |
+ IFX_PMU_MODULE_PPE_QSB |
+ IFX_PMU_MODULE_TPE |
+ IFX_PMU_MODULE_DSL_DFE);
+}
+
+static inline void uninit_pmu(void)
+{
+}
+
+static inline void reset_ppe(void)
+{
+#ifdef MODULE
+ // reset PPE
+// ifx_rcu_rst(IFX_RCU_DOMAIN_PPE, IFX_RCU_MODULE_ATM);
+#endif
+}
+
+static inline void init_ema(void)
+{
+ IFX_REG_W32((EMA_CMD_BUF_LEN << 16) | (EMA_CMD_BASE_ADDR >> 2), EMA_CMDCFG);
+ IFX_REG_W32((EMA_DATA_BUF_LEN << 16) | (EMA_DATA_BASE_ADDR >> 2), EMA_DATACFG);
+ IFX_REG_W32(0x000000FF, EMA_IER);
+ IFX_REG_W32(EMA_READ_BURST | (EMA_WRITE_BURST << 2), EMA_CFG);
+}
+
+static inline void init_mailbox(void)
+{
+ IFX_REG_W32(0xFFFFFFFF, MBOX_IGU1_ISRC);
+ IFX_REG_W32(0x00000000, MBOX_IGU1_IER);
+ IFX_REG_W32(0xFFFFFFFF, MBOX_IGU3_ISRC);
+ IFX_REG_W32(0x00000000, MBOX_IGU3_IER);
+}
+
+static inline void clear_share_buffer(void)
+{
+ volatile u32 *p = SB_RAM0_ADDR(0);
+ unsigned int i;
+
+ for ( i = 0; i < SB_RAM0_DWLEN + SB_RAM1_DWLEN + SB_RAM2_DWLEN + SB_RAM3_DWLEN + SB_RAM4_DWLEN; i++ )
+ IFX_REG_W32(0, p++);
+}
+
+static inline int pp32_download_code(u32 *code_src, unsigned int code_dword_len, u32 *data_src, unsigned int data_dword_len)
+{
+ volatile u32 *dest;
+
+ if ( code_src == 0 || ((unsigned long)code_src & 0x03) != 0
+ || data_src == 0 || ((unsigned long)data_src & 0x03) != 0 )
+ return -1;
+
+ if ( code_dword_len <= CDM_CODE_MEMORYn_DWLEN(0) )
+ IFX_REG_W32(0x00, CDM_CFG);
+ else
+ IFX_REG_W32(0x04, CDM_CFG);
+
+ /* copy code */
+ dest = CDM_CODE_MEMORY(0, 0);
+ while ( code_dword_len-- > 0 )
+ IFX_REG_W32(*code_src++, dest++);
+
+ /* copy data */
+ dest = CDM_DATA_MEMORY(0, 0);
+ while ( data_dword_len-- > 0 )
+ IFX_REG_W32(*data_src++, dest++);
+
+ return 0;
+}
+
+void ar9_fw_ver(unsigned int *major, unsigned int *minor)
+{
+ ASSERT(major != NULL, "pointer is NULL");
+ ASSERT(minor != NULL, "pointer is NULL");
+
+ *major = FW_VER_ID->major;
+ *minor = FW_VER_ID->minor;
+}
+
+void ar9_init(void)
+{
+ init_pmu();
+ reset_ppe();
+ init_ema();
+ init_mailbox();
+ clear_share_buffer();
+}
+
+void ar9_shutdown(void)
+{
+ ltq_pmu_disable(IFX_PMU_MODULE_PPE_SLL01 |
+ IFX_PMU_MODULE_PPE_TC |
+ IFX_PMU_MODULE_PPE_EMA |
+ IFX_PMU_MODULE_PPE_QSB |
+ IFX_PMU_MODULE_TPE |
+ IFX_PMU_MODULE_DSL_DFE);
+}
+
+int ar9_start(int pp32)
+{
+ int ret;
+
+ ret = pp32_download_code(ar9_fw_bin, sizeof(ar9_fw_bin) / sizeof(*ar9_fw_bin),
+ ar9_fw_data, sizeof(ar9_fw_data) / sizeof(*ar9_fw_data));
+ if ( ret != 0 )
+ return ret;
+
+ IFX_REG_W32(DBG_CTRL_RESTART, PP32_DBG_CTRL(0));
+
+ udelay(10);
+
+ return 0;
+}
+
+void ar9_stop(int pp32)
+{
+ IFX_REG_W32(DBG_CTRL_STOP, PP32_DBG_CTRL(0));
+}
+
+struct ltq_atm_ops ar9_ops = {
+ .init = ar9_init,
+ .shutdown = ar9_shutdown,
+ .start = ar9_start,
+ .stop = ar9_stop,
+ .fw_ver = ar9_fw_ver,
+};
+
+
diff --git a/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_core.h.svn-base b/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_core.h.svn-base
new file mode 100644
index 0000000..2f754c9
--- /dev/null
+++ b/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_core.h.svn-base
@@ -0,0 +1,245 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_atm_core.h
+** PROJECT : UEIP
+** MODULES : ATM
+**
+** DATE : 7 Jul 2009
+** AUTHOR : Xu Liang
+** DESCRIPTION : ATM driver header file (core functions)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 17 JUN 2009 Xu Liang Init Version
+*******************************************************************************/
+
+#ifndef IFXMIPS_ATM_CORE_H
+#define IFXMIPS_ATM_CORE_H
+
+
+#define INT_NUM_IM2_IRL24 (INT_NUM_IM2_IRL0 + 24)
+#define INT_NUM_IM2_IRL13 (INT_NUM_IM2_IRL0 + 13)
+#define CONFIG_IFXMIPS_DSL_CPE_MEI
+#define IFX_REG_W32(_v, _r) __raw_writel((_v), (volatile unsigned int *)(_r))
+#define IFX_REG_R32(_r) __raw_readl((volatile unsigned int *)(_r))
+#define IFX_REG_W32_MASK(_clr, _set, _r) IFX_REG_W32((IFX_REG_R32((_r)) & ~(_clr)) | (_set), (_r))
+#define SET_BITS(x, msb, lsb, value) (((x) & ~(((1 << ((msb) + 1)) - 1) ^ ((1 << (lsb)) - 1))) | (((value) & ((1 << (1 + (msb) - (lsb))) - 1)) << (lsb)))
+
+struct ltq_atm_ops {
+ void (*init)(void);
+ void (*shutdown)(void);
+
+ int (*start)(int pp32);
+ void (*stop)(int pp32);
+
+ void (*fw_ver)(unsigned int *major, unsigned int *minor);
+};
+
+#include <lantiq_atm.h>
+
+/*
+ * ####################################
+ * Definition
+ * ####################################
+ */
+
+/*
+ * Compile Options
+ */
+
+#define ENABLE_DEBUG 1
+
+#define ENABLE_ASSERT 1
+
+#define INLINE
+
+#define DEBUG_DUMP_SKB 1
+
+#define DEBUG_QOS 1
+
+#define DISABLE_QOS_WORKAROUND 0
+
+#define ENABLE_DBG_PROC 1
+
+#define ENABLE_FW_PROC 1
+
+#ifdef CONFIG_IFX_ATM_TASKLET
+ #define ENABLE_TASKLET 1
+#endif
+
+#ifdef CONFIG_IFX_ATM_RETX
+ #define ENABLE_ATM_RETX 1
+#endif
+
+#if defined(CONFIG_DSL_MEI_CPE_DRV) && !defined(CONFIG_IFXMIPS_DSL_CPE_MEI)
+ #define CONFIG_IFXMIPS_DSL_CPE_MEI 1
+#endif
+
+/*
+ * Debug/Assert/Error Message
+ */
+
+#define ifx_atm_dbg_enable 1
+
+#define DBG_ENABLE_MASK_ERR (1 << 0)
+#define DBG_ENABLE_MASK_DEBUG_PRINT (1 << 1)
+#define DBG_ENABLE_MASK_ASSERT (1 << 2)
+#define DBG_ENABLE_MASK_DUMP_SKB_RX (1 << 8)
+#define DBG_ENABLE_MASK_DUMP_SKB_TX (1 << 9)
+#define DBG_ENABLE_MASK_DUMP_QOS (1 << 10)
+#define DBG_ENABLE_MASK_DUMP_INIT (1 << 11)
+#define DBG_ENABLE_MASK_MAC_SWAP (1 << 12)
+#define DBG_ENABLE_MASK_ALL (DBG_ENABLE_MASK_ERR | DBG_ENABLE_MASK_DEBUG_PRINT | DBG_ENABLE_MASK_ASSERT | DBG_ENABLE_MASK_DUMP_SKB_RX | DBG_ENABLE_MASK_DUMP_SKB_TX | DBG_ENABLE_MASK_DUMP_QOS | DBG_ENABLE_MASK_DUMP_INIT | DBG_ENABLE_MASK_MAC_SWAP)
+
+#if defined(ENABLE_ASSERT) && ENABLE_ASSERT
+ #define ASSERT(cond, format, arg...) do { if ( (ifx_atm_dbg_enable & DBG_ENABLE_MASK_ASSERT) && !(cond) ) printk(KERN_ERR __FILE__ ":%d:%s: " format "\n", __LINE__, __FUNCTION__, ##arg); } while ( 0 )
+#else
+ #define ASSERT(cond, format, arg...)
+#endif
+
+
+/*
+ * Constants
+ */
+#define DEFAULT_TX_LINK_RATE 3200 // in cells
+
+/*
+ * ATM Port, QSB Queue, DMA RX/TX Channel Parameters
+ */
+#define ATM_PORT_NUMBER 2
+#define MAX_QUEUE_NUMBER 16
+#define OAM_RX_QUEUE 15
+#define QSB_RESERVE_TX_QUEUE 0
+#define FIRST_QSB_QID 1
+#define MAX_PVC_NUMBER (MAX_QUEUE_NUMBER - FIRST_QSB_QID)
+#define MAX_RX_DMA_CHANNEL_NUMBER 8
+#define MAX_TX_DMA_CHANNEL_NUMBER 16
+#define DATA_BUFFER_ALIGNMENT EMA_ALIGNMENT
+#define DESC_ALIGNMENT 8
+#define DEFAULT_RX_HUNT_BITTH 4
+
+/*
+ * RX DMA Channel Allocation
+ */
+#define RX_DMA_CH_OAM 0
+#define RX_DMA_CH_AAL 1
+#define RX_DMA_CH_TOTAL 2
+#define RX_DMA_CH_OAM_DESC_LEN 32
+#define RX_DMA_CH_OAM_BUF_SIZE ((CELL_SIZE + 14) & ~15)
+#define RX_DMA_CH_AAL_BUF_SIZE (2048 - 48)
+
+/*
+ * OAM Constants
+ */
+#define OAM_HTU_ENTRY_NUMBER 3
+#define OAM_F4_SEG_HTU_ENTRY 0
+#define OAM_F4_TOT_HTU_ENTRY 1
+#define OAM_F5_HTU_ENTRY 2
+#define OAM_F4_CELL_ID 0
+#define OAM_F5_CELL_ID 15
+#if defined(ENABLE_ATM_RETX) && ENABLE_ATM_RETX
+ #undef OAM_HTU_ENTRY_NUMBER
+ #define OAM_HTU_ENTRY_NUMBER 4
+ #define OAM_ARQ_HTU_ENTRY 3
+#endif
+
+/*
+ * RX Frame Definitions
+ */
+#define MAX_RX_PACKET_ALIGN_BYTES 3
+#define MAX_RX_PACKET_PADDING_BYTES 3
+#define RX_INBAND_TRAILER_LENGTH 8
+#define MAX_RX_FRAME_EXTRA_BYTES (RX_INBAND_TRAILER_LENGTH + MAX_RX_PACKET_ALIGN_BYTES + MAX_RX_PACKET_PADDING_BYTES)
+
+/*
+ * TX Frame Definitions
+ */
+#define MAX_TX_HEADER_ALIGN_BYTES 12
+#define MAX_TX_PACKET_ALIGN_BYTES 3
+#define MAX_TX_PACKET_PADDING_BYTES 3
+#define TX_INBAND_HEADER_LENGTH 8
+#define MAX_TX_FRAME_EXTRA_BYTES (TX_INBAND_HEADER_LENGTH + MAX_TX_HEADER_ALIGN_BYTES + MAX_TX_PACKET_ALIGN_BYTES + MAX_TX_PACKET_PADDING_BYTES)
+
+#define CELL_SIZE ATM_AAL0_SDU
+
+#if defined(ENABLE_ATM_RETX) && ENABLE_ATM_RETX
+ #define RETX_PLAYOUT_BUFFER_ORDER 6
+ #define RETX_PLAYOUT_BUFFER_SIZE (PAGE_SIZE * (1 << RETX_PLAYOUT_BUFFER_ORDER))
+ #define RETX_PLAYOUT_FW_BUFF_SIZE (RETX_PLAYOUT_BUFFER_SIZE / (32 * 56 /* cell size */))
+ #define RETX_POLLING_INTERVAL (HZ / 100 > 0 ? HZ / 100 : 1)
+#endif
+
+typedef struct {
+ unsigned int h;
+ unsigned int l;
+} ppe_u64_t;
+
+struct port {
+ unsigned int tx_max_cell_rate;
+ unsigned int tx_current_cell_rate;
+
+ struct atm_dev *dev;
+};
+
+struct connection {
+ struct atm_vcc *vcc;
+
+ volatile struct tx_descriptor *tx_desc;
+ unsigned int tx_desc_pos;
+ struct sk_buff **tx_skb;
+
+ unsigned int aal5_vcc_crc_err; /* number of packets with CRC error */
+ unsigned int aal5_vcc_oversize_sdu; /* number of packets with oversize error */
+
+ unsigned int port;
+};
+
+struct atm_priv_data {
+ unsigned long conn_table;
+ struct connection conn[MAX_PVC_NUMBER];
+
+ volatile struct rx_descriptor *aal_desc;
+ unsigned int aal_desc_pos;
+
+ volatile struct rx_descriptor *oam_desc;
+ unsigned char *oam_buf;
+ unsigned int oam_desc_pos;
+
+ struct port port[ATM_PORT_NUMBER];
+
+ unsigned int wrx_pdu; /* successfully received AAL5 packet */
+ unsigned int wrx_drop_pdu; /* AAL5 packet dropped by driver on RX */
+ unsigned int wtx_pdu; /* successfully transmitted AAL5 packet */
+ unsigned int wtx_err_pdu; /* error AAL5 packet */
+ unsigned int wtx_drop_pdu; /* AAL5 packet dropped by driver on TX */
+
+ unsigned int wrx_oam; /* successfully received OAM cell */
+ unsigned int wrx_drop_oam; /* OAM cell dropped by driver on RX */
+ unsigned int wtx_oam; /* successfully transmitted OAM cell */
+ unsigned int wtx_err_oam; /* error during transmiting OAM cell */
+ unsigned int wtx_drop_oam; /* OAM cell dropped by driver on TX */
+
+ ppe_u64_t wrx_total_byte;
+ ppe_u64_t wtx_total_byte;
+ unsigned int prev_wrx_total_byte;
+ unsigned int prev_wtx_total_byte;
+
+ void *aal_desc_base;
+ void *oam_desc_base;
+ void *oam_buf_base;
+ void *tx_desc_base;
+ void *tx_skb_base;
+};
+
+#include "ifxmips_atm_ppe_common.h"
+#include "ifxmips_atm_fw_regs_common.h"
+
+#endif
diff --git a/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_danube.c.svn-base b/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_danube.c.svn-base
new file mode 100644
index 0000000..9bab5b4
--- /dev/null
+++ b/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_danube.c.svn-base
@@ -0,0 +1,231 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_atm_danube.c
+** PROJECT : UEIP
+** MODULES : ATM
+**
+** DATE : 7 Jul 2009
+** AUTHOR : Xu Liang
+** DESCRIPTION : ATM driver common source file (core functions)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 07 JUL 2009 Xu Liang Init Version
+*******************************************************************************/
+
+
+
+/*
+ * ####################################
+ * Head File
+ * ####################################
+ */
+
+/*
+ * Common Head File
+ */
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/version.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/proc_fs.h>
+#include <linux/init.h>
+#include <linux/ioctl.h>
+#include <linux/delay.h>
+
+/*
+ * Chip Specific Head File
+ */
+#include "ifxmips_atm_core.h"
+
+#ifdef CONFIG_DANUBE
+
+#include "ifxmips_atm_fw_danube.h"
+#include "ifxmips_atm_fw_regs_danube.h"
+
+#include <lantiq_soc.h>
+
+#define EMA_CMD_BUF_LEN 0x0040
+#define EMA_CMD_BASE_ADDR (0x00001580 << 2)
+#define EMA_DATA_BUF_LEN 0x0100
+#define EMA_DATA_BASE_ADDR (0x00001900 << 2)
+#define EMA_WRITE_BURST 0x2
+#define EMA_READ_BURST 0x2
+
+static inline void reset_ppe(void);
+
+#define IFX_PMU_MODULE_PPE_SLL01 BIT(19)
+#define IFX_PMU_MODULE_PPE_TC BIT(21)
+#define IFX_PMU_MODULE_PPE_EMA BIT(22)
+#define IFX_PMU_MODULE_PPE_QSB BIT(18)
+#define IFX_PMU_MODULE_TPE BIT(13)
+#define IFX_PMU_MODULE_DSL_DFE BIT(9)
+
+static inline void reset_ppe(void)
+{
+/*#ifdef MODULE
+ unsigned int etop_cfg;
+ unsigned int etop_mdio_cfg;
+ unsigned int etop_ig_plen_ctrl;
+ unsigned int enet_mac_cfg;
+
+ etop_cfg = *IFX_PP32_ETOP_CFG;
+ etop_mdio_cfg = *IFX_PP32_ETOP_MDIO_CFG;
+ etop_ig_plen_ctrl = *IFX_PP32_ETOP_IG_PLEN_CTRL;
+ enet_mac_cfg = *IFX_PP32_ENET_MAC_CFG;
+
+ *IFX_PP32_ETOP_CFG &= ~0x03C0;
+
+ // reset PPE
+ ifx_rcu_rst(IFX_RCU_DOMAIN_PPE, IFX_RCU_MODULE_ATM);
+
+ *IFX_PP32_ETOP_MDIO_CFG = etop_mdio_cfg;
+ *IFX_PP32_ETOP_IG_PLEN_CTRL = etop_ig_plen_ctrl;
+ *IFX_PP32_ENET_MAC_CFG = enet_mac_cfg;
+ *IFX_PP32_ETOP_CFG = etop_cfg;
+#endif*/
+}
+
+/*
+ * Description:
+ * Download PPE firmware binary code.
+ * Input:
+ * src --- u32 *, binary code buffer
+ * dword_len --- unsigned int, binary code length in DWORD (32-bit)
+ * Output:
+ * int --- 0: Success
+ * else: Error Code
+ */
+static inline int danube_pp32_download_code(u32 *code_src, unsigned int code_dword_len, u32 *data_src, unsigned int data_dword_len)
+{
+ volatile u32 *dest;
+
+ if ( code_src == 0 || ((unsigned long)code_src & 0x03) != 0
+ || data_src == 0 || ((unsigned long)data_src & 0x03) != 0 )
+ return -1;
+
+ if ( code_dword_len <= CDM_CODE_MEMORYn_DWLEN(0) )
+ IFX_REG_W32(0x00, CDM_CFG);
+ else
+ IFX_REG_W32(0x04, CDM_CFG);
+
+ /* copy code */
+ dest = CDM_CODE_MEMORY(0, 0);
+ while ( code_dword_len-- > 0 )
+ IFX_REG_W32(*code_src++, dest++);
+
+ /* copy data */
+ dest = CDM_DATA_MEMORY(0, 0);
+ while ( data_dword_len-- > 0 )
+ IFX_REG_W32(*data_src++, dest++);
+
+ return 0;
+}
+
+static void danube_fw_ver(unsigned int *major, unsigned int *minor)
+{
+ ASSERT(major != NULL, "pointer is NULL");
+ ASSERT(minor != NULL, "pointer is NULL");
+
+ *major = FW_VER_ID->major;
+ *minor = FW_VER_ID->minor;
+}
+
+static void danube_init(void)
+{
+ volatile u32 *p = SB_RAM0_ADDR(0);
+ unsigned int i;
+
+ ltq_pmu_enable(IFX_PMU_MODULE_PPE_SLL01 |
+ IFX_PMU_MODULE_PPE_TC |
+ IFX_PMU_MODULE_PPE_EMA |
+ IFX_PMU_MODULE_PPE_QSB |
+ IFX_PMU_MODULE_TPE |
+ IFX_PMU_MODULE_DSL_DFE);
+
+ reset_ppe();
+
+ /* init ema */
+ IFX_REG_W32((EMA_CMD_BUF_LEN << 16) | (EMA_CMD_BASE_ADDR >> 2), EMA_CMDCFG);
+ IFX_REG_W32((EMA_DATA_BUF_LEN << 16) | (EMA_DATA_BASE_ADDR >> 2), EMA_DATACFG);
+ IFX_REG_W32(0x000000FF, EMA_IER);
+ IFX_REG_W32(EMA_READ_BURST | (EMA_WRITE_BURST << 2), EMA_CFG);
+
+ /* init mailbox */
+ IFX_REG_W32(0xFFFFFFFF, MBOX_IGU1_ISRC);
+ IFX_REG_W32(0x00000000, MBOX_IGU1_IER);
+ IFX_REG_W32(0xFFFFFFFF, MBOX_IGU3_ISRC);
+ IFX_REG_W32(0x00000000, MBOX_IGU3_IER);
+
+ /* init atm tc */
+ IFX_REG_W32(0x0000, DREG_AT_CTRL);
+ IFX_REG_W32(0x0000, DREG_AR_CTRL);
+ IFX_REG_W32(0x0, DREG_AT_IDLE0);
+ IFX_REG_W32(0x0, DREG_AT_IDLE1);
+ IFX_REG_W32(0x0, DREG_AR_IDLE0);
+ IFX_REG_W32(0x0, DREG_AR_IDLE1);
+ IFX_REG_W32(0x40, RFBI_CFG);
+ IFX_REG_W32(0x1600, SFSM_DBA0);
+ IFX_REG_W32(0x1718, SFSM_DBA1);
+ IFX_REG_W32(0x1830, SFSM_CBA0);
+ IFX_REG_W32(0x1844, SFSM_CBA1);
+ IFX_REG_W32(0x14014, SFSM_CFG0);
+ IFX_REG_W32(0x14014, SFSM_CFG1);
+ IFX_REG_W32(0x1858, FFSM_DBA0);
+ IFX_REG_W32(0x18AC, FFSM_DBA1);
+ IFX_REG_W32(0x10006, FFSM_CFG0);
+ IFX_REG_W32(0x10006, FFSM_CFG1);
+ IFX_REG_W32(0x00000001, FFSM_IDLE_HEAD_BC0);
+ IFX_REG_W32(0x00000001, FFSM_IDLE_HEAD_BC1);
+
+ for ( i = 0; i < SB_RAM0_DWLEN + SB_RAM1_DWLEN + SB_RAM2_DWLEN + SB_RAM3_DWLEN; i++ )
+ IFX_REG_W32(0, p++);
+}
+
+static void danube_shutdown(void)
+{
+}
+
+int danube_start(int pp32)
+{
+ int ret;
+
+ /* download firmware */
+ ret = danube_pp32_download_code(
+ danube_fw_bin, sizeof(danube_fw_bin) / sizeof(*danube_fw_bin),
+ danube_fw_data, sizeof(danube_fw_data) / sizeof(*danube_fw_data));
+ if ( ret != 0 )
+ return ret;
+
+ /* run PP32 */
+ IFX_REG_W32(DBG_CTRL_START_SET(1), PP32_DBG_CTRL);
+
+ /* idle for a while to let PP32 init itself */
+ udelay(10);
+
+ return 0;
+}
+
+void danube_stop(int pp32)
+{
+ IFX_REG_W32(DBG_CTRL_STOP_SET(1), PP32_DBG_CTRL);
+}
+
+struct ltq_atm_ops danube_ops = {
+ .init = danube_init,
+ .shutdown = danube_shutdown,
+ .start = danube_start,
+ .stop = danube_stop,
+ .fw_ver = danube_fw_ver,
+};
+
+#endif
diff --git a/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_fw_amazon_se.h.svn-base b/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_fw_amazon_se.h.svn-base
new file mode 100644
index 0000000..b0a9c91
--- /dev/null
+++ b/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_fw_amazon_se.h.svn-base
@@ -0,0 +1,457 @@
+#ifndef IFXMIPS_ATM_FW_AMAZON_SE_H
+#define IFXMIPS_ATM_FW_AMAZON_SE_H
+
+
+/******************************************************************************
+**
+** FILE NAME : ifxmips_atm_fw_amazon_se.h
+** PROJECT : UEIP
+** MODULES : ATM (ADSL)
+**
+** DATE : 1 AUG 2005
+** AUTHOR : Xu Liang
+** DESCRIPTION : ATM Driver (PP32 Firmware)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 4 AUG 2005 Xu Liang Initiate Version
+** 23 OCT 2006 Xu Liang Add GPL header.
+** 9 JAN 2007 Xu Liang First version got from Anand (IC designer)
+*******************************************************************************/
+
+
+#define VER_IN_FIRMWARE 1
+
+#define ATM_FW_VER_MAJOR 0
+#define ATM_FW_VER_MINOR 16
+
+
+static unsigned int firmware_binary_code[] = {
+ 0x800004b8, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8000ffe0, 0x00000000, 0x00000000, 0x00000000,
+ 0xc1000002, 0xd90c00f8, 0xc2000002, 0xda0800f9, 0x80004cc8, 0xc2000000, 0xda0800f9, 0x80004330,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x800042e8, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x800055a8, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x800041e8, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xc0400000, 0xc0004840, 0xc88400f8, 0x80004988, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xc0400002, 0xc0004840, 0xc88400f8, 0x80004908, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xc3c00004, 0xdbc800f9, 0xc10c0002, 0xd90c00f8, 0x8000fee0, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xc10e0002, 0xd90c00f8, 0xc0004808, 0xc84000f8, 0x80004938, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xc3e1fffe, 0x597dfffe, 0x593dfe14, 0x900004d9, 0x00000000, 0x00000000, 0x00000000, 0x90cc0481,
+ 0x00000000, 0x00000000, 0x00000000, 0xc3c00000, 0xdbc800f9, 0xc1400008, 0xc1900000, 0x71588000,
+ 0x14100100, 0xc140000a, 0xc1900002, 0x71588000, 0x14100100, 0xc140000c, 0xc1900004, 0x71588000,
+ 0x14100100, 0xc1400004, 0xc1900006, 0x71588000, 0x14100100, 0xc1400006, 0xc1900008, 0x71588000,
+ 0x14100100, 0xc140000e, 0xc190000a, 0x71588000, 0x14100100, 0xc1400000, 0xc190000c, 0x71588000,
+ 0x14100100, 0xc1400002, 0xc190000e, 0x71588000, 0x14100100, 0xc0400000, 0xc11c0000, 0xc000082c,
+ 0xcd05ce00, 0xc11c0002, 0xc000082c, 0xcd05ce00, 0xc0400002, 0xc11c0000, 0xc000082c, 0xcd05ce00,
+ 0xc11c0002, 0xc000082c, 0xcd05ce00, 0xc0000824, 0x00000000, 0xcbc000f9, 0xcb8000f9, 0xcb4000f9,
+ 0xcb0000f8, 0xc0004878, 0x5bfc4000, 0xcfc000f9, 0x5bb84000, 0xcf8000f9, 0x5b744000, 0xcf4000f9,
+ 0x5b304000, 0xcf0000f8, 0xc0000a10, 0x00000000, 0xcbc000f9, 0xcb8000f8, 0xc0004874, 0x5bfc4000,
+ 0xcfc000f9, 0x5bb84000, 0xcf8000f8, 0xc30001fe, 0xc000140a, 0xcf0000f8, 0xc3000000, 0x7f018000,
+ 0xc000042e, 0xcf0000f8, 0xc000040e, 0xcf0000f8, 0xc3c1fffe, 0xc000490e, 0xcfc00078, 0xc000492c,
+ 0xcfc00078, 0xc0004924, 0xcfc00038, 0xc0004912, 0xcfc00038, 0xc0004966, 0xcfc00038, 0xc0004968,
+ 0xcfc00078, 0xc000496a, 0xcfc00078, 0xc3c1fffe, 0xc00049a0, 0xcfc000f8, 0xc3c00000, 0xc2800020,
+ 0xc3000000, 0x7f018000, 0x6ff88000, 0x6fd44000, 0x4395c000, 0x5bb84a00, 0x5838000a, 0xcf0000f8,
+ 0x5bfc0002, 0xb7e8ffc8, 0x00000000, 0xc3c00000, 0xc2800010, 0x6ff86000, 0x47bdc000, 0x5bb84c80,
+ 0xc3400000, 0x58380004, 0xcb420078, 0x00000000, 0x58380008, 0xcf400078, 0x5bfc0002, 0xb7e8ffb0,
+ 0x00000000, 0xc3c00000, 0xc2800020, 0xc348001e, 0xc3000000, 0x7f018000, 0x6ff8a000, 0x6fd44000,
+ 0x4795c000, 0x47bdc000, 0x5bb85e00, 0x58380008, 0xcf408418, 0x5838000a, 0xcf0000f8, 0x5bfc0002,
+ 0xb7e8ffb0, 0x00000000, 0x00000000, 0xc3e06242, 0x5bfc0020, 0xc0004802, 0xcfc000f8, 0xc161fffe,
+ 0x5955fffe, 0x14140000, 0x00000000, 0xc1000000, 0xd91c00f8, 0xc3e01002, 0x5bfd88c0, 0xc3a00f88,
+ 0x5bb839a2, 0x99005fa8, 0xdbd800f8, 0xdb9800f9, 0x00000000, 0xc3c00000, 0xdf7f0038, 0xa7ccfff0,
+ 0xc3800000, 0xc00048c0, 0xcb818078, 0xc0001408, 0xcfc000f8, 0xc10e0002, 0xd90c00f8, 0x5d3802a6,
+ 0xc1000002, 0xd91c1f02, 0x00000000, 0xc121fffe, 0x5911fe14, 0x14100000, 0xa9fe0270, 0xc3c00000,
+ 0xddfc00f0, 0x5d3c0000, 0x84000100, 0xc0000c04, 0xcb8000f8, 0xc11c0002, 0x00000000, 0x7391c000,
+ 0xcf8000f8, 0xc3800000, 0xc3400080, 0xdf780038, 0xb7b4ffea, 0xc3203002, 0x5b3188c4, 0xc2e00f88,
+ 0x5aec100e, 0x99005fa8, 0xdb1800f8, 0xdad800f9, 0x00000000, 0xc3800000, 0xc3400080, 0xdf780038,
+ 0xb7b4ffea, 0xc3205002, 0x5b3188c8, 0xc2e00f90, 0x5aec180c, 0x99005fa8, 0xdb1800f8, 0xdad800f9,
+ 0x00000000, 0x80000128, 0xc00048cc, 0xca8000f8, 0x00000000, 0xc1000006, 0x76914000, 0x840000fa,
+ 0x00000000, 0xa6800070, 0xc3800000, 0xc3400080, 0xdf780038, 0xb7b4ffea, 0xc3202002, 0x5b31c8c6,
+ 0xc2e00f88, 0x5aec100e, 0x99005fa8, 0xdb1800f8, 0xdad800f9, 0x00000000, 0xa6820068, 0xc3800000,
+ 0xc3400080, 0xdf780038, 0xb7b4ffea, 0xc3204002, 0x5b31c8ca, 0xc2e00f90, 0x5aec180c, 0x99005fa8,
+ 0xdb1800f8, 0xdad800f9, 0x00000000, 0xc00048cc, 0xc2800000, 0xce8000f8, 0xc3a00140, 0x5bfc0002,
+ 0x47bc8000, 0xc1000000, 0xc53c00fe, 0xdbdc00f0, 0x80000530, 0x00000000, 0x80002130, 0x00000000,
+ 0x8000fd70, 0xc0004958, 0xc84000f8, 0x00000000, 0xc3c00002, 0x787c2000, 0xcc4000f8, 0xc0004848,
+ 0xcb8400f8, 0xc000495c, 0xcac400f8, 0xc0004844, 0xc88400f8, 0x47ad0000, 0x8400ff82, 0xc000487c,
+ 0xc80400f8, 0x00000000, 0x00000000, 0x40080000, 0xca0000f8, 0xc0001624, 0xcb0400f8, 0xa63c007a,
+ 0x00000000, 0x00000000, 0xa71eff22, 0x00000000, 0xc0000824, 0xca8400f8, 0x6ca08000, 0x6ca42000,
+ 0x46250000, 0x42290000, 0xc35e0002, 0xc6340060, 0xc0001624, 0xcf440078, 0xc2000000, 0xc161fffe,
+ 0x5955fffe, 0x14140000, 0x00000000, 0xc0004844, 0xc88400f8, 0xc000082c, 0xca040038, 0x00000000,
+ 0x00000000, 0x58880002, 0xb6080018, 0x00000000, 0xc0800000, 0xc0004844, 0xcc840038, 0x5aec0002,
+ 0xc000495c, 0xcec400f8, 0x5e6c0006, 0x84000060, 0xc0004848, 0xcb8400f8, 0xc0000838, 0xc2500002,
+ 0xce450800, 0x5fb80002, 0xc0004848, 0xcf8400f8, 0x5eec0002, 0xc000495c, 0xcec400f8, 0x00000000,
+ 0xc121fffe, 0x5911fe14, 0x14100000, 0x8000fd98, 0xc000495a, 0xc84000f8, 0x00000000, 0xc3c00002,
+ 0x787c2000, 0xcc4000f8, 0xc0004960, 0xcac400f8, 0x00000000, 0x00000000, 0x5eec0000, 0x8400010a,
+ 0x00000000, 0xb6fc0050, 0xc0001600, 0xca0400f8, 0x00000000, 0x00000000, 0xa61e00d2, 0x6fe90000,
+ 0xc0000a28, 0xce850800, 0xc2c00000, 0xc2800004, 0xb6e800a0, 0xc0001604, 0xca8400f8, 0xc0004960,
+ 0xcec400f8, 0xa69efcc2, 0x00000000, 0x6fe90000, 0xc0000a28, 0xce850800, 0xc2c00002, 0xc0001600,
+ 0xca0400f8, 0x00000000, 0x00000000, 0xa61e002a, 0x6fe90000, 0xc0000a28, 0xce850800, 0xc2c00000,
+ 0xc0001604, 0xca8400f8, 0xc0004960, 0xcec400f8, 0xa69efc2a, 0xc2400000, 0xc0000a14, 0xca440028,
+ 0x00000000, 0x00000000, 0x466d2000, 0xa4400020, 0xc2800000, 0xdfeb0029, 0x80000010, 0xdfea0029,
+ 0xb668f932, 0x00000000, 0xc00048a0, 0xcb0400f8, 0xc0000a10, 0xca8400f8, 0x6f208000, 0x6f242000,
+ 0x46250000, 0x42a10000, 0xc2400000, 0xc0000a14, 0xca440028, 0xc35e0002, 0xc6340060, 0xc0001604,
+ 0xcf440078, 0x5b300002, 0xb6700018, 0x5aec0002, 0xc3000000, 0xc00048a0, 0xcf0400f8, 0xc0004960,
+ 0xcec400f8, 0x8000f868, 0xc0004918, 0xd28000f8, 0xc2000000, 0xdf600038, 0x5e600080, 0x84000272,
+ 0x00000000, 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000, 0xc000480a, 0xca0000f8, 0xc0004912,
+ 0xca4000f8, 0xc0004924, 0xca8000f8, 0xc0004966, 0xcac000f8, 0x00000000, 0xc121fffe, 0x5911fe14,
+ 0x14100000, 0x76250000, 0x76290000, 0x762d0000, 0x840001ca, 0xc0004918, 0xca4000f8, 0xc28001fe,
+ 0x76290000, 0x5a640002, 0x6a254010, 0x5ee80000, 0x8400001a, 0x6aa54000, 0x80000010, 0xc62800f8,
+ 0x62818008, 0xc0004918, 0xcf0000f8, 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000, 0xc0004966,
+ 0xca4000f8, 0xc2000002, 0x6a310000, 0x7e010000, 0x76612000, 0xce4000f8, 0x00000000, 0xc121fffe,
+ 0x5911fe14, 0x14100000, 0x6f346000, 0x4771a000, 0x5b744c80, 0xc2800000, 0x58340006, 0xca800078,
+ 0xc2c00000, 0x58340000, 0xcac000d8, 0xc2400000, 0x5834000a, 0xca420078, 0x6ea82000, 0x42e9e000,
+ 0x6f2ca000, 0x42e56000, 0x5aec1400, 0xc3990040, 0xc7381c18, 0xc6f80060, 0x99005fa8, 0xdb9800f8,
+ 0xdbd800f9, 0x00000000, 0xdea000f8, 0x46310000, 0x8400fd80, 0xc0004958, 0xc84000f8, 0x00000000,
+ 0xc3c00002, 0x787c2000, 0xcc4000f8, 0xc0004848, 0xcb8400f8, 0xc0004844, 0xc88400f8, 0x5fb80000,
+ 0x8400f7f2, 0xc0001a1c, 0xca0000f8, 0xc2400002, 0x6a452000, 0x76250000, 0x8400f7c2, 0xc000487c,
+ 0xc80400f8, 0x00000000, 0x00000000, 0x40080000, 0xca0000f8, 0xc42400f8, 0x00000000, 0xa63c17da,
+ 0x00000000, 0xc0004878, 0xc80400f8, 0x6c908000, 0x45088000, 0x45088000, 0x40100000, 0xca0000f8,
+ 0xc42400f8, 0x00000000, 0xc0004934, 0xce0000f8, 0xc2800002, 0xc4681c08, 0xc62821d0, 0xc2600010,
+ 0x5a652440, 0xc0004800, 0xcb4000f8, 0xc2200400, 0x5a202400, 0xc7601040, 0xc0001220, 0xce8000f8,
+ 0xc0001200, 0xce4000f8, 0xc0001202, 0xce0000f8, 0xc0001240, 0xcb4000f8, 0x00000000, 0x00000000,
+ 0xa754ffe0, 0xc2000000, 0xc7600040, 0xa7520042, 0x00000000, 0x00000000, 0x99006720, 0xc0004822,
+ 0xc94000f8, 0xc1800002, 0x80001680, 0x58206480, 0xc2000000, 0xca000018, 0xc2400000, 0xca414000,
+ 0xc2800000, 0xca812000, 0xc2c00000, 0xcac20018, 0xc0004938, 0xce0000f8, 0xc0004920, 0xce4000f8,
+ 0xc0004916, 0xce8000f8, 0xc0004922, 0xcec000f8, 0xa6400540, 0x00000000, 0xc0004938, 0xcbc000f8,
+ 0x00000000, 0xc3800000, 0x6ff48000, 0x6fd44000, 0x4355a000, 0x5b744a00, 0x58340000, 0xcb802010,
+ 0x00000000, 0xc2000000, 0x6fb46000, 0x4779a000, 0x5b744c80, 0x5834000c, 0xca000020, 0xc000491a,
+ 0xcf8000f8, 0x5e200000, 0x8400046a, 0xc2000000, 0xdf610048, 0x5e6001e8, 0x8800ffe8, 0xc2000002,
+ 0xc2400466, 0xc2a00000, 0x5aa80000, 0xc0001006, 0xce0000f8, 0xc0001008, 0xce4000f8, 0xc000100a,
+ 0xce8000f8, 0x990059e8, 0xc1a0fffe, 0xc0000824, 0xc9840060, 0xc0004934, 0xca4000f8, 0xc2000000,
+ 0xc2800002, 0x99005a28, 0xda9800f8, 0xc61400f8, 0xc65800f8, 0xc161fffe, 0x5955fffe, 0x14140000,
+ 0x00000000, 0x99005b10, 0xc000491a, 0xc94000f8, 0x00000000, 0x00000000, 0xc121fffe, 0x5911fe14,
+ 0x14100000, 0xc0004922, 0xca001118, 0xc3c00000, 0xc3800000, 0xc0004930, 0xce023118, 0xc0004932,
+ 0xcbc000d8, 0xc2800000, 0xc000491e, 0xcfc000f8, 0xc0004862, 0xca800060, 0xc3a0001a, 0x5bb94000,
+ 0xc6b80060, 0xc000491c, 0xcf8000f8, 0x99005d80, 0xc000491c, 0xc1400000, 0xc9420048, 0x00000000,
+ 0x00000000, 0x00000000, 0xa8e2ffe8, 0xc2000000, 0xc1220002, 0xd90c00f8, 0xdf600038, 0x5e600080,
+ 0x8400fff2, 0xc000491c, 0xca0000f8, 0xc000491e, 0xca4000f8, 0x00000000, 0x00000000, 0x99005fa8,
+ 0xda1800f8, 0xda5800f9, 0x00000000, 0xc2000000, 0xdf610048, 0x5e6001fe, 0x8800ffe8, 0xc0004916,
+ 0xca8000f8, 0xc2c00000, 0xdfec0048, 0xc2400000, 0x466d2000, 0x8400004a, 0x5ea80000, 0x8400003a,
+ 0xc2600002, 0x99006720, 0xc000482e, 0xc94000f8, 0xc1800002, 0x80000030, 0xc2600000, 0x99006720,
+ 0xc000482c, 0xc94000f8, 0xc1800002, 0xc2000068, 0xc6240078, 0xc0004930, 0xce400080, 0xc000491a,
+ 0xc98000f8, 0xc0004862, 0xc94000f8, 0x6d9c6000, 0x45d8e000, 0x59dc4c80, 0x99005e08, 0xd95800f8,
+ 0xd99800f9, 0xd9d400f8, 0x99005d80, 0xc000491c, 0xc1400000, 0xc9420048, 0xc2000000, 0xdf600038,
+ 0x5e600080, 0x8400ffea, 0x00000000, 0xc000491c, 0xca0000f8, 0xc000491e, 0xca4000f8, 0x00000000,
+ 0x00000000, 0x99005fa8, 0xda1800f8, 0xda5800f9, 0x00000000, 0x800010e8, 0x00000000, 0x99006720,
+ 0xc000482a, 0xc94000f8, 0xc1800002, 0x800010b8, 0xc0004938, 0xcbc000f8, 0x00000000, 0x00000000,
+ 0x6ff88000, 0x6fd44000, 0x4395c000, 0x5bb84a00, 0x58380008, 0xca0000f8, 0x00000000, 0x00000000,
+ 0xa6000382, 0x00000000, 0xc0004938, 0xcbc000f8, 0xc3000000, 0x00000000, 0x6ff88000, 0x6fd44000,
+ 0x4395c000, 0x5bb84a00, 0x58380000, 0xcb002010, 0xc2000000, 0x58380008, 0xca020078, 0x5838000c,
+ 0xcac000f8, 0x5838000e, 0xca4000f8, 0xc000491a, 0xcf0000f8, 0xc0004930, 0xcec000f8, 0xc000493c,
+ 0xce0000f8, 0xc0004932, 0xce4000f8, 0x5e200000, 0x84000120, 0xc2800000, 0xa6fe00ba, 0x6f206000,
+ 0x46310000, 0x5a204c80, 0x5820000c, 0xca800020, 0x00000000, 0x00000000, 0x5ea80000, 0x840001f2,
+ 0x00000000, 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000, 0x99005b10, 0xc000491a, 0xc94000f8,
+ 0x00000000, 0x00000000, 0xc121fffe, 0x5911fe14, 0x14100000, 0xc0004930, 0xcac000f8, 0xc0004932,
+ 0xca4000f8, 0xc7ec1118, 0xc0004930, 0xcec000f8, 0x5838000c, 0xcec000f8, 0x58000002, 0xce4000f8,
+ 0xc0004934, 0xca0000f8, 0xc2400002, 0x6e642000, 0x6e642000, 0x76612000, 0x8400002a, 0xc2400002,
+ 0x6e684000, 0x58380008, 0xce804200, 0xa6000020, 0x6e682000, 0x58380008, 0xce802100, 0xc2400002,
+ 0x6e642000, 0x76612000, 0x840000ea, 0x58380008, 0xca0000f8, 0xc2800000, 0xc2400000, 0xa60200c0,
+ 0xdba800f8, 0x6f386000, 0x47b1c000, 0x5bb84c80, 0x58380004, 0xca400078, 0x58380002, 0xca800078,
+ 0x00000000, 0xdeb800f8, 0x46a54000, 0x88000060, 0x00000000, 0xc0004824, 0xca0000f8, 0xc2400002,
+ 0x6e640000, 0x5a200002, 0xce0000f8, 0x58380008, 0xce400000, 0x80000018, 0x00000000, 0x80000048,
+ 0xc0004934, 0xca0000f8, 0x00000000, 0x00000000, 0xa6020c6a, 0x00000000, 0x00000000, 0x80000c98,
+ 0xc2800000, 0xc2000200, 0xc240001a, 0xdf690048, 0x46294000, 0x46a54000, 0x8800ffd2, 0xc2000006,
+ 0xc2600982, 0x5a643b6e, 0x5838000a, 0xca8000f8, 0xc0001006, 0xce0000f8, 0xc0001008, 0xce4000f8,
+ 0xc000100a, 0xce8000f8, 0x990059e8, 0xc1a0fffe, 0xc0000824, 0xc9840060, 0xc2000000, 0xc0004930,
+ 0xca02e008, 0x58380026, 0xca4000f8, 0x00000000, 0xc2800000, 0x99005a28, 0xda9800f8, 0xc61400f8,
+ 0xc65800f8, 0xc0004934, 0xca0000f8, 0x00000000, 0x00000000, 0xa6020022, 0x00000000, 0x00000000,
+ 0x80000318, 0xc0004938, 0xcbc000f8, 0xc0004878, 0xc80400f8, 0x6c908000, 0x45088000, 0x45088000,
+ 0x40100000, 0xca0000f8, 0xc42400f8, 0x00000000, 0x58240018, 0xca0000f8, 0x6ff88000, 0x6fd44000,
+ 0x4395c000, 0x5bb84a00, 0xc3000000, 0xc3400002, 0xc2c00000, 0xc62c0078, 0xc6270038, 0xc0004940,
+ 0xce400038, 0xc6260038, 0xc0004942, 0xce400038, 0xc000493c, 0xca0000f8, 0x5eec0000, 0x8400018a,
+ 0x5a6c0010, 0x46254000, 0x88000190, 0x5a600052, 0x46e54000, 0x88000178, 0x58380006, 0xca8000f8,
+ 0xc0004940, 0xca0000f8, 0xc2400000, 0xc6a70038, 0x7e412000, 0x76612000, 0xc2000000, 0xc6a10038,
+ 0x46250000, 0x84000138, 0xc0004942, 0xca0000f8, 0xc2400000, 0xc6a60038, 0x7e412000, 0x76612000,
+ 0xc2000000, 0xc6a00038, 0x58380002, 0xca8000f8, 0x46250000, 0x840000e8, 0xc2400000, 0xc6a60078,
+ 0x466d0000, 0x880000da, 0xc2400000, 0xc6a40078, 0x58380008, 0xca8000f8, 0x46e50000, 0x880000ba,
+ 0x00000000, 0xa6820018, 0x00000000, 0xc7700b00, 0xa6840098, 0x00000000, 0xc7700a00, 0x80000080,
+ 0xc7700200, 0xc000493c, 0xcac000f8, 0x80000060, 0xc7700300, 0xc000493c, 0xcac000f8, 0x80000040,
+ 0xc7700900, 0x80000030, 0xc7700800, 0x80000020, 0xc7700700, 0x80000010, 0xc7700500, 0xc0004944,
+ 0xcf0000f8, 0xc000493e, 0xcec000f8, 0xc0004938, 0xca4000f8, 0xc000493c, 0xcb8000f8, 0xc000493e,
+ 0xcb4000f8, 0xc3000000, 0x6e608000, 0x6e544000, 0x42150000, 0x5a204a00, 0x5aa00008, 0x58200004,
+ 0xcb000078, 0xc0004934, 0xca0000f8, 0xc2400000, 0xc0004930, 0xca42e008, 0xc3c00018, 0xa6020098,
+ 0x00000000, 0x43656000, 0x47ad0000, 0x88000050, 0x46f96000, 0x6ee04010, 0x5be00004, 0xc2000000,
+ 0xc6e00008, 0x5e200000, 0x84000042, 0x5bfc0002, 0x80000030, 0xc3c00004, 0x5a2c0008, 0x47a10000,
+ 0x88000012, 0x5fb80008, 0x6fe04000, 0x42390000, 0x47212000, 0x88000068, 0xc2400000, 0xc0004930,
+ 0xca42e008, 0xc2060002, 0xc68000f8, 0xce006300, 0x6fe04000, 0x4721c000, 0x5f700010, 0x4765a000,
+ 0xc2000000, 0xc6340008, 0xc25a000a, 0xc000491a, 0xca401c18, 0xc2800000, 0xc0004932, 0xca8000d8,
+ 0xc0004862, 0xca400060, 0x6fa04010, 0x42290000, 0xc000491e, 0xce0000f8, 0xc7e41048, 0xc000491c,
+ 0xce4000f8, 0x6fe04000, 0x43a1c000, 0xc000493c, 0xcf8000f8, 0xc000493e, 0xcf4000f8, 0xc000493a,
+ 0xcfc000f8, 0x80000008, 0x00000000, 0x00000000, 0x00000000, 0xc2000000, 0xdce000f8, 0xa622ffd8,
+ 0xc1220002, 0xd90c00f8, 0xc0004938, 0xcbc000f8, 0xc0004944, 0xcb4000f8, 0xc0004862, 0xcb0000f8,
+ 0xc0004934, 0xca0000f8, 0x6ff88000, 0x6fd44000, 0x4395c000, 0x5bb84a00, 0xa6020268, 0xc2400000,
+ 0x58380008, 0xca406000, 0xdfe800f8, 0xc2218e08, 0x5a21baf6, 0x46a14000, 0x84000022, 0xc2080002,
+ 0x7361a000, 0x80000058, 0x5e640000, 0x84000022, 0xc20c0002, 0x7361a000, 0x80000030, 0xc2000000,
+ 0xc760e710, 0xc7604218, 0x5e200000, 0x84000272, 0xc2200002, 0xc0004930, 0xce021000, 0x99006720,
+ 0xc0004828, 0xc94000f8, 0xc1800002, 0x58380000, 0xca0000f8, 0x00000000, 0x00000000, 0xa6000132,
+ 0xc0004940, 0xca8000f8, 0xc0004942, 0xca4000f8, 0xc7600078, 0xc6a01838, 0xc6601038, 0xc000493a,
+ 0xca4000f8, 0xc0004934, 0xca8000f8, 0xc0005600, 0x40300000, 0x40240000, 0x5c000004, 0x5ec05800,
+ 0x88000012, 0x5c000200, 0xce0000f8, 0x58000002, 0x5ec05800, 0x88000012, 0x5c000200, 0xce8000f8,
+ 0xc000493e, 0xca0000f8, 0xc2400000, 0x5838000c, 0xce4000f8, 0x99006720, 0xc0004830, 0xc94000f8,
+ 0xc61800f8, 0xc0004930, 0xc6100078, 0xcd000078, 0x800000a8, 0xc2400002, 0x58380008, 0xce400000,
+ 0xc0004944, 0xcf4000f8, 0x80000278, 0xc000493c, 0xca4000f8, 0xdfe800f8, 0x5a300018, 0xc0005600,
+ 0x40200000, 0xca0000f8, 0x58380008, 0xc6501078, 0xcd021078, 0x5838000a, 0xce8000f8, 0x58380026,
+ 0xce0000f8, 0xc0004944, 0xcf4000f8, 0x99005d80, 0xc000491c, 0xc1400000, 0xc9420048, 0x80000038,
+ 0x00000000, 0x99006720, 0xc0004826, 0xc94000f8, 0xc1800002, 0x8000fdd8, 0xc2000000, 0xc2400080,
+ 0xdf600038, 0xb624ffea, 0xc000491c, 0xca4000f8, 0xc000491e, 0xca8000f8, 0x99005fa8, 0xda5800f8,
+ 0xda9800f9, 0x00000000, 0xc0004934, 0xca0000f8, 0x00000000, 0xc2800000, 0xa6020160, 0xc2400004,
+ 0xc2000200, 0xdf690048, 0x46294000, 0x46a54000, 0x8800ffda, 0x00000000, 0xc000491a, 0xc98000f8,
+ 0xc0004862, 0xc94000f8, 0x6d9c6000, 0x45d8e000, 0x59dc4c80, 0x99005e08, 0xd95800f8, 0xd99800f9,
+ 0xd9d400f8, 0x99005d80, 0xc000491c, 0xc1400000, 0xc9420048, 0xc2000000, 0xc2400080, 0xdf600038,
+ 0xb624ffea, 0xc000491c, 0xca4000f8, 0xc000491e, 0xca8000f8, 0x99005fa8, 0xda5800f8, 0xda9800f9,
+ 0x00000000, 0x58380008, 0xca4000f8, 0xc2000000, 0xce000018, 0xc2a1fffe, 0x5aa9fffe, 0xce021078,
+ 0x5838000a, 0xce8000f8, 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000, 0xc0000838, 0xc2500002,
+ 0xce450800, 0xc0004848, 0xcb8400f8, 0xc2000000, 0xc000082c, 0xca040028, 0x5fb80002, 0xc0004848,
+ 0xcf8400f8, 0x58880002, 0xb6080018, 0x00000000, 0xc0800000, 0xc0004844, 0xcc8400f8, 0x00000000,
+ 0xc121fffe, 0x5911fe14, 0x14100000, 0x8000ded8, 0xc2000000, 0xdf600038, 0x5e200080, 0x8400026a,
+ 0x00000000, 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000, 0xc000480c, 0xca0000f8, 0xc0004910,
+ 0xca4000f8, 0xc000492c, 0xca8000f8, 0xc0004968, 0xcac000f8, 0x00000000, 0xc121fffe, 0x5911fe14,
+ 0x14100000, 0x76250000, 0x76290000, 0x76e16000, 0x840001c2, 0xc0004926, 0xca4000f8, 0xc201fffe,
+ 0x76e16000, 0x5a640002, 0x6ae50010, 0x5f200000, 0x8400001a, 0x6a250000, 0x80000010, 0xc6e000f8,
+ 0x62014008, 0xc0004926, 0xce8000f8, 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000, 0xc0004968,
+ 0xca4000f8, 0xc2000002, 0x6a290000, 0x7e010000, 0x76612000, 0xce4000f8, 0x00000000, 0xc121fffe,
+ 0x5911fe14, 0x14100000, 0x6eb4a000, 0x6e944000, 0x4755a000, 0x4769a000, 0x5b745e00, 0x58340002,
+ 0xc2000000, 0xca0000d8, 0x5834002e, 0xc2400000, 0xca400078, 0x6eb0a000, 0x6ebc4000, 0x473d8000,
+ 0x47298000, 0x5b301e2e, 0x5b300004, 0x6e642000, 0x4225e000, 0xc39a8024, 0xc7380060, 0xc6b81c18,
+ 0x99005fa8, 0xdb9800f8, 0xdbd800f9, 0x00000000, 0xc2000000, 0xdf600038, 0x5e200080, 0x84000352,
+ 0x00000000, 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000, 0xc000490e, 0xca0000f8, 0xc00049a0,
+ 0xca8000f8, 0xc000492a, 0xca4000f8, 0xc000496a, 0xcb0000f8, 0xc0004956, 0xcac000f8, 0x00000000,
+ 0xc121fffe, 0x5911fe14, 0x14100000, 0x77218000, 0x77258000, 0x77298000, 0x8400029a, 0xc201fffe,
+ 0x77218000, 0x5aec0002, 0x6b2d0010, 0x5ea00000, 0x8400001a, 0x6a2d0000, 0x80000010, 0xc72000f8,
+ 0x62016008, 0xc0004956, 0xcec000f8, 0x6ef4a000, 0x6ed44000, 0x4755a000, 0x476da000, 0x5b745e00,
+ 0x58340000, 0xc9c000f8, 0xc00049a0, 0xca0000f8, 0xc3000000, 0xc5f04018, 0xc2400000, 0xc5e50038,
+ 0x7e412000, 0x76250000, 0xce0000f8, 0xc0004980, 0x40300000, 0xcec000f8, 0xc161fffe, 0x5955fffe,
+ 0x14140000, 0x00000000, 0xc000496a, 0xca4000f8, 0xc2000002, 0x6a2d0000, 0x7e010000, 0x76612000,
+ 0xce4000f8, 0x00000000, 0xc121fffe, 0x5911fe14, 0x14100000, 0x6ef4a000, 0x6ed44000, 0x4755a000,
+ 0x476da000, 0x5b745e00, 0x5834000e, 0xc2000000, 0xca0000d8, 0x58340008, 0xc2400000, 0xca420078,
+ 0x5834000c, 0xc2800000, 0xca832010, 0x6e644010, 0x42250000, 0x4229e000, 0xc39a8008, 0x58340008,
+ 0xcb809018, 0x58340008, 0xc2800000, 0xca810010, 0x6ee0a000, 0x6ee44000, 0x46250000, 0x462d0000,
+ 0x5a200008, 0x5a201e08, 0x42290000, 0xc6380060, 0xc6f81c18, 0x99005fa8, 0xdb9800f8, 0xdbd800f9,
+ 0x00000000, 0xc000495a, 0xc84000f8, 0x00000000, 0xc3c00002, 0x787c2000, 0xcc4000f8, 0xc0001a1c,
+ 0xca0000f8, 0xc2400008, 0x6a452000, 0x76250000, 0x84000ec2, 0xc0000a28, 0xc3800000, 0xcb840028,
+ 0xc0000a14, 0xc3400000, 0xcb440028, 0xc0004880, 0xcb0400f8, 0xb7b40072, 0x58041802, 0xcac000f8,
+ 0xa7000078, 0x00000000, 0x00000000, 0xa6c8d598, 0xc1000000, 0xc6d00018, 0xc0004980, 0x40100000,
+ 0xca8000f8, 0x80000070, 0x00000000, 0x00000000, 0x00000000, 0x8000d548, 0x00000000, 0xc2800000,
+ 0xc7282018, 0xc000490e, 0xca4000f8, 0x6be9e000, 0x00000000, 0x767d2000, 0x8400d500, 0x6ea0a000,
+ 0x6e944000, 0x46150000, 0x46290000, 0x5a205e00, 0x5820000c, 0xca0000f8, 0xc0004946, 0xce8000f8,
+ 0xa62203a8, 0x00000000, 0xc2200060, 0xc0004948, 0xce000008, 0xce021038, 0xc240000a, 0xc000494a,
+ 0xce4000f8, 0xc2b60002, 0xc0004964, 0xce837b00, 0x99006278, 0xc00048a0, 0xc88400f8, 0x00000000,
+ 0xc0004946, 0xcbc000f8, 0x00000000, 0x00000000, 0x6ff8a000, 0x6fd44000, 0x4795c000, 0x47bdc000,
+ 0x5bb85e00, 0x99006038, 0xdbd800f8, 0xdb9800f9, 0x00000000, 0x99005d80, 0xc000491c, 0xc1400000,
+ 0xc9420048, 0xc000491c, 0x99006230, 0xc94000f9, 0xc98000f8, 0x00000000, 0x99005fa8, 0xd95800f8,
+ 0xd99800f9, 0x00000000, 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000, 0x99005c70, 0xdbd800f8,
+ 0xdb9800f9, 0xc7d800f8, 0x00000000, 0xc121fffe, 0x5911fe14, 0x14100000, 0x6ff8a000, 0x6fd44000,
+ 0x4795c000, 0x47bdc000, 0x5bb85e00, 0x58380010, 0xca0000f8, 0xc0004874, 0xc80400f8, 0x6c908000,
+ 0x45088000, 0x45088000, 0x40100000, 0xca4000f8, 0xc43400f8, 0x00000000, 0xc74000f8, 0xce0000f8,
+ 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000, 0xc000490e, 0xca4000f8, 0xc2800002, 0x6abd4000,
+ 0x72692000, 0xce4000f8, 0x00000000, 0xc121fffe, 0x5911fe14, 0x14100000, 0x99006720, 0xc0004836,
+ 0xc94000f8, 0xc1800002, 0x00000000, 0x00000000, 0x00000000, 0xa8e2ffe8, 0x00000000, 0x58380000,
+ 0xc90000f8, 0xc00049a0, 0xca0000f8, 0xc2800000, 0xc5290038, 0x72290000, 0xce0000f8, 0xc1220002,
+ 0xd90c00f8, 0xc2000000, 0xc0000a14, 0xca040028, 0xc0000a28, 0xc2500002, 0xce450800, 0x58880002,
+ 0xb6080018, 0xc00048a0, 0xc0800000, 0xcc8400f8, 0x8000d110, 0xc0004946, 0xcbc000f8, 0xc161fffe,
+ 0x5955fffe, 0x14140000, 0x00000000, 0xc000490e, 0xca4000f8, 0xc2800002, 0x6abd4000, 0x72692000,
+ 0xce4000f8, 0x00000000, 0xc121fffe, 0x5911fe14, 0x14100000, 0x6ff8a000, 0x6fd44000, 0x4795c000,
+ 0x47bdc000, 0x5bb85e00, 0x58380008, 0xca0000f8, 0x5838000c, 0xca4000f8, 0xc3400000, 0xc6340000,
+ 0xc000494e, 0xcf4000f8, 0xc2800000, 0xc62a0078, 0xc3000000, 0xc6308018, 0x6f304000, 0x43298000,
+ 0xc000493c, 0xcf0000f8, 0xc2c00000, 0xc66c0078, 0xc0004950, 0xcec000f8, 0xc2800000, 0xc66ae020,
+ 0xc0004954, 0xce8000f8, 0x5f740000, 0x840001a0, 0x5e300028, 0x46e12000, 0x8400016a, 0x46e12000,
+ 0x88000132, 0x5e300018, 0x46e12000, 0x8800002a, 0x46e12000, 0x84000042, 0x00000000, 0x800000c0,
+ 0x00000000, 0x990063b8, 0xdbd800f8, 0xdb9800f9, 0xc78000f8, 0xc3400002, 0xc000494e, 0xcf4000f8,
+ 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000, 0xc000490e, 0xca4000f8, 0xc2800002, 0x6abd4000,
+ 0x7e814000, 0x76692000, 0xce4000f8, 0x00000000, 0xc121fffe, 0x5911fe14, 0x14100000, 0xc2200060,
+ 0xc0004948, 0xce021038, 0xc2000000, 0xc000494c, 0xce0000f8, 0x80000080, 0x00000000, 0x990063b8,
+ 0xdbd800f8, 0xdb9800f9, 0xc78000f8, 0x990065b8, 0xdbd800f8, 0xdb9800f9, 0xc78000f8, 0xc2200058,
+ 0xc0004948, 0xce021038, 0xc2000002, 0xc000494c, 0xce0000f8, 0xc2000006, 0xc0001006, 0xce0000f8,
+ 0x5838000a, 0xca4000f8, 0xc2200982, 0x5a203b6e, 0xc0001008, 0xce0000f8, 0xc000100a, 0xce4000f8,
+ 0xc0004954, 0xca8000f8, 0xc200000c, 0xc000494a, 0xce0000f8, 0xc0004948, 0xce800008, 0xc2b60000,
+ 0xc0004964, 0xce8000f8, 0x99006278, 0xc00048a0, 0xc88400f8, 0x00000000, 0xc0004946, 0xcbc000f8,
+ 0xc000494c, 0xca0000f8, 0x6ff8a000, 0x6fd44000, 0x4795c000, 0x47bdc000, 0x5bb85e00, 0x5e200000,
+ 0x840000fa, 0x00000000, 0x99006038, 0xdbd800f8, 0xdb9800f9, 0x00000000, 0x99005d80, 0xc000491c,
+ 0xc1400000, 0xc9420048, 0xc000491c, 0x99006230, 0xc94000f9, 0xc98000f8, 0x00000000, 0x99005fa8,
+ 0xd95800f8, 0xd99800f9, 0x00000000, 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000, 0x99005c70,
+ 0xdbd800f8, 0xdb9800f9, 0xc7d800f8, 0x00000000, 0xc121fffe, 0x5911fe14, 0x14100000, 0xc000493c,
+ 0xca8000f8, 0xc000494e, 0xcac000f8, 0xc3000018, 0xc3400006, 0x5e200000, 0x8400002a, 0xc2800000,
+ 0xc2c00000, 0xc300001e, 0xc3400000, 0xc6ac1078, 0xc72c0418, 0xc76c0810, 0x58380010, 0xca8000f8,
+ 0x58380008, 0xcec000f8, 0xc6280100, 0xc0004874, 0xc80400f8, 0x6c908000, 0x45088000, 0x45088000,
+ 0x40100000, 0xcb0000f8, 0xc43400f8, 0x00000000, 0xc74000f8, 0xce8000f8, 0xc0004952, 0xce8000f8,
+ 0x00000000, 0x00000000, 0x00000000, 0xa8e2ffe8, 0x00000000, 0xc000494c, 0xca0000f8, 0xc0004950,
+ 0xcac000f8, 0x5e200000, 0x8400006a, 0xdfe800f8, 0x7e814000, 0x5834001a, 0xce8000f8, 0x99006720,
+ 0xc0004834, 0xc94000f8, 0xc1800002, 0x99006720, 0xc0004838, 0xc94000f8, 0xc6d800f8, 0xc1220002,
+ 0xd90c00f8, 0x5e200000, 0x84000040, 0x5838002c, 0xcb0000f8, 0xdfe800f8, 0x00000000, 0x58380014,
+ 0xcf0000f8, 0x80000058, 0xc2a1fffe, 0x5aa9fffe, 0x58380000, 0xc90000f8, 0xc00049a0, 0xcb0000f8,
+ 0xc2c00000, 0xc52d0038, 0x732d8000, 0xcf0000f8, 0x5838000a, 0xce8000f8, 0xc3000000, 0xc0000a14,
+ 0xcb040028, 0xc2d00002, 0xc0000a28, 0xcec50800, 0xc000494e, 0xca8000f8, 0x58880002, 0xb4b00018,
+ 0xc00048a0, 0xc0800000, 0xcc8400f8, 0x5ea80000, 0x8400017a, 0x5e200000, 0x84000168, 0xc000493c,
+ 0xca8000f8, 0x00000000, 0x00000000, 0x5aa80060, 0xce8000f8, 0x990063b8, 0xdbd800f8, 0xdb9800f9,
+ 0xc78000f8, 0x990065b8, 0xdbd800f8, 0xdb9800f9, 0xc78000f8, 0x58380000, 0xcac000f8, 0x00000000,
+ 0xc2000000, 0xc6e04018, 0xc0004952, 0xcac000f8, 0x58380000, 0xca8000f8, 0xc30c0002, 0xc6300018,
+ 0xa6800098, 0x00000000, 0x00000000, 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000, 0xc0001800,
+ 0xca0000f8, 0x00000000, 0x00000000, 0xa60cffea, 0xc6f00500, 0xc6b0c400, 0xcf0000f8, 0x00000000,
+ 0xc121fffe, 0x5911fe14, 0x14100000, 0x8000c758, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x8000c6f0, 0xdcbc00f9, 0x5ffc0000, 0x84000052, 0xc3800002, 0xdb8800f9, 0x5ffc0004, 0x8400bf4a,
+ 0xc3800000, 0xdb8800f9, 0xc3ce0002, 0xc0000800, 0xcfc0e700, 0xc3e1fffe, 0x597dfffe, 0x593dfe14,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0xc000487c, 0xc80400f8, 0x00000000, 0x00000000,
+ 0x40080000, 0xcbc000f8, 0xc43800f8, 0x00000000, 0xc000480e, 0xca0000f8, 0xc0004858, 0xcb4400f8,
+ 0x00000000, 0x00000000, 0x47610000, 0x880000b0, 0x00000000, 0xa7c00048, 0xc0004854, 0xc1000002,
+ 0xcd0400f8, 0xc11c0000, 0xc000082c, 0xcd05ce00, 0x800000d8, 0x00000000, 0xa7d20138, 0x00000000,
+ 0xc7e14040, 0xc2400000, 0xc6246028, 0xc200006a, 0x46250000, 0xc6240030, 0xc0000810, 0xce440030,
+ 0x8000ff70, 0xc2000000, 0xc0000808, 0xca040010, 0xc11c0000, 0xc000082c, 0xcd05ce00, 0x5a200002,
+ 0x5e600010, 0x84000010, 0xc2000000, 0xc0000808, 0xce040010, 0xc3400000, 0x80000028, 0xc1200002,
+ 0xc0000818, 0xcd061000, 0x5b740002, 0xc0004858, 0xcf4400f8, 0x990059c0, 0xc0004848, 0xc94400f8,
+ 0xc1800000, 0xc11c0002, 0xc000082c, 0xcd05ce00, 0x80000600, 0x5b740002, 0xc0004858, 0xcf4400f8,
+ 0xc78000f8, 0xc13c0002, 0xcd03de00, 0xc0004848, 0xc94400f8, 0xc1800000, 0xc000082c, 0xc9840028,
+ 0x59540002, 0xc0004848, 0xcd4400f8, 0x58880002, 0xb4980580, 0x00000000, 0xc0800000, 0x80000568,
+ 0xc000487c, 0xc80400f8, 0x00000000, 0x00000000, 0x40080000, 0xcbc000f8, 0xc42800f8, 0x00000000,
+ 0xa7c00130, 0xc000484c, 0xca0400f8, 0xc2400000, 0xc0001aec, 0xca440018, 0x5a200002, 0xc000484c,
+ 0xce0400f8, 0xb624008a, 0xc68000f8, 0xc13c0002, 0xcd03de00, 0xc0004848, 0xc94400f8, 0xc1800000,
+ 0xc000082c, 0xc9840028, 0x59540002, 0xc0004848, 0xcd4400f8, 0x58880002, 0xb4980470, 0x00000000,
+ 0xc0800000, 0x80000458, 0xc0004854, 0xc1000004, 0xcd0400f8, 0xc0000820, 0xc2000002, 0xce0400f8,
+ 0xc2000000, 0xc000484c, 0xce0400f8, 0xc0004858, 0xce0400f8, 0x8000ff28, 0xc0004854, 0xc1000000,
+ 0xcd0400f8, 0xc11c0000, 0xc000082c, 0xcd05ce00, 0x990059c0, 0xc0004848, 0xc94400f8, 0xc1800000,
+ 0xc1200000, 0xc0000818, 0xcd061000, 0xc11c0002, 0xc000082c, 0xcd05ce00, 0xc2000000, 0xc000484c,
+ 0xce0400f8, 0x80000358, 0xc0001ac0, 0xcb8400f8, 0xc000487c, 0xc80400f8, 0x00000000, 0x00000000,
+ 0x40080000, 0xcbc000f8, 0xc42800f8, 0x00000000, 0x00000000, 0xc68000f8, 0xc13c0000, 0xcd03de00,
+ 0xa780024a, 0x00000000, 0x00000000, 0xa7c0020a, 0x00000000, 0xc0001b00, 0xc2060006, 0xce046308,
+ 0xa7e801c2, 0x00000000, 0xc0004850, 0xca0400f8, 0xc2400000, 0xc0001aec, 0xca448018, 0x5a200002,
+ 0xc0004850, 0xce0400f8, 0xb62400aa, 0x00000000, 0xc68000f8, 0xc13c0002, 0xcd03de00, 0xc0001acc,
+ 0xc2000002, 0xce040000, 0xc0004848, 0xc94400f8, 0xc1800000, 0xc000082c, 0xc9840028, 0x59540002,
+ 0xc0004848, 0xcd4400f8, 0x58880002, 0xb49801c8, 0x00000000, 0xc0800000, 0x800001b0, 0xc0004854,
+ 0xc1000000, 0xcd0400f8, 0xc11c0000, 0xc000082c, 0xcd05ce00, 0x990059c0, 0xc0004848, 0xc94400f8,
+ 0xc1800000, 0xc2000000, 0xc0000820, 0xce0400f8, 0xc1200000, 0xc0000818, 0xcd061000, 0xc11c0002,
+ 0xc000082c, 0xcd05ce00, 0xc0004850, 0xce0400f8, 0xc2000002, 0xc0001acc, 0xce040008, 0x800000e8,
+ 0xc2000002, 0xc0004850, 0xce0400f8, 0x8000fe88, 0xc2000000, 0xc0004850, 0xce0400f8, 0xa7e60032,
+ 0x00000000, 0xc2000002, 0xc0001b00, 0xce040000, 0x8000fe70, 0x00000000, 0xa7860052, 0x00000000,
+ 0xc68000f8, 0xc13c0002, 0xcd03de00, 0xc2020002, 0xc7e2a540, 0xc0001b00, 0xce0400f8, 0x8000fe18,
+ 0xc2040002, 0xc0001b00, 0xce044200, 0x8000fdf8, 0xc2c80002, 0x6ac56000, 0xdacc00f8, 0xc0004854,
+ 0xcb4400f8, 0xc0004848, 0xcb8400f8, 0xc0000838, 0xc3c00000, 0xcbc40028, 0x5ef40004, 0x84000022,
+ 0xc3000000, 0xc0001acc, 0xcf042100, 0x47f98000, 0x8400002a, 0x47f98000, 0x88000030, 0xc1006e8c,
+ 0x8000b380, 0xc0004840, 0xcc8400f8, 0x8000f6b0, 0xc0001ac0, 0xcac400f8, 0xc0004854, 0xcb4400f8,
+ 0xa6c0fbd2, 0x00000000, 0x5ef40000, 0x8400f70a, 0x5ef40002, 0x8400f99a, 0x5ef40004, 0x8400fb9a,
+ 0xc1006ce8, 0x8000b2f8, 0x00000000, 0xc0800000, 0xdf4b0038, 0xc0004900, 0xcb8000f8, 0xc2000000,
+ 0xc000490a, 0xa78000d0, 0xcbc000f8, 0xc1000000, 0xd90000f9, 0xc1000002, 0xd90c00f8, 0x6ff46000,
+ 0x477da000, 0x5b744c80, 0xc2400000, 0x58340004, 0xca400078, 0xc0004900, 0xce000000, 0x5a640002,
+ 0x58340004, 0xc6500078, 0xcd000078, 0xc0004914, 0xca4000f8, 0xc2000002, 0x6a3d0000, 0x72612000,
+ 0xce4000f8, 0xc0000408, 0xce0000f8, 0xa78200d8, 0xc0004908, 0xcbc000f8, 0xc1000000, 0xd90000f9,
+ 0xc1000002, 0xd90c00f8, 0x6ff4a000, 0x6fd44000, 0x4755a000, 0x477da000, 0x5b745e00, 0xc2800000,
+ 0x58340006, 0xca800078, 0xc2000000, 0xc0004900, 0xce002100, 0x5ea80002, 0x58340006, 0xc6900078,
+ 0xcd000078, 0x5a7c0020, 0xc2000002, 0x6a250000, 0xc0000408, 0xce0000f8, 0xdca800f9, 0x5ea80000,
+ 0x8400b168, 0x00000000, 0xa4800230, 0x00000000, 0xc3c00000, 0xc000140e, 0xcbc00018, 0xc3400000,
+ 0xc2400000, 0x6ff86000, 0x47bdc000, 0x5bb84c80, 0x58380008, 0xcb400078, 0x58380006, 0xca400078,
+ 0x5f740002, 0x58380008, 0xc7500078, 0xcd000078, 0xc2000000, 0x58380004, 0xca020078, 0xc3000000,
+ 0x5838000c, 0xcb000020, 0x5a640002, 0x46610000, 0x84000010, 0xc2400000, 0x58380006, 0xc6500078,
+ 0xcd000078, 0xc2000000, 0x5838000a, 0xca020078, 0x5b300002, 0x5838000c, 0xc7100020, 0xcd000020,
+ 0xc2420020, 0x5a200004, 0x46252000, 0x84000010, 0xc2000000, 0x5838000a, 0xc6101078, 0xcd021078,
+ 0xc0004966, 0xca4000f8, 0xc2000002, 0x6a3d0000, 0x72612000, 0xce4000f8, 0x5f740000, 0x84000040,
+ 0xc0004912, 0xca0000f8, 0xc2c00002, 0x6afd6000, 0x7ec16000, 0x762d0000, 0xce0000f8, 0x5f300020,
+ 0x84000040, 0xc0004924, 0xca0000f8, 0xc2c00002, 0x6afd6000, 0x7ec16000, 0x762d0000, 0xce0000f8,
+ 0xa4820070, 0xc2400000, 0xc000140e, 0xca408018, 0xc2000002, 0xc0004900, 0xce000000, 0xc000490a,
+ 0xce4000f8, 0xc1000000, 0xd90000f9, 0xd8400078, 0xc1000004, 0xd90000f9, 0xa4840270, 0x00000000,
+ 0xc3c00000, 0xc000140e, 0xcbc10018, 0xc2800000, 0xc2000000, 0x6ff8a000, 0x6fd44000, 0x4795c000,
+ 0x47bdc000, 0x5bb85e00, 0x5838002e, 0xca800078, 0x58380006, 0xca020078, 0xc3400000, 0x5838002e,
+ 0xcb420078, 0x5aa80002, 0x46a10000, 0x84000010, 0xc2800000, 0x5838002e, 0xc6900078, 0xcd000078,
+ 0x5f740002, 0x5838002e, 0xc7501078, 0xcd021078, 0xc0004968, 0xca4000f8, 0xc2000002, 0x6a3d0000,
+ 0x72612000, 0xce4000f8, 0xc000492a, 0xca8000f8, 0x5e740000, 0x84000040, 0xc0004910, 0xca0000f8,
+ 0xc2c00002, 0x6afd6000, 0x7ec16000, 0x762d0000, 0xce0000f8, 0x6abd4010, 0xa68000ba, 0x00000000,
+ 0x58380032, 0xca0000f8, 0x58000002, 0xca4000f8, 0x5838000c, 0x00000000, 0xce0000f9, 0xce4000f8,
+ 0xc000492a, 0xca0000f8, 0xc2c00002, 0x6afd6000, 0x722d0000, 0xce0000f8, 0xc000492c, 0xca0000f8,
+ 0xc2c00002, 0x6afd6000, 0x722d0000, 0xce0000f8, 0x80000040, 0xc000492c, 0xca0000f8, 0xc2c00002,
+ 0x6afd6000, 0x7ec16000, 0x762d0000, 0xce0000f8, 0xa4880148, 0xc2c00000, 0xc000140e, 0xcac20018,
+ 0xc000490e, 0xca4000f8, 0xc2000002, 0x6a2d0000, 0x7e010000, 0x76612000, 0xce4000f8, 0xc000496a,
+ 0xca4000f8, 0xc2000002, 0x6a2d0000, 0x72612000, 0xce4000f8, 0x6ef0a000, 0x6ed44000, 0x47158000,
+ 0x472d8000, 0x5b305e00, 0x58300000, 0xca0000f8, 0x00000000, 0xc2400002, 0x76612000, 0x84000072,
+ 0x58300000, 0xca4000f8, 0xc2800000, 0x00000000, 0xc6684018, 0xc24c0002, 0xc6a40018, 0xc624c400,
+ 0x58300010, 0xca400500, 0x00000000, 0xc0001800, 0xce4000f8, 0xa4860070, 0xc2400000, 0xc000140e,
+ 0xca418018, 0xc2020002, 0xc0004900, 0xce002100, 0xc0004908, 0xce4000f8, 0xc1000000, 0xd90000f9,
+ 0xd8400078, 0xc1000004, 0xd90000f9, 0xa48c00e8, 0xc2400000, 0xc000140e, 0xca430018, 0x00000000,
+ 0x00000000, 0x5d240002, 0x84000058, 0xc00048c4, 0xca0000f8, 0xc00048c6, 0xc1040002, 0x72110000,
+ 0xce0000f8, 0xc1000002, 0xc00048cc, 0xcd000000, 0x80000060, 0x5d240004, 0x84000050, 0xc00048c8,
+ 0xca0000f8, 0xc00048ca, 0xc1160002, 0x72110000, 0xce0000f8, 0xc1020002, 0xc00048cc, 0xcd002100,
+ 0xc0001408, 0xcc8000f8, 0xc10e0002, 0xd90c00f8, 0x8000ecc8, 0xdfbc00f9, 0xc000496e, 0x990066c8,
+ 0xc94000f8, 0xc7d800f8, 0x00000000, 0xc57000f8, 0x5ef00020, 0x88000148, 0x6f346000, 0x4771a000,
+ 0x5b744c80, 0x58340008, 0xc2400000, 0xca400078, 0x00000000, 0xc2000000, 0x5a640002, 0xce400078,
+ 0x58340004, 0xca000078, 0x00000000, 0x00000000, 0x5e200002, 0xce000078, 0xc0004912, 0xca8000f8,
+ 0xc2400002, 0x6a712000, 0x72a54000, 0xce8000f8, 0x5e200000, 0x84000052, 0xc000480a, 0xca0000f8,
+ 0xc0000408, 0xca8000f8, 0x76250000, 0x00000000, 0x72a14000, 0xce8000f8, 0x80000038, 0xc0004914,
+ 0xca0000f8, 0x7e412000, 0x00000000, 0x76250000, 0xce0000f8, 0x800000d0, 0x6ef4a000, 0x6ed44000,
+ 0x4755a000, 0x476da000, 0x5b745e00, 0x5834002e, 0xc2400000, 0xca420078, 0x00000000, 0xc2000000,
+ 0x5a640002, 0xc6501078, 0xcd021078, 0x58340006, 0xca000078, 0x00000000, 0x00000000, 0x5a200002,
+ 0xce000078, 0xc0004910, 0xca4000f8, 0xc2000002, 0x6a2d0000, 0x72612000, 0xce4000f8, 0xc2000002,
+ 0x6a310000, 0xc000042a, 0xce0000f8, 0xc1040002, 0xd90c00f8, 0x00000000, 0x8000ea38, 0x00000000,
+ 0xc4980928, 0x9d000000, 0xc5580028, 0xc0000838, 0xcd8400f8, 0xc1440200, 0xc1c01600, 0xc55c1070,
+ 0xc000100e, 0x9d000000, 0xcd8000f8, 0xc000100c, 0xcdc000f8, 0xc0004862, 0xc9c000f8, 0x00000000,
+ 0x00000000, 0xd9d800f9, 0xc0005600, 0x401c0000, 0x5dc05800, 0x88000012, 0x5c000200, 0xcd8000f8,
+ 0xc1f0000a, 0x715ca000, 0xdd9800f8, 0xdd9c00f9, 0x41d8e000, 0xc5d40260, 0xc0001010, 0xcd4000f8,
+ 0x6c9c8000, 0x45c8e000, 0x45c8e000, 0x59dc0004, 0xc1601260, 0xc5d40260, 0x9d000000, 0xc0001012,
+ 0xcd4000f8, 0x00000000, 0x00000000, 0xd95800f8, 0x6d586000, 0x4594c000, 0x59984c80, 0xd99800f9,
+ 0x5818000a, 0xc1800000, 0xc9800078, 0xc0005400, 0x6d5ca000, 0x401c0000, 0x40180000, 0xc94000f8,
+ 0x58000002, 0x00000000, 0xc9c000f8, 0xc0004930, 0xcd4000f8, 0xc0004932, 0xcdc000f8, 0x59980004,
+ 0xc1c20020, 0xb59c0018, 0x00000000, 0xc1800000, 0xdd9c00f9, 0x581c000a, 0xcd800078, 0x581c000c,
+ 0xc1800000, 0xc9800020, 0xc1c00002, 0xdd9400f8, 0x69d4e000, 0x5d980002, 0xcd800020, 0xc0004924,
+ 0xc98000f8, 0x00000000, 0x9d000000, 0x00000000, 0x719cc000, 0xcd8000f8, 0xc000492a, 0xc94000f8,
+ 0xc1c00002, 0x69d8e000, 0x7dc0c000, 0x7558a000, 0xcd4000f8, 0xc000492c, 0xc94000f8, 0xdd8000f9,
+ 0x58000032, 0x755ca000, 0x84000090, 0xc94000f9, 0xc98000f8, 0xdd8000f9, 0x5800000c, 0x00000000,
+ 0xcd4000f9, 0xcd8000f8, 0xc000492c, 0xc94000f8, 0xc000492a, 0xc98000f8, 0x715ca000, 0xc000492c,
+ 0xcd4000f8, 0x719cc000, 0xc000492a, 0xcd8000f8, 0x9d000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xc0004862, 0xc98000f8, 0x00000000, 0xc1c00200, 0x4194c000, 0x459ce000, 0x88000012, 0xc5d800f8,
+ 0xc0004862, 0xcd8000f8, 0xc0001406, 0xc98000f8, 0xc1c00002, 0x9d000000, 0xc5d80a00, 0xc5581048,
+ 0xcd8000f8, 0xc0004930, 0xc98000f8, 0xc0004932, 0xc9c000f8, 0xc140000e, 0xc5581c18, 0xdd9400f8,
+ 0xc0005600, 0x40140000, 0x5d405800, 0x88000012, 0x5c000200, 0xcd8000f8, 0x58000002, 0x5d405800,
+ 0x88000012, 0x5c000200, 0xcdc000f8, 0xdd5400f8, 0xc1c00000, 0x58140006, 0xc9c20078, 0xc1800000,
+ 0x58140000, 0xc98000d8, 0x6ddc2000, 0xc000491e, 0x41d8e000, 0xcdc000f8, 0xdd9800f8, 0xc1c00022,
+ 0xc5d80d70, 0xdd9400f9, 0xc5581c18, 0xc000491c, 0xcd8000f8, 0xdd5400f8, 0xc1c00000, 0x58140006,
+ 0xc9c20078, 0xc1800000, 0x58140004, 0xc9820078, 0x00000000, 0x59dc0002, 0x45d8c000, 0x84000010,
+ 0xc1c00000, 0x9d000000, 0x58140006, 0xc5d81078, 0xcd821078, 0xc0004860, 0xc94000f8, 0xc1820080,
+ 0xc1d00002, 0x58146b00, 0xd58000f8, 0x58000002, 0xd58000f9, 0x59540004, 0xb5580018, 0xc0004860,
+ 0xc1400000, 0xcd4000f8, 0xdd9800f9, 0x9d000000, 0xdd9400f8, 0xc0001404, 0xcdc10800, 0xc1c00000,
+ 0xc1800200, 0x5d980004, 0xdf5d0048, 0x459ca000, 0x8800fff2, 0xdd8000f9, 0x5800000c, 0x00000000,
+ 0xc94000f9, 0xc98000f8, 0xc1c00002, 0xc5d43f00, 0xc5d81e00, 0xc0004862, 0xc9c000f8, 0x00000000,
+ 0x00000000, 0x581c5600, 0x5dc05800, 0x88000012, 0x5c000200, 0xcd4000f8, 0x58000002, 0x5dc05800,
+ 0x88000012, 0x5c000200, 0xcd8000f8, 0xc0004862, 0xc9c000f8, 0x00000000, 0xc15004c0, 0xc5d40060,
+ 0xdd9c00f8, 0xc5d41c18, 0xc1c00000, 0xdd8000f9, 0x58000030, 0xc9c00078, 0xdd8000f9, 0x58000002,
+ 0xc98000f8, 0x6ddc2000, 0xc000491c, 0x41d8e000, 0xcd4000f9, 0xcdc000f8, 0xdd9400f9, 0xc1c00000,
+ 0x58140030, 0xc9c00078, 0xc1800000, 0x58140006, 0xc9820078, 0x00000000, 0x59dc0002, 0x45d8c000,
+ 0x84000010, 0xc1c00000, 0x9d000000, 0x58140030, 0xc5d80078, 0xcd800078, 0xc1c00000, 0xdf5c0038,
+ 0x5ddc0080, 0x8400ffea, 0x00000000, 0x9d000000, 0x00000000, 0x00000000, 0x00000000, 0xc160fffe,
+ 0xc0000a10, 0xc9440060, 0xc1a0fffe, 0x59981e08, 0xc000100c, 0xcd4000f8, 0xc000100e, 0xcd8000f8,
+ 0xc0004964, 0xc98000f8, 0x00000000, 0xc170000a, 0x7158a000, 0x6c988000, 0x4588c000, 0x4588c000,
+ 0x59980004, 0xc5940270, 0xc0001010, 0xcd4000f8, 0xc0004946, 0xc94000f8, 0x00000000, 0x00000000,
+ 0x6d58a000, 0x6d5c4000, 0x459cc000, 0x4594c000, 0xc000494a, 0xc94000f8, 0xc0004948, 0xc9c000f8,
+ 0x4194c000, 0xc1400012, 0xc55c1818, 0x9d000000, 0xc59c0268, 0xc0001012, 0xcdc000f8, 0xc1400000,
+ 0x58000012, 0xc9410038, 0xc0004950, 0xc9c000f8, 0xc55800f8, 0xc5940838, 0xc5581078, 0xd99400f8,
+ 0xc000493c, 0xc94000f8, 0xc0004954, 0xc98000f8, 0x59dc00a8, 0x45d4e000, 0x41d8e000, 0x5d5c0030,
+ 0x88000010, 0xc1c00030, 0xc1800000, 0xc5d84028, 0xc1400000, 0xc5d40008, 0x5dd40002, 0x84000072,
+ 0x5dd40004, 0x8400009a, 0x5dd40006, 0x840000c2, 0x5dd80026, 0x840000ea, 0xdd5400f8, 0xdd8000f9,
+ 0x58000008, 0x40180000, 0xcd4000f8, 0x59980002, 0x8000ffc0, 0xdd5400f8, 0xdd8000f9, 0x58000008,
+ 0x40180000, 0xcd4000b8, 0x59980002, 0x8000ff88, 0xdd5400f8, 0xdd8000f9, 0x58000008, 0x40180000,
+ 0xcd400078, 0x59980002, 0x8000ff50, 0xdd5400f8, 0xdd8000f9, 0x58000008, 0x40180000, 0xcd400038,
+ 0x59980002, 0x8000ff18, 0x00000000, 0x9d000000, 0x00000000, 0x00000000, 0x00000000, 0x58000012,
+ 0xc94000f8, 0xc0004954, 0xc9c000f8, 0xc0004950, 0xc9400078, 0xdd8000f9, 0x58000028, 0x5d9c0000,
+ 0x84000052, 0x5d9c0002, 0x84000052, 0x5d9c0004, 0x8400006a, 0xc55b0038, 0xc55c08b8, 0xcd800039,
+ 0xcdc108b8, 0x80000060, 0xcd4000f8, 0x80000050, 0xc55900b8, 0xc55c1838, 0xcd8000b9, 0xcdc31838,
+ 0x80000028, 0xc55a0078, 0xc55c1078, 0xcd800079, 0xcdc21078, 0x9d000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x59540002, 0x6994e018, 0x61c0c008, 0x4194a000, 0x5d940040, 0x88000012, 0xc59400f8,
+ 0x9d000000, 0xcd4000f8, 0x00000000, 0x00000000, 0x9d000000, 0x4158a000, 0xcd4000f8, 0x00000000,
+};
+
+static unsigned int firmware_binary_data[] = {
+};
+
+
+#endif // IFXMIPS_ATM_FW_AMAZON_SE_H
diff --git a/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_fw_ar9.h.svn-base b/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_fw_ar9.h.svn-base
new file mode 100644
index 0000000..5ee6d23
--- /dev/null
+++ b/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_fw_ar9.h.svn-base
@@ -0,0 +1,439 @@
+#ifndef IFXMIPS_ATM_FW_AR9_H
+#define IFXMIPS_ATM_FW_AR9_H
+
+
+/******************************************************************************
+**
+** FILE NAME : ifxmips_atm_fw_ar9.h
+** PROJECT : UEIP
+** MODULES : ATM (ADSL)
+**
+** DATE : 22 OCT 2007
+** AUTHOR : Xu Liang
+** DESCRIPTION : ATM Driver (PP32 Firmware)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 22 OCT 2007 Xu Liang Initiate Version, v00.01
+*******************************************************************************/
+
+
+#define VER_IN_FIRMWARE 1
+
+#define ATM_FW_VER_MAJOR 0
+#define ATM_FW_VER_MINOR 16
+
+
+static unsigned int ar9_fw_bin[] = {
+ 0x800004b8, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8000ffe0, 0x00000000, 0x00000000, 0x00000000,
+ 0xc1000002, 0xd90c00f8, 0xc2000002, 0xda0800f9, 0x80004980, 0xc2000000, 0xda0800f9, 0x80003fe8,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x80003fa0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x80005178, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x80003ea0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xc0400000, 0xc0004840, 0xc88400f8, 0x80004640, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xc0400002, 0xc0004840, 0xc88400f8, 0x800045c0, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xc3c00004, 0xdbc800f9, 0xc10c0002, 0xd90c00f8, 0x8000fee0, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xc10e0002, 0xd90c00f8, 0xc0004808, 0xc84000f8, 0x800045f0, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xc3e1fffe, 0x597dfffe, 0x593dfe14, 0x900004d9, 0x00000000, 0x00000000, 0x00000000, 0x90cc0481,
+ 0x00000000, 0x00000000, 0x00000000, 0xc3c00000, 0xdbc800f9, 0xc1400008, 0xc1900000, 0x71588000,
+ 0x14100100, 0xc140000a, 0xc1900002, 0x71588000, 0x14100100, 0xc140000c, 0xc1900004, 0x71588000,
+ 0x14100100, 0xc1400004, 0xc1900006, 0x71588000, 0x14100100, 0xc1400006, 0xc1900008, 0x71588000,
+ 0x14100100, 0xc140000e, 0xc190000a, 0x71588000, 0x14100100, 0xc1400000, 0xc190000c, 0x71588000,
+ 0x14100100, 0xc1400002, 0xc190000e, 0x71588000, 0x14100100, 0xc0400000, 0xc11c0000, 0xc000082c,
+ 0xcd05ce00, 0xc11c0002, 0xc000082c, 0xcd05ce00, 0xc0400002, 0xc11c0000, 0xc000082c, 0xcd05ce00,
+ 0xc11c0002, 0xc000082c, 0xcd05ce00, 0xc0000824, 0x00000000, 0xcbc000f9, 0xcb8000f9, 0xcb4000f9,
+ 0xcb0000f8, 0xc0004878, 0x5bfc4000, 0xcfc000f9, 0x5bb84000, 0xcf8000f9, 0x5b744000, 0xcf4000f9,
+ 0x5b304000, 0xcf0000f8, 0xc0000a10, 0x00000000, 0xcbc000f9, 0xcb8000f8, 0xc0004874, 0x5bfc4000,
+ 0xcfc000f9, 0x5bb84000, 0xcf8000f8, 0xc30001fe, 0xc000140a, 0xcf0000f8, 0xc3000000, 0x7f018000,
+ 0xc000042e, 0xcf0000f8, 0xc000040e, 0xcf0000f8, 0xc3c1fffe, 0xc000490e, 0xcfc00078, 0xc000492c,
+ 0xcfc00078, 0xc0004924, 0xcfc00038, 0xc0004912, 0xcfc00038, 0xc0004966, 0xcfc00038, 0xc0004968,
+ 0xcfc00078, 0xc000496a, 0xcfc00078, 0xc3c1fffe, 0xc00049a0, 0xcfc000f8, 0xc3c00000, 0xc2800020,
+ 0xc3000000, 0x7f018000, 0x6ff88000, 0x6fd44000, 0x4395c000, 0x5bb84a00, 0x5838000a, 0xcf0000f8,
+ 0x5bfc0002, 0xb7e8ffc8, 0x00000000, 0xc3c00000, 0xc2800010, 0x6ff86000, 0x47bdc000, 0x5bb84c80,
+ 0xc3400000, 0x58380004, 0xcb420078, 0x00000000, 0x58380008, 0xcf400078, 0x5bfc0002, 0xb7e8ffb0,
+ 0x00000000, 0xc3c00000, 0xc2800020, 0xc348001e, 0xc3000000, 0x7f018000, 0x6ff8a000, 0x6fd44000,
+ 0x4795c000, 0x47bdc000, 0x5bb87000, 0x58380008, 0xcf408418, 0x5838000a, 0xcf0000f8, 0x5bfc0002,
+ 0xb7e8ffb0, 0x00000000, 0x00000000, 0xc3e0a242, 0x5bfc0020, 0xc0004002, 0xcfc000f8, 0x00000000,
+ 0xc121fffe, 0x5911fe14, 0x14100000, 0x80000530, 0x00000000, 0x80002130, 0x00000000, 0x8000ffe0,
+ 0xc0004958, 0xc84000f8, 0x00000000, 0xc3c00002, 0x787c2000, 0xcc4000f8, 0xc0004848, 0xcb8400f8,
+ 0xc000495c, 0xcac400f8, 0xc0004844, 0xc88400f8, 0x47ad0000, 0x8400ff82, 0xc000487c, 0xc80400f8,
+ 0x00000000, 0x00000000, 0x40080000, 0xca0000f8, 0xc0001624, 0xcb0400f8, 0xa63c007a, 0x00000000,
+ 0x00000000, 0xa71eff22, 0x00000000, 0xc0000824, 0xca8400f8, 0x6ca08000, 0x6ca42000, 0x46250000,
+ 0x42290000, 0xc35e0002, 0xc6340060, 0xc0001624, 0xcf440078, 0xc2000000, 0xc161fffe, 0x5955fffe,
+ 0x14140000, 0x00000000, 0xc0004844, 0xc88400f8, 0xc000082c, 0xca040038, 0x00000000, 0x00000000,
+ 0x58880002, 0xb6080018, 0x00000000, 0xc0800000, 0xc0004844, 0xcc840038, 0x5aec0002, 0xc000495c,
+ 0xcec400f8, 0x5e6c0006, 0x84000060, 0xc0004848, 0xcb8400f8, 0xc0000838, 0xc2500002, 0xce450800,
+ 0x5fb80002, 0xc0004848, 0xcf8400f8, 0x5eec0002, 0xc000495c, 0xcec400f8, 0x00000000, 0xc121fffe,
+ 0x5911fe14, 0x14100000, 0x8000fd98, 0xc000495a, 0xc84000f8, 0x00000000, 0xc3c00002, 0x787c2000,
+ 0xcc4000f8, 0xc0004960, 0xcac400f8, 0x00000000, 0x00000000, 0x5eec0000, 0x8400010a, 0x00000000,
+ 0xb6fc0050, 0xc0001600, 0xca0400f8, 0x00000000, 0x00000000, 0xa61e00d2, 0x6fe90000, 0xc0000a28,
+ 0xce850800, 0xc2c00000, 0xc2800004, 0xb6e800a0, 0xc0001604, 0xca8400f8, 0xc0004960, 0xcec400f8,
+ 0xa69efcc2, 0x00000000, 0x6fe90000, 0xc0000a28, 0xce850800, 0xc2c00002, 0xc0001600, 0xca0400f8,
+ 0x00000000, 0x00000000, 0xa61e002a, 0x6fe90000, 0xc0000a28, 0xce850800, 0xc2c00000, 0xc0001604,
+ 0xca8400f8, 0xc0004960, 0xcec400f8, 0xa69efc2a, 0xc2400000, 0xc0000a14, 0xca440028, 0x00000000,
+ 0x00000000, 0x466d2000, 0xa4400020, 0xc2800000, 0xdfeb0029, 0x80000010, 0xdfea0029, 0xb668fba2,
+ 0x00000000, 0xc00048a0, 0xcb0400f8, 0xc0000a10, 0xca8400f8, 0x6f208000, 0x6f242000, 0x46250000,
+ 0x42a10000, 0xc2400000, 0xc0000a14, 0xca440028, 0xc35e0002, 0xc6340060, 0xc0001604, 0xcf440078,
+ 0x5b300002, 0xb6700018, 0x5aec0002, 0xc3000000, 0xc00048a0, 0xcf0400f8, 0xc0004960, 0xcec400f8,
+ 0x8000fad8, 0xc0004918, 0xd28000f8, 0xc2000000, 0xdf600038, 0x5e600080, 0x84000272, 0x00000000,
+ 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000, 0xc000480a, 0xca0000f8, 0xc0004912, 0xca4000f8,
+ 0xc0004924, 0xca8000f8, 0xc0004966, 0xcac000f8, 0x00000000, 0xc121fffe, 0x5911fe14, 0x14100000,
+ 0x76250000, 0x76290000, 0x762d0000, 0x840001ca, 0xc0004918, 0xca4000f8, 0xc28001fe, 0x76290000,
+ 0x5a640002, 0x6a254010, 0x5ee80000, 0x8400001a, 0x6aa54000, 0x80000010, 0xc62800f8, 0x62818008,
+ 0xc0004918, 0xcf0000f8, 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000, 0xc0004966, 0xca4000f8,
+ 0xc2000002, 0x6a310000, 0x7e010000, 0x76612000, 0xce4000f8, 0x00000000, 0xc121fffe, 0x5911fe14,
+ 0x14100000, 0x6f346000, 0x4771a000, 0x5b744c80, 0xc2800000, 0x58340006, 0xca800078, 0xc2c00000,
+ 0x58340000, 0xcac000d8, 0xc2400000, 0x5834000a, 0xca420078, 0x6ea82000, 0x42e9e000, 0x6f2ca000,
+ 0x42e56000, 0x5aec2e00, 0xc3990040, 0xc7381c18, 0xc6f80060, 0x99005b78, 0xdb9800f8, 0xdbd800f9,
+ 0x00000000, 0xdea000f8, 0x46310000, 0x8400fd80, 0xc0004958, 0xc84000f8, 0x00000000, 0xc3c00002,
+ 0x787c2000, 0xcc4000f8, 0xc0004848, 0xcb8400f8, 0xc0004844, 0xc88400f8, 0x5fb80000, 0x8400f7f2,
+ 0xc0001a1c, 0xca0000f8, 0xc2400002, 0x6a452000, 0x76250000, 0x8400f7c2, 0xc000487c, 0xc80400f8,
+ 0x00000000, 0x00000000, 0x40080000, 0xca0000f8, 0xc42400f8, 0x00000000, 0xa63c17da, 0x00000000,
+ 0xc0004878, 0xc80400f8, 0x6c908000, 0x45088000, 0x45088000, 0x40100000, 0xca0000f8, 0xc42400f8,
+ 0x00000000, 0xc0004934, 0xce0000f8, 0xc2800002, 0xc4681c08, 0xc62821d0, 0xc2600010, 0x5a650060,
+ 0xc0004800, 0xcb4000f8, 0xc2200400, 0x5a200020, 0xc7601040, 0xc0001220, 0xce8000f8, 0xc0001200,
+ 0xce4000f8, 0xc0001202, 0xce0000f8, 0xc0001240, 0xcb4000f8, 0x00000000, 0x00000000, 0xa754ffe0,
+ 0xc2000000, 0xc7600040, 0xa7520042, 0x00000000, 0x00000000, 0x990062f0, 0xc0004822, 0xc94000f8,
+ 0xc1800002, 0x80001680, 0x582040a0, 0xc2000000, 0xca000018, 0xc2400000, 0xca414000, 0xc2800000,
+ 0xca812000, 0xc2c00000, 0xcac20018, 0xc0004938, 0xce0000f8, 0xc0004920, 0xce4000f8, 0xc0004916,
+ 0xce8000f8, 0xc0004922, 0xcec000f8, 0xa6400540, 0x00000000, 0xc0004938, 0xcbc000f8, 0x00000000,
+ 0xc3800000, 0x6ff48000, 0x6fd44000, 0x4355a000, 0x5b744a00, 0x58340000, 0xcb802010, 0x00000000,
+ 0xc2000000, 0x6fb46000, 0x4779a000, 0x5b744c80, 0x5834000c, 0xca000020, 0xc000491a, 0xcf8000f8,
+ 0x5e200000, 0x8400046a, 0xc2000000, 0xdf610048, 0x5e6001e8, 0x8800ffe8, 0xc2000002, 0xc2400466,
+ 0xc2a00000, 0x5aa80000, 0xc0001006, 0xce0000f8, 0xc0001008, 0xce4000f8, 0xc000100a, 0xce8000f8,
+ 0x990055b8, 0xc1a0fffe, 0xc0000824, 0xc9840060, 0xc0004934, 0xca4000f8, 0xc2000000, 0xc2800002,
+ 0x990055f8, 0xda9800f8, 0xc61400f8, 0xc65800f8, 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000,
+ 0x990056e0, 0xc000491a, 0xc94000f8, 0x00000000, 0x00000000, 0xc121fffe, 0x5911fe14, 0x14100000,
+ 0xc0004922, 0xca001118, 0xc3c00000, 0xc3800000, 0xc0004930, 0xce023118, 0xc0004932, 0xcbc000d8,
+ 0xc2800000, 0xc000491e, 0xcfc000f8, 0xc0004862, 0xca800060, 0xc3a0001a, 0x5bb94000, 0xc6b80060,
+ 0xc000491c, 0xcf8000f8, 0x99005950, 0xc000491c, 0xc1400000, 0xc9420048, 0x00000000, 0x00000000,
+ 0x00000000, 0xa8e2ffe8, 0xc2000000, 0xc1220002, 0xd90c00f8, 0xdf600038, 0x5e600080, 0x8400fff2,
+ 0xc000491c, 0xca0000f8, 0xc000491e, 0xca4000f8, 0x00000000, 0x00000000, 0x99005b78, 0xda1800f8,
+ 0xda5800f9, 0x00000000, 0xc2000000, 0xdf610048, 0x5e6001fe, 0x8800ffe8, 0xc0004916, 0xca8000f8,
+ 0xc2c00000, 0xdfec0048, 0xc2400000, 0x466d2000, 0x8400004a, 0x5ea80000, 0x8400003a, 0xc2600002,
+ 0x990062f0, 0xc000482e, 0xc94000f8, 0xc1800002, 0x80000030, 0xc2600000, 0x990062f0, 0xc000482c,
+ 0xc94000f8, 0xc1800002, 0xc2000068, 0xc6240078, 0xc0004930, 0xce400080, 0xc000491a, 0xc98000f8,
+ 0xc0004862, 0xc94000f8, 0x6d9c6000, 0x45d8e000, 0x59dc4c80, 0x990059d8, 0xd95800f8, 0xd99800f9,
+ 0xd9d400f8, 0x99005950, 0xc000491c, 0xc1400000, 0xc9420048, 0xc2000000, 0xdf600038, 0x5e600080,
+ 0x8400ffea, 0x00000000, 0xc000491c, 0xca0000f8, 0xc000491e, 0xca4000f8, 0x00000000, 0x00000000,
+ 0x99005b78, 0xda1800f8, 0xda5800f9, 0x00000000, 0x800010e8, 0x00000000, 0x990062f0, 0xc000482a,
+ 0xc94000f8, 0xc1800002, 0x800010b8, 0xc0004938, 0xcbc000f8, 0x00000000, 0x00000000, 0x6ff88000,
+ 0x6fd44000, 0x4395c000, 0x5bb84a00, 0x58380008, 0xca0000f8, 0x00000000, 0x00000000, 0xa6000382,
+ 0x00000000, 0xc0004938, 0xcbc000f8, 0xc3000000, 0x00000000, 0x6ff88000, 0x6fd44000, 0x4395c000,
+ 0x5bb84a00, 0x58380000, 0xcb002010, 0xc2000000, 0x58380008, 0xca020078, 0x5838000c, 0xcac000f8,
+ 0x5838000e, 0xca4000f8, 0xc000491a, 0xcf0000f8, 0xc0004930, 0xcec000f8, 0xc000493c, 0xce0000f8,
+ 0xc0004932, 0xce4000f8, 0x5e200000, 0x84000120, 0xc2800000, 0xa6fe00ba, 0x6f206000, 0x46310000,
+ 0x5a204c80, 0x5820000c, 0xca800020, 0x00000000, 0x00000000, 0x5ea80000, 0x840001f2, 0x00000000,
+ 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000, 0x990056e0, 0xc000491a, 0xc94000f8, 0x00000000,
+ 0x00000000, 0xc121fffe, 0x5911fe14, 0x14100000, 0xc0004930, 0xcac000f8, 0xc0004932, 0xca4000f8,
+ 0xc7ec1118, 0xc0004930, 0xcec000f8, 0x5838000c, 0xcec000f8, 0x58000002, 0xce4000f8, 0xc0004934,
+ 0xca0000f8, 0xc2400002, 0x6e642000, 0x6e642000, 0x76612000, 0x8400002a, 0xc2400002, 0x6e684000,
+ 0x58380008, 0xce804200, 0xa6000020, 0x6e682000, 0x58380008, 0xce802100, 0xc2400002, 0x6e642000,
+ 0x76612000, 0x840000ea, 0x58380008, 0xca0000f8, 0xc2800000, 0xc2400000, 0xa60200c0, 0xdba800f8,
+ 0x6f386000, 0x47b1c000, 0x5bb84c80, 0x58380004, 0xca400078, 0x58380002, 0xca800078, 0x00000000,
+ 0xdeb800f8, 0x46a54000, 0x88000060, 0x00000000, 0xc0004824, 0xca0000f8, 0xc2400002, 0x6e640000,
+ 0x5a200002, 0xce0000f8, 0x58380008, 0xce400000, 0x80000018, 0x00000000, 0x80000048, 0xc0004934,
+ 0xca0000f8, 0x00000000, 0x00000000, 0xa6020c6a, 0x00000000, 0x00000000, 0x80000c98, 0xc2800000,
+ 0xc2000200, 0xc240001a, 0xdf690048, 0x46294000, 0x46a54000, 0x8800ffd2, 0xc2000006, 0xc2600982,
+ 0x5a643b6e, 0x5838000a, 0xca8000f8, 0xc0001006, 0xce0000f8, 0xc0001008, 0xce4000f8, 0xc000100a,
+ 0xce8000f8, 0x990055b8, 0xc1a0fffe, 0xc0000824, 0xc9840060, 0xc2000000, 0xc0004930, 0xca02e008,
+ 0x58380026, 0xca4000f8, 0x00000000, 0xc2800000, 0x990055f8, 0xda9800f8, 0xc61400f8, 0xc65800f8,
+ 0xc0004934, 0xca0000f8, 0x00000000, 0x00000000, 0xa6020022, 0x00000000, 0x00000000, 0x80000318,
+ 0xc0004938, 0xcbc000f8, 0xc0004878, 0xc80400f8, 0x6c908000, 0x45088000, 0x45088000, 0x40100000,
+ 0xca0000f8, 0xc42400f8, 0x00000000, 0x58240018, 0xca0000f8, 0x6ff88000, 0x6fd44000, 0x4395c000,
+ 0x5bb84a00, 0xc3000000, 0xc3400002, 0xc2c00000, 0xc62c0078, 0xc6270038, 0xc0004940, 0xce400038,
+ 0xc6260038, 0xc0004942, 0xce400038, 0xc000493c, 0xca0000f8, 0x5eec0000, 0x8400018a, 0x5a6c0010,
+ 0x46254000, 0x88000190, 0x5a600052, 0x46e54000, 0x88000178, 0x58380006, 0xca8000f8, 0xc0004940,
+ 0xca0000f8, 0xc2400000, 0xc6a70038, 0x7e412000, 0x76612000, 0xc2000000, 0xc6a10038, 0x46250000,
+ 0x84000138, 0xc0004942, 0xca0000f8, 0xc2400000, 0xc6a60038, 0x7e412000, 0x76612000, 0xc2000000,
+ 0xc6a00038, 0x58380002, 0xca8000f8, 0x46250000, 0x840000e8, 0xc2400000, 0xc6a60078, 0x466d0000,
+ 0x880000da, 0xc2400000, 0xc6a40078, 0x58380008, 0xca8000f8, 0x46e50000, 0x880000ba, 0x00000000,
+ 0xa6820018, 0x00000000, 0xc7700b00, 0xa6840098, 0x00000000, 0xc7700a00, 0x80000080, 0xc7700200,
+ 0xc000493c, 0xcac000f8, 0x80000060, 0xc7700300, 0xc000493c, 0xcac000f8, 0x80000040, 0xc7700900,
+ 0x80000030, 0xc7700800, 0x80000020, 0xc7700700, 0x80000010, 0xc7700500, 0xc0004944, 0xcf0000f8,
+ 0xc000493e, 0xcec000f8, 0xc0004938, 0xca4000f8, 0xc000493c, 0xcb8000f8, 0xc000493e, 0xcb4000f8,
+ 0xc3000000, 0x6e608000, 0x6e544000, 0x42150000, 0x5a204a00, 0x5aa00008, 0x58200004, 0xcb000078,
+ 0xc0004934, 0xca0000f8, 0xc2400000, 0xc0004930, 0xca42e008, 0xc3c00018, 0xa6020098, 0x00000000,
+ 0x43656000, 0x47ad0000, 0x88000050, 0x46f96000, 0x6ee04010, 0x5be00004, 0xc2000000, 0xc6e00008,
+ 0x5e200000, 0x84000042, 0x5bfc0002, 0x80000030, 0xc3c00004, 0x5a2c0008, 0x47a10000, 0x88000012,
+ 0x5fb80008, 0x6fe04000, 0x42390000, 0x47212000, 0x88000068, 0xc2400000, 0xc0004930, 0xca42e008,
+ 0xc2060002, 0xc68000f8, 0xce006300, 0x6fe04000, 0x4721c000, 0x5f700010, 0x4765a000, 0xc2000000,
+ 0xc6340008, 0xc25a000a, 0xc000491a, 0xca401c18, 0xc2800000, 0xc0004932, 0xca8000d8, 0xc0004862,
+ 0xca400060, 0x6fa04010, 0x42290000, 0xc000491e, 0xce0000f8, 0xc7e41048, 0xc000491c, 0xce4000f8,
+ 0x6fe04000, 0x43a1c000, 0xc000493c, 0xcf8000f8, 0xc000493e, 0xcf4000f8, 0xc000493a, 0xcfc000f8,
+ 0x80000008, 0x00000000, 0x00000000, 0x00000000, 0xc2000000, 0xdce000f8, 0xa622ffd8, 0xc1220002,
+ 0xd90c00f8, 0xc0004938, 0xcbc000f8, 0xc0004944, 0xcb4000f8, 0xc0004862, 0xcb0000f8, 0xc0004934,
+ 0xca0000f8, 0x6ff88000, 0x6fd44000, 0x4395c000, 0x5bb84a00, 0xa6020268, 0xc2400000, 0x58380008,
+ 0xca406000, 0xdfe800f8, 0xc2218e08, 0x5a21baf6, 0x46a14000, 0x84000022, 0xc2080002, 0x7361a000,
+ 0x80000058, 0x5e640000, 0x84000022, 0xc20c0002, 0x7361a000, 0x80000030, 0xc2000000, 0xc760e710,
+ 0xc7604218, 0x5e200000, 0x84000272, 0xc2200002, 0xc0004930, 0xce021000, 0x990062f0, 0xc0004828,
+ 0xc94000f8, 0xc1800002, 0x58380000, 0xca0000f8, 0x00000000, 0x00000000, 0xa6000132, 0xc0004940,
+ 0xca8000f8, 0xc0004942, 0xca4000f8, 0xc7600078, 0xc6a01838, 0xc6601038, 0xc000493a, 0xca4000f8,
+ 0xc0004934, 0xca8000f8, 0xc0007800, 0x40300000, 0x40240000, 0x5c000004, 0x5ec07a00, 0x88000012,
+ 0x5c000200, 0xce0000f8, 0x58000002, 0x5ec07a00, 0x88000012, 0x5c000200, 0xce8000f8, 0xc000493e,
+ 0xca0000f8, 0xc2400000, 0x5838000c, 0xce4000f8, 0x990062f0, 0xc0004830, 0xc94000f8, 0xc61800f8,
+ 0xc0004930, 0xc6100078, 0xcd000078, 0x800000a8, 0xc2400002, 0x58380008, 0xce400000, 0xc0004944,
+ 0xcf4000f8, 0x80000278, 0xc000493c, 0xca4000f8, 0xdfe800f8, 0x5a300018, 0xc0007800, 0x40200000,
+ 0xca0000f8, 0x58380008, 0xc6501078, 0xcd021078, 0x5838000a, 0xce8000f8, 0x58380026, 0xce0000f8,
+ 0xc0004944, 0xcf4000f8, 0x99005950, 0xc000491c, 0xc1400000, 0xc9420048, 0x80000038, 0x00000000,
+ 0x990062f0, 0xc0004826, 0xc94000f8, 0xc1800002, 0x8000fdd8, 0xc2000000, 0xc2400080, 0xdf600038,
+ 0xb624ffea, 0xc000491c, 0xca4000f8, 0xc000491e, 0xca8000f8, 0x99005b78, 0xda5800f8, 0xda9800f9,
+ 0x00000000, 0xc0004934, 0xca0000f8, 0x00000000, 0xc2800000, 0xa6020160, 0xc2400004, 0xc2000200,
+ 0xdf690048, 0x46294000, 0x46a54000, 0x8800ffda, 0x00000000, 0xc000491a, 0xc98000f8, 0xc0004862,
+ 0xc94000f8, 0x6d9c6000, 0x45d8e000, 0x59dc4c80, 0x990059d8, 0xd95800f8, 0xd99800f9, 0xd9d400f8,
+ 0x99005950, 0xc000491c, 0xc1400000, 0xc9420048, 0xc2000000, 0xc2400080, 0xdf600038, 0xb624ffea,
+ 0xc000491c, 0xca4000f8, 0xc000491e, 0xca8000f8, 0x99005b78, 0xda5800f8, 0xda9800f9, 0x00000000,
+ 0x58380008, 0xca4000f8, 0xc2000000, 0xce000018, 0xc2a1fffe, 0x5aa9fffe, 0xce021078, 0x5838000a,
+ 0xce8000f8, 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000, 0xc0000838, 0xc2500002, 0xce450800,
+ 0xc0004848, 0xcb8400f8, 0xc2000000, 0xc000082c, 0xca040028, 0x5fb80002, 0xc0004848, 0xcf8400f8,
+ 0x58880002, 0xb6080018, 0x00000000, 0xc0800000, 0xc0004844, 0xcc8400f8, 0x00000000, 0xc121fffe,
+ 0x5911fe14, 0x14100000, 0x8000ded8, 0xc2000000, 0xdf600038, 0x5e200080, 0x8400026a, 0x00000000,
+ 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000, 0xc000480c, 0xca0000f8, 0xc0004910, 0xca4000f8,
+ 0xc000492c, 0xca8000f8, 0xc0004968, 0xcac000f8, 0x00000000, 0xc121fffe, 0x5911fe14, 0x14100000,
+ 0x76250000, 0x76290000, 0x76e16000, 0x840001c2, 0xc0004926, 0xca4000f8, 0xc201fffe, 0x76e16000,
+ 0x5a640002, 0x6ae50010, 0x5f200000, 0x8400001a, 0x6a250000, 0x80000010, 0xc6e000f8, 0x62014008,
+ 0xc0004926, 0xce8000f8, 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000, 0xc0004968, 0xca4000f8,
+ 0xc2000002, 0x6a290000, 0x7e010000, 0x76612000, 0xce4000f8, 0x00000000, 0xc121fffe, 0x5911fe14,
+ 0x14100000, 0x6eb4a000, 0x6e944000, 0x4755a000, 0x4769a000, 0x5b747000, 0x58340002, 0xc2000000,
+ 0xca0000d8, 0x5834002e, 0xc2400000, 0xca400078, 0x6eb0a000, 0x6ebc4000, 0x473d8000, 0x47298000,
+ 0x5b30302e, 0x5b300004, 0x6e642000, 0x4225e000, 0xc39a8024, 0xc7380060, 0xc6b81c18, 0x99005b78,
+ 0xdb9800f8, 0xdbd800f9, 0x00000000, 0xc2000000, 0xdf600038, 0x5e200080, 0x84000352, 0x00000000,
+ 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000, 0xc000490e, 0xca0000f8, 0xc00049a0, 0xca8000f8,
+ 0xc000492a, 0xca4000f8, 0xc000496a, 0xcb0000f8, 0xc0004956, 0xcac000f8, 0x00000000, 0xc121fffe,
+ 0x5911fe14, 0x14100000, 0x77218000, 0x77258000, 0x77298000, 0x8400029a, 0xc201fffe, 0x77218000,
+ 0x5aec0002, 0x6b2d0010, 0x5ea00000, 0x8400001a, 0x6a2d0000, 0x80000010, 0xc72000f8, 0x62016008,
+ 0xc0004956, 0xcec000f8, 0x6ef4a000, 0x6ed44000, 0x4755a000, 0x476da000, 0x5b747000, 0x58340000,
+ 0xc9c000f8, 0xc00049a0, 0xca0000f8, 0xc3000000, 0xc5f04018, 0xc2400000, 0xc5e50038, 0x7e412000,
+ 0x76250000, 0xce0000f8, 0xc0004980, 0x40300000, 0xcec000f8, 0xc161fffe, 0x5955fffe, 0x14140000,
+ 0x00000000, 0xc000496a, 0xca4000f8, 0xc2000002, 0x6a2d0000, 0x7e010000, 0x76612000, 0xce4000f8,
+ 0x00000000, 0xc121fffe, 0x5911fe14, 0x14100000, 0x6ef4a000, 0x6ed44000, 0x4755a000, 0x476da000,
+ 0x5b747000, 0x5834000e, 0xc2000000, 0xca0000d8, 0x58340008, 0xc2400000, 0xca420078, 0x5834000c,
+ 0xc2800000, 0xca832010, 0x6e644010, 0x42250000, 0x4229e000, 0xc39a8008, 0x58340008, 0xcb809018,
+ 0x58340008, 0xc2800000, 0xca810010, 0x6ee0a000, 0x6ee44000, 0x46250000, 0x462d0000, 0x5a200008,
+ 0x5a203008, 0x42290000, 0xc6380060, 0xc6f81c18, 0x99005b78, 0xdb9800f8, 0xdbd800f9, 0x00000000,
+ 0xc000495a, 0xc84000f8, 0x00000000, 0xc3c00002, 0x787c2000, 0xcc4000f8, 0xc0001a1c, 0xca0000f8,
+ 0xc2400008, 0x6a452000, 0x76250000, 0x84000ec2, 0xc0000a28, 0xc3800000, 0xcb840028, 0xc0000a14,
+ 0xc3400000, 0xcb440028, 0xc0004880, 0xcb0400f8, 0xb7b40072, 0x58041802, 0xcac000f8, 0xa7000078,
+ 0x00000000, 0x00000000, 0xa6c8d808, 0xc1000000, 0xc6d00018, 0xc0004980, 0x40100000, 0xca8000f8,
+ 0x80000070, 0x00000000, 0x00000000, 0x00000000, 0x8000d7b8, 0x00000000, 0xc2800000, 0xc7282018,
+ 0xc000490e, 0xca4000f8, 0x6be9e000, 0x00000000, 0x767d2000, 0x8400d770, 0x6ea0a000, 0x6e944000,
+ 0x46150000, 0x46290000, 0x5a207000, 0x5820000c, 0xca0000f8, 0xc0004946, 0xce8000f8, 0xa62203a8,
+ 0x00000000, 0xc2200060, 0xc0004948, 0xce000008, 0xce021038, 0xc240000a, 0xc000494a, 0xce4000f8,
+ 0xc2b60002, 0xc0004964, 0xce837b00, 0x99005e48, 0xc00048a0, 0xc88400f8, 0x00000000, 0xc0004946,
+ 0xcbc000f8, 0x00000000, 0x00000000, 0x6ff8a000, 0x6fd44000, 0x4795c000, 0x47bdc000, 0x5bb87000,
+ 0x99005c08, 0xdbd800f8, 0xdb9800f9, 0x00000000, 0x99005950, 0xc000491c, 0xc1400000, 0xc9420048,
+ 0xc000491c, 0x99005e00, 0xc94000f9, 0xc98000f8, 0x00000000, 0x99005b78, 0xd95800f8, 0xd99800f9,
+ 0x00000000, 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000, 0x99005840, 0xdbd800f8, 0xdb9800f9,
+ 0xc7d800f8, 0x00000000, 0xc121fffe, 0x5911fe14, 0x14100000, 0x6ff8a000, 0x6fd44000, 0x4795c000,
+ 0x47bdc000, 0x5bb87000, 0x58380010, 0xca0000f8, 0xc0004874, 0xc80400f8, 0x6c908000, 0x45088000,
+ 0x45088000, 0x40100000, 0xca4000f8, 0xc43400f8, 0x00000000, 0xc74000f8, 0xce0000f8, 0xc161fffe,
+ 0x5955fffe, 0x14140000, 0x00000000, 0xc000490e, 0xca4000f8, 0xc2800002, 0x6abd4000, 0x72692000,
+ 0xce4000f8, 0x00000000, 0xc121fffe, 0x5911fe14, 0x14100000, 0x990062f0, 0xc0004836, 0xc94000f8,
+ 0xc1800002, 0x00000000, 0x00000000, 0x00000000, 0xa8e2ffe8, 0x00000000, 0x58380000, 0xc90000f8,
+ 0xc00049a0, 0xca0000f8, 0xc2800000, 0xc5290038, 0x72290000, 0xce0000f8, 0xc1220002, 0xd90c00f8,
+ 0xc2000000, 0xc0000a14, 0xca040028, 0xc0000a28, 0xc2500002, 0xce450800, 0x58880002, 0xb6080018,
+ 0xc00048a0, 0xc0800000, 0xcc8400f8, 0x8000d380, 0xc0004946, 0xcbc000f8, 0xc161fffe, 0x5955fffe,
+ 0x14140000, 0x00000000, 0xc000490e, 0xca4000f8, 0xc2800002, 0x6abd4000, 0x72692000, 0xce4000f8,
+ 0x00000000, 0xc121fffe, 0x5911fe14, 0x14100000, 0x6ff8a000, 0x6fd44000, 0x4795c000, 0x47bdc000,
+ 0x5bb87000, 0x58380008, 0xca0000f8, 0x5838000c, 0xca4000f8, 0xc3400000, 0xc6340000, 0xc000494e,
+ 0xcf4000f8, 0xc2800000, 0xc62a0078, 0xc3000000, 0xc6308018, 0x6f304000, 0x43298000, 0xc000493c,
+ 0xcf0000f8, 0xc2c00000, 0xc66c0078, 0xc0004950, 0xcec000f8, 0xc2800000, 0xc66ae020, 0xc0004954,
+ 0xce8000f8, 0x5f740000, 0x840001a0, 0x5e300028, 0x46e12000, 0x8400016a, 0x46e12000, 0x88000132,
+ 0x5e300018, 0x46e12000, 0x8800002a, 0x46e12000, 0x84000042, 0x00000000, 0x800000c0, 0x00000000,
+ 0x99005f88, 0xdbd800f8, 0xdb9800f9, 0xc78000f8, 0xc3400002, 0xc000494e, 0xcf4000f8, 0xc161fffe,
+ 0x5955fffe, 0x14140000, 0x00000000, 0xc000490e, 0xca4000f8, 0xc2800002, 0x6abd4000, 0x7e814000,
+ 0x76692000, 0xce4000f8, 0x00000000, 0xc121fffe, 0x5911fe14, 0x14100000, 0xc2200060, 0xc0004948,
+ 0xce021038, 0xc2000000, 0xc000494c, 0xce0000f8, 0x80000080, 0x00000000, 0x99005f88, 0xdbd800f8,
+ 0xdb9800f9, 0xc78000f8, 0x99006188, 0xdbd800f8, 0xdb9800f9, 0xc78000f8, 0xc2200058, 0xc0004948,
+ 0xce021038, 0xc2000002, 0xc000494c, 0xce0000f8, 0xc2000006, 0xc0001006, 0xce0000f8, 0x5838000a,
+ 0xca4000f8, 0xc2200982, 0x5a203b6e, 0xc0001008, 0xce0000f8, 0xc000100a, 0xce4000f8, 0xc0004954,
+ 0xca8000f8, 0xc200000c, 0xc000494a, 0xce0000f8, 0xc0004948, 0xce800008, 0xc2b60000, 0xc0004964,
+ 0xce8000f8, 0x99005e48, 0xc00048a0, 0xc88400f8, 0x00000000, 0xc0004946, 0xcbc000f8, 0xc000494c,
+ 0xca0000f8, 0x6ff8a000, 0x6fd44000, 0x4795c000, 0x47bdc000, 0x5bb87000, 0x5e200000, 0x840000fa,
+ 0x00000000, 0x99005c08, 0xdbd800f8, 0xdb9800f9, 0x00000000, 0x99005950, 0xc000491c, 0xc1400000,
+ 0xc9420048, 0xc000491c, 0x99005e00, 0xc94000f9, 0xc98000f8, 0x00000000, 0x99005b78, 0xd95800f8,
+ 0xd99800f9, 0x00000000, 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000, 0x99005840, 0xdbd800f8,
+ 0xdb9800f9, 0xc7d800f8, 0x00000000, 0xc121fffe, 0x5911fe14, 0x14100000, 0xc000493c, 0xca8000f8,
+ 0xc000494e, 0xcac000f8, 0xc3000018, 0xc3400006, 0x5e200000, 0x8400002a, 0xc2800000, 0xc2c00000,
+ 0xc300001e, 0xc3400000, 0xc6ac1078, 0xc72c0418, 0xc76c0810, 0x58380010, 0xca8000f8, 0x58380008,
+ 0xcec000f8, 0xc6280100, 0xc0004874, 0xc80400f8, 0x6c908000, 0x45088000, 0x45088000, 0x40100000,
+ 0xcb0000f8, 0xc43400f8, 0x00000000, 0xc74000f8, 0xce8000f8, 0xc0004952, 0xce8000f8, 0x00000000,
+ 0x00000000, 0x00000000, 0xa8e2ffe8, 0x00000000, 0xc000494c, 0xca0000f8, 0xc0004950, 0xcac000f8,
+ 0x5e200000, 0x8400006a, 0xdfe800f8, 0x7e814000, 0x5834001a, 0xce8000f8, 0x990062f0, 0xc0004834,
+ 0xc94000f8, 0xc1800002, 0x990062f0, 0xc0004838, 0xc94000f8, 0xc6d800f8, 0xc1220002, 0xd90c00f8,
+ 0x5e200000, 0x84000040, 0x5838002c, 0xcb0000f8, 0xdfe800f8, 0x00000000, 0x58380014, 0xcf0000f8,
+ 0x80000058, 0xc2a1fffe, 0x5aa9fffe, 0x58380000, 0xc90000f8, 0xc00049a0, 0xcb0000f8, 0xc2c00000,
+ 0xc52d0038, 0x732d8000, 0xcf0000f8, 0x5838000a, 0xce8000f8, 0xc3000000, 0xc0000a14, 0xcb040028,
+ 0xc2d00002, 0xc0000a28, 0xcec50800, 0xc000494e, 0xca8000f8, 0x58880002, 0xb4b00018, 0xc00048a0,
+ 0xc0800000, 0xcc8400f8, 0x5ea80000, 0x8400017a, 0x5e200000, 0x84000168, 0xc000493c, 0xca8000f8,
+ 0x00000000, 0x00000000, 0x5aa80060, 0xce8000f8, 0x99005f88, 0xdbd800f8, 0xdb9800f9, 0xc78000f8,
+ 0x99006188, 0xdbd800f8, 0xdb9800f9, 0xc78000f8, 0x58380000, 0xcac000f8, 0x00000000, 0xc2000000,
+ 0xc6e04018, 0xc0004952, 0xcac000f8, 0x58380000, 0xca8000f8, 0xc30c0002, 0xc6300018, 0xa6800098,
+ 0x00000000, 0x00000000, 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000, 0xc0001800, 0xca0000f8,
+ 0x00000000, 0x00000000, 0xa60cffea, 0xc6f00500, 0xc6b0c400, 0xcf0000f8, 0x00000000, 0xc121fffe,
+ 0x5911fe14, 0x14100000, 0x8000c9c8, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8000c960,
+ 0xdcbc00f9, 0x5ffc0000, 0x84000052, 0xc3800002, 0xdb8800f9, 0x5ffc0004, 0x8400c292, 0xc3800000,
+ 0xdb8800f9, 0xc3ce0002, 0xc0000800, 0xcfc0e700, 0xc3e1fffe, 0x597dfffe, 0x593dfe14, 0x94000001,
+ 0x00000000, 0x00000000, 0x00000000, 0xc000487c, 0xc80400f8, 0x00000000, 0x00000000, 0x40080000,
+ 0xcbc000f8, 0xc43800f8, 0x00000000, 0xc000480e, 0xca0000f8, 0xc0004858, 0xcb4400f8, 0x00000000,
+ 0x00000000, 0x47610000, 0x880000b0, 0x00000000, 0xa7c00048, 0xc0004854, 0xc1000002, 0xcd0400f8,
+ 0xc11c0000, 0xc000082c, 0xcd05ce00, 0x800000d8, 0x00000000, 0xa7d20138, 0x00000000, 0xc7e14040,
+ 0xc2400000, 0xc6246028, 0xc200006a, 0x46250000, 0xc6240030, 0xc0000810, 0xce440030, 0x8000ff70,
+ 0xc2000000, 0xc0000808, 0xca040010, 0xc11c0000, 0xc000082c, 0xcd05ce00, 0x5a200002, 0x5e600010,
+ 0x84000010, 0xc2000000, 0xc0000808, 0xce040010, 0xc3400000, 0x80000028, 0xc1200002, 0xc0000818,
+ 0xcd061000, 0x5b740002, 0xc0004858, 0xcf4400f8, 0x99005590, 0xc0004848, 0xc94400f8, 0xc1800000,
+ 0xc11c0002, 0xc000082c, 0xcd05ce00, 0x80000600, 0x5b740002, 0xc0004858, 0xcf4400f8, 0xc78000f8,
+ 0xc13c0002, 0xcd03de00, 0xc0004848, 0xc94400f8, 0xc1800000, 0xc000082c, 0xc9840028, 0x59540002,
+ 0xc0004848, 0xcd4400f8, 0x58880002, 0xb4980580, 0x00000000, 0xc0800000, 0x80000568, 0xc000487c,
+ 0xc80400f8, 0x00000000, 0x00000000, 0x40080000, 0xcbc000f8, 0xc42800f8, 0x00000000, 0xa7c00130,
+ 0xc000484c, 0xca0400f8, 0xc2400000, 0xc0001aec, 0xca440018, 0x5a200002, 0xc000484c, 0xce0400f8,
+ 0xb624008a, 0xc68000f8, 0xc13c0002, 0xcd03de00, 0xc0004848, 0xc94400f8, 0xc1800000, 0xc000082c,
+ 0xc9840028, 0x59540002, 0xc0004848, 0xcd4400f8, 0x58880002, 0xb4980470, 0x00000000, 0xc0800000,
+ 0x80000458, 0xc0004854, 0xc1000004, 0xcd0400f8, 0xc0000820, 0xc2000002, 0xce0400f8, 0xc2000000,
+ 0xc000484c, 0xce0400f8, 0xc0004858, 0xce0400f8, 0x8000ff28, 0xc0004854, 0xc1000000, 0xcd0400f8,
+ 0xc11c0000, 0xc000082c, 0xcd05ce00, 0x99005590, 0xc0004848, 0xc94400f8, 0xc1800000, 0xc1200000,
+ 0xc0000818, 0xcd061000, 0xc11c0002, 0xc000082c, 0xcd05ce00, 0xc2000000, 0xc000484c, 0xce0400f8,
+ 0x80000358, 0xc0001ac0, 0xcb8400f8, 0xc000487c, 0xc80400f8, 0x00000000, 0x00000000, 0x40080000,
+ 0xcbc000f8, 0xc42800f8, 0x00000000, 0x00000000, 0xc68000f8, 0xc13c0000, 0xcd03de00, 0xa780024a,
+ 0x00000000, 0x00000000, 0xa7c0020a, 0x00000000, 0xc0001b00, 0xc2060006, 0xce046308, 0xa7e801c2,
+ 0x00000000, 0xc0004850, 0xca0400f8, 0xc2400000, 0xc0001aec, 0xca448018, 0x5a200002, 0xc0004850,
+ 0xce0400f8, 0xb62400aa, 0x00000000, 0xc68000f8, 0xc13c0002, 0xcd03de00, 0xc0001acc, 0xc2000002,
+ 0xce040000, 0xc0004848, 0xc94400f8, 0xc1800000, 0xc000082c, 0xc9840028, 0x59540002, 0xc0004848,
+ 0xcd4400f8, 0x58880002, 0xb49801c8, 0x00000000, 0xc0800000, 0x800001b0, 0xc0004854, 0xc1000000,
+ 0xcd0400f8, 0xc11c0000, 0xc000082c, 0xcd05ce00, 0x99005590, 0xc0004848, 0xc94400f8, 0xc1800000,
+ 0xc2000000, 0xc0000820, 0xce0400f8, 0xc1200000, 0xc0000818, 0xcd061000, 0xc11c0002, 0xc000082c,
+ 0xcd05ce00, 0xc0004850, 0xce0400f8, 0xc2000002, 0xc0001acc, 0xce040008, 0x800000e8, 0xc2000002,
+ 0xc0004850, 0xce0400f8, 0x8000fe88, 0xc2000000, 0xc0004850, 0xce0400f8, 0xa7e60032, 0x00000000,
+ 0xc2000002, 0xc0001b00, 0xce040000, 0x8000fe70, 0x00000000, 0xa7860052, 0x00000000, 0xc68000f8,
+ 0xc13c0002, 0xcd03de00, 0xc2020002, 0xc7e2a540, 0xc0001b00, 0xce0400f8, 0x8000fe18, 0xc2040002,
+ 0xc0001b00, 0xce044200, 0x8000fdf8, 0xc2c80002, 0x6ac56000, 0xdacc00f8, 0xc0004854, 0xcb4400f8,
+ 0xc0004848, 0xcb8400f8, 0xc0000838, 0xc3c00000, 0xcbc40028, 0x5ef40004, 0x84000022, 0xc3000000,
+ 0xc0001acc, 0xcf042100, 0x47f98000, 0x8400002a, 0x47f98000, 0x88000030, 0xc1006e8c, 0x8000b6c8,
+ 0xc0004840, 0xcc8400f8, 0x8000f6b0, 0xc0001ac0, 0xcac400f8, 0xc0004854, 0xcb4400f8, 0xa6c0fbd2,
+ 0x00000000, 0x5ef40000, 0x8400f70a, 0x5ef40002, 0x8400f99a, 0x5ef40004, 0x8400fb9a, 0xc1006ce8,
+ 0x8000b640, 0x00000000, 0xc0800000, 0xdf4b0038, 0xc0004900, 0xcb8000f8, 0xc2000000, 0xc000490a,
+ 0xa78000d0, 0xcbc000f8, 0xc1000000, 0xd90000f9, 0xc1000002, 0xd90c00f8, 0x6ff46000, 0x477da000,
+ 0x5b744c80, 0xc2400000, 0x58340004, 0xca400078, 0xc0004900, 0xce000000, 0x5a640002, 0x58340004,
+ 0xc6500078, 0xcd000078, 0xc0004914, 0xca4000f8, 0xc2000002, 0x6a3d0000, 0x72612000, 0xce4000f8,
+ 0xc0000408, 0xce0000f8, 0xa78200d8, 0xc0004908, 0xcbc000f8, 0xc1000000, 0xd90000f9, 0xc1000002,
+ 0xd90c00f8, 0x6ff4a000, 0x6fd44000, 0x4755a000, 0x477da000, 0x5b747000, 0xc2800000, 0x58340006,
+ 0xca800078, 0xc2000000, 0xc0004900, 0xce002100, 0x5ea80002, 0x58340006, 0xc6900078, 0xcd000078,
+ 0x5a7c0020, 0xc2000002, 0x6a250000, 0xc0000408, 0xce0000f8, 0xdca800f9, 0x5ea80000, 0x8400b4b0,
+ 0x00000000, 0xa4800230, 0x00000000, 0xc3c00000, 0xc000140e, 0xcbc00018, 0xc3400000, 0xc2400000,
+ 0x6ff86000, 0x47bdc000, 0x5bb84c80, 0x58380008, 0xcb400078, 0x58380006, 0xca400078, 0x5f740002,
+ 0x58380008, 0xc7500078, 0xcd000078, 0xc2000000, 0x58380004, 0xca020078, 0xc3000000, 0x5838000c,
+ 0xcb000020, 0x5a640002, 0x46610000, 0x84000010, 0xc2400000, 0x58380006, 0xc6500078, 0xcd000078,
+ 0xc2000000, 0x5838000a, 0xca020078, 0x5b300002, 0x5838000c, 0xc7100020, 0xcd000020, 0xc2420020,
+ 0x5a200004, 0x46252000, 0x84000010, 0xc2000000, 0x5838000a, 0xc6101078, 0xcd021078, 0xc0004966,
+ 0xca4000f8, 0xc2000002, 0x6a3d0000, 0x72612000, 0xce4000f8, 0x5f740000, 0x84000040, 0xc0004912,
+ 0xca0000f8, 0xc2c00002, 0x6afd6000, 0x7ec16000, 0x762d0000, 0xce0000f8, 0x5f300020, 0x84000040,
+ 0xc0004924, 0xca0000f8, 0xc2c00002, 0x6afd6000, 0x7ec16000, 0x762d0000, 0xce0000f8, 0xa4820070,
+ 0xc2400000, 0xc000140e, 0xca408018, 0xc2000002, 0xc0004900, 0xce000000, 0xc000490a, 0xce4000f8,
+ 0xc1000000, 0xd90000f9, 0xd8400078, 0xc1000004, 0xd90000f9, 0xa4840270, 0x00000000, 0xc3c00000,
+ 0xc000140e, 0xcbc10018, 0xc2800000, 0xc2000000, 0x6ff8a000, 0x6fd44000, 0x4795c000, 0x47bdc000,
+ 0x5bb87000, 0x5838002e, 0xca800078, 0x58380006, 0xca020078, 0xc3400000, 0x5838002e, 0xcb420078,
+ 0x5aa80002, 0x46a10000, 0x84000010, 0xc2800000, 0x5838002e, 0xc6900078, 0xcd000078, 0x5f740002,
+ 0x5838002e, 0xc7501078, 0xcd021078, 0xc0004968, 0xca4000f8, 0xc2000002, 0x6a3d0000, 0x72612000,
+ 0xce4000f8, 0xc000492a, 0xca8000f8, 0x5e740000, 0x84000040, 0xc0004910, 0xca0000f8, 0xc2c00002,
+ 0x6afd6000, 0x7ec16000, 0x762d0000, 0xce0000f8, 0x6abd4010, 0xa68000ba, 0x00000000, 0x58380032,
+ 0xca0000f8, 0x58000002, 0xca4000f8, 0x5838000c, 0x00000000, 0xce0000f9, 0xce4000f8, 0xc000492a,
+ 0xca0000f8, 0xc2c00002, 0x6afd6000, 0x722d0000, 0xce0000f8, 0xc000492c, 0xca0000f8, 0xc2c00002,
+ 0x6afd6000, 0x722d0000, 0xce0000f8, 0x80000040, 0xc000492c, 0xca0000f8, 0xc2c00002, 0x6afd6000,
+ 0x7ec16000, 0x762d0000, 0xce0000f8, 0xa4880148, 0xc2c00000, 0xc000140e, 0xcac20018, 0xc000490e,
+ 0xca4000f8, 0xc2000002, 0x6a2d0000, 0x7e010000, 0x76612000, 0xce4000f8, 0xc000496a, 0xca4000f8,
+ 0xc2000002, 0x6a2d0000, 0x72612000, 0xce4000f8, 0x6ef0a000, 0x6ed44000, 0x47158000, 0x472d8000,
+ 0x5b307000, 0x58300000, 0xca0000f8, 0x00000000, 0xc2400002, 0x76612000, 0x84000072, 0x58300000,
+ 0xca4000f8, 0xc2800000, 0x00000000, 0xc6684018, 0xc24c0002, 0xc6a40018, 0xc624c400, 0x58300010,
+ 0xca400500, 0x00000000, 0xc0001800, 0xce4000f8, 0xa4860070, 0xc2400000, 0xc000140e, 0xca418018,
+ 0xc2020002, 0xc0004900, 0xce002100, 0xc0004908, 0xce4000f8, 0xc1000000, 0xd90000f9, 0xd8400078,
+ 0xc1000004, 0xd90000f9, 0xc0001408, 0xcc8000f8, 0xc10e0002, 0xd90c00f8, 0x8000edb0, 0xdfbc00f9,
+ 0xc000496e, 0x99006298, 0xc94000f8, 0xc7d800f8, 0x00000000, 0xc57000f8, 0x5ef00020, 0x88000148,
+ 0x6f346000, 0x4771a000, 0x5b744c80, 0x58340008, 0xc2400000, 0xca400078, 0x00000000, 0xc2000000,
+ 0x5a640002, 0xce400078, 0x58340004, 0xca000078, 0x00000000, 0x00000000, 0x5e200002, 0xce000078,
+ 0xc0004912, 0xca8000f8, 0xc2400002, 0x6a712000, 0x72a54000, 0xce8000f8, 0x5e200000, 0x84000052,
+ 0xc000480a, 0xca0000f8, 0xc0000408, 0xca8000f8, 0x76250000, 0x00000000, 0x72a14000, 0xce8000f8,
+ 0x80000038, 0xc0004914, 0xca0000f8, 0x7e412000, 0x00000000, 0x76250000, 0xce0000f8, 0x800000d0,
+ 0x6ef4a000, 0x6ed44000, 0x4755a000, 0x476da000, 0x5b747000, 0x5834002e, 0xc2400000, 0xca420078,
+ 0x00000000, 0xc2000000, 0x5a640002, 0xc6501078, 0xcd021078, 0x58340006, 0xca000078, 0x00000000,
+ 0x00000000, 0x5a200002, 0xce000078, 0xc0004910, 0xca4000f8, 0xc2000002, 0x6a2d0000, 0x72612000,
+ 0xce4000f8, 0xc2000002, 0x6a310000, 0xc000042a, 0xce0000f8, 0xc1040002, 0xd90c00f8, 0x00000000,
+ 0x8000eb20, 0x00000000, 0xc4980928, 0x9d000000, 0xc5580028, 0xc0000838, 0xcd8400f8, 0xc1440200,
+ 0xc1c03800, 0xc55c1070, 0xc000100e, 0x9d000000, 0xcd8000f8, 0xc000100c, 0xcdc000f8, 0xc0004862,
+ 0xc9c000f8, 0x00000000, 0x00000000, 0xd9d800f9, 0xc0007800, 0x401c0000, 0x5dc07a00, 0x88000012,
+ 0x5c000200, 0xcd8000f8, 0xc1f0000a, 0x715ca000, 0xdd9800f8, 0xdd9c00f9, 0x41d8e000, 0xc5d40260,
+ 0xc0001010, 0xcd4000f8, 0x6c9c8000, 0x45c8e000, 0x45c8e000, 0x59dc0004, 0xc1601260, 0xc5d40260,
+ 0x9d000000, 0xc0001012, 0xcd4000f8, 0x00000000, 0x00000000, 0xd95800f8, 0x6d586000, 0x4594c000,
+ 0x59984c80, 0xd99800f9, 0x5818000a, 0xc1800000, 0xc9800078, 0xc0006e00, 0x6d5ca000, 0x401c0000,
+ 0x40180000, 0xc94000f8, 0x58000002, 0x00000000, 0xc9c000f8, 0xc0004930, 0xcd4000f8, 0xc0004932,
+ 0xcdc000f8, 0x59980004, 0xc1c20020, 0xb59c0018, 0x00000000, 0xc1800000, 0xdd9c00f9, 0x581c000a,
+ 0xcd800078, 0x581c000c, 0xc1800000, 0xc9800020, 0xc1c00002, 0xdd9400f8, 0x69d4e000, 0x5d980002,
+ 0xcd800020, 0xc0004924, 0xc98000f8, 0x00000000, 0x9d000000, 0x00000000, 0x719cc000, 0xcd8000f8,
+ 0xc000492a, 0xc94000f8, 0xc1c00002, 0x69d8e000, 0x7dc0c000, 0x7558a000, 0xcd4000f8, 0xc000492c,
+ 0xc94000f8, 0xdd8000f9, 0x58000032, 0x755ca000, 0x84000090, 0xc94000f9, 0xc98000f8, 0xdd8000f9,
+ 0x5800000c, 0x00000000, 0xcd4000f9, 0xcd8000f8, 0xc000492c, 0xc94000f8, 0xc000492a, 0xc98000f8,
+ 0x715ca000, 0xc000492c, 0xcd4000f8, 0x719cc000, 0xc000492a, 0xcd8000f8, 0x9d000000, 0x00000000,
+ 0x00000000, 0x00000000, 0xc0004862, 0xc98000f8, 0x00000000, 0xc1c00200, 0x4194c000, 0x459ce000,
+ 0x88000012, 0xc5d800f8, 0xc0004862, 0xcd8000f8, 0xc0001406, 0xc98000f8, 0xc1c00002, 0x9d000000,
+ 0xc5d80a00, 0xc5581048, 0xcd8000f8, 0xc0004930, 0xc98000f8, 0xc0004932, 0xc9c000f8, 0xc140000e,
+ 0xc5581c18, 0xdd9400f8, 0xc0007800, 0x40140000, 0x5d407a00, 0x88000012, 0x5c000200, 0xcd8000f8,
+ 0x58000002, 0x5d407a00, 0x88000012, 0x5c000200, 0xcdc000f8, 0xdd5400f8, 0xc1c00000, 0x58140006,
+ 0xc9c20078, 0xc1800000, 0x58140000, 0xc98000d8, 0x6ddc2000, 0xc000491e, 0x41d8e000, 0xcdc000f8,
+ 0xdd9800f8, 0xc1c00022, 0xc5d80d70, 0xdd9400f9, 0xc5581c18, 0xc000491c, 0xcd8000f8, 0xdd5400f8,
+ 0xc1c00000, 0x58140006, 0xc9c20078, 0xc1800000, 0x58140004, 0xc9820078, 0x00000000, 0x59dc0002,
+ 0x45d8c000, 0x84000010, 0xc1c00000, 0x9d000000, 0x58140006, 0xc5d81078, 0xcd821078, 0xc0004860,
+ 0xc94000f8, 0xc1820080, 0xc1d00002, 0x58147700, 0xd58000f8, 0x58000002, 0xd58000f9, 0x59540004,
+ 0xb5580018, 0xc0004860, 0xc1400000, 0xcd4000f8, 0xdd9800f9, 0x9d000000, 0xdd9400f8, 0xc0001404,
+ 0xcdc10800, 0xc1c00000, 0xc1800200, 0x5d980004, 0xdf5d0048, 0x459ca000, 0x8800fff2, 0xdd8000f9,
+ 0x5800000c, 0x00000000, 0xc94000f9, 0xc98000f8, 0xc1c00002, 0xc5d43f00, 0xc5d81e00, 0xc0004862,
+ 0xc9c000f8, 0x00000000, 0x00000000, 0x581c7800, 0x5dc07a00, 0x88000012, 0x5c000200, 0xcd4000f8,
+ 0x58000002, 0x5dc07a00, 0x88000012, 0x5c000200, 0xcd8000f8, 0xc0004862, 0xc9c000f8, 0x00000000,
+ 0xc15004c0, 0xc5d40060, 0xdd9c00f8, 0xc5d41c18, 0xc1c00000, 0xdd8000f9, 0x58000030, 0xc9c00078,
+ 0xdd8000f9, 0x58000002, 0xc98000f8, 0x6ddc2000, 0xc000491c, 0x41d8e000, 0xcd4000f9, 0xcdc000f8,
+ 0xdd9400f9, 0xc1c00000, 0x58140030, 0xc9c00078, 0xc1800000, 0x58140006, 0xc9820078, 0x00000000,
+ 0x59dc0002, 0x45d8c000, 0x84000010, 0xc1c00000, 0x9d000000, 0x58140030, 0xc5d80078, 0xcd800078,
+ 0xc1c00000, 0xdf5c0038, 0x5ddc0080, 0x8400ffea, 0x00000000, 0x9d000000, 0x00000000, 0x00000000,
+ 0x00000000, 0xc160fffe, 0xc0000a10, 0xc9440060, 0xc1a0fffe, 0x59983008, 0xc000100c, 0xcd4000f8,
+ 0xc000100e, 0xcd8000f8, 0xc0004964, 0xc98000f8, 0x00000000, 0xc170000a, 0x7158a000, 0x6c988000,
+ 0x4588c000, 0x4588c000, 0x59980004, 0xc5940270, 0xc0001010, 0xcd4000f8, 0xc0004946, 0xc94000f8,
+ 0x00000000, 0x00000000, 0x6d58a000, 0x6d5c4000, 0x459cc000, 0x4594c000, 0xc000494a, 0xc94000f8,
+ 0xc0004948, 0xc9c000f8, 0x4194c000, 0xc1400012, 0xc55c1818, 0x9d000000, 0xc59c0268, 0xc0001012,
+ 0xcdc000f8, 0xc1400000, 0x58000012, 0xc9410038, 0xc0004950, 0xc9c000f8, 0xc55800f8, 0xc5940838,
+ 0xc5581078, 0xd99400f8, 0xc000493c, 0xc94000f8, 0xc0004954, 0xc98000f8, 0x59dc00a8, 0x45d4e000,
+ 0x41d8e000, 0x5d5c0030, 0x88000010, 0xc1c00030, 0xc1800000, 0xc5d84028, 0xc1400000, 0xc5d40008,
+ 0x5dd40002, 0x84000072, 0x5dd40004, 0x8400009a, 0x5dd40006, 0x840000c2, 0x5dd80026, 0x840000ea,
+ 0xdd5400f8, 0xdd8000f9, 0x58000008, 0x40180000, 0xcd4000f8, 0x59980002, 0x8000ffc0, 0xdd5400f8,
+ 0xdd8000f9, 0x58000008, 0x40180000, 0xcd4000b8, 0x59980002, 0x8000ff88, 0xdd5400f8, 0xdd8000f9,
+ 0x58000008, 0x40180000, 0xcd400078, 0x59980002, 0x8000ff50, 0xdd5400f8, 0xdd8000f9, 0x58000008,
+ 0x40180000, 0xcd400038, 0x59980002, 0x8000ff18, 0x00000000, 0x9d000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x58000012, 0xc94000f8, 0xc0004954, 0xc9c000f8, 0xc0004950, 0xc9400078, 0xdd8000f9,
+ 0x58000028, 0x5d9c0000, 0x84000052, 0x5d9c0002, 0x84000052, 0x5d9c0004, 0x8400006a, 0xc55b0038,
+ 0xc55c08b8, 0xcd800039, 0xcdc108b8, 0x80000060, 0xcd4000f8, 0x80000050, 0xc55900b8, 0xc55c1838,
+ 0xcd8000b9, 0xcdc31838, 0x80000028, 0xc55a0078, 0xc55c1078, 0xcd800079, 0xcdc21078, 0x9d000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x59540002, 0x6994e018, 0x61c0c008, 0x4194a000, 0x5d940040,
+ 0x88000012, 0xc59400f8, 0x9d000000, 0xcd4000f8, 0x00000000, 0x00000000, 0x9d000000, 0x4158a000,
+ 0xcd4000f8, 0x00000000,
+};
+
+static unsigned int ar9_fw_data[] = {
+};
+
+
+#endif // IFXMIPS_ATM_FW_AR9_H
diff --git a/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_fw_ar9_retx.h.svn-base b/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_fw_ar9_retx.h.svn-base
new file mode 100644
index 0000000..0fc4789
--- /dev/null
+++ b/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_fw_ar9_retx.h.svn-base
@@ -0,0 +1,611 @@
+#ifndef IFXMIPS_ATM_FW_AR9_H
+#define IFXMIPS_ATM_FW_AR9_H
+
+
+/******************************************************************************
+**
+** FILE NAME : ifxmips_atm_fw_ar9.h
+** PROJECT : UEIP
+** MODULES : ATM (ADSL)
+**
+** DATE : 22 OCT 2007
+** AUTHOR : Xu Liang
+** DESCRIPTION : ATM Driver (PP32 Firmware)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 22 OCT 2007 Xu Liang Initiate Version, v00.01
+*******************************************************************************/
+
+
+#define VER_IN_FIRMWARE 1
+
+#define ATM_FW_VER_MAJOR 0
+#define ATM_FW_VER_MINOR 15
+
+
+static unsigned int firmware_binary_code[] = {
+ 0x800004B8, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8000FFE0, 0x00000000, 0x00000000, 0x00000000,
+ 0xC1000002, 0xD90C00F8, 0xC2000002, 0xDA0800F9, 0xC0001B50, 0x8C100000, 0x00000000, 0x00000000,
+ 0x00000000, 0xC2000000, 0xDA0800F9, 0x80006030, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x80006008, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC1001DA6, 0x8D3C0000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x80005F08, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC0400000, 0xC0004840, 0xC88400F8, 0xC2001AEE, 0x8E100000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC0400002, 0xC0004840, 0xC88400F8, 0xC2001AEE, 0x8E100000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC3C00004, 0xDBC800F9, 0xC10C0002, 0xD90C00F8, 0x8000FEE0, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC10E0002, 0xD90C00F8, 0xC0004808, 0xC84000F8, 0xC2001B4C, 0x8E100000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC3E1FFFE, 0x597DFFFE, 0x593DFE14, 0x900004D9, 0x00000000, 0x00000000, 0x00000000, 0x90CC0481,
+ 0x00000000, 0x00000000, 0x00000000, 0xC3E0A252, 0x5BFC001E, 0xC0004002, 0xCFC000F8, 0xC3C00000,
+ 0xDBC800F9, 0xC1400008, 0xC1900000, 0x71588000, 0x14100100, 0xC140000A, 0xC1900002, 0x71588000,
+ 0x14100100, 0xC140000C, 0xC1900004, 0x71588000, 0x14100100, 0xC1400004, 0xC1900006, 0x71588000,
+ 0x14100100, 0xC1400006, 0xC1900008, 0x71588000, 0x14100100, 0xC140000E, 0xC190000A, 0x71588000,
+ 0x14100100, 0xC1400000, 0xC190000C, 0x71588000, 0x14100100, 0xC1400002, 0xC190000E, 0x71588000,
+ 0x14100100, 0xC0400000, 0xC11C0000, 0xC000082C, 0xCD05CE00, 0xC11C0002, 0xC000082C, 0xCD05CE00,
+ 0xC0400002, 0xC11C0000, 0xC000082C, 0xCD05CE00, 0xC0000824, 0x00000000, 0xCBC000F9, 0xCB8000F9,
+ 0xCB4000F9, 0xCB0000F8, 0xC0004878, 0x5BFC4000, 0xCFC000F9, 0x5BB84000, 0xCF8000F9, 0x5B744000,
+ 0xCF4000F9, 0x5B304000, 0xCF0000F8, 0xC0000A10, 0x00000000, 0xCBC000F9, 0xCB8000F8, 0xC0004874,
+ 0x5BFC4000, 0xCFC000F9, 0x5BB84000, 0xCF8000F8, 0xC30001FE, 0xC000140A, 0xCF0000F8, 0xC3000000,
+ 0x7F018000, 0xC000042E, 0xCF0000F8, 0xC000040E, 0xCF0000F8, 0xC3C1FFFE, 0xC000490E, 0xCFC00078,
+ 0xC000492C, 0xCFC00078, 0xC0004924, 0xCFC00038, 0xC0004912, 0xCFC00038, 0xC0004966, 0xCFC00038,
+ 0xC0004968, 0xCFC00078, 0xC000496A, 0xCFC00078, 0xC3C00000, 0xC2800020, 0xC3000000, 0x7F018000,
+ 0x6FF88000, 0x6FD44000, 0x4395C000, 0x5BB84A00, 0x5838000A, 0xCF0000F8, 0x5BFC0002, 0xB7E8FFC8,
+ 0x00000000, 0xC3C00000, 0xC2800010, 0x6FF86000, 0x47BDC000, 0x5BB84C80, 0xC3400000, 0x58380004,
+ 0xCB420078, 0x00000000, 0x58380008, 0xCF400078, 0x5BFC0002, 0xB7E8FFB0, 0x00000000, 0xC3C00000,
+ 0xC2800020, 0xC348001E, 0xC3000000, 0x7F018000, 0x6FF8A000, 0x6FD44000, 0x4795C000, 0x47BDC000,
+ 0x5BB87000, 0x58380008, 0xCF408418, 0x5838000A, 0xCF0000F8, 0x5BFC0002, 0xB7E8FFB0, 0x00000000,
+ 0x00000000, 0xC0004816, 0xC3C00000, 0xCBC00078, 0x00000000, 0x00000000, 0xC1000000, 0xD90400F9,
+ 0xDBC40078, 0xC1000006, 0xD90400F9, 0x00000000, 0xC121FFFE, 0x5911FE54, 0x14100000, 0xC3C00000,
+ 0xDCFC2000, 0x5FFC0002, 0x00000000, 0x98C08D62, 0xC0004730, 0xC94000F8, 0xC0004732, 0xC0001AF2,
+ 0xCBC000F8, 0x00000000, 0x00000000, 0xA7C20470, 0xC000474A, 0xCA8000F8, 0x00000000, 0x00000000,
+ 0x5D280000, 0x8400FFE0, 0x00000000, 0xC121FFFE, 0x5911FEF4, 0x14100000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC2802000, 0x6EA8E010, 0xC0004200, 0xC2400000, 0x7E410000, 0xC1000000, 0xCE4000F9, 0xCE4000F9,
+ 0xCE4000F9, 0xCE4000F9, 0x5EA80002, 0x8400FFD8, 0xC0004300, 0xC2800200, 0x6EA84010, 0xCE4000F9,
+ 0xCE0000F9, 0xCE4000F9, 0xCE0000F9, 0xCE4000F9, 0xCE0000F9, 0xCE4000F9, 0xCE0000F9, 0x5EA80002,
+ 0x8400FFB8, 0xC0004700, 0xC2800200, 0x6EA8E010, 0xCE4000F9, 0xCE4000F9, 0xCE4000F9, 0xCE4000F9,
+ 0x5EA80002, 0x8400FFD8, 0xC0004740, 0xCE4000F8, 0xC0004742, 0xC1000200, 0x5D100002, 0xCD0000F8,
+ 0xC0004744, 0xCE4000F8, 0xC0004746, 0xCE4000F8, 0xC0004748, 0xCE4000F8, 0xC000474A, 0xCE4000F8,
+ 0xC000474C, 0xC1000002, 0xCD0000F8, 0xC000474E, 0xCE4000F8, 0xC0004750, 0xCE4000F8, 0xC0004752,
+ 0xCE4000F8, 0xC0004754, 0xCE4000F8, 0xC0400000, 0xC11C0000, 0xC000082C, 0xCD05CE00, 0xC0000838,
+ 0xCE4000F8, 0xC0000818, 0xCE4000F8, 0xC0000820, 0xCE4000F8, 0xC2804840, 0xC240485A, 0x98C086B0,
+ 0xC68000F8, 0xC65400F8, 0xC1800000, 0xC11C0002, 0xC000082C, 0xCD05CE00, 0x00000000, 0xC121FFFE,
+ 0x5911FE54, 0x14100000, 0xC0000A10, 0xCB8000F8, 0xC0000A12, 0xCB4000F8, 0xC0000A14, 0xCB0000F8,
+ 0xC0000A16, 0xCAC000F8, 0xC0000040, 0xC2800000, 0xCE800000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xC2800002,
+ 0xCE800000, 0xC0000A10, 0xCF8000F8, 0xC0000A12, 0xCF4000F8, 0xC0000A14, 0xCF0000F8, 0xC0000A16,
+ 0xCEC000F8, 0xC1000000, 0xC00048A0, 0xCD0000F8, 0xC00048A2, 0xCD0000F8, 0xC0001AF2, 0xC1000000,
+ 0xCD002100, 0x80001038, 0x00000000, 0xC3C00000, 0xDCFC2000, 0x5FFC0002, 0x00000000, 0x98C08D62,
+ 0xC0004730, 0xC94000F8, 0xC0004732, 0x800033D8, 0x00000000, 0xC3C00000, 0xDCFC2000, 0x5FFC0002,
+ 0x00000000, 0x98C08D62, 0xC0004730, 0xC94000F8, 0xC0004732, 0xC0004810, 0xC90000F8, 0xC000474A,
+ 0xC94000F8, 0xA50007E8, 0x00000000, 0x5D140002, 0x840007D2, 0xC1000000, 0xC000484A, 0xC90000F8,
+ 0xC0004740, 0xC84000F8, 0x5D100000, 0x84000798, 0x00000000, 0x00000000, 0xC121FFFE, 0x5911FEF4,
+ 0x14100000, 0xC0004744, 0xC88000F8, 0xC0001AF0, 0xC3000000, 0x58000002, 0xCB010038, 0x6C7C2000,
+ 0x5BFC4300, 0x98C08A88, 0xC1400000, 0xC4540020, 0x6C40A010, 0x5D240002, 0x8400021A, 0x00000000,
+ 0xC0004742, 0xCA8000F8, 0x00000000, 0x00000000, 0x59280002, 0x6D130000, 0x6D130010, 0x45048000,
+ 0x84000692, 0x00000000, 0x98C08870, 0xC45400F8, 0xC69800F8, 0xC241FFFE, 0xC67400F8, 0x5D35FFFE,
+ 0x84000652, 0x47448000, 0x84000642, 0xC1000000, 0x6F502000, 0xC0004300, 0x40100000, 0xC1400000,
+ 0x58000000, 0xC9410038, 0xC1800000, 0xC0004814, 0xC9820038, 0x4714A000, 0xC10001FE, 0x4150A004,
+ 0x45588000, 0x880005CA, 0x4744C000, 0xC1000200, 0x4190C004, 0xC000473E, 0xC90000F8, 0x00000000,
+ 0x00000000, 0x41188000, 0xCD0000F8, 0xC000471C, 0xC90000F8, 0x00000000, 0x00000000, 0x41188000,
+ 0xCD0000F8, 0x98C087E8, 0xC45400F8, 0x6C58A010, 0xC0004700, 0x58440002, 0x6C470000, 0x6C470010,
+ 0x44748000, 0x8400FFC0, 0xC74400F8, 0xC0004740, 0xCC4000F8, 0xC0800000, 0xC0004744, 0xCC8000F8,
+ 0x800004D0, 0xC1000000, 0x583C0000, 0xC9000038, 0x00000000, 0x00000000, 0x44908000, 0x88000280,
+ 0xC1400000, 0x583C0000, 0xC9410038, 0xC1800000, 0xC0004814, 0xC9800038, 0x4714A000, 0xC10001FE,
+ 0x4150A004, 0x45588000, 0x88000442, 0xC3800000, 0x583C0002, 0xCB820078, 0xC1000000, 0x583C0002,
+ 0xC9000078, 0x00000000, 0x00000000, 0x47908000, 0x8400024A, 0xC0400002, 0xC0800000, 0xC3C00000,
+ 0xC000481A, 0xC80000F8, 0x6F908000, 0x45388000, 0x45388000, 0x4011E000, 0xC000491E, 0xCFC000F8,
+ 0xC3400000, 0xC0004878, 0xC80400F8, 0x6C908000, 0x45088000, 0x45088000, 0x40100000, 0xCAC000F8,
+ 0xC43000F8, 0x00000000, 0xC7340060, 0xC1000002, 0xC5341B00, 0xC100001C, 0xC5341048, 0xC100000C,
+ 0xC5340D10, 0xC000491C, 0xCF4000F8, 0xC3000000, 0xDF700038, 0x5D300080, 0x8800FFE8, 0xC000474A,
+ 0xC1000002, 0xCD0000F8, 0xC000491C, 0xCB4000F8, 0xC000491E, 0xCBC000F8, 0x99007F18, 0xDB5800F8,
+ 0xDBD800F9, 0x00000000, 0xC1400000, 0xC794A030, 0xC1800000, 0xC7980020, 0x58144200, 0xC9C000F8,
+ 0xC1210000, 0x69188010, 0x7D008000, 0x75D0E000, 0xCDC000F8, 0x80000228, 0x00000000, 0xC1000000,
+ 0x583C0000, 0xC903E000, 0x00000000, 0x00000000, 0x5D100000, 0x84000042, 0xC0004734, 0xC90000F8,
+ 0x00000000, 0x00000000, 0x59100002, 0xCD0000F8, 0x800000C0, 0xC1400000, 0x583C0000, 0xC9410038,
+ 0xC1800000, 0xC0004814, 0xC9820038, 0x4714A000, 0xC10001FE, 0x4150A004, 0x45588000, 0x8800015A,
+ 0xC000473E, 0xC90000F8, 0x00000000, 0x00000000, 0x59100002, 0xCD0000F8, 0xC000471C, 0xC90000F8,
+ 0x00000000, 0x00000000, 0x59100002, 0xCD0000F8, 0xC3800000, 0x583C0002, 0xCB820078, 0x00000000,
+ 0x00000000, 0x5D39FFFE, 0x84000062, 0xC1400000, 0xC794A030, 0xC1800000, 0xC7980020, 0x58144200,
+ 0xC9C000F8, 0xC1210000, 0x69188010, 0x7D008000, 0x75D0E000, 0xCDC000F8, 0x98C087E8, 0xC45400F8,
+ 0x6C58A010, 0xC0004700, 0x58440002, 0x6C470000, 0x6C470010, 0xC0004740, 0xCC4000F8, 0xC0800000,
+ 0xC0004744, 0xCC8000F8, 0x00000000, 0xC121FFFE, 0x5911FE54, 0x14100000, 0x8000F288, 0x00000000,
+ 0x00000000, 0x98C086F0, 0xC0004748, 0xC98000F8, 0xC2000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0xC1400000, 0xC7D4A030, 0xC1800000, 0xC7D80020, 0x58144200,
+ 0xC9C000F8, 0xC1210000, 0x69188010, 0x7D008000, 0x75D0E000, 0xCDC000F8, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x98C087E8, 0xC7D400F8, 0x6FD8A010, 0xC0004700, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x98C08870, 0xC7D400F8, 0xC79800F8, 0xC241FFFE, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x98C08A88, 0xC1400000, 0xC7D40020, 0x6FC0A010,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x98C08AB8, 0xC1400000, 0xC7D40020, 0x6FC0A010,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x98C08AF0, 0xC7D400F8, 0xC0004740, 0xC9C000F8,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x98C08BE0, 0xC7D400F8, 0xC0004742, 0xC98000F8,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xC0004958, 0xC84000F8, 0x00000000, 0xC3C00002,
+ 0x787C2000, 0xCC4000F8, 0xC0004848, 0xCB8400F8, 0xC000495C, 0xCAC400F8, 0xC0004844, 0xC88400F8,
+ 0x47AD0000, 0x8400F492, 0xC000487C, 0xC80400F8, 0x00000000, 0x00000000, 0x40080000, 0xCA0000F8,
+ 0xC0001624, 0xCB0400F8, 0xA63C007A, 0x00000000, 0x00000000, 0xA71EF432, 0x00000000, 0xC0000824,
+ 0xCA8400F8, 0x6CA08000, 0x6CA42000, 0x46250000, 0x42290000, 0xC35E0002, 0xC6340060, 0xC0001624,
+ 0xCF440078, 0xC2000000, 0xC161FFFE, 0x5955FFFE, 0x14140000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0xC0004844, 0xC88400F8, 0xC000082C, 0xCA040038, 0x00000000, 0x00000000, 0x58880002,
+ 0xB6080018, 0x00000000, 0xC0800000, 0xC0004844, 0xCC840038, 0x5AEC0002, 0xC000495C, 0xCEC400F8,
+ 0x5E6C0006, 0x84000060, 0xC0004848, 0xCB8400F8, 0xC0000838, 0xC2500002, 0xCE450800, 0x5FB80002,
+ 0xC0004848, 0xCF8400F8, 0x5EEC0002, 0xC000495C, 0xCEC400F8, 0x00000000, 0xC121FFFE, 0x5911FE54,
+ 0x14100000, 0x8000F290, 0xC000495A, 0xC84000F8, 0x00000000, 0xC3C00002, 0x787C2000, 0xCC4000F8,
+ 0xC0004960, 0xCAC400F8, 0x00000000, 0x00000000, 0x5EEC0000, 0x8400010A, 0x00000000, 0xB6FC0050,
+ 0xC0001600, 0xCA0400F8, 0x00000000, 0x00000000, 0xA61E00D2, 0x6FE90000, 0xC0000A28, 0xCE850800,
+ 0xC2C00000, 0xC2800004, 0xB6E800A0, 0xC0001604, 0xCA8400F8, 0xC0004960, 0xCEC400F8, 0xA69EFCAA,
+ 0x00000000, 0x6FE90000, 0xC0000A28, 0xCE850800, 0xC2C00002, 0xC0001600, 0xCA0400F8, 0x00000000,
+ 0x00000000, 0xA61E002A, 0x6FE90000, 0xC0000A28, 0xCE850800, 0xC2C00000, 0xC0001604, 0xCA8400F8,
+ 0xC0004960, 0xCEC400F8, 0xA69EFC12, 0xC2400000, 0xC0000A14, 0xCA440028, 0x00000000, 0x00000000,
+ 0x466D2000, 0xA4400020, 0xC2800000, 0xDFEB0029, 0x80000010, 0xDFEA0029, 0xB668EC0A, 0x00000000,
+ 0xC00048A0, 0xCB0400F8, 0xC0000A10, 0xCA8400F8, 0x6F208000, 0x6F242000, 0x46250000, 0x42A10000,
+ 0xC2400000, 0xC0000A14, 0xCA440028, 0xC35E0002, 0xC6340060, 0xC0001604, 0xCF440078, 0x5B300002,
+ 0xB6700018, 0x5AEC0002, 0xC3000000, 0xC00048A0, 0xCF0400F8, 0xC0004960, 0xCEC400F8, 0x8000F030,
+ 0xC0004918, 0xD28000F8, 0xC2000000, 0xDF600038, 0x5E600080, 0x840002A2, 0x00000000, 0xC161FFFE,
+ 0x5955FFFE, 0x14140000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xC000480A, 0xCA0000F8,
+ 0xC0004912, 0xCA4000F8, 0xC0004924, 0xCA8000F8, 0xC0004966, 0xCAC000F8, 0x00000000, 0xC121FFFE,
+ 0x5911FE54, 0x14100000, 0x76250000, 0x76290000, 0x762D0000, 0x840001E2, 0xC0004918, 0xCA4000F8,
+ 0xC28001FE, 0x76290000, 0x5A640002, 0x6A254010, 0x5EE80000, 0x8400001A, 0x6AA54000, 0x80000010,
+ 0xC62800F8, 0x62818008, 0xC0004918, 0xCF0000F8, 0xC161FFFE, 0x5955FFFE, 0x14140000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0xC0004966, 0xCA4000F8, 0xC2000002, 0x6A310000, 0x7E010000,
+ 0x76612000, 0xCE4000F8, 0x00000000, 0xC121FFFE, 0x5911FE54, 0x14100000, 0x6F346000, 0x4771A000,
+ 0x5B744C80, 0xC2800000, 0x58340006, 0xCA800078, 0xC2C00000, 0x58340000, 0xCAC000D8, 0xC2400000,
+ 0x5834000A, 0xCA420078, 0x6EA82000, 0x42E9E000, 0x6F2CA000, 0x42E56000, 0x5AEC2E00, 0xC3990040,
+ 0xC7381C18, 0xC6F80060, 0x99007F18, 0xDB9800F8, 0xDBD800F9, 0x00000000, 0xDEA000F8, 0x46310000,
+ 0x8400FD50, 0xC0004958, 0xC84000F8, 0x00000000, 0xC1000002, 0x78502000, 0xCC4000F8, 0xC0004848,
+ 0xCBC400F8, 0xC0004844, 0xC88400F8, 0x5FFC0000, 0x8400ECBA, 0xC0004740, 0xCB0000F8, 0xC0004744,
+ 0xCAC000F8, 0x6F282000, 0x5AA84300, 0xC000487C, 0xC80400F8, 0x00000000, 0x00000000, 0x40080000,
+ 0xCA4000F8, 0xC40000F8, 0x00000000, 0xC0004878, 0xC80400F8, 0x6C908000, 0x45088000, 0x45088000,
+ 0x40100000, 0xC90000F8, 0xC43400F8, 0x00000000, 0x5C440000, 0x840000A2, 0x00000000, 0xC00047D2,
+ 0xC90000F8, 0x00000000, 0x00000000, 0x59100002, 0xCD0000F8, 0x58340002, 0xC9000078, 0x00000000,
+ 0x00000000, 0x58280002, 0x6D120000, 0xCD021078, 0x5AEC0002, 0xC0004744, 0xCEC000F8, 0x80000630,
+ 0x00000000, 0xC00047C0, 0xC90000F8, 0x00000000, 0x00000000, 0x59100002, 0xCD0000F8, 0xA67C0048,
+ 0xC00047C2, 0xC90000F8, 0x00000000, 0x00000000, 0x59100002, 0xCD0000F8, 0x80001E18, 0x00000000,
+ 0xA6600042, 0xC00047C4, 0xC90000F8, 0x00000000, 0x00000000, 0x59100002, 0xCD0000F8, 0x80000570,
+ 0xC00047C6, 0xC90000F8, 0x00000000, 0x00000000, 0x59100002, 0xCD0000F8, 0xC3C00000, 0xC67D0038,
+ 0xC3800000, 0xC6780038, 0x47F08000, 0x840000A8, 0x47AC8000, 0x84000098, 0xC1000000, 0xC0004814,
+ 0xC9000038, 0x00000000, 0x00000000, 0x5D100000, 0x840000F0, 0x5AEC0002, 0xC0004744, 0xCEC000F8,
+ 0xC00047CA, 0xC90000F8, 0x00000000, 0x00000000, 0x59100002, 0xCD0000F8, 0x80000478, 0x00000000,
+ 0x98C08AF0, 0xC7D400F8, 0xC0004740, 0xC9C000F8, 0x5D240000, 0x8400006A, 0x00000000, 0x98C087E8,
+ 0xC7D400F8, 0x6FD8A010, 0xC0004700, 0xC00047C8, 0xC90000F8, 0x00000000, 0x00000000, 0x59100002,
+ 0xCD0000F8, 0x80001C40, 0xC00047CC, 0xC90000F8, 0x00000000, 0x00000000, 0x59100002, 0xCD0000F8,
+ 0x6FE82000, 0x5AA84300, 0x5D380000, 0x840000A0, 0x00000000, 0x98C086F0, 0xC0004748, 0xC98000F8,
+ 0xC2000000, 0x58280002, 0x6E520000, 0xCD021078, 0x58280002, 0xCE400078, 0x5D25FFFE, 0x84000040,
+ 0xC00047D0, 0xC90000F8, 0x00000000, 0x00000000, 0x59100002, 0xCD0000F8, 0x800002D0, 0xC3000000,
+ 0x58280002, 0xCB000078, 0x00000000, 0x00000000, 0x5D31FFFE, 0x84000048, 0xC00047D0, 0xC90000F8,
+ 0x00000000, 0x00000000, 0x59100002, 0xCD0000F8, 0x80000260, 0x00000000, 0x98C086F0, 0xC0004748,
+ 0xC98000F8, 0xC2000000, 0x58340002, 0xC6500078, 0xC7D01038, 0xC7901838, 0xCD0000F8, 0x58280002,
+ 0xCE400078, 0xC3C00200, 0x5FFC001C, 0xC3800000, 0xDF790048, 0x00000000, 0x00000000, 0x47F88000,
+ 0x8800FFDA, 0xC0004862, 0xCBC000F8, 0xC0000000, 0xC76C00F8, 0x5BBC7800, 0xC280001C, 0xCA6C00F9,
+ 0x00000000, 0x00000000, 0xCE7800F9, 0xC1007A00, 0x45388000, 0xC1007800, 0xC53800FE, 0x5EA80002,
+ 0x8400FFB8, 0xC3800000, 0xC000481A, 0xC80000F8, 0x6F108000, 0x45308000, 0x45308000, 0x4011C000,
+ 0xC000491E, 0xCF8000F8, 0xC2C00000, 0xC7EC0060, 0xC100001C, 0xC52C1048, 0xC100000A, 0xC52C0D10,
+ 0xC000491C, 0xCEC000F8, 0x99007CF0, 0xC000491C, 0xC1400000, 0xC9420048, 0xC2800000, 0xDF680038,
+ 0x5D280080, 0x8800FFE8, 0xC000491C, 0xCAC000F8, 0xC000491E, 0xCB8000F8, 0x99007F18, 0xDAD800F8,
+ 0xDB9800F9, 0x00000000, 0xC00047CE, 0xC90000F8, 0x00000000, 0x00000000, 0x59100002, 0xCD0000F8,
+ 0x00000000, 0x80001880, 0x00000000, 0x00000000, 0x00000000, 0xC0004878, 0xC80400F8, 0x6C908000,
+ 0x45088000, 0x45088000, 0x40100000, 0xCA0000F8, 0xC42400F8, 0x00000000, 0xC0004934, 0xCE0000F8,
+ 0xC2800002, 0xC4681C08, 0xC62821D0, 0xC6281E00, 0xC2600010, 0x5A650060, 0xC0004800, 0xCB4000F8,
+ 0xC2200400, 0x5A200020, 0xC7601040, 0xC0001220, 0xCE8000F8, 0xC0001200, 0xCE4000F8, 0xC0001202,
+ 0xCE0000F8, 0xC0001240, 0xCB4000F8, 0x00000000, 0x00000000, 0xA754FFE0, 0xC2000000, 0xC7600040,
+ 0xA7520042, 0x00000000, 0x00000000, 0x99008690, 0xC0004822, 0xC94000F8, 0xC1800002, 0x80001710,
+ 0x582040A0, 0xC2000000, 0xCA000018, 0xC2400000, 0xCA414000, 0xC2800000, 0xCA812000, 0xC2C00000,
+ 0xCAC20018, 0xC0004938, 0xCE0000F8, 0xC0004920, 0xCE4000F8, 0xC0004916, 0xCE8000F8, 0xC0004922,
+ 0xCEC000F8, 0xA6400558, 0x00000000, 0xC0004938, 0xCBC000F8, 0x00000000, 0xC3800000, 0x6FF48000,
+ 0x6FD44000, 0x4355A000, 0x5B744A00, 0x58340000, 0xCB802010, 0x00000000, 0xC2000000, 0x6FB46000,
+ 0x4779A000, 0x5B744C80, 0x5834000C, 0xCA000020, 0xC000491A, 0xCF8000F8, 0x5E200000, 0x84000482,
+ 0xC2000000, 0xDF610048, 0x5E6001E8, 0x8800FFE8, 0xC2000002, 0xC2400466, 0xC2A00000, 0x5AA80000,
+ 0xC0001006, 0xCE0000F8, 0xC0001008, 0xCE4000F8, 0xC000100A, 0xCE8000F8, 0x99007958, 0xC1A0FFFE,
+ 0xC0000824, 0xC9840060, 0xC0004934, 0xCA4000F8, 0xC2000000, 0xC2800002, 0x99007998, 0xDA9800F8,
+ 0xC61400F8, 0xC65800F8, 0xC161FFFE, 0x5955FFFE, 0x14140000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x99007A80, 0xC000491A, 0xC94000F8, 0x00000000, 0x00000000, 0xC121FFFE, 0x5911FE54,
+ 0x14100000, 0xC0004922, 0xCA001118, 0xC3C00000, 0xC3800000, 0xC0004930, 0xCE023118, 0xC0004932,
+ 0xCBC000D8, 0xC2800000, 0xC000491E, 0xCFC000F8, 0xC0004862, 0xCA800060, 0xC3A0001A, 0x5BB94000,
+ 0xC6B80060, 0xC000491C, 0xCF8000F8, 0x99007CF0, 0xC000491C, 0xC1400000, 0xC9420048, 0x00000000,
+ 0x00000000, 0x00000000, 0xA8E2FFE8, 0xC2000000, 0xC1220002, 0xD90C00F8, 0xDF600038, 0x5E600080,
+ 0x8400FFF2, 0xC000491C, 0xCA0000F8, 0xC000491E, 0xCA4000F8, 0x00000000, 0x00000000, 0x99007F18,
+ 0xDA1800F8, 0xDA5800F9, 0x00000000, 0xC2000000, 0xDF610048, 0x5E6001FE, 0x8800FFE8, 0xC0004916,
+ 0xCA8000F8, 0xC2C00000, 0xDFEC0048, 0xC2400000, 0x466D2000, 0x8400004A, 0x5EA80000, 0x8400003A,
+ 0xC2600002, 0x99008690, 0xC000482E, 0xC94000F8, 0xC1800002, 0x80000030, 0xC2600000, 0x99008690,
+ 0xC000482C, 0xC94000F8, 0xC1800002, 0xC2000068, 0xC6240078, 0xC0004930, 0xCE400080, 0xC000491A,
+ 0xC98000F8, 0xC0004862, 0xC94000F8, 0x6D9C6000, 0x45D8E000, 0x59DC4C80, 0x99007D78, 0xD95800F8,
+ 0xD99800F9, 0xD9D400F8, 0x99007CF0, 0xC000491C, 0xC1400000, 0xC9420048, 0xC2000000, 0xDF600038,
+ 0x5E600080, 0x8400FFEA, 0x00000000, 0xC000491C, 0xCA0000F8, 0xC000491E, 0xCA4000F8, 0x00000000,
+ 0x00000000, 0x99007F18, 0xDA1800F8, 0xDA5800F9, 0x00000000, 0x80001160, 0x00000000, 0x99008690,
+ 0xC000482A, 0xC94000F8, 0xC1800002, 0x80001130, 0xC0004938, 0xCBC000F8, 0x00000000, 0x00000000,
+ 0x6FF88000, 0x6FD44000, 0x4395C000, 0x5BB84A00, 0x58380008, 0xCA0000F8, 0x00000000, 0x00000000,
+ 0xA600039A, 0x00000000, 0xC0004938, 0xCBC000F8, 0xC3000000, 0x00000000, 0x6FF88000, 0x6FD44000,
+ 0x4395C000, 0x5BB84A00, 0x58380000, 0xCB002010, 0xC2000000, 0x58380008, 0xCA020078, 0x5838000C,
+ 0xCAC000F8, 0x5838000E, 0xCA4000F8, 0xC000491A, 0xCF0000F8, 0xC0004930, 0xCEC000F8, 0xC000493C,
+ 0xCE0000F8, 0xC0004932, 0xCE4000F8, 0x5E200000, 0x84000138, 0xC2800000, 0xA6FE00D2, 0x6F206000,
+ 0x46310000, 0x5A204C80, 0x5820000C, 0xCA800020, 0x00000000, 0x00000000, 0x5EA80000, 0x8400020A,
+ 0x00000000, 0xC161FFFE, 0x5955FFFE, 0x14140000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x99007A80, 0xC000491A, 0xC94000F8, 0x00000000, 0x00000000, 0xC121FFFE, 0x5911FE54, 0x14100000,
+ 0xC0004930, 0xCAC000F8, 0xC0004932, 0xCA4000F8, 0xC7EC1118, 0xC0004930, 0xCEC000F8, 0x5838000C,
+ 0xCEC000F8, 0x58000002, 0xCE4000F8, 0xC0004934, 0xCA0000F8, 0xC2400002, 0x6E642000, 0x6E642000,
+ 0x76612000, 0x8400002A, 0xC2400002, 0x6E684000, 0x58380008, 0xCE804200, 0xA6000020, 0x6E682000,
+ 0x58380008, 0xCE802100, 0xC2400002, 0x6E642000, 0x76612000, 0x840000EA, 0x58380008, 0xCA0000F8,
+ 0xC2800000, 0xC2400000, 0xA60200C0, 0xDBA800F8, 0x6F386000, 0x47B1C000, 0x5BB84C80, 0x58380004,
+ 0xCA400078, 0x58380002, 0xCA800078, 0x00000000, 0xDEB800F8, 0x46A54000, 0x88000060, 0x00000000,
+ 0xC0004824, 0xCA0000F8, 0xC2400002, 0x6E640000, 0x5A200002, 0xCE0000F8, 0x58380008, 0xCE400000,
+ 0x80000018, 0x00000000, 0x80000048, 0xC0004934, 0xCA0000F8, 0x00000000, 0x00000000, 0xA6020CCA,
+ 0x00000000, 0x00000000, 0x80000CF8, 0xC2800000, 0xC2000200, 0xC240001A, 0xDF690048, 0x46294000,
+ 0x46A54000, 0x8800FFD2, 0xC2000006, 0xC2600982, 0x5A643B6E, 0x5838000A, 0xCA8000F8, 0xC0001006,
+ 0xCE0000F8, 0xC0001008, 0xCE4000F8, 0xC000100A, 0xCE8000F8, 0x99007958, 0xC1A0FFFE, 0xC0000824,
+ 0xC9840060, 0xC2000000, 0xC0004930, 0xCA02E008, 0x58380026, 0xCA4000F8, 0x00000000, 0xC2800000,
+ 0x99007998, 0xDA9800F8, 0xC61400F8, 0xC65800F8, 0xC0004934, 0xCA0000F8, 0x00000000, 0x00000000,
+ 0xA6020022, 0x00000000, 0x00000000, 0x80000318, 0xC0004938, 0xCBC000F8, 0xC0004878, 0xC80400F8,
+ 0x6C908000, 0x45088000, 0x45088000, 0x40100000, 0xCA0000F8, 0xC42400F8, 0x00000000, 0x58240018,
+ 0xCA0000F8, 0x6FF88000, 0x6FD44000, 0x4395C000, 0x5BB84A00, 0xC3000000, 0xC3400002, 0xC2C00000,
+ 0xC62C0078, 0xC6270038, 0xC0004940, 0xCE400038, 0xC6260038, 0xC0004942, 0xCE400038, 0xC000493C,
+ 0xCA0000F8, 0x5EEC0000, 0x8400018A, 0x5A6C0010, 0x46254000, 0x88000190, 0x5A600052, 0x46E54000,
+ 0x88000178, 0x58380006, 0xCA8000F8, 0xC0004940, 0xCA0000F8, 0xC2400000, 0xC6A70038, 0x7E412000,
+ 0x76612000, 0xC2000000, 0xC6A10038, 0x46250000, 0x84000138, 0xC0004942, 0xCA0000F8, 0xC2400000,
+ 0xC6A60038, 0x7E412000, 0x76612000, 0xC2000000, 0xC6A00038, 0x58380002, 0xCA8000F8, 0x46250000,
+ 0x840000E8, 0xC2400000, 0xC6A60078, 0x466D0000, 0x880000DA, 0xC2400000, 0xC6A40078, 0x58380008,
+ 0xCA8000F8, 0x46E50000, 0x880000BA, 0x00000000, 0xA6820018, 0x00000000, 0xC7700B00, 0xA6840098,
+ 0x00000000, 0xC7700A00, 0x80000080, 0xC7700200, 0xC000493C, 0xCAC000F8, 0x80000060, 0xC7700300,
+ 0xC000493C, 0xCAC000F8, 0x80000040, 0xC7700900, 0x80000030, 0xC7700800, 0x80000020, 0xC7700700,
+ 0x80000010, 0xC7700500, 0xC0004944, 0xCF0000F8, 0xC000493E, 0xCEC000F8, 0xC0004938, 0xCA4000F8,
+ 0xC000493C, 0xCB8000F8, 0xC000493E, 0xCB4000F8, 0xC3000000, 0x6E608000, 0x6E544000, 0x42150000,
+ 0x5A204A00, 0x5AA00008, 0x58200004, 0xCB000078, 0xC0004934, 0xCA0000F8, 0xC2400000, 0xC0004930,
+ 0xCA42E008, 0xC3C00018, 0xA6020098, 0x00000000, 0x43656000, 0x47AD0000, 0x88000050, 0x46F96000,
+ 0x6EE04010, 0x5BE00004, 0xC2000000, 0xC6E00008, 0x5E200000, 0x84000042, 0x5BFC0002, 0x80000030,
+ 0xC3C00004, 0x5A2C0008, 0x47A10000, 0x88000012, 0x5FB80008, 0x6FE04000, 0x42390000, 0x47212000,
+ 0x88000068, 0xC2400000, 0xC0004930, 0xCA42E008, 0xC2060002, 0xC68000F8, 0xCE006300, 0x6FE04000,
+ 0x4721C000, 0x5F700010, 0x4765A000, 0xC2000000, 0xC6340008, 0xC25A000A, 0xC000491A, 0xCA401C18,
+ 0xC2800000, 0xC0004932, 0xCA8000D8, 0xC0004862, 0xCA400060, 0x6FA04010, 0x42290000, 0xC000491E,
+ 0xCE0000F8, 0xC7E41048, 0xC000491C, 0xCE4000F8, 0x6FE04000, 0x43A1C000, 0xC000493C, 0xCF8000F8,
+ 0xC000493E, 0xCF4000F8, 0xC000493A, 0xCFC000F8, 0x80000008, 0x00000000, 0x00000000, 0x00000000,
+ 0xC2000000, 0xDCE000F8, 0xA622FFD8, 0xC1220002, 0xD90C00F8, 0xC0004938, 0xCBC000F8, 0xC0004944,
+ 0xCB4000F8, 0xC0004862, 0xCB0000F8, 0xC0004934, 0xCA0000F8, 0x6FF88000, 0x6FD44000, 0x4395C000,
+ 0x5BB84A00, 0xA6020298, 0xC2400000, 0x58380008, 0xCA406000, 0xDFE800F8, 0xC2218E08, 0x5A21BAF6,
+ 0x46A14000, 0x84000022, 0xC2080002, 0x7361A000, 0x80000058, 0x5E640000, 0x84000022, 0xC20C0002,
+ 0x7361A000, 0x80000030, 0xC2000000, 0xC760E710, 0xC7604218, 0x5E200000, 0x840002A2, 0xC2200002,
+ 0xC0004930, 0xCE021000, 0x99008690, 0xC0004828, 0xC94000F8, 0xC1800002, 0xC0004780, 0xC93C00F8,
+ 0x00000000, 0x00000000, 0x59100002, 0xCD3C00F8, 0x58380000, 0xCA0000F8, 0x00000000, 0x00000000,
+ 0xA6000132, 0xC0004940, 0xCA8000F8, 0xC0004942, 0xCA4000F8, 0xC7600078, 0xC6A01838, 0xC6601038,
+ 0xC000493A, 0xCA4000F8, 0xC0004934, 0xCA8000F8, 0xC0007800, 0x40300000, 0x40240000, 0x5C000004,
+ 0x5EC07A00, 0x88000012, 0x5C000200, 0xCE0000F8, 0x58000002, 0x5EC07A00, 0x88000012, 0x5C000200,
+ 0xCE8000F8, 0xC000493E, 0xCA0000F8, 0xC2400000, 0x5838000C, 0xCE4000F8, 0x99008690, 0xC0004830,
+ 0xC94000F8, 0xC61800F8, 0xC0004930, 0xC6100078, 0xCD000078, 0x800000A8, 0xC2400002, 0x58380008,
+ 0xCE400000, 0xC0004944, 0xCF4000F8, 0x800002A8, 0xC000493C, 0xCA4000F8, 0xDFE800F8, 0x5A300018,
+ 0xC0007800, 0x40200000, 0xCA0000F8, 0x58380008, 0xC6501078, 0xCD021078, 0x5838000A, 0xCE8000F8,
+ 0x58380026, 0xCE0000F8, 0xC0004944, 0xCF4000F8, 0x99007CF0, 0xC000491C, 0xC1400000, 0xC9420048,
+ 0x80000068, 0x00000000, 0x99008690, 0xC0004826, 0xC94000F8, 0xC1800002, 0xC0004760, 0xC93C00F8,
+ 0x00000000, 0x00000000, 0x59100002, 0xCD3C00F8, 0x8000FDA8, 0xC2000000, 0xC2400080, 0xDF600038,
+ 0xB624FFEA, 0xC000491C, 0xCA4000F8, 0xC000491E, 0xCA8000F8, 0x99007F18, 0xDA5800F8, 0xDA9800F9,
+ 0x00000000, 0xC0004934, 0xCA0000F8, 0x00000000, 0xC2800000, 0xA6020160, 0xC2400004, 0xC2000200,
+ 0xDF690048, 0x46294000, 0x46A54000, 0x8800FFDA, 0x00000000, 0xC000491A, 0xC98000F8, 0xC0004862,
+ 0xC94000F8, 0x6D9C6000, 0x45D8E000, 0x59DC4C80, 0x99007D78, 0xD95800F8, 0xD99800F9, 0xD9D400F8,
+ 0x99007CF0, 0xC000491C, 0xC1400000, 0xC9420048, 0xC2000000, 0xC2400080, 0xDF600038, 0xB624FFEA,
+ 0xC000491C, 0xCA4000F8, 0xC000491E, 0xCA8000F8, 0x99007F18, 0xDA5800F8, 0xDA9800F9, 0x00000000,
+ 0x58380008, 0xCA4000F8, 0xC2000000, 0xCE000018, 0xC2A1FFFE, 0x5AA9FFFE, 0xCE021078, 0x5838000A,
+ 0xCE8000F8, 0xC161FFFE, 0x5955FFFE, 0x14140000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC0000838, 0xC2500002, 0xCE450800, 0xC0004848, 0xCBC400F8, 0xC3800000, 0xC000082C, 0xCB840028,
+ 0x5FFC0002, 0xC0004848, 0xCFC400F8, 0x58880002, 0x47888000, 0xC1000000, 0xC50800FE, 0xC0004844,
+ 0xCC8400F8, 0x00000000, 0xC121FFFE, 0x5911FE54, 0x14100000, 0x8000CBF0, 0xC2000000, 0xDF600038,
+ 0x5E200080, 0x8400029A, 0x00000000, 0xC161FFFE, 0x5955FFFE, 0x14140000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0xC000480C, 0xCA0000F8, 0xC0004910, 0xCA4000F8, 0xC000492C, 0xCA8000F8,
+ 0xC0004968, 0xCAC000F8, 0x00000000, 0xC121FFFE, 0x5911FE54, 0x14100000, 0x76250000, 0x76290000,
+ 0x76E16000, 0x840001DA, 0xC0004926, 0xCA4000F8, 0xC201FFFE, 0x76E16000, 0x5A640002, 0x6AE50010,
+ 0x5F200000, 0x8400001A, 0x6A250000, 0x80000010, 0xC6E000F8, 0x62014008, 0xC0004926, 0xCE8000F8,
+ 0xC161FFFE, 0x5955FFFE, 0x14140000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xC0004968,
+ 0xCA4000F8, 0xC2000002, 0x6A290000, 0x7E010000, 0x76612000, 0xCE4000F8, 0x00000000, 0xC121FFFE,
+ 0x5911FE54, 0x14100000, 0x6EB4A000, 0x6E944000, 0x4755A000, 0x4769A000, 0x5B747000, 0x58340002,
+ 0xC2000000, 0xCA0000D8, 0x5834002E, 0xC2400000, 0xCA400078, 0x6EB0A000, 0x6EBC4000, 0x473D8000,
+ 0x47298000, 0x5B30302E, 0x5B300004, 0x6E642000, 0x4225E000, 0xC39A8024, 0xC7380060, 0xC6B81C18,
+ 0x99007F18, 0xDB9800F8, 0xDBD800F9, 0x00000000, 0xC2000000, 0xDF600038, 0x5E200080, 0x840002D2,
+ 0x00000000, 0xC161FFFE, 0x5955FFFE, 0x14140000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC000490E, 0xCA0000F8, 0xC000492A, 0xCA4000F8, 0xC000496A, 0xCB0000F8, 0xC0004956, 0xCAC000F8,
+ 0x00000000, 0xC121FFFE, 0x5911FE54, 0x14100000, 0x77218000, 0x77258000, 0x8400021A, 0xC201FFFE,
+ 0x77218000, 0x5AEC0002, 0x6B2D0010, 0x5EA00000, 0x8400001A, 0x6A2D0000, 0x80000010, 0xC72000F8,
+ 0x62016008, 0xC0004956, 0xCEC000F8, 0xC161FFFE, 0x5955FFFE, 0x14140000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0xC000496A, 0xCA4000F8, 0xC2000002, 0x6A2D0000, 0x7E010000, 0x76612000,
+ 0xCE4000F8, 0x00000000, 0xC121FFFE, 0x5911FE54, 0x14100000, 0x6EF4A000, 0x6ED44000, 0x4755A000,
+ 0x476DA000, 0x5B747000, 0x5834000E, 0xC2000000, 0xCA0000D8, 0x58340008, 0xC2400000, 0xCA420078,
+ 0x5834000C, 0xC2800000, 0xCA832010, 0x6E644010, 0x42250000, 0x4229E000, 0xC39A8008, 0x58340008,
+ 0xCB809018, 0x58340008, 0xC2800000, 0xCA810010, 0x6EE0A000, 0x6EE44000, 0x46250000, 0x462D0000,
+ 0x5A200008, 0x5A203008, 0x42290000, 0xC6380060, 0xC6F81C18, 0x99007F18, 0xDB9800F8, 0xDBD800F9,
+ 0x00000000, 0xC000495A, 0xC84000F8, 0x00000000, 0xC3C00002, 0x787C2000, 0xCC4000F8, 0xC0001A1C,
+ 0xCA0000F8, 0xC2400008, 0x6A452000, 0x76250000, 0x84000E9A, 0xC0000A28, 0xC3800000, 0xCB840028,
+ 0xC0000A14, 0xC3400000, 0xCB440028, 0xC0004880, 0xCB0400F8, 0x47B48000, 0x88000E48, 0x58041802,
+ 0xCAC000F8, 0xA7000060, 0x00000000, 0x00000000, 0xA6C8C5C8, 0xC2800000, 0xC6E80018, 0x80000070,
+ 0x00000000, 0x00000000, 0x00000000, 0x8000C590, 0x00000000, 0xC2800000, 0xC7282018, 0xC000490E,
+ 0xCA4000F8, 0x6BE9E000, 0x00000000, 0x767D2000, 0x8400C548, 0x6EA0A000, 0x6E944000, 0x46150000,
+ 0x46290000, 0x5A207000, 0x5820000C, 0xCA0000F8, 0xC0004946, 0xCE8000F8, 0xA6220398, 0x00000000,
+ 0xC2200060, 0xC0004948, 0xCE000008, 0xCE021038, 0xC240000A, 0xC000494A, 0xCE4000F8, 0xC2B60002,
+ 0xC0004964, 0xCE837B00, 0x990081E8, 0xC00048A0, 0xC88400F8, 0x00000000, 0xC0004946, 0xCBC000F8,
+ 0x00000000, 0x00000000, 0x6FF8A000, 0x6FD44000, 0x4795C000, 0x47BDC000, 0x5BB87000, 0x99007FA8,
+ 0xDBD800F8, 0xDB9800F9, 0x00000000, 0x99007CF0, 0xC000491C, 0xC1400000, 0xC9420048, 0xC000491C,
+ 0x990081A0, 0xC94000F9, 0xC98000F8, 0x00000000, 0x99007F18, 0xD95800F8, 0xD99800F9, 0x00000000,
+ 0xC161FFFE, 0x5955FFFE, 0x14140000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x99007BE0,
+ 0xDBD800F8, 0xDB9800F9, 0xC7D800F8, 0x00000000, 0xC121FFFE, 0x5911FE54, 0x14100000, 0x6FF8A000,
+ 0x6FD44000, 0x4795C000, 0x47BDC000, 0x5BB87000, 0x58380010, 0xCA0000F8, 0xC0004874, 0xC80400F8,
+ 0x6C908000, 0x45088000, 0x45088000, 0x40100000, 0xCA4000F8, 0xC43400F8, 0x00000000, 0xC74000F8,
+ 0xCE0000F8, 0xC161FFFE, 0x5955FFFE, 0x14140000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC000490E, 0xCA4000F8, 0xC2800002, 0x6ABD4000, 0x72692000, 0xCE4000F8, 0x00000000, 0xC121FFFE,
+ 0x5911FE54, 0x14100000, 0x99008690, 0xC0004836, 0xC94000F8, 0xC1800002, 0x00000000, 0x00000000,
+ 0x00000000, 0xA8E2FFE8, 0x00000000, 0xC1220002, 0xD90C00F8, 0xC2000000, 0xC0000A14, 0xCA040028,
+ 0xC0000A28, 0xC2500002, 0xCE450800, 0x58880002, 0xB6080018, 0xC00048A0, 0xC0800000, 0xCC8400F8,
+ 0x8000C168, 0xC0004946, 0xCBC000F8, 0xC161FFFE, 0x5955FFFE, 0x14140000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0xC000490E, 0xCA4000F8, 0xC2800002, 0x6ABD4000, 0x72692000, 0xCE4000F8,
+ 0x00000000, 0xC121FFFE, 0x5911FE54, 0x14100000, 0x6FF8A000, 0x6FD44000, 0x4795C000, 0x47BDC000,
+ 0x5BB87000, 0x58380008, 0xCA0000F8, 0x5838000C, 0xCA4000F8, 0xC3400000, 0xC6340000, 0xC000494E,
+ 0xCF4000F8, 0xC2800000, 0xC62A0078, 0xC3000000, 0xC6308018, 0x6F304000, 0x43298000, 0xC000493C,
+ 0xCF0000F8, 0xC2C00000, 0xC66C0078, 0xC0004950, 0xCEC000F8, 0xC2800000, 0xC66AE020, 0xC0004954,
+ 0xCE8000F8, 0x5F740000, 0x840001B8, 0x5E300028, 0x46E12000, 0x84000182, 0x46E12000, 0x8800014A,
+ 0x5E300018, 0x46E12000, 0x8800002A, 0x46E12000, 0x84000042, 0x00000000, 0x800000D8, 0x00000000,
+ 0x99008328, 0xDBD800F8, 0xDB9800F9, 0xC78000F8, 0xC3400002, 0xC000494E, 0xCF4000F8, 0xC161FFFE,
+ 0x5955FFFE, 0x14140000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xC000490E, 0xCA4000F8,
+ 0xC2800002, 0x6ABD4000, 0x7E814000, 0x76692000, 0xCE4000F8, 0x00000000, 0xC121FFFE, 0x5911FE54,
+ 0x14100000, 0xC2200060, 0xC0004948, 0xCE021038, 0xC2000000, 0xC000494C, 0xCE0000F8, 0x80000080,
+ 0x00000000, 0x99008328, 0xDBD800F8, 0xDB9800F9, 0xC78000F8, 0x99008528, 0xDBD800F8, 0xDB9800F9,
+ 0xC78000F8, 0xC2200058, 0xC0004948, 0xCE021038, 0xC2000002, 0xC000494C, 0xCE0000F8, 0xC2000006,
+ 0xC0001006, 0xCE0000F8, 0x5838000A, 0xCA4000F8, 0xC2200982, 0x5A203B6E, 0xC0001008, 0xCE0000F8,
+ 0xC000100A, 0xCE4000F8, 0xC0004954, 0xCA8000F8, 0xC200000C, 0xC000494A, 0xCE0000F8, 0xC0004948,
+ 0xCE800008, 0xC2B60000, 0xC0004964, 0xCE8000F8, 0x990081E8, 0xC00048A0, 0xC88400F8, 0x00000000,
+ 0xC0004946, 0xCBC000F8, 0xC000494C, 0xCA0000F8, 0x6FF8A000, 0x6FD44000, 0x4795C000, 0x47BDC000,
+ 0x5BB87000, 0x5E200000, 0x84000112, 0x00000000, 0x99007FA8, 0xDBD800F8, 0xDB9800F9, 0x00000000,
+ 0x99007CF0, 0xC000491C, 0xC1400000, 0xC9420048, 0xC000491C, 0x990081A0, 0xC94000F9, 0xC98000F8,
+ 0x00000000, 0x99007F18, 0xD95800F8, 0xD99800F9, 0x00000000, 0xC161FFFE, 0x5955FFFE, 0x14140000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x99007BE0, 0xDBD800F8, 0xDB9800F9, 0xC7D800F8,
+ 0x00000000, 0xC121FFFE, 0x5911FE54, 0x14100000, 0xC000493C, 0xCA8000F8, 0xC000494E, 0xCAC000F8,
+ 0xC3000018, 0xC3400006, 0x5E200000, 0x8400002A, 0xC2800000, 0xC2C00000, 0xC300001E, 0xC3400000,
+ 0xC6AC1078, 0xC72C0418, 0xC76C0810, 0x58380010, 0xCA8000F8, 0x58380008, 0xCEC000F8, 0xC6280100,
+ 0xC0004874, 0xC80400F8, 0x6C908000, 0x45088000, 0x45088000, 0x40100000, 0xCB0000F8, 0xC43400F8,
+ 0x00000000, 0xC74000F8, 0xCE8000F8, 0xC0004952, 0xCE8000F8, 0x00000000, 0x00000000, 0x00000000,
+ 0xA8E2FFE8, 0x00000000, 0xC000494C, 0xCA0000F8, 0xC0004950, 0xCAC000F8, 0x5E200000, 0x8400006A,
+ 0xDFE800F8, 0x7E814000, 0x5834001A, 0xCE8000F8, 0x99008690, 0xC0004834, 0xC94000F8, 0xC1800002,
+ 0x99008690, 0xC0004838, 0xC94000F8, 0xC6D800F8, 0xC1220002, 0xD90C00F8, 0x5E200000, 0x84000040,
+ 0x5838002C, 0xCB0000F8, 0xDFE800F8, 0x00000000, 0x58380014, 0xCF0000F8, 0x80000018, 0xC2A1FFFE,
+ 0x5AA9FFFE, 0x5838000A, 0xCE8000F8, 0xC3000000, 0xC0000A14, 0xCB040028, 0xC2D00002, 0xC0000A28,
+ 0xCEC50800, 0xC000494E, 0xCA8000F8, 0x58880002, 0xB4B00018, 0xC00048A0, 0xC0800000, 0xCC8400F8,
+ 0x5EA80000, 0x8400016A, 0x5E200000, 0x84000158, 0xC000493C, 0xCA8000F8, 0x00000000, 0x00000000,
+ 0x5AA80060, 0xCE8000F8, 0x99008328, 0xDBD800F8, 0xDB9800F9, 0xC78000F8, 0x99008528, 0xDBD800F8,
+ 0xDB9800F9, 0xC78000F8, 0xC0004952, 0xCAC000F8, 0x58380000, 0xCA8000F8, 0xC30C0002, 0xC7F00018,
+ 0xA68000B0, 0x00000000, 0x00000000, 0xC161FFFE, 0x5955FFFE, 0x14140000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0xC0001800, 0xCA0000F8, 0x00000000, 0x00000000, 0xA60CFFEA, 0xC6F00500,
+ 0xC6B0C400, 0xCF0000F8, 0x00000000, 0xC121FFFE, 0x5911FE54, 0x14100000, 0x8000B7B8, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x8000B750, 0xDCBC00F9, 0x5FFC0000, 0x8400095A, 0xC3800002,
+ 0xDB8800F9, 0xC3800000, 0xDB8800F9, 0xC0004728, 0xC90000F8, 0x00000000, 0x00000000, 0x59100002,
+ 0xCD0000F8, 0xC0004730, 0xC98000F8, 0xC000472E, 0xC94000F8, 0xC00047DC, 0xC90000F8, 0xC00047DE,
+ 0xC9C000F8, 0xC000472E, 0xCD8000F8, 0x6D110000, 0xC5D30038, 0xC00047DC, 0xCD0000F8, 0x4594A000,
+ 0x6DDD0000, 0xC55C0038, 0xC00047DE, 0xCDC000F8, 0xC0001AC4, 0xC94000F8, 0xC0001AC8, 0xC98000F8,
+ 0xC000472C, 0xC9C000F8, 0x45948000, 0xC1000002, 0x41D0E004, 0xCDC000F8, 0xC5501078, 0xC5900078,
+ 0xC000472A, 0xCD0000F8, 0xC0001AF0, 0xCBC000F8, 0x58000002, 0xCB8000F8, 0xC3400000, 0xC7F50038,
+ 0x6F702000, 0x5B304300, 0xC000474C, 0xCAC000F8, 0xC0004720, 0xC94000F8, 0x00000000, 0x00000000,
+ 0x5D940002, 0x6D9B8000, 0x6D9B8010, 0x581847E0, 0xC98000F8, 0x581447E0, 0xC9C000F8, 0x5D2C0000,
+ 0x8400007A, 0xC7901078, 0xC7D00078, 0xCD0000F8, 0xC1000000, 0xC5910038, 0x45348000, 0x84000090,
+ 0xC0004722, 0xC90000F8, 0x00000000, 0x00000000, 0x59100002, 0xCD0000F8, 0x80000058, 0xC1000000,
+ 0xC5D10038, 0x45348000, 0x8400003A, 0xC0004724, 0xC90000F8, 0x00000000, 0x00000000, 0x59100002,
+ 0xCD0000F8, 0xA7840080, 0x59540002, 0x6D578000, 0x6D578010, 0xC0004720, 0xCD4000F8, 0xC1000000,
+ 0xC5910038, 0x45348000, 0x84000038, 0xC0004726, 0xC90000F8, 0x00000000, 0x00000000, 0x59100002,
+ 0xCD0000F8, 0xA78000B8, 0xC2800002, 0xC000474E, 0xCE8000F8, 0xC2C00000, 0xC000474C, 0xCEC000F8,
+ 0xC0004758, 0xCFC000F8, 0x58000002, 0xCF8000F8, 0xC000475C, 0xC90000F8, 0x00000000, 0x00000000,
+ 0xA53E003A, 0x00000000, 0xC13E0002, 0xCFC000F8, 0xCD03DE08, 0x58000002, 0xCF8000F8, 0x800001A0,
+ 0xC000475C, 0xC13C0002, 0xCD03DE08, 0x5D2C0000, 0x8400017A, 0xC2C00000, 0xC000474C, 0xCEC000F8,
+ 0x98C08AF0, 0xC75400F8, 0xC0004740, 0xC9C000F8, 0x5D240000, 0x84000042, 0xC1000002, 0xC0004750,
+ 0xCD0000F8, 0xC0004752, 0xCD0000F8, 0x80000100, 0x00000000, 0x98C08BE0, 0xC75400F8, 0xC0004742,
+ 0xC98000F8, 0x5D240000, 0x8400002A, 0xC1000002, 0xC0004752, 0xCD0000F8, 0x80000060, 0xC0004742,
+ 0xC94000F8, 0xC0004754, 0xC1000002, 0xCD0000F8, 0x98C08CF0, 0xC55400F8, 0xC75800F8, 0x00000000,
+ 0xC0004742, 0xCF4000F8, 0x98C08AB8, 0xC1400000, 0xC7540020, 0x6F40A010, 0xC1000000, 0xC7D00038,
+ 0x58300000, 0x6D110000, 0xCD010838, 0xA7840398, 0xC000474C, 0xCAC000F8, 0xC000474E, 0xCA8000F8,
+ 0xC0004750, 0xCBC000F8, 0xC0004752, 0xCB8000F8, 0xC0004710, 0xC90000F8, 0x00000000, 0x00000000,
+ 0x59100002, 0xCD0000F8, 0x5D280002, 0x840000B8, 0xC000473C, 0xC90000F8, 0x00000000, 0x00000000,
+ 0x59100002, 0xCD0000F8, 0xC0004712, 0xC90000F8, 0x00000000, 0x00000000, 0x59100002, 0xCD0000F8,
+ 0xC0004754, 0xC90000F8, 0x00000000, 0x00000000, 0x5D100000, 0x8400021A, 0x58300000, 0xC13C0002,
+ 0xCD03DE00, 0x800001F8, 0xC0004714, 0xC90000F8, 0x00000000, 0x00000000, 0x59100002, 0xCD0000F8,
+ 0x5D380000, 0x8400003A, 0xC0004736, 0xC90000F8, 0x00000000, 0x00000000, 0x59100002, 0xCD0000F8,
+ 0x5D3C0000, 0x84000042, 0xC0004718, 0xC90000F8, 0x00000000, 0x00000000, 0x59100002, 0xCD0000F8,
+ 0x80000140, 0xC1000000, 0x58300000, 0xC903E000, 0x00000000, 0x00000000, 0x5D100000, 0x84000042,
+ 0xC000471A, 0xC90000F8, 0x00000000, 0x00000000, 0x59100002, 0xCD0000F8, 0x800000D0, 0x58300000,
+ 0xC13E0002, 0xCD03FF00, 0xC1000000, 0x58300000, 0xC903C000, 0x00000000, 0x00000000, 0x5D100000,
+ 0x84000082, 0xC0004716, 0xC90000F8, 0x00000000, 0x00000000, 0x59100002, 0xCD0000F8, 0xC000473A,
+ 0xC90000F8, 0x00000000, 0x00000000, 0x59100002, 0xCD0000F8, 0x58300000, 0xC13C0000, 0xCD03DE00,
+ 0xC1000000, 0xC0004746, 0xCD0000F8, 0xC0004750, 0xCD0000F8, 0xC0004752, 0xCD0000F8, 0xC000474E,
+ 0xCD0000F8, 0xC2C00002, 0xC000474C, 0xCEC000F8, 0xC0004754, 0xCD0000F8, 0xC3CE0002, 0xC0000800,
+ 0xCFC0E700, 0xC3E1FFFE, 0x597DFFFE, 0x593DFE14, 0x94000001, 0x00000000, 0x00000000, 0x00000000,
+ 0xC000487C, 0xC80400F8, 0x00000000, 0x00000000, 0x40080000, 0xCBC000F8, 0xC43800F8, 0x00000000,
+ 0xC000480E, 0xCA0000F8, 0xC0004858, 0xCB4400F8, 0x00000000, 0x00000000, 0x47610000, 0x880000B0,
+ 0x00000000, 0xA7C00048, 0xC0004854, 0xC1000002, 0xCD0400F8, 0xC11C0000, 0xC000082C, 0xCD05CE00,
+ 0x800000D8, 0x00000000, 0xA7D20138, 0x00000000, 0xC7E14040, 0xC2400000, 0xC6246028, 0xC200006A,
+ 0x46250000, 0xC6240030, 0xC0000810, 0xCE440030, 0x8000FF70, 0xC2000000, 0xC0000808, 0xCA040010,
+ 0xC11C0000, 0xC000082C, 0xCD05CE00, 0x5A200002, 0x5E600010, 0x84000010, 0xC2000000, 0xC0000808,
+ 0xCE040010, 0xC3400000, 0x80000028, 0xC1200002, 0xC0000818, 0xCD061000, 0x5B740002, 0xC0004858,
+ 0xCF4400F8, 0x99007930, 0xC0004848, 0xC94400F8, 0xC1800000, 0xC11C0002, 0xC000082C, 0xCD05CE00,
+ 0x80000878, 0x5B740002, 0xC0004858, 0xCF4400F8, 0xC78000F8, 0xC13C0002, 0xCD03DE00, 0xC0004848,
+ 0xC94400F8, 0xC1800000, 0xC000082C, 0xC9840028, 0x59540002, 0xC0004848, 0xCD4400F8, 0x58880002,
+ 0xB49807F8, 0x00000000, 0xC0800000, 0x800007E0, 0xC000487C, 0xC80400F8, 0x00000000, 0x00000000,
+ 0x40080000, 0xCBC000F8, 0xC42800F8, 0x00000000, 0xA7C00130, 0xC000484C, 0xCA0400F8, 0xC2400000,
+ 0xC0001AEC, 0xCA440018, 0x5A200002, 0xC000484C, 0xCE0400F8, 0xB624008A, 0xC68000F8, 0xC13C0002,
+ 0xCD03DE00, 0xC0004848, 0xC94400F8, 0xC1800000, 0xC000082C, 0xC9840028, 0x59540002, 0xC0004848,
+ 0xCD4400F8, 0x58880002, 0xB49806E8, 0x00000000, 0xC0800000, 0x800006D0, 0xC0004854, 0xC1000004,
+ 0xCD0400F8, 0xC0000820, 0xC2000002, 0xCE0400F8, 0xC2000000, 0xC000484C, 0xCE0400F8, 0xC0004858,
+ 0xCE0400F8, 0x8000FF28, 0xC0004854, 0xC1000000, 0xCD0400F8, 0xC11C0000, 0xC000082C, 0xCD05CE00,
+ 0x99007930, 0xC0004848, 0xC94400F8, 0xC1800000, 0xC1200000, 0xC0000818, 0xCD061000, 0xC11C0002,
+ 0xC000082C, 0xCD05CE00, 0xC2000000, 0xC000484C, 0xCE0400F8, 0x800005D0, 0xC0001AC0, 0xCB8400F8,
+ 0xC000487C, 0xC80400F8, 0x00000000, 0x00000000, 0x40080000, 0xCBC000F8, 0xC42800F8, 0x00000000,
+ 0xA78004E2, 0x00000000, 0x00000000, 0xA7C004A2, 0x00000000, 0xC0001B00, 0xC2060006, 0xCE046308,
+ 0xA7E8045A, 0x00000000, 0xC0004850, 0xCA0400F8, 0xC2400000, 0xC0004812, 0xCA420078, 0x5A200002,
+ 0xC0004850, 0xCE0400F8, 0x5E640000, 0x8400001A, 0x46250000, 0x880002F8, 0xC68000F8, 0xC13C0002,
+ 0xCD03DE00, 0xC0001ACC, 0xC2000002, 0xCE040000, 0x5C440000, 0x84000250, 0xC0004810, 0xC94000F8,
+ 0xC68000F8, 0xCBC000F8, 0x00000000, 0xC1000000, 0xA5400208, 0xC53C1000, 0x00000000, 0xA7FC01F2,
+ 0xC0001AF0, 0xC1000000, 0x58000002, 0xC9000000, 0xC000474E, 0xC98000F8, 0x5D100000, 0x84000022,
+ 0xC1000002, 0xC53C1E00, 0x80000198, 0x5D180000, 0x84000022, 0xC1000002, 0xC53C1E00, 0x80000170,
+ 0xC0004878, 0xC80400F8, 0x6C908000, 0x45088000, 0x45088000, 0x40100000, 0xC98000F8, 0xC43800F8,
+ 0x00000000, 0xC000481E, 0xC9C000F8, 0xC000481C, 0xCA0000F8, 0x00000000, 0x759CC000, 0x45A08000,
+ 0x840000E8, 0xC0001AF0, 0xC3400000, 0x58000000, 0xCB410038, 0xC0004746, 0xC94000F8, 0x6F702000,
+ 0x5B304300, 0xC2C00000, 0x58300000, 0xCAC00038, 0x00000000, 0x00000000, 0x456C8000, 0x88000020,
+ 0xC1000002, 0xC53C1E00, 0x80000040, 0x5AEC0002, 0x58300000, 0xCEC00038, 0xC1000002, 0xC53C1000,
+ 0xC77C0838, 0xC57C0038, 0x59540002, 0xC0004746, 0xCD4000F8, 0xC68000F8, 0xCFC000F8, 0xC0004848,
+ 0xC94400F8, 0xC1800000, 0xC000082C, 0xC9840028, 0x59540002, 0xC0004848, 0xCD4400F8, 0x58880002,
+ 0xB49801F8, 0x00000000, 0xC0800000, 0x800001E0, 0xC000471E, 0xC90000F8, 0x00000000, 0x00000000,
+ 0x59100002, 0xCD0000F8, 0xC0004854, 0xC1000000, 0xCD0400F8, 0xC11C0000, 0xC000082C, 0xCD05CE00,
+ 0x99007930, 0xC0004848, 0xC94400F8, 0xC1800000, 0xC2000000, 0xC0000820, 0xCE0400F8, 0xC1200000,
+ 0xC0000818, 0xCD061000, 0xC11C0002, 0xC000082C, 0xCD05CE00, 0xC0004850, 0xCE0400F8, 0xC2000002,
+ 0xC0001ACC, 0xCE040008, 0x800000E8, 0xC2000002, 0xC0004850, 0xCE0400F8, 0x8000FC00, 0xC2000000,
+ 0xC0004850, 0xCE0400F8, 0xA7E60032, 0x00000000, 0xC2000002, 0xC0001B00, 0xCE040000, 0x8000FBE8,
+ 0x00000000, 0xA7860052, 0x00000000, 0xC68000F8, 0xC13C0002, 0xCD03DE00, 0xC2020002, 0xC7E2A540,
+ 0xC0001B00, 0xCE0400F8, 0x8000FB90, 0xC2040002, 0xC0001B00, 0xCE044200, 0x8000FB70, 0xC2C80002,
+ 0x6AC56000, 0xDACC00F8, 0xC0004854, 0xCB4400F8, 0xC0004848, 0xCB8400F8, 0xC0000838, 0xC3C00000,
+ 0xCBC40028, 0x5EF40004, 0x84000022, 0xC3000000, 0xC0001ACC, 0xCF042100, 0x47F98000, 0x8400004A,
+ 0x47F98000, 0x88000050, 0xC1006E8C, 0xC1400010, 0x8D580000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC0004840, 0xCC8400F8, 0x8000EB10, 0xC0001AC0, 0xCAC400F8, 0xC0004854, 0xCB4400F8, 0xA6C0F93A,
+ 0x00000000, 0x5EF40000, 0x8400F472, 0x5EF40002, 0x8400F702, 0x5EF40004, 0x8400F902, 0xC1006CE8,
+ 0xC1400010, 0x8D580000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xC0800000, 0xDF4B0038,
+ 0xC0004900, 0xCB8000F8, 0xC2000000, 0xC000490A, 0xA78000D0, 0xCBC000F8, 0xC1000000, 0xD90000F9,
+ 0xC1000002, 0xD90C00F8, 0x6FF46000, 0x477DA000, 0x5B744C80, 0xC2400000, 0x58340004, 0xCA400078,
+ 0xC0004900, 0xCE000000, 0x5A640002, 0x58340004, 0xC6500078, 0xCD000078, 0xC0004914, 0xCA4000F8,
+ 0xC2000002, 0x6A3D0000, 0x72612000, 0xCE4000F8, 0xC0000408, 0xCE0000F8, 0xA78200D8, 0xC0004908,
+ 0xCBC000F8, 0xC1000000, 0xD90000F9, 0xC1000002, 0xD90C00F8, 0x6FF4A000, 0x6FD44000, 0x4755A000,
+ 0x477DA000, 0x5B747000, 0xC2800000, 0x58340006, 0xCA800078, 0xC2000000, 0xC0004900, 0xCE002100,
+ 0x5EA80002, 0x58340006, 0xC6900078, 0xCD000078, 0x5A7C0020, 0xC2000002, 0x6A250000, 0xC0000408,
+ 0xCE0000F8, 0xC0000032, 0xDCA800F9, 0xC1000002, 0x45294000, 0x00000000, 0x8C100006, 0x00000000,
+ 0x00000000, 0x00000000, 0xA4800230, 0x00000000, 0xC3C00000, 0xC000140E, 0xCBC00018, 0xC3400000,
+ 0xC2400000, 0x6FF86000, 0x47BDC000, 0x5BB84C80, 0x58380008, 0xCB400078, 0x58380006, 0xCA400078,
+ 0x5F740002, 0x58380008, 0xC7500078, 0xCD000078, 0xC2000000, 0x58380004, 0xCA020078, 0xC3000000,
+ 0x5838000C, 0xCB000020, 0x5A640002, 0x46610000, 0x84000010, 0xC2400000, 0x58380006, 0xC6500078,
+ 0xCD000078, 0xC2000000, 0x5838000A, 0xCA020078, 0x5B300002, 0x5838000C, 0xC7100020, 0xCD000020,
+ 0xC2420020, 0x5A200004, 0x46252000, 0x84000010, 0xC2000000, 0x5838000A, 0xC6101078, 0xCD021078,
+ 0xC0004966, 0xCA4000F8, 0xC2000002, 0x6A3D0000, 0x72612000, 0xCE4000F8, 0x5F740000, 0x84000040,
+ 0xC0004912, 0xCA0000F8, 0xC2C00002, 0x6AFD6000, 0x7EC16000, 0x762D0000, 0xCE0000F8, 0x5F300020,
+ 0x84000040, 0xC0004924, 0xCA0000F8, 0xC2C00002, 0x6AFD6000, 0x7EC16000, 0x762D0000, 0xCE0000F8,
+ 0xA4820070, 0xC2400000, 0xC000140E, 0xCA408018, 0xC2000002, 0xC0004900, 0xCE000000, 0xC000490A,
+ 0xCE4000F8, 0xC1000000, 0xD90000F9, 0xD8400078, 0xC1000004, 0xD90000F9, 0xA48402A8, 0x00000000,
+ 0xC3C00000, 0xC000140E, 0xCBC10018, 0xC2800000, 0xC2000000, 0x6FF8A000, 0x6FD44000, 0x4795C000,
+ 0x47BDC000, 0x5BB87000, 0x5838002E, 0xCA800078, 0x58380006, 0xCA020078, 0xC3400000, 0x5838002E,
+ 0xCB420078, 0x5AA80002, 0x46A10000, 0x84000010, 0xC2800000, 0x5838002E, 0xC6900078, 0xCD000078,
+ 0x5F740002, 0x5838002E, 0xC7501078, 0xCD021078, 0xC0004968, 0xCA4000F8, 0xC2000002, 0x6A3D0000,
+ 0x72612000, 0xCE4000F8, 0xC000492A, 0xCA8000F8, 0x5E740000, 0x84000040, 0xC0004910, 0xCA0000F8,
+ 0xC2C00002, 0x6AFD6000, 0x7EC16000, 0x762D0000, 0xCE0000F8, 0x6ABD4010, 0xA68000F2, 0x00000000,
+ 0xC0004910, 0xCA0000F8, 0xC2C00002, 0x6AFD6000, 0x7EC16000, 0x762D0000, 0xCE0000F8, 0x58380032,
+ 0xCA0000F8, 0x58000002, 0xCA4000F8, 0x5838000C, 0x00000000, 0xCE0000F9, 0xCE4000F8, 0xC000492A,
+ 0xCA0000F8, 0xC2C00002, 0x6AFD6000, 0x722D0000, 0xCE0000F8, 0xC000492C, 0xCA0000F8, 0xC2C00002,
+ 0x6AFD6000, 0x722D0000, 0xCE0000F8, 0x80000040, 0xC000492C, 0xCA0000F8, 0xC2C00002, 0x6AFD6000,
+ 0x7EC16000, 0x762D0000, 0xCE0000F8, 0xA4880120, 0xC2C00000, 0xC000140E, 0xCAC20018, 0xC000490E,
+ 0xCA4000F8, 0xC2000002, 0x6A2D0000, 0x7E010000, 0x76612000, 0xCE4000F8, 0xC000496A, 0xCA4000F8,
+ 0xC2000002, 0x6A2D0000, 0x72612000, 0xCE4000F8, 0x6EF0A000, 0x6ED44000, 0x47158000, 0x472D8000,
+ 0x5B307000, 0x58300000, 0xCA0000F8, 0x00000000, 0xC2400002, 0x76612000, 0x8400004A, 0xC24C0002,
+ 0xC6E40018, 0xC624C400, 0x58300010, 0xCA400500, 0x00000000, 0xC0001800, 0xCE4000F8, 0xA4860070,
+ 0xC2400000, 0xC000140E, 0xCA418018, 0xC2020002, 0xC0004900, 0xCE002100, 0xC0004908, 0xCE4000F8,
+ 0xC1000000, 0xD90000F9, 0xD8400078, 0xC1000004, 0xD90000F9, 0xA48C0048, 0xC2800002, 0xC000484A,
+ 0xCE8000F8, 0xC2800000, 0xC000474A, 0xCE8000F8, 0xC0004846, 0xCE8000F8, 0xC0001408, 0xCC8000F8,
+ 0xC10E0002, 0xD90C00F8, 0x8000EA78, 0xDFBC00F9, 0xC000496E, 0x99008638, 0xC94000F8, 0xC7D800F8,
+ 0x00000000, 0xC57000F8, 0x5EF00020, 0x88000148, 0x6F346000, 0x4771A000, 0x5B744C80, 0x58340008,
+ 0xC2400000, 0xCA400078, 0x00000000, 0xC2000000, 0x5A640002, 0xCE400078, 0x58340004, 0xCA000078,
+ 0x00000000, 0x00000000, 0x5E200002, 0xCE000078, 0xC0004912, 0xCA8000F8, 0xC2400002, 0x6A712000,
+ 0x72A54000, 0xCE8000F8, 0x5E200000, 0x84000052, 0xC000480A, 0xCA0000F8, 0xC0000408, 0xCA8000F8,
+ 0x76250000, 0x00000000, 0x72A14000, 0xCE8000F8, 0x80000038, 0xC0004914, 0xCA0000F8, 0x7E412000,
+ 0x00000000, 0x76250000, 0xCE0000F8, 0x800000D0, 0x6EF4A000, 0x6ED44000, 0x4755A000, 0x476DA000,
+ 0x5B747000, 0x5834002E, 0xC2400000, 0xCA420078, 0x00000000, 0xC2000000, 0x5A640002, 0xC6501078,
+ 0xCD021078, 0x58340006, 0xCA000078, 0x00000000, 0x00000000, 0x5A200002, 0xCE000078, 0xC0004910,
+ 0xCA4000F8, 0xC2000002, 0x6A2D0000, 0x72612000, 0xCE4000F8, 0xC2000002, 0x6A310000, 0xC000042A,
+ 0xCE0000F8, 0xC1040002, 0xD90C00F8, 0x00000000, 0x8000E7E8, 0x00000000, 0xC4980928, 0x9D000000,
+ 0xC5580028, 0xC0000838, 0xCD8400F8, 0xC1440200, 0xC1C03800, 0xC55C1070, 0xC000100E, 0x9D000000,
+ 0xCD8000F8, 0xC000100C, 0xCDC000F8, 0xC0004862, 0xC9C000F8, 0x00000000, 0x00000000, 0xD9D800F9,
+ 0xC0007800, 0x401C0000, 0x5DC07A00, 0x88000012, 0x5C000200, 0xCD8000F8, 0xC1F0000A, 0x715CA000,
+ 0xDD9800F8, 0xDD9C00F9, 0x41D8E000, 0xC5D40260, 0xC0001010, 0xCD4000F8, 0x6C9C8000, 0x45C8E000,
+ 0x45C8E000, 0x59DC0004, 0xC1601260, 0xC5D40260, 0x9D000000, 0xC0001012, 0xCD4000F8, 0x00000000,
+ 0x00000000, 0xD95800F8, 0x6D586000, 0x4594C000, 0x59984C80, 0xD99800F9, 0x5818000A, 0xC1800000,
+ 0xC9800078, 0xC0006E00, 0x6D5CA000, 0x401C0000, 0x40180000, 0xC94000F8, 0x58000002, 0x00000000,
+ 0xC9C000F8, 0xC0004930, 0xCD4000F8, 0xC0004932, 0xCDC000F8, 0x59980004, 0xC1C20020, 0xB59C0018,
+ 0x00000000, 0xC1800000, 0xDD9C00F9, 0x581C000A, 0xCD800078, 0x581C000C, 0xC1800000, 0xC9800020,
+ 0xC1C00002, 0xDD9400F8, 0x69D4E000, 0x5D980002, 0xCD800020, 0xC0004924, 0xC98000F8, 0x00000000,
+ 0x9D000000, 0x00000000, 0x719CC000, 0xCD8000F8, 0xC000492A, 0xC94000F8, 0xC1C00002, 0x69D8E000,
+ 0x7DC0C000, 0x7558A000, 0xCD4000F8, 0xC000492C, 0xC94000F8, 0xDD8000F9, 0x58000032, 0x755CA000,
+ 0x84000090, 0xC94000F9, 0xC98000F8, 0xDD8000F9, 0x5800000C, 0x00000000, 0xCD4000F9, 0xCD8000F8,
+ 0xC000492C, 0xC94000F8, 0xC000492A, 0xC98000F8, 0x715CA000, 0xC000492C, 0xCD4000F8, 0x719CC000,
+ 0xC000492A, 0xCD8000F8, 0x9D000000, 0x00000000, 0x00000000, 0x00000000, 0xC0004862, 0xC98000F8,
+ 0x00000000, 0xC1C00200, 0x4194C000, 0x459CE000, 0x88000012, 0xC5D800F8, 0xC0004862, 0xCD8000F8,
+ 0xC0001406, 0xC98000F8, 0xC1C00002, 0x9D000000, 0xC5D80A00, 0xC5581048, 0xCD8000F8, 0xC0004930,
+ 0xC98000F8, 0xC0004932, 0xC9C000F8, 0xC140000E, 0xC5581C18, 0xDD9400F8, 0xC0007800, 0x40140000,
+ 0x5D407A00, 0x88000012, 0x5C000200, 0xCD8000F8, 0x58000002, 0x5D407A00, 0x88000012, 0x5C000200,
+ 0xCDC000F8, 0xDD5400F8, 0xC1C00000, 0x58140006, 0xC9C20078, 0xC1800000, 0x58140000, 0xC98000D8,
+ 0x6DDC2000, 0xC000491E, 0x41D8E000, 0xCDC000F8, 0xDD9800F8, 0xC1C00022, 0xC5D80D70, 0xDD9400F9,
+ 0xC5581C18, 0xC000491C, 0xCD8000F8, 0xDD5400F8, 0xC1C00000, 0x58140006, 0xC9C20078, 0xC1800000,
+ 0x58140004, 0xC9820078, 0x00000000, 0x59DC0002, 0x45D8C000, 0x84000010, 0xC1C00000, 0x9D000000,
+ 0x58140006, 0xC5D81078, 0xCD821078, 0xC0004860, 0xC94000F8, 0xC1820080, 0xC1D00002, 0x58147700,
+ 0xD58000F8, 0x58000002, 0xD58000F9, 0x59540004, 0xB5580018, 0xC0004860, 0xC1400000, 0xCD4000F8,
+ 0xDD9800F9, 0x9D000000, 0xDD9400F8, 0xC0001404, 0xCDC10800, 0xC1C00000, 0xC1800200, 0x5D980004,
+ 0xDF5D0048, 0x459CA000, 0x8800FFF2, 0xDD8000F9, 0x5800000C, 0x00000000, 0xC94000F9, 0xC98000F8,
+ 0xC1C00002, 0xC5D43F00, 0xC5D81E00, 0xC0004862, 0xC9C000F8, 0x00000000, 0x00000000, 0x581C7800,
+ 0x5DC07A00, 0x88000012, 0x5C000200, 0xCD4000F8, 0x58000002, 0x5DC07A00, 0x88000012, 0x5C000200,
+ 0xCD8000F8, 0xC0004862, 0xC9C000F8, 0x00000000, 0xC15004C0, 0xC5D40060, 0xDD9C00F8, 0xC5D41C18,
+ 0xC1C00000, 0xDD8000F9, 0x58000030, 0xC9C00078, 0xDD8000F9, 0x58000002, 0xC98000F8, 0x6DDC2000,
+ 0xC000491C, 0x41D8E000, 0xCD4000F9, 0xCDC000F8, 0xDD9400F9, 0xC1C00000, 0x58140030, 0xC9C00078,
+ 0xC1800000, 0x58140006, 0xC9820078, 0x00000000, 0x59DC0002, 0x45D8C000, 0x84000010, 0xC1C00000,
+ 0x9D000000, 0x58140030, 0xC5D80078, 0xCD800078, 0xC1C00000, 0xDF5C0038, 0x5DDC0080, 0x8400FFEA,
+ 0x00000000, 0x9D000000, 0x00000000, 0x00000000, 0x00000000, 0xC160FFFE, 0xC0000A10, 0xC9440060,
+ 0xC1A0FFFE, 0x59983008, 0xC000100C, 0xCD4000F8, 0xC000100E, 0xCD8000F8, 0xC0004964, 0xC98000F8,
+ 0x00000000, 0xC170000A, 0x7158A000, 0x6C988000, 0x4588C000, 0x4588C000, 0x59980004, 0xC5940270,
+ 0xC0001010, 0xCD4000F8, 0xC0004946, 0xC94000F8, 0x00000000, 0x00000000, 0x6D58A000, 0x6D5C4000,
+ 0x459CC000, 0x4594C000, 0xC000494A, 0xC94000F8, 0xC0004948, 0xC9C000F8, 0x4194C000, 0xC1400012,
+ 0xC55C1818, 0x9D000000, 0xC59C0268, 0xC0001012, 0xCDC000F8, 0xC1400000, 0x58000012, 0xC9410038,
+ 0xC0004950, 0xC9C000F8, 0xC55800F8, 0xC5940838, 0xC5581078, 0xD99400F8, 0xC000493C, 0xC94000F8,
+ 0xC0004954, 0xC98000F8, 0x59DC00A8, 0x45D4E000, 0x41D8E000, 0x5D5C0030, 0x88000010, 0xC1C00030,
+ 0xC1800000, 0xC5D84028, 0xC1400000, 0xC5D40008, 0x5DD40002, 0x84000072, 0x5DD40004, 0x8400009A,
+ 0x5DD40006, 0x840000C2, 0x5DD80026, 0x840000EA, 0xDD5400F8, 0xDD8000F9, 0x58000008, 0x40180000,
+ 0xCD4000F8, 0x59980002, 0x8000FFC0, 0xDD5400F8, 0xDD8000F9, 0x58000008, 0x40180000, 0xCD4000B8,
+ 0x59980002, 0x8000FF88, 0xDD5400F8, 0xDD8000F9, 0x58000008, 0x40180000, 0xCD400078, 0x59980002,
+ 0x8000FF50, 0xDD5400F8, 0xDD8000F9, 0x58000008, 0x40180000, 0xCD400038, 0x59980002, 0x8000FF18,
+ 0x00000000, 0x9D000000, 0x00000000, 0x00000000, 0x00000000, 0x58000012, 0xC94000F8, 0xC0004954,
+ 0xC9C000F8, 0xC0004950, 0xC9400078, 0xDD8000F9, 0x58000028, 0x5D9C0000, 0x84000052, 0x5D9C0002,
+ 0x84000052, 0x5D9C0004, 0x8400006A, 0xC55B0038, 0xC55C08B8, 0xCD800039, 0xCDC108B8, 0x80000060,
+ 0xCD4000F8, 0x80000050, 0xC55900B8, 0xC55C1838, 0xCD8000B9, 0xCDC31838, 0x80000028, 0xC55A0078,
+ 0xC55C1078, 0xCD800079, 0xCDC21078, 0x9D000000, 0x00000000, 0x00000000, 0x00000000, 0x59540002,
+ 0x6994E018, 0x61C0C008, 0x4194A000, 0x5D940040, 0x88000012, 0xC59400F8, 0x9D000000, 0xCD4000F8,
+ 0x00000000, 0x00000000, 0x9D000000, 0x4158A000, 0xCD4000F8, 0x00000000, 0xCD8000F9, 0x45408000,
+ 0x8800FFF0, 0x00000000, 0x9CC00000, 0x00000000, 0x00000000, 0x00000000, 0xC0004810, 0xCA010038,
+ 0xC241FFFE, 0xC1400000, 0x46148000, 0x00000000, 0x9CC00006, 0xC0004200, 0x40180000, 0xC9C000F8,
+ 0x00000000, 0x00000000, 0x61C08010, 0x8400005A, 0xC2400002, 0x6A512000, 0x71E4E000, 0xCDC000F8,
+ 0xC0004748, 0xCD8000F8, 0x9CC00000, 0x6D98A000, 0x5998003E, 0x45912000, 0x59540002, 0x59980002,
+ 0x46188000, 0xC1000000, 0xC51800FE, 0x8000FF38, 0x00000000, 0x40180000, 0xC9C000F8, 0xC2000000,
+ 0xC5600020, 0xC1210000, 0x69208010, 0x7D008000, 0x75D0E000, 0xCDC000F8, 0x6D542000, 0x58144300,
+ 0xC1000000, 0xCD0000F9, 0x9CC00000, 0xC121FFFE, 0x5911FFFE, 0xCD0000F9, 0x79588000, 0x6D10A010,
+ 0x5D100000, 0x840000C0, 0x45948000, 0x880000B0, 0x6D536000, 0x6D136010, 0x6D54A010, 0xC0004700,
+ 0x40140000, 0xCA0000F8, 0x00000000, 0x00000000, 0x6A110000, 0x6A110010, 0x62008018, 0x84000032,
+ 0x00000000, 0x9CC00000, 0x6D54A000, 0x5954003E, 0x45512000, 0x59540002, 0x6D57A000, 0x6D57A010,
+ 0x6D54A000, 0x6D936000, 0x6D136010, 0xC1E10000, 0x69D0E010, 0x5DDC0002, 0x7DC0E000, 0x6D98A010,
+ 0x6D536000, 0x6D136010, 0x6D54A010, 0xC0004700, 0x40140000, 0xCA0000F8, 0x00000000, 0x00000000,
+ 0x6A110000, 0x6A110010, 0x45588000, 0x00000000, 0x761D0002, 0x62008018, 0x84000032, 0x00000000,
+ 0x9CC00000, 0x6D54A000, 0x5954003E, 0x45512000, 0x45588000, 0x00000000, 0x9CC00002, 0x59540002,
+ 0x6D57A000, 0x6D57A010, 0xC0004700, 0x40140000, 0xCA0000F8, 0x8000FF68, 0x00000000, 0x00000000,
+ 0x00000000, 0x58004700, 0xC98000F8, 0x9CC00000, 0x00000000, 0x6994C000, 0x6DA7E010, 0x58004700,
+ 0xC98000F8, 0xC1210000, 0x9CC00000, 0x69148010, 0x7190C000, 0xCD8000F8, 0xC1000000, 0xC0004810,
+ 0xC9020038, 0x00000000, 0x00000000, 0x45D0C000, 0x88000062, 0xC2400002, 0x45588000, 0xC1000000,
+ 0xC52400FC, 0x45D48000, 0xC1000000, 0xC52400FE, 0x9CC00000, 0x00000000, 0x00000000, 0x00000000,
+ 0x59980200, 0xC2400000, 0x455C8000, 0xC1000002, 0xC52400FC, 0x45948000, 0xC1000002, 0xC52400FE,
+ 0x9CC00000, 0x00000000, 0x00000000, 0x00000000, 0xC0004740, 0xC9C000F8, 0x59180002, 0x6D130000,
+ 0x6D130010, 0x451C8000, 0xC2400000, 0x9CC00002, 0x00000000, 0x00000000, 0x459C8000, 0x88000062,
+ 0xC2400002, 0x455C8000, 0xC1000000, 0xC52400FC, 0x45948000, 0xC1000000, 0xC52400FC, 0x9CC00000,
+ 0x00000000, 0x00000000, 0x00000000, 0xC2400000, 0x45588000, 0xC1000002, 0xC52400FE, 0x45D48000,
+ 0xC1000002, 0xC52400FE, 0x9CC00000, 0x00000000, 0x00000000, 0x00000000, 0x59540002, 0x6D570000,
+ 0x6D570010, 0x45588000, 0x6D402000, 0x9CC00002, 0x58004300, 0x58000000, 0xC13C0002, 0xCD03DE00,
+ 0x8000FFB0, 0x00000000, 0x00000000, 0x00000000, 0xC1020002, 0xD90C00F8, 0xC98000F8, 0x59540002,
+ 0xC0004730, 0xCD4000F8, 0x5D980002, 0x00000000, 0x80000036, 0x00000000, 0x9CC00000, 0xC0004732,
+ 0xCD8000F8, 0x00000000, 0xC0004734, 0xC9C000F8, 0xC1800000, 0xC0004816, 0xC9820078, 0xC0004738,
+ 0xCDC000F8, 0xC1C00000, 0xC0004734, 0x9CC00000, 0xCDC000F8, 0xC0004732, 0xCD8000F8,
+};
+
+static unsigned int firmware_binary_data[] = {
+};
+
+
+#endif // IFXMIPS_ATM_FW_AR9_H
diff --git a/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_fw_danube.h.svn-base b/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_fw_danube.h.svn-base
new file mode 100644
index 0000000..57b7586
--- /dev/null
+++ b/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_fw_danube.h.svn-base
@@ -0,0 +1,442 @@
+#ifndef IFXMIPS_ATM_FW_DANUBE_H
+#define IFXMIPS_ATM_FW_DANUBE_H
+
+
+/******************************************************************************
+**
+** FILE NAME : ifxmips_atm_fw_danube.h
+** PROJECT : Danube
+** MODULES : ATM (ADSL)
+**
+** DATE : 1 AUG 2005
+** AUTHOR : Xu Liang
+** DESCRIPTION : ATM Driver (PP32 Firmware)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 4 AUG 2005 Xu Liang Initiate Version
+** 23 OCT 2006 Xu Liang Add GPL header.
+*******************************************************************************/
+
+
+#define VER_IN_FIRMWARE 1
+
+#define ATM_FW_VER_MAJOR 0
+#define ATM_FW_VER_MINOR 17
+// fix 1 upstream packet stuck in TX queue issue
+// add multiple queue per PVC feature
+
+
+static unsigned int danube_fw_bin[] = {
+ 0x800004A0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8000FFC8, 0x00000000, 0x00000000, 0x00000000,
+ 0xC1000002, 0xD90C0000, 0xC2000002, 0xDA080001, 0x80004968, 0xC2000000, 0xDA080001, 0x80003FD0,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x80003F88, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x80005160, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x80003E88, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC0400000, 0xC0004840, 0xC8840000, 0x80004628, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC0400002, 0xC0004840, 0xC8840000, 0x800045A8, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC3C00004, 0xDBC80001, 0xC10C0002, 0xD90C0000, 0x8000FEC8, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC10E0002, 0xD90C0000, 0xC0004808, 0xC8400000, 0x800045D8, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC3E1FFFE, 0x597DFFFE, 0x593DFE14, 0x900004D9, 0x00000000, 0x00000000, 0x00000000, 0x90CC0481,
+ 0x00000000, 0x00000000, 0x00000000, 0xC3C00000, 0xDBC80001, 0xC1400008, 0xC1900000, 0x71948000,
+ 0x15000100, 0xC140000A, 0xC1900002, 0x71948000, 0x15000100, 0xC140000C, 0xC1900004, 0x71948000,
+ 0x15000100, 0xC1400004, 0xC1900006, 0x71948000, 0x15000100, 0xC1400006, 0xC1900008, 0x71948000,
+ 0x15000100, 0xC140000E, 0xC190000A, 0x71948000, 0x15000100, 0xC1400000, 0xC190000C, 0x71948000,
+ 0x15000100, 0xC1400002, 0xC190000E, 0x71948000, 0x15000100, 0xC0400000, 0xC11C0000, 0xC000082C,
+ 0xCD040E08, 0xC11C0002, 0xC000082C, 0xCD040E08, 0xC0400002, 0xC11C0000, 0xC000082C, 0xCD040E08,
+ 0xC11C0002, 0xC000082C, 0xCD040E08, 0xC0000824, 0x00000000, 0xCBC00001, 0xCB800001, 0xCB400001,
+ 0xCB000000, 0xC0004878, 0x5BFC4000, 0xCFC00001, 0x5BB84000, 0xCF800001, 0x5B744000, 0xCF400001,
+ 0x5B304000, 0xCF000000, 0xC0000A10, 0x00000000, 0xCBC00001, 0xCB800000, 0xC0004874, 0x5BFC4000,
+ 0xCFC00001, 0x5BB84000, 0xCF800000, 0xC30001FE, 0xC000140A, 0xCF000000, 0xC3000000, 0x7F018000,
+ 0xC000042E, 0xCF000000, 0xC000040E, 0xCF000000, 0xC3C1FFFE, 0xC000490E, 0xCFC00080, 0xC000492C,
+ 0xCFC00080, 0xC0004924, 0xCFC00040, 0xC0004912, 0xCFC00040, 0xC0004966, 0xCFC00040, 0xC0004968,
+ 0xCFC00080, 0xC000496A, 0xCFC00080, 0xC3C1FFFE, 0xC00049A0, 0xCFC00000, 0xC3C00000, 0xC2800020,
+ 0xC3000000, 0x7F018000, 0x6FF88000, 0x6FD44000, 0x4395C000, 0x5BB84A00, 0x5838000A, 0xCF000000,
+ 0x5BFC0002, 0xB7E8FFA8, 0x00000000, 0xC3C00000, 0xC2800010, 0x6FF86000, 0x47F9C000, 0x5BB84C80,
+ 0xC3400000, 0x58380004, 0xCB420080, 0x00000000, 0x58380008, 0xCF400080, 0x5BFC0002, 0xB7E8FF90,
+ 0x00000000, 0xC3C00000, 0xC2800020, 0xC348001E, 0xC3000000, 0x7F018000, 0x6FF8A000, 0x6FD44000,
+ 0x4579C000, 0x47F9C000, 0x5BB84E20, 0x58380008, 0xCF400420, 0x5838000A, 0xCF000000, 0x5BFC0002,
+ 0xB7E8FF90, 0x00000000, 0x00000000, 0xC3E02242, 0x5BFC0022, 0xC0004002, 0xCFC00000, 0x00000000,
+ 0xC121FFFE, 0x5911FE14, 0x15000000, 0x80000518, 0x00000000, 0x80002118, 0x00000000, 0x8000FFC8,
+ 0xC0004958, 0xC8400000, 0x00000000, 0xC3C00002, 0x7BC42000, 0xCC400000, 0xC0004848, 0xCB840000,
+ 0xC000495C, 0xCAC40000, 0xC0004844, 0xC8840000, 0x46F90000, 0x8400FF6A, 0xC000487C, 0xC8040000,
+ 0x00000000, 0x00000000, 0x40080000, 0xCA000000, 0xC0001624, 0xCB040000, 0xA63C005A, 0x00000000,
+ 0x00000000, 0xA71EFF02, 0x00000000, 0xC0000824, 0xCA840000, 0x6CA08000, 0x6CA42000, 0x46610000,
+ 0x42290000, 0xC35E0002, 0xC6340068, 0xC0001624, 0xCF440080, 0xC2000000, 0xC161FFFE, 0x5955FFFE,
+ 0x15400000, 0x00000000, 0xC0004844, 0xC8840000, 0xC000082C, 0xCA040040, 0x00000000, 0x00000000,
+ 0x58880002, 0xB608FFF8, 0x00000000, 0xC0800000, 0xC0004844, 0xCC840040, 0x5AEC0002, 0xC000495C,
+ 0xCEC40000, 0x5E6C0006, 0x84000048, 0xC0004848, 0xCB840000, 0xC0000838, 0xC2500002, 0xCE440808,
+ 0x5FB80002, 0xC0004848, 0xCF840000, 0x5EEC0002, 0xC000495C, 0xCEC40000, 0x00000000, 0xC121FFFE,
+ 0x5911FE14, 0x15000000, 0x8000FD80, 0xC000495A, 0xC8400000, 0x00000000, 0xC3C00002, 0x7BC42000,
+ 0xCC400000, 0xC0004960, 0xCAC40000, 0x00000000, 0x00000000, 0x5EEC0000, 0x840000F2, 0x00000000,
+ 0xB6FC0030, 0xC0001600, 0xCA040000, 0x00000000, 0x00000000, 0xA61E00B2, 0x6FE90000, 0xC0000A28,
+ 0xCE840808, 0xC2C00000, 0xC2800004, 0xB6E80080, 0xC0001604, 0xCA840000, 0xC0004960, 0xCEC40000,
+ 0xA69EFCA2, 0x00000000, 0x6FE90000, 0xC0000A28, 0xCE840808, 0xC2C00002, 0xC0001600, 0xCA040000,
+ 0x00000000, 0x00000000, 0xA61E000A, 0x6FE90000, 0xC0000A28, 0xCE840808, 0xC2C00000, 0xC0001604,
+ 0xCA840000, 0xC0004960, 0xCEC40000, 0xA69EFC0A, 0xC2400000, 0xC0000A14, 0xCA440030, 0x00000000,
+ 0x00000000, 0x46E52000, 0xA4400000, 0xC2800000, 0xDFEB0031, 0x8000FFF8, 0xDFEA0031, 0xB668FB82,
+ 0x00000000, 0xC00048A0, 0xCB040000, 0xC0000A10, 0xCA840000, 0x6F208000, 0x6F242000, 0x46610000,
+ 0x42A10000, 0xC2400000, 0xC0000A14, 0xCA440030, 0xC35E0002, 0xC6340068, 0xC0001604, 0xCF440080,
+ 0x5B300002, 0xB670FFF8, 0x5AEC0002, 0xC3000000, 0xC00048A0, 0xCF040000, 0xC0004960, 0xCEC40000,
+ 0x8000FAC0, 0xC0004918, 0xD2800000, 0xC2000000, 0xDF600040, 0x5E600080, 0x8400025A, 0x00000000,
+ 0xC161FFFE, 0x5955FFFE, 0x15400000, 0x00000000, 0xC000480A, 0xCA000000, 0xC0004912, 0xCA400000,
+ 0xC0004924, 0xCA800000, 0xC0004966, 0xCAC00000, 0x00000000, 0xC121FFFE, 0x5911FE14, 0x15000000,
+ 0x76610000, 0x76A10000, 0x76E10000, 0x840001B2, 0xC0004918, 0xCA400000, 0xC28001FE, 0x76A10000,
+ 0x5A640002, 0x6A254010, 0x5EE80000, 0x84000002, 0x6AA54000, 0x8000FFF8, 0xC6280000, 0x62818008,
+ 0xC0004918, 0xCF000000, 0xC161FFFE, 0x5955FFFE, 0x15400000, 0x00000000, 0xC0004966, 0xCA400000,
+ 0xC2000002, 0x6A310000, 0x7E010000, 0x76252000, 0xCE400000, 0x00000000, 0xC121FFFE, 0x5911FE14,
+ 0x15000000, 0x6F346000, 0x4735A000, 0x5B744C80, 0xC2800000, 0x58340006, 0xCA800080, 0xC2C00000,
+ 0x58340000, 0xCAC000E0, 0xC2400000, 0x5834000A, 0xCA420080, 0x6EA82000, 0x42E9E000, 0x6F2CA000,
+ 0x42E56000, 0x5AEC1400, 0xC3990040, 0xC7381C20, 0xC6F80068, 0x99005B78, 0xDB980000, 0xDBD80001,
+ 0x00000000, 0xDEA00000, 0x47210000, 0x8400FD68, 0xC0004958, 0xC8400000, 0x00000000, 0xC3C00002,
+ 0x7BC42000, 0xCC400000, 0xC0004848, 0xCB840000, 0xC0004844, 0xC8840000, 0x5FB80000, 0x8400F7DA,
+ 0xC0001A1C, 0xCA000000, 0xC2400002, 0x6A452000, 0x76610000, 0x8400F7AA, 0xC000487C, 0xC8040000,
+ 0x00000000, 0x00000000, 0x40080000, 0xCA000000, 0xC4240000, 0x00000000, 0xA63C17BA, 0x00000000,
+ 0xC0004878, 0xC8040000, 0x6C908000, 0x44908000, 0x44908000, 0x40100000, 0xCA000000, 0xC4240000,
+ 0x00000000, 0xC0004934, 0xCE000000, 0xC2800002, 0xC4681C10, 0xC62821D8, 0xC2600010, 0x5A650040,
+ 0xC0004800, 0xCB400000, 0xC2200400, 0x5A200000, 0xC7601048, 0xC0001220, 0xCE800000, 0xC0001200,
+ 0xCE400000, 0xC0001202, 0xCE000000, 0xC0001240, 0xCB400000, 0x00000000, 0x00000000, 0xA754FFC0,
+ 0xC2000000, 0xC7600048, 0xA7520022, 0x00000000, 0x00000000, 0x990062F0, 0xC0004822, 0xC9400000,
+ 0xC1800002, 0x80001668, 0x58204080, 0xC2000000, 0xCA000020, 0xC2400000, 0xCA414008, 0xC2800000,
+ 0xCA812008, 0xC2C00000, 0xCAC20020, 0xC0004938, 0xCE000000, 0xC0004920, 0xCE400000, 0xC0004916,
+ 0xCE800000, 0xC0004922, 0xCEC00000, 0xA6400520, 0x00000000, 0xC0004938, 0xCBC00000, 0x00000000,
+ 0xC3800000, 0x6FF48000, 0x6FD44000, 0x4355A000, 0x5B744A00, 0x58340000, 0xCB802018, 0x00000000,
+ 0xC2000000, 0x6FB46000, 0x47B5A000, 0x5B744C80, 0x5834000C, 0xCA000028, 0xC000491A, 0xCF800000,
+ 0x5E200000, 0x84000452, 0xC2000000, 0xDF610050, 0x5E6001E8, 0x8800FFD0, 0xC2000002, 0xC2400466,
+ 0xC2A00000, 0x5AA80000, 0xC0001006, 0xCE000000, 0xC0001008, 0xCE400000, 0xC000100A, 0xCE800000,
+ 0x990055B8, 0xC1A0FFFE, 0xC0000824, 0xC9840068, 0xC0004934, 0xCA400000, 0xC2000000, 0xC2800002,
+ 0x990055F8, 0xDA980000, 0xC6140000, 0xC6580000, 0xC161FFFE, 0x5955FFFE, 0x15400000, 0x00000000,
+ 0x990056E0, 0xC000491A, 0xC9400000, 0x00000000, 0x00000000, 0xC121FFFE, 0x5911FE14, 0x15000000,
+ 0xC0004922, 0xCA001120, 0xC3C00000, 0xC3800000, 0xC0004930, 0xCE001120, 0xC0004932, 0xCBC000E0,
+ 0xC2800000, 0xC000491E, 0xCFC00000, 0xC0004862, 0xCA800068, 0xC3A0001A, 0x5BB94000, 0xC6B80068,
+ 0xC000491C, 0xCF800000, 0x99005950, 0xC000491C, 0xC1400000, 0xC9420050, 0x00000000, 0x00000000,
+ 0x00000000, 0xA8E2FFC8, 0xC2000000, 0xC1220002, 0xD90C0000, 0xDF600040, 0x5E600080, 0x8400FFDA,
+ 0xC000491C, 0xCA000000, 0xC000491E, 0xCA400000, 0x00000000, 0x00000000, 0x99005B78, 0xDA180000,
+ 0xDA580001, 0x00000000, 0xC2000000, 0xDF610050, 0x5E6001FE, 0x8800FFD0, 0xC0004916, 0xCA800000,
+ 0xC2C00000, 0xDFEC0050, 0xC2400000, 0x46E52000, 0x84000032, 0x5EA80000, 0x84000022, 0xC2600002,
+ 0x990062F0, 0xC000482E, 0xC9400000, 0xC1800002, 0x80000018, 0xC2600000, 0x990062F0, 0xC000482C,
+ 0xC9400000, 0xC1800002, 0xC2000068, 0xC6240080, 0xC0004930, 0xCE400088, 0xC000491A, 0xC9800000,
+ 0xC0004862, 0xC9400000, 0x6D9C6000, 0x459CE000, 0x59DC4C80, 0x990059D8, 0xD9580000, 0xD9980001,
+ 0xD9D40000, 0x99005950, 0xC000491C, 0xC1400000, 0xC9420050, 0xC2000000, 0xDF600040, 0x5E600080,
+ 0x8400FFD2, 0x00000000, 0xC000491C, 0xCA000000, 0xC000491E, 0xCA400000, 0x00000000, 0x00000000,
+ 0x99005B78, 0xDA180000, 0xDA580001, 0x00000000, 0x800010D0, 0x00000000, 0x990062F0, 0xC000482A,
+ 0xC9400000, 0xC1800002, 0x800010A0, 0xC0004938, 0xCBC00000, 0x00000000, 0x00000000, 0x6FF88000,
+ 0x6FD44000, 0x4395C000, 0x5BB84A00, 0x58380008, 0xCA000000, 0x00000000, 0x00000000, 0xA6000362,
+ 0x00000000, 0xC0004938, 0xCBC00000, 0xC3000000, 0x00000000, 0x6FF88000, 0x6FD44000, 0x4395C000,
+ 0x5BB84A00, 0x58380000, 0xCB002018, 0xC2000000, 0x58380008, 0xCA020080, 0x5838000C, 0xCAC00000,
+ 0x5838000E, 0xCA400000, 0xC000491A, 0xCF000000, 0xC0004930, 0xCEC00000, 0xC000493C, 0xCE000000,
+ 0xC0004932, 0xCE400000, 0x5E200000, 0x84000108, 0xC2800000, 0xA6FE009A, 0x6F206000, 0x47210000,
+ 0x5A204C80, 0x5820000C, 0xCA800028, 0x00000000, 0x00000000, 0x5EA80000, 0x840001DA, 0x00000000,
+ 0xC161FFFE, 0x5955FFFE, 0x15400000, 0x00000000, 0x990056E0, 0xC000491A, 0xC9400000, 0x00000000,
+ 0x00000000, 0xC121FFFE, 0x5911FE14, 0x15000000, 0xC0004930, 0xCAC00000, 0xC0004932, 0xCA400000,
+ 0xC7EC1120, 0xC0004930, 0xCEC00000, 0x5838000C, 0xCEC00000, 0x58000002, 0xCE400000, 0xC0004934,
+ 0xCA000000, 0xC2400002, 0x6E642000, 0x6E642000, 0x76252000, 0x84000012, 0xC2400002, 0x6E684000,
+ 0x58380008, 0xCE800208, 0xA6000000, 0x6E682000, 0x58380008, 0xCE800108, 0xC2400002, 0x6E642000,
+ 0x76252000, 0x840000D2, 0x58380008, 0xCA000000, 0xC2800000, 0xC2400000, 0xA60200A0, 0xDBA80000,
+ 0x6F386000, 0x4739C000, 0x5BB84C80, 0x58380004, 0xCA400080, 0x58380002, 0xCA800080, 0x00000000,
+ 0xDEB80000, 0x46694000, 0x88000048, 0x00000000, 0xC0004824, 0xCA000000, 0xC2400002, 0x6E640000,
+ 0x5A200002, 0xCE000000, 0x58380008, 0xCE400008, 0x80000000, 0x00000000, 0x80000030, 0xC0004934,
+ 0xCA000000, 0x00000000, 0x00000000, 0xA6020C4A, 0x00000000, 0x00000000, 0x80000C80, 0xC2800000,
+ 0xC2000200, 0xC240001A, 0xDF690050, 0x46A14000, 0x46694000, 0x8800FFBA, 0xC2000006, 0xC2600982,
+ 0x5A643B6E, 0x5838000A, 0xCA800000, 0xC0001006, 0xCE000000, 0xC0001008, 0xCE400000, 0xC000100A,
+ 0xCE800000, 0x990055B8, 0xC1A0FFFE, 0xC0000824, 0xC9840068, 0xC2000000, 0xC0004930, 0xCA02E010,
+ 0x58380026, 0xCA400000, 0x00000000, 0xC2800000, 0x990055F8, 0xDA980000, 0xC6140000, 0xC6580000,
+ 0xC0004934, 0xCA000000, 0x00000000, 0x00000000, 0xA6020002, 0x00000000, 0x00000000, 0x80000300,
+ 0xC0004938, 0xCBC00000, 0xC0004878, 0xC8040000, 0x6C908000, 0x44908000, 0x44908000, 0x40100000,
+ 0xCA000000, 0xC4240000, 0x00000000, 0x58240018, 0xCA000000, 0x6FF88000, 0x6FD44000, 0x4395C000,
+ 0x5BB84A00, 0xC3000000, 0xC3400002, 0xC2C00000, 0xC62C0080, 0xC6270040, 0xC0004940, 0xCE400040,
+ 0xC6260040, 0xC0004942, 0xCE400040, 0xC000493C, 0xCA000000, 0x5EEC0000, 0x84000172, 0x5A6C0010,
+ 0x46614000, 0x88000178, 0x5A600052, 0x466D4000, 0x88000160, 0x58380006, 0xCA800000, 0xC0004940,
+ 0xCA000000, 0xC2400000, 0xC6A70040, 0x7E412000, 0x76252000, 0xC2000000, 0xC6A10040, 0x46610000,
+ 0x84000120, 0xC0004942, 0xCA000000, 0xC2400000, 0xC6A60040, 0x7E412000, 0x76252000, 0xC2000000,
+ 0xC6A00040, 0x58380002, 0xCA800000, 0x46610000, 0x840000D0, 0xC2400000, 0xC6A60080, 0x46E50000,
+ 0x880000C2, 0xC2400000, 0xC6A40080, 0x58380008, 0xCA800000, 0x466D0000, 0x880000A2, 0x00000000,
+ 0xA682FFF8, 0x00000000, 0xC7700B08, 0xA6840078, 0x00000000, 0xC7700A08, 0x80000068, 0xC7700208,
+ 0xC000493C, 0xCAC00000, 0x80000048, 0xC7700308, 0xC000493C, 0xCAC00000, 0x80000028, 0xC7700908,
+ 0x80000018, 0xC7700808, 0x80000008, 0xC7700708, 0x8000FFF8, 0xC7700508, 0xC0004944, 0xCF000000,
+ 0xC000493E, 0xCEC00000, 0xC0004938, 0xCA400000, 0xC000493C, 0xCB800000, 0xC000493E, 0xCB400000,
+ 0xC3000000, 0x6E608000, 0x6E544000, 0x42150000, 0x5A204A00, 0x5AA00008, 0x58200004, 0xCB000080,
+ 0xC0004934, 0xCA000000, 0xC2400000, 0xC0004930, 0xCA42E010, 0xC3C00018, 0xA6020078, 0x00000000,
+ 0x43656000, 0x46F90000, 0x88000038, 0x47AD6000, 0x6EE04010, 0x5BE00004, 0xC2000000, 0xC6E00010,
+ 0x5E200000, 0x8400002A, 0x5BFC0002, 0x80000018, 0xC3C00004, 0x5A2C0008, 0x46390000, 0x8800FFFA,
+ 0x5FB80008, 0x6FE04000, 0x42390000, 0x46312000, 0x88000050, 0xC2400000, 0xC0004930, 0xCA42E010,
+ 0xC2060002, 0xC6800000, 0xCE000308, 0x6FE04000, 0x4631C000, 0x5F700010, 0x4675A000, 0xC2000000,
+ 0xC6340010, 0xC25A000A, 0xC000491A, 0xCA401C20, 0xC2800000, 0xC0004932, 0xCA8000E0, 0xC0004862,
+ 0xCA400068, 0x6FA04010, 0x42290000, 0xC000491E, 0xCE000000, 0xC7E41050, 0xC000491C, 0xCE400000,
+ 0x6FE04000, 0x43A1C000, 0xC000493C, 0xCF800000, 0xC000493E, 0xCF400000, 0xC000493A, 0xCFC00000,
+ 0x8000FFF0, 0x00000000, 0x00000000, 0x00000000, 0xC2000000, 0xDCE00000, 0xA622FFB8, 0xC1220002,
+ 0xD90C0000, 0xC0004938, 0xCBC00000, 0xC0004944, 0xCB400000, 0xC0004862, 0xCB000000, 0xC0004934,
+ 0xCA000000, 0x6FF88000, 0x6FD44000, 0x4395C000, 0x5BB84A00, 0xA6020248, 0xC2400000, 0x58380008,
+ 0xCA406008, 0xDFE80000, 0xC2218E08, 0x5A21BAF6, 0x46294000, 0x8400000A, 0xC2080002, 0x7235A000,
+ 0x80000040, 0x5E640000, 0x8400000A, 0xC20C0002, 0x7235A000, 0x80000018, 0xC2000000, 0xC760E718,
+ 0xC7604220, 0x5E200000, 0x8400025A, 0xC2200002, 0xC0004930, 0xCE001008, 0x990062F0, 0xC0004828,
+ 0xC9400000, 0xC1800002, 0x58380000, 0xCA000000, 0x00000000, 0x00000000, 0xA6000112, 0xC0004940,
+ 0xCA800000, 0xC0004942, 0xCA400000, 0xC7600080, 0xC6A01840, 0xC6601040, 0xC000493A, 0xCA400000,
+ 0xC0004934, 0xCA800000, 0xC0007200, 0x40300000, 0x40240000, 0x5C000004, 0x5EC07400, 0x8800FFFA,
+ 0x5C000200, 0xCE000000, 0x58000002, 0x5EC07400, 0x8800FFFA, 0x5C000200, 0xCE800000, 0xC000493E,
+ 0xCA000000, 0xC2400000, 0x5838000C, 0xCE400000, 0x990062F0, 0xC0004830, 0xC9400000, 0xC6180000,
+ 0xC0004930, 0xC6100080, 0xCD000080, 0x80000090, 0xC2400002, 0x58380008, 0xCE400008, 0xC0004944,
+ 0xCF400000, 0x80000260, 0xC000493C, 0xCA400000, 0xDFE80000, 0x5A300018, 0xC0007200, 0x40200000,
+ 0xCA000000, 0x58380008, 0xC6501080, 0xCD001080, 0x5838000A, 0xCE800000, 0x58380026, 0xCE000000,
+ 0xC0004944, 0xCF400000, 0x99005950, 0xC000491C, 0xC1400000, 0xC9420050, 0x80000020, 0x00000000,
+ 0x990062F0, 0xC0004826, 0xC9400000, 0xC1800002, 0x8000FDC0, 0xC2000000, 0xC2400080, 0xDF600040,
+ 0xB624FFCA, 0xC000491C, 0xCA400000, 0xC000491E, 0xCA800000, 0x99005B78, 0xDA580000, 0xDA980001,
+ 0x00000000, 0xC0004934, 0xCA000000, 0x00000000, 0xC2800000, 0xA6020140, 0xC2400004, 0xC2000200,
+ 0xDF690050, 0x46A14000, 0x46694000, 0x8800FFC2, 0x00000000, 0xC000491A, 0xC9800000, 0xC0004862,
+ 0xC9400000, 0x6D9C6000, 0x459CE000, 0x59DC4C80, 0x990059D8, 0xD9580000, 0xD9980001, 0xD9D40000,
+ 0x99005950, 0xC000491C, 0xC1400000, 0xC9420050, 0xC2000000, 0xC2400080, 0xDF600040, 0xB624FFCA,
+ 0xC000491C, 0xCA400000, 0xC000491E, 0xCA800000, 0x99005B78, 0xDA580000, 0xDA980001, 0x00000000,
+ 0x58380008, 0xCA400000, 0xC2000000, 0xCE000020, 0xC2A1FFFE, 0x5AA9FFFE, 0xCE001080, 0x5838000A,
+ 0xCE800000, 0xC161FFFE, 0x5955FFFE, 0x15400000, 0x00000000, 0xC0000838, 0xC2500002, 0xCE440808,
+ 0xC0004848, 0xCB840000, 0xC2000000, 0xC000082C, 0xCA040030, 0x5FB80002, 0xC0004848, 0xCF840000,
+ 0x58880002, 0xB608FFF8, 0x00000000, 0xC0800000, 0xC0004844, 0xCC840000, 0x00000000, 0xC121FFFE,
+ 0x5911FE14, 0x15000000, 0x8000DEC0, 0xC2000000, 0xDF600040, 0x5E200080, 0x84000252, 0x00000000,
+ 0xC161FFFE, 0x5955FFFE, 0x15400000, 0x00000000, 0xC000480C, 0xCA000000, 0xC0004910, 0xCA400000,
+ 0xC000492C, 0xCA800000, 0xC0004968, 0xCAC00000, 0x00000000, 0xC121FFFE, 0x5911FE14, 0x15000000,
+ 0x76610000, 0x76A10000, 0x762D6000, 0x840001AA, 0xC0004926, 0xCA400000, 0xC201FFFE, 0x762D6000,
+ 0x5A640002, 0x6AE50010, 0x5F200000, 0x84000002, 0x6A250000, 0x8000FFF8, 0xC6E00000, 0x62014008,
+ 0xC0004926, 0xCE800000, 0xC161FFFE, 0x5955FFFE, 0x15400000, 0x00000000, 0xC0004968, 0xCA400000,
+ 0xC2000002, 0x6A290000, 0x7E010000, 0x76252000, 0xCE400000, 0x00000000, 0xC121FFFE, 0x5911FE14,
+ 0x15000000, 0x6EB4A000, 0x6E944000, 0x4575A000, 0x46B5A000, 0x5B744E20, 0x58340002, 0xC2000000,
+ 0xCA0000E0, 0x5834002E, 0xC2400000, 0xCA400080, 0x6EB0A000, 0x6EBC4000, 0x47F18000, 0x46B18000,
+ 0x5B300E4E, 0x5B300004, 0x6E642000, 0x4225E000, 0xC39A8024, 0xC7380068, 0xC6B81C20, 0x99005B78,
+ 0xDB980000, 0xDBD80001, 0x00000000, 0xC2000000, 0xDF600040, 0x5E200080, 0x8400033A, 0x00000000,
+ 0xC161FFFE, 0x5955FFFE, 0x15400000, 0x00000000, 0xC000490E, 0xCA000000, 0xC00049A0, 0xCA800000,
+ 0xC000492A, 0xCA400000, 0xC000496A, 0xCB000000, 0xC0004956, 0xCAC00000, 0x00000000, 0xC121FFFE,
+ 0x5911FE14, 0x15000000, 0x76318000, 0x76718000, 0x76B18000, 0x84000282, 0xC201FFFE, 0x76318000,
+ 0x5AEC0002, 0x6B2D0010, 0x5EA00000, 0x84000002, 0x6A2D0000, 0x8000FFF8, 0xC7200000, 0x62016008,
+ 0xC0004956, 0xCEC00000, 0x6EF4A000, 0x6ED44000, 0x4575A000, 0x46F5A000, 0x5B744E20, 0x58340000,
+ 0xC9C00000, 0xC00049A0, 0xCA000000, 0xC3000000, 0xC5F04020, 0xC2400000, 0xC5E50040, 0x7E412000,
+ 0x76610000, 0xCE000000, 0xC0004980, 0x40300000, 0xCEC00000, 0xC161FFFE, 0x5955FFFE, 0x15400000,
+ 0x00000000, 0xC000496A, 0xCA400000, 0xC2000002, 0x6A2D0000, 0x7E010000, 0x76252000, 0xCE400000,
+ 0x00000000, 0xC121FFFE, 0x5911FE14, 0x15000000, 0x6EF4A000, 0x6ED44000, 0x4575A000, 0x46F5A000,
+ 0x5B744E20, 0x5834000E, 0xC2000000, 0xCA0000E0, 0x58340008, 0xC2400000, 0xCA420080, 0x5834000C,
+ 0xC2800000, 0xCA832018, 0x6E644010, 0x42250000, 0x4229E000, 0xC39A8008, 0x58340008, 0xCB809020,
+ 0x58340008, 0xC2800000, 0xCA810018, 0x6EE0A000, 0x6EE44000, 0x46610000, 0x46E10000, 0x5A200008,
+ 0x5A200E28, 0x42290000, 0xC6380068, 0xC6F81C20, 0x99005B78, 0xDB980000, 0xDBD80001, 0x00000000,
+ 0xC000495A, 0xC8400000, 0x00000000, 0xC3C00002, 0x7BC42000, 0xCC400000, 0xC0001A1C, 0xCA000000,
+ 0xC2400008, 0x6A452000, 0x76610000, 0x84000EAA, 0xC0000A28, 0xC3800000, 0xCB840030, 0xC0000A14,
+ 0xC3400000, 0xCB440030, 0xC0004880, 0xCB040000, 0xB7B40052, 0x58041802, 0xCAC00000, 0xA7000058,
+ 0x00000000, 0x00000000, 0xA6C8D7E8, 0xC1000000, 0xC6D00020, 0xC0004980, 0x40100000, 0xCA800000,
+ 0x80000058, 0x00000000, 0x00000000, 0x00000000, 0x8000D7A0, 0x00000000, 0xC2800000, 0xC7282020,
+ 0xC000490E, 0xCA400000, 0x6BE9E000, 0x00000000, 0x77E52000, 0x8400D758, 0x6EA0A000, 0x6E944000,
+ 0x45610000, 0x46A10000, 0x5A204E20, 0x5820000C, 0xCA000000, 0xC0004946, 0xCE800000, 0xA6220388,
+ 0x00000000, 0xC2200060, 0xC0004948, 0xCE000010, 0xCE001040, 0xC240000A, 0xC000494A, 0xCE400000,
+ 0xC2B60002, 0xC0004964, 0xCE801B08, 0x99005E48, 0xC00048A0, 0xC8840000, 0x00000000, 0xC0004946,
+ 0xCBC00000, 0x00000000, 0x00000000, 0x6FF8A000, 0x6FD44000, 0x4579C000, 0x47F9C000, 0x5BB84E20,
+ 0x99005C08, 0xDBD80000, 0xDB980001, 0x00000000, 0x99005950, 0xC000491C, 0xC1400000, 0xC9420050,
+ 0xC000491C, 0x99005E00, 0xC9400001, 0xC9800000, 0x00000000, 0x99005B78, 0xD9580000, 0xD9980001,
+ 0x00000000, 0xC161FFFE, 0x5955FFFE, 0x15400000, 0x00000000, 0x99005840, 0xDBD80000, 0xDB980001,
+ 0xC7D80000, 0x00000000, 0xC121FFFE, 0x5911FE14, 0x15000000, 0x6FF8A000, 0x6FD44000, 0x4579C000,
+ 0x47F9C000, 0x5BB84E20, 0x58380010, 0xCA000000, 0xC0004874, 0xC8040000, 0x6C908000, 0x44908000,
+ 0x44908000, 0x40100000, 0xCA400000, 0xC4340000, 0x00000000, 0xC7400000, 0xCE000000, 0xC161FFFE,
+ 0x5955FFFE, 0x15400000, 0x00000000, 0xC000490E, 0xCA400000, 0xC2800002, 0x6ABD4000, 0x72A52000,
+ 0xCE400000, 0x00000000, 0xC121FFFE, 0x5911FE14, 0x15000000, 0x990062F0, 0xC0004836, 0xC9400000,
+ 0xC1800002, 0x00000000, 0x00000000, 0x00000000, 0xA8E2FFC8, 0x00000000, 0x58380000, 0xC9000000,
+ 0xC00049A0, 0xCA000000, 0xC2800000, 0xC5290040, 0x72A10000, 0xCE000000, 0xC1220002, 0xD90C0000,
+ 0xC2000000, 0xC0000A14, 0xCA040030, 0xC0000A28, 0xC2500002, 0xCE440808, 0x58880002, 0xB608FFF8,
+ 0xC00048A0, 0xC0800000, 0xCC840000, 0x8000D368, 0xC0004946, 0xCBC00000, 0xC161FFFE, 0x5955FFFE,
+ 0x15400000, 0x00000000, 0xC000490E, 0xCA400000, 0xC2800002, 0x6ABD4000, 0x72A52000, 0xCE400000,
+ 0x00000000, 0xC121FFFE, 0x5911FE14, 0x15000000, 0x6FF8A000, 0x6FD44000, 0x4579C000, 0x47F9C000,
+ 0x5BB84E20, 0x58380008, 0xCA000000, 0x5838000C, 0xCA400000, 0xC3400000, 0xC6340008, 0xC000494E,
+ 0xCF400000, 0xC2800000, 0xC62A0080, 0xC3000000, 0xC6308020, 0x6F304000, 0x43298000, 0xC000493C,
+ 0xCF000000, 0xC2C00000, 0xC66C0080, 0xC0004950, 0xCEC00000, 0xC2800000, 0xC66AE028, 0xC0004954,
+ 0xCE800000, 0x5F740000, 0x84000188, 0x5E300028, 0x462D2000, 0x84000152, 0x462D2000, 0x8800011A,
+ 0x5E300018, 0x462D2000, 0x88000012, 0x462D2000, 0x8400002A, 0x00000000, 0x800000A8, 0x00000000,
+ 0x99005F88, 0xDBD80000, 0xDB980001, 0xC7800000, 0xC3400002, 0xC000494E, 0xCF400000, 0xC161FFFE,
+ 0x5955FFFE, 0x15400000, 0x00000000, 0xC000490E, 0xCA400000, 0xC2800002, 0x6ABD4000, 0x7E814000,
+ 0x76A52000, 0xCE400000, 0x00000000, 0xC121FFFE, 0x5911FE14, 0x15000000, 0xC2200060, 0xC0004948,
+ 0xCE001040, 0xC2000000, 0xC000494C, 0xCE000000, 0x80000068, 0x00000000, 0x99005F88, 0xDBD80000,
+ 0xDB980001, 0xC7800000, 0x99006188, 0xDBD80000, 0xDB980001, 0xC7800000, 0xC2200058, 0xC0004948,
+ 0xCE001040, 0xC2000002, 0xC000494C, 0xCE000000, 0xC2000006, 0xC0001006, 0xCE000000, 0x5838000A,
+ 0xCA400000, 0xC2200982, 0x5A203B6E, 0xC0001008, 0xCE000000, 0xC000100A, 0xCE400000, 0xC0004954,
+ 0xCA800000, 0xC200000C, 0xC000494A, 0xCE000000, 0xC0004948, 0xCE800010, 0xC2B60000, 0xC0004964,
+ 0xCE800000, 0x99005E48, 0xC00048A0, 0xC8840000, 0x00000000, 0xC0004946, 0xCBC00000, 0xC000494C,
+ 0xCA000000, 0x6FF8A000, 0x6FD44000, 0x4579C000, 0x47F9C000, 0x5BB84E20, 0x5E200000, 0x840000E2,
+ 0x00000000, 0x99005C08, 0xDBD80000, 0xDB980001, 0x00000000, 0x99005950, 0xC000491C, 0xC1400000,
+ 0xC9420050, 0xC000491C, 0x99005E00, 0xC9400001, 0xC9800000, 0x00000000, 0x99005B78, 0xD9580000,
+ 0xD9980001, 0x00000000, 0xC161FFFE, 0x5955FFFE, 0x15400000, 0x00000000, 0x99005840, 0xDBD80000,
+ 0xDB980001, 0xC7D80000, 0x00000000, 0xC121FFFE, 0x5911FE14, 0x15000000, 0xC000493C, 0xCA800000,
+ 0xC000494E, 0xCAC00000, 0xC3000018, 0xC3400006, 0x5E200000, 0x84000012, 0xC2800000, 0xC2C00000,
+ 0xC300001E, 0xC3400000, 0xC6AC1080, 0xC72C0420, 0xC76C0818, 0x58380010, 0xCA800000, 0x58380008,
+ 0xCEC00000, 0xC6280108, 0xC0004874, 0xC8040000, 0x6C908000, 0x44908000, 0x44908000, 0x40100000,
+ 0xCB000000, 0xC4340000, 0x00000000, 0xC7400000, 0xCE800000, 0xC0004952, 0xCE800000, 0x00000000,
+ 0x00000000, 0x00000000, 0xA8E2FFC8, 0x00000000, 0xC000494C, 0xCA000000, 0xC0004950, 0xCAC00000,
+ 0x5E200000, 0x84000052, 0xDFE80000, 0x7E814000, 0x5834001A, 0xCE800000, 0x990062F0, 0xC0004834,
+ 0xC9400000, 0xC1800002, 0x990062F0, 0xC0004838, 0xC9400000, 0xC6D80000, 0xC1220002, 0xD90C0000,
+ 0x5E200000, 0x84000028, 0x5838002C, 0xCB000000, 0xDFE80000, 0x00000000, 0x58380014, 0xCF000000,
+ 0x80000040, 0xC2A1FFFE, 0x5AA9FFFE, 0x58380000, 0xC9000000, 0xC00049A0, 0xCB000000, 0xC2C00000,
+ 0xC52D0040, 0x72F18000, 0xCF000000, 0x5838000A, 0xCE800000, 0xC3000000, 0xC0000A14, 0xCB040030,
+ 0xC2D00002, 0xC0000A28, 0xCEC40808, 0xC000494E, 0xCA800000, 0x58880002, 0xB4B0FFF8, 0xC00048A0,
+ 0xC0800000, 0xCC840000, 0x5EA80000, 0x84000162, 0x5E200000, 0x84000150, 0xC000493C, 0xCA800000,
+ 0x00000000, 0x00000000, 0x5AA80060, 0xCE800000, 0x99005F88, 0xDBD80000, 0xDB980001, 0xC7800000,
+ 0x99006188, 0xDBD80000, 0xDB980001, 0xC7800000, 0x58380000, 0xCAC00000, 0x00000000, 0xC2000000,
+ 0xC6E04020, 0xC0004952, 0xCAC00000, 0x58380000, 0xCA800000, 0xC30C0002, 0xC6300020, 0xA6800078,
+ 0x00000000, 0x00000000, 0xC161FFFE, 0x5955FFFE, 0x15400000, 0x00000000, 0xC0001800, 0xCA000000,
+ 0x00000000, 0x00000000, 0xA60CFFCA, 0xC6F00508, 0xC6B0C408, 0xCF000000, 0x00000000, 0xC121FFFE,
+ 0x5911FE14, 0x15000000, 0x8000C9B0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8000C948,
+ 0xDCBC0001, 0x5FFC0000, 0x8400003A, 0xC3800002, 0xDB880001, 0x5FFC0004, 0x8400C27A, 0xC3800000,
+ 0xDB880001, 0xC3CE0002, 0xC0000800, 0xCFC00708, 0xC3E1FFFE, 0x597DFFFE, 0x593DFE14, 0x94000001,
+ 0x00000000, 0x00000000, 0x00000000, 0xC000487C, 0xC8040000, 0x00000000, 0x00000000, 0x40080000,
+ 0xCBC00000, 0xC4380000, 0x00000000, 0xC000480E, 0xCA000000, 0xC0004858, 0xCB440000, 0x00000000,
+ 0x00000000, 0x46350000, 0x88000098, 0x00000000, 0xA7C00028, 0xC0004854, 0xC1000002, 0xCD040000,
+ 0xC11C0000, 0xC000082C, 0xCD040E08, 0x800000C0, 0x00000000, 0xA7D20118, 0x00000000, 0xC7E14048,
+ 0xC2400000, 0xC6246030, 0xC200006A, 0x46610000, 0xC6240038, 0xC0000810, 0xCE440038, 0x8000FF58,
+ 0xC2000000, 0xC0000808, 0xCA040018, 0xC11C0000, 0xC000082C, 0xCD040E08, 0x5A200002, 0x5E600010,
+ 0x8400FFF8, 0xC2000000, 0xC0000808, 0xCE040018, 0xC3400000, 0x80000010, 0xC1200002, 0xC0000818,
+ 0xCD041008, 0x5B740002, 0xC0004858, 0xCF440000, 0x99005590, 0xC0004848, 0xC9440000, 0xC1800000,
+ 0xC11C0002, 0xC000082C, 0xCD040E08, 0x800005E8, 0x5B740002, 0xC0004858, 0xCF440000, 0xC7800000,
+ 0xC13C0002, 0xCD001E08, 0xC0004848, 0xC9440000, 0xC1800000, 0xC000082C, 0xC9840030, 0x59540002,
+ 0xC0004848, 0xCD440000, 0x58880002, 0xB4980560, 0x00000000, 0xC0800000, 0x80000550, 0xC000487C,
+ 0xC8040000, 0x00000000, 0x00000000, 0x40080000, 0xCBC00000, 0xC4280000, 0x00000000, 0xA7C00110,
+ 0xC000484C, 0xCA040000, 0xC2400000, 0xC0001AEC, 0xCA440020, 0x5A200002, 0xC000484C, 0xCE040000,
+ 0xB624006A, 0xC6800000, 0xC13C0002, 0xCD001E08, 0xC0004848, 0xC9440000, 0xC1800000, 0xC000082C,
+ 0xC9840030, 0x59540002, 0xC0004848, 0xCD440000, 0x58880002, 0xB4980450, 0x00000000, 0xC0800000,
+ 0x80000440, 0xC0004854, 0xC1000004, 0xCD040000, 0xC0000820, 0xC2000002, 0xCE040000, 0xC2000000,
+ 0xC000484C, 0xCE040000, 0xC0004858, 0xCE040000, 0x8000FF10, 0xC0004854, 0xC1000000, 0xCD040000,
+ 0xC11C0000, 0xC000082C, 0xCD040E08, 0x99005590, 0xC0004848, 0xC9440000, 0xC1800000, 0xC1200000,
+ 0xC0000818, 0xCD041008, 0xC11C0002, 0xC000082C, 0xCD040E08, 0xC2000000, 0xC000484C, 0xCE040000,
+ 0x80000340, 0xC0001AC0, 0xCB840000, 0xC000487C, 0xC8040000, 0x00000000, 0x00000000, 0x40080000,
+ 0xCBC00000, 0xC4280000, 0x00000000, 0x00000000, 0xC6800000, 0xC13C0000, 0xCD001E08, 0xA780022A,
+ 0x00000000, 0x00000000, 0xA7C001EA, 0x00000000, 0xC0001B00, 0xC2060006, 0xCE040310, 0xA7E801A2,
+ 0x00000000, 0xC0004850, 0xCA040000, 0xC2400000, 0xC0001AEC, 0xCA448020, 0x5A200002, 0xC0004850,
+ 0xCE040000, 0xB624008A, 0x00000000, 0xC6800000, 0xC13C0002, 0xCD001E08, 0xC0001ACC, 0xC2000002,
+ 0xCE040008, 0xC0004848, 0xC9440000, 0xC1800000, 0xC000082C, 0xC9840030, 0x59540002, 0xC0004848,
+ 0xCD440000, 0x58880002, 0xB49801A8, 0x00000000, 0xC0800000, 0x80000198, 0xC0004854, 0xC1000000,
+ 0xCD040000, 0xC11C0000, 0xC000082C, 0xCD040E08, 0x99005590, 0xC0004848, 0xC9440000, 0xC1800000,
+ 0xC2000000, 0xC0000820, 0xCE040000, 0xC1200000, 0xC0000818, 0xCD041008, 0xC11C0002, 0xC000082C,
+ 0xCD040E08, 0xC0004850, 0xCE040000, 0xC2000002, 0xC0001ACC, 0xCE040010, 0x800000D0, 0xC2000002,
+ 0xC0004850, 0xCE040000, 0x8000FE70, 0xC2000000, 0xC0004850, 0xCE040000, 0xA7E60012, 0x00000000,
+ 0xC2000002, 0xC0001B00, 0xCE040008, 0x8000FE58, 0x00000000, 0xA7860032, 0x00000000, 0xC6800000,
+ 0xC13C0002, 0xCD001E08, 0xC2020002, 0xC7E2A548, 0xC0001B00, 0xCE040000, 0x8000FE00, 0xC2040002,
+ 0xC0001B00, 0xCE040208, 0x8000FDE0, 0xC2C80002, 0x6AC56000, 0xDACC0000, 0xC0004854, 0xCB440000,
+ 0xC0004848, 0xCB840000, 0xC0000838, 0xC3C00000, 0xCBC40030, 0x5EF40004, 0x8400000A, 0xC3000000,
+ 0xC0001ACC, 0xCF040108, 0x47BD8000, 0x84000012, 0x47BD8000, 0x88000018, 0xC1006E8C, 0x8000B6B0,
+ 0xC0004840, 0xCC840000, 0x8000F698, 0xC0001AC0, 0xCAC40000, 0xC0004854, 0xCB440000, 0xA6C0FBB2,
+ 0x00000000, 0x5EF40000, 0x8400F6F2, 0x5EF40002, 0x8400F982, 0x5EF40004, 0x8400FB82, 0xC1006CE8,
+ 0x8000B628, 0x00000000, 0xC0800000, 0xDF4B0040, 0xC0004900, 0xCB800000, 0xC2000000, 0xC000490A,
+ 0xA78000B0, 0xCBC00000, 0xC1000000, 0xD9000001, 0xC1000002, 0xD90C0000, 0x6FF46000, 0x47F5A000,
+ 0x5B744C80, 0xC2400000, 0x58340004, 0xCA400080, 0xC0004900, 0xCE000008, 0x5A640002, 0x58340004,
+ 0xC6500080, 0xCD000080, 0xC0004914, 0xCA400000, 0xC2000002, 0x6A3D0000, 0x72252000, 0xCE400000,
+ 0xC0000408, 0xCE000000, 0xA78200B8, 0xC0004908, 0xCBC00000, 0xC1000000, 0xD9000001, 0xC1000002,
+ 0xD90C0000, 0x6FF4A000, 0x6FD44000, 0x4575A000, 0x47F5A000, 0x5B744E20, 0xC2800000, 0x58340006,
+ 0xCA800080, 0xC2000000, 0xC0004900, 0xCE000108, 0x5EA80002, 0x58340006, 0xC6900080, 0xCD000080,
+ 0x5A7C0020, 0xC2000002, 0x6A250000, 0xC0000408, 0xCE000000, 0xDCA80001, 0x5EA80000, 0x8400B498,
+ 0x00000000, 0xA4800210, 0x00000000, 0xC3C00000, 0xC000140E, 0xCBC00020, 0xC3400000, 0xC2400000,
+ 0x6FF86000, 0x47F9C000, 0x5BB84C80, 0x58380008, 0xCB400080, 0x58380006, 0xCA400080, 0x5F740002,
+ 0x58380008, 0xC7500080, 0xCD000080, 0xC2000000, 0x58380004, 0xCA020080, 0xC3000000, 0x5838000C,
+ 0xCB000028, 0x5A640002, 0x46250000, 0x8400FFF8, 0xC2400000, 0x58380006, 0xC6500080, 0xCD000080,
+ 0xC2000000, 0x5838000A, 0xCA020080, 0x5B300002, 0x5838000C, 0xC7100028, 0xCD000028, 0xC2420020,
+ 0x5A200004, 0x46612000, 0x8400FFF8, 0xC2000000, 0x5838000A, 0xC6101080, 0xCD001080, 0xC0004966,
+ 0xCA400000, 0xC2000002, 0x6A3D0000, 0x72252000, 0xCE400000, 0x5F740000, 0x84000028, 0xC0004912,
+ 0xCA000000, 0xC2C00002, 0x6AFD6000, 0x7EC16000, 0x76E10000, 0xCE000000, 0x5F300020, 0x84000028,
+ 0xC0004924, 0xCA000000, 0xC2C00002, 0x6AFD6000, 0x7EC16000, 0x76E10000, 0xCE000000, 0xA4820050,
+ 0xC2400000, 0xC000140E, 0xCA408020, 0xC2000002, 0xC0004900, 0xCE000008, 0xC000490A, 0xCE400000,
+ 0xC1000000, 0xD9000001, 0xD8400080, 0xC1000004, 0xD9000001, 0xA4840250, 0x00000000, 0xC3C00000,
+ 0xC000140E, 0xCBC10020, 0xC2800000, 0xC2000000, 0x6FF8A000, 0x6FD44000, 0x4579C000, 0x47F9C000,
+ 0x5BB84E20, 0x5838002E, 0xCA800080, 0x58380006, 0xCA020080, 0xC3400000, 0x5838002E, 0xCB420080,
+ 0x5AA80002, 0x46290000, 0x8400FFF8, 0xC2800000, 0x5838002E, 0xC6900080, 0xCD000080, 0x5F740002,
+ 0x5838002E, 0xC7501080, 0xCD001080, 0xC0004968, 0xCA400000, 0xC2000002, 0x6A3D0000, 0x72252000,
+ 0xCE400000, 0xC000492A, 0xCA800000, 0x5E740000, 0x84000028, 0xC0004910, 0xCA000000, 0xC2C00002,
+ 0x6AFD6000, 0x7EC16000, 0x76E10000, 0xCE000000, 0x6ABD4010, 0xA680009A, 0x00000000, 0x58380032,
+ 0xCA000000, 0x58000002, 0xCA400000, 0x5838000C, 0x00000000, 0xCE000001, 0xCE400000, 0xC000492A,
+ 0xCA000000, 0xC2C00002, 0x6AFD6000, 0x72E10000, 0xCE000000, 0xC000492C, 0xCA000000, 0xC2C00002,
+ 0x6AFD6000, 0x72E10000, 0xCE000000, 0x80000028, 0xC000492C, 0xCA000000, 0xC2C00002, 0x6AFD6000,
+ 0x7EC16000, 0x76E10000, 0xCE000000, 0xA4880128, 0xC2C00000, 0xC000140E, 0xCAC20020, 0xC000490E,
+ 0xCA400000, 0xC2000002, 0x6A2D0000, 0x7E010000, 0x76252000, 0xCE400000, 0xC000496A, 0xCA400000,
+ 0xC2000002, 0x6A2D0000, 0x72252000, 0xCE400000, 0x6EF0A000, 0x6ED44000, 0x45718000, 0x46F18000,
+ 0x5B304E20, 0x58300000, 0xCA000000, 0x00000000, 0xC2400002, 0x76252000, 0x8400005A, 0x58300000,
+ 0xCA400000, 0xC2800000, 0x00000000, 0xC6684020, 0xC24C0002, 0xC6A40020, 0xC624C408, 0x58300010,
+ 0xCA400508, 0x00000000, 0xC0001800, 0xCE400000, 0xA4860050, 0xC2400000, 0xC000140E, 0xCA418020,
+ 0xC2020002, 0xC0004900, 0xCE000108, 0xC0004908, 0xCE400000, 0xC1000000, 0xD9000001, 0xD8400080,
+ 0xC1000004, 0xD9000001, 0xC0001408, 0xCC800000, 0xC10E0002, 0xD90C0000, 0x8000ED98, 0xDFBC0001,
+ 0xC000496E, 0x99006298, 0xC9400000, 0xC7D80000, 0x00000000, 0xC5700000, 0x5EF00020, 0x88000130,
+ 0x6F346000, 0x4735A000, 0x5B744C80, 0x58340008, 0xC2400000, 0xCA400080, 0x00000000, 0xC2000000,
+ 0x5A640002, 0xCE400080, 0x58340004, 0xCA000080, 0x00000000, 0x00000000, 0x5E200002, 0xCE000080,
+ 0xC0004912, 0xCA800000, 0xC2400002, 0x6A712000, 0x72694000, 0xCE800000, 0x5E200000, 0x8400003A,
+ 0xC000480A, 0xCA000000, 0xC0000408, 0xCA800000, 0x76610000, 0x00000000, 0x72294000, 0xCE800000,
+ 0x80000020, 0xC0004914, 0xCA000000, 0x7E412000, 0x00000000, 0x76610000, 0xCE000000, 0x800000B8,
+ 0x6EF4A000, 0x6ED44000, 0x4575A000, 0x46F5A000, 0x5B744E20, 0x5834002E, 0xC2400000, 0xCA420080,
+ 0x00000000, 0xC2000000, 0x5A640002, 0xC6501080, 0xCD001080, 0x58340006, 0xCA000080, 0x00000000,
+ 0x00000000, 0x5A200002, 0xCE000080, 0xC0004910, 0xCA400000, 0xC2000002, 0x6A2D0000, 0x72252000,
+ 0xCE400000, 0xC2000002, 0x6A310000, 0xC000042A, 0xCE000000, 0xC1040002, 0xD90C0000, 0x00000000,
+ 0x8000EB08, 0x00000000, 0xC4980930, 0x9D000000, 0xC5580030, 0xC0000838, 0xCD840000, 0xC1440200,
+ 0xC1C03200, 0xC55C1078, 0xC000100E, 0x9D000000, 0xCD800000, 0xC000100C, 0xCDC00000, 0xC0004862,
+ 0xC9C00000, 0x00000000, 0x00000000, 0xD9D80001, 0xC0007200, 0x401C0000, 0x5DC07400, 0x8800FFFA,
+ 0x5C000200, 0xCD800000, 0xC1F0000A, 0x71D4A000, 0xDD980000, 0xDD9C0001, 0x41D8E000, 0xC5D40268,
+ 0xC0001010, 0xCD400000, 0x6C9C8000, 0x449CE000, 0x449CE000, 0x59DC0004, 0xC1601260, 0xC5D40268,
+ 0x9D000000, 0xC0001012, 0xCD400000, 0x00000000, 0x00000000, 0xD9580000, 0x6D586000, 0x4558C000,
+ 0x59984C80, 0xD9980001, 0x5818000A, 0xC1800000, 0xC9800080, 0xC0005400, 0x6D5CA000, 0x401C0000,
+ 0x40180000, 0xC9400000, 0x58000002, 0x00000000, 0xC9C00000, 0xC0004930, 0xCD400000, 0xC0004932,
+ 0xCDC00000, 0x59980004, 0xC1C20020, 0xB59CFFF8, 0x00000000, 0xC1800000, 0xDD9C0001, 0x581C000A,
+ 0xCD800080, 0x581C000C, 0xC1800000, 0xC9800028, 0xC1C00002, 0xDD940000, 0x69D4E000, 0x5D980002,
+ 0xCD800028, 0xC0004924, 0xC9800000, 0x00000000, 0x9D000000, 0x00000000, 0x71D8C000, 0xCD800000,
+ 0xC000492A, 0xC9400000, 0xC1C00002, 0x69D8E000, 0x7DC0C000, 0x7594A000, 0xCD400000, 0xC000492C,
+ 0xC9400000, 0xDD800001, 0x58000032, 0x75D4A000, 0x84000078, 0xC9400001, 0xC9800000, 0xDD800001,
+ 0x5800000C, 0x00000000, 0xCD400001, 0xCD800000, 0xC000492C, 0xC9400000, 0xC000492A, 0xC9800000,
+ 0x71D4A000, 0xC000492C, 0xCD400000, 0x71D8C000, 0xC000492A, 0xCD800000, 0x9D000000, 0x00000000,
+ 0x00000000, 0x00000000, 0xC0004862, 0xC9800000, 0x00000000, 0xC1C00200, 0x4194C000, 0x45D8E000,
+ 0x8800FFFA, 0xC5D80000, 0xC0004862, 0xCD800000, 0xC0001406, 0xC9800000, 0xC1C00002, 0x9D000000,
+ 0xC5D80A08, 0xC5581050, 0xCD800000, 0xC0004930, 0xC9800000, 0xC0004932, 0xC9C00000, 0xC140000E,
+ 0xC5581C20, 0xDD940000, 0xC0007200, 0x40140000, 0x5D407400, 0x8800FFFA, 0x5C000200, 0xCD800000,
+ 0x58000002, 0x5D407400, 0x8800FFFA, 0x5C000200, 0xCDC00000, 0xDD540000, 0xC1C00000, 0x58140006,
+ 0xC9C20080, 0xC1800000, 0x58140000, 0xC98000E0, 0x6DDC2000, 0xC000491E, 0x41D8E000, 0xCDC00000,
+ 0xDD980000, 0xC1C00022, 0xC5D80D78, 0xDD940001, 0xC5581C20, 0xC000491C, 0xCD800000, 0xDD540000,
+ 0xC1C00000, 0x58140006, 0xC9C20080, 0xC1800000, 0x58140004, 0xC9820080, 0x00000000, 0x59DC0002,
+ 0x459CC000, 0x8400FFF8, 0xC1C00000, 0x9D000000, 0x58140006, 0xC5D81080, 0xCD801080, 0xC0004860,
+ 0xC9400000, 0xC1820080, 0xC1D00002, 0x58146B00, 0xD5800000, 0x58000002, 0xD5800001, 0x59540004,
+ 0xB558FFF8, 0xC0004860, 0xC1400000, 0xCD400000, 0xDD980001, 0x9D000000, 0xDD940000, 0xC0001404,
+ 0xCDC00808, 0xC1C00000, 0xC1800200, 0x5D980004, 0xDF5D0050, 0x45D8A000, 0x8800FFDA, 0xDD800001,
+ 0x5800000C, 0x00000000, 0xC9400001, 0xC9800000, 0xC1C00002, 0xC5D43F08, 0xC5D81E08, 0xC0004862,
+ 0xC9C00000, 0x00000000, 0x00000000, 0x581C7200, 0x5DC07400, 0x8800FFFA, 0x5C000200, 0xCD400000,
+ 0x58000002, 0x5DC07400, 0x8800FFFA, 0x5C000200, 0xCD800000, 0xC0004862, 0xC9C00000, 0x00000000,
+ 0xC15004C0, 0xC5D40068, 0xDD9C0000, 0xC5D41C20, 0xC1C00000, 0xDD800001, 0x58000030, 0xC9C00080,
+ 0xDD800001, 0x58000002, 0xC9800000, 0x6DDC2000, 0xC000491C, 0x41D8E000, 0xCD400001, 0xCDC00000,
+ 0xDD940001, 0xC1C00000, 0x58140030, 0xC9C00080, 0xC1800000, 0x58140006, 0xC9820080, 0x00000000,
+ 0x59DC0002, 0x459CC000, 0x8400FFF8, 0xC1C00000, 0x9D000000, 0x58140030, 0xC5D80080, 0xCD800080,
+ 0xC1C00000, 0xDF5C0040, 0x5DDC0080, 0x8400FFD2, 0x00000000, 0x9D000000, 0x00000000, 0x00000000,
+ 0x00000000, 0xC160FFFE, 0xC0000A10, 0xC9440068, 0xC1A0FFFE, 0x59980E28, 0xC000100C, 0xCD400000,
+ 0xC000100E, 0xCD800000, 0xC0004964, 0xC9800000, 0x00000000, 0xC170000A, 0x7194A000, 0x6C988000,
+ 0x4498C000, 0x4498C000, 0x59980004, 0xC5940278, 0xC0001010, 0xCD400000, 0xC0004946, 0xC9400000,
+ 0x00000000, 0x00000000, 0x6D58A000, 0x6D5C4000, 0x45D8C000, 0x4558C000, 0xC000494A, 0xC9400000,
+ 0xC0004948, 0xC9C00000, 0x4194C000, 0xC1400012, 0xC55C1820, 0x9D000000, 0xC59C0270, 0xC0001012,
+ 0xCDC00000, 0xC1400000, 0x58000012, 0xC9410040, 0xC0004950, 0xC9C00000, 0xC5580000, 0xC5940840,
+ 0xC5581080, 0xD9940000, 0xC000493C, 0xC9400000, 0xC0004954, 0xC9800000, 0x59DC00A8, 0x455CE000,
+ 0x41D8E000, 0x5D5C0030, 0x8800FFF8, 0xC1C00030, 0xC1800000, 0xC5D84030, 0xC1400000, 0xC5D40010,
+ 0x5DD40002, 0x8400005A, 0x5DD40004, 0x84000082, 0x5DD40006, 0x840000AA, 0x5DD80026, 0x840000D2,
+ 0xDD540000, 0xDD800001, 0x58000008, 0x40180000, 0xCD400000, 0x59980002, 0x8000FFA8, 0xDD540000,
+ 0xDD800001, 0x58000008, 0x40180000, 0xCD4000C0, 0x59980002, 0x8000FF70, 0xDD540000, 0xDD800001,
+ 0x58000008, 0x40180000, 0xCD400080, 0x59980002, 0x8000FF38, 0xDD540000, 0xDD800001, 0x58000008,
+ 0x40180000, 0xCD400040, 0x59980002, 0x8000FF00, 0x00000000, 0x9D000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x58000012, 0xC9400000, 0xC0004954, 0xC9C00000, 0xC0004950, 0xC9400080, 0xDD800001,
+ 0x58000028, 0x5D9C0000, 0x8400003A, 0x5D9C0002, 0x8400003A, 0x5D9C0004, 0x84000052, 0xC55B0040,
+ 0xC55C08C0, 0xCD800041, 0xCDC008C0, 0x80000048, 0xCD400000, 0x80000038, 0xC55900C0, 0xC55C1840,
+ 0xCD8000C1, 0xCDC01840, 0x80000010, 0xC55A0080, 0xC55C1080, 0xCD800081, 0xCDC01080, 0x9D000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x59540002, 0x6994E018, 0x61C0C008, 0x4194A000, 0x5D940040,
+ 0x8800FFFA, 0xC5940000, 0x9D000000, 0xCD400000, 0x00000000, 0x00000000, 0x9D000000, 0x4158A000,
+ 0xCD400000, 0x00000000,
+};
+
+static unsigned int danube_fw_data[] = {
+};
+
+
+#endif // IFXMIPS_ATM_FW_DANUBE_H
diff --git a/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_fw_danube_retx.h.svn-base b/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_fw_danube_retx.h.svn-base
new file mode 100644
index 0000000..ff4e500
--- /dev/null
+++ b/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_fw_danube_retx.h.svn-base
@@ -0,0 +1,612 @@
+#ifndef IFXMIPS_ATM_FW_DANUBE_H
+#define IFXMIPS_ATM_FW_DANUBE_H
+
+
+/******************************************************************************
+**
+** FILE NAME : ifxmips_atm_fw_danube.h
+** PROJECT : Danube
+** MODULES : ATM (ADSL)
+**
+** DATE : 1 AUG 2005
+** AUTHOR : Xu Liang
+** DESCRIPTION : ATM Driver (PP32 Firmware)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 4 AUG 2005 Xu Liang Initiate Version
+** 23 OCT 2006 Xu Liang Add GPL header.
+*******************************************************************************/
+
+
+#define VER_IN_FIRMWARE 1
+
+#define ATM_FW_VER_MAJOR 0
+#define ATM_FW_VER_MINOR 15
+
+
+static unsigned int firmware_binary_code[] = {
+ 0x800004A0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8000FFC8, 0x00000000, 0x00000000, 0x00000000,
+ 0xC1000002, 0xD90C0000, 0xC2000002, 0xDA080001, 0xC0001B50, 0x8C100000, 0x00000000, 0x00000000,
+ 0x00000000, 0xC2000000, 0xDA080001, 0x80006018, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x80005FF0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC1001DA6, 0x8D3C0000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x80005EF0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC0400000, 0xC0004840, 0xC8840000, 0xC2001AEE, 0x8E100000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC0400002, 0xC0004840, 0xC8840000, 0xC2001AEE, 0x8E100000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC3C00004, 0xDBC80001, 0xC10C0002, 0xD90C0000, 0x8000FEC8, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC10E0002, 0xD90C0000, 0xC0004808, 0xC8400000, 0xC2001B4C, 0x8E100000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC3E1FFFE, 0x597DFFFE, 0x593DFE14, 0x900004D9, 0x00000000, 0x00000000, 0x00000000, 0x90CC0481,
+ 0x00000000, 0x00000000, 0x00000000, 0xC3E02252, 0x5BFC001E, 0xC0004002, 0xCFC00000, 0xC3C00000,
+ 0xDBC80001, 0xC1400008, 0xC1900000, 0x71948000, 0x15000100, 0xC140000A, 0xC1900002, 0x71948000,
+ 0x15000100, 0xC140000C, 0xC1900004, 0x71948000, 0x15000100, 0xC1400004, 0xC1900006, 0x71948000,
+ 0x15000100, 0xC1400006, 0xC1900008, 0x71948000, 0x15000100, 0xC140000E, 0xC190000A, 0x71948000,
+ 0x15000100, 0xC1400000, 0xC190000C, 0x71948000, 0x15000100, 0xC1400002, 0xC190000E, 0x71948000,
+ 0x15000100, 0xC0400000, 0xC11C0000, 0xC000082C, 0xCD040E08, 0xC11C0002, 0xC000082C, 0xCD040E08,
+ 0xC0400002, 0xC11C0000, 0xC000082C, 0xCD040E08, 0xC0000824, 0x00000000, 0xCBC00001, 0xCB800001,
+ 0xCB400001, 0xCB000000, 0xC0004878, 0x5BFC4000, 0xCFC00001, 0x5BB84000, 0xCF800001, 0x5B744000,
+ 0xCF400001, 0x5B304000, 0xCF000000, 0xC0000A10, 0x00000000, 0xCBC00001, 0xCB800000, 0xC0004874,
+ 0x5BFC4000, 0xCFC00001, 0x5BB84000, 0xCF800000, 0xC30001FE, 0xC000140A, 0xCF000000, 0xC3000000,
+ 0x7F018000, 0xC000042E, 0xCF000000, 0xC000040E, 0xCF000000, 0xC3C1FFFE, 0xC000490E, 0xCFC00080,
+ 0xC000492C, 0xCFC00080, 0xC0004924, 0xCFC00040, 0xC0004912, 0xCFC00040, 0xC0004966, 0xCFC00040,
+ 0xC0004968, 0xCFC00080, 0xC000496A, 0xCFC00080, 0xC3C00000, 0xC2800020, 0xC3000000, 0x7F018000,
+ 0x6FF88000, 0x6FD44000, 0x4395C000, 0x5BB84A00, 0x5838000A, 0xCF000000, 0x5BFC0002, 0xB7E8FFA8,
+ 0x00000000, 0xC3C00000, 0xC2800010, 0x6FF86000, 0x47F9C000, 0x5BB84C80, 0xC3400000, 0x58380004,
+ 0xCB420080, 0x00000000, 0x58380008, 0xCF400080, 0x5BFC0002, 0xB7E8FF90, 0x00000000, 0xC3C00000,
+ 0xC2800020, 0xC348001E, 0xC3000000, 0x7F018000, 0x6FF8A000, 0x6FD44000, 0x4579C000, 0x47F9C000,
+ 0x5BB84E20, 0x58380008, 0xCF400420, 0x5838000A, 0xCF000000, 0x5BFC0002, 0xB7E8FF90, 0x00000000,
+ 0x00000000, 0xC0004816, 0xC3C00000, 0xCBC00080, 0x00000000, 0x00000000, 0xC1000000, 0xD9040001,
+ 0xDBC40080, 0xC1000006, 0xD9040001, 0x00000000, 0xC121FFFE, 0x5911FE54, 0x15000000, 0xC3C00000,
+ 0xDCFC2008, 0x5FFC0002, 0x00000000, 0x98C08D62, 0xC0004730, 0xC9400000, 0xC0004732, 0xC0001AF2,
+ 0xCBC00000, 0x00000000, 0x00000000, 0xA7C20450, 0xC000474A, 0xCA800000, 0x00000000, 0x00000000,
+ 0x5D280000, 0x8400FFC8, 0x00000000, 0xC121FFFE, 0x5911FEF4, 0x15000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC2802000, 0x6EA8E010, 0xC0004200, 0xC2400000, 0x7E410000, 0xC1000000, 0xCE400001, 0xCE400001,
+ 0xCE400001, 0xCE400001, 0x5EA80002, 0x8400FFC0, 0xC0004300, 0xC2800200, 0x6EA84010, 0xCE400001,
+ 0xCE000001, 0xCE400001, 0xCE000001, 0xCE400001, 0xCE000001, 0xCE400001, 0xCE000001, 0x5EA80002,
+ 0x8400FFA0, 0xC0004700, 0xC2800200, 0x6EA8E010, 0xCE400001, 0xCE400001, 0xCE400001, 0xCE400001,
+ 0x5EA80002, 0x8400FFC0, 0xC0004740, 0xCE400000, 0xC0004742, 0xC1000200, 0x5D100002, 0xCD000000,
+ 0xC0004744, 0xCE400000, 0xC0004746, 0xCE400000, 0xC0004748, 0xCE400000, 0xC000474A, 0xCE400000,
+ 0xC000474C, 0xC1000002, 0xCD000000, 0xC000474E, 0xCE400000, 0xC0004750, 0xCE400000, 0xC0004752,
+ 0xCE400000, 0xC0004754, 0xCE400000, 0xC0400000, 0xC11C0000, 0xC000082C, 0xCD040E08, 0xC0000838,
+ 0xCE400000, 0xC0000818, 0xCE400000, 0xC0000820, 0xCE400000, 0xC2804840, 0xC240485A, 0x98C086B0,
+ 0xC6800000, 0xC6540000, 0xC1800000, 0xC11C0002, 0xC000082C, 0xCD040E08, 0x00000000, 0xC121FFFE,
+ 0x5911FE54, 0x15000000, 0xC0000A10, 0xCB800000, 0xC0000A12, 0xCB400000, 0xC0000A14, 0xCB000000,
+ 0xC0000A16, 0xCAC00000, 0xC0000040, 0xC2800000, 0xCE800008, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xC2800002,
+ 0xCE800008, 0xC0000A10, 0xCF800000, 0xC0000A12, 0xCF400000, 0xC0000A14, 0xCF000000, 0xC0000A16,
+ 0xCEC00000, 0xC1000000, 0xC00048A0, 0xCD000000, 0xC00048A2, 0xCD000000, 0xC0001AF2, 0xC1000000,
+ 0xCD000108, 0x80001020, 0x00000000, 0xC3C00000, 0xDCFC2008, 0x5FFC0002, 0x00000000, 0x98C08D62,
+ 0xC0004730, 0xC9400000, 0xC0004732, 0x800033C0, 0x00000000, 0xC3C00000, 0xDCFC2008, 0x5FFC0002,
+ 0x00000000, 0x98C08D62, 0xC0004730, 0xC9400000, 0xC0004732, 0xC0004810, 0xC9000000, 0xC000474A,
+ 0xC9400000, 0xA50007C8, 0x00000000, 0x5D140002, 0x840007BA, 0xC1000000, 0xC000484A, 0xC9000000,
+ 0xC0004740, 0xC8400000, 0x5D100000, 0x84000780, 0x00000000, 0x00000000, 0xC121FFFE, 0x5911FEF4,
+ 0x15000000, 0xC0004744, 0xC8800000, 0xC0001AF0, 0xC3000000, 0x58000002, 0xCB010040, 0x6C7C2000,
+ 0x5BFC4300, 0x98C08A88, 0xC1400000, 0xC4540028, 0x6C40A010, 0x5D240002, 0x84000202, 0x00000000,
+ 0xC0004742, 0xCA800000, 0x00000000, 0x00000000, 0x59280002, 0x6D130000, 0x6D130010, 0x44508000,
+ 0x8400067A, 0x00000000, 0x98C08870, 0xC4540000, 0xC6980000, 0xC241FFFE, 0xC6740000, 0x5D35FFFE,
+ 0x8400063A, 0x44748000, 0x8400062A, 0xC1000000, 0x6F502000, 0xC0004300, 0x40100000, 0xC1400000,
+ 0x58000000, 0xC9410040, 0xC1800000, 0xC0004814, 0xC9820040, 0x4570A000, 0xC10001FE, 0x4150A004,
+ 0x45948000, 0x880005B2, 0x4474C000, 0xC1000200, 0x4190C004, 0xC000473E, 0xC9000000, 0x00000000,
+ 0x00000000, 0x41188000, 0xCD000000, 0xC000471C, 0xC9000000, 0x00000000, 0x00000000, 0x41188000,
+ 0xCD000000, 0x98C087E8, 0xC4540000, 0x6C58A010, 0xC0004700, 0x58440002, 0x6C470000, 0x6C470010,
+ 0x47448000, 0x8400FFA8, 0xC7440000, 0xC0004740, 0xCC400000, 0xC0800000, 0xC0004744, 0xCC800000,
+ 0x800004B8, 0xC1000000, 0x583C0000, 0xC9000040, 0x00000000, 0x00000000, 0x45088000, 0x88000268,
+ 0xC1400000, 0x583C0000, 0xC9410040, 0xC1800000, 0xC0004814, 0xC9800040, 0x4570A000, 0xC10001FE,
+ 0x4150A004, 0x45948000, 0x8800042A, 0xC3800000, 0x583C0002, 0xCB820080, 0xC1000000, 0x583C0002,
+ 0xC9000080, 0x00000000, 0x00000000, 0x45388000, 0x84000232, 0xC0400002, 0xC0800000, 0xC3C00000,
+ 0xC000481A, 0xC8000000, 0x6F908000, 0x47908000, 0x47908000, 0x4011E000, 0xC000491E, 0xCFC00000,
+ 0xC3400000, 0xC0004878, 0xC8040000, 0x6C908000, 0x44908000, 0x44908000, 0x40100000, 0xCAC00000,
+ 0xC4300000, 0x00000000, 0xC7340068, 0xC1000002, 0xC5341B08, 0xC100001C, 0xC5341050, 0xC100000C,
+ 0xC5340D18, 0xC000491C, 0xCF400000, 0xC3000000, 0xDF700040, 0x5D300080, 0x8800FFD0, 0xC000474A,
+ 0xC1000002, 0xCD000000, 0xC000491C, 0xCB400000, 0xC000491E, 0xCBC00000, 0x99007F18, 0xDB580000,
+ 0xDBD80001, 0x00000000, 0xC1400000, 0xC794A038, 0xC1800000, 0xC7980028, 0x58144200, 0xC9C00000,
+ 0xC1210000, 0x69188010, 0x7D008000, 0x751CE000, 0xCDC00000, 0x80000210, 0x00000000, 0xC1000000,
+ 0x583C0000, 0xC903E008, 0x00000000, 0x00000000, 0x5D100000, 0x8400002A, 0xC0004734, 0xC9000000,
+ 0x00000000, 0x00000000, 0x59100002, 0xCD000000, 0x800000A8, 0xC1400000, 0x583C0000, 0xC9410040,
+ 0xC1800000, 0xC0004814, 0xC9820040, 0x4570A000, 0xC10001FE, 0x4150A004, 0x45948000, 0x88000142,
+ 0xC000473E, 0xC9000000, 0x00000000, 0x00000000, 0x59100002, 0xCD000000, 0xC000471C, 0xC9000000,
+ 0x00000000, 0x00000000, 0x59100002, 0xCD000000, 0xC3800000, 0x583C0002, 0xCB820080, 0x00000000,
+ 0x00000000, 0x5D39FFFE, 0x8400004A, 0xC1400000, 0xC794A038, 0xC1800000, 0xC7980028, 0x58144200,
+ 0xC9C00000, 0xC1210000, 0x69188010, 0x7D008000, 0x751CE000, 0xCDC00000, 0x98C087E8, 0xC4540000,
+ 0x6C58A010, 0xC0004700, 0x58440002, 0x6C470000, 0x6C470010, 0xC0004740, 0xCC400000, 0xC0800000,
+ 0xC0004744, 0xCC800000, 0x00000000, 0xC121FFFE, 0x5911FE54, 0x15000000, 0x8000F270, 0x00000000,
+ 0x00000000, 0x98C086F0, 0xC0004748, 0xC9800000, 0xC2000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0xC1400000, 0xC7D4A038, 0xC1800000, 0xC7D80028, 0x58144200,
+ 0xC9C00000, 0xC1210000, 0x69188010, 0x7D008000, 0x751CE000, 0xCDC00000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x98C087E8, 0xC7D40000, 0x6FD8A010, 0xC0004700, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x98C08870, 0xC7D40000, 0xC7980000, 0xC241FFFE, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x98C08A88, 0xC1400000, 0xC7D40028, 0x6FC0A010,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x98C08AB8, 0xC1400000, 0xC7D40028, 0x6FC0A010,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x98C08AF0, 0xC7D40000, 0xC0004740, 0xC9C00000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x98C08BE0, 0xC7D40000, 0xC0004742, 0xC9800000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xC0004958, 0xC8400000, 0x00000000, 0xC3C00002,
+ 0x7BC42000, 0xCC400000, 0xC0004848, 0xCB840000, 0xC000495C, 0xCAC40000, 0xC0004844, 0xC8840000,
+ 0x46F90000, 0x8400F47A, 0xC000487C, 0xC8040000, 0x00000000, 0x00000000, 0x40080000, 0xCA000000,
+ 0xC0001624, 0xCB040000, 0xA63C005A, 0x00000000, 0x00000000, 0xA71EF412, 0x00000000, 0xC0000824,
+ 0xCA840000, 0x6CA08000, 0x6CA42000, 0x46610000, 0x42290000, 0xC35E0002, 0xC6340068, 0xC0001624,
+ 0xCF440080, 0xC2000000, 0xC161FFFE, 0x5955FFFE, 0x15400000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0xC0004844, 0xC8840000, 0xC000082C, 0xCA040040, 0x00000000, 0x00000000, 0x58880002,
+ 0xB608FFF8, 0x00000000, 0xC0800000, 0xC0004844, 0xCC840040, 0x5AEC0002, 0xC000495C, 0xCEC40000,
+ 0x5E6C0006, 0x84000048, 0xC0004848, 0xCB840000, 0xC0000838, 0xC2500002, 0xCE440808, 0x5FB80002,
+ 0xC0004848, 0xCF840000, 0x5EEC0002, 0xC000495C, 0xCEC40000, 0x00000000, 0xC121FFFE, 0x5911FE54,
+ 0x15000000, 0x8000F278, 0xC000495A, 0xC8400000, 0x00000000, 0xC3C00002, 0x7BC42000, 0xCC400000,
+ 0xC0004960, 0xCAC40000, 0x00000000, 0x00000000, 0x5EEC0000, 0x840000F2, 0x00000000, 0xB6FC0030,
+ 0xC0001600, 0xCA040000, 0x00000000, 0x00000000, 0xA61E00B2, 0x6FE90000, 0xC0000A28, 0xCE840808,
+ 0xC2C00000, 0xC2800004, 0xB6E80080, 0xC0001604, 0xCA840000, 0xC0004960, 0xCEC40000, 0xA69EFC8A,
+ 0x00000000, 0x6FE90000, 0xC0000A28, 0xCE840808, 0xC2C00002, 0xC0001600, 0xCA040000, 0x00000000,
+ 0x00000000, 0xA61E000A, 0x6FE90000, 0xC0000A28, 0xCE840808, 0xC2C00000, 0xC0001604, 0xCA840000,
+ 0xC0004960, 0xCEC40000, 0xA69EFBF2, 0xC2400000, 0xC0000A14, 0xCA440030, 0x00000000, 0x00000000,
+ 0x46E52000, 0xA4400000, 0xC2800000, 0xDFEB0031, 0x8000FFF8, 0xDFEA0031, 0xB668EBEA, 0x00000000,
+ 0xC00048A0, 0xCB040000, 0xC0000A10, 0xCA840000, 0x6F208000, 0x6F242000, 0x46610000, 0x42A10000,
+ 0xC2400000, 0xC0000A14, 0xCA440030, 0xC35E0002, 0xC6340068, 0xC0001604, 0xCF440080, 0x5B300002,
+ 0xB670FFF8, 0x5AEC0002, 0xC3000000, 0xC00048A0, 0xCF040000, 0xC0004960, 0xCEC40000, 0x8000F018,
+ 0xC0004918, 0xD2800000, 0xC2000000, 0xDF600040, 0x5E600080, 0x8400028A, 0x00000000, 0xC161FFFE,
+ 0x5955FFFE, 0x15400000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xC000480A, 0xCA000000,
+ 0xC0004912, 0xCA400000, 0xC0004924, 0xCA800000, 0xC0004966, 0xCAC00000, 0x00000000, 0xC121FFFE,
+ 0x5911FE54, 0x15000000, 0x76610000, 0x76A10000, 0x76E10000, 0x840001CA, 0xC0004918, 0xCA400000,
+ 0xC28001FE, 0x76A10000, 0x5A640002, 0x6A254010, 0x5EE80000, 0x84000002, 0x6AA54000, 0x8000FFF8,
+ 0xC6280000, 0x62818008, 0xC0004918, 0xCF000000, 0xC161FFFE, 0x5955FFFE, 0x15400000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0xC0004966, 0xCA400000, 0xC2000002, 0x6A310000, 0x7E010000,
+ 0x76252000, 0xCE400000, 0x00000000, 0xC121FFFE, 0x5911FE54, 0x15000000, 0x6F346000, 0x4735A000,
+ 0x5B744C80, 0xC2800000, 0x58340006, 0xCA800080, 0xC2C00000, 0x58340000, 0xCAC000E0, 0xC2400000,
+ 0x5834000A, 0xCA420080, 0x6EA82000, 0x42E9E000, 0x6F2CA000, 0x42E56000, 0x5AEC1400, 0xC3990040,
+ 0xC7381C20, 0xC6F80068, 0x99007F18, 0xDB980000, 0xDBD80001, 0x00000000, 0xDEA00000, 0x47210000,
+ 0x8400FD38, 0xC0004958, 0xC8400000, 0x00000000, 0xC1000002, 0x79042000, 0xCC400000, 0xC0004848,
+ 0xCBC40000, 0xC0004844, 0xC8840000, 0x5FFC0000, 0x8400ECA2, 0xC0004740, 0xCB000000, 0xC0004744,
+ 0xCAC00000, 0x6F282000, 0x5AA84300, 0xC000487C, 0xC8040000, 0x00000000, 0x00000000, 0x40080000,
+ 0xCA400000, 0xC4000000, 0x00000000, 0xC0004878, 0xC8040000, 0x6C908000, 0x44908000, 0x44908000,
+ 0x40100000, 0xC9000000, 0xC4340000, 0x00000000, 0x5C440000, 0x8400008A, 0x00000000, 0xC00047D2,
+ 0xC9000000, 0x00000000, 0x00000000, 0x59100002, 0xCD000000, 0x58340002, 0xC9000080, 0x00000000,
+ 0x00000000, 0x58280002, 0x6D120000, 0xCD001080, 0x5AEC0002, 0xC0004744, 0xCEC00000, 0x80000618,
+ 0x00000000, 0xC00047C0, 0xC9000000, 0x00000000, 0x00000000, 0x59100002, 0xCD000000, 0xA67C0028,
+ 0xC00047C2, 0xC9000000, 0x00000000, 0x00000000, 0x59100002, 0xCD000000, 0x80001E00, 0x00000000,
+ 0xA6600022, 0xC00047C4, 0xC9000000, 0x00000000, 0x00000000, 0x59100002, 0xCD000000, 0x80000558,
+ 0xC00047C6, 0xC9000000, 0x00000000, 0x00000000, 0x59100002, 0xCD000000, 0xC3C00000, 0xC67D0040,
+ 0xC3800000, 0xC6780040, 0x473C8000, 0x84000090, 0x46F88000, 0x84000080, 0xC1000000, 0xC0004814,
+ 0xC9000040, 0x00000000, 0x00000000, 0x5D100000, 0x840000D8, 0x5AEC0002, 0xC0004744, 0xCEC00000,
+ 0xC00047CA, 0xC9000000, 0x00000000, 0x00000000, 0x59100002, 0xCD000000, 0x80000460, 0x00000000,
+ 0x98C08AF0, 0xC7D40000, 0xC0004740, 0xC9C00000, 0x5D240000, 0x84000052, 0x00000000, 0x98C087E8,
+ 0xC7D40000, 0x6FD8A010, 0xC0004700, 0xC00047C8, 0xC9000000, 0x00000000, 0x00000000, 0x59100002,
+ 0xCD000000, 0x80001C28, 0xC00047CC, 0xC9000000, 0x00000000, 0x00000000, 0x59100002, 0xCD000000,
+ 0x6FE82000, 0x5AA84300, 0x5D380000, 0x84000088, 0x00000000, 0x98C086F0, 0xC0004748, 0xC9800000,
+ 0xC2000000, 0x58280002, 0x6E520000, 0xCD001080, 0x58280002, 0xCE400080, 0x5D25FFFE, 0x84000028,
+ 0xC00047D0, 0xC9000000, 0x00000000, 0x00000000, 0x59100002, 0xCD000000, 0x800002B8, 0xC3000000,
+ 0x58280002, 0xCB000080, 0x00000000, 0x00000000, 0x5D31FFFE, 0x84000030, 0xC00047D0, 0xC9000000,
+ 0x00000000, 0x00000000, 0x59100002, 0xCD000000, 0x80000248, 0x00000000, 0x98C086F0, 0xC0004748,
+ 0xC9800000, 0xC2000000, 0x58340002, 0xC6500080, 0xC7D01040, 0xC7901840, 0xCD000000, 0x58280002,
+ 0xCE400080, 0xC3C00200, 0x5FFC001C, 0xC3800000, 0xDF790050, 0x00000000, 0x00000000, 0x47BC8000,
+ 0x8800FFC2, 0xC0004862, 0xCBC00000, 0xC0000000, 0xC76C0000, 0x5BBC7200, 0xC280001C, 0xCA6C0001,
+ 0x00000000, 0x00000000, 0xCE780001, 0xC1007400, 0x47908000, 0xC1007200, 0xC5380006, 0x5EA80002,
+ 0x8400FFA0, 0xC3800000, 0xC000481A, 0xC8000000, 0x6F108000, 0x47108000, 0x47108000, 0x4011C000,
+ 0xC000491E, 0xCF800000, 0xC2C00000, 0xC7EC0068, 0xC100001C, 0xC52C1050, 0xC100000A, 0xC52C0D18,
+ 0xC000491C, 0xCEC00000, 0x99007CF0, 0xC000491C, 0xC1400000, 0xC9420050, 0xC2800000, 0xDF680040,
+ 0x5D280080, 0x8800FFD0, 0xC000491C, 0xCAC00000, 0xC000491E, 0xCB800000, 0x99007F18, 0xDAD80000,
+ 0xDB980001, 0x00000000, 0xC00047CE, 0xC9000000, 0x00000000, 0x00000000, 0x59100002, 0xCD000000,
+ 0x00000000, 0x80001868, 0x00000000, 0x00000000, 0x00000000, 0xC0004878, 0xC8040000, 0x6C908000,
+ 0x44908000, 0x44908000, 0x40100000, 0xCA000000, 0xC4240000, 0x00000000, 0xC0004934, 0xCE000000,
+ 0xC2800002, 0xC4681C10, 0xC62821D8, 0xC6281E08, 0xC2600010, 0x5A650080, 0xC0004800, 0xCB400000,
+ 0xC2200400, 0x5A200040, 0xC7601048, 0xC0001220, 0xCE800000, 0xC0001200, 0xCE400000, 0xC0001202,
+ 0xCE000000, 0xC0001240, 0xCB400000, 0x00000000, 0x00000000, 0xA754FFC0, 0xC2000000, 0xC7600048,
+ 0xA7520022, 0x00000000, 0x00000000, 0x99008690, 0xC0004822, 0xC9400000, 0xC1800002, 0x800016F8,
+ 0x582040C0, 0xC2000000, 0xCA000020, 0xC2400000, 0xCA414008, 0xC2800000, 0xCA812008, 0xC2C00000,
+ 0xCAC20020, 0xC0004938, 0xCE000000, 0xC0004920, 0xCE400000, 0xC0004916, 0xCE800000, 0xC0004922,
+ 0xCEC00000, 0xA6400538, 0x00000000, 0xC0004938, 0xCBC00000, 0x00000000, 0xC3800000, 0x6FF48000,
+ 0x6FD44000, 0x4355A000, 0x5B744A00, 0x58340000, 0xCB802018, 0x00000000, 0xC2000000, 0x6FB46000,
+ 0x47B5A000, 0x5B744C80, 0x5834000C, 0xCA000028, 0xC000491A, 0xCF800000, 0x5E200000, 0x8400046A,
+ 0xC2000000, 0xDF610050, 0x5E6001E8, 0x8800FFD0, 0xC2000002, 0xC2400466, 0xC2A00000, 0x5AA80000,
+ 0xC0001006, 0xCE000000, 0xC0001008, 0xCE400000, 0xC000100A, 0xCE800000, 0x99007958, 0xC1A0FFFE,
+ 0xC0000824, 0xC9840068, 0xC0004934, 0xCA400000, 0xC2000000, 0xC2800002, 0x99007998, 0xDA980000,
+ 0xC6140000, 0xC6580000, 0xC161FFFE, 0x5955FFFE, 0x15400000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x99007A80, 0xC000491A, 0xC9400000, 0x00000000, 0x00000000, 0xC121FFFE, 0x5911FE54,
+ 0x15000000, 0xC0004922, 0xCA001120, 0xC3C00000, 0xC3800000, 0xC0004930, 0xCE001120, 0xC0004932,
+ 0xCBC000E0, 0xC2800000, 0xC000491E, 0xCFC00000, 0xC0004862, 0xCA800068, 0xC3A0001A, 0x5BB94000,
+ 0xC6B80068, 0xC000491C, 0xCF800000, 0x99007CF0, 0xC000491C, 0xC1400000, 0xC9420050, 0x00000000,
+ 0x00000000, 0x00000000, 0xA8E2FFC8, 0xC2000000, 0xC1220002, 0xD90C0000, 0xDF600040, 0x5E600080,
+ 0x8400FFDA, 0xC000491C, 0xCA000000, 0xC000491E, 0xCA400000, 0x00000000, 0x00000000, 0x99007F18,
+ 0xDA180000, 0xDA580001, 0x00000000, 0xC2000000, 0xDF610050, 0x5E6001FE, 0x8800FFD0, 0xC0004916,
+ 0xCA800000, 0xC2C00000, 0xDFEC0050, 0xC2400000, 0x46E52000, 0x84000032, 0x5EA80000, 0x84000022,
+ 0xC2600002, 0x99008690, 0xC000482E, 0xC9400000, 0xC1800002, 0x80000018, 0xC2600000, 0x99008690,
+ 0xC000482C, 0xC9400000, 0xC1800002, 0xC2000068, 0xC6240080, 0xC0004930, 0xCE400088, 0xC000491A,
+ 0xC9800000, 0xC0004862, 0xC9400000, 0x6D9C6000, 0x459CE000, 0x59DC4C80, 0x99007D78, 0xD9580000,
+ 0xD9980001, 0xD9D40000, 0x99007CF0, 0xC000491C, 0xC1400000, 0xC9420050, 0xC2000000, 0xDF600040,
+ 0x5E600080, 0x8400FFD2, 0x00000000, 0xC000491C, 0xCA000000, 0xC000491E, 0xCA400000, 0x00000000,
+ 0x00000000, 0x99007F18, 0xDA180000, 0xDA580001, 0x00000000, 0x80001148, 0x00000000, 0x99008690,
+ 0xC000482A, 0xC9400000, 0xC1800002, 0x80001118, 0xC0004938, 0xCBC00000, 0x00000000, 0x00000000,
+ 0x6FF88000, 0x6FD44000, 0x4395C000, 0x5BB84A00, 0x58380008, 0xCA000000, 0x00000000, 0x00000000,
+ 0xA600037A, 0x00000000, 0xC0004938, 0xCBC00000, 0xC3000000, 0x00000000, 0x6FF88000, 0x6FD44000,
+ 0x4395C000, 0x5BB84A00, 0x58380000, 0xCB002018, 0xC2000000, 0x58380008, 0xCA020080, 0x5838000C,
+ 0xCAC00000, 0x5838000E, 0xCA400000, 0xC000491A, 0xCF000000, 0xC0004930, 0xCEC00000, 0xC000493C,
+ 0xCE000000, 0xC0004932, 0xCE400000, 0x5E200000, 0x84000120, 0xC2800000, 0xA6FE00B2, 0x6F206000,
+ 0x47210000, 0x5A204C80, 0x5820000C, 0xCA800028, 0x00000000, 0x00000000, 0x5EA80000, 0x840001F2,
+ 0x00000000, 0xC161FFFE, 0x5955FFFE, 0x15400000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x99007A80, 0xC000491A, 0xC9400000, 0x00000000, 0x00000000, 0xC121FFFE, 0x5911FE54, 0x15000000,
+ 0xC0004930, 0xCAC00000, 0xC0004932, 0xCA400000, 0xC7EC1120, 0xC0004930, 0xCEC00000, 0x5838000C,
+ 0xCEC00000, 0x58000002, 0xCE400000, 0xC0004934, 0xCA000000, 0xC2400002, 0x6E642000, 0x6E642000,
+ 0x76252000, 0x84000012, 0xC2400002, 0x6E684000, 0x58380008, 0xCE800208, 0xA6000000, 0x6E682000,
+ 0x58380008, 0xCE800108, 0xC2400002, 0x6E642000, 0x76252000, 0x840000D2, 0x58380008, 0xCA000000,
+ 0xC2800000, 0xC2400000, 0xA60200A0, 0xDBA80000, 0x6F386000, 0x4739C000, 0x5BB84C80, 0x58380004,
+ 0xCA400080, 0x58380002, 0xCA800080, 0x00000000, 0xDEB80000, 0x46694000, 0x88000048, 0x00000000,
+ 0xC0004824, 0xCA000000, 0xC2400002, 0x6E640000, 0x5A200002, 0xCE000000, 0x58380008, 0xCE400008,
+ 0x80000000, 0x00000000, 0x80000030, 0xC0004934, 0xCA000000, 0x00000000, 0x00000000, 0xA6020CAA,
+ 0x00000000, 0x00000000, 0x80000CE0, 0xC2800000, 0xC2000200, 0xC240001A, 0xDF690050, 0x46A14000,
+ 0x46694000, 0x8800FFBA, 0xC2000006, 0xC2600982, 0x5A643B6E, 0x5838000A, 0xCA800000, 0xC0001006,
+ 0xCE000000, 0xC0001008, 0xCE400000, 0xC000100A, 0xCE800000, 0x99007958, 0xC1A0FFFE, 0xC0000824,
+ 0xC9840068, 0xC2000000, 0xC0004930, 0xCA02E010, 0x58380026, 0xCA400000, 0x00000000, 0xC2800000,
+ 0x99007998, 0xDA980000, 0xC6140000, 0xC6580000, 0xC0004934, 0xCA000000, 0x00000000, 0x00000000,
+ 0xA6020002, 0x00000000, 0x00000000, 0x80000300, 0xC0004938, 0xCBC00000, 0xC0004878, 0xC8040000,
+ 0x6C908000, 0x44908000, 0x44908000, 0x40100000, 0xCA000000, 0xC4240000, 0x00000000, 0x58240018,
+ 0xCA000000, 0x6FF88000, 0x6FD44000, 0x4395C000, 0x5BB84A00, 0xC3000000, 0xC3400002, 0xC2C00000,
+ 0xC62C0080, 0xC6270040, 0xC0004940, 0xCE400040, 0xC6260040, 0xC0004942, 0xCE400040, 0xC000493C,
+ 0xCA000000, 0x5EEC0000, 0x84000172, 0x5A6C0010, 0x46614000, 0x88000178, 0x5A600052, 0x466D4000,
+ 0x88000160, 0x58380006, 0xCA800000, 0xC0004940, 0xCA000000, 0xC2400000, 0xC6A70040, 0x7E412000,
+ 0x76252000, 0xC2000000, 0xC6A10040, 0x46610000, 0x84000120, 0xC0004942, 0xCA000000, 0xC2400000,
+ 0xC6A60040, 0x7E412000, 0x76252000, 0xC2000000, 0xC6A00040, 0x58380002, 0xCA800000, 0x46610000,
+ 0x840000D0, 0xC2400000, 0xC6A60080, 0x46E50000, 0x880000C2, 0xC2400000, 0xC6A40080, 0x58380008,
+ 0xCA800000, 0x466D0000, 0x880000A2, 0x00000000, 0xA682FFF8, 0x00000000, 0xC7700B08, 0xA6840078,
+ 0x00000000, 0xC7700A08, 0x80000068, 0xC7700208, 0xC000493C, 0xCAC00000, 0x80000048, 0xC7700308,
+ 0xC000493C, 0xCAC00000, 0x80000028, 0xC7700908, 0x80000018, 0xC7700808, 0x80000008, 0xC7700708,
+ 0x8000FFF8, 0xC7700508, 0xC0004944, 0xCF000000, 0xC000493E, 0xCEC00000, 0xC0004938, 0xCA400000,
+ 0xC000493C, 0xCB800000, 0xC000493E, 0xCB400000, 0xC3000000, 0x6E608000, 0x6E544000, 0x42150000,
+ 0x5A204A00, 0x5AA00008, 0x58200004, 0xCB000080, 0xC0004934, 0xCA000000, 0xC2400000, 0xC0004930,
+ 0xCA42E010, 0xC3C00018, 0xA6020078, 0x00000000, 0x43656000, 0x46F90000, 0x88000038, 0x47AD6000,
+ 0x6EE04010, 0x5BE00004, 0xC2000000, 0xC6E00010, 0x5E200000, 0x8400002A, 0x5BFC0002, 0x80000018,
+ 0xC3C00004, 0x5A2C0008, 0x46390000, 0x8800FFFA, 0x5FB80008, 0x6FE04000, 0x42390000, 0x46312000,
+ 0x88000050, 0xC2400000, 0xC0004930, 0xCA42E010, 0xC2060002, 0xC6800000, 0xCE000308, 0x6FE04000,
+ 0x4631C000, 0x5F700010, 0x4675A000, 0xC2000000, 0xC6340010, 0xC25A000A, 0xC000491A, 0xCA401C20,
+ 0xC2800000, 0xC0004932, 0xCA8000E0, 0xC0004862, 0xCA400068, 0x6FA04010, 0x42290000, 0xC000491E,
+ 0xCE000000, 0xC7E41050, 0xC000491C, 0xCE400000, 0x6FE04000, 0x43A1C000, 0xC000493C, 0xCF800000,
+ 0xC000493E, 0xCF400000, 0xC000493A, 0xCFC00000, 0x8000FFF0, 0x00000000, 0x00000000, 0x00000000,
+ 0xC2000000, 0xDCE00000, 0xA622FFB8, 0xC1220002, 0xD90C0000, 0xC0004938, 0xCBC00000, 0xC0004944,
+ 0xCB400000, 0xC0004862, 0xCB000000, 0xC0004934, 0xCA000000, 0x6FF88000, 0x6FD44000, 0x4395C000,
+ 0x5BB84A00, 0xA6020278, 0xC2400000, 0x58380008, 0xCA406008, 0xDFE80000, 0xC2218E08, 0x5A21BAF6,
+ 0x46294000, 0x8400000A, 0xC2080002, 0x7235A000, 0x80000040, 0x5E640000, 0x8400000A, 0xC20C0002,
+ 0x7235A000, 0x80000018, 0xC2000000, 0xC760E718, 0xC7604220, 0x5E200000, 0x8400028A, 0xC2200002,
+ 0xC0004930, 0xCE001008, 0x99008690, 0xC0004828, 0xC9400000, 0xC1800002, 0xC0004780, 0xC93C0000,
+ 0x00000000, 0x00000000, 0x59100002, 0xCD3C0000, 0x58380000, 0xCA000000, 0x00000000, 0x00000000,
+ 0xA6000112, 0xC0004940, 0xCA800000, 0xC0004942, 0xCA400000, 0xC7600080, 0xC6A01840, 0xC6601040,
+ 0xC000493A, 0xCA400000, 0xC0004934, 0xCA800000, 0xC0007200, 0x40300000, 0x40240000, 0x5C000004,
+ 0x5EC07400, 0x8800FFFA, 0x5C000200, 0xCE000000, 0x58000002, 0x5EC07400, 0x8800FFFA, 0x5C000200,
+ 0xCE800000, 0xC000493E, 0xCA000000, 0xC2400000, 0x5838000C, 0xCE400000, 0x99008690, 0xC0004830,
+ 0xC9400000, 0xC6180000, 0xC0004930, 0xC6100080, 0xCD000080, 0x80000090, 0xC2400002, 0x58380008,
+ 0xCE400008, 0xC0004944, 0xCF400000, 0x80000290, 0xC000493C, 0xCA400000, 0xDFE80000, 0x5A300018,
+ 0xC0007200, 0x40200000, 0xCA000000, 0x58380008, 0xC6501080, 0xCD001080, 0x5838000A, 0xCE800000,
+ 0x58380026, 0xCE000000, 0xC0004944, 0xCF400000, 0x99007CF0, 0xC000491C, 0xC1400000, 0xC9420050,
+ 0x80000050, 0x00000000, 0x99008690, 0xC0004826, 0xC9400000, 0xC1800002, 0xC0004760, 0xC93C0000,
+ 0x00000000, 0x00000000, 0x59100002, 0xCD3C0000, 0x8000FD90, 0xC2000000, 0xC2400080, 0xDF600040,
+ 0xB624FFCA, 0xC000491C, 0xCA400000, 0xC000491E, 0xCA800000, 0x99007F18, 0xDA580000, 0xDA980001,
+ 0x00000000, 0xC0004934, 0xCA000000, 0x00000000, 0xC2800000, 0xA6020140, 0xC2400004, 0xC2000200,
+ 0xDF690050, 0x46A14000, 0x46694000, 0x8800FFC2, 0x00000000, 0xC000491A, 0xC9800000, 0xC0004862,
+ 0xC9400000, 0x6D9C6000, 0x459CE000, 0x59DC4C80, 0x99007D78, 0xD9580000, 0xD9980001, 0xD9D40000,
+ 0x99007CF0, 0xC000491C, 0xC1400000, 0xC9420050, 0xC2000000, 0xC2400080, 0xDF600040, 0xB624FFCA,
+ 0xC000491C, 0xCA400000, 0xC000491E, 0xCA800000, 0x99007F18, 0xDA580000, 0xDA980001, 0x00000000,
+ 0x58380008, 0xCA400000, 0xC2000000, 0xCE000020, 0xC2A1FFFE, 0x5AA9FFFE, 0xCE001080, 0x5838000A,
+ 0xCE800000, 0xC161FFFE, 0x5955FFFE, 0x15400000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC0000838, 0xC2500002, 0xCE440808, 0xC0004848, 0xCBC40000, 0xC3800000, 0xC000082C, 0xCB840030,
+ 0x5FFC0002, 0xC0004848, 0xCFC40000, 0x58880002, 0x44B88000, 0xC1000000, 0xC5080006, 0xC0004844,
+ 0xCC840000, 0x00000000, 0xC121FFFE, 0x5911FE54, 0x15000000, 0x8000CBD8, 0xC2000000, 0xDF600040,
+ 0x5E200080, 0x84000282, 0x00000000, 0xC161FFFE, 0x5955FFFE, 0x15400000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0xC000480C, 0xCA000000, 0xC0004910, 0xCA400000, 0xC000492C, 0xCA800000,
+ 0xC0004968, 0xCAC00000, 0x00000000, 0xC121FFFE, 0x5911FE54, 0x15000000, 0x76610000, 0x76A10000,
+ 0x762D6000, 0x840001C2, 0xC0004926, 0xCA400000, 0xC201FFFE, 0x762D6000, 0x5A640002, 0x6AE50010,
+ 0x5F200000, 0x84000002, 0x6A250000, 0x8000FFF8, 0xC6E00000, 0x62014008, 0xC0004926, 0xCE800000,
+ 0xC161FFFE, 0x5955FFFE, 0x15400000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xC0004968,
+ 0xCA400000, 0xC2000002, 0x6A290000, 0x7E010000, 0x76252000, 0xCE400000, 0x00000000, 0xC121FFFE,
+ 0x5911FE54, 0x15000000, 0x6EB4A000, 0x6E944000, 0x4575A000, 0x46B5A000, 0x5B744E20, 0x58340002,
+ 0xC2000000, 0xCA0000E0, 0x5834002E, 0xC2400000, 0xCA400080, 0x6EB0A000, 0x6EBC4000, 0x47F18000,
+ 0x46B18000, 0x5B300E4E, 0x5B300004, 0x6E642000, 0x4225E000, 0xC39A8024, 0xC7380068, 0xC6B81C20,
+ 0x99007F18, 0xDB980000, 0xDBD80001, 0x00000000, 0xC2000000, 0xDF600040, 0x5E200080, 0x840002BA,
+ 0x00000000, 0xC161FFFE, 0x5955FFFE, 0x15400000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC000490E, 0xCA000000, 0xC000492A, 0xCA400000, 0xC000496A, 0xCB000000, 0xC0004956, 0xCAC00000,
+ 0x00000000, 0xC121FFFE, 0x5911FE54, 0x15000000, 0x76318000, 0x76718000, 0x84000202, 0xC201FFFE,
+ 0x76318000, 0x5AEC0002, 0x6B2D0010, 0x5EA00000, 0x84000002, 0x6A2D0000, 0x8000FFF8, 0xC7200000,
+ 0x62016008, 0xC0004956, 0xCEC00000, 0xC161FFFE, 0x5955FFFE, 0x15400000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0xC000496A, 0xCA400000, 0xC2000002, 0x6A2D0000, 0x7E010000, 0x76252000,
+ 0xCE400000, 0x00000000, 0xC121FFFE, 0x5911FE54, 0x15000000, 0x6EF4A000, 0x6ED44000, 0x4575A000,
+ 0x46F5A000, 0x5B744E20, 0x5834000E, 0xC2000000, 0xCA0000E0, 0x58340008, 0xC2400000, 0xCA420080,
+ 0x5834000C, 0xC2800000, 0xCA832018, 0x6E644010, 0x42250000, 0x4229E000, 0xC39A8008, 0x58340008,
+ 0xCB809020, 0x58340008, 0xC2800000, 0xCA810018, 0x6EE0A000, 0x6EE44000, 0x46610000, 0x46E10000,
+ 0x5A200008, 0x5A200E28, 0x42290000, 0xC6380068, 0xC6F81C20, 0x99007F18, 0xDB980000, 0xDBD80001,
+ 0x00000000, 0xC000495A, 0xC8400000, 0x00000000, 0xC3C00002, 0x7BC42000, 0xCC400000, 0xC0001A1C,
+ 0xCA000000, 0xC2400008, 0x6A452000, 0x76610000, 0x84000E82, 0xC0000A28, 0xC3800000, 0xCB840030,
+ 0xC0000A14, 0xC3400000, 0xCB440030, 0xC0004880, 0xCB040000, 0x47788000, 0x88000E30, 0x58041802,
+ 0xCAC00000, 0xA7000040, 0x00000000, 0x00000000, 0xA6C8C5A8, 0xC2800000, 0xC6E80020, 0x80000058,
+ 0x00000000, 0x00000000, 0x00000000, 0x8000C578, 0x00000000, 0xC2800000, 0xC7282020, 0xC000490E,
+ 0xCA400000, 0x6BE9E000, 0x00000000, 0x77E52000, 0x8400C530, 0x6EA0A000, 0x6E944000, 0x45610000,
+ 0x46A10000, 0x5A204E20, 0x5820000C, 0xCA000000, 0xC0004946, 0xCE800000, 0xA6220378, 0x00000000,
+ 0xC2200060, 0xC0004948, 0xCE000010, 0xCE001040, 0xC240000A, 0xC000494A, 0xCE400000, 0xC2B60002,
+ 0xC0004964, 0xCE801B08, 0x990081E8, 0xC00048A0, 0xC8840000, 0x00000000, 0xC0004946, 0xCBC00000,
+ 0x00000000, 0x00000000, 0x6FF8A000, 0x6FD44000, 0x4579C000, 0x47F9C000, 0x5BB84E20, 0x99007FA8,
+ 0xDBD80000, 0xDB980001, 0x00000000, 0x99007CF0, 0xC000491C, 0xC1400000, 0xC9420050, 0xC000491C,
+ 0x990081A0, 0xC9400001, 0xC9800000, 0x00000000, 0x99007F18, 0xD9580000, 0xD9980001, 0x00000000,
+ 0xC161FFFE, 0x5955FFFE, 0x15400000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x99007BE0,
+ 0xDBD80000, 0xDB980001, 0xC7D80000, 0x00000000, 0xC121FFFE, 0x5911FE54, 0x15000000, 0x6FF8A000,
+ 0x6FD44000, 0x4579C000, 0x47F9C000, 0x5BB84E20, 0x58380010, 0xCA000000, 0xC0004874, 0xC8040000,
+ 0x6C908000, 0x44908000, 0x44908000, 0x40100000, 0xCA400000, 0xC4340000, 0x00000000, 0xC7400000,
+ 0xCE000000, 0xC161FFFE, 0x5955FFFE, 0x15400000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC000490E, 0xCA400000, 0xC2800002, 0x6ABD4000, 0x72A52000, 0xCE400000, 0x00000000, 0xC121FFFE,
+ 0x5911FE54, 0x15000000, 0x99008690, 0xC0004836, 0xC9400000, 0xC1800002, 0x00000000, 0x00000000,
+ 0x00000000, 0xA8E2FFC8, 0x00000000, 0xC1220002, 0xD90C0000, 0xC2000000, 0xC0000A14, 0xCA040030,
+ 0xC0000A28, 0xC2500002, 0xCE440808, 0x58880002, 0xB608FFF8, 0xC00048A0, 0xC0800000, 0xCC840000,
+ 0x8000C150, 0xC0004946, 0xCBC00000, 0xC161FFFE, 0x5955FFFE, 0x15400000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0xC000490E, 0xCA400000, 0xC2800002, 0x6ABD4000, 0x72A52000, 0xCE400000,
+ 0x00000000, 0xC121FFFE, 0x5911FE54, 0x15000000, 0x6FF8A000, 0x6FD44000, 0x4579C000, 0x47F9C000,
+ 0x5BB84E20, 0x58380008, 0xCA000000, 0x5838000C, 0xCA400000, 0xC3400000, 0xC6340008, 0xC000494E,
+ 0xCF400000, 0xC2800000, 0xC62A0080, 0xC3000000, 0xC6308020, 0x6F304000, 0x43298000, 0xC000493C,
+ 0xCF000000, 0xC2C00000, 0xC66C0080, 0xC0004950, 0xCEC00000, 0xC2800000, 0xC66AE028, 0xC0004954,
+ 0xCE800000, 0x5F740000, 0x840001A0, 0x5E300028, 0x462D2000, 0x8400016A, 0x462D2000, 0x88000132,
+ 0x5E300018, 0x462D2000, 0x88000012, 0x462D2000, 0x8400002A, 0x00000000, 0x800000C0, 0x00000000,
+ 0x99008328, 0xDBD80000, 0xDB980001, 0xC7800000, 0xC3400002, 0xC000494E, 0xCF400000, 0xC161FFFE,
+ 0x5955FFFE, 0x15400000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xC000490E, 0xCA400000,
+ 0xC2800002, 0x6ABD4000, 0x7E814000, 0x76A52000, 0xCE400000, 0x00000000, 0xC121FFFE, 0x5911FE54,
+ 0x15000000, 0xC2200060, 0xC0004948, 0xCE001040, 0xC2000000, 0xC000494C, 0xCE000000, 0x80000068,
+ 0x00000000, 0x99008328, 0xDBD80000, 0xDB980001, 0xC7800000, 0x99008528, 0xDBD80000, 0xDB980001,
+ 0xC7800000, 0xC2200058, 0xC0004948, 0xCE001040, 0xC2000002, 0xC000494C, 0xCE000000, 0xC2000006,
+ 0xC0001006, 0xCE000000, 0x5838000A, 0xCA400000, 0xC2200982, 0x5A203B6E, 0xC0001008, 0xCE000000,
+ 0xC000100A, 0xCE400000, 0xC0004954, 0xCA800000, 0xC200000C, 0xC000494A, 0xCE000000, 0xC0004948,
+ 0xCE800010, 0xC2B60000, 0xC0004964, 0xCE800000, 0x990081E8, 0xC00048A0, 0xC8840000, 0x00000000,
+ 0xC0004946, 0xCBC00000, 0xC000494C, 0xCA000000, 0x6FF8A000, 0x6FD44000, 0x4579C000, 0x47F9C000,
+ 0x5BB84E20, 0x5E200000, 0x840000FA, 0x00000000, 0x99007FA8, 0xDBD80000, 0xDB980001, 0x00000000,
+ 0x99007CF0, 0xC000491C, 0xC1400000, 0xC9420050, 0xC000491C, 0x990081A0, 0xC9400001, 0xC9800000,
+ 0x00000000, 0x99007F18, 0xD9580000, 0xD9980001, 0x00000000, 0xC161FFFE, 0x5955FFFE, 0x15400000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x99007BE0, 0xDBD80000, 0xDB980001, 0xC7D80000,
+ 0x00000000, 0xC121FFFE, 0x5911FE54, 0x15000000, 0xC000493C, 0xCA800000, 0xC000494E, 0xCAC00000,
+ 0xC3000018, 0xC3400006, 0x5E200000, 0x84000012, 0xC2800000, 0xC2C00000, 0xC300001E, 0xC3400000,
+ 0xC6AC1080, 0xC72C0420, 0xC76C0818, 0x58380010, 0xCA800000, 0x58380008, 0xCEC00000, 0xC6280108,
+ 0xC0004874, 0xC8040000, 0x6C908000, 0x44908000, 0x44908000, 0x40100000, 0xCB000000, 0xC4340000,
+ 0x00000000, 0xC7400000, 0xCE800000, 0xC0004952, 0xCE800000, 0x00000000, 0x00000000, 0x00000000,
+ 0xA8E2FFC8, 0x00000000, 0xC000494C, 0xCA000000, 0xC0004950, 0xCAC00000, 0x5E200000, 0x84000052,
+ 0xDFE80000, 0x7E814000, 0x5834001A, 0xCE800000, 0x99008690, 0xC0004834, 0xC9400000, 0xC1800002,
+ 0x99008690, 0xC0004838, 0xC9400000, 0xC6D80000, 0xC1220002, 0xD90C0000, 0x5E200000, 0x84000028,
+ 0x5838002C, 0xCB000000, 0xDFE80000, 0x00000000, 0x58380014, 0xCF000000, 0x80000000, 0xC2A1FFFE,
+ 0x5AA9FFFE, 0x5838000A, 0xCE800000, 0xC3000000, 0xC0000A14, 0xCB040030, 0xC2D00002, 0xC0000A28,
+ 0xCEC40808, 0xC000494E, 0xCA800000, 0x58880002, 0xB4B0FFF8, 0xC00048A0, 0xC0800000, 0xCC840000,
+ 0x5EA80000, 0x84000152, 0x5E200000, 0x84000140, 0xC000493C, 0xCA800000, 0x00000000, 0x00000000,
+ 0x5AA80060, 0xCE800000, 0x99008328, 0xDBD80000, 0xDB980001, 0xC7800000, 0x99008528, 0xDBD80000,
+ 0xDB980001, 0xC7800000, 0xC0004952, 0xCAC00000, 0x58380000, 0xCA800000, 0xC30C0002, 0xC7F00020,
+ 0xA6800090, 0x00000000, 0x00000000, 0xC161FFFE, 0x5955FFFE, 0x15400000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0xC0001800, 0xCA000000, 0x00000000, 0x00000000, 0xA60CFFCA, 0xC6F00508,
+ 0xC6B0C408, 0xCF000000, 0x00000000, 0xC121FFFE, 0x5911FE54, 0x15000000, 0x8000B7A0, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x8000B738, 0xDCBC0001, 0x5FFC0000, 0x84000942, 0xC3800002,
+ 0xDB880001, 0xC3800000, 0xDB880001, 0xC0004728, 0xC9000000, 0x00000000, 0x00000000, 0x59100002,
+ 0xCD000000, 0xC0004730, 0xC9800000, 0xC000472E, 0xC9400000, 0xC00047DC, 0xC9000000, 0xC00047DE,
+ 0xC9C00000, 0xC000472E, 0xCD800000, 0x6D110000, 0xC5D30040, 0xC00047DC, 0xCD000000, 0x4558A000,
+ 0x6DDD0000, 0xC55C0040, 0xC00047DE, 0xCDC00000, 0xC0001AC4, 0xC9400000, 0xC0001AC8, 0xC9800000,
+ 0xC000472C, 0xC9C00000, 0x45588000, 0xC1000002, 0x41D0E004, 0xCDC00000, 0xC5501080, 0xC5900080,
+ 0xC000472A, 0xCD000000, 0xC0001AF0, 0xCBC00000, 0x58000002, 0xCB800000, 0xC3400000, 0xC7F50040,
+ 0x6F702000, 0x5B304300, 0xC000474C, 0xCAC00000, 0xC0004720, 0xC9400000, 0x00000000, 0x00000000,
+ 0x5D940002, 0x6D9B8000, 0x6D9B8010, 0x581847E0, 0xC9800000, 0x581447E0, 0xC9C00000, 0x5D2C0000,
+ 0x84000062, 0xC7901080, 0xC7D00080, 0xCD000000, 0xC1000000, 0xC5910040, 0x47508000, 0x84000078,
+ 0xC0004722, 0xC9000000, 0x00000000, 0x00000000, 0x59100002, 0xCD000000, 0x80000040, 0xC1000000,
+ 0xC5D10040, 0x47508000, 0x84000022, 0xC0004724, 0xC9000000, 0x00000000, 0x00000000, 0x59100002,
+ 0xCD000000, 0xA7840060, 0x59540002, 0x6D578000, 0x6D578010, 0xC0004720, 0xCD400000, 0xC1000000,
+ 0xC5910040, 0x47508000, 0x84000020, 0xC0004726, 0xC9000000, 0x00000000, 0x00000000, 0x59100002,
+ 0xCD000000, 0xA7800098, 0xC2800002, 0xC000474E, 0xCE800000, 0xC2C00000, 0xC000474C, 0xCEC00000,
+ 0xC0004758, 0xCFC00000, 0x58000002, 0xCF800000, 0xC000475C, 0xC9000000, 0x00000000, 0x00000000,
+ 0xA53E001A, 0x00000000, 0xC13E0002, 0xCFC00000, 0xCD001E10, 0x58000002, 0xCF800000, 0x80000188,
+ 0xC000475C, 0xC13C0002, 0xCD001E10, 0x5D2C0000, 0x84000162, 0xC2C00000, 0xC000474C, 0xCEC00000,
+ 0x98C08AF0, 0xC7540000, 0xC0004740, 0xC9C00000, 0x5D240000, 0x8400002A, 0xC1000002, 0xC0004750,
+ 0xCD000000, 0xC0004752, 0xCD000000, 0x800000E8, 0x00000000, 0x98C08BE0, 0xC7540000, 0xC0004742,
+ 0xC9800000, 0x5D240000, 0x84000012, 0xC1000002, 0xC0004752, 0xCD000000, 0x80000048, 0xC0004742,
+ 0xC9400000, 0xC0004754, 0xC1000002, 0xCD000000, 0x98C08CF0, 0xC5540000, 0xC7580000, 0x00000000,
+ 0xC0004742, 0xCF400000, 0x98C08AB8, 0xC1400000, 0xC7540028, 0x6F40A010, 0xC1000000, 0xC7D00040,
+ 0x58300000, 0x6D110000, 0xCD000840, 0xA7840378, 0xC000474C, 0xCAC00000, 0xC000474E, 0xCA800000,
+ 0xC0004750, 0xCBC00000, 0xC0004752, 0xCB800000, 0xC0004710, 0xC9000000, 0x00000000, 0x00000000,
+ 0x59100002, 0xCD000000, 0x5D280002, 0x840000A0, 0xC000473C, 0xC9000000, 0x00000000, 0x00000000,
+ 0x59100002, 0xCD000000, 0xC0004712, 0xC9000000, 0x00000000, 0x00000000, 0x59100002, 0xCD000000,
+ 0xC0004754, 0xC9000000, 0x00000000, 0x00000000, 0x5D100000, 0x84000202, 0x58300000, 0xC13C0002,
+ 0xCD001E08, 0x800001E0, 0xC0004714, 0xC9000000, 0x00000000, 0x00000000, 0x59100002, 0xCD000000,
+ 0x5D380000, 0x84000022, 0xC0004736, 0xC9000000, 0x00000000, 0x00000000, 0x59100002, 0xCD000000,
+ 0x5D3C0000, 0x8400002A, 0xC0004718, 0xC9000000, 0x00000000, 0x00000000, 0x59100002, 0xCD000000,
+ 0x80000128, 0xC1000000, 0x58300000, 0xC903E008, 0x00000000, 0x00000000, 0x5D100000, 0x8400002A,
+ 0xC000471A, 0xC9000000, 0x00000000, 0x00000000, 0x59100002, 0xCD000000, 0x800000B8, 0x58300000,
+ 0xC13E0002, 0xCD001F08, 0xC1000000, 0x58300000, 0xC903C008, 0x00000000, 0x00000000, 0x5D100000,
+ 0x8400006A, 0xC0004716, 0xC9000000, 0x00000000, 0x00000000, 0x59100002, 0xCD000000, 0xC000473A,
+ 0xC9000000, 0x00000000, 0x00000000, 0x59100002, 0xCD000000, 0x58300000, 0xC13C0000, 0xCD001E08,
+ 0xC1000000, 0xC0004746, 0xCD000000, 0xC0004750, 0xCD000000, 0xC0004752, 0xCD000000, 0xC000474E,
+ 0xCD000000, 0xC2C00002, 0xC000474C, 0xCEC00000, 0xC0004754, 0xCD000000, 0xC3CE0002, 0xC0000800,
+ 0xCFC00708, 0xC3E1FFFE, 0x597DFFFE, 0x593DFE14, 0x94000001, 0x00000000, 0x00000000, 0x00000000,
+ 0xC000487C, 0xC8040000, 0x00000000, 0x00000000, 0x40080000, 0xCBC00000, 0xC4380000, 0x00000000,
+ 0xC000480E, 0xCA000000, 0xC0004858, 0xCB440000, 0x00000000, 0x00000000, 0x46350000, 0x88000098,
+ 0x00000000, 0xA7C00028, 0xC0004854, 0xC1000002, 0xCD040000, 0xC11C0000, 0xC000082C, 0xCD040E08,
+ 0x800000C0, 0x00000000, 0xA7D20118, 0x00000000, 0xC7E14048, 0xC2400000, 0xC6246030, 0xC200006A,
+ 0x46610000, 0xC6240038, 0xC0000810, 0xCE440038, 0x8000FF58, 0xC2000000, 0xC0000808, 0xCA040018,
+ 0xC11C0000, 0xC000082C, 0xCD040E08, 0x5A200002, 0x5E600010, 0x8400FFF8, 0xC2000000, 0xC0000808,
+ 0xCE040018, 0xC3400000, 0x80000010, 0xC1200002, 0xC0000818, 0xCD041008, 0x5B740002, 0xC0004858,
+ 0xCF440000, 0x99007930, 0xC0004848, 0xC9440000, 0xC1800000, 0xC11C0002, 0xC000082C, 0xCD040E08,
+ 0x80000860, 0x5B740002, 0xC0004858, 0xCF440000, 0xC7800000, 0xC13C0002, 0xCD001E08, 0xC0004848,
+ 0xC9440000, 0xC1800000, 0xC000082C, 0xC9840030, 0x59540002, 0xC0004848, 0xCD440000, 0x58880002,
+ 0xB49807D8, 0x00000000, 0xC0800000, 0x800007C8, 0xC000487C, 0xC8040000, 0x00000000, 0x00000000,
+ 0x40080000, 0xCBC00000, 0xC4280000, 0x00000000, 0xA7C00110, 0xC000484C, 0xCA040000, 0xC2400000,
+ 0xC0001AEC, 0xCA440020, 0x5A200002, 0xC000484C, 0xCE040000, 0xB624006A, 0xC6800000, 0xC13C0002,
+ 0xCD001E08, 0xC0004848, 0xC9440000, 0xC1800000, 0xC000082C, 0xC9840030, 0x59540002, 0xC0004848,
+ 0xCD440000, 0x58880002, 0xB49806C8, 0x00000000, 0xC0800000, 0x800006B8, 0xC0004854, 0xC1000004,
+ 0xCD040000, 0xC0000820, 0xC2000002, 0xCE040000, 0xC2000000, 0xC000484C, 0xCE040000, 0xC0004858,
+ 0xCE040000, 0x8000FF10, 0xC0004854, 0xC1000000, 0xCD040000, 0xC11C0000, 0xC000082C, 0xCD040E08,
+ 0x99007930, 0xC0004848, 0xC9440000, 0xC1800000, 0xC1200000, 0xC0000818, 0xCD041008, 0xC11C0002,
+ 0xC000082C, 0xCD040E08, 0xC2000000, 0xC000484C, 0xCE040000, 0x800005B8, 0xC0001AC0, 0xCB840000,
+ 0xC000487C, 0xC8040000, 0x00000000, 0x00000000, 0x40080000, 0xCBC00000, 0xC4280000, 0x00000000,
+ 0xA78004C2, 0x00000000, 0x00000000, 0xA7C00482, 0x00000000, 0xC0001B00, 0xC2060006, 0xCE040310,
+ 0xA7E8043A, 0x00000000, 0xC0004850, 0xCA040000, 0xC2400000, 0xC0004812, 0xCA420080, 0x5A200002,
+ 0xC0004850, 0xCE040000, 0x5E640000, 0x84000002, 0x46610000, 0x880002E0, 0xC6800000, 0xC13C0002,
+ 0xCD001E08, 0xC0001ACC, 0xC2000002, 0xCE040008, 0x5C440000, 0x84000238, 0xC0004810, 0xC9400000,
+ 0xC6800000, 0xCBC00000, 0x00000000, 0xC1000000, 0xA54001E8, 0xC53C1008, 0x00000000, 0xA7FC01D2,
+ 0xC0001AF0, 0xC1000000, 0x58000002, 0xC9000008, 0xC000474E, 0xC9800000, 0x5D100000, 0x8400000A,
+ 0xC1000002, 0xC53C1E08, 0x80000180, 0x5D180000, 0x8400000A, 0xC1000002, 0xC53C1E08, 0x80000158,
+ 0xC0004878, 0xC8040000, 0x6C908000, 0x44908000, 0x44908000, 0x40100000, 0xC9800000, 0xC4380000,
+ 0x00000000, 0xC000481E, 0xC9C00000, 0xC000481C, 0xCA000000, 0x00000000, 0x75D8C000, 0x46188000,
+ 0x840000D0, 0xC0001AF0, 0xC3400000, 0x58000000, 0xCB410040, 0xC0004746, 0xC9400000, 0x6F702000,
+ 0x5B304300, 0xC2C00000, 0x58300000, 0xCAC00040, 0x00000000, 0x00000000, 0x46D48000, 0x88000008,
+ 0xC1000002, 0xC53C1E08, 0x80000028, 0x5AEC0002, 0x58300000, 0xCEC00040, 0xC1000002, 0xC53C1008,
+ 0xC77C0840, 0xC57C0040, 0x59540002, 0xC0004746, 0xCD400000, 0xC6800000, 0xCFC00000, 0xC0004848,
+ 0xC9440000, 0xC1800000, 0xC000082C, 0xC9840030, 0x59540002, 0xC0004848, 0xCD440000, 0x58880002,
+ 0xB49801D8, 0x00000000, 0xC0800000, 0x800001C8, 0xC000471E, 0xC9000000, 0x00000000, 0x00000000,
+ 0x59100002, 0xCD000000, 0xC0004854, 0xC1000000, 0xCD040000, 0xC11C0000, 0xC000082C, 0xCD040E08,
+ 0x99007930, 0xC0004848, 0xC9440000, 0xC1800000, 0xC2000000, 0xC0000820, 0xCE040000, 0xC1200000,
+ 0xC0000818, 0xCD041008, 0xC11C0002, 0xC000082C, 0xCD040E08, 0xC0004850, 0xCE040000, 0xC2000002,
+ 0xC0001ACC, 0xCE040010, 0x800000D0, 0xC2000002, 0xC0004850, 0xCE040000, 0x8000FBE8, 0xC2000000,
+ 0xC0004850, 0xCE040000, 0xA7E60012, 0x00000000, 0xC2000002, 0xC0001B00, 0xCE040008, 0x8000FBD0,
+ 0x00000000, 0xA7860032, 0x00000000, 0xC6800000, 0xC13C0002, 0xCD001E08, 0xC2020002, 0xC7E2A548,
+ 0xC0001B00, 0xCE040000, 0x8000FB78, 0xC2040002, 0xC0001B00, 0xCE040208, 0x8000FB58, 0xC2C80002,
+ 0x6AC56000, 0xDACC0000, 0xC0004854, 0xCB440000, 0xC0004848, 0xCB840000, 0xC0000838, 0xC3C00000,
+ 0xCBC40030, 0x5EF40004, 0x8400000A, 0xC3000000, 0xC0001ACC, 0xCF040108, 0x47BD8000, 0x84000032,
+ 0x47BD8000, 0x88000038, 0xC1006E8C, 0xC1400010, 0x8D580000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC0004840, 0xCC840000, 0x8000EAF8, 0xC0001AC0, 0xCAC40000, 0xC0004854, 0xCB440000, 0xA6C0F91A,
+ 0x00000000, 0x5EF40000, 0x8400F45A, 0x5EF40002, 0x8400F6EA, 0x5EF40004, 0x8400F8EA, 0xC1006CE8,
+ 0xC1400010, 0x8D580000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xC0800000, 0xDF4B0040,
+ 0xC0004900, 0xCB800000, 0xC2000000, 0xC000490A, 0xA78000B0, 0xCBC00000, 0xC1000000, 0xD9000001,
+ 0xC1000002, 0xD90C0000, 0x6FF46000, 0x47F5A000, 0x5B744C80, 0xC2400000, 0x58340004, 0xCA400080,
+ 0xC0004900, 0xCE000008, 0x5A640002, 0x58340004, 0xC6500080, 0xCD000080, 0xC0004914, 0xCA400000,
+ 0xC2000002, 0x6A3D0000, 0x72252000, 0xCE400000, 0xC0000408, 0xCE000000, 0xA78200B8, 0xC0004908,
+ 0xCBC00000, 0xC1000000, 0xD9000001, 0xC1000002, 0xD90C0000, 0x6FF4A000, 0x6FD44000, 0x4575A000,
+ 0x47F5A000, 0x5B744E20, 0xC2800000, 0x58340006, 0xCA800080, 0xC2000000, 0xC0004900, 0xCE000108,
+ 0x5EA80002, 0x58340006, 0xC6900080, 0xCD000080, 0x5A7C0020, 0xC2000002, 0x6A250000, 0xC0000408,
+ 0xCE000000, 0xC0000032, 0xDCA80001, 0xC1000002, 0x46914000, 0x00000000, 0x8C100006, 0x00000000,
+ 0x00000000, 0x00000000, 0xA4800210, 0x00000000, 0xC3C00000, 0xC000140E, 0xCBC00020, 0xC3400000,
+ 0xC2400000, 0x6FF86000, 0x47F9C000, 0x5BB84C80, 0x58380008, 0xCB400080, 0x58380006, 0xCA400080,
+ 0x5F740002, 0x58380008, 0xC7500080, 0xCD000080, 0xC2000000, 0x58380004, 0xCA020080, 0xC3000000,
+ 0x5838000C, 0xCB000028, 0x5A640002, 0x46250000, 0x8400FFF8, 0xC2400000, 0x58380006, 0xC6500080,
+ 0xCD000080, 0xC2000000, 0x5838000A, 0xCA020080, 0x5B300002, 0x5838000C, 0xC7100028, 0xCD000028,
+ 0xC2420020, 0x5A200004, 0x46612000, 0x8400FFF8, 0xC2000000, 0x5838000A, 0xC6101080, 0xCD001080,
+ 0xC0004966, 0xCA400000, 0xC2000002, 0x6A3D0000, 0x72252000, 0xCE400000, 0x5F740000, 0x84000028,
+ 0xC0004912, 0xCA000000, 0xC2C00002, 0x6AFD6000, 0x7EC16000, 0x76E10000, 0xCE000000, 0x5F300020,
+ 0x84000028, 0xC0004924, 0xCA000000, 0xC2C00002, 0x6AFD6000, 0x7EC16000, 0x76E10000, 0xCE000000,
+ 0xA4820050, 0xC2400000, 0xC000140E, 0xCA408020, 0xC2000002, 0xC0004900, 0xCE000008, 0xC000490A,
+ 0xCE400000, 0xC1000000, 0xD9000001, 0xD8400080, 0xC1000004, 0xD9000001, 0xA4840288, 0x00000000,
+ 0xC3C00000, 0xC000140E, 0xCBC10020, 0xC2800000, 0xC2000000, 0x6FF8A000, 0x6FD44000, 0x4579C000,
+ 0x47F9C000, 0x5BB84E20, 0x5838002E, 0xCA800080, 0x58380006, 0xCA020080, 0xC3400000, 0x5838002E,
+ 0xCB420080, 0x5AA80002, 0x46290000, 0x8400FFF8, 0xC2800000, 0x5838002E, 0xC6900080, 0xCD000080,
+ 0x5F740002, 0x5838002E, 0xC7501080, 0xCD001080, 0xC0004968, 0xCA400000, 0xC2000002, 0x6A3D0000,
+ 0x72252000, 0xCE400000, 0xC000492A, 0xCA800000, 0x5E740000, 0x84000028, 0xC0004910, 0xCA000000,
+ 0xC2C00002, 0x6AFD6000, 0x7EC16000, 0x76E10000, 0xCE000000, 0x6ABD4010, 0xA68000D2, 0x00000000,
+ 0xC0004910, 0xCA000000, 0xC2C00002, 0x6AFD6000, 0x7EC16000, 0x76E10000, 0xCE000000, 0x58380032,
+ 0xCA000000, 0x58000002, 0xCA400000, 0x5838000C, 0x00000000, 0xCE000001, 0xCE400000, 0xC000492A,
+ 0xCA000000, 0xC2C00002, 0x6AFD6000, 0x72E10000, 0xCE000000, 0xC000492C, 0xCA000000, 0xC2C00002,
+ 0x6AFD6000, 0x72E10000, 0xCE000000, 0x80000028, 0xC000492C, 0xCA000000, 0xC2C00002, 0x6AFD6000,
+ 0x7EC16000, 0x76E10000, 0xCE000000, 0xA4880100, 0xC2C00000, 0xC000140E, 0xCAC20020, 0xC000490E,
+ 0xCA400000, 0xC2000002, 0x6A2D0000, 0x7E010000, 0x76252000, 0xCE400000, 0xC000496A, 0xCA400000,
+ 0xC2000002, 0x6A2D0000, 0x72252000, 0xCE400000, 0x6EF0A000, 0x6ED44000, 0x45718000, 0x46F18000,
+ 0x5B304E20, 0x58300000, 0xCA000000, 0x00000000, 0xC2400002, 0x76252000, 0x84000032, 0xC24C0002,
+ 0xC6E40020, 0xC624C408, 0x58300010, 0xCA400508, 0x00000000, 0xC0001800, 0xCE400000, 0xA4860050,
+ 0xC2400000, 0xC000140E, 0xCA418020, 0xC2020002, 0xC0004900, 0xCE000108, 0xC0004908, 0xCE400000,
+ 0xC1000000, 0xD9000001, 0xD8400080, 0xC1000004, 0xD9000001, 0xA48C0028, 0xC2800002, 0xC000484A,
+ 0xCE800000, 0xC2800000, 0xC000474A, 0xCE800000, 0xC0004846, 0xCE800000, 0xC0001408, 0xCC800000,
+ 0xC10E0002, 0xD90C0000, 0x8000EA60, 0xDFBC0001, 0xC000496E, 0x99008638, 0xC9400000, 0xC7D80000,
+ 0x00000000, 0xC5700000, 0x5EF00020, 0x88000130, 0x6F346000, 0x4735A000, 0x5B744C80, 0x58340008,
+ 0xC2400000, 0xCA400080, 0x00000000, 0xC2000000, 0x5A640002, 0xCE400080, 0x58340004, 0xCA000080,
+ 0x00000000, 0x00000000, 0x5E200002, 0xCE000080, 0xC0004912, 0xCA800000, 0xC2400002, 0x6A712000,
+ 0x72694000, 0xCE800000, 0x5E200000, 0x8400003A, 0xC000480A, 0xCA000000, 0xC0000408, 0xCA800000,
+ 0x76610000, 0x00000000, 0x72294000, 0xCE800000, 0x80000020, 0xC0004914, 0xCA000000, 0x7E412000,
+ 0x00000000, 0x76610000, 0xCE000000, 0x800000B8, 0x6EF4A000, 0x6ED44000, 0x4575A000, 0x46F5A000,
+ 0x5B744E20, 0x5834002E, 0xC2400000, 0xCA420080, 0x00000000, 0xC2000000, 0x5A640002, 0xC6501080,
+ 0xCD001080, 0x58340006, 0xCA000080, 0x00000000, 0x00000000, 0x5A200002, 0xCE000080, 0xC0004910,
+ 0xCA400000, 0xC2000002, 0x6A2D0000, 0x72252000, 0xCE400000, 0xC2000002, 0x6A310000, 0xC000042A,
+ 0xCE000000, 0xC1040002, 0xD90C0000, 0x00000000, 0x8000E7D0, 0x00000000, 0xC4980930, 0x9D000000,
+ 0xC5580030, 0xC0000838, 0xCD840000, 0xC1440200, 0xC1C03200, 0xC55C1078, 0xC000100E, 0x9D000000,
+ 0xCD800000, 0xC000100C, 0xCDC00000, 0xC0004862, 0xC9C00000, 0x00000000, 0x00000000, 0xD9D80001,
+ 0xC0007200, 0x401C0000, 0x5DC07400, 0x8800FFFA, 0x5C000200, 0xCD800000, 0xC1F0000A, 0x71D4A000,
+ 0xDD980000, 0xDD9C0001, 0x41D8E000, 0xC5D40268, 0xC0001010, 0xCD400000, 0x6C9C8000, 0x449CE000,
+ 0x449CE000, 0x59DC0004, 0xC1601260, 0xC5D40268, 0x9D000000, 0xC0001012, 0xCD400000, 0x00000000,
+ 0x00000000, 0xD9580000, 0x6D586000, 0x4558C000, 0x59984C80, 0xD9980001, 0x5818000A, 0xC1800000,
+ 0xC9800080, 0xC0005400, 0x6D5CA000, 0x401C0000, 0x40180000, 0xC9400000, 0x58000002, 0x00000000,
+ 0xC9C00000, 0xC0004930, 0xCD400000, 0xC0004932, 0xCDC00000, 0x59980004, 0xC1C20020, 0xB59CFFF8,
+ 0x00000000, 0xC1800000, 0xDD9C0001, 0x581C000A, 0xCD800080, 0x581C000C, 0xC1800000, 0xC9800028,
+ 0xC1C00002, 0xDD940000, 0x69D4E000, 0x5D980002, 0xCD800028, 0xC0004924, 0xC9800000, 0x00000000,
+ 0x9D000000, 0x00000000, 0x71D8C000, 0xCD800000, 0xC000492A, 0xC9400000, 0xC1C00002, 0x69D8E000,
+ 0x7DC0C000, 0x7594A000, 0xCD400000, 0xC000492C, 0xC9400000, 0xDD800001, 0x58000032, 0x75D4A000,
+ 0x84000078, 0xC9400001, 0xC9800000, 0xDD800001, 0x5800000C, 0x00000000, 0xCD400001, 0xCD800000,
+ 0xC000492C, 0xC9400000, 0xC000492A, 0xC9800000, 0x71D4A000, 0xC000492C, 0xCD400000, 0x71D8C000,
+ 0xC000492A, 0xCD800000, 0x9D000000, 0x00000000, 0x00000000, 0x00000000, 0xC0004862, 0xC9800000,
+ 0x00000000, 0xC1C00200, 0x4194C000, 0x45D8E000, 0x8800FFFA, 0xC5D80000, 0xC0004862, 0xCD800000,
+ 0xC0001406, 0xC9800000, 0xC1C00002, 0x9D000000, 0xC5D80A08, 0xC5581050, 0xCD800000, 0xC0004930,
+ 0xC9800000, 0xC0004932, 0xC9C00000, 0xC140000E, 0xC5581C20, 0xDD940000, 0xC0007200, 0x40140000,
+ 0x5D407400, 0x8800FFFA, 0x5C000200, 0xCD800000, 0x58000002, 0x5D407400, 0x8800FFFA, 0x5C000200,
+ 0xCDC00000, 0xDD540000, 0xC1C00000, 0x58140006, 0xC9C20080, 0xC1800000, 0x58140000, 0xC98000E0,
+ 0x6DDC2000, 0xC000491E, 0x41D8E000, 0xCDC00000, 0xDD980000, 0xC1C00022, 0xC5D80D78, 0xDD940001,
+ 0xC5581C20, 0xC000491C, 0xCD800000, 0xDD540000, 0xC1C00000, 0x58140006, 0xC9C20080, 0xC1800000,
+ 0x58140004, 0xC9820080, 0x00000000, 0x59DC0002, 0x459CC000, 0x8400FFF8, 0xC1C00000, 0x9D000000,
+ 0x58140006, 0xC5D81080, 0xCD801080, 0xC0004860, 0xC9400000, 0xC1820080, 0xC1D00002, 0x58146B00,
+ 0xD5800000, 0x58000002, 0xD5800001, 0x59540004, 0xB558FFF8, 0xC0004860, 0xC1400000, 0xCD400000,
+ 0xDD980001, 0x9D000000, 0xDD940000, 0xC0001404, 0xCDC00808, 0xC1C00000, 0xC1800200, 0x5D980004,
+ 0xDF5D0050, 0x45D8A000, 0x8800FFDA, 0xDD800001, 0x5800000C, 0x00000000, 0xC9400001, 0xC9800000,
+ 0xC1C00002, 0xC5D43F08, 0xC5D81E08, 0xC0004862, 0xC9C00000, 0x00000000, 0x00000000, 0x581C7200,
+ 0x5DC07400, 0x8800FFFA, 0x5C000200, 0xCD400000, 0x58000002, 0x5DC07400, 0x8800FFFA, 0x5C000200,
+ 0xCD800000, 0xC0004862, 0xC9C00000, 0x00000000, 0xC15004C0, 0xC5D40068, 0xDD9C0000, 0xC5D41C20,
+ 0xC1C00000, 0xDD800001, 0x58000030, 0xC9C00080, 0xDD800001, 0x58000002, 0xC9800000, 0x6DDC2000,
+ 0xC000491C, 0x41D8E000, 0xCD400001, 0xCDC00000, 0xDD940001, 0xC1C00000, 0x58140030, 0xC9C00080,
+ 0xC1800000, 0x58140006, 0xC9820080, 0x00000000, 0x59DC0002, 0x459CC000, 0x8400FFF8, 0xC1C00000,
+ 0x9D000000, 0x58140030, 0xC5D80080, 0xCD800080, 0xC1C00000, 0xDF5C0040, 0x5DDC0080, 0x8400FFD2,
+ 0x00000000, 0x9D000000, 0x00000000, 0x00000000, 0x00000000, 0xC160FFFE, 0xC0000A10, 0xC9440068,
+ 0xC1A0FFFE, 0x59980E28, 0xC000100C, 0xCD400000, 0xC000100E, 0xCD800000, 0xC0004964, 0xC9800000,
+ 0x00000000, 0xC170000A, 0x7194A000, 0x6C988000, 0x4498C000, 0x4498C000, 0x59980004, 0xC5940278,
+ 0xC0001010, 0xCD400000, 0xC0004946, 0xC9400000, 0x00000000, 0x00000000, 0x6D58A000, 0x6D5C4000,
+ 0x45D8C000, 0x4558C000, 0xC000494A, 0xC9400000, 0xC0004948, 0xC9C00000, 0x4194C000, 0xC1400012,
+ 0xC55C1820, 0x9D000000, 0xC59C0270, 0xC0001012, 0xCDC00000, 0xC1400000, 0x58000012, 0xC9410040,
+ 0xC0004950, 0xC9C00000, 0xC5580000, 0xC5940840, 0xC5581080, 0xD9940000, 0xC000493C, 0xC9400000,
+ 0xC0004954, 0xC9800000, 0x59DC00A8, 0x455CE000, 0x41D8E000, 0x5D5C0030, 0x8800FFF8, 0xC1C00030,
+ 0xC1800000, 0xC5D84030, 0xC1400000, 0xC5D40010, 0x5DD40002, 0x8400005A, 0x5DD40004, 0x84000082,
+ 0x5DD40006, 0x840000AA, 0x5DD80026, 0x840000D2, 0xDD540000, 0xDD800001, 0x58000008, 0x40180000,
+ 0xCD400000, 0x59980002, 0x8000FFA8, 0xDD540000, 0xDD800001, 0x58000008, 0x40180000, 0xCD4000C0,
+ 0x59980002, 0x8000FF70, 0xDD540000, 0xDD800001, 0x58000008, 0x40180000, 0xCD400080, 0x59980002,
+ 0x8000FF38, 0xDD540000, 0xDD800001, 0x58000008, 0x40180000, 0xCD400040, 0x59980002, 0x8000FF00,
+ 0x00000000, 0x9D000000, 0x00000000, 0x00000000, 0x00000000, 0x58000012, 0xC9400000, 0xC0004954,
+ 0xC9C00000, 0xC0004950, 0xC9400080, 0xDD800001, 0x58000028, 0x5D9C0000, 0x8400003A, 0x5D9C0002,
+ 0x8400003A, 0x5D9C0004, 0x84000052, 0xC55B0040, 0xC55C08C0, 0xCD800041, 0xCDC008C0, 0x80000048,
+ 0xCD400000, 0x80000038, 0xC55900C0, 0xC55C1840, 0xCD8000C1, 0xCDC01840, 0x80000010, 0xC55A0080,
+ 0xC55C1080, 0xCD800081, 0xCDC01080, 0x9D000000, 0x00000000, 0x00000000, 0x00000000, 0x59540002,
+ 0x6994E018, 0x61C0C008, 0x4194A000, 0x5D940040, 0x8800FFFA, 0xC5940000, 0x9D000000, 0xCD400000,
+ 0x00000000, 0x00000000, 0x9D000000, 0x4158A000, 0xCD400000, 0x00000000, 0xCD800001, 0x44148000,
+ 0x8800FFD8, 0x00000000, 0x9CC00000, 0x00000000, 0x00000000, 0x00000000, 0xC0004810, 0xCA010040,
+ 0xC241FFFE, 0xC1400000, 0x45608000, 0x00000000, 0x9CC00006, 0xC0004200, 0x40180000, 0xC9C00000,
+ 0x00000000, 0x00000000, 0x61C08010, 0x84000042, 0xC2400002, 0x6A512000, 0x725CE000, 0xCDC00000,
+ 0xC0004748, 0xCD800000, 0x9CC00000, 0x6D98A000, 0x5998003E, 0x45192000, 0x59540002, 0x59980002,
+ 0x45A08000, 0xC1000000, 0xC5180006, 0x8000FF20, 0x00000000, 0x40180000, 0xC9C00000, 0xC2000000,
+ 0xC5600028, 0xC1210000, 0x69208010, 0x7D008000, 0x751CE000, 0xCDC00000, 0x6D542000, 0x58144300,
+ 0xC1000000, 0xCD000001, 0x9CC00000, 0xC121FFFE, 0x5911FFFE, 0xCD000001, 0x79948000, 0x6D10A010,
+ 0x5D100000, 0x840000A8, 0x45588000, 0x88000098, 0x6D536000, 0x6D136010, 0x6D54A010, 0xC0004700,
+ 0x40140000, 0xCA000000, 0x00000000, 0x00000000, 0x6A110000, 0x6A110010, 0x62008018, 0x8400001A,
+ 0x00000000, 0x9CC00000, 0x6D54A000, 0x5954003E, 0x45152000, 0x59540002, 0x6D57A000, 0x6D57A010,
+ 0x6D54A000, 0x6D936000, 0x6D136010, 0xC1E10000, 0x69D0E010, 0x5DDC0002, 0x7DC0E000, 0x6D98A010,
+ 0x6D536000, 0x6D136010, 0x6D54A010, 0xC0004700, 0x40140000, 0xCA000000, 0x00000000, 0x00000000,
+ 0x6A110000, 0x6A110010, 0x45948000, 0x00000000, 0x75E10002, 0x62008018, 0x8400001A, 0x00000000,
+ 0x9CC00000, 0x6D54A000, 0x5954003E, 0x45152000, 0x45948000, 0x00000000, 0x9CC00002, 0x59540002,
+ 0x6D57A000, 0x6D57A010, 0xC0004700, 0x40140000, 0xCA000000, 0x8000FF50, 0x00000000, 0x00000000,
+ 0x00000000, 0x58004700, 0xC9800000, 0x9CC00000, 0x00000000, 0x6994C000, 0x6DA7E010, 0x58004700,
+ 0xC9800000, 0xC1210000, 0x9CC00000, 0x69148010, 0x7118C000, 0xCD800000, 0xC1000000, 0xC0004810,
+ 0xC9020040, 0x00000000, 0x00000000, 0x451CC000, 0x8800004A, 0xC2400002, 0x45948000, 0xC1000000,
+ 0xC5240004, 0x455C8000, 0xC1000000, 0xC5240006, 0x9CC00000, 0x00000000, 0x00000000, 0x00000000,
+ 0x59980200, 0xC2400000, 0x45D48000, 0xC1000002, 0xC5240004, 0x45588000, 0xC1000002, 0xC5240006,
+ 0x9CC00000, 0x00000000, 0x00000000, 0x00000000, 0xC0004740, 0xC9C00000, 0x59180002, 0x6D130000,
+ 0x6D130010, 0x45D08000, 0xC2400000, 0x9CC00002, 0x00000000, 0x00000000, 0x45D88000, 0x8800004A,
+ 0xC2400002, 0x45D48000, 0xC1000000, 0xC5240004, 0x45588000, 0xC1000000, 0xC5240004, 0x9CC00000,
+ 0x00000000, 0x00000000, 0x00000000, 0xC2400000, 0x45948000, 0xC1000002, 0xC5240006, 0x455C8000,
+ 0xC1000002, 0xC5240006, 0x9CC00000, 0x00000000, 0x00000000, 0x00000000, 0x59540002, 0x6D570000,
+ 0x6D570010, 0x45948000, 0x6D402000, 0x9CC00002, 0x58004300, 0x58000000, 0xC13C0002, 0xCD001E08,
+ 0x8000FF98, 0x00000000, 0x00000000, 0x00000000, 0xC1020002, 0xD90C0000, 0xC9800000, 0x59540002,
+ 0xC0004730, 0xCD400000, 0x5D980002, 0x00000000, 0x8000001E, 0x00000000, 0x9CC00000, 0xC0004732,
+ 0xCD800000, 0x00000000, 0xC0004734, 0xC9C00000, 0xC1800000, 0xC0004816, 0xC9820080, 0xC0004738,
+ 0xCDC00000, 0xC1C00000, 0xC0004734, 0x9CC00000, 0xCDC00000, 0xC0004732, 0xCD800000,
+};
+
+static unsigned int firmware_binary_data[] = {
+};
+
+
+#endif // IFXMIPS_ATM_FW_DANUBE_H
diff --git a/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_fw_regs_amazon_se.h.svn-base b/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_fw_regs_amazon_se.h.svn-base
new file mode 100644
index 0000000..87cbe5d
--- /dev/null
+++ b/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_fw_regs_amazon_se.h.svn-base
@@ -0,0 +1,57 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_atm_fw_regs_amazon_se.h
+** PROJECT : UEIP
+** MODULES : ATM (ADSL)
+**
+** DATE : 1 AUG 2005
+** AUTHOR : Xu Liang
+** DESCRIPTION : ATM Driver (Firmware Registers)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 4 AUG 2005 Xu Liang Initiate Version
+** 23 OCT 2006 Xu Liang Add GPL header.
+** 9 JAN 2007 Xu Liang First version got from Anand (IC designer)
+*******************************************************************************/
+
+
+
+#ifndef IFXMIPS_ATM_FW_REGS_AMAZON_SE_H
+#define IFXMIPS_ATM_FW_REGS_AMAZON_SE_H
+
+
+
+/*
+ * Host-PPE Communication Data Address Mapping
+ */
+#define FW_VER_ID ((volatile struct fw_ver_id *) SB_BUFFER(0x2401)) /* Firmware Version ID */
+#define CFG_WRX_HTUTS SB_BUFFER(0x2400) /* WAN RX HTU Table Size, must be configured before enable PPE firmware. */
+//#define CFG_WRX_QNUM SB_BUFFER(0x2401) /* WAN RX Queue Number */
+#define CFG_WRX_DCHNUM SB_BUFFER(0x2402) /* WAN RX DMA Channel Number, no more than 8, must be configured before enable PPE firmware. */
+#define CFG_WTX_DCHNUM SB_BUFFER(0x2403) /* WAN TX DMA Channel Number, no more than 16, must be configured before enable PPE firmware. */
+#define CFG_WRDES_DELAY SB_BUFFER(0x2404) /* WAN Descriptor Write Delay, must be configured before enable PPE firmware. */
+#define WRX_DMACH_ON SB_BUFFER(0x2405) /* WAN RX DMA Channel Enable, must be configured before enable PPE firmware. */
+#define WTX_DMACH_ON SB_BUFFER(0x2406) /* WAN TX DMA Channel Enable, must be configured before enable PPE firmware. */
+#define WRX_HUNT_BITTH SB_BUFFER(0x2407) /* WAN RX HUNT Threshold, must be between 2 to 8. */
+#define WRX_QUEUE_CONFIG(i) ((struct wrx_queue_config*) SB_BUFFER(0x2500 + (i) * 20))
+#define WRX_DMA_CHANNEL_CONFIG(i) ((struct wrx_dma_channel_config*) SB_BUFFER(0x2640 + (i) * 7))
+#define WTX_PORT_CONFIG(i) ((struct wtx_port_config*) SB_BUFFER(0x2440 + (i)))
+#define WTX_QUEUE_CONFIG(i) ((struct wtx_queue_config*) SB_BUFFER(0x2F00 + (i) * 27))
+#define WTX_DMA_CHANNEL_CONFIG(i) ((struct wtx_dma_channel_config*) SB_BUFFER(0x2F01 + (i) * 27))
+#define WAN_MIB_TABLE ((struct wan_mib_table*) SB_BUFFER(0x2410))
+#define HTU_ENTRY(i) ((struct htu_entry*) SB_BUFFER(0x3200 + (i)))
+#define HTU_MASK(i) ((struct htu_mask*) SB_BUFFER(0x3220 + (i)))
+#define HTU_RESULT(i) ((struct htu_result*) SB_BUFFER(0x3240 + (i)))
+
+
+
+#endif // IFXMIPS_ATM_FW_REGS_AMAZON_SE_H
diff --git a/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_fw_regs_ar9.h.svn-base b/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_fw_regs_ar9.h.svn-base
new file mode 100644
index 0000000..dd010f5
--- /dev/null
+++ b/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_fw_regs_ar9.h.svn-base
@@ -0,0 +1,172 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_atm_fw_regs_ar9.h
+** PROJECT : UEIP
+** MODULES : ATM (ADSL)
+**
+** DATE : 1 AUG 2005
+** AUTHOR : Xu Liang
+** DESCRIPTION : ATM Driver (Firmware Registers)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 4 AUG 2005 Xu Liang Initiate Version
+** 23 OCT 2006 Xu Liang Add GPL header.
+** 9 JAN 2007 Xu Liang First version got from Anand (IC designer)
+*******************************************************************************/
+
+
+
+#ifndef IFXMIPS_ATM_FW_REGS_AR9_H
+#define IFXMIPS_ATM_FW_REGS_AR9_H
+
+
+
+/*
+ * Host-PPE Communication Data Address Mapping
+ */
+#define FW_VER_ID ((volatile struct fw_ver_id *) SB_BUFFER(0x2001))
+#define CFG_WRX_HTUTS SB_BUFFER(0x2400) /* WAN RX HTU Table Size, must be configured before enable PPE firmware. */
+#define CFG_WRX_QNUM SB_BUFFER(0x2401) /* WAN RX Queue Number */
+#define CFG_WRX_DCHNUM SB_BUFFER(0x2402) /* WAN RX DMA Channel Number, no more than 8, must be configured before enable PPE firmware. */
+#define CFG_WTX_DCHNUM SB_BUFFER(0x2403) /* WAN TX DMA Channel Number, no more than 16, must be configured before enable PPE firmware. */
+#define CFG_WRDES_DELAY SB_BUFFER(0x2404) /* WAN Descriptor Write Delay, must be configured before enable PPE firmware. */
+#define WRX_DMACH_ON SB_BUFFER(0x2405) /* WAN RX DMA Channel Enable, must be configured before enable PPE firmware. */
+#define WTX_DMACH_ON SB_BUFFER(0x2406) /* WAN TX DMA Channel Enable, must be configured before enable PPE firmware. */
+#define WRX_HUNT_BITTH SB_BUFFER(0x2407) /* WAN RX HUNT Threshold, must be between 2 to 8. */
+#define WRX_QUEUE_CONFIG(i) ((struct wrx_queue_config*) SB_BUFFER(0x2500 + (i) * 20))
+#define WRX_QUEUE_CONTEXT(i) ((struct wrx_queue_context*) SB_BUFFER(0x2504 + (i) * 20))
+#define WRX_DMA_CHANNEL_CONFIG(i) ((struct wrx_dma_channel_config*) SB_BUFFER(0x2640 + (i) * 7))
+#define WRX_DESC_CONTEXT(i) ((struct wrx_desc_context*) SB_BUFFER(0x2643 + (i) * 7))
+#define WTX_PORT_CONFIG(i) ((struct wtx_port_config*) SB_BUFFER(0x2440 + (i)))
+#define WTX_QUEUE_CONFIG(i) ((struct wtx_queue_config*) SB_BUFFER(0x3800 + (i) * 27))
+#define WTX_DMA_CHANNEL_CONFIG(i) ((struct wtx_dma_channel_config*) SB_BUFFER(0x3801 + (i) * 27))
+#define WAN_MIB_TABLE ((struct wan_mib_table*) SB_BUFFER(0x2410))
+#define HTU_ENTRY(i) ((struct htu_entry*) SB_BUFFER(0x2010 + (i)))
+#define HTU_MASK(i) ((struct htu_mask*) SB_BUFFER(0x2030 + (i)))
+#define HTU_RESULT(i) ((struct htu_result*) SB_BUFFER(0x2050 + (i)))
+
+#if defined(ENABLE_ATM_RETX) && ENABLE_ATM_RETX
+
+ #define RETX_MODE_CFG ((volatile struct Retx_mode_cfg *) SB_BUFFER(0x2408))
+ #define RETX_TSYNC_CFG ((volatile struct Retx_Tsync_cfg *) SB_BUFFER(0x2409))
+ #define RETX_TD_CFG ((volatile struct Retx_Td_cfg *) SB_BUFFER(0x240A))
+ #define RETX_MIB_TIMER_CFG ((volatile struct Retx_MIB_Timer_cfg *) SB_BUFFER(0x240B))
+ #define RETX_PLAYOUT_BUFFER_BASE SB_BUFFER(0x240D)
+ #define RETX_SERVICE_HEADER_CFG SB_BUFFER(0x240E)
+ #define RETX_MASK_HEADER_CFG SB_BUFFER(0x240F)
+
+ #define RETX_ADSL_PPE_INTF ((volatile struct Retx_adsl_ppe_intf *) PPE_REG_ADDR(0x0D78))
+ #define BAD_REC_RETX_ADSL_PPE_INTF ((volatile struct Retx_adsl_ppe_intf *) SB_BUFFER(0x23AC))
+ #define FIRST_BAD_REC_RETX_ADSL_PPE_INTF ((volatile struct Retx_adsl_ppe_intf *) SB_BUFFER(0x23AE))
+
+ #define PB_BUFFER_USAGE SB_BUFFER(0x2100)
+ #define DTU_STAT_INFO ((volatile struct DTU_stat_info *) SB_BUFFER(0x2180))
+ #define DTU_VLD_STAT SB_BUFFER(0x2380)
+
+
+ //=====================================================================
+ // retx firmware mib, for debug purpose
+ // address : 0x2388 - 0x238F
+ // size : 8
+ //=====================================================================
+ #define URETX_RX_TOTAL_DTU SB_BUFFER(0x2388)
+ #define URETX_RX_BAD_DTU SB_BUFFER(0x2389)
+ #define URETX_RX_GOOD_DTU SB_BUFFER(0x238A)
+ #define URETX_RX_CORRECTED_DTU SB_BUFFER(0x238B)
+ #define URETX_RX_OUTOFDATE_DTU SB_BUFFER(0x238C)
+ #define URETX_RX_DUPLICATE_DTU SB_BUFFER(0x238D)
+ #define URETX_RX_TIMEOUT_DTU SB_BUFFER(0x238E)
+
+ #define URETX_ALPHA_SWITCH_TO_HUNT_TIMES SB_BUFFER(0x238F)
+
+ // cell counter for debug purpose
+ #define WRX_BC0_CELL_NUM SB_BUFFER(0x23E0)
+ #define WRX_BC0_DROP_CELL_NUM SB_BUFFER(0x23E1)
+ #define WRX_BC0_NONRETX_CELL_NUM SB_BUFFER(0x23E2)
+ #define WRX_BC0_RETX_CELL_NUM SB_BUFFER(0x23E3)
+ #define WRX_BC0_OUTOFDATE_CELL_NUM SB_BUFFER(0x23E4)
+ #define WRX_BC0_DIRECTUP_NUM SB_BUFFER(0x23E5)
+ #define WRX_BC0_PBW_TOTAL_NUM SB_BUFFER(0x23E6)
+ #define WRX_BC0_PBW_SUCC_NUM SB_BUFFER(0x23E7)
+ #define WRX_BC0_PBW_FAIL_NUM SB_BUFFER(0x23E8)
+ #define WRX_BC1_CELL_NUM SB_BUFFER(0x23E9)
+
+ // debug info (interface)
+
+ #define DBG_DTU_INTF_WRPTR SB_BUFFER(0x2390)
+ #define DBG_INTF_FCW_DUP_CNT SB_BUFFER(0x2391)
+ #define DBG_INTF_SID_CHANGE_IN_DTU_CNT SB_BUFFER(0x2392)
+ #define DBG_INTF_LCW_DUP_CNT SB_BUFFER(0x2393)
+
+ #define DBG_RFBI_DONE_INT_CNT SB_BUFFER(0x2394)
+ #define DBG_DREG_BEG_END SB_BUFFER(0x2395)
+ #define DBG_RFBI_BC0_INVALID_CNT SB_BUFFER(0x2396)
+ #define DBG_RFBI_LAST_T SB_BUFFER(0x2397)
+
+ #define DBG_RFBI_INTV0 SB_BUFFER(0x23EE)
+ #define DBG_RFBI_INTV1 SB_BUFFER(0x23EF)
+
+ #define DBG_INTF_INFO(i) ((volatile struct Retx_adsl_ppe_intf_rec *) SB_BUFFER(0x23F0 + i))
+
+ // Internal status
+ #define URetx_curr_time SB_BUFFER(0x2398)
+ #define URetx_sec_counter SB_BUFFER(0x2399)
+ #define RxCURR_EFB SB_BUFFER(0x239A)
+ #define RxDTURetransmittedCNT SB_BUFFER(0x239B)
+
+ //=====================================================================
+ // standardized MIB counter
+ // address : 0x239C - 0x239F
+ // size : 4
+ //=====================================================================
+ #define RxLastEFBCNT SB_BUFFER(0x239C)
+ #define RxDTUCorrectedCNT SB_BUFFER(0x239D)
+ #define RxDTUCorruptedCNT SB_BUFFER(0x239E)
+ #define RxRetxDTUUncorrectedCNT SB_BUFFER(0x239F)
+
+
+ //=====================================================================
+ // General URetx Context
+ // address : 0x23A0 - 0x23AF
+ // size : 16
+ //=====================================================================
+ #define NEXT_DTU_SID_OUT SB_BUFFER(0x23A0)
+ #define LAST_DTU_SID_IN SB_BUFFER(0x23A1)
+ #define NEXT_CELL_SID_OUT SB_BUFFER(0x23A2)
+ #define ISR_CELL_ID SB_BUFFER(0x23A3)
+ #define PB_CELL_SEARCH_IDX SB_BUFFER(0x23A4)
+ #define PB_READ_PEND_FLAG SB_BUFFER(0x23A5)
+ #define RFBI_FIRST_CW SB_BUFFER(0x23A6)
+ #define RFBI_BAD_CW SB_BUFFER(0x23A7)
+ #define RFBI_INVALID_CW SB_BUFFER(0x23A8)
+ #define RFBI_RETX_CW SB_BUFFER(0x23A9)
+ #define RFBI_CHK_DTU_STATUS SB_BUFFER(0x23AA)
+
+ //=====================================================================
+ // per PVC counter for RX error_pdu and correct_pdu
+ // address : 0x23B0 - 0x23CF
+ // size : 32
+ //=====================================================================
+ #define WRX_PER_PVC_CORRECT_PDU_BASE SB_BUFFER(0x23B0)
+ #define WRX_PER_PVC_ERROR_PDU_BASE SB_BUFFER(0x23C0)
+
+ #define __WRXCTXT_L2_RdPtr(i) SB_BUFFER(0x2422 + (i))
+ #define __WRXCTXT_L2Pages(i) SB_BUFFER(0x2424 + (i))
+
+ #define __WTXCTXT_TC_WRPTR(i) SB_BUFFER(0x2450 + (i))
+ #define __WRXCTXT_PortState(i) SB_BUFFER(0x242A + (i))
+
+#endif
+
+
+
+#endif // IFXMIPS_ATM_FW_REGS_AR9_H
diff --git a/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_fw_regs_common.h.svn-base b/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_fw_regs_common.h.svn-base
new file mode 100644
index 0000000..49be99e
--- /dev/null
+++ b/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_fw_regs_common.h.svn-base
@@ -0,0 +1,549 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_atm_fw_regs_common.h
+** PROJECT : UEIP
+** MODULES : ATM (ADSL)
+**
+** DATE : 1 AUG 2005
+** AUTHOR : Xu Liang
+** DESCRIPTION : ATM Driver (Firmware Register Structures)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 4 AUG 2005 Xu Liang Initiate Version
+** 23 OCT 2006 Xu Liang Add GPL header.
+** 9 JAN 2007 Xu Liang First version got from Anand (IC designer)
+*******************************************************************************/
+
+
+
+#ifndef IFXMIPS_ATM_FW_REGS_COMMON_H
+#define IFXMIPS_ATM_FW_REGS_COMMON_H
+
+
+#if defined(CONFIG_DANUBE)
+ #include "ifxmips_atm_fw_regs_danube.h"
+#elif defined(CONFIG_AMAZON_SE)
+ #include "ifxmips_atm_fw_regs_amazon_se.h"
+#elif defined(CONFIG_AR9)
+ #include "ifxmips_atm_fw_regs_ar9.h"
+#elif defined(CONFIG_VR9)
+ #include "ifxmips_atm_fw_regs_vr9.h"
+#else
+ #error Platform is not specified!
+#endif
+
+
+
+/*
+ * PPE ATM Cell Header
+ */
+#if defined(__BIG_ENDIAN)
+ struct uni_cell_header {
+ unsigned int gfc :4;
+ unsigned int vpi :8;
+ unsigned int vci :16;
+ unsigned int pti :3;
+ unsigned int clp :1;
+ };
+#else
+ struct uni_cell_header {
+ unsigned int clp :1;
+ unsigned int pti :3;
+ unsigned int vci :16;
+ unsigned int vpi :8;
+ unsigned int gfc :4;
+ };
+#endif // defined(__BIG_ENDIAN)
+
+/*
+ * Inband Header and Trailer
+ */
+#if defined(__BIG_ENDIAN)
+ struct rx_inband_trailer {
+ /* 0 - 3h */
+ unsigned int uu :8;
+ unsigned int cpi :8;
+ unsigned int stw_res1:4;
+ unsigned int stw_clp :1;
+ unsigned int stw_ec :1;
+ unsigned int stw_uu :1;
+ unsigned int stw_cpi :1;
+ unsigned int stw_ovz :1;
+ unsigned int stw_mfl :1;
+ unsigned int stw_usz :1;
+ unsigned int stw_crc :1;
+ unsigned int stw_il :1;
+ unsigned int stw_ra :1;
+ unsigned int stw_res2:2;
+ /* 4 - 7h */
+ unsigned int gfc :4;
+ unsigned int vpi :8;
+ unsigned int vci :16;
+ unsigned int pti :3;
+ unsigned int clp :1;
+ };
+
+ struct tx_inband_header {
+ /* 0 - 3h */
+ unsigned int gfc :4;
+ unsigned int vpi :8;
+ unsigned int vci :16;
+ unsigned int pti :3;
+ unsigned int clp :1;
+ /* 4 - 7h */
+ unsigned int uu :8;
+ unsigned int cpi :8;
+ unsigned int pad :8;
+ unsigned int res1 :8;
+ };
+#else
+ struct rx_inband_trailer {
+ /* 0 - 3h */
+ unsigned int stw_res2:2;
+ unsigned int stw_ra :1;
+ unsigned int stw_il :1;
+ unsigned int stw_crc :1;
+ unsigned int stw_usz :1;
+ unsigned int stw_mfl :1;
+ unsigned int stw_ovz :1;
+ unsigned int stw_cpi :1;
+ unsigned int stw_uu :1;
+ unsigned int stw_ec :1;
+ unsigned int stw_clp :1;
+ unsigned int stw_res1:4;
+ unsigned int cpi :8;
+ unsigned int uu :8;
+ /* 4 - 7h */
+ unsigned int clp :1;
+ unsigned int pti :3;
+ unsigned int vci :16;
+ unsigned int vpi :8;
+ unsigned int gfc :4;
+ };
+
+ struct tx_inband_header {
+ /* 0 - 3h */
+ unsigned int clp :1;
+ unsigned int pti :3;
+ unsigned int vci :16;
+ unsigned int vpi :8;
+ unsigned int gfc :4;
+ /* 4 - 7h */
+ unsigned int res1 :8;
+ unsigned int pad :8;
+ unsigned int cpi :8;
+ unsigned int uu :8;
+ };
+#endif // defined(__BIG_ENDIAN)
+
+/*
+ * MIB Table Maintained by Firmware
+ */
+struct wan_mib_table {
+ u32 res1;
+ u32 wrx_drophtu_cell;
+ u32 wrx_dropdes_pdu;
+ u32 wrx_correct_pdu;
+ u32 wrx_err_pdu;
+ u32 wrx_dropdes_cell;
+ u32 wrx_correct_cell;
+ u32 wrx_err_cell;
+ u32 wrx_total_byte;
+ u32 res2;
+ u32 wtx_total_pdu;
+ u32 wtx_total_cell;
+ u32 wtx_total_byte;
+};
+
+/*
+ * Host-PPE Communication Data Structure
+ */
+
+#if defined(__BIG_ENDIAN)
+ struct fw_ver_id {
+ unsigned int family :4;
+ unsigned int fwtype :4;
+ unsigned int interface :4;
+ unsigned int fwmode :4;
+ unsigned int major :8;
+ unsigned int minor :8;
+ };
+
+ struct wrx_queue_config {
+ /* 0h */
+ unsigned int res2 :27;
+ unsigned int dmach :4;
+ unsigned int errdp :1;
+ /* 1h */
+ unsigned int oversize :16;
+ unsigned int undersize :16;
+ /* 2h */
+ unsigned int res1 :16;
+ unsigned int mfs :16;
+ /* 3h */
+ unsigned int uumask :8;
+ unsigned int cpimask :8;
+ unsigned int uuexp :8;
+ unsigned int cpiexp :8;
+ };
+
+ struct wrx_queue_context {
+ /* 0h */
+ unsigned int curr_len :16;
+ unsigned int res0 :12;
+ unsigned int mfs :1;
+ unsigned int ec :1;
+ unsigned int clp1 :1;
+ unsigned int aal5dp :1;
+
+ /* 1h */
+ unsigned int intcrc;
+
+ /* 2h, 3h */
+ unsigned int curr_des0;
+ unsigned int curr_des1;
+
+ /* 4h - 0xE */
+ unsigned int res1[11];
+
+ unsigned int last_dword;
+ };
+
+ struct wtx_port_config {
+ unsigned int res1 :27;
+ unsigned int qid :4;
+ unsigned int qsben :1;
+ };
+
+ struct wtx_queue_config {
+ unsigned int res1 :16;
+ unsigned int same_vc_qmap:8;
+ unsigned int res2 :1;
+ unsigned int sbid :1;
+ unsigned int qsb_vcid :4; // Which QSB queue (VCID) does this TX queue map to.
+ unsigned int res3 :1;
+ unsigned int qsben :1;
+ };
+
+ struct wrx_desc_context {
+ unsigned int dmach_wrptr : 16;
+ unsigned int dmach_rdptr : 16;
+
+ unsigned int res0 : 16;
+ unsigned int dmach_fcnt : 16;
+
+ unsigned int res1 : 11;
+ unsigned int desbuf_wrptr : 5;
+ unsigned int res2 : 11;
+ unsigned int desbuf_rdptr : 5;
+
+ unsigned int res3 : 27;
+ unsigned int desbuf_vcnt : 5;
+ };
+
+ struct wrx_dma_channel_config {
+ /* 0h */
+ unsigned int res1 :1;
+ unsigned int mode :2;
+ unsigned int rlcfg :1;
+ unsigned int desba :28;
+ /* 1h */
+ unsigned int chrl :16;
+ unsigned int clp1th :16;
+ /* 2h */
+ unsigned int deslen :16;
+ unsigned int vlddes :16;
+ };
+
+ struct wtx_dma_channel_config {
+ /* 0h */
+ unsigned int res2 :1;
+ unsigned int mode :2;
+ unsigned int res3 :1;
+ unsigned int desba :28;
+ /* 1h */
+ unsigned int res1 :32;
+ /* 2h */
+ unsigned int deslen :16;
+ unsigned int vlddes :16;
+ };
+
+ struct htu_entry {
+ unsigned int res1 :1;
+ unsigned int clp :1;
+ unsigned int pid :2;
+ unsigned int vpi :8;
+ unsigned int vci :16;
+ unsigned int pti :3;
+ unsigned int vld :1;
+ };
+
+ struct htu_mask {
+ unsigned int set :1;
+ unsigned int clp :1;
+ unsigned int pid_mask :2;
+ unsigned int vpi_mask :8;
+ unsigned int vci_mask :16;
+ unsigned int pti_mask :3;
+ unsigned int clear :1;
+ };
+
+ struct htu_result {
+ unsigned int res1 :12;
+ unsigned int cellid :4;
+ unsigned int res2 :5;
+ unsigned int type :1;
+ unsigned int ven :1;
+ unsigned int res3 :5;
+ unsigned int qid :4;
+ };
+
+ struct rx_descriptor {
+ /* 0 - 3h */
+ unsigned int own :1;
+ unsigned int c :1;
+ unsigned int sop :1;
+ unsigned int eop :1;
+ unsigned int res1 :3;
+ unsigned int byteoff :2;
+ unsigned int res2 :2;
+ unsigned int id :4;
+ unsigned int err :1;
+ unsigned int datalen :16;
+ /* 4 - 7h */
+ unsigned int res3 :4;
+ unsigned int dataptr :28;
+ };
+
+ struct tx_descriptor {
+ /* 0 - 3h */
+ unsigned int own :1;
+ unsigned int c :1;
+ unsigned int sop :1;
+ unsigned int eop :1;
+ unsigned int byteoff :5;
+ unsigned int res1 :5;
+ unsigned int iscell :1;
+ unsigned int clp :1;
+ unsigned int datalen :16;
+ /* 4 - 7h */
+ unsigned int res2 :4;
+ unsigned int dataptr :28;
+ };
+#else
+ struct wrx_queue_config {
+ /* 0h */
+ unsigned int errdp :1;
+ unsigned int dmach :4;
+ unsigned int res2 :27;
+ /* 1h */
+ unsigned int undersize :16;
+ unsigned int oversize :16;
+ /* 2h */
+ unsigned int mfs :16;
+ unsigned int res1 :16;
+ /* 3h */
+ unsigned int cpiexp :8;
+ unsigned int uuexp :8;
+ unsigned int cpimask :8;
+ unsigned int uumask :8;
+ };
+
+ struct wtx_port_config {
+ unsigned int qsben :1;
+ unsigned int qid :4;
+ unsigned int res1 :27;
+ };
+
+ struct wtx_queue_config {
+ unsigned int qsben :1;
+ unsigned int res3 :1;
+ unsigned int qsb_vcid :4; // Which QSB queue (VCID) does this TX queue map to.
+ unsigned int sbid :1;
+ unsigned int res2 :1;
+ unsigned int same_vc_qmap:8;
+ unsigned int res1 :16;
+ };
+
+ struct wrx_dma_channel_config
+ {
+ /* 0h */
+ unsigned int desba :28;
+ unsigned int rlcfg :1;
+ unsigned int mode :2;
+ unsigned int res1 :1;
+ /* 1h */
+ unsigned int clp1th :16;
+ unsigned int chrl :16;
+ /* 2h */
+ unsigned int vlddes :16;
+ unsigned int deslen :16;
+ };
+
+ struct wtx_dma_channel_config {
+ /* 0h */
+ unsigned int desba :28;
+ unsigned int res3 :1;
+ unsigned int mode :2;
+ unsigned int res2 :1;
+ /* 1h */
+ unsigned int res1 :32;
+ /* 2h */
+ unsigned int vlddes :16;
+ unsigned int deslen :16;
+ };
+
+ struct rx_descriptor {
+ /* 4 - 7h */
+ unsigned int dataptr :28;
+ unsigned int res3 :4;
+ /* 0 - 3h */
+ unsigned int datalen :16;
+ unsigned int err :1;
+ unsigned int id :4;
+ unsigned int res2 :2;
+ unsigned int byteoff :2;
+ unsigned int res1 :3;
+ unsigned int eop :1;
+ unsigned int sop :1;
+ unsigned int c :1;
+ unsigned int own :1;
+ };
+
+ struct tx_descriptor {
+ /* 4 - 7h */
+ unsigned int dataptr :28;
+ unsigned int res2 :4;
+ /* 0 - 3h */
+ unsigned int datalen :16;
+ unsigned int clp :1;
+ unsigned int iscell :1;
+ unsigned int res1 :5;
+ unsigned int byteoff :5;
+ unsigned int eop :1;
+ unsigned int sop :1;
+ unsigned int c :1;
+ unsigned int own :1;
+ };
+#endif // defined(__BIG_ENDIAN)
+
+#if defined(ENABLE_ATM_RETX) && ENABLE_ATM_RETX
+ #if defined(__BIG_ENDIAN)
+
+ struct Retx_adsl_ppe_intf {
+ unsigned int res0_0 : 16;
+ unsigned int dtu_sid : 8;
+ unsigned int dtu_timestamp : 8;
+
+ unsigned int res1_0 : 16;
+ unsigned int local_time : 8;
+ unsigned int res1_1 : 5;
+ unsigned int is_last_cw : 1;
+ unsigned int reinit_flag : 1;
+ unsigned int is_bad_cw : 1;
+ };
+
+ struct Retx_adsl_ppe_intf_rec {
+
+ unsigned int local_time : 8;
+ unsigned int res1_1 : 5;
+ unsigned int is_last_cw : 1;
+ unsigned int reinit_flag : 1;
+ unsigned int is_bad_cw : 1;
+
+ unsigned int dtu_sid : 8;
+ unsigned int dtu_timestamp : 8;
+
+ };
+
+ struct Retx_mode_cfg {
+ unsigned int res0 :8;
+ unsigned int invld_range :8; // used for rejecting the too late arrival of the retransmitted DTU
+ unsigned int buff_size :8; // the total number of cells in playout buffer is 32 * buff_size
+ unsigned int res1 :7;
+ unsigned int retx_en :1;
+ };
+
+ struct Retx_Tsync_cfg {
+ unsigned int fw_alpha :16; // number of consecutive HEC error cell causes that the cell delineation state machine transit from SYNC to HUNT (0 means never)
+ unsigned int sync_inp :16; // reserved
+ };
+
+ struct Retx_Td_cfg {
+ unsigned int res0 :8;
+ unsigned int td_max :8; // maximum delay between the time a DTU is first created at transmitter and the time the DTU is sent out of ReTX layer at receiver
+ unsigned int res1 :8;
+ unsigned int td_min :8; // minimum delay between the time a DTU is first created at transmitter and the time the DTU is sent out of ReTX layer at receiver
+ };
+
+ struct Retx_MIB_Timer_cfg {
+ unsigned int ticks_per_sec : 16;
+ unsigned int tick_cycle : 16;
+ };
+
+ struct DTU_stat_info {
+ unsigned int complete : 1;
+ unsigned int bad : 1;
+ unsigned int res0_0 : 14;
+ unsigned int time_stamp : 8;
+ unsigned int cell_cnt : 8;
+
+ unsigned int dtu_rd_ptr : 16;
+ unsigned int dtu_wr_ptr : 16;
+ };
+
+ struct Retx_ctrl_field {
+ unsigned int res0 : 1;
+
+ unsigned int l2_drop : 1;
+ unsigned int res1 : 13;
+ unsigned int retx : 1;
+
+ unsigned int dtu_sid : 8;
+ unsigned int cell_sid : 8;
+ };
+
+ #else
+ #error Little Endian is not supported yet.
+ #endif
+
+ struct dsl_param {
+ unsigned int update_flag; // 00
+ unsigned int res0; // 04
+ unsigned int MinDelayrt; // 08
+ unsigned int MaxDelayrt; // 0C
+ unsigned int res1; // 10
+ unsigned int res2; // 14
+ unsigned int RetxEnable; // 18
+ unsigned int ServiceSpecificReTx; // 1C
+ unsigned int res3; // 20
+ unsigned int ReTxPVC; // 24
+ unsigned int res4; // 28
+ unsigned int res5; // 2C
+ unsigned int res6; // 30
+ unsigned int res7; // 34
+ unsigned int res8; // 38
+ unsigned int res9; // 3C
+ unsigned int res10; // 40
+ unsigned int res11; // 44
+ unsigned int res12; // 48
+ unsigned int res13; // 4C
+ unsigned int RxDtuCorruptedCNT; // 50
+ unsigned int RxRetxDtuUnCorrectedCNT;// 54
+ unsigned int RxLastEFB; // 58
+ unsigned int RxDtuCorrectedCNT; // 5C
+ };
+#endif
+
+
+
+#endif // IFXMIPS_ATM_FW_REGS_COMMON_H
diff --git a/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_fw_regs_danube.h.svn-base b/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_fw_regs_danube.h.svn-base
new file mode 100644
index 0000000..9bdefdb
--- /dev/null
+++ b/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_fw_regs_danube.h.svn-base
@@ -0,0 +1,51 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_atm_fw_regs_danube.h
+** PROJECT : UEIP
+** MODULES : ATM (ADSL)
+**
+** DATE : 1 AUG 2005
+** AUTHOR : Xu Liang
+** DESCRIPTION : ATM Driver (Firmware Registers)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 4 AUG 2005 Xu Liang Initiate Version
+** 23 OCT 2006 Xu Liang Add GPL header.
+** 9 JAN 2007 Xu Liang First version got from Anand (IC designer)
+*******************************************************************************/
+
+
+
+#ifndef IFXMIPS_ATM_FW_REGS_DANUBE_H
+#define IFXMIPS_ATM_FW_REGS_DANUBE_H
+
+#define FW_VER_ID ((volatile struct fw_ver_id *) SB_BUFFER(0x2001))
+#define CFG_WRX_HTUTS SB_BUFFER(0x2400) /* WAN RX HTU Table Size, must be configured before enable PPE firmware. */
+#define CFG_WRX_QNUM SB_BUFFER(0x2401) /* WAN RX Queue Number */
+#define CFG_WRX_DCHNUM SB_BUFFER(0x2402) /* WAN RX DMA Channel Number, no more than 8, must be configured before enable PPE firmware. */
+#define CFG_WTX_DCHNUM SB_BUFFER(0x2403) /* WAN TX DMA Channel Number, no more than 16, must be configured before enable PPE firmware. */
+#define CFG_WRDES_DELAY SB_BUFFER(0x2404) /* WAN Descriptor Write Delay, must be configured before enable PPE firmware. */
+#define WRX_DMACH_ON SB_BUFFER(0x2405) /* WAN RX DMA Channel Enable, must be configured before enable PPE firmware. */
+#define WTX_DMACH_ON SB_BUFFER(0x2406) /* WAN TX DMA Channel Enable, must be configured before enable PPE firmware. */
+#define WRX_HUNT_BITTH SB_BUFFER(0x2407) /* WAN RX HUNT Threshold, must be between 2 to 8. */
+
+#define WRX_QUEUE_CONFIG(i) ((struct wrx_queue_config*) SB_BUFFER(0x2500 + (i) * 20))
+#define WRX_DMA_CHANNEL_CONFIG(i) ((struct wrx_dma_channel_config*) SB_BUFFER(0x2640 + (i) * 7))
+#define WTX_PORT_CONFIG(i) ((struct wtx_port_config*) SB_BUFFER(0x2440 + (i)))
+#define WTX_QUEUE_CONFIG(i) ((struct wtx_queue_config*) SB_BUFFER(0x2710 + (i) * 27))
+#define WTX_DMA_CHANNEL_CONFIG(i) ((struct wtx_dma_channel_config*) SB_BUFFER(0x2711 + (i) * 27))
+#define WAN_MIB_TABLE ((struct wan_mib_table*) SB_BUFFER(0x2410))
+#define HTU_ENTRY(i) ((struct htu_entry*) SB_BUFFER(0x2000 + (i)))
+#define HTU_MASK(i) ((struct htu_mask*) SB_BUFFER(0x2020 + (i)))
+#define HTU_RESULT(i) ((struct htu_result*) SB_BUFFER(0x2040 + (i)))
+
+#endif
diff --git a/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_fw_regs_vr9.h.svn-base b/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_fw_regs_vr9.h.svn-base
new file mode 100644
index 0000000..708d337
--- /dev/null
+++ b/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_fw_regs_vr9.h.svn-base
@@ -0,0 +1,72 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_atm_fw_regs_vr9.h
+** PROJECT : UEIP
+** MODULES : ATM (ADSL)
+**
+** DATE : 1 AUG 2005
+** AUTHOR : Xu Liang
+** DESCRIPTION : ATM Driver (Firmware Registers)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 4 AUG 2005 Xu Liang Initiate Version
+** 23 OCT 2006 Xu Liang Add GPL header.
+** 9 JAN 2007 Xu Liang First version got from Anand (IC designer)
+*******************************************************************************/
+
+
+
+#ifndef IFXMIPS_ATM_FW_REGS_VR9_H
+#define IFXMIPS_ATM_FW_REGS_VR9_H
+
+#define FW_VER_ID ((volatile struct fw_ver_id *) SB_BUFFER(0x2001))
+
+/* WAN RX HTU Table Size, must be configured before enable PPE firmware. */
+#define CFG_WRX_HTUTS SB_BUFFER(0x2010)
+/* WAN RX Queue Number */
+#define CFG_WRX_QNUM SB_BUFFER(0x2011)
+/* WAN RX DMA Channel Number, no more than 8, must be configured before enable PPE firmware. */
+#define CFG_WRX_DCHNUM SB_BUFFER(0x2012)
+/* WAN TX DMA Channel Number, no more than 16, must be configured before enable PPE firmware. */
+#define CFG_WTX_DCHNUM SB_BUFFER(0x2013)
+/* WAN Descriptor Write Delay, must be configured before enable PPE firmware. */
+#define CFG_WRDES_DELAY SB_BUFFER(0x2014)
+/* WAN RX DMA Channel Enable, must be configured before enable PPE firmware. */
+#define WRX_DMACH_ON SB_BUFFER(0x2015)
+/* WAN TX DMA Channel Enable, must be configured before enable PPE firmware. */
+#define WTX_DMACH_ON SB_BUFFER(0x2016)
+/* WAN RX HUNT Threshold, must be between 2 to 8. */
+#define WRX_HUNT_BITTH SB_BUFFER(0x2017)
+/* i < 16 */
+#define WRX_QUEUE_CONFIG(i) ((struct wrx_queue_config *) SB_BUFFER(0x4C00 + (i) * 20))
+/* i < 8 */
+#define WRX_DMA_CHANNEL_CONFIG(i) ((struct wrx_dma_channel_config *) SB_BUFFER(0x4F80 + (i) * 7))
+/* i < 2 */
+#define WTX_PORT_CONFIG(i) ((struct wtx_port_config *) SB_BUFFER(0x4FB8 + (i)))
+/* i < 16 */
+#define WTX_QUEUE_CONFIG(i) ((struct wtx_queue_config *) SB_BUFFER(0x3A00 + (i) * 27))
+/* i < 16 */
+#define WTX_DMA_CHANNEL_CONFIG(i) ((struct wtx_dma_channel_config *) SB_BUFFER(0x3A01 + (i) * 27))
+
+#define WAN_MIB_TABLE ((struct wan_mib_table *) SB_BUFFER(0x4EF0))
+/* i < 32 */
+#define HTU_ENTRY(i) ((struct htu_entry *) SB_BUFFER(0x26A0 + (i)))
+/* i < 32 */
+#define HTU_MASK(i) ((struct htu_mask *) SB_BUFFER(0x26C0 + (i)))
+/* i < 32 */
+#define HTU_RESULT(i) ((struct htu_result *) SB_BUFFER(0x26E0 + (i)))
+/* bit 0~3 - 0x0F: in showtime, 0x00: not in showtime */
+#define UTP_CFG SB_BUFFER(0x2018)
+
+
+
+#endif // IFXMIPS_ATM_FW_REGS_VR9_H
diff --git a/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_fw_vr9.h.svn-base b/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_fw_vr9.h.svn-base
new file mode 100644
index 0000000..99c351f
--- /dev/null
+++ b/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_fw_vr9.h.svn-base
@@ -0,0 +1,427 @@
+#ifndef IFXMIPS_ATM_FW_VR9_H
+#define IFXMIPS_ATM_FW_VR9_H
+
+
+/******************************************************************************
+**
+** FILE NAME : ifxmips_atm_fw_vr9.h
+** PROJECT : UEIP
+** MODULES : ATM (ADSL)
+**
+** DATE : 22 OCT 2007
+** AUTHOR : Xu Liang
+** DESCRIPTION : ATM Driver (PP32 Firmware)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 22 OCT 2007 Xu Liang Initial Version, v00.01
+*******************************************************************************/
+
+
+#define VER_IN_FIRMWARE 1
+
+#define ATM_FW_VER_MAJOR 0
+#define ATM_FW_VER_MINOR 24
+
+
+static u32 vr9_fw_bin[] = {
+ 0x800004B8, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8000FFE0, 0x00000000, 0x00000000, 0x00000000,
+ 0xC1000002, 0xD90C00F8, 0xC2000002, 0xDA0800F9, 0x80004390, 0xC2000000, 0xDA0800F9, 0x80003A10,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x800039C8, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x80004B60, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x800038C8, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC0400000, 0xC000ABC0, 0xC88400F8, 0x80004050, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC0400002, 0xC000ABC0, 0xC88400F8, 0x80003FD0, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC3C00004, 0xDBC800F9, 0xC10C0002, 0xD90C00F8, 0x8000FEE0, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC10E0002, 0xD90C00F8, 0xC0004028, 0xC84000F8, 0x80004000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC3E1FFFE, 0x597DFFFE, 0x593DFE14, 0x900004D9, 0x00000000, 0x00000000, 0x00000000, 0x90CC0481,
+ 0x00000000, 0x00000000, 0x00000000, 0xC3C00000, 0xDBC800F9, 0xC1400008, 0xC1900000, 0x71588000,
+ 0x14100100, 0xC140000A, 0xC1900002, 0x71588000, 0x14100100, 0xC140000C, 0xC1900004, 0x71588000,
+ 0x14100100, 0xC1400004, 0xC1900006, 0x71588000, 0x14100100, 0xC1400006, 0xC1900008, 0x71588000,
+ 0x14100100, 0xC140000E, 0xC190000A, 0x71588000, 0x14100100, 0xC1400000, 0xC190000C, 0x71588000,
+ 0x14100100, 0xC1400002, 0xC190000E, 0x71588000, 0x14100100, 0xC0400000, 0xC11C0000, 0xC000E82C,
+ 0xCD05CE00, 0xC11C0002, 0xC000E82C, 0xCD05CE00, 0xC0400002, 0xC11C0000, 0xC000E82C, 0xCD05CE00,
+ 0xC11C0002, 0xC000E82C, 0xCD05CE00, 0xC000E824, 0x00000000, 0xCBC000F9, 0xCB8000F9, 0xCB4000F9,
+ 0xCB0000F8, 0xC000ABE4, 0x5BFC4000, 0xCFC000F9, 0x5BB84000, 0xCF8000F9, 0x5B744000, 0xCF4000F9,
+ 0x5B304000, 0xCF0000F8, 0xC000EA10, 0x00000000, 0xCBC000F9, 0xCB8000F8, 0xC000ABE0, 0x5BFC4000,
+ 0xCFC000F9, 0x5BB84000, 0xCF8000F8, 0xC30001FE, 0xC000F416, 0xCF0000F8, 0xC3000000, 0x7F018000,
+ 0xC000E42E, 0xCF0000F8, 0xC000E40E, 0xCF0000F8, 0xC3C1FFFE, 0xC000690E, 0xCFC00078, 0xC000692C,
+ 0xCFC00078, 0xC0006924, 0xCFC00038, 0xC0006912, 0xCFC00038, 0xC0006966, 0xCFC00038, 0xC0006968,
+ 0xCFC00078, 0xC000696A, 0xCFC00078, 0xC3C00000, 0xC2800020, 0xC3000000, 0x7F018000, 0x6FF88000,
+ 0x6FD44000, 0x4395C000, 0x5BB89800, 0x5838000A, 0xCF0000F8, 0x5BFC0002, 0xB7E8FFC8, 0x00000000,
+ 0xC3C00000, 0xC2800010, 0x6FF86000, 0x47BDC000, 0x5BB89F00, 0xC3400000, 0x58380004, 0xCB420078,
+ 0x00000000, 0x58380008, 0xCF400078, 0x5BFC0002, 0xB7E8FFB0, 0x00000000, 0xC3C00000, 0xC2800020,
+ 0xC348001E, 0xC3000000, 0x7F018000, 0x6FF8A000, 0x6FD44000, 0x4795C000, 0x47BDC000, 0x5BB87400,
+ 0x58380008, 0xCF408418, 0x5838000A, 0xCF0000F8, 0x5BFC0002, 0xB7E8FFB0, 0x00000000, 0x00000000,
+ 0xC3E0E282, 0x5BFC0030, 0xC0004002, 0xCFC000F8, 0xC000E82C, 0xC11E0002, 0xCD01EF00, 0xC000E82E,
+ 0xCD01EF00, 0x00000000, 0xC121FFFE, 0x5911FE94, 0x14100000, 0x80000028, 0x00000000, 0x80001CB8,
+ 0x00000000, 0x8000FFE0, 0xC0006918, 0xD28000F8, 0xC2000000, 0xDF600038, 0x5E600020, 0x84000272,
+ 0x00000000, 0xC161FFFE, 0x5955FFFE, 0x14140000, 0x00000000, 0xC000402A, 0xCA0000F8, 0xC0006912,
+ 0xCA4000F8, 0xC0006924, 0xCA8000F8, 0xC0006966, 0xCAC000F8, 0x00000000, 0xC121FFFE, 0x5911FE94,
+ 0x14100000, 0x76250000, 0x76290000, 0x762D0000, 0x840001CA, 0xC0006918, 0xCA4000F8, 0xC28001FE,
+ 0x76290000, 0x5A640002, 0x6A254010, 0x5EE80000, 0x8400001A, 0x6AA54000, 0x80000010, 0xC62800F8,
+ 0x62818008, 0xC0006918, 0xCF0000F8, 0xC161FFFE, 0x5955FFFE, 0x14140000, 0x00000000, 0xC0006966,
+ 0xCA4000F8, 0xC2000002, 0x6A310000, 0x7E010000, 0x76612000, 0xCE4000F8, 0x00000000, 0xC121FFFE,
+ 0x5911FE94, 0x14100000, 0x6F346000, 0x4771A000, 0x5B749F00, 0xC2800000, 0x58340006, 0xCA800078,
+ 0xC2C00000, 0x58340000, 0xCAC000D8, 0xC2400000, 0x5834000A, 0xCA420078, 0x6EA82000, 0x42E9E000,
+ 0x6F2CA000, 0x42E56000, 0x5AEC3200, 0xC3990040, 0xC7381C18, 0xC6F80060, 0x99005560, 0xDB9800F8,
+ 0xDBD800F9, 0x00000000, 0xDEA000F8, 0x46310000, 0x8400FD80, 0xC0006958, 0xC84000F8, 0x00000000,
+ 0xC3C00002, 0x787C2000, 0xCC4000F8, 0xC000ABC8, 0xCB8400F8, 0xC000ABC4, 0xC88400F8, 0x5FB80000,
+ 0x8400FCFA, 0xC000FAC0, 0xCA0400F8, 0x00000000, 0x00000000, 0xA6040070, 0xC000ABE4, 0xC80400F8,
+ 0x6C908000, 0x45088000, 0x45088000, 0x40100000, 0xCA0000F8, 0xC42400F8, 0x00000000, 0x98C05CD8,
+ 0xC000697C, 0xCA0000F8, 0x59640004, 0xC0004030, 0xCA0000F8, 0xC2400002, 0x6A452000, 0x76250000,
+ 0x8400FC3A, 0xC000ABE8, 0xC80400F8, 0x00000000, 0x00000000, 0x40080000, 0xCA0000F8, 0xC42400F8,
+ 0x00000000, 0xA63C17DA, 0x00000000, 0xC000ABE4, 0xC80400F8, 0x6C908000, 0x45088000, 0x45088000,
+ 0x40100000, 0xCA0000F8, 0xC42400F8, 0x00000000, 0xC0006934, 0xCE0000F8, 0xC2800002, 0xC4681C08,
+ 0xC62821D0, 0xC2600010, 0x5A650D80, 0xC0004020, 0xCB4000F8, 0xC2200400, 0x5A200D40, 0xC7601040,
+ 0xC000F220, 0xCE8000F8, 0xC000F200, 0xCE4000F8, 0xC000F202, 0xCE0000F8, 0xC000F240, 0xCB4000F8,
+ 0x00000000, 0x00000000, 0xA754FFE0, 0xC2000000, 0xC7600040, 0xA7520042, 0x00000000, 0x00000000,
+ 0x99005FD8, 0xC0009DE2, 0xC94000F8, 0xC1800002, 0x80001680, 0x58204DC0, 0xC2000000, 0xCA000018,
+ 0xC2400000, 0xCA414000, 0xC2800000, 0xCA812000, 0xC2C00000, 0xCAC20018, 0xC0006938, 0xCE0000F8,
+ 0xC0006920, 0xCE4000F8, 0xC0006916, 0xCE8000F8, 0xC0006922, 0xCEC000F8, 0xA6400540, 0x00000000,
+ 0xC0006938, 0xCBC000F8, 0x00000000, 0xC3800000, 0x6FF48000, 0x6FD44000, 0x4355A000, 0x5B749800,
+ 0x58340000, 0xCB802010, 0x00000000, 0xC2000000, 0x6FB46000, 0x4779A000, 0x5B749F00, 0x5834000C,
+ 0xCA000020, 0xC000691A, 0xCF8000F8, 0x5E200000, 0x8400046A, 0xC2000000, 0xDF610048, 0x5E6001E8,
+ 0x8800FFE8, 0xC2000002, 0xC2400466, 0xC2A00000, 0x5AA80000, 0xC000F006, 0xCE0000F8, 0xC000F008,
+ 0xCE4000F8, 0xC000F00A, 0xCE8000F8, 0x99004FA0, 0xC1A0FFFE, 0xC000E824, 0xC9840070, 0xC0006934,
+ 0xCA4000F8, 0xC2000000, 0xC2800002, 0x99004FE0, 0xDA9800F8, 0xC61400F8, 0xC65800F8, 0xC161FFFE,
+ 0x5955FFFE, 0x14140000, 0x00000000, 0x990050C8, 0xC000691A, 0xC94000F8, 0x00000000, 0x00000000,
+ 0xC121FFFE, 0x5911FE94, 0x14100000, 0xC0006922, 0xCA001118, 0xC3C00000, 0xC3800000, 0xC0006930,
+ 0xCE023118, 0xC0006932, 0xCBC000D8, 0xC2800000, 0xC000691E, 0xCFC000F8, 0xC000ABDE, 0xCA800060,
+ 0xC3A0001A, 0x5BB94000, 0xC6B80060, 0xC000691C, 0xCF8000F8, 0x99005338, 0xC000691C, 0xC1400000,
+ 0xC9420048, 0x00000000, 0x00000000, 0x00000000, 0xA8E2FFE8, 0xC2000000, 0xC1220002, 0xD90C00F8,
+ 0xDF600038, 0x5E600020, 0x8400FFF2, 0xC000691C, 0xCA0000F8, 0xC000691E, 0xCA4000F8, 0x00000000,
+ 0x00000000, 0x99005560, 0xDA1800F8, 0xDA5800F9, 0x00000000, 0xC2000000, 0xDF610048, 0x5E6001FE,
+ 0x8800FFE8, 0xC0006916, 0xCA8000F8, 0xC2C00000, 0xDFEC0048, 0xC2400000, 0x466D2000, 0x8400004A,
+ 0x5EA80000, 0x8400003A, 0xC2600002, 0x99005FD8, 0xC0009DEE, 0xC94000F8, 0xC1800002, 0x80000030,
+ 0xC2600000, 0x99005FD8, 0xC0009DEC, 0xC94000F8, 0xC1800002, 0xC2000068, 0xC6240078, 0xC0006930,
+ 0xCE400080, 0xC000691A, 0xC98000F8, 0xC000ABDE, 0xC94000F8, 0x6D9C6000, 0x45D8E000, 0x59DC9F00,
+ 0x990053C0, 0xD95800F8, 0xD99800F9, 0xD9D400F8, 0x99005338, 0xC000691C, 0xC1400000, 0xC9420048,
+ 0xC2000000, 0xDF600038, 0x5E600020, 0x8400FFEA, 0x00000000, 0xC000691C, 0xCA0000F8, 0xC000691E,
+ 0xCA4000F8, 0x00000000, 0x00000000, 0x99005560, 0xDA1800F8, 0xDA5800F9, 0x00000000, 0x800010E8,
+ 0x00000000, 0x99005FD8, 0xC0009DEA, 0xC94000F8, 0xC1800002, 0x800010B8, 0xC0006938, 0xCBC000F8,
+ 0x00000000, 0x00000000, 0x6FF88000, 0x6FD44000, 0x4395C000, 0x5BB89800, 0x58380008, 0xCA0000F8,
+ 0x00000000, 0x00000000, 0xA6000382, 0x00000000, 0xC0006938, 0xCBC000F8, 0xC3000000, 0x00000000,
+ 0x6FF88000, 0x6FD44000, 0x4395C000, 0x5BB89800, 0x58380000, 0xCB002010, 0xC2000000, 0x58380008,
+ 0xCA020078, 0x5838000C, 0xCAC000F8, 0x5838000E, 0xCA4000F8, 0xC000691A, 0xCF0000F8, 0xC0006930,
+ 0xCEC000F8, 0xC000693C, 0xCE0000F8, 0xC0006932, 0xCE4000F8, 0x5E200000, 0x84000120, 0xC2800000,
+ 0xA6FE00BA, 0x6F206000, 0x46310000, 0x5A209F00, 0x5820000C, 0xCA800020, 0x00000000, 0x00000000,
+ 0x5EA80000, 0x840001F2, 0x00000000, 0xC161FFFE, 0x5955FFFE, 0x14140000, 0x00000000, 0x990050C8,
+ 0xC000691A, 0xC94000F8, 0x00000000, 0x00000000, 0xC121FFFE, 0x5911FE94, 0x14100000, 0xC0006930,
+ 0xCAC000F8, 0xC0006932, 0xCA4000F8, 0xC7EC1118, 0xC0006930, 0xCEC000F8, 0x5838000C, 0xCEC000F8,
+ 0x58000002, 0xCE4000F8, 0xC0006934, 0xCA0000F8, 0xC2400002, 0x6E642000, 0x6E642000, 0x76612000,
+ 0x8400002A, 0xC2400002, 0x6E684000, 0x58380008, 0xCE804200, 0xA6000020, 0x6E682000, 0x58380008,
+ 0xCE802100, 0xC2400002, 0x6E642000, 0x76612000, 0x840000EA, 0x58380008, 0xCA0000F8, 0xC2800000,
+ 0xC2400000, 0xA60200C0, 0xDBA800F8, 0x6F386000, 0x47B1C000, 0x5BB89F00, 0x58380004, 0xCA400078,
+ 0x58380002, 0xCA800078, 0x00000000, 0xDEB800F8, 0x46A54000, 0x88000060, 0x00000000, 0xC0009DE4,
+ 0xCA0000F8, 0xC2400002, 0x6E640000, 0x5A200002, 0xCE0000F8, 0x58380008, 0xCE400000, 0x80000018,
+ 0x00000000, 0x80000048, 0xC0006934, 0xCA0000F8, 0x00000000, 0x00000000, 0xA6020C6A, 0x00000000,
+ 0x00000000, 0x80000C98, 0xC2800000, 0xC2000080, 0xC240001A, 0xDF690048, 0x46294000, 0x46A54000,
+ 0x8800FFD2, 0xC2000006, 0xC2600982, 0x5A643B6E, 0x5838000A, 0xCA8000F8, 0xC000F006, 0xCE0000F8,
+ 0xC000F008, 0xCE4000F8, 0xC000F00A, 0xCE8000F8, 0x99004FA0, 0xC1A0FFFE, 0xC000E824, 0xC9840070,
+ 0xC2000000, 0xC0006930, 0xCA02E008, 0x58380026, 0xCA4000F8, 0x00000000, 0xC2800000, 0x99004FE0,
+ 0xDA9800F8, 0xC61400F8, 0xC65800F8, 0xC0006934, 0xCA0000F8, 0x00000000, 0x00000000, 0xA6020022,
+ 0x00000000, 0x00000000, 0x80000318, 0xC0006938, 0xCBC000F8, 0xC000ABE4, 0xC80400F8, 0x6C908000,
+ 0x45088000, 0x45088000, 0x40100000, 0xCA0000F8, 0xC42400F8, 0x00000000, 0x58240018, 0xCA0000F8,
+ 0x6FF88000, 0x6FD44000, 0x4395C000, 0x5BB89800, 0xC3000000, 0xC3400002, 0xC2C00000, 0xC62C0078,
+ 0xC6270038, 0xC0006940, 0xCE400038, 0xC6260038, 0xC0006942, 0xCE400038, 0xC000693C, 0xCA0000F8,
+ 0x5EEC0000, 0x8400018A, 0x5A6C0010, 0x46254000, 0x88000190, 0x5A600052, 0x46E54000, 0x88000178,
+ 0x58380006, 0xCA8000F8, 0xC0006940, 0xCA0000F8, 0xC2400000, 0xC6A70038, 0x7E412000, 0x76612000,
+ 0xC2000000, 0xC6A10038, 0x46250000, 0x84000138, 0xC0006942, 0xCA0000F8, 0xC2400000, 0xC6A60038,
+ 0x7E412000, 0x76612000, 0xC2000000, 0xC6A00038, 0x58380002, 0xCA8000F8, 0x46250000, 0x840000E8,
+ 0xC2400000, 0xC6A60078, 0x466D0000, 0x880000DA, 0xC2400000, 0xC6A40078, 0x58380008, 0xCA8000F8,
+ 0x46E50000, 0x880000BA, 0x00000000, 0xA6820018, 0x00000000, 0xC7700B00, 0xA6840098, 0x00000000,
+ 0xC7700A00, 0x80000080, 0xC7700200, 0xC000693C, 0xCAC000F8, 0x80000060, 0xC7700300, 0xC000693C,
+ 0xCAC000F8, 0x80000040, 0xC7700900, 0x80000030, 0xC7700800, 0x80000020, 0xC7700700, 0x80000010,
+ 0xC7700500, 0xC0006944, 0xCF0000F8, 0xC000693E, 0xCEC000F8, 0xC0006938, 0xCA4000F8, 0xC000693C,
+ 0xCB8000F8, 0xC000693E, 0xCB4000F8, 0xC3000000, 0x6E608000, 0x6E544000, 0x42150000, 0x5A209800,
+ 0x5AA00008, 0x58200004, 0xCB000078, 0xC0006934, 0xCA0000F8, 0xC2400000, 0xC0006930, 0xCA42E008,
+ 0xC3C00018, 0xA6020098, 0x00000000, 0x43656000, 0x47AD0000, 0x88000050, 0x46F96000, 0x6EE04010,
+ 0x5BE00004, 0xC2000000, 0xC6E00008, 0x5E200000, 0x84000042, 0x5BFC0002, 0x80000030, 0xC3C00004,
+ 0x5A2C0008, 0x47A10000, 0x88000012, 0x5FB80008, 0x6FE04000, 0x42390000, 0x47212000, 0x88000068,
+ 0xC2400000, 0xC0006930, 0xCA42E008, 0xC2060002, 0xC68000F8, 0xCE006300, 0x6FE04000, 0x4721C000,
+ 0x5F700010, 0x4765A000, 0xC2000000, 0xC6340008, 0xC25A000A, 0xC000691A, 0xCA401C18, 0xC2800000,
+ 0xC0006932, 0xCA8000D8, 0xC000ABDE, 0xCA400060, 0x6FA04010, 0x42290000, 0xC000691E, 0xCE0000F8,
+ 0xC7E41048, 0xC000691C, 0xCE4000F8, 0x6FE04000, 0x43A1C000, 0xC000693C, 0xCF8000F8, 0xC000693E,
+ 0xCF4000F8, 0xC000693A, 0xCFC000F8, 0x80000008, 0x00000000, 0x00000000, 0x00000000, 0xC2000000,
+ 0xDCE000F8, 0xA622FFD8, 0xC1220002, 0xD90C00F8, 0xC0006938, 0xCBC000F8, 0xC0006944, 0xCB4000F8,
+ 0xC000ABDE, 0xCB0000F8, 0xC0006934, 0xCA0000F8, 0x6FF88000, 0x6FD44000, 0x4395C000, 0x5BB89800,
+ 0xA6020268, 0xC2400000, 0x58380008, 0xCA406000, 0xDFE800F8, 0xC2218E08, 0x5A21BAF6, 0x46A14000,
+ 0x84000022, 0xC2080002, 0x7361A000, 0x80000058, 0x5E640000, 0x84000022, 0xC20C0002, 0x7361A000,
+ 0x80000030, 0xC2000000, 0xC760E710, 0xC7604218, 0x5E200000, 0x84000272, 0xC2200002, 0xC0006930,
+ 0xCE021000, 0x99005FD8, 0xC0009DE8, 0xC94000F8, 0xC1800002, 0x58380000, 0xCA0000F8, 0x00000000,
+ 0x00000000, 0xA6000132, 0xC0006940, 0xCA8000F8, 0xC0006942, 0xCA4000F8, 0xC7600078, 0xC6A01838,
+ 0xC6601038, 0xC000693A, 0xCA4000F8, 0xC0006934, 0xCA8000F8, 0xC000AB40, 0x40300000, 0x40240000,
+ 0x5C000004, 0x5EC0ABC0, 0x88000012, 0x5C000080, 0xCE0000F8, 0x58000002, 0x5EC0ABC0, 0x88000012,
+ 0x5C000080, 0xCE8000F8, 0xC000693E, 0xCA0000F8, 0xC2400000, 0x5838000C, 0xCE4000F8, 0x99005FD8,
+ 0xC0009DF0, 0xC94000F8, 0xC61800F8, 0xC0006930, 0xC6100078, 0xCD000078, 0x800000A8, 0xC2400002,
+ 0x58380008, 0xCE400000, 0xC0006944, 0xCF4000F8, 0x80000278, 0xC000693C, 0xCA4000F8, 0xDFE800F8,
+ 0x5A300018, 0xC000AB40, 0x40200000, 0xCA0000F8, 0x58380008, 0xC6501078, 0xCD021078, 0x5838000A,
+ 0xCE8000F8, 0x58380026, 0xCE0000F8, 0xC0006944, 0xCF4000F8, 0x99005338, 0xC000691C, 0xC1400000,
+ 0xC9420048, 0x80000038, 0x00000000, 0x99005FD8, 0xC0009DE6, 0xC94000F8, 0xC1800002, 0x8000FDD8,
+ 0xC2000000, 0xC2400020, 0xDF600038, 0xB624FFEA, 0xC000691C, 0xCA4000F8, 0xC000691E, 0xCA8000F8,
+ 0x99005560, 0xDA5800F8, 0xDA9800F9, 0x00000000, 0xC0006934, 0xCA0000F8, 0x00000000, 0xC2800000,
+ 0xA6020160, 0xC2400004, 0xC2000080, 0xDF690048, 0x46294000, 0x46A54000, 0x8800FFDA, 0x00000000,
+ 0xC000691A, 0xC98000F8, 0xC000ABDE, 0xC94000F8, 0x6D9C6000, 0x45D8E000, 0x59DC9F00, 0x990053C0,
+ 0xD95800F8, 0xD99800F9, 0xD9D400F8, 0x99005338, 0xC000691C, 0xC1400000, 0xC9420048, 0xC2000000,
+ 0xC2400020, 0xDF600038, 0xB624FFEA, 0xC000691C, 0xCA4000F8, 0xC000691E, 0xCA8000F8, 0x99005560,
+ 0xDA5800F8, 0xDA9800F9, 0x00000000, 0x58380008, 0xCA4000F8, 0xC2000000, 0xCE000018, 0xC2A1FFFE,
+ 0x5AA9FFFE, 0xCE021078, 0x5838000A, 0xCE8000F8, 0xC161FFFE, 0x5955FFFE, 0x14140000, 0x00000000,
+ 0xC000E838, 0xC2500002, 0xCE450800, 0xC000ABC8, 0xCB8400F8, 0xC2000000, 0xC000E82C, 0xCA040038,
+ 0x5FB80002, 0xC000ABC8, 0xCF8400F8, 0x58880002, 0xB6080018, 0x00000000, 0xC0800000, 0xC000ABC4,
+ 0xCC8400F8, 0x00000000, 0xC121FFFE, 0x5911FE94, 0x14100000, 0x8000E350, 0xC2000000, 0xDF600038,
+ 0x5E200020, 0x8400026A, 0x00000000, 0xC161FFFE, 0x5955FFFE, 0x14140000, 0x00000000, 0xC000402C,
+ 0xCA0000F8, 0xC0006910, 0xCA4000F8, 0xC000692C, 0xCA8000F8, 0xC0006968, 0xCAC000F8, 0x00000000,
+ 0xC121FFFE, 0x5911FE94, 0x14100000, 0x76250000, 0x76290000, 0x76E16000, 0x840001C2, 0xC0006926,
+ 0xCA4000F8, 0xC201FFFE, 0x76E16000, 0x5A640002, 0x6AE50010, 0x5F200000, 0x8400001A, 0x6A250000,
+ 0x80000010, 0xC6E000F8, 0x62014008, 0xC0006926, 0xCE8000F8, 0xC161FFFE, 0x5955FFFE, 0x14140000,
+ 0x00000000, 0xC0006968, 0xCA4000F8, 0xC2000002, 0x6A290000, 0x7E010000, 0x76612000, 0xCE4000F8,
+ 0x00000000, 0xC121FFFE, 0x5911FE94, 0x14100000, 0x6EB4A000, 0x6E944000, 0x4755A000, 0x4769A000,
+ 0x5B747400, 0x58340002, 0xC2000000, 0xCA0000D8, 0x5834002E, 0xC2400000, 0xCA400078, 0x6EB0A000,
+ 0x6EBC4000, 0x473D8000, 0x47298000, 0x5B30342E, 0x5B300004, 0x6E642000, 0x4225E000, 0xC39A8024,
+ 0xC7380060, 0xC6B81C18, 0x99005560, 0xDB9800F8, 0xDBD800F9, 0x00000000, 0xC2000000, 0xDF600038,
+ 0x5E200020, 0x840002A2, 0x00000000, 0xC161FFFE, 0x5955FFFE, 0x14140000, 0x00000000, 0xC000690E,
+ 0xCA0000F8, 0xC000692A, 0xCA4000F8, 0xC000696A, 0xCB0000F8, 0xC0006956, 0xCAC000F8, 0x00000000,
+ 0xC121FFFE, 0x5911FE94, 0x14100000, 0x77218000, 0x77258000, 0x84000202, 0xC201FFFE, 0x77218000,
+ 0x5AEC0002, 0x6B2D0010, 0x5EA00000, 0x8400001A, 0x6A2D0000, 0x80000010, 0xC72000F8, 0x62016008,
+ 0xC0006956, 0xCEC000F8, 0xC161FFFE, 0x5955FFFE, 0x14140000, 0x00000000, 0xC000696A, 0xCA4000F8,
+ 0xC2000002, 0x6A2D0000, 0x7E010000, 0x76612000, 0xCE4000F8, 0x00000000, 0xC121FFFE, 0x5911FE94,
+ 0x14100000, 0x6EF4A000, 0x6ED44000, 0x4755A000, 0x476DA000, 0x5B747400, 0x5834000E, 0xC2000000,
+ 0xCA0000D8, 0x58340008, 0xC2400000, 0xCA420078, 0x5834000C, 0xC2800000, 0xCA832010, 0x6E644010,
+ 0x42250000, 0x4229E000, 0xC39A8008, 0x58340008, 0xCB809018, 0x58340008, 0xC2800000, 0xCA810010,
+ 0x6EE0A000, 0x6EE44000, 0x46250000, 0x462D0000, 0x5A200008, 0x5A203408, 0x42290000, 0xC6380060,
+ 0xC6F81C18, 0x99005560, 0xDB9800F8, 0xDBD800F9, 0x00000000, 0xC000695A, 0xC84000F8, 0x00000000,
+ 0xC3C00002, 0x787C2000, 0xCC4000F8, 0xC0004030, 0xCA0000F8, 0xC2400008, 0x6A452000, 0x76250000,
+ 0x84000E02, 0xC000EA28, 0xC3800000, 0xCB840038, 0xC000EA14, 0xC3400000, 0xCB440038, 0xC0009F70,
+ 0xCB0400F8, 0xB7B4005A, 0x5804F802, 0xCAC000F8, 0xA7000060, 0x00000000, 0x00000000, 0xA6C8DD30,
+ 0xC2800000, 0xC6E80018, 0x80000070, 0x00000000, 0x00000000, 0x00000000, 0x8000DCF8, 0x00000000,
+ 0xC2800000, 0xC7282018, 0xC000690E, 0xCA4000F8, 0x6BE9E000, 0x00000000, 0x767D2000, 0x8400DCB0,
+ 0x6EA0A000, 0x6E944000, 0x46150000, 0x46290000, 0x5A207400, 0x5820000C, 0xCA0000F8, 0xC0006946,
+ 0xCE8000F8, 0xA6220368, 0x00000000, 0xC2200060, 0xC0006948, 0xCE000008, 0xCE021038, 0xC240000A,
+ 0xC000694A, 0xCE4000F8, 0xC2B60002, 0xC0006964, 0xCE837B00, 0x99005830, 0xC0009F74, 0xC88400F8,
+ 0x00000000, 0xC0006946, 0xCBC000F8, 0x00000000, 0x00000000, 0x6FF8A000, 0x6FD44000, 0x4795C000,
+ 0x47BDC000, 0x5BB87400, 0x990055F0, 0xDBD800F8, 0xDB9800F9, 0x00000000, 0x99005338, 0xC000691C,
+ 0xC1400000, 0xC9420048, 0xC000691C, 0x990057E8, 0xC94000F9, 0xC98000F8, 0x00000000, 0x99005560,
+ 0xD95800F8, 0xD99800F9, 0x00000000, 0xC161FFFE, 0x5955FFFE, 0x14140000, 0x00000000, 0x99005228,
+ 0xDBD800F8, 0xDB9800F9, 0xC7D800F8, 0x00000000, 0xC121FFFE, 0x5911FE94, 0x14100000, 0x6FF8A000,
+ 0x6FD44000, 0x4795C000, 0x47BDC000, 0x5BB87400, 0x58380010, 0xCA0000F8, 0xC000ABE0, 0xC80400F8,
+ 0x6C908000, 0x45088000, 0x45088000, 0x40100000, 0xCA4000F8, 0xC43400F8, 0x00000000, 0xC74000F8,
+ 0xCE0000F8, 0xC161FFFE, 0x5955FFFE, 0x14140000, 0x00000000, 0xC000690E, 0xCA4000F8, 0xC2800002,
+ 0x6ABD4000, 0x72692000, 0xCE4000F8, 0x00000000, 0xC121FFFE, 0x5911FE94, 0x14100000, 0x99005FD8,
+ 0xC0009DF6, 0xC94000F8, 0xC1800002, 0x00000000, 0x00000000, 0x00000000, 0xA8E2FFE8, 0x00000000,
+ 0xC1220002, 0xD90C00F8, 0xC2000000, 0xC000EA14, 0xCA040038, 0xC000EA28, 0xC2500002, 0xCE450800,
+ 0x58880002, 0xB6080018, 0xC0009F74, 0xC0800000, 0xCC8400F8, 0x8000D900, 0xC0006946, 0xCBC000F8,
+ 0xC161FFFE, 0x5955FFFE, 0x14140000, 0x00000000, 0xC000690E, 0xCA4000F8, 0xC2800002, 0x6ABD4000,
+ 0x72692000, 0xCE4000F8, 0x00000000, 0xC121FFFE, 0x5911FE94, 0x14100000, 0x6FF8A000, 0x6FD44000,
+ 0x4795C000, 0x47BDC000, 0x5BB87400, 0x58380008, 0xCA0000F8, 0x5838000C, 0xCA4000F8, 0xC3400000,
+ 0xC6340000, 0xC000694E, 0xCF4000F8, 0xC2800000, 0xC62A0078, 0xC3000000, 0xC6308018, 0x6F304000,
+ 0x43298000, 0xC000693C, 0xCF0000F8, 0xC2C00000, 0xC66C0078, 0xC0006950, 0xCEC000F8, 0xC2800000,
+ 0xC66AE020, 0xC0006954, 0xCE8000F8, 0x5F740000, 0x840001A0, 0x5E300028, 0x46E12000, 0x8400016A,
+ 0x46E12000, 0x88000132, 0x5E300018, 0x46E12000, 0x8800002A, 0x46E12000, 0x84000042, 0x00000000,
+ 0x800000C0, 0x00000000, 0x99005970, 0xDBD800F8, 0xDB9800F9, 0xC78000F8, 0xC3400002, 0xC000694E,
+ 0xCF4000F8, 0xC161FFFE, 0x5955FFFE, 0x14140000, 0x00000000, 0xC000690E, 0xCA4000F8, 0xC2800002,
+ 0x6ABD4000, 0x7E814000, 0x76692000, 0xCE4000F8, 0x00000000, 0xC121FFFE, 0x5911FE94, 0x14100000,
+ 0xC2200060, 0xC0006948, 0xCE021038, 0xC2000000, 0xC000694C, 0xCE0000F8, 0x80000080, 0x00000000,
+ 0x99005970, 0xDBD800F8, 0xDB9800F9, 0xC78000F8, 0x99005B70, 0xDBD800F8, 0xDB9800F9, 0xC78000F8,
+ 0xC2200058, 0xC0006948, 0xCE021038, 0xC2000002, 0xC000694C, 0xCE0000F8, 0xC2000006, 0xC000F006,
+ 0xCE0000F8, 0x5838000A, 0xCA4000F8, 0xC2200982, 0x5A203B6E, 0xC000F008, 0xCE0000F8, 0xC000F00A,
+ 0xCE4000F8, 0xC0006954, 0xCA8000F8, 0xC200000C, 0xC000694A, 0xCE0000F8, 0xC0006948, 0xCE800008,
+ 0xC2B60000, 0xC0006964, 0xCE8000F8, 0x99005830, 0xC0009F74, 0xC88400F8, 0x00000000, 0xC0006946,
+ 0xCBC000F8, 0xC000694C, 0xCA0000F8, 0x6FF8A000, 0x6FD44000, 0x4795C000, 0x47BDC000, 0x5BB87400,
+ 0x5E200000, 0x840000FA, 0x00000000, 0x990055F0, 0xDBD800F8, 0xDB9800F9, 0x00000000, 0x99005338,
+ 0xC000691C, 0xC1400000, 0xC9420048, 0xC000691C, 0x990057E8, 0xC94000F9, 0xC98000F8, 0x00000000,
+ 0x99005560, 0xD95800F8, 0xD99800F9, 0x00000000, 0xC161FFFE, 0x5955FFFE, 0x14140000, 0x00000000,
+ 0x99005228, 0xDBD800F8, 0xDB9800F9, 0xC7D800F8, 0x00000000, 0xC121FFFE, 0x5911FE94, 0x14100000,
+ 0xC000693C, 0xCA8000F8, 0xC000694E, 0xCAC000F8, 0xC3000018, 0xC3400006, 0x5E200000, 0x8400002A,
+ 0xC2800000, 0xC2C00000, 0xC300001E, 0xC3400000, 0xC6AC1078, 0xC72C0418, 0xC76C0810, 0x58380010,
+ 0xCA8000F8, 0x58380008, 0xCEC000F8, 0xC6280100, 0xC000ABE0, 0xC80400F8, 0x6C908000, 0x45088000,
+ 0x45088000, 0x40100000, 0xCB0000F8, 0xC43400F8, 0x00000000, 0xC74000F8, 0xCE8000F8, 0xC0006952,
+ 0xCE8000F8, 0x00000000, 0x00000000, 0x00000000, 0xA8E2FFE8, 0x00000000, 0xC000694C, 0xCA0000F8,
+ 0xC0006950, 0xCAC000F8, 0x5E200000, 0x8400006A, 0xDFE800F8, 0x7E814000, 0x5834001A, 0xCE8000F8,
+ 0x99005FD8, 0xC0009DF4, 0xC94000F8, 0xC1800002, 0x99005FD8, 0xC0009DF8, 0xC94000F8, 0xC6D800F8,
+ 0xC1220002, 0xD90C00F8, 0x5E200000, 0x84000040, 0x5838002C, 0xCB0000F8, 0xDFE800F8, 0x00000000,
+ 0x58380014, 0xCF0000F8, 0x80000018, 0xC2A1FFFE, 0x5AA9FFFE, 0x5838000A, 0xCE8000F8, 0xC3000000,
+ 0xC000EA14, 0xCB040038, 0xC2D00002, 0xC000EA28, 0xCEC50800, 0xC000694E, 0xCA8000F8, 0x58880002,
+ 0xB4B00018, 0xC0009F74, 0xC0800000, 0xCC8400F8, 0x5EA80000, 0x84000152, 0x5E200000, 0x84000140,
+ 0xC000693C, 0xCA8000F8, 0x00000000, 0x00000000, 0x5AA80060, 0xCE8000F8, 0x99005970, 0xDBD800F8,
+ 0xDB9800F9, 0xC78000F8, 0x99005B70, 0xDBD800F8, 0xDB9800F9, 0xC78000F8, 0xC0006952, 0xCAC000F8,
+ 0x58380000, 0xCA8000F8, 0xC30C0002, 0xC7F00018, 0xA6800098, 0x00000000, 0x00000000, 0xC161FFFE,
+ 0x5955FFFE, 0x14140000, 0x00000000, 0xC000F800, 0xCA0000F8, 0x00000000, 0x00000000, 0xA60CFFEA,
+ 0xC6F00500, 0xC6B0C400, 0xCF0000F8, 0x00000000, 0xC121FFFE, 0x5911FE94, 0x14100000, 0x8000CFB0,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8000CF48, 0xDCBC00F9, 0x5FFC0000, 0x84000052,
+ 0xC3800002, 0xDB8800F9, 0x5FFC0004, 0x8400C86A, 0xC3800000, 0xDB8800F9, 0xC3CE0002, 0xC000E800,
+ 0xCFC0E700, 0xC3E1FFFE, 0x597DFFFE, 0x593DFE14, 0x94000001, 0x00000000, 0x00000000, 0x00000000,
+ 0xC000ABE8, 0xC80400F8, 0x00000000, 0x00000000, 0x40080000, 0xCBC000F8, 0xC43800F8, 0x00000000,
+ 0xC000402E, 0xCA0000F8, 0xC000ABD8, 0xCB4400F8, 0x00000000, 0x00000000, 0x47610000, 0x880000B0,
+ 0x00000000, 0xA7C00048, 0xC000ABD4, 0xC1000002, 0xCD0400F8, 0xC11C0000, 0xC000E82C, 0xCD05CE00,
+ 0x800000D8, 0x00000000, 0xA7D20120, 0x00000000, 0xC7E14040, 0xC2400000, 0xC6246028, 0xC200006A,
+ 0x46250000, 0xC6240030, 0xC000E810, 0xCE440030, 0x8000FF70, 0xC2000000, 0xC000E808, 0xCA040010,
+ 0xC11C0000, 0xC000E82C, 0xCD05CE00, 0x5A200002, 0x5E600010, 0x84000010, 0xC2000000, 0xC000E808,
+ 0xCE040010, 0xC3400000, 0x80000010, 0x5B740002, 0xC000ABD8, 0xCF4400F8, 0x99004F78, 0xC000ABC8,
+ 0xC94400F8, 0xC1800000, 0xC11C0002, 0xC000E82C, 0xCD05CE00, 0x80000600, 0x5B740002, 0xC000ABD8,
+ 0xCF4400F8, 0xC78000F8, 0xC13C0002, 0xCD03DE00, 0xC000ABC8, 0xC94400F8, 0xC1800000, 0xC000E82C,
+ 0xC9840038, 0x59540002, 0xC000ABC8, 0xCD4400F8, 0x58880002, 0xB4980580, 0x00000000, 0xC0800000,
+ 0x80000568, 0xC000ABE8, 0xC80400F8, 0x00000000, 0x00000000, 0x40080000, 0xCBC000F8, 0xC42800F8,
+ 0x00000000, 0xA7C00130, 0xC000ABCC, 0xCA0400F8, 0xC2400000, 0xC000FAEC, 0xCA440018, 0x5A200002,
+ 0xC000ABCC, 0xCE0400F8, 0xB624008A, 0xC68000F8, 0xC13C0002, 0xCD03DE00, 0xC000ABC8, 0xC94400F8,
+ 0xC1800000, 0xC000E82C, 0xC9840038, 0x59540002, 0xC000ABC8, 0xCD4400F8, 0x58880002, 0xB4980470,
+ 0x00000000, 0xC0800000, 0x80000458, 0xC000ABD4, 0xC1000004, 0xCD0400F8, 0xC000E820, 0xC2000002,
+ 0xCE0400F8, 0xC2000000, 0xC000ABCC, 0xCE0400F8, 0xC000ABD8, 0xCE0400F8, 0x8000FF28, 0xC000ABD4,
+ 0xC1000000, 0xCD0400F8, 0xC11C0000, 0xC000E82C, 0xCD05CE00, 0x99004F78, 0xC000ABC8, 0xC94400F8,
+ 0xC1800000, 0xC1200000, 0xC000E818, 0xCD061000, 0xC11C0002, 0xC000E82C, 0xCD05CE00, 0xC2000000,
+ 0xC000ABCC, 0xCE0400F8, 0x80000358, 0xC000FAC0, 0xCB8400F8, 0xC000ABE8, 0xC80400F8, 0x00000000,
+ 0x00000000, 0x40080000, 0xCBC000F8, 0xC42800F8, 0x00000000, 0x00000000, 0xC68000F8, 0xC13C0000,
+ 0xCD03DE00, 0xA780024A, 0x00000000, 0x00000000, 0xA7C0020A, 0x00000000, 0xC000FB60, 0xC2060006,
+ 0xCE046308, 0xA7E801C2, 0x00000000, 0xC000ABD0, 0xCA0400F8, 0xC2400000, 0xC000FAEC, 0xCA448018,
+ 0x5A200002, 0xC000ABD0, 0xCE0400F8, 0xB62400AA, 0x00000000, 0xC68000F8, 0xC13C0002, 0xCD03DE00,
+ 0xC000FACC, 0xC2000002, 0xCE040000, 0xC000ABC8, 0xC94400F8, 0xC1800000, 0xC000E82C, 0xC9840038,
+ 0x59540002, 0xC000ABC8, 0xCD4400F8, 0x58880002, 0xB49801C8, 0x00000000, 0xC0800000, 0x800001B0,
+ 0xC000ABD4, 0xC1000000, 0xCD0400F8, 0xC11C0000, 0xC000E82C, 0xCD05CE00, 0x99004F78, 0xC000ABC8,
+ 0xC94400F8, 0xC1800000, 0xC2000000, 0xC000E820, 0xCE0400F8, 0xC1200000, 0xC000E818, 0xCD061000,
+ 0xC11C0002, 0xC000E82C, 0xCD05CE00, 0xC000ABD0, 0xCE0400F8, 0xC2000002, 0xC000FACC, 0xCE040008,
+ 0x800000E8, 0xC2000002, 0xC000ABD0, 0xCE0400F8, 0x8000FE88, 0xC2000000, 0xC000ABD0, 0xCE0400F8,
+ 0xA7E60032, 0x00000000, 0xC2000002, 0xC000FB60, 0xCE040000, 0x8000FE70, 0x00000000, 0xA7860052,
+ 0x00000000, 0xC68000F8, 0xC13C0002, 0xCD03DE00, 0xC2020002, 0xC7E2A540, 0xC000FB60, 0xCE0400F8,
+ 0x8000FE18, 0xC2040002, 0xC000FB60, 0xCE044200, 0x8000FDF8, 0xC2C80002, 0x6AC56000, 0xDACC00F8,
+ 0xC000ABD4, 0xCB4400F8, 0xC000ABC8, 0xCB8400F8, 0xC000E838, 0xC3C00000, 0xCBC40038, 0x5EF40004,
+ 0x84000022, 0xC3000000, 0xC000FACC, 0xCF042100, 0x47F98000, 0x8400002A, 0x47F98000, 0x88000030,
+ 0xC1006E8C, 0x8000BCB8, 0xC000ABC0, 0xCC8400F8, 0x8000F6C8, 0xC000FAC0, 0xCAC400F8, 0xC000ABD4,
+ 0xCB4400F8, 0xA6C0FBD2, 0x00000000, 0x5EF40000, 0x8400F722, 0x5EF40002, 0x8400F99A, 0x5EF40004,
+ 0x8400FB9A, 0xC1006CE8, 0x8000BC30, 0x00000000, 0xC0800000, 0xDF4B0038, 0xC0006900, 0xCB8000F8,
+ 0xC2000000, 0xC000690A, 0xA78000D0, 0xCBC000F8, 0xC1000000, 0xD90000F9, 0xC1000002, 0xD90C00F8,
+ 0x6FF46000, 0x477DA000, 0x5B749F00, 0xC2400000, 0x58340004, 0xCA400078, 0xC0006900, 0xCE000000,
+ 0x5A640002, 0x58340004, 0xC6500078, 0xCD000078, 0xC0006914, 0xCA4000F8, 0xC2000002, 0x6A3D0000,
+ 0x72612000, 0xCE4000F8, 0xC000E408, 0xCE0000F8, 0xA78200D8, 0xC0006908, 0xCBC000F8, 0xC1000000,
+ 0xD90000F9, 0xC1000002, 0xD90C00F8, 0x6FF4A000, 0x6FD44000, 0x4755A000, 0x477DA000, 0x5B747400,
+ 0xC2800000, 0x58340006, 0xCA800078, 0xC2000000, 0xC0006900, 0xCE002100, 0x5EA80002, 0x58340006,
+ 0xC6900078, 0xCD000078, 0x5A7C0020, 0xC2000002, 0x6A250000, 0xC000E408, 0xCE0000F8, 0xDCA800F9,
+ 0x5EA80000, 0x8400BAA0, 0x00000000, 0xA4800230, 0x00000000, 0xC3C00000, 0xC000F418, 0xCBC00018,
+ 0xC3400000, 0xC2400000, 0x6FF86000, 0x47BDC000, 0x5BB89F00, 0x58380008, 0xCB400078, 0x58380006,
+ 0xCA400078, 0x5F740002, 0x58380008, 0xC7500078, 0xCD000078, 0xC2000000, 0x58380004, 0xCA020078,
+ 0xC3000000, 0x5838000C, 0xCB000020, 0x5A640002, 0x46610000, 0x84000010, 0xC2400000, 0x58380006,
+ 0xC6500078, 0xCD000078, 0xC2000000, 0x5838000A, 0xCA020078, 0x5B300002, 0x5838000C, 0xC7100020,
+ 0xCD000020, 0xC2420020, 0x5A200004, 0x46252000, 0x84000010, 0xC2000000, 0x5838000A, 0xC6101078,
+ 0xCD021078, 0xC0006966, 0xCA4000F8, 0xC2000002, 0x6A3D0000, 0x72612000, 0xCE4000F8, 0x5F740000,
+ 0x84000040, 0xC0006912, 0xCA0000F8, 0xC2C00002, 0x6AFD6000, 0x7EC16000, 0x762D0000, 0xCE0000F8,
+ 0x5F300020, 0x84000040, 0xC0006924, 0xCA0000F8, 0xC2C00002, 0x6AFD6000, 0x7EC16000, 0x762D0000,
+ 0xCE0000F8, 0xA4820070, 0xC2400000, 0xC000F418, 0xCA408018, 0xC2000002, 0xC0006900, 0xCE000000,
+ 0xC000690A, 0xCE4000F8, 0xC1000000, 0xD90000F9, 0xD8400078, 0xC1000004, 0xD90000F9, 0xA4840270,
+ 0x00000000, 0xC3C00000, 0xC000F418, 0xCBC10018, 0xC2800000, 0xC2000000, 0x6FF8A000, 0x6FD44000,
+ 0x4795C000, 0x47BDC000, 0x5BB87400, 0x5838002E, 0xCA800078, 0x58380006, 0xCA020078, 0xC3400000,
+ 0x5838002E, 0xCB420078, 0x5AA80002, 0x46A10000, 0x84000010, 0xC2800000, 0x5838002E, 0xC6900078,
+ 0xCD000078, 0x5F740002, 0x5838002E, 0xC7501078, 0xCD021078, 0xC0006968, 0xCA4000F8, 0xC2000002,
+ 0x6A3D0000, 0x72612000, 0xCE4000F8, 0xC000692A, 0xCA8000F8, 0x5E740000, 0x84000040, 0xC0006910,
+ 0xCA0000F8, 0xC2C00002, 0x6AFD6000, 0x7EC16000, 0x762D0000, 0xCE0000F8, 0x6ABD4010, 0xA68000BA,
+ 0x00000000, 0x58380032, 0xCA0000F8, 0x58000002, 0xCA4000F8, 0x5838000C, 0x00000000, 0xCE0000F9,
+ 0xCE4000F8, 0xC000692A, 0xCA0000F8, 0xC2C00002, 0x6AFD6000, 0x722D0000, 0xCE0000F8, 0xC000692C,
+ 0xCA0000F8, 0xC2C00002, 0x6AFD6000, 0x722D0000, 0xCE0000F8, 0x80000040, 0xC000692C, 0xCA0000F8,
+ 0xC2C00002, 0x6AFD6000, 0x7EC16000, 0x762D0000, 0xCE0000F8, 0xA4880120, 0xC2C00000, 0xC000F418,
+ 0xCAC20018, 0xC000690E, 0xCA4000F8, 0xC2000002, 0x6A2D0000, 0x7E010000, 0x76612000, 0xCE4000F8,
+ 0xC000696A, 0xCA4000F8, 0xC2000002, 0x6A2D0000, 0x72612000, 0xCE4000F8, 0x6EF0A000, 0x6ED44000,
+ 0x47158000, 0x472D8000, 0x5B307400, 0x58300000, 0xCA0000F8, 0x00000000, 0xC2400002, 0x76612000,
+ 0x8400004A, 0xC24C0002, 0xC6E40018, 0xC624C400, 0x58300010, 0xCA400500, 0x00000000, 0xC000F800,
+ 0xCE4000F8, 0xA4860070, 0xC2400000, 0xC000F418, 0xCA418018, 0xC2020002, 0xC0006900, 0xCE002100,
+ 0xC0006908, 0xCE4000F8, 0xC1000000, 0xD90000F9, 0xD8400078, 0xC1000004, 0xD90000F9, 0xC000F414,
+ 0xCC8000F8, 0xC10E0002, 0xD90C00F8, 0x8000EDF0, 0xDFBC00F9, 0xC000696E, 0x99005C80, 0xC94000F8,
+ 0xC7D800F8, 0x00000000, 0xC57000F8, 0x5EF00020, 0x88000148, 0x6F346000, 0x4771A000, 0x5B749F00,
+ 0x58340008, 0xC2400000, 0xCA400078, 0x00000000, 0xC2000000, 0x5A640002, 0xCE400078, 0x58340004,
+ 0xCA000078, 0x00000000, 0x00000000, 0x5E200002, 0xCE000078, 0xC0006912, 0xCA8000F8, 0xC2400002,
+ 0x6A712000, 0x72A54000, 0xCE8000F8, 0x5E200000, 0x84000052, 0xC000402A, 0xCA0000F8, 0xC000E408,
+ 0xCA8000F8, 0x76250000, 0x00000000, 0x72A14000, 0xCE8000F8, 0x80000038, 0xC0006914, 0xCA0000F8,
+ 0x7E412000, 0x00000000, 0x76250000, 0xCE0000F8, 0x800000D0, 0x6EF4A000, 0x6ED44000, 0x4755A000,
+ 0x476DA000, 0x5B747400, 0x5834002E, 0xC2400000, 0xCA420078, 0x00000000, 0xC2000000, 0x5A640002,
+ 0xC6501078, 0xCD021078, 0x58340006, 0xCA000078, 0x00000000, 0x00000000, 0x5A200002, 0xCE000078,
+ 0xC0006910, 0xCA4000F8, 0xC2000002, 0x6A2D0000, 0x72612000, 0xCE4000F8, 0xC2000002, 0x6A310000,
+ 0xC000E42A, 0xCE0000F8, 0xC1040002, 0xD90C00F8, 0x00000000, 0x8000EB60, 0x00000000, 0xC4980928,
+ 0x9D000000, 0xC5580038, 0xC000E838, 0xCD8400F8, 0xC1440080, 0xC1C06B40, 0xC55C0F80, 0xC000F00E,
+ 0x9D000000, 0xCD8000F8, 0xC000F00C, 0xCDC000F8, 0xC000ABDE, 0xC9C000F8, 0x00000000, 0x00000000,
+ 0xD9D800F9, 0xC000AB40, 0x401C0000, 0x5DC0ABC0, 0x88000012, 0x5C000080, 0xCD8000F8, 0xC1F0000A,
+ 0x715CA000, 0xDD9800F8, 0xDD9C00F9, 0x41D8E000, 0xC5D40260, 0xC000F010, 0xCD4000F8, 0x6C9C8000,
+ 0x45C8E000, 0x45C8E000, 0x59DC0004, 0xC1601260, 0xC5D40260, 0x9D000000, 0xC000F012, 0xCD4000F8,
+ 0x00000000, 0x00000000, 0xD95800F8, 0x6D586000, 0x4594C000, 0x59989F00, 0xD99800F9, 0x5818000A,
+ 0xC1800000, 0xC9800078, 0xC0007200, 0x6D5CA000, 0x401C0000, 0x40180000, 0xC94000F8, 0x58000002,
+ 0x00000000, 0xC9C000F8, 0xC0006930, 0xCD4000F8, 0xC0006932, 0xCDC000F8, 0x59980004, 0xC1C20020,
+ 0xB59C0018, 0x00000000, 0xC1800000, 0xDD9C00F9, 0x581C000A, 0xCD800078, 0x581C000C, 0xC1800000,
+ 0xC9800020, 0xC1C00002, 0xDD9400F8, 0x69D4E000, 0x5D980002, 0xCD800020, 0xC0006924, 0xC98000F8,
+ 0x00000000, 0x9D000000, 0x00000000, 0x719CC000, 0xCD8000F8, 0xC000692A, 0xC94000F8, 0xC1C00002,
+ 0x69D8E000, 0x7DC0C000, 0x7558A000, 0xCD4000F8, 0xC000692C, 0xC94000F8, 0xDD8000F9, 0x58000032,
+ 0x755CA000, 0x84000090, 0xC94000F9, 0xC98000F8, 0xDD8000F9, 0x5800000C, 0x00000000, 0xCD4000F9,
+ 0xCD8000F8, 0xC000692C, 0xC94000F8, 0xC000692A, 0xC98000F8, 0x715CA000, 0xC000692C, 0xCD4000F8,
+ 0x719CC000, 0xC000692A, 0xCD8000F8, 0x9D000000, 0x00000000, 0x00000000, 0x00000000, 0xC000ABDE,
+ 0xC98000F8, 0x00000000, 0xC1C00080, 0x4194C000, 0x459CE000, 0x88000012, 0xC5D800F8, 0xC000ABDE,
+ 0xCD8000F8, 0xC000F406, 0xC98000F8, 0xC1C00002, 0x9D000000, 0xC5D80A00, 0xC5581048, 0xCD8000F8,
+ 0xC0006930, 0xC98000F8, 0xC0006932, 0xC9C000F8, 0xC140000E, 0xC5581C18, 0xDD9400F8, 0xC000AB40,
+ 0x40140000, 0x5D40ABC0, 0x88000012, 0x5C000080, 0xCD8000F8, 0x58000002, 0x5D40ABC0, 0x88000012,
+ 0x5C000080, 0xCDC000F8, 0xDD5400F8, 0xC1C00000, 0x58140006, 0xC9C20078, 0xC1800000, 0x58140000,
+ 0xC98000D8, 0x6DDC2000, 0xC000691E, 0x41D8E000, 0xCDC000F8, 0xDD9800F8, 0xC1C00022, 0xC5D80D70,
+ 0xDD9400F9, 0xC5581C18, 0xC000691C, 0xCD8000F8, 0xDD5400F8, 0xC1C00000, 0x58140006, 0xC9C20078,
+ 0xC1800000, 0x58140004, 0xC9820078, 0x00000000, 0x59DC0002, 0x45D8C000, 0x84000010, 0xC1C00000,
+ 0x9D000000, 0x58140006, 0xC5D81078, 0xCD821078, 0xC000ABDC, 0xC94000F8, 0xC1820020, 0xC1D00002,
+ 0x5814AB00, 0xD58000F8, 0x58000002, 0xD58000F9, 0x59540004, 0xB5580018, 0xC000ABDC, 0xC1400000,
+ 0xCD4000F8, 0xDD9800F9, 0x9D000000, 0xDD9400F8, 0xC000F402, 0xCDC10800, 0xC1C00000, 0xC1800080,
+ 0x5D980004, 0xDF5D0048, 0x459CA000, 0x8800FFF2, 0xDD8000F9, 0x5800000C, 0x00000000, 0xC94000F9,
+ 0xC98000F8, 0xC1C00002, 0xC5D43F00, 0xC5D81E00, 0xC000ABDE, 0xC9C000F8, 0x00000000, 0x00000000,
+ 0x581CAB40, 0x5DC0ABC0, 0x88000012, 0x5C000080, 0xCD4000F8, 0x58000002, 0x5DC0ABC0, 0x88000012,
+ 0x5C000080, 0xCD8000F8, 0xC000ABDE, 0xC9C000F8, 0x00000000, 0xC15004C0, 0xC5D40060, 0xDD9C00F8,
+ 0xC5D41C18, 0xC1C00000, 0xDD8000F9, 0x58000030, 0xC9C00078, 0xDD8000F9, 0x58000002, 0xC98000F8,
+ 0x6DDC2000, 0xC000691C, 0x41D8E000, 0xCD4000F9, 0xCDC000F8, 0xDD9400F9, 0xC1C00000, 0x58140030,
+ 0xC9C00078, 0xC1800000, 0x58140006, 0xC9820078, 0x00000000, 0x59DC0002, 0x45D8C000, 0x84000010,
+ 0xC1C00000, 0x9D000000, 0x58140030, 0xC5D80078, 0xCD800078, 0xC1C00000, 0xDF5C0038, 0x5DDC0020,
+ 0x8400FFEA, 0x00000000, 0x9D000000, 0x00000000, 0x00000000, 0x00000000, 0xC160FFFE, 0xC000EA10,
+ 0xC9440070, 0xC1A0FFFE, 0x59983408, 0xC000F00C, 0xCD4000F8, 0xC000F00E, 0xCD8000F8, 0xC0006964,
+ 0xC98000F8, 0x00000000, 0xC170000A, 0x7158A000, 0x6C988000, 0x4588C000, 0x4588C000, 0x59980004,
+ 0xC5940270, 0xC000F010, 0xCD4000F8, 0xC0006946, 0xC94000F8, 0x00000000, 0x00000000, 0x6D58A000,
+ 0x6D5C4000, 0x459CC000, 0x4594C000, 0xC000694A, 0xC94000F8, 0xC0006948, 0xC9C000F8, 0x4194C000,
+ 0xC1400012, 0xC55C1818, 0x9D000000, 0xC59C0268, 0xC000F012, 0xCDC000F8, 0xC1400000, 0x58000012,
+ 0xC9410038, 0xC0006950, 0xC9C000F8, 0xC55800F8, 0xC5940838, 0xC5581078, 0xD99400F8, 0xC000693C,
+ 0xC94000F8, 0xC0006954, 0xC98000F8, 0x59DC00A8, 0x45D4E000, 0x41D8E000, 0x5D5C0030, 0x88000010,
+ 0xC1C00030, 0xC1800000, 0xC5D84028, 0xC1400000, 0xC5D40008, 0x5DD40002, 0x84000072, 0x5DD40004,
+ 0x8400009A, 0x5DD40006, 0x840000C2, 0x5DD80026, 0x840000EA, 0xDD5400F8, 0xDD8000F9, 0x58000008,
+ 0x40180000, 0xCD4000F8, 0x59980002, 0x8000FFC0, 0xDD5400F8, 0xDD8000F9, 0x58000008, 0x40180000,
+ 0xCD4000B8, 0x59980002, 0x8000FF88, 0xDD5400F8, 0xDD8000F9, 0x58000008, 0x40180000, 0xCD400078,
+ 0x59980002, 0x8000FF50, 0xDD5400F8, 0xDD8000F9, 0x58000008, 0x40180000, 0xCD400038, 0x59980002,
+ 0x8000FF18, 0x00000000, 0x9D000000, 0x00000000, 0x00000000, 0x00000000, 0x58000012, 0xC94000F8,
+ 0xC0006954, 0xC9C000F8, 0xC0006950, 0xC9400078, 0xDD8000F9, 0x58000028, 0x5D9C0000, 0x84000052,
+ 0x5D9C0002, 0x84000052, 0x5D9C0004, 0x8400006A, 0xC55B0038, 0xC55C08B8, 0xCD800039, 0xCDC108B8,
+ 0x80000060, 0xCD4000F8, 0x80000050, 0xC55900B8, 0xC55C1838, 0xCD8000B9, 0xCDC31838, 0x80000028,
+ 0xC55A0078, 0xC55C1078, 0xCD800079, 0xCDC21078, 0x9D000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x59540002, 0x6994E018, 0x61C0C008, 0x4194A000, 0x5D940040, 0x88000012, 0xC59400F8, 0x9D000000,
+ 0xCD4000F8, 0x00000000, 0x00000000, 0xC000697E, 0xCA4000F8, 0xC0000000, 0xC55800F8, 0xC9D400F9,
+ 0x00000000, 0x00000000, 0x79E08000, 0xCD1800F9, 0xC5D000F8, 0xC9D400F9, 0xC66000F8, 0xC52160A0,
+ 0xC5241550, 0x79E08000, 0xCD1800F9, 0xC5D000F8, 0xC9D400F9, 0xC66000F8, 0xC52160A0, 0xC5241550,
+ 0x79E08000, 0xCD1800F9, 0xC5D000F8, 0xC9D400F9, 0xC66000F8, 0xC52160A0, 0xC5241550, 0x79E08000,
+ 0xCD1800F9, 0xC5D000F8, 0xC9D400F9, 0xC66000F8, 0xC52160A0, 0xC5241550, 0x79E08000, 0xCD1800F9,
+ 0xC5D000F8, 0xC9D400F9, 0xC66000F8, 0xC52160A0, 0xC5241550, 0x79E08000, 0xCD1800F9, 0xC5D000F8,
+ 0xC9D400F9, 0xC66000F8, 0xC52160A0, 0xC5241550, 0x79E08000, 0xCD1800F9, 0xC5D000F8, 0xC9D400F9,
+ 0xC66000F8, 0xC52160A0, 0xC5241550, 0x79E08000, 0xCD1800F9, 0xC5D000F8, 0xC9D400F9, 0xC66000F8,
+ 0xC52160A0, 0xC5241550, 0x79E08000, 0xCD1800F9, 0xC5D000F8, 0xC9D400F9, 0xC66000F8, 0xC52160A0,
+ 0xC5241550, 0x79E08000, 0xCD1800F9, 0xC5D000F8, 0xC9D400F9, 0xC66000F8, 0xC52160A0, 0xC5241550,
+ 0x79E08000, 0xCD1800F9, 0xC5D000F8, 0xC9D400F9, 0xC66000F8, 0xC52160A0, 0xC5241550, 0x79E08000,
+ 0xCD1800F9, 0xC5D000F8, 0xC9D400F9, 0xC66000F8, 0xC52160A0, 0xC5241550, 0xC000697C, 0x9CC00000,
+ 0xCE0000F8, 0xC000697E, 0xCE4000F8, 0x9D000000, 0x4158A000, 0xCD4000F8, 0x00000000,
+};
+
+static u32 vr9_fw_data[] = {
+};
+
+
+#endif // IFXMIPS_ATM_FW_VR9_H
+
diff --git a/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_ppe_amazon_se.h.svn-base b/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_ppe_amazon_se.h.svn-base
new file mode 100644
index 0000000..412f605
--- /dev/null
+++ b/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_ppe_amazon_se.h.svn-base
@@ -0,0 +1,121 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_atm_ppe_amazon_se.h
+** PROJECT : UEIP
+** MODULES : ATM (ADSL)
+**
+** DATE : 1 AUG 2005
+** AUTHOR : Xu Liang
+** DESCRIPTION : ATM Driver (PPE Registers)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 4 AUG 2005 Xu Liang Initiate Version
+** 23 OCT 2006 Xu Liang Add GPL header.
+** 9 JAN 2007 Xu Liang First version got from Anand (IC designer)
+*******************************************************************************/
+
+
+
+#ifndef IFXMIPS_ATM_PPE_AMAZON_SE_H
+#define IFXMIPS_ATM_PPE_AMAZON_SE_H
+
+
+
+/*
+ * FPI Configuration Bus Register and Memory Address Mapping
+ */
+#define IFX_PPE (KSEG1 | 0x1E180000)
+#define PP32_DEBUG_REG_ADDR(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x0000) << 2)))
+#define PPM_INT_REG_ADDR(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x0030) << 2)))
+#define PP32_INTERNAL_RES_ADDR(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x0040) << 2)))
+#define CDM_CODE_MEMORY(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x1000) << 2)))
+#define PPE_REG_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x4000) << 2)))
+#define CDM_DATA_MEMORY(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x5000) << 2)))
+#define PPM_INT_UNIT_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6000) << 2)))
+#define PPM_TIMER0_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6100) << 2)))
+#define PPM_TASK_IND_REG_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6200) << 2)))
+#define PPS_BRK_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6300) << 2)))
+#define PPM_TIMER1_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6400) << 2)))
+#define SB_RAM0_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x8200) << 2)))
+#define SB_RAM1_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x8C00) << 2)))
+#define QSB_CONF_REG_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0xC000) << 2)))
+
+/*
+ * DWORD-Length of Memory Blocks
+ */
+#define PP32_DEBUG_REG_DWLEN 0x0030
+#define PPM_INT_REG_DWLEN 0x0010
+#define PP32_INTERNAL_RES_DWLEN 0x00C0
+#define CDM_CODE_MEMORYn_DWLEN(n) ((n) == 0 ? 0x1000 : 0x0800)
+#define PPE_REG_DWLEN 0x1000
+#define CDM_DATA_MEMORY_DWLEN CDM_CODE_MEMORYn_DWLEN(1)
+#define PPM_INT_UNIT_DWLEN 0x0100
+#define PPM_TIMER0_DWLEN 0x0100
+#define PPM_TASK_IND_REG_DWLEN 0x0100
+#define PPS_BRK_DWLEN 0x0100
+#define PPM_TIMER1_DWLEN 0x0100
+#define SB_RAM0_DWLEN 0x0A00
+#define SB_RAM1_DWLEN 0x0A00
+#define QSB_CONF_REG_DWLEN 0x0100
+
+/*
+ * PP32 to FPI Address Mapping
+ */
+#define SB_BUFFER(__sb_addr) ((volatile unsigned int *)((((__sb_addr) >= 0x2200) && ((__sb_addr) <= 0x2BFF)) ? SB_RAM0_ADDR((__sb_addr) - 0x2200) : \
+ (((__sb_addr) >= 0x2C00) && ((__sb_addr) <= 0x35FF)) ? SB_RAM1_ADDR((__sb_addr) - 0x2C00) : \
+ 0))
+
+/*
+ * PP32 Debug Control Register
+ */
+#define PP32_DBG_CTRL PP32_DEBUG_REG_ADDR(0, 0x0000)
+
+#define DBG_CTRL_RESTART 0
+#define DBG_CTRL_STOP 1
+
+#define PP32_HALT_STAT PP32_DEBUG_REG_ADDR(0, 0x0D00)
+#define PP32_BREAKPOINT_REASONS PP32_DEBUG_REG_ADDR(0, 0x0A00)
+
+#define PP32_BRK_SRC PP32_DEBUG_REG_ADDR(0, 0x0F00)
+
+#define PP32_DBG_CUR_PC PP32_DEBUG_REG_ADDR(0, 0x0F80)
+
+#define PP32_DBG_TASK_NO PP32_DEBUG_REG_ADDR(0, 0x0F81)
+
+/*
+ * Share Buffer
+ */
+#define SB_MST_PRI0 PPE_REG_ADDR(0x0300)
+#define SB_MST_PRI1 PPE_REG_ADDR(0x0301)
+
+/*
+ * EMA Registers
+ */
+#define EMA_CMDCFG PPE_REG_ADDR(0x0A00)
+#define EMA_DATACFG PPE_REG_ADDR(0x0A01)
+#define EMA_CMDCNT PPE_REG_ADDR(0x0A02)
+#define EMA_DATACNT PPE_REG_ADDR(0x0A03)
+#define EMA_ISR PPE_REG_ADDR(0x0A04)
+#define EMA_IER PPE_REG_ADDR(0x0A05)
+#define EMA_CFG PPE_REG_ADDR(0x0A06)
+#define EMA_SUBID PPE_REG_ADDR(0x0A07)
+
+#define EMA_ALIGNMENT 4
+
+/*
+ * Mailbox IGU1 Interrupt
+ */
+#define PPE_MAILBOX_IGU1_INT INT_NUM_IM2_IRL13
+
+
+
+#endif // IFXMIPS_ATM_PPE_AMAZON_SE_H
diff --git a/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_ppe_ar9.h.svn-base b/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_ppe_ar9.h.svn-base
new file mode 100644
index 0000000..fae0252
--- /dev/null
+++ b/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_ppe_ar9.h.svn-base
@@ -0,0 +1,188 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_atm_ppe_ar9.h
+** PROJECT : UEIP
+** MODULES : ATM (ADSL)
+**
+** DATE : 1 AUG 2005
+** AUTHOR : Xu Liang
+** DESCRIPTION : ATM Driver (PPE Registers)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 4 AUG 2005 Xu Liang Initiate Version
+** 23 OCT 2006 Xu Liang Add GPL header.
+** 9 JAN 2007 Xu Liang First version got from Anand (IC designer)
+*******************************************************************************/
+
+
+
+#ifndef IFXMIPS_ATM_PPE_AR9_H
+#define IFXMIPS_ATM_PPE_AR9_H
+
+
+
+/*
+ * FPI Configuration Bus Register and Memory Address Mapping
+ */
+#define IFX_PPE (KSEG1 | 0x1E180000)
+#define PP32_DEBUG_REG_ADDR(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x0000) << 2)))
+#define PPM_INT_REG_ADDR(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x0030) << 2)))
+#define PP32_INTERNAL_RES_ADDR(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x0040) << 2)))
+#define CDM_CODE_MEMORY(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x1000) << 2)))
+#define PPE_REG_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x4000) << 2)))
+#define CDM_DATA_MEMORY(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x5000) << 2)))
+#define PPM_INT_UNIT_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6000) << 2)))
+#define PPM_TIMER0_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6100) << 2)))
+#define PPM_TASK_IND_REG_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6200) << 2)))
+#define PPS_BRK_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6300) << 2)))
+#define PPM_TIMER1_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6400) << 2)))
+#define SB_RAM0_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x8000) << 2)))
+#define SB_RAM1_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x8800) << 2)))
+#define SB_RAM2_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x9000) << 2)))
+#define SB_RAM3_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x9800) << 2)))
+#define SB_RAM4_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0xA000) << 2)))
+#define QSB_CONF_REG_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0xC000) << 2)))
+
+/*
+ * DWORD-Length of Memory Blocks
+ */
+#define PP32_DEBUG_REG_DWLEN 0x0030
+#define PPM_INT_REG_DWLEN 0x0010
+#define PP32_INTERNAL_RES_DWLEN 0x00C0
+#define CDM_CODE_MEMORYn_DWLEN(n) 0x1000
+#define PPE_REG_DWLEN 0x1000
+#define CDM_DATA_MEMORY_DWLEN CDM_CODE_MEMORYn_DWLEN(1)
+#define PPM_INT_UNIT_DWLEN 0x0100
+#define PPM_TIMER0_DWLEN 0x0100
+#define PPM_TASK_IND_REG_DWLEN 0x0100
+#define PPS_BRK_DWLEN 0x0100
+#define PPM_TIMER1_DWLEN 0x0100
+#define SB_RAM0_DWLEN 0x0800
+#define SB_RAM1_DWLEN 0x0800
+#define SB_RAM2_DWLEN 0x0800
+#define SB_RAM3_DWLEN 0x0800
+#define SB_RAM4_DWLEN 0x0C00
+#define QSB_CONF_REG_DWLEN 0x0100
+
+/*
+ * PP32 to FPI Address Mapping
+ */
+#define SB_BUFFER(__sb_addr) ((volatile unsigned int *)((((__sb_addr) >= 0x0000) && ((__sb_addr) <= 0x0FFF)) ? PPE_REG_ADDR((__sb_addr)): \
+ (((__sb_addr) >= 0x2000) && ((__sb_addr) <= 0x27FF)) ? SB_RAM0_ADDR((__sb_addr) - 0x2000) : \
+ (((__sb_addr) >= 0x2800) && ((__sb_addr) <= 0x2FFF)) ? SB_RAM1_ADDR((__sb_addr) - 0x2800) : \
+ (((__sb_addr) >= 0x3000) && ((__sb_addr) <= 0x37FF)) ? SB_RAM2_ADDR((__sb_addr) - 0x3000) : \
+ (((__sb_addr) >= 0x3800) && ((__sb_addr) <= 0x3FFF)) ? SB_RAM3_ADDR((__sb_addr) - 0x3800) : \
+ (((__sb_addr) >= 0x4000) && ((__sb_addr) <= 0x4BFF)) ? SB_RAM4_ADDR((__sb_addr) - 0x4000) : \
+ 0))
+
+/*
+ * PP32 Debug Control Register
+ */
+#define NUM_OF_PP32 1
+
+#define PP32_DBG_CTRL(n) PP32_DEBUG_REG_ADDR(n, 0x0000)
+
+#define DBG_CTRL_RESTART 0
+#define DBG_CTRL_STOP 1
+
+#define PP32_CTRL_CMD(n) PP32_DEBUG_REG_ADDR(n, 0x0B00)
+ #define PP32_CTRL_CMD_RESTART (1 << 0)
+ #define PP32_CTRL_CMD_STOP (1 << 1)
+ #define PP32_CTRL_CMD_STEP (1 << 2)
+ #define PP32_CTRL_CMD_BREAKOUT (1 << 3)
+
+#define PP32_CTRL_OPT(n) PP32_DEBUG_REG_ADDR(n, 0x0C00)
+ #define PP32_CTRL_OPT_BREAKOUT_ON_STOP_ON (3 << 0)
+ #define PP32_CTRL_OPT_BREAKOUT_ON_STOP_OFF (2 << 0)
+ #define PP32_CTRL_OPT_BREAKOUT_ON_BREAKIN_ON (3 << 2)
+ #define PP32_CTRL_OPT_BREAKOUT_ON_BREAKIN_OFF (2 << 2)
+ #define PP32_CTRL_OPT_STOP_ON_BREAKIN_ON (3 << 4)
+ #define PP32_CTRL_OPT_STOP_ON_BREAKIN_OFF (2 << 4)
+ #define PP32_CTRL_OPT_STOP_ON_BREAKPOINT_ON (3 << 6)
+ #define PP32_CTRL_OPT_STOP_ON_BREAKPOINT_OFF (2 << 6)
+ #define PP32_CTRL_OPT_BREAKOUT_ON_STOP(n) (*PP32_CTRL_OPT(n) & (1 << 0))
+ #define PP32_CTRL_OPT_BREAKOUT_ON_BREAKIN(n) (*PP32_CTRL_OPT(n) & (1 << 2))
+ #define PP32_CTRL_OPT_STOP_ON_BREAKIN(n) (*PP32_CTRL_OPT(n) & (1 << 4))
+ #define PP32_CTRL_OPT_STOP_ON_BREAKPOINT(n) (*PP32_CTRL_OPT(n) & (1 << 6))
+
+#define PP32_BRK_PC(n, i) PP32_DEBUG_REG_ADDR(n, 0x0900 + (i) * 2)
+#define PP32_BRK_PC_MASK(n, i) PP32_DEBUG_REG_ADDR(n, 0x0901 + (i) * 2)
+#define PP32_BRK_DATA_ADDR(n, i) PP32_DEBUG_REG_ADDR(n, 0x0904 + (i) * 2)
+#define PP32_BRK_DATA_ADDR_MASK(n, i) PP32_DEBUG_REG_ADDR(n, 0x0905 + (i) * 2)
+#define PP32_BRK_DATA_VALUE_RD(n, i) PP32_DEBUG_REG_ADDR(n, 0x0908 + (i) * 2)
+#define PP32_BRK_DATA_VALUE_RD_MASK(n, i) PP32_DEBUG_REG_ADDR(n, 0x0909 + (i) * 2)
+#define PP32_BRK_DATA_VALUE_WR(n, i) PP32_DEBUG_REG_ADDR(n, 0x090C + (i) * 2)
+#define PP32_BRK_DATA_VALUE_WR_MASK(n, i) PP32_DEBUG_REG_ADDR(n, 0x090D + (i) * 2)
+ #define PP32_BRK_CONTEXT_MASK(i) (1 << (i))
+ #define PP32_BRK_CONTEXT_MASK_EN (1 << 4)
+ #define PP32_BRK_COMPARE_GREATER_EQUAL (1 << 5) // valid for break data value rd/wr only
+ #define PP32_BRK_COMPARE_LOWER_EQUAL (1 << 6)
+ #define PP32_BRK_COMPARE_EN (1 << 7)
+
+#define PP32_BRK_TRIG(n) PP32_DEBUG_REG_ADDR(n, 0x0F00)
+ #define PP32_BRK_GRPi_PCn_ON(i, n) ((3 << ((n) * 2)) << ((i) * 16))
+ #define PP32_BRK_GRPi_PCn_OFF(i, n) ((2 << ((n) * 2)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_ADDRn_ON(i, n) ((3 << ((n) * 2 + 4)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_ADDRn_OFF(i, n) ((2 << ((n) * 2 + 4)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_VALUE_RDn_ON(i, n) ((3 << ((n) * 2 + 8)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_VALUE_RDn_OFF(i, n)((2 << ((n) * 2 + 8)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_VALUE_WRn_ON(i, n) ((3 << ((n) * 2 + 12)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_VALUE_WRn_OFF(i, n)((2 << ((n) * 2 + 12)) << ((i) * 16))
+ #define PP32_BRK_GRPi_PCn(k, i, n) (*PP32_BRK_TRIG(k) & ((1 << ((n))) << ((i) * 8)))
+ #define PP32_BRK_GRPi_DATA_ADDRn(k, i, n) (*PP32_BRK_TRIG(k) & ((1 << ((n) + 2)) << ((i) * 8)))
+ #define PP32_BRK_GRPi_DATA_VALUE_RDn(k, i, n) (*PP32_BRK_TRIG(k) & ((1 << ((n) + 4)) << ((i) * 8)))
+ #define PP32_BRK_GRPi_DATA_VALUE_WRn(k, i, n) (*PP32_BRK_TRIG(k) & ((1 << ((n) + 6)) << ((i) * 8)))
+
+#define PP32_CPU_STATUS(n) PP32_DEBUG_REG_ADDR(n, 0x0D00)
+#define PP32_HALT_STAT(n) PP32_CPU_STATUS(n)
+#define PP32_DBG_CUR_PC(n) PP32_CPU_STATUS(n)
+ #define PP32_CPU_USER_STOPPED(n) (*PP32_CPU_STATUS(n) & (1 << 0))
+ #define PP32_CPU_USER_BREAKIN_RCV(n) (*PP32_CPU_STATUS(n) & (1 << 1))
+ #define PP32_CPU_USER_BREAKPOINT_MET(n) (*PP32_CPU_STATUS(n) & (1 << 2))
+ #define PP32_CPU_CUR_PC(n) (*PP32_CPU_STATUS(n) >> 16)
+
+#define PP32_BREAKPOINT_REASONS(n) PP32_DEBUG_REG_ADDR(n, 0x0A00)
+ #define PP32_BRK_PC_MET(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << (i)))
+ #define PP32_BRK_DATA_ADDR_MET(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) + 2)))
+ #define PP32_BRK_DATA_VALUE_RD_MET(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) + 4)))
+ #define PP32_BRK_DATA_VALUE_WR_MET(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) + 6)))
+ #define PP32_BRK_DATA_VALUE_RD_LO_EQ(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) * 2 + 8)))
+ #define PP32_BRK_DATA_VALUE_RD_GT_EQ(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) * 2 + 9)))
+ #define PP32_BRK_DATA_VALUE_WR_LO_EQ(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) * 2 + 12)))
+ #define PP32_BRK_DATA_VALUE_WR_GT_EQ(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) * 2 + 13)))
+ #define PP32_BRK_CUR_CONTEXT(n) ((*PP32_BREAKPOINT_REASONS(n) >> 16) & 0x03)
+
+#define PP32_GP_REG_BASE(n) PP32_DEBUG_REG_ADDR(n, 0x0E00)
+#define PP32_GP_CONTEXTi_REGn(n, i, j) PP32_DEBUG_REG_ADDR(n, 0x0E00 + (i) * 16 + (j))
+
+/*
+ * EMA Registers
+ */
+#define EMA_CMDCFG PPE_REG_ADDR(0x0A00)
+#define EMA_DATACFG PPE_REG_ADDR(0x0A01)
+#define EMA_CMDCNT PPE_REG_ADDR(0x0A02)
+#define EMA_DATACNT PPE_REG_ADDR(0x0A03)
+#define EMA_ISR PPE_REG_ADDR(0x0A04)
+#define EMA_IER PPE_REG_ADDR(0x0A05)
+#define EMA_CFG PPE_REG_ADDR(0x0A06)
+#define EMA_SUBID PPE_REG_ADDR(0x0A07)
+
+#define EMA_ALIGNMENT 4
+
+/*
+ * Mailbox IGU1 Interrupt
+ */
+#define PPE_MAILBOX_IGU1_INT INT_NUM_IM2_IRL24
+
+
+
+#endif // IFXMIPS_ATM_PPE_AR9_H
diff --git a/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_ppe_common.h.svn-base b/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_ppe_common.h.svn-base
new file mode 100644
index 0000000..ee55fd7
--- /dev/null
+++ b/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_ppe_common.h.svn-base
@@ -0,0 +1,368 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_atm_ppe_common.h
+** PROJECT : UEIP
+** MODULES : ATM (ADSL)
+**
+** DATE : 1 AUG 2005
+** AUTHOR : Xu Liang
+** DESCRIPTION : ATM Driver (PPE Registers)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 4 AUG 2005 Xu Liang Initiate Version
+** 23 OCT 2006 Xu Liang Add GPL header.
+** 9 JAN 2007 Xu Liang First version got from Anand (IC designer)
+*******************************************************************************/
+
+
+
+#ifndef IFXMIPS_ATM_PPE_COMMON_H
+#define IFXMIPS_ATM_PPE_COMMON_H
+
+
+
+#if defined(CONFIG_DANUBE)
+ #include "ifxmips_atm_ppe_danube.h"
+#elif defined(CONFIG_AMAZON_SE)
+ #include "ifxmips_atm_ppe_amazon_se.h"
+#elif defined(CONFIG_AR9)
+ #include "ifxmips_atm_ppe_ar9.h"
+#elif defined(CONFIG_VR9)
+ #include "ifxmips_atm_ppe_vr9.h"
+#else
+ #error Platform is not specified!
+#endif
+
+
+
+/*
+ * Code/Data Memory (CDM) Interface Configuration Register
+ */
+#define CDM_CFG PPE_REG_ADDR(0x0100)
+
+#define CDM_CFG_RAM1 GET_BITS(*CDM_CFG, 3, 2)
+#define CDM_CFG_RAM0 (*CDM_CFG & (1 << 1))
+
+#define CDM_CFG_RAM1_SET(value) SET_BITS(0, 3, 2, value)
+#define CDM_CFG_RAM0_SET(value) ((value) ? (1 << 1) : 0)
+
+/*
+ * QSB Internal Cell Delay Variation Register
+ */
+#define QSB_ICDV QSB_CONF_REG_ADDR(0x0007)
+
+#define QSB_ICDV_TAU GET_BITS(*QSB_ICDV, 5, 0)
+
+#define QSB_ICDV_TAU_SET(value) SET_BITS(0, 5, 0, value)
+
+/*
+ * QSB Scheduler Burst Limit Register
+ */
+#define QSB_SBL QSB_CONF_REG_ADDR(0x0009)
+
+#define QSB_SBL_SBL GET_BITS(*QSB_SBL, 3, 0)
+
+#define QSB_SBL_SBL_SET(value) SET_BITS(0, 3, 0, value)
+
+/*
+ * QSB Configuration Register
+ */
+#define QSB_CFG QSB_CONF_REG_ADDR(0x000A)
+
+#define QSB_CFG_TSTEPC GET_BITS(*QSB_CFG, 1, 0)
+
+#define QSB_CFG_TSTEPC_SET(value) SET_BITS(0, 1, 0, value)
+
+/*
+ * QSB RAM Transfer Table Register
+ */
+#define QSB_RTM QSB_CONF_REG_ADDR(0x000B)
+
+#define QSB_RTM_DM (*QSB_RTM)
+
+#define QSB_RTM_DM_SET(value) ((value) & 0xFFFFFFFF)
+
+/*
+ * QSB RAM Transfer Data Register
+ */
+#define QSB_RTD QSB_CONF_REG_ADDR(0x000C)
+
+#define QSB_RTD_TTV (*QSB_RTD)
+
+#define QSB_RTD_TTV_SET(value) ((value) & 0xFFFFFFFF)
+
+/*
+ * QSB RAM Access Register
+ */
+#define QSB_RAMAC QSB_CONF_REG_ADDR(0x000D)
+
+#define QSB_RAMAC_RW (*QSB_RAMAC & (1 << 31))
+#define QSB_RAMAC_TSEL GET_BITS(*QSB_RAMAC, 27, 24)
+#define QSB_RAMAC_LH (*QSB_RAMAC & (1 << 16))
+#define QSB_RAMAC_TESEL GET_BITS(*QSB_RAMAC, 9, 0)
+
+#define QSB_RAMAC_RW_SET(value) ((value) ? (1 << 31) : 0)
+#define QSB_RAMAC_TSEL_SET(value) SET_BITS(0, 27, 24, value)
+#define QSB_RAMAC_LH_SET(value) ((value) ? (1 << 16) : 0)
+#define QSB_RAMAC_TESEL_SET(value) SET_BITS(0, 9, 0, value)
+
+/*
+ * QSB Queue Scheduling and Shaping Definitions
+ */
+#define QSB_WFQ_NONUBR_MAX 0x3f00
+#define QSB_WFQ_UBR_BYPASS 0x3fff
+#define QSB_TP_TS_MAX 65472
+#define QSB_TAUS_MAX 64512
+#define QSB_GCR_MIN 18
+
+/*
+ * QSB Constant
+ */
+#define QSB_RAMAC_RW_READ 0
+#define QSB_RAMAC_RW_WRITE 1
+
+#define QSB_RAMAC_TSEL_QPT 0x01
+#define QSB_RAMAC_TSEL_SCT 0x02
+#define QSB_RAMAC_TSEL_SPT 0x03
+#define QSB_RAMAC_TSEL_VBR 0x08
+
+#define QSB_RAMAC_LH_LOW 0
+#define QSB_RAMAC_LH_HIGH 1
+
+#define QSB_QPT_SET_MASK 0x0
+#define QSB_QVPT_SET_MASK 0x0
+#define QSB_SET_SCT_MASK 0x0
+#define QSB_SET_SPT_MASK 0x0
+#define QSB_SET_SPT_SBVALID_MASK 0x7FFFFFFF
+
+#define QSB_SPT_SBV_VALID (1 << 31)
+#define QSB_SPT_PN_SET(value) (((value) & 0x01) ? (1 << 16) : 0)
+#define QSB_SPT_INTRATE_SET(value) SET_BITS(0, 13, 0, value)
+
+/*
+ * QSB Queue Parameter Table Entry and Queue VBR Parameter Table Entry
+ */
+#if defined(__BIG_ENDIAN)
+ union qsb_queue_parameter_table {
+ struct {
+ unsigned int res1 :1;
+ unsigned int vbr :1;
+ unsigned int wfqf :14;
+ unsigned int tp :16;
+ } bit;
+ u32 dword;
+ };
+
+ union qsb_queue_vbr_parameter_table {
+ struct {
+ unsigned int taus :16;
+ unsigned int ts :16;
+ } bit;
+ u32 dword;
+ };
+#else
+ union qsb_queue_parameter_table {
+ struct {
+ unsigned int tp :16;
+ unsigned int wfqf :14;
+ unsigned int vbr :1;
+ unsigned int res1 :1;
+ } bit;
+ u32 dword;
+ };
+
+ union qsb_queue_vbr_parameter_table {
+ struct {
+ unsigned int ts :16;
+ unsigned int taus :16;
+ } bit;
+ u32 dword;
+ };
+#endif // defined(__BIG_ENDIAN)
+
+/*
+ * Mailbox IGU0 Registers
+ */
+#define MBOX_IGU0_ISRS PPE_REG_ADDR(0x0200)
+#define MBOX_IGU0_ISRC PPE_REG_ADDR(0x0201)
+#define MBOX_IGU0_ISR PPE_REG_ADDR(0x0202)
+#define MBOX_IGU0_IER PPE_REG_ADDR(0x0203)
+
+#define MBOX_IGU0_ISRS_SET(n) (1 << (n))
+#define MBOX_IGU0_ISRC_CLEAR(n) (1 << (n))
+#define MBOX_IGU0_ISR_ISR(n) (*MBOX_IGU0_ISR & (1 << (n)))
+#define MBOX_IGU0_IER_EN(n) (*MBOX_IGU0_IER & (1 << (n)))
+#define MBOX_IGU0_IER_EN_SET(n) (1 << (n))
+
+/*
+ * Mailbox IGU1 Registers
+ */
+#define MBOX_IGU1_ISRS PPE_REG_ADDR(0x0204)
+#define MBOX_IGU1_ISRC PPE_REG_ADDR(0x0205)
+#define MBOX_IGU1_ISR PPE_REG_ADDR(0x0206)
+#define MBOX_IGU1_IER PPE_REG_ADDR(0x0207)
+
+#define MBOX_IGU1_ISRS_SET(n) (1 << (n))
+#define MBOX_IGU1_ISRC_CLEAR(n) (1 << (n))
+#define MBOX_IGU1_ISR_ISR(n) (*MBOX_IGU1_ISR & (1 << (n)))
+#define MBOX_IGU1_IER_EN(n) (*MBOX_IGU1_IER & (1 << (n)))
+#define MBOX_IGU1_IER_EN_SET(n) (1 << (n))
+
+/*
+ * Mailbox IGU3 Registers
+ */
+#define MBOX_IGU3_ISRS PPE_REG_ADDR(0x0214)
+#define MBOX_IGU3_ISRC PPE_REG_ADDR(0x0215)
+#define MBOX_IGU3_ISR PPE_REG_ADDR(0x0216)
+#define MBOX_IGU3_IER PPE_REG_ADDR(0x0217)
+
+#define MBOX_IGU3_ISRS_SET(n) (1 << (n))
+#define MBOX_IGU3_ISRC_CLEAR(n) (1 << (n))
+#define MBOX_IGU3_ISR_ISR(n) (*MBOX_IGU3_ISR & (1 << (n)))
+#define MBOX_IGU3_IER_EN(n) (*MBOX_IGU3_IER & (1 << (n)))
+#define MBOX_IGU3_IER_EN_SET(n) (1 << (n))
+
+/*
+ * RTHA/TTHA Registers
+ */
+#define RFBI_CFG PPE_REG_ADDR(0x0400)
+#define RBA_CFG0 PPE_REG_ADDR(0x0404)
+#define RBA_CFG1 PPE_REG_ADDR(0x0405)
+#define RCA_CFG0 PPE_REG_ADDR(0x0408)
+#define RCA_CFG1 PPE_REG_ADDR(0x0409)
+#define RDES_CFG0 PPE_REG_ADDR(0x040C)
+#define RDES_CFG1 PPE_REG_ADDR(0x040D)
+#define SFSM_STATE0 PPE_REG_ADDR(0x0410)
+#define SFSM_STATE1 PPE_REG_ADDR(0x0411)
+#define SFSM_DBA0 PPE_REG_ADDR(0x0412)
+#define SFSM_DBA1 PPE_REG_ADDR(0x0413)
+#define SFSM_CBA0 PPE_REG_ADDR(0x0414)
+#define SFSM_CBA1 PPE_REG_ADDR(0x0415)
+#define SFSM_CFG0 PPE_REG_ADDR(0x0416)
+#define SFSM_CFG1 PPE_REG_ADDR(0x0417)
+#define SFSM_PGCNT0 PPE_REG_ADDR(0x041C)
+#define SFSM_PGCNT1 PPE_REG_ADDR(0x041D)
+#define FFSM_DBA0 PPE_REG_ADDR(0x0508)
+#define FFSM_DBA1 PPE_REG_ADDR(0x0509)
+#define FFSM_CFG0 PPE_REG_ADDR(0x050A)
+#define FFSM_CFG1 PPE_REG_ADDR(0x050B)
+#define FFSM_IDLE_HEAD_BC0 PPE_REG_ADDR(0x050E)
+#define FFSM_IDLE_HEAD_BC1 PPE_REG_ADDR(0x050F)
+#define FFSM_PGCNT0 PPE_REG_ADDR(0x0514)
+#define FFSM_PGCNT1 PPE_REG_ADDR(0x0515)
+
+/*
+ * PPE TC Logic Registers (partial)
+ */
+#define DREG_A_VERSION PPE_REG_ADDR(0x0D00)
+#define DREG_A_CFG PPE_REG_ADDR(0x0D01)
+#define DREG_AT_CTRL PPE_REG_ADDR(0x0D02)
+#define DREG_AT_CB_CFG0 PPE_REG_ADDR(0x0D03)
+#define DREG_AT_CB_CFG1 PPE_REG_ADDR(0x0D04)
+#define DREG_AR_CTRL PPE_REG_ADDR(0x0D08)
+#define DREG_AR_CB_CFG0 PPE_REG_ADDR(0x0D09)
+#define DREG_AR_CB_CFG1 PPE_REG_ADDR(0x0D0A)
+#define DREG_A_UTPCFG PPE_REG_ADDR(0x0D0E)
+#define DREG_A_STATUS PPE_REG_ADDR(0x0D0F)
+#define DREG_AT_CFG0 PPE_REG_ADDR(0x0D20)
+#define DREG_AT_CFG1 PPE_REG_ADDR(0x0D21)
+#define DREG_AT_FB_SIZE0 PPE_REG_ADDR(0x0D22)
+#define DREG_AT_FB_SIZE1 PPE_REG_ADDR(0x0D23)
+#define DREG_AT_CELL0 PPE_REG_ADDR(0x0D24)
+#define DREG_AT_CELL1 PPE_REG_ADDR(0x0D25)
+#define DREG_AT_IDLE_CNT0 PPE_REG_ADDR(0x0D26)
+#define DREG_AT_IDLE_CNT1 PPE_REG_ADDR(0x0D27)
+#define DREG_AT_IDLE0 PPE_REG_ADDR(0x0D28)
+#define DREG_AT_IDLE1 PPE_REG_ADDR(0x0D29)
+#define DREG_AR_CFG0 PPE_REG_ADDR(0x0D60)
+#define DREG_AR_CFG1 PPE_REG_ADDR(0x0D61)
+#define DREG_AR_CELL0 PPE_REG_ADDR(0x0D68)
+#define DREG_AR_CELL1 PPE_REG_ADDR(0x0D69)
+#define DREG_AR_IDLE_CNT0 PPE_REG_ADDR(0x0D6A)
+#define DREG_AR_IDLE_CNT1 PPE_REG_ADDR(0x0D6B)
+#define DREG_AR_AIIDLE_CNT0 PPE_REG_ADDR(0x0D6C)
+#define DREG_AR_AIIDLE_CNT1 PPE_REG_ADDR(0x0D6D)
+#define DREG_AR_BE_CNT0 PPE_REG_ADDR(0x0D6E)
+#define DREG_AR_BE_CNT1 PPE_REG_ADDR(0x0D6F)
+#define DREG_AR_HEC_CNT0 PPE_REG_ADDR(0x0D70)
+#define DREG_AR_HEC_CNT1 PPE_REG_ADDR(0x0D71)
+#define DREG_AR_IDLE0 PPE_REG_ADDR(0x0D74)
+#define DREG_AR_IDLE1 PPE_REG_ADDR(0x0D75)
+#define DREG_AR_CVN_CNT0 PPE_REG_ADDR(0x0DA4)
+#define DREG_AR_CVN_CNT1 PPE_REG_ADDR(0x0DA5)
+#define DREG_AR_CVNP_CNT0 PPE_REG_ADDR(0x0DA6)
+#define DREG_AR_CVNP_CNT1 PPE_REG_ADDR(0x0DA7)
+#define DREG_B0_LADR PPE_REG_ADDR(0x0DA8)
+#define DREG_B1_LADR PPE_REG_ADDR(0x0DA9)
+
+#define SFSM_DBA(i) ( (SFSM_dba * ) PPE_REG_ADDR(0x0412 + (i)))
+#define SFSM_CBA(i) ( (SFSM_cba * ) PPE_REG_ADDR(0x0414 + (i)))
+#define SFSM_CFG(i) ( (SFSM_cfg * ) PPE_REG_ADDR(0x0416 + (i)))
+#define SFSM_PGCNT(i) ( (SFSM_pgcnt * ) PPE_REG_ADDR(0x041C + (i)))
+
+#define FFSM_DBA(i) ( (FFSM_dba * ) PPE_REG_ADDR(0x0508 + (i)))
+#define FFSM_CFG(i) ( (FFSM_cfg * ) PPE_REG_ADDR(0x050A + (i)))
+#define FFSM_PGCNT(i) ( (FFSM_pgcnt * ) PPE_REG_ADDR(0x0514 + (i)))
+
+typedef struct {
+ unsigned int res : 19;
+ unsigned int dbase : 13;
+} SFSM_dba;
+
+typedef struct {
+ unsigned int res : 19;
+ unsigned int cbase : 13;
+} SFSM_cba;
+
+typedef struct {
+ unsigned int res : 15;
+ unsigned int endian : 1;
+ unsigned int idlekeep: 1;
+ unsigned int sen : 1;
+ unsigned int res1 : 8;
+ unsigned int pnum : 6;
+} SFSM_cfg;
+
+typedef struct {
+ unsigned int res : 17;
+ unsigned int pptr : 6;
+ unsigned int dcmd : 1;
+ unsigned int res1 : 2;
+ unsigned int upage : 6;
+} SFSM_pgcnt;
+
+typedef struct {
+ unsigned int res : 19;
+ unsigned int dbase : 13;
+} FFSM_dba;
+
+typedef struct {
+ unsigned int res : 12;
+ unsigned int rstptr : 1;
+ unsigned int clvpage : 1;
+ unsigned int fidle : 1;
+ unsigned int endian : 1;
+ unsigned int res1 : 10;
+ unsigned int pnum : 6;
+} FFSM_cfg;
+
+typedef struct {
+ unsigned int res : 17;
+ unsigned int ival : 6;
+ unsigned int icmd : 1;
+ unsigned int res1 : 2;
+ unsigned int vpage : 6;
+} FFSM_pgcnt;
+
+
+
+#endif // IFXMIPS_ATM_PPE_COMMON_H
diff --git a/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_ppe_danube.h.svn-base b/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_ppe_danube.h.svn-base
new file mode 100644
index 0000000..7aaaa8d
--- /dev/null
+++ b/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_ppe_danube.h.svn-base
@@ -0,0 +1,129 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_atm_ppe_danube.h
+** PROJECT : UEIP
+** MODULES : ATM (ADSL)
+**
+** DATE : 1 AUG 2005
+** AUTHOR : Xu Liang
+** DESCRIPTION : ATM Driver (PPE Registers)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 4 AUG 2005 Xu Liang Initiate Version
+** 23 OCT 2006 Xu Liang Add GPL header.
+** 9 JAN 2007 Xu Liang First version got from Anand (IC designer)
+*******************************************************************************/
+
+
+
+#ifndef IFXMIPS_ATM_PPE_DANUBE_H
+#define IFXMIPS_ATM_PPE_DANUBE_H
+
+
+
+/*
+ * FPI Configuration Bus Register and Memory Address Mapping
+ */
+#define IFX_PPE (KSEG1 | 0x1E180000)
+#define PP32_DEBUG_REG_ADDR(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x0000) << 2)))
+#define PPM_INT_REG_ADDR(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x0030) << 2)))
+#define PP32_INTERNAL_RES_ADDR(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x0040) << 2)))
+#define CDM_CODE_MEMORY(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x1000) << 2)))
+#define PPE_REG_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x4000) << 2)))
+#define CDM_DATA_MEMORY(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x5000) << 2)))
+#define PPM_INT_UNIT_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6000) << 2)))
+#define PPM_TIMER0_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6100) << 2)))
+#define PPM_TASK_IND_REG_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6200) << 2)))
+#define PPS_BRK_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6300) << 2)))
+#define PPM_TIMER1_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6400) << 2)))
+#define SB_RAM0_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x8000) << 2)))
+#define SB_RAM1_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x8400) << 2)))
+#define SB_RAM2_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x8C00) << 2)))
+#define SB_RAM3_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x9600) << 2)))
+#define QSB_CONF_REG_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0xC000) << 2)))
+
+/*
+ * DWORD-Length of Memory Blocks
+ */
+#define PP32_DEBUG_REG_DWLEN 0x0030
+#define PPM_INT_REG_DWLEN 0x0010
+#define PP32_INTERNAL_RES_DWLEN 0x00C0
+#define CDM_CODE_MEMORYn_DWLEN(n) ((n) == 0 ? 0x1000 : 0x0800)
+#define PPE_REG_DWLEN 0x1000
+#define CDM_DATA_MEMORY_DWLEN CDM_CODE_MEMORYn_DWLEN(1)
+#define PPM_INT_UNIT_DWLEN 0x0100
+#define PPM_TIMER0_DWLEN 0x0100
+#define PPM_TASK_IND_REG_DWLEN 0x0100
+#define PPS_BRK_DWLEN 0x0100
+#define PPM_TIMER1_DWLEN 0x0100
+#define SB_RAM0_DWLEN 0x0400
+#define SB_RAM1_DWLEN 0x0800
+#define SB_RAM2_DWLEN 0x0A00
+#define SB_RAM3_DWLEN 0x0400
+#define QSB_CONF_REG_DWLEN 0x0100
+
+/*
+ * PP32 to FPI Address Mapping
+ */
+#define SB_BUFFER(__sb_addr) ((volatile unsigned int *)((((__sb_addr) >= 0x2000) && ((__sb_addr) <= 0x23FF)) ? SB_RAM0_ADDR((__sb_addr) - 0x2000) : \
+ (((__sb_addr) >= 0x2400) && ((__sb_addr) <= 0x2BFF)) ? SB_RAM1_ADDR((__sb_addr) - 0x2400) : \
+ (((__sb_addr) >= 0x2C00) && ((__sb_addr) <= 0x35FF)) ? SB_RAM2_ADDR((__sb_addr) - 0x2C00) : \
+ (((__sb_addr) >= 0x3600) && ((__sb_addr) <= 0x39FF)) ? SB_RAM3_ADDR((__sb_addr) - 0x3600) : \
+ 0))
+
+/*
+ * PP32 Debug Control Register
+ */
+#define PP32_DBG_CTRL PP32_DEBUG_REG_ADDR(0, 0x0000)
+
+#define DBG_CTRL_START_SET(value) ((value) ? (1 << 0) : 0)
+#define DBG_CTRL_STOP_SET(value) ((value) ? (1 << 1) : 0)
+#define DBG_CTRL_STEP_SET(value) ((value) ? (1 << 2) : 0)
+
+#define PP32_HALT_STAT PP32_DEBUG_REG_ADDR(0, 0x0001)
+
+#define PP32_BRK_SRC PP32_DEBUG_REG_ADDR(0, 0x0002)
+
+#define PP32_DBG_PC_MIN(i) PP32_DEBUG_REG_ADDR(0, 0x0010 + (i))
+#define PP32_DBG_PC_MAX(i) PP32_DEBUG_REG_ADDR(0, 0x0014 + (i))
+#define PP32_DBG_DATA_MIN(i) PP32_DEBUG_REG_ADDR(0, 0x0018 + (i))
+#define PP32_DBG_DATA_MAX(i) PP32_DEBUG_REG_ADDR(0, 0x001A + (i))
+#define PP32_DBG_DATA_VAL(i) PP32_DEBUG_REG_ADDR(0, 0x001C + (i))
+
+#define PP32_DBG_CUR_PC PP32_DEBUG_REG_ADDR(0, 0x0080)
+
+#define PP32_DBG_TASK_NO PP32_DEBUG_REG_ADDR(0, 0x0081)
+
+#define PP32_DBG_REG_BASE(tsk, i) PP32_DEBUG_REG_ADDR(0, 0x0100 + (tsk) * 16 + (i))
+
+/*
+ * EMA Registers
+ */
+#define EMA_CMDCFG PPE_REG_ADDR(0x0A00)
+#define EMA_DATACFG PPE_REG_ADDR(0x0A01)
+#define EMA_CMDCNT PPE_REG_ADDR(0x0A02)
+#define EMA_DATACNT PPE_REG_ADDR(0x0A03)
+#define EMA_ISR PPE_REG_ADDR(0x0A04)
+#define EMA_IER PPE_REG_ADDR(0x0A05)
+#define EMA_CFG PPE_REG_ADDR(0x0A06)
+#define EMA_SUBID PPE_REG_ADDR(0x0A07)
+
+#define EMA_ALIGNMENT 4
+
+/*
+ * Mailbox IGU1 Interrupt
+ */
+#define PPE_MAILBOX_IGU1_INT INT_NUM_IM2_IRL24
+
+
+
+#endif // IFXMIPS_ATM_PPE_DANUBE_H
diff --git a/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_ppe_vr9.h.svn-base b/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_ppe_vr9.h.svn-base
new file mode 100644
index 0000000..144c396
--- /dev/null
+++ b/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_ppe_vr9.h.svn-base
@@ -0,0 +1,192 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_atm_ppe_vr9.h
+** PROJECT : UEIP
+** MODULES : ATM (ADSL)
+**
+** DATE : 1 AUG 2005
+** AUTHOR : Xu Liang
+** DESCRIPTION : ATM Driver (PPE Registers)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 4 AUG 2005 Xu Liang Initiate Version
+** 23 OCT 2006 Xu Liang Add GPL header.
+** 9 JAN 2007 Xu Liang First version got from Anand (IC designer)
+*******************************************************************************/
+
+
+
+#ifndef IFXMIPS_ATM_PPE_VR9_H
+#define IFXMIPS_ATM_PPE_VR9_H
+
+
+
+/*
+ * FPI Configuration Bus Register and Memory Address Mapping
+ */
+#define IFX_PPE (KSEG1 | 0x1E200000)
+#define PP32_DEBUG_REG_ADDR(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x000000 + (i) * 0x00010000) << 2)))
+#define CDM_CODE_MEMORY(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x001000 + (i) * 0x00010000) << 2)))
+#define CDM_DATA_MEMORY(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x004000 + (i) * 0x00010000) << 2)))
+#define SB_RAM0_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x008000) << 2)))
+#define SB_RAM1_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x009000) << 2)))
+#define SB_RAM2_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x00A000) << 2)))
+#define SB_RAM3_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x00B000) << 2)))
+#define PPE_REG_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x00D000) << 2)))
+#define QSB_CONF_REG_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x00E000) << 2)))
+#define SB_RAM6_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x018000) << 2)))
+
+/*
+ * DWORD-Length of Memory Blocks
+ */
+#define PP32_DEBUG_REG_DWLEN 0x0030
+#define CDM_CODE_MEMORYn_DWLEN(n) ((n) == 0 ? 0x1000 : 0x0800)
+#define CDM_DATA_MEMORY_DWLEN CDM_CODE_MEMORYn_DWLEN(1)
+#define SB_RAM0_DWLEN 0x1000
+#define SB_RAM1_DWLEN 0x1000
+#define SB_RAM2_DWLEN 0x1000
+#define SB_RAM3_DWLEN 0x1000
+#define SB_RAM6_DWLEN 0x8000
+#define QSB_CONF_REG_DWLEN 0x0100
+
+/*
+ * PP32 to FPI Address Mapping
+ */
+#define SB_BUFFER(__sb_addr) ((volatile unsigned int *)((((__sb_addr) >= 0x0000) && ((__sb_addr) <= 0x1FFF)) ? PPE_REG_ADDR((__sb_addr)) : \
+ (((__sb_addr) >= 0x2000) && ((__sb_addr) <= 0x2FFF)) ? SB_RAM0_ADDR((__sb_addr) - 0x2000) : \
+ (((__sb_addr) >= 0x3000) && ((__sb_addr) <= 0x3FFF)) ? SB_RAM1_ADDR((__sb_addr) - 0x3000) : \
+ (((__sb_addr) >= 0x4000) && ((__sb_addr) <= 0x4FFF)) ? SB_RAM2_ADDR((__sb_addr) - 0x4000) : \
+ (((__sb_addr) >= 0x5000) && ((__sb_addr) <= 0x5FFF)) ? SB_RAM3_ADDR((__sb_addr) - 0x5000) : \
+ (((__sb_addr) >= 0x7000) && ((__sb_addr) <= 0x7FFF)) ? PPE_REG_ADDR((__sb_addr) - 0x7000) : \
+ (((__sb_addr) >= 0x8000) && ((__sb_addr) <= 0xFFFF)) ? SB_RAM6_ADDR((__sb_addr) - 0x8000) : \
+ 0))
+
+/*
+ * PP32 Debug Control Register
+ */
+#define NUM_OF_PP32 2
+
+#define PP32_FREEZE PPE_REG_ADDR(0x0000)
+#define PP32_SRST PPE_REG_ADDR(0x0020)
+
+#define PP32_DBG_CTRL(n) PP32_DEBUG_REG_ADDR(n, 0x0000)
+
+#define DBG_CTRL_RESTART 0
+#define DBG_CTRL_STOP 1
+
+#define PP32_CTRL_CMD(n) PP32_DEBUG_REG_ADDR(n, 0x0B00)
+ #define PP32_CTRL_CMD_RESTART (1 << 0)
+ #define PP32_CTRL_CMD_STOP (1 << 1)
+ #define PP32_CTRL_CMD_STEP (1 << 2)
+ #define PP32_CTRL_CMD_BREAKOUT (1 << 3)
+
+#define PP32_CTRL_OPT(n) PP32_DEBUG_REG_ADDR(n, 0x0C00)
+ #define PP32_CTRL_OPT_BREAKOUT_ON_STOP_ON (3 << 0)
+ #define PP32_CTRL_OPT_BREAKOUT_ON_STOP_OFF (2 << 0)
+ #define PP32_CTRL_OPT_BREAKOUT_ON_BREAKIN_ON (3 << 2)
+ #define PP32_CTRL_OPT_BREAKOUT_ON_BREAKIN_OFF (2 << 2)
+ #define PP32_CTRL_OPT_STOP_ON_BREAKIN_ON (3 << 4)
+ #define PP32_CTRL_OPT_STOP_ON_BREAKIN_OFF (2 << 4)
+ #define PP32_CTRL_OPT_STOP_ON_BREAKPOINT_ON (3 << 6)
+ #define PP32_CTRL_OPT_STOP_ON_BREAKPOINT_OFF (2 << 6)
+ #define PP32_CTRL_OPT_BREAKOUT_ON_STOP(n) (*PP32_CTRL_OPT(n) & (1 << 0))
+ #define PP32_CTRL_OPT_BREAKOUT_ON_BREAKIN(n) (*PP32_CTRL_OPT(n) & (1 << 2))
+ #define PP32_CTRL_OPT_STOP_ON_BREAKIN(n) (*PP32_CTRL_OPT(n) & (1 << 4))
+ #define PP32_CTRL_OPT_STOP_ON_BREAKPOINT(n) (*PP32_CTRL_OPT(n) & (1 << 6))
+
+#define PP32_BRK_PC(n, i) PP32_DEBUG_REG_ADDR(n, 0x0900 + (i) * 2)
+#define PP32_BRK_PC_MASK(n, i) PP32_DEBUG_REG_ADDR(n, 0x0901 + (i) * 2)
+#define PP32_BRK_DATA_ADDR(n, i) PP32_DEBUG_REG_ADDR(n, 0x0904 + (i) * 2)
+#define PP32_BRK_DATA_ADDR_MASK(n, i) PP32_DEBUG_REG_ADDR(n, 0x0905 + (i) * 2)
+#define PP32_BRK_DATA_VALUE_RD(n, i) PP32_DEBUG_REG_ADDR(n, 0x0908 + (i) * 2)
+#define PP32_BRK_DATA_VALUE_RD_MASK(n, i) PP32_DEBUG_REG_ADDR(n, 0x0909 + (i) * 2)
+#define PP32_BRK_DATA_VALUE_WR(n, i) PP32_DEBUG_REG_ADDR(n, 0x090C + (i) * 2)
+#define PP32_BRK_DATA_VALUE_WR_MASK(n, i) PP32_DEBUG_REG_ADDR(n, 0x090D + (i) * 2)
+ #define PP32_BRK_CONTEXT_MASK(i) (1 << (i))
+ #define PP32_BRK_CONTEXT_MASK_EN (1 << 4)
+ #define PP32_BRK_COMPARE_GREATER_EQUAL (1 << 5) // valid for break data value rd/wr only
+ #define PP32_BRK_COMPARE_LOWER_EQUAL (1 << 6)
+ #define PP32_BRK_COMPARE_EN (1 << 7)
+
+#define PP32_BRK_TRIG(n) PP32_DEBUG_REG_ADDR(n, 0x0F00)
+ #define PP32_BRK_GRPi_PCn_ON(i, n) ((3 << ((n) * 2)) << ((i) * 16))
+ #define PP32_BRK_GRPi_PCn_OFF(i, n) ((2 << ((n) * 2)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_ADDRn_ON(i, n) ((3 << ((n) * 2 + 4)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_ADDRn_OFF(i, n) ((2 << ((n) * 2 + 4)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_VALUE_RDn_ON(i, n) ((3 << ((n) * 2 + 8)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_VALUE_RDn_OFF(i, n)((2 << ((n) * 2 + 8)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_VALUE_WRn_ON(i, n) ((3 << ((n) * 2 + 12)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_VALUE_WRn_OFF(i, n)((2 << ((n) * 2 + 12)) << ((i) * 16))
+ #define PP32_BRK_GRPi_PCn(k, i, n) (*PP32_BRK_TRIG(k) & ((1 << ((n))) << ((i) * 8)))
+ #define PP32_BRK_GRPi_DATA_ADDRn(k, i, n) (*PP32_BRK_TRIG(k) & ((1 << ((n) + 2)) << ((i) * 8)))
+ #define PP32_BRK_GRPi_DATA_VALUE_RDn(k, i, n) (*PP32_BRK_TRIG(k) & ((1 << ((n) + 4)) << ((i) * 8)))
+ #define PP32_BRK_GRPi_DATA_VALUE_WRn(k, i, n) (*PP32_BRK_TRIG(k) & ((1 << ((n) + 6)) << ((i) * 8)))
+
+#define PP32_CPU_STATUS(n) PP32_DEBUG_REG_ADDR(n, 0x0D00)
+#define PP32_HALT_STAT(n) PP32_CPU_STATUS(n)
+#define PP32_DBG_CUR_PC(n) PP32_CPU_STATUS(n)
+ #define PP32_CPU_USER_STOPPED(n) (*PP32_CPU_STATUS(n) & (1 << 0))
+ #define PP32_CPU_USER_BREAKIN_RCV(n) (*PP32_CPU_STATUS(n) & (1 << 1))
+ #define PP32_CPU_USER_BREAKPOINT_MET(n) (*PP32_CPU_STATUS(n) & (1 << 2))
+ #define PP32_CPU_CUR_PC(n) (*PP32_CPU_STATUS(n) >> 16)
+
+#define PP32_BREAKPOINT_REASONS(n) PP32_DEBUG_REG_ADDR(n, 0x0A00)
+ #define PP32_BRK_PC_MET(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << (i)))
+ #define PP32_BRK_DATA_ADDR_MET(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) + 2)))
+ #define PP32_BRK_DATA_VALUE_RD_MET(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) + 4)))
+ #define PP32_BRK_DATA_VALUE_WR_MET(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) + 6)))
+ #define PP32_BRK_DATA_VALUE_RD_LO_EQ(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) * 2 + 8)))
+ #define PP32_BRK_DATA_VALUE_RD_GT_EQ(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) * 2 + 9)))
+ #define PP32_BRK_DATA_VALUE_WR_LO_EQ(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) * 2 + 12)))
+ #define PP32_BRK_DATA_VALUE_WR_GT_EQ(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) * 2 + 13)))
+ #define PP32_BRK_CUR_CONTEXT(n) ((*PP32_BREAKPOINT_REASONS(n) >> 16) & 0x03)
+
+#define PP32_GP_REG_BASE(n) PP32_DEBUG_REG_ADDR(n, 0x0E00)
+#define PP32_GP_CONTEXTi_REGn(n, i, j) PP32_DEBUG_REG_ADDR(n, 0x0E00 + (i) * 16 + (j))
+
+/*
+ * PDMA/EMA Registers
+ */
+#define PDMA_CFG PPE_REG_ADDR(0x0A00)
+#define PDMA_RX_CMDCNT PPE_REG_ADDR(0x0A01)
+#define PDMA_TX_CMDCNT PPE_REG_ADDR(0x0A02)
+#define PDMA_RX_FWDATACNT PPE_REG_ADDR(0x0A03)
+#define PDMA_TX_FWDATACNT PPE_REG_ADDR(0x0A04)
+#define PDMA_RX_CTX_CFG PPE_REG_ADDR(0x0A05)
+#define PDMA_TX_CTX_CFG PPE_REG_ADDR(0x0A06)
+#define PDMA_RX_MAX_LEN_REG PPE_REG_ADDR(0x0A07)
+#define PDMA_RX_DELAY_CFG PPE_REG_ADDR(0x0A08)
+#define PDMA_INT_FIFO_RD PPE_REG_ADDR(0x0A09)
+#define PDMA_ISR PPE_REG_ADDR(0x0A0A)
+#define PDMA_IER PPE_REG_ADDR(0x0A0B)
+#define PDMA_SUBID PPE_REG_ADDR(0x0A0C)
+#define PDMA_BAR0 PPE_REG_ADDR(0x0A0D)
+#define PDMA_BAR1 PPE_REG_ADDR(0x0A0E)
+
+#define SAR_PDMA_RX_CMDBUF_CFG PPE_REG_ADDR(0x0F00)
+#define SAR_PDMA_TX_CMDBUF_CFG PPE_REG_ADDR(0x0F01)
+#define SAR_PDMA_RX_FW_CMDBUF_CFG PPE_REG_ADDR(0x0F02)
+#define SAR_PDMA_TX_FW_CMDBUF_CFG PPE_REG_ADDR(0x0F03)
+#define SAR_PDMA_RX_CMDBUF_STATUS PPE_REG_ADDR(0x0F04)
+#define SAR_PDMA_TX_CMDBUF_STATUS PPE_REG_ADDR(0x0F05)
+
+#define PDMA_ALIGNMENT 4
+#define EMA_ALIGNMENT PDMA_ALIGNMENT
+
+/*
+ * Mailbox IGU1 Interrupt
+ */
+#define PPE_MAILBOX_IGU1_INT INT_NUM_IM2_IRL24
+
+
+
+#endif // IFXMIPS_ATM_PPE_VR9_H
diff --git a/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_vr9.c.svn-base b/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_vr9.c.svn-base
new file mode 100644
index 0000000..89c71e3
--- /dev/null
+++ b/package/platform/lantiq/ltq-atm/src/.svn/text-base/ifxmips_atm_vr9.c.svn-base
@@ -0,0 +1,190 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_atm_vr9.c
+** PROJECT : UEIP
+** MODULES : ATM
+**
+** DATE : 7 Jul 2009
+** AUTHOR : Xu Liang
+** DESCRIPTION : ATM driver common source file (core functions)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 07 JUL 2009 Xu Liang Init Version
+*******************************************************************************/
+
+
+
+/*
+ * ####################################
+ * Head File
+ * ####################################
+ */
+
+/*
+ * Common Head File
+ */
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/version.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/proc_fs.h>
+#include <linux/init.h>
+#include <linux/ioctl.h>
+#include <asm/delay.h>
+
+#include "ifxmips_atm_core.h"
+#include "ifxmips_atm_fw_vr9.h"
+
+#ifdef CONFIG_VR9
+
+#include <lantiq_soc.h>
+
+#define IFX_PMU_MODULE_PPE_SLL01 BIT(19)
+#define IFX_PMU_MODULE_PPE_TC BIT(21)
+#define IFX_PMU_MODULE_PPE_EMA BIT(22)
+#define IFX_PMU_MODULE_PPE_QSB BIT(18)
+#define IFX_PMU_MODULE_AHBS BIT(13)
+#define IFX_PMU_MODULE_DSL_DFE BIT(9)
+
+static inline void vr9_reset_ppe(void)
+{
+/*#ifdef MODULE
+ // reset PPE
+ ifx_rcu_rst(IFX_RCU_DOMAIN_DSLDFE, IFX_RCU_MODULE_ATM);
+ udelay(1000);
+ ifx_rcu_rst(IFX_RCU_DOMAIN_DSLTC, IFX_RCU_MODULE_ATM);
+ udelay(1000);
+ ifx_rcu_rst(IFX_RCU_DOMAIN_PPE, IFX_RCU_MODULE_ATM);
+ udelay(1000);
+ *PP32_SRST &= ~0x000303CF;
+ udelay(1000);
+ *PP32_SRST |= 0x000303CF;
+ udelay(1000);
+#endif*/
+}
+
+static inline int vr9_pp32_download_code(int pp32, u32 *code_src, unsigned int code_dword_len, u32 *data_src, unsigned int data_dword_len)
+{
+ unsigned int clr, set;
+ volatile u32 *dest;
+
+ if ( code_src == 0 || ((unsigned long)code_src & 0x03) != 0
+ || data_src == 0 || ((unsigned long)data_src & 0x03) != 0 )
+ return -1;
+
+ clr = pp32 ? 0xF0 : 0x0F;
+ if ( code_dword_len <= CDM_CODE_MEMORYn_DWLEN(0) )
+ set = pp32 ? (3 << 6): (2 << 2);
+ else
+ set = 0x00;
+ IFX_REG_W32_MASK(clr, set, CDM_CFG);
+
+ dest = CDM_CODE_MEMORY(pp32, 0);
+ while ( code_dword_len-- > 0 )
+ IFX_REG_W32(*code_src++, dest++);
+
+ dest = CDM_DATA_MEMORY(pp32, 0);
+ while ( data_dword_len-- > 0 )
+ IFX_REG_W32(*data_src++, dest++);
+
+ return 0;
+}
+
+static void vr9_fw_ver(unsigned int *major, unsigned int *minor)
+{
+
+ *major = FW_VER_ID->major;
+ *minor = FW_VER_ID->minor;
+}
+
+static void vr9_init(void)
+{
+ volatile u32 *p;
+ unsigned int i;
+
+ /* setup pmu */
+ ltq_pmu_enable(IFX_PMU_MODULE_PPE_SLL01 |
+ IFX_PMU_MODULE_PPE_TC |
+ IFX_PMU_MODULE_PPE_EMA |
+ IFX_PMU_MODULE_PPE_QSB |
+ IFX_PMU_MODULE_AHBS |
+ IFX_PMU_MODULE_DSL_DFE);
+
+ vr9_reset_ppe();
+
+ /* pdma init */
+ IFX_REG_W32(0x08, PDMA_CFG);
+ IFX_REG_W32(0x00203580, SAR_PDMA_RX_CMDBUF_CFG);
+ IFX_REG_W32(0x004035A0, SAR_PDMA_RX_FW_CMDBUF_CFG);
+
+ /* mailbox init */
+ IFX_REG_W32(0xFFFFFFFF, MBOX_IGU1_ISRC);
+ IFX_REG_W32(0x00000000, MBOX_IGU1_IER);
+ IFX_REG_W32(0xFFFFFFFF, MBOX_IGU3_ISRC);
+ IFX_REG_W32(0x00000000, MBOX_IGU3_IER);
+
+ /* tc init - clear sync state */
+ *SFSM_STATE0 = 0;
+ *SFSM_STATE1 = 0;
+
+ /* init shared buffer */
+ p = SB_RAM0_ADDR(0);
+ for ( i = 0; i < SB_RAM0_DWLEN + SB_RAM1_DWLEN + SB_RAM2_DWLEN + SB_RAM3_DWLEN; i++ )
+ IFX_REG_W32(0, p++);
+
+ p = SB_RAM6_ADDR(0);
+ for ( i = 0; i < SB_RAM6_DWLEN; i++ )
+ IFX_REG_W32(0, p++);
+}
+
+static void vr9_shutdown(void)
+{
+}
+
+static int vr9_start(int pp32)
+{
+ unsigned int mask = 1 << (pp32 << 4);
+ int ret;
+
+ /* download firmware */
+ ret = vr9_pp32_download_code(pp32,
+ vr9_fw_bin, sizeof(vr9_fw_bin) / sizeof(*vr9_fw_bin),
+ vr9_fw_data, sizeof(vr9_fw_data) / sizeof(*vr9_fw_data));
+ if ( ret != 0 )
+ return ret;
+
+ /* run PP32 */
+ IFX_REG_W32_MASK(mask, 0, PP32_FREEZE);
+
+ /* idle for a while to let PP32 init itself */
+ udelay(10);
+
+ return 0;
+}
+
+static void vr9_stop(int pp32)
+{
+ unsigned int mask = 1 << (pp32 << 4);
+
+ IFX_REG_W32_MASK(0, mask, PP32_FREEZE);
+}
+
+struct ltq_atm_ops vr9_ops = {
+ .init = vr9_init,
+ .shutdown = vr9_shutdown,
+ .start = vr9_start,
+ .stop = vr9_stop,
+ .fw_ver = vr9_fw_ver,
+};
+
+#endif
diff --git a/package/platform/lantiq/ltq-atm/src/.svn/text-base/ltq_atm.c.svn-base b/package/platform/lantiq/ltq-atm/src/.svn/text-base/ltq_atm.c.svn-base
new file mode 100644
index 0000000..0e7e6e9
--- /dev/null
+++ b/package/platform/lantiq/ltq-atm/src/.svn/text-base/ltq_atm.c.svn-base
@@ -0,0 +1,1897 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_atm_core.c
+** PROJECT : UEIP
+** MODULES : ATM
+**
+** DATE : 7 Jul 2009
+** AUTHOR : Xu Liang
+** DESCRIPTION : ATM driver common source file (core functions)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 07 JUL 2009 Xu Liang Init Version
+*******************************************************************************/
+
+#define IFX_ATM_VER_MAJOR 1
+#define IFX_ATM_VER_MID 0
+#define IFX_ATM_VER_MINOR 26
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/version.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/proc_fs.h>
+#include <linux/init.h>
+#include <linux/ioctl.h>
+#include <linux/atmdev.h>
+#include <linux/platform_device.h>
+#include <linux/of_device.h>
+#include <linux/atm.h>
+#include <linux/clk.h>
+#include <linux/interrupt.h>
+#ifdef CONFIG_XFRM
+ #include <net/xfrm.h>
+#endif
+
+#include <lantiq_soc.h>
+
+#include "ifxmips_atm_core.h"
+
+#define MODULE_PARM_ARRAY(a, b) module_param_array(a, int, NULL, 0)
+#define MODULE_PARM(a, b) module_param(a, int, 0)
+
+/*!
+ \brief QSB cell delay variation due to concurrency
+ */
+static int qsb_tau = 1; /* QSB cell delay variation due to concurrency */
+/*!
+ \brief QSB scheduler burst length
+ */
+static int qsb_srvm = 0x0F; /* QSB scheduler burst length */
+/*!
+ \brief QSB time step, all legal values are 1, 2, 4
+ */
+static int qsb_tstep = 4 ; /* QSB time step, all legal values are 1, 2, 4 */
+
+/*!
+ \brief Write descriptor delay
+ */
+static int write_descriptor_delay = 0x20; /* Write descriptor delay */
+
+/*!
+ \brief AAL5 padding byte ('~')
+ */
+static int aal5_fill_pattern = 0x007E; /* AAL5 padding byte ('~') */
+/*!
+ \brief Max frame size for RX
+ */
+static int aal5r_max_packet_size = 0x0700; /* Max frame size for RX */
+/*!
+ \brief Min frame size for RX
+ */
+static int aal5r_min_packet_size = 0x0000; /* Min frame size for RX */
+/*!
+ \brief Max frame size for TX
+ */
+static int aal5s_max_packet_size = 0x0700; /* Max frame size for TX */
+/*!
+ \brief Min frame size for TX
+ */
+static int aal5s_min_packet_size = 0x0000; /* Min frame size for TX */
+/*!
+ \brief Drop error packet in RX path
+ */
+static int aal5r_drop_error_packet = 1; /* Drop error packet in RX path */
+
+/*!
+ \brief Number of descriptors per DMA RX channel
+ */
+static int dma_rx_descriptor_length = 128; /* Number of descriptors per DMA RX channel */
+/*!
+ \brief Number of descriptors per DMA TX channel
+ */
+static int dma_tx_descriptor_length = 64; /* Number of descriptors per DMA TX channel */
+/*!
+ \brief PPE core clock cycles between descriptor write and effectiveness in external RAM
+ */
+static int dma_rx_clp1_descriptor_threshold = 38;
+/*@}*/
+
+MODULE_PARM(qsb_tau, "i");
+MODULE_PARM_DESC(qsb_tau, "Cell delay variation. Value must be > 0");
+MODULE_PARM(qsb_srvm, "i");
+MODULE_PARM_DESC(qsb_srvm, "Maximum burst size");
+MODULE_PARM(qsb_tstep, "i");
+MODULE_PARM_DESC(qsb_tstep, "n*32 cycles per sbs cycles n=1,2,4");
+
+MODULE_PARM(write_descriptor_delay, "i");
+MODULE_PARM_DESC(write_descriptor_delay, "PPE core clock cycles between descriptor write and effectiveness in external RAM");
+
+MODULE_PARM(aal5_fill_pattern, "i");
+MODULE_PARM_DESC(aal5_fill_pattern, "Filling pattern (PAD) for AAL5 frames");
+MODULE_PARM(aal5r_max_packet_size, "i");
+MODULE_PARM_DESC(aal5r_max_packet_size, "Max packet size in byte for downstream AAL5 frames");
+MODULE_PARM(aal5r_min_packet_size, "i");
+MODULE_PARM_DESC(aal5r_min_packet_size, "Min packet size in byte for downstream AAL5 frames");
+MODULE_PARM(aal5s_max_packet_size, "i");
+MODULE_PARM_DESC(aal5s_max_packet_size, "Max packet size in byte for upstream AAL5 frames");
+MODULE_PARM(aal5s_min_packet_size, "i");
+MODULE_PARM_DESC(aal5s_min_packet_size, "Min packet size in byte for upstream AAL5 frames");
+MODULE_PARM(aal5r_drop_error_packet, "i");
+MODULE_PARM_DESC(aal5r_drop_error_packet, "Non-zero value to drop error packet for downstream");
+
+MODULE_PARM(dma_rx_descriptor_length, "i");
+MODULE_PARM_DESC(dma_rx_descriptor_length, "Number of descriptor assigned to DMA RX channel (>16)");
+MODULE_PARM(dma_tx_descriptor_length, "i");
+MODULE_PARM_DESC(dma_tx_descriptor_length, "Number of descriptor assigned to DMA TX channel (>16)");
+MODULE_PARM(dma_rx_clp1_descriptor_threshold, "i");
+MODULE_PARM_DESC(dma_rx_clp1_descriptor_threshold, "Descriptor threshold for cells with cell loss priority 1");
+
+
+
+/*
+ * ####################################
+ * Definition
+ * ####################################
+ */
+
+#ifdef CONFIG_AMAZON_SE
+ #define ENABLE_LESS_CACHE_INV 1
+ #define LESS_CACHE_INV_LEN 96
+#endif
+
+#define DUMP_SKB_LEN ~0
+
+
+
+/*
+ * ####################################
+ * Declaration
+ * ####################################
+ */
+
+/*
+ * Network Operations
+ */
+static int ppe_ioctl(struct atm_dev *, unsigned int, void *);
+static int ppe_open(struct atm_vcc *);
+static void ppe_close(struct atm_vcc *);
+static int ppe_send(struct atm_vcc *, struct sk_buff *);
+static int ppe_send_oam(struct atm_vcc *, void *, int);
+static int ppe_change_qos(struct atm_vcc *, struct atm_qos *, int);
+
+/*
+ * ADSL LED
+ */
+static inline void adsl_led_flash(void);
+
+/*
+ * 64-bit operation used by MIB calculation
+ */
+static inline void u64_add_u32(ppe_u64_t, unsigned int, ppe_u64_t *);
+
+/*
+ * buffer manage functions
+ */
+static inline struct sk_buff* alloc_skb_rx(void);
+static inline struct sk_buff* alloc_skb_tx(unsigned int);
+struct sk_buff* atm_alloc_tx(struct atm_vcc *, unsigned int);
+static inline void atm_free_tx_skb_vcc(struct sk_buff *, struct atm_vcc *);
+static inline struct sk_buff *get_skb_rx_pointer(unsigned int);
+static inline int get_tx_desc(unsigned int);
+static struct sk_buff* skb_duplicate(struct sk_buff *);
+static struct sk_buff* skb_break_away_from_protocol(struct sk_buff *);
+
+/*
+ * mailbox handler and signal function
+ */
+static inline void mailbox_oam_rx_handler(void);
+static inline void mailbox_aal_rx_handler(void);
+static irqreturn_t mailbox_irq_handler(int, void *);
+static inline void mailbox_signal(unsigned int, int);
+
+/*
+ * QSB & HTU setting functions
+ */
+static void set_qsb(struct atm_vcc *, struct atm_qos *, unsigned int);
+static void qsb_global_set(void);
+static inline void set_htu_entry(unsigned int, unsigned int, unsigned int, int, int);
+static inline void clear_htu_entry(unsigned int);
+static void validate_oam_htu_entry(void);
+static void invalidate_oam_htu_entry(void);
+
+/*
+ * look up for connection ID
+ */
+static inline int find_vpi(unsigned int);
+static inline int find_vpivci(unsigned int, unsigned int);
+static inline int find_vcc(struct atm_vcc *);
+
+static inline int ifx_atm_version(const struct ltq_atm_ops *ops, char *);
+
+/*
+ * Init & clean-up functions
+ */
+static inline void check_parameters(void);
+static inline int init_priv_data(void);
+static inline void clear_priv_data(void);
+static inline void init_rx_tables(void);
+static inline void init_tx_tables(void);
+
+/*
+ * Exteranl Function
+ */
+#if defined(CONFIG_IFX_OAM) || defined(CONFIG_IFX_OAM_MODULE)
+extern void ifx_push_oam(unsigned char *);
+#else
+static inline void ifx_push_oam(unsigned char *dummy) {}
+#endif
+
+#if defined(CONFIG_IFXMIPS_DSL_CPE_MEI) || defined(CONFIG_IFXMIPS_DSL_CPE_MEI_MODULE)
+extern int ifx_mei_atm_showtime_check(int *is_showtime, struct port_cell_info *port_cell, void **xdata_addr);
+extern int (*ifx_mei_atm_showtime_enter)(struct port_cell_info *, void *);
+
+extern int (*ifx_mei_atm_showtime_exit)(void);
+extern int ifx_mei_atm_led_blink(void);
+#else
+static inline int ifx_mei_atm_led_blink(void) { return 0; }
+static inline int ifx_mei_atm_showtime_check(int *is_showtime, struct port_cell_info *port_cell, void **xdata_addr)
+{
+ if ( is_showtime != NULL )
+ *is_showtime = 0;
+ return 0;
+}
+int (*ifx_mei_atm_showtime_enter)(struct port_cell_info *, void *) = NULL;
+EXPORT_SYMBOL(ifx_mei_atm_showtime_enter);
+
+int (*ifx_mei_atm_showtime_exit)(void) = NULL;
+EXPORT_SYMBOL(ifx_mei_atm_showtime_exit);
+
+#endif
+
+static struct sk_buff* (*ifx_atm_alloc_tx)(struct atm_vcc *, unsigned int) = NULL;
+
+static struct atm_priv_data g_atm_priv_data;
+
+static struct atmdev_ops g_ifx_atm_ops = {
+ .open = ppe_open,
+ .close = ppe_close,
+ .ioctl = ppe_ioctl,
+ .send = ppe_send,
+ .send_oam = ppe_send_oam,
+ .change_qos = ppe_change_qos,
+ .owner = THIS_MODULE,
+};
+
+static int g_showtime = 0;
+static void *g_xdata_addr = NULL;
+
+static int ppe_ioctl(struct atm_dev *dev, unsigned int cmd, void *arg)
+{
+ int ret = 0;
+ atm_cell_ifEntry_t mib_cell;
+ atm_aal5_ifEntry_t mib_aal5;
+ atm_aal5_vcc_x_t mib_vcc;
+ unsigned int value;
+ int conn;
+
+ if ( _IOC_TYPE(cmd) != PPE_ATM_IOC_MAGIC
+ || _IOC_NR(cmd) >= PPE_ATM_IOC_MAXNR )
+ return -ENOTTY;
+
+ if ( _IOC_DIR(cmd) & _IOC_READ )
+ ret = !access_ok(VERIFY_WRITE, arg, _IOC_SIZE(cmd));
+ else if ( _IOC_DIR(cmd) & _IOC_WRITE )
+ ret = !access_ok(VERIFY_READ, arg, _IOC_SIZE(cmd));
+ if ( ret )
+ return -EFAULT;
+
+ switch (cmd) {
+ case PPE_ATM_MIB_CELL: /* cell level MIB */
+ /* These MIB should be read at ARC side, now put zero only. */
+ mib_cell.ifHCInOctets_h = 0;
+ mib_cell.ifHCInOctets_l = 0;
+ mib_cell.ifHCOutOctets_h = 0;
+ mib_cell.ifHCOutOctets_l = 0;
+ mib_cell.ifInErrors = 0;
+ mib_cell.ifInUnknownProtos = WAN_MIB_TABLE->wrx_drophtu_cell;
+ mib_cell.ifOutErrors = 0;
+
+ ret = sizeof(mib_cell) - copy_to_user(arg, &mib_cell, sizeof(mib_cell));
+ break;
+
+ case PPE_ATM_MIB_AAL5: /* AAL5 MIB */
+ value = WAN_MIB_TABLE->wrx_total_byte;
+ u64_add_u32(g_atm_priv_data.wrx_total_byte, value - g_atm_priv_data.prev_wrx_total_byte, &g_atm_priv_data.wrx_total_byte);
+ g_atm_priv_data.prev_wrx_total_byte = value;
+ mib_aal5.ifHCInOctets_h = g_atm_priv_data.wrx_total_byte.h;
+ mib_aal5.ifHCInOctets_l = g_atm_priv_data.wrx_total_byte.l;
+
+ value = WAN_MIB_TABLE->wtx_total_byte;
+ u64_add_u32(g_atm_priv_data.wtx_total_byte, value - g_atm_priv_data.prev_wtx_total_byte, &g_atm_priv_data.wtx_total_byte);
+ g_atm_priv_data.prev_wtx_total_byte = value;
+ mib_aal5.ifHCOutOctets_h = g_atm_priv_data.wtx_total_byte.h;
+ mib_aal5.ifHCOutOctets_l = g_atm_priv_data.wtx_total_byte.l;
+
+ mib_aal5.ifInUcastPkts = g_atm_priv_data.wrx_pdu;
+ mib_aal5.ifOutUcastPkts = WAN_MIB_TABLE->wtx_total_pdu;
+ mib_aal5.ifInErrors = WAN_MIB_TABLE->wrx_err_pdu;
+ mib_aal5.ifInDiscards = WAN_MIB_TABLE->wrx_dropdes_pdu + g_atm_priv_data.wrx_drop_pdu;
+ mib_aal5.ifOutErros = g_atm_priv_data.wtx_err_pdu;
+ mib_aal5.ifOutDiscards = g_atm_priv_data.wtx_drop_pdu;
+
+ ret = sizeof(mib_aal5) - copy_to_user(arg, &mib_aal5, sizeof(mib_aal5));
+ break;
+
+ case PPE_ATM_MIB_VCC: /* VCC related MIB */
+ copy_from_user(&mib_vcc, arg, sizeof(mib_vcc));
+ conn = find_vpivci(mib_vcc.vpi, mib_vcc.vci);
+ if (conn >= 0) {
+ mib_vcc.mib_vcc.aal5VccCrcErrors = g_atm_priv_data.conn[conn].aal5_vcc_crc_err;
+ mib_vcc.mib_vcc.aal5VccOverSizedSDUs = g_atm_priv_data.conn[conn].aal5_vcc_oversize_sdu;
+ mib_vcc.mib_vcc.aal5VccSarTimeOuts = 0; /* no timer support */
+ ret = sizeof(mib_vcc) - copy_to_user(arg, &mib_vcc, sizeof(mib_vcc));
+ } else
+ ret = -EINVAL;
+ break;
+
+ default:
+ ret = -ENOIOCTLCMD;
+ }
+
+ return ret;
+}
+
+static int ppe_open(struct atm_vcc *vcc)
+{
+ int ret;
+ short vpi = vcc->vpi;
+ int vci = vcc->vci;
+ struct port *port = &g_atm_priv_data.port[(int)vcc->dev->dev_data];
+ int conn;
+ int f_enable_irq = 0;
+
+ if ( vcc->qos.aal != ATM_AAL5 && vcc->qos.aal != ATM_AAL0 )
+ return -EPROTONOSUPPORT;
+
+#if !defined(DISABLE_QOS_WORKAROUND) || !DISABLE_QOS_WORKAROUND
+ /* check bandwidth */
+ if ( (vcc->qos.txtp.traffic_class == ATM_CBR && vcc->qos.txtp.max_pcr > (port->tx_max_cell_rate - port->tx_current_cell_rate))
+ || (vcc->qos.txtp.traffic_class == ATM_VBR_RT && vcc->qos.txtp.max_pcr > (port->tx_max_cell_rate - port->tx_current_cell_rate))
+ || (vcc->qos.txtp.traffic_class == ATM_VBR_NRT && vcc->qos.txtp.scr > (port->tx_max_cell_rate - port->tx_current_cell_rate))
+ || (vcc->qos.txtp.traffic_class == ATM_UBR_PLUS && vcc->qos.txtp.min_pcr > (port->tx_max_cell_rate - port->tx_current_cell_rate)) )
+ {
+ ret = -EINVAL;
+ goto PPE_OPEN_EXIT;
+ }
+#endif
+
+ /* check existing vpi,vci */
+ conn = find_vpivci(vpi, vci);
+ if ( conn >= 0 ) {
+ ret = -EADDRINUSE;
+ goto PPE_OPEN_EXIT;
+ }
+
+ /* check whether it need to enable irq */
+ if ( g_atm_priv_data.conn_table == 0 )
+ f_enable_irq = 1;
+
+ /* allocate connection */
+ for ( conn = 0; conn < MAX_PVC_NUMBER; conn++ ) {
+ if ( test_and_set_bit(conn, &g_atm_priv_data.conn_table) == 0 ) {
+ g_atm_priv_data.conn[conn].vcc = vcc;
+ break;
+ }
+ }
+ if ( conn == MAX_PVC_NUMBER ) {
+ ret = -EINVAL;
+ goto PPE_OPEN_EXIT;
+ }
+
+ /* reserve bandwidth */
+ switch ( vcc->qos.txtp.traffic_class ) {
+ case ATM_CBR:
+ case ATM_VBR_RT:
+ port->tx_current_cell_rate += vcc->qos.txtp.max_pcr;
+ break;
+ case ATM_VBR_NRT:
+ port->tx_current_cell_rate += vcc->qos.txtp.scr;
+ break;
+ case ATM_UBR_PLUS:
+ port->tx_current_cell_rate += vcc->qos.txtp.min_pcr;
+ break;
+ }
+
+ /* set qsb */
+ set_qsb(vcc, &vcc->qos, conn);
+
+ /* update atm_vcc structure */
+ vcc->itf = (int)vcc->dev->dev_data;
+ vcc->vpi = vpi;
+ vcc->vci = vci;
+ set_bit(ATM_VF_READY, &vcc->flags);
+
+ /* enable irq */
+ if ( f_enable_irq ) {
+ ifx_atm_alloc_tx = atm_alloc_tx;
+
+ *MBOX_IGU1_ISRC = (1 << RX_DMA_CH_AAL) | (1 << RX_DMA_CH_OAM);
+ *MBOX_IGU1_IER = (1 << RX_DMA_CH_AAL) | (1 << RX_DMA_CH_OAM);
+
+ enable_irq(PPE_MAILBOX_IGU1_INT);
+ }
+
+ /* set port */
+ WTX_QUEUE_CONFIG(conn + FIRST_QSB_QID)->sbid = (int)vcc->dev->dev_data;
+
+ /* set htu entry */
+ set_htu_entry(vpi, vci, conn, vcc->qos.aal == ATM_AAL5 ? 1 : 0, 0);
+
+ ret = 0;
+
+PPE_OPEN_EXIT:
+ return ret;
+}
+
+static void ppe_close(struct atm_vcc *vcc)
+{
+ int conn;
+ struct port *port;
+ struct connection *connection;
+ if ( vcc == NULL )
+ return;
+
+ /* get connection id */
+ conn = find_vcc(vcc);
+ if ( conn < 0 ) {
+ pr_err("can't find vcc\n");
+ goto PPE_CLOSE_EXIT;
+ }
+ connection = &g_atm_priv_data.conn[conn];
+ port = &g_atm_priv_data.port[connection->port];
+
+ /* clear htu */
+ clear_htu_entry(conn);
+
+ /* release connection */
+ connection->vcc = NULL;
+ connection->aal5_vcc_crc_err = 0;
+ connection->aal5_vcc_oversize_sdu = 0;
+ clear_bit(conn, &g_atm_priv_data.conn_table);
+
+ /* disable irq */
+ if ( g_atm_priv_data.conn_table == 0 ) {
+ disable_irq(PPE_MAILBOX_IGU1_INT);
+ ifx_atm_alloc_tx = NULL;
+ }
+
+ /* release bandwidth */
+ switch ( vcc->qos.txtp.traffic_class )
+ {
+ case ATM_CBR:
+ case ATM_VBR_RT:
+ port->tx_current_cell_rate -= vcc->qos.txtp.max_pcr;
+ break;
+ case ATM_VBR_NRT:
+ port->tx_current_cell_rate -= vcc->qos.txtp.scr;
+ break;
+ case ATM_UBR_PLUS:
+ port->tx_current_cell_rate -= vcc->qos.txtp.min_pcr;
+ break;
+ }
+
+PPE_CLOSE_EXIT:
+ return;
+}
+
+static int ppe_send(struct atm_vcc *vcc, struct sk_buff *skb)
+{
+ int ret;
+ int conn;
+ int desc_base;
+ struct tx_descriptor reg_desc = {0};
+ struct sk_buff *new_skb;
+
+ if ( vcc == NULL || skb == NULL )
+ return -EINVAL;
+
+ skb_get(skb);
+ atm_free_tx_skb_vcc(skb, vcc);
+
+ conn = find_vcc(vcc);
+ if ( conn < 0 ) {
+ ret = -EINVAL;
+ goto FIND_VCC_FAIL;
+ }
+
+ if ( !g_showtime ) {
+ pr_debug("not in showtime\n");
+ ret = -EIO;
+ goto PPE_SEND_FAIL;
+ }
+
+ if ( vcc->qos.aal == ATM_AAL5 ) {
+ int byteoff;
+ int datalen;
+ struct tx_inband_header *header;
+
+ byteoff = (unsigned int)skb->data & (DATA_BUFFER_ALIGNMENT - 1);
+ if ( skb_headroom(skb) < byteoff + TX_INBAND_HEADER_LENGTH )
+ new_skb = skb_duplicate(skb);
+ else
+ new_skb = skb_break_away_from_protocol(skb);
+ if ( new_skb == NULL ) {
+ pr_err("either skb_duplicate or skb_break_away_from_protocol fail\n");
+ ret = -ENOMEM;
+ goto PPE_SEND_FAIL;
+ }
+ dev_kfree_skb_any(skb);
+ skb = new_skb;
+
+ datalen = skb->len;
+ byteoff = (unsigned int)skb->data & (DATA_BUFFER_ALIGNMENT - 1);
+
+ skb_push(skb, byteoff + TX_INBAND_HEADER_LENGTH);
+
+ header = (struct tx_inband_header *)skb->data;
+
+ /* setup inband trailer */
+ header->uu = 0;
+ header->cpi = 0;
+ header->pad = aal5_fill_pattern;
+ header->res1 = 0;
+
+ /* setup cell header */
+ header->clp = (vcc->atm_options & ATM_ATMOPT_CLP) ? 1 : 0;
+ header->pti = ATM_PTI_US0;
+ header->vci = vcc->vci;
+ header->vpi = vcc->vpi;
+ header->gfc = 0;
+
+ /* setup descriptor */
+ reg_desc.dataptr = (unsigned int)skb->data >> 2;
+ reg_desc.datalen = datalen;
+ reg_desc.byteoff = byteoff;
+ reg_desc.iscell = 0;
+ } else {
+ /* if data pointer is not aligned, allocate new sk_buff */
+ if ( ((unsigned int)skb->data & (DATA_BUFFER_ALIGNMENT - 1)) != 0 ) {
+ pr_err("skb->data not aligned\n");
+ new_skb = skb_duplicate(skb);
+ } else
+ new_skb = skb_break_away_from_protocol(skb);
+ if ( new_skb == NULL ) {
+ pr_err("either skb_duplicate or skb_break_away_from_protocol fail\n");
+ ret = -ENOMEM;
+ goto PPE_SEND_FAIL;
+ }
+ dev_kfree_skb_any(skb);
+ skb = new_skb;
+
+ reg_desc.dataptr = (unsigned int)skb->data >> 2;
+ reg_desc.datalen = skb->len;
+ reg_desc.byteoff = 0;
+ reg_desc.iscell = 1;
+ }
+
+ reg_desc.own = 1;
+ reg_desc.c = 1;
+ reg_desc.sop = reg_desc.eop = 1;
+
+ desc_base = get_tx_desc(conn);
+ if ( desc_base < 0 ) {
+ pr_debug("ALLOC_TX_CONNECTION_FAIL\n");
+ ret = -EIO;
+ goto PPE_SEND_FAIL;
+ }
+
+ if ( vcc->stats )
+ atomic_inc(&vcc->stats->tx);
+ if ( vcc->qos.aal == ATM_AAL5 )
+ g_atm_priv_data.wtx_pdu++;
+
+ /* update descriptor send pointer */
+ if ( g_atm_priv_data.conn[conn].tx_skb[desc_base] != NULL )
+ dev_kfree_skb_any(g_atm_priv_data.conn[conn].tx_skb[desc_base]);
+ g_atm_priv_data.conn[conn].tx_skb[desc_base] = skb;
+
+ /* write discriptor to memory and write back cache */
+ g_atm_priv_data.conn[conn].tx_desc[desc_base] = reg_desc;
+ dma_cache_wback((unsigned long)skb->data, skb->len);
+
+ mailbox_signal(conn, 1);
+
+ adsl_led_flash();
+
+ return 0;
+
+FIND_VCC_FAIL:
+ pr_err("FIND_VCC_FAIL\n");
+ g_atm_priv_data.wtx_err_pdu++;
+ dev_kfree_skb_any(skb);
+ return ret;
+
+PPE_SEND_FAIL:
+ if ( vcc->qos.aal == ATM_AAL5 )
+ g_atm_priv_data.wtx_drop_pdu++;
+ if ( vcc->stats )
+ atomic_inc(&vcc->stats->tx_err);
+ dev_kfree_skb_any(skb);
+ return ret;
+}
+
+/* operation and maintainance */
+static int ppe_send_oam(struct atm_vcc *vcc, void *cell, int flags)
+{
+ int conn;
+ struct uni_cell_header *uni_cell_header = (struct uni_cell_header *)cell;
+ int desc_base;
+ struct sk_buff *skb;
+ struct tx_descriptor reg_desc = {0};
+
+ if ( ((uni_cell_header->pti == ATM_PTI_SEGF5 || uni_cell_header->pti == ATM_PTI_E2EF5)
+ && find_vpivci(uni_cell_header->vpi, uni_cell_header->vci) < 0)
+ || ((uni_cell_header->vci == 0x03 || uni_cell_header->vci == 0x04)
+ && find_vpi(uni_cell_header->vpi) < 0) )
+ {
+ g_atm_priv_data.wtx_err_oam++;
+ return -EINVAL;
+ }
+
+ if ( !g_showtime ) {
+ pr_err("not in showtime\n");
+ g_atm_priv_data.wtx_drop_oam++;
+ return -EIO;
+ }
+
+ conn = find_vcc(vcc);
+ if ( conn < 0 ) {
+ pr_err("FIND_VCC_FAIL\n");
+ g_atm_priv_data.wtx_drop_oam++;
+ return -EINVAL;
+ }
+
+ skb = alloc_skb_tx(CELL_SIZE);
+ if ( skb == NULL ) {
+ pr_err("ALLOC_SKB_TX_FAIL\n");
+ g_atm_priv_data.wtx_drop_oam++;
+ return -ENOMEM;
+ }
+ skb_put(skb, CELL_SIZE);
+ memcpy(skb->data, cell, CELL_SIZE);
+
+ reg_desc.dataptr = (unsigned int)skb->data >> 2;
+ reg_desc.datalen = CELL_SIZE;
+ reg_desc.byteoff = 0;
+ reg_desc.iscell = 1;
+
+ reg_desc.own = 1;
+ reg_desc.c = 1;
+ reg_desc.sop = reg_desc.eop = 1;
+
+ desc_base = get_tx_desc(conn);
+ if ( desc_base < 0 ) {
+ dev_kfree_skb_any(skb);
+ pr_err("ALLOC_TX_CONNECTION_FAIL\n");
+ g_atm_priv_data.wtx_drop_oam++;
+ return -EIO;
+ }
+
+ if ( vcc->stats )
+ atomic_inc(&vcc->stats->tx);
+
+ /* update descriptor send pointer */
+ if ( g_atm_priv_data.conn[conn].tx_skb[desc_base] != NULL )
+ dev_kfree_skb_any(g_atm_priv_data.conn[conn].tx_skb[desc_base]);
+ g_atm_priv_data.conn[conn].tx_skb[desc_base] = skb;
+
+ /* write discriptor to memory and write back cache */
+ g_atm_priv_data.conn[conn].tx_desc[desc_base] = reg_desc;
+ dma_cache_wback((unsigned long)skb->data, CELL_SIZE);
+
+ mailbox_signal(conn, 1);
+
+ g_atm_priv_data.wtx_oam++;
+ adsl_led_flash();
+
+ return 0;
+}
+
+static int ppe_change_qos(struct atm_vcc *vcc, struct atm_qos *qos, int flags)
+{
+ int conn;
+
+ if ( vcc == NULL || qos == NULL )
+ return -EINVAL;
+
+ conn = find_vcc(vcc);
+ if ( conn < 0 )
+ return -EINVAL;
+
+ set_qsb(vcc, qos, conn);
+
+ return 0;
+}
+
+static inline void adsl_led_flash(void)
+{
+ ifx_mei_atm_led_blink();
+}
+
+/*
+* Description:
+* Add a 32-bit value to 64-bit value, and put result in a 64-bit variable.
+* Input:
+* opt1 --- ppe_u64_t, first operand, a 64-bit unsigned integer value
+* opt2 --- unsigned int, second operand, a 32-bit unsigned integer value
+* ret --- ppe_u64_t, pointer to a variable to hold result
+* Output:
+* none
+*/
+static inline void u64_add_u32(ppe_u64_t opt1, unsigned int opt2, ppe_u64_t *ret)
+{
+ ret->l = opt1.l + opt2;
+ if ( ret->l < opt1.l || ret->l < opt2 )
+ ret->h++;
+}
+
+static inline struct sk_buff* alloc_skb_rx(void)
+{
+ struct sk_buff *skb;
+
+ skb = dev_alloc_skb(RX_DMA_CH_AAL_BUF_SIZE + DATA_BUFFER_ALIGNMENT);
+ if ( skb != NULL ) {
+ /* must be burst length alignment */
+ if ( ((unsigned int)skb->data & (DATA_BUFFER_ALIGNMENT - 1)) != 0 )
+ skb_reserve(skb, ~((unsigned int)skb->data + (DATA_BUFFER_ALIGNMENT - 1)) & (DATA_BUFFER_ALIGNMENT - 1));
+ /* pub skb in reserved area "skb->data - 4" */
+ *((struct sk_buff **)skb->data - 1) = skb;
+ /* write back and invalidate cache */
+ dma_cache_wback_inv((unsigned long)skb->data - sizeof(skb), sizeof(skb));
+ /* invalidate cache */
+#if defined(ENABLE_LESS_CACHE_INV) && ENABLE_LESS_CACHE_INV
+ dma_cache_inv((unsigned long)skb->data, LESS_CACHE_INV_LEN);
+#else
+ dma_cache_inv((unsigned long)skb->data, RX_DMA_CH_AAL_BUF_SIZE);
+#endif
+ }
+ return skb;
+}
+
+static inline struct sk_buff* alloc_skb_tx(unsigned int size)
+{
+ struct sk_buff *skb;
+
+ /* allocate memory including header and padding */
+ size += TX_INBAND_HEADER_LENGTH + MAX_TX_PACKET_ALIGN_BYTES + MAX_TX_PACKET_PADDING_BYTES;
+ size &= ~(DATA_BUFFER_ALIGNMENT - 1);
+ skb = dev_alloc_skb(size + DATA_BUFFER_ALIGNMENT);
+ /* must be burst length alignment */
+ if ( skb != NULL )
+ skb_reserve(skb, (~((unsigned int)skb->data + (DATA_BUFFER_ALIGNMENT - 1)) & (DATA_BUFFER_ALIGNMENT - 1)) + TX_INBAND_HEADER_LENGTH);
+ return skb;
+}
+
+struct sk_buff* atm_alloc_tx(struct atm_vcc *vcc, unsigned int size)
+{
+ int conn;
+ struct sk_buff *skb;
+
+ /* oversize packet */
+ if ( size > aal5s_max_packet_size ) {
+ pr_err("atm_alloc_tx: oversize packet\n");
+ return NULL;
+ }
+ /* send buffer overflow */
+ if ( sk_wmem_alloc_get(sk_atm(vcc)) && !atm_may_send(vcc, size) ) {
+ pr_err("atm_alloc_tx: send buffer overflow\n");
+ return NULL;
+ }
+ conn = find_vcc(vcc);
+ if ( conn < 0 ) {
+ pr_err("atm_alloc_tx: unknown VCC\n");
+ return NULL;
+ }
+
+ skb = dev_alloc_skb(size);
+ if ( skb == NULL ) {
+ pr_err("atm_alloc_tx: sk buffer is used up\n");
+ return NULL;
+ }
+
+ atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
+
+ return skb;
+}
+
+static inline void atm_free_tx_skb_vcc(struct sk_buff *skb, struct atm_vcc *vcc)
+{
+ if ( vcc->pop != NULL )
+ vcc->pop(vcc, skb);
+ else
+ dev_kfree_skb_any(skb);
+}
+
+static inline struct sk_buff *get_skb_rx_pointer(unsigned int dataptr)
+{
+ unsigned int skb_dataptr;
+ struct sk_buff *skb;
+
+ skb_dataptr = ((dataptr - 1) << 2) | KSEG1;
+ skb = *(struct sk_buff **)skb_dataptr;
+
+ ASSERT((unsigned int)skb >= KSEG0, "invalid skb - skb = %#08x, dataptr = %#08x", (unsigned int)skb, dataptr);
+ ASSERT(((unsigned int)skb->data | KSEG1) == ((dataptr << 2) | KSEG1), "invalid skb - skb = %#08x, skb->data = %#08x, dataptr = %#08x", (unsigned int)skb, (unsigned int)skb->data, dataptr);
+
+ return skb;
+}
+
+static inline int get_tx_desc(unsigned int conn)
+{
+ int desc_base = -1;
+ struct connection *p_conn = &g_atm_priv_data.conn[conn];
+
+ if ( p_conn->tx_desc[p_conn->tx_desc_pos].own == 0 ) {
+ desc_base = p_conn->tx_desc_pos;
+ if ( ++(p_conn->tx_desc_pos) == dma_tx_descriptor_length )
+ p_conn->tx_desc_pos = 0;
+ }
+
+ return desc_base;
+}
+
+static struct sk_buff* skb_duplicate(struct sk_buff *skb)
+{
+ struct sk_buff *new_skb;
+
+ new_skb = alloc_skb_tx(skb->len);
+ if ( new_skb == NULL )
+ return NULL;
+
+ skb_put(new_skb, skb->len);
+ memcpy(new_skb->data, skb->data, skb->len);
+
+ return new_skb;
+}
+
+static struct sk_buff* skb_break_away_from_protocol(struct sk_buff *skb)
+{
+ struct sk_buff *new_skb;
+
+ if ( skb_shared(skb) ) {
+ new_skb = skb_clone(skb, GFP_ATOMIC);
+ if ( new_skb == NULL )
+ return NULL;
+ } else
+ new_skb = skb_get(skb);
+
+ skb_dst_drop(new_skb);
+#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
+ nf_conntrack_put(new_skb->nfct);
+ new_skb->nfct = NULL;
+ nf_conntrack_put_reasm(new_skb->nfct_reasm);
+ new_skb->nfct_reasm = NULL;
+ #ifdef CONFIG_BRIDGE_NETFILTER
+ nf_bridge_put(new_skb->nf_bridge);
+ new_skb->nf_bridge = NULL;
+ #endif
+#endif
+
+ return new_skb;
+}
+
+static inline void mailbox_oam_rx_handler(void)
+{
+ unsigned int vlddes = WRX_DMA_CHANNEL_CONFIG(RX_DMA_CH_OAM)->vlddes;
+ struct rx_descriptor reg_desc;
+ struct uni_cell_header *header;
+ int conn;
+ struct atm_vcc *vcc;
+ unsigned int i;
+
+ for ( i = 0; i < vlddes; i++ ) {
+ unsigned int loop_count = 0;
+
+ do {
+ reg_desc = g_atm_priv_data.oam_desc[g_atm_priv_data.oam_desc_pos];
+ if ( ++loop_count == 1000 )
+ break;
+ } while ( reg_desc.own || !reg_desc.c ); // keep test OWN and C bit until data is ready
+ ASSERT(loop_count == 1, "loop_count = %u, own = %d, c = %d, oam_desc_pos = %u", loop_count, (int)reg_desc.own, (int)reg_desc.c, g_atm_priv_data.oam_desc_pos);
+
+ header = (struct uni_cell_header *)&g_atm_priv_data.oam_buf[g_atm_priv_data.oam_desc_pos * RX_DMA_CH_OAM_BUF_SIZE];
+
+ if ( header->pti == ATM_PTI_SEGF5 || header->pti == ATM_PTI_E2EF5 )
+ conn = find_vpivci(header->vpi, header->vci);
+ else if ( header->vci == 0x03 || header->vci == 0x04 )
+ conn = find_vpi(header->vpi);
+ else
+ conn = -1;
+
+ if ( conn >= 0 && g_atm_priv_data.conn[conn].vcc != NULL ) {
+ vcc = g_atm_priv_data.conn[conn].vcc;
+
+ if ( vcc->push_oam != NULL )
+ vcc->push_oam(vcc, header);
+ else
+ ifx_push_oam((unsigned char *)header);
+
+ g_atm_priv_data.wrx_oam++;
+
+ adsl_led_flash();
+ } else
+ g_atm_priv_data.wrx_drop_oam++;
+
+ reg_desc.byteoff = 0;
+ reg_desc.datalen = RX_DMA_CH_OAM_BUF_SIZE;
+ reg_desc.own = 1;
+ reg_desc.c = 0;
+
+ g_atm_priv_data.oam_desc[g_atm_priv_data.oam_desc_pos] = reg_desc;
+ if ( ++g_atm_priv_data.oam_desc_pos == RX_DMA_CH_OAM_DESC_LEN )
+ g_atm_priv_data.oam_desc_pos = 0;
+
+ dma_cache_inv((unsigned long)header, CELL_SIZE);
+ mailbox_signal(RX_DMA_CH_OAM, 0);
+ }
+}
+
+static inline void mailbox_aal_rx_handler(void)
+{
+ unsigned int vlddes = WRX_DMA_CHANNEL_CONFIG(RX_DMA_CH_AAL)->vlddes;
+ struct rx_descriptor reg_desc;
+ int conn;
+ struct atm_vcc *vcc;
+ struct sk_buff *skb, *new_skb;
+ struct rx_inband_trailer *trailer;
+ unsigned int i;
+
+ for ( i = 0; i < vlddes; i++ ) {
+ unsigned int loop_count = 0;
+
+ do {
+ reg_desc = g_atm_priv_data.aal_desc[g_atm_priv_data.aal_desc_pos];
+ if ( ++loop_count == 1000 )
+ break;
+ } while ( reg_desc.own || !reg_desc.c ); // keep test OWN and C bit until data is ready
+ ASSERT(loop_count == 1, "loop_count = %u, own = %d, c = %d, aal_desc_pos = %u", loop_count, (int)reg_desc.own, (int)reg_desc.c, g_atm_priv_data.aal_desc_pos);
+
+ conn = reg_desc.id;
+
+ if ( g_atm_priv_data.conn[conn].vcc != NULL ) {
+ vcc = g_atm_priv_data.conn[conn].vcc;
+
+ skb = get_skb_rx_pointer(reg_desc.dataptr);
+
+ if ( reg_desc.err ) {
+ if ( vcc->qos.aal == ATM_AAL5 ) {
+ trailer = (struct rx_inband_trailer *)((unsigned int)skb->data + ((reg_desc.byteoff + reg_desc.datalen + MAX_RX_PACKET_PADDING_BYTES) & ~MAX_RX_PACKET_PADDING_BYTES));
+ if ( trailer->stw_crc )
+ g_atm_priv_data.conn[conn].aal5_vcc_crc_err++;
+ if ( trailer->stw_ovz )
+ g_atm_priv_data.conn[conn].aal5_vcc_oversize_sdu++;
+ g_atm_priv_data.wrx_drop_pdu++;
+ }
+ if ( vcc->stats ) {
+ atomic_inc(&vcc->stats->rx_drop);
+ atomic_inc(&vcc->stats->rx_err);
+ }
+ reg_desc.err = 0;
+ } else if ( atm_charge(vcc, skb->truesize) ) {
+ new_skb = alloc_skb_rx();
+ if ( new_skb != NULL ) {
+#if defined(ENABLE_LESS_CACHE_INV) && ENABLE_LESS_CACHE_INV
+ if ( reg_desc.byteoff + reg_desc.datalen > LESS_CACHE_INV_LEN )
+ dma_cache_inv((unsigned long)skb->data + LESS_CACHE_INV_LEN, reg_desc.byteoff + reg_desc.datalen - LESS_CACHE_INV_LEN);
+#endif
+
+ skb_reserve(skb, reg_desc.byteoff);
+ skb_put(skb, reg_desc.datalen);
+ ATM_SKB(skb)->vcc = vcc;
+
+ vcc->push(vcc, skb);
+
+ if ( vcc->qos.aal == ATM_AAL5 )
+ g_atm_priv_data.wrx_pdu++;
+ if ( vcc->stats )
+ atomic_inc(&vcc->stats->rx);
+ adsl_led_flash();
+
+ reg_desc.dataptr = (unsigned int)new_skb->data >> 2;
+ } else {
+ atm_return(vcc, skb->truesize);
+ if ( vcc->qos.aal == ATM_AAL5 )
+ g_atm_priv_data.wrx_drop_pdu++;
+ if ( vcc->stats )
+ atomic_inc(&vcc->stats->rx_drop);
+ }
+ } else {
+ if ( vcc->qos.aal == ATM_AAL5 )
+ g_atm_priv_data.wrx_drop_pdu++;
+ if ( vcc->stats )
+ atomic_inc(&vcc->stats->rx_drop);
+ }
+ } else {
+ g_atm_priv_data.wrx_drop_pdu++;
+ }
+
+ reg_desc.byteoff = 0;
+ reg_desc.datalen = RX_DMA_CH_AAL_BUF_SIZE;
+ reg_desc.own = 1;
+ reg_desc.c = 0;
+
+ g_atm_priv_data.aal_desc[g_atm_priv_data.aal_desc_pos] = reg_desc;
+ if ( ++g_atm_priv_data.aal_desc_pos == dma_rx_descriptor_length )
+ g_atm_priv_data.aal_desc_pos = 0;
+
+ mailbox_signal(RX_DMA_CH_AAL, 0);
+ }
+}
+
+static irqreturn_t mailbox_irq_handler(int irq, void *dev_id)
+{
+ if ( !*MBOX_IGU1_ISR )
+ return IRQ_HANDLED;
+
+ *MBOX_IGU1_ISRC = *MBOX_IGU1_ISR;
+ mailbox_oam_rx_handler();
+ mailbox_aal_rx_handler();
+
+ return IRQ_HANDLED;
+}
+
+static inline void mailbox_signal(unsigned int queue, int is_tx)
+{
+ int count = 1000;
+
+ if ( is_tx ) {
+ while ( MBOX_IGU3_ISR_ISR(queue + FIRST_QSB_QID + 16) && count > 0 )
+ count--;
+ *MBOX_IGU3_ISRS = MBOX_IGU3_ISRS_SET(queue + FIRST_QSB_QID + 16);
+ } else {
+ while ( MBOX_IGU3_ISR_ISR(queue) && count > 0 )
+ count--;
+ *MBOX_IGU3_ISRS = MBOX_IGU3_ISRS_SET(queue);
+ }
+
+ ASSERT(count > 0, "queue = %u, is_tx = %d, MBOX_IGU3_ISR = 0x%08x", queue, is_tx, IFX_REG_R32(MBOX_IGU3_ISR));
+}
+
+static void set_qsb(struct atm_vcc *vcc, struct atm_qos *qos, unsigned int queue)
+{
+ struct clk *fpi_clk = clk_get_fpi();
+ unsigned int qsb_clk = clk_get_rate(fpi_clk);
+ unsigned int qsb_qid = queue + FIRST_QSB_QID;
+ union qsb_queue_parameter_table qsb_queue_parameter_table = {{0}};
+ union qsb_queue_vbr_parameter_table qsb_queue_vbr_parameter_table = {{0}};
+ unsigned int tmp;
+
+
+ /*
+ * Peak Cell Rate (PCR) Limiter
+ */
+ if ( qos->txtp.max_pcr == 0 )
+ qsb_queue_parameter_table.bit.tp = 0; /* disable PCR limiter */
+ else {
+ /* peak cell rate would be slightly lower than requested [maximum_rate / pcr = (qsb_clock / 8) * (time_step / 4) / pcr] */
+ tmp = ((qsb_clk * qsb_tstep) >> 5) / qos->txtp.max_pcr + 1;
+ /* check if overflow takes place */
+ qsb_queue_parameter_table.bit.tp = tmp > QSB_TP_TS_MAX ? QSB_TP_TS_MAX : tmp;
+ }
+
+#if !defined(DISABLE_QOS_WORKAROUND) || !DISABLE_QOS_WORKAROUND
+ // A funny issue. Create two PVCs, one UBR and one UBR with max_pcr.
+ // Send packets to these two PVCs at same time, it trigger strange behavior.
+ // In A1, RAM from 0x80000000 to 0x0x8007FFFF was corrupted with fixed pattern 0x00000000 0x40000000.
+ // In A4, PPE firmware keep emiting unknown cell and do not respond to driver.
+ // To work around, create UBR always with max_pcr.
+ // If user want to create UBR without max_pcr, we give a default one larger than line-rate.
+ if ( qos->txtp.traffic_class == ATM_UBR && qsb_queue_parameter_table.bit.tp == 0 ) {
+ int port = g_atm_priv_data.conn[queue].port;
+ unsigned int max_pcr = g_atm_priv_data.port[port].tx_max_cell_rate + 1000;
+
+ tmp = ((qsb_clk * qsb_tstep) >> 5) / max_pcr + 1;
+ if ( tmp > QSB_TP_TS_MAX )
+ tmp = QSB_TP_TS_MAX;
+ else if ( tmp < 1 )
+ tmp = 1;
+ qsb_queue_parameter_table.bit.tp = tmp;
+ }
+#endif
+
+ /*
+ * Weighted Fair Queueing Factor (WFQF)
+ */
+ switch ( qos->txtp.traffic_class ) {
+ case ATM_CBR:
+ case ATM_VBR_RT:
+ /* real time queue gets weighted fair queueing bypass */
+ qsb_queue_parameter_table.bit.wfqf = 0;
+ break;
+ case ATM_VBR_NRT:
+ case ATM_UBR_PLUS:
+ /* WFQF calculation here is based on virtual cell rates, to reduce granularity for high rates */
+ /* WFQF is maximum cell rate / garenteed cell rate */
+ /* wfqf = qsb_minimum_cell_rate * QSB_WFQ_NONUBR_MAX / requested_minimum_peak_cell_rate */
+ if ( qos->txtp.min_pcr == 0 )
+ qsb_queue_parameter_table.bit.wfqf = QSB_WFQ_NONUBR_MAX;
+ else {
+ tmp = QSB_GCR_MIN * QSB_WFQ_NONUBR_MAX / qos->txtp.min_pcr;
+ if ( tmp == 0 )
+ qsb_queue_parameter_table.bit.wfqf = 1;
+ else if ( tmp > QSB_WFQ_NONUBR_MAX )
+ qsb_queue_parameter_table.bit.wfqf = QSB_WFQ_NONUBR_MAX;
+ else
+ qsb_queue_parameter_table.bit.wfqf = tmp;
+ }
+ break;
+ default:
+ case ATM_UBR:
+ qsb_queue_parameter_table.bit.wfqf = QSB_WFQ_UBR_BYPASS;
+ }
+
+ /*
+ * Sustained Cell Rate (SCR) Leaky Bucket Shaper VBR.0/VBR.1
+ */
+ if ( qos->txtp.traffic_class == ATM_VBR_RT || qos->txtp.traffic_class == ATM_VBR_NRT ) {
+ if ( qos->txtp.scr == 0 ) {
+ /* disable shaper */
+ qsb_queue_vbr_parameter_table.bit.taus = 0;
+ qsb_queue_vbr_parameter_table.bit.ts = 0;
+ } else {
+ /* Cell Loss Priority (CLP) */
+ if ( (vcc->atm_options & ATM_ATMOPT_CLP) )
+ /* CLP1 */
+ qsb_queue_parameter_table.bit.vbr = 1;
+ else
+ /* CLP0 */
+ qsb_queue_parameter_table.bit.vbr = 0;
+ /* Rate Shaper Parameter (TS) and Burst Tolerance Parameter for SCR (tauS) */
+ tmp = ((qsb_clk * qsb_tstep) >> 5) / qos->txtp.scr + 1;
+ qsb_queue_vbr_parameter_table.bit.ts = tmp > QSB_TP_TS_MAX ? QSB_TP_TS_MAX : tmp;
+ tmp = (qos->txtp.mbs - 1) * (qsb_queue_vbr_parameter_table.bit.ts - qsb_queue_parameter_table.bit.tp) / 64;
+ if ( tmp == 0 )
+ qsb_queue_vbr_parameter_table.bit.taus = 1;
+ else if ( tmp > QSB_TAUS_MAX )
+ qsb_queue_vbr_parameter_table.bit.taus = QSB_TAUS_MAX;
+ else
+ qsb_queue_vbr_parameter_table.bit.taus = tmp;
+ }
+ } else {
+ qsb_queue_vbr_parameter_table.bit.taus = 0;
+ qsb_queue_vbr_parameter_table.bit.ts = 0;
+ }
+
+ /* Queue Parameter Table (QPT) */
+ *QSB_RTM = QSB_RTM_DM_SET(QSB_QPT_SET_MASK);
+ *QSB_RTD = QSB_RTD_TTV_SET(qsb_queue_parameter_table.dword);
+ *QSB_RAMAC = QSB_RAMAC_RW_SET(QSB_RAMAC_RW_WRITE) | QSB_RAMAC_TSEL_SET(QSB_RAMAC_TSEL_QPT) | QSB_RAMAC_LH_SET(QSB_RAMAC_LH_LOW) | QSB_RAMAC_TESEL_SET(qsb_qid);
+ /* Queue VBR Paramter Table (QVPT) */
+ *QSB_RTM = QSB_RTM_DM_SET(QSB_QVPT_SET_MASK);
+ *QSB_RTD = QSB_RTD_TTV_SET(qsb_queue_vbr_parameter_table.dword);
+ *QSB_RAMAC = QSB_RAMAC_RW_SET(QSB_RAMAC_RW_WRITE) | QSB_RAMAC_TSEL_SET(QSB_RAMAC_TSEL_VBR) | QSB_RAMAC_LH_SET(QSB_RAMAC_LH_LOW) | QSB_RAMAC_TESEL_SET(qsb_qid);
+
+}
+
+static void qsb_global_set(void)
+{
+ struct clk *fpi_clk = clk_get_fpi();
+ unsigned int qsb_clk = clk_get_rate(fpi_clk);
+ int i;
+ unsigned int tmp1, tmp2, tmp3;
+
+ *QSB_ICDV = QSB_ICDV_TAU_SET(qsb_tau);
+ *QSB_SBL = QSB_SBL_SBL_SET(qsb_srvm);
+ *QSB_CFG = QSB_CFG_TSTEPC_SET(qsb_tstep >> 1);
+
+ /*
+ * set SCT and SPT per port
+ */
+ for ( i = 0; i < ATM_PORT_NUMBER; i++ ) {
+ if ( g_atm_priv_data.port[i].tx_max_cell_rate != 0 ) {
+ tmp1 = ((qsb_clk * qsb_tstep) >> 1) / g_atm_priv_data.port[i].tx_max_cell_rate;
+ tmp2 = tmp1 >> 6; /* integer value of Tsb */
+ tmp3 = (tmp1 & ((1 << 6) - 1)) + 1; /* fractional part of Tsb */
+ /* carry over to integer part (?) */
+ if ( tmp3 == (1 << 6) ) {
+ tmp3 = 0;
+ tmp2++;
+ }
+ if ( tmp2 == 0 )
+ tmp2 = tmp3 = 1;
+ /* 1. set mask */
+ /* 2. write value to data transfer register */
+ /* 3. start the tranfer */
+ /* SCT (FracRate) */
+ *QSB_RTM = QSB_RTM_DM_SET(QSB_SET_SCT_MASK);
+ *QSB_RTD = QSB_RTD_TTV_SET(tmp3);
+ *QSB_RAMAC = QSB_RAMAC_RW_SET(QSB_RAMAC_RW_WRITE) |
+ QSB_RAMAC_TSEL_SET(QSB_RAMAC_TSEL_SCT) |
+ QSB_RAMAC_LH_SET(QSB_RAMAC_LH_LOW) |
+ QSB_RAMAC_TESEL_SET(i & 0x01);
+ /* SPT (SBV + PN + IntRage) */
+ *QSB_RTM = QSB_RTM_DM_SET(QSB_SET_SPT_MASK);
+ *QSB_RTD = QSB_RTD_TTV_SET(QSB_SPT_SBV_VALID | QSB_SPT_PN_SET(i & 0x01) | QSB_SPT_INTRATE_SET(tmp2));
+ *QSB_RAMAC = QSB_RAMAC_RW_SET(QSB_RAMAC_RW_WRITE) |
+ QSB_RAMAC_TSEL_SET(QSB_RAMAC_TSEL_SPT) |
+ QSB_RAMAC_LH_SET(QSB_RAMAC_LH_LOW) |
+ QSB_RAMAC_TESEL_SET(i & 0x01);
+ }
+ }
+}
+
+static inline void set_htu_entry(unsigned int vpi, unsigned int vci, unsigned int queue, int aal5, int is_retx)
+{
+ struct htu_entry htu_entry = {
+ res1: 0x00,
+ clp: is_retx ? 0x01 : 0x00,
+ pid: g_atm_priv_data.conn[queue].port & 0x01,
+ vpi: vpi,
+ vci: vci,
+ pti: 0x00,
+ vld: 0x01};
+
+ struct htu_mask htu_mask = {
+ set: 0x01,
+ clp: 0x01,
+ pid_mask: 0x02,
+ vpi_mask: 0x00,
+ vci_mask: 0x0000,
+ pti_mask: 0x03, // 0xx, user data
+ clear: 0x00};
+
+ struct htu_result htu_result = {
+ res1: 0x00,
+ cellid: queue,
+ res2: 0x00,
+ type: aal5 ? 0x00 : 0x01,
+ ven: 0x01,
+ res3: 0x00,
+ qid: queue};
+
+ *HTU_RESULT(queue + OAM_HTU_ENTRY_NUMBER) = htu_result;
+ *HTU_MASK(queue + OAM_HTU_ENTRY_NUMBER) = htu_mask;
+ *HTU_ENTRY(queue + OAM_HTU_ENTRY_NUMBER) = htu_entry;
+}
+
+static inline void clear_htu_entry(unsigned int queue)
+{
+ HTU_ENTRY(queue + OAM_HTU_ENTRY_NUMBER)->vld = 0;
+}
+
+static void validate_oam_htu_entry(void)
+{
+ HTU_ENTRY(OAM_F4_SEG_HTU_ENTRY)->vld = 1;
+ HTU_ENTRY(OAM_F4_TOT_HTU_ENTRY)->vld = 1;
+ HTU_ENTRY(OAM_F5_HTU_ENTRY)->vld = 1;
+}
+
+static void invalidate_oam_htu_entry(void)
+{
+ HTU_ENTRY(OAM_F4_SEG_HTU_ENTRY)->vld = 0;
+ HTU_ENTRY(OAM_F4_TOT_HTU_ENTRY)->vld = 0;
+ HTU_ENTRY(OAM_F5_HTU_ENTRY)->vld = 0;
+}
+
+static inline int find_vpi(unsigned int vpi)
+{
+ int i;
+ unsigned int bit;
+
+ for ( i = 0, bit = 1; i < MAX_PVC_NUMBER; i++, bit <<= 1 ) {
+ if ( (g_atm_priv_data.conn_table & bit) != 0
+ && g_atm_priv_data.conn[i].vcc != NULL
+ && vpi == g_atm_priv_data.conn[i].vcc->vpi )
+ return i;
+ }
+
+ return -1;
+}
+
+static inline int find_vpivci(unsigned int vpi, unsigned int vci)
+{
+ int i;
+ unsigned int bit;
+
+ for ( i = 0, bit = 1; i < MAX_PVC_NUMBER; i++, bit <<= 1 ) {
+ if ( (g_atm_priv_data.conn_table & bit) != 0
+ && g_atm_priv_data.conn[i].vcc != NULL
+ && vpi == g_atm_priv_data.conn[i].vcc->vpi
+ && vci == g_atm_priv_data.conn[i].vcc->vci )
+ return i;
+ }
+
+ return -1;
+}
+
+static inline int find_vcc(struct atm_vcc *vcc)
+{
+ int i;
+ unsigned int bit;
+
+ for ( i = 0, bit = 1; i < MAX_PVC_NUMBER; i++, bit <<= 1 ) {
+ if ( (g_atm_priv_data.conn_table & bit) != 0
+ && g_atm_priv_data.conn[i].vcc == vcc )
+ return i;
+ }
+
+ return -1;
+}
+
+static inline int ifx_atm_version(const struct ltq_atm_ops *ops, char *buf)
+{
+ int len = 0;
+ unsigned int major, minor;
+
+ ops->fw_ver(&major, &minor);
+
+ len += sprintf(buf + len, "ATM%d.%d.%d", IFX_ATM_VER_MAJOR, IFX_ATM_VER_MID, IFX_ATM_VER_MINOR);
+ len += sprintf(buf + len, " ATM (A1) firmware version %d.%d\n", major, minor);
+
+ return len;
+}
+
+static inline void check_parameters(void)
+{
+ /* Please refer to Amazon spec 15.4 for setting these values. */
+ if ( qsb_tau < 1 )
+ qsb_tau = 1;
+ if ( qsb_tstep < 1 )
+ qsb_tstep = 1;
+ else if ( qsb_tstep > 4 )
+ qsb_tstep = 4;
+ else if ( qsb_tstep == 3 )
+ qsb_tstep = 2;
+
+ /* There is a delay between PPE write descriptor and descriptor is */
+ /* really stored in memory. Host also has this delay when writing */
+ /* descriptor. So PPE will use this value to determine if the write */
+ /* operation makes effect. */
+ if ( write_descriptor_delay < 0 )
+ write_descriptor_delay = 0;
+
+ if ( aal5_fill_pattern < 0 )
+ aal5_fill_pattern = 0;
+ else
+ aal5_fill_pattern &= 0xFF;
+
+ /* Because of the limitation of length field in descriptors, the packet */
+ /* size could not be larger than 64K minus overhead size. */
+ if ( aal5r_max_packet_size < 0 )
+ aal5r_max_packet_size = 0;
+ else if ( aal5r_max_packet_size >= 65535 - MAX_RX_FRAME_EXTRA_BYTES )
+ aal5r_max_packet_size = 65535 - MAX_RX_FRAME_EXTRA_BYTES;
+ if ( aal5r_min_packet_size < 0 )
+ aal5r_min_packet_size = 0;
+ else if ( aal5r_min_packet_size > aal5r_max_packet_size )
+ aal5r_min_packet_size = aal5r_max_packet_size;
+ if ( aal5s_max_packet_size < 0 )
+ aal5s_max_packet_size = 0;
+ else if ( aal5s_max_packet_size >= 65535 - MAX_TX_FRAME_EXTRA_BYTES )
+ aal5s_max_packet_size = 65535 - MAX_TX_FRAME_EXTRA_BYTES;
+ if ( aal5s_min_packet_size < 0 )
+ aal5s_min_packet_size = 0;
+ else if ( aal5s_min_packet_size > aal5s_max_packet_size )
+ aal5s_min_packet_size = aal5s_max_packet_size;
+
+ if ( dma_rx_descriptor_length < 2 )
+ dma_rx_descriptor_length = 2;
+ if ( dma_tx_descriptor_length < 2 )
+ dma_tx_descriptor_length = 2;
+ if ( dma_rx_clp1_descriptor_threshold < 0 )
+ dma_rx_clp1_descriptor_threshold = 0;
+ else if ( dma_rx_clp1_descriptor_threshold > dma_rx_descriptor_length )
+ dma_rx_clp1_descriptor_threshold = dma_rx_descriptor_length;
+
+ if ( dma_tx_descriptor_length < 2 )
+ dma_tx_descriptor_length = 2;
+}
+
+static inline int init_priv_data(void)
+{
+ void *p;
+ int i;
+ struct rx_descriptor rx_desc = {0};
+ struct sk_buff *skb;
+ volatile struct tx_descriptor *p_tx_desc;
+ struct sk_buff **ppskb;
+
+ // clear atm private data structure
+ memset(&g_atm_priv_data, 0, sizeof(g_atm_priv_data));
+
+ // allocate memory for RX (AAL) descriptors
+ p = kzalloc(dma_rx_descriptor_length * sizeof(struct rx_descriptor) + DESC_ALIGNMENT, GFP_KERNEL);
+ if ( p == NULL )
+ return -1;
+ dma_cache_wback_inv((unsigned long)p, dma_rx_descriptor_length * sizeof(struct rx_descriptor) + DESC_ALIGNMENT);
+ g_atm_priv_data.aal_desc_base = p;
+ p = (void *)((((unsigned int)p + DESC_ALIGNMENT - 1) & ~(DESC_ALIGNMENT - 1)) | KSEG1);
+ g_atm_priv_data.aal_desc = (volatile struct rx_descriptor *)p;
+
+ // allocate memory for RX (OAM) descriptors
+ p = kzalloc(RX_DMA_CH_OAM_DESC_LEN * sizeof(struct rx_descriptor) + DESC_ALIGNMENT, GFP_KERNEL);
+ if ( p == NULL )
+ return -1;
+ dma_cache_wback_inv((unsigned long)p, RX_DMA_CH_OAM_DESC_LEN * sizeof(struct rx_descriptor) + DESC_ALIGNMENT);
+ g_atm_priv_data.oam_desc_base = p;
+ p = (void *)((((unsigned int)p + DESC_ALIGNMENT - 1) & ~(DESC_ALIGNMENT - 1)) | KSEG1);
+ g_atm_priv_data.oam_desc = (volatile struct rx_descriptor *)p;
+
+ // allocate memory for RX (OAM) buffer
+ p = kzalloc(RX_DMA_CH_OAM_DESC_LEN * RX_DMA_CH_OAM_BUF_SIZE + DATA_BUFFER_ALIGNMENT, GFP_KERNEL);
+ if ( p == NULL )
+ return -1;
+ dma_cache_wback_inv((unsigned long)p, RX_DMA_CH_OAM_DESC_LEN * RX_DMA_CH_OAM_BUF_SIZE + DATA_BUFFER_ALIGNMENT);
+ g_atm_priv_data.oam_buf_base = p;
+ p = (void *)(((unsigned int)p + DATA_BUFFER_ALIGNMENT - 1) & ~(DATA_BUFFER_ALIGNMENT - 1));
+ g_atm_priv_data.oam_buf = p;
+
+ // allocate memory for TX descriptors
+ p = kzalloc(MAX_PVC_NUMBER * dma_tx_descriptor_length * sizeof(struct tx_descriptor) + DESC_ALIGNMENT, GFP_KERNEL);
+ if ( p == NULL )
+ return -1;
+ dma_cache_wback_inv((unsigned long)p, MAX_PVC_NUMBER * dma_tx_descriptor_length * sizeof(struct tx_descriptor) + DESC_ALIGNMENT);
+ g_atm_priv_data.tx_desc_base = p;
+
+ // allocate memory for TX skb pointers
+ p = kzalloc(MAX_PVC_NUMBER * dma_tx_descriptor_length * sizeof(struct sk_buff *) + 4, GFP_KERNEL);
+ if ( p == NULL )
+ return -1;
+ dma_cache_wback_inv((unsigned long)p, MAX_PVC_NUMBER * dma_tx_descriptor_length * sizeof(struct sk_buff *) + 4);
+ g_atm_priv_data.tx_skb_base = p;
+
+ // setup RX (AAL) descriptors
+ rx_desc.own = 1;
+ rx_desc.c = 0;
+ rx_desc.sop = 1;
+ rx_desc.eop = 1;
+ rx_desc.byteoff = 0;
+ rx_desc.id = 0;
+ rx_desc.err = 0;
+ rx_desc.datalen = RX_DMA_CH_AAL_BUF_SIZE;
+ for ( i = 0; i < dma_rx_descriptor_length; i++ ) {
+ skb = alloc_skb_rx();
+ if ( skb == NULL )
+ return -1;
+ rx_desc.dataptr = ((unsigned int)skb->data >> 2) & 0x0FFFFFFF;
+ g_atm_priv_data.aal_desc[i] = rx_desc;
+ }
+
+ // setup RX (OAM) descriptors
+ p = (void *)((unsigned int)g_atm_priv_data.oam_buf | KSEG1);
+ rx_desc.own = 1;
+ rx_desc.c = 0;
+ rx_desc.sop = 1;
+ rx_desc.eop = 1;
+ rx_desc.byteoff = 0;
+ rx_desc.id = 0;
+ rx_desc.err = 0;
+ rx_desc.datalen = RX_DMA_CH_OAM_BUF_SIZE;
+ for ( i = 0; i < RX_DMA_CH_OAM_DESC_LEN; i++ ) {
+ rx_desc.dataptr = ((unsigned int)p >> 2) & 0x0FFFFFFF;
+ g_atm_priv_data.oam_desc[i] = rx_desc;
+ p = (void *)((unsigned int)p + RX_DMA_CH_OAM_BUF_SIZE);
+ }
+
+ // setup TX descriptors and skb pointers
+ p_tx_desc = (volatile struct tx_descriptor *)((((unsigned int)g_atm_priv_data.tx_desc_base + DESC_ALIGNMENT - 1) & ~(DESC_ALIGNMENT - 1)) | KSEG1);
+ ppskb = (struct sk_buff **)(((unsigned int)g_atm_priv_data.tx_skb_base + 3) & ~3);
+ for ( i = 0; i < MAX_PVC_NUMBER; i++ ) {
+ g_atm_priv_data.conn[i].tx_desc = &p_tx_desc[i * dma_tx_descriptor_length];
+ g_atm_priv_data.conn[i].tx_skb = &ppskb[i * dma_tx_descriptor_length];
+ }
+
+ for ( i = 0; i < ATM_PORT_NUMBER; i++ )
+ g_atm_priv_data.port[i].tx_max_cell_rate = DEFAULT_TX_LINK_RATE;
+
+ return 0;
+}
+
+static inline void clear_priv_data(void)
+{
+ int i, j;
+ struct sk_buff *skb;
+
+ for ( i = 0; i < MAX_PVC_NUMBER; i++ ) {
+ if ( g_atm_priv_data.conn[i].tx_skb != NULL ) {
+ for ( j = 0; j < dma_tx_descriptor_length; j++ )
+ if ( g_atm_priv_data.conn[i].tx_skb[j] != NULL )
+ dev_kfree_skb_any(g_atm_priv_data.conn[i].tx_skb[j]);
+ }
+ }
+
+ if ( g_atm_priv_data.tx_skb_base != NULL )
+ kfree(g_atm_priv_data.tx_skb_base);
+
+ if ( g_atm_priv_data.tx_desc_base != NULL )
+ kfree(g_atm_priv_data.tx_desc_base);
+
+ if ( g_atm_priv_data.oam_buf_base != NULL )
+ kfree(g_atm_priv_data.oam_buf_base);
+
+ if ( g_atm_priv_data.oam_desc_base != NULL )
+ kfree(g_atm_priv_data.oam_desc_base);
+
+ if ( g_atm_priv_data.aal_desc_base != NULL ) {
+ for ( i = 0; i < dma_rx_descriptor_length; i++ ) {
+ if ( g_atm_priv_data.aal_desc[i].sop || g_atm_priv_data.aal_desc[i].eop ) { // descriptor initialized
+ skb = get_skb_rx_pointer(g_atm_priv_data.aal_desc[i].dataptr);
+ dev_kfree_skb_any(skb);
+ }
+ }
+ kfree(g_atm_priv_data.aal_desc_base);
+ }
+}
+
+static inline void init_rx_tables(void)
+{
+ int i;
+ struct wrx_queue_config wrx_queue_config = {0};
+ struct wrx_dma_channel_config wrx_dma_channel_config = {0};
+ struct htu_entry htu_entry = {0};
+ struct htu_result htu_result = {0};
+ struct htu_mask htu_mask = {
+ set: 0x01,
+ clp: 0x01,
+ pid_mask: 0x00,
+ vpi_mask: 0x00,
+ vci_mask: 0x00,
+ pti_mask: 0x00,
+ clear: 0x00
+ };
+
+ /*
+ * General Registers
+ */
+ *CFG_WRX_HTUTS = MAX_PVC_NUMBER + OAM_HTU_ENTRY_NUMBER;
+#ifndef CONFIG_AMAZON_SE
+ *CFG_WRX_QNUM = MAX_QUEUE_NUMBER;
+#endif
+ *CFG_WRX_DCHNUM = RX_DMA_CH_TOTAL;
+ *WRX_DMACH_ON = (1 << RX_DMA_CH_TOTAL) - 1;
+ *WRX_HUNT_BITTH = DEFAULT_RX_HUNT_BITTH;
+
+ /*
+ * WRX Queue Configuration Table
+ */
+ wrx_queue_config.uumask = 0xFF;
+ wrx_queue_config.cpimask = 0xFF;
+ wrx_queue_config.uuexp = 0;
+ wrx_queue_config.cpiexp = 0;
+ wrx_queue_config.mfs = aal5r_max_packet_size;
+ wrx_queue_config.oversize = aal5r_max_packet_size;
+ wrx_queue_config.undersize = aal5r_min_packet_size;
+ wrx_queue_config.errdp = aal5r_drop_error_packet;
+ wrx_queue_config.dmach = RX_DMA_CH_AAL;
+ for ( i = 0; i < MAX_QUEUE_NUMBER; i++ )
+ *WRX_QUEUE_CONFIG(i) = wrx_queue_config;
+ WRX_QUEUE_CONFIG(OAM_RX_QUEUE)->dmach = RX_DMA_CH_OAM;
+
+ /*
+ * WRX DMA Channel Configuration Table
+ */
+ wrx_dma_channel_config.chrl = 0;
+ wrx_dma_channel_config.clp1th = dma_rx_clp1_descriptor_threshold;
+ wrx_dma_channel_config.mode = 0;
+ wrx_dma_channel_config.rlcfg = 0;
+
+ wrx_dma_channel_config.deslen = RX_DMA_CH_OAM_DESC_LEN;
+ wrx_dma_channel_config.desba = ((unsigned int)g_atm_priv_data.oam_desc >> 2) & 0x0FFFFFFF;
+ *WRX_DMA_CHANNEL_CONFIG(RX_DMA_CH_OAM) = wrx_dma_channel_config;
+
+ wrx_dma_channel_config.deslen = dma_rx_descriptor_length;
+ wrx_dma_channel_config.desba = ((unsigned int)g_atm_priv_data.aal_desc >> 2) & 0x0FFFFFFF;
+ *WRX_DMA_CHANNEL_CONFIG(RX_DMA_CH_AAL) = wrx_dma_channel_config;
+
+ /*
+ * HTU Tables
+ */
+ for (i = 0; i < MAX_PVC_NUMBER; i++) {
+ htu_result.qid = (unsigned int)i;
+
+ *HTU_ENTRY(i + OAM_HTU_ENTRY_NUMBER) = htu_entry;
+ *HTU_MASK(i + OAM_HTU_ENTRY_NUMBER) = htu_mask;
+ *HTU_RESULT(i + OAM_HTU_ENTRY_NUMBER) = htu_result;
+ }
+
+ /* OAM HTU Entry */
+ htu_entry.vci = 0x03;
+ htu_mask.pid_mask = 0x03;
+ htu_mask.vpi_mask = 0xFF;
+ htu_mask.vci_mask = 0x0000;
+ htu_mask.pti_mask = 0x07;
+ htu_result.cellid = OAM_RX_QUEUE;
+ htu_result.type = 1;
+ htu_result.ven = 1;
+ htu_result.qid = OAM_RX_QUEUE;
+ *HTU_RESULT(OAM_F4_SEG_HTU_ENTRY) = htu_result;
+ *HTU_MASK(OAM_F4_SEG_HTU_ENTRY) = htu_mask;
+ *HTU_ENTRY(OAM_F4_SEG_HTU_ENTRY) = htu_entry;
+ htu_entry.vci = 0x04;
+ htu_result.cellid = OAM_RX_QUEUE;
+ htu_result.type = 1;
+ htu_result.ven = 1;
+ htu_result.qid = OAM_RX_QUEUE;
+ *HTU_RESULT(OAM_F4_TOT_HTU_ENTRY) = htu_result;
+ *HTU_MASK(OAM_F4_TOT_HTU_ENTRY) = htu_mask;
+ *HTU_ENTRY(OAM_F4_TOT_HTU_ENTRY) = htu_entry;
+ htu_entry.vci = 0x00;
+ htu_entry.pti = 0x04;
+ htu_mask.vci_mask = 0xFFFF;
+ htu_mask.pti_mask = 0x01;
+ htu_result.cellid = OAM_RX_QUEUE;
+ htu_result.type = 1;
+ htu_result.ven = 1;
+ htu_result.qid = OAM_RX_QUEUE;
+ *HTU_RESULT(OAM_F5_HTU_ENTRY) = htu_result;
+ *HTU_MASK(OAM_F5_HTU_ENTRY) = htu_mask;
+ *HTU_ENTRY(OAM_F5_HTU_ENTRY) = htu_entry;
+}
+
+static inline void init_tx_tables(void)
+{
+ int i;
+ struct wtx_queue_config wtx_queue_config = {0};
+ struct wtx_dma_channel_config wtx_dma_channel_config = {0};
+ struct wtx_port_config wtx_port_config = {
+ res1: 0,
+ qid: 0,
+ qsben: 1
+ };
+
+ /*
+ * General Registers
+ */
+ *CFG_WTX_DCHNUM = MAX_TX_DMA_CHANNEL_NUMBER;
+ *WTX_DMACH_ON = ((1 << MAX_TX_DMA_CHANNEL_NUMBER) - 1) ^ ((1 << FIRST_QSB_QID) - 1);
+ *CFG_WRDES_DELAY = write_descriptor_delay;
+
+ /*
+ * WTX Port Configuration Table
+ */
+ for ( i = 0; i < ATM_PORT_NUMBER; i++ )
+ *WTX_PORT_CONFIG(i) = wtx_port_config;
+
+ /*
+ * WTX Queue Configuration Table
+ */
+ wtx_queue_config.qsben = 1;
+ wtx_queue_config.sbid = 0;
+ for ( i = 0; i < MAX_TX_DMA_CHANNEL_NUMBER; i++ ) {
+ wtx_queue_config.qsb_vcid = i;
+ *WTX_QUEUE_CONFIG(i) = wtx_queue_config;
+ }
+
+ /*
+ * WTX DMA Channel Configuration Table
+ */
+ wtx_dma_channel_config.mode = 0;
+ wtx_dma_channel_config.deslen = 0;
+ wtx_dma_channel_config.desba = 0;
+ for ( i = 0; i < FIRST_QSB_QID; i++ )
+ *WTX_DMA_CHANNEL_CONFIG(i) = wtx_dma_channel_config;
+ /* normal connection */
+ wtx_dma_channel_config.deslen = dma_tx_descriptor_length;
+ for ( ; i < MAX_TX_DMA_CHANNEL_NUMBER ; i++ ) {
+ wtx_dma_channel_config.desba = ((unsigned int)g_atm_priv_data.conn[i - FIRST_QSB_QID].tx_desc >> 2) & 0x0FFFFFFF;
+ *WTX_DMA_CHANNEL_CONFIG(i) = wtx_dma_channel_config;
+ }
+}
+
+static int atm_showtime_enter(struct port_cell_info *port_cell, void *xdata_addr)
+{
+ int i, j;
+
+ ASSERT(port_cell != NULL, "port_cell is NULL");
+ ASSERT(xdata_addr != NULL, "xdata_addr is NULL");
+
+ for ( j = 0; j < ATM_PORT_NUMBER && j < port_cell->port_num; j++ )
+ if ( port_cell->tx_link_rate[j] > 0 )
+ break;
+ for ( i = 0; i < ATM_PORT_NUMBER && i < port_cell->port_num; i++ )
+ g_atm_priv_data.port[i].tx_max_cell_rate =
+ port_cell->tx_link_rate[i] > 0 ? port_cell->tx_link_rate[i] : port_cell->tx_link_rate[j];
+
+ qsb_global_set();
+
+ for ( i = 0; i < MAX_PVC_NUMBER; i++ )
+ if ( g_atm_priv_data.conn[i].vcc != NULL )
+ set_qsb(g_atm_priv_data.conn[i].vcc, &g_atm_priv_data.conn[i].vcc->qos, i);
+
+ // TODO: ReTX set xdata_addr
+ g_xdata_addr = xdata_addr;
+
+ g_showtime = 1;
+
+#if defined(CONFIG_VR9)
+ IFX_REG_W32(0x0F, UTP_CFG);
+#endif
+
+ printk("enter showtime, cell rate: 0 - %d, 1 - %d, xdata addr: 0x%08x\n",
+ g_atm_priv_data.port[0].tx_max_cell_rate,
+ g_atm_priv_data.port[1].tx_max_cell_rate,
+ (unsigned int)g_xdata_addr);
+
+ return 0;
+}
+
+static int atm_showtime_exit(void)
+{
+ if ( !g_showtime )
+ return -1;
+
+#if defined(CONFIG_VR9)
+ IFX_REG_W32(0x00, UTP_CFG);
+#endif
+ g_showtime = 0;
+ g_xdata_addr = NULL;
+ printk("leave showtime\n");
+ return 0;
+}
+
+extern struct ltq_atm_ops ar9_ops;
+extern struct ltq_atm_ops vr9_ops;
+extern struct ltq_atm_ops danube_ops;
+extern struct ltq_atm_ops ase_ops;
+
+static const struct of_device_id ltq_atm_match[] = {
+#ifdef CONFIG_DANUBE
+ { .compatible = "lantiq,ppe-danube", .data = &danube_ops },
+#elif defined CONFIG_AMAZON_SE
+ { .compatible = "lantiq,ppe-ase", .data = &ase_ops },
+#elif defined CONFIG_AR9
+ { .compatible = "lantiq,ppe-arx100", .data = &ar9_ops },
+#elif defined CONFIG_VR9
+ { .compatible = "lantiq,ppe-xrx200", .data = &vr9_ops },
+#endif
+ {},
+};
+MODULE_DEVICE_TABLE(of, ltq_atm_match);
+
+static int ltq_atm_probe(struct platform_device *pdev)
+{
+ const struct of_device_id *match;
+ struct ltq_atm_ops *ops = NULL;
+ int ret;
+ int port_num;
+ struct port_cell_info port_cell = {0};
+ int i, j;
+ char ver_str[256];
+
+ match = of_match_device(ltq_atm_match, &pdev->dev);
+ if (!match) {
+ dev_err(&pdev->dev, "failed to find matching device\n");
+ return -ENOENT;
+ }
+ ops = (struct ltq_atm_ops *) match->data;
+
+ check_parameters();
+
+ ret = init_priv_data();
+ if ( ret != 0 ) {
+ pr_err("INIT_PRIV_DATA_FAIL\n");
+ goto INIT_PRIV_DATA_FAIL;
+ }
+
+ ops->init();
+ init_rx_tables();
+ init_tx_tables();
+
+ /* create devices */
+ for ( port_num = 0; port_num < ATM_PORT_NUMBER; port_num++ ) {
+ g_atm_priv_data.port[port_num].dev = atm_dev_register("ifxmips_atm", NULL, &g_ifx_atm_ops, -1, NULL);
+ if ( !g_atm_priv_data.port[port_num].dev ) {
+ pr_err("failed to register atm device %d!\n", port_num);
+ ret = -EIO;
+ goto ATM_DEV_REGISTER_FAIL;
+ } else {
+ g_atm_priv_data.port[port_num].dev->ci_range.vpi_bits = 8;
+ g_atm_priv_data.port[port_num].dev->ci_range.vci_bits = 16;
+ g_atm_priv_data.port[port_num].dev->link_rate = g_atm_priv_data.port[port_num].tx_max_cell_rate;
+ g_atm_priv_data.port[port_num].dev->dev_data = (void*)port_num;
+ }
+ }
+
+ /* register interrupt handler */
+ ret = request_irq(PPE_MAILBOX_IGU1_INT, mailbox_irq_handler, IRQF_DISABLED, "atm_mailbox_isr", &g_atm_priv_data);
+ if ( ret ) {
+ if ( ret == -EBUSY ) {
+ pr_err("IRQ may be occupied by other driver, please reconfig to disable it.\n");
+ } else {
+ pr_err("request_irq fail irq:%d\n", PPE_MAILBOX_IGU1_INT);
+ }
+ goto REQUEST_IRQ_PPE_MAILBOX_IGU1_INT_FAIL;
+ }
+ disable_irq(PPE_MAILBOX_IGU1_INT);
+
+
+ ret = ops->start(0);
+ if ( ret ) {
+ pr_err("ifx_pp32_start fail!\n");
+ goto PP32_START_FAIL;
+ }
+
+ port_cell.port_num = ATM_PORT_NUMBER;
+ ifx_mei_atm_showtime_check(&g_showtime, &port_cell, &g_xdata_addr);
+ if ( g_showtime ) {
+ for ( i = 0; i < ATM_PORT_NUMBER; i++ )
+ if ( port_cell.tx_link_rate[i] != 0 )
+ break;
+ for ( j = 0; j < ATM_PORT_NUMBER; j++ )
+ g_atm_priv_data.port[j].tx_max_cell_rate =
+ port_cell.tx_link_rate[j] != 0 ? port_cell.tx_link_rate[j] : port_cell.tx_link_rate[i];
+ }
+
+ qsb_global_set();
+ validate_oam_htu_entry();
+
+ ifx_mei_atm_showtime_enter = atm_showtime_enter;
+ ifx_mei_atm_showtime_exit = atm_showtime_exit;
+
+ ifx_atm_version(ops, ver_str);
+ printk(KERN_INFO "%s", ver_str);
+ platform_set_drvdata(pdev, ops);
+ printk("ifxmips_atm: ATM init succeed\n");
+
+ return 0;
+
+PP32_START_FAIL:
+ free_irq(PPE_MAILBOX_IGU1_INT, &g_atm_priv_data);
+REQUEST_IRQ_PPE_MAILBOX_IGU1_INT_FAIL:
+ATM_DEV_REGISTER_FAIL:
+ while ( port_num-- > 0 )
+ atm_dev_deregister(g_atm_priv_data.port[port_num].dev);
+INIT_PRIV_DATA_FAIL:
+ clear_priv_data();
+ printk("ifxmips_atm: ATM init failed\n");
+ return ret;
+}
+
+static int ltq_atm_remove(struct platform_device *pdev)
+{
+ int port_num;
+ struct ltq_atm_ops *ops = platform_get_drvdata(pdev);
+
+ ifx_mei_atm_showtime_enter = NULL;
+ ifx_mei_atm_showtime_exit = NULL;
+
+ invalidate_oam_htu_entry();
+
+ ops->stop(0);
+
+ free_irq(PPE_MAILBOX_IGU1_INT, &g_atm_priv_data);
+
+ for ( port_num = 0; port_num < ATM_PORT_NUMBER; port_num++ )
+ atm_dev_deregister(g_atm_priv_data.port[port_num].dev);
+
+ ops->shutdown();
+
+ clear_priv_data();
+
+ return 0;
+}
+
+static struct platform_driver ltq_atm_driver = {
+ .probe = ltq_atm_probe,
+ .remove = ltq_atm_remove,
+ .driver = {
+ .name = "atm",
+ .owner = THIS_MODULE,
+ .of_match_table = ltq_atm_match,
+ },
+};
+
+module_platform_driver(ltq_atm_driver);
+
+MODULE_LICENSE("Dual BSD/GPL");
diff --git a/package/platform/lantiq/ltq-atm/src/Makefile b/package/platform/lantiq/ltq-atm/src/Makefile
new file mode 100644
index 0000000..3d68c8f
--- /dev/null
+++ b/package/platform/lantiq/ltq-atm/src/Makefile
@@ -0,0 +1,23 @@
+ifeq ($(BUILD_VARIANT),danube)
+ CFLAGS_MODULE = -DCONFIG_DANUBE
+ obj-m = ltq_atm_danube.o
+ ltq_atm_danube-objs = ltq_atm.o ifxmips_atm_danube.o
+endif
+
+ifeq ($(BUILD_VARIANT),ase)
+ CFLAGS_MODULE = -DCONFIG_AMAZON_SE
+ obj-m = ltq_atm_ase.o
+ ltq_atm_ase-objs = ltq_atm.o ifxmips_atm_amazon_se.o
+endif
+
+ifeq ($(BUILD_VARIANT),ar9)
+ CFLAGS_MODULE = -DCONFIG_AR9
+ obj-m = ltq_atm_ar9.o
+ ltq_atm_ar9-objs = ltq_atm.o ifxmips_atm_ar9.o
+endif
+
+ifeq ($(BUILD_VARIANT),vr9)
+ CFLAGS_MODULE = -DCONFIG_VR9
+ obj-m = ltq_atm_vr9.o
+ ltq_atm_vr9-objs = ltq_atm.o ifxmips_atm_vr9.o
+endif
diff --git a/package/platform/lantiq/ltq-atm/src/ifxmips_atm_amazon_se.c b/package/platform/lantiq/ltq-atm/src/ifxmips_atm_amazon_se.c
new file mode 100644
index 0000000..6e8975b
--- /dev/null
+++ b/package/platform/lantiq/ltq-atm/src/ifxmips_atm_amazon_se.c
@@ -0,0 +1,341 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_atm_amazon_se.c
+** PROJECT : UEIP
+** MODULES : ATM
+**
+** DATE : 7 Jul 2009
+** AUTHOR : Xu Liang
+** DESCRIPTION : ATM driver common source file (core functions)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 07 JUL 2009 Xu Liang Init Version
+*******************************************************************************/
+
+
+
+/*
+ * ####################################
+ * Head File
+ * ####################################
+ */
+
+/*
+ * Common Head File
+ */
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/version.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/proc_fs.h>
+#include <linux/init.h>
+#include <linux/ioctl.h>
+#include <asm/delay.h>
+
+/*
+ * Chip Specific Head File
+ */
+#include "ifxmips_atm_core.h"
+#include "ifxmips_atm_fw_amazon_se.h"
+
+#include <lantiq_soc.h>
+
+#define EMA_CMD_BUF_LEN 0x0040
+#define EMA_CMD_BASE_ADDR (0x00001580 << 2)
+#define EMA_DATA_BUF_LEN 0x0100
+#define EMA_DATA_BASE_ADDR (0x00001900 << 2)
+#define EMA_WRITE_BURST 0x2
+#define EMA_READ_BURST 0x2
+
+
+
+/*
+ * ####################################
+ * Definition
+ * ####################################
+ */
+
+/*
+ * EMA Settings
+ */
+#define EMA_CMD_BUF_LEN 0x0040
+#define EMA_CMD_BASE_ADDR (0x00001580 << 2)
+#define EMA_DATA_BUF_LEN 0x0100
+#define EMA_DATA_BASE_ADDR (0x00000B00 << 2)
+#define EMA_WRITE_BURST 0x2
+#define EMA_READ_BURST 0x2
+
+
+
+/*
+ * ####################################
+ * Declaration
+ * ####################################
+ */
+
+/*
+ * Hardware Init/Uninit Functions
+ */
+static inline void init_pmu(void);
+static inline void uninit_pmu(void);
+static inline void reset_ppe(void);
+static inline void init_ema(void);
+static inline void init_mailbox(void);
+static inline void init_atm_tc(void);
+static inline void clear_share_buffer(void);
+
+
+
+/*
+ * ####################################
+ * Local Variable
+ * ####################################
+ */
+
+
+
+/*
+ * ####################################
+ * Local Function
+ * ####################################
+ */
+#define IFX_PMU_MODULE_PPE_SLL01 BIT(19)
+#define IFX_PMU_MODULE_PPE_TC BIT(21)
+#define IFX_PMU_MODULE_PPE_EMA BIT(22)
+#define IFX_PMU_MODULE_PPE_QSB BIT(18)
+#define IFX_PMU_MODULE_TPE BIT(13)
+#define IFX_PMU_MODULE_DSL_DFE BIT(9)
+
+static inline void init_pmu(void)
+{
+ //*(unsigned long *)0xBF10201C &= ~((1 << 15) | (1 << 13) | (1 << 9));
+ //PPE_TOP_PMU_SETUP(IFX_PMU_ENABLE);
+/* PPE_SLL01_PMU_SETUP(IFX_PMU_ENABLE);
+ PPE_TC_PMU_SETUP(IFX_PMU_ENABLE);
+ PPE_EMA_PMU_SETUP(IFX_PMU_ENABLE);
+ //PPE_QSB_PMU_SETUP(IFX_PMU_ENABLE);
+ PPE_TPE_PMU_SETUP(IFX_PMU_ENABLE);
+ DSL_DFE_PMU_SETUP(IFX_PMU_ENABLE);*/
+ ltq_pmu_enable(IFX_PMU_MODULE_PPE_SLL01 |
+ IFX_PMU_MODULE_PPE_TC |
+ IFX_PMU_MODULE_PPE_EMA |
+ IFX_PMU_MODULE_TPE |
+ IFX_PMU_MODULE_DSL_DFE);
+}
+
+static inline void uninit_pmu(void)
+{
+ /*PPE_SLL01_PMU_SETUP(IFX_PMU_DISABLE);
+ PPE_TC_PMU_SETUP(IFX_PMU_DISABLE);
+ PPE_EMA_PMU_SETUP(IFX_PMU_DISABLE);
+ //PPE_QSB_PMU_SETUP(IFX_PMU_DISABLE);
+ PPE_TPE_PMU_SETUP(IFX_PMU_DISABLE);
+ DSL_DFE_PMU_SETUP(IFX_PMU_DISABLE);
+ //PPE_TOP_PMU_SETUP(IFX_PMU_DISABLE);*/
+}
+
+static inline void reset_ppe(void)
+{
+#if 0 //MODULE
+ unsigned int etop_cfg;
+ unsigned int etop_mdio_cfg;
+ unsigned int etop_ig_plen_ctrl;
+ unsigned int enet_mac_cfg;
+
+ etop_cfg = *IFX_PP32_ETOP_CFG;
+ etop_mdio_cfg = *IFX_PP32_ETOP_MDIO_CFG;
+ etop_ig_plen_ctrl = *IFX_PP32_ETOP_IG_PLEN_CTRL;
+ enet_mac_cfg = *IFX_PP32_ENET_MAC_CFG;
+
+ *IFX_PP32_ETOP_CFG = (*IFX_PP32_ETOP_CFG & ~0x03C0) | 0x0001;
+
+ // reset PPE
+ ifx_rcu_rst(IFX_RCU_DOMAIN_PPE, IFX_RCU_MODULE_ATM);
+
+ *IFX_PP32_ETOP_MDIO_CFG = etop_mdio_cfg;
+ *IFX_PP32_ETOP_IG_PLEN_CTRL = etop_ig_plen_ctrl;
+ *IFX_PP32_ENET_MAC_CFG = enet_mac_cfg;
+ *IFX_PP32_ETOP_CFG = etop_cfg;
+#endif
+}
+
+static inline void init_ema(void)
+{
+ IFX_REG_W32((EMA_CMD_BUF_LEN << 16) | (EMA_CMD_BASE_ADDR >> 2), EMA_CMDCFG);
+ IFX_REG_W32((EMA_DATA_BUF_LEN << 16) | (EMA_DATA_BASE_ADDR >> 2), EMA_DATACFG);
+ IFX_REG_W32(0x000000FF, EMA_IER);
+ IFX_REG_W32(EMA_READ_BURST | (EMA_WRITE_BURST << 2), EMA_CFG);
+}
+
+static inline void init_mailbox(void)
+{
+ IFX_REG_W32(0xFFFFFFFF, MBOX_IGU1_ISRC);
+ IFX_REG_W32(0x00000000, MBOX_IGU1_IER);
+ IFX_REG_W32(0xFFFFFFFF, MBOX_IGU3_ISRC);
+ IFX_REG_W32(0x00000000, MBOX_IGU3_IER);
+}
+
+static inline void init_atm_tc(void)
+{
+ IFX_REG_W32(0x0000, DREG_AT_CTRL);
+ IFX_REG_W32(0x0000, DREG_AR_CTRL);
+ IFX_REG_W32(0x0, DREG_AT_IDLE0);
+ IFX_REG_W32(0x0, DREG_AT_IDLE1);
+ IFX_REG_W32(0x0, DREG_AR_IDLE0);
+ IFX_REG_W32(0x0, DREG_AR_IDLE1);
+ IFX_REG_W32(0x40, RFBI_CFG);
+ IFX_REG_W32(0x0700, SFSM_DBA0);
+ IFX_REG_W32(0x0818, SFSM_DBA1);
+ IFX_REG_W32(0x0930, SFSM_CBA0);
+ IFX_REG_W32(0x0944, SFSM_CBA1);
+ IFX_REG_W32(0x14014, SFSM_CFG0);
+ IFX_REG_W32(0x14014, SFSM_CFG1);
+ IFX_REG_W32(0x0958, FFSM_DBA0);
+ IFX_REG_W32(0x09AC, FFSM_DBA1);
+ IFX_REG_W32(0x10006, FFSM_CFG0);
+ IFX_REG_W32(0x10006, FFSM_CFG1);
+ IFX_REG_W32(0x00000001, FFSM_IDLE_HEAD_BC0);
+ IFX_REG_W32(0x00000001, FFSM_IDLE_HEAD_BC1);
+}
+
+static inline void clear_share_buffer(void)
+{
+ volatile u32 *p = SB_RAM0_ADDR(0);
+ unsigned int i;
+
+ for ( i = 0; i < SB_RAM0_DWLEN + SB_RAM1_DWLEN; i++ )
+ IFX_REG_W32(0, p++);
+}
+
+/*
+ * Description:
+ * Download PPE firmware binary code.
+ * Input:
+ * src --- u32 *, binary code buffer
+ * dword_len --- unsigned int, binary code length in DWORD (32-bit)
+ * Output:
+ * int --- 0: Success
+ * else: Error Code
+ */
+static inline int pp32_download_code(u32 *code_src, unsigned int code_dword_len, u32 *data_src, unsigned int data_dword_len)
+{
+ volatile u32 *dest;
+
+ if ( code_src == 0 || ((unsigned long)code_src & 0x03) != 0
+ || data_src == 0 || ((unsigned long)data_src & 0x03) != 0 )
+ return -1;
+
+ if ( code_dword_len <= CDM_CODE_MEMORYn_DWLEN(0) )
+ IFX_REG_W32(0x00, CDM_CFG);
+ else
+ IFX_REG_W32(0x04, CDM_CFG);
+
+ /* copy code */
+ dest = CDM_CODE_MEMORY(0, 0);
+ while ( code_dword_len-- > 0 )
+ IFX_REG_W32(*code_src++, dest++);
+
+ /* copy data */
+ dest = CDM_DATA_MEMORY(0, 0);
+ while ( data_dword_len-- > 0 )
+ IFX_REG_W32(*data_src++, dest++);
+
+ return 0;
+}
+
+
+
+/*
+ * ####################################
+ * Global Function
+ * ####################################
+ */
+
+extern void ase_fw_ver(unsigned int *major, unsigned int *minor)
+{
+ ASSERT(major != NULL, "pointer is NULL");
+ ASSERT(minor != NULL, "pointer is NULL");
+
+ *major = FW_VER_ID->major;
+ *minor = FW_VER_ID->minor;
+}
+
+void ase_init(void)
+{
+ init_pmu();
+
+ reset_ppe();
+
+ init_ema();
+
+ init_mailbox();
+
+ init_atm_tc();
+
+ clear_share_buffer();
+}
+
+void ase_shutdown(void)
+{
+ uninit_pmu();
+}
+
+/*
+ * Description:
+ * Initialize and start up PP32.
+ * Input:
+ * none
+ * Output:
+ * int --- 0: Success
+ * else: Error Code
+ */
+int ase_start(int pp32)
+{
+ int ret;
+
+ /* download firmware */
+ ret = pp32_download_code(firmware_binary_code, sizeof(firmware_binary_code) / sizeof(*firmware_binary_code), firmware_binary_data, sizeof(firmware_binary_data) / sizeof(*firmware_binary_data));
+ if ( ret != 0 )
+ return ret;
+
+ /* run PP32 */
+ IFX_REG_W32(DBG_CTRL_RESTART, PP32_DBG_CTRL);
+
+ /* idle for a while to let PP32 init itself */
+ udelay(10);
+
+ return 0;
+}
+
+/*
+ * Description:
+ * Halt PP32.
+ * Input:
+ * none
+ * Output:
+ * none
+ */
+void ase_stop(int pp32)
+{
+ /* halt PP32 */
+ IFX_REG_W32(DBG_CTRL_STOP, PP32_DBG_CTRL);
+}
+
+struct ltq_atm_ops ase_ops = {
+ .init = ase_init,
+ .shutdown = ase_shutdown,
+ .start = ase_start,
+ .stop = ase_stop,
+ .fw_ver = ase_fw_ver,
+};
+
diff --git a/package/platform/lantiq/ltq-atm/src/ifxmips_atm_ar9.c b/package/platform/lantiq/ltq-atm/src/ifxmips_atm_ar9.c
new file mode 100644
index 0000000..b68848b
--- /dev/null
+++ b/package/platform/lantiq/ltq-atm/src/ifxmips_atm_ar9.c
@@ -0,0 +1,244 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_atm_ar9.c
+** PROJECT : UEIP
+** MODULES : ATM
+**
+** DATE : 7 Jul 2009
+** AUTHOR : Xu Liang
+** DESCRIPTION : ATM driver common source file (core functions)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 07 JUL 2009 Xu Liang Init Version
+*******************************************************************************/
+
+
+
+/*
+ * ####################################
+ * Head File
+ * ####################################
+ */
+
+/*
+ * Common Head File
+ */
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/version.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/proc_fs.h>
+#include <linux/init.h>
+#include <linux/ioctl.h>
+#include <asm/delay.h>
+
+/*
+ * Chip Specific Head File
+ */
+#include "ifxmips_atm_core.h"
+
+#include "ifxmips_atm_fw_ar9.h"
+#include "ifxmips_atm_fw_regs_ar9.h"
+
+#include <lantiq_soc.h>
+
+
+
+/*
+ * ####################################
+ * Definition
+ * ####################################
+ */
+
+/*
+ * EMA Settings
+ */
+#define EMA_CMD_BUF_LEN 0x0040
+#define EMA_CMD_BASE_ADDR (0x00003B80 << 2)
+#define EMA_DATA_BUF_LEN 0x0100
+#define EMA_DATA_BASE_ADDR (0x00003C00 << 2)
+#define EMA_WRITE_BURST 0x2
+#define EMA_READ_BURST 0x2
+
+
+
+/*
+ * ####################################
+ * Declaration
+ * ####################################
+ */
+
+/*
+ * Hardware Init/Uninit Functions
+ */
+static inline void init_pmu(void);
+static inline void uninit_pmu(void);
+static inline void reset_ppe(void);
+static inline void init_ema(void);
+static inline void init_mailbox(void);
+static inline void clear_share_buffer(void);
+
+
+
+/*
+ * ####################################
+ * Local Variable
+ * ####################################
+ */
+
+
+
+/*
+ * ####################################
+ * Local Function
+ * ####################################
+ */
+
+#define IFX_PMU_MODULE_PPE_SLL01 BIT(19)
+#define IFX_PMU_MODULE_PPE_TC BIT(21)
+#define IFX_PMU_MODULE_PPE_EMA BIT(22)
+#define IFX_PMU_MODULE_PPE_QSB BIT(18)
+#define IFX_PMU_MODULE_TPE BIT(13)
+#define IFX_PMU_MODULE_DSL_DFE BIT(9)
+
+static inline void init_pmu(void)
+{
+ ltq_pmu_enable(IFX_PMU_MODULE_PPE_SLL01 |
+ IFX_PMU_MODULE_PPE_TC |
+ IFX_PMU_MODULE_PPE_EMA |
+ IFX_PMU_MODULE_PPE_QSB |
+ IFX_PMU_MODULE_TPE |
+ IFX_PMU_MODULE_DSL_DFE);
+}
+
+static inline void uninit_pmu(void)
+{
+}
+
+static inline void reset_ppe(void)
+{
+#ifdef MODULE
+ // reset PPE
+// ifx_rcu_rst(IFX_RCU_DOMAIN_PPE, IFX_RCU_MODULE_ATM);
+#endif
+}
+
+static inline void init_ema(void)
+{
+ IFX_REG_W32((EMA_CMD_BUF_LEN << 16) | (EMA_CMD_BASE_ADDR >> 2), EMA_CMDCFG);
+ IFX_REG_W32((EMA_DATA_BUF_LEN << 16) | (EMA_DATA_BASE_ADDR >> 2), EMA_DATACFG);
+ IFX_REG_W32(0x000000FF, EMA_IER);
+ IFX_REG_W32(EMA_READ_BURST | (EMA_WRITE_BURST << 2), EMA_CFG);
+}
+
+static inline void init_mailbox(void)
+{
+ IFX_REG_W32(0xFFFFFFFF, MBOX_IGU1_ISRC);
+ IFX_REG_W32(0x00000000, MBOX_IGU1_IER);
+ IFX_REG_W32(0xFFFFFFFF, MBOX_IGU3_ISRC);
+ IFX_REG_W32(0x00000000, MBOX_IGU3_IER);
+}
+
+static inline void clear_share_buffer(void)
+{
+ volatile u32 *p = SB_RAM0_ADDR(0);
+ unsigned int i;
+
+ for ( i = 0; i < SB_RAM0_DWLEN + SB_RAM1_DWLEN + SB_RAM2_DWLEN + SB_RAM3_DWLEN + SB_RAM4_DWLEN; i++ )
+ IFX_REG_W32(0, p++);
+}
+
+static inline int pp32_download_code(u32 *code_src, unsigned int code_dword_len, u32 *data_src, unsigned int data_dword_len)
+{
+ volatile u32 *dest;
+
+ if ( code_src == 0 || ((unsigned long)code_src & 0x03) != 0
+ || data_src == 0 || ((unsigned long)data_src & 0x03) != 0 )
+ return -1;
+
+ if ( code_dword_len <= CDM_CODE_MEMORYn_DWLEN(0) )
+ IFX_REG_W32(0x00, CDM_CFG);
+ else
+ IFX_REG_W32(0x04, CDM_CFG);
+
+ /* copy code */
+ dest = CDM_CODE_MEMORY(0, 0);
+ while ( code_dword_len-- > 0 )
+ IFX_REG_W32(*code_src++, dest++);
+
+ /* copy data */
+ dest = CDM_DATA_MEMORY(0, 0);
+ while ( data_dword_len-- > 0 )
+ IFX_REG_W32(*data_src++, dest++);
+
+ return 0;
+}
+
+void ar9_fw_ver(unsigned int *major, unsigned int *minor)
+{
+ ASSERT(major != NULL, "pointer is NULL");
+ ASSERT(minor != NULL, "pointer is NULL");
+
+ *major = FW_VER_ID->major;
+ *minor = FW_VER_ID->minor;
+}
+
+void ar9_init(void)
+{
+ init_pmu();
+ reset_ppe();
+ init_ema();
+ init_mailbox();
+ clear_share_buffer();
+}
+
+void ar9_shutdown(void)
+{
+ ltq_pmu_disable(IFX_PMU_MODULE_PPE_SLL01 |
+ IFX_PMU_MODULE_PPE_TC |
+ IFX_PMU_MODULE_PPE_EMA |
+ IFX_PMU_MODULE_PPE_QSB |
+ IFX_PMU_MODULE_TPE |
+ IFX_PMU_MODULE_DSL_DFE);
+}
+
+int ar9_start(int pp32)
+{
+ int ret;
+
+ ret = pp32_download_code(ar9_fw_bin, sizeof(ar9_fw_bin) / sizeof(*ar9_fw_bin),
+ ar9_fw_data, sizeof(ar9_fw_data) / sizeof(*ar9_fw_data));
+ if ( ret != 0 )
+ return ret;
+
+ IFX_REG_W32(DBG_CTRL_RESTART, PP32_DBG_CTRL(0));
+
+ udelay(10);
+
+ return 0;
+}
+
+void ar9_stop(int pp32)
+{
+ IFX_REG_W32(DBG_CTRL_STOP, PP32_DBG_CTRL(0));
+}
+
+struct ltq_atm_ops ar9_ops = {
+ .init = ar9_init,
+ .shutdown = ar9_shutdown,
+ .start = ar9_start,
+ .stop = ar9_stop,
+ .fw_ver = ar9_fw_ver,
+};
+
+
diff --git a/package/platform/lantiq/ltq-atm/src/ifxmips_atm_core.h b/package/platform/lantiq/ltq-atm/src/ifxmips_atm_core.h
new file mode 100644
index 0000000..2f754c9
--- /dev/null
+++ b/package/platform/lantiq/ltq-atm/src/ifxmips_atm_core.h
@@ -0,0 +1,245 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_atm_core.h
+** PROJECT : UEIP
+** MODULES : ATM
+**
+** DATE : 7 Jul 2009
+** AUTHOR : Xu Liang
+** DESCRIPTION : ATM driver header file (core functions)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 17 JUN 2009 Xu Liang Init Version
+*******************************************************************************/
+
+#ifndef IFXMIPS_ATM_CORE_H
+#define IFXMIPS_ATM_CORE_H
+
+
+#define INT_NUM_IM2_IRL24 (INT_NUM_IM2_IRL0 + 24)
+#define INT_NUM_IM2_IRL13 (INT_NUM_IM2_IRL0 + 13)
+#define CONFIG_IFXMIPS_DSL_CPE_MEI
+#define IFX_REG_W32(_v, _r) __raw_writel((_v), (volatile unsigned int *)(_r))
+#define IFX_REG_R32(_r) __raw_readl((volatile unsigned int *)(_r))
+#define IFX_REG_W32_MASK(_clr, _set, _r) IFX_REG_W32((IFX_REG_R32((_r)) & ~(_clr)) | (_set), (_r))
+#define SET_BITS(x, msb, lsb, value) (((x) & ~(((1 << ((msb) + 1)) - 1) ^ ((1 << (lsb)) - 1))) | (((value) & ((1 << (1 + (msb) - (lsb))) - 1)) << (lsb)))
+
+struct ltq_atm_ops {
+ void (*init)(void);
+ void (*shutdown)(void);
+
+ int (*start)(int pp32);
+ void (*stop)(int pp32);
+
+ void (*fw_ver)(unsigned int *major, unsigned int *minor);
+};
+
+#include <lantiq_atm.h>
+
+/*
+ * ####################################
+ * Definition
+ * ####################################
+ */
+
+/*
+ * Compile Options
+ */
+
+#define ENABLE_DEBUG 1
+
+#define ENABLE_ASSERT 1
+
+#define INLINE
+
+#define DEBUG_DUMP_SKB 1
+
+#define DEBUG_QOS 1
+
+#define DISABLE_QOS_WORKAROUND 0
+
+#define ENABLE_DBG_PROC 1
+
+#define ENABLE_FW_PROC 1
+
+#ifdef CONFIG_IFX_ATM_TASKLET
+ #define ENABLE_TASKLET 1
+#endif
+
+#ifdef CONFIG_IFX_ATM_RETX
+ #define ENABLE_ATM_RETX 1
+#endif
+
+#if defined(CONFIG_DSL_MEI_CPE_DRV) && !defined(CONFIG_IFXMIPS_DSL_CPE_MEI)
+ #define CONFIG_IFXMIPS_DSL_CPE_MEI 1
+#endif
+
+/*
+ * Debug/Assert/Error Message
+ */
+
+#define ifx_atm_dbg_enable 1
+
+#define DBG_ENABLE_MASK_ERR (1 << 0)
+#define DBG_ENABLE_MASK_DEBUG_PRINT (1 << 1)
+#define DBG_ENABLE_MASK_ASSERT (1 << 2)
+#define DBG_ENABLE_MASK_DUMP_SKB_RX (1 << 8)
+#define DBG_ENABLE_MASK_DUMP_SKB_TX (1 << 9)
+#define DBG_ENABLE_MASK_DUMP_QOS (1 << 10)
+#define DBG_ENABLE_MASK_DUMP_INIT (1 << 11)
+#define DBG_ENABLE_MASK_MAC_SWAP (1 << 12)
+#define DBG_ENABLE_MASK_ALL (DBG_ENABLE_MASK_ERR | DBG_ENABLE_MASK_DEBUG_PRINT | DBG_ENABLE_MASK_ASSERT | DBG_ENABLE_MASK_DUMP_SKB_RX | DBG_ENABLE_MASK_DUMP_SKB_TX | DBG_ENABLE_MASK_DUMP_QOS | DBG_ENABLE_MASK_DUMP_INIT | DBG_ENABLE_MASK_MAC_SWAP)
+
+#if defined(ENABLE_ASSERT) && ENABLE_ASSERT
+ #define ASSERT(cond, format, arg...) do { if ( (ifx_atm_dbg_enable & DBG_ENABLE_MASK_ASSERT) && !(cond) ) printk(KERN_ERR __FILE__ ":%d:%s: " format "\n", __LINE__, __FUNCTION__, ##arg); } while ( 0 )
+#else
+ #define ASSERT(cond, format, arg...)
+#endif
+
+
+/*
+ * Constants
+ */
+#define DEFAULT_TX_LINK_RATE 3200 // in cells
+
+/*
+ * ATM Port, QSB Queue, DMA RX/TX Channel Parameters
+ */
+#define ATM_PORT_NUMBER 2
+#define MAX_QUEUE_NUMBER 16
+#define OAM_RX_QUEUE 15
+#define QSB_RESERVE_TX_QUEUE 0
+#define FIRST_QSB_QID 1
+#define MAX_PVC_NUMBER (MAX_QUEUE_NUMBER - FIRST_QSB_QID)
+#define MAX_RX_DMA_CHANNEL_NUMBER 8
+#define MAX_TX_DMA_CHANNEL_NUMBER 16
+#define DATA_BUFFER_ALIGNMENT EMA_ALIGNMENT
+#define DESC_ALIGNMENT 8
+#define DEFAULT_RX_HUNT_BITTH 4
+
+/*
+ * RX DMA Channel Allocation
+ */
+#define RX_DMA_CH_OAM 0
+#define RX_DMA_CH_AAL 1
+#define RX_DMA_CH_TOTAL 2
+#define RX_DMA_CH_OAM_DESC_LEN 32
+#define RX_DMA_CH_OAM_BUF_SIZE ((CELL_SIZE + 14) & ~15)
+#define RX_DMA_CH_AAL_BUF_SIZE (2048 - 48)
+
+/*
+ * OAM Constants
+ */
+#define OAM_HTU_ENTRY_NUMBER 3
+#define OAM_F4_SEG_HTU_ENTRY 0
+#define OAM_F4_TOT_HTU_ENTRY 1
+#define OAM_F5_HTU_ENTRY 2
+#define OAM_F4_CELL_ID 0
+#define OAM_F5_CELL_ID 15
+#if defined(ENABLE_ATM_RETX) && ENABLE_ATM_RETX
+ #undef OAM_HTU_ENTRY_NUMBER
+ #define OAM_HTU_ENTRY_NUMBER 4
+ #define OAM_ARQ_HTU_ENTRY 3
+#endif
+
+/*
+ * RX Frame Definitions
+ */
+#define MAX_RX_PACKET_ALIGN_BYTES 3
+#define MAX_RX_PACKET_PADDING_BYTES 3
+#define RX_INBAND_TRAILER_LENGTH 8
+#define MAX_RX_FRAME_EXTRA_BYTES (RX_INBAND_TRAILER_LENGTH + MAX_RX_PACKET_ALIGN_BYTES + MAX_RX_PACKET_PADDING_BYTES)
+
+/*
+ * TX Frame Definitions
+ */
+#define MAX_TX_HEADER_ALIGN_BYTES 12
+#define MAX_TX_PACKET_ALIGN_BYTES 3
+#define MAX_TX_PACKET_PADDING_BYTES 3
+#define TX_INBAND_HEADER_LENGTH 8
+#define MAX_TX_FRAME_EXTRA_BYTES (TX_INBAND_HEADER_LENGTH + MAX_TX_HEADER_ALIGN_BYTES + MAX_TX_PACKET_ALIGN_BYTES + MAX_TX_PACKET_PADDING_BYTES)
+
+#define CELL_SIZE ATM_AAL0_SDU
+
+#if defined(ENABLE_ATM_RETX) && ENABLE_ATM_RETX
+ #define RETX_PLAYOUT_BUFFER_ORDER 6
+ #define RETX_PLAYOUT_BUFFER_SIZE (PAGE_SIZE * (1 << RETX_PLAYOUT_BUFFER_ORDER))
+ #define RETX_PLAYOUT_FW_BUFF_SIZE (RETX_PLAYOUT_BUFFER_SIZE / (32 * 56 /* cell size */))
+ #define RETX_POLLING_INTERVAL (HZ / 100 > 0 ? HZ / 100 : 1)
+#endif
+
+typedef struct {
+ unsigned int h;
+ unsigned int l;
+} ppe_u64_t;
+
+struct port {
+ unsigned int tx_max_cell_rate;
+ unsigned int tx_current_cell_rate;
+
+ struct atm_dev *dev;
+};
+
+struct connection {
+ struct atm_vcc *vcc;
+
+ volatile struct tx_descriptor *tx_desc;
+ unsigned int tx_desc_pos;
+ struct sk_buff **tx_skb;
+
+ unsigned int aal5_vcc_crc_err; /* number of packets with CRC error */
+ unsigned int aal5_vcc_oversize_sdu; /* number of packets with oversize error */
+
+ unsigned int port;
+};
+
+struct atm_priv_data {
+ unsigned long conn_table;
+ struct connection conn[MAX_PVC_NUMBER];
+
+ volatile struct rx_descriptor *aal_desc;
+ unsigned int aal_desc_pos;
+
+ volatile struct rx_descriptor *oam_desc;
+ unsigned char *oam_buf;
+ unsigned int oam_desc_pos;
+
+ struct port port[ATM_PORT_NUMBER];
+
+ unsigned int wrx_pdu; /* successfully received AAL5 packet */
+ unsigned int wrx_drop_pdu; /* AAL5 packet dropped by driver on RX */
+ unsigned int wtx_pdu; /* successfully transmitted AAL5 packet */
+ unsigned int wtx_err_pdu; /* error AAL5 packet */
+ unsigned int wtx_drop_pdu; /* AAL5 packet dropped by driver on TX */
+
+ unsigned int wrx_oam; /* successfully received OAM cell */
+ unsigned int wrx_drop_oam; /* OAM cell dropped by driver on RX */
+ unsigned int wtx_oam; /* successfully transmitted OAM cell */
+ unsigned int wtx_err_oam; /* error during transmiting OAM cell */
+ unsigned int wtx_drop_oam; /* OAM cell dropped by driver on TX */
+
+ ppe_u64_t wrx_total_byte;
+ ppe_u64_t wtx_total_byte;
+ unsigned int prev_wrx_total_byte;
+ unsigned int prev_wtx_total_byte;
+
+ void *aal_desc_base;
+ void *oam_desc_base;
+ void *oam_buf_base;
+ void *tx_desc_base;
+ void *tx_skb_base;
+};
+
+#include "ifxmips_atm_ppe_common.h"
+#include "ifxmips_atm_fw_regs_common.h"
+
+#endif
diff --git a/package/platform/lantiq/ltq-atm/src/ifxmips_atm_danube.c b/package/platform/lantiq/ltq-atm/src/ifxmips_atm_danube.c
new file mode 100644
index 0000000..9bab5b4
--- /dev/null
+++ b/package/platform/lantiq/ltq-atm/src/ifxmips_atm_danube.c
@@ -0,0 +1,231 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_atm_danube.c
+** PROJECT : UEIP
+** MODULES : ATM
+**
+** DATE : 7 Jul 2009
+** AUTHOR : Xu Liang
+** DESCRIPTION : ATM driver common source file (core functions)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 07 JUL 2009 Xu Liang Init Version
+*******************************************************************************/
+
+
+
+/*
+ * ####################################
+ * Head File
+ * ####################################
+ */
+
+/*
+ * Common Head File
+ */
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/version.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/proc_fs.h>
+#include <linux/init.h>
+#include <linux/ioctl.h>
+#include <linux/delay.h>
+
+/*
+ * Chip Specific Head File
+ */
+#include "ifxmips_atm_core.h"
+
+#ifdef CONFIG_DANUBE
+
+#include "ifxmips_atm_fw_danube.h"
+#include "ifxmips_atm_fw_regs_danube.h"
+
+#include <lantiq_soc.h>
+
+#define EMA_CMD_BUF_LEN 0x0040
+#define EMA_CMD_BASE_ADDR (0x00001580 << 2)
+#define EMA_DATA_BUF_LEN 0x0100
+#define EMA_DATA_BASE_ADDR (0x00001900 << 2)
+#define EMA_WRITE_BURST 0x2
+#define EMA_READ_BURST 0x2
+
+static inline void reset_ppe(void);
+
+#define IFX_PMU_MODULE_PPE_SLL01 BIT(19)
+#define IFX_PMU_MODULE_PPE_TC BIT(21)
+#define IFX_PMU_MODULE_PPE_EMA BIT(22)
+#define IFX_PMU_MODULE_PPE_QSB BIT(18)
+#define IFX_PMU_MODULE_TPE BIT(13)
+#define IFX_PMU_MODULE_DSL_DFE BIT(9)
+
+static inline void reset_ppe(void)
+{
+/*#ifdef MODULE
+ unsigned int etop_cfg;
+ unsigned int etop_mdio_cfg;
+ unsigned int etop_ig_plen_ctrl;
+ unsigned int enet_mac_cfg;
+
+ etop_cfg = *IFX_PP32_ETOP_CFG;
+ etop_mdio_cfg = *IFX_PP32_ETOP_MDIO_CFG;
+ etop_ig_plen_ctrl = *IFX_PP32_ETOP_IG_PLEN_CTRL;
+ enet_mac_cfg = *IFX_PP32_ENET_MAC_CFG;
+
+ *IFX_PP32_ETOP_CFG &= ~0x03C0;
+
+ // reset PPE
+ ifx_rcu_rst(IFX_RCU_DOMAIN_PPE, IFX_RCU_MODULE_ATM);
+
+ *IFX_PP32_ETOP_MDIO_CFG = etop_mdio_cfg;
+ *IFX_PP32_ETOP_IG_PLEN_CTRL = etop_ig_plen_ctrl;
+ *IFX_PP32_ENET_MAC_CFG = enet_mac_cfg;
+ *IFX_PP32_ETOP_CFG = etop_cfg;
+#endif*/
+}
+
+/*
+ * Description:
+ * Download PPE firmware binary code.
+ * Input:
+ * src --- u32 *, binary code buffer
+ * dword_len --- unsigned int, binary code length in DWORD (32-bit)
+ * Output:
+ * int --- 0: Success
+ * else: Error Code
+ */
+static inline int danube_pp32_download_code(u32 *code_src, unsigned int code_dword_len, u32 *data_src, unsigned int data_dword_len)
+{
+ volatile u32 *dest;
+
+ if ( code_src == 0 || ((unsigned long)code_src & 0x03) != 0
+ || data_src == 0 || ((unsigned long)data_src & 0x03) != 0 )
+ return -1;
+
+ if ( code_dword_len <= CDM_CODE_MEMORYn_DWLEN(0) )
+ IFX_REG_W32(0x00, CDM_CFG);
+ else
+ IFX_REG_W32(0x04, CDM_CFG);
+
+ /* copy code */
+ dest = CDM_CODE_MEMORY(0, 0);
+ while ( code_dword_len-- > 0 )
+ IFX_REG_W32(*code_src++, dest++);
+
+ /* copy data */
+ dest = CDM_DATA_MEMORY(0, 0);
+ while ( data_dword_len-- > 0 )
+ IFX_REG_W32(*data_src++, dest++);
+
+ return 0;
+}
+
+static void danube_fw_ver(unsigned int *major, unsigned int *minor)
+{
+ ASSERT(major != NULL, "pointer is NULL");
+ ASSERT(minor != NULL, "pointer is NULL");
+
+ *major = FW_VER_ID->major;
+ *minor = FW_VER_ID->minor;
+}
+
+static void danube_init(void)
+{
+ volatile u32 *p = SB_RAM0_ADDR(0);
+ unsigned int i;
+
+ ltq_pmu_enable(IFX_PMU_MODULE_PPE_SLL01 |
+ IFX_PMU_MODULE_PPE_TC |
+ IFX_PMU_MODULE_PPE_EMA |
+ IFX_PMU_MODULE_PPE_QSB |
+ IFX_PMU_MODULE_TPE |
+ IFX_PMU_MODULE_DSL_DFE);
+
+ reset_ppe();
+
+ /* init ema */
+ IFX_REG_W32((EMA_CMD_BUF_LEN << 16) | (EMA_CMD_BASE_ADDR >> 2), EMA_CMDCFG);
+ IFX_REG_W32((EMA_DATA_BUF_LEN << 16) | (EMA_DATA_BASE_ADDR >> 2), EMA_DATACFG);
+ IFX_REG_W32(0x000000FF, EMA_IER);
+ IFX_REG_W32(EMA_READ_BURST | (EMA_WRITE_BURST << 2), EMA_CFG);
+
+ /* init mailbox */
+ IFX_REG_W32(0xFFFFFFFF, MBOX_IGU1_ISRC);
+ IFX_REG_W32(0x00000000, MBOX_IGU1_IER);
+ IFX_REG_W32(0xFFFFFFFF, MBOX_IGU3_ISRC);
+ IFX_REG_W32(0x00000000, MBOX_IGU3_IER);
+
+ /* init atm tc */
+ IFX_REG_W32(0x0000, DREG_AT_CTRL);
+ IFX_REG_W32(0x0000, DREG_AR_CTRL);
+ IFX_REG_W32(0x0, DREG_AT_IDLE0);
+ IFX_REG_W32(0x0, DREG_AT_IDLE1);
+ IFX_REG_W32(0x0, DREG_AR_IDLE0);
+ IFX_REG_W32(0x0, DREG_AR_IDLE1);
+ IFX_REG_W32(0x40, RFBI_CFG);
+ IFX_REG_W32(0x1600, SFSM_DBA0);
+ IFX_REG_W32(0x1718, SFSM_DBA1);
+ IFX_REG_W32(0x1830, SFSM_CBA0);
+ IFX_REG_W32(0x1844, SFSM_CBA1);
+ IFX_REG_W32(0x14014, SFSM_CFG0);
+ IFX_REG_W32(0x14014, SFSM_CFG1);
+ IFX_REG_W32(0x1858, FFSM_DBA0);
+ IFX_REG_W32(0x18AC, FFSM_DBA1);
+ IFX_REG_W32(0x10006, FFSM_CFG0);
+ IFX_REG_W32(0x10006, FFSM_CFG1);
+ IFX_REG_W32(0x00000001, FFSM_IDLE_HEAD_BC0);
+ IFX_REG_W32(0x00000001, FFSM_IDLE_HEAD_BC1);
+
+ for ( i = 0; i < SB_RAM0_DWLEN + SB_RAM1_DWLEN + SB_RAM2_DWLEN + SB_RAM3_DWLEN; i++ )
+ IFX_REG_W32(0, p++);
+}
+
+static void danube_shutdown(void)
+{
+}
+
+int danube_start(int pp32)
+{
+ int ret;
+
+ /* download firmware */
+ ret = danube_pp32_download_code(
+ danube_fw_bin, sizeof(danube_fw_bin) / sizeof(*danube_fw_bin),
+ danube_fw_data, sizeof(danube_fw_data) / sizeof(*danube_fw_data));
+ if ( ret != 0 )
+ return ret;
+
+ /* run PP32 */
+ IFX_REG_W32(DBG_CTRL_START_SET(1), PP32_DBG_CTRL);
+
+ /* idle for a while to let PP32 init itself */
+ udelay(10);
+
+ return 0;
+}
+
+void danube_stop(int pp32)
+{
+ IFX_REG_W32(DBG_CTRL_STOP_SET(1), PP32_DBG_CTRL);
+}
+
+struct ltq_atm_ops danube_ops = {
+ .init = danube_init,
+ .shutdown = danube_shutdown,
+ .start = danube_start,
+ .stop = danube_stop,
+ .fw_ver = danube_fw_ver,
+};
+
+#endif
diff --git a/package/platform/lantiq/ltq-atm/src/ifxmips_atm_fw_amazon_se.h b/package/platform/lantiq/ltq-atm/src/ifxmips_atm_fw_amazon_se.h
new file mode 100644
index 0000000..b0a9c91
--- /dev/null
+++ b/package/platform/lantiq/ltq-atm/src/ifxmips_atm_fw_amazon_se.h
@@ -0,0 +1,457 @@
+#ifndef IFXMIPS_ATM_FW_AMAZON_SE_H
+#define IFXMIPS_ATM_FW_AMAZON_SE_H
+
+
+/******************************************************************************
+**
+** FILE NAME : ifxmips_atm_fw_amazon_se.h
+** PROJECT : UEIP
+** MODULES : ATM (ADSL)
+**
+** DATE : 1 AUG 2005
+** AUTHOR : Xu Liang
+** DESCRIPTION : ATM Driver (PP32 Firmware)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 4 AUG 2005 Xu Liang Initiate Version
+** 23 OCT 2006 Xu Liang Add GPL header.
+** 9 JAN 2007 Xu Liang First version got from Anand (IC designer)
+*******************************************************************************/
+
+
+#define VER_IN_FIRMWARE 1
+
+#define ATM_FW_VER_MAJOR 0
+#define ATM_FW_VER_MINOR 16
+
+
+static unsigned int firmware_binary_code[] = {
+ 0x800004b8, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8000ffe0, 0x00000000, 0x00000000, 0x00000000,
+ 0xc1000002, 0xd90c00f8, 0xc2000002, 0xda0800f9, 0x80004cc8, 0xc2000000, 0xda0800f9, 0x80004330,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x800042e8, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x800055a8, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x800041e8, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xc0400000, 0xc0004840, 0xc88400f8, 0x80004988, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xc0400002, 0xc0004840, 0xc88400f8, 0x80004908, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xc3c00004, 0xdbc800f9, 0xc10c0002, 0xd90c00f8, 0x8000fee0, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xc10e0002, 0xd90c00f8, 0xc0004808, 0xc84000f8, 0x80004938, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xc3e1fffe, 0x597dfffe, 0x593dfe14, 0x900004d9, 0x00000000, 0x00000000, 0x00000000, 0x90cc0481,
+ 0x00000000, 0x00000000, 0x00000000, 0xc3c00000, 0xdbc800f9, 0xc1400008, 0xc1900000, 0x71588000,
+ 0x14100100, 0xc140000a, 0xc1900002, 0x71588000, 0x14100100, 0xc140000c, 0xc1900004, 0x71588000,
+ 0x14100100, 0xc1400004, 0xc1900006, 0x71588000, 0x14100100, 0xc1400006, 0xc1900008, 0x71588000,
+ 0x14100100, 0xc140000e, 0xc190000a, 0x71588000, 0x14100100, 0xc1400000, 0xc190000c, 0x71588000,
+ 0x14100100, 0xc1400002, 0xc190000e, 0x71588000, 0x14100100, 0xc0400000, 0xc11c0000, 0xc000082c,
+ 0xcd05ce00, 0xc11c0002, 0xc000082c, 0xcd05ce00, 0xc0400002, 0xc11c0000, 0xc000082c, 0xcd05ce00,
+ 0xc11c0002, 0xc000082c, 0xcd05ce00, 0xc0000824, 0x00000000, 0xcbc000f9, 0xcb8000f9, 0xcb4000f9,
+ 0xcb0000f8, 0xc0004878, 0x5bfc4000, 0xcfc000f9, 0x5bb84000, 0xcf8000f9, 0x5b744000, 0xcf4000f9,
+ 0x5b304000, 0xcf0000f8, 0xc0000a10, 0x00000000, 0xcbc000f9, 0xcb8000f8, 0xc0004874, 0x5bfc4000,
+ 0xcfc000f9, 0x5bb84000, 0xcf8000f8, 0xc30001fe, 0xc000140a, 0xcf0000f8, 0xc3000000, 0x7f018000,
+ 0xc000042e, 0xcf0000f8, 0xc000040e, 0xcf0000f8, 0xc3c1fffe, 0xc000490e, 0xcfc00078, 0xc000492c,
+ 0xcfc00078, 0xc0004924, 0xcfc00038, 0xc0004912, 0xcfc00038, 0xc0004966, 0xcfc00038, 0xc0004968,
+ 0xcfc00078, 0xc000496a, 0xcfc00078, 0xc3c1fffe, 0xc00049a0, 0xcfc000f8, 0xc3c00000, 0xc2800020,
+ 0xc3000000, 0x7f018000, 0x6ff88000, 0x6fd44000, 0x4395c000, 0x5bb84a00, 0x5838000a, 0xcf0000f8,
+ 0x5bfc0002, 0xb7e8ffc8, 0x00000000, 0xc3c00000, 0xc2800010, 0x6ff86000, 0x47bdc000, 0x5bb84c80,
+ 0xc3400000, 0x58380004, 0xcb420078, 0x00000000, 0x58380008, 0xcf400078, 0x5bfc0002, 0xb7e8ffb0,
+ 0x00000000, 0xc3c00000, 0xc2800020, 0xc348001e, 0xc3000000, 0x7f018000, 0x6ff8a000, 0x6fd44000,
+ 0x4795c000, 0x47bdc000, 0x5bb85e00, 0x58380008, 0xcf408418, 0x5838000a, 0xcf0000f8, 0x5bfc0002,
+ 0xb7e8ffb0, 0x00000000, 0x00000000, 0xc3e06242, 0x5bfc0020, 0xc0004802, 0xcfc000f8, 0xc161fffe,
+ 0x5955fffe, 0x14140000, 0x00000000, 0xc1000000, 0xd91c00f8, 0xc3e01002, 0x5bfd88c0, 0xc3a00f88,
+ 0x5bb839a2, 0x99005fa8, 0xdbd800f8, 0xdb9800f9, 0x00000000, 0xc3c00000, 0xdf7f0038, 0xa7ccfff0,
+ 0xc3800000, 0xc00048c0, 0xcb818078, 0xc0001408, 0xcfc000f8, 0xc10e0002, 0xd90c00f8, 0x5d3802a6,
+ 0xc1000002, 0xd91c1f02, 0x00000000, 0xc121fffe, 0x5911fe14, 0x14100000, 0xa9fe0270, 0xc3c00000,
+ 0xddfc00f0, 0x5d3c0000, 0x84000100, 0xc0000c04, 0xcb8000f8, 0xc11c0002, 0x00000000, 0x7391c000,
+ 0xcf8000f8, 0xc3800000, 0xc3400080, 0xdf780038, 0xb7b4ffea, 0xc3203002, 0x5b3188c4, 0xc2e00f88,
+ 0x5aec100e, 0x99005fa8, 0xdb1800f8, 0xdad800f9, 0x00000000, 0xc3800000, 0xc3400080, 0xdf780038,
+ 0xb7b4ffea, 0xc3205002, 0x5b3188c8, 0xc2e00f90, 0x5aec180c, 0x99005fa8, 0xdb1800f8, 0xdad800f9,
+ 0x00000000, 0x80000128, 0xc00048cc, 0xca8000f8, 0x00000000, 0xc1000006, 0x76914000, 0x840000fa,
+ 0x00000000, 0xa6800070, 0xc3800000, 0xc3400080, 0xdf780038, 0xb7b4ffea, 0xc3202002, 0x5b31c8c6,
+ 0xc2e00f88, 0x5aec100e, 0x99005fa8, 0xdb1800f8, 0xdad800f9, 0x00000000, 0xa6820068, 0xc3800000,
+ 0xc3400080, 0xdf780038, 0xb7b4ffea, 0xc3204002, 0x5b31c8ca, 0xc2e00f90, 0x5aec180c, 0x99005fa8,
+ 0xdb1800f8, 0xdad800f9, 0x00000000, 0xc00048cc, 0xc2800000, 0xce8000f8, 0xc3a00140, 0x5bfc0002,
+ 0x47bc8000, 0xc1000000, 0xc53c00fe, 0xdbdc00f0, 0x80000530, 0x00000000, 0x80002130, 0x00000000,
+ 0x8000fd70, 0xc0004958, 0xc84000f8, 0x00000000, 0xc3c00002, 0x787c2000, 0xcc4000f8, 0xc0004848,
+ 0xcb8400f8, 0xc000495c, 0xcac400f8, 0xc0004844, 0xc88400f8, 0x47ad0000, 0x8400ff82, 0xc000487c,
+ 0xc80400f8, 0x00000000, 0x00000000, 0x40080000, 0xca0000f8, 0xc0001624, 0xcb0400f8, 0xa63c007a,
+ 0x00000000, 0x00000000, 0xa71eff22, 0x00000000, 0xc0000824, 0xca8400f8, 0x6ca08000, 0x6ca42000,
+ 0x46250000, 0x42290000, 0xc35e0002, 0xc6340060, 0xc0001624, 0xcf440078, 0xc2000000, 0xc161fffe,
+ 0x5955fffe, 0x14140000, 0x00000000, 0xc0004844, 0xc88400f8, 0xc000082c, 0xca040038, 0x00000000,
+ 0x00000000, 0x58880002, 0xb6080018, 0x00000000, 0xc0800000, 0xc0004844, 0xcc840038, 0x5aec0002,
+ 0xc000495c, 0xcec400f8, 0x5e6c0006, 0x84000060, 0xc0004848, 0xcb8400f8, 0xc0000838, 0xc2500002,
+ 0xce450800, 0x5fb80002, 0xc0004848, 0xcf8400f8, 0x5eec0002, 0xc000495c, 0xcec400f8, 0x00000000,
+ 0xc121fffe, 0x5911fe14, 0x14100000, 0x8000fd98, 0xc000495a, 0xc84000f8, 0x00000000, 0xc3c00002,
+ 0x787c2000, 0xcc4000f8, 0xc0004960, 0xcac400f8, 0x00000000, 0x00000000, 0x5eec0000, 0x8400010a,
+ 0x00000000, 0xb6fc0050, 0xc0001600, 0xca0400f8, 0x00000000, 0x00000000, 0xa61e00d2, 0x6fe90000,
+ 0xc0000a28, 0xce850800, 0xc2c00000, 0xc2800004, 0xb6e800a0, 0xc0001604, 0xca8400f8, 0xc0004960,
+ 0xcec400f8, 0xa69efcc2, 0x00000000, 0x6fe90000, 0xc0000a28, 0xce850800, 0xc2c00002, 0xc0001600,
+ 0xca0400f8, 0x00000000, 0x00000000, 0xa61e002a, 0x6fe90000, 0xc0000a28, 0xce850800, 0xc2c00000,
+ 0xc0001604, 0xca8400f8, 0xc0004960, 0xcec400f8, 0xa69efc2a, 0xc2400000, 0xc0000a14, 0xca440028,
+ 0x00000000, 0x00000000, 0x466d2000, 0xa4400020, 0xc2800000, 0xdfeb0029, 0x80000010, 0xdfea0029,
+ 0xb668f932, 0x00000000, 0xc00048a0, 0xcb0400f8, 0xc0000a10, 0xca8400f8, 0x6f208000, 0x6f242000,
+ 0x46250000, 0x42a10000, 0xc2400000, 0xc0000a14, 0xca440028, 0xc35e0002, 0xc6340060, 0xc0001604,
+ 0xcf440078, 0x5b300002, 0xb6700018, 0x5aec0002, 0xc3000000, 0xc00048a0, 0xcf0400f8, 0xc0004960,
+ 0xcec400f8, 0x8000f868, 0xc0004918, 0xd28000f8, 0xc2000000, 0xdf600038, 0x5e600080, 0x84000272,
+ 0x00000000, 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000, 0xc000480a, 0xca0000f8, 0xc0004912,
+ 0xca4000f8, 0xc0004924, 0xca8000f8, 0xc0004966, 0xcac000f8, 0x00000000, 0xc121fffe, 0x5911fe14,
+ 0x14100000, 0x76250000, 0x76290000, 0x762d0000, 0x840001ca, 0xc0004918, 0xca4000f8, 0xc28001fe,
+ 0x76290000, 0x5a640002, 0x6a254010, 0x5ee80000, 0x8400001a, 0x6aa54000, 0x80000010, 0xc62800f8,
+ 0x62818008, 0xc0004918, 0xcf0000f8, 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000, 0xc0004966,
+ 0xca4000f8, 0xc2000002, 0x6a310000, 0x7e010000, 0x76612000, 0xce4000f8, 0x00000000, 0xc121fffe,
+ 0x5911fe14, 0x14100000, 0x6f346000, 0x4771a000, 0x5b744c80, 0xc2800000, 0x58340006, 0xca800078,
+ 0xc2c00000, 0x58340000, 0xcac000d8, 0xc2400000, 0x5834000a, 0xca420078, 0x6ea82000, 0x42e9e000,
+ 0x6f2ca000, 0x42e56000, 0x5aec1400, 0xc3990040, 0xc7381c18, 0xc6f80060, 0x99005fa8, 0xdb9800f8,
+ 0xdbd800f9, 0x00000000, 0xdea000f8, 0x46310000, 0x8400fd80, 0xc0004958, 0xc84000f8, 0x00000000,
+ 0xc3c00002, 0x787c2000, 0xcc4000f8, 0xc0004848, 0xcb8400f8, 0xc0004844, 0xc88400f8, 0x5fb80000,
+ 0x8400f7f2, 0xc0001a1c, 0xca0000f8, 0xc2400002, 0x6a452000, 0x76250000, 0x8400f7c2, 0xc000487c,
+ 0xc80400f8, 0x00000000, 0x00000000, 0x40080000, 0xca0000f8, 0xc42400f8, 0x00000000, 0xa63c17da,
+ 0x00000000, 0xc0004878, 0xc80400f8, 0x6c908000, 0x45088000, 0x45088000, 0x40100000, 0xca0000f8,
+ 0xc42400f8, 0x00000000, 0xc0004934, 0xce0000f8, 0xc2800002, 0xc4681c08, 0xc62821d0, 0xc2600010,
+ 0x5a652440, 0xc0004800, 0xcb4000f8, 0xc2200400, 0x5a202400, 0xc7601040, 0xc0001220, 0xce8000f8,
+ 0xc0001200, 0xce4000f8, 0xc0001202, 0xce0000f8, 0xc0001240, 0xcb4000f8, 0x00000000, 0x00000000,
+ 0xa754ffe0, 0xc2000000, 0xc7600040, 0xa7520042, 0x00000000, 0x00000000, 0x99006720, 0xc0004822,
+ 0xc94000f8, 0xc1800002, 0x80001680, 0x58206480, 0xc2000000, 0xca000018, 0xc2400000, 0xca414000,
+ 0xc2800000, 0xca812000, 0xc2c00000, 0xcac20018, 0xc0004938, 0xce0000f8, 0xc0004920, 0xce4000f8,
+ 0xc0004916, 0xce8000f8, 0xc0004922, 0xcec000f8, 0xa6400540, 0x00000000, 0xc0004938, 0xcbc000f8,
+ 0x00000000, 0xc3800000, 0x6ff48000, 0x6fd44000, 0x4355a000, 0x5b744a00, 0x58340000, 0xcb802010,
+ 0x00000000, 0xc2000000, 0x6fb46000, 0x4779a000, 0x5b744c80, 0x5834000c, 0xca000020, 0xc000491a,
+ 0xcf8000f8, 0x5e200000, 0x8400046a, 0xc2000000, 0xdf610048, 0x5e6001e8, 0x8800ffe8, 0xc2000002,
+ 0xc2400466, 0xc2a00000, 0x5aa80000, 0xc0001006, 0xce0000f8, 0xc0001008, 0xce4000f8, 0xc000100a,
+ 0xce8000f8, 0x990059e8, 0xc1a0fffe, 0xc0000824, 0xc9840060, 0xc0004934, 0xca4000f8, 0xc2000000,
+ 0xc2800002, 0x99005a28, 0xda9800f8, 0xc61400f8, 0xc65800f8, 0xc161fffe, 0x5955fffe, 0x14140000,
+ 0x00000000, 0x99005b10, 0xc000491a, 0xc94000f8, 0x00000000, 0x00000000, 0xc121fffe, 0x5911fe14,
+ 0x14100000, 0xc0004922, 0xca001118, 0xc3c00000, 0xc3800000, 0xc0004930, 0xce023118, 0xc0004932,
+ 0xcbc000d8, 0xc2800000, 0xc000491e, 0xcfc000f8, 0xc0004862, 0xca800060, 0xc3a0001a, 0x5bb94000,
+ 0xc6b80060, 0xc000491c, 0xcf8000f8, 0x99005d80, 0xc000491c, 0xc1400000, 0xc9420048, 0x00000000,
+ 0x00000000, 0x00000000, 0xa8e2ffe8, 0xc2000000, 0xc1220002, 0xd90c00f8, 0xdf600038, 0x5e600080,
+ 0x8400fff2, 0xc000491c, 0xca0000f8, 0xc000491e, 0xca4000f8, 0x00000000, 0x00000000, 0x99005fa8,
+ 0xda1800f8, 0xda5800f9, 0x00000000, 0xc2000000, 0xdf610048, 0x5e6001fe, 0x8800ffe8, 0xc0004916,
+ 0xca8000f8, 0xc2c00000, 0xdfec0048, 0xc2400000, 0x466d2000, 0x8400004a, 0x5ea80000, 0x8400003a,
+ 0xc2600002, 0x99006720, 0xc000482e, 0xc94000f8, 0xc1800002, 0x80000030, 0xc2600000, 0x99006720,
+ 0xc000482c, 0xc94000f8, 0xc1800002, 0xc2000068, 0xc6240078, 0xc0004930, 0xce400080, 0xc000491a,
+ 0xc98000f8, 0xc0004862, 0xc94000f8, 0x6d9c6000, 0x45d8e000, 0x59dc4c80, 0x99005e08, 0xd95800f8,
+ 0xd99800f9, 0xd9d400f8, 0x99005d80, 0xc000491c, 0xc1400000, 0xc9420048, 0xc2000000, 0xdf600038,
+ 0x5e600080, 0x8400ffea, 0x00000000, 0xc000491c, 0xca0000f8, 0xc000491e, 0xca4000f8, 0x00000000,
+ 0x00000000, 0x99005fa8, 0xda1800f8, 0xda5800f9, 0x00000000, 0x800010e8, 0x00000000, 0x99006720,
+ 0xc000482a, 0xc94000f8, 0xc1800002, 0x800010b8, 0xc0004938, 0xcbc000f8, 0x00000000, 0x00000000,
+ 0x6ff88000, 0x6fd44000, 0x4395c000, 0x5bb84a00, 0x58380008, 0xca0000f8, 0x00000000, 0x00000000,
+ 0xa6000382, 0x00000000, 0xc0004938, 0xcbc000f8, 0xc3000000, 0x00000000, 0x6ff88000, 0x6fd44000,
+ 0x4395c000, 0x5bb84a00, 0x58380000, 0xcb002010, 0xc2000000, 0x58380008, 0xca020078, 0x5838000c,
+ 0xcac000f8, 0x5838000e, 0xca4000f8, 0xc000491a, 0xcf0000f8, 0xc0004930, 0xcec000f8, 0xc000493c,
+ 0xce0000f8, 0xc0004932, 0xce4000f8, 0x5e200000, 0x84000120, 0xc2800000, 0xa6fe00ba, 0x6f206000,
+ 0x46310000, 0x5a204c80, 0x5820000c, 0xca800020, 0x00000000, 0x00000000, 0x5ea80000, 0x840001f2,
+ 0x00000000, 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000, 0x99005b10, 0xc000491a, 0xc94000f8,
+ 0x00000000, 0x00000000, 0xc121fffe, 0x5911fe14, 0x14100000, 0xc0004930, 0xcac000f8, 0xc0004932,
+ 0xca4000f8, 0xc7ec1118, 0xc0004930, 0xcec000f8, 0x5838000c, 0xcec000f8, 0x58000002, 0xce4000f8,
+ 0xc0004934, 0xca0000f8, 0xc2400002, 0x6e642000, 0x6e642000, 0x76612000, 0x8400002a, 0xc2400002,
+ 0x6e684000, 0x58380008, 0xce804200, 0xa6000020, 0x6e682000, 0x58380008, 0xce802100, 0xc2400002,
+ 0x6e642000, 0x76612000, 0x840000ea, 0x58380008, 0xca0000f8, 0xc2800000, 0xc2400000, 0xa60200c0,
+ 0xdba800f8, 0x6f386000, 0x47b1c000, 0x5bb84c80, 0x58380004, 0xca400078, 0x58380002, 0xca800078,
+ 0x00000000, 0xdeb800f8, 0x46a54000, 0x88000060, 0x00000000, 0xc0004824, 0xca0000f8, 0xc2400002,
+ 0x6e640000, 0x5a200002, 0xce0000f8, 0x58380008, 0xce400000, 0x80000018, 0x00000000, 0x80000048,
+ 0xc0004934, 0xca0000f8, 0x00000000, 0x00000000, 0xa6020c6a, 0x00000000, 0x00000000, 0x80000c98,
+ 0xc2800000, 0xc2000200, 0xc240001a, 0xdf690048, 0x46294000, 0x46a54000, 0x8800ffd2, 0xc2000006,
+ 0xc2600982, 0x5a643b6e, 0x5838000a, 0xca8000f8, 0xc0001006, 0xce0000f8, 0xc0001008, 0xce4000f8,
+ 0xc000100a, 0xce8000f8, 0x990059e8, 0xc1a0fffe, 0xc0000824, 0xc9840060, 0xc2000000, 0xc0004930,
+ 0xca02e008, 0x58380026, 0xca4000f8, 0x00000000, 0xc2800000, 0x99005a28, 0xda9800f8, 0xc61400f8,
+ 0xc65800f8, 0xc0004934, 0xca0000f8, 0x00000000, 0x00000000, 0xa6020022, 0x00000000, 0x00000000,
+ 0x80000318, 0xc0004938, 0xcbc000f8, 0xc0004878, 0xc80400f8, 0x6c908000, 0x45088000, 0x45088000,
+ 0x40100000, 0xca0000f8, 0xc42400f8, 0x00000000, 0x58240018, 0xca0000f8, 0x6ff88000, 0x6fd44000,
+ 0x4395c000, 0x5bb84a00, 0xc3000000, 0xc3400002, 0xc2c00000, 0xc62c0078, 0xc6270038, 0xc0004940,
+ 0xce400038, 0xc6260038, 0xc0004942, 0xce400038, 0xc000493c, 0xca0000f8, 0x5eec0000, 0x8400018a,
+ 0x5a6c0010, 0x46254000, 0x88000190, 0x5a600052, 0x46e54000, 0x88000178, 0x58380006, 0xca8000f8,
+ 0xc0004940, 0xca0000f8, 0xc2400000, 0xc6a70038, 0x7e412000, 0x76612000, 0xc2000000, 0xc6a10038,
+ 0x46250000, 0x84000138, 0xc0004942, 0xca0000f8, 0xc2400000, 0xc6a60038, 0x7e412000, 0x76612000,
+ 0xc2000000, 0xc6a00038, 0x58380002, 0xca8000f8, 0x46250000, 0x840000e8, 0xc2400000, 0xc6a60078,
+ 0x466d0000, 0x880000da, 0xc2400000, 0xc6a40078, 0x58380008, 0xca8000f8, 0x46e50000, 0x880000ba,
+ 0x00000000, 0xa6820018, 0x00000000, 0xc7700b00, 0xa6840098, 0x00000000, 0xc7700a00, 0x80000080,
+ 0xc7700200, 0xc000493c, 0xcac000f8, 0x80000060, 0xc7700300, 0xc000493c, 0xcac000f8, 0x80000040,
+ 0xc7700900, 0x80000030, 0xc7700800, 0x80000020, 0xc7700700, 0x80000010, 0xc7700500, 0xc0004944,
+ 0xcf0000f8, 0xc000493e, 0xcec000f8, 0xc0004938, 0xca4000f8, 0xc000493c, 0xcb8000f8, 0xc000493e,
+ 0xcb4000f8, 0xc3000000, 0x6e608000, 0x6e544000, 0x42150000, 0x5a204a00, 0x5aa00008, 0x58200004,
+ 0xcb000078, 0xc0004934, 0xca0000f8, 0xc2400000, 0xc0004930, 0xca42e008, 0xc3c00018, 0xa6020098,
+ 0x00000000, 0x43656000, 0x47ad0000, 0x88000050, 0x46f96000, 0x6ee04010, 0x5be00004, 0xc2000000,
+ 0xc6e00008, 0x5e200000, 0x84000042, 0x5bfc0002, 0x80000030, 0xc3c00004, 0x5a2c0008, 0x47a10000,
+ 0x88000012, 0x5fb80008, 0x6fe04000, 0x42390000, 0x47212000, 0x88000068, 0xc2400000, 0xc0004930,
+ 0xca42e008, 0xc2060002, 0xc68000f8, 0xce006300, 0x6fe04000, 0x4721c000, 0x5f700010, 0x4765a000,
+ 0xc2000000, 0xc6340008, 0xc25a000a, 0xc000491a, 0xca401c18, 0xc2800000, 0xc0004932, 0xca8000d8,
+ 0xc0004862, 0xca400060, 0x6fa04010, 0x42290000, 0xc000491e, 0xce0000f8, 0xc7e41048, 0xc000491c,
+ 0xce4000f8, 0x6fe04000, 0x43a1c000, 0xc000493c, 0xcf8000f8, 0xc000493e, 0xcf4000f8, 0xc000493a,
+ 0xcfc000f8, 0x80000008, 0x00000000, 0x00000000, 0x00000000, 0xc2000000, 0xdce000f8, 0xa622ffd8,
+ 0xc1220002, 0xd90c00f8, 0xc0004938, 0xcbc000f8, 0xc0004944, 0xcb4000f8, 0xc0004862, 0xcb0000f8,
+ 0xc0004934, 0xca0000f8, 0x6ff88000, 0x6fd44000, 0x4395c000, 0x5bb84a00, 0xa6020268, 0xc2400000,
+ 0x58380008, 0xca406000, 0xdfe800f8, 0xc2218e08, 0x5a21baf6, 0x46a14000, 0x84000022, 0xc2080002,
+ 0x7361a000, 0x80000058, 0x5e640000, 0x84000022, 0xc20c0002, 0x7361a000, 0x80000030, 0xc2000000,
+ 0xc760e710, 0xc7604218, 0x5e200000, 0x84000272, 0xc2200002, 0xc0004930, 0xce021000, 0x99006720,
+ 0xc0004828, 0xc94000f8, 0xc1800002, 0x58380000, 0xca0000f8, 0x00000000, 0x00000000, 0xa6000132,
+ 0xc0004940, 0xca8000f8, 0xc0004942, 0xca4000f8, 0xc7600078, 0xc6a01838, 0xc6601038, 0xc000493a,
+ 0xca4000f8, 0xc0004934, 0xca8000f8, 0xc0005600, 0x40300000, 0x40240000, 0x5c000004, 0x5ec05800,
+ 0x88000012, 0x5c000200, 0xce0000f8, 0x58000002, 0x5ec05800, 0x88000012, 0x5c000200, 0xce8000f8,
+ 0xc000493e, 0xca0000f8, 0xc2400000, 0x5838000c, 0xce4000f8, 0x99006720, 0xc0004830, 0xc94000f8,
+ 0xc61800f8, 0xc0004930, 0xc6100078, 0xcd000078, 0x800000a8, 0xc2400002, 0x58380008, 0xce400000,
+ 0xc0004944, 0xcf4000f8, 0x80000278, 0xc000493c, 0xca4000f8, 0xdfe800f8, 0x5a300018, 0xc0005600,
+ 0x40200000, 0xca0000f8, 0x58380008, 0xc6501078, 0xcd021078, 0x5838000a, 0xce8000f8, 0x58380026,
+ 0xce0000f8, 0xc0004944, 0xcf4000f8, 0x99005d80, 0xc000491c, 0xc1400000, 0xc9420048, 0x80000038,
+ 0x00000000, 0x99006720, 0xc0004826, 0xc94000f8, 0xc1800002, 0x8000fdd8, 0xc2000000, 0xc2400080,
+ 0xdf600038, 0xb624ffea, 0xc000491c, 0xca4000f8, 0xc000491e, 0xca8000f8, 0x99005fa8, 0xda5800f8,
+ 0xda9800f9, 0x00000000, 0xc0004934, 0xca0000f8, 0x00000000, 0xc2800000, 0xa6020160, 0xc2400004,
+ 0xc2000200, 0xdf690048, 0x46294000, 0x46a54000, 0x8800ffda, 0x00000000, 0xc000491a, 0xc98000f8,
+ 0xc0004862, 0xc94000f8, 0x6d9c6000, 0x45d8e000, 0x59dc4c80, 0x99005e08, 0xd95800f8, 0xd99800f9,
+ 0xd9d400f8, 0x99005d80, 0xc000491c, 0xc1400000, 0xc9420048, 0xc2000000, 0xc2400080, 0xdf600038,
+ 0xb624ffea, 0xc000491c, 0xca4000f8, 0xc000491e, 0xca8000f8, 0x99005fa8, 0xda5800f8, 0xda9800f9,
+ 0x00000000, 0x58380008, 0xca4000f8, 0xc2000000, 0xce000018, 0xc2a1fffe, 0x5aa9fffe, 0xce021078,
+ 0x5838000a, 0xce8000f8, 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000, 0xc0000838, 0xc2500002,
+ 0xce450800, 0xc0004848, 0xcb8400f8, 0xc2000000, 0xc000082c, 0xca040028, 0x5fb80002, 0xc0004848,
+ 0xcf8400f8, 0x58880002, 0xb6080018, 0x00000000, 0xc0800000, 0xc0004844, 0xcc8400f8, 0x00000000,
+ 0xc121fffe, 0x5911fe14, 0x14100000, 0x8000ded8, 0xc2000000, 0xdf600038, 0x5e200080, 0x8400026a,
+ 0x00000000, 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000, 0xc000480c, 0xca0000f8, 0xc0004910,
+ 0xca4000f8, 0xc000492c, 0xca8000f8, 0xc0004968, 0xcac000f8, 0x00000000, 0xc121fffe, 0x5911fe14,
+ 0x14100000, 0x76250000, 0x76290000, 0x76e16000, 0x840001c2, 0xc0004926, 0xca4000f8, 0xc201fffe,
+ 0x76e16000, 0x5a640002, 0x6ae50010, 0x5f200000, 0x8400001a, 0x6a250000, 0x80000010, 0xc6e000f8,
+ 0x62014008, 0xc0004926, 0xce8000f8, 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000, 0xc0004968,
+ 0xca4000f8, 0xc2000002, 0x6a290000, 0x7e010000, 0x76612000, 0xce4000f8, 0x00000000, 0xc121fffe,
+ 0x5911fe14, 0x14100000, 0x6eb4a000, 0x6e944000, 0x4755a000, 0x4769a000, 0x5b745e00, 0x58340002,
+ 0xc2000000, 0xca0000d8, 0x5834002e, 0xc2400000, 0xca400078, 0x6eb0a000, 0x6ebc4000, 0x473d8000,
+ 0x47298000, 0x5b301e2e, 0x5b300004, 0x6e642000, 0x4225e000, 0xc39a8024, 0xc7380060, 0xc6b81c18,
+ 0x99005fa8, 0xdb9800f8, 0xdbd800f9, 0x00000000, 0xc2000000, 0xdf600038, 0x5e200080, 0x84000352,
+ 0x00000000, 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000, 0xc000490e, 0xca0000f8, 0xc00049a0,
+ 0xca8000f8, 0xc000492a, 0xca4000f8, 0xc000496a, 0xcb0000f8, 0xc0004956, 0xcac000f8, 0x00000000,
+ 0xc121fffe, 0x5911fe14, 0x14100000, 0x77218000, 0x77258000, 0x77298000, 0x8400029a, 0xc201fffe,
+ 0x77218000, 0x5aec0002, 0x6b2d0010, 0x5ea00000, 0x8400001a, 0x6a2d0000, 0x80000010, 0xc72000f8,
+ 0x62016008, 0xc0004956, 0xcec000f8, 0x6ef4a000, 0x6ed44000, 0x4755a000, 0x476da000, 0x5b745e00,
+ 0x58340000, 0xc9c000f8, 0xc00049a0, 0xca0000f8, 0xc3000000, 0xc5f04018, 0xc2400000, 0xc5e50038,
+ 0x7e412000, 0x76250000, 0xce0000f8, 0xc0004980, 0x40300000, 0xcec000f8, 0xc161fffe, 0x5955fffe,
+ 0x14140000, 0x00000000, 0xc000496a, 0xca4000f8, 0xc2000002, 0x6a2d0000, 0x7e010000, 0x76612000,
+ 0xce4000f8, 0x00000000, 0xc121fffe, 0x5911fe14, 0x14100000, 0x6ef4a000, 0x6ed44000, 0x4755a000,
+ 0x476da000, 0x5b745e00, 0x5834000e, 0xc2000000, 0xca0000d8, 0x58340008, 0xc2400000, 0xca420078,
+ 0x5834000c, 0xc2800000, 0xca832010, 0x6e644010, 0x42250000, 0x4229e000, 0xc39a8008, 0x58340008,
+ 0xcb809018, 0x58340008, 0xc2800000, 0xca810010, 0x6ee0a000, 0x6ee44000, 0x46250000, 0x462d0000,
+ 0x5a200008, 0x5a201e08, 0x42290000, 0xc6380060, 0xc6f81c18, 0x99005fa8, 0xdb9800f8, 0xdbd800f9,
+ 0x00000000, 0xc000495a, 0xc84000f8, 0x00000000, 0xc3c00002, 0x787c2000, 0xcc4000f8, 0xc0001a1c,
+ 0xca0000f8, 0xc2400008, 0x6a452000, 0x76250000, 0x84000ec2, 0xc0000a28, 0xc3800000, 0xcb840028,
+ 0xc0000a14, 0xc3400000, 0xcb440028, 0xc0004880, 0xcb0400f8, 0xb7b40072, 0x58041802, 0xcac000f8,
+ 0xa7000078, 0x00000000, 0x00000000, 0xa6c8d598, 0xc1000000, 0xc6d00018, 0xc0004980, 0x40100000,
+ 0xca8000f8, 0x80000070, 0x00000000, 0x00000000, 0x00000000, 0x8000d548, 0x00000000, 0xc2800000,
+ 0xc7282018, 0xc000490e, 0xca4000f8, 0x6be9e000, 0x00000000, 0x767d2000, 0x8400d500, 0x6ea0a000,
+ 0x6e944000, 0x46150000, 0x46290000, 0x5a205e00, 0x5820000c, 0xca0000f8, 0xc0004946, 0xce8000f8,
+ 0xa62203a8, 0x00000000, 0xc2200060, 0xc0004948, 0xce000008, 0xce021038, 0xc240000a, 0xc000494a,
+ 0xce4000f8, 0xc2b60002, 0xc0004964, 0xce837b00, 0x99006278, 0xc00048a0, 0xc88400f8, 0x00000000,
+ 0xc0004946, 0xcbc000f8, 0x00000000, 0x00000000, 0x6ff8a000, 0x6fd44000, 0x4795c000, 0x47bdc000,
+ 0x5bb85e00, 0x99006038, 0xdbd800f8, 0xdb9800f9, 0x00000000, 0x99005d80, 0xc000491c, 0xc1400000,
+ 0xc9420048, 0xc000491c, 0x99006230, 0xc94000f9, 0xc98000f8, 0x00000000, 0x99005fa8, 0xd95800f8,
+ 0xd99800f9, 0x00000000, 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000, 0x99005c70, 0xdbd800f8,
+ 0xdb9800f9, 0xc7d800f8, 0x00000000, 0xc121fffe, 0x5911fe14, 0x14100000, 0x6ff8a000, 0x6fd44000,
+ 0x4795c000, 0x47bdc000, 0x5bb85e00, 0x58380010, 0xca0000f8, 0xc0004874, 0xc80400f8, 0x6c908000,
+ 0x45088000, 0x45088000, 0x40100000, 0xca4000f8, 0xc43400f8, 0x00000000, 0xc74000f8, 0xce0000f8,
+ 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000, 0xc000490e, 0xca4000f8, 0xc2800002, 0x6abd4000,
+ 0x72692000, 0xce4000f8, 0x00000000, 0xc121fffe, 0x5911fe14, 0x14100000, 0x99006720, 0xc0004836,
+ 0xc94000f8, 0xc1800002, 0x00000000, 0x00000000, 0x00000000, 0xa8e2ffe8, 0x00000000, 0x58380000,
+ 0xc90000f8, 0xc00049a0, 0xca0000f8, 0xc2800000, 0xc5290038, 0x72290000, 0xce0000f8, 0xc1220002,
+ 0xd90c00f8, 0xc2000000, 0xc0000a14, 0xca040028, 0xc0000a28, 0xc2500002, 0xce450800, 0x58880002,
+ 0xb6080018, 0xc00048a0, 0xc0800000, 0xcc8400f8, 0x8000d110, 0xc0004946, 0xcbc000f8, 0xc161fffe,
+ 0x5955fffe, 0x14140000, 0x00000000, 0xc000490e, 0xca4000f8, 0xc2800002, 0x6abd4000, 0x72692000,
+ 0xce4000f8, 0x00000000, 0xc121fffe, 0x5911fe14, 0x14100000, 0x6ff8a000, 0x6fd44000, 0x4795c000,
+ 0x47bdc000, 0x5bb85e00, 0x58380008, 0xca0000f8, 0x5838000c, 0xca4000f8, 0xc3400000, 0xc6340000,
+ 0xc000494e, 0xcf4000f8, 0xc2800000, 0xc62a0078, 0xc3000000, 0xc6308018, 0x6f304000, 0x43298000,
+ 0xc000493c, 0xcf0000f8, 0xc2c00000, 0xc66c0078, 0xc0004950, 0xcec000f8, 0xc2800000, 0xc66ae020,
+ 0xc0004954, 0xce8000f8, 0x5f740000, 0x840001a0, 0x5e300028, 0x46e12000, 0x8400016a, 0x46e12000,
+ 0x88000132, 0x5e300018, 0x46e12000, 0x8800002a, 0x46e12000, 0x84000042, 0x00000000, 0x800000c0,
+ 0x00000000, 0x990063b8, 0xdbd800f8, 0xdb9800f9, 0xc78000f8, 0xc3400002, 0xc000494e, 0xcf4000f8,
+ 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000, 0xc000490e, 0xca4000f8, 0xc2800002, 0x6abd4000,
+ 0x7e814000, 0x76692000, 0xce4000f8, 0x00000000, 0xc121fffe, 0x5911fe14, 0x14100000, 0xc2200060,
+ 0xc0004948, 0xce021038, 0xc2000000, 0xc000494c, 0xce0000f8, 0x80000080, 0x00000000, 0x990063b8,
+ 0xdbd800f8, 0xdb9800f9, 0xc78000f8, 0x990065b8, 0xdbd800f8, 0xdb9800f9, 0xc78000f8, 0xc2200058,
+ 0xc0004948, 0xce021038, 0xc2000002, 0xc000494c, 0xce0000f8, 0xc2000006, 0xc0001006, 0xce0000f8,
+ 0x5838000a, 0xca4000f8, 0xc2200982, 0x5a203b6e, 0xc0001008, 0xce0000f8, 0xc000100a, 0xce4000f8,
+ 0xc0004954, 0xca8000f8, 0xc200000c, 0xc000494a, 0xce0000f8, 0xc0004948, 0xce800008, 0xc2b60000,
+ 0xc0004964, 0xce8000f8, 0x99006278, 0xc00048a0, 0xc88400f8, 0x00000000, 0xc0004946, 0xcbc000f8,
+ 0xc000494c, 0xca0000f8, 0x6ff8a000, 0x6fd44000, 0x4795c000, 0x47bdc000, 0x5bb85e00, 0x5e200000,
+ 0x840000fa, 0x00000000, 0x99006038, 0xdbd800f8, 0xdb9800f9, 0x00000000, 0x99005d80, 0xc000491c,
+ 0xc1400000, 0xc9420048, 0xc000491c, 0x99006230, 0xc94000f9, 0xc98000f8, 0x00000000, 0x99005fa8,
+ 0xd95800f8, 0xd99800f9, 0x00000000, 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000, 0x99005c70,
+ 0xdbd800f8, 0xdb9800f9, 0xc7d800f8, 0x00000000, 0xc121fffe, 0x5911fe14, 0x14100000, 0xc000493c,
+ 0xca8000f8, 0xc000494e, 0xcac000f8, 0xc3000018, 0xc3400006, 0x5e200000, 0x8400002a, 0xc2800000,
+ 0xc2c00000, 0xc300001e, 0xc3400000, 0xc6ac1078, 0xc72c0418, 0xc76c0810, 0x58380010, 0xca8000f8,
+ 0x58380008, 0xcec000f8, 0xc6280100, 0xc0004874, 0xc80400f8, 0x6c908000, 0x45088000, 0x45088000,
+ 0x40100000, 0xcb0000f8, 0xc43400f8, 0x00000000, 0xc74000f8, 0xce8000f8, 0xc0004952, 0xce8000f8,
+ 0x00000000, 0x00000000, 0x00000000, 0xa8e2ffe8, 0x00000000, 0xc000494c, 0xca0000f8, 0xc0004950,
+ 0xcac000f8, 0x5e200000, 0x8400006a, 0xdfe800f8, 0x7e814000, 0x5834001a, 0xce8000f8, 0x99006720,
+ 0xc0004834, 0xc94000f8, 0xc1800002, 0x99006720, 0xc0004838, 0xc94000f8, 0xc6d800f8, 0xc1220002,
+ 0xd90c00f8, 0x5e200000, 0x84000040, 0x5838002c, 0xcb0000f8, 0xdfe800f8, 0x00000000, 0x58380014,
+ 0xcf0000f8, 0x80000058, 0xc2a1fffe, 0x5aa9fffe, 0x58380000, 0xc90000f8, 0xc00049a0, 0xcb0000f8,
+ 0xc2c00000, 0xc52d0038, 0x732d8000, 0xcf0000f8, 0x5838000a, 0xce8000f8, 0xc3000000, 0xc0000a14,
+ 0xcb040028, 0xc2d00002, 0xc0000a28, 0xcec50800, 0xc000494e, 0xca8000f8, 0x58880002, 0xb4b00018,
+ 0xc00048a0, 0xc0800000, 0xcc8400f8, 0x5ea80000, 0x8400017a, 0x5e200000, 0x84000168, 0xc000493c,
+ 0xca8000f8, 0x00000000, 0x00000000, 0x5aa80060, 0xce8000f8, 0x990063b8, 0xdbd800f8, 0xdb9800f9,
+ 0xc78000f8, 0x990065b8, 0xdbd800f8, 0xdb9800f9, 0xc78000f8, 0x58380000, 0xcac000f8, 0x00000000,
+ 0xc2000000, 0xc6e04018, 0xc0004952, 0xcac000f8, 0x58380000, 0xca8000f8, 0xc30c0002, 0xc6300018,
+ 0xa6800098, 0x00000000, 0x00000000, 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000, 0xc0001800,
+ 0xca0000f8, 0x00000000, 0x00000000, 0xa60cffea, 0xc6f00500, 0xc6b0c400, 0xcf0000f8, 0x00000000,
+ 0xc121fffe, 0x5911fe14, 0x14100000, 0x8000c758, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x8000c6f0, 0xdcbc00f9, 0x5ffc0000, 0x84000052, 0xc3800002, 0xdb8800f9, 0x5ffc0004, 0x8400bf4a,
+ 0xc3800000, 0xdb8800f9, 0xc3ce0002, 0xc0000800, 0xcfc0e700, 0xc3e1fffe, 0x597dfffe, 0x593dfe14,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0xc000487c, 0xc80400f8, 0x00000000, 0x00000000,
+ 0x40080000, 0xcbc000f8, 0xc43800f8, 0x00000000, 0xc000480e, 0xca0000f8, 0xc0004858, 0xcb4400f8,
+ 0x00000000, 0x00000000, 0x47610000, 0x880000b0, 0x00000000, 0xa7c00048, 0xc0004854, 0xc1000002,
+ 0xcd0400f8, 0xc11c0000, 0xc000082c, 0xcd05ce00, 0x800000d8, 0x00000000, 0xa7d20138, 0x00000000,
+ 0xc7e14040, 0xc2400000, 0xc6246028, 0xc200006a, 0x46250000, 0xc6240030, 0xc0000810, 0xce440030,
+ 0x8000ff70, 0xc2000000, 0xc0000808, 0xca040010, 0xc11c0000, 0xc000082c, 0xcd05ce00, 0x5a200002,
+ 0x5e600010, 0x84000010, 0xc2000000, 0xc0000808, 0xce040010, 0xc3400000, 0x80000028, 0xc1200002,
+ 0xc0000818, 0xcd061000, 0x5b740002, 0xc0004858, 0xcf4400f8, 0x990059c0, 0xc0004848, 0xc94400f8,
+ 0xc1800000, 0xc11c0002, 0xc000082c, 0xcd05ce00, 0x80000600, 0x5b740002, 0xc0004858, 0xcf4400f8,
+ 0xc78000f8, 0xc13c0002, 0xcd03de00, 0xc0004848, 0xc94400f8, 0xc1800000, 0xc000082c, 0xc9840028,
+ 0x59540002, 0xc0004848, 0xcd4400f8, 0x58880002, 0xb4980580, 0x00000000, 0xc0800000, 0x80000568,
+ 0xc000487c, 0xc80400f8, 0x00000000, 0x00000000, 0x40080000, 0xcbc000f8, 0xc42800f8, 0x00000000,
+ 0xa7c00130, 0xc000484c, 0xca0400f8, 0xc2400000, 0xc0001aec, 0xca440018, 0x5a200002, 0xc000484c,
+ 0xce0400f8, 0xb624008a, 0xc68000f8, 0xc13c0002, 0xcd03de00, 0xc0004848, 0xc94400f8, 0xc1800000,
+ 0xc000082c, 0xc9840028, 0x59540002, 0xc0004848, 0xcd4400f8, 0x58880002, 0xb4980470, 0x00000000,
+ 0xc0800000, 0x80000458, 0xc0004854, 0xc1000004, 0xcd0400f8, 0xc0000820, 0xc2000002, 0xce0400f8,
+ 0xc2000000, 0xc000484c, 0xce0400f8, 0xc0004858, 0xce0400f8, 0x8000ff28, 0xc0004854, 0xc1000000,
+ 0xcd0400f8, 0xc11c0000, 0xc000082c, 0xcd05ce00, 0x990059c0, 0xc0004848, 0xc94400f8, 0xc1800000,
+ 0xc1200000, 0xc0000818, 0xcd061000, 0xc11c0002, 0xc000082c, 0xcd05ce00, 0xc2000000, 0xc000484c,
+ 0xce0400f8, 0x80000358, 0xc0001ac0, 0xcb8400f8, 0xc000487c, 0xc80400f8, 0x00000000, 0x00000000,
+ 0x40080000, 0xcbc000f8, 0xc42800f8, 0x00000000, 0x00000000, 0xc68000f8, 0xc13c0000, 0xcd03de00,
+ 0xa780024a, 0x00000000, 0x00000000, 0xa7c0020a, 0x00000000, 0xc0001b00, 0xc2060006, 0xce046308,
+ 0xa7e801c2, 0x00000000, 0xc0004850, 0xca0400f8, 0xc2400000, 0xc0001aec, 0xca448018, 0x5a200002,
+ 0xc0004850, 0xce0400f8, 0xb62400aa, 0x00000000, 0xc68000f8, 0xc13c0002, 0xcd03de00, 0xc0001acc,
+ 0xc2000002, 0xce040000, 0xc0004848, 0xc94400f8, 0xc1800000, 0xc000082c, 0xc9840028, 0x59540002,
+ 0xc0004848, 0xcd4400f8, 0x58880002, 0xb49801c8, 0x00000000, 0xc0800000, 0x800001b0, 0xc0004854,
+ 0xc1000000, 0xcd0400f8, 0xc11c0000, 0xc000082c, 0xcd05ce00, 0x990059c0, 0xc0004848, 0xc94400f8,
+ 0xc1800000, 0xc2000000, 0xc0000820, 0xce0400f8, 0xc1200000, 0xc0000818, 0xcd061000, 0xc11c0002,
+ 0xc000082c, 0xcd05ce00, 0xc0004850, 0xce0400f8, 0xc2000002, 0xc0001acc, 0xce040008, 0x800000e8,
+ 0xc2000002, 0xc0004850, 0xce0400f8, 0x8000fe88, 0xc2000000, 0xc0004850, 0xce0400f8, 0xa7e60032,
+ 0x00000000, 0xc2000002, 0xc0001b00, 0xce040000, 0x8000fe70, 0x00000000, 0xa7860052, 0x00000000,
+ 0xc68000f8, 0xc13c0002, 0xcd03de00, 0xc2020002, 0xc7e2a540, 0xc0001b00, 0xce0400f8, 0x8000fe18,
+ 0xc2040002, 0xc0001b00, 0xce044200, 0x8000fdf8, 0xc2c80002, 0x6ac56000, 0xdacc00f8, 0xc0004854,
+ 0xcb4400f8, 0xc0004848, 0xcb8400f8, 0xc0000838, 0xc3c00000, 0xcbc40028, 0x5ef40004, 0x84000022,
+ 0xc3000000, 0xc0001acc, 0xcf042100, 0x47f98000, 0x8400002a, 0x47f98000, 0x88000030, 0xc1006e8c,
+ 0x8000b380, 0xc0004840, 0xcc8400f8, 0x8000f6b0, 0xc0001ac0, 0xcac400f8, 0xc0004854, 0xcb4400f8,
+ 0xa6c0fbd2, 0x00000000, 0x5ef40000, 0x8400f70a, 0x5ef40002, 0x8400f99a, 0x5ef40004, 0x8400fb9a,
+ 0xc1006ce8, 0x8000b2f8, 0x00000000, 0xc0800000, 0xdf4b0038, 0xc0004900, 0xcb8000f8, 0xc2000000,
+ 0xc000490a, 0xa78000d0, 0xcbc000f8, 0xc1000000, 0xd90000f9, 0xc1000002, 0xd90c00f8, 0x6ff46000,
+ 0x477da000, 0x5b744c80, 0xc2400000, 0x58340004, 0xca400078, 0xc0004900, 0xce000000, 0x5a640002,
+ 0x58340004, 0xc6500078, 0xcd000078, 0xc0004914, 0xca4000f8, 0xc2000002, 0x6a3d0000, 0x72612000,
+ 0xce4000f8, 0xc0000408, 0xce0000f8, 0xa78200d8, 0xc0004908, 0xcbc000f8, 0xc1000000, 0xd90000f9,
+ 0xc1000002, 0xd90c00f8, 0x6ff4a000, 0x6fd44000, 0x4755a000, 0x477da000, 0x5b745e00, 0xc2800000,
+ 0x58340006, 0xca800078, 0xc2000000, 0xc0004900, 0xce002100, 0x5ea80002, 0x58340006, 0xc6900078,
+ 0xcd000078, 0x5a7c0020, 0xc2000002, 0x6a250000, 0xc0000408, 0xce0000f8, 0xdca800f9, 0x5ea80000,
+ 0x8400b168, 0x00000000, 0xa4800230, 0x00000000, 0xc3c00000, 0xc000140e, 0xcbc00018, 0xc3400000,
+ 0xc2400000, 0x6ff86000, 0x47bdc000, 0x5bb84c80, 0x58380008, 0xcb400078, 0x58380006, 0xca400078,
+ 0x5f740002, 0x58380008, 0xc7500078, 0xcd000078, 0xc2000000, 0x58380004, 0xca020078, 0xc3000000,
+ 0x5838000c, 0xcb000020, 0x5a640002, 0x46610000, 0x84000010, 0xc2400000, 0x58380006, 0xc6500078,
+ 0xcd000078, 0xc2000000, 0x5838000a, 0xca020078, 0x5b300002, 0x5838000c, 0xc7100020, 0xcd000020,
+ 0xc2420020, 0x5a200004, 0x46252000, 0x84000010, 0xc2000000, 0x5838000a, 0xc6101078, 0xcd021078,
+ 0xc0004966, 0xca4000f8, 0xc2000002, 0x6a3d0000, 0x72612000, 0xce4000f8, 0x5f740000, 0x84000040,
+ 0xc0004912, 0xca0000f8, 0xc2c00002, 0x6afd6000, 0x7ec16000, 0x762d0000, 0xce0000f8, 0x5f300020,
+ 0x84000040, 0xc0004924, 0xca0000f8, 0xc2c00002, 0x6afd6000, 0x7ec16000, 0x762d0000, 0xce0000f8,
+ 0xa4820070, 0xc2400000, 0xc000140e, 0xca408018, 0xc2000002, 0xc0004900, 0xce000000, 0xc000490a,
+ 0xce4000f8, 0xc1000000, 0xd90000f9, 0xd8400078, 0xc1000004, 0xd90000f9, 0xa4840270, 0x00000000,
+ 0xc3c00000, 0xc000140e, 0xcbc10018, 0xc2800000, 0xc2000000, 0x6ff8a000, 0x6fd44000, 0x4795c000,
+ 0x47bdc000, 0x5bb85e00, 0x5838002e, 0xca800078, 0x58380006, 0xca020078, 0xc3400000, 0x5838002e,
+ 0xcb420078, 0x5aa80002, 0x46a10000, 0x84000010, 0xc2800000, 0x5838002e, 0xc6900078, 0xcd000078,
+ 0x5f740002, 0x5838002e, 0xc7501078, 0xcd021078, 0xc0004968, 0xca4000f8, 0xc2000002, 0x6a3d0000,
+ 0x72612000, 0xce4000f8, 0xc000492a, 0xca8000f8, 0x5e740000, 0x84000040, 0xc0004910, 0xca0000f8,
+ 0xc2c00002, 0x6afd6000, 0x7ec16000, 0x762d0000, 0xce0000f8, 0x6abd4010, 0xa68000ba, 0x00000000,
+ 0x58380032, 0xca0000f8, 0x58000002, 0xca4000f8, 0x5838000c, 0x00000000, 0xce0000f9, 0xce4000f8,
+ 0xc000492a, 0xca0000f8, 0xc2c00002, 0x6afd6000, 0x722d0000, 0xce0000f8, 0xc000492c, 0xca0000f8,
+ 0xc2c00002, 0x6afd6000, 0x722d0000, 0xce0000f8, 0x80000040, 0xc000492c, 0xca0000f8, 0xc2c00002,
+ 0x6afd6000, 0x7ec16000, 0x762d0000, 0xce0000f8, 0xa4880148, 0xc2c00000, 0xc000140e, 0xcac20018,
+ 0xc000490e, 0xca4000f8, 0xc2000002, 0x6a2d0000, 0x7e010000, 0x76612000, 0xce4000f8, 0xc000496a,
+ 0xca4000f8, 0xc2000002, 0x6a2d0000, 0x72612000, 0xce4000f8, 0x6ef0a000, 0x6ed44000, 0x47158000,
+ 0x472d8000, 0x5b305e00, 0x58300000, 0xca0000f8, 0x00000000, 0xc2400002, 0x76612000, 0x84000072,
+ 0x58300000, 0xca4000f8, 0xc2800000, 0x00000000, 0xc6684018, 0xc24c0002, 0xc6a40018, 0xc624c400,
+ 0x58300010, 0xca400500, 0x00000000, 0xc0001800, 0xce4000f8, 0xa4860070, 0xc2400000, 0xc000140e,
+ 0xca418018, 0xc2020002, 0xc0004900, 0xce002100, 0xc0004908, 0xce4000f8, 0xc1000000, 0xd90000f9,
+ 0xd8400078, 0xc1000004, 0xd90000f9, 0xa48c00e8, 0xc2400000, 0xc000140e, 0xca430018, 0x00000000,
+ 0x00000000, 0x5d240002, 0x84000058, 0xc00048c4, 0xca0000f8, 0xc00048c6, 0xc1040002, 0x72110000,
+ 0xce0000f8, 0xc1000002, 0xc00048cc, 0xcd000000, 0x80000060, 0x5d240004, 0x84000050, 0xc00048c8,
+ 0xca0000f8, 0xc00048ca, 0xc1160002, 0x72110000, 0xce0000f8, 0xc1020002, 0xc00048cc, 0xcd002100,
+ 0xc0001408, 0xcc8000f8, 0xc10e0002, 0xd90c00f8, 0x8000ecc8, 0xdfbc00f9, 0xc000496e, 0x990066c8,
+ 0xc94000f8, 0xc7d800f8, 0x00000000, 0xc57000f8, 0x5ef00020, 0x88000148, 0x6f346000, 0x4771a000,
+ 0x5b744c80, 0x58340008, 0xc2400000, 0xca400078, 0x00000000, 0xc2000000, 0x5a640002, 0xce400078,
+ 0x58340004, 0xca000078, 0x00000000, 0x00000000, 0x5e200002, 0xce000078, 0xc0004912, 0xca8000f8,
+ 0xc2400002, 0x6a712000, 0x72a54000, 0xce8000f8, 0x5e200000, 0x84000052, 0xc000480a, 0xca0000f8,
+ 0xc0000408, 0xca8000f8, 0x76250000, 0x00000000, 0x72a14000, 0xce8000f8, 0x80000038, 0xc0004914,
+ 0xca0000f8, 0x7e412000, 0x00000000, 0x76250000, 0xce0000f8, 0x800000d0, 0x6ef4a000, 0x6ed44000,
+ 0x4755a000, 0x476da000, 0x5b745e00, 0x5834002e, 0xc2400000, 0xca420078, 0x00000000, 0xc2000000,
+ 0x5a640002, 0xc6501078, 0xcd021078, 0x58340006, 0xca000078, 0x00000000, 0x00000000, 0x5a200002,
+ 0xce000078, 0xc0004910, 0xca4000f8, 0xc2000002, 0x6a2d0000, 0x72612000, 0xce4000f8, 0xc2000002,
+ 0x6a310000, 0xc000042a, 0xce0000f8, 0xc1040002, 0xd90c00f8, 0x00000000, 0x8000ea38, 0x00000000,
+ 0xc4980928, 0x9d000000, 0xc5580028, 0xc0000838, 0xcd8400f8, 0xc1440200, 0xc1c01600, 0xc55c1070,
+ 0xc000100e, 0x9d000000, 0xcd8000f8, 0xc000100c, 0xcdc000f8, 0xc0004862, 0xc9c000f8, 0x00000000,
+ 0x00000000, 0xd9d800f9, 0xc0005600, 0x401c0000, 0x5dc05800, 0x88000012, 0x5c000200, 0xcd8000f8,
+ 0xc1f0000a, 0x715ca000, 0xdd9800f8, 0xdd9c00f9, 0x41d8e000, 0xc5d40260, 0xc0001010, 0xcd4000f8,
+ 0x6c9c8000, 0x45c8e000, 0x45c8e000, 0x59dc0004, 0xc1601260, 0xc5d40260, 0x9d000000, 0xc0001012,
+ 0xcd4000f8, 0x00000000, 0x00000000, 0xd95800f8, 0x6d586000, 0x4594c000, 0x59984c80, 0xd99800f9,
+ 0x5818000a, 0xc1800000, 0xc9800078, 0xc0005400, 0x6d5ca000, 0x401c0000, 0x40180000, 0xc94000f8,
+ 0x58000002, 0x00000000, 0xc9c000f8, 0xc0004930, 0xcd4000f8, 0xc0004932, 0xcdc000f8, 0x59980004,
+ 0xc1c20020, 0xb59c0018, 0x00000000, 0xc1800000, 0xdd9c00f9, 0x581c000a, 0xcd800078, 0x581c000c,
+ 0xc1800000, 0xc9800020, 0xc1c00002, 0xdd9400f8, 0x69d4e000, 0x5d980002, 0xcd800020, 0xc0004924,
+ 0xc98000f8, 0x00000000, 0x9d000000, 0x00000000, 0x719cc000, 0xcd8000f8, 0xc000492a, 0xc94000f8,
+ 0xc1c00002, 0x69d8e000, 0x7dc0c000, 0x7558a000, 0xcd4000f8, 0xc000492c, 0xc94000f8, 0xdd8000f9,
+ 0x58000032, 0x755ca000, 0x84000090, 0xc94000f9, 0xc98000f8, 0xdd8000f9, 0x5800000c, 0x00000000,
+ 0xcd4000f9, 0xcd8000f8, 0xc000492c, 0xc94000f8, 0xc000492a, 0xc98000f8, 0x715ca000, 0xc000492c,
+ 0xcd4000f8, 0x719cc000, 0xc000492a, 0xcd8000f8, 0x9d000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xc0004862, 0xc98000f8, 0x00000000, 0xc1c00200, 0x4194c000, 0x459ce000, 0x88000012, 0xc5d800f8,
+ 0xc0004862, 0xcd8000f8, 0xc0001406, 0xc98000f8, 0xc1c00002, 0x9d000000, 0xc5d80a00, 0xc5581048,
+ 0xcd8000f8, 0xc0004930, 0xc98000f8, 0xc0004932, 0xc9c000f8, 0xc140000e, 0xc5581c18, 0xdd9400f8,
+ 0xc0005600, 0x40140000, 0x5d405800, 0x88000012, 0x5c000200, 0xcd8000f8, 0x58000002, 0x5d405800,
+ 0x88000012, 0x5c000200, 0xcdc000f8, 0xdd5400f8, 0xc1c00000, 0x58140006, 0xc9c20078, 0xc1800000,
+ 0x58140000, 0xc98000d8, 0x6ddc2000, 0xc000491e, 0x41d8e000, 0xcdc000f8, 0xdd9800f8, 0xc1c00022,
+ 0xc5d80d70, 0xdd9400f9, 0xc5581c18, 0xc000491c, 0xcd8000f8, 0xdd5400f8, 0xc1c00000, 0x58140006,
+ 0xc9c20078, 0xc1800000, 0x58140004, 0xc9820078, 0x00000000, 0x59dc0002, 0x45d8c000, 0x84000010,
+ 0xc1c00000, 0x9d000000, 0x58140006, 0xc5d81078, 0xcd821078, 0xc0004860, 0xc94000f8, 0xc1820080,
+ 0xc1d00002, 0x58146b00, 0xd58000f8, 0x58000002, 0xd58000f9, 0x59540004, 0xb5580018, 0xc0004860,
+ 0xc1400000, 0xcd4000f8, 0xdd9800f9, 0x9d000000, 0xdd9400f8, 0xc0001404, 0xcdc10800, 0xc1c00000,
+ 0xc1800200, 0x5d980004, 0xdf5d0048, 0x459ca000, 0x8800fff2, 0xdd8000f9, 0x5800000c, 0x00000000,
+ 0xc94000f9, 0xc98000f8, 0xc1c00002, 0xc5d43f00, 0xc5d81e00, 0xc0004862, 0xc9c000f8, 0x00000000,
+ 0x00000000, 0x581c5600, 0x5dc05800, 0x88000012, 0x5c000200, 0xcd4000f8, 0x58000002, 0x5dc05800,
+ 0x88000012, 0x5c000200, 0xcd8000f8, 0xc0004862, 0xc9c000f8, 0x00000000, 0xc15004c0, 0xc5d40060,
+ 0xdd9c00f8, 0xc5d41c18, 0xc1c00000, 0xdd8000f9, 0x58000030, 0xc9c00078, 0xdd8000f9, 0x58000002,
+ 0xc98000f8, 0x6ddc2000, 0xc000491c, 0x41d8e000, 0xcd4000f9, 0xcdc000f8, 0xdd9400f9, 0xc1c00000,
+ 0x58140030, 0xc9c00078, 0xc1800000, 0x58140006, 0xc9820078, 0x00000000, 0x59dc0002, 0x45d8c000,
+ 0x84000010, 0xc1c00000, 0x9d000000, 0x58140030, 0xc5d80078, 0xcd800078, 0xc1c00000, 0xdf5c0038,
+ 0x5ddc0080, 0x8400ffea, 0x00000000, 0x9d000000, 0x00000000, 0x00000000, 0x00000000, 0xc160fffe,
+ 0xc0000a10, 0xc9440060, 0xc1a0fffe, 0x59981e08, 0xc000100c, 0xcd4000f8, 0xc000100e, 0xcd8000f8,
+ 0xc0004964, 0xc98000f8, 0x00000000, 0xc170000a, 0x7158a000, 0x6c988000, 0x4588c000, 0x4588c000,
+ 0x59980004, 0xc5940270, 0xc0001010, 0xcd4000f8, 0xc0004946, 0xc94000f8, 0x00000000, 0x00000000,
+ 0x6d58a000, 0x6d5c4000, 0x459cc000, 0x4594c000, 0xc000494a, 0xc94000f8, 0xc0004948, 0xc9c000f8,
+ 0x4194c000, 0xc1400012, 0xc55c1818, 0x9d000000, 0xc59c0268, 0xc0001012, 0xcdc000f8, 0xc1400000,
+ 0x58000012, 0xc9410038, 0xc0004950, 0xc9c000f8, 0xc55800f8, 0xc5940838, 0xc5581078, 0xd99400f8,
+ 0xc000493c, 0xc94000f8, 0xc0004954, 0xc98000f8, 0x59dc00a8, 0x45d4e000, 0x41d8e000, 0x5d5c0030,
+ 0x88000010, 0xc1c00030, 0xc1800000, 0xc5d84028, 0xc1400000, 0xc5d40008, 0x5dd40002, 0x84000072,
+ 0x5dd40004, 0x8400009a, 0x5dd40006, 0x840000c2, 0x5dd80026, 0x840000ea, 0xdd5400f8, 0xdd8000f9,
+ 0x58000008, 0x40180000, 0xcd4000f8, 0x59980002, 0x8000ffc0, 0xdd5400f8, 0xdd8000f9, 0x58000008,
+ 0x40180000, 0xcd4000b8, 0x59980002, 0x8000ff88, 0xdd5400f8, 0xdd8000f9, 0x58000008, 0x40180000,
+ 0xcd400078, 0x59980002, 0x8000ff50, 0xdd5400f8, 0xdd8000f9, 0x58000008, 0x40180000, 0xcd400038,
+ 0x59980002, 0x8000ff18, 0x00000000, 0x9d000000, 0x00000000, 0x00000000, 0x00000000, 0x58000012,
+ 0xc94000f8, 0xc0004954, 0xc9c000f8, 0xc0004950, 0xc9400078, 0xdd8000f9, 0x58000028, 0x5d9c0000,
+ 0x84000052, 0x5d9c0002, 0x84000052, 0x5d9c0004, 0x8400006a, 0xc55b0038, 0xc55c08b8, 0xcd800039,
+ 0xcdc108b8, 0x80000060, 0xcd4000f8, 0x80000050, 0xc55900b8, 0xc55c1838, 0xcd8000b9, 0xcdc31838,
+ 0x80000028, 0xc55a0078, 0xc55c1078, 0xcd800079, 0xcdc21078, 0x9d000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x59540002, 0x6994e018, 0x61c0c008, 0x4194a000, 0x5d940040, 0x88000012, 0xc59400f8,
+ 0x9d000000, 0xcd4000f8, 0x00000000, 0x00000000, 0x9d000000, 0x4158a000, 0xcd4000f8, 0x00000000,
+};
+
+static unsigned int firmware_binary_data[] = {
+};
+
+
+#endif // IFXMIPS_ATM_FW_AMAZON_SE_H
diff --git a/package/platform/lantiq/ltq-atm/src/ifxmips_atm_fw_ar9.h b/package/platform/lantiq/ltq-atm/src/ifxmips_atm_fw_ar9.h
new file mode 100644
index 0000000..5ee6d23
--- /dev/null
+++ b/package/platform/lantiq/ltq-atm/src/ifxmips_atm_fw_ar9.h
@@ -0,0 +1,439 @@
+#ifndef IFXMIPS_ATM_FW_AR9_H
+#define IFXMIPS_ATM_FW_AR9_H
+
+
+/******************************************************************************
+**
+** FILE NAME : ifxmips_atm_fw_ar9.h
+** PROJECT : UEIP
+** MODULES : ATM (ADSL)
+**
+** DATE : 22 OCT 2007
+** AUTHOR : Xu Liang
+** DESCRIPTION : ATM Driver (PP32 Firmware)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 22 OCT 2007 Xu Liang Initiate Version, v00.01
+*******************************************************************************/
+
+
+#define VER_IN_FIRMWARE 1
+
+#define ATM_FW_VER_MAJOR 0
+#define ATM_FW_VER_MINOR 16
+
+
+static unsigned int ar9_fw_bin[] = {
+ 0x800004b8, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8000ffe0, 0x00000000, 0x00000000, 0x00000000,
+ 0xc1000002, 0xd90c00f8, 0xc2000002, 0xda0800f9, 0x80004980, 0xc2000000, 0xda0800f9, 0x80003fe8,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x80003fa0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x80005178, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x80003ea0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xc0400000, 0xc0004840, 0xc88400f8, 0x80004640, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xc0400002, 0xc0004840, 0xc88400f8, 0x800045c0, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xc3c00004, 0xdbc800f9, 0xc10c0002, 0xd90c00f8, 0x8000fee0, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xc10e0002, 0xd90c00f8, 0xc0004808, 0xc84000f8, 0x800045f0, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xc3e1fffe, 0x597dfffe, 0x593dfe14, 0x900004d9, 0x00000000, 0x00000000, 0x00000000, 0x90cc0481,
+ 0x00000000, 0x00000000, 0x00000000, 0xc3c00000, 0xdbc800f9, 0xc1400008, 0xc1900000, 0x71588000,
+ 0x14100100, 0xc140000a, 0xc1900002, 0x71588000, 0x14100100, 0xc140000c, 0xc1900004, 0x71588000,
+ 0x14100100, 0xc1400004, 0xc1900006, 0x71588000, 0x14100100, 0xc1400006, 0xc1900008, 0x71588000,
+ 0x14100100, 0xc140000e, 0xc190000a, 0x71588000, 0x14100100, 0xc1400000, 0xc190000c, 0x71588000,
+ 0x14100100, 0xc1400002, 0xc190000e, 0x71588000, 0x14100100, 0xc0400000, 0xc11c0000, 0xc000082c,
+ 0xcd05ce00, 0xc11c0002, 0xc000082c, 0xcd05ce00, 0xc0400002, 0xc11c0000, 0xc000082c, 0xcd05ce00,
+ 0xc11c0002, 0xc000082c, 0xcd05ce00, 0xc0000824, 0x00000000, 0xcbc000f9, 0xcb8000f9, 0xcb4000f9,
+ 0xcb0000f8, 0xc0004878, 0x5bfc4000, 0xcfc000f9, 0x5bb84000, 0xcf8000f9, 0x5b744000, 0xcf4000f9,
+ 0x5b304000, 0xcf0000f8, 0xc0000a10, 0x00000000, 0xcbc000f9, 0xcb8000f8, 0xc0004874, 0x5bfc4000,
+ 0xcfc000f9, 0x5bb84000, 0xcf8000f8, 0xc30001fe, 0xc000140a, 0xcf0000f8, 0xc3000000, 0x7f018000,
+ 0xc000042e, 0xcf0000f8, 0xc000040e, 0xcf0000f8, 0xc3c1fffe, 0xc000490e, 0xcfc00078, 0xc000492c,
+ 0xcfc00078, 0xc0004924, 0xcfc00038, 0xc0004912, 0xcfc00038, 0xc0004966, 0xcfc00038, 0xc0004968,
+ 0xcfc00078, 0xc000496a, 0xcfc00078, 0xc3c1fffe, 0xc00049a0, 0xcfc000f8, 0xc3c00000, 0xc2800020,
+ 0xc3000000, 0x7f018000, 0x6ff88000, 0x6fd44000, 0x4395c000, 0x5bb84a00, 0x5838000a, 0xcf0000f8,
+ 0x5bfc0002, 0xb7e8ffc8, 0x00000000, 0xc3c00000, 0xc2800010, 0x6ff86000, 0x47bdc000, 0x5bb84c80,
+ 0xc3400000, 0x58380004, 0xcb420078, 0x00000000, 0x58380008, 0xcf400078, 0x5bfc0002, 0xb7e8ffb0,
+ 0x00000000, 0xc3c00000, 0xc2800020, 0xc348001e, 0xc3000000, 0x7f018000, 0x6ff8a000, 0x6fd44000,
+ 0x4795c000, 0x47bdc000, 0x5bb87000, 0x58380008, 0xcf408418, 0x5838000a, 0xcf0000f8, 0x5bfc0002,
+ 0xb7e8ffb0, 0x00000000, 0x00000000, 0xc3e0a242, 0x5bfc0020, 0xc0004002, 0xcfc000f8, 0x00000000,
+ 0xc121fffe, 0x5911fe14, 0x14100000, 0x80000530, 0x00000000, 0x80002130, 0x00000000, 0x8000ffe0,
+ 0xc0004958, 0xc84000f8, 0x00000000, 0xc3c00002, 0x787c2000, 0xcc4000f8, 0xc0004848, 0xcb8400f8,
+ 0xc000495c, 0xcac400f8, 0xc0004844, 0xc88400f8, 0x47ad0000, 0x8400ff82, 0xc000487c, 0xc80400f8,
+ 0x00000000, 0x00000000, 0x40080000, 0xca0000f8, 0xc0001624, 0xcb0400f8, 0xa63c007a, 0x00000000,
+ 0x00000000, 0xa71eff22, 0x00000000, 0xc0000824, 0xca8400f8, 0x6ca08000, 0x6ca42000, 0x46250000,
+ 0x42290000, 0xc35e0002, 0xc6340060, 0xc0001624, 0xcf440078, 0xc2000000, 0xc161fffe, 0x5955fffe,
+ 0x14140000, 0x00000000, 0xc0004844, 0xc88400f8, 0xc000082c, 0xca040038, 0x00000000, 0x00000000,
+ 0x58880002, 0xb6080018, 0x00000000, 0xc0800000, 0xc0004844, 0xcc840038, 0x5aec0002, 0xc000495c,
+ 0xcec400f8, 0x5e6c0006, 0x84000060, 0xc0004848, 0xcb8400f8, 0xc0000838, 0xc2500002, 0xce450800,
+ 0x5fb80002, 0xc0004848, 0xcf8400f8, 0x5eec0002, 0xc000495c, 0xcec400f8, 0x00000000, 0xc121fffe,
+ 0x5911fe14, 0x14100000, 0x8000fd98, 0xc000495a, 0xc84000f8, 0x00000000, 0xc3c00002, 0x787c2000,
+ 0xcc4000f8, 0xc0004960, 0xcac400f8, 0x00000000, 0x00000000, 0x5eec0000, 0x8400010a, 0x00000000,
+ 0xb6fc0050, 0xc0001600, 0xca0400f8, 0x00000000, 0x00000000, 0xa61e00d2, 0x6fe90000, 0xc0000a28,
+ 0xce850800, 0xc2c00000, 0xc2800004, 0xb6e800a0, 0xc0001604, 0xca8400f8, 0xc0004960, 0xcec400f8,
+ 0xa69efcc2, 0x00000000, 0x6fe90000, 0xc0000a28, 0xce850800, 0xc2c00002, 0xc0001600, 0xca0400f8,
+ 0x00000000, 0x00000000, 0xa61e002a, 0x6fe90000, 0xc0000a28, 0xce850800, 0xc2c00000, 0xc0001604,
+ 0xca8400f8, 0xc0004960, 0xcec400f8, 0xa69efc2a, 0xc2400000, 0xc0000a14, 0xca440028, 0x00000000,
+ 0x00000000, 0x466d2000, 0xa4400020, 0xc2800000, 0xdfeb0029, 0x80000010, 0xdfea0029, 0xb668fba2,
+ 0x00000000, 0xc00048a0, 0xcb0400f8, 0xc0000a10, 0xca8400f8, 0x6f208000, 0x6f242000, 0x46250000,
+ 0x42a10000, 0xc2400000, 0xc0000a14, 0xca440028, 0xc35e0002, 0xc6340060, 0xc0001604, 0xcf440078,
+ 0x5b300002, 0xb6700018, 0x5aec0002, 0xc3000000, 0xc00048a0, 0xcf0400f8, 0xc0004960, 0xcec400f8,
+ 0x8000fad8, 0xc0004918, 0xd28000f8, 0xc2000000, 0xdf600038, 0x5e600080, 0x84000272, 0x00000000,
+ 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000, 0xc000480a, 0xca0000f8, 0xc0004912, 0xca4000f8,
+ 0xc0004924, 0xca8000f8, 0xc0004966, 0xcac000f8, 0x00000000, 0xc121fffe, 0x5911fe14, 0x14100000,
+ 0x76250000, 0x76290000, 0x762d0000, 0x840001ca, 0xc0004918, 0xca4000f8, 0xc28001fe, 0x76290000,
+ 0x5a640002, 0x6a254010, 0x5ee80000, 0x8400001a, 0x6aa54000, 0x80000010, 0xc62800f8, 0x62818008,
+ 0xc0004918, 0xcf0000f8, 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000, 0xc0004966, 0xca4000f8,
+ 0xc2000002, 0x6a310000, 0x7e010000, 0x76612000, 0xce4000f8, 0x00000000, 0xc121fffe, 0x5911fe14,
+ 0x14100000, 0x6f346000, 0x4771a000, 0x5b744c80, 0xc2800000, 0x58340006, 0xca800078, 0xc2c00000,
+ 0x58340000, 0xcac000d8, 0xc2400000, 0x5834000a, 0xca420078, 0x6ea82000, 0x42e9e000, 0x6f2ca000,
+ 0x42e56000, 0x5aec2e00, 0xc3990040, 0xc7381c18, 0xc6f80060, 0x99005b78, 0xdb9800f8, 0xdbd800f9,
+ 0x00000000, 0xdea000f8, 0x46310000, 0x8400fd80, 0xc0004958, 0xc84000f8, 0x00000000, 0xc3c00002,
+ 0x787c2000, 0xcc4000f8, 0xc0004848, 0xcb8400f8, 0xc0004844, 0xc88400f8, 0x5fb80000, 0x8400f7f2,
+ 0xc0001a1c, 0xca0000f8, 0xc2400002, 0x6a452000, 0x76250000, 0x8400f7c2, 0xc000487c, 0xc80400f8,
+ 0x00000000, 0x00000000, 0x40080000, 0xca0000f8, 0xc42400f8, 0x00000000, 0xa63c17da, 0x00000000,
+ 0xc0004878, 0xc80400f8, 0x6c908000, 0x45088000, 0x45088000, 0x40100000, 0xca0000f8, 0xc42400f8,
+ 0x00000000, 0xc0004934, 0xce0000f8, 0xc2800002, 0xc4681c08, 0xc62821d0, 0xc2600010, 0x5a650060,
+ 0xc0004800, 0xcb4000f8, 0xc2200400, 0x5a200020, 0xc7601040, 0xc0001220, 0xce8000f8, 0xc0001200,
+ 0xce4000f8, 0xc0001202, 0xce0000f8, 0xc0001240, 0xcb4000f8, 0x00000000, 0x00000000, 0xa754ffe0,
+ 0xc2000000, 0xc7600040, 0xa7520042, 0x00000000, 0x00000000, 0x990062f0, 0xc0004822, 0xc94000f8,
+ 0xc1800002, 0x80001680, 0x582040a0, 0xc2000000, 0xca000018, 0xc2400000, 0xca414000, 0xc2800000,
+ 0xca812000, 0xc2c00000, 0xcac20018, 0xc0004938, 0xce0000f8, 0xc0004920, 0xce4000f8, 0xc0004916,
+ 0xce8000f8, 0xc0004922, 0xcec000f8, 0xa6400540, 0x00000000, 0xc0004938, 0xcbc000f8, 0x00000000,
+ 0xc3800000, 0x6ff48000, 0x6fd44000, 0x4355a000, 0x5b744a00, 0x58340000, 0xcb802010, 0x00000000,
+ 0xc2000000, 0x6fb46000, 0x4779a000, 0x5b744c80, 0x5834000c, 0xca000020, 0xc000491a, 0xcf8000f8,
+ 0x5e200000, 0x8400046a, 0xc2000000, 0xdf610048, 0x5e6001e8, 0x8800ffe8, 0xc2000002, 0xc2400466,
+ 0xc2a00000, 0x5aa80000, 0xc0001006, 0xce0000f8, 0xc0001008, 0xce4000f8, 0xc000100a, 0xce8000f8,
+ 0x990055b8, 0xc1a0fffe, 0xc0000824, 0xc9840060, 0xc0004934, 0xca4000f8, 0xc2000000, 0xc2800002,
+ 0x990055f8, 0xda9800f8, 0xc61400f8, 0xc65800f8, 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000,
+ 0x990056e0, 0xc000491a, 0xc94000f8, 0x00000000, 0x00000000, 0xc121fffe, 0x5911fe14, 0x14100000,
+ 0xc0004922, 0xca001118, 0xc3c00000, 0xc3800000, 0xc0004930, 0xce023118, 0xc0004932, 0xcbc000d8,
+ 0xc2800000, 0xc000491e, 0xcfc000f8, 0xc0004862, 0xca800060, 0xc3a0001a, 0x5bb94000, 0xc6b80060,
+ 0xc000491c, 0xcf8000f8, 0x99005950, 0xc000491c, 0xc1400000, 0xc9420048, 0x00000000, 0x00000000,
+ 0x00000000, 0xa8e2ffe8, 0xc2000000, 0xc1220002, 0xd90c00f8, 0xdf600038, 0x5e600080, 0x8400fff2,
+ 0xc000491c, 0xca0000f8, 0xc000491e, 0xca4000f8, 0x00000000, 0x00000000, 0x99005b78, 0xda1800f8,
+ 0xda5800f9, 0x00000000, 0xc2000000, 0xdf610048, 0x5e6001fe, 0x8800ffe8, 0xc0004916, 0xca8000f8,
+ 0xc2c00000, 0xdfec0048, 0xc2400000, 0x466d2000, 0x8400004a, 0x5ea80000, 0x8400003a, 0xc2600002,
+ 0x990062f0, 0xc000482e, 0xc94000f8, 0xc1800002, 0x80000030, 0xc2600000, 0x990062f0, 0xc000482c,
+ 0xc94000f8, 0xc1800002, 0xc2000068, 0xc6240078, 0xc0004930, 0xce400080, 0xc000491a, 0xc98000f8,
+ 0xc0004862, 0xc94000f8, 0x6d9c6000, 0x45d8e000, 0x59dc4c80, 0x990059d8, 0xd95800f8, 0xd99800f9,
+ 0xd9d400f8, 0x99005950, 0xc000491c, 0xc1400000, 0xc9420048, 0xc2000000, 0xdf600038, 0x5e600080,
+ 0x8400ffea, 0x00000000, 0xc000491c, 0xca0000f8, 0xc000491e, 0xca4000f8, 0x00000000, 0x00000000,
+ 0x99005b78, 0xda1800f8, 0xda5800f9, 0x00000000, 0x800010e8, 0x00000000, 0x990062f0, 0xc000482a,
+ 0xc94000f8, 0xc1800002, 0x800010b8, 0xc0004938, 0xcbc000f8, 0x00000000, 0x00000000, 0x6ff88000,
+ 0x6fd44000, 0x4395c000, 0x5bb84a00, 0x58380008, 0xca0000f8, 0x00000000, 0x00000000, 0xa6000382,
+ 0x00000000, 0xc0004938, 0xcbc000f8, 0xc3000000, 0x00000000, 0x6ff88000, 0x6fd44000, 0x4395c000,
+ 0x5bb84a00, 0x58380000, 0xcb002010, 0xc2000000, 0x58380008, 0xca020078, 0x5838000c, 0xcac000f8,
+ 0x5838000e, 0xca4000f8, 0xc000491a, 0xcf0000f8, 0xc0004930, 0xcec000f8, 0xc000493c, 0xce0000f8,
+ 0xc0004932, 0xce4000f8, 0x5e200000, 0x84000120, 0xc2800000, 0xa6fe00ba, 0x6f206000, 0x46310000,
+ 0x5a204c80, 0x5820000c, 0xca800020, 0x00000000, 0x00000000, 0x5ea80000, 0x840001f2, 0x00000000,
+ 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000, 0x990056e0, 0xc000491a, 0xc94000f8, 0x00000000,
+ 0x00000000, 0xc121fffe, 0x5911fe14, 0x14100000, 0xc0004930, 0xcac000f8, 0xc0004932, 0xca4000f8,
+ 0xc7ec1118, 0xc0004930, 0xcec000f8, 0x5838000c, 0xcec000f8, 0x58000002, 0xce4000f8, 0xc0004934,
+ 0xca0000f8, 0xc2400002, 0x6e642000, 0x6e642000, 0x76612000, 0x8400002a, 0xc2400002, 0x6e684000,
+ 0x58380008, 0xce804200, 0xa6000020, 0x6e682000, 0x58380008, 0xce802100, 0xc2400002, 0x6e642000,
+ 0x76612000, 0x840000ea, 0x58380008, 0xca0000f8, 0xc2800000, 0xc2400000, 0xa60200c0, 0xdba800f8,
+ 0x6f386000, 0x47b1c000, 0x5bb84c80, 0x58380004, 0xca400078, 0x58380002, 0xca800078, 0x00000000,
+ 0xdeb800f8, 0x46a54000, 0x88000060, 0x00000000, 0xc0004824, 0xca0000f8, 0xc2400002, 0x6e640000,
+ 0x5a200002, 0xce0000f8, 0x58380008, 0xce400000, 0x80000018, 0x00000000, 0x80000048, 0xc0004934,
+ 0xca0000f8, 0x00000000, 0x00000000, 0xa6020c6a, 0x00000000, 0x00000000, 0x80000c98, 0xc2800000,
+ 0xc2000200, 0xc240001a, 0xdf690048, 0x46294000, 0x46a54000, 0x8800ffd2, 0xc2000006, 0xc2600982,
+ 0x5a643b6e, 0x5838000a, 0xca8000f8, 0xc0001006, 0xce0000f8, 0xc0001008, 0xce4000f8, 0xc000100a,
+ 0xce8000f8, 0x990055b8, 0xc1a0fffe, 0xc0000824, 0xc9840060, 0xc2000000, 0xc0004930, 0xca02e008,
+ 0x58380026, 0xca4000f8, 0x00000000, 0xc2800000, 0x990055f8, 0xda9800f8, 0xc61400f8, 0xc65800f8,
+ 0xc0004934, 0xca0000f8, 0x00000000, 0x00000000, 0xa6020022, 0x00000000, 0x00000000, 0x80000318,
+ 0xc0004938, 0xcbc000f8, 0xc0004878, 0xc80400f8, 0x6c908000, 0x45088000, 0x45088000, 0x40100000,
+ 0xca0000f8, 0xc42400f8, 0x00000000, 0x58240018, 0xca0000f8, 0x6ff88000, 0x6fd44000, 0x4395c000,
+ 0x5bb84a00, 0xc3000000, 0xc3400002, 0xc2c00000, 0xc62c0078, 0xc6270038, 0xc0004940, 0xce400038,
+ 0xc6260038, 0xc0004942, 0xce400038, 0xc000493c, 0xca0000f8, 0x5eec0000, 0x8400018a, 0x5a6c0010,
+ 0x46254000, 0x88000190, 0x5a600052, 0x46e54000, 0x88000178, 0x58380006, 0xca8000f8, 0xc0004940,
+ 0xca0000f8, 0xc2400000, 0xc6a70038, 0x7e412000, 0x76612000, 0xc2000000, 0xc6a10038, 0x46250000,
+ 0x84000138, 0xc0004942, 0xca0000f8, 0xc2400000, 0xc6a60038, 0x7e412000, 0x76612000, 0xc2000000,
+ 0xc6a00038, 0x58380002, 0xca8000f8, 0x46250000, 0x840000e8, 0xc2400000, 0xc6a60078, 0x466d0000,
+ 0x880000da, 0xc2400000, 0xc6a40078, 0x58380008, 0xca8000f8, 0x46e50000, 0x880000ba, 0x00000000,
+ 0xa6820018, 0x00000000, 0xc7700b00, 0xa6840098, 0x00000000, 0xc7700a00, 0x80000080, 0xc7700200,
+ 0xc000493c, 0xcac000f8, 0x80000060, 0xc7700300, 0xc000493c, 0xcac000f8, 0x80000040, 0xc7700900,
+ 0x80000030, 0xc7700800, 0x80000020, 0xc7700700, 0x80000010, 0xc7700500, 0xc0004944, 0xcf0000f8,
+ 0xc000493e, 0xcec000f8, 0xc0004938, 0xca4000f8, 0xc000493c, 0xcb8000f8, 0xc000493e, 0xcb4000f8,
+ 0xc3000000, 0x6e608000, 0x6e544000, 0x42150000, 0x5a204a00, 0x5aa00008, 0x58200004, 0xcb000078,
+ 0xc0004934, 0xca0000f8, 0xc2400000, 0xc0004930, 0xca42e008, 0xc3c00018, 0xa6020098, 0x00000000,
+ 0x43656000, 0x47ad0000, 0x88000050, 0x46f96000, 0x6ee04010, 0x5be00004, 0xc2000000, 0xc6e00008,
+ 0x5e200000, 0x84000042, 0x5bfc0002, 0x80000030, 0xc3c00004, 0x5a2c0008, 0x47a10000, 0x88000012,
+ 0x5fb80008, 0x6fe04000, 0x42390000, 0x47212000, 0x88000068, 0xc2400000, 0xc0004930, 0xca42e008,
+ 0xc2060002, 0xc68000f8, 0xce006300, 0x6fe04000, 0x4721c000, 0x5f700010, 0x4765a000, 0xc2000000,
+ 0xc6340008, 0xc25a000a, 0xc000491a, 0xca401c18, 0xc2800000, 0xc0004932, 0xca8000d8, 0xc0004862,
+ 0xca400060, 0x6fa04010, 0x42290000, 0xc000491e, 0xce0000f8, 0xc7e41048, 0xc000491c, 0xce4000f8,
+ 0x6fe04000, 0x43a1c000, 0xc000493c, 0xcf8000f8, 0xc000493e, 0xcf4000f8, 0xc000493a, 0xcfc000f8,
+ 0x80000008, 0x00000000, 0x00000000, 0x00000000, 0xc2000000, 0xdce000f8, 0xa622ffd8, 0xc1220002,
+ 0xd90c00f8, 0xc0004938, 0xcbc000f8, 0xc0004944, 0xcb4000f8, 0xc0004862, 0xcb0000f8, 0xc0004934,
+ 0xca0000f8, 0x6ff88000, 0x6fd44000, 0x4395c000, 0x5bb84a00, 0xa6020268, 0xc2400000, 0x58380008,
+ 0xca406000, 0xdfe800f8, 0xc2218e08, 0x5a21baf6, 0x46a14000, 0x84000022, 0xc2080002, 0x7361a000,
+ 0x80000058, 0x5e640000, 0x84000022, 0xc20c0002, 0x7361a000, 0x80000030, 0xc2000000, 0xc760e710,
+ 0xc7604218, 0x5e200000, 0x84000272, 0xc2200002, 0xc0004930, 0xce021000, 0x990062f0, 0xc0004828,
+ 0xc94000f8, 0xc1800002, 0x58380000, 0xca0000f8, 0x00000000, 0x00000000, 0xa6000132, 0xc0004940,
+ 0xca8000f8, 0xc0004942, 0xca4000f8, 0xc7600078, 0xc6a01838, 0xc6601038, 0xc000493a, 0xca4000f8,
+ 0xc0004934, 0xca8000f8, 0xc0007800, 0x40300000, 0x40240000, 0x5c000004, 0x5ec07a00, 0x88000012,
+ 0x5c000200, 0xce0000f8, 0x58000002, 0x5ec07a00, 0x88000012, 0x5c000200, 0xce8000f8, 0xc000493e,
+ 0xca0000f8, 0xc2400000, 0x5838000c, 0xce4000f8, 0x990062f0, 0xc0004830, 0xc94000f8, 0xc61800f8,
+ 0xc0004930, 0xc6100078, 0xcd000078, 0x800000a8, 0xc2400002, 0x58380008, 0xce400000, 0xc0004944,
+ 0xcf4000f8, 0x80000278, 0xc000493c, 0xca4000f8, 0xdfe800f8, 0x5a300018, 0xc0007800, 0x40200000,
+ 0xca0000f8, 0x58380008, 0xc6501078, 0xcd021078, 0x5838000a, 0xce8000f8, 0x58380026, 0xce0000f8,
+ 0xc0004944, 0xcf4000f8, 0x99005950, 0xc000491c, 0xc1400000, 0xc9420048, 0x80000038, 0x00000000,
+ 0x990062f0, 0xc0004826, 0xc94000f8, 0xc1800002, 0x8000fdd8, 0xc2000000, 0xc2400080, 0xdf600038,
+ 0xb624ffea, 0xc000491c, 0xca4000f8, 0xc000491e, 0xca8000f8, 0x99005b78, 0xda5800f8, 0xda9800f9,
+ 0x00000000, 0xc0004934, 0xca0000f8, 0x00000000, 0xc2800000, 0xa6020160, 0xc2400004, 0xc2000200,
+ 0xdf690048, 0x46294000, 0x46a54000, 0x8800ffda, 0x00000000, 0xc000491a, 0xc98000f8, 0xc0004862,
+ 0xc94000f8, 0x6d9c6000, 0x45d8e000, 0x59dc4c80, 0x990059d8, 0xd95800f8, 0xd99800f9, 0xd9d400f8,
+ 0x99005950, 0xc000491c, 0xc1400000, 0xc9420048, 0xc2000000, 0xc2400080, 0xdf600038, 0xb624ffea,
+ 0xc000491c, 0xca4000f8, 0xc000491e, 0xca8000f8, 0x99005b78, 0xda5800f8, 0xda9800f9, 0x00000000,
+ 0x58380008, 0xca4000f8, 0xc2000000, 0xce000018, 0xc2a1fffe, 0x5aa9fffe, 0xce021078, 0x5838000a,
+ 0xce8000f8, 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000, 0xc0000838, 0xc2500002, 0xce450800,
+ 0xc0004848, 0xcb8400f8, 0xc2000000, 0xc000082c, 0xca040028, 0x5fb80002, 0xc0004848, 0xcf8400f8,
+ 0x58880002, 0xb6080018, 0x00000000, 0xc0800000, 0xc0004844, 0xcc8400f8, 0x00000000, 0xc121fffe,
+ 0x5911fe14, 0x14100000, 0x8000ded8, 0xc2000000, 0xdf600038, 0x5e200080, 0x8400026a, 0x00000000,
+ 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000, 0xc000480c, 0xca0000f8, 0xc0004910, 0xca4000f8,
+ 0xc000492c, 0xca8000f8, 0xc0004968, 0xcac000f8, 0x00000000, 0xc121fffe, 0x5911fe14, 0x14100000,
+ 0x76250000, 0x76290000, 0x76e16000, 0x840001c2, 0xc0004926, 0xca4000f8, 0xc201fffe, 0x76e16000,
+ 0x5a640002, 0x6ae50010, 0x5f200000, 0x8400001a, 0x6a250000, 0x80000010, 0xc6e000f8, 0x62014008,
+ 0xc0004926, 0xce8000f8, 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000, 0xc0004968, 0xca4000f8,
+ 0xc2000002, 0x6a290000, 0x7e010000, 0x76612000, 0xce4000f8, 0x00000000, 0xc121fffe, 0x5911fe14,
+ 0x14100000, 0x6eb4a000, 0x6e944000, 0x4755a000, 0x4769a000, 0x5b747000, 0x58340002, 0xc2000000,
+ 0xca0000d8, 0x5834002e, 0xc2400000, 0xca400078, 0x6eb0a000, 0x6ebc4000, 0x473d8000, 0x47298000,
+ 0x5b30302e, 0x5b300004, 0x6e642000, 0x4225e000, 0xc39a8024, 0xc7380060, 0xc6b81c18, 0x99005b78,
+ 0xdb9800f8, 0xdbd800f9, 0x00000000, 0xc2000000, 0xdf600038, 0x5e200080, 0x84000352, 0x00000000,
+ 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000, 0xc000490e, 0xca0000f8, 0xc00049a0, 0xca8000f8,
+ 0xc000492a, 0xca4000f8, 0xc000496a, 0xcb0000f8, 0xc0004956, 0xcac000f8, 0x00000000, 0xc121fffe,
+ 0x5911fe14, 0x14100000, 0x77218000, 0x77258000, 0x77298000, 0x8400029a, 0xc201fffe, 0x77218000,
+ 0x5aec0002, 0x6b2d0010, 0x5ea00000, 0x8400001a, 0x6a2d0000, 0x80000010, 0xc72000f8, 0x62016008,
+ 0xc0004956, 0xcec000f8, 0x6ef4a000, 0x6ed44000, 0x4755a000, 0x476da000, 0x5b747000, 0x58340000,
+ 0xc9c000f8, 0xc00049a0, 0xca0000f8, 0xc3000000, 0xc5f04018, 0xc2400000, 0xc5e50038, 0x7e412000,
+ 0x76250000, 0xce0000f8, 0xc0004980, 0x40300000, 0xcec000f8, 0xc161fffe, 0x5955fffe, 0x14140000,
+ 0x00000000, 0xc000496a, 0xca4000f8, 0xc2000002, 0x6a2d0000, 0x7e010000, 0x76612000, 0xce4000f8,
+ 0x00000000, 0xc121fffe, 0x5911fe14, 0x14100000, 0x6ef4a000, 0x6ed44000, 0x4755a000, 0x476da000,
+ 0x5b747000, 0x5834000e, 0xc2000000, 0xca0000d8, 0x58340008, 0xc2400000, 0xca420078, 0x5834000c,
+ 0xc2800000, 0xca832010, 0x6e644010, 0x42250000, 0x4229e000, 0xc39a8008, 0x58340008, 0xcb809018,
+ 0x58340008, 0xc2800000, 0xca810010, 0x6ee0a000, 0x6ee44000, 0x46250000, 0x462d0000, 0x5a200008,
+ 0x5a203008, 0x42290000, 0xc6380060, 0xc6f81c18, 0x99005b78, 0xdb9800f8, 0xdbd800f9, 0x00000000,
+ 0xc000495a, 0xc84000f8, 0x00000000, 0xc3c00002, 0x787c2000, 0xcc4000f8, 0xc0001a1c, 0xca0000f8,
+ 0xc2400008, 0x6a452000, 0x76250000, 0x84000ec2, 0xc0000a28, 0xc3800000, 0xcb840028, 0xc0000a14,
+ 0xc3400000, 0xcb440028, 0xc0004880, 0xcb0400f8, 0xb7b40072, 0x58041802, 0xcac000f8, 0xa7000078,
+ 0x00000000, 0x00000000, 0xa6c8d808, 0xc1000000, 0xc6d00018, 0xc0004980, 0x40100000, 0xca8000f8,
+ 0x80000070, 0x00000000, 0x00000000, 0x00000000, 0x8000d7b8, 0x00000000, 0xc2800000, 0xc7282018,
+ 0xc000490e, 0xca4000f8, 0x6be9e000, 0x00000000, 0x767d2000, 0x8400d770, 0x6ea0a000, 0x6e944000,
+ 0x46150000, 0x46290000, 0x5a207000, 0x5820000c, 0xca0000f8, 0xc0004946, 0xce8000f8, 0xa62203a8,
+ 0x00000000, 0xc2200060, 0xc0004948, 0xce000008, 0xce021038, 0xc240000a, 0xc000494a, 0xce4000f8,
+ 0xc2b60002, 0xc0004964, 0xce837b00, 0x99005e48, 0xc00048a0, 0xc88400f8, 0x00000000, 0xc0004946,
+ 0xcbc000f8, 0x00000000, 0x00000000, 0x6ff8a000, 0x6fd44000, 0x4795c000, 0x47bdc000, 0x5bb87000,
+ 0x99005c08, 0xdbd800f8, 0xdb9800f9, 0x00000000, 0x99005950, 0xc000491c, 0xc1400000, 0xc9420048,
+ 0xc000491c, 0x99005e00, 0xc94000f9, 0xc98000f8, 0x00000000, 0x99005b78, 0xd95800f8, 0xd99800f9,
+ 0x00000000, 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000, 0x99005840, 0xdbd800f8, 0xdb9800f9,
+ 0xc7d800f8, 0x00000000, 0xc121fffe, 0x5911fe14, 0x14100000, 0x6ff8a000, 0x6fd44000, 0x4795c000,
+ 0x47bdc000, 0x5bb87000, 0x58380010, 0xca0000f8, 0xc0004874, 0xc80400f8, 0x6c908000, 0x45088000,
+ 0x45088000, 0x40100000, 0xca4000f8, 0xc43400f8, 0x00000000, 0xc74000f8, 0xce0000f8, 0xc161fffe,
+ 0x5955fffe, 0x14140000, 0x00000000, 0xc000490e, 0xca4000f8, 0xc2800002, 0x6abd4000, 0x72692000,
+ 0xce4000f8, 0x00000000, 0xc121fffe, 0x5911fe14, 0x14100000, 0x990062f0, 0xc0004836, 0xc94000f8,
+ 0xc1800002, 0x00000000, 0x00000000, 0x00000000, 0xa8e2ffe8, 0x00000000, 0x58380000, 0xc90000f8,
+ 0xc00049a0, 0xca0000f8, 0xc2800000, 0xc5290038, 0x72290000, 0xce0000f8, 0xc1220002, 0xd90c00f8,
+ 0xc2000000, 0xc0000a14, 0xca040028, 0xc0000a28, 0xc2500002, 0xce450800, 0x58880002, 0xb6080018,
+ 0xc00048a0, 0xc0800000, 0xcc8400f8, 0x8000d380, 0xc0004946, 0xcbc000f8, 0xc161fffe, 0x5955fffe,
+ 0x14140000, 0x00000000, 0xc000490e, 0xca4000f8, 0xc2800002, 0x6abd4000, 0x72692000, 0xce4000f8,
+ 0x00000000, 0xc121fffe, 0x5911fe14, 0x14100000, 0x6ff8a000, 0x6fd44000, 0x4795c000, 0x47bdc000,
+ 0x5bb87000, 0x58380008, 0xca0000f8, 0x5838000c, 0xca4000f8, 0xc3400000, 0xc6340000, 0xc000494e,
+ 0xcf4000f8, 0xc2800000, 0xc62a0078, 0xc3000000, 0xc6308018, 0x6f304000, 0x43298000, 0xc000493c,
+ 0xcf0000f8, 0xc2c00000, 0xc66c0078, 0xc0004950, 0xcec000f8, 0xc2800000, 0xc66ae020, 0xc0004954,
+ 0xce8000f8, 0x5f740000, 0x840001a0, 0x5e300028, 0x46e12000, 0x8400016a, 0x46e12000, 0x88000132,
+ 0x5e300018, 0x46e12000, 0x8800002a, 0x46e12000, 0x84000042, 0x00000000, 0x800000c0, 0x00000000,
+ 0x99005f88, 0xdbd800f8, 0xdb9800f9, 0xc78000f8, 0xc3400002, 0xc000494e, 0xcf4000f8, 0xc161fffe,
+ 0x5955fffe, 0x14140000, 0x00000000, 0xc000490e, 0xca4000f8, 0xc2800002, 0x6abd4000, 0x7e814000,
+ 0x76692000, 0xce4000f8, 0x00000000, 0xc121fffe, 0x5911fe14, 0x14100000, 0xc2200060, 0xc0004948,
+ 0xce021038, 0xc2000000, 0xc000494c, 0xce0000f8, 0x80000080, 0x00000000, 0x99005f88, 0xdbd800f8,
+ 0xdb9800f9, 0xc78000f8, 0x99006188, 0xdbd800f8, 0xdb9800f9, 0xc78000f8, 0xc2200058, 0xc0004948,
+ 0xce021038, 0xc2000002, 0xc000494c, 0xce0000f8, 0xc2000006, 0xc0001006, 0xce0000f8, 0x5838000a,
+ 0xca4000f8, 0xc2200982, 0x5a203b6e, 0xc0001008, 0xce0000f8, 0xc000100a, 0xce4000f8, 0xc0004954,
+ 0xca8000f8, 0xc200000c, 0xc000494a, 0xce0000f8, 0xc0004948, 0xce800008, 0xc2b60000, 0xc0004964,
+ 0xce8000f8, 0x99005e48, 0xc00048a0, 0xc88400f8, 0x00000000, 0xc0004946, 0xcbc000f8, 0xc000494c,
+ 0xca0000f8, 0x6ff8a000, 0x6fd44000, 0x4795c000, 0x47bdc000, 0x5bb87000, 0x5e200000, 0x840000fa,
+ 0x00000000, 0x99005c08, 0xdbd800f8, 0xdb9800f9, 0x00000000, 0x99005950, 0xc000491c, 0xc1400000,
+ 0xc9420048, 0xc000491c, 0x99005e00, 0xc94000f9, 0xc98000f8, 0x00000000, 0x99005b78, 0xd95800f8,
+ 0xd99800f9, 0x00000000, 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000, 0x99005840, 0xdbd800f8,
+ 0xdb9800f9, 0xc7d800f8, 0x00000000, 0xc121fffe, 0x5911fe14, 0x14100000, 0xc000493c, 0xca8000f8,
+ 0xc000494e, 0xcac000f8, 0xc3000018, 0xc3400006, 0x5e200000, 0x8400002a, 0xc2800000, 0xc2c00000,
+ 0xc300001e, 0xc3400000, 0xc6ac1078, 0xc72c0418, 0xc76c0810, 0x58380010, 0xca8000f8, 0x58380008,
+ 0xcec000f8, 0xc6280100, 0xc0004874, 0xc80400f8, 0x6c908000, 0x45088000, 0x45088000, 0x40100000,
+ 0xcb0000f8, 0xc43400f8, 0x00000000, 0xc74000f8, 0xce8000f8, 0xc0004952, 0xce8000f8, 0x00000000,
+ 0x00000000, 0x00000000, 0xa8e2ffe8, 0x00000000, 0xc000494c, 0xca0000f8, 0xc0004950, 0xcac000f8,
+ 0x5e200000, 0x8400006a, 0xdfe800f8, 0x7e814000, 0x5834001a, 0xce8000f8, 0x990062f0, 0xc0004834,
+ 0xc94000f8, 0xc1800002, 0x990062f0, 0xc0004838, 0xc94000f8, 0xc6d800f8, 0xc1220002, 0xd90c00f8,
+ 0x5e200000, 0x84000040, 0x5838002c, 0xcb0000f8, 0xdfe800f8, 0x00000000, 0x58380014, 0xcf0000f8,
+ 0x80000058, 0xc2a1fffe, 0x5aa9fffe, 0x58380000, 0xc90000f8, 0xc00049a0, 0xcb0000f8, 0xc2c00000,
+ 0xc52d0038, 0x732d8000, 0xcf0000f8, 0x5838000a, 0xce8000f8, 0xc3000000, 0xc0000a14, 0xcb040028,
+ 0xc2d00002, 0xc0000a28, 0xcec50800, 0xc000494e, 0xca8000f8, 0x58880002, 0xb4b00018, 0xc00048a0,
+ 0xc0800000, 0xcc8400f8, 0x5ea80000, 0x8400017a, 0x5e200000, 0x84000168, 0xc000493c, 0xca8000f8,
+ 0x00000000, 0x00000000, 0x5aa80060, 0xce8000f8, 0x99005f88, 0xdbd800f8, 0xdb9800f9, 0xc78000f8,
+ 0x99006188, 0xdbd800f8, 0xdb9800f9, 0xc78000f8, 0x58380000, 0xcac000f8, 0x00000000, 0xc2000000,
+ 0xc6e04018, 0xc0004952, 0xcac000f8, 0x58380000, 0xca8000f8, 0xc30c0002, 0xc6300018, 0xa6800098,
+ 0x00000000, 0x00000000, 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000, 0xc0001800, 0xca0000f8,
+ 0x00000000, 0x00000000, 0xa60cffea, 0xc6f00500, 0xc6b0c400, 0xcf0000f8, 0x00000000, 0xc121fffe,
+ 0x5911fe14, 0x14100000, 0x8000c9c8, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8000c960,
+ 0xdcbc00f9, 0x5ffc0000, 0x84000052, 0xc3800002, 0xdb8800f9, 0x5ffc0004, 0x8400c292, 0xc3800000,
+ 0xdb8800f9, 0xc3ce0002, 0xc0000800, 0xcfc0e700, 0xc3e1fffe, 0x597dfffe, 0x593dfe14, 0x94000001,
+ 0x00000000, 0x00000000, 0x00000000, 0xc000487c, 0xc80400f8, 0x00000000, 0x00000000, 0x40080000,
+ 0xcbc000f8, 0xc43800f8, 0x00000000, 0xc000480e, 0xca0000f8, 0xc0004858, 0xcb4400f8, 0x00000000,
+ 0x00000000, 0x47610000, 0x880000b0, 0x00000000, 0xa7c00048, 0xc0004854, 0xc1000002, 0xcd0400f8,
+ 0xc11c0000, 0xc000082c, 0xcd05ce00, 0x800000d8, 0x00000000, 0xa7d20138, 0x00000000, 0xc7e14040,
+ 0xc2400000, 0xc6246028, 0xc200006a, 0x46250000, 0xc6240030, 0xc0000810, 0xce440030, 0x8000ff70,
+ 0xc2000000, 0xc0000808, 0xca040010, 0xc11c0000, 0xc000082c, 0xcd05ce00, 0x5a200002, 0x5e600010,
+ 0x84000010, 0xc2000000, 0xc0000808, 0xce040010, 0xc3400000, 0x80000028, 0xc1200002, 0xc0000818,
+ 0xcd061000, 0x5b740002, 0xc0004858, 0xcf4400f8, 0x99005590, 0xc0004848, 0xc94400f8, 0xc1800000,
+ 0xc11c0002, 0xc000082c, 0xcd05ce00, 0x80000600, 0x5b740002, 0xc0004858, 0xcf4400f8, 0xc78000f8,
+ 0xc13c0002, 0xcd03de00, 0xc0004848, 0xc94400f8, 0xc1800000, 0xc000082c, 0xc9840028, 0x59540002,
+ 0xc0004848, 0xcd4400f8, 0x58880002, 0xb4980580, 0x00000000, 0xc0800000, 0x80000568, 0xc000487c,
+ 0xc80400f8, 0x00000000, 0x00000000, 0x40080000, 0xcbc000f8, 0xc42800f8, 0x00000000, 0xa7c00130,
+ 0xc000484c, 0xca0400f8, 0xc2400000, 0xc0001aec, 0xca440018, 0x5a200002, 0xc000484c, 0xce0400f8,
+ 0xb624008a, 0xc68000f8, 0xc13c0002, 0xcd03de00, 0xc0004848, 0xc94400f8, 0xc1800000, 0xc000082c,
+ 0xc9840028, 0x59540002, 0xc0004848, 0xcd4400f8, 0x58880002, 0xb4980470, 0x00000000, 0xc0800000,
+ 0x80000458, 0xc0004854, 0xc1000004, 0xcd0400f8, 0xc0000820, 0xc2000002, 0xce0400f8, 0xc2000000,
+ 0xc000484c, 0xce0400f8, 0xc0004858, 0xce0400f8, 0x8000ff28, 0xc0004854, 0xc1000000, 0xcd0400f8,
+ 0xc11c0000, 0xc000082c, 0xcd05ce00, 0x99005590, 0xc0004848, 0xc94400f8, 0xc1800000, 0xc1200000,
+ 0xc0000818, 0xcd061000, 0xc11c0002, 0xc000082c, 0xcd05ce00, 0xc2000000, 0xc000484c, 0xce0400f8,
+ 0x80000358, 0xc0001ac0, 0xcb8400f8, 0xc000487c, 0xc80400f8, 0x00000000, 0x00000000, 0x40080000,
+ 0xcbc000f8, 0xc42800f8, 0x00000000, 0x00000000, 0xc68000f8, 0xc13c0000, 0xcd03de00, 0xa780024a,
+ 0x00000000, 0x00000000, 0xa7c0020a, 0x00000000, 0xc0001b00, 0xc2060006, 0xce046308, 0xa7e801c2,
+ 0x00000000, 0xc0004850, 0xca0400f8, 0xc2400000, 0xc0001aec, 0xca448018, 0x5a200002, 0xc0004850,
+ 0xce0400f8, 0xb62400aa, 0x00000000, 0xc68000f8, 0xc13c0002, 0xcd03de00, 0xc0001acc, 0xc2000002,
+ 0xce040000, 0xc0004848, 0xc94400f8, 0xc1800000, 0xc000082c, 0xc9840028, 0x59540002, 0xc0004848,
+ 0xcd4400f8, 0x58880002, 0xb49801c8, 0x00000000, 0xc0800000, 0x800001b0, 0xc0004854, 0xc1000000,
+ 0xcd0400f8, 0xc11c0000, 0xc000082c, 0xcd05ce00, 0x99005590, 0xc0004848, 0xc94400f8, 0xc1800000,
+ 0xc2000000, 0xc0000820, 0xce0400f8, 0xc1200000, 0xc0000818, 0xcd061000, 0xc11c0002, 0xc000082c,
+ 0xcd05ce00, 0xc0004850, 0xce0400f8, 0xc2000002, 0xc0001acc, 0xce040008, 0x800000e8, 0xc2000002,
+ 0xc0004850, 0xce0400f8, 0x8000fe88, 0xc2000000, 0xc0004850, 0xce0400f8, 0xa7e60032, 0x00000000,
+ 0xc2000002, 0xc0001b00, 0xce040000, 0x8000fe70, 0x00000000, 0xa7860052, 0x00000000, 0xc68000f8,
+ 0xc13c0002, 0xcd03de00, 0xc2020002, 0xc7e2a540, 0xc0001b00, 0xce0400f8, 0x8000fe18, 0xc2040002,
+ 0xc0001b00, 0xce044200, 0x8000fdf8, 0xc2c80002, 0x6ac56000, 0xdacc00f8, 0xc0004854, 0xcb4400f8,
+ 0xc0004848, 0xcb8400f8, 0xc0000838, 0xc3c00000, 0xcbc40028, 0x5ef40004, 0x84000022, 0xc3000000,
+ 0xc0001acc, 0xcf042100, 0x47f98000, 0x8400002a, 0x47f98000, 0x88000030, 0xc1006e8c, 0x8000b6c8,
+ 0xc0004840, 0xcc8400f8, 0x8000f6b0, 0xc0001ac0, 0xcac400f8, 0xc0004854, 0xcb4400f8, 0xa6c0fbd2,
+ 0x00000000, 0x5ef40000, 0x8400f70a, 0x5ef40002, 0x8400f99a, 0x5ef40004, 0x8400fb9a, 0xc1006ce8,
+ 0x8000b640, 0x00000000, 0xc0800000, 0xdf4b0038, 0xc0004900, 0xcb8000f8, 0xc2000000, 0xc000490a,
+ 0xa78000d0, 0xcbc000f8, 0xc1000000, 0xd90000f9, 0xc1000002, 0xd90c00f8, 0x6ff46000, 0x477da000,
+ 0x5b744c80, 0xc2400000, 0x58340004, 0xca400078, 0xc0004900, 0xce000000, 0x5a640002, 0x58340004,
+ 0xc6500078, 0xcd000078, 0xc0004914, 0xca4000f8, 0xc2000002, 0x6a3d0000, 0x72612000, 0xce4000f8,
+ 0xc0000408, 0xce0000f8, 0xa78200d8, 0xc0004908, 0xcbc000f8, 0xc1000000, 0xd90000f9, 0xc1000002,
+ 0xd90c00f8, 0x6ff4a000, 0x6fd44000, 0x4755a000, 0x477da000, 0x5b747000, 0xc2800000, 0x58340006,
+ 0xca800078, 0xc2000000, 0xc0004900, 0xce002100, 0x5ea80002, 0x58340006, 0xc6900078, 0xcd000078,
+ 0x5a7c0020, 0xc2000002, 0x6a250000, 0xc0000408, 0xce0000f8, 0xdca800f9, 0x5ea80000, 0x8400b4b0,
+ 0x00000000, 0xa4800230, 0x00000000, 0xc3c00000, 0xc000140e, 0xcbc00018, 0xc3400000, 0xc2400000,
+ 0x6ff86000, 0x47bdc000, 0x5bb84c80, 0x58380008, 0xcb400078, 0x58380006, 0xca400078, 0x5f740002,
+ 0x58380008, 0xc7500078, 0xcd000078, 0xc2000000, 0x58380004, 0xca020078, 0xc3000000, 0x5838000c,
+ 0xcb000020, 0x5a640002, 0x46610000, 0x84000010, 0xc2400000, 0x58380006, 0xc6500078, 0xcd000078,
+ 0xc2000000, 0x5838000a, 0xca020078, 0x5b300002, 0x5838000c, 0xc7100020, 0xcd000020, 0xc2420020,
+ 0x5a200004, 0x46252000, 0x84000010, 0xc2000000, 0x5838000a, 0xc6101078, 0xcd021078, 0xc0004966,
+ 0xca4000f8, 0xc2000002, 0x6a3d0000, 0x72612000, 0xce4000f8, 0x5f740000, 0x84000040, 0xc0004912,
+ 0xca0000f8, 0xc2c00002, 0x6afd6000, 0x7ec16000, 0x762d0000, 0xce0000f8, 0x5f300020, 0x84000040,
+ 0xc0004924, 0xca0000f8, 0xc2c00002, 0x6afd6000, 0x7ec16000, 0x762d0000, 0xce0000f8, 0xa4820070,
+ 0xc2400000, 0xc000140e, 0xca408018, 0xc2000002, 0xc0004900, 0xce000000, 0xc000490a, 0xce4000f8,
+ 0xc1000000, 0xd90000f9, 0xd8400078, 0xc1000004, 0xd90000f9, 0xa4840270, 0x00000000, 0xc3c00000,
+ 0xc000140e, 0xcbc10018, 0xc2800000, 0xc2000000, 0x6ff8a000, 0x6fd44000, 0x4795c000, 0x47bdc000,
+ 0x5bb87000, 0x5838002e, 0xca800078, 0x58380006, 0xca020078, 0xc3400000, 0x5838002e, 0xcb420078,
+ 0x5aa80002, 0x46a10000, 0x84000010, 0xc2800000, 0x5838002e, 0xc6900078, 0xcd000078, 0x5f740002,
+ 0x5838002e, 0xc7501078, 0xcd021078, 0xc0004968, 0xca4000f8, 0xc2000002, 0x6a3d0000, 0x72612000,
+ 0xce4000f8, 0xc000492a, 0xca8000f8, 0x5e740000, 0x84000040, 0xc0004910, 0xca0000f8, 0xc2c00002,
+ 0x6afd6000, 0x7ec16000, 0x762d0000, 0xce0000f8, 0x6abd4010, 0xa68000ba, 0x00000000, 0x58380032,
+ 0xca0000f8, 0x58000002, 0xca4000f8, 0x5838000c, 0x00000000, 0xce0000f9, 0xce4000f8, 0xc000492a,
+ 0xca0000f8, 0xc2c00002, 0x6afd6000, 0x722d0000, 0xce0000f8, 0xc000492c, 0xca0000f8, 0xc2c00002,
+ 0x6afd6000, 0x722d0000, 0xce0000f8, 0x80000040, 0xc000492c, 0xca0000f8, 0xc2c00002, 0x6afd6000,
+ 0x7ec16000, 0x762d0000, 0xce0000f8, 0xa4880148, 0xc2c00000, 0xc000140e, 0xcac20018, 0xc000490e,
+ 0xca4000f8, 0xc2000002, 0x6a2d0000, 0x7e010000, 0x76612000, 0xce4000f8, 0xc000496a, 0xca4000f8,
+ 0xc2000002, 0x6a2d0000, 0x72612000, 0xce4000f8, 0x6ef0a000, 0x6ed44000, 0x47158000, 0x472d8000,
+ 0x5b307000, 0x58300000, 0xca0000f8, 0x00000000, 0xc2400002, 0x76612000, 0x84000072, 0x58300000,
+ 0xca4000f8, 0xc2800000, 0x00000000, 0xc6684018, 0xc24c0002, 0xc6a40018, 0xc624c400, 0x58300010,
+ 0xca400500, 0x00000000, 0xc0001800, 0xce4000f8, 0xa4860070, 0xc2400000, 0xc000140e, 0xca418018,
+ 0xc2020002, 0xc0004900, 0xce002100, 0xc0004908, 0xce4000f8, 0xc1000000, 0xd90000f9, 0xd8400078,
+ 0xc1000004, 0xd90000f9, 0xc0001408, 0xcc8000f8, 0xc10e0002, 0xd90c00f8, 0x8000edb0, 0xdfbc00f9,
+ 0xc000496e, 0x99006298, 0xc94000f8, 0xc7d800f8, 0x00000000, 0xc57000f8, 0x5ef00020, 0x88000148,
+ 0x6f346000, 0x4771a000, 0x5b744c80, 0x58340008, 0xc2400000, 0xca400078, 0x00000000, 0xc2000000,
+ 0x5a640002, 0xce400078, 0x58340004, 0xca000078, 0x00000000, 0x00000000, 0x5e200002, 0xce000078,
+ 0xc0004912, 0xca8000f8, 0xc2400002, 0x6a712000, 0x72a54000, 0xce8000f8, 0x5e200000, 0x84000052,
+ 0xc000480a, 0xca0000f8, 0xc0000408, 0xca8000f8, 0x76250000, 0x00000000, 0x72a14000, 0xce8000f8,
+ 0x80000038, 0xc0004914, 0xca0000f8, 0x7e412000, 0x00000000, 0x76250000, 0xce0000f8, 0x800000d0,
+ 0x6ef4a000, 0x6ed44000, 0x4755a000, 0x476da000, 0x5b747000, 0x5834002e, 0xc2400000, 0xca420078,
+ 0x00000000, 0xc2000000, 0x5a640002, 0xc6501078, 0xcd021078, 0x58340006, 0xca000078, 0x00000000,
+ 0x00000000, 0x5a200002, 0xce000078, 0xc0004910, 0xca4000f8, 0xc2000002, 0x6a2d0000, 0x72612000,
+ 0xce4000f8, 0xc2000002, 0x6a310000, 0xc000042a, 0xce0000f8, 0xc1040002, 0xd90c00f8, 0x00000000,
+ 0x8000eb20, 0x00000000, 0xc4980928, 0x9d000000, 0xc5580028, 0xc0000838, 0xcd8400f8, 0xc1440200,
+ 0xc1c03800, 0xc55c1070, 0xc000100e, 0x9d000000, 0xcd8000f8, 0xc000100c, 0xcdc000f8, 0xc0004862,
+ 0xc9c000f8, 0x00000000, 0x00000000, 0xd9d800f9, 0xc0007800, 0x401c0000, 0x5dc07a00, 0x88000012,
+ 0x5c000200, 0xcd8000f8, 0xc1f0000a, 0x715ca000, 0xdd9800f8, 0xdd9c00f9, 0x41d8e000, 0xc5d40260,
+ 0xc0001010, 0xcd4000f8, 0x6c9c8000, 0x45c8e000, 0x45c8e000, 0x59dc0004, 0xc1601260, 0xc5d40260,
+ 0x9d000000, 0xc0001012, 0xcd4000f8, 0x00000000, 0x00000000, 0xd95800f8, 0x6d586000, 0x4594c000,
+ 0x59984c80, 0xd99800f9, 0x5818000a, 0xc1800000, 0xc9800078, 0xc0006e00, 0x6d5ca000, 0x401c0000,
+ 0x40180000, 0xc94000f8, 0x58000002, 0x00000000, 0xc9c000f8, 0xc0004930, 0xcd4000f8, 0xc0004932,
+ 0xcdc000f8, 0x59980004, 0xc1c20020, 0xb59c0018, 0x00000000, 0xc1800000, 0xdd9c00f9, 0x581c000a,
+ 0xcd800078, 0x581c000c, 0xc1800000, 0xc9800020, 0xc1c00002, 0xdd9400f8, 0x69d4e000, 0x5d980002,
+ 0xcd800020, 0xc0004924, 0xc98000f8, 0x00000000, 0x9d000000, 0x00000000, 0x719cc000, 0xcd8000f8,
+ 0xc000492a, 0xc94000f8, 0xc1c00002, 0x69d8e000, 0x7dc0c000, 0x7558a000, 0xcd4000f8, 0xc000492c,
+ 0xc94000f8, 0xdd8000f9, 0x58000032, 0x755ca000, 0x84000090, 0xc94000f9, 0xc98000f8, 0xdd8000f9,
+ 0x5800000c, 0x00000000, 0xcd4000f9, 0xcd8000f8, 0xc000492c, 0xc94000f8, 0xc000492a, 0xc98000f8,
+ 0x715ca000, 0xc000492c, 0xcd4000f8, 0x719cc000, 0xc000492a, 0xcd8000f8, 0x9d000000, 0x00000000,
+ 0x00000000, 0x00000000, 0xc0004862, 0xc98000f8, 0x00000000, 0xc1c00200, 0x4194c000, 0x459ce000,
+ 0x88000012, 0xc5d800f8, 0xc0004862, 0xcd8000f8, 0xc0001406, 0xc98000f8, 0xc1c00002, 0x9d000000,
+ 0xc5d80a00, 0xc5581048, 0xcd8000f8, 0xc0004930, 0xc98000f8, 0xc0004932, 0xc9c000f8, 0xc140000e,
+ 0xc5581c18, 0xdd9400f8, 0xc0007800, 0x40140000, 0x5d407a00, 0x88000012, 0x5c000200, 0xcd8000f8,
+ 0x58000002, 0x5d407a00, 0x88000012, 0x5c000200, 0xcdc000f8, 0xdd5400f8, 0xc1c00000, 0x58140006,
+ 0xc9c20078, 0xc1800000, 0x58140000, 0xc98000d8, 0x6ddc2000, 0xc000491e, 0x41d8e000, 0xcdc000f8,
+ 0xdd9800f8, 0xc1c00022, 0xc5d80d70, 0xdd9400f9, 0xc5581c18, 0xc000491c, 0xcd8000f8, 0xdd5400f8,
+ 0xc1c00000, 0x58140006, 0xc9c20078, 0xc1800000, 0x58140004, 0xc9820078, 0x00000000, 0x59dc0002,
+ 0x45d8c000, 0x84000010, 0xc1c00000, 0x9d000000, 0x58140006, 0xc5d81078, 0xcd821078, 0xc0004860,
+ 0xc94000f8, 0xc1820080, 0xc1d00002, 0x58147700, 0xd58000f8, 0x58000002, 0xd58000f9, 0x59540004,
+ 0xb5580018, 0xc0004860, 0xc1400000, 0xcd4000f8, 0xdd9800f9, 0x9d000000, 0xdd9400f8, 0xc0001404,
+ 0xcdc10800, 0xc1c00000, 0xc1800200, 0x5d980004, 0xdf5d0048, 0x459ca000, 0x8800fff2, 0xdd8000f9,
+ 0x5800000c, 0x00000000, 0xc94000f9, 0xc98000f8, 0xc1c00002, 0xc5d43f00, 0xc5d81e00, 0xc0004862,
+ 0xc9c000f8, 0x00000000, 0x00000000, 0x581c7800, 0x5dc07a00, 0x88000012, 0x5c000200, 0xcd4000f8,
+ 0x58000002, 0x5dc07a00, 0x88000012, 0x5c000200, 0xcd8000f8, 0xc0004862, 0xc9c000f8, 0x00000000,
+ 0xc15004c0, 0xc5d40060, 0xdd9c00f8, 0xc5d41c18, 0xc1c00000, 0xdd8000f9, 0x58000030, 0xc9c00078,
+ 0xdd8000f9, 0x58000002, 0xc98000f8, 0x6ddc2000, 0xc000491c, 0x41d8e000, 0xcd4000f9, 0xcdc000f8,
+ 0xdd9400f9, 0xc1c00000, 0x58140030, 0xc9c00078, 0xc1800000, 0x58140006, 0xc9820078, 0x00000000,
+ 0x59dc0002, 0x45d8c000, 0x84000010, 0xc1c00000, 0x9d000000, 0x58140030, 0xc5d80078, 0xcd800078,
+ 0xc1c00000, 0xdf5c0038, 0x5ddc0080, 0x8400ffea, 0x00000000, 0x9d000000, 0x00000000, 0x00000000,
+ 0x00000000, 0xc160fffe, 0xc0000a10, 0xc9440060, 0xc1a0fffe, 0x59983008, 0xc000100c, 0xcd4000f8,
+ 0xc000100e, 0xcd8000f8, 0xc0004964, 0xc98000f8, 0x00000000, 0xc170000a, 0x7158a000, 0x6c988000,
+ 0x4588c000, 0x4588c000, 0x59980004, 0xc5940270, 0xc0001010, 0xcd4000f8, 0xc0004946, 0xc94000f8,
+ 0x00000000, 0x00000000, 0x6d58a000, 0x6d5c4000, 0x459cc000, 0x4594c000, 0xc000494a, 0xc94000f8,
+ 0xc0004948, 0xc9c000f8, 0x4194c000, 0xc1400012, 0xc55c1818, 0x9d000000, 0xc59c0268, 0xc0001012,
+ 0xcdc000f8, 0xc1400000, 0x58000012, 0xc9410038, 0xc0004950, 0xc9c000f8, 0xc55800f8, 0xc5940838,
+ 0xc5581078, 0xd99400f8, 0xc000493c, 0xc94000f8, 0xc0004954, 0xc98000f8, 0x59dc00a8, 0x45d4e000,
+ 0x41d8e000, 0x5d5c0030, 0x88000010, 0xc1c00030, 0xc1800000, 0xc5d84028, 0xc1400000, 0xc5d40008,
+ 0x5dd40002, 0x84000072, 0x5dd40004, 0x8400009a, 0x5dd40006, 0x840000c2, 0x5dd80026, 0x840000ea,
+ 0xdd5400f8, 0xdd8000f9, 0x58000008, 0x40180000, 0xcd4000f8, 0x59980002, 0x8000ffc0, 0xdd5400f8,
+ 0xdd8000f9, 0x58000008, 0x40180000, 0xcd4000b8, 0x59980002, 0x8000ff88, 0xdd5400f8, 0xdd8000f9,
+ 0x58000008, 0x40180000, 0xcd400078, 0x59980002, 0x8000ff50, 0xdd5400f8, 0xdd8000f9, 0x58000008,
+ 0x40180000, 0xcd400038, 0x59980002, 0x8000ff18, 0x00000000, 0x9d000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x58000012, 0xc94000f8, 0xc0004954, 0xc9c000f8, 0xc0004950, 0xc9400078, 0xdd8000f9,
+ 0x58000028, 0x5d9c0000, 0x84000052, 0x5d9c0002, 0x84000052, 0x5d9c0004, 0x8400006a, 0xc55b0038,
+ 0xc55c08b8, 0xcd800039, 0xcdc108b8, 0x80000060, 0xcd4000f8, 0x80000050, 0xc55900b8, 0xc55c1838,
+ 0xcd8000b9, 0xcdc31838, 0x80000028, 0xc55a0078, 0xc55c1078, 0xcd800079, 0xcdc21078, 0x9d000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x59540002, 0x6994e018, 0x61c0c008, 0x4194a000, 0x5d940040,
+ 0x88000012, 0xc59400f8, 0x9d000000, 0xcd4000f8, 0x00000000, 0x00000000, 0x9d000000, 0x4158a000,
+ 0xcd4000f8, 0x00000000,
+};
+
+static unsigned int ar9_fw_data[] = {
+};
+
+
+#endif // IFXMIPS_ATM_FW_AR9_H
diff --git a/package/platform/lantiq/ltq-atm/src/ifxmips_atm_fw_ar9_retx.h b/package/platform/lantiq/ltq-atm/src/ifxmips_atm_fw_ar9_retx.h
new file mode 100644
index 0000000..0fc4789
--- /dev/null
+++ b/package/platform/lantiq/ltq-atm/src/ifxmips_atm_fw_ar9_retx.h
@@ -0,0 +1,611 @@
+#ifndef IFXMIPS_ATM_FW_AR9_H
+#define IFXMIPS_ATM_FW_AR9_H
+
+
+/******************************************************************************
+**
+** FILE NAME : ifxmips_atm_fw_ar9.h
+** PROJECT : UEIP
+** MODULES : ATM (ADSL)
+**
+** DATE : 22 OCT 2007
+** AUTHOR : Xu Liang
+** DESCRIPTION : ATM Driver (PP32 Firmware)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 22 OCT 2007 Xu Liang Initiate Version, v00.01
+*******************************************************************************/
+
+
+#define VER_IN_FIRMWARE 1
+
+#define ATM_FW_VER_MAJOR 0
+#define ATM_FW_VER_MINOR 15
+
+
+static unsigned int firmware_binary_code[] = {
+ 0x800004B8, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8000FFE0, 0x00000000, 0x00000000, 0x00000000,
+ 0xC1000002, 0xD90C00F8, 0xC2000002, 0xDA0800F9, 0xC0001B50, 0x8C100000, 0x00000000, 0x00000000,
+ 0x00000000, 0xC2000000, 0xDA0800F9, 0x80006030, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x80006008, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC1001DA6, 0x8D3C0000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x80005F08, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC0400000, 0xC0004840, 0xC88400F8, 0xC2001AEE, 0x8E100000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC0400002, 0xC0004840, 0xC88400F8, 0xC2001AEE, 0x8E100000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC3C00004, 0xDBC800F9, 0xC10C0002, 0xD90C00F8, 0x8000FEE0, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC10E0002, 0xD90C00F8, 0xC0004808, 0xC84000F8, 0xC2001B4C, 0x8E100000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC3E1FFFE, 0x597DFFFE, 0x593DFE14, 0x900004D9, 0x00000000, 0x00000000, 0x00000000, 0x90CC0481,
+ 0x00000000, 0x00000000, 0x00000000, 0xC3E0A252, 0x5BFC001E, 0xC0004002, 0xCFC000F8, 0xC3C00000,
+ 0xDBC800F9, 0xC1400008, 0xC1900000, 0x71588000, 0x14100100, 0xC140000A, 0xC1900002, 0x71588000,
+ 0x14100100, 0xC140000C, 0xC1900004, 0x71588000, 0x14100100, 0xC1400004, 0xC1900006, 0x71588000,
+ 0x14100100, 0xC1400006, 0xC1900008, 0x71588000, 0x14100100, 0xC140000E, 0xC190000A, 0x71588000,
+ 0x14100100, 0xC1400000, 0xC190000C, 0x71588000, 0x14100100, 0xC1400002, 0xC190000E, 0x71588000,
+ 0x14100100, 0xC0400000, 0xC11C0000, 0xC000082C, 0xCD05CE00, 0xC11C0002, 0xC000082C, 0xCD05CE00,
+ 0xC0400002, 0xC11C0000, 0xC000082C, 0xCD05CE00, 0xC0000824, 0x00000000, 0xCBC000F9, 0xCB8000F9,
+ 0xCB4000F9, 0xCB0000F8, 0xC0004878, 0x5BFC4000, 0xCFC000F9, 0x5BB84000, 0xCF8000F9, 0x5B744000,
+ 0xCF4000F9, 0x5B304000, 0xCF0000F8, 0xC0000A10, 0x00000000, 0xCBC000F9, 0xCB8000F8, 0xC0004874,
+ 0x5BFC4000, 0xCFC000F9, 0x5BB84000, 0xCF8000F8, 0xC30001FE, 0xC000140A, 0xCF0000F8, 0xC3000000,
+ 0x7F018000, 0xC000042E, 0xCF0000F8, 0xC000040E, 0xCF0000F8, 0xC3C1FFFE, 0xC000490E, 0xCFC00078,
+ 0xC000492C, 0xCFC00078, 0xC0004924, 0xCFC00038, 0xC0004912, 0xCFC00038, 0xC0004966, 0xCFC00038,
+ 0xC0004968, 0xCFC00078, 0xC000496A, 0xCFC00078, 0xC3C00000, 0xC2800020, 0xC3000000, 0x7F018000,
+ 0x6FF88000, 0x6FD44000, 0x4395C000, 0x5BB84A00, 0x5838000A, 0xCF0000F8, 0x5BFC0002, 0xB7E8FFC8,
+ 0x00000000, 0xC3C00000, 0xC2800010, 0x6FF86000, 0x47BDC000, 0x5BB84C80, 0xC3400000, 0x58380004,
+ 0xCB420078, 0x00000000, 0x58380008, 0xCF400078, 0x5BFC0002, 0xB7E8FFB0, 0x00000000, 0xC3C00000,
+ 0xC2800020, 0xC348001E, 0xC3000000, 0x7F018000, 0x6FF8A000, 0x6FD44000, 0x4795C000, 0x47BDC000,
+ 0x5BB87000, 0x58380008, 0xCF408418, 0x5838000A, 0xCF0000F8, 0x5BFC0002, 0xB7E8FFB0, 0x00000000,
+ 0x00000000, 0xC0004816, 0xC3C00000, 0xCBC00078, 0x00000000, 0x00000000, 0xC1000000, 0xD90400F9,
+ 0xDBC40078, 0xC1000006, 0xD90400F9, 0x00000000, 0xC121FFFE, 0x5911FE54, 0x14100000, 0xC3C00000,
+ 0xDCFC2000, 0x5FFC0002, 0x00000000, 0x98C08D62, 0xC0004730, 0xC94000F8, 0xC0004732, 0xC0001AF2,
+ 0xCBC000F8, 0x00000000, 0x00000000, 0xA7C20470, 0xC000474A, 0xCA8000F8, 0x00000000, 0x00000000,
+ 0x5D280000, 0x8400FFE0, 0x00000000, 0xC121FFFE, 0x5911FEF4, 0x14100000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC2802000, 0x6EA8E010, 0xC0004200, 0xC2400000, 0x7E410000, 0xC1000000, 0xCE4000F9, 0xCE4000F9,
+ 0xCE4000F9, 0xCE4000F9, 0x5EA80002, 0x8400FFD8, 0xC0004300, 0xC2800200, 0x6EA84010, 0xCE4000F9,
+ 0xCE0000F9, 0xCE4000F9, 0xCE0000F9, 0xCE4000F9, 0xCE0000F9, 0xCE4000F9, 0xCE0000F9, 0x5EA80002,
+ 0x8400FFB8, 0xC0004700, 0xC2800200, 0x6EA8E010, 0xCE4000F9, 0xCE4000F9, 0xCE4000F9, 0xCE4000F9,
+ 0x5EA80002, 0x8400FFD8, 0xC0004740, 0xCE4000F8, 0xC0004742, 0xC1000200, 0x5D100002, 0xCD0000F8,
+ 0xC0004744, 0xCE4000F8, 0xC0004746, 0xCE4000F8, 0xC0004748, 0xCE4000F8, 0xC000474A, 0xCE4000F8,
+ 0xC000474C, 0xC1000002, 0xCD0000F8, 0xC000474E, 0xCE4000F8, 0xC0004750, 0xCE4000F8, 0xC0004752,
+ 0xCE4000F8, 0xC0004754, 0xCE4000F8, 0xC0400000, 0xC11C0000, 0xC000082C, 0xCD05CE00, 0xC0000838,
+ 0xCE4000F8, 0xC0000818, 0xCE4000F8, 0xC0000820, 0xCE4000F8, 0xC2804840, 0xC240485A, 0x98C086B0,
+ 0xC68000F8, 0xC65400F8, 0xC1800000, 0xC11C0002, 0xC000082C, 0xCD05CE00, 0x00000000, 0xC121FFFE,
+ 0x5911FE54, 0x14100000, 0xC0000A10, 0xCB8000F8, 0xC0000A12, 0xCB4000F8, 0xC0000A14, 0xCB0000F8,
+ 0xC0000A16, 0xCAC000F8, 0xC0000040, 0xC2800000, 0xCE800000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xC2800002,
+ 0xCE800000, 0xC0000A10, 0xCF8000F8, 0xC0000A12, 0xCF4000F8, 0xC0000A14, 0xCF0000F8, 0xC0000A16,
+ 0xCEC000F8, 0xC1000000, 0xC00048A0, 0xCD0000F8, 0xC00048A2, 0xCD0000F8, 0xC0001AF2, 0xC1000000,
+ 0xCD002100, 0x80001038, 0x00000000, 0xC3C00000, 0xDCFC2000, 0x5FFC0002, 0x00000000, 0x98C08D62,
+ 0xC0004730, 0xC94000F8, 0xC0004732, 0x800033D8, 0x00000000, 0xC3C00000, 0xDCFC2000, 0x5FFC0002,
+ 0x00000000, 0x98C08D62, 0xC0004730, 0xC94000F8, 0xC0004732, 0xC0004810, 0xC90000F8, 0xC000474A,
+ 0xC94000F8, 0xA50007E8, 0x00000000, 0x5D140002, 0x840007D2, 0xC1000000, 0xC000484A, 0xC90000F8,
+ 0xC0004740, 0xC84000F8, 0x5D100000, 0x84000798, 0x00000000, 0x00000000, 0xC121FFFE, 0x5911FEF4,
+ 0x14100000, 0xC0004744, 0xC88000F8, 0xC0001AF0, 0xC3000000, 0x58000002, 0xCB010038, 0x6C7C2000,
+ 0x5BFC4300, 0x98C08A88, 0xC1400000, 0xC4540020, 0x6C40A010, 0x5D240002, 0x8400021A, 0x00000000,
+ 0xC0004742, 0xCA8000F8, 0x00000000, 0x00000000, 0x59280002, 0x6D130000, 0x6D130010, 0x45048000,
+ 0x84000692, 0x00000000, 0x98C08870, 0xC45400F8, 0xC69800F8, 0xC241FFFE, 0xC67400F8, 0x5D35FFFE,
+ 0x84000652, 0x47448000, 0x84000642, 0xC1000000, 0x6F502000, 0xC0004300, 0x40100000, 0xC1400000,
+ 0x58000000, 0xC9410038, 0xC1800000, 0xC0004814, 0xC9820038, 0x4714A000, 0xC10001FE, 0x4150A004,
+ 0x45588000, 0x880005CA, 0x4744C000, 0xC1000200, 0x4190C004, 0xC000473E, 0xC90000F8, 0x00000000,
+ 0x00000000, 0x41188000, 0xCD0000F8, 0xC000471C, 0xC90000F8, 0x00000000, 0x00000000, 0x41188000,
+ 0xCD0000F8, 0x98C087E8, 0xC45400F8, 0x6C58A010, 0xC0004700, 0x58440002, 0x6C470000, 0x6C470010,
+ 0x44748000, 0x8400FFC0, 0xC74400F8, 0xC0004740, 0xCC4000F8, 0xC0800000, 0xC0004744, 0xCC8000F8,
+ 0x800004D0, 0xC1000000, 0x583C0000, 0xC9000038, 0x00000000, 0x00000000, 0x44908000, 0x88000280,
+ 0xC1400000, 0x583C0000, 0xC9410038, 0xC1800000, 0xC0004814, 0xC9800038, 0x4714A000, 0xC10001FE,
+ 0x4150A004, 0x45588000, 0x88000442, 0xC3800000, 0x583C0002, 0xCB820078, 0xC1000000, 0x583C0002,
+ 0xC9000078, 0x00000000, 0x00000000, 0x47908000, 0x8400024A, 0xC0400002, 0xC0800000, 0xC3C00000,
+ 0xC000481A, 0xC80000F8, 0x6F908000, 0x45388000, 0x45388000, 0x4011E000, 0xC000491E, 0xCFC000F8,
+ 0xC3400000, 0xC0004878, 0xC80400F8, 0x6C908000, 0x45088000, 0x45088000, 0x40100000, 0xCAC000F8,
+ 0xC43000F8, 0x00000000, 0xC7340060, 0xC1000002, 0xC5341B00, 0xC100001C, 0xC5341048, 0xC100000C,
+ 0xC5340D10, 0xC000491C, 0xCF4000F8, 0xC3000000, 0xDF700038, 0x5D300080, 0x8800FFE8, 0xC000474A,
+ 0xC1000002, 0xCD0000F8, 0xC000491C, 0xCB4000F8, 0xC000491E, 0xCBC000F8, 0x99007F18, 0xDB5800F8,
+ 0xDBD800F9, 0x00000000, 0xC1400000, 0xC794A030, 0xC1800000, 0xC7980020, 0x58144200, 0xC9C000F8,
+ 0xC1210000, 0x69188010, 0x7D008000, 0x75D0E000, 0xCDC000F8, 0x80000228, 0x00000000, 0xC1000000,
+ 0x583C0000, 0xC903E000, 0x00000000, 0x00000000, 0x5D100000, 0x84000042, 0xC0004734, 0xC90000F8,
+ 0x00000000, 0x00000000, 0x59100002, 0xCD0000F8, 0x800000C0, 0xC1400000, 0x583C0000, 0xC9410038,
+ 0xC1800000, 0xC0004814, 0xC9820038, 0x4714A000, 0xC10001FE, 0x4150A004, 0x45588000, 0x8800015A,
+ 0xC000473E, 0xC90000F8, 0x00000000, 0x00000000, 0x59100002, 0xCD0000F8, 0xC000471C, 0xC90000F8,
+ 0x00000000, 0x00000000, 0x59100002, 0xCD0000F8, 0xC3800000, 0x583C0002, 0xCB820078, 0x00000000,
+ 0x00000000, 0x5D39FFFE, 0x84000062, 0xC1400000, 0xC794A030, 0xC1800000, 0xC7980020, 0x58144200,
+ 0xC9C000F8, 0xC1210000, 0x69188010, 0x7D008000, 0x75D0E000, 0xCDC000F8, 0x98C087E8, 0xC45400F8,
+ 0x6C58A010, 0xC0004700, 0x58440002, 0x6C470000, 0x6C470010, 0xC0004740, 0xCC4000F8, 0xC0800000,
+ 0xC0004744, 0xCC8000F8, 0x00000000, 0xC121FFFE, 0x5911FE54, 0x14100000, 0x8000F288, 0x00000000,
+ 0x00000000, 0x98C086F0, 0xC0004748, 0xC98000F8, 0xC2000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0xC1400000, 0xC7D4A030, 0xC1800000, 0xC7D80020, 0x58144200,
+ 0xC9C000F8, 0xC1210000, 0x69188010, 0x7D008000, 0x75D0E000, 0xCDC000F8, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x98C087E8, 0xC7D400F8, 0x6FD8A010, 0xC0004700, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x98C08870, 0xC7D400F8, 0xC79800F8, 0xC241FFFE, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x98C08A88, 0xC1400000, 0xC7D40020, 0x6FC0A010,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x98C08AB8, 0xC1400000, 0xC7D40020, 0x6FC0A010,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x98C08AF0, 0xC7D400F8, 0xC0004740, 0xC9C000F8,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x98C08BE0, 0xC7D400F8, 0xC0004742, 0xC98000F8,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xC0004958, 0xC84000F8, 0x00000000, 0xC3C00002,
+ 0x787C2000, 0xCC4000F8, 0xC0004848, 0xCB8400F8, 0xC000495C, 0xCAC400F8, 0xC0004844, 0xC88400F8,
+ 0x47AD0000, 0x8400F492, 0xC000487C, 0xC80400F8, 0x00000000, 0x00000000, 0x40080000, 0xCA0000F8,
+ 0xC0001624, 0xCB0400F8, 0xA63C007A, 0x00000000, 0x00000000, 0xA71EF432, 0x00000000, 0xC0000824,
+ 0xCA8400F8, 0x6CA08000, 0x6CA42000, 0x46250000, 0x42290000, 0xC35E0002, 0xC6340060, 0xC0001624,
+ 0xCF440078, 0xC2000000, 0xC161FFFE, 0x5955FFFE, 0x14140000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0xC0004844, 0xC88400F8, 0xC000082C, 0xCA040038, 0x00000000, 0x00000000, 0x58880002,
+ 0xB6080018, 0x00000000, 0xC0800000, 0xC0004844, 0xCC840038, 0x5AEC0002, 0xC000495C, 0xCEC400F8,
+ 0x5E6C0006, 0x84000060, 0xC0004848, 0xCB8400F8, 0xC0000838, 0xC2500002, 0xCE450800, 0x5FB80002,
+ 0xC0004848, 0xCF8400F8, 0x5EEC0002, 0xC000495C, 0xCEC400F8, 0x00000000, 0xC121FFFE, 0x5911FE54,
+ 0x14100000, 0x8000F290, 0xC000495A, 0xC84000F8, 0x00000000, 0xC3C00002, 0x787C2000, 0xCC4000F8,
+ 0xC0004960, 0xCAC400F8, 0x00000000, 0x00000000, 0x5EEC0000, 0x8400010A, 0x00000000, 0xB6FC0050,
+ 0xC0001600, 0xCA0400F8, 0x00000000, 0x00000000, 0xA61E00D2, 0x6FE90000, 0xC0000A28, 0xCE850800,
+ 0xC2C00000, 0xC2800004, 0xB6E800A0, 0xC0001604, 0xCA8400F8, 0xC0004960, 0xCEC400F8, 0xA69EFCAA,
+ 0x00000000, 0x6FE90000, 0xC0000A28, 0xCE850800, 0xC2C00002, 0xC0001600, 0xCA0400F8, 0x00000000,
+ 0x00000000, 0xA61E002A, 0x6FE90000, 0xC0000A28, 0xCE850800, 0xC2C00000, 0xC0001604, 0xCA8400F8,
+ 0xC0004960, 0xCEC400F8, 0xA69EFC12, 0xC2400000, 0xC0000A14, 0xCA440028, 0x00000000, 0x00000000,
+ 0x466D2000, 0xA4400020, 0xC2800000, 0xDFEB0029, 0x80000010, 0xDFEA0029, 0xB668EC0A, 0x00000000,
+ 0xC00048A0, 0xCB0400F8, 0xC0000A10, 0xCA8400F8, 0x6F208000, 0x6F242000, 0x46250000, 0x42A10000,
+ 0xC2400000, 0xC0000A14, 0xCA440028, 0xC35E0002, 0xC6340060, 0xC0001604, 0xCF440078, 0x5B300002,
+ 0xB6700018, 0x5AEC0002, 0xC3000000, 0xC00048A0, 0xCF0400F8, 0xC0004960, 0xCEC400F8, 0x8000F030,
+ 0xC0004918, 0xD28000F8, 0xC2000000, 0xDF600038, 0x5E600080, 0x840002A2, 0x00000000, 0xC161FFFE,
+ 0x5955FFFE, 0x14140000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xC000480A, 0xCA0000F8,
+ 0xC0004912, 0xCA4000F8, 0xC0004924, 0xCA8000F8, 0xC0004966, 0xCAC000F8, 0x00000000, 0xC121FFFE,
+ 0x5911FE54, 0x14100000, 0x76250000, 0x76290000, 0x762D0000, 0x840001E2, 0xC0004918, 0xCA4000F8,
+ 0xC28001FE, 0x76290000, 0x5A640002, 0x6A254010, 0x5EE80000, 0x8400001A, 0x6AA54000, 0x80000010,
+ 0xC62800F8, 0x62818008, 0xC0004918, 0xCF0000F8, 0xC161FFFE, 0x5955FFFE, 0x14140000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0xC0004966, 0xCA4000F8, 0xC2000002, 0x6A310000, 0x7E010000,
+ 0x76612000, 0xCE4000F8, 0x00000000, 0xC121FFFE, 0x5911FE54, 0x14100000, 0x6F346000, 0x4771A000,
+ 0x5B744C80, 0xC2800000, 0x58340006, 0xCA800078, 0xC2C00000, 0x58340000, 0xCAC000D8, 0xC2400000,
+ 0x5834000A, 0xCA420078, 0x6EA82000, 0x42E9E000, 0x6F2CA000, 0x42E56000, 0x5AEC2E00, 0xC3990040,
+ 0xC7381C18, 0xC6F80060, 0x99007F18, 0xDB9800F8, 0xDBD800F9, 0x00000000, 0xDEA000F8, 0x46310000,
+ 0x8400FD50, 0xC0004958, 0xC84000F8, 0x00000000, 0xC1000002, 0x78502000, 0xCC4000F8, 0xC0004848,
+ 0xCBC400F8, 0xC0004844, 0xC88400F8, 0x5FFC0000, 0x8400ECBA, 0xC0004740, 0xCB0000F8, 0xC0004744,
+ 0xCAC000F8, 0x6F282000, 0x5AA84300, 0xC000487C, 0xC80400F8, 0x00000000, 0x00000000, 0x40080000,
+ 0xCA4000F8, 0xC40000F8, 0x00000000, 0xC0004878, 0xC80400F8, 0x6C908000, 0x45088000, 0x45088000,
+ 0x40100000, 0xC90000F8, 0xC43400F8, 0x00000000, 0x5C440000, 0x840000A2, 0x00000000, 0xC00047D2,
+ 0xC90000F8, 0x00000000, 0x00000000, 0x59100002, 0xCD0000F8, 0x58340002, 0xC9000078, 0x00000000,
+ 0x00000000, 0x58280002, 0x6D120000, 0xCD021078, 0x5AEC0002, 0xC0004744, 0xCEC000F8, 0x80000630,
+ 0x00000000, 0xC00047C0, 0xC90000F8, 0x00000000, 0x00000000, 0x59100002, 0xCD0000F8, 0xA67C0048,
+ 0xC00047C2, 0xC90000F8, 0x00000000, 0x00000000, 0x59100002, 0xCD0000F8, 0x80001E18, 0x00000000,
+ 0xA6600042, 0xC00047C4, 0xC90000F8, 0x00000000, 0x00000000, 0x59100002, 0xCD0000F8, 0x80000570,
+ 0xC00047C6, 0xC90000F8, 0x00000000, 0x00000000, 0x59100002, 0xCD0000F8, 0xC3C00000, 0xC67D0038,
+ 0xC3800000, 0xC6780038, 0x47F08000, 0x840000A8, 0x47AC8000, 0x84000098, 0xC1000000, 0xC0004814,
+ 0xC9000038, 0x00000000, 0x00000000, 0x5D100000, 0x840000F0, 0x5AEC0002, 0xC0004744, 0xCEC000F8,
+ 0xC00047CA, 0xC90000F8, 0x00000000, 0x00000000, 0x59100002, 0xCD0000F8, 0x80000478, 0x00000000,
+ 0x98C08AF0, 0xC7D400F8, 0xC0004740, 0xC9C000F8, 0x5D240000, 0x8400006A, 0x00000000, 0x98C087E8,
+ 0xC7D400F8, 0x6FD8A010, 0xC0004700, 0xC00047C8, 0xC90000F8, 0x00000000, 0x00000000, 0x59100002,
+ 0xCD0000F8, 0x80001C40, 0xC00047CC, 0xC90000F8, 0x00000000, 0x00000000, 0x59100002, 0xCD0000F8,
+ 0x6FE82000, 0x5AA84300, 0x5D380000, 0x840000A0, 0x00000000, 0x98C086F0, 0xC0004748, 0xC98000F8,
+ 0xC2000000, 0x58280002, 0x6E520000, 0xCD021078, 0x58280002, 0xCE400078, 0x5D25FFFE, 0x84000040,
+ 0xC00047D0, 0xC90000F8, 0x00000000, 0x00000000, 0x59100002, 0xCD0000F8, 0x800002D0, 0xC3000000,
+ 0x58280002, 0xCB000078, 0x00000000, 0x00000000, 0x5D31FFFE, 0x84000048, 0xC00047D0, 0xC90000F8,
+ 0x00000000, 0x00000000, 0x59100002, 0xCD0000F8, 0x80000260, 0x00000000, 0x98C086F0, 0xC0004748,
+ 0xC98000F8, 0xC2000000, 0x58340002, 0xC6500078, 0xC7D01038, 0xC7901838, 0xCD0000F8, 0x58280002,
+ 0xCE400078, 0xC3C00200, 0x5FFC001C, 0xC3800000, 0xDF790048, 0x00000000, 0x00000000, 0x47F88000,
+ 0x8800FFDA, 0xC0004862, 0xCBC000F8, 0xC0000000, 0xC76C00F8, 0x5BBC7800, 0xC280001C, 0xCA6C00F9,
+ 0x00000000, 0x00000000, 0xCE7800F9, 0xC1007A00, 0x45388000, 0xC1007800, 0xC53800FE, 0x5EA80002,
+ 0x8400FFB8, 0xC3800000, 0xC000481A, 0xC80000F8, 0x6F108000, 0x45308000, 0x45308000, 0x4011C000,
+ 0xC000491E, 0xCF8000F8, 0xC2C00000, 0xC7EC0060, 0xC100001C, 0xC52C1048, 0xC100000A, 0xC52C0D10,
+ 0xC000491C, 0xCEC000F8, 0x99007CF0, 0xC000491C, 0xC1400000, 0xC9420048, 0xC2800000, 0xDF680038,
+ 0x5D280080, 0x8800FFE8, 0xC000491C, 0xCAC000F8, 0xC000491E, 0xCB8000F8, 0x99007F18, 0xDAD800F8,
+ 0xDB9800F9, 0x00000000, 0xC00047CE, 0xC90000F8, 0x00000000, 0x00000000, 0x59100002, 0xCD0000F8,
+ 0x00000000, 0x80001880, 0x00000000, 0x00000000, 0x00000000, 0xC0004878, 0xC80400F8, 0x6C908000,
+ 0x45088000, 0x45088000, 0x40100000, 0xCA0000F8, 0xC42400F8, 0x00000000, 0xC0004934, 0xCE0000F8,
+ 0xC2800002, 0xC4681C08, 0xC62821D0, 0xC6281E00, 0xC2600010, 0x5A650060, 0xC0004800, 0xCB4000F8,
+ 0xC2200400, 0x5A200020, 0xC7601040, 0xC0001220, 0xCE8000F8, 0xC0001200, 0xCE4000F8, 0xC0001202,
+ 0xCE0000F8, 0xC0001240, 0xCB4000F8, 0x00000000, 0x00000000, 0xA754FFE0, 0xC2000000, 0xC7600040,
+ 0xA7520042, 0x00000000, 0x00000000, 0x99008690, 0xC0004822, 0xC94000F8, 0xC1800002, 0x80001710,
+ 0x582040A0, 0xC2000000, 0xCA000018, 0xC2400000, 0xCA414000, 0xC2800000, 0xCA812000, 0xC2C00000,
+ 0xCAC20018, 0xC0004938, 0xCE0000F8, 0xC0004920, 0xCE4000F8, 0xC0004916, 0xCE8000F8, 0xC0004922,
+ 0xCEC000F8, 0xA6400558, 0x00000000, 0xC0004938, 0xCBC000F8, 0x00000000, 0xC3800000, 0x6FF48000,
+ 0x6FD44000, 0x4355A000, 0x5B744A00, 0x58340000, 0xCB802010, 0x00000000, 0xC2000000, 0x6FB46000,
+ 0x4779A000, 0x5B744C80, 0x5834000C, 0xCA000020, 0xC000491A, 0xCF8000F8, 0x5E200000, 0x84000482,
+ 0xC2000000, 0xDF610048, 0x5E6001E8, 0x8800FFE8, 0xC2000002, 0xC2400466, 0xC2A00000, 0x5AA80000,
+ 0xC0001006, 0xCE0000F8, 0xC0001008, 0xCE4000F8, 0xC000100A, 0xCE8000F8, 0x99007958, 0xC1A0FFFE,
+ 0xC0000824, 0xC9840060, 0xC0004934, 0xCA4000F8, 0xC2000000, 0xC2800002, 0x99007998, 0xDA9800F8,
+ 0xC61400F8, 0xC65800F8, 0xC161FFFE, 0x5955FFFE, 0x14140000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x99007A80, 0xC000491A, 0xC94000F8, 0x00000000, 0x00000000, 0xC121FFFE, 0x5911FE54,
+ 0x14100000, 0xC0004922, 0xCA001118, 0xC3C00000, 0xC3800000, 0xC0004930, 0xCE023118, 0xC0004932,
+ 0xCBC000D8, 0xC2800000, 0xC000491E, 0xCFC000F8, 0xC0004862, 0xCA800060, 0xC3A0001A, 0x5BB94000,
+ 0xC6B80060, 0xC000491C, 0xCF8000F8, 0x99007CF0, 0xC000491C, 0xC1400000, 0xC9420048, 0x00000000,
+ 0x00000000, 0x00000000, 0xA8E2FFE8, 0xC2000000, 0xC1220002, 0xD90C00F8, 0xDF600038, 0x5E600080,
+ 0x8400FFF2, 0xC000491C, 0xCA0000F8, 0xC000491E, 0xCA4000F8, 0x00000000, 0x00000000, 0x99007F18,
+ 0xDA1800F8, 0xDA5800F9, 0x00000000, 0xC2000000, 0xDF610048, 0x5E6001FE, 0x8800FFE8, 0xC0004916,
+ 0xCA8000F8, 0xC2C00000, 0xDFEC0048, 0xC2400000, 0x466D2000, 0x8400004A, 0x5EA80000, 0x8400003A,
+ 0xC2600002, 0x99008690, 0xC000482E, 0xC94000F8, 0xC1800002, 0x80000030, 0xC2600000, 0x99008690,
+ 0xC000482C, 0xC94000F8, 0xC1800002, 0xC2000068, 0xC6240078, 0xC0004930, 0xCE400080, 0xC000491A,
+ 0xC98000F8, 0xC0004862, 0xC94000F8, 0x6D9C6000, 0x45D8E000, 0x59DC4C80, 0x99007D78, 0xD95800F8,
+ 0xD99800F9, 0xD9D400F8, 0x99007CF0, 0xC000491C, 0xC1400000, 0xC9420048, 0xC2000000, 0xDF600038,
+ 0x5E600080, 0x8400FFEA, 0x00000000, 0xC000491C, 0xCA0000F8, 0xC000491E, 0xCA4000F8, 0x00000000,
+ 0x00000000, 0x99007F18, 0xDA1800F8, 0xDA5800F9, 0x00000000, 0x80001160, 0x00000000, 0x99008690,
+ 0xC000482A, 0xC94000F8, 0xC1800002, 0x80001130, 0xC0004938, 0xCBC000F8, 0x00000000, 0x00000000,
+ 0x6FF88000, 0x6FD44000, 0x4395C000, 0x5BB84A00, 0x58380008, 0xCA0000F8, 0x00000000, 0x00000000,
+ 0xA600039A, 0x00000000, 0xC0004938, 0xCBC000F8, 0xC3000000, 0x00000000, 0x6FF88000, 0x6FD44000,
+ 0x4395C000, 0x5BB84A00, 0x58380000, 0xCB002010, 0xC2000000, 0x58380008, 0xCA020078, 0x5838000C,
+ 0xCAC000F8, 0x5838000E, 0xCA4000F8, 0xC000491A, 0xCF0000F8, 0xC0004930, 0xCEC000F8, 0xC000493C,
+ 0xCE0000F8, 0xC0004932, 0xCE4000F8, 0x5E200000, 0x84000138, 0xC2800000, 0xA6FE00D2, 0x6F206000,
+ 0x46310000, 0x5A204C80, 0x5820000C, 0xCA800020, 0x00000000, 0x00000000, 0x5EA80000, 0x8400020A,
+ 0x00000000, 0xC161FFFE, 0x5955FFFE, 0x14140000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x99007A80, 0xC000491A, 0xC94000F8, 0x00000000, 0x00000000, 0xC121FFFE, 0x5911FE54, 0x14100000,
+ 0xC0004930, 0xCAC000F8, 0xC0004932, 0xCA4000F8, 0xC7EC1118, 0xC0004930, 0xCEC000F8, 0x5838000C,
+ 0xCEC000F8, 0x58000002, 0xCE4000F8, 0xC0004934, 0xCA0000F8, 0xC2400002, 0x6E642000, 0x6E642000,
+ 0x76612000, 0x8400002A, 0xC2400002, 0x6E684000, 0x58380008, 0xCE804200, 0xA6000020, 0x6E682000,
+ 0x58380008, 0xCE802100, 0xC2400002, 0x6E642000, 0x76612000, 0x840000EA, 0x58380008, 0xCA0000F8,
+ 0xC2800000, 0xC2400000, 0xA60200C0, 0xDBA800F8, 0x6F386000, 0x47B1C000, 0x5BB84C80, 0x58380004,
+ 0xCA400078, 0x58380002, 0xCA800078, 0x00000000, 0xDEB800F8, 0x46A54000, 0x88000060, 0x00000000,
+ 0xC0004824, 0xCA0000F8, 0xC2400002, 0x6E640000, 0x5A200002, 0xCE0000F8, 0x58380008, 0xCE400000,
+ 0x80000018, 0x00000000, 0x80000048, 0xC0004934, 0xCA0000F8, 0x00000000, 0x00000000, 0xA6020CCA,
+ 0x00000000, 0x00000000, 0x80000CF8, 0xC2800000, 0xC2000200, 0xC240001A, 0xDF690048, 0x46294000,
+ 0x46A54000, 0x8800FFD2, 0xC2000006, 0xC2600982, 0x5A643B6E, 0x5838000A, 0xCA8000F8, 0xC0001006,
+ 0xCE0000F8, 0xC0001008, 0xCE4000F8, 0xC000100A, 0xCE8000F8, 0x99007958, 0xC1A0FFFE, 0xC0000824,
+ 0xC9840060, 0xC2000000, 0xC0004930, 0xCA02E008, 0x58380026, 0xCA4000F8, 0x00000000, 0xC2800000,
+ 0x99007998, 0xDA9800F8, 0xC61400F8, 0xC65800F8, 0xC0004934, 0xCA0000F8, 0x00000000, 0x00000000,
+ 0xA6020022, 0x00000000, 0x00000000, 0x80000318, 0xC0004938, 0xCBC000F8, 0xC0004878, 0xC80400F8,
+ 0x6C908000, 0x45088000, 0x45088000, 0x40100000, 0xCA0000F8, 0xC42400F8, 0x00000000, 0x58240018,
+ 0xCA0000F8, 0x6FF88000, 0x6FD44000, 0x4395C000, 0x5BB84A00, 0xC3000000, 0xC3400002, 0xC2C00000,
+ 0xC62C0078, 0xC6270038, 0xC0004940, 0xCE400038, 0xC6260038, 0xC0004942, 0xCE400038, 0xC000493C,
+ 0xCA0000F8, 0x5EEC0000, 0x8400018A, 0x5A6C0010, 0x46254000, 0x88000190, 0x5A600052, 0x46E54000,
+ 0x88000178, 0x58380006, 0xCA8000F8, 0xC0004940, 0xCA0000F8, 0xC2400000, 0xC6A70038, 0x7E412000,
+ 0x76612000, 0xC2000000, 0xC6A10038, 0x46250000, 0x84000138, 0xC0004942, 0xCA0000F8, 0xC2400000,
+ 0xC6A60038, 0x7E412000, 0x76612000, 0xC2000000, 0xC6A00038, 0x58380002, 0xCA8000F8, 0x46250000,
+ 0x840000E8, 0xC2400000, 0xC6A60078, 0x466D0000, 0x880000DA, 0xC2400000, 0xC6A40078, 0x58380008,
+ 0xCA8000F8, 0x46E50000, 0x880000BA, 0x00000000, 0xA6820018, 0x00000000, 0xC7700B00, 0xA6840098,
+ 0x00000000, 0xC7700A00, 0x80000080, 0xC7700200, 0xC000493C, 0xCAC000F8, 0x80000060, 0xC7700300,
+ 0xC000493C, 0xCAC000F8, 0x80000040, 0xC7700900, 0x80000030, 0xC7700800, 0x80000020, 0xC7700700,
+ 0x80000010, 0xC7700500, 0xC0004944, 0xCF0000F8, 0xC000493E, 0xCEC000F8, 0xC0004938, 0xCA4000F8,
+ 0xC000493C, 0xCB8000F8, 0xC000493E, 0xCB4000F8, 0xC3000000, 0x6E608000, 0x6E544000, 0x42150000,
+ 0x5A204A00, 0x5AA00008, 0x58200004, 0xCB000078, 0xC0004934, 0xCA0000F8, 0xC2400000, 0xC0004930,
+ 0xCA42E008, 0xC3C00018, 0xA6020098, 0x00000000, 0x43656000, 0x47AD0000, 0x88000050, 0x46F96000,
+ 0x6EE04010, 0x5BE00004, 0xC2000000, 0xC6E00008, 0x5E200000, 0x84000042, 0x5BFC0002, 0x80000030,
+ 0xC3C00004, 0x5A2C0008, 0x47A10000, 0x88000012, 0x5FB80008, 0x6FE04000, 0x42390000, 0x47212000,
+ 0x88000068, 0xC2400000, 0xC0004930, 0xCA42E008, 0xC2060002, 0xC68000F8, 0xCE006300, 0x6FE04000,
+ 0x4721C000, 0x5F700010, 0x4765A000, 0xC2000000, 0xC6340008, 0xC25A000A, 0xC000491A, 0xCA401C18,
+ 0xC2800000, 0xC0004932, 0xCA8000D8, 0xC0004862, 0xCA400060, 0x6FA04010, 0x42290000, 0xC000491E,
+ 0xCE0000F8, 0xC7E41048, 0xC000491C, 0xCE4000F8, 0x6FE04000, 0x43A1C000, 0xC000493C, 0xCF8000F8,
+ 0xC000493E, 0xCF4000F8, 0xC000493A, 0xCFC000F8, 0x80000008, 0x00000000, 0x00000000, 0x00000000,
+ 0xC2000000, 0xDCE000F8, 0xA622FFD8, 0xC1220002, 0xD90C00F8, 0xC0004938, 0xCBC000F8, 0xC0004944,
+ 0xCB4000F8, 0xC0004862, 0xCB0000F8, 0xC0004934, 0xCA0000F8, 0x6FF88000, 0x6FD44000, 0x4395C000,
+ 0x5BB84A00, 0xA6020298, 0xC2400000, 0x58380008, 0xCA406000, 0xDFE800F8, 0xC2218E08, 0x5A21BAF6,
+ 0x46A14000, 0x84000022, 0xC2080002, 0x7361A000, 0x80000058, 0x5E640000, 0x84000022, 0xC20C0002,
+ 0x7361A000, 0x80000030, 0xC2000000, 0xC760E710, 0xC7604218, 0x5E200000, 0x840002A2, 0xC2200002,
+ 0xC0004930, 0xCE021000, 0x99008690, 0xC0004828, 0xC94000F8, 0xC1800002, 0xC0004780, 0xC93C00F8,
+ 0x00000000, 0x00000000, 0x59100002, 0xCD3C00F8, 0x58380000, 0xCA0000F8, 0x00000000, 0x00000000,
+ 0xA6000132, 0xC0004940, 0xCA8000F8, 0xC0004942, 0xCA4000F8, 0xC7600078, 0xC6A01838, 0xC6601038,
+ 0xC000493A, 0xCA4000F8, 0xC0004934, 0xCA8000F8, 0xC0007800, 0x40300000, 0x40240000, 0x5C000004,
+ 0x5EC07A00, 0x88000012, 0x5C000200, 0xCE0000F8, 0x58000002, 0x5EC07A00, 0x88000012, 0x5C000200,
+ 0xCE8000F8, 0xC000493E, 0xCA0000F8, 0xC2400000, 0x5838000C, 0xCE4000F8, 0x99008690, 0xC0004830,
+ 0xC94000F8, 0xC61800F8, 0xC0004930, 0xC6100078, 0xCD000078, 0x800000A8, 0xC2400002, 0x58380008,
+ 0xCE400000, 0xC0004944, 0xCF4000F8, 0x800002A8, 0xC000493C, 0xCA4000F8, 0xDFE800F8, 0x5A300018,
+ 0xC0007800, 0x40200000, 0xCA0000F8, 0x58380008, 0xC6501078, 0xCD021078, 0x5838000A, 0xCE8000F8,
+ 0x58380026, 0xCE0000F8, 0xC0004944, 0xCF4000F8, 0x99007CF0, 0xC000491C, 0xC1400000, 0xC9420048,
+ 0x80000068, 0x00000000, 0x99008690, 0xC0004826, 0xC94000F8, 0xC1800002, 0xC0004760, 0xC93C00F8,
+ 0x00000000, 0x00000000, 0x59100002, 0xCD3C00F8, 0x8000FDA8, 0xC2000000, 0xC2400080, 0xDF600038,
+ 0xB624FFEA, 0xC000491C, 0xCA4000F8, 0xC000491E, 0xCA8000F8, 0x99007F18, 0xDA5800F8, 0xDA9800F9,
+ 0x00000000, 0xC0004934, 0xCA0000F8, 0x00000000, 0xC2800000, 0xA6020160, 0xC2400004, 0xC2000200,
+ 0xDF690048, 0x46294000, 0x46A54000, 0x8800FFDA, 0x00000000, 0xC000491A, 0xC98000F8, 0xC0004862,
+ 0xC94000F8, 0x6D9C6000, 0x45D8E000, 0x59DC4C80, 0x99007D78, 0xD95800F8, 0xD99800F9, 0xD9D400F8,
+ 0x99007CF0, 0xC000491C, 0xC1400000, 0xC9420048, 0xC2000000, 0xC2400080, 0xDF600038, 0xB624FFEA,
+ 0xC000491C, 0xCA4000F8, 0xC000491E, 0xCA8000F8, 0x99007F18, 0xDA5800F8, 0xDA9800F9, 0x00000000,
+ 0x58380008, 0xCA4000F8, 0xC2000000, 0xCE000018, 0xC2A1FFFE, 0x5AA9FFFE, 0xCE021078, 0x5838000A,
+ 0xCE8000F8, 0xC161FFFE, 0x5955FFFE, 0x14140000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC0000838, 0xC2500002, 0xCE450800, 0xC0004848, 0xCBC400F8, 0xC3800000, 0xC000082C, 0xCB840028,
+ 0x5FFC0002, 0xC0004848, 0xCFC400F8, 0x58880002, 0x47888000, 0xC1000000, 0xC50800FE, 0xC0004844,
+ 0xCC8400F8, 0x00000000, 0xC121FFFE, 0x5911FE54, 0x14100000, 0x8000CBF0, 0xC2000000, 0xDF600038,
+ 0x5E200080, 0x8400029A, 0x00000000, 0xC161FFFE, 0x5955FFFE, 0x14140000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0xC000480C, 0xCA0000F8, 0xC0004910, 0xCA4000F8, 0xC000492C, 0xCA8000F8,
+ 0xC0004968, 0xCAC000F8, 0x00000000, 0xC121FFFE, 0x5911FE54, 0x14100000, 0x76250000, 0x76290000,
+ 0x76E16000, 0x840001DA, 0xC0004926, 0xCA4000F8, 0xC201FFFE, 0x76E16000, 0x5A640002, 0x6AE50010,
+ 0x5F200000, 0x8400001A, 0x6A250000, 0x80000010, 0xC6E000F8, 0x62014008, 0xC0004926, 0xCE8000F8,
+ 0xC161FFFE, 0x5955FFFE, 0x14140000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xC0004968,
+ 0xCA4000F8, 0xC2000002, 0x6A290000, 0x7E010000, 0x76612000, 0xCE4000F8, 0x00000000, 0xC121FFFE,
+ 0x5911FE54, 0x14100000, 0x6EB4A000, 0x6E944000, 0x4755A000, 0x4769A000, 0x5B747000, 0x58340002,
+ 0xC2000000, 0xCA0000D8, 0x5834002E, 0xC2400000, 0xCA400078, 0x6EB0A000, 0x6EBC4000, 0x473D8000,
+ 0x47298000, 0x5B30302E, 0x5B300004, 0x6E642000, 0x4225E000, 0xC39A8024, 0xC7380060, 0xC6B81C18,
+ 0x99007F18, 0xDB9800F8, 0xDBD800F9, 0x00000000, 0xC2000000, 0xDF600038, 0x5E200080, 0x840002D2,
+ 0x00000000, 0xC161FFFE, 0x5955FFFE, 0x14140000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC000490E, 0xCA0000F8, 0xC000492A, 0xCA4000F8, 0xC000496A, 0xCB0000F8, 0xC0004956, 0xCAC000F8,
+ 0x00000000, 0xC121FFFE, 0x5911FE54, 0x14100000, 0x77218000, 0x77258000, 0x8400021A, 0xC201FFFE,
+ 0x77218000, 0x5AEC0002, 0x6B2D0010, 0x5EA00000, 0x8400001A, 0x6A2D0000, 0x80000010, 0xC72000F8,
+ 0x62016008, 0xC0004956, 0xCEC000F8, 0xC161FFFE, 0x5955FFFE, 0x14140000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0xC000496A, 0xCA4000F8, 0xC2000002, 0x6A2D0000, 0x7E010000, 0x76612000,
+ 0xCE4000F8, 0x00000000, 0xC121FFFE, 0x5911FE54, 0x14100000, 0x6EF4A000, 0x6ED44000, 0x4755A000,
+ 0x476DA000, 0x5B747000, 0x5834000E, 0xC2000000, 0xCA0000D8, 0x58340008, 0xC2400000, 0xCA420078,
+ 0x5834000C, 0xC2800000, 0xCA832010, 0x6E644010, 0x42250000, 0x4229E000, 0xC39A8008, 0x58340008,
+ 0xCB809018, 0x58340008, 0xC2800000, 0xCA810010, 0x6EE0A000, 0x6EE44000, 0x46250000, 0x462D0000,
+ 0x5A200008, 0x5A203008, 0x42290000, 0xC6380060, 0xC6F81C18, 0x99007F18, 0xDB9800F8, 0xDBD800F9,
+ 0x00000000, 0xC000495A, 0xC84000F8, 0x00000000, 0xC3C00002, 0x787C2000, 0xCC4000F8, 0xC0001A1C,
+ 0xCA0000F8, 0xC2400008, 0x6A452000, 0x76250000, 0x84000E9A, 0xC0000A28, 0xC3800000, 0xCB840028,
+ 0xC0000A14, 0xC3400000, 0xCB440028, 0xC0004880, 0xCB0400F8, 0x47B48000, 0x88000E48, 0x58041802,
+ 0xCAC000F8, 0xA7000060, 0x00000000, 0x00000000, 0xA6C8C5C8, 0xC2800000, 0xC6E80018, 0x80000070,
+ 0x00000000, 0x00000000, 0x00000000, 0x8000C590, 0x00000000, 0xC2800000, 0xC7282018, 0xC000490E,
+ 0xCA4000F8, 0x6BE9E000, 0x00000000, 0x767D2000, 0x8400C548, 0x6EA0A000, 0x6E944000, 0x46150000,
+ 0x46290000, 0x5A207000, 0x5820000C, 0xCA0000F8, 0xC0004946, 0xCE8000F8, 0xA6220398, 0x00000000,
+ 0xC2200060, 0xC0004948, 0xCE000008, 0xCE021038, 0xC240000A, 0xC000494A, 0xCE4000F8, 0xC2B60002,
+ 0xC0004964, 0xCE837B00, 0x990081E8, 0xC00048A0, 0xC88400F8, 0x00000000, 0xC0004946, 0xCBC000F8,
+ 0x00000000, 0x00000000, 0x6FF8A000, 0x6FD44000, 0x4795C000, 0x47BDC000, 0x5BB87000, 0x99007FA8,
+ 0xDBD800F8, 0xDB9800F9, 0x00000000, 0x99007CF0, 0xC000491C, 0xC1400000, 0xC9420048, 0xC000491C,
+ 0x990081A0, 0xC94000F9, 0xC98000F8, 0x00000000, 0x99007F18, 0xD95800F8, 0xD99800F9, 0x00000000,
+ 0xC161FFFE, 0x5955FFFE, 0x14140000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x99007BE0,
+ 0xDBD800F8, 0xDB9800F9, 0xC7D800F8, 0x00000000, 0xC121FFFE, 0x5911FE54, 0x14100000, 0x6FF8A000,
+ 0x6FD44000, 0x4795C000, 0x47BDC000, 0x5BB87000, 0x58380010, 0xCA0000F8, 0xC0004874, 0xC80400F8,
+ 0x6C908000, 0x45088000, 0x45088000, 0x40100000, 0xCA4000F8, 0xC43400F8, 0x00000000, 0xC74000F8,
+ 0xCE0000F8, 0xC161FFFE, 0x5955FFFE, 0x14140000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC000490E, 0xCA4000F8, 0xC2800002, 0x6ABD4000, 0x72692000, 0xCE4000F8, 0x00000000, 0xC121FFFE,
+ 0x5911FE54, 0x14100000, 0x99008690, 0xC0004836, 0xC94000F8, 0xC1800002, 0x00000000, 0x00000000,
+ 0x00000000, 0xA8E2FFE8, 0x00000000, 0xC1220002, 0xD90C00F8, 0xC2000000, 0xC0000A14, 0xCA040028,
+ 0xC0000A28, 0xC2500002, 0xCE450800, 0x58880002, 0xB6080018, 0xC00048A0, 0xC0800000, 0xCC8400F8,
+ 0x8000C168, 0xC0004946, 0xCBC000F8, 0xC161FFFE, 0x5955FFFE, 0x14140000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0xC000490E, 0xCA4000F8, 0xC2800002, 0x6ABD4000, 0x72692000, 0xCE4000F8,
+ 0x00000000, 0xC121FFFE, 0x5911FE54, 0x14100000, 0x6FF8A000, 0x6FD44000, 0x4795C000, 0x47BDC000,
+ 0x5BB87000, 0x58380008, 0xCA0000F8, 0x5838000C, 0xCA4000F8, 0xC3400000, 0xC6340000, 0xC000494E,
+ 0xCF4000F8, 0xC2800000, 0xC62A0078, 0xC3000000, 0xC6308018, 0x6F304000, 0x43298000, 0xC000493C,
+ 0xCF0000F8, 0xC2C00000, 0xC66C0078, 0xC0004950, 0xCEC000F8, 0xC2800000, 0xC66AE020, 0xC0004954,
+ 0xCE8000F8, 0x5F740000, 0x840001B8, 0x5E300028, 0x46E12000, 0x84000182, 0x46E12000, 0x8800014A,
+ 0x5E300018, 0x46E12000, 0x8800002A, 0x46E12000, 0x84000042, 0x00000000, 0x800000D8, 0x00000000,
+ 0x99008328, 0xDBD800F8, 0xDB9800F9, 0xC78000F8, 0xC3400002, 0xC000494E, 0xCF4000F8, 0xC161FFFE,
+ 0x5955FFFE, 0x14140000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xC000490E, 0xCA4000F8,
+ 0xC2800002, 0x6ABD4000, 0x7E814000, 0x76692000, 0xCE4000F8, 0x00000000, 0xC121FFFE, 0x5911FE54,
+ 0x14100000, 0xC2200060, 0xC0004948, 0xCE021038, 0xC2000000, 0xC000494C, 0xCE0000F8, 0x80000080,
+ 0x00000000, 0x99008328, 0xDBD800F8, 0xDB9800F9, 0xC78000F8, 0x99008528, 0xDBD800F8, 0xDB9800F9,
+ 0xC78000F8, 0xC2200058, 0xC0004948, 0xCE021038, 0xC2000002, 0xC000494C, 0xCE0000F8, 0xC2000006,
+ 0xC0001006, 0xCE0000F8, 0x5838000A, 0xCA4000F8, 0xC2200982, 0x5A203B6E, 0xC0001008, 0xCE0000F8,
+ 0xC000100A, 0xCE4000F8, 0xC0004954, 0xCA8000F8, 0xC200000C, 0xC000494A, 0xCE0000F8, 0xC0004948,
+ 0xCE800008, 0xC2B60000, 0xC0004964, 0xCE8000F8, 0x990081E8, 0xC00048A0, 0xC88400F8, 0x00000000,
+ 0xC0004946, 0xCBC000F8, 0xC000494C, 0xCA0000F8, 0x6FF8A000, 0x6FD44000, 0x4795C000, 0x47BDC000,
+ 0x5BB87000, 0x5E200000, 0x84000112, 0x00000000, 0x99007FA8, 0xDBD800F8, 0xDB9800F9, 0x00000000,
+ 0x99007CF0, 0xC000491C, 0xC1400000, 0xC9420048, 0xC000491C, 0x990081A0, 0xC94000F9, 0xC98000F8,
+ 0x00000000, 0x99007F18, 0xD95800F8, 0xD99800F9, 0x00000000, 0xC161FFFE, 0x5955FFFE, 0x14140000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x99007BE0, 0xDBD800F8, 0xDB9800F9, 0xC7D800F8,
+ 0x00000000, 0xC121FFFE, 0x5911FE54, 0x14100000, 0xC000493C, 0xCA8000F8, 0xC000494E, 0xCAC000F8,
+ 0xC3000018, 0xC3400006, 0x5E200000, 0x8400002A, 0xC2800000, 0xC2C00000, 0xC300001E, 0xC3400000,
+ 0xC6AC1078, 0xC72C0418, 0xC76C0810, 0x58380010, 0xCA8000F8, 0x58380008, 0xCEC000F8, 0xC6280100,
+ 0xC0004874, 0xC80400F8, 0x6C908000, 0x45088000, 0x45088000, 0x40100000, 0xCB0000F8, 0xC43400F8,
+ 0x00000000, 0xC74000F8, 0xCE8000F8, 0xC0004952, 0xCE8000F8, 0x00000000, 0x00000000, 0x00000000,
+ 0xA8E2FFE8, 0x00000000, 0xC000494C, 0xCA0000F8, 0xC0004950, 0xCAC000F8, 0x5E200000, 0x8400006A,
+ 0xDFE800F8, 0x7E814000, 0x5834001A, 0xCE8000F8, 0x99008690, 0xC0004834, 0xC94000F8, 0xC1800002,
+ 0x99008690, 0xC0004838, 0xC94000F8, 0xC6D800F8, 0xC1220002, 0xD90C00F8, 0x5E200000, 0x84000040,
+ 0x5838002C, 0xCB0000F8, 0xDFE800F8, 0x00000000, 0x58380014, 0xCF0000F8, 0x80000018, 0xC2A1FFFE,
+ 0x5AA9FFFE, 0x5838000A, 0xCE8000F8, 0xC3000000, 0xC0000A14, 0xCB040028, 0xC2D00002, 0xC0000A28,
+ 0xCEC50800, 0xC000494E, 0xCA8000F8, 0x58880002, 0xB4B00018, 0xC00048A0, 0xC0800000, 0xCC8400F8,
+ 0x5EA80000, 0x8400016A, 0x5E200000, 0x84000158, 0xC000493C, 0xCA8000F8, 0x00000000, 0x00000000,
+ 0x5AA80060, 0xCE8000F8, 0x99008328, 0xDBD800F8, 0xDB9800F9, 0xC78000F8, 0x99008528, 0xDBD800F8,
+ 0xDB9800F9, 0xC78000F8, 0xC0004952, 0xCAC000F8, 0x58380000, 0xCA8000F8, 0xC30C0002, 0xC7F00018,
+ 0xA68000B0, 0x00000000, 0x00000000, 0xC161FFFE, 0x5955FFFE, 0x14140000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0xC0001800, 0xCA0000F8, 0x00000000, 0x00000000, 0xA60CFFEA, 0xC6F00500,
+ 0xC6B0C400, 0xCF0000F8, 0x00000000, 0xC121FFFE, 0x5911FE54, 0x14100000, 0x8000B7B8, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x8000B750, 0xDCBC00F9, 0x5FFC0000, 0x8400095A, 0xC3800002,
+ 0xDB8800F9, 0xC3800000, 0xDB8800F9, 0xC0004728, 0xC90000F8, 0x00000000, 0x00000000, 0x59100002,
+ 0xCD0000F8, 0xC0004730, 0xC98000F8, 0xC000472E, 0xC94000F8, 0xC00047DC, 0xC90000F8, 0xC00047DE,
+ 0xC9C000F8, 0xC000472E, 0xCD8000F8, 0x6D110000, 0xC5D30038, 0xC00047DC, 0xCD0000F8, 0x4594A000,
+ 0x6DDD0000, 0xC55C0038, 0xC00047DE, 0xCDC000F8, 0xC0001AC4, 0xC94000F8, 0xC0001AC8, 0xC98000F8,
+ 0xC000472C, 0xC9C000F8, 0x45948000, 0xC1000002, 0x41D0E004, 0xCDC000F8, 0xC5501078, 0xC5900078,
+ 0xC000472A, 0xCD0000F8, 0xC0001AF0, 0xCBC000F8, 0x58000002, 0xCB8000F8, 0xC3400000, 0xC7F50038,
+ 0x6F702000, 0x5B304300, 0xC000474C, 0xCAC000F8, 0xC0004720, 0xC94000F8, 0x00000000, 0x00000000,
+ 0x5D940002, 0x6D9B8000, 0x6D9B8010, 0x581847E0, 0xC98000F8, 0x581447E0, 0xC9C000F8, 0x5D2C0000,
+ 0x8400007A, 0xC7901078, 0xC7D00078, 0xCD0000F8, 0xC1000000, 0xC5910038, 0x45348000, 0x84000090,
+ 0xC0004722, 0xC90000F8, 0x00000000, 0x00000000, 0x59100002, 0xCD0000F8, 0x80000058, 0xC1000000,
+ 0xC5D10038, 0x45348000, 0x8400003A, 0xC0004724, 0xC90000F8, 0x00000000, 0x00000000, 0x59100002,
+ 0xCD0000F8, 0xA7840080, 0x59540002, 0x6D578000, 0x6D578010, 0xC0004720, 0xCD4000F8, 0xC1000000,
+ 0xC5910038, 0x45348000, 0x84000038, 0xC0004726, 0xC90000F8, 0x00000000, 0x00000000, 0x59100002,
+ 0xCD0000F8, 0xA78000B8, 0xC2800002, 0xC000474E, 0xCE8000F8, 0xC2C00000, 0xC000474C, 0xCEC000F8,
+ 0xC0004758, 0xCFC000F8, 0x58000002, 0xCF8000F8, 0xC000475C, 0xC90000F8, 0x00000000, 0x00000000,
+ 0xA53E003A, 0x00000000, 0xC13E0002, 0xCFC000F8, 0xCD03DE08, 0x58000002, 0xCF8000F8, 0x800001A0,
+ 0xC000475C, 0xC13C0002, 0xCD03DE08, 0x5D2C0000, 0x8400017A, 0xC2C00000, 0xC000474C, 0xCEC000F8,
+ 0x98C08AF0, 0xC75400F8, 0xC0004740, 0xC9C000F8, 0x5D240000, 0x84000042, 0xC1000002, 0xC0004750,
+ 0xCD0000F8, 0xC0004752, 0xCD0000F8, 0x80000100, 0x00000000, 0x98C08BE0, 0xC75400F8, 0xC0004742,
+ 0xC98000F8, 0x5D240000, 0x8400002A, 0xC1000002, 0xC0004752, 0xCD0000F8, 0x80000060, 0xC0004742,
+ 0xC94000F8, 0xC0004754, 0xC1000002, 0xCD0000F8, 0x98C08CF0, 0xC55400F8, 0xC75800F8, 0x00000000,
+ 0xC0004742, 0xCF4000F8, 0x98C08AB8, 0xC1400000, 0xC7540020, 0x6F40A010, 0xC1000000, 0xC7D00038,
+ 0x58300000, 0x6D110000, 0xCD010838, 0xA7840398, 0xC000474C, 0xCAC000F8, 0xC000474E, 0xCA8000F8,
+ 0xC0004750, 0xCBC000F8, 0xC0004752, 0xCB8000F8, 0xC0004710, 0xC90000F8, 0x00000000, 0x00000000,
+ 0x59100002, 0xCD0000F8, 0x5D280002, 0x840000B8, 0xC000473C, 0xC90000F8, 0x00000000, 0x00000000,
+ 0x59100002, 0xCD0000F8, 0xC0004712, 0xC90000F8, 0x00000000, 0x00000000, 0x59100002, 0xCD0000F8,
+ 0xC0004754, 0xC90000F8, 0x00000000, 0x00000000, 0x5D100000, 0x8400021A, 0x58300000, 0xC13C0002,
+ 0xCD03DE00, 0x800001F8, 0xC0004714, 0xC90000F8, 0x00000000, 0x00000000, 0x59100002, 0xCD0000F8,
+ 0x5D380000, 0x8400003A, 0xC0004736, 0xC90000F8, 0x00000000, 0x00000000, 0x59100002, 0xCD0000F8,
+ 0x5D3C0000, 0x84000042, 0xC0004718, 0xC90000F8, 0x00000000, 0x00000000, 0x59100002, 0xCD0000F8,
+ 0x80000140, 0xC1000000, 0x58300000, 0xC903E000, 0x00000000, 0x00000000, 0x5D100000, 0x84000042,
+ 0xC000471A, 0xC90000F8, 0x00000000, 0x00000000, 0x59100002, 0xCD0000F8, 0x800000D0, 0x58300000,
+ 0xC13E0002, 0xCD03FF00, 0xC1000000, 0x58300000, 0xC903C000, 0x00000000, 0x00000000, 0x5D100000,
+ 0x84000082, 0xC0004716, 0xC90000F8, 0x00000000, 0x00000000, 0x59100002, 0xCD0000F8, 0xC000473A,
+ 0xC90000F8, 0x00000000, 0x00000000, 0x59100002, 0xCD0000F8, 0x58300000, 0xC13C0000, 0xCD03DE00,
+ 0xC1000000, 0xC0004746, 0xCD0000F8, 0xC0004750, 0xCD0000F8, 0xC0004752, 0xCD0000F8, 0xC000474E,
+ 0xCD0000F8, 0xC2C00002, 0xC000474C, 0xCEC000F8, 0xC0004754, 0xCD0000F8, 0xC3CE0002, 0xC0000800,
+ 0xCFC0E700, 0xC3E1FFFE, 0x597DFFFE, 0x593DFE14, 0x94000001, 0x00000000, 0x00000000, 0x00000000,
+ 0xC000487C, 0xC80400F8, 0x00000000, 0x00000000, 0x40080000, 0xCBC000F8, 0xC43800F8, 0x00000000,
+ 0xC000480E, 0xCA0000F8, 0xC0004858, 0xCB4400F8, 0x00000000, 0x00000000, 0x47610000, 0x880000B0,
+ 0x00000000, 0xA7C00048, 0xC0004854, 0xC1000002, 0xCD0400F8, 0xC11C0000, 0xC000082C, 0xCD05CE00,
+ 0x800000D8, 0x00000000, 0xA7D20138, 0x00000000, 0xC7E14040, 0xC2400000, 0xC6246028, 0xC200006A,
+ 0x46250000, 0xC6240030, 0xC0000810, 0xCE440030, 0x8000FF70, 0xC2000000, 0xC0000808, 0xCA040010,
+ 0xC11C0000, 0xC000082C, 0xCD05CE00, 0x5A200002, 0x5E600010, 0x84000010, 0xC2000000, 0xC0000808,
+ 0xCE040010, 0xC3400000, 0x80000028, 0xC1200002, 0xC0000818, 0xCD061000, 0x5B740002, 0xC0004858,
+ 0xCF4400F8, 0x99007930, 0xC0004848, 0xC94400F8, 0xC1800000, 0xC11C0002, 0xC000082C, 0xCD05CE00,
+ 0x80000878, 0x5B740002, 0xC0004858, 0xCF4400F8, 0xC78000F8, 0xC13C0002, 0xCD03DE00, 0xC0004848,
+ 0xC94400F8, 0xC1800000, 0xC000082C, 0xC9840028, 0x59540002, 0xC0004848, 0xCD4400F8, 0x58880002,
+ 0xB49807F8, 0x00000000, 0xC0800000, 0x800007E0, 0xC000487C, 0xC80400F8, 0x00000000, 0x00000000,
+ 0x40080000, 0xCBC000F8, 0xC42800F8, 0x00000000, 0xA7C00130, 0xC000484C, 0xCA0400F8, 0xC2400000,
+ 0xC0001AEC, 0xCA440018, 0x5A200002, 0xC000484C, 0xCE0400F8, 0xB624008A, 0xC68000F8, 0xC13C0002,
+ 0xCD03DE00, 0xC0004848, 0xC94400F8, 0xC1800000, 0xC000082C, 0xC9840028, 0x59540002, 0xC0004848,
+ 0xCD4400F8, 0x58880002, 0xB49806E8, 0x00000000, 0xC0800000, 0x800006D0, 0xC0004854, 0xC1000004,
+ 0xCD0400F8, 0xC0000820, 0xC2000002, 0xCE0400F8, 0xC2000000, 0xC000484C, 0xCE0400F8, 0xC0004858,
+ 0xCE0400F8, 0x8000FF28, 0xC0004854, 0xC1000000, 0xCD0400F8, 0xC11C0000, 0xC000082C, 0xCD05CE00,
+ 0x99007930, 0xC0004848, 0xC94400F8, 0xC1800000, 0xC1200000, 0xC0000818, 0xCD061000, 0xC11C0002,
+ 0xC000082C, 0xCD05CE00, 0xC2000000, 0xC000484C, 0xCE0400F8, 0x800005D0, 0xC0001AC0, 0xCB8400F8,
+ 0xC000487C, 0xC80400F8, 0x00000000, 0x00000000, 0x40080000, 0xCBC000F8, 0xC42800F8, 0x00000000,
+ 0xA78004E2, 0x00000000, 0x00000000, 0xA7C004A2, 0x00000000, 0xC0001B00, 0xC2060006, 0xCE046308,
+ 0xA7E8045A, 0x00000000, 0xC0004850, 0xCA0400F8, 0xC2400000, 0xC0004812, 0xCA420078, 0x5A200002,
+ 0xC0004850, 0xCE0400F8, 0x5E640000, 0x8400001A, 0x46250000, 0x880002F8, 0xC68000F8, 0xC13C0002,
+ 0xCD03DE00, 0xC0001ACC, 0xC2000002, 0xCE040000, 0x5C440000, 0x84000250, 0xC0004810, 0xC94000F8,
+ 0xC68000F8, 0xCBC000F8, 0x00000000, 0xC1000000, 0xA5400208, 0xC53C1000, 0x00000000, 0xA7FC01F2,
+ 0xC0001AF0, 0xC1000000, 0x58000002, 0xC9000000, 0xC000474E, 0xC98000F8, 0x5D100000, 0x84000022,
+ 0xC1000002, 0xC53C1E00, 0x80000198, 0x5D180000, 0x84000022, 0xC1000002, 0xC53C1E00, 0x80000170,
+ 0xC0004878, 0xC80400F8, 0x6C908000, 0x45088000, 0x45088000, 0x40100000, 0xC98000F8, 0xC43800F8,
+ 0x00000000, 0xC000481E, 0xC9C000F8, 0xC000481C, 0xCA0000F8, 0x00000000, 0x759CC000, 0x45A08000,
+ 0x840000E8, 0xC0001AF0, 0xC3400000, 0x58000000, 0xCB410038, 0xC0004746, 0xC94000F8, 0x6F702000,
+ 0x5B304300, 0xC2C00000, 0x58300000, 0xCAC00038, 0x00000000, 0x00000000, 0x456C8000, 0x88000020,
+ 0xC1000002, 0xC53C1E00, 0x80000040, 0x5AEC0002, 0x58300000, 0xCEC00038, 0xC1000002, 0xC53C1000,
+ 0xC77C0838, 0xC57C0038, 0x59540002, 0xC0004746, 0xCD4000F8, 0xC68000F8, 0xCFC000F8, 0xC0004848,
+ 0xC94400F8, 0xC1800000, 0xC000082C, 0xC9840028, 0x59540002, 0xC0004848, 0xCD4400F8, 0x58880002,
+ 0xB49801F8, 0x00000000, 0xC0800000, 0x800001E0, 0xC000471E, 0xC90000F8, 0x00000000, 0x00000000,
+ 0x59100002, 0xCD0000F8, 0xC0004854, 0xC1000000, 0xCD0400F8, 0xC11C0000, 0xC000082C, 0xCD05CE00,
+ 0x99007930, 0xC0004848, 0xC94400F8, 0xC1800000, 0xC2000000, 0xC0000820, 0xCE0400F8, 0xC1200000,
+ 0xC0000818, 0xCD061000, 0xC11C0002, 0xC000082C, 0xCD05CE00, 0xC0004850, 0xCE0400F8, 0xC2000002,
+ 0xC0001ACC, 0xCE040008, 0x800000E8, 0xC2000002, 0xC0004850, 0xCE0400F8, 0x8000FC00, 0xC2000000,
+ 0xC0004850, 0xCE0400F8, 0xA7E60032, 0x00000000, 0xC2000002, 0xC0001B00, 0xCE040000, 0x8000FBE8,
+ 0x00000000, 0xA7860052, 0x00000000, 0xC68000F8, 0xC13C0002, 0xCD03DE00, 0xC2020002, 0xC7E2A540,
+ 0xC0001B00, 0xCE0400F8, 0x8000FB90, 0xC2040002, 0xC0001B00, 0xCE044200, 0x8000FB70, 0xC2C80002,
+ 0x6AC56000, 0xDACC00F8, 0xC0004854, 0xCB4400F8, 0xC0004848, 0xCB8400F8, 0xC0000838, 0xC3C00000,
+ 0xCBC40028, 0x5EF40004, 0x84000022, 0xC3000000, 0xC0001ACC, 0xCF042100, 0x47F98000, 0x8400004A,
+ 0x47F98000, 0x88000050, 0xC1006E8C, 0xC1400010, 0x8D580000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC0004840, 0xCC8400F8, 0x8000EB10, 0xC0001AC0, 0xCAC400F8, 0xC0004854, 0xCB4400F8, 0xA6C0F93A,
+ 0x00000000, 0x5EF40000, 0x8400F472, 0x5EF40002, 0x8400F702, 0x5EF40004, 0x8400F902, 0xC1006CE8,
+ 0xC1400010, 0x8D580000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xC0800000, 0xDF4B0038,
+ 0xC0004900, 0xCB8000F8, 0xC2000000, 0xC000490A, 0xA78000D0, 0xCBC000F8, 0xC1000000, 0xD90000F9,
+ 0xC1000002, 0xD90C00F8, 0x6FF46000, 0x477DA000, 0x5B744C80, 0xC2400000, 0x58340004, 0xCA400078,
+ 0xC0004900, 0xCE000000, 0x5A640002, 0x58340004, 0xC6500078, 0xCD000078, 0xC0004914, 0xCA4000F8,
+ 0xC2000002, 0x6A3D0000, 0x72612000, 0xCE4000F8, 0xC0000408, 0xCE0000F8, 0xA78200D8, 0xC0004908,
+ 0xCBC000F8, 0xC1000000, 0xD90000F9, 0xC1000002, 0xD90C00F8, 0x6FF4A000, 0x6FD44000, 0x4755A000,
+ 0x477DA000, 0x5B747000, 0xC2800000, 0x58340006, 0xCA800078, 0xC2000000, 0xC0004900, 0xCE002100,
+ 0x5EA80002, 0x58340006, 0xC6900078, 0xCD000078, 0x5A7C0020, 0xC2000002, 0x6A250000, 0xC0000408,
+ 0xCE0000F8, 0xC0000032, 0xDCA800F9, 0xC1000002, 0x45294000, 0x00000000, 0x8C100006, 0x00000000,
+ 0x00000000, 0x00000000, 0xA4800230, 0x00000000, 0xC3C00000, 0xC000140E, 0xCBC00018, 0xC3400000,
+ 0xC2400000, 0x6FF86000, 0x47BDC000, 0x5BB84C80, 0x58380008, 0xCB400078, 0x58380006, 0xCA400078,
+ 0x5F740002, 0x58380008, 0xC7500078, 0xCD000078, 0xC2000000, 0x58380004, 0xCA020078, 0xC3000000,
+ 0x5838000C, 0xCB000020, 0x5A640002, 0x46610000, 0x84000010, 0xC2400000, 0x58380006, 0xC6500078,
+ 0xCD000078, 0xC2000000, 0x5838000A, 0xCA020078, 0x5B300002, 0x5838000C, 0xC7100020, 0xCD000020,
+ 0xC2420020, 0x5A200004, 0x46252000, 0x84000010, 0xC2000000, 0x5838000A, 0xC6101078, 0xCD021078,
+ 0xC0004966, 0xCA4000F8, 0xC2000002, 0x6A3D0000, 0x72612000, 0xCE4000F8, 0x5F740000, 0x84000040,
+ 0xC0004912, 0xCA0000F8, 0xC2C00002, 0x6AFD6000, 0x7EC16000, 0x762D0000, 0xCE0000F8, 0x5F300020,
+ 0x84000040, 0xC0004924, 0xCA0000F8, 0xC2C00002, 0x6AFD6000, 0x7EC16000, 0x762D0000, 0xCE0000F8,
+ 0xA4820070, 0xC2400000, 0xC000140E, 0xCA408018, 0xC2000002, 0xC0004900, 0xCE000000, 0xC000490A,
+ 0xCE4000F8, 0xC1000000, 0xD90000F9, 0xD8400078, 0xC1000004, 0xD90000F9, 0xA48402A8, 0x00000000,
+ 0xC3C00000, 0xC000140E, 0xCBC10018, 0xC2800000, 0xC2000000, 0x6FF8A000, 0x6FD44000, 0x4795C000,
+ 0x47BDC000, 0x5BB87000, 0x5838002E, 0xCA800078, 0x58380006, 0xCA020078, 0xC3400000, 0x5838002E,
+ 0xCB420078, 0x5AA80002, 0x46A10000, 0x84000010, 0xC2800000, 0x5838002E, 0xC6900078, 0xCD000078,
+ 0x5F740002, 0x5838002E, 0xC7501078, 0xCD021078, 0xC0004968, 0xCA4000F8, 0xC2000002, 0x6A3D0000,
+ 0x72612000, 0xCE4000F8, 0xC000492A, 0xCA8000F8, 0x5E740000, 0x84000040, 0xC0004910, 0xCA0000F8,
+ 0xC2C00002, 0x6AFD6000, 0x7EC16000, 0x762D0000, 0xCE0000F8, 0x6ABD4010, 0xA68000F2, 0x00000000,
+ 0xC0004910, 0xCA0000F8, 0xC2C00002, 0x6AFD6000, 0x7EC16000, 0x762D0000, 0xCE0000F8, 0x58380032,
+ 0xCA0000F8, 0x58000002, 0xCA4000F8, 0x5838000C, 0x00000000, 0xCE0000F9, 0xCE4000F8, 0xC000492A,
+ 0xCA0000F8, 0xC2C00002, 0x6AFD6000, 0x722D0000, 0xCE0000F8, 0xC000492C, 0xCA0000F8, 0xC2C00002,
+ 0x6AFD6000, 0x722D0000, 0xCE0000F8, 0x80000040, 0xC000492C, 0xCA0000F8, 0xC2C00002, 0x6AFD6000,
+ 0x7EC16000, 0x762D0000, 0xCE0000F8, 0xA4880120, 0xC2C00000, 0xC000140E, 0xCAC20018, 0xC000490E,
+ 0xCA4000F8, 0xC2000002, 0x6A2D0000, 0x7E010000, 0x76612000, 0xCE4000F8, 0xC000496A, 0xCA4000F8,
+ 0xC2000002, 0x6A2D0000, 0x72612000, 0xCE4000F8, 0x6EF0A000, 0x6ED44000, 0x47158000, 0x472D8000,
+ 0x5B307000, 0x58300000, 0xCA0000F8, 0x00000000, 0xC2400002, 0x76612000, 0x8400004A, 0xC24C0002,
+ 0xC6E40018, 0xC624C400, 0x58300010, 0xCA400500, 0x00000000, 0xC0001800, 0xCE4000F8, 0xA4860070,
+ 0xC2400000, 0xC000140E, 0xCA418018, 0xC2020002, 0xC0004900, 0xCE002100, 0xC0004908, 0xCE4000F8,
+ 0xC1000000, 0xD90000F9, 0xD8400078, 0xC1000004, 0xD90000F9, 0xA48C0048, 0xC2800002, 0xC000484A,
+ 0xCE8000F8, 0xC2800000, 0xC000474A, 0xCE8000F8, 0xC0004846, 0xCE8000F8, 0xC0001408, 0xCC8000F8,
+ 0xC10E0002, 0xD90C00F8, 0x8000EA78, 0xDFBC00F9, 0xC000496E, 0x99008638, 0xC94000F8, 0xC7D800F8,
+ 0x00000000, 0xC57000F8, 0x5EF00020, 0x88000148, 0x6F346000, 0x4771A000, 0x5B744C80, 0x58340008,
+ 0xC2400000, 0xCA400078, 0x00000000, 0xC2000000, 0x5A640002, 0xCE400078, 0x58340004, 0xCA000078,
+ 0x00000000, 0x00000000, 0x5E200002, 0xCE000078, 0xC0004912, 0xCA8000F8, 0xC2400002, 0x6A712000,
+ 0x72A54000, 0xCE8000F8, 0x5E200000, 0x84000052, 0xC000480A, 0xCA0000F8, 0xC0000408, 0xCA8000F8,
+ 0x76250000, 0x00000000, 0x72A14000, 0xCE8000F8, 0x80000038, 0xC0004914, 0xCA0000F8, 0x7E412000,
+ 0x00000000, 0x76250000, 0xCE0000F8, 0x800000D0, 0x6EF4A000, 0x6ED44000, 0x4755A000, 0x476DA000,
+ 0x5B747000, 0x5834002E, 0xC2400000, 0xCA420078, 0x00000000, 0xC2000000, 0x5A640002, 0xC6501078,
+ 0xCD021078, 0x58340006, 0xCA000078, 0x00000000, 0x00000000, 0x5A200002, 0xCE000078, 0xC0004910,
+ 0xCA4000F8, 0xC2000002, 0x6A2D0000, 0x72612000, 0xCE4000F8, 0xC2000002, 0x6A310000, 0xC000042A,
+ 0xCE0000F8, 0xC1040002, 0xD90C00F8, 0x00000000, 0x8000E7E8, 0x00000000, 0xC4980928, 0x9D000000,
+ 0xC5580028, 0xC0000838, 0xCD8400F8, 0xC1440200, 0xC1C03800, 0xC55C1070, 0xC000100E, 0x9D000000,
+ 0xCD8000F8, 0xC000100C, 0xCDC000F8, 0xC0004862, 0xC9C000F8, 0x00000000, 0x00000000, 0xD9D800F9,
+ 0xC0007800, 0x401C0000, 0x5DC07A00, 0x88000012, 0x5C000200, 0xCD8000F8, 0xC1F0000A, 0x715CA000,
+ 0xDD9800F8, 0xDD9C00F9, 0x41D8E000, 0xC5D40260, 0xC0001010, 0xCD4000F8, 0x6C9C8000, 0x45C8E000,
+ 0x45C8E000, 0x59DC0004, 0xC1601260, 0xC5D40260, 0x9D000000, 0xC0001012, 0xCD4000F8, 0x00000000,
+ 0x00000000, 0xD95800F8, 0x6D586000, 0x4594C000, 0x59984C80, 0xD99800F9, 0x5818000A, 0xC1800000,
+ 0xC9800078, 0xC0006E00, 0x6D5CA000, 0x401C0000, 0x40180000, 0xC94000F8, 0x58000002, 0x00000000,
+ 0xC9C000F8, 0xC0004930, 0xCD4000F8, 0xC0004932, 0xCDC000F8, 0x59980004, 0xC1C20020, 0xB59C0018,
+ 0x00000000, 0xC1800000, 0xDD9C00F9, 0x581C000A, 0xCD800078, 0x581C000C, 0xC1800000, 0xC9800020,
+ 0xC1C00002, 0xDD9400F8, 0x69D4E000, 0x5D980002, 0xCD800020, 0xC0004924, 0xC98000F8, 0x00000000,
+ 0x9D000000, 0x00000000, 0x719CC000, 0xCD8000F8, 0xC000492A, 0xC94000F8, 0xC1C00002, 0x69D8E000,
+ 0x7DC0C000, 0x7558A000, 0xCD4000F8, 0xC000492C, 0xC94000F8, 0xDD8000F9, 0x58000032, 0x755CA000,
+ 0x84000090, 0xC94000F9, 0xC98000F8, 0xDD8000F9, 0x5800000C, 0x00000000, 0xCD4000F9, 0xCD8000F8,
+ 0xC000492C, 0xC94000F8, 0xC000492A, 0xC98000F8, 0x715CA000, 0xC000492C, 0xCD4000F8, 0x719CC000,
+ 0xC000492A, 0xCD8000F8, 0x9D000000, 0x00000000, 0x00000000, 0x00000000, 0xC0004862, 0xC98000F8,
+ 0x00000000, 0xC1C00200, 0x4194C000, 0x459CE000, 0x88000012, 0xC5D800F8, 0xC0004862, 0xCD8000F8,
+ 0xC0001406, 0xC98000F8, 0xC1C00002, 0x9D000000, 0xC5D80A00, 0xC5581048, 0xCD8000F8, 0xC0004930,
+ 0xC98000F8, 0xC0004932, 0xC9C000F8, 0xC140000E, 0xC5581C18, 0xDD9400F8, 0xC0007800, 0x40140000,
+ 0x5D407A00, 0x88000012, 0x5C000200, 0xCD8000F8, 0x58000002, 0x5D407A00, 0x88000012, 0x5C000200,
+ 0xCDC000F8, 0xDD5400F8, 0xC1C00000, 0x58140006, 0xC9C20078, 0xC1800000, 0x58140000, 0xC98000D8,
+ 0x6DDC2000, 0xC000491E, 0x41D8E000, 0xCDC000F8, 0xDD9800F8, 0xC1C00022, 0xC5D80D70, 0xDD9400F9,
+ 0xC5581C18, 0xC000491C, 0xCD8000F8, 0xDD5400F8, 0xC1C00000, 0x58140006, 0xC9C20078, 0xC1800000,
+ 0x58140004, 0xC9820078, 0x00000000, 0x59DC0002, 0x45D8C000, 0x84000010, 0xC1C00000, 0x9D000000,
+ 0x58140006, 0xC5D81078, 0xCD821078, 0xC0004860, 0xC94000F8, 0xC1820080, 0xC1D00002, 0x58147700,
+ 0xD58000F8, 0x58000002, 0xD58000F9, 0x59540004, 0xB5580018, 0xC0004860, 0xC1400000, 0xCD4000F8,
+ 0xDD9800F9, 0x9D000000, 0xDD9400F8, 0xC0001404, 0xCDC10800, 0xC1C00000, 0xC1800200, 0x5D980004,
+ 0xDF5D0048, 0x459CA000, 0x8800FFF2, 0xDD8000F9, 0x5800000C, 0x00000000, 0xC94000F9, 0xC98000F8,
+ 0xC1C00002, 0xC5D43F00, 0xC5D81E00, 0xC0004862, 0xC9C000F8, 0x00000000, 0x00000000, 0x581C7800,
+ 0x5DC07A00, 0x88000012, 0x5C000200, 0xCD4000F8, 0x58000002, 0x5DC07A00, 0x88000012, 0x5C000200,
+ 0xCD8000F8, 0xC0004862, 0xC9C000F8, 0x00000000, 0xC15004C0, 0xC5D40060, 0xDD9C00F8, 0xC5D41C18,
+ 0xC1C00000, 0xDD8000F9, 0x58000030, 0xC9C00078, 0xDD8000F9, 0x58000002, 0xC98000F8, 0x6DDC2000,
+ 0xC000491C, 0x41D8E000, 0xCD4000F9, 0xCDC000F8, 0xDD9400F9, 0xC1C00000, 0x58140030, 0xC9C00078,
+ 0xC1800000, 0x58140006, 0xC9820078, 0x00000000, 0x59DC0002, 0x45D8C000, 0x84000010, 0xC1C00000,
+ 0x9D000000, 0x58140030, 0xC5D80078, 0xCD800078, 0xC1C00000, 0xDF5C0038, 0x5DDC0080, 0x8400FFEA,
+ 0x00000000, 0x9D000000, 0x00000000, 0x00000000, 0x00000000, 0xC160FFFE, 0xC0000A10, 0xC9440060,
+ 0xC1A0FFFE, 0x59983008, 0xC000100C, 0xCD4000F8, 0xC000100E, 0xCD8000F8, 0xC0004964, 0xC98000F8,
+ 0x00000000, 0xC170000A, 0x7158A000, 0x6C988000, 0x4588C000, 0x4588C000, 0x59980004, 0xC5940270,
+ 0xC0001010, 0xCD4000F8, 0xC0004946, 0xC94000F8, 0x00000000, 0x00000000, 0x6D58A000, 0x6D5C4000,
+ 0x459CC000, 0x4594C000, 0xC000494A, 0xC94000F8, 0xC0004948, 0xC9C000F8, 0x4194C000, 0xC1400012,
+ 0xC55C1818, 0x9D000000, 0xC59C0268, 0xC0001012, 0xCDC000F8, 0xC1400000, 0x58000012, 0xC9410038,
+ 0xC0004950, 0xC9C000F8, 0xC55800F8, 0xC5940838, 0xC5581078, 0xD99400F8, 0xC000493C, 0xC94000F8,
+ 0xC0004954, 0xC98000F8, 0x59DC00A8, 0x45D4E000, 0x41D8E000, 0x5D5C0030, 0x88000010, 0xC1C00030,
+ 0xC1800000, 0xC5D84028, 0xC1400000, 0xC5D40008, 0x5DD40002, 0x84000072, 0x5DD40004, 0x8400009A,
+ 0x5DD40006, 0x840000C2, 0x5DD80026, 0x840000EA, 0xDD5400F8, 0xDD8000F9, 0x58000008, 0x40180000,
+ 0xCD4000F8, 0x59980002, 0x8000FFC0, 0xDD5400F8, 0xDD8000F9, 0x58000008, 0x40180000, 0xCD4000B8,
+ 0x59980002, 0x8000FF88, 0xDD5400F8, 0xDD8000F9, 0x58000008, 0x40180000, 0xCD400078, 0x59980002,
+ 0x8000FF50, 0xDD5400F8, 0xDD8000F9, 0x58000008, 0x40180000, 0xCD400038, 0x59980002, 0x8000FF18,
+ 0x00000000, 0x9D000000, 0x00000000, 0x00000000, 0x00000000, 0x58000012, 0xC94000F8, 0xC0004954,
+ 0xC9C000F8, 0xC0004950, 0xC9400078, 0xDD8000F9, 0x58000028, 0x5D9C0000, 0x84000052, 0x5D9C0002,
+ 0x84000052, 0x5D9C0004, 0x8400006A, 0xC55B0038, 0xC55C08B8, 0xCD800039, 0xCDC108B8, 0x80000060,
+ 0xCD4000F8, 0x80000050, 0xC55900B8, 0xC55C1838, 0xCD8000B9, 0xCDC31838, 0x80000028, 0xC55A0078,
+ 0xC55C1078, 0xCD800079, 0xCDC21078, 0x9D000000, 0x00000000, 0x00000000, 0x00000000, 0x59540002,
+ 0x6994E018, 0x61C0C008, 0x4194A000, 0x5D940040, 0x88000012, 0xC59400F8, 0x9D000000, 0xCD4000F8,
+ 0x00000000, 0x00000000, 0x9D000000, 0x4158A000, 0xCD4000F8, 0x00000000, 0xCD8000F9, 0x45408000,
+ 0x8800FFF0, 0x00000000, 0x9CC00000, 0x00000000, 0x00000000, 0x00000000, 0xC0004810, 0xCA010038,
+ 0xC241FFFE, 0xC1400000, 0x46148000, 0x00000000, 0x9CC00006, 0xC0004200, 0x40180000, 0xC9C000F8,
+ 0x00000000, 0x00000000, 0x61C08010, 0x8400005A, 0xC2400002, 0x6A512000, 0x71E4E000, 0xCDC000F8,
+ 0xC0004748, 0xCD8000F8, 0x9CC00000, 0x6D98A000, 0x5998003E, 0x45912000, 0x59540002, 0x59980002,
+ 0x46188000, 0xC1000000, 0xC51800FE, 0x8000FF38, 0x00000000, 0x40180000, 0xC9C000F8, 0xC2000000,
+ 0xC5600020, 0xC1210000, 0x69208010, 0x7D008000, 0x75D0E000, 0xCDC000F8, 0x6D542000, 0x58144300,
+ 0xC1000000, 0xCD0000F9, 0x9CC00000, 0xC121FFFE, 0x5911FFFE, 0xCD0000F9, 0x79588000, 0x6D10A010,
+ 0x5D100000, 0x840000C0, 0x45948000, 0x880000B0, 0x6D536000, 0x6D136010, 0x6D54A010, 0xC0004700,
+ 0x40140000, 0xCA0000F8, 0x00000000, 0x00000000, 0x6A110000, 0x6A110010, 0x62008018, 0x84000032,
+ 0x00000000, 0x9CC00000, 0x6D54A000, 0x5954003E, 0x45512000, 0x59540002, 0x6D57A000, 0x6D57A010,
+ 0x6D54A000, 0x6D936000, 0x6D136010, 0xC1E10000, 0x69D0E010, 0x5DDC0002, 0x7DC0E000, 0x6D98A010,
+ 0x6D536000, 0x6D136010, 0x6D54A010, 0xC0004700, 0x40140000, 0xCA0000F8, 0x00000000, 0x00000000,
+ 0x6A110000, 0x6A110010, 0x45588000, 0x00000000, 0x761D0002, 0x62008018, 0x84000032, 0x00000000,
+ 0x9CC00000, 0x6D54A000, 0x5954003E, 0x45512000, 0x45588000, 0x00000000, 0x9CC00002, 0x59540002,
+ 0x6D57A000, 0x6D57A010, 0xC0004700, 0x40140000, 0xCA0000F8, 0x8000FF68, 0x00000000, 0x00000000,
+ 0x00000000, 0x58004700, 0xC98000F8, 0x9CC00000, 0x00000000, 0x6994C000, 0x6DA7E010, 0x58004700,
+ 0xC98000F8, 0xC1210000, 0x9CC00000, 0x69148010, 0x7190C000, 0xCD8000F8, 0xC1000000, 0xC0004810,
+ 0xC9020038, 0x00000000, 0x00000000, 0x45D0C000, 0x88000062, 0xC2400002, 0x45588000, 0xC1000000,
+ 0xC52400FC, 0x45D48000, 0xC1000000, 0xC52400FE, 0x9CC00000, 0x00000000, 0x00000000, 0x00000000,
+ 0x59980200, 0xC2400000, 0x455C8000, 0xC1000002, 0xC52400FC, 0x45948000, 0xC1000002, 0xC52400FE,
+ 0x9CC00000, 0x00000000, 0x00000000, 0x00000000, 0xC0004740, 0xC9C000F8, 0x59180002, 0x6D130000,
+ 0x6D130010, 0x451C8000, 0xC2400000, 0x9CC00002, 0x00000000, 0x00000000, 0x459C8000, 0x88000062,
+ 0xC2400002, 0x455C8000, 0xC1000000, 0xC52400FC, 0x45948000, 0xC1000000, 0xC52400FC, 0x9CC00000,
+ 0x00000000, 0x00000000, 0x00000000, 0xC2400000, 0x45588000, 0xC1000002, 0xC52400FE, 0x45D48000,
+ 0xC1000002, 0xC52400FE, 0x9CC00000, 0x00000000, 0x00000000, 0x00000000, 0x59540002, 0x6D570000,
+ 0x6D570010, 0x45588000, 0x6D402000, 0x9CC00002, 0x58004300, 0x58000000, 0xC13C0002, 0xCD03DE00,
+ 0x8000FFB0, 0x00000000, 0x00000000, 0x00000000, 0xC1020002, 0xD90C00F8, 0xC98000F8, 0x59540002,
+ 0xC0004730, 0xCD4000F8, 0x5D980002, 0x00000000, 0x80000036, 0x00000000, 0x9CC00000, 0xC0004732,
+ 0xCD8000F8, 0x00000000, 0xC0004734, 0xC9C000F8, 0xC1800000, 0xC0004816, 0xC9820078, 0xC0004738,
+ 0xCDC000F8, 0xC1C00000, 0xC0004734, 0x9CC00000, 0xCDC000F8, 0xC0004732, 0xCD8000F8,
+};
+
+static unsigned int firmware_binary_data[] = {
+};
+
+
+#endif // IFXMIPS_ATM_FW_AR9_H
diff --git a/package/platform/lantiq/ltq-atm/src/ifxmips_atm_fw_danube.h b/package/platform/lantiq/ltq-atm/src/ifxmips_atm_fw_danube.h
new file mode 100644
index 0000000..57b7586
--- /dev/null
+++ b/package/platform/lantiq/ltq-atm/src/ifxmips_atm_fw_danube.h
@@ -0,0 +1,442 @@
+#ifndef IFXMIPS_ATM_FW_DANUBE_H
+#define IFXMIPS_ATM_FW_DANUBE_H
+
+
+/******************************************************************************
+**
+** FILE NAME : ifxmips_atm_fw_danube.h
+** PROJECT : Danube
+** MODULES : ATM (ADSL)
+**
+** DATE : 1 AUG 2005
+** AUTHOR : Xu Liang
+** DESCRIPTION : ATM Driver (PP32 Firmware)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 4 AUG 2005 Xu Liang Initiate Version
+** 23 OCT 2006 Xu Liang Add GPL header.
+*******************************************************************************/
+
+
+#define VER_IN_FIRMWARE 1
+
+#define ATM_FW_VER_MAJOR 0
+#define ATM_FW_VER_MINOR 17
+// fix 1 upstream packet stuck in TX queue issue
+// add multiple queue per PVC feature
+
+
+static unsigned int danube_fw_bin[] = {
+ 0x800004A0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8000FFC8, 0x00000000, 0x00000000, 0x00000000,
+ 0xC1000002, 0xD90C0000, 0xC2000002, 0xDA080001, 0x80004968, 0xC2000000, 0xDA080001, 0x80003FD0,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x80003F88, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x80005160, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x80003E88, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC0400000, 0xC0004840, 0xC8840000, 0x80004628, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC0400002, 0xC0004840, 0xC8840000, 0x800045A8, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC3C00004, 0xDBC80001, 0xC10C0002, 0xD90C0000, 0x8000FEC8, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC10E0002, 0xD90C0000, 0xC0004808, 0xC8400000, 0x800045D8, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC3E1FFFE, 0x597DFFFE, 0x593DFE14, 0x900004D9, 0x00000000, 0x00000000, 0x00000000, 0x90CC0481,
+ 0x00000000, 0x00000000, 0x00000000, 0xC3C00000, 0xDBC80001, 0xC1400008, 0xC1900000, 0x71948000,
+ 0x15000100, 0xC140000A, 0xC1900002, 0x71948000, 0x15000100, 0xC140000C, 0xC1900004, 0x71948000,
+ 0x15000100, 0xC1400004, 0xC1900006, 0x71948000, 0x15000100, 0xC1400006, 0xC1900008, 0x71948000,
+ 0x15000100, 0xC140000E, 0xC190000A, 0x71948000, 0x15000100, 0xC1400000, 0xC190000C, 0x71948000,
+ 0x15000100, 0xC1400002, 0xC190000E, 0x71948000, 0x15000100, 0xC0400000, 0xC11C0000, 0xC000082C,
+ 0xCD040E08, 0xC11C0002, 0xC000082C, 0xCD040E08, 0xC0400002, 0xC11C0000, 0xC000082C, 0xCD040E08,
+ 0xC11C0002, 0xC000082C, 0xCD040E08, 0xC0000824, 0x00000000, 0xCBC00001, 0xCB800001, 0xCB400001,
+ 0xCB000000, 0xC0004878, 0x5BFC4000, 0xCFC00001, 0x5BB84000, 0xCF800001, 0x5B744000, 0xCF400001,
+ 0x5B304000, 0xCF000000, 0xC0000A10, 0x00000000, 0xCBC00001, 0xCB800000, 0xC0004874, 0x5BFC4000,
+ 0xCFC00001, 0x5BB84000, 0xCF800000, 0xC30001FE, 0xC000140A, 0xCF000000, 0xC3000000, 0x7F018000,
+ 0xC000042E, 0xCF000000, 0xC000040E, 0xCF000000, 0xC3C1FFFE, 0xC000490E, 0xCFC00080, 0xC000492C,
+ 0xCFC00080, 0xC0004924, 0xCFC00040, 0xC0004912, 0xCFC00040, 0xC0004966, 0xCFC00040, 0xC0004968,
+ 0xCFC00080, 0xC000496A, 0xCFC00080, 0xC3C1FFFE, 0xC00049A0, 0xCFC00000, 0xC3C00000, 0xC2800020,
+ 0xC3000000, 0x7F018000, 0x6FF88000, 0x6FD44000, 0x4395C000, 0x5BB84A00, 0x5838000A, 0xCF000000,
+ 0x5BFC0002, 0xB7E8FFA8, 0x00000000, 0xC3C00000, 0xC2800010, 0x6FF86000, 0x47F9C000, 0x5BB84C80,
+ 0xC3400000, 0x58380004, 0xCB420080, 0x00000000, 0x58380008, 0xCF400080, 0x5BFC0002, 0xB7E8FF90,
+ 0x00000000, 0xC3C00000, 0xC2800020, 0xC348001E, 0xC3000000, 0x7F018000, 0x6FF8A000, 0x6FD44000,
+ 0x4579C000, 0x47F9C000, 0x5BB84E20, 0x58380008, 0xCF400420, 0x5838000A, 0xCF000000, 0x5BFC0002,
+ 0xB7E8FF90, 0x00000000, 0x00000000, 0xC3E02242, 0x5BFC0022, 0xC0004002, 0xCFC00000, 0x00000000,
+ 0xC121FFFE, 0x5911FE14, 0x15000000, 0x80000518, 0x00000000, 0x80002118, 0x00000000, 0x8000FFC8,
+ 0xC0004958, 0xC8400000, 0x00000000, 0xC3C00002, 0x7BC42000, 0xCC400000, 0xC0004848, 0xCB840000,
+ 0xC000495C, 0xCAC40000, 0xC0004844, 0xC8840000, 0x46F90000, 0x8400FF6A, 0xC000487C, 0xC8040000,
+ 0x00000000, 0x00000000, 0x40080000, 0xCA000000, 0xC0001624, 0xCB040000, 0xA63C005A, 0x00000000,
+ 0x00000000, 0xA71EFF02, 0x00000000, 0xC0000824, 0xCA840000, 0x6CA08000, 0x6CA42000, 0x46610000,
+ 0x42290000, 0xC35E0002, 0xC6340068, 0xC0001624, 0xCF440080, 0xC2000000, 0xC161FFFE, 0x5955FFFE,
+ 0x15400000, 0x00000000, 0xC0004844, 0xC8840000, 0xC000082C, 0xCA040040, 0x00000000, 0x00000000,
+ 0x58880002, 0xB608FFF8, 0x00000000, 0xC0800000, 0xC0004844, 0xCC840040, 0x5AEC0002, 0xC000495C,
+ 0xCEC40000, 0x5E6C0006, 0x84000048, 0xC0004848, 0xCB840000, 0xC0000838, 0xC2500002, 0xCE440808,
+ 0x5FB80002, 0xC0004848, 0xCF840000, 0x5EEC0002, 0xC000495C, 0xCEC40000, 0x00000000, 0xC121FFFE,
+ 0x5911FE14, 0x15000000, 0x8000FD80, 0xC000495A, 0xC8400000, 0x00000000, 0xC3C00002, 0x7BC42000,
+ 0xCC400000, 0xC0004960, 0xCAC40000, 0x00000000, 0x00000000, 0x5EEC0000, 0x840000F2, 0x00000000,
+ 0xB6FC0030, 0xC0001600, 0xCA040000, 0x00000000, 0x00000000, 0xA61E00B2, 0x6FE90000, 0xC0000A28,
+ 0xCE840808, 0xC2C00000, 0xC2800004, 0xB6E80080, 0xC0001604, 0xCA840000, 0xC0004960, 0xCEC40000,
+ 0xA69EFCA2, 0x00000000, 0x6FE90000, 0xC0000A28, 0xCE840808, 0xC2C00002, 0xC0001600, 0xCA040000,
+ 0x00000000, 0x00000000, 0xA61E000A, 0x6FE90000, 0xC0000A28, 0xCE840808, 0xC2C00000, 0xC0001604,
+ 0xCA840000, 0xC0004960, 0xCEC40000, 0xA69EFC0A, 0xC2400000, 0xC0000A14, 0xCA440030, 0x00000000,
+ 0x00000000, 0x46E52000, 0xA4400000, 0xC2800000, 0xDFEB0031, 0x8000FFF8, 0xDFEA0031, 0xB668FB82,
+ 0x00000000, 0xC00048A0, 0xCB040000, 0xC0000A10, 0xCA840000, 0x6F208000, 0x6F242000, 0x46610000,
+ 0x42A10000, 0xC2400000, 0xC0000A14, 0xCA440030, 0xC35E0002, 0xC6340068, 0xC0001604, 0xCF440080,
+ 0x5B300002, 0xB670FFF8, 0x5AEC0002, 0xC3000000, 0xC00048A0, 0xCF040000, 0xC0004960, 0xCEC40000,
+ 0x8000FAC0, 0xC0004918, 0xD2800000, 0xC2000000, 0xDF600040, 0x5E600080, 0x8400025A, 0x00000000,
+ 0xC161FFFE, 0x5955FFFE, 0x15400000, 0x00000000, 0xC000480A, 0xCA000000, 0xC0004912, 0xCA400000,
+ 0xC0004924, 0xCA800000, 0xC0004966, 0xCAC00000, 0x00000000, 0xC121FFFE, 0x5911FE14, 0x15000000,
+ 0x76610000, 0x76A10000, 0x76E10000, 0x840001B2, 0xC0004918, 0xCA400000, 0xC28001FE, 0x76A10000,
+ 0x5A640002, 0x6A254010, 0x5EE80000, 0x84000002, 0x6AA54000, 0x8000FFF8, 0xC6280000, 0x62818008,
+ 0xC0004918, 0xCF000000, 0xC161FFFE, 0x5955FFFE, 0x15400000, 0x00000000, 0xC0004966, 0xCA400000,
+ 0xC2000002, 0x6A310000, 0x7E010000, 0x76252000, 0xCE400000, 0x00000000, 0xC121FFFE, 0x5911FE14,
+ 0x15000000, 0x6F346000, 0x4735A000, 0x5B744C80, 0xC2800000, 0x58340006, 0xCA800080, 0xC2C00000,
+ 0x58340000, 0xCAC000E0, 0xC2400000, 0x5834000A, 0xCA420080, 0x6EA82000, 0x42E9E000, 0x6F2CA000,
+ 0x42E56000, 0x5AEC1400, 0xC3990040, 0xC7381C20, 0xC6F80068, 0x99005B78, 0xDB980000, 0xDBD80001,
+ 0x00000000, 0xDEA00000, 0x47210000, 0x8400FD68, 0xC0004958, 0xC8400000, 0x00000000, 0xC3C00002,
+ 0x7BC42000, 0xCC400000, 0xC0004848, 0xCB840000, 0xC0004844, 0xC8840000, 0x5FB80000, 0x8400F7DA,
+ 0xC0001A1C, 0xCA000000, 0xC2400002, 0x6A452000, 0x76610000, 0x8400F7AA, 0xC000487C, 0xC8040000,
+ 0x00000000, 0x00000000, 0x40080000, 0xCA000000, 0xC4240000, 0x00000000, 0xA63C17BA, 0x00000000,
+ 0xC0004878, 0xC8040000, 0x6C908000, 0x44908000, 0x44908000, 0x40100000, 0xCA000000, 0xC4240000,
+ 0x00000000, 0xC0004934, 0xCE000000, 0xC2800002, 0xC4681C10, 0xC62821D8, 0xC2600010, 0x5A650040,
+ 0xC0004800, 0xCB400000, 0xC2200400, 0x5A200000, 0xC7601048, 0xC0001220, 0xCE800000, 0xC0001200,
+ 0xCE400000, 0xC0001202, 0xCE000000, 0xC0001240, 0xCB400000, 0x00000000, 0x00000000, 0xA754FFC0,
+ 0xC2000000, 0xC7600048, 0xA7520022, 0x00000000, 0x00000000, 0x990062F0, 0xC0004822, 0xC9400000,
+ 0xC1800002, 0x80001668, 0x58204080, 0xC2000000, 0xCA000020, 0xC2400000, 0xCA414008, 0xC2800000,
+ 0xCA812008, 0xC2C00000, 0xCAC20020, 0xC0004938, 0xCE000000, 0xC0004920, 0xCE400000, 0xC0004916,
+ 0xCE800000, 0xC0004922, 0xCEC00000, 0xA6400520, 0x00000000, 0xC0004938, 0xCBC00000, 0x00000000,
+ 0xC3800000, 0x6FF48000, 0x6FD44000, 0x4355A000, 0x5B744A00, 0x58340000, 0xCB802018, 0x00000000,
+ 0xC2000000, 0x6FB46000, 0x47B5A000, 0x5B744C80, 0x5834000C, 0xCA000028, 0xC000491A, 0xCF800000,
+ 0x5E200000, 0x84000452, 0xC2000000, 0xDF610050, 0x5E6001E8, 0x8800FFD0, 0xC2000002, 0xC2400466,
+ 0xC2A00000, 0x5AA80000, 0xC0001006, 0xCE000000, 0xC0001008, 0xCE400000, 0xC000100A, 0xCE800000,
+ 0x990055B8, 0xC1A0FFFE, 0xC0000824, 0xC9840068, 0xC0004934, 0xCA400000, 0xC2000000, 0xC2800002,
+ 0x990055F8, 0xDA980000, 0xC6140000, 0xC6580000, 0xC161FFFE, 0x5955FFFE, 0x15400000, 0x00000000,
+ 0x990056E0, 0xC000491A, 0xC9400000, 0x00000000, 0x00000000, 0xC121FFFE, 0x5911FE14, 0x15000000,
+ 0xC0004922, 0xCA001120, 0xC3C00000, 0xC3800000, 0xC0004930, 0xCE001120, 0xC0004932, 0xCBC000E0,
+ 0xC2800000, 0xC000491E, 0xCFC00000, 0xC0004862, 0xCA800068, 0xC3A0001A, 0x5BB94000, 0xC6B80068,
+ 0xC000491C, 0xCF800000, 0x99005950, 0xC000491C, 0xC1400000, 0xC9420050, 0x00000000, 0x00000000,
+ 0x00000000, 0xA8E2FFC8, 0xC2000000, 0xC1220002, 0xD90C0000, 0xDF600040, 0x5E600080, 0x8400FFDA,
+ 0xC000491C, 0xCA000000, 0xC000491E, 0xCA400000, 0x00000000, 0x00000000, 0x99005B78, 0xDA180000,
+ 0xDA580001, 0x00000000, 0xC2000000, 0xDF610050, 0x5E6001FE, 0x8800FFD0, 0xC0004916, 0xCA800000,
+ 0xC2C00000, 0xDFEC0050, 0xC2400000, 0x46E52000, 0x84000032, 0x5EA80000, 0x84000022, 0xC2600002,
+ 0x990062F0, 0xC000482E, 0xC9400000, 0xC1800002, 0x80000018, 0xC2600000, 0x990062F0, 0xC000482C,
+ 0xC9400000, 0xC1800002, 0xC2000068, 0xC6240080, 0xC0004930, 0xCE400088, 0xC000491A, 0xC9800000,
+ 0xC0004862, 0xC9400000, 0x6D9C6000, 0x459CE000, 0x59DC4C80, 0x990059D8, 0xD9580000, 0xD9980001,
+ 0xD9D40000, 0x99005950, 0xC000491C, 0xC1400000, 0xC9420050, 0xC2000000, 0xDF600040, 0x5E600080,
+ 0x8400FFD2, 0x00000000, 0xC000491C, 0xCA000000, 0xC000491E, 0xCA400000, 0x00000000, 0x00000000,
+ 0x99005B78, 0xDA180000, 0xDA580001, 0x00000000, 0x800010D0, 0x00000000, 0x990062F0, 0xC000482A,
+ 0xC9400000, 0xC1800002, 0x800010A0, 0xC0004938, 0xCBC00000, 0x00000000, 0x00000000, 0x6FF88000,
+ 0x6FD44000, 0x4395C000, 0x5BB84A00, 0x58380008, 0xCA000000, 0x00000000, 0x00000000, 0xA6000362,
+ 0x00000000, 0xC0004938, 0xCBC00000, 0xC3000000, 0x00000000, 0x6FF88000, 0x6FD44000, 0x4395C000,
+ 0x5BB84A00, 0x58380000, 0xCB002018, 0xC2000000, 0x58380008, 0xCA020080, 0x5838000C, 0xCAC00000,
+ 0x5838000E, 0xCA400000, 0xC000491A, 0xCF000000, 0xC0004930, 0xCEC00000, 0xC000493C, 0xCE000000,
+ 0xC0004932, 0xCE400000, 0x5E200000, 0x84000108, 0xC2800000, 0xA6FE009A, 0x6F206000, 0x47210000,
+ 0x5A204C80, 0x5820000C, 0xCA800028, 0x00000000, 0x00000000, 0x5EA80000, 0x840001DA, 0x00000000,
+ 0xC161FFFE, 0x5955FFFE, 0x15400000, 0x00000000, 0x990056E0, 0xC000491A, 0xC9400000, 0x00000000,
+ 0x00000000, 0xC121FFFE, 0x5911FE14, 0x15000000, 0xC0004930, 0xCAC00000, 0xC0004932, 0xCA400000,
+ 0xC7EC1120, 0xC0004930, 0xCEC00000, 0x5838000C, 0xCEC00000, 0x58000002, 0xCE400000, 0xC0004934,
+ 0xCA000000, 0xC2400002, 0x6E642000, 0x6E642000, 0x76252000, 0x84000012, 0xC2400002, 0x6E684000,
+ 0x58380008, 0xCE800208, 0xA6000000, 0x6E682000, 0x58380008, 0xCE800108, 0xC2400002, 0x6E642000,
+ 0x76252000, 0x840000D2, 0x58380008, 0xCA000000, 0xC2800000, 0xC2400000, 0xA60200A0, 0xDBA80000,
+ 0x6F386000, 0x4739C000, 0x5BB84C80, 0x58380004, 0xCA400080, 0x58380002, 0xCA800080, 0x00000000,
+ 0xDEB80000, 0x46694000, 0x88000048, 0x00000000, 0xC0004824, 0xCA000000, 0xC2400002, 0x6E640000,
+ 0x5A200002, 0xCE000000, 0x58380008, 0xCE400008, 0x80000000, 0x00000000, 0x80000030, 0xC0004934,
+ 0xCA000000, 0x00000000, 0x00000000, 0xA6020C4A, 0x00000000, 0x00000000, 0x80000C80, 0xC2800000,
+ 0xC2000200, 0xC240001A, 0xDF690050, 0x46A14000, 0x46694000, 0x8800FFBA, 0xC2000006, 0xC2600982,
+ 0x5A643B6E, 0x5838000A, 0xCA800000, 0xC0001006, 0xCE000000, 0xC0001008, 0xCE400000, 0xC000100A,
+ 0xCE800000, 0x990055B8, 0xC1A0FFFE, 0xC0000824, 0xC9840068, 0xC2000000, 0xC0004930, 0xCA02E010,
+ 0x58380026, 0xCA400000, 0x00000000, 0xC2800000, 0x990055F8, 0xDA980000, 0xC6140000, 0xC6580000,
+ 0xC0004934, 0xCA000000, 0x00000000, 0x00000000, 0xA6020002, 0x00000000, 0x00000000, 0x80000300,
+ 0xC0004938, 0xCBC00000, 0xC0004878, 0xC8040000, 0x6C908000, 0x44908000, 0x44908000, 0x40100000,
+ 0xCA000000, 0xC4240000, 0x00000000, 0x58240018, 0xCA000000, 0x6FF88000, 0x6FD44000, 0x4395C000,
+ 0x5BB84A00, 0xC3000000, 0xC3400002, 0xC2C00000, 0xC62C0080, 0xC6270040, 0xC0004940, 0xCE400040,
+ 0xC6260040, 0xC0004942, 0xCE400040, 0xC000493C, 0xCA000000, 0x5EEC0000, 0x84000172, 0x5A6C0010,
+ 0x46614000, 0x88000178, 0x5A600052, 0x466D4000, 0x88000160, 0x58380006, 0xCA800000, 0xC0004940,
+ 0xCA000000, 0xC2400000, 0xC6A70040, 0x7E412000, 0x76252000, 0xC2000000, 0xC6A10040, 0x46610000,
+ 0x84000120, 0xC0004942, 0xCA000000, 0xC2400000, 0xC6A60040, 0x7E412000, 0x76252000, 0xC2000000,
+ 0xC6A00040, 0x58380002, 0xCA800000, 0x46610000, 0x840000D0, 0xC2400000, 0xC6A60080, 0x46E50000,
+ 0x880000C2, 0xC2400000, 0xC6A40080, 0x58380008, 0xCA800000, 0x466D0000, 0x880000A2, 0x00000000,
+ 0xA682FFF8, 0x00000000, 0xC7700B08, 0xA6840078, 0x00000000, 0xC7700A08, 0x80000068, 0xC7700208,
+ 0xC000493C, 0xCAC00000, 0x80000048, 0xC7700308, 0xC000493C, 0xCAC00000, 0x80000028, 0xC7700908,
+ 0x80000018, 0xC7700808, 0x80000008, 0xC7700708, 0x8000FFF8, 0xC7700508, 0xC0004944, 0xCF000000,
+ 0xC000493E, 0xCEC00000, 0xC0004938, 0xCA400000, 0xC000493C, 0xCB800000, 0xC000493E, 0xCB400000,
+ 0xC3000000, 0x6E608000, 0x6E544000, 0x42150000, 0x5A204A00, 0x5AA00008, 0x58200004, 0xCB000080,
+ 0xC0004934, 0xCA000000, 0xC2400000, 0xC0004930, 0xCA42E010, 0xC3C00018, 0xA6020078, 0x00000000,
+ 0x43656000, 0x46F90000, 0x88000038, 0x47AD6000, 0x6EE04010, 0x5BE00004, 0xC2000000, 0xC6E00010,
+ 0x5E200000, 0x8400002A, 0x5BFC0002, 0x80000018, 0xC3C00004, 0x5A2C0008, 0x46390000, 0x8800FFFA,
+ 0x5FB80008, 0x6FE04000, 0x42390000, 0x46312000, 0x88000050, 0xC2400000, 0xC0004930, 0xCA42E010,
+ 0xC2060002, 0xC6800000, 0xCE000308, 0x6FE04000, 0x4631C000, 0x5F700010, 0x4675A000, 0xC2000000,
+ 0xC6340010, 0xC25A000A, 0xC000491A, 0xCA401C20, 0xC2800000, 0xC0004932, 0xCA8000E0, 0xC0004862,
+ 0xCA400068, 0x6FA04010, 0x42290000, 0xC000491E, 0xCE000000, 0xC7E41050, 0xC000491C, 0xCE400000,
+ 0x6FE04000, 0x43A1C000, 0xC000493C, 0xCF800000, 0xC000493E, 0xCF400000, 0xC000493A, 0xCFC00000,
+ 0x8000FFF0, 0x00000000, 0x00000000, 0x00000000, 0xC2000000, 0xDCE00000, 0xA622FFB8, 0xC1220002,
+ 0xD90C0000, 0xC0004938, 0xCBC00000, 0xC0004944, 0xCB400000, 0xC0004862, 0xCB000000, 0xC0004934,
+ 0xCA000000, 0x6FF88000, 0x6FD44000, 0x4395C000, 0x5BB84A00, 0xA6020248, 0xC2400000, 0x58380008,
+ 0xCA406008, 0xDFE80000, 0xC2218E08, 0x5A21BAF6, 0x46294000, 0x8400000A, 0xC2080002, 0x7235A000,
+ 0x80000040, 0x5E640000, 0x8400000A, 0xC20C0002, 0x7235A000, 0x80000018, 0xC2000000, 0xC760E718,
+ 0xC7604220, 0x5E200000, 0x8400025A, 0xC2200002, 0xC0004930, 0xCE001008, 0x990062F0, 0xC0004828,
+ 0xC9400000, 0xC1800002, 0x58380000, 0xCA000000, 0x00000000, 0x00000000, 0xA6000112, 0xC0004940,
+ 0xCA800000, 0xC0004942, 0xCA400000, 0xC7600080, 0xC6A01840, 0xC6601040, 0xC000493A, 0xCA400000,
+ 0xC0004934, 0xCA800000, 0xC0007200, 0x40300000, 0x40240000, 0x5C000004, 0x5EC07400, 0x8800FFFA,
+ 0x5C000200, 0xCE000000, 0x58000002, 0x5EC07400, 0x8800FFFA, 0x5C000200, 0xCE800000, 0xC000493E,
+ 0xCA000000, 0xC2400000, 0x5838000C, 0xCE400000, 0x990062F0, 0xC0004830, 0xC9400000, 0xC6180000,
+ 0xC0004930, 0xC6100080, 0xCD000080, 0x80000090, 0xC2400002, 0x58380008, 0xCE400008, 0xC0004944,
+ 0xCF400000, 0x80000260, 0xC000493C, 0xCA400000, 0xDFE80000, 0x5A300018, 0xC0007200, 0x40200000,
+ 0xCA000000, 0x58380008, 0xC6501080, 0xCD001080, 0x5838000A, 0xCE800000, 0x58380026, 0xCE000000,
+ 0xC0004944, 0xCF400000, 0x99005950, 0xC000491C, 0xC1400000, 0xC9420050, 0x80000020, 0x00000000,
+ 0x990062F0, 0xC0004826, 0xC9400000, 0xC1800002, 0x8000FDC0, 0xC2000000, 0xC2400080, 0xDF600040,
+ 0xB624FFCA, 0xC000491C, 0xCA400000, 0xC000491E, 0xCA800000, 0x99005B78, 0xDA580000, 0xDA980001,
+ 0x00000000, 0xC0004934, 0xCA000000, 0x00000000, 0xC2800000, 0xA6020140, 0xC2400004, 0xC2000200,
+ 0xDF690050, 0x46A14000, 0x46694000, 0x8800FFC2, 0x00000000, 0xC000491A, 0xC9800000, 0xC0004862,
+ 0xC9400000, 0x6D9C6000, 0x459CE000, 0x59DC4C80, 0x990059D8, 0xD9580000, 0xD9980001, 0xD9D40000,
+ 0x99005950, 0xC000491C, 0xC1400000, 0xC9420050, 0xC2000000, 0xC2400080, 0xDF600040, 0xB624FFCA,
+ 0xC000491C, 0xCA400000, 0xC000491E, 0xCA800000, 0x99005B78, 0xDA580000, 0xDA980001, 0x00000000,
+ 0x58380008, 0xCA400000, 0xC2000000, 0xCE000020, 0xC2A1FFFE, 0x5AA9FFFE, 0xCE001080, 0x5838000A,
+ 0xCE800000, 0xC161FFFE, 0x5955FFFE, 0x15400000, 0x00000000, 0xC0000838, 0xC2500002, 0xCE440808,
+ 0xC0004848, 0xCB840000, 0xC2000000, 0xC000082C, 0xCA040030, 0x5FB80002, 0xC0004848, 0xCF840000,
+ 0x58880002, 0xB608FFF8, 0x00000000, 0xC0800000, 0xC0004844, 0xCC840000, 0x00000000, 0xC121FFFE,
+ 0x5911FE14, 0x15000000, 0x8000DEC0, 0xC2000000, 0xDF600040, 0x5E200080, 0x84000252, 0x00000000,
+ 0xC161FFFE, 0x5955FFFE, 0x15400000, 0x00000000, 0xC000480C, 0xCA000000, 0xC0004910, 0xCA400000,
+ 0xC000492C, 0xCA800000, 0xC0004968, 0xCAC00000, 0x00000000, 0xC121FFFE, 0x5911FE14, 0x15000000,
+ 0x76610000, 0x76A10000, 0x762D6000, 0x840001AA, 0xC0004926, 0xCA400000, 0xC201FFFE, 0x762D6000,
+ 0x5A640002, 0x6AE50010, 0x5F200000, 0x84000002, 0x6A250000, 0x8000FFF8, 0xC6E00000, 0x62014008,
+ 0xC0004926, 0xCE800000, 0xC161FFFE, 0x5955FFFE, 0x15400000, 0x00000000, 0xC0004968, 0xCA400000,
+ 0xC2000002, 0x6A290000, 0x7E010000, 0x76252000, 0xCE400000, 0x00000000, 0xC121FFFE, 0x5911FE14,
+ 0x15000000, 0x6EB4A000, 0x6E944000, 0x4575A000, 0x46B5A000, 0x5B744E20, 0x58340002, 0xC2000000,
+ 0xCA0000E0, 0x5834002E, 0xC2400000, 0xCA400080, 0x6EB0A000, 0x6EBC4000, 0x47F18000, 0x46B18000,
+ 0x5B300E4E, 0x5B300004, 0x6E642000, 0x4225E000, 0xC39A8024, 0xC7380068, 0xC6B81C20, 0x99005B78,
+ 0xDB980000, 0xDBD80001, 0x00000000, 0xC2000000, 0xDF600040, 0x5E200080, 0x8400033A, 0x00000000,
+ 0xC161FFFE, 0x5955FFFE, 0x15400000, 0x00000000, 0xC000490E, 0xCA000000, 0xC00049A0, 0xCA800000,
+ 0xC000492A, 0xCA400000, 0xC000496A, 0xCB000000, 0xC0004956, 0xCAC00000, 0x00000000, 0xC121FFFE,
+ 0x5911FE14, 0x15000000, 0x76318000, 0x76718000, 0x76B18000, 0x84000282, 0xC201FFFE, 0x76318000,
+ 0x5AEC0002, 0x6B2D0010, 0x5EA00000, 0x84000002, 0x6A2D0000, 0x8000FFF8, 0xC7200000, 0x62016008,
+ 0xC0004956, 0xCEC00000, 0x6EF4A000, 0x6ED44000, 0x4575A000, 0x46F5A000, 0x5B744E20, 0x58340000,
+ 0xC9C00000, 0xC00049A0, 0xCA000000, 0xC3000000, 0xC5F04020, 0xC2400000, 0xC5E50040, 0x7E412000,
+ 0x76610000, 0xCE000000, 0xC0004980, 0x40300000, 0xCEC00000, 0xC161FFFE, 0x5955FFFE, 0x15400000,
+ 0x00000000, 0xC000496A, 0xCA400000, 0xC2000002, 0x6A2D0000, 0x7E010000, 0x76252000, 0xCE400000,
+ 0x00000000, 0xC121FFFE, 0x5911FE14, 0x15000000, 0x6EF4A000, 0x6ED44000, 0x4575A000, 0x46F5A000,
+ 0x5B744E20, 0x5834000E, 0xC2000000, 0xCA0000E0, 0x58340008, 0xC2400000, 0xCA420080, 0x5834000C,
+ 0xC2800000, 0xCA832018, 0x6E644010, 0x42250000, 0x4229E000, 0xC39A8008, 0x58340008, 0xCB809020,
+ 0x58340008, 0xC2800000, 0xCA810018, 0x6EE0A000, 0x6EE44000, 0x46610000, 0x46E10000, 0x5A200008,
+ 0x5A200E28, 0x42290000, 0xC6380068, 0xC6F81C20, 0x99005B78, 0xDB980000, 0xDBD80001, 0x00000000,
+ 0xC000495A, 0xC8400000, 0x00000000, 0xC3C00002, 0x7BC42000, 0xCC400000, 0xC0001A1C, 0xCA000000,
+ 0xC2400008, 0x6A452000, 0x76610000, 0x84000EAA, 0xC0000A28, 0xC3800000, 0xCB840030, 0xC0000A14,
+ 0xC3400000, 0xCB440030, 0xC0004880, 0xCB040000, 0xB7B40052, 0x58041802, 0xCAC00000, 0xA7000058,
+ 0x00000000, 0x00000000, 0xA6C8D7E8, 0xC1000000, 0xC6D00020, 0xC0004980, 0x40100000, 0xCA800000,
+ 0x80000058, 0x00000000, 0x00000000, 0x00000000, 0x8000D7A0, 0x00000000, 0xC2800000, 0xC7282020,
+ 0xC000490E, 0xCA400000, 0x6BE9E000, 0x00000000, 0x77E52000, 0x8400D758, 0x6EA0A000, 0x6E944000,
+ 0x45610000, 0x46A10000, 0x5A204E20, 0x5820000C, 0xCA000000, 0xC0004946, 0xCE800000, 0xA6220388,
+ 0x00000000, 0xC2200060, 0xC0004948, 0xCE000010, 0xCE001040, 0xC240000A, 0xC000494A, 0xCE400000,
+ 0xC2B60002, 0xC0004964, 0xCE801B08, 0x99005E48, 0xC00048A0, 0xC8840000, 0x00000000, 0xC0004946,
+ 0xCBC00000, 0x00000000, 0x00000000, 0x6FF8A000, 0x6FD44000, 0x4579C000, 0x47F9C000, 0x5BB84E20,
+ 0x99005C08, 0xDBD80000, 0xDB980001, 0x00000000, 0x99005950, 0xC000491C, 0xC1400000, 0xC9420050,
+ 0xC000491C, 0x99005E00, 0xC9400001, 0xC9800000, 0x00000000, 0x99005B78, 0xD9580000, 0xD9980001,
+ 0x00000000, 0xC161FFFE, 0x5955FFFE, 0x15400000, 0x00000000, 0x99005840, 0xDBD80000, 0xDB980001,
+ 0xC7D80000, 0x00000000, 0xC121FFFE, 0x5911FE14, 0x15000000, 0x6FF8A000, 0x6FD44000, 0x4579C000,
+ 0x47F9C000, 0x5BB84E20, 0x58380010, 0xCA000000, 0xC0004874, 0xC8040000, 0x6C908000, 0x44908000,
+ 0x44908000, 0x40100000, 0xCA400000, 0xC4340000, 0x00000000, 0xC7400000, 0xCE000000, 0xC161FFFE,
+ 0x5955FFFE, 0x15400000, 0x00000000, 0xC000490E, 0xCA400000, 0xC2800002, 0x6ABD4000, 0x72A52000,
+ 0xCE400000, 0x00000000, 0xC121FFFE, 0x5911FE14, 0x15000000, 0x990062F0, 0xC0004836, 0xC9400000,
+ 0xC1800002, 0x00000000, 0x00000000, 0x00000000, 0xA8E2FFC8, 0x00000000, 0x58380000, 0xC9000000,
+ 0xC00049A0, 0xCA000000, 0xC2800000, 0xC5290040, 0x72A10000, 0xCE000000, 0xC1220002, 0xD90C0000,
+ 0xC2000000, 0xC0000A14, 0xCA040030, 0xC0000A28, 0xC2500002, 0xCE440808, 0x58880002, 0xB608FFF8,
+ 0xC00048A0, 0xC0800000, 0xCC840000, 0x8000D368, 0xC0004946, 0xCBC00000, 0xC161FFFE, 0x5955FFFE,
+ 0x15400000, 0x00000000, 0xC000490E, 0xCA400000, 0xC2800002, 0x6ABD4000, 0x72A52000, 0xCE400000,
+ 0x00000000, 0xC121FFFE, 0x5911FE14, 0x15000000, 0x6FF8A000, 0x6FD44000, 0x4579C000, 0x47F9C000,
+ 0x5BB84E20, 0x58380008, 0xCA000000, 0x5838000C, 0xCA400000, 0xC3400000, 0xC6340008, 0xC000494E,
+ 0xCF400000, 0xC2800000, 0xC62A0080, 0xC3000000, 0xC6308020, 0x6F304000, 0x43298000, 0xC000493C,
+ 0xCF000000, 0xC2C00000, 0xC66C0080, 0xC0004950, 0xCEC00000, 0xC2800000, 0xC66AE028, 0xC0004954,
+ 0xCE800000, 0x5F740000, 0x84000188, 0x5E300028, 0x462D2000, 0x84000152, 0x462D2000, 0x8800011A,
+ 0x5E300018, 0x462D2000, 0x88000012, 0x462D2000, 0x8400002A, 0x00000000, 0x800000A8, 0x00000000,
+ 0x99005F88, 0xDBD80000, 0xDB980001, 0xC7800000, 0xC3400002, 0xC000494E, 0xCF400000, 0xC161FFFE,
+ 0x5955FFFE, 0x15400000, 0x00000000, 0xC000490E, 0xCA400000, 0xC2800002, 0x6ABD4000, 0x7E814000,
+ 0x76A52000, 0xCE400000, 0x00000000, 0xC121FFFE, 0x5911FE14, 0x15000000, 0xC2200060, 0xC0004948,
+ 0xCE001040, 0xC2000000, 0xC000494C, 0xCE000000, 0x80000068, 0x00000000, 0x99005F88, 0xDBD80000,
+ 0xDB980001, 0xC7800000, 0x99006188, 0xDBD80000, 0xDB980001, 0xC7800000, 0xC2200058, 0xC0004948,
+ 0xCE001040, 0xC2000002, 0xC000494C, 0xCE000000, 0xC2000006, 0xC0001006, 0xCE000000, 0x5838000A,
+ 0xCA400000, 0xC2200982, 0x5A203B6E, 0xC0001008, 0xCE000000, 0xC000100A, 0xCE400000, 0xC0004954,
+ 0xCA800000, 0xC200000C, 0xC000494A, 0xCE000000, 0xC0004948, 0xCE800010, 0xC2B60000, 0xC0004964,
+ 0xCE800000, 0x99005E48, 0xC00048A0, 0xC8840000, 0x00000000, 0xC0004946, 0xCBC00000, 0xC000494C,
+ 0xCA000000, 0x6FF8A000, 0x6FD44000, 0x4579C000, 0x47F9C000, 0x5BB84E20, 0x5E200000, 0x840000E2,
+ 0x00000000, 0x99005C08, 0xDBD80000, 0xDB980001, 0x00000000, 0x99005950, 0xC000491C, 0xC1400000,
+ 0xC9420050, 0xC000491C, 0x99005E00, 0xC9400001, 0xC9800000, 0x00000000, 0x99005B78, 0xD9580000,
+ 0xD9980001, 0x00000000, 0xC161FFFE, 0x5955FFFE, 0x15400000, 0x00000000, 0x99005840, 0xDBD80000,
+ 0xDB980001, 0xC7D80000, 0x00000000, 0xC121FFFE, 0x5911FE14, 0x15000000, 0xC000493C, 0xCA800000,
+ 0xC000494E, 0xCAC00000, 0xC3000018, 0xC3400006, 0x5E200000, 0x84000012, 0xC2800000, 0xC2C00000,
+ 0xC300001E, 0xC3400000, 0xC6AC1080, 0xC72C0420, 0xC76C0818, 0x58380010, 0xCA800000, 0x58380008,
+ 0xCEC00000, 0xC6280108, 0xC0004874, 0xC8040000, 0x6C908000, 0x44908000, 0x44908000, 0x40100000,
+ 0xCB000000, 0xC4340000, 0x00000000, 0xC7400000, 0xCE800000, 0xC0004952, 0xCE800000, 0x00000000,
+ 0x00000000, 0x00000000, 0xA8E2FFC8, 0x00000000, 0xC000494C, 0xCA000000, 0xC0004950, 0xCAC00000,
+ 0x5E200000, 0x84000052, 0xDFE80000, 0x7E814000, 0x5834001A, 0xCE800000, 0x990062F0, 0xC0004834,
+ 0xC9400000, 0xC1800002, 0x990062F0, 0xC0004838, 0xC9400000, 0xC6D80000, 0xC1220002, 0xD90C0000,
+ 0x5E200000, 0x84000028, 0x5838002C, 0xCB000000, 0xDFE80000, 0x00000000, 0x58380014, 0xCF000000,
+ 0x80000040, 0xC2A1FFFE, 0x5AA9FFFE, 0x58380000, 0xC9000000, 0xC00049A0, 0xCB000000, 0xC2C00000,
+ 0xC52D0040, 0x72F18000, 0xCF000000, 0x5838000A, 0xCE800000, 0xC3000000, 0xC0000A14, 0xCB040030,
+ 0xC2D00002, 0xC0000A28, 0xCEC40808, 0xC000494E, 0xCA800000, 0x58880002, 0xB4B0FFF8, 0xC00048A0,
+ 0xC0800000, 0xCC840000, 0x5EA80000, 0x84000162, 0x5E200000, 0x84000150, 0xC000493C, 0xCA800000,
+ 0x00000000, 0x00000000, 0x5AA80060, 0xCE800000, 0x99005F88, 0xDBD80000, 0xDB980001, 0xC7800000,
+ 0x99006188, 0xDBD80000, 0xDB980001, 0xC7800000, 0x58380000, 0xCAC00000, 0x00000000, 0xC2000000,
+ 0xC6E04020, 0xC0004952, 0xCAC00000, 0x58380000, 0xCA800000, 0xC30C0002, 0xC6300020, 0xA6800078,
+ 0x00000000, 0x00000000, 0xC161FFFE, 0x5955FFFE, 0x15400000, 0x00000000, 0xC0001800, 0xCA000000,
+ 0x00000000, 0x00000000, 0xA60CFFCA, 0xC6F00508, 0xC6B0C408, 0xCF000000, 0x00000000, 0xC121FFFE,
+ 0x5911FE14, 0x15000000, 0x8000C9B0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8000C948,
+ 0xDCBC0001, 0x5FFC0000, 0x8400003A, 0xC3800002, 0xDB880001, 0x5FFC0004, 0x8400C27A, 0xC3800000,
+ 0xDB880001, 0xC3CE0002, 0xC0000800, 0xCFC00708, 0xC3E1FFFE, 0x597DFFFE, 0x593DFE14, 0x94000001,
+ 0x00000000, 0x00000000, 0x00000000, 0xC000487C, 0xC8040000, 0x00000000, 0x00000000, 0x40080000,
+ 0xCBC00000, 0xC4380000, 0x00000000, 0xC000480E, 0xCA000000, 0xC0004858, 0xCB440000, 0x00000000,
+ 0x00000000, 0x46350000, 0x88000098, 0x00000000, 0xA7C00028, 0xC0004854, 0xC1000002, 0xCD040000,
+ 0xC11C0000, 0xC000082C, 0xCD040E08, 0x800000C0, 0x00000000, 0xA7D20118, 0x00000000, 0xC7E14048,
+ 0xC2400000, 0xC6246030, 0xC200006A, 0x46610000, 0xC6240038, 0xC0000810, 0xCE440038, 0x8000FF58,
+ 0xC2000000, 0xC0000808, 0xCA040018, 0xC11C0000, 0xC000082C, 0xCD040E08, 0x5A200002, 0x5E600010,
+ 0x8400FFF8, 0xC2000000, 0xC0000808, 0xCE040018, 0xC3400000, 0x80000010, 0xC1200002, 0xC0000818,
+ 0xCD041008, 0x5B740002, 0xC0004858, 0xCF440000, 0x99005590, 0xC0004848, 0xC9440000, 0xC1800000,
+ 0xC11C0002, 0xC000082C, 0xCD040E08, 0x800005E8, 0x5B740002, 0xC0004858, 0xCF440000, 0xC7800000,
+ 0xC13C0002, 0xCD001E08, 0xC0004848, 0xC9440000, 0xC1800000, 0xC000082C, 0xC9840030, 0x59540002,
+ 0xC0004848, 0xCD440000, 0x58880002, 0xB4980560, 0x00000000, 0xC0800000, 0x80000550, 0xC000487C,
+ 0xC8040000, 0x00000000, 0x00000000, 0x40080000, 0xCBC00000, 0xC4280000, 0x00000000, 0xA7C00110,
+ 0xC000484C, 0xCA040000, 0xC2400000, 0xC0001AEC, 0xCA440020, 0x5A200002, 0xC000484C, 0xCE040000,
+ 0xB624006A, 0xC6800000, 0xC13C0002, 0xCD001E08, 0xC0004848, 0xC9440000, 0xC1800000, 0xC000082C,
+ 0xC9840030, 0x59540002, 0xC0004848, 0xCD440000, 0x58880002, 0xB4980450, 0x00000000, 0xC0800000,
+ 0x80000440, 0xC0004854, 0xC1000004, 0xCD040000, 0xC0000820, 0xC2000002, 0xCE040000, 0xC2000000,
+ 0xC000484C, 0xCE040000, 0xC0004858, 0xCE040000, 0x8000FF10, 0xC0004854, 0xC1000000, 0xCD040000,
+ 0xC11C0000, 0xC000082C, 0xCD040E08, 0x99005590, 0xC0004848, 0xC9440000, 0xC1800000, 0xC1200000,
+ 0xC0000818, 0xCD041008, 0xC11C0002, 0xC000082C, 0xCD040E08, 0xC2000000, 0xC000484C, 0xCE040000,
+ 0x80000340, 0xC0001AC0, 0xCB840000, 0xC000487C, 0xC8040000, 0x00000000, 0x00000000, 0x40080000,
+ 0xCBC00000, 0xC4280000, 0x00000000, 0x00000000, 0xC6800000, 0xC13C0000, 0xCD001E08, 0xA780022A,
+ 0x00000000, 0x00000000, 0xA7C001EA, 0x00000000, 0xC0001B00, 0xC2060006, 0xCE040310, 0xA7E801A2,
+ 0x00000000, 0xC0004850, 0xCA040000, 0xC2400000, 0xC0001AEC, 0xCA448020, 0x5A200002, 0xC0004850,
+ 0xCE040000, 0xB624008A, 0x00000000, 0xC6800000, 0xC13C0002, 0xCD001E08, 0xC0001ACC, 0xC2000002,
+ 0xCE040008, 0xC0004848, 0xC9440000, 0xC1800000, 0xC000082C, 0xC9840030, 0x59540002, 0xC0004848,
+ 0xCD440000, 0x58880002, 0xB49801A8, 0x00000000, 0xC0800000, 0x80000198, 0xC0004854, 0xC1000000,
+ 0xCD040000, 0xC11C0000, 0xC000082C, 0xCD040E08, 0x99005590, 0xC0004848, 0xC9440000, 0xC1800000,
+ 0xC2000000, 0xC0000820, 0xCE040000, 0xC1200000, 0xC0000818, 0xCD041008, 0xC11C0002, 0xC000082C,
+ 0xCD040E08, 0xC0004850, 0xCE040000, 0xC2000002, 0xC0001ACC, 0xCE040010, 0x800000D0, 0xC2000002,
+ 0xC0004850, 0xCE040000, 0x8000FE70, 0xC2000000, 0xC0004850, 0xCE040000, 0xA7E60012, 0x00000000,
+ 0xC2000002, 0xC0001B00, 0xCE040008, 0x8000FE58, 0x00000000, 0xA7860032, 0x00000000, 0xC6800000,
+ 0xC13C0002, 0xCD001E08, 0xC2020002, 0xC7E2A548, 0xC0001B00, 0xCE040000, 0x8000FE00, 0xC2040002,
+ 0xC0001B00, 0xCE040208, 0x8000FDE0, 0xC2C80002, 0x6AC56000, 0xDACC0000, 0xC0004854, 0xCB440000,
+ 0xC0004848, 0xCB840000, 0xC0000838, 0xC3C00000, 0xCBC40030, 0x5EF40004, 0x8400000A, 0xC3000000,
+ 0xC0001ACC, 0xCF040108, 0x47BD8000, 0x84000012, 0x47BD8000, 0x88000018, 0xC1006E8C, 0x8000B6B0,
+ 0xC0004840, 0xCC840000, 0x8000F698, 0xC0001AC0, 0xCAC40000, 0xC0004854, 0xCB440000, 0xA6C0FBB2,
+ 0x00000000, 0x5EF40000, 0x8400F6F2, 0x5EF40002, 0x8400F982, 0x5EF40004, 0x8400FB82, 0xC1006CE8,
+ 0x8000B628, 0x00000000, 0xC0800000, 0xDF4B0040, 0xC0004900, 0xCB800000, 0xC2000000, 0xC000490A,
+ 0xA78000B0, 0xCBC00000, 0xC1000000, 0xD9000001, 0xC1000002, 0xD90C0000, 0x6FF46000, 0x47F5A000,
+ 0x5B744C80, 0xC2400000, 0x58340004, 0xCA400080, 0xC0004900, 0xCE000008, 0x5A640002, 0x58340004,
+ 0xC6500080, 0xCD000080, 0xC0004914, 0xCA400000, 0xC2000002, 0x6A3D0000, 0x72252000, 0xCE400000,
+ 0xC0000408, 0xCE000000, 0xA78200B8, 0xC0004908, 0xCBC00000, 0xC1000000, 0xD9000001, 0xC1000002,
+ 0xD90C0000, 0x6FF4A000, 0x6FD44000, 0x4575A000, 0x47F5A000, 0x5B744E20, 0xC2800000, 0x58340006,
+ 0xCA800080, 0xC2000000, 0xC0004900, 0xCE000108, 0x5EA80002, 0x58340006, 0xC6900080, 0xCD000080,
+ 0x5A7C0020, 0xC2000002, 0x6A250000, 0xC0000408, 0xCE000000, 0xDCA80001, 0x5EA80000, 0x8400B498,
+ 0x00000000, 0xA4800210, 0x00000000, 0xC3C00000, 0xC000140E, 0xCBC00020, 0xC3400000, 0xC2400000,
+ 0x6FF86000, 0x47F9C000, 0x5BB84C80, 0x58380008, 0xCB400080, 0x58380006, 0xCA400080, 0x5F740002,
+ 0x58380008, 0xC7500080, 0xCD000080, 0xC2000000, 0x58380004, 0xCA020080, 0xC3000000, 0x5838000C,
+ 0xCB000028, 0x5A640002, 0x46250000, 0x8400FFF8, 0xC2400000, 0x58380006, 0xC6500080, 0xCD000080,
+ 0xC2000000, 0x5838000A, 0xCA020080, 0x5B300002, 0x5838000C, 0xC7100028, 0xCD000028, 0xC2420020,
+ 0x5A200004, 0x46612000, 0x8400FFF8, 0xC2000000, 0x5838000A, 0xC6101080, 0xCD001080, 0xC0004966,
+ 0xCA400000, 0xC2000002, 0x6A3D0000, 0x72252000, 0xCE400000, 0x5F740000, 0x84000028, 0xC0004912,
+ 0xCA000000, 0xC2C00002, 0x6AFD6000, 0x7EC16000, 0x76E10000, 0xCE000000, 0x5F300020, 0x84000028,
+ 0xC0004924, 0xCA000000, 0xC2C00002, 0x6AFD6000, 0x7EC16000, 0x76E10000, 0xCE000000, 0xA4820050,
+ 0xC2400000, 0xC000140E, 0xCA408020, 0xC2000002, 0xC0004900, 0xCE000008, 0xC000490A, 0xCE400000,
+ 0xC1000000, 0xD9000001, 0xD8400080, 0xC1000004, 0xD9000001, 0xA4840250, 0x00000000, 0xC3C00000,
+ 0xC000140E, 0xCBC10020, 0xC2800000, 0xC2000000, 0x6FF8A000, 0x6FD44000, 0x4579C000, 0x47F9C000,
+ 0x5BB84E20, 0x5838002E, 0xCA800080, 0x58380006, 0xCA020080, 0xC3400000, 0x5838002E, 0xCB420080,
+ 0x5AA80002, 0x46290000, 0x8400FFF8, 0xC2800000, 0x5838002E, 0xC6900080, 0xCD000080, 0x5F740002,
+ 0x5838002E, 0xC7501080, 0xCD001080, 0xC0004968, 0xCA400000, 0xC2000002, 0x6A3D0000, 0x72252000,
+ 0xCE400000, 0xC000492A, 0xCA800000, 0x5E740000, 0x84000028, 0xC0004910, 0xCA000000, 0xC2C00002,
+ 0x6AFD6000, 0x7EC16000, 0x76E10000, 0xCE000000, 0x6ABD4010, 0xA680009A, 0x00000000, 0x58380032,
+ 0xCA000000, 0x58000002, 0xCA400000, 0x5838000C, 0x00000000, 0xCE000001, 0xCE400000, 0xC000492A,
+ 0xCA000000, 0xC2C00002, 0x6AFD6000, 0x72E10000, 0xCE000000, 0xC000492C, 0xCA000000, 0xC2C00002,
+ 0x6AFD6000, 0x72E10000, 0xCE000000, 0x80000028, 0xC000492C, 0xCA000000, 0xC2C00002, 0x6AFD6000,
+ 0x7EC16000, 0x76E10000, 0xCE000000, 0xA4880128, 0xC2C00000, 0xC000140E, 0xCAC20020, 0xC000490E,
+ 0xCA400000, 0xC2000002, 0x6A2D0000, 0x7E010000, 0x76252000, 0xCE400000, 0xC000496A, 0xCA400000,
+ 0xC2000002, 0x6A2D0000, 0x72252000, 0xCE400000, 0x6EF0A000, 0x6ED44000, 0x45718000, 0x46F18000,
+ 0x5B304E20, 0x58300000, 0xCA000000, 0x00000000, 0xC2400002, 0x76252000, 0x8400005A, 0x58300000,
+ 0xCA400000, 0xC2800000, 0x00000000, 0xC6684020, 0xC24C0002, 0xC6A40020, 0xC624C408, 0x58300010,
+ 0xCA400508, 0x00000000, 0xC0001800, 0xCE400000, 0xA4860050, 0xC2400000, 0xC000140E, 0xCA418020,
+ 0xC2020002, 0xC0004900, 0xCE000108, 0xC0004908, 0xCE400000, 0xC1000000, 0xD9000001, 0xD8400080,
+ 0xC1000004, 0xD9000001, 0xC0001408, 0xCC800000, 0xC10E0002, 0xD90C0000, 0x8000ED98, 0xDFBC0001,
+ 0xC000496E, 0x99006298, 0xC9400000, 0xC7D80000, 0x00000000, 0xC5700000, 0x5EF00020, 0x88000130,
+ 0x6F346000, 0x4735A000, 0x5B744C80, 0x58340008, 0xC2400000, 0xCA400080, 0x00000000, 0xC2000000,
+ 0x5A640002, 0xCE400080, 0x58340004, 0xCA000080, 0x00000000, 0x00000000, 0x5E200002, 0xCE000080,
+ 0xC0004912, 0xCA800000, 0xC2400002, 0x6A712000, 0x72694000, 0xCE800000, 0x5E200000, 0x8400003A,
+ 0xC000480A, 0xCA000000, 0xC0000408, 0xCA800000, 0x76610000, 0x00000000, 0x72294000, 0xCE800000,
+ 0x80000020, 0xC0004914, 0xCA000000, 0x7E412000, 0x00000000, 0x76610000, 0xCE000000, 0x800000B8,
+ 0x6EF4A000, 0x6ED44000, 0x4575A000, 0x46F5A000, 0x5B744E20, 0x5834002E, 0xC2400000, 0xCA420080,
+ 0x00000000, 0xC2000000, 0x5A640002, 0xC6501080, 0xCD001080, 0x58340006, 0xCA000080, 0x00000000,
+ 0x00000000, 0x5A200002, 0xCE000080, 0xC0004910, 0xCA400000, 0xC2000002, 0x6A2D0000, 0x72252000,
+ 0xCE400000, 0xC2000002, 0x6A310000, 0xC000042A, 0xCE000000, 0xC1040002, 0xD90C0000, 0x00000000,
+ 0x8000EB08, 0x00000000, 0xC4980930, 0x9D000000, 0xC5580030, 0xC0000838, 0xCD840000, 0xC1440200,
+ 0xC1C03200, 0xC55C1078, 0xC000100E, 0x9D000000, 0xCD800000, 0xC000100C, 0xCDC00000, 0xC0004862,
+ 0xC9C00000, 0x00000000, 0x00000000, 0xD9D80001, 0xC0007200, 0x401C0000, 0x5DC07400, 0x8800FFFA,
+ 0x5C000200, 0xCD800000, 0xC1F0000A, 0x71D4A000, 0xDD980000, 0xDD9C0001, 0x41D8E000, 0xC5D40268,
+ 0xC0001010, 0xCD400000, 0x6C9C8000, 0x449CE000, 0x449CE000, 0x59DC0004, 0xC1601260, 0xC5D40268,
+ 0x9D000000, 0xC0001012, 0xCD400000, 0x00000000, 0x00000000, 0xD9580000, 0x6D586000, 0x4558C000,
+ 0x59984C80, 0xD9980001, 0x5818000A, 0xC1800000, 0xC9800080, 0xC0005400, 0x6D5CA000, 0x401C0000,
+ 0x40180000, 0xC9400000, 0x58000002, 0x00000000, 0xC9C00000, 0xC0004930, 0xCD400000, 0xC0004932,
+ 0xCDC00000, 0x59980004, 0xC1C20020, 0xB59CFFF8, 0x00000000, 0xC1800000, 0xDD9C0001, 0x581C000A,
+ 0xCD800080, 0x581C000C, 0xC1800000, 0xC9800028, 0xC1C00002, 0xDD940000, 0x69D4E000, 0x5D980002,
+ 0xCD800028, 0xC0004924, 0xC9800000, 0x00000000, 0x9D000000, 0x00000000, 0x71D8C000, 0xCD800000,
+ 0xC000492A, 0xC9400000, 0xC1C00002, 0x69D8E000, 0x7DC0C000, 0x7594A000, 0xCD400000, 0xC000492C,
+ 0xC9400000, 0xDD800001, 0x58000032, 0x75D4A000, 0x84000078, 0xC9400001, 0xC9800000, 0xDD800001,
+ 0x5800000C, 0x00000000, 0xCD400001, 0xCD800000, 0xC000492C, 0xC9400000, 0xC000492A, 0xC9800000,
+ 0x71D4A000, 0xC000492C, 0xCD400000, 0x71D8C000, 0xC000492A, 0xCD800000, 0x9D000000, 0x00000000,
+ 0x00000000, 0x00000000, 0xC0004862, 0xC9800000, 0x00000000, 0xC1C00200, 0x4194C000, 0x45D8E000,
+ 0x8800FFFA, 0xC5D80000, 0xC0004862, 0xCD800000, 0xC0001406, 0xC9800000, 0xC1C00002, 0x9D000000,
+ 0xC5D80A08, 0xC5581050, 0xCD800000, 0xC0004930, 0xC9800000, 0xC0004932, 0xC9C00000, 0xC140000E,
+ 0xC5581C20, 0xDD940000, 0xC0007200, 0x40140000, 0x5D407400, 0x8800FFFA, 0x5C000200, 0xCD800000,
+ 0x58000002, 0x5D407400, 0x8800FFFA, 0x5C000200, 0xCDC00000, 0xDD540000, 0xC1C00000, 0x58140006,
+ 0xC9C20080, 0xC1800000, 0x58140000, 0xC98000E0, 0x6DDC2000, 0xC000491E, 0x41D8E000, 0xCDC00000,
+ 0xDD980000, 0xC1C00022, 0xC5D80D78, 0xDD940001, 0xC5581C20, 0xC000491C, 0xCD800000, 0xDD540000,
+ 0xC1C00000, 0x58140006, 0xC9C20080, 0xC1800000, 0x58140004, 0xC9820080, 0x00000000, 0x59DC0002,
+ 0x459CC000, 0x8400FFF8, 0xC1C00000, 0x9D000000, 0x58140006, 0xC5D81080, 0xCD801080, 0xC0004860,
+ 0xC9400000, 0xC1820080, 0xC1D00002, 0x58146B00, 0xD5800000, 0x58000002, 0xD5800001, 0x59540004,
+ 0xB558FFF8, 0xC0004860, 0xC1400000, 0xCD400000, 0xDD980001, 0x9D000000, 0xDD940000, 0xC0001404,
+ 0xCDC00808, 0xC1C00000, 0xC1800200, 0x5D980004, 0xDF5D0050, 0x45D8A000, 0x8800FFDA, 0xDD800001,
+ 0x5800000C, 0x00000000, 0xC9400001, 0xC9800000, 0xC1C00002, 0xC5D43F08, 0xC5D81E08, 0xC0004862,
+ 0xC9C00000, 0x00000000, 0x00000000, 0x581C7200, 0x5DC07400, 0x8800FFFA, 0x5C000200, 0xCD400000,
+ 0x58000002, 0x5DC07400, 0x8800FFFA, 0x5C000200, 0xCD800000, 0xC0004862, 0xC9C00000, 0x00000000,
+ 0xC15004C0, 0xC5D40068, 0xDD9C0000, 0xC5D41C20, 0xC1C00000, 0xDD800001, 0x58000030, 0xC9C00080,
+ 0xDD800001, 0x58000002, 0xC9800000, 0x6DDC2000, 0xC000491C, 0x41D8E000, 0xCD400001, 0xCDC00000,
+ 0xDD940001, 0xC1C00000, 0x58140030, 0xC9C00080, 0xC1800000, 0x58140006, 0xC9820080, 0x00000000,
+ 0x59DC0002, 0x459CC000, 0x8400FFF8, 0xC1C00000, 0x9D000000, 0x58140030, 0xC5D80080, 0xCD800080,
+ 0xC1C00000, 0xDF5C0040, 0x5DDC0080, 0x8400FFD2, 0x00000000, 0x9D000000, 0x00000000, 0x00000000,
+ 0x00000000, 0xC160FFFE, 0xC0000A10, 0xC9440068, 0xC1A0FFFE, 0x59980E28, 0xC000100C, 0xCD400000,
+ 0xC000100E, 0xCD800000, 0xC0004964, 0xC9800000, 0x00000000, 0xC170000A, 0x7194A000, 0x6C988000,
+ 0x4498C000, 0x4498C000, 0x59980004, 0xC5940278, 0xC0001010, 0xCD400000, 0xC0004946, 0xC9400000,
+ 0x00000000, 0x00000000, 0x6D58A000, 0x6D5C4000, 0x45D8C000, 0x4558C000, 0xC000494A, 0xC9400000,
+ 0xC0004948, 0xC9C00000, 0x4194C000, 0xC1400012, 0xC55C1820, 0x9D000000, 0xC59C0270, 0xC0001012,
+ 0xCDC00000, 0xC1400000, 0x58000012, 0xC9410040, 0xC0004950, 0xC9C00000, 0xC5580000, 0xC5940840,
+ 0xC5581080, 0xD9940000, 0xC000493C, 0xC9400000, 0xC0004954, 0xC9800000, 0x59DC00A8, 0x455CE000,
+ 0x41D8E000, 0x5D5C0030, 0x8800FFF8, 0xC1C00030, 0xC1800000, 0xC5D84030, 0xC1400000, 0xC5D40010,
+ 0x5DD40002, 0x8400005A, 0x5DD40004, 0x84000082, 0x5DD40006, 0x840000AA, 0x5DD80026, 0x840000D2,
+ 0xDD540000, 0xDD800001, 0x58000008, 0x40180000, 0xCD400000, 0x59980002, 0x8000FFA8, 0xDD540000,
+ 0xDD800001, 0x58000008, 0x40180000, 0xCD4000C0, 0x59980002, 0x8000FF70, 0xDD540000, 0xDD800001,
+ 0x58000008, 0x40180000, 0xCD400080, 0x59980002, 0x8000FF38, 0xDD540000, 0xDD800001, 0x58000008,
+ 0x40180000, 0xCD400040, 0x59980002, 0x8000FF00, 0x00000000, 0x9D000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x58000012, 0xC9400000, 0xC0004954, 0xC9C00000, 0xC0004950, 0xC9400080, 0xDD800001,
+ 0x58000028, 0x5D9C0000, 0x8400003A, 0x5D9C0002, 0x8400003A, 0x5D9C0004, 0x84000052, 0xC55B0040,
+ 0xC55C08C0, 0xCD800041, 0xCDC008C0, 0x80000048, 0xCD400000, 0x80000038, 0xC55900C0, 0xC55C1840,
+ 0xCD8000C1, 0xCDC01840, 0x80000010, 0xC55A0080, 0xC55C1080, 0xCD800081, 0xCDC01080, 0x9D000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x59540002, 0x6994E018, 0x61C0C008, 0x4194A000, 0x5D940040,
+ 0x8800FFFA, 0xC5940000, 0x9D000000, 0xCD400000, 0x00000000, 0x00000000, 0x9D000000, 0x4158A000,
+ 0xCD400000, 0x00000000,
+};
+
+static unsigned int danube_fw_data[] = {
+};
+
+
+#endif // IFXMIPS_ATM_FW_DANUBE_H
diff --git a/package/platform/lantiq/ltq-atm/src/ifxmips_atm_fw_danube_retx.h b/package/platform/lantiq/ltq-atm/src/ifxmips_atm_fw_danube_retx.h
new file mode 100644
index 0000000..ff4e500
--- /dev/null
+++ b/package/platform/lantiq/ltq-atm/src/ifxmips_atm_fw_danube_retx.h
@@ -0,0 +1,612 @@
+#ifndef IFXMIPS_ATM_FW_DANUBE_H
+#define IFXMIPS_ATM_FW_DANUBE_H
+
+
+/******************************************************************************
+**
+** FILE NAME : ifxmips_atm_fw_danube.h
+** PROJECT : Danube
+** MODULES : ATM (ADSL)
+**
+** DATE : 1 AUG 2005
+** AUTHOR : Xu Liang
+** DESCRIPTION : ATM Driver (PP32 Firmware)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 4 AUG 2005 Xu Liang Initiate Version
+** 23 OCT 2006 Xu Liang Add GPL header.
+*******************************************************************************/
+
+
+#define VER_IN_FIRMWARE 1
+
+#define ATM_FW_VER_MAJOR 0
+#define ATM_FW_VER_MINOR 15
+
+
+static unsigned int firmware_binary_code[] = {
+ 0x800004A0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8000FFC8, 0x00000000, 0x00000000, 0x00000000,
+ 0xC1000002, 0xD90C0000, 0xC2000002, 0xDA080001, 0xC0001B50, 0x8C100000, 0x00000000, 0x00000000,
+ 0x00000000, 0xC2000000, 0xDA080001, 0x80006018, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x80005FF0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC1001DA6, 0x8D3C0000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x80005EF0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC0400000, 0xC0004840, 0xC8840000, 0xC2001AEE, 0x8E100000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC0400002, 0xC0004840, 0xC8840000, 0xC2001AEE, 0x8E100000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC3C00004, 0xDBC80001, 0xC10C0002, 0xD90C0000, 0x8000FEC8, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC10E0002, 0xD90C0000, 0xC0004808, 0xC8400000, 0xC2001B4C, 0x8E100000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC3E1FFFE, 0x597DFFFE, 0x593DFE14, 0x900004D9, 0x00000000, 0x00000000, 0x00000000, 0x90CC0481,
+ 0x00000000, 0x00000000, 0x00000000, 0xC3E02252, 0x5BFC001E, 0xC0004002, 0xCFC00000, 0xC3C00000,
+ 0xDBC80001, 0xC1400008, 0xC1900000, 0x71948000, 0x15000100, 0xC140000A, 0xC1900002, 0x71948000,
+ 0x15000100, 0xC140000C, 0xC1900004, 0x71948000, 0x15000100, 0xC1400004, 0xC1900006, 0x71948000,
+ 0x15000100, 0xC1400006, 0xC1900008, 0x71948000, 0x15000100, 0xC140000E, 0xC190000A, 0x71948000,
+ 0x15000100, 0xC1400000, 0xC190000C, 0x71948000, 0x15000100, 0xC1400002, 0xC190000E, 0x71948000,
+ 0x15000100, 0xC0400000, 0xC11C0000, 0xC000082C, 0xCD040E08, 0xC11C0002, 0xC000082C, 0xCD040E08,
+ 0xC0400002, 0xC11C0000, 0xC000082C, 0xCD040E08, 0xC0000824, 0x00000000, 0xCBC00001, 0xCB800001,
+ 0xCB400001, 0xCB000000, 0xC0004878, 0x5BFC4000, 0xCFC00001, 0x5BB84000, 0xCF800001, 0x5B744000,
+ 0xCF400001, 0x5B304000, 0xCF000000, 0xC0000A10, 0x00000000, 0xCBC00001, 0xCB800000, 0xC0004874,
+ 0x5BFC4000, 0xCFC00001, 0x5BB84000, 0xCF800000, 0xC30001FE, 0xC000140A, 0xCF000000, 0xC3000000,
+ 0x7F018000, 0xC000042E, 0xCF000000, 0xC000040E, 0xCF000000, 0xC3C1FFFE, 0xC000490E, 0xCFC00080,
+ 0xC000492C, 0xCFC00080, 0xC0004924, 0xCFC00040, 0xC0004912, 0xCFC00040, 0xC0004966, 0xCFC00040,
+ 0xC0004968, 0xCFC00080, 0xC000496A, 0xCFC00080, 0xC3C00000, 0xC2800020, 0xC3000000, 0x7F018000,
+ 0x6FF88000, 0x6FD44000, 0x4395C000, 0x5BB84A00, 0x5838000A, 0xCF000000, 0x5BFC0002, 0xB7E8FFA8,
+ 0x00000000, 0xC3C00000, 0xC2800010, 0x6FF86000, 0x47F9C000, 0x5BB84C80, 0xC3400000, 0x58380004,
+ 0xCB420080, 0x00000000, 0x58380008, 0xCF400080, 0x5BFC0002, 0xB7E8FF90, 0x00000000, 0xC3C00000,
+ 0xC2800020, 0xC348001E, 0xC3000000, 0x7F018000, 0x6FF8A000, 0x6FD44000, 0x4579C000, 0x47F9C000,
+ 0x5BB84E20, 0x58380008, 0xCF400420, 0x5838000A, 0xCF000000, 0x5BFC0002, 0xB7E8FF90, 0x00000000,
+ 0x00000000, 0xC0004816, 0xC3C00000, 0xCBC00080, 0x00000000, 0x00000000, 0xC1000000, 0xD9040001,
+ 0xDBC40080, 0xC1000006, 0xD9040001, 0x00000000, 0xC121FFFE, 0x5911FE54, 0x15000000, 0xC3C00000,
+ 0xDCFC2008, 0x5FFC0002, 0x00000000, 0x98C08D62, 0xC0004730, 0xC9400000, 0xC0004732, 0xC0001AF2,
+ 0xCBC00000, 0x00000000, 0x00000000, 0xA7C20450, 0xC000474A, 0xCA800000, 0x00000000, 0x00000000,
+ 0x5D280000, 0x8400FFC8, 0x00000000, 0xC121FFFE, 0x5911FEF4, 0x15000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC2802000, 0x6EA8E010, 0xC0004200, 0xC2400000, 0x7E410000, 0xC1000000, 0xCE400001, 0xCE400001,
+ 0xCE400001, 0xCE400001, 0x5EA80002, 0x8400FFC0, 0xC0004300, 0xC2800200, 0x6EA84010, 0xCE400001,
+ 0xCE000001, 0xCE400001, 0xCE000001, 0xCE400001, 0xCE000001, 0xCE400001, 0xCE000001, 0x5EA80002,
+ 0x8400FFA0, 0xC0004700, 0xC2800200, 0x6EA8E010, 0xCE400001, 0xCE400001, 0xCE400001, 0xCE400001,
+ 0x5EA80002, 0x8400FFC0, 0xC0004740, 0xCE400000, 0xC0004742, 0xC1000200, 0x5D100002, 0xCD000000,
+ 0xC0004744, 0xCE400000, 0xC0004746, 0xCE400000, 0xC0004748, 0xCE400000, 0xC000474A, 0xCE400000,
+ 0xC000474C, 0xC1000002, 0xCD000000, 0xC000474E, 0xCE400000, 0xC0004750, 0xCE400000, 0xC0004752,
+ 0xCE400000, 0xC0004754, 0xCE400000, 0xC0400000, 0xC11C0000, 0xC000082C, 0xCD040E08, 0xC0000838,
+ 0xCE400000, 0xC0000818, 0xCE400000, 0xC0000820, 0xCE400000, 0xC2804840, 0xC240485A, 0x98C086B0,
+ 0xC6800000, 0xC6540000, 0xC1800000, 0xC11C0002, 0xC000082C, 0xCD040E08, 0x00000000, 0xC121FFFE,
+ 0x5911FE54, 0x15000000, 0xC0000A10, 0xCB800000, 0xC0000A12, 0xCB400000, 0xC0000A14, 0xCB000000,
+ 0xC0000A16, 0xCAC00000, 0xC0000040, 0xC2800000, 0xCE800008, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xC2800002,
+ 0xCE800008, 0xC0000A10, 0xCF800000, 0xC0000A12, 0xCF400000, 0xC0000A14, 0xCF000000, 0xC0000A16,
+ 0xCEC00000, 0xC1000000, 0xC00048A0, 0xCD000000, 0xC00048A2, 0xCD000000, 0xC0001AF2, 0xC1000000,
+ 0xCD000108, 0x80001020, 0x00000000, 0xC3C00000, 0xDCFC2008, 0x5FFC0002, 0x00000000, 0x98C08D62,
+ 0xC0004730, 0xC9400000, 0xC0004732, 0x800033C0, 0x00000000, 0xC3C00000, 0xDCFC2008, 0x5FFC0002,
+ 0x00000000, 0x98C08D62, 0xC0004730, 0xC9400000, 0xC0004732, 0xC0004810, 0xC9000000, 0xC000474A,
+ 0xC9400000, 0xA50007C8, 0x00000000, 0x5D140002, 0x840007BA, 0xC1000000, 0xC000484A, 0xC9000000,
+ 0xC0004740, 0xC8400000, 0x5D100000, 0x84000780, 0x00000000, 0x00000000, 0xC121FFFE, 0x5911FEF4,
+ 0x15000000, 0xC0004744, 0xC8800000, 0xC0001AF0, 0xC3000000, 0x58000002, 0xCB010040, 0x6C7C2000,
+ 0x5BFC4300, 0x98C08A88, 0xC1400000, 0xC4540028, 0x6C40A010, 0x5D240002, 0x84000202, 0x00000000,
+ 0xC0004742, 0xCA800000, 0x00000000, 0x00000000, 0x59280002, 0x6D130000, 0x6D130010, 0x44508000,
+ 0x8400067A, 0x00000000, 0x98C08870, 0xC4540000, 0xC6980000, 0xC241FFFE, 0xC6740000, 0x5D35FFFE,
+ 0x8400063A, 0x44748000, 0x8400062A, 0xC1000000, 0x6F502000, 0xC0004300, 0x40100000, 0xC1400000,
+ 0x58000000, 0xC9410040, 0xC1800000, 0xC0004814, 0xC9820040, 0x4570A000, 0xC10001FE, 0x4150A004,
+ 0x45948000, 0x880005B2, 0x4474C000, 0xC1000200, 0x4190C004, 0xC000473E, 0xC9000000, 0x00000000,
+ 0x00000000, 0x41188000, 0xCD000000, 0xC000471C, 0xC9000000, 0x00000000, 0x00000000, 0x41188000,
+ 0xCD000000, 0x98C087E8, 0xC4540000, 0x6C58A010, 0xC0004700, 0x58440002, 0x6C470000, 0x6C470010,
+ 0x47448000, 0x8400FFA8, 0xC7440000, 0xC0004740, 0xCC400000, 0xC0800000, 0xC0004744, 0xCC800000,
+ 0x800004B8, 0xC1000000, 0x583C0000, 0xC9000040, 0x00000000, 0x00000000, 0x45088000, 0x88000268,
+ 0xC1400000, 0x583C0000, 0xC9410040, 0xC1800000, 0xC0004814, 0xC9800040, 0x4570A000, 0xC10001FE,
+ 0x4150A004, 0x45948000, 0x8800042A, 0xC3800000, 0x583C0002, 0xCB820080, 0xC1000000, 0x583C0002,
+ 0xC9000080, 0x00000000, 0x00000000, 0x45388000, 0x84000232, 0xC0400002, 0xC0800000, 0xC3C00000,
+ 0xC000481A, 0xC8000000, 0x6F908000, 0x47908000, 0x47908000, 0x4011E000, 0xC000491E, 0xCFC00000,
+ 0xC3400000, 0xC0004878, 0xC8040000, 0x6C908000, 0x44908000, 0x44908000, 0x40100000, 0xCAC00000,
+ 0xC4300000, 0x00000000, 0xC7340068, 0xC1000002, 0xC5341B08, 0xC100001C, 0xC5341050, 0xC100000C,
+ 0xC5340D18, 0xC000491C, 0xCF400000, 0xC3000000, 0xDF700040, 0x5D300080, 0x8800FFD0, 0xC000474A,
+ 0xC1000002, 0xCD000000, 0xC000491C, 0xCB400000, 0xC000491E, 0xCBC00000, 0x99007F18, 0xDB580000,
+ 0xDBD80001, 0x00000000, 0xC1400000, 0xC794A038, 0xC1800000, 0xC7980028, 0x58144200, 0xC9C00000,
+ 0xC1210000, 0x69188010, 0x7D008000, 0x751CE000, 0xCDC00000, 0x80000210, 0x00000000, 0xC1000000,
+ 0x583C0000, 0xC903E008, 0x00000000, 0x00000000, 0x5D100000, 0x8400002A, 0xC0004734, 0xC9000000,
+ 0x00000000, 0x00000000, 0x59100002, 0xCD000000, 0x800000A8, 0xC1400000, 0x583C0000, 0xC9410040,
+ 0xC1800000, 0xC0004814, 0xC9820040, 0x4570A000, 0xC10001FE, 0x4150A004, 0x45948000, 0x88000142,
+ 0xC000473E, 0xC9000000, 0x00000000, 0x00000000, 0x59100002, 0xCD000000, 0xC000471C, 0xC9000000,
+ 0x00000000, 0x00000000, 0x59100002, 0xCD000000, 0xC3800000, 0x583C0002, 0xCB820080, 0x00000000,
+ 0x00000000, 0x5D39FFFE, 0x8400004A, 0xC1400000, 0xC794A038, 0xC1800000, 0xC7980028, 0x58144200,
+ 0xC9C00000, 0xC1210000, 0x69188010, 0x7D008000, 0x751CE000, 0xCDC00000, 0x98C087E8, 0xC4540000,
+ 0x6C58A010, 0xC0004700, 0x58440002, 0x6C470000, 0x6C470010, 0xC0004740, 0xCC400000, 0xC0800000,
+ 0xC0004744, 0xCC800000, 0x00000000, 0xC121FFFE, 0x5911FE54, 0x15000000, 0x8000F270, 0x00000000,
+ 0x00000000, 0x98C086F0, 0xC0004748, 0xC9800000, 0xC2000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0xC1400000, 0xC7D4A038, 0xC1800000, 0xC7D80028, 0x58144200,
+ 0xC9C00000, 0xC1210000, 0x69188010, 0x7D008000, 0x751CE000, 0xCDC00000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x98C087E8, 0xC7D40000, 0x6FD8A010, 0xC0004700, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x98C08870, 0xC7D40000, 0xC7980000, 0xC241FFFE, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x98C08A88, 0xC1400000, 0xC7D40028, 0x6FC0A010,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x98C08AB8, 0xC1400000, 0xC7D40028, 0x6FC0A010,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x98C08AF0, 0xC7D40000, 0xC0004740, 0xC9C00000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x98C08BE0, 0xC7D40000, 0xC0004742, 0xC9800000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xC0004958, 0xC8400000, 0x00000000, 0xC3C00002,
+ 0x7BC42000, 0xCC400000, 0xC0004848, 0xCB840000, 0xC000495C, 0xCAC40000, 0xC0004844, 0xC8840000,
+ 0x46F90000, 0x8400F47A, 0xC000487C, 0xC8040000, 0x00000000, 0x00000000, 0x40080000, 0xCA000000,
+ 0xC0001624, 0xCB040000, 0xA63C005A, 0x00000000, 0x00000000, 0xA71EF412, 0x00000000, 0xC0000824,
+ 0xCA840000, 0x6CA08000, 0x6CA42000, 0x46610000, 0x42290000, 0xC35E0002, 0xC6340068, 0xC0001624,
+ 0xCF440080, 0xC2000000, 0xC161FFFE, 0x5955FFFE, 0x15400000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0xC0004844, 0xC8840000, 0xC000082C, 0xCA040040, 0x00000000, 0x00000000, 0x58880002,
+ 0xB608FFF8, 0x00000000, 0xC0800000, 0xC0004844, 0xCC840040, 0x5AEC0002, 0xC000495C, 0xCEC40000,
+ 0x5E6C0006, 0x84000048, 0xC0004848, 0xCB840000, 0xC0000838, 0xC2500002, 0xCE440808, 0x5FB80002,
+ 0xC0004848, 0xCF840000, 0x5EEC0002, 0xC000495C, 0xCEC40000, 0x00000000, 0xC121FFFE, 0x5911FE54,
+ 0x15000000, 0x8000F278, 0xC000495A, 0xC8400000, 0x00000000, 0xC3C00002, 0x7BC42000, 0xCC400000,
+ 0xC0004960, 0xCAC40000, 0x00000000, 0x00000000, 0x5EEC0000, 0x840000F2, 0x00000000, 0xB6FC0030,
+ 0xC0001600, 0xCA040000, 0x00000000, 0x00000000, 0xA61E00B2, 0x6FE90000, 0xC0000A28, 0xCE840808,
+ 0xC2C00000, 0xC2800004, 0xB6E80080, 0xC0001604, 0xCA840000, 0xC0004960, 0xCEC40000, 0xA69EFC8A,
+ 0x00000000, 0x6FE90000, 0xC0000A28, 0xCE840808, 0xC2C00002, 0xC0001600, 0xCA040000, 0x00000000,
+ 0x00000000, 0xA61E000A, 0x6FE90000, 0xC0000A28, 0xCE840808, 0xC2C00000, 0xC0001604, 0xCA840000,
+ 0xC0004960, 0xCEC40000, 0xA69EFBF2, 0xC2400000, 0xC0000A14, 0xCA440030, 0x00000000, 0x00000000,
+ 0x46E52000, 0xA4400000, 0xC2800000, 0xDFEB0031, 0x8000FFF8, 0xDFEA0031, 0xB668EBEA, 0x00000000,
+ 0xC00048A0, 0xCB040000, 0xC0000A10, 0xCA840000, 0x6F208000, 0x6F242000, 0x46610000, 0x42A10000,
+ 0xC2400000, 0xC0000A14, 0xCA440030, 0xC35E0002, 0xC6340068, 0xC0001604, 0xCF440080, 0x5B300002,
+ 0xB670FFF8, 0x5AEC0002, 0xC3000000, 0xC00048A0, 0xCF040000, 0xC0004960, 0xCEC40000, 0x8000F018,
+ 0xC0004918, 0xD2800000, 0xC2000000, 0xDF600040, 0x5E600080, 0x8400028A, 0x00000000, 0xC161FFFE,
+ 0x5955FFFE, 0x15400000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xC000480A, 0xCA000000,
+ 0xC0004912, 0xCA400000, 0xC0004924, 0xCA800000, 0xC0004966, 0xCAC00000, 0x00000000, 0xC121FFFE,
+ 0x5911FE54, 0x15000000, 0x76610000, 0x76A10000, 0x76E10000, 0x840001CA, 0xC0004918, 0xCA400000,
+ 0xC28001FE, 0x76A10000, 0x5A640002, 0x6A254010, 0x5EE80000, 0x84000002, 0x6AA54000, 0x8000FFF8,
+ 0xC6280000, 0x62818008, 0xC0004918, 0xCF000000, 0xC161FFFE, 0x5955FFFE, 0x15400000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0xC0004966, 0xCA400000, 0xC2000002, 0x6A310000, 0x7E010000,
+ 0x76252000, 0xCE400000, 0x00000000, 0xC121FFFE, 0x5911FE54, 0x15000000, 0x6F346000, 0x4735A000,
+ 0x5B744C80, 0xC2800000, 0x58340006, 0xCA800080, 0xC2C00000, 0x58340000, 0xCAC000E0, 0xC2400000,
+ 0x5834000A, 0xCA420080, 0x6EA82000, 0x42E9E000, 0x6F2CA000, 0x42E56000, 0x5AEC1400, 0xC3990040,
+ 0xC7381C20, 0xC6F80068, 0x99007F18, 0xDB980000, 0xDBD80001, 0x00000000, 0xDEA00000, 0x47210000,
+ 0x8400FD38, 0xC0004958, 0xC8400000, 0x00000000, 0xC1000002, 0x79042000, 0xCC400000, 0xC0004848,
+ 0xCBC40000, 0xC0004844, 0xC8840000, 0x5FFC0000, 0x8400ECA2, 0xC0004740, 0xCB000000, 0xC0004744,
+ 0xCAC00000, 0x6F282000, 0x5AA84300, 0xC000487C, 0xC8040000, 0x00000000, 0x00000000, 0x40080000,
+ 0xCA400000, 0xC4000000, 0x00000000, 0xC0004878, 0xC8040000, 0x6C908000, 0x44908000, 0x44908000,
+ 0x40100000, 0xC9000000, 0xC4340000, 0x00000000, 0x5C440000, 0x8400008A, 0x00000000, 0xC00047D2,
+ 0xC9000000, 0x00000000, 0x00000000, 0x59100002, 0xCD000000, 0x58340002, 0xC9000080, 0x00000000,
+ 0x00000000, 0x58280002, 0x6D120000, 0xCD001080, 0x5AEC0002, 0xC0004744, 0xCEC00000, 0x80000618,
+ 0x00000000, 0xC00047C0, 0xC9000000, 0x00000000, 0x00000000, 0x59100002, 0xCD000000, 0xA67C0028,
+ 0xC00047C2, 0xC9000000, 0x00000000, 0x00000000, 0x59100002, 0xCD000000, 0x80001E00, 0x00000000,
+ 0xA6600022, 0xC00047C4, 0xC9000000, 0x00000000, 0x00000000, 0x59100002, 0xCD000000, 0x80000558,
+ 0xC00047C6, 0xC9000000, 0x00000000, 0x00000000, 0x59100002, 0xCD000000, 0xC3C00000, 0xC67D0040,
+ 0xC3800000, 0xC6780040, 0x473C8000, 0x84000090, 0x46F88000, 0x84000080, 0xC1000000, 0xC0004814,
+ 0xC9000040, 0x00000000, 0x00000000, 0x5D100000, 0x840000D8, 0x5AEC0002, 0xC0004744, 0xCEC00000,
+ 0xC00047CA, 0xC9000000, 0x00000000, 0x00000000, 0x59100002, 0xCD000000, 0x80000460, 0x00000000,
+ 0x98C08AF0, 0xC7D40000, 0xC0004740, 0xC9C00000, 0x5D240000, 0x84000052, 0x00000000, 0x98C087E8,
+ 0xC7D40000, 0x6FD8A010, 0xC0004700, 0xC00047C8, 0xC9000000, 0x00000000, 0x00000000, 0x59100002,
+ 0xCD000000, 0x80001C28, 0xC00047CC, 0xC9000000, 0x00000000, 0x00000000, 0x59100002, 0xCD000000,
+ 0x6FE82000, 0x5AA84300, 0x5D380000, 0x84000088, 0x00000000, 0x98C086F0, 0xC0004748, 0xC9800000,
+ 0xC2000000, 0x58280002, 0x6E520000, 0xCD001080, 0x58280002, 0xCE400080, 0x5D25FFFE, 0x84000028,
+ 0xC00047D0, 0xC9000000, 0x00000000, 0x00000000, 0x59100002, 0xCD000000, 0x800002B8, 0xC3000000,
+ 0x58280002, 0xCB000080, 0x00000000, 0x00000000, 0x5D31FFFE, 0x84000030, 0xC00047D0, 0xC9000000,
+ 0x00000000, 0x00000000, 0x59100002, 0xCD000000, 0x80000248, 0x00000000, 0x98C086F0, 0xC0004748,
+ 0xC9800000, 0xC2000000, 0x58340002, 0xC6500080, 0xC7D01040, 0xC7901840, 0xCD000000, 0x58280002,
+ 0xCE400080, 0xC3C00200, 0x5FFC001C, 0xC3800000, 0xDF790050, 0x00000000, 0x00000000, 0x47BC8000,
+ 0x8800FFC2, 0xC0004862, 0xCBC00000, 0xC0000000, 0xC76C0000, 0x5BBC7200, 0xC280001C, 0xCA6C0001,
+ 0x00000000, 0x00000000, 0xCE780001, 0xC1007400, 0x47908000, 0xC1007200, 0xC5380006, 0x5EA80002,
+ 0x8400FFA0, 0xC3800000, 0xC000481A, 0xC8000000, 0x6F108000, 0x47108000, 0x47108000, 0x4011C000,
+ 0xC000491E, 0xCF800000, 0xC2C00000, 0xC7EC0068, 0xC100001C, 0xC52C1050, 0xC100000A, 0xC52C0D18,
+ 0xC000491C, 0xCEC00000, 0x99007CF0, 0xC000491C, 0xC1400000, 0xC9420050, 0xC2800000, 0xDF680040,
+ 0x5D280080, 0x8800FFD0, 0xC000491C, 0xCAC00000, 0xC000491E, 0xCB800000, 0x99007F18, 0xDAD80000,
+ 0xDB980001, 0x00000000, 0xC00047CE, 0xC9000000, 0x00000000, 0x00000000, 0x59100002, 0xCD000000,
+ 0x00000000, 0x80001868, 0x00000000, 0x00000000, 0x00000000, 0xC0004878, 0xC8040000, 0x6C908000,
+ 0x44908000, 0x44908000, 0x40100000, 0xCA000000, 0xC4240000, 0x00000000, 0xC0004934, 0xCE000000,
+ 0xC2800002, 0xC4681C10, 0xC62821D8, 0xC6281E08, 0xC2600010, 0x5A650080, 0xC0004800, 0xCB400000,
+ 0xC2200400, 0x5A200040, 0xC7601048, 0xC0001220, 0xCE800000, 0xC0001200, 0xCE400000, 0xC0001202,
+ 0xCE000000, 0xC0001240, 0xCB400000, 0x00000000, 0x00000000, 0xA754FFC0, 0xC2000000, 0xC7600048,
+ 0xA7520022, 0x00000000, 0x00000000, 0x99008690, 0xC0004822, 0xC9400000, 0xC1800002, 0x800016F8,
+ 0x582040C0, 0xC2000000, 0xCA000020, 0xC2400000, 0xCA414008, 0xC2800000, 0xCA812008, 0xC2C00000,
+ 0xCAC20020, 0xC0004938, 0xCE000000, 0xC0004920, 0xCE400000, 0xC0004916, 0xCE800000, 0xC0004922,
+ 0xCEC00000, 0xA6400538, 0x00000000, 0xC0004938, 0xCBC00000, 0x00000000, 0xC3800000, 0x6FF48000,
+ 0x6FD44000, 0x4355A000, 0x5B744A00, 0x58340000, 0xCB802018, 0x00000000, 0xC2000000, 0x6FB46000,
+ 0x47B5A000, 0x5B744C80, 0x5834000C, 0xCA000028, 0xC000491A, 0xCF800000, 0x5E200000, 0x8400046A,
+ 0xC2000000, 0xDF610050, 0x5E6001E8, 0x8800FFD0, 0xC2000002, 0xC2400466, 0xC2A00000, 0x5AA80000,
+ 0xC0001006, 0xCE000000, 0xC0001008, 0xCE400000, 0xC000100A, 0xCE800000, 0x99007958, 0xC1A0FFFE,
+ 0xC0000824, 0xC9840068, 0xC0004934, 0xCA400000, 0xC2000000, 0xC2800002, 0x99007998, 0xDA980000,
+ 0xC6140000, 0xC6580000, 0xC161FFFE, 0x5955FFFE, 0x15400000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x99007A80, 0xC000491A, 0xC9400000, 0x00000000, 0x00000000, 0xC121FFFE, 0x5911FE54,
+ 0x15000000, 0xC0004922, 0xCA001120, 0xC3C00000, 0xC3800000, 0xC0004930, 0xCE001120, 0xC0004932,
+ 0xCBC000E0, 0xC2800000, 0xC000491E, 0xCFC00000, 0xC0004862, 0xCA800068, 0xC3A0001A, 0x5BB94000,
+ 0xC6B80068, 0xC000491C, 0xCF800000, 0x99007CF0, 0xC000491C, 0xC1400000, 0xC9420050, 0x00000000,
+ 0x00000000, 0x00000000, 0xA8E2FFC8, 0xC2000000, 0xC1220002, 0xD90C0000, 0xDF600040, 0x5E600080,
+ 0x8400FFDA, 0xC000491C, 0xCA000000, 0xC000491E, 0xCA400000, 0x00000000, 0x00000000, 0x99007F18,
+ 0xDA180000, 0xDA580001, 0x00000000, 0xC2000000, 0xDF610050, 0x5E6001FE, 0x8800FFD0, 0xC0004916,
+ 0xCA800000, 0xC2C00000, 0xDFEC0050, 0xC2400000, 0x46E52000, 0x84000032, 0x5EA80000, 0x84000022,
+ 0xC2600002, 0x99008690, 0xC000482E, 0xC9400000, 0xC1800002, 0x80000018, 0xC2600000, 0x99008690,
+ 0xC000482C, 0xC9400000, 0xC1800002, 0xC2000068, 0xC6240080, 0xC0004930, 0xCE400088, 0xC000491A,
+ 0xC9800000, 0xC0004862, 0xC9400000, 0x6D9C6000, 0x459CE000, 0x59DC4C80, 0x99007D78, 0xD9580000,
+ 0xD9980001, 0xD9D40000, 0x99007CF0, 0xC000491C, 0xC1400000, 0xC9420050, 0xC2000000, 0xDF600040,
+ 0x5E600080, 0x8400FFD2, 0x00000000, 0xC000491C, 0xCA000000, 0xC000491E, 0xCA400000, 0x00000000,
+ 0x00000000, 0x99007F18, 0xDA180000, 0xDA580001, 0x00000000, 0x80001148, 0x00000000, 0x99008690,
+ 0xC000482A, 0xC9400000, 0xC1800002, 0x80001118, 0xC0004938, 0xCBC00000, 0x00000000, 0x00000000,
+ 0x6FF88000, 0x6FD44000, 0x4395C000, 0x5BB84A00, 0x58380008, 0xCA000000, 0x00000000, 0x00000000,
+ 0xA600037A, 0x00000000, 0xC0004938, 0xCBC00000, 0xC3000000, 0x00000000, 0x6FF88000, 0x6FD44000,
+ 0x4395C000, 0x5BB84A00, 0x58380000, 0xCB002018, 0xC2000000, 0x58380008, 0xCA020080, 0x5838000C,
+ 0xCAC00000, 0x5838000E, 0xCA400000, 0xC000491A, 0xCF000000, 0xC0004930, 0xCEC00000, 0xC000493C,
+ 0xCE000000, 0xC0004932, 0xCE400000, 0x5E200000, 0x84000120, 0xC2800000, 0xA6FE00B2, 0x6F206000,
+ 0x47210000, 0x5A204C80, 0x5820000C, 0xCA800028, 0x00000000, 0x00000000, 0x5EA80000, 0x840001F2,
+ 0x00000000, 0xC161FFFE, 0x5955FFFE, 0x15400000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x99007A80, 0xC000491A, 0xC9400000, 0x00000000, 0x00000000, 0xC121FFFE, 0x5911FE54, 0x15000000,
+ 0xC0004930, 0xCAC00000, 0xC0004932, 0xCA400000, 0xC7EC1120, 0xC0004930, 0xCEC00000, 0x5838000C,
+ 0xCEC00000, 0x58000002, 0xCE400000, 0xC0004934, 0xCA000000, 0xC2400002, 0x6E642000, 0x6E642000,
+ 0x76252000, 0x84000012, 0xC2400002, 0x6E684000, 0x58380008, 0xCE800208, 0xA6000000, 0x6E682000,
+ 0x58380008, 0xCE800108, 0xC2400002, 0x6E642000, 0x76252000, 0x840000D2, 0x58380008, 0xCA000000,
+ 0xC2800000, 0xC2400000, 0xA60200A0, 0xDBA80000, 0x6F386000, 0x4739C000, 0x5BB84C80, 0x58380004,
+ 0xCA400080, 0x58380002, 0xCA800080, 0x00000000, 0xDEB80000, 0x46694000, 0x88000048, 0x00000000,
+ 0xC0004824, 0xCA000000, 0xC2400002, 0x6E640000, 0x5A200002, 0xCE000000, 0x58380008, 0xCE400008,
+ 0x80000000, 0x00000000, 0x80000030, 0xC0004934, 0xCA000000, 0x00000000, 0x00000000, 0xA6020CAA,
+ 0x00000000, 0x00000000, 0x80000CE0, 0xC2800000, 0xC2000200, 0xC240001A, 0xDF690050, 0x46A14000,
+ 0x46694000, 0x8800FFBA, 0xC2000006, 0xC2600982, 0x5A643B6E, 0x5838000A, 0xCA800000, 0xC0001006,
+ 0xCE000000, 0xC0001008, 0xCE400000, 0xC000100A, 0xCE800000, 0x99007958, 0xC1A0FFFE, 0xC0000824,
+ 0xC9840068, 0xC2000000, 0xC0004930, 0xCA02E010, 0x58380026, 0xCA400000, 0x00000000, 0xC2800000,
+ 0x99007998, 0xDA980000, 0xC6140000, 0xC6580000, 0xC0004934, 0xCA000000, 0x00000000, 0x00000000,
+ 0xA6020002, 0x00000000, 0x00000000, 0x80000300, 0xC0004938, 0xCBC00000, 0xC0004878, 0xC8040000,
+ 0x6C908000, 0x44908000, 0x44908000, 0x40100000, 0xCA000000, 0xC4240000, 0x00000000, 0x58240018,
+ 0xCA000000, 0x6FF88000, 0x6FD44000, 0x4395C000, 0x5BB84A00, 0xC3000000, 0xC3400002, 0xC2C00000,
+ 0xC62C0080, 0xC6270040, 0xC0004940, 0xCE400040, 0xC6260040, 0xC0004942, 0xCE400040, 0xC000493C,
+ 0xCA000000, 0x5EEC0000, 0x84000172, 0x5A6C0010, 0x46614000, 0x88000178, 0x5A600052, 0x466D4000,
+ 0x88000160, 0x58380006, 0xCA800000, 0xC0004940, 0xCA000000, 0xC2400000, 0xC6A70040, 0x7E412000,
+ 0x76252000, 0xC2000000, 0xC6A10040, 0x46610000, 0x84000120, 0xC0004942, 0xCA000000, 0xC2400000,
+ 0xC6A60040, 0x7E412000, 0x76252000, 0xC2000000, 0xC6A00040, 0x58380002, 0xCA800000, 0x46610000,
+ 0x840000D0, 0xC2400000, 0xC6A60080, 0x46E50000, 0x880000C2, 0xC2400000, 0xC6A40080, 0x58380008,
+ 0xCA800000, 0x466D0000, 0x880000A2, 0x00000000, 0xA682FFF8, 0x00000000, 0xC7700B08, 0xA6840078,
+ 0x00000000, 0xC7700A08, 0x80000068, 0xC7700208, 0xC000493C, 0xCAC00000, 0x80000048, 0xC7700308,
+ 0xC000493C, 0xCAC00000, 0x80000028, 0xC7700908, 0x80000018, 0xC7700808, 0x80000008, 0xC7700708,
+ 0x8000FFF8, 0xC7700508, 0xC0004944, 0xCF000000, 0xC000493E, 0xCEC00000, 0xC0004938, 0xCA400000,
+ 0xC000493C, 0xCB800000, 0xC000493E, 0xCB400000, 0xC3000000, 0x6E608000, 0x6E544000, 0x42150000,
+ 0x5A204A00, 0x5AA00008, 0x58200004, 0xCB000080, 0xC0004934, 0xCA000000, 0xC2400000, 0xC0004930,
+ 0xCA42E010, 0xC3C00018, 0xA6020078, 0x00000000, 0x43656000, 0x46F90000, 0x88000038, 0x47AD6000,
+ 0x6EE04010, 0x5BE00004, 0xC2000000, 0xC6E00010, 0x5E200000, 0x8400002A, 0x5BFC0002, 0x80000018,
+ 0xC3C00004, 0x5A2C0008, 0x46390000, 0x8800FFFA, 0x5FB80008, 0x6FE04000, 0x42390000, 0x46312000,
+ 0x88000050, 0xC2400000, 0xC0004930, 0xCA42E010, 0xC2060002, 0xC6800000, 0xCE000308, 0x6FE04000,
+ 0x4631C000, 0x5F700010, 0x4675A000, 0xC2000000, 0xC6340010, 0xC25A000A, 0xC000491A, 0xCA401C20,
+ 0xC2800000, 0xC0004932, 0xCA8000E0, 0xC0004862, 0xCA400068, 0x6FA04010, 0x42290000, 0xC000491E,
+ 0xCE000000, 0xC7E41050, 0xC000491C, 0xCE400000, 0x6FE04000, 0x43A1C000, 0xC000493C, 0xCF800000,
+ 0xC000493E, 0xCF400000, 0xC000493A, 0xCFC00000, 0x8000FFF0, 0x00000000, 0x00000000, 0x00000000,
+ 0xC2000000, 0xDCE00000, 0xA622FFB8, 0xC1220002, 0xD90C0000, 0xC0004938, 0xCBC00000, 0xC0004944,
+ 0xCB400000, 0xC0004862, 0xCB000000, 0xC0004934, 0xCA000000, 0x6FF88000, 0x6FD44000, 0x4395C000,
+ 0x5BB84A00, 0xA6020278, 0xC2400000, 0x58380008, 0xCA406008, 0xDFE80000, 0xC2218E08, 0x5A21BAF6,
+ 0x46294000, 0x8400000A, 0xC2080002, 0x7235A000, 0x80000040, 0x5E640000, 0x8400000A, 0xC20C0002,
+ 0x7235A000, 0x80000018, 0xC2000000, 0xC760E718, 0xC7604220, 0x5E200000, 0x8400028A, 0xC2200002,
+ 0xC0004930, 0xCE001008, 0x99008690, 0xC0004828, 0xC9400000, 0xC1800002, 0xC0004780, 0xC93C0000,
+ 0x00000000, 0x00000000, 0x59100002, 0xCD3C0000, 0x58380000, 0xCA000000, 0x00000000, 0x00000000,
+ 0xA6000112, 0xC0004940, 0xCA800000, 0xC0004942, 0xCA400000, 0xC7600080, 0xC6A01840, 0xC6601040,
+ 0xC000493A, 0xCA400000, 0xC0004934, 0xCA800000, 0xC0007200, 0x40300000, 0x40240000, 0x5C000004,
+ 0x5EC07400, 0x8800FFFA, 0x5C000200, 0xCE000000, 0x58000002, 0x5EC07400, 0x8800FFFA, 0x5C000200,
+ 0xCE800000, 0xC000493E, 0xCA000000, 0xC2400000, 0x5838000C, 0xCE400000, 0x99008690, 0xC0004830,
+ 0xC9400000, 0xC6180000, 0xC0004930, 0xC6100080, 0xCD000080, 0x80000090, 0xC2400002, 0x58380008,
+ 0xCE400008, 0xC0004944, 0xCF400000, 0x80000290, 0xC000493C, 0xCA400000, 0xDFE80000, 0x5A300018,
+ 0xC0007200, 0x40200000, 0xCA000000, 0x58380008, 0xC6501080, 0xCD001080, 0x5838000A, 0xCE800000,
+ 0x58380026, 0xCE000000, 0xC0004944, 0xCF400000, 0x99007CF0, 0xC000491C, 0xC1400000, 0xC9420050,
+ 0x80000050, 0x00000000, 0x99008690, 0xC0004826, 0xC9400000, 0xC1800002, 0xC0004760, 0xC93C0000,
+ 0x00000000, 0x00000000, 0x59100002, 0xCD3C0000, 0x8000FD90, 0xC2000000, 0xC2400080, 0xDF600040,
+ 0xB624FFCA, 0xC000491C, 0xCA400000, 0xC000491E, 0xCA800000, 0x99007F18, 0xDA580000, 0xDA980001,
+ 0x00000000, 0xC0004934, 0xCA000000, 0x00000000, 0xC2800000, 0xA6020140, 0xC2400004, 0xC2000200,
+ 0xDF690050, 0x46A14000, 0x46694000, 0x8800FFC2, 0x00000000, 0xC000491A, 0xC9800000, 0xC0004862,
+ 0xC9400000, 0x6D9C6000, 0x459CE000, 0x59DC4C80, 0x99007D78, 0xD9580000, 0xD9980001, 0xD9D40000,
+ 0x99007CF0, 0xC000491C, 0xC1400000, 0xC9420050, 0xC2000000, 0xC2400080, 0xDF600040, 0xB624FFCA,
+ 0xC000491C, 0xCA400000, 0xC000491E, 0xCA800000, 0x99007F18, 0xDA580000, 0xDA980001, 0x00000000,
+ 0x58380008, 0xCA400000, 0xC2000000, 0xCE000020, 0xC2A1FFFE, 0x5AA9FFFE, 0xCE001080, 0x5838000A,
+ 0xCE800000, 0xC161FFFE, 0x5955FFFE, 0x15400000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC0000838, 0xC2500002, 0xCE440808, 0xC0004848, 0xCBC40000, 0xC3800000, 0xC000082C, 0xCB840030,
+ 0x5FFC0002, 0xC0004848, 0xCFC40000, 0x58880002, 0x44B88000, 0xC1000000, 0xC5080006, 0xC0004844,
+ 0xCC840000, 0x00000000, 0xC121FFFE, 0x5911FE54, 0x15000000, 0x8000CBD8, 0xC2000000, 0xDF600040,
+ 0x5E200080, 0x84000282, 0x00000000, 0xC161FFFE, 0x5955FFFE, 0x15400000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0xC000480C, 0xCA000000, 0xC0004910, 0xCA400000, 0xC000492C, 0xCA800000,
+ 0xC0004968, 0xCAC00000, 0x00000000, 0xC121FFFE, 0x5911FE54, 0x15000000, 0x76610000, 0x76A10000,
+ 0x762D6000, 0x840001C2, 0xC0004926, 0xCA400000, 0xC201FFFE, 0x762D6000, 0x5A640002, 0x6AE50010,
+ 0x5F200000, 0x84000002, 0x6A250000, 0x8000FFF8, 0xC6E00000, 0x62014008, 0xC0004926, 0xCE800000,
+ 0xC161FFFE, 0x5955FFFE, 0x15400000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xC0004968,
+ 0xCA400000, 0xC2000002, 0x6A290000, 0x7E010000, 0x76252000, 0xCE400000, 0x00000000, 0xC121FFFE,
+ 0x5911FE54, 0x15000000, 0x6EB4A000, 0x6E944000, 0x4575A000, 0x46B5A000, 0x5B744E20, 0x58340002,
+ 0xC2000000, 0xCA0000E0, 0x5834002E, 0xC2400000, 0xCA400080, 0x6EB0A000, 0x6EBC4000, 0x47F18000,
+ 0x46B18000, 0x5B300E4E, 0x5B300004, 0x6E642000, 0x4225E000, 0xC39A8024, 0xC7380068, 0xC6B81C20,
+ 0x99007F18, 0xDB980000, 0xDBD80001, 0x00000000, 0xC2000000, 0xDF600040, 0x5E200080, 0x840002BA,
+ 0x00000000, 0xC161FFFE, 0x5955FFFE, 0x15400000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC000490E, 0xCA000000, 0xC000492A, 0xCA400000, 0xC000496A, 0xCB000000, 0xC0004956, 0xCAC00000,
+ 0x00000000, 0xC121FFFE, 0x5911FE54, 0x15000000, 0x76318000, 0x76718000, 0x84000202, 0xC201FFFE,
+ 0x76318000, 0x5AEC0002, 0x6B2D0010, 0x5EA00000, 0x84000002, 0x6A2D0000, 0x8000FFF8, 0xC7200000,
+ 0x62016008, 0xC0004956, 0xCEC00000, 0xC161FFFE, 0x5955FFFE, 0x15400000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0xC000496A, 0xCA400000, 0xC2000002, 0x6A2D0000, 0x7E010000, 0x76252000,
+ 0xCE400000, 0x00000000, 0xC121FFFE, 0x5911FE54, 0x15000000, 0x6EF4A000, 0x6ED44000, 0x4575A000,
+ 0x46F5A000, 0x5B744E20, 0x5834000E, 0xC2000000, 0xCA0000E0, 0x58340008, 0xC2400000, 0xCA420080,
+ 0x5834000C, 0xC2800000, 0xCA832018, 0x6E644010, 0x42250000, 0x4229E000, 0xC39A8008, 0x58340008,
+ 0xCB809020, 0x58340008, 0xC2800000, 0xCA810018, 0x6EE0A000, 0x6EE44000, 0x46610000, 0x46E10000,
+ 0x5A200008, 0x5A200E28, 0x42290000, 0xC6380068, 0xC6F81C20, 0x99007F18, 0xDB980000, 0xDBD80001,
+ 0x00000000, 0xC000495A, 0xC8400000, 0x00000000, 0xC3C00002, 0x7BC42000, 0xCC400000, 0xC0001A1C,
+ 0xCA000000, 0xC2400008, 0x6A452000, 0x76610000, 0x84000E82, 0xC0000A28, 0xC3800000, 0xCB840030,
+ 0xC0000A14, 0xC3400000, 0xCB440030, 0xC0004880, 0xCB040000, 0x47788000, 0x88000E30, 0x58041802,
+ 0xCAC00000, 0xA7000040, 0x00000000, 0x00000000, 0xA6C8C5A8, 0xC2800000, 0xC6E80020, 0x80000058,
+ 0x00000000, 0x00000000, 0x00000000, 0x8000C578, 0x00000000, 0xC2800000, 0xC7282020, 0xC000490E,
+ 0xCA400000, 0x6BE9E000, 0x00000000, 0x77E52000, 0x8400C530, 0x6EA0A000, 0x6E944000, 0x45610000,
+ 0x46A10000, 0x5A204E20, 0x5820000C, 0xCA000000, 0xC0004946, 0xCE800000, 0xA6220378, 0x00000000,
+ 0xC2200060, 0xC0004948, 0xCE000010, 0xCE001040, 0xC240000A, 0xC000494A, 0xCE400000, 0xC2B60002,
+ 0xC0004964, 0xCE801B08, 0x990081E8, 0xC00048A0, 0xC8840000, 0x00000000, 0xC0004946, 0xCBC00000,
+ 0x00000000, 0x00000000, 0x6FF8A000, 0x6FD44000, 0x4579C000, 0x47F9C000, 0x5BB84E20, 0x99007FA8,
+ 0xDBD80000, 0xDB980001, 0x00000000, 0x99007CF0, 0xC000491C, 0xC1400000, 0xC9420050, 0xC000491C,
+ 0x990081A0, 0xC9400001, 0xC9800000, 0x00000000, 0x99007F18, 0xD9580000, 0xD9980001, 0x00000000,
+ 0xC161FFFE, 0x5955FFFE, 0x15400000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x99007BE0,
+ 0xDBD80000, 0xDB980001, 0xC7D80000, 0x00000000, 0xC121FFFE, 0x5911FE54, 0x15000000, 0x6FF8A000,
+ 0x6FD44000, 0x4579C000, 0x47F9C000, 0x5BB84E20, 0x58380010, 0xCA000000, 0xC0004874, 0xC8040000,
+ 0x6C908000, 0x44908000, 0x44908000, 0x40100000, 0xCA400000, 0xC4340000, 0x00000000, 0xC7400000,
+ 0xCE000000, 0xC161FFFE, 0x5955FFFE, 0x15400000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC000490E, 0xCA400000, 0xC2800002, 0x6ABD4000, 0x72A52000, 0xCE400000, 0x00000000, 0xC121FFFE,
+ 0x5911FE54, 0x15000000, 0x99008690, 0xC0004836, 0xC9400000, 0xC1800002, 0x00000000, 0x00000000,
+ 0x00000000, 0xA8E2FFC8, 0x00000000, 0xC1220002, 0xD90C0000, 0xC2000000, 0xC0000A14, 0xCA040030,
+ 0xC0000A28, 0xC2500002, 0xCE440808, 0x58880002, 0xB608FFF8, 0xC00048A0, 0xC0800000, 0xCC840000,
+ 0x8000C150, 0xC0004946, 0xCBC00000, 0xC161FFFE, 0x5955FFFE, 0x15400000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0xC000490E, 0xCA400000, 0xC2800002, 0x6ABD4000, 0x72A52000, 0xCE400000,
+ 0x00000000, 0xC121FFFE, 0x5911FE54, 0x15000000, 0x6FF8A000, 0x6FD44000, 0x4579C000, 0x47F9C000,
+ 0x5BB84E20, 0x58380008, 0xCA000000, 0x5838000C, 0xCA400000, 0xC3400000, 0xC6340008, 0xC000494E,
+ 0xCF400000, 0xC2800000, 0xC62A0080, 0xC3000000, 0xC6308020, 0x6F304000, 0x43298000, 0xC000493C,
+ 0xCF000000, 0xC2C00000, 0xC66C0080, 0xC0004950, 0xCEC00000, 0xC2800000, 0xC66AE028, 0xC0004954,
+ 0xCE800000, 0x5F740000, 0x840001A0, 0x5E300028, 0x462D2000, 0x8400016A, 0x462D2000, 0x88000132,
+ 0x5E300018, 0x462D2000, 0x88000012, 0x462D2000, 0x8400002A, 0x00000000, 0x800000C0, 0x00000000,
+ 0x99008328, 0xDBD80000, 0xDB980001, 0xC7800000, 0xC3400002, 0xC000494E, 0xCF400000, 0xC161FFFE,
+ 0x5955FFFE, 0x15400000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xC000490E, 0xCA400000,
+ 0xC2800002, 0x6ABD4000, 0x7E814000, 0x76A52000, 0xCE400000, 0x00000000, 0xC121FFFE, 0x5911FE54,
+ 0x15000000, 0xC2200060, 0xC0004948, 0xCE001040, 0xC2000000, 0xC000494C, 0xCE000000, 0x80000068,
+ 0x00000000, 0x99008328, 0xDBD80000, 0xDB980001, 0xC7800000, 0x99008528, 0xDBD80000, 0xDB980001,
+ 0xC7800000, 0xC2200058, 0xC0004948, 0xCE001040, 0xC2000002, 0xC000494C, 0xCE000000, 0xC2000006,
+ 0xC0001006, 0xCE000000, 0x5838000A, 0xCA400000, 0xC2200982, 0x5A203B6E, 0xC0001008, 0xCE000000,
+ 0xC000100A, 0xCE400000, 0xC0004954, 0xCA800000, 0xC200000C, 0xC000494A, 0xCE000000, 0xC0004948,
+ 0xCE800010, 0xC2B60000, 0xC0004964, 0xCE800000, 0x990081E8, 0xC00048A0, 0xC8840000, 0x00000000,
+ 0xC0004946, 0xCBC00000, 0xC000494C, 0xCA000000, 0x6FF8A000, 0x6FD44000, 0x4579C000, 0x47F9C000,
+ 0x5BB84E20, 0x5E200000, 0x840000FA, 0x00000000, 0x99007FA8, 0xDBD80000, 0xDB980001, 0x00000000,
+ 0x99007CF0, 0xC000491C, 0xC1400000, 0xC9420050, 0xC000491C, 0x990081A0, 0xC9400001, 0xC9800000,
+ 0x00000000, 0x99007F18, 0xD9580000, 0xD9980001, 0x00000000, 0xC161FFFE, 0x5955FFFE, 0x15400000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x99007BE0, 0xDBD80000, 0xDB980001, 0xC7D80000,
+ 0x00000000, 0xC121FFFE, 0x5911FE54, 0x15000000, 0xC000493C, 0xCA800000, 0xC000494E, 0xCAC00000,
+ 0xC3000018, 0xC3400006, 0x5E200000, 0x84000012, 0xC2800000, 0xC2C00000, 0xC300001E, 0xC3400000,
+ 0xC6AC1080, 0xC72C0420, 0xC76C0818, 0x58380010, 0xCA800000, 0x58380008, 0xCEC00000, 0xC6280108,
+ 0xC0004874, 0xC8040000, 0x6C908000, 0x44908000, 0x44908000, 0x40100000, 0xCB000000, 0xC4340000,
+ 0x00000000, 0xC7400000, 0xCE800000, 0xC0004952, 0xCE800000, 0x00000000, 0x00000000, 0x00000000,
+ 0xA8E2FFC8, 0x00000000, 0xC000494C, 0xCA000000, 0xC0004950, 0xCAC00000, 0x5E200000, 0x84000052,
+ 0xDFE80000, 0x7E814000, 0x5834001A, 0xCE800000, 0x99008690, 0xC0004834, 0xC9400000, 0xC1800002,
+ 0x99008690, 0xC0004838, 0xC9400000, 0xC6D80000, 0xC1220002, 0xD90C0000, 0x5E200000, 0x84000028,
+ 0x5838002C, 0xCB000000, 0xDFE80000, 0x00000000, 0x58380014, 0xCF000000, 0x80000000, 0xC2A1FFFE,
+ 0x5AA9FFFE, 0x5838000A, 0xCE800000, 0xC3000000, 0xC0000A14, 0xCB040030, 0xC2D00002, 0xC0000A28,
+ 0xCEC40808, 0xC000494E, 0xCA800000, 0x58880002, 0xB4B0FFF8, 0xC00048A0, 0xC0800000, 0xCC840000,
+ 0x5EA80000, 0x84000152, 0x5E200000, 0x84000140, 0xC000493C, 0xCA800000, 0x00000000, 0x00000000,
+ 0x5AA80060, 0xCE800000, 0x99008328, 0xDBD80000, 0xDB980001, 0xC7800000, 0x99008528, 0xDBD80000,
+ 0xDB980001, 0xC7800000, 0xC0004952, 0xCAC00000, 0x58380000, 0xCA800000, 0xC30C0002, 0xC7F00020,
+ 0xA6800090, 0x00000000, 0x00000000, 0xC161FFFE, 0x5955FFFE, 0x15400000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0xC0001800, 0xCA000000, 0x00000000, 0x00000000, 0xA60CFFCA, 0xC6F00508,
+ 0xC6B0C408, 0xCF000000, 0x00000000, 0xC121FFFE, 0x5911FE54, 0x15000000, 0x8000B7A0, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x8000B738, 0xDCBC0001, 0x5FFC0000, 0x84000942, 0xC3800002,
+ 0xDB880001, 0xC3800000, 0xDB880001, 0xC0004728, 0xC9000000, 0x00000000, 0x00000000, 0x59100002,
+ 0xCD000000, 0xC0004730, 0xC9800000, 0xC000472E, 0xC9400000, 0xC00047DC, 0xC9000000, 0xC00047DE,
+ 0xC9C00000, 0xC000472E, 0xCD800000, 0x6D110000, 0xC5D30040, 0xC00047DC, 0xCD000000, 0x4558A000,
+ 0x6DDD0000, 0xC55C0040, 0xC00047DE, 0xCDC00000, 0xC0001AC4, 0xC9400000, 0xC0001AC8, 0xC9800000,
+ 0xC000472C, 0xC9C00000, 0x45588000, 0xC1000002, 0x41D0E004, 0xCDC00000, 0xC5501080, 0xC5900080,
+ 0xC000472A, 0xCD000000, 0xC0001AF0, 0xCBC00000, 0x58000002, 0xCB800000, 0xC3400000, 0xC7F50040,
+ 0x6F702000, 0x5B304300, 0xC000474C, 0xCAC00000, 0xC0004720, 0xC9400000, 0x00000000, 0x00000000,
+ 0x5D940002, 0x6D9B8000, 0x6D9B8010, 0x581847E0, 0xC9800000, 0x581447E0, 0xC9C00000, 0x5D2C0000,
+ 0x84000062, 0xC7901080, 0xC7D00080, 0xCD000000, 0xC1000000, 0xC5910040, 0x47508000, 0x84000078,
+ 0xC0004722, 0xC9000000, 0x00000000, 0x00000000, 0x59100002, 0xCD000000, 0x80000040, 0xC1000000,
+ 0xC5D10040, 0x47508000, 0x84000022, 0xC0004724, 0xC9000000, 0x00000000, 0x00000000, 0x59100002,
+ 0xCD000000, 0xA7840060, 0x59540002, 0x6D578000, 0x6D578010, 0xC0004720, 0xCD400000, 0xC1000000,
+ 0xC5910040, 0x47508000, 0x84000020, 0xC0004726, 0xC9000000, 0x00000000, 0x00000000, 0x59100002,
+ 0xCD000000, 0xA7800098, 0xC2800002, 0xC000474E, 0xCE800000, 0xC2C00000, 0xC000474C, 0xCEC00000,
+ 0xC0004758, 0xCFC00000, 0x58000002, 0xCF800000, 0xC000475C, 0xC9000000, 0x00000000, 0x00000000,
+ 0xA53E001A, 0x00000000, 0xC13E0002, 0xCFC00000, 0xCD001E10, 0x58000002, 0xCF800000, 0x80000188,
+ 0xC000475C, 0xC13C0002, 0xCD001E10, 0x5D2C0000, 0x84000162, 0xC2C00000, 0xC000474C, 0xCEC00000,
+ 0x98C08AF0, 0xC7540000, 0xC0004740, 0xC9C00000, 0x5D240000, 0x8400002A, 0xC1000002, 0xC0004750,
+ 0xCD000000, 0xC0004752, 0xCD000000, 0x800000E8, 0x00000000, 0x98C08BE0, 0xC7540000, 0xC0004742,
+ 0xC9800000, 0x5D240000, 0x84000012, 0xC1000002, 0xC0004752, 0xCD000000, 0x80000048, 0xC0004742,
+ 0xC9400000, 0xC0004754, 0xC1000002, 0xCD000000, 0x98C08CF0, 0xC5540000, 0xC7580000, 0x00000000,
+ 0xC0004742, 0xCF400000, 0x98C08AB8, 0xC1400000, 0xC7540028, 0x6F40A010, 0xC1000000, 0xC7D00040,
+ 0x58300000, 0x6D110000, 0xCD000840, 0xA7840378, 0xC000474C, 0xCAC00000, 0xC000474E, 0xCA800000,
+ 0xC0004750, 0xCBC00000, 0xC0004752, 0xCB800000, 0xC0004710, 0xC9000000, 0x00000000, 0x00000000,
+ 0x59100002, 0xCD000000, 0x5D280002, 0x840000A0, 0xC000473C, 0xC9000000, 0x00000000, 0x00000000,
+ 0x59100002, 0xCD000000, 0xC0004712, 0xC9000000, 0x00000000, 0x00000000, 0x59100002, 0xCD000000,
+ 0xC0004754, 0xC9000000, 0x00000000, 0x00000000, 0x5D100000, 0x84000202, 0x58300000, 0xC13C0002,
+ 0xCD001E08, 0x800001E0, 0xC0004714, 0xC9000000, 0x00000000, 0x00000000, 0x59100002, 0xCD000000,
+ 0x5D380000, 0x84000022, 0xC0004736, 0xC9000000, 0x00000000, 0x00000000, 0x59100002, 0xCD000000,
+ 0x5D3C0000, 0x8400002A, 0xC0004718, 0xC9000000, 0x00000000, 0x00000000, 0x59100002, 0xCD000000,
+ 0x80000128, 0xC1000000, 0x58300000, 0xC903E008, 0x00000000, 0x00000000, 0x5D100000, 0x8400002A,
+ 0xC000471A, 0xC9000000, 0x00000000, 0x00000000, 0x59100002, 0xCD000000, 0x800000B8, 0x58300000,
+ 0xC13E0002, 0xCD001F08, 0xC1000000, 0x58300000, 0xC903C008, 0x00000000, 0x00000000, 0x5D100000,
+ 0x8400006A, 0xC0004716, 0xC9000000, 0x00000000, 0x00000000, 0x59100002, 0xCD000000, 0xC000473A,
+ 0xC9000000, 0x00000000, 0x00000000, 0x59100002, 0xCD000000, 0x58300000, 0xC13C0000, 0xCD001E08,
+ 0xC1000000, 0xC0004746, 0xCD000000, 0xC0004750, 0xCD000000, 0xC0004752, 0xCD000000, 0xC000474E,
+ 0xCD000000, 0xC2C00002, 0xC000474C, 0xCEC00000, 0xC0004754, 0xCD000000, 0xC3CE0002, 0xC0000800,
+ 0xCFC00708, 0xC3E1FFFE, 0x597DFFFE, 0x593DFE14, 0x94000001, 0x00000000, 0x00000000, 0x00000000,
+ 0xC000487C, 0xC8040000, 0x00000000, 0x00000000, 0x40080000, 0xCBC00000, 0xC4380000, 0x00000000,
+ 0xC000480E, 0xCA000000, 0xC0004858, 0xCB440000, 0x00000000, 0x00000000, 0x46350000, 0x88000098,
+ 0x00000000, 0xA7C00028, 0xC0004854, 0xC1000002, 0xCD040000, 0xC11C0000, 0xC000082C, 0xCD040E08,
+ 0x800000C0, 0x00000000, 0xA7D20118, 0x00000000, 0xC7E14048, 0xC2400000, 0xC6246030, 0xC200006A,
+ 0x46610000, 0xC6240038, 0xC0000810, 0xCE440038, 0x8000FF58, 0xC2000000, 0xC0000808, 0xCA040018,
+ 0xC11C0000, 0xC000082C, 0xCD040E08, 0x5A200002, 0x5E600010, 0x8400FFF8, 0xC2000000, 0xC0000808,
+ 0xCE040018, 0xC3400000, 0x80000010, 0xC1200002, 0xC0000818, 0xCD041008, 0x5B740002, 0xC0004858,
+ 0xCF440000, 0x99007930, 0xC0004848, 0xC9440000, 0xC1800000, 0xC11C0002, 0xC000082C, 0xCD040E08,
+ 0x80000860, 0x5B740002, 0xC0004858, 0xCF440000, 0xC7800000, 0xC13C0002, 0xCD001E08, 0xC0004848,
+ 0xC9440000, 0xC1800000, 0xC000082C, 0xC9840030, 0x59540002, 0xC0004848, 0xCD440000, 0x58880002,
+ 0xB49807D8, 0x00000000, 0xC0800000, 0x800007C8, 0xC000487C, 0xC8040000, 0x00000000, 0x00000000,
+ 0x40080000, 0xCBC00000, 0xC4280000, 0x00000000, 0xA7C00110, 0xC000484C, 0xCA040000, 0xC2400000,
+ 0xC0001AEC, 0xCA440020, 0x5A200002, 0xC000484C, 0xCE040000, 0xB624006A, 0xC6800000, 0xC13C0002,
+ 0xCD001E08, 0xC0004848, 0xC9440000, 0xC1800000, 0xC000082C, 0xC9840030, 0x59540002, 0xC0004848,
+ 0xCD440000, 0x58880002, 0xB49806C8, 0x00000000, 0xC0800000, 0x800006B8, 0xC0004854, 0xC1000004,
+ 0xCD040000, 0xC0000820, 0xC2000002, 0xCE040000, 0xC2000000, 0xC000484C, 0xCE040000, 0xC0004858,
+ 0xCE040000, 0x8000FF10, 0xC0004854, 0xC1000000, 0xCD040000, 0xC11C0000, 0xC000082C, 0xCD040E08,
+ 0x99007930, 0xC0004848, 0xC9440000, 0xC1800000, 0xC1200000, 0xC0000818, 0xCD041008, 0xC11C0002,
+ 0xC000082C, 0xCD040E08, 0xC2000000, 0xC000484C, 0xCE040000, 0x800005B8, 0xC0001AC0, 0xCB840000,
+ 0xC000487C, 0xC8040000, 0x00000000, 0x00000000, 0x40080000, 0xCBC00000, 0xC4280000, 0x00000000,
+ 0xA78004C2, 0x00000000, 0x00000000, 0xA7C00482, 0x00000000, 0xC0001B00, 0xC2060006, 0xCE040310,
+ 0xA7E8043A, 0x00000000, 0xC0004850, 0xCA040000, 0xC2400000, 0xC0004812, 0xCA420080, 0x5A200002,
+ 0xC0004850, 0xCE040000, 0x5E640000, 0x84000002, 0x46610000, 0x880002E0, 0xC6800000, 0xC13C0002,
+ 0xCD001E08, 0xC0001ACC, 0xC2000002, 0xCE040008, 0x5C440000, 0x84000238, 0xC0004810, 0xC9400000,
+ 0xC6800000, 0xCBC00000, 0x00000000, 0xC1000000, 0xA54001E8, 0xC53C1008, 0x00000000, 0xA7FC01D2,
+ 0xC0001AF0, 0xC1000000, 0x58000002, 0xC9000008, 0xC000474E, 0xC9800000, 0x5D100000, 0x8400000A,
+ 0xC1000002, 0xC53C1E08, 0x80000180, 0x5D180000, 0x8400000A, 0xC1000002, 0xC53C1E08, 0x80000158,
+ 0xC0004878, 0xC8040000, 0x6C908000, 0x44908000, 0x44908000, 0x40100000, 0xC9800000, 0xC4380000,
+ 0x00000000, 0xC000481E, 0xC9C00000, 0xC000481C, 0xCA000000, 0x00000000, 0x75D8C000, 0x46188000,
+ 0x840000D0, 0xC0001AF0, 0xC3400000, 0x58000000, 0xCB410040, 0xC0004746, 0xC9400000, 0x6F702000,
+ 0x5B304300, 0xC2C00000, 0x58300000, 0xCAC00040, 0x00000000, 0x00000000, 0x46D48000, 0x88000008,
+ 0xC1000002, 0xC53C1E08, 0x80000028, 0x5AEC0002, 0x58300000, 0xCEC00040, 0xC1000002, 0xC53C1008,
+ 0xC77C0840, 0xC57C0040, 0x59540002, 0xC0004746, 0xCD400000, 0xC6800000, 0xCFC00000, 0xC0004848,
+ 0xC9440000, 0xC1800000, 0xC000082C, 0xC9840030, 0x59540002, 0xC0004848, 0xCD440000, 0x58880002,
+ 0xB49801D8, 0x00000000, 0xC0800000, 0x800001C8, 0xC000471E, 0xC9000000, 0x00000000, 0x00000000,
+ 0x59100002, 0xCD000000, 0xC0004854, 0xC1000000, 0xCD040000, 0xC11C0000, 0xC000082C, 0xCD040E08,
+ 0x99007930, 0xC0004848, 0xC9440000, 0xC1800000, 0xC2000000, 0xC0000820, 0xCE040000, 0xC1200000,
+ 0xC0000818, 0xCD041008, 0xC11C0002, 0xC000082C, 0xCD040E08, 0xC0004850, 0xCE040000, 0xC2000002,
+ 0xC0001ACC, 0xCE040010, 0x800000D0, 0xC2000002, 0xC0004850, 0xCE040000, 0x8000FBE8, 0xC2000000,
+ 0xC0004850, 0xCE040000, 0xA7E60012, 0x00000000, 0xC2000002, 0xC0001B00, 0xCE040008, 0x8000FBD0,
+ 0x00000000, 0xA7860032, 0x00000000, 0xC6800000, 0xC13C0002, 0xCD001E08, 0xC2020002, 0xC7E2A548,
+ 0xC0001B00, 0xCE040000, 0x8000FB78, 0xC2040002, 0xC0001B00, 0xCE040208, 0x8000FB58, 0xC2C80002,
+ 0x6AC56000, 0xDACC0000, 0xC0004854, 0xCB440000, 0xC0004848, 0xCB840000, 0xC0000838, 0xC3C00000,
+ 0xCBC40030, 0x5EF40004, 0x8400000A, 0xC3000000, 0xC0001ACC, 0xCF040108, 0x47BD8000, 0x84000032,
+ 0x47BD8000, 0x88000038, 0xC1006E8C, 0xC1400010, 0x8D580000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC0004840, 0xCC840000, 0x8000EAF8, 0xC0001AC0, 0xCAC40000, 0xC0004854, 0xCB440000, 0xA6C0F91A,
+ 0x00000000, 0x5EF40000, 0x8400F45A, 0x5EF40002, 0x8400F6EA, 0x5EF40004, 0x8400F8EA, 0xC1006CE8,
+ 0xC1400010, 0x8D580000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xC0800000, 0xDF4B0040,
+ 0xC0004900, 0xCB800000, 0xC2000000, 0xC000490A, 0xA78000B0, 0xCBC00000, 0xC1000000, 0xD9000001,
+ 0xC1000002, 0xD90C0000, 0x6FF46000, 0x47F5A000, 0x5B744C80, 0xC2400000, 0x58340004, 0xCA400080,
+ 0xC0004900, 0xCE000008, 0x5A640002, 0x58340004, 0xC6500080, 0xCD000080, 0xC0004914, 0xCA400000,
+ 0xC2000002, 0x6A3D0000, 0x72252000, 0xCE400000, 0xC0000408, 0xCE000000, 0xA78200B8, 0xC0004908,
+ 0xCBC00000, 0xC1000000, 0xD9000001, 0xC1000002, 0xD90C0000, 0x6FF4A000, 0x6FD44000, 0x4575A000,
+ 0x47F5A000, 0x5B744E20, 0xC2800000, 0x58340006, 0xCA800080, 0xC2000000, 0xC0004900, 0xCE000108,
+ 0x5EA80002, 0x58340006, 0xC6900080, 0xCD000080, 0x5A7C0020, 0xC2000002, 0x6A250000, 0xC0000408,
+ 0xCE000000, 0xC0000032, 0xDCA80001, 0xC1000002, 0x46914000, 0x00000000, 0x8C100006, 0x00000000,
+ 0x00000000, 0x00000000, 0xA4800210, 0x00000000, 0xC3C00000, 0xC000140E, 0xCBC00020, 0xC3400000,
+ 0xC2400000, 0x6FF86000, 0x47F9C000, 0x5BB84C80, 0x58380008, 0xCB400080, 0x58380006, 0xCA400080,
+ 0x5F740002, 0x58380008, 0xC7500080, 0xCD000080, 0xC2000000, 0x58380004, 0xCA020080, 0xC3000000,
+ 0x5838000C, 0xCB000028, 0x5A640002, 0x46250000, 0x8400FFF8, 0xC2400000, 0x58380006, 0xC6500080,
+ 0xCD000080, 0xC2000000, 0x5838000A, 0xCA020080, 0x5B300002, 0x5838000C, 0xC7100028, 0xCD000028,
+ 0xC2420020, 0x5A200004, 0x46612000, 0x8400FFF8, 0xC2000000, 0x5838000A, 0xC6101080, 0xCD001080,
+ 0xC0004966, 0xCA400000, 0xC2000002, 0x6A3D0000, 0x72252000, 0xCE400000, 0x5F740000, 0x84000028,
+ 0xC0004912, 0xCA000000, 0xC2C00002, 0x6AFD6000, 0x7EC16000, 0x76E10000, 0xCE000000, 0x5F300020,
+ 0x84000028, 0xC0004924, 0xCA000000, 0xC2C00002, 0x6AFD6000, 0x7EC16000, 0x76E10000, 0xCE000000,
+ 0xA4820050, 0xC2400000, 0xC000140E, 0xCA408020, 0xC2000002, 0xC0004900, 0xCE000008, 0xC000490A,
+ 0xCE400000, 0xC1000000, 0xD9000001, 0xD8400080, 0xC1000004, 0xD9000001, 0xA4840288, 0x00000000,
+ 0xC3C00000, 0xC000140E, 0xCBC10020, 0xC2800000, 0xC2000000, 0x6FF8A000, 0x6FD44000, 0x4579C000,
+ 0x47F9C000, 0x5BB84E20, 0x5838002E, 0xCA800080, 0x58380006, 0xCA020080, 0xC3400000, 0x5838002E,
+ 0xCB420080, 0x5AA80002, 0x46290000, 0x8400FFF8, 0xC2800000, 0x5838002E, 0xC6900080, 0xCD000080,
+ 0x5F740002, 0x5838002E, 0xC7501080, 0xCD001080, 0xC0004968, 0xCA400000, 0xC2000002, 0x6A3D0000,
+ 0x72252000, 0xCE400000, 0xC000492A, 0xCA800000, 0x5E740000, 0x84000028, 0xC0004910, 0xCA000000,
+ 0xC2C00002, 0x6AFD6000, 0x7EC16000, 0x76E10000, 0xCE000000, 0x6ABD4010, 0xA68000D2, 0x00000000,
+ 0xC0004910, 0xCA000000, 0xC2C00002, 0x6AFD6000, 0x7EC16000, 0x76E10000, 0xCE000000, 0x58380032,
+ 0xCA000000, 0x58000002, 0xCA400000, 0x5838000C, 0x00000000, 0xCE000001, 0xCE400000, 0xC000492A,
+ 0xCA000000, 0xC2C00002, 0x6AFD6000, 0x72E10000, 0xCE000000, 0xC000492C, 0xCA000000, 0xC2C00002,
+ 0x6AFD6000, 0x72E10000, 0xCE000000, 0x80000028, 0xC000492C, 0xCA000000, 0xC2C00002, 0x6AFD6000,
+ 0x7EC16000, 0x76E10000, 0xCE000000, 0xA4880100, 0xC2C00000, 0xC000140E, 0xCAC20020, 0xC000490E,
+ 0xCA400000, 0xC2000002, 0x6A2D0000, 0x7E010000, 0x76252000, 0xCE400000, 0xC000496A, 0xCA400000,
+ 0xC2000002, 0x6A2D0000, 0x72252000, 0xCE400000, 0x6EF0A000, 0x6ED44000, 0x45718000, 0x46F18000,
+ 0x5B304E20, 0x58300000, 0xCA000000, 0x00000000, 0xC2400002, 0x76252000, 0x84000032, 0xC24C0002,
+ 0xC6E40020, 0xC624C408, 0x58300010, 0xCA400508, 0x00000000, 0xC0001800, 0xCE400000, 0xA4860050,
+ 0xC2400000, 0xC000140E, 0xCA418020, 0xC2020002, 0xC0004900, 0xCE000108, 0xC0004908, 0xCE400000,
+ 0xC1000000, 0xD9000001, 0xD8400080, 0xC1000004, 0xD9000001, 0xA48C0028, 0xC2800002, 0xC000484A,
+ 0xCE800000, 0xC2800000, 0xC000474A, 0xCE800000, 0xC0004846, 0xCE800000, 0xC0001408, 0xCC800000,
+ 0xC10E0002, 0xD90C0000, 0x8000EA60, 0xDFBC0001, 0xC000496E, 0x99008638, 0xC9400000, 0xC7D80000,
+ 0x00000000, 0xC5700000, 0x5EF00020, 0x88000130, 0x6F346000, 0x4735A000, 0x5B744C80, 0x58340008,
+ 0xC2400000, 0xCA400080, 0x00000000, 0xC2000000, 0x5A640002, 0xCE400080, 0x58340004, 0xCA000080,
+ 0x00000000, 0x00000000, 0x5E200002, 0xCE000080, 0xC0004912, 0xCA800000, 0xC2400002, 0x6A712000,
+ 0x72694000, 0xCE800000, 0x5E200000, 0x8400003A, 0xC000480A, 0xCA000000, 0xC0000408, 0xCA800000,
+ 0x76610000, 0x00000000, 0x72294000, 0xCE800000, 0x80000020, 0xC0004914, 0xCA000000, 0x7E412000,
+ 0x00000000, 0x76610000, 0xCE000000, 0x800000B8, 0x6EF4A000, 0x6ED44000, 0x4575A000, 0x46F5A000,
+ 0x5B744E20, 0x5834002E, 0xC2400000, 0xCA420080, 0x00000000, 0xC2000000, 0x5A640002, 0xC6501080,
+ 0xCD001080, 0x58340006, 0xCA000080, 0x00000000, 0x00000000, 0x5A200002, 0xCE000080, 0xC0004910,
+ 0xCA400000, 0xC2000002, 0x6A2D0000, 0x72252000, 0xCE400000, 0xC2000002, 0x6A310000, 0xC000042A,
+ 0xCE000000, 0xC1040002, 0xD90C0000, 0x00000000, 0x8000E7D0, 0x00000000, 0xC4980930, 0x9D000000,
+ 0xC5580030, 0xC0000838, 0xCD840000, 0xC1440200, 0xC1C03200, 0xC55C1078, 0xC000100E, 0x9D000000,
+ 0xCD800000, 0xC000100C, 0xCDC00000, 0xC0004862, 0xC9C00000, 0x00000000, 0x00000000, 0xD9D80001,
+ 0xC0007200, 0x401C0000, 0x5DC07400, 0x8800FFFA, 0x5C000200, 0xCD800000, 0xC1F0000A, 0x71D4A000,
+ 0xDD980000, 0xDD9C0001, 0x41D8E000, 0xC5D40268, 0xC0001010, 0xCD400000, 0x6C9C8000, 0x449CE000,
+ 0x449CE000, 0x59DC0004, 0xC1601260, 0xC5D40268, 0x9D000000, 0xC0001012, 0xCD400000, 0x00000000,
+ 0x00000000, 0xD9580000, 0x6D586000, 0x4558C000, 0x59984C80, 0xD9980001, 0x5818000A, 0xC1800000,
+ 0xC9800080, 0xC0005400, 0x6D5CA000, 0x401C0000, 0x40180000, 0xC9400000, 0x58000002, 0x00000000,
+ 0xC9C00000, 0xC0004930, 0xCD400000, 0xC0004932, 0xCDC00000, 0x59980004, 0xC1C20020, 0xB59CFFF8,
+ 0x00000000, 0xC1800000, 0xDD9C0001, 0x581C000A, 0xCD800080, 0x581C000C, 0xC1800000, 0xC9800028,
+ 0xC1C00002, 0xDD940000, 0x69D4E000, 0x5D980002, 0xCD800028, 0xC0004924, 0xC9800000, 0x00000000,
+ 0x9D000000, 0x00000000, 0x71D8C000, 0xCD800000, 0xC000492A, 0xC9400000, 0xC1C00002, 0x69D8E000,
+ 0x7DC0C000, 0x7594A000, 0xCD400000, 0xC000492C, 0xC9400000, 0xDD800001, 0x58000032, 0x75D4A000,
+ 0x84000078, 0xC9400001, 0xC9800000, 0xDD800001, 0x5800000C, 0x00000000, 0xCD400001, 0xCD800000,
+ 0xC000492C, 0xC9400000, 0xC000492A, 0xC9800000, 0x71D4A000, 0xC000492C, 0xCD400000, 0x71D8C000,
+ 0xC000492A, 0xCD800000, 0x9D000000, 0x00000000, 0x00000000, 0x00000000, 0xC0004862, 0xC9800000,
+ 0x00000000, 0xC1C00200, 0x4194C000, 0x45D8E000, 0x8800FFFA, 0xC5D80000, 0xC0004862, 0xCD800000,
+ 0xC0001406, 0xC9800000, 0xC1C00002, 0x9D000000, 0xC5D80A08, 0xC5581050, 0xCD800000, 0xC0004930,
+ 0xC9800000, 0xC0004932, 0xC9C00000, 0xC140000E, 0xC5581C20, 0xDD940000, 0xC0007200, 0x40140000,
+ 0x5D407400, 0x8800FFFA, 0x5C000200, 0xCD800000, 0x58000002, 0x5D407400, 0x8800FFFA, 0x5C000200,
+ 0xCDC00000, 0xDD540000, 0xC1C00000, 0x58140006, 0xC9C20080, 0xC1800000, 0x58140000, 0xC98000E0,
+ 0x6DDC2000, 0xC000491E, 0x41D8E000, 0xCDC00000, 0xDD980000, 0xC1C00022, 0xC5D80D78, 0xDD940001,
+ 0xC5581C20, 0xC000491C, 0xCD800000, 0xDD540000, 0xC1C00000, 0x58140006, 0xC9C20080, 0xC1800000,
+ 0x58140004, 0xC9820080, 0x00000000, 0x59DC0002, 0x459CC000, 0x8400FFF8, 0xC1C00000, 0x9D000000,
+ 0x58140006, 0xC5D81080, 0xCD801080, 0xC0004860, 0xC9400000, 0xC1820080, 0xC1D00002, 0x58146B00,
+ 0xD5800000, 0x58000002, 0xD5800001, 0x59540004, 0xB558FFF8, 0xC0004860, 0xC1400000, 0xCD400000,
+ 0xDD980001, 0x9D000000, 0xDD940000, 0xC0001404, 0xCDC00808, 0xC1C00000, 0xC1800200, 0x5D980004,
+ 0xDF5D0050, 0x45D8A000, 0x8800FFDA, 0xDD800001, 0x5800000C, 0x00000000, 0xC9400001, 0xC9800000,
+ 0xC1C00002, 0xC5D43F08, 0xC5D81E08, 0xC0004862, 0xC9C00000, 0x00000000, 0x00000000, 0x581C7200,
+ 0x5DC07400, 0x8800FFFA, 0x5C000200, 0xCD400000, 0x58000002, 0x5DC07400, 0x8800FFFA, 0x5C000200,
+ 0xCD800000, 0xC0004862, 0xC9C00000, 0x00000000, 0xC15004C0, 0xC5D40068, 0xDD9C0000, 0xC5D41C20,
+ 0xC1C00000, 0xDD800001, 0x58000030, 0xC9C00080, 0xDD800001, 0x58000002, 0xC9800000, 0x6DDC2000,
+ 0xC000491C, 0x41D8E000, 0xCD400001, 0xCDC00000, 0xDD940001, 0xC1C00000, 0x58140030, 0xC9C00080,
+ 0xC1800000, 0x58140006, 0xC9820080, 0x00000000, 0x59DC0002, 0x459CC000, 0x8400FFF8, 0xC1C00000,
+ 0x9D000000, 0x58140030, 0xC5D80080, 0xCD800080, 0xC1C00000, 0xDF5C0040, 0x5DDC0080, 0x8400FFD2,
+ 0x00000000, 0x9D000000, 0x00000000, 0x00000000, 0x00000000, 0xC160FFFE, 0xC0000A10, 0xC9440068,
+ 0xC1A0FFFE, 0x59980E28, 0xC000100C, 0xCD400000, 0xC000100E, 0xCD800000, 0xC0004964, 0xC9800000,
+ 0x00000000, 0xC170000A, 0x7194A000, 0x6C988000, 0x4498C000, 0x4498C000, 0x59980004, 0xC5940278,
+ 0xC0001010, 0xCD400000, 0xC0004946, 0xC9400000, 0x00000000, 0x00000000, 0x6D58A000, 0x6D5C4000,
+ 0x45D8C000, 0x4558C000, 0xC000494A, 0xC9400000, 0xC0004948, 0xC9C00000, 0x4194C000, 0xC1400012,
+ 0xC55C1820, 0x9D000000, 0xC59C0270, 0xC0001012, 0xCDC00000, 0xC1400000, 0x58000012, 0xC9410040,
+ 0xC0004950, 0xC9C00000, 0xC5580000, 0xC5940840, 0xC5581080, 0xD9940000, 0xC000493C, 0xC9400000,
+ 0xC0004954, 0xC9800000, 0x59DC00A8, 0x455CE000, 0x41D8E000, 0x5D5C0030, 0x8800FFF8, 0xC1C00030,
+ 0xC1800000, 0xC5D84030, 0xC1400000, 0xC5D40010, 0x5DD40002, 0x8400005A, 0x5DD40004, 0x84000082,
+ 0x5DD40006, 0x840000AA, 0x5DD80026, 0x840000D2, 0xDD540000, 0xDD800001, 0x58000008, 0x40180000,
+ 0xCD400000, 0x59980002, 0x8000FFA8, 0xDD540000, 0xDD800001, 0x58000008, 0x40180000, 0xCD4000C0,
+ 0x59980002, 0x8000FF70, 0xDD540000, 0xDD800001, 0x58000008, 0x40180000, 0xCD400080, 0x59980002,
+ 0x8000FF38, 0xDD540000, 0xDD800001, 0x58000008, 0x40180000, 0xCD400040, 0x59980002, 0x8000FF00,
+ 0x00000000, 0x9D000000, 0x00000000, 0x00000000, 0x00000000, 0x58000012, 0xC9400000, 0xC0004954,
+ 0xC9C00000, 0xC0004950, 0xC9400080, 0xDD800001, 0x58000028, 0x5D9C0000, 0x8400003A, 0x5D9C0002,
+ 0x8400003A, 0x5D9C0004, 0x84000052, 0xC55B0040, 0xC55C08C0, 0xCD800041, 0xCDC008C0, 0x80000048,
+ 0xCD400000, 0x80000038, 0xC55900C0, 0xC55C1840, 0xCD8000C1, 0xCDC01840, 0x80000010, 0xC55A0080,
+ 0xC55C1080, 0xCD800081, 0xCDC01080, 0x9D000000, 0x00000000, 0x00000000, 0x00000000, 0x59540002,
+ 0x6994E018, 0x61C0C008, 0x4194A000, 0x5D940040, 0x8800FFFA, 0xC5940000, 0x9D000000, 0xCD400000,
+ 0x00000000, 0x00000000, 0x9D000000, 0x4158A000, 0xCD400000, 0x00000000, 0xCD800001, 0x44148000,
+ 0x8800FFD8, 0x00000000, 0x9CC00000, 0x00000000, 0x00000000, 0x00000000, 0xC0004810, 0xCA010040,
+ 0xC241FFFE, 0xC1400000, 0x45608000, 0x00000000, 0x9CC00006, 0xC0004200, 0x40180000, 0xC9C00000,
+ 0x00000000, 0x00000000, 0x61C08010, 0x84000042, 0xC2400002, 0x6A512000, 0x725CE000, 0xCDC00000,
+ 0xC0004748, 0xCD800000, 0x9CC00000, 0x6D98A000, 0x5998003E, 0x45192000, 0x59540002, 0x59980002,
+ 0x45A08000, 0xC1000000, 0xC5180006, 0x8000FF20, 0x00000000, 0x40180000, 0xC9C00000, 0xC2000000,
+ 0xC5600028, 0xC1210000, 0x69208010, 0x7D008000, 0x751CE000, 0xCDC00000, 0x6D542000, 0x58144300,
+ 0xC1000000, 0xCD000001, 0x9CC00000, 0xC121FFFE, 0x5911FFFE, 0xCD000001, 0x79948000, 0x6D10A010,
+ 0x5D100000, 0x840000A8, 0x45588000, 0x88000098, 0x6D536000, 0x6D136010, 0x6D54A010, 0xC0004700,
+ 0x40140000, 0xCA000000, 0x00000000, 0x00000000, 0x6A110000, 0x6A110010, 0x62008018, 0x8400001A,
+ 0x00000000, 0x9CC00000, 0x6D54A000, 0x5954003E, 0x45152000, 0x59540002, 0x6D57A000, 0x6D57A010,
+ 0x6D54A000, 0x6D936000, 0x6D136010, 0xC1E10000, 0x69D0E010, 0x5DDC0002, 0x7DC0E000, 0x6D98A010,
+ 0x6D536000, 0x6D136010, 0x6D54A010, 0xC0004700, 0x40140000, 0xCA000000, 0x00000000, 0x00000000,
+ 0x6A110000, 0x6A110010, 0x45948000, 0x00000000, 0x75E10002, 0x62008018, 0x8400001A, 0x00000000,
+ 0x9CC00000, 0x6D54A000, 0x5954003E, 0x45152000, 0x45948000, 0x00000000, 0x9CC00002, 0x59540002,
+ 0x6D57A000, 0x6D57A010, 0xC0004700, 0x40140000, 0xCA000000, 0x8000FF50, 0x00000000, 0x00000000,
+ 0x00000000, 0x58004700, 0xC9800000, 0x9CC00000, 0x00000000, 0x6994C000, 0x6DA7E010, 0x58004700,
+ 0xC9800000, 0xC1210000, 0x9CC00000, 0x69148010, 0x7118C000, 0xCD800000, 0xC1000000, 0xC0004810,
+ 0xC9020040, 0x00000000, 0x00000000, 0x451CC000, 0x8800004A, 0xC2400002, 0x45948000, 0xC1000000,
+ 0xC5240004, 0x455C8000, 0xC1000000, 0xC5240006, 0x9CC00000, 0x00000000, 0x00000000, 0x00000000,
+ 0x59980200, 0xC2400000, 0x45D48000, 0xC1000002, 0xC5240004, 0x45588000, 0xC1000002, 0xC5240006,
+ 0x9CC00000, 0x00000000, 0x00000000, 0x00000000, 0xC0004740, 0xC9C00000, 0x59180002, 0x6D130000,
+ 0x6D130010, 0x45D08000, 0xC2400000, 0x9CC00002, 0x00000000, 0x00000000, 0x45D88000, 0x8800004A,
+ 0xC2400002, 0x45D48000, 0xC1000000, 0xC5240004, 0x45588000, 0xC1000000, 0xC5240004, 0x9CC00000,
+ 0x00000000, 0x00000000, 0x00000000, 0xC2400000, 0x45948000, 0xC1000002, 0xC5240006, 0x455C8000,
+ 0xC1000002, 0xC5240006, 0x9CC00000, 0x00000000, 0x00000000, 0x00000000, 0x59540002, 0x6D570000,
+ 0x6D570010, 0x45948000, 0x6D402000, 0x9CC00002, 0x58004300, 0x58000000, 0xC13C0002, 0xCD001E08,
+ 0x8000FF98, 0x00000000, 0x00000000, 0x00000000, 0xC1020002, 0xD90C0000, 0xC9800000, 0x59540002,
+ 0xC0004730, 0xCD400000, 0x5D980002, 0x00000000, 0x8000001E, 0x00000000, 0x9CC00000, 0xC0004732,
+ 0xCD800000, 0x00000000, 0xC0004734, 0xC9C00000, 0xC1800000, 0xC0004816, 0xC9820080, 0xC0004738,
+ 0xCDC00000, 0xC1C00000, 0xC0004734, 0x9CC00000, 0xCDC00000, 0xC0004732, 0xCD800000,
+};
+
+static unsigned int firmware_binary_data[] = {
+};
+
+
+#endif // IFXMIPS_ATM_FW_DANUBE_H
diff --git a/package/platform/lantiq/ltq-atm/src/ifxmips_atm_fw_regs_amazon_se.h b/package/platform/lantiq/ltq-atm/src/ifxmips_atm_fw_regs_amazon_se.h
new file mode 100644
index 0000000..87cbe5d
--- /dev/null
+++ b/package/platform/lantiq/ltq-atm/src/ifxmips_atm_fw_regs_amazon_se.h
@@ -0,0 +1,57 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_atm_fw_regs_amazon_se.h
+** PROJECT : UEIP
+** MODULES : ATM (ADSL)
+**
+** DATE : 1 AUG 2005
+** AUTHOR : Xu Liang
+** DESCRIPTION : ATM Driver (Firmware Registers)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 4 AUG 2005 Xu Liang Initiate Version
+** 23 OCT 2006 Xu Liang Add GPL header.
+** 9 JAN 2007 Xu Liang First version got from Anand (IC designer)
+*******************************************************************************/
+
+
+
+#ifndef IFXMIPS_ATM_FW_REGS_AMAZON_SE_H
+#define IFXMIPS_ATM_FW_REGS_AMAZON_SE_H
+
+
+
+/*
+ * Host-PPE Communication Data Address Mapping
+ */
+#define FW_VER_ID ((volatile struct fw_ver_id *) SB_BUFFER(0x2401)) /* Firmware Version ID */
+#define CFG_WRX_HTUTS SB_BUFFER(0x2400) /* WAN RX HTU Table Size, must be configured before enable PPE firmware. */
+//#define CFG_WRX_QNUM SB_BUFFER(0x2401) /* WAN RX Queue Number */
+#define CFG_WRX_DCHNUM SB_BUFFER(0x2402) /* WAN RX DMA Channel Number, no more than 8, must be configured before enable PPE firmware. */
+#define CFG_WTX_DCHNUM SB_BUFFER(0x2403) /* WAN TX DMA Channel Number, no more than 16, must be configured before enable PPE firmware. */
+#define CFG_WRDES_DELAY SB_BUFFER(0x2404) /* WAN Descriptor Write Delay, must be configured before enable PPE firmware. */
+#define WRX_DMACH_ON SB_BUFFER(0x2405) /* WAN RX DMA Channel Enable, must be configured before enable PPE firmware. */
+#define WTX_DMACH_ON SB_BUFFER(0x2406) /* WAN TX DMA Channel Enable, must be configured before enable PPE firmware. */
+#define WRX_HUNT_BITTH SB_BUFFER(0x2407) /* WAN RX HUNT Threshold, must be between 2 to 8. */
+#define WRX_QUEUE_CONFIG(i) ((struct wrx_queue_config*) SB_BUFFER(0x2500 + (i) * 20))
+#define WRX_DMA_CHANNEL_CONFIG(i) ((struct wrx_dma_channel_config*) SB_BUFFER(0x2640 + (i) * 7))
+#define WTX_PORT_CONFIG(i) ((struct wtx_port_config*) SB_BUFFER(0x2440 + (i)))
+#define WTX_QUEUE_CONFIG(i) ((struct wtx_queue_config*) SB_BUFFER(0x2F00 + (i) * 27))
+#define WTX_DMA_CHANNEL_CONFIG(i) ((struct wtx_dma_channel_config*) SB_BUFFER(0x2F01 + (i) * 27))
+#define WAN_MIB_TABLE ((struct wan_mib_table*) SB_BUFFER(0x2410))
+#define HTU_ENTRY(i) ((struct htu_entry*) SB_BUFFER(0x3200 + (i)))
+#define HTU_MASK(i) ((struct htu_mask*) SB_BUFFER(0x3220 + (i)))
+#define HTU_RESULT(i) ((struct htu_result*) SB_BUFFER(0x3240 + (i)))
+
+
+
+#endif // IFXMIPS_ATM_FW_REGS_AMAZON_SE_H
diff --git a/package/platform/lantiq/ltq-atm/src/ifxmips_atm_fw_regs_ar9.h b/package/platform/lantiq/ltq-atm/src/ifxmips_atm_fw_regs_ar9.h
new file mode 100644
index 0000000..dd010f5
--- /dev/null
+++ b/package/platform/lantiq/ltq-atm/src/ifxmips_atm_fw_regs_ar9.h
@@ -0,0 +1,172 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_atm_fw_regs_ar9.h
+** PROJECT : UEIP
+** MODULES : ATM (ADSL)
+**
+** DATE : 1 AUG 2005
+** AUTHOR : Xu Liang
+** DESCRIPTION : ATM Driver (Firmware Registers)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 4 AUG 2005 Xu Liang Initiate Version
+** 23 OCT 2006 Xu Liang Add GPL header.
+** 9 JAN 2007 Xu Liang First version got from Anand (IC designer)
+*******************************************************************************/
+
+
+
+#ifndef IFXMIPS_ATM_FW_REGS_AR9_H
+#define IFXMIPS_ATM_FW_REGS_AR9_H
+
+
+
+/*
+ * Host-PPE Communication Data Address Mapping
+ */
+#define FW_VER_ID ((volatile struct fw_ver_id *) SB_BUFFER(0x2001))
+#define CFG_WRX_HTUTS SB_BUFFER(0x2400) /* WAN RX HTU Table Size, must be configured before enable PPE firmware. */
+#define CFG_WRX_QNUM SB_BUFFER(0x2401) /* WAN RX Queue Number */
+#define CFG_WRX_DCHNUM SB_BUFFER(0x2402) /* WAN RX DMA Channel Number, no more than 8, must be configured before enable PPE firmware. */
+#define CFG_WTX_DCHNUM SB_BUFFER(0x2403) /* WAN TX DMA Channel Number, no more than 16, must be configured before enable PPE firmware. */
+#define CFG_WRDES_DELAY SB_BUFFER(0x2404) /* WAN Descriptor Write Delay, must be configured before enable PPE firmware. */
+#define WRX_DMACH_ON SB_BUFFER(0x2405) /* WAN RX DMA Channel Enable, must be configured before enable PPE firmware. */
+#define WTX_DMACH_ON SB_BUFFER(0x2406) /* WAN TX DMA Channel Enable, must be configured before enable PPE firmware. */
+#define WRX_HUNT_BITTH SB_BUFFER(0x2407) /* WAN RX HUNT Threshold, must be between 2 to 8. */
+#define WRX_QUEUE_CONFIG(i) ((struct wrx_queue_config*) SB_BUFFER(0x2500 + (i) * 20))
+#define WRX_QUEUE_CONTEXT(i) ((struct wrx_queue_context*) SB_BUFFER(0x2504 + (i) * 20))
+#define WRX_DMA_CHANNEL_CONFIG(i) ((struct wrx_dma_channel_config*) SB_BUFFER(0x2640 + (i) * 7))
+#define WRX_DESC_CONTEXT(i) ((struct wrx_desc_context*) SB_BUFFER(0x2643 + (i) * 7))
+#define WTX_PORT_CONFIG(i) ((struct wtx_port_config*) SB_BUFFER(0x2440 + (i)))
+#define WTX_QUEUE_CONFIG(i) ((struct wtx_queue_config*) SB_BUFFER(0x3800 + (i) * 27))
+#define WTX_DMA_CHANNEL_CONFIG(i) ((struct wtx_dma_channel_config*) SB_BUFFER(0x3801 + (i) * 27))
+#define WAN_MIB_TABLE ((struct wan_mib_table*) SB_BUFFER(0x2410))
+#define HTU_ENTRY(i) ((struct htu_entry*) SB_BUFFER(0x2010 + (i)))
+#define HTU_MASK(i) ((struct htu_mask*) SB_BUFFER(0x2030 + (i)))
+#define HTU_RESULT(i) ((struct htu_result*) SB_BUFFER(0x2050 + (i)))
+
+#if defined(ENABLE_ATM_RETX) && ENABLE_ATM_RETX
+
+ #define RETX_MODE_CFG ((volatile struct Retx_mode_cfg *) SB_BUFFER(0x2408))
+ #define RETX_TSYNC_CFG ((volatile struct Retx_Tsync_cfg *) SB_BUFFER(0x2409))
+ #define RETX_TD_CFG ((volatile struct Retx_Td_cfg *) SB_BUFFER(0x240A))
+ #define RETX_MIB_TIMER_CFG ((volatile struct Retx_MIB_Timer_cfg *) SB_BUFFER(0x240B))
+ #define RETX_PLAYOUT_BUFFER_BASE SB_BUFFER(0x240D)
+ #define RETX_SERVICE_HEADER_CFG SB_BUFFER(0x240E)
+ #define RETX_MASK_HEADER_CFG SB_BUFFER(0x240F)
+
+ #define RETX_ADSL_PPE_INTF ((volatile struct Retx_adsl_ppe_intf *) PPE_REG_ADDR(0x0D78))
+ #define BAD_REC_RETX_ADSL_PPE_INTF ((volatile struct Retx_adsl_ppe_intf *) SB_BUFFER(0x23AC))
+ #define FIRST_BAD_REC_RETX_ADSL_PPE_INTF ((volatile struct Retx_adsl_ppe_intf *) SB_BUFFER(0x23AE))
+
+ #define PB_BUFFER_USAGE SB_BUFFER(0x2100)
+ #define DTU_STAT_INFO ((volatile struct DTU_stat_info *) SB_BUFFER(0x2180))
+ #define DTU_VLD_STAT SB_BUFFER(0x2380)
+
+
+ //=====================================================================
+ // retx firmware mib, for debug purpose
+ // address : 0x2388 - 0x238F
+ // size : 8
+ //=====================================================================
+ #define URETX_RX_TOTAL_DTU SB_BUFFER(0x2388)
+ #define URETX_RX_BAD_DTU SB_BUFFER(0x2389)
+ #define URETX_RX_GOOD_DTU SB_BUFFER(0x238A)
+ #define URETX_RX_CORRECTED_DTU SB_BUFFER(0x238B)
+ #define URETX_RX_OUTOFDATE_DTU SB_BUFFER(0x238C)
+ #define URETX_RX_DUPLICATE_DTU SB_BUFFER(0x238D)
+ #define URETX_RX_TIMEOUT_DTU SB_BUFFER(0x238E)
+
+ #define URETX_ALPHA_SWITCH_TO_HUNT_TIMES SB_BUFFER(0x238F)
+
+ // cell counter for debug purpose
+ #define WRX_BC0_CELL_NUM SB_BUFFER(0x23E0)
+ #define WRX_BC0_DROP_CELL_NUM SB_BUFFER(0x23E1)
+ #define WRX_BC0_NONRETX_CELL_NUM SB_BUFFER(0x23E2)
+ #define WRX_BC0_RETX_CELL_NUM SB_BUFFER(0x23E3)
+ #define WRX_BC0_OUTOFDATE_CELL_NUM SB_BUFFER(0x23E4)
+ #define WRX_BC0_DIRECTUP_NUM SB_BUFFER(0x23E5)
+ #define WRX_BC0_PBW_TOTAL_NUM SB_BUFFER(0x23E6)
+ #define WRX_BC0_PBW_SUCC_NUM SB_BUFFER(0x23E7)
+ #define WRX_BC0_PBW_FAIL_NUM SB_BUFFER(0x23E8)
+ #define WRX_BC1_CELL_NUM SB_BUFFER(0x23E9)
+
+ // debug info (interface)
+
+ #define DBG_DTU_INTF_WRPTR SB_BUFFER(0x2390)
+ #define DBG_INTF_FCW_DUP_CNT SB_BUFFER(0x2391)
+ #define DBG_INTF_SID_CHANGE_IN_DTU_CNT SB_BUFFER(0x2392)
+ #define DBG_INTF_LCW_DUP_CNT SB_BUFFER(0x2393)
+
+ #define DBG_RFBI_DONE_INT_CNT SB_BUFFER(0x2394)
+ #define DBG_DREG_BEG_END SB_BUFFER(0x2395)
+ #define DBG_RFBI_BC0_INVALID_CNT SB_BUFFER(0x2396)
+ #define DBG_RFBI_LAST_T SB_BUFFER(0x2397)
+
+ #define DBG_RFBI_INTV0 SB_BUFFER(0x23EE)
+ #define DBG_RFBI_INTV1 SB_BUFFER(0x23EF)
+
+ #define DBG_INTF_INFO(i) ((volatile struct Retx_adsl_ppe_intf_rec *) SB_BUFFER(0x23F0 + i))
+
+ // Internal status
+ #define URetx_curr_time SB_BUFFER(0x2398)
+ #define URetx_sec_counter SB_BUFFER(0x2399)
+ #define RxCURR_EFB SB_BUFFER(0x239A)
+ #define RxDTURetransmittedCNT SB_BUFFER(0x239B)
+
+ //=====================================================================
+ // standardized MIB counter
+ // address : 0x239C - 0x239F
+ // size : 4
+ //=====================================================================
+ #define RxLastEFBCNT SB_BUFFER(0x239C)
+ #define RxDTUCorrectedCNT SB_BUFFER(0x239D)
+ #define RxDTUCorruptedCNT SB_BUFFER(0x239E)
+ #define RxRetxDTUUncorrectedCNT SB_BUFFER(0x239F)
+
+
+ //=====================================================================
+ // General URetx Context
+ // address : 0x23A0 - 0x23AF
+ // size : 16
+ //=====================================================================
+ #define NEXT_DTU_SID_OUT SB_BUFFER(0x23A0)
+ #define LAST_DTU_SID_IN SB_BUFFER(0x23A1)
+ #define NEXT_CELL_SID_OUT SB_BUFFER(0x23A2)
+ #define ISR_CELL_ID SB_BUFFER(0x23A3)
+ #define PB_CELL_SEARCH_IDX SB_BUFFER(0x23A4)
+ #define PB_READ_PEND_FLAG SB_BUFFER(0x23A5)
+ #define RFBI_FIRST_CW SB_BUFFER(0x23A6)
+ #define RFBI_BAD_CW SB_BUFFER(0x23A7)
+ #define RFBI_INVALID_CW SB_BUFFER(0x23A8)
+ #define RFBI_RETX_CW SB_BUFFER(0x23A9)
+ #define RFBI_CHK_DTU_STATUS SB_BUFFER(0x23AA)
+
+ //=====================================================================
+ // per PVC counter for RX error_pdu and correct_pdu
+ // address : 0x23B0 - 0x23CF
+ // size : 32
+ //=====================================================================
+ #define WRX_PER_PVC_CORRECT_PDU_BASE SB_BUFFER(0x23B0)
+ #define WRX_PER_PVC_ERROR_PDU_BASE SB_BUFFER(0x23C0)
+
+ #define __WRXCTXT_L2_RdPtr(i) SB_BUFFER(0x2422 + (i))
+ #define __WRXCTXT_L2Pages(i) SB_BUFFER(0x2424 + (i))
+
+ #define __WTXCTXT_TC_WRPTR(i) SB_BUFFER(0x2450 + (i))
+ #define __WRXCTXT_PortState(i) SB_BUFFER(0x242A + (i))
+
+#endif
+
+
+
+#endif // IFXMIPS_ATM_FW_REGS_AR9_H
diff --git a/package/platform/lantiq/ltq-atm/src/ifxmips_atm_fw_regs_common.h b/package/platform/lantiq/ltq-atm/src/ifxmips_atm_fw_regs_common.h
new file mode 100644
index 0000000..49be99e
--- /dev/null
+++ b/package/platform/lantiq/ltq-atm/src/ifxmips_atm_fw_regs_common.h
@@ -0,0 +1,549 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_atm_fw_regs_common.h
+** PROJECT : UEIP
+** MODULES : ATM (ADSL)
+**
+** DATE : 1 AUG 2005
+** AUTHOR : Xu Liang
+** DESCRIPTION : ATM Driver (Firmware Register Structures)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 4 AUG 2005 Xu Liang Initiate Version
+** 23 OCT 2006 Xu Liang Add GPL header.
+** 9 JAN 2007 Xu Liang First version got from Anand (IC designer)
+*******************************************************************************/
+
+
+
+#ifndef IFXMIPS_ATM_FW_REGS_COMMON_H
+#define IFXMIPS_ATM_FW_REGS_COMMON_H
+
+
+#if defined(CONFIG_DANUBE)
+ #include "ifxmips_atm_fw_regs_danube.h"
+#elif defined(CONFIG_AMAZON_SE)
+ #include "ifxmips_atm_fw_regs_amazon_se.h"
+#elif defined(CONFIG_AR9)
+ #include "ifxmips_atm_fw_regs_ar9.h"
+#elif defined(CONFIG_VR9)
+ #include "ifxmips_atm_fw_regs_vr9.h"
+#else
+ #error Platform is not specified!
+#endif
+
+
+
+/*
+ * PPE ATM Cell Header
+ */
+#if defined(__BIG_ENDIAN)
+ struct uni_cell_header {
+ unsigned int gfc :4;
+ unsigned int vpi :8;
+ unsigned int vci :16;
+ unsigned int pti :3;
+ unsigned int clp :1;
+ };
+#else
+ struct uni_cell_header {
+ unsigned int clp :1;
+ unsigned int pti :3;
+ unsigned int vci :16;
+ unsigned int vpi :8;
+ unsigned int gfc :4;
+ };
+#endif // defined(__BIG_ENDIAN)
+
+/*
+ * Inband Header and Trailer
+ */
+#if defined(__BIG_ENDIAN)
+ struct rx_inband_trailer {
+ /* 0 - 3h */
+ unsigned int uu :8;
+ unsigned int cpi :8;
+ unsigned int stw_res1:4;
+ unsigned int stw_clp :1;
+ unsigned int stw_ec :1;
+ unsigned int stw_uu :1;
+ unsigned int stw_cpi :1;
+ unsigned int stw_ovz :1;
+ unsigned int stw_mfl :1;
+ unsigned int stw_usz :1;
+ unsigned int stw_crc :1;
+ unsigned int stw_il :1;
+ unsigned int stw_ra :1;
+ unsigned int stw_res2:2;
+ /* 4 - 7h */
+ unsigned int gfc :4;
+ unsigned int vpi :8;
+ unsigned int vci :16;
+ unsigned int pti :3;
+ unsigned int clp :1;
+ };
+
+ struct tx_inband_header {
+ /* 0 - 3h */
+ unsigned int gfc :4;
+ unsigned int vpi :8;
+ unsigned int vci :16;
+ unsigned int pti :3;
+ unsigned int clp :1;
+ /* 4 - 7h */
+ unsigned int uu :8;
+ unsigned int cpi :8;
+ unsigned int pad :8;
+ unsigned int res1 :8;
+ };
+#else
+ struct rx_inband_trailer {
+ /* 0 - 3h */
+ unsigned int stw_res2:2;
+ unsigned int stw_ra :1;
+ unsigned int stw_il :1;
+ unsigned int stw_crc :1;
+ unsigned int stw_usz :1;
+ unsigned int stw_mfl :1;
+ unsigned int stw_ovz :1;
+ unsigned int stw_cpi :1;
+ unsigned int stw_uu :1;
+ unsigned int stw_ec :1;
+ unsigned int stw_clp :1;
+ unsigned int stw_res1:4;
+ unsigned int cpi :8;
+ unsigned int uu :8;
+ /* 4 - 7h */
+ unsigned int clp :1;
+ unsigned int pti :3;
+ unsigned int vci :16;
+ unsigned int vpi :8;
+ unsigned int gfc :4;
+ };
+
+ struct tx_inband_header {
+ /* 0 - 3h */
+ unsigned int clp :1;
+ unsigned int pti :3;
+ unsigned int vci :16;
+ unsigned int vpi :8;
+ unsigned int gfc :4;
+ /* 4 - 7h */
+ unsigned int res1 :8;
+ unsigned int pad :8;
+ unsigned int cpi :8;
+ unsigned int uu :8;
+ };
+#endif // defined(__BIG_ENDIAN)
+
+/*
+ * MIB Table Maintained by Firmware
+ */
+struct wan_mib_table {
+ u32 res1;
+ u32 wrx_drophtu_cell;
+ u32 wrx_dropdes_pdu;
+ u32 wrx_correct_pdu;
+ u32 wrx_err_pdu;
+ u32 wrx_dropdes_cell;
+ u32 wrx_correct_cell;
+ u32 wrx_err_cell;
+ u32 wrx_total_byte;
+ u32 res2;
+ u32 wtx_total_pdu;
+ u32 wtx_total_cell;
+ u32 wtx_total_byte;
+};
+
+/*
+ * Host-PPE Communication Data Structure
+ */
+
+#if defined(__BIG_ENDIAN)
+ struct fw_ver_id {
+ unsigned int family :4;
+ unsigned int fwtype :4;
+ unsigned int interface :4;
+ unsigned int fwmode :4;
+ unsigned int major :8;
+ unsigned int minor :8;
+ };
+
+ struct wrx_queue_config {
+ /* 0h */
+ unsigned int res2 :27;
+ unsigned int dmach :4;
+ unsigned int errdp :1;
+ /* 1h */
+ unsigned int oversize :16;
+ unsigned int undersize :16;
+ /* 2h */
+ unsigned int res1 :16;
+ unsigned int mfs :16;
+ /* 3h */
+ unsigned int uumask :8;
+ unsigned int cpimask :8;
+ unsigned int uuexp :8;
+ unsigned int cpiexp :8;
+ };
+
+ struct wrx_queue_context {
+ /* 0h */
+ unsigned int curr_len :16;
+ unsigned int res0 :12;
+ unsigned int mfs :1;
+ unsigned int ec :1;
+ unsigned int clp1 :1;
+ unsigned int aal5dp :1;
+
+ /* 1h */
+ unsigned int intcrc;
+
+ /* 2h, 3h */
+ unsigned int curr_des0;
+ unsigned int curr_des1;
+
+ /* 4h - 0xE */
+ unsigned int res1[11];
+
+ unsigned int last_dword;
+ };
+
+ struct wtx_port_config {
+ unsigned int res1 :27;
+ unsigned int qid :4;
+ unsigned int qsben :1;
+ };
+
+ struct wtx_queue_config {
+ unsigned int res1 :16;
+ unsigned int same_vc_qmap:8;
+ unsigned int res2 :1;
+ unsigned int sbid :1;
+ unsigned int qsb_vcid :4; // Which QSB queue (VCID) does this TX queue map to.
+ unsigned int res3 :1;
+ unsigned int qsben :1;
+ };
+
+ struct wrx_desc_context {
+ unsigned int dmach_wrptr : 16;
+ unsigned int dmach_rdptr : 16;
+
+ unsigned int res0 : 16;
+ unsigned int dmach_fcnt : 16;
+
+ unsigned int res1 : 11;
+ unsigned int desbuf_wrptr : 5;
+ unsigned int res2 : 11;
+ unsigned int desbuf_rdptr : 5;
+
+ unsigned int res3 : 27;
+ unsigned int desbuf_vcnt : 5;
+ };
+
+ struct wrx_dma_channel_config {
+ /* 0h */
+ unsigned int res1 :1;
+ unsigned int mode :2;
+ unsigned int rlcfg :1;
+ unsigned int desba :28;
+ /* 1h */
+ unsigned int chrl :16;
+ unsigned int clp1th :16;
+ /* 2h */
+ unsigned int deslen :16;
+ unsigned int vlddes :16;
+ };
+
+ struct wtx_dma_channel_config {
+ /* 0h */
+ unsigned int res2 :1;
+ unsigned int mode :2;
+ unsigned int res3 :1;
+ unsigned int desba :28;
+ /* 1h */
+ unsigned int res1 :32;
+ /* 2h */
+ unsigned int deslen :16;
+ unsigned int vlddes :16;
+ };
+
+ struct htu_entry {
+ unsigned int res1 :1;
+ unsigned int clp :1;
+ unsigned int pid :2;
+ unsigned int vpi :8;
+ unsigned int vci :16;
+ unsigned int pti :3;
+ unsigned int vld :1;
+ };
+
+ struct htu_mask {
+ unsigned int set :1;
+ unsigned int clp :1;
+ unsigned int pid_mask :2;
+ unsigned int vpi_mask :8;
+ unsigned int vci_mask :16;
+ unsigned int pti_mask :3;
+ unsigned int clear :1;
+ };
+
+ struct htu_result {
+ unsigned int res1 :12;
+ unsigned int cellid :4;
+ unsigned int res2 :5;
+ unsigned int type :1;
+ unsigned int ven :1;
+ unsigned int res3 :5;
+ unsigned int qid :4;
+ };
+
+ struct rx_descriptor {
+ /* 0 - 3h */
+ unsigned int own :1;
+ unsigned int c :1;
+ unsigned int sop :1;
+ unsigned int eop :1;
+ unsigned int res1 :3;
+ unsigned int byteoff :2;
+ unsigned int res2 :2;
+ unsigned int id :4;
+ unsigned int err :1;
+ unsigned int datalen :16;
+ /* 4 - 7h */
+ unsigned int res3 :4;
+ unsigned int dataptr :28;
+ };
+
+ struct tx_descriptor {
+ /* 0 - 3h */
+ unsigned int own :1;
+ unsigned int c :1;
+ unsigned int sop :1;
+ unsigned int eop :1;
+ unsigned int byteoff :5;
+ unsigned int res1 :5;
+ unsigned int iscell :1;
+ unsigned int clp :1;
+ unsigned int datalen :16;
+ /* 4 - 7h */
+ unsigned int res2 :4;
+ unsigned int dataptr :28;
+ };
+#else
+ struct wrx_queue_config {
+ /* 0h */
+ unsigned int errdp :1;
+ unsigned int dmach :4;
+ unsigned int res2 :27;
+ /* 1h */
+ unsigned int undersize :16;
+ unsigned int oversize :16;
+ /* 2h */
+ unsigned int mfs :16;
+ unsigned int res1 :16;
+ /* 3h */
+ unsigned int cpiexp :8;
+ unsigned int uuexp :8;
+ unsigned int cpimask :8;
+ unsigned int uumask :8;
+ };
+
+ struct wtx_port_config {
+ unsigned int qsben :1;
+ unsigned int qid :4;
+ unsigned int res1 :27;
+ };
+
+ struct wtx_queue_config {
+ unsigned int qsben :1;
+ unsigned int res3 :1;
+ unsigned int qsb_vcid :4; // Which QSB queue (VCID) does this TX queue map to.
+ unsigned int sbid :1;
+ unsigned int res2 :1;
+ unsigned int same_vc_qmap:8;
+ unsigned int res1 :16;
+ };
+
+ struct wrx_dma_channel_config
+ {
+ /* 0h */
+ unsigned int desba :28;
+ unsigned int rlcfg :1;
+ unsigned int mode :2;
+ unsigned int res1 :1;
+ /* 1h */
+ unsigned int clp1th :16;
+ unsigned int chrl :16;
+ /* 2h */
+ unsigned int vlddes :16;
+ unsigned int deslen :16;
+ };
+
+ struct wtx_dma_channel_config {
+ /* 0h */
+ unsigned int desba :28;
+ unsigned int res3 :1;
+ unsigned int mode :2;
+ unsigned int res2 :1;
+ /* 1h */
+ unsigned int res1 :32;
+ /* 2h */
+ unsigned int vlddes :16;
+ unsigned int deslen :16;
+ };
+
+ struct rx_descriptor {
+ /* 4 - 7h */
+ unsigned int dataptr :28;
+ unsigned int res3 :4;
+ /* 0 - 3h */
+ unsigned int datalen :16;
+ unsigned int err :1;
+ unsigned int id :4;
+ unsigned int res2 :2;
+ unsigned int byteoff :2;
+ unsigned int res1 :3;
+ unsigned int eop :1;
+ unsigned int sop :1;
+ unsigned int c :1;
+ unsigned int own :1;
+ };
+
+ struct tx_descriptor {
+ /* 4 - 7h */
+ unsigned int dataptr :28;
+ unsigned int res2 :4;
+ /* 0 - 3h */
+ unsigned int datalen :16;
+ unsigned int clp :1;
+ unsigned int iscell :1;
+ unsigned int res1 :5;
+ unsigned int byteoff :5;
+ unsigned int eop :1;
+ unsigned int sop :1;
+ unsigned int c :1;
+ unsigned int own :1;
+ };
+#endif // defined(__BIG_ENDIAN)
+
+#if defined(ENABLE_ATM_RETX) && ENABLE_ATM_RETX
+ #if defined(__BIG_ENDIAN)
+
+ struct Retx_adsl_ppe_intf {
+ unsigned int res0_0 : 16;
+ unsigned int dtu_sid : 8;
+ unsigned int dtu_timestamp : 8;
+
+ unsigned int res1_0 : 16;
+ unsigned int local_time : 8;
+ unsigned int res1_1 : 5;
+ unsigned int is_last_cw : 1;
+ unsigned int reinit_flag : 1;
+ unsigned int is_bad_cw : 1;
+ };
+
+ struct Retx_adsl_ppe_intf_rec {
+
+ unsigned int local_time : 8;
+ unsigned int res1_1 : 5;
+ unsigned int is_last_cw : 1;
+ unsigned int reinit_flag : 1;
+ unsigned int is_bad_cw : 1;
+
+ unsigned int dtu_sid : 8;
+ unsigned int dtu_timestamp : 8;
+
+ };
+
+ struct Retx_mode_cfg {
+ unsigned int res0 :8;
+ unsigned int invld_range :8; // used for rejecting the too late arrival of the retransmitted DTU
+ unsigned int buff_size :8; // the total number of cells in playout buffer is 32 * buff_size
+ unsigned int res1 :7;
+ unsigned int retx_en :1;
+ };
+
+ struct Retx_Tsync_cfg {
+ unsigned int fw_alpha :16; // number of consecutive HEC error cell causes that the cell delineation state machine transit from SYNC to HUNT (0 means never)
+ unsigned int sync_inp :16; // reserved
+ };
+
+ struct Retx_Td_cfg {
+ unsigned int res0 :8;
+ unsigned int td_max :8; // maximum delay between the time a DTU is first created at transmitter and the time the DTU is sent out of ReTX layer at receiver
+ unsigned int res1 :8;
+ unsigned int td_min :8; // minimum delay between the time a DTU is first created at transmitter and the time the DTU is sent out of ReTX layer at receiver
+ };
+
+ struct Retx_MIB_Timer_cfg {
+ unsigned int ticks_per_sec : 16;
+ unsigned int tick_cycle : 16;
+ };
+
+ struct DTU_stat_info {
+ unsigned int complete : 1;
+ unsigned int bad : 1;
+ unsigned int res0_0 : 14;
+ unsigned int time_stamp : 8;
+ unsigned int cell_cnt : 8;
+
+ unsigned int dtu_rd_ptr : 16;
+ unsigned int dtu_wr_ptr : 16;
+ };
+
+ struct Retx_ctrl_field {
+ unsigned int res0 : 1;
+
+ unsigned int l2_drop : 1;
+ unsigned int res1 : 13;
+ unsigned int retx : 1;
+
+ unsigned int dtu_sid : 8;
+ unsigned int cell_sid : 8;
+ };
+
+ #else
+ #error Little Endian is not supported yet.
+ #endif
+
+ struct dsl_param {
+ unsigned int update_flag; // 00
+ unsigned int res0; // 04
+ unsigned int MinDelayrt; // 08
+ unsigned int MaxDelayrt; // 0C
+ unsigned int res1; // 10
+ unsigned int res2; // 14
+ unsigned int RetxEnable; // 18
+ unsigned int ServiceSpecificReTx; // 1C
+ unsigned int res3; // 20
+ unsigned int ReTxPVC; // 24
+ unsigned int res4; // 28
+ unsigned int res5; // 2C
+ unsigned int res6; // 30
+ unsigned int res7; // 34
+ unsigned int res8; // 38
+ unsigned int res9; // 3C
+ unsigned int res10; // 40
+ unsigned int res11; // 44
+ unsigned int res12; // 48
+ unsigned int res13; // 4C
+ unsigned int RxDtuCorruptedCNT; // 50
+ unsigned int RxRetxDtuUnCorrectedCNT;// 54
+ unsigned int RxLastEFB; // 58
+ unsigned int RxDtuCorrectedCNT; // 5C
+ };
+#endif
+
+
+
+#endif // IFXMIPS_ATM_FW_REGS_COMMON_H
diff --git a/package/platform/lantiq/ltq-atm/src/ifxmips_atm_fw_regs_danube.h b/package/platform/lantiq/ltq-atm/src/ifxmips_atm_fw_regs_danube.h
new file mode 100644
index 0000000..9bdefdb
--- /dev/null
+++ b/package/platform/lantiq/ltq-atm/src/ifxmips_atm_fw_regs_danube.h
@@ -0,0 +1,51 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_atm_fw_regs_danube.h
+** PROJECT : UEIP
+** MODULES : ATM (ADSL)
+**
+** DATE : 1 AUG 2005
+** AUTHOR : Xu Liang
+** DESCRIPTION : ATM Driver (Firmware Registers)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 4 AUG 2005 Xu Liang Initiate Version
+** 23 OCT 2006 Xu Liang Add GPL header.
+** 9 JAN 2007 Xu Liang First version got from Anand (IC designer)
+*******************************************************************************/
+
+
+
+#ifndef IFXMIPS_ATM_FW_REGS_DANUBE_H
+#define IFXMIPS_ATM_FW_REGS_DANUBE_H
+
+#define FW_VER_ID ((volatile struct fw_ver_id *) SB_BUFFER(0x2001))
+#define CFG_WRX_HTUTS SB_BUFFER(0x2400) /* WAN RX HTU Table Size, must be configured before enable PPE firmware. */
+#define CFG_WRX_QNUM SB_BUFFER(0x2401) /* WAN RX Queue Number */
+#define CFG_WRX_DCHNUM SB_BUFFER(0x2402) /* WAN RX DMA Channel Number, no more than 8, must be configured before enable PPE firmware. */
+#define CFG_WTX_DCHNUM SB_BUFFER(0x2403) /* WAN TX DMA Channel Number, no more than 16, must be configured before enable PPE firmware. */
+#define CFG_WRDES_DELAY SB_BUFFER(0x2404) /* WAN Descriptor Write Delay, must be configured before enable PPE firmware. */
+#define WRX_DMACH_ON SB_BUFFER(0x2405) /* WAN RX DMA Channel Enable, must be configured before enable PPE firmware. */
+#define WTX_DMACH_ON SB_BUFFER(0x2406) /* WAN TX DMA Channel Enable, must be configured before enable PPE firmware. */
+#define WRX_HUNT_BITTH SB_BUFFER(0x2407) /* WAN RX HUNT Threshold, must be between 2 to 8. */
+
+#define WRX_QUEUE_CONFIG(i) ((struct wrx_queue_config*) SB_BUFFER(0x2500 + (i) * 20))
+#define WRX_DMA_CHANNEL_CONFIG(i) ((struct wrx_dma_channel_config*) SB_BUFFER(0x2640 + (i) * 7))
+#define WTX_PORT_CONFIG(i) ((struct wtx_port_config*) SB_BUFFER(0x2440 + (i)))
+#define WTX_QUEUE_CONFIG(i) ((struct wtx_queue_config*) SB_BUFFER(0x2710 + (i) * 27))
+#define WTX_DMA_CHANNEL_CONFIG(i) ((struct wtx_dma_channel_config*) SB_BUFFER(0x2711 + (i) * 27))
+#define WAN_MIB_TABLE ((struct wan_mib_table*) SB_BUFFER(0x2410))
+#define HTU_ENTRY(i) ((struct htu_entry*) SB_BUFFER(0x2000 + (i)))
+#define HTU_MASK(i) ((struct htu_mask*) SB_BUFFER(0x2020 + (i)))
+#define HTU_RESULT(i) ((struct htu_result*) SB_BUFFER(0x2040 + (i)))
+
+#endif
diff --git a/package/platform/lantiq/ltq-atm/src/ifxmips_atm_fw_regs_vr9.h b/package/platform/lantiq/ltq-atm/src/ifxmips_atm_fw_regs_vr9.h
new file mode 100644
index 0000000..708d337
--- /dev/null
+++ b/package/platform/lantiq/ltq-atm/src/ifxmips_atm_fw_regs_vr9.h
@@ -0,0 +1,72 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_atm_fw_regs_vr9.h
+** PROJECT : UEIP
+** MODULES : ATM (ADSL)
+**
+** DATE : 1 AUG 2005
+** AUTHOR : Xu Liang
+** DESCRIPTION : ATM Driver (Firmware Registers)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 4 AUG 2005 Xu Liang Initiate Version
+** 23 OCT 2006 Xu Liang Add GPL header.
+** 9 JAN 2007 Xu Liang First version got from Anand (IC designer)
+*******************************************************************************/
+
+
+
+#ifndef IFXMIPS_ATM_FW_REGS_VR9_H
+#define IFXMIPS_ATM_FW_REGS_VR9_H
+
+#define FW_VER_ID ((volatile struct fw_ver_id *) SB_BUFFER(0x2001))
+
+/* WAN RX HTU Table Size, must be configured before enable PPE firmware. */
+#define CFG_WRX_HTUTS SB_BUFFER(0x2010)
+/* WAN RX Queue Number */
+#define CFG_WRX_QNUM SB_BUFFER(0x2011)
+/* WAN RX DMA Channel Number, no more than 8, must be configured before enable PPE firmware. */
+#define CFG_WRX_DCHNUM SB_BUFFER(0x2012)
+/* WAN TX DMA Channel Number, no more than 16, must be configured before enable PPE firmware. */
+#define CFG_WTX_DCHNUM SB_BUFFER(0x2013)
+/* WAN Descriptor Write Delay, must be configured before enable PPE firmware. */
+#define CFG_WRDES_DELAY SB_BUFFER(0x2014)
+/* WAN RX DMA Channel Enable, must be configured before enable PPE firmware. */
+#define WRX_DMACH_ON SB_BUFFER(0x2015)
+/* WAN TX DMA Channel Enable, must be configured before enable PPE firmware. */
+#define WTX_DMACH_ON SB_BUFFER(0x2016)
+/* WAN RX HUNT Threshold, must be between 2 to 8. */
+#define WRX_HUNT_BITTH SB_BUFFER(0x2017)
+/* i < 16 */
+#define WRX_QUEUE_CONFIG(i) ((struct wrx_queue_config *) SB_BUFFER(0x4C00 + (i) * 20))
+/* i < 8 */
+#define WRX_DMA_CHANNEL_CONFIG(i) ((struct wrx_dma_channel_config *) SB_BUFFER(0x4F80 + (i) * 7))
+/* i < 2 */
+#define WTX_PORT_CONFIG(i) ((struct wtx_port_config *) SB_BUFFER(0x4FB8 + (i)))
+/* i < 16 */
+#define WTX_QUEUE_CONFIG(i) ((struct wtx_queue_config *) SB_BUFFER(0x3A00 + (i) * 27))
+/* i < 16 */
+#define WTX_DMA_CHANNEL_CONFIG(i) ((struct wtx_dma_channel_config *) SB_BUFFER(0x3A01 + (i) * 27))
+
+#define WAN_MIB_TABLE ((struct wan_mib_table *) SB_BUFFER(0x4EF0))
+/* i < 32 */
+#define HTU_ENTRY(i) ((struct htu_entry *) SB_BUFFER(0x26A0 + (i)))
+/* i < 32 */
+#define HTU_MASK(i) ((struct htu_mask *) SB_BUFFER(0x26C0 + (i)))
+/* i < 32 */
+#define HTU_RESULT(i) ((struct htu_result *) SB_BUFFER(0x26E0 + (i)))
+/* bit 0~3 - 0x0F: in showtime, 0x00: not in showtime */
+#define UTP_CFG SB_BUFFER(0x2018)
+
+
+
+#endif // IFXMIPS_ATM_FW_REGS_VR9_H
diff --git a/package/platform/lantiq/ltq-atm/src/ifxmips_atm_fw_vr9.h b/package/platform/lantiq/ltq-atm/src/ifxmips_atm_fw_vr9.h
new file mode 100644
index 0000000..99c351f
--- /dev/null
+++ b/package/platform/lantiq/ltq-atm/src/ifxmips_atm_fw_vr9.h
@@ -0,0 +1,427 @@
+#ifndef IFXMIPS_ATM_FW_VR9_H
+#define IFXMIPS_ATM_FW_VR9_H
+
+
+/******************************************************************************
+**
+** FILE NAME : ifxmips_atm_fw_vr9.h
+** PROJECT : UEIP
+** MODULES : ATM (ADSL)
+**
+** DATE : 22 OCT 2007
+** AUTHOR : Xu Liang
+** DESCRIPTION : ATM Driver (PP32 Firmware)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 22 OCT 2007 Xu Liang Initial Version, v00.01
+*******************************************************************************/
+
+
+#define VER_IN_FIRMWARE 1
+
+#define ATM_FW_VER_MAJOR 0
+#define ATM_FW_VER_MINOR 24
+
+
+static u32 vr9_fw_bin[] = {
+ 0x800004B8, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8000FFE0, 0x00000000, 0x00000000, 0x00000000,
+ 0xC1000002, 0xD90C00F8, 0xC2000002, 0xDA0800F9, 0x80004390, 0xC2000000, 0xDA0800F9, 0x80003A10,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x800039C8, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x80004B60, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x800038C8, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC0400000, 0xC000ABC0, 0xC88400F8, 0x80004050, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC0400002, 0xC000ABC0, 0xC88400F8, 0x80003FD0, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC3C00004, 0xDBC800F9, 0xC10C0002, 0xD90C00F8, 0x8000FEE0, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC10E0002, 0xD90C00F8, 0xC0004028, 0xC84000F8, 0x80004000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xC3E1FFFE, 0x597DFFFE, 0x593DFE14, 0x900004D9, 0x00000000, 0x00000000, 0x00000000, 0x90CC0481,
+ 0x00000000, 0x00000000, 0x00000000, 0xC3C00000, 0xDBC800F9, 0xC1400008, 0xC1900000, 0x71588000,
+ 0x14100100, 0xC140000A, 0xC1900002, 0x71588000, 0x14100100, 0xC140000C, 0xC1900004, 0x71588000,
+ 0x14100100, 0xC1400004, 0xC1900006, 0x71588000, 0x14100100, 0xC1400006, 0xC1900008, 0x71588000,
+ 0x14100100, 0xC140000E, 0xC190000A, 0x71588000, 0x14100100, 0xC1400000, 0xC190000C, 0x71588000,
+ 0x14100100, 0xC1400002, 0xC190000E, 0x71588000, 0x14100100, 0xC0400000, 0xC11C0000, 0xC000E82C,
+ 0xCD05CE00, 0xC11C0002, 0xC000E82C, 0xCD05CE00, 0xC0400002, 0xC11C0000, 0xC000E82C, 0xCD05CE00,
+ 0xC11C0002, 0xC000E82C, 0xCD05CE00, 0xC000E824, 0x00000000, 0xCBC000F9, 0xCB8000F9, 0xCB4000F9,
+ 0xCB0000F8, 0xC000ABE4, 0x5BFC4000, 0xCFC000F9, 0x5BB84000, 0xCF8000F9, 0x5B744000, 0xCF4000F9,
+ 0x5B304000, 0xCF0000F8, 0xC000EA10, 0x00000000, 0xCBC000F9, 0xCB8000F8, 0xC000ABE0, 0x5BFC4000,
+ 0xCFC000F9, 0x5BB84000, 0xCF8000F8, 0xC30001FE, 0xC000F416, 0xCF0000F8, 0xC3000000, 0x7F018000,
+ 0xC000E42E, 0xCF0000F8, 0xC000E40E, 0xCF0000F8, 0xC3C1FFFE, 0xC000690E, 0xCFC00078, 0xC000692C,
+ 0xCFC00078, 0xC0006924, 0xCFC00038, 0xC0006912, 0xCFC00038, 0xC0006966, 0xCFC00038, 0xC0006968,
+ 0xCFC00078, 0xC000696A, 0xCFC00078, 0xC3C00000, 0xC2800020, 0xC3000000, 0x7F018000, 0x6FF88000,
+ 0x6FD44000, 0x4395C000, 0x5BB89800, 0x5838000A, 0xCF0000F8, 0x5BFC0002, 0xB7E8FFC8, 0x00000000,
+ 0xC3C00000, 0xC2800010, 0x6FF86000, 0x47BDC000, 0x5BB89F00, 0xC3400000, 0x58380004, 0xCB420078,
+ 0x00000000, 0x58380008, 0xCF400078, 0x5BFC0002, 0xB7E8FFB0, 0x00000000, 0xC3C00000, 0xC2800020,
+ 0xC348001E, 0xC3000000, 0x7F018000, 0x6FF8A000, 0x6FD44000, 0x4795C000, 0x47BDC000, 0x5BB87400,
+ 0x58380008, 0xCF408418, 0x5838000A, 0xCF0000F8, 0x5BFC0002, 0xB7E8FFB0, 0x00000000, 0x00000000,
+ 0xC3E0E282, 0x5BFC0030, 0xC0004002, 0xCFC000F8, 0xC000E82C, 0xC11E0002, 0xCD01EF00, 0xC000E82E,
+ 0xCD01EF00, 0x00000000, 0xC121FFFE, 0x5911FE94, 0x14100000, 0x80000028, 0x00000000, 0x80001CB8,
+ 0x00000000, 0x8000FFE0, 0xC0006918, 0xD28000F8, 0xC2000000, 0xDF600038, 0x5E600020, 0x84000272,
+ 0x00000000, 0xC161FFFE, 0x5955FFFE, 0x14140000, 0x00000000, 0xC000402A, 0xCA0000F8, 0xC0006912,
+ 0xCA4000F8, 0xC0006924, 0xCA8000F8, 0xC0006966, 0xCAC000F8, 0x00000000, 0xC121FFFE, 0x5911FE94,
+ 0x14100000, 0x76250000, 0x76290000, 0x762D0000, 0x840001CA, 0xC0006918, 0xCA4000F8, 0xC28001FE,
+ 0x76290000, 0x5A640002, 0x6A254010, 0x5EE80000, 0x8400001A, 0x6AA54000, 0x80000010, 0xC62800F8,
+ 0x62818008, 0xC0006918, 0xCF0000F8, 0xC161FFFE, 0x5955FFFE, 0x14140000, 0x00000000, 0xC0006966,
+ 0xCA4000F8, 0xC2000002, 0x6A310000, 0x7E010000, 0x76612000, 0xCE4000F8, 0x00000000, 0xC121FFFE,
+ 0x5911FE94, 0x14100000, 0x6F346000, 0x4771A000, 0x5B749F00, 0xC2800000, 0x58340006, 0xCA800078,
+ 0xC2C00000, 0x58340000, 0xCAC000D8, 0xC2400000, 0x5834000A, 0xCA420078, 0x6EA82000, 0x42E9E000,
+ 0x6F2CA000, 0x42E56000, 0x5AEC3200, 0xC3990040, 0xC7381C18, 0xC6F80060, 0x99005560, 0xDB9800F8,
+ 0xDBD800F9, 0x00000000, 0xDEA000F8, 0x46310000, 0x8400FD80, 0xC0006958, 0xC84000F8, 0x00000000,
+ 0xC3C00002, 0x787C2000, 0xCC4000F8, 0xC000ABC8, 0xCB8400F8, 0xC000ABC4, 0xC88400F8, 0x5FB80000,
+ 0x8400FCFA, 0xC000FAC0, 0xCA0400F8, 0x00000000, 0x00000000, 0xA6040070, 0xC000ABE4, 0xC80400F8,
+ 0x6C908000, 0x45088000, 0x45088000, 0x40100000, 0xCA0000F8, 0xC42400F8, 0x00000000, 0x98C05CD8,
+ 0xC000697C, 0xCA0000F8, 0x59640004, 0xC0004030, 0xCA0000F8, 0xC2400002, 0x6A452000, 0x76250000,
+ 0x8400FC3A, 0xC000ABE8, 0xC80400F8, 0x00000000, 0x00000000, 0x40080000, 0xCA0000F8, 0xC42400F8,
+ 0x00000000, 0xA63C17DA, 0x00000000, 0xC000ABE4, 0xC80400F8, 0x6C908000, 0x45088000, 0x45088000,
+ 0x40100000, 0xCA0000F8, 0xC42400F8, 0x00000000, 0xC0006934, 0xCE0000F8, 0xC2800002, 0xC4681C08,
+ 0xC62821D0, 0xC2600010, 0x5A650D80, 0xC0004020, 0xCB4000F8, 0xC2200400, 0x5A200D40, 0xC7601040,
+ 0xC000F220, 0xCE8000F8, 0xC000F200, 0xCE4000F8, 0xC000F202, 0xCE0000F8, 0xC000F240, 0xCB4000F8,
+ 0x00000000, 0x00000000, 0xA754FFE0, 0xC2000000, 0xC7600040, 0xA7520042, 0x00000000, 0x00000000,
+ 0x99005FD8, 0xC0009DE2, 0xC94000F8, 0xC1800002, 0x80001680, 0x58204DC0, 0xC2000000, 0xCA000018,
+ 0xC2400000, 0xCA414000, 0xC2800000, 0xCA812000, 0xC2C00000, 0xCAC20018, 0xC0006938, 0xCE0000F8,
+ 0xC0006920, 0xCE4000F8, 0xC0006916, 0xCE8000F8, 0xC0006922, 0xCEC000F8, 0xA6400540, 0x00000000,
+ 0xC0006938, 0xCBC000F8, 0x00000000, 0xC3800000, 0x6FF48000, 0x6FD44000, 0x4355A000, 0x5B749800,
+ 0x58340000, 0xCB802010, 0x00000000, 0xC2000000, 0x6FB46000, 0x4779A000, 0x5B749F00, 0x5834000C,
+ 0xCA000020, 0xC000691A, 0xCF8000F8, 0x5E200000, 0x8400046A, 0xC2000000, 0xDF610048, 0x5E6001E8,
+ 0x8800FFE8, 0xC2000002, 0xC2400466, 0xC2A00000, 0x5AA80000, 0xC000F006, 0xCE0000F8, 0xC000F008,
+ 0xCE4000F8, 0xC000F00A, 0xCE8000F8, 0x99004FA0, 0xC1A0FFFE, 0xC000E824, 0xC9840070, 0xC0006934,
+ 0xCA4000F8, 0xC2000000, 0xC2800002, 0x99004FE0, 0xDA9800F8, 0xC61400F8, 0xC65800F8, 0xC161FFFE,
+ 0x5955FFFE, 0x14140000, 0x00000000, 0x990050C8, 0xC000691A, 0xC94000F8, 0x00000000, 0x00000000,
+ 0xC121FFFE, 0x5911FE94, 0x14100000, 0xC0006922, 0xCA001118, 0xC3C00000, 0xC3800000, 0xC0006930,
+ 0xCE023118, 0xC0006932, 0xCBC000D8, 0xC2800000, 0xC000691E, 0xCFC000F8, 0xC000ABDE, 0xCA800060,
+ 0xC3A0001A, 0x5BB94000, 0xC6B80060, 0xC000691C, 0xCF8000F8, 0x99005338, 0xC000691C, 0xC1400000,
+ 0xC9420048, 0x00000000, 0x00000000, 0x00000000, 0xA8E2FFE8, 0xC2000000, 0xC1220002, 0xD90C00F8,
+ 0xDF600038, 0x5E600020, 0x8400FFF2, 0xC000691C, 0xCA0000F8, 0xC000691E, 0xCA4000F8, 0x00000000,
+ 0x00000000, 0x99005560, 0xDA1800F8, 0xDA5800F9, 0x00000000, 0xC2000000, 0xDF610048, 0x5E6001FE,
+ 0x8800FFE8, 0xC0006916, 0xCA8000F8, 0xC2C00000, 0xDFEC0048, 0xC2400000, 0x466D2000, 0x8400004A,
+ 0x5EA80000, 0x8400003A, 0xC2600002, 0x99005FD8, 0xC0009DEE, 0xC94000F8, 0xC1800002, 0x80000030,
+ 0xC2600000, 0x99005FD8, 0xC0009DEC, 0xC94000F8, 0xC1800002, 0xC2000068, 0xC6240078, 0xC0006930,
+ 0xCE400080, 0xC000691A, 0xC98000F8, 0xC000ABDE, 0xC94000F8, 0x6D9C6000, 0x45D8E000, 0x59DC9F00,
+ 0x990053C0, 0xD95800F8, 0xD99800F9, 0xD9D400F8, 0x99005338, 0xC000691C, 0xC1400000, 0xC9420048,
+ 0xC2000000, 0xDF600038, 0x5E600020, 0x8400FFEA, 0x00000000, 0xC000691C, 0xCA0000F8, 0xC000691E,
+ 0xCA4000F8, 0x00000000, 0x00000000, 0x99005560, 0xDA1800F8, 0xDA5800F9, 0x00000000, 0x800010E8,
+ 0x00000000, 0x99005FD8, 0xC0009DEA, 0xC94000F8, 0xC1800002, 0x800010B8, 0xC0006938, 0xCBC000F8,
+ 0x00000000, 0x00000000, 0x6FF88000, 0x6FD44000, 0x4395C000, 0x5BB89800, 0x58380008, 0xCA0000F8,
+ 0x00000000, 0x00000000, 0xA6000382, 0x00000000, 0xC0006938, 0xCBC000F8, 0xC3000000, 0x00000000,
+ 0x6FF88000, 0x6FD44000, 0x4395C000, 0x5BB89800, 0x58380000, 0xCB002010, 0xC2000000, 0x58380008,
+ 0xCA020078, 0x5838000C, 0xCAC000F8, 0x5838000E, 0xCA4000F8, 0xC000691A, 0xCF0000F8, 0xC0006930,
+ 0xCEC000F8, 0xC000693C, 0xCE0000F8, 0xC0006932, 0xCE4000F8, 0x5E200000, 0x84000120, 0xC2800000,
+ 0xA6FE00BA, 0x6F206000, 0x46310000, 0x5A209F00, 0x5820000C, 0xCA800020, 0x00000000, 0x00000000,
+ 0x5EA80000, 0x840001F2, 0x00000000, 0xC161FFFE, 0x5955FFFE, 0x14140000, 0x00000000, 0x990050C8,
+ 0xC000691A, 0xC94000F8, 0x00000000, 0x00000000, 0xC121FFFE, 0x5911FE94, 0x14100000, 0xC0006930,
+ 0xCAC000F8, 0xC0006932, 0xCA4000F8, 0xC7EC1118, 0xC0006930, 0xCEC000F8, 0x5838000C, 0xCEC000F8,
+ 0x58000002, 0xCE4000F8, 0xC0006934, 0xCA0000F8, 0xC2400002, 0x6E642000, 0x6E642000, 0x76612000,
+ 0x8400002A, 0xC2400002, 0x6E684000, 0x58380008, 0xCE804200, 0xA6000020, 0x6E682000, 0x58380008,
+ 0xCE802100, 0xC2400002, 0x6E642000, 0x76612000, 0x840000EA, 0x58380008, 0xCA0000F8, 0xC2800000,
+ 0xC2400000, 0xA60200C0, 0xDBA800F8, 0x6F386000, 0x47B1C000, 0x5BB89F00, 0x58380004, 0xCA400078,
+ 0x58380002, 0xCA800078, 0x00000000, 0xDEB800F8, 0x46A54000, 0x88000060, 0x00000000, 0xC0009DE4,
+ 0xCA0000F8, 0xC2400002, 0x6E640000, 0x5A200002, 0xCE0000F8, 0x58380008, 0xCE400000, 0x80000018,
+ 0x00000000, 0x80000048, 0xC0006934, 0xCA0000F8, 0x00000000, 0x00000000, 0xA6020C6A, 0x00000000,
+ 0x00000000, 0x80000C98, 0xC2800000, 0xC2000080, 0xC240001A, 0xDF690048, 0x46294000, 0x46A54000,
+ 0x8800FFD2, 0xC2000006, 0xC2600982, 0x5A643B6E, 0x5838000A, 0xCA8000F8, 0xC000F006, 0xCE0000F8,
+ 0xC000F008, 0xCE4000F8, 0xC000F00A, 0xCE8000F8, 0x99004FA0, 0xC1A0FFFE, 0xC000E824, 0xC9840070,
+ 0xC2000000, 0xC0006930, 0xCA02E008, 0x58380026, 0xCA4000F8, 0x00000000, 0xC2800000, 0x99004FE0,
+ 0xDA9800F8, 0xC61400F8, 0xC65800F8, 0xC0006934, 0xCA0000F8, 0x00000000, 0x00000000, 0xA6020022,
+ 0x00000000, 0x00000000, 0x80000318, 0xC0006938, 0xCBC000F8, 0xC000ABE4, 0xC80400F8, 0x6C908000,
+ 0x45088000, 0x45088000, 0x40100000, 0xCA0000F8, 0xC42400F8, 0x00000000, 0x58240018, 0xCA0000F8,
+ 0x6FF88000, 0x6FD44000, 0x4395C000, 0x5BB89800, 0xC3000000, 0xC3400002, 0xC2C00000, 0xC62C0078,
+ 0xC6270038, 0xC0006940, 0xCE400038, 0xC6260038, 0xC0006942, 0xCE400038, 0xC000693C, 0xCA0000F8,
+ 0x5EEC0000, 0x8400018A, 0x5A6C0010, 0x46254000, 0x88000190, 0x5A600052, 0x46E54000, 0x88000178,
+ 0x58380006, 0xCA8000F8, 0xC0006940, 0xCA0000F8, 0xC2400000, 0xC6A70038, 0x7E412000, 0x76612000,
+ 0xC2000000, 0xC6A10038, 0x46250000, 0x84000138, 0xC0006942, 0xCA0000F8, 0xC2400000, 0xC6A60038,
+ 0x7E412000, 0x76612000, 0xC2000000, 0xC6A00038, 0x58380002, 0xCA8000F8, 0x46250000, 0x840000E8,
+ 0xC2400000, 0xC6A60078, 0x466D0000, 0x880000DA, 0xC2400000, 0xC6A40078, 0x58380008, 0xCA8000F8,
+ 0x46E50000, 0x880000BA, 0x00000000, 0xA6820018, 0x00000000, 0xC7700B00, 0xA6840098, 0x00000000,
+ 0xC7700A00, 0x80000080, 0xC7700200, 0xC000693C, 0xCAC000F8, 0x80000060, 0xC7700300, 0xC000693C,
+ 0xCAC000F8, 0x80000040, 0xC7700900, 0x80000030, 0xC7700800, 0x80000020, 0xC7700700, 0x80000010,
+ 0xC7700500, 0xC0006944, 0xCF0000F8, 0xC000693E, 0xCEC000F8, 0xC0006938, 0xCA4000F8, 0xC000693C,
+ 0xCB8000F8, 0xC000693E, 0xCB4000F8, 0xC3000000, 0x6E608000, 0x6E544000, 0x42150000, 0x5A209800,
+ 0x5AA00008, 0x58200004, 0xCB000078, 0xC0006934, 0xCA0000F8, 0xC2400000, 0xC0006930, 0xCA42E008,
+ 0xC3C00018, 0xA6020098, 0x00000000, 0x43656000, 0x47AD0000, 0x88000050, 0x46F96000, 0x6EE04010,
+ 0x5BE00004, 0xC2000000, 0xC6E00008, 0x5E200000, 0x84000042, 0x5BFC0002, 0x80000030, 0xC3C00004,
+ 0x5A2C0008, 0x47A10000, 0x88000012, 0x5FB80008, 0x6FE04000, 0x42390000, 0x47212000, 0x88000068,
+ 0xC2400000, 0xC0006930, 0xCA42E008, 0xC2060002, 0xC68000F8, 0xCE006300, 0x6FE04000, 0x4721C000,
+ 0x5F700010, 0x4765A000, 0xC2000000, 0xC6340008, 0xC25A000A, 0xC000691A, 0xCA401C18, 0xC2800000,
+ 0xC0006932, 0xCA8000D8, 0xC000ABDE, 0xCA400060, 0x6FA04010, 0x42290000, 0xC000691E, 0xCE0000F8,
+ 0xC7E41048, 0xC000691C, 0xCE4000F8, 0x6FE04000, 0x43A1C000, 0xC000693C, 0xCF8000F8, 0xC000693E,
+ 0xCF4000F8, 0xC000693A, 0xCFC000F8, 0x80000008, 0x00000000, 0x00000000, 0x00000000, 0xC2000000,
+ 0xDCE000F8, 0xA622FFD8, 0xC1220002, 0xD90C00F8, 0xC0006938, 0xCBC000F8, 0xC0006944, 0xCB4000F8,
+ 0xC000ABDE, 0xCB0000F8, 0xC0006934, 0xCA0000F8, 0x6FF88000, 0x6FD44000, 0x4395C000, 0x5BB89800,
+ 0xA6020268, 0xC2400000, 0x58380008, 0xCA406000, 0xDFE800F8, 0xC2218E08, 0x5A21BAF6, 0x46A14000,
+ 0x84000022, 0xC2080002, 0x7361A000, 0x80000058, 0x5E640000, 0x84000022, 0xC20C0002, 0x7361A000,
+ 0x80000030, 0xC2000000, 0xC760E710, 0xC7604218, 0x5E200000, 0x84000272, 0xC2200002, 0xC0006930,
+ 0xCE021000, 0x99005FD8, 0xC0009DE8, 0xC94000F8, 0xC1800002, 0x58380000, 0xCA0000F8, 0x00000000,
+ 0x00000000, 0xA6000132, 0xC0006940, 0xCA8000F8, 0xC0006942, 0xCA4000F8, 0xC7600078, 0xC6A01838,
+ 0xC6601038, 0xC000693A, 0xCA4000F8, 0xC0006934, 0xCA8000F8, 0xC000AB40, 0x40300000, 0x40240000,
+ 0x5C000004, 0x5EC0ABC0, 0x88000012, 0x5C000080, 0xCE0000F8, 0x58000002, 0x5EC0ABC0, 0x88000012,
+ 0x5C000080, 0xCE8000F8, 0xC000693E, 0xCA0000F8, 0xC2400000, 0x5838000C, 0xCE4000F8, 0x99005FD8,
+ 0xC0009DF0, 0xC94000F8, 0xC61800F8, 0xC0006930, 0xC6100078, 0xCD000078, 0x800000A8, 0xC2400002,
+ 0x58380008, 0xCE400000, 0xC0006944, 0xCF4000F8, 0x80000278, 0xC000693C, 0xCA4000F8, 0xDFE800F8,
+ 0x5A300018, 0xC000AB40, 0x40200000, 0xCA0000F8, 0x58380008, 0xC6501078, 0xCD021078, 0x5838000A,
+ 0xCE8000F8, 0x58380026, 0xCE0000F8, 0xC0006944, 0xCF4000F8, 0x99005338, 0xC000691C, 0xC1400000,
+ 0xC9420048, 0x80000038, 0x00000000, 0x99005FD8, 0xC0009DE6, 0xC94000F8, 0xC1800002, 0x8000FDD8,
+ 0xC2000000, 0xC2400020, 0xDF600038, 0xB624FFEA, 0xC000691C, 0xCA4000F8, 0xC000691E, 0xCA8000F8,
+ 0x99005560, 0xDA5800F8, 0xDA9800F9, 0x00000000, 0xC0006934, 0xCA0000F8, 0x00000000, 0xC2800000,
+ 0xA6020160, 0xC2400004, 0xC2000080, 0xDF690048, 0x46294000, 0x46A54000, 0x8800FFDA, 0x00000000,
+ 0xC000691A, 0xC98000F8, 0xC000ABDE, 0xC94000F8, 0x6D9C6000, 0x45D8E000, 0x59DC9F00, 0x990053C0,
+ 0xD95800F8, 0xD99800F9, 0xD9D400F8, 0x99005338, 0xC000691C, 0xC1400000, 0xC9420048, 0xC2000000,
+ 0xC2400020, 0xDF600038, 0xB624FFEA, 0xC000691C, 0xCA4000F8, 0xC000691E, 0xCA8000F8, 0x99005560,
+ 0xDA5800F8, 0xDA9800F9, 0x00000000, 0x58380008, 0xCA4000F8, 0xC2000000, 0xCE000018, 0xC2A1FFFE,
+ 0x5AA9FFFE, 0xCE021078, 0x5838000A, 0xCE8000F8, 0xC161FFFE, 0x5955FFFE, 0x14140000, 0x00000000,
+ 0xC000E838, 0xC2500002, 0xCE450800, 0xC000ABC8, 0xCB8400F8, 0xC2000000, 0xC000E82C, 0xCA040038,
+ 0x5FB80002, 0xC000ABC8, 0xCF8400F8, 0x58880002, 0xB6080018, 0x00000000, 0xC0800000, 0xC000ABC4,
+ 0xCC8400F8, 0x00000000, 0xC121FFFE, 0x5911FE94, 0x14100000, 0x8000E350, 0xC2000000, 0xDF600038,
+ 0x5E200020, 0x8400026A, 0x00000000, 0xC161FFFE, 0x5955FFFE, 0x14140000, 0x00000000, 0xC000402C,
+ 0xCA0000F8, 0xC0006910, 0xCA4000F8, 0xC000692C, 0xCA8000F8, 0xC0006968, 0xCAC000F8, 0x00000000,
+ 0xC121FFFE, 0x5911FE94, 0x14100000, 0x76250000, 0x76290000, 0x76E16000, 0x840001C2, 0xC0006926,
+ 0xCA4000F8, 0xC201FFFE, 0x76E16000, 0x5A640002, 0x6AE50010, 0x5F200000, 0x8400001A, 0x6A250000,
+ 0x80000010, 0xC6E000F8, 0x62014008, 0xC0006926, 0xCE8000F8, 0xC161FFFE, 0x5955FFFE, 0x14140000,
+ 0x00000000, 0xC0006968, 0xCA4000F8, 0xC2000002, 0x6A290000, 0x7E010000, 0x76612000, 0xCE4000F8,
+ 0x00000000, 0xC121FFFE, 0x5911FE94, 0x14100000, 0x6EB4A000, 0x6E944000, 0x4755A000, 0x4769A000,
+ 0x5B747400, 0x58340002, 0xC2000000, 0xCA0000D8, 0x5834002E, 0xC2400000, 0xCA400078, 0x6EB0A000,
+ 0x6EBC4000, 0x473D8000, 0x47298000, 0x5B30342E, 0x5B300004, 0x6E642000, 0x4225E000, 0xC39A8024,
+ 0xC7380060, 0xC6B81C18, 0x99005560, 0xDB9800F8, 0xDBD800F9, 0x00000000, 0xC2000000, 0xDF600038,
+ 0x5E200020, 0x840002A2, 0x00000000, 0xC161FFFE, 0x5955FFFE, 0x14140000, 0x00000000, 0xC000690E,
+ 0xCA0000F8, 0xC000692A, 0xCA4000F8, 0xC000696A, 0xCB0000F8, 0xC0006956, 0xCAC000F8, 0x00000000,
+ 0xC121FFFE, 0x5911FE94, 0x14100000, 0x77218000, 0x77258000, 0x84000202, 0xC201FFFE, 0x77218000,
+ 0x5AEC0002, 0x6B2D0010, 0x5EA00000, 0x8400001A, 0x6A2D0000, 0x80000010, 0xC72000F8, 0x62016008,
+ 0xC0006956, 0xCEC000F8, 0xC161FFFE, 0x5955FFFE, 0x14140000, 0x00000000, 0xC000696A, 0xCA4000F8,
+ 0xC2000002, 0x6A2D0000, 0x7E010000, 0x76612000, 0xCE4000F8, 0x00000000, 0xC121FFFE, 0x5911FE94,
+ 0x14100000, 0x6EF4A000, 0x6ED44000, 0x4755A000, 0x476DA000, 0x5B747400, 0x5834000E, 0xC2000000,
+ 0xCA0000D8, 0x58340008, 0xC2400000, 0xCA420078, 0x5834000C, 0xC2800000, 0xCA832010, 0x6E644010,
+ 0x42250000, 0x4229E000, 0xC39A8008, 0x58340008, 0xCB809018, 0x58340008, 0xC2800000, 0xCA810010,
+ 0x6EE0A000, 0x6EE44000, 0x46250000, 0x462D0000, 0x5A200008, 0x5A203408, 0x42290000, 0xC6380060,
+ 0xC6F81C18, 0x99005560, 0xDB9800F8, 0xDBD800F9, 0x00000000, 0xC000695A, 0xC84000F8, 0x00000000,
+ 0xC3C00002, 0x787C2000, 0xCC4000F8, 0xC0004030, 0xCA0000F8, 0xC2400008, 0x6A452000, 0x76250000,
+ 0x84000E02, 0xC000EA28, 0xC3800000, 0xCB840038, 0xC000EA14, 0xC3400000, 0xCB440038, 0xC0009F70,
+ 0xCB0400F8, 0xB7B4005A, 0x5804F802, 0xCAC000F8, 0xA7000060, 0x00000000, 0x00000000, 0xA6C8DD30,
+ 0xC2800000, 0xC6E80018, 0x80000070, 0x00000000, 0x00000000, 0x00000000, 0x8000DCF8, 0x00000000,
+ 0xC2800000, 0xC7282018, 0xC000690E, 0xCA4000F8, 0x6BE9E000, 0x00000000, 0x767D2000, 0x8400DCB0,
+ 0x6EA0A000, 0x6E944000, 0x46150000, 0x46290000, 0x5A207400, 0x5820000C, 0xCA0000F8, 0xC0006946,
+ 0xCE8000F8, 0xA6220368, 0x00000000, 0xC2200060, 0xC0006948, 0xCE000008, 0xCE021038, 0xC240000A,
+ 0xC000694A, 0xCE4000F8, 0xC2B60002, 0xC0006964, 0xCE837B00, 0x99005830, 0xC0009F74, 0xC88400F8,
+ 0x00000000, 0xC0006946, 0xCBC000F8, 0x00000000, 0x00000000, 0x6FF8A000, 0x6FD44000, 0x4795C000,
+ 0x47BDC000, 0x5BB87400, 0x990055F0, 0xDBD800F8, 0xDB9800F9, 0x00000000, 0x99005338, 0xC000691C,
+ 0xC1400000, 0xC9420048, 0xC000691C, 0x990057E8, 0xC94000F9, 0xC98000F8, 0x00000000, 0x99005560,
+ 0xD95800F8, 0xD99800F9, 0x00000000, 0xC161FFFE, 0x5955FFFE, 0x14140000, 0x00000000, 0x99005228,
+ 0xDBD800F8, 0xDB9800F9, 0xC7D800F8, 0x00000000, 0xC121FFFE, 0x5911FE94, 0x14100000, 0x6FF8A000,
+ 0x6FD44000, 0x4795C000, 0x47BDC000, 0x5BB87400, 0x58380010, 0xCA0000F8, 0xC000ABE0, 0xC80400F8,
+ 0x6C908000, 0x45088000, 0x45088000, 0x40100000, 0xCA4000F8, 0xC43400F8, 0x00000000, 0xC74000F8,
+ 0xCE0000F8, 0xC161FFFE, 0x5955FFFE, 0x14140000, 0x00000000, 0xC000690E, 0xCA4000F8, 0xC2800002,
+ 0x6ABD4000, 0x72692000, 0xCE4000F8, 0x00000000, 0xC121FFFE, 0x5911FE94, 0x14100000, 0x99005FD8,
+ 0xC0009DF6, 0xC94000F8, 0xC1800002, 0x00000000, 0x00000000, 0x00000000, 0xA8E2FFE8, 0x00000000,
+ 0xC1220002, 0xD90C00F8, 0xC2000000, 0xC000EA14, 0xCA040038, 0xC000EA28, 0xC2500002, 0xCE450800,
+ 0x58880002, 0xB6080018, 0xC0009F74, 0xC0800000, 0xCC8400F8, 0x8000D900, 0xC0006946, 0xCBC000F8,
+ 0xC161FFFE, 0x5955FFFE, 0x14140000, 0x00000000, 0xC000690E, 0xCA4000F8, 0xC2800002, 0x6ABD4000,
+ 0x72692000, 0xCE4000F8, 0x00000000, 0xC121FFFE, 0x5911FE94, 0x14100000, 0x6FF8A000, 0x6FD44000,
+ 0x4795C000, 0x47BDC000, 0x5BB87400, 0x58380008, 0xCA0000F8, 0x5838000C, 0xCA4000F8, 0xC3400000,
+ 0xC6340000, 0xC000694E, 0xCF4000F8, 0xC2800000, 0xC62A0078, 0xC3000000, 0xC6308018, 0x6F304000,
+ 0x43298000, 0xC000693C, 0xCF0000F8, 0xC2C00000, 0xC66C0078, 0xC0006950, 0xCEC000F8, 0xC2800000,
+ 0xC66AE020, 0xC0006954, 0xCE8000F8, 0x5F740000, 0x840001A0, 0x5E300028, 0x46E12000, 0x8400016A,
+ 0x46E12000, 0x88000132, 0x5E300018, 0x46E12000, 0x8800002A, 0x46E12000, 0x84000042, 0x00000000,
+ 0x800000C0, 0x00000000, 0x99005970, 0xDBD800F8, 0xDB9800F9, 0xC78000F8, 0xC3400002, 0xC000694E,
+ 0xCF4000F8, 0xC161FFFE, 0x5955FFFE, 0x14140000, 0x00000000, 0xC000690E, 0xCA4000F8, 0xC2800002,
+ 0x6ABD4000, 0x7E814000, 0x76692000, 0xCE4000F8, 0x00000000, 0xC121FFFE, 0x5911FE94, 0x14100000,
+ 0xC2200060, 0xC0006948, 0xCE021038, 0xC2000000, 0xC000694C, 0xCE0000F8, 0x80000080, 0x00000000,
+ 0x99005970, 0xDBD800F8, 0xDB9800F9, 0xC78000F8, 0x99005B70, 0xDBD800F8, 0xDB9800F9, 0xC78000F8,
+ 0xC2200058, 0xC0006948, 0xCE021038, 0xC2000002, 0xC000694C, 0xCE0000F8, 0xC2000006, 0xC000F006,
+ 0xCE0000F8, 0x5838000A, 0xCA4000F8, 0xC2200982, 0x5A203B6E, 0xC000F008, 0xCE0000F8, 0xC000F00A,
+ 0xCE4000F8, 0xC0006954, 0xCA8000F8, 0xC200000C, 0xC000694A, 0xCE0000F8, 0xC0006948, 0xCE800008,
+ 0xC2B60000, 0xC0006964, 0xCE8000F8, 0x99005830, 0xC0009F74, 0xC88400F8, 0x00000000, 0xC0006946,
+ 0xCBC000F8, 0xC000694C, 0xCA0000F8, 0x6FF8A000, 0x6FD44000, 0x4795C000, 0x47BDC000, 0x5BB87400,
+ 0x5E200000, 0x840000FA, 0x00000000, 0x990055F0, 0xDBD800F8, 0xDB9800F9, 0x00000000, 0x99005338,
+ 0xC000691C, 0xC1400000, 0xC9420048, 0xC000691C, 0x990057E8, 0xC94000F9, 0xC98000F8, 0x00000000,
+ 0x99005560, 0xD95800F8, 0xD99800F9, 0x00000000, 0xC161FFFE, 0x5955FFFE, 0x14140000, 0x00000000,
+ 0x99005228, 0xDBD800F8, 0xDB9800F9, 0xC7D800F8, 0x00000000, 0xC121FFFE, 0x5911FE94, 0x14100000,
+ 0xC000693C, 0xCA8000F8, 0xC000694E, 0xCAC000F8, 0xC3000018, 0xC3400006, 0x5E200000, 0x8400002A,
+ 0xC2800000, 0xC2C00000, 0xC300001E, 0xC3400000, 0xC6AC1078, 0xC72C0418, 0xC76C0810, 0x58380010,
+ 0xCA8000F8, 0x58380008, 0xCEC000F8, 0xC6280100, 0xC000ABE0, 0xC80400F8, 0x6C908000, 0x45088000,
+ 0x45088000, 0x40100000, 0xCB0000F8, 0xC43400F8, 0x00000000, 0xC74000F8, 0xCE8000F8, 0xC0006952,
+ 0xCE8000F8, 0x00000000, 0x00000000, 0x00000000, 0xA8E2FFE8, 0x00000000, 0xC000694C, 0xCA0000F8,
+ 0xC0006950, 0xCAC000F8, 0x5E200000, 0x8400006A, 0xDFE800F8, 0x7E814000, 0x5834001A, 0xCE8000F8,
+ 0x99005FD8, 0xC0009DF4, 0xC94000F8, 0xC1800002, 0x99005FD8, 0xC0009DF8, 0xC94000F8, 0xC6D800F8,
+ 0xC1220002, 0xD90C00F8, 0x5E200000, 0x84000040, 0x5838002C, 0xCB0000F8, 0xDFE800F8, 0x00000000,
+ 0x58380014, 0xCF0000F8, 0x80000018, 0xC2A1FFFE, 0x5AA9FFFE, 0x5838000A, 0xCE8000F8, 0xC3000000,
+ 0xC000EA14, 0xCB040038, 0xC2D00002, 0xC000EA28, 0xCEC50800, 0xC000694E, 0xCA8000F8, 0x58880002,
+ 0xB4B00018, 0xC0009F74, 0xC0800000, 0xCC8400F8, 0x5EA80000, 0x84000152, 0x5E200000, 0x84000140,
+ 0xC000693C, 0xCA8000F8, 0x00000000, 0x00000000, 0x5AA80060, 0xCE8000F8, 0x99005970, 0xDBD800F8,
+ 0xDB9800F9, 0xC78000F8, 0x99005B70, 0xDBD800F8, 0xDB9800F9, 0xC78000F8, 0xC0006952, 0xCAC000F8,
+ 0x58380000, 0xCA8000F8, 0xC30C0002, 0xC7F00018, 0xA6800098, 0x00000000, 0x00000000, 0xC161FFFE,
+ 0x5955FFFE, 0x14140000, 0x00000000, 0xC000F800, 0xCA0000F8, 0x00000000, 0x00000000, 0xA60CFFEA,
+ 0xC6F00500, 0xC6B0C400, 0xCF0000F8, 0x00000000, 0xC121FFFE, 0x5911FE94, 0x14100000, 0x8000CFB0,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8000CF48, 0xDCBC00F9, 0x5FFC0000, 0x84000052,
+ 0xC3800002, 0xDB8800F9, 0x5FFC0004, 0x8400C86A, 0xC3800000, 0xDB8800F9, 0xC3CE0002, 0xC000E800,
+ 0xCFC0E700, 0xC3E1FFFE, 0x597DFFFE, 0x593DFE14, 0x94000001, 0x00000000, 0x00000000, 0x00000000,
+ 0xC000ABE8, 0xC80400F8, 0x00000000, 0x00000000, 0x40080000, 0xCBC000F8, 0xC43800F8, 0x00000000,
+ 0xC000402E, 0xCA0000F8, 0xC000ABD8, 0xCB4400F8, 0x00000000, 0x00000000, 0x47610000, 0x880000B0,
+ 0x00000000, 0xA7C00048, 0xC000ABD4, 0xC1000002, 0xCD0400F8, 0xC11C0000, 0xC000E82C, 0xCD05CE00,
+ 0x800000D8, 0x00000000, 0xA7D20120, 0x00000000, 0xC7E14040, 0xC2400000, 0xC6246028, 0xC200006A,
+ 0x46250000, 0xC6240030, 0xC000E810, 0xCE440030, 0x8000FF70, 0xC2000000, 0xC000E808, 0xCA040010,
+ 0xC11C0000, 0xC000E82C, 0xCD05CE00, 0x5A200002, 0x5E600010, 0x84000010, 0xC2000000, 0xC000E808,
+ 0xCE040010, 0xC3400000, 0x80000010, 0x5B740002, 0xC000ABD8, 0xCF4400F8, 0x99004F78, 0xC000ABC8,
+ 0xC94400F8, 0xC1800000, 0xC11C0002, 0xC000E82C, 0xCD05CE00, 0x80000600, 0x5B740002, 0xC000ABD8,
+ 0xCF4400F8, 0xC78000F8, 0xC13C0002, 0xCD03DE00, 0xC000ABC8, 0xC94400F8, 0xC1800000, 0xC000E82C,
+ 0xC9840038, 0x59540002, 0xC000ABC8, 0xCD4400F8, 0x58880002, 0xB4980580, 0x00000000, 0xC0800000,
+ 0x80000568, 0xC000ABE8, 0xC80400F8, 0x00000000, 0x00000000, 0x40080000, 0xCBC000F8, 0xC42800F8,
+ 0x00000000, 0xA7C00130, 0xC000ABCC, 0xCA0400F8, 0xC2400000, 0xC000FAEC, 0xCA440018, 0x5A200002,
+ 0xC000ABCC, 0xCE0400F8, 0xB624008A, 0xC68000F8, 0xC13C0002, 0xCD03DE00, 0xC000ABC8, 0xC94400F8,
+ 0xC1800000, 0xC000E82C, 0xC9840038, 0x59540002, 0xC000ABC8, 0xCD4400F8, 0x58880002, 0xB4980470,
+ 0x00000000, 0xC0800000, 0x80000458, 0xC000ABD4, 0xC1000004, 0xCD0400F8, 0xC000E820, 0xC2000002,
+ 0xCE0400F8, 0xC2000000, 0xC000ABCC, 0xCE0400F8, 0xC000ABD8, 0xCE0400F8, 0x8000FF28, 0xC000ABD4,
+ 0xC1000000, 0xCD0400F8, 0xC11C0000, 0xC000E82C, 0xCD05CE00, 0x99004F78, 0xC000ABC8, 0xC94400F8,
+ 0xC1800000, 0xC1200000, 0xC000E818, 0xCD061000, 0xC11C0002, 0xC000E82C, 0xCD05CE00, 0xC2000000,
+ 0xC000ABCC, 0xCE0400F8, 0x80000358, 0xC000FAC0, 0xCB8400F8, 0xC000ABE8, 0xC80400F8, 0x00000000,
+ 0x00000000, 0x40080000, 0xCBC000F8, 0xC42800F8, 0x00000000, 0x00000000, 0xC68000F8, 0xC13C0000,
+ 0xCD03DE00, 0xA780024A, 0x00000000, 0x00000000, 0xA7C0020A, 0x00000000, 0xC000FB60, 0xC2060006,
+ 0xCE046308, 0xA7E801C2, 0x00000000, 0xC000ABD0, 0xCA0400F8, 0xC2400000, 0xC000FAEC, 0xCA448018,
+ 0x5A200002, 0xC000ABD0, 0xCE0400F8, 0xB62400AA, 0x00000000, 0xC68000F8, 0xC13C0002, 0xCD03DE00,
+ 0xC000FACC, 0xC2000002, 0xCE040000, 0xC000ABC8, 0xC94400F8, 0xC1800000, 0xC000E82C, 0xC9840038,
+ 0x59540002, 0xC000ABC8, 0xCD4400F8, 0x58880002, 0xB49801C8, 0x00000000, 0xC0800000, 0x800001B0,
+ 0xC000ABD4, 0xC1000000, 0xCD0400F8, 0xC11C0000, 0xC000E82C, 0xCD05CE00, 0x99004F78, 0xC000ABC8,
+ 0xC94400F8, 0xC1800000, 0xC2000000, 0xC000E820, 0xCE0400F8, 0xC1200000, 0xC000E818, 0xCD061000,
+ 0xC11C0002, 0xC000E82C, 0xCD05CE00, 0xC000ABD0, 0xCE0400F8, 0xC2000002, 0xC000FACC, 0xCE040008,
+ 0x800000E8, 0xC2000002, 0xC000ABD0, 0xCE0400F8, 0x8000FE88, 0xC2000000, 0xC000ABD0, 0xCE0400F8,
+ 0xA7E60032, 0x00000000, 0xC2000002, 0xC000FB60, 0xCE040000, 0x8000FE70, 0x00000000, 0xA7860052,
+ 0x00000000, 0xC68000F8, 0xC13C0002, 0xCD03DE00, 0xC2020002, 0xC7E2A540, 0xC000FB60, 0xCE0400F8,
+ 0x8000FE18, 0xC2040002, 0xC000FB60, 0xCE044200, 0x8000FDF8, 0xC2C80002, 0x6AC56000, 0xDACC00F8,
+ 0xC000ABD4, 0xCB4400F8, 0xC000ABC8, 0xCB8400F8, 0xC000E838, 0xC3C00000, 0xCBC40038, 0x5EF40004,
+ 0x84000022, 0xC3000000, 0xC000FACC, 0xCF042100, 0x47F98000, 0x8400002A, 0x47F98000, 0x88000030,
+ 0xC1006E8C, 0x8000BCB8, 0xC000ABC0, 0xCC8400F8, 0x8000F6C8, 0xC000FAC0, 0xCAC400F8, 0xC000ABD4,
+ 0xCB4400F8, 0xA6C0FBD2, 0x00000000, 0x5EF40000, 0x8400F722, 0x5EF40002, 0x8400F99A, 0x5EF40004,
+ 0x8400FB9A, 0xC1006CE8, 0x8000BC30, 0x00000000, 0xC0800000, 0xDF4B0038, 0xC0006900, 0xCB8000F8,
+ 0xC2000000, 0xC000690A, 0xA78000D0, 0xCBC000F8, 0xC1000000, 0xD90000F9, 0xC1000002, 0xD90C00F8,
+ 0x6FF46000, 0x477DA000, 0x5B749F00, 0xC2400000, 0x58340004, 0xCA400078, 0xC0006900, 0xCE000000,
+ 0x5A640002, 0x58340004, 0xC6500078, 0xCD000078, 0xC0006914, 0xCA4000F8, 0xC2000002, 0x6A3D0000,
+ 0x72612000, 0xCE4000F8, 0xC000E408, 0xCE0000F8, 0xA78200D8, 0xC0006908, 0xCBC000F8, 0xC1000000,
+ 0xD90000F9, 0xC1000002, 0xD90C00F8, 0x6FF4A000, 0x6FD44000, 0x4755A000, 0x477DA000, 0x5B747400,
+ 0xC2800000, 0x58340006, 0xCA800078, 0xC2000000, 0xC0006900, 0xCE002100, 0x5EA80002, 0x58340006,
+ 0xC6900078, 0xCD000078, 0x5A7C0020, 0xC2000002, 0x6A250000, 0xC000E408, 0xCE0000F8, 0xDCA800F9,
+ 0x5EA80000, 0x8400BAA0, 0x00000000, 0xA4800230, 0x00000000, 0xC3C00000, 0xC000F418, 0xCBC00018,
+ 0xC3400000, 0xC2400000, 0x6FF86000, 0x47BDC000, 0x5BB89F00, 0x58380008, 0xCB400078, 0x58380006,
+ 0xCA400078, 0x5F740002, 0x58380008, 0xC7500078, 0xCD000078, 0xC2000000, 0x58380004, 0xCA020078,
+ 0xC3000000, 0x5838000C, 0xCB000020, 0x5A640002, 0x46610000, 0x84000010, 0xC2400000, 0x58380006,
+ 0xC6500078, 0xCD000078, 0xC2000000, 0x5838000A, 0xCA020078, 0x5B300002, 0x5838000C, 0xC7100020,
+ 0xCD000020, 0xC2420020, 0x5A200004, 0x46252000, 0x84000010, 0xC2000000, 0x5838000A, 0xC6101078,
+ 0xCD021078, 0xC0006966, 0xCA4000F8, 0xC2000002, 0x6A3D0000, 0x72612000, 0xCE4000F8, 0x5F740000,
+ 0x84000040, 0xC0006912, 0xCA0000F8, 0xC2C00002, 0x6AFD6000, 0x7EC16000, 0x762D0000, 0xCE0000F8,
+ 0x5F300020, 0x84000040, 0xC0006924, 0xCA0000F8, 0xC2C00002, 0x6AFD6000, 0x7EC16000, 0x762D0000,
+ 0xCE0000F8, 0xA4820070, 0xC2400000, 0xC000F418, 0xCA408018, 0xC2000002, 0xC0006900, 0xCE000000,
+ 0xC000690A, 0xCE4000F8, 0xC1000000, 0xD90000F9, 0xD8400078, 0xC1000004, 0xD90000F9, 0xA4840270,
+ 0x00000000, 0xC3C00000, 0xC000F418, 0xCBC10018, 0xC2800000, 0xC2000000, 0x6FF8A000, 0x6FD44000,
+ 0x4795C000, 0x47BDC000, 0x5BB87400, 0x5838002E, 0xCA800078, 0x58380006, 0xCA020078, 0xC3400000,
+ 0x5838002E, 0xCB420078, 0x5AA80002, 0x46A10000, 0x84000010, 0xC2800000, 0x5838002E, 0xC6900078,
+ 0xCD000078, 0x5F740002, 0x5838002E, 0xC7501078, 0xCD021078, 0xC0006968, 0xCA4000F8, 0xC2000002,
+ 0x6A3D0000, 0x72612000, 0xCE4000F8, 0xC000692A, 0xCA8000F8, 0x5E740000, 0x84000040, 0xC0006910,
+ 0xCA0000F8, 0xC2C00002, 0x6AFD6000, 0x7EC16000, 0x762D0000, 0xCE0000F8, 0x6ABD4010, 0xA68000BA,
+ 0x00000000, 0x58380032, 0xCA0000F8, 0x58000002, 0xCA4000F8, 0x5838000C, 0x00000000, 0xCE0000F9,
+ 0xCE4000F8, 0xC000692A, 0xCA0000F8, 0xC2C00002, 0x6AFD6000, 0x722D0000, 0xCE0000F8, 0xC000692C,
+ 0xCA0000F8, 0xC2C00002, 0x6AFD6000, 0x722D0000, 0xCE0000F8, 0x80000040, 0xC000692C, 0xCA0000F8,
+ 0xC2C00002, 0x6AFD6000, 0x7EC16000, 0x762D0000, 0xCE0000F8, 0xA4880120, 0xC2C00000, 0xC000F418,
+ 0xCAC20018, 0xC000690E, 0xCA4000F8, 0xC2000002, 0x6A2D0000, 0x7E010000, 0x76612000, 0xCE4000F8,
+ 0xC000696A, 0xCA4000F8, 0xC2000002, 0x6A2D0000, 0x72612000, 0xCE4000F8, 0x6EF0A000, 0x6ED44000,
+ 0x47158000, 0x472D8000, 0x5B307400, 0x58300000, 0xCA0000F8, 0x00000000, 0xC2400002, 0x76612000,
+ 0x8400004A, 0xC24C0002, 0xC6E40018, 0xC624C400, 0x58300010, 0xCA400500, 0x00000000, 0xC000F800,
+ 0xCE4000F8, 0xA4860070, 0xC2400000, 0xC000F418, 0xCA418018, 0xC2020002, 0xC0006900, 0xCE002100,
+ 0xC0006908, 0xCE4000F8, 0xC1000000, 0xD90000F9, 0xD8400078, 0xC1000004, 0xD90000F9, 0xC000F414,
+ 0xCC8000F8, 0xC10E0002, 0xD90C00F8, 0x8000EDF0, 0xDFBC00F9, 0xC000696E, 0x99005C80, 0xC94000F8,
+ 0xC7D800F8, 0x00000000, 0xC57000F8, 0x5EF00020, 0x88000148, 0x6F346000, 0x4771A000, 0x5B749F00,
+ 0x58340008, 0xC2400000, 0xCA400078, 0x00000000, 0xC2000000, 0x5A640002, 0xCE400078, 0x58340004,
+ 0xCA000078, 0x00000000, 0x00000000, 0x5E200002, 0xCE000078, 0xC0006912, 0xCA8000F8, 0xC2400002,
+ 0x6A712000, 0x72A54000, 0xCE8000F8, 0x5E200000, 0x84000052, 0xC000402A, 0xCA0000F8, 0xC000E408,
+ 0xCA8000F8, 0x76250000, 0x00000000, 0x72A14000, 0xCE8000F8, 0x80000038, 0xC0006914, 0xCA0000F8,
+ 0x7E412000, 0x00000000, 0x76250000, 0xCE0000F8, 0x800000D0, 0x6EF4A000, 0x6ED44000, 0x4755A000,
+ 0x476DA000, 0x5B747400, 0x5834002E, 0xC2400000, 0xCA420078, 0x00000000, 0xC2000000, 0x5A640002,
+ 0xC6501078, 0xCD021078, 0x58340006, 0xCA000078, 0x00000000, 0x00000000, 0x5A200002, 0xCE000078,
+ 0xC0006910, 0xCA4000F8, 0xC2000002, 0x6A2D0000, 0x72612000, 0xCE4000F8, 0xC2000002, 0x6A310000,
+ 0xC000E42A, 0xCE0000F8, 0xC1040002, 0xD90C00F8, 0x00000000, 0x8000EB60, 0x00000000, 0xC4980928,
+ 0x9D000000, 0xC5580038, 0xC000E838, 0xCD8400F8, 0xC1440080, 0xC1C06B40, 0xC55C0F80, 0xC000F00E,
+ 0x9D000000, 0xCD8000F8, 0xC000F00C, 0xCDC000F8, 0xC000ABDE, 0xC9C000F8, 0x00000000, 0x00000000,
+ 0xD9D800F9, 0xC000AB40, 0x401C0000, 0x5DC0ABC0, 0x88000012, 0x5C000080, 0xCD8000F8, 0xC1F0000A,
+ 0x715CA000, 0xDD9800F8, 0xDD9C00F9, 0x41D8E000, 0xC5D40260, 0xC000F010, 0xCD4000F8, 0x6C9C8000,
+ 0x45C8E000, 0x45C8E000, 0x59DC0004, 0xC1601260, 0xC5D40260, 0x9D000000, 0xC000F012, 0xCD4000F8,
+ 0x00000000, 0x00000000, 0xD95800F8, 0x6D586000, 0x4594C000, 0x59989F00, 0xD99800F9, 0x5818000A,
+ 0xC1800000, 0xC9800078, 0xC0007200, 0x6D5CA000, 0x401C0000, 0x40180000, 0xC94000F8, 0x58000002,
+ 0x00000000, 0xC9C000F8, 0xC0006930, 0xCD4000F8, 0xC0006932, 0xCDC000F8, 0x59980004, 0xC1C20020,
+ 0xB59C0018, 0x00000000, 0xC1800000, 0xDD9C00F9, 0x581C000A, 0xCD800078, 0x581C000C, 0xC1800000,
+ 0xC9800020, 0xC1C00002, 0xDD9400F8, 0x69D4E000, 0x5D980002, 0xCD800020, 0xC0006924, 0xC98000F8,
+ 0x00000000, 0x9D000000, 0x00000000, 0x719CC000, 0xCD8000F8, 0xC000692A, 0xC94000F8, 0xC1C00002,
+ 0x69D8E000, 0x7DC0C000, 0x7558A000, 0xCD4000F8, 0xC000692C, 0xC94000F8, 0xDD8000F9, 0x58000032,
+ 0x755CA000, 0x84000090, 0xC94000F9, 0xC98000F8, 0xDD8000F9, 0x5800000C, 0x00000000, 0xCD4000F9,
+ 0xCD8000F8, 0xC000692C, 0xC94000F8, 0xC000692A, 0xC98000F8, 0x715CA000, 0xC000692C, 0xCD4000F8,
+ 0x719CC000, 0xC000692A, 0xCD8000F8, 0x9D000000, 0x00000000, 0x00000000, 0x00000000, 0xC000ABDE,
+ 0xC98000F8, 0x00000000, 0xC1C00080, 0x4194C000, 0x459CE000, 0x88000012, 0xC5D800F8, 0xC000ABDE,
+ 0xCD8000F8, 0xC000F406, 0xC98000F8, 0xC1C00002, 0x9D000000, 0xC5D80A00, 0xC5581048, 0xCD8000F8,
+ 0xC0006930, 0xC98000F8, 0xC0006932, 0xC9C000F8, 0xC140000E, 0xC5581C18, 0xDD9400F8, 0xC000AB40,
+ 0x40140000, 0x5D40ABC0, 0x88000012, 0x5C000080, 0xCD8000F8, 0x58000002, 0x5D40ABC0, 0x88000012,
+ 0x5C000080, 0xCDC000F8, 0xDD5400F8, 0xC1C00000, 0x58140006, 0xC9C20078, 0xC1800000, 0x58140000,
+ 0xC98000D8, 0x6DDC2000, 0xC000691E, 0x41D8E000, 0xCDC000F8, 0xDD9800F8, 0xC1C00022, 0xC5D80D70,
+ 0xDD9400F9, 0xC5581C18, 0xC000691C, 0xCD8000F8, 0xDD5400F8, 0xC1C00000, 0x58140006, 0xC9C20078,
+ 0xC1800000, 0x58140004, 0xC9820078, 0x00000000, 0x59DC0002, 0x45D8C000, 0x84000010, 0xC1C00000,
+ 0x9D000000, 0x58140006, 0xC5D81078, 0xCD821078, 0xC000ABDC, 0xC94000F8, 0xC1820020, 0xC1D00002,
+ 0x5814AB00, 0xD58000F8, 0x58000002, 0xD58000F9, 0x59540004, 0xB5580018, 0xC000ABDC, 0xC1400000,
+ 0xCD4000F8, 0xDD9800F9, 0x9D000000, 0xDD9400F8, 0xC000F402, 0xCDC10800, 0xC1C00000, 0xC1800080,
+ 0x5D980004, 0xDF5D0048, 0x459CA000, 0x8800FFF2, 0xDD8000F9, 0x5800000C, 0x00000000, 0xC94000F9,
+ 0xC98000F8, 0xC1C00002, 0xC5D43F00, 0xC5D81E00, 0xC000ABDE, 0xC9C000F8, 0x00000000, 0x00000000,
+ 0x581CAB40, 0x5DC0ABC0, 0x88000012, 0x5C000080, 0xCD4000F8, 0x58000002, 0x5DC0ABC0, 0x88000012,
+ 0x5C000080, 0xCD8000F8, 0xC000ABDE, 0xC9C000F8, 0x00000000, 0xC15004C0, 0xC5D40060, 0xDD9C00F8,
+ 0xC5D41C18, 0xC1C00000, 0xDD8000F9, 0x58000030, 0xC9C00078, 0xDD8000F9, 0x58000002, 0xC98000F8,
+ 0x6DDC2000, 0xC000691C, 0x41D8E000, 0xCD4000F9, 0xCDC000F8, 0xDD9400F9, 0xC1C00000, 0x58140030,
+ 0xC9C00078, 0xC1800000, 0x58140006, 0xC9820078, 0x00000000, 0x59DC0002, 0x45D8C000, 0x84000010,
+ 0xC1C00000, 0x9D000000, 0x58140030, 0xC5D80078, 0xCD800078, 0xC1C00000, 0xDF5C0038, 0x5DDC0020,
+ 0x8400FFEA, 0x00000000, 0x9D000000, 0x00000000, 0x00000000, 0x00000000, 0xC160FFFE, 0xC000EA10,
+ 0xC9440070, 0xC1A0FFFE, 0x59983408, 0xC000F00C, 0xCD4000F8, 0xC000F00E, 0xCD8000F8, 0xC0006964,
+ 0xC98000F8, 0x00000000, 0xC170000A, 0x7158A000, 0x6C988000, 0x4588C000, 0x4588C000, 0x59980004,
+ 0xC5940270, 0xC000F010, 0xCD4000F8, 0xC0006946, 0xC94000F8, 0x00000000, 0x00000000, 0x6D58A000,
+ 0x6D5C4000, 0x459CC000, 0x4594C000, 0xC000694A, 0xC94000F8, 0xC0006948, 0xC9C000F8, 0x4194C000,
+ 0xC1400012, 0xC55C1818, 0x9D000000, 0xC59C0268, 0xC000F012, 0xCDC000F8, 0xC1400000, 0x58000012,
+ 0xC9410038, 0xC0006950, 0xC9C000F8, 0xC55800F8, 0xC5940838, 0xC5581078, 0xD99400F8, 0xC000693C,
+ 0xC94000F8, 0xC0006954, 0xC98000F8, 0x59DC00A8, 0x45D4E000, 0x41D8E000, 0x5D5C0030, 0x88000010,
+ 0xC1C00030, 0xC1800000, 0xC5D84028, 0xC1400000, 0xC5D40008, 0x5DD40002, 0x84000072, 0x5DD40004,
+ 0x8400009A, 0x5DD40006, 0x840000C2, 0x5DD80026, 0x840000EA, 0xDD5400F8, 0xDD8000F9, 0x58000008,
+ 0x40180000, 0xCD4000F8, 0x59980002, 0x8000FFC0, 0xDD5400F8, 0xDD8000F9, 0x58000008, 0x40180000,
+ 0xCD4000B8, 0x59980002, 0x8000FF88, 0xDD5400F8, 0xDD8000F9, 0x58000008, 0x40180000, 0xCD400078,
+ 0x59980002, 0x8000FF50, 0xDD5400F8, 0xDD8000F9, 0x58000008, 0x40180000, 0xCD400038, 0x59980002,
+ 0x8000FF18, 0x00000000, 0x9D000000, 0x00000000, 0x00000000, 0x00000000, 0x58000012, 0xC94000F8,
+ 0xC0006954, 0xC9C000F8, 0xC0006950, 0xC9400078, 0xDD8000F9, 0x58000028, 0x5D9C0000, 0x84000052,
+ 0x5D9C0002, 0x84000052, 0x5D9C0004, 0x8400006A, 0xC55B0038, 0xC55C08B8, 0xCD800039, 0xCDC108B8,
+ 0x80000060, 0xCD4000F8, 0x80000050, 0xC55900B8, 0xC55C1838, 0xCD8000B9, 0xCDC31838, 0x80000028,
+ 0xC55A0078, 0xC55C1078, 0xCD800079, 0xCDC21078, 0x9D000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x59540002, 0x6994E018, 0x61C0C008, 0x4194A000, 0x5D940040, 0x88000012, 0xC59400F8, 0x9D000000,
+ 0xCD4000F8, 0x00000000, 0x00000000, 0xC000697E, 0xCA4000F8, 0xC0000000, 0xC55800F8, 0xC9D400F9,
+ 0x00000000, 0x00000000, 0x79E08000, 0xCD1800F9, 0xC5D000F8, 0xC9D400F9, 0xC66000F8, 0xC52160A0,
+ 0xC5241550, 0x79E08000, 0xCD1800F9, 0xC5D000F8, 0xC9D400F9, 0xC66000F8, 0xC52160A0, 0xC5241550,
+ 0x79E08000, 0xCD1800F9, 0xC5D000F8, 0xC9D400F9, 0xC66000F8, 0xC52160A0, 0xC5241550, 0x79E08000,
+ 0xCD1800F9, 0xC5D000F8, 0xC9D400F9, 0xC66000F8, 0xC52160A0, 0xC5241550, 0x79E08000, 0xCD1800F9,
+ 0xC5D000F8, 0xC9D400F9, 0xC66000F8, 0xC52160A0, 0xC5241550, 0x79E08000, 0xCD1800F9, 0xC5D000F8,
+ 0xC9D400F9, 0xC66000F8, 0xC52160A0, 0xC5241550, 0x79E08000, 0xCD1800F9, 0xC5D000F8, 0xC9D400F9,
+ 0xC66000F8, 0xC52160A0, 0xC5241550, 0x79E08000, 0xCD1800F9, 0xC5D000F8, 0xC9D400F9, 0xC66000F8,
+ 0xC52160A0, 0xC5241550, 0x79E08000, 0xCD1800F9, 0xC5D000F8, 0xC9D400F9, 0xC66000F8, 0xC52160A0,
+ 0xC5241550, 0x79E08000, 0xCD1800F9, 0xC5D000F8, 0xC9D400F9, 0xC66000F8, 0xC52160A0, 0xC5241550,
+ 0x79E08000, 0xCD1800F9, 0xC5D000F8, 0xC9D400F9, 0xC66000F8, 0xC52160A0, 0xC5241550, 0x79E08000,
+ 0xCD1800F9, 0xC5D000F8, 0xC9D400F9, 0xC66000F8, 0xC52160A0, 0xC5241550, 0xC000697C, 0x9CC00000,
+ 0xCE0000F8, 0xC000697E, 0xCE4000F8, 0x9D000000, 0x4158A000, 0xCD4000F8, 0x00000000,
+};
+
+static u32 vr9_fw_data[] = {
+};
+
+
+#endif // IFXMIPS_ATM_FW_VR9_H
+
diff --git a/package/platform/lantiq/ltq-atm/src/ifxmips_atm_ppe_amazon_se.h b/package/platform/lantiq/ltq-atm/src/ifxmips_atm_ppe_amazon_se.h
new file mode 100644
index 0000000..412f605
--- /dev/null
+++ b/package/platform/lantiq/ltq-atm/src/ifxmips_atm_ppe_amazon_se.h
@@ -0,0 +1,121 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_atm_ppe_amazon_se.h
+** PROJECT : UEIP
+** MODULES : ATM (ADSL)
+**
+** DATE : 1 AUG 2005
+** AUTHOR : Xu Liang
+** DESCRIPTION : ATM Driver (PPE Registers)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 4 AUG 2005 Xu Liang Initiate Version
+** 23 OCT 2006 Xu Liang Add GPL header.
+** 9 JAN 2007 Xu Liang First version got from Anand (IC designer)
+*******************************************************************************/
+
+
+
+#ifndef IFXMIPS_ATM_PPE_AMAZON_SE_H
+#define IFXMIPS_ATM_PPE_AMAZON_SE_H
+
+
+
+/*
+ * FPI Configuration Bus Register and Memory Address Mapping
+ */
+#define IFX_PPE (KSEG1 | 0x1E180000)
+#define PP32_DEBUG_REG_ADDR(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x0000) << 2)))
+#define PPM_INT_REG_ADDR(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x0030) << 2)))
+#define PP32_INTERNAL_RES_ADDR(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x0040) << 2)))
+#define CDM_CODE_MEMORY(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x1000) << 2)))
+#define PPE_REG_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x4000) << 2)))
+#define CDM_DATA_MEMORY(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x5000) << 2)))
+#define PPM_INT_UNIT_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6000) << 2)))
+#define PPM_TIMER0_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6100) << 2)))
+#define PPM_TASK_IND_REG_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6200) << 2)))
+#define PPS_BRK_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6300) << 2)))
+#define PPM_TIMER1_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6400) << 2)))
+#define SB_RAM0_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x8200) << 2)))
+#define SB_RAM1_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x8C00) << 2)))
+#define QSB_CONF_REG_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0xC000) << 2)))
+
+/*
+ * DWORD-Length of Memory Blocks
+ */
+#define PP32_DEBUG_REG_DWLEN 0x0030
+#define PPM_INT_REG_DWLEN 0x0010
+#define PP32_INTERNAL_RES_DWLEN 0x00C0
+#define CDM_CODE_MEMORYn_DWLEN(n) ((n) == 0 ? 0x1000 : 0x0800)
+#define PPE_REG_DWLEN 0x1000
+#define CDM_DATA_MEMORY_DWLEN CDM_CODE_MEMORYn_DWLEN(1)
+#define PPM_INT_UNIT_DWLEN 0x0100
+#define PPM_TIMER0_DWLEN 0x0100
+#define PPM_TASK_IND_REG_DWLEN 0x0100
+#define PPS_BRK_DWLEN 0x0100
+#define PPM_TIMER1_DWLEN 0x0100
+#define SB_RAM0_DWLEN 0x0A00
+#define SB_RAM1_DWLEN 0x0A00
+#define QSB_CONF_REG_DWLEN 0x0100
+
+/*
+ * PP32 to FPI Address Mapping
+ */
+#define SB_BUFFER(__sb_addr) ((volatile unsigned int *)((((__sb_addr) >= 0x2200) && ((__sb_addr) <= 0x2BFF)) ? SB_RAM0_ADDR((__sb_addr) - 0x2200) : \
+ (((__sb_addr) >= 0x2C00) && ((__sb_addr) <= 0x35FF)) ? SB_RAM1_ADDR((__sb_addr) - 0x2C00) : \
+ 0))
+
+/*
+ * PP32 Debug Control Register
+ */
+#define PP32_DBG_CTRL PP32_DEBUG_REG_ADDR(0, 0x0000)
+
+#define DBG_CTRL_RESTART 0
+#define DBG_CTRL_STOP 1
+
+#define PP32_HALT_STAT PP32_DEBUG_REG_ADDR(0, 0x0D00)
+#define PP32_BREAKPOINT_REASONS PP32_DEBUG_REG_ADDR(0, 0x0A00)
+
+#define PP32_BRK_SRC PP32_DEBUG_REG_ADDR(0, 0x0F00)
+
+#define PP32_DBG_CUR_PC PP32_DEBUG_REG_ADDR(0, 0x0F80)
+
+#define PP32_DBG_TASK_NO PP32_DEBUG_REG_ADDR(0, 0x0F81)
+
+/*
+ * Share Buffer
+ */
+#define SB_MST_PRI0 PPE_REG_ADDR(0x0300)
+#define SB_MST_PRI1 PPE_REG_ADDR(0x0301)
+
+/*
+ * EMA Registers
+ */
+#define EMA_CMDCFG PPE_REG_ADDR(0x0A00)
+#define EMA_DATACFG PPE_REG_ADDR(0x0A01)
+#define EMA_CMDCNT PPE_REG_ADDR(0x0A02)
+#define EMA_DATACNT PPE_REG_ADDR(0x0A03)
+#define EMA_ISR PPE_REG_ADDR(0x0A04)
+#define EMA_IER PPE_REG_ADDR(0x0A05)
+#define EMA_CFG PPE_REG_ADDR(0x0A06)
+#define EMA_SUBID PPE_REG_ADDR(0x0A07)
+
+#define EMA_ALIGNMENT 4
+
+/*
+ * Mailbox IGU1 Interrupt
+ */
+#define PPE_MAILBOX_IGU1_INT INT_NUM_IM2_IRL13
+
+
+
+#endif // IFXMIPS_ATM_PPE_AMAZON_SE_H
diff --git a/package/platform/lantiq/ltq-atm/src/ifxmips_atm_ppe_ar9.h b/package/platform/lantiq/ltq-atm/src/ifxmips_atm_ppe_ar9.h
new file mode 100644
index 0000000..fae0252
--- /dev/null
+++ b/package/platform/lantiq/ltq-atm/src/ifxmips_atm_ppe_ar9.h
@@ -0,0 +1,188 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_atm_ppe_ar9.h
+** PROJECT : UEIP
+** MODULES : ATM (ADSL)
+**
+** DATE : 1 AUG 2005
+** AUTHOR : Xu Liang
+** DESCRIPTION : ATM Driver (PPE Registers)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 4 AUG 2005 Xu Liang Initiate Version
+** 23 OCT 2006 Xu Liang Add GPL header.
+** 9 JAN 2007 Xu Liang First version got from Anand (IC designer)
+*******************************************************************************/
+
+
+
+#ifndef IFXMIPS_ATM_PPE_AR9_H
+#define IFXMIPS_ATM_PPE_AR9_H
+
+
+
+/*
+ * FPI Configuration Bus Register and Memory Address Mapping
+ */
+#define IFX_PPE (KSEG1 | 0x1E180000)
+#define PP32_DEBUG_REG_ADDR(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x0000) << 2)))
+#define PPM_INT_REG_ADDR(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x0030) << 2)))
+#define PP32_INTERNAL_RES_ADDR(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x0040) << 2)))
+#define CDM_CODE_MEMORY(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x1000) << 2)))
+#define PPE_REG_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x4000) << 2)))
+#define CDM_DATA_MEMORY(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x5000) << 2)))
+#define PPM_INT_UNIT_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6000) << 2)))
+#define PPM_TIMER0_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6100) << 2)))
+#define PPM_TASK_IND_REG_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6200) << 2)))
+#define PPS_BRK_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6300) << 2)))
+#define PPM_TIMER1_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6400) << 2)))
+#define SB_RAM0_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x8000) << 2)))
+#define SB_RAM1_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x8800) << 2)))
+#define SB_RAM2_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x9000) << 2)))
+#define SB_RAM3_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x9800) << 2)))
+#define SB_RAM4_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0xA000) << 2)))
+#define QSB_CONF_REG_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0xC000) << 2)))
+
+/*
+ * DWORD-Length of Memory Blocks
+ */
+#define PP32_DEBUG_REG_DWLEN 0x0030
+#define PPM_INT_REG_DWLEN 0x0010
+#define PP32_INTERNAL_RES_DWLEN 0x00C0
+#define CDM_CODE_MEMORYn_DWLEN(n) 0x1000
+#define PPE_REG_DWLEN 0x1000
+#define CDM_DATA_MEMORY_DWLEN CDM_CODE_MEMORYn_DWLEN(1)
+#define PPM_INT_UNIT_DWLEN 0x0100
+#define PPM_TIMER0_DWLEN 0x0100
+#define PPM_TASK_IND_REG_DWLEN 0x0100
+#define PPS_BRK_DWLEN 0x0100
+#define PPM_TIMER1_DWLEN 0x0100
+#define SB_RAM0_DWLEN 0x0800
+#define SB_RAM1_DWLEN 0x0800
+#define SB_RAM2_DWLEN 0x0800
+#define SB_RAM3_DWLEN 0x0800
+#define SB_RAM4_DWLEN 0x0C00
+#define QSB_CONF_REG_DWLEN 0x0100
+
+/*
+ * PP32 to FPI Address Mapping
+ */
+#define SB_BUFFER(__sb_addr) ((volatile unsigned int *)((((__sb_addr) >= 0x0000) && ((__sb_addr) <= 0x0FFF)) ? PPE_REG_ADDR((__sb_addr)): \
+ (((__sb_addr) >= 0x2000) && ((__sb_addr) <= 0x27FF)) ? SB_RAM0_ADDR((__sb_addr) - 0x2000) : \
+ (((__sb_addr) >= 0x2800) && ((__sb_addr) <= 0x2FFF)) ? SB_RAM1_ADDR((__sb_addr) - 0x2800) : \
+ (((__sb_addr) >= 0x3000) && ((__sb_addr) <= 0x37FF)) ? SB_RAM2_ADDR((__sb_addr) - 0x3000) : \
+ (((__sb_addr) >= 0x3800) && ((__sb_addr) <= 0x3FFF)) ? SB_RAM3_ADDR((__sb_addr) - 0x3800) : \
+ (((__sb_addr) >= 0x4000) && ((__sb_addr) <= 0x4BFF)) ? SB_RAM4_ADDR((__sb_addr) - 0x4000) : \
+ 0))
+
+/*
+ * PP32 Debug Control Register
+ */
+#define NUM_OF_PP32 1
+
+#define PP32_DBG_CTRL(n) PP32_DEBUG_REG_ADDR(n, 0x0000)
+
+#define DBG_CTRL_RESTART 0
+#define DBG_CTRL_STOP 1
+
+#define PP32_CTRL_CMD(n) PP32_DEBUG_REG_ADDR(n, 0x0B00)
+ #define PP32_CTRL_CMD_RESTART (1 << 0)
+ #define PP32_CTRL_CMD_STOP (1 << 1)
+ #define PP32_CTRL_CMD_STEP (1 << 2)
+ #define PP32_CTRL_CMD_BREAKOUT (1 << 3)
+
+#define PP32_CTRL_OPT(n) PP32_DEBUG_REG_ADDR(n, 0x0C00)
+ #define PP32_CTRL_OPT_BREAKOUT_ON_STOP_ON (3 << 0)
+ #define PP32_CTRL_OPT_BREAKOUT_ON_STOP_OFF (2 << 0)
+ #define PP32_CTRL_OPT_BREAKOUT_ON_BREAKIN_ON (3 << 2)
+ #define PP32_CTRL_OPT_BREAKOUT_ON_BREAKIN_OFF (2 << 2)
+ #define PP32_CTRL_OPT_STOP_ON_BREAKIN_ON (3 << 4)
+ #define PP32_CTRL_OPT_STOP_ON_BREAKIN_OFF (2 << 4)
+ #define PP32_CTRL_OPT_STOP_ON_BREAKPOINT_ON (3 << 6)
+ #define PP32_CTRL_OPT_STOP_ON_BREAKPOINT_OFF (2 << 6)
+ #define PP32_CTRL_OPT_BREAKOUT_ON_STOP(n) (*PP32_CTRL_OPT(n) & (1 << 0))
+ #define PP32_CTRL_OPT_BREAKOUT_ON_BREAKIN(n) (*PP32_CTRL_OPT(n) & (1 << 2))
+ #define PP32_CTRL_OPT_STOP_ON_BREAKIN(n) (*PP32_CTRL_OPT(n) & (1 << 4))
+ #define PP32_CTRL_OPT_STOP_ON_BREAKPOINT(n) (*PP32_CTRL_OPT(n) & (1 << 6))
+
+#define PP32_BRK_PC(n, i) PP32_DEBUG_REG_ADDR(n, 0x0900 + (i) * 2)
+#define PP32_BRK_PC_MASK(n, i) PP32_DEBUG_REG_ADDR(n, 0x0901 + (i) * 2)
+#define PP32_BRK_DATA_ADDR(n, i) PP32_DEBUG_REG_ADDR(n, 0x0904 + (i) * 2)
+#define PP32_BRK_DATA_ADDR_MASK(n, i) PP32_DEBUG_REG_ADDR(n, 0x0905 + (i) * 2)
+#define PP32_BRK_DATA_VALUE_RD(n, i) PP32_DEBUG_REG_ADDR(n, 0x0908 + (i) * 2)
+#define PP32_BRK_DATA_VALUE_RD_MASK(n, i) PP32_DEBUG_REG_ADDR(n, 0x0909 + (i) * 2)
+#define PP32_BRK_DATA_VALUE_WR(n, i) PP32_DEBUG_REG_ADDR(n, 0x090C + (i) * 2)
+#define PP32_BRK_DATA_VALUE_WR_MASK(n, i) PP32_DEBUG_REG_ADDR(n, 0x090D + (i) * 2)
+ #define PP32_BRK_CONTEXT_MASK(i) (1 << (i))
+ #define PP32_BRK_CONTEXT_MASK_EN (1 << 4)
+ #define PP32_BRK_COMPARE_GREATER_EQUAL (1 << 5) // valid for break data value rd/wr only
+ #define PP32_BRK_COMPARE_LOWER_EQUAL (1 << 6)
+ #define PP32_BRK_COMPARE_EN (1 << 7)
+
+#define PP32_BRK_TRIG(n) PP32_DEBUG_REG_ADDR(n, 0x0F00)
+ #define PP32_BRK_GRPi_PCn_ON(i, n) ((3 << ((n) * 2)) << ((i) * 16))
+ #define PP32_BRK_GRPi_PCn_OFF(i, n) ((2 << ((n) * 2)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_ADDRn_ON(i, n) ((3 << ((n) * 2 + 4)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_ADDRn_OFF(i, n) ((2 << ((n) * 2 + 4)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_VALUE_RDn_ON(i, n) ((3 << ((n) * 2 + 8)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_VALUE_RDn_OFF(i, n)((2 << ((n) * 2 + 8)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_VALUE_WRn_ON(i, n) ((3 << ((n) * 2 + 12)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_VALUE_WRn_OFF(i, n)((2 << ((n) * 2 + 12)) << ((i) * 16))
+ #define PP32_BRK_GRPi_PCn(k, i, n) (*PP32_BRK_TRIG(k) & ((1 << ((n))) << ((i) * 8)))
+ #define PP32_BRK_GRPi_DATA_ADDRn(k, i, n) (*PP32_BRK_TRIG(k) & ((1 << ((n) + 2)) << ((i) * 8)))
+ #define PP32_BRK_GRPi_DATA_VALUE_RDn(k, i, n) (*PP32_BRK_TRIG(k) & ((1 << ((n) + 4)) << ((i) * 8)))
+ #define PP32_BRK_GRPi_DATA_VALUE_WRn(k, i, n) (*PP32_BRK_TRIG(k) & ((1 << ((n) + 6)) << ((i) * 8)))
+
+#define PP32_CPU_STATUS(n) PP32_DEBUG_REG_ADDR(n, 0x0D00)
+#define PP32_HALT_STAT(n) PP32_CPU_STATUS(n)
+#define PP32_DBG_CUR_PC(n) PP32_CPU_STATUS(n)
+ #define PP32_CPU_USER_STOPPED(n) (*PP32_CPU_STATUS(n) & (1 << 0))
+ #define PP32_CPU_USER_BREAKIN_RCV(n) (*PP32_CPU_STATUS(n) & (1 << 1))
+ #define PP32_CPU_USER_BREAKPOINT_MET(n) (*PP32_CPU_STATUS(n) & (1 << 2))
+ #define PP32_CPU_CUR_PC(n) (*PP32_CPU_STATUS(n) >> 16)
+
+#define PP32_BREAKPOINT_REASONS(n) PP32_DEBUG_REG_ADDR(n, 0x0A00)
+ #define PP32_BRK_PC_MET(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << (i)))
+ #define PP32_BRK_DATA_ADDR_MET(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) + 2)))
+ #define PP32_BRK_DATA_VALUE_RD_MET(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) + 4)))
+ #define PP32_BRK_DATA_VALUE_WR_MET(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) + 6)))
+ #define PP32_BRK_DATA_VALUE_RD_LO_EQ(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) * 2 + 8)))
+ #define PP32_BRK_DATA_VALUE_RD_GT_EQ(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) * 2 + 9)))
+ #define PP32_BRK_DATA_VALUE_WR_LO_EQ(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) * 2 + 12)))
+ #define PP32_BRK_DATA_VALUE_WR_GT_EQ(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) * 2 + 13)))
+ #define PP32_BRK_CUR_CONTEXT(n) ((*PP32_BREAKPOINT_REASONS(n) >> 16) & 0x03)
+
+#define PP32_GP_REG_BASE(n) PP32_DEBUG_REG_ADDR(n, 0x0E00)
+#define PP32_GP_CONTEXTi_REGn(n, i, j) PP32_DEBUG_REG_ADDR(n, 0x0E00 + (i) * 16 + (j))
+
+/*
+ * EMA Registers
+ */
+#define EMA_CMDCFG PPE_REG_ADDR(0x0A00)
+#define EMA_DATACFG PPE_REG_ADDR(0x0A01)
+#define EMA_CMDCNT PPE_REG_ADDR(0x0A02)
+#define EMA_DATACNT PPE_REG_ADDR(0x0A03)
+#define EMA_ISR PPE_REG_ADDR(0x0A04)
+#define EMA_IER PPE_REG_ADDR(0x0A05)
+#define EMA_CFG PPE_REG_ADDR(0x0A06)
+#define EMA_SUBID PPE_REG_ADDR(0x0A07)
+
+#define EMA_ALIGNMENT 4
+
+/*
+ * Mailbox IGU1 Interrupt
+ */
+#define PPE_MAILBOX_IGU1_INT INT_NUM_IM2_IRL24
+
+
+
+#endif // IFXMIPS_ATM_PPE_AR9_H
diff --git a/package/platform/lantiq/ltq-atm/src/ifxmips_atm_ppe_common.h b/package/platform/lantiq/ltq-atm/src/ifxmips_atm_ppe_common.h
new file mode 100644
index 0000000..ee55fd7
--- /dev/null
+++ b/package/platform/lantiq/ltq-atm/src/ifxmips_atm_ppe_common.h
@@ -0,0 +1,368 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_atm_ppe_common.h
+** PROJECT : UEIP
+** MODULES : ATM (ADSL)
+**
+** DATE : 1 AUG 2005
+** AUTHOR : Xu Liang
+** DESCRIPTION : ATM Driver (PPE Registers)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 4 AUG 2005 Xu Liang Initiate Version
+** 23 OCT 2006 Xu Liang Add GPL header.
+** 9 JAN 2007 Xu Liang First version got from Anand (IC designer)
+*******************************************************************************/
+
+
+
+#ifndef IFXMIPS_ATM_PPE_COMMON_H
+#define IFXMIPS_ATM_PPE_COMMON_H
+
+
+
+#if defined(CONFIG_DANUBE)
+ #include "ifxmips_atm_ppe_danube.h"
+#elif defined(CONFIG_AMAZON_SE)
+ #include "ifxmips_atm_ppe_amazon_se.h"
+#elif defined(CONFIG_AR9)
+ #include "ifxmips_atm_ppe_ar9.h"
+#elif defined(CONFIG_VR9)
+ #include "ifxmips_atm_ppe_vr9.h"
+#else
+ #error Platform is not specified!
+#endif
+
+
+
+/*
+ * Code/Data Memory (CDM) Interface Configuration Register
+ */
+#define CDM_CFG PPE_REG_ADDR(0x0100)
+
+#define CDM_CFG_RAM1 GET_BITS(*CDM_CFG, 3, 2)
+#define CDM_CFG_RAM0 (*CDM_CFG & (1 << 1))
+
+#define CDM_CFG_RAM1_SET(value) SET_BITS(0, 3, 2, value)
+#define CDM_CFG_RAM0_SET(value) ((value) ? (1 << 1) : 0)
+
+/*
+ * QSB Internal Cell Delay Variation Register
+ */
+#define QSB_ICDV QSB_CONF_REG_ADDR(0x0007)
+
+#define QSB_ICDV_TAU GET_BITS(*QSB_ICDV, 5, 0)
+
+#define QSB_ICDV_TAU_SET(value) SET_BITS(0, 5, 0, value)
+
+/*
+ * QSB Scheduler Burst Limit Register
+ */
+#define QSB_SBL QSB_CONF_REG_ADDR(0x0009)
+
+#define QSB_SBL_SBL GET_BITS(*QSB_SBL, 3, 0)
+
+#define QSB_SBL_SBL_SET(value) SET_BITS(0, 3, 0, value)
+
+/*
+ * QSB Configuration Register
+ */
+#define QSB_CFG QSB_CONF_REG_ADDR(0x000A)
+
+#define QSB_CFG_TSTEPC GET_BITS(*QSB_CFG, 1, 0)
+
+#define QSB_CFG_TSTEPC_SET(value) SET_BITS(0, 1, 0, value)
+
+/*
+ * QSB RAM Transfer Table Register
+ */
+#define QSB_RTM QSB_CONF_REG_ADDR(0x000B)
+
+#define QSB_RTM_DM (*QSB_RTM)
+
+#define QSB_RTM_DM_SET(value) ((value) & 0xFFFFFFFF)
+
+/*
+ * QSB RAM Transfer Data Register
+ */
+#define QSB_RTD QSB_CONF_REG_ADDR(0x000C)
+
+#define QSB_RTD_TTV (*QSB_RTD)
+
+#define QSB_RTD_TTV_SET(value) ((value) & 0xFFFFFFFF)
+
+/*
+ * QSB RAM Access Register
+ */
+#define QSB_RAMAC QSB_CONF_REG_ADDR(0x000D)
+
+#define QSB_RAMAC_RW (*QSB_RAMAC & (1 << 31))
+#define QSB_RAMAC_TSEL GET_BITS(*QSB_RAMAC, 27, 24)
+#define QSB_RAMAC_LH (*QSB_RAMAC & (1 << 16))
+#define QSB_RAMAC_TESEL GET_BITS(*QSB_RAMAC, 9, 0)
+
+#define QSB_RAMAC_RW_SET(value) ((value) ? (1 << 31) : 0)
+#define QSB_RAMAC_TSEL_SET(value) SET_BITS(0, 27, 24, value)
+#define QSB_RAMAC_LH_SET(value) ((value) ? (1 << 16) : 0)
+#define QSB_RAMAC_TESEL_SET(value) SET_BITS(0, 9, 0, value)
+
+/*
+ * QSB Queue Scheduling and Shaping Definitions
+ */
+#define QSB_WFQ_NONUBR_MAX 0x3f00
+#define QSB_WFQ_UBR_BYPASS 0x3fff
+#define QSB_TP_TS_MAX 65472
+#define QSB_TAUS_MAX 64512
+#define QSB_GCR_MIN 18
+
+/*
+ * QSB Constant
+ */
+#define QSB_RAMAC_RW_READ 0
+#define QSB_RAMAC_RW_WRITE 1
+
+#define QSB_RAMAC_TSEL_QPT 0x01
+#define QSB_RAMAC_TSEL_SCT 0x02
+#define QSB_RAMAC_TSEL_SPT 0x03
+#define QSB_RAMAC_TSEL_VBR 0x08
+
+#define QSB_RAMAC_LH_LOW 0
+#define QSB_RAMAC_LH_HIGH 1
+
+#define QSB_QPT_SET_MASK 0x0
+#define QSB_QVPT_SET_MASK 0x0
+#define QSB_SET_SCT_MASK 0x0
+#define QSB_SET_SPT_MASK 0x0
+#define QSB_SET_SPT_SBVALID_MASK 0x7FFFFFFF
+
+#define QSB_SPT_SBV_VALID (1 << 31)
+#define QSB_SPT_PN_SET(value) (((value) & 0x01) ? (1 << 16) : 0)
+#define QSB_SPT_INTRATE_SET(value) SET_BITS(0, 13, 0, value)
+
+/*
+ * QSB Queue Parameter Table Entry and Queue VBR Parameter Table Entry
+ */
+#if defined(__BIG_ENDIAN)
+ union qsb_queue_parameter_table {
+ struct {
+ unsigned int res1 :1;
+ unsigned int vbr :1;
+ unsigned int wfqf :14;
+ unsigned int tp :16;
+ } bit;
+ u32 dword;
+ };
+
+ union qsb_queue_vbr_parameter_table {
+ struct {
+ unsigned int taus :16;
+ unsigned int ts :16;
+ } bit;
+ u32 dword;
+ };
+#else
+ union qsb_queue_parameter_table {
+ struct {
+ unsigned int tp :16;
+ unsigned int wfqf :14;
+ unsigned int vbr :1;
+ unsigned int res1 :1;
+ } bit;
+ u32 dword;
+ };
+
+ union qsb_queue_vbr_parameter_table {
+ struct {
+ unsigned int ts :16;
+ unsigned int taus :16;
+ } bit;
+ u32 dword;
+ };
+#endif // defined(__BIG_ENDIAN)
+
+/*
+ * Mailbox IGU0 Registers
+ */
+#define MBOX_IGU0_ISRS PPE_REG_ADDR(0x0200)
+#define MBOX_IGU0_ISRC PPE_REG_ADDR(0x0201)
+#define MBOX_IGU0_ISR PPE_REG_ADDR(0x0202)
+#define MBOX_IGU0_IER PPE_REG_ADDR(0x0203)
+
+#define MBOX_IGU0_ISRS_SET(n) (1 << (n))
+#define MBOX_IGU0_ISRC_CLEAR(n) (1 << (n))
+#define MBOX_IGU0_ISR_ISR(n) (*MBOX_IGU0_ISR & (1 << (n)))
+#define MBOX_IGU0_IER_EN(n) (*MBOX_IGU0_IER & (1 << (n)))
+#define MBOX_IGU0_IER_EN_SET(n) (1 << (n))
+
+/*
+ * Mailbox IGU1 Registers
+ */
+#define MBOX_IGU1_ISRS PPE_REG_ADDR(0x0204)
+#define MBOX_IGU1_ISRC PPE_REG_ADDR(0x0205)
+#define MBOX_IGU1_ISR PPE_REG_ADDR(0x0206)
+#define MBOX_IGU1_IER PPE_REG_ADDR(0x0207)
+
+#define MBOX_IGU1_ISRS_SET(n) (1 << (n))
+#define MBOX_IGU1_ISRC_CLEAR(n) (1 << (n))
+#define MBOX_IGU1_ISR_ISR(n) (*MBOX_IGU1_ISR & (1 << (n)))
+#define MBOX_IGU1_IER_EN(n) (*MBOX_IGU1_IER & (1 << (n)))
+#define MBOX_IGU1_IER_EN_SET(n) (1 << (n))
+
+/*
+ * Mailbox IGU3 Registers
+ */
+#define MBOX_IGU3_ISRS PPE_REG_ADDR(0x0214)
+#define MBOX_IGU3_ISRC PPE_REG_ADDR(0x0215)
+#define MBOX_IGU3_ISR PPE_REG_ADDR(0x0216)
+#define MBOX_IGU3_IER PPE_REG_ADDR(0x0217)
+
+#define MBOX_IGU3_ISRS_SET(n) (1 << (n))
+#define MBOX_IGU3_ISRC_CLEAR(n) (1 << (n))
+#define MBOX_IGU3_ISR_ISR(n) (*MBOX_IGU3_ISR & (1 << (n)))
+#define MBOX_IGU3_IER_EN(n) (*MBOX_IGU3_IER & (1 << (n)))
+#define MBOX_IGU3_IER_EN_SET(n) (1 << (n))
+
+/*
+ * RTHA/TTHA Registers
+ */
+#define RFBI_CFG PPE_REG_ADDR(0x0400)
+#define RBA_CFG0 PPE_REG_ADDR(0x0404)
+#define RBA_CFG1 PPE_REG_ADDR(0x0405)
+#define RCA_CFG0 PPE_REG_ADDR(0x0408)
+#define RCA_CFG1 PPE_REG_ADDR(0x0409)
+#define RDES_CFG0 PPE_REG_ADDR(0x040C)
+#define RDES_CFG1 PPE_REG_ADDR(0x040D)
+#define SFSM_STATE0 PPE_REG_ADDR(0x0410)
+#define SFSM_STATE1 PPE_REG_ADDR(0x0411)
+#define SFSM_DBA0 PPE_REG_ADDR(0x0412)
+#define SFSM_DBA1 PPE_REG_ADDR(0x0413)
+#define SFSM_CBA0 PPE_REG_ADDR(0x0414)
+#define SFSM_CBA1 PPE_REG_ADDR(0x0415)
+#define SFSM_CFG0 PPE_REG_ADDR(0x0416)
+#define SFSM_CFG1 PPE_REG_ADDR(0x0417)
+#define SFSM_PGCNT0 PPE_REG_ADDR(0x041C)
+#define SFSM_PGCNT1 PPE_REG_ADDR(0x041D)
+#define FFSM_DBA0 PPE_REG_ADDR(0x0508)
+#define FFSM_DBA1 PPE_REG_ADDR(0x0509)
+#define FFSM_CFG0 PPE_REG_ADDR(0x050A)
+#define FFSM_CFG1 PPE_REG_ADDR(0x050B)
+#define FFSM_IDLE_HEAD_BC0 PPE_REG_ADDR(0x050E)
+#define FFSM_IDLE_HEAD_BC1 PPE_REG_ADDR(0x050F)
+#define FFSM_PGCNT0 PPE_REG_ADDR(0x0514)
+#define FFSM_PGCNT1 PPE_REG_ADDR(0x0515)
+
+/*
+ * PPE TC Logic Registers (partial)
+ */
+#define DREG_A_VERSION PPE_REG_ADDR(0x0D00)
+#define DREG_A_CFG PPE_REG_ADDR(0x0D01)
+#define DREG_AT_CTRL PPE_REG_ADDR(0x0D02)
+#define DREG_AT_CB_CFG0 PPE_REG_ADDR(0x0D03)
+#define DREG_AT_CB_CFG1 PPE_REG_ADDR(0x0D04)
+#define DREG_AR_CTRL PPE_REG_ADDR(0x0D08)
+#define DREG_AR_CB_CFG0 PPE_REG_ADDR(0x0D09)
+#define DREG_AR_CB_CFG1 PPE_REG_ADDR(0x0D0A)
+#define DREG_A_UTPCFG PPE_REG_ADDR(0x0D0E)
+#define DREG_A_STATUS PPE_REG_ADDR(0x0D0F)
+#define DREG_AT_CFG0 PPE_REG_ADDR(0x0D20)
+#define DREG_AT_CFG1 PPE_REG_ADDR(0x0D21)
+#define DREG_AT_FB_SIZE0 PPE_REG_ADDR(0x0D22)
+#define DREG_AT_FB_SIZE1 PPE_REG_ADDR(0x0D23)
+#define DREG_AT_CELL0 PPE_REG_ADDR(0x0D24)
+#define DREG_AT_CELL1 PPE_REG_ADDR(0x0D25)
+#define DREG_AT_IDLE_CNT0 PPE_REG_ADDR(0x0D26)
+#define DREG_AT_IDLE_CNT1 PPE_REG_ADDR(0x0D27)
+#define DREG_AT_IDLE0 PPE_REG_ADDR(0x0D28)
+#define DREG_AT_IDLE1 PPE_REG_ADDR(0x0D29)
+#define DREG_AR_CFG0 PPE_REG_ADDR(0x0D60)
+#define DREG_AR_CFG1 PPE_REG_ADDR(0x0D61)
+#define DREG_AR_CELL0 PPE_REG_ADDR(0x0D68)
+#define DREG_AR_CELL1 PPE_REG_ADDR(0x0D69)
+#define DREG_AR_IDLE_CNT0 PPE_REG_ADDR(0x0D6A)
+#define DREG_AR_IDLE_CNT1 PPE_REG_ADDR(0x0D6B)
+#define DREG_AR_AIIDLE_CNT0 PPE_REG_ADDR(0x0D6C)
+#define DREG_AR_AIIDLE_CNT1 PPE_REG_ADDR(0x0D6D)
+#define DREG_AR_BE_CNT0 PPE_REG_ADDR(0x0D6E)
+#define DREG_AR_BE_CNT1 PPE_REG_ADDR(0x0D6F)
+#define DREG_AR_HEC_CNT0 PPE_REG_ADDR(0x0D70)
+#define DREG_AR_HEC_CNT1 PPE_REG_ADDR(0x0D71)
+#define DREG_AR_IDLE0 PPE_REG_ADDR(0x0D74)
+#define DREG_AR_IDLE1 PPE_REG_ADDR(0x0D75)
+#define DREG_AR_CVN_CNT0 PPE_REG_ADDR(0x0DA4)
+#define DREG_AR_CVN_CNT1 PPE_REG_ADDR(0x0DA5)
+#define DREG_AR_CVNP_CNT0 PPE_REG_ADDR(0x0DA6)
+#define DREG_AR_CVNP_CNT1 PPE_REG_ADDR(0x0DA7)
+#define DREG_B0_LADR PPE_REG_ADDR(0x0DA8)
+#define DREG_B1_LADR PPE_REG_ADDR(0x0DA9)
+
+#define SFSM_DBA(i) ( (SFSM_dba * ) PPE_REG_ADDR(0x0412 + (i)))
+#define SFSM_CBA(i) ( (SFSM_cba * ) PPE_REG_ADDR(0x0414 + (i)))
+#define SFSM_CFG(i) ( (SFSM_cfg * ) PPE_REG_ADDR(0x0416 + (i)))
+#define SFSM_PGCNT(i) ( (SFSM_pgcnt * ) PPE_REG_ADDR(0x041C + (i)))
+
+#define FFSM_DBA(i) ( (FFSM_dba * ) PPE_REG_ADDR(0x0508 + (i)))
+#define FFSM_CFG(i) ( (FFSM_cfg * ) PPE_REG_ADDR(0x050A + (i)))
+#define FFSM_PGCNT(i) ( (FFSM_pgcnt * ) PPE_REG_ADDR(0x0514 + (i)))
+
+typedef struct {
+ unsigned int res : 19;
+ unsigned int dbase : 13;
+} SFSM_dba;
+
+typedef struct {
+ unsigned int res : 19;
+ unsigned int cbase : 13;
+} SFSM_cba;
+
+typedef struct {
+ unsigned int res : 15;
+ unsigned int endian : 1;
+ unsigned int idlekeep: 1;
+ unsigned int sen : 1;
+ unsigned int res1 : 8;
+ unsigned int pnum : 6;
+} SFSM_cfg;
+
+typedef struct {
+ unsigned int res : 17;
+ unsigned int pptr : 6;
+ unsigned int dcmd : 1;
+ unsigned int res1 : 2;
+ unsigned int upage : 6;
+} SFSM_pgcnt;
+
+typedef struct {
+ unsigned int res : 19;
+ unsigned int dbase : 13;
+} FFSM_dba;
+
+typedef struct {
+ unsigned int res : 12;
+ unsigned int rstptr : 1;
+ unsigned int clvpage : 1;
+ unsigned int fidle : 1;
+ unsigned int endian : 1;
+ unsigned int res1 : 10;
+ unsigned int pnum : 6;
+} FFSM_cfg;
+
+typedef struct {
+ unsigned int res : 17;
+ unsigned int ival : 6;
+ unsigned int icmd : 1;
+ unsigned int res1 : 2;
+ unsigned int vpage : 6;
+} FFSM_pgcnt;
+
+
+
+#endif // IFXMIPS_ATM_PPE_COMMON_H
diff --git a/package/platform/lantiq/ltq-atm/src/ifxmips_atm_ppe_danube.h b/package/platform/lantiq/ltq-atm/src/ifxmips_atm_ppe_danube.h
new file mode 100644
index 0000000..7aaaa8d
--- /dev/null
+++ b/package/platform/lantiq/ltq-atm/src/ifxmips_atm_ppe_danube.h
@@ -0,0 +1,129 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_atm_ppe_danube.h
+** PROJECT : UEIP
+** MODULES : ATM (ADSL)
+**
+** DATE : 1 AUG 2005
+** AUTHOR : Xu Liang
+** DESCRIPTION : ATM Driver (PPE Registers)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 4 AUG 2005 Xu Liang Initiate Version
+** 23 OCT 2006 Xu Liang Add GPL header.
+** 9 JAN 2007 Xu Liang First version got from Anand (IC designer)
+*******************************************************************************/
+
+
+
+#ifndef IFXMIPS_ATM_PPE_DANUBE_H
+#define IFXMIPS_ATM_PPE_DANUBE_H
+
+
+
+/*
+ * FPI Configuration Bus Register and Memory Address Mapping
+ */
+#define IFX_PPE (KSEG1 | 0x1E180000)
+#define PP32_DEBUG_REG_ADDR(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x0000) << 2)))
+#define PPM_INT_REG_ADDR(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x0030) << 2)))
+#define PP32_INTERNAL_RES_ADDR(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x0040) << 2)))
+#define CDM_CODE_MEMORY(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x1000) << 2)))
+#define PPE_REG_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x4000) << 2)))
+#define CDM_DATA_MEMORY(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x5000) << 2)))
+#define PPM_INT_UNIT_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6000) << 2)))
+#define PPM_TIMER0_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6100) << 2)))
+#define PPM_TASK_IND_REG_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6200) << 2)))
+#define PPS_BRK_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6300) << 2)))
+#define PPM_TIMER1_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6400) << 2)))
+#define SB_RAM0_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x8000) << 2)))
+#define SB_RAM1_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x8400) << 2)))
+#define SB_RAM2_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x8C00) << 2)))
+#define SB_RAM3_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x9600) << 2)))
+#define QSB_CONF_REG_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0xC000) << 2)))
+
+/*
+ * DWORD-Length of Memory Blocks
+ */
+#define PP32_DEBUG_REG_DWLEN 0x0030
+#define PPM_INT_REG_DWLEN 0x0010
+#define PP32_INTERNAL_RES_DWLEN 0x00C0
+#define CDM_CODE_MEMORYn_DWLEN(n) ((n) == 0 ? 0x1000 : 0x0800)
+#define PPE_REG_DWLEN 0x1000
+#define CDM_DATA_MEMORY_DWLEN CDM_CODE_MEMORYn_DWLEN(1)
+#define PPM_INT_UNIT_DWLEN 0x0100
+#define PPM_TIMER0_DWLEN 0x0100
+#define PPM_TASK_IND_REG_DWLEN 0x0100
+#define PPS_BRK_DWLEN 0x0100
+#define PPM_TIMER1_DWLEN 0x0100
+#define SB_RAM0_DWLEN 0x0400
+#define SB_RAM1_DWLEN 0x0800
+#define SB_RAM2_DWLEN 0x0A00
+#define SB_RAM3_DWLEN 0x0400
+#define QSB_CONF_REG_DWLEN 0x0100
+
+/*
+ * PP32 to FPI Address Mapping
+ */
+#define SB_BUFFER(__sb_addr) ((volatile unsigned int *)((((__sb_addr) >= 0x2000) && ((__sb_addr) <= 0x23FF)) ? SB_RAM0_ADDR((__sb_addr) - 0x2000) : \
+ (((__sb_addr) >= 0x2400) && ((__sb_addr) <= 0x2BFF)) ? SB_RAM1_ADDR((__sb_addr) - 0x2400) : \
+ (((__sb_addr) >= 0x2C00) && ((__sb_addr) <= 0x35FF)) ? SB_RAM2_ADDR((__sb_addr) - 0x2C00) : \
+ (((__sb_addr) >= 0x3600) && ((__sb_addr) <= 0x39FF)) ? SB_RAM3_ADDR((__sb_addr) - 0x3600) : \
+ 0))
+
+/*
+ * PP32 Debug Control Register
+ */
+#define PP32_DBG_CTRL PP32_DEBUG_REG_ADDR(0, 0x0000)
+
+#define DBG_CTRL_START_SET(value) ((value) ? (1 << 0) : 0)
+#define DBG_CTRL_STOP_SET(value) ((value) ? (1 << 1) : 0)
+#define DBG_CTRL_STEP_SET(value) ((value) ? (1 << 2) : 0)
+
+#define PP32_HALT_STAT PP32_DEBUG_REG_ADDR(0, 0x0001)
+
+#define PP32_BRK_SRC PP32_DEBUG_REG_ADDR(0, 0x0002)
+
+#define PP32_DBG_PC_MIN(i) PP32_DEBUG_REG_ADDR(0, 0x0010 + (i))
+#define PP32_DBG_PC_MAX(i) PP32_DEBUG_REG_ADDR(0, 0x0014 + (i))
+#define PP32_DBG_DATA_MIN(i) PP32_DEBUG_REG_ADDR(0, 0x0018 + (i))
+#define PP32_DBG_DATA_MAX(i) PP32_DEBUG_REG_ADDR(0, 0x001A + (i))
+#define PP32_DBG_DATA_VAL(i) PP32_DEBUG_REG_ADDR(0, 0x001C + (i))
+
+#define PP32_DBG_CUR_PC PP32_DEBUG_REG_ADDR(0, 0x0080)
+
+#define PP32_DBG_TASK_NO PP32_DEBUG_REG_ADDR(0, 0x0081)
+
+#define PP32_DBG_REG_BASE(tsk, i) PP32_DEBUG_REG_ADDR(0, 0x0100 + (tsk) * 16 + (i))
+
+/*
+ * EMA Registers
+ */
+#define EMA_CMDCFG PPE_REG_ADDR(0x0A00)
+#define EMA_DATACFG PPE_REG_ADDR(0x0A01)
+#define EMA_CMDCNT PPE_REG_ADDR(0x0A02)
+#define EMA_DATACNT PPE_REG_ADDR(0x0A03)
+#define EMA_ISR PPE_REG_ADDR(0x0A04)
+#define EMA_IER PPE_REG_ADDR(0x0A05)
+#define EMA_CFG PPE_REG_ADDR(0x0A06)
+#define EMA_SUBID PPE_REG_ADDR(0x0A07)
+
+#define EMA_ALIGNMENT 4
+
+/*
+ * Mailbox IGU1 Interrupt
+ */
+#define PPE_MAILBOX_IGU1_INT INT_NUM_IM2_IRL24
+
+
+
+#endif // IFXMIPS_ATM_PPE_DANUBE_H
diff --git a/package/platform/lantiq/ltq-atm/src/ifxmips_atm_ppe_vr9.h b/package/platform/lantiq/ltq-atm/src/ifxmips_atm_ppe_vr9.h
new file mode 100644
index 0000000..144c396
--- /dev/null
+++ b/package/platform/lantiq/ltq-atm/src/ifxmips_atm_ppe_vr9.h
@@ -0,0 +1,192 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_atm_ppe_vr9.h
+** PROJECT : UEIP
+** MODULES : ATM (ADSL)
+**
+** DATE : 1 AUG 2005
+** AUTHOR : Xu Liang
+** DESCRIPTION : ATM Driver (PPE Registers)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 4 AUG 2005 Xu Liang Initiate Version
+** 23 OCT 2006 Xu Liang Add GPL header.
+** 9 JAN 2007 Xu Liang First version got from Anand (IC designer)
+*******************************************************************************/
+
+
+
+#ifndef IFXMIPS_ATM_PPE_VR9_H
+#define IFXMIPS_ATM_PPE_VR9_H
+
+
+
+/*
+ * FPI Configuration Bus Register and Memory Address Mapping
+ */
+#define IFX_PPE (KSEG1 | 0x1E200000)
+#define PP32_DEBUG_REG_ADDR(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x000000 + (i) * 0x00010000) << 2)))
+#define CDM_CODE_MEMORY(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x001000 + (i) * 0x00010000) << 2)))
+#define CDM_DATA_MEMORY(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x004000 + (i) * 0x00010000) << 2)))
+#define SB_RAM0_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x008000) << 2)))
+#define SB_RAM1_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x009000) << 2)))
+#define SB_RAM2_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x00A000) << 2)))
+#define SB_RAM3_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x00B000) << 2)))
+#define PPE_REG_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x00D000) << 2)))
+#define QSB_CONF_REG_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x00E000) << 2)))
+#define SB_RAM6_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x018000) << 2)))
+
+/*
+ * DWORD-Length of Memory Blocks
+ */
+#define PP32_DEBUG_REG_DWLEN 0x0030
+#define CDM_CODE_MEMORYn_DWLEN(n) ((n) == 0 ? 0x1000 : 0x0800)
+#define CDM_DATA_MEMORY_DWLEN CDM_CODE_MEMORYn_DWLEN(1)
+#define SB_RAM0_DWLEN 0x1000
+#define SB_RAM1_DWLEN 0x1000
+#define SB_RAM2_DWLEN 0x1000
+#define SB_RAM3_DWLEN 0x1000
+#define SB_RAM6_DWLEN 0x8000
+#define QSB_CONF_REG_DWLEN 0x0100
+
+/*
+ * PP32 to FPI Address Mapping
+ */
+#define SB_BUFFER(__sb_addr) ((volatile unsigned int *)((((__sb_addr) >= 0x0000) && ((__sb_addr) <= 0x1FFF)) ? PPE_REG_ADDR((__sb_addr)) : \
+ (((__sb_addr) >= 0x2000) && ((__sb_addr) <= 0x2FFF)) ? SB_RAM0_ADDR((__sb_addr) - 0x2000) : \
+ (((__sb_addr) >= 0x3000) && ((__sb_addr) <= 0x3FFF)) ? SB_RAM1_ADDR((__sb_addr) - 0x3000) : \
+ (((__sb_addr) >= 0x4000) && ((__sb_addr) <= 0x4FFF)) ? SB_RAM2_ADDR((__sb_addr) - 0x4000) : \
+ (((__sb_addr) >= 0x5000) && ((__sb_addr) <= 0x5FFF)) ? SB_RAM3_ADDR((__sb_addr) - 0x5000) : \
+ (((__sb_addr) >= 0x7000) && ((__sb_addr) <= 0x7FFF)) ? PPE_REG_ADDR((__sb_addr) - 0x7000) : \
+ (((__sb_addr) >= 0x8000) && ((__sb_addr) <= 0xFFFF)) ? SB_RAM6_ADDR((__sb_addr) - 0x8000) : \
+ 0))
+
+/*
+ * PP32 Debug Control Register
+ */
+#define NUM_OF_PP32 2
+
+#define PP32_FREEZE PPE_REG_ADDR(0x0000)
+#define PP32_SRST PPE_REG_ADDR(0x0020)
+
+#define PP32_DBG_CTRL(n) PP32_DEBUG_REG_ADDR(n, 0x0000)
+
+#define DBG_CTRL_RESTART 0
+#define DBG_CTRL_STOP 1
+
+#define PP32_CTRL_CMD(n) PP32_DEBUG_REG_ADDR(n, 0x0B00)
+ #define PP32_CTRL_CMD_RESTART (1 << 0)
+ #define PP32_CTRL_CMD_STOP (1 << 1)
+ #define PP32_CTRL_CMD_STEP (1 << 2)
+ #define PP32_CTRL_CMD_BREAKOUT (1 << 3)
+
+#define PP32_CTRL_OPT(n) PP32_DEBUG_REG_ADDR(n, 0x0C00)
+ #define PP32_CTRL_OPT_BREAKOUT_ON_STOP_ON (3 << 0)
+ #define PP32_CTRL_OPT_BREAKOUT_ON_STOP_OFF (2 << 0)
+ #define PP32_CTRL_OPT_BREAKOUT_ON_BREAKIN_ON (3 << 2)
+ #define PP32_CTRL_OPT_BREAKOUT_ON_BREAKIN_OFF (2 << 2)
+ #define PP32_CTRL_OPT_STOP_ON_BREAKIN_ON (3 << 4)
+ #define PP32_CTRL_OPT_STOP_ON_BREAKIN_OFF (2 << 4)
+ #define PP32_CTRL_OPT_STOP_ON_BREAKPOINT_ON (3 << 6)
+ #define PP32_CTRL_OPT_STOP_ON_BREAKPOINT_OFF (2 << 6)
+ #define PP32_CTRL_OPT_BREAKOUT_ON_STOP(n) (*PP32_CTRL_OPT(n) & (1 << 0))
+ #define PP32_CTRL_OPT_BREAKOUT_ON_BREAKIN(n) (*PP32_CTRL_OPT(n) & (1 << 2))
+ #define PP32_CTRL_OPT_STOP_ON_BREAKIN(n) (*PP32_CTRL_OPT(n) & (1 << 4))
+ #define PP32_CTRL_OPT_STOP_ON_BREAKPOINT(n) (*PP32_CTRL_OPT(n) & (1 << 6))
+
+#define PP32_BRK_PC(n, i) PP32_DEBUG_REG_ADDR(n, 0x0900 + (i) * 2)
+#define PP32_BRK_PC_MASK(n, i) PP32_DEBUG_REG_ADDR(n, 0x0901 + (i) * 2)
+#define PP32_BRK_DATA_ADDR(n, i) PP32_DEBUG_REG_ADDR(n, 0x0904 + (i) * 2)
+#define PP32_BRK_DATA_ADDR_MASK(n, i) PP32_DEBUG_REG_ADDR(n, 0x0905 + (i) * 2)
+#define PP32_BRK_DATA_VALUE_RD(n, i) PP32_DEBUG_REG_ADDR(n, 0x0908 + (i) * 2)
+#define PP32_BRK_DATA_VALUE_RD_MASK(n, i) PP32_DEBUG_REG_ADDR(n, 0x0909 + (i) * 2)
+#define PP32_BRK_DATA_VALUE_WR(n, i) PP32_DEBUG_REG_ADDR(n, 0x090C + (i) * 2)
+#define PP32_BRK_DATA_VALUE_WR_MASK(n, i) PP32_DEBUG_REG_ADDR(n, 0x090D + (i) * 2)
+ #define PP32_BRK_CONTEXT_MASK(i) (1 << (i))
+ #define PP32_BRK_CONTEXT_MASK_EN (1 << 4)
+ #define PP32_BRK_COMPARE_GREATER_EQUAL (1 << 5) // valid for break data value rd/wr only
+ #define PP32_BRK_COMPARE_LOWER_EQUAL (1 << 6)
+ #define PP32_BRK_COMPARE_EN (1 << 7)
+
+#define PP32_BRK_TRIG(n) PP32_DEBUG_REG_ADDR(n, 0x0F00)
+ #define PP32_BRK_GRPi_PCn_ON(i, n) ((3 << ((n) * 2)) << ((i) * 16))
+ #define PP32_BRK_GRPi_PCn_OFF(i, n) ((2 << ((n) * 2)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_ADDRn_ON(i, n) ((3 << ((n) * 2 + 4)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_ADDRn_OFF(i, n) ((2 << ((n) * 2 + 4)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_VALUE_RDn_ON(i, n) ((3 << ((n) * 2 + 8)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_VALUE_RDn_OFF(i, n)((2 << ((n) * 2 + 8)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_VALUE_WRn_ON(i, n) ((3 << ((n) * 2 + 12)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_VALUE_WRn_OFF(i, n)((2 << ((n) * 2 + 12)) << ((i) * 16))
+ #define PP32_BRK_GRPi_PCn(k, i, n) (*PP32_BRK_TRIG(k) & ((1 << ((n))) << ((i) * 8)))
+ #define PP32_BRK_GRPi_DATA_ADDRn(k, i, n) (*PP32_BRK_TRIG(k) & ((1 << ((n) + 2)) << ((i) * 8)))
+ #define PP32_BRK_GRPi_DATA_VALUE_RDn(k, i, n) (*PP32_BRK_TRIG(k) & ((1 << ((n) + 4)) << ((i) * 8)))
+ #define PP32_BRK_GRPi_DATA_VALUE_WRn(k, i, n) (*PP32_BRK_TRIG(k) & ((1 << ((n) + 6)) << ((i) * 8)))
+
+#define PP32_CPU_STATUS(n) PP32_DEBUG_REG_ADDR(n, 0x0D00)
+#define PP32_HALT_STAT(n) PP32_CPU_STATUS(n)
+#define PP32_DBG_CUR_PC(n) PP32_CPU_STATUS(n)
+ #define PP32_CPU_USER_STOPPED(n) (*PP32_CPU_STATUS(n) & (1 << 0))
+ #define PP32_CPU_USER_BREAKIN_RCV(n) (*PP32_CPU_STATUS(n) & (1 << 1))
+ #define PP32_CPU_USER_BREAKPOINT_MET(n) (*PP32_CPU_STATUS(n) & (1 << 2))
+ #define PP32_CPU_CUR_PC(n) (*PP32_CPU_STATUS(n) >> 16)
+
+#define PP32_BREAKPOINT_REASONS(n) PP32_DEBUG_REG_ADDR(n, 0x0A00)
+ #define PP32_BRK_PC_MET(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << (i)))
+ #define PP32_BRK_DATA_ADDR_MET(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) + 2)))
+ #define PP32_BRK_DATA_VALUE_RD_MET(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) + 4)))
+ #define PP32_BRK_DATA_VALUE_WR_MET(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) + 6)))
+ #define PP32_BRK_DATA_VALUE_RD_LO_EQ(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) * 2 + 8)))
+ #define PP32_BRK_DATA_VALUE_RD_GT_EQ(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) * 2 + 9)))
+ #define PP32_BRK_DATA_VALUE_WR_LO_EQ(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) * 2 + 12)))
+ #define PP32_BRK_DATA_VALUE_WR_GT_EQ(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) * 2 + 13)))
+ #define PP32_BRK_CUR_CONTEXT(n) ((*PP32_BREAKPOINT_REASONS(n) >> 16) & 0x03)
+
+#define PP32_GP_REG_BASE(n) PP32_DEBUG_REG_ADDR(n, 0x0E00)
+#define PP32_GP_CONTEXTi_REGn(n, i, j) PP32_DEBUG_REG_ADDR(n, 0x0E00 + (i) * 16 + (j))
+
+/*
+ * PDMA/EMA Registers
+ */
+#define PDMA_CFG PPE_REG_ADDR(0x0A00)
+#define PDMA_RX_CMDCNT PPE_REG_ADDR(0x0A01)
+#define PDMA_TX_CMDCNT PPE_REG_ADDR(0x0A02)
+#define PDMA_RX_FWDATACNT PPE_REG_ADDR(0x0A03)
+#define PDMA_TX_FWDATACNT PPE_REG_ADDR(0x0A04)
+#define PDMA_RX_CTX_CFG PPE_REG_ADDR(0x0A05)
+#define PDMA_TX_CTX_CFG PPE_REG_ADDR(0x0A06)
+#define PDMA_RX_MAX_LEN_REG PPE_REG_ADDR(0x0A07)
+#define PDMA_RX_DELAY_CFG PPE_REG_ADDR(0x0A08)
+#define PDMA_INT_FIFO_RD PPE_REG_ADDR(0x0A09)
+#define PDMA_ISR PPE_REG_ADDR(0x0A0A)
+#define PDMA_IER PPE_REG_ADDR(0x0A0B)
+#define PDMA_SUBID PPE_REG_ADDR(0x0A0C)
+#define PDMA_BAR0 PPE_REG_ADDR(0x0A0D)
+#define PDMA_BAR1 PPE_REG_ADDR(0x0A0E)
+
+#define SAR_PDMA_RX_CMDBUF_CFG PPE_REG_ADDR(0x0F00)
+#define SAR_PDMA_TX_CMDBUF_CFG PPE_REG_ADDR(0x0F01)
+#define SAR_PDMA_RX_FW_CMDBUF_CFG PPE_REG_ADDR(0x0F02)
+#define SAR_PDMA_TX_FW_CMDBUF_CFG PPE_REG_ADDR(0x0F03)
+#define SAR_PDMA_RX_CMDBUF_STATUS PPE_REG_ADDR(0x0F04)
+#define SAR_PDMA_TX_CMDBUF_STATUS PPE_REG_ADDR(0x0F05)
+
+#define PDMA_ALIGNMENT 4
+#define EMA_ALIGNMENT PDMA_ALIGNMENT
+
+/*
+ * Mailbox IGU1 Interrupt
+ */
+#define PPE_MAILBOX_IGU1_INT INT_NUM_IM2_IRL24
+
+
+
+#endif // IFXMIPS_ATM_PPE_VR9_H
diff --git a/package/platform/lantiq/ltq-atm/src/ifxmips_atm_vr9.c b/package/platform/lantiq/ltq-atm/src/ifxmips_atm_vr9.c
new file mode 100644
index 0000000..89c71e3
--- /dev/null
+++ b/package/platform/lantiq/ltq-atm/src/ifxmips_atm_vr9.c
@@ -0,0 +1,190 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_atm_vr9.c
+** PROJECT : UEIP
+** MODULES : ATM
+**
+** DATE : 7 Jul 2009
+** AUTHOR : Xu Liang
+** DESCRIPTION : ATM driver common source file (core functions)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 07 JUL 2009 Xu Liang Init Version
+*******************************************************************************/
+
+
+
+/*
+ * ####################################
+ * Head File
+ * ####################################
+ */
+
+/*
+ * Common Head File
+ */
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/version.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/proc_fs.h>
+#include <linux/init.h>
+#include <linux/ioctl.h>
+#include <asm/delay.h>
+
+#include "ifxmips_atm_core.h"
+#include "ifxmips_atm_fw_vr9.h"
+
+#ifdef CONFIG_VR9
+
+#include <lantiq_soc.h>
+
+#define IFX_PMU_MODULE_PPE_SLL01 BIT(19)
+#define IFX_PMU_MODULE_PPE_TC BIT(21)
+#define IFX_PMU_MODULE_PPE_EMA BIT(22)
+#define IFX_PMU_MODULE_PPE_QSB BIT(18)
+#define IFX_PMU_MODULE_AHBS BIT(13)
+#define IFX_PMU_MODULE_DSL_DFE BIT(9)
+
+static inline void vr9_reset_ppe(void)
+{
+/*#ifdef MODULE
+ // reset PPE
+ ifx_rcu_rst(IFX_RCU_DOMAIN_DSLDFE, IFX_RCU_MODULE_ATM);
+ udelay(1000);
+ ifx_rcu_rst(IFX_RCU_DOMAIN_DSLTC, IFX_RCU_MODULE_ATM);
+ udelay(1000);
+ ifx_rcu_rst(IFX_RCU_DOMAIN_PPE, IFX_RCU_MODULE_ATM);
+ udelay(1000);
+ *PP32_SRST &= ~0x000303CF;
+ udelay(1000);
+ *PP32_SRST |= 0x000303CF;
+ udelay(1000);
+#endif*/
+}
+
+static inline int vr9_pp32_download_code(int pp32, u32 *code_src, unsigned int code_dword_len, u32 *data_src, unsigned int data_dword_len)
+{
+ unsigned int clr, set;
+ volatile u32 *dest;
+
+ if ( code_src == 0 || ((unsigned long)code_src & 0x03) != 0
+ || data_src == 0 || ((unsigned long)data_src & 0x03) != 0 )
+ return -1;
+
+ clr = pp32 ? 0xF0 : 0x0F;
+ if ( code_dword_len <= CDM_CODE_MEMORYn_DWLEN(0) )
+ set = pp32 ? (3 << 6): (2 << 2);
+ else
+ set = 0x00;
+ IFX_REG_W32_MASK(clr, set, CDM_CFG);
+
+ dest = CDM_CODE_MEMORY(pp32, 0);
+ while ( code_dword_len-- > 0 )
+ IFX_REG_W32(*code_src++, dest++);
+
+ dest = CDM_DATA_MEMORY(pp32, 0);
+ while ( data_dword_len-- > 0 )
+ IFX_REG_W32(*data_src++, dest++);
+
+ return 0;
+}
+
+static void vr9_fw_ver(unsigned int *major, unsigned int *minor)
+{
+
+ *major = FW_VER_ID->major;
+ *minor = FW_VER_ID->minor;
+}
+
+static void vr9_init(void)
+{
+ volatile u32 *p;
+ unsigned int i;
+
+ /* setup pmu */
+ ltq_pmu_enable(IFX_PMU_MODULE_PPE_SLL01 |
+ IFX_PMU_MODULE_PPE_TC |
+ IFX_PMU_MODULE_PPE_EMA |
+ IFX_PMU_MODULE_PPE_QSB |
+ IFX_PMU_MODULE_AHBS |
+ IFX_PMU_MODULE_DSL_DFE);
+
+ vr9_reset_ppe();
+
+ /* pdma init */
+ IFX_REG_W32(0x08, PDMA_CFG);
+ IFX_REG_W32(0x00203580, SAR_PDMA_RX_CMDBUF_CFG);
+ IFX_REG_W32(0x004035A0, SAR_PDMA_RX_FW_CMDBUF_CFG);
+
+ /* mailbox init */
+ IFX_REG_W32(0xFFFFFFFF, MBOX_IGU1_ISRC);
+ IFX_REG_W32(0x00000000, MBOX_IGU1_IER);
+ IFX_REG_W32(0xFFFFFFFF, MBOX_IGU3_ISRC);
+ IFX_REG_W32(0x00000000, MBOX_IGU3_IER);
+
+ /* tc init - clear sync state */
+ *SFSM_STATE0 = 0;
+ *SFSM_STATE1 = 0;
+
+ /* init shared buffer */
+ p = SB_RAM0_ADDR(0);
+ for ( i = 0; i < SB_RAM0_DWLEN + SB_RAM1_DWLEN + SB_RAM2_DWLEN + SB_RAM3_DWLEN; i++ )
+ IFX_REG_W32(0, p++);
+
+ p = SB_RAM6_ADDR(0);
+ for ( i = 0; i < SB_RAM6_DWLEN; i++ )
+ IFX_REG_W32(0, p++);
+}
+
+static void vr9_shutdown(void)
+{
+}
+
+static int vr9_start(int pp32)
+{
+ unsigned int mask = 1 << (pp32 << 4);
+ int ret;
+
+ /* download firmware */
+ ret = vr9_pp32_download_code(pp32,
+ vr9_fw_bin, sizeof(vr9_fw_bin) / sizeof(*vr9_fw_bin),
+ vr9_fw_data, sizeof(vr9_fw_data) / sizeof(*vr9_fw_data));
+ if ( ret != 0 )
+ return ret;
+
+ /* run PP32 */
+ IFX_REG_W32_MASK(mask, 0, PP32_FREEZE);
+
+ /* idle for a while to let PP32 init itself */
+ udelay(10);
+
+ return 0;
+}
+
+static void vr9_stop(int pp32)
+{
+ unsigned int mask = 1 << (pp32 << 4);
+
+ IFX_REG_W32_MASK(0, mask, PP32_FREEZE);
+}
+
+struct ltq_atm_ops vr9_ops = {
+ .init = vr9_init,
+ .shutdown = vr9_shutdown,
+ .start = vr9_start,
+ .stop = vr9_stop,
+ .fw_ver = vr9_fw_ver,
+};
+
+#endif
diff --git a/package/platform/lantiq/ltq-atm/src/ltq_atm.c b/package/platform/lantiq/ltq-atm/src/ltq_atm.c
new file mode 100644
index 0000000..0e7e6e9
--- /dev/null
+++ b/package/platform/lantiq/ltq-atm/src/ltq_atm.c
@@ -0,0 +1,1897 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_atm_core.c
+** PROJECT : UEIP
+** MODULES : ATM
+**
+** DATE : 7 Jul 2009
+** AUTHOR : Xu Liang
+** DESCRIPTION : ATM driver common source file (core functions)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 07 JUL 2009 Xu Liang Init Version
+*******************************************************************************/
+
+#define IFX_ATM_VER_MAJOR 1
+#define IFX_ATM_VER_MID 0
+#define IFX_ATM_VER_MINOR 26
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/version.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/proc_fs.h>
+#include <linux/init.h>
+#include <linux/ioctl.h>
+#include <linux/atmdev.h>
+#include <linux/platform_device.h>
+#include <linux/of_device.h>
+#include <linux/atm.h>
+#include <linux/clk.h>
+#include <linux/interrupt.h>
+#ifdef CONFIG_XFRM
+ #include <net/xfrm.h>
+#endif
+
+#include <lantiq_soc.h>
+
+#include "ifxmips_atm_core.h"
+
+#define MODULE_PARM_ARRAY(a, b) module_param_array(a, int, NULL, 0)
+#define MODULE_PARM(a, b) module_param(a, int, 0)
+
+/*!
+ \brief QSB cell delay variation due to concurrency
+ */
+static int qsb_tau = 1; /* QSB cell delay variation due to concurrency */
+/*!
+ \brief QSB scheduler burst length
+ */
+static int qsb_srvm = 0x0F; /* QSB scheduler burst length */
+/*!
+ \brief QSB time step, all legal values are 1, 2, 4
+ */
+static int qsb_tstep = 4 ; /* QSB time step, all legal values are 1, 2, 4 */
+
+/*!
+ \brief Write descriptor delay
+ */
+static int write_descriptor_delay = 0x20; /* Write descriptor delay */
+
+/*!
+ \brief AAL5 padding byte ('~')
+ */
+static int aal5_fill_pattern = 0x007E; /* AAL5 padding byte ('~') */
+/*!
+ \brief Max frame size for RX
+ */
+static int aal5r_max_packet_size = 0x0700; /* Max frame size for RX */
+/*!
+ \brief Min frame size for RX
+ */
+static int aal5r_min_packet_size = 0x0000; /* Min frame size for RX */
+/*!
+ \brief Max frame size for TX
+ */
+static int aal5s_max_packet_size = 0x0700; /* Max frame size for TX */
+/*!
+ \brief Min frame size for TX
+ */
+static int aal5s_min_packet_size = 0x0000; /* Min frame size for TX */
+/*!
+ \brief Drop error packet in RX path
+ */
+static int aal5r_drop_error_packet = 1; /* Drop error packet in RX path */
+
+/*!
+ \brief Number of descriptors per DMA RX channel
+ */
+static int dma_rx_descriptor_length = 128; /* Number of descriptors per DMA RX channel */
+/*!
+ \brief Number of descriptors per DMA TX channel
+ */
+static int dma_tx_descriptor_length = 64; /* Number of descriptors per DMA TX channel */
+/*!
+ \brief PPE core clock cycles between descriptor write and effectiveness in external RAM
+ */
+static int dma_rx_clp1_descriptor_threshold = 38;
+/*@}*/
+
+MODULE_PARM(qsb_tau, "i");
+MODULE_PARM_DESC(qsb_tau, "Cell delay variation. Value must be > 0");
+MODULE_PARM(qsb_srvm, "i");
+MODULE_PARM_DESC(qsb_srvm, "Maximum burst size");
+MODULE_PARM(qsb_tstep, "i");
+MODULE_PARM_DESC(qsb_tstep, "n*32 cycles per sbs cycles n=1,2,4");
+
+MODULE_PARM(write_descriptor_delay, "i");
+MODULE_PARM_DESC(write_descriptor_delay, "PPE core clock cycles between descriptor write and effectiveness in external RAM");
+
+MODULE_PARM(aal5_fill_pattern, "i");
+MODULE_PARM_DESC(aal5_fill_pattern, "Filling pattern (PAD) for AAL5 frames");
+MODULE_PARM(aal5r_max_packet_size, "i");
+MODULE_PARM_DESC(aal5r_max_packet_size, "Max packet size in byte for downstream AAL5 frames");
+MODULE_PARM(aal5r_min_packet_size, "i");
+MODULE_PARM_DESC(aal5r_min_packet_size, "Min packet size in byte for downstream AAL5 frames");
+MODULE_PARM(aal5s_max_packet_size, "i");
+MODULE_PARM_DESC(aal5s_max_packet_size, "Max packet size in byte for upstream AAL5 frames");
+MODULE_PARM(aal5s_min_packet_size, "i");
+MODULE_PARM_DESC(aal5s_min_packet_size, "Min packet size in byte for upstream AAL5 frames");
+MODULE_PARM(aal5r_drop_error_packet, "i");
+MODULE_PARM_DESC(aal5r_drop_error_packet, "Non-zero value to drop error packet for downstream");
+
+MODULE_PARM(dma_rx_descriptor_length, "i");
+MODULE_PARM_DESC(dma_rx_descriptor_length, "Number of descriptor assigned to DMA RX channel (>16)");
+MODULE_PARM(dma_tx_descriptor_length, "i");
+MODULE_PARM_DESC(dma_tx_descriptor_length, "Number of descriptor assigned to DMA TX channel (>16)");
+MODULE_PARM(dma_rx_clp1_descriptor_threshold, "i");
+MODULE_PARM_DESC(dma_rx_clp1_descriptor_threshold, "Descriptor threshold for cells with cell loss priority 1");
+
+
+
+/*
+ * ####################################
+ * Definition
+ * ####################################
+ */
+
+#ifdef CONFIG_AMAZON_SE
+ #define ENABLE_LESS_CACHE_INV 1
+ #define LESS_CACHE_INV_LEN 96
+#endif
+
+#define DUMP_SKB_LEN ~0
+
+
+
+/*
+ * ####################################
+ * Declaration
+ * ####################################
+ */
+
+/*
+ * Network Operations
+ */
+static int ppe_ioctl(struct atm_dev *, unsigned int, void *);
+static int ppe_open(struct atm_vcc *);
+static void ppe_close(struct atm_vcc *);
+static int ppe_send(struct atm_vcc *, struct sk_buff *);
+static int ppe_send_oam(struct atm_vcc *, void *, int);
+static int ppe_change_qos(struct atm_vcc *, struct atm_qos *, int);
+
+/*
+ * ADSL LED
+ */
+static inline void adsl_led_flash(void);
+
+/*
+ * 64-bit operation used by MIB calculation
+ */
+static inline void u64_add_u32(ppe_u64_t, unsigned int, ppe_u64_t *);
+
+/*
+ * buffer manage functions
+ */
+static inline struct sk_buff* alloc_skb_rx(void);
+static inline struct sk_buff* alloc_skb_tx(unsigned int);
+struct sk_buff* atm_alloc_tx(struct atm_vcc *, unsigned int);
+static inline void atm_free_tx_skb_vcc(struct sk_buff *, struct atm_vcc *);
+static inline struct sk_buff *get_skb_rx_pointer(unsigned int);
+static inline int get_tx_desc(unsigned int);
+static struct sk_buff* skb_duplicate(struct sk_buff *);
+static struct sk_buff* skb_break_away_from_protocol(struct sk_buff *);
+
+/*
+ * mailbox handler and signal function
+ */
+static inline void mailbox_oam_rx_handler(void);
+static inline void mailbox_aal_rx_handler(void);
+static irqreturn_t mailbox_irq_handler(int, void *);
+static inline void mailbox_signal(unsigned int, int);
+
+/*
+ * QSB & HTU setting functions
+ */
+static void set_qsb(struct atm_vcc *, struct atm_qos *, unsigned int);
+static void qsb_global_set(void);
+static inline void set_htu_entry(unsigned int, unsigned int, unsigned int, int, int);
+static inline void clear_htu_entry(unsigned int);
+static void validate_oam_htu_entry(void);
+static void invalidate_oam_htu_entry(void);
+
+/*
+ * look up for connection ID
+ */
+static inline int find_vpi(unsigned int);
+static inline int find_vpivci(unsigned int, unsigned int);
+static inline int find_vcc(struct atm_vcc *);
+
+static inline int ifx_atm_version(const struct ltq_atm_ops *ops, char *);
+
+/*
+ * Init & clean-up functions
+ */
+static inline void check_parameters(void);
+static inline int init_priv_data(void);
+static inline void clear_priv_data(void);
+static inline void init_rx_tables(void);
+static inline void init_tx_tables(void);
+
+/*
+ * Exteranl Function
+ */
+#if defined(CONFIG_IFX_OAM) || defined(CONFIG_IFX_OAM_MODULE)
+extern void ifx_push_oam(unsigned char *);
+#else
+static inline void ifx_push_oam(unsigned char *dummy) {}
+#endif
+
+#if defined(CONFIG_IFXMIPS_DSL_CPE_MEI) || defined(CONFIG_IFXMIPS_DSL_CPE_MEI_MODULE)
+extern int ifx_mei_atm_showtime_check(int *is_showtime, struct port_cell_info *port_cell, void **xdata_addr);
+extern int (*ifx_mei_atm_showtime_enter)(struct port_cell_info *, void *);
+
+extern int (*ifx_mei_atm_showtime_exit)(void);
+extern int ifx_mei_atm_led_blink(void);
+#else
+static inline int ifx_mei_atm_led_blink(void) { return 0; }
+static inline int ifx_mei_atm_showtime_check(int *is_showtime, struct port_cell_info *port_cell, void **xdata_addr)
+{
+ if ( is_showtime != NULL )
+ *is_showtime = 0;
+ return 0;
+}
+int (*ifx_mei_atm_showtime_enter)(struct port_cell_info *, void *) = NULL;
+EXPORT_SYMBOL(ifx_mei_atm_showtime_enter);
+
+int (*ifx_mei_atm_showtime_exit)(void) = NULL;
+EXPORT_SYMBOL(ifx_mei_atm_showtime_exit);
+
+#endif
+
+static struct sk_buff* (*ifx_atm_alloc_tx)(struct atm_vcc *, unsigned int) = NULL;
+
+static struct atm_priv_data g_atm_priv_data;
+
+static struct atmdev_ops g_ifx_atm_ops = {
+ .open = ppe_open,
+ .close = ppe_close,
+ .ioctl = ppe_ioctl,
+ .send = ppe_send,
+ .send_oam = ppe_send_oam,
+ .change_qos = ppe_change_qos,
+ .owner = THIS_MODULE,
+};
+
+static int g_showtime = 0;
+static void *g_xdata_addr = NULL;
+
+static int ppe_ioctl(struct atm_dev *dev, unsigned int cmd, void *arg)
+{
+ int ret = 0;
+ atm_cell_ifEntry_t mib_cell;
+ atm_aal5_ifEntry_t mib_aal5;
+ atm_aal5_vcc_x_t mib_vcc;
+ unsigned int value;
+ int conn;
+
+ if ( _IOC_TYPE(cmd) != PPE_ATM_IOC_MAGIC
+ || _IOC_NR(cmd) >= PPE_ATM_IOC_MAXNR )
+ return -ENOTTY;
+
+ if ( _IOC_DIR(cmd) & _IOC_READ )
+ ret = !access_ok(VERIFY_WRITE, arg, _IOC_SIZE(cmd));
+ else if ( _IOC_DIR(cmd) & _IOC_WRITE )
+ ret = !access_ok(VERIFY_READ, arg, _IOC_SIZE(cmd));
+ if ( ret )
+ return -EFAULT;
+
+ switch (cmd) {
+ case PPE_ATM_MIB_CELL: /* cell level MIB */
+ /* These MIB should be read at ARC side, now put zero only. */
+ mib_cell.ifHCInOctets_h = 0;
+ mib_cell.ifHCInOctets_l = 0;
+ mib_cell.ifHCOutOctets_h = 0;
+ mib_cell.ifHCOutOctets_l = 0;
+ mib_cell.ifInErrors = 0;
+ mib_cell.ifInUnknownProtos = WAN_MIB_TABLE->wrx_drophtu_cell;
+ mib_cell.ifOutErrors = 0;
+
+ ret = sizeof(mib_cell) - copy_to_user(arg, &mib_cell, sizeof(mib_cell));
+ break;
+
+ case PPE_ATM_MIB_AAL5: /* AAL5 MIB */
+ value = WAN_MIB_TABLE->wrx_total_byte;
+ u64_add_u32(g_atm_priv_data.wrx_total_byte, value - g_atm_priv_data.prev_wrx_total_byte, &g_atm_priv_data.wrx_total_byte);
+ g_atm_priv_data.prev_wrx_total_byte = value;
+ mib_aal5.ifHCInOctets_h = g_atm_priv_data.wrx_total_byte.h;
+ mib_aal5.ifHCInOctets_l = g_atm_priv_data.wrx_total_byte.l;
+
+ value = WAN_MIB_TABLE->wtx_total_byte;
+ u64_add_u32(g_atm_priv_data.wtx_total_byte, value - g_atm_priv_data.prev_wtx_total_byte, &g_atm_priv_data.wtx_total_byte);
+ g_atm_priv_data.prev_wtx_total_byte = value;
+ mib_aal5.ifHCOutOctets_h = g_atm_priv_data.wtx_total_byte.h;
+ mib_aal5.ifHCOutOctets_l = g_atm_priv_data.wtx_total_byte.l;
+
+ mib_aal5.ifInUcastPkts = g_atm_priv_data.wrx_pdu;
+ mib_aal5.ifOutUcastPkts = WAN_MIB_TABLE->wtx_total_pdu;
+ mib_aal5.ifInErrors = WAN_MIB_TABLE->wrx_err_pdu;
+ mib_aal5.ifInDiscards = WAN_MIB_TABLE->wrx_dropdes_pdu + g_atm_priv_data.wrx_drop_pdu;
+ mib_aal5.ifOutErros = g_atm_priv_data.wtx_err_pdu;
+ mib_aal5.ifOutDiscards = g_atm_priv_data.wtx_drop_pdu;
+
+ ret = sizeof(mib_aal5) - copy_to_user(arg, &mib_aal5, sizeof(mib_aal5));
+ break;
+
+ case PPE_ATM_MIB_VCC: /* VCC related MIB */
+ copy_from_user(&mib_vcc, arg, sizeof(mib_vcc));
+ conn = find_vpivci(mib_vcc.vpi, mib_vcc.vci);
+ if (conn >= 0) {
+ mib_vcc.mib_vcc.aal5VccCrcErrors = g_atm_priv_data.conn[conn].aal5_vcc_crc_err;
+ mib_vcc.mib_vcc.aal5VccOverSizedSDUs = g_atm_priv_data.conn[conn].aal5_vcc_oversize_sdu;
+ mib_vcc.mib_vcc.aal5VccSarTimeOuts = 0; /* no timer support */
+ ret = sizeof(mib_vcc) - copy_to_user(arg, &mib_vcc, sizeof(mib_vcc));
+ } else
+ ret = -EINVAL;
+ break;
+
+ default:
+ ret = -ENOIOCTLCMD;
+ }
+
+ return ret;
+}
+
+static int ppe_open(struct atm_vcc *vcc)
+{
+ int ret;
+ short vpi = vcc->vpi;
+ int vci = vcc->vci;
+ struct port *port = &g_atm_priv_data.port[(int)vcc->dev->dev_data];
+ int conn;
+ int f_enable_irq = 0;
+
+ if ( vcc->qos.aal != ATM_AAL5 && vcc->qos.aal != ATM_AAL0 )
+ return -EPROTONOSUPPORT;
+
+#if !defined(DISABLE_QOS_WORKAROUND) || !DISABLE_QOS_WORKAROUND
+ /* check bandwidth */
+ if ( (vcc->qos.txtp.traffic_class == ATM_CBR && vcc->qos.txtp.max_pcr > (port->tx_max_cell_rate - port->tx_current_cell_rate))
+ || (vcc->qos.txtp.traffic_class == ATM_VBR_RT && vcc->qos.txtp.max_pcr > (port->tx_max_cell_rate - port->tx_current_cell_rate))
+ || (vcc->qos.txtp.traffic_class == ATM_VBR_NRT && vcc->qos.txtp.scr > (port->tx_max_cell_rate - port->tx_current_cell_rate))
+ || (vcc->qos.txtp.traffic_class == ATM_UBR_PLUS && vcc->qos.txtp.min_pcr > (port->tx_max_cell_rate - port->tx_current_cell_rate)) )
+ {
+ ret = -EINVAL;
+ goto PPE_OPEN_EXIT;
+ }
+#endif
+
+ /* check existing vpi,vci */
+ conn = find_vpivci(vpi, vci);
+ if ( conn >= 0 ) {
+ ret = -EADDRINUSE;
+ goto PPE_OPEN_EXIT;
+ }
+
+ /* check whether it need to enable irq */
+ if ( g_atm_priv_data.conn_table == 0 )
+ f_enable_irq = 1;
+
+ /* allocate connection */
+ for ( conn = 0; conn < MAX_PVC_NUMBER; conn++ ) {
+ if ( test_and_set_bit(conn, &g_atm_priv_data.conn_table) == 0 ) {
+ g_atm_priv_data.conn[conn].vcc = vcc;
+ break;
+ }
+ }
+ if ( conn == MAX_PVC_NUMBER ) {
+ ret = -EINVAL;
+ goto PPE_OPEN_EXIT;
+ }
+
+ /* reserve bandwidth */
+ switch ( vcc->qos.txtp.traffic_class ) {
+ case ATM_CBR:
+ case ATM_VBR_RT:
+ port->tx_current_cell_rate += vcc->qos.txtp.max_pcr;
+ break;
+ case ATM_VBR_NRT:
+ port->tx_current_cell_rate += vcc->qos.txtp.scr;
+ break;
+ case ATM_UBR_PLUS:
+ port->tx_current_cell_rate += vcc->qos.txtp.min_pcr;
+ break;
+ }
+
+ /* set qsb */
+ set_qsb(vcc, &vcc->qos, conn);
+
+ /* update atm_vcc structure */
+ vcc->itf = (int)vcc->dev->dev_data;
+ vcc->vpi = vpi;
+ vcc->vci = vci;
+ set_bit(ATM_VF_READY, &vcc->flags);
+
+ /* enable irq */
+ if ( f_enable_irq ) {
+ ifx_atm_alloc_tx = atm_alloc_tx;
+
+ *MBOX_IGU1_ISRC = (1 << RX_DMA_CH_AAL) | (1 << RX_DMA_CH_OAM);
+ *MBOX_IGU1_IER = (1 << RX_DMA_CH_AAL) | (1 << RX_DMA_CH_OAM);
+
+ enable_irq(PPE_MAILBOX_IGU1_INT);
+ }
+
+ /* set port */
+ WTX_QUEUE_CONFIG(conn + FIRST_QSB_QID)->sbid = (int)vcc->dev->dev_data;
+
+ /* set htu entry */
+ set_htu_entry(vpi, vci, conn, vcc->qos.aal == ATM_AAL5 ? 1 : 0, 0);
+
+ ret = 0;
+
+PPE_OPEN_EXIT:
+ return ret;
+}
+
+static void ppe_close(struct atm_vcc *vcc)
+{
+ int conn;
+ struct port *port;
+ struct connection *connection;
+ if ( vcc == NULL )
+ return;
+
+ /* get connection id */
+ conn = find_vcc(vcc);
+ if ( conn < 0 ) {
+ pr_err("can't find vcc\n");
+ goto PPE_CLOSE_EXIT;
+ }
+ connection = &g_atm_priv_data.conn[conn];
+ port = &g_atm_priv_data.port[connection->port];
+
+ /* clear htu */
+ clear_htu_entry(conn);
+
+ /* release connection */
+ connection->vcc = NULL;
+ connection->aal5_vcc_crc_err = 0;
+ connection->aal5_vcc_oversize_sdu = 0;
+ clear_bit(conn, &g_atm_priv_data.conn_table);
+
+ /* disable irq */
+ if ( g_atm_priv_data.conn_table == 0 ) {
+ disable_irq(PPE_MAILBOX_IGU1_INT);
+ ifx_atm_alloc_tx = NULL;
+ }
+
+ /* release bandwidth */
+ switch ( vcc->qos.txtp.traffic_class )
+ {
+ case ATM_CBR:
+ case ATM_VBR_RT:
+ port->tx_current_cell_rate -= vcc->qos.txtp.max_pcr;
+ break;
+ case ATM_VBR_NRT:
+ port->tx_current_cell_rate -= vcc->qos.txtp.scr;
+ break;
+ case ATM_UBR_PLUS:
+ port->tx_current_cell_rate -= vcc->qos.txtp.min_pcr;
+ break;
+ }
+
+PPE_CLOSE_EXIT:
+ return;
+}
+
+static int ppe_send(struct atm_vcc *vcc, struct sk_buff *skb)
+{
+ int ret;
+ int conn;
+ int desc_base;
+ struct tx_descriptor reg_desc = {0};
+ struct sk_buff *new_skb;
+
+ if ( vcc == NULL || skb == NULL )
+ return -EINVAL;
+
+ skb_get(skb);
+ atm_free_tx_skb_vcc(skb, vcc);
+
+ conn = find_vcc(vcc);
+ if ( conn < 0 ) {
+ ret = -EINVAL;
+ goto FIND_VCC_FAIL;
+ }
+
+ if ( !g_showtime ) {
+ pr_debug("not in showtime\n");
+ ret = -EIO;
+ goto PPE_SEND_FAIL;
+ }
+
+ if ( vcc->qos.aal == ATM_AAL5 ) {
+ int byteoff;
+ int datalen;
+ struct tx_inband_header *header;
+
+ byteoff = (unsigned int)skb->data & (DATA_BUFFER_ALIGNMENT - 1);
+ if ( skb_headroom(skb) < byteoff + TX_INBAND_HEADER_LENGTH )
+ new_skb = skb_duplicate(skb);
+ else
+ new_skb = skb_break_away_from_protocol(skb);
+ if ( new_skb == NULL ) {
+ pr_err("either skb_duplicate or skb_break_away_from_protocol fail\n");
+ ret = -ENOMEM;
+ goto PPE_SEND_FAIL;
+ }
+ dev_kfree_skb_any(skb);
+ skb = new_skb;
+
+ datalen = skb->len;
+ byteoff = (unsigned int)skb->data & (DATA_BUFFER_ALIGNMENT - 1);
+
+ skb_push(skb, byteoff + TX_INBAND_HEADER_LENGTH);
+
+ header = (struct tx_inband_header *)skb->data;
+
+ /* setup inband trailer */
+ header->uu = 0;
+ header->cpi = 0;
+ header->pad = aal5_fill_pattern;
+ header->res1 = 0;
+
+ /* setup cell header */
+ header->clp = (vcc->atm_options & ATM_ATMOPT_CLP) ? 1 : 0;
+ header->pti = ATM_PTI_US0;
+ header->vci = vcc->vci;
+ header->vpi = vcc->vpi;
+ header->gfc = 0;
+
+ /* setup descriptor */
+ reg_desc.dataptr = (unsigned int)skb->data >> 2;
+ reg_desc.datalen = datalen;
+ reg_desc.byteoff = byteoff;
+ reg_desc.iscell = 0;
+ } else {
+ /* if data pointer is not aligned, allocate new sk_buff */
+ if ( ((unsigned int)skb->data & (DATA_BUFFER_ALIGNMENT - 1)) != 0 ) {
+ pr_err("skb->data not aligned\n");
+ new_skb = skb_duplicate(skb);
+ } else
+ new_skb = skb_break_away_from_protocol(skb);
+ if ( new_skb == NULL ) {
+ pr_err("either skb_duplicate or skb_break_away_from_protocol fail\n");
+ ret = -ENOMEM;
+ goto PPE_SEND_FAIL;
+ }
+ dev_kfree_skb_any(skb);
+ skb = new_skb;
+
+ reg_desc.dataptr = (unsigned int)skb->data >> 2;
+ reg_desc.datalen = skb->len;
+ reg_desc.byteoff = 0;
+ reg_desc.iscell = 1;
+ }
+
+ reg_desc.own = 1;
+ reg_desc.c = 1;
+ reg_desc.sop = reg_desc.eop = 1;
+
+ desc_base = get_tx_desc(conn);
+ if ( desc_base < 0 ) {
+ pr_debug("ALLOC_TX_CONNECTION_FAIL\n");
+ ret = -EIO;
+ goto PPE_SEND_FAIL;
+ }
+
+ if ( vcc->stats )
+ atomic_inc(&vcc->stats->tx);
+ if ( vcc->qos.aal == ATM_AAL5 )
+ g_atm_priv_data.wtx_pdu++;
+
+ /* update descriptor send pointer */
+ if ( g_atm_priv_data.conn[conn].tx_skb[desc_base] != NULL )
+ dev_kfree_skb_any(g_atm_priv_data.conn[conn].tx_skb[desc_base]);
+ g_atm_priv_data.conn[conn].tx_skb[desc_base] = skb;
+
+ /* write discriptor to memory and write back cache */
+ g_atm_priv_data.conn[conn].tx_desc[desc_base] = reg_desc;
+ dma_cache_wback((unsigned long)skb->data, skb->len);
+
+ mailbox_signal(conn, 1);
+
+ adsl_led_flash();
+
+ return 0;
+
+FIND_VCC_FAIL:
+ pr_err("FIND_VCC_FAIL\n");
+ g_atm_priv_data.wtx_err_pdu++;
+ dev_kfree_skb_any(skb);
+ return ret;
+
+PPE_SEND_FAIL:
+ if ( vcc->qos.aal == ATM_AAL5 )
+ g_atm_priv_data.wtx_drop_pdu++;
+ if ( vcc->stats )
+ atomic_inc(&vcc->stats->tx_err);
+ dev_kfree_skb_any(skb);
+ return ret;
+}
+
+/* operation and maintainance */
+static int ppe_send_oam(struct atm_vcc *vcc, void *cell, int flags)
+{
+ int conn;
+ struct uni_cell_header *uni_cell_header = (struct uni_cell_header *)cell;
+ int desc_base;
+ struct sk_buff *skb;
+ struct tx_descriptor reg_desc = {0};
+
+ if ( ((uni_cell_header->pti == ATM_PTI_SEGF5 || uni_cell_header->pti == ATM_PTI_E2EF5)
+ && find_vpivci(uni_cell_header->vpi, uni_cell_header->vci) < 0)
+ || ((uni_cell_header->vci == 0x03 || uni_cell_header->vci == 0x04)
+ && find_vpi(uni_cell_header->vpi) < 0) )
+ {
+ g_atm_priv_data.wtx_err_oam++;
+ return -EINVAL;
+ }
+
+ if ( !g_showtime ) {
+ pr_err("not in showtime\n");
+ g_atm_priv_data.wtx_drop_oam++;
+ return -EIO;
+ }
+
+ conn = find_vcc(vcc);
+ if ( conn < 0 ) {
+ pr_err("FIND_VCC_FAIL\n");
+ g_atm_priv_data.wtx_drop_oam++;
+ return -EINVAL;
+ }
+
+ skb = alloc_skb_tx(CELL_SIZE);
+ if ( skb == NULL ) {
+ pr_err("ALLOC_SKB_TX_FAIL\n");
+ g_atm_priv_data.wtx_drop_oam++;
+ return -ENOMEM;
+ }
+ skb_put(skb, CELL_SIZE);
+ memcpy(skb->data, cell, CELL_SIZE);
+
+ reg_desc.dataptr = (unsigned int)skb->data >> 2;
+ reg_desc.datalen = CELL_SIZE;
+ reg_desc.byteoff = 0;
+ reg_desc.iscell = 1;
+
+ reg_desc.own = 1;
+ reg_desc.c = 1;
+ reg_desc.sop = reg_desc.eop = 1;
+
+ desc_base = get_tx_desc(conn);
+ if ( desc_base < 0 ) {
+ dev_kfree_skb_any(skb);
+ pr_err("ALLOC_TX_CONNECTION_FAIL\n");
+ g_atm_priv_data.wtx_drop_oam++;
+ return -EIO;
+ }
+
+ if ( vcc->stats )
+ atomic_inc(&vcc->stats->tx);
+
+ /* update descriptor send pointer */
+ if ( g_atm_priv_data.conn[conn].tx_skb[desc_base] != NULL )
+ dev_kfree_skb_any(g_atm_priv_data.conn[conn].tx_skb[desc_base]);
+ g_atm_priv_data.conn[conn].tx_skb[desc_base] = skb;
+
+ /* write discriptor to memory and write back cache */
+ g_atm_priv_data.conn[conn].tx_desc[desc_base] = reg_desc;
+ dma_cache_wback((unsigned long)skb->data, CELL_SIZE);
+
+ mailbox_signal(conn, 1);
+
+ g_atm_priv_data.wtx_oam++;
+ adsl_led_flash();
+
+ return 0;
+}
+
+static int ppe_change_qos(struct atm_vcc *vcc, struct atm_qos *qos, int flags)
+{
+ int conn;
+
+ if ( vcc == NULL || qos == NULL )
+ return -EINVAL;
+
+ conn = find_vcc(vcc);
+ if ( conn < 0 )
+ return -EINVAL;
+
+ set_qsb(vcc, qos, conn);
+
+ return 0;
+}
+
+static inline void adsl_led_flash(void)
+{
+ ifx_mei_atm_led_blink();
+}
+
+/*
+* Description:
+* Add a 32-bit value to 64-bit value, and put result in a 64-bit variable.
+* Input:
+* opt1 --- ppe_u64_t, first operand, a 64-bit unsigned integer value
+* opt2 --- unsigned int, second operand, a 32-bit unsigned integer value
+* ret --- ppe_u64_t, pointer to a variable to hold result
+* Output:
+* none
+*/
+static inline void u64_add_u32(ppe_u64_t opt1, unsigned int opt2, ppe_u64_t *ret)
+{
+ ret->l = opt1.l + opt2;
+ if ( ret->l < opt1.l || ret->l < opt2 )
+ ret->h++;
+}
+
+static inline struct sk_buff* alloc_skb_rx(void)
+{
+ struct sk_buff *skb;
+
+ skb = dev_alloc_skb(RX_DMA_CH_AAL_BUF_SIZE + DATA_BUFFER_ALIGNMENT);
+ if ( skb != NULL ) {
+ /* must be burst length alignment */
+ if ( ((unsigned int)skb->data & (DATA_BUFFER_ALIGNMENT - 1)) != 0 )
+ skb_reserve(skb, ~((unsigned int)skb->data + (DATA_BUFFER_ALIGNMENT - 1)) & (DATA_BUFFER_ALIGNMENT - 1));
+ /* pub skb in reserved area "skb->data - 4" */
+ *((struct sk_buff **)skb->data - 1) = skb;
+ /* write back and invalidate cache */
+ dma_cache_wback_inv((unsigned long)skb->data - sizeof(skb), sizeof(skb));
+ /* invalidate cache */
+#if defined(ENABLE_LESS_CACHE_INV) && ENABLE_LESS_CACHE_INV
+ dma_cache_inv((unsigned long)skb->data, LESS_CACHE_INV_LEN);
+#else
+ dma_cache_inv((unsigned long)skb->data, RX_DMA_CH_AAL_BUF_SIZE);
+#endif
+ }
+ return skb;
+}
+
+static inline struct sk_buff* alloc_skb_tx(unsigned int size)
+{
+ struct sk_buff *skb;
+
+ /* allocate memory including header and padding */
+ size += TX_INBAND_HEADER_LENGTH + MAX_TX_PACKET_ALIGN_BYTES + MAX_TX_PACKET_PADDING_BYTES;
+ size &= ~(DATA_BUFFER_ALIGNMENT - 1);
+ skb = dev_alloc_skb(size + DATA_BUFFER_ALIGNMENT);
+ /* must be burst length alignment */
+ if ( skb != NULL )
+ skb_reserve(skb, (~((unsigned int)skb->data + (DATA_BUFFER_ALIGNMENT - 1)) & (DATA_BUFFER_ALIGNMENT - 1)) + TX_INBAND_HEADER_LENGTH);
+ return skb;
+}
+
+struct sk_buff* atm_alloc_tx(struct atm_vcc *vcc, unsigned int size)
+{
+ int conn;
+ struct sk_buff *skb;
+
+ /* oversize packet */
+ if ( size > aal5s_max_packet_size ) {
+ pr_err("atm_alloc_tx: oversize packet\n");
+ return NULL;
+ }
+ /* send buffer overflow */
+ if ( sk_wmem_alloc_get(sk_atm(vcc)) && !atm_may_send(vcc, size) ) {
+ pr_err("atm_alloc_tx: send buffer overflow\n");
+ return NULL;
+ }
+ conn = find_vcc(vcc);
+ if ( conn < 0 ) {
+ pr_err("atm_alloc_tx: unknown VCC\n");
+ return NULL;
+ }
+
+ skb = dev_alloc_skb(size);
+ if ( skb == NULL ) {
+ pr_err("atm_alloc_tx: sk buffer is used up\n");
+ return NULL;
+ }
+
+ atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
+
+ return skb;
+}
+
+static inline void atm_free_tx_skb_vcc(struct sk_buff *skb, struct atm_vcc *vcc)
+{
+ if ( vcc->pop != NULL )
+ vcc->pop(vcc, skb);
+ else
+ dev_kfree_skb_any(skb);
+}
+
+static inline struct sk_buff *get_skb_rx_pointer(unsigned int dataptr)
+{
+ unsigned int skb_dataptr;
+ struct sk_buff *skb;
+
+ skb_dataptr = ((dataptr - 1) << 2) | KSEG1;
+ skb = *(struct sk_buff **)skb_dataptr;
+
+ ASSERT((unsigned int)skb >= KSEG0, "invalid skb - skb = %#08x, dataptr = %#08x", (unsigned int)skb, dataptr);
+ ASSERT(((unsigned int)skb->data | KSEG1) == ((dataptr << 2) | KSEG1), "invalid skb - skb = %#08x, skb->data = %#08x, dataptr = %#08x", (unsigned int)skb, (unsigned int)skb->data, dataptr);
+
+ return skb;
+}
+
+static inline int get_tx_desc(unsigned int conn)
+{
+ int desc_base = -1;
+ struct connection *p_conn = &g_atm_priv_data.conn[conn];
+
+ if ( p_conn->tx_desc[p_conn->tx_desc_pos].own == 0 ) {
+ desc_base = p_conn->tx_desc_pos;
+ if ( ++(p_conn->tx_desc_pos) == dma_tx_descriptor_length )
+ p_conn->tx_desc_pos = 0;
+ }
+
+ return desc_base;
+}
+
+static struct sk_buff* skb_duplicate(struct sk_buff *skb)
+{
+ struct sk_buff *new_skb;
+
+ new_skb = alloc_skb_tx(skb->len);
+ if ( new_skb == NULL )
+ return NULL;
+
+ skb_put(new_skb, skb->len);
+ memcpy(new_skb->data, skb->data, skb->len);
+
+ return new_skb;
+}
+
+static struct sk_buff* skb_break_away_from_protocol(struct sk_buff *skb)
+{
+ struct sk_buff *new_skb;
+
+ if ( skb_shared(skb) ) {
+ new_skb = skb_clone(skb, GFP_ATOMIC);
+ if ( new_skb == NULL )
+ return NULL;
+ } else
+ new_skb = skb_get(skb);
+
+ skb_dst_drop(new_skb);
+#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
+ nf_conntrack_put(new_skb->nfct);
+ new_skb->nfct = NULL;
+ nf_conntrack_put_reasm(new_skb->nfct_reasm);
+ new_skb->nfct_reasm = NULL;
+ #ifdef CONFIG_BRIDGE_NETFILTER
+ nf_bridge_put(new_skb->nf_bridge);
+ new_skb->nf_bridge = NULL;
+ #endif
+#endif
+
+ return new_skb;
+}
+
+static inline void mailbox_oam_rx_handler(void)
+{
+ unsigned int vlddes = WRX_DMA_CHANNEL_CONFIG(RX_DMA_CH_OAM)->vlddes;
+ struct rx_descriptor reg_desc;
+ struct uni_cell_header *header;
+ int conn;
+ struct atm_vcc *vcc;
+ unsigned int i;
+
+ for ( i = 0; i < vlddes; i++ ) {
+ unsigned int loop_count = 0;
+
+ do {
+ reg_desc = g_atm_priv_data.oam_desc[g_atm_priv_data.oam_desc_pos];
+ if ( ++loop_count == 1000 )
+ break;
+ } while ( reg_desc.own || !reg_desc.c ); // keep test OWN and C bit until data is ready
+ ASSERT(loop_count == 1, "loop_count = %u, own = %d, c = %d, oam_desc_pos = %u", loop_count, (int)reg_desc.own, (int)reg_desc.c, g_atm_priv_data.oam_desc_pos);
+
+ header = (struct uni_cell_header *)&g_atm_priv_data.oam_buf[g_atm_priv_data.oam_desc_pos * RX_DMA_CH_OAM_BUF_SIZE];
+
+ if ( header->pti == ATM_PTI_SEGF5 || header->pti == ATM_PTI_E2EF5 )
+ conn = find_vpivci(header->vpi, header->vci);
+ else if ( header->vci == 0x03 || header->vci == 0x04 )
+ conn = find_vpi(header->vpi);
+ else
+ conn = -1;
+
+ if ( conn >= 0 && g_atm_priv_data.conn[conn].vcc != NULL ) {
+ vcc = g_atm_priv_data.conn[conn].vcc;
+
+ if ( vcc->push_oam != NULL )
+ vcc->push_oam(vcc, header);
+ else
+ ifx_push_oam((unsigned char *)header);
+
+ g_atm_priv_data.wrx_oam++;
+
+ adsl_led_flash();
+ } else
+ g_atm_priv_data.wrx_drop_oam++;
+
+ reg_desc.byteoff = 0;
+ reg_desc.datalen = RX_DMA_CH_OAM_BUF_SIZE;
+ reg_desc.own = 1;
+ reg_desc.c = 0;
+
+ g_atm_priv_data.oam_desc[g_atm_priv_data.oam_desc_pos] = reg_desc;
+ if ( ++g_atm_priv_data.oam_desc_pos == RX_DMA_CH_OAM_DESC_LEN )
+ g_atm_priv_data.oam_desc_pos = 0;
+
+ dma_cache_inv((unsigned long)header, CELL_SIZE);
+ mailbox_signal(RX_DMA_CH_OAM, 0);
+ }
+}
+
+static inline void mailbox_aal_rx_handler(void)
+{
+ unsigned int vlddes = WRX_DMA_CHANNEL_CONFIG(RX_DMA_CH_AAL)->vlddes;
+ struct rx_descriptor reg_desc;
+ int conn;
+ struct atm_vcc *vcc;
+ struct sk_buff *skb, *new_skb;
+ struct rx_inband_trailer *trailer;
+ unsigned int i;
+
+ for ( i = 0; i < vlddes; i++ ) {
+ unsigned int loop_count = 0;
+
+ do {
+ reg_desc = g_atm_priv_data.aal_desc[g_atm_priv_data.aal_desc_pos];
+ if ( ++loop_count == 1000 )
+ break;
+ } while ( reg_desc.own || !reg_desc.c ); // keep test OWN and C bit until data is ready
+ ASSERT(loop_count == 1, "loop_count = %u, own = %d, c = %d, aal_desc_pos = %u", loop_count, (int)reg_desc.own, (int)reg_desc.c, g_atm_priv_data.aal_desc_pos);
+
+ conn = reg_desc.id;
+
+ if ( g_atm_priv_data.conn[conn].vcc != NULL ) {
+ vcc = g_atm_priv_data.conn[conn].vcc;
+
+ skb = get_skb_rx_pointer(reg_desc.dataptr);
+
+ if ( reg_desc.err ) {
+ if ( vcc->qos.aal == ATM_AAL5 ) {
+ trailer = (struct rx_inband_trailer *)((unsigned int)skb->data + ((reg_desc.byteoff + reg_desc.datalen + MAX_RX_PACKET_PADDING_BYTES) & ~MAX_RX_PACKET_PADDING_BYTES));
+ if ( trailer->stw_crc )
+ g_atm_priv_data.conn[conn].aal5_vcc_crc_err++;
+ if ( trailer->stw_ovz )
+ g_atm_priv_data.conn[conn].aal5_vcc_oversize_sdu++;
+ g_atm_priv_data.wrx_drop_pdu++;
+ }
+ if ( vcc->stats ) {
+ atomic_inc(&vcc->stats->rx_drop);
+ atomic_inc(&vcc->stats->rx_err);
+ }
+ reg_desc.err = 0;
+ } else if ( atm_charge(vcc, skb->truesize) ) {
+ new_skb = alloc_skb_rx();
+ if ( new_skb != NULL ) {
+#if defined(ENABLE_LESS_CACHE_INV) && ENABLE_LESS_CACHE_INV
+ if ( reg_desc.byteoff + reg_desc.datalen > LESS_CACHE_INV_LEN )
+ dma_cache_inv((unsigned long)skb->data + LESS_CACHE_INV_LEN, reg_desc.byteoff + reg_desc.datalen - LESS_CACHE_INV_LEN);
+#endif
+
+ skb_reserve(skb, reg_desc.byteoff);
+ skb_put(skb, reg_desc.datalen);
+ ATM_SKB(skb)->vcc = vcc;
+
+ vcc->push(vcc, skb);
+
+ if ( vcc->qos.aal == ATM_AAL5 )
+ g_atm_priv_data.wrx_pdu++;
+ if ( vcc->stats )
+ atomic_inc(&vcc->stats->rx);
+ adsl_led_flash();
+
+ reg_desc.dataptr = (unsigned int)new_skb->data >> 2;
+ } else {
+ atm_return(vcc, skb->truesize);
+ if ( vcc->qos.aal == ATM_AAL5 )
+ g_atm_priv_data.wrx_drop_pdu++;
+ if ( vcc->stats )
+ atomic_inc(&vcc->stats->rx_drop);
+ }
+ } else {
+ if ( vcc->qos.aal == ATM_AAL5 )
+ g_atm_priv_data.wrx_drop_pdu++;
+ if ( vcc->stats )
+ atomic_inc(&vcc->stats->rx_drop);
+ }
+ } else {
+ g_atm_priv_data.wrx_drop_pdu++;
+ }
+
+ reg_desc.byteoff = 0;
+ reg_desc.datalen = RX_DMA_CH_AAL_BUF_SIZE;
+ reg_desc.own = 1;
+ reg_desc.c = 0;
+
+ g_atm_priv_data.aal_desc[g_atm_priv_data.aal_desc_pos] = reg_desc;
+ if ( ++g_atm_priv_data.aal_desc_pos == dma_rx_descriptor_length )
+ g_atm_priv_data.aal_desc_pos = 0;
+
+ mailbox_signal(RX_DMA_CH_AAL, 0);
+ }
+}
+
+static irqreturn_t mailbox_irq_handler(int irq, void *dev_id)
+{
+ if ( !*MBOX_IGU1_ISR )
+ return IRQ_HANDLED;
+
+ *MBOX_IGU1_ISRC = *MBOX_IGU1_ISR;
+ mailbox_oam_rx_handler();
+ mailbox_aal_rx_handler();
+
+ return IRQ_HANDLED;
+}
+
+static inline void mailbox_signal(unsigned int queue, int is_tx)
+{
+ int count = 1000;
+
+ if ( is_tx ) {
+ while ( MBOX_IGU3_ISR_ISR(queue + FIRST_QSB_QID + 16) && count > 0 )
+ count--;
+ *MBOX_IGU3_ISRS = MBOX_IGU3_ISRS_SET(queue + FIRST_QSB_QID + 16);
+ } else {
+ while ( MBOX_IGU3_ISR_ISR(queue) && count > 0 )
+ count--;
+ *MBOX_IGU3_ISRS = MBOX_IGU3_ISRS_SET(queue);
+ }
+
+ ASSERT(count > 0, "queue = %u, is_tx = %d, MBOX_IGU3_ISR = 0x%08x", queue, is_tx, IFX_REG_R32(MBOX_IGU3_ISR));
+}
+
+static void set_qsb(struct atm_vcc *vcc, struct atm_qos *qos, unsigned int queue)
+{
+ struct clk *fpi_clk = clk_get_fpi();
+ unsigned int qsb_clk = clk_get_rate(fpi_clk);
+ unsigned int qsb_qid = queue + FIRST_QSB_QID;
+ union qsb_queue_parameter_table qsb_queue_parameter_table = {{0}};
+ union qsb_queue_vbr_parameter_table qsb_queue_vbr_parameter_table = {{0}};
+ unsigned int tmp;
+
+
+ /*
+ * Peak Cell Rate (PCR) Limiter
+ */
+ if ( qos->txtp.max_pcr == 0 )
+ qsb_queue_parameter_table.bit.tp = 0; /* disable PCR limiter */
+ else {
+ /* peak cell rate would be slightly lower than requested [maximum_rate / pcr = (qsb_clock / 8) * (time_step / 4) / pcr] */
+ tmp = ((qsb_clk * qsb_tstep) >> 5) / qos->txtp.max_pcr + 1;
+ /* check if overflow takes place */
+ qsb_queue_parameter_table.bit.tp = tmp > QSB_TP_TS_MAX ? QSB_TP_TS_MAX : tmp;
+ }
+
+#if !defined(DISABLE_QOS_WORKAROUND) || !DISABLE_QOS_WORKAROUND
+ // A funny issue. Create two PVCs, one UBR and one UBR with max_pcr.
+ // Send packets to these two PVCs at same time, it trigger strange behavior.
+ // In A1, RAM from 0x80000000 to 0x0x8007FFFF was corrupted with fixed pattern 0x00000000 0x40000000.
+ // In A4, PPE firmware keep emiting unknown cell and do not respond to driver.
+ // To work around, create UBR always with max_pcr.
+ // If user want to create UBR without max_pcr, we give a default one larger than line-rate.
+ if ( qos->txtp.traffic_class == ATM_UBR && qsb_queue_parameter_table.bit.tp == 0 ) {
+ int port = g_atm_priv_data.conn[queue].port;
+ unsigned int max_pcr = g_atm_priv_data.port[port].tx_max_cell_rate + 1000;
+
+ tmp = ((qsb_clk * qsb_tstep) >> 5) / max_pcr + 1;
+ if ( tmp > QSB_TP_TS_MAX )
+ tmp = QSB_TP_TS_MAX;
+ else if ( tmp < 1 )
+ tmp = 1;
+ qsb_queue_parameter_table.bit.tp = tmp;
+ }
+#endif
+
+ /*
+ * Weighted Fair Queueing Factor (WFQF)
+ */
+ switch ( qos->txtp.traffic_class ) {
+ case ATM_CBR:
+ case ATM_VBR_RT:
+ /* real time queue gets weighted fair queueing bypass */
+ qsb_queue_parameter_table.bit.wfqf = 0;
+ break;
+ case ATM_VBR_NRT:
+ case ATM_UBR_PLUS:
+ /* WFQF calculation here is based on virtual cell rates, to reduce granularity for high rates */
+ /* WFQF is maximum cell rate / garenteed cell rate */
+ /* wfqf = qsb_minimum_cell_rate * QSB_WFQ_NONUBR_MAX / requested_minimum_peak_cell_rate */
+ if ( qos->txtp.min_pcr == 0 )
+ qsb_queue_parameter_table.bit.wfqf = QSB_WFQ_NONUBR_MAX;
+ else {
+ tmp = QSB_GCR_MIN * QSB_WFQ_NONUBR_MAX / qos->txtp.min_pcr;
+ if ( tmp == 0 )
+ qsb_queue_parameter_table.bit.wfqf = 1;
+ else if ( tmp > QSB_WFQ_NONUBR_MAX )
+ qsb_queue_parameter_table.bit.wfqf = QSB_WFQ_NONUBR_MAX;
+ else
+ qsb_queue_parameter_table.bit.wfqf = tmp;
+ }
+ break;
+ default:
+ case ATM_UBR:
+ qsb_queue_parameter_table.bit.wfqf = QSB_WFQ_UBR_BYPASS;
+ }
+
+ /*
+ * Sustained Cell Rate (SCR) Leaky Bucket Shaper VBR.0/VBR.1
+ */
+ if ( qos->txtp.traffic_class == ATM_VBR_RT || qos->txtp.traffic_class == ATM_VBR_NRT ) {
+ if ( qos->txtp.scr == 0 ) {
+ /* disable shaper */
+ qsb_queue_vbr_parameter_table.bit.taus = 0;
+ qsb_queue_vbr_parameter_table.bit.ts = 0;
+ } else {
+ /* Cell Loss Priority (CLP) */
+ if ( (vcc->atm_options & ATM_ATMOPT_CLP) )
+ /* CLP1 */
+ qsb_queue_parameter_table.bit.vbr = 1;
+ else
+ /* CLP0 */
+ qsb_queue_parameter_table.bit.vbr = 0;
+ /* Rate Shaper Parameter (TS) and Burst Tolerance Parameter for SCR (tauS) */
+ tmp = ((qsb_clk * qsb_tstep) >> 5) / qos->txtp.scr + 1;
+ qsb_queue_vbr_parameter_table.bit.ts = tmp > QSB_TP_TS_MAX ? QSB_TP_TS_MAX : tmp;
+ tmp = (qos->txtp.mbs - 1) * (qsb_queue_vbr_parameter_table.bit.ts - qsb_queue_parameter_table.bit.tp) / 64;
+ if ( tmp == 0 )
+ qsb_queue_vbr_parameter_table.bit.taus = 1;
+ else if ( tmp > QSB_TAUS_MAX )
+ qsb_queue_vbr_parameter_table.bit.taus = QSB_TAUS_MAX;
+ else
+ qsb_queue_vbr_parameter_table.bit.taus = tmp;
+ }
+ } else {
+ qsb_queue_vbr_parameter_table.bit.taus = 0;
+ qsb_queue_vbr_parameter_table.bit.ts = 0;
+ }
+
+ /* Queue Parameter Table (QPT) */
+ *QSB_RTM = QSB_RTM_DM_SET(QSB_QPT_SET_MASK);
+ *QSB_RTD = QSB_RTD_TTV_SET(qsb_queue_parameter_table.dword);
+ *QSB_RAMAC = QSB_RAMAC_RW_SET(QSB_RAMAC_RW_WRITE) | QSB_RAMAC_TSEL_SET(QSB_RAMAC_TSEL_QPT) | QSB_RAMAC_LH_SET(QSB_RAMAC_LH_LOW) | QSB_RAMAC_TESEL_SET(qsb_qid);
+ /* Queue VBR Paramter Table (QVPT) */
+ *QSB_RTM = QSB_RTM_DM_SET(QSB_QVPT_SET_MASK);
+ *QSB_RTD = QSB_RTD_TTV_SET(qsb_queue_vbr_parameter_table.dword);
+ *QSB_RAMAC = QSB_RAMAC_RW_SET(QSB_RAMAC_RW_WRITE) | QSB_RAMAC_TSEL_SET(QSB_RAMAC_TSEL_VBR) | QSB_RAMAC_LH_SET(QSB_RAMAC_LH_LOW) | QSB_RAMAC_TESEL_SET(qsb_qid);
+
+}
+
+static void qsb_global_set(void)
+{
+ struct clk *fpi_clk = clk_get_fpi();
+ unsigned int qsb_clk = clk_get_rate(fpi_clk);
+ int i;
+ unsigned int tmp1, tmp2, tmp3;
+
+ *QSB_ICDV = QSB_ICDV_TAU_SET(qsb_tau);
+ *QSB_SBL = QSB_SBL_SBL_SET(qsb_srvm);
+ *QSB_CFG = QSB_CFG_TSTEPC_SET(qsb_tstep >> 1);
+
+ /*
+ * set SCT and SPT per port
+ */
+ for ( i = 0; i < ATM_PORT_NUMBER; i++ ) {
+ if ( g_atm_priv_data.port[i].tx_max_cell_rate != 0 ) {
+ tmp1 = ((qsb_clk * qsb_tstep) >> 1) / g_atm_priv_data.port[i].tx_max_cell_rate;
+ tmp2 = tmp1 >> 6; /* integer value of Tsb */
+ tmp3 = (tmp1 & ((1 << 6) - 1)) + 1; /* fractional part of Tsb */
+ /* carry over to integer part (?) */
+ if ( tmp3 == (1 << 6) ) {
+ tmp3 = 0;
+ tmp2++;
+ }
+ if ( tmp2 == 0 )
+ tmp2 = tmp3 = 1;
+ /* 1. set mask */
+ /* 2. write value to data transfer register */
+ /* 3. start the tranfer */
+ /* SCT (FracRate) */
+ *QSB_RTM = QSB_RTM_DM_SET(QSB_SET_SCT_MASK);
+ *QSB_RTD = QSB_RTD_TTV_SET(tmp3);
+ *QSB_RAMAC = QSB_RAMAC_RW_SET(QSB_RAMAC_RW_WRITE) |
+ QSB_RAMAC_TSEL_SET(QSB_RAMAC_TSEL_SCT) |
+ QSB_RAMAC_LH_SET(QSB_RAMAC_LH_LOW) |
+ QSB_RAMAC_TESEL_SET(i & 0x01);
+ /* SPT (SBV + PN + IntRage) */
+ *QSB_RTM = QSB_RTM_DM_SET(QSB_SET_SPT_MASK);
+ *QSB_RTD = QSB_RTD_TTV_SET(QSB_SPT_SBV_VALID | QSB_SPT_PN_SET(i & 0x01) | QSB_SPT_INTRATE_SET(tmp2));
+ *QSB_RAMAC = QSB_RAMAC_RW_SET(QSB_RAMAC_RW_WRITE) |
+ QSB_RAMAC_TSEL_SET(QSB_RAMAC_TSEL_SPT) |
+ QSB_RAMAC_LH_SET(QSB_RAMAC_LH_LOW) |
+ QSB_RAMAC_TESEL_SET(i & 0x01);
+ }
+ }
+}
+
+static inline void set_htu_entry(unsigned int vpi, unsigned int vci, unsigned int queue, int aal5, int is_retx)
+{
+ struct htu_entry htu_entry = {
+ res1: 0x00,
+ clp: is_retx ? 0x01 : 0x00,
+ pid: g_atm_priv_data.conn[queue].port & 0x01,
+ vpi: vpi,
+ vci: vci,
+ pti: 0x00,
+ vld: 0x01};
+
+ struct htu_mask htu_mask = {
+ set: 0x01,
+ clp: 0x01,
+ pid_mask: 0x02,
+ vpi_mask: 0x00,
+ vci_mask: 0x0000,
+ pti_mask: 0x03, // 0xx, user data
+ clear: 0x00};
+
+ struct htu_result htu_result = {
+ res1: 0x00,
+ cellid: queue,
+ res2: 0x00,
+ type: aal5 ? 0x00 : 0x01,
+ ven: 0x01,
+ res3: 0x00,
+ qid: queue};
+
+ *HTU_RESULT(queue + OAM_HTU_ENTRY_NUMBER) = htu_result;
+ *HTU_MASK(queue + OAM_HTU_ENTRY_NUMBER) = htu_mask;
+ *HTU_ENTRY(queue + OAM_HTU_ENTRY_NUMBER) = htu_entry;
+}
+
+static inline void clear_htu_entry(unsigned int queue)
+{
+ HTU_ENTRY(queue + OAM_HTU_ENTRY_NUMBER)->vld = 0;
+}
+
+static void validate_oam_htu_entry(void)
+{
+ HTU_ENTRY(OAM_F4_SEG_HTU_ENTRY)->vld = 1;
+ HTU_ENTRY(OAM_F4_TOT_HTU_ENTRY)->vld = 1;
+ HTU_ENTRY(OAM_F5_HTU_ENTRY)->vld = 1;
+}
+
+static void invalidate_oam_htu_entry(void)
+{
+ HTU_ENTRY(OAM_F4_SEG_HTU_ENTRY)->vld = 0;
+ HTU_ENTRY(OAM_F4_TOT_HTU_ENTRY)->vld = 0;
+ HTU_ENTRY(OAM_F5_HTU_ENTRY)->vld = 0;
+}
+
+static inline int find_vpi(unsigned int vpi)
+{
+ int i;
+ unsigned int bit;
+
+ for ( i = 0, bit = 1; i < MAX_PVC_NUMBER; i++, bit <<= 1 ) {
+ if ( (g_atm_priv_data.conn_table & bit) != 0
+ && g_atm_priv_data.conn[i].vcc != NULL
+ && vpi == g_atm_priv_data.conn[i].vcc->vpi )
+ return i;
+ }
+
+ return -1;
+}
+
+static inline int find_vpivci(unsigned int vpi, unsigned int vci)
+{
+ int i;
+ unsigned int bit;
+
+ for ( i = 0, bit = 1; i < MAX_PVC_NUMBER; i++, bit <<= 1 ) {
+ if ( (g_atm_priv_data.conn_table & bit) != 0
+ && g_atm_priv_data.conn[i].vcc != NULL
+ && vpi == g_atm_priv_data.conn[i].vcc->vpi
+ && vci == g_atm_priv_data.conn[i].vcc->vci )
+ return i;
+ }
+
+ return -1;
+}
+
+static inline int find_vcc(struct atm_vcc *vcc)
+{
+ int i;
+ unsigned int bit;
+
+ for ( i = 0, bit = 1; i < MAX_PVC_NUMBER; i++, bit <<= 1 ) {
+ if ( (g_atm_priv_data.conn_table & bit) != 0
+ && g_atm_priv_data.conn[i].vcc == vcc )
+ return i;
+ }
+
+ return -1;
+}
+
+static inline int ifx_atm_version(const struct ltq_atm_ops *ops, char *buf)
+{
+ int len = 0;
+ unsigned int major, minor;
+
+ ops->fw_ver(&major, &minor);
+
+ len += sprintf(buf + len, "ATM%d.%d.%d", IFX_ATM_VER_MAJOR, IFX_ATM_VER_MID, IFX_ATM_VER_MINOR);
+ len += sprintf(buf + len, " ATM (A1) firmware version %d.%d\n", major, minor);
+
+ return len;
+}
+
+static inline void check_parameters(void)
+{
+ /* Please refer to Amazon spec 15.4 for setting these values. */
+ if ( qsb_tau < 1 )
+ qsb_tau = 1;
+ if ( qsb_tstep < 1 )
+ qsb_tstep = 1;
+ else if ( qsb_tstep > 4 )
+ qsb_tstep = 4;
+ else if ( qsb_tstep == 3 )
+ qsb_tstep = 2;
+
+ /* There is a delay between PPE write descriptor and descriptor is */
+ /* really stored in memory. Host also has this delay when writing */
+ /* descriptor. So PPE will use this value to determine if the write */
+ /* operation makes effect. */
+ if ( write_descriptor_delay < 0 )
+ write_descriptor_delay = 0;
+
+ if ( aal5_fill_pattern < 0 )
+ aal5_fill_pattern = 0;
+ else
+ aal5_fill_pattern &= 0xFF;
+
+ /* Because of the limitation of length field in descriptors, the packet */
+ /* size could not be larger than 64K minus overhead size. */
+ if ( aal5r_max_packet_size < 0 )
+ aal5r_max_packet_size = 0;
+ else if ( aal5r_max_packet_size >= 65535 - MAX_RX_FRAME_EXTRA_BYTES )
+ aal5r_max_packet_size = 65535 - MAX_RX_FRAME_EXTRA_BYTES;
+ if ( aal5r_min_packet_size < 0 )
+ aal5r_min_packet_size = 0;
+ else if ( aal5r_min_packet_size > aal5r_max_packet_size )
+ aal5r_min_packet_size = aal5r_max_packet_size;
+ if ( aal5s_max_packet_size < 0 )
+ aal5s_max_packet_size = 0;
+ else if ( aal5s_max_packet_size >= 65535 - MAX_TX_FRAME_EXTRA_BYTES )
+ aal5s_max_packet_size = 65535 - MAX_TX_FRAME_EXTRA_BYTES;
+ if ( aal5s_min_packet_size < 0 )
+ aal5s_min_packet_size = 0;
+ else if ( aal5s_min_packet_size > aal5s_max_packet_size )
+ aal5s_min_packet_size = aal5s_max_packet_size;
+
+ if ( dma_rx_descriptor_length < 2 )
+ dma_rx_descriptor_length = 2;
+ if ( dma_tx_descriptor_length < 2 )
+ dma_tx_descriptor_length = 2;
+ if ( dma_rx_clp1_descriptor_threshold < 0 )
+ dma_rx_clp1_descriptor_threshold = 0;
+ else if ( dma_rx_clp1_descriptor_threshold > dma_rx_descriptor_length )
+ dma_rx_clp1_descriptor_threshold = dma_rx_descriptor_length;
+
+ if ( dma_tx_descriptor_length < 2 )
+ dma_tx_descriptor_length = 2;
+}
+
+static inline int init_priv_data(void)
+{
+ void *p;
+ int i;
+ struct rx_descriptor rx_desc = {0};
+ struct sk_buff *skb;
+ volatile struct tx_descriptor *p_tx_desc;
+ struct sk_buff **ppskb;
+
+ // clear atm private data structure
+ memset(&g_atm_priv_data, 0, sizeof(g_atm_priv_data));
+
+ // allocate memory for RX (AAL) descriptors
+ p = kzalloc(dma_rx_descriptor_length * sizeof(struct rx_descriptor) + DESC_ALIGNMENT, GFP_KERNEL);
+ if ( p == NULL )
+ return -1;
+ dma_cache_wback_inv((unsigned long)p, dma_rx_descriptor_length * sizeof(struct rx_descriptor) + DESC_ALIGNMENT);
+ g_atm_priv_data.aal_desc_base = p;
+ p = (void *)((((unsigned int)p + DESC_ALIGNMENT - 1) & ~(DESC_ALIGNMENT - 1)) | KSEG1);
+ g_atm_priv_data.aal_desc = (volatile struct rx_descriptor *)p;
+
+ // allocate memory for RX (OAM) descriptors
+ p = kzalloc(RX_DMA_CH_OAM_DESC_LEN * sizeof(struct rx_descriptor) + DESC_ALIGNMENT, GFP_KERNEL);
+ if ( p == NULL )
+ return -1;
+ dma_cache_wback_inv((unsigned long)p, RX_DMA_CH_OAM_DESC_LEN * sizeof(struct rx_descriptor) + DESC_ALIGNMENT);
+ g_atm_priv_data.oam_desc_base = p;
+ p = (void *)((((unsigned int)p + DESC_ALIGNMENT - 1) & ~(DESC_ALIGNMENT - 1)) | KSEG1);
+ g_atm_priv_data.oam_desc = (volatile struct rx_descriptor *)p;
+
+ // allocate memory for RX (OAM) buffer
+ p = kzalloc(RX_DMA_CH_OAM_DESC_LEN * RX_DMA_CH_OAM_BUF_SIZE + DATA_BUFFER_ALIGNMENT, GFP_KERNEL);
+ if ( p == NULL )
+ return -1;
+ dma_cache_wback_inv((unsigned long)p, RX_DMA_CH_OAM_DESC_LEN * RX_DMA_CH_OAM_BUF_SIZE + DATA_BUFFER_ALIGNMENT);
+ g_atm_priv_data.oam_buf_base = p;
+ p = (void *)(((unsigned int)p + DATA_BUFFER_ALIGNMENT - 1) & ~(DATA_BUFFER_ALIGNMENT - 1));
+ g_atm_priv_data.oam_buf = p;
+
+ // allocate memory for TX descriptors
+ p = kzalloc(MAX_PVC_NUMBER * dma_tx_descriptor_length * sizeof(struct tx_descriptor) + DESC_ALIGNMENT, GFP_KERNEL);
+ if ( p == NULL )
+ return -1;
+ dma_cache_wback_inv((unsigned long)p, MAX_PVC_NUMBER * dma_tx_descriptor_length * sizeof(struct tx_descriptor) + DESC_ALIGNMENT);
+ g_atm_priv_data.tx_desc_base = p;
+
+ // allocate memory for TX skb pointers
+ p = kzalloc(MAX_PVC_NUMBER * dma_tx_descriptor_length * sizeof(struct sk_buff *) + 4, GFP_KERNEL);
+ if ( p == NULL )
+ return -1;
+ dma_cache_wback_inv((unsigned long)p, MAX_PVC_NUMBER * dma_tx_descriptor_length * sizeof(struct sk_buff *) + 4);
+ g_atm_priv_data.tx_skb_base = p;
+
+ // setup RX (AAL) descriptors
+ rx_desc.own = 1;
+ rx_desc.c = 0;
+ rx_desc.sop = 1;
+ rx_desc.eop = 1;
+ rx_desc.byteoff = 0;
+ rx_desc.id = 0;
+ rx_desc.err = 0;
+ rx_desc.datalen = RX_DMA_CH_AAL_BUF_SIZE;
+ for ( i = 0; i < dma_rx_descriptor_length; i++ ) {
+ skb = alloc_skb_rx();
+ if ( skb == NULL )
+ return -1;
+ rx_desc.dataptr = ((unsigned int)skb->data >> 2) & 0x0FFFFFFF;
+ g_atm_priv_data.aal_desc[i] = rx_desc;
+ }
+
+ // setup RX (OAM) descriptors
+ p = (void *)((unsigned int)g_atm_priv_data.oam_buf | KSEG1);
+ rx_desc.own = 1;
+ rx_desc.c = 0;
+ rx_desc.sop = 1;
+ rx_desc.eop = 1;
+ rx_desc.byteoff = 0;
+ rx_desc.id = 0;
+ rx_desc.err = 0;
+ rx_desc.datalen = RX_DMA_CH_OAM_BUF_SIZE;
+ for ( i = 0; i < RX_DMA_CH_OAM_DESC_LEN; i++ ) {
+ rx_desc.dataptr = ((unsigned int)p >> 2) & 0x0FFFFFFF;
+ g_atm_priv_data.oam_desc[i] = rx_desc;
+ p = (void *)((unsigned int)p + RX_DMA_CH_OAM_BUF_SIZE);
+ }
+
+ // setup TX descriptors and skb pointers
+ p_tx_desc = (volatile struct tx_descriptor *)((((unsigned int)g_atm_priv_data.tx_desc_base + DESC_ALIGNMENT - 1) & ~(DESC_ALIGNMENT - 1)) | KSEG1);
+ ppskb = (struct sk_buff **)(((unsigned int)g_atm_priv_data.tx_skb_base + 3) & ~3);
+ for ( i = 0; i < MAX_PVC_NUMBER; i++ ) {
+ g_atm_priv_data.conn[i].tx_desc = &p_tx_desc[i * dma_tx_descriptor_length];
+ g_atm_priv_data.conn[i].tx_skb = &ppskb[i * dma_tx_descriptor_length];
+ }
+
+ for ( i = 0; i < ATM_PORT_NUMBER; i++ )
+ g_atm_priv_data.port[i].tx_max_cell_rate = DEFAULT_TX_LINK_RATE;
+
+ return 0;
+}
+
+static inline void clear_priv_data(void)
+{
+ int i, j;
+ struct sk_buff *skb;
+
+ for ( i = 0; i < MAX_PVC_NUMBER; i++ ) {
+ if ( g_atm_priv_data.conn[i].tx_skb != NULL ) {
+ for ( j = 0; j < dma_tx_descriptor_length; j++ )
+ if ( g_atm_priv_data.conn[i].tx_skb[j] != NULL )
+ dev_kfree_skb_any(g_atm_priv_data.conn[i].tx_skb[j]);
+ }
+ }
+
+ if ( g_atm_priv_data.tx_skb_base != NULL )
+ kfree(g_atm_priv_data.tx_skb_base);
+
+ if ( g_atm_priv_data.tx_desc_base != NULL )
+ kfree(g_atm_priv_data.tx_desc_base);
+
+ if ( g_atm_priv_data.oam_buf_base != NULL )
+ kfree(g_atm_priv_data.oam_buf_base);
+
+ if ( g_atm_priv_data.oam_desc_base != NULL )
+ kfree(g_atm_priv_data.oam_desc_base);
+
+ if ( g_atm_priv_data.aal_desc_base != NULL ) {
+ for ( i = 0; i < dma_rx_descriptor_length; i++ ) {
+ if ( g_atm_priv_data.aal_desc[i].sop || g_atm_priv_data.aal_desc[i].eop ) { // descriptor initialized
+ skb = get_skb_rx_pointer(g_atm_priv_data.aal_desc[i].dataptr);
+ dev_kfree_skb_any(skb);
+ }
+ }
+ kfree(g_atm_priv_data.aal_desc_base);
+ }
+}
+
+static inline void init_rx_tables(void)
+{
+ int i;
+ struct wrx_queue_config wrx_queue_config = {0};
+ struct wrx_dma_channel_config wrx_dma_channel_config = {0};
+ struct htu_entry htu_entry = {0};
+ struct htu_result htu_result = {0};
+ struct htu_mask htu_mask = {
+ set: 0x01,
+ clp: 0x01,
+ pid_mask: 0x00,
+ vpi_mask: 0x00,
+ vci_mask: 0x00,
+ pti_mask: 0x00,
+ clear: 0x00
+ };
+
+ /*
+ * General Registers
+ */
+ *CFG_WRX_HTUTS = MAX_PVC_NUMBER + OAM_HTU_ENTRY_NUMBER;
+#ifndef CONFIG_AMAZON_SE
+ *CFG_WRX_QNUM = MAX_QUEUE_NUMBER;
+#endif
+ *CFG_WRX_DCHNUM = RX_DMA_CH_TOTAL;
+ *WRX_DMACH_ON = (1 << RX_DMA_CH_TOTAL) - 1;
+ *WRX_HUNT_BITTH = DEFAULT_RX_HUNT_BITTH;
+
+ /*
+ * WRX Queue Configuration Table
+ */
+ wrx_queue_config.uumask = 0xFF;
+ wrx_queue_config.cpimask = 0xFF;
+ wrx_queue_config.uuexp = 0;
+ wrx_queue_config.cpiexp = 0;
+ wrx_queue_config.mfs = aal5r_max_packet_size;
+ wrx_queue_config.oversize = aal5r_max_packet_size;
+ wrx_queue_config.undersize = aal5r_min_packet_size;
+ wrx_queue_config.errdp = aal5r_drop_error_packet;
+ wrx_queue_config.dmach = RX_DMA_CH_AAL;
+ for ( i = 0; i < MAX_QUEUE_NUMBER; i++ )
+ *WRX_QUEUE_CONFIG(i) = wrx_queue_config;
+ WRX_QUEUE_CONFIG(OAM_RX_QUEUE)->dmach = RX_DMA_CH_OAM;
+
+ /*
+ * WRX DMA Channel Configuration Table
+ */
+ wrx_dma_channel_config.chrl = 0;
+ wrx_dma_channel_config.clp1th = dma_rx_clp1_descriptor_threshold;
+ wrx_dma_channel_config.mode = 0;
+ wrx_dma_channel_config.rlcfg = 0;
+
+ wrx_dma_channel_config.deslen = RX_DMA_CH_OAM_DESC_LEN;
+ wrx_dma_channel_config.desba = ((unsigned int)g_atm_priv_data.oam_desc >> 2) & 0x0FFFFFFF;
+ *WRX_DMA_CHANNEL_CONFIG(RX_DMA_CH_OAM) = wrx_dma_channel_config;
+
+ wrx_dma_channel_config.deslen = dma_rx_descriptor_length;
+ wrx_dma_channel_config.desba = ((unsigned int)g_atm_priv_data.aal_desc >> 2) & 0x0FFFFFFF;
+ *WRX_DMA_CHANNEL_CONFIG(RX_DMA_CH_AAL) = wrx_dma_channel_config;
+
+ /*
+ * HTU Tables
+ */
+ for (i = 0; i < MAX_PVC_NUMBER; i++) {
+ htu_result.qid = (unsigned int)i;
+
+ *HTU_ENTRY(i + OAM_HTU_ENTRY_NUMBER) = htu_entry;
+ *HTU_MASK(i + OAM_HTU_ENTRY_NUMBER) = htu_mask;
+ *HTU_RESULT(i + OAM_HTU_ENTRY_NUMBER) = htu_result;
+ }
+
+ /* OAM HTU Entry */
+ htu_entry.vci = 0x03;
+ htu_mask.pid_mask = 0x03;
+ htu_mask.vpi_mask = 0xFF;
+ htu_mask.vci_mask = 0x0000;
+ htu_mask.pti_mask = 0x07;
+ htu_result.cellid = OAM_RX_QUEUE;
+ htu_result.type = 1;
+ htu_result.ven = 1;
+ htu_result.qid = OAM_RX_QUEUE;
+ *HTU_RESULT(OAM_F4_SEG_HTU_ENTRY) = htu_result;
+ *HTU_MASK(OAM_F4_SEG_HTU_ENTRY) = htu_mask;
+ *HTU_ENTRY(OAM_F4_SEG_HTU_ENTRY) = htu_entry;
+ htu_entry.vci = 0x04;
+ htu_result.cellid = OAM_RX_QUEUE;
+ htu_result.type = 1;
+ htu_result.ven = 1;
+ htu_result.qid = OAM_RX_QUEUE;
+ *HTU_RESULT(OAM_F4_TOT_HTU_ENTRY) = htu_result;
+ *HTU_MASK(OAM_F4_TOT_HTU_ENTRY) = htu_mask;
+ *HTU_ENTRY(OAM_F4_TOT_HTU_ENTRY) = htu_entry;
+ htu_entry.vci = 0x00;
+ htu_entry.pti = 0x04;
+ htu_mask.vci_mask = 0xFFFF;
+ htu_mask.pti_mask = 0x01;
+ htu_result.cellid = OAM_RX_QUEUE;
+ htu_result.type = 1;
+ htu_result.ven = 1;
+ htu_result.qid = OAM_RX_QUEUE;
+ *HTU_RESULT(OAM_F5_HTU_ENTRY) = htu_result;
+ *HTU_MASK(OAM_F5_HTU_ENTRY) = htu_mask;
+ *HTU_ENTRY(OAM_F5_HTU_ENTRY) = htu_entry;
+}
+
+static inline void init_tx_tables(void)
+{
+ int i;
+ struct wtx_queue_config wtx_queue_config = {0};
+ struct wtx_dma_channel_config wtx_dma_channel_config = {0};
+ struct wtx_port_config wtx_port_config = {
+ res1: 0,
+ qid: 0,
+ qsben: 1
+ };
+
+ /*
+ * General Registers
+ */
+ *CFG_WTX_DCHNUM = MAX_TX_DMA_CHANNEL_NUMBER;
+ *WTX_DMACH_ON = ((1 << MAX_TX_DMA_CHANNEL_NUMBER) - 1) ^ ((1 << FIRST_QSB_QID) - 1);
+ *CFG_WRDES_DELAY = write_descriptor_delay;
+
+ /*
+ * WTX Port Configuration Table
+ */
+ for ( i = 0; i < ATM_PORT_NUMBER; i++ )
+ *WTX_PORT_CONFIG(i) = wtx_port_config;
+
+ /*
+ * WTX Queue Configuration Table
+ */
+ wtx_queue_config.qsben = 1;
+ wtx_queue_config.sbid = 0;
+ for ( i = 0; i < MAX_TX_DMA_CHANNEL_NUMBER; i++ ) {
+ wtx_queue_config.qsb_vcid = i;
+ *WTX_QUEUE_CONFIG(i) = wtx_queue_config;
+ }
+
+ /*
+ * WTX DMA Channel Configuration Table
+ */
+ wtx_dma_channel_config.mode = 0;
+ wtx_dma_channel_config.deslen = 0;
+ wtx_dma_channel_config.desba = 0;
+ for ( i = 0; i < FIRST_QSB_QID; i++ )
+ *WTX_DMA_CHANNEL_CONFIG(i) = wtx_dma_channel_config;
+ /* normal connection */
+ wtx_dma_channel_config.deslen = dma_tx_descriptor_length;
+ for ( ; i < MAX_TX_DMA_CHANNEL_NUMBER ; i++ ) {
+ wtx_dma_channel_config.desba = ((unsigned int)g_atm_priv_data.conn[i - FIRST_QSB_QID].tx_desc >> 2) & 0x0FFFFFFF;
+ *WTX_DMA_CHANNEL_CONFIG(i) = wtx_dma_channel_config;
+ }
+}
+
+static int atm_showtime_enter(struct port_cell_info *port_cell, void *xdata_addr)
+{
+ int i, j;
+
+ ASSERT(port_cell != NULL, "port_cell is NULL");
+ ASSERT(xdata_addr != NULL, "xdata_addr is NULL");
+
+ for ( j = 0; j < ATM_PORT_NUMBER && j < port_cell->port_num; j++ )
+ if ( port_cell->tx_link_rate[j] > 0 )
+ break;
+ for ( i = 0; i < ATM_PORT_NUMBER && i < port_cell->port_num; i++ )
+ g_atm_priv_data.port[i].tx_max_cell_rate =
+ port_cell->tx_link_rate[i] > 0 ? port_cell->tx_link_rate[i] : port_cell->tx_link_rate[j];
+
+ qsb_global_set();
+
+ for ( i = 0; i < MAX_PVC_NUMBER; i++ )
+ if ( g_atm_priv_data.conn[i].vcc != NULL )
+ set_qsb(g_atm_priv_data.conn[i].vcc, &g_atm_priv_data.conn[i].vcc->qos, i);
+
+ // TODO: ReTX set xdata_addr
+ g_xdata_addr = xdata_addr;
+
+ g_showtime = 1;
+
+#if defined(CONFIG_VR9)
+ IFX_REG_W32(0x0F, UTP_CFG);
+#endif
+
+ printk("enter showtime, cell rate: 0 - %d, 1 - %d, xdata addr: 0x%08x\n",
+ g_atm_priv_data.port[0].tx_max_cell_rate,
+ g_atm_priv_data.port[1].tx_max_cell_rate,
+ (unsigned int)g_xdata_addr);
+
+ return 0;
+}
+
+static int atm_showtime_exit(void)
+{
+ if ( !g_showtime )
+ return -1;
+
+#if defined(CONFIG_VR9)
+ IFX_REG_W32(0x00, UTP_CFG);
+#endif
+ g_showtime = 0;
+ g_xdata_addr = NULL;
+ printk("leave showtime\n");
+ return 0;
+}
+
+extern struct ltq_atm_ops ar9_ops;
+extern struct ltq_atm_ops vr9_ops;
+extern struct ltq_atm_ops danube_ops;
+extern struct ltq_atm_ops ase_ops;
+
+static const struct of_device_id ltq_atm_match[] = {
+#ifdef CONFIG_DANUBE
+ { .compatible = "lantiq,ppe-danube", .data = &danube_ops },
+#elif defined CONFIG_AMAZON_SE
+ { .compatible = "lantiq,ppe-ase", .data = &ase_ops },
+#elif defined CONFIG_AR9
+ { .compatible = "lantiq,ppe-arx100", .data = &ar9_ops },
+#elif defined CONFIG_VR9
+ { .compatible = "lantiq,ppe-xrx200", .data = &vr9_ops },
+#endif
+ {},
+};
+MODULE_DEVICE_TABLE(of, ltq_atm_match);
+
+static int ltq_atm_probe(struct platform_device *pdev)
+{
+ const struct of_device_id *match;
+ struct ltq_atm_ops *ops = NULL;
+ int ret;
+ int port_num;
+ struct port_cell_info port_cell = {0};
+ int i, j;
+ char ver_str[256];
+
+ match = of_match_device(ltq_atm_match, &pdev->dev);
+ if (!match) {
+ dev_err(&pdev->dev, "failed to find matching device\n");
+ return -ENOENT;
+ }
+ ops = (struct ltq_atm_ops *) match->data;
+
+ check_parameters();
+
+ ret = init_priv_data();
+ if ( ret != 0 ) {
+ pr_err("INIT_PRIV_DATA_FAIL\n");
+ goto INIT_PRIV_DATA_FAIL;
+ }
+
+ ops->init();
+ init_rx_tables();
+ init_tx_tables();
+
+ /* create devices */
+ for ( port_num = 0; port_num < ATM_PORT_NUMBER; port_num++ ) {
+ g_atm_priv_data.port[port_num].dev = atm_dev_register("ifxmips_atm", NULL, &g_ifx_atm_ops, -1, NULL);
+ if ( !g_atm_priv_data.port[port_num].dev ) {
+ pr_err("failed to register atm device %d!\n", port_num);
+ ret = -EIO;
+ goto ATM_DEV_REGISTER_FAIL;
+ } else {
+ g_atm_priv_data.port[port_num].dev->ci_range.vpi_bits = 8;
+ g_atm_priv_data.port[port_num].dev->ci_range.vci_bits = 16;
+ g_atm_priv_data.port[port_num].dev->link_rate = g_atm_priv_data.port[port_num].tx_max_cell_rate;
+ g_atm_priv_data.port[port_num].dev->dev_data = (void*)port_num;
+ }
+ }
+
+ /* register interrupt handler */
+ ret = request_irq(PPE_MAILBOX_IGU1_INT, mailbox_irq_handler, IRQF_DISABLED, "atm_mailbox_isr", &g_atm_priv_data);
+ if ( ret ) {
+ if ( ret == -EBUSY ) {
+ pr_err("IRQ may be occupied by other driver, please reconfig to disable it.\n");
+ } else {
+ pr_err("request_irq fail irq:%d\n", PPE_MAILBOX_IGU1_INT);
+ }
+ goto REQUEST_IRQ_PPE_MAILBOX_IGU1_INT_FAIL;
+ }
+ disable_irq(PPE_MAILBOX_IGU1_INT);
+
+
+ ret = ops->start(0);
+ if ( ret ) {
+ pr_err("ifx_pp32_start fail!\n");
+ goto PP32_START_FAIL;
+ }
+
+ port_cell.port_num = ATM_PORT_NUMBER;
+ ifx_mei_atm_showtime_check(&g_showtime, &port_cell, &g_xdata_addr);
+ if ( g_showtime ) {
+ for ( i = 0; i < ATM_PORT_NUMBER; i++ )
+ if ( port_cell.tx_link_rate[i] != 0 )
+ break;
+ for ( j = 0; j < ATM_PORT_NUMBER; j++ )
+ g_atm_priv_data.port[j].tx_max_cell_rate =
+ port_cell.tx_link_rate[j] != 0 ? port_cell.tx_link_rate[j] : port_cell.tx_link_rate[i];
+ }
+
+ qsb_global_set();
+ validate_oam_htu_entry();
+
+ ifx_mei_atm_showtime_enter = atm_showtime_enter;
+ ifx_mei_atm_showtime_exit = atm_showtime_exit;
+
+ ifx_atm_version(ops, ver_str);
+ printk(KERN_INFO "%s", ver_str);
+ platform_set_drvdata(pdev, ops);
+ printk("ifxmips_atm: ATM init succeed\n");
+
+ return 0;
+
+PP32_START_FAIL:
+ free_irq(PPE_MAILBOX_IGU1_INT, &g_atm_priv_data);
+REQUEST_IRQ_PPE_MAILBOX_IGU1_INT_FAIL:
+ATM_DEV_REGISTER_FAIL:
+ while ( port_num-- > 0 )
+ atm_dev_deregister(g_atm_priv_data.port[port_num].dev);
+INIT_PRIV_DATA_FAIL:
+ clear_priv_data();
+ printk("ifxmips_atm: ATM init failed\n");
+ return ret;
+}
+
+static int ltq_atm_remove(struct platform_device *pdev)
+{
+ int port_num;
+ struct ltq_atm_ops *ops = platform_get_drvdata(pdev);
+
+ ifx_mei_atm_showtime_enter = NULL;
+ ifx_mei_atm_showtime_exit = NULL;
+
+ invalidate_oam_htu_entry();
+
+ ops->stop(0);
+
+ free_irq(PPE_MAILBOX_IGU1_INT, &g_atm_priv_data);
+
+ for ( port_num = 0; port_num < ATM_PORT_NUMBER; port_num++ )
+ atm_dev_deregister(g_atm_priv_data.port[port_num].dev);
+
+ ops->shutdown();
+
+ clear_priv_data();
+
+ return 0;
+}
+
+static struct platform_driver ltq_atm_driver = {
+ .probe = ltq_atm_probe,
+ .remove = ltq_atm_remove,
+ .driver = {
+ .name = "atm",
+ .owner = THIS_MODULE,
+ .of_match_table = ltq_atm_match,
+ },
+};
+
+module_platform_driver(ltq_atm_driver);
+
+MODULE_LICENSE("Dual BSD/GPL");
diff --git a/package/platform/lantiq/ltq-deu/.svn/entries b/package/platform/lantiq/ltq-deu/.svn/entries
new file mode 100644
index 0000000..5fc3a1e
--- /dev/null
+++ b/package/platform/lantiq/ltq-deu/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/platform/lantiq/ltq-deu
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-14T18:43:07.706647Z
+36021
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+src
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:11.000000Z
+84c4abd7ba5805b98f4b04fc2e6c05ee
+2012-12-15T02:00:05.424603Z
+34689
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1374
+
diff --git a/package/platform/lantiq/ltq-deu/.svn/text-base/Makefile.svn-base b/package/platform/lantiq/ltq-deu/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..4e0d955
--- /dev/null
+++ b/package/platform/lantiq/ltq-deu/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,49 @@
+# Copyright (C) 2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=ltq-deu
+PKG_RELEASE:=1
+PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/ltq-deu-$(BUILD_VARIANT)
+
+PKG_MAINTAINER:=John Crispin <blogic@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/ltq-deu-template
+ SECTION:=sys
+ CATEGORY:=Kernel modules
+ SUBMENU:=Cryptographic API modules
+ TITLE:=deu driver for $(1)
+ URL:=http://www.lantiq.com/
+ VARIANT:=$(1)
+ DEPENDS:=@TARGET_lantiq_xway
+ FILES:=$(PKG_BUILD_DIR)/ltq_deu_$(1).ko $(PKG_BUILD_DIR)/ltq_deu_testmgr.ko
+ AUTOLOAD:=$(call AutoLoad,52,ltq_deu_$(1))
+endef
+
+KernelPackage/ltq-deu-danube=$(call KernelPackage/ltq-deu-template,danube)
+KernelPackage/ltq-deu-ar9=$(call KernelPackage/ltq-deu-template,ar9)
+KernelPackage/ltq-deu-vr9=$(call KernelPackage/ltq-deu-template,vr9)
+
+define Build/Prepare
+ $(INSTALL_DIR) $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+ cd $(LINUX_DIR); \
+ ARCH=mips CROSS_COMPILE="$(KERNEL_CROSS)" \
+ $(MAKE) BUILD_VARIANT=$(BUILD_VARIANT) M=$(PKG_BUILD_DIR) V=1 modules
+endef
+
+$(eval $(call KernelPackage,ltq-deu-danube))
+$(eval $(call KernelPackage,ltq-deu-ar9))
+$(eval $(call KernelPackage,ltq-deu-vr9))
diff --git a/package/platform/lantiq/ltq-deu/Makefile b/package/platform/lantiq/ltq-deu/Makefile
new file mode 100644
index 0000000..4e0d955
--- /dev/null
+++ b/package/platform/lantiq/ltq-deu/Makefile
@@ -0,0 +1,49 @@
+# Copyright (C) 2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=ltq-deu
+PKG_RELEASE:=1
+PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/ltq-deu-$(BUILD_VARIANT)
+
+PKG_MAINTAINER:=John Crispin <blogic@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/ltq-deu-template
+ SECTION:=sys
+ CATEGORY:=Kernel modules
+ SUBMENU:=Cryptographic API modules
+ TITLE:=deu driver for $(1)
+ URL:=http://www.lantiq.com/
+ VARIANT:=$(1)
+ DEPENDS:=@TARGET_lantiq_xway
+ FILES:=$(PKG_BUILD_DIR)/ltq_deu_$(1).ko $(PKG_BUILD_DIR)/ltq_deu_testmgr.ko
+ AUTOLOAD:=$(call AutoLoad,52,ltq_deu_$(1))
+endef
+
+KernelPackage/ltq-deu-danube=$(call KernelPackage/ltq-deu-template,danube)
+KernelPackage/ltq-deu-ar9=$(call KernelPackage/ltq-deu-template,ar9)
+KernelPackage/ltq-deu-vr9=$(call KernelPackage/ltq-deu-template,vr9)
+
+define Build/Prepare
+ $(INSTALL_DIR) $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+ cd $(LINUX_DIR); \
+ ARCH=mips CROSS_COMPILE="$(KERNEL_CROSS)" \
+ $(MAKE) BUILD_VARIANT=$(BUILD_VARIANT) M=$(PKG_BUILD_DIR) V=1 modules
+endef
+
+$(eval $(call KernelPackage,ltq-deu-danube))
+$(eval $(call KernelPackage,ltq-deu-ar9))
+$(eval $(call KernelPackage,ltq-deu-vr9))
diff --git a/package/platform/lantiq/ltq-deu/src/.svn/entries b/package/platform/lantiq/ltq-deu/src/.svn/entries
new file mode 100644
index 0000000..5dbcecd
--- /dev/null
+++ b/package/platform/lantiq/ltq-deu/src/.svn/entries
@@ -0,0 +1,844 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/platform/lantiq/ltq-deu/src
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-14T18:43:07.706647Z
+36021
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+ifxmips_deu_danube.h
+file
+
+
+
+
+2013-03-17T12:13:11.000000Z
+43de405cdb38449b1dbaf6205d35a6be
+2012-12-15T02:00:05.424603Z
+34689
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5279
+
+ltq_deu_testmgr.c
+file
+
+
+
+
+2013-03-17T12:13:11.000000Z
+14273f5cdc25e9fe40a83237065fc33a
+2012-12-15T02:00:05.424603Z
+34689
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+89818
+
+ifxmips_deu_dma.h
+file
+
+
+
+
+2013-03-17T12:13:11.000000Z
+3d6be5651286b37b93e125c4ad3cee99
+2012-12-15T02:00:05.424603Z
+34689
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2118
+
+ifxmips_async_aes.c
+file
+
+
+
+
+2013-03-17T12:13:11.000000Z
+2998836cc6118b1a4d3b1f33e5707dd5
+2012-12-15T02:00:05.424603Z
+34689
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+37451
+
+ifxmips_aes.c
+file
+
+
+
+
+2013-03-17T12:13:11.000000Z
+a37ce9fe846682bd2da10f6051c17589
+2012-12-15T02:00:05.424603Z
+34689
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+31868
+
+ifxmips_async_des.c
+file
+
+
+
+
+2013-03-17T12:13:11.000000Z
+63666400ffee9dab5f82d3274628f15e
+2012-12-15T02:00:05.424603Z
+34689
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+31401
+
+ifxmips_des.c
+file
+
+
+
+
+2013-03-17T12:13:11.000000Z
+37550f25e2ab6bc1f325c73739a007cc
+2012-12-15T02:00:05.424603Z
+34689
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+28259
+
+ifxmips_deu_vr9.c
+file
+
+
+
+
+2013-03-17T12:13:11.000000Z
+817fcac16bf6062ce0e97a40f222a5eb
+2012-12-15T02:00:05.424603Z
+34689
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3567
+
+ifxmips_deu.c
+file
+
+
+
+
+2013-03-17T12:13:11.000000Z
+b257a20f8f24855046fe42b00eb596b3
+2013-03-14T18:43:07.706647Z
+36021
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5372
+
+ifxmips_md5_hmac.c
+file
+
+
+
+
+2013-03-17T12:13:11.000000Z
+3bcd2308b7fcc60fb8655e92a7296f18
+2012-12-15T02:00:05.424603Z
+34689
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+10917
+
+ifxmips_deu_vr9.h
+file
+
+
+
+
+2013-03-17T12:13:11.000000Z
+47c61b400121e1bf4cdee912ccb18350
+2012-12-15T02:00:05.424603Z
+34689
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+6719
+
+ifxmips_deu.h
+file
+
+
+
+
+2013-03-17T12:13:11.000000Z
+a5d4812fda91160c331cf0bfae627b81
+2012-12-15T02:00:05.424603Z
+34689
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+6866
+
+internal.h
+file
+
+
+
+
+2013-03-17T12:13:11.000000Z
+2d3741ff5f6f8ab278fbb1f9097b7ed5
+2012-12-15T02:00:05.424603Z
+34689
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3950
+
+ifxmips_sha1_hmac.c
+file
+
+
+
+
+2013-03-17T12:13:11.000000Z
+24aaf526b64c272796afe93fd385f238
+2012-12-15T02:00:05.424603Z
+34689
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+10432
+
+ifxmips_md5.c
+file
+
+
+
+
+2013-03-17T12:13:11.000000Z
+88b5b7c3ccb8fb4f04d6c6738dfea579
+2012-12-15T02:00:05.424603Z
+34689
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+9005
+
+ifxmips_deu_ar9.c
+file
+
+
+
+
+2013-03-17T12:13:11.000000Z
+417cef4453a65d4a0431d31f2e863943
+2012-12-15T02:00:05.424603Z
+34689
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3359
+
+ifxmips_arc4.c
+file
+
+
+
+
+2013-03-17T12:13:11.000000Z
+a0345e21aa67ac800b8fe276b1b8817e
+2012-12-15T02:00:05.424603Z
+34689
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+13082
+
+ifxmips_testmgr.h
+file
+
+
+
+
+2013-03-17T12:13:11.000000Z
+750f4940d53b65fc635ef0a2ba5dc947
+2012-12-15T02:00:05.424603Z
+34689
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+318869
+
+ifxmips_tcrypt.h
+file
+
+
+
+
+2013-03-17T12:13:11.000000Z
+e9007e184962df9d49b76e5b8d2e4c09
+2012-12-15T02:00:05.424603Z
+34689
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2542
+
+ifxmips_deu_danube.c
+file
+
+
+
+
+2013-03-17T12:13:11.000000Z
+9d84e83bde4036e2f5b27648cd123cf1
+2012-12-15T02:00:05.424603Z
+34689
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4386
+
+ifxmips_sha1.c
+file
+
+
+
+
+2013-03-17T12:13:11.000000Z
+84480c6898b6b2f67aeba928b77f83ea
+2012-12-15T02:00:05.424603Z
+34689
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+8121
+
+ifxmips_deu_ar9.h
+file
+
+
+
+
+2013-03-17T12:13:11.000000Z
+e38b65fb70ac3ef7c3349e52dae32e14
+2012-12-15T02:00:05.424603Z
+34689
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+6145
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:11.000000Z
+671ccee744995d3000ab28f0b3aa42ea
+2012-12-15T02:00:05.424603Z
+34689
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1439
+
+ifxmips_deu_dma.c
+file
+
+
+
+
+2013-03-17T12:13:11.000000Z
+7fbb30e9d2053733ba73b4030c0cf446
+2012-12-15T02:00:05.424603Z
+34689
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1241
+
diff --git a/package/platform/lantiq/ltq-deu/src/.svn/text-base/Makefile.svn-base b/package/platform/lantiq/ltq-deu/src/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..f6cb9c9
--- /dev/null
+++ b/package/platform/lantiq/ltq-deu/src/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,26 @@
+ifeq ($(BUILD_VARIANT),danube)
+ CFLAGS_MODULE =-DCONFIG_DANUBE -DCONFIG_CRYPTO_DEV_DEU -DCONFIG_CRYPTO_DEV_SPEED_TEST -DCONFIG_CRYPTO_DEV_DES \
+ -DCONFIG_CRYPTO_DEV_AES -DCONFIG_CRYPTO_DEV_SHA1 -DCONFIG_CRYPTO_DEV_MD5
+ obj-m = ltq_deu_danube.o
+ ltq_deu_danube-objs = ifxmips_deu.o ifxmips_deu_danube.o ifxmips_des.o ifxmips_aes.o ifxmips_sha1.o ifxmips_md5.o
+endif
+
+ifeq ($(BUILD_VARIANT),ar9)
+ CFLAGS_MODULE = -DCONFIG_AR9 -DCONFIG_CRYPTO_DEV_DEU -DCONFIG_CRYPTO_DEV_SPEED_TEST -DCONFIG_CRYPTO_DEV_DES \
+ -DCONFIG_CRYPTO_DEV_AES -DCONFIG_CRYPTO_DEV_SHA1 -DCONFIG_CRYPTO_DEV_MD5 -DCONFIG_CRYPTO_DEV_ARC4 \
+ -DCONFIG_CRYPTO_DEV_SHA1_HMAC -DCONFIG_CRYPTO_DEV_MD5_HMAC
+ obj-m = ltq_deu_ar9.o
+ ltq_deu_ar9-objs = ifxmips_deu.o ifxmips_deu_ar9.o ifxmips_des.o ifxmips_aes.o ifxmips_arc4.o \
+ ifxmips_sha1.o ifxmips_md5.o ifxmips_sha1_hmac.o ifxmips_md5_hmac.o
+endif
+
+ifeq ($(BUILD_VARIANT),vr9)
+ CFLAGS_MODULE = -DCONFIG_VR9 -DCONFIG_CRYPTO_DEV_DEU -DCONFIG_CRYPTO_DEV_SPEED_TEST -DCONFIG_CRYPTO_DEV_DES \
+ -DCONFIG_CRYPTO_DEV_AES -DCONFIG_CRYPTO_DEV_SHA1 -DCONFIG_CRYPTO_DEV_MD5 -DCONFIG_CRYPTO_DEV_ARC4 \
+ -DCONFIG_CRYPTO_DEV_SHA1_HMAC -DCONFIG_CRYPTO_DEV_MD5_HMAC
+ obj-m = ltq_deu_vr9.o
+ ltq_deu_vr9-objs = ifxmips_deu.o ifxmips_deu_vr9.o ifxmips_des.o ifxmips_aes.o ifxmips_arc4.o \
+ ifxmips_sha1.o ifxmips_md5.o ifxmips_sha1_hmac.o ifxmips_md5_hmac.o
+endif
+
+obj-m += ltq_deu_testmgr.o
diff --git a/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_aes.c.svn-base b/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_aes.c.svn-base
new file mode 100644
index 0000000..bf77537
--- /dev/null
+++ b/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_aes.c.svn-base
@@ -0,0 +1,904 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_aes.c
+** PROJECT : IFX UEIP
+** MODULES : DEU Module
+**
+** DATE : September 8, 2009
+** AUTHOR : Mohammad Firdaus
+** DESCRIPTION : Data Encryption Unit Driver for AES Algorithm
+** COPYRIGHT : Copyright (c) 2009
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 08,Sept 2009 Mohammad Firdaus Initial UEIP release
+*******************************************************************************/
+/*!
+ \defgroup IFX_DEU IFX_DEU_DRIVERS
+ \ingroup API
+ \brief ifx DEU driver module
+*/
+
+/*!
+ \file ifxmips_aes.c
+ \ingroup IFX_DEU
+ \brief AES Encryption Driver main file
+*/
+
+/*!
+ \defgroup IFX_AES_FUNCTIONS IFX_AES_FUNCTIONS
+ \ingroup IFX_DEU
+ \brief IFX AES driver Functions
+*/
+
+
+/* Project Header Files */
+#if defined(CONFIG_MODVERSIONS)
+#define MODVERSIONS
+#include <linux/modeversions>
+#endif
+
+#include <linux/version.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/proc_fs.h>
+#include <linux/fs.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/crypto.h>
+#include <linux/interrupt.h>
+#include <linux/delay.h>
+#include <asm/byteorder.h>
+#include <crypto/algapi.h>
+
+#include "ifxmips_deu.h"
+
+#if defined(CONFIG_DANUBE)
+#include "ifxmips_deu_danube.h"
+extern int ifx_danube_pre_1_4;
+#elif defined(CONFIG_AR9)
+#include "ifxmips_deu_ar9.h"
+#elif defined(CONFIG_VR9) || defined(CONFIG_AR10)
+#include "ifxmips_deu_vr9.h"
+#else
+#error "Unkown platform"
+#endif
+
+/* DMA related header and variables */
+
+spinlock_t aes_lock;
+#define CRTCL_SECT_INIT spin_lock_init(&aes_lock)
+#define CRTCL_SECT_START spin_lock_irqsave(&aes_lock, flag)
+#define CRTCL_SECT_END spin_unlock_irqrestore(&aes_lock, flag)
+
+/* Definition of constants */
+#define AES_START IFX_AES_CON
+#define AES_MIN_KEY_SIZE 16
+#define AES_MAX_KEY_SIZE 32
+#define AES_BLOCK_SIZE 16
+#define CTR_RFC3686_NONCE_SIZE 4
+#define CTR_RFC3686_IV_SIZE 8
+#define CTR_RFC3686_MAX_KEY_SIZE (AES_MAX_KEY_SIZE + CTR_RFC3686_NONCE_SIZE)
+
+#ifdef CRYPTO_DEBUG
+extern char debug_level;
+#define DPRINTF(level, format, args...) if (level < debug_level) printk(KERN_INFO "[%s %s %d]: " format, __FILE__, __func__, __LINE__, ##args);
+#else
+#define DPRINTF(level, format, args...)
+#endif /* CRYPTO_DEBUG */
+
+/* Function decleration */
+int aes_chip_init(void);
+u32 endian_swap(u32 input);
+u32 input_swap(u32 input);
+u32* memory_alignment(const u8 *arg, u32 *buff_alloc, int in_out, int nbytes);
+void aes_dma_memory_copy(u32 *outcopy, u32 *out_dma, u8 *out_arg, int nbytes);
+void des_dma_memory_copy(u32 *outcopy, u32 *out_dma, u8 *out_arg, int nbytes);
+int aes_memory_allocate(int value);
+int des_memory_allocate(int value);
+void memory_release(u32 *addr);
+
+
+extern void ifx_deu_aes (void *ctx_arg, uint8_t *out_arg, const uint8_t *in_arg,
+ uint8_t *iv_arg, size_t nbytes, int encdec, int mode);
+/* End of function decleration */
+
+struct aes_ctx {
+ int key_length;
+ u32 buf[AES_MAX_KEY_SIZE];
+ u8 nonce[CTR_RFC3686_NONCE_SIZE];
+};
+
+extern int disable_deudma;
+extern int disable_multiblock;
+
+/*! \fn int aes_set_key (struct crypto_tfm *tfm, const uint8_t *in_key, unsigned int key_len)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief sets the AES keys
+ * \param tfm linux crypto algo transform
+ * \param in_key input key
+ * \param key_len key lengths of 16, 24 and 32 bytes supported
+ * \return -EINVAL - bad key length, 0 - SUCCESS
+*/
+int aes_set_key (struct crypto_tfm *tfm, const u8 *in_key, unsigned int key_len)
+{
+ struct aes_ctx *ctx = crypto_tfm_ctx(tfm);
+ unsigned long *flags = (unsigned long *) &tfm->crt_flags;
+
+ //printk("set_key in %s\n", __FILE__);
+
+ //aes_chip_init();
+
+ if (key_len != 16 && key_len != 24 && key_len != 32) {
+ *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
+ return -EINVAL;
+ }
+
+ ctx->key_length = key_len;
+ DPRINTF(0, "ctx @%p, key_len %d, ctx->key_length %d\n", ctx, key_len, ctx->key_length);
+ memcpy ((u8 *) (ctx->buf), in_key, key_len);
+
+ return 0;
+}
+
+
+/*! \fn void ifx_deu_aes (void *ctx_arg, u8 *out_arg, const u8 *in_arg, u8 *iv_arg, size_t nbytes, int encdec, int mode)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief main interface to AES hardware
+ * \param ctx_arg crypto algo context
+ * \param out_arg output bytestream
+ * \param in_arg input bytestream
+ * \param iv_arg initialization vector
+ * \param nbytes length of bytestream
+ * \param encdec 1 for encrypt; 0 for decrypt
+ * \param mode operation mode such as ebc, cbc, ctr
+ *
+*/
+void ifx_deu_aes (void *ctx_arg, u8 *out_arg, const u8 *in_arg,
+ u8 *iv_arg, size_t nbytes, int encdec, int mode)
+
+{
+ /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+ volatile struct aes_t *aes = (volatile struct aes_t *) AES_START;
+ struct aes_ctx *ctx = (struct aes_ctx *)ctx_arg;
+ u32 *in_key = ctx->buf;
+ unsigned long flag;
+ /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+ int key_len = ctx->key_length;
+
+ int i = 0;
+ int byte_cnt = nbytes;
+
+
+ CRTCL_SECT_START;
+ /* 128, 192 or 256 bit key length */
+ aes->controlr.K = key_len / 8 - 2;
+ if (key_len == 128 / 8) {
+ aes->K3R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 0));
+ aes->K2R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 1));
+ aes->K1R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 2));
+ aes->K0R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 3));
+ }
+ else if (key_len == 192 / 8) {
+ aes->K5R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 0));
+ aes->K4R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 1));
+ aes->K3R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 2));
+ aes->K2R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 3));
+ aes->K1R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 4));
+ aes->K0R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 5));
+ }
+ else if (key_len == 256 / 8) {
+ aes->K7R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 0));
+ aes->K6R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 1));
+ aes->K5R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 2));
+ aes->K4R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 3));
+ aes->K3R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 4));
+ aes->K2R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 5));
+ aes->K1R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 6));
+ aes->K0R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 7));
+ }
+ else {
+ printk (KERN_ERR "[%s %s %d]: Invalid key_len : %d\n", __FILE__, __func__, __LINE__, key_len);
+ CRTCL_SECT_END;
+ return;// -EINVAL;
+ }
+
+ /* let HW pre-process DEcryption key in any case (even if
+ ENcryption is used). Key Valid (KV) bit is then only
+ checked in decryption routine! */
+ aes->controlr.PNK = 1;
+
+
+ aes->controlr.E_D = !encdec; //encryption
+ aes->controlr.O = mode; //0 ECB 1 CBC 2 OFB 3 CFB 4 CTR
+
+ //aes->controlr.F = 128; //default; only for CFB and OFB modes; change only for customer-specific apps
+ if (mode > 0) {
+ aes->IV3R = DEU_ENDIAN_SWAP(*(u32 *) iv_arg);
+ aes->IV2R = DEU_ENDIAN_SWAP(*((u32 *) iv_arg + 1));
+ aes->IV1R = DEU_ENDIAN_SWAP(*((u32 *) iv_arg + 2));
+ aes->IV0R = DEU_ENDIAN_SWAP(*((u32 *) iv_arg + 3));
+ };
+
+
+ i = 0;
+ while (byte_cnt >= 16) {
+
+ aes->ID3R = INPUT_ENDIAN_SWAP(*((u32 *) in_arg + (i * 4) + 0));
+ aes->ID2R = INPUT_ENDIAN_SWAP(*((u32 *) in_arg + (i * 4) + 1));
+ aes->ID1R = INPUT_ENDIAN_SWAP(*((u32 *) in_arg + (i * 4) + 2));
+ aes->ID0R = INPUT_ENDIAN_SWAP(*((u32 *) in_arg + (i * 4) + 3)); /* start crypto */
+
+ while (aes->controlr.BUS) {
+ // this will not take long
+ }
+
+ *((volatile u32 *) out_arg + (i * 4) + 0) = aes->OD3R;
+ *((volatile u32 *) out_arg + (i * 4) + 1) = aes->OD2R;
+ *((volatile u32 *) out_arg + (i * 4) + 2) = aes->OD1R;
+ *((volatile u32 *) out_arg + (i * 4) + 3) = aes->OD0R;
+
+ i++;
+ byte_cnt -= 16;
+ }
+
+
+ //tc.chen : copy iv_arg back
+ if (mode > 0) {
+ *((u32 *) iv_arg) = DEU_ENDIAN_SWAP(*((u32 *) iv_arg));
+ *((u32 *) iv_arg + 1) = DEU_ENDIAN_SWAP(*((u32 *) iv_arg + 1));
+ *((u32 *) iv_arg + 2) = DEU_ENDIAN_SWAP(*((u32 *) iv_arg + 2));
+ *((u32 *) iv_arg + 3) = DEU_ENDIAN_SWAP(*((u32 *) iv_arg + 3));
+ }
+
+ CRTCL_SECT_END;
+}
+
+/*!
+ * \fn int ctr_rfc3686_aes_set_key (struct crypto_tfm *tfm, const uint8_t *in_key, unsigned int key_len)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief sets RFC3686 key
+ * \param tfm linux crypto algo transform
+ * \param in_key input key
+ * \param key_len key lengths of 20, 28 and 36 bytes supported; last 4 bytes is nonce
+ * \return 0 - SUCCESS
+ * -EINVAL - bad key length
+*/
+int ctr_rfc3686_aes_set_key (struct crypto_tfm *tfm, const uint8_t *in_key, unsigned int key_len)
+{
+ struct aes_ctx *ctx = crypto_tfm_ctx(tfm);
+ unsigned long *flags = (unsigned long *)&tfm->crt_flags;
+
+ //printk("ctr_rfc3686_aes_set_key in %s\n", __FILE__);
+
+ memcpy(ctx->nonce, in_key + (key_len - CTR_RFC3686_NONCE_SIZE),
+ CTR_RFC3686_NONCE_SIZE);
+
+ key_len -= CTR_RFC3686_NONCE_SIZE; // remove 4 bytes of nonce
+
+ if (key_len != 16 && key_len != 24 && key_len != 32) {
+ *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
+ return -EINVAL;
+ }
+
+ ctx->key_length = key_len;
+
+ memcpy ((u8 *) (ctx->buf), in_key, key_len);
+
+ return 0;
+}
+
+/*! \fn void ifx_deu_aes (void *ctx_arg, u8 *out_arg, const u8 *in_arg, u8 *iv_arg, u32 nbytes, int encdec, int mode)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief main interface with deu hardware in DMA mode
+ * \param ctx_arg crypto algo context
+ * \param out_arg output bytestream
+ * \param in_arg input bytestream
+ * \param iv_arg initialization vector
+ * \param nbytes length of bytestream
+ * \param encdec 1 for encrypt; 0 for decrypt
+ * \param mode operation mode such as ebc, cbc, ctr
+*/
+
+
+//definitions from linux/include/crypto.h:
+//#define CRYPTO_TFM_MODE_ECB 0x00000001
+//#define CRYPTO_TFM_MODE_CBC 0x00000002
+//#define CRYPTO_TFM_MODE_CFB 0x00000004
+//#define CRYPTO_TFM_MODE_CTR 0x00000008
+//#define CRYPTO_TFM_MODE_OFB 0x00000010 // not even defined
+//but hardware definition: 0 ECB 1 CBC 2 OFB 3 CFB 4 CTR
+
+/*! \fn void ifx_deu_aes_ecb (void *ctx, uint8_t *dst, const uint8_t *src, uint8_t *iv, size_t nbytes, int encdec, int inplace)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief sets AES hardware to ECB mode
+ * \param ctx crypto algo context
+ * \param dst output bytestream
+ * \param src input bytestream
+ * \param iv initialization vector
+ * \param nbytes length of bytestream
+ * \param encdec 1 for encrypt; 0 for decrypt
+ * \param inplace not used
+*/
+void ifx_deu_aes_ecb (void *ctx, uint8_t *dst, const uint8_t *src,
+ uint8_t *iv, size_t nbytes, int encdec, int inplace)
+{
+ ifx_deu_aes (ctx, dst, src, NULL, nbytes, encdec, 0);
+}
+
+/*! \fn void ifx_deu_aes_cbc (void *ctx, uint8_t *dst, const uint8_t *src, uint8_t *iv, size_t nbytes, int encdec, int inplace)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief sets AES hardware to CBC mode
+ * \param ctx crypto algo context
+ * \param dst output bytestream
+ * \param src input bytestream
+ * \param iv initialization vector
+ * \param nbytes length of bytestream
+ * \param encdec 1 for encrypt; 0 for decrypt
+ * \param inplace not used
+*/
+void ifx_deu_aes_cbc (void *ctx, uint8_t *dst, const uint8_t *src,
+ uint8_t *iv, size_t nbytes, int encdec, int inplace)
+{
+ ifx_deu_aes (ctx, dst, src, iv, nbytes, encdec, 1);
+}
+
+/*! \fn void ifx_deu_aes_ofb (void *ctx, uint8_t *dst, const uint8_t *src, uint8_t *iv, size_t nbytes, int encdec, int inplace)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief sets AES hardware to OFB mode
+ * \param ctx crypto algo context
+ * \param dst output bytestream
+ * \param src input bytestream
+ * \param iv initialization vector
+ * \param nbytes length of bytestream
+ * \param encdec 1 for encrypt; 0 for decrypt
+ * \param inplace not used
+*/
+void ifx_deu_aes_ofb (void *ctx, uint8_t *dst, const uint8_t *src,
+ uint8_t *iv, size_t nbytes, int encdec, int inplace)
+{
+ ifx_deu_aes (ctx, dst, src, iv, nbytes, encdec, 2);
+}
+
+/*! \fn void ifx_deu_aes_cfb (void *ctx, uint8_t *dst, const uint8_t *src, uint8_t *iv, size_t nbytes, int encdec, int inplace)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief sets AES hardware to CFB mode
+ * \param ctx crypto algo context
+ * \param dst output bytestream
+ * \param src input bytestream
+ * \param iv initialization vector
+ * \param nbytes length of bytestream
+ * \param encdec 1 for encrypt; 0 for decrypt
+ * \param inplace not used
+*/
+void ifx_deu_aes_cfb (void *ctx, uint8_t *dst, const uint8_t *src,
+ uint8_t *iv, size_t nbytes, int encdec, int inplace)
+{
+ ifx_deu_aes (ctx, dst, src, iv, nbytes, encdec, 3);
+}
+
+/*! \fn void ifx_deu_aes_ctr (void *ctx, uint8_t *dst, const uint8_t *src, uint8_t *iv, size_t nbytes, int encdec, int inplace)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief sets AES hardware to CTR mode
+ * \param ctx crypto algo context
+ * \param dst output bytestream
+ * \param src input bytestream
+ * \param iv initialization vector
+ * \param nbytes length of bytestream
+ * \param encdec 1 for encrypt; 0 for decrypt
+ * \param inplace not used
+*/
+void ifx_deu_aes_ctr (void *ctx, uint8_t *dst, const uint8_t *src,
+ uint8_t *iv, size_t nbytes, int encdec, int inplace)
+{
+ ifx_deu_aes (ctx, dst, src, iv, nbytes, encdec, 4);
+}
+
+/*! \fn void aes_encrypt (struct crypto_tfm *tfm, uint8_t *out, const uint8_t *in)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief encrypt AES_BLOCK_SIZE of data
+ * \param tfm linux crypto algo transform
+ * \param out output bytestream
+ * \param in input bytestream
+*/
+void aes_encrypt (struct crypto_tfm *tfm, uint8_t *out, const uint8_t *in)
+{
+ struct aes_ctx *ctx = crypto_tfm_ctx(tfm);
+ ifx_deu_aes (ctx, out, in, NULL, AES_BLOCK_SIZE,
+ CRYPTO_DIR_ENCRYPT, 0);
+}
+
+/*! \fn void aes_decrypt (struct crypto_tfm *tfm, uint8_t *out, const uint8_t *in)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief decrypt AES_BLOCK_SIZE of data
+ * \param tfm linux crypto algo transform
+ * \param out output bytestream
+ * \param in input bytestream
+*/
+void aes_decrypt (struct crypto_tfm *tfm, uint8_t *out, const uint8_t *in)
+{
+ struct aes_ctx *ctx = crypto_tfm_ctx(tfm);
+ ifx_deu_aes (ctx, out, in, NULL, AES_BLOCK_SIZE,
+ CRYPTO_DIR_DECRYPT, 0);
+}
+
+/*
+ * \brief AES function mappings
+*/
+struct crypto_alg ifxdeu_aes_alg = {
+ .cra_name = "aes",
+ .cra_driver_name = "ifxdeu-aes",
+ .cra_flags = CRYPTO_ALG_TYPE_CIPHER,
+ .cra_blocksize = AES_BLOCK_SIZE,
+ .cra_ctxsize = sizeof(struct aes_ctx),
+ .cra_module = THIS_MODULE,
+ .cra_list = LIST_HEAD_INIT(ifxdeu_aes_alg.cra_list),
+ .cra_u = {
+ .cipher = {
+ .cia_min_keysize = AES_MIN_KEY_SIZE,
+ .cia_max_keysize = AES_MAX_KEY_SIZE,
+ .cia_setkey = aes_set_key,
+ .cia_encrypt = aes_encrypt,
+ .cia_decrypt = aes_decrypt,
+ }
+ }
+};
+
+/*! \fn int ecb_aes_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief ECB AES encrypt using linux crypto blkcipher
+ * \param desc blkcipher descriptor
+ * \param dst output scatterlist
+ * \param src input scatterlist
+ * \param nbytes data size in bytes
+ * \return err
+*/
+int ecb_aes_encrypt(struct blkcipher_desc *desc,
+ struct scatterlist *dst, struct scatterlist *src,
+ unsigned int nbytes)
+{
+ struct aes_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
+ struct blkcipher_walk walk;
+ int err;
+
+ blkcipher_walk_init(&walk, dst, src, nbytes);
+ err = blkcipher_walk_virt(desc, &walk);
+
+ while ((nbytes = walk.nbytes)) {
+ nbytes -= (nbytes % AES_BLOCK_SIZE);
+ ifx_deu_aes_ecb(ctx, walk.dst.virt.addr, walk.src.virt.addr,
+ NULL, nbytes, CRYPTO_DIR_ENCRYPT, 0);
+ nbytes &= AES_BLOCK_SIZE - 1;
+ err = blkcipher_walk_done(desc, &walk, nbytes);
+ }
+
+ return err;
+}
+
+/*! \fn int ecb_aes_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief ECB AES decrypt using linux crypto blkcipher
+ * \param desc blkcipher descriptor
+ * \param dst output scatterlist
+ * \param src input scatterlist
+ * \param nbytes data size in bytes
+ * \return err
+*/
+int ecb_aes_decrypt(struct blkcipher_desc *desc,
+ struct scatterlist *dst, struct scatterlist *src,
+ unsigned int nbytes)
+{
+ struct aes_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
+ struct blkcipher_walk walk;
+ int err;
+
+ blkcipher_walk_init(&walk, dst, src, nbytes);
+ err = blkcipher_walk_virt(desc, &walk);
+
+ while ((nbytes = walk.nbytes)) {
+ nbytes -= (nbytes % AES_BLOCK_SIZE);
+ ifx_deu_aes_ecb(ctx, walk.dst.virt.addr, walk.src.virt.addr,
+ NULL, nbytes, CRYPTO_DIR_DECRYPT, 0);
+ nbytes &= AES_BLOCK_SIZE - 1;
+ err = blkcipher_walk_done(desc, &walk, nbytes);
+ }
+
+ return err;
+}
+
+/*
+ * \brief AES function mappings
+*/
+struct crypto_alg ifxdeu_ecb_aes_alg = {
+ .cra_name = "ecb(aes)",
+ .cra_driver_name = "ifxdeu-ecb(aes)",
+ .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER,
+ .cra_blocksize = AES_BLOCK_SIZE,
+ .cra_ctxsize = sizeof(struct aes_ctx),
+ .cra_type = &crypto_blkcipher_type,
+ .cra_module = THIS_MODULE,
+ .cra_list = LIST_HEAD_INIT(ifxdeu_ecb_aes_alg.cra_list),
+ .cra_u = {
+ .blkcipher = {
+ .min_keysize = AES_MIN_KEY_SIZE,
+ .max_keysize = AES_MAX_KEY_SIZE,
+ .setkey = aes_set_key,
+ .encrypt = ecb_aes_encrypt,
+ .decrypt = ecb_aes_decrypt,
+ }
+ }
+};
+
+
+/*! \fn int cbc_aes_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief CBC AES encrypt using linux crypto blkcipher
+ * \param desc blkcipher descriptor
+ * \param dst output scatterlist
+ * \param src input scatterlist
+ * \param nbytes data size in bytes
+ * \return err
+*/
+int cbc_aes_encrypt(struct blkcipher_desc *desc,
+ struct scatterlist *dst, struct scatterlist *src,
+ unsigned int nbytes)
+{
+ struct aes_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
+ struct blkcipher_walk walk;
+ int err;
+
+ blkcipher_walk_init(&walk, dst, src, nbytes);
+ err = blkcipher_walk_virt(desc, &walk);
+
+ while ((nbytes = walk.nbytes)) {
+ u8 *iv = walk.iv;
+ nbytes -= (nbytes % AES_BLOCK_SIZE);
+ ifx_deu_aes_cbc(ctx, walk.dst.virt.addr, walk.src.virt.addr,
+ iv, nbytes, CRYPTO_DIR_ENCRYPT, 0);
+ nbytes &= AES_BLOCK_SIZE - 1;
+ err = blkcipher_walk_done(desc, &walk, nbytes);
+ }
+
+ return err;
+}
+
+/*! \fn int cbc_aes_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief CBC AES decrypt using linux crypto blkcipher
+ * \param desc blkcipher descriptor
+ * \param dst output scatterlist
+ * \param src input scatterlist
+ * \param nbytes data size in bytes
+ * \return err
+*/
+int cbc_aes_decrypt(struct blkcipher_desc *desc,
+ struct scatterlist *dst, struct scatterlist *src,
+ unsigned int nbytes)
+{
+ struct aes_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
+ struct blkcipher_walk walk;
+ int err;
+
+ blkcipher_walk_init(&walk, dst, src, nbytes);
+ err = blkcipher_walk_virt(desc, &walk);
+
+ while ((nbytes = walk.nbytes)) {
+ u8 *iv = walk.iv;
+ nbytes -= (nbytes % AES_BLOCK_SIZE);
+ ifx_deu_aes_cbc(ctx, walk.dst.virt.addr, walk.src.virt.addr,
+ iv, nbytes, CRYPTO_DIR_DECRYPT, 0);
+ nbytes &= AES_BLOCK_SIZE - 1;
+ err = blkcipher_walk_done(desc, &walk, nbytes);
+ }
+
+ return err;
+}
+
+/*
+ * \brief AES function mappings
+*/
+struct crypto_alg ifxdeu_cbc_aes_alg = {
+ .cra_name = "cbc(aes)",
+ .cra_driver_name = "ifxdeu-cbc(aes)",
+ .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER,
+ .cra_blocksize = AES_BLOCK_SIZE,
+ .cra_ctxsize = sizeof(struct aes_ctx),
+ .cra_type = &crypto_blkcipher_type,
+ .cra_module = THIS_MODULE,
+ .cra_list = LIST_HEAD_INIT(ifxdeu_cbc_aes_alg.cra_list),
+ .cra_u = {
+ .blkcipher = {
+ .min_keysize = AES_MIN_KEY_SIZE,
+ .max_keysize = AES_MAX_KEY_SIZE,
+ .ivsize = AES_BLOCK_SIZE,
+ .setkey = aes_set_key,
+ .encrypt = cbc_aes_encrypt,
+ .decrypt = cbc_aes_decrypt,
+ }
+ }
+};
+
+
+/*! \fn int ctr_basic_aes_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief Counter mode AES encrypt using linux crypto blkcipher
+ * \param desc blkcipher descriptor
+ * \param dst output scatterlist
+ * \param src input scatterlist
+ * \param nbytes data size in bytes
+ * \return err
+*/
+int ctr_basic_aes_encrypt(struct blkcipher_desc *desc,
+ struct scatterlist *dst, struct scatterlist *src,
+ unsigned int nbytes)
+{
+ struct aes_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
+ struct blkcipher_walk walk;
+ int err;
+
+ blkcipher_walk_init(&walk, dst, src, nbytes);
+ err = blkcipher_walk_virt(desc, &walk);
+
+ while ((nbytes = walk.nbytes)) {
+ u8 *iv = walk.iv;
+ nbytes -= (nbytes % AES_BLOCK_SIZE);
+ ifx_deu_aes_ctr(ctx, walk.dst.virt.addr, walk.src.virt.addr,
+ iv, nbytes, CRYPTO_DIR_ENCRYPT, 0);
+ nbytes &= AES_BLOCK_SIZE - 1;
+ err = blkcipher_walk_done(desc, &walk, nbytes);
+ }
+
+ return err;
+}
+
+/*! \fn int ctr_basic_aes_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief Counter mode AES decrypt using linux crypto blkcipher
+ * \param desc blkcipher descriptor
+ * \param dst output scatterlist
+ * \param src input scatterlist
+ * \param nbytes data size in bytes
+ * \return err
+*/
+int ctr_basic_aes_decrypt(struct blkcipher_desc *desc,
+ struct scatterlist *dst, struct scatterlist *src,
+ unsigned int nbytes)
+{
+ struct aes_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
+ struct blkcipher_walk walk;
+ int err;
+
+ blkcipher_walk_init(&walk, dst, src, nbytes);
+ err = blkcipher_walk_virt(desc, &walk);
+
+ while ((nbytes = walk.nbytes)) {
+ u8 *iv = walk.iv;
+ nbytes -= (nbytes % AES_BLOCK_SIZE);
+ ifx_deu_aes_ctr(ctx, walk.dst.virt.addr, walk.src.virt.addr,
+ iv, nbytes, CRYPTO_DIR_DECRYPT, 0);
+ nbytes &= AES_BLOCK_SIZE - 1;
+ err = blkcipher_walk_done(desc, &walk, nbytes);
+ }
+
+ return err;
+}
+
+/*
+ * \brief AES function mappings
+*/
+struct crypto_alg ifxdeu_ctr_basic_aes_alg = {
+ .cra_name = "ctr(aes)",
+ .cra_driver_name = "ifxdeu-ctr(aes)",
+ .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER,
+ .cra_blocksize = AES_BLOCK_SIZE,
+ .cra_ctxsize = sizeof(struct aes_ctx),
+ .cra_type = &crypto_blkcipher_type,
+ .cra_module = THIS_MODULE,
+ .cra_list = LIST_HEAD_INIT(ifxdeu_ctr_basic_aes_alg.cra_list),
+ .cra_u = {
+ .blkcipher = {
+ .min_keysize = AES_MIN_KEY_SIZE,
+ .max_keysize = AES_MAX_KEY_SIZE,
+ .ivsize = AES_BLOCK_SIZE,
+ .setkey = aes_set_key,
+ .encrypt = ctr_basic_aes_encrypt,
+ .decrypt = ctr_basic_aes_decrypt,
+ }
+ }
+};
+
+
+/*! \fn int ctr_rfc3686_aes_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief Counter mode AES (rfc3686) encrypt using linux crypto blkcipher
+ * \param desc blkcipher descriptor
+ * \param dst output scatterlist
+ * \param src input scatterlist
+ * \param nbytes data size in bytes
+ * \return err
+*/
+int ctr_rfc3686_aes_encrypt(struct blkcipher_desc *desc,
+ struct scatterlist *dst, struct scatterlist *src,
+ unsigned int nbytes)
+{
+ struct aes_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
+ struct blkcipher_walk walk;
+ int err;
+ u8 rfc3686_iv[16];
+
+ blkcipher_walk_init(&walk, dst, src, nbytes);
+ err = blkcipher_walk_virt(desc, &walk);
+
+ /* set up counter block */
+ memcpy(rfc3686_iv, ctx->nonce, CTR_RFC3686_NONCE_SIZE);
+ memcpy(rfc3686_iv + CTR_RFC3686_NONCE_SIZE, walk.iv, CTR_RFC3686_IV_SIZE);
+
+ /* initialize counter portion of counter block */
+ *(__be32 *)(rfc3686_iv + CTR_RFC3686_NONCE_SIZE + CTR_RFC3686_IV_SIZE) =
+ cpu_to_be32(1);
+
+ while ((nbytes = walk.nbytes)) {
+ nbytes -= (nbytes % AES_BLOCK_SIZE);
+ ifx_deu_aes_ctr(ctx, walk.dst.virt.addr, walk.src.virt.addr,
+ rfc3686_iv, nbytes, CRYPTO_DIR_ENCRYPT, 0);
+ nbytes &= AES_BLOCK_SIZE - 1;
+ err = blkcipher_walk_done(desc, &walk, nbytes);
+ }
+
+ return err;
+}
+
+/*! \fn int ctr_rfc3686_aes_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief Counter mode AES (rfc3686) decrypt using linux crypto blkcipher
+ * \param desc blkcipher descriptor
+ * \param dst output scatterlist
+ * \param src input scatterlist
+ * \param nbytes data size in bytes
+ * \return err
+*/
+int ctr_rfc3686_aes_decrypt(struct blkcipher_desc *desc,
+ struct scatterlist *dst, struct scatterlist *src,
+ unsigned int nbytes)
+{
+ struct aes_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
+ struct blkcipher_walk walk;
+ int err;
+ u8 rfc3686_iv[16];
+
+ blkcipher_walk_init(&walk, dst, src, nbytes);
+ err = blkcipher_walk_virt(desc, &walk);
+
+ /* set up counter block */
+ memcpy(rfc3686_iv, ctx->nonce, CTR_RFC3686_NONCE_SIZE);
+ memcpy(rfc3686_iv + CTR_RFC3686_NONCE_SIZE, walk.iv, CTR_RFC3686_IV_SIZE);
+
+ /* initialize counter portion of counter block */
+ *(__be32 *)(rfc3686_iv + CTR_RFC3686_NONCE_SIZE + CTR_RFC3686_IV_SIZE) =
+ cpu_to_be32(1);
+
+ while ((nbytes = walk.nbytes)) {
+ nbytes -= (nbytes % AES_BLOCK_SIZE);
+ ifx_deu_aes_ctr(ctx, walk.dst.virt.addr, walk.src.virt.addr,
+ rfc3686_iv, nbytes, CRYPTO_DIR_DECRYPT, 0);
+ nbytes &= AES_BLOCK_SIZE - 1;
+ err = blkcipher_walk_done(desc, &walk, nbytes);
+ }
+
+ return err;
+}
+
+/*
+ * \brief AES function mappings
+*/
+struct crypto_alg ifxdeu_ctr_rfc3686_aes_alg = {
+ .cra_name = "rfc3686(ctr(aes))",
+ .cra_driver_name = "ifxdeu-ctr-rfc3686(aes)",
+ .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER,
+ .cra_blocksize = AES_BLOCK_SIZE,
+ .cra_ctxsize = sizeof(struct aes_ctx),
+ .cra_type = &crypto_blkcipher_type,
+ .cra_module = THIS_MODULE,
+ .cra_list = LIST_HEAD_INIT(ifxdeu_ctr_rfc3686_aes_alg.cra_list),
+ .cra_u = {
+ .blkcipher = {
+ .min_keysize = AES_MIN_KEY_SIZE,
+ .max_keysize = CTR_RFC3686_MAX_KEY_SIZE,
+ .ivsize = CTR_RFC3686_IV_SIZE,
+ .setkey = ctr_rfc3686_aes_set_key,
+ .encrypt = ctr_rfc3686_aes_encrypt,
+ .decrypt = ctr_rfc3686_aes_decrypt,
+ }
+ }
+};
+
+
+/*! \fn int __init ifxdeu_init_aes (void)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief function to initialize AES driver
+ * \return ret
+*/
+int __init ifxdeu_init_aes (void)
+{
+ int ret = -ENOSYS;
+
+
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20))
+ if (!disable_multiblock) {
+ ifxdeu_aes_alg.cra_u.cipher.cia_max_nbytes = AES_BLOCK_SIZE; //(size_t)-1;
+ ifxdeu_aes_alg.cra_u.cipher.cia_req_align = 16;
+ ifxdeu_aes_alg.cra_u.cipher.cia_ecb = ifx_deu_aes_ecb;
+ ifxdeu_aes_alg.cra_u.cipher.cia_cbc = ifx_deu_aes_cbc;
+ ifxdeu_aes_alg.cra_u.cipher.cia_cfb = ifx_deu_aes_cfb;
+ ifxdeu_aes_alg.cra_u.cipher.cia_ofb = ifx_deu_aes_ofb;
+ }
+#endif
+
+ if ((ret = crypto_register_alg(&ifxdeu_aes_alg)))
+ goto aes_err;
+
+ if ((ret = crypto_register_alg(&ifxdeu_ecb_aes_alg)))
+ goto ecb_aes_err;
+
+ if ((ret = crypto_register_alg(&ifxdeu_cbc_aes_alg)))
+ goto cbc_aes_err;
+
+ if ((ret = crypto_register_alg(&ifxdeu_ctr_basic_aes_alg)))
+ goto ctr_basic_aes_err;
+
+ if ((ret = crypto_register_alg(&ifxdeu_ctr_rfc3686_aes_alg)))
+ goto ctr_rfc3686_aes_err;
+
+ aes_chip_init ();
+
+ CRTCL_SECT_INIT;
+
+
+ printk (KERN_NOTICE "IFX DEU AES initialized%s%s.\n", disable_multiblock ? "" : " (multiblock)", disable_deudma ? "" : " (DMA)");
+ return ret;
+
+ctr_rfc3686_aes_err:
+ crypto_unregister_alg(&ifxdeu_ctr_rfc3686_aes_alg);
+ printk (KERN_ERR "IFX ctr_rfc3686_aes initialization failed!\n");
+ return ret;
+ctr_basic_aes_err:
+ crypto_unregister_alg(&ifxdeu_ctr_basic_aes_alg);
+ printk (KERN_ERR "IFX ctr_basic_aes initialization failed!\n");
+ return ret;
+cbc_aes_err:
+ crypto_unregister_alg(&ifxdeu_cbc_aes_alg);
+ printk (KERN_ERR "IFX cbc_aes initialization failed!\n");
+ return ret;
+ecb_aes_err:
+ crypto_unregister_alg(&ifxdeu_ecb_aes_alg);
+ printk (KERN_ERR "IFX aes initialization failed!\n");
+ return ret;
+aes_err:
+ printk(KERN_ERR "IFX DEU AES initialization failed!\n");
+
+ return ret;
+}
+
+/*! \fn void __exit ifxdeu_fini_aes (void)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief unregister aes driver
+*/
+void __exit ifxdeu_fini_aes (void)
+{
+ crypto_unregister_alg (&ifxdeu_aes_alg);
+ crypto_unregister_alg (&ifxdeu_ecb_aes_alg);
+ crypto_unregister_alg (&ifxdeu_cbc_aes_alg);
+ crypto_unregister_alg (&ifxdeu_ctr_basic_aes_alg);
+ crypto_unregister_alg (&ifxdeu_ctr_rfc3686_aes_alg);
+
+}
+
+
diff --git a/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_arc4.c.svn-base b/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_arc4.c.svn-base
new file mode 100644
index 0000000..ee56187
--- /dev/null
+++ b/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_arc4.c.svn-base
@@ -0,0 +1,389 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_arc4.c
+** PROJECT : IFX UEIP
+** MODULES : DEU Module
+**
+** DATE : September 8, 2009
+** AUTHOR : Mohammad Firdaus
+** DESCRIPTION : Data Encryption Unit Driver for ARC4 Algorithm
+** COPYRIGHT : Copyright (c) 2009
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 08 Sept 2009 Mohammad Firdaus Initial UEIP release
+*******************************************************************************/
+
+/*!
+ \defgroup IFX_DEU IFX_DEU_DRIVERS
+ \ingroup API
+ \brief ifx deu driver module
+*/
+
+/*!
+ \file ifxmips_arc4.c
+ \ingroup IFX_DEU
+ \brief ARC4 encryption DEU driver file
+*/
+
+/*!
+ \defgroup IFX_ARC4_FUNCTIONS IFX_ARC4_FUNCTIONS
+ \ingroup IFX_DEU
+ \brief IFX deu driver functions
+*/
+
+/* Project header */
+#include <linux/version.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/crypto.h>
+#include <crypto/algapi.h>
+#include <linux/interrupt.h>
+#include <asm/byteorder.h>
+#include <linux/delay.h>
+
+/* Board specific header files */
+#ifdef CONFIG_AR9
+#include "ifxmips_deu_ar9.h"
+#endif
+#ifdef CONFIG_VR9
+#include "ifxmips_deu_vr9.h"
+#endif
+
+static spinlock_t lock;
+#define CRTCL_SECT_INIT spin_lock_init(&lock)
+#define CRTCL_SECT_START spin_lock_irqsave(&lock, flag)
+#define CRTCL_SECT_END spin_unlock_irqrestore(&lock, flag)
+
+/* Preprocessor declerations */
+#define ARC4_MIN_KEY_SIZE 1
+//#define ARC4_MAX_KEY_SIZE 256
+#define ARC4_MAX_KEY_SIZE 16
+#define ARC4_BLOCK_SIZE 1
+#define ARC4_START IFX_ARC4_CON
+#ifdef CRYPTO_DEBUG
+extern char debug_level;
+#define DPRINTF(level, format, args...) if (level < debug_level) printk(KERN_INFO "[%s %s %d]: " format, __FILE__, __func__, __LINE__, ##args);
+#else
+#define DPRINTF(level, format, args...)
+#endif
+
+/*
+ * \brief arc4 private structure
+*/
+struct arc4_ctx {
+ int key_length;
+ u8 buf[120];
+};
+
+extern int disable_deudma;
+extern int disable_multiblock;
+
+
+/*! \fn static void _deu_arc4 (void *ctx_arg, u8 *out_arg, const u8 *in_arg, u8 *iv_arg, u32 nbytes, int encdec, int mode)
+ \ingroup IFX_ARC4_FUNCTIONS
+ \brief main interface to ARC4 hardware
+ \param ctx_arg crypto algo context
+ \param out_arg output bytestream
+ \param in_arg input bytestream
+ \param iv_arg initialization vector
+ \param nbytes length of bytestream
+ \param encdec 1 for encrypt; 0 for decrypt
+ \param mode operation mode such as ebc, cbc, ctr
+*/
+static void _deu_arc4 (void *ctx_arg, u8 *out_arg, const u8 *in_arg,
+ u8 *iv_arg, u32 nbytes, int encdec, int mode)
+{
+ volatile struct arc4_t *arc4 = (struct arc4_t *) ARC4_START;
+
+ int i = 0;
+ unsigned long flag;
+
+#if 1 // need to handle nbytes not multiple of 16
+ volatile u32 tmp_array32[4];
+ volatile u8 *tmp_ptr8;
+ int remaining_bytes, j;
+#endif
+
+ CRTCL_SECT_START;
+
+ arc4->IDLEN = nbytes;
+
+#if 1
+ while (i < nbytes) {
+ arc4->ID3R = *((u32 *) in_arg + (i>>2) + 0);
+ arc4->ID2R = *((u32 *) in_arg + (i>>2) + 1);
+ arc4->ID1R = *((u32 *) in_arg + (i>>2) + 2);
+ arc4->ID0R = *((u32 *) in_arg + (i>>2) + 3);
+
+ arc4->controlr.GO = 1;
+
+ while (arc4->controlr.BUS) {
+ // this will not take long
+ }
+
+#if 1
+ // need to handle nbytes not multiple of 16
+ tmp_array32[0] = arc4->OD3R;
+ tmp_array32[1] = arc4->OD2R;
+ tmp_array32[2] = arc4->OD1R;
+ tmp_array32[3] = arc4->OD0R;
+
+ remaining_bytes = nbytes - i;
+ if (remaining_bytes > 16)
+ remaining_bytes = 16;
+
+ tmp_ptr8 = (u8 *)&tmp_array32[0];
+ for (j = 0; j < remaining_bytes; j++)
+ *out_arg++ = *tmp_ptr8++;
+#else
+ *((u32 *) out_arg + (i>>2) + 0) = arc4->OD3R;
+ *((u32 *) out_arg + (i>>2) + 1) = arc4->OD2R;
+ *((u32 *) out_arg + (i>>2) + 2) = arc4->OD1R;
+ *((u32 *) out_arg + (i>>2) + 3) = arc4->OD0R;
+#endif
+
+ i += 16;
+ }
+#else // dma
+
+#endif // dma
+
+ CRTCL_SECT_END;
+}
+
+/*! \fn arc4_chip_init (void)
+ \ingroup IFX_ARC4_FUNCTIONS
+ \brief initialize arc4 hardware
+*/
+static void arc4_chip_init (void)
+{
+ //do nothing
+}
+
+/*! \fn static int arc4_set_key(struct crypto_tfm *tfm, const u8 *in_key, unsigned int key_len)
+ \ingroup IFX_ARC4_FUNCTIONS
+ \brief sets ARC4 key
+ \param tfm linux crypto algo transform
+ \param in_key input key
+ \param key_len key lengths less than or equal to 16 bytes supported
+*/
+static int arc4_set_key(struct crypto_tfm *tfm, const u8 *inkey,
+ unsigned int key_len)
+{
+ //struct arc4_ctx *ctx = crypto_tfm_ctx(tfm);
+ volatile struct arc4_t *arc4 = (struct arc4_t *) ARC4_START;
+ u32 *in_key = (u32 *)inkey;
+
+ // must program all bits at one go?!!!
+//#if 1
+ *IFX_ARC4_CON = ( (1<<31) | ((key_len - 1)<<27) | (1<<26) | (3<<16) );
+ //NDC=1,ENDI=1,GO=0,KSAE=1,SM=0
+
+ arc4->K3R = *((u32 *) in_key + 0);
+ arc4->K2R = *((u32 *) in_key + 1);
+ arc4->K1R = *((u32 *) in_key + 2);
+ arc4->K0R = *((u32 *) in_key + 3);
+
+#if 0 // arc4 is a ugly state machine, KSAE can only be set once per session
+ ctx->key_length = key_len;
+
+ memcpy ((u8 *) (ctx->buf), in_key, key_len);
+#endif
+
+ return 0;
+}
+
+/*! \fn static void _deu_arc4_ecb(void *ctx, uint8_t *dst, const uint8_t *src, uint8_t *iv, size_t nbytes, int encdec, int inplace)
+ \ingroup IFX_ARC4_FUNCTIONS
+ \brief sets ARC4 hardware to ECB mode
+ \param ctx crypto algo context
+ \param dst output bytestream
+ \param src input bytestream
+ \param iv initialization vector
+ \param nbytes length of bytestream
+ \param encdec 1 for encrypt; 0 for decrypt
+ \param inplace not used
+*/
+static void _deu_arc4_ecb(void *ctx, uint8_t *dst, const uint8_t *src,
+ uint8_t *iv, size_t nbytes, int encdec, int inplace)
+{
+ _deu_arc4 (ctx, dst, src, NULL, nbytes, encdec, 0);
+}
+
+/*! \fn static void arc4_crypt(struct crypto_tfm *tfm, u8 *out, const u8 *in)
+ \ingroup IFX_ARC4_FUNCTIONS
+ \brief encrypt/decrypt ARC4_BLOCK_SIZE of data
+ \param tfm linux crypto algo transform
+ \param out output bytestream
+ \param in input bytestream
+*/
+static void arc4_crypt(struct crypto_tfm *tfm, u8 *out, const u8 *in)
+{
+ struct arc4_ctx *ctx = crypto_tfm_ctx(tfm);
+
+ _deu_arc4 (ctx, out, in, NULL, ARC4_BLOCK_SIZE,
+ CRYPTO_DIR_DECRYPT, 0);
+
+}
+
+/*
+ * \brief ARC4 function mappings
+*/
+static struct crypto_alg ifxdeu_arc4_alg = {
+ .cra_name = "arc4",
+ .cra_driver_name = "ifxdeu-arc4",
+ .cra_flags = CRYPTO_ALG_TYPE_CIPHER,
+ .cra_blocksize = ARC4_BLOCK_SIZE,
+ .cra_ctxsize = sizeof(struct arc4_ctx),
+ .cra_module = THIS_MODULE,
+ .cra_list = LIST_HEAD_INIT(ifxdeu_arc4_alg.cra_list),
+ .cra_u = {
+ .cipher = {
+ .cia_min_keysize = ARC4_MIN_KEY_SIZE,
+ .cia_max_keysize = ARC4_MAX_KEY_SIZE,
+ .cia_setkey = arc4_set_key,
+ .cia_encrypt = arc4_crypt,
+ .cia_decrypt = arc4_crypt,
+ }
+ }
+};
+
+/*! \fn static int ecb_arc4_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes)
+ \ingroup IFX_ARC4_FUNCTIONS
+ \brief ECB ARC4 encrypt using linux crypto blkcipher
+ \param desc blkcipher descriptor
+ \param dst output scatterlist
+ \param src input scatterlist
+ \param nbytes data size in bytes
+*/
+static int ecb_arc4_encrypt(struct blkcipher_desc *desc,
+ struct scatterlist *dst, struct scatterlist *src,
+ unsigned int nbytes)
+{
+ struct arc4_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
+ struct blkcipher_walk walk;
+ int err;
+
+ DPRINTF(1, "\n");
+ blkcipher_walk_init(&walk, dst, src, nbytes);
+ err = blkcipher_walk_virt(desc, &walk);
+
+ while ((nbytes = walk.nbytes)) {
+ _deu_arc4_ecb(ctx, walk.dst.virt.addr, walk.src.virt.addr,
+ NULL, nbytes, CRYPTO_DIR_ENCRYPT, 0);
+ nbytes &= ARC4_BLOCK_SIZE - 1;
+ err = blkcipher_walk_done(desc, &walk, nbytes);
+ }
+
+ return err;
+}
+
+/*! \fn static int ecb_arc4_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes)
+ \ingroup IFX_ARC4_FUNCTIONS
+ \brief ECB ARC4 decrypt using linux crypto blkcipher
+ \param desc blkcipher descriptor
+ \param dst output scatterlist
+ \param src input scatterlist
+ \param nbytes data size in bytes
+*/
+static int ecb_arc4_decrypt(struct blkcipher_desc *desc,
+ struct scatterlist *dst, struct scatterlist *src,
+ unsigned int nbytes)
+{
+ struct arc4_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
+ struct blkcipher_walk walk;
+ int err;
+
+ DPRINTF(1, "\n");
+ blkcipher_walk_init(&walk, dst, src, nbytes);
+ err = blkcipher_walk_virt(desc, &walk);
+
+ while ((nbytes = walk.nbytes)) {
+ _deu_arc4_ecb(ctx, walk.dst.virt.addr, walk.src.virt.addr,
+ NULL, nbytes, CRYPTO_DIR_DECRYPT, 0);
+ nbytes &= ARC4_BLOCK_SIZE - 1;
+ err = blkcipher_walk_done(desc, &walk, nbytes);
+ }
+
+ return err;
+}
+
+/*
+ * \brief ARC4 function mappings
+*/
+static struct crypto_alg ifxdeu_ecb_arc4_alg = {
+ .cra_name = "ecb(arc4)",
+ .cra_driver_name = "ifxdeu-ecb(arc4)",
+ .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER,
+ .cra_blocksize = ARC4_BLOCK_SIZE,
+ .cra_ctxsize = sizeof(struct arc4_ctx),
+ .cra_type = &crypto_blkcipher_type,
+ .cra_module = THIS_MODULE,
+ .cra_list = LIST_HEAD_INIT(ifxdeu_ecb_arc4_alg.cra_list),
+ .cra_u = {
+ .blkcipher = {
+ .min_keysize = ARC4_MIN_KEY_SIZE,
+ .max_keysize = ARC4_MAX_KEY_SIZE,
+ .setkey = arc4_set_key,
+ .encrypt = ecb_arc4_encrypt,
+ .decrypt = ecb_arc4_decrypt,
+ }
+ }
+};
+
+/*! \fn int __init ifxdeu_init_arc4(void)
+ \ingroup IFX_ARC4_FUNCTIONS
+ \brief initialize arc4 driver
+*/
+int __init ifxdeu_init_arc4(void)
+{
+ int ret = -ENOSYS;
+
+
+ if ((ret = crypto_register_alg(&ifxdeu_arc4_alg)))
+ goto arc4_err;
+
+ if ((ret = crypto_register_alg(&ifxdeu_ecb_arc4_alg)))
+ goto ecb_arc4_err;
+
+ arc4_chip_init ();
+
+ CRTCL_SECT_INIT;
+
+ printk (KERN_NOTICE "IFX DEU ARC4 initialized%s%s.\n", disable_multiblock ? "" : " (multiblock)", disable_deudma ? "" : " (DMA)");
+ return ret;
+
+arc4_err:
+ crypto_unregister_alg(&ifxdeu_arc4_alg);
+ printk(KERN_ERR "IFX arc4 initialization failed!\n");
+ return ret;
+ecb_arc4_err:
+ crypto_unregister_alg(&ifxdeu_ecb_arc4_alg);
+ printk (KERN_ERR "IFX ecb_arc4 initialization failed!\n");
+ return ret;
+
+}
+
+/*! \fn void __exit ifxdeu_fini_arc4(void)
+ \ingroup IFX_ARC4_FUNCTIONS
+ \brief unregister arc4 driver
+*/
+void __exit ifxdeu_fini_arc4(void)
+{
+ crypto_unregister_alg (&ifxdeu_arc4_alg);
+ crypto_unregister_alg (&ifxdeu_ecb_arc4_alg);
+
+
+}
+
+
diff --git a/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_async_aes.c.svn-base b/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_async_aes.c.svn-base
new file mode 100644
index 0000000..64536da
--- /dev/null
+++ b/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_async_aes.c.svn-base
@@ -0,0 +1,1137 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_async_aes.c
+** PROJECT : IFX UEIP
+** MODULES : DEU Module
+**
+** DATE : October 11, 2010
+** AUTHOR : Mohammad Firdaus
+** DESCRIPTION : Data Encryption Unit Driver for AES Algorithm
+** COPYRIGHT : Copyright (c) 2010
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 08,Sept 2009 Mohammad Firdaus Initial UEIP release
+** 11, Oct 2010 Mohammad Firdaus Kernel Port incl. Async. Ablkcipher mode
+** 21,March 2011 Mohammad Firdaus Changes for Kernel 2.6.32 and IPSec integration
+*******************************************************************************/
+/*!
+ \defgroup IFX_DEU IFX_DEU_DRIVERS
+ \ingroup API
+ \brief ifx DEU driver module
+*/
+
+/*!
+ \file ifxmips_async_aes.c
+ \ingroup IFX_DEU
+ \brief AES Encryption Driver main file
+*/
+
+/*!
+ \defgroup IFX_AES_FUNCTIONS IFX_AES_FUNCTIONS
+ \ingroup IFX_DEU
+ \brief IFX AES driver Functions
+*/
+
+
+
+#include <linux/wait.h>
+#include <linux/crypto.h>
+#include <linux/kernel.h>
+#include <linux/kthread.h>
+#include <linux/interrupt.h>
+#include <linux/spinlock.h>
+#include <linux/list.h>
+#include <crypto/ctr.h>
+#include <crypto/aes.h>
+#include <crypto/algapi.h>
+#include <crypto/scatterwalk.h>
+
+#include <asm/ifx/ifx_regs.h>
+#include <asm/ifx/ifx_types.h>
+#include <asm/ifx/common_routines.h>
+#include <asm/ifx/irq.h>
+#include <asm/ifx/ifx_pmu.h>
+#include <asm/ifx/ifx_gpio.h>
+#include <asm/kmap_types.h>
+
+#include "ifxmips_deu.h"
+
+#if defined(CONFIG_DANUBE)
+#include "ifxmips_deu_danube.h"
+extern int ifx_danube_pre_1_4;
+#elif defined(CONFIG_AR9)
+#include "ifxmips_deu_ar9.h"
+#elif defined(CONFIG_VR9) || defined(CONFIG_AR10)
+#include "ifxmips_deu_vr9.h"
+#else
+#error "Unkown platform"
+#endif
+
+/* DMA related header and variables */
+
+spinlock_t aes_lock;
+#define CRTCL_SECT_INIT spin_lock_init(&aes_lock)
+#define CRTCL_SECT_START spin_lock_irqsave(&aes_lock, flag)
+#define CRTCL_SECT_END spin_unlock_irqrestore(&aes_lock, flag)
+
+/* Definition of constants */
+//#define AES_START IFX_AES_CON
+#define AES_MIN_KEY_SIZE 16
+#define AES_MAX_KEY_SIZE 32
+#define AES_BLOCK_SIZE 16
+#define CTR_RFC3686_NONCE_SIZE 4
+#define CTR_RFC3686_IV_SIZE 8
+#define CTR_RFC3686_MAX_KEY_SIZE (AES_MAX_KEY_SIZE + CTR_RFC3686_NONCE_SIZE)
+
+#ifdef CRYPTO_DEBUG
+extern char debug_level;
+#define DPRINTF(level, format, args...) if (level < debug_level) printk(KERN_INFO "[%s %s %d]: " format, __FILE__, __func__, __LINE__, ##args);
+#else
+#define DPRINTF(level, format, args...)
+#endif /* CRYPTO_DEBUG */
+
+
+static int disable_multiblock = 0;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
+module_param(disable_multiblock, int, 0);
+#else
+MODULE_PARM_DESC(disable_multiblock, "Disable encryption of whole multiblock buffers");
+#endif
+
+static int disable_deudma = 1;
+
+/* Function decleration */
+int aes_chip_init(void);
+u32 endian_swap(u32 input);
+u32 input_swap(u32 input);
+u32* memory_alignment(const u8 *arg, u32 *buff_alloc, int in_out, int nbytes);
+void aes_dma_memory_copy(u32 *outcopy, u32 *out_dma, u8 *out_arg, int nbytes);
+int aes_memory_allocate(int value);
+int des_memory_allocate(int value);
+void memory_release(u32 *addr);
+
+
+struct aes_ctx {
+ int key_length;
+ u32 buf[AES_MAX_KEY_SIZE];
+ u8 nonce[CTR_RFC3686_NONCE_SIZE];
+
+};
+
+struct aes_container {
+ u8 *iv;
+ u8 *src_buf;
+ u8 *dst_buf;
+
+ int mode;
+ int encdec;
+ int complete;
+ int flag;
+
+ u32 bytes_processed;
+ u32 nbytes;
+
+ struct ablkcipher_request arequest;
+
+};
+
+aes_priv_t *aes_queue;
+extern deu_drv_priv_t deu_dma_priv;
+
+void hexdump(unsigned char *buf, unsigned int len)
+{
+ print_hex_dump(KERN_CONT, "", DUMP_PREFIX_OFFSET,
+ 16, 1,
+ buf, len, false);
+}
+
+/*! \fn void lq_deu_aes_core (void *ctx_arg, u8 *out_arg, const u8 *in_arg, u8 *iv_arg,
+ size_t nbytes, int encdec, int mode)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief main interface to AES hardware
+ * \param ctx_arg crypto algo context
+ * \param out_arg output bytestream
+ * \param in_arg input bytestream
+ * \param iv_arg initialization vector
+ * \param nbytes length of bytestream
+ * \param encdec 1 for encrypt; 0 for decrypt
+ * \param mode operation mode such as ebc, cbc, ctr
+ *
+*/
+
+static int lq_deu_aes_core (void *ctx_arg, u8 *out_arg, const u8 *in_arg,
+ u8 *iv_arg, size_t nbytes, int encdec, int mode)
+{
+ /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+ volatile struct aes_t *aes = (volatile struct aes_t *) AES_START;
+ struct aes_ctx *ctx = (struct aes_ctx *)ctx_arg;
+ u32 *in_key = ctx->buf;
+ unsigned long flag;
+ /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+ int key_len = ctx->key_length;
+
+ volatile struct deu_dma_t *dma = (struct deu_dma_t *) IFX_DEU_DMA_CON;
+ struct dma_device_info *dma_device = ifx_deu[0].dma_device;
+ deu_drv_priv_t *deu_priv = (deu_drv_priv_t *)dma_device->priv;
+ int wlen = 0;
+ //u32 *outcopy = NULL;
+ u32 *dword_mem_aligned_in = NULL;
+
+ CRTCL_SECT_START;
+
+ /* 128, 192 or 256 bit key length */
+ aes->controlr.K = key_len / 8 - 2;
+ if (key_len == 128 / 8) {
+ aes->K3R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 0));
+ aes->K2R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 1));
+ aes->K1R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 2));
+ aes->K0R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 3));
+ }
+ else if (key_len == 192 / 8) {
+ aes->K5R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 0));
+ aes->K4R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 1));
+ aes->K3R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 2));
+ aes->K2R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 3));
+ aes->K1R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 4));
+ aes->K0R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 5));
+ }
+ else if (key_len == 256 / 8) {
+ aes->K7R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 0));
+ aes->K6R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 1));
+ aes->K5R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 2));
+ aes->K4R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 3));
+ aes->K3R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 4));
+ aes->K2R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 5));
+ aes->K1R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 6));
+ aes->K0R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 7));
+ }
+ else {
+ printk (KERN_ERR "[%s %s %d]: Invalid key_len : %d\n", __FILE__, __func__, __LINE__, key_len);
+ CRTCL_SECT_END;
+ return -EINVAL;
+ }
+
+ /* let HW pre-process DEcryption key in any case (even if
+ ENcryption is used). Key Valid (KV) bit is then only
+ checked in decryption routine! */
+ aes->controlr.PNK = 1;
+
+ while (aes->controlr.BUS) {
+ // this will not take long
+ }
+ AES_DMA_MISC_CONFIG();
+
+ aes->controlr.E_D = !encdec; //encryption
+ aes->controlr.O = mode; //0 ECB 1 CBC 2 OFB 3 CFB 4 CTR
+
+ //aes->controlr.F = 128; //default; only for CFB and OFB modes; change only for customer-specific apps
+ if (mode > 0) {
+ aes->IV3R = DEU_ENDIAN_SWAP(*(u32 *) iv_arg);
+ aes->IV2R = DEU_ENDIAN_SWAP(*((u32 *) iv_arg + 1));
+ aes->IV1R = DEU_ENDIAN_SWAP(*((u32 *) iv_arg + 2));
+ aes->IV0R = DEU_ENDIAN_SWAP(*((u32 *) iv_arg + 3));
+ };
+
+
+ /* Prepare Rx buf length used in dma psuedo interrupt */
+ deu_priv->deu_rx_buf = (u32 *)out_arg;
+ deu_priv->deu_rx_len = nbytes;
+
+ /* memory alignment issue */
+ dword_mem_aligned_in = (u32 *) DEU_DWORD_REORDERING(in_arg, aes_buff_in, BUFFER_IN, nbytes);
+
+ dma->controlr.ALGO = 1; //AES
+ dma->controlr.BS = 0;
+ aes->controlr.DAU = 0;
+ dma->controlr.EN = 1;
+
+ while (aes->controlr.BUS) {
+ // wait for AES to be ready
+ };
+
+ deu_priv->outcopy = (u32 *) DEU_DWORD_REORDERING(out_arg, aes_buff_out, BUFFER_OUT, nbytes);
+ deu_priv->event_src = AES_ASYNC_EVENT;
+
+ wlen = dma_device_write (dma_device, (u8 *)dword_mem_aligned_in, nbytes, NULL);
+ if (wlen != nbytes) {
+ dma->controlr.EN = 0;
+ CRTCL_SECT_END;
+ printk (KERN_ERR "[%s %s %d]: dma_device_write fail!\n", __FILE__, __func__, __LINE__);
+ return -EINVAL;
+ }
+
+ // WAIT_AES_DMA_READY();
+
+ CRTCL_SECT_END;
+
+ if (mode > 0) {
+ *((u32 *) iv_arg) = DEU_ENDIAN_SWAP(*((u32 *) iv_arg));
+ *((u32 *) iv_arg + 1) = DEU_ENDIAN_SWAP(*((u32 *) iv_arg + 1));
+ *((u32 *) iv_arg + 2) = DEU_ENDIAN_SWAP(*((u32 *) iv_arg + 2));
+ *((u32 *) iv_arg + 3) = DEU_ENDIAN_SWAP(*((u32 *) iv_arg + 3));
+ }
+
+ return -EINPROGRESS;
+}
+
+/* \fn static int count_sgs(struct scatterlist *sl, unsigned int total_bytes)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief Counts and return the number of scatterlists
+ * \param *sl Function pointer to the scatterlist
+ * \param total_bytes The total number of bytes that needs to be encrypted/decrypted
+ * \return The number of scatterlists
+*/
+
+static int count_sgs(struct scatterlist *sl, unsigned int total_bytes)
+{
+ int i = 0;
+
+ do {
+ total_bytes -= sl[i].length;
+ i++;
+
+ } while (total_bytes > 0);
+
+ return i;
+}
+
+/* \fn void lq_sg_init(struct scatterlist *src,
+ * struct scatterlist *dst)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief Maps the scatterlists into a source/destination page.
+ * \param *src Pointer to the source scatterlist
+ * \param *dst Pointer to the destination scatterlist
+*/
+
+static void lq_sg_init(struct aes_container *aes_con,struct scatterlist *src,
+ struct scatterlist *dst)
+{
+
+ struct page *dst_page, *src_page;
+
+ src_page = sg_virt(src);
+ aes_con->src_buf = (char *) src_page;
+
+ dst_page = sg_virt(dst);
+ aes_con->dst_buf = (char *) dst_page;
+
+}
+
+
+/* \fn static void lq_sg_complete(struct aes_container *aes_con)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief Free the used up memory after encryt/decrypt.
+*/
+
+static void lq_sg_complete(struct aes_container *aes_con)
+{
+ unsigned long queue_flag;
+
+ spin_lock_irqsave(&aes_queue->lock, queue_flag);
+ kfree(aes_con);
+ spin_unlock_irqrestore(&aes_queue->lock, queue_flag);
+}
+
+/* \fn static inline struct aes_container *aes_container_cast (
+ * struct scatterlist *dst)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief Locate the structure aes_container in memory.
+ * \param *areq Pointer to memory location where ablkcipher_request is located
+ * \return *aes_cointainer The function pointer to aes_container
+*/
+static inline struct aes_container *aes_container_cast (
+ struct ablkcipher_request *areq)
+{
+ return container_of(areq, struct aes_container, arequest);
+}
+
+
+/* \fn static int process_next_packet(struct aes_container *aes_con, struct ablkcipher_request *areq,
+ * \ int state)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief Process next packet to be encrypt/decrypt
+ * \param *aes_con AES container structure
+ * \param *areq Pointer to memory location where ablkcipher_request is located
+ * \param state The state of the current packet (part of scatterlist or new packet)
+ * \return -EINVAL: error, -EINPROGRESS: Crypto still running, 1: no more scatterlist
+*/
+
+static int process_next_packet(struct aes_container *aes_con, struct ablkcipher_request *areq,
+ int state)
+{
+ u8 *iv;
+ int mode, dir, err = -EINVAL;
+ unsigned long queue_flag;
+ u32 inc, nbytes, remain, chunk_size;
+ struct scatterlist *src = NULL;
+ struct scatterlist *dst = NULL;
+ struct crypto_ablkcipher *cipher;
+ struct aes_ctx *ctx;
+
+ spin_lock_irqsave(&aes_queue->lock, queue_flag);
+
+ dir = aes_con->encdec;
+ mode = aes_con->mode;
+ iv = aes_con->iv;
+
+ if (state & PROCESS_SCATTER) {
+ src = scatterwalk_sg_next(areq->src);
+ dst = scatterwalk_sg_next(areq->dst);
+
+ if (!src || !dst) {
+ spin_unlock_irqrestore(&aes_queue->lock, queue_flag);
+ return 1;
+ }
+ }
+ else if (state & PROCESS_NEW_PACKET) {
+ src = areq->src;
+ dst = areq->dst;
+ }
+
+ remain = aes_con->bytes_processed;
+ chunk_size = src->length;
+
+ if (remain > DEU_MAX_PACKET_SIZE)
+ inc = DEU_MAX_PACKET_SIZE;
+ else if (remain > chunk_size)
+ inc = chunk_size;
+ else
+ inc = remain;
+
+ remain -= inc;
+ aes_con->nbytes = inc;
+
+ if (state & PROCESS_SCATTER) {
+ aes_con->src_buf += aes_con->nbytes;
+ aes_con->dst_buf += aes_con->nbytes;
+ }
+
+ lq_sg_init(aes_con, src, dst);
+
+ nbytes = aes_con->nbytes;
+
+ //printk("debug - Line: %d, func: %s, reqsize: %d, scattersize: %d\n",
+ // __LINE__, __func__, nbytes, chunk_size);
+
+ cipher = crypto_ablkcipher_reqtfm(areq);
+ ctx = crypto_ablkcipher_ctx(cipher);
+
+
+ if (aes_queue->hw_status == AES_IDLE)
+ aes_queue->hw_status = AES_STARTED;
+
+ aes_con->bytes_processed -= aes_con->nbytes;
+ err = ablkcipher_enqueue_request(&aes_queue->list, &aes_con->arequest);
+ if (err == -EBUSY) {
+ spin_unlock_irqrestore(&aes_queue->lock, queue_flag);
+ printk("Failed to enqueue request, ln: %d, err: %d\n",
+ __LINE__, err);
+ return -EINVAL;
+ }
+
+ spin_unlock_irqrestore(&aes_queue->lock, queue_flag);
+
+ err = lq_deu_aes_core(ctx, aes_con->dst_buf, aes_con->src_buf, iv, nbytes, dir, mode);
+ return err;
+
+}
+
+/* \fn static void process_queue (unsigned long data)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief tasklet to signal the dequeuing of the next packet to be processed
+ * \param unsigned long data Not used
+ * \return void
+*/
+
+static void process_queue(unsigned long data)
+{
+
+ DEU_WAKEUP_EVENT(deu_dma_priv.deu_thread_wait, AES_ASYNC_EVENT,
+ deu_dma_priv.aes_event_flags);
+}
+
+
+/* \fn static int aes_crypto_thread (void *data)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief AES thread that handles crypto requests from upper layer & DMA
+ * \param *data Not used
+ * \return -EINVAL: DEU failure, -EBUSY: DEU HW busy, 0: exit thread
+*/
+static int aes_crypto_thread (void *data)
+{
+ struct aes_container *aes_con = NULL;
+ struct ablkcipher_request *areq = NULL;
+ int err;
+ unsigned long queue_flag;
+
+ daemonize("lq_aes_thread");
+ printk("AES Queue Manager Starting\n");
+
+ while (1)
+ {
+ DEU_WAIT_EVENT(deu_dma_priv.deu_thread_wait, AES_ASYNC_EVENT,
+ deu_dma_priv.aes_event_flags);
+
+ spin_lock_irqsave(&aes_queue->lock, queue_flag);
+
+ /* wait to prevent starting a crypto session before
+ * exiting the dma interrupt thread.
+ */
+ if (aes_queue->hw_status == AES_STARTED) {
+ areq = ablkcipher_dequeue_request(&aes_queue->list);
+ aes_con = aes_container_cast(areq);
+ aes_queue->hw_status = AES_BUSY;
+ }
+ else if (aes_queue->hw_status == AES_IDLE) {
+ areq = ablkcipher_dequeue_request(&aes_queue->list);
+ aes_con = aes_container_cast(areq);
+ aes_queue->hw_status = AES_STARTED;
+ }
+ else if (aes_queue->hw_status == AES_BUSY) {
+ areq = ablkcipher_dequeue_request(&aes_queue->list);
+ aes_con = aes_container_cast(areq);
+ }
+ else if (aes_queue->hw_status == AES_COMPLETED) {
+ lq_sg_complete(aes_con);
+ aes_queue->hw_status = AES_IDLE;
+ areq->base.complete(&areq->base, 0);
+ spin_unlock_irqrestore(&aes_queue->lock, queue_flag);
+ return 0;
+ }
+ //printk("debug ln: %d, bytes proc: %d\n", __LINE__, aes_con->bytes_processed);
+ spin_unlock_irqrestore(&aes_queue->lock, queue_flag);
+
+ if (!aes_con) {
+ printk("AES_CON return null\n");
+ goto aes_done;
+ }
+
+ if (aes_con->bytes_processed == 0) {
+ goto aes_done;
+ }
+
+ /* Process new packet or the next packet in a scatterlist */
+ if (aes_con->flag & PROCESS_NEW_PACKET) {
+ aes_con->flag = PROCESS_SCATTER;
+ err = process_next_packet(aes_con, areq, PROCESS_NEW_PACKET);
+ }
+ else
+ err = process_next_packet(aes_con, areq, PROCESS_SCATTER);
+
+ if (err == -EINVAL) {
+ areq->base.complete(&areq->base, err);
+ lq_sg_complete(aes_con);
+ printk("src/dst returned -EINVAL in func: %s\n", __func__);
+ }
+ else if (err > 0) {
+ printk("src/dst returned zero in func: %s\n", __func__);
+ goto aes_done;
+ }
+
+ continue;
+
+aes_done:
+ //printk("debug line - %d, func: %s, qlen: %d\n", __LINE__, __func__, aes_queue->list.qlen);
+ areq->base.complete(&areq->base, 0);
+ lq_sg_complete(aes_con);
+
+ spin_lock_irqsave(&aes_queue->lock, queue_flag);
+ if (aes_queue->list.qlen > 0) {
+ spin_unlock_irqrestore(&aes_queue->lock, queue_flag);
+ tasklet_schedule(&aes_queue->aes_task);
+ }
+ else {
+ aes_queue->hw_status = AES_IDLE;
+ spin_unlock_irqrestore(&aes_queue->lock, queue_flag);
+ }
+ } //while(1)
+
+ return 0;
+}
+
+/* \fn static int lq_aes_queue_mgr(struct aes_ctx *ctx, struct ablkcipher_request *areq,
+ u8 *iv, int dir, int mode)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief starts the process of queuing DEU requests
+ * \param *ctx crypto algo contax
+ * \param *areq Pointer to the balkcipher requests
+ * \param *iv Pointer to intput vector location
+ * \param dir Encrypt/Decrypt
+ * \mode The mode AES algo is running
+ * \return 0 if success
+*/
+
+static int lq_aes_queue_mgr(struct aes_ctx *ctx, struct ablkcipher_request *areq,
+ u8 *iv, int dir, int mode)
+{
+ int err = -EINVAL;
+ unsigned long queue_flag;
+ struct scatterlist *src = areq->src;
+ struct scatterlist *dst = areq->dst;
+ struct aes_container *aes_con = NULL;
+ u32 remain, inc, nbytes = areq->nbytes;
+ u32 chunk_bytes = src->length;
+
+
+ aes_con = (struct aes_container *)kmalloc(sizeof(struct aes_container),
+ GFP_KERNEL);
+
+ if (!(aes_con)) {
+ printk("Cannot allocate memory for AES container, fn %s, ln %d\n",
+ __func__, __LINE__);
+ return -ENOMEM;
+ }
+
+ /* AES encrypt/decrypt mode */
+ if (mode == 5) {
+ nbytes = AES_BLOCK_SIZE;
+ chunk_bytes = AES_BLOCK_SIZE;
+ mode = 0;
+ }
+
+ aes_con->bytes_processed = nbytes;
+ aes_con->arequest = *(areq);
+ remain = nbytes;
+
+ //printk("debug - Line: %d, func: %s, reqsize: %d, scattersize: %d\n",
+ // __LINE__, __func__, nbytes, chunk_bytes);
+
+ if (remain > DEU_MAX_PACKET_SIZE)
+ inc = DEU_MAX_PACKET_SIZE;
+ else if (remain > chunk_bytes)
+ inc = chunk_bytes;
+ else
+ inc = remain;
+
+ remain -= inc;
+ lq_sg_init(aes_con, src, dst);
+
+ if (remain <= 0)
+ aes_con->complete = 1;
+ else
+ aes_con->complete = 0;
+
+ aes_con->nbytes = inc;
+ aes_con->iv = iv;
+ aes_con->mode = mode;
+ aes_con->encdec = dir;
+
+ spin_lock_irqsave(&aes_queue->lock, queue_flag);
+
+ if (aes_queue->hw_status == AES_STARTED || aes_queue->hw_status == AES_BUSY ||
+ aes_queue->list.qlen > 0) {
+
+ aes_con->flag = PROCESS_NEW_PACKET;
+ err = ablkcipher_enqueue_request(&aes_queue->list, &aes_con->arequest);
+
+ /* max queue length reached */
+ if (err == -EBUSY) {
+ spin_unlock_irqrestore(&aes_queue->lock, queue_flag);
+ printk("Unable to enqueue request ln: %d, err: %d\n", __LINE__, err);
+ return err;
+ }
+
+ spin_unlock_irqrestore(&aes_queue->lock, queue_flag);
+ return -EINPROGRESS;
+ }
+ else if (aes_queue->hw_status == AES_IDLE)
+ aes_queue->hw_status = AES_STARTED;
+
+ aes_con->flag = PROCESS_SCATTER;
+ aes_con->bytes_processed -= aes_con->nbytes;
+ /* or enqueue the whole structure so as to get back the info
+ * at the moment that it's queued. nbytes might be different */
+ err = ablkcipher_enqueue_request(&aes_queue->list, &aes_con->arequest);
+
+ if (err == -EBUSY) {
+ spin_unlock_irqrestore(&aes_queue->lock, queue_flag);
+ printk("Unable to enqueue request ln: %d, err: %d\n", __LINE__, err);
+ return err;
+ }
+
+ spin_unlock_irqrestore(&aes_queue->lock, queue_flag);
+ return lq_deu_aes_core(ctx, aes_con->dst_buf, aes_con->src_buf, iv, inc, dir, mode);
+
+}
+
+/* \fn static int aes_setkey(struct crypto_ablkcipher *tfm, const u8 *in_key,
+ * unsigned int keylen)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief Sets AES key
+ * \param *tfm Pointer to the ablkcipher transform
+ * \param *in_key Pointer to input keys
+ * \param key_len Length of the AES keys
+ * \return 0 is success, -EINVAL if bad key length
+*/
+
+static int aes_setkey(struct crypto_ablkcipher *tfm, const u8 *in_key,
+ unsigned int keylen)
+{
+ struct aes_ctx *ctx = crypto_ablkcipher_ctx(tfm);
+ unsigned long *flags = (unsigned long *) &tfm->base.crt_flags;
+
+ DPRINTF(2, "set_key in %s\n", __FILE__);
+
+ if (keylen != 16 && keylen != 24 && keylen != 32) {
+ *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
+ return -EINVAL;
+ }
+
+ ctx->key_length = keylen;
+ DPRINTF(0, "ctx @%p, keylen %d, ctx->key_length %d\n", ctx, keylen, ctx->key_length);
+ memcpy ((u8 *) (ctx->buf), in_key, keylen);
+
+ return 0;
+
+}
+
+/* \fn static int aes_generic_setkey(struct crypto_ablkcipher *tfm, const u8 *in_key,
+ * unsigned int keylen)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief Sets AES key
+ * \param *tfm Pointer to the ablkcipher transform
+ * \param *key Pointer to input keys
+ * \param keylen Length of AES keys
+ * \return 0 is success, -EINVAL if bad key length
+*/
+
+static int aes_generic_setkey(struct crypto_ablkcipher *tfm, const u8 *key,
+ unsigned int keylen)
+{
+ return aes_setkey(tfm, key, keylen);
+}
+
+/* \fn static int rfc3686_aes_setkey(struct crypto_ablkcipher *tfm, const u8 *in_key,
+ * unsigned int keylen)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief Sets AES key
+ * \param *tfm Pointer to the ablkcipher transform
+ * \param *in_key Pointer to input keys
+ * \param key_len Length of the AES keys
+ * \return 0 is success, -EINVAL if bad key length
+*/
+
+static int rfc3686_aes_setkey(struct crypto_ablkcipher *tfm,
+ const u8 *in_key, unsigned int keylen)
+{
+ struct aes_ctx *ctx = crypto_ablkcipher_ctx(tfm);
+ unsigned long *flags = (unsigned long *)&tfm->base.crt_flags;
+
+ DPRINTF(2, "ctr_rfc3686_aes_set_key in %s\n", __FILE__);
+
+ memcpy(ctx->nonce, in_key + (keylen - CTR_RFC3686_NONCE_SIZE),
+ CTR_RFC3686_NONCE_SIZE);
+
+ keylen -= CTR_RFC3686_NONCE_SIZE; // remove 4 bytes of nonce
+
+ if (keylen != 16 && keylen != 24 && keylen != 32) {
+ *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
+ return -EINVAL;
+ }
+
+ ctx->key_length = keylen;
+
+ memcpy ((u8 *) (ctx->buf), in_key, keylen);
+
+ return 0;
+}
+
+/* \fn static int aes_encrypt(struct ablkcipher_request *areq)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief Encrypt function for AES algo
+ * \param *areq Pointer to ablkcipher request in memory
+ * \return 0 is success, -EINPROGRESS if encryting, EINVAL if failure
+*/
+
+static int aes_encrypt (struct ablkcipher_request *areq)
+{
+ struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
+ struct aes_ctx *ctx = crypto_ablkcipher_ctx(cipher);
+
+ return lq_aes_queue_mgr(ctx, areq, NULL, CRYPTO_DIR_ENCRYPT, 5);
+
+}
+
+/* \fn static int aes_decrypt(struct ablkcipher_request *areq)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief Decrypt function for AES algo
+ * \param *areq Pointer to ablkcipher request in memory
+ * \return 0 is success, -EINPROGRESS if encryting, EINVAL if failure
+*/
+static int aes_decrypt (struct ablkcipher_request *areq)
+{
+ struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
+ struct aes_ctx *ctx = crypto_ablkcipher_ctx(cipher);
+
+ return lq_aes_queue_mgr(ctx, areq, NULL, CRYPTO_DIR_DECRYPT, 5);
+}
+
+/* \fn static int ecb_aes_decrypt(struct ablkcipher_request *areq)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief Encrypt function for AES algo
+ * \param *areq Pointer to ablkcipher request in memory
+ * \return 0 is success, -EINPROGRESS if encryting, EINVAL if failure
+*/
+
+static int ecb_aes_encrypt (struct ablkcipher_request *areq)
+{
+ struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
+ struct aes_ctx *ctx = crypto_ablkcipher_ctx(cipher);
+
+ return lq_aes_queue_mgr(ctx, areq, areq->info, CRYPTO_DIR_ENCRYPT, 0);
+
+}
+/* \fn static int ecb_aes_decrypt(struct ablkcipher_request *areq)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief Decrypt function for AES algo
+ * \param *areq Pointer to ablkcipher request in memory
+ * \return 0 is success, -EINPROGRESS if encryting, EINVAL if failure
+*/
+static int ecb_aes_decrypt(struct ablkcipher_request *areq)
+
+{
+ struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
+ struct aes_ctx *ctx = crypto_ablkcipher_ctx(cipher);
+
+ return lq_aes_queue_mgr(ctx, areq, areq->info, CRYPTO_DIR_DECRYPT, 0);
+}
+
+/* \fn static int cbc_aes_encrypt(struct ablkcipher_request *areq)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief Encrypt function for AES algo
+ * \param *areq Pointer to ablkcipher request in memory
+ * \return 0 is success, -EINPROGRESS if encryting, EINVAL if failure
+*/
+
+static int cbc_aes_encrypt (struct ablkcipher_request *areq)
+{
+ struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
+ struct aes_ctx *ctx = crypto_ablkcipher_ctx(cipher);
+
+ return lq_aes_queue_mgr(ctx, areq, areq->info, CRYPTO_DIR_ENCRYPT, 1);
+
+}
+
+/* \fn static int cbc_aes_decrypt(struct ablkcipher_request *areq)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief Decrypt function for AES algo
+ * \param *areq Pointer to ablkcipher request in memory
+ * \return 0 is success, -EINPROGRESS if encryting, EINVAL if failure
+*/
+
+static int cbc_aes_decrypt(struct ablkcipher_request *areq)
+{
+ struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
+ struct aes_ctx *ctx = crypto_ablkcipher_ctx(cipher);
+
+ return lq_aes_queue_mgr(ctx, areq, areq->info, CRYPTO_DIR_DECRYPT, 1);
+}
+#if 0
+static int ofb_aes_encrypt (struct ablkcipher_request *areq)
+{
+ struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
+ struct aes_ctx *ctx = crypto_ablkcipher_ctx(cipher);
+
+ return lq_aes_queue_mgr(ctx, areq, areq->info, CRYPTO_DIR_ENCRYPT, 2);
+
+}
+
+static int ofb_aes_decrypt(struct ablkcipher_request *areq)
+{
+ struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
+ struct aes_ctx *ctx = crypto_ablkcipher_ctx(cipher);
+
+ return lq_aes_queue_mgr(ctx, areq, areq->info, CRYPTO_DIR_DECRYPT, 2);
+}
+
+static int cfb_aes_encrypt (struct ablkcipher_request *areq)
+{
+ struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
+ struct aes_ctx *ctx = crypto_ablkcipher_ctx(cipher);
+
+ return lq_aes_queue_mgr(ctx, areq, areq->info, CRYPTO_DIR_ENCRYPT, 3);
+
+}
+
+static int cfb_aes_decrypt(struct ablkcipher_request *areq)
+{
+ struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
+ struct aes_ctx *ctx = crypto_ablkcipher_ctx(cipher);
+
+ return lq_aes_queue_mgr(ctx, areq, areq->info, CRYPTO_DIR_DECRYPT, 3);
+}
+#endif
+
+/* \fn static int ctr_aes_encrypt(struct ablkcipher_request *areq)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief Encrypt function for AES algo
+ * \param *areq Pointer to ablkcipher request in memory
+ * \return 0 is success, -EINPROGRESS if encryting, EINVAL if failure
+*/
+
+static int ctr_aes_encrypt (struct ablkcipher_request *areq)
+{
+ struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
+ struct aes_ctx *ctx = crypto_ablkcipher_ctx(cipher);
+
+ return lq_aes_queue_mgr(ctx, areq, areq->info, CRYPTO_DIR_ENCRYPT, 4);
+
+}
+
+/* \fn static int ctr_aes_decrypt(struct ablkcipher_request *areq)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief Decrypt function for AES algo
+ * \param *areq Pointer to ablkcipher request in memory
+ * \return 0 is success, -EINPROGRESS if encryting, EINVAL if failure
+*/
+
+static int ctr_aes_decrypt(struct ablkcipher_request *areq)
+{
+ struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
+ struct aes_ctx *ctx = crypto_ablkcipher_ctx(cipher);
+
+ return lq_aes_queue_mgr(ctx, areq, areq->info, CRYPTO_DIR_DECRYPT, 4);
+}
+
+/* \fn static int rfc3686_aes_encrypt(struct ablkcipher_request *areq)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief Encrypt function for AES algo
+ * \param *areq Pointer to ablkcipher request in memory
+ * \return 0 is success, -EINPROGRESS if encryting, EINVAL if failure
+*/
+
+static int rfc3686_aes_encrypt(struct ablkcipher_request *areq)
+{
+ struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
+ struct aes_ctx *ctx = crypto_ablkcipher_ctx(cipher);
+ int ret;
+ u8 *info = areq->info;
+ u8 rfc3686_iv[16];
+
+ memcpy(rfc3686_iv, ctx->nonce, CTR_RFC3686_NONCE_SIZE);
+ memcpy(rfc3686_iv + CTR_RFC3686_NONCE_SIZE, info, CTR_RFC3686_IV_SIZE);
+
+ /* initialize counter portion of counter block */
+ *(__be32 *)(rfc3686_iv + CTR_RFC3686_NONCE_SIZE + CTR_RFC3686_IV_SIZE) =
+ cpu_to_be32(1);
+
+ areq->info = rfc3686_iv;
+ ret = lq_aes_queue_mgr(ctx, areq, areq->info, CRYPTO_DIR_ENCRYPT, 4);
+ areq->info = info;
+ return ret;
+}
+
+/* \fn static int rfc3686_aes_decrypt(struct ablkcipher_request *areq)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief Decrypt function for AES algo
+ * \param *areq Pointer to ablkcipher request in memory
+ * \return 0 is success, -EINPROGRESS if encryting, EINVAL if failure
+*/
+
+static int rfc3686_aes_decrypt(struct ablkcipher_request *areq)
+{
+ struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
+ struct aes_ctx *ctx = crypto_ablkcipher_ctx(cipher);
+ int ret;
+ u8 *info = areq->info;
+ u8 rfc3686_iv[16];
+
+ /* set up counter block */
+ memcpy(rfc3686_iv, ctx->nonce, CTR_RFC3686_NONCE_SIZE);
+ memcpy(rfc3686_iv + CTR_RFC3686_NONCE_SIZE, info, CTR_RFC3686_IV_SIZE);
+
+ /* initialize counter portion of counter block */
+ *(__be32 *)(rfc3686_iv + CTR_RFC3686_NONCE_SIZE + CTR_RFC3686_IV_SIZE) =
+ cpu_to_be32(1);
+
+ areq->info = rfc3686_iv;
+ ret = lq_aes_queue_mgr(ctx, areq, areq->info, CRYPTO_DIR_DECRYPT, 4);
+ areq->info = info;
+ return ret;
+}
+
+struct lq_aes_alg {
+ struct crypto_alg alg;
+};
+
+/* AES supported algo array */
+static struct lq_aes_alg aes_drivers_alg[] = {
+ {
+ .alg = {
+ .cra_name = "aes",
+ .cra_driver_name = "ifxdeu-aes",
+ .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
+ .cra_blocksize = AES_BLOCK_SIZE,
+ .cra_ctxsize = sizeof(struct aes_ctx),
+ .cra_type = &crypto_ablkcipher_type,
+ .cra_priority = 300,
+ .cra_module = THIS_MODULE,
+ .cra_ablkcipher = {
+ .setkey = aes_setkey,
+ .encrypt = aes_encrypt,
+ .decrypt = aes_decrypt,
+ .geniv = "eseqiv",
+ .min_keysize = AES_MIN_KEY_SIZE,
+ .max_keysize = AES_MAX_KEY_SIZE,
+ .ivsize = AES_BLOCK_SIZE,
+ }
+ }
+ },{
+ .alg = {
+ .cra_name = "ecb(aes)",
+ .cra_driver_name = "ifxdeu-ecb(aes)",
+ .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
+ .cra_blocksize = AES_BLOCK_SIZE,
+ .cra_ctxsize = sizeof(struct aes_ctx),
+ .cra_type = &crypto_ablkcipher_type,
+ .cra_priority = 300,
+ .cra_module = THIS_MODULE,
+ .cra_ablkcipher = {
+ .setkey = aes_generic_setkey,
+ .encrypt = ecb_aes_encrypt,
+ .decrypt = ecb_aes_decrypt,
+ .geniv = "eseqiv",
+ .min_keysize = AES_MIN_KEY_SIZE,
+ .max_keysize = AES_MAX_KEY_SIZE,
+ .ivsize = AES_BLOCK_SIZE,
+ }
+ }
+ },{
+ .alg = {
+ .cra_name = "cbc(aes)",
+ .cra_driver_name = "ifxdeu-cbc(aes)",
+ .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
+ .cra_blocksize = AES_BLOCK_SIZE,
+ .cra_ctxsize = sizeof(struct aes_ctx),
+ .cra_type = &crypto_ablkcipher_type,
+ .cra_priority = 300,
+ .cra_module = THIS_MODULE,
+ .cra_ablkcipher = {
+ .setkey = aes_generic_setkey,
+ .encrypt = cbc_aes_encrypt,
+ .decrypt = cbc_aes_decrypt,
+ .geniv = "eseqiv",
+ .min_keysize = AES_MIN_KEY_SIZE,
+ .max_keysize = AES_MAX_KEY_SIZE,
+ .ivsize = AES_BLOCK_SIZE,
+ }
+ }
+ },{
+ .alg = {
+ .cra_name = "ctr(aes)",
+ .cra_driver_name = "ifxdeu-ctr(aes)",
+ .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
+ .cra_blocksize = AES_BLOCK_SIZE,
+ .cra_ctxsize = sizeof(struct aes_ctx),
+ .cra_type = &crypto_ablkcipher_type,
+ .cra_priority = 300,
+ .cra_module = THIS_MODULE,
+ .cra_ablkcipher = {
+ .setkey = aes_generic_setkey,
+ .encrypt = ctr_aes_encrypt,
+ .decrypt = ctr_aes_decrypt,
+ .geniv = "eseqiv",
+ .min_keysize = AES_MIN_KEY_SIZE,
+ .max_keysize = AES_MAX_KEY_SIZE,
+ .ivsize = AES_BLOCK_SIZE,
+ }
+ }
+ },{
+ .alg = {
+ .cra_name = "rfc3686(ctr(aes))",
+ .cra_driver_name = "ifxdeu-rfc3686(ctr(aes))",
+ .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
+ .cra_blocksize = AES_BLOCK_SIZE,
+ .cra_ctxsize = sizeof(struct aes_ctx),
+ .cra_type = &crypto_ablkcipher_type,
+ .cra_priority = 300,
+ .cra_module = THIS_MODULE,
+ .cra_ablkcipher = {
+ .setkey = rfc3686_aes_setkey,
+ .encrypt = rfc3686_aes_encrypt,
+ .decrypt = rfc3686_aes_decrypt,
+ .geniv = "eseqiv",
+ .min_keysize = AES_MIN_KEY_SIZE,
+ .max_keysize = CTR_RFC3686_MAX_KEY_SIZE,
+ //.max_keysize = AES_MAX_KEY_SIZE,
+ //.ivsize = CTR_RFC3686_IV_SIZE,
+ .ivsize = AES_BLOCK_SIZE, // else cannot reg
+ }
+ }
+ }
+};
+
+/* \fn int __init lqdeu_async_aes_init (void)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief Initializes the Async. AES driver
+ * \return 0 is success, -EINPROGRESS if encryting, EINVAL if failure
+*/
+
+int __init lqdeu_async_aes_init (void)
+{
+ int i, j, ret = -EINVAL;
+
+#define IFX_DEU_DRV_VERSION "2.0.0"
+ printk(KERN_INFO "Lantiq Technologies DEU Driver version %s\n", IFX_DEU_DRV_VERSION);
+
+ for (i = 0; i < ARRAY_SIZE(aes_drivers_alg); i++) {
+ ret = crypto_register_alg(&aes_drivers_alg[i].alg);
+ printk("driver: %s\n", aes_drivers_alg[i].alg.cra_name);
+ if (ret)
+ goto aes_err;
+ }
+
+ aes_chip_init();
+
+ CRTCL_SECT_INIT;
+
+
+ printk (KERN_NOTICE "Lantiq DEU AES initialized %s %s.\n",
+ disable_multiblock ? "" : " (multiblock)", disable_deudma ? "" : " (DMA)");
+
+ return ret;
+
+aes_err:
+
+ for (j = 0; j < i; j++)
+ crypto_unregister_alg(&aes_drivers_alg[j].alg);
+
+ printk(KERN_ERR "Lantiq %s driver initialization failed!\n", (char *)&aes_drivers_alg[i].alg.cra_driver_name);
+ return ret;
+
+ctr_rfc3686_aes_err:
+ for (i = 0; i < ARRAY_SIZE(aes_drivers_alg); i++) {
+ if (!strcmp((char *)&aes_drivers_alg[i].alg.cra_name, "rfc3686(ctr(aes))"))
+ crypto_unregister_alg(&aes_drivers_alg[j].alg);
+ }
+ printk (KERN_ERR "Lantiq ctr_rfc3686_aes initialization failed!\n");
+ return ret;
+}
+
+/*! \fn void __exit ifxdeu_fini_aes (void)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief unregister aes driver
+*/
+void __exit lqdeu_fini_async_aes (void)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(aes_drivers_alg); i++)
+ crypto_unregister_alg(&aes_drivers_alg[i].alg);
+
+ aes_queue->hw_status = AES_COMPLETED;
+
+ DEU_WAKEUP_EVENT(deu_dma_priv.deu_thread_wait, AES_ASYNC_EVENT,
+ deu_dma_priv.aes_event_flags);
+
+ kfree(aes_queue);
+
+}
diff --git a/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_async_des.c.svn-base b/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_async_des.c.svn-base
new file mode 100644
index 0000000..9c593ae
--- /dev/null
+++ b/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_async_des.c.svn-base
@@ -0,0 +1,954 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_async_des.c
+** PROJECT : IFX UEIP
+** MODULES : DEU Module
+**
+** DATE : October 11, 2010
+** AUTHOR : Mohammad Firdaus
+** DESCRIPTION : Data Encryption Unit Driver for DES Algorithm
+** COPYRIGHT : Copyright (c) 2010
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 08,Sept 2009 Mohammad Firdaus Initial UEIP release
+** 11, Oct 2010 Mohammad Firdaus Kernel Port incl. Async. Ablkcipher mode
+** 21,March 2011 Mohammad Firdaus Changes for Kernel 2.6.32 and IPSec integration
+*******************************************************************************/
+/*!
+ \defgroup IFX_DEU IFX_DEU_DRIVERS
+ \ingroup API
+ \brief ifx DEU driver module
+*/
+
+/*!
+ \file ifxmips_async_des.c
+ \ingroup IFX_DEU
+ \brief DES Encryption Driver main file
+*/
+
+/*!
+ \defgroup IFX_DES_FUNCTIONS IFX_DES_FUNCTIONS
+ \ingroup IFX_DEU
+ \brief IFX DES driver Functions
+*/
+
+#include <linux/wait.h>
+#include <linux/crypto.h>
+#include <linux/kernel.h>
+#include <linux/interrupt.h>
+#include <linux/spinlock.h>
+#include <linux/list.h>
+#include <crypto/ctr.h>
+#include <crypto/aes.h>
+#include <crypto/algapi.h>
+#include <crypto/scatterwalk.h>
+
+#include <asm/ifx/ifx_regs.h>
+#include <asm/ifx/ifx_types.h>
+#include <asm/ifx/common_routines.h>
+#include <asm/ifx/irq.h>
+#include <asm/ifx/ifx_pmu.h>
+#include <asm/ifx/ifx_gpio.h>
+#include <asm/kmap_types.h>
+
+#include "ifxmips_deu.h"
+
+#if defined(CONFIG_DANUBE)
+#include "ifxmips_deu_danube.h"
+extern int ifx_danube_pre_1_4;
+#elif defined(CONFIG_AR9)
+#include "ifxmips_deu_ar9.h"
+#elif defined(CONFIG_VR9) || defined(CONFIG_AR10)
+#include "ifxmips_deu_vr9.h"
+#else
+#error "Unkown platform"
+#endif
+
+/* DMA specific header and variables */
+
+spinlock_t des_lock;
+#define CRTCL_SECT_INIT spin_lock_init(&des_lock)
+#define CRTCL_SECT_START spin_lock_irqsave(&des_lock, flag)
+#define CRTCL_SECT_END spin_unlock_irqrestore(&des_lock, flag)
+
+/* Preprocessor declerations */
+#ifdef CRYPTO_DEBUG
+extern char debug_level;
+#define DPRINTF(level, format, args...) if (level < debug_level) printk(KERN_INFO "[%s %s %d]: " format, __FILE__, __func__, __LINE__, ##args);
+#else
+#define DPRINTF(level, format, args...)
+#endif
+//#define DES_3DES_START IFX_DES_CON
+#define DES_KEY_SIZE 8
+#define DES_EXPKEY_WORDS 32
+#define DES_BLOCK_SIZE 8
+#define DES3_EDE_KEY_SIZE (3 * DES_KEY_SIZE)
+#define DES3_EDE_EXPKEY_WORDS (3 * DES_EXPKEY_WORDS)
+#define DES3_EDE_BLOCK_SIZE DES_BLOCK_SIZE
+
+/* Function Declaration to prevent warning messages */
+void des_chip_init (void);
+u32 endian_swap(u32 input);
+u32 input_swap(u32 input);
+int aes_memory_allocate(int value);
+int des_memory_allocate(int value);
+void memory_release(u32 *buffer);
+u32* memory_alignment(const u8 *arg, u32 *buff_alloc, int in_out, int nbytes);
+void aes_dma_memory_copy(u32 *outcopy, u32 *out_dma, u8 *out_arg, int nbytes);
+void des_dma_memory_copy(u32 *outcopy, u32 *out_dma, u8 *out_arg, int nbytes);
+
+static int lq_deu_des_core (void *ctx_arg, u8 *out_arg, const u8 *in_arg,
+ u8 *iv_arg, u32 nbytes, int encdec, int mode);
+
+struct des_ctx {
+ int controlr_M;
+ int key_length;
+ u8 iv[DES_BLOCK_SIZE];
+ u32 expkey[DES3_EDE_EXPKEY_WORDS];
+};
+
+
+static int disable_multiblock = 0;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
+module_param(disable_multiblock, int, 0);
+#else
+MODULE_PARM_DESC(disable_multiblock, "Disable encryption of whole multiblock buffers");
+#endif
+
+static int disable_deudma = 1;
+
+struct des_container {
+ u8 *iv;
+ u8 *dst_buf;
+ u8 *src_buf;
+ int mode;
+ int encdec;
+ int complete;
+ int flag;
+
+ u32 bytes_processed;
+ u32 nbytes;
+
+ struct ablkcipher_request arequest;
+};
+
+des_priv_t *des_queue;
+extern deu_drv_priv_t deu_dma_priv;
+
+void hexdump1(unsigned char *buf, unsigned int len)
+{
+ print_hex_dump(KERN_CONT, "", DUMP_PREFIX_OFFSET,
+ 16, 1,
+ buf, len, false);
+}
+
+
+/*! \fn int lq_des_setkey(struct crypto_ablkcipher *tfm, const u8 *key, unsigned int keylen)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief sets DES key
+ * \param tfm linux crypto algo transform
+ * \param key input key
+ * \param keylen key length
+*/
+static int lq_des_setkey(struct crypto_ablkcipher *tfm, const u8 *key,
+ unsigned int keylen)
+{
+ struct des_ctx *dctx = crypto_ablkcipher_ctx(tfm);
+
+ //printk("setkey in %s\n", __FILE__);
+
+ dctx->controlr_M = 0; // des
+ dctx->key_length = keylen;
+
+ memcpy ((u8 *) (dctx->expkey), key, keylen);
+
+ return 0;
+}
+
+/*! \fn int lq_des3_ede_setkey(struct crypto_ablkcipher *tfm, const u8 *key, unsigned int keylen)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief sets DES key
+ * \param tfm linux crypto algo transform
+ * \param key input key
+ * \param keylen key length
+*/
+
+static int lq_des3_ede_setkey(struct crypto_ablkcipher *tfm, const u8 *in_key,
+ unsigned int keylen)
+{
+ struct des_ctx *dctx = crypto_ablkcipher_ctx(tfm);
+
+ //printk("setkey in %s\n", __FILE__);
+
+ dctx->controlr_M = keylen/8 + 1; // des
+ dctx->key_length = keylen;
+
+ memcpy ((u8 *) (dctx->expkey), in_key, keylen);
+
+ return 0;
+}
+
+/*! \fn void ifx_deu_des_core(void *ctx_arg, u8 *out_arg, const u8 *in_arg, u8 *iv_arg, u32 nbytes, int encdec, int mode)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief main interface to DES hardware
+ * \param ctx_arg crypto algo context
+ * \param out_arg output bytestream
+ * \param in_arg input bytestream
+ * \param iv_arg initialization vector
+ * \param nbytes length of bytestream
+ * \param encdec 1 for encrypt; 0 for decrypt
+ * \param mode operation mode such as ebc, cbc
+*/
+
+static int lq_deu_des_core (void *ctx_arg, u8 *out_arg, const u8 *in_arg,
+ u8 *iv_arg, u32 nbytes, int encdec, int mode)
+{
+ volatile struct des_t *des = (struct des_t *) DES_3DES_START;
+ struct des_ctx *dctx = ctx_arg;
+ u32 *key = dctx->expkey;
+ unsigned long flag;
+
+ int i = 0;
+ int nblocks = 0;
+
+ CRTCL_SECT_START;
+
+ des->controlr.M = dctx->controlr_M;
+ if (dctx->controlr_M == 0) // des
+ {
+ des->K1HR = DEU_ENDIAN_SWAP(*((u32 *) key + 0));
+ des->K1LR = DEU_ENDIAN_SWAP(*((u32 *) key + 1));
+
+ }
+ else {
+ /* Hardware Section */
+ switch (dctx->key_length) {
+ case 24:
+ des->K3HR = DEU_ENDIAN_SWAP(*((u32 *) key + 4));
+ des->K3LR = DEU_ENDIAN_SWAP(*((u32 *) key + 5));
+ /* no break; */
+
+ case 16:
+ des->K2HR = DEU_ENDIAN_SWAP(*((u32 *) key + 2));
+ des->K2LR = DEU_ENDIAN_SWAP(*((u32 *) key + 3));
+
+ /* no break; */
+ case 8:
+ des->K1HR = DEU_ENDIAN_SWAP(*((u32 *) key + 0));
+ des->K1LR = DEU_ENDIAN_SWAP(*((u32 *) key + 1));
+ break;
+
+ default:
+ CRTCL_SECT_END;
+ return -EINVAL;
+ }
+ }
+
+ des->controlr.E_D = !encdec; //encryption
+ des->controlr.O = mode; //0 ECB 1 CBC 2 OFB 3 CFB 4 CTR hexdump(prin,sizeof(*des));
+
+ if (mode > 0) {
+ des->IVHR = DEU_ENDIAN_SWAP(*(u32 *) iv_arg);
+ des->IVLR = DEU_ENDIAN_SWAP(*((u32 *) iv_arg + 1));
+ };
+
+ /* memory alignment issue */
+ dword_mem_aligned_in = (u32 *) DEU_DWORD_REORDERING(in_arg, des_buff_in, BUFFER_IN, nbytes);
+
+ deu_priv->deu_rx_buf = (u32 *) out_arg;
+ deu_priv->deu_rx_len = nbytes;
+
+ dma->controlr.ALGO = 0; //DES
+ des->controlr.DAU = 0;
+ dma->controlr.BS = 0;
+ dma->controlr.EN = 1;
+
+ while (des->controlr.BUS) {
+ };
+
+ wlen = dma_device_write (dma_device, (u8 *) dword_mem_aligned_in, nbytes, NULL);
+ if (wlen != nbytes) {
+ dma->controlr.EN = 0;
+ CRTCL_SECT_END;
+ printk (KERN_ERR "[%s %s %d]: dma_device_write fail!\n", __FILE__, __func__, __LINE__);
+ return -EINVAL;
+ }
+
+
+ /* Prepare Rx buf length used in dma psuedo interrupt */
+ outcopy = (u32 *) DEU_DWORD_REORDERING(out_arg, des_buff_out, BUFFER_OUT, nbytes);
+ deu_priv->outcopy = outcopy;
+ deu_priv->event_src = DES_ASYNC_EVENT;
+
+ if (mode > 0) {
+ *(u32 *) iv_arg = DEU_ENDIAN_SWAP(des->IVHR);
+ *((u32 *) iv_arg + 1) = DEU_ENDIAN_SWAP(des->IVLR);
+ };
+
+ CRTCL_SECT_END;
+
+ return -EINPROGRESS;
+
+}
+
+static int count_sgs(struct scatterlist *sl, unsigned int total_bytes)
+{
+ int i = 0;
+
+ do {
+ total_bytes -= sl[i].length;
+ i++;
+
+ } while (total_bytes > 0);
+
+ return i;
+}
+
+/* \fn static inline struct des_container *des_container_cast (
+ * struct scatterlist *dst)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief Locate the structure des_container in memory.
+ * \param *areq Pointer to memory location where ablkcipher_request is located
+ * \return *des_cointainer The function pointer to des_container
+*/
+
+static inline struct des_container *des_container_cast(
+ struct ablkcipher_request *areq)
+{
+ return container_of(areq, struct des_container, arequest);
+}
+
+/* \fn static void lq_sg_complete(struct des_container *des_con)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief Free the used up memory after encryt/decrypt.
+*/
+
+static void lq_sg_complete(struct des_container *des_con)
+{
+ unsigned long queue_flag;
+
+ spin_lock_irqsave(&des_queue->lock, queue_flag);
+ kfree(des_con);
+ spin_unlock_irqrestore(&des_queue->lock, queue_flag);
+}
+
+/* \fn void lq_sg_init(struct scatterlist *src,
+ * struct scatterlist *dst)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief Maps the scatterlists into a source/destination page.
+ * \param *src Pointer to the source scatterlist
+ * \param *dst Pointer to the destination scatterlist
+*/
+
+static void lq_sg_init(struct des_container *des_con, struct scatterlist *src,
+ struct scatterlist *dst)
+{
+ struct page *dst_page, *src_page;
+
+ src_page = sg_virt(src);
+ des_con->src_buf = (char *) src_page;
+
+ dst_page = sg_virt(dst);
+ des_con->dst_buf = (char *) dst_page;
+}
+
+/* \fn static int process_next_packet(struct des_container *des_con, struct ablkcipher_request *areq,
+ * int state)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief Process the next packet after dequeuing the packet from crypto queue
+ * \param *des_con Pointer to DES container structure
+ * \param *areq Pointer to ablkcipher_request container
+ * \param state State of the packet (scattered packet or new packet to be processed)
+ * \return -EINVAL: DEU failure, -EINPROGRESS: DEU encrypt/decrypt in progress, 1: no scatterlist left
+*/
+
+static int process_next_packet(struct des_container *des_con, struct ablkcipher_request *areq,
+ int state)
+{
+ u8 *iv;
+ int mode, encdec, err = -EINVAL;
+ u32 remain, inc, chunk_size, nbytes;
+ struct scatterlist *src = NULL;
+ struct scatterlist *dst = NULL;
+ struct crypto_ablkcipher *cipher;
+ struct des_ctx *ctx;
+ unsigned long queue_flag;
+
+ spin_lock_irqsave(&des_queue->lock, queue_flag);
+
+ mode = des_con->mode;
+ encdec = des_con->encdec;
+ iv = des_con->iv;
+
+ if (state & PROCESS_SCATTER) {
+ src = scatterwalk_sg_next(areq->src);
+ dst = scatterwalk_sg_next(areq->dst);
+
+ if (!src || !dst) {
+ spin_unlock_irqrestore(&des_queue->lock, queue_flag);
+ return 1;
+ }
+ }
+ else if (state & PROCESS_NEW_PACKET) {
+ src = areq->src;
+ dst = areq->dst;
+ }
+
+ remain = des_con->bytes_processed;
+ chunk_size = src->length;
+
+ //printk("debug ln: %d, func: %s, reqsize: %d, scattersize: %d\n",
+// __LINE__, __func__, areq->nbytes, chunk_size);
+
+ if (remain > DEU_MAX_PACKET_SIZE)
+ inc = DEU_MAX_PACKET_SIZE;
+ else if(remain > chunk_size)
+ inc = chunk_size;
+ else
+ inc = remain;
+
+ remain -= inc;
+ des_con->nbytes = inc;
+
+ if (state & PROCESS_SCATTER) {
+ des_con->src_buf += des_con->nbytes;
+ des_con->dst_buf += des_con->nbytes;
+ }
+
+ lq_sg_init(des_con, src, dst);
+
+ nbytes = des_con->nbytes;
+
+ cipher = crypto_ablkcipher_reqtfm(areq);
+ ctx = crypto_ablkcipher_ctx(cipher);
+
+ if (des_queue->hw_status == DES_IDLE) {
+ des_queue->hw_status = DES_STARTED;
+ }
+
+ des_con->bytes_processed -= des_con->nbytes;
+ err = ablkcipher_enqueue_request(&des_queue->list, &des_con->arequest);
+ if (err == -EBUSY) {
+ printk("Failed to enqueue request, ln: %d, err: %d\n",
+ __LINE__, err);
+ spin_unlock_irqrestore(&des_queue->lock, queue_flag);
+ return -EINVAL;
+ }
+
+ spin_unlock_irqrestore(&des_queue->lock, queue_flag);
+ err = lq_deu_des_core(ctx, des_con->dst_buf, des_con->src_buf, iv, nbytes, encdec, mode);
+
+ return err;
+}
+
+/* \fn static void process_queue(unsigned long data)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief Process next packet in queue
+ * \param data not used
+ * \return
+*/
+
+static void process_queue(unsigned long data)
+{
+ DEU_WAKEUP_EVENT(deu_dma_priv.deu_thread_wait, DES_ASYNC_EVENT,
+ deu_dma_priv.des_event_flags);
+
+}
+
+/* \fn static int des_crypto_thread (void *data)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief DES thread that handles crypto requests from upper layer & DMA
+ * \param *data Not used
+ * \return -EINVAL: DEU failure, -EBUSY: DEU HW busy, 0: exit thread
+*/
+
+static int des_crypto_thread(void *data)
+{
+ struct des_container *des_con = NULL;
+ struct ablkcipher_request *areq = NULL;
+ int err;
+ unsigned long queue_flag;
+
+ daemonize("lq_des_thread");
+
+ while (1)
+ {
+ DEU_WAIT_EVENT(deu_dma_priv.deu_thread_wait, DES_ASYNC_EVENT,
+ deu_dma_priv.des_event_flags);
+ spin_lock_irqsave(&des_queue->lock, queue_flag);
+
+ /* wait to prevent starting a crypto session before
+ * exiting the dma interrupt thread.
+ */
+
+ if (des_queue->hw_status == DES_STARTED) {
+ areq = ablkcipher_dequeue_request(&des_queue->list);
+ des_con = des_container_cast(areq);
+ des_queue->hw_status = DES_BUSY;
+ }
+ else if (des_queue->hw_status == DES_IDLE) {
+ areq = ablkcipher_dequeue_request(&des_queue->list);
+ des_con = des_container_cast(areq);
+ des_queue->hw_status = DES_STARTED;
+ }
+ else if (des_queue->hw_status == DES_BUSY) {
+ areq = ablkcipher_dequeue_request(&des_queue->list);
+ des_con = des_container_cast(areq);
+ }
+ else if (des_queue->hw_status == DES_COMPLETED) {
+ areq->base.complete(&areq->base, 0);
+ lq_sg_complete(des_con);
+ des_queue->hw_status = DES_IDLE;
+ spin_unlock_irqrestore(&des_queue->lock, queue_flag);
+ return 0;
+ }
+ spin_unlock_irqrestore(&des_queue->lock, queue_flag);
+
+ if ((des_con->bytes_processed == 0)) {
+ goto des_done;
+ }
+
+ if (!des_con) {
+ goto des_done;
+ }
+
+ if (des_con->flag & PROCESS_NEW_PACKET) {
+ des_con->flag = PROCESS_SCATTER;
+ err = process_next_packet(des_con, areq, PROCESS_NEW_PACKET);
+ }
+ else
+ err = process_next_packet(des_con, areq, PROCESS_SCATTER);
+
+ if (err == -EINVAL) {
+ areq->base.complete(&areq->base, err);
+ lq_sg_complete(des_con);
+ printk("src/dst returned -EINVAL in func: %s\n", __func__);
+ }
+ else if (err > 0) {
+ printk("src/dst returned zero in func: %s\n", __func__);
+ goto des_done;
+ }
+
+ continue;
+
+des_done:
+ //printk("debug line - %d, func: %s, qlen: %d\n", __LINE__, __func__, des_queue->list.qlen);
+ areq->base.complete(&areq->base, 0);
+ lq_sg_complete(des_con);
+
+ spin_lock_irqsave(&des_queue->lock, queue_flag);
+ if (des_queue->list.qlen > 0) {
+ spin_unlock_irqrestore(&des_queue->lock, queue_flag);
+ tasklet_schedule(&des_queue->des_task);
+ }
+ else {
+ des_queue->hw_status = DES_IDLE;
+ spin_unlock_irqrestore(&des_queue->lock, queue_flag);
+ }
+ } // while(1)
+
+ return 0;
+
+}
+
+/* \fn static int lq_des_queue_mgr(struct des_ctx *ctx, struct ablkcipher_request *areq,
+ u8 *iv, int encdec, int mode)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief starts the process of queuing DEU requests
+ * \param *ctx crypto algo contax
+ * \param *areq Pointer to the balkcipher requests
+ * \param *iv Pointer to intput vector location
+ * \param dir Encrypt/Decrypt
+ * \mode The mode DES algo is running
+ * \return 0 if success
+*/
+
+static int lq_queue_mgr(struct des_ctx *ctx, struct ablkcipher_request *areq,
+ u8 *iv, int encdec, int mode)
+{
+ int err = -EINVAL;
+ unsigned long queue_flag;
+ struct scatterlist *src = areq->src;
+ struct scatterlist *dst = areq->dst;
+ struct des_container *des_con = NULL;
+ u32 remain, inc, nbytes = areq->nbytes;
+ u32 chunk_bytes = src->length;
+
+ des_con = (struct des_container *)kmalloc(sizeof(struct des_container),
+ GFP_KERNEL);
+
+ if (!(des_con)) {
+ printk("Cannot allocate memory for AES container, fn %s, ln %d\n",
+ __func__, __LINE__);
+ return -ENOMEM;
+ }
+
+ /* DES encrypt/decrypt mode */
+ if (mode == 5) {
+ nbytes = DES_BLOCK_SIZE;
+ chunk_bytes = DES_BLOCK_SIZE;
+ mode = 0;
+ }
+
+ des_con->bytes_processed = nbytes;
+ des_con->arequest = (*areq);
+ remain = nbytes;
+
+ //printk("debug - Line: %d, func: %s, reqsize: %d, scattersize: %d\n",
+ // __LINE__, __func__, nbytes, chunk_bytes);
+
+ if (remain > DEU_MAX_PACKET_SIZE)
+ inc = DEU_MAX_PACKET_SIZE;
+ else if(remain > chunk_bytes)
+ inc = chunk_bytes;
+ else
+ inc = remain;
+
+ remain -= inc;
+ lq_sg_init(des_con, src, dst);
+
+ if (remain <= 0 ) {
+ des_con->complete = 1;
+ }
+ else
+ des_con->complete = 0;
+
+ des_con->nbytes = inc;
+ des_con->iv = iv;
+ des_con->mode = mode;
+ des_con->encdec = encdec;
+
+ spin_lock_irqsave(&des_queue->lock, queue_flag);
+
+ if (des_queue->hw_status == DES_STARTED || des_queue->hw_status == DES_BUSY ||
+ des_queue->list.qlen > 0) {
+
+ des_con->flag = PROCESS_NEW_PACKET;
+ err = ablkcipher_enqueue_request(&des_queue->list, &des_con->arequest);
+ if (err == -EBUSY) {
+ spin_unlock_irqrestore(&des_queue->lock, queue_flag);
+ printk("Fail to enqueue ablkcipher request ln: %d, err: %d\n",
+ __LINE__, err);
+ return err;
+ }
+
+ spin_unlock_irqrestore(&des_queue->lock, queue_flag);
+ return -EINPROGRESS;
+
+ }
+ else if (des_queue->hw_status == DES_IDLE) {
+ des_queue->hw_status = DES_STARTED;
+ }
+
+ des_con->flag = PROCESS_SCATTER;
+ des_con->bytes_processed -= des_con->nbytes;
+
+ err = ablkcipher_enqueue_request(&des_queue->list, &des_con->arequest);
+ if (err == -EBUSY) {
+ printk("Fail to enqueue ablkcipher request ln: %d, err: %d\n",
+ __LINE__, err);
+
+ spin_unlock_irqrestore(&des_queue->lock, queue_flag);
+ return err;
+ }
+
+ spin_unlock_irqrestore(&des_queue->lock, queue_flag);
+ return lq_deu_des_core(ctx, des_con->dst_buf, des_con->src_buf, iv, inc, encdec, mode);
+
+}
+
+/* \fn static int lq_des_encrypt(struct ablkcipher_request *areq)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief Decrypt function for DES algo
+ * \param *areq Pointer to ablkcipher request in memory
+ * \return 0 is success, -EINPROGRESS if encryting, EINVAL if failure
+*/
+
+static int lq_des_encrypt(struct ablkcipher_request *areq)
+{
+ struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
+ struct des_ctx *ctx = crypto_ablkcipher_ctx(cipher);
+
+ return lq_queue_mgr(ctx, areq, NULL, CRYPTO_DIR_ENCRYPT, 5);
+
+}
+
+/* \fn static int lq_des_decrypt(struct ablkcipher_request *areq)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief Decrypt function for DES algo
+ * \param *areq Pointer to ablkcipher request in memory
+ * \return 0 is success, -EINPROGRESS if encryting, EINVAL if failure
+*/
+
+static int lq_des_decrypt(struct ablkcipher_request *areq)
+{
+ struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
+ struct des_ctx *ctx = crypto_ablkcipher_ctx(cipher);
+
+ return lq_queue_mgr(ctx, areq, NULL, CRYPTO_DIR_DECRYPT, 5);
+}
+
+/* \fn static int lq_ecb_des_encrypt(struct ablkcipher_request *areq)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief Decrypt function for DES algo
+ * \param *areq Pointer to ablkcipher request in memory
+ * \return 0 is success, -EINPROGRESS if encryting, EINVAL if failure
+*/
+
+static int lq_ecb_des_encrypt(struct ablkcipher_request *areq)
+{
+ struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
+ struct des_ctx *ctx = crypto_ablkcipher_ctx(cipher);
+
+ return lq_queue_mgr(ctx, areq, areq->info, CRYPTO_DIR_ENCRYPT, 0);
+}
+
+/* \fn static int lq_ecb_des_decrypt(struct ablkcipher_request *areq)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief Decrypt function for DES algo
+ * \param *areq Pointer to ablkcipher request in memory
+ * \return 0 is success, -EINPROGRESS if encryting, EINVAL if failure
+*/
+static int lq_ecb_des_decrypt(struct ablkcipher_request *areq)
+{
+ struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
+ struct des_ctx *ctx = crypto_ablkcipher_ctx(cipher);
+
+ return lq_queue_mgr(ctx, areq, areq->info, CRYPTO_DIR_DECRYPT, 0);
+
+}
+
+/* \fn static int lq_cbc_ecb_des_encrypt(struct ablkcipher_request *areq)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief Decrypt function for DES algo
+ * \param *areq Pointer to ablkcipher request in memory
+ * \return 0 is success, -EINPROGRESS if encryting, EINVAL if failure
+*/
+
+static int lq_cbc_des_encrypt(struct ablkcipher_request *areq)
+{
+ struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
+ struct des_ctx *ctx = crypto_ablkcipher_ctx(cipher);
+
+ return lq_queue_mgr(ctx, areq, areq->info, CRYPTO_DIR_ENCRYPT, 1);
+}
+/* \fn static int lq_cbc_des_decrypt(struct ablkcipher_request *areq)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief Decrypt function for DES algo
+ * \param *areq Pointer to ablkcipher request in memory
+ * \return 0 is success, -EINPROGRESS if encryting, EINVAL if failure
+*/
+
+static int lq_cbc_des_decrypt(struct ablkcipher_request *areq)
+{
+ struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
+ struct des_ctx *ctx = crypto_ablkcipher_ctx(cipher);
+
+ return lq_queue_mgr(ctx, areq, areq->info, CRYPTO_DIR_DECRYPT, 1);
+}
+
+struct lq_des_alg {
+ struct crypto_alg alg;
+};
+
+/* DES Supported algo array */
+static struct lq_des_alg des_drivers_alg [] = {
+ {
+ .alg = {
+ .cra_name = "des",
+ .cra_driver_name = "lqdeu-des",
+ .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
+ .cra_blocksize = DES_BLOCK_SIZE,
+ .cra_ctxsize = sizeof(struct des_ctx),
+ .cra_type = &crypto_ablkcipher_type,
+ .cra_priority = 300,
+ .cra_module = THIS_MODULE,
+ .cra_ablkcipher = {
+ .setkey = lq_des_setkey,
+ .encrypt = lq_des_encrypt,
+ .decrypt = lq_des_decrypt,
+ .geniv = "eseqiv",
+ .min_keysize = DES_KEY_SIZE,
+ .max_keysize = DES_KEY_SIZE,
+ .ivsize = DES_BLOCK_SIZE,
+ }
+ }
+
+ },{
+ .alg = {
+ .cra_name = "ecb(des)",
+ .cra_driver_name = "lqdeu-ecb(des)",
+ .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
+ .cra_blocksize = DES_BLOCK_SIZE,
+ .cra_ctxsize = sizeof(struct des_ctx),
+ .cra_type = &crypto_ablkcipher_type,
+ .cra_priority = 300,
+ .cra_module = THIS_MODULE,
+ .cra_ablkcipher = {
+ .setkey = lq_des_setkey,
+ .encrypt = lq_ecb_des_encrypt,
+ .decrypt = lq_ecb_des_decrypt,
+ .geniv = "eseqiv",
+ .min_keysize = DES_KEY_SIZE,
+ .max_keysize = DES_KEY_SIZE,
+ .ivsize = DES_BLOCK_SIZE,
+ }
+ }
+ },{
+ .alg = {
+ .cra_name = "cbc(des)",
+ .cra_driver_name = "lqdeu-cbc(des)",
+ .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
+ .cra_blocksize = DES_BLOCK_SIZE,
+ .cra_ctxsize = sizeof(struct des_ctx),
+ .cra_type = &crypto_ablkcipher_type,
+ .cra_priority = 300,
+ .cra_module = THIS_MODULE,
+ .cra_ablkcipher = {
+ .setkey = lq_des_setkey,
+ .encrypt = lq_cbc_des_encrypt,
+ .decrypt = lq_cbc_des_decrypt,
+ .geniv = "eseqiv",
+ .min_keysize = DES3_EDE_KEY_SIZE,
+ .max_keysize = DES3_EDE_KEY_SIZE,
+ .ivsize = DES3_EDE_BLOCK_SIZE,
+ }
+ }
+ },{
+ .alg = {
+ .cra_name = "des3_ede",
+ .cra_driver_name = "lqdeu-des3_ede",
+ .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
+ .cra_blocksize = DES_BLOCK_SIZE,
+ .cra_ctxsize = sizeof(struct des_ctx),
+ .cra_type = &crypto_ablkcipher_type,
+ .cra_priority = 300,
+ .cra_module = THIS_MODULE,
+ .cra_ablkcipher = {
+ .setkey = lq_des3_ede_setkey,
+ .encrypt = lq_des_encrypt,
+ .decrypt = lq_des_decrypt,
+ .geniv = "eseqiv",
+ .min_keysize = DES_KEY_SIZE,
+ .max_keysize = DES_KEY_SIZE,
+ .ivsize = DES_BLOCK_SIZE,
+ }
+ }
+ },{
+ .alg = {
+ .cra_name = "ecb(des3_ede)",
+ .cra_driver_name = "lqdeu-ecb(des3_ede)",
+ .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
+ .cra_blocksize = DES_BLOCK_SIZE,
+ .cra_ctxsize = sizeof(struct des_ctx),
+ .cra_type = &crypto_ablkcipher_type,
+ .cra_priority = 300,
+ .cra_module = THIS_MODULE,
+ .cra_ablkcipher = {
+ .setkey = lq_des3_ede_setkey,
+ .encrypt = lq_ecb_des_encrypt,
+ .decrypt = lq_ecb_des_decrypt,
+ .geniv = "eseqiv",
+ .min_keysize = DES3_EDE_KEY_SIZE,
+ .max_keysize = DES3_EDE_KEY_SIZE,
+ .ivsize = DES3_EDE_BLOCK_SIZE,
+ }
+ }
+ },{
+ .alg = {
+ .cra_name = "cbc(des3_ede)",
+ .cra_driver_name = "lqdeu-cbc(des3_ede)",
+ .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
+ .cra_blocksize = DES_BLOCK_SIZE,
+ .cra_ctxsize = sizeof(struct des_ctx),
+ .cra_type = &crypto_ablkcipher_type,
+ .cra_priority = 300,
+ .cra_module = THIS_MODULE,
+ .cra_ablkcipher = {
+ .setkey = lq_des3_ede_setkey,
+ .encrypt = lq_cbc_des_encrypt,
+ .decrypt = lq_cbc_des_decrypt,
+ .geniv = "eseqiv",
+ .min_keysize = DES3_EDE_KEY_SIZE,
+ .max_keysize = DES3_EDE_KEY_SIZE,
+ .ivsize = DES3_EDE_BLOCK_SIZE,
+ }
+ }
+ }
+};
+
+/*! \fn int __init lqdeu_async_des_init (void)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief initialize des driver
+*/
+int __init lqdeu_async_des_init (void)
+{
+ int i, j, ret = -EINVAL;
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20))
+ if (!disable_multiblock) {
+ ifxdeu_des_alg.cra_u.cipher.cia_max_nbytes = DES_BLOCK_SIZE; //(size_t)-1;
+ ifxdeu_des_alg.cra_u.cipher.cia_req_align = 16;
+ ifxdeu_des_alg.cra_u.cipher.cia_ecb = ifx_deu_des_ecb;
+ ifxdeu_des_alg.cra_u.cipher.cia_cbc = ifx_deu_des_cbc;
+ ifxdeu_des_alg.cra_u.cipher.cia_cfb = ifx_deu_des_cfb;
+ ifxdeu_des_alg.cra_u.cipher.cia_ofb = ifx_deu_des_ofb;
+ }
+#endif
+ for (i = 0; i < ARRAY_SIZE(des_drivers_alg); i++) {
+ ret = crypto_register_alg(&des_drivers_alg[i].alg);
+ //printk("driver: %s\n", des_drivers_alg[i].alg.cra_name);
+ if (ret)
+ goto des_err;
+ }
+
+ des_chip_init();
+ CRTCL_SECT_INIT;
+
+
+ printk (KERN_NOTICE "IFX DEU DES initialized%s%s.\n", disable_multiblock ? "" : " (multiblock)", disable_deudma ? "" : " (DMA)");
+ return ret;
+
+des_err:
+ for (j = 0; j < i; j++)
+ crypto_unregister_alg(&des_drivers_alg[i].alg);
+
+ printk(KERN_ERR "Lantiq %s driver initialization failed!\n", (char *)&des_drivers_alg[i].alg.cra_driver_name);
+ return ret;
+
+cbc_des3_ede_err:
+ for (i = 0; i < ARRAY_SIZE(des_drivers_alg); i++) {
+ if (!strcmp((char *)&des_drivers_alg[i].alg.cra_name, "cbc(des3_ede)"))
+ crypto_unregister_alg(&des_drivers_alg[i].alg);
+ }
+
+ printk(KERN_ERR "Lantiq %s driver initialization failed!\n", (char *)&des_drivers_alg[i].alg.cra_driver_name);
+ return ret;
+}
+
+/*! \fn void __exit lqdeu_fini_async_des (void)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief unregister des driver
+*/
+void __exit lqdeu_fini_async_des (void)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(des_drivers_alg); i++)
+ crypto_unregister_alg(&des_drivers_alg[i].alg);
+
+ des_queue->hw_status = DES_COMPLETED;
+ DEU_WAKEUP_EVENT(deu_dma_priv.deu_thread_wait, DES_ASYNC_EVENT,
+ deu_dma_priv.des_event_flags);
+
+ kfree(des_queue);
+}
+
diff --git a/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_des.c.svn-base b/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_des.c.svn-base
new file mode 100644
index 0000000..dcf6c18
--- /dev/null
+++ b/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_des.c.svn-base
@@ -0,0 +1,768 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_des.c
+** PROJECT : IFX UEIP
+** MODULES : DEU Module
+**
+** DATE : September 8, 2009
+** AUTHOR : Mohammad Firdaus
+** DESCRIPTION : Data Encryption Unit Driver for DES Algorithm
+** COPYRIGHT : Copyright (c) 2009
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 08 Sept 2009 Mohammad Firdaus Initial UEIP release
+*******************************************************************************/
+
+/*!
+ \defgroup IFX_DEU IFX_DEU_DRIVERS
+ \ingroup API
+ \brief ifx deu driver
+*/
+
+/*!
+ \file ifxmips_des.c
+ \ingroup IFX_DEU
+ \brief DES encryption DEU driver file
+*/
+
+/*!
+ \defgroup IFX_DES_FUNCTIONS IFX_DES_FUNCTIONS
+ \ingroup IFX_DEU
+ \brief IFX DES Encryption functions
+*/
+
+/* Project Header Files */
+#include <linux/version.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/crypto.h>
+#include <linux/interrupt.h>
+#include <linux/delay.h>
+#include <asm/byteorder.h>
+#include <crypto/algapi.h>
+#include "ifxmips_deu.h"
+
+#if defined(CONFIG_DANUBE)
+#include "ifxmips_deu_danube.h"
+extern int ifx_danube_pre_1_4;
+#elif defined(CONFIG_AR9)
+#include "ifxmips_deu_ar9.h"
+#elif defined(CONFIG_VR9) || defined(CONFIG_AR10)
+#include "ifxmips_deu_vr9.h"
+#else
+#error "Unkown platform"
+#endif
+
+/* DMA specific header and variables */
+
+#if 0
+ #define CRTCL_SECT_INIT
+ #define CRTCL_SECT_START
+ #define CRTCL_SECT_END
+#else
+spinlock_t des_lock;
+#define CRTCL_SECT_INIT spin_lock_init(&des_lock)
+#define CRTCL_SECT_START spin_lock_irqsave(&des_lock, flag)
+#define CRTCL_SECT_END spin_unlock_irqrestore(&des_lock, flag)
+#endif
+
+/* Preprocessor declerations */
+#ifdef CRYPTO_DEBUG
+extern char debug_level;
+#define DPRINTF(level, format, args...) if (level < debug_level) printk(KERN_INFO "[%s %s %d]: " format, __FILE__, __func__, __LINE__, ##args);
+#else
+#define DPRINTF(level, format, args...)
+#endif
+#define DES_3DES_START IFX_DES_CON
+#define DES_KEY_SIZE 8
+#define DES_EXPKEY_WORDS 32
+#define DES_BLOCK_SIZE 8
+#define DES3_EDE_KEY_SIZE (3 * DES_KEY_SIZE)
+#define DES3_EDE_EXPKEY_WORDS (3 * DES_EXPKEY_WORDS)
+#define DES3_EDE_BLOCK_SIZE DES_BLOCK_SIZE
+
+/* Function Declaration to prevent warning messages */
+void des_chip_init (void);
+u32 endian_swap(u32 input);
+u32 input_swap(u32 input);
+int aes_memory_allocate(int value);
+int des_memory_allocate(int value);
+void memory_release(u32 *buffer);
+u32* memory_alignment(const u8 *arg, u32 *buff_alloc, int in_out, int nbytes);
+void aes_dma_memory_copy(u32 *outcopy, u32 *out_dma, u8 *out_arg, int nbytes);
+void des_dma_memory_copy(u32 *outcopy, u32 *out_dma, u8 *out_arg, int nbytes);
+
+void ifx_deu_des (void *ctx_arg, u8 *out_arg, const u8 *in_arg,
+ u8 *iv_arg, u32 nbytes, int encdec, int mode);
+
+struct des_ctx {
+ int controlr_M;
+ int key_length;
+ u8 iv[DES_BLOCK_SIZE];
+ u32 expkey[DES3_EDE_EXPKEY_WORDS];
+};
+
+extern int disable_multiblock;
+extern int disable_deudma;
+
+
+/*! \fn int des_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief sets DES key
+ * \param tfm linux crypto algo transform
+ * \param key input key
+ * \param keylen key length
+*/
+int des_setkey(struct crypto_tfm *tfm, const u8 *key,
+ unsigned int keylen)
+{
+ struct des_ctx *dctx = crypto_tfm_ctx(tfm);
+
+ //printk("setkey in %s\n", __FILE__);
+
+ dctx->controlr_M = 0; // des
+ dctx->key_length = keylen;
+
+ memcpy ((u8 *) (dctx->expkey), key, keylen);
+
+ return 0;
+}
+
+
+/*! \fn void ifx_deu_des(void *ctx_arg, u8 *out_arg, const u8 *in_arg, u8 *iv_arg, u32 nbytes, int encdec, int mode)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief main interface to DES hardware
+ * \param ctx_arg crypto algo context
+ * \param out_arg output bytestream
+ * \param in_arg input bytestream
+ * \param iv_arg initialization vector
+ * \param nbytes length of bytestream
+ * \param encdec 1 for encrypt; 0 for decrypt
+ * \param mode operation mode such as ebc, cbc
+*/
+
+void ifx_deu_des (void *ctx_arg, u8 *out_arg, const u8 *in_arg,
+ u8 *iv_arg, u32 nbytes, int encdec, int mode)
+{
+ volatile struct des_t *des = (struct des_t *) DES_3DES_START;
+ struct des_ctx *dctx = ctx_arg;
+ u32 *key = dctx->expkey;
+ unsigned long flag;
+
+ int i = 0;
+ int nblocks = 0;
+
+ CRTCL_SECT_START;
+
+ des->controlr.M = dctx->controlr_M;
+ if (dctx->controlr_M == 0) // des
+ {
+ des->K1HR = DEU_ENDIAN_SWAP(*((u32 *) key + 0));
+ des->K1LR = DEU_ENDIAN_SWAP(*((u32 *) key + 1));
+
+ }
+ else {
+ /* Hardware Section */
+ switch (dctx->key_length) {
+ case 24:
+ des->K3HR = DEU_ENDIAN_SWAP(*((u32 *) key + 4));
+ des->K3LR = DEU_ENDIAN_SWAP(*((u32 *) key + 5));
+ /* no break; */
+
+ case 16:
+ des->K2HR = DEU_ENDIAN_SWAP(*((u32 *) key + 2));
+ des->K2LR = DEU_ENDIAN_SWAP(*((u32 *) key + 3));
+
+ /* no break; */
+ case 8:
+ des->K1HR = DEU_ENDIAN_SWAP(*((u32 *) key + 0));
+ des->K1LR = DEU_ENDIAN_SWAP(*((u32 *) key + 1));
+ break;
+
+ default:
+ CRTCL_SECT_END;
+ return;
+ }
+ }
+
+ des->controlr.E_D = !encdec; //encryption
+ des->controlr.O = mode; //0 ECB 1 CBC 2 OFB 3 CFB 4 CTR hexdump(prin,sizeof(*des));
+
+ if (mode > 0) {
+ des->IVHR = DEU_ENDIAN_SWAP(*(u32 *) iv_arg);
+ des->IVLR = DEU_ENDIAN_SWAP(*((u32 *) iv_arg + 1));
+ };
+
+ nblocks = nbytes / 4;
+
+ for (i = 0; i < nblocks; i += 2) {
+ /* wait for busy bit to clear */
+
+ /*--- Workaround ----------------------------------------------------
+ do a dummy read to the busy flag because it is not raised early
+ enough in CFB/OFB 3DES modes */
+#ifdef CRYPTO_DEBUG
+ printk ("ihr: %x\n", (*((u32 *) in_arg + i)));
+ printk ("ilr: %x\n", (*((u32 *) in_arg + 1 + i)));
+#endif
+ des->IHR = INPUT_ENDIAN_SWAP(*((u32 *) in_arg + i));
+ des->ILR = INPUT_ENDIAN_SWAP(*((u32 *) in_arg + 1 + i)); /* start crypto */
+
+ while (des->controlr.BUS) {
+ // this will not take long
+ }
+
+ *((u32 *) out_arg + 0 + i) = des->OHR;
+ *((u32 *) out_arg + 1 + i) = des->OLR;
+
+ }
+
+
+
+ if (mode > 0) {
+ *(u32 *) iv_arg = DEU_ENDIAN_SWAP(des->IVHR);
+ *((u32 *) iv_arg + 1) = DEU_ENDIAN_SWAP(des->IVLR);
+ };
+
+ CRTCL_SECT_END;
+}
+
+//definitions from linux/include/crypto.h:
+//#define CRYPTO_TFM_MODE_ECB 0x00000001
+//#define CRYPTO_TFM_MODE_CBC 0x00000002
+//#define CRYPTO_TFM_MODE_CFB 0x00000004
+//#define CRYPTO_TFM_MODE_CTR 0x00000008
+//#define CRYPTO_TFM_MODE_OFB 0x00000010 // not even defined
+//but hardware definition: 0 ECB 1 CBC 2 OFB 3 CFB 4 CTR
+
+/*! \fn void ifx_deu_des(void *ctx_arg, u8 *out_arg, const u8 *in_arg, u8 *iv_arg, u32 nbytes, int encdec, int mode)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief main interface to DES hardware
+ * \param ctx_arg crypto algo context
+ * \param out_arg output bytestream
+ * \param in_arg input bytestream
+ * \param iv_arg initialization vector
+ * \param nbytes length of bytestream
+ * \param encdec 1 for encrypt; 0 for decrypt
+ * \param mode operation mode such as ebc, cbc
+*/
+
+
+
+/*! \fn void ifx_deu_des_ecb (void *ctx, uint8_t *dst, const uint8_t *src, uint8_t *iv, size_t nbytes, int encdec, int inplace)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief sets DES hardware to ECB mode
+ * \param ctx crypto algo context
+ * \param dst output bytestream
+ * \param src input bytestream
+ * \param iv initialization vector
+ * \param nbytes length of bytestream
+ * \param encdec 1 for encrypt; 0 for decrypt
+ * \param inplace not used
+*/
+
+void ifx_deu_des_ecb (void *ctx, uint8_t *dst, const uint8_t *src,
+ uint8_t *iv, size_t nbytes, int encdec, int inplace)
+{
+ ifx_deu_des (ctx, dst, src, NULL, nbytes, encdec, 0);
+}
+
+/*! \fn void ifx_deu_des_cbc (void *ctx, uint8_t *dst, const uint8_t *src, uint8_t *iv, size_t nbytes, int encdec, int inplace)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief sets DES hardware to CBC mode
+ * \param ctx crypto algo context
+ * \param dst output bytestream
+ * \param src input bytestream
+ * \param iv initialization vector
+ * \param nbytes length of bytestream
+ * \param encdec 1 for encrypt; 0 for decrypt
+ * \param inplace not used
+*/
+void ifx_deu_des_cbc (void *ctx, uint8_t *dst, const uint8_t *src,
+ uint8_t *iv, size_t nbytes, int encdec, int inplace)
+{
+ ifx_deu_des (ctx, dst, src, iv, nbytes, encdec, 1);
+}
+
+/*! \fn void ifx_deu_des_ofb (void *ctx, uint8_t *dst, const uint8_t *src, uint8_t *iv, size_t nbytes, int encdec, int inplace)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief sets DES hardware to OFB mode
+ * \param ctx crypto algo context
+ * \param dst output bytestream
+ * \param src input bytestream
+ * \param iv initialization vector
+ * \param nbytes length of bytestream
+ * \param encdec 1 for encrypt; 0 for decrypt
+ * \param inplace not used
+*/
+void ifx_deu_des_ofb (void *ctx, uint8_t *dst, const uint8_t *src,
+ uint8_t *iv, size_t nbytes, int encdec, int inplace)
+{
+ ifx_deu_des (ctx, dst, src, iv, nbytes, encdec, 2);
+}
+
+/*! \fn void ifx_deu_des_cfb (void *ctx, uint8_t *dst, const uint8_t *src, uint8_t *iv, size_t nbytes, int encdec, int inplace)
+ \ingroup IFX_DES_FUNCTIONS
+ \brief sets DES hardware to CFB mode
+ \param ctx crypto algo context
+ \param dst output bytestream
+ \param src input bytestream
+ \param iv initialization vector
+ \param nbytes length of bytestream
+ \param encdec 1 for encrypt; 0 for decrypt
+ \param inplace not used
+*/
+void ifx_deu_des_cfb (void *ctx, uint8_t *dst, const uint8_t *src,
+ uint8_t *iv, size_t nbytes, int encdec, int inplace)
+{
+ ifx_deu_des (ctx, dst, src, iv, nbytes, encdec, 3);
+}
+
+/*! \fn void ifx_deu_des_ctr (void *ctx, uint8_t *dst, const uint8_t *src, uint8_t *iv, size_t nbytes, int encdec, int inplace)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief sets DES hardware to CTR mode
+ * \param ctx crypto algo context
+ * \param dst output bytestream
+ * \param src input bytestream
+ * \param iv initialization vector
+ * \param nbytes length of bytestream
+ * \param encdec 1 for encrypt; 0 for decrypt
+ * \param inplace not used
+*/
+void ifx_deu_des_ctr (void *ctx, uint8_t *dst, const uint8_t *src,
+ uint8_t *iv, size_t nbytes, int encdec, int inplace)
+{
+ ifx_deu_des (ctx, dst, src, iv, nbytes, encdec, 4);
+}
+
+/*! \fn void des_encrypt (struct crypto_tfm *tfm, uint8_t *out, const uint8_t *in)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief encrypt DES_BLOCK_SIZE of data
+ * \param tfm linux crypto algo transform
+ * \param out output bytestream
+ * \param in input bytestream
+*/
+void des_encrypt (struct crypto_tfm *tfm, uint8_t * out, const uint8_t * in)
+{
+ struct des_ctx *ctx = crypto_tfm_ctx(tfm);
+ ifx_deu_des (ctx, out, in, NULL, DES_BLOCK_SIZE,
+ CRYPTO_DIR_ENCRYPT, 0);
+
+}
+
+/*! \fn void des_decrypt (struct crypto_tfm *tfm, uint8_t *out, const uint8_t *in)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief encrypt DES_BLOCK_SIZE of data
+ * \param tfm linux crypto algo transform
+ * \param out output bytestream
+ * \param in input bytestream
+*/
+void des_decrypt (struct crypto_tfm *tfm, uint8_t * out, const uint8_t * in)
+{
+ struct des_ctx *ctx = crypto_tfm_ctx(tfm);
+ ifx_deu_des (ctx, out, in, NULL, DES_BLOCK_SIZE,
+ CRYPTO_DIR_DECRYPT, 0);
+}
+
+/*
+ * \brief RFC2451:
+ *
+ * For DES-EDE3, there is no known need to reject weak or
+ * complementation keys. Any weakness is obviated by the use of
+ * multiple keys.
+ *
+ * However, if the first two or last two independent 64-bit keys are
+ * equal (k1 == k2 or k2 == k3), then the DES3 operation is simply the
+ * same as DES. Implementers MUST reject keys that exhibit this
+ * property.
+ *
+ */
+
+/*! \fn int des3_ede_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief sets 3DES key
+ * \param tfm linux crypto algo transform
+ * \param key input key
+ * \param keylen key length
+*/
+int des3_ede_setkey(struct crypto_tfm *tfm, const u8 *key,
+ unsigned int keylen)
+{
+ struct des_ctx *dctx = crypto_tfm_ctx(tfm);
+
+ //printk("setkey in %s\n", __FILE__);
+
+ dctx->controlr_M = keylen / 8 + 1; // 3DES EDE1 / EDE2 / EDE3 Mode
+ dctx->key_length = keylen;
+
+ memcpy ((u8 *) (dctx->expkey), key, keylen);
+
+ return 0;
+}
+
+/*
+ * \brief DES function mappings
+*/
+struct crypto_alg ifxdeu_des_alg = {
+ .cra_name = "des",
+ .cra_driver_name = "ifxdeu-des",
+ .cra_flags = CRYPTO_ALG_TYPE_CIPHER,
+ .cra_blocksize = DES_BLOCK_SIZE,
+ .cra_ctxsize = sizeof(struct des_ctx),
+ .cra_module = THIS_MODULE,
+ .cra_alignmask = 3,
+ .cra_list = LIST_HEAD_INIT(ifxdeu_des_alg.cra_list),
+ .cra_u = { .cipher = {
+ .cia_min_keysize = DES_KEY_SIZE,
+ .cia_max_keysize = DES_KEY_SIZE,
+ .cia_setkey = des_setkey,
+ .cia_encrypt = des_encrypt,
+ .cia_decrypt = des_decrypt } }
+};
+
+/*
+ * \brief DES function mappings
+*/
+struct crypto_alg ifxdeu_des3_ede_alg = {
+ .cra_name = "des3_ede",
+ .cra_driver_name = "ifxdeu-des3_ede",
+ .cra_flags = CRYPTO_ALG_TYPE_CIPHER,
+ .cra_blocksize = DES_BLOCK_SIZE,
+ .cra_ctxsize = sizeof(struct des_ctx),
+ .cra_module = THIS_MODULE,
+ .cra_alignmask = 3,
+ .cra_list = LIST_HEAD_INIT(ifxdeu_des3_ede_alg.cra_list),
+ .cra_u = { .cipher = {
+ .cia_min_keysize = DES_KEY_SIZE,
+ .cia_max_keysize = DES_KEY_SIZE,
+ .cia_setkey = des3_ede_setkey,
+ .cia_encrypt = des_encrypt,
+ .cia_decrypt = des_decrypt } }
+};
+
+/*! \fn int ecb_des_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief ECB DES encrypt using linux crypto blkcipher
+ * \param desc blkcipher descriptor
+ * \param dst output scatterlist
+ * \param src input scatterlist
+ * \param nbytes data size in bytes
+*/
+int ecb_des_encrypt(struct blkcipher_desc *desc,
+ struct scatterlist *dst, struct scatterlist *src,
+ unsigned int nbytes)
+{
+ struct des_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
+ struct blkcipher_walk walk;
+ int err;
+
+ blkcipher_walk_init(&walk, dst, src, nbytes);
+ err = blkcipher_walk_virt(desc, &walk);
+
+ while ((nbytes = walk.nbytes)) {
+ nbytes -= (nbytes % DES_BLOCK_SIZE);
+ ifx_deu_des_ecb(ctx, walk.dst.virt.addr, walk.src.virt.addr,
+ NULL, nbytes, CRYPTO_DIR_ENCRYPT, 0);
+ nbytes &= DES_BLOCK_SIZE - 1;
+ err = blkcipher_walk_done(desc, &walk, nbytes);
+ }
+
+ return err;
+}
+
+/*! \fn int ecb_des_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief ECB DES decrypt using linux crypto blkcipher
+ * \param desc blkcipher descriptor
+ * \param dst output scatterlist
+ * \param src input scatterlist
+ * \param nbytes data size in bytes
+ * \return err
+*/
+int ecb_des_decrypt(struct blkcipher_desc *desc,
+ struct scatterlist *dst, struct scatterlist *src,
+ unsigned int nbytes)
+{
+ struct des_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
+ struct blkcipher_walk walk;
+ int err;
+
+ DPRINTF(1, "\n");
+ blkcipher_walk_init(&walk, dst, src, nbytes);
+ err = blkcipher_walk_virt(desc, &walk);
+
+ while ((nbytes = walk.nbytes)) {
+ nbytes -= (nbytes % DES_BLOCK_SIZE);
+ ifx_deu_des_ecb(ctx, walk.dst.virt.addr, walk.src.virt.addr,
+ NULL, nbytes, CRYPTO_DIR_DECRYPT, 0);
+ nbytes &= DES_BLOCK_SIZE - 1;
+ err = blkcipher_walk_done(desc, &walk, nbytes);
+ }
+
+ return err;
+}
+
+/*
+ * \brief DES function mappings
+*/
+struct crypto_alg ifxdeu_ecb_des_alg = {
+ .cra_name = "ecb(des)",
+ .cra_driver_name = "ifxdeu-ecb(des)",
+ .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER,
+ .cra_blocksize = DES_BLOCK_SIZE,
+ .cra_ctxsize = sizeof(struct des_ctx),
+ .cra_type = &crypto_blkcipher_type,
+ .cra_module = THIS_MODULE,
+ .cra_list = LIST_HEAD_INIT(ifxdeu_ecb_des_alg.cra_list),
+ .cra_u = {
+ .blkcipher = {
+ .min_keysize = DES_KEY_SIZE,
+ .max_keysize = DES_KEY_SIZE,
+ .setkey = des_setkey,
+ .encrypt = ecb_des_encrypt,
+ .decrypt = ecb_des_decrypt,
+ }
+ }
+};
+
+/*
+ * \brief DES function mappings
+*/
+struct crypto_alg ifxdeu_ecb_des3_ede_alg = {
+ .cra_name = "ecb(des3_ede)",
+ .cra_driver_name = "ifxdeu-ecb(des3_ede)",
+ .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER,
+ .cra_blocksize = DES3_EDE_BLOCK_SIZE,
+ .cra_ctxsize = sizeof(struct des_ctx),
+ .cra_type = &crypto_blkcipher_type,
+ .cra_module = THIS_MODULE,
+ .cra_list = LIST_HEAD_INIT(ifxdeu_ecb_des3_ede_alg.cra_list),
+ .cra_u = {
+ .blkcipher = {
+ .min_keysize = DES3_EDE_KEY_SIZE,
+ .max_keysize = DES3_EDE_KEY_SIZE,
+ .setkey = des3_ede_setkey,
+ .encrypt = ecb_des_encrypt,
+ .decrypt = ecb_des_decrypt,
+ }
+ }
+};
+
+/*! \fn int cbc_des_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief CBC DES encrypt using linux crypto blkcipher
+ * \param desc blkcipher descriptor
+ * \param dst output scatterlist
+ * \param src input scatterlist
+ * \param nbytes data size in bytes
+ * \return err
+*/
+int cbc_des_encrypt(struct blkcipher_desc *desc,
+ struct scatterlist *dst, struct scatterlist *src,
+ unsigned int nbytes)
+{
+ struct des_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
+ struct blkcipher_walk walk;
+ int err;
+
+ DPRINTF(1, "\n");
+ blkcipher_walk_init(&walk, dst, src, nbytes);
+ err = blkcipher_walk_virt(desc, &walk);
+
+ while ((nbytes = walk.nbytes)) {
+ u8 *iv = walk.iv;
+ nbytes -= (nbytes % DES_BLOCK_SIZE);
+ ifx_deu_des_cbc(ctx, walk.dst.virt.addr, walk.src.virt.addr,
+ iv, nbytes, CRYPTO_DIR_ENCRYPT, 0);
+ nbytes &= DES_BLOCK_SIZE - 1;
+ err = blkcipher_walk_done(desc, &walk, nbytes);
+ }
+
+ return err;
+}
+
+/*! \fn int cbc_des_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief CBC DES decrypt using linux crypto blkcipher
+ * \param desc blkcipher descriptor
+ * \param dst output scatterlist
+ * \param src input scatterlist
+ * \param nbytes data size in bytes
+ * \return err
+*/
+int cbc_des_decrypt(struct blkcipher_desc *desc,
+ struct scatterlist *dst, struct scatterlist *src,
+ unsigned int nbytes)
+{
+ struct des_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
+ struct blkcipher_walk walk;
+ int err;
+
+ DPRINTF(1, "\n");
+ blkcipher_walk_init(&walk, dst, src, nbytes);
+ err = blkcipher_walk_virt(desc, &walk);
+
+ while ((nbytes = walk.nbytes)) {
+ u8 *iv = walk.iv;
+ nbytes -= (nbytes % DES_BLOCK_SIZE);
+ ifx_deu_des_cbc(ctx, walk.dst.virt.addr, walk.src.virt.addr,
+ iv, nbytes, CRYPTO_DIR_DECRYPT, 0);
+ nbytes &= DES_BLOCK_SIZE - 1;
+ err = blkcipher_walk_done(desc, &walk, nbytes);
+ }
+
+ return err;
+}
+
+/*
+ * \brief DES function mappings
+*/
+struct crypto_alg ifxdeu_cbc_des_alg = {
+ .cra_name = "cbc(des)",
+ .cra_driver_name = "ifxdeu-cbc(des)",
+ .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER,
+ .cra_blocksize = DES_BLOCK_SIZE,
+ .cra_ctxsize = sizeof(struct des_ctx),
+ .cra_type = &crypto_blkcipher_type,
+ .cra_module = THIS_MODULE,
+ .cra_list = LIST_HEAD_INIT(ifxdeu_cbc_des_alg.cra_list),
+ .cra_u = {
+ .blkcipher = {
+ .min_keysize = DES_KEY_SIZE,
+ .max_keysize = DES_KEY_SIZE,
+ .ivsize = DES_BLOCK_SIZE,
+ .setkey = des_setkey,
+ .encrypt = cbc_des_encrypt,
+ .decrypt = cbc_des_decrypt,
+ }
+ }
+};
+
+/*
+ * \brief DES function mappings
+*/
+struct crypto_alg ifxdeu_cbc_des3_ede_alg = {
+ .cra_name = "cbc(des3_ede)",
+ .cra_driver_name = "ifxdeu-cbc(des3_ede)",
+ .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER,
+ .cra_blocksize = DES3_EDE_BLOCK_SIZE,
+ .cra_ctxsize = sizeof(struct des_ctx),
+ .cra_type = &crypto_blkcipher_type,
+ .cra_module = THIS_MODULE,
+ .cra_list = LIST_HEAD_INIT(ifxdeu_cbc_des3_ede_alg.cra_list),
+ .cra_u = {
+ .blkcipher = {
+ .min_keysize = DES3_EDE_KEY_SIZE,
+ .max_keysize = DES3_EDE_KEY_SIZE,
+ .ivsize = DES_BLOCK_SIZE,
+ .setkey = des3_ede_setkey,
+ .encrypt = cbc_des_encrypt,
+ .decrypt = cbc_des_decrypt,
+ }
+ }
+};
+
+/*! \fn int __init ifxdeu_init_des (void)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief initialize des driver
+*/
+int __init ifxdeu_init_des (void)
+{
+ int ret = -ENOSYS;
+
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20))
+ if (!disable_multiblock) {
+ ifxdeu_des_alg.cra_u.cipher.cia_max_nbytes = DES_BLOCK_SIZE; //(size_t)-1;
+ ifxdeu_des_alg.cra_u.cipher.cia_req_align = 16;
+ ifxdeu_des_alg.cra_u.cipher.cia_ecb = ifx_deu_des_ecb;
+ ifxdeu_des_alg.cra_u.cipher.cia_cbc = ifx_deu_des_cbc;
+ ifxdeu_des_alg.cra_u.cipher.cia_cfb = ifx_deu_des_cfb;
+ ifxdeu_des_alg.cra_u.cipher.cia_ofb = ifx_deu_des_ofb;
+ }
+#endif
+
+ ret = crypto_register_alg(&ifxdeu_des_alg);
+ if (ret < 0)
+ goto des_err;
+
+ ret = crypto_register_alg(&ifxdeu_ecb_des_alg);
+ if (ret < 0)
+ goto ecb_des_err;
+
+ ret = crypto_register_alg(&ifxdeu_cbc_des_alg);
+ if (ret < 0)
+ goto cbc_des_err;
+
+ ret = crypto_register_alg(&ifxdeu_des3_ede_alg);
+ if (ret < 0)
+ goto des3_ede_err;
+
+ ret = crypto_register_alg(&ifxdeu_ecb_des3_ede_alg);
+ if (ret < 0)
+ goto ecb_des3_ede_err;
+
+ ret = crypto_register_alg(&ifxdeu_cbc_des3_ede_alg);
+ if (ret < 0)
+ goto cbc_des3_ede_err;
+
+ des_chip_init();
+ CRTCL_SECT_INIT;
+
+
+
+ printk (KERN_NOTICE "IFX DEU DES initialized%s%s.\n", disable_multiblock ? "" : " (multiblock)", disable_deudma ? "" : " (DMA)");
+ return ret;
+
+des_err:
+ crypto_unregister_alg(&ifxdeu_des_alg);
+ printk(KERN_ERR "IFX des initialization failed!\n");
+ return ret;
+ecb_des_err:
+ crypto_unregister_alg(&ifxdeu_ecb_des_alg);
+ printk (KERN_ERR "IFX ecb_des initialization failed!\n");
+ return ret;
+cbc_des_err:
+ crypto_unregister_alg(&ifxdeu_cbc_des_alg);
+ printk (KERN_ERR "IFX cbc_des initialization failed!\n");
+ return ret;
+des3_ede_err:
+ crypto_unregister_alg(&ifxdeu_des3_ede_alg);
+ printk(KERN_ERR "IFX des3_ede initialization failed!\n");
+ return ret;
+ecb_des3_ede_err:
+ crypto_unregister_alg(&ifxdeu_ecb_des3_ede_alg);
+ printk (KERN_ERR "IFX ecb_des3_ede initialization failed!\n");
+ return ret;
+cbc_des3_ede_err:
+ crypto_unregister_alg(&ifxdeu_cbc_des3_ede_alg);
+ printk (KERN_ERR "IFX cbc_des3_ede initialization failed!\n");
+ return ret;
+
+}
+
+/*! \fn void __exit ifxdeu_fini_des (void)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief unregister des driver
+*/
+void __exit ifxdeu_fini_des (void)
+{
+ crypto_unregister_alg (&ifxdeu_des_alg);
+ crypto_unregister_alg (&ifxdeu_ecb_des_alg);
+ crypto_unregister_alg (&ifxdeu_cbc_des_alg);
+ crypto_unregister_alg (&ifxdeu_des3_ede_alg);
+ crypto_unregister_alg (&ifxdeu_ecb_des3_ede_alg);
+ crypto_unregister_alg (&ifxdeu_cbc_des3_ede_alg);
+
+}
+
diff --git a/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_deu.c.svn-base b/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_deu.c.svn-base
new file mode 100644
index 0000000..05f1681
--- /dev/null
+++ b/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_deu.c.svn-base
@@ -0,0 +1,210 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_deu.c
+** PROJECT : IFX UEIP
+** MODULES : DEU Module for Danube
+**
+** DATE : September 8, 2009
+** AUTHOR : Mohammad Firdaus
+** DESCRIPTION : Data Encryption Unit Driver
+** COPYRIGHT : Copyright (c) 2009
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 08,Sept 2009 Mohammad Firdaus Initial UEIP release
+*******************************************************************************/
+
+/*!
+ \defgroup IFX_DEU IFX_DEU_DRIVERS
+ \ingroup API
+ \brief ifx deu driver module
+*/
+
+/*!
+ \file ifxmips_deu.c
+ \ingroup IFX_DEU
+ \brief main deu driver file
+*/
+
+/*!
+ \defgroup IFX_DEU_FUNCTIONS IFX_DEU_FUNCTIONS
+ \ingroup IFX_DEU
+ \brief IFX DEU functions
+*/
+
+/* Project header */
+#include <linux/version.h>
+#if defined(CONFIG_MODVERSIONS)
+#define MODVERSIONS
+#include <linux/modversions.h>
+#endif
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/crypto.h>
+#include <linux/proc_fs.h>
+#include <linux/platform_device.h>
+#include <linux/fs.h> /* Stuff about file systems that we need */
+#include <asm/byteorder.h>
+#include "ifxmips_deu.h"
+
+#include <lantiq_soc.h>
+
+#if defined(CONFIG_DANUBE)
+#include "ifxmips_deu_danube.h"
+#elif defined(CONFIG_AR9)
+#include "ifxmips_deu_ar9.h"
+#elif defined(CONFIG_VR9) || defined(CONFIG_AR10)
+#include "ifxmips_deu_vr9.h"
+#else
+#error "Platform unknown!"
+#endif /* CONFIG_xxxx */
+
+int disable_deudma = 1;
+
+void chip_version(void);
+
+/*! \fn static int __init deu_init (void)
+ * \ingroup IFX_DEU_FUNCTIONS
+ * \brief link all modules that have been selected in kernel config for ifx hw crypto support
+ * \return ret
+*/
+
+static int ltq_deu_probe(struct platform_device *pdev)
+{
+ int ret = -ENOSYS;
+
+
+ START_DEU_POWER;
+
+#define IFX_DEU_DRV_VERSION "2.0.0"
+ printk(KERN_INFO "Infineon Technologies DEU driver version %s \n", IFX_DEU_DRV_VERSION);
+
+ FIND_DEU_CHIP_VERSION;
+
+#if defined(CONFIG_CRYPTO_DEV_DES)
+ if ((ret = ifxdeu_init_des ())) {
+ printk (KERN_ERR "IFX DES initialization failed!\n");
+ }
+#endif
+#if defined(CONFIG_CRYPTO_DEV_AES)
+ if ((ret = ifxdeu_init_aes ())) {
+ printk (KERN_ERR "IFX AES initialization failed!\n");
+ }
+
+#endif
+#if defined(CONFIG_CRYPTO_DEV_ARC4)
+ if ((ret = ifxdeu_init_arc4 ())) {
+ printk (KERN_ERR "IFX ARC4 initialization failed!\n");
+ }
+
+#endif
+#if defined(CONFIG_CRYPTO_DEV_SHA1)
+ if ((ret = ifxdeu_init_sha1 ())) {
+ printk (KERN_ERR "IFX SHA1 initialization failed!\n");
+ }
+#endif
+#if defined(CONFIG_CRYPTO_DEV_MD5)
+ if ((ret = ifxdeu_init_md5 ())) {
+ printk (KERN_ERR "IFX MD5 initialization failed!\n");
+ }
+
+#endif
+#if defined(CONFIG_CRYPTO_DEV_SHA1_HMAC)
+ if ((ret = ifxdeu_init_sha1_hmac ())) {
+ printk (KERN_ERR "IFX SHA1_HMAC initialization failed!\n");
+ }
+#endif
+#if defined(CONFIG_CRYPTO_DEV_MD5_HMAC)
+ if ((ret = ifxdeu_init_md5_hmac ())) {
+ printk (KERN_ERR "IFX MD5_HMAC initialization failed!\n");
+ }
+#endif
+
+
+
+ return ret;
+
+}
+
+/*! \fn static void __exit deu_fini (void)
+ * \ingroup IFX_DEU_FUNCTIONS
+ * \brief remove the loaded crypto algorithms
+*/
+static int ltq_deu_remove(struct platform_device *pdev)
+{
+//#ifdef CONFIG_CRYPTO_DEV_PWR_SAVE_MODE
+ #if defined(CONFIG_CRYPTO_DEV_DES)
+ ifxdeu_fini_des ();
+ #endif
+ #if defined(CONFIG_CRYPTO_DEV_AES)
+ ifxdeu_fini_aes ();
+ #endif
+ #if defined(CONFIG_CRYPTO_DEV_ARC4)
+ ifxdeu_fini_arc4 ();
+ #endif
+ #if defined(CONFIG_CRYPTO_DEV_SHA1)
+ ifxdeu_fini_sha1 ();
+ #endif
+ #if defined(CONFIG_CRYPTO_DEV_MD5)
+ ifxdeu_fini_md5 ();
+ #endif
+ #if defined(CONFIG_CRYPTO_DEV_SHA1_HMAC)
+ ifxdeu_fini_sha1_hmac ();
+ #endif
+ #if defined(CONFIG_CRYPTO_DEV_MD5_HMAC)
+ ifxdeu_fini_md5_hmac ();
+ #endif
+ printk("DEU has exited successfully\n");
+
+ return 0;
+}
+
+
+int disable_multiblock = 0;
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
+module_param(disable_multiblock,int,0);
+
+#else
+//MODULE_PARM (disable_multiblock, "i");
+MODULE_PARM_DESC (disable_multiblock,
+ "Disable encryption of whole multiblock buffers.");
+#endif
+
+static const struct of_device_id ltq_deu_match[] = {
+#ifdef CONFIG_DANUBE
+ { .compatible = "lantiq,deu-danube"},
+#elif defined CONFIG_AR9
+ { .compatible = "lantiq,deu-arx100"},
+#elif defined CONFIG_VR9
+ { .compatible = "lantiq,deu-xrx200"},
+#endif
+ {},
+};
+MODULE_DEVICE_TABLE(of, ltq_deu_match);
+
+
+static struct platform_driver ltq_deu_driver = {
+ .probe = ltq_deu_probe,
+ .remove = ltq_deu_remove,
+ .driver = {
+ .name = "deu",
+ .owner = THIS_MODULE,
+ .of_match_table = ltq_deu_match,
+ },
+};
+
+module_platform_driver(ltq_deu_driver);
+
+MODULE_DESCRIPTION ("Infineon DEU crypto engine support.");
+MODULE_LICENSE ("GPL");
+MODULE_AUTHOR ("Mohammad Firdaus");
diff --git a/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_deu.h.svn-base b/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_deu.h.svn-base
new file mode 100644
index 0000000..c842d64
--- /dev/null
+++ b/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_deu.h.svn-base
@@ -0,0 +1,232 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_deu.h
+** DESCRIPTION : Data Encryption Unit Driver
+** COPYRIGHT : Copyright (c) 2009
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 08,Sept 2009 Mohammad Firdaus Initial UEIP release
+*******************************************************************************/
+/*!
+ \defgroup IFX_DEU IFX_DEU_DRIVERS
+ \ingroup API
+ \brief ifx deu driver module
+*/
+
+/*!
+ \file ifxmips_deu.h
+ \brief main deu driver header file
+*/
+
+/*!
+ \defgroup IFX_DEU_DEFINITIONS IFX_DEU_DEFINITIONS
+ \ingroup IFX_DEU
+ \brief ifx deu definitions
+*/
+
+
+#ifndef IFXMIPS_DEU_H
+#define IFXMIPS_DEU_H
+
+#include <crypto/algapi.h>
+#include <linux/interrupt.h>
+
+#define IFXDEU_ALIGNMENT 16
+
+#define IFX_DEU_BASE_ADDR (KSEG1 | 0x1E103100)
+#define IFX_DEU_CLK ((volatile u32 *)(IFX_DEU_BASE_ADDR + 0x0000))
+#define IFX_DES_CON ((volatile u32 *)(IFX_DEU_BASE_ADDR + 0x0010))
+#define IFX_AES_CON ((volatile u32 *)(IFX_DEU_BASE_ADDR + 0x0050))
+#define IFX_HASH_CON ((volatile u32 *)(IFX_DEU_BASE_ADDR + 0x00B0))
+#define IFX_ARC4_CON ((volatile u32 *)(IFX_DEU_BASE_ADDR + 0x0100))
+
+#define PFX "ifxdeu: "
+#define CLC_START IFX_DEU_CLK
+#define IFXDEU_CRA_PRIORITY 300
+#define IFXDEU_COMPOSITE_PRIORITY 400
+//#define KSEG1 0xA0000000
+#define IFX_PMU_ENABLE 1
+#define IFX_PMU_DISABLE 0
+
+#define CRYPTO_DIR_ENCRYPT 1
+#define CRYPTO_DIR_DECRYPT 0
+
+#define AES_IDLE 0
+#define AES_BUSY 1
+#define AES_STARTED 2
+#define AES_COMPLETED 3
+#define DES_IDLE 0
+#define DES_BUSY 1
+#define DES_STARTED 2
+#define DES_COMPLETED 3
+
+#define PROCESS_SCATTER 1
+#define PROCESS_NEW_PACKET 2
+
+#define PMU_DEU BIT(20)
+#define START_DEU_POWER \
+ do { \
+ volatile struct clc_controlr_t *clc = (struct clc_controlr_t *) CLC_START; \
+ ltq_pmu_enable(PMU_DEU); \
+ clc->FSOE = 0; \
+ clc->SBWE = 0; \
+ clc->SPEN = 0; \
+ clc->SBWE = 0; \
+ clc->DISS = 0; \
+ clc->DISR = 0; \
+ } while(0)
+
+#define STOP_DEU_POWER \
+ do { \
+ volatile struct clc_controlr_t *clc = (struct clc_controlr_t *) CLC_START; \
+ ltq_pmu_disable(PMU_DEU); \
+ clc->FSOE = 1; \
+ clc->SBWE = 1; \
+ clc->SPEN = 1; \
+ clc->SBWE = 1; \
+ clc->DISS = 1; \
+ clc->DISR = 1; \
+ } while (0)
+
+/*
+ * Not used anymore in UEIP (use IFX_DES_CON, IFX_AES_CON, etc instead)
+ * #define DEU_BASE (KSEG1+0x1E103100)
+ * #define DES_CON (DEU_BASE+0x10)
+ * #define AES_CON (DEU_BASE+0x50)
+ * #define HASH_CON (DEU_BASE+0xB0)
+ * #define DMA_CON (DEU_BASE+0xEC)
+ * #define INT_CON (DEU_BASE+0xF4)
+ * #define ARC4_CON (DEU_BASE+0x100)
+ */
+
+
+int __init ifxdeu_init_des (void);
+int __init ifxdeu_init_aes (void);
+int __init ifxdeu_init_arc4 (void);
+int __init ifxdeu_init_sha1 (void);
+int __init ifxdeu_init_md5 (void);
+int __init ifxdeu_init_sha1_hmac (void);
+int __init ifxdeu_init_md5_hmac (void);
+int __init lqdeu_async_aes_init(void);
+int __init lqdeu_async_des_init(void);
+
+void __exit ifxdeu_fini_des (void);
+void __exit ifxdeu_fini_aes (void);
+void __exit ifxdeu_fini_arc4 (void);
+void __exit ifxdeu_fini_sha1 (void);
+void __exit ifxdeu_fini_md5 (void);
+void __exit ifxdeu_fini_sha1_hmac (void);
+void __exit ifxdeu_fini_md5_hmac (void);
+void __exit ifxdeu_fini_dma(void);
+void __exit lqdeu_fini_async_aes(void);
+void __exit lqdeu_fini_async_des(void);
+void __exit deu_fini (void);
+int deu_dma_init (void);
+
+
+
+#define DEU_WAKELIST_INIT(queue) \
+ init_waitqueue_head(&queue)
+
+#define DEU_WAIT_EVENT_TIMEOUT(queue, event, flags, timeout) \
+ do { \
+ wait_event_interruptible_timeout((queue), \
+ test_bit((event), &(flags)), (timeout)); \
+ clear_bit((event), &(flags)); \
+ }while (0)
+
+
+#define DEU_WAKEUP_EVENT(queue, event, flags) \
+ do { \
+ set_bit((event), &(flags)); \
+ wake_up_interruptible(&(queue)); \
+ }while (0)
+
+#define DEU_WAIT_EVENT(queue, event, flags) \
+ do { \
+ wait_event_interruptible(queue, \
+ test_bit((event), &(flags))); \
+ clear_bit((event), &(flags)); \
+ }while (0)
+
+typedef struct deu_drv_priv {
+ wait_queue_head_t deu_thread_wait;
+#define DEU_EVENT 1
+#define DES_ASYNC_EVENT 2
+#define AES_ASYNC_EVENT 3
+ volatile long des_event_flags;
+ volatile long aes_event_flags;
+ volatile long deu_event_flags;
+ int event_src;
+ u32 *deu_rx_buf;
+ u32 *outcopy;
+ u32 deu_rx_len;
+
+ struct aes_priv *aes_dataptr;
+ struct des_priv *des_dataptr;
+}deu_drv_priv_t;
+
+
+/**
+ * struct aes_priv_t - ASYNC AES
+ * @lock: spinlock lock
+ * @lock_flag: flag for spinlock activities
+ * @list: crypto queue API list
+ * @hw_status: DEU hw status flag
+ * @aes_wait_flag: flag for sleep queue
+ * @aes_wait_queue: queue attributes for aes
+ * @bytes_processed: number of bytes to process by DEU
+ * @aes_pid: pid number for AES thread
+ * @aes_sync: atomic wait sync for AES
+ *
+*/
+
+typedef struct {
+ spinlock_t lock;
+ struct crypto_queue list;
+ unsigned int hw_status;
+ volatile long aes_wait_flag;
+ wait_queue_head_t aes_wait_queue;
+
+ pid_t aes_pid;
+
+ struct tasklet_struct aes_task;
+
+} aes_priv_t;
+
+/**
+ * struct des_priv_t - ASYNC DES
+ * @lock: spinlock lock
+ * @list: crypto queue API list
+ * @hw_status: DEU hw status flag
+ * @des_wait_flag: flag for sleep queue
+ * @des_wait_queue: queue attributes for des
+ * @des_pid: pid number for DES thread
+ * @des_sync: atomic wait sync for DES
+ *
+*/
+
+typedef struct {
+ spinlock_t lock;
+ struct crypto_queue list;
+ unsigned int hw_status;
+ volatile long des_wait_flag;
+ wait_queue_head_t des_wait_queue;
+
+ pid_t des_pid;
+
+ struct tasklet_struct des_task;
+
+} des_priv_t;
+
+#endif /* IFXMIPS_DEU_H */
+
+
diff --git a/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_deu_ar9.c.svn-base b/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_deu_ar9.c.svn-base
new file mode 100644
index 0000000..9dc3e30
--- /dev/null
+++ b/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_deu_ar9.c.svn-base
@@ -0,0 +1,135 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_deu_ar9.c
+** PROJECT : IFX UEIP
+** MODULES : DEU Module for AR9
+**
+** DATE : September 8, 2009
+** AUTHOR : Mohammad Firdaus
+** DESCRIPTION : Data Encryption Unit Driver
+** COPYRIGHT : Copyright (c) 2009
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 08,Sept 2009 Mohammad Firdaus Initial UEIP release
+*******************************************************************************/
+/*!
+ \defgroup IFX_DEU IFX_DEU_DRIVERS
+ \ingroup API
+ \brief ifx deu driver module
+*/
+
+/*!
+ \file ifxmips_deu_ar9.c
+ \brief ifx deu board specific driver file for ar9
+*/
+
+/*!
+ \defgroup BOARD_SPECIFIC_FUNCTIONS IFX_BOARD_SPECIFIC_FUNCTIONS
+ \ingroup IFX_DEU
+ \brief board specific functions
+*/
+
+/* Project header files */
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <asm/io.h> //dma_cache_inv
+
+#include "ifxmips_deu_dma.h"
+#include "ifxmips_deu_ar9.h"
+
+/* Function decleration */
+void aes_chip_init (void);
+void des_chip_init (void);
+int deu_dma_init (void);
+u32 endian_swap(u32 input);
+u32* memory_alignment(const u8 *arg, u32 *buff_alloc, int in_out, int nbytes);
+void aes_dma_memory_copy(u32 *outcopy, u32 *out_dma, u8 *out_arg, int nbytes);
+void des_dma_memory_copy(u32 *outcopy, u32 *out_dma, u8 *out_arg, int nbytes);
+void deu_dma_priv_init(void);
+void __exit ifxdeu_fini_dma(void);
+
+#define DES_3DES_START IFX_DES_CON
+#define AES_START IFX_AES_CON
+#define CLC_START IFX_DEU_CLK
+
+/* Variables */
+
+u8 *g_dma_page_ptr = NULL;
+u8 *g_dma_block = NULL;
+u8 *g_dma_block2 = NULL;
+
+deu_drv_priv_t deu_dma_priv;
+
+
+/*! \fn u32 endian_swap(u32 input)
+ * \ingroup BOARD_SPECIFIC_FUNCTIONS
+ * \brief Swap data given to the function
+ * \param input Data input to be swapped
+ * \return either the swapped data or the input data depending on whether it is in DMA mode or FPI mode
+*/
+u32 endian_swap(u32 input)
+{
+ return input;
+}
+
+/*! \fn u32 input_swap(u32 input)
+ * \ingroup BOARD_SPECIFIC_FUNCTIONS
+ * \brief Not used
+ * \return input
+*/
+
+u32 input_swap(u32 input)
+{
+ return input;
+}
+
+/*! \fn void aes_chip_init (void)
+ * \ingroup BOARD_SPECIFIC_FUNCTIONS
+ * \brief initialize AES hardware
+*/
+
+void aes_chip_init (void)
+{
+ volatile struct aes_t *aes = (struct aes_t *) AES_START;
+
+ aes->controlr.SM = 1;
+ aes->controlr.ARS = 1;
+
+}
+
+/*! \fn void des_chip_init (void)
+ * \ingroup BOARD_SPECIFIC_FUNCTIONS
+ * \brief initialize DES hardware
+*/
+
+void des_chip_init (void)
+{
+ volatile struct des_t *des = (struct des_t *) DES_3DES_START;
+
+ // start crypto engine with write to ILR
+ des->controlr.SM = 1;
+ asm("sync");
+ des->controlr.ARS = 1;
+
+}
+
+/*! \fn void chip_version(void)
+ * \ingroup BOARD_SPECIFIC_FUNCTIONS
+ * \brief not used!
+*/
+
+void chip_version(void)
+{
+ return;
+}
+
diff --git a/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_deu_ar9.h.svn-base b/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_deu_ar9.h.svn-base
new file mode 100644
index 0000000..1d84da3
--- /dev/null
+++ b/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_deu_ar9.h.svn-base
@@ -0,0 +1,299 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_deu_ar9.h
+** PROJECT : IFX UEIP
+** MODULES : DEU Module for AR9
+**
+** DATE : September 8, 2009
+** AUTHOR : Mohammad Firdaus
+** DESCRIPTION : Data Encryption Unit Driver
+** COPYRIGHT : Copyright (c) 2009
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 08,Sept 2009 Mohammad Firdaus Initial UEIP release
+*******************************************************************************/
+/*!
+ \defgroup IFX_DEU IFX_DEU_DRIVERS
+ \ingroup API
+ \brief deu driver module
+*/
+
+/*!
+ \defgroup IFX_DEU_DEFINITIONS IFX_DEU_DEFINITIONS
+ \ingroup IFX_DEU
+ \brief ifx deu definitions
+*/
+
+/*!
+ \file ifxmips_deu_ar9.h
+ \brief deu driver header file
+*/
+
+
+#ifndef IFXMIPS_DEU_AR9_H
+#define IFXMIPS_DEU_AR9_H
+
+/* Project Header Files */
+#include <linux/version.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/crypto.h>
+#include <linux/interrupt.h>
+#include <linux/delay.h>
+#include <asm/byteorder.h>
+#include <crypto/algapi.h>
+#include <linux/module.h>
+#include <linux/mm.h>
+#include <asm/scatterlist.h>
+#include <linux/skbuff.h>
+#include <linux/netdevice.h>
+#include "ifxmips_deu.h"
+
+
+/* SHA CONSTANTS */
+#define HASH_CON_VALUE 0x0700002C
+
+#define INPUT_ENDIAN_SWAP(input) input_swap(input)
+#define DEU_ENDIAN_SWAP(input) endian_swap(input)
+#define DELAY_PERIOD 10
+#define FIND_DEU_CHIP_VERSION chip_version()
+#define CLC_START IFX_DEU_CLK
+
+#define AES_INIT 0
+#define DES_INIT 1
+#define ARC4_INIT 2
+#define SHA1_INIT 3
+#define MD5_INIT 4
+#define SHA1_HMAC_INIT 5
+#define MD5_HMAC_INIT 6
+
+#define AES_START IFX_AES_CON
+#define DES_3DES_START IFX_DES_CON
+
+#define WAIT_AES_DMA_READY() \
+ do { \
+ int i; \
+ volatile struct deu_dma_t *dma = (struct deu_dma_t *) IFX_DEU_DMA_CON; \
+ volatile struct aes_t *aes = (volatile struct aes_t *) AES_START; \
+ for (i = 0; i < 10; i++) \
+ udelay(DELAY_PERIOD); \
+ while (dma->controlr.BSY) {}; \
+ while (aes->controlr.BUS) {}; \
+ } while (0)
+
+#define WAIT_DES_DMA_READY() \
+ do { \
+ int i; \
+ volatile struct deu_dma_t *dma = (struct deu_dma_t *) IFX_DEU_DMA_CON; \
+ volatile struct des_t *des = (struct des_t *) DES_3DES_START; \
+ for (i = 0; i < 10; i++) \
+ udelay(DELAY_PERIOD); \
+ while (dma->controlr.BSY) {}; \
+ while (des->controlr.BUS) {}; \
+ } while (0)
+
+#define AES_DMA_MISC_CONFIG() \
+ do { \
+ volatile struct aes_t *aes = (volatile struct aes_t *) AES_START; \
+ aes->controlr.KRE = 1; \
+ aes->controlr.GO = 1; \
+ } while(0)
+
+#define SHA_HASH_INIT \
+ do { \
+ volatile struct deu_hash_t *hash = (struct deu_hash_t *) HASH_START; \
+ hash->controlr.SM = 1; \
+ hash->controlr.ALGO = 0; \
+ hash->controlr.INIT = 1; \
+ } while(0)
+
+/* DEU Common Structures for AR9*/
+
+struct clc_controlr_t {
+ u32 Res:26;
+ u32 FSOE:1;
+ u32 SBWE:1;
+ u32 EDIS:1;
+ u32 SPEN:1;
+ u32 DISS:1;
+ u32 DISR:1;
+
+};
+
+struct des_t {
+ struct des_controlr { //10h
+ u32 KRE:1;
+ u32 reserved1:5;
+ u32 GO:1;
+ u32 STP:1;
+ u32 Res2:6;
+ u32 NDC:1;
+ u32 ENDI:1;
+ u32 Res3:2;
+ u32 F:3;
+ u32 O:3;
+ u32 BUS:1;
+ u32 DAU:1;
+ u32 ARS:1;
+ u32 SM:1;
+ u32 E_D:1;
+ u32 M:3;
+
+ } controlr;
+ u32 IHR; //14h
+ u32 ILR; //18h
+ u32 K1HR; //1c
+ u32 K1LR; //
+ u32 K2HR;
+ u32 K2LR;
+ u32 K3HR;
+ u32 K3LR; //30h
+ u32 IVHR; //34h
+ u32 IVLR; //38
+ u32 OHR; //3c
+ u32 OLR; //40
+};
+
+struct aes_t {
+ struct aes_controlr {
+
+ u32 KRE:1;
+ u32 reserved1:4;
+ u32 PNK:1;
+ u32 GO:1;
+ u32 STP:1;
+ u32 reserved2:6;
+ u32 NDC:1;
+ u32 ENDI:1;
+ u32 reserved3:2;
+ u32 F:3; //fbs
+ u32 O:3; //om
+ u32 BUS:1; //bsy
+ u32 DAU:1;
+ u32 ARS:1;
+ u32 SM:1;
+ u32 E_D:1;
+ u32 KV:1;
+ u32 K:2; //KL
+
+ } controlr;
+ u32 ID3R; //80h
+ u32 ID2R; //84h
+ u32 ID1R; //88h
+ u32 ID0R; //8Ch
+ u32 K7R; //90h
+ u32 K6R; //94h
+ u32 K5R; //98h
+ u32 K4R; //9Ch
+ u32 K3R; //A0h
+ u32 K2R; //A4h
+ u32 K1R; //A8h
+ u32 K0R; //ACh
+ u32 IV3R; //B0h
+ u32 IV2R; //B4h
+ u32 IV1R; //B8h
+ u32 IV0R; //BCh
+ u32 OD3R; //D4h
+ u32 OD2R; //D8h
+ u32 OD1R; //DCh
+ u32 OD0R; //E0h
+};
+
+struct arc4_t {
+ struct arc4_controlr {
+
+ u32 KRE:1;
+ u32 KLEN:4;
+ u32 KSAE:1;
+ u32 GO:1;
+ u32 STP:1;
+ u32 reserved1:6;
+ u32 NDC:1;
+ u32 ENDI:1;
+ u32 reserved2:8;
+ u32 BUS:1; //bsy
+ u32 reserved3:1;
+ u32 ARS:1;
+ u32 SM:1;
+ u32 reserved4:4;
+
+ } controlr;
+ u32 K3R; //104h
+ u32 K2R; //108h
+ u32 K1R; //10Ch
+ u32 K0R; //110h
+
+ u32 IDLEN; //114h
+
+ u32 ID3R; //118h
+ u32 ID2R; //11Ch
+ u32 ID1R; //120h
+ u32 ID0R; //124h
+
+ u32 OD3R; //128h
+ u32 OD2R; //12Ch
+ u32 OD1R; //130h
+ u32 OD0R; //134h
+};
+
+struct deu_hash_t {
+ struct hash_controlr {
+ u32 reserved1:5;
+ u32 KHS:1;
+ u32 GO:1;
+ u32 INIT:1;
+ u32 reserved2:6;
+ u32 NDC:1;
+ u32 ENDI:1;
+ u32 reserved3:7;
+ u32 DGRY:1;
+ u32 BSY:1;
+ u32 reserved4:1;
+ u32 IRCL:1;
+ u32 SM:1;
+ u32 KYUE:1;
+ u32 HMEN:1;
+ u32 SSEN:1;
+ u32 ALGO:1;
+
+ } controlr;
+ u32 MR; //B4h
+ u32 D1R; //B8h
+ u32 D2R; //BCh
+ u32 D3R; //C0h
+ u32 D4R; //C4h
+ u32 D5R; //C8h
+
+ u32 dummy; //CCh
+
+ u32 KIDX; //D0h
+ u32 KEY; //D4h
+ u32 DBN; //D8h
+};
+
+
+struct deu_dma_t {
+ struct dma_controlr {
+ u32 reserved1:22;
+ u32 BS:2;
+ u32 BSY:1;
+ u32 reserved2:1;
+ u32 ALGO:2;
+ u32 RXCLS:2;
+ u32 reserved3:1;
+ u32 EN:1;
+
+ } controlr;
+};
+
+#endif /* IFXMIPS_DEU_AR9_H */
diff --git a/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_deu_danube.c.svn-base b/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_deu_danube.c.svn-base
new file mode 100644
index 0000000..492391d
--- /dev/null
+++ b/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_deu_danube.c.svn-base
@@ -0,0 +1,168 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_deu_danube.c
+** PROJECT : IFX UEIP
+** MODULES : DEU Module for Danube
+**
+** DATE : September 8, 2009
+** AUTHOR : Mohammad Firdaus
+** DESCRIPTION : Data Encryption Unit Driver
+** COPYRIGHT : Copyright (c) 2009
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 08,Sept 2009 Mohammad Firdaus Initial UEIP release
+*******************************************************************************/
+/*!
+ \defgroup IFX_DEU IFX_DEU_DRIVERS
+ \ingroup API
+ \brief deu driver module
+*/
+
+/*!
+ \file ifxmips_deu_danube.c
+ \ingroup IFX_DEU
+ \brief board specific deu driver file for danube
+*/
+
+/*!
+ \defgroup BOARD_SPECIFIC_FUNCTIONS IFX_BOARD_SPECIFIC_FUNCTIONS
+ \ingroup IFX_DEU
+ \brief board specific deu functions
+*/
+
+/* Project header files */
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <asm/io.h> //dma_cache_inv
+
+#include "ifxmips_deu_dma.h"
+#include "ifxmips_deu_danube.h"
+
+
+/* Function Declerations */
+int aes_memory_allocate(int value);
+int des_memory_allocate(int value);
+void memory_release(u32 *addr);
+int aes_chip_init (void);
+void des_chip_init (void);
+int deu_dma_init (void);
+u32 endian_swap(u32 input);
+u32* memory_alignment(const u8 *arg, u32 *buff_alloc, int in_out, int nbytes);
+void dma_memory_copy(u32 *outcopy, u32 *out_dma, u8 *out_arg, int nbytes);
+void chip_version(void);
+void deu_dma_priv_init(void);
+void __exit ifxdeu_fini_dma(void);
+
+#define DES_3DES_START IFX_DES_CON
+#define AES_START IFX_AES_CON
+#define CLC_START IFX_DEU_CLK
+
+/* Variables definition */
+int ifx_danube_pre_1_4;
+u8 *g_dma_page_ptr = NULL;
+u8 *g_dma_block = NULL;
+u8 *g_dma_block2 = NULL;
+
+deu_drv_priv_t deu_dma_priv;
+
+
+/*! \fn u32 endian_swap(u32 input)
+ * \ingroup BOARD_SPECIFIC_FUNCTIONS
+ * \brief function is not used
+ * \param input Data input to be swapped
+ * \return input
+*/
+
+u32 endian_swap(u32 input)
+{
+ return input;
+}
+
+/*! \fn u32 input_swap(u32 input)
+ * \ingroup BOARD_SPECIFIC_FUNCTIONS
+ * \brief Swap the input data if the current chip is Danube version
+ * 1.4 and do nothing to the data if the current chip is
+ * Danube version 1.3
+ * \param input data that needs to be swapped
+ * \return input or swapped input
+*/
+
+u32 input_swap(u32 input)
+{
+ if (!ifx_danube_pre_1_4) {
+ u8 *ptr = (u8 *)&input;
+ return ((ptr[3] << 24) | (ptr[2] << 16) | (ptr[1] << 8) | ptr[0]);
+ }
+ else
+ return input;
+}
+
+
+
+/*! \fn void aes_chip_init (void)
+ * \ingroup BOARD_SPECIFIC_FUNCTIONS
+ * \brief initialize AES hardware
+*/
+
+int aes_chip_init (void)
+{
+ volatile struct aes_t *aes = (struct aes_t *) AES_START;
+
+ //start crypto engine with write to ILR
+ aes->controlr.SM = 1;
+ aes->controlr.ARS = 1;
+ return 0;
+}
+
+/*! \fn void des_chip_init (void)
+ * \ingroup BOARD_SPECIFIC_FUNCTIONS
+ * \brief initialize DES hardware
+*/
+
+void des_chip_init (void)
+{
+ volatile struct des_t *des = (struct des_t *) DES_3DES_START;
+
+ // start crypto engine with write to ILR
+ des->controlr.SM = 1;
+ des->controlr.ARS = 1;
+}
+
+/*! \fn void chip_version (void)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief To find the version of the chip by looking at the chip ID
+ * \param ifx_danube_pre_1_4 (sets to 1 if Chip is Danube less than v1.4)
+*/
+#define IFX_MPS (KSEG1 | 0x1F107000)
+#define IFX_MPS_CHIPID ((volatile u32*)(IFX_MPS + 0x0344))
+
+void chip_version(void)
+{
+
+ /* DANUBE PRE 1.4 SOFTWARE FIX */
+ int chip_id = 0;
+ chip_id = *IFX_MPS_CHIPID;
+ chip_id >>= 28;
+
+ if (chip_id >= 4) {
+ ifx_danube_pre_1_4 = 0;
+ printk("Danube Chip ver. 1.4 detected. \n");
+ }
+ else {
+ ifx_danube_pre_1_4 = 1;
+ printk("Danube Chip ver. 1.3 or below detected. \n");
+ }
+
+ return;
+}
+
diff --git a/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_deu_danube.h.svn-base b/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_deu_danube.h.svn-base
new file mode 100644
index 0000000..62ad96d
--- /dev/null
+++ b/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_deu_danube.h.svn-base
@@ -0,0 +1,250 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_deu_danube.h
+** PROJECT : IFX UEIP
+** MODULES : DEU Module for Danube
+**
+** DATE : September 8, 2009
+** AUTHOR : Mohammad Firdaus
+** DESCRIPTION : Data Encryption Unit Driver
+** COPYRIGHT : Copyright (c) 2009
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 08,Sept 2009 Mohammad Firdaus Initial UEIP release
+*******************************************************************************/
+/*!
+ \defgroup IFX_DEU IFX_DEU_DRIVERS
+ \ingroup API
+ \brief deu driver module
+*/
+
+/*!
+ \file ifxmips_deu_danube.h
+ \brief board specific driver header file for danube
+*/
+
+/*!
+ \defgroup BOARD_SPECIFIC_FUNCTIONS IFX_BOARD_SPECIFIC_FUNCTIONS
+ \ingroup IFX_DEU
+ \brief board specific deu header files
+*/
+
+#ifndef IFXMIPS_DEU_DANUBE_H
+#define IFXMIPS_DEU_DANUBE_H
+
+/* Project Header Files */
+#include <linux/version.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/crypto.h>
+#include <linux/interrupt.h>
+#include <linux/delay.h>
+#include <asm/byteorder.h>
+#include <crypto/algapi.h>
+#include <linux/module.h>
+#include <linux/mm.h>
+#include <asm/scatterlist.h>
+#include <linux/skbuff.h>
+#include <linux/netdevice.h>
+#include "ifxmips_deu.h"
+
+
+
+#define INPUT_ENDIAN_SWAP(input) input_swap(input)
+#define DEU_ENDIAN_SWAP(input) endian_swap(input)
+#define FIND_DEU_CHIP_VERSION chip_version()
+#define AES_DMA_MISC_CONFIG()
+#define CLC_START IFX_DEU_CLK
+
+#define AES_START IFX_AES_CON
+#define DES_3DES_START IFX_DES_CON
+
+#define AES_INIT 0
+#define DES_INIT 1
+#define SHA1_INIT 2
+#define MD5_INIT 3
+
+#define WAIT_AES_DMA_READY() \
+ do { \
+ int i; \
+ volatile struct deu_dma_t *dma = (struct deu_dma_t *) IFX_DEU_DMA_CON; \
+ volatile struct aes_t *aes = (volatile struct aes_t *) AES_START; \
+ for (i = 0; i < 10; i++) \
+ udelay(DELAY_PERIOD); \
+ while (dma->controlr.BSY) {}; \
+ while (aes->controlr.BUS) {}; \
+ } while (0)
+
+#define WAIT_DES_DMA_READY() \
+ do { \
+ int i; \
+ volatile struct deu_dma_t *dma = (struct deu_dma_t *) IFX_DEU_DMA_CON; \
+ volatile struct des_t *des = (struct des_t *) DES_3DES_START; \
+ for (i = 0; i < 10; i++) \
+ udelay(DELAY_PERIOD); \
+ while (dma->controlr.BSY) {}; \
+ while (des->controlr.BUS) {}; \
+ } while (0)
+
+#define SHA_HASH_INIT \
+ do { \
+ volatile struct deu_hash_t *hash = (struct deu_hash_t *) HASH_START; \
+ hash->controlr.SM = 1; \
+ hash->controlr.ALGO = 0; \
+ hash->controlr.INIT = 1; \
+ } while(0)
+
+/* DEU STRUCTURES */
+
+struct clc_controlr_t {
+ u32 Res:26;
+ u32 FSOE:1;
+ u32 SBWE:1;
+ u32 EDIS:1;
+ u32 SPEN:1;
+ u32 DISS:1;
+ u32 DISR:1;
+
+};
+
+struct des_t {
+ struct des_controlr { //10h
+ u32 KRE:1;
+ u32 reserved1:5;
+ u32 GO:1;
+ u32 STP:1;
+ u32 Res2:6;
+ u32 NDC:1;
+ u32 ENDI:1;
+ u32 Res3:2;
+ u32 F:3;
+ u32 O:3;
+ u32 BUS:1;
+ u32 DAU:1;
+ u32 ARS:1;
+ u32 SM:1;
+ u32 E_D:1;
+ u32 M:3;
+
+ } controlr;
+ u32 IHR; //14h
+ u32 ILR; //18h
+ u32 K1HR; //1c
+ u32 K1LR; //
+ u32 K2HR;
+ u32 K2LR;
+ u32 K3HR;
+ u32 K3LR; //30h
+ u32 IVHR; //34h
+ u32 IVLR; //38
+ u32 OHR; //3c
+ u32 OLR; //40
+};
+
+struct aes_t {
+ struct aes_controlr {
+
+ u32 KRE:1;
+ u32 reserved1:4;
+ u32 PNK:1;
+ u32 GO:1;
+ u32 STP:1;
+
+ u32 reserved2:6;
+ u32 NDC:1;
+ u32 ENDI:1;
+ u32 reserved3:2;
+
+ u32 F:3; //fbs
+ u32 O:3; //om
+ u32 BUS:1; //bsy
+ u32 DAU:1;
+ u32 ARS:1;
+ u32 SM:1;
+ u32 E_D:1;
+ u32 KV:1;
+ u32 K:2; //KL
+
+ } controlr;
+ u32 ID3R; //80h
+ u32 ID2R; //84h
+ u32 ID1R; //88h
+ u32 ID0R; //8Ch
+ u32 K7R; //90h
+ u32 K6R; //94h
+ u32 K5R; //98h
+ u32 K4R; //9Ch
+ u32 K3R; //A0h
+ u32 K2R; //A4h
+ u32 K1R; //A8h
+ u32 K0R; //ACh
+ u32 IV3R; //B0h
+ u32 IV2R; //B4h
+ u32 IV1R; //B8h
+ u32 IV0R; //BCh
+ u32 OD3R; //D4h
+ u32 OD2R; //D8h
+ u32 OD1R; //DCh
+ u32 OD0R; //E0h
+};
+
+struct deu_hash_t {
+ struct hash_controlr {
+ u32 reserved1:5;
+ u32 KHS:1;
+ u32 GO:1;
+ u32 INIT:1;
+ u32 reserved2:6;
+ u32 NDC:1;
+ u32 ENDI:1;
+ u32 reserved3:7;
+ u32 DGRY:1;
+ u32 BSY:1;
+ u32 reserved4:1;
+ u32 IRCL:1;
+ u32 SM:1;
+ u32 KYUE:1;
+ u32 HMEN:1;
+ u32 SSEN:1;
+ u32 ALGO:1;
+
+ } controlr;
+ u32 MR; //B4h
+ u32 D1R; //B8h
+ u32 D2R; //BCh
+ u32 D3R; //C0h
+ u32 D4R; //C4h
+ u32 D5R; //C8h
+
+ u32 dummy; //CCh
+
+ u32 KIDX; //D0h
+ u32 KEY; //D4h
+ u32 DBN; //D8h
+};
+
+struct deu_dma_t {
+ struct dma_controlr {
+ u32 reserved1:22;
+ u32 BS:2;
+ u32 BSY:1;
+ u32 reserved2:1;
+ u32 ALGO:2;
+ u32 RXCLS:2;
+ u32 reserved3:1;
+ u32 EN:1;
+
+ } controlr;
+};
+
+#endif /* IFXMIPS_DEU_DANUBE_H */
diff --git a/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_deu_dma.c.svn-base b/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_deu_dma.c.svn-base
new file mode 100644
index 0000000..13dc921
--- /dev/null
+++ b/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_deu_dma.c.svn-base
@@ -0,0 +1,42 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_deu_dma.c
+** PROJECT : IFX UEIP
+** MODULES : DEU Module for Danube
+**
+** DATE : September 8, 2009
+** AUTHOR : Mohammad Firdaus
+** DESCRIPTION : Data Encryption Unit Driver
+** COPYRIGHT : Copyright (c) 2009
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 08 Sept 2009 Mohammad Firdaus Initial UEIP release
+*******************************************************************************/
+/*!
+ \defgroup IFX_DEU IFX_DEU_DRIVERS
+ \ingroup IFX_API
+ \brief ifx deu driver module
+*/
+
+/*!
+ \file ifxmips_deu_dma.c
+ \ingroup IFX_DEU
+ \brief DMA deu driver file
+*/
+
+/*!
+ \defgroup IFX_DMA_FUNCTIONS IFX_DMA_FUNCTIONS
+ \ingroup IFX_DEU
+ \brief deu-dma driver functions
+*/
+
+/* Project header files */
+
diff --git a/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_deu_dma.h.svn-base b/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_deu_dma.h.svn-base
new file mode 100644
index 0000000..5198a4a
--- /dev/null
+++ b/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_deu_dma.h.svn-base
@@ -0,0 +1,69 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_deu_dma.h
+** DESCRIPTION : Data Encryption Unit Driver
+** COPYRIGHT : Copyright (c) 2009
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 08,Sept 2009 Mohammad Firdaus Initial UEIP release
+*******************************************************************************/
+
+/*!
+ \addtogroup IFX_DEU IFX_DEU_DRIVERS
+ \ingroup API
+ \brief ifx deu driver module
+*/
+
+/*!
+ \file ifxmips_deu_dma.h
+ \ingroup IFX_DEU
+ \brief DMA deu driver header file
+*/
+
+#ifndef IFXMIPS_DEU_DMA_H
+#define IFXMIPS_DEU_DMA_H
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/mm.h>
+#include <linux/crypto.h>
+#include <asm/scatterlist.h>
+#include <asm/byteorder.h>
+#include <linux/skbuff.h>
+#include <linux/netdevice.h>
+
+// must match the size of memory block allocated for g_dma_block and g_dma_block2
+#define DEU_MAX_PACKET_SIZE (PAGE_SIZE >> 1)
+
+typedef struct ifx_deu_device {
+ struct dma_device_info *dma_device;
+ u8 *dst;
+ u8 *src;
+ int len;
+ int dst_count;
+ int src_count;
+ int recv_count;
+ int packet_size;
+ int packet_num;
+ wait_queue_t wait;
+} _ifx_deu_device;
+
+extern _ifx_deu_device ifx_deu[1];
+
+extern int deu_dma_intr_handler (struct dma_device_info *, int);
+extern u8 *deu_dma_buffer_alloc (int, int *, void **);
+extern int deu_dma_buffer_free (u8 *, void *);
+extern void deu_dma_inactivate_poll(struct dma_device_info* dma_dev);
+extern void deu_dma_activate_poll (struct dma_device_info* dma_dev);
+extern struct dma_device_info* deu_dma_reserve(struct dma_device_info** dma_device);
+extern int deu_dma_release(struct dma_device_info** dma_device);
+
+#endif /* IFMIPS_DEU_DMA_H */
diff --git a/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_deu_vr9.c.svn-base b/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_deu_vr9.c.svn-base
new file mode 100644
index 0000000..aaa7bce
--- /dev/null
+++ b/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_deu_vr9.c.svn-base
@@ -0,0 +1,144 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_deu_vr9.c
+** PROJECT : IFX UEIP
+** MODULES : DEU Module for VR9
+**
+** DATE : September 8, 2009
+** AUTHOR : Mohammad Firdaus
+** DESCRIPTION : Data Encryption Unit Driver
+** COPYRIGHT : Copyright (c) 2009
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 08,Sept 2009 Mohammad Firdaus Initial UEIP release
+*******************************************************************************/
+
+/*!
+ \defgroup IFX_DEU IFX_DEU_DRIVERS
+ \ingroup API
+ \brief deu driver module
+*/
+
+/*!
+ \file ifxmips_deu_vr9.c
+ \ingroup IFX_DEU
+ \brief board specific deu driver file for vr9
+*/
+
+/*!
+ \defgroup BOARD_SPECIFIC_FUNCTIONS IFX_BOARD_SPECIFIC_FUNCTIONS
+ \ingroup IFX_DEU
+ \brief board specific deu driver functions
+*/
+
+/* Project header files */
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <asm/io.h> //dma_cache_inv
+
+#include "ifxmips_deu_dma.h"
+#include "ifxmips_deu_vr9.h"
+
+/* Function decleration */
+void aes_chip_init (void);
+void des_chip_init (void);
+int deu_dma_init (void);
+void deu_dma_priv_init(void);
+u32 endian_swap(u32 input);
+u32* memory_alignment(const u8 *arg, u32 *buff_alloc, int in_out, int nbytes);
+void aes_dma_memory_copy(u32 *outcopy, u32 *out_dma, u8 *out_arg, int nbytes);
+void des_dma_memory_copy(u32 *outcopy, u32 *out_dma, u8 *out_arg, int nbytes);
+void __exit ifxdeu_fini_dma(void);
+
+#define DES_3DES_START IFX_DES_CON
+#define AES_START IFX_AES_CON
+
+/* Variables */
+
+u8 *g_dma_page_ptr = NULL;
+u8 *g_dma_block = NULL;
+u8 *g_dma_block2 = NULL;
+
+deu_drv_priv_t deu_dma_priv;
+
+
+/*! \fn u32 endian_swap(u32 input)
+ * \ingroup BOARD_SPECIFIC_FUNCTIONS
+ * \brief Swap data given to the function
+ * \param input Data input to be swapped
+ * \return either the swapped data or the input data depending on whether it is in DMA mode or FPI mode
+*/
+
+
+u32 endian_swap(u32 input)
+{
+ return input;
+}
+
+/*! \fn u32 input_swap(u32 input)
+ * \ingroup BOARD_SPECIFIC_FUNCTIONS
+ * \brief Not used
+ * \return input
+*/
+
+u32 input_swap(u32 input)
+{
+ return input;
+}
+
+/*! \fn void aes_chip_init (void)
+ * \ingroup BOARD_SPECIFIC_FUNCTIONS
+ * \brief initialize AES hardware
+*/
+
+void aes_chip_init (void)
+{
+ volatile struct aes_t *aes = (struct aes_t *) AES_START;
+
+ // start crypto engine with write to ILR
+ aes->controlr.SM = 1;
+ aes->controlr.NDC = 0;
+ asm("sync");
+ aes->controlr.ENDI = 1;
+ asm("sync");
+ aes->controlr.ARS = 0;
+
+}
+
+/*! \fn void des_chip_init (void)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief initialize DES hardware
+*/
+
+void des_chip_init (void)
+{
+ volatile struct des_t *des = (struct des_t *) DES_3DES_START;
+
+ // start crypto engine with write to ILR
+ des->controlr.SM = 1;
+ des->controlr.NDC = 1;
+ asm("sync");
+ des->controlr.ENDI = 1;
+ asm("sync");
+ des->controlr.ARS = 0;
+
+}
+/*! \fn void chip_version(void)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief function not used in VR9
+*/
+void chip_version(void)
+{
+ return;
+}
+
diff --git a/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_deu_vr9.h.svn-base b/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_deu_vr9.h.svn-base
new file mode 100644
index 0000000..d2cfd11
--- /dev/null
+++ b/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_deu_vr9.h.svn-base
@@ -0,0 +1,324 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_deu_vr9.h
+** PROJECT : IFX UEIP
+** MODULES : DEU Module for VR9
+**
+** DATE : September 8, 2009
+** AUTHOR : Mohammad Firdaus
+** DESCRIPTION : Data Encryption Unit Driver
+** COPYRIGHT : Copyright (c) 2009
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 08,Sept 2009 Mohammad Firdaus Initial UEIP release
+*******************************************************************************/
+/*!
+ \defgroup IFX_DEU IFX_DEU_DRIVERS
+ \ingroup API
+ \brief deu driver module
+*/
+
+/*!
+ \file ifxmips_deu_vr9.h
+ \ingroup IFX_DEU
+ \brief board specific deu driver header file for vr9
+*/
+
+/*!
+ \defgroup IFX_DEU_DEFINITIONS IFX_DEU_DEFINITIONS
+ \brief deu driver header file
+*/
+
+
+#ifndef IFXMIPS_DEU_VR9_H
+#define IFXMIPS_DEU_VR9_H
+
+/* Project Header Files */
+#include <linux/version.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/crypto.h>
+#include <linux/interrupt.h>
+#include <linux/delay.h>
+#include <asm/byteorder.h>
+#include <crypto/algapi.h>
+#include <linux/module.h>
+#include <linux/mm.h>
+#include <asm/scatterlist.h>
+#include <linux/skbuff.h>
+#include <linux/netdevice.h>
+#include "ifxmips_deu.h"
+
+
+#define AES_INIT 1
+#define DES_INIT 2
+#define ARC4_INIT 3
+#define SHA1_INIT 4
+#define MD5_INIT 5
+#define SHA1_HMAC_INIT 6
+#define MD5_HMAC_INIT 7
+
+#define AES_START IFX_AES_CON
+#define DES_3DES_START IFX_DES_CON
+
+#if 0
+#define AES_IDLE 0
+#define AES_BUSY 1
+#define AES_STARTED 2
+#define AES_COMPLETED 3
+#define DES_IDLE 0
+#define DES_BUSY 1
+#define DES_STARTED 2
+#define DES_COMPLETED 3
+#endif
+
+/* SHA1 CONSTANT */
+#define HASH_CON_VALUE 0x0701002C
+
+#define INPUT_ENDIAN_SWAP(input) input_swap(input)
+#define DEU_ENDIAN_SWAP(input) endian_swap(input)
+#define FIND_DEU_CHIP_VERSION chip_version()
+
+#if defined (CONFIG_AR10)
+#define DELAY_PERIOD 30
+#else
+#define DELAY_PERIOD 10
+#endif
+
+#define WAIT_AES_DMA_READY() \
+ do { \
+ int i; \
+ volatile struct deu_dma_t *dma = (struct deu_dma_t *) IFX_DEU_DMA_CON; \
+ volatile struct aes_t *aes = (volatile struct aes_t *) AES_START; \
+ for (i = 0; i < 10; i++) \
+ udelay(DELAY_PERIOD); \
+ while (dma->controlr.BSY) {}; \
+ while (aes->controlr.BUS) {}; \
+ } while (0)
+
+#define WAIT_DES_DMA_READY() \
+ do { \
+ int i; \
+ volatile struct deu_dma_t *dma = (struct deu_dma_t *) IFX_DEU_DMA_CON; \
+ volatile struct des_t *des = (struct des_t *) DES_3DES_START; \
+ for (i = 0; i < 10; i++) \
+ udelay(DELAY_PERIOD); \
+ while (dma->controlr.BSY) {}; \
+ while (des->controlr.BUS) {}; \
+ } while (0)
+
+#define AES_DMA_MISC_CONFIG() \
+ do { \
+ volatile struct aes_t *aes = (volatile struct aes_t *) AES_START; \
+ aes->controlr.KRE = 1; \
+ aes->controlr.GO = 1; \
+ } while(0)
+
+#define SHA_HASH_INIT \
+ do { \
+ volatile struct deu_hash_t *hash = (struct deu_hash_t *) HASH_START; \
+ hash->controlr.ENDI = 1; \
+ hash->controlr.SM = 1; \
+ hash->controlr.ALGO = 0; \
+ hash->controlr.INIT = 1; \
+ } while(0)
+
+#define MD5_HASH_INIT \
+ do { \
+ volatile struct deu_hash_t *hash = (struct deu_hash_t *) HASH_START; \
+ hash->controlr.ENDI = 1; \
+ hash->controlr.SM = 1; \
+ hash->controlr.ALGO = 1; \
+ hash->controlr.INIT = 1; \
+ } while(0)
+
+/* DEU Common Structures for AR9*/
+
+struct clc_controlr_t {
+ u32 Res:26;
+ u32 FSOE:1;
+ u32 SBWE:1;
+ u32 EDIS:1;
+ u32 SPEN:1;
+ u32 DISS:1;
+ u32 DISR:1;
+
+};
+
+struct des_t {
+ struct des_controlr { //10h
+ u32 KRE:1;
+ u32 reserved1:5;
+ u32 GO:1;
+ u32 STP:1;
+ u32 Res2:6;
+ u32 NDC:1;
+ u32 ENDI:1;
+ u32 Res3:2;
+ u32 F:3;
+ u32 O:3;
+ u32 BUS:1;
+ u32 DAU:1;
+ u32 ARS:1;
+ u32 SM:1;
+ u32 E_D:1;
+ u32 M:3;
+
+ } controlr;
+ u32 IHR; //14h
+ u32 ILR; //18h
+ u32 K1HR; //1c
+ u32 K1LR; //
+ u32 K2HR;
+ u32 K2LR;
+ u32 K3HR;
+ u32 K3LR; //30h
+ u32 IVHR; //34h
+ u32 IVLR; //38
+ u32 OHR; //3c
+ u32 OLR; //40
+};
+
+struct aes_t {
+ struct aes_controlr {
+
+ u32 KRE:1;
+ u32 reserved1:4;
+ u32 PNK:1;
+ u32 GO:1;
+ u32 STP:1;
+ u32 reserved2:6;
+ u32 NDC:1;
+ u32 ENDI:1;
+ u32 reserved3:2;
+ u32 F:3; //fbs
+ u32 O:3; //om
+ u32 BUS:1; //bsy
+ u32 DAU:1;
+ u32 ARS:1;
+ u32 SM:1;
+ u32 E_D:1;
+ u32 KV:1;
+ u32 K:2; //KL
+
+ } controlr;
+ u32 ID3R; //80h
+ u32 ID2R; //84h
+ u32 ID1R; //88h
+ u32 ID0R; //8Ch
+ u32 K7R; //90h
+ u32 K6R; //94h
+ u32 K5R; //98h
+ u32 K4R; //9Ch
+ u32 K3R; //A0h
+ u32 K2R; //A4h
+ u32 K1R; //A8h
+ u32 K0R; //ACh
+ u32 IV3R; //B0h
+ u32 IV2R; //B4h
+ u32 IV1R; //B8h
+ u32 IV0R; //BCh
+ u32 OD3R; //D4h
+ u32 OD2R; //D8h
+ u32 OD1R; //DCh
+ u32 OD0R; //E0h
+};
+
+struct arc4_t {
+ struct arc4_controlr {
+
+ u32 KRE:1;
+ u32 KLEN:4;
+ u32 KSAE:1;
+ u32 GO:1;
+ u32 STP:1;
+ u32 reserved1:6;
+ u32 NDC:1;
+ u32 ENDI:1;
+ u32 reserved2:8;
+ u32 BUS:1; //bsy
+ u32 reserved3:1;
+ u32 ARS:1;
+ u32 SM:1;
+ u32 reserved4:4;
+
+ } controlr;
+ u32 K3R; //104h
+ u32 K2R; //108h
+ u32 K1R; //10Ch
+ u32 K0R; //110h
+
+ u32 IDLEN; //114h
+
+ u32 ID3R; //118h
+ u32 ID2R; //11Ch
+ u32 ID1R; //120h
+ u32 ID0R; //124h
+
+ u32 OD3R; //128h
+ u32 OD2R; //12Ch
+ u32 OD1R; //130h
+ u32 OD0R; //134h
+};
+
+struct deu_hash_t {
+ struct hash_controlr {
+ u32 reserved1:5;
+ u32 KHS:1;
+ u32 GO:1;
+ u32 INIT:1;
+ u32 reserved2:6;
+ u32 NDC:1;
+ u32 ENDI:1;
+ u32 reserved3:7;
+ u32 DGRY:1;
+ u32 BSY:1;
+ u32 reserved4:1;
+ u32 IRCL:1;
+ u32 SM:1;
+ u32 KYUE:1;
+ u32 HMEN:1;
+ u32 SSEN:1;
+ u32 ALGO:1;
+
+ } controlr;
+ u32 MR; //B4h
+ u32 D1R; //B8h
+ u32 D2R; //BCh
+ u32 D3R; //C0h
+ u32 D4R; //C4h
+ u32 D5R; //C8h
+
+ u32 dummy; //CCh
+
+ u32 KIDX; //D0h
+ u32 KEY; //D4h
+ u32 DBN; //D8h
+};
+
+
+struct deu_dma_t {
+ struct dma_controlr {
+ u32 reserved1:22;
+ u32 BS:2;
+ u32 BSY:1;
+ u32 reserved2:1;
+ u32 ALGO:2;
+ u32 RXCLS:2;
+ u32 reserved3:1;
+ u32 EN:1;
+
+ } controlr;
+};
+
+#endif /* IFXMIPS_DEU_VR9_H */
diff --git a/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_md5.c.svn-base b/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_md5.c.svn-base
new file mode 100644
index 0000000..591389f
--- /dev/null
+++ b/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_md5.c.svn-base
@@ -0,0 +1,310 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_md5.c
+** PROJECT : IFX UEIP
+** MODULES : DEU Module for UEIP
+**
+** DATE : September 8, 2009
+** AUTHOR : Mohammad Firdaus
+** DESCRIPTION : Data Encryption Unit Driver
+** COPYRIGHT : Copyright (c) 2009
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 08,Sept 2009 Mohammad Firdaus Initial UEIP release
+*******************************************************************************/
+/*!
+ \defgroup IFX_DEU IFX_DEU_DRIVERS
+ \ingroup API
+ \brief ifx deu driver module
+*/
+
+/*!
+ \file ifxmips_md5.c
+ \ingroup IFX_DEU
+ \brief MD5 encryption deu driver file
+*/
+
+/*!
+ \defgroup IFX_MD5_FUNCTIONS IFX_MD5_FUNCTIONS
+ \ingroup IFX_DEU
+ \brief ifx deu MD5 functions
+*/
+
+/*Project header files */
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/string.h>
+#include <linux/crypto.h>
+#include <linux/types.h>
+#include <crypto/internal/hash.h>
+#include <asm/byteorder.h>
+
+/* Project header */
+#if defined(CONFIG_DANUBE)
+#include "ifxmips_deu_danube.h"
+#elif defined(CONFIG_AR9)
+#include "ifxmips_deu_ar9.h"
+#elif defined(CONFIG_VR9) || defined(CONFIG_AR10)
+#include "ifxmips_deu_vr9.h"
+#else
+#error "Plaform Unknwon!"
+#endif
+
+#define MD5_DIGEST_SIZE 16
+#define MD5_HMAC_BLOCK_SIZE 64
+#define MD5_BLOCK_WORDS 16
+#define MD5_HASH_WORDS 4
+#define HASH_START IFX_HASH_CON
+
+static spinlock_t lock;
+#define CRTCL_SECT_INIT spin_lock_init(&lock)
+#define CRTCL_SECT_START spin_lock_irqsave(&lock, flag)
+#define CRTCL_SECT_END spin_unlock_irqrestore(&lock, flag)
+
+//#define CRYPTO_DEBUG
+#ifdef CRYPTO_DEBUG
+extern char debug_level;
+#define DPRINTF(level, format, args...) if (level < debug_level) printk(KERN_INFO "[%s %s %d]: " format, __FILE__, __func__, __LINE__, ##args);
+#else
+#define DPRINTF(level, format, args...)
+#endif
+
+struct md5_ctx {
+ int started;
+ u32 hash[MD5_HASH_WORDS];
+ u32 block[MD5_BLOCK_WORDS];
+ u64 byte_count;
+};
+
+extern int disable_deudma;
+
+/*! \fn static u32 endian_swap(u32 input)
+ * \ingroup IFX_MD5_FUNCTIONS
+ * \brief perform dword level endian swap
+ * \param input value of dword that requires to be swapped
+*/
+static u32 endian_swap(u32 input)
+{
+ u8 *ptr = (u8 *)&input;
+
+ return ((ptr[3] << 24) | (ptr[2] << 16) | (ptr[1] << 8) | ptr[0]);
+}
+
+/*! \fn static void md5_transform(u32 *hash, u32 const *in)
+ * \ingroup IFX_MD5_FUNCTIONS
+ * \brief main interface to md5 hardware
+ * \param hash current hash value
+ * \param in 64-byte block of input
+*/
+static void md5_transform(struct md5_ctx *mctx, u32 *hash, u32 const *in)
+{
+ int i;
+ volatile struct deu_hash_t *hashs = (struct deu_hash_t *) HASH_START;
+ unsigned long flag;
+
+ CRTCL_SECT_START;
+
+ if (mctx->started) {
+ hashs->D1R = endian_swap(*((u32 *) hash + 0));
+ hashs->D2R = endian_swap(*((u32 *) hash + 1));
+ hashs->D3R = endian_swap(*((u32 *) hash + 2));
+ hashs->D4R = endian_swap(*((u32 *) hash + 3));
+ }
+
+ for (i = 0; i < 16; i++) {
+ hashs->MR = endian_swap(in[i]);
+// printk("in[%d]: %08x\n", i, endian_swap(in[i]));
+ };
+
+ //wait for processing
+ while (hashs->controlr.BSY) {
+ // this will not take long
+ }
+
+ *((u32 *) hash + 0) = endian_swap (hashs->D1R);
+ *((u32 *) hash + 1) = endian_swap (hashs->D2R);
+ *((u32 *) hash + 2) = endian_swap (hashs->D3R);
+ *((u32 *) hash + 3) = endian_swap (hashs->D4R);
+
+ mctx->started = 1;
+
+ CRTCL_SECT_END;
+}
+
+/*! \fn static inline void md5_transform_helper(struct md5_ctx *ctx)
+ * \ingroup IFX_MD5_FUNCTIONS
+ * \brief interfacing function for md5_transform()
+ * \param ctx crypto context
+*/
+static inline void md5_transform_helper(struct md5_ctx *ctx)
+{
+ //le32_to_cpu_array(ctx->block, sizeof(ctx->block) / sizeof(u32));
+ md5_transform(ctx, ctx->hash, ctx->block);
+}
+
+/*! \fn static void md5_init(struct crypto_tfm *tfm)
+ * \ingroup IFX_MD5_FUNCTIONS
+ * \brief initialize md5 hardware
+ * \param tfm linux crypto algo transform
+*/
+static int md5_init(struct shash_desc *desc)
+{
+ struct md5_ctx *mctx = shash_desc_ctx(desc);
+ volatile struct deu_hash_t *hash = (struct deu_hash_t *) HASH_START;
+
+ hash->controlr.ENDI = 0;
+ hash->controlr.SM = 1;
+ hash->controlr.ALGO = 1; // 1 = md5 0 = sha1
+ hash->controlr.INIT = 1; // Initialize the hash operation by writing a '1' to the INIT bit.
+
+ mctx->byte_count = 0;
+ mctx->started = 0;
+ return 0;
+}
+
+/*! \fn static void md5_update(struct crypto_tfm *tfm, const u8 *data, unsigned int len)
+ * \ingroup IFX_MD5_FUNCTIONS
+ * \brief on-the-fly md5 computation
+ * \param tfm linux crypto algo transform
+ * \param data input data
+ * \param len size of input data
+*/
+static int md5_update(struct shash_desc *desc, const u8 *data, unsigned int len)
+{
+ struct md5_ctx *mctx = shash_desc_ctx(desc);
+ const u32 avail = sizeof(mctx->block) - (mctx->byte_count & 0x3f);
+
+ mctx->byte_count += len;
+
+ if (avail > len) {
+ memcpy((char *)mctx->block + (sizeof(mctx->block) - avail),
+ data, len);
+ return 0;
+ }
+
+ memcpy((char *)mctx->block + (sizeof(mctx->block) - avail),
+ data, avail);
+
+ md5_transform_helper(mctx);
+ data += avail;
+ len -= avail;
+
+ while (len >= sizeof(mctx->block)) {
+ memcpy(mctx->block, data, sizeof(mctx->block));
+ md5_transform_helper(mctx);
+ data += sizeof(mctx->block);
+ len -= sizeof(mctx->block);
+ }
+
+ memcpy(mctx->block, data, len);
+ return 0;
+}
+
+/*! \fn static void md5_final(struct crypto_tfm *tfm, u8 *out)
+ * \ingroup IFX_MD5_FUNCTIONS
+ * \brief compute final md5 value
+ * \param tfm linux crypto algo transform
+ * \param out final md5 output value
+*/
+static int md5_final(struct shash_desc *desc, u8 *out)
+{
+ struct md5_ctx *mctx = shash_desc_ctx(desc);
+ const unsigned int offset = mctx->byte_count & 0x3f;
+ char *p = (char *)mctx->block + offset;
+ int padding = 56 - (offset + 1);
+ volatile struct deu_hash_t *hashs = (struct deu_hash_t *) HASH_START;
+ unsigned long flag;
+
+ *p++ = 0x80;
+ if (padding < 0) {
+ memset(p, 0x00, padding + sizeof (u64));
+ md5_transform_helper(mctx);
+ p = (char *)mctx->block;
+ padding = 56;
+ }
+
+ memset(p, 0, padding);
+ mctx->block[14] = endian_swap(mctx->byte_count << 3);
+ mctx->block[15] = endian_swap(mctx->byte_count >> 29);
+
+#if 0
+ le32_to_cpu_array(mctx->block, (sizeof(mctx->block) -
+ sizeof(u64)) / sizeof(u32));
+#endif
+
+ md5_transform(mctx, mctx->hash, mctx->block);
+
+ CRTCL_SECT_START;
+
+ *((u32 *) out + 0) = endian_swap (hashs->D1R);
+ *((u32 *) out + 1) = endian_swap (hashs->D2R);
+ *((u32 *) out + 2) = endian_swap (hashs->D3R);
+ *((u32 *) out + 3) = endian_swap (hashs->D4R);
+
+ CRTCL_SECT_END;
+
+ // Wipe context
+ memset(mctx, 0, sizeof(*mctx));
+
+ return 0;
+}
+
+/*
+ * \brief MD5 function mappings
+*/
+static struct shash_alg ifxdeu_md5_alg = {
+ .digestsize = MD5_DIGEST_SIZE,
+ .init = md5_init,
+ .update = md5_update,
+ .final = md5_final,
+ .descsize = sizeof(struct md5_ctx),
+ .base = {
+ .cra_name = "md5",
+ .cra_driver_name= "ifxdeu-md5",
+ .cra_flags = CRYPTO_ALG_TYPE_DIGEST,
+ .cra_blocksize = MD5_HMAC_BLOCK_SIZE,
+ .cra_module = THIS_MODULE,
+ }
+};
+
+/*! \fn int __init ifxdeu_init_md5 (void)
+ * \ingroup IFX_MD5_FUNCTIONS
+ * \brief initialize md5 driver
+*/
+int __init ifxdeu_init_md5 (void)
+{
+ int ret = -ENOSYS;
+
+
+ if ((ret = crypto_register_shash(&ifxdeu_md5_alg)))
+ goto md5_err;
+
+ CRTCL_SECT_INIT;
+
+ printk (KERN_NOTICE "IFX DEU MD5 initialized%s.\n", disable_deudma ? "" : " (DMA)");
+ return ret;
+
+md5_err:
+ printk(KERN_ERR "IFX DEU MD5 initialization failed!\n");
+ return ret;
+}
+
+/*! \fn void __exit ifxdeu_fini_md5 (void)
+ * \ingroup IFX_MD5_FUNCTIONS
+ * \brief unregister md5 driver
+*/
+
+void __exit ifxdeu_fini_md5 (void)
+{
+ crypto_unregister_shash(&ifxdeu_md5_alg);
+
+}
+
diff --git a/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_md5_hmac.c.svn-base b/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_md5_hmac.c.svn-base
new file mode 100644
index 0000000..fc6f52e
--- /dev/null
+++ b/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_md5_hmac.c.svn-base
@@ -0,0 +1,386 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_md5_hmac.c
+** PROJECT : IFX UEIP
+** MODULES : DEU Module for UEIP
+**
+** DATE : September 8, 2009
+** AUTHOR : Mohammad Firdaus
+** DESCRIPTION : Data Encryption Unit Driver
+** COPYRIGHT : Copyright (c) 2009
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 08,Sept 2009 Mohammad Firdaus Initial UEIP release
+** 21,March 2011 Mohammad Firdaus Changes for Kernel 2.6.32 and IPSec integration
+*******************************************************************************/
+/*!
+ \defgroup IFX_DEU IFX_DEU_DRIVERS
+ \ingroup API
+ \brief ifx deu driver module
+*/
+
+/*!
+ \file ifxmips_md5_hmac.c
+ \ingroup IFX_DEU
+ \brief MD5-HMAC encryption deu driver file
+*/
+
+/*!
+ \defgroup IFX_MD5_HMAC_FUNCTIONS IFX_MD5_HMAC_FUNCTIONS
+ \ingroup IFX_DEU
+ \brief ifx md5-hmac driver functions
+*/
+
+/* Project Header files */
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/string.h>
+#include <linux/crypto.h>
+#include <linux/types.h>
+#include <crypto/internal/hash.h>
+#include <asm/byteorder.h>
+
+#if defined(CONFIG_AR9)
+#include "ifxmips_deu_ar9.h"
+#elif defined(CONFIG_VR9) || defined(CONFIG_AR10)
+#include "ifxmips_deu_vr9.h"
+#else
+#error "Plaform Unknwon!"
+#endif
+
+#define MD5_DIGEST_SIZE 16
+#define MD5_HMAC_BLOCK_SIZE 64
+#define MD5_BLOCK_WORDS 16
+#define MD5_HASH_WORDS 4
+#define MD5_HMAC_DBN_TEMP_SIZE 1024 // size in dword, needed for dbn workaround
+#define HASH_START IFX_HASH_CON
+
+static spinlock_t lock;
+#define CRTCL_SECT_INIT spin_lock_init(&lock)
+#define CRTCL_SECT_START spin_lock_irqsave(&lock, flag)
+#define CRTCL_SECT_END spin_unlock_irqrestore(&lock, flag)
+
+//#define CRYPTO_DEBUG
+#ifdef CRYPTO_DEBUG
+extern char debug_level;
+#define DPRINTF(level, format, args...) if (level < debug_level) printk(KERN_INFO "[%s %s %d]: " format, __FILE__, __func__, __LINE__, ##args);
+#else
+#define DPRINTF(level, format, args...)
+#endif
+
+#define MAX_HASH_KEYLEN 64
+
+struct md5_hmac_ctx {
+ u8 key[MAX_HASH_KEYLEN];
+ u32 hash[MD5_HASH_WORDS];
+ u32 block[MD5_BLOCK_WORDS];
+ u64 byte_count;
+ u32 dbn;
+ unsigned int keylen;
+};
+
+static u32 temp[MD5_HMAC_DBN_TEMP_SIZE];
+
+extern int disable_deudma;
+
+/*! \fn static u32 endian_swap(u32 input)
+ * \ingroup IFX_MD5_HMAC_FUNCTIONS
+ * \brief perform dword level endian swap
+ * \param input value of dword that requires to be swapped
+*/
+static u32 endian_swap(u32 input)
+{
+ u8 *ptr = (u8 *)&input;
+
+ return ((ptr[3] << 24) | (ptr[2] << 16) | (ptr[1] << 8) | ptr[0]);
+}
+
+/*! \fn static void md5_hmac_transform(struct crypto_tfm *tfm, u32 const *in)
+ * \ingroup IFX_MD5_HMAC_FUNCTIONS
+ * \brief save input block to context
+ * \param tfm linux crypto algo transform
+ * \param in 64-byte block of input
+*/
+static void md5_hmac_transform(struct shash_desc *desc, u32 const *in)
+{
+ struct md5_hmac_ctx *mctx = crypto_shash_ctx(desc->tfm);
+
+ memcpy(&temp[mctx->dbn<<4], in, 64); //dbn workaround
+ mctx->dbn += 1;
+
+ if ( (mctx->dbn<<4) > MD5_HMAC_DBN_TEMP_SIZE )
+ {
+ printk("MD5_HMAC_DBN_TEMP_SIZE exceeded\n");
+ }
+
+}
+
+/*! \fn int md5_hmac_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen)
+ * \ingroup IFX_MD5_HMAC_FUNCTIONS
+ * \brief sets md5 hmac key
+ * \param tfm linux crypto algo transform
+ * \param key input key
+ * \param keylen key length greater than 64 bytes IS NOT SUPPORTED
+*/
+static int md5_hmac_setkey(struct crypto_shash *tfm, const u8 *key, unsigned int keylen)
+{
+ struct md5_hmac_ctx *mctx = crypto_shash_ctx(tfm);
+ volatile struct deu_hash_t *hash = (struct deu_hash_t *) HASH_START;
+ //printk("copying keys to context with length %d\n", keylen);
+
+ if (keylen > MAX_HASH_KEYLEN) {
+ printk("Key length more than what DEU hash can handle\n");
+ return -EINVAL;
+ }
+
+
+ hash->KIDX |= 0x80000000; // reset all 16 words of the key to '0'
+ memcpy(&mctx->key, key, keylen);
+ mctx->keylen = keylen;
+
+ return 0;
+
+}
+
+
+/*! \fn int md5_hmac_setkey_hw(const u8 *key, unsigned int keylen)
+ * \ingroup IFX_MD5_HMAC_FUNCTIONS
+ * \brief sets md5 hmac key into the hardware registers
+ * \param key input key
+ * \param keylen key length greater than 64 bytes IS NOT SUPPORTED
+*/
+
+static int md5_hmac_setkey_hw(const u8 *key, unsigned int keylen)
+{
+ volatile struct deu_hash_t *hash = (struct deu_hash_t *) HASH_START;
+ unsigned long flag;
+ int i, j;
+ u32 *in_key = (u32 *)key;
+
+ //printk("\nsetkey keylen: %d\n key: ", keylen);
+
+ CRTCL_SECT_START;
+ j = 0;
+ for (i = 0; i < keylen; i+=4)
+ {
+ hash->KIDX = j;
+ asm("sync");
+ hash->KEY = *((u32 *) in_key + j);
+ asm("sync");
+ j++;
+ }
+ CRTCL_SECT_END;
+
+ return 0;
+}
+
+/*! \fn void md5_hmac_init(struct crypto_tfm *tfm)
+ * \ingroup IFX_MD5_HMAC_FUNCTIONS
+ * \brief initialize md5 hmac context
+ * \param tfm linux crypto algo transform
+*/
+static int md5_hmac_init(struct shash_desc *desc)
+{
+
+ struct md5_hmac_ctx *mctx = crypto_shash_ctx(desc->tfm);
+
+
+ mctx->dbn = 0; //dbn workaround
+ md5_hmac_setkey_hw(mctx->key, mctx->keylen);
+
+ return 0;
+}
+EXPORT_SYMBOL(md5_hmac_init);
+
+/*! \fn void md5_hmac_update(struct crypto_tfm *tfm, const u8 *data, unsigned int len)
+ * \ingroup IFX_MD5_HMAC_FUNCTIONS
+ * \brief on-the-fly md5 hmac computation
+ * \param tfm linux crypto algo transform
+ * \param data input data
+ * \param len size of input data
+*/
+static int md5_hmac_update(struct shash_desc *desc, const u8 *data, unsigned int len)
+{
+ struct md5_hmac_ctx *mctx = crypto_shash_ctx(desc->tfm);
+ const u32 avail = sizeof(mctx->block) - (mctx->byte_count & 0x3f);
+
+ mctx->byte_count += len;
+
+ if (avail > len) {
+ memcpy((char *)mctx->block + (sizeof(mctx->block) - avail),
+ data, len);
+ return 0;
+ }
+
+ memcpy((char *)mctx->block + (sizeof(mctx->block) - avail),
+ data, avail);
+
+ md5_hmac_transform(desc, mctx->block);
+ data += avail;
+ len -= avail;
+
+ while (len >= sizeof(mctx->block)) {
+ memcpy(mctx->block, data, sizeof(mctx->block));
+ md5_hmac_transform(desc, mctx->block);
+ data += sizeof(mctx->block);
+ len -= sizeof(mctx->block);
+ }
+
+ memcpy(mctx->block, data, len);
+ return 0;
+}
+EXPORT_SYMBOL(md5_hmac_update);
+
+/*! \fn void md5_hmac_final(struct crypto_tfm *tfm, u8 *out)
+ * \ingroup IFX_MD5_HMAC_FUNCTIONS
+ * \brief compute final md5 hmac value
+ * \param tfm linux crypto algo transform
+ * \param out final md5 hmac output value
+*/
+static int md5_hmac_final(struct shash_desc *desc, u8 *out)
+{
+ struct md5_hmac_ctx *mctx = crypto_shash_ctx(desc->tfm);
+ const unsigned int offset = mctx->byte_count & 0x3f;
+ char *p = (char *)mctx->block + offset;
+ int padding = 56 - (offset + 1);
+ volatile struct deu_hash_t *hashs = (struct deu_hash_t *) HASH_START;
+ unsigned long flag;
+ int i = 0;
+ int dbn;
+ u32 *in = &temp[0];
+
+
+ *p++ = 0x80;
+ if (padding < 0) {
+ memset(p, 0x00, padding + sizeof (u64));
+ md5_hmac_transform(desc, mctx->block);
+ p = (char *)mctx->block;
+ padding = 56;
+ }
+
+ memset(p, 0, padding);
+ mctx->block[14] = endian_swap((mctx->byte_count + 64) << 3); // need to add 512 bit of the IPAD operation
+ mctx->block[15] = 0x00000000;
+
+ md5_hmac_transform(desc, mctx->block);
+
+ CRTCL_SECT_START;
+
+ //printk("\ndbn = %d\n", mctx->dbn);
+ hashs->DBN = mctx->dbn;
+ asm("sync");
+
+ *IFX_HASH_CON = 0x0703002D; //khs, go, init, ndc, endi, kyue, hmen, md5
+
+ //wait for processing
+ while (hashs->controlr.BSY) {
+ // this will not take long
+ }
+
+ for (dbn = 0; dbn < mctx->dbn; dbn++)
+ {
+ for (i = 0; i < 16; i++) {
+ hashs->MR = in[i];
+ };
+
+ hashs->controlr.GO = 1;
+ asm("sync");
+
+ //wait for processing
+ while (hashs->controlr.BSY) {
+ // this will not take long
+ }
+
+ in += 16;
+}
+
+
+#if 1
+ //wait for digest ready
+ while (! hashs->controlr.DGRY) {
+ // this will not take long
+ }
+#endif
+
+ *((u32 *) out + 0) = hashs->D1R;
+ *((u32 *) out + 1) = hashs->D2R;
+ *((u32 *) out + 2) = hashs->D3R;
+ *((u32 *) out + 3) = hashs->D4R;
+ *((u32 *) out + 4) = hashs->D5R;
+
+ /* reset the context after we finish with the hash */
+ mctx->byte_count = 0;
+ memset(&mctx->hash[0], 0, sizeof(MD5_HASH_WORDS));
+ memset(&mctx->block[0], 0, sizeof(MD5_BLOCK_WORDS));
+ memset(&temp[0], 0, MD5_HMAC_DBN_TEMP_SIZE);
+
+ CRTCL_SECT_END;
+
+
+ return 0;
+}
+
+EXPORT_SYMBOL(md5_hmac_final);
+
+/*
+ * \brief MD5_HMAC function mappings
+*/
+
+static struct shash_alg ifxdeu_md5_hmac_alg = {
+ .digestsize = MD5_DIGEST_SIZE,
+ .init = md5_hmac_init,
+ .update = md5_hmac_update,
+ .final = md5_hmac_final,
+ .setkey = md5_hmac_setkey,
+ .descsize = sizeof(struct md5_hmac_ctx),
+ .base = {
+ .cra_name = "hmac(md5)",
+ .cra_driver_name= "ifxdeu-md5_hmac",
+ .cra_ctxsize = sizeof(struct md5_hmac_ctx),
+ .cra_flags = CRYPTO_ALG_TYPE_DIGEST,
+ .cra_blocksize = MD5_HMAC_BLOCK_SIZE,
+ .cra_module = THIS_MODULE,
+ }
+};
+
+/*! \fn int __init ifxdeu_init_md5_hmac (void)
+ * \ingroup IFX_MD5_HMAC_FUNCTIONS
+ * \brief initialize md5 hmac driver
+*/
+int __init ifxdeu_init_md5_hmac (void)
+{
+
+ int ret = -ENOSYS;
+
+
+ if ((ret = crypto_register_shash(&ifxdeu_md5_hmac_alg)))
+ goto md5_hmac_err;
+
+ CRTCL_SECT_INIT;
+
+ printk (KERN_NOTICE "IFX DEU MD5_HMAC initialized%s.\n", disable_deudma ? "" : " (DMA)");
+ return ret;
+
+md5_hmac_err:
+ printk(KERN_ERR "IFX DEU MD5_HMAC initialization failed!\n");
+ return ret;
+}
+
+/** \fn void __exit ifxdeu_fini_md5_hmac (void)
+ * \ingroup IFX_MD5_HMAC_FUNCTIONS
+ * \brief unregister md5 hmac driver
+*/
+void __exit ifxdeu_fini_md5_hmac (void)
+{
+ crypto_unregister_shash(&ifxdeu_md5_hmac_alg);
+}
+
+
diff --git a/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_sha1.c.svn-base b/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_sha1.c.svn-base
new file mode 100644
index 0000000..a5f5f90
--- /dev/null
+++ b/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_sha1.c.svn-base
@@ -0,0 +1,301 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_sha1.c
+** PROJECT : IFX UEIP
+** MODULES : DEU Module for Danube
+**
+** DATE : September 8, 2009
+** AUTHOR : Mohammad Firdaus
+** DESCRIPTION : Data Encryption Unit Driver
+** COPYRIGHT : Copyright (c) 2009
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 08,Sept 2009 Mohammad Firdaus Initial UEIP release
+*******************************************************************************/
+/*!
+ \defgroup IFX_DEU IFX_DEU_DRIVERS
+ \ingroup API
+ \brief ifx deu driver module
+*/
+
+/*!
+ \file ifxmips_sha1.c
+ \ingroup IFX_DEU
+ \brief SHA1 encryption deu driver file
+*/
+
+/*!
+ \defgroup IFX_SHA1_FUNCTIONS IFX_SHA1_FUNCTIONS
+ \ingroup IFX_DEU
+ \brief ifx deu sha1 functions
+*/
+
+
+/* Project header */
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/mm.h>
+#include <linux/crypto.h>
+#include <linux/cryptohash.h>
+#include <crypto/sha.h>
+#include <crypto/internal/hash.h>
+#include <linux/types.h>
+#include <asm/scatterlist.h>
+#include <asm/byteorder.h>
+
+#if defined(CONFIG_DANUBE)
+#include "ifxmips_deu_danube.h"
+#elif defined(CONFIG_AR9)
+#include "ifxmips_deu_ar9.h"
+#elif defined(CONFIG_VR9) || defined(CONFIG_AR10)
+#include "ifxmips_deu_vr9.h"
+#else
+#error "Plaform Unknwon!"
+#endif
+
+#define SHA1_DIGEST_SIZE 20
+#define SHA1_HMAC_BLOCK_SIZE 64
+#define HASH_START IFX_HASH_CON
+
+static spinlock_t lock;
+#define CRTCL_SECT_INIT spin_lock_init(&lock)
+#define CRTCL_SECT_START spin_lock_irqsave(&lock, flag)
+#define CRTCL_SECT_END spin_unlock_irqrestore(&lock, flag)
+
+//#define CRYPTO_DEBUG
+#ifdef CRYPTO_DEBUG
+extern char debug_level;
+#define DPRINTF(level, format, args...) if (level < debug_level) printk(KERN_INFO "[%s %s %d]: " format, __FILE__, __func__, __LINE__, ##args);
+#else
+#define DPRINTF(level, format, args...)
+#endif
+
+/*
+ * \brief SHA1 private structure
+*/
+struct sha1_ctx {
+ int started;
+ u64 count;
+ u32 hash[5];
+ u32 state[5];
+ u8 buffer[64];
+};
+
+extern int disable_deudma;
+
+
+/*! \fn static void sha1_transform (u32 *state, const u32 *in)
+ * \ingroup IFX_SHA1_FUNCTIONS
+ * \brief main interface to sha1 hardware
+ * \param state current state
+ * \param in 64-byte block of input
+*/
+static void sha1_transform (struct sha1_ctx *sctx, u32 *state, const u32 *in)
+{
+ int i = 0;
+ volatile struct deu_hash_t *hashs = (struct deu_hash_t *) HASH_START;
+ unsigned long flag;
+
+ CRTCL_SECT_START;
+
+ /* For context switching purposes, the previous hash output
+ * is loaded back into the output register
+ */
+ if (sctx->started) {
+ hashs->D1R = *((u32 *) sctx->hash + 0);
+ hashs->D2R = *((u32 *) sctx->hash + 1);
+ hashs->D3R = *((u32 *) sctx->hash + 2);
+ hashs->D4R = *((u32 *) sctx->hash + 3);
+ hashs->D5R = *((u32 *) sctx->hash + 4);
+ }
+
+ for (i = 0; i < 16; i++) {
+ hashs->MR = in[i];
+ };
+
+ //wait for processing
+ while (hashs->controlr.BSY) {
+ // this will not take long
+ }
+
+ /* For context switching purposes, the output is saved into a
+ * context struct which can be used later on
+ */
+ *((u32 *) sctx->hash + 0) = hashs->D1R;
+ *((u32 *) sctx->hash + 1) = hashs->D2R;
+ *((u32 *) sctx->hash + 2) = hashs->D3R;
+ *((u32 *) sctx->hash + 3) = hashs->D4R;
+ *((u32 *) sctx->hash + 4) = hashs->D5R;
+
+ sctx->started = 1;
+
+ CRTCL_SECT_END;
+}
+
+/*! \fn static void sha1_init(struct crypto_tfm *tfm)
+ * \ingroup IFX_SHA1_FUNCTIONS
+ * \brief initialize sha1 hardware
+ * \param tfm linux crypto algo transform
+*/
+static int sha1_init(struct shash_desc *desc)
+{
+ struct sha1_ctx *sctx = shash_desc_ctx(desc);
+
+ SHA_HASH_INIT;
+
+ sctx->started = 0;
+ sctx->count = 0;
+ return 0;
+}
+
+/*! \fn static void sha1_update(struct crypto_tfm *tfm, const u8 *data, unsigned int len)
+ * \ingroup IFX_SHA1_FUNCTIONS
+ * \brief on-the-fly sha1 computation
+ * \param tfm linux crypto algo transform
+ * \param data input data
+ * \param len size of input data
+*/
+static int sha1_update(struct shash_desc * desc, const u8 *data,
+ unsigned int len)
+{
+ struct sha1_ctx *sctx = shash_desc_ctx(desc);
+ unsigned int i, j;
+
+ j = (sctx->count >> 3) & 0x3f;
+ sctx->count += len << 3;
+
+ if ((j + len) > 63) {
+ memcpy (&sctx->buffer[j], data, (i = 64 - j));
+ sha1_transform (sctx, sctx->state, (const u32 *)sctx->buffer);
+ for (; i + 63 < len; i += 64) {
+ sha1_transform (sctx, sctx->state, (const u32 *)&data[i]);
+ }
+
+ j = 0;
+ }
+ else
+ i = 0;
+
+ memcpy (&sctx->buffer[j], &data[i], len - i);
+ return 0;
+}
+
+/*! \fn static void sha1_final(struct crypto_tfm *tfm, u8 *out)
+ * \ingroup IFX_SHA1_FUNCTIONS
+ * \brief compute final sha1 value
+ * \param tfm linux crypto algo transform
+ * \param out final md5 output value
+*/
+static int sha1_final(struct shash_desc *desc, u8 *out)
+{
+ struct sha1_ctx *sctx = shash_desc_ctx(desc);
+ u32 index, padlen;
+ u64 t;
+ u8 bits[8] = { 0, };
+ static const u8 padding[64] = { 0x80, };
+ volatile struct deu_hash_t *hashs = (struct deu_hash_t *) HASH_START;
+ unsigned long flag;
+
+ t = sctx->count;
+ bits[7] = 0xff & t;
+ t >>= 8;
+ bits[6] = 0xff & t;
+ t >>= 8;
+ bits[5] = 0xff & t;
+ t >>= 8;
+ bits[4] = 0xff & t;
+ t >>= 8;
+ bits[3] = 0xff & t;
+ t >>= 8;
+ bits[2] = 0xff & t;
+ t >>= 8;
+ bits[1] = 0xff & t;
+ t >>= 8;
+ bits[0] = 0xff & t;
+
+ /* Pad out to 56 mod 64 */
+ index = (sctx->count >> 3) & 0x3f;
+ padlen = (index < 56) ? (56 - index) : ((64 + 56) - index);
+ sha1_update (desc, padding, padlen);
+
+ /* Append length */
+ sha1_update (desc, bits, sizeof bits);
+
+ CRTCL_SECT_START;
+
+ *((u32 *) out + 0) = hashs->D1R;
+ *((u32 *) out + 1) = hashs->D2R;
+ *((u32 *) out + 2) = hashs->D3R;
+ *((u32 *) out + 3) = hashs->D4R;
+ *((u32 *) out + 4) = hashs->D5R;
+
+ CRTCL_SECT_END;
+
+ // Wipe context
+ memset (sctx, 0, sizeof *sctx);
+
+ return 0;
+}
+
+/*
+ * \brief SHA1 function mappings
+*/
+static struct shash_alg ifxdeu_sha1_alg = {
+ .digestsize = SHA1_DIGEST_SIZE,
+ .init = sha1_init,
+ .update = sha1_update,
+ .final = sha1_final,
+ .descsize = sizeof(struct sha1_ctx),
+ .statesize = sizeof(struct sha1_state),
+ .base = {
+ .cra_name = "sha1",
+ .cra_driver_name= "ifxdeu-sha1",
+ .cra_flags = CRYPTO_ALG_TYPE_DIGEST,
+ .cra_blocksize = SHA1_HMAC_BLOCK_SIZE,
+ .cra_module = THIS_MODULE,
+ }
+};
+
+
+/*! \fn int __init ifxdeu_init_sha1 (void)
+ * \ingroup IFX_SHA1_FUNCTIONS
+ * \brief initialize sha1 driver
+*/
+int __init ifxdeu_init_sha1 (void)
+{
+ int ret = -ENOSYS;
+
+
+ if ((ret = crypto_register_shash(&ifxdeu_sha1_alg)))
+ goto sha1_err;
+
+ CRTCL_SECT_INIT;
+
+ printk (KERN_NOTICE "IFX DEU SHA1 initialized%s.\n", disable_deudma ? "" : " (DMA)");
+ return ret;
+
+sha1_err:
+ printk(KERN_ERR "IFX DEU SHA1 initialization failed!\n");
+ return ret;
+}
+
+/*! \fn void __exit ifxdeu_fini_sha1 (void)
+ * \ingroup IFX_SHA1_FUNCTIONS
+ * \brief unregister sha1 driver
+*/
+void __exit ifxdeu_fini_sha1 (void)
+{
+ crypto_unregister_shash(&ifxdeu_sha1_alg);
+
+
+}
+
+
diff --git a/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_sha1_hmac.c.svn-base b/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_sha1_hmac.c.svn-base
new file mode 100644
index 0000000..a5a6c39
--- /dev/null
+++ b/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_sha1_hmac.c.svn-base
@@ -0,0 +1,378 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_sha1_hmac.c
+** PROJECT : IFX UEIP
+** MODULES : DEU Module for UEIP
+** DATE : September 8, 2009
+** AUTHOR : Mohammad Firdaus
+** DESCRIPTION : Data Encryption Unit Driver
+** COPYRIGHT : Copyright (c) 2009
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 08,Sept 2009 Mohammad Firdaus Initial UEIP release
+** 21,March 2011 Mohammad Firdaus Changes for Kernel 2.6.32 and IPSec integration
+*******************************************************************************/
+/*!
+ \defgroup IFX_DEU IFX_DEU_DRIVERS
+ \ingroup API
+ \brief ifx deu driver module
+*/
+
+/*!
+ \file ifxmips_sha1_hmac.c
+ \ingroup IFX_DEU
+ \brief SHA1-HMAC deu driver file
+*/
+
+/*!
+ \defgroup IFX_SHA1_HMAC_FUNCTIONS IFX_SHA1_HMAC_FUNCTIONS
+ \ingroup IFX_DEU
+ \brief ifx sha1 hmac functions
+*/
+
+
+/* Project header */
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/mm.h>
+#include <linux/crypto.h>
+#include <linux/cryptohash.h>
+#include <crypto/internal/hash.h>
+#include <linux/types.h>
+#include <asm/scatterlist.h>
+#include <asm/byteorder.h>
+#include <linux/delay.h>
+
+#if defined(CONFIG_AR9)
+#include "ifxmips_deu_ar9.h"
+#elif defined(CONFIG_VR9) || defined(CONFIG_AR10)
+#include "ifxmips_deu_vr9.h"
+#else
+#error "Plaform Unknwon!"
+#endif
+
+#define SHA1_DIGEST_SIZE 20
+#define SHA1_HMAC_BLOCK_SIZE 64
+#define SHA1_HMAC_DBN_TEMP_SIZE 1024 // size in dword, needed for dbn workaround
+#define HASH_START IFX_HASH_CON
+
+#define SHA1_HMAC_MAX_KEYLEN 64
+
+static spinlock_t lock;
+#define CRTCL_SECT_INIT spin_lock_init(&lock)
+#define CRTCL_SECT_START spin_lock_irqsave(&lock, flag)
+#define CRTCL_SECT_END spin_unlock_irqrestore(&lock, flag)
+
+#ifdef CRYPTO_DEBUG
+extern char debug_level;
+#define DPRINTF(level, format, args...) if (level < debug_level) printk(KERN_INFO "[%s %s %d]: " format, __FILE__, __func__, __LINE__, ##args);
+#else
+#define DPRINTF(level, format, args...)
+#endif
+
+struct sha1_hmac_ctx {
+ int keylen;
+
+ u8 buffer[SHA1_HMAC_BLOCK_SIZE];
+ u8 key[SHA1_HMAC_MAX_KEYLEN];
+ u32 state[5];
+ u32 dbn;
+ u64 count;
+
+};
+
+static u32 temp[SHA1_HMAC_DBN_TEMP_SIZE];
+
+extern int disable_deudma;
+
+/*! \fn static void sha1_hmac_transform(struct crypto_tfm *tfm, u32 const *in)
+ * \ingroup IFX_SHA1_HMAC_FUNCTIONS
+ * \brief save input block to context
+ * \param tfm linux crypto algo transform
+ * \param in 64-byte block of input
+*/
+static int sha1_hmac_transform(struct shash_desc *desc, u32 const *in)
+{
+ struct sha1_hmac_ctx *sctx = crypto_shash_ctx(desc->tfm);
+
+ memcpy(&temp[sctx->dbn<<4], in, 64); //dbn workaround
+ sctx->dbn += 1;
+
+ if ( (sctx->dbn<<4) > SHA1_HMAC_DBN_TEMP_SIZE )
+ {
+ printk("SHA1_HMAC_DBN_TEMP_SIZE exceeded\n");
+ }
+
+ return 0;
+}
+
+/*! \fn int sha1_hmac_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen)
+ * \ingroup IFX_SHA1_HMAC_FUNCTIONS
+ * \brief sets sha1 hmac key
+ * \param tfm linux crypto algo transform
+ * \param key input key
+ * \param keylen key length greater than 64 bytes IS NOT SUPPORTED
+*/
+static int sha1_hmac_setkey(struct crypto_shash *tfm, const u8 *key, unsigned int keylen)
+{
+ struct sha1_hmac_ctx *sctx = crypto_shash_ctx(tfm);
+ volatile struct deu_hash_t *hashs = (struct deu_hash_t *) HASH_START;
+
+ if (keylen > SHA1_HMAC_MAX_KEYLEN) {
+ printk("Key length exceeds maximum key length\n");
+ return -EINVAL;
+ }
+
+ //printk("Setting keys of len: %d\n", keylen);
+
+ hashs->KIDX |= 0x80000000; //reset keys back to 0
+ memcpy(&sctx->key, key, keylen);
+ sctx->keylen = keylen;
+
+ return 0;
+
+}
+
+
+/*! \fn int sha1_hmac_setkey_hw(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen)
+ * \ingroup IFX_SHA1_HMAC_FUNCTIONS
+ * \brief sets sha1 hmac key into hw registers
+ * \param tfm linux crypto algo transform
+ * \param key input key
+ * \param keylen key length greater than 64 bytes IS NOT SUPPORTED
+*/
+static int sha1_hmac_setkey_hw(const u8 *key, unsigned int keylen)
+{
+ volatile struct deu_hash_t *hash = (struct deu_hash_t *) HASH_START;
+ int i, j;
+ unsigned long flag;
+ u32 *in_key = (u32 *)key;
+
+ j = 0;
+
+ CRTCL_SECT_START;
+ for (i = 0; i < keylen; i+=4)
+ {
+ hash->KIDX = j;
+ asm("sync");
+ hash->KEY = *((u32 *) in_key + j);
+ j++;
+ }
+
+ CRTCL_SECT_END;
+ return 0;
+}
+
+/*! \fn void sha1_hmac_init(struct crypto_tfm *tfm)
+ * \ingroup IFX_SHA1_HMAC_FUNCTIONS
+ * \brief initialize sha1 hmac context
+ * \param tfm linux crypto algo transform
+*/
+static int sha1_hmac_init(struct shash_desc *desc)
+{
+ struct sha1_hmac_ctx *sctx = crypto_shash_ctx(desc->tfm);
+
+ //printk("debug ln: %d, fn: %s\n", __LINE__, __func__);
+ sctx->dbn = 0; //dbn workaround
+ sha1_hmac_setkey_hw(sctx->key, sctx->keylen);
+
+ return 0;
+}
+
+/*! \fn static void sha1_hmac_update(struct crypto_tfm *tfm, const u8 *data, unsigned int len)
+ * \ingroup IFX_SHA1_HMAC_FUNCTIONS
+ * \brief on-the-fly sha1 hmac computation
+ * \param tfm linux crypto algo transform
+ * \param data input data
+ * \param len size of input data
+*/
+static int sha1_hmac_update(struct shash_desc *desc, const u8 *data,
+ unsigned int len)
+{
+ struct sha1_hmac_ctx *sctx = crypto_shash_ctx(desc->tfm);
+ unsigned int i, j;
+
+ j = (sctx->count >> 3) & 0x3f;
+ sctx->count += len << 3;
+ // printk("sctx->count = %d\n", sctx->count);
+
+ if ((j + len) > 63) {
+ memcpy (&sctx->buffer[j], data, (i = 64 - j));
+ sha1_hmac_transform (desc, (const u32 *)sctx->buffer);
+ for (; i + 63 < len; i += 64) {
+ sha1_hmac_transform (desc, (const u32 *)&data[i]);
+ }
+
+ j = 0;
+ }
+ else
+ i = 0;
+
+ memcpy (&sctx->buffer[j], &data[i], len - i);
+ return 0;
+}
+
+/*! \fn static void sha1_hmac_final(struct crypto_tfm *tfm, u8 *out)
+ * \ingroup IFX_SHA1_HMAC_FUNCTIONS
+ * \brief ompute final sha1 hmac value
+ * \param tfm linux crypto algo transform
+ * \param out final sha1 hmac output value
+*/
+static int sha1_hmac_final(struct shash_desc *desc, u8 *out)
+{
+ //struct sha1_hmac_ctx *sctx = shash_desc_ctx(desc);
+ struct sha1_hmac_ctx *sctx = crypto_shash_ctx(desc->tfm);
+ u32 index, padlen;
+ u64 t;
+ u8 bits[8] = { 0, };
+ static const u8 padding[64] = { 0x80, };
+ volatile struct deu_hash_t *hashs = (struct deu_hash_t *) HASH_START;
+ unsigned long flag;
+ int i = 0;
+ int dbn;
+ u32 *in = &temp[0];
+
+ t = sctx->count + 512; // need to add 512 bit of the IPAD operation
+ bits[7] = 0xff & t;
+ t >>= 8;
+ bits[6] = 0xff & t;
+ t >>= 8;
+ bits[5] = 0xff & t;
+ t >>= 8;
+ bits[4] = 0xff & t;
+ t >>= 8;
+ bits[3] = 0xff & t;
+ t >>= 8;
+ bits[2] = 0xff & t;
+ t >>= 8;
+ bits[1] = 0xff & t;
+ t >>= 8;
+ bits[0] = 0xff & t;
+
+ /* Pad out to 56 mod 64 */
+ index = (sctx->count >> 3) & 0x3f;
+ padlen = (index < 56) ? (56 - index) : ((64 + 56) - index);
+ sha1_hmac_update (desc, padding, padlen);
+
+ /* Append length */
+ sha1_hmac_update (desc, bits, sizeof bits);
+
+ CRTCL_SECT_START;
+
+ hashs->DBN = sctx->dbn;
+
+ //for vr9 change, ENDI = 1
+ *IFX_HASH_CON = HASH_CON_VALUE;
+
+ //wait for processing
+ while (hashs->controlr.BSY) {
+ // this will not take long
+ }
+
+ for (dbn = 0; dbn < sctx->dbn; dbn++)
+ {
+ for (i = 0; i < 16; i++) {
+ hashs->MR = in[i];
+ };
+
+ hashs->controlr.GO = 1;
+ asm("sync");
+
+ //wait for processing
+ while (hashs->controlr.BSY) {
+ // this will not take long
+ }
+
+ in += 16;
+}
+
+
+#if 1
+ //wait for digest ready
+ while (! hashs->controlr.DGRY) {
+ // this will not take long
+ }
+#endif
+
+ *((u32 *) out + 0) = hashs->D1R;
+ *((u32 *) out + 1) = hashs->D2R;
+ *((u32 *) out + 2) = hashs->D3R;
+ *((u32 *) out + 3) = hashs->D4R;
+ *((u32 *) out + 4) = hashs->D5R;
+
+ memset(&sctx->buffer[0], 0, SHA1_HMAC_BLOCK_SIZE);
+ sctx->count = 0;
+
+ //printk("debug ln: %d, fn: %s\n", __LINE__, __func__);
+ CRTCL_SECT_END;
+
+
+ return 0;
+
+}
+
+/*
+ * \brief SHA1-HMAC function mappings
+*/
+static struct shash_alg ifxdeu_sha1_hmac_alg = {
+ .digestsize = SHA1_DIGEST_SIZE,
+ .init = sha1_hmac_init,
+ .update = sha1_hmac_update,
+ .final = sha1_hmac_final,
+ .setkey = sha1_hmac_setkey,
+ .descsize = sizeof(struct sha1_hmac_ctx),
+ .base = {
+ .cra_name = "hmac(sha1)",
+ .cra_driver_name= "ifxdeu-sha1_hmac",
+ .cra_ctxsize = sizeof(struct sha1_hmac_ctx),
+ .cra_flags = CRYPTO_ALG_TYPE_DIGEST,
+ .cra_blocksize = SHA1_HMAC_BLOCK_SIZE,
+ .cra_module = THIS_MODULE,
+ }
+
+};
+
+
+/*! \fn int __init ifxdeu_init_sha1_hmac (void)
+ * \ingroup IFX_SHA1_HMAC_FUNCTIONS
+ * \brief initialize sha1 hmac driver
+*/
+int __init ifxdeu_init_sha1_hmac (void)
+{
+ int ret = -ENOSYS;
+
+
+
+ if ((ret = crypto_register_shash(&ifxdeu_sha1_hmac_alg)))
+ goto sha1_err;
+
+ CRTCL_SECT_INIT;
+
+ printk (KERN_NOTICE "IFX DEU SHA1_HMAC initialized%s.\n", disable_deudma ? "" : " (DMA)");
+ return ret;
+
+sha1_err:
+ printk(KERN_ERR "IFX DEU SHA1_HMAC initialization failed!\n");
+ return ret;
+}
+
+/*! \fn void __exit ifxdeu_fini_sha1_hmac (void)
+ * \ingroup IFX_SHA1_HMAC_FUNCTIONS
+ * \brief unregister sha1 hmac driver
+*/
+void __exit ifxdeu_fini_sha1_hmac (void)
+{
+
+ crypto_unregister_shash(&ifxdeu_sha1_hmac_alg);
+
+
+}
+
diff --git a/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_tcrypt.h.svn-base b/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_tcrypt.h.svn-base
new file mode 100644
index 0000000..1e7047b
--- /dev/null
+++ b/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_tcrypt.h.svn-base
@@ -0,0 +1,92 @@
+/*
+ * Quick & dirty crypto testing module.
+ *
+ * This will only exist until we have a better testing mechanism
+ * (e.g. a char device).
+ *
+ * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
+ * Copyright (c) 2002 Jean-Francois Dive <jef@linuxbe.org>
+ * Copyright (c) 2007 Nokia Siemens Networks
+ *
+ * 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 of the License, or (at your option)
+ * any later version.
+ *
+ */
+#ifndef _IFXMIPS_CRYPTO_TCRYPT_H
+#define _IFXMIPS_CRYPTO_TCRYPT_H
+
+struct cipher_speed_template {
+ const char *key;
+ unsigned int klen;
+};
+
+struct hash_speed {
+ unsigned int blen; /* buffer length */
+ unsigned int plen; /* per-update length */
+};
+
+/*
+ * DES test vectors.
+ */
+#define DES3_SPEED_VECTORS 1
+#define CRYPTO_ALG_TYPE_SPEED_TEST 0xB
+
+static int alg_speed_test(const char *alg, const char *driver,
+ unsigned int sec,
+ struct cipher_speed_template *t,
+ unsigned int tcount, u8 *keysize);
+
+static struct cipher_speed_template des3_speed_template[] = {
+ {
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef"
+ "\x55\x55\x55\x55\x55\x55\x55\x55"
+ "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .klen = 24,
+ }
+};
+
+/*
+ * Cipher speed tests
+ */
+static u8 speed_template_8[] = {8, 0};
+static u8 speed_template_24[] = {24, 0};
+static u8 speed_template_8_32[] = {8, 32, 0};
+static u8 speed_template_16_32[] = {16, 32, 0};
+static u8 speed_template_16_24_32[] = {16, 24, 32, 0};
+static u8 speed_template_32_40_48[] = {32, 40, 48, 0};
+static u8 speed_template_32_48_64[] = {32, 48, 64, 0};
+
+/*
+ * Digest speed tests
+ */
+static struct hash_speed generic_hash_speed_template[] = {
+ { .blen = 16, .plen = 16, },
+ { .blen = 64, .plen = 16, },
+ { .blen = 64, .plen = 64, },
+ { .blen = 256, .plen = 16, },
+ { .blen = 256, .plen = 64, },
+ { .blen = 256, .plen = 256, },
+ { .blen = 1024, .plen = 16, },
+ { .blen = 1024, .plen = 256, },
+ { .blen = 1024, .plen = 1024, },
+ { .blen = 2048, .plen = 16, },
+ { .blen = 2048, .plen = 256, },
+ { .blen = 2048, .plen = 1024, },
+ { .blen = 2048, .plen = 2048, },
+ { .blen = 4096, .plen = 16, },
+ { .blen = 4096, .plen = 256, },
+ { .blen = 4096, .plen = 1024, },
+ { .blen = 4096, .plen = 4096, },
+ { .blen = 8192, .plen = 16, },
+ { .blen = 8192, .plen = 256, },
+ { .blen = 8192, .plen = 1024, },
+ { .blen = 8192, .plen = 4096, },
+ { .blen = 8192, .plen = 8192, },
+
+ /* End marker */
+ { .blen = 0, .plen = 0, }
+};
+
+#endif /* _CRYPTO_TCRYPT_H */
diff --git a/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_testmgr.h.svn-base b/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_testmgr.h.svn-base
new file mode 100644
index 0000000..27fe9a9
--- /dev/null
+++ b/package/platform/lantiq/ltq-deu/src/.svn/text-base/ifxmips_testmgr.h.svn-base
@@ -0,0 +1,9598 @@
+/*
+ * Algorithm testing framework and tests.
+ *
+ * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
+ * Copyright (c) 2002 Jean-Francois Dive <jef@linuxbe.org>
+ * Copyright (c) 2007 Nokia Siemens Networks
+ * Copyright (c) 2008 Herbert Xu <herbert@gondor.apana.org.au>
+ *
+ * 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 of the License, or (at your option)
+ * any later version.
+ *
+ */
+#ifndef _IFXMIPS_CRYPTO_TESTMGR_H
+#define _IFXMIPS_CRYPTO_TESTMGR_H
+
+#include <linux/netlink.h>
+#include <linux/zlib.h>
+
+#include <crypto/compress.h>
+
+#define MAX_DIGEST_SIZE 64
+#define MAX_TAP 8
+
+#define MAX_KEYLEN 56
+#define MAX_IVLEN 32
+
+struct hash_testvec {
+ /* only used with keyed hash algorithms */
+ char *key;
+ char *plaintext;
+ char *digest;
+ unsigned char tap[MAX_TAP];
+ unsigned char psize;
+ unsigned char np;
+ unsigned char ksize;
+};
+
+struct cipher_testvec {
+ char *key;
+ char *iv;
+ char *input;
+ char *result;
+ unsigned short tap[MAX_TAP];
+ int np;
+ unsigned char fail;
+ unsigned char wk; /* weak key flag */
+ unsigned char klen;
+ unsigned short ilen;
+ unsigned short rlen;
+};
+
+struct aead_testvec {
+ char *key;
+ char *iv;
+ char *input;
+ char *assoc;
+ char *result;
+ unsigned char tap[MAX_TAP];
+ unsigned char atap[MAX_TAP];
+ int np;
+ int anp;
+ unsigned char fail;
+ unsigned char novrfy; /* ccm dec verification failure expected */
+ unsigned char wk; /* weak key flag */
+ unsigned char klen;
+ unsigned short ilen;
+ unsigned short alen;
+ unsigned short rlen;
+};
+
+struct cprng_testvec {
+ char *key;
+ char *dt;
+ char *v;
+ char *result;
+ unsigned char klen;
+ unsigned short dtlen;
+ unsigned short vlen;
+ unsigned short rlen;
+ unsigned short loops;
+};
+
+static char zeroed_string[48];
+
+/*
+ * MD4 test vectors from RFC1320
+ */
+#define MD4_TEST_VECTORS 7
+
+static struct hash_testvec md4_tv_template [] = {
+ {
+ .plaintext = "",
+ .digest = "\x31\xd6\xcf\xe0\xd1\x6a\xe9\x31"
+ "\xb7\x3c\x59\xd7\xe0\xc0\x89\xc0",
+ }, {
+ .plaintext = "a",
+ .psize = 1,
+ .digest = "\xbd\xe5\x2c\xb3\x1d\xe3\x3e\x46"
+ "\x24\x5e\x05\xfb\xdb\xd6\xfb\x24",
+ }, {
+ .plaintext = "abc",
+ .psize = 3,
+ .digest = "\xa4\x48\x01\x7a\xaf\x21\xd8\x52"
+ "\x5f\xc1\x0a\xe8\x7a\xa6\x72\x9d",
+ }, {
+ .plaintext = "message digest",
+ .psize = 14,
+ .digest = "\xd9\x13\x0a\x81\x64\x54\x9f\xe8"
+ "\x18\x87\x48\x06\xe1\xc7\x01\x4b",
+ }, {
+ .plaintext = "abcdefghijklmnopqrstuvwxyz",
+ .psize = 26,
+ .digest = "\xd7\x9e\x1c\x30\x8a\xa5\xbb\xcd"
+ "\xee\xa8\xed\x63\xdf\x41\x2d\xa9",
+ .np = 2,
+ .tap = { 13, 13 },
+ }, {
+ .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
+ .psize = 62,
+ .digest = "\x04\x3f\x85\x82\xf2\x41\xdb\x35"
+ "\x1c\xe6\x27\xe1\x53\xe7\xf0\xe4",
+ }, {
+ .plaintext = "123456789012345678901234567890123456789012345678901234567890123"
+ "45678901234567890",
+ .psize = 80,
+ .digest = "\xe3\x3b\x4d\xdc\x9c\x38\xf2\x19"
+ "\x9c\x3e\x7b\x16\x4f\xcc\x05\x36",
+ },
+};
+
+/*
+ * MD5 test vectors from RFC1321
+ */
+#define MD5_TEST_VECTORS 7
+
+static struct hash_testvec md5_tv_template[] = {
+ {
+ .digest = "\xd4\x1d\x8c\xd9\x8f\x00\xb2\x04"
+ "\xe9\x80\x09\x98\xec\xf8\x42\x7e",
+ }, {
+ .plaintext = "a",
+ .psize = 1,
+ .digest = "\x0c\xc1\x75\xb9\xc0\xf1\xb6\xa8"
+ "\x31\xc3\x99\xe2\x69\x77\x26\x61",
+ }, {
+ .plaintext = "abc",
+ .psize = 3,
+ .digest = "\x90\x01\x50\x98\x3c\xd2\x4f\xb0"
+ "\xd6\x96\x3f\x7d\x28\xe1\x7f\x72",
+ }, {
+ .plaintext = "message digest",
+ .psize = 14,
+ .digest = "\xf9\x6b\x69\x7d\x7c\xb7\x93\x8d"
+ "\x52\x5a\x2f\x31\xaa\xf1\x61\xd0",
+ }, {
+ .plaintext = "abcdefghijklmnopqrstuvwxyz",
+ .psize = 26,
+ .digest = "\xc3\xfc\xd3\xd7\x61\x92\xe4\x00"
+ "\x7d\xfb\x49\x6c\xca\x67\xe1\x3b",
+ .np = 2,
+ .tap = {13, 13}
+ }, {
+ .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
+ .psize = 62,
+ .digest = "\xd1\x74\xab\x98\xd2\x77\xd9\xf5"
+ "\xa5\x61\x1c\x2c\x9f\x41\x9d\x9f",
+ }, {
+ .plaintext = "12345678901234567890123456789012345678901234567890123456789012"
+ "345678901234567890",
+ .psize = 80,
+ .digest = "\x57\xed\xf4\xa2\x2b\xe3\xc9\x55"
+ "\xac\x49\xda\x2e\x21\x07\xb6\x7a",
+ }
+
+};
+
+/*
+ * RIPEMD-128 test vectors from ISO/IEC 10118-3:2004(E)
+ */
+#define RMD128_TEST_VECTORS 10
+
+static struct hash_testvec rmd128_tv_template[] = {
+ {
+ .digest = "\xcd\xf2\x62\x13\xa1\x50\xdc\x3e"
+ "\xcb\x61\x0f\x18\xf6\xb3\x8b\x46",
+ }, {
+ .plaintext = "a",
+ .psize = 1,
+ .digest = "\x86\xbe\x7a\xfa\x33\x9d\x0f\xc7"
+ "\xcf\xc7\x85\xe7\x2f\x57\x8d\x33",
+ }, {
+ .plaintext = "abc",
+ .psize = 3,
+ .digest = "\xc1\x4a\x12\x19\x9c\x66\xe4\xba"
+ "\x84\x63\x6b\x0f\x69\x14\x4c\x77",
+ }, {
+ .plaintext = "message digest",
+ .psize = 14,
+ .digest = "\x9e\x32\x7b\x3d\x6e\x52\x30\x62"
+ "\xaf\xc1\x13\x2d\x7d\xf9\xd1\xb8",
+ }, {
+ .plaintext = "abcdefghijklmnopqrstuvwxyz",
+ .psize = 26,
+ .digest = "\xfd\x2a\xa6\x07\xf7\x1d\xc8\xf5"
+ "\x10\x71\x49\x22\xb3\x71\x83\x4e",
+ }, {
+ .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcde"
+ "fghijklmnopqrstuvwxyz0123456789",
+ .psize = 62,
+ .digest = "\xd1\xe9\x59\xeb\x17\x9c\x91\x1f"
+ "\xae\xa4\x62\x4c\x60\xc5\xc7\x02",
+ }, {
+ .plaintext = "1234567890123456789012345678901234567890"
+ "1234567890123456789012345678901234567890",
+ .psize = 80,
+ .digest = "\x3f\x45\xef\x19\x47\x32\xc2\xdb"
+ "\xb2\xc4\xa2\xc7\x69\x79\x5f\xa3",
+ }, {
+ .plaintext = "abcdbcdecdefdefgefghfghighij"
+ "hijkijkljklmklmnlmnomnopnopq",
+ .psize = 56,
+ .digest = "\xa1\xaa\x06\x89\xd0\xfa\xfa\x2d"
+ "\xdc\x22\xe8\x8b\x49\x13\x3a\x06",
+ .np = 2,
+ .tap = { 28, 28 },
+ }, {
+ .plaintext = "abcdefghbcdefghicdefghijdefghijkefghijklfghi"
+ "jklmghijklmnhijklmnoijklmnopjklmnopqklmnopqr"
+ "lmnopqrsmnopqrstnopqrstu",
+ .psize = 112,
+ .digest = "\xd4\xec\xc9\x13\xe1\xdf\x77\x6b"
+ "\xf4\x8d\xe9\xd5\x5b\x1f\x25\x46",
+ }, {
+ .plaintext = "abcdbcdecdefdefgefghfghighijhijk",
+ .psize = 32,
+ .digest = "\x13\xfc\x13\xe8\xef\xff\x34\x7d"
+ "\xe1\x93\xff\x46\xdb\xac\xcf\xd4",
+ }
+};
+
+/*
+ * RIPEMD-160 test vectors from ISO/IEC 10118-3:2004(E)
+ */
+#define RMD160_TEST_VECTORS 10
+
+static struct hash_testvec rmd160_tv_template[] = {
+ {
+ .digest = "\x9c\x11\x85\xa5\xc5\xe9\xfc\x54\x61\x28"
+ "\x08\x97\x7e\xe8\xf5\x48\xb2\x25\x8d\x31",
+ }, {
+ .plaintext = "a",
+ .psize = 1,
+ .digest = "\x0b\xdc\x9d\x2d\x25\x6b\x3e\xe9\xda\xae"
+ "\x34\x7b\xe6\xf4\xdc\x83\x5a\x46\x7f\xfe",
+ }, {
+ .plaintext = "abc",
+ .psize = 3,
+ .digest = "\x8e\xb2\x08\xf7\xe0\x5d\x98\x7a\x9b\x04"
+ "\x4a\x8e\x98\xc6\xb0\x87\xf1\x5a\x0b\xfc",
+ }, {
+ .plaintext = "message digest",
+ .psize = 14,
+ .digest = "\x5d\x06\x89\xef\x49\xd2\xfa\xe5\x72\xb8"
+ "\x81\xb1\x23\xa8\x5f\xfa\x21\x59\x5f\x36",
+ }, {
+ .plaintext = "abcdefghijklmnopqrstuvwxyz",
+ .psize = 26,
+ .digest = "\xf7\x1c\x27\x10\x9c\x69\x2c\x1b\x56\xbb"
+ "\xdc\xeb\x5b\x9d\x28\x65\xb3\x70\x8d\xbc",
+ }, {
+ .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcde"
+ "fghijklmnopqrstuvwxyz0123456789",
+ .psize = 62,
+ .digest = "\xb0\xe2\x0b\x6e\x31\x16\x64\x02\x86\xed"
+ "\x3a\x87\xa5\x71\x30\x79\xb2\x1f\x51\x89",
+ }, {
+ .plaintext = "1234567890123456789012345678901234567890"
+ "1234567890123456789012345678901234567890",
+ .psize = 80,
+ .digest = "\x9b\x75\x2e\x45\x57\x3d\x4b\x39\xf4\xdb"
+ "\xd3\x32\x3c\xab\x82\xbf\x63\x32\x6b\xfb",
+ }, {
+ .plaintext = "abcdbcdecdefdefgefghfghighij"
+ "hijkijkljklmklmnlmnomnopnopq",
+ .psize = 56,
+ .digest = "\x12\xa0\x53\x38\x4a\x9c\x0c\x88\xe4\x05"
+ "\xa0\x6c\x27\xdc\xf4\x9a\xda\x62\xeb\x2b",
+ .np = 2,
+ .tap = { 28, 28 },
+ }, {
+ .plaintext = "abcdefghbcdefghicdefghijdefghijkefghijklfghi"
+ "jklmghijklmnhijklmnoijklmnopjklmnopqklmnopqr"
+ "lmnopqrsmnopqrstnopqrstu",
+ .psize = 112,
+ .digest = "\x6f\x3f\xa3\x9b\x6b\x50\x3c\x38\x4f\x91"
+ "\x9a\x49\xa7\xaa\x5c\x2c\x08\xbd\xfb\x45",
+ }, {
+ .plaintext = "abcdbcdecdefdefgefghfghighijhijk",
+ .psize = 32,
+ .digest = "\x94\xc2\x64\x11\x54\x04\xe6\x33\x79\x0d"
+ "\xfc\xc8\x7b\x58\x7d\x36\x77\x06\x7d\x9f",
+ }
+};
+
+/*
+ * RIPEMD-256 test vectors
+ */
+#define RMD256_TEST_VECTORS 8
+
+static struct hash_testvec rmd256_tv_template[] = {
+ {
+ .digest = "\x02\xba\x4c\x4e\x5f\x8e\xcd\x18"
+ "\x77\xfc\x52\xd6\x4d\x30\xe3\x7a"
+ "\x2d\x97\x74\xfb\x1e\x5d\x02\x63"
+ "\x80\xae\x01\x68\xe3\xc5\x52\x2d",
+ }, {
+ .plaintext = "a",
+ .psize = 1,
+ .digest = "\xf9\x33\x3e\x45\xd8\x57\xf5\xd9"
+ "\x0a\x91\xba\xb7\x0a\x1e\xba\x0c"
+ "\xfb\x1b\xe4\xb0\x78\x3c\x9a\xcf"
+ "\xcd\x88\x3a\x91\x34\x69\x29\x25",
+ }, {
+ .plaintext = "abc",
+ .psize = 3,
+ .digest = "\xaf\xbd\x6e\x22\x8b\x9d\x8c\xbb"
+ "\xce\xf5\xca\x2d\x03\xe6\xdb\xa1"
+ "\x0a\xc0\xbc\x7d\xcb\xe4\x68\x0e"
+ "\x1e\x42\xd2\xe9\x75\x45\x9b\x65",
+ }, {
+ .plaintext = "message digest",
+ .psize = 14,
+ .digest = "\x87\xe9\x71\x75\x9a\x1c\xe4\x7a"
+ "\x51\x4d\x5c\x91\x4c\x39\x2c\x90"
+ "\x18\xc7\xc4\x6b\xc1\x44\x65\x55"
+ "\x4a\xfc\xdf\x54\xa5\x07\x0c\x0e",
+ }, {
+ .plaintext = "abcdefghijklmnopqrstuvwxyz",
+ .psize = 26,
+ .digest = "\x64\x9d\x30\x34\x75\x1e\xa2\x16"
+ "\x77\x6b\xf9\xa1\x8a\xcc\x81\xbc"
+ "\x78\x96\x11\x8a\x51\x97\x96\x87"
+ "\x82\xdd\x1f\xd9\x7d\x8d\x51\x33",
+ }, {
+ .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcde"
+ "fghijklmnopqrstuvwxyz0123456789",
+ .psize = 62,
+ .digest = "\x57\x40\xa4\x08\xac\x16\xb7\x20"
+ "\xb8\x44\x24\xae\x93\x1c\xbb\x1f"
+ "\xe3\x63\xd1\xd0\xbf\x40\x17\xf1"
+ "\xa8\x9f\x7e\xa6\xde\x77\xa0\xb8",
+ }, {
+ .plaintext = "1234567890123456789012345678901234567890"
+ "1234567890123456789012345678901234567890",
+ .psize = 80,
+ .digest = "\x06\xfd\xcc\x7a\x40\x95\x48\xaa"
+ "\xf9\x13\x68\xc0\x6a\x62\x75\xb5"
+ "\x53\xe3\xf0\x99\xbf\x0e\xa4\xed"
+ "\xfd\x67\x78\xdf\x89\xa8\x90\xdd",
+ }, {
+ .plaintext = "abcdbcdecdefdefgefghfghighij"
+ "hijkijkljklmklmnlmnomnopnopq",
+ .psize = 56,
+ .digest = "\x38\x43\x04\x55\x83\xaa\xc6\xc8"
+ "\xc8\xd9\x12\x85\x73\xe7\xa9\x80"
+ "\x9a\xfb\x2a\x0f\x34\xcc\xc3\x6e"
+ "\xa9\xe7\x2f\x16\xf6\x36\x8e\x3f",
+ .np = 2,
+ .tap = { 28, 28 },
+ }
+};
+
+/*
+ * RIPEMD-320 test vectors
+ */
+#define RMD320_TEST_VECTORS 8
+
+static struct hash_testvec rmd320_tv_template[] = {
+ {
+ .digest = "\x22\xd6\x5d\x56\x61\x53\x6c\xdc\x75\xc1"
+ "\xfd\xf5\xc6\xde\x7b\x41\xb9\xf2\x73\x25"
+ "\xeb\xc6\x1e\x85\x57\x17\x7d\x70\x5a\x0e"
+ "\xc8\x80\x15\x1c\x3a\x32\xa0\x08\x99\xb8",
+ }, {
+ .plaintext = "a",
+ .psize = 1,
+ .digest = "\xce\x78\x85\x06\x38\xf9\x26\x58\xa5\xa5"
+ "\x85\x09\x75\x79\x92\x6d\xda\x66\x7a\x57"
+ "\x16\x56\x2c\xfc\xf6\xfb\xe7\x7f\x63\x54"
+ "\x2f\x99\xb0\x47\x05\xd6\x97\x0d\xff\x5d",
+ }, {
+ .plaintext = "abc",
+ .psize = 3,
+ .digest = "\xde\x4c\x01\xb3\x05\x4f\x89\x30\xa7\x9d"
+ "\x09\xae\x73\x8e\x92\x30\x1e\x5a\x17\x08"
+ "\x5b\xef\xfd\xc1\xb8\xd1\x16\x71\x3e\x74"
+ "\xf8\x2f\xa9\x42\xd6\x4c\xdb\xc4\x68\x2d",
+ }, {
+ .plaintext = "message digest",
+ .psize = 14,
+ .digest = "\x3a\x8e\x28\x50\x2e\xd4\x5d\x42\x2f\x68"
+ "\x84\x4f\x9d\xd3\x16\xe7\xb9\x85\x33\xfa"
+ "\x3f\x2a\x91\xd2\x9f\x84\xd4\x25\xc8\x8d"
+ "\x6b\x4e\xff\x72\x7d\xf6\x6a\x7c\x01\x97",
+ }, {
+ .plaintext = "abcdefghijklmnopqrstuvwxyz",
+ .psize = 26,
+ .digest = "\xca\xbd\xb1\x81\x0b\x92\x47\x0a\x20\x93"
+ "\xaa\x6b\xce\x05\x95\x2c\x28\x34\x8c\xf4"
+ "\x3f\xf6\x08\x41\x97\x51\x66\xbb\x40\xed"
+ "\x23\x40\x04\xb8\x82\x44\x63\xe6\xb0\x09",
+ }, {
+ .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcde"
+ "fghijklmnopqrstuvwxyz0123456789",
+ .psize = 62,
+ .digest = "\xed\x54\x49\x40\xc8\x6d\x67\xf2\x50\xd2"
+ "\x32\xc3\x0b\x7b\x3e\x57\x70\xe0\xc6\x0c"
+ "\x8c\xb9\xa4\xca\xfe\x3b\x11\x38\x8a\xf9"
+ "\x92\x0e\x1b\x99\x23\x0b\x84\x3c\x86\xa4",
+ }, {
+ .plaintext = "1234567890123456789012345678901234567890"
+ "1234567890123456789012345678901234567890",
+ .psize = 80,
+ .digest = "\x55\x78\x88\xaf\x5f\x6d\x8e\xd6\x2a\xb6"
+ "\x69\x45\xc6\xd2\xa0\xa4\x7e\xcd\x53\x41"
+ "\xe9\x15\xeb\x8f\xea\x1d\x05\x24\x95\x5f"
+ "\x82\x5d\xc7\x17\xe4\xa0\x08\xab\x2d\x42",
+ }, {
+ .plaintext = "abcdbcdecdefdefgefghfghighij"
+ "hijkijkljklmklmnlmnomnopnopq",
+ .psize = 56,
+ .digest = "\xd0\x34\xa7\x95\x0c\xf7\x22\x02\x1b\xa4"
+ "\xb8\x4d\xf7\x69\xa5\xde\x20\x60\xe2\x59"
+ "\xdf\x4c\x9b\xb4\xa4\x26\x8c\x0e\x93\x5b"
+ "\xbc\x74\x70\xa9\x69\xc9\xd0\x72\xa1\xac",
+ .np = 2,
+ .tap = { 28, 28 },
+ }
+};
+
+/*
+ * SHA1 test vectors from from FIPS PUB 180-1
+ */
+#define SHA1_TEST_VECTORS 2
+
+static struct hash_testvec sha1_tv_template[] = {
+ {
+ .plaintext = "abc",
+ .psize = 3,
+ .digest = "\xa9\x99\x3e\x36\x47\x06\x81\x6a\xba\x3e"
+ "\x25\x71\x78\x50\xc2\x6c\x9c\xd0\xd8\x9d",
+ }, {
+ .plaintext = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
+ .psize = 56,
+ .digest = "\x84\x98\x3e\x44\x1c\x3b\xd2\x6e\xba\xae"
+ "\x4a\xa1\xf9\x51\x29\xe5\xe5\x46\x70\xf1",
+ .np = 2,
+ .tap = { 28, 28 }
+ }
+};
+
+
+/*
+ * SHA224 test vectors from from FIPS PUB 180-2
+ */
+#define SHA224_TEST_VECTORS 2
+
+static struct hash_testvec sha224_tv_template[] = {
+ {
+ .plaintext = "abc",
+ .psize = 3,
+ .digest = "\x23\x09\x7D\x22\x34\x05\xD8\x22"
+ "\x86\x42\xA4\x77\xBD\xA2\x55\xB3"
+ "\x2A\xAD\xBC\xE4\xBD\xA0\xB3\xF7"
+ "\xE3\x6C\x9D\xA7",
+ }, {
+ .plaintext =
+ "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
+ .psize = 56,
+ .digest = "\x75\x38\x8B\x16\x51\x27\x76\xCC"
+ "\x5D\xBA\x5D\xA1\xFD\x89\x01\x50"
+ "\xB0\xC6\x45\x5C\xB4\xF5\x8B\x19"
+ "\x52\x52\x25\x25",
+ .np = 2,
+ .tap = { 28, 28 }
+ }
+};
+
+/*
+ * SHA256 test vectors from from NIST
+ */
+#define SHA256_TEST_VECTORS 2
+
+static struct hash_testvec sha256_tv_template[] = {
+ {
+ .plaintext = "abc",
+ .psize = 3,
+ .digest = "\xba\x78\x16\xbf\x8f\x01\xcf\xea"
+ "\x41\x41\x40\xde\x5d\xae\x22\x23"
+ "\xb0\x03\x61\xa3\x96\x17\x7a\x9c"
+ "\xb4\x10\xff\x61\xf2\x00\x15\xad",
+ }, {
+ .plaintext = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
+ .psize = 56,
+ .digest = "\x24\x8d\x6a\x61\xd2\x06\x38\xb8"
+ "\xe5\xc0\x26\x93\x0c\x3e\x60\x39"
+ "\xa3\x3c\xe4\x59\x64\xff\x21\x67"
+ "\xf6\xec\xed\xd4\x19\xdb\x06\xc1",
+ .np = 2,
+ .tap = { 28, 28 }
+ },
+};
+
+/*
+ * SHA384 test vectors from from NIST and kerneli
+ */
+#define SHA384_TEST_VECTORS 4
+
+static struct hash_testvec sha384_tv_template[] = {
+ {
+ .plaintext= "abc",
+ .psize = 3,
+ .digest = "\xcb\x00\x75\x3f\x45\xa3\x5e\x8b"
+ "\xb5\xa0\x3d\x69\x9a\xc6\x50\x07"
+ "\x27\x2c\x32\xab\x0e\xde\xd1\x63"
+ "\x1a\x8b\x60\x5a\x43\xff\x5b\xed"
+ "\x80\x86\x07\x2b\xa1\xe7\xcc\x23"
+ "\x58\xba\xec\xa1\x34\xc8\x25\xa7",
+ }, {
+ .plaintext = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
+ .psize = 56,
+ .digest = "\x33\x91\xfd\xdd\xfc\x8d\xc7\x39"
+ "\x37\x07\xa6\x5b\x1b\x47\x09\x39"
+ "\x7c\xf8\xb1\xd1\x62\xaf\x05\xab"
+ "\xfe\x8f\x45\x0d\xe5\xf3\x6b\xc6"
+ "\xb0\x45\x5a\x85\x20\xbc\x4e\x6f"
+ "\x5f\xe9\x5b\x1f\xe3\xc8\x45\x2b",
+ }, {
+ .plaintext = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn"
+ "hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu",
+ .psize = 112,
+ .digest = "\x09\x33\x0c\x33\xf7\x11\x47\xe8"
+ "\x3d\x19\x2f\xc7\x82\xcd\x1b\x47"
+ "\x53\x11\x1b\x17\x3b\x3b\x05\xd2"
+ "\x2f\xa0\x80\x86\xe3\xb0\xf7\x12"
+ "\xfc\xc7\xc7\x1a\x55\x7e\x2d\xb9"
+ "\x66\xc3\xe9\xfa\x91\x74\x60\x39",
+ }, {
+ .plaintext = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd"
+ "efghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz",
+ .psize = 104,
+ .digest = "\x3d\x20\x89\x73\xab\x35\x08\xdb"
+ "\xbd\x7e\x2c\x28\x62\xba\x29\x0a"
+ "\xd3\x01\x0e\x49\x78\xc1\x98\xdc"
+ "\x4d\x8f\xd0\x14\xe5\x82\x82\x3a"
+ "\x89\xe1\x6f\x9b\x2a\x7b\xbc\x1a"
+ "\xc9\x38\xe2\xd1\x99\xe8\xbe\xa4",
+ .np = 4,
+ .tap = { 26, 26, 26, 26 }
+ },
+};
+
+/*
+ * SHA512 test vectors from from NIST and kerneli
+ */
+#define SHA512_TEST_VECTORS 4
+
+static struct hash_testvec sha512_tv_template[] = {
+ {
+ .plaintext = "abc",
+ .psize = 3,
+ .digest = "\xdd\xaf\x35\xa1\x93\x61\x7a\xba"
+ "\xcc\x41\x73\x49\xae\x20\x41\x31"
+ "\x12\xe6\xfa\x4e\x89\xa9\x7e\xa2"
+ "\x0a\x9e\xee\xe6\x4b\x55\xd3\x9a"
+ "\x21\x92\x99\x2a\x27\x4f\xc1\xa8"
+ "\x36\xba\x3c\x23\xa3\xfe\xeb\xbd"
+ "\x45\x4d\x44\x23\x64\x3c\xe8\x0e"
+ "\x2a\x9a\xc9\x4f\xa5\x4c\xa4\x9f",
+ }, {
+ .plaintext = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
+ .psize = 56,
+ .digest = "\x20\x4a\x8f\xc6\xdd\xa8\x2f\x0a"
+ "\x0c\xed\x7b\xeb\x8e\x08\xa4\x16"
+ "\x57\xc1\x6e\xf4\x68\xb2\x28\xa8"
+ "\x27\x9b\xe3\x31\xa7\x03\xc3\x35"
+ "\x96\xfd\x15\xc1\x3b\x1b\x07\xf9"
+ "\xaa\x1d\x3b\xea\x57\x78\x9c\xa0"
+ "\x31\xad\x85\xc7\xa7\x1d\xd7\x03"
+ "\x54\xec\x63\x12\x38\xca\x34\x45",
+ }, {
+ .plaintext = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn"
+ "hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu",
+ .psize = 112,
+ .digest = "\x8e\x95\x9b\x75\xda\xe3\x13\xda"
+ "\x8c\xf4\xf7\x28\x14\xfc\x14\x3f"
+ "\x8f\x77\x79\xc6\xeb\x9f\x7f\xa1"
+ "\x72\x99\xae\xad\xb6\x88\x90\x18"
+ "\x50\x1d\x28\x9e\x49\x00\xf7\xe4"
+ "\x33\x1b\x99\xde\xc4\xb5\x43\x3a"
+ "\xc7\xd3\x29\xee\xb6\xdd\x26\x54"
+ "\x5e\x96\xe5\x5b\x87\x4b\xe9\x09",
+ }, {
+ .plaintext = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd"
+ "efghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz",
+ .psize = 104,
+ .digest = "\x93\x0d\x0c\xef\xcb\x30\xff\x11"
+ "\x33\xb6\x89\x81\x21\xf1\xcf\x3d"
+ "\x27\x57\x8a\xfc\xaf\xe8\x67\x7c"
+ "\x52\x57\xcf\x06\x99\x11\xf7\x5d"
+ "\x8f\x58\x31\xb5\x6e\xbf\xda\x67"
+ "\xb2\x78\xe6\x6d\xff\x8b\x84\xfe"
+ "\x2b\x28\x70\xf7\x42\xa5\x80\xd8"
+ "\xed\xb4\x19\x87\x23\x28\x50\xc9",
+ .np = 4,
+ .tap = { 26, 26, 26, 26 }
+ },
+};
+
+
+/*
+ * WHIRLPOOL test vectors from Whirlpool package
+ * by Vincent Rijmen and Paulo S. L. M. Barreto as part of the NESSIE
+ * submission
+ */
+#define WP512_TEST_VECTORS 8
+
+static struct hash_testvec wp512_tv_template[] = {
+ {
+ .plaintext = "",
+ .psize = 0,
+ .digest = "\x19\xFA\x61\xD7\x55\x22\xA4\x66"
+ "\x9B\x44\xE3\x9C\x1D\x2E\x17\x26"
+ "\xC5\x30\x23\x21\x30\xD4\x07\xF8"
+ "\x9A\xFE\xE0\x96\x49\x97\xF7\xA7"
+ "\x3E\x83\xBE\x69\x8B\x28\x8F\xEB"
+ "\xCF\x88\xE3\xE0\x3C\x4F\x07\x57"
+ "\xEA\x89\x64\xE5\x9B\x63\xD9\x37"
+ "\x08\xB1\x38\xCC\x42\xA6\x6E\xB3",
+
+
+ }, {
+ .plaintext = "a",
+ .psize = 1,
+ .digest = "\x8A\xCA\x26\x02\x79\x2A\xEC\x6F"
+ "\x11\xA6\x72\x06\x53\x1F\xB7\xD7"
+ "\xF0\xDF\xF5\x94\x13\x14\x5E\x69"
+ "\x73\xC4\x50\x01\xD0\x08\x7B\x42"
+ "\xD1\x1B\xC6\x45\x41\x3A\xEF\xF6"
+ "\x3A\x42\x39\x1A\x39\x14\x5A\x59"
+ "\x1A\x92\x20\x0D\x56\x01\x95\xE5"
+ "\x3B\x47\x85\x84\xFD\xAE\x23\x1A",
+ }, {
+ .plaintext = "abc",
+ .psize = 3,
+ .digest = "\x4E\x24\x48\xA4\xC6\xF4\x86\xBB"
+ "\x16\xB6\x56\x2C\x73\xB4\x02\x0B"
+ "\xF3\x04\x3E\x3A\x73\x1B\xCE\x72"
+ "\x1A\xE1\xB3\x03\xD9\x7E\x6D\x4C"
+ "\x71\x81\xEE\xBD\xB6\xC5\x7E\x27"
+ "\x7D\x0E\x34\x95\x71\x14\xCB\xD6"
+ "\xC7\x97\xFC\x9D\x95\xD8\xB5\x82"
+ "\xD2\x25\x29\x20\x76\xD4\xEE\xF5",
+ }, {
+ .plaintext = "message digest",
+ .psize = 14,
+ .digest = "\x37\x8C\x84\xA4\x12\x6E\x2D\xC6"
+ "\xE5\x6D\xCC\x74\x58\x37\x7A\xAC"
+ "\x83\x8D\x00\x03\x22\x30\xF5\x3C"
+ "\xE1\xF5\x70\x0C\x0F\xFB\x4D\x3B"
+ "\x84\x21\x55\x76\x59\xEF\x55\xC1"
+ "\x06\xB4\xB5\x2A\xC5\xA4\xAA\xA6"
+ "\x92\xED\x92\x00\x52\x83\x8F\x33"
+ "\x62\xE8\x6D\xBD\x37\xA8\x90\x3E",
+ }, {
+ .plaintext = "abcdefghijklmnopqrstuvwxyz",
+ .psize = 26,
+ .digest = "\xF1\xD7\x54\x66\x26\x36\xFF\xE9"
+ "\x2C\x82\xEB\xB9\x21\x2A\x48\x4A"
+ "\x8D\x38\x63\x1E\xAD\x42\x38\xF5"
+ "\x44\x2E\xE1\x3B\x80\x54\xE4\x1B"
+ "\x08\xBF\x2A\x92\x51\xC3\x0B\x6A"
+ "\x0B\x8A\xAE\x86\x17\x7A\xB4\xA6"
+ "\xF6\x8F\x67\x3E\x72\x07\x86\x5D"
+ "\x5D\x98\x19\xA3\xDB\xA4\xEB\x3B",
+ }, {
+ .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "abcdefghijklmnopqrstuvwxyz0123456789",
+ .psize = 62,
+ .digest = "\xDC\x37\xE0\x08\xCF\x9E\xE6\x9B"
+ "\xF1\x1F\x00\xED\x9A\xBA\x26\x90"
+ "\x1D\xD7\xC2\x8C\xDE\xC0\x66\xCC"
+ "\x6A\xF4\x2E\x40\xF8\x2F\x3A\x1E"
+ "\x08\xEB\xA2\x66\x29\x12\x9D\x8F"
+ "\xB7\xCB\x57\x21\x1B\x92\x81\xA6"
+ "\x55\x17\xCC\x87\x9D\x7B\x96\x21"
+ "\x42\xC6\x5F\x5A\x7A\xF0\x14\x67",
+ }, {
+ .plaintext = "1234567890123456789012345678901234567890"
+ "1234567890123456789012345678901234567890",
+ .psize = 80,
+ .digest = "\x46\x6E\xF1\x8B\xAB\xB0\x15\x4D"
+ "\x25\xB9\xD3\x8A\x64\x14\xF5\xC0"
+ "\x87\x84\x37\x2B\xCC\xB2\x04\xD6"
+ "\x54\x9C\x4A\xFA\xDB\x60\x14\x29"
+ "\x4D\x5B\xD8\xDF\x2A\x6C\x44\xE5"
+ "\x38\xCD\x04\x7B\x26\x81\xA5\x1A"
+ "\x2C\x60\x48\x1E\x88\xC5\xA2\x0B"
+ "\x2C\x2A\x80\xCF\x3A\x9A\x08\x3B",
+ }, {
+ .plaintext = "abcdbcdecdefdefgefghfghighijhijk",
+ .psize = 32,
+ .digest = "\x2A\x98\x7E\xA4\x0F\x91\x70\x61"
+ "\xF5\xD6\xF0\xA0\xE4\x64\x4F\x48"
+ "\x8A\x7A\x5A\x52\xDE\xEE\x65\x62"
+ "\x07\xC5\x62\xF9\x88\xE9\x5C\x69"
+ "\x16\xBD\xC8\x03\x1B\xC5\xBE\x1B"
+ "\x7B\x94\x76\x39\xFE\x05\x0B\x56"
+ "\x93\x9B\xAA\xA0\xAD\xFF\x9A\xE6"
+ "\x74\x5B\x7B\x18\x1C\x3B\xE3\xFD",
+ },
+};
+
+#define WP384_TEST_VECTORS 8
+
+static struct hash_testvec wp384_tv_template[] = {
+ {
+ .plaintext = "",
+ .psize = 0,
+ .digest = "\x19\xFA\x61\xD7\x55\x22\xA4\x66"
+ "\x9B\x44\xE3\x9C\x1D\x2E\x17\x26"
+ "\xC5\x30\x23\x21\x30\xD4\x07\xF8"
+ "\x9A\xFE\xE0\x96\x49\x97\xF7\xA7"
+ "\x3E\x83\xBE\x69\x8B\x28\x8F\xEB"
+ "\xCF\x88\xE3\xE0\x3C\x4F\x07\x57",
+
+
+ }, {
+ .plaintext = "a",
+ .psize = 1,
+ .digest = "\x8A\xCA\x26\x02\x79\x2A\xEC\x6F"
+ "\x11\xA6\x72\x06\x53\x1F\xB7\xD7"
+ "\xF0\xDF\xF5\x94\x13\x14\x5E\x69"
+ "\x73\xC4\x50\x01\xD0\x08\x7B\x42"
+ "\xD1\x1B\xC6\x45\x41\x3A\xEF\xF6"
+ "\x3A\x42\x39\x1A\x39\x14\x5A\x59",
+ }, {
+ .plaintext = "abc",
+ .psize = 3,
+ .digest = "\x4E\x24\x48\xA4\xC6\xF4\x86\xBB"
+ "\x16\xB6\x56\x2C\x73\xB4\x02\x0B"
+ "\xF3\x04\x3E\x3A\x73\x1B\xCE\x72"
+ "\x1A\xE1\xB3\x03\xD9\x7E\x6D\x4C"
+ "\x71\x81\xEE\xBD\xB6\xC5\x7E\x27"
+ "\x7D\x0E\x34\x95\x71\x14\xCB\xD6",
+ }, {
+ .plaintext = "message digest",
+ .psize = 14,
+ .digest = "\x37\x8C\x84\xA4\x12\x6E\x2D\xC6"
+ "\xE5\x6D\xCC\x74\x58\x37\x7A\xAC"
+ "\x83\x8D\x00\x03\x22\x30\xF5\x3C"
+ "\xE1\xF5\x70\x0C\x0F\xFB\x4D\x3B"
+ "\x84\x21\x55\x76\x59\xEF\x55\xC1"
+ "\x06\xB4\xB5\x2A\xC5\xA4\xAA\xA6",
+ }, {
+ .plaintext = "abcdefghijklmnopqrstuvwxyz",
+ .psize = 26,
+ .digest = "\xF1\xD7\x54\x66\x26\x36\xFF\xE9"
+ "\x2C\x82\xEB\xB9\x21\x2A\x48\x4A"
+ "\x8D\x38\x63\x1E\xAD\x42\x38\xF5"
+ "\x44\x2E\xE1\x3B\x80\x54\xE4\x1B"
+ "\x08\xBF\x2A\x92\x51\xC3\x0B\x6A"
+ "\x0B\x8A\xAE\x86\x17\x7A\xB4\xA6",
+ }, {
+ .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "abcdefghijklmnopqrstuvwxyz0123456789",
+ .psize = 62,
+ .digest = "\xDC\x37\xE0\x08\xCF\x9E\xE6\x9B"
+ "\xF1\x1F\x00\xED\x9A\xBA\x26\x90"
+ "\x1D\xD7\xC2\x8C\xDE\xC0\x66\xCC"
+ "\x6A\xF4\x2E\x40\xF8\x2F\x3A\x1E"
+ "\x08\xEB\xA2\x66\x29\x12\x9D\x8F"
+ "\xB7\xCB\x57\x21\x1B\x92\x81\xA6",
+ }, {
+ .plaintext = "1234567890123456789012345678901234567890"
+ "1234567890123456789012345678901234567890",
+ .psize = 80,
+ .digest = "\x46\x6E\xF1\x8B\xAB\xB0\x15\x4D"
+ "\x25\xB9\xD3\x8A\x64\x14\xF5\xC0"
+ "\x87\x84\x37\x2B\xCC\xB2\x04\xD6"
+ "\x54\x9C\x4A\xFA\xDB\x60\x14\x29"
+ "\x4D\x5B\xD8\xDF\x2A\x6C\x44\xE5"
+ "\x38\xCD\x04\x7B\x26\x81\xA5\x1A",
+ }, {
+ .plaintext = "abcdbcdecdefdefgefghfghighijhijk",
+ .psize = 32,
+ .digest = "\x2A\x98\x7E\xA4\x0F\x91\x70\x61"
+ "\xF5\xD6\xF0\xA0\xE4\x64\x4F\x48"
+ "\x8A\x7A\x5A\x52\xDE\xEE\x65\x62"
+ "\x07\xC5\x62\xF9\x88\xE9\x5C\x69"
+ "\x16\xBD\xC8\x03\x1B\xC5\xBE\x1B"
+ "\x7B\x94\x76\x39\xFE\x05\x0B\x56",
+ },
+};
+
+#define WP256_TEST_VECTORS 8
+
+static struct hash_testvec wp256_tv_template[] = {
+ {
+ .plaintext = "",
+ .psize = 0,
+ .digest = "\x19\xFA\x61\xD7\x55\x22\xA4\x66"
+ "\x9B\x44\xE3\x9C\x1D\x2E\x17\x26"
+ "\xC5\x30\x23\x21\x30\xD4\x07\xF8"
+ "\x9A\xFE\xE0\x96\x49\x97\xF7\xA7",
+
+
+ }, {
+ .plaintext = "a",
+ .psize = 1,
+ .digest = "\x8A\xCA\x26\x02\x79\x2A\xEC\x6F"
+ "\x11\xA6\x72\x06\x53\x1F\xB7\xD7"
+ "\xF0\xDF\xF5\x94\x13\x14\x5E\x69"
+ "\x73\xC4\x50\x01\xD0\x08\x7B\x42",
+ }, {
+ .plaintext = "abc",
+ .psize = 3,
+ .digest = "\x4E\x24\x48\xA4\xC6\xF4\x86\xBB"
+ "\x16\xB6\x56\x2C\x73\xB4\x02\x0B"
+ "\xF3\x04\x3E\x3A\x73\x1B\xCE\x72"
+ "\x1A\xE1\xB3\x03\xD9\x7E\x6D\x4C",
+ }, {
+ .plaintext = "message digest",
+ .psize = 14,
+ .digest = "\x37\x8C\x84\xA4\x12\x6E\x2D\xC6"
+ "\xE5\x6D\xCC\x74\x58\x37\x7A\xAC"
+ "\x83\x8D\x00\x03\x22\x30\xF5\x3C"
+ "\xE1\xF5\x70\x0C\x0F\xFB\x4D\x3B",
+ }, {
+ .plaintext = "abcdefghijklmnopqrstuvwxyz",
+ .psize = 26,
+ .digest = "\xF1\xD7\x54\x66\x26\x36\xFF\xE9"
+ "\x2C\x82\xEB\xB9\x21\x2A\x48\x4A"
+ "\x8D\x38\x63\x1E\xAD\x42\x38\xF5"
+ "\x44\x2E\xE1\x3B\x80\x54\xE4\x1B",
+ }, {
+ .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "abcdefghijklmnopqrstuvwxyz0123456789",
+ .psize = 62,
+ .digest = "\xDC\x37\xE0\x08\xCF\x9E\xE6\x9B"
+ "\xF1\x1F\x00\xED\x9A\xBA\x26\x90"
+ "\x1D\xD7\xC2\x8C\xDE\xC0\x66\xCC"
+ "\x6A\xF4\x2E\x40\xF8\x2F\x3A\x1E",
+ }, {
+ .plaintext = "1234567890123456789012345678901234567890"
+ "1234567890123456789012345678901234567890",
+ .psize = 80,
+ .digest = "\x46\x6E\xF1\x8B\xAB\xB0\x15\x4D"
+ "\x25\xB9\xD3\x8A\x64\x14\xF5\xC0"
+ "\x87\x84\x37\x2B\xCC\xB2\x04\xD6"
+ "\x54\x9C\x4A\xFA\xDB\x60\x14\x29",
+ }, {
+ .plaintext = "abcdbcdecdefdefgefghfghighijhijk",
+ .psize = 32,
+ .digest = "\x2A\x98\x7E\xA4\x0F\x91\x70\x61"
+ "\xF5\xD6\xF0\xA0\xE4\x64\x4F\x48"
+ "\x8A\x7A\x5A\x52\xDE\xEE\x65\x62"
+ "\x07\xC5\x62\xF9\x88\xE9\x5C\x69",
+ },
+};
+
+/*
+ * TIGER test vectors from Tiger website
+ */
+#define TGR192_TEST_VECTORS 6
+
+static struct hash_testvec tgr192_tv_template[] = {
+ {
+ .plaintext = "",
+ .psize = 0,
+ .digest = "\x24\xf0\x13\x0c\x63\xac\x93\x32"
+ "\x16\x16\x6e\x76\xb1\xbb\x92\x5f"
+ "\xf3\x73\xde\x2d\x49\x58\x4e\x7a",
+ }, {
+ .plaintext = "abc",
+ .psize = 3,
+ .digest = "\xf2\x58\xc1\xe8\x84\x14\xab\x2a"
+ "\x52\x7a\xb5\x41\xff\xc5\xb8\xbf"
+ "\x93\x5f\x7b\x95\x1c\x13\x29\x51",
+ }, {
+ .plaintext = "Tiger",
+ .psize = 5,
+ .digest = "\x9f\x00\xf5\x99\x07\x23\x00\xdd"
+ "\x27\x6a\xbb\x38\xc8\xeb\x6d\xec"
+ "\x37\x79\x0c\x11\x6f\x9d\x2b\xdf",
+ }, {
+ .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-",
+ .psize = 64,
+ .digest = "\x87\xfb\x2a\x90\x83\x85\x1c\xf7"
+ "\x47\x0d\x2c\xf8\x10\xe6\xdf\x9e"
+ "\xb5\x86\x44\x50\x34\xa5\xa3\x86",
+ }, {
+ .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZ=abcdefghijklmnopqrstuvwxyz+0123456789",
+ .psize = 64,
+ .digest = "\x46\x7d\xb8\x08\x63\xeb\xce\x48"
+ "\x8d\xf1\xcd\x12\x61\x65\x5d\xe9"
+ "\x57\x89\x65\x65\x97\x5f\x91\x97",
+ }, {
+ .plaintext = "Tiger - A Fast New Hash Function, "
+ "by Ross Anderson and Eli Biham, "
+ "proceedings of Fast Software Encryption 3, "
+ "Cambridge, 1996.",
+ .psize = 125,
+ .digest = "\x3d\x9a\xeb\x03\xd1\xbd\x1a\x63"
+ "\x57\xb2\x77\x4d\xfd\x6d\x5b\x24"
+ "\xdd\x68\x15\x1d\x50\x39\x74\xfc",
+ },
+};
+
+#define TGR160_TEST_VECTORS 6
+
+static struct hash_testvec tgr160_tv_template[] = {
+ {
+ .plaintext = "",
+ .psize = 0,
+ .digest = "\x24\xf0\x13\x0c\x63\xac\x93\x32"
+ "\x16\x16\x6e\x76\xb1\xbb\x92\x5f"
+ "\xf3\x73\xde\x2d",
+ }, {
+ .plaintext = "abc",
+ .psize = 3,
+ .digest = "\xf2\x58\xc1\xe8\x84\x14\xab\x2a"
+ "\x52\x7a\xb5\x41\xff\xc5\xb8\xbf"
+ "\x93\x5f\x7b\x95",
+ }, {
+ .plaintext = "Tiger",
+ .psize = 5,
+ .digest = "\x9f\x00\xf5\x99\x07\x23\x00\xdd"
+ "\x27\x6a\xbb\x38\xc8\xeb\x6d\xec"
+ "\x37\x79\x0c\x11",
+ }, {
+ .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-",
+ .psize = 64,
+ .digest = "\x87\xfb\x2a\x90\x83\x85\x1c\xf7"
+ "\x47\x0d\x2c\xf8\x10\xe6\xdf\x9e"
+ "\xb5\x86\x44\x50",
+ }, {
+ .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZ=abcdefghijklmnopqrstuvwxyz+0123456789",
+ .psize = 64,
+ .digest = "\x46\x7d\xb8\x08\x63\xeb\xce\x48"
+ "\x8d\xf1\xcd\x12\x61\x65\x5d\xe9"
+ "\x57\x89\x65\x65",
+ }, {
+ .plaintext = "Tiger - A Fast New Hash Function, "
+ "by Ross Anderson and Eli Biham, "
+ "proceedings of Fast Software Encryption 3, "
+ "Cambridge, 1996.",
+ .psize = 125,
+ .digest = "\x3d\x9a\xeb\x03\xd1\xbd\x1a\x63"
+ "\x57\xb2\x77\x4d\xfd\x6d\x5b\x24"
+ "\xdd\x68\x15\x1d",
+ },
+};
+
+#define TGR128_TEST_VECTORS 6
+
+static struct hash_testvec tgr128_tv_template[] = {
+ {
+ .plaintext = "",
+ .psize = 0,
+ .digest = "\x24\xf0\x13\x0c\x63\xac\x93\x32"
+ "\x16\x16\x6e\x76\xb1\xbb\x92\x5f",
+ }, {
+ .plaintext = "abc",
+ .psize = 3,
+ .digest = "\xf2\x58\xc1\xe8\x84\x14\xab\x2a"
+ "\x52\x7a\xb5\x41\xff\xc5\xb8\xbf",
+ }, {
+ .plaintext = "Tiger",
+ .psize = 5,
+ .digest = "\x9f\x00\xf5\x99\x07\x23\x00\xdd"
+ "\x27\x6a\xbb\x38\xc8\xeb\x6d\xec",
+ }, {
+ .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-",
+ .psize = 64,
+ .digest = "\x87\xfb\x2a\x90\x83\x85\x1c\xf7"
+ "\x47\x0d\x2c\xf8\x10\xe6\xdf\x9e",
+ }, {
+ .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZ=abcdefghijklmnopqrstuvwxyz+0123456789",
+ .psize = 64,
+ .digest = "\x46\x7d\xb8\x08\x63\xeb\xce\x48"
+ "\x8d\xf1\xcd\x12\x61\x65\x5d\xe9",
+ }, {
+ .plaintext = "Tiger - A Fast New Hash Function, "
+ "by Ross Anderson and Eli Biham, "
+ "proceedings of Fast Software Encryption 3, "
+ "Cambridge, 1996.",
+ .psize = 125,
+ .digest = "\x3d\x9a\xeb\x03\xd1\xbd\x1a\x63"
+ "\x57\xb2\x77\x4d\xfd\x6d\x5b\x24",
+ },
+};
+
+/*
+ * HMAC-MD5 test vectors from RFC2202
+ * (These need to be fixed to not use strlen).
+ */
+#ifndef CONFIG_CRYPTO_DEV_MD5_HMAC
+#define HMAC_MD5_TEST_VECTORS 7
+#else
+#define HMAC_MD5_TEST_VECTORS 5
+#endif
+
+static struct hash_testvec hmac_md5_tv_template[] =
+{
+ {
+ .key = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b",
+ .ksize = 16,
+ .plaintext = "Hi There",
+ .psize = 8,
+ .digest = "\x92\x94\x72\x7a\x36\x38\xbb\x1c"
+ "\x13\xf4\x8e\xf8\x15\x8b\xfc\x9d",
+ }, {
+ .key = "Jefe",
+ .ksize = 4,
+ .plaintext = "what do ya want for nothing?",
+ .psize = 28,
+ .digest = "\x75\x0c\x78\x3e\x6a\xb0\xb5\x03"
+ "\xea\xa8\x6e\x31\x0a\x5d\xb7\x38",
+ .np = 2,
+ .tap = {14, 14}
+ }, {
+ .key = "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa",
+ .ksize = 16,
+ .plaintext = "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
+ "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
+ "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
+ "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd",
+ .psize = 50,
+ .digest = "\x56\xbe\x34\x52\x1d\x14\x4c\x88"
+ "\xdb\xb8\xc7\x33\xf0\xe8\xb3\xf6",
+ }, {
+ .key = "\x01\x02\x03\x04\x05\x06\x07\x08"
+ "\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10"
+ "\x11\x12\x13\x14\x15\x16\x17\x18\x19",
+ .ksize = 25,
+ .plaintext = "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
+ "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
+ "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
+ "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd",
+ .psize = 50,
+ .digest = "\x69\x7e\xaf\x0a\xca\x3a\x3a\xea"
+ "\x3a\x75\x16\x47\x46\xff\xaa\x79",
+ }, {
+ .key = "\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c",
+ .ksize = 16,
+ .plaintext = "Test With Truncation",
+ .psize = 20,
+ .digest = "\x56\x46\x1e\xf2\x34\x2e\xdc\x00"
+ "\xf9\xba\xb9\x95\x69\x0e\xfd\x4c",
+#ifndef CONFIG_CRYPTO_DEV_MD5_HMAC
+ }, {
+ .key = "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa",
+ .ksize = 80,
+ .plaintext = "Test Using Larger Than Block-Size Key - Hash Key First",
+ .psize = 54,
+ .digest = "\x6b\x1a\xb7\xfe\x4b\xd7\xbf\x8f"
+ "\x0b\x62\xe6\xce\x61\xb9\xd0\xcd",
+ }, {
+ .key = "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa",
+ .ksize = 80,
+ .plaintext = "Test Using Larger Than Block-Size Key and Larger Than One "
+ "Block-Size Data",
+ .psize = 73,
+ .digest = "\x6f\x63\x0f\xad\x67\xcd\xa0\xee"
+ "\x1f\xb1\xf5\x62\xdb\x3a\xa5\x3e",
+#endif /* CONFIG_CRYPTO_DEV_MD5_HMAC */
+ },
+};
+
+/*
+ * HMAC-RIPEMD128 test vectors from RFC2286
+ */
+#define HMAC_RMD128_TEST_VECTORS 7
+
+static struct hash_testvec hmac_rmd128_tv_template[] = {
+ {
+ .key = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b",
+ .ksize = 16,
+ .plaintext = "Hi There",
+ .psize = 8,
+ .digest = "\xfb\xf6\x1f\x94\x92\xaa\x4b\xbf"
+ "\x81\xc1\x72\xe8\x4e\x07\x34\xdb",
+ }, {
+ .key = "Jefe",
+ .ksize = 4,
+ .plaintext = "what do ya want for nothing?",
+ .psize = 28,
+ .digest = "\x87\x5f\x82\x88\x62\xb6\xb3\x34"
+ "\xb4\x27\xc5\x5f\x9f\x7f\xf0\x9b",
+ .np = 2,
+ .tap = { 14, 14 },
+ }, {
+ .key = "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa",
+ .ksize = 16,
+ .plaintext = "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
+ "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
+ "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
+ "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd",
+ .psize = 50,
+ .digest = "\x09\xf0\xb2\x84\x6d\x2f\x54\x3d"
+ "\xa3\x63\xcb\xec\x8d\x62\xa3\x8d",
+ }, {
+ .key = "\x01\x02\x03\x04\x05\x06\x07\x08"
+ "\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10"
+ "\x11\x12\x13\x14\x15\x16\x17\x18\x19",
+ .ksize = 25,
+ .plaintext = "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
+ "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
+ "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
+ "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd",
+ .psize = 50,
+ .digest = "\xbd\xbb\xd7\xcf\x03\xe4\x4b\x5a"
+ "\xa6\x0a\xf8\x15\xbe\x4d\x22\x94",
+ }, {
+ .key = "\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c",
+ .ksize = 16,
+ .plaintext = "Test With Truncation",
+ .psize = 20,
+ .digest = "\xe7\x98\x08\xf2\x4b\x25\xfd\x03"
+ "\x1c\x15\x5f\x0d\x55\x1d\x9a\x3a",
+ }, {
+ .key = "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa",
+ .ksize = 80,
+ .plaintext = "Test Using Larger Than Block-Size Key - Hash Key First",
+ .psize = 54,
+ .digest = "\xdc\x73\x29\x28\xde\x98\x10\x4a"
+ "\x1f\x59\xd3\x73\xc1\x50\xac\xbb",
+ }, {
+ .key = "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa",
+ .ksize = 80,
+ .plaintext = "Test Using Larger Than Block-Size Key and Larger Than One "
+ "Block-Size Data",
+ .psize = 73,
+ .digest = "\x5c\x6b\xec\x96\x79\x3e\x16\xd4"
+ "\x06\x90\xc2\x37\x63\x5f\x30\xc5",
+ },
+};
+
+/*
+ * HMAC-RIPEMD160 test vectors from RFC2286
+ */
+#define HMAC_RMD160_TEST_VECTORS 7
+
+static struct hash_testvec hmac_rmd160_tv_template[] = {
+ {
+ .key = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b",
+ .ksize = 20,
+ .plaintext = "Hi There",
+ .psize = 8,
+ .digest = "\x24\xcb\x4b\xd6\x7d\x20\xfc\x1a\x5d\x2e"
+ "\xd7\x73\x2d\xcc\x39\x37\x7f\x0a\x56\x68",
+ }, {
+ .key = "Jefe",
+ .ksize = 4,
+ .plaintext = "what do ya want for nothing?",
+ .psize = 28,
+ .digest = "\xdd\xa6\xc0\x21\x3a\x48\x5a\x9e\x24\xf4"
+ "\x74\x20\x64\xa7\xf0\x33\xb4\x3c\x40\x69",
+ .np = 2,
+ .tap = { 14, 14 },
+ }, {
+ .key = "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa",
+ .ksize = 20,
+ .plaintext = "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
+ "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
+ "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
+ "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd",
+ .psize = 50,
+ .digest = "\xb0\xb1\x05\x36\x0d\xe7\x59\x96\x0a\xb4"
+ "\xf3\x52\x98\xe1\x16\xe2\x95\xd8\xe7\xc1",
+ }, {
+ .key = "\x01\x02\x03\x04\x05\x06\x07\x08"
+ "\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10"
+ "\x11\x12\x13\x14\x15\x16\x17\x18\x19",
+ .ksize = 25,
+ .plaintext = "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
+ "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
+ "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
+ "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd",
+ .psize = 50,
+ .digest = "\xd5\xca\x86\x2f\x4d\x21\xd5\xe6\x10\xe1"
+ "\x8b\x4c\xf1\xbe\xb9\x7a\x43\x65\xec\xf4",
+ }, {
+ .key = "\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c",
+ .ksize = 20,
+ .plaintext = "Test With Truncation",
+ .psize = 20,
+ .digest = "\x76\x19\x69\x39\x78\xf9\x1d\x90\x53\x9a"
+ "\xe7\x86\x50\x0f\xf3\xd8\xe0\x51\x8e\x39",
+ }, {
+ .key = "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa",
+ .ksize = 80,
+ .plaintext = "Test Using Larger Than Block-Size Key - Hash Key First",
+ .psize = 54,
+ .digest = "\x64\x66\xca\x07\xac\x5e\xac\x29\xe1\xbd"
+ "\x52\x3e\x5a\xda\x76\x05\xb7\x91\xfd\x8b",
+ }, {
+ .key = "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa",
+ .ksize = 80,
+ .plaintext = "Test Using Larger Than Block-Size Key and Larger Than One "
+ "Block-Size Data",
+ .psize = 73,
+ .digest = "\x69\xea\x60\x79\x8d\x71\x61\x6c\xce\x5f"
+ "\xd0\x87\x1e\x23\x75\x4c\xd7\x5d\x5a\x0a",
+ },
+};
+
+/*
+ * HMAC-SHA1 test vectors from RFC2202
+ */
+#ifndef CONFIG_CRYPTO_DEV_SHA1_HMAC
+#define HMAC_SHA1_TEST_VECTORS 7
+#else
+#define HMAC_SHA1_TEST_VECTORS 5
+#endif
+
+static struct hash_testvec hmac_sha1_tv_template[] = {
+ {
+ .key = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b",
+ .ksize = 20,
+ .plaintext = "Hi There",
+ .psize = 8,
+ .digest = "\xb6\x17\x31\x86\x55\x05\x72\x64"
+ "\xe2\x8b\xc0\xb6\xfb\x37\x8c\x8e\xf1"
+ "\x46\xbe",
+ }, {
+ .key = "Jefe",
+ .ksize = 4,
+ .plaintext = "what do ya want for nothing?",
+ .psize = 28,
+ .digest = "\xef\xfc\xdf\x6a\xe5\xeb\x2f\xa2\xd2\x74"
+ "\x16\xd5\xf1\x84\xdf\x9c\x25\x9a\x7c\x79",
+ .np = 2,
+ .tap = { 14, 14 }
+ }, {
+ .key = "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa",
+ .ksize = 20,
+ .plaintext = "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
+ "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
+ "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
+ "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd",
+ .psize = 50,
+ .digest = "\x12\x5d\x73\x42\xb9\xac\x11\xcd\x91\xa3"
+ "\x9a\xf4\x8a\xa1\x7b\x4f\x63\xf1\x75\xd3",
+ }, {
+ .key = "\x01\x02\x03\x04\x05\x06\x07\x08"
+ "\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10"
+ "\x11\x12\x13\x14\x15\x16\x17\x18\x19",
+ .ksize = 25,
+ .plaintext = "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
+ "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
+ "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
+ "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd",
+ .psize = 50,
+ .digest = "\x4c\x90\x07\xf4\x02\x62\x50\xc6\xbc\x84"
+ "\x14\xf9\xbf\x50\xc8\x6c\x2d\x72\x35\xda",
+ }, {
+ .key = "\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c",
+ .ksize = 20,
+ .plaintext = "Test With Truncation",
+ .psize = 20,
+ .digest = "\x4c\x1a\x03\x42\x4b\x55\xe0\x7f\xe7\xf2"
+ "\x7b\xe1\xd5\x8b\xb9\x32\x4a\x9a\x5a\x04",
+
+#ifndef CONFIG_CRYPTO_DEV_SHA1_HMAC
+ }, {
+ .key = "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa",
+ .ksize = 80,
+ .plaintext = "Test Using Larger Than Block-Size Key - Hash Key First",
+ .psize = 54,
+ .digest = "\xaa\x4a\xe5\xe1\x52\x72\xd0\x0e\x95\x70"
+ "\x56\x37\xce\x8a\x3b\x55\xed\x40\x21\x12",
+ }, {
+ .key = "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa",
+ .ksize = 80,
+ .plaintext = "Test Using Larger Than Block-Size Key and Larger Than One "
+ "Block-Size Data",
+ .psize = 73,
+ .digest = "\xe8\xe9\x9d\x0f\x45\x23\x7d\x78\x6d\x6b"
+ "\xba\xa7\x96\x5c\x78\x08\xbb\xff\x1a\x91",
+#endif
+ },
+};
+
+
+/*
+ * SHA224 HMAC test vectors from RFC4231
+ */
+#define HMAC_SHA224_TEST_VECTORS 4
+
+static struct hash_testvec hmac_sha224_tv_template[] = {
+ {
+ .key = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
+ "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
+ "\x0b\x0b\x0b\x0b",
+ .ksize = 20,
+ /* ("Hi There") */
+ .plaintext = "\x48\x69\x20\x54\x68\x65\x72\x65",
+ .psize = 8,
+ .digest = "\x89\x6f\xb1\x12\x8a\xbb\xdf\x19"
+ "\x68\x32\x10\x7c\xd4\x9d\xf3\x3f"
+ "\x47\xb4\xb1\x16\x99\x12\xba\x4f"
+ "\x53\x68\x4b\x22",
+ }, {
+ .key = "Jefe",
+ .ksize = 4,
+ /* ("what do ya want for nothing?") */
+ .plaintext = "\x77\x68\x61\x74\x20\x64\x6f\x20"
+ "\x79\x61\x20\x77\x61\x6e\x74\x20"
+ "\x66\x6f\x72\x20\x6e\x6f\x74\x68"
+ "\x69\x6e\x67\x3f",
+ .psize = 28,
+ .digest = "\xa3\x0e\x01\x09\x8b\xc6\xdb\xbf"
+ "\x45\x69\x0f\x3a\x7e\x9e\x6d\x0f"
+ "\x8b\xbe\xa2\xa3\x9e\x61\x48\x00"
+ "\x8f\xd0\x5e\x44",
+ .np = 4,
+ .tap = { 7, 7, 7, 7 }
+ }, {
+ .key = "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa",
+ .ksize = 131,
+ /* ("Test Using Larger Than Block-Size Key - Hash Key First") */
+ .plaintext = "\x54\x65\x73\x74\x20\x55\x73\x69"
+ "\x6e\x67\x20\x4c\x61\x72\x67\x65"
+ "\x72\x20\x54\x68\x61\x6e\x20\x42"
+ "\x6c\x6f\x63\x6b\x2d\x53\x69\x7a"
+ "\x65\x20\x4b\x65\x79\x20\x2d\x20"
+ "\x48\x61\x73\x68\x20\x4b\x65\x79"
+ "\x20\x46\x69\x72\x73\x74",
+ .psize = 54,
+ .digest = "\x95\xe9\xa0\xdb\x96\x20\x95\xad"
+ "\xae\xbe\x9b\x2d\x6f\x0d\xbc\xe2"
+ "\xd4\x99\xf1\x12\xf2\xd2\xb7\x27"
+ "\x3f\xa6\x87\x0e",
+ }, {
+ .key = "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa",
+ .ksize = 131,
+ /* ("This is a test using a larger than block-size key and a")
+ (" larger than block-size data. The key needs to be")
+ (" hashed before being used by the HMAC algorithm.") */
+ .plaintext = "\x54\x68\x69\x73\x20\x69\x73\x20"
+ "\x61\x20\x74\x65\x73\x74\x20\x75"
+ "\x73\x69\x6e\x67\x20\x61\x20\x6c"
+ "\x61\x72\x67\x65\x72\x20\x74\x68"
+ "\x61\x6e\x20\x62\x6c\x6f\x63\x6b"
+ "\x2d\x73\x69\x7a\x65\x20\x6b\x65"
+ "\x79\x20\x61\x6e\x64\x20\x61\x20"
+ "\x6c\x61\x72\x67\x65\x72\x20\x74"
+ "\x68\x61\x6e\x20\x62\x6c\x6f\x63"
+ "\x6b\x2d\x73\x69\x7a\x65\x20\x64"
+ "\x61\x74\x61\x2e\x20\x54\x68\x65"
+ "\x20\x6b\x65\x79\x20\x6e\x65\x65"
+ "\x64\x73\x20\x74\x6f\x20\x62\x65"
+ "\x20\x68\x61\x73\x68\x65\x64\x20"
+ "\x62\x65\x66\x6f\x72\x65\x20\x62"
+ "\x65\x69\x6e\x67\x20\x75\x73\x65"
+ "\x64\x20\x62\x79\x20\x74\x68\x65"
+ "\x20\x48\x4d\x41\x43\x20\x61\x6c"
+ "\x67\x6f\x72\x69\x74\x68\x6d\x2e",
+ .psize = 152,
+ .digest = "\x3a\x85\x41\x66\xac\x5d\x9f\x02"
+ "\x3f\x54\xd5\x17\xd0\xb3\x9d\xbd"
+ "\x94\x67\x70\xdb\x9c\x2b\x95\xc9"
+ "\xf6\xf5\x65\xd1",
+ },
+};
+
+/*
+ * HMAC-SHA256 test vectors from
+ * draft-ietf-ipsec-ciph-sha-256-01.txt
+ */
+#define HMAC_SHA256_TEST_VECTORS 10
+
+static struct hash_testvec hmac_sha256_tv_template[] = {
+ {
+ .key = "\x01\x02\x03\x04\x05\x06\x07\x08"
+ "\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10"
+ "\x11\x12\x13\x14\x15\x16\x17\x18"
+ "\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20",
+ .ksize = 32,
+ .plaintext = "abc",
+ .psize = 3,
+ .digest = "\xa2\x1b\x1f\x5d\x4c\xf4\xf7\x3a"
+ "\x4d\xd9\x39\x75\x0f\x7a\x06\x6a"
+ "\x7f\x98\xcc\x13\x1c\xb1\x6a\x66"
+ "\x92\x75\x90\x21\xcf\xab\x81\x81",
+ }, {
+ .key = "\x01\x02\x03\x04\x05\x06\x07\x08"
+ "\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10"
+ "\x11\x12\x13\x14\x15\x16\x17\x18"
+ "\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20",
+ .ksize = 32,
+ .plaintext = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
+ .psize = 56,
+ .digest = "\x10\x4f\xdc\x12\x57\x32\x8f\x08"
+ "\x18\x4b\xa7\x31\x31\xc5\x3c\xae"
+ "\xe6\x98\xe3\x61\x19\x42\x11\x49"
+ "\xea\x8c\x71\x24\x56\x69\x7d\x30",
+ }, {
+ .key = "\x01\x02\x03\x04\x05\x06\x07\x08"
+ "\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10"
+ "\x11\x12\x13\x14\x15\x16\x17\x18"
+ "\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20",
+ .ksize = 32,
+ .plaintext = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
+ "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
+ .psize = 112,
+ .digest = "\x47\x03\x05\xfc\x7e\x40\xfe\x34"
+ "\xd3\xee\xb3\xe7\x73\xd9\x5a\xab"
+ "\x73\xac\xf0\xfd\x06\x04\x47\xa5"
+ "\xeb\x45\x95\xbf\x33\xa9\xd1\xa3",
+ }, {
+ .key = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
+ "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
+ "\x0b\x0b\x0b\x0b\x0b\x0b",
+ .ksize = 32,
+ .plaintext = "Hi There",
+ .psize = 8,
+ .digest = "\x19\x8a\x60\x7e\xb4\x4b\xfb\xc6"
+ "\x99\x03\xa0\xf1\xcf\x2b\xbd\xc5"
+ "\xba\x0a\xa3\xf3\xd9\xae\x3c\x1c"
+ "\x7a\x3b\x16\x96\xa0\xb6\x8c\xf7",
+ }, {
+ .key = "Jefe",
+ .ksize = 4,
+ .plaintext = "what do ya want for nothing?",
+ .psize = 28,
+ .digest = "\x5b\xdc\xc1\x46\xbf\x60\x75\x4e"
+ "\x6a\x04\x24\x26\x08\x95\x75\xc7"
+ "\x5a\x00\x3f\x08\x9d\x27\x39\x83"
+ "\x9d\xec\x58\xb9\x64\xec\x38\x43",
+ .np = 2,
+ .tap = { 14, 14 }
+ }, {
+ .key = "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa",
+ .ksize = 32,
+ .plaintext = "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
+ "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
+ "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
+ "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd",
+ .psize = 50,
+ .digest = "\xcd\xcb\x12\x20\xd1\xec\xcc\xea"
+ "\x91\xe5\x3a\xba\x30\x92\xf9\x62"
+ "\xe5\x49\xfe\x6c\xe9\xed\x7f\xdc"
+ "\x43\x19\x1f\xbd\xe4\x5c\x30\xb0",
+ }, {
+ .key = "\x01\x02\x03\x04\x05\x06\x07\x08"
+ "\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10"
+ "\x11\x12\x13\x14\x15\x16\x17\x18"
+ "\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20"
+ "\x21\x22\x23\x24\x25",
+ .ksize = 37,
+ .plaintext = "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
+ "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
+ "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
+ "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd",
+ .psize = 50,
+ .digest = "\xd4\x63\x3c\x17\xf6\xfb\x8d\x74"
+ "\x4c\x66\xde\xe0\xf8\xf0\x74\x55"
+ "\x6e\xc4\xaf\x55\xef\x07\x99\x85"
+ "\x41\x46\x8e\xb4\x9b\xd2\xe9\x17",
+ }, {
+ .key = "\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c"
+ "\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c"
+ "\x0c\x0c\x0c\x0c\x0c\x0c",
+ .ksize = 32,
+ .plaintext = "Test With Truncation",
+ .psize = 20,
+ .digest = "\x75\x46\xaf\x01\x84\x1f\xc0\x9b"
+ "\x1a\xb9\xc3\x74\x9a\x5f\x1c\x17"
+ "\xd4\xf5\x89\x66\x8a\x58\x7b\x27"
+ "\x00\xa9\xc9\x7c\x11\x93\xcf\x42",
+ }, {
+ .key = "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa",
+ .ksize = 80,
+ .plaintext = "Test Using Larger Than Block-Size Key - Hash Key First",
+ .psize = 54,
+ .digest = "\x69\x53\x02\x5e\xd9\x6f\x0c\x09"
+ "\xf8\x0a\x96\xf7\x8e\x65\x38\xdb"
+ "\xe2\xe7\xb8\x20\xe3\xdd\x97\x0e"
+ "\x7d\xdd\x39\x09\x1b\x32\x35\x2f",
+ }, {
+ .key = "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa",
+ .ksize = 80,
+ .plaintext = "Test Using Larger Than Block-Size Key and Larger Than "
+ "One Block-Size Data",
+ .psize = 73,
+ .digest = "\x63\x55\xac\x22\xe8\x90\xd0\xa3"
+ "\xc8\x48\x1a\x5c\xa4\x82\x5b\xc8"
+ "\x84\xd3\xe7\xa1\xff\x98\xa2\xfc"
+ "\x2a\xc7\xd8\xe0\x64\xc3\xb2\xe6",
+ },
+};
+
+#define XCBC_AES_TEST_VECTORS 6
+
+static struct hash_testvec aes_xcbc128_tv_template[] = {
+ {
+ .key = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .plaintext = zeroed_string,
+ .digest = "\x75\xf0\x25\x1d\x52\x8a\xc0\x1c"
+ "\x45\x73\xdf\xd5\x84\xd7\x9f\x29",
+ .psize = 0,
+ .ksize = 16,
+ }, {
+ .key = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .plaintext = "\x00\x01\x02",
+ .digest = "\x5b\x37\x65\x80\xae\x2f\x19\xaf"
+ "\xe7\x21\x9c\xee\xf1\x72\x75\x6f",
+ .psize = 3,
+ .ksize = 16,
+ } , {
+ .key = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .plaintext = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .digest = "\xd2\xa2\x46\xfa\x34\x9b\x68\xa7"
+ "\x99\x98\xa4\x39\x4f\xf7\xa2\x63",
+ .psize = 16,
+ .ksize = 16,
+ }, {
+ .key = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .plaintext = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13",
+ .digest = "\x47\xf5\x1b\x45\x64\x96\x62\x15"
+ "\xb8\x98\x5c\x63\x05\x5e\xd3\x08",
+ .tap = { 10, 10 },
+ .psize = 20,
+ .np = 2,
+ .ksize = 16,
+ }, {
+ .key = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .plaintext = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
+ .digest = "\xf5\x4f\x0e\xc8\xd2\xb9\xf3\xd3"
+ "\x68\x07\x73\x4b\xd5\x28\x3f\xd4",
+ .psize = 32,
+ .ksize = 16,
+ }, {
+ .key = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .plaintext = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
+ "\x20\x21",
+ .digest = "\xbe\xcb\xb3\xbc\xcd\xb5\x18\xa3"
+ "\x06\x77\xd5\x48\x1f\xb6\xb4\xd8",
+ .tap = { 17, 17 },
+ .psize = 34,
+ .np = 2,
+ .ksize = 16,
+ }
+};
+
+#define VMAC_AES_TEST_VECTORS 1
+static char vmac_string[128] = {'\x01', '\x01', '\x01', '\x01',
+ '\x02', '\x03', '\x02', '\x02',
+ '\x02', '\x04', '\x01', '\x07',
+ '\x04', '\x01', '\x04', '\x03',};
+static struct hash_testvec aes_vmac128_tv_template[] = {
+ {
+ .key = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .plaintext = vmac_string,
+ .digest = "\xcb\xd7\x8a\xfd\xb7\x33\x79\xe7",
+ .psize = 128,
+ .ksize = 16,
+ },
+};
+
+/*
+ * SHA384 HMAC test vectors from RFC4231
+ */
+
+#define HMAC_SHA384_TEST_VECTORS 4
+
+static struct hash_testvec hmac_sha384_tv_template[] = {
+ {
+ .key = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
+ "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
+ "\x0b\x0b\x0b\x0b",
+ .ksize = 20,
+ .plaintext = "Hi There",
+ .psize = 8,
+ .digest = "\xaf\xd0\x39\x44\xd8\x48\x95\x62"
+ "\x6b\x08\x25\xf4\xab\x46\x90\x7f"
+ "\x15\xf9\xda\xdb\xe4\x10\x1e\xc6"
+ "\x82\xaa\x03\x4c\x7c\xeb\xc5\x9c"
+ "\xfa\xea\x9e\xa9\x07\x6e\xde\x7f"
+ "\x4a\xf1\x52\xe8\xb2\xfa\x9c\xb6",
+ }, {
+ .key = "Jefe",
+ .ksize = 4,
+ .plaintext = "what do ya want for nothing?",
+ .psize = 28,
+ .digest = "\xaf\x45\xd2\xe3\x76\x48\x40\x31"
+ "\x61\x7f\x78\xd2\xb5\x8a\x6b\x1b"
+ "\x9c\x7e\xf4\x64\xf5\xa0\x1b\x47"
+ "\xe4\x2e\xc3\x73\x63\x22\x44\x5e"
+ "\x8e\x22\x40\xca\x5e\x69\xe2\xc7"
+ "\x8b\x32\x39\xec\xfa\xb2\x16\x49",
+ .np = 4,
+ .tap = { 7, 7, 7, 7 }
+ }, {
+ .key = "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa",
+ .ksize = 131,
+ .plaintext = "Test Using Larger Than Block-Siz"
+ "e Key - Hash Key First",
+ .psize = 54,
+ .digest = "\x4e\xce\x08\x44\x85\x81\x3e\x90"
+ "\x88\xd2\xc6\x3a\x04\x1b\xc5\xb4"
+ "\x4f\x9e\xf1\x01\x2a\x2b\x58\x8f"
+ "\x3c\xd1\x1f\x05\x03\x3a\xc4\xc6"
+ "\x0c\x2e\xf6\xab\x40\x30\xfe\x82"
+ "\x96\x24\x8d\xf1\x63\xf4\x49\x52",
+ }, {
+ .key = "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa",
+ .ksize = 131,
+ .plaintext = "This is a test u"
+ "sing a larger th"
+ "an block-size ke"
+ "y and a larger t"
+ "han block-size d"
+ "ata. The key nee"
+ "ds to be hashed "
+ "before being use"
+ "d by the HMAC al"
+ "gorithm.",
+ .psize = 152,
+ .digest = "\x66\x17\x17\x8e\x94\x1f\x02\x0d"
+ "\x35\x1e\x2f\x25\x4e\x8f\xd3\x2c"
+ "\x60\x24\x20\xfe\xb0\xb8\xfb\x9a"
+ "\xdc\xce\xbb\x82\x46\x1e\x99\xc5"
+ "\xa6\x78\xcc\x31\xe7\x99\x17\x6d"
+ "\x38\x60\xe6\x11\x0c\x46\x52\x3e",
+ },
+};
+
+/*
+ * SHA512 HMAC test vectors from RFC4231
+ */
+
+#define HMAC_SHA512_TEST_VECTORS 4
+
+static struct hash_testvec hmac_sha512_tv_template[] = {
+ {
+ .key = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
+ "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
+ "\x0b\x0b\x0b\x0b",
+ .ksize = 20,
+ .plaintext = "Hi There",
+ .psize = 8,
+ .digest = "\x87\xaa\x7c\xde\xa5\xef\x61\x9d"
+ "\x4f\xf0\xb4\x24\x1a\x1d\x6c\xb0"
+ "\x23\x79\xf4\xe2\xce\x4e\xc2\x78"
+ "\x7a\xd0\xb3\x05\x45\xe1\x7c\xde"
+ "\xda\xa8\x33\xb7\xd6\xb8\xa7\x02"
+ "\x03\x8b\x27\x4e\xae\xa3\xf4\xe4"
+ "\xbe\x9d\x91\x4e\xeb\x61\xf1\x70"
+ "\x2e\x69\x6c\x20\x3a\x12\x68\x54",
+ }, {
+ .key = "Jefe",
+ .ksize = 4,
+ .plaintext = "what do ya want for nothing?",
+ .psize = 28,
+ .digest = "\x16\x4b\x7a\x7b\xfc\xf8\x19\xe2"
+ "\xe3\x95\xfb\xe7\x3b\x56\xe0\xa3"
+ "\x87\xbd\x64\x22\x2e\x83\x1f\xd6"
+ "\x10\x27\x0c\xd7\xea\x25\x05\x54"
+ "\x97\x58\xbf\x75\xc0\x5a\x99\x4a"
+ "\x6d\x03\x4f\x65\xf8\xf0\xe6\xfd"
+ "\xca\xea\xb1\xa3\x4d\x4a\x6b\x4b"
+ "\x63\x6e\x07\x0a\x38\xbc\xe7\x37",
+ .np = 4,
+ .tap = { 7, 7, 7, 7 }
+ }, {
+ .key = "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa",
+ .ksize = 131,
+ .plaintext = "Test Using Large"
+ "r Than Block-Siz"
+ "e Key - Hash Key"
+ " First",
+ .psize = 54,
+ .digest = "\x80\xb2\x42\x63\xc7\xc1\xa3\xeb"
+ "\xb7\x14\x93\xc1\xdd\x7b\xe8\xb4"
+ "\x9b\x46\xd1\xf4\x1b\x4a\xee\xc1"
+ "\x12\x1b\x01\x37\x83\xf8\xf3\x52"
+ "\x6b\x56\xd0\x37\xe0\x5f\x25\x98"
+ "\xbd\x0f\xd2\x21\x5d\x6a\x1e\x52"
+ "\x95\xe6\x4f\x73\xf6\x3f\x0a\xec"
+ "\x8b\x91\x5a\x98\x5d\x78\x65\x98",
+ }, {
+ .key = "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa",
+ .ksize = 131,
+ .plaintext =
+ "This is a test u"
+ "sing a larger th"
+ "an block-size ke"
+ "y and a larger t"
+ "han block-size d"
+ "ata. The key nee"
+ "ds to be hashed "
+ "before being use"
+ "d by the HMAC al"
+ "gorithm.",
+ .psize = 152,
+ .digest = "\xe3\x7b\x6a\x77\x5d\xc8\x7d\xba"
+ "\xa4\xdf\xa9\xf9\x6e\x5e\x3f\xfd"
+ "\xde\xbd\x71\xf8\x86\x72\x89\x86"
+ "\x5d\xf5\xa3\x2d\x20\xcd\xc9\x44"
+ "\xb6\x02\x2c\xac\x3c\x49\x82\xb1"
+ "\x0d\x5e\xeb\x55\xc3\xe4\xde\x15"
+ "\x13\x46\x76\xfb\x6d\xe0\x44\x60"
+ "\x65\xc9\x74\x40\xfa\x8c\x6a\x58",
+ },
+};
+
+/*
+ * DES test vectors.
+ */
+#if defined(CONFIG_CRYPTO_DEV_DES) || defined (CONFIG_CRYPTO_ASYNC_DES)
+#define DES_ENC_TEST_VECTORS 5
+#define DES_DEC_TEST_VECTORS 3
+#define DES_CBC_ENC_TEST_VECTORS 4
+#define DES_CBC_DEC_TEST_VECTORS 3
+#define DES3_EDE_ENC_TEST_VECTORS 3
+#define DES3_EDE_DEC_TEST_VECTORS 3
+#define DES3_EDE_CBC_ENC_TEST_VECTORS 1
+#define DES3_EDE_CBC_DEC_TEST_VECTORS 1
+#else
+#define DES_ENC_TEST_VECTORS 10
+#define DES_DEC_TEST_VECTORS 4
+#define DES_CBC_ENC_TEST_VECTORS 5
+#define DES_CBC_DEC_TEST_VECTORS 4
+#define DES3_EDE_ENC_TEST_VECTORS 3
+#define DES3_EDE_DEC_TEST_VECTORS 3
+#define DES3_EDE_CBC_ENC_TEST_VECTORS 1
+#define DES3_EDE_CBC_DEC_TEST_VECTORS 1
+#endif /*CONFIG_CRYPTO_DEV_DES*/
+
+static struct cipher_testvec des_enc_tv_template[] = {
+ { /* From Applied Cryptography */
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .klen = 8,
+ .input = "\x01\x23\x45\x67\x89\xab\xcd\xe7",
+ .ilen = 8,
+ .result = "\xc9\x57\x44\x25\x6a\x5e\xd3\x1d",
+ .rlen = 8,
+ }, { /* Same key, different plaintext block */
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .klen = 8,
+ .input = "\x22\x33\x44\x55\x66\x77\x88\x99",
+ .ilen = 8,
+ .result = "\xf7\x9c\x89\x2a\x33\x8f\x4a\x8b",
+ .rlen = 8,
+ }, { /* Sbox test from NBS */
+ .key = "\x7c\xa1\x10\x45\x4a\x1a\x6e\x57",
+ .klen = 8,
+ .input = "\x01\xa1\xd6\xd0\x39\x77\x67\x42",
+ .ilen = 8,
+ .result = "\x69\x0f\x5b\x0d\x9a\x26\x93\x9b",
+ .rlen = 8,
+ }, { /* Three blocks */
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .klen = 8,
+ .input = "\x01\x23\x45\x67\x89\xab\xcd\xe7"
+ "\x22\x33\x44\x55\x66\x77\x88\x99"
+ "\xca\xfe\xba\xbe\xfe\xed\xbe\xef",
+ .ilen = 24,
+ .result = "\xc9\x57\x44\x25\x6a\x5e\xd3\x1d"
+ "\xf7\x9c\x89\x2a\x33\x8f\x4a\x8b"
+ "\xb4\x99\x26\xf7\x1f\xe1\xd4\x90",
+ .rlen = 24,
+//#if !defined(CONFIG_CRYPTO_DEV_DES) && !defined(CONFIG_CRYPTO_ASYNC_DES)
+#if 0
+ }, { /* Weak key */
+ .fail = 1,
+ .wk = 1,
+ .key = "\x01\x01\x01\x01\x01\x01\x01\x01",
+ .klen = 8,
+ .input = "\x01\x23\x45\x67\x89\xab\xcd\xe7",
+ .ilen = 8,
+ .result = "\xc9\x57\x44\x25\x6a\x5e\xd3\x1d",
+ .rlen = 8,
+#endif
+ }, { /* Two blocks -- for testing encryption across pages */
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .klen = 8,
+ .input = "\x01\x23\x45\x67\x89\xab\xcd\xe7"
+ "\x22\x33\x44\x55\x66\x77\x88\x99",
+ .ilen = 16,
+ .result = "\xc9\x57\x44\x25\x6a\x5e\xd3\x1d"
+ "\xf7\x9c\x89\x2a\x33\x8f\x4a\x8b",
+ .rlen = 16,
+ .np = 2,
+ .tap = { 8, 8 }
+//#if !defined(CONFIG_CRYPTO_DEV_DES) && !defined(CONFIG_CRYPTO_ASYNC_DES)
+#if 0
+ }, { /* Four blocks -- for testing encryption with chunking */
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .klen = 8,
+ .input = "\x01\x23\x45\x67\x89\xab\xcd\xe7"
+ "\x22\x33\x44\x55\x66\x77\x88\x99"
+ "\xca\xfe\xba\xbe\xfe\xed\xbe\xef"
+ "\x22\x33\x44\x55\x66\x77\x88\x99",
+ .ilen = 32,
+ .result = "\xc9\x57\x44\x25\x6a\x5e\xd3\x1d"
+ "\xf7\x9c\x89\x2a\x33\x8f\x4a\x8b"
+ "\xb4\x99\x26\xf7\x1f\xe1\xd4\x90"
+ "\xf7\x9c\x89\x2a\x33\x8f\x4a\x8b",
+ .rlen = 32,
+ .np = 3,
+ .tap = { 14, 10, 8 }
+ }, {
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .klen = 8,
+ .input = "\x01\x23\x45\x67\x89\xab\xcd\xe7"
+ "\x22\x33\x44\x55\x66\x77\x88\x99"
+ "\xca\xfe\xba\xbe\xfe\xed\xbe\xef",
+ .ilen = 24,
+ .result = "\xc9\x57\x44\x25\x6a\x5e\xd3\x1d"
+ "\xf7\x9c\x89\x2a\x33\x8f\x4a\x8b"
+ "\xb4\x99\x26\xf7\x1f\xe1\xd4\x90",
+ .rlen = 24,
+ .np = 4,
+ .tap = { 2, 1, 3, 18 }
+ }, {
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .klen = 8,
+ .input = "\x01\x23\x45\x67\x89\xab\xcd\xe7"
+ "\x22\x33\x44\x55\x66\x77\x88\x99",
+ .ilen = 16,
+ .result = "\xc9\x57\x44\x25\x6a\x5e\xd3\x1d"
+ "\xf7\x9c\x89\x2a\x33\x8f\x4a\x8b",
+ .rlen = 16,
+ .np = 5,
+ .tap = { 2, 2, 2, 2, 8 }
+ }, {
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .klen = 8,
+ .input = "\x01\x23\x45\x67\x89\xab\xcd\xe7",
+ .ilen = 8,
+ .result = "\xc9\x57\x44\x25\x6a\x5e\xd3\x1d",
+ .rlen = 8,
+ .np = 8,
+ .tap = { 1, 1, 1, 1, 1, 1, 1, 1 }
+#endif
+ },
+};
+
+static struct cipher_testvec des_dec_tv_template[] = {
+ { /* From Applied Cryptography */
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .klen = 8,
+ .input = "\xc9\x57\x44\x25\x6a\x5e\xd3\x1d",
+ .ilen = 8,
+ .result = "\x01\x23\x45\x67\x89\xab\xcd\xe7",
+ .rlen = 8,
+ }, { /* Sbox test from NBS */
+ .key = "\x7c\xa1\x10\x45\x4a\x1a\x6e\x57",
+ .klen = 8,
+ .input = "\x69\x0f\x5b\x0d\x9a\x26\x93\x9b",
+ .ilen = 8,
+ .result = "\x01\xa1\xd6\xd0\x39\x77\x67\x42",
+ .rlen = 8,
+ }, { /* Two blocks, for chunking test */
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .klen = 8,
+ .input = "\xc9\x57\x44\x25\x6a\x5e\xd3\x1d"
+ "\x69\x0f\x5b\x0d\x9a\x26\x93\x9b",
+ .ilen = 16,
+ .result = "\x01\x23\x45\x67\x89\xab\xcd\xe7"
+ "\xa3\x99\x7b\xca\xaf\x69\xa0\xf5",
+ .rlen = 16,
+ .np = 2,
+ .tap = { 8, 8 }
+ }, {
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .klen = 8,
+ .input = "\xc9\x57\x44\x25\x6a\x5e\xd3\x1d"
+ "\x69\x0f\x5b\x0d\x9a\x26\x93\x9b",
+ .ilen = 16,
+ .result = "\x01\x23\x45\x67\x89\xab\xcd\xe7"
+ "\xa3\x99\x7b\xca\xaf\x69\xa0\xf5",
+ .rlen = 16,
+ .np = 3,
+ .tap = { 3, 12, 1 }
+ },
+};
+
+static struct cipher_testvec des_cbc_enc_tv_template[] = {
+ { /* From OpenSSL */
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .klen = 8,
+ .iv = "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .input = "\x37\x36\x35\x34\x33\x32\x31\x20"
+ "\x4e\x6f\x77\x20\x69\x73\x20\x74"
+ "\x68\x65\x20\x74\x69\x6d\x65\x20",
+ .ilen = 24,
+ .result = "\xcc\xd1\x73\xff\xab\x20\x39\xf4"
+ "\xac\xd8\xae\xfd\xdf\xd8\xa1\xeb"
+ "\x46\x8e\x91\x15\x78\x88\xba\x68",
+ .rlen = 24,
+ }, { /* FIPS Pub 81 */
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .klen = 8,
+ .iv = "\x12\x34\x56\x78\x90\xab\xcd\xef",
+ .input = "\x4e\x6f\x77\x20\x69\x73\x20\x74",
+ .ilen = 8,
+ .result = "\xe5\xc7\xcd\xde\x87\x2b\xf2\x7c",
+ .rlen = 8,
+ }, {
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .klen = 8,
+ .iv = "\xe5\xc7\xcd\xde\x87\x2b\xf2\x7c",
+ .input = "\x68\x65\x20\x74\x69\x6d\x65\x20",
+ .ilen = 8,
+ .result = "\x43\xe9\x34\x00\x8c\x38\x9c\x0f",
+ .rlen = 8,
+ }, {
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .klen = 8,
+ .iv = "\x43\xe9\x34\x00\x8c\x38\x9c\x0f",
+ .input = "\x66\x6f\x72\x20\x61\x6c\x6c\x20",
+ .ilen = 8,
+ .result = "\x68\x37\x88\x49\x9a\x7c\x05\xf6",
+ .rlen = 8,
+#if 0
+ }, { /* Copy of openssl vector for chunk testing */
+ /* From OpenSSL */
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .klen = 8,
+ .iv = "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .input = "\x37\x36\x35\x34\x33\x32\x31\x20"
+ "\x4e\x6f\x77\x20\x69\x73\x20\x74"
+ "\x68\x65\x20\x74\x69\x6d\x65\x20",
+ .ilen = 24,
+ .result = "\xcc\xd1\x73\xff\xab\x20\x39\xf4"
+ "\xac\xd8\xae\xfd\xdf\xd8\xa1\xeb"
+ "\x46\x8e\x91\x15\x78\x88\xba\x68",
+ .rlen = 24,
+ .np = 2,
+ .tap = { 13, 11 }
+#endif
+ },
+};
+
+static struct cipher_testvec des_cbc_dec_tv_template[] = {
+ { /* FIPS Pub 81 */
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .klen = 8,
+ .iv = "\x12\x34\x56\x78\x90\xab\xcd\xef",
+ .input = "\xe5\xc7\xcd\xde\x87\x2b\xf2\x7c",
+ .ilen = 8,
+ .result = "\x4e\x6f\x77\x20\x69\x73\x20\x74",
+ .rlen = 8,
+ }, {
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .klen = 8,
+ .iv = "\xe5\xc7\xcd\xde\x87\x2b\xf2\x7c",
+ .input = "\x43\xe9\x34\x00\x8c\x38\x9c\x0f",
+ .ilen = 8,
+ .result = "\x68\x65\x20\x74\x69\x6d\x65\x20",
+ .rlen = 8,
+ }, {
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .klen = 8,
+ .iv = "\x43\xe9\x34\x00\x8c\x38\x9c\x0f",
+ .input = "\x68\x37\x88\x49\x9a\x7c\x05\xf6",
+ .ilen = 8,
+ .result = "\x66\x6f\x72\x20\x61\x6c\x6c\x20",
+ .rlen = 8,
+ }, { /* Copy of above, for chunk testing */
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .klen = 8,
+ .iv = "\x43\xe9\x34\x00\x8c\x38\x9c\x0f",
+ .input = "\x68\x37\x88\x49\x9a\x7c\x05\xf6",
+ .ilen = 8,
+ .result = "\x66\x6f\x72\x20\x61\x6c\x6c\x20",
+ .rlen = 8,
+ .np = 2,
+ .tap = { 4, 4 }
+ },
+};
+
+static struct cipher_testvec des3_ede_enc_tv_template[] = {
+ { /* These are from openssl */
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef"
+ "\x55\x55\x55\x55\x55\x55\x55\x55"
+ "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .klen = 24,
+ .input = "\x73\x6f\x6d\x65\x64\x61\x74\x61",
+ .ilen = 8,
+ .result = "\x18\xd7\x48\xe5\x63\x62\x05\x72",
+ .rlen = 8,
+ }, {
+ .key = "\x03\x52\x02\x07\x67\x20\x82\x17"
+ "\x86\x02\x87\x66\x59\x08\x21\x98"
+ "\x64\x05\x6a\xbd\xfe\xa9\x34\x57",
+ .klen = 24,
+ .input = "\x73\x71\x75\x69\x67\x67\x6c\x65",
+ .ilen = 8,
+ .result = "\xc0\x7d\x2a\x0f\xa5\x66\xfa\x30",
+ .rlen = 8,
+ }, {
+ .key = "\x10\x46\x10\x34\x89\x98\x80\x20"
+ "\x91\x07\xd0\x15\x89\x19\x01\x01"
+ "\x19\x07\x92\x10\x98\x1a\x01\x01",
+ .klen = 24,
+ .input = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .ilen = 8,
+ .result = "\xe1\xef\x62\xc3\x32\xfe\x82\x5b",
+ .rlen = 8,
+ },
+};
+
+static struct cipher_testvec des3_ede_dec_tv_template[] = {
+ { /* These are from openssl */
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef"
+ "\x55\x55\x55\x55\x55\x55\x55\x55"
+ "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .klen = 24,
+ .input = "\x18\xd7\x48\xe5\x63\x62\x05\x72",
+ .ilen = 8,
+ .result = "\x73\x6f\x6d\x65\x64\x61\x74\x61",
+ .rlen = 8,
+ }, {
+ .key = "\x03\x52\x02\x07\x67\x20\x82\x17"
+ "\x86\x02\x87\x66\x59\x08\x21\x98"
+ "\x64\x05\x6a\xbd\xfe\xa9\x34\x57",
+ .klen = 24,
+ .input = "\xc0\x7d\x2a\x0f\xa5\x66\xfa\x30",
+ .ilen = 8,
+ .result = "\x73\x71\x75\x69\x67\x67\x6c\x65",
+ .rlen = 8,
+ }, {
+ .key = "\x10\x46\x10\x34\x89\x98\x80\x20"
+ "\x91\x07\xd0\x15\x89\x19\x01\x01"
+ "\x19\x07\x92\x10\x98\x1a\x01\x01",
+ .klen = 24,
+ .input = "\xe1\xef\x62\xc3\x32\xfe\x82\x5b",
+ .ilen = 8,
+ .result = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .rlen = 8,
+ },
+};
+
+static struct cipher_testvec des3_ede_cbc_enc_tv_template[] = {
+ { /* Generated from openssl */
+ .key = "\xE9\xC0\xFF\x2E\x76\x0B\x64\x24"
+ "\x44\x4D\x99\x5A\x12\xD6\x40\xC0"
+ "\xEA\xC2\x84\xE8\x14\x95\xDB\xE8",
+ .klen = 24,
+ .iv = "\x7D\x33\x88\x93\x0F\x93\xB2\x42",
+ .input = "\x6f\x54\x20\x6f\x61\x4d\x79\x6e"
+ "\x53\x20\x63\x65\x65\x72\x73\x74"
+ "\x54\x20\x6f\x6f\x4d\x20\x6e\x61"
+ "\x20\x79\x65\x53\x72\x63\x74\x65"
+ "\x20\x73\x6f\x54\x20\x6f\x61\x4d"
+ "\x79\x6e\x53\x20\x63\x65\x65\x72"
+ "\x73\x74\x54\x20\x6f\x6f\x4d\x20"
+ "\x6e\x61\x20\x79\x65\x53\x72\x63"
+ "\x74\x65\x20\x73\x6f\x54\x20\x6f"
+ "\x61\x4d\x79\x6e\x53\x20\x63\x65"
+ "\x65\x72\x73\x74\x54\x20\x6f\x6f"
+ "\x4d\x20\x6e\x61\x20\x79\x65\x53"
+ "\x72\x63\x74\x65\x20\x73\x6f\x54"
+ "\x20\x6f\x61\x4d\x79\x6e\x53\x20"
+ "\x63\x65\x65\x72\x73\x74\x54\x20"
+ "\x6f\x6f\x4d\x20\x6e\x61\x0a\x79",
+ .ilen = 128,
+ .result = "\x0e\x2d\xb6\x97\x3c\x56\x33\xf4"
+ "\x67\x17\x21\xc7\x6e\x8a\xd5\x49"
+ "\x74\xb3\x49\x05\xc5\x1c\xd0\xed"
+ "\x12\x56\x5c\x53\x96\xb6\x00\x7d"
+ "\x90\x48\xfc\xf5\x8d\x29\x39\xcc"
+ "\x8a\xd5\x35\x18\x36\x23\x4e\xd7"
+ "\x76\xd1\xda\x0c\x94\x67\xbb\x04"
+ "\x8b\xf2\x03\x6c\xa8\xcf\xb6\xea"
+ "\x22\x64\x47\xaa\x8f\x75\x13\xbf"
+ "\x9f\xc2\xc3\xf0\xc9\x56\xc5\x7a"
+ "\x71\x63\x2e\x89\x7b\x1e\x12\xca"
+ "\xe2\x5f\xaf\xd8\xa4\xf8\xc9\x7a"
+ "\xd6\xf9\x21\x31\x62\x44\x45\xa6"
+ "\xd6\xbc\x5a\xd3\x2d\x54\x43\xcc"
+ "\x9d\xde\xa5\x70\xe9\x42\x45\x8a"
+ "\x6b\xfa\xb1\x91\x13\xb0\xd9\x19",
+ .rlen = 128,
+ },
+};
+
+static struct cipher_testvec des3_ede_cbc_dec_tv_template[] = {
+ { /* Generated from openssl */
+ .key = "\xE9\xC0\xFF\x2E\x76\x0B\x64\x24"
+ "\x44\x4D\x99\x5A\x12\xD6\x40\xC0"
+ "\xEA\xC2\x84\xE8\x14\x95\xDB\xE8",
+ .klen = 24,
+ .iv = "\x7D\x33\x88\x93\x0F\x93\xB2\x42",
+ .input = "\x0e\x2d\xb6\x97\x3c\x56\x33\xf4"
+ "\x67\x17\x21\xc7\x6e\x8a\xd5\x49"
+ "\x74\xb3\x49\x05\xc5\x1c\xd0\xed"
+ "\x12\x56\x5c\x53\x96\xb6\x00\x7d"
+ "\x90\x48\xfc\xf5\x8d\x29\x39\xcc"
+ "\x8a\xd5\x35\x18\x36\x23\x4e\xd7"
+ "\x76\xd1\xda\x0c\x94\x67\xbb\x04"
+ "\x8b\xf2\x03\x6c\xa8\xcf\xb6\xea"
+ "\x22\x64\x47\xaa\x8f\x75\x13\xbf"
+ "\x9f\xc2\xc3\xf0\xc9\x56\xc5\x7a"
+ "\x71\x63\x2e\x89\x7b\x1e\x12\xca"
+ "\xe2\x5f\xaf\xd8\xa4\xf8\xc9\x7a"
+ "\xd6\xf9\x21\x31\x62\x44\x45\xa6"
+ "\xd6\xbc\x5a\xd3\x2d\x54\x43\xcc"
+ "\x9d\xde\xa5\x70\xe9\x42\x45\x8a"
+ "\x6b\xfa\xb1\x91\x13\xb0\xd9\x19",
+ .ilen = 128,
+ .result = "\x6f\x54\x20\x6f\x61\x4d\x79\x6e"
+ "\x53\x20\x63\x65\x65\x72\x73\x74"
+ "\x54\x20\x6f\x6f\x4d\x20\x6e\x61"
+ "\x20\x79\x65\x53\x72\x63\x74\x65"
+ "\x20\x73\x6f\x54\x20\x6f\x61\x4d"
+ "\x79\x6e\x53\x20\x63\x65\x65\x72"
+ "\x73\x74\x54\x20\x6f\x6f\x4d\x20"
+ "\x6e\x61\x20\x79\x65\x53\x72\x63"
+ "\x74\x65\x20\x73\x6f\x54\x20\x6f"
+ "\x61\x4d\x79\x6e\x53\x20\x63\x65"
+ "\x65\x72\x73\x74\x54\x20\x6f\x6f"
+ "\x4d\x20\x6e\x61\x20\x79\x65\x53"
+ "\x72\x63\x74\x65\x20\x73\x6f\x54"
+ "\x20\x6f\x61\x4d\x79\x6e\x53\x20"
+ "\x63\x65\x65\x72\x73\x74\x54\x20"
+ "\x6f\x6f\x4d\x20\x6e\x61\x0a\x79",
+ .rlen = 128,
+ },
+};
+
+/*
+ * Blowfish test vectors.
+ */
+#define BF_ENC_TEST_VECTORS 6
+#define BF_DEC_TEST_VECTORS 6
+#define BF_CBC_ENC_TEST_VECTORS 1
+#define BF_CBC_DEC_TEST_VECTORS 1
+
+static struct cipher_testvec bf_enc_tv_template[] = {
+ { /* DES test vectors from OpenSSL */
+ .key = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .klen = 8,
+ .input = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .ilen = 8,
+ .result = "\x4e\xf9\x97\x45\x61\x98\xdd\x78",
+ .rlen = 8,
+ }, {
+ .key = "\x1f\x1f\x1f\x1f\x0e\x0e\x0e\x0e",
+ .klen = 8,
+ .input = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .ilen = 8,
+ .result = "\xa7\x90\x79\x51\x08\xea\x3c\xae",
+ .rlen = 8,
+ }, {
+ .key = "\xf0\xe1\xd2\xc3\xb4\xa5\x96\x87",
+ .klen = 8,
+ .input = "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .ilen = 8,
+ .result = "\xe8\x7a\x24\x4e\x2c\xc8\x5e\x82",
+ .rlen = 8,
+ }, { /* Vary the keylength... */
+ .key = "\xf0\xe1\xd2\xc3\xb4\xa5\x96\x87"
+ "\x78\x69\x5a\x4b\x3c\x2d\x1e\x0f",
+ .klen = 16,
+ .input = "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .ilen = 8,
+ .result = "\x93\x14\x28\x87\xee\x3b\xe1\x5c",
+ .rlen = 8,
+ }, {
+ .key = "\xf0\xe1\xd2\xc3\xb4\xa5\x96\x87"
+ "\x78\x69\x5a\x4b\x3c\x2d\x1e\x0f"
+ "\x00\x11\x22\x33\x44",
+ .klen = 21,
+ .input = "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .ilen = 8,
+ .result = "\xe6\xf5\x1e\xd7\x9b\x9d\xb2\x1f",
+ .rlen = 8,
+ }, { /* Generated with bf488 */
+ .key = "\xf0\xe1\xd2\xc3\xb4\xa5\x96\x87"
+ "\x78\x69\x5a\x4b\x3c\x2d\x1e\x0f"
+ "\x00\x11\x22\x33\x44\x55\x66\x77"
+ "\x04\x68\x91\x04\xc2\xfd\x3b\x2f"
+ "\x58\x40\x23\x64\x1a\xba\x61\x76"
+ "\x1f\x1f\x1f\x1f\x0e\x0e\x0e\x0e"
+ "\xff\xff\xff\xff\xff\xff\xff\xff",
+ .klen = 56,
+ .input = "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .ilen = 8,
+ .result = "\xc0\x45\x04\x01\x2e\x4e\x1f\x53",
+ .rlen = 8,
+ },
+};
+
+static struct cipher_testvec bf_dec_tv_template[] = {
+ { /* DES test vectors from OpenSSL */
+ .key = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .klen = 8,
+ .input = "\x4e\xf9\x97\x45\x61\x98\xdd\x78",
+ .ilen = 8,
+ .result = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .rlen = 8,
+ }, {
+ .key = "\x1f\x1f\x1f\x1f\x0e\x0e\x0e\x0e",
+ .klen = 8,
+ .input = "\xa7\x90\x79\x51\x08\xea\x3c\xae",
+ .ilen = 8,
+ .result = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .rlen = 8,
+ }, {
+ .key = "\xf0\xe1\xd2\xc3\xb4\xa5\x96\x87",
+ .klen = 8,
+ .input = "\xe8\x7a\x24\x4e\x2c\xc8\x5e\x82",
+ .ilen = 8,
+ .result = "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .rlen = 8,
+ }, { /* Vary the keylength... */
+ .key = "\xf0\xe1\xd2\xc3\xb4\xa5\x96\x87"
+ "\x78\x69\x5a\x4b\x3c\x2d\x1e\x0f",
+ .klen = 16,
+ .input = "\x93\x14\x28\x87\xee\x3b\xe1\x5c",
+ .ilen = 8,
+ .result = "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .rlen = 8,
+ }, {
+ .key = "\xf0\xe1\xd2\xc3\xb4\xa5\x96\x87"
+ "\x78\x69\x5a\x4b\x3c\x2d\x1e\x0f"
+ "\x00\x11\x22\x33\x44",
+ .klen = 21,
+ .input = "\xe6\xf5\x1e\xd7\x9b\x9d\xb2\x1f",
+ .ilen = 8,
+ .result = "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .rlen = 8,
+ }, { /* Generated with bf488, using OpenSSL, Libgcrypt and Nettle */
+ .key = "\xf0\xe1\xd2\xc3\xb4\xa5\x96\x87"
+ "\x78\x69\x5a\x4b\x3c\x2d\x1e\x0f"
+ "\x00\x11\x22\x33\x44\x55\x66\x77"
+ "\x04\x68\x91\x04\xc2\xfd\x3b\x2f"
+ "\x58\x40\x23\x64\x1a\xba\x61\x76"
+ "\x1f\x1f\x1f\x1f\x0e\x0e\x0e\x0e"
+ "\xff\xff\xff\xff\xff\xff\xff\xff",
+ .klen = 56,
+ .input = "\xc0\x45\x04\x01\x2e\x4e\x1f\x53",
+ .ilen = 8,
+ .result = "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .rlen = 8,
+ },
+};
+
+static struct cipher_testvec bf_cbc_enc_tv_template[] = {
+ { /* From OpenSSL */
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef"
+ "\xf0\xe1\xd2\xc3\xb4\xa5\x96\x87",
+ .klen = 16,
+ .iv = "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .input = "\x37\x36\x35\x34\x33\x32\x31\x20"
+ "\x4e\x6f\x77\x20\x69\x73\x20\x74"
+ "\x68\x65\x20\x74\x69\x6d\x65\x20"
+ "\x66\x6f\x72\x20\x00\x00\x00\x00",
+ .ilen = 32,
+ .result = "\x6b\x77\xb4\xd6\x30\x06\xde\xe6"
+ "\x05\xb1\x56\xe2\x74\x03\x97\x93"
+ "\x58\xde\xb9\xe7\x15\x46\x16\xd9"
+ "\x59\xf1\x65\x2b\xd5\xff\x92\xcc",
+ .rlen = 32,
+ },
+};
+
+static struct cipher_testvec bf_cbc_dec_tv_template[] = {
+ { /* From OpenSSL */
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef"
+ "\xf0\xe1\xd2\xc3\xb4\xa5\x96\x87",
+ .klen = 16,
+ .iv = "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .input = "\x6b\x77\xb4\xd6\x30\x06\xde\xe6"
+ "\x05\xb1\x56\xe2\x74\x03\x97\x93"
+ "\x58\xde\xb9\xe7\x15\x46\x16\xd9"
+ "\x59\xf1\x65\x2b\xd5\xff\x92\xcc",
+ .ilen = 32,
+ .result = "\x37\x36\x35\x34\x33\x32\x31\x20"
+ "\x4e\x6f\x77\x20\x69\x73\x20\x74"
+ "\x68\x65\x20\x74\x69\x6d\x65\x20"
+ "\x66\x6f\x72\x20\x00\x00\x00\x00",
+ .rlen = 32,
+ },
+};
+
+/*
+ * Twofish test vectors.
+ */
+#define TF_ENC_TEST_VECTORS 3
+#define TF_DEC_TEST_VECTORS 3
+#define TF_CBC_ENC_TEST_VECTORS 4
+#define TF_CBC_DEC_TEST_VECTORS 4
+
+static struct cipher_testvec tf_enc_tv_template[] = {
+ {
+ .key = zeroed_string,
+ .klen = 16,
+ .input = zeroed_string,
+ .ilen = 16,
+ .result = "\x9f\x58\x9f\x5c\xf6\x12\x2c\x32"
+ "\xb6\xbf\xec\x2f\x2a\xe8\xc3\x5a",
+ .rlen = 16,
+ }, {
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef"
+ "\xfe\xdc\xba\x98\x76\x54\x32\x10"
+ "\x00\x11\x22\x33\x44\x55\x66\x77",
+ .klen = 24,
+ .input = zeroed_string,
+ .ilen = 16,
+ .result = "\xcf\xd1\xd2\xe5\xa9\xbe\x9c\xdf"
+ "\x50\x1f\x13\xb8\x92\xbd\x22\x48",
+ .rlen = 16,
+ }, {
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef"
+ "\xfe\xdc\xba\x98\x76\x54\x32\x10"
+ "\x00\x11\x22\x33\x44\x55\x66\x77"
+ "\x88\x99\xaa\xbb\xcc\xdd\xee\xff",
+ .klen = 32,
+ .input = zeroed_string,
+ .ilen = 16,
+ .result = "\x37\x52\x7b\xe0\x05\x23\x34\xb8"
+ "\x9f\x0c\xfc\xca\xe8\x7c\xfa\x20",
+ .rlen = 16,
+ },
+};
+
+static struct cipher_testvec tf_dec_tv_template[] = {
+ {
+ .key = zeroed_string,
+ .klen = 16,
+ .input = "\x9f\x58\x9f\x5c\xf6\x12\x2c\x32"
+ "\xb6\xbf\xec\x2f\x2a\xe8\xc3\x5a",
+ .ilen = 16,
+ .result = zeroed_string,
+ .rlen = 16,
+ }, {
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef"
+ "\xfe\xdc\xba\x98\x76\x54\x32\x10"
+ "\x00\x11\x22\x33\x44\x55\x66\x77",
+ .klen = 24,
+ .input = "\xcf\xd1\xd2\xe5\xa9\xbe\x9c\xdf"
+ "\x50\x1f\x13\xb8\x92\xbd\x22\x48",
+ .ilen = 16,
+ .result = zeroed_string,
+ .rlen = 16,
+ }, {
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef"
+ "\xfe\xdc\xba\x98\x76\x54\x32\x10"
+ "\x00\x11\x22\x33\x44\x55\x66\x77"
+ "\x88\x99\xaa\xbb\xcc\xdd\xee\xff",
+ .klen = 32,
+ .input = "\x37\x52\x7b\xe0\x05\x23\x34\xb8"
+ "\x9f\x0c\xfc\xca\xe8\x7c\xfa\x20",
+ .ilen = 16,
+ .result = zeroed_string,
+ .rlen = 16,
+ },
+};
+
+static struct cipher_testvec tf_cbc_enc_tv_template[] = {
+ { /* Generated with Nettle */
+ .key = zeroed_string,
+ .klen = 16,
+ .iv = zeroed_string,
+ .input = zeroed_string,
+ .ilen = 16,
+ .result = "\x9f\x58\x9f\x5c\xf6\x12\x2c\x32"
+ "\xb6\xbf\xec\x2f\x2a\xe8\xc3\x5a",
+ .rlen = 16,
+ }, {
+ .key = zeroed_string,
+ .klen = 16,
+ .iv = "\x9f\x58\x9f\x5c\xf6\x12\x2c\x32"
+ "\xb6\xbf\xec\x2f\x2a\xe8\xc3\x5a",
+ .input = zeroed_string,
+ .ilen = 16,
+ .result = "\xd4\x91\xdb\x16\xe7\xb1\xc3\x9e"
+ "\x86\xcb\x08\x6b\x78\x9f\x54\x19",
+ .rlen = 16,
+ }, {
+ .key = zeroed_string,
+ .klen = 16,
+ .iv = "\xd4\x91\xdb\x16\xe7\xb1\xc3\x9e"
+ "\x86\xcb\x08\x6b\x78\x9f\x54\x19",
+ .input = zeroed_string,
+ .ilen = 16,
+ .result = "\x05\xef\x8c\x61\xa8\x11\x58\x26"
+ "\x34\xba\x5c\xb7\x10\x6a\xa6\x41",
+ .rlen = 16,
+ }, {
+ .key = zeroed_string,
+ .klen = 16,
+ .iv = zeroed_string,
+ .input = zeroed_string,
+ .ilen = 48,
+ .result = "\x9f\x58\x9f\x5c\xf6\x12\x2c\x32"
+ "\xb6\xbf\xec\x2f\x2a\xe8\xc3\x5a"
+ "\xd4\x91\xdb\x16\xe7\xb1\xc3\x9e"
+ "\x86\xcb\x08\x6b\x78\x9f\x54\x19"
+ "\x05\xef\x8c\x61\xa8\x11\x58\x26"
+ "\x34\xba\x5c\xb7\x10\x6a\xa6\x41",
+ .rlen = 48,
+ },
+};
+
+static struct cipher_testvec tf_cbc_dec_tv_template[] = {
+ { /* Reverse of the first four above */
+ .key = zeroed_string,
+ .klen = 16,
+ .iv = zeroed_string,
+ .input = "\x9f\x58\x9f\x5c\xf6\x12\x2c\x32"
+ "\xb6\xbf\xec\x2f\x2a\xe8\xc3\x5a",
+ .ilen = 16,
+ .result = zeroed_string,
+ .rlen = 16,
+ }, {
+ .key = zeroed_string,
+ .klen = 16,
+ .iv = "\x9f\x58\x9f\x5c\xf6\x12\x2c\x32"
+ "\xb6\xbf\xec\x2f\x2a\xe8\xc3\x5a",
+ .input = "\xd4\x91\xdb\x16\xe7\xb1\xc3\x9e"
+ "\x86\xcb\x08\x6b\x78\x9f\x54\x19",
+ .ilen = 16,
+ .result = zeroed_string,
+ .rlen = 16,
+ }, {
+ .key = zeroed_string,
+ .klen = 16,
+ .iv = "\xd4\x91\xdb\x16\xe7\xb1\xc3\x9e"
+ "\x86\xcb\x08\x6b\x78\x9f\x54\x19",
+ .input = "\x05\xef\x8c\x61\xa8\x11\x58\x26"
+ "\x34\xba\x5c\xb7\x10\x6a\xa6\x41",
+ .ilen = 16,
+ .result = zeroed_string,
+ .rlen = 16,
+ }, {
+ .key = zeroed_string,
+ .klen = 16,
+ .iv = zeroed_string,
+ .input = "\x9f\x58\x9f\x5c\xf6\x12\x2c\x32"
+ "\xb6\xbf\xec\x2f\x2a\xe8\xc3\x5a"
+ "\xd4\x91\xdb\x16\xe7\xb1\xc3\x9e"
+ "\x86\xcb\x08\x6b\x78\x9f\x54\x19"
+ "\x05\xef\x8c\x61\xa8\x11\x58\x26"
+ "\x34\xba\x5c\xb7\x10\x6a\xa6\x41",
+ .ilen = 48,
+ .result = zeroed_string,
+ .rlen = 48,
+ },
+};
+
+/*
+ * Serpent test vectors. These are backwards because Serpent writes
+ * octet sequences in right-to-left mode.
+ */
+#define SERPENT_ENC_TEST_VECTORS 4
+#define SERPENT_DEC_TEST_VECTORS 4
+
+#define TNEPRES_ENC_TEST_VECTORS 4
+#define TNEPRES_DEC_TEST_VECTORS 4
+
+static struct cipher_testvec serpent_enc_tv_template[] = {
+ {
+ .input = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .ilen = 16,
+ .result = "\x12\x07\xfc\xce\x9b\xd0\xd6\x47"
+ "\x6a\xe9\x8f\xbe\xd1\x43\xa0\xe2",
+ .rlen = 16,
+ }, {
+ .key = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .klen = 16,
+ .input = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .ilen = 16,
+ .result = "\x4c\x7d\x8a\x32\x80\x72\xa2\x2c"
+ "\x82\x3e\x4a\x1f\x3a\xcd\xa1\x6d",
+ .rlen = 16,
+ }, {
+ .key = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
+ .klen = 32,
+ .input = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .ilen = 16,
+ .result = "\xde\x26\x9f\xf8\x33\xe4\x32\xb8"
+ "\x5b\x2e\x88\xd2\x70\x1c\xe7\x5c",
+ .rlen = 16,
+ }, {
+ .key = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80",
+ .klen = 16,
+ .input = zeroed_string,
+ .ilen = 16,
+ .result = "\xdd\xd2\x6b\x98\xa5\xff\xd8\x2c"
+ "\x05\x34\x5a\x9d\xad\xbf\xaf\x49",
+ .rlen = 16,
+ },
+};
+
+static struct cipher_testvec tnepres_enc_tv_template[] = {
+ { /* KeySize=128, PT=0, I=1 */
+ .input = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .key = "\x80\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .klen = 16,
+ .ilen = 16,
+ .result = "\x49\xaf\xbf\xad\x9d\x5a\x34\x05"
+ "\x2c\xd8\xff\xa5\x98\x6b\xd2\xdd",
+ .rlen = 16,
+ }, { /* KeySize=192, PT=0, I=1 */
+ .key = "\x80\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .klen = 24,
+ .input = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .ilen = 16,
+ .result = "\xe7\x8e\x54\x02\xc7\x19\x55\x68"
+ "\xac\x36\x78\xf7\xa3\xf6\x0c\x66",
+ .rlen = 16,
+ }, { /* KeySize=256, PT=0, I=1 */
+ .key = "\x80\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .klen = 32,
+ .input = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .ilen = 16,
+ .result = "\xab\xed\x96\xe7\x66\xbf\x28\xcb"
+ "\xc0\xeb\xd2\x1a\x82\xef\x08\x19",
+ .rlen = 16,
+ }, { /* KeySize=256, I=257 */
+ .key = "\x1f\x1e\x1d\x1c\x1b\x1a\x19\x18"
+ "\x17\x16\x15\x14\x13\x12\x11\x10"
+ "\x0f\x0e\x0d\x0c\x0b\x0a\x09\x08"
+ "\x07\x06\x05\x04\x03\x02\x01\x00",
+ .klen = 32,
+ .input = "\x0f\x0e\x0d\x0c\x0b\x0a\x09\x08"
+ "\x07\x06\x05\x04\x03\x02\x01\x00",
+ .ilen = 16,
+ .result = "\x5c\xe7\x1c\x70\xd2\x88\x2e\x5b"
+ "\xb8\x32\xe4\x33\xf8\x9f\x26\xde",
+ .rlen = 16,
+ },
+};
+
+
+static struct cipher_testvec serpent_dec_tv_template[] = {
+ {
+ .input = "\x12\x07\xfc\xce\x9b\xd0\xd6\x47"
+ "\x6a\xe9\x8f\xbe\xd1\x43\xa0\xe2",
+ .ilen = 16,
+ .result = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .rlen = 16,
+ }, {
+ .key = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .klen = 16,
+ .input = "\x4c\x7d\x8a\x32\x80\x72\xa2\x2c"
+ "\x82\x3e\x4a\x1f\x3a\xcd\xa1\x6d",
+ .ilen = 16,
+ .result = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .rlen = 16,
+ }, {
+ .key = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
+ .klen = 32,
+ .input = "\xde\x26\x9f\xf8\x33\xe4\x32\xb8"
+ "\x5b\x2e\x88\xd2\x70\x1c\xe7\x5c",
+ .ilen = 16,
+ .result = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .rlen = 16,
+ }, {
+ .key = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80",
+ .klen = 16,
+ .input = "\xdd\xd2\x6b\x98\xa5\xff\xd8\x2c"
+ "\x05\x34\x5a\x9d\xad\xbf\xaf\x49",
+ .ilen = 16,
+ .result = zeroed_string,
+ .rlen = 16,
+ },
+};
+
+static struct cipher_testvec tnepres_dec_tv_template[] = {
+ {
+ .input = "\x41\xcc\x6b\x31\x59\x31\x45\x97"
+ "\x6d\x6f\xbb\x38\x4b\x37\x21\x28",
+ .ilen = 16,
+ .result = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .rlen = 16,
+ }, {
+ .key = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .klen = 16,
+ .input = "\xea\xf4\xd7\xfc\xd8\x01\x34\x47"
+ "\x81\x45\x0b\xfa\x0c\xd6\xad\x6e",
+ .ilen = 16,
+ .result = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .rlen = 16,
+ }, {
+ .key = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
+ .klen = 32,
+ .input = "\x64\xa9\x1a\x37\xed\x9f\xe7\x49"
+ "\xa8\x4e\x76\xd6\xf5\x0d\x78\xee",
+ .ilen = 16,
+ .result = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .rlen = 16,
+ }, { /* KeySize=128, I=121 */
+ .key = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80",
+ .klen = 16,
+ .input = "\x3d\xda\xbf\xc0\x06\xda\xab\x06"
+ "\x46\x2a\xf4\xef\x81\x54\x4e\x26",
+ .ilen = 16,
+ .result = zeroed_string,
+ .rlen = 16,
+ },
+};
+
+
+/* Cast6 test vectors from RFC 2612 */
+#define CAST6_ENC_TEST_VECTORS 3
+#define CAST6_DEC_TEST_VECTORS 3
+
+static struct cipher_testvec cast6_enc_tv_template[] = {
+ {
+ .key = "\x23\x42\xbb\x9e\xfa\x38\x54\x2c"
+ "\x0a\xf7\x56\x47\xf2\x9f\x61\x5d",
+ .klen = 16,
+ .input = zeroed_string,
+ .ilen = 16,
+ .result = "\xc8\x42\xa0\x89\x72\xb4\x3d\x20"
+ "\x83\x6c\x91\xd1\xb7\x53\x0f\x6b",
+ .rlen = 16,
+ }, {
+ .key = "\x23\x42\xbb\x9e\xfa\x38\x54\x2c"
+ "\xbe\xd0\xac\x83\x94\x0a\xc2\x98"
+ "\xba\xc7\x7a\x77\x17\x94\x28\x63",
+ .klen = 24,
+ .input = zeroed_string,
+ .ilen = 16,
+ .result = "\x1b\x38\x6c\x02\x10\xdc\xad\xcb"
+ "\xdd\x0e\x41\xaa\x08\xa7\xa7\xe8",
+ .rlen = 16,
+ }, {
+ .key = "\x23\x42\xbb\x9e\xfa\x38\x54\x2c"
+ "\xbe\xd0\xac\x83\x94\x0a\xc2\x98"
+ "\x8d\x7c\x47\xce\x26\x49\x08\x46"
+ "\x1c\xc1\xb5\x13\x7a\xe6\xb6\x04",
+ .klen = 32,
+ .input = zeroed_string,
+ .ilen = 16,
+ .result = "\x4f\x6a\x20\x38\x28\x68\x97\xb9"
+ "\xc9\x87\x01\x36\x55\x33\x17\xfa",
+ .rlen = 16,
+ },
+};
+
+static struct cipher_testvec cast6_dec_tv_template[] = {
+ {
+ .key = "\x23\x42\xbb\x9e\xfa\x38\x54\x2c"
+ "\x0a\xf7\x56\x47\xf2\x9f\x61\x5d",
+ .klen = 16,
+ .input = "\xc8\x42\xa0\x89\x72\xb4\x3d\x20"
+ "\x83\x6c\x91\xd1\xb7\x53\x0f\x6b",
+ .ilen = 16,
+ .result = zeroed_string,
+ .rlen = 16,
+ }, {
+ .key = "\x23\x42\xbb\x9e\xfa\x38\x54\x2c"
+ "\xbe\xd0\xac\x83\x94\x0a\xc2\x98"
+ "\xba\xc7\x7a\x77\x17\x94\x28\x63",
+ .klen = 24,
+ .input = "\x1b\x38\x6c\x02\x10\xdc\xad\xcb"
+ "\xdd\x0e\x41\xaa\x08\xa7\xa7\xe8",
+ .ilen = 16,
+ .result = zeroed_string,
+ .rlen = 16,
+ }, {
+ .key = "\x23\x42\xbb\x9e\xfa\x38\x54\x2c"
+ "\xbe\xd0\xac\x83\x94\x0a\xc2\x98"
+ "\x8d\x7c\x47\xce\x26\x49\x08\x46"
+ "\x1c\xc1\xb5\x13\x7a\xe6\xb6\x04",
+ .klen = 32,
+ .input = "\x4f\x6a\x20\x38\x28\x68\x97\xb9"
+ "\xc9\x87\x01\x36\x55\x33\x17\xfa",
+ .ilen = 16,
+ .result = zeroed_string,
+ .rlen = 16,
+ },
+};
+
+
+/*
+ * AES test vectors.
+ */
+#if !defined(CONFIG_CRYPTO_DEV_AES) && !defined(CONFIG_CRYPTO_ASYNC_AES)
+#define AES_ENC_TEST_VECTORS 3
+#define AES_DEC_TEST_VECTORS 3
+#define AES_CBC_ENC_TEST_VECTORS 4
+#define AES_CBC_DEC_TEST_VECTORS 4
+#define AES_LRW_ENC_TEST_VECTORS 8
+#define AES_LRW_DEC_TEST_VECTORS 8
+#define AES_XTS_ENC_TEST_VECTORS 4
+#define AES_XTS_DEC_TEST_VECTORS 4
+#define AES_CTR_ENC_TEST_VECTORS 3
+#define AES_CTR_DEC_TEST_VECTORS 3
+#define AES_CTR_3686_ENC_TEST_VECTORS 7
+#define AES_CTR_3686_DEC_TEST_VECTORS 6
+#define AES_GCM_ENC_TEST_VECTORS 9
+#define AES_GCM_DEC_TEST_VECTORS 8
+#define AES_CCM_ENC_TEST_VECTORS 7
+#define AES_CCM_DEC_TEST_VECTORS 7
+#define AES_CCM_4309_ENC_TEST_VECTORS 7
+#define AES_CCM_4309_DEC_TEST_VECTORS 10
+#else
+#define AES_ENC_TEST_VECTORS 3
+#define AES_DEC_TEST_VECTORS 3
+#define AES_CBC_ENC_TEST_VECTORS 3
+#define AES_CBC_DEC_TEST_VECTORS 3
+#define AES_CTR_ENC_TEST_VECTORS 3
+#define AES_CTR_DEC_TEST_VECTORS 3
+#define AES_GCM_ENC_TEST_VECTORS 9
+#define AES_GCM_DEC_TEST_VECTORS 8
+#define AES_CCM_ENC_TEST_VECTORS 7
+#define AES_CCM_DEC_TEST_VECTORS 7
+#define AES_CCM_4309_ENC_TEST_VECTORS 7
+#define AES_CCM_4309_DEC_TEST_VECTORS 10
+#define AES_CTR_3686_ENC_TEST_VECTORS 6
+#define AES_CTR_3686_DEC_TEST_VECTORS 6
+#endif /* CONFIG_CRYPTO_DEV_AES */
+
+static struct cipher_testvec aes_enc_tv_template[] = {
+ { /* From FIPS-197 */
+ .key = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .klen = 16,
+ .input = "\x00\x11\x22\x33\x44\x55\x66\x77"
+ "\x88\x99\xaa\xbb\xcc\xdd\xee\xff",
+ .ilen = 16,
+ .result = "\x69\xc4\xe0\xd8\x6a\x7b\x04\x30"
+ "\xd8\xcd\xb7\x80\x70\xb4\xc5\x5a",
+ .rlen = 16,
+ }, {
+ .key = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17",
+ .klen = 24,
+ .input = "\x00\x11\x22\x33\x44\x55\x66\x77"
+ "\x88\x99\xaa\xbb\xcc\xdd\xee\xff",
+ .ilen = 16,
+ .result = "\xdd\xa9\x7c\xa4\x86\x4c\xdf\xe0"
+ "\x6e\xaf\x70\xa0\xec\x0d\x71\x91",
+ .rlen = 16,
+ }, {
+ .key = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
+ .klen = 32,
+ .input = "\x00\x11\x22\x33\x44\x55\x66\x77"
+ "\x88\x99\xaa\xbb\xcc\xdd\xee\xff",
+ .ilen = 16,
+ .result = "\x8e\xa2\xb7\xca\x51\x67\x45\xbf"
+ "\xea\xfc\x49\x90\x4b\x49\x60\x89",
+ .rlen = 16,
+ },
+};
+
+static struct cipher_testvec aes_dec_tv_template[] = {
+ { /* From FIPS-197 */
+ .key = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .klen = 16,
+ .input = "\x69\xc4\xe0\xd8\x6a\x7b\x04\x30"
+ "\xd8\xcd\xb7\x80\x70\xb4\xc5\x5a",
+ .ilen = 16,
+ .result = "\x00\x11\x22\x33\x44\x55\x66\x77"
+ "\x88\x99\xaa\xbb\xcc\xdd\xee\xff",
+ .rlen = 16,
+ }, {
+ .key = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17",
+ .klen = 24,
+ .input = "\xdd\xa9\x7c\xa4\x86\x4c\xdf\xe0"
+ "\x6e\xaf\x70\xa0\xec\x0d\x71\x91",
+ .ilen = 16,
+ .result = "\x00\x11\x22\x33\x44\x55\x66\x77"
+ "\x88\x99\xaa\xbb\xcc\xdd\xee\xff",
+ .rlen = 16,
+ }, {
+ .key = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
+ .klen = 32,
+ .input = "\x8e\xa2\xb7\xca\x51\x67\x45\xbf"
+ "\xea\xfc\x49\x90\x4b\x49\x60\x89",
+ .ilen = 16,
+ .result = "\x00\x11\x22\x33\x44\x55\x66\x77"
+ "\x88\x99\xaa\xbb\xcc\xdd\xee\xff",
+ .rlen = 16,
+ },
+};
+
+static struct cipher_testvec aes_cbc_enc_tv_template[] = {
+ { /* From RFC 3602 */
+ .key = "\x06\xa9\x21\x40\x36\xb8\xa1\x5b"
+ "\x51\x2e\x03\xd5\x34\x12\x00\x06",
+ .klen = 16,
+ .iv = "\x3d\xaf\xba\x42\x9d\x9e\xb4\x30"
+ "\xb4\x22\xda\x80\x2c\x9f\xac\x41",
+ .input = "Single block msg",
+ .ilen = 16,
+ .result = "\xe3\x53\x77\x9c\x10\x79\xae\xb8"
+ "\x27\x08\x94\x2d\xbe\x77\x18\x1a",
+ .rlen = 16,
+ }, {
+ .key = "\xc2\x86\x69\x6d\x88\x7c\x9a\xa0"
+ "\x61\x1b\xbb\x3e\x20\x25\xa4\x5a",
+ .klen = 16,
+ .iv = "\x56\x2e\x17\x99\x6d\x09\x3d\x28"
+ "\xdd\xb3\xba\x69\x5a\x2e\x6f\x58",
+ .input = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
+ .ilen = 32,
+ .result = "\xd2\x96\xcd\x94\xc2\xcc\xcf\x8a"
+ "\x3a\x86\x30\x28\xb5\xe1\xdc\x0a"
+ "\x75\x86\x60\x2d\x25\x3c\xff\xf9"
+ "\x1b\x82\x66\xbe\xa6\xd6\x1a\xb1",
+ .rlen = 32,
+ }, { /* From NIST SP800-38A */
+ .key = "\x8e\x73\xb0\xf7\xda\x0e\x64\x52"
+ "\xc8\x10\xf3\x2b\x80\x90\x79\xe5"
+ "\x62\xf8\xea\xd2\x52\x2c\x6b\x7b",
+ .klen = 24,
+ .iv = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .input = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96"
+ "\xe9\x3d\x7e\x11\x73\x93\x17\x2a"
+ "\xae\x2d\x8a\x57\x1e\x03\xac\x9c"
+ "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51"
+ "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11"
+ "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef"
+ "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17"
+ "\xad\x2b\x41\x7b\xe6\x6c\x37\x10",
+ .ilen = 64,
+ .result = "\x4f\x02\x1d\xb2\x43\xbc\x63\x3d"
+ "\x71\x78\x18\x3a\x9f\xa0\x71\xe8"
+ "\xb4\xd9\xad\xa9\xad\x7d\xed\xf4"
+ "\xe5\xe7\x38\x76\x3f\x69\x14\x5a"
+ "\x57\x1b\x24\x20\x12\xfb\x7a\xe0"
+ "\x7f\xa9\xba\xac\x3d\xf1\x02\xe0"
+ "\x08\xb0\xe2\x79\x88\x59\x88\x81"
+ "\xd9\x20\xa9\xe6\x4f\x56\x15\xcd",
+ .rlen = 64,
+#if !defined(CONFIG_CRYPTO_DEV_AES) && !defined(CONFIG_CRYPTO_ASYNC_AES)
+ }, {
+ .key = "\x60\x3d\xeb\x10\x15\xca\x71\xbe"
+ "\x2b\x73\xae\xf0\x85\x7d\x77\x81"
+ "\x1f\x35\x2c\x07\x3b\x61\x08\xd7"
+ "\x2d\x98\x10\xa3\x09\x14\xdf\xf4",
+ .klen = 32,
+ .iv = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .input = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96"
+ "\xe9\x3d\x7e\x11\x73\x93\x17\x2a"
+ "\xae\x2d\x8a\x57\x1e\x03\xac\x9c"
+ "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51"
+ "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11"
+ "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef"
+ "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17"
+ "\xad\x2b\x41\x7b\xe6\x6c\x37\x10",
+ .ilen = 64,
+ .result = "\xf5\x8c\x4c\x04\xd6\xe5\xf1\xba"
+ "\x77\x9e\xab\xfb\x5f\x7b\xfb\xd6"
+ "\x9c\xfc\x4e\x96\x7e\xdb\x80\x8d"
+ "\x67\x9f\x77\x7b\xc6\x70\x2c\x7d"
+ "\x39\xf2\x33\x69\xa9\xd9\xba\xcf"
+ "\xa5\x30\xe2\x63\x04\x23\x14\x61"
+ "\xb2\xeb\x05\xe2\xc3\x9b\xe9\xfc"
+ "\xda\x6c\x19\x07\x8c\x6a\x9d\x1b",
+ .rlen = 64,
+#endif
+ },
+};
+
+static struct cipher_testvec aes_cbc_dec_tv_template[] = {
+ { /* From RFC 3602 */
+ .key = "\x06\xa9\x21\x40\x36\xb8\xa1\x5b"
+ "\x51\x2e\x03\xd5\x34\x12\x00\x06",
+ .klen = 16,
+ .iv = "\x3d\xaf\xba\x42\x9d\x9e\xb4\x30"
+ "\xb4\x22\xda\x80\x2c\x9f\xac\x41",
+ .input = "\xe3\x53\x77\x9c\x10\x79\xae\xb8"
+ "\x27\x08\x94\x2d\xbe\x77\x18\x1a",
+ .ilen = 16,
+ .result = "Single block msg",
+ .rlen = 16,
+ }, {
+ .key = "\xc2\x86\x69\x6d\x88\x7c\x9a\xa0"
+ "\x61\x1b\xbb\x3e\x20\x25\xa4\x5a",
+ .klen = 16,
+ .iv = "\x56\x2e\x17\x99\x6d\x09\x3d\x28"
+ "\xdd\xb3\xba\x69\x5a\x2e\x6f\x58",
+ .input = "\xd2\x96\xcd\x94\xc2\xcc\xcf\x8a"
+ "\x3a\x86\x30\x28\xb5\xe1\xdc\x0a"
+ "\x75\x86\x60\x2d\x25\x3c\xff\xf9"
+ "\x1b\x82\x66\xbe\xa6\xd6\x1a\xb1",
+ .ilen = 32,
+ .result = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
+ .rlen = 32,
+ }, { /* From NIST SP800-38A */
+ .key = "\x8e\x73\xb0\xf7\xda\x0e\x64\x52"
+ "\xc8\x10\xf3\x2b\x80\x90\x79\xe5"
+ "\x62\xf8\xea\xd2\x52\x2c\x6b\x7b",
+ .klen = 24,
+ .iv = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .input = "\x4f\x02\x1d\xb2\x43\xbc\x63\x3d"
+ "\x71\x78\x18\x3a\x9f\xa0\x71\xe8"
+ "\xb4\xd9\xad\xa9\xad\x7d\xed\xf4"
+ "\xe5\xe7\x38\x76\x3f\x69\x14\x5a"
+ "\x57\x1b\x24\x20\x12\xfb\x7a\xe0"
+ "\x7f\xa9\xba\xac\x3d\xf1\x02\xe0"
+ "\x08\xb0\xe2\x79\x88\x59\x88\x81"
+ "\xd9\x20\xa9\xe6\x4f\x56\x15\xcd",
+ .ilen = 64,
+ .result = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96"
+ "\xe9\x3d\x7e\x11\x73\x93\x17\x2a"
+ "\xae\x2d\x8a\x57\x1e\x03\xac\x9c"
+ "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51"
+ "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11"
+ "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef"
+ "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17"
+ "\xad\x2b\x41\x7b\xe6\x6c\x37\x10",
+ .rlen = 64,
+#if !defined(CONFIG_CRYPTO_DEV_AES) && !defined(CONFIG_CRYPTO_ASYNC_AES)
+ }, {
+ .key = "\x60\x3d\xeb\x10\x15\xca\x71\xbe"
+ "\x2b\x73\xae\xf0\x85\x7d\x77\x81"
+ "\x1f\x35\x2c\x07\x3b\x61\x08\xd7"
+ "\x2d\x98\x10\xa3\x09\x14\xdf\xf4",
+ .klen = 32,
+ .iv = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .input = "\xf5\x8c\x4c\x04\xd6\xe5\xf1\xba"
+ "\x77\x9e\xab\xfb\x5f\x7b\xfb\xd6"
+ "\x9c\xfc\x4e\x96\x7e\xdb\x80\x8d"
+ "\x67\x9f\x77\x7b\xc6\x70\x2c\x7d"
+ "\x39\xf2\x33\x69\xa9\xd9\xba\xcf"
+ "\xa5\x30\xe2\x63\x04\x23\x14\x61"
+ "\xb2\xeb\x05\xe2\xc3\x9b\xe9\xfc"
+ "\xda\x6c\x19\x07\x8c\x6a\x9d\x1b",
+ .ilen = 64,
+ .result = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96"
+ "\xe9\x3d\x7e\x11\x73\x93\x17\x2a"
+ "\xae\x2d\x8a\x57\x1e\x03\xac\x9c"
+ "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51"
+ "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11"
+ "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef"
+ "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17"
+ "\xad\x2b\x41\x7b\xe6\x6c\x37\x10",
+ .rlen = 64,
+#endif
+ },
+};
+
+#if !defined(CONFIG_CRYPTO_DEV_AES) && !defined(CONFIG_CRYPTO_ASYNC_AES)
+
+static struct cipher_testvec aes_lrw_enc_tv_template[] = {
+ /* from http://grouper.ieee.org/groups/1619/email/pdf00017.pdf */
+ { /* LRW-32-AES 1 */
+ .key = "\x45\x62\xac\x25\xf8\x28\x17\x6d"
+ "\x4c\x26\x84\x14\xb5\x68\x01\x85"
+ "\x25\x8e\x2a\x05\xe7\x3e\x9d\x03"
+ "\xee\x5a\x83\x0c\xcc\x09\x4c\x87",
+ .klen = 32,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x01",
+ .input = "\x30\x31\x32\x33\x34\x35\x36\x37"
+ "\x38\x39\x41\x42\x43\x44\x45\x46",
+ .ilen = 16,
+ .result = "\xf1\xb2\x73\xcd\x65\xa3\xdf\x5f"
+ "\xe9\x5d\x48\x92\x54\x63\x4e\xb8",
+ .rlen = 16,
+ }, { /* LRW-32-AES 2 */
+ .key = "\x59\x70\x47\x14\xf5\x57\x47\x8c"
+ "\xd7\x79\xe8\x0f\x54\x88\x79\x44"
+ "\x0d\x48\xf0\xb7\xb1\x5a\x53\xea"
+ "\x1c\xaa\x6b\x29\xc2\xca\xfb\xaf",
+ .klen = 32,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x02",
+ .input = "\x30\x31\x32\x33\x34\x35\x36\x37"
+ "\x38\x39\x41\x42\x43\x44\x45\x46",
+ .ilen = 16,
+ .result = "\x00\xc8\x2b\xae\x95\xbb\xcd\xe5"
+ "\x27\x4f\x07\x69\xb2\x60\xe1\x36",
+ .rlen = 16,
+ }, { /* LRW-32-AES 3 */
+ .key = "\xd8\x2a\x91\x34\xb2\x6a\x56\x50"
+ "\x30\xfe\x69\xe2\x37\x7f\x98\x47"
+ "\xcd\xf9\x0b\x16\x0c\x64\x8f\xb6"
+ "\xb0\x0d\x0d\x1b\xae\x85\x87\x1f",
+ .klen = 32,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x02\x00\x00\x00\x00",
+ .input = "\x30\x31\x32\x33\x34\x35\x36\x37"
+ "\x38\x39\x41\x42\x43\x44\x45\x46",
+ .ilen = 16,
+ .result = "\x76\x32\x21\x83\xed\x8f\xf1\x82"
+ "\xf9\x59\x62\x03\x69\x0e\x5e\x01",
+ .rlen = 16,
+ }, { /* LRW-32-AES 4 */
+ .key = "\x0f\x6a\xef\xf8\xd3\xd2\xbb\x15"
+ "\x25\x83\xf7\x3c\x1f\x01\x28\x74"
+ "\xca\xc6\xbc\x35\x4d\x4a\x65\x54"
+ "\x90\xae\x61\xcf\x7b\xae\xbd\xcc"
+ "\xad\xe4\x94\xc5\x4a\x29\xae\x70",
+ .klen = 40,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x01",
+ .input = "\x30\x31\x32\x33\x34\x35\x36\x37"
+ "\x38\x39\x41\x42\x43\x44\x45\x46",
+ .ilen = 16,
+ .result = "\x9c\x0f\x15\x2f\x55\xa2\xd8\xf0"
+ "\xd6\x7b\x8f\x9e\x28\x22\xbc\x41",
+ .rlen = 16,
+ }, { /* LRW-32-AES 5 */
+ .key = "\x8a\xd4\xee\x10\x2f\xbd\x81\xff"
+ "\xf8\x86\xce\xac\x93\xc5\xad\xc6"
+ "\xa0\x19\x07\xc0\x9d\xf7\xbb\xdd"
+ "\x52\x13\xb2\xb7\xf0\xff\x11\xd8"
+ "\xd6\x08\xd0\xcd\x2e\xb1\x17\x6f",
+ .klen = 40,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x02\x00\x00\x00\x00",
+ .input = "\x30\x31\x32\x33\x34\x35\x36\x37"
+ "\x38\x39\x41\x42\x43\x44\x45\x46",
+ .ilen = 16,
+ .result = "\xd4\x27\x6a\x7f\x14\x91\x3d\x65"
+ "\xc8\x60\x48\x02\x87\xe3\x34\x06",
+ .rlen = 16,
+ }, { /* LRW-32-AES 6 */
+ .key = "\xf8\xd4\x76\xff\xd6\x46\xee\x6c"
+ "\x23\x84\xcb\x1c\x77\xd6\x19\x5d"
+ "\xfe\xf1\xa9\xf3\x7b\xbc\x8d\x21"
+ "\xa7\x9c\x21\xf8\xcb\x90\x02\x89"
+ "\xa8\x45\x34\x8e\xc8\xc5\xb5\xf1"
+ "\x26\xf5\x0e\x76\xfe\xfd\x1b\x1e",
+ .klen = 48,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x01",
+ .input = "\x30\x31\x32\x33\x34\x35\x36\x37"
+ "\x38\x39\x41\x42\x43\x44\x45\x46",
+ .ilen = 16,
+ .result = "\xbd\x06\xb8\xe1\xdb\x98\x89\x9e"
+ "\xc4\x98\xe4\x91\xcf\x1c\x70\x2b",
+ .rlen = 16,
+ }, { /* LRW-32-AES 7 */
+ .key = "\xfb\x76\x15\xb2\x3d\x80\x89\x1d"
+ "\xd4\x70\x98\x0b\xc7\x95\x84\xc8"
+ "\xb2\xfb\x64\xce\x60\x97\x87\x8d"
+ "\x17\xfc\xe4\x5a\x49\xe8\x30\xb7"
+ "\x6e\x78\x17\xe7\x2d\x5e\x12\xd4"
+ "\x60\x64\x04\x7a\xf1\x2f\x9e\x0c",
+ .klen = 48,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x02\x00\x00\x00\x00",
+ .input = "\x30\x31\x32\x33\x34\x35\x36\x37"
+ "\x38\x39\x41\x42\x43\x44\x45\x46",
+ .ilen = 16,
+ .result = "\x5b\x90\x8e\xc1\xab\xdd\x67\x5f"
+ "\x3d\x69\x8a\x95\x53\xc8\x9c\xe5",
+ .rlen = 16,
+ }, {
+/* http://www.mail-archive.com/stds-p1619@listserv.ieee.org/msg00173.html */
+ .key = "\xf8\xd4\x76\xff\xd6\x46\xee\x6c"
+ "\x23\x84\xcb\x1c\x77\xd6\x19\x5d"
+ "\xfe\xf1\xa9\xf3\x7b\xbc\x8d\x21"
+ "\xa7\x9c\x21\xf8\xcb\x90\x02\x89"
+ "\xa8\x45\x34\x8e\xc8\xc5\xb5\xf1"
+ "\x26\xf5\x0e\x76\xfe\xfd\x1b\x1e",
+ .klen = 48,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x01",
+ .input = "\x05\x11\xb7\x18\xab\xc6\x2d\xac"
+ "\x70\x5d\xf6\x22\x94\xcd\xe5\x6c"
+ "\x17\x6b\xf6\x1c\xf0\xf3\x6e\xf8"
+ "\x50\x38\x1f\x71\x49\xb6\x57\xd6"
+ "\x8f\xcb\x8d\x6b\xe3\xa6\x29\x90"
+ "\xfe\x2a\x62\x82\xae\x6d\x8b\xf6"
+ "\xad\x1e\x9e\x20\x5f\x38\xbe\x04"
+ "\xda\x10\x8e\xed\xa2\xa4\x87\xab"
+ "\xda\x6b\xb4\x0c\x75\xba\xd3\x7c"
+ "\xc9\xac\x42\x31\x95\x7c\xc9\x04"
+ "\xeb\xd5\x6e\x32\x69\x8a\xdb\xa6"
+ "\x15\xd7\x3f\x4f\x2f\x66\x69\x03"
+ "\x9c\x1f\x54\x0f\xde\x1f\xf3\x65"
+ "\x4c\x96\x12\xed\x7c\x92\x03\x01"
+ "\x6f\xbc\x35\x93\xac\xf1\x27\xf1"
+ "\xb4\x96\x82\x5a\x5f\xb0\xa0\x50"
+ "\x89\xa4\x8e\x66\x44\x85\xcc\xfd"
+ "\x33\x14\x70\xe3\x96\xb2\xc3\xd3"
+ "\xbb\x54\x5a\x1a\xf9\x74\xa2\xc5"
+ "\x2d\x64\x75\xdd\xb4\x54\xe6\x74"
+ "\x8c\xd3\x9d\x9e\x86\xab\x51\x53"
+ "\xb7\x93\x3e\x6f\xd0\x4e\x2c\x40"
+ "\xf6\xa8\x2e\x3e\x9d\xf4\x66\xa5"
+ "\x76\x12\x73\x44\x1a\x56\xd7\x72"
+ "\x88\xcd\x21\x8c\x4c\x0f\xfe\xda"
+ "\x95\xe0\x3a\xa6\xa5\x84\x46\xcd"
+ "\xd5\x3e\x9d\x3a\xe2\x67\xe6\x60"
+ "\x1a\xe2\x70\x85\x58\xc2\x1b\x09"
+ "\xe1\xd7\x2c\xca\xad\xa8\x8f\xf9"
+ "\xac\xb3\x0e\xdb\xca\x2e\xe2\xb8"
+ "\x51\x71\xd9\x3c\x6c\xf1\x56\xf8"
+ "\xea\x9c\xf1\xfb\x0c\xe6\xb7\x10"
+ "\x1c\xf8\xa9\x7c\xe8\x53\x35\xc1"
+ "\x90\x3e\x76\x4a\x74\xa4\x21\x2c"
+ "\xf6\x2c\x4e\x0f\x94\x3a\x88\x2e"
+ "\x41\x09\x6a\x33\x7d\xf6\xdd\x3f"
+ "\x8d\x23\x31\x74\x84\xeb\x88\x6e"
+ "\xcc\xb9\xbc\x22\x83\x19\x07\x22"
+ "\xa5\x2d\xdf\xa5\xf3\x80\x85\x78"
+ "\x84\x39\x6a\x6d\x6a\x99\x4f\xa5"
+ "\x15\xfe\x46\xb0\xe4\x6c\xa5\x41"
+ "\x3c\xce\x8f\x42\x60\x71\xa7\x75"
+ "\x08\x40\x65\x8a\x82\xbf\xf5\x43"
+ "\x71\x96\xa9\x4d\x44\x8a\x20\xbe"
+ "\xfa\x4d\xbb\xc0\x7d\x31\x96\x65"
+ "\xe7\x75\xe5\x3e\xfd\x92\x3b\xc9"
+ "\x55\xbb\x16\x7e\xf7\xc2\x8c\xa4"
+ "\x40\x1d\xe5\xef\x0e\xdf\xe4\x9a"
+ "\x62\x73\x65\xfd\x46\x63\x25\x3d"
+ "\x2b\xaf\xe5\x64\xfe\xa5\x5c\xcf"
+ "\x24\xf3\xb4\xac\x64\xba\xdf\x4b"
+ "\xc6\x96\x7d\x81\x2d\x8d\x97\xf7"
+ "\xc5\x68\x77\x84\x32\x2b\xcc\x85"
+ "\x74\x96\xf0\x12\x77\x61\xb9\xeb"
+ "\x71\xaa\x82\xcb\x1c\xdb\x89\xc8"
+ "\xc6\xb5\xe3\x5c\x7d\x39\x07\x24"
+ "\xda\x39\x87\x45\xc0\x2b\xbb\x01"
+ "\xac\xbc\x2a\x5c\x7f\xfc\xe8\xce"
+ "\x6d\x9c\x6f\xed\xd3\xc1\xa1\xd6"
+ "\xc5\x55\xa9\x66\x2f\xe1\xc8\x32"
+ "\xa6\x5d\xa4\x3a\x98\x73\xe8\x45"
+ "\xa4\xc7\xa8\xb4\xf6\x13\x03\xf6"
+ "\xe9\x2e\xc4\x29\x0f\x84\xdb\xc4"
+ "\x21\xc4\xc2\x75\x67\x89\x37\x0a",
+ .ilen = 512,
+ .result = "\x1a\x1d\xa9\x30\xad\xf9\x2f\x9b"
+ "\xb6\x1d\xae\xef\xf0\x2f\xf8\x5a"
+ "\x39\x3c\xbf\x2a\xb2\x45\xb2\x23"
+ "\x1b\x63\x3c\xcf\xaa\xbe\xcf\x4e"
+ "\xfa\xe8\x29\xc2\x20\x68\x2b\x3c"
+ "\x2e\x8b\xf7\x6e\x25\xbd\xe3\x3d"
+ "\x66\x27\xd6\xaf\xd6\x64\x3e\xe3"
+ "\xe8\x58\x46\x97\x39\x51\x07\xde"
+ "\xcb\x37\xbc\xa9\xc0\x5f\x75\xc3"
+ "\x0e\x84\x23\x1d\x16\xd4\x1c\x59"
+ "\x9c\x1a\x02\x55\xab\x3a\x97\x1d"
+ "\xdf\xdd\xc7\x06\x51\xd7\x70\xae"
+ "\x23\xc6\x8c\xf5\x1e\xa0\xe5\x82"
+ "\xb8\xb2\xbf\x04\xa0\x32\x8e\x68"
+ "\xeb\xaf\x6e\x2d\x94\x22\x2f\xce"
+ "\x4c\xb5\x59\xe2\xa2\x2f\xa0\x98"
+ "\x1a\x97\xc6\xd4\xb5\x00\x59\xf2"
+ "\x84\x14\x72\xb1\x9a\x6e\xa3\x7f"
+ "\xea\x20\xe7\xcb\x65\x77\x3a\xdf"
+ "\xc8\x97\x67\x15\xc2\x2a\x27\xcc"
+ "\x18\x55\xa1\x24\x0b\x24\x24\xaf"
+ "\x5b\xec\x68\xb8\xc8\xf5\xba\x63"
+ "\xff\xed\x89\xce\xd5\x3d\x88\xf3"
+ "\x25\xef\x05\x7c\x3a\xef\xeb\xd8"
+ "\x7a\x32\x0d\xd1\x1e\x58\x59\x99"
+ "\x90\x25\xb5\x26\xb0\xe3\x2b\x6c"
+ "\x4c\xa9\x8b\x84\x4f\x5e\x01\x50"
+ "\x41\x30\x58\xc5\x62\x74\x52\x1d"
+ "\x45\x24\x6a\x42\x64\x4f\x97\x1c"
+ "\xa8\x66\xb5\x6d\x79\xd4\x0d\x48"
+ "\xc5\x5f\xf3\x90\x32\xdd\xdd\xe1"
+ "\xe4\xa9\x9f\xfc\xc3\x52\x5a\x46"
+ "\xe4\x81\x84\x95\x36\x59\x7a\x6b"
+ "\xaa\xb3\x60\xad\xce\x9f\x9f\x28"
+ "\xe0\x01\x75\x22\xc4\x4e\xa9\x62"
+ "\x5c\x62\x0d\x00\xcb\x13\xe8\x43"
+ "\x72\xd4\x2d\x53\x46\xb5\xd1\x16"
+ "\x22\x18\xdf\x34\x33\xf5\xd6\x1c"
+ "\xb8\x79\x78\x97\x94\xff\x72\x13"
+ "\x4c\x27\xfc\xcb\xbf\x01\x53\xa6"
+ "\xb4\x50\x6e\xde\xdf\xb5\x43\xa4"
+ "\x59\xdf\x52\xf9\x7c\xe0\x11\x6f"
+ "\x2d\x14\x8e\x24\x61\x2c\xe1\x17"
+ "\xcc\xce\x51\x0c\x19\x8a\x82\x30"
+ "\x94\xd5\x3d\x6a\x53\x06\x5e\xbd"
+ "\xb7\xeb\xfa\xfd\x27\x51\xde\x85"
+ "\x1e\x86\x53\x11\x53\x94\x00\xee"
+ "\x2b\x8c\x08\x2a\xbf\xdd\xae\x11"
+ "\xcb\x1e\xa2\x07\x9a\x80\xcf\x62"
+ "\x9b\x09\xdc\x95\x3c\x96\x8e\xb1"
+ "\x09\xbd\xe4\xeb\xdb\xca\x70\x7a"
+ "\x9e\xfa\x31\x18\x45\x3c\x21\x33"
+ "\xb0\xb3\x2b\xea\xf3\x71\x2d\xe1"
+ "\x03\xad\x1b\x48\xd4\x67\x27\xf0"
+ "\x62\xe4\x3d\xfb\x9b\x08\x76\xe7"
+ "\xdd\x2b\x01\x39\x04\x5a\x58\x7a"
+ "\xf7\x11\x90\xec\xbd\x51\x5c\x32"
+ "\x6b\xd7\x35\x39\x02\x6b\xf2\xa6"
+ "\xd0\x0d\x07\xe1\x06\xc4\x5b\x7d"
+ "\xe4\x6a\xd7\xee\x15\x1f\x83\xb4"
+ "\xa3\xa7\x5e\xc3\x90\xb7\xef\xd3"
+ "\xb7\x4f\xf8\x92\x4c\xb7\x3c\x29"
+ "\xcd\x7e\x2b\x5d\x43\xea\x42\xe7"
+ "\x74\x3f\x7d\x58\x88\x75\xde\x3e",
+ .rlen = 512,
+ }
+};
+
+static struct cipher_testvec aes_lrw_dec_tv_template[] = {
+ /* from http://grouper.ieee.org/groups/1619/email/pdf00017.pdf */
+ /* same as enc vectors with input and result reversed */
+ { /* LRW-32-AES 1 */
+ .key = "\x45\x62\xac\x25\xf8\x28\x17\x6d"
+ "\x4c\x26\x84\x14\xb5\x68\x01\x85"
+ "\x25\x8e\x2a\x05\xe7\x3e\x9d\x03"
+ "\xee\x5a\x83\x0c\xcc\x09\x4c\x87",
+ .klen = 32,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x01",
+ .input = "\xf1\xb2\x73\xcd\x65\xa3\xdf\x5f"
+ "\xe9\x5d\x48\x92\x54\x63\x4e\xb8",
+ .ilen = 16,
+ .result = "\x30\x31\x32\x33\x34\x35\x36\x37"
+ "\x38\x39\x41\x42\x43\x44\x45\x46",
+ .rlen = 16,
+ }, { /* LRW-32-AES 2 */
+ .key = "\x59\x70\x47\x14\xf5\x57\x47\x8c"
+ "\xd7\x79\xe8\x0f\x54\x88\x79\x44"
+ "\x0d\x48\xf0\xb7\xb1\x5a\x53\xea"
+ "\x1c\xaa\x6b\x29\xc2\xca\xfb\xaf",
+ .klen = 32,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x02",
+ .input = "\x00\xc8\x2b\xae\x95\xbb\xcd\xe5"
+ "\x27\x4f\x07\x69\xb2\x60\xe1\x36",
+ .ilen = 16,
+ .result = "\x30\x31\x32\x33\x34\x35\x36\x37"
+ "\x38\x39\x41\x42\x43\x44\x45\x46",
+ .rlen = 16,
+ }, { /* LRW-32-AES 3 */
+ .key = "\xd8\x2a\x91\x34\xb2\x6a\x56\x50"
+ "\x30\xfe\x69\xe2\x37\x7f\x98\x47"
+ "\xcd\xf9\x0b\x16\x0c\x64\x8f\xb6"
+ "\xb0\x0d\x0d\x1b\xae\x85\x87\x1f",
+ .klen = 32,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x02\x00\x00\x00\x00",
+ .input = "\x76\x32\x21\x83\xed\x8f\xf1\x82"
+ "\xf9\x59\x62\x03\x69\x0e\x5e\x01",
+ .ilen = 16,
+ .result = "\x30\x31\x32\x33\x34\x35\x36\x37"
+ "\x38\x39\x41\x42\x43\x44\x45\x46",
+ .rlen = 16,
+ }, { /* LRW-32-AES 4 */
+ .key = "\x0f\x6a\xef\xf8\xd3\xd2\xbb\x15"
+ "\x25\x83\xf7\x3c\x1f\x01\x28\x74"
+ "\xca\xc6\xbc\x35\x4d\x4a\x65\x54"
+ "\x90\xae\x61\xcf\x7b\xae\xbd\xcc"
+ "\xad\xe4\x94\xc5\x4a\x29\xae\x70",
+ .klen = 40,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x01",
+ .input = "\x9c\x0f\x15\x2f\x55\xa2\xd8\xf0"
+ "\xd6\x7b\x8f\x9e\x28\x22\xbc\x41",
+ .ilen = 16,
+ .result = "\x30\x31\x32\x33\x34\x35\x36\x37"
+ "\x38\x39\x41\x42\x43\x44\x45\x46",
+ .rlen = 16,
+ }, { /* LRW-32-AES 5 */
+ .key = "\x8a\xd4\xee\x10\x2f\xbd\x81\xff"
+ "\xf8\x86\xce\xac\x93\xc5\xad\xc6"
+ "\xa0\x19\x07\xc0\x9d\xf7\xbb\xdd"
+ "\x52\x13\xb2\xb7\xf0\xff\x11\xd8"
+ "\xd6\x08\xd0\xcd\x2e\xb1\x17\x6f",
+ .klen = 40,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x02\x00\x00\x00\x00",
+ .input = "\xd4\x27\x6a\x7f\x14\x91\x3d\x65"
+ "\xc8\x60\x48\x02\x87\xe3\x34\x06",
+ .ilen = 16,
+ .result = "\x30\x31\x32\x33\x34\x35\x36\x37"
+ "\x38\x39\x41\x42\x43\x44\x45\x46",
+ .rlen = 16,
+ }, { /* LRW-32-AES 6 */
+ .key = "\xf8\xd4\x76\xff\xd6\x46\xee\x6c"
+ "\x23\x84\xcb\x1c\x77\xd6\x19\x5d"
+ "\xfe\xf1\xa9\xf3\x7b\xbc\x8d\x21"
+ "\xa7\x9c\x21\xf8\xcb\x90\x02\x89"
+ "\xa8\x45\x34\x8e\xc8\xc5\xb5\xf1"
+ "\x26\xf5\x0e\x76\xfe\xfd\x1b\x1e",
+ .klen = 48,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x01",
+ .input = "\xbd\x06\xb8\xe1\xdb\x98\x89\x9e"
+ "\xc4\x98\xe4\x91\xcf\x1c\x70\x2b",
+ .ilen = 16,
+ .result = "\x30\x31\x32\x33\x34\x35\x36\x37"
+ "\x38\x39\x41\x42\x43\x44\x45\x46",
+ .rlen = 16,
+ }, { /* LRW-32-AES 7 */
+ .key = "\xfb\x76\x15\xb2\x3d\x80\x89\x1d"
+ "\xd4\x70\x98\x0b\xc7\x95\x84\xc8"
+ "\xb2\xfb\x64\xce\x60\x97\x87\x8d"
+ "\x17\xfc\xe4\x5a\x49\xe8\x30\xb7"
+ "\x6e\x78\x17\xe7\x2d\x5e\x12\xd4"
+ "\x60\x64\x04\x7a\xf1\x2f\x9e\x0c",
+ .klen = 48,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x02\x00\x00\x00\x00",
+ .input = "\x5b\x90\x8e\xc1\xab\xdd\x67\x5f"
+ "\x3d\x69\x8a\x95\x53\xc8\x9c\xe5",
+ .ilen = 16,
+ .result = "\x30\x31\x32\x33\x34\x35\x36\x37"
+ "\x38\x39\x41\x42\x43\x44\x45\x46",
+ .rlen = 16,
+ }, {
+/* http://www.mail-archive.com/stds-p1619@listserv.ieee.org/msg00173.html */
+ .key = "\xf8\xd4\x76\xff\xd6\x46\xee\x6c"
+ "\x23\x84\xcb\x1c\x77\xd6\x19\x5d"
+ "\xfe\xf1\xa9\xf3\x7b\xbc\x8d\x21"
+ "\xa7\x9c\x21\xf8\xcb\x90\x02\x89"
+ "\xa8\x45\x34\x8e\xc8\xc5\xb5\xf1"
+ "\x26\xf5\x0e\x76\xfe\xfd\x1b\x1e",
+ .klen = 48,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x01",
+ .input = "\x1a\x1d\xa9\x30\xad\xf9\x2f\x9b"
+ "\xb6\x1d\xae\xef\xf0\x2f\xf8\x5a"
+ "\x39\x3c\xbf\x2a\xb2\x45\xb2\x23"
+ "\x1b\x63\x3c\xcf\xaa\xbe\xcf\x4e"
+ "\xfa\xe8\x29\xc2\x20\x68\x2b\x3c"
+ "\x2e\x8b\xf7\x6e\x25\xbd\xe3\x3d"
+ "\x66\x27\xd6\xaf\xd6\x64\x3e\xe3"
+ "\xe8\x58\x46\x97\x39\x51\x07\xde"
+ "\xcb\x37\xbc\xa9\xc0\x5f\x75\xc3"
+ "\x0e\x84\x23\x1d\x16\xd4\x1c\x59"
+ "\x9c\x1a\x02\x55\xab\x3a\x97\x1d"
+ "\xdf\xdd\xc7\x06\x51\xd7\x70\xae"
+ "\x23\xc6\x8c\xf5\x1e\xa0\xe5\x82"
+ "\xb8\xb2\xbf\x04\xa0\x32\x8e\x68"
+ "\xeb\xaf\x6e\x2d\x94\x22\x2f\xce"
+ "\x4c\xb5\x59\xe2\xa2\x2f\xa0\x98"
+ "\x1a\x97\xc6\xd4\xb5\x00\x59\xf2"
+ "\x84\x14\x72\xb1\x9a\x6e\xa3\x7f"
+ "\xea\x20\xe7\xcb\x65\x77\x3a\xdf"
+ "\xc8\x97\x67\x15\xc2\x2a\x27\xcc"
+ "\x18\x55\xa1\x24\x0b\x24\x24\xaf"
+ "\x5b\xec\x68\xb8\xc8\xf5\xba\x63"
+ "\xff\xed\x89\xce\xd5\x3d\x88\xf3"
+ "\x25\xef\x05\x7c\x3a\xef\xeb\xd8"
+ "\x7a\x32\x0d\xd1\x1e\x58\x59\x99"
+ "\x90\x25\xb5\x26\xb0\xe3\x2b\x6c"
+ "\x4c\xa9\x8b\x84\x4f\x5e\x01\x50"
+ "\x41\x30\x58\xc5\x62\x74\x52\x1d"
+ "\x45\x24\x6a\x42\x64\x4f\x97\x1c"
+ "\xa8\x66\xb5\x6d\x79\xd4\x0d\x48"
+ "\xc5\x5f\xf3\x90\x32\xdd\xdd\xe1"
+ "\xe4\xa9\x9f\xfc\xc3\x52\x5a\x46"
+ "\xe4\x81\x84\x95\x36\x59\x7a\x6b"
+ "\xaa\xb3\x60\xad\xce\x9f\x9f\x28"
+ "\xe0\x01\x75\x22\xc4\x4e\xa9\x62"
+ "\x5c\x62\x0d\x00\xcb\x13\xe8\x43"
+ "\x72\xd4\x2d\x53\x46\xb5\xd1\x16"
+ "\x22\x18\xdf\x34\x33\xf5\xd6\x1c"
+ "\xb8\x79\x78\x97\x94\xff\x72\x13"
+ "\x4c\x27\xfc\xcb\xbf\x01\x53\xa6"
+ "\xb4\x50\x6e\xde\xdf\xb5\x43\xa4"
+ "\x59\xdf\x52\xf9\x7c\xe0\x11\x6f"
+ "\x2d\x14\x8e\x24\x61\x2c\xe1\x17"
+ "\xcc\xce\x51\x0c\x19\x8a\x82\x30"
+ "\x94\xd5\x3d\x6a\x53\x06\x5e\xbd"
+ "\xb7\xeb\xfa\xfd\x27\x51\xde\x85"
+ "\x1e\x86\x53\x11\x53\x94\x00\xee"
+ "\x2b\x8c\x08\x2a\xbf\xdd\xae\x11"
+ "\xcb\x1e\xa2\x07\x9a\x80\xcf\x62"
+ "\x9b\x09\xdc\x95\x3c\x96\x8e\xb1"
+ "\x09\xbd\xe4\xeb\xdb\xca\x70\x7a"
+ "\x9e\xfa\x31\x18\x45\x3c\x21\x33"
+ "\xb0\xb3\x2b\xea\xf3\x71\x2d\xe1"
+ "\x03\xad\x1b\x48\xd4\x67\x27\xf0"
+ "\x62\xe4\x3d\xfb\x9b\x08\x76\xe7"
+ "\xdd\x2b\x01\x39\x04\x5a\x58\x7a"
+ "\xf7\x11\x90\xec\xbd\x51\x5c\x32"
+ "\x6b\xd7\x35\x39\x02\x6b\xf2\xa6"
+ "\xd0\x0d\x07\xe1\x06\xc4\x5b\x7d"
+ "\xe4\x6a\xd7\xee\x15\x1f\x83\xb4"
+ "\xa3\xa7\x5e\xc3\x90\xb7\xef\xd3"
+ "\xb7\x4f\xf8\x92\x4c\xb7\x3c\x29"
+ "\xcd\x7e\x2b\x5d\x43\xea\x42\xe7"
+ "\x74\x3f\x7d\x58\x88\x75\xde\x3e",
+ .ilen = 512,
+ .result = "\x05\x11\xb7\x18\xab\xc6\x2d\xac"
+ "\x70\x5d\xf6\x22\x94\xcd\xe5\x6c"
+ "\x17\x6b\xf6\x1c\xf0\xf3\x6e\xf8"
+ "\x50\x38\x1f\x71\x49\xb6\x57\xd6"
+ "\x8f\xcb\x8d\x6b\xe3\xa6\x29\x90"
+ "\xfe\x2a\x62\x82\xae\x6d\x8b\xf6"
+ "\xad\x1e\x9e\x20\x5f\x38\xbe\x04"
+ "\xda\x10\x8e\xed\xa2\xa4\x87\xab"
+ "\xda\x6b\xb4\x0c\x75\xba\xd3\x7c"
+ "\xc9\xac\x42\x31\x95\x7c\xc9\x04"
+ "\xeb\xd5\x6e\x32\x69\x8a\xdb\xa6"
+ "\x15\xd7\x3f\x4f\x2f\x66\x69\x03"
+ "\x9c\x1f\x54\x0f\xde\x1f\xf3\x65"
+ "\x4c\x96\x12\xed\x7c\x92\x03\x01"
+ "\x6f\xbc\x35\x93\xac\xf1\x27\xf1"
+ "\xb4\x96\x82\x5a\x5f\xb0\xa0\x50"
+ "\x89\xa4\x8e\x66\x44\x85\xcc\xfd"
+ "\x33\x14\x70\xe3\x96\xb2\xc3\xd3"
+ "\xbb\x54\x5a\x1a\xf9\x74\xa2\xc5"
+ "\x2d\x64\x75\xdd\xb4\x54\xe6\x74"
+ "\x8c\xd3\x9d\x9e\x86\xab\x51\x53"
+ "\xb7\x93\x3e\x6f\xd0\x4e\x2c\x40"
+ "\xf6\xa8\x2e\x3e\x9d\xf4\x66\xa5"
+ "\x76\x12\x73\x44\x1a\x56\xd7\x72"
+ "\x88\xcd\x21\x8c\x4c\x0f\xfe\xda"
+ "\x95\xe0\x3a\xa6\xa5\x84\x46\xcd"
+ "\xd5\x3e\x9d\x3a\xe2\x67\xe6\x60"
+ "\x1a\xe2\x70\x85\x58\xc2\x1b\x09"
+ "\xe1\xd7\x2c\xca\xad\xa8\x8f\xf9"
+ "\xac\xb3\x0e\xdb\xca\x2e\xe2\xb8"
+ "\x51\x71\xd9\x3c\x6c\xf1\x56\xf8"
+ "\xea\x9c\xf1\xfb\x0c\xe6\xb7\x10"
+ "\x1c\xf8\xa9\x7c\xe8\x53\x35\xc1"
+ "\x90\x3e\x76\x4a\x74\xa4\x21\x2c"
+ "\xf6\x2c\x4e\x0f\x94\x3a\x88\x2e"
+ "\x41\x09\x6a\x33\x7d\xf6\xdd\x3f"
+ "\x8d\x23\x31\x74\x84\xeb\x88\x6e"
+ "\xcc\xb9\xbc\x22\x83\x19\x07\x22"
+ "\xa5\x2d\xdf\xa5\xf3\x80\x85\x78"
+ "\x84\x39\x6a\x6d\x6a\x99\x4f\xa5"
+ "\x15\xfe\x46\xb0\xe4\x6c\xa5\x41"
+ "\x3c\xce\x8f\x42\x60\x71\xa7\x75"
+ "\x08\x40\x65\x8a\x82\xbf\xf5\x43"
+ "\x71\x96\xa9\x4d\x44\x8a\x20\xbe"
+ "\xfa\x4d\xbb\xc0\x7d\x31\x96\x65"
+ "\xe7\x75\xe5\x3e\xfd\x92\x3b\xc9"
+ "\x55\xbb\x16\x7e\xf7\xc2\x8c\xa4"
+ "\x40\x1d\xe5\xef\x0e\xdf\xe4\x9a"
+ "\x62\x73\x65\xfd\x46\x63\x25\x3d"
+ "\x2b\xaf\xe5\x64\xfe\xa5\x5c\xcf"
+ "\x24\xf3\xb4\xac\x64\xba\xdf\x4b"
+ "\xc6\x96\x7d\x81\x2d\x8d\x97\xf7"
+ "\xc5\x68\x77\x84\x32\x2b\xcc\x85"
+ "\x74\x96\xf0\x12\x77\x61\xb9\xeb"
+ "\x71\xaa\x82\xcb\x1c\xdb\x89\xc8"
+ "\xc6\xb5\xe3\x5c\x7d\x39\x07\x24"
+ "\xda\x39\x87\x45\xc0\x2b\xbb\x01"
+ "\xac\xbc\x2a\x5c\x7f\xfc\xe8\xce"
+ "\x6d\x9c\x6f\xed\xd3\xc1\xa1\xd6"
+ "\xc5\x55\xa9\x66\x2f\xe1\xc8\x32"
+ "\xa6\x5d\xa4\x3a\x98\x73\xe8\x45"
+ "\xa4\xc7\xa8\xb4\xf6\x13\x03\xf6"
+ "\xe9\x2e\xc4\x29\x0f\x84\xdb\xc4"
+ "\x21\xc4\xc2\x75\x67\x89\x37\x0a",
+ .rlen = 512,
+ }
+};
+
+static struct cipher_testvec aes_xts_enc_tv_template[] = {
+ /* http://grouper.ieee.org/groups/1619/email/pdf00086.pdf */
+ { /* XTS-AES 1 */
+ .key = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .klen = 32,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .input = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .ilen = 32,
+ .result = "\x91\x7c\xf6\x9e\xbd\x68\xb2\xec"
+ "\x9b\x9f\xe9\xa3\xea\xdd\xa6\x92"
+ "\xcd\x43\xd2\xf5\x95\x98\xed\x85"
+ "\x8c\x02\xc2\x65\x2f\xbf\x92\x2e",
+ .rlen = 32,
+ }, { /* XTS-AES 2 */
+ .key = "\x11\x11\x11\x11\x11\x11\x11\x11"
+ "\x11\x11\x11\x11\x11\x11\x11\x11"
+ "\x22\x22\x22\x22\x22\x22\x22\x22"
+ "\x22\x22\x22\x22\x22\x22\x22\x22",
+ .klen = 32,
+ .iv = "\x33\x33\x33\x33\x33\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .input = "\x44\x44\x44\x44\x44\x44\x44\x44"
+ "\x44\x44\x44\x44\x44\x44\x44\x44"
+ "\x44\x44\x44\x44\x44\x44\x44\x44"
+ "\x44\x44\x44\x44\x44\x44\x44\x44",
+ .ilen = 32,
+ .result = "\xc4\x54\x18\x5e\x6a\x16\x93\x6e"
+ "\x39\x33\x40\x38\xac\xef\x83\x8b"
+ "\xfb\x18\x6f\xff\x74\x80\xad\xc4"
+ "\x28\x93\x82\xec\xd6\xd3\x94\xf0",
+ .rlen = 32,
+ }, { /* XTS-AES 3 */
+ .key = "\xff\xfe\xfd\xfc\xfb\xfa\xf9\xf8"
+ "\xf7\xf6\xf5\xf4\xf3\xf2\xf1\xf0"
+ "\x22\x22\x22\x22\x22\x22\x22\x22"
+ "\x22\x22\x22\x22\x22\x22\x22\x22",
+ .klen = 32,
+ .iv = "\x33\x33\x33\x33\x33\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .input = "\x44\x44\x44\x44\x44\x44\x44\x44"
+ "\x44\x44\x44\x44\x44\x44\x44\x44"
+ "\x44\x44\x44\x44\x44\x44\x44\x44"
+ "\x44\x44\x44\x44\x44\x44\x44\x44",
+ .ilen = 32,
+ .result = "\xaf\x85\x33\x6b\x59\x7a\xfc\x1a"
+ "\x90\x0b\x2e\xb2\x1e\xc9\x49\xd2"
+ "\x92\xdf\x4c\x04\x7e\x0b\x21\x53"
+ "\x21\x86\xa5\x97\x1a\x22\x7a\x89",
+ .rlen = 32,
+ }, { /* XTS-AES 4 */
+ .key = "\x27\x18\x28\x18\x28\x45\x90\x45"
+ "\x23\x53\x60\x28\x74\x71\x35\x26"
+ "\x31\x41\x59\x26\x53\x58\x97\x93"
+ "\x23\x84\x62\x64\x33\x83\x27\x95",
+ .klen = 32,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .input = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
+ "\x20\x21\x22\x23\x24\x25\x26\x27"
+ "\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f"
+ "\x30\x31\x32\x33\x34\x35\x36\x37"
+ "\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f"
+ "\x40\x41\x42\x43\x44\x45\x46\x47"
+ "\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f"
+ "\x50\x51\x52\x53\x54\x55\x56\x57"
+ "\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f"
+ "\x60\x61\x62\x63\x64\x65\x66\x67"
+ "\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f"
+ "\x70\x71\x72\x73\x74\x75\x76\x77"
+ "\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f"
+ "\x80\x81\x82\x83\x84\x85\x86\x87"
+ "\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
+ "\x90\x91\x92\x93\x94\x95\x96\x97"
+ "\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
+ "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7"
+ "\xa8\xa9\xaa\xab\xac\xad\xae\xaf"
+ "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7"
+ "\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf"
+ "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
+ "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
+ "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7"
+ "\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf"
+ "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7"
+ "\xe8\xe9\xea\xeb\xec\xed\xee\xef"
+ "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7"
+ "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"
+ "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
+ "\x20\x21\x22\x23\x24\x25\x26\x27"
+ "\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f"
+ "\x30\x31\x32\x33\x34\x35\x36\x37"
+ "\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f"
+ "\x40\x41\x42\x43\x44\x45\x46\x47"
+ "\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f"
+ "\x50\x51\x52\x53\x54\x55\x56\x57"
+ "\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f"
+ "\x60\x61\x62\x63\x64\x65\x66\x67"
+ "\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f"
+ "\x70\x71\x72\x73\x74\x75\x76\x77"
+ "\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f"
+ "\x80\x81\x82\x83\x84\x85\x86\x87"
+ "\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
+ "\x90\x91\x92\x93\x94\x95\x96\x97"
+ "\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
+ "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7"
+ "\xa8\xa9\xaa\xab\xac\xad\xae\xaf"
+ "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7"
+ "\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf"
+ "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
+ "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
+ "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7"
+ "\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf"
+ "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7"
+ "\xe8\xe9\xea\xeb\xec\xed\xee\xef"
+ "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7"
+ "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff",
+ .ilen = 512,
+ .result = "\x27\xa7\x47\x9b\xef\xa1\xd4\x76"
+ "\x48\x9f\x30\x8c\xd4\xcf\xa6\xe2"
+ "\xa9\x6e\x4b\xbe\x32\x08\xff\x25"
+ "\x28\x7d\xd3\x81\x96\x16\xe8\x9c"
+ "\xc7\x8c\xf7\xf5\xe5\x43\x44\x5f"
+ "\x83\x33\xd8\xfa\x7f\x56\x00\x00"
+ "\x05\x27\x9f\xa5\xd8\xb5\xe4\xad"
+ "\x40\xe7\x36\xdd\xb4\xd3\x54\x12"
+ "\x32\x80\x63\xfd\x2a\xab\x53\xe5"
+ "\xea\x1e\x0a\x9f\x33\x25\x00\xa5"
+ "\xdf\x94\x87\xd0\x7a\x5c\x92\xcc"
+ "\x51\x2c\x88\x66\xc7\xe8\x60\xce"
+ "\x93\xfd\xf1\x66\xa2\x49\x12\xb4"
+ "\x22\x97\x61\x46\xae\x20\xce\x84"
+ "\x6b\xb7\xdc\x9b\xa9\x4a\x76\x7a"
+ "\xae\xf2\x0c\x0d\x61\xad\x02\x65"
+ "\x5e\xa9\x2d\xc4\xc4\xe4\x1a\x89"
+ "\x52\xc6\x51\xd3\x31\x74\xbe\x51"
+ "\xa1\x0c\x42\x11\x10\xe6\xd8\x15"
+ "\x88\xed\xe8\x21\x03\xa2\x52\xd8"
+ "\xa7\x50\xe8\x76\x8d\xef\xff\xed"
+ "\x91\x22\x81\x0a\xae\xb9\x9f\x91"
+ "\x72\xaf\x82\xb6\x04\xdc\x4b\x8e"
+ "\x51\xbc\xb0\x82\x35\xa6\xf4\x34"
+ "\x13\x32\xe4\xca\x60\x48\x2a\x4b"
+ "\xa1\xa0\x3b\x3e\x65\x00\x8f\xc5"
+ "\xda\x76\xb7\x0b\xf1\x69\x0d\xb4"
+ "\xea\xe2\x9c\x5f\x1b\xad\xd0\x3c"
+ "\x5c\xcf\x2a\x55\xd7\x05\xdd\xcd"
+ "\x86\xd4\x49\x51\x1c\xeb\x7e\xc3"
+ "\x0b\xf1\x2b\x1f\xa3\x5b\x91\x3f"
+ "\x9f\x74\x7a\x8a\xfd\x1b\x13\x0e"
+ "\x94\xbf\xf9\x4e\xff\xd0\x1a\x91"
+ "\x73\x5c\xa1\x72\x6a\xcd\x0b\x19"
+ "\x7c\x4e\x5b\x03\x39\x36\x97\xe1"
+ "\x26\x82\x6f\xb6\xbb\xde\x8e\xcc"
+ "\x1e\x08\x29\x85\x16\xe2\xc9\xed"
+ "\x03\xff\x3c\x1b\x78\x60\xf6\xde"
+ "\x76\xd4\xce\xcd\x94\xc8\x11\x98"
+ "\x55\xef\x52\x97\xca\x67\xe9\xf3"
+ "\xe7\xff\x72\xb1\xe9\x97\x85\xca"
+ "\x0a\x7e\x77\x20\xc5\xb3\x6d\xc6"
+ "\xd7\x2c\xac\x95\x74\xc8\xcb\xbc"
+ "\x2f\x80\x1e\x23\xe5\x6f\xd3\x44"
+ "\xb0\x7f\x22\x15\x4b\xeb\xa0\xf0"
+ "\x8c\xe8\x89\x1e\x64\x3e\xd9\x95"
+ "\xc9\x4d\x9a\x69\xc9\xf1\xb5\xf4"
+ "\x99\x02\x7a\x78\x57\x2a\xee\xbd"
+ "\x74\xd2\x0c\xc3\x98\x81\xc2\x13"
+ "\xee\x77\x0b\x10\x10\xe4\xbe\xa7"
+ "\x18\x84\x69\x77\xae\x11\x9f\x7a"
+ "\x02\x3a\xb5\x8c\xca\x0a\xd7\x52"
+ "\xaf\xe6\x56\xbb\x3c\x17\x25\x6a"
+ "\x9f\x6e\x9b\xf1\x9f\xdd\x5a\x38"
+ "\xfc\x82\xbb\xe8\x72\xc5\x53\x9e"
+ "\xdb\x60\x9e\xf4\xf7\x9c\x20\x3e"
+ "\xbb\x14\x0f\x2e\x58\x3c\xb2\xad"
+ "\x15\xb4\xaa\x5b\x65\x50\x16\xa8"
+ "\x44\x92\x77\xdb\xd4\x77\xef\x2c"
+ "\x8d\x6c\x01\x7d\xb7\x38\xb1\x8d"
+ "\xeb\x4a\x42\x7d\x19\x23\xce\x3f"
+ "\xf2\x62\x73\x57\x79\xa4\x18\xf2"
+ "\x0a\x28\x2d\xf9\x20\x14\x7b\xea"
+ "\xbe\x42\x1e\xe5\x31\x9d\x05\x68",
+ .rlen = 512,
+ }
+};
+
+static struct cipher_testvec aes_xts_dec_tv_template[] = {
+ /* http://grouper.ieee.org/groups/1619/email/pdf00086.pdf */
+ { /* XTS-AES 1 */
+ .key = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .klen = 32,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .input = "\x91\x7c\xf6\x9e\xbd\x68\xb2\xec"
+ "\x9b\x9f\xe9\xa3\xea\xdd\xa6\x92"
+ "\xcd\x43\xd2\xf5\x95\x98\xed\x85"
+ "\x8c\x02\xc2\x65\x2f\xbf\x92\x2e",
+ .ilen = 32,
+ .result = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .rlen = 32,
+ }, { /* XTS-AES 2 */
+ .key = "\x11\x11\x11\x11\x11\x11\x11\x11"
+ "\x11\x11\x11\x11\x11\x11\x11\x11"
+ "\x22\x22\x22\x22\x22\x22\x22\x22"
+ "\x22\x22\x22\x22\x22\x22\x22\x22",
+ .klen = 32,
+ .iv = "\x33\x33\x33\x33\x33\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .input = "\xc4\x54\x18\x5e\x6a\x16\x93\x6e"
+ "\x39\x33\x40\x38\xac\xef\x83\x8b"
+ "\xfb\x18\x6f\xff\x74\x80\xad\xc4"
+ "\x28\x93\x82\xec\xd6\xd3\x94\xf0",
+ .ilen = 32,
+ .result = "\x44\x44\x44\x44\x44\x44\x44\x44"
+ "\x44\x44\x44\x44\x44\x44\x44\x44"
+ "\x44\x44\x44\x44\x44\x44\x44\x44"
+ "\x44\x44\x44\x44\x44\x44\x44\x44",
+ .rlen = 32,
+ }, { /* XTS-AES 3 */
+ .key = "\xff\xfe\xfd\xfc\xfb\xfa\xf9\xf8"
+ "\xf7\xf6\xf5\xf4\xf3\xf2\xf1\xf0"
+ "\x22\x22\x22\x22\x22\x22\x22\x22"
+ "\x22\x22\x22\x22\x22\x22\x22\x22",
+ .klen = 32,
+ .iv = "\x33\x33\x33\x33\x33\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .input = "\xaf\x85\x33\x6b\x59\x7a\xfc\x1a"
+ "\x90\x0b\x2e\xb2\x1e\xc9\x49\xd2"
+ "\x92\xdf\x4c\x04\x7e\x0b\x21\x53"
+ "\x21\x86\xa5\x97\x1a\x22\x7a\x89",
+ .ilen = 32,
+ .result = "\x44\x44\x44\x44\x44\x44\x44\x44"
+ "\x44\x44\x44\x44\x44\x44\x44\x44"
+ "\x44\x44\x44\x44\x44\x44\x44\x44"
+ "\x44\x44\x44\x44\x44\x44\x44\x44",
+ .rlen = 32,
+ }, { /* XTS-AES 4 */
+ .key = "\x27\x18\x28\x18\x28\x45\x90\x45"
+ "\x23\x53\x60\x28\x74\x71\x35\x26"
+ "\x31\x41\x59\x26\x53\x58\x97\x93"
+ "\x23\x84\x62\x64\x33\x83\x27\x95",
+ .klen = 32,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .input = "\x27\xa7\x47\x9b\xef\xa1\xd4\x76"
+ "\x48\x9f\x30\x8c\xd4\xcf\xa6\xe2"
+ "\xa9\x6e\x4b\xbe\x32\x08\xff\x25"
+ "\x28\x7d\xd3\x81\x96\x16\xe8\x9c"
+ "\xc7\x8c\xf7\xf5\xe5\x43\x44\x5f"
+ "\x83\x33\xd8\xfa\x7f\x56\x00\x00"
+ "\x05\x27\x9f\xa5\xd8\xb5\xe4\xad"
+ "\x40\xe7\x36\xdd\xb4\xd3\x54\x12"
+ "\x32\x80\x63\xfd\x2a\xab\x53\xe5"
+ "\xea\x1e\x0a\x9f\x33\x25\x00\xa5"
+ "\xdf\x94\x87\xd0\x7a\x5c\x92\xcc"
+ "\x51\x2c\x88\x66\xc7\xe8\x60\xce"
+ "\x93\xfd\xf1\x66\xa2\x49\x12\xb4"
+ "\x22\x97\x61\x46\xae\x20\xce\x84"
+ "\x6b\xb7\xdc\x9b\xa9\x4a\x76\x7a"
+ "\xae\xf2\x0c\x0d\x61\xad\x02\x65"
+ "\x5e\xa9\x2d\xc4\xc4\xe4\x1a\x89"
+ "\x52\xc6\x51\xd3\x31\x74\xbe\x51"
+ "\xa1\x0c\x42\x11\x10\xe6\xd8\x15"
+ "\x88\xed\xe8\x21\x03\xa2\x52\xd8"
+ "\xa7\x50\xe8\x76\x8d\xef\xff\xed"
+ "\x91\x22\x81\x0a\xae\xb9\x9f\x91"
+ "\x72\xaf\x82\xb6\x04\xdc\x4b\x8e"
+ "\x51\xbc\xb0\x82\x35\xa6\xf4\x34"
+ "\x13\x32\xe4\xca\x60\x48\x2a\x4b"
+ "\xa1\xa0\x3b\x3e\x65\x00\x8f\xc5"
+ "\xda\x76\xb7\x0b\xf1\x69\x0d\xb4"
+ "\xea\xe2\x9c\x5f\x1b\xad\xd0\x3c"
+ "\x5c\xcf\x2a\x55\xd7\x05\xdd\xcd"
+ "\x86\xd4\x49\x51\x1c\xeb\x7e\xc3"
+ "\x0b\xf1\x2b\x1f\xa3\x5b\x91\x3f"
+ "\x9f\x74\x7a\x8a\xfd\x1b\x13\x0e"
+ "\x94\xbf\xf9\x4e\xff\xd0\x1a\x91"
+ "\x73\x5c\xa1\x72\x6a\xcd\x0b\x19"
+ "\x7c\x4e\x5b\x03\x39\x36\x97\xe1"
+ "\x26\x82\x6f\xb6\xbb\xde\x8e\xcc"
+ "\x1e\x08\x29\x85\x16\xe2\xc9\xed"
+ "\x03\xff\x3c\x1b\x78\x60\xf6\xde"
+ "\x76\xd4\xce\xcd\x94\xc8\x11\x98"
+ "\x55\xef\x52\x97\xca\x67\xe9\xf3"
+ "\xe7\xff\x72\xb1\xe9\x97\x85\xca"
+ "\x0a\x7e\x77\x20\xc5\xb3\x6d\xc6"
+ "\xd7\x2c\xac\x95\x74\xc8\xcb\xbc"
+ "\x2f\x80\x1e\x23\xe5\x6f\xd3\x44"
+ "\xb0\x7f\x22\x15\x4b\xeb\xa0\xf0"
+ "\x8c\xe8\x89\x1e\x64\x3e\xd9\x95"
+ "\xc9\x4d\x9a\x69\xc9\xf1\xb5\xf4"
+ "\x99\x02\x7a\x78\x57\x2a\xee\xbd"
+ "\x74\xd2\x0c\xc3\x98\x81\xc2\x13"
+ "\xee\x77\x0b\x10\x10\xe4\xbe\xa7"
+ "\x18\x84\x69\x77\xae\x11\x9f\x7a"
+ "\x02\x3a\xb5\x8c\xca\x0a\xd7\x52"
+ "\xaf\xe6\x56\xbb\x3c\x17\x25\x6a"
+ "\x9f\x6e\x9b\xf1\x9f\xdd\x5a\x38"
+ "\xfc\x82\xbb\xe8\x72\xc5\x53\x9e"
+ "\xdb\x60\x9e\xf4\xf7\x9c\x20\x3e"
+ "\xbb\x14\x0f\x2e\x58\x3c\xb2\xad"
+ "\x15\xb4\xaa\x5b\x65\x50\x16\xa8"
+ "\x44\x92\x77\xdb\xd4\x77\xef\x2c"
+ "\x8d\x6c\x01\x7d\xb7\x38\xb1\x8d"
+ "\xeb\x4a\x42\x7d\x19\x23\xce\x3f"
+ "\xf2\x62\x73\x57\x79\xa4\x18\xf2"
+ "\x0a\x28\x2d\xf9\x20\x14\x7b\xea"
+ "\xbe\x42\x1e\xe5\x31\x9d\x05\x68",
+ .ilen = 512,
+ .result = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
+ "\x20\x21\x22\x23\x24\x25\x26\x27"
+ "\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f"
+ "\x30\x31\x32\x33\x34\x35\x36\x37"
+ "\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f"
+ "\x40\x41\x42\x43\x44\x45\x46\x47"
+ "\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f"
+ "\x50\x51\x52\x53\x54\x55\x56\x57"
+ "\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f"
+ "\x60\x61\x62\x63\x64\x65\x66\x67"
+ "\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f"
+ "\x70\x71\x72\x73\x74\x75\x76\x77"
+ "\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f"
+ "\x80\x81\x82\x83\x84\x85\x86\x87"
+ "\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
+ "\x90\x91\x92\x93\x94\x95\x96\x97"
+ "\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
+ "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7"
+ "\xa8\xa9\xaa\xab\xac\xad\xae\xaf"
+ "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7"
+ "\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf"
+ "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
+ "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
+ "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7"
+ "\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf"
+ "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7"
+ "\xe8\xe9\xea\xeb\xec\xed\xee\xef"
+ "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7"
+ "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"
+ "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
+ "\x20\x21\x22\x23\x24\x25\x26\x27"
+ "\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f"
+ "\x30\x31\x32\x33\x34\x35\x36\x37"
+ "\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f"
+ "\x40\x41\x42\x43\x44\x45\x46\x47"
+ "\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f"
+ "\x50\x51\x52\x53\x54\x55\x56\x57"
+ "\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f"
+ "\x60\x61\x62\x63\x64\x65\x66\x67"
+ "\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f"
+ "\x70\x71\x72\x73\x74\x75\x76\x77"
+ "\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f"
+ "\x80\x81\x82\x83\x84\x85\x86\x87"
+ "\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
+ "\x90\x91\x92\x93\x94\x95\x96\x97"
+ "\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
+ "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7"
+ "\xa8\xa9\xaa\xab\xac\xad\xae\xaf"
+ "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7"
+ "\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf"
+ "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
+ "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
+ "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7"
+ "\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf"
+ "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7"
+ "\xe8\xe9\xea\xeb\xec\xed\xee\xef"
+ "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7"
+ "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff",
+ .rlen = 512,
+ }
+};
+
+#endif
+
+static struct cipher_testvec aes_ctr_enc_tv_template[] = {
+ { /* From NIST Special Publication 800-38A, Appendix F.5 */
+ .key = "\x2b\x7e\x15\x16\x28\xae\xd2\xa6"
+ "\xab\xf7\x15\x88\x09\xcf\x4f\x3c",
+ .klen = 16,
+ .iv = "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7"
+ "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff",
+ .input = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96"
+ "\xe9\x3d\x7e\x11\x73\x93\x17\x2a"
+ "\xae\x2d\x8a\x57\x1e\x03\xac\x9c"
+ "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51"
+ "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11"
+ "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef"
+ "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17"
+ "\xad\x2b\x41\x7b\xe6\x6c\x37\x10",
+ .ilen = 64,
+ .result = "\x87\x4d\x61\x91\xb6\x20\xe3\x26"
+ "\x1b\xef\x68\x64\x99\x0d\xb6\xce"
+ "\x98\x06\xf6\x6b\x79\x70\xfd\xff"
+ "\x86\x17\x18\x7b\xb9\xff\xfd\xff"
+ "\x5a\xe4\xdf\x3e\xdb\xd5\xd3\x5e"
+ "\x5b\x4f\x09\x02\x0d\xb0\x3e\xab"
+ "\x1e\x03\x1d\xda\x2f\xbe\x03\xd1"
+ "\x79\x21\x70\xa0\xf3\x00\x9c\xee",
+ .rlen = 64,
+ }, {
+ .key = "\x8e\x73\xb0\xf7\xda\x0e\x64\x52"
+ "\xc8\x10\xf3\x2b\x80\x90\x79\xe5"
+ "\x62\xf8\xea\xd2\x52\x2c\x6b\x7b",
+ .klen = 24,
+ .iv = "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7"
+ "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff",
+ .input = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96"
+ "\xe9\x3d\x7e\x11\x73\x93\x17\x2a"
+ "\xae\x2d\x8a\x57\x1e\x03\xac\x9c"
+ "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51"
+ "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11"
+ "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef"
+ "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17"
+ "\xad\x2b\x41\x7b\xe6\x6c\x37\x10",
+ .ilen = 64,
+ .result = "\x1a\xbc\x93\x24\x17\x52\x1c\xa2"
+ "\x4f\x2b\x04\x59\xfe\x7e\x6e\x0b"
+ "\x09\x03\x39\xec\x0a\xa6\xfa\xef"
+ "\xd5\xcc\xc2\xc6\xf4\xce\x8e\x94"
+ "\x1e\x36\xb2\x6b\xd1\xeb\xc6\x70"
+ "\xd1\xbd\x1d\x66\x56\x20\xab\xf7"
+ "\x4f\x78\xa7\xf6\xd2\x98\x09\x58"
+ "\x5a\x97\xda\xec\x58\xc6\xb0\x50",
+ .rlen = 64,
+ }, {
+ .key = "\x60\x3d\xeb\x10\x15\xca\x71\xbe"
+ "\x2b\x73\xae\xf0\x85\x7d\x77\x81"
+ "\x1f\x35\x2c\x07\x3b\x61\x08\xd7"
+ "\x2d\x98\x10\xa3\x09\x14\xdf\xf4",
+ .klen = 32,
+ .iv = "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7"
+ "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff",
+ .input = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96"
+ "\xe9\x3d\x7e\x11\x73\x93\x17\x2a"
+ "\xae\x2d\x8a\x57\x1e\x03\xac\x9c"
+ "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51"
+ "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11"
+ "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef"
+ "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17"
+ "\xad\x2b\x41\x7b\xe6\x6c\x37\x10",
+ .ilen = 64,
+ .result = "\x60\x1e\xc3\x13\x77\x57\x89\xa5"
+ "\xb7\xa7\xf5\x04\xbb\xf3\xd2\x28"
+ "\xf4\x43\xe3\xca\x4d\x62\xb5\x9a"
+ "\xca\x84\xe9\x90\xca\xca\xf5\xc5"
+ "\x2b\x09\x30\xda\xa2\x3d\xe9\x4c"
+ "\xe8\x70\x17\xba\x2d\x84\x98\x8d"
+ "\xdf\xc9\xc5\x8d\xb6\x7a\xad\xa6"
+ "\x13\xc2\xdd\x08\x45\x79\x41\xa6",
+ .rlen = 64,
+ }
+};
+
+static struct cipher_testvec aes_ctr_dec_tv_template[] = {
+ { /* From NIST Special Publication 800-38A, Appendix F.5 */
+ .key = "\x2b\x7e\x15\x16\x28\xae\xd2\xa6"
+ "\xab\xf7\x15\x88\x09\xcf\x4f\x3c",
+ .klen = 16,
+ .iv = "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7"
+ "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff",
+ .input = "\x87\x4d\x61\x91\xb6\x20\xe3\x26"
+ "\x1b\xef\x68\x64\x99\x0d\xb6\xce"
+ "\x98\x06\xf6\x6b\x79\x70\xfd\xff"
+ "\x86\x17\x18\x7b\xb9\xff\xfd\xff"
+ "\x5a\xe4\xdf\x3e\xdb\xd5\xd3\x5e"
+ "\x5b\x4f\x09\x02\x0d\xb0\x3e\xab"
+ "\x1e\x03\x1d\xda\x2f\xbe\x03\xd1"
+ "\x79\x21\x70\xa0\xf3\x00\x9c\xee",
+ .ilen = 64,
+ .result = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96"
+ "\xe9\x3d\x7e\x11\x73\x93\x17\x2a"
+ "\xae\x2d\x8a\x57\x1e\x03\xac\x9c"
+ "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51"
+ "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11"
+ "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef"
+ "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17"
+ "\xad\x2b\x41\x7b\xe6\x6c\x37\x10",
+ .rlen = 64,
+ }, {
+ .key = "\x8e\x73\xb0\xf7\xda\x0e\x64\x52"
+ "\xc8\x10\xf3\x2b\x80\x90\x79\xe5"
+ "\x62\xf8\xea\xd2\x52\x2c\x6b\x7b",
+ .klen = 24,
+ .iv = "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7"
+ "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff",
+ .input = "\x1a\xbc\x93\x24\x17\x52\x1c\xa2"
+ "\x4f\x2b\x04\x59\xfe\x7e\x6e\x0b"
+ "\x09\x03\x39\xec\x0a\xa6\xfa\xef"
+ "\xd5\xcc\xc2\xc6\xf4\xce\x8e\x94"
+ "\x1e\x36\xb2\x6b\xd1\xeb\xc6\x70"
+ "\xd1\xbd\x1d\x66\x56\x20\xab\xf7"
+ "\x4f\x78\xa7\xf6\xd2\x98\x09\x58"
+ "\x5a\x97\xda\xec\x58\xc6\xb0\x50",
+ .ilen = 64,
+ .result = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96"
+ "\xe9\x3d\x7e\x11\x73\x93\x17\x2a"
+ "\xae\x2d\x8a\x57\x1e\x03\xac\x9c"
+ "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51"
+ "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11"
+ "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef"
+ "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17"
+ "\xad\x2b\x41\x7b\xe6\x6c\x37\x10",
+ .rlen = 64,
+ }, {
+ .key = "\x60\x3d\xeb\x10\x15\xca\x71\xbe"
+ "\x2b\x73\xae\xf0\x85\x7d\x77\x81"
+ "\x1f\x35\x2c\x07\x3b\x61\x08\xd7"
+ "\x2d\x98\x10\xa3\x09\x14\xdf\xf4",
+ .klen = 32,
+ .iv = "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7"
+ "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff",
+ .input = "\x60\x1e\xc3\x13\x77\x57\x89\xa5"
+ "\xb7\xa7\xf5\x04\xbb\xf3\xd2\x28"
+ "\xf4\x43\xe3\xca\x4d\x62\xb5\x9a"
+ "\xca\x84\xe9\x90\xca\xca\xf5\xc5"
+ "\x2b\x09\x30\xda\xa2\x3d\xe9\x4c"
+ "\xe8\x70\x17\xba\x2d\x84\x98\x8d"
+ "\xdf\xc9\xc5\x8d\xb6\x7a\xad\xa6"
+ "\x13\xc2\xdd\x08\x45\x79\x41\xa6",
+ .ilen = 64,
+ .result = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96"
+ "\xe9\x3d\x7e\x11\x73\x93\x17\x2a"
+ "\xae\x2d\x8a\x57\x1e\x03\xac\x9c"
+ "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51"
+ "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11"
+ "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef"
+ "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17"
+ "\xad\x2b\x41\x7b\xe6\x6c\x37\x10",
+ .rlen = 64,
+ }
+};
+
+static struct cipher_testvec aes_ctr_rfc3686_enc_tv_template[] = {
+ { /* From RFC 3686 */
+ .key = "\xae\x68\x52\xf8\x12\x10\x67\xcc"
+ "\x4b\xf7\xa5\x76\x55\x77\xf3\x9e"
+ "\x00\x00\x00\x30",
+ .klen = 20,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .input = "Single block msg",
+ .ilen = 16,
+ .result = "\xe4\x09\x5d\x4f\xb7\xa7\xb3\x79"
+ "\x2d\x61\x75\xa3\x26\x13\x11\xb8",
+ .rlen = 16,
+ }, {
+ .key = "\x7e\x24\x06\x78\x17\xfa\xe0\xd7"
+ "\x43\xd6\xce\x1f\x32\x53\x91\x63"
+ "\x00\x6c\xb6\xdb",
+ .klen = 20,
+ .iv = "\xc0\x54\x3b\x59\xda\x48\xd9\x0b",
+ .input = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
+ .ilen = 32,
+ .result = "\x51\x04\xa1\x06\x16\x8a\x72\xd9"
+ "\x79\x0d\x41\xee\x8e\xda\xd3\x88"
+ "\xeb\x2e\x1e\xfc\x46\xda\x57\xc8"
+ "\xfc\xe6\x30\xdf\x91\x41\xbe\x28",
+ .rlen = 32,
+ }, {
+ .key = "\x16\xaf\x5b\x14\x5f\xc9\xf5\x79"
+ "\xc1\x75\xf9\x3e\x3b\xfb\x0e\xed"
+ "\x86\x3d\x06\xcc\xfd\xb7\x85\x15"
+ "\x00\x00\x00\x48",
+ .klen = 28,
+ .iv = "\x36\x73\x3c\x14\x7d\x6d\x93\xcb",
+ .input = "Single block msg",
+ .ilen = 16,
+ .result = "\x4b\x55\x38\x4f\xe2\x59\xc9\xc8"
+ "\x4e\x79\x35\xa0\x03\xcb\xe9\x28",
+ .rlen = 16,
+ }, {
+ .key = "\x7c\x5c\xb2\x40\x1b\x3d\xc3\x3c"
+ "\x19\xe7\x34\x08\x19\xe0\xf6\x9c"
+ "\x67\x8c\x3d\xb8\xe6\xf6\xa9\x1a"
+ "\x00\x96\xb0\x3b",
+ .klen = 28,
+ .iv = "\x02\x0c\x6e\xad\xc2\xcb\x50\x0d",
+ .input = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
+ .ilen = 32,
+ .result = "\x45\x32\x43\xfc\x60\x9b\x23\x32"
+ "\x7e\xdf\xaa\xfa\x71\x31\xcd\x9f"
+ "\x84\x90\x70\x1c\x5a\xd4\xa7\x9c"
+ "\xfc\x1f\xe0\xff\x42\xf4\xfb\x00",
+ .rlen = 32,
+ }, {
+ .key = "\x77\x6b\xef\xf2\x85\x1d\xb0\x6f"
+ "\x4c\x8a\x05\x42\xc8\x69\x6f\x6c"
+ "\x6a\x81\xaf\x1e\xec\x96\xb4\xd3"
+ "\x7f\xc1\xd6\x89\xe6\xc1\xc1\x04"
+ "\x00\x00\x00\x60",
+ .klen = 36,
+ .iv = "\xdb\x56\x72\xc9\x7a\xa8\xf0\xb2",
+ .input = "Single block msg",
+ .ilen = 16,
+ .result = "\x14\x5a\xd0\x1d\xbf\x82\x4e\xc7"
+ "\x56\x08\x63\xdc\x71\xe3\xe0\xc0",
+ .rlen = 16,
+ }, {
+ .key = "\xf6\xd6\x6d\x6b\xd5\x2d\x59\xbb"
+ "\x07\x96\x36\x58\x79\xef\xf8\x86"
+ "\xc6\x6d\xd5\x1a\x5b\x6a\x99\x74"
+ "\x4b\x50\x59\x0c\x87\xa2\x38\x84"
+ "\x00\xfa\xac\x24",
+ .klen = 36,
+ .iv = "\xc1\x58\x5e\xf1\x5a\x43\xd8\x75",
+ .input = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
+ .ilen = 32,
+ .result = "\xf0\x5e\x23\x1b\x38\x94\x61\x2c"
+ "\x49\xee\x00\x0b\x80\x4e\xb2\xa9"
+ "\xb8\x30\x6b\x50\x8f\x83\x9d\x6a"
+ "\x55\x30\x83\x1d\x93\x44\xaf\x1c",
+ .rlen = 32,
+ }, {
+#if 0
+ // generated using Crypto++
+ .key = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
+ "\x00\x00\x00\x00",
+ .klen = 32 + 4,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .input =
+ "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
+ "\x20\x21\x22\x23\x24\x25\x26\x27"
+ "\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f"
+ "\x30\x31\x32\x33\x34\x35\x36\x37"
+ "\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f"
+ "\x40\x41\x42\x43\x44\x45\x46\x47"
+ "\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f"
+ "\x50\x51\x52\x53\x54\x55\x56\x57"
+ "\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f"
+ "\x60\x61\x62\x63\x64\x65\x66\x67"
+ "\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f"
+ "\x70\x71\x72\x73\x74\x75\x76\x77"
+ "\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f"
+ "\x80\x81\x82\x83\x84\x85\x86\x87"
+ "\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
+ "\x90\x91\x92\x93\x94\x95\x96\x97"
+ "\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
+ "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7"
+ "\xa8\xa9\xaa\xab\xac\xad\xae\xaf"
+ "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7"
+ "\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf"
+ "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
+ "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
+ "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7"
+ "\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf"
+ "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7"
+ "\xe8\xe9\xea\xeb\xec\xed\xee\xef"
+ "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7"
+ "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"
+ "\x00\x03\x06\x09\x0c\x0f\x12\x15"
+ "\x18\x1b\x1e\x21\x24\x27\x2a\x2d"
+ "\x30\x33\x36\x39\x3c\x3f\x42\x45"
+ "\x48\x4b\x4e\x51\x54\x57\x5a\x5d"
+ "\x60\x63\x66\x69\x6c\x6f\x72\x75"
+ "\x78\x7b\x7e\x81\x84\x87\x8a\x8d"
+ "\x90\x93\x96\x99\x9c\x9f\xa2\xa5"
+ "\xa8\xab\xae\xb1\xb4\xb7\xba\xbd"
+ "\xc0\xc3\xc6\xc9\xcc\xcf\xd2\xd5"
+ "\xd8\xdb\xde\xe1\xe4\xe7\xea\xed"
+ "\xf0\xf3\xf6\xf9\xfc\xff\x02\x05"
+ "\x08\x0b\x0e\x11\x14\x17\x1a\x1d"
+ "\x20\x23\x26\x29\x2c\x2f\x32\x35"
+ "\x38\x3b\x3e\x41\x44\x47\x4a\x4d"
+ "\x50\x53\x56\x59\x5c\x5f\x62\x65"
+ "\x68\x6b\x6e\x71\x74\x77\x7a\x7d"
+ "\x80\x83\x86\x89\x8c\x8f\x92\x95"
+ "\x98\x9b\x9e\xa1\xa4\xa7\xaa\xad"
+ "\xb0\xb3\xb6\xb9\xbc\xbf\xc2\xc5"
+ "\xc8\xcb\xce\xd1\xd4\xd7\xda\xdd"
+ "\xe0\xe3\xe6\xe9\xec\xef\xf2\xf5"
+ "\xf8\xfb\xfe\x01\x04\x07\x0a\x0d"
+ "\x10\x13\x16\x19\x1c\x1f\x22\x25"
+ "\x28\x2b\x2e\x31\x34\x37\x3a\x3d"
+ "\x40\x43\x46\x49\x4c\x4f\x52\x55"
+ "\x58\x5b\x5e\x61\x64\x67\x6a\x6d"
+ "\x70\x73\x76\x79\x7c\x7f\x82\x85"
+ "\x88\x8b\x8e\x91\x94\x97\x9a\x9d"
+ "\xa0\xa3\xa6\xa9\xac\xaf\xb2\xb5"
+ "\xb8\xbb\xbe\xc1\xc4\xc7\xca\xcd"
+ "\xd0\xd3\xd6\xd9\xdc\xdf\xe2\xe5"
+ "\xe8\xeb\xee\xf1\xf4\xf7\xfa\xfd"
+ "\x00\x05\x0a\x0f\x14\x19\x1e\x23"
+ "\x28\x2d\x32\x37\x3c\x41\x46\x4b"
+ "\x50\x55\x5a\x5f\x64\x69\x6e\x73"
+ "\x78\x7d\x82\x87\x8c\x91\x96\x9b"
+ "\xa0\xa5\xaa\xaf\xb4\xb9\xbe\xc3"
+ "\xc8\xcd\xd2\xd7\xdc\xe1\xe6\xeb"
+ "\xf0\xf5\xfa\xff\x04\x09\x0e\x13"
+ "\x18\x1d\x22\x27\x2c\x31\x36\x3b"
+ "\x40\x45\x4a\x4f\x54\x59\x5e\x63"
+ "\x68\x6d\x72\x77\x7c\x81\x86\x8b"
+ "\x90\x95\x9a\x9f\xa4\xa9\xae\xb3"
+ "\xb8\xbd\xc2\xc7\xcc\xd1\xd6\xdb"
+ "\xe0\xe5\xea\xef\xf4\xf9\xfe\x03"
+ "\x08\x0d\x12\x17\x1c\x21\x26\x2b"
+ "\x30\x35\x3a\x3f\x44\x49\x4e\x53"
+ "\x58\x5d\x62\x67\x6c\x71\x76\x7b"
+ "\x80\x85\x8a\x8f\x94\x99\x9e\xa3"
+ "\xa8\xad\xb2\xb7\xbc\xc1\xc6\xcb"
+ "\xd0\xd5\xda\xdf\xe4\xe9\xee\xf3"
+ "\xf8\xfd\x02\x07\x0c\x11\x16\x1b"
+ "\x20\x25\x2a\x2f\x34\x39\x3e\x43"
+ "\x48\x4d\x52\x57\x5c\x61\x66\x6b"
+ "\x70\x75\x7a\x7f\x84\x89\x8e\x93"
+ "\x98\x9d\xa2\xa7\xac\xb1\xb6\xbb"
+ "\xc0\xc5\xca\xcf\xd4\xd9\xde\xe3"
+ "\xe8\xed\xf2\xf7\xfc\x01\x06\x0b"
+ "\x10\x15\x1a\x1f\x24\x29\x2e\x33"
+ "\x38\x3d\x42\x47\x4c\x51\x56\x5b"
+ "\x60\x65\x6a\x6f\x74\x79\x7e\x83"
+ "\x88\x8d\x92\x97\x9c\xa1\xa6\xab"
+ "\xb0\xb5\xba\xbf\xc4\xc9\xce\xd3"
+ "\xd8\xdd\xe2\xe7\xec\xf1\xf6\xfb"
+ "\x00\x07\x0e\x15\x1c\x23\x2a\x31"
+ "\x38\x3f\x46\x4d\x54\x5b\x62\x69"
+ "\x70\x77\x7e\x85\x8c\x93\x9a\xa1"
+ "\xa8\xaf\xb6\xbd\xc4\xcb\xd2\xd9"
+ "\xe0\xe7\xee\xf5\xfc\x03\x0a\x11"
+ "\x18\x1f\x26\x2d\x34\x3b\x42\x49"
+ "\x50\x57\x5e\x65\x6c\x73\x7a\x81"
+ "\x88\x8f\x96\x9d\xa4\xab\xb2\xb9"
+ "\xc0\xc7\xce\xd5\xdc\xe3\xea\xf1"
+ "\xf8\xff\x06\x0d\x14\x1b\x22\x29"
+ "\x30\x37\x3e\x45\x4c\x53\x5a\x61"
+ "\x68\x6f\x76\x7d\x84\x8b\x92\x99"
+ "\xa0\xa7\xae\xb5\xbc\xc3\xca\xd1"
+ "\xd8\xdf\xe6\xed\xf4\xfb\x02\x09"
+ "\x10\x17\x1e\x25\x2c\x33\x3a\x41"
+ "\x48\x4f\x56\x5d\x64\x6b\x72\x79"
+ "\x80\x87\x8e\x95\x9c\xa3\xaa\xb1"
+ "\xb8\xbf\xc6\xcd\xd4\xdb\xe2\xe9"
+ "\xf0\xf7\xfe\x05\x0c\x13\x1a\x21"
+ "\x28\x2f\x36\x3d\x44\x4b\x52\x59"
+ "\x60\x67\x6e\x75\x7c\x83\x8a\x91"
+ "\x98\x9f\xa6\xad\xb4\xbb\xc2\xc9"
+ "\xd0\xd7\xde\xe5\xec\xf3\xfa\x01"
+ "\x08\x0f\x16\x1d\x24\x2b\x32\x39"
+ "\x40\x47\x4e\x55\x5c\x63\x6a\x71"
+ "\x78\x7f\x86\x8d\x94\x9b\xa2\xa9"
+ "\xb0\xb7\xbe\xc5\xcc\xd3\xda\xe1"
+ "\xe8\xef\xf6\xfd\x04\x0b\x12\x19"
+ "\x20\x27\x2e\x35\x3c\x43\x4a\x51"
+ "\x58\x5f\x66\x6d\x74\x7b\x82\x89"
+ "\x90\x97\x9e\xa5\xac\xb3\xba\xc1"
+ "\xc8\xcf\xd6\xdd\xe4\xeb\xf2\xf9"
+ "\x00\x09\x12\x1b\x24\x2d\x36\x3f"
+ "\x48\x51\x5a\x63\x6c\x75\x7e\x87"
+ "\x90\x99\xa2\xab\xb4\xbd\xc6\xcf"
+ "\xd8\xe1\xea\xf3\xfc\x05\x0e\x17"
+ "\x20\x29\x32\x3b\x44\x4d\x56\x5f"
+ "\x68\x71\x7a\x83\x8c\x95\x9e\xa7"
+ "\xb0\xb9\xc2\xcb\xd4\xdd\xe6\xef"
+ "\xf8\x01\x0a\x13\x1c\x25\x2e\x37"
+ "\x40\x49\x52\x5b\x64\x6d\x76\x7f"
+ "\x88\x91\x9a\xa3\xac\xb5\xbe\xc7"
+ "\xd0\xd9\xe2\xeb\xf4\xfd\x06\x0f"
+ "\x18\x21\x2a\x33\x3c\x45\x4e\x57"
+ "\x60\x69\x72\x7b\x84\x8d\x96\x9f"
+ "\xa8\xb1\xba\xc3\xcc\xd5\xde\xe7"
+ "\xf0\xf9\x02\x0b\x14\x1d\x26\x2f"
+ "\x38\x41\x4a\x53\x5c\x65\x6e\x77"
+ "\x80\x89\x92\x9b\xa4\xad\xb6\xbf"
+ "\xc8\xd1\xda\xe3\xec\xf5\xfe\x07"
+ "\x10\x19\x22\x2b\x34\x3d\x46\x4f"
+ "\x58\x61\x6a\x73\x7c\x85\x8e\x97"
+ "\xa0\xa9\xb2\xbb\xc4\xcd\xd6\xdf"
+ "\xe8\xf1\xfa\x03\x0c\x15\x1e\x27"
+ "\x30\x39\x42\x4b\x54\x5d\x66\x6f"
+ "\x78\x81\x8a\x93\x9c\xa5\xae\xb7"
+ "\xc0\xc9\xd2\xdb\xe4\xed\xf6\xff"
+ "\x08\x11\x1a\x23\x2c\x35\x3e\x47"
+ "\x50\x59\x62\x6b\x74\x7d\x86\x8f"
+ "\x98\xa1\xaa\xb3\xbc\xc5\xce\xd7"
+ "\xe0\xe9\xf2\xfb\x04\x0d\x16\x1f"
+ "\x28\x31\x3a\x43\x4c\x55\x5e\x67"
+ "\x70\x79\x82\x8b\x94\x9d\xa6\xaf"
+ "\xb8\xc1\xca\xd3\xdc\xe5\xee\xf7"
+ "\x00\x0b\x16\x21\x2c\x37\x42\x4d"
+ "\x58\x63\x6e\x79\x84\x8f\x9a\xa5"
+ "\xb0\xbb\xc6\xd1\xdc\xe7\xf2\xfd"
+ "\x08\x13\x1e\x29\x34\x3f\x4a\x55"
+ "\x60\x6b\x76\x81\x8c\x97\xa2\xad"
+ "\xb8\xc3\xce\xd9\xe4\xef\xfa\x05"
+ "\x10\x1b\x26\x31\x3c\x47\x52\x5d"
+ "\x68\x73\x7e\x89\x94\x9f\xaa\xb5"
+ "\xc0\xcb\xd6\xe1\xec\xf7\x02\x0d"
+ "\x18\x23\x2e\x39\x44\x4f\x5a\x65"
+ "\x70\x7b\x86\x91\x9c\xa7\xb2\xbd"
+ "\xc8\xd3\xde\xe9\xf4\xff\x0a\x15"
+ "\x20\x2b\x36\x41\x4c\x57\x62\x6d"
+ "\x78\x83\x8e\x99\xa4\xaf\xba\xc5"
+ "\xd0\xdb\xe6\xf1\xfc\x07\x12\x1d"
+ "\x28\x33\x3e\x49\x54\x5f\x6a\x75"
+ "\x80\x8b\x96\xa1\xac\xb7\xc2\xcd"
+ "\xd8\xe3\xee\xf9\x04\x0f\x1a\x25"
+ "\x30\x3b\x46\x51\x5c\x67\x72\x7d"
+ "\x88\x93\x9e\xa9\xb4\xbf\xca\xd5"
+ "\xe0\xeb\xf6\x01\x0c\x17\x22\x2d"
+ "\x38\x43\x4e\x59\x64\x6f\x7a\x85"
+ "\x90\x9b\xa6\xb1\xbc\xc7\xd2\xdd"
+ "\xe8\xf3\xfe\x09\x14\x1f\x2a\x35"
+ "\x40\x4b\x56\x61\x6c\x77\x82\x8d"
+ "\x98\xa3\xae\xb9\xc4\xcf\xda\xe5"
+ "\xf0\xfb\x06\x11\x1c\x27\x32\x3d"
+ "\x48\x53\x5e\x69\x74\x7f\x8a\x95"
+ "\xa0\xab\xb6\xc1\xcc\xd7\xe2\xed"
+ "\xf8\x03\x0e\x19\x24\x2f\x3a\x45"
+ "\x50\x5b\x66\x71\x7c\x87\x92\x9d"
+ "\xa8\xb3\xbe\xc9\xd4\xdf\xea\xf5"
+ "\x00\x0d\x1a\x27\x34\x41\x4e\x5b"
+ "\x68\x75\x82\x8f\x9c\xa9\xb6\xc3"
+ "\xd0\xdd\xea\xf7\x04\x11\x1e\x2b"
+ "\x38\x45\x52\x5f\x6c\x79\x86\x93"
+ "\xa0\xad\xba\xc7\xd4\xe1\xee\xfb"
+ "\x08\x15\x22\x2f\x3c\x49\x56\x63"
+ "\x70\x7d\x8a\x97\xa4\xb1\xbe\xcb"
+ "\xd8\xe5\xf2\xff\x0c\x19\x26\x33"
+ "\x40\x4d\x5a\x67\x74\x81\x8e\x9b"
+ "\xa8\xb5\xc2\xcf\xdc\xe9\xf6\x03"
+ "\x10\x1d\x2a\x37\x44\x51\x5e\x6b"
+ "\x78\x85\x92\x9f\xac\xb9\xc6\xd3"
+ "\xe0\xed\xfa\x07\x14\x21\x2e\x3b"
+ "\x48\x55\x62\x6f\x7c\x89\x96\xa3"
+ "\xb0\xbd\xca\xd7\xe4\xf1\xfe\x0b"
+ "\x18\x25\x32\x3f\x4c\x59\x66\x73"
+ "\x80\x8d\x9a\xa7\xb4\xc1\xce\xdb"
+ "\xe8\xf5\x02\x0f\x1c\x29\x36\x43"
+ "\x50\x5d\x6a\x77\x84\x91\x9e\xab"
+ "\xb8\xc5\xd2\xdf\xec\xf9\x06\x13"
+ "\x20\x2d\x3a\x47\x54\x61\x6e\x7b"
+ "\x88\x95\xa2\xaf\xbc\xc9\xd6\xe3"
+ "\xf0\xfd\x0a\x17\x24\x31\x3e\x4b"
+ "\x58\x65\x72\x7f\x8c\x99\xa6\xb3"
+ "\xc0\xcd\xda\xe7\xf4\x01\x0e\x1b"
+ "\x28\x35\x42\x4f\x5c\x69\x76\x83"
+ "\x90\x9d\xaa\xb7\xc4\xd1\xde\xeb"
+ "\xf8\x05\x12\x1f\x2c\x39\x46\x53"
+ "\x60\x6d\x7a\x87\x94\xa1\xae\xbb"
+ "\xc8\xd5\xe2\xef\xfc\x09\x16\x23"
+ "\x30\x3d\x4a\x57\x64\x71\x7e\x8b"
+ "\x98\xa5\xb2\xbf\xcc\xd9\xe6\xf3"
+ "\x00\x0f\x1e\x2d\x3c\x4b\x5a\x69"
+ "\x78\x87\x96\xa5\xb4\xc3\xd2\xe1"
+ "\xf0\xff\x0e\x1d\x2c\x3b\x4a\x59"
+ "\x68\x77\x86\x95\xa4\xb3\xc2\xd1"
+ "\xe0\xef\xfe\x0d\x1c\x2b\x3a\x49"
+ "\x58\x67\x76\x85\x94\xa3\xb2\xc1"
+ "\xd0\xdf\xee\xfd\x0c\x1b\x2a\x39"
+ "\x48\x57\x66\x75\x84\x93\xa2\xb1"
+ "\xc0\xcf\xde\xed\xfc\x0b\x1a\x29"
+ "\x38\x47\x56\x65\x74\x83\x92\xa1"
+ "\xb0\xbf\xce\xdd\xec\xfb\x0a\x19"
+ "\x28\x37\x46\x55\x64\x73\x82\x91"
+ "\xa0\xaf\xbe\xcd\xdc\xeb\xfa\x09"
+ "\x18\x27\x36\x45\x54\x63\x72\x81"
+ "\x90\x9f\xae\xbd\xcc\xdb\xea\xf9"
+ "\x08\x17\x26\x35\x44\x53\x62\x71"
+ "\x80\x8f\x9e\xad\xbc\xcb\xda\xe9"
+ "\xf8\x07\x16\x25\x34\x43\x52\x61"
+ "\x70\x7f\x8e\x9d\xac\xbb\xca\xd9"
+ "\xe8\xf7\x06\x15\x24\x33\x42\x51"
+ "\x60\x6f\x7e\x8d\x9c\xab\xba\xc9"
+ "\xd8\xe7\xf6\x05\x14\x23\x32\x41"
+ "\x50\x5f\x6e\x7d\x8c\x9b\xaa\xb9"
+ "\xc8\xd7\xe6\xf5\x04\x13\x22\x31"
+ "\x40\x4f\x5e\x6d\x7c\x8b\x9a\xa9"
+ "\xb8\xc7\xd6\xe5\xf4\x03\x12\x21"
+ "\x30\x3f\x4e\x5d\x6c\x7b\x8a\x99"
+ "\xa8\xb7\xc6\xd5\xe4\xf3\x02\x11"
+ "\x20\x2f\x3e\x4d\x5c\x6b\x7a\x89"
+ "\x98\xa7\xb6\xc5\xd4\xe3\xf2\x01"
+ "\x10\x1f\x2e\x3d\x4c\x5b\x6a\x79"
+ "\x88\x97\xa6\xb5\xc4\xd3\xe2\xf1"
+ "\x00\x11\x22\x33\x44\x55\x66\x77"
+ "\x88\x99\xaa\xbb\xcc\xdd\xee\xff"
+ "\x10\x21\x32\x43\x54\x65\x76\x87"
+ "\x98\xa9\xba\xcb\xdc\xed\xfe\x0f"
+ "\x20\x31\x42\x53\x64\x75\x86\x97"
+ "\xa8\xb9\xca\xdb\xec\xfd\x0e\x1f"
+ "\x30\x41\x52\x63\x74\x85\x96\xa7"
+ "\xb8\xc9\xda\xeb\xfc\x0d\x1e\x2f"
+ "\x40\x51\x62\x73\x84\x95\xa6\xb7"
+ "\xc8\xd9\xea\xfb\x0c\x1d\x2e\x3f"
+ "\x50\x61\x72\x83\x94\xa5\xb6\xc7"
+ "\xd8\xe9\xfa\x0b\x1c\x2d\x3e\x4f"
+ "\x60\x71\x82\x93\xa4\xb5\xc6\xd7"
+ "\xe8\xf9\x0a\x1b\x2c\x3d\x4e\x5f"
+ "\x70\x81\x92\xa3\xb4\xc5\xd6\xe7"
+ "\xf8\x09\x1a\x2b\x3c\x4d\x5e\x6f"
+ "\x80\x91\xa2\xb3\xc4\xd5\xe6\xf7"
+ "\x08\x19\x2a\x3b\x4c\x5d\x6e\x7f"
+ "\x90\xa1\xb2\xc3\xd4\xe5\xf6\x07"
+ "\x18\x29\x3a\x4b\x5c\x6d\x7e\x8f"
+ "\xa0\xb1\xc2\xd3\xe4\xf5\x06\x17"
+ "\x28\x39\x4a\x5b\x6c\x7d\x8e\x9f"
+ "\xb0\xc1\xd2\xe3\xf4\x05\x16\x27"
+ "\x38\x49\x5a\x6b\x7c\x8d\x9e\xaf"
+ "\xc0\xd1\xe2\xf3\x04\x15\x26\x37"
+ "\x48\x59\x6a\x7b\x8c\x9d\xae\xbf"
+ "\xd0\xe1\xf2\x03\x14\x25\x36\x47"
+ "\x58\x69\x7a\x8b\x9c\xad\xbe\xcf"
+ "\xe0\xf1\x02\x13\x24\x35\x46\x57"
+ "\x68\x79\x8a\x9b\xac\xbd\xce\xdf"
+ "\xf0\x01\x12\x23\x34\x45\x56\x67"
+ "\x78\x89\x9a\xab\xbc\xcd\xde\xef"
+ "\x00\x13\x26\x39\x4c\x5f\x72\x85"
+ "\x98\xab\xbe\xd1\xe4\xf7\x0a\x1d"
+ "\x30\x43\x56\x69\x7c\x8f\xa2\xb5"
+ "\xc8\xdb\xee\x01\x14\x27\x3a\x4d"
+ "\x60\x73\x86\x99\xac\xbf\xd2\xe5"
+ "\xf8\x0b\x1e\x31\x44\x57\x6a\x7d"
+ "\x90\xa3\xb6\xc9\xdc\xef\x02\x15"
+ "\x28\x3b\x4e\x61\x74\x87\x9a\xad"
+ "\xc0\xd3\xe6\xf9\x0c\x1f\x32\x45"
+ "\x58\x6b\x7e\x91\xa4\xb7\xca\xdd"
+ "\xf0\x03\x16\x29\x3c\x4f\x62\x75"
+ "\x88\x9b\xae\xc1\xd4\xe7\xfa\x0d"
+ "\x20\x33\x46\x59\x6c\x7f\x92\xa5"
+ "\xb8\xcb\xde\xf1\x04\x17\x2a\x3d"
+ "\x50\x63\x76\x89\x9c\xaf\xc2\xd5"
+ "\xe8\xfb\x0e\x21\x34\x47\x5a\x6d"
+ "\x80\x93\xa6\xb9\xcc\xdf\xf2\x05"
+ "\x18\x2b\x3e\x51\x64\x77\x8a\x9d"
+ "\xb0\xc3\xd6\xe9\xfc\x0f\x22\x35"
+ "\x48\x5b\x6e\x81\x94\xa7\xba\xcd"
+ "\xe0\xf3\x06\x19\x2c\x3f\x52\x65"
+ "\x78\x8b\x9e\xb1\xc4\xd7\xea\xfd"
+ "\x10\x23\x36\x49\x5c\x6f\x82\x95"
+ "\xa8\xbb\xce\xe1\xf4\x07\x1a\x2d"
+ "\x40\x53\x66\x79\x8c\x9f\xb2\xc5"
+ "\xd8\xeb\xfe\x11\x24\x37\x4a\x5d"
+ "\x70\x83\x96\xa9\xbc\xcf\xe2\xf5"
+ "\x08\x1b\x2e\x41\x54\x67\x7a\x8d"
+ "\xa0\xb3\xc6\xd9\xec\xff\x12\x25"
+ "\x38\x4b\x5e\x71\x84\x97\xaa\xbd"
+ "\xd0\xe3\xf6\x09\x1c\x2f\x42\x55"
+ "\x68\x7b\x8e\xa1\xb4\xc7\xda\xed"
+ "\x00\x15\x2a\x3f\x54\x69\x7e\x93"
+ "\xa8\xbd\xd2\xe7\xfc\x11\x26\x3b"
+ "\x50\x65\x7a\x8f\xa4\xb9\xce\xe3"
+ "\xf8\x0d\x22\x37\x4c\x61\x76\x8b"
+ "\xa0\xb5\xca\xdf\xf4\x09\x1e\x33"
+ "\x48\x5d\x72\x87\x9c\xb1\xc6\xdb"
+ "\xf0\x05\x1a\x2f\x44\x59\x6e\x83"
+ "\x98\xad\xc2\xd7\xec\x01\x16\x2b"
+ "\x40\x55\x6a\x7f\x94\xa9\xbe\xd3"
+ "\xe8\xfd\x12\x27\x3c\x51\x66\x7b"
+ "\x90\xa5\xba\xcf\xe4\xf9\x0e\x23"
+ "\x38\x4d\x62\x77\x8c\xa1\xb6\xcb"
+ "\xe0\xf5\x0a\x1f\x34\x49\x5e\x73"
+ "\x88\x9d\xb2\xc7\xdc\xf1\x06\x1b"
+ "\x30\x45\x5a\x6f\x84\x99\xae\xc3"
+ "\xd8\xed\x02\x17\x2c\x41\x56\x6b"
+ "\x80\x95\xaa\xbf\xd4\xe9\xfe\x13"
+ "\x28\x3d\x52\x67\x7c\x91\xa6\xbb"
+ "\xd0\xe5\xfa\x0f\x24\x39\x4e\x63"
+ "\x78\x8d\xa2\xb7\xcc\xe1\xf6\x0b"
+ "\x20\x35\x4a\x5f\x74\x89\x9e\xb3"
+ "\xc8\xdd\xf2\x07\x1c\x31\x46\x5b"
+ "\x70\x85\x9a\xaf\xc4\xd9\xee\x03"
+ "\x18\x2d\x42\x57\x6c\x81\x96\xab"
+ "\xc0\xd5\xea\xff\x14\x29\x3e\x53"
+ "\x68\x7d\x92\xa7\xbc\xd1\xe6\xfb"
+ "\x10\x25\x3a\x4f\x64\x79\x8e\xa3"
+ "\xb8\xcd\xe2\xf7\x0c\x21\x36\x4b"
+ "\x60\x75\x8a\x9f\xb4\xc9\xde\xf3"
+ "\x08\x1d\x32\x47\x5c\x71\x86\x9b"
+ "\xb0\xc5\xda\xef\x04\x19\x2e\x43"
+ "\x58\x6d\x82\x97\xac\xc1\xd6\xeb"
+ "\x00\x17\x2e\x45\x5c\x73\x8a\xa1"
+ "\xb8\xcf\xe6\xfd\x14\x2b\x42\x59"
+ "\x70\x87\x9e\xb5\xcc\xe3\xfa\x11"
+ "\x28\x3f\x56\x6d\x84\x9b\xb2\xc9"
+ "\xe0\xf7\x0e\x25\x3c\x53\x6a\x81"
+ "\x98\xaf\xc6\xdd\xf4\x0b\x22\x39"
+ "\x50\x67\x7e\x95\xac\xc3\xda\xf1"
+ "\x08\x1f\x36\x4d\x64\x7b\x92\xa9"
+ "\xc0\xd7\xee\x05\x1c\x33\x4a\x61"
+ "\x78\x8f\xa6\xbd\xd4\xeb\x02\x19"
+ "\x30\x47\x5e\x75\x8c\xa3\xba\xd1"
+ "\xe8\xff\x16\x2d\x44\x5b\x72\x89"
+ "\xa0\xb7\xce\xe5\xfc\x13\x2a\x41"
+ "\x58\x6f\x86\x9d\xb4\xcb\xe2\xf9"
+ "\x10\x27\x3e\x55\x6c\x83\x9a\xb1"
+ "\xc8\xdf\xf6\x0d\x24\x3b\x52\x69"
+ "\x80\x97\xae\xc5\xdc\xf3\x0a\x21"
+ "\x38\x4f\x66\x7d\x94\xab\xc2\xd9"
+ "\xf0\x07\x1e\x35\x4c\x63\x7a\x91"
+ "\xa8\xbf\xd6\xed\x04\x1b\x32\x49"
+ "\x60\x77\x8e\xa5\xbc\xd3\xea\x01"
+ "\x18\x2f\x46\x5d\x74\x8b\xa2\xb9"
+ "\xd0\xe7\xfe\x15\x2c\x43\x5a\x71"
+ "\x88\x9f\xb6\xcd\xe4\xfb\x12\x29"
+ "\x40\x57\x6e\x85\x9c\xb3\xca\xe1"
+ "\xf8\x0f\x26\x3d\x54\x6b\x82\x99"
+ "\xb0\xc7\xde\xf5\x0c\x23\x3a\x51"
+ "\x68\x7f\x96\xad\xc4\xdb\xf2\x09"
+ "\x20\x37\x4e\x65\x7c\x93\xaa\xc1"
+ "\xd8\xef\x06\x1d\x34\x4b\x62\x79"
+ "\x90\xa7\xbe\xd5\xec\x03\x1a\x31"
+ "\x48\x5f\x76\x8d\xa4\xbb\xd2\xe9"
+ "\x00\x19\x32\x4b\x64\x7d\x96\xaf"
+ "\xc8\xe1\xfa\x13\x2c\x45\x5e\x77"
+ "\x90\xa9\xc2\xdb\xf4\x0d\x26\x3f"
+ "\x58\x71\x8a\xa3\xbc\xd5\xee\x07"
+ "\x20\x39\x52\x6b\x84\x9d\xb6\xcf"
+ "\xe8\x01\x1a\x33\x4c\x65\x7e\x97"
+ "\xb0\xc9\xe2\xfb\x14\x2d\x46\x5f"
+ "\x78\x91\xaa\xc3\xdc\xf5\x0e\x27"
+ "\x40\x59\x72\x8b\xa4\xbd\xd6\xef"
+ "\x08\x21\x3a\x53\x6c\x85\x9e\xb7"
+ "\xd0\xe9\x02\x1b\x34\x4d\x66\x7f"
+ "\x98\xb1\xca\xe3\xfc\x15\x2e\x47"
+ "\x60\x79\x92\xab\xc4\xdd\xf6\x0f"
+ "\x28\x41\x5a\x73\x8c\xa5\xbe\xd7"
+ "\xf0\x09\x22\x3b\x54\x6d\x86\x9f"
+ "\xb8\xd1\xea\x03\x1c\x35\x4e\x67"
+ "\x80\x99\xb2\xcb\xe4\xfd\x16\x2f"
+ "\x48\x61\x7a\x93\xac\xc5\xde\xf7"
+ "\x10\x29\x42\x5b\x74\x8d\xa6\xbf"
+ "\xd8\xf1\x0a\x23\x3c\x55\x6e\x87"
+ "\xa0\xb9\xd2\xeb\x04\x1d\x36\x4f"
+ "\x68\x81\x9a\xb3\xcc\xe5\xfe\x17"
+ "\x30\x49\x62\x7b\x94\xad\xc6\xdf"
+ "\xf8\x11\x2a\x43\x5c\x75\x8e\xa7"
+ "\xc0\xd9\xf2\x0b\x24\x3d\x56\x6f"
+ "\x88\xa1\xba\xd3\xec\x05\x1e\x37"
+ "\x50\x69\x82\x9b\xb4\xcd\xe6\xff"
+ "\x18\x31\x4a\x63\x7c\x95\xae\xc7"
+ "\xe0\xf9\x12\x2b\x44\x5d\x76\x8f"
+ "\xa8\xc1\xda\xf3\x0c\x25\x3e\x57"
+ "\x70\x89\xa2\xbb\xd4\xed\x06\x1f"
+ "\x38\x51\x6a\x83\x9c\xb5\xce\xe7"
+ "\x00\x1b\x36\x51\x6c\x87\xa2\xbd"
+ "\xd8\xf3\x0e\x29\x44\x5f\x7a\x95"
+ "\xb0\xcb\xe6\x01\x1c\x37\x52\x6d"
+ "\x88\xa3\xbe\xd9\xf4\x0f\x2a\x45"
+ "\x60\x7b\x96\xb1\xcc\xe7\x02\x1d"
+ "\x38\x53\x6e\x89\xa4\xbf\xda\xf5"
+ "\x10\x2b\x46\x61\x7c\x97\xb2\xcd"
+ "\xe8\x03\x1e\x39\x54\x6f\x8a\xa5"
+ "\xc0\xdb\xf6\x11\x2c\x47\x62\x7d"
+ "\x98\xb3\xce\xe9\x04\x1f\x3a\x55"
+ "\x70\x8b\xa6\xc1\xdc\xf7\x12\x2d"
+ "\x48\x63\x7e\x99\xb4\xcf\xea\x05"
+ "\x20\x3b\x56\x71\x8c\xa7\xc2\xdd"
+ "\xf8\x13\x2e\x49\x64\x7f\x9a\xb5"
+ "\xd0\xeb\x06\x21\x3c\x57\x72\x8d"
+ "\xa8\xc3\xde\xf9\x14\x2f\x4a\x65"
+ "\x80\x9b\xb6\xd1\xec\x07\x22\x3d"
+ "\x58\x73\x8e\xa9\xc4\xdf\xfa\x15"
+ "\x30\x4b\x66\x81\x9c\xb7\xd2\xed"
+ "\x08\x23\x3e\x59\x74\x8f\xaa\xc5"
+ "\xe0\xfb\x16\x31\x4c\x67\x82\x9d"
+ "\xb8\xd3\xee\x09\x24\x3f\x5a\x75"
+ "\x90\xab\xc6\xe1\xfc\x17\x32\x4d"
+ "\x68\x83\x9e\xb9\xd4\xef\x0a\x25"
+ "\x40\x5b\x76\x91\xac\xc7\xe2\xfd"
+ "\x18\x33\x4e\x69\x84\x9f\xba\xd5"
+ "\xf0\x0b\x26\x41\x5c\x77\x92\xad"
+ "\xc8\xe3\xfe\x19\x34\x4f\x6a\x85"
+ "\xa0\xbb\xd6\xf1\x0c\x27\x42\x5d"
+ "\x78\x93\xae\xc9\xe4\xff\x1a\x35"
+ "\x50\x6b\x86\xa1\xbc\xd7\xf2\x0d"
+ "\x28\x43\x5e\x79\x94\xaf\xca\xe5"
+ "\x00\x1d\x3a\x57\x74\x91\xae\xcb"
+ "\xe8\x05\x22\x3f\x5c\x79\x96\xb3"
+ "\xd0\xed\x0a\x27\x44\x61\x7e\x9b"
+ "\xb8\xd5\xf2\x0f\x2c\x49\x66\x83"
+ "\xa0\xbd\xda\xf7\x14\x31\x4e\x6b"
+ "\x88\xa5\xc2\xdf\xfc\x19\x36\x53"
+ "\x70\x8d\xaa\xc7\xe4\x01\x1e\x3b"
+ "\x58\x75\x92\xaf\xcc\xe9\x06\x23"
+ "\x40\x5d\x7a\x97\xb4\xd1\xee\x0b"
+ "\x28\x45\x62\x7f\x9c\xb9\xd6\xf3"
+ "\x10\x2d\x4a\x67\x84\xa1\xbe\xdb"
+ "\xf8\x15\x32\x4f\x6c\x89\xa6\xc3"
+ "\xe0\xfd\x1a\x37\x54\x71\x8e\xab"
+ "\xc8\xe5\x02\x1f\x3c\x59\x76\x93"
+ "\xb0\xcd\xea\x07\x24\x41\x5e\x7b"
+ "\x98\xb5\xd2\xef\x0c\x29\x46\x63"
+ "\x80\x9d\xba\xd7\xf4\x11\x2e\x4b"
+ "\x68\x85\xa2\xbf\xdc\xf9\x16\x33"
+ "\x50\x6d\x8a\xa7\xc4\xe1\xfe\x1b"
+ "\x38\x55\x72\x8f\xac\xc9\xe6\x03"
+ "\x20\x3d\x5a\x77\x94\xb1\xce\xeb"
+ "\x08\x25\x42\x5f\x7c\x99\xb6\xd3"
+ "\xf0\x0d\x2a\x47\x64\x81\x9e\xbb"
+ "\xd8\xf5\x12\x2f\x4c\x69\x86\xa3"
+ "\xc0\xdd\xfa\x17\x34\x51\x6e\x8b"
+ "\xa8\xc5\xe2\xff\x1c\x39\x56\x73"
+ "\x90\xad\xca\xe7\x04\x21\x3e\x5b"
+ "\x78\x95\xb2\xcf\xec\x09\x26\x43"
+ "\x60\x7d\x9a\xb7\xd4\xf1\x0e\x2b"
+ "\x48\x65\x82\x9f\xbc\xd9\xf6\x13"
+ "\x30\x4d\x6a\x87\xa4\xc1\xde\xfb"
+ "\x18\x35\x52\x6f\x8c\xa9\xc6\xe3"
+ "\x00\x1f\x3e\x5d\x7c\x9b\xba\xd9"
+ "\xf8\x17\x36\x55\x74\x93\xb2\xd1"
+ "\xf0\x0f\x2e\x4d\x6c\x8b\xaa\xc9"
+ "\xe8\x07\x26\x45\x64\x83\xa2\xc1"
+ "\xe0\xff\x1e\x3d\x5c\x7b\x9a\xb9"
+ "\xd8\xf7\x16\x35\x54\x73\x92\xb1"
+ "\xd0\xef\x0e\x2d\x4c\x6b\x8a\xa9"
+ "\xc8\xe7\x06\x25\x44\x63\x82\xa1"
+ "\xc0\xdf\xfe\x1d\x3c\x5b\x7a\x99"
+ "\xb8\xd7\xf6\x15\x34\x53\x72\x91"
+ "\xb0\xcf\xee\x0d\x2c\x4b\x6a\x89"
+ "\xa8\xc7\xe6\x05\x24\x43\x62\x81"
+ "\xa0\xbf\xde\xfd\x1c\x3b\x5a\x79"
+ "\x98\xb7\xd6\xf5\x14\x33\x52\x71"
+ "\x90\xaf\xce\xed\x0c\x2b\x4a\x69"
+ "\x88\xa7\xc6\xe5\x04\x23\x42\x61"
+ "\x80\x9f\xbe\xdd\xfc\x1b\x3a\x59"
+ "\x78\x97\xb6\xd5\xf4\x13\x32\x51"
+ "\x70\x8f\xae\xcd\xec\x0b\x2a\x49"
+ "\x68\x87\xa6\xc5\xe4\x03\x22\x41"
+ "\x60\x7f\x9e\xbd\xdc\xfb\x1a\x39"
+ "\x58\x77\x96\xb5\xd4\xf3\x12\x31"
+ "\x50\x6f\x8e\xad\xcc\xeb\x0a\x29"
+ "\x48\x67\x86\xa5\xc4\xe3\x02\x21"
+ "\x40\x5f\x7e\x9d\xbc\xdb\xfa\x19"
+ "\x38\x57\x76\x95\xb4\xd3\xf2\x11"
+ "\x30\x4f\x6e\x8d\xac\xcb\xea\x09"
+ "\x28\x47\x66\x85\xa4\xc3\xe2\x01"
+ "\x20\x3f\x5e\x7d\x9c\xbb\xda\xf9"
+ "\x18\x37\x56\x75\x94\xb3\xd2\xf1"
+ "\x10\x2f\x4e\x6d\x8c\xab\xca\xe9"
+ "\x08\x27\x46\x65\x84\xa3\xc2\xe1"
+ "\x00\x21\x42\x63",
+ .ilen = 4100,
+ .result =
+ "\xf0\x5c\x74\xad\x4e\xbc\x99\xe2"
+ "\xae\xff\x91\x3a\x44\xcf\x38\x32"
+ "\x1e\xad\xa7\xcd\xa1\x39\x95\xaa"
+ "\x10\xb1\xb3\x2e\x04\x31\x8f\x86"
+ "\xf2\x62\x74\x70\x0c\xa4\x46\x08"
+ "\xa8\xb7\x99\xa8\xe9\xd2\x73\x79"
+ "\x7e\x6e\xd4\x8f\x1e\xc7\x8e\x31"
+ "\x0b\xfa\x4b\xce\xfd\xf3\x57\x71"
+ "\xe9\x46\x03\xa5\x3d\x34\x00\xe2"
+ "\x18\xff\x75\x6d\x06\x2d\x00\xab"
+ "\xb9\x3e\x6c\x59\xc5\x84\x06\xb5"
+ "\x8b\xd0\x89\x9c\x4a\x79\x16\xc6"
+ "\x3d\x74\x54\xfa\x44\xcd\x23\x26"
+ "\x5c\xcf\x7e\x28\x92\x32\xbf\xdf"
+ "\xa7\x20\x3c\x74\x58\x2a\x9a\xde"
+ "\x61\x00\x1c\x4f\xff\x59\xc4\x22"
+ "\xac\x3c\xd0\xe8\x6c\xf9\x97\x1b"
+ "\x58\x9b\xad\x71\xe8\xa9\xb5\x0d"
+ "\xee\x2f\x04\x1f\x7f\xbc\x99\xee"
+ "\x84\xff\x42\x60\xdc\x3a\x18\xa5"
+ "\x81\xf9\xef\xdc\x7a\x0f\x65\x41"
+ "\x2f\xa3\xd3\xf9\xc2\xcb\xc0\x4d"
+ "\x8f\xd3\x76\x96\xad\x49\x6d\x38"
+ "\x3d\x39\x0b\x6c\x80\xb7\x54\x69"
+ "\xf0\x2c\x90\x02\x29\x0d\x1c\x12"
+ "\xad\x55\xc3\x8b\x68\xd9\xcc\xb3"
+ "\xb2\x64\x33\x90\x5e\xca\x4b\xe2"
+ "\xfb\x75\xdc\x63\xf7\x9f\x82\x74"
+ "\xf0\xc9\xaa\x7f\xe9\x2a\x9b\x33"
+ "\xbc\x88\x00\x7f\xca\xb2\x1f\x14"
+ "\xdb\xc5\x8e\x7b\x11\x3c\x3e\x08"
+ "\xf3\x83\xe8\xe0\x94\x86\x2e\x92"
+ "\x78\x6b\x01\xc9\xc7\x83\xba\x21"
+ "\x6a\x25\x15\x33\x4e\x45\x08\xec"
+ "\x35\xdb\xe0\x6e\x31\x51\x79\xa9"
+ "\x42\x44\x65\xc1\xa0\xf1\xf9\x2a"
+ "\x70\xd5\xb6\xc6\xc1\x8c\x39\xfc"
+ "\x25\xa6\x55\xd9\xdd\x2d\x4c\xec"
+ "\x49\xc6\xeb\x0e\xa8\x25\x2a\x16"
+ "\x1b\x66\x84\xda\xe2\x92\xe5\xc0"
+ "\xc8\x53\x07\xaf\x80\x84\xec\xfd"
+ "\xcd\xd1\x6e\xcd\x6f\x6a\xf5\x36"
+ "\xc5\x15\xe5\x25\x7d\x77\xd1\x1a"
+ "\x93\x36\xa9\xcf\x7c\xa4\x54\x4a"
+ "\x06\x51\x48\x4e\xf6\x59\x87\xd2"
+ "\x04\x02\xef\xd3\x44\xde\x76\x31"
+ "\xb3\x34\x17\x1b\x9d\x66\x11\x9f"
+ "\x1e\xcc\x17\xe9\xc7\x3c\x1b\xe7"
+ "\xcb\x50\x08\xfc\xdc\x2b\x24\xdb"
+ "\x65\x83\xd0\x3b\xe3\x30\xea\x94"
+ "\x6c\xe7\xe8\x35\x32\xc7\xdb\x64"
+ "\xb4\x01\xab\x36\x2c\x77\x13\xaf"
+ "\xf8\x2b\x88\x3f\x54\x39\xc4\x44"
+ "\xfe\xef\x6f\x68\x34\xbe\x0f\x05"
+ "\x16\x6d\xf6\x0a\x30\xe7\xe3\xed"
+ "\xc4\xde\x3c\x1b\x13\xd8\xdb\xfe"
+ "\x41\x62\xe5\x28\xd4\x8d\xa3\xc7"
+ "\x93\x97\xc6\x48\x45\x1d\x9f\x83"
+ "\xdf\x4b\x40\x3e\x42\x25\x87\x80"
+ "\x4c\x7d\xa8\xd4\x98\x23\x95\x75"
+ "\x41\x8c\xda\x41\x9b\xd4\xa7\x06"
+ "\xb5\xf1\x71\x09\x53\xbe\xca\xbf"
+ "\x32\x03\xed\xf0\x50\x1c\x56\x39"
+ "\x5b\xa4\x75\x18\xf7\x9b\x58\xef"
+ "\x53\xfc\x2a\x38\x23\x15\x75\xcd"
+ "\x45\xe5\x5a\x82\x55\xba\x21\xfa"
+ "\xd4\xbd\xc6\x94\x7c\xc5\x80\x12"
+ "\xf7\x4b\x32\xc4\x9a\x82\xd8\x28"
+ "\x8f\xd9\xc2\x0f\x60\x03\xbe\x5e"
+ "\x21\xd6\x5f\x58\xbf\x5c\xb1\x32"
+ "\x82\x8d\xa9\xe5\xf2\x66\x1a\xc0"
+ "\xa0\xbc\x58\x2f\x71\xf5\x2f\xed"
+ "\xd1\x26\xb9\xd8\x49\x5a\x07\x19"
+ "\x01\x7c\x59\xb0\xf8\xa4\xb7\xd3"
+ "\x7b\x1a\x8c\x38\xf4\x50\xa4\x59"
+ "\xb0\xcc\x41\x0b\x88\x7f\xe5\x31"
+ "\xb3\x42\xba\xa2\x7e\xd4\x32\x71"
+ "\x45\x87\x48\xa9\xc2\xf2\x89\xb3"
+ "\xe4\xa7\x7e\x52\x15\x61\xfa\xfe"
+ "\xc9\xdd\x81\xeb\x13\xab\xab\xc3"
+ "\x98\x59\xd8\x16\x3d\x14\x7a\x1c"
+ "\x3c\x41\x9a\x16\x16\x9b\xd2\xd2"
+ "\x69\x3a\x29\x23\xac\x86\x32\xa5"
+ "\x48\x9c\x9e\xf3\x47\x77\x81\x70"
+ "\x24\xe8\x85\xd2\xf5\xb5\xfa\xff"
+ "\x59\x6a\xd3\x50\x59\x43\x59\xde"
+ "\xd9\xf1\x55\xa5\x0c\xc3\x1a\x1a"
+ "\x18\x34\x0d\x1a\x63\x33\xed\x10"
+ "\xe0\x1d\x2a\x18\xd2\xc0\x54\xa8"
+ "\xca\xb5\x9a\xd3\xdd\xca\x45\x84"
+ "\x50\xe7\x0f\xfe\xa4\x99\x5a\xbe"
+ "\x43\x2d\x9a\xcb\x92\x3f\x5a\x1d"
+ "\x85\xd8\xc9\xdf\x68\xc9\x12\x80"
+ "\x56\x0c\xdc\x00\xdc\x3a\x7d\x9d"
+ "\xa3\xa2\xe8\x4d\xbf\xf9\x70\xa0"
+ "\xa4\x13\x4f\x6b\xaf\x0a\x89\x7f"
+ "\xda\xf0\xbf\x9b\xc8\x1d\xe5\xf8"
+ "\x2e\x8b\x07\xb5\x73\x1b\xcc\xa2"
+ "\xa6\xad\x30\xbc\x78\x3c\x5b\x10"
+ "\xfa\x5e\x62\x2d\x9e\x64\xb3\x33"
+ "\xce\xf9\x1f\x86\xe7\x8b\xa2\xb8"
+ "\xe8\x99\x57\x8c\x11\xed\x66\xd9"
+ "\x3c\x72\xb9\xc3\xe6\x4e\x17\x3a"
+ "\x6a\xcb\x42\x24\x06\xed\x3e\x4e"
+ "\xa3\xe8\x6a\x94\xda\x0d\x4e\xd5"
+ "\x14\x19\xcf\xb6\x26\xd8\x2e\xcc"
+ "\x64\x76\x38\x49\x4d\xfe\x30\x6d"
+ "\xe4\xc8\x8c\x7b\xc4\xe0\x35\xba"
+ "\x22\x6e\x76\xe1\x1a\xf2\x53\xc3"
+ "\x28\xa2\x82\x1f\x61\x69\xad\xc1"
+ "\x7b\x28\x4b\x1e\x6c\x85\x95\x9b"
+ "\x51\xb5\x17\x7f\x12\x69\x8c\x24"
+ "\xd5\xc7\x5a\x5a\x11\x54\xff\x5a"
+ "\xf7\x16\xc3\x91\xa6\xf0\xdc\x0a"
+ "\xb6\xa7\x4a\x0d\x7a\x58\xfe\xa5"
+ "\xf5\xcb\x8f\x7b\x0e\xea\x57\xe7"
+ "\xbd\x79\xd6\x1c\x88\x23\x6c\xf2"
+ "\x4d\x29\x77\x53\x35\x6a\x00\x8d"
+ "\xcd\xa3\x58\xbe\x77\x99\x18\xf8"
+ "\xe6\xe1\x8f\xe9\x37\x8f\xe3\xe2"
+ "\x5a\x8a\x93\x25\xaf\xf3\x78\x80"
+ "\xbe\xa6\x1b\xc6\xac\x8b\x1c\x91"
+ "\x58\xe1\x9f\x89\x35\x9d\x1d\x21"
+ "\x29\x9f\xf4\x99\x02\x27\x0f\xa8"
+ "\x4f\x79\x94\x2b\x33\x2c\xda\xa2"
+ "\x26\x39\x83\x94\xef\x27\xd8\x53"
+ "\x8f\x66\x0d\xe4\x41\x7d\x34\xcd"
+ "\x43\x7c\x95\x0a\x53\xef\x66\xda"
+ "\x7e\x9b\xf3\x93\xaf\xd0\x73\x71"
+ "\xba\x40\x9b\x74\xf8\xd7\xd7\x41"
+ "\x6d\xaf\x72\x9c\x8d\x21\x87\x3c"
+ "\xfd\x0a\x90\xa9\x47\x96\x9e\xd3"
+ "\x88\xee\x73\xcf\x66\x2f\x52\x56"
+ "\x6d\xa9\x80\x4c\xe2\x6f\x62\x88"
+ "\x3f\x0e\x54\x17\x48\x80\x5d\xd3"
+ "\xc3\xda\x25\x3d\xa1\xc8\xcb\x9f"
+ "\x9b\x70\xb3\xa1\xeb\x04\x52\xa1"
+ "\xf2\x22\x0f\xfc\xc8\x18\xfa\xf9"
+ "\x85\x9c\xf1\xac\xeb\x0c\x02\x46"
+ "\x75\xd2\xf5\x2c\xe3\xd2\x59\x94"
+ "\x12\xf3\x3c\xfc\xd7\x92\xfa\x36"
+ "\xba\x61\x34\x38\x7c\xda\x48\x3e"
+ "\x08\xc9\x39\x23\x5e\x02\x2c\x1a"
+ "\x18\x7e\xb4\xd9\xfd\x9e\x40\x02"
+ "\xb1\x33\x37\x32\xe7\xde\xd6\xd0"
+ "\x7c\x58\x65\x4b\xf8\x34\x27\x9c"
+ "\x44\xb4\xbd\xe9\xe9\x4c\x78\x7d"
+ "\x4b\x9f\xce\xb1\xcd\x47\xa5\x37"
+ "\xe5\x6d\xbd\xb9\x43\x94\x0a\xd4"
+ "\xd6\xf9\x04\x5f\xb5\x66\x6c\x1a"
+ "\x35\x12\xe3\x36\x28\x27\x36\x58"
+ "\x01\x2b\x79\xe4\xba\x6d\x10\x7d"
+ "\x65\xdf\x84\x95\xf4\xd5\xb6\x8f"
+ "\x2b\x9f\x96\x00\x86\x60\xf0\x21"
+ "\x76\xa8\x6a\x8c\x28\x1c\xb3\x6b"
+ "\x97\xd7\xb6\x53\x2a\xcc\xab\x40"
+ "\x9d\x62\x79\x58\x52\xe6\x65\xb7"
+ "\xab\x55\x67\x9c\x89\x7c\x03\xb0"
+ "\x73\x59\xc5\x81\xf5\x18\x17\x5c"
+ "\x89\xf3\x78\x35\x44\x62\x78\x72"
+ "\xd0\x96\xeb\x31\xe7\x87\x77\x14"
+ "\x99\x51\xf2\x59\x26\x9e\xb5\xa6"
+ "\x45\xfe\x6e\xbd\x07\x4c\x94\x5a"
+ "\xa5\x7d\xfc\xf1\x2b\x77\xe2\xfe"
+ "\x17\xd4\x84\xa0\xac\xb5\xc7\xda"
+ "\xa9\x1a\xb6\xf3\x74\x11\xb4\x9d"
+ "\xfb\x79\x2e\x04\x2d\x50\x28\x83"
+ "\xbf\xc6\x52\xd3\x34\xd6\xe8\x7a"
+ "\xb6\xea\xe7\xa8\x6c\x15\x1e\x2c"
+ "\x57\xbc\x48\x4e\x5f\x5c\xb6\x92"
+ "\xd2\x49\x77\x81\x6d\x90\x70\xae"
+ "\x98\xa1\x03\x0d\x6b\xb9\x77\x14"
+ "\xf1\x4e\x23\xd3\xf8\x68\xbd\xc2"
+ "\xfe\x04\xb7\x5c\xc5\x17\x60\x8f"
+ "\x65\x54\xa4\x7a\x42\xdc\x18\x0d"
+ "\xb5\xcf\x0f\xd3\xc7\x91\x66\x1b"
+ "\x45\x42\x27\x75\x50\xe5\xee\xb8"
+ "\x7f\x33\x2c\xba\x4a\x92\x4d\x2c"
+ "\x3c\xe3\x0d\x80\x01\xba\x0d\x29"
+ "\xd8\x3c\xe9\x13\x16\x57\xe6\xea"
+ "\x94\x52\xe7\x00\x4d\x30\xb0\x0f"
+ "\x35\xb8\xb8\xa7\xb1\xb5\x3b\x44"
+ "\xe1\x2f\xfd\x88\xed\x43\xe7\x52"
+ "\x10\x93\xb3\x8a\x30\x6b\x0a\xf7"
+ "\x23\xc6\x50\x9d\x4a\xb0\xde\xc3"
+ "\xdc\x9b\x2f\x01\x56\x36\x09\xc5"
+ "\x2f\x6b\xfe\xf1\xd8\x27\x45\x03"
+ "\x30\x5e\x5c\x5b\xb4\x62\x0e\x1a"
+ "\xa9\x21\x2b\x92\x94\x87\x62\x57"
+ "\x4c\x10\x74\x1a\xf1\x0a\xc5\x84"
+ "\x3b\x9e\x72\x02\xd7\xcc\x09\x56"
+ "\xbd\x54\xc1\xf0\xc3\xe3\xb3\xf8"
+ "\xd2\x0d\x61\xcb\xef\xce\x0d\x05"
+ "\xb0\x98\xd9\x8e\x4f\xf9\xbc\x93"
+ "\xa6\xea\xc8\xcf\x10\x53\x4b\xf1"
+ "\xec\xfc\x89\xf9\x64\xb0\x22\xbf"
+ "\x9e\x55\x46\x9f\x7c\x50\x8e\x84"
+ "\x54\x20\x98\xd7\x6c\x40\x1e\xdb"
+ "\x69\x34\x78\x61\x24\x21\x9c\x8a"
+ "\xb3\x62\x31\x8b\x6e\xf5\x2a\x35"
+ "\x86\x13\xb1\x6c\x64\x2e\x41\xa5"
+ "\x05\xf2\x42\xba\xd2\x3a\x0d\x8e"
+ "\x8a\x59\x94\x3c\xcf\x36\x27\x82"
+ "\xc2\x45\xee\x58\xcd\x88\xb4\xec"
+ "\xde\xb2\x96\x0a\xaf\x38\x6f\x88"
+ "\xd7\xd8\xe1\xdf\xb9\x96\xa9\x0a"
+ "\xb1\x95\x28\x86\x20\xe9\x17\x49"
+ "\xa2\x29\x38\xaa\xa5\xe9\x6e\xf1"
+ "\x19\x27\xc0\xd5\x2a\x22\xc3\x0b"
+ "\xdb\x7c\x73\x10\xb9\xba\x89\x76"
+ "\x54\xae\x7d\x71\xb3\x93\xf6\x32"
+ "\xe6\x47\x43\x55\xac\xa0\x0d\xc2"
+ "\x93\x27\x4a\x8e\x0e\x74\x15\xc7"
+ "\x0b\x85\xd9\x0c\xa9\x30\x7a\x3e"
+ "\xea\x8f\x85\x6d\x3a\x12\x4f\x72"
+ "\x69\x58\x7a\x80\xbb\xb5\x97\xf3"
+ "\xcf\x70\xd2\x5d\xdd\x4d\x21\x79"
+ "\x54\x4d\xe4\x05\xe8\xbd\xc2\x62"
+ "\xb1\x3b\x77\x1c\xd6\x5c\xf3\xa0"
+ "\x79\x00\xa8\x6c\x29\xd9\x18\x24"
+ "\x36\xa2\x46\xc0\x96\x65\x7f\xbd"
+ "\x2a\xed\x36\x16\x0c\xaa\x9f\xf4"
+ "\xc5\xb4\xe2\x12\xed\x69\xed\x4f"
+ "\x26\x2c\x39\x52\x89\x98\xe7\x2c"
+ "\x99\xa4\x9e\xa3\x9b\x99\x46\x7a"
+ "\x3a\xdc\xa8\x59\xa3\xdb\xc3\x3b"
+ "\x95\x0d\x3b\x09\x6e\xee\x83\x5d"
+ "\x32\x4d\xed\xab\xfa\x98\x14\x4e"
+ "\xc3\x15\x45\x53\x61\xc4\x93\xbd"
+ "\x90\xf4\x99\x95\x4c\xe6\x76\x92"
+ "\x29\x90\x46\x30\x92\x69\x7d\x13"
+ "\xf2\xa5\xcd\x69\x49\x44\xb2\x0f"
+ "\x63\x40\x36\x5f\x09\xe2\x78\xf8"
+ "\x91\xe3\xe2\xfa\x10\xf7\xc8\x24"
+ "\xa8\x89\x32\x5c\x37\x25\x1d\xb2"
+ "\xea\x17\x8a\x0a\xa9\x64\xc3\x7c"
+ "\x3c\x7c\xbd\xc6\x79\x34\xe7\xe2"
+ "\x85\x8e\xbf\xf8\xde\x92\xa0\xae"
+ "\x20\xc4\xf6\xbb\x1f\x38\x19\x0e"
+ "\xe8\x79\x9c\xa1\x23\xe9\x54\x7e"
+ "\x37\x2f\xe2\x94\x32\xaf\xa0\x23"
+ "\x49\xe4\xc0\xb3\xac\x00\x8f\x36"
+ "\x05\xc4\xa6\x96\xec\x05\x98\x4f"
+ "\x96\x67\x57\x1f\x20\x86\x1b\x2d"
+ "\x69\xe4\x29\x93\x66\x5f\xaf\x6b"
+ "\x88\x26\x2c\x67\x02\x4b\x52\xd0"
+ "\x83\x7a\x43\x1f\xc0\x71\x15\x25"
+ "\x77\x65\x08\x60\x11\x76\x4c\x8d"
+ "\xed\xa9\x27\xc6\xb1\x2a\x2c\x6a"
+ "\x4a\x97\xf5\xc6\xb7\x70\x42\xd3"
+ "\x03\xd1\x24\x95\xec\x6d\xab\x38"
+ "\x72\xce\xe2\x8b\x33\xd7\x51\x09"
+ "\xdc\x45\xe0\x09\x96\x32\xf3\xc4"
+ "\x84\xdc\x73\x73\x2d\x1b\x11\x98"
+ "\xc5\x0e\x69\x28\x94\xc7\xb5\x4d"
+ "\xc8\x8a\xd0\xaa\x13\x2e\x18\x74"
+ "\xdd\xd1\x1e\xf3\x90\xe8\xfc\x9a"
+ "\x72\x4a\x0e\xd1\xe4\xfb\x0d\x96"
+ "\xd1\x0c\x79\x85\x1b\x1c\xfe\xe1"
+ "\x62\x8f\x7a\x73\x32\xab\xc8\x18"
+ "\x69\xe3\x34\x30\xdf\x13\xa6\xe5"
+ "\xe8\x0e\x67\x7f\x81\x11\xb4\x60"
+ "\xc7\xbd\x79\x65\x50\xdc\xc4\x5b"
+ "\xde\x39\xa4\x01\x72\x63\xf3\xd1"
+ "\x64\x4e\xdf\xfc\x27\x92\x37\x0d"
+ "\x57\xcd\x11\x4f\x11\x04\x8e\x1d"
+ "\x16\xf7\xcd\x92\x9a\x99\x30\x14"
+ "\xf1\x7c\x67\x1b\x1f\x41\x0b\xe8"
+ "\x32\xe8\xb8\xc1\x4f\x54\x86\x4f"
+ "\xe5\x79\x81\x73\xcd\x43\x59\x68"
+ "\x73\x02\x3b\x78\x21\x72\x43\x00"
+ "\x49\x17\xf7\x00\xaf\x68\x24\x53"
+ "\x05\x0a\xc3\x33\xe0\x33\x3f\x69"
+ "\xd2\x84\x2f\x0b\xed\xde\x04\xf4"
+ "\x11\x94\x13\x69\x51\x09\x28\xde"
+ "\x57\x5c\xef\xdc\x9a\x49\x1c\x17"
+ "\x97\xf3\x96\xc1\x7f\x5d\x2e\x7d"
+ "\x55\xb8\xb3\x02\x09\xb3\x1f\xe7"
+ "\xc9\x8d\xa3\x36\x34\x8a\x77\x13"
+ "\x30\x63\x4c\xa5\xcd\xc3\xe0\x7e"
+ "\x05\xa1\x7b\x0c\xcb\x74\x47\x31"
+ "\x62\x03\x43\xf1\x87\xb4\xb0\x85"
+ "\x87\x8e\x4b\x25\xc7\xcf\xae\x4b"
+ "\x36\x46\x3e\x62\xbc\x6f\xeb\x5f"
+ "\x73\xac\xe6\x07\xee\xc1\xa1\xd6"
+ "\xc4\xab\xc9\xd6\x89\x45\xe1\xf1"
+ "\x04\x4e\x1a\x6f\xbb\x4f\x3a\xa3"
+ "\xa0\xcb\xa3\x0a\xd8\x71\x35\x55"
+ "\xe4\xbc\x2e\x04\x06\xe6\xff\x5b"
+ "\x1c\xc0\x11\x7c\xc5\x17\xf3\x38"
+ "\xcf\xe9\xba\x0f\x0e\xef\x02\xc2"
+ "\x8d\xc6\xbc\x4b\x67\x20\x95\xd7"
+ "\x2c\x45\x5b\x86\x44\x8c\x6f\x2e"
+ "\x7e\x9f\x1c\x77\xba\x6b\x0e\xa3"
+ "\x69\xdc\xab\x24\x57\x60\x47\xc1"
+ "\xd1\xa5\x9d\x23\xe6\xb1\x37\xfe"
+ "\x93\xd2\x4c\x46\xf9\x0c\xc6\xfb"
+ "\xd6\x9d\x99\x69\xab\x7a\x07\x0c"
+ "\x65\xe7\xc4\x08\x96\xe2\xa5\x01"
+ "\x3f\x46\x07\x05\x7e\xe8\x9a\x90"
+ "\x50\xdc\xe9\x7a\xea\xa1\x39\x6e"
+ "\x66\xe4\x6f\xa5\x5f\xb2\xd9\x5b"
+ "\xf5\xdb\x2a\x32\xf0\x11\x6f\x7c"
+ "\x26\x10\x8f\x3d\x80\xe9\x58\xf7"
+ "\xe0\xa8\x57\xf8\xdb\x0e\xce\x99"
+ "\x63\x19\x3d\xd5\xec\x1b\x77\x69"
+ "\x98\xf6\xe4\x5f\x67\x17\x4b\x09"
+ "\x85\x62\x82\x70\x18\xe2\x9a\x78"
+ "\xe2\x62\xbd\xb4\xf1\x42\xc6\xfb"
+ "\x08\xd0\xbd\xeb\x4e\x09\xf2\xc8"
+ "\x1e\xdc\x3d\x32\x21\x56\x9c\x4f"
+ "\x35\xf3\x61\x06\x72\x84\xc4\x32"
+ "\xf2\xf1\xfa\x0b\x2f\xc3\xdb\x02"
+ "\x04\xc2\xde\x57\x64\x60\x8d\xcf"
+ "\xcb\x86\x5d\x97\x3e\xb1\x9c\x01"
+ "\xd6\x28\x8f\x99\xbc\x46\xeb\x05"
+ "\xaf\x7e\xb8\x21\x2a\x56\x85\x1c"
+ "\xb3\x71\xa0\xde\xca\x96\xf1\x78"
+ "\x49\xa2\x99\x81\x80\x5c\x01\xf5"
+ "\xa0\xa2\x56\x63\xe2\x70\x07\xa5"
+ "\x95\xd6\x85\xeb\x36\x9e\xa9\x51"
+ "\x66\x56\x5f\x1d\x02\x19\xe2\xf6"
+ "\x4f\x73\x38\x09\x75\x64\x48\xe0"
+ "\xf1\x7e\x0e\xe8\x9d\xf9\xed\x94"
+ "\xfe\x16\x26\x62\x49\x74\xf4\xb0"
+ "\xd4\xa9\x6c\xb0\xfd\x53\xe9\x81"
+ "\xe0\x7a\xbf\xcf\xb5\xc4\x01\x81"
+ "\x79\x99\x77\x01\x3b\xe9\xa2\xb6"
+ "\xe6\x6a\x8a\x9e\x56\x1c\x8d\x1e"
+ "\x8f\x06\x55\x2c\x6c\xdc\x92\x87"
+ "\x64\x3b\x4b\x19\xa1\x13\x64\x1d"
+ "\x4a\xe9\xc0\x00\xb8\x95\xef\x6b"
+ "\x1a\x86\x6d\x37\x52\x02\xc2\xe0"
+ "\xc8\xbb\x42\x0c\x02\x21\x4a\xc9"
+ "\xef\xa0\x54\xe4\x5e\x16\x53\x81"
+ "\x70\x62\x10\xaf\xde\xb8\xb5\xd3"
+ "\xe8\x5e\x6c\xc3\x8a\x3e\x18\x07"
+ "\xf2\x2f\x7d\xa7\xe1\x3d\x4e\xb4"
+ "\x26\xa7\xa3\x93\x86\xb2\x04\x1e"
+ "\x53\x5d\x86\xd6\xde\x65\xca\xe3"
+ "\x4e\xc1\xcf\xef\xc8\x70\x1b\x83"
+ "\x13\xdd\x18\x8b\x0d\x76\xd2\xf6"
+ "\x37\x7a\x93\x7a\x50\x11\x9f\x96"
+ "\x86\x25\xfd\xac\xdc\xbe\x18\x93"
+ "\x19\x6b\xec\x58\x4f\xb9\x75\xa7"
+ "\xdd\x3f\x2f\xec\xc8\x5a\x84\xab"
+ "\xd5\xe4\x8a\x07\xf6\x4d\x23\xd6"
+ "\x03\xfb\x03\x6a\xea\x66\xbf\xd4"
+ "\xb1\x34\xfb\x78\xe9\x55\xdc\x7c"
+ "\x3d\x9c\xe5\x9a\xac\xc3\x7a\x80"
+ "\x24\x6d\xa0\xef\x25\x7c\xb7\xea"
+ "\xce\x4d\x5f\x18\x60\xce\x87\x22"
+ "\x66\x2f\xd5\xdd\xdd\x02\x21\x75"
+ "\x82\xa0\x1f\x58\xc6\xd3\x62\xf7"
+ "\x32\xd8\xaf\x1e\x07\x77\x51\x96"
+ "\xd5\x6b\x1e\x7e\x80\x02\xe8\x67"
+ "\xea\x17\x0b\x10\xd2\x3f\x28\x25"
+ "\x4f\x05\x77\x02\x14\x69\xf0\x2c"
+ "\xbe\x0c\xf1\x74\x30\xd1\xb9\x9b"
+ "\xfc\x8c\xbb\x04\x16\xd9\xba\xc3"
+ "\xbc\x91\x8a\xc4\x30\xa4\xb0\x12"
+ "\x4c\x21\x87\xcb\xc9\x1d\x16\x96"
+ "\x07\x6f\x23\x54\xb9\x6f\x79\xe5"
+ "\x64\xc0\x64\xda\xb1\xae\xdd\x60"
+ "\x6c\x1a\x9d\xd3\x04\x8e\x45\xb0"
+ "\x92\x61\xd0\x48\x81\xed\x5e\x1d"
+ "\xa0\xc9\xa4\x33\xc7\x13\x51\x5d"
+ "\x7f\x83\x73\xb6\x70\x18\x65\x3e"
+ "\x2f\x0e\x7a\x12\x39\x98\xab\xd8"
+ "\x7e\x6f\xa3\xd1\xba\x56\xad\xbd"
+ "\xf0\x03\x01\x1c\x85\x35\x9f\xeb"
+ "\x19\x63\xa1\xaf\xfe\x2d\x35\x50"
+ "\x39\xa0\x65\x7c\x95\x7e\x6b\xfe"
+ "\xc1\xac\x07\x7c\x98\x4f\xbe\x57"
+ "\xa7\x22\xec\xe2\x7e\x29\x09\x53"
+ "\xe8\xbf\xb4\x7e\x3f\x8f\xfc\x14"
+ "\xce\x54\xf9\x18\x58\xb5\xff\x44"
+ "\x05\x9d\xce\x1b\xb6\x82\x23\xc8"
+ "\x2e\xbc\x69\xbb\x4a\x29\x0f\x65"
+ "\x94\xf0\x63\x06\x0e\xef\x8c\xbd"
+ "\xff\xfd\xb0\x21\x6e\x57\x05\x75"
+ "\xda\xd5\xc4\xeb\x8d\x32\xf7\x50"
+ "\xd3\x6f\x22\xed\x5f\x8e\xa2\x5b"
+ "\x80\x8c\xc8\x78\x40\x24\x4b\x89"
+ "\x30\xce\x7a\x97\x0e\xc4\xaf\xef"
+ "\x9b\xb4\xcd\x66\x74\x14\x04\x2b"
+ "\xf7\xce\x0b\x1c\x6e\xc2\x78\x8c"
+ "\xca\xc5\xd0\x1c\x95\x4a\x91\x2d"
+ "\xa7\x20\xeb\x86\x52\xb7\x67\xd8"
+ "\x0c\xd6\x04\x14\xde\x51\x74\x75"
+ "\xe7\x11\xb4\x87\xa3\x3d\x2d\xad"
+ "\x4f\xef\xa0\x0f\x70\x00\x6d\x13"
+ "\x19\x1d\x41\x50\xe9\xd8\xf0\x32"
+ "\x71\xbc\xd3\x11\xf2\xac\xbe\xaf"
+ "\x75\x46\x65\x4e\x07\x34\x37\xa3"
+ "\x89\xfe\x75\xd4\x70\x4c\xc6\x3f"
+ "\x69\x24\x0e\x38\x67\x43\x8c\xde"
+ "\x06\xb5\xb8\xe7\xc4\xf0\x41\x8f"
+ "\xf0\xbd\x2f\x0b\xb9\x18\xf8\xde"
+ "\x64\xb1\xdb\xee\x00\x50\x77\xe1"
+ "\xc7\xff\xa6\xfa\xdd\x70\xf4\xe3"
+ "\x93\xe9\x77\x35\x3d\x4b\x2f\x2b"
+ "\x6d\x55\xf0\xfc\x88\x54\x4e\x89"
+ "\xc1\x8a\x23\x31\x2d\x14\x2a\xb8"
+ "\x1b\x15\xdd\x9e\x6e\x7b\xda\x05"
+ "\x91\x7d\x62\x64\x96\x72\xde\xfc"
+ "\xc1\xec\xf0\x23\x51\x6f\xdb\x5b"
+ "\x1d\x08\x57\xce\x09\xb8\xf6\xcd"
+ "\x8d\x95\xf2\x20\xbf\x0f\x20\x57"
+ "\x98\x81\x84\x4f\x15\x5c\x76\xe7"
+ "\x3e\x0a\x3a\x6c\xc4\x8a\xbe\x78"
+ "\x74\x77\xc3\x09\x4b\x5d\x48\xe4"
+ "\xc8\xcb\x0b\xea\x17\x28\xcf\xcf"
+ "\x31\x32\x44\xa4\xe5\x0e\x1a\x98"
+ "\x94\xc4\xf0\xff\xae\x3e\x44\xe8"
+ "\xa5\xb3\xb5\x37\x2f\xe8\xaf\x6f"
+ "\x28\xc1\x37\x5f\x31\xd2\xb9\x33"
+ "\xb1\xb2\x52\x94\x75\x2c\x29\x59"
+ "\x06\xc2\x25\xe8\x71\x65\x4e\xed"
+ "\xc0\x9c\xb1\xbb\x25\xdc\x6c\xe7"
+ "\x4b\xa5\x7a\x54\x7a\x60\xff\x7a"
+ "\xe0\x50\x40\x96\x35\x63\xe4\x0b"
+ "\x76\xbd\xa4\x65\x00\x1b\x57\x88"
+ "\xae\xed\x39\x88\x42\x11\x3c\xed"
+ "\x85\x67\x7d\xb9\x68\x82\xe9\x43"
+ "\x3c\x47\x53\xfa\xe8\xf8\x9f\x1f"
+ "\x9f\xef\x0f\xf7\x30\xd9\x30\x0e"
+ "\xb9\x9f\x69\x18\x2f\x7e\xf8\xf8"
+ "\xf8\x8c\x0f\xd4\x02\x4d\xea\xcd"
+ "\x0a\x9c\x6f\x71\x6d\x5a\x4c\x60"
+ "\xce\x20\x56\x32\xc6\xc5\x99\x1f"
+ "\x09\xe6\x4e\x18\x1a\x15\x13\xa8"
+ "\x7d\xb1\x6b\xc0\xb2\x6d\xf8\x26"
+ "\x66\xf8\x3d\x18\x74\x70\x66\x7a"
+ "\x34\x17\xde\xba\x47\xf1\x06\x18"
+ "\xcb\xaf\xeb\x4a\x1e\x8f\xa7\x77"
+ "\xe0\x3b\x78\x62\x66\xc9\x10\xea"
+ "\x1f\xb7\x29\x0a\x45\xa1\x1d\x1e"
+ "\x1d\xe2\x65\x61\x50\x9c\xd7\x05"
+ "\xf2\x0b\x5b\x12\x61\x02\xc8\xe5"
+ "\x63\x4f\x20\x0c\x07\x17\x33\x5e"
+ "\x03\x9a\x53\x0f\x2e\x55\xfe\x50"
+ "\x43\x7d\xd0\xb6\x7e\x5a\xda\xae"
+ "\x58\xef\x15\xa9\x83\xd9\x46\xb1"
+ "\x42\xaa\xf5\x02\x6c\xce\x92\x06"
+ "\x1b\xdb\x66\x45\x91\x79\xc2\x2d"
+ "\xe6\x53\xd3\x14\xfd\xbb\x44\x63"
+ "\xc6\xd7\x3d\x7a\x0c\x75\x78\x9d"
+ "\x5c\xa6\x39\xb3\xe5\x63\xca\x8b"
+ "\xfe\xd3\xef\x60\x83\xf6\x8e\x70"
+ "\xb6\x67\xc7\x77\xed\x23\xef\x4c"
+ "\xf0\xed\x2d\x07\x59\x6f\xc1\x01"
+ "\x34\x37\x08\xab\xd9\x1f\x09\xb1"
+ "\xce\x5b\x17\xff\x74\xf8\x9c\xd5"
+ "\x2c\x56\x39\x79\x0f\x69\x44\x75"
+ "\x58\x27\x01\xc4\xbf\xa7\xa1\x1d"
+ "\x90\x17\x77\x86\x5a\x3f\xd9\xd1"
+ "\x0e\xa0\x10\xf8\xec\x1e\xa5\x7f"
+ "\x5e\x36\xd1\xe3\x04\x2c\x70\xf7"
+ "\x8e\xc0\x98\x2f\x6c\x94\x2b\x41"
+ "\xb7\x60\x00\xb7\x2e\xb8\x02\x8d"
+ "\xb8\xb0\xd3\x86\xba\x1d\xd7\x90"
+ "\xd6\xb6\xe1\xfc\xd7\xd8\x28\x06"
+ "\x63\x9b\xce\x61\x24\x79\xc0\x70"
+ "\x52\xd0\xb6\xd4\x28\x95\x24\x87"
+ "\x03\x1f\xb7\x9a\xda\xa3\xfb\x52"
+ "\x5b\x68\xe7\x4c\x8c\x24\xe1\x42"
+ "\xf7\xd5\xfd\xad\x06\x32\x9f\xba"
+ "\xc1\xfc\xdd\xc6\xfc\xfc\xb3\x38"
+ "\x74\x56\x58\x40\x02\x37\x52\x2c"
+ "\x55\xcc\xb3\x9e\x7a\xe9\xd4\x38"
+ "\x41\x5e\x0c\x35\xe2\x11\xd1\x13"
+ "\xf8\xb7\x8d\x72\x6b\x22\x2a\xb0"
+ "\xdb\x08\xba\x35\xb9\x3f\xc8\xd3"
+ "\x24\x90\xec\x58\xd2\x09\xc7\x2d"
+ "\xed\x38\x80\x36\x72\x43\x27\x49"
+ "\x4a\x80\x8a\xa2\xe8\xd3\xda\x30"
+ "\x7d\xb6\x82\x37\x86\x92\x86\x3e"
+ "\x08\xb2\x28\x5a\x55\x44\x24\x7d"
+ "\x40\x48\x8a\xb6\x89\x58\x08\xa0"
+ "\xd6\x6d\x3a\x17\xbf\xf6\x54\xa2"
+ "\xf5\xd3\x8c\x0f\x78\x12\x57\x8b"
+ "\xd5\xc2\xfd\x58\x5b\x7f\x38\xe3"
+ "\xcc\xb7\x7c\x48\xb3\x20\xe8\x81"
+ "\x14\x32\x45\x05\xe0\xdb\x9f\x75"
+ "\x85\xb4\x6a\xfc\x95\xe3\x54\x22"
+ "\x12\xee\x30\xfe\xd8\x30\xef\x34"
+ "\x50\xab\x46\x30\x98\x2f\xb7\xc0"
+ "\x15\xa2\x83\xb6\xf2\x06\x21\xa2"
+ "\xc3\x26\x37\x14\xd1\x4d\xb5\x10"
+ "\x52\x76\x4d\x6a\xee\xb5\x2b\x15"
+ "\xb7\xf9\x51\xe8\x2a\xaf\xc7\xfa"
+ "\x77\xaf\xb0\x05\x4d\xd1\x68\x8e"
+ "\x74\x05\x9f\x9d\x93\xa5\x3e\x7f"
+ "\x4e\x5f\x9d\xcb\x09\xc7\x83\xe3"
+ "\x02\x9d\x27\x1f\xef\x85\x05\x8d"
+ "\xec\x55\x88\x0f\x0d\x7c\x4c\xe8"
+ "\xa1\x75\xa0\xd8\x06\x47\x14\xef"
+ "\xaa\x61\xcf\x26\x15\xad\xd8\xa3"
+ "\xaa\x75\xf2\x78\x4a\x5a\x61\xdf"
+ "\x8b\xc7\x04\xbc\xb2\x32\xd2\x7e"
+ "\x42\xee\xb4\x2f\x51\xff\x7b\x2e"
+ "\xd3\x02\xe8\xdc\x5d\x0d\x50\xdc"
+ "\xae\xb7\x46\xf9\xa8\xe6\xd0\x16"
+ "\xcc\xe6\x2c\x81\xc7\xad\xe9\xf0"
+ "\x05\x72\x6d\x3d\x0a\x7a\xa9\x02"
+ "\xac\x82\x93\x6e\xb6\x1c\x28\xfc"
+ "\x44\x12\xfb\x73\x77\xd4\x13\x39"
+ "\x29\x88\x8a\xf3\x5c\xa6\x36\xa0"
+ "\x2a\xed\x7e\xb1\x1d\xd6\x4c\x6b"
+ "\x41\x01\x18\x5d\x5d\x07\x97\xa6"
+ "\x4b\xef\x31\x18\xea\xac\xb1\x84"
+ "\x21\xed\xda\x86",
+ .rlen = 4100,
+ .np = 2,
+ .tap = { 4064, 36 },
+#endif
+ },
+};
+
+static struct cipher_testvec aes_ctr_rfc3686_dec_tv_template[] = {
+ { /* From RFC 3686 */
+ .key = "\xae\x68\x52\xf8\x12\x10\x67\xcc"
+ "\x4b\xf7\xa5\x76\x55\x77\xf3\x9e"
+ "\x00\x00\x00\x30",
+ .klen = 20,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .input = "\xe4\x09\x5d\x4f\xb7\xa7\xb3\x79"
+ "\x2d\x61\x75\xa3\x26\x13\x11\xb8",
+ .ilen = 16,
+ .result = "Single block msg",
+ .rlen = 16,
+ }, {
+ .key = "\x7e\x24\x06\x78\x17\xfa\xe0\xd7"
+ "\x43\xd6\xce\x1f\x32\x53\x91\x63"
+ "\x00\x6c\xb6\xdb",
+ .klen = 20,
+ .iv = "\xc0\x54\x3b\x59\xda\x48\xd9\x0b",
+ .input = "\x51\x04\xa1\x06\x16\x8a\x72\xd9"
+ "\x79\x0d\x41\xee\x8e\xda\xd3\x88"
+ "\xeb\x2e\x1e\xfc\x46\xda\x57\xc8"
+ "\xfc\xe6\x30\xdf\x91\x41\xbe\x28",
+ .ilen = 32,
+ .result = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
+ .rlen = 32,
+ }, {
+ .key = "\x16\xaf\x5b\x14\x5f\xc9\xf5\x79"
+ "\xc1\x75\xf9\x3e\x3b\xfb\x0e\xed"
+ "\x86\x3d\x06\xcc\xfd\xb7\x85\x15"
+ "\x00\x00\x00\x48",
+ .klen = 28,
+ .iv = "\x36\x73\x3c\x14\x7d\x6d\x93\xcb",
+ .input = "\x4b\x55\x38\x4f\xe2\x59\xc9\xc8"
+ "\x4e\x79\x35\xa0\x03\xcb\xe9\x28",
+ .ilen = 16,
+ .result = "Single block msg",
+ .rlen = 16,
+ }, {
+ .key = "\x7c\x5c\xb2\x40\x1b\x3d\xc3\x3c"
+ "\x19\xe7\x34\x08\x19\xe0\xf6\x9c"
+ "\x67\x8c\x3d\xb8\xe6\xf6\xa9\x1a"
+ "\x00\x96\xb0\x3b",
+ .klen = 28,
+ .iv = "\x02\x0c\x6e\xad\xc2\xcb\x50\x0d",
+ .input = "\x45\x32\x43\xfc\x60\x9b\x23\x32"
+ "\x7e\xdf\xaa\xfa\x71\x31\xcd\x9f"
+ "\x84\x90\x70\x1c\x5a\xd4\xa7\x9c"
+ "\xfc\x1f\xe0\xff\x42\xf4\xfb\x00",
+ .ilen = 32,
+ .result = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
+ .rlen = 32,
+ }, {
+ .key = "\x77\x6b\xef\xf2\x85\x1d\xb0\x6f"
+ "\x4c\x8a\x05\x42\xc8\x69\x6f\x6c"
+ "\x6a\x81\xaf\x1e\xec\x96\xb4\xd3"
+ "\x7f\xc1\xd6\x89\xe6\xc1\xc1\x04"
+ "\x00\x00\x00\x60",
+ .klen = 36,
+ .iv = "\xdb\x56\x72\xc9\x7a\xa8\xf0\xb2",
+ .input = "\x14\x5a\xd0\x1d\xbf\x82\x4e\xc7"
+ "\x56\x08\x63\xdc\x71\xe3\xe0\xc0",
+ .ilen = 16,
+ .result = "Single block msg",
+ .rlen = 16,
+ }, {
+ .key = "\xf6\xd6\x6d\x6b\xd5\x2d\x59\xbb"
+ "\x07\x96\x36\x58\x79\xef\xf8\x86"
+ "\xc6\x6d\xd5\x1a\x5b\x6a\x99\x74"
+ "\x4b\x50\x59\x0c\x87\xa2\x38\x84"
+ "\x00\xfa\xac\x24",
+ .klen = 36,
+ .iv = "\xc1\x58\x5e\xf1\x5a\x43\xd8\x75",
+ .input = "\xf0\x5e\x23\x1b\x38\x94\x61\x2c"
+ "\x49\xee\x00\x0b\x80\x4e\xb2\xa9"
+ "\xb8\x30\x6b\x50\x8f\x83\x9d\x6a"
+ "\x55\x30\x83\x1d\x93\x44\xaf\x1c",
+ .ilen = 32,
+ .result = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
+ .rlen = 32,
+ },
+};
+
+static struct aead_testvec aes_gcm_enc_tv_template[] = {
+ { /* From McGrew & Viega - http://citeseer.ist.psu.edu/656989.html */
+ .key = zeroed_string,
+ .klen = 16,
+ .result = "\x58\xe2\xfc\xce\xfa\x7e\x30\x61"
+ "\x36\x7f\x1d\x57\xa4\xe7\x45\x5a",
+ .rlen = 16,
+ }, {
+ .key = zeroed_string,
+ .klen = 16,
+ .input = zeroed_string,
+ .ilen = 16,
+ .result = "\x03\x88\xda\xce\x60\xb6\xa3\x92"
+ "\xf3\x28\xc2\xb9\x71\xb2\xfe\x78"
+ "\xab\x6e\x47\xd4\x2c\xec\x13\xbd"
+ "\xf5\x3a\x67\xb2\x12\x57\xbd\xdf",
+ .rlen = 32,
+ }, {
+ .key = "\xfe\xff\xe9\x92\x86\x65\x73\x1c"
+ "\x6d\x6a\x8f\x94\x67\x30\x83\x08",
+ .klen = 16,
+ .iv = "\xca\xfe\xba\xbe\xfa\xce\xdb\xad"
+ "\xde\xca\xf8\x88",
+ .input = "\xd9\x31\x32\x25\xf8\x84\x06\xe5"
+ "\xa5\x59\x09\xc5\xaf\xf5\x26\x9a"
+ "\x86\xa7\xa9\x53\x15\x34\xf7\xda"
+ "\x2e\x4c\x30\x3d\x8a\x31\x8a\x72"
+ "\x1c\x3c\x0c\x95\x95\x68\x09\x53"
+ "\x2f\xcf\x0e\x24\x49\xa6\xb5\x25"
+ "\xb1\x6a\xed\xf5\xaa\x0d\xe6\x57"
+ "\xba\x63\x7b\x39\x1a\xaf\xd2\x55",
+ .ilen = 64,
+ .result = "\x42\x83\x1e\xc2\x21\x77\x74\x24"
+ "\x4b\x72\x21\xb7\x84\xd0\xd4\x9c"
+ "\xe3\xaa\x21\x2f\x2c\x02\xa4\xe0"
+ "\x35\xc1\x7e\x23\x29\xac\xa1\x2e"
+ "\x21\xd5\x14\xb2\x54\x66\x93\x1c"
+ "\x7d\x8f\x6a\x5a\xac\x84\xaa\x05"
+ "\x1b\xa3\x0b\x39\x6a\x0a\xac\x97"
+ "\x3d\x58\xe0\x91\x47\x3f\x59\x85"
+ "\x4d\x5c\x2a\xf3\x27\xcd\x64\xa6"
+ "\x2c\xf3\x5a\xbd\x2b\xa6\xfa\xb4",
+ .rlen = 80,
+ }, {
+ .key = "\xfe\xff\xe9\x92\x86\x65\x73\x1c"
+ "\x6d\x6a\x8f\x94\x67\x30\x83\x08",
+ .klen = 16,
+ .iv = "\xca\xfe\xba\xbe\xfa\xce\xdb\xad"
+ "\xde\xca\xf8\x88",
+ .input = "\xd9\x31\x32\x25\xf8\x84\x06\xe5"
+ "\xa5\x59\x09\xc5\xaf\xf5\x26\x9a"
+ "\x86\xa7\xa9\x53\x15\x34\xf7\xda"
+ "\x2e\x4c\x30\x3d\x8a\x31\x8a\x72"
+ "\x1c\x3c\x0c\x95\x95\x68\x09\x53"
+ "\x2f\xcf\x0e\x24\x49\xa6\xb5\x25"
+ "\xb1\x6a\xed\xf5\xaa\x0d\xe6\x57"
+ "\xba\x63\x7b\x39",
+ .ilen = 60,
+ .assoc = "\xfe\xed\xfa\xce\xde\xad\xbe\xef"
+ "\xfe\xed\xfa\xce\xde\xad\xbe\xef"
+ "\xab\xad\xda\xd2",
+ .alen = 20,
+ .result = "\x42\x83\x1e\xc2\x21\x77\x74\x24"
+ "\x4b\x72\x21\xb7\x84\xd0\xd4\x9c"
+ "\xe3\xaa\x21\x2f\x2c\x02\xa4\xe0"
+ "\x35\xc1\x7e\x23\x29\xac\xa1\x2e"
+ "\x21\xd5\x14\xb2\x54\x66\x93\x1c"
+ "\x7d\x8f\x6a\x5a\xac\x84\xaa\x05"
+ "\x1b\xa3\x0b\x39\x6a\x0a\xac\x97"
+ "\x3d\x58\xe0\x91"
+ "\x5b\xc9\x4f\xbc\x32\x21\xa5\xdb"
+ "\x94\xfa\xe9\x5a\xe7\x12\x1a\x47",
+ .rlen = 76,
+ }, {
+ .key = zeroed_string,
+ .klen = 24,
+ .result = "\xcd\x33\xb2\x8a\xc7\x73\xf7\x4b"
+ "\xa0\x0e\xd1\xf3\x12\x57\x24\x35",
+ .rlen = 16,
+ }, {
+ .key = zeroed_string,
+ .klen = 24,
+ .input = zeroed_string,
+ .ilen = 16,
+ .result = "\x98\xe7\x24\x7c\x07\xf0\xfe\x41"
+ "\x1c\x26\x7e\x43\x84\xb0\xf6\x00"
+ "\x2f\xf5\x8d\x80\x03\x39\x27\xab"
+ "\x8e\xf4\xd4\x58\x75\x14\xf0\xfb",
+ .rlen = 32,
+ }, {
+ .key = "\xfe\xff\xe9\x92\x86\x65\x73\x1c"
+ "\x6d\x6a\x8f\x94\x67\x30\x83\x08"
+ "\xfe\xff\xe9\x92\x86\x65\x73\x1c",
+ .klen = 24,
+ .iv = "\xca\xfe\xba\xbe\xfa\xce\xdb\xad"
+ "\xde\xca\xf8\x88",
+ .input = "\xd9\x31\x32\x25\xf8\x84\x06\xe5"
+ "\xa5\x59\x09\xc5\xaf\xf5\x26\x9a"
+ "\x86\xa7\xa9\x53\x15\x34\xf7\xda"
+ "\x2e\x4c\x30\x3d\x8a\x31\x8a\x72"
+ "\x1c\x3c\x0c\x95\x95\x68\x09\x53"
+ "\x2f\xcf\x0e\x24\x49\xa6\xb5\x25"
+ "\xb1\x6a\xed\xf5\xaa\x0d\xe6\x57"
+ "\xba\x63\x7b\x39\x1a\xaf\xd2\x55",
+ .ilen = 64,
+ .result = "\x39\x80\xca\x0b\x3c\x00\xe8\x41"
+ "\xeb\x06\xfa\xc4\x87\x2a\x27\x57"
+ "\x85\x9e\x1c\xea\xa6\xef\xd9\x84"
+ "\x62\x85\x93\xb4\x0c\xa1\xe1\x9c"
+ "\x7d\x77\x3d\x00\xc1\x44\xc5\x25"
+ "\xac\x61\x9d\x18\xc8\x4a\x3f\x47"
+ "\x18\xe2\x44\x8b\x2f\xe3\x24\xd9"
+ "\xcc\xda\x27\x10\xac\xad\xe2\x56"
+ "\x99\x24\xa7\xc8\x58\x73\x36\xbf"
+ "\xb1\x18\x02\x4d\xb8\x67\x4a\x14",
+ .rlen = 80,
+ }, {
+ .key = "\xfe\xff\xe9\x92\x86\x65\x73\x1c"
+ "\x6d\x6a\x8f\x94\x67\x30\x83\x08"
+ "\xfe\xff\xe9\x92\x86\x65\x73\x1c",
+ .klen = 24,
+ .iv = "\xca\xfe\xba\xbe\xfa\xce\xdb\xad"
+ "\xde\xca\xf8\x88",
+ .input = "\xd9\x31\x32\x25\xf8\x84\x06\xe5"
+ "\xa5\x59\x09\xc5\xaf\xf5\x26\x9a"
+ "\x86\xa7\xa9\x53\x15\x34\xf7\xda"
+ "\x2e\x4c\x30\x3d\x8a\x31\x8a\x72"
+ "\x1c\x3c\x0c\x95\x95\x68\x09\x53"
+ "\x2f\xcf\x0e\x24\x49\xa6\xb5\x25"
+ "\xb1\x6a\xed\xf5\xaa\x0d\xe6\x57"
+ "\xba\x63\x7b\x39",
+ .ilen = 60,
+ .assoc = "\xfe\xed\xfa\xce\xde\xad\xbe\xef"
+ "\xfe\xed\xfa\xce\xde\xad\xbe\xef"
+ "\xab\xad\xda\xd2",
+ .alen = 20,
+ .result = "\x39\x80\xca\x0b\x3c\x00\xe8\x41"
+ "\xeb\x06\xfa\xc4\x87\x2a\x27\x57"
+ "\x85\x9e\x1c\xea\xa6\xef\xd9\x84"
+ "\x62\x85\x93\xb4\x0c\xa1\xe1\x9c"
+ "\x7d\x77\x3d\x00\xc1\x44\xc5\x25"
+ "\xac\x61\x9d\x18\xc8\x4a\x3f\x47"
+ "\x18\xe2\x44\x8b\x2f\xe3\x24\xd9"
+ "\xcc\xda\x27\x10"
+ "\x25\x19\x49\x8e\x80\xf1\x47\x8f"
+ "\x37\xba\x55\xbd\x6d\x27\x61\x8c",
+ .rlen = 76,
+ .np = 2,
+ .tap = { 32, 28 },
+ .anp = 2,
+ .atap = { 8, 12 }
+ }, {
+ .key = zeroed_string,
+ .klen = 32,
+ .result = "\x53\x0f\x8a\xfb\xc7\x45\x36\xb9"
+ "\xa9\x63\xb4\xf1\xc4\xcb\x73\x8b",
+ .rlen = 16,
+ }
+};
+
+static struct aead_testvec aes_gcm_dec_tv_template[] = {
+ { /* From McGrew & Viega - http://citeseer.ist.psu.edu/656989.html */
+ .key = zeroed_string,
+ .klen = 32,
+ .input = "\xce\xa7\x40\x3d\x4d\x60\x6b\x6e"
+ "\x07\x4e\xc5\xd3\xba\xf3\x9d\x18"
+ "\xd0\xd1\xc8\xa7\x99\x99\x6b\xf0"
+ "\x26\x5b\x98\xb5\xd4\x8a\xb9\x19",
+ .ilen = 32,
+ .result = zeroed_string,
+ .rlen = 16,
+ }, {
+ .key = "\xfe\xff\xe9\x92\x86\x65\x73\x1c"
+ "\x6d\x6a\x8f\x94\x67\x30\x83\x08"
+ "\xfe\xff\xe9\x92\x86\x65\x73\x1c"
+ "\x6d\x6a\x8f\x94\x67\x30\x83\x08",
+ .klen = 32,
+ .iv = "\xca\xfe\xba\xbe\xfa\xce\xdb\xad"
+ "\xde\xca\xf8\x88",
+ .input = "\x52\x2d\xc1\xf0\x99\x56\x7d\x07"
+ "\xf4\x7f\x37\xa3\x2a\x84\x42\x7d"
+ "\x64\x3a\x8c\xdc\xbf\xe5\xc0\xc9"
+ "\x75\x98\xa2\xbd\x25\x55\xd1\xaa"
+ "\x8c\xb0\x8e\x48\x59\x0d\xbb\x3d"
+ "\xa7\xb0\x8b\x10\x56\x82\x88\x38"
+ "\xc5\xf6\x1e\x63\x93\xba\x7a\x0a"
+ "\xbc\xc9\xf6\x62\x89\x80\x15\xad"
+ "\xb0\x94\xda\xc5\xd9\x34\x71\xbd"
+ "\xec\x1a\x50\x22\x70\xe3\xcc\x6c",
+ .ilen = 80,
+ .result = "\xd9\x31\x32\x25\xf8\x84\x06\xe5"
+ "\xa5\x59\x09\xc5\xaf\xf5\x26\x9a"
+ "\x86\xa7\xa9\x53\x15\x34\xf7\xda"
+ "\x2e\x4c\x30\x3d\x8a\x31\x8a\x72"
+ "\x1c\x3c\x0c\x95\x95\x68\x09\x53"
+ "\x2f\xcf\x0e\x24\x49\xa6\xb5\x25"
+ "\xb1\x6a\xed\xf5\xaa\x0d\xe6\x57"
+ "\xba\x63\x7b\x39\x1a\xaf\xd2\x55",
+ .rlen = 64,
+ }, {
+ .key = "\xfe\xff\xe9\x92\x86\x65\x73\x1c"
+ "\x6d\x6a\x8f\x94\x67\x30\x83\x08"
+ "\xfe\xff\xe9\x92\x86\x65\x73\x1c"
+ "\x6d\x6a\x8f\x94\x67\x30\x83\x08",
+ .klen = 32,
+ .iv = "\xca\xfe\xba\xbe\xfa\xce\xdb\xad"
+ "\xde\xca\xf8\x88",
+ .input = "\x52\x2d\xc1\xf0\x99\x56\x7d\x07"
+ "\xf4\x7f\x37\xa3\x2a\x84\x42\x7d"
+ "\x64\x3a\x8c\xdc\xbf\xe5\xc0\xc9"
+ "\x75\x98\xa2\xbd\x25\x55\xd1\xaa"
+ "\x8c\xb0\x8e\x48\x59\x0d\xbb\x3d"
+ "\xa7\xb0\x8b\x10\x56\x82\x88\x38"
+ "\xc5\xf6\x1e\x63\x93\xba\x7a\x0a"
+ "\xbc\xc9\xf6\x62"
+ "\x76\xfc\x6e\xce\x0f\x4e\x17\x68"
+ "\xcd\xdf\x88\x53\xbb\x2d\x55\x1b",
+ .ilen = 76,
+ .assoc = "\xfe\xed\xfa\xce\xde\xad\xbe\xef"
+ "\xfe\xed\xfa\xce\xde\xad\xbe\xef"
+ "\xab\xad\xda\xd2",
+ .alen = 20,
+ .result = "\xd9\x31\x32\x25\xf8\x84\x06\xe5"
+ "\xa5\x59\x09\xc5\xaf\xf5\x26\x9a"
+ "\x86\xa7\xa9\x53\x15\x34\xf7\xda"
+ "\x2e\x4c\x30\x3d\x8a\x31\x8a\x72"
+ "\x1c\x3c\x0c\x95\x95\x68\x09\x53"
+ "\x2f\xcf\x0e\x24\x49\xa6\xb5\x25"
+ "\xb1\x6a\xed\xf5\xaa\x0d\xe6\x57"
+ "\xba\x63\x7b\x39",
+ .rlen = 60,
+ .np = 2,
+ .tap = { 48, 28 },
+ .anp = 3,
+ .atap = { 8, 8, 4 }
+ }, {
+ .key = "\xfe\xff\xe9\x92\x86\x65\x73\x1c"
+ "\x6d\x6a\x8f\x94\x67\x30\x83\x08",
+ .klen = 16,
+ .iv = "\xca\xfe\xba\xbe\xfa\xce\xdb\xad"
+ "\xde\xca\xf8\x88",
+ .input = "\x42\x83\x1e\xc2\x21\x77\x74\x24"
+ "\x4b\x72\x21\xb7\x84\xd0\xd4\x9c"
+ "\xe3\xaa\x21\x2f\x2c\x02\xa4\xe0"
+ "\x35\xc1\x7e\x23\x29\xac\xa1\x2e"
+ "\x21\xd5\x14\xb2\x54\x66\x93\x1c"
+ "\x7d\x8f\x6a\x5a\xac\x84\xaa\x05"
+ "\x1b\xa3\x0b\x39\x6a\x0a\xac\x97"
+ "\x3d\x58\xe0\x91\x47\x3f\x59\x85"
+ "\x4d\x5c\x2a\xf3\x27\xcd\x64\xa6"
+ "\x2c\xf3\x5a\xbd\x2b\xa6\xfa\xb4",
+ .ilen = 80,
+ .result = "\xd9\x31\x32\x25\xf8\x84\x06\xe5"
+ "\xa5\x59\x09\xc5\xaf\xf5\x26\x9a"
+ "\x86\xa7\xa9\x53\x15\x34\xf7\xda"
+ "\x2e\x4c\x30\x3d\x8a\x31\x8a\x72"
+ "\x1c\x3c\x0c\x95\x95\x68\x09\x53"
+ "\x2f\xcf\x0e\x24\x49\xa6\xb5\x25"
+ "\xb1\x6a\xed\xf5\xaa\x0d\xe6\x57"
+ "\xba\x63\x7b\x39\x1a\xaf\xd2\x55",
+ .rlen = 64,
+ }, {
+ .key = "\xfe\xff\xe9\x92\x86\x65\x73\x1c"
+ "\x6d\x6a\x8f\x94\x67\x30\x83\x08",
+ .klen = 16,
+ .iv = "\xca\xfe\xba\xbe\xfa\xce\xdb\xad"
+ "\xde\xca\xf8\x88",
+ .input = "\x42\x83\x1e\xc2\x21\x77\x74\x24"
+ "\x4b\x72\x21\xb7\x84\xd0\xd4\x9c"
+ "\xe3\xaa\x21\x2f\x2c\x02\xa4\xe0"
+ "\x35\xc1\x7e\x23\x29\xac\xa1\x2e"
+ "\x21\xd5\x14\xb2\x54\x66\x93\x1c"
+ "\x7d\x8f\x6a\x5a\xac\x84\xaa\x05"
+ "\x1b\xa3\x0b\x39\x6a\x0a\xac\x97"
+ "\x3d\x58\xe0\x91"
+ "\x5b\xc9\x4f\xbc\x32\x21\xa5\xdb"
+ "\x94\xfa\xe9\x5a\xe7\x12\x1a\x47",
+ .ilen = 76,
+ .assoc = "\xfe\xed\xfa\xce\xde\xad\xbe\xef"
+ "\xfe\xed\xfa\xce\xde\xad\xbe\xef"
+ "\xab\xad\xda\xd2",
+ .alen = 20,
+ .result = "\xd9\x31\x32\x25\xf8\x84\x06\xe5"
+ "\xa5\x59\x09\xc5\xaf\xf5\x26\x9a"
+ "\x86\xa7\xa9\x53\x15\x34\xf7\xda"
+ "\x2e\x4c\x30\x3d\x8a\x31\x8a\x72"
+ "\x1c\x3c\x0c\x95\x95\x68\x09\x53"
+ "\x2f\xcf\x0e\x24\x49\xa6\xb5\x25"
+ "\xb1\x6a\xed\xf5\xaa\x0d\xe6\x57"
+ "\xba\x63\x7b\x39",
+ .rlen = 60,
+ }, {
+ .key = zeroed_string,
+ .klen = 24,
+ .input = "\x98\xe7\x24\x7c\x07\xf0\xfe\x41"
+ "\x1c\x26\x7e\x43\x84\xb0\xf6\x00"
+ "\x2f\xf5\x8d\x80\x03\x39\x27\xab"
+ "\x8e\xf4\xd4\x58\x75\x14\xf0\xfb",
+ .ilen = 32,
+ .result = zeroed_string,
+ .rlen = 16,
+ }, {
+ .key = "\xfe\xff\xe9\x92\x86\x65\x73\x1c"
+ "\x6d\x6a\x8f\x94\x67\x30\x83\x08"
+ "\xfe\xff\xe9\x92\x86\x65\x73\x1c",
+ .klen = 24,
+ .iv = "\xca\xfe\xba\xbe\xfa\xce\xdb\xad"
+ "\xde\xca\xf8\x88",
+ .input = "\x39\x80\xca\x0b\x3c\x00\xe8\x41"
+ "\xeb\x06\xfa\xc4\x87\x2a\x27\x57"
+ "\x85\x9e\x1c\xea\xa6\xef\xd9\x84"
+ "\x62\x85\x93\xb4\x0c\xa1\xe1\x9c"
+ "\x7d\x77\x3d\x00\xc1\x44\xc5\x25"
+ "\xac\x61\x9d\x18\xc8\x4a\x3f\x47"
+ "\x18\xe2\x44\x8b\x2f\xe3\x24\xd9"
+ "\xcc\xda\x27\x10\xac\xad\xe2\x56"
+ "\x99\x24\xa7\xc8\x58\x73\x36\xbf"
+ "\xb1\x18\x02\x4d\xb8\x67\x4a\x14",
+ .ilen = 80,
+ .result = "\xd9\x31\x32\x25\xf8\x84\x06\xe5"
+ "\xa5\x59\x09\xc5\xaf\xf5\x26\x9a"
+ "\x86\xa7\xa9\x53\x15\x34\xf7\xda"
+ "\x2e\x4c\x30\x3d\x8a\x31\x8a\x72"
+ "\x1c\x3c\x0c\x95\x95\x68\x09\x53"
+ "\x2f\xcf\x0e\x24\x49\xa6\xb5\x25"
+ "\xb1\x6a\xed\xf5\xaa\x0d\xe6\x57"
+ "\xba\x63\x7b\x39\x1a\xaf\xd2\x55",
+ .rlen = 64,
+ }, {
+ .key = "\xfe\xff\xe9\x92\x86\x65\x73\x1c"
+ "\x6d\x6a\x8f\x94\x67\x30\x83\x08"
+ "\xfe\xff\xe9\x92\x86\x65\x73\x1c",
+ .klen = 24,
+ .iv = "\xca\xfe\xba\xbe\xfa\xce\xdb\xad"
+ "\xde\xca\xf8\x88",
+ .input = "\x39\x80\xca\x0b\x3c\x00\xe8\x41"
+ "\xeb\x06\xfa\xc4\x87\x2a\x27\x57"
+ "\x85\x9e\x1c\xea\xa6\xef\xd9\x84"
+ "\x62\x85\x93\xb4\x0c\xa1\xe1\x9c"
+ "\x7d\x77\x3d\x00\xc1\x44\xc5\x25"
+ "\xac\x61\x9d\x18\xc8\x4a\x3f\x47"
+ "\x18\xe2\x44\x8b\x2f\xe3\x24\xd9"
+ "\xcc\xda\x27\x10"
+ "\x25\x19\x49\x8e\x80\xf1\x47\x8f"
+ "\x37\xba\x55\xbd\x6d\x27\x61\x8c",
+ .ilen = 76,
+ .assoc = "\xfe\xed\xfa\xce\xde\xad\xbe\xef"
+ "\xfe\xed\xfa\xce\xde\xad\xbe\xef"
+ "\xab\xad\xda\xd2",
+ .alen = 20,
+ .result = "\xd9\x31\x32\x25\xf8\x84\x06\xe5"
+ "\xa5\x59\x09\xc5\xaf\xf5\x26\x9a"
+ "\x86\xa7\xa9\x53\x15\x34\xf7\xda"
+ "\x2e\x4c\x30\x3d\x8a\x31\x8a\x72"
+ "\x1c\x3c\x0c\x95\x95\x68\x09\x53"
+ "\x2f\xcf\x0e\x24\x49\xa6\xb5\x25"
+ "\xb1\x6a\xed\xf5\xaa\x0d\xe6\x57"
+ "\xba\x63\x7b\x39",
+ .rlen = 60,
+ }
+};
+
+static struct aead_testvec aes_ccm_enc_tv_template[] = {
+ { /* From RFC 3610 */
+ .key = "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
+ "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf",
+ .klen = 16,
+ .iv = "\x01\x00\x00\x00\x03\x02\x01\x00"
+ "\xa0\xa1\xa2\xa3\xa4\xa5\x00\x00",
+ .assoc = "\x00\x01\x02\x03\x04\x05\x06\x07",
+ .alen = 8,
+ .input = "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e",
+ .ilen = 23,
+ .result = "\x58\x8c\x97\x9a\x61\xc6\x63\xd2"
+ "\xf0\x66\xd0\xc2\xc0\xf9\x89\x80"
+ "\x6d\x5f\x6b\x61\xda\xc3\x84\x17"
+ "\xe8\xd1\x2c\xfd\xf9\x26\xe0",
+ .rlen = 31,
+ }, {
+ .key = "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
+ "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf",
+ .klen = 16,
+ .iv = "\x01\x00\x00\x00\x07\x06\x05\x04"
+ "\xa0\xa1\xa2\xa3\xa4\xa5\x00\x00",
+ .assoc = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b",
+ .alen = 12,
+ .input = "\x0c\x0d\x0e\x0f\x10\x11\x12\x13"
+ "\x14\x15\x16\x17\x18\x19\x1a\x1b"
+ "\x1c\x1d\x1e\x1f",
+ .ilen = 20,
+ .result = "\xdc\xf1\xfb\x7b\x5d\x9e\x23\xfb"
+ "\x9d\x4e\x13\x12\x53\x65\x8a\xd8"
+ "\x6e\xbd\xca\x3e\x51\xe8\x3f\x07"
+ "\x7d\x9c\x2d\x93",
+ .rlen = 28,
+ }, {
+ .key = "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
+ "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf",
+ .klen = 16,
+ .iv = "\x01\x00\x00\x00\x0b\x0a\x09\x08"
+ "\xa0\xa1\xa2\xa3\xa4\xa5\x00\x00",
+ .assoc = "\x00\x01\x02\x03\x04\x05\x06\x07",
+ .alen = 8,
+ .input = "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
+ "\x20",
+ .ilen = 25,
+ .result = "\x82\x53\x1a\x60\xcc\x24\x94\x5a"
+ "\x4b\x82\x79\x18\x1a\xb5\xc8\x4d"
+ "\xf2\x1c\xe7\xf9\xb7\x3f\x42\xe1"
+ "\x97\xea\x9c\x07\xe5\x6b\x5e\xb1"
+ "\x7e\x5f\x4e",
+ .rlen = 35,
+ }, {
+ .key = "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
+ "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf",
+ .klen = 16,
+ .iv = "\x01\x00\x00\x00\x0c\x0b\x0a\x09"
+ "\xa0\xa1\xa2\xa3\xa4\xa5\x00\x00",
+ .assoc = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b",
+ .alen = 12,
+ .input = "\x0c\x0d\x0e\x0f\x10\x11\x12\x13"
+ "\x14\x15\x16\x17\x18\x19\x1a\x1b"
+ "\x1c\x1d\x1e",
+ .ilen = 19,
+ .result = "\x07\x34\x25\x94\x15\x77\x85\x15"
+ "\x2b\x07\x40\x98\x33\x0a\xbb\x14"
+ "\x1b\x94\x7b\x56\x6a\xa9\x40\x6b"
+ "\x4d\x99\x99\x88\xdd",
+ .rlen = 29,
+ }, {
+ .key = "\xd7\x82\x8d\x13\xb2\xb0\xbd\xc3"
+ "\x25\xa7\x62\x36\xdf\x93\xcc\x6b",
+ .klen = 16,
+ .iv = "\x01\x00\x33\x56\x8e\xf7\xb2\x63"
+ "\x3c\x96\x96\x76\x6c\xfa\x00\x00",
+ .assoc = "\x63\x01\x8f\x76\xdc\x8a\x1b\xcb",
+ .alen = 8,
+ .input = "\x90\x20\xea\x6f\x91\xbd\xd8\x5a"
+ "\xfa\x00\x39\xba\x4b\xaf\xf9\xbf"
+ "\xb7\x9c\x70\x28\x94\x9c\xd0\xec",
+ .ilen = 24,
+ .result = "\x4c\xcb\x1e\x7c\xa9\x81\xbe\xfa"
+ "\xa0\x72\x6c\x55\xd3\x78\x06\x12"
+ "\x98\xc8\x5c\x92\x81\x4a\xbc\x33"
+ "\xc5\x2e\xe8\x1d\x7d\x77\xc0\x8a",
+ .rlen = 32,
+ }, {
+ .key = "\xd7\x82\x8d\x13\xb2\xb0\xbd\xc3"
+ "\x25\xa7\x62\x36\xdf\x93\xcc\x6b",
+ .klen = 16,
+ .iv = "\x01\x00\xd5\x60\x91\x2d\x3f\x70"
+ "\x3c\x96\x96\x76\x6c\xfa\x00\x00",
+ .assoc = "\xcd\x90\x44\xd2\xb7\x1f\xdb\x81"
+ "\x20\xea\x60\xc0",
+ .alen = 12,
+ .input = "\x64\x35\xac\xba\xfb\x11\xa8\x2e"
+ "\x2f\x07\x1d\x7c\xa4\xa5\xeb\xd9"
+ "\x3a\x80\x3b\xa8\x7f",
+ .ilen = 21,
+ .result = "\x00\x97\x69\xec\xab\xdf\x48\x62"
+ "\x55\x94\xc5\x92\x51\xe6\x03\x57"
+ "\x22\x67\x5e\x04\xc8\x47\x09\x9e"
+ "\x5a\xe0\x70\x45\x51",
+ .rlen = 29,
+ }, {
+ .key = "\xd7\x82\x8d\x13\xb2\xb0\xbd\xc3"
+ "\x25\xa7\x62\x36\xdf\x93\xcc\x6b",
+ .klen = 16,
+ .iv = "\x01\x00\x42\xff\xf8\xf1\x95\x1c"
+ "\x3c\x96\x96\x76\x6c\xfa\x00\x00",
+ .assoc = "\xd8\x5b\xc7\xe6\x9f\x94\x4f\xb8",
+ .alen = 8,
+ .input = "\x8a\x19\xb9\x50\xbc\xf7\x1a\x01"
+ "\x8e\x5e\x67\x01\xc9\x17\x87\x65"
+ "\x98\x09\xd6\x7d\xbe\xdd\x18",
+ .ilen = 23,
+ .result = "\xbc\x21\x8d\xaa\x94\x74\x27\xb6"
+ "\xdb\x38\x6a\x99\xac\x1a\xef\x23"
+ "\xad\xe0\xb5\x29\x39\xcb\x6a\x63"
+ "\x7c\xf9\xbe\xc2\x40\x88\x97\xc6"
+ "\xba",
+ .rlen = 33,
+ },
+};
+
+static struct aead_testvec aes_ccm_dec_tv_template[] = {
+ { /* From RFC 3610 */
+ .key = "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
+ "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf",
+ .klen = 16,
+ .iv = "\x01\x00\x00\x00\x03\x02\x01\x00"
+ "\xa0\xa1\xa2\xa3\xa4\xa5\x00\x00",
+ .assoc = "\x00\x01\x02\x03\x04\x05\x06\x07",
+ .alen = 8,
+ .input = "\x58\x8c\x97\x9a\x61\xc6\x63\xd2"
+ "\xf0\x66\xd0\xc2\xc0\xf9\x89\x80"
+ "\x6d\x5f\x6b\x61\xda\xc3\x84\x17"
+ "\xe8\xd1\x2c\xfd\xf9\x26\xe0",
+ .ilen = 31,
+ .result = "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e",
+ .rlen = 23,
+ }, {
+ .key = "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
+ "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf",
+ .klen = 16,
+ .iv = "\x01\x00\x00\x00\x07\x06\x05\x04"
+ "\xa0\xa1\xa2\xa3\xa4\xa5\x00\x00",
+ .assoc = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b",
+ .alen = 12,
+ .input = "\xdc\xf1\xfb\x7b\x5d\x9e\x23\xfb"
+ "\x9d\x4e\x13\x12\x53\x65\x8a\xd8"
+ "\x6e\xbd\xca\x3e\x51\xe8\x3f\x07"
+ "\x7d\x9c\x2d\x93",
+ .ilen = 28,
+ .result = "\x0c\x0d\x0e\x0f\x10\x11\x12\x13"
+ "\x14\x15\x16\x17\x18\x19\x1a\x1b"
+ "\x1c\x1d\x1e\x1f",
+ .rlen = 20,
+ }, {
+ .key = "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
+ "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf",
+ .klen = 16,
+ .iv = "\x01\x00\x00\x00\x0b\x0a\x09\x08"
+ "\xa0\xa1\xa2\xa3\xa4\xa5\x00\x00",
+ .assoc = "\x00\x01\x02\x03\x04\x05\x06\x07",
+ .alen = 8,
+ .input = "\x82\x53\x1a\x60\xcc\x24\x94\x5a"
+ "\x4b\x82\x79\x18\x1a\xb5\xc8\x4d"
+ "\xf2\x1c\xe7\xf9\xb7\x3f\x42\xe1"
+ "\x97\xea\x9c\x07\xe5\x6b\x5e\xb1"
+ "\x7e\x5f\x4e",
+ .ilen = 35,
+ .result = "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
+ "\x20",
+ .rlen = 25,
+ }, {
+ .key = "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
+ "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf",
+ .klen = 16,
+ .iv = "\x01\x00\x00\x00\x0c\x0b\x0a\x09"
+ "\xa0\xa1\xa2\xa3\xa4\xa5\x00\x00",
+ .assoc = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b",
+ .alen = 12,
+ .input = "\x07\x34\x25\x94\x15\x77\x85\x15"
+ "\x2b\x07\x40\x98\x33\x0a\xbb\x14"
+ "\x1b\x94\x7b\x56\x6a\xa9\x40\x6b"
+ "\x4d\x99\x99\x88\xdd",
+ .ilen = 29,
+ .result = "\x0c\x0d\x0e\x0f\x10\x11\x12\x13"
+ "\x14\x15\x16\x17\x18\x19\x1a\x1b"
+ "\x1c\x1d\x1e",
+ .rlen = 19,
+ }, {
+ .key = "\xd7\x82\x8d\x13\xb2\xb0\xbd\xc3"
+ "\x25\xa7\x62\x36\xdf\x93\xcc\x6b",
+ .klen = 16,
+ .iv = "\x01\x00\x33\x56\x8e\xf7\xb2\x63"
+ "\x3c\x96\x96\x76\x6c\xfa\x00\x00",
+ .assoc = "\x63\x01\x8f\x76\xdc\x8a\x1b\xcb",
+ .alen = 8,
+ .input = "\x4c\xcb\x1e\x7c\xa9\x81\xbe\xfa"
+ "\xa0\x72\x6c\x55\xd3\x78\x06\x12"
+ "\x98\xc8\x5c\x92\x81\x4a\xbc\x33"
+ "\xc5\x2e\xe8\x1d\x7d\x77\xc0\x8a",
+ .ilen = 32,
+ .result = "\x90\x20\xea\x6f\x91\xbd\xd8\x5a"
+ "\xfa\x00\x39\xba\x4b\xaf\xf9\xbf"
+ "\xb7\x9c\x70\x28\x94\x9c\xd0\xec",
+ .rlen = 24,
+ }, {
+ .key = "\xd7\x82\x8d\x13\xb2\xb0\xbd\xc3"
+ "\x25\xa7\x62\x36\xdf\x93\xcc\x6b",
+ .klen = 16,
+ .iv = "\x01\x00\xd5\x60\x91\x2d\x3f\x70"
+ "\x3c\x96\x96\x76\x6c\xfa\x00\x00",
+ .assoc = "\xcd\x90\x44\xd2\xb7\x1f\xdb\x81"
+ "\x20\xea\x60\xc0",
+ .alen = 12,
+ .input = "\x00\x97\x69\xec\xab\xdf\x48\x62"
+ "\x55\x94\xc5\x92\x51\xe6\x03\x57"
+ "\x22\x67\x5e\x04\xc8\x47\x09\x9e"
+ "\x5a\xe0\x70\x45\x51",
+ .ilen = 29,
+ .result = "\x64\x35\xac\xba\xfb\x11\xa8\x2e"
+ "\x2f\x07\x1d\x7c\xa4\xa5\xeb\xd9"
+ "\x3a\x80\x3b\xa8\x7f",
+ .rlen = 21,
+ }, {
+ .key = "\xd7\x82\x8d\x13\xb2\xb0\xbd\xc3"
+ "\x25\xa7\x62\x36\xdf\x93\xcc\x6b",
+ .klen = 16,
+ .iv = "\x01\x00\x42\xff\xf8\xf1\x95\x1c"
+ "\x3c\x96\x96\x76\x6c\xfa\x00\x00",
+ .assoc = "\xd8\x5b\xc7\xe6\x9f\x94\x4f\xb8",
+ .alen = 8,
+ .input = "\xbc\x21\x8d\xaa\x94\x74\x27\xb6"
+ "\xdb\x38\x6a\x99\xac\x1a\xef\x23"
+ "\xad\xe0\xb5\x29\x39\xcb\x6a\x63"
+ "\x7c\xf9\xbe\xc2\x40\x88\x97\xc6"
+ "\xba",
+ .ilen = 33,
+ .result = "\x8a\x19\xb9\x50\xbc\xf7\x1a\x01"
+ "\x8e\x5e\x67\x01\xc9\x17\x87\x65"
+ "\x98\x09\xd6\x7d\xbe\xdd\x18",
+ .rlen = 23,
+ },
+};
+
+/*
+ * rfc4309 refers to section 8 of rfc3610 for test vectors, but they all
+ * use a 13-byte nonce, we only support an 11-byte nonce. Similarly, all of
+ * Special Publication 800-38C's test vectors also use nonce lengths our
+ * implementation doesn't support. The following are taken from fips cavs
+ * fax files on hand at Red Hat.
+ *
+ * nb: actual key lengths are (klen - 3), the last 3 bytes are actually
+ * part of the nonce which combine w/the iv, but need to be input this way.
+ */
+static struct aead_testvec aes_ccm_rfc4309_enc_tv_template[] = {
+ {
+ .key = "\x83\xac\x54\x66\xc2\xeb\xe5\x05"
+ "\x2e\x01\xd1\xfc\x5d\x82\x66\x2e"
+ "\x96\xac\x59",
+ .klen = 19,
+ .iv = "\x30\x07\xa1\xe2\xa2\xc7\x55\x24",
+ .alen = 0,
+ .input = "\x19\xc8\x81\xf6\xe9\x86\xff\x93"
+ "\x0b\x78\x67\xe5\xbb\xb7\xfc\x6e"
+ "\x83\x77\xb3\xa6\x0c\x8c\x9f\x9c"
+ "\x35\x2e\xad\xe0\x62\xf9\x91\xa1",
+ .ilen = 32,
+ .result = "\xab\x6f\xe1\x69\x1d\x19\x99\xa8"
+ "\x92\xa0\xc4\x6f\x7e\xe2\x8b\xb1"
+ "\x70\xbb\x8c\xa6\x4c\x6e\x97\x8a"
+ "\x57\x2b\xbe\x5d\x98\xa6\xb1\x32"
+ "\xda\x24\xea\xd9\xa1\x39\x98\xfd"
+ "\xa4\xbe\xd9\xf2\x1a\x6d\x22\xa8",
+ .rlen = 48,
+ }, {
+ .key = "\x1e\x2c\x7e\x01\x41\x9a\xef\xc0"
+ "\x0d\x58\x96\x6e\x5c\xa2\x4b\xd3"
+ "\x4f\xa3\x19",
+ .klen = 19,
+ .iv = "\xd3\x01\x5a\xd8\x30\x60\x15\x56",
+ .assoc = "\xda\xe6\x28\x9c\x45\x2d\xfd\x63"
+ "\x5e\xda\x4c\xb6\xe6\xfc\xf9\xb7"
+ "\x0c\x56\xcb\xe4\xe0\x05\x7a\xe1"
+ "\x0a\x63\x09\x78\xbc\x2c\x55\xde",
+ .alen = 32,
+ .input = "\x87\xa3\x36\xfd\x96\xb3\x93\x78"
+ "\xa9\x28\x63\xba\x12\xa3\x14\x85"
+ "\x57\x1e\x06\xc9\x7b\x21\xef\x76"
+ "\x7f\x38\x7e\x8e\x29\xa4\x3e\x7e",
+ .ilen = 32,
+ .result = "\x8a\x1e\x11\xf0\x02\x6b\xe2\x19"
+ "\xfc\x70\xc4\x6d\x8e\xb7\x99\xab"
+ "\xc5\x4b\xa2\xac\xd3\xf3\x48\xff"
+ "\x3b\xb5\xce\x53\xef\xde\xbb\x02"
+ "\xa9\x86\x15\x6c\x13\xfe\xda\x0a"
+ "\x22\xb8\x29\x3d\xd8\x39\x9a\x23",
+ .rlen = 48,
+ }, {
+ .key = "\xf4\x6b\xc2\x75\x62\xfe\xb4\xe1"
+ "\xa3\xf0\xff\xdd\x4e\x4b\x12\x75"
+ "\x53\x14\x73\x66\x8d\x88\xf6\x80"
+ "\xa0\x20\x35",
+ .klen = 27,
+ .iv = "\x26\xf2\x21\x8d\x50\x20\xda\xe2",
+ .assoc = "\x5b\x9e\x13\x67\x02\x5e\xef\xc1"
+ "\x6c\xf9\xd7\x1e\x52\x8f\x7a\x47"
+ "\xe9\xd4\xcf\x20\x14\x6e\xf0\x2d"
+ "\xd8\x9e\x2b\x56\x10\x23\x56\xe7",
+ .alen = 32,
+ .ilen = 0,
+ .result = "\x36\xea\x7a\x70\x08\xdc\x6a\xbc"
+ "\xad\x0c\x7a\x63\xf6\x61\xfd\x9b",
+ .rlen = 16,
+ }, {
+ .key = "\x56\xdf\x5c\x8f\x26\x3f\x0e\x42"
+ "\xef\x7a\xd3\xce\xfc\x84\x60\x62"
+ "\xca\xb4\x40\xaf\x5f\xc9\xc9\x01"
+ "\xd6\x3c\x8c",
+ .klen = 27,
+ .iv = "\x86\x84\xb6\xcd\xef\x09\x2e\x94",
+ .assoc = "\x02\x65\x78\x3c\xe9\x21\x30\x91"
+ "\xb1\xb9\xda\x76\x9a\x78\x6d\x95"
+ "\xf2\x88\x32\xa3\xf2\x50\xcb\x4c"
+ "\xe3\x00\x73\x69\x84\x69\x87\x79",
+ .alen = 32,
+ .input = "\x9f\xd2\x02\x4b\x52\x49\x31\x3c"
+ "\x43\x69\x3a\x2d\x8e\x70\xad\x7e"
+ "\xe0\xe5\x46\x09\x80\x89\x13\xb2"
+ "\x8c\x8b\xd9\x3f\x86\xfb\xb5\x6b",
+ .ilen = 32,
+ .result = "\x39\xdf\x7c\x3c\x5a\x29\xb9\x62"
+ "\x5d\x51\xc2\x16\xd8\xbd\x06\x9f"
+ "\x9b\x6a\x09\x70\xc1\x51\x83\xc2"
+ "\x66\x88\x1d\x4f\x9a\xda\xe0\x1e"
+ "\xc7\x79\x11\x58\xe5\x6b\x20\x40"
+ "\x7a\xea\x46\x42\x8b\xe4\x6f\xe1",
+ .rlen = 48,
+ }, {
+ .key = "\xe0\x8d\x99\x71\x60\xd7\x97\x1a"
+ "\xbd\x01\x99\xd5\x8a\xdf\x71\x3a"
+ "\xd3\xdf\x24\x4b\x5e\x3d\x4b\x4e"
+ "\x30\x7a\xb9\xd8\x53\x0a\x5e\x2b"
+ "\x1e\x29\x91",
+ .klen = 35,
+ .iv = "\xad\x8e\xc1\x53\x0a\xcf\x2d\xbe",
+ .assoc = "\x19\xb6\x1f\x57\xc4\xf3\xf0\x8b"
+ "\x78\x2b\x94\x02\x29\x0f\x42\x27"
+ "\x6b\x75\xcb\x98\x34\x08\x7e\x79"
+ "\xe4\x3e\x49\x0d\x84\x8b\x22\x87",
+ .alen = 32,
+ .input = "\xe1\xd9\xd8\x13\xeb\x3a\x75\x3f"
+ "\x9d\xbd\x5f\x66\xbe\xdc\xbb\x66"
+ "\xbf\x17\x99\x62\x4a\x39\x27\x1f"
+ "\x1d\xdc\x24\xae\x19\x2f\x98\x4c",
+ .ilen = 32,
+ .result = "\x19\xb8\x61\x33\x45\x2b\x43\x96"
+ "\x6f\x51\xd0\x20\x30\x7d\x9b\xc6"
+ "\x26\x3d\xf8\xc9\x65\x16\xa8\x9f"
+ "\xf0\x62\x17\x34\xf2\x1e\x8d\x75"
+ "\x4e\x13\xcc\xc0\xc3\x2a\x54\x2d",
+ .rlen = 40,
+ }, {
+ .key = "\x7c\xc8\x18\x3b\x8d\x99\xe0\x7c"
+ "\x45\x41\xb8\xbd\x5c\xa7\xc2\x32"
+ "\x8a\xb8\x02\x59\xa4\xfe\xa9\x2c"
+ "\x09\x75\x9a\x9b\x3c\x9b\x27\x39"
+ "\xf9\xd9\x4e",
+ .klen = 35,
+ .iv = "\x63\xb5\x3d\x9d\x43\xf6\x1e\x50",
+ .assoc = "\x57\xf5\x6b\x8b\x57\x5c\x3d\x3b"
+ "\x13\x02\x01\x0c\x83\x4c\x96\x35"
+ "\x8e\xd6\x39\xcf\x7d\x14\x9b\x94"
+ "\xb0\x39\x36\xe6\x8f\x57\xe0\x13",
+ .alen = 32,
+ .input = "\x3b\x6c\x29\x36\xb6\xef\x07\xa6"
+ "\x83\x72\x07\x4f\xcf\xfa\x66\x89"
+ "\x5f\xca\xb1\xba\xd5\x8f\x2c\x27"
+ "\x30\xdb\x75\x09\x93\xd4\x65\xe4",
+ .ilen = 32,
+ .result = "\xb0\x88\x5a\x33\xaa\xe5\xc7\x1d"
+ "\x85\x23\xc7\xc6\x2f\xf4\x1e\x3d"
+ "\xcc\x63\x44\x25\x07\x78\x4f\x9e"
+ "\x96\xb8\x88\xeb\xbc\x48\x1f\x06"
+ "\x39\xaf\x39\xac\xd8\x4a\x80\x39"
+ "\x7b\x72\x8a\xf7",
+ .rlen = 44,
+ }, {
+ .key = "\xab\xd0\xe9\x33\x07\x26\xe5\x83"
+ "\x8c\x76\x95\xd4\xb6\xdc\xf3\x46"
+ "\xf9\x8f\xad\xe3\x02\x13\x83\x77"
+ "\x3f\xb0\xf1\xa1\xa1\x22\x0f\x2b"
+ "\x24\xa7\x8b",
+ .klen = 35,
+ .iv = "\x07\xcb\xcc\x0e\xe6\x33\xbf\xf5",
+ .assoc = "\xd4\xdb\x30\x1d\x03\xfe\xfd\x5f"
+ "\x87\xd4\x8c\xb6\xb6\xf1\x7a\x5d"
+ "\xab\x90\x65\x8d\x8e\xca\x4d\x4f"
+ "\x16\x0c\x40\x90\x4b\xc7\x36\x73",
+ .alen = 32,
+ .input = "\xf5\xc6\x7d\x48\xc1\xb7\xe6\x92"
+ "\x97\x5a\xca\xc4\xa9\x6d\xf9\x3d"
+ "\x6c\xde\xbc\xf1\x90\xea\x6a\xb2"
+ "\x35\x86\x36\xaf\x5c\xfe\x4b\x3a",
+ .ilen = 32,
+ .result = "\x83\x6f\x40\x87\x72\xcf\xc1\x13"
+ "\xef\xbb\x80\x21\x04\x6c\x58\x09"
+ "\x07\x1b\xfc\xdf\xc0\x3f\x5b\xc7"
+ "\xe0\x79\xa8\x6e\x71\x7c\x3f\xcf"
+ "\x5c\xda\xb2\x33\xe5\x13\xe2\x0d"
+ "\x74\xd1\xef\xb5\x0f\x3a\xb5\xf8",
+ .rlen = 48,
+ },
+};
+
+static struct aead_testvec aes_ccm_rfc4309_dec_tv_template[] = {
+ {
+ .key = "\xab\x2f\x8a\x74\xb7\x1c\xd2\xb1"
+ "\xff\x80\x2e\x48\x7d\x82\xf8\xb9"
+ "\xc6\xfb\x7d",
+ .klen = 19,
+ .iv = "\x80\x0d\x13\xab\xd8\xa6\xb2\xd8",
+ .alen = 0,
+ .input = "\xd5\xe8\x93\x9f\xc7\x89\x2e\x2b",
+ .ilen = 8,
+ .result = "\x00",
+ .rlen = 0,
+ .novrfy = 1,
+ }, {
+ .key = "\xab\x2f\x8a\x74\xb7\x1c\xd2\xb1"
+ "\xff\x80\x2e\x48\x7d\x82\xf8\xb9"
+ "\xaf\x94\x87",
+ .klen = 19,
+ .iv = "\x78\x35\x82\x81\x7f\x88\x94\x68",
+ .alen = 0,
+ .input = "\x41\x3c\xb8\x87\x73\xcb\xf3\xf3",
+ .ilen = 8,
+ .result = "\x00",
+ .rlen = 0,
+ }, {
+ .key = "\x61\x0e\x8c\xae\xe3\x23\xb6\x38"
+ "\x76\x1c\xf6\x3a\x67\xa3\x9c\xd8"
+ "\xc6\xfb\x7d",
+ .klen = 19,
+ .iv = "\x80\x0d\x13\xab\xd8\xa6\xb2\xd8",
+ .assoc = "\xf3\x94\x87\x78\x35\x82\x81\x7f"
+ "\x88\x94\x68\xb1\x78\x6b\x2b\xd6"
+ "\x04\x1f\x4e\xed\x78\xd5\x33\x66"
+ "\xd8\x94\x99\x91\x81\x54\x62\x57",
+ .alen = 32,
+ .input = "\xf0\x7c\x29\x02\xae\x1c\x2f\x55"
+ "\xd0\xd1\x3d\x1a\xa3\x6d\xe4\x0a"
+ "\x86\xb0\x87\x6b\x62\x33\x8c\x34"
+ "\xce\xab\x57\xcc\x79\x0b\xe0\x6f"
+ "\x5c\x3e\x48\x1f\x6c\x46\xf7\x51"
+ "\x8b\x84\x83\x2a\xc1\x05\xb8\xc5",
+ .ilen = 48,
+ .result = "\x50\x82\x3e\x07\xe2\x1e\xb6\xfb"
+ "\x33\xe4\x73\xce\xd2\xfb\x95\x79"
+ "\xe8\xb4\xb5\x77\x11\x10\x62\x6f"
+ "\x6a\x82\xd1\x13\xec\xf5\xd0\x48",
+ .rlen = 32,
+ .novrfy = 1,
+ }, {
+ .key = "\x61\x0e\x8c\xae\xe3\x23\xb6\x38"
+ "\x76\x1c\xf6\x3a\x67\xa3\x9c\xd8"
+ "\x05\xe0\xc9",
+ .klen = 19,
+ .iv = "\x0f\xed\x34\xea\x97\xd4\x3b\xdf",
+ .assoc = "\x49\x5c\x50\x1f\x1d\x94\xcc\x81"
+ "\xba\xb7\xb6\x03\xaf\xa5\xc1\xa1"
+ "\xd8\x5c\x42\x68\xe0\x6c\xda\x89"
+ "\x05\xac\x56\xac\x1b\x2a\xd3\x86",
+ .alen = 32,
+ .input = "\x39\xbe\x7d\x15\x62\x77\xf3\x3c"
+ "\xad\x83\x52\x6d\x71\x03\x25\x1c"
+ "\xed\x81\x3a\x9a\x16\x7d\x19\x80"
+ "\x72\x04\x72\xd0\xf6\xff\x05\x0f"
+ "\xb7\x14\x30\x00\x32\x9e\xa0\xa6"
+ "\x9e\x5a\x18\xa1\xb8\xfe\xdb\xd3",
+ .ilen = 48,
+ .result = "\x75\x05\xbe\xc2\xd9\x1e\xde\x60"
+ "\x47\x3d\x8c\x7d\xbd\xb5\xd9\xb7"
+ "\xf2\xae\x61\x05\x8f\x82\x24\x3f"
+ "\x9c\x67\x91\xe1\x38\x4f\xe4\x0c",
+ .rlen = 32,
+ }, {
+ .key = "\x39\xbb\xa7\xbe\x59\x97\x9e\x73"
+ "\xa2\xbc\x6b\x98\xd7\x75\x7f\xe3"
+ "\xa4\x48\x93\x39\x26\x71\x4a\xc6"
+ "\xee\x49\x83",
+ .klen = 27,
+ .iv = "\xe9\xa9\xff\xe9\x57\xba\xfd\x9e",
+ .assoc = "\x44\xa6\x2c\x05\xe9\xe1\x43\xb1"
+ "\x58\x7c\xf2\x5c\x6d\x39\x0a\x64"
+ "\xa4\xf0\x13\x05\xd1\x77\x99\x67"
+ "\x11\xc4\xc6\xdb\x00\x56\x36\x61",
+ .alen = 32,
+ .input = "\x71\x99\xfa\xf4\x44\x12\x68\x9b",
+ .ilen = 8,
+ .result = "\x00",
+ .rlen = 0,
+ }, {
+ .key = "\x58\x5d\xa0\x96\x65\x1a\x04\xd7"
+ "\x96\xe5\xc5\x68\xaa\x95\x35\xe0"
+ "\x29\xa0\xba\x9e\x48\x78\xd1\xba"
+ "\xee\x49\x83",
+ .klen = 27,
+ .iv = "\xe9\xa9\xff\xe9\x57\xba\xfd\x9e",
+ .assoc = "\x44\xa6\x2c\x05\xe9\xe1\x43\xb1"
+ "\x58\x7c\xf2\x5c\x6d\x39\x0a\x64"
+ "\xa4\xf0\x13\x05\xd1\x77\x99\x67"
+ "\x11\xc4\xc6\xdb\x00\x56\x36\x61",
+ .alen = 32,
+ .input = "\xfb\xe5\x5d\x34\xbe\xe5\xe8\xe7"
+ "\x5a\xef\x2f\xbf\x1f\x7f\xd4\xb2"
+ "\x66\xca\x61\x1e\x96\x7a\x61\xb3"
+ "\x1c\x16\x45\x52\xba\x04\x9c\x9f"
+ "\xb1\xd2\x40\xbc\x52\x7c\x6f\xb1",
+ .ilen = 40,
+ .result = "\x85\x34\x66\x42\xc8\x92\x0f\x36"
+ "\x58\xe0\x6b\x91\x3c\x98\x5c\xbb"
+ "\x0a\x85\xcc\x02\xad\x7a\x96\xe9"
+ "\x65\x43\xa4\xc3\x0f\xdc\x55\x81",
+ .rlen = 32,
+ }, {
+ .key = "\x58\x5d\xa0\x96\x65\x1a\x04\xd7"
+ "\x96\xe5\xc5\x68\xaa\x95\x35\xe0"
+ "\x29\xa0\xba\x9e\x48\x78\xd1\xba"
+ "\xd1\xfc\x57",
+ .klen = 27,
+ .iv = "\x9c\xfe\xb8\x9c\xad\x71\xaa\x1f",
+ .assoc = "\x86\x67\xa5\xa9\x14\x5f\x0d\xc6"
+ "\xff\x14\xc7\x44\xbf\x6c\x3a\xc3"
+ "\xff\xb6\x81\xbd\xe2\xd5\x06\xc7"
+ "\x3c\xa1\x52\x13\x03\x8a\x23\x3a",
+ .alen = 32,
+ .input = "\x3f\x66\xb0\x9d\xe5\x4b\x38\x00"
+ "\xc6\x0e\x6e\xe5\xd6\x98\xa6\x37"
+ "\x8c\x26\x33\xc6\xb2\xa2\x17\xfa"
+ "\x64\x19\xc0\x30\xd7\xfc\x14\x6b"
+ "\xe3\x33\xc2\x04\xb0\x37\xbe\x3f"
+ "\xa9\xb4\x2d\x68\x03\xa3\x44\xef",
+ .ilen = 48,
+ .result = "\x02\x87\x4d\x28\x80\x6e\xb2\xed"
+ "\x99\x2a\xa8\xca\x04\x25\x45\x90"
+ "\x1d\xdd\x5a\xd9\xe4\xdb\x9c\x9c"
+ "\x49\xe9\x01\xfe\xa7\x80\x6d\x6b",
+ .rlen = 32,
+ .novrfy = 1,
+ }, {
+ .key = "\xa4\x4b\x54\x29\x0a\xb8\x6d\x01"
+ "\x5b\x80\x2a\xcf\x25\xc4\xb7\x5c"
+ "\x20\x2c\xad\x30\xc2\x2b\x41\xfb"
+ "\x0e\x85\xbc\x33\xad\x0f\x2b\xff"
+ "\xee\x49\x83",
+ .klen = 35,
+ .iv = "\xe9\xa9\xff\xe9\x57\xba\xfd\x9e",
+ .alen = 0,
+ .input = "\x1f\xb8\x8f\xa3\xdd\x54\x00\xf2",
+ .ilen = 8,
+ .result = "\x00",
+ .rlen = 0,
+ }, {
+ .key = "\x39\xbb\xa7\xbe\x59\x97\x9e\x73"
+ "\xa2\xbc\x6b\x98\xd7\x75\x7f\xe3"
+ "\xa4\x48\x93\x39\x26\x71\x4a\xc6"
+ "\xae\x8f\x11\x4c\xc2\x9c\x4a\xbb"
+ "\x85\x34\x66",
+ .klen = 35,
+ .iv = "\x42\xc8\x92\x0f\x36\x58\xe0\x6b",
+ .alen = 0,
+ .input = "\x48\x01\x5e\x02\x24\x04\x66\x47"
+ "\xa1\xea\x6f\xaf\xe8\xfc\xfb\xdd"
+ "\xa5\xa9\x87\x8d\x84\xee\x2e\x77"
+ "\xbb\x86\xb9\xf5\x5c\x6c\xff\xf6"
+ "\x72\xc3\x8e\xf7\x70\xb1\xb2\x07"
+ "\xbc\xa8\xa3\xbd\x83\x7c\x1d\x2a",
+ .ilen = 48,
+ .result = "\xdc\x56\xf2\x71\xb0\xb1\xa0\x6c"
+ "\xf0\x97\x3a\xfb\x6d\xe7\x32\x99"
+ "\x3e\xaf\x70\x5e\xb2\x4d\xea\x39"
+ "\x89\xd4\x75\x7a\x63\xb1\xda\x93",
+ .rlen = 32,
+ .novrfy = 1,
+ }, {
+ .key = "\x58\x5d\xa0\x96\x65\x1a\x04\xd7"
+ "\x96\xe5\xc5\x68\xaa\x95\x35\xe0"
+ "\x29\xa0\xba\x9e\x48\x78\xd1\xba"
+ "\x0d\x1a\x53\x3b\xb5\xe3\xf8\x8b"
+ "\xcf\x76\x3f",
+ .klen = 35,
+ .iv = "\xd9\x95\x75\x8f\x44\x89\x40\x7b",
+ .assoc = "\x8f\x86\x6c\x4d\x1d\xc5\x39\x88"
+ "\xc8\xf3\x5c\x52\x10\x63\x6f\x2b"
+ "\x8a\x2a\xc5\x6f\x30\x23\x58\x7b"
+ "\xfb\x36\x03\x11\xb4\xd9\xf2\xfe",
+ .alen = 32,
+ .input = "\x48\x58\xd6\xf3\xad\x63\x58\xbf"
+ "\xae\xc7\x5e\xae\x83\x8f\x7b\xe4"
+ "\x78\x5c\x4c\x67\x71\x89\x94\xbf"
+ "\x47\xf1\x63\x7e\x1c\x59\xbd\xc5"
+ "\x7f\x44\x0a\x0c\x01\x18\x07\x92"
+ "\xe1\xd3\x51\xce\x32\x6d\x0c\x5b",
+ .ilen = 48,
+ .result = "\xc2\x54\xc8\xde\x78\x87\x77\x40"
+ "\x49\x71\xe4\xb7\xe7\xcb\x76\x61"
+ "\x0a\x41\xb9\xe9\xc0\x76\x54\xab"
+ "\x04\x49\x3b\x19\x93\x57\x25\x5d",
+ .rlen = 32,
+ },
+};
+
+/*
+ * ANSI X9.31 Continuous Pseudo-Random Number Generator (
+ * test vectors, taken from Appendix B.2.9 and B.2.10:
+ * http://csrc.nist.gov/groups/STM/cavp/documents/rng/RNGVS.pdf
+ * Only AES-128 is supported at this time.
+ */
+#define ANSI_CPRNG_AES_TEST_VECTORS 6
+
+static struct cprng_testvec ansi_cprng_aes_tv_template[] = {
+ {
+ .key = "\xf3\xb1\x66\x6d\x13\x60\x72\x42"
+ "\xed\x06\x1c\xab\xb8\xd4\x62\x02",
+ .klen = 16,
+ .dt = "\xe6\xb3\xbe\x78\x2a\x23\xfa\x62"
+ "\xd7\x1d\x4a\xfb\xb0\xe9\x22\xf9",
+ .dtlen = 16,
+ .v = "\x80\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .vlen = 16,
+ .result = "\x59\x53\x1e\xd1\x3b\xb0\xc0\x55"
+ "\x84\x79\x66\x85\xc1\x2f\x76\x41",
+ .rlen = 16,
+ .loops = 1,
+ }, {
+ .key = "\xf3\xb1\x66\x6d\x13\x60\x72\x42"
+ "\xed\x06\x1c\xab\xb8\xd4\x62\x02",
+ .klen = 16,
+ .dt = "\xe6\xb3\xbe\x78\x2a\x23\xfa\x62"
+ "\xd7\x1d\x4a\xfb\xb0\xe9\x22\xfa",
+ .dtlen = 16,
+ .v = "\xc0\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .vlen = 16,
+ .result = "\x7c\x22\x2c\xf4\xca\x8f\xa2\x4c"
+ "\x1c\x9c\xb6\x41\xa9\xf3\x22\x0d",
+ .rlen = 16,
+ .loops = 1,
+ }, {
+ .key = "\xf3\xb1\x66\x6d\x13\x60\x72\x42"
+ "\xed\x06\x1c\xab\xb8\xd4\x62\x02",
+ .klen = 16,
+ .dt = "\xe6\xb3\xbe\x78\x2a\x23\xfa\x62"
+ "\xd7\x1d\x4a\xfb\xb0\xe9\x22\xfb",
+ .dtlen = 16,
+ .v = "\xe0\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .vlen = 16,
+ .result = "\x8a\xaa\x00\x39\x66\x67\x5b\xe5"
+ "\x29\x14\x28\x81\xa9\x4d\x4e\xc7",
+ .rlen = 16,
+ .loops = 1,
+ }, {
+ .key = "\xf3\xb1\x66\x6d\x13\x60\x72\x42"
+ "\xed\x06\x1c\xab\xb8\xd4\x62\x02",
+ .klen = 16,
+ .dt = "\xe6\xb3\xbe\x78\x2a\x23\xfa\x62"
+ "\xd7\x1d\x4a\xfb\xb0\xe9\x22\xfc",
+ .dtlen = 16,
+ .v = "\xf0\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .vlen = 16,
+ .result = "\x88\xdd\xa4\x56\x30\x24\x23\xe5"
+ "\xf6\x9d\xa5\x7e\x7b\x95\xc7\x3a",
+ .rlen = 16,
+ .loops = 1,
+ }, {
+ .key = "\xf3\xb1\x66\x6d\x13\x60\x72\x42"
+ "\xed\x06\x1c\xab\xb8\xd4\x62\x02",
+ .klen = 16,
+ .dt = "\xe6\xb3\xbe\x78\x2a\x23\xfa\x62"
+ "\xd7\x1d\x4a\xfb\xb0\xe9\x22\xfd",
+ .dtlen = 16,
+ .v = "\xf8\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .vlen = 16,
+ .result = "\x05\x25\x92\x46\x61\x79\xd2\xcb"
+ "\x78\xc4\x0b\x14\x0a\x5a\x9a\xc8",
+ .rlen = 16,
+ .loops = 1,
+ }, { /* Monte Carlo Test */
+ .key = "\x9f\x5b\x51\x20\x0b\xf3\x34\xb5"
+ "\xd8\x2b\xe8\xc3\x72\x55\xc8\x48",
+ .klen = 16,
+ .dt = "\x63\x76\xbb\xe5\x29\x02\xba\x3b"
+ "\x67\xc9\x25\xfa\x70\x1f\x11\xac",
+ .dtlen = 16,
+ .v = "\x57\x2c\x8e\x76\x87\x26\x47\x97"
+ "\x7e\x74\xfb\xdd\xc4\x95\x01\xd1",
+ .vlen = 16,
+ .result = "\x48\xe9\xbd\x0d\x06\xee\x18\xfb"
+ "\xe4\x57\x90\xd5\xc3\xfc\x9b\x73",
+ .rlen = 16,
+ .loops = 10000,
+ },
+};
+
+/* Cast5 test vectors from RFC 2144 */
+#define CAST5_ENC_TEST_VECTORS 3
+#define CAST5_DEC_TEST_VECTORS 3
+
+static struct cipher_testvec cast5_enc_tv_template[] = {
+ {
+ .key = "\x01\x23\x45\x67\x12\x34\x56\x78"
+ "\x23\x45\x67\x89\x34\x56\x78\x9a",
+ .klen = 16,
+ .input = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .ilen = 8,
+ .result = "\x23\x8b\x4f\xe5\x84\x7e\x44\xb2",
+ .rlen = 8,
+ }, {
+ .key = "\x01\x23\x45\x67\x12\x34\x56\x78"
+ "\x23\x45",
+ .klen = 10,
+ .input = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .ilen = 8,
+ .result = "\xeb\x6a\x71\x1a\x2c\x02\x27\x1b",
+ .rlen = 8,
+ }, {
+ .key = "\x01\x23\x45\x67\x12",
+ .klen = 5,
+ .input = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .ilen = 8,
+ .result = "\x7a\xc8\x16\xd1\x6e\x9b\x30\x2e",
+ .rlen = 8,
+ },
+};
+
+static struct cipher_testvec cast5_dec_tv_template[] = {
+ {
+ .key = "\x01\x23\x45\x67\x12\x34\x56\x78"
+ "\x23\x45\x67\x89\x34\x56\x78\x9a",
+ .klen = 16,
+ .input = "\x23\x8b\x4f\xe5\x84\x7e\x44\xb2",
+ .ilen = 8,
+ .result = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .rlen = 8,
+ }, {
+ .key = "\x01\x23\x45\x67\x12\x34\x56\x78"
+ "\x23\x45",
+ .klen = 10,
+ .input = "\xeb\x6a\x71\x1a\x2c\x02\x27\x1b",
+ .ilen = 8,
+ .result = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .rlen = 8,
+ }, {
+ .key = "\x01\x23\x45\x67\x12",
+ .klen = 5,
+ .input = "\x7a\xc8\x16\xd1\x6e\x9b\x30\x2e",
+ .ilen = 8,
+ .result = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .rlen = 8,
+ },
+};
+
+/*
+ * ARC4 test vectors from OpenSSL
+ */
+#define ARC4_ENC_TEST_VECTORS 7
+#define ARC4_DEC_TEST_VECTORS 7
+
+static struct cipher_testvec arc4_enc_tv_template[] = {
+ {
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .klen = 8,
+ .input = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .ilen = 8,
+ .result = "\x75\xb7\x87\x80\x99\xe0\xc5\x96",
+ .rlen = 8,
+ }, {
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .klen = 8,
+ .input = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .ilen = 8,
+ .result = "\x74\x94\xc2\xe7\x10\x4b\x08\x79",
+ .rlen = 8,
+ }, {
+ .key = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .klen = 8,
+ .input = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .ilen = 8,
+ .result = "\xde\x18\x89\x41\xa3\x37\x5d\x3a",
+ .rlen = 8,
+ }, {
+ .key = "\xef\x01\x23\x45",
+ .klen = 4,
+ .input = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00",
+ .ilen = 20,
+ .result = "\xd6\xa1\x41\xa7\xec\x3c\x38\xdf"
+ "\xbd\x61\x5a\x11\x62\xe1\xc7\xba"
+ "\x36\xb6\x78\x58",
+ .rlen = 20,
+ }, {
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .klen = 8,
+ .input = "\x12\x34\x56\x78\x9A\xBC\xDE\xF0"
+ "\x12\x34\x56\x78\x9A\xBC\xDE\xF0"
+ "\x12\x34\x56\x78\x9A\xBC\xDE\xF0"
+ "\x12\x34\x56\x78",
+ .ilen = 28,
+ .result = "\x66\xa0\x94\x9f\x8a\xf7\xd6\x89"
+ "\x1f\x7f\x83\x2b\xa8\x33\xc0\x0c"
+ "\x89\x2e\xbe\x30\x14\x3c\xe2\x87"
+ "\x40\x01\x1e\xcf",
+ .rlen = 28,
+ }, {
+ .key = "\xef\x01\x23\x45",
+ .klen = 4,
+ .input = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00",
+ .ilen = 10,
+ .result = "\xd6\xa1\x41\xa7\xec\x3c\x38\xdf"
+ "\xbd\x61",
+ .rlen = 10,
+ }, {
+ .key = "\x01\x23\x45\x67\x89\xAB\xCD\xEF"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .klen = 16,
+ .input = "\x01\x23\x45\x67\x89\xAB\xCD\xEF",
+ .ilen = 8,
+ .result = "\x69\x72\x36\x59\x1B\x52\x42\xB1",
+ .rlen = 8,
+ },
+};
+
+static struct cipher_testvec arc4_dec_tv_template[] = {
+ {
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .klen = 8,
+ .input = "\x75\xb7\x87\x80\x99\xe0\xc5\x96",
+ .ilen = 8,
+ .result = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .rlen = 8,
+ }, {
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .klen = 8,
+ .input = "\x74\x94\xc2\xe7\x10\x4b\x08\x79",
+ .ilen = 8,
+ .result = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .rlen = 8,
+ }, {
+ .key = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .klen = 8,
+ .input = "\xde\x18\x89\x41\xa3\x37\x5d\x3a",
+ .ilen = 8,
+ .result = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .rlen = 8,
+ }, {
+ .key = "\xef\x01\x23\x45",
+ .klen = 4,
+ .input = "\xd6\xa1\x41\xa7\xec\x3c\x38\xdf"
+ "\xbd\x61\x5a\x11\x62\xe1\xc7\xba"
+ "\x36\xb6\x78\x58",
+ .ilen = 20,
+ .result = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00",
+ .rlen = 20,
+ }, {
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .klen = 8,
+ .input = "\x66\xa0\x94\x9f\x8a\xf7\xd6\x89"
+ "\x1f\x7f\x83\x2b\xa8\x33\xc0\x0c"
+ "\x89\x2e\xbe\x30\x14\x3c\xe2\x87"
+ "\x40\x01\x1e\xcf",
+ .ilen = 28,
+ .result = "\x12\x34\x56\x78\x9A\xBC\xDE\xF0"
+ "\x12\x34\x56\x78\x9A\xBC\xDE\xF0"
+ "\x12\x34\x56\x78\x9A\xBC\xDE\xF0"
+ "\x12\x34\x56\x78",
+ .rlen = 28,
+ }, {
+ .key = "\xef\x01\x23\x45",
+ .klen = 4,
+ .input = "\xd6\xa1\x41\xa7\xec\x3c\x38\xdf"
+ "\xbd\x61",
+ .ilen = 10,
+ .result = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00",
+ .rlen = 10,
+ }, {
+ .key = "\x01\x23\x45\x67\x89\xAB\xCD\xEF"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .klen = 16,
+ .input = "\x69\x72\x36\x59\x1B\x52\x42\xB1",
+ .ilen = 8,
+ .result = "\x01\x23\x45\x67\x89\xAB\xCD\xEF",
+ .rlen = 8,
+ },
+};
+
+/*
+ * TEA test vectors
+ */
+#define TEA_ENC_TEST_VECTORS 4
+#define TEA_DEC_TEST_VECTORS 4
+
+static struct cipher_testvec tea_enc_tv_template[] = {
+ {
+ .key = zeroed_string,
+ .klen = 16,
+ .input = zeroed_string,
+ .ilen = 8,
+ .result = "\x0a\x3a\xea\x41\x40\xa9\xba\x94",
+ .rlen = 8,
+ }, {
+ .key = "\x2b\x02\x05\x68\x06\x14\x49\x76"
+ "\x77\x5d\x0e\x26\x6c\x28\x78\x43",
+ .klen = 16,
+ .input = "\x74\x65\x73\x74\x20\x6d\x65\x2e",
+ .ilen = 8,
+ .result = "\x77\x5d\x2a\x6a\xf6\xce\x92\x09",
+ .rlen = 8,
+ }, {
+ .key = "\x09\x65\x43\x11\x66\x44\x39\x25"
+ "\x51\x3a\x16\x10\x0a\x08\x12\x6e",
+ .klen = 16,
+ .input = "\x6c\x6f\x6e\x67\x65\x72\x5f\x74"
+ "\x65\x73\x74\x5f\x76\x65\x63\x74",
+ .ilen = 16,
+ .result = "\xbe\x7a\xbb\x81\x95\x2d\x1f\x1e"
+ "\xdd\x89\xa1\x25\x04\x21\xdf\x95",
+ .rlen = 16,
+ }, {
+ .key = "\x4d\x76\x32\x17\x05\x3f\x75\x2c"
+ "\x5d\x04\x16\x36\x15\x72\x63\x2f",
+ .klen = 16,
+ .input = "\x54\x65\x61\x20\x69\x73\x20\x67"
+ "\x6f\x6f\x64\x20\x66\x6f\x72\x20"
+ "\x79\x6f\x75\x21\x21\x21\x20\x72"
+ "\x65\x61\x6c\x6c\x79\x21\x21\x21",
+ .ilen = 32,
+ .result = "\xe0\x4d\x5d\x3c\xb7\x8c\x36\x47"
+ "\x94\x18\x95\x91\xa9\xfc\x49\xf8"
+ "\x44\xd1\x2d\xc2\x99\xb8\x08\x2a"
+ "\x07\x89\x73\xc2\x45\x92\xc6\x90",
+ .rlen = 32,
+ }
+};
+
+static struct cipher_testvec tea_dec_tv_template[] = {
+ {
+ .key = zeroed_string,
+ .klen = 16,
+ .input = "\x0a\x3a\xea\x41\x40\xa9\xba\x94",
+ .ilen = 8,
+ .result = zeroed_string,
+ .rlen = 8,
+ }, {
+ .key = "\x2b\x02\x05\x68\x06\x14\x49\x76"
+ "\x77\x5d\x0e\x26\x6c\x28\x78\x43",
+ .klen = 16,
+ .input = "\x77\x5d\x2a\x6a\xf6\xce\x92\x09",
+ .ilen = 8,
+ .result = "\x74\x65\x73\x74\x20\x6d\x65\x2e",
+ .rlen = 8,
+ }, {
+ .key = "\x09\x65\x43\x11\x66\x44\x39\x25"
+ "\x51\x3a\x16\x10\x0a\x08\x12\x6e",
+ .klen = 16,
+ .input = "\xbe\x7a\xbb\x81\x95\x2d\x1f\x1e"
+ "\xdd\x89\xa1\x25\x04\x21\xdf\x95",
+ .ilen = 16,
+ .result = "\x6c\x6f\x6e\x67\x65\x72\x5f\x74"
+ "\x65\x73\x74\x5f\x76\x65\x63\x74",
+ .rlen = 16,
+ }, {
+ .key = "\x4d\x76\x32\x17\x05\x3f\x75\x2c"
+ "\x5d\x04\x16\x36\x15\x72\x63\x2f",
+ .klen = 16,
+ .input = "\xe0\x4d\x5d\x3c\xb7\x8c\x36\x47"
+ "\x94\x18\x95\x91\xa9\xfc\x49\xf8"
+ "\x44\xd1\x2d\xc2\x99\xb8\x08\x2a"
+ "\x07\x89\x73\xc2\x45\x92\xc6\x90",
+ .ilen = 32,
+ .result = "\x54\x65\x61\x20\x69\x73\x20\x67"
+ "\x6f\x6f\x64\x20\x66\x6f\x72\x20"
+ "\x79\x6f\x75\x21\x21\x21\x20\x72"
+ "\x65\x61\x6c\x6c\x79\x21\x21\x21",
+ .rlen = 32,
+ }
+};
+
+/*
+ * XTEA test vectors
+ */
+#define XTEA_ENC_TEST_VECTORS 4
+#define XTEA_DEC_TEST_VECTORS 4
+
+static struct cipher_testvec xtea_enc_tv_template[] = {
+ {
+ .key = zeroed_string,
+ .klen = 16,
+ .input = zeroed_string,
+ .ilen = 8,
+ .result = "\xd8\xd4\xe9\xde\xd9\x1e\x13\xf7",
+ .rlen = 8,
+ }, {
+ .key = "\x2b\x02\x05\x68\x06\x14\x49\x76"
+ "\x77\x5d\x0e\x26\x6c\x28\x78\x43",
+ .klen = 16,
+ .input = "\x74\x65\x73\x74\x20\x6d\x65\x2e",
+ .ilen = 8,
+ .result = "\x94\xeb\xc8\x96\x84\x6a\x49\xa8",
+ .rlen = 8,
+ }, {
+ .key = "\x09\x65\x43\x11\x66\x44\x39\x25"
+ "\x51\x3a\x16\x10\x0a\x08\x12\x6e",
+ .klen = 16,
+ .input = "\x6c\x6f\x6e\x67\x65\x72\x5f\x74"
+ "\x65\x73\x74\x5f\x76\x65\x63\x74",
+ .ilen = 16,
+ .result = "\x3e\xce\xae\x22\x60\x56\xa8\x9d"
+ "\x77\x4d\xd4\xb4\x87\x24\xe3\x9a",
+ .rlen = 16,
+ }, {
+ .key = "\x4d\x76\x32\x17\x05\x3f\x75\x2c"
+ "\x5d\x04\x16\x36\x15\x72\x63\x2f",
+ .klen = 16,
+ .input = "\x54\x65\x61\x20\x69\x73\x20\x67"
+ "\x6f\x6f\x64\x20\x66\x6f\x72\x20"
+ "\x79\x6f\x75\x21\x21\x21\x20\x72"
+ "\x65\x61\x6c\x6c\x79\x21\x21\x21",
+ .ilen = 32,
+ .result = "\x99\x81\x9f\x5d\x6f\x4b\x31\x3a"
+ "\x86\xff\x6f\xd0\xe3\x87\x70\x07"
+ "\x4d\xb8\xcf\xf3\x99\x50\xb3\xd4"
+ "\x73\xa2\xfa\xc9\x16\x59\x5d\x81",
+ .rlen = 32,
+ }
+};
+
+static struct cipher_testvec xtea_dec_tv_template[] = {
+ {
+ .key = zeroed_string,
+ .klen = 16,
+ .input = "\xd8\xd4\xe9\xde\xd9\x1e\x13\xf7",
+ .ilen = 8,
+ .result = zeroed_string,
+ .rlen = 8,
+ }, {
+ .key = "\x2b\x02\x05\x68\x06\x14\x49\x76"
+ "\x77\x5d\x0e\x26\x6c\x28\x78\x43",
+ .klen = 16,
+ .input = "\x94\xeb\xc8\x96\x84\x6a\x49\xa8",
+ .ilen = 8,
+ .result = "\x74\x65\x73\x74\x20\x6d\x65\x2e",
+ .rlen = 8,
+ }, {
+ .key = "\x09\x65\x43\x11\x66\x44\x39\x25"
+ "\x51\x3a\x16\x10\x0a\x08\x12\x6e",
+ .klen = 16,
+ .input = "\x3e\xce\xae\x22\x60\x56\xa8\x9d"
+ "\x77\x4d\xd4\xb4\x87\x24\xe3\x9a",
+ .ilen = 16,
+ .result = "\x6c\x6f\x6e\x67\x65\x72\x5f\x74"
+ "\x65\x73\x74\x5f\x76\x65\x63\x74",
+ .rlen = 16,
+ }, {
+ .key = "\x4d\x76\x32\x17\x05\x3f\x75\x2c"
+ "\x5d\x04\x16\x36\x15\x72\x63\x2f",
+ .klen = 16,
+ .input = "\x99\x81\x9f\x5d\x6f\x4b\x31\x3a"
+ "\x86\xff\x6f\xd0\xe3\x87\x70\x07"
+ "\x4d\xb8\xcf\xf3\x99\x50\xb3\xd4"
+ "\x73\xa2\xfa\xc9\x16\x59\x5d\x81",
+ .ilen = 32,
+ .result = "\x54\x65\x61\x20\x69\x73\x20\x67"
+ "\x6f\x6f\x64\x20\x66\x6f\x72\x20"
+ "\x79\x6f\x75\x21\x21\x21\x20\x72"
+ "\x65\x61\x6c\x6c\x79\x21\x21\x21",
+ .rlen = 32,
+ }
+};
+
+/*
+ * KHAZAD test vectors.
+ */
+#define KHAZAD_ENC_TEST_VECTORS 5
+#define KHAZAD_DEC_TEST_VECTORS 5
+
+static struct cipher_testvec khazad_enc_tv_template[] = {
+ {
+ .key = "\x80\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .klen = 16,
+ .input = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .ilen = 8,
+ .result = "\x49\xa4\xce\x32\xac\x19\x0e\x3f",
+ .rlen = 8,
+ }, {
+ .key = "\x38\x38\x38\x38\x38\x38\x38\x38"
+ "\x38\x38\x38\x38\x38\x38\x38\x38",
+ .klen = 16,
+ .input = "\x38\x38\x38\x38\x38\x38\x38\x38",
+ .ilen = 8,
+ .result = "\x7e\x82\x12\xa1\xd9\x5b\xe4\xf9",
+ .rlen = 8,
+ }, {
+ .key = "\xa2\xa2\xa2\xa2\xa2\xa2\xa2\xa2"
+ "\xa2\xa2\xa2\xa2\xa2\xa2\xa2\xa2",
+ .klen = 16,
+ .input = "\xa2\xa2\xa2\xa2\xa2\xa2\xa2\xa2",
+ .ilen = 8,
+ .result = "\xaa\xbe\xc1\x95\xc5\x94\x1a\x9c",
+ .rlen = 8,
+ }, {
+ .key = "\x2f\x2f\x2f\x2f\x2f\x2f\x2f\x2f"
+ "\x2f\x2f\x2f\x2f\x2f\x2f\x2f\x2f",
+ .klen = 16,
+ .input = "\x2f\x2f\x2f\x2f\x2f\x2f\x2f\x2f",
+ .ilen = 8,
+ .result = "\x04\x74\xf5\x70\x50\x16\xd3\xb8",
+ .rlen = 8,
+ }, {
+ .key = "\x2f\x2f\x2f\x2f\x2f\x2f\x2f\x2f"
+ "\x2f\x2f\x2f\x2f\x2f\x2f\x2f\x2f",
+ .klen = 16,
+ .input = "\x2f\x2f\x2f\x2f\x2f\x2f\x2f\x2f"
+ "\x2f\x2f\x2f\x2f\x2f\x2f\x2f\x2f",
+ .ilen = 16,
+ .result = "\x04\x74\xf5\x70\x50\x16\xd3\xb8"
+ "\x04\x74\xf5\x70\x50\x16\xd3\xb8",
+ .rlen = 16,
+ },
+};
+
+static struct cipher_testvec khazad_dec_tv_template[] = {
+ {
+ .key = "\x80\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .klen = 16,
+ .input = "\x49\xa4\xce\x32\xac\x19\x0e\x3f",
+ .ilen = 8,
+ .result = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .rlen = 8,
+ }, {
+ .key = "\x38\x38\x38\x38\x38\x38\x38\x38"
+ "\x38\x38\x38\x38\x38\x38\x38\x38",
+ .klen = 16,
+ .input = "\x7e\x82\x12\xa1\xd9\x5b\xe4\xf9",
+ .ilen = 8,
+ .result = "\x38\x38\x38\x38\x38\x38\x38\x38",
+ .rlen = 8,
+ }, {
+ .key = "\xa2\xa2\xa2\xa2\xa2\xa2\xa2\xa2"
+ "\xa2\xa2\xa2\xa2\xa2\xa2\xa2\xa2",
+ .klen = 16,
+ .input = "\xaa\xbe\xc1\x95\xc5\x94\x1a\x9c",
+ .ilen = 8,
+ .result = "\xa2\xa2\xa2\xa2\xa2\xa2\xa2\xa2",
+ .rlen = 8,
+ }, {
+ .key = "\x2f\x2f\x2f\x2f\x2f\x2f\x2f\x2f"
+ "\x2f\x2f\x2f\x2f\x2f\x2f\x2f\x2f",
+ .klen = 16,
+ .input = "\x04\x74\xf5\x70\x50\x16\xd3\xb8",
+ .ilen = 8,
+ .result = "\x2f\x2f\x2f\x2f\x2f\x2f\x2f\x2f",
+ .rlen = 8,
+ }, {
+ .key = "\x2f\x2f\x2f\x2f\x2f\x2f\x2f\x2f"
+ "\x2f\x2f\x2f\x2f\x2f\x2f\x2f\x2f",
+ .klen = 16,
+ .input = "\x04\x74\xf5\x70\x50\x16\xd3\xb8"
+ "\x04\x74\xf5\x70\x50\x16\xd3\xb8",
+ .ilen = 16,
+ .result = "\x2f\x2f\x2f\x2f\x2f\x2f\x2f\x2f"
+ "\x2f\x2f\x2f\x2f\x2f\x2f\x2f\x2f",
+ .rlen = 16,
+ },
+};
+
+/*
+ * Anubis test vectors.
+ */
+
+#define ANUBIS_ENC_TEST_VECTORS 5
+#define ANUBIS_DEC_TEST_VECTORS 5
+#define ANUBIS_CBC_ENC_TEST_VECTORS 2
+#define ANUBIS_CBC_DEC_TEST_VECTORS 2
+
+static struct cipher_testvec anubis_enc_tv_template[] = {
+ {
+ .key = "\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe"
+ "\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe",
+ .klen = 16,
+ .input = "\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe"
+ "\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe",
+ .ilen = 16,
+ .result = "\x6d\xc5\xda\xa2\x26\x7d\x62\x6f"
+ "\x08\xb7\x52\x8e\x6e\x6e\x86\x90",
+ .rlen = 16,
+ }, {
+
+ .key = "\x03\x03\x03\x03\x03\x03\x03\x03"
+ "\x03\x03\x03\x03\x03\x03\x03\x03"
+ "\x03\x03\x03\x03",
+ .klen = 20,
+ .input = "\x03\x03\x03\x03\x03\x03\x03\x03"
+ "\x03\x03\x03\x03\x03\x03\x03\x03",
+ .ilen = 16,
+ .result = "\xdb\xf1\x42\xf4\xd1\x8a\xc7\x49"
+ "\x87\x41\x6f\x82\x0a\x98\x64\xae",
+ .rlen = 16,
+ }, {
+ .key = "\x24\x24\x24\x24\x24\x24\x24\x24"
+ "\x24\x24\x24\x24\x24\x24\x24\x24"
+ "\x24\x24\x24\x24\x24\x24\x24\x24"
+ "\x24\x24\x24\x24",
+ .klen = 28,
+ .input = "\x24\x24\x24\x24\x24\x24\x24\x24"
+ "\x24\x24\x24\x24\x24\x24\x24\x24",
+ .ilen = 16,
+ .result = "\xfd\x1b\x4a\xe3\xbf\xf0\xad\x3d"
+ "\x06\xd3\x61\x27\xfd\x13\x9e\xde",
+ .rlen = 16,
+ }, {
+ .key = "\x25\x25\x25\x25\x25\x25\x25\x25"
+ "\x25\x25\x25\x25\x25\x25\x25\x25"
+ "\x25\x25\x25\x25\x25\x25\x25\x25"
+ "\x25\x25\x25\x25\x25\x25\x25\x25",
+ .klen = 32,
+ .input = "\x25\x25\x25\x25\x25\x25\x25\x25"
+ "\x25\x25\x25\x25\x25\x25\x25\x25",
+ .ilen = 16,
+ .result = "\x1a\x91\xfb\x2b\xb7\x78\x6b\xc4"
+ "\x17\xd9\xff\x40\x3b\x0e\xe5\xfe",
+ .rlen = 16,
+ }, {
+ .key = "\x35\x35\x35\x35\x35\x35\x35\x35"
+ "\x35\x35\x35\x35\x35\x35\x35\x35"
+ "\x35\x35\x35\x35\x35\x35\x35\x35"
+ "\x35\x35\x35\x35\x35\x35\x35\x35"
+ "\x35\x35\x35\x35\x35\x35\x35\x35",
+ .klen = 40,
+ .input = "\x35\x35\x35\x35\x35\x35\x35\x35"
+ "\x35\x35\x35\x35\x35\x35\x35\x35",
+ .ilen = 16,
+ .result = "\xa5\x2c\x85\x6f\x9c\xba\xa0\x97"
+ "\x9e\xc6\x84\x0f\x17\x21\x07\xee",
+ .rlen = 16,
+ },
+};
+
+static struct cipher_testvec anubis_dec_tv_template[] = {
+ {
+ .key = "\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe"
+ "\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe",
+ .klen = 16,
+ .input = "\x6d\xc5\xda\xa2\x26\x7d\x62\x6f"
+ "\x08\xb7\x52\x8e\x6e\x6e\x86\x90",
+ .ilen = 16,
+ .result = "\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe"
+ "\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe",
+ .rlen = 16,
+ }, {
+
+ .key = "\x03\x03\x03\x03\x03\x03\x03\x03"
+ "\x03\x03\x03\x03\x03\x03\x03\x03"
+ "\x03\x03\x03\x03",
+ .klen = 20,
+ .input = "\xdb\xf1\x42\xf4\xd1\x8a\xc7\x49"
+ "\x87\x41\x6f\x82\x0a\x98\x64\xae",
+ .ilen = 16,
+ .result = "\x03\x03\x03\x03\x03\x03\x03\x03"
+ "\x03\x03\x03\x03\x03\x03\x03\x03",
+ .rlen = 16,
+ }, {
+ .key = "\x24\x24\x24\x24\x24\x24\x24\x24"
+ "\x24\x24\x24\x24\x24\x24\x24\x24"
+ "\x24\x24\x24\x24\x24\x24\x24\x24"
+ "\x24\x24\x24\x24",
+ .klen = 28,
+ .input = "\xfd\x1b\x4a\xe3\xbf\xf0\xad\x3d"
+ "\x06\xd3\x61\x27\xfd\x13\x9e\xde",
+ .ilen = 16,
+ .result = "\x24\x24\x24\x24\x24\x24\x24\x24"
+ "\x24\x24\x24\x24\x24\x24\x24\x24",
+ .rlen = 16,
+ }, {
+ .key = "\x25\x25\x25\x25\x25\x25\x25\x25"
+ "\x25\x25\x25\x25\x25\x25\x25\x25"
+ "\x25\x25\x25\x25\x25\x25\x25\x25"
+ "\x25\x25\x25\x25\x25\x25\x25\x25",
+ .klen = 32,
+ .input = "\x1a\x91\xfb\x2b\xb7\x78\x6b\xc4"
+ "\x17\xd9\xff\x40\x3b\x0e\xe5\xfe",
+ .ilen = 16,
+ .result = "\x25\x25\x25\x25\x25\x25\x25\x25"
+ "\x25\x25\x25\x25\x25\x25\x25\x25",
+ .rlen = 16,
+ }, {
+ .key = "\x35\x35\x35\x35\x35\x35\x35\x35"
+ "\x35\x35\x35\x35\x35\x35\x35\x35"
+ "\x35\x35\x35\x35\x35\x35\x35\x35"
+ "\x35\x35\x35\x35\x35\x35\x35\x35"
+ "\x35\x35\x35\x35\x35\x35\x35\x35",
+ .input = "\xa5\x2c\x85\x6f\x9c\xba\xa0\x97"
+ "\x9e\xc6\x84\x0f\x17\x21\x07\xee",
+ .klen = 40,
+ .ilen = 16,
+ .result = "\x35\x35\x35\x35\x35\x35\x35\x35"
+ "\x35\x35\x35\x35\x35\x35\x35\x35",
+ .rlen = 16,
+ },
+};
+
+static struct cipher_testvec anubis_cbc_enc_tv_template[] = {
+ {
+ .key = "\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe"
+ "\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe",
+ .klen = 16,
+ .input = "\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe"
+ "\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe"
+ "\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe"
+ "\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe",
+ .ilen = 32,
+ .result = "\x6d\xc5\xda\xa2\x26\x7d\x62\x6f"
+ "\x08\xb7\x52\x8e\x6e\x6e\x86\x90"
+ "\x86\xd8\xb5\x6f\x98\x5e\x8a\x66"
+ "\x4f\x1f\x78\xa1\xbb\x37\xf1\xbe",
+ .rlen = 32,
+ }, {
+ .key = "\x35\x35\x35\x35\x35\x35\x35\x35"
+ "\x35\x35\x35\x35\x35\x35\x35\x35"
+ "\x35\x35\x35\x35\x35\x35\x35\x35"
+ "\x35\x35\x35\x35\x35\x35\x35\x35"
+ "\x35\x35\x35\x35\x35\x35\x35\x35",
+ .klen = 40,
+ .input = "\x35\x35\x35\x35\x35\x35\x35\x35"
+ "\x35\x35\x35\x35\x35\x35\x35\x35"
+ "\x35\x35\x35\x35\x35\x35\x35\x35"
+ "\x35\x35\x35\x35\x35\x35\x35\x35",
+ .ilen = 32,
+ .result = "\xa5\x2c\x85\x6f\x9c\xba\xa0\x97"
+ "\x9e\xc6\x84\x0f\x17\x21\x07\xee"
+ "\xa2\xbc\x06\x98\xc6\x4b\xda\x75"
+ "\x2e\xaa\xbe\x58\xce\x01\x5b\xc7",
+ .rlen = 32,
+ },
+};
+
+static struct cipher_testvec anubis_cbc_dec_tv_template[] = {
+ {
+ .key = "\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe"
+ "\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe",
+ .klen = 16,
+ .input = "\x6d\xc5\xda\xa2\x26\x7d\x62\x6f"
+ "\x08\xb7\x52\x8e\x6e\x6e\x86\x90"
+ "\x86\xd8\xb5\x6f\x98\x5e\x8a\x66"
+ "\x4f\x1f\x78\xa1\xbb\x37\xf1\xbe",
+ .ilen = 32,
+ .result = "\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe"
+ "\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe"
+ "\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe"
+ "\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe",
+ .rlen = 32,
+ }, {
+ .key = "\x35\x35\x35\x35\x35\x35\x35\x35"
+ "\x35\x35\x35\x35\x35\x35\x35\x35"
+ "\x35\x35\x35\x35\x35\x35\x35\x35"
+ "\x35\x35\x35\x35\x35\x35\x35\x35"
+ "\x35\x35\x35\x35\x35\x35\x35\x35",
+ .klen = 40,
+ .input = "\xa5\x2c\x85\x6f\x9c\xba\xa0\x97"
+ "\x9e\xc6\x84\x0f\x17\x21\x07\xee"
+ "\xa2\xbc\x06\x98\xc6\x4b\xda\x75"
+ "\x2e\xaa\xbe\x58\xce\x01\x5b\xc7",
+ .ilen = 32,
+ .result = "\x35\x35\x35\x35\x35\x35\x35\x35"
+ "\x35\x35\x35\x35\x35\x35\x35\x35"
+ "\x35\x35\x35\x35\x35\x35\x35\x35"
+ "\x35\x35\x35\x35\x35\x35\x35\x35",
+ .rlen = 32,
+ },
+};
+
+/*
+ * XETA test vectors
+ */
+#define XETA_ENC_TEST_VECTORS 4
+#define XETA_DEC_TEST_VECTORS 4
+
+static struct cipher_testvec xeta_enc_tv_template[] = {
+ {
+ .key = zeroed_string,
+ .klen = 16,
+ .input = zeroed_string,
+ .ilen = 8,
+ .result = "\xaa\x22\x96\xe5\x6c\x61\xf3\x45",
+ .rlen = 8,
+ }, {
+ .key = "\x2b\x02\x05\x68\x06\x14\x49\x76"
+ "\x77\x5d\x0e\x26\x6c\x28\x78\x43",
+ .klen = 16,
+ .input = "\x74\x65\x73\x74\x20\x6d\x65\x2e",
+ .ilen = 8,
+ .result = "\x82\x3e\xeb\x35\xdc\xdd\xd9\xc3",
+ .rlen = 8,
+ }, {
+ .key = "\x09\x65\x43\x11\x66\x44\x39\x25"
+ "\x51\x3a\x16\x10\x0a\x08\x12\x6e",
+ .klen = 16,
+ .input = "\x6c\x6f\x6e\x67\x65\x72\x5f\x74"
+ "\x65\x73\x74\x5f\x76\x65\x63\x74",
+ .ilen = 16,
+ .result = "\xe2\x04\xdb\xf2\x89\x85\x9e\xea"
+ "\x61\x35\xaa\xed\xb5\xcb\x71\x2c",
+ .rlen = 16,
+ }, {
+ .key = "\x4d\x76\x32\x17\x05\x3f\x75\x2c"
+ "\x5d\x04\x16\x36\x15\x72\x63\x2f",
+ .klen = 16,
+ .input = "\x54\x65\x61\x20\x69\x73\x20\x67"
+ "\x6f\x6f\x64\x20\x66\x6f\x72\x20"
+ "\x79\x6f\x75\x21\x21\x21\x20\x72"
+ "\x65\x61\x6c\x6c\x79\x21\x21\x21",
+ .ilen = 32,
+ .result = "\x0b\x03\xcd\x8a\xbe\x95\xfd\xb1"
+ "\xc1\x44\x91\x0b\xa5\xc9\x1b\xb4"
+ "\xa9\xda\x1e\x9e\xb1\x3e\x2a\x8f"
+ "\xea\xa5\x6a\x85\xd1\xf4\xa8\xa5",
+ .rlen = 32,
+ }
+};
+
+static struct cipher_testvec xeta_dec_tv_template[] = {
+ {
+ .key = zeroed_string,
+ .klen = 16,
+ .input = "\xaa\x22\x96\xe5\x6c\x61\xf3\x45",
+ .ilen = 8,
+ .result = zeroed_string,
+ .rlen = 8,
+ }, {
+ .key = "\x2b\x02\x05\x68\x06\x14\x49\x76"
+ "\x77\x5d\x0e\x26\x6c\x28\x78\x43",
+ .klen = 16,
+ .input = "\x82\x3e\xeb\x35\xdc\xdd\xd9\xc3",
+ .ilen = 8,
+ .result = "\x74\x65\x73\x74\x20\x6d\x65\x2e",
+ .rlen = 8,
+ }, {
+ .key = "\x09\x65\x43\x11\x66\x44\x39\x25"
+ "\x51\x3a\x16\x10\x0a\x08\x12\x6e",
+ .klen = 16,
+ .input = "\xe2\x04\xdb\xf2\x89\x85\x9e\xea"
+ "\x61\x35\xaa\xed\xb5\xcb\x71\x2c",
+ .ilen = 16,
+ .result = "\x6c\x6f\x6e\x67\x65\x72\x5f\x74"
+ "\x65\x73\x74\x5f\x76\x65\x63\x74",
+ .rlen = 16,
+ }, {
+ .key = "\x4d\x76\x32\x17\x05\x3f\x75\x2c"
+ "\x5d\x04\x16\x36\x15\x72\x63\x2f",
+ .klen = 16,
+ .input = "\x0b\x03\xcd\x8a\xbe\x95\xfd\xb1"
+ "\xc1\x44\x91\x0b\xa5\xc9\x1b\xb4"
+ "\xa9\xda\x1e\x9e\xb1\x3e\x2a\x8f"
+ "\xea\xa5\x6a\x85\xd1\xf4\xa8\xa5",
+ .ilen = 32,
+ .result = "\x54\x65\x61\x20\x69\x73\x20\x67"
+ "\x6f\x6f\x64\x20\x66\x6f\x72\x20"
+ "\x79\x6f\x75\x21\x21\x21\x20\x72"
+ "\x65\x61\x6c\x6c\x79\x21\x21\x21",
+ .rlen = 32,
+ }
+};
+
+/*
+ * FCrypt test vectors
+ */
+#define FCRYPT_ENC_TEST_VECTORS ARRAY_SIZE(fcrypt_pcbc_enc_tv_template)
+#define FCRYPT_DEC_TEST_VECTORS ARRAY_SIZE(fcrypt_pcbc_dec_tv_template)
+
+static struct cipher_testvec fcrypt_pcbc_enc_tv_template[] = {
+ { /* http://www.openafs.org/pipermail/openafs-devel/2000-December/005320.html */
+ .key = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .klen = 8,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .input = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .ilen = 8,
+ .result = "\x0E\x09\x00\xC7\x3E\xF7\xED\x41",
+ .rlen = 8,
+ }, {
+ .key = "\x11\x44\x77\xAA\xDD\x00\x33\x66",
+ .klen = 8,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .input = "\x12\x34\x56\x78\x9A\xBC\xDE\xF0",
+ .ilen = 8,
+ .result = "\xD8\xED\x78\x74\x77\xEC\x06\x80",
+ .rlen = 8,
+ }, { /* From Arla */
+ .key = "\xf0\xe1\xd2\xc3\xb4\xa5\x96\x87",
+ .klen = 8,
+ .iv = "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .input = "The quick brown fox jumps over the lazy dogs.\0\0",
+ .ilen = 48,
+ .result = "\x00\xf0\x0e\x11\x75\xe6\x23\x82"
+ "\xee\xac\x98\x62\x44\x51\xe4\x84"
+ "\xc3\x59\xd8\xaa\x64\x60\xae\xf7"
+ "\xd2\xd9\x13\x79\x72\xa3\x45\x03"
+ "\x23\xb5\x62\xd7\x0c\xf5\x27\xd1"
+ "\xf8\x91\x3c\xac\x44\x22\x92\xef",
+ .rlen = 48,
+ }, {
+ .key = "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .klen = 8,
+ .iv = "\xf0\xe1\xd2\xc3\xb4\xa5\x96\x87",
+ .input = "The quick brown fox jumps over the lazy dogs.\0\0",
+ .ilen = 48,
+ .result = "\xca\x90\xf5\x9d\xcb\xd4\xd2\x3c"
+ "\x01\x88\x7f\x3e\x31\x6e\x62\x9d"
+ "\xd8\xe0\x57\xa3\x06\x3a\x42\x58"
+ "\x2a\x28\xfe\x72\x52\x2f\xdd\xe0"
+ "\x19\x89\x09\x1c\x2a\x8e\x8c\x94"
+ "\xfc\xc7\x68\xe4\x88\xaa\xde\x0f",
+ .rlen = 48,
+ }, { /* split-page version */
+ .key = "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .klen = 8,
+ .iv = "\xf0\xe1\xd2\xc3\xb4\xa5\x96\x87",
+ .input = "The quick brown fox jumps over the lazy dogs.\0\0",
+ .ilen = 48,
+ .result = "\xca\x90\xf5\x9d\xcb\xd4\xd2\x3c"
+ "\x01\x88\x7f\x3e\x31\x6e\x62\x9d"
+ "\xd8\xe0\x57\xa3\x06\x3a\x42\x58"
+ "\x2a\x28\xfe\x72\x52\x2f\xdd\xe0"
+ "\x19\x89\x09\x1c\x2a\x8e\x8c\x94"
+ "\xfc\xc7\x68\xe4\x88\xaa\xde\x0f",
+ .rlen = 48,
+ .np = 2,
+ .tap = { 20, 28 },
+ }
+};
+
+static struct cipher_testvec fcrypt_pcbc_dec_tv_template[] = {
+ { /* http://www.openafs.org/pipermail/openafs-devel/2000-December/005320.html */
+ .key = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .klen = 8,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .input = "\x0E\x09\x00\xC7\x3E\xF7\xED\x41",
+ .ilen = 8,
+ .result = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .rlen = 8,
+ }, {
+ .key = "\x11\x44\x77\xAA\xDD\x00\x33\x66",
+ .klen = 8,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .input = "\xD8\xED\x78\x74\x77\xEC\x06\x80",
+ .ilen = 8,
+ .result = "\x12\x34\x56\x78\x9A\xBC\xDE\xF0",
+ .rlen = 8,
+ }, { /* From Arla */
+ .key = "\xf0\xe1\xd2\xc3\xb4\xa5\x96\x87",
+ .klen = 8,
+ .iv = "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .input = "\x00\xf0\x0e\x11\x75\xe6\x23\x82"
+ "\xee\xac\x98\x62\x44\x51\xe4\x84"
+ "\xc3\x59\xd8\xaa\x64\x60\xae\xf7"
+ "\xd2\xd9\x13\x79\x72\xa3\x45\x03"
+ "\x23\xb5\x62\xd7\x0c\xf5\x27\xd1"
+ "\xf8\x91\x3c\xac\x44\x22\x92\xef",
+ .ilen = 48,
+ .result = "The quick brown fox jumps over the lazy dogs.\0\0",
+ .rlen = 48,
+ }, {
+ .key = "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .klen = 8,
+ .iv = "\xf0\xe1\xd2\xc3\xb4\xa5\x96\x87",
+ .input = "\xca\x90\xf5\x9d\xcb\xd4\xd2\x3c"
+ "\x01\x88\x7f\x3e\x31\x6e\x62\x9d"
+ "\xd8\xe0\x57\xa3\x06\x3a\x42\x58"
+ "\x2a\x28\xfe\x72\x52\x2f\xdd\xe0"
+ "\x19\x89\x09\x1c\x2a\x8e\x8c\x94"
+ "\xfc\xc7\x68\xe4\x88\xaa\xde\x0f",
+ .ilen = 48,
+ .result = "The quick brown fox jumps over the lazy dogs.\0\0",
+ .rlen = 48,
+ }, { /* split-page version */
+ .key = "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .klen = 8,
+ .iv = "\xf0\xe1\xd2\xc3\xb4\xa5\x96\x87",
+ .input = "\xca\x90\xf5\x9d\xcb\xd4\xd2\x3c"
+ "\x01\x88\x7f\x3e\x31\x6e\x62\x9d"
+ "\xd8\xe0\x57\xa3\x06\x3a\x42\x58"
+ "\x2a\x28\xfe\x72\x52\x2f\xdd\xe0"
+ "\x19\x89\x09\x1c\x2a\x8e\x8c\x94"
+ "\xfc\xc7\x68\xe4\x88\xaa\xde\x0f",
+ .ilen = 48,
+ .result = "The quick brown fox jumps over the lazy dogs.\0\0",
+ .rlen = 48,
+ .np = 2,
+ .tap = { 20, 28 },
+ }
+};
+
+/*
+ * CAMELLIA test vectors.
+ */
+#define CAMELLIA_ENC_TEST_VECTORS 3
+#define CAMELLIA_DEC_TEST_VECTORS 3
+#define CAMELLIA_CBC_ENC_TEST_VECTORS 2
+#define CAMELLIA_CBC_DEC_TEST_VECTORS 2
+
+static struct cipher_testvec camellia_enc_tv_template[] = {
+ {
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef"
+ "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .klen = 16,
+ .input = "\x01\x23\x45\x67\x89\xab\xcd\xef"
+ "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .ilen = 16,
+ .result = "\x67\x67\x31\x38\x54\x96\x69\x73"
+ "\x08\x57\x06\x56\x48\xea\xbe\x43",
+ .rlen = 16,
+ }, {
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef"
+ "\xfe\xdc\xba\x98\x76\x54\x32\x10"
+ "\x00\x11\x22\x33\x44\x55\x66\x77",
+ .klen = 24,
+ .input = "\x01\x23\x45\x67\x89\xab\xcd\xef"
+ "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .ilen = 16,
+ .result = "\xb4\x99\x34\x01\xb3\xe9\x96\xf8"
+ "\x4e\xe5\xce\xe7\xd7\x9b\x09\xb9",
+ .rlen = 16,
+ }, {
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef"
+ "\xfe\xdc\xba\x98\x76\x54\x32\x10"
+ "\x00\x11\x22\x33\x44\x55\x66\x77"
+ "\x88\x99\xaa\xbb\xcc\xdd\xee\xff",
+ .klen = 32,
+ .input = "\x01\x23\x45\x67\x89\xab\xcd\xef"
+ "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .ilen = 16,
+ .result = "\x9a\xcc\x23\x7d\xff\x16\xd7\x6c"
+ "\x20\xef\x7c\x91\x9e\x3a\x75\x09",
+ .rlen = 16,
+ },
+};
+
+static struct cipher_testvec camellia_dec_tv_template[] = {
+ {
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef"
+ "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .klen = 16,
+ .input = "\x67\x67\x31\x38\x54\x96\x69\x73"
+ "\x08\x57\x06\x56\x48\xea\xbe\x43",
+ .ilen = 16,
+ .result = "\x01\x23\x45\x67\x89\xab\xcd\xef"
+ "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .rlen = 16,
+ }, {
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef"
+ "\xfe\xdc\xba\x98\x76\x54\x32\x10"
+ "\x00\x11\x22\x33\x44\x55\x66\x77",
+ .klen = 24,
+ .input = "\xb4\x99\x34\x01\xb3\xe9\x96\xf8"
+ "\x4e\xe5\xce\xe7\xd7\x9b\x09\xb9",
+ .ilen = 16,
+ .result = "\x01\x23\x45\x67\x89\xab\xcd\xef"
+ "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .rlen = 16,
+ }, {
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef"
+ "\xfe\xdc\xba\x98\x76\x54\x32\x10"
+ "\x00\x11\x22\x33\x44\x55\x66\x77"
+ "\x88\x99\xaa\xbb\xcc\xdd\xee\xff",
+ .klen = 32,
+ .input = "\x9a\xcc\x23\x7d\xff\x16\xd7\x6c"
+ "\x20\xef\x7c\x91\x9e\x3a\x75\x09",
+ .ilen = 16,
+ .result = "\x01\x23\x45\x67\x89\xab\xcd\xef"
+ "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .rlen = 16,
+ },
+};
+
+static struct cipher_testvec camellia_cbc_enc_tv_template[] = {
+ {
+ .key = "\x06\xa9\x21\x40\x36\xb8\xa1\x5b"
+ "\x51\x2e\x03\xd5\x34\x12\x00\x06",
+ .klen = 16,
+ .iv = "\x3d\xaf\xba\x42\x9d\x9e\xb4\x30"
+ "\xb4\x22\xda\x80\x2c\x9f\xac\x41",
+ .input = "Single block msg",
+ .ilen = 16,
+ .result = "\xea\x32\x12\x76\x3b\x50\x10\xe7"
+ "\x18\xf6\xfd\x5d\xf6\x8f\x13\x51",
+ .rlen = 16,
+ }, {
+ .key = "\xc2\x86\x69\x6d\x88\x7c\x9a\xa0"
+ "\x61\x1b\xbb\x3e\x20\x25\xa4\x5a",
+ .klen = 16,
+ .iv = "\x56\x2e\x17\x99\x6d\x09\x3d\x28"
+ "\xdd\xb3\xba\x69\x5a\x2e\x6f\x58",
+ .input = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
+ .ilen = 32,
+ .result = "\xa5\xdf\x6e\x50\xda\x70\x6c\x01"
+ "\x4a\xab\xf3\xf2\xd6\xfc\x6c\xfd"
+ "\x19\xb4\x3e\x57\x1c\x02\x5e\xa0"
+ "\x15\x78\xe0\x5e\xf2\xcb\x87\x16",
+ .rlen = 32,
+ },
+};
+
+static struct cipher_testvec camellia_cbc_dec_tv_template[] = {
+ {
+ .key = "\x06\xa9\x21\x40\x36\xb8\xa1\x5b"
+ "\x51\x2e\x03\xd5\x34\x12\x00\x06",
+ .klen = 16,
+ .iv = "\x3d\xaf\xba\x42\x9d\x9e\xb4\x30"
+ "\xb4\x22\xda\x80\x2c\x9f\xac\x41",
+ .input = "\xea\x32\x12\x76\x3b\x50\x10\xe7"
+ "\x18\xf6\xfd\x5d\xf6\x8f\x13\x51",
+ .ilen = 16,
+ .result = "Single block msg",
+ .rlen = 16,
+ }, {
+ .key = "\xc2\x86\x69\x6d\x88\x7c\x9a\xa0"
+ "\x61\x1b\xbb\x3e\x20\x25\xa4\x5a",
+ .klen = 16,
+ .iv = "\x56\x2e\x17\x99\x6d\x09\x3d\x28"
+ "\xdd\xb3\xba\x69\x5a\x2e\x6f\x58",
+ .input = "\xa5\xdf\x6e\x50\xda\x70\x6c\x01"
+ "\x4a\xab\xf3\xf2\xd6\xfc\x6c\xfd"
+ "\x19\xb4\x3e\x57\x1c\x02\x5e\xa0"
+ "\x15\x78\xe0\x5e\xf2\xcb\x87\x16",
+ .ilen = 32,
+ .result = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
+ .rlen = 32,
+ },
+};
+
+/*
+ * SEED test vectors
+ */
+#define SEED_ENC_TEST_VECTORS 4
+#define SEED_DEC_TEST_VECTORS 4
+
+static struct cipher_testvec seed_enc_tv_template[] = {
+ {
+ .key = zeroed_string,
+ .klen = 16,
+ .input = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .ilen = 16,
+ .result = "\x5e\xba\xc6\xe0\x05\x4e\x16\x68"
+ "\x19\xaf\xf1\xcc\x6d\x34\x6c\xdb",
+ .rlen = 16,
+ }, {
+ .key = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .klen = 16,
+ .input = zeroed_string,
+ .ilen = 16,
+ .result = "\xc1\x1f\x22\xf2\x01\x40\x50\x50"
+ "\x84\x48\x35\x97\xe4\x37\x0f\x43",
+ .rlen = 16,
+ }, {
+ .key = "\x47\x06\x48\x08\x51\xe6\x1b\xe8"
+ "\x5d\x74\xbf\xb3\xfd\x95\x61\x85",
+ .klen = 16,
+ .input = "\x83\xa2\xf8\xa2\x88\x64\x1f\xb9"
+ "\xa4\xe9\xa5\xcc\x2f\x13\x1c\x7d",
+ .ilen = 16,
+ .result = "\xee\x54\xd1\x3e\xbc\xae\x70\x6d"
+ "\x22\x6b\xc3\x14\x2c\xd4\x0d\x4a",
+ .rlen = 16,
+ }, {
+ .key = "\x28\xdb\xc3\xbc\x49\xff\xd8\x7d"
+ "\xcf\xa5\x09\xb1\x1d\x42\x2b\xe7",
+ .klen = 16,
+ .input = "\xb4\x1e\x6b\xe2\xeb\xa8\x4a\x14"
+ "\x8e\x2e\xed\x84\x59\x3c\x5e\xc7",
+ .ilen = 16,
+ .result = "\x9b\x9b\x7b\xfc\xd1\x81\x3c\xb9"
+ "\x5d\x0b\x36\x18\xf4\x0f\x51\x22",
+ .rlen = 16,
+ }
+};
+
+static struct cipher_testvec seed_dec_tv_template[] = {
+ {
+ .key = zeroed_string,
+ .klen = 16,
+ .input = "\x5e\xba\xc6\xe0\x05\x4e\x16\x68"
+ "\x19\xaf\xf1\xcc\x6d\x34\x6c\xdb",
+ .ilen = 16,
+ .result = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .rlen = 16,
+ }, {
+ .key = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .klen = 16,
+ .input = "\xc1\x1f\x22\xf2\x01\x40\x50\x50"
+ "\x84\x48\x35\x97\xe4\x37\x0f\x43",
+ .ilen = 16,
+ .result = zeroed_string,
+ .rlen = 16,
+ }, {
+ .key = "\x47\x06\x48\x08\x51\xe6\x1b\xe8"
+ "\x5d\x74\xbf\xb3\xfd\x95\x61\x85",
+ .klen = 16,
+ .input = "\xee\x54\xd1\x3e\xbc\xae\x70\x6d"
+ "\x22\x6b\xc3\x14\x2c\xd4\x0d\x4a",
+ .ilen = 16,
+ .result = "\x83\xa2\xf8\xa2\x88\x64\x1f\xb9"
+ "\xa4\xe9\xa5\xcc\x2f\x13\x1c\x7d",
+ .rlen = 16,
+ }, {
+ .key = "\x28\xdb\xc3\xbc\x49\xff\xd8\x7d"
+ "\xcf\xa5\x09\xb1\x1d\x42\x2b\xe7",
+ .klen = 16,
+ .input = "\x9b\x9b\x7b\xfc\xd1\x81\x3c\xb9"
+ "\x5d\x0b\x36\x18\xf4\x0f\x51\x22",
+ .ilen = 16,
+ .result = "\xb4\x1e\x6b\xe2\xeb\xa8\x4a\x14"
+ "\x8e\x2e\xed\x84\x59\x3c\x5e\xc7",
+ .rlen = 16,
+ }
+};
+
+#define SALSA20_STREAM_ENC_TEST_VECTORS 5
+static struct cipher_testvec salsa20_stream_enc_tv_template[] = {
+ /*
+ * Testvectors from verified.test-vectors submitted to ECRYPT.
+ * They are truncated to size 39, 64, 111, 129 to test a variety
+ * of input length.
+ */
+ { /* Set 3, vector 0 */
+ .key = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F",
+ .klen = 16,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .input = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00",
+ .ilen = 39,
+ .result = "\x2D\xD5\xC3\xF7\xBA\x2B\x20\xF7"
+ "\x68\x02\x41\x0C\x68\x86\x88\x89"
+ "\x5A\xD8\xC1\xBD\x4E\xA6\xC9\xB1"
+ "\x40\xFB\x9B\x90\xE2\x10\x49\xBF"
+ "\x58\x3F\x52\x79\x70\xEB\xC1",
+ .rlen = 39,
+ }, { /* Set 5, vector 0 */
+ .key = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .klen = 16,
+ .iv = "\x80\x00\x00\x00\x00\x00\x00\x00",
+ .input = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .ilen = 64,
+ .result = "\xB6\x6C\x1E\x44\x46\xDD\x95\x57"
+ "\xE5\x78\xE2\x23\xB0\xB7\x68\x01"
+ "\x7B\x23\xB2\x67\xBB\x02\x34\xAE"
+ "\x46\x26\xBF\x44\x3F\x21\x97\x76"
+ "\x43\x6F\xB1\x9F\xD0\xE8\x86\x6F"
+ "\xCD\x0D\xE9\xA9\x53\x8F\x4A\x09"
+ "\xCA\x9A\xC0\x73\x2E\x30\xBC\xF9"
+ "\x8E\x4F\x13\xE4\xB9\xE2\x01\xD9",
+ .rlen = 64,
+ }, { /* Set 3, vector 27 */
+ .key = "\x1B\x1C\x1D\x1E\x1F\x20\x21\x22"
+ "\x23\x24\x25\x26\x27\x28\x29\x2A"
+ "\x2B\x2C\x2D\x2E\x2F\x30\x31\x32"
+ "\x33\x34\x35\x36\x37\x38\x39\x3A",
+ .klen = 32,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .input = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00",
+ .ilen = 111,
+ .result = "\xAE\x39\x50\x8E\xAC\x9A\xEC\xE7"
+ "\xBF\x97\xBB\x20\xB9\xDE\xE4\x1F"
+ "\x87\xD9\x47\xF8\x28\x91\x35\x98"
+ "\xDB\x72\xCC\x23\x29\x48\x56\x5E"
+ "\x83\x7E\x0B\xF3\x7D\x5D\x38\x7B"
+ "\x2D\x71\x02\xB4\x3B\xB5\xD8\x23"
+ "\xB0\x4A\xDF\x3C\xEC\xB6\xD9\x3B"
+ "\x9B\xA7\x52\xBE\xC5\xD4\x50\x59"
+ "\x15\x14\xB4\x0E\x40\xE6\x53\xD1"
+ "\x83\x9C\x5B\xA0\x92\x29\x6B\x5E"
+ "\x96\x5B\x1E\x2F\xD3\xAC\xC1\x92"
+ "\xB1\x41\x3F\x19\x2F\xC4\x3B\xC6"
+ "\x95\x46\x45\x54\xE9\x75\x03\x08"
+ "\x44\xAF\xE5\x8A\x81\x12\x09",
+ .rlen = 111,
+ }, { /* Set 5, vector 27 */
+ .key = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .klen = 32,
+ .iv = "\x00\x00\x00\x10\x00\x00\x00\x00",
+ .input = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00",
+ .ilen = 129,
+ .result = "\xD2\xDB\x1A\x5C\xF1\xC1\xAC\xDB"
+ "\xE8\x1A\x7A\x43\x40\xEF\x53\x43"
+ "\x5E\x7F\x4B\x1A\x50\x52\x3F\x8D"
+ "\x28\x3D\xCF\x85\x1D\x69\x6E\x60"
+ "\xF2\xDE\x74\x56\x18\x1B\x84\x10"
+ "\xD4\x62\xBA\x60\x50\xF0\x61\xF2"
+ "\x1C\x78\x7F\xC1\x24\x34\xAF\x58"
+ "\xBF\x2C\x59\xCA\x90\x77\xF3\xB0"
+ "\x5B\x4A\xDF\x89\xCE\x2C\x2F\xFC"
+ "\x67\xF0\xE3\x45\xE8\xB3\xB3\x75"
+ "\xA0\x95\x71\xA1\x29\x39\x94\xCA"
+ "\x45\x2F\xBD\xCB\x10\xB6\xBE\x9F"
+ "\x8E\xF9\xB2\x01\x0A\x5A\x0A\xB7"
+ "\x6B\x9D\x70\x8E\x4B\xD6\x2F\xCD"
+ "\x2E\x40\x48\x75\xE9\xE2\x21\x45"
+ "\x0B\xC9\xB6\xB5\x66\xBC\x9A\x59"
+ "\x5A",
+ .rlen = 129,
+ }, { /* large test vector generated using Crypto++ */
+ .key = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
+ .klen = 32,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .input =
+ "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
+ "\x20\x21\x22\x23\x24\x25\x26\x27"
+ "\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f"
+ "\x30\x31\x32\x33\x34\x35\x36\x37"
+ "\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f"
+ "\x40\x41\x42\x43\x44\x45\x46\x47"
+ "\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f"
+ "\x50\x51\x52\x53\x54\x55\x56\x57"
+ "\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f"
+ "\x60\x61\x62\x63\x64\x65\x66\x67"
+ "\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f"
+ "\x70\x71\x72\x73\x74\x75\x76\x77"
+ "\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f"
+ "\x80\x81\x82\x83\x84\x85\x86\x87"
+ "\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
+ "\x90\x91\x92\x93\x94\x95\x96\x97"
+ "\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
+ "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7"
+ "\xa8\xa9\xaa\xab\xac\xad\xae\xaf"
+ "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7"
+ "\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf"
+ "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
+ "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
+ "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7"
+ "\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf"
+ "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7"
+ "\xe8\xe9\xea\xeb\xec\xed\xee\xef"
+ "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7"
+ "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"
+ "\x00\x03\x06\x09\x0c\x0f\x12\x15"
+ "\x18\x1b\x1e\x21\x24\x27\x2a\x2d"
+ "\x30\x33\x36\x39\x3c\x3f\x42\x45"
+ "\x48\x4b\x4e\x51\x54\x57\x5a\x5d"
+ "\x60\x63\x66\x69\x6c\x6f\x72\x75"
+ "\x78\x7b\x7e\x81\x84\x87\x8a\x8d"
+ "\x90\x93\x96\x99\x9c\x9f\xa2\xa5"
+ "\xa8\xab\xae\xb1\xb4\xb7\xba\xbd"
+ "\xc0\xc3\xc6\xc9\xcc\xcf\xd2\xd5"
+ "\xd8\xdb\xde\xe1\xe4\xe7\xea\xed"
+ "\xf0\xf3\xf6\xf9\xfc\xff\x02\x05"
+ "\x08\x0b\x0e\x11\x14\x17\x1a\x1d"
+ "\x20\x23\x26\x29\x2c\x2f\x32\x35"
+ "\x38\x3b\x3e\x41\x44\x47\x4a\x4d"
+ "\x50\x53\x56\x59\x5c\x5f\x62\x65"
+ "\x68\x6b\x6e\x71\x74\x77\x7a\x7d"
+ "\x80\x83\x86\x89\x8c\x8f\x92\x95"
+ "\x98\x9b\x9e\xa1\xa4\xa7\xaa\xad"
+ "\xb0\xb3\xb6\xb9\xbc\xbf\xc2\xc5"
+ "\xc8\xcb\xce\xd1\xd4\xd7\xda\xdd"
+ "\xe0\xe3\xe6\xe9\xec\xef\xf2\xf5"
+ "\xf8\xfb\xfe\x01\x04\x07\x0a\x0d"
+ "\x10\x13\x16\x19\x1c\x1f\x22\x25"
+ "\x28\x2b\x2e\x31\x34\x37\x3a\x3d"
+ "\x40\x43\x46\x49\x4c\x4f\x52\x55"
+ "\x58\x5b\x5e\x61\x64\x67\x6a\x6d"
+ "\x70\x73\x76\x79\x7c\x7f\x82\x85"
+ "\x88\x8b\x8e\x91\x94\x97\x9a\x9d"
+ "\xa0\xa3\xa6\xa9\xac\xaf\xb2\xb5"
+ "\xb8\xbb\xbe\xc1\xc4\xc7\xca\xcd"
+ "\xd0\xd3\xd6\xd9\xdc\xdf\xe2\xe5"
+ "\xe8\xeb\xee\xf1\xf4\xf7\xfa\xfd"
+ "\x00\x05\x0a\x0f\x14\x19\x1e\x23"
+ "\x28\x2d\x32\x37\x3c\x41\x46\x4b"
+ "\x50\x55\x5a\x5f\x64\x69\x6e\x73"
+ "\x78\x7d\x82\x87\x8c\x91\x96\x9b"
+ "\xa0\xa5\xaa\xaf\xb4\xb9\xbe\xc3"
+ "\xc8\xcd\xd2\xd7\xdc\xe1\xe6\xeb"
+ "\xf0\xf5\xfa\xff\x04\x09\x0e\x13"
+ "\x18\x1d\x22\x27\x2c\x31\x36\x3b"
+ "\x40\x45\x4a\x4f\x54\x59\x5e\x63"
+ "\x68\x6d\x72\x77\x7c\x81\x86\x8b"
+ "\x90\x95\x9a\x9f\xa4\xa9\xae\xb3"
+ "\xb8\xbd\xc2\xc7\xcc\xd1\xd6\xdb"
+ "\xe0\xe5\xea\xef\xf4\xf9\xfe\x03"
+ "\x08\x0d\x12\x17\x1c\x21\x26\x2b"
+ "\x30\x35\x3a\x3f\x44\x49\x4e\x53"
+ "\x58\x5d\x62\x67\x6c\x71\x76\x7b"
+ "\x80\x85\x8a\x8f\x94\x99\x9e\xa3"
+ "\xa8\xad\xb2\xb7\xbc\xc1\xc6\xcb"
+ "\xd0\xd5\xda\xdf\xe4\xe9\xee\xf3"
+ "\xf8\xfd\x02\x07\x0c\x11\x16\x1b"
+ "\x20\x25\x2a\x2f\x34\x39\x3e\x43"
+ "\x48\x4d\x52\x57\x5c\x61\x66\x6b"
+ "\x70\x75\x7a\x7f\x84\x89\x8e\x93"
+ "\x98\x9d\xa2\xa7\xac\xb1\xb6\xbb"
+ "\xc0\xc5\xca\xcf\xd4\xd9\xde\xe3"
+ "\xe8\xed\xf2\xf7\xfc\x01\x06\x0b"
+ "\x10\x15\x1a\x1f\x24\x29\x2e\x33"
+ "\x38\x3d\x42\x47\x4c\x51\x56\x5b"
+ "\x60\x65\x6a\x6f\x74\x79\x7e\x83"
+ "\x88\x8d\x92\x97\x9c\xa1\xa6\xab"
+ "\xb0\xb5\xba\xbf\xc4\xc9\xce\xd3"
+ "\xd8\xdd\xe2\xe7\xec\xf1\xf6\xfb"
+ "\x00\x07\x0e\x15\x1c\x23\x2a\x31"
+ "\x38\x3f\x46\x4d\x54\x5b\x62\x69"
+ "\x70\x77\x7e\x85\x8c\x93\x9a\xa1"
+ "\xa8\xaf\xb6\xbd\xc4\xcb\xd2\xd9"
+ "\xe0\xe7\xee\xf5\xfc\x03\x0a\x11"
+ "\x18\x1f\x26\x2d\x34\x3b\x42\x49"
+ "\x50\x57\x5e\x65\x6c\x73\x7a\x81"
+ "\x88\x8f\x96\x9d\xa4\xab\xb2\xb9"
+ "\xc0\xc7\xce\xd5\xdc\xe3\xea\xf1"
+ "\xf8\xff\x06\x0d\x14\x1b\x22\x29"
+ "\x30\x37\x3e\x45\x4c\x53\x5a\x61"
+ "\x68\x6f\x76\x7d\x84\x8b\x92\x99"
+ "\xa0\xa7\xae\xb5\xbc\xc3\xca\xd1"
+ "\xd8\xdf\xe6\xed\xf4\xfb\x02\x09"
+ "\x10\x17\x1e\x25\x2c\x33\x3a\x41"
+ "\x48\x4f\x56\x5d\x64\x6b\x72\x79"
+ "\x80\x87\x8e\x95\x9c\xa3\xaa\xb1"
+ "\xb8\xbf\xc6\xcd\xd4\xdb\xe2\xe9"
+ "\xf0\xf7\xfe\x05\x0c\x13\x1a\x21"
+ "\x28\x2f\x36\x3d\x44\x4b\x52\x59"
+ "\x60\x67\x6e\x75\x7c\x83\x8a\x91"
+ "\x98\x9f\xa6\xad\xb4\xbb\xc2\xc9"
+ "\xd0\xd7\xde\xe5\xec\xf3\xfa\x01"
+ "\x08\x0f\x16\x1d\x24\x2b\x32\x39"
+ "\x40\x47\x4e\x55\x5c\x63\x6a\x71"
+ "\x78\x7f\x86\x8d\x94\x9b\xa2\xa9"
+ "\xb0\xb7\xbe\xc5\xcc\xd3\xda\xe1"
+ "\xe8\xef\xf6\xfd\x04\x0b\x12\x19"
+ "\x20\x27\x2e\x35\x3c\x43\x4a\x51"
+ "\x58\x5f\x66\x6d\x74\x7b\x82\x89"
+ "\x90\x97\x9e\xa5\xac\xb3\xba\xc1"
+ "\xc8\xcf\xd6\xdd\xe4\xeb\xf2\xf9"
+ "\x00\x09\x12\x1b\x24\x2d\x36\x3f"
+ "\x48\x51\x5a\x63\x6c\x75\x7e\x87"
+ "\x90\x99\xa2\xab\xb4\xbd\xc6\xcf"
+ "\xd8\xe1\xea\xf3\xfc\x05\x0e\x17"
+ "\x20\x29\x32\x3b\x44\x4d\x56\x5f"
+ "\x68\x71\x7a\x83\x8c\x95\x9e\xa7"
+ "\xb0\xb9\xc2\xcb\xd4\xdd\xe6\xef"
+ "\xf8\x01\x0a\x13\x1c\x25\x2e\x37"
+ "\x40\x49\x52\x5b\x64\x6d\x76\x7f"
+ "\x88\x91\x9a\xa3\xac\xb5\xbe\xc7"
+ "\xd0\xd9\xe2\xeb\xf4\xfd\x06\x0f"
+ "\x18\x21\x2a\x33\x3c\x45\x4e\x57"
+ "\x60\x69\x72\x7b\x84\x8d\x96\x9f"
+ "\xa8\xb1\xba\xc3\xcc\xd5\xde\xe7"
+ "\xf0\xf9\x02\x0b\x14\x1d\x26\x2f"
+ "\x38\x41\x4a\x53\x5c\x65\x6e\x77"
+ "\x80\x89\x92\x9b\xa4\xad\xb6\xbf"
+ "\xc8\xd1\xda\xe3\xec\xf5\xfe\x07"
+ "\x10\x19\x22\x2b\x34\x3d\x46\x4f"
+ "\x58\x61\x6a\x73\x7c\x85\x8e\x97"
+ "\xa0\xa9\xb2\xbb\xc4\xcd\xd6\xdf"
+ "\xe8\xf1\xfa\x03\x0c\x15\x1e\x27"
+ "\x30\x39\x42\x4b\x54\x5d\x66\x6f"
+ "\x78\x81\x8a\x93\x9c\xa5\xae\xb7"
+ "\xc0\xc9\xd2\xdb\xe4\xed\xf6\xff"
+ "\x08\x11\x1a\x23\x2c\x35\x3e\x47"
+ "\x50\x59\x62\x6b\x74\x7d\x86\x8f"
+ "\x98\xa1\xaa\xb3\xbc\xc5\xce\xd7"
+ "\xe0\xe9\xf2\xfb\x04\x0d\x16\x1f"
+ "\x28\x31\x3a\x43\x4c\x55\x5e\x67"
+ "\x70\x79\x82\x8b\x94\x9d\xa6\xaf"
+ "\xb8\xc1\xca\xd3\xdc\xe5\xee\xf7"
+ "\x00\x0b\x16\x21\x2c\x37\x42\x4d"
+ "\x58\x63\x6e\x79\x84\x8f\x9a\xa5"
+ "\xb0\xbb\xc6\xd1\xdc\xe7\xf2\xfd"
+ "\x08\x13\x1e\x29\x34\x3f\x4a\x55"
+ "\x60\x6b\x76\x81\x8c\x97\xa2\xad"
+ "\xb8\xc3\xce\xd9\xe4\xef\xfa\x05"
+ "\x10\x1b\x26\x31\x3c\x47\x52\x5d"
+ "\x68\x73\x7e\x89\x94\x9f\xaa\xb5"
+ "\xc0\xcb\xd6\xe1\xec\xf7\x02\x0d"
+ "\x18\x23\x2e\x39\x44\x4f\x5a\x65"
+ "\x70\x7b\x86\x91\x9c\xa7\xb2\xbd"
+ "\xc8\xd3\xde\xe9\xf4\xff\x0a\x15"
+ "\x20\x2b\x36\x41\x4c\x57\x62\x6d"
+ "\x78\x83\x8e\x99\xa4\xaf\xba\xc5"
+ "\xd0\xdb\xe6\xf1\xfc\x07\x12\x1d"
+ "\x28\x33\x3e\x49\x54\x5f\x6a\x75"
+ "\x80\x8b\x96\xa1\xac\xb7\xc2\xcd"
+ "\xd8\xe3\xee\xf9\x04\x0f\x1a\x25"
+ "\x30\x3b\x46\x51\x5c\x67\x72\x7d"
+ "\x88\x93\x9e\xa9\xb4\xbf\xca\xd5"
+ "\xe0\xeb\xf6\x01\x0c\x17\x22\x2d"
+ "\x38\x43\x4e\x59\x64\x6f\x7a\x85"
+ "\x90\x9b\xa6\xb1\xbc\xc7\xd2\xdd"
+ "\xe8\xf3\xfe\x09\x14\x1f\x2a\x35"
+ "\x40\x4b\x56\x61\x6c\x77\x82\x8d"
+ "\x98\xa3\xae\xb9\xc4\xcf\xda\xe5"
+ "\xf0\xfb\x06\x11\x1c\x27\x32\x3d"
+ "\x48\x53\x5e\x69\x74\x7f\x8a\x95"
+ "\xa0\xab\xb6\xc1\xcc\xd7\xe2\xed"
+ "\xf8\x03\x0e\x19\x24\x2f\x3a\x45"
+ "\x50\x5b\x66\x71\x7c\x87\x92\x9d"
+ "\xa8\xb3\xbe\xc9\xd4\xdf\xea\xf5"
+ "\x00\x0d\x1a\x27\x34\x41\x4e\x5b"
+ "\x68\x75\x82\x8f\x9c\xa9\xb6\xc3"
+ "\xd0\xdd\xea\xf7\x04\x11\x1e\x2b"
+ "\x38\x45\x52\x5f\x6c\x79\x86\x93"
+ "\xa0\xad\xba\xc7\xd4\xe1\xee\xfb"
+ "\x08\x15\x22\x2f\x3c\x49\x56\x63"
+ "\x70\x7d\x8a\x97\xa4\xb1\xbe\xcb"
+ "\xd8\xe5\xf2\xff\x0c\x19\x26\x33"
+ "\x40\x4d\x5a\x67\x74\x81\x8e\x9b"
+ "\xa8\xb5\xc2\xcf\xdc\xe9\xf6\x03"
+ "\x10\x1d\x2a\x37\x44\x51\x5e\x6b"
+ "\x78\x85\x92\x9f\xac\xb9\xc6\xd3"
+ "\xe0\xed\xfa\x07\x14\x21\x2e\x3b"
+ "\x48\x55\x62\x6f\x7c\x89\x96\xa3"
+ "\xb0\xbd\xca\xd7\xe4\xf1\xfe\x0b"
+ "\x18\x25\x32\x3f\x4c\x59\x66\x73"
+ "\x80\x8d\x9a\xa7\xb4\xc1\xce\xdb"
+ "\xe8\xf5\x02\x0f\x1c\x29\x36\x43"
+ "\x50\x5d\x6a\x77\x84\x91\x9e\xab"
+ "\xb8\xc5\xd2\xdf\xec\xf9\x06\x13"
+ "\x20\x2d\x3a\x47\x54\x61\x6e\x7b"
+ "\x88\x95\xa2\xaf\xbc\xc9\xd6\xe3"
+ "\xf0\xfd\x0a\x17\x24\x31\x3e\x4b"
+ "\x58\x65\x72\x7f\x8c\x99\xa6\xb3"
+ "\xc0\xcd\xda\xe7\xf4\x01\x0e\x1b"
+ "\x28\x35\x42\x4f\x5c\x69\x76\x83"
+ "\x90\x9d\xaa\xb7\xc4\xd1\xde\xeb"
+ "\xf8\x05\x12\x1f\x2c\x39\x46\x53"
+ "\x60\x6d\x7a\x87\x94\xa1\xae\xbb"
+ "\xc8\xd5\xe2\xef\xfc\x09\x16\x23"
+ "\x30\x3d\x4a\x57\x64\x71\x7e\x8b"
+ "\x98\xa5\xb2\xbf\xcc\xd9\xe6\xf3"
+ "\x00\x0f\x1e\x2d\x3c\x4b\x5a\x69"
+ "\x78\x87\x96\xa5\xb4\xc3\xd2\xe1"
+ "\xf0\xff\x0e\x1d\x2c\x3b\x4a\x59"
+ "\x68\x77\x86\x95\xa4\xb3\xc2\xd1"
+ "\xe0\xef\xfe\x0d\x1c\x2b\x3a\x49"
+ "\x58\x67\x76\x85\x94\xa3\xb2\xc1"
+ "\xd0\xdf\xee\xfd\x0c\x1b\x2a\x39"
+ "\x48\x57\x66\x75\x84\x93\xa2\xb1"
+ "\xc0\xcf\xde\xed\xfc\x0b\x1a\x29"
+ "\x38\x47\x56\x65\x74\x83\x92\xa1"
+ "\xb0\xbf\xce\xdd\xec\xfb\x0a\x19"
+ "\x28\x37\x46\x55\x64\x73\x82\x91"
+ "\xa0\xaf\xbe\xcd\xdc\xeb\xfa\x09"
+ "\x18\x27\x36\x45\x54\x63\x72\x81"
+ "\x90\x9f\xae\xbd\xcc\xdb\xea\xf9"
+ "\x08\x17\x26\x35\x44\x53\x62\x71"
+ "\x80\x8f\x9e\xad\xbc\xcb\xda\xe9"
+ "\xf8\x07\x16\x25\x34\x43\x52\x61"
+ "\x70\x7f\x8e\x9d\xac\xbb\xca\xd9"
+ "\xe8\xf7\x06\x15\x24\x33\x42\x51"
+ "\x60\x6f\x7e\x8d\x9c\xab\xba\xc9"
+ "\xd8\xe7\xf6\x05\x14\x23\x32\x41"
+ "\x50\x5f\x6e\x7d\x8c\x9b\xaa\xb9"
+ "\xc8\xd7\xe6\xf5\x04\x13\x22\x31"
+ "\x40\x4f\x5e\x6d\x7c\x8b\x9a\xa9"
+ "\xb8\xc7\xd6\xe5\xf4\x03\x12\x21"
+ "\x30\x3f\x4e\x5d\x6c\x7b\x8a\x99"
+ "\xa8\xb7\xc6\xd5\xe4\xf3\x02\x11"
+ "\x20\x2f\x3e\x4d\x5c\x6b\x7a\x89"
+ "\x98\xa7\xb6\xc5\xd4\xe3\xf2\x01"
+ "\x10\x1f\x2e\x3d\x4c\x5b\x6a\x79"
+ "\x88\x97\xa6\xb5\xc4\xd3\xe2\xf1"
+ "\x00\x11\x22\x33\x44\x55\x66\x77"
+ "\x88\x99\xaa\xbb\xcc\xdd\xee\xff"
+ "\x10\x21\x32\x43\x54\x65\x76\x87"
+ "\x98\xa9\xba\xcb\xdc\xed\xfe\x0f"
+ "\x20\x31\x42\x53\x64\x75\x86\x97"
+ "\xa8\xb9\xca\xdb\xec\xfd\x0e\x1f"
+ "\x30\x41\x52\x63\x74\x85\x96\xa7"
+ "\xb8\xc9\xda\xeb\xfc\x0d\x1e\x2f"
+ "\x40\x51\x62\x73\x84\x95\xa6\xb7"
+ "\xc8\xd9\xea\xfb\x0c\x1d\x2e\x3f"
+ "\x50\x61\x72\x83\x94\xa5\xb6\xc7"
+ "\xd8\xe9\xfa\x0b\x1c\x2d\x3e\x4f"
+ "\x60\x71\x82\x93\xa4\xb5\xc6\xd7"
+ "\xe8\xf9\x0a\x1b\x2c\x3d\x4e\x5f"
+ "\x70\x81\x92\xa3\xb4\xc5\xd6\xe7"
+ "\xf8\x09\x1a\x2b\x3c\x4d\x5e\x6f"
+ "\x80\x91\xa2\xb3\xc4\xd5\xe6\xf7"
+ "\x08\x19\x2a\x3b\x4c\x5d\x6e\x7f"
+ "\x90\xa1\xb2\xc3\xd4\xe5\xf6\x07"
+ "\x18\x29\x3a\x4b\x5c\x6d\x7e\x8f"
+ "\xa0\xb1\xc2\xd3\xe4\xf5\x06\x17"
+ "\x28\x39\x4a\x5b\x6c\x7d\x8e\x9f"
+ "\xb0\xc1\xd2\xe3\xf4\x05\x16\x27"
+ "\x38\x49\x5a\x6b\x7c\x8d\x9e\xaf"
+ "\xc0\xd1\xe2\xf3\x04\x15\x26\x37"
+ "\x48\x59\x6a\x7b\x8c\x9d\xae\xbf"
+ "\xd0\xe1\xf2\x03\x14\x25\x36\x47"
+ "\x58\x69\x7a\x8b\x9c\xad\xbe\xcf"
+ "\xe0\xf1\x02\x13\x24\x35\x46\x57"
+ "\x68\x79\x8a\x9b\xac\xbd\xce\xdf"
+ "\xf0\x01\x12\x23\x34\x45\x56\x67"
+ "\x78\x89\x9a\xab\xbc\xcd\xde\xef"
+ "\x00\x13\x26\x39\x4c\x5f\x72\x85"
+ "\x98\xab\xbe\xd1\xe4\xf7\x0a\x1d"
+ "\x30\x43\x56\x69\x7c\x8f\xa2\xb5"
+ "\xc8\xdb\xee\x01\x14\x27\x3a\x4d"
+ "\x60\x73\x86\x99\xac\xbf\xd2\xe5"
+ "\xf8\x0b\x1e\x31\x44\x57\x6a\x7d"
+ "\x90\xa3\xb6\xc9\xdc\xef\x02\x15"
+ "\x28\x3b\x4e\x61\x74\x87\x9a\xad"
+ "\xc0\xd3\xe6\xf9\x0c\x1f\x32\x45"
+ "\x58\x6b\x7e\x91\xa4\xb7\xca\xdd"
+ "\xf0\x03\x16\x29\x3c\x4f\x62\x75"
+ "\x88\x9b\xae\xc1\xd4\xe7\xfa\x0d"
+ "\x20\x33\x46\x59\x6c\x7f\x92\xa5"
+ "\xb8\xcb\xde\xf1\x04\x17\x2a\x3d"
+ "\x50\x63\x76\x89\x9c\xaf\xc2\xd5"
+ "\xe8\xfb\x0e\x21\x34\x47\x5a\x6d"
+ "\x80\x93\xa6\xb9\xcc\xdf\xf2\x05"
+ "\x18\x2b\x3e\x51\x64\x77\x8a\x9d"
+ "\xb0\xc3\xd6\xe9\xfc\x0f\x22\x35"
+ "\x48\x5b\x6e\x81\x94\xa7\xba\xcd"
+ "\xe0\xf3\x06\x19\x2c\x3f\x52\x65"
+ "\x78\x8b\x9e\xb1\xc4\xd7\xea\xfd"
+ "\x10\x23\x36\x49\x5c\x6f\x82\x95"
+ "\xa8\xbb\xce\xe1\xf4\x07\x1a\x2d"
+ "\x40\x53\x66\x79\x8c\x9f\xb2\xc5"
+ "\xd8\xeb\xfe\x11\x24\x37\x4a\x5d"
+ "\x70\x83\x96\xa9\xbc\xcf\xe2\xf5"
+ "\x08\x1b\x2e\x41\x54\x67\x7a\x8d"
+ "\xa0\xb3\xc6\xd9\xec\xff\x12\x25"
+ "\x38\x4b\x5e\x71\x84\x97\xaa\xbd"
+ "\xd0\xe3\xf6\x09\x1c\x2f\x42\x55"
+ "\x68\x7b\x8e\xa1\xb4\xc7\xda\xed"
+ "\x00\x15\x2a\x3f\x54\x69\x7e\x93"
+ "\xa8\xbd\xd2\xe7\xfc\x11\x26\x3b"
+ "\x50\x65\x7a\x8f\xa4\xb9\xce\xe3"
+ "\xf8\x0d\x22\x37\x4c\x61\x76\x8b"
+ "\xa0\xb5\xca\xdf\xf4\x09\x1e\x33"
+ "\x48\x5d\x72\x87\x9c\xb1\xc6\xdb"
+ "\xf0\x05\x1a\x2f\x44\x59\x6e\x83"
+ "\x98\xad\xc2\xd7\xec\x01\x16\x2b"
+ "\x40\x55\x6a\x7f\x94\xa9\xbe\xd3"
+ "\xe8\xfd\x12\x27\x3c\x51\x66\x7b"
+ "\x90\xa5\xba\xcf\xe4\xf9\x0e\x23"
+ "\x38\x4d\x62\x77\x8c\xa1\xb6\xcb"
+ "\xe0\xf5\x0a\x1f\x34\x49\x5e\x73"
+ "\x88\x9d\xb2\xc7\xdc\xf1\x06\x1b"
+ "\x30\x45\x5a\x6f\x84\x99\xae\xc3"
+ "\xd8\xed\x02\x17\x2c\x41\x56\x6b"
+ "\x80\x95\xaa\xbf\xd4\xe9\xfe\x13"
+ "\x28\x3d\x52\x67\x7c\x91\xa6\xbb"
+ "\xd0\xe5\xfa\x0f\x24\x39\x4e\x63"
+ "\x78\x8d\xa2\xb7\xcc\xe1\xf6\x0b"
+ "\x20\x35\x4a\x5f\x74\x89\x9e\xb3"
+ "\xc8\xdd\xf2\x07\x1c\x31\x46\x5b"
+ "\x70\x85\x9a\xaf\xc4\xd9\xee\x03"
+ "\x18\x2d\x42\x57\x6c\x81\x96\xab"
+ "\xc0\xd5\xea\xff\x14\x29\x3e\x53"
+ "\x68\x7d\x92\xa7\xbc\xd1\xe6\xfb"
+ "\x10\x25\x3a\x4f\x64\x79\x8e\xa3"
+ "\xb8\xcd\xe2\xf7\x0c\x21\x36\x4b"
+ "\x60\x75\x8a\x9f\xb4\xc9\xde\xf3"
+ "\x08\x1d\x32\x47\x5c\x71\x86\x9b"
+ "\xb0\xc5\xda\xef\x04\x19\x2e\x43"
+ "\x58\x6d\x82\x97\xac\xc1\xd6\xeb"
+ "\x00\x17\x2e\x45\x5c\x73\x8a\xa1"
+ "\xb8\xcf\xe6\xfd\x14\x2b\x42\x59"
+ "\x70\x87\x9e\xb5\xcc\xe3\xfa\x11"
+ "\x28\x3f\x56\x6d\x84\x9b\xb2\xc9"
+ "\xe0\xf7\x0e\x25\x3c\x53\x6a\x81"
+ "\x98\xaf\xc6\xdd\xf4\x0b\x22\x39"
+ "\x50\x67\x7e\x95\xac\xc3\xda\xf1"
+ "\x08\x1f\x36\x4d\x64\x7b\x92\xa9"
+ "\xc0\xd7\xee\x05\x1c\x33\x4a\x61"
+ "\x78\x8f\xa6\xbd\xd4\xeb\x02\x19"
+ "\x30\x47\x5e\x75\x8c\xa3\xba\xd1"
+ "\xe8\xff\x16\x2d\x44\x5b\x72\x89"
+ "\xa0\xb7\xce\xe5\xfc\x13\x2a\x41"
+ "\x58\x6f\x86\x9d\xb4\xcb\xe2\xf9"
+ "\x10\x27\x3e\x55\x6c\x83\x9a\xb1"
+ "\xc8\xdf\xf6\x0d\x24\x3b\x52\x69"
+ "\x80\x97\xae\xc5\xdc\xf3\x0a\x21"
+ "\x38\x4f\x66\x7d\x94\xab\xc2\xd9"
+ "\xf0\x07\x1e\x35\x4c\x63\x7a\x91"
+ "\xa8\xbf\xd6\xed\x04\x1b\x32\x49"
+ "\x60\x77\x8e\xa5\xbc\xd3\xea\x01"
+ "\x18\x2f\x46\x5d\x74\x8b\xa2\xb9"
+ "\xd0\xe7\xfe\x15\x2c\x43\x5a\x71"
+ "\x88\x9f\xb6\xcd\xe4\xfb\x12\x29"
+ "\x40\x57\x6e\x85\x9c\xb3\xca\xe1"
+ "\xf8\x0f\x26\x3d\x54\x6b\x82\x99"
+ "\xb0\xc7\xde\xf5\x0c\x23\x3a\x51"
+ "\x68\x7f\x96\xad\xc4\xdb\xf2\x09"
+ "\x20\x37\x4e\x65\x7c\x93\xaa\xc1"
+ "\xd8\xef\x06\x1d\x34\x4b\x62\x79"
+ "\x90\xa7\xbe\xd5\xec\x03\x1a\x31"
+ "\x48\x5f\x76\x8d\xa4\xbb\xd2\xe9"
+ "\x00\x19\x32\x4b\x64\x7d\x96\xaf"
+ "\xc8\xe1\xfa\x13\x2c\x45\x5e\x77"
+ "\x90\xa9\xc2\xdb\xf4\x0d\x26\x3f"
+ "\x58\x71\x8a\xa3\xbc\xd5\xee\x07"
+ "\x20\x39\x52\x6b\x84\x9d\xb6\xcf"
+ "\xe8\x01\x1a\x33\x4c\x65\x7e\x97"
+ "\xb0\xc9\xe2\xfb\x14\x2d\x46\x5f"
+ "\x78\x91\xaa\xc3\xdc\xf5\x0e\x27"
+ "\x40\x59\x72\x8b\xa4\xbd\xd6\xef"
+ "\x08\x21\x3a\x53\x6c\x85\x9e\xb7"
+ "\xd0\xe9\x02\x1b\x34\x4d\x66\x7f"
+ "\x98\xb1\xca\xe3\xfc\x15\x2e\x47"
+ "\x60\x79\x92\xab\xc4\xdd\xf6\x0f"
+ "\x28\x41\x5a\x73\x8c\xa5\xbe\xd7"
+ "\xf0\x09\x22\x3b\x54\x6d\x86\x9f"
+ "\xb8\xd1\xea\x03\x1c\x35\x4e\x67"
+ "\x80\x99\xb2\xcb\xe4\xfd\x16\x2f"
+ "\x48\x61\x7a\x93\xac\xc5\xde\xf7"
+ "\x10\x29\x42\x5b\x74\x8d\xa6\xbf"
+ "\xd8\xf1\x0a\x23\x3c\x55\x6e\x87"
+ "\xa0\xb9\xd2\xeb\x04\x1d\x36\x4f"
+ "\x68\x81\x9a\xb3\xcc\xe5\xfe\x17"
+ "\x30\x49\x62\x7b\x94\xad\xc6\xdf"
+ "\xf8\x11\x2a\x43\x5c\x75\x8e\xa7"
+ "\xc0\xd9\xf2\x0b\x24\x3d\x56\x6f"
+ "\x88\xa1\xba\xd3\xec\x05\x1e\x37"
+ "\x50\x69\x82\x9b\xb4\xcd\xe6\xff"
+ "\x18\x31\x4a\x63\x7c\x95\xae\xc7"
+ "\xe0\xf9\x12\x2b\x44\x5d\x76\x8f"
+ "\xa8\xc1\xda\xf3\x0c\x25\x3e\x57"
+ "\x70\x89\xa2\xbb\xd4\xed\x06\x1f"
+ "\x38\x51\x6a\x83\x9c\xb5\xce\xe7"
+ "\x00\x1b\x36\x51\x6c\x87\xa2\xbd"
+ "\xd8\xf3\x0e\x29\x44\x5f\x7a\x95"
+ "\xb0\xcb\xe6\x01\x1c\x37\x52\x6d"
+ "\x88\xa3\xbe\xd9\xf4\x0f\x2a\x45"
+ "\x60\x7b\x96\xb1\xcc\xe7\x02\x1d"
+ "\x38\x53\x6e\x89\xa4\xbf\xda\xf5"
+ "\x10\x2b\x46\x61\x7c\x97\xb2\xcd"
+ "\xe8\x03\x1e\x39\x54\x6f\x8a\xa5"
+ "\xc0\xdb\xf6\x11\x2c\x47\x62\x7d"
+ "\x98\xb3\xce\xe9\x04\x1f\x3a\x55"
+ "\x70\x8b\xa6\xc1\xdc\xf7\x12\x2d"
+ "\x48\x63\x7e\x99\xb4\xcf\xea\x05"
+ "\x20\x3b\x56\x71\x8c\xa7\xc2\xdd"
+ "\xf8\x13\x2e\x49\x64\x7f\x9a\xb5"
+ "\xd0\xeb\x06\x21\x3c\x57\x72\x8d"
+ "\xa8\xc3\xde\xf9\x14\x2f\x4a\x65"
+ "\x80\x9b\xb6\xd1\xec\x07\x22\x3d"
+ "\x58\x73\x8e\xa9\xc4\xdf\xfa\x15"
+ "\x30\x4b\x66\x81\x9c\xb7\xd2\xed"
+ "\x08\x23\x3e\x59\x74\x8f\xaa\xc5"
+ "\xe0\xfb\x16\x31\x4c\x67\x82\x9d"
+ "\xb8\xd3\xee\x09\x24\x3f\x5a\x75"
+ "\x90\xab\xc6\xe1\xfc\x17\x32\x4d"
+ "\x68\x83\x9e\xb9\xd4\xef\x0a\x25"
+ "\x40\x5b\x76\x91\xac\xc7\xe2\xfd"
+ "\x18\x33\x4e\x69\x84\x9f\xba\xd5"
+ "\xf0\x0b\x26\x41\x5c\x77\x92\xad"
+ "\xc8\xe3\xfe\x19\x34\x4f\x6a\x85"
+ "\xa0\xbb\xd6\xf1\x0c\x27\x42\x5d"
+ "\x78\x93\xae\xc9\xe4\xff\x1a\x35"
+ "\x50\x6b\x86\xa1\xbc\xd7\xf2\x0d"
+ "\x28\x43\x5e\x79\x94\xaf\xca\xe5"
+ "\x00\x1d\x3a\x57\x74\x91\xae\xcb"
+ "\xe8\x05\x22\x3f\x5c\x79\x96\xb3"
+ "\xd0\xed\x0a\x27\x44\x61\x7e\x9b"
+ "\xb8\xd5\xf2\x0f\x2c\x49\x66\x83"
+ "\xa0\xbd\xda\xf7\x14\x31\x4e\x6b"
+ "\x88\xa5\xc2\xdf\xfc\x19\x36\x53"
+ "\x70\x8d\xaa\xc7\xe4\x01\x1e\x3b"
+ "\x58\x75\x92\xaf\xcc\xe9\x06\x23"
+ "\x40\x5d\x7a\x97\xb4\xd1\xee\x0b"
+ "\x28\x45\x62\x7f\x9c\xb9\xd6\xf3"
+ "\x10\x2d\x4a\x67\x84\xa1\xbe\xdb"
+ "\xf8\x15\x32\x4f\x6c\x89\xa6\xc3"
+ "\xe0\xfd\x1a\x37\x54\x71\x8e\xab"
+ "\xc8\xe5\x02\x1f\x3c\x59\x76\x93"
+ "\xb0\xcd\xea\x07\x24\x41\x5e\x7b"
+ "\x98\xb5\xd2\xef\x0c\x29\x46\x63"
+ "\x80\x9d\xba\xd7\xf4\x11\x2e\x4b"
+ "\x68\x85\xa2\xbf\xdc\xf9\x16\x33"
+ "\x50\x6d\x8a\xa7\xc4\xe1\xfe\x1b"
+ "\x38\x55\x72\x8f\xac\xc9\xe6\x03"
+ "\x20\x3d\x5a\x77\x94\xb1\xce\xeb"
+ "\x08\x25\x42\x5f\x7c\x99\xb6\xd3"
+ "\xf0\x0d\x2a\x47\x64\x81\x9e\xbb"
+ "\xd8\xf5\x12\x2f\x4c\x69\x86\xa3"
+ "\xc0\xdd\xfa\x17\x34\x51\x6e\x8b"
+ "\xa8\xc5\xe2\xff\x1c\x39\x56\x73"
+ "\x90\xad\xca\xe7\x04\x21\x3e\x5b"
+ "\x78\x95\xb2\xcf\xec\x09\x26\x43"
+ "\x60\x7d\x9a\xb7\xd4\xf1\x0e\x2b"
+ "\x48\x65\x82\x9f\xbc\xd9\xf6\x13"
+ "\x30\x4d\x6a\x87\xa4\xc1\xde\xfb"
+ "\x18\x35\x52\x6f\x8c\xa9\xc6\xe3"
+ "\x00\x1f\x3e\x5d\x7c\x9b\xba\xd9"
+ "\xf8\x17\x36\x55\x74\x93\xb2\xd1"
+ "\xf0\x0f\x2e\x4d\x6c\x8b\xaa\xc9"
+ "\xe8\x07\x26\x45\x64\x83\xa2\xc1"
+ "\xe0\xff\x1e\x3d\x5c\x7b\x9a\xb9"
+ "\xd8\xf7\x16\x35\x54\x73\x92\xb1"
+ "\xd0\xef\x0e\x2d\x4c\x6b\x8a\xa9"
+ "\xc8\xe7\x06\x25\x44\x63\x82\xa1"
+ "\xc0\xdf\xfe\x1d\x3c\x5b\x7a\x99"
+ "\xb8\xd7\xf6\x15\x34\x53\x72\x91"
+ "\xb0\xcf\xee\x0d\x2c\x4b\x6a\x89"
+ "\xa8\xc7\xe6\x05\x24\x43\x62\x81"
+ "\xa0\xbf\xde\xfd\x1c\x3b\x5a\x79"
+ "\x98\xb7\xd6\xf5\x14\x33\x52\x71"
+ "\x90\xaf\xce\xed\x0c\x2b\x4a\x69"
+ "\x88\xa7\xc6\xe5\x04\x23\x42\x61"
+ "\x80\x9f\xbe\xdd\xfc\x1b\x3a\x59"
+ "\x78\x97\xb6\xd5\xf4\x13\x32\x51"
+ "\x70\x8f\xae\xcd\xec\x0b\x2a\x49"
+ "\x68\x87\xa6\xc5\xe4\x03\x22\x41"
+ "\x60\x7f\x9e\xbd\xdc\xfb\x1a\x39"
+ "\x58\x77\x96\xb5\xd4\xf3\x12\x31"
+ "\x50\x6f\x8e\xad\xcc\xeb\x0a\x29"
+ "\x48\x67\x86\xa5\xc4\xe3\x02\x21"
+ "\x40\x5f\x7e\x9d\xbc\xdb\xfa\x19"
+ "\x38\x57\x76\x95\xb4\xd3\xf2\x11"
+ "\x30\x4f\x6e\x8d\xac\xcb\xea\x09"
+ "\x28\x47\x66\x85\xa4\xc3\xe2\x01"
+ "\x20\x3f\x5e\x7d\x9c\xbb\xda\xf9"
+ "\x18\x37\x56\x75\x94\xb3\xd2\xf1"
+ "\x10\x2f\x4e\x6d\x8c\xab\xca\xe9"
+ "\x08\x27\x46\x65\x84\xa3\xc2\xe1"
+ "\x00\x21\x42\x63",
+ .ilen = 4100,
+ .result =
+ "\xb5\x81\xf5\x64\x18\x73\xe3\xf0"
+ "\x4c\x13\xf2\x77\x18\x60\x65\x5e"
+ "\x29\x01\xce\x98\x55\x53\xf9\x0c"
+ "\x2a\x08\xd5\x09\xb3\x57\x55\x56"
+ "\xc5\xe9\x56\x90\xcb\x6a\xa3\xc0"
+ "\xff\xc4\x79\xb4\xd2\x97\x5d\xc4"
+ "\x43\xd1\xfe\x94\x7b\x88\x06\x5a"
+ "\xb2\x9e\x2c\xfc\x44\x03\xb7\x90"
+ "\xa0\xc1\xba\x6a\x33\xb8\xc7\xb2"
+ "\x9d\xe1\x12\x4f\xc0\x64\xd4\x01"
+ "\xfe\x8c\x7a\x66\xf7\xe6\x5a\x91"
+ "\xbb\xde\x56\x86\xab\x65\x21\x30"
+ "\x00\x84\x65\x24\xa5\x7d\x85\xb4"
+ "\xe3\x17\xed\x3a\xb7\x6f\xb4\x0b"
+ "\x0b\xaf\x15\xae\x5a\x8f\xf2\x0c"
+ "\x2f\x27\xf4\x09\xd8\xd2\x96\xb7"
+ "\x71\xf2\xc5\x99\x4d\x7e\x7f\x75"
+ "\x77\x89\x30\x8b\x59\xdb\xa2\xb2"
+ "\xa0\xf3\x19\x39\x2b\xc5\x7e\x3f"
+ "\x4f\xd9\xd3\x56\x28\x97\x44\xdc"
+ "\xc0\x8b\x77\x24\xd9\x52\xe7\xc5"
+ "\xaf\xf6\x7d\x59\xb2\x44\x05\x1d"
+ "\xb1\xb0\x11\xa5\x0f\xec\x33\xe1"
+ "\x6d\x1b\x4e\x1f\xff\x57\x91\xb4"
+ "\x5b\x9a\x96\xc5\x53\xbc\xae\x20"
+ "\x3c\xbb\x14\xe2\xe8\x22\x33\xc1"
+ "\x5e\x76\x9e\x46\x99\xf6\x2a\x15"
+ "\xc6\x97\x02\xa0\x66\x43\xd1\xa6"
+ "\x31\xa6\x9f\xfb\xf4\xd3\x69\xe5"
+ "\xcd\x76\x95\xb8\x7a\x82\x7f\x21"
+ "\x45\xff\x3f\xce\x55\xf6\x95\x10"
+ "\x08\x77\x10\x43\xc6\xf3\x09\xe5"
+ "\x68\xe7\x3c\xad\x00\x52\x45\x0d"
+ "\xfe\x2d\xc6\xc2\x94\x8c\x12\x1d"
+ "\xe6\x25\xae\x98\x12\x8e\x19\x9c"
+ "\x81\x68\xb1\x11\xf6\x69\xda\xe3"
+ "\x62\x08\x18\x7a\x25\x49\x28\xac"
+ "\xba\x71\x12\x0b\xe4\xa2\xe5\xc7"
+ "\x5d\x8e\xec\x49\x40\x21\xbf\x5a"
+ "\x98\xf3\x02\x68\x55\x03\x7f\x8a"
+ "\xe5\x94\x0c\x32\x5c\x07\x82\x63"
+ "\xaf\x6f\x91\x40\x84\x8e\x52\x25"
+ "\xd0\xb0\x29\x53\x05\xe2\x50\x7a"
+ "\x34\xeb\xc9\x46\x20\xa8\x3d\xde"
+ "\x7f\x16\x5f\x36\xc5\x2e\xdc\xd1"
+ "\x15\x47\xc7\x50\x40\x6d\x91\xc5"
+ "\xe7\x93\x95\x1a\xd3\x57\xbc\x52"
+ "\x33\xee\x14\x19\x22\x52\x89\xa7"
+ "\x4a\x25\x56\x77\x4b\xca\xcf\x0a"
+ "\xe1\xf5\x35\x85\x30\x7e\x59\x4a"
+ "\xbd\x14\x5b\xdf\xe3\x46\xcb\xac"
+ "\x1f\x6c\x96\x0e\xf4\x81\xd1\x99"
+ "\xca\x88\x63\x3d\x02\x58\x6b\xa9"
+ "\xe5\x9f\xb3\x00\xb2\x54\xc6\x74"
+ "\x1c\xbf\x46\xab\x97\xcc\xf8\x54"
+ "\x04\x07\x08\x52\xe6\xc0\xda\x93"
+ "\x74\x7d\x93\x99\x5d\x78\x68\xa6"
+ "\x2e\x6b\xd3\x6a\x69\xcc\x12\x6b"
+ "\xd4\xc7\xa5\xc6\xe7\xf6\x03\x04"
+ "\x5d\xcd\x61\x5e\x17\x40\xdc\xd1"
+ "\x5c\xf5\x08\xdf\x5c\x90\x85\xa4"
+ "\xaf\xf6\x78\xbb\x0d\xf1\xf4\xa4"
+ "\x54\x26\x72\x9e\x61\xfa\x86\xcf"
+ "\xe8\x9e\xa1\xe0\xc7\x48\x23\xae"
+ "\x5a\x90\xae\x75\x0a\x74\x18\x89"
+ "\x05\xb1\x92\xb2\x7f\xd0\x1b\xa6"
+ "\x62\x07\x25\x01\xc7\xc2\x4f\xf9"
+ "\xe8\xfe\x63\x95\x80\x07\xb4\x26"
+ "\xcc\xd1\x26\xb6\xc4\x3f\x9e\xcb"
+ "\x8e\x3b\x2e\x44\x16\xd3\x10\x9a"
+ "\x95\x08\xeb\xc8\xcb\xeb\xbf\x6f"
+ "\x0b\xcd\x1f\xc8\xca\x86\xaa\xec"
+ "\x33\xe6\x69\xf4\x45\x25\x86\x3a"
+ "\x22\x94\x4f\x00\x23\x6a\x44\xc2"
+ "\x49\x97\x33\xab\x36\x14\x0a\x70"
+ "\x24\xc3\xbe\x04\x3b\x79\xa0\xf9"
+ "\xb8\xe7\x76\x29\x22\x83\xd7\xf2"
+ "\x94\xf4\x41\x49\xba\x5f\x7b\x07"
+ "\xb5\xfb\xdb\x03\x1a\x9f\xb6\x4c"
+ "\xc2\x2e\x37\x40\x49\xc3\x38\x16"
+ "\xe2\x4f\x77\x82\xb0\x68\x4c\x71"
+ "\x1d\x57\x61\x9c\xd9\x4e\x54\x99"
+ "\x47\x13\x28\x73\x3c\xbb\x00\x90"
+ "\xf3\x4d\xc9\x0e\xfd\xe7\xb1\x71"
+ "\xd3\x15\x79\xbf\xcc\x26\x2f\xbd"
+ "\xad\x6c\x50\x69\x6c\x3e\x6d\x80"
+ "\x9a\xea\x78\xaf\x19\xb2\x0d\x4d"
+ "\xad\x04\x07\xae\x22\x90\x4a\x93"
+ "\x32\x0e\x36\x9b\x1b\x46\xba\x3b"
+ "\xb4\xac\xc6\xd1\xa2\x31\x53\x3b"
+ "\x2a\x3d\x45\xfe\x03\x61\x10\x85"
+ "\x17\x69\xa6\x78\xcc\x6c\x87\x49"
+ "\x53\xf9\x80\x10\xde\x80\xa2\x41"
+ "\x6a\xc3\x32\x02\xad\x6d\x3c\x56"
+ "\x00\x71\x51\x06\xa7\xbd\xfb\xef"
+ "\x3c\xb5\x9f\xfc\x48\x7d\x53\x7c"
+ "\x66\xb0\x49\x23\xc4\x47\x10\x0e"
+ "\xe5\x6c\x74\x13\xe6\xc5\x3f\xaa"
+ "\xde\xff\x07\x44\xdd\x56\x1b\xad"
+ "\x09\x77\xfb\x5b\x12\xb8\x0d\x38"
+ "\x17\x37\x35\x7b\x9b\xbc\xfe\xd4"
+ "\x7e\x8b\xda\x7e\x5b\x04\xa7\x22"
+ "\xa7\x31\xa1\x20\x86\xc7\x1b\x99"
+ "\xdb\xd1\x89\xf4\x94\xa3\x53\x69"
+ "\x8d\xe7\xe8\x74\x11\x8d\x74\xd6"
+ "\x07\x37\x91\x9f\xfd\x67\x50\x3a"
+ "\xc9\xe1\xf4\x36\xd5\xa0\x47\xd1"
+ "\xf9\xe5\x39\xa3\x31\xac\x07\x36"
+ "\x23\xf8\x66\x18\x14\x28\x34\x0f"
+ "\xb8\xd0\xe7\x29\xb3\x04\x4b\x55"
+ "\x01\x41\xb2\x75\x8d\xcb\x96\x85"
+ "\x3a\xfb\xab\x2b\x9e\xfa\x58\x20"
+ "\x44\x1f\xc0\x14\x22\x75\x61\xe8"
+ "\xaa\x19\xcf\xf1\x82\x56\xf4\xd7"
+ "\x78\x7b\x3d\x5f\xb3\x9e\x0b\x8a"
+ "\x57\x50\xdb\x17\x41\x65\x4d\xa3"
+ "\x02\xc9\x9c\x9c\x53\xfb\x39\x39"
+ "\x9b\x1d\x72\x24\xda\xb7\x39\xbe"
+ "\x13\x3b\xfa\x29\xda\x9e\x54\x64"
+ "\x6e\xba\xd8\xa1\xcb\xb3\x36\xfa"
+ "\xcb\x47\x85\xe9\x61\x38\xbc\xbe"
+ "\xc5\x00\x38\x2a\x54\xf7\xc4\xb9"
+ "\xb3\xd3\x7b\xa0\xa0\xf8\x72\x7f"
+ "\x8c\x8e\x82\x0e\xc6\x1c\x75\x9d"
+ "\xca\x8e\x61\x87\xde\xad\x80\xd2"
+ "\xf5\xf9\x80\xef\x15\x75\xaf\xf5"
+ "\x80\xfb\xff\x6d\x1e\x25\xb7\x40"
+ "\x61\x6a\x39\x5a\x6a\xb5\x31\xab"
+ "\x97\x8a\x19\x89\x44\x40\xc0\xa6"
+ "\xb4\x4e\x30\x32\x7b\x13\xe7\x67"
+ "\xa9\x8b\x57\x04\xc2\x01\xa6\xf4"
+ "\x28\x99\xad\x2c\x76\xa3\x78\xc2"
+ "\x4a\xe6\xca\x5c\x50\x6a\xc1\xb0"
+ "\x62\x4b\x10\x8e\x7c\x17\x43\xb3"
+ "\x17\x66\x1c\x3e\x8d\x69\xf0\x5a"
+ "\x71\xf5\x97\xdc\xd1\x45\xdd\x28"
+ "\xf3\x5d\xdf\x53\x7b\x11\xe5\xbc"
+ "\x4c\xdb\x1b\x51\x6b\xe9\xfb\x3d"
+ "\xc1\xc3\x2c\xb9\x71\xf5\xb6\xb2"
+ "\x13\x36\x79\x80\x53\xe8\xd3\xa6"
+ "\x0a\xaf\xfd\x56\x97\xf7\x40\x8e"
+ "\x45\xce\xf8\xb0\x9e\x5c\x33\x82"
+ "\xb0\x44\x56\xfc\x05\x09\xe9\x2a"
+ "\xac\x26\x80\x14\x1d\xc8\x3a\x35"
+ "\x4c\x82\x97\xfd\x76\xb7\xa9\x0a"
+ "\x35\x58\x79\x8e\x0f\x66\xea\xaf"
+ "\x51\x6c\x09\xa9\x6e\x9b\xcb\x9a"
+ "\x31\x47\xa0\x2f\x7c\x71\xb4\x4a"
+ "\x11\xaa\x8c\x66\xc5\x64\xe6\x3a"
+ "\x54\xda\x24\x6a\xc4\x41\x65\x46"
+ "\x82\xa0\x0a\x0f\x5f\xfb\x25\xd0"
+ "\x2c\x91\xa7\xee\xc4\x81\x07\x86"
+ "\x75\x5e\x33\x69\x97\xe4\x2c\xa8"
+ "\x9d\x9f\x0b\x6a\xbe\xad\x98\xda"
+ "\x6d\x94\x41\xda\x2c\x1e\x89\xc4"
+ "\xc2\xaf\x1e\x00\x05\x0b\x83\x60"
+ "\xbd\x43\xea\x15\x23\x7f\xb9\xac"
+ "\xee\x4f\x2c\xaf\x2a\xf3\xdf\xd0"
+ "\xf3\x19\x31\xbb\x4a\x74\x84\x17"
+ "\x52\x32\x2c\x7d\x61\xe4\xcb\xeb"
+ "\x80\x38\x15\x52\xcb\x6f\xea\xe5"
+ "\x73\x9c\xd9\x24\x69\xc6\x95\x32"
+ "\x21\xc8\x11\xe4\xdc\x36\xd7\x93"
+ "\x38\x66\xfb\xb2\x7f\x3a\xb9\xaf"
+ "\x31\xdd\x93\x75\x78\x8a\x2c\x94"
+ "\x87\x1a\x58\xec\x9e\x7d\x4d\xba"
+ "\xe1\xe5\x4d\xfc\xbc\xa4\x2a\x14"
+ "\xef\xcc\xa7\xec\xab\x43\x09\x18"
+ "\xd3\xab\x68\xd1\x07\x99\x44\x47"
+ "\xd6\x83\x85\x3b\x30\xea\xa9\x6b"
+ "\x63\xea\xc4\x07\xfb\x43\x2f\xa4"
+ "\xaa\xb0\xab\x03\x89\xce\x3f\x8c"
+ "\x02\x7c\x86\x54\xbc\x88\xaf\x75"
+ "\xd2\xdc\x63\x17\xd3\x26\xf6\x96"
+ "\xa9\x3c\xf1\x61\x8c\x11\x18\xcc"
+ "\xd6\xea\x5b\xe2\xcd\xf0\xf1\xb2"
+ "\xe5\x35\x90\x1f\x85\x4c\x76\x5b"
+ "\x66\xce\x44\xa4\x32\x9f\xe6\x7b"
+ "\x71\x6e\x9f\x58\x15\x67\x72\x87"
+ "\x64\x8e\x3a\x44\x45\xd4\x76\xfa"
+ "\xc2\xf6\xef\x85\x05\x18\x7a\x9b"
+ "\xba\x41\x54\xac\xf0\xfc\x59\x12"
+ "\x3f\xdf\xa0\xe5\x8a\x65\xfd\x3a"
+ "\x62\x8d\x83\x2c\x03\xbe\x05\x76"
+ "\x2e\x53\x49\x97\x94\x33\xae\x40"
+ "\x81\x15\xdb\x6e\xad\xaa\xf5\x4b"
+ "\xe3\x98\x70\xdf\xe0\x7c\xcd\xdb"
+ "\x02\xd4\x7d\x2f\xc1\xe6\xb4\xf3"
+ "\xd7\x0d\x7a\xd9\x23\x9e\x87\x2d"
+ "\xce\x87\xad\xcc\x72\x05\x00\x29"
+ "\xdc\x73\x7f\x64\xc1\x15\x0e\xc2"
+ "\xdf\xa7\x5f\xeb\x41\xa1\xcd\xef"
+ "\x5c\x50\x79\x2a\x56\x56\x71\x8c"
+ "\xac\xc0\x79\x50\x69\xca\x59\x32"
+ "\x65\xf2\x54\xe4\x52\x38\x76\xd1"
+ "\x5e\xde\x26\x9e\xfb\x75\x2e\x11"
+ "\xb5\x10\xf4\x17\x73\xf5\x89\xc7"
+ "\x4f\x43\x5c\x8e\x7c\xb9\x05\x52"
+ "\x24\x40\x99\xfe\x9b\x85\x0b\x6c"
+ "\x22\x3e\x8b\xae\x86\xa1\xd2\x79"
+ "\x05\x68\x6b\xab\xe3\x41\x49\xed"
+ "\x15\xa1\x8d\x40\x2d\x61\xdf\x1a"
+ "\x59\xc9\x26\x8b\xef\x30\x4c\x88"
+ "\x4b\x10\xf8\x8d\xa6\x92\x9f\x4b"
+ "\xf3\xc4\x53\x0b\x89\x5d\x28\x92"
+ "\xcf\x78\xb2\xc0\x5d\xed\x7e\xfc"
+ "\xc0\x12\x23\x5f\x5a\x78\x86\x43"
+ "\x6e\x27\xf7\x5a\xa7\x6a\xed\x19"
+ "\x04\xf0\xb3\x12\xd1\xbd\x0e\x89"
+ "\x6e\xbc\x96\xa8\xd8\x49\x39\x9f"
+ "\x7e\x67\xf0\x2e\x3e\x01\xa9\xba"
+ "\xec\x8b\x62\x8e\xcb\x4a\x70\x43"
+ "\xc7\xc2\xc4\xca\x82\x03\x73\xe9"
+ "\x11\xdf\xcf\x54\xea\xc9\xb0\x95"
+ "\x51\xc0\x13\x3d\x92\x05\xfa\xf4"
+ "\xa9\x34\xc8\xce\x6c\x3d\x54\xcc"
+ "\xc4\xaf\xf1\xdc\x11\x44\x26\xa2"
+ "\xaf\xf1\x85\x75\x7d\x03\x61\x68"
+ "\x4e\x78\xc6\x92\x7d\x86\x7d\x77"
+ "\xdc\x71\x72\xdb\xc6\xae\xa1\xcb"
+ "\x70\x9a\x0b\x19\xbe\x4a\x6c\x2a"
+ "\xe2\xba\x6c\x64\x9a\x13\x28\xdf"
+ "\x85\x75\xe6\x43\xf6\x87\x08\x68"
+ "\x6e\xba\x6e\x79\x9f\x04\xbc\x23"
+ "\x50\xf6\x33\x5c\x1f\x24\x25\xbe"
+ "\x33\x47\x80\x45\x56\xa3\xa7\xd7"
+ "\x7a\xb1\x34\x0b\x90\x3c\x9c\xad"
+ "\x44\x5f\x9e\x0e\x9d\xd4\xbd\x93"
+ "\x5e\xfa\x3c\xe0\xb0\xd9\xed\xf3"
+ "\xd6\x2e\xff\x24\xd8\x71\x6c\xed"
+ "\xaf\x55\xeb\x22\xac\x93\x68\x32"
+ "\x05\x5b\x47\xdd\xc6\x4a\xcb\xc7"
+ "\x10\xe1\x3c\x92\x1a\xf3\x23\x78"
+ "\x2b\xa1\xd2\x80\xf4\x12\xb1\x20"
+ "\x8f\xff\x26\x35\xdd\xfb\xc7\x4e"
+ "\x78\xf1\x2d\x50\x12\x77\xa8\x60"
+ "\x7c\x0f\xf5\x16\x2f\x63\x70\x2a"
+ "\xc0\x96\x80\x4e\x0a\xb4\x93\x35"
+ "\x5d\x1d\x3f\x56\xf7\x2f\xbb\x90"
+ "\x11\x16\x8f\xa2\xec\x47\xbe\xac"
+ "\x56\x01\x26\x56\xb1\x8c\xb2\x10"
+ "\xf9\x1a\xca\xf5\xd1\xb7\x39\x20"
+ "\x63\xf1\x69\x20\x4f\x13\x12\x1f"
+ "\x5b\x65\xfc\x98\xf7\xc4\x7a\xbe"
+ "\xf7\x26\x4d\x2b\x84\x7b\x42\xad"
+ "\xd8\x7a\x0a\xb4\xd8\x74\xbf\xc1"
+ "\xf0\x6e\xb4\x29\xa3\xbb\xca\x46"
+ "\x67\x70\x6a\x2d\xce\x0e\xa2\x8a"
+ "\xa9\x87\xbf\x05\xc4\xc1\x04\xa3"
+ "\xab\xd4\x45\x43\x8c\xb6\x02\xb0"
+ "\x41\xc8\xfc\x44\x3d\x59\xaa\x2e"
+ "\x44\x21\x2a\x8d\x88\x9d\x57\xf4"
+ "\xa0\x02\x77\xb8\xa6\xa0\xe6\x75"
+ "\x5c\x82\x65\x3e\x03\x5c\x29\x8f"
+ "\x38\x55\xab\x33\x26\xef\x9f\x43"
+ "\x52\xfd\x68\xaf\x36\xb4\xbb\x9a"
+ "\x58\x09\x09\x1b\xc3\x65\x46\x46"
+ "\x1d\xa7\x94\x18\x23\x50\x2c\xca"
+ "\x2c\x55\x19\x97\x01\x9d\x93\x3b"
+ "\x63\x86\xf2\x03\x67\x45\xd2\x72"
+ "\x28\x52\x6c\xf4\xe3\x1c\xb5\x11"
+ "\x13\xf1\xeb\x21\xc7\xd9\x56\x82"
+ "\x2b\x82\x39\xbd\x69\x54\xed\x62"
+ "\xc3\xe2\xde\x73\xd4\x6a\x12\xae"
+ "\x13\x21\x7f\x4b\x5b\xfc\xbf\xe8"
+ "\x2b\xbe\x56\xba\x68\x8b\x9a\xb1"
+ "\x6e\xfa\xbf\x7e\x5a\x4b\xf1\xac"
+ "\x98\x65\x85\xd1\x93\x53\xd3\x7b"
+ "\x09\xdd\x4b\x10\x6d\x84\xb0\x13"
+ "\x65\xbd\xcf\x52\x09\xc4\x85\xe2"
+ "\x84\x74\x15\x65\xb7\xf7\x51\xaf"
+ "\x55\xad\xa4\xd1\x22\x54\x70\x94"
+ "\xa0\x1c\x90\x41\xfd\x99\xd7\x5a"
+ "\x31\xef\xaa\x25\xd0\x7f\x4f\xea"
+ "\x1d\x55\x42\xe5\x49\xb0\xd0\x46"
+ "\x62\x36\x43\xb2\x82\x15\x75\x50"
+ "\xa4\x72\xeb\x54\x27\x1f\x8a\xe4"
+ "\x7d\xe9\x66\xc5\xf1\x53\xa4\xd1"
+ "\x0c\xeb\xb8\xf8\xbc\xd4\xe2\xe7"
+ "\xe1\xf8\x4b\xcb\xa9\xa1\xaf\x15"
+ "\x83\xcb\x72\xd0\x33\x79\x00\x2d"
+ "\x9f\xd7\xf1\x2e\x1e\x10\xe4\x45"
+ "\xc0\x75\x3a\x39\xea\x68\xf7\x5d"
+ "\x1b\x73\x8f\xe9\x8e\x0f\x72\x47"
+ "\xae\x35\x0a\x31\x7a\x14\x4d\x4a"
+ "\x6f\x47\xf7\x7e\x91\x6e\x74\x8b"
+ "\x26\x47\xf9\xc3\xf9\xde\x70\xf5"
+ "\x61\xab\xa9\x27\x9f\x82\xe4\x9c"
+ "\x89\x91\x3f\x2e\x6a\xfd\xb5\x49"
+ "\xe9\xfd\x59\x14\x36\x49\x40\x6d"
+ "\x32\xd8\x85\x42\xf3\xa5\xdf\x0c"
+ "\xa8\x27\xd7\x54\xe2\x63\x2f\xf2"
+ "\x7e\x8b\x8b\xe7\xf1\x9a\x95\x35"
+ "\x43\xdc\x3a\xe4\xb6\xf4\xd0\xdf"
+ "\x9c\xcb\x94\xf3\x21\xa0\x77\x50"
+ "\xe2\xc6\xc4\xc6\x5f\x09\x64\x5b"
+ "\x92\x90\xd8\xe1\xd1\xed\x4b\x42"
+ "\xd7\x37\xaf\x65\x3d\x11\x39\xb6"
+ "\x24\x8a\x60\xae\xd6\x1e\xbf\x0e"
+ "\x0d\xd7\xdc\x96\x0e\x65\x75\x4e"
+ "\x29\x06\x9d\xa4\x51\x3a\x10\x63"
+ "\x8f\x17\x07\xd5\x8e\x3c\xf4\x28"
+ "\x00\x5a\x5b\x05\x19\xd8\xc0\x6c"
+ "\xe5\x15\xe4\x9c\x9d\x71\x9d\x5e"
+ "\x94\x29\x1a\xa7\x80\xfa\x0e\x33"
+ "\x03\xdd\xb7\x3e\x9a\xa9\x26\x18"
+ "\x37\xa9\x64\x08\x4d\x94\x5a\x88"
+ "\xca\x35\xce\x81\x02\xe3\x1f\x1b"
+ "\x89\x1a\x77\x85\xe3\x41\x6d\x32"
+ "\x42\x19\x23\x7d\xc8\x73\xee\x25"
+ "\x85\x0d\xf8\x31\x25\x79\x1b\x6f"
+ "\x79\x25\xd2\xd8\xd4\x23\xfd\xf7"
+ "\x82\x36\x6a\x0c\x46\x22\x15\xe9"
+ "\xff\x72\x41\x91\x91\x7d\x3a\xb7"
+ "\xdd\x65\x99\x70\xf6\x8d\x84\xf8"
+ "\x67\x15\x20\x11\xd6\xb2\x55\x7b"
+ "\xdb\x87\xee\xef\x55\x89\x2a\x59"
+ "\x2b\x07\x8f\x43\x8a\x59\x3c\x01"
+ "\x8b\x65\x54\xa1\x66\xd5\x38\xbd"
+ "\xc6\x30\xa9\xcc\x49\xb6\xa8\x1b"
+ "\xb8\xc0\x0e\xe3\x45\x28\xe2\xff"
+ "\x41\x9f\x7e\x7c\xd1\xae\x9e\x25"
+ "\x3f\x4c\x7c\x7c\xf4\xa8\x26\x4d"
+ "\x5c\xfd\x4b\x27\x18\xf9\x61\x76"
+ "\x48\xba\x0c\x6b\xa9\x4d\xfc\xf5"
+ "\x3b\x35\x7e\x2f\x4a\xa9\xc2\x9a"
+ "\xae\xab\x86\x09\x89\xc9\xc2\x40"
+ "\x39\x2c\x81\xb3\xb8\x17\x67\xc2"
+ "\x0d\x32\x4a\x3a\x67\x81\xd7\x1a"
+ "\x34\x52\xc5\xdb\x0a\xf5\x63\x39"
+ "\xea\x1f\xe1\x7c\xa1\x9e\xc1\x35"
+ "\xe3\xb1\x18\x45\x67\xf9\x22\x38"
+ "\x95\xd9\x34\x34\x86\xc6\x41\x94"
+ "\x15\xf9\x5b\x41\xa6\x87\x8b\xf8"
+ "\xd5\xe1\x1b\xe2\x5b\xf3\x86\x10"
+ "\xff\xe6\xae\x69\x76\xbc\x0d\xb4"
+ "\x09\x90\x0c\xa2\x65\x0c\xad\x74"
+ "\xf5\xd7\xff\xda\xc1\xce\x85\xbe"
+ "\x00\xa7\xff\x4d\x2f\x65\xd3\x8c"
+ "\x86\x2d\x05\xe8\xed\x3e\x6b\x8b"
+ "\x0f\x3d\x83\x8c\xf1\x1d\x5b\x96"
+ "\x2e\xb1\x9c\xc2\x98\xe1\x70\xb9"
+ "\xba\x5c\x8a\x43\xd6\x34\xa7\x2d"
+ "\xc9\x92\xae\xf2\xa5\x7b\x05\x49"
+ "\xa7\x33\x34\x86\xca\xe4\x96\x23"
+ "\x76\x5b\xf2\xc6\xf1\x51\x28\x42"
+ "\x7b\xcc\x76\x8f\xfa\xa2\xad\x31"
+ "\xd4\xd6\x7a\x6d\x25\x25\x54\xe4"
+ "\x3f\x50\x59\xe1\x5c\x05\xb7\x27"
+ "\x48\xbf\x07\xec\x1b\x13\xbe\x2b"
+ "\xa1\x57\x2b\xd5\xab\xd7\xd0\x4c"
+ "\x1e\xcb\x71\x9b\xc5\x90\x85\xd3"
+ "\xde\x59\xec\x71\xeb\x89\xbb\xd0"
+ "\x09\x50\xe1\x16\x3f\xfd\x1c\x34"
+ "\xc3\x1c\xa1\x10\x77\x53\x98\xef"
+ "\xf2\xfd\xa5\x01\x59\xc2\x9b\x26"
+ "\xc7\x42\xd9\x49\xda\x58\x2b\x6e"
+ "\x9f\x53\x19\x76\x7e\xd9\xc9\x0e"
+ "\x68\xc8\x7f\x51\x22\x42\xef\x49"
+ "\xa4\x55\xb6\x36\xac\x09\xc7\x31"
+ "\x88\x15\x4b\x2e\x8f\x3a\x08\xf7"
+ "\xd8\xf7\xa8\xc5\xa9\x33\xa6\x45"
+ "\xe4\xc4\x94\x76\xf3\x0d\x8f\x7e"
+ "\xc8\xf6\xbc\x23\x0a\xb6\x4c\xd3"
+ "\x6a\xcd\x36\xc2\x90\x5c\x5c\x3c"
+ "\x65\x7b\xc2\xd6\xcc\xe6\x0d\x87"
+ "\x73\x2e\x71\x79\x16\x06\x63\x28"
+ "\x09\x15\xd8\x89\x38\x38\x3d\xb5"
+ "\x42\x1c\x08\x24\xf7\x2a\xd2\x9d"
+ "\xc8\xca\xef\xf9\x27\xd8\x07\x86"
+ "\xf7\x43\x0b\x55\x15\x3f\x9f\x83"
+ "\xef\xdc\x49\x9d\x2a\xc1\x54\x62"
+ "\xbd\x9b\x66\x55\x9f\xb7\x12\xf3"
+ "\x1b\x4d\x9d\x2a\x5c\xed\x87\x75"
+ "\x87\x26\xec\x61\x2c\xb4\x0f\x89"
+ "\xb0\xfb\x2e\x68\x5d\x15\xc7\x8d"
+ "\x2e\xc0\xd9\xec\xaf\x4f\xd2\x25"
+ "\x29\xe8\xd2\x26\x2b\x67\xe9\xfc"
+ "\x2b\xa8\x67\x96\x12\x1f\x5b\x96"
+ "\xc6\x14\x53\xaf\x44\xea\xd6\xe2"
+ "\x94\x98\xe4\x12\x93\x4c\x92\xe0"
+ "\x18\xa5\x8d\x2d\xe4\x71\x3c\x47"
+ "\x4c\xf7\xe6\x47\x9e\xc0\x68\xdf"
+ "\xd4\xf5\x5a\x74\xb1\x2b\x29\x03"
+ "\x19\x07\xaf\x90\x62\x5c\x68\x98"
+ "\x48\x16\x11\x02\x9d\xee\xb4\x9b"
+ "\xe5\x42\x7f\x08\xfd\x16\x32\x0b"
+ "\xd0\xb3\xfa\x2b\xb7\x99\xf9\x29"
+ "\xcd\x20\x45\x9f\xb3\x1a\x5d\xa2"
+ "\xaf\x4d\xe0\xbd\x42\x0d\xbc\x74"
+ "\x99\x9c\x8e\x53\x1a\xb4\x3e\xbd"
+ "\xa2\x9a\x2d\xf7\xf8\x39\x0f\x67"
+ "\x63\xfc\x6b\xc0\xaf\xb3\x4b\x4f"
+ "\x55\xc4\xcf\xa7\xc8\x04\x11\x3e"
+ "\x14\x32\xbb\x1b\x38\x77\xd6\x7f"
+ "\x54\x4c\xdf\x75\xf3\x07\x2d\x33"
+ "\x9b\xa8\x20\xe1\x7b\x12\xb5\xf3"
+ "\xef\x2f\xce\x72\xe5\x24\x60\xc1"
+ "\x30\xe2\xab\xa1\x8e\x11\x09\xa8"
+ "\x21\x33\x44\xfe\x7f\x35\x32\x93"
+ "\x39\xa7\xad\x8b\x79\x06\xb2\xcb"
+ "\x4e\xa9\x5f\xc7\xba\x74\x29\xec"
+ "\x93\xa0\x4e\x54\x93\xc0\xbc\x55"
+ "\x64\xf0\x48\xe5\x57\x99\xee\x75"
+ "\xd6\x79\x0f\x66\xb7\xc6\x57\x76"
+ "\xf7\xb7\xf3\x9c\xc5\x60\xe8\x7f"
+ "\x83\x76\xd6\x0e\xaa\xe6\x90\x39"
+ "\x1d\xa6\x32\x6a\x34\xe3\x55\xf8"
+ "\x58\xa0\x58\x7d\x33\xe0\x22\x39"
+ "\x44\x64\x87\x86\x5a\x2f\xa7\x7e"
+ "\x0f\x38\xea\xb0\x30\xcc\x61\xa5"
+ "\x6a\x32\xae\x1e\xf7\xe9\xd0\xa9"
+ "\x0c\x32\x4b\xb5\x49\x28\xab\x85"
+ "\x2f\x8e\x01\x36\x38\x52\xd0\xba"
+ "\xd6\x02\x78\xf8\x0e\x3e\x9c\x8b"
+ "\x6b\x45\x99\x3f\x5c\xfe\x58\xf1"
+ "\x5c\x94\x04\xe1\xf5\x18\x6d\x51"
+ "\xb2\x5d\x18\x20\xb6\xc2\x9a\x42"
+ "\x1d\xb3\xab\x3c\xb6\x3a\x13\x03"
+ "\xb2\x46\x82\x4f\xfc\x64\xbc\x4f"
+ "\xca\xfa\x9c\xc0\xd5\xa7\xbd\x11"
+ "\xb7\xe4\x5a\xf6\x6f\x4d\x4d\x54"
+ "\xea\xa4\x98\x66\xd4\x22\x3b\xd3"
+ "\x8f\x34\x47\xd9\x7c\xf4\x72\x3b"
+ "\x4d\x02\x77\xf6\xd6\xdd\x08\x0a"
+ "\x81\xe1\x86\x89\x3e\x56\x10\x3c"
+ "\xba\xd7\x81\x8c\x08\xbc\x8b\xe2"
+ "\x53\xec\xa7\x89\xee\xc8\x56\xb5"
+ "\x36\x2c\xb2\x03\xba\x99\xdd\x7c"
+ "\x48\xa0\xb0\xbc\x91\x33\xe9\xa8"
+ "\xcb\xcd\xcf\x59\x5f\x1f\x15\xe2"
+ "\x56\xf5\x4e\x01\x35\x27\x45\x77"
+ "\x47\xc8\xbc\xcb\x7e\x39\xc1\x97"
+ "\x28\xd3\x84\xfc\x2c\x3e\xc8\xad"
+ "\x9c\xf8\x8a\x61\x9c\x28\xaa\xc5"
+ "\x99\x20\x43\x85\x9d\xa5\xe2\x8b"
+ "\xb8\xae\xeb\xd0\x32\x0d\x52\x78"
+ "\x09\x56\x3f\xc7\xd8\x7e\x26\xfc"
+ "\x37\xfb\x6f\x04\xfc\xfa\x92\x10"
+ "\xac\xf8\x3e\x21\xdc\x8c\x21\x16"
+ "\x7d\x67\x6e\xf6\xcd\xda\xb6\x98"
+ "\x23\xab\x23\x3c\xb2\x10\xa0\x53"
+ "\x5a\x56\x9f\xc5\xd0\xff\xbb\xe4"
+ "\x98\x3c\x69\x1e\xdb\x38\x8f\x7e"
+ "\x0f\xd2\x98\x88\x81\x8b\x45\x67"
+ "\xea\x33\xf1\xeb\xe9\x97\x55\x2e"
+ "\xd9\xaa\xeb\x5a\xec\xda\xe1\x68"
+ "\xa8\x9d\x3c\x84\x7c\x05\x3d\x62"
+ "\x87\x8f\x03\x21\x28\x95\x0c\x89"
+ "\x25\x22\x4a\xb0\x93\xa9\x50\xa2"
+ "\x2f\x57\x6e\x18\x42\x19\x54\x0c"
+ "\x55\x67\xc6\x11\x49\xf4\x5c\xd2"
+ "\xe9\x3d\xdd\x8b\x48\x71\x21\x00"
+ "\xc3\x9a\x6c\x85\x74\x28\x83\x4a"
+ "\x1b\x31\x05\xe1\x06\x92\xe7\xda"
+ "\x85\x73\x78\x45\x20\x7f\xae\x13"
+ "\x7c\x33\x06\x22\xf4\x83\xf9\x35"
+ "\x3f\x6c\x71\xa8\x4e\x48\xbe\x9b"
+ "\xce\x8a\xba\xda\xbe\x28\x08\xf7"
+ "\xe2\x14\x8c\x71\xea\x72\xf9\x33"
+ "\xf2\x88\x3f\xd7\xbb\x69\x6c\x29"
+ "\x19\xdc\x84\xce\x1f\x12\x4f\xc8"
+ "\xaf\xa5\x04\xba\x5a\xab\xb0\xd9"
+ "\x14\x1f\x6c\x68\x98\x39\x89\x7a"
+ "\xd9\xd8\x2f\xdf\xa8\x47\x4a\x25"
+ "\xe2\xfb\x33\xf4\x59\x78\xe1\x68"
+ "\x85\xcf\xfe\x59\x20\xd4\x05\x1d"
+ "\x80\x99\xae\xbc\xca\xae\x0f\x2f"
+ "\x65\x43\x34\x8e\x7e\xac\xd3\x93"
+ "\x2f\xac\x6d\x14\x3d\x02\x07\x70"
+ "\x9d\xa4\xf3\x1b\x5c\x36\xfc\x01"
+ "\x73\x34\x85\x0c\x6c\xd6\xf1\xbd"
+ "\x3f\xdf\xee\xf5\xd9\xba\x56\xef"
+ "\xf4\x9b\x6b\xee\x9f\x5a\x78\x6d"
+ "\x32\x19\xf4\xf7\xf8\x4c\x69\x0b"
+ "\x4b\xbc\xbb\xb7\xf2\x85\xaf\x70"
+ "\x75\x24\x6c\x54\xa7\x0e\x4d\x1d"
+ "\x01\xbf\x08\xac\xcf\x7f\x2c\xe3"
+ "\x14\x89\x5e\x70\x5a\x99\x92\xcd"
+ "\x01\x84\xc8\xd2\xab\xe5\x4f\x58"
+ "\xe7\x0f\x2f\x0e\xff\x68\xea\xfd"
+ "\x15\xb3\x17\xe6\xb0\xe7\x85\xd8"
+ "\x23\x2e\x05\xc7\xc9\xc4\x46\x1f"
+ "\xe1\x9e\x49\x20\x23\x24\x4d\x7e"
+ "\x29\x65\xff\xf4\xb6\xfd\x1a\x85"
+ "\xc4\x16\xec\xfc\xea\x7b\xd6\x2c"
+ "\x43\xf8\xb7\xbf\x79\xc0\x85\xcd"
+ "\xef\xe1\x98\xd3\xa5\xf7\x90\x8c"
+ "\xe9\x7f\x80\x6b\xd2\xac\x4c\x30"
+ "\xa7\xc6\x61\x6c\xd2\xf9\x2c\xff"
+ "\x30\xbc\x22\x81\x7d\x93\x12\xe4"
+ "\x0a\xcd\xaf\xdd\xe8\xab\x0a\x1e"
+ "\x13\xa4\x27\xc3\x5f\xf7\x4b\xbb"
+ "\x37\x09\x4b\x91\x6f\x92\x4f\xaf"
+ "\x52\xee\xdf\xef\x09\x6f\xf7\x5c"
+ "\x6e\x12\x17\x72\x63\x57\xc7\xba"
+ "\x3b\x6b\x38\x32\x73\x1b\x9c\x80"
+ "\xc1\x7a\xc6\xcf\xcd\x35\xc0\x6b"
+ "\x31\x1a\x6b\xe9\xd8\x2c\x29\x3f"
+ "\x96\xfb\xb6\xcd\x13\x91\x3b\xc2"
+ "\xd2\xa3\x31\x8d\xa4\xcd\x57\xcd"
+ "\x13\x3d\x64\xfd\x06\xce\xe6\xdc"
+ "\x0c\x24\x43\x31\x40\x57\xf1\x72"
+ "\x17\xe3\x3a\x63\x6d\x35\xcf\x5d"
+ "\x97\x40\x59\xdd\xf7\x3c\x02\xf7"
+ "\x1c\x7e\x05\xbb\xa9\x0d\x01\xb1"
+ "\x8e\xc0\x30\xa9\x53\x24\xc9\x89"
+ "\x84\x6d\xaa\xd0\xcd\x91\xc2\x4d"
+ "\x91\xb0\x89\xe2\xbf\x83\x44\xaa"
+ "\x28\x72\x23\xa0\xc2\xad\xad\x1c"
+ "\xfc\x3f\x09\x7a\x0b\xdc\xc5\x1b"
+ "\x87\x13\xc6\x5b\x59\x8d\xf2\xc8"
+ "\xaf\xdf\x11\x95",
+ .rlen = 4100,
+ .np = 2,
+ .tap = { 4064, 36 },
+ },
+};
+
+/*
+ * CTS (Cipher Text Stealing) mode tests
+ */
+#define CTS_MODE_ENC_TEST_VECTORS 6
+#define CTS_MODE_DEC_TEST_VECTORS 6
+static struct cipher_testvec cts_mode_enc_tv_template[] = {
+ { /* from rfc3962 */
+ .klen = 16,
+ .key = "\x63\x68\x69\x63\x6b\x65\x6e\x20"
+ "\x74\x65\x72\x69\x79\x61\x6b\x69",
+ .ilen = 17,
+ .input = "\x49\x20\x77\x6f\x75\x6c\x64\x20"
+ "\x6c\x69\x6b\x65\x20\x74\x68\x65"
+ "\x20",
+ .rlen = 17,
+ .result = "\xc6\x35\x35\x68\xf2\xbf\x8c\xb4"
+ "\xd8\xa5\x80\x36\x2d\xa7\xff\x7f"
+ "\x97",
+ }, {
+ .klen = 16,
+ .key = "\x63\x68\x69\x63\x6b\x65\x6e\x20"
+ "\x74\x65\x72\x69\x79\x61\x6b\x69",
+ .ilen = 31,
+ .input = "\x49\x20\x77\x6f\x75\x6c\x64\x20"
+ "\x6c\x69\x6b\x65\x20\x74\x68\x65"
+ "\x20\x47\x65\x6e\x65\x72\x61\x6c"
+ "\x20\x47\x61\x75\x27\x73\x20",
+ .rlen = 31,
+ .result = "\xfc\x00\x78\x3e\x0e\xfd\xb2\xc1"
+ "\xd4\x45\xd4\xc8\xef\xf7\xed\x22"
+ "\x97\x68\x72\x68\xd6\xec\xcc\xc0"
+ "\xc0\x7b\x25\xe2\x5e\xcf\xe5",
+ }, {
+ .klen = 16,
+ .key = "\x63\x68\x69\x63\x6b\x65\x6e\x20"
+ "\x74\x65\x72\x69\x79\x61\x6b\x69",
+ .ilen = 32,
+ .input = "\x49\x20\x77\x6f\x75\x6c\x64\x20"
+ "\x6c\x69\x6b\x65\x20\x74\x68\x65"
+ "\x20\x47\x65\x6e\x65\x72\x61\x6c"
+ "\x20\x47\x61\x75\x27\x73\x20\x43",
+ .rlen = 32,
+ .result = "\x39\x31\x25\x23\xa7\x86\x62\xd5"
+ "\xbe\x7f\xcb\xcc\x98\xeb\xf5\xa8"
+ "\x97\x68\x72\x68\xd6\xec\xcc\xc0"
+ "\xc0\x7b\x25\xe2\x5e\xcf\xe5\x84",
+ }, {
+ .klen = 16,
+ .key = "\x63\x68\x69\x63\x6b\x65\x6e\x20"
+ "\x74\x65\x72\x69\x79\x61\x6b\x69",
+ .ilen = 47,
+ .input = "\x49\x20\x77\x6f\x75\x6c\x64\x20"
+ "\x6c\x69\x6b\x65\x20\x74\x68\x65"
+ "\x20\x47\x65\x6e\x65\x72\x61\x6c"
+ "\x20\x47\x61\x75\x27\x73\x20\x43"
+ "\x68\x69\x63\x6b\x65\x6e\x2c\x20"
+ "\x70\x6c\x65\x61\x73\x65\x2c",
+ .rlen = 47,
+ .result = "\x97\x68\x72\x68\xd6\xec\xcc\xc0"
+ "\xc0\x7b\x25\xe2\x5e\xcf\xe5\x84"
+ "\xb3\xff\xfd\x94\x0c\x16\xa1\x8c"
+ "\x1b\x55\x49\xd2\xf8\x38\x02\x9e"
+ "\x39\x31\x25\x23\xa7\x86\x62\xd5"
+ "\xbe\x7f\xcb\xcc\x98\xeb\xf5",
+ }, {
+ .klen = 16,
+ .key = "\x63\x68\x69\x63\x6b\x65\x6e\x20"
+ "\x74\x65\x72\x69\x79\x61\x6b\x69",
+ .ilen = 48,
+ .input = "\x49\x20\x77\x6f\x75\x6c\x64\x20"
+ "\x6c\x69\x6b\x65\x20\x74\x68\x65"
+ "\x20\x47\x65\x6e\x65\x72\x61\x6c"
+ "\x20\x47\x61\x75\x27\x73\x20\x43"
+ "\x68\x69\x63\x6b\x65\x6e\x2c\x20"
+ "\x70\x6c\x65\x61\x73\x65\x2c\x20",
+ .rlen = 48,
+ .result = "\x97\x68\x72\x68\xd6\xec\xcc\xc0"
+ "\xc0\x7b\x25\xe2\x5e\xcf\xe5\x84"
+ "\x9d\xad\x8b\xbb\x96\xc4\xcd\xc0"
+ "\x3b\xc1\x03\xe1\xa1\x94\xbb\xd8"
+ "\x39\x31\x25\x23\xa7\x86\x62\xd5"
+ "\xbe\x7f\xcb\xcc\x98\xeb\xf5\xa8",
+ }, {
+ .klen = 16,
+ .key = "\x63\x68\x69\x63\x6b\x65\x6e\x20"
+ "\x74\x65\x72\x69\x79\x61\x6b\x69",
+ .ilen = 64,
+ .input = "\x49\x20\x77\x6f\x75\x6c\x64\x20"
+ "\x6c\x69\x6b\x65\x20\x74\x68\x65"
+ "\x20\x47\x65\x6e\x65\x72\x61\x6c"
+ "\x20\x47\x61\x75\x27\x73\x20\x43"
+ "\x68\x69\x63\x6b\x65\x6e\x2c\x20"
+ "\x70\x6c\x65\x61\x73\x65\x2c\x20"
+ "\x61\x6e\x64\x20\x77\x6f\x6e\x74"
+ "\x6f\x6e\x20\x73\x6f\x75\x70\x2e",
+ .rlen = 64,
+ .result = "\x97\x68\x72\x68\xd6\xec\xcc\xc0"
+ "\xc0\x7b\x25\xe2\x5e\xcf\xe5\x84"
+ "\x39\x31\x25\x23\xa7\x86\x62\xd5"
+ "\xbe\x7f\xcb\xcc\x98\xeb\xf5\xa8"
+ "\x48\x07\xef\xe8\x36\xee\x89\xa5"
+ "\x26\x73\x0d\xbc\x2f\x7b\xc8\x40"
+ "\x9d\xad\x8b\xbb\x96\xc4\xcd\xc0"
+ "\x3b\xc1\x03\xe1\xa1\x94\xbb\xd8",
+ }
+};
+
+static struct cipher_testvec cts_mode_dec_tv_template[] = {
+ { /* from rfc3962 */
+ .klen = 16,
+ .key = "\x63\x68\x69\x63\x6b\x65\x6e\x20"
+ "\x74\x65\x72\x69\x79\x61\x6b\x69",
+ .rlen = 17,
+ .result = "\x49\x20\x77\x6f\x75\x6c\x64\x20"
+ "\x6c\x69\x6b\x65\x20\x74\x68\x65"
+ "\x20",
+ .ilen = 17,
+ .input = "\xc6\x35\x35\x68\xf2\xbf\x8c\xb4"
+ "\xd8\xa5\x80\x36\x2d\xa7\xff\x7f"
+ "\x97",
+ }, {
+ .klen = 16,
+ .key = "\x63\x68\x69\x63\x6b\x65\x6e\x20"
+ "\x74\x65\x72\x69\x79\x61\x6b\x69",
+ .rlen = 31,
+ .result = "\x49\x20\x77\x6f\x75\x6c\x64\x20"
+ "\x6c\x69\x6b\x65\x20\x74\x68\x65"
+ "\x20\x47\x65\x6e\x65\x72\x61\x6c"
+ "\x20\x47\x61\x75\x27\x73\x20",
+ .ilen = 31,
+ .input = "\xfc\x00\x78\x3e\x0e\xfd\xb2\xc1"
+ "\xd4\x45\xd4\xc8\xef\xf7\xed\x22"
+ "\x97\x68\x72\x68\xd6\xec\xcc\xc0"
+ "\xc0\x7b\x25\xe2\x5e\xcf\xe5",
+ }, {
+ .klen = 16,
+ .key = "\x63\x68\x69\x63\x6b\x65\x6e\x20"
+ "\x74\x65\x72\x69\x79\x61\x6b\x69",
+ .rlen = 32,
+ .result = "\x49\x20\x77\x6f\x75\x6c\x64\x20"
+ "\x6c\x69\x6b\x65\x20\x74\x68\x65"
+ "\x20\x47\x65\x6e\x65\x72\x61\x6c"
+ "\x20\x47\x61\x75\x27\x73\x20\x43",
+ .ilen = 32,
+ .input = "\x39\x31\x25\x23\xa7\x86\x62\xd5"
+ "\xbe\x7f\xcb\xcc\x98\xeb\xf5\xa8"
+ "\x97\x68\x72\x68\xd6\xec\xcc\xc0"
+ "\xc0\x7b\x25\xe2\x5e\xcf\xe5\x84",
+ }, {
+ .klen = 16,
+ .key = "\x63\x68\x69\x63\x6b\x65\x6e\x20"
+ "\x74\x65\x72\x69\x79\x61\x6b\x69",
+ .rlen = 47,
+ .result = "\x49\x20\x77\x6f\x75\x6c\x64\x20"
+ "\x6c\x69\x6b\x65\x20\x74\x68\x65"
+ "\x20\x47\x65\x6e\x65\x72\x61\x6c"
+ "\x20\x47\x61\x75\x27\x73\x20\x43"
+ "\x68\x69\x63\x6b\x65\x6e\x2c\x20"
+ "\x70\x6c\x65\x61\x73\x65\x2c",
+ .ilen = 47,
+ .input = "\x97\x68\x72\x68\xd6\xec\xcc\xc0"
+ "\xc0\x7b\x25\xe2\x5e\xcf\xe5\x84"
+ "\xb3\xff\xfd\x94\x0c\x16\xa1\x8c"
+ "\x1b\x55\x49\xd2\xf8\x38\x02\x9e"
+ "\x39\x31\x25\x23\xa7\x86\x62\xd5"
+ "\xbe\x7f\xcb\xcc\x98\xeb\xf5",
+ }, {
+ .klen = 16,
+ .key = "\x63\x68\x69\x63\x6b\x65\x6e\x20"
+ "\x74\x65\x72\x69\x79\x61\x6b\x69",
+ .rlen = 48,
+ .result = "\x49\x20\x77\x6f\x75\x6c\x64\x20"
+ "\x6c\x69\x6b\x65\x20\x74\x68\x65"
+ "\x20\x47\x65\x6e\x65\x72\x61\x6c"
+ "\x20\x47\x61\x75\x27\x73\x20\x43"
+ "\x68\x69\x63\x6b\x65\x6e\x2c\x20"
+ "\x70\x6c\x65\x61\x73\x65\x2c\x20",
+ .ilen = 48,
+ .input = "\x97\x68\x72\x68\xd6\xec\xcc\xc0"
+ "\xc0\x7b\x25\xe2\x5e\xcf\xe5\x84"
+ "\x9d\xad\x8b\xbb\x96\xc4\xcd\xc0"
+ "\x3b\xc1\x03\xe1\xa1\x94\xbb\xd8"
+ "\x39\x31\x25\x23\xa7\x86\x62\xd5"
+ "\xbe\x7f\xcb\xcc\x98\xeb\xf5\xa8",
+ }, {
+ .klen = 16,
+ .key = "\x63\x68\x69\x63\x6b\x65\x6e\x20"
+ "\x74\x65\x72\x69\x79\x61\x6b\x69",
+ .rlen = 64,
+ .result = "\x49\x20\x77\x6f\x75\x6c\x64\x20"
+ "\x6c\x69\x6b\x65\x20\x74\x68\x65"
+ "\x20\x47\x65\x6e\x65\x72\x61\x6c"
+ "\x20\x47\x61\x75\x27\x73\x20\x43"
+ "\x68\x69\x63\x6b\x65\x6e\x2c\x20"
+ "\x70\x6c\x65\x61\x73\x65\x2c\x20"
+ "\x61\x6e\x64\x20\x77\x6f\x6e\x74"
+ "\x6f\x6e\x20\x73\x6f\x75\x70\x2e",
+ .ilen = 64,
+ .input = "\x97\x68\x72\x68\xd6\xec\xcc\xc0"
+ "\xc0\x7b\x25\xe2\x5e\xcf\xe5\x84"
+ "\x39\x31\x25\x23\xa7\x86\x62\xd5"
+ "\xbe\x7f\xcb\xcc\x98\xeb\xf5\xa8"
+ "\x48\x07\xef\xe8\x36\xee\x89\xa5"
+ "\x26\x73\x0d\xbc\x2f\x7b\xc8\x40"
+ "\x9d\xad\x8b\xbb\x96\xc4\xcd\xc0"
+ "\x3b\xc1\x03\xe1\xa1\x94\xbb\xd8",
+ }
+};
+
+/*
+ * Compression stuff.
+ */
+#define COMP_BUF_SIZE 512
+
+struct comp_testvec {
+ int inlen, outlen;
+ char input[COMP_BUF_SIZE];
+ char output[COMP_BUF_SIZE];
+};
+
+struct pcomp_testvec {
+ void *params;
+ unsigned int paramsize;
+ int inlen, outlen;
+ char input[COMP_BUF_SIZE];
+ char output[COMP_BUF_SIZE];
+};
+
+/*
+ * Deflate test vectors (null-terminated strings).
+ * Params: winbits=-11, Z_DEFAULT_COMPRESSION, MAX_MEM_LEVEL.
+ */
+
+#define DEFLATE_COMP_TEST_VECTORS 2
+#define DEFLATE_DECOMP_TEST_VECTORS 2
+
+static struct comp_testvec deflate_comp_tv_template[] = {
+ {
+ .inlen = 70,
+ .outlen = 38,
+ .input = "Join us now and share the software "
+ "Join us now and share the software ",
+ .output = "\xf3\xca\xcf\xcc\x53\x28\x2d\x56"
+ "\xc8\xcb\x2f\x57\x48\xcc\x4b\x51"
+ "\x28\xce\x48\x2c\x4a\x55\x28\xc9"
+ "\x48\x55\x28\xce\x4f\x2b\x29\x07"
+ "\x71\xbc\x08\x2b\x01\x00",
+ }, {
+ .inlen = 191,
+ .outlen = 122,
+ .input = "This document describes a compression method based on the DEFLATE"
+ "compression algorithm. This document defines the application of "
+ "the DEFLATE algorithm to the IP Payload Compression Protocol.",
+ .output = "\x5d\x8d\x31\x0e\xc2\x30\x10\x04"
+ "\xbf\xb2\x2f\xc8\x1f\x10\x04\x09"
+ "\x89\xc2\x85\x3f\x70\xb1\x2f\xf8"
+ "\x24\xdb\x67\xd9\x47\xc1\xef\x49"
+ "\x68\x12\x51\xae\x76\x67\xd6\x27"
+ "\x19\x88\x1a\xde\x85\xab\x21\xf2"
+ "\x08\x5d\x16\x1e\x20\x04\x2d\xad"
+ "\xf3\x18\xa2\x15\x85\x2d\x69\xc4"
+ "\x42\x83\x23\xb6\x6c\x89\x71\x9b"
+ "\xef\xcf\x8b\x9f\xcf\x33\xca\x2f"
+ "\xed\x62\xa9\x4c\x80\xff\x13\xaf"
+ "\x52\x37\xed\x0e\x52\x6b\x59\x02"
+ "\xd9\x4e\xe8\x7a\x76\x1d\x02\x98"
+ "\xfe\x8a\x87\x83\xa3\x4f\x56\x8a"
+ "\xb8\x9e\x8e\x5c\x57\xd3\xa0\x79"
+ "\xfa\x02",
+ },
+};
+
+static struct comp_testvec deflate_decomp_tv_template[] = {
+ {
+ .inlen = 122,
+ .outlen = 191,
+ .input = "\x5d\x8d\x31\x0e\xc2\x30\x10\x04"
+ "\xbf\xb2\x2f\xc8\x1f\x10\x04\x09"
+ "\x89\xc2\x85\x3f\x70\xb1\x2f\xf8"
+ "\x24\xdb\x67\xd9\x47\xc1\xef\x49"
+ "\x68\x12\x51\xae\x76\x67\xd6\x27"
+ "\x19\x88\x1a\xde\x85\xab\x21\xf2"
+ "\x08\x5d\x16\x1e\x20\x04\x2d\xad"
+ "\xf3\x18\xa2\x15\x85\x2d\x69\xc4"
+ "\x42\x83\x23\xb6\x6c\x89\x71\x9b"
+ "\xef\xcf\x8b\x9f\xcf\x33\xca\x2f"
+ "\xed\x62\xa9\x4c\x80\xff\x13\xaf"
+ "\x52\x37\xed\x0e\x52\x6b\x59\x02"
+ "\xd9\x4e\xe8\x7a\x76\x1d\x02\x98"
+ "\xfe\x8a\x87\x83\xa3\x4f\x56\x8a"
+ "\xb8\x9e\x8e\x5c\x57\xd3\xa0\x79"
+ "\xfa\x02",
+ .output = "This document describes a compression method based on the DEFLATE"
+ "compression algorithm. This document defines the application of "
+ "the DEFLATE algorithm to the IP Payload Compression Protocol.",
+ }, {
+ .inlen = 38,
+ .outlen = 70,
+ .input = "\xf3\xca\xcf\xcc\x53\x28\x2d\x56"
+ "\xc8\xcb\x2f\x57\x48\xcc\x4b\x51"
+ "\x28\xce\x48\x2c\x4a\x55\x28\xc9"
+ "\x48\x55\x28\xce\x4f\x2b\x29\x07"
+ "\x71\xbc\x08\x2b\x01\x00",
+ .output = "Join us now and share the software "
+ "Join us now and share the software ",
+ },
+};
+
+#define ZLIB_COMP_TEST_VECTORS 2
+#define ZLIB_DECOMP_TEST_VECTORS 2
+
+static const struct {
+ struct nlattr nla;
+ int val;
+} deflate_comp_params[] = {
+ {
+ .nla = {
+ .nla_len = NLA_HDRLEN + sizeof(int),
+ .nla_type = ZLIB_COMP_LEVEL,
+ },
+ .val = Z_DEFAULT_COMPRESSION,
+ }, {
+ .nla = {
+ .nla_len = NLA_HDRLEN + sizeof(int),
+ .nla_type = ZLIB_COMP_METHOD,
+ },
+ .val = Z_DEFLATED,
+ }, {
+ .nla = {
+ .nla_len = NLA_HDRLEN + sizeof(int),
+ .nla_type = ZLIB_COMP_WINDOWBITS,
+ },
+ .val = -11,
+ }, {
+ .nla = {
+ .nla_len = NLA_HDRLEN + sizeof(int),
+ .nla_type = ZLIB_COMP_MEMLEVEL,
+ },
+ .val = MAX_MEM_LEVEL,
+ }, {
+ .nla = {
+ .nla_len = NLA_HDRLEN + sizeof(int),
+ .nla_type = ZLIB_COMP_STRATEGY,
+ },
+ .val = Z_DEFAULT_STRATEGY,
+ }
+};
+
+static const struct {
+ struct nlattr nla;
+ int val;
+} deflate_decomp_params[] = {
+ {
+ .nla = {
+ .nla_len = NLA_HDRLEN + sizeof(int),
+ .nla_type = ZLIB_DECOMP_WINDOWBITS,
+ },
+ .val = -11,
+ }
+};
+
+static struct pcomp_testvec zlib_comp_tv_template[] = {
+ {
+ .params = &deflate_comp_params,
+ .paramsize = sizeof(deflate_comp_params),
+ .inlen = 70,
+ .outlen = 38,
+ .input = "Join us now and share the software "
+ "Join us now and share the software ",
+ .output = "\xf3\xca\xcf\xcc\x53\x28\x2d\x56"
+ "\xc8\xcb\x2f\x57\x48\xcc\x4b\x51"
+ "\x28\xce\x48\x2c\x4a\x55\x28\xc9"
+ "\x48\x55\x28\xce\x4f\x2b\x29\x07"
+ "\x71\xbc\x08\x2b\x01\x00",
+ }, {
+ .params = &deflate_comp_params,
+ .paramsize = sizeof(deflate_comp_params),
+ .inlen = 191,
+ .outlen = 122,
+ .input = "This document describes a compression method based on the DEFLATE"
+ "compression algorithm. This document defines the application of "
+ "the DEFLATE algorithm to the IP Payload Compression Protocol.",
+ .output = "\x5d\x8d\x31\x0e\xc2\x30\x10\x04"
+ "\xbf\xb2\x2f\xc8\x1f\x10\x04\x09"
+ "\x89\xc2\x85\x3f\x70\xb1\x2f\xf8"
+ "\x24\xdb\x67\xd9\x47\xc1\xef\x49"
+ "\x68\x12\x51\xae\x76\x67\xd6\x27"
+ "\x19\x88\x1a\xde\x85\xab\x21\xf2"
+ "\x08\x5d\x16\x1e\x20\x04\x2d\xad"
+ "\xf3\x18\xa2\x15\x85\x2d\x69\xc4"
+ "\x42\x83\x23\xb6\x6c\x89\x71\x9b"
+ "\xef\xcf\x8b\x9f\xcf\x33\xca\x2f"
+ "\xed\x62\xa9\x4c\x80\xff\x13\xaf"
+ "\x52\x37\xed\x0e\x52\x6b\x59\x02"
+ "\xd9\x4e\xe8\x7a\x76\x1d\x02\x98"
+ "\xfe\x8a\x87\x83\xa3\x4f\x56\x8a"
+ "\xb8\x9e\x8e\x5c\x57\xd3\xa0\x79"
+ "\xfa\x02",
+ },
+};
+
+static struct pcomp_testvec zlib_decomp_tv_template[] = {
+ {
+ .params = &deflate_decomp_params,
+ .paramsize = sizeof(deflate_decomp_params),
+ .inlen = 122,
+ .outlen = 191,
+ .input = "\x5d\x8d\x31\x0e\xc2\x30\x10\x04"
+ "\xbf\xb2\x2f\xc8\x1f\x10\x04\x09"
+ "\x89\xc2\x85\x3f\x70\xb1\x2f\xf8"
+ "\x24\xdb\x67\xd9\x47\xc1\xef\x49"
+ "\x68\x12\x51\xae\x76\x67\xd6\x27"
+ "\x19\x88\x1a\xde\x85\xab\x21\xf2"
+ "\x08\x5d\x16\x1e\x20\x04\x2d\xad"
+ "\xf3\x18\xa2\x15\x85\x2d\x69\xc4"
+ "\x42\x83\x23\xb6\x6c\x89\x71\x9b"
+ "\xef\xcf\x8b\x9f\xcf\x33\xca\x2f"
+ "\xed\x62\xa9\x4c\x80\xff\x13\xaf"
+ "\x52\x37\xed\x0e\x52\x6b\x59\x02"
+ "\xd9\x4e\xe8\x7a\x76\x1d\x02\x98"
+ "\xfe\x8a\x87\x83\xa3\x4f\x56\x8a"
+ "\xb8\x9e\x8e\x5c\x57\xd3\xa0\x79"
+ "\xfa\x02",
+ .output = "This document describes a compression method based on the DEFLATE"
+ "compression algorithm. This document defines the application of "
+ "the DEFLATE algorithm to the IP Payload Compression Protocol.",
+ }, {
+ .params = &deflate_decomp_params,
+ .paramsize = sizeof(deflate_decomp_params),
+ .inlen = 38,
+ .outlen = 70,
+ .input = "\xf3\xca\xcf\xcc\x53\x28\x2d\x56"
+ "\xc8\xcb\x2f\x57\x48\xcc\x4b\x51"
+ "\x28\xce\x48\x2c\x4a\x55\x28\xc9"
+ "\x48\x55\x28\xce\x4f\x2b\x29\x07"
+ "\x71\xbc\x08\x2b\x01\x00",
+ .output = "Join us now and share the software "
+ "Join us now and share the software ",
+ },
+};
+
+/*
+ * LZO test vectors (null-terminated strings).
+ */
+#define LZO_COMP_TEST_VECTORS 2
+#define LZO_DECOMP_TEST_VECTORS 2
+
+static struct comp_testvec lzo_comp_tv_template[] = {
+ {
+ .inlen = 70,
+ .outlen = 46,
+ .input = "Join us now and share the software "
+ "Join us now and share the software ",
+ .output = "\x00\x0d\x4a\x6f\x69\x6e\x20\x75"
+ "\x73\x20\x6e\x6f\x77\x20\x61\x6e"
+ "\x64\x20\x73\x68\x61\x72\x65\x20"
+ "\x74\x68\x65\x20\x73\x6f\x66\x74"
+ "\x77\x70\x01\x01\x4a\x6f\x69\x6e"
+ "\x3d\x88\x00\x11\x00\x00",
+ }, {
+ .inlen = 159,
+ .outlen = 133,
+ .input = "This document describes a compression method based on the LZO "
+ "compression algorithm. This document defines the application of "
+ "the LZO algorithm used in UBIFS.",
+ .output = "\x00\x2b\x54\x68\x69\x73\x20\x64"
+ "\x6f\x63\x75\x6d\x65\x6e\x74\x20"
+ "\x64\x65\x73\x63\x72\x69\x62\x65"
+ "\x73\x20\x61\x20\x63\x6f\x6d\x70"
+ "\x72\x65\x73\x73\x69\x6f\x6e\x20"
+ "\x6d\x65\x74\x68\x6f\x64\x20\x62"
+ "\x61\x73\x65\x64\x20\x6f\x6e\x20"
+ "\x74\x68\x65\x20\x4c\x5a\x4f\x2b"
+ "\x8c\x00\x0d\x61\x6c\x67\x6f\x72"
+ "\x69\x74\x68\x6d\x2e\x20\x20\x54"
+ "\x68\x69\x73\x2a\x54\x01\x02\x66"
+ "\x69\x6e\x65\x73\x94\x06\x05\x61"
+ "\x70\x70\x6c\x69\x63\x61\x74\x76"
+ "\x0a\x6f\x66\x88\x02\x60\x09\x27"
+ "\xf0\x00\x0c\x20\x75\x73\x65\x64"
+ "\x20\x69\x6e\x20\x55\x42\x49\x46"
+ "\x53\x2e\x11\x00\x00",
+ },
+};
+
+static struct comp_testvec lzo_decomp_tv_template[] = {
+ {
+ .inlen = 133,
+ .outlen = 159,
+ .input = "\x00\x2b\x54\x68\x69\x73\x20\x64"
+ "\x6f\x63\x75\x6d\x65\x6e\x74\x20"
+ "\x64\x65\x73\x63\x72\x69\x62\x65"
+ "\x73\x20\x61\x20\x63\x6f\x6d\x70"
+ "\x72\x65\x73\x73\x69\x6f\x6e\x20"
+ "\x6d\x65\x74\x68\x6f\x64\x20\x62"
+ "\x61\x73\x65\x64\x20\x6f\x6e\x20"
+ "\x74\x68\x65\x20\x4c\x5a\x4f\x2b"
+ "\x8c\x00\x0d\x61\x6c\x67\x6f\x72"
+ "\x69\x74\x68\x6d\x2e\x20\x20\x54"
+ "\x68\x69\x73\x2a\x54\x01\x02\x66"
+ "\x69\x6e\x65\x73\x94\x06\x05\x61"
+ "\x70\x70\x6c\x69\x63\x61\x74\x76"
+ "\x0a\x6f\x66\x88\x02\x60\x09\x27"
+ "\xf0\x00\x0c\x20\x75\x73\x65\x64"
+ "\x20\x69\x6e\x20\x55\x42\x49\x46"
+ "\x53\x2e\x11\x00\x00",
+ .output = "This document describes a compression method based on the LZO "
+ "compression algorithm. This document defines the application of "
+ "the LZO algorithm used in UBIFS.",
+ }, {
+ .inlen = 46,
+ .outlen = 70,
+ .input = "\x00\x0d\x4a\x6f\x69\x6e\x20\x75"
+ "\x73\x20\x6e\x6f\x77\x20\x61\x6e"
+ "\x64\x20\x73\x68\x61\x72\x65\x20"
+ "\x74\x68\x65\x20\x73\x6f\x66\x74"
+ "\x77\x70\x01\x01\x4a\x6f\x69\x6e"
+ "\x3d\x88\x00\x11\x00\x00",
+ .output = "Join us now and share the software "
+ "Join us now and share the software ",
+ },
+};
+
+/*
+ * Michael MIC test vectors from IEEE 802.11i
+ */
+#define MICHAEL_MIC_TEST_VECTORS 6
+
+static struct hash_testvec michael_mic_tv_template[] = {
+ {
+ .key = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .ksize = 8,
+ .plaintext = zeroed_string,
+ .psize = 0,
+ .digest = "\x82\x92\x5c\x1c\xa1\xd1\x30\xb8",
+ },
+ {
+ .key = "\x82\x92\x5c\x1c\xa1\xd1\x30\xb8",
+ .ksize = 8,
+ .plaintext = "M",
+ .psize = 1,
+ .digest = "\x43\x47\x21\xca\x40\x63\x9b\x3f",
+ },
+ {
+ .key = "\x43\x47\x21\xca\x40\x63\x9b\x3f",
+ .ksize = 8,
+ .plaintext = "Mi",
+ .psize = 2,
+ .digest = "\xe8\xf9\xbe\xca\xe9\x7e\x5d\x29",
+ },
+ {
+ .key = "\xe8\xf9\xbe\xca\xe9\x7e\x5d\x29",
+ .ksize = 8,
+ .plaintext = "Mic",
+ .psize = 3,
+ .digest = "\x90\x03\x8f\xc6\xcf\x13\xc1\xdb",
+ },
+ {
+ .key = "\x90\x03\x8f\xc6\xcf\x13\xc1\xdb",
+ .ksize = 8,
+ .plaintext = "Mich",
+ .psize = 4,
+ .digest = "\xd5\x5e\x10\x05\x10\x12\x89\x86",
+ },
+ {
+ .key = "\xd5\x5e\x10\x05\x10\x12\x89\x86",
+ .ksize = 8,
+ .plaintext = "Michael",
+ .psize = 7,
+ .digest = "\x0a\x94\x2b\x12\x4e\xca\xa5\x46",
+ }
+};
+
+/*
+ * CRC32C test vectors
+ */
+#define CRC32C_TEST_VECTORS 14
+
+static struct hash_testvec crc32c_tv_template[] = {
+ {
+ .psize = 0,
+ .digest = "\x00\x00\x00\x00",
+ },
+ {
+ .key = "\x87\xa9\xcb\xed",
+ .ksize = 4,
+ .psize = 0,
+ .digest = "\x78\x56\x34\x12",
+ },
+ {
+ .key = "\xff\xff\xff\xff",
+ .ksize = 4,
+ .plaintext = "\x01\x02\x03\x04\x05\x06\x07\x08"
+ "\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10"
+ "\x11\x12\x13\x14\x15\x16\x17\x18"
+ "\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20"
+ "\x21\x22\x23\x24\x25\x26\x27\x28",
+ .psize = 40,
+ .digest = "\x7f\x15\x2c\x0e",
+ },
+ {
+ .key = "\xff\xff\xff\xff",
+ .ksize = 4,
+ .plaintext = "\x29\x2a\x2b\x2c\x2d\x2e\x2f\x30"
+ "\x31\x32\x33\x34\x35\x36\x37\x38"
+ "\x39\x3a\x3b\x3c\x3d\x3e\x3f\x40"
+ "\x41\x42\x43\x44\x45\x46\x47\x48"
+ "\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50",
+ .psize = 40,
+ .digest = "\xf6\xeb\x80\xe9",
+ },
+ {
+ .key = "\xff\xff\xff\xff",
+ .ksize = 4,
+ .plaintext = "\x51\x52\x53\x54\x55\x56\x57\x58"
+ "\x59\x5a\x5b\x5c\x5d\x5e\x5f\x60"
+ "\x61\x62\x63\x64\x65\x66\x67\x68"
+ "\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70"
+ "\x71\x72\x73\x74\x75\x76\x77\x78",
+ .psize = 40,
+ .digest = "\xed\xbd\x74\xde",
+ },
+ {
+ .key = "\xff\xff\xff\xff",
+ .ksize = 4,
+ .plaintext = "\x79\x7a\x7b\x7c\x7d\x7e\x7f\x80"
+ "\x81\x82\x83\x84\x85\x86\x87\x88"
+ "\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90"
+ "\x91\x92\x93\x94\x95\x96\x97\x98"
+ "\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0",
+ .psize = 40,
+ .digest = "\x62\xc8\x79\xd5",
+ },
+ {
+ .key = "\xff\xff\xff\xff",
+ .ksize = 4,
+ .plaintext = "\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8"
+ "\xa9\xaa\xab\xac\xad\xae\xaf\xb0"
+ "\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8"
+ "\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0"
+ "\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8",
+ .psize = 40,
+ .digest = "\xd0\x9a\x97\xba",
+ },
+ {
+ .key = "\xff\xff\xff\xff",
+ .ksize = 4,
+ .plaintext = "\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0"
+ "\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8"
+ "\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0"
+ "\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8"
+ "\xe9\xea\xeb\xec\xed\xee\xef\xf0",
+ .psize = 40,
+ .digest = "\x13\xd9\x29\x2b",
+ },
+ {
+ .key = "\x80\xea\xd3\xf1",
+ .ksize = 4,
+ .plaintext = "\x29\x2a\x2b\x2c\x2d\x2e\x2f\x30"
+ "\x31\x32\x33\x34\x35\x36\x37\x38"
+ "\x39\x3a\x3b\x3c\x3d\x3e\x3f\x40"
+ "\x41\x42\x43\x44\x45\x46\x47\x48"
+ "\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50",
+ .psize = 40,
+ .digest = "\x0c\xb5\xe2\xa2",
+ },
+ {
+ .key = "\xf3\x4a\x1d\x5d",
+ .ksize = 4,
+ .plaintext = "\x51\x52\x53\x54\x55\x56\x57\x58"
+ "\x59\x5a\x5b\x5c\x5d\x5e\x5f\x60"
+ "\x61\x62\x63\x64\x65\x66\x67\x68"
+ "\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70"
+ "\x71\x72\x73\x74\x75\x76\x77\x78",
+ .psize = 40,
+ .digest = "\xd1\x7f\xfb\xa6",
+ },
+ {
+ .key = "\x2e\x80\x04\x59",
+ .ksize = 4,
+ .plaintext = "\x79\x7a\x7b\x7c\x7d\x7e\x7f\x80"
+ "\x81\x82\x83\x84\x85\x86\x87\x88"
+ "\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90"
+ "\x91\x92\x93\x94\x95\x96\x97\x98"
+ "\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0",
+ .psize = 40,
+ .digest = "\x59\x33\xe6\x7a",
+ },
+ {
+ .key = "\xa6\xcc\x19\x85",
+ .ksize = 4,
+ .plaintext = "\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8"
+ "\xa9\xaa\xab\xac\xad\xae\xaf\xb0"
+ "\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8"
+ "\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0"
+ "\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8",
+ .psize = 40,
+ .digest = "\xbe\x03\x01\xd2",
+ },
+ {
+ .key = "\x41\xfc\xfe\x2d",
+ .ksize = 4,
+ .plaintext = "\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0"
+ "\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8"
+ "\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0"
+ "\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8"
+ "\xe9\xea\xeb\xec\xed\xee\xef\xf0",
+ .psize = 40,
+ .digest = "\x75\xd3\xc5\x24",
+ },
+ {
+ .key = "\xff\xff\xff\xff",
+ .ksize = 4,
+ .plaintext = "\x01\x02\x03\x04\x05\x06\x07\x08"
+ "\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10"
+ "\x11\x12\x13\x14\x15\x16\x17\x18"
+ "\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20"
+ "\x21\x22\x23\x24\x25\x26\x27\x28"
+ "\x29\x2a\x2b\x2c\x2d\x2e\x2f\x30"
+ "\x31\x32\x33\x34\x35\x36\x37\x38"
+ "\x39\x3a\x3b\x3c\x3d\x3e\x3f\x40"
+ "\x41\x42\x43\x44\x45\x46\x47\x48"
+ "\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50"
+ "\x51\x52\x53\x54\x55\x56\x57\x58"
+ "\x59\x5a\x5b\x5c\x5d\x5e\x5f\x60"
+ "\x61\x62\x63\x64\x65\x66\x67\x68"
+ "\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70"
+ "\x71\x72\x73\x74\x75\x76\x77\x78"
+ "\x79\x7a\x7b\x7c\x7d\x7e\x7f\x80"
+ "\x81\x82\x83\x84\x85\x86\x87\x88"
+ "\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90"
+ "\x91\x92\x93\x94\x95\x96\x97\x98"
+ "\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0"
+ "\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8"
+ "\xa9\xaa\xab\xac\xad\xae\xaf\xb0"
+ "\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8"
+ "\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0"
+ "\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8"
+ "\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0"
+ "\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8"
+ "\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0"
+ "\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8"
+ "\xe9\xea\xeb\xec\xed\xee\xef\xf0",
+ .psize = 240,
+ .digest = "\x75\xd3\xc5\x24",
+ .np = 2,
+ .tap = { 31, 209 }
+ },
+};
+
+#endif /* _IFXMIPS_CRYPTO_TESTMGR_H */
diff --git a/package/platform/lantiq/ltq-deu/src/.svn/text-base/internal.h.svn-base b/package/platform/lantiq/ltq-deu/src/.svn/text-base/internal.h.svn-base
new file mode 100644
index 0000000..2d22636
--- /dev/null
+++ b/package/platform/lantiq/ltq-deu/src/.svn/text-base/internal.h.svn-base
@@ -0,0 +1,141 @@
+/*
+ * Cryptographic API.
+ *
+ * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
+ * Copyright (c) 2005 Herbert Xu <herbert@gondor.apana.org.au>
+ *
+ * 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 of the License, or (at your option)
+ * any later version.
+ *
+ */
+#ifndef _CRYPTO_INTERNAL_H
+#define _CRYPTO_INTERNAL_H
+
+#include <crypto/algapi.h>
+#include <linux/completion.h>
+#include <linux/mm.h>
+#include <linux/highmem.h>
+#include <linux/interrupt.h>
+#include <linux/init.h>
+#include <linux/list.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/notifier.h>
+#include <linux/rwsem.h>
+#include <linux/slab.h>
+#include <linux/fips.h>
+
+/* Crypto notification events. */
+enum {
+ CRYPTO_MSG_ALG_REQUEST,
+ CRYPTO_MSG_ALG_REGISTER,
+ CRYPTO_MSG_ALG_UNREGISTER,
+ CRYPTO_MSG_TMPL_REGISTER,
+ CRYPTO_MSG_TMPL_UNREGISTER,
+};
+
+struct crypto_instance;
+struct crypto_template;
+
+struct crypto_larval {
+ struct crypto_alg alg;
+ struct crypto_alg *adult;
+ struct completion completion;
+ u32 mask;
+};
+
+extern struct list_head crypto_alg_list;
+extern struct rw_semaphore crypto_alg_sem;
+extern struct blocking_notifier_head crypto_chain;
+
+#ifdef CONFIG_PROC_FS
+void __init crypto_init_proc(void);
+void __exit crypto_exit_proc(void);
+#else
+static inline void crypto_init_proc(void)
+{ }
+static inline void crypto_exit_proc(void)
+{ }
+#endif
+
+static inline unsigned int crypto_cipher_ctxsize(struct crypto_alg *alg)
+{
+ return alg->cra_ctxsize;
+}
+
+static inline unsigned int crypto_compress_ctxsize(struct crypto_alg *alg)
+{
+ return alg->cra_ctxsize;
+}
+
+struct crypto_alg *crypto_mod_get(struct crypto_alg *alg);
+struct crypto_alg *crypto_alg_lookup(const char *name, u32 type, u32 mask);
+struct crypto_alg *crypto_alg_mod_lookup(const char *name, u32 type, u32 mask);
+
+int crypto_init_cipher_ops(struct crypto_tfm *tfm);
+int crypto_init_compress_ops(struct crypto_tfm *tfm);
+
+void crypto_exit_cipher_ops(struct crypto_tfm *tfm);
+void crypto_exit_compress_ops(struct crypto_tfm *tfm);
+
+struct crypto_larval *crypto_larval_alloc(const char *name, u32 type, u32 mask);
+void crypto_larval_kill(struct crypto_alg *alg);
+struct crypto_alg *crypto_larval_lookup(const char *name, u32 type, u32 mask);
+void crypto_larval_error(const char *name, u32 type, u32 mask);
+void crypto_alg_tested(const char *name, int err);
+
+void crypto_shoot_alg(struct crypto_alg *alg);
+struct crypto_tfm *__crypto_alloc_tfm(struct crypto_alg *alg, u32 type,
+ u32 mask);
+void *crypto_create_tfm(struct crypto_alg *alg,
+ const struct crypto_type *frontend);
+struct crypto_alg *crypto_find_alg(const char *alg_name,
+ const struct crypto_type *frontend,
+ u32 type, u32 mask);
+void *crypto_alloc_tfm(const char *alg_name,
+ const struct crypto_type *frontend, u32 type, u32 mask);
+
+int crypto_register_notifier(struct notifier_block *nb);
+int crypto_unregister_notifier(struct notifier_block *nb);
+int crypto_probing_notify(unsigned long val, void *v);
+
+static inline void crypto_alg_put(struct crypto_alg *alg)
+{
+ if (atomic_dec_and_test(&alg->cra_refcnt) && alg->cra_destroy)
+ alg->cra_destroy(alg);
+}
+
+static inline int crypto_tmpl_get(struct crypto_template *tmpl)
+{
+ return try_module_get(tmpl->module);
+}
+
+static inline void crypto_tmpl_put(struct crypto_template *tmpl)
+{
+ module_put(tmpl->module);
+}
+
+static inline int crypto_is_larval(struct crypto_alg *alg)
+{
+ return alg->cra_flags & CRYPTO_ALG_LARVAL;
+}
+
+static inline int crypto_is_dead(struct crypto_alg *alg)
+{
+ return alg->cra_flags & CRYPTO_ALG_DEAD;
+}
+
+static inline int crypto_is_moribund(struct crypto_alg *alg)
+{
+ return alg->cra_flags & (CRYPTO_ALG_DEAD | CRYPTO_ALG_DYING);
+}
+
+static inline void crypto_notify(unsigned long val, void *v)
+{
+ blocking_notifier_call_chain(&crypto_chain, val, v);
+}
+
+#endif /* _CRYPTO_INTERNAL_H */
+
diff --git a/package/platform/lantiq/ltq-deu/src/.svn/text-base/ltq_deu_testmgr.c.svn-base b/package/platform/lantiq/ltq-deu/src/.svn/text-base/ltq_deu_testmgr.c.svn-base
new file mode 100644
index 0000000..f1b5752
--- /dev/null
+++ b/package/platform/lantiq/ltq-deu/src/.svn/text-base/ltq_deu_testmgr.c.svn-base
@@ -0,0 +1,3957 @@
+/*
+ * Algorithm testing framework and tests.
+ *
+ * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
+ * Copyright (c) 2002 Jean-Francois Dive <jef@linuxbe.org>
+ * Copyright (c) 2007 Nokia Siemens Networks
+ * Copyright (c) 2008 Herbert Xu <herbert@gondor.apana.org.au>
+ *
+ * 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 of the License, or (at your option)
+ * any later version.
+ *
+ */
+
+#include <crypto/hash.h>
+#include <linux/err.h>
+#include <linux/module.h>
+#include <linux/scatterlist.h>
+#include <linux/slab.h>
+#include <linux/string.h>
+#include <crypto/rng.h>
+#include <linux/jiffies.h>
+#include <linux/init.h>
+#include <linux/moduleparam.h>
+#include <linux/delay.h>
+#include <linux/types.h>
+#include <linux/sched.h>
+
+#include "internal.h"
+#include "ifxmips_testmgr.h"
+#include "ifxmips_tcrypt.h"
+#include "ifxmips_deu.h"
+
+/* changes for LQ ablkcipher speedtest */
+#include <linux/timex.h>
+#include <linux/interrupt.h>
+#include <asm/mipsregs.h>
+
+/*
+ * Need slab memory for testing (size in number of pages).
+ */
+#define XBUFSIZE 8
+
+/*
+ * Indexes into the xbuf to simulate cross-page access.
+ */
+#define IDX1 32
+#define IDX2 32400
+#define IDX3 1
+#define IDX4 8193
+#define IDX5 22222
+#define IDX6 17101
+#define IDX7 27333
+#define IDX8 3000
+
+/*
+* Used by test_cipher()
+*/
+#define ENCRYPT 1
+#define DECRYPT 0
+
+/*
+ * Need slab memory for testing (size in number of pages).
+ */
+#define TVMEMSIZE 4
+
+/*
+* Used by test_cipher_speed()
+*/
+#define ENCRYPT 1
+#define DECRYPT 0
+
+/*
+ * Used by test_cipher_speed()
+ */
+
+
+static unsigned int sec;
+
+static char *alg = NULL;
+static u32 type;
+static u32 mask;
+static int mode;
+static char *tvmem[TVMEMSIZE];
+
+static char *check[] = {
+ "des", "md5", "des3_ede", "rot13", "sha1", "sha224", "sha256",
+ "blowfish", "twofish", "serpent", "sha384", "sha512", "md4", "aes",
+ "cast6", "arc4", "michael_mic", "deflate", "crc32c", "tea", "xtea",
+ "khazad", "wp512", "wp384", "wp256", "tnepres", "xeta", "fcrypt",
+ "camellia", "seed", "salsa20", "rmd128", "rmd160", "rmd256", "rmd320",
+ "lzo", "cts", "zlib", NULL
+};
+struct tcrypt_result {
+ struct completion completion;
+ int err;
+};
+
+struct aead_test_suite {
+ struct {
+ struct aead_testvec *vecs;
+ unsigned int count;
+ } enc, dec;
+};
+
+struct cipher_test_suite {
+ struct {
+ struct cipher_testvec *vecs;
+ unsigned int count;
+ } enc, dec;
+};
+
+struct comp_test_suite {
+ struct {
+ struct comp_testvec *vecs;
+ unsigned int count;
+ } comp, decomp;
+};
+
+struct pcomp_test_suite {
+ struct {
+ struct pcomp_testvec *vecs;
+ unsigned int count;
+ } comp, decomp;
+};
+
+struct hash_test_suite {
+ struct hash_testvec *vecs;
+ unsigned int count;
+};
+
+struct cprng_test_suite {
+ struct cprng_testvec *vecs;
+ unsigned int count;
+};
+
+struct alg_test_desc {
+ const char *alg;
+ int (*test)(const struct alg_test_desc *desc, const char *driver,
+ u32 type, u32 mask);
+ int fips_allowed; /* set if alg is allowed in fips mode */
+
+ union {
+ struct aead_test_suite aead;
+ struct cipher_test_suite cipher;
+ struct comp_test_suite comp;
+ struct pcomp_test_suite pcomp;
+ struct hash_test_suite hash;
+ struct cprng_test_suite cprng;
+ } suite;
+};
+
+static unsigned int IDX[8] = { IDX1, IDX2, IDX3, IDX4, IDX5, IDX6, IDX7, IDX8 };
+
+static void hexdump(unsigned char *buf, unsigned int len)
+{
+ print_hex_dump(KERN_CONT, "", DUMP_PREFIX_OFFSET,
+ 16, 1,
+ buf, len, false);
+}
+
+static void tcrypt_complete(struct crypto_async_request *req, int err)
+{
+ struct tcrypt_result *res = req->data;
+
+ //printk("Signal done test\n");
+
+ if (err == -EINPROGRESS) {
+ printk("********************* Completion didnt go too well **************************** \n");
+ return;
+ }
+
+ res->err = err;
+ complete_all(&res->completion);
+}
+
+static int testmgr_alloc_buf(char *buf[XBUFSIZE])
+{
+ int i;
+
+ for (i = 0; i < XBUFSIZE; i++) {
+ buf[i] = (void *)__get_free_page(GFP_KERNEL);
+ if (!buf[i])
+ goto err_free_buf;
+ }
+
+ return 0;
+
+err_free_buf:
+ while (i-- > 0)
+ free_page((unsigned long)buf[i]);
+
+ return -ENOMEM;
+}
+
+static void testmgr_free_buf(char *buf[XBUFSIZE])
+{
+ int i;
+
+ for (i = 0; i < XBUFSIZE; i++)
+ free_page((unsigned long)buf[i]);
+}
+
+static int test_hash(struct crypto_ahash *tfm, struct hash_testvec *template,
+ unsigned int tcount)
+{
+ const char *algo = crypto_tfm_alg_driver_name(crypto_ahash_tfm(tfm));
+ unsigned int i, j, k, temp;
+ struct scatterlist sg[8];
+ char result[64];
+ struct ahash_request *req;
+ struct tcrypt_result tresult;
+ void *hash_buff;
+ char *xbuf[XBUFSIZE];
+ int ret = -ENOMEM;
+
+ if (testmgr_alloc_buf(xbuf))
+ goto out_nobuf;
+
+ init_completion(&tresult.completion);
+
+ req = ahash_request_alloc(tfm, GFP_KERNEL);
+ if (!req) {
+ printk(KERN_ERR "alg: hash: Failed to allocate request for "
+ "%s\n", algo);
+ goto out_noreq;
+ }
+ ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG,
+ tcrypt_complete, &tresult);
+
+ j = 0;
+ for (i = 0; i < tcount; i++) {
+ if (template[i].np)
+ continue;
+
+ j++;
+ memset(result, 0, 64);
+
+ hash_buff = xbuf[0];
+
+ memcpy(hash_buff, template[i].plaintext, template[i].psize);
+ sg_init_one(&sg[0], hash_buff, template[i].psize);
+
+ if (template[i].ksize) {
+ crypto_ahash_clear_flags(tfm, ~0);
+ ret = crypto_ahash_setkey(tfm, template[i].key,
+ template[i].ksize);
+ if (ret) {
+ printk(KERN_ERR "alg: hash: setkey failed on "
+ "test %d for %s: ret=%d\n", j, algo,
+ -ret);
+ goto out;
+ }
+ }
+
+ ahash_request_set_crypt(req, sg, result, template[i].psize);
+ ret = crypto_ahash_digest(req);
+ switch (ret) {
+ case 0:
+ break;
+ case -EINPROGRESS:
+ case -EBUSY:
+ ret = wait_for_completion_interruptible(
+ &tresult.completion);
+ if (!ret && !(ret = tresult.err)) {
+ INIT_COMPLETION(tresult.completion);
+ break;
+ }
+ /* fall through */
+ default:
+ printk(KERN_ERR "alg: hash: digest failed on test %d "
+ "for %s: ret=%d\n", j, algo, -ret);
+ goto out;
+ }
+
+ if (memcmp(result, template[i].digest,
+ crypto_ahash_digestsize(tfm))) {
+ printk(KERN_ERR "alg: hash: Test %d failed for %s\n",
+ j, algo);
+ hexdump(result, crypto_ahash_digestsize(tfm));
+ ret = -EINVAL;
+ goto out;
+ }
+ else {
+ printk(KERN_ERR "alg: hash: Test %d passed for %s\n",
+ j, algo);
+ hexdump(result, crypto_ahash_digestsize(tfm));
+ }
+ }
+
+ j = 0;
+ for (i = 0; i < tcount; i++) {
+ if (template[i].np) {
+ j++;
+ memset(result, 0, 64);
+
+ temp = 0;
+ sg_init_table(sg, template[i].np);
+ ret = -EINVAL;
+ for (k = 0; k < template[i].np; k++) {
+ if (WARN_ON(offset_in_page(IDX[k]) +
+ template[i].tap[k] > PAGE_SIZE))
+ goto out;
+ sg_set_buf(&sg[k],
+ memcpy(xbuf[IDX[k] >> PAGE_SHIFT] +
+ offset_in_page(IDX[k]),
+ template[i].plaintext + temp,
+ template[i].tap[k]),
+ template[i].tap[k]);
+ temp += template[i].tap[k];
+ }
+
+ if (template[i].ksize) {
+ crypto_ahash_clear_flags(tfm, ~0);
+ ret = crypto_ahash_setkey(tfm, template[i].key,
+ template[i].ksize);
+
+ if (ret) {
+ printk(KERN_ERR "alg: hash: setkey "
+ "failed on chunking test %d "
+ "for %s: ret=%d\n", j, algo,
+ -ret);
+ goto out;
+ }
+ }
+
+ ahash_request_set_crypt(req, sg, result,
+ template[i].psize);
+ ret = crypto_ahash_digest(req);
+ switch (ret) {
+ case 0:
+ break;
+ case -EINPROGRESS:
+ case -EBUSY:
+ ret = wait_for_completion_interruptible(
+ &tresult.completion);
+ if (!ret && !(ret = tresult.err)) {
+ INIT_COMPLETION(tresult.completion);
+ break;
+ }
+ /* fall through */
+ default:
+ printk(KERN_ERR "alg: hash: digest failed "
+ "on chunking test %d for %s: "
+ "ret=%d\n", j, algo, -ret);
+ goto out;
+ }
+
+ if (memcmp(result, template[i].digest,
+ crypto_ahash_digestsize(tfm))) {
+ printk(KERN_ERR "alg: hash: Chunking test %d "
+ "failed for %s\n", j, algo);
+ hexdump(result, crypto_ahash_digestsize(tfm));
+ ret = -EINVAL;
+ goto out;
+ }
+ else {
+ printk(KERN_ERR "alg: hash: Chunking test %d "
+ "passed for %s\n", j, algo);
+ hexdump(result, crypto_ahash_digestsize(tfm));
+ }
+ }
+ }
+
+ ret = 0;
+
+out:
+ ahash_request_free(req);
+out_noreq:
+ testmgr_free_buf(xbuf);
+out_nobuf:
+ return ret;
+}
+
+static int test_aead(struct crypto_aead *tfm, int enc,
+ struct aead_testvec *template, unsigned int tcount)
+{
+ const char *algo = crypto_tfm_alg_driver_name(crypto_aead_tfm(tfm));
+ unsigned int i, j, k, n, temp;
+ int ret = -ENOMEM;
+ char *q;
+ char *key;
+ struct aead_request *req;
+ struct scatterlist sg[8];
+ struct scatterlist asg[8];
+ const char *e;
+ struct tcrypt_result result;
+ unsigned int authsize;
+ void *input;
+ void *assoc;
+ char iv[MAX_IVLEN];
+ char *xbuf[XBUFSIZE];
+ char *axbuf[XBUFSIZE];
+
+ if (testmgr_alloc_buf(xbuf))
+ goto out_noxbuf;
+ if (testmgr_alloc_buf(axbuf))
+ goto out_noaxbuf;
+
+ if (enc == ENCRYPT)
+ e = "encryption";
+ else
+ e = "decryption";
+
+ init_completion(&result.completion);
+
+ req = aead_request_alloc(tfm, GFP_KERNEL);
+ if (!req) {
+ printk(KERN_ERR "alg: aead: Failed to allocate request for "
+ "%s\n", algo);
+ goto out;
+ }
+
+ aead_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG,
+ tcrypt_complete, &result);
+
+ for (i = 0, j = 0; i < tcount; i++) {
+ if (!template[i].np) {
+ j++;
+
+ /* some tepmplates have no input data but they will
+ * touch input
+ */
+ input = xbuf[0];
+ assoc = axbuf[0];
+
+ ret = -EINVAL;
+ if (WARN_ON(template[i].ilen > PAGE_SIZE ||
+ template[i].alen > PAGE_SIZE))
+ goto out;
+
+ memcpy(input, template[i].input, template[i].ilen);
+ memcpy(assoc, template[i].assoc, template[i].alen);
+ if (template[i].iv)
+ memcpy(iv, template[i].iv, MAX_IVLEN);
+ else
+ memset(iv, 0, MAX_IVLEN);
+
+ crypto_aead_clear_flags(tfm, ~0);
+ if (template[i].wk)
+ crypto_aead_set_flags(
+ tfm, CRYPTO_TFM_REQ_WEAK_KEY);
+
+ key = template[i].key;
+
+ ret = crypto_aead_setkey(tfm, key,
+ template[i].klen);
+ if (!ret == template[i].fail) {
+ printk(KERN_ERR "alg: aead: setkey failed on "
+ "test %d for %s: flags=%x\n", j, algo,
+ crypto_aead_get_flags(tfm));
+ goto out;
+ } else if (ret)
+ continue;
+
+ authsize = abs(template[i].rlen - template[i].ilen);
+ ret = crypto_aead_setauthsize(tfm, authsize);
+ if (ret) {
+ printk(KERN_ERR "alg: aead: Failed to set "
+ "authsize to %u on test %d for %s\n",
+ authsize, j, algo);
+ goto out;
+ }
+
+ sg_init_one(&sg[0], input,
+ template[i].ilen + (enc ? authsize : 0));
+
+ sg_init_one(&asg[0], assoc, template[i].alen);
+
+ aead_request_set_crypt(req, sg, sg,
+ template[i].ilen, iv);
+
+ aead_request_set_assoc(req, asg, template[i].alen);
+
+ ret = enc ?
+ crypto_aead_encrypt(req) :
+ crypto_aead_decrypt(req);
+
+ switch (ret) {
+ case 0:
+ if (template[i].novrfy) {
+ /* verification was supposed to fail */
+ printk(KERN_ERR "alg: aead: %s failed "
+ "on test %d for %s: ret was 0, "
+ "expected -EBADMSG\n",
+ e, j, algo);
+ /* so really, we got a bad message */
+ ret = -EBADMSG;
+ goto out;
+ }
+ break;
+ case -EINPROGRESS:
+ case -EBUSY:
+ ret = wait_for_completion_interruptible(
+ &result.completion);
+ if (!ret && !(ret = result.err)) {
+ INIT_COMPLETION(result.completion);
+ break;
+ }
+ case -EBADMSG:
+ if (template[i].novrfy)
+ /* verification failure was expected */
+ continue;
+ /* fall through */
+ default:
+ printk(KERN_ERR "alg: aead: %s failed on test "
+ "%d for %s: ret=%d\n", e, j, algo, -ret);
+ goto out;
+ }
+
+ q = input;
+ if (memcmp(q, template[i].result, template[i].rlen)) {
+ printk(KERN_ERR "alg: aead: Test %d failed on "
+ "%s for %s\n", j, e, algo);
+ hexdump(q, template[i].rlen);
+ ret = -EINVAL;
+ goto out;
+ }
+ else {
+ printk(KERN_ERR "alg: aead: Test %d passed on "
+ "%s for %s\n", j, e, algo);
+ hexdump(q, template[i].rlen);
+ }
+ }
+ }
+
+ for (i = 0, j = 0; i < tcount; i++) {
+ if (template[i].np) {
+ j++;
+
+ if (template[i].iv)
+ memcpy(iv, template[i].iv, MAX_IVLEN);
+ else
+ memset(iv, 0, MAX_IVLEN);
+
+ crypto_aead_clear_flags(tfm, ~0);
+ if (template[i].wk)
+ crypto_aead_set_flags(
+ tfm, CRYPTO_TFM_REQ_WEAK_KEY);
+ key = template[i].key;
+
+ ret = crypto_aead_setkey(tfm, key, template[i].klen);
+ if (!ret == template[i].fail) {
+ printk(KERN_ERR "alg: aead: setkey failed on "
+ "chunk test %d for %s: flags=%x\n", j,
+ algo, crypto_aead_get_flags(tfm));
+ goto out;
+ } else if (ret)
+ continue;
+
+ authsize = abs(template[i].rlen - template[i].ilen);
+
+ ret = -EINVAL;
+ sg_init_table(sg, template[i].np);
+ for (k = 0, temp = 0; k < template[i].np; k++) {
+ if (WARN_ON(offset_in_page(IDX[k]) +
+ template[i].tap[k] > PAGE_SIZE))
+ goto out;
+
+ q = xbuf[IDX[k] >> PAGE_SHIFT] +
+ offset_in_page(IDX[k]);
+
+ memcpy(q, template[i].input + temp,
+ template[i].tap[k]);
+
+ n = template[i].tap[k];
+ if (k == template[i].np - 1 && enc)
+ n += authsize;
+ if (offset_in_page(q) + n < PAGE_SIZE)
+ q[n] = 0;
+
+ sg_set_buf(&sg[k], q, template[i].tap[k]);
+ temp += template[i].tap[k];
+ }
+
+ ret = crypto_aead_setauthsize(tfm, authsize);
+ if (ret) {
+ printk(KERN_ERR "alg: aead: Failed to set "
+ "authsize to %u on chunk test %d for "
+ "%s\n", authsize, j, algo);
+ goto out;
+ }
+
+ if (enc) {
+ if (WARN_ON(sg[k - 1].offset +
+ sg[k - 1].length + authsize >
+ PAGE_SIZE)) {
+ ret = -EINVAL;
+ goto out;
+ }
+
+ sg[k - 1].length += authsize;
+ }
+
+ sg_init_table(asg, template[i].anp);
+ ret = -EINVAL;
+ for (k = 0, temp = 0; k < template[i].anp; k++) {
+ if (WARN_ON(offset_in_page(IDX[k]) +
+ template[i].atap[k] > PAGE_SIZE))
+ goto out;
+ sg_set_buf(&asg[k],
+ memcpy(axbuf[IDX[k] >> PAGE_SHIFT] +
+ offset_in_page(IDX[k]),
+ template[i].assoc + temp,
+ template[i].atap[k]),
+ template[i].atap[k]);
+ temp += template[i].atap[k];
+ }
+
+ aead_request_set_crypt(req, sg, sg,
+ template[i].ilen,
+ iv);
+
+ aead_request_set_assoc(req, asg, template[i].alen);
+
+ ret = enc ?
+ crypto_aead_encrypt(req) :
+ crypto_aead_decrypt(req);
+
+ switch (ret) {
+ case 0:
+ if (template[i].novrfy) {
+ /* verification was supposed to fail */
+ printk(KERN_ERR "alg: aead: %s failed "
+ "on chunk test %d for %s: ret "
+ "was 0, expected -EBADMSG\n",
+ e, j, algo);
+ /* so really, we got a bad message */
+ ret = -EBADMSG;
+ goto out;
+ }
+ break;
+ case -EINPROGRESS:
+ case -EBUSY:
+ ret = wait_for_completion_interruptible(
+ &result.completion);
+ if (!ret && !(ret = result.err)) {
+ INIT_COMPLETION(result.completion);
+ break;
+ }
+ case -EBADMSG:
+ if (template[i].novrfy)
+ /* verification failure was expected */
+ continue;
+ /* fall through */
+ default:
+ printk(KERN_ERR "alg: aead: %s failed on "
+ "chunk test %d for %s: ret=%d\n", e, j,
+ algo, -ret);
+ goto out;
+ }
+
+ ret = -EINVAL;
+ for (k = 0, temp = 0; k < template[i].np; k++) {
+ q = xbuf[IDX[k] >> PAGE_SHIFT] +
+ offset_in_page(IDX[k]);
+
+ n = template[i].tap[k];
+ if (k == template[i].np - 1)
+ n += enc ? authsize : -authsize;
+
+ if (memcmp(q, template[i].result + temp, n)) {
+ printk(KERN_ERR "alg: aead: Chunk "
+ "test %d failed on %s at page "
+ "%u for %s\n", j, e, k, algo);
+ hexdump(q, n);
+ goto out;
+ }
+ else {
+ printk(KERN_ERR "alg: aead: Chunk "
+ "test %d passed on %s at page "
+ "%u for %s\n", j, e, k, algo);
+ hexdump(q, n);
+ }
+
+ q += n;
+ if (k == template[i].np - 1 && !enc) {
+ if (memcmp(q, template[i].input +
+ temp + n, authsize))
+ n = authsize;
+ else
+ n = 0;
+ } else {
+ for (n = 0; offset_in_page(q + n) &&
+ q[n]; n++)
+ ;
+ }
+ if (n) {
+ printk(KERN_ERR "alg: aead: Result "
+ "buffer corruption in chunk "
+ "test %d on %s at page %u for "
+ "%s: %u bytes:\n", j, e, k,
+ algo, n);
+ hexdump(q, n);
+ goto out;
+ }
+ temp += template[i].tap[k];
+ }
+ }
+ }
+
+ ret = 0;
+
+out:
+ aead_request_free(req);
+ testmgr_free_buf(axbuf);
+out_noaxbuf:
+ testmgr_free_buf(xbuf);
+out_noxbuf:
+ return ret;
+}
+
+static int test_cipher(struct crypto_cipher *tfm, int enc,
+ struct cipher_testvec *template, unsigned int tcount)
+{
+ const char *algo = crypto_tfm_alg_driver_name(crypto_cipher_tfm(tfm));
+ unsigned int i, j, k;
+ char *q;
+ const char *e;
+ void *data;
+ char *xbuf[XBUFSIZE];
+ int ret = -ENOMEM;
+
+ if (testmgr_alloc_buf(xbuf))
+ goto out_nobuf;
+
+ if (enc == ENCRYPT)
+ e = "encryption";
+ else
+ e = "decryption";
+
+ j = 0;
+ for (i = 0; i < tcount; i++) {
+ if (template[i].np)
+ continue;
+
+ j++;
+
+ ret = -EINVAL;
+ if (WARN_ON(template[i].ilen > PAGE_SIZE))
+ goto out;
+
+ data = xbuf[0];
+ memcpy(data, template[i].input, template[i].ilen);
+
+ crypto_cipher_clear_flags(tfm, ~0);
+ if (template[i].wk)
+ crypto_cipher_set_flags(tfm, CRYPTO_TFM_REQ_WEAK_KEY);
+
+ ret = crypto_cipher_setkey(tfm, template[i].key,
+ template[i].klen);
+ if (!ret == template[i].fail) {
+ printk(KERN_ERR "alg: cipher: setkey failed "
+ "on test %d for %s: flags=%x\n", j,
+ algo, crypto_cipher_get_flags(tfm));
+ goto out;
+ } else if (ret)
+ continue;
+
+ for (k = 0; k < template[i].ilen;
+ k += crypto_cipher_blocksize(tfm)) {
+ if (enc)
+ crypto_cipher_encrypt_one(tfm, data + k,
+ data + k);
+ else
+ crypto_cipher_decrypt_one(tfm, data + k,
+ data + k);
+ }
+
+ q = data;
+ if (memcmp(q, template[i].result, template[i].rlen)) {
+ printk(KERN_ERR "alg: cipher: Test %d failed "
+ "on %s for %s\n", j, e, algo);
+ hexdump(q, template[i].rlen);
+ ret = -EINVAL;
+ goto out;
+ }
+ else {
+ printk(KERN_ERR "alg: cipher: Test %d passed "
+ "on %s for %s\n", j, e, algo);
+ hexdump(q, template[i].rlen);
+ }
+ }
+
+ ret = 0;
+
+out:
+ testmgr_free_buf(xbuf);
+out_nobuf:
+ return ret;
+}
+
+static int test_skcipher(struct crypto_ablkcipher *tfm, int enc,
+ struct cipher_testvec *template, unsigned int tcount)
+{
+ const char *algo =
+ crypto_tfm_alg_driver_name(crypto_ablkcipher_tfm(tfm));
+ unsigned int i, j, k, n, temp;
+ char *q;
+ struct ablkcipher_request *req;
+ struct scatterlist sg[8];
+ const char *e;
+ struct tcrypt_result result;
+ void *data;
+ char iv[MAX_IVLEN];
+ char *xbuf[XBUFSIZE];
+ int ret = -ENOMEM;
+
+ if (testmgr_alloc_buf(xbuf))
+ goto out_nobuf;
+
+ if (enc == ENCRYPT)
+ e = "encryption";
+ else
+ e = "decryption";
+
+ init_completion(&result.completion);
+
+ req = ablkcipher_request_alloc(tfm, GFP_KERNEL);
+ if (!req) {
+ printk(KERN_ERR "alg: skcipher: Failed to allocate request "
+ "for %s\n", algo);
+ goto out;
+ }
+
+ //printk("tcount: %u\n", tcount);
+
+ ablkcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG,
+ tcrypt_complete, &result);
+
+ j = 0;
+ for (i = 0; i < tcount; i++) {
+ if (template[i].iv)
+ memcpy(iv, template[i].iv, MAX_IVLEN);
+ else
+ memset(iv, 0, MAX_IVLEN);
+
+ if (!(template[i].np)) {
+ //printk("np: %d, i: %d, j: %d\n", template[i].np, i, j);
+ j++;
+
+ ret = -EINVAL;
+ if (WARN_ON(template[i].ilen > PAGE_SIZE))
+ goto out;
+
+ data = xbuf[0];
+ memcpy(data, template[i].input, template[i].ilen);
+
+ crypto_ablkcipher_clear_flags(tfm, ~0);
+ if (template[i].wk)
+ crypto_ablkcipher_set_flags(
+ tfm, CRYPTO_TFM_REQ_WEAK_KEY);
+
+ ret = crypto_ablkcipher_setkey(tfm, template[i].key,
+ template[i].klen);
+ if (!ret == template[i].fail) {
+ printk(KERN_ERR "alg: skcipher: setkey failed "
+ "on test %d for %s: flags=%x\n", j,
+ algo, crypto_ablkcipher_get_flags(tfm));
+ printk("ERROR\n");
+ goto out;
+ } else if (ret)
+ continue;
+
+ sg_init_one(&sg[0], data, template[i].ilen);
+
+ ablkcipher_request_set_crypt(req, sg, sg,
+ template[i].ilen, iv);
+ ret = enc ?
+ crypto_ablkcipher_encrypt(req) :
+ crypto_ablkcipher_decrypt(req);
+
+ switch (ret) {
+ case 0:
+ break;
+ case -EINPROGRESS:
+ case -EBUSY:
+ ret = wait_for_completion_interruptible(
+ &result.completion);
+ if (!ret && !((ret = result.err))) {
+ INIT_COMPLETION(result.completion);
+ break;
+ }
+ /* fall through */
+ default:
+ printk(KERN_ERR "alg: skcipher: %s failed on "
+ "test %d for %s: ret=%d\n", e, j, algo,
+ -ret);
+ printk("ERROR\n");
+ goto out;
+ }
+ q = data;
+ if (memcmp(q, template[i].result, template[i].rlen)) {
+ printk(KERN_ERR "alg: skcipher: Test %d "
+ "failed on %s for %s\n", j, e, algo);
+ hexdump(q, template[i].rlen);
+ printk("ERROR\n");
+ ret = -EINVAL;
+ goto out;
+ }
+ else {
+ printk(KERN_ERR "alg: skcipher: Test %d "
+ "*PASSED* on %s for %s\n", j, e, algo);
+ hexdump(q, template[i].rlen);
+ printk("DONE\n");
+ }
+ }
+ }
+ printk("Testing %s chunking across pages.\n", algo);
+ j = 0;
+ for (i = 0; i < tcount; i++) {
+ if (template[i].iv)
+ memcpy(iv, template[i].iv, MAX_IVLEN);
+ else
+ memset(iv, 0, MAX_IVLEN);
+
+ if (template[i].np) {
+ j++;
+
+ crypto_ablkcipher_clear_flags(tfm, ~0);
+ if (template[i].wk)
+ crypto_ablkcipher_set_flags(
+ tfm, CRYPTO_TFM_REQ_WEAK_KEY);
+
+ ret = crypto_ablkcipher_setkey(tfm, template[i].key,
+ template[i].klen);
+ if (!ret == template[i].fail) {
+ printk(KERN_ERR "alg: skcipher: setkey failed "
+ "on chunk test %d for %s: flags=%x\n",
+ j, algo,
+ crypto_ablkcipher_get_flags(tfm));
+ printk("ERROR\n");
+ goto out;
+ } else if (ret)
+ continue;
+
+ temp = 0;
+ ret = -EINVAL;
+ sg_init_table(sg, template[i].np);
+ for (k = 0; k < template[i].np; k++) {
+ if (WARN_ON(offset_in_page(IDX[k]) +
+ template[i].tap[k] > PAGE_SIZE))
+ goto out;
+
+ q = xbuf[IDX[k] >> PAGE_SHIFT] +
+ offset_in_page(IDX[k]);
+
+ memcpy(q, template[i].input + temp,
+ template[i].tap[k]);
+
+ if (offset_in_page(q) + template[i].tap[k] <
+ PAGE_SIZE)
+ q[template[i].tap[k]] = 0;
+
+ sg_set_buf(&sg[k], q, template[i].tap[k]);
+
+ temp += template[i].tap[k];
+ }
+
+ ablkcipher_request_set_crypt(req, sg, sg,
+ template[i].ilen, iv);
+
+ ret = enc ?
+ crypto_ablkcipher_encrypt(req) :
+ crypto_ablkcipher_decrypt(req);
+
+ switch (ret) {
+ case 0:
+ break;
+ case -EINPROGRESS:
+ case -EBUSY:
+ ret = wait_for_completion_interruptible(
+ &result.completion);
+ if (!ret && !((ret = result.err))) {
+ INIT_COMPLETION(result.completion);
+ break;
+ }
+ /* fall through */
+ default:
+ printk(KERN_ERR "alg: skcipher: %s failed on "
+ "chunk test %d for %s: ret=%d\n", e, j,
+ algo, -ret);
+ printk("ERROR\n");
+ goto out;
+ }
+
+ temp = 0;
+ ret = -EINVAL;
+ for (k = 0; k < template[i].np; k++) {
+ q = xbuf[IDX[k] >> PAGE_SHIFT] +
+ offset_in_page(IDX[k]);
+
+ if (memcmp(q, template[i].result + temp,
+ template[i].tap[k])) {
+ printk(KERN_ERR "alg: skcipher: Chunk "
+ "test %d failed on %s at page "
+ "%u for %s\n", j, e, k, algo);
+ hexdump(q, template[i].tap[k]);
+ printk("ERROR\n");
+ goto out;
+ }
+ else {
+ printk(KERN_ERR "alg: skcipher: Chunk "
+ "test %d *PASSED* on %s at page "
+ "%u for %s\n", j, e, k, algo);
+ hexdump(q, template[i].tap[k]);
+ printk("DONE\n");
+ }
+
+ q += template[i].tap[k];
+ for (n = 0; offset_in_page(q + n) && q[n]; n++)
+ ;
+#if 1
+ if (n) {
+ printk(KERN_ERR "alg: skcipher: "
+ "Result buffer corruption in "
+ "chunk test %d on %s at page "
+ "%u for %s: %u bytes:\n", j, e,
+ k, algo, n);
+ hexdump(q, n);
+ printk("ERROR\n");
+ goto out;
+ }
+ else {
+ printk(KERN_ERR "alg: skcipher: "
+ "Result buffer clean in "
+ "chunk test %d on %s at page "
+ "%u for %s: %u bytes:\n", j, e,
+ k, algo, n);
+ hexdump(q, n);
+ printk("Chunk Buffer clean\n");
+ }
+#endif
+ temp += template[i].tap[k];
+ }
+ }
+ }
+
+ ret = 0;
+out:
+ ablkcipher_request_free(req);
+ testmgr_free_buf(xbuf);
+out_nobuf:
+ return ret;
+}
+
+static int test_comp(struct crypto_comp *tfm, struct comp_testvec *ctemplate,
+ struct comp_testvec *dtemplate, int ctcount, int dtcount)
+{
+ const char *algo = crypto_tfm_alg_driver_name(crypto_comp_tfm(tfm));
+ unsigned int i;
+ char result[COMP_BUF_SIZE];
+ int ret;
+
+ for (i = 0; i < ctcount; i++) {
+ int ilen;
+ unsigned int dlen = COMP_BUF_SIZE;
+
+ memset(result, 0, sizeof (result));
+
+ ilen = ctemplate[i].inlen;
+ ret = crypto_comp_compress(tfm, ctemplate[i].input,
+ ilen, result, &dlen);
+ if (ret) {
+ printk(KERN_ERR "alg: comp: compression failed "
+ "on test %d for %s: ret=%d\n", i + 1, algo,
+ -ret);
+ goto out;
+ }
+
+ if (dlen != ctemplate[i].outlen) {
+ printk(KERN_ERR "alg: comp: Compression test %d "
+ "failed for %s: output len = %d\n", i + 1, algo,
+ dlen);
+ ret = -EINVAL;
+ goto out;
+ }
+
+ if (memcmp(result, ctemplate[i].output, dlen)) {
+ printk(KERN_ERR "alg: comp: Compression test %d "
+ "failed for %s\n", i + 1, algo);
+ hexdump(result, dlen);
+ ret = -EINVAL;
+ goto out;
+ }
+ else {
+ printk(KERN_ERR "alg: comp: Compression test %d "
+ "passed for %s\n", i + 1, algo);
+ hexdump(result, dlen);
+ }
+ }
+
+ for (i = 0; i < dtcount; i++) {
+ int ilen;
+ unsigned int dlen = COMP_BUF_SIZE;
+
+ memset(result, 0, sizeof (result));
+
+ ilen = dtemplate[i].inlen;
+ ret = crypto_comp_decompress(tfm, dtemplate[i].input,
+ ilen, result, &dlen);
+ if (ret) {
+ printk(KERN_ERR "alg: comp: decompression failed "
+ "on test %d for %s: ret=%d\n", i + 1, algo,
+ -ret);
+ goto out;
+ }
+
+ if (dlen != dtemplate[i].outlen) {
+ printk(KERN_ERR "alg: comp: Decompression test %d "
+ "failed for %s: output len = %d\n", i + 1, algo,
+ dlen);
+ ret = -EINVAL;
+ goto out;
+ }
+
+ if (memcmp(result, dtemplate[i].output, dlen)) {
+ printk(KERN_ERR "alg: comp: Decompression test %d "
+ "failed for %s\n", i + 1, algo);
+ hexdump(result, dlen);
+ ret = -EINVAL;
+ goto out;
+ }
+ else {
+ printk(KERN_ERR "alg: comp: Decompression test %d "
+ "passed for %s\n", i + 1, algo);
+ hexdump(result, dlen);
+ }
+ }
+
+ ret = 0;
+
+out:
+ return ret;
+}
+
+static int test_pcomp(struct crypto_pcomp *tfm,
+ struct pcomp_testvec *ctemplate,
+ struct pcomp_testvec *dtemplate, int ctcount,
+ int dtcount)
+{
+ const char *algo = crypto_tfm_alg_driver_name(crypto_pcomp_tfm(tfm));
+ unsigned int i;
+ char result[COMP_BUF_SIZE];
+ int res;
+
+ for (i = 0; i < ctcount; i++) {
+ struct comp_request req;
+ unsigned int produced = 0;
+
+ res = crypto_compress_setup(tfm, ctemplate[i].params,
+ ctemplate[i].paramsize);
+ if (res) {
+ pr_err("alg: pcomp: compression setup failed on test "
+ "%d for %s: error=%d\n", i + 1, algo, res);
+ return res;
+ }
+
+ res = crypto_compress_init(tfm);
+ if (res) {
+ pr_err("alg: pcomp: compression init failed on test "
+ "%d for %s: error=%d\n", i + 1, algo, res);
+ return res;
+ }
+
+ memset(result, 0, sizeof(result));
+
+ req.next_in = ctemplate[i].input;
+ req.avail_in = ctemplate[i].inlen / 2;
+ req.next_out = result;
+ req.avail_out = ctemplate[i].outlen / 2;
+
+ res = crypto_compress_update(tfm, &req);
+ if (res < 0 && (res != -EAGAIN || req.avail_in)) {
+ pr_err("alg: pcomp: compression update failed on test "
+ "%d for %s: error=%d\n", i + 1, algo, res);
+ return res;
+ }
+ if (res > 0)
+ produced += res;
+
+ /* Add remaining input data */
+ req.avail_in += (ctemplate[i].inlen + 1) / 2;
+
+ res = crypto_compress_update(tfm, &req);
+ if (res < 0 && (res != -EAGAIN || req.avail_in)) {
+ pr_err("alg: pcomp: compression update failed on test "
+ "%d for %s: error=%d\n", i + 1, algo, res);
+ return res;
+ }
+ if (res > 0)
+ produced += res;
+
+ /* Provide remaining output space */
+ req.avail_out += COMP_BUF_SIZE - ctemplate[i].outlen / 2;
+
+ res = crypto_compress_final(tfm, &req);
+ if (res < 0) {
+ pr_err("alg: pcomp: compression final failed on test "
+ "%d for %s: error=%d\n", i + 1, algo, res);
+ return res;
+ }
+ produced += res;
+
+ if (COMP_BUF_SIZE - req.avail_out != ctemplate[i].outlen) {
+ pr_err("alg: comp: Compression test %d failed for %s: "
+ "output len = %d (expected %d)\n", i + 1, algo,
+ COMP_BUF_SIZE - req.avail_out,
+ ctemplate[i].outlen);
+ return -EINVAL;
+ }
+
+ if (produced != ctemplate[i].outlen) {
+ pr_err("alg: comp: Compression test %d failed for %s: "
+ "returned len = %u (expected %d)\n", i + 1,
+ algo, produced, ctemplate[i].outlen);
+ return -EINVAL;
+ }
+
+ if (memcmp(result, ctemplate[i].output, ctemplate[i].outlen)) {
+ pr_err("alg: pcomp: Compression test %d failed for "
+ "%s\n", i + 1, algo);
+ hexdump(result, ctemplate[i].outlen);
+ return -EINVAL;
+ }
+ }
+
+ for (i = 0; i < dtcount; i++) {
+ struct comp_request req;
+ unsigned int produced = 0;
+
+ res = crypto_decompress_setup(tfm, dtemplate[i].params,
+ dtemplate[i].paramsize);
+ if (res) {
+ pr_err("alg: pcomp: decompression setup failed on "
+ "test %d for %s: error=%d\n", i + 1, algo, res);
+ return res;
+ }
+
+ res = crypto_decompress_init(tfm);
+ if (res) {
+ pr_err("alg: pcomp: decompression init failed on test "
+ "%d for %s: error=%d\n", i + 1, algo, res);
+ return res;
+ }
+
+ memset(result, 0, sizeof(result));
+
+ req.next_in = dtemplate[i].input;
+ req.avail_in = dtemplate[i].inlen / 2;
+ req.next_out = result;
+ req.avail_out = dtemplate[i].outlen / 2;
+
+ res = crypto_decompress_update(tfm, &req);
+ if (res < 0 && (res != -EAGAIN || req.avail_in)) {
+ pr_err("alg: pcomp: decompression update failed on "
+ "test %d for %s: error=%d\n", i + 1, algo, res);
+ return res;
+ }
+ if (res > 0)
+ produced += res;
+
+ /* Add remaining input data */
+ req.avail_in += (dtemplate[i].inlen + 1) / 2;
+
+ res = crypto_decompress_update(tfm, &req);
+ if (res < 0 && (res != -EAGAIN || req.avail_in)) {
+ pr_err("alg: pcomp: decompression update failed on "
+ "test %d for %s: error=%d\n", i + 1, algo, res);
+ return res;
+ }
+ if (res > 0)
+ produced += res;
+
+ /* Provide remaining output space */
+ req.avail_out += COMP_BUF_SIZE - dtemplate[i].outlen / 2;
+
+ res = crypto_decompress_final(tfm, &req);
+ if (res < 0 && (res != -EAGAIN || req.avail_in)) {
+ pr_err("alg: pcomp: decompression final failed on "
+ "test %d for %s: error=%d\n", i + 1, algo, res);
+ return res;
+ }
+ if (res > 0)
+ produced += res;
+
+ if (COMP_BUF_SIZE - req.avail_out != dtemplate[i].outlen) {
+ pr_err("alg: comp: Decompression test %d failed for "
+ "%s: output len = %d (expected %d)\n", i + 1,
+ algo, COMP_BUF_SIZE - req.avail_out,
+ dtemplate[i].outlen);
+ return -EINVAL;
+ }
+
+ if (produced != dtemplate[i].outlen) {
+ pr_err("alg: comp: Decompression test %d failed for "
+ "%s: returned len = %u (expected %d)\n", i + 1,
+ algo, produced, dtemplate[i].outlen);
+ return -EINVAL;
+ }
+
+ if (memcmp(result, dtemplate[i].output, dtemplate[i].outlen)) {
+ pr_err("alg: pcomp: Decompression test %d failed for "
+ "%s\n", i + 1, algo);
+ hexdump(result, dtemplate[i].outlen);
+ return -EINVAL;
+ }
+ }
+
+ return 0;
+}
+
+static int test_ablkcipher_jiffies(struct ablkcipher_request *req, int enc,
+ int sec, struct tcrypt_result *result,
+ int blen)
+{
+ unsigned long start, end;
+ int bcount;
+ int ret;
+
+ for (start = jiffies, end = start + sec * HZ, bcount = 0;
+ time_before(jiffies, end); bcount++) {
+
+ if (enc)
+ ret = crypto_ablkcipher_encrypt(req);
+ else
+ ret = crypto_ablkcipher_decrypt(req);
+
+ switch (ret) {
+ case 0:
+ break;
+ case -EINPROGRESS:
+ case -EBUSY:
+ ret = wait_for_completion_interruptible(
+ &result->completion);
+ if (!ret && !((ret = result->err))) {
+ INIT_COMPLETION(result->completion);
+ break;
+ }
+ default:
+ printk("ERROR\n");
+ return ret;
+ }
+ }
+
+ printk("%d operations in %d seconds (%ld bytes)\n",
+ bcount, sec, (long)bcount * blen);
+
+ return 0;
+}
+
+static int test_ablkcipher_cycles(struct ablkcipher_request *req, int enc,
+ int sec, struct tcrypt_result *result,
+ int blen)
+{
+ unsigned long cycles = 0;
+ int ret = 0;
+ int i;
+ unsigned long start, end = 0;
+ //local_bh_disable();
+ //local_irq_disable();
+ /* Warm-up run. */
+ for (i = 0; i < 4; i++) {
+ if (enc)
+ ret = crypto_ablkcipher_encrypt(req);
+ else
+ ret = crypto_ablkcipher_decrypt(req);
+
+ switch (ret) {
+ case 0:
+ break;
+ case -EINPROGRESS:
+ case -EBUSY:
+#if 0
+ ret = wait_for_completion_interruptible(
+ &result->completion);
+ if (!ret && !((ret = result->err))) {
+ INIT_COMPLETION(result->completion);
+ break;
+ }
+#else
+
+ wait_for_completion(&result->completion);
+ INIT_COMPLETION(result->completion);
+ break;
+#endif
+ default:
+ printk("ERROR\n");
+ return ret;
+ }
+
+ if (signal_pending(current)) {
+ printk("Signal caught\n");
+ break;
+ }
+
+ }
+
+ //printk("Debug ln: (%d), fn: %s\n", __LINE__, __func__);
+ /* The real thing. */
+ for (i = 0; i < 8; i++) {
+ end = 0;
+ start = 0;
+ start = read_c0_count();
+ if (enc)
+ ret = crypto_ablkcipher_encrypt(req);
+ else
+ ret = crypto_ablkcipher_decrypt(req);
+
+ switch (ret) {
+ case 0:
+ break;
+ case -EINPROGRESS:
+ case -EBUSY:
+#if 0
+ ret = wait_for_completion_interruptible(
+ &result->completion);
+ end = get_cycles();
+ if (!ret && !((ret = result->err))) {
+ INIT_COMPLETION(result->completion);
+ break;
+ }
+#else
+ wait_for_completion(&result->completion);
+ end = read_c0_count();
+ INIT_COMPLETION(result->completion);
+ break;
+#endif
+ default:
+ printk("ERROR\n");
+ return ret;
+ }
+
+ if (signal_pending(current)) {
+ printk("Signal caught\n");
+ break;
+ }
+
+ cycles += end - start;
+ }
+
+ // local_irq_enable();
+ // local_bh_enable();
+
+ printk("1 operation in %lu cycles (%d bytes)\n",
+ (cycles + 4) / 8, blen);
+
+ return 0;
+
+}
+
+static u32 b_size[] = {16, 64, 256, 1024, 8192, 0};
+
+static int test_skcipher_speed(struct crypto_ablkcipher *tfm, int enc,
+ struct cipher_speed_template *template,
+ unsigned int tcount, unsigned int sec,
+ u8* keysize)
+{
+ const char *algo =
+ crypto_tfm_alg_driver_name(crypto_ablkcipher_tfm(tfm));
+
+ unsigned int i = 0, j, iv_len;
+ struct ablkcipher_request *req;
+ //struct scatterlist sg[8];
+ const char *e;
+ struct tcrypt_result result;
+ char iv[MAX_IVLEN];
+ static char *xbuf[XBUFSIZE];
+ int ret = -ENOMEM;
+ u32 *block_size;
+ static char *tvmem_buf[4];
+ const char *key;
+
+ if (testmgr_alloc_buf(xbuf))
+ goto out_nobuf;
+
+ if (enc == ENCRYPT)
+ e = "encryption";
+ else
+ e = "decryption";
+
+ init_completion(&result.completion);
+
+ printk("Start ablkcipher speed test\n");
+
+ req = ablkcipher_request_alloc(tfm, GFP_KERNEL);
+ if (!req) {
+ printk(KERN_ERR "alg: skcipher: Failed to allocate request "
+ "for %s\n", algo);
+ goto out;
+ }
+
+// ablkcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG,
+ ablkcipher_request_set_callback(req, 0,
+ tcrypt_complete, &result);
+
+ do {
+
+ block_size = b_size;
+
+ do {
+ struct scatterlist sg[4];
+ if ((*keysize + *block_size) > 4 * PAGE_SIZE) {
+ printk("template (%u) too big for "
+ "tvmem_buf (%lu)\n", *keysize + *block_size,
+ 4 * PAGE_SIZE);
+ goto out;
+ }
+ crypto_ablkcipher_clear_flags(tfm, ~0);
+
+ printk("test %u (%d bit key, %d byte blocks): ", i,
+ *keysize * 8, *block_size);
+
+ memset(tvmem_buf[0], 0xff, PAGE_SIZE);
+ key = tvmem_buf[0];
+
+ for (j = 0; j < tcount; j++) {
+ if (template[j].klen == *keysize) {
+ key = template[j].key;
+ break;
+ }
+ }
+ ret = crypto_ablkcipher_setkey(tfm, key, *keysize);
+ if (ret) {
+ printk("Error setting of keys\n");
+ goto out;
+ }
+
+ sg_init_table(sg, 4);
+
+ for (j = 0; j < 4; j++) {
+ tvmem_buf[j] = xbuf[j];
+ memset(tvmem_buf[j], 0xff, PAGE_SIZE);
+ sg_set_buf(sg + j, tvmem_buf[j], PAGE_SIZE);
+ }
+
+ iv_len = crypto_ablkcipher_ivsize(tfm);
+ if (iv_len) {
+ memset(&iv, 0xff, iv_len);
+ }
+
+ ablkcipher_request_set_crypt(req, sg, sg,
+ *block_size, iv);
+
+ //printk("Debug ln: %d, %s\n", __LINE__, __func__);
+ if (sec)
+ ret = test_ablkcipher_jiffies(req, enc, sec,
+ &result, *block_size);
+ else
+ ret = test_ablkcipher_cycles(req, enc, sec,
+ &result, *block_size);
+
+
+ if (ret) {
+ printk(KERN_ERR "alg: skcipher: %s failed on "
+ "test %d for %s: ret=%d\n", e, j, algo,
+ -ret);
+ goto out;
+ }
+
+ block_size++;
+ i++;
+ } while (*block_size);
+ keysize++;
+ } while (*keysize);
+
+ ret = 0;
+out:
+ printk("End ablkcipher speed test\n");
+ ablkcipher_request_free(req);
+ testmgr_free_buf(xbuf);
+#if 0
+ if (!completion_done(&result->completion)) {
+ printk("There are threads waiting for completion, completing all\n");
+ complete_all(&result->completion);
+ }
+#endif
+
+ //testmgr_free_buf(tvbuf);
+out_nobuf:
+ return ret;
+
+}
+
+static int test_cprng(struct crypto_rng *tfm, struct cprng_testvec *template,
+ unsigned int tcount)
+{
+ const char *algo = crypto_tfm_alg_driver_name(crypto_rng_tfm(tfm));
+ int err = 0, i, j, seedsize;
+ u8 *seed;
+ char result[32];
+
+ seedsize = crypto_rng_seedsize(tfm);
+
+ seed = kmalloc(seedsize, GFP_KERNEL);
+ if (!seed) {
+ printk(KERN_ERR "alg: cprng: Failed to allocate seed space "
+ "for %s\n", algo);
+ return -ENOMEM;
+ }
+
+ for (i = 0; i < tcount; i++) {
+ memset(result, 0, 32);
+
+ memcpy(seed, template[i].v, template[i].vlen);
+ memcpy(seed + template[i].vlen, template[i].key,
+ template[i].klen);
+ memcpy(seed + template[i].vlen + template[i].klen,
+ template[i].dt, template[i].dtlen);
+
+ err = crypto_rng_reset(tfm, seed, seedsize);
+ if (err) {
+ printk(KERN_ERR "alg: cprng: Failed to reset rng "
+ "for %s\n", algo);
+ goto out;
+ }
+
+ for (j = 0; j < template[i].loops; j++) {
+ err = crypto_rng_get_bytes(tfm, result,
+ template[i].rlen);
+ if (err != template[i].rlen) {
+ printk(KERN_ERR "alg: cprng: Failed to obtain "
+ "the correct amount of random data for "
+ "%s (requested %d, got %d)\n", algo,
+ template[i].rlen, err);
+ goto out;
+ }
+ }
+
+ err = memcmp(result, template[i].result,
+ template[i].rlen);
+ if (err) {
+ printk(KERN_ERR "alg: cprng: Test %d failed for %s\n",
+ i, algo);
+ hexdump(result, template[i].rlen);
+ err = -EINVAL;
+ goto out;
+ }
+ }
+
+out:
+ kfree(seed);
+ return err;
+}
+
+static int alg_test_aead(const struct alg_test_desc *desc, const char *driver,
+ u32 type, u32 mask)
+{
+ struct crypto_aead *tfm;
+ int err = 0;
+
+ tfm = crypto_alloc_aead(driver, type, mask);
+ if (IS_ERR(tfm)) {
+ printk(KERN_ERR "alg: aead: Failed to load transform for %s: "
+ "%ld\n", driver, PTR_ERR(tfm));
+ return PTR_ERR(tfm);
+ }
+
+ if (desc->suite.aead.enc.vecs) {
+ err = test_aead(tfm, ENCRYPT, desc->suite.aead.enc.vecs,
+ desc->suite.aead.enc.count);
+ if (err)
+ goto out;
+ }
+
+ if (!err && desc->suite.aead.dec.vecs)
+ err = test_aead(tfm, DECRYPT, desc->suite.aead.dec.vecs,
+ desc->suite.aead.dec.count);
+
+out:
+ crypto_free_aead(tfm);
+ return err;
+}
+
+static int alg_test_cipher(const struct alg_test_desc *desc,
+ const char *driver, u32 type, u32 mask)
+{
+ struct crypto_cipher *tfm;
+ int err = 0;
+
+ tfm = crypto_alloc_cipher(driver, type, mask);
+ if (IS_ERR(tfm)) {
+ printk(KERN_ERR "alg: cipher: Failed to load transform for "
+ "%s: %ld\n", driver, PTR_ERR(tfm));
+ return PTR_ERR(tfm);
+ }
+
+ if (desc->suite.cipher.enc.vecs) {
+ err = test_cipher(tfm, ENCRYPT, desc->suite.cipher.enc.vecs,
+ desc->suite.cipher.enc.count);
+ if (err)
+ goto out;
+ }
+
+ if (desc->suite.cipher.dec.vecs)
+ err = test_cipher(tfm, DECRYPT, desc->suite.cipher.dec.vecs,
+ desc->suite.cipher.dec.count);
+
+out:
+ crypto_free_cipher(tfm);
+ return err;
+}
+
+static int alg_test_skcipher(const struct alg_test_desc *desc,
+ const char *driver, u32 type, u32 mask)
+{
+ struct crypto_ablkcipher *tfm;
+ int err = 0;
+
+ tfm = crypto_alloc_ablkcipher(driver, type, mask);
+ if (IS_ERR(tfm)) {
+ printk(KERN_ERR "alg: skcipher: Failed to load transform for "
+ "%s: %ld\n", driver, PTR_ERR(tfm));
+ return PTR_ERR(tfm);
+ }
+
+ if (desc->suite.cipher.enc.vecs) {
+ err = test_skcipher(tfm, ENCRYPT, desc->suite.cipher.enc.vecs,
+ desc->suite.cipher.enc.count);
+ if (err)
+ goto out;
+ }
+
+ if (desc->suite.cipher.dec.vecs)
+ err = test_skcipher(tfm, DECRYPT, desc->suite.cipher.dec.vecs,
+ desc->suite.cipher.dec.count);
+
+out:
+ crypto_free_ablkcipher(tfm);
+ return err;
+}
+
+static int alg_test_comp(const struct alg_test_desc *desc, const char *driver,
+ u32 type, u32 mask)
+{
+ struct crypto_comp *tfm;
+ int err;
+
+ tfm = crypto_alloc_comp(driver, type, mask);
+ if (IS_ERR(tfm)) {
+ printk(KERN_ERR "alg: comp: Failed to load transform for %s: "
+ "%ld\n", driver, PTR_ERR(tfm));
+ return PTR_ERR(tfm);
+ }
+
+ err = test_comp(tfm, desc->suite.comp.comp.vecs,
+ desc->suite.comp.decomp.vecs,
+ desc->suite.comp.comp.count,
+ desc->suite.comp.decomp.count);
+
+ crypto_free_comp(tfm);
+ return err;
+}
+
+static int alg_test_pcomp(const struct alg_test_desc *desc, const char *driver,
+ u32 type, u32 mask)
+{
+ struct crypto_pcomp *tfm;
+ int err;
+
+ tfm = crypto_alloc_pcomp(driver, type, mask);
+ if (IS_ERR(tfm)) {
+ pr_err("alg: pcomp: Failed to load transform for %s: %ld\n",
+ driver, PTR_ERR(tfm));
+ return PTR_ERR(tfm);
+ }
+
+ err = test_pcomp(tfm, desc->suite.pcomp.comp.vecs,
+ desc->suite.pcomp.decomp.vecs,
+ desc->suite.pcomp.comp.count,
+ desc->suite.pcomp.decomp.count);
+
+ crypto_free_pcomp(tfm);
+ return err;
+}
+
+static int alg_test_hash(const struct alg_test_desc *desc, const char *driver,
+ u32 type, u32 mask)
+{
+ struct crypto_ahash *tfm;
+ int err;
+
+ tfm = crypto_alloc_ahash(driver, type, mask);
+ if (IS_ERR(tfm)) {
+ printk(KERN_ERR "alg: hash: Failed to load transform for %s: "
+ "%ld\n", driver, PTR_ERR(tfm));
+ return PTR_ERR(tfm);
+ }
+
+ err = test_hash(tfm, desc->suite.hash.vecs, desc->suite.hash.count);
+
+ crypto_free_ahash(tfm);
+ return err;
+}
+
+static int alg_test_crc32c(const struct alg_test_desc *desc,
+ const char *driver, u32 type, u32 mask)
+{
+ struct crypto_shash *tfm;
+ u32 val;
+ int err;
+
+ err = alg_test_hash(desc, driver, type, mask);
+ if (err)
+ goto out;
+
+ tfm = crypto_alloc_shash(driver, type, mask);
+ if (IS_ERR(tfm)) {
+ printk(KERN_ERR "alg: crc32c: Failed to load transform for %s: "
+ "%ld\n", driver, PTR_ERR(tfm));
+ err = PTR_ERR(tfm);
+ goto out;
+ }
+
+ do {
+ struct {
+ struct shash_desc shash;
+ char ctx[crypto_shash_descsize(tfm)];
+ } sdesc;
+
+ sdesc.shash.tfm = tfm;
+ sdesc.shash.flags = 0;
+
+ *(u32 *)sdesc.ctx = le32_to_cpu(420553207);
+ err = crypto_shash_final(&sdesc.shash, (u8 *)&val);
+ if (err) {
+ printk(KERN_ERR "alg: crc32c: Operation failed for "
+ "%s: %d\n", driver, err);
+ break;
+ }
+
+ if (val != ~420553207) {
+ printk(KERN_ERR "alg: crc32c: Test failed for %s: "
+ "%d\n", driver, val);
+ err = -EINVAL;
+ }
+ } while (0);
+
+ crypto_free_shash(tfm);
+
+out:
+ return err;
+}
+
+static int alg_test_cprng(const struct alg_test_desc *desc, const char *driver,
+ u32 type, u32 mask)
+{
+ struct crypto_rng *rng;
+ int err = 0;
+
+ rng = crypto_alloc_rng(driver, type, mask);
+ if (IS_ERR(rng)) {
+ printk(KERN_ERR "alg: cprng: Failed to load transform for %s: "
+ "%ld\n", driver, PTR_ERR(rng));
+ return PTR_ERR(rng);
+ }
+
+ err = test_cprng(rng, desc->suite.cprng.vecs, desc->suite.cprng.count);
+
+ crypto_free_rng(rng);
+
+ return err;
+}
+
+/* Please keep this list sorted by algorithm name. */
+static const struct alg_test_desc alg_test_descs[] = {
+ {
+ .alg = "ansi_cprng",
+ .test = alg_test_cprng,
+ .fips_allowed = 1,
+ .suite = {
+ .cprng = {
+ .vecs = ansi_cprng_aes_tv_template,
+ .count = ANSI_CPRNG_AES_TEST_VECTORS
+ }
+ }
+ }, {
+ .alg = "cbc(aes)",
+ .test = alg_test_skcipher,
+ .fips_allowed = 1,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = aes_cbc_enc_tv_template,
+ .count = AES_CBC_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = aes_cbc_dec_tv_template,
+ .count = AES_CBC_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "cbc(anubis)",
+ .test = alg_test_skcipher,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = anubis_cbc_enc_tv_template,
+ .count = ANUBIS_CBC_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = anubis_cbc_dec_tv_template,
+ .count = ANUBIS_CBC_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "cbc(blowfish)",
+ .test = alg_test_skcipher,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = bf_cbc_enc_tv_template,
+ .count = BF_CBC_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = bf_cbc_dec_tv_template,
+ .count = BF_CBC_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "cbc(camellia)",
+ .test = alg_test_skcipher,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = camellia_cbc_enc_tv_template,
+ .count = CAMELLIA_CBC_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = camellia_cbc_dec_tv_template,
+ .count = CAMELLIA_CBC_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "cbc(des)",
+ .test = alg_test_skcipher,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = des_cbc_enc_tv_template,
+ .count = DES_CBC_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = des_cbc_dec_tv_template,
+ .count = DES_CBC_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "cbc(des3_ede)",
+ .test = alg_test_skcipher,
+ .fips_allowed = 1,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = des3_ede_cbc_enc_tv_template,
+ .count = DES3_EDE_CBC_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = des3_ede_cbc_dec_tv_template,
+ .count = DES3_EDE_CBC_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "cbc(twofish)",
+ .test = alg_test_skcipher,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = tf_cbc_enc_tv_template,
+ .count = TF_CBC_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = tf_cbc_dec_tv_template,
+ .count = TF_CBC_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "ccm(aes)",
+ .test = alg_test_aead,
+ .fips_allowed = 1,
+ .suite = {
+ .aead = {
+ .enc = {
+ .vecs = aes_ccm_enc_tv_template,
+ .count = AES_CCM_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = aes_ccm_dec_tv_template,
+ .count = AES_CCM_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "crc32c",
+ .test = alg_test_crc32c,
+ .fips_allowed = 1,
+ .suite = {
+ .hash = {
+ .vecs = crc32c_tv_template,
+ .count = CRC32C_TEST_VECTORS
+ }
+ }
+ }, {
+ .alg = "ctr(aes)",
+ .test = alg_test_skcipher,
+ .fips_allowed = 1,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = aes_ctr_enc_tv_template,
+ .count = AES_CTR_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = aes_ctr_dec_tv_template,
+ .count = AES_CTR_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "cts(cbc(aes))",
+ .test = alg_test_skcipher,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = cts_mode_enc_tv_template,
+ .count = CTS_MODE_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = cts_mode_dec_tv_template,
+ .count = CTS_MODE_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "deflate",
+ .test = alg_test_comp,
+ .suite = {
+ .comp = {
+ .comp = {
+ .vecs = deflate_comp_tv_template,
+ .count = DEFLATE_COMP_TEST_VECTORS
+ },
+ .decomp = {
+ .vecs = deflate_decomp_tv_template,
+ .count = DEFLATE_DECOMP_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "ecb(aes)",
+ .test = alg_test_skcipher,
+ .fips_allowed = 1,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = aes_enc_tv_template,
+ .count = AES_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = aes_dec_tv_template,
+ .count = AES_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "ecb(anubis)",
+ .test = alg_test_skcipher,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = anubis_enc_tv_template,
+ .count = ANUBIS_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = anubis_dec_tv_template,
+ .count = ANUBIS_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "ecb(arc4)",
+ .test = alg_test_skcipher,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = arc4_enc_tv_template,
+ .count = ARC4_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = arc4_dec_tv_template,
+ .count = ARC4_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "ecb(blowfish)",
+ .test = alg_test_skcipher,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = bf_enc_tv_template,
+ .count = BF_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = bf_dec_tv_template,
+ .count = BF_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "ecb(camellia)",
+ .test = alg_test_skcipher,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = camellia_enc_tv_template,
+ .count = CAMELLIA_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = camellia_dec_tv_template,
+ .count = CAMELLIA_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "ecb(cast5)",
+ .test = alg_test_skcipher,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = cast5_enc_tv_template,
+ .count = CAST5_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = cast5_dec_tv_template,
+ .count = CAST5_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "ecb(cast6)",
+ .test = alg_test_skcipher,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = cast6_enc_tv_template,
+ .count = CAST6_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = cast6_dec_tv_template,
+ .count = CAST6_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "ecb(des)",
+ .test = alg_test_skcipher,
+ .fips_allowed = 1,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = des_enc_tv_template,
+ .count = DES_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = des_dec_tv_template,
+ .count = DES_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "ecb(des3_ede)",
+ .test = alg_test_skcipher,
+ .fips_allowed = 1,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = des3_ede_enc_tv_template,
+ .count = DES3_EDE_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = des3_ede_dec_tv_template,
+ .count = DES3_EDE_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "ecb(khazad)",
+ .test = alg_test_skcipher,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = khazad_enc_tv_template,
+ .count = KHAZAD_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = khazad_dec_tv_template,
+ .count = KHAZAD_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "ecb(seed)",
+ .test = alg_test_skcipher,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = seed_enc_tv_template,
+ .count = SEED_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = seed_dec_tv_template,
+ .count = SEED_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "ecb(serpent)",
+ .test = alg_test_skcipher,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = serpent_enc_tv_template,
+ .count = SERPENT_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = serpent_dec_tv_template,
+ .count = SERPENT_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "ecb(tea)",
+ .test = alg_test_skcipher,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = tea_enc_tv_template,
+ .count = TEA_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = tea_dec_tv_template,
+ .count = TEA_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "ecb(tnepres)",
+ .test = alg_test_skcipher,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = tnepres_enc_tv_template,
+ .count = TNEPRES_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = tnepres_dec_tv_template,
+ .count = TNEPRES_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "ecb(twofish)",
+ .test = alg_test_skcipher,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = tf_enc_tv_template,
+ .count = TF_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = tf_dec_tv_template,
+ .count = TF_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "ecb(xeta)",
+ .test = alg_test_skcipher,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = xeta_enc_tv_template,
+ .count = XETA_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = xeta_dec_tv_template,
+ .count = XETA_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "ecb(xtea)",
+ .test = alg_test_skcipher,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = xtea_enc_tv_template,
+ .count = XTEA_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = xtea_dec_tv_template,
+ .count = XTEA_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "gcm(aes)",
+ .test = alg_test_aead,
+ .fips_allowed = 1,
+ .suite = {
+ .aead = {
+ .enc = {
+ .vecs = aes_gcm_enc_tv_template,
+ .count = AES_GCM_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = aes_gcm_dec_tv_template,
+ .count = AES_GCM_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "hmac(md5)",
+ .test = alg_test_hash,
+ .suite = {
+ .hash = {
+ .vecs = hmac_md5_tv_template,
+ .count = HMAC_MD5_TEST_VECTORS
+ }
+ }
+ }, {
+ .alg = "hmac(rmd128)",
+ .test = alg_test_hash,
+ .suite = {
+ .hash = {
+ .vecs = hmac_rmd128_tv_template,
+ .count = HMAC_RMD128_TEST_VECTORS
+ }
+ }
+ }, {
+ .alg = "hmac(rmd160)",
+ .test = alg_test_hash,
+ .suite = {
+ .hash = {
+ .vecs = hmac_rmd160_tv_template,
+ .count = HMAC_RMD160_TEST_VECTORS
+ }
+ }
+ }, {
+ .alg = "hmac(sha1)",
+ .test = alg_test_hash,
+ .fips_allowed = 1,
+ .suite = {
+ .hash = {
+ .vecs = hmac_sha1_tv_template,
+ .count = HMAC_SHA1_TEST_VECTORS
+ }
+ }
+ }, {
+ .alg = "hmac(sha224)",
+ .test = alg_test_hash,
+ .fips_allowed = 1,
+ .suite = {
+ .hash = {
+ .vecs = hmac_sha224_tv_template,
+ .count = HMAC_SHA224_TEST_VECTORS
+ }
+ }
+ }, {
+ .alg = "hmac(sha256)",
+ .test = alg_test_hash,
+ .fips_allowed = 1,
+ .suite = {
+ .hash = {
+ .vecs = hmac_sha256_tv_template,
+ .count = HMAC_SHA256_TEST_VECTORS
+ }
+ }
+ }, {
+ .alg = "hmac(sha384)",
+ .test = alg_test_hash,
+ .fips_allowed = 1,
+ .suite = {
+ .hash = {
+ .vecs = hmac_sha384_tv_template,
+ .count = HMAC_SHA384_TEST_VECTORS
+ }
+ }
+ }, {
+ .alg = "hmac(sha512)",
+ .test = alg_test_hash,
+ .fips_allowed = 1,
+ .suite = {
+ .hash = {
+ .vecs = hmac_sha512_tv_template,
+ .count = HMAC_SHA512_TEST_VECTORS
+ }
+ }
+#if !defined(CONFIG_CRYPTO_DEV_AES) && !defined(CONFIG_CRYPTO_ASYNC_AES)
+ }, {
+ .alg = "lrw(aes)",
+ .test = alg_test_skcipher,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = aes_lrw_enc_tv_template,
+ .count = AES_LRW_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = aes_lrw_dec_tv_template,
+ .count = AES_LRW_DEC_TEST_VECTORS
+ }
+ }
+ }
+#endif
+ }, {
+ .alg = "lzo",
+ .test = alg_test_comp,
+ .suite = {
+ .comp = {
+ .comp = {
+ .vecs = lzo_comp_tv_template,
+ .count = LZO_COMP_TEST_VECTORS
+ },
+ .decomp = {
+ .vecs = lzo_decomp_tv_template,
+ .count = LZO_DECOMP_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "md4",
+ .test = alg_test_hash,
+ .suite = {
+ .hash = {
+ .vecs = md4_tv_template,
+ .count = MD4_TEST_VECTORS
+ }
+ }
+ }, {
+ .alg = "md5",
+ .test = alg_test_hash,
+ .suite = {
+ .hash = {
+ .vecs = md5_tv_template,
+ .count = MD5_TEST_VECTORS
+ }
+ }
+ }, {
+ .alg = "michael_mic",
+ .test = alg_test_hash,
+ .suite = {
+ .hash = {
+ .vecs = michael_mic_tv_template,
+ .count = MICHAEL_MIC_TEST_VECTORS
+ }
+ }
+ }, {
+ .alg = "pcbc(fcrypt)",
+ .test = alg_test_skcipher,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = fcrypt_pcbc_enc_tv_template,
+ .count = FCRYPT_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = fcrypt_pcbc_dec_tv_template,
+ .count = FCRYPT_DEC_TEST_VECTORS
+ }
+ }
+ }
+
+ }, {
+ .alg = "rfc3686(ctr(aes))",
+ .test = alg_test_skcipher,
+ .fips_allowed = 1,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = aes_ctr_rfc3686_enc_tv_template,
+ .count = AES_CTR_3686_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = aes_ctr_rfc3686_dec_tv_template,
+ .count = AES_CTR_3686_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "rfc4309(ccm(aes))",
+ .test = alg_test_aead,
+ .fips_allowed = 1,
+ .suite = {
+ .aead = {
+ .enc = {
+ .vecs = aes_ccm_rfc4309_enc_tv_template,
+ .count = AES_CCM_4309_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = aes_ccm_rfc4309_dec_tv_template,
+ .count = AES_CCM_4309_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "rmd128",
+ .test = alg_test_hash,
+ .suite = {
+ .hash = {
+ .vecs = rmd128_tv_template,
+ .count = RMD128_TEST_VECTORS
+ }
+ }
+ }, {
+ .alg = "rmd160",
+ .test = alg_test_hash,
+ .suite = {
+ .hash = {
+ .vecs = rmd160_tv_template,
+ .count = RMD160_TEST_VECTORS
+ }
+ }
+ }, {
+ .alg = "rmd256",
+ .test = alg_test_hash,
+ .suite = {
+ .hash = {
+ .vecs = rmd256_tv_template,
+ .count = RMD256_TEST_VECTORS
+ }
+ }
+ }, {
+ .alg = "rmd320",
+ .test = alg_test_hash,
+ .suite = {
+ .hash = {
+ .vecs = rmd320_tv_template,
+ .count = RMD320_TEST_VECTORS
+ }
+ }
+ }, {
+ .alg = "salsa20",
+ .test = alg_test_skcipher,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = salsa20_stream_enc_tv_template,
+ .count = SALSA20_STREAM_ENC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "sha1",
+ .test = alg_test_hash,
+ .fips_allowed = 1,
+ .suite = {
+ .hash = {
+ .vecs = sha1_tv_template,
+ .count = SHA1_TEST_VECTORS
+ }
+ }
+ }, {
+ .alg = "sha224",
+ .test = alg_test_hash,
+ .fips_allowed = 1,
+ .suite = {
+ .hash = {
+ .vecs = sha224_tv_template,
+ .count = SHA224_TEST_VECTORS
+ }
+ }
+ }, {
+ .alg = "sha256",
+ .test = alg_test_hash,
+ .fips_allowed = 1,
+ .suite = {
+ .hash = {
+ .vecs = sha256_tv_template,
+ .count = SHA256_TEST_VECTORS
+ }
+ }
+ }, {
+ .alg = "sha384",
+ .test = alg_test_hash,
+ .fips_allowed = 1,
+ .suite = {
+ .hash = {
+ .vecs = sha384_tv_template,
+ .count = SHA384_TEST_VECTORS
+ }
+ }
+ }, {
+ .alg = "sha512",
+ .test = alg_test_hash,
+ .fips_allowed = 1,
+ .suite = {
+ .hash = {
+ .vecs = sha512_tv_template,
+ .count = SHA512_TEST_VECTORS
+ }
+ }
+ }, {
+ .alg = "tgr128",
+ .test = alg_test_hash,
+ .suite = {
+ .hash = {
+ .vecs = tgr128_tv_template,
+ .count = TGR128_TEST_VECTORS
+ }
+ }
+ }, {
+ .alg = "tgr160",
+ .test = alg_test_hash,
+ .suite = {
+ .hash = {
+ .vecs = tgr160_tv_template,
+ .count = TGR160_TEST_VECTORS
+ }
+ }
+ }, {
+ .alg = "tgr192",
+ .test = alg_test_hash,
+ .suite = {
+ .hash = {
+ .vecs = tgr192_tv_template,
+ .count = TGR192_TEST_VECTORS
+ }
+ }
+ }, {
+ .alg = "vmac(aes)",
+ .test = alg_test_hash,
+ .suite = {
+ .hash = {
+ .vecs = aes_vmac128_tv_template,
+ .count = VMAC_AES_TEST_VECTORS
+ }
+ }
+ }, {
+ .alg = "wp256",
+ .test = alg_test_hash,
+ .suite = {
+ .hash = {
+ .vecs = wp256_tv_template,
+ .count = WP256_TEST_VECTORS
+ }
+ }
+ }, {
+ .alg = "wp384",
+ .test = alg_test_hash,
+ .suite = {
+ .hash = {
+ .vecs = wp384_tv_template,
+ .count = WP384_TEST_VECTORS
+ }
+ }
+ }, {
+ .alg = "wp512",
+ .test = alg_test_hash,
+ .suite = {
+ .hash = {
+ .vecs = wp512_tv_template,
+ .count = WP512_TEST_VECTORS
+ }
+ }
+ }, {
+ .alg = "xcbc(aes)",
+ .test = alg_test_hash,
+ .suite = {
+ .hash = {
+ .vecs = aes_xcbc128_tv_template,
+ .count = XCBC_AES_TEST_VECTORS
+ }
+ }
+#if 0
+ }, {
+ .alg = "xts(aes)",
+ .test = alg_test_skcipher,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = aes_xts_enc_tv_template,
+ .count = AES_XTS_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = aes_xts_dec_tv_template,
+ .count = AES_XTS_DEC_TEST_VECTORS
+ }
+ }
+ }
+#endif
+ }, {
+ .alg = "zlib",
+ .test = alg_test_pcomp,
+ .suite = {
+ .pcomp = {
+ .comp = {
+ .vecs = zlib_comp_tv_template,
+ .count = ZLIB_COMP_TEST_VECTORS
+ },
+ .decomp = {
+ .vecs = zlib_decomp_tv_template,
+ .count = ZLIB_DECOMP_TEST_VECTORS
+ }
+ }
+ }
+ }
+};
+
+static int alg_find_test(const char *alg)
+{
+ int start = 0;
+ int end = ARRAY_SIZE(alg_test_descs);
+
+ while (start < end) {
+ int i = (start + end) / 2;
+ int diff = strcmp(alg_test_descs[i].alg, alg);
+
+ if (diff > 0) {
+ end = i;
+ continue;
+ }
+
+ if (diff < 0) {
+ start = i + 1;
+ continue;
+ }
+
+ return i;
+ }
+
+ return -1;
+}
+
+static int ifx_alg_test(const char *driver, const char *alg, u32 type, u32 mask)
+{
+ int i;
+ int j;
+ int rc;
+
+ if ((type & CRYPTO_ALG_TYPE_MASK) == CRYPTO_ALG_TYPE_CIPHER) {
+ char nalg[CRYPTO_MAX_ALG_NAME];
+
+ if (snprintf(nalg, sizeof(nalg), "ecb(%s)", alg) >=
+ sizeof(nalg))
+ return -ENAMETOOLONG;
+
+ i = alg_find_test(nalg);
+ if (i < 0)
+ goto notest;
+
+ if (fips_enabled && !alg_test_descs[i].fips_allowed)
+ goto non_fips_alg;
+
+ rc = alg_test_cipher(alg_test_descs + i, driver, type, mask);
+ goto test_done;
+ }
+
+ i = alg_find_test(alg);
+ j = alg_find_test(driver);
+ if (i < 0 && j < 0)
+ goto notest;
+
+ if (fips_enabled && ((i >= 0 && !alg_test_descs[i].fips_allowed) ||
+ (j >= 0 && !alg_test_descs[j].fips_allowed)))
+ goto non_fips_alg;
+
+ rc = 0;
+ if (i >= 0)
+ rc |= alg_test_descs[i].test(alg_test_descs + i, driver,
+ type, mask);
+ if (j >= 0)
+ rc |= alg_test_descs[j].test(alg_test_descs + j, driver,
+ type, mask);
+
+test_done:
+ if (fips_enabled && rc)
+ panic("%s: %s alg self test failed in fips mode!\n", driver, alg);
+
+ if (fips_enabled && !rc)
+ printk(KERN_INFO "alg: self-tests for %s (%s) passed\n",
+ driver, alg);
+
+ return rc;
+
+notest:
+ printk(KERN_INFO "alg: No test for %s (%s)\n", alg, driver);
+ return 0;
+non_fips_alg:
+ return -EINVAL;
+}
+EXPORT_SYMBOL_GPL(ifx_alg_test);
+
+/* Modified speed test for async block cipher mode*/
+
+static int ifx_alg_speed_test(const char *driver, const char *alg,
+ unsigned int sec,
+ struct cipher_speed_template *template,
+ unsigned int tcount, u8 *keysize)
+{
+ int i;
+ int j;
+ int err;
+ int type = 0, mask = 0;
+ struct crypto_ablkcipher *tfm;
+
+ i = alg_find_test(alg);
+ j = alg_find_test(driver);
+
+ if (i < 0 && j < 0)
+ goto notest;
+
+ if (fips_enabled && ((i >= 0 && !alg_test_descs[i].fips_allowed) ||
+ (j >= 0 && !alg_test_descs[j].fips_allowed)))
+ goto non_fips_alg;
+
+ tfm = crypto_alloc_ablkcipher(driver, type, mask);
+
+ if (IS_ERR(tfm)) {
+ printk(KERN_ERR "alg: skcipher: Failed to load transform for "
+ "%s: %ld\n", driver, PTR_ERR(tfm));
+ return PTR_ERR(tfm);
+ }
+ err = test_skcipher_speed(tfm, ENCRYPT, template,
+ tcount, sec, keysize);
+ if (err)
+ goto test_done;
+
+ err = test_skcipher_speed(tfm, DECRYPT, template,
+ tcount, sec, keysize);
+ if (!err)
+ goto test_done;
+
+notest:
+ return 0;
+non_fips_alg:
+ return -EINVAL;
+
+test_done:
+ if (fips_enabled && err)
+ panic("%s: %s alg self test failed in fips mode!\n", driver, alg);
+
+ if (fips_enabled && !err)
+ printk(KERN_INFO "alg: self-tests for %s (%s) passed\n",
+ driver, alg);
+
+ crypto_free_ablkcipher(tfm);
+ return err;
+}
+EXPORT_SYMBOL_GPL(ifx_alg_speed_test);
+
+
+static int test_cipher_jiffies(struct blkcipher_desc *desc, int enc,
+ struct scatterlist *sg, int blen, int sec)
+{
+ unsigned long start, end;
+ int bcount;
+ int ret;
+
+ for (start = jiffies, end = start + sec * HZ, bcount = 0;
+ time_before(jiffies, end); bcount++) {
+ if (enc)
+ ret = crypto_blkcipher_encrypt(desc, sg, sg, blen);
+ else
+ ret = crypto_blkcipher_decrypt(desc, sg, sg, blen);
+
+ if (ret)
+ return ret;
+ }
+
+ printk("%d operations in %d seconds (%ld bytes)\n",
+ bcount, sec, (long)bcount * blen);
+ return 0;
+}
+
+static int test_cipher_cycles(struct blkcipher_desc *desc, int enc,
+ struct scatterlist *sg, int blen)
+{
+ unsigned long cycles = 0;
+ unsigned long start, end;
+ int ret = 0;
+ int i;
+
+ local_bh_disable();
+ local_irq_disable();
+
+ /* Warm-up run. */
+ for (i = 0; i < 4; i++) {
+ if (enc)
+ ret = crypto_blkcipher_encrypt(desc, sg, sg, blen);
+ else
+ ret = crypto_blkcipher_decrypt(desc, sg, sg, blen);
+
+ if (ret)
+ goto out;
+ }
+
+ /* The real thing. */
+ for (i = 0; i < 8; i++) {
+ /* Original code to get cycles, does not work with MIPS
+ * cycles_t start, end;
+ * start = get_cycles();
+ */
+
+ start = read_c0_count(); // LQ modified tcrypt
+
+ if (enc)
+ ret = crypto_blkcipher_encrypt(desc, sg, sg, blen);
+ else
+ ret = crypto_blkcipher_decrypt(desc, sg, sg, blen);
+
+ /* Original code to get cycles, does not work with MIPS
+ * end = get_cycles();
+ */
+
+ end = read_c0_count(); //LQ modified tcrypt
+
+ if (ret)
+ goto out;
+
+ cycles += end - start;
+ }
+
+out:
+ local_irq_enable();
+ local_bh_enable();
+
+ if (ret == 0)
+ printk("1 operation in %lu cycles (%d bytes)\n",
+ (cycles + 4) / 8, blen);
+
+ return ret;
+}
+
+static u32 block_sizes[] = { 16, 64, 256, 1024, 8192, 0 };
+
+static void test_cipher_speed(const char *algo, int enc, unsigned int sec,
+ struct cipher_speed_template *template,
+ unsigned int tcount, u8 *keysize)
+{
+ unsigned int ret, i, j, iv_len;
+ const char *key, iv[128];
+ struct crypto_blkcipher *tfm;
+ struct blkcipher_desc desc;
+ const char *e;
+ u32 *b_size;
+
+ if (enc == ENCRYPT)
+ e = "encryption";
+ else
+ e = "decryption";
+
+ printk("\n ******* testing speed of %s %s ******* \n", algo, e);
+
+ tfm = crypto_alloc_blkcipher(algo, 0, CRYPTO_ALG_ASYNC);
+
+ if (IS_ERR(tfm)) {
+ printk("failed to load transform for %s: %ld\n", algo,
+ PTR_ERR(tfm));
+ return;
+ }
+ desc.tfm = tfm;
+ desc.flags = 0;
+
+ i = 0;
+ do {
+
+ b_size = block_sizes;
+ do {
+ struct scatterlist sg[TVMEMSIZE];
+
+ if ((*keysize + *b_size) > TVMEMSIZE * PAGE_SIZE) {
+ printk("template (%u) too big for "
+ "tvmem (%lu)\n", *keysize + *b_size,
+ TVMEMSIZE * PAGE_SIZE);
+ goto out;
+ }
+
+ printk("test %u (%d bit key, %d byte blocks): ", i,
+ *keysize * 8, *b_size);
+
+ memset(tvmem[0], 0xff, PAGE_SIZE);
+
+ /* set key, plain text and IV */
+ key = tvmem[0];
+ for (j = 0; j < tcount; j++) {
+ if (template[j].klen == *keysize) {
+ key = template[j].key;
+ break;
+ }
+ }
+
+ ret = crypto_blkcipher_setkey(tfm, key, *keysize);
+ if (ret) {
+ printk("setkey() failed flags=%x\n",
+ crypto_blkcipher_get_flags(tfm));
+ goto out;
+ }
+
+ sg_init_table(sg, TVMEMSIZE);
+ sg_set_buf(sg, tvmem[0] + *keysize,
+ PAGE_SIZE - *keysize);
+ for (j = 1; j < TVMEMSIZE; j++) {
+ sg_set_buf(sg + j, tvmem[j], PAGE_SIZE);
+ memset (tvmem[j], 0xff, PAGE_SIZE);
+ }
+
+ iv_len = crypto_blkcipher_ivsize(tfm);
+ if (iv_len) {
+ memset(&iv, 0xff, iv_len);
+ crypto_blkcipher_set_iv(tfm, iv, iv_len);
+ }
+
+ if (sec)
+ ret = test_cipher_jiffies(&desc, enc, sg,
+ *b_size, sec);
+ else
+ ret = test_cipher_cycles(&desc, enc, sg,
+ *b_size);
+
+ if (ret) {
+ printk("%s() failed flags=%x\n", e, desc.flags);
+ break;
+ }
+ b_size++;
+ i++;
+ } while (*b_size);
+ keysize++;
+ } while (*keysize);
+
+out:
+ crypto_free_blkcipher(tfm);
+}
+
+static int test_hash_jiffies_digest(struct hash_desc *desc,
+ struct scatterlist *sg, int blen,
+ char *out, int sec)
+{
+ unsigned long start, end;
+ int bcount;
+ int ret;
+
+ for (start = jiffies, end = start + sec * HZ, bcount = 0;
+ time_before(jiffies, end); bcount++) {
+ ret = crypto_hash_digest(desc, sg, blen, out);
+ if (ret)
+ return ret;
+ }
+
+ printk("%6u opers/sec, %9lu bytes/sec\n",
+ bcount / sec, ((long)bcount * blen) / sec);
+
+ return 0;
+}
+
+static int test_hash_jiffies(struct hash_desc *desc, struct scatterlist *sg,
+ int blen, int plen, char *out, int sec)
+{
+ unsigned long start, end;
+ int bcount, pcount;
+ int ret;
+
+ if (plen == blen)
+ return test_hash_jiffies_digest(desc, sg, blen, out, sec);
+
+ for (start = jiffies, end = start + sec * HZ, bcount = 0;
+ time_before(jiffies, end); bcount++) {
+ ret = crypto_hash_init(desc);
+ if (ret)
+ return ret;
+ for (pcount = 0; pcount < blen; pcount += plen) {
+ ret = crypto_hash_update(desc, sg, plen);
+ if (ret)
+ return ret;
+ }
+ /* we assume there is enough space in 'out' for the result */
+ ret = crypto_hash_final(desc, out);
+ if (ret)
+ return ret;
+ }
+
+ printk("%6u opers/sec, %9lu bytes/sec\n",
+ bcount / sec, ((long)bcount * blen) / sec);
+
+ return 0;
+}
+
+static int test_hash_cycles_digest(struct hash_desc *desc,
+ struct scatterlist *sg, int blen, char *out)
+{
+ unsigned long cycles = 0;
+ unsigned long start, end;
+ int i;
+ int ret;
+
+ local_bh_disable();
+ local_irq_disable();
+
+ /* Warm-up run. */
+ for (i = 0; i < 4; i++) {
+ ret = crypto_hash_digest(desc, sg, blen, out);
+ if (ret)
+ goto out;
+ }
+
+ /* The real thing. */
+ for (i = 0; i < 8; i++) {
+
+ /* Original code to get cycles, does not work with MIPS
+ * cycles_t start, end;
+ * start = get_cycles();
+ */
+
+ start = read_c0_count(); // LQ modified tcrypt
+
+ ret = crypto_hash_digest(desc, sg, blen, out);
+ if (ret)
+ goto out;
+
+ /* Original code to get cycles, does not work with MIPS
+ * end = get_cycles();
+ */
+
+ end = read_c0_count(); // LQ modified tcrypt
+
+ cycles += end - start;
+ }
+
+out:
+ local_irq_enable();
+ local_bh_enable();
+
+ if (ret)
+ return ret;
+
+ printk("%6lu cycles/operation, %4lu cycles/byte\n",
+ cycles / 8, cycles / (8 * blen));
+
+ return 0;
+}
+
+static int test_hash_cycles(struct hash_desc *desc, struct scatterlist *sg,
+ int blen, int plen, char *out)
+{
+ unsigned long cycles = 0;
+ unsigned long start, end;
+ int i, pcount;
+ int ret;
+
+ if (plen == blen)
+ return test_hash_cycles_digest(desc, sg, blen, out);
+
+ local_bh_disable();
+ local_irq_disable();
+
+ /* Warm-up run. */
+ for (i = 0; i < 4; i++) {
+ ret = crypto_hash_init(desc);
+ if (ret)
+ goto out;
+ for (pcount = 0; pcount < blen; pcount += plen) {
+ ret = crypto_hash_update(desc, sg, plen);
+ if (ret)
+ goto out;
+ }
+ ret = crypto_hash_final(desc, out);
+ if (ret)
+ goto out;
+ }
+
+ /* The real thing. */
+ for (i = 0; i < 8; i++) {
+
+ /* Original code for getting cycles, not working for MIPS
+ * cycle_t start, end;
+ * end = get_cycles();
+ */
+
+ start = read_c0_count(); // LQ modified tcrypt
+
+ ret = crypto_hash_init(desc);
+ if (ret)
+ goto out;
+ for (pcount = 0; pcount < blen; pcount += plen) {
+ ret = crypto_hash_update(desc, sg, plen);
+ if (ret)
+ goto out;
+ }
+ ret = crypto_hash_final(desc, out);
+ if (ret)
+ goto out;
+
+ /* Original code for getting cycles, not working for MIPS
+ * end = get_cycles();
+ */
+
+ end = read_c0_count(); // LQ modified tcrypt
+
+ cycles += end - start;
+ }
+
+out:
+ local_irq_enable();
+ local_bh_enable();
+
+ if (ret)
+ return ret;
+
+ printk("%6lu cycles/operation, %4lu cycles/byte\n",
+ cycles / 8, cycles / (8 * blen));
+
+ return 0;
+}
+
+static void test_hash_speed(const char *algo, unsigned int sec,
+ struct hash_speed *speed)
+{
+ struct scatterlist sg[TVMEMSIZE];
+ struct crypto_hash *tfm;
+ struct hash_desc desc;
+ static char output[1024];
+ int i;
+ int ret;
+
+ printk(KERN_INFO "\ntesting speed of %s\n", algo);
+
+ tfm = crypto_alloc_hash(algo, 0, CRYPTO_ALG_ASYNC);
+
+ if (IS_ERR(tfm)) {
+ printk(KERN_ERR "failed to load transform for %s: %ld\n", algo,
+ PTR_ERR(tfm));
+ return;
+ }
+
+ desc.tfm = tfm;
+ desc.flags = 0;
+
+ if (crypto_hash_digestsize(tfm) > sizeof(output)) {
+ printk(KERN_ERR "digestsize(%u) > outputbuffer(%zu)\n",
+ crypto_hash_digestsize(tfm), sizeof(output));
+ goto out;
+ }
+
+ sg_init_table(sg, TVMEMSIZE);
+ for (i = 0; i < TVMEMSIZE; i++) {
+ sg_set_buf(sg + i, tvmem[i], PAGE_SIZE);
+ memset(tvmem[i], 0xff, PAGE_SIZE);
+ }
+
+ for (i = 0; speed[i].blen != 0; i++) {
+ if (speed[i].blen > TVMEMSIZE * PAGE_SIZE) {
+ printk(KERN_ERR
+ "template (%u) too big for tvmem (%lu)\n",
+ speed[i].blen, TVMEMSIZE * PAGE_SIZE);
+ goto out;
+ }
+
+ printk(KERN_INFO "test%3u "
+ "(%5u byte blocks,%5u bytes per update,%4u updates): ",
+ i, speed[i].blen, speed[i].plen, speed[i].blen / speed[i].plen);
+
+ if (sec)
+ ret = test_hash_jiffies(&desc, sg, speed[i].blen,
+ speed[i].plen, output, sec);
+ else
+ ret = test_hash_cycles(&desc, sg, speed[i].blen,
+ speed[i].plen, output);
+
+ if (ret) {
+ printk(KERN_ERR "hashing failed ret=%d\n", ret);
+ break;
+ }
+ }
+
+out:
+ crypto_free_hash(tfm);
+}
+
+
+static void test_available(void)
+{
+ char **name = check;
+
+ while (*name) {
+ printk("alg %s ", *name);
+ printk(crypto_has_alg(*name, 0, 0) ?
+ "found\n" : "not found\n");
+ name++;
+ }
+}
+
+static inline int tcrypt_test(const char *alg)
+{
+ int ret;
+
+ printk("Running test %s\n", alg);
+ ret = ifx_alg_test(alg, alg, 0, 0);
+ /* non-fips algs return -EINVAL in fips mode */
+ if (fips_enabled && ret == -EINVAL)
+ ret = 0;
+ return ret;
+}
+
+static inline int tcrypt_speedtest(const char *alg,
+ struct cipher_speed_template *template,
+ unsigned int tcount, u8 *keysize)
+{
+ int ret;
+
+ printk("[****** Running speedtest %s *******]\n", alg);
+ ret = ifx_alg_speed_test(alg, alg, sec, template, tcount, keysize);
+ if (fips_enabled && ret == -EINVAL)
+ ret = 0;
+ return ret;
+}
+
+
+static int do_test(int m)
+{
+ int i;
+ int ret = 0;
+
+ switch (m) {
+ case 0:
+ for (i = 1; i < 200; i++)
+ ret += do_test(i);
+ break;
+
+ case 1:
+ ret += tcrypt_test("md5");
+ break;
+
+ case 2:
+ ret += tcrypt_test("sha1");
+ break;
+
+ case 3:
+ ret += tcrypt_test("ecb(des)");
+ ret += tcrypt_test("cbc(des)");
+ break;
+
+ case 4:
+ ret += tcrypt_test("ecb(des3_ede)");
+ ret += tcrypt_test("cbc(des3_ede)");
+ break;
+
+ case 5:
+ ret += tcrypt_test("md4");
+ break;
+
+ case 6:
+ ret += tcrypt_test("sha256");
+ break;
+
+ case 7:
+ ret += tcrypt_test("ecb(blowfish)");
+ ret += tcrypt_test("cbc(blowfish)");
+ break;
+
+ case 8:
+ ret += tcrypt_test("ecb(twofish)");
+ ret += tcrypt_test("cbc(twofish)");
+ break;
+
+ case 9:
+ ret += tcrypt_test("ecb(serpent)");
+ break;
+
+ case 10:
+ ret += tcrypt_test("ecb(aes)");
+ ret += tcrypt_test("cbc(aes)");
+ // ret += tcrypt_test("lrw(aes)");
+ // ret += tcrypt_test("xts(aes)");
+ ret += tcrypt_test("ctr(aes)");
+ ret += tcrypt_test("rfc3686(ctr(aes))");
+ break;
+
+ case 11:
+ ret += tcrypt_test("sha384");
+ break;
+
+ case 12:
+ ret += tcrypt_test("sha512");
+ break;
+
+ case 13:
+ ret += tcrypt_test("deflate");
+ break;
+
+ case 14:
+ ret += tcrypt_test("ecb(cast5)");
+ break;
+
+ case 15:
+ ret += tcrypt_test("ecb(cast6)");
+ break;
+
+ case 16:
+ ret += tcrypt_test("ecb(arc4)");
+ break;
+
+ case 17:
+ ret += tcrypt_test("michael_mic");
+ break;
+
+ case 18:
+ ret += tcrypt_test("crc32c");
+ break;
+
+ case 19:
+ ret += tcrypt_test("ecb(tea)");
+ break;
+
+ case 20:
+ ret += tcrypt_test("ecb(xtea)");
+ break;
+
+ case 21:
+ ret += tcrypt_test("ecb(khazad)");
+ break;
+
+ case 22:
+ ret += tcrypt_test("wp512");
+ break;
+
+ case 23:
+ ret += tcrypt_test("wp384");
+ break;
+
+ case 24:
+ ret += tcrypt_test("wp256");
+ break;
+
+ case 25:
+ ret += tcrypt_test("ecb(tnepres)");
+ break;
+
+ case 26:
+ ret += tcrypt_test("ecb(anubis)");
+ ret += tcrypt_test("cbc(anubis)");
+ break;
+
+ case 27:
+ ret += tcrypt_test("tgr192");
+ break;
+
+ case 28:
+
+ ret += tcrypt_test("tgr160");
+ break;
+
+ case 29:
+ ret += tcrypt_test("tgr128");
+ break;
+
+ case 30:
+ ret += tcrypt_test("ecb(xeta)");
+ break;
+
+ case 31:
+ ret += tcrypt_test("pcbc(fcrypt)");
+ break;
+
+ case 32:
+ ret += tcrypt_test("ecb(camellia)");
+ ret += tcrypt_test("cbc(camellia)");
+ break;
+ case 33:
+ ret += tcrypt_test("sha224");
+ break;
+
+ case 34:
+ ret += tcrypt_test("salsa20");
+ break;
+
+ case 35:
+ ret += tcrypt_test("gcm(aes)");
+ break;
+
+ case 36:
+ ret += tcrypt_test("lzo");
+ break;
+
+ case 37:
+ ret += tcrypt_test("ccm(aes)");
+ break;
+
+ case 38:
+ ret += tcrypt_test("cts(cbc(aes))");
+ break;
+
+ case 39:
+ ret += tcrypt_test("rmd128");
+ break;
+
+ case 40:
+ ret += tcrypt_test("rmd160");
+ break;
+
+ case 41:
+ ret += tcrypt_test("rmd256");
+ break;
+
+ case 42:
+ ret += tcrypt_test("rmd320");
+ break;
+
+ case 43:
+ ret += tcrypt_test("ecb(seed)");
+ break;
+
+ case 44:
+ ret += tcrypt_test("zlib");
+ break;
+
+ case 45:
+ ret += tcrypt_test("rfc4309(ccm(aes))");
+ break;
+
+ case 100:
+ ret += tcrypt_test("hmac(md5)");
+ break;
+
+ case 101:
+ ret += tcrypt_test("hmac(sha1)");
+ break;
+
+ case 102:
+ ret += tcrypt_test("hmac(sha256)");
+ break;
+
+ case 103:
+ ret += tcrypt_test("hmac(sha384)");
+ break;
+
+ case 104:
+ ret += tcrypt_test("hmac(sha512)");
+ break;
+
+ case 105:
+ ret += tcrypt_test("hmac(sha224)");
+ break;
+
+ case 106:
+ ret += tcrypt_test("xcbc(aes)");
+ break;
+
+ case 107:
+ ret += tcrypt_test("hmac(rmd128)");
+ break;
+
+ case 108:
+ ret += tcrypt_test("hmac(rmd160)");
+ break;
+
+ case 109:
+ ret += tcrypt_test("vmac(aes)");
+ break;
+
+ case 150:
+ ret += tcrypt_test("ansi_cprng");
+ break;
+
+ case 200:
+ test_cipher_speed("ecb(aes)", ENCRYPT, sec, NULL, 0,
+ speed_template_16_24_32);
+ test_cipher_speed("ecb(aes)", DECRYPT, sec, NULL, 0,
+ speed_template_16_24_32);
+ test_cipher_speed("cbc(aes)", ENCRYPT, sec, NULL, 0,
+ speed_template_16_24_32);
+ test_cipher_speed("cbc(aes)", DECRYPT, sec, NULL, 0,
+ speed_template_16_24_32);
+#if !defined(CONFIG_CRYPTO_DEV_AES) && !defined(CONFIG_CRYPTO_ASYNC_AES)
+ test_cipher_speed("lrw(aes)", ENCRYPT, sec, NULL, 0,
+ speed_template_32_40_48);
+ test_cipher_speed("lrw(aes)", DECRYPT, sec, NULL, 0,
+ speed_template_32_40_48);
+ test_cipher_speed("xts(aes)", ENCRYPT, sec, NULL, 0,
+ speed_template_32_48_64);
+ test_cipher_speed("xts(aes)", DECRYPT, sec, NULL, 0,
+ speed_template_32_48_64);
+#endif
+ break;
+
+ case 201:
+ test_cipher_speed("ecb(des3_ede)", ENCRYPT, sec,
+ des3_speed_template, DES3_SPEED_VECTORS,
+ speed_template_24);
+ test_cipher_speed("ecb(des3_ede)", DECRYPT, sec,
+ des3_speed_template, DES3_SPEED_VECTORS,
+ speed_template_24);
+ test_cipher_speed("cbc(des3_ede)", ENCRYPT, sec,
+ des3_speed_template, DES3_SPEED_VECTORS,
+ speed_template_24);
+ test_cipher_speed("cbc(des3_ede)", DECRYPT, sec,
+ des3_speed_template, DES3_SPEED_VECTORS,
+ speed_template_24);
+ break;
+
+ case 202:
+ test_cipher_speed("ecb(twofish)", ENCRYPT, sec, NULL, 0,
+ speed_template_16_24_32);
+ test_cipher_speed("ecb(twofish)", DECRYPT, sec, NULL, 0,
+ speed_template_16_24_32);
+ test_cipher_speed("cbc(twofish)", ENCRYPT, sec, NULL, 0,
+ speed_template_16_24_32);
+ test_cipher_speed("cbc(twofish)", DECRYPT, sec, NULL, 0,
+ speed_template_16_24_32);
+ break;
+
+ case 203:
+ test_cipher_speed("ecb(blowfish)", ENCRYPT, sec, NULL, 0,
+ speed_template_8_32);
+ test_cipher_speed("ecb(blowfish)", DECRYPT, sec, NULL, 0,
+ speed_template_8_32);
+ test_cipher_speed("cbc(blowfish)", ENCRYPT, sec, NULL, 0,
+ speed_template_8_32);
+ test_cipher_speed("cbc(blowfish)", DECRYPT, sec, NULL, 0,
+ speed_template_8_32);
+ break;
+
+ case 204:
+ test_cipher_speed("ecb(des)", ENCRYPT, sec, NULL, 0,
+ speed_template_8);
+ test_cipher_speed("ecb(des)", DECRYPT, sec, NULL, 0,
+ speed_template_8);
+ test_cipher_speed("cbc(des)", ENCRYPT, sec, NULL, 0,
+ speed_template_8);
+ test_cipher_speed("cbc(des)", DECRYPT, sec, NULL, 0,
+ speed_template_8);
+ break;
+
+ case 205:
+ test_cipher_speed("ecb(camellia)", ENCRYPT, sec, NULL, 0,
+ speed_template_16_24_32);
+ test_cipher_speed("ecb(camellia)", DECRYPT, sec, NULL, 0,
+ speed_template_16_24_32);
+ test_cipher_speed("cbc(camellia)", ENCRYPT, sec, NULL, 0,
+ speed_template_16_24_32);
+ test_cipher_speed("cbc(camellia)", DECRYPT, sec, NULL, 0,
+ speed_template_16_24_32);
+ break;
+
+ case 206:
+ test_cipher_speed("salsa20", ENCRYPT, sec, NULL, 0,
+ speed_template_16_32);
+ break;
+
+ case 300:
+ /* fall through */
+
+ case 301:
+ test_hash_speed("md4", sec, generic_hash_speed_template);
+ if (mode > 300 && mode < 400) break;
+
+ case 302:
+ test_hash_speed("md5", sec, generic_hash_speed_template);
+ if (mode > 300 && mode < 400) break;
+
+ case 303:
+ test_hash_speed("sha1", sec, generic_hash_speed_template);
+ if (mode > 300 && mode < 400) break;
+
+ case 304:
+ test_hash_speed("sha256", sec, generic_hash_speed_template);
+ if (mode > 300 && mode < 400) break;
+
+ case 305:
+ test_hash_speed("sha384", sec, generic_hash_speed_template);
+ if (mode > 300 && mode < 400) break;
+
+ case 306:
+ test_hash_speed("sha512", sec, generic_hash_speed_template);
+ if (mode > 300 && mode < 400) break;
+
+ case 307:
+ test_hash_speed("wp256", sec, generic_hash_speed_template);
+ if (mode > 300 && mode < 400) break;
+
+ case 308:
+ test_hash_speed("wp384", sec, generic_hash_speed_template);
+ if (mode > 300 && mode < 400) break;
+
+ case 309:
+ test_hash_speed("wp512", sec, generic_hash_speed_template);
+ if (mode > 300 && mode < 400) break;
+
+ case 310:
+ test_hash_speed("tgr128", sec, generic_hash_speed_template);
+ if (mode > 300 && mode < 400) break;
+
+ case 311:
+ test_hash_speed("tgr160", sec, generic_hash_speed_template);
+ if (mode > 300 && mode < 400) break;
+
+ case 312:
+ test_hash_speed("tgr192", sec, generic_hash_speed_template);
+ if (mode > 300 && mode < 400) break;
+
+ case 313:
+ test_hash_speed("sha224", sec, generic_hash_speed_template);
+ if (mode > 300 && mode < 400) break;
+
+ case 314:
+ test_hash_speed("rmd128", sec, generic_hash_speed_template);
+ if (mode > 300 && mode < 400) break;
+
+ case 315:
+ test_hash_speed("rmd160", sec, generic_hash_speed_template);
+ if (mode > 300 && mode < 400) break;
+
+ case 316:
+ test_hash_speed("rmd256", sec, generic_hash_speed_template);
+ if (mode > 300 && mode < 400) break;
+
+ case 317:
+ test_hash_speed("rmd320", sec, generic_hash_speed_template);
+ if (mode > 300 && mode < 400) break;
+
+ case 399:
+ break;
+
+ /* Modified speed test for async block cipher mode */
+ case 400:
+ tcrypt_speedtest("ecb(aes)", NULL, 0,
+ speed_template_16_24_32);
+ tcrypt_speedtest("cbc(aes)", NULL, 0,
+ speed_template_16_24_32);
+ break;
+
+ case 401:
+ tcrypt_speedtest("ecb(des3_ede)", des3_speed_template,
+ DES3_SPEED_VECTORS,speed_template_24);
+ tcrypt_speedtest("cbc(des3_ede)", des3_speed_template,
+ DES3_SPEED_VECTORS,speed_template_24);
+ break;
+
+ case 404:
+ tcrypt_speedtest("ecb(des)", NULL, 0,
+ speed_template_8);
+ tcrypt_speedtest("cbc(des)", NULL, 0,
+ speed_template_8);
+ break;
+
+ case 1000:
+ test_available();
+ break;
+ }
+
+ return ret;
+}
+#if !defined(CONFIG_CRYPTO_DEV_DEU)
+static int do_alg_test(const char *alg, u32 type, u32 mask)
+{
+ return crypto_has_alg(alg, type, mask ?: CRYPTO_ALG_TYPE_MASK) ?
+ 0 : -ENOENT;
+}
+#endif
+
+static int __init tcrypt_mod_init(void)
+{
+ int err = -ENOMEM;
+ int i;
+
+ printk("Starting Lantiq DEU Crypto TESTS . . . . . . .\n");
+
+ for (i = 0; i < TVMEMSIZE; i++) {
+ tvmem[i] = (void *)__get_free_page(GFP_KERNEL);
+ if (!tvmem[i])
+ goto err_free_tv;
+ }
+
+#if defined(CONFIG_CRYPTO_DEV_DEU)
+#if defined(CONFIG_CRYPTO_DEV_MD5)
+ mode = 1; // test md5 only
+ err = do_test(mode);
+ if (err)
+ goto md5_err;
+
+md5_err:
+ if (err) {
+ printk(KERN_ERR "md5: one or more tests failed!\n");
+ goto err_free_tv;
+ }
+#endif
+#if defined(CONFIG_CRYPTO_DEV_SHA1)
+ mode = 2; // test sha1 only
+ err = do_test(mode);
+ if (err)
+ goto sha1_err;
+
+sha1_err:
+ if (err) {
+ printk(KERN_ERR "sha1: one or more tests failed!\n");
+ goto err_free_tv;
+ }
+#endif
+#if defined (CONFIG_CRYPTO_DEV_DES) || defined (CONFIG_CRYPTO_ASYNC_DES)
+ mode = 3; // test des only
+ err = do_test(mode);
+ if (err)
+ goto des_err;
+
+ mode = 4; // test des3 only
+ err = do_test(mode);
+ if (err)
+ goto des_err;
+
+des_err:
+ if (err) {
+ printk(KERN_ERR "des3: one or more tests failed!\n");
+ goto err_free_tv;
+ }
+#endif
+#if defined (CONFIG_CRYPTO_ASYNC_AES) || defined (CONFIG_CRYPTO_DEV_AES)
+ mode = 10; // test aes only
+ err = do_test(mode);
+ if (err)
+ goto aes_err;
+
+aes_err:
+ if (err) {
+ printk(KERN_ERR "aes: one or more tests failed!\n");
+ goto err_free_tv;
+ }
+#endif
+#if defined(CONFIG_CRYPTO_DEV_ARC4)
+ mode = 16;
+ err = do_test(mode);
+
+ if (err) {
+ printk(KERN_ERR "arc4: one or more tests failed!\n");
+ goto err_free_tv;
+ }
+#endif
+#if defined (CONFIG_CRYPTO_DEV_MD5_HMAC)
+ mode = 100;
+ err = do_test(mode);
+
+ if (err) {
+ printk(KERN_ERR "tcrypt: one or more tests failed!\n");
+ goto err_free_tv;
+ }
+#endif
+#if defined (CONFIG_CRYPTO_DEV_SHA1_HMAC)
+ mode = 101;
+ err = do_test(mode);
+
+ if (err) {
+ printk(KERN_ERR "tcrypt: one or more tests failed!\n");
+ goto err_free_tv;
+ }
+#endif
+
+/* Start Speed tests test modes */
+#if defined(CONFIG_CRYPTO_DEV_SPEED_TEST)
+#if defined(CONFIG_CRYPTO_DEV_AES)
+ mode = 200;
+ err = do_test(mode);
+ if (err)
+ goto speed_err;
+#endif
+#if defined (CONFIG_CRYPTO_DEV_DES)
+ mode = 201;
+ err = do_test(mode);
+ if (err)
+ goto speed_err;
+
+ mode = 204;
+ err = do_test(mode);
+ if (err)
+ goto speed_err;
+#endif
+#if defined (CONFIG_CRYPTO_DEV_MD5)
+ mode = 302;
+ err = do_test(mode);
+ if (err)
+ goto speed_err;
+#endif
+#if defined (CONFIG_CRYPTO_DEV_SHA1)
+ mode = 303;
+ err = do_test(mode);
+ if (err)
+ goto speed_err;
+#endif
+ printk("Speed tests finished successfully\n");
+ goto fips_check;
+
+speed_err:
+ printk(KERN_ERR "tcrypt: one or more tests failed!\n");
+ goto err_free_tv;
+#endif /* CONFIG_CRYPTO_DEV_SPEED_TEST */
+
+#else
+ if (alg)
+ err = do_alg_test(alg, type, mask);
+ else
+ err = do_test(mode);
+
+ if (err) {
+ printk(KERN_ERR "tcrypt: one or more tests failed!\n");
+ goto err_free_tv;
+ }
+#endif /* CONFIG_CRYPTO_DEV_DEU */
+
+fips_check:
+ /* We intentionaly return -EAGAIN to prevent keeping the module,
+ * unless we're running in fips mode. It does all its work from
+ * init() and doesn't offer any runtime functionality, but in
+ * the fips case, checking for a successful load is helpful.
+ * => we don't need it in the memory, do we?
+ * -- mludvig
+ */
+ if (!fips_enabled)
+ err = -EAGAIN;
+
+err_free_tv:
+ for (i = 0; i < TVMEMSIZE && tvmem[i]; i++ ){
+ printk("Freeing page: %d\n", i);
+ free_page((unsigned long)tvmem[i]);
+ }
+
+ printk("Finished DEU testing . . . . . .\n");
+ return err;
+}
+
+/*
+ * If an init function is provided, an exit function must also be provided
+ * to allow module unload.
+ */
+static void __exit tcrypt_mod_fini(void) {}
+
+
+module_init(tcrypt_mod_init);
+module_exit(tcrypt_mod_fini);
+
+module_param(alg, charp, 0);
+module_param(type, uint, 0);
+module_param(mask, uint, 0);
+module_param(mode, int, 0);
+module_param(sec, uint, 0);
+MODULE_PARM_DESC(sec, "Length in seconds of speed tests "
+ "(defaults to zero which uses CPU cycles instead)");
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("Quick & dirty crypto testing module");
+MODULE_AUTHOR("James Morris <jmorris@intercode.com.au>");
+
diff --git a/package/platform/lantiq/ltq-deu/src/Makefile b/package/platform/lantiq/ltq-deu/src/Makefile
new file mode 100644
index 0000000..f6cb9c9
--- /dev/null
+++ b/package/platform/lantiq/ltq-deu/src/Makefile
@@ -0,0 +1,26 @@
+ifeq ($(BUILD_VARIANT),danube)
+ CFLAGS_MODULE =-DCONFIG_DANUBE -DCONFIG_CRYPTO_DEV_DEU -DCONFIG_CRYPTO_DEV_SPEED_TEST -DCONFIG_CRYPTO_DEV_DES \
+ -DCONFIG_CRYPTO_DEV_AES -DCONFIG_CRYPTO_DEV_SHA1 -DCONFIG_CRYPTO_DEV_MD5
+ obj-m = ltq_deu_danube.o
+ ltq_deu_danube-objs = ifxmips_deu.o ifxmips_deu_danube.o ifxmips_des.o ifxmips_aes.o ifxmips_sha1.o ifxmips_md5.o
+endif
+
+ifeq ($(BUILD_VARIANT),ar9)
+ CFLAGS_MODULE = -DCONFIG_AR9 -DCONFIG_CRYPTO_DEV_DEU -DCONFIG_CRYPTO_DEV_SPEED_TEST -DCONFIG_CRYPTO_DEV_DES \
+ -DCONFIG_CRYPTO_DEV_AES -DCONFIG_CRYPTO_DEV_SHA1 -DCONFIG_CRYPTO_DEV_MD5 -DCONFIG_CRYPTO_DEV_ARC4 \
+ -DCONFIG_CRYPTO_DEV_SHA1_HMAC -DCONFIG_CRYPTO_DEV_MD5_HMAC
+ obj-m = ltq_deu_ar9.o
+ ltq_deu_ar9-objs = ifxmips_deu.o ifxmips_deu_ar9.o ifxmips_des.o ifxmips_aes.o ifxmips_arc4.o \
+ ifxmips_sha1.o ifxmips_md5.o ifxmips_sha1_hmac.o ifxmips_md5_hmac.o
+endif
+
+ifeq ($(BUILD_VARIANT),vr9)
+ CFLAGS_MODULE = -DCONFIG_VR9 -DCONFIG_CRYPTO_DEV_DEU -DCONFIG_CRYPTO_DEV_SPEED_TEST -DCONFIG_CRYPTO_DEV_DES \
+ -DCONFIG_CRYPTO_DEV_AES -DCONFIG_CRYPTO_DEV_SHA1 -DCONFIG_CRYPTO_DEV_MD5 -DCONFIG_CRYPTO_DEV_ARC4 \
+ -DCONFIG_CRYPTO_DEV_SHA1_HMAC -DCONFIG_CRYPTO_DEV_MD5_HMAC
+ obj-m = ltq_deu_vr9.o
+ ltq_deu_vr9-objs = ifxmips_deu.o ifxmips_deu_vr9.o ifxmips_des.o ifxmips_aes.o ifxmips_arc4.o \
+ ifxmips_sha1.o ifxmips_md5.o ifxmips_sha1_hmac.o ifxmips_md5_hmac.o
+endif
+
+obj-m += ltq_deu_testmgr.o
diff --git a/package/platform/lantiq/ltq-deu/src/ifxmips_aes.c b/package/platform/lantiq/ltq-deu/src/ifxmips_aes.c
new file mode 100644
index 0000000..bf77537
--- /dev/null
+++ b/package/platform/lantiq/ltq-deu/src/ifxmips_aes.c
@@ -0,0 +1,904 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_aes.c
+** PROJECT : IFX UEIP
+** MODULES : DEU Module
+**
+** DATE : September 8, 2009
+** AUTHOR : Mohammad Firdaus
+** DESCRIPTION : Data Encryption Unit Driver for AES Algorithm
+** COPYRIGHT : Copyright (c) 2009
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 08,Sept 2009 Mohammad Firdaus Initial UEIP release
+*******************************************************************************/
+/*!
+ \defgroup IFX_DEU IFX_DEU_DRIVERS
+ \ingroup API
+ \brief ifx DEU driver module
+*/
+
+/*!
+ \file ifxmips_aes.c
+ \ingroup IFX_DEU
+ \brief AES Encryption Driver main file
+*/
+
+/*!
+ \defgroup IFX_AES_FUNCTIONS IFX_AES_FUNCTIONS
+ \ingroup IFX_DEU
+ \brief IFX AES driver Functions
+*/
+
+
+/* Project Header Files */
+#if defined(CONFIG_MODVERSIONS)
+#define MODVERSIONS
+#include <linux/modeversions>
+#endif
+
+#include <linux/version.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/proc_fs.h>
+#include <linux/fs.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/crypto.h>
+#include <linux/interrupt.h>
+#include <linux/delay.h>
+#include <asm/byteorder.h>
+#include <crypto/algapi.h>
+
+#include "ifxmips_deu.h"
+
+#if defined(CONFIG_DANUBE)
+#include "ifxmips_deu_danube.h"
+extern int ifx_danube_pre_1_4;
+#elif defined(CONFIG_AR9)
+#include "ifxmips_deu_ar9.h"
+#elif defined(CONFIG_VR9) || defined(CONFIG_AR10)
+#include "ifxmips_deu_vr9.h"
+#else
+#error "Unkown platform"
+#endif
+
+/* DMA related header and variables */
+
+spinlock_t aes_lock;
+#define CRTCL_SECT_INIT spin_lock_init(&aes_lock)
+#define CRTCL_SECT_START spin_lock_irqsave(&aes_lock, flag)
+#define CRTCL_SECT_END spin_unlock_irqrestore(&aes_lock, flag)
+
+/* Definition of constants */
+#define AES_START IFX_AES_CON
+#define AES_MIN_KEY_SIZE 16
+#define AES_MAX_KEY_SIZE 32
+#define AES_BLOCK_SIZE 16
+#define CTR_RFC3686_NONCE_SIZE 4
+#define CTR_RFC3686_IV_SIZE 8
+#define CTR_RFC3686_MAX_KEY_SIZE (AES_MAX_KEY_SIZE + CTR_RFC3686_NONCE_SIZE)
+
+#ifdef CRYPTO_DEBUG
+extern char debug_level;
+#define DPRINTF(level, format, args...) if (level < debug_level) printk(KERN_INFO "[%s %s %d]: " format, __FILE__, __func__, __LINE__, ##args);
+#else
+#define DPRINTF(level, format, args...)
+#endif /* CRYPTO_DEBUG */
+
+/* Function decleration */
+int aes_chip_init(void);
+u32 endian_swap(u32 input);
+u32 input_swap(u32 input);
+u32* memory_alignment(const u8 *arg, u32 *buff_alloc, int in_out, int nbytes);
+void aes_dma_memory_copy(u32 *outcopy, u32 *out_dma, u8 *out_arg, int nbytes);
+void des_dma_memory_copy(u32 *outcopy, u32 *out_dma, u8 *out_arg, int nbytes);
+int aes_memory_allocate(int value);
+int des_memory_allocate(int value);
+void memory_release(u32 *addr);
+
+
+extern void ifx_deu_aes (void *ctx_arg, uint8_t *out_arg, const uint8_t *in_arg,
+ uint8_t *iv_arg, size_t nbytes, int encdec, int mode);
+/* End of function decleration */
+
+struct aes_ctx {
+ int key_length;
+ u32 buf[AES_MAX_KEY_SIZE];
+ u8 nonce[CTR_RFC3686_NONCE_SIZE];
+};
+
+extern int disable_deudma;
+extern int disable_multiblock;
+
+/*! \fn int aes_set_key (struct crypto_tfm *tfm, const uint8_t *in_key, unsigned int key_len)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief sets the AES keys
+ * \param tfm linux crypto algo transform
+ * \param in_key input key
+ * \param key_len key lengths of 16, 24 and 32 bytes supported
+ * \return -EINVAL - bad key length, 0 - SUCCESS
+*/
+int aes_set_key (struct crypto_tfm *tfm, const u8 *in_key, unsigned int key_len)
+{
+ struct aes_ctx *ctx = crypto_tfm_ctx(tfm);
+ unsigned long *flags = (unsigned long *) &tfm->crt_flags;
+
+ //printk("set_key in %s\n", __FILE__);
+
+ //aes_chip_init();
+
+ if (key_len != 16 && key_len != 24 && key_len != 32) {
+ *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
+ return -EINVAL;
+ }
+
+ ctx->key_length = key_len;
+ DPRINTF(0, "ctx @%p, key_len %d, ctx->key_length %d\n", ctx, key_len, ctx->key_length);
+ memcpy ((u8 *) (ctx->buf), in_key, key_len);
+
+ return 0;
+}
+
+
+/*! \fn void ifx_deu_aes (void *ctx_arg, u8 *out_arg, const u8 *in_arg, u8 *iv_arg, size_t nbytes, int encdec, int mode)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief main interface to AES hardware
+ * \param ctx_arg crypto algo context
+ * \param out_arg output bytestream
+ * \param in_arg input bytestream
+ * \param iv_arg initialization vector
+ * \param nbytes length of bytestream
+ * \param encdec 1 for encrypt; 0 for decrypt
+ * \param mode operation mode such as ebc, cbc, ctr
+ *
+*/
+void ifx_deu_aes (void *ctx_arg, u8 *out_arg, const u8 *in_arg,
+ u8 *iv_arg, size_t nbytes, int encdec, int mode)
+
+{
+ /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+ volatile struct aes_t *aes = (volatile struct aes_t *) AES_START;
+ struct aes_ctx *ctx = (struct aes_ctx *)ctx_arg;
+ u32 *in_key = ctx->buf;
+ unsigned long flag;
+ /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+ int key_len = ctx->key_length;
+
+ int i = 0;
+ int byte_cnt = nbytes;
+
+
+ CRTCL_SECT_START;
+ /* 128, 192 or 256 bit key length */
+ aes->controlr.K = key_len / 8 - 2;
+ if (key_len == 128 / 8) {
+ aes->K3R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 0));
+ aes->K2R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 1));
+ aes->K1R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 2));
+ aes->K0R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 3));
+ }
+ else if (key_len == 192 / 8) {
+ aes->K5R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 0));
+ aes->K4R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 1));
+ aes->K3R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 2));
+ aes->K2R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 3));
+ aes->K1R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 4));
+ aes->K0R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 5));
+ }
+ else if (key_len == 256 / 8) {
+ aes->K7R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 0));
+ aes->K6R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 1));
+ aes->K5R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 2));
+ aes->K4R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 3));
+ aes->K3R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 4));
+ aes->K2R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 5));
+ aes->K1R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 6));
+ aes->K0R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 7));
+ }
+ else {
+ printk (KERN_ERR "[%s %s %d]: Invalid key_len : %d\n", __FILE__, __func__, __LINE__, key_len);
+ CRTCL_SECT_END;
+ return;// -EINVAL;
+ }
+
+ /* let HW pre-process DEcryption key in any case (even if
+ ENcryption is used). Key Valid (KV) bit is then only
+ checked in decryption routine! */
+ aes->controlr.PNK = 1;
+
+
+ aes->controlr.E_D = !encdec; //encryption
+ aes->controlr.O = mode; //0 ECB 1 CBC 2 OFB 3 CFB 4 CTR
+
+ //aes->controlr.F = 128; //default; only for CFB and OFB modes; change only for customer-specific apps
+ if (mode > 0) {
+ aes->IV3R = DEU_ENDIAN_SWAP(*(u32 *) iv_arg);
+ aes->IV2R = DEU_ENDIAN_SWAP(*((u32 *) iv_arg + 1));
+ aes->IV1R = DEU_ENDIAN_SWAP(*((u32 *) iv_arg + 2));
+ aes->IV0R = DEU_ENDIAN_SWAP(*((u32 *) iv_arg + 3));
+ };
+
+
+ i = 0;
+ while (byte_cnt >= 16) {
+
+ aes->ID3R = INPUT_ENDIAN_SWAP(*((u32 *) in_arg + (i * 4) + 0));
+ aes->ID2R = INPUT_ENDIAN_SWAP(*((u32 *) in_arg + (i * 4) + 1));
+ aes->ID1R = INPUT_ENDIAN_SWAP(*((u32 *) in_arg + (i * 4) + 2));
+ aes->ID0R = INPUT_ENDIAN_SWAP(*((u32 *) in_arg + (i * 4) + 3)); /* start crypto */
+
+ while (aes->controlr.BUS) {
+ // this will not take long
+ }
+
+ *((volatile u32 *) out_arg + (i * 4) + 0) = aes->OD3R;
+ *((volatile u32 *) out_arg + (i * 4) + 1) = aes->OD2R;
+ *((volatile u32 *) out_arg + (i * 4) + 2) = aes->OD1R;
+ *((volatile u32 *) out_arg + (i * 4) + 3) = aes->OD0R;
+
+ i++;
+ byte_cnt -= 16;
+ }
+
+
+ //tc.chen : copy iv_arg back
+ if (mode > 0) {
+ *((u32 *) iv_arg) = DEU_ENDIAN_SWAP(*((u32 *) iv_arg));
+ *((u32 *) iv_arg + 1) = DEU_ENDIAN_SWAP(*((u32 *) iv_arg + 1));
+ *((u32 *) iv_arg + 2) = DEU_ENDIAN_SWAP(*((u32 *) iv_arg + 2));
+ *((u32 *) iv_arg + 3) = DEU_ENDIAN_SWAP(*((u32 *) iv_arg + 3));
+ }
+
+ CRTCL_SECT_END;
+}
+
+/*!
+ * \fn int ctr_rfc3686_aes_set_key (struct crypto_tfm *tfm, const uint8_t *in_key, unsigned int key_len)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief sets RFC3686 key
+ * \param tfm linux crypto algo transform
+ * \param in_key input key
+ * \param key_len key lengths of 20, 28 and 36 bytes supported; last 4 bytes is nonce
+ * \return 0 - SUCCESS
+ * -EINVAL - bad key length
+*/
+int ctr_rfc3686_aes_set_key (struct crypto_tfm *tfm, const uint8_t *in_key, unsigned int key_len)
+{
+ struct aes_ctx *ctx = crypto_tfm_ctx(tfm);
+ unsigned long *flags = (unsigned long *)&tfm->crt_flags;
+
+ //printk("ctr_rfc3686_aes_set_key in %s\n", __FILE__);
+
+ memcpy(ctx->nonce, in_key + (key_len - CTR_RFC3686_NONCE_SIZE),
+ CTR_RFC3686_NONCE_SIZE);
+
+ key_len -= CTR_RFC3686_NONCE_SIZE; // remove 4 bytes of nonce
+
+ if (key_len != 16 && key_len != 24 && key_len != 32) {
+ *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
+ return -EINVAL;
+ }
+
+ ctx->key_length = key_len;
+
+ memcpy ((u8 *) (ctx->buf), in_key, key_len);
+
+ return 0;
+}
+
+/*! \fn void ifx_deu_aes (void *ctx_arg, u8 *out_arg, const u8 *in_arg, u8 *iv_arg, u32 nbytes, int encdec, int mode)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief main interface with deu hardware in DMA mode
+ * \param ctx_arg crypto algo context
+ * \param out_arg output bytestream
+ * \param in_arg input bytestream
+ * \param iv_arg initialization vector
+ * \param nbytes length of bytestream
+ * \param encdec 1 for encrypt; 0 for decrypt
+ * \param mode operation mode such as ebc, cbc, ctr
+*/
+
+
+//definitions from linux/include/crypto.h:
+//#define CRYPTO_TFM_MODE_ECB 0x00000001
+//#define CRYPTO_TFM_MODE_CBC 0x00000002
+//#define CRYPTO_TFM_MODE_CFB 0x00000004
+//#define CRYPTO_TFM_MODE_CTR 0x00000008
+//#define CRYPTO_TFM_MODE_OFB 0x00000010 // not even defined
+//but hardware definition: 0 ECB 1 CBC 2 OFB 3 CFB 4 CTR
+
+/*! \fn void ifx_deu_aes_ecb (void *ctx, uint8_t *dst, const uint8_t *src, uint8_t *iv, size_t nbytes, int encdec, int inplace)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief sets AES hardware to ECB mode
+ * \param ctx crypto algo context
+ * \param dst output bytestream
+ * \param src input bytestream
+ * \param iv initialization vector
+ * \param nbytes length of bytestream
+ * \param encdec 1 for encrypt; 0 for decrypt
+ * \param inplace not used
+*/
+void ifx_deu_aes_ecb (void *ctx, uint8_t *dst, const uint8_t *src,
+ uint8_t *iv, size_t nbytes, int encdec, int inplace)
+{
+ ifx_deu_aes (ctx, dst, src, NULL, nbytes, encdec, 0);
+}
+
+/*! \fn void ifx_deu_aes_cbc (void *ctx, uint8_t *dst, const uint8_t *src, uint8_t *iv, size_t nbytes, int encdec, int inplace)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief sets AES hardware to CBC mode
+ * \param ctx crypto algo context
+ * \param dst output bytestream
+ * \param src input bytestream
+ * \param iv initialization vector
+ * \param nbytes length of bytestream
+ * \param encdec 1 for encrypt; 0 for decrypt
+ * \param inplace not used
+*/
+void ifx_deu_aes_cbc (void *ctx, uint8_t *dst, const uint8_t *src,
+ uint8_t *iv, size_t nbytes, int encdec, int inplace)
+{
+ ifx_deu_aes (ctx, dst, src, iv, nbytes, encdec, 1);
+}
+
+/*! \fn void ifx_deu_aes_ofb (void *ctx, uint8_t *dst, const uint8_t *src, uint8_t *iv, size_t nbytes, int encdec, int inplace)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief sets AES hardware to OFB mode
+ * \param ctx crypto algo context
+ * \param dst output bytestream
+ * \param src input bytestream
+ * \param iv initialization vector
+ * \param nbytes length of bytestream
+ * \param encdec 1 for encrypt; 0 for decrypt
+ * \param inplace not used
+*/
+void ifx_deu_aes_ofb (void *ctx, uint8_t *dst, const uint8_t *src,
+ uint8_t *iv, size_t nbytes, int encdec, int inplace)
+{
+ ifx_deu_aes (ctx, dst, src, iv, nbytes, encdec, 2);
+}
+
+/*! \fn void ifx_deu_aes_cfb (void *ctx, uint8_t *dst, const uint8_t *src, uint8_t *iv, size_t nbytes, int encdec, int inplace)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief sets AES hardware to CFB mode
+ * \param ctx crypto algo context
+ * \param dst output bytestream
+ * \param src input bytestream
+ * \param iv initialization vector
+ * \param nbytes length of bytestream
+ * \param encdec 1 for encrypt; 0 for decrypt
+ * \param inplace not used
+*/
+void ifx_deu_aes_cfb (void *ctx, uint8_t *dst, const uint8_t *src,
+ uint8_t *iv, size_t nbytes, int encdec, int inplace)
+{
+ ifx_deu_aes (ctx, dst, src, iv, nbytes, encdec, 3);
+}
+
+/*! \fn void ifx_deu_aes_ctr (void *ctx, uint8_t *dst, const uint8_t *src, uint8_t *iv, size_t nbytes, int encdec, int inplace)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief sets AES hardware to CTR mode
+ * \param ctx crypto algo context
+ * \param dst output bytestream
+ * \param src input bytestream
+ * \param iv initialization vector
+ * \param nbytes length of bytestream
+ * \param encdec 1 for encrypt; 0 for decrypt
+ * \param inplace not used
+*/
+void ifx_deu_aes_ctr (void *ctx, uint8_t *dst, const uint8_t *src,
+ uint8_t *iv, size_t nbytes, int encdec, int inplace)
+{
+ ifx_deu_aes (ctx, dst, src, iv, nbytes, encdec, 4);
+}
+
+/*! \fn void aes_encrypt (struct crypto_tfm *tfm, uint8_t *out, const uint8_t *in)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief encrypt AES_BLOCK_SIZE of data
+ * \param tfm linux crypto algo transform
+ * \param out output bytestream
+ * \param in input bytestream
+*/
+void aes_encrypt (struct crypto_tfm *tfm, uint8_t *out, const uint8_t *in)
+{
+ struct aes_ctx *ctx = crypto_tfm_ctx(tfm);
+ ifx_deu_aes (ctx, out, in, NULL, AES_BLOCK_SIZE,
+ CRYPTO_DIR_ENCRYPT, 0);
+}
+
+/*! \fn void aes_decrypt (struct crypto_tfm *tfm, uint8_t *out, const uint8_t *in)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief decrypt AES_BLOCK_SIZE of data
+ * \param tfm linux crypto algo transform
+ * \param out output bytestream
+ * \param in input bytestream
+*/
+void aes_decrypt (struct crypto_tfm *tfm, uint8_t *out, const uint8_t *in)
+{
+ struct aes_ctx *ctx = crypto_tfm_ctx(tfm);
+ ifx_deu_aes (ctx, out, in, NULL, AES_BLOCK_SIZE,
+ CRYPTO_DIR_DECRYPT, 0);
+}
+
+/*
+ * \brief AES function mappings
+*/
+struct crypto_alg ifxdeu_aes_alg = {
+ .cra_name = "aes",
+ .cra_driver_name = "ifxdeu-aes",
+ .cra_flags = CRYPTO_ALG_TYPE_CIPHER,
+ .cra_blocksize = AES_BLOCK_SIZE,
+ .cra_ctxsize = sizeof(struct aes_ctx),
+ .cra_module = THIS_MODULE,
+ .cra_list = LIST_HEAD_INIT(ifxdeu_aes_alg.cra_list),
+ .cra_u = {
+ .cipher = {
+ .cia_min_keysize = AES_MIN_KEY_SIZE,
+ .cia_max_keysize = AES_MAX_KEY_SIZE,
+ .cia_setkey = aes_set_key,
+ .cia_encrypt = aes_encrypt,
+ .cia_decrypt = aes_decrypt,
+ }
+ }
+};
+
+/*! \fn int ecb_aes_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief ECB AES encrypt using linux crypto blkcipher
+ * \param desc blkcipher descriptor
+ * \param dst output scatterlist
+ * \param src input scatterlist
+ * \param nbytes data size in bytes
+ * \return err
+*/
+int ecb_aes_encrypt(struct blkcipher_desc *desc,
+ struct scatterlist *dst, struct scatterlist *src,
+ unsigned int nbytes)
+{
+ struct aes_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
+ struct blkcipher_walk walk;
+ int err;
+
+ blkcipher_walk_init(&walk, dst, src, nbytes);
+ err = blkcipher_walk_virt(desc, &walk);
+
+ while ((nbytes = walk.nbytes)) {
+ nbytes -= (nbytes % AES_BLOCK_SIZE);
+ ifx_deu_aes_ecb(ctx, walk.dst.virt.addr, walk.src.virt.addr,
+ NULL, nbytes, CRYPTO_DIR_ENCRYPT, 0);
+ nbytes &= AES_BLOCK_SIZE - 1;
+ err = blkcipher_walk_done(desc, &walk, nbytes);
+ }
+
+ return err;
+}
+
+/*! \fn int ecb_aes_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief ECB AES decrypt using linux crypto blkcipher
+ * \param desc blkcipher descriptor
+ * \param dst output scatterlist
+ * \param src input scatterlist
+ * \param nbytes data size in bytes
+ * \return err
+*/
+int ecb_aes_decrypt(struct blkcipher_desc *desc,
+ struct scatterlist *dst, struct scatterlist *src,
+ unsigned int nbytes)
+{
+ struct aes_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
+ struct blkcipher_walk walk;
+ int err;
+
+ blkcipher_walk_init(&walk, dst, src, nbytes);
+ err = blkcipher_walk_virt(desc, &walk);
+
+ while ((nbytes = walk.nbytes)) {
+ nbytes -= (nbytes % AES_BLOCK_SIZE);
+ ifx_deu_aes_ecb(ctx, walk.dst.virt.addr, walk.src.virt.addr,
+ NULL, nbytes, CRYPTO_DIR_DECRYPT, 0);
+ nbytes &= AES_BLOCK_SIZE - 1;
+ err = blkcipher_walk_done(desc, &walk, nbytes);
+ }
+
+ return err;
+}
+
+/*
+ * \brief AES function mappings
+*/
+struct crypto_alg ifxdeu_ecb_aes_alg = {
+ .cra_name = "ecb(aes)",
+ .cra_driver_name = "ifxdeu-ecb(aes)",
+ .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER,
+ .cra_blocksize = AES_BLOCK_SIZE,
+ .cra_ctxsize = sizeof(struct aes_ctx),
+ .cra_type = &crypto_blkcipher_type,
+ .cra_module = THIS_MODULE,
+ .cra_list = LIST_HEAD_INIT(ifxdeu_ecb_aes_alg.cra_list),
+ .cra_u = {
+ .blkcipher = {
+ .min_keysize = AES_MIN_KEY_SIZE,
+ .max_keysize = AES_MAX_KEY_SIZE,
+ .setkey = aes_set_key,
+ .encrypt = ecb_aes_encrypt,
+ .decrypt = ecb_aes_decrypt,
+ }
+ }
+};
+
+
+/*! \fn int cbc_aes_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief CBC AES encrypt using linux crypto blkcipher
+ * \param desc blkcipher descriptor
+ * \param dst output scatterlist
+ * \param src input scatterlist
+ * \param nbytes data size in bytes
+ * \return err
+*/
+int cbc_aes_encrypt(struct blkcipher_desc *desc,
+ struct scatterlist *dst, struct scatterlist *src,
+ unsigned int nbytes)
+{
+ struct aes_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
+ struct blkcipher_walk walk;
+ int err;
+
+ blkcipher_walk_init(&walk, dst, src, nbytes);
+ err = blkcipher_walk_virt(desc, &walk);
+
+ while ((nbytes = walk.nbytes)) {
+ u8 *iv = walk.iv;
+ nbytes -= (nbytes % AES_BLOCK_SIZE);
+ ifx_deu_aes_cbc(ctx, walk.dst.virt.addr, walk.src.virt.addr,
+ iv, nbytes, CRYPTO_DIR_ENCRYPT, 0);
+ nbytes &= AES_BLOCK_SIZE - 1;
+ err = blkcipher_walk_done(desc, &walk, nbytes);
+ }
+
+ return err;
+}
+
+/*! \fn int cbc_aes_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief CBC AES decrypt using linux crypto blkcipher
+ * \param desc blkcipher descriptor
+ * \param dst output scatterlist
+ * \param src input scatterlist
+ * \param nbytes data size in bytes
+ * \return err
+*/
+int cbc_aes_decrypt(struct blkcipher_desc *desc,
+ struct scatterlist *dst, struct scatterlist *src,
+ unsigned int nbytes)
+{
+ struct aes_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
+ struct blkcipher_walk walk;
+ int err;
+
+ blkcipher_walk_init(&walk, dst, src, nbytes);
+ err = blkcipher_walk_virt(desc, &walk);
+
+ while ((nbytes = walk.nbytes)) {
+ u8 *iv = walk.iv;
+ nbytes -= (nbytes % AES_BLOCK_SIZE);
+ ifx_deu_aes_cbc(ctx, walk.dst.virt.addr, walk.src.virt.addr,
+ iv, nbytes, CRYPTO_DIR_DECRYPT, 0);
+ nbytes &= AES_BLOCK_SIZE - 1;
+ err = blkcipher_walk_done(desc, &walk, nbytes);
+ }
+
+ return err;
+}
+
+/*
+ * \brief AES function mappings
+*/
+struct crypto_alg ifxdeu_cbc_aes_alg = {
+ .cra_name = "cbc(aes)",
+ .cra_driver_name = "ifxdeu-cbc(aes)",
+ .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER,
+ .cra_blocksize = AES_BLOCK_SIZE,
+ .cra_ctxsize = sizeof(struct aes_ctx),
+ .cra_type = &crypto_blkcipher_type,
+ .cra_module = THIS_MODULE,
+ .cra_list = LIST_HEAD_INIT(ifxdeu_cbc_aes_alg.cra_list),
+ .cra_u = {
+ .blkcipher = {
+ .min_keysize = AES_MIN_KEY_SIZE,
+ .max_keysize = AES_MAX_KEY_SIZE,
+ .ivsize = AES_BLOCK_SIZE,
+ .setkey = aes_set_key,
+ .encrypt = cbc_aes_encrypt,
+ .decrypt = cbc_aes_decrypt,
+ }
+ }
+};
+
+
+/*! \fn int ctr_basic_aes_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief Counter mode AES encrypt using linux crypto blkcipher
+ * \param desc blkcipher descriptor
+ * \param dst output scatterlist
+ * \param src input scatterlist
+ * \param nbytes data size in bytes
+ * \return err
+*/
+int ctr_basic_aes_encrypt(struct blkcipher_desc *desc,
+ struct scatterlist *dst, struct scatterlist *src,
+ unsigned int nbytes)
+{
+ struct aes_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
+ struct blkcipher_walk walk;
+ int err;
+
+ blkcipher_walk_init(&walk, dst, src, nbytes);
+ err = blkcipher_walk_virt(desc, &walk);
+
+ while ((nbytes = walk.nbytes)) {
+ u8 *iv = walk.iv;
+ nbytes -= (nbytes % AES_BLOCK_SIZE);
+ ifx_deu_aes_ctr(ctx, walk.dst.virt.addr, walk.src.virt.addr,
+ iv, nbytes, CRYPTO_DIR_ENCRYPT, 0);
+ nbytes &= AES_BLOCK_SIZE - 1;
+ err = blkcipher_walk_done(desc, &walk, nbytes);
+ }
+
+ return err;
+}
+
+/*! \fn int ctr_basic_aes_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief Counter mode AES decrypt using linux crypto blkcipher
+ * \param desc blkcipher descriptor
+ * \param dst output scatterlist
+ * \param src input scatterlist
+ * \param nbytes data size in bytes
+ * \return err
+*/
+int ctr_basic_aes_decrypt(struct blkcipher_desc *desc,
+ struct scatterlist *dst, struct scatterlist *src,
+ unsigned int nbytes)
+{
+ struct aes_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
+ struct blkcipher_walk walk;
+ int err;
+
+ blkcipher_walk_init(&walk, dst, src, nbytes);
+ err = blkcipher_walk_virt(desc, &walk);
+
+ while ((nbytes = walk.nbytes)) {
+ u8 *iv = walk.iv;
+ nbytes -= (nbytes % AES_BLOCK_SIZE);
+ ifx_deu_aes_ctr(ctx, walk.dst.virt.addr, walk.src.virt.addr,
+ iv, nbytes, CRYPTO_DIR_DECRYPT, 0);
+ nbytes &= AES_BLOCK_SIZE - 1;
+ err = blkcipher_walk_done(desc, &walk, nbytes);
+ }
+
+ return err;
+}
+
+/*
+ * \brief AES function mappings
+*/
+struct crypto_alg ifxdeu_ctr_basic_aes_alg = {
+ .cra_name = "ctr(aes)",
+ .cra_driver_name = "ifxdeu-ctr(aes)",
+ .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER,
+ .cra_blocksize = AES_BLOCK_SIZE,
+ .cra_ctxsize = sizeof(struct aes_ctx),
+ .cra_type = &crypto_blkcipher_type,
+ .cra_module = THIS_MODULE,
+ .cra_list = LIST_HEAD_INIT(ifxdeu_ctr_basic_aes_alg.cra_list),
+ .cra_u = {
+ .blkcipher = {
+ .min_keysize = AES_MIN_KEY_SIZE,
+ .max_keysize = AES_MAX_KEY_SIZE,
+ .ivsize = AES_BLOCK_SIZE,
+ .setkey = aes_set_key,
+ .encrypt = ctr_basic_aes_encrypt,
+ .decrypt = ctr_basic_aes_decrypt,
+ }
+ }
+};
+
+
+/*! \fn int ctr_rfc3686_aes_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief Counter mode AES (rfc3686) encrypt using linux crypto blkcipher
+ * \param desc blkcipher descriptor
+ * \param dst output scatterlist
+ * \param src input scatterlist
+ * \param nbytes data size in bytes
+ * \return err
+*/
+int ctr_rfc3686_aes_encrypt(struct blkcipher_desc *desc,
+ struct scatterlist *dst, struct scatterlist *src,
+ unsigned int nbytes)
+{
+ struct aes_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
+ struct blkcipher_walk walk;
+ int err;
+ u8 rfc3686_iv[16];
+
+ blkcipher_walk_init(&walk, dst, src, nbytes);
+ err = blkcipher_walk_virt(desc, &walk);
+
+ /* set up counter block */
+ memcpy(rfc3686_iv, ctx->nonce, CTR_RFC3686_NONCE_SIZE);
+ memcpy(rfc3686_iv + CTR_RFC3686_NONCE_SIZE, walk.iv, CTR_RFC3686_IV_SIZE);
+
+ /* initialize counter portion of counter block */
+ *(__be32 *)(rfc3686_iv + CTR_RFC3686_NONCE_SIZE + CTR_RFC3686_IV_SIZE) =
+ cpu_to_be32(1);
+
+ while ((nbytes = walk.nbytes)) {
+ nbytes -= (nbytes % AES_BLOCK_SIZE);
+ ifx_deu_aes_ctr(ctx, walk.dst.virt.addr, walk.src.virt.addr,
+ rfc3686_iv, nbytes, CRYPTO_DIR_ENCRYPT, 0);
+ nbytes &= AES_BLOCK_SIZE - 1;
+ err = blkcipher_walk_done(desc, &walk, nbytes);
+ }
+
+ return err;
+}
+
+/*! \fn int ctr_rfc3686_aes_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief Counter mode AES (rfc3686) decrypt using linux crypto blkcipher
+ * \param desc blkcipher descriptor
+ * \param dst output scatterlist
+ * \param src input scatterlist
+ * \param nbytes data size in bytes
+ * \return err
+*/
+int ctr_rfc3686_aes_decrypt(struct blkcipher_desc *desc,
+ struct scatterlist *dst, struct scatterlist *src,
+ unsigned int nbytes)
+{
+ struct aes_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
+ struct blkcipher_walk walk;
+ int err;
+ u8 rfc3686_iv[16];
+
+ blkcipher_walk_init(&walk, dst, src, nbytes);
+ err = blkcipher_walk_virt(desc, &walk);
+
+ /* set up counter block */
+ memcpy(rfc3686_iv, ctx->nonce, CTR_RFC3686_NONCE_SIZE);
+ memcpy(rfc3686_iv + CTR_RFC3686_NONCE_SIZE, walk.iv, CTR_RFC3686_IV_SIZE);
+
+ /* initialize counter portion of counter block */
+ *(__be32 *)(rfc3686_iv + CTR_RFC3686_NONCE_SIZE + CTR_RFC3686_IV_SIZE) =
+ cpu_to_be32(1);
+
+ while ((nbytes = walk.nbytes)) {
+ nbytes -= (nbytes % AES_BLOCK_SIZE);
+ ifx_deu_aes_ctr(ctx, walk.dst.virt.addr, walk.src.virt.addr,
+ rfc3686_iv, nbytes, CRYPTO_DIR_DECRYPT, 0);
+ nbytes &= AES_BLOCK_SIZE - 1;
+ err = blkcipher_walk_done(desc, &walk, nbytes);
+ }
+
+ return err;
+}
+
+/*
+ * \brief AES function mappings
+*/
+struct crypto_alg ifxdeu_ctr_rfc3686_aes_alg = {
+ .cra_name = "rfc3686(ctr(aes))",
+ .cra_driver_name = "ifxdeu-ctr-rfc3686(aes)",
+ .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER,
+ .cra_blocksize = AES_BLOCK_SIZE,
+ .cra_ctxsize = sizeof(struct aes_ctx),
+ .cra_type = &crypto_blkcipher_type,
+ .cra_module = THIS_MODULE,
+ .cra_list = LIST_HEAD_INIT(ifxdeu_ctr_rfc3686_aes_alg.cra_list),
+ .cra_u = {
+ .blkcipher = {
+ .min_keysize = AES_MIN_KEY_SIZE,
+ .max_keysize = CTR_RFC3686_MAX_KEY_SIZE,
+ .ivsize = CTR_RFC3686_IV_SIZE,
+ .setkey = ctr_rfc3686_aes_set_key,
+ .encrypt = ctr_rfc3686_aes_encrypt,
+ .decrypt = ctr_rfc3686_aes_decrypt,
+ }
+ }
+};
+
+
+/*! \fn int __init ifxdeu_init_aes (void)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief function to initialize AES driver
+ * \return ret
+*/
+int __init ifxdeu_init_aes (void)
+{
+ int ret = -ENOSYS;
+
+
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20))
+ if (!disable_multiblock) {
+ ifxdeu_aes_alg.cra_u.cipher.cia_max_nbytes = AES_BLOCK_SIZE; //(size_t)-1;
+ ifxdeu_aes_alg.cra_u.cipher.cia_req_align = 16;
+ ifxdeu_aes_alg.cra_u.cipher.cia_ecb = ifx_deu_aes_ecb;
+ ifxdeu_aes_alg.cra_u.cipher.cia_cbc = ifx_deu_aes_cbc;
+ ifxdeu_aes_alg.cra_u.cipher.cia_cfb = ifx_deu_aes_cfb;
+ ifxdeu_aes_alg.cra_u.cipher.cia_ofb = ifx_deu_aes_ofb;
+ }
+#endif
+
+ if ((ret = crypto_register_alg(&ifxdeu_aes_alg)))
+ goto aes_err;
+
+ if ((ret = crypto_register_alg(&ifxdeu_ecb_aes_alg)))
+ goto ecb_aes_err;
+
+ if ((ret = crypto_register_alg(&ifxdeu_cbc_aes_alg)))
+ goto cbc_aes_err;
+
+ if ((ret = crypto_register_alg(&ifxdeu_ctr_basic_aes_alg)))
+ goto ctr_basic_aes_err;
+
+ if ((ret = crypto_register_alg(&ifxdeu_ctr_rfc3686_aes_alg)))
+ goto ctr_rfc3686_aes_err;
+
+ aes_chip_init ();
+
+ CRTCL_SECT_INIT;
+
+
+ printk (KERN_NOTICE "IFX DEU AES initialized%s%s.\n", disable_multiblock ? "" : " (multiblock)", disable_deudma ? "" : " (DMA)");
+ return ret;
+
+ctr_rfc3686_aes_err:
+ crypto_unregister_alg(&ifxdeu_ctr_rfc3686_aes_alg);
+ printk (KERN_ERR "IFX ctr_rfc3686_aes initialization failed!\n");
+ return ret;
+ctr_basic_aes_err:
+ crypto_unregister_alg(&ifxdeu_ctr_basic_aes_alg);
+ printk (KERN_ERR "IFX ctr_basic_aes initialization failed!\n");
+ return ret;
+cbc_aes_err:
+ crypto_unregister_alg(&ifxdeu_cbc_aes_alg);
+ printk (KERN_ERR "IFX cbc_aes initialization failed!\n");
+ return ret;
+ecb_aes_err:
+ crypto_unregister_alg(&ifxdeu_ecb_aes_alg);
+ printk (KERN_ERR "IFX aes initialization failed!\n");
+ return ret;
+aes_err:
+ printk(KERN_ERR "IFX DEU AES initialization failed!\n");
+
+ return ret;
+}
+
+/*! \fn void __exit ifxdeu_fini_aes (void)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief unregister aes driver
+*/
+void __exit ifxdeu_fini_aes (void)
+{
+ crypto_unregister_alg (&ifxdeu_aes_alg);
+ crypto_unregister_alg (&ifxdeu_ecb_aes_alg);
+ crypto_unregister_alg (&ifxdeu_cbc_aes_alg);
+ crypto_unregister_alg (&ifxdeu_ctr_basic_aes_alg);
+ crypto_unregister_alg (&ifxdeu_ctr_rfc3686_aes_alg);
+
+}
+
+
diff --git a/package/platform/lantiq/ltq-deu/src/ifxmips_arc4.c b/package/platform/lantiq/ltq-deu/src/ifxmips_arc4.c
new file mode 100644
index 0000000..ee56187
--- /dev/null
+++ b/package/platform/lantiq/ltq-deu/src/ifxmips_arc4.c
@@ -0,0 +1,389 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_arc4.c
+** PROJECT : IFX UEIP
+** MODULES : DEU Module
+**
+** DATE : September 8, 2009
+** AUTHOR : Mohammad Firdaus
+** DESCRIPTION : Data Encryption Unit Driver for ARC4 Algorithm
+** COPYRIGHT : Copyright (c) 2009
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 08 Sept 2009 Mohammad Firdaus Initial UEIP release
+*******************************************************************************/
+
+/*!
+ \defgroup IFX_DEU IFX_DEU_DRIVERS
+ \ingroup API
+ \brief ifx deu driver module
+*/
+
+/*!
+ \file ifxmips_arc4.c
+ \ingroup IFX_DEU
+ \brief ARC4 encryption DEU driver file
+*/
+
+/*!
+ \defgroup IFX_ARC4_FUNCTIONS IFX_ARC4_FUNCTIONS
+ \ingroup IFX_DEU
+ \brief IFX deu driver functions
+*/
+
+/* Project header */
+#include <linux/version.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/crypto.h>
+#include <crypto/algapi.h>
+#include <linux/interrupt.h>
+#include <asm/byteorder.h>
+#include <linux/delay.h>
+
+/* Board specific header files */
+#ifdef CONFIG_AR9
+#include "ifxmips_deu_ar9.h"
+#endif
+#ifdef CONFIG_VR9
+#include "ifxmips_deu_vr9.h"
+#endif
+
+static spinlock_t lock;
+#define CRTCL_SECT_INIT spin_lock_init(&lock)
+#define CRTCL_SECT_START spin_lock_irqsave(&lock, flag)
+#define CRTCL_SECT_END spin_unlock_irqrestore(&lock, flag)
+
+/* Preprocessor declerations */
+#define ARC4_MIN_KEY_SIZE 1
+//#define ARC4_MAX_KEY_SIZE 256
+#define ARC4_MAX_KEY_SIZE 16
+#define ARC4_BLOCK_SIZE 1
+#define ARC4_START IFX_ARC4_CON
+#ifdef CRYPTO_DEBUG
+extern char debug_level;
+#define DPRINTF(level, format, args...) if (level < debug_level) printk(KERN_INFO "[%s %s %d]: " format, __FILE__, __func__, __LINE__, ##args);
+#else
+#define DPRINTF(level, format, args...)
+#endif
+
+/*
+ * \brief arc4 private structure
+*/
+struct arc4_ctx {
+ int key_length;
+ u8 buf[120];
+};
+
+extern int disable_deudma;
+extern int disable_multiblock;
+
+
+/*! \fn static void _deu_arc4 (void *ctx_arg, u8 *out_arg, const u8 *in_arg, u8 *iv_arg, u32 nbytes, int encdec, int mode)
+ \ingroup IFX_ARC4_FUNCTIONS
+ \brief main interface to ARC4 hardware
+ \param ctx_arg crypto algo context
+ \param out_arg output bytestream
+ \param in_arg input bytestream
+ \param iv_arg initialization vector
+ \param nbytes length of bytestream
+ \param encdec 1 for encrypt; 0 for decrypt
+ \param mode operation mode such as ebc, cbc, ctr
+*/
+static void _deu_arc4 (void *ctx_arg, u8 *out_arg, const u8 *in_arg,
+ u8 *iv_arg, u32 nbytes, int encdec, int mode)
+{
+ volatile struct arc4_t *arc4 = (struct arc4_t *) ARC4_START;
+
+ int i = 0;
+ unsigned long flag;
+
+#if 1 // need to handle nbytes not multiple of 16
+ volatile u32 tmp_array32[4];
+ volatile u8 *tmp_ptr8;
+ int remaining_bytes, j;
+#endif
+
+ CRTCL_SECT_START;
+
+ arc4->IDLEN = nbytes;
+
+#if 1
+ while (i < nbytes) {
+ arc4->ID3R = *((u32 *) in_arg + (i>>2) + 0);
+ arc4->ID2R = *((u32 *) in_arg + (i>>2) + 1);
+ arc4->ID1R = *((u32 *) in_arg + (i>>2) + 2);
+ arc4->ID0R = *((u32 *) in_arg + (i>>2) + 3);
+
+ arc4->controlr.GO = 1;
+
+ while (arc4->controlr.BUS) {
+ // this will not take long
+ }
+
+#if 1
+ // need to handle nbytes not multiple of 16
+ tmp_array32[0] = arc4->OD3R;
+ tmp_array32[1] = arc4->OD2R;
+ tmp_array32[2] = arc4->OD1R;
+ tmp_array32[3] = arc4->OD0R;
+
+ remaining_bytes = nbytes - i;
+ if (remaining_bytes > 16)
+ remaining_bytes = 16;
+
+ tmp_ptr8 = (u8 *)&tmp_array32[0];
+ for (j = 0; j < remaining_bytes; j++)
+ *out_arg++ = *tmp_ptr8++;
+#else
+ *((u32 *) out_arg + (i>>2) + 0) = arc4->OD3R;
+ *((u32 *) out_arg + (i>>2) + 1) = arc4->OD2R;
+ *((u32 *) out_arg + (i>>2) + 2) = arc4->OD1R;
+ *((u32 *) out_arg + (i>>2) + 3) = arc4->OD0R;
+#endif
+
+ i += 16;
+ }
+#else // dma
+
+#endif // dma
+
+ CRTCL_SECT_END;
+}
+
+/*! \fn arc4_chip_init (void)
+ \ingroup IFX_ARC4_FUNCTIONS
+ \brief initialize arc4 hardware
+*/
+static void arc4_chip_init (void)
+{
+ //do nothing
+}
+
+/*! \fn static int arc4_set_key(struct crypto_tfm *tfm, const u8 *in_key, unsigned int key_len)
+ \ingroup IFX_ARC4_FUNCTIONS
+ \brief sets ARC4 key
+ \param tfm linux crypto algo transform
+ \param in_key input key
+ \param key_len key lengths less than or equal to 16 bytes supported
+*/
+static int arc4_set_key(struct crypto_tfm *tfm, const u8 *inkey,
+ unsigned int key_len)
+{
+ //struct arc4_ctx *ctx = crypto_tfm_ctx(tfm);
+ volatile struct arc4_t *arc4 = (struct arc4_t *) ARC4_START;
+ u32 *in_key = (u32 *)inkey;
+
+ // must program all bits at one go?!!!
+//#if 1
+ *IFX_ARC4_CON = ( (1<<31) | ((key_len - 1)<<27) | (1<<26) | (3<<16) );
+ //NDC=1,ENDI=1,GO=0,KSAE=1,SM=0
+
+ arc4->K3R = *((u32 *) in_key + 0);
+ arc4->K2R = *((u32 *) in_key + 1);
+ arc4->K1R = *((u32 *) in_key + 2);
+ arc4->K0R = *((u32 *) in_key + 3);
+
+#if 0 // arc4 is a ugly state machine, KSAE can only be set once per session
+ ctx->key_length = key_len;
+
+ memcpy ((u8 *) (ctx->buf), in_key, key_len);
+#endif
+
+ return 0;
+}
+
+/*! \fn static void _deu_arc4_ecb(void *ctx, uint8_t *dst, const uint8_t *src, uint8_t *iv, size_t nbytes, int encdec, int inplace)
+ \ingroup IFX_ARC4_FUNCTIONS
+ \brief sets ARC4 hardware to ECB mode
+ \param ctx crypto algo context
+ \param dst output bytestream
+ \param src input bytestream
+ \param iv initialization vector
+ \param nbytes length of bytestream
+ \param encdec 1 for encrypt; 0 for decrypt
+ \param inplace not used
+*/
+static void _deu_arc4_ecb(void *ctx, uint8_t *dst, const uint8_t *src,
+ uint8_t *iv, size_t nbytes, int encdec, int inplace)
+{
+ _deu_arc4 (ctx, dst, src, NULL, nbytes, encdec, 0);
+}
+
+/*! \fn static void arc4_crypt(struct crypto_tfm *tfm, u8 *out, const u8 *in)
+ \ingroup IFX_ARC4_FUNCTIONS
+ \brief encrypt/decrypt ARC4_BLOCK_SIZE of data
+ \param tfm linux crypto algo transform
+ \param out output bytestream
+ \param in input bytestream
+*/
+static void arc4_crypt(struct crypto_tfm *tfm, u8 *out, const u8 *in)
+{
+ struct arc4_ctx *ctx = crypto_tfm_ctx(tfm);
+
+ _deu_arc4 (ctx, out, in, NULL, ARC4_BLOCK_SIZE,
+ CRYPTO_DIR_DECRYPT, 0);
+
+}
+
+/*
+ * \brief ARC4 function mappings
+*/
+static struct crypto_alg ifxdeu_arc4_alg = {
+ .cra_name = "arc4",
+ .cra_driver_name = "ifxdeu-arc4",
+ .cra_flags = CRYPTO_ALG_TYPE_CIPHER,
+ .cra_blocksize = ARC4_BLOCK_SIZE,
+ .cra_ctxsize = sizeof(struct arc4_ctx),
+ .cra_module = THIS_MODULE,
+ .cra_list = LIST_HEAD_INIT(ifxdeu_arc4_alg.cra_list),
+ .cra_u = {
+ .cipher = {
+ .cia_min_keysize = ARC4_MIN_KEY_SIZE,
+ .cia_max_keysize = ARC4_MAX_KEY_SIZE,
+ .cia_setkey = arc4_set_key,
+ .cia_encrypt = arc4_crypt,
+ .cia_decrypt = arc4_crypt,
+ }
+ }
+};
+
+/*! \fn static int ecb_arc4_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes)
+ \ingroup IFX_ARC4_FUNCTIONS
+ \brief ECB ARC4 encrypt using linux crypto blkcipher
+ \param desc blkcipher descriptor
+ \param dst output scatterlist
+ \param src input scatterlist
+ \param nbytes data size in bytes
+*/
+static int ecb_arc4_encrypt(struct blkcipher_desc *desc,
+ struct scatterlist *dst, struct scatterlist *src,
+ unsigned int nbytes)
+{
+ struct arc4_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
+ struct blkcipher_walk walk;
+ int err;
+
+ DPRINTF(1, "\n");
+ blkcipher_walk_init(&walk, dst, src, nbytes);
+ err = blkcipher_walk_virt(desc, &walk);
+
+ while ((nbytes = walk.nbytes)) {
+ _deu_arc4_ecb(ctx, walk.dst.virt.addr, walk.src.virt.addr,
+ NULL, nbytes, CRYPTO_DIR_ENCRYPT, 0);
+ nbytes &= ARC4_BLOCK_SIZE - 1;
+ err = blkcipher_walk_done(desc, &walk, nbytes);
+ }
+
+ return err;
+}
+
+/*! \fn static int ecb_arc4_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes)
+ \ingroup IFX_ARC4_FUNCTIONS
+ \brief ECB ARC4 decrypt using linux crypto blkcipher
+ \param desc blkcipher descriptor
+ \param dst output scatterlist
+ \param src input scatterlist
+ \param nbytes data size in bytes
+*/
+static int ecb_arc4_decrypt(struct blkcipher_desc *desc,
+ struct scatterlist *dst, struct scatterlist *src,
+ unsigned int nbytes)
+{
+ struct arc4_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
+ struct blkcipher_walk walk;
+ int err;
+
+ DPRINTF(1, "\n");
+ blkcipher_walk_init(&walk, dst, src, nbytes);
+ err = blkcipher_walk_virt(desc, &walk);
+
+ while ((nbytes = walk.nbytes)) {
+ _deu_arc4_ecb(ctx, walk.dst.virt.addr, walk.src.virt.addr,
+ NULL, nbytes, CRYPTO_DIR_DECRYPT, 0);
+ nbytes &= ARC4_BLOCK_SIZE - 1;
+ err = blkcipher_walk_done(desc, &walk, nbytes);
+ }
+
+ return err;
+}
+
+/*
+ * \brief ARC4 function mappings
+*/
+static struct crypto_alg ifxdeu_ecb_arc4_alg = {
+ .cra_name = "ecb(arc4)",
+ .cra_driver_name = "ifxdeu-ecb(arc4)",
+ .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER,
+ .cra_blocksize = ARC4_BLOCK_SIZE,
+ .cra_ctxsize = sizeof(struct arc4_ctx),
+ .cra_type = &crypto_blkcipher_type,
+ .cra_module = THIS_MODULE,
+ .cra_list = LIST_HEAD_INIT(ifxdeu_ecb_arc4_alg.cra_list),
+ .cra_u = {
+ .blkcipher = {
+ .min_keysize = ARC4_MIN_KEY_SIZE,
+ .max_keysize = ARC4_MAX_KEY_SIZE,
+ .setkey = arc4_set_key,
+ .encrypt = ecb_arc4_encrypt,
+ .decrypt = ecb_arc4_decrypt,
+ }
+ }
+};
+
+/*! \fn int __init ifxdeu_init_arc4(void)
+ \ingroup IFX_ARC4_FUNCTIONS
+ \brief initialize arc4 driver
+*/
+int __init ifxdeu_init_arc4(void)
+{
+ int ret = -ENOSYS;
+
+
+ if ((ret = crypto_register_alg(&ifxdeu_arc4_alg)))
+ goto arc4_err;
+
+ if ((ret = crypto_register_alg(&ifxdeu_ecb_arc4_alg)))
+ goto ecb_arc4_err;
+
+ arc4_chip_init ();
+
+ CRTCL_SECT_INIT;
+
+ printk (KERN_NOTICE "IFX DEU ARC4 initialized%s%s.\n", disable_multiblock ? "" : " (multiblock)", disable_deudma ? "" : " (DMA)");
+ return ret;
+
+arc4_err:
+ crypto_unregister_alg(&ifxdeu_arc4_alg);
+ printk(KERN_ERR "IFX arc4 initialization failed!\n");
+ return ret;
+ecb_arc4_err:
+ crypto_unregister_alg(&ifxdeu_ecb_arc4_alg);
+ printk (KERN_ERR "IFX ecb_arc4 initialization failed!\n");
+ return ret;
+
+}
+
+/*! \fn void __exit ifxdeu_fini_arc4(void)
+ \ingroup IFX_ARC4_FUNCTIONS
+ \brief unregister arc4 driver
+*/
+void __exit ifxdeu_fini_arc4(void)
+{
+ crypto_unregister_alg (&ifxdeu_arc4_alg);
+ crypto_unregister_alg (&ifxdeu_ecb_arc4_alg);
+
+
+}
+
+
diff --git a/package/platform/lantiq/ltq-deu/src/ifxmips_async_aes.c b/package/platform/lantiq/ltq-deu/src/ifxmips_async_aes.c
new file mode 100644
index 0000000..64536da
--- /dev/null
+++ b/package/platform/lantiq/ltq-deu/src/ifxmips_async_aes.c
@@ -0,0 +1,1137 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_async_aes.c
+** PROJECT : IFX UEIP
+** MODULES : DEU Module
+**
+** DATE : October 11, 2010
+** AUTHOR : Mohammad Firdaus
+** DESCRIPTION : Data Encryption Unit Driver for AES Algorithm
+** COPYRIGHT : Copyright (c) 2010
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 08,Sept 2009 Mohammad Firdaus Initial UEIP release
+** 11, Oct 2010 Mohammad Firdaus Kernel Port incl. Async. Ablkcipher mode
+** 21,March 2011 Mohammad Firdaus Changes for Kernel 2.6.32 and IPSec integration
+*******************************************************************************/
+/*!
+ \defgroup IFX_DEU IFX_DEU_DRIVERS
+ \ingroup API
+ \brief ifx DEU driver module
+*/
+
+/*!
+ \file ifxmips_async_aes.c
+ \ingroup IFX_DEU
+ \brief AES Encryption Driver main file
+*/
+
+/*!
+ \defgroup IFX_AES_FUNCTIONS IFX_AES_FUNCTIONS
+ \ingroup IFX_DEU
+ \brief IFX AES driver Functions
+*/
+
+
+
+#include <linux/wait.h>
+#include <linux/crypto.h>
+#include <linux/kernel.h>
+#include <linux/kthread.h>
+#include <linux/interrupt.h>
+#include <linux/spinlock.h>
+#include <linux/list.h>
+#include <crypto/ctr.h>
+#include <crypto/aes.h>
+#include <crypto/algapi.h>
+#include <crypto/scatterwalk.h>
+
+#include <asm/ifx/ifx_regs.h>
+#include <asm/ifx/ifx_types.h>
+#include <asm/ifx/common_routines.h>
+#include <asm/ifx/irq.h>
+#include <asm/ifx/ifx_pmu.h>
+#include <asm/ifx/ifx_gpio.h>
+#include <asm/kmap_types.h>
+
+#include "ifxmips_deu.h"
+
+#if defined(CONFIG_DANUBE)
+#include "ifxmips_deu_danube.h"
+extern int ifx_danube_pre_1_4;
+#elif defined(CONFIG_AR9)
+#include "ifxmips_deu_ar9.h"
+#elif defined(CONFIG_VR9) || defined(CONFIG_AR10)
+#include "ifxmips_deu_vr9.h"
+#else
+#error "Unkown platform"
+#endif
+
+/* DMA related header and variables */
+
+spinlock_t aes_lock;
+#define CRTCL_SECT_INIT spin_lock_init(&aes_lock)
+#define CRTCL_SECT_START spin_lock_irqsave(&aes_lock, flag)
+#define CRTCL_SECT_END spin_unlock_irqrestore(&aes_lock, flag)
+
+/* Definition of constants */
+//#define AES_START IFX_AES_CON
+#define AES_MIN_KEY_SIZE 16
+#define AES_MAX_KEY_SIZE 32
+#define AES_BLOCK_SIZE 16
+#define CTR_RFC3686_NONCE_SIZE 4
+#define CTR_RFC3686_IV_SIZE 8
+#define CTR_RFC3686_MAX_KEY_SIZE (AES_MAX_KEY_SIZE + CTR_RFC3686_NONCE_SIZE)
+
+#ifdef CRYPTO_DEBUG
+extern char debug_level;
+#define DPRINTF(level, format, args...) if (level < debug_level) printk(KERN_INFO "[%s %s %d]: " format, __FILE__, __func__, __LINE__, ##args);
+#else
+#define DPRINTF(level, format, args...)
+#endif /* CRYPTO_DEBUG */
+
+
+static int disable_multiblock = 0;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
+module_param(disable_multiblock, int, 0);
+#else
+MODULE_PARM_DESC(disable_multiblock, "Disable encryption of whole multiblock buffers");
+#endif
+
+static int disable_deudma = 1;
+
+/* Function decleration */
+int aes_chip_init(void);
+u32 endian_swap(u32 input);
+u32 input_swap(u32 input);
+u32* memory_alignment(const u8 *arg, u32 *buff_alloc, int in_out, int nbytes);
+void aes_dma_memory_copy(u32 *outcopy, u32 *out_dma, u8 *out_arg, int nbytes);
+int aes_memory_allocate(int value);
+int des_memory_allocate(int value);
+void memory_release(u32 *addr);
+
+
+struct aes_ctx {
+ int key_length;
+ u32 buf[AES_MAX_KEY_SIZE];
+ u8 nonce[CTR_RFC3686_NONCE_SIZE];
+
+};
+
+struct aes_container {
+ u8 *iv;
+ u8 *src_buf;
+ u8 *dst_buf;
+
+ int mode;
+ int encdec;
+ int complete;
+ int flag;
+
+ u32 bytes_processed;
+ u32 nbytes;
+
+ struct ablkcipher_request arequest;
+
+};
+
+aes_priv_t *aes_queue;
+extern deu_drv_priv_t deu_dma_priv;
+
+void hexdump(unsigned char *buf, unsigned int len)
+{
+ print_hex_dump(KERN_CONT, "", DUMP_PREFIX_OFFSET,
+ 16, 1,
+ buf, len, false);
+}
+
+/*! \fn void lq_deu_aes_core (void *ctx_arg, u8 *out_arg, const u8 *in_arg, u8 *iv_arg,
+ size_t nbytes, int encdec, int mode)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief main interface to AES hardware
+ * \param ctx_arg crypto algo context
+ * \param out_arg output bytestream
+ * \param in_arg input bytestream
+ * \param iv_arg initialization vector
+ * \param nbytes length of bytestream
+ * \param encdec 1 for encrypt; 0 for decrypt
+ * \param mode operation mode such as ebc, cbc, ctr
+ *
+*/
+
+static int lq_deu_aes_core (void *ctx_arg, u8 *out_arg, const u8 *in_arg,
+ u8 *iv_arg, size_t nbytes, int encdec, int mode)
+{
+ /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+ volatile struct aes_t *aes = (volatile struct aes_t *) AES_START;
+ struct aes_ctx *ctx = (struct aes_ctx *)ctx_arg;
+ u32 *in_key = ctx->buf;
+ unsigned long flag;
+ /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+ int key_len = ctx->key_length;
+
+ volatile struct deu_dma_t *dma = (struct deu_dma_t *) IFX_DEU_DMA_CON;
+ struct dma_device_info *dma_device = ifx_deu[0].dma_device;
+ deu_drv_priv_t *deu_priv = (deu_drv_priv_t *)dma_device->priv;
+ int wlen = 0;
+ //u32 *outcopy = NULL;
+ u32 *dword_mem_aligned_in = NULL;
+
+ CRTCL_SECT_START;
+
+ /* 128, 192 or 256 bit key length */
+ aes->controlr.K = key_len / 8 - 2;
+ if (key_len == 128 / 8) {
+ aes->K3R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 0));
+ aes->K2R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 1));
+ aes->K1R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 2));
+ aes->K0R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 3));
+ }
+ else if (key_len == 192 / 8) {
+ aes->K5R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 0));
+ aes->K4R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 1));
+ aes->K3R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 2));
+ aes->K2R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 3));
+ aes->K1R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 4));
+ aes->K0R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 5));
+ }
+ else if (key_len == 256 / 8) {
+ aes->K7R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 0));
+ aes->K6R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 1));
+ aes->K5R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 2));
+ aes->K4R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 3));
+ aes->K3R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 4));
+ aes->K2R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 5));
+ aes->K1R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 6));
+ aes->K0R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 7));
+ }
+ else {
+ printk (KERN_ERR "[%s %s %d]: Invalid key_len : %d\n", __FILE__, __func__, __LINE__, key_len);
+ CRTCL_SECT_END;
+ return -EINVAL;
+ }
+
+ /* let HW pre-process DEcryption key in any case (even if
+ ENcryption is used). Key Valid (KV) bit is then only
+ checked in decryption routine! */
+ aes->controlr.PNK = 1;
+
+ while (aes->controlr.BUS) {
+ // this will not take long
+ }
+ AES_DMA_MISC_CONFIG();
+
+ aes->controlr.E_D = !encdec; //encryption
+ aes->controlr.O = mode; //0 ECB 1 CBC 2 OFB 3 CFB 4 CTR
+
+ //aes->controlr.F = 128; //default; only for CFB and OFB modes; change only for customer-specific apps
+ if (mode > 0) {
+ aes->IV3R = DEU_ENDIAN_SWAP(*(u32 *) iv_arg);
+ aes->IV2R = DEU_ENDIAN_SWAP(*((u32 *) iv_arg + 1));
+ aes->IV1R = DEU_ENDIAN_SWAP(*((u32 *) iv_arg + 2));
+ aes->IV0R = DEU_ENDIAN_SWAP(*((u32 *) iv_arg + 3));
+ };
+
+
+ /* Prepare Rx buf length used in dma psuedo interrupt */
+ deu_priv->deu_rx_buf = (u32 *)out_arg;
+ deu_priv->deu_rx_len = nbytes;
+
+ /* memory alignment issue */
+ dword_mem_aligned_in = (u32 *) DEU_DWORD_REORDERING(in_arg, aes_buff_in, BUFFER_IN, nbytes);
+
+ dma->controlr.ALGO = 1; //AES
+ dma->controlr.BS = 0;
+ aes->controlr.DAU = 0;
+ dma->controlr.EN = 1;
+
+ while (aes->controlr.BUS) {
+ // wait for AES to be ready
+ };
+
+ deu_priv->outcopy = (u32 *) DEU_DWORD_REORDERING(out_arg, aes_buff_out, BUFFER_OUT, nbytes);
+ deu_priv->event_src = AES_ASYNC_EVENT;
+
+ wlen = dma_device_write (dma_device, (u8 *)dword_mem_aligned_in, nbytes, NULL);
+ if (wlen != nbytes) {
+ dma->controlr.EN = 0;
+ CRTCL_SECT_END;
+ printk (KERN_ERR "[%s %s %d]: dma_device_write fail!\n", __FILE__, __func__, __LINE__);
+ return -EINVAL;
+ }
+
+ // WAIT_AES_DMA_READY();
+
+ CRTCL_SECT_END;
+
+ if (mode > 0) {
+ *((u32 *) iv_arg) = DEU_ENDIAN_SWAP(*((u32 *) iv_arg));
+ *((u32 *) iv_arg + 1) = DEU_ENDIAN_SWAP(*((u32 *) iv_arg + 1));
+ *((u32 *) iv_arg + 2) = DEU_ENDIAN_SWAP(*((u32 *) iv_arg + 2));
+ *((u32 *) iv_arg + 3) = DEU_ENDIAN_SWAP(*((u32 *) iv_arg + 3));
+ }
+
+ return -EINPROGRESS;
+}
+
+/* \fn static int count_sgs(struct scatterlist *sl, unsigned int total_bytes)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief Counts and return the number of scatterlists
+ * \param *sl Function pointer to the scatterlist
+ * \param total_bytes The total number of bytes that needs to be encrypted/decrypted
+ * \return The number of scatterlists
+*/
+
+static int count_sgs(struct scatterlist *sl, unsigned int total_bytes)
+{
+ int i = 0;
+
+ do {
+ total_bytes -= sl[i].length;
+ i++;
+
+ } while (total_bytes > 0);
+
+ return i;
+}
+
+/* \fn void lq_sg_init(struct scatterlist *src,
+ * struct scatterlist *dst)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief Maps the scatterlists into a source/destination page.
+ * \param *src Pointer to the source scatterlist
+ * \param *dst Pointer to the destination scatterlist
+*/
+
+static void lq_sg_init(struct aes_container *aes_con,struct scatterlist *src,
+ struct scatterlist *dst)
+{
+
+ struct page *dst_page, *src_page;
+
+ src_page = sg_virt(src);
+ aes_con->src_buf = (char *) src_page;
+
+ dst_page = sg_virt(dst);
+ aes_con->dst_buf = (char *) dst_page;
+
+}
+
+
+/* \fn static void lq_sg_complete(struct aes_container *aes_con)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief Free the used up memory after encryt/decrypt.
+*/
+
+static void lq_sg_complete(struct aes_container *aes_con)
+{
+ unsigned long queue_flag;
+
+ spin_lock_irqsave(&aes_queue->lock, queue_flag);
+ kfree(aes_con);
+ spin_unlock_irqrestore(&aes_queue->lock, queue_flag);
+}
+
+/* \fn static inline struct aes_container *aes_container_cast (
+ * struct scatterlist *dst)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief Locate the structure aes_container in memory.
+ * \param *areq Pointer to memory location where ablkcipher_request is located
+ * \return *aes_cointainer The function pointer to aes_container
+*/
+static inline struct aes_container *aes_container_cast (
+ struct ablkcipher_request *areq)
+{
+ return container_of(areq, struct aes_container, arequest);
+}
+
+
+/* \fn static int process_next_packet(struct aes_container *aes_con, struct ablkcipher_request *areq,
+ * \ int state)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief Process next packet to be encrypt/decrypt
+ * \param *aes_con AES container structure
+ * \param *areq Pointer to memory location where ablkcipher_request is located
+ * \param state The state of the current packet (part of scatterlist or new packet)
+ * \return -EINVAL: error, -EINPROGRESS: Crypto still running, 1: no more scatterlist
+*/
+
+static int process_next_packet(struct aes_container *aes_con, struct ablkcipher_request *areq,
+ int state)
+{
+ u8 *iv;
+ int mode, dir, err = -EINVAL;
+ unsigned long queue_flag;
+ u32 inc, nbytes, remain, chunk_size;
+ struct scatterlist *src = NULL;
+ struct scatterlist *dst = NULL;
+ struct crypto_ablkcipher *cipher;
+ struct aes_ctx *ctx;
+
+ spin_lock_irqsave(&aes_queue->lock, queue_flag);
+
+ dir = aes_con->encdec;
+ mode = aes_con->mode;
+ iv = aes_con->iv;
+
+ if (state & PROCESS_SCATTER) {
+ src = scatterwalk_sg_next(areq->src);
+ dst = scatterwalk_sg_next(areq->dst);
+
+ if (!src || !dst) {
+ spin_unlock_irqrestore(&aes_queue->lock, queue_flag);
+ return 1;
+ }
+ }
+ else if (state & PROCESS_NEW_PACKET) {
+ src = areq->src;
+ dst = areq->dst;
+ }
+
+ remain = aes_con->bytes_processed;
+ chunk_size = src->length;
+
+ if (remain > DEU_MAX_PACKET_SIZE)
+ inc = DEU_MAX_PACKET_SIZE;
+ else if (remain > chunk_size)
+ inc = chunk_size;
+ else
+ inc = remain;
+
+ remain -= inc;
+ aes_con->nbytes = inc;
+
+ if (state & PROCESS_SCATTER) {
+ aes_con->src_buf += aes_con->nbytes;
+ aes_con->dst_buf += aes_con->nbytes;
+ }
+
+ lq_sg_init(aes_con, src, dst);
+
+ nbytes = aes_con->nbytes;
+
+ //printk("debug - Line: %d, func: %s, reqsize: %d, scattersize: %d\n",
+ // __LINE__, __func__, nbytes, chunk_size);
+
+ cipher = crypto_ablkcipher_reqtfm(areq);
+ ctx = crypto_ablkcipher_ctx(cipher);
+
+
+ if (aes_queue->hw_status == AES_IDLE)
+ aes_queue->hw_status = AES_STARTED;
+
+ aes_con->bytes_processed -= aes_con->nbytes;
+ err = ablkcipher_enqueue_request(&aes_queue->list, &aes_con->arequest);
+ if (err == -EBUSY) {
+ spin_unlock_irqrestore(&aes_queue->lock, queue_flag);
+ printk("Failed to enqueue request, ln: %d, err: %d\n",
+ __LINE__, err);
+ return -EINVAL;
+ }
+
+ spin_unlock_irqrestore(&aes_queue->lock, queue_flag);
+
+ err = lq_deu_aes_core(ctx, aes_con->dst_buf, aes_con->src_buf, iv, nbytes, dir, mode);
+ return err;
+
+}
+
+/* \fn static void process_queue (unsigned long data)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief tasklet to signal the dequeuing of the next packet to be processed
+ * \param unsigned long data Not used
+ * \return void
+*/
+
+static void process_queue(unsigned long data)
+{
+
+ DEU_WAKEUP_EVENT(deu_dma_priv.deu_thread_wait, AES_ASYNC_EVENT,
+ deu_dma_priv.aes_event_flags);
+}
+
+
+/* \fn static int aes_crypto_thread (void *data)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief AES thread that handles crypto requests from upper layer & DMA
+ * \param *data Not used
+ * \return -EINVAL: DEU failure, -EBUSY: DEU HW busy, 0: exit thread
+*/
+static int aes_crypto_thread (void *data)
+{
+ struct aes_container *aes_con = NULL;
+ struct ablkcipher_request *areq = NULL;
+ int err;
+ unsigned long queue_flag;
+
+ daemonize("lq_aes_thread");
+ printk("AES Queue Manager Starting\n");
+
+ while (1)
+ {
+ DEU_WAIT_EVENT(deu_dma_priv.deu_thread_wait, AES_ASYNC_EVENT,
+ deu_dma_priv.aes_event_flags);
+
+ spin_lock_irqsave(&aes_queue->lock, queue_flag);
+
+ /* wait to prevent starting a crypto session before
+ * exiting the dma interrupt thread.
+ */
+ if (aes_queue->hw_status == AES_STARTED) {
+ areq = ablkcipher_dequeue_request(&aes_queue->list);
+ aes_con = aes_container_cast(areq);
+ aes_queue->hw_status = AES_BUSY;
+ }
+ else if (aes_queue->hw_status == AES_IDLE) {
+ areq = ablkcipher_dequeue_request(&aes_queue->list);
+ aes_con = aes_container_cast(areq);
+ aes_queue->hw_status = AES_STARTED;
+ }
+ else if (aes_queue->hw_status == AES_BUSY) {
+ areq = ablkcipher_dequeue_request(&aes_queue->list);
+ aes_con = aes_container_cast(areq);
+ }
+ else if (aes_queue->hw_status == AES_COMPLETED) {
+ lq_sg_complete(aes_con);
+ aes_queue->hw_status = AES_IDLE;
+ areq->base.complete(&areq->base, 0);
+ spin_unlock_irqrestore(&aes_queue->lock, queue_flag);
+ return 0;
+ }
+ //printk("debug ln: %d, bytes proc: %d\n", __LINE__, aes_con->bytes_processed);
+ spin_unlock_irqrestore(&aes_queue->lock, queue_flag);
+
+ if (!aes_con) {
+ printk("AES_CON return null\n");
+ goto aes_done;
+ }
+
+ if (aes_con->bytes_processed == 0) {
+ goto aes_done;
+ }
+
+ /* Process new packet or the next packet in a scatterlist */
+ if (aes_con->flag & PROCESS_NEW_PACKET) {
+ aes_con->flag = PROCESS_SCATTER;
+ err = process_next_packet(aes_con, areq, PROCESS_NEW_PACKET);
+ }
+ else
+ err = process_next_packet(aes_con, areq, PROCESS_SCATTER);
+
+ if (err == -EINVAL) {
+ areq->base.complete(&areq->base, err);
+ lq_sg_complete(aes_con);
+ printk("src/dst returned -EINVAL in func: %s\n", __func__);
+ }
+ else if (err > 0) {
+ printk("src/dst returned zero in func: %s\n", __func__);
+ goto aes_done;
+ }
+
+ continue;
+
+aes_done:
+ //printk("debug line - %d, func: %s, qlen: %d\n", __LINE__, __func__, aes_queue->list.qlen);
+ areq->base.complete(&areq->base, 0);
+ lq_sg_complete(aes_con);
+
+ spin_lock_irqsave(&aes_queue->lock, queue_flag);
+ if (aes_queue->list.qlen > 0) {
+ spin_unlock_irqrestore(&aes_queue->lock, queue_flag);
+ tasklet_schedule(&aes_queue->aes_task);
+ }
+ else {
+ aes_queue->hw_status = AES_IDLE;
+ spin_unlock_irqrestore(&aes_queue->lock, queue_flag);
+ }
+ } //while(1)
+
+ return 0;
+}
+
+/* \fn static int lq_aes_queue_mgr(struct aes_ctx *ctx, struct ablkcipher_request *areq,
+ u8 *iv, int dir, int mode)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief starts the process of queuing DEU requests
+ * \param *ctx crypto algo contax
+ * \param *areq Pointer to the balkcipher requests
+ * \param *iv Pointer to intput vector location
+ * \param dir Encrypt/Decrypt
+ * \mode The mode AES algo is running
+ * \return 0 if success
+*/
+
+static int lq_aes_queue_mgr(struct aes_ctx *ctx, struct ablkcipher_request *areq,
+ u8 *iv, int dir, int mode)
+{
+ int err = -EINVAL;
+ unsigned long queue_flag;
+ struct scatterlist *src = areq->src;
+ struct scatterlist *dst = areq->dst;
+ struct aes_container *aes_con = NULL;
+ u32 remain, inc, nbytes = areq->nbytes;
+ u32 chunk_bytes = src->length;
+
+
+ aes_con = (struct aes_container *)kmalloc(sizeof(struct aes_container),
+ GFP_KERNEL);
+
+ if (!(aes_con)) {
+ printk("Cannot allocate memory for AES container, fn %s, ln %d\n",
+ __func__, __LINE__);
+ return -ENOMEM;
+ }
+
+ /* AES encrypt/decrypt mode */
+ if (mode == 5) {
+ nbytes = AES_BLOCK_SIZE;
+ chunk_bytes = AES_BLOCK_SIZE;
+ mode = 0;
+ }
+
+ aes_con->bytes_processed = nbytes;
+ aes_con->arequest = *(areq);
+ remain = nbytes;
+
+ //printk("debug - Line: %d, func: %s, reqsize: %d, scattersize: %d\n",
+ // __LINE__, __func__, nbytes, chunk_bytes);
+
+ if (remain > DEU_MAX_PACKET_SIZE)
+ inc = DEU_MAX_PACKET_SIZE;
+ else if (remain > chunk_bytes)
+ inc = chunk_bytes;
+ else
+ inc = remain;
+
+ remain -= inc;
+ lq_sg_init(aes_con, src, dst);
+
+ if (remain <= 0)
+ aes_con->complete = 1;
+ else
+ aes_con->complete = 0;
+
+ aes_con->nbytes = inc;
+ aes_con->iv = iv;
+ aes_con->mode = mode;
+ aes_con->encdec = dir;
+
+ spin_lock_irqsave(&aes_queue->lock, queue_flag);
+
+ if (aes_queue->hw_status == AES_STARTED || aes_queue->hw_status == AES_BUSY ||
+ aes_queue->list.qlen > 0) {
+
+ aes_con->flag = PROCESS_NEW_PACKET;
+ err = ablkcipher_enqueue_request(&aes_queue->list, &aes_con->arequest);
+
+ /* max queue length reached */
+ if (err == -EBUSY) {
+ spin_unlock_irqrestore(&aes_queue->lock, queue_flag);
+ printk("Unable to enqueue request ln: %d, err: %d\n", __LINE__, err);
+ return err;
+ }
+
+ spin_unlock_irqrestore(&aes_queue->lock, queue_flag);
+ return -EINPROGRESS;
+ }
+ else if (aes_queue->hw_status == AES_IDLE)
+ aes_queue->hw_status = AES_STARTED;
+
+ aes_con->flag = PROCESS_SCATTER;
+ aes_con->bytes_processed -= aes_con->nbytes;
+ /* or enqueue the whole structure so as to get back the info
+ * at the moment that it's queued. nbytes might be different */
+ err = ablkcipher_enqueue_request(&aes_queue->list, &aes_con->arequest);
+
+ if (err == -EBUSY) {
+ spin_unlock_irqrestore(&aes_queue->lock, queue_flag);
+ printk("Unable to enqueue request ln: %d, err: %d\n", __LINE__, err);
+ return err;
+ }
+
+ spin_unlock_irqrestore(&aes_queue->lock, queue_flag);
+ return lq_deu_aes_core(ctx, aes_con->dst_buf, aes_con->src_buf, iv, inc, dir, mode);
+
+}
+
+/* \fn static int aes_setkey(struct crypto_ablkcipher *tfm, const u8 *in_key,
+ * unsigned int keylen)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief Sets AES key
+ * \param *tfm Pointer to the ablkcipher transform
+ * \param *in_key Pointer to input keys
+ * \param key_len Length of the AES keys
+ * \return 0 is success, -EINVAL if bad key length
+*/
+
+static int aes_setkey(struct crypto_ablkcipher *tfm, const u8 *in_key,
+ unsigned int keylen)
+{
+ struct aes_ctx *ctx = crypto_ablkcipher_ctx(tfm);
+ unsigned long *flags = (unsigned long *) &tfm->base.crt_flags;
+
+ DPRINTF(2, "set_key in %s\n", __FILE__);
+
+ if (keylen != 16 && keylen != 24 && keylen != 32) {
+ *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
+ return -EINVAL;
+ }
+
+ ctx->key_length = keylen;
+ DPRINTF(0, "ctx @%p, keylen %d, ctx->key_length %d\n", ctx, keylen, ctx->key_length);
+ memcpy ((u8 *) (ctx->buf), in_key, keylen);
+
+ return 0;
+
+}
+
+/* \fn static int aes_generic_setkey(struct crypto_ablkcipher *tfm, const u8 *in_key,
+ * unsigned int keylen)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief Sets AES key
+ * \param *tfm Pointer to the ablkcipher transform
+ * \param *key Pointer to input keys
+ * \param keylen Length of AES keys
+ * \return 0 is success, -EINVAL if bad key length
+*/
+
+static int aes_generic_setkey(struct crypto_ablkcipher *tfm, const u8 *key,
+ unsigned int keylen)
+{
+ return aes_setkey(tfm, key, keylen);
+}
+
+/* \fn static int rfc3686_aes_setkey(struct crypto_ablkcipher *tfm, const u8 *in_key,
+ * unsigned int keylen)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief Sets AES key
+ * \param *tfm Pointer to the ablkcipher transform
+ * \param *in_key Pointer to input keys
+ * \param key_len Length of the AES keys
+ * \return 0 is success, -EINVAL if bad key length
+*/
+
+static int rfc3686_aes_setkey(struct crypto_ablkcipher *tfm,
+ const u8 *in_key, unsigned int keylen)
+{
+ struct aes_ctx *ctx = crypto_ablkcipher_ctx(tfm);
+ unsigned long *flags = (unsigned long *)&tfm->base.crt_flags;
+
+ DPRINTF(2, "ctr_rfc3686_aes_set_key in %s\n", __FILE__);
+
+ memcpy(ctx->nonce, in_key + (keylen - CTR_RFC3686_NONCE_SIZE),
+ CTR_RFC3686_NONCE_SIZE);
+
+ keylen -= CTR_RFC3686_NONCE_SIZE; // remove 4 bytes of nonce
+
+ if (keylen != 16 && keylen != 24 && keylen != 32) {
+ *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
+ return -EINVAL;
+ }
+
+ ctx->key_length = keylen;
+
+ memcpy ((u8 *) (ctx->buf), in_key, keylen);
+
+ return 0;
+}
+
+/* \fn static int aes_encrypt(struct ablkcipher_request *areq)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief Encrypt function for AES algo
+ * \param *areq Pointer to ablkcipher request in memory
+ * \return 0 is success, -EINPROGRESS if encryting, EINVAL if failure
+*/
+
+static int aes_encrypt (struct ablkcipher_request *areq)
+{
+ struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
+ struct aes_ctx *ctx = crypto_ablkcipher_ctx(cipher);
+
+ return lq_aes_queue_mgr(ctx, areq, NULL, CRYPTO_DIR_ENCRYPT, 5);
+
+}
+
+/* \fn static int aes_decrypt(struct ablkcipher_request *areq)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief Decrypt function for AES algo
+ * \param *areq Pointer to ablkcipher request in memory
+ * \return 0 is success, -EINPROGRESS if encryting, EINVAL if failure
+*/
+static int aes_decrypt (struct ablkcipher_request *areq)
+{
+ struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
+ struct aes_ctx *ctx = crypto_ablkcipher_ctx(cipher);
+
+ return lq_aes_queue_mgr(ctx, areq, NULL, CRYPTO_DIR_DECRYPT, 5);
+}
+
+/* \fn static int ecb_aes_decrypt(struct ablkcipher_request *areq)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief Encrypt function for AES algo
+ * \param *areq Pointer to ablkcipher request in memory
+ * \return 0 is success, -EINPROGRESS if encryting, EINVAL if failure
+*/
+
+static int ecb_aes_encrypt (struct ablkcipher_request *areq)
+{
+ struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
+ struct aes_ctx *ctx = crypto_ablkcipher_ctx(cipher);
+
+ return lq_aes_queue_mgr(ctx, areq, areq->info, CRYPTO_DIR_ENCRYPT, 0);
+
+}
+/* \fn static int ecb_aes_decrypt(struct ablkcipher_request *areq)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief Decrypt function for AES algo
+ * \param *areq Pointer to ablkcipher request in memory
+ * \return 0 is success, -EINPROGRESS if encryting, EINVAL if failure
+*/
+static int ecb_aes_decrypt(struct ablkcipher_request *areq)
+
+{
+ struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
+ struct aes_ctx *ctx = crypto_ablkcipher_ctx(cipher);
+
+ return lq_aes_queue_mgr(ctx, areq, areq->info, CRYPTO_DIR_DECRYPT, 0);
+}
+
+/* \fn static int cbc_aes_encrypt(struct ablkcipher_request *areq)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief Encrypt function for AES algo
+ * \param *areq Pointer to ablkcipher request in memory
+ * \return 0 is success, -EINPROGRESS if encryting, EINVAL if failure
+*/
+
+static int cbc_aes_encrypt (struct ablkcipher_request *areq)
+{
+ struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
+ struct aes_ctx *ctx = crypto_ablkcipher_ctx(cipher);
+
+ return lq_aes_queue_mgr(ctx, areq, areq->info, CRYPTO_DIR_ENCRYPT, 1);
+
+}
+
+/* \fn static int cbc_aes_decrypt(struct ablkcipher_request *areq)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief Decrypt function for AES algo
+ * \param *areq Pointer to ablkcipher request in memory
+ * \return 0 is success, -EINPROGRESS if encryting, EINVAL if failure
+*/
+
+static int cbc_aes_decrypt(struct ablkcipher_request *areq)
+{
+ struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
+ struct aes_ctx *ctx = crypto_ablkcipher_ctx(cipher);
+
+ return lq_aes_queue_mgr(ctx, areq, areq->info, CRYPTO_DIR_DECRYPT, 1);
+}
+#if 0
+static int ofb_aes_encrypt (struct ablkcipher_request *areq)
+{
+ struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
+ struct aes_ctx *ctx = crypto_ablkcipher_ctx(cipher);
+
+ return lq_aes_queue_mgr(ctx, areq, areq->info, CRYPTO_DIR_ENCRYPT, 2);
+
+}
+
+static int ofb_aes_decrypt(struct ablkcipher_request *areq)
+{
+ struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
+ struct aes_ctx *ctx = crypto_ablkcipher_ctx(cipher);
+
+ return lq_aes_queue_mgr(ctx, areq, areq->info, CRYPTO_DIR_DECRYPT, 2);
+}
+
+static int cfb_aes_encrypt (struct ablkcipher_request *areq)
+{
+ struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
+ struct aes_ctx *ctx = crypto_ablkcipher_ctx(cipher);
+
+ return lq_aes_queue_mgr(ctx, areq, areq->info, CRYPTO_DIR_ENCRYPT, 3);
+
+}
+
+static int cfb_aes_decrypt(struct ablkcipher_request *areq)
+{
+ struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
+ struct aes_ctx *ctx = crypto_ablkcipher_ctx(cipher);
+
+ return lq_aes_queue_mgr(ctx, areq, areq->info, CRYPTO_DIR_DECRYPT, 3);
+}
+#endif
+
+/* \fn static int ctr_aes_encrypt(struct ablkcipher_request *areq)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief Encrypt function for AES algo
+ * \param *areq Pointer to ablkcipher request in memory
+ * \return 0 is success, -EINPROGRESS if encryting, EINVAL if failure
+*/
+
+static int ctr_aes_encrypt (struct ablkcipher_request *areq)
+{
+ struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
+ struct aes_ctx *ctx = crypto_ablkcipher_ctx(cipher);
+
+ return lq_aes_queue_mgr(ctx, areq, areq->info, CRYPTO_DIR_ENCRYPT, 4);
+
+}
+
+/* \fn static int ctr_aes_decrypt(struct ablkcipher_request *areq)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief Decrypt function for AES algo
+ * \param *areq Pointer to ablkcipher request in memory
+ * \return 0 is success, -EINPROGRESS if encryting, EINVAL if failure
+*/
+
+static int ctr_aes_decrypt(struct ablkcipher_request *areq)
+{
+ struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
+ struct aes_ctx *ctx = crypto_ablkcipher_ctx(cipher);
+
+ return lq_aes_queue_mgr(ctx, areq, areq->info, CRYPTO_DIR_DECRYPT, 4);
+}
+
+/* \fn static int rfc3686_aes_encrypt(struct ablkcipher_request *areq)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief Encrypt function for AES algo
+ * \param *areq Pointer to ablkcipher request in memory
+ * \return 0 is success, -EINPROGRESS if encryting, EINVAL if failure
+*/
+
+static int rfc3686_aes_encrypt(struct ablkcipher_request *areq)
+{
+ struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
+ struct aes_ctx *ctx = crypto_ablkcipher_ctx(cipher);
+ int ret;
+ u8 *info = areq->info;
+ u8 rfc3686_iv[16];
+
+ memcpy(rfc3686_iv, ctx->nonce, CTR_RFC3686_NONCE_SIZE);
+ memcpy(rfc3686_iv + CTR_RFC3686_NONCE_SIZE, info, CTR_RFC3686_IV_SIZE);
+
+ /* initialize counter portion of counter block */
+ *(__be32 *)(rfc3686_iv + CTR_RFC3686_NONCE_SIZE + CTR_RFC3686_IV_SIZE) =
+ cpu_to_be32(1);
+
+ areq->info = rfc3686_iv;
+ ret = lq_aes_queue_mgr(ctx, areq, areq->info, CRYPTO_DIR_ENCRYPT, 4);
+ areq->info = info;
+ return ret;
+}
+
+/* \fn static int rfc3686_aes_decrypt(struct ablkcipher_request *areq)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief Decrypt function for AES algo
+ * \param *areq Pointer to ablkcipher request in memory
+ * \return 0 is success, -EINPROGRESS if encryting, EINVAL if failure
+*/
+
+static int rfc3686_aes_decrypt(struct ablkcipher_request *areq)
+{
+ struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
+ struct aes_ctx *ctx = crypto_ablkcipher_ctx(cipher);
+ int ret;
+ u8 *info = areq->info;
+ u8 rfc3686_iv[16];
+
+ /* set up counter block */
+ memcpy(rfc3686_iv, ctx->nonce, CTR_RFC3686_NONCE_SIZE);
+ memcpy(rfc3686_iv + CTR_RFC3686_NONCE_SIZE, info, CTR_RFC3686_IV_SIZE);
+
+ /* initialize counter portion of counter block */
+ *(__be32 *)(rfc3686_iv + CTR_RFC3686_NONCE_SIZE + CTR_RFC3686_IV_SIZE) =
+ cpu_to_be32(1);
+
+ areq->info = rfc3686_iv;
+ ret = lq_aes_queue_mgr(ctx, areq, areq->info, CRYPTO_DIR_DECRYPT, 4);
+ areq->info = info;
+ return ret;
+}
+
+struct lq_aes_alg {
+ struct crypto_alg alg;
+};
+
+/* AES supported algo array */
+static struct lq_aes_alg aes_drivers_alg[] = {
+ {
+ .alg = {
+ .cra_name = "aes",
+ .cra_driver_name = "ifxdeu-aes",
+ .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
+ .cra_blocksize = AES_BLOCK_SIZE,
+ .cra_ctxsize = sizeof(struct aes_ctx),
+ .cra_type = &crypto_ablkcipher_type,
+ .cra_priority = 300,
+ .cra_module = THIS_MODULE,
+ .cra_ablkcipher = {
+ .setkey = aes_setkey,
+ .encrypt = aes_encrypt,
+ .decrypt = aes_decrypt,
+ .geniv = "eseqiv",
+ .min_keysize = AES_MIN_KEY_SIZE,
+ .max_keysize = AES_MAX_KEY_SIZE,
+ .ivsize = AES_BLOCK_SIZE,
+ }
+ }
+ },{
+ .alg = {
+ .cra_name = "ecb(aes)",
+ .cra_driver_name = "ifxdeu-ecb(aes)",
+ .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
+ .cra_blocksize = AES_BLOCK_SIZE,
+ .cra_ctxsize = sizeof(struct aes_ctx),
+ .cra_type = &crypto_ablkcipher_type,
+ .cra_priority = 300,
+ .cra_module = THIS_MODULE,
+ .cra_ablkcipher = {
+ .setkey = aes_generic_setkey,
+ .encrypt = ecb_aes_encrypt,
+ .decrypt = ecb_aes_decrypt,
+ .geniv = "eseqiv",
+ .min_keysize = AES_MIN_KEY_SIZE,
+ .max_keysize = AES_MAX_KEY_SIZE,
+ .ivsize = AES_BLOCK_SIZE,
+ }
+ }
+ },{
+ .alg = {
+ .cra_name = "cbc(aes)",
+ .cra_driver_name = "ifxdeu-cbc(aes)",
+ .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
+ .cra_blocksize = AES_BLOCK_SIZE,
+ .cra_ctxsize = sizeof(struct aes_ctx),
+ .cra_type = &crypto_ablkcipher_type,
+ .cra_priority = 300,
+ .cra_module = THIS_MODULE,
+ .cra_ablkcipher = {
+ .setkey = aes_generic_setkey,
+ .encrypt = cbc_aes_encrypt,
+ .decrypt = cbc_aes_decrypt,
+ .geniv = "eseqiv",
+ .min_keysize = AES_MIN_KEY_SIZE,
+ .max_keysize = AES_MAX_KEY_SIZE,
+ .ivsize = AES_BLOCK_SIZE,
+ }
+ }
+ },{
+ .alg = {
+ .cra_name = "ctr(aes)",
+ .cra_driver_name = "ifxdeu-ctr(aes)",
+ .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
+ .cra_blocksize = AES_BLOCK_SIZE,
+ .cra_ctxsize = sizeof(struct aes_ctx),
+ .cra_type = &crypto_ablkcipher_type,
+ .cra_priority = 300,
+ .cra_module = THIS_MODULE,
+ .cra_ablkcipher = {
+ .setkey = aes_generic_setkey,
+ .encrypt = ctr_aes_encrypt,
+ .decrypt = ctr_aes_decrypt,
+ .geniv = "eseqiv",
+ .min_keysize = AES_MIN_KEY_SIZE,
+ .max_keysize = AES_MAX_KEY_SIZE,
+ .ivsize = AES_BLOCK_SIZE,
+ }
+ }
+ },{
+ .alg = {
+ .cra_name = "rfc3686(ctr(aes))",
+ .cra_driver_name = "ifxdeu-rfc3686(ctr(aes))",
+ .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
+ .cra_blocksize = AES_BLOCK_SIZE,
+ .cra_ctxsize = sizeof(struct aes_ctx),
+ .cra_type = &crypto_ablkcipher_type,
+ .cra_priority = 300,
+ .cra_module = THIS_MODULE,
+ .cra_ablkcipher = {
+ .setkey = rfc3686_aes_setkey,
+ .encrypt = rfc3686_aes_encrypt,
+ .decrypt = rfc3686_aes_decrypt,
+ .geniv = "eseqiv",
+ .min_keysize = AES_MIN_KEY_SIZE,
+ .max_keysize = CTR_RFC3686_MAX_KEY_SIZE,
+ //.max_keysize = AES_MAX_KEY_SIZE,
+ //.ivsize = CTR_RFC3686_IV_SIZE,
+ .ivsize = AES_BLOCK_SIZE, // else cannot reg
+ }
+ }
+ }
+};
+
+/* \fn int __init lqdeu_async_aes_init (void)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief Initializes the Async. AES driver
+ * \return 0 is success, -EINPROGRESS if encryting, EINVAL if failure
+*/
+
+int __init lqdeu_async_aes_init (void)
+{
+ int i, j, ret = -EINVAL;
+
+#define IFX_DEU_DRV_VERSION "2.0.0"
+ printk(KERN_INFO "Lantiq Technologies DEU Driver version %s\n", IFX_DEU_DRV_VERSION);
+
+ for (i = 0; i < ARRAY_SIZE(aes_drivers_alg); i++) {
+ ret = crypto_register_alg(&aes_drivers_alg[i].alg);
+ printk("driver: %s\n", aes_drivers_alg[i].alg.cra_name);
+ if (ret)
+ goto aes_err;
+ }
+
+ aes_chip_init();
+
+ CRTCL_SECT_INIT;
+
+
+ printk (KERN_NOTICE "Lantiq DEU AES initialized %s %s.\n",
+ disable_multiblock ? "" : " (multiblock)", disable_deudma ? "" : " (DMA)");
+
+ return ret;
+
+aes_err:
+
+ for (j = 0; j < i; j++)
+ crypto_unregister_alg(&aes_drivers_alg[j].alg);
+
+ printk(KERN_ERR "Lantiq %s driver initialization failed!\n", (char *)&aes_drivers_alg[i].alg.cra_driver_name);
+ return ret;
+
+ctr_rfc3686_aes_err:
+ for (i = 0; i < ARRAY_SIZE(aes_drivers_alg); i++) {
+ if (!strcmp((char *)&aes_drivers_alg[i].alg.cra_name, "rfc3686(ctr(aes))"))
+ crypto_unregister_alg(&aes_drivers_alg[j].alg);
+ }
+ printk (KERN_ERR "Lantiq ctr_rfc3686_aes initialization failed!\n");
+ return ret;
+}
+
+/*! \fn void __exit ifxdeu_fini_aes (void)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief unregister aes driver
+*/
+void __exit lqdeu_fini_async_aes (void)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(aes_drivers_alg); i++)
+ crypto_unregister_alg(&aes_drivers_alg[i].alg);
+
+ aes_queue->hw_status = AES_COMPLETED;
+
+ DEU_WAKEUP_EVENT(deu_dma_priv.deu_thread_wait, AES_ASYNC_EVENT,
+ deu_dma_priv.aes_event_flags);
+
+ kfree(aes_queue);
+
+}
diff --git a/package/platform/lantiq/ltq-deu/src/ifxmips_async_des.c b/package/platform/lantiq/ltq-deu/src/ifxmips_async_des.c
new file mode 100644
index 0000000..9c593ae
--- /dev/null
+++ b/package/platform/lantiq/ltq-deu/src/ifxmips_async_des.c
@@ -0,0 +1,954 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_async_des.c
+** PROJECT : IFX UEIP
+** MODULES : DEU Module
+**
+** DATE : October 11, 2010
+** AUTHOR : Mohammad Firdaus
+** DESCRIPTION : Data Encryption Unit Driver for DES Algorithm
+** COPYRIGHT : Copyright (c) 2010
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 08,Sept 2009 Mohammad Firdaus Initial UEIP release
+** 11, Oct 2010 Mohammad Firdaus Kernel Port incl. Async. Ablkcipher mode
+** 21,March 2011 Mohammad Firdaus Changes for Kernel 2.6.32 and IPSec integration
+*******************************************************************************/
+/*!
+ \defgroup IFX_DEU IFX_DEU_DRIVERS
+ \ingroup API
+ \brief ifx DEU driver module
+*/
+
+/*!
+ \file ifxmips_async_des.c
+ \ingroup IFX_DEU
+ \brief DES Encryption Driver main file
+*/
+
+/*!
+ \defgroup IFX_DES_FUNCTIONS IFX_DES_FUNCTIONS
+ \ingroup IFX_DEU
+ \brief IFX DES driver Functions
+*/
+
+#include <linux/wait.h>
+#include <linux/crypto.h>
+#include <linux/kernel.h>
+#include <linux/interrupt.h>
+#include <linux/spinlock.h>
+#include <linux/list.h>
+#include <crypto/ctr.h>
+#include <crypto/aes.h>
+#include <crypto/algapi.h>
+#include <crypto/scatterwalk.h>
+
+#include <asm/ifx/ifx_regs.h>
+#include <asm/ifx/ifx_types.h>
+#include <asm/ifx/common_routines.h>
+#include <asm/ifx/irq.h>
+#include <asm/ifx/ifx_pmu.h>
+#include <asm/ifx/ifx_gpio.h>
+#include <asm/kmap_types.h>
+
+#include "ifxmips_deu.h"
+
+#if defined(CONFIG_DANUBE)
+#include "ifxmips_deu_danube.h"
+extern int ifx_danube_pre_1_4;
+#elif defined(CONFIG_AR9)
+#include "ifxmips_deu_ar9.h"
+#elif defined(CONFIG_VR9) || defined(CONFIG_AR10)
+#include "ifxmips_deu_vr9.h"
+#else
+#error "Unkown platform"
+#endif
+
+/* DMA specific header and variables */
+
+spinlock_t des_lock;
+#define CRTCL_SECT_INIT spin_lock_init(&des_lock)
+#define CRTCL_SECT_START spin_lock_irqsave(&des_lock, flag)
+#define CRTCL_SECT_END spin_unlock_irqrestore(&des_lock, flag)
+
+/* Preprocessor declerations */
+#ifdef CRYPTO_DEBUG
+extern char debug_level;
+#define DPRINTF(level, format, args...) if (level < debug_level) printk(KERN_INFO "[%s %s %d]: " format, __FILE__, __func__, __LINE__, ##args);
+#else
+#define DPRINTF(level, format, args...)
+#endif
+//#define DES_3DES_START IFX_DES_CON
+#define DES_KEY_SIZE 8
+#define DES_EXPKEY_WORDS 32
+#define DES_BLOCK_SIZE 8
+#define DES3_EDE_KEY_SIZE (3 * DES_KEY_SIZE)
+#define DES3_EDE_EXPKEY_WORDS (3 * DES_EXPKEY_WORDS)
+#define DES3_EDE_BLOCK_SIZE DES_BLOCK_SIZE
+
+/* Function Declaration to prevent warning messages */
+void des_chip_init (void);
+u32 endian_swap(u32 input);
+u32 input_swap(u32 input);
+int aes_memory_allocate(int value);
+int des_memory_allocate(int value);
+void memory_release(u32 *buffer);
+u32* memory_alignment(const u8 *arg, u32 *buff_alloc, int in_out, int nbytes);
+void aes_dma_memory_copy(u32 *outcopy, u32 *out_dma, u8 *out_arg, int nbytes);
+void des_dma_memory_copy(u32 *outcopy, u32 *out_dma, u8 *out_arg, int nbytes);
+
+static int lq_deu_des_core (void *ctx_arg, u8 *out_arg, const u8 *in_arg,
+ u8 *iv_arg, u32 nbytes, int encdec, int mode);
+
+struct des_ctx {
+ int controlr_M;
+ int key_length;
+ u8 iv[DES_BLOCK_SIZE];
+ u32 expkey[DES3_EDE_EXPKEY_WORDS];
+};
+
+
+static int disable_multiblock = 0;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
+module_param(disable_multiblock, int, 0);
+#else
+MODULE_PARM_DESC(disable_multiblock, "Disable encryption of whole multiblock buffers");
+#endif
+
+static int disable_deudma = 1;
+
+struct des_container {
+ u8 *iv;
+ u8 *dst_buf;
+ u8 *src_buf;
+ int mode;
+ int encdec;
+ int complete;
+ int flag;
+
+ u32 bytes_processed;
+ u32 nbytes;
+
+ struct ablkcipher_request arequest;
+};
+
+des_priv_t *des_queue;
+extern deu_drv_priv_t deu_dma_priv;
+
+void hexdump1(unsigned char *buf, unsigned int len)
+{
+ print_hex_dump(KERN_CONT, "", DUMP_PREFIX_OFFSET,
+ 16, 1,
+ buf, len, false);
+}
+
+
+/*! \fn int lq_des_setkey(struct crypto_ablkcipher *tfm, const u8 *key, unsigned int keylen)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief sets DES key
+ * \param tfm linux crypto algo transform
+ * \param key input key
+ * \param keylen key length
+*/
+static int lq_des_setkey(struct crypto_ablkcipher *tfm, const u8 *key,
+ unsigned int keylen)
+{
+ struct des_ctx *dctx = crypto_ablkcipher_ctx(tfm);
+
+ //printk("setkey in %s\n", __FILE__);
+
+ dctx->controlr_M = 0; // des
+ dctx->key_length = keylen;
+
+ memcpy ((u8 *) (dctx->expkey), key, keylen);
+
+ return 0;
+}
+
+/*! \fn int lq_des3_ede_setkey(struct crypto_ablkcipher *tfm, const u8 *key, unsigned int keylen)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief sets DES key
+ * \param tfm linux crypto algo transform
+ * \param key input key
+ * \param keylen key length
+*/
+
+static int lq_des3_ede_setkey(struct crypto_ablkcipher *tfm, const u8 *in_key,
+ unsigned int keylen)
+{
+ struct des_ctx *dctx = crypto_ablkcipher_ctx(tfm);
+
+ //printk("setkey in %s\n", __FILE__);
+
+ dctx->controlr_M = keylen/8 + 1; // des
+ dctx->key_length = keylen;
+
+ memcpy ((u8 *) (dctx->expkey), in_key, keylen);
+
+ return 0;
+}
+
+/*! \fn void ifx_deu_des_core(void *ctx_arg, u8 *out_arg, const u8 *in_arg, u8 *iv_arg, u32 nbytes, int encdec, int mode)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief main interface to DES hardware
+ * \param ctx_arg crypto algo context
+ * \param out_arg output bytestream
+ * \param in_arg input bytestream
+ * \param iv_arg initialization vector
+ * \param nbytes length of bytestream
+ * \param encdec 1 for encrypt; 0 for decrypt
+ * \param mode operation mode such as ebc, cbc
+*/
+
+static int lq_deu_des_core (void *ctx_arg, u8 *out_arg, const u8 *in_arg,
+ u8 *iv_arg, u32 nbytes, int encdec, int mode)
+{
+ volatile struct des_t *des = (struct des_t *) DES_3DES_START;
+ struct des_ctx *dctx = ctx_arg;
+ u32 *key = dctx->expkey;
+ unsigned long flag;
+
+ int i = 0;
+ int nblocks = 0;
+
+ CRTCL_SECT_START;
+
+ des->controlr.M = dctx->controlr_M;
+ if (dctx->controlr_M == 0) // des
+ {
+ des->K1HR = DEU_ENDIAN_SWAP(*((u32 *) key + 0));
+ des->K1LR = DEU_ENDIAN_SWAP(*((u32 *) key + 1));
+
+ }
+ else {
+ /* Hardware Section */
+ switch (dctx->key_length) {
+ case 24:
+ des->K3HR = DEU_ENDIAN_SWAP(*((u32 *) key + 4));
+ des->K3LR = DEU_ENDIAN_SWAP(*((u32 *) key + 5));
+ /* no break; */
+
+ case 16:
+ des->K2HR = DEU_ENDIAN_SWAP(*((u32 *) key + 2));
+ des->K2LR = DEU_ENDIAN_SWAP(*((u32 *) key + 3));
+
+ /* no break; */
+ case 8:
+ des->K1HR = DEU_ENDIAN_SWAP(*((u32 *) key + 0));
+ des->K1LR = DEU_ENDIAN_SWAP(*((u32 *) key + 1));
+ break;
+
+ default:
+ CRTCL_SECT_END;
+ return -EINVAL;
+ }
+ }
+
+ des->controlr.E_D = !encdec; //encryption
+ des->controlr.O = mode; //0 ECB 1 CBC 2 OFB 3 CFB 4 CTR hexdump(prin,sizeof(*des));
+
+ if (mode > 0) {
+ des->IVHR = DEU_ENDIAN_SWAP(*(u32 *) iv_arg);
+ des->IVLR = DEU_ENDIAN_SWAP(*((u32 *) iv_arg + 1));
+ };
+
+ /* memory alignment issue */
+ dword_mem_aligned_in = (u32 *) DEU_DWORD_REORDERING(in_arg, des_buff_in, BUFFER_IN, nbytes);
+
+ deu_priv->deu_rx_buf = (u32 *) out_arg;
+ deu_priv->deu_rx_len = nbytes;
+
+ dma->controlr.ALGO = 0; //DES
+ des->controlr.DAU = 0;
+ dma->controlr.BS = 0;
+ dma->controlr.EN = 1;
+
+ while (des->controlr.BUS) {
+ };
+
+ wlen = dma_device_write (dma_device, (u8 *) dword_mem_aligned_in, nbytes, NULL);
+ if (wlen != nbytes) {
+ dma->controlr.EN = 0;
+ CRTCL_SECT_END;
+ printk (KERN_ERR "[%s %s %d]: dma_device_write fail!\n", __FILE__, __func__, __LINE__);
+ return -EINVAL;
+ }
+
+
+ /* Prepare Rx buf length used in dma psuedo interrupt */
+ outcopy = (u32 *) DEU_DWORD_REORDERING(out_arg, des_buff_out, BUFFER_OUT, nbytes);
+ deu_priv->outcopy = outcopy;
+ deu_priv->event_src = DES_ASYNC_EVENT;
+
+ if (mode > 0) {
+ *(u32 *) iv_arg = DEU_ENDIAN_SWAP(des->IVHR);
+ *((u32 *) iv_arg + 1) = DEU_ENDIAN_SWAP(des->IVLR);
+ };
+
+ CRTCL_SECT_END;
+
+ return -EINPROGRESS;
+
+}
+
+static int count_sgs(struct scatterlist *sl, unsigned int total_bytes)
+{
+ int i = 0;
+
+ do {
+ total_bytes -= sl[i].length;
+ i++;
+
+ } while (total_bytes > 0);
+
+ return i;
+}
+
+/* \fn static inline struct des_container *des_container_cast (
+ * struct scatterlist *dst)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief Locate the structure des_container in memory.
+ * \param *areq Pointer to memory location where ablkcipher_request is located
+ * \return *des_cointainer The function pointer to des_container
+*/
+
+static inline struct des_container *des_container_cast(
+ struct ablkcipher_request *areq)
+{
+ return container_of(areq, struct des_container, arequest);
+}
+
+/* \fn static void lq_sg_complete(struct des_container *des_con)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief Free the used up memory after encryt/decrypt.
+*/
+
+static void lq_sg_complete(struct des_container *des_con)
+{
+ unsigned long queue_flag;
+
+ spin_lock_irqsave(&des_queue->lock, queue_flag);
+ kfree(des_con);
+ spin_unlock_irqrestore(&des_queue->lock, queue_flag);
+}
+
+/* \fn void lq_sg_init(struct scatterlist *src,
+ * struct scatterlist *dst)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief Maps the scatterlists into a source/destination page.
+ * \param *src Pointer to the source scatterlist
+ * \param *dst Pointer to the destination scatterlist
+*/
+
+static void lq_sg_init(struct des_container *des_con, struct scatterlist *src,
+ struct scatterlist *dst)
+{
+ struct page *dst_page, *src_page;
+
+ src_page = sg_virt(src);
+ des_con->src_buf = (char *) src_page;
+
+ dst_page = sg_virt(dst);
+ des_con->dst_buf = (char *) dst_page;
+}
+
+/* \fn static int process_next_packet(struct des_container *des_con, struct ablkcipher_request *areq,
+ * int state)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief Process the next packet after dequeuing the packet from crypto queue
+ * \param *des_con Pointer to DES container structure
+ * \param *areq Pointer to ablkcipher_request container
+ * \param state State of the packet (scattered packet or new packet to be processed)
+ * \return -EINVAL: DEU failure, -EINPROGRESS: DEU encrypt/decrypt in progress, 1: no scatterlist left
+*/
+
+static int process_next_packet(struct des_container *des_con, struct ablkcipher_request *areq,
+ int state)
+{
+ u8 *iv;
+ int mode, encdec, err = -EINVAL;
+ u32 remain, inc, chunk_size, nbytes;
+ struct scatterlist *src = NULL;
+ struct scatterlist *dst = NULL;
+ struct crypto_ablkcipher *cipher;
+ struct des_ctx *ctx;
+ unsigned long queue_flag;
+
+ spin_lock_irqsave(&des_queue->lock, queue_flag);
+
+ mode = des_con->mode;
+ encdec = des_con->encdec;
+ iv = des_con->iv;
+
+ if (state & PROCESS_SCATTER) {
+ src = scatterwalk_sg_next(areq->src);
+ dst = scatterwalk_sg_next(areq->dst);
+
+ if (!src || !dst) {
+ spin_unlock_irqrestore(&des_queue->lock, queue_flag);
+ return 1;
+ }
+ }
+ else if (state & PROCESS_NEW_PACKET) {
+ src = areq->src;
+ dst = areq->dst;
+ }
+
+ remain = des_con->bytes_processed;
+ chunk_size = src->length;
+
+ //printk("debug ln: %d, func: %s, reqsize: %d, scattersize: %d\n",
+// __LINE__, __func__, areq->nbytes, chunk_size);
+
+ if (remain > DEU_MAX_PACKET_SIZE)
+ inc = DEU_MAX_PACKET_SIZE;
+ else if(remain > chunk_size)
+ inc = chunk_size;
+ else
+ inc = remain;
+
+ remain -= inc;
+ des_con->nbytes = inc;
+
+ if (state & PROCESS_SCATTER) {
+ des_con->src_buf += des_con->nbytes;
+ des_con->dst_buf += des_con->nbytes;
+ }
+
+ lq_sg_init(des_con, src, dst);
+
+ nbytes = des_con->nbytes;
+
+ cipher = crypto_ablkcipher_reqtfm(areq);
+ ctx = crypto_ablkcipher_ctx(cipher);
+
+ if (des_queue->hw_status == DES_IDLE) {
+ des_queue->hw_status = DES_STARTED;
+ }
+
+ des_con->bytes_processed -= des_con->nbytes;
+ err = ablkcipher_enqueue_request(&des_queue->list, &des_con->arequest);
+ if (err == -EBUSY) {
+ printk("Failed to enqueue request, ln: %d, err: %d\n",
+ __LINE__, err);
+ spin_unlock_irqrestore(&des_queue->lock, queue_flag);
+ return -EINVAL;
+ }
+
+ spin_unlock_irqrestore(&des_queue->lock, queue_flag);
+ err = lq_deu_des_core(ctx, des_con->dst_buf, des_con->src_buf, iv, nbytes, encdec, mode);
+
+ return err;
+}
+
+/* \fn static void process_queue(unsigned long data)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief Process next packet in queue
+ * \param data not used
+ * \return
+*/
+
+static void process_queue(unsigned long data)
+{
+ DEU_WAKEUP_EVENT(deu_dma_priv.deu_thread_wait, DES_ASYNC_EVENT,
+ deu_dma_priv.des_event_flags);
+
+}
+
+/* \fn static int des_crypto_thread (void *data)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief DES thread that handles crypto requests from upper layer & DMA
+ * \param *data Not used
+ * \return -EINVAL: DEU failure, -EBUSY: DEU HW busy, 0: exit thread
+*/
+
+static int des_crypto_thread(void *data)
+{
+ struct des_container *des_con = NULL;
+ struct ablkcipher_request *areq = NULL;
+ int err;
+ unsigned long queue_flag;
+
+ daemonize("lq_des_thread");
+
+ while (1)
+ {
+ DEU_WAIT_EVENT(deu_dma_priv.deu_thread_wait, DES_ASYNC_EVENT,
+ deu_dma_priv.des_event_flags);
+ spin_lock_irqsave(&des_queue->lock, queue_flag);
+
+ /* wait to prevent starting a crypto session before
+ * exiting the dma interrupt thread.
+ */
+
+ if (des_queue->hw_status == DES_STARTED) {
+ areq = ablkcipher_dequeue_request(&des_queue->list);
+ des_con = des_container_cast(areq);
+ des_queue->hw_status = DES_BUSY;
+ }
+ else if (des_queue->hw_status == DES_IDLE) {
+ areq = ablkcipher_dequeue_request(&des_queue->list);
+ des_con = des_container_cast(areq);
+ des_queue->hw_status = DES_STARTED;
+ }
+ else if (des_queue->hw_status == DES_BUSY) {
+ areq = ablkcipher_dequeue_request(&des_queue->list);
+ des_con = des_container_cast(areq);
+ }
+ else if (des_queue->hw_status == DES_COMPLETED) {
+ areq->base.complete(&areq->base, 0);
+ lq_sg_complete(des_con);
+ des_queue->hw_status = DES_IDLE;
+ spin_unlock_irqrestore(&des_queue->lock, queue_flag);
+ return 0;
+ }
+ spin_unlock_irqrestore(&des_queue->lock, queue_flag);
+
+ if ((des_con->bytes_processed == 0)) {
+ goto des_done;
+ }
+
+ if (!des_con) {
+ goto des_done;
+ }
+
+ if (des_con->flag & PROCESS_NEW_PACKET) {
+ des_con->flag = PROCESS_SCATTER;
+ err = process_next_packet(des_con, areq, PROCESS_NEW_PACKET);
+ }
+ else
+ err = process_next_packet(des_con, areq, PROCESS_SCATTER);
+
+ if (err == -EINVAL) {
+ areq->base.complete(&areq->base, err);
+ lq_sg_complete(des_con);
+ printk("src/dst returned -EINVAL in func: %s\n", __func__);
+ }
+ else if (err > 0) {
+ printk("src/dst returned zero in func: %s\n", __func__);
+ goto des_done;
+ }
+
+ continue;
+
+des_done:
+ //printk("debug line - %d, func: %s, qlen: %d\n", __LINE__, __func__, des_queue->list.qlen);
+ areq->base.complete(&areq->base, 0);
+ lq_sg_complete(des_con);
+
+ spin_lock_irqsave(&des_queue->lock, queue_flag);
+ if (des_queue->list.qlen > 0) {
+ spin_unlock_irqrestore(&des_queue->lock, queue_flag);
+ tasklet_schedule(&des_queue->des_task);
+ }
+ else {
+ des_queue->hw_status = DES_IDLE;
+ spin_unlock_irqrestore(&des_queue->lock, queue_flag);
+ }
+ } // while(1)
+
+ return 0;
+
+}
+
+/* \fn static int lq_des_queue_mgr(struct des_ctx *ctx, struct ablkcipher_request *areq,
+ u8 *iv, int encdec, int mode)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief starts the process of queuing DEU requests
+ * \param *ctx crypto algo contax
+ * \param *areq Pointer to the balkcipher requests
+ * \param *iv Pointer to intput vector location
+ * \param dir Encrypt/Decrypt
+ * \mode The mode DES algo is running
+ * \return 0 if success
+*/
+
+static int lq_queue_mgr(struct des_ctx *ctx, struct ablkcipher_request *areq,
+ u8 *iv, int encdec, int mode)
+{
+ int err = -EINVAL;
+ unsigned long queue_flag;
+ struct scatterlist *src = areq->src;
+ struct scatterlist *dst = areq->dst;
+ struct des_container *des_con = NULL;
+ u32 remain, inc, nbytes = areq->nbytes;
+ u32 chunk_bytes = src->length;
+
+ des_con = (struct des_container *)kmalloc(sizeof(struct des_container),
+ GFP_KERNEL);
+
+ if (!(des_con)) {
+ printk("Cannot allocate memory for AES container, fn %s, ln %d\n",
+ __func__, __LINE__);
+ return -ENOMEM;
+ }
+
+ /* DES encrypt/decrypt mode */
+ if (mode == 5) {
+ nbytes = DES_BLOCK_SIZE;
+ chunk_bytes = DES_BLOCK_SIZE;
+ mode = 0;
+ }
+
+ des_con->bytes_processed = nbytes;
+ des_con->arequest = (*areq);
+ remain = nbytes;
+
+ //printk("debug - Line: %d, func: %s, reqsize: %d, scattersize: %d\n",
+ // __LINE__, __func__, nbytes, chunk_bytes);
+
+ if (remain > DEU_MAX_PACKET_SIZE)
+ inc = DEU_MAX_PACKET_SIZE;
+ else if(remain > chunk_bytes)
+ inc = chunk_bytes;
+ else
+ inc = remain;
+
+ remain -= inc;
+ lq_sg_init(des_con, src, dst);
+
+ if (remain <= 0 ) {
+ des_con->complete = 1;
+ }
+ else
+ des_con->complete = 0;
+
+ des_con->nbytes = inc;
+ des_con->iv = iv;
+ des_con->mode = mode;
+ des_con->encdec = encdec;
+
+ spin_lock_irqsave(&des_queue->lock, queue_flag);
+
+ if (des_queue->hw_status == DES_STARTED || des_queue->hw_status == DES_BUSY ||
+ des_queue->list.qlen > 0) {
+
+ des_con->flag = PROCESS_NEW_PACKET;
+ err = ablkcipher_enqueue_request(&des_queue->list, &des_con->arequest);
+ if (err == -EBUSY) {
+ spin_unlock_irqrestore(&des_queue->lock, queue_flag);
+ printk("Fail to enqueue ablkcipher request ln: %d, err: %d\n",
+ __LINE__, err);
+ return err;
+ }
+
+ spin_unlock_irqrestore(&des_queue->lock, queue_flag);
+ return -EINPROGRESS;
+
+ }
+ else if (des_queue->hw_status == DES_IDLE) {
+ des_queue->hw_status = DES_STARTED;
+ }
+
+ des_con->flag = PROCESS_SCATTER;
+ des_con->bytes_processed -= des_con->nbytes;
+
+ err = ablkcipher_enqueue_request(&des_queue->list, &des_con->arequest);
+ if (err == -EBUSY) {
+ printk("Fail to enqueue ablkcipher request ln: %d, err: %d\n",
+ __LINE__, err);
+
+ spin_unlock_irqrestore(&des_queue->lock, queue_flag);
+ return err;
+ }
+
+ spin_unlock_irqrestore(&des_queue->lock, queue_flag);
+ return lq_deu_des_core(ctx, des_con->dst_buf, des_con->src_buf, iv, inc, encdec, mode);
+
+}
+
+/* \fn static int lq_des_encrypt(struct ablkcipher_request *areq)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief Decrypt function for DES algo
+ * \param *areq Pointer to ablkcipher request in memory
+ * \return 0 is success, -EINPROGRESS if encryting, EINVAL if failure
+*/
+
+static int lq_des_encrypt(struct ablkcipher_request *areq)
+{
+ struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
+ struct des_ctx *ctx = crypto_ablkcipher_ctx(cipher);
+
+ return lq_queue_mgr(ctx, areq, NULL, CRYPTO_DIR_ENCRYPT, 5);
+
+}
+
+/* \fn static int lq_des_decrypt(struct ablkcipher_request *areq)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief Decrypt function for DES algo
+ * \param *areq Pointer to ablkcipher request in memory
+ * \return 0 is success, -EINPROGRESS if encryting, EINVAL if failure
+*/
+
+static int lq_des_decrypt(struct ablkcipher_request *areq)
+{
+ struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
+ struct des_ctx *ctx = crypto_ablkcipher_ctx(cipher);
+
+ return lq_queue_mgr(ctx, areq, NULL, CRYPTO_DIR_DECRYPT, 5);
+}
+
+/* \fn static int lq_ecb_des_encrypt(struct ablkcipher_request *areq)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief Decrypt function for DES algo
+ * \param *areq Pointer to ablkcipher request in memory
+ * \return 0 is success, -EINPROGRESS if encryting, EINVAL if failure
+*/
+
+static int lq_ecb_des_encrypt(struct ablkcipher_request *areq)
+{
+ struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
+ struct des_ctx *ctx = crypto_ablkcipher_ctx(cipher);
+
+ return lq_queue_mgr(ctx, areq, areq->info, CRYPTO_DIR_ENCRYPT, 0);
+}
+
+/* \fn static int lq_ecb_des_decrypt(struct ablkcipher_request *areq)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief Decrypt function for DES algo
+ * \param *areq Pointer to ablkcipher request in memory
+ * \return 0 is success, -EINPROGRESS if encryting, EINVAL if failure
+*/
+static int lq_ecb_des_decrypt(struct ablkcipher_request *areq)
+{
+ struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
+ struct des_ctx *ctx = crypto_ablkcipher_ctx(cipher);
+
+ return lq_queue_mgr(ctx, areq, areq->info, CRYPTO_DIR_DECRYPT, 0);
+
+}
+
+/* \fn static int lq_cbc_ecb_des_encrypt(struct ablkcipher_request *areq)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief Decrypt function for DES algo
+ * \param *areq Pointer to ablkcipher request in memory
+ * \return 0 is success, -EINPROGRESS if encryting, EINVAL if failure
+*/
+
+static int lq_cbc_des_encrypt(struct ablkcipher_request *areq)
+{
+ struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
+ struct des_ctx *ctx = crypto_ablkcipher_ctx(cipher);
+
+ return lq_queue_mgr(ctx, areq, areq->info, CRYPTO_DIR_ENCRYPT, 1);
+}
+/* \fn static int lq_cbc_des_decrypt(struct ablkcipher_request *areq)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief Decrypt function for DES algo
+ * \param *areq Pointer to ablkcipher request in memory
+ * \return 0 is success, -EINPROGRESS if encryting, EINVAL if failure
+*/
+
+static int lq_cbc_des_decrypt(struct ablkcipher_request *areq)
+{
+ struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
+ struct des_ctx *ctx = crypto_ablkcipher_ctx(cipher);
+
+ return lq_queue_mgr(ctx, areq, areq->info, CRYPTO_DIR_DECRYPT, 1);
+}
+
+struct lq_des_alg {
+ struct crypto_alg alg;
+};
+
+/* DES Supported algo array */
+static struct lq_des_alg des_drivers_alg [] = {
+ {
+ .alg = {
+ .cra_name = "des",
+ .cra_driver_name = "lqdeu-des",
+ .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
+ .cra_blocksize = DES_BLOCK_SIZE,
+ .cra_ctxsize = sizeof(struct des_ctx),
+ .cra_type = &crypto_ablkcipher_type,
+ .cra_priority = 300,
+ .cra_module = THIS_MODULE,
+ .cra_ablkcipher = {
+ .setkey = lq_des_setkey,
+ .encrypt = lq_des_encrypt,
+ .decrypt = lq_des_decrypt,
+ .geniv = "eseqiv",
+ .min_keysize = DES_KEY_SIZE,
+ .max_keysize = DES_KEY_SIZE,
+ .ivsize = DES_BLOCK_SIZE,
+ }
+ }
+
+ },{
+ .alg = {
+ .cra_name = "ecb(des)",
+ .cra_driver_name = "lqdeu-ecb(des)",
+ .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
+ .cra_blocksize = DES_BLOCK_SIZE,
+ .cra_ctxsize = sizeof(struct des_ctx),
+ .cra_type = &crypto_ablkcipher_type,
+ .cra_priority = 300,
+ .cra_module = THIS_MODULE,
+ .cra_ablkcipher = {
+ .setkey = lq_des_setkey,
+ .encrypt = lq_ecb_des_encrypt,
+ .decrypt = lq_ecb_des_decrypt,
+ .geniv = "eseqiv",
+ .min_keysize = DES_KEY_SIZE,
+ .max_keysize = DES_KEY_SIZE,
+ .ivsize = DES_BLOCK_SIZE,
+ }
+ }
+ },{
+ .alg = {
+ .cra_name = "cbc(des)",
+ .cra_driver_name = "lqdeu-cbc(des)",
+ .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
+ .cra_blocksize = DES_BLOCK_SIZE,
+ .cra_ctxsize = sizeof(struct des_ctx),
+ .cra_type = &crypto_ablkcipher_type,
+ .cra_priority = 300,
+ .cra_module = THIS_MODULE,
+ .cra_ablkcipher = {
+ .setkey = lq_des_setkey,
+ .encrypt = lq_cbc_des_encrypt,
+ .decrypt = lq_cbc_des_decrypt,
+ .geniv = "eseqiv",
+ .min_keysize = DES3_EDE_KEY_SIZE,
+ .max_keysize = DES3_EDE_KEY_SIZE,
+ .ivsize = DES3_EDE_BLOCK_SIZE,
+ }
+ }
+ },{
+ .alg = {
+ .cra_name = "des3_ede",
+ .cra_driver_name = "lqdeu-des3_ede",
+ .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
+ .cra_blocksize = DES_BLOCK_SIZE,
+ .cra_ctxsize = sizeof(struct des_ctx),
+ .cra_type = &crypto_ablkcipher_type,
+ .cra_priority = 300,
+ .cra_module = THIS_MODULE,
+ .cra_ablkcipher = {
+ .setkey = lq_des3_ede_setkey,
+ .encrypt = lq_des_encrypt,
+ .decrypt = lq_des_decrypt,
+ .geniv = "eseqiv",
+ .min_keysize = DES_KEY_SIZE,
+ .max_keysize = DES_KEY_SIZE,
+ .ivsize = DES_BLOCK_SIZE,
+ }
+ }
+ },{
+ .alg = {
+ .cra_name = "ecb(des3_ede)",
+ .cra_driver_name = "lqdeu-ecb(des3_ede)",
+ .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
+ .cra_blocksize = DES_BLOCK_SIZE,
+ .cra_ctxsize = sizeof(struct des_ctx),
+ .cra_type = &crypto_ablkcipher_type,
+ .cra_priority = 300,
+ .cra_module = THIS_MODULE,
+ .cra_ablkcipher = {
+ .setkey = lq_des3_ede_setkey,
+ .encrypt = lq_ecb_des_encrypt,
+ .decrypt = lq_ecb_des_decrypt,
+ .geniv = "eseqiv",
+ .min_keysize = DES3_EDE_KEY_SIZE,
+ .max_keysize = DES3_EDE_KEY_SIZE,
+ .ivsize = DES3_EDE_BLOCK_SIZE,
+ }
+ }
+ },{
+ .alg = {
+ .cra_name = "cbc(des3_ede)",
+ .cra_driver_name = "lqdeu-cbc(des3_ede)",
+ .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
+ .cra_blocksize = DES_BLOCK_SIZE,
+ .cra_ctxsize = sizeof(struct des_ctx),
+ .cra_type = &crypto_ablkcipher_type,
+ .cra_priority = 300,
+ .cra_module = THIS_MODULE,
+ .cra_ablkcipher = {
+ .setkey = lq_des3_ede_setkey,
+ .encrypt = lq_cbc_des_encrypt,
+ .decrypt = lq_cbc_des_decrypt,
+ .geniv = "eseqiv",
+ .min_keysize = DES3_EDE_KEY_SIZE,
+ .max_keysize = DES3_EDE_KEY_SIZE,
+ .ivsize = DES3_EDE_BLOCK_SIZE,
+ }
+ }
+ }
+};
+
+/*! \fn int __init lqdeu_async_des_init (void)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief initialize des driver
+*/
+int __init lqdeu_async_des_init (void)
+{
+ int i, j, ret = -EINVAL;
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20))
+ if (!disable_multiblock) {
+ ifxdeu_des_alg.cra_u.cipher.cia_max_nbytes = DES_BLOCK_SIZE; //(size_t)-1;
+ ifxdeu_des_alg.cra_u.cipher.cia_req_align = 16;
+ ifxdeu_des_alg.cra_u.cipher.cia_ecb = ifx_deu_des_ecb;
+ ifxdeu_des_alg.cra_u.cipher.cia_cbc = ifx_deu_des_cbc;
+ ifxdeu_des_alg.cra_u.cipher.cia_cfb = ifx_deu_des_cfb;
+ ifxdeu_des_alg.cra_u.cipher.cia_ofb = ifx_deu_des_ofb;
+ }
+#endif
+ for (i = 0; i < ARRAY_SIZE(des_drivers_alg); i++) {
+ ret = crypto_register_alg(&des_drivers_alg[i].alg);
+ //printk("driver: %s\n", des_drivers_alg[i].alg.cra_name);
+ if (ret)
+ goto des_err;
+ }
+
+ des_chip_init();
+ CRTCL_SECT_INIT;
+
+
+ printk (KERN_NOTICE "IFX DEU DES initialized%s%s.\n", disable_multiblock ? "" : " (multiblock)", disable_deudma ? "" : " (DMA)");
+ return ret;
+
+des_err:
+ for (j = 0; j < i; j++)
+ crypto_unregister_alg(&des_drivers_alg[i].alg);
+
+ printk(KERN_ERR "Lantiq %s driver initialization failed!\n", (char *)&des_drivers_alg[i].alg.cra_driver_name);
+ return ret;
+
+cbc_des3_ede_err:
+ for (i = 0; i < ARRAY_SIZE(des_drivers_alg); i++) {
+ if (!strcmp((char *)&des_drivers_alg[i].alg.cra_name, "cbc(des3_ede)"))
+ crypto_unregister_alg(&des_drivers_alg[i].alg);
+ }
+
+ printk(KERN_ERR "Lantiq %s driver initialization failed!\n", (char *)&des_drivers_alg[i].alg.cra_driver_name);
+ return ret;
+}
+
+/*! \fn void __exit lqdeu_fini_async_des (void)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief unregister des driver
+*/
+void __exit lqdeu_fini_async_des (void)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(des_drivers_alg); i++)
+ crypto_unregister_alg(&des_drivers_alg[i].alg);
+
+ des_queue->hw_status = DES_COMPLETED;
+ DEU_WAKEUP_EVENT(deu_dma_priv.deu_thread_wait, DES_ASYNC_EVENT,
+ deu_dma_priv.des_event_flags);
+
+ kfree(des_queue);
+}
+
diff --git a/package/platform/lantiq/ltq-deu/src/ifxmips_des.c b/package/platform/lantiq/ltq-deu/src/ifxmips_des.c
new file mode 100644
index 0000000..dcf6c18
--- /dev/null
+++ b/package/platform/lantiq/ltq-deu/src/ifxmips_des.c
@@ -0,0 +1,768 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_des.c
+** PROJECT : IFX UEIP
+** MODULES : DEU Module
+**
+** DATE : September 8, 2009
+** AUTHOR : Mohammad Firdaus
+** DESCRIPTION : Data Encryption Unit Driver for DES Algorithm
+** COPYRIGHT : Copyright (c) 2009
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 08 Sept 2009 Mohammad Firdaus Initial UEIP release
+*******************************************************************************/
+
+/*!
+ \defgroup IFX_DEU IFX_DEU_DRIVERS
+ \ingroup API
+ \brief ifx deu driver
+*/
+
+/*!
+ \file ifxmips_des.c
+ \ingroup IFX_DEU
+ \brief DES encryption DEU driver file
+*/
+
+/*!
+ \defgroup IFX_DES_FUNCTIONS IFX_DES_FUNCTIONS
+ \ingroup IFX_DEU
+ \brief IFX DES Encryption functions
+*/
+
+/* Project Header Files */
+#include <linux/version.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/crypto.h>
+#include <linux/interrupt.h>
+#include <linux/delay.h>
+#include <asm/byteorder.h>
+#include <crypto/algapi.h>
+#include "ifxmips_deu.h"
+
+#if defined(CONFIG_DANUBE)
+#include "ifxmips_deu_danube.h"
+extern int ifx_danube_pre_1_4;
+#elif defined(CONFIG_AR9)
+#include "ifxmips_deu_ar9.h"
+#elif defined(CONFIG_VR9) || defined(CONFIG_AR10)
+#include "ifxmips_deu_vr9.h"
+#else
+#error "Unkown platform"
+#endif
+
+/* DMA specific header and variables */
+
+#if 0
+ #define CRTCL_SECT_INIT
+ #define CRTCL_SECT_START
+ #define CRTCL_SECT_END
+#else
+spinlock_t des_lock;
+#define CRTCL_SECT_INIT spin_lock_init(&des_lock)
+#define CRTCL_SECT_START spin_lock_irqsave(&des_lock, flag)
+#define CRTCL_SECT_END spin_unlock_irqrestore(&des_lock, flag)
+#endif
+
+/* Preprocessor declerations */
+#ifdef CRYPTO_DEBUG
+extern char debug_level;
+#define DPRINTF(level, format, args...) if (level < debug_level) printk(KERN_INFO "[%s %s %d]: " format, __FILE__, __func__, __LINE__, ##args);
+#else
+#define DPRINTF(level, format, args...)
+#endif
+#define DES_3DES_START IFX_DES_CON
+#define DES_KEY_SIZE 8
+#define DES_EXPKEY_WORDS 32
+#define DES_BLOCK_SIZE 8
+#define DES3_EDE_KEY_SIZE (3 * DES_KEY_SIZE)
+#define DES3_EDE_EXPKEY_WORDS (3 * DES_EXPKEY_WORDS)
+#define DES3_EDE_BLOCK_SIZE DES_BLOCK_SIZE
+
+/* Function Declaration to prevent warning messages */
+void des_chip_init (void);
+u32 endian_swap(u32 input);
+u32 input_swap(u32 input);
+int aes_memory_allocate(int value);
+int des_memory_allocate(int value);
+void memory_release(u32 *buffer);
+u32* memory_alignment(const u8 *arg, u32 *buff_alloc, int in_out, int nbytes);
+void aes_dma_memory_copy(u32 *outcopy, u32 *out_dma, u8 *out_arg, int nbytes);
+void des_dma_memory_copy(u32 *outcopy, u32 *out_dma, u8 *out_arg, int nbytes);
+
+void ifx_deu_des (void *ctx_arg, u8 *out_arg, const u8 *in_arg,
+ u8 *iv_arg, u32 nbytes, int encdec, int mode);
+
+struct des_ctx {
+ int controlr_M;
+ int key_length;
+ u8 iv[DES_BLOCK_SIZE];
+ u32 expkey[DES3_EDE_EXPKEY_WORDS];
+};
+
+extern int disable_multiblock;
+extern int disable_deudma;
+
+
+/*! \fn int des_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief sets DES key
+ * \param tfm linux crypto algo transform
+ * \param key input key
+ * \param keylen key length
+*/
+int des_setkey(struct crypto_tfm *tfm, const u8 *key,
+ unsigned int keylen)
+{
+ struct des_ctx *dctx = crypto_tfm_ctx(tfm);
+
+ //printk("setkey in %s\n", __FILE__);
+
+ dctx->controlr_M = 0; // des
+ dctx->key_length = keylen;
+
+ memcpy ((u8 *) (dctx->expkey), key, keylen);
+
+ return 0;
+}
+
+
+/*! \fn void ifx_deu_des(void *ctx_arg, u8 *out_arg, const u8 *in_arg, u8 *iv_arg, u32 nbytes, int encdec, int mode)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief main interface to DES hardware
+ * \param ctx_arg crypto algo context
+ * \param out_arg output bytestream
+ * \param in_arg input bytestream
+ * \param iv_arg initialization vector
+ * \param nbytes length of bytestream
+ * \param encdec 1 for encrypt; 0 for decrypt
+ * \param mode operation mode such as ebc, cbc
+*/
+
+void ifx_deu_des (void *ctx_arg, u8 *out_arg, const u8 *in_arg,
+ u8 *iv_arg, u32 nbytes, int encdec, int mode)
+{
+ volatile struct des_t *des = (struct des_t *) DES_3DES_START;
+ struct des_ctx *dctx = ctx_arg;
+ u32 *key = dctx->expkey;
+ unsigned long flag;
+
+ int i = 0;
+ int nblocks = 0;
+
+ CRTCL_SECT_START;
+
+ des->controlr.M = dctx->controlr_M;
+ if (dctx->controlr_M == 0) // des
+ {
+ des->K1HR = DEU_ENDIAN_SWAP(*((u32 *) key + 0));
+ des->K1LR = DEU_ENDIAN_SWAP(*((u32 *) key + 1));
+
+ }
+ else {
+ /* Hardware Section */
+ switch (dctx->key_length) {
+ case 24:
+ des->K3HR = DEU_ENDIAN_SWAP(*((u32 *) key + 4));
+ des->K3LR = DEU_ENDIAN_SWAP(*((u32 *) key + 5));
+ /* no break; */
+
+ case 16:
+ des->K2HR = DEU_ENDIAN_SWAP(*((u32 *) key + 2));
+ des->K2LR = DEU_ENDIAN_SWAP(*((u32 *) key + 3));
+
+ /* no break; */
+ case 8:
+ des->K1HR = DEU_ENDIAN_SWAP(*((u32 *) key + 0));
+ des->K1LR = DEU_ENDIAN_SWAP(*((u32 *) key + 1));
+ break;
+
+ default:
+ CRTCL_SECT_END;
+ return;
+ }
+ }
+
+ des->controlr.E_D = !encdec; //encryption
+ des->controlr.O = mode; //0 ECB 1 CBC 2 OFB 3 CFB 4 CTR hexdump(prin,sizeof(*des));
+
+ if (mode > 0) {
+ des->IVHR = DEU_ENDIAN_SWAP(*(u32 *) iv_arg);
+ des->IVLR = DEU_ENDIAN_SWAP(*((u32 *) iv_arg + 1));
+ };
+
+ nblocks = nbytes / 4;
+
+ for (i = 0; i < nblocks; i += 2) {
+ /* wait for busy bit to clear */
+
+ /*--- Workaround ----------------------------------------------------
+ do a dummy read to the busy flag because it is not raised early
+ enough in CFB/OFB 3DES modes */
+#ifdef CRYPTO_DEBUG
+ printk ("ihr: %x\n", (*((u32 *) in_arg + i)));
+ printk ("ilr: %x\n", (*((u32 *) in_arg + 1 + i)));
+#endif
+ des->IHR = INPUT_ENDIAN_SWAP(*((u32 *) in_arg + i));
+ des->ILR = INPUT_ENDIAN_SWAP(*((u32 *) in_arg + 1 + i)); /* start crypto */
+
+ while (des->controlr.BUS) {
+ // this will not take long
+ }
+
+ *((u32 *) out_arg + 0 + i) = des->OHR;
+ *((u32 *) out_arg + 1 + i) = des->OLR;
+
+ }
+
+
+
+ if (mode > 0) {
+ *(u32 *) iv_arg = DEU_ENDIAN_SWAP(des->IVHR);
+ *((u32 *) iv_arg + 1) = DEU_ENDIAN_SWAP(des->IVLR);
+ };
+
+ CRTCL_SECT_END;
+}
+
+//definitions from linux/include/crypto.h:
+//#define CRYPTO_TFM_MODE_ECB 0x00000001
+//#define CRYPTO_TFM_MODE_CBC 0x00000002
+//#define CRYPTO_TFM_MODE_CFB 0x00000004
+//#define CRYPTO_TFM_MODE_CTR 0x00000008
+//#define CRYPTO_TFM_MODE_OFB 0x00000010 // not even defined
+//but hardware definition: 0 ECB 1 CBC 2 OFB 3 CFB 4 CTR
+
+/*! \fn void ifx_deu_des(void *ctx_arg, u8 *out_arg, const u8 *in_arg, u8 *iv_arg, u32 nbytes, int encdec, int mode)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief main interface to DES hardware
+ * \param ctx_arg crypto algo context
+ * \param out_arg output bytestream
+ * \param in_arg input bytestream
+ * \param iv_arg initialization vector
+ * \param nbytes length of bytestream
+ * \param encdec 1 for encrypt; 0 for decrypt
+ * \param mode operation mode such as ebc, cbc
+*/
+
+
+
+/*! \fn void ifx_deu_des_ecb (void *ctx, uint8_t *dst, const uint8_t *src, uint8_t *iv, size_t nbytes, int encdec, int inplace)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief sets DES hardware to ECB mode
+ * \param ctx crypto algo context
+ * \param dst output bytestream
+ * \param src input bytestream
+ * \param iv initialization vector
+ * \param nbytes length of bytestream
+ * \param encdec 1 for encrypt; 0 for decrypt
+ * \param inplace not used
+*/
+
+void ifx_deu_des_ecb (void *ctx, uint8_t *dst, const uint8_t *src,
+ uint8_t *iv, size_t nbytes, int encdec, int inplace)
+{
+ ifx_deu_des (ctx, dst, src, NULL, nbytes, encdec, 0);
+}
+
+/*! \fn void ifx_deu_des_cbc (void *ctx, uint8_t *dst, const uint8_t *src, uint8_t *iv, size_t nbytes, int encdec, int inplace)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief sets DES hardware to CBC mode
+ * \param ctx crypto algo context
+ * \param dst output bytestream
+ * \param src input bytestream
+ * \param iv initialization vector
+ * \param nbytes length of bytestream
+ * \param encdec 1 for encrypt; 0 for decrypt
+ * \param inplace not used
+*/
+void ifx_deu_des_cbc (void *ctx, uint8_t *dst, const uint8_t *src,
+ uint8_t *iv, size_t nbytes, int encdec, int inplace)
+{
+ ifx_deu_des (ctx, dst, src, iv, nbytes, encdec, 1);
+}
+
+/*! \fn void ifx_deu_des_ofb (void *ctx, uint8_t *dst, const uint8_t *src, uint8_t *iv, size_t nbytes, int encdec, int inplace)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief sets DES hardware to OFB mode
+ * \param ctx crypto algo context
+ * \param dst output bytestream
+ * \param src input bytestream
+ * \param iv initialization vector
+ * \param nbytes length of bytestream
+ * \param encdec 1 for encrypt; 0 for decrypt
+ * \param inplace not used
+*/
+void ifx_deu_des_ofb (void *ctx, uint8_t *dst, const uint8_t *src,
+ uint8_t *iv, size_t nbytes, int encdec, int inplace)
+{
+ ifx_deu_des (ctx, dst, src, iv, nbytes, encdec, 2);
+}
+
+/*! \fn void ifx_deu_des_cfb (void *ctx, uint8_t *dst, const uint8_t *src, uint8_t *iv, size_t nbytes, int encdec, int inplace)
+ \ingroup IFX_DES_FUNCTIONS
+ \brief sets DES hardware to CFB mode
+ \param ctx crypto algo context
+ \param dst output bytestream
+ \param src input bytestream
+ \param iv initialization vector
+ \param nbytes length of bytestream
+ \param encdec 1 for encrypt; 0 for decrypt
+ \param inplace not used
+*/
+void ifx_deu_des_cfb (void *ctx, uint8_t *dst, const uint8_t *src,
+ uint8_t *iv, size_t nbytes, int encdec, int inplace)
+{
+ ifx_deu_des (ctx, dst, src, iv, nbytes, encdec, 3);
+}
+
+/*! \fn void ifx_deu_des_ctr (void *ctx, uint8_t *dst, const uint8_t *src, uint8_t *iv, size_t nbytes, int encdec, int inplace)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief sets DES hardware to CTR mode
+ * \param ctx crypto algo context
+ * \param dst output bytestream
+ * \param src input bytestream
+ * \param iv initialization vector
+ * \param nbytes length of bytestream
+ * \param encdec 1 for encrypt; 0 for decrypt
+ * \param inplace not used
+*/
+void ifx_deu_des_ctr (void *ctx, uint8_t *dst, const uint8_t *src,
+ uint8_t *iv, size_t nbytes, int encdec, int inplace)
+{
+ ifx_deu_des (ctx, dst, src, iv, nbytes, encdec, 4);
+}
+
+/*! \fn void des_encrypt (struct crypto_tfm *tfm, uint8_t *out, const uint8_t *in)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief encrypt DES_BLOCK_SIZE of data
+ * \param tfm linux crypto algo transform
+ * \param out output bytestream
+ * \param in input bytestream
+*/
+void des_encrypt (struct crypto_tfm *tfm, uint8_t * out, const uint8_t * in)
+{
+ struct des_ctx *ctx = crypto_tfm_ctx(tfm);
+ ifx_deu_des (ctx, out, in, NULL, DES_BLOCK_SIZE,
+ CRYPTO_DIR_ENCRYPT, 0);
+
+}
+
+/*! \fn void des_decrypt (struct crypto_tfm *tfm, uint8_t *out, const uint8_t *in)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief encrypt DES_BLOCK_SIZE of data
+ * \param tfm linux crypto algo transform
+ * \param out output bytestream
+ * \param in input bytestream
+*/
+void des_decrypt (struct crypto_tfm *tfm, uint8_t * out, const uint8_t * in)
+{
+ struct des_ctx *ctx = crypto_tfm_ctx(tfm);
+ ifx_deu_des (ctx, out, in, NULL, DES_BLOCK_SIZE,
+ CRYPTO_DIR_DECRYPT, 0);
+}
+
+/*
+ * \brief RFC2451:
+ *
+ * For DES-EDE3, there is no known need to reject weak or
+ * complementation keys. Any weakness is obviated by the use of
+ * multiple keys.
+ *
+ * However, if the first two or last two independent 64-bit keys are
+ * equal (k1 == k2 or k2 == k3), then the DES3 operation is simply the
+ * same as DES. Implementers MUST reject keys that exhibit this
+ * property.
+ *
+ */
+
+/*! \fn int des3_ede_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief sets 3DES key
+ * \param tfm linux crypto algo transform
+ * \param key input key
+ * \param keylen key length
+*/
+int des3_ede_setkey(struct crypto_tfm *tfm, const u8 *key,
+ unsigned int keylen)
+{
+ struct des_ctx *dctx = crypto_tfm_ctx(tfm);
+
+ //printk("setkey in %s\n", __FILE__);
+
+ dctx->controlr_M = keylen / 8 + 1; // 3DES EDE1 / EDE2 / EDE3 Mode
+ dctx->key_length = keylen;
+
+ memcpy ((u8 *) (dctx->expkey), key, keylen);
+
+ return 0;
+}
+
+/*
+ * \brief DES function mappings
+*/
+struct crypto_alg ifxdeu_des_alg = {
+ .cra_name = "des",
+ .cra_driver_name = "ifxdeu-des",
+ .cra_flags = CRYPTO_ALG_TYPE_CIPHER,
+ .cra_blocksize = DES_BLOCK_SIZE,
+ .cra_ctxsize = sizeof(struct des_ctx),
+ .cra_module = THIS_MODULE,
+ .cra_alignmask = 3,
+ .cra_list = LIST_HEAD_INIT(ifxdeu_des_alg.cra_list),
+ .cra_u = { .cipher = {
+ .cia_min_keysize = DES_KEY_SIZE,
+ .cia_max_keysize = DES_KEY_SIZE,
+ .cia_setkey = des_setkey,
+ .cia_encrypt = des_encrypt,
+ .cia_decrypt = des_decrypt } }
+};
+
+/*
+ * \brief DES function mappings
+*/
+struct crypto_alg ifxdeu_des3_ede_alg = {
+ .cra_name = "des3_ede",
+ .cra_driver_name = "ifxdeu-des3_ede",
+ .cra_flags = CRYPTO_ALG_TYPE_CIPHER,
+ .cra_blocksize = DES_BLOCK_SIZE,
+ .cra_ctxsize = sizeof(struct des_ctx),
+ .cra_module = THIS_MODULE,
+ .cra_alignmask = 3,
+ .cra_list = LIST_HEAD_INIT(ifxdeu_des3_ede_alg.cra_list),
+ .cra_u = { .cipher = {
+ .cia_min_keysize = DES_KEY_SIZE,
+ .cia_max_keysize = DES_KEY_SIZE,
+ .cia_setkey = des3_ede_setkey,
+ .cia_encrypt = des_encrypt,
+ .cia_decrypt = des_decrypt } }
+};
+
+/*! \fn int ecb_des_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief ECB DES encrypt using linux crypto blkcipher
+ * \param desc blkcipher descriptor
+ * \param dst output scatterlist
+ * \param src input scatterlist
+ * \param nbytes data size in bytes
+*/
+int ecb_des_encrypt(struct blkcipher_desc *desc,
+ struct scatterlist *dst, struct scatterlist *src,
+ unsigned int nbytes)
+{
+ struct des_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
+ struct blkcipher_walk walk;
+ int err;
+
+ blkcipher_walk_init(&walk, dst, src, nbytes);
+ err = blkcipher_walk_virt(desc, &walk);
+
+ while ((nbytes = walk.nbytes)) {
+ nbytes -= (nbytes % DES_BLOCK_SIZE);
+ ifx_deu_des_ecb(ctx, walk.dst.virt.addr, walk.src.virt.addr,
+ NULL, nbytes, CRYPTO_DIR_ENCRYPT, 0);
+ nbytes &= DES_BLOCK_SIZE - 1;
+ err = blkcipher_walk_done(desc, &walk, nbytes);
+ }
+
+ return err;
+}
+
+/*! \fn int ecb_des_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief ECB DES decrypt using linux crypto blkcipher
+ * \param desc blkcipher descriptor
+ * \param dst output scatterlist
+ * \param src input scatterlist
+ * \param nbytes data size in bytes
+ * \return err
+*/
+int ecb_des_decrypt(struct blkcipher_desc *desc,
+ struct scatterlist *dst, struct scatterlist *src,
+ unsigned int nbytes)
+{
+ struct des_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
+ struct blkcipher_walk walk;
+ int err;
+
+ DPRINTF(1, "\n");
+ blkcipher_walk_init(&walk, dst, src, nbytes);
+ err = blkcipher_walk_virt(desc, &walk);
+
+ while ((nbytes = walk.nbytes)) {
+ nbytes -= (nbytes % DES_BLOCK_SIZE);
+ ifx_deu_des_ecb(ctx, walk.dst.virt.addr, walk.src.virt.addr,
+ NULL, nbytes, CRYPTO_DIR_DECRYPT, 0);
+ nbytes &= DES_BLOCK_SIZE - 1;
+ err = blkcipher_walk_done(desc, &walk, nbytes);
+ }
+
+ return err;
+}
+
+/*
+ * \brief DES function mappings
+*/
+struct crypto_alg ifxdeu_ecb_des_alg = {
+ .cra_name = "ecb(des)",
+ .cra_driver_name = "ifxdeu-ecb(des)",
+ .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER,
+ .cra_blocksize = DES_BLOCK_SIZE,
+ .cra_ctxsize = sizeof(struct des_ctx),
+ .cra_type = &crypto_blkcipher_type,
+ .cra_module = THIS_MODULE,
+ .cra_list = LIST_HEAD_INIT(ifxdeu_ecb_des_alg.cra_list),
+ .cra_u = {
+ .blkcipher = {
+ .min_keysize = DES_KEY_SIZE,
+ .max_keysize = DES_KEY_SIZE,
+ .setkey = des_setkey,
+ .encrypt = ecb_des_encrypt,
+ .decrypt = ecb_des_decrypt,
+ }
+ }
+};
+
+/*
+ * \brief DES function mappings
+*/
+struct crypto_alg ifxdeu_ecb_des3_ede_alg = {
+ .cra_name = "ecb(des3_ede)",
+ .cra_driver_name = "ifxdeu-ecb(des3_ede)",
+ .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER,
+ .cra_blocksize = DES3_EDE_BLOCK_SIZE,
+ .cra_ctxsize = sizeof(struct des_ctx),
+ .cra_type = &crypto_blkcipher_type,
+ .cra_module = THIS_MODULE,
+ .cra_list = LIST_HEAD_INIT(ifxdeu_ecb_des3_ede_alg.cra_list),
+ .cra_u = {
+ .blkcipher = {
+ .min_keysize = DES3_EDE_KEY_SIZE,
+ .max_keysize = DES3_EDE_KEY_SIZE,
+ .setkey = des3_ede_setkey,
+ .encrypt = ecb_des_encrypt,
+ .decrypt = ecb_des_decrypt,
+ }
+ }
+};
+
+/*! \fn int cbc_des_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief CBC DES encrypt using linux crypto blkcipher
+ * \param desc blkcipher descriptor
+ * \param dst output scatterlist
+ * \param src input scatterlist
+ * \param nbytes data size in bytes
+ * \return err
+*/
+int cbc_des_encrypt(struct blkcipher_desc *desc,
+ struct scatterlist *dst, struct scatterlist *src,
+ unsigned int nbytes)
+{
+ struct des_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
+ struct blkcipher_walk walk;
+ int err;
+
+ DPRINTF(1, "\n");
+ blkcipher_walk_init(&walk, dst, src, nbytes);
+ err = blkcipher_walk_virt(desc, &walk);
+
+ while ((nbytes = walk.nbytes)) {
+ u8 *iv = walk.iv;
+ nbytes -= (nbytes % DES_BLOCK_SIZE);
+ ifx_deu_des_cbc(ctx, walk.dst.virt.addr, walk.src.virt.addr,
+ iv, nbytes, CRYPTO_DIR_ENCRYPT, 0);
+ nbytes &= DES_BLOCK_SIZE - 1;
+ err = blkcipher_walk_done(desc, &walk, nbytes);
+ }
+
+ return err;
+}
+
+/*! \fn int cbc_des_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief CBC DES decrypt using linux crypto blkcipher
+ * \param desc blkcipher descriptor
+ * \param dst output scatterlist
+ * \param src input scatterlist
+ * \param nbytes data size in bytes
+ * \return err
+*/
+int cbc_des_decrypt(struct blkcipher_desc *desc,
+ struct scatterlist *dst, struct scatterlist *src,
+ unsigned int nbytes)
+{
+ struct des_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
+ struct blkcipher_walk walk;
+ int err;
+
+ DPRINTF(1, "\n");
+ blkcipher_walk_init(&walk, dst, src, nbytes);
+ err = blkcipher_walk_virt(desc, &walk);
+
+ while ((nbytes = walk.nbytes)) {
+ u8 *iv = walk.iv;
+ nbytes -= (nbytes % DES_BLOCK_SIZE);
+ ifx_deu_des_cbc(ctx, walk.dst.virt.addr, walk.src.virt.addr,
+ iv, nbytes, CRYPTO_DIR_DECRYPT, 0);
+ nbytes &= DES_BLOCK_SIZE - 1;
+ err = blkcipher_walk_done(desc, &walk, nbytes);
+ }
+
+ return err;
+}
+
+/*
+ * \brief DES function mappings
+*/
+struct crypto_alg ifxdeu_cbc_des_alg = {
+ .cra_name = "cbc(des)",
+ .cra_driver_name = "ifxdeu-cbc(des)",
+ .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER,
+ .cra_blocksize = DES_BLOCK_SIZE,
+ .cra_ctxsize = sizeof(struct des_ctx),
+ .cra_type = &crypto_blkcipher_type,
+ .cra_module = THIS_MODULE,
+ .cra_list = LIST_HEAD_INIT(ifxdeu_cbc_des_alg.cra_list),
+ .cra_u = {
+ .blkcipher = {
+ .min_keysize = DES_KEY_SIZE,
+ .max_keysize = DES_KEY_SIZE,
+ .ivsize = DES_BLOCK_SIZE,
+ .setkey = des_setkey,
+ .encrypt = cbc_des_encrypt,
+ .decrypt = cbc_des_decrypt,
+ }
+ }
+};
+
+/*
+ * \brief DES function mappings
+*/
+struct crypto_alg ifxdeu_cbc_des3_ede_alg = {
+ .cra_name = "cbc(des3_ede)",
+ .cra_driver_name = "ifxdeu-cbc(des3_ede)",
+ .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER,
+ .cra_blocksize = DES3_EDE_BLOCK_SIZE,
+ .cra_ctxsize = sizeof(struct des_ctx),
+ .cra_type = &crypto_blkcipher_type,
+ .cra_module = THIS_MODULE,
+ .cra_list = LIST_HEAD_INIT(ifxdeu_cbc_des3_ede_alg.cra_list),
+ .cra_u = {
+ .blkcipher = {
+ .min_keysize = DES3_EDE_KEY_SIZE,
+ .max_keysize = DES3_EDE_KEY_SIZE,
+ .ivsize = DES_BLOCK_SIZE,
+ .setkey = des3_ede_setkey,
+ .encrypt = cbc_des_encrypt,
+ .decrypt = cbc_des_decrypt,
+ }
+ }
+};
+
+/*! \fn int __init ifxdeu_init_des (void)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief initialize des driver
+*/
+int __init ifxdeu_init_des (void)
+{
+ int ret = -ENOSYS;
+
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20))
+ if (!disable_multiblock) {
+ ifxdeu_des_alg.cra_u.cipher.cia_max_nbytes = DES_BLOCK_SIZE; //(size_t)-1;
+ ifxdeu_des_alg.cra_u.cipher.cia_req_align = 16;
+ ifxdeu_des_alg.cra_u.cipher.cia_ecb = ifx_deu_des_ecb;
+ ifxdeu_des_alg.cra_u.cipher.cia_cbc = ifx_deu_des_cbc;
+ ifxdeu_des_alg.cra_u.cipher.cia_cfb = ifx_deu_des_cfb;
+ ifxdeu_des_alg.cra_u.cipher.cia_ofb = ifx_deu_des_ofb;
+ }
+#endif
+
+ ret = crypto_register_alg(&ifxdeu_des_alg);
+ if (ret < 0)
+ goto des_err;
+
+ ret = crypto_register_alg(&ifxdeu_ecb_des_alg);
+ if (ret < 0)
+ goto ecb_des_err;
+
+ ret = crypto_register_alg(&ifxdeu_cbc_des_alg);
+ if (ret < 0)
+ goto cbc_des_err;
+
+ ret = crypto_register_alg(&ifxdeu_des3_ede_alg);
+ if (ret < 0)
+ goto des3_ede_err;
+
+ ret = crypto_register_alg(&ifxdeu_ecb_des3_ede_alg);
+ if (ret < 0)
+ goto ecb_des3_ede_err;
+
+ ret = crypto_register_alg(&ifxdeu_cbc_des3_ede_alg);
+ if (ret < 0)
+ goto cbc_des3_ede_err;
+
+ des_chip_init();
+ CRTCL_SECT_INIT;
+
+
+
+ printk (KERN_NOTICE "IFX DEU DES initialized%s%s.\n", disable_multiblock ? "" : " (multiblock)", disable_deudma ? "" : " (DMA)");
+ return ret;
+
+des_err:
+ crypto_unregister_alg(&ifxdeu_des_alg);
+ printk(KERN_ERR "IFX des initialization failed!\n");
+ return ret;
+ecb_des_err:
+ crypto_unregister_alg(&ifxdeu_ecb_des_alg);
+ printk (KERN_ERR "IFX ecb_des initialization failed!\n");
+ return ret;
+cbc_des_err:
+ crypto_unregister_alg(&ifxdeu_cbc_des_alg);
+ printk (KERN_ERR "IFX cbc_des initialization failed!\n");
+ return ret;
+des3_ede_err:
+ crypto_unregister_alg(&ifxdeu_des3_ede_alg);
+ printk(KERN_ERR "IFX des3_ede initialization failed!\n");
+ return ret;
+ecb_des3_ede_err:
+ crypto_unregister_alg(&ifxdeu_ecb_des3_ede_alg);
+ printk (KERN_ERR "IFX ecb_des3_ede initialization failed!\n");
+ return ret;
+cbc_des3_ede_err:
+ crypto_unregister_alg(&ifxdeu_cbc_des3_ede_alg);
+ printk (KERN_ERR "IFX cbc_des3_ede initialization failed!\n");
+ return ret;
+
+}
+
+/*! \fn void __exit ifxdeu_fini_des (void)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief unregister des driver
+*/
+void __exit ifxdeu_fini_des (void)
+{
+ crypto_unregister_alg (&ifxdeu_des_alg);
+ crypto_unregister_alg (&ifxdeu_ecb_des_alg);
+ crypto_unregister_alg (&ifxdeu_cbc_des_alg);
+ crypto_unregister_alg (&ifxdeu_des3_ede_alg);
+ crypto_unregister_alg (&ifxdeu_ecb_des3_ede_alg);
+ crypto_unregister_alg (&ifxdeu_cbc_des3_ede_alg);
+
+}
+
diff --git a/package/platform/lantiq/ltq-deu/src/ifxmips_deu.c b/package/platform/lantiq/ltq-deu/src/ifxmips_deu.c
new file mode 100644
index 0000000..05f1681
--- /dev/null
+++ b/package/platform/lantiq/ltq-deu/src/ifxmips_deu.c
@@ -0,0 +1,210 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_deu.c
+** PROJECT : IFX UEIP
+** MODULES : DEU Module for Danube
+**
+** DATE : September 8, 2009
+** AUTHOR : Mohammad Firdaus
+** DESCRIPTION : Data Encryption Unit Driver
+** COPYRIGHT : Copyright (c) 2009
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 08,Sept 2009 Mohammad Firdaus Initial UEIP release
+*******************************************************************************/
+
+/*!
+ \defgroup IFX_DEU IFX_DEU_DRIVERS
+ \ingroup API
+ \brief ifx deu driver module
+*/
+
+/*!
+ \file ifxmips_deu.c
+ \ingroup IFX_DEU
+ \brief main deu driver file
+*/
+
+/*!
+ \defgroup IFX_DEU_FUNCTIONS IFX_DEU_FUNCTIONS
+ \ingroup IFX_DEU
+ \brief IFX DEU functions
+*/
+
+/* Project header */
+#include <linux/version.h>
+#if defined(CONFIG_MODVERSIONS)
+#define MODVERSIONS
+#include <linux/modversions.h>
+#endif
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/crypto.h>
+#include <linux/proc_fs.h>
+#include <linux/platform_device.h>
+#include <linux/fs.h> /* Stuff about file systems that we need */
+#include <asm/byteorder.h>
+#include "ifxmips_deu.h"
+
+#include <lantiq_soc.h>
+
+#if defined(CONFIG_DANUBE)
+#include "ifxmips_deu_danube.h"
+#elif defined(CONFIG_AR9)
+#include "ifxmips_deu_ar9.h"
+#elif defined(CONFIG_VR9) || defined(CONFIG_AR10)
+#include "ifxmips_deu_vr9.h"
+#else
+#error "Platform unknown!"
+#endif /* CONFIG_xxxx */
+
+int disable_deudma = 1;
+
+void chip_version(void);
+
+/*! \fn static int __init deu_init (void)
+ * \ingroup IFX_DEU_FUNCTIONS
+ * \brief link all modules that have been selected in kernel config for ifx hw crypto support
+ * \return ret
+*/
+
+static int ltq_deu_probe(struct platform_device *pdev)
+{
+ int ret = -ENOSYS;
+
+
+ START_DEU_POWER;
+
+#define IFX_DEU_DRV_VERSION "2.0.0"
+ printk(KERN_INFO "Infineon Technologies DEU driver version %s \n", IFX_DEU_DRV_VERSION);
+
+ FIND_DEU_CHIP_VERSION;
+
+#if defined(CONFIG_CRYPTO_DEV_DES)
+ if ((ret = ifxdeu_init_des ())) {
+ printk (KERN_ERR "IFX DES initialization failed!\n");
+ }
+#endif
+#if defined(CONFIG_CRYPTO_DEV_AES)
+ if ((ret = ifxdeu_init_aes ())) {
+ printk (KERN_ERR "IFX AES initialization failed!\n");
+ }
+
+#endif
+#if defined(CONFIG_CRYPTO_DEV_ARC4)
+ if ((ret = ifxdeu_init_arc4 ())) {
+ printk (KERN_ERR "IFX ARC4 initialization failed!\n");
+ }
+
+#endif
+#if defined(CONFIG_CRYPTO_DEV_SHA1)
+ if ((ret = ifxdeu_init_sha1 ())) {
+ printk (KERN_ERR "IFX SHA1 initialization failed!\n");
+ }
+#endif
+#if defined(CONFIG_CRYPTO_DEV_MD5)
+ if ((ret = ifxdeu_init_md5 ())) {
+ printk (KERN_ERR "IFX MD5 initialization failed!\n");
+ }
+
+#endif
+#if defined(CONFIG_CRYPTO_DEV_SHA1_HMAC)
+ if ((ret = ifxdeu_init_sha1_hmac ())) {
+ printk (KERN_ERR "IFX SHA1_HMAC initialization failed!\n");
+ }
+#endif
+#if defined(CONFIG_CRYPTO_DEV_MD5_HMAC)
+ if ((ret = ifxdeu_init_md5_hmac ())) {
+ printk (KERN_ERR "IFX MD5_HMAC initialization failed!\n");
+ }
+#endif
+
+
+
+ return ret;
+
+}
+
+/*! \fn static void __exit deu_fini (void)
+ * \ingroup IFX_DEU_FUNCTIONS
+ * \brief remove the loaded crypto algorithms
+*/
+static int ltq_deu_remove(struct platform_device *pdev)
+{
+//#ifdef CONFIG_CRYPTO_DEV_PWR_SAVE_MODE
+ #if defined(CONFIG_CRYPTO_DEV_DES)
+ ifxdeu_fini_des ();
+ #endif
+ #if defined(CONFIG_CRYPTO_DEV_AES)
+ ifxdeu_fini_aes ();
+ #endif
+ #if defined(CONFIG_CRYPTO_DEV_ARC4)
+ ifxdeu_fini_arc4 ();
+ #endif
+ #if defined(CONFIG_CRYPTO_DEV_SHA1)
+ ifxdeu_fini_sha1 ();
+ #endif
+ #if defined(CONFIG_CRYPTO_DEV_MD5)
+ ifxdeu_fini_md5 ();
+ #endif
+ #if defined(CONFIG_CRYPTO_DEV_SHA1_HMAC)
+ ifxdeu_fini_sha1_hmac ();
+ #endif
+ #if defined(CONFIG_CRYPTO_DEV_MD5_HMAC)
+ ifxdeu_fini_md5_hmac ();
+ #endif
+ printk("DEU has exited successfully\n");
+
+ return 0;
+}
+
+
+int disable_multiblock = 0;
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
+module_param(disable_multiblock,int,0);
+
+#else
+//MODULE_PARM (disable_multiblock, "i");
+MODULE_PARM_DESC (disable_multiblock,
+ "Disable encryption of whole multiblock buffers.");
+#endif
+
+static const struct of_device_id ltq_deu_match[] = {
+#ifdef CONFIG_DANUBE
+ { .compatible = "lantiq,deu-danube"},
+#elif defined CONFIG_AR9
+ { .compatible = "lantiq,deu-arx100"},
+#elif defined CONFIG_VR9
+ { .compatible = "lantiq,deu-xrx200"},
+#endif
+ {},
+};
+MODULE_DEVICE_TABLE(of, ltq_deu_match);
+
+
+static struct platform_driver ltq_deu_driver = {
+ .probe = ltq_deu_probe,
+ .remove = ltq_deu_remove,
+ .driver = {
+ .name = "deu",
+ .owner = THIS_MODULE,
+ .of_match_table = ltq_deu_match,
+ },
+};
+
+module_platform_driver(ltq_deu_driver);
+
+MODULE_DESCRIPTION ("Infineon DEU crypto engine support.");
+MODULE_LICENSE ("GPL");
+MODULE_AUTHOR ("Mohammad Firdaus");
diff --git a/package/platform/lantiq/ltq-deu/src/ifxmips_deu.h b/package/platform/lantiq/ltq-deu/src/ifxmips_deu.h
new file mode 100644
index 0000000..c842d64
--- /dev/null
+++ b/package/platform/lantiq/ltq-deu/src/ifxmips_deu.h
@@ -0,0 +1,232 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_deu.h
+** DESCRIPTION : Data Encryption Unit Driver
+** COPYRIGHT : Copyright (c) 2009
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 08,Sept 2009 Mohammad Firdaus Initial UEIP release
+*******************************************************************************/
+/*!
+ \defgroup IFX_DEU IFX_DEU_DRIVERS
+ \ingroup API
+ \brief ifx deu driver module
+*/
+
+/*!
+ \file ifxmips_deu.h
+ \brief main deu driver header file
+*/
+
+/*!
+ \defgroup IFX_DEU_DEFINITIONS IFX_DEU_DEFINITIONS
+ \ingroup IFX_DEU
+ \brief ifx deu definitions
+*/
+
+
+#ifndef IFXMIPS_DEU_H
+#define IFXMIPS_DEU_H
+
+#include <crypto/algapi.h>
+#include <linux/interrupt.h>
+
+#define IFXDEU_ALIGNMENT 16
+
+#define IFX_DEU_BASE_ADDR (KSEG1 | 0x1E103100)
+#define IFX_DEU_CLK ((volatile u32 *)(IFX_DEU_BASE_ADDR + 0x0000))
+#define IFX_DES_CON ((volatile u32 *)(IFX_DEU_BASE_ADDR + 0x0010))
+#define IFX_AES_CON ((volatile u32 *)(IFX_DEU_BASE_ADDR + 0x0050))
+#define IFX_HASH_CON ((volatile u32 *)(IFX_DEU_BASE_ADDR + 0x00B0))
+#define IFX_ARC4_CON ((volatile u32 *)(IFX_DEU_BASE_ADDR + 0x0100))
+
+#define PFX "ifxdeu: "
+#define CLC_START IFX_DEU_CLK
+#define IFXDEU_CRA_PRIORITY 300
+#define IFXDEU_COMPOSITE_PRIORITY 400
+//#define KSEG1 0xA0000000
+#define IFX_PMU_ENABLE 1
+#define IFX_PMU_DISABLE 0
+
+#define CRYPTO_DIR_ENCRYPT 1
+#define CRYPTO_DIR_DECRYPT 0
+
+#define AES_IDLE 0
+#define AES_BUSY 1
+#define AES_STARTED 2
+#define AES_COMPLETED 3
+#define DES_IDLE 0
+#define DES_BUSY 1
+#define DES_STARTED 2
+#define DES_COMPLETED 3
+
+#define PROCESS_SCATTER 1
+#define PROCESS_NEW_PACKET 2
+
+#define PMU_DEU BIT(20)
+#define START_DEU_POWER \
+ do { \
+ volatile struct clc_controlr_t *clc = (struct clc_controlr_t *) CLC_START; \
+ ltq_pmu_enable(PMU_DEU); \
+ clc->FSOE = 0; \
+ clc->SBWE = 0; \
+ clc->SPEN = 0; \
+ clc->SBWE = 0; \
+ clc->DISS = 0; \
+ clc->DISR = 0; \
+ } while(0)
+
+#define STOP_DEU_POWER \
+ do { \
+ volatile struct clc_controlr_t *clc = (struct clc_controlr_t *) CLC_START; \
+ ltq_pmu_disable(PMU_DEU); \
+ clc->FSOE = 1; \
+ clc->SBWE = 1; \
+ clc->SPEN = 1; \
+ clc->SBWE = 1; \
+ clc->DISS = 1; \
+ clc->DISR = 1; \
+ } while (0)
+
+/*
+ * Not used anymore in UEIP (use IFX_DES_CON, IFX_AES_CON, etc instead)
+ * #define DEU_BASE (KSEG1+0x1E103100)
+ * #define DES_CON (DEU_BASE+0x10)
+ * #define AES_CON (DEU_BASE+0x50)
+ * #define HASH_CON (DEU_BASE+0xB0)
+ * #define DMA_CON (DEU_BASE+0xEC)
+ * #define INT_CON (DEU_BASE+0xF4)
+ * #define ARC4_CON (DEU_BASE+0x100)
+ */
+
+
+int __init ifxdeu_init_des (void);
+int __init ifxdeu_init_aes (void);
+int __init ifxdeu_init_arc4 (void);
+int __init ifxdeu_init_sha1 (void);
+int __init ifxdeu_init_md5 (void);
+int __init ifxdeu_init_sha1_hmac (void);
+int __init ifxdeu_init_md5_hmac (void);
+int __init lqdeu_async_aes_init(void);
+int __init lqdeu_async_des_init(void);
+
+void __exit ifxdeu_fini_des (void);
+void __exit ifxdeu_fini_aes (void);
+void __exit ifxdeu_fini_arc4 (void);
+void __exit ifxdeu_fini_sha1 (void);
+void __exit ifxdeu_fini_md5 (void);
+void __exit ifxdeu_fini_sha1_hmac (void);
+void __exit ifxdeu_fini_md5_hmac (void);
+void __exit ifxdeu_fini_dma(void);
+void __exit lqdeu_fini_async_aes(void);
+void __exit lqdeu_fini_async_des(void);
+void __exit deu_fini (void);
+int deu_dma_init (void);
+
+
+
+#define DEU_WAKELIST_INIT(queue) \
+ init_waitqueue_head(&queue)
+
+#define DEU_WAIT_EVENT_TIMEOUT(queue, event, flags, timeout) \
+ do { \
+ wait_event_interruptible_timeout((queue), \
+ test_bit((event), &(flags)), (timeout)); \
+ clear_bit((event), &(flags)); \
+ }while (0)
+
+
+#define DEU_WAKEUP_EVENT(queue, event, flags) \
+ do { \
+ set_bit((event), &(flags)); \
+ wake_up_interruptible(&(queue)); \
+ }while (0)
+
+#define DEU_WAIT_EVENT(queue, event, flags) \
+ do { \
+ wait_event_interruptible(queue, \
+ test_bit((event), &(flags))); \
+ clear_bit((event), &(flags)); \
+ }while (0)
+
+typedef struct deu_drv_priv {
+ wait_queue_head_t deu_thread_wait;
+#define DEU_EVENT 1
+#define DES_ASYNC_EVENT 2
+#define AES_ASYNC_EVENT 3
+ volatile long des_event_flags;
+ volatile long aes_event_flags;
+ volatile long deu_event_flags;
+ int event_src;
+ u32 *deu_rx_buf;
+ u32 *outcopy;
+ u32 deu_rx_len;
+
+ struct aes_priv *aes_dataptr;
+ struct des_priv *des_dataptr;
+}deu_drv_priv_t;
+
+
+/**
+ * struct aes_priv_t - ASYNC AES
+ * @lock: spinlock lock
+ * @lock_flag: flag for spinlock activities
+ * @list: crypto queue API list
+ * @hw_status: DEU hw status flag
+ * @aes_wait_flag: flag for sleep queue
+ * @aes_wait_queue: queue attributes for aes
+ * @bytes_processed: number of bytes to process by DEU
+ * @aes_pid: pid number for AES thread
+ * @aes_sync: atomic wait sync for AES
+ *
+*/
+
+typedef struct {
+ spinlock_t lock;
+ struct crypto_queue list;
+ unsigned int hw_status;
+ volatile long aes_wait_flag;
+ wait_queue_head_t aes_wait_queue;
+
+ pid_t aes_pid;
+
+ struct tasklet_struct aes_task;
+
+} aes_priv_t;
+
+/**
+ * struct des_priv_t - ASYNC DES
+ * @lock: spinlock lock
+ * @list: crypto queue API list
+ * @hw_status: DEU hw status flag
+ * @des_wait_flag: flag for sleep queue
+ * @des_wait_queue: queue attributes for des
+ * @des_pid: pid number for DES thread
+ * @des_sync: atomic wait sync for DES
+ *
+*/
+
+typedef struct {
+ spinlock_t lock;
+ struct crypto_queue list;
+ unsigned int hw_status;
+ volatile long des_wait_flag;
+ wait_queue_head_t des_wait_queue;
+
+ pid_t des_pid;
+
+ struct tasklet_struct des_task;
+
+} des_priv_t;
+
+#endif /* IFXMIPS_DEU_H */
+
+
diff --git a/package/platform/lantiq/ltq-deu/src/ifxmips_deu_ar9.c b/package/platform/lantiq/ltq-deu/src/ifxmips_deu_ar9.c
new file mode 100644
index 0000000..9dc3e30
--- /dev/null
+++ b/package/platform/lantiq/ltq-deu/src/ifxmips_deu_ar9.c
@@ -0,0 +1,135 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_deu_ar9.c
+** PROJECT : IFX UEIP
+** MODULES : DEU Module for AR9
+**
+** DATE : September 8, 2009
+** AUTHOR : Mohammad Firdaus
+** DESCRIPTION : Data Encryption Unit Driver
+** COPYRIGHT : Copyright (c) 2009
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 08,Sept 2009 Mohammad Firdaus Initial UEIP release
+*******************************************************************************/
+/*!
+ \defgroup IFX_DEU IFX_DEU_DRIVERS
+ \ingroup API
+ \brief ifx deu driver module
+*/
+
+/*!
+ \file ifxmips_deu_ar9.c
+ \brief ifx deu board specific driver file for ar9
+*/
+
+/*!
+ \defgroup BOARD_SPECIFIC_FUNCTIONS IFX_BOARD_SPECIFIC_FUNCTIONS
+ \ingroup IFX_DEU
+ \brief board specific functions
+*/
+
+/* Project header files */
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <asm/io.h> //dma_cache_inv
+
+#include "ifxmips_deu_dma.h"
+#include "ifxmips_deu_ar9.h"
+
+/* Function decleration */
+void aes_chip_init (void);
+void des_chip_init (void);
+int deu_dma_init (void);
+u32 endian_swap(u32 input);
+u32* memory_alignment(const u8 *arg, u32 *buff_alloc, int in_out, int nbytes);
+void aes_dma_memory_copy(u32 *outcopy, u32 *out_dma, u8 *out_arg, int nbytes);
+void des_dma_memory_copy(u32 *outcopy, u32 *out_dma, u8 *out_arg, int nbytes);
+void deu_dma_priv_init(void);
+void __exit ifxdeu_fini_dma(void);
+
+#define DES_3DES_START IFX_DES_CON
+#define AES_START IFX_AES_CON
+#define CLC_START IFX_DEU_CLK
+
+/* Variables */
+
+u8 *g_dma_page_ptr = NULL;
+u8 *g_dma_block = NULL;
+u8 *g_dma_block2 = NULL;
+
+deu_drv_priv_t deu_dma_priv;
+
+
+/*! \fn u32 endian_swap(u32 input)
+ * \ingroup BOARD_SPECIFIC_FUNCTIONS
+ * \brief Swap data given to the function
+ * \param input Data input to be swapped
+ * \return either the swapped data or the input data depending on whether it is in DMA mode or FPI mode
+*/
+u32 endian_swap(u32 input)
+{
+ return input;
+}
+
+/*! \fn u32 input_swap(u32 input)
+ * \ingroup BOARD_SPECIFIC_FUNCTIONS
+ * \brief Not used
+ * \return input
+*/
+
+u32 input_swap(u32 input)
+{
+ return input;
+}
+
+/*! \fn void aes_chip_init (void)
+ * \ingroup BOARD_SPECIFIC_FUNCTIONS
+ * \brief initialize AES hardware
+*/
+
+void aes_chip_init (void)
+{
+ volatile struct aes_t *aes = (struct aes_t *) AES_START;
+
+ aes->controlr.SM = 1;
+ aes->controlr.ARS = 1;
+
+}
+
+/*! \fn void des_chip_init (void)
+ * \ingroup BOARD_SPECIFIC_FUNCTIONS
+ * \brief initialize DES hardware
+*/
+
+void des_chip_init (void)
+{
+ volatile struct des_t *des = (struct des_t *) DES_3DES_START;
+
+ // start crypto engine with write to ILR
+ des->controlr.SM = 1;
+ asm("sync");
+ des->controlr.ARS = 1;
+
+}
+
+/*! \fn void chip_version(void)
+ * \ingroup BOARD_SPECIFIC_FUNCTIONS
+ * \brief not used!
+*/
+
+void chip_version(void)
+{
+ return;
+}
+
diff --git a/package/platform/lantiq/ltq-deu/src/ifxmips_deu_ar9.h b/package/platform/lantiq/ltq-deu/src/ifxmips_deu_ar9.h
new file mode 100644
index 0000000..1d84da3
--- /dev/null
+++ b/package/platform/lantiq/ltq-deu/src/ifxmips_deu_ar9.h
@@ -0,0 +1,299 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_deu_ar9.h
+** PROJECT : IFX UEIP
+** MODULES : DEU Module for AR9
+**
+** DATE : September 8, 2009
+** AUTHOR : Mohammad Firdaus
+** DESCRIPTION : Data Encryption Unit Driver
+** COPYRIGHT : Copyright (c) 2009
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 08,Sept 2009 Mohammad Firdaus Initial UEIP release
+*******************************************************************************/
+/*!
+ \defgroup IFX_DEU IFX_DEU_DRIVERS
+ \ingroup API
+ \brief deu driver module
+*/
+
+/*!
+ \defgroup IFX_DEU_DEFINITIONS IFX_DEU_DEFINITIONS
+ \ingroup IFX_DEU
+ \brief ifx deu definitions
+*/
+
+/*!
+ \file ifxmips_deu_ar9.h
+ \brief deu driver header file
+*/
+
+
+#ifndef IFXMIPS_DEU_AR9_H
+#define IFXMIPS_DEU_AR9_H
+
+/* Project Header Files */
+#include <linux/version.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/crypto.h>
+#include <linux/interrupt.h>
+#include <linux/delay.h>
+#include <asm/byteorder.h>
+#include <crypto/algapi.h>
+#include <linux/module.h>
+#include <linux/mm.h>
+#include <asm/scatterlist.h>
+#include <linux/skbuff.h>
+#include <linux/netdevice.h>
+#include "ifxmips_deu.h"
+
+
+/* SHA CONSTANTS */
+#define HASH_CON_VALUE 0x0700002C
+
+#define INPUT_ENDIAN_SWAP(input) input_swap(input)
+#define DEU_ENDIAN_SWAP(input) endian_swap(input)
+#define DELAY_PERIOD 10
+#define FIND_DEU_CHIP_VERSION chip_version()
+#define CLC_START IFX_DEU_CLK
+
+#define AES_INIT 0
+#define DES_INIT 1
+#define ARC4_INIT 2
+#define SHA1_INIT 3
+#define MD5_INIT 4
+#define SHA1_HMAC_INIT 5
+#define MD5_HMAC_INIT 6
+
+#define AES_START IFX_AES_CON
+#define DES_3DES_START IFX_DES_CON
+
+#define WAIT_AES_DMA_READY() \
+ do { \
+ int i; \
+ volatile struct deu_dma_t *dma = (struct deu_dma_t *) IFX_DEU_DMA_CON; \
+ volatile struct aes_t *aes = (volatile struct aes_t *) AES_START; \
+ for (i = 0; i < 10; i++) \
+ udelay(DELAY_PERIOD); \
+ while (dma->controlr.BSY) {}; \
+ while (aes->controlr.BUS) {}; \
+ } while (0)
+
+#define WAIT_DES_DMA_READY() \
+ do { \
+ int i; \
+ volatile struct deu_dma_t *dma = (struct deu_dma_t *) IFX_DEU_DMA_CON; \
+ volatile struct des_t *des = (struct des_t *) DES_3DES_START; \
+ for (i = 0; i < 10; i++) \
+ udelay(DELAY_PERIOD); \
+ while (dma->controlr.BSY) {}; \
+ while (des->controlr.BUS) {}; \
+ } while (0)
+
+#define AES_DMA_MISC_CONFIG() \
+ do { \
+ volatile struct aes_t *aes = (volatile struct aes_t *) AES_START; \
+ aes->controlr.KRE = 1; \
+ aes->controlr.GO = 1; \
+ } while(0)
+
+#define SHA_HASH_INIT \
+ do { \
+ volatile struct deu_hash_t *hash = (struct deu_hash_t *) HASH_START; \
+ hash->controlr.SM = 1; \
+ hash->controlr.ALGO = 0; \
+ hash->controlr.INIT = 1; \
+ } while(0)
+
+/* DEU Common Structures for AR9*/
+
+struct clc_controlr_t {
+ u32 Res:26;
+ u32 FSOE:1;
+ u32 SBWE:1;
+ u32 EDIS:1;
+ u32 SPEN:1;
+ u32 DISS:1;
+ u32 DISR:1;
+
+};
+
+struct des_t {
+ struct des_controlr { //10h
+ u32 KRE:1;
+ u32 reserved1:5;
+ u32 GO:1;
+ u32 STP:1;
+ u32 Res2:6;
+ u32 NDC:1;
+ u32 ENDI:1;
+ u32 Res3:2;
+ u32 F:3;
+ u32 O:3;
+ u32 BUS:1;
+ u32 DAU:1;
+ u32 ARS:1;
+ u32 SM:1;
+ u32 E_D:1;
+ u32 M:3;
+
+ } controlr;
+ u32 IHR; //14h
+ u32 ILR; //18h
+ u32 K1HR; //1c
+ u32 K1LR; //
+ u32 K2HR;
+ u32 K2LR;
+ u32 K3HR;
+ u32 K3LR; //30h
+ u32 IVHR; //34h
+ u32 IVLR; //38
+ u32 OHR; //3c
+ u32 OLR; //40
+};
+
+struct aes_t {
+ struct aes_controlr {
+
+ u32 KRE:1;
+ u32 reserved1:4;
+ u32 PNK:1;
+ u32 GO:1;
+ u32 STP:1;
+ u32 reserved2:6;
+ u32 NDC:1;
+ u32 ENDI:1;
+ u32 reserved3:2;
+ u32 F:3; //fbs
+ u32 O:3; //om
+ u32 BUS:1; //bsy
+ u32 DAU:1;
+ u32 ARS:1;
+ u32 SM:1;
+ u32 E_D:1;
+ u32 KV:1;
+ u32 K:2; //KL
+
+ } controlr;
+ u32 ID3R; //80h
+ u32 ID2R; //84h
+ u32 ID1R; //88h
+ u32 ID0R; //8Ch
+ u32 K7R; //90h
+ u32 K6R; //94h
+ u32 K5R; //98h
+ u32 K4R; //9Ch
+ u32 K3R; //A0h
+ u32 K2R; //A4h
+ u32 K1R; //A8h
+ u32 K0R; //ACh
+ u32 IV3R; //B0h
+ u32 IV2R; //B4h
+ u32 IV1R; //B8h
+ u32 IV0R; //BCh
+ u32 OD3R; //D4h
+ u32 OD2R; //D8h
+ u32 OD1R; //DCh
+ u32 OD0R; //E0h
+};
+
+struct arc4_t {
+ struct arc4_controlr {
+
+ u32 KRE:1;
+ u32 KLEN:4;
+ u32 KSAE:1;
+ u32 GO:1;
+ u32 STP:1;
+ u32 reserved1:6;
+ u32 NDC:1;
+ u32 ENDI:1;
+ u32 reserved2:8;
+ u32 BUS:1; //bsy
+ u32 reserved3:1;
+ u32 ARS:1;
+ u32 SM:1;
+ u32 reserved4:4;
+
+ } controlr;
+ u32 K3R; //104h
+ u32 K2R; //108h
+ u32 K1R; //10Ch
+ u32 K0R; //110h
+
+ u32 IDLEN; //114h
+
+ u32 ID3R; //118h
+ u32 ID2R; //11Ch
+ u32 ID1R; //120h
+ u32 ID0R; //124h
+
+ u32 OD3R; //128h
+ u32 OD2R; //12Ch
+ u32 OD1R; //130h
+ u32 OD0R; //134h
+};
+
+struct deu_hash_t {
+ struct hash_controlr {
+ u32 reserved1:5;
+ u32 KHS:1;
+ u32 GO:1;
+ u32 INIT:1;
+ u32 reserved2:6;
+ u32 NDC:1;
+ u32 ENDI:1;
+ u32 reserved3:7;
+ u32 DGRY:1;
+ u32 BSY:1;
+ u32 reserved4:1;
+ u32 IRCL:1;
+ u32 SM:1;
+ u32 KYUE:1;
+ u32 HMEN:1;
+ u32 SSEN:1;
+ u32 ALGO:1;
+
+ } controlr;
+ u32 MR; //B4h
+ u32 D1R; //B8h
+ u32 D2R; //BCh
+ u32 D3R; //C0h
+ u32 D4R; //C4h
+ u32 D5R; //C8h
+
+ u32 dummy; //CCh
+
+ u32 KIDX; //D0h
+ u32 KEY; //D4h
+ u32 DBN; //D8h
+};
+
+
+struct deu_dma_t {
+ struct dma_controlr {
+ u32 reserved1:22;
+ u32 BS:2;
+ u32 BSY:1;
+ u32 reserved2:1;
+ u32 ALGO:2;
+ u32 RXCLS:2;
+ u32 reserved3:1;
+ u32 EN:1;
+
+ } controlr;
+};
+
+#endif /* IFXMIPS_DEU_AR9_H */
diff --git a/package/platform/lantiq/ltq-deu/src/ifxmips_deu_danube.c b/package/platform/lantiq/ltq-deu/src/ifxmips_deu_danube.c
new file mode 100644
index 0000000..492391d
--- /dev/null
+++ b/package/platform/lantiq/ltq-deu/src/ifxmips_deu_danube.c
@@ -0,0 +1,168 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_deu_danube.c
+** PROJECT : IFX UEIP
+** MODULES : DEU Module for Danube
+**
+** DATE : September 8, 2009
+** AUTHOR : Mohammad Firdaus
+** DESCRIPTION : Data Encryption Unit Driver
+** COPYRIGHT : Copyright (c) 2009
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 08,Sept 2009 Mohammad Firdaus Initial UEIP release
+*******************************************************************************/
+/*!
+ \defgroup IFX_DEU IFX_DEU_DRIVERS
+ \ingroup API
+ \brief deu driver module
+*/
+
+/*!
+ \file ifxmips_deu_danube.c
+ \ingroup IFX_DEU
+ \brief board specific deu driver file for danube
+*/
+
+/*!
+ \defgroup BOARD_SPECIFIC_FUNCTIONS IFX_BOARD_SPECIFIC_FUNCTIONS
+ \ingroup IFX_DEU
+ \brief board specific deu functions
+*/
+
+/* Project header files */
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <asm/io.h> //dma_cache_inv
+
+#include "ifxmips_deu_dma.h"
+#include "ifxmips_deu_danube.h"
+
+
+/* Function Declerations */
+int aes_memory_allocate(int value);
+int des_memory_allocate(int value);
+void memory_release(u32 *addr);
+int aes_chip_init (void);
+void des_chip_init (void);
+int deu_dma_init (void);
+u32 endian_swap(u32 input);
+u32* memory_alignment(const u8 *arg, u32 *buff_alloc, int in_out, int nbytes);
+void dma_memory_copy(u32 *outcopy, u32 *out_dma, u8 *out_arg, int nbytes);
+void chip_version(void);
+void deu_dma_priv_init(void);
+void __exit ifxdeu_fini_dma(void);
+
+#define DES_3DES_START IFX_DES_CON
+#define AES_START IFX_AES_CON
+#define CLC_START IFX_DEU_CLK
+
+/* Variables definition */
+int ifx_danube_pre_1_4;
+u8 *g_dma_page_ptr = NULL;
+u8 *g_dma_block = NULL;
+u8 *g_dma_block2 = NULL;
+
+deu_drv_priv_t deu_dma_priv;
+
+
+/*! \fn u32 endian_swap(u32 input)
+ * \ingroup BOARD_SPECIFIC_FUNCTIONS
+ * \brief function is not used
+ * \param input Data input to be swapped
+ * \return input
+*/
+
+u32 endian_swap(u32 input)
+{
+ return input;
+}
+
+/*! \fn u32 input_swap(u32 input)
+ * \ingroup BOARD_SPECIFIC_FUNCTIONS
+ * \brief Swap the input data if the current chip is Danube version
+ * 1.4 and do nothing to the data if the current chip is
+ * Danube version 1.3
+ * \param input data that needs to be swapped
+ * \return input or swapped input
+*/
+
+u32 input_swap(u32 input)
+{
+ if (!ifx_danube_pre_1_4) {
+ u8 *ptr = (u8 *)&input;
+ return ((ptr[3] << 24) | (ptr[2] << 16) | (ptr[1] << 8) | ptr[0]);
+ }
+ else
+ return input;
+}
+
+
+
+/*! \fn void aes_chip_init (void)
+ * \ingroup BOARD_SPECIFIC_FUNCTIONS
+ * \brief initialize AES hardware
+*/
+
+int aes_chip_init (void)
+{
+ volatile struct aes_t *aes = (struct aes_t *) AES_START;
+
+ //start crypto engine with write to ILR
+ aes->controlr.SM = 1;
+ aes->controlr.ARS = 1;
+ return 0;
+}
+
+/*! \fn void des_chip_init (void)
+ * \ingroup BOARD_SPECIFIC_FUNCTIONS
+ * \brief initialize DES hardware
+*/
+
+void des_chip_init (void)
+{
+ volatile struct des_t *des = (struct des_t *) DES_3DES_START;
+
+ // start crypto engine with write to ILR
+ des->controlr.SM = 1;
+ des->controlr.ARS = 1;
+}
+
+/*! \fn void chip_version (void)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief To find the version of the chip by looking at the chip ID
+ * \param ifx_danube_pre_1_4 (sets to 1 if Chip is Danube less than v1.4)
+*/
+#define IFX_MPS (KSEG1 | 0x1F107000)
+#define IFX_MPS_CHIPID ((volatile u32*)(IFX_MPS + 0x0344))
+
+void chip_version(void)
+{
+
+ /* DANUBE PRE 1.4 SOFTWARE FIX */
+ int chip_id = 0;
+ chip_id = *IFX_MPS_CHIPID;
+ chip_id >>= 28;
+
+ if (chip_id >= 4) {
+ ifx_danube_pre_1_4 = 0;
+ printk("Danube Chip ver. 1.4 detected. \n");
+ }
+ else {
+ ifx_danube_pre_1_4 = 1;
+ printk("Danube Chip ver. 1.3 or below detected. \n");
+ }
+
+ return;
+}
+
diff --git a/package/platform/lantiq/ltq-deu/src/ifxmips_deu_danube.h b/package/platform/lantiq/ltq-deu/src/ifxmips_deu_danube.h
new file mode 100644
index 0000000..62ad96d
--- /dev/null
+++ b/package/platform/lantiq/ltq-deu/src/ifxmips_deu_danube.h
@@ -0,0 +1,250 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_deu_danube.h
+** PROJECT : IFX UEIP
+** MODULES : DEU Module for Danube
+**
+** DATE : September 8, 2009
+** AUTHOR : Mohammad Firdaus
+** DESCRIPTION : Data Encryption Unit Driver
+** COPYRIGHT : Copyright (c) 2009
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 08,Sept 2009 Mohammad Firdaus Initial UEIP release
+*******************************************************************************/
+/*!
+ \defgroup IFX_DEU IFX_DEU_DRIVERS
+ \ingroup API
+ \brief deu driver module
+*/
+
+/*!
+ \file ifxmips_deu_danube.h
+ \brief board specific driver header file for danube
+*/
+
+/*!
+ \defgroup BOARD_SPECIFIC_FUNCTIONS IFX_BOARD_SPECIFIC_FUNCTIONS
+ \ingroup IFX_DEU
+ \brief board specific deu header files
+*/
+
+#ifndef IFXMIPS_DEU_DANUBE_H
+#define IFXMIPS_DEU_DANUBE_H
+
+/* Project Header Files */
+#include <linux/version.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/crypto.h>
+#include <linux/interrupt.h>
+#include <linux/delay.h>
+#include <asm/byteorder.h>
+#include <crypto/algapi.h>
+#include <linux/module.h>
+#include <linux/mm.h>
+#include <asm/scatterlist.h>
+#include <linux/skbuff.h>
+#include <linux/netdevice.h>
+#include "ifxmips_deu.h"
+
+
+
+#define INPUT_ENDIAN_SWAP(input) input_swap(input)
+#define DEU_ENDIAN_SWAP(input) endian_swap(input)
+#define FIND_DEU_CHIP_VERSION chip_version()
+#define AES_DMA_MISC_CONFIG()
+#define CLC_START IFX_DEU_CLK
+
+#define AES_START IFX_AES_CON
+#define DES_3DES_START IFX_DES_CON
+
+#define AES_INIT 0
+#define DES_INIT 1
+#define SHA1_INIT 2
+#define MD5_INIT 3
+
+#define WAIT_AES_DMA_READY() \
+ do { \
+ int i; \
+ volatile struct deu_dma_t *dma = (struct deu_dma_t *) IFX_DEU_DMA_CON; \
+ volatile struct aes_t *aes = (volatile struct aes_t *) AES_START; \
+ for (i = 0; i < 10; i++) \
+ udelay(DELAY_PERIOD); \
+ while (dma->controlr.BSY) {}; \
+ while (aes->controlr.BUS) {}; \
+ } while (0)
+
+#define WAIT_DES_DMA_READY() \
+ do { \
+ int i; \
+ volatile struct deu_dma_t *dma = (struct deu_dma_t *) IFX_DEU_DMA_CON; \
+ volatile struct des_t *des = (struct des_t *) DES_3DES_START; \
+ for (i = 0; i < 10; i++) \
+ udelay(DELAY_PERIOD); \
+ while (dma->controlr.BSY) {}; \
+ while (des->controlr.BUS) {}; \
+ } while (0)
+
+#define SHA_HASH_INIT \
+ do { \
+ volatile struct deu_hash_t *hash = (struct deu_hash_t *) HASH_START; \
+ hash->controlr.SM = 1; \
+ hash->controlr.ALGO = 0; \
+ hash->controlr.INIT = 1; \
+ } while(0)
+
+/* DEU STRUCTURES */
+
+struct clc_controlr_t {
+ u32 Res:26;
+ u32 FSOE:1;
+ u32 SBWE:1;
+ u32 EDIS:1;
+ u32 SPEN:1;
+ u32 DISS:1;
+ u32 DISR:1;
+
+};
+
+struct des_t {
+ struct des_controlr { //10h
+ u32 KRE:1;
+ u32 reserved1:5;
+ u32 GO:1;
+ u32 STP:1;
+ u32 Res2:6;
+ u32 NDC:1;
+ u32 ENDI:1;
+ u32 Res3:2;
+ u32 F:3;
+ u32 O:3;
+ u32 BUS:1;
+ u32 DAU:1;
+ u32 ARS:1;
+ u32 SM:1;
+ u32 E_D:1;
+ u32 M:3;
+
+ } controlr;
+ u32 IHR; //14h
+ u32 ILR; //18h
+ u32 K1HR; //1c
+ u32 K1LR; //
+ u32 K2HR;
+ u32 K2LR;
+ u32 K3HR;
+ u32 K3LR; //30h
+ u32 IVHR; //34h
+ u32 IVLR; //38
+ u32 OHR; //3c
+ u32 OLR; //40
+};
+
+struct aes_t {
+ struct aes_controlr {
+
+ u32 KRE:1;
+ u32 reserved1:4;
+ u32 PNK:1;
+ u32 GO:1;
+ u32 STP:1;
+
+ u32 reserved2:6;
+ u32 NDC:1;
+ u32 ENDI:1;
+ u32 reserved3:2;
+
+ u32 F:3; //fbs
+ u32 O:3; //om
+ u32 BUS:1; //bsy
+ u32 DAU:1;
+ u32 ARS:1;
+ u32 SM:1;
+ u32 E_D:1;
+ u32 KV:1;
+ u32 K:2; //KL
+
+ } controlr;
+ u32 ID3R; //80h
+ u32 ID2R; //84h
+ u32 ID1R; //88h
+ u32 ID0R; //8Ch
+ u32 K7R; //90h
+ u32 K6R; //94h
+ u32 K5R; //98h
+ u32 K4R; //9Ch
+ u32 K3R; //A0h
+ u32 K2R; //A4h
+ u32 K1R; //A8h
+ u32 K0R; //ACh
+ u32 IV3R; //B0h
+ u32 IV2R; //B4h
+ u32 IV1R; //B8h
+ u32 IV0R; //BCh
+ u32 OD3R; //D4h
+ u32 OD2R; //D8h
+ u32 OD1R; //DCh
+ u32 OD0R; //E0h
+};
+
+struct deu_hash_t {
+ struct hash_controlr {
+ u32 reserved1:5;
+ u32 KHS:1;
+ u32 GO:1;
+ u32 INIT:1;
+ u32 reserved2:6;
+ u32 NDC:1;
+ u32 ENDI:1;
+ u32 reserved3:7;
+ u32 DGRY:1;
+ u32 BSY:1;
+ u32 reserved4:1;
+ u32 IRCL:1;
+ u32 SM:1;
+ u32 KYUE:1;
+ u32 HMEN:1;
+ u32 SSEN:1;
+ u32 ALGO:1;
+
+ } controlr;
+ u32 MR; //B4h
+ u32 D1R; //B8h
+ u32 D2R; //BCh
+ u32 D3R; //C0h
+ u32 D4R; //C4h
+ u32 D5R; //C8h
+
+ u32 dummy; //CCh
+
+ u32 KIDX; //D0h
+ u32 KEY; //D4h
+ u32 DBN; //D8h
+};
+
+struct deu_dma_t {
+ struct dma_controlr {
+ u32 reserved1:22;
+ u32 BS:2;
+ u32 BSY:1;
+ u32 reserved2:1;
+ u32 ALGO:2;
+ u32 RXCLS:2;
+ u32 reserved3:1;
+ u32 EN:1;
+
+ } controlr;
+};
+
+#endif /* IFXMIPS_DEU_DANUBE_H */
diff --git a/package/platform/lantiq/ltq-deu/src/ifxmips_deu_dma.c b/package/platform/lantiq/ltq-deu/src/ifxmips_deu_dma.c
new file mode 100644
index 0000000..13dc921
--- /dev/null
+++ b/package/platform/lantiq/ltq-deu/src/ifxmips_deu_dma.c
@@ -0,0 +1,42 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_deu_dma.c
+** PROJECT : IFX UEIP
+** MODULES : DEU Module for Danube
+**
+** DATE : September 8, 2009
+** AUTHOR : Mohammad Firdaus
+** DESCRIPTION : Data Encryption Unit Driver
+** COPYRIGHT : Copyright (c) 2009
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 08 Sept 2009 Mohammad Firdaus Initial UEIP release
+*******************************************************************************/
+/*!
+ \defgroup IFX_DEU IFX_DEU_DRIVERS
+ \ingroup IFX_API
+ \brief ifx deu driver module
+*/
+
+/*!
+ \file ifxmips_deu_dma.c
+ \ingroup IFX_DEU
+ \brief DMA deu driver file
+*/
+
+/*!
+ \defgroup IFX_DMA_FUNCTIONS IFX_DMA_FUNCTIONS
+ \ingroup IFX_DEU
+ \brief deu-dma driver functions
+*/
+
+/* Project header files */
+
diff --git a/package/platform/lantiq/ltq-deu/src/ifxmips_deu_dma.h b/package/platform/lantiq/ltq-deu/src/ifxmips_deu_dma.h
new file mode 100644
index 0000000..5198a4a
--- /dev/null
+++ b/package/platform/lantiq/ltq-deu/src/ifxmips_deu_dma.h
@@ -0,0 +1,69 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_deu_dma.h
+** DESCRIPTION : Data Encryption Unit Driver
+** COPYRIGHT : Copyright (c) 2009
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 08,Sept 2009 Mohammad Firdaus Initial UEIP release
+*******************************************************************************/
+
+/*!
+ \addtogroup IFX_DEU IFX_DEU_DRIVERS
+ \ingroup API
+ \brief ifx deu driver module
+*/
+
+/*!
+ \file ifxmips_deu_dma.h
+ \ingroup IFX_DEU
+ \brief DMA deu driver header file
+*/
+
+#ifndef IFXMIPS_DEU_DMA_H
+#define IFXMIPS_DEU_DMA_H
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/mm.h>
+#include <linux/crypto.h>
+#include <asm/scatterlist.h>
+#include <asm/byteorder.h>
+#include <linux/skbuff.h>
+#include <linux/netdevice.h>
+
+// must match the size of memory block allocated for g_dma_block and g_dma_block2
+#define DEU_MAX_PACKET_SIZE (PAGE_SIZE >> 1)
+
+typedef struct ifx_deu_device {
+ struct dma_device_info *dma_device;
+ u8 *dst;
+ u8 *src;
+ int len;
+ int dst_count;
+ int src_count;
+ int recv_count;
+ int packet_size;
+ int packet_num;
+ wait_queue_t wait;
+} _ifx_deu_device;
+
+extern _ifx_deu_device ifx_deu[1];
+
+extern int deu_dma_intr_handler (struct dma_device_info *, int);
+extern u8 *deu_dma_buffer_alloc (int, int *, void **);
+extern int deu_dma_buffer_free (u8 *, void *);
+extern void deu_dma_inactivate_poll(struct dma_device_info* dma_dev);
+extern void deu_dma_activate_poll (struct dma_device_info* dma_dev);
+extern struct dma_device_info* deu_dma_reserve(struct dma_device_info** dma_device);
+extern int deu_dma_release(struct dma_device_info** dma_device);
+
+#endif /* IFMIPS_DEU_DMA_H */
diff --git a/package/platform/lantiq/ltq-deu/src/ifxmips_deu_vr9.c b/package/platform/lantiq/ltq-deu/src/ifxmips_deu_vr9.c
new file mode 100644
index 0000000..aaa7bce
--- /dev/null
+++ b/package/platform/lantiq/ltq-deu/src/ifxmips_deu_vr9.c
@@ -0,0 +1,144 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_deu_vr9.c
+** PROJECT : IFX UEIP
+** MODULES : DEU Module for VR9
+**
+** DATE : September 8, 2009
+** AUTHOR : Mohammad Firdaus
+** DESCRIPTION : Data Encryption Unit Driver
+** COPYRIGHT : Copyright (c) 2009
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 08,Sept 2009 Mohammad Firdaus Initial UEIP release
+*******************************************************************************/
+
+/*!
+ \defgroup IFX_DEU IFX_DEU_DRIVERS
+ \ingroup API
+ \brief deu driver module
+*/
+
+/*!
+ \file ifxmips_deu_vr9.c
+ \ingroup IFX_DEU
+ \brief board specific deu driver file for vr9
+*/
+
+/*!
+ \defgroup BOARD_SPECIFIC_FUNCTIONS IFX_BOARD_SPECIFIC_FUNCTIONS
+ \ingroup IFX_DEU
+ \brief board specific deu driver functions
+*/
+
+/* Project header files */
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <asm/io.h> //dma_cache_inv
+
+#include "ifxmips_deu_dma.h"
+#include "ifxmips_deu_vr9.h"
+
+/* Function decleration */
+void aes_chip_init (void);
+void des_chip_init (void);
+int deu_dma_init (void);
+void deu_dma_priv_init(void);
+u32 endian_swap(u32 input);
+u32* memory_alignment(const u8 *arg, u32 *buff_alloc, int in_out, int nbytes);
+void aes_dma_memory_copy(u32 *outcopy, u32 *out_dma, u8 *out_arg, int nbytes);
+void des_dma_memory_copy(u32 *outcopy, u32 *out_dma, u8 *out_arg, int nbytes);
+void __exit ifxdeu_fini_dma(void);
+
+#define DES_3DES_START IFX_DES_CON
+#define AES_START IFX_AES_CON
+
+/* Variables */
+
+u8 *g_dma_page_ptr = NULL;
+u8 *g_dma_block = NULL;
+u8 *g_dma_block2 = NULL;
+
+deu_drv_priv_t deu_dma_priv;
+
+
+/*! \fn u32 endian_swap(u32 input)
+ * \ingroup BOARD_SPECIFIC_FUNCTIONS
+ * \brief Swap data given to the function
+ * \param input Data input to be swapped
+ * \return either the swapped data or the input data depending on whether it is in DMA mode or FPI mode
+*/
+
+
+u32 endian_swap(u32 input)
+{
+ return input;
+}
+
+/*! \fn u32 input_swap(u32 input)
+ * \ingroup BOARD_SPECIFIC_FUNCTIONS
+ * \brief Not used
+ * \return input
+*/
+
+u32 input_swap(u32 input)
+{
+ return input;
+}
+
+/*! \fn void aes_chip_init (void)
+ * \ingroup BOARD_SPECIFIC_FUNCTIONS
+ * \brief initialize AES hardware
+*/
+
+void aes_chip_init (void)
+{
+ volatile struct aes_t *aes = (struct aes_t *) AES_START;
+
+ // start crypto engine with write to ILR
+ aes->controlr.SM = 1;
+ aes->controlr.NDC = 0;
+ asm("sync");
+ aes->controlr.ENDI = 1;
+ asm("sync");
+ aes->controlr.ARS = 0;
+
+}
+
+/*! \fn void des_chip_init (void)
+ * \ingroup IFX_AES_FUNCTIONS
+ * \brief initialize DES hardware
+*/
+
+void des_chip_init (void)
+{
+ volatile struct des_t *des = (struct des_t *) DES_3DES_START;
+
+ // start crypto engine with write to ILR
+ des->controlr.SM = 1;
+ des->controlr.NDC = 1;
+ asm("sync");
+ des->controlr.ENDI = 1;
+ asm("sync");
+ des->controlr.ARS = 0;
+
+}
+/*! \fn void chip_version(void)
+ * \ingroup IFX_DES_FUNCTIONS
+ * \brief function not used in VR9
+*/
+void chip_version(void)
+{
+ return;
+}
+
diff --git a/package/platform/lantiq/ltq-deu/src/ifxmips_deu_vr9.h b/package/platform/lantiq/ltq-deu/src/ifxmips_deu_vr9.h
new file mode 100644
index 0000000..d2cfd11
--- /dev/null
+++ b/package/platform/lantiq/ltq-deu/src/ifxmips_deu_vr9.h
@@ -0,0 +1,324 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_deu_vr9.h
+** PROJECT : IFX UEIP
+** MODULES : DEU Module for VR9
+**
+** DATE : September 8, 2009
+** AUTHOR : Mohammad Firdaus
+** DESCRIPTION : Data Encryption Unit Driver
+** COPYRIGHT : Copyright (c) 2009
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 08,Sept 2009 Mohammad Firdaus Initial UEIP release
+*******************************************************************************/
+/*!
+ \defgroup IFX_DEU IFX_DEU_DRIVERS
+ \ingroup API
+ \brief deu driver module
+*/
+
+/*!
+ \file ifxmips_deu_vr9.h
+ \ingroup IFX_DEU
+ \brief board specific deu driver header file for vr9
+*/
+
+/*!
+ \defgroup IFX_DEU_DEFINITIONS IFX_DEU_DEFINITIONS
+ \brief deu driver header file
+*/
+
+
+#ifndef IFXMIPS_DEU_VR9_H
+#define IFXMIPS_DEU_VR9_H
+
+/* Project Header Files */
+#include <linux/version.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/crypto.h>
+#include <linux/interrupt.h>
+#include <linux/delay.h>
+#include <asm/byteorder.h>
+#include <crypto/algapi.h>
+#include <linux/module.h>
+#include <linux/mm.h>
+#include <asm/scatterlist.h>
+#include <linux/skbuff.h>
+#include <linux/netdevice.h>
+#include "ifxmips_deu.h"
+
+
+#define AES_INIT 1
+#define DES_INIT 2
+#define ARC4_INIT 3
+#define SHA1_INIT 4
+#define MD5_INIT 5
+#define SHA1_HMAC_INIT 6
+#define MD5_HMAC_INIT 7
+
+#define AES_START IFX_AES_CON
+#define DES_3DES_START IFX_DES_CON
+
+#if 0
+#define AES_IDLE 0
+#define AES_BUSY 1
+#define AES_STARTED 2
+#define AES_COMPLETED 3
+#define DES_IDLE 0
+#define DES_BUSY 1
+#define DES_STARTED 2
+#define DES_COMPLETED 3
+#endif
+
+/* SHA1 CONSTANT */
+#define HASH_CON_VALUE 0x0701002C
+
+#define INPUT_ENDIAN_SWAP(input) input_swap(input)
+#define DEU_ENDIAN_SWAP(input) endian_swap(input)
+#define FIND_DEU_CHIP_VERSION chip_version()
+
+#if defined (CONFIG_AR10)
+#define DELAY_PERIOD 30
+#else
+#define DELAY_PERIOD 10
+#endif
+
+#define WAIT_AES_DMA_READY() \
+ do { \
+ int i; \
+ volatile struct deu_dma_t *dma = (struct deu_dma_t *) IFX_DEU_DMA_CON; \
+ volatile struct aes_t *aes = (volatile struct aes_t *) AES_START; \
+ for (i = 0; i < 10; i++) \
+ udelay(DELAY_PERIOD); \
+ while (dma->controlr.BSY) {}; \
+ while (aes->controlr.BUS) {}; \
+ } while (0)
+
+#define WAIT_DES_DMA_READY() \
+ do { \
+ int i; \
+ volatile struct deu_dma_t *dma = (struct deu_dma_t *) IFX_DEU_DMA_CON; \
+ volatile struct des_t *des = (struct des_t *) DES_3DES_START; \
+ for (i = 0; i < 10; i++) \
+ udelay(DELAY_PERIOD); \
+ while (dma->controlr.BSY) {}; \
+ while (des->controlr.BUS) {}; \
+ } while (0)
+
+#define AES_DMA_MISC_CONFIG() \
+ do { \
+ volatile struct aes_t *aes = (volatile struct aes_t *) AES_START; \
+ aes->controlr.KRE = 1; \
+ aes->controlr.GO = 1; \
+ } while(0)
+
+#define SHA_HASH_INIT \
+ do { \
+ volatile struct deu_hash_t *hash = (struct deu_hash_t *) HASH_START; \
+ hash->controlr.ENDI = 1; \
+ hash->controlr.SM = 1; \
+ hash->controlr.ALGO = 0; \
+ hash->controlr.INIT = 1; \
+ } while(0)
+
+#define MD5_HASH_INIT \
+ do { \
+ volatile struct deu_hash_t *hash = (struct deu_hash_t *) HASH_START; \
+ hash->controlr.ENDI = 1; \
+ hash->controlr.SM = 1; \
+ hash->controlr.ALGO = 1; \
+ hash->controlr.INIT = 1; \
+ } while(0)
+
+/* DEU Common Structures for AR9*/
+
+struct clc_controlr_t {
+ u32 Res:26;
+ u32 FSOE:1;
+ u32 SBWE:1;
+ u32 EDIS:1;
+ u32 SPEN:1;
+ u32 DISS:1;
+ u32 DISR:1;
+
+};
+
+struct des_t {
+ struct des_controlr { //10h
+ u32 KRE:1;
+ u32 reserved1:5;
+ u32 GO:1;
+ u32 STP:1;
+ u32 Res2:6;
+ u32 NDC:1;
+ u32 ENDI:1;
+ u32 Res3:2;
+ u32 F:3;
+ u32 O:3;
+ u32 BUS:1;
+ u32 DAU:1;
+ u32 ARS:1;
+ u32 SM:1;
+ u32 E_D:1;
+ u32 M:3;
+
+ } controlr;
+ u32 IHR; //14h
+ u32 ILR; //18h
+ u32 K1HR; //1c
+ u32 K1LR; //
+ u32 K2HR;
+ u32 K2LR;
+ u32 K3HR;
+ u32 K3LR; //30h
+ u32 IVHR; //34h
+ u32 IVLR; //38
+ u32 OHR; //3c
+ u32 OLR; //40
+};
+
+struct aes_t {
+ struct aes_controlr {
+
+ u32 KRE:1;
+ u32 reserved1:4;
+ u32 PNK:1;
+ u32 GO:1;
+ u32 STP:1;
+ u32 reserved2:6;
+ u32 NDC:1;
+ u32 ENDI:1;
+ u32 reserved3:2;
+ u32 F:3; //fbs
+ u32 O:3; //om
+ u32 BUS:1; //bsy
+ u32 DAU:1;
+ u32 ARS:1;
+ u32 SM:1;
+ u32 E_D:1;
+ u32 KV:1;
+ u32 K:2; //KL
+
+ } controlr;
+ u32 ID3R; //80h
+ u32 ID2R; //84h
+ u32 ID1R; //88h
+ u32 ID0R; //8Ch
+ u32 K7R; //90h
+ u32 K6R; //94h
+ u32 K5R; //98h
+ u32 K4R; //9Ch
+ u32 K3R; //A0h
+ u32 K2R; //A4h
+ u32 K1R; //A8h
+ u32 K0R; //ACh
+ u32 IV3R; //B0h
+ u32 IV2R; //B4h
+ u32 IV1R; //B8h
+ u32 IV0R; //BCh
+ u32 OD3R; //D4h
+ u32 OD2R; //D8h
+ u32 OD1R; //DCh
+ u32 OD0R; //E0h
+};
+
+struct arc4_t {
+ struct arc4_controlr {
+
+ u32 KRE:1;
+ u32 KLEN:4;
+ u32 KSAE:1;
+ u32 GO:1;
+ u32 STP:1;
+ u32 reserved1:6;
+ u32 NDC:1;
+ u32 ENDI:1;
+ u32 reserved2:8;
+ u32 BUS:1; //bsy
+ u32 reserved3:1;
+ u32 ARS:1;
+ u32 SM:1;
+ u32 reserved4:4;
+
+ } controlr;
+ u32 K3R; //104h
+ u32 K2R; //108h
+ u32 K1R; //10Ch
+ u32 K0R; //110h
+
+ u32 IDLEN; //114h
+
+ u32 ID3R; //118h
+ u32 ID2R; //11Ch
+ u32 ID1R; //120h
+ u32 ID0R; //124h
+
+ u32 OD3R; //128h
+ u32 OD2R; //12Ch
+ u32 OD1R; //130h
+ u32 OD0R; //134h
+};
+
+struct deu_hash_t {
+ struct hash_controlr {
+ u32 reserved1:5;
+ u32 KHS:1;
+ u32 GO:1;
+ u32 INIT:1;
+ u32 reserved2:6;
+ u32 NDC:1;
+ u32 ENDI:1;
+ u32 reserved3:7;
+ u32 DGRY:1;
+ u32 BSY:1;
+ u32 reserved4:1;
+ u32 IRCL:1;
+ u32 SM:1;
+ u32 KYUE:1;
+ u32 HMEN:1;
+ u32 SSEN:1;
+ u32 ALGO:1;
+
+ } controlr;
+ u32 MR; //B4h
+ u32 D1R; //B8h
+ u32 D2R; //BCh
+ u32 D3R; //C0h
+ u32 D4R; //C4h
+ u32 D5R; //C8h
+
+ u32 dummy; //CCh
+
+ u32 KIDX; //D0h
+ u32 KEY; //D4h
+ u32 DBN; //D8h
+};
+
+
+struct deu_dma_t {
+ struct dma_controlr {
+ u32 reserved1:22;
+ u32 BS:2;
+ u32 BSY:1;
+ u32 reserved2:1;
+ u32 ALGO:2;
+ u32 RXCLS:2;
+ u32 reserved3:1;
+ u32 EN:1;
+
+ } controlr;
+};
+
+#endif /* IFXMIPS_DEU_VR9_H */
diff --git a/package/platform/lantiq/ltq-deu/src/ifxmips_md5.c b/package/platform/lantiq/ltq-deu/src/ifxmips_md5.c
new file mode 100644
index 0000000..591389f
--- /dev/null
+++ b/package/platform/lantiq/ltq-deu/src/ifxmips_md5.c
@@ -0,0 +1,310 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_md5.c
+** PROJECT : IFX UEIP
+** MODULES : DEU Module for UEIP
+**
+** DATE : September 8, 2009
+** AUTHOR : Mohammad Firdaus
+** DESCRIPTION : Data Encryption Unit Driver
+** COPYRIGHT : Copyright (c) 2009
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 08,Sept 2009 Mohammad Firdaus Initial UEIP release
+*******************************************************************************/
+/*!
+ \defgroup IFX_DEU IFX_DEU_DRIVERS
+ \ingroup API
+ \brief ifx deu driver module
+*/
+
+/*!
+ \file ifxmips_md5.c
+ \ingroup IFX_DEU
+ \brief MD5 encryption deu driver file
+*/
+
+/*!
+ \defgroup IFX_MD5_FUNCTIONS IFX_MD5_FUNCTIONS
+ \ingroup IFX_DEU
+ \brief ifx deu MD5 functions
+*/
+
+/*Project header files */
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/string.h>
+#include <linux/crypto.h>
+#include <linux/types.h>
+#include <crypto/internal/hash.h>
+#include <asm/byteorder.h>
+
+/* Project header */
+#if defined(CONFIG_DANUBE)
+#include "ifxmips_deu_danube.h"
+#elif defined(CONFIG_AR9)
+#include "ifxmips_deu_ar9.h"
+#elif defined(CONFIG_VR9) || defined(CONFIG_AR10)
+#include "ifxmips_deu_vr9.h"
+#else
+#error "Plaform Unknwon!"
+#endif
+
+#define MD5_DIGEST_SIZE 16
+#define MD5_HMAC_BLOCK_SIZE 64
+#define MD5_BLOCK_WORDS 16
+#define MD5_HASH_WORDS 4
+#define HASH_START IFX_HASH_CON
+
+static spinlock_t lock;
+#define CRTCL_SECT_INIT spin_lock_init(&lock)
+#define CRTCL_SECT_START spin_lock_irqsave(&lock, flag)
+#define CRTCL_SECT_END spin_unlock_irqrestore(&lock, flag)
+
+//#define CRYPTO_DEBUG
+#ifdef CRYPTO_DEBUG
+extern char debug_level;
+#define DPRINTF(level, format, args...) if (level < debug_level) printk(KERN_INFO "[%s %s %d]: " format, __FILE__, __func__, __LINE__, ##args);
+#else
+#define DPRINTF(level, format, args...)
+#endif
+
+struct md5_ctx {
+ int started;
+ u32 hash[MD5_HASH_WORDS];
+ u32 block[MD5_BLOCK_WORDS];
+ u64 byte_count;
+};
+
+extern int disable_deudma;
+
+/*! \fn static u32 endian_swap(u32 input)
+ * \ingroup IFX_MD5_FUNCTIONS
+ * \brief perform dword level endian swap
+ * \param input value of dword that requires to be swapped
+*/
+static u32 endian_swap(u32 input)
+{
+ u8 *ptr = (u8 *)&input;
+
+ return ((ptr[3] << 24) | (ptr[2] << 16) | (ptr[1] << 8) | ptr[0]);
+}
+
+/*! \fn static void md5_transform(u32 *hash, u32 const *in)
+ * \ingroup IFX_MD5_FUNCTIONS
+ * \brief main interface to md5 hardware
+ * \param hash current hash value
+ * \param in 64-byte block of input
+*/
+static void md5_transform(struct md5_ctx *mctx, u32 *hash, u32 const *in)
+{
+ int i;
+ volatile struct deu_hash_t *hashs = (struct deu_hash_t *) HASH_START;
+ unsigned long flag;
+
+ CRTCL_SECT_START;
+
+ if (mctx->started) {
+ hashs->D1R = endian_swap(*((u32 *) hash + 0));
+ hashs->D2R = endian_swap(*((u32 *) hash + 1));
+ hashs->D3R = endian_swap(*((u32 *) hash + 2));
+ hashs->D4R = endian_swap(*((u32 *) hash + 3));
+ }
+
+ for (i = 0; i < 16; i++) {
+ hashs->MR = endian_swap(in[i]);
+// printk("in[%d]: %08x\n", i, endian_swap(in[i]));
+ };
+
+ //wait for processing
+ while (hashs->controlr.BSY) {
+ // this will not take long
+ }
+
+ *((u32 *) hash + 0) = endian_swap (hashs->D1R);
+ *((u32 *) hash + 1) = endian_swap (hashs->D2R);
+ *((u32 *) hash + 2) = endian_swap (hashs->D3R);
+ *((u32 *) hash + 3) = endian_swap (hashs->D4R);
+
+ mctx->started = 1;
+
+ CRTCL_SECT_END;
+}
+
+/*! \fn static inline void md5_transform_helper(struct md5_ctx *ctx)
+ * \ingroup IFX_MD5_FUNCTIONS
+ * \brief interfacing function for md5_transform()
+ * \param ctx crypto context
+*/
+static inline void md5_transform_helper(struct md5_ctx *ctx)
+{
+ //le32_to_cpu_array(ctx->block, sizeof(ctx->block) / sizeof(u32));
+ md5_transform(ctx, ctx->hash, ctx->block);
+}
+
+/*! \fn static void md5_init(struct crypto_tfm *tfm)
+ * \ingroup IFX_MD5_FUNCTIONS
+ * \brief initialize md5 hardware
+ * \param tfm linux crypto algo transform
+*/
+static int md5_init(struct shash_desc *desc)
+{
+ struct md5_ctx *mctx = shash_desc_ctx(desc);
+ volatile struct deu_hash_t *hash = (struct deu_hash_t *) HASH_START;
+
+ hash->controlr.ENDI = 0;
+ hash->controlr.SM = 1;
+ hash->controlr.ALGO = 1; // 1 = md5 0 = sha1
+ hash->controlr.INIT = 1; // Initialize the hash operation by writing a '1' to the INIT bit.
+
+ mctx->byte_count = 0;
+ mctx->started = 0;
+ return 0;
+}
+
+/*! \fn static void md5_update(struct crypto_tfm *tfm, const u8 *data, unsigned int len)
+ * \ingroup IFX_MD5_FUNCTIONS
+ * \brief on-the-fly md5 computation
+ * \param tfm linux crypto algo transform
+ * \param data input data
+ * \param len size of input data
+*/
+static int md5_update(struct shash_desc *desc, const u8 *data, unsigned int len)
+{
+ struct md5_ctx *mctx = shash_desc_ctx(desc);
+ const u32 avail = sizeof(mctx->block) - (mctx->byte_count & 0x3f);
+
+ mctx->byte_count += len;
+
+ if (avail > len) {
+ memcpy((char *)mctx->block + (sizeof(mctx->block) - avail),
+ data, len);
+ return 0;
+ }
+
+ memcpy((char *)mctx->block + (sizeof(mctx->block) - avail),
+ data, avail);
+
+ md5_transform_helper(mctx);
+ data += avail;
+ len -= avail;
+
+ while (len >= sizeof(mctx->block)) {
+ memcpy(mctx->block, data, sizeof(mctx->block));
+ md5_transform_helper(mctx);
+ data += sizeof(mctx->block);
+ len -= sizeof(mctx->block);
+ }
+
+ memcpy(mctx->block, data, len);
+ return 0;
+}
+
+/*! \fn static void md5_final(struct crypto_tfm *tfm, u8 *out)
+ * \ingroup IFX_MD5_FUNCTIONS
+ * \brief compute final md5 value
+ * \param tfm linux crypto algo transform
+ * \param out final md5 output value
+*/
+static int md5_final(struct shash_desc *desc, u8 *out)
+{
+ struct md5_ctx *mctx = shash_desc_ctx(desc);
+ const unsigned int offset = mctx->byte_count & 0x3f;
+ char *p = (char *)mctx->block + offset;
+ int padding = 56 - (offset + 1);
+ volatile struct deu_hash_t *hashs = (struct deu_hash_t *) HASH_START;
+ unsigned long flag;
+
+ *p++ = 0x80;
+ if (padding < 0) {
+ memset(p, 0x00, padding + sizeof (u64));
+ md5_transform_helper(mctx);
+ p = (char *)mctx->block;
+ padding = 56;
+ }
+
+ memset(p, 0, padding);
+ mctx->block[14] = endian_swap(mctx->byte_count << 3);
+ mctx->block[15] = endian_swap(mctx->byte_count >> 29);
+
+#if 0
+ le32_to_cpu_array(mctx->block, (sizeof(mctx->block) -
+ sizeof(u64)) / sizeof(u32));
+#endif
+
+ md5_transform(mctx, mctx->hash, mctx->block);
+
+ CRTCL_SECT_START;
+
+ *((u32 *) out + 0) = endian_swap (hashs->D1R);
+ *((u32 *) out + 1) = endian_swap (hashs->D2R);
+ *((u32 *) out + 2) = endian_swap (hashs->D3R);
+ *((u32 *) out + 3) = endian_swap (hashs->D4R);
+
+ CRTCL_SECT_END;
+
+ // Wipe context
+ memset(mctx, 0, sizeof(*mctx));
+
+ return 0;
+}
+
+/*
+ * \brief MD5 function mappings
+*/
+static struct shash_alg ifxdeu_md5_alg = {
+ .digestsize = MD5_DIGEST_SIZE,
+ .init = md5_init,
+ .update = md5_update,
+ .final = md5_final,
+ .descsize = sizeof(struct md5_ctx),
+ .base = {
+ .cra_name = "md5",
+ .cra_driver_name= "ifxdeu-md5",
+ .cra_flags = CRYPTO_ALG_TYPE_DIGEST,
+ .cra_blocksize = MD5_HMAC_BLOCK_SIZE,
+ .cra_module = THIS_MODULE,
+ }
+};
+
+/*! \fn int __init ifxdeu_init_md5 (void)
+ * \ingroup IFX_MD5_FUNCTIONS
+ * \brief initialize md5 driver
+*/
+int __init ifxdeu_init_md5 (void)
+{
+ int ret = -ENOSYS;
+
+
+ if ((ret = crypto_register_shash(&ifxdeu_md5_alg)))
+ goto md5_err;
+
+ CRTCL_SECT_INIT;
+
+ printk (KERN_NOTICE "IFX DEU MD5 initialized%s.\n", disable_deudma ? "" : " (DMA)");
+ return ret;
+
+md5_err:
+ printk(KERN_ERR "IFX DEU MD5 initialization failed!\n");
+ return ret;
+}
+
+/*! \fn void __exit ifxdeu_fini_md5 (void)
+ * \ingroup IFX_MD5_FUNCTIONS
+ * \brief unregister md5 driver
+*/
+
+void __exit ifxdeu_fini_md5 (void)
+{
+ crypto_unregister_shash(&ifxdeu_md5_alg);
+
+}
+
diff --git a/package/platform/lantiq/ltq-deu/src/ifxmips_md5_hmac.c b/package/platform/lantiq/ltq-deu/src/ifxmips_md5_hmac.c
new file mode 100644
index 0000000..fc6f52e
--- /dev/null
+++ b/package/platform/lantiq/ltq-deu/src/ifxmips_md5_hmac.c
@@ -0,0 +1,386 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_md5_hmac.c
+** PROJECT : IFX UEIP
+** MODULES : DEU Module for UEIP
+**
+** DATE : September 8, 2009
+** AUTHOR : Mohammad Firdaus
+** DESCRIPTION : Data Encryption Unit Driver
+** COPYRIGHT : Copyright (c) 2009
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 08,Sept 2009 Mohammad Firdaus Initial UEIP release
+** 21,March 2011 Mohammad Firdaus Changes for Kernel 2.6.32 and IPSec integration
+*******************************************************************************/
+/*!
+ \defgroup IFX_DEU IFX_DEU_DRIVERS
+ \ingroup API
+ \brief ifx deu driver module
+*/
+
+/*!
+ \file ifxmips_md5_hmac.c
+ \ingroup IFX_DEU
+ \brief MD5-HMAC encryption deu driver file
+*/
+
+/*!
+ \defgroup IFX_MD5_HMAC_FUNCTIONS IFX_MD5_HMAC_FUNCTIONS
+ \ingroup IFX_DEU
+ \brief ifx md5-hmac driver functions
+*/
+
+/* Project Header files */
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/string.h>
+#include <linux/crypto.h>
+#include <linux/types.h>
+#include <crypto/internal/hash.h>
+#include <asm/byteorder.h>
+
+#if defined(CONFIG_AR9)
+#include "ifxmips_deu_ar9.h"
+#elif defined(CONFIG_VR9) || defined(CONFIG_AR10)
+#include "ifxmips_deu_vr9.h"
+#else
+#error "Plaform Unknwon!"
+#endif
+
+#define MD5_DIGEST_SIZE 16
+#define MD5_HMAC_BLOCK_SIZE 64
+#define MD5_BLOCK_WORDS 16
+#define MD5_HASH_WORDS 4
+#define MD5_HMAC_DBN_TEMP_SIZE 1024 // size in dword, needed for dbn workaround
+#define HASH_START IFX_HASH_CON
+
+static spinlock_t lock;
+#define CRTCL_SECT_INIT spin_lock_init(&lock)
+#define CRTCL_SECT_START spin_lock_irqsave(&lock, flag)
+#define CRTCL_SECT_END spin_unlock_irqrestore(&lock, flag)
+
+//#define CRYPTO_DEBUG
+#ifdef CRYPTO_DEBUG
+extern char debug_level;
+#define DPRINTF(level, format, args...) if (level < debug_level) printk(KERN_INFO "[%s %s %d]: " format, __FILE__, __func__, __LINE__, ##args);
+#else
+#define DPRINTF(level, format, args...)
+#endif
+
+#define MAX_HASH_KEYLEN 64
+
+struct md5_hmac_ctx {
+ u8 key[MAX_HASH_KEYLEN];
+ u32 hash[MD5_HASH_WORDS];
+ u32 block[MD5_BLOCK_WORDS];
+ u64 byte_count;
+ u32 dbn;
+ unsigned int keylen;
+};
+
+static u32 temp[MD5_HMAC_DBN_TEMP_SIZE];
+
+extern int disable_deudma;
+
+/*! \fn static u32 endian_swap(u32 input)
+ * \ingroup IFX_MD5_HMAC_FUNCTIONS
+ * \brief perform dword level endian swap
+ * \param input value of dword that requires to be swapped
+*/
+static u32 endian_swap(u32 input)
+{
+ u8 *ptr = (u8 *)&input;
+
+ return ((ptr[3] << 24) | (ptr[2] << 16) | (ptr[1] << 8) | ptr[0]);
+}
+
+/*! \fn static void md5_hmac_transform(struct crypto_tfm *tfm, u32 const *in)
+ * \ingroup IFX_MD5_HMAC_FUNCTIONS
+ * \brief save input block to context
+ * \param tfm linux crypto algo transform
+ * \param in 64-byte block of input
+*/
+static void md5_hmac_transform(struct shash_desc *desc, u32 const *in)
+{
+ struct md5_hmac_ctx *mctx = crypto_shash_ctx(desc->tfm);
+
+ memcpy(&temp[mctx->dbn<<4], in, 64); //dbn workaround
+ mctx->dbn += 1;
+
+ if ( (mctx->dbn<<4) > MD5_HMAC_DBN_TEMP_SIZE )
+ {
+ printk("MD5_HMAC_DBN_TEMP_SIZE exceeded\n");
+ }
+
+}
+
+/*! \fn int md5_hmac_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen)
+ * \ingroup IFX_MD5_HMAC_FUNCTIONS
+ * \brief sets md5 hmac key
+ * \param tfm linux crypto algo transform
+ * \param key input key
+ * \param keylen key length greater than 64 bytes IS NOT SUPPORTED
+*/
+static int md5_hmac_setkey(struct crypto_shash *tfm, const u8 *key, unsigned int keylen)
+{
+ struct md5_hmac_ctx *mctx = crypto_shash_ctx(tfm);
+ volatile struct deu_hash_t *hash = (struct deu_hash_t *) HASH_START;
+ //printk("copying keys to context with length %d\n", keylen);
+
+ if (keylen > MAX_HASH_KEYLEN) {
+ printk("Key length more than what DEU hash can handle\n");
+ return -EINVAL;
+ }
+
+
+ hash->KIDX |= 0x80000000; // reset all 16 words of the key to '0'
+ memcpy(&mctx->key, key, keylen);
+ mctx->keylen = keylen;
+
+ return 0;
+
+}
+
+
+/*! \fn int md5_hmac_setkey_hw(const u8 *key, unsigned int keylen)
+ * \ingroup IFX_MD5_HMAC_FUNCTIONS
+ * \brief sets md5 hmac key into the hardware registers
+ * \param key input key
+ * \param keylen key length greater than 64 bytes IS NOT SUPPORTED
+*/
+
+static int md5_hmac_setkey_hw(const u8 *key, unsigned int keylen)
+{
+ volatile struct deu_hash_t *hash = (struct deu_hash_t *) HASH_START;
+ unsigned long flag;
+ int i, j;
+ u32 *in_key = (u32 *)key;
+
+ //printk("\nsetkey keylen: %d\n key: ", keylen);
+
+ CRTCL_SECT_START;
+ j = 0;
+ for (i = 0; i < keylen; i+=4)
+ {
+ hash->KIDX = j;
+ asm("sync");
+ hash->KEY = *((u32 *) in_key + j);
+ asm("sync");
+ j++;
+ }
+ CRTCL_SECT_END;
+
+ return 0;
+}
+
+/*! \fn void md5_hmac_init(struct crypto_tfm *tfm)
+ * \ingroup IFX_MD5_HMAC_FUNCTIONS
+ * \brief initialize md5 hmac context
+ * \param tfm linux crypto algo transform
+*/
+static int md5_hmac_init(struct shash_desc *desc)
+{
+
+ struct md5_hmac_ctx *mctx = crypto_shash_ctx(desc->tfm);
+
+
+ mctx->dbn = 0; //dbn workaround
+ md5_hmac_setkey_hw(mctx->key, mctx->keylen);
+
+ return 0;
+}
+EXPORT_SYMBOL(md5_hmac_init);
+
+/*! \fn void md5_hmac_update(struct crypto_tfm *tfm, const u8 *data, unsigned int len)
+ * \ingroup IFX_MD5_HMAC_FUNCTIONS
+ * \brief on-the-fly md5 hmac computation
+ * \param tfm linux crypto algo transform
+ * \param data input data
+ * \param len size of input data
+*/
+static int md5_hmac_update(struct shash_desc *desc, const u8 *data, unsigned int len)
+{
+ struct md5_hmac_ctx *mctx = crypto_shash_ctx(desc->tfm);
+ const u32 avail = sizeof(mctx->block) - (mctx->byte_count & 0x3f);
+
+ mctx->byte_count += len;
+
+ if (avail > len) {
+ memcpy((char *)mctx->block + (sizeof(mctx->block) - avail),
+ data, len);
+ return 0;
+ }
+
+ memcpy((char *)mctx->block + (sizeof(mctx->block) - avail),
+ data, avail);
+
+ md5_hmac_transform(desc, mctx->block);
+ data += avail;
+ len -= avail;
+
+ while (len >= sizeof(mctx->block)) {
+ memcpy(mctx->block, data, sizeof(mctx->block));
+ md5_hmac_transform(desc, mctx->block);
+ data += sizeof(mctx->block);
+ len -= sizeof(mctx->block);
+ }
+
+ memcpy(mctx->block, data, len);
+ return 0;
+}
+EXPORT_SYMBOL(md5_hmac_update);
+
+/*! \fn void md5_hmac_final(struct crypto_tfm *tfm, u8 *out)
+ * \ingroup IFX_MD5_HMAC_FUNCTIONS
+ * \brief compute final md5 hmac value
+ * \param tfm linux crypto algo transform
+ * \param out final md5 hmac output value
+*/
+static int md5_hmac_final(struct shash_desc *desc, u8 *out)
+{
+ struct md5_hmac_ctx *mctx = crypto_shash_ctx(desc->tfm);
+ const unsigned int offset = mctx->byte_count & 0x3f;
+ char *p = (char *)mctx->block + offset;
+ int padding = 56 - (offset + 1);
+ volatile struct deu_hash_t *hashs = (struct deu_hash_t *) HASH_START;
+ unsigned long flag;
+ int i = 0;
+ int dbn;
+ u32 *in = &temp[0];
+
+
+ *p++ = 0x80;
+ if (padding < 0) {
+ memset(p, 0x00, padding + sizeof (u64));
+ md5_hmac_transform(desc, mctx->block);
+ p = (char *)mctx->block;
+ padding = 56;
+ }
+
+ memset(p, 0, padding);
+ mctx->block[14] = endian_swap((mctx->byte_count + 64) << 3); // need to add 512 bit of the IPAD operation
+ mctx->block[15] = 0x00000000;
+
+ md5_hmac_transform(desc, mctx->block);
+
+ CRTCL_SECT_START;
+
+ //printk("\ndbn = %d\n", mctx->dbn);
+ hashs->DBN = mctx->dbn;
+ asm("sync");
+
+ *IFX_HASH_CON = 0x0703002D; //khs, go, init, ndc, endi, kyue, hmen, md5
+
+ //wait for processing
+ while (hashs->controlr.BSY) {
+ // this will not take long
+ }
+
+ for (dbn = 0; dbn < mctx->dbn; dbn++)
+ {
+ for (i = 0; i < 16; i++) {
+ hashs->MR = in[i];
+ };
+
+ hashs->controlr.GO = 1;
+ asm("sync");
+
+ //wait for processing
+ while (hashs->controlr.BSY) {
+ // this will not take long
+ }
+
+ in += 16;
+}
+
+
+#if 1
+ //wait for digest ready
+ while (! hashs->controlr.DGRY) {
+ // this will not take long
+ }
+#endif
+
+ *((u32 *) out + 0) = hashs->D1R;
+ *((u32 *) out + 1) = hashs->D2R;
+ *((u32 *) out + 2) = hashs->D3R;
+ *((u32 *) out + 3) = hashs->D4R;
+ *((u32 *) out + 4) = hashs->D5R;
+
+ /* reset the context after we finish with the hash */
+ mctx->byte_count = 0;
+ memset(&mctx->hash[0], 0, sizeof(MD5_HASH_WORDS));
+ memset(&mctx->block[0], 0, sizeof(MD5_BLOCK_WORDS));
+ memset(&temp[0], 0, MD5_HMAC_DBN_TEMP_SIZE);
+
+ CRTCL_SECT_END;
+
+
+ return 0;
+}
+
+EXPORT_SYMBOL(md5_hmac_final);
+
+/*
+ * \brief MD5_HMAC function mappings
+*/
+
+static struct shash_alg ifxdeu_md5_hmac_alg = {
+ .digestsize = MD5_DIGEST_SIZE,
+ .init = md5_hmac_init,
+ .update = md5_hmac_update,
+ .final = md5_hmac_final,
+ .setkey = md5_hmac_setkey,
+ .descsize = sizeof(struct md5_hmac_ctx),
+ .base = {
+ .cra_name = "hmac(md5)",
+ .cra_driver_name= "ifxdeu-md5_hmac",
+ .cra_ctxsize = sizeof(struct md5_hmac_ctx),
+ .cra_flags = CRYPTO_ALG_TYPE_DIGEST,
+ .cra_blocksize = MD5_HMAC_BLOCK_SIZE,
+ .cra_module = THIS_MODULE,
+ }
+};
+
+/*! \fn int __init ifxdeu_init_md5_hmac (void)
+ * \ingroup IFX_MD5_HMAC_FUNCTIONS
+ * \brief initialize md5 hmac driver
+*/
+int __init ifxdeu_init_md5_hmac (void)
+{
+
+ int ret = -ENOSYS;
+
+
+ if ((ret = crypto_register_shash(&ifxdeu_md5_hmac_alg)))
+ goto md5_hmac_err;
+
+ CRTCL_SECT_INIT;
+
+ printk (KERN_NOTICE "IFX DEU MD5_HMAC initialized%s.\n", disable_deudma ? "" : " (DMA)");
+ return ret;
+
+md5_hmac_err:
+ printk(KERN_ERR "IFX DEU MD5_HMAC initialization failed!\n");
+ return ret;
+}
+
+/** \fn void __exit ifxdeu_fini_md5_hmac (void)
+ * \ingroup IFX_MD5_HMAC_FUNCTIONS
+ * \brief unregister md5 hmac driver
+*/
+void __exit ifxdeu_fini_md5_hmac (void)
+{
+ crypto_unregister_shash(&ifxdeu_md5_hmac_alg);
+}
+
+
diff --git a/package/platform/lantiq/ltq-deu/src/ifxmips_sha1.c b/package/platform/lantiq/ltq-deu/src/ifxmips_sha1.c
new file mode 100644
index 0000000..a5f5f90
--- /dev/null
+++ b/package/platform/lantiq/ltq-deu/src/ifxmips_sha1.c
@@ -0,0 +1,301 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_sha1.c
+** PROJECT : IFX UEIP
+** MODULES : DEU Module for Danube
+**
+** DATE : September 8, 2009
+** AUTHOR : Mohammad Firdaus
+** DESCRIPTION : Data Encryption Unit Driver
+** COPYRIGHT : Copyright (c) 2009
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 08,Sept 2009 Mohammad Firdaus Initial UEIP release
+*******************************************************************************/
+/*!
+ \defgroup IFX_DEU IFX_DEU_DRIVERS
+ \ingroup API
+ \brief ifx deu driver module
+*/
+
+/*!
+ \file ifxmips_sha1.c
+ \ingroup IFX_DEU
+ \brief SHA1 encryption deu driver file
+*/
+
+/*!
+ \defgroup IFX_SHA1_FUNCTIONS IFX_SHA1_FUNCTIONS
+ \ingroup IFX_DEU
+ \brief ifx deu sha1 functions
+*/
+
+
+/* Project header */
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/mm.h>
+#include <linux/crypto.h>
+#include <linux/cryptohash.h>
+#include <crypto/sha.h>
+#include <crypto/internal/hash.h>
+#include <linux/types.h>
+#include <asm/scatterlist.h>
+#include <asm/byteorder.h>
+
+#if defined(CONFIG_DANUBE)
+#include "ifxmips_deu_danube.h"
+#elif defined(CONFIG_AR9)
+#include "ifxmips_deu_ar9.h"
+#elif defined(CONFIG_VR9) || defined(CONFIG_AR10)
+#include "ifxmips_deu_vr9.h"
+#else
+#error "Plaform Unknwon!"
+#endif
+
+#define SHA1_DIGEST_SIZE 20
+#define SHA1_HMAC_BLOCK_SIZE 64
+#define HASH_START IFX_HASH_CON
+
+static spinlock_t lock;
+#define CRTCL_SECT_INIT spin_lock_init(&lock)
+#define CRTCL_SECT_START spin_lock_irqsave(&lock, flag)
+#define CRTCL_SECT_END spin_unlock_irqrestore(&lock, flag)
+
+//#define CRYPTO_DEBUG
+#ifdef CRYPTO_DEBUG
+extern char debug_level;
+#define DPRINTF(level, format, args...) if (level < debug_level) printk(KERN_INFO "[%s %s %d]: " format, __FILE__, __func__, __LINE__, ##args);
+#else
+#define DPRINTF(level, format, args...)
+#endif
+
+/*
+ * \brief SHA1 private structure
+*/
+struct sha1_ctx {
+ int started;
+ u64 count;
+ u32 hash[5];
+ u32 state[5];
+ u8 buffer[64];
+};
+
+extern int disable_deudma;
+
+
+/*! \fn static void sha1_transform (u32 *state, const u32 *in)
+ * \ingroup IFX_SHA1_FUNCTIONS
+ * \brief main interface to sha1 hardware
+ * \param state current state
+ * \param in 64-byte block of input
+*/
+static void sha1_transform (struct sha1_ctx *sctx, u32 *state, const u32 *in)
+{
+ int i = 0;
+ volatile struct deu_hash_t *hashs = (struct deu_hash_t *) HASH_START;
+ unsigned long flag;
+
+ CRTCL_SECT_START;
+
+ /* For context switching purposes, the previous hash output
+ * is loaded back into the output register
+ */
+ if (sctx->started) {
+ hashs->D1R = *((u32 *) sctx->hash + 0);
+ hashs->D2R = *((u32 *) sctx->hash + 1);
+ hashs->D3R = *((u32 *) sctx->hash + 2);
+ hashs->D4R = *((u32 *) sctx->hash + 3);
+ hashs->D5R = *((u32 *) sctx->hash + 4);
+ }
+
+ for (i = 0; i < 16; i++) {
+ hashs->MR = in[i];
+ };
+
+ //wait for processing
+ while (hashs->controlr.BSY) {
+ // this will not take long
+ }
+
+ /* For context switching purposes, the output is saved into a
+ * context struct which can be used later on
+ */
+ *((u32 *) sctx->hash + 0) = hashs->D1R;
+ *((u32 *) sctx->hash + 1) = hashs->D2R;
+ *((u32 *) sctx->hash + 2) = hashs->D3R;
+ *((u32 *) sctx->hash + 3) = hashs->D4R;
+ *((u32 *) sctx->hash + 4) = hashs->D5R;
+
+ sctx->started = 1;
+
+ CRTCL_SECT_END;
+}
+
+/*! \fn static void sha1_init(struct crypto_tfm *tfm)
+ * \ingroup IFX_SHA1_FUNCTIONS
+ * \brief initialize sha1 hardware
+ * \param tfm linux crypto algo transform
+*/
+static int sha1_init(struct shash_desc *desc)
+{
+ struct sha1_ctx *sctx = shash_desc_ctx(desc);
+
+ SHA_HASH_INIT;
+
+ sctx->started = 0;
+ sctx->count = 0;
+ return 0;
+}
+
+/*! \fn static void sha1_update(struct crypto_tfm *tfm, const u8 *data, unsigned int len)
+ * \ingroup IFX_SHA1_FUNCTIONS
+ * \brief on-the-fly sha1 computation
+ * \param tfm linux crypto algo transform
+ * \param data input data
+ * \param len size of input data
+*/
+static int sha1_update(struct shash_desc * desc, const u8 *data,
+ unsigned int len)
+{
+ struct sha1_ctx *sctx = shash_desc_ctx(desc);
+ unsigned int i, j;
+
+ j = (sctx->count >> 3) & 0x3f;
+ sctx->count += len << 3;
+
+ if ((j + len) > 63) {
+ memcpy (&sctx->buffer[j], data, (i = 64 - j));
+ sha1_transform (sctx, sctx->state, (const u32 *)sctx->buffer);
+ for (; i + 63 < len; i += 64) {
+ sha1_transform (sctx, sctx->state, (const u32 *)&data[i]);
+ }
+
+ j = 0;
+ }
+ else
+ i = 0;
+
+ memcpy (&sctx->buffer[j], &data[i], len - i);
+ return 0;
+}
+
+/*! \fn static void sha1_final(struct crypto_tfm *tfm, u8 *out)
+ * \ingroup IFX_SHA1_FUNCTIONS
+ * \brief compute final sha1 value
+ * \param tfm linux crypto algo transform
+ * \param out final md5 output value
+*/
+static int sha1_final(struct shash_desc *desc, u8 *out)
+{
+ struct sha1_ctx *sctx = shash_desc_ctx(desc);
+ u32 index, padlen;
+ u64 t;
+ u8 bits[8] = { 0, };
+ static const u8 padding[64] = { 0x80, };
+ volatile struct deu_hash_t *hashs = (struct deu_hash_t *) HASH_START;
+ unsigned long flag;
+
+ t = sctx->count;
+ bits[7] = 0xff & t;
+ t >>= 8;
+ bits[6] = 0xff & t;
+ t >>= 8;
+ bits[5] = 0xff & t;
+ t >>= 8;
+ bits[4] = 0xff & t;
+ t >>= 8;
+ bits[3] = 0xff & t;
+ t >>= 8;
+ bits[2] = 0xff & t;
+ t >>= 8;
+ bits[1] = 0xff & t;
+ t >>= 8;
+ bits[0] = 0xff & t;
+
+ /* Pad out to 56 mod 64 */
+ index = (sctx->count >> 3) & 0x3f;
+ padlen = (index < 56) ? (56 - index) : ((64 + 56) - index);
+ sha1_update (desc, padding, padlen);
+
+ /* Append length */
+ sha1_update (desc, bits, sizeof bits);
+
+ CRTCL_SECT_START;
+
+ *((u32 *) out + 0) = hashs->D1R;
+ *((u32 *) out + 1) = hashs->D2R;
+ *((u32 *) out + 2) = hashs->D3R;
+ *((u32 *) out + 3) = hashs->D4R;
+ *((u32 *) out + 4) = hashs->D5R;
+
+ CRTCL_SECT_END;
+
+ // Wipe context
+ memset (sctx, 0, sizeof *sctx);
+
+ return 0;
+}
+
+/*
+ * \brief SHA1 function mappings
+*/
+static struct shash_alg ifxdeu_sha1_alg = {
+ .digestsize = SHA1_DIGEST_SIZE,
+ .init = sha1_init,
+ .update = sha1_update,
+ .final = sha1_final,
+ .descsize = sizeof(struct sha1_ctx),
+ .statesize = sizeof(struct sha1_state),
+ .base = {
+ .cra_name = "sha1",
+ .cra_driver_name= "ifxdeu-sha1",
+ .cra_flags = CRYPTO_ALG_TYPE_DIGEST,
+ .cra_blocksize = SHA1_HMAC_BLOCK_SIZE,
+ .cra_module = THIS_MODULE,
+ }
+};
+
+
+/*! \fn int __init ifxdeu_init_sha1 (void)
+ * \ingroup IFX_SHA1_FUNCTIONS
+ * \brief initialize sha1 driver
+*/
+int __init ifxdeu_init_sha1 (void)
+{
+ int ret = -ENOSYS;
+
+
+ if ((ret = crypto_register_shash(&ifxdeu_sha1_alg)))
+ goto sha1_err;
+
+ CRTCL_SECT_INIT;
+
+ printk (KERN_NOTICE "IFX DEU SHA1 initialized%s.\n", disable_deudma ? "" : " (DMA)");
+ return ret;
+
+sha1_err:
+ printk(KERN_ERR "IFX DEU SHA1 initialization failed!\n");
+ return ret;
+}
+
+/*! \fn void __exit ifxdeu_fini_sha1 (void)
+ * \ingroup IFX_SHA1_FUNCTIONS
+ * \brief unregister sha1 driver
+*/
+void __exit ifxdeu_fini_sha1 (void)
+{
+ crypto_unregister_shash(&ifxdeu_sha1_alg);
+
+
+}
+
+
diff --git a/package/platform/lantiq/ltq-deu/src/ifxmips_sha1_hmac.c b/package/platform/lantiq/ltq-deu/src/ifxmips_sha1_hmac.c
new file mode 100644
index 0000000..a5a6c39
--- /dev/null
+++ b/package/platform/lantiq/ltq-deu/src/ifxmips_sha1_hmac.c
@@ -0,0 +1,378 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_sha1_hmac.c
+** PROJECT : IFX UEIP
+** MODULES : DEU Module for UEIP
+** DATE : September 8, 2009
+** AUTHOR : Mohammad Firdaus
+** DESCRIPTION : Data Encryption Unit Driver
+** COPYRIGHT : Copyright (c) 2009
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 08,Sept 2009 Mohammad Firdaus Initial UEIP release
+** 21,March 2011 Mohammad Firdaus Changes for Kernel 2.6.32 and IPSec integration
+*******************************************************************************/
+/*!
+ \defgroup IFX_DEU IFX_DEU_DRIVERS
+ \ingroup API
+ \brief ifx deu driver module
+*/
+
+/*!
+ \file ifxmips_sha1_hmac.c
+ \ingroup IFX_DEU
+ \brief SHA1-HMAC deu driver file
+*/
+
+/*!
+ \defgroup IFX_SHA1_HMAC_FUNCTIONS IFX_SHA1_HMAC_FUNCTIONS
+ \ingroup IFX_DEU
+ \brief ifx sha1 hmac functions
+*/
+
+
+/* Project header */
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/mm.h>
+#include <linux/crypto.h>
+#include <linux/cryptohash.h>
+#include <crypto/internal/hash.h>
+#include <linux/types.h>
+#include <asm/scatterlist.h>
+#include <asm/byteorder.h>
+#include <linux/delay.h>
+
+#if defined(CONFIG_AR9)
+#include "ifxmips_deu_ar9.h"
+#elif defined(CONFIG_VR9) || defined(CONFIG_AR10)
+#include "ifxmips_deu_vr9.h"
+#else
+#error "Plaform Unknwon!"
+#endif
+
+#define SHA1_DIGEST_SIZE 20
+#define SHA1_HMAC_BLOCK_SIZE 64
+#define SHA1_HMAC_DBN_TEMP_SIZE 1024 // size in dword, needed for dbn workaround
+#define HASH_START IFX_HASH_CON
+
+#define SHA1_HMAC_MAX_KEYLEN 64
+
+static spinlock_t lock;
+#define CRTCL_SECT_INIT spin_lock_init(&lock)
+#define CRTCL_SECT_START spin_lock_irqsave(&lock, flag)
+#define CRTCL_SECT_END spin_unlock_irqrestore(&lock, flag)
+
+#ifdef CRYPTO_DEBUG
+extern char debug_level;
+#define DPRINTF(level, format, args...) if (level < debug_level) printk(KERN_INFO "[%s %s %d]: " format, __FILE__, __func__, __LINE__, ##args);
+#else
+#define DPRINTF(level, format, args...)
+#endif
+
+struct sha1_hmac_ctx {
+ int keylen;
+
+ u8 buffer[SHA1_HMAC_BLOCK_SIZE];
+ u8 key[SHA1_HMAC_MAX_KEYLEN];
+ u32 state[5];
+ u32 dbn;
+ u64 count;
+
+};
+
+static u32 temp[SHA1_HMAC_DBN_TEMP_SIZE];
+
+extern int disable_deudma;
+
+/*! \fn static void sha1_hmac_transform(struct crypto_tfm *tfm, u32 const *in)
+ * \ingroup IFX_SHA1_HMAC_FUNCTIONS
+ * \brief save input block to context
+ * \param tfm linux crypto algo transform
+ * \param in 64-byte block of input
+*/
+static int sha1_hmac_transform(struct shash_desc *desc, u32 const *in)
+{
+ struct sha1_hmac_ctx *sctx = crypto_shash_ctx(desc->tfm);
+
+ memcpy(&temp[sctx->dbn<<4], in, 64); //dbn workaround
+ sctx->dbn += 1;
+
+ if ( (sctx->dbn<<4) > SHA1_HMAC_DBN_TEMP_SIZE )
+ {
+ printk("SHA1_HMAC_DBN_TEMP_SIZE exceeded\n");
+ }
+
+ return 0;
+}
+
+/*! \fn int sha1_hmac_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen)
+ * \ingroup IFX_SHA1_HMAC_FUNCTIONS
+ * \brief sets sha1 hmac key
+ * \param tfm linux crypto algo transform
+ * \param key input key
+ * \param keylen key length greater than 64 bytes IS NOT SUPPORTED
+*/
+static int sha1_hmac_setkey(struct crypto_shash *tfm, const u8 *key, unsigned int keylen)
+{
+ struct sha1_hmac_ctx *sctx = crypto_shash_ctx(tfm);
+ volatile struct deu_hash_t *hashs = (struct deu_hash_t *) HASH_START;
+
+ if (keylen > SHA1_HMAC_MAX_KEYLEN) {
+ printk("Key length exceeds maximum key length\n");
+ return -EINVAL;
+ }
+
+ //printk("Setting keys of len: %d\n", keylen);
+
+ hashs->KIDX |= 0x80000000; //reset keys back to 0
+ memcpy(&sctx->key, key, keylen);
+ sctx->keylen = keylen;
+
+ return 0;
+
+}
+
+
+/*! \fn int sha1_hmac_setkey_hw(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen)
+ * \ingroup IFX_SHA1_HMAC_FUNCTIONS
+ * \brief sets sha1 hmac key into hw registers
+ * \param tfm linux crypto algo transform
+ * \param key input key
+ * \param keylen key length greater than 64 bytes IS NOT SUPPORTED
+*/
+static int sha1_hmac_setkey_hw(const u8 *key, unsigned int keylen)
+{
+ volatile struct deu_hash_t *hash = (struct deu_hash_t *) HASH_START;
+ int i, j;
+ unsigned long flag;
+ u32 *in_key = (u32 *)key;
+
+ j = 0;
+
+ CRTCL_SECT_START;
+ for (i = 0; i < keylen; i+=4)
+ {
+ hash->KIDX = j;
+ asm("sync");
+ hash->KEY = *((u32 *) in_key + j);
+ j++;
+ }
+
+ CRTCL_SECT_END;
+ return 0;
+}
+
+/*! \fn void sha1_hmac_init(struct crypto_tfm *tfm)
+ * \ingroup IFX_SHA1_HMAC_FUNCTIONS
+ * \brief initialize sha1 hmac context
+ * \param tfm linux crypto algo transform
+*/
+static int sha1_hmac_init(struct shash_desc *desc)
+{
+ struct sha1_hmac_ctx *sctx = crypto_shash_ctx(desc->tfm);
+
+ //printk("debug ln: %d, fn: %s\n", __LINE__, __func__);
+ sctx->dbn = 0; //dbn workaround
+ sha1_hmac_setkey_hw(sctx->key, sctx->keylen);
+
+ return 0;
+}
+
+/*! \fn static void sha1_hmac_update(struct crypto_tfm *tfm, const u8 *data, unsigned int len)
+ * \ingroup IFX_SHA1_HMAC_FUNCTIONS
+ * \brief on-the-fly sha1 hmac computation
+ * \param tfm linux crypto algo transform
+ * \param data input data
+ * \param len size of input data
+*/
+static int sha1_hmac_update(struct shash_desc *desc, const u8 *data,
+ unsigned int len)
+{
+ struct sha1_hmac_ctx *sctx = crypto_shash_ctx(desc->tfm);
+ unsigned int i, j;
+
+ j = (sctx->count >> 3) & 0x3f;
+ sctx->count += len << 3;
+ // printk("sctx->count = %d\n", sctx->count);
+
+ if ((j + len) > 63) {
+ memcpy (&sctx->buffer[j], data, (i = 64 - j));
+ sha1_hmac_transform (desc, (const u32 *)sctx->buffer);
+ for (; i + 63 < len; i += 64) {
+ sha1_hmac_transform (desc, (const u32 *)&data[i]);
+ }
+
+ j = 0;
+ }
+ else
+ i = 0;
+
+ memcpy (&sctx->buffer[j], &data[i], len - i);
+ return 0;
+}
+
+/*! \fn static void sha1_hmac_final(struct crypto_tfm *tfm, u8 *out)
+ * \ingroup IFX_SHA1_HMAC_FUNCTIONS
+ * \brief ompute final sha1 hmac value
+ * \param tfm linux crypto algo transform
+ * \param out final sha1 hmac output value
+*/
+static int sha1_hmac_final(struct shash_desc *desc, u8 *out)
+{
+ //struct sha1_hmac_ctx *sctx = shash_desc_ctx(desc);
+ struct sha1_hmac_ctx *sctx = crypto_shash_ctx(desc->tfm);
+ u32 index, padlen;
+ u64 t;
+ u8 bits[8] = { 0, };
+ static const u8 padding[64] = { 0x80, };
+ volatile struct deu_hash_t *hashs = (struct deu_hash_t *) HASH_START;
+ unsigned long flag;
+ int i = 0;
+ int dbn;
+ u32 *in = &temp[0];
+
+ t = sctx->count + 512; // need to add 512 bit of the IPAD operation
+ bits[7] = 0xff & t;
+ t >>= 8;
+ bits[6] = 0xff & t;
+ t >>= 8;
+ bits[5] = 0xff & t;
+ t >>= 8;
+ bits[4] = 0xff & t;
+ t >>= 8;
+ bits[3] = 0xff & t;
+ t >>= 8;
+ bits[2] = 0xff & t;
+ t >>= 8;
+ bits[1] = 0xff & t;
+ t >>= 8;
+ bits[0] = 0xff & t;
+
+ /* Pad out to 56 mod 64 */
+ index = (sctx->count >> 3) & 0x3f;
+ padlen = (index < 56) ? (56 - index) : ((64 + 56) - index);
+ sha1_hmac_update (desc, padding, padlen);
+
+ /* Append length */
+ sha1_hmac_update (desc, bits, sizeof bits);
+
+ CRTCL_SECT_START;
+
+ hashs->DBN = sctx->dbn;
+
+ //for vr9 change, ENDI = 1
+ *IFX_HASH_CON = HASH_CON_VALUE;
+
+ //wait for processing
+ while (hashs->controlr.BSY) {
+ // this will not take long
+ }
+
+ for (dbn = 0; dbn < sctx->dbn; dbn++)
+ {
+ for (i = 0; i < 16; i++) {
+ hashs->MR = in[i];
+ };
+
+ hashs->controlr.GO = 1;
+ asm("sync");
+
+ //wait for processing
+ while (hashs->controlr.BSY) {
+ // this will not take long
+ }
+
+ in += 16;
+}
+
+
+#if 1
+ //wait for digest ready
+ while (! hashs->controlr.DGRY) {
+ // this will not take long
+ }
+#endif
+
+ *((u32 *) out + 0) = hashs->D1R;
+ *((u32 *) out + 1) = hashs->D2R;
+ *((u32 *) out + 2) = hashs->D3R;
+ *((u32 *) out + 3) = hashs->D4R;
+ *((u32 *) out + 4) = hashs->D5R;
+
+ memset(&sctx->buffer[0], 0, SHA1_HMAC_BLOCK_SIZE);
+ sctx->count = 0;
+
+ //printk("debug ln: %d, fn: %s\n", __LINE__, __func__);
+ CRTCL_SECT_END;
+
+
+ return 0;
+
+}
+
+/*
+ * \brief SHA1-HMAC function mappings
+*/
+static struct shash_alg ifxdeu_sha1_hmac_alg = {
+ .digestsize = SHA1_DIGEST_SIZE,
+ .init = sha1_hmac_init,
+ .update = sha1_hmac_update,
+ .final = sha1_hmac_final,
+ .setkey = sha1_hmac_setkey,
+ .descsize = sizeof(struct sha1_hmac_ctx),
+ .base = {
+ .cra_name = "hmac(sha1)",
+ .cra_driver_name= "ifxdeu-sha1_hmac",
+ .cra_ctxsize = sizeof(struct sha1_hmac_ctx),
+ .cra_flags = CRYPTO_ALG_TYPE_DIGEST,
+ .cra_blocksize = SHA1_HMAC_BLOCK_SIZE,
+ .cra_module = THIS_MODULE,
+ }
+
+};
+
+
+/*! \fn int __init ifxdeu_init_sha1_hmac (void)
+ * \ingroup IFX_SHA1_HMAC_FUNCTIONS
+ * \brief initialize sha1 hmac driver
+*/
+int __init ifxdeu_init_sha1_hmac (void)
+{
+ int ret = -ENOSYS;
+
+
+
+ if ((ret = crypto_register_shash(&ifxdeu_sha1_hmac_alg)))
+ goto sha1_err;
+
+ CRTCL_SECT_INIT;
+
+ printk (KERN_NOTICE "IFX DEU SHA1_HMAC initialized%s.\n", disable_deudma ? "" : " (DMA)");
+ return ret;
+
+sha1_err:
+ printk(KERN_ERR "IFX DEU SHA1_HMAC initialization failed!\n");
+ return ret;
+}
+
+/*! \fn void __exit ifxdeu_fini_sha1_hmac (void)
+ * \ingroup IFX_SHA1_HMAC_FUNCTIONS
+ * \brief unregister sha1 hmac driver
+*/
+void __exit ifxdeu_fini_sha1_hmac (void)
+{
+
+ crypto_unregister_shash(&ifxdeu_sha1_hmac_alg);
+
+
+}
+
diff --git a/package/platform/lantiq/ltq-deu/src/ifxmips_tcrypt.h b/package/platform/lantiq/ltq-deu/src/ifxmips_tcrypt.h
new file mode 100644
index 0000000..1e7047b
--- /dev/null
+++ b/package/platform/lantiq/ltq-deu/src/ifxmips_tcrypt.h
@@ -0,0 +1,92 @@
+/*
+ * Quick & dirty crypto testing module.
+ *
+ * This will only exist until we have a better testing mechanism
+ * (e.g. a char device).
+ *
+ * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
+ * Copyright (c) 2002 Jean-Francois Dive <jef@linuxbe.org>
+ * Copyright (c) 2007 Nokia Siemens Networks
+ *
+ * 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 of the License, or (at your option)
+ * any later version.
+ *
+ */
+#ifndef _IFXMIPS_CRYPTO_TCRYPT_H
+#define _IFXMIPS_CRYPTO_TCRYPT_H
+
+struct cipher_speed_template {
+ const char *key;
+ unsigned int klen;
+};
+
+struct hash_speed {
+ unsigned int blen; /* buffer length */
+ unsigned int plen; /* per-update length */
+};
+
+/*
+ * DES test vectors.
+ */
+#define DES3_SPEED_VECTORS 1
+#define CRYPTO_ALG_TYPE_SPEED_TEST 0xB
+
+static int alg_speed_test(const char *alg, const char *driver,
+ unsigned int sec,
+ struct cipher_speed_template *t,
+ unsigned int tcount, u8 *keysize);
+
+static struct cipher_speed_template des3_speed_template[] = {
+ {
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef"
+ "\x55\x55\x55\x55\x55\x55\x55\x55"
+ "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .klen = 24,
+ }
+};
+
+/*
+ * Cipher speed tests
+ */
+static u8 speed_template_8[] = {8, 0};
+static u8 speed_template_24[] = {24, 0};
+static u8 speed_template_8_32[] = {8, 32, 0};
+static u8 speed_template_16_32[] = {16, 32, 0};
+static u8 speed_template_16_24_32[] = {16, 24, 32, 0};
+static u8 speed_template_32_40_48[] = {32, 40, 48, 0};
+static u8 speed_template_32_48_64[] = {32, 48, 64, 0};
+
+/*
+ * Digest speed tests
+ */
+static struct hash_speed generic_hash_speed_template[] = {
+ { .blen = 16, .plen = 16, },
+ { .blen = 64, .plen = 16, },
+ { .blen = 64, .plen = 64, },
+ { .blen = 256, .plen = 16, },
+ { .blen = 256, .plen = 64, },
+ { .blen = 256, .plen = 256, },
+ { .blen = 1024, .plen = 16, },
+ { .blen = 1024, .plen = 256, },
+ { .blen = 1024, .plen = 1024, },
+ { .blen = 2048, .plen = 16, },
+ { .blen = 2048, .plen = 256, },
+ { .blen = 2048, .plen = 1024, },
+ { .blen = 2048, .plen = 2048, },
+ { .blen = 4096, .plen = 16, },
+ { .blen = 4096, .plen = 256, },
+ { .blen = 4096, .plen = 1024, },
+ { .blen = 4096, .plen = 4096, },
+ { .blen = 8192, .plen = 16, },
+ { .blen = 8192, .plen = 256, },
+ { .blen = 8192, .plen = 1024, },
+ { .blen = 8192, .plen = 4096, },
+ { .blen = 8192, .plen = 8192, },
+
+ /* End marker */
+ { .blen = 0, .plen = 0, }
+};
+
+#endif /* _CRYPTO_TCRYPT_H */
diff --git a/package/platform/lantiq/ltq-deu/src/ifxmips_testmgr.h b/package/platform/lantiq/ltq-deu/src/ifxmips_testmgr.h
new file mode 100644
index 0000000..27fe9a9
--- /dev/null
+++ b/package/platform/lantiq/ltq-deu/src/ifxmips_testmgr.h
@@ -0,0 +1,9598 @@
+/*
+ * Algorithm testing framework and tests.
+ *
+ * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
+ * Copyright (c) 2002 Jean-Francois Dive <jef@linuxbe.org>
+ * Copyright (c) 2007 Nokia Siemens Networks
+ * Copyright (c) 2008 Herbert Xu <herbert@gondor.apana.org.au>
+ *
+ * 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 of the License, or (at your option)
+ * any later version.
+ *
+ */
+#ifndef _IFXMIPS_CRYPTO_TESTMGR_H
+#define _IFXMIPS_CRYPTO_TESTMGR_H
+
+#include <linux/netlink.h>
+#include <linux/zlib.h>
+
+#include <crypto/compress.h>
+
+#define MAX_DIGEST_SIZE 64
+#define MAX_TAP 8
+
+#define MAX_KEYLEN 56
+#define MAX_IVLEN 32
+
+struct hash_testvec {
+ /* only used with keyed hash algorithms */
+ char *key;
+ char *plaintext;
+ char *digest;
+ unsigned char tap[MAX_TAP];
+ unsigned char psize;
+ unsigned char np;
+ unsigned char ksize;
+};
+
+struct cipher_testvec {
+ char *key;
+ char *iv;
+ char *input;
+ char *result;
+ unsigned short tap[MAX_TAP];
+ int np;
+ unsigned char fail;
+ unsigned char wk; /* weak key flag */
+ unsigned char klen;
+ unsigned short ilen;
+ unsigned short rlen;
+};
+
+struct aead_testvec {
+ char *key;
+ char *iv;
+ char *input;
+ char *assoc;
+ char *result;
+ unsigned char tap[MAX_TAP];
+ unsigned char atap[MAX_TAP];
+ int np;
+ int anp;
+ unsigned char fail;
+ unsigned char novrfy; /* ccm dec verification failure expected */
+ unsigned char wk; /* weak key flag */
+ unsigned char klen;
+ unsigned short ilen;
+ unsigned short alen;
+ unsigned short rlen;
+};
+
+struct cprng_testvec {
+ char *key;
+ char *dt;
+ char *v;
+ char *result;
+ unsigned char klen;
+ unsigned short dtlen;
+ unsigned short vlen;
+ unsigned short rlen;
+ unsigned short loops;
+};
+
+static char zeroed_string[48];
+
+/*
+ * MD4 test vectors from RFC1320
+ */
+#define MD4_TEST_VECTORS 7
+
+static struct hash_testvec md4_tv_template [] = {
+ {
+ .plaintext = "",
+ .digest = "\x31\xd6\xcf\xe0\xd1\x6a\xe9\x31"
+ "\xb7\x3c\x59\xd7\xe0\xc0\x89\xc0",
+ }, {
+ .plaintext = "a",
+ .psize = 1,
+ .digest = "\xbd\xe5\x2c\xb3\x1d\xe3\x3e\x46"
+ "\x24\x5e\x05\xfb\xdb\xd6\xfb\x24",
+ }, {
+ .plaintext = "abc",
+ .psize = 3,
+ .digest = "\xa4\x48\x01\x7a\xaf\x21\xd8\x52"
+ "\x5f\xc1\x0a\xe8\x7a\xa6\x72\x9d",
+ }, {
+ .plaintext = "message digest",
+ .psize = 14,
+ .digest = "\xd9\x13\x0a\x81\x64\x54\x9f\xe8"
+ "\x18\x87\x48\x06\xe1\xc7\x01\x4b",
+ }, {
+ .plaintext = "abcdefghijklmnopqrstuvwxyz",
+ .psize = 26,
+ .digest = "\xd7\x9e\x1c\x30\x8a\xa5\xbb\xcd"
+ "\xee\xa8\xed\x63\xdf\x41\x2d\xa9",
+ .np = 2,
+ .tap = { 13, 13 },
+ }, {
+ .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
+ .psize = 62,
+ .digest = "\x04\x3f\x85\x82\xf2\x41\xdb\x35"
+ "\x1c\xe6\x27\xe1\x53\xe7\xf0\xe4",
+ }, {
+ .plaintext = "123456789012345678901234567890123456789012345678901234567890123"
+ "45678901234567890",
+ .psize = 80,
+ .digest = "\xe3\x3b\x4d\xdc\x9c\x38\xf2\x19"
+ "\x9c\x3e\x7b\x16\x4f\xcc\x05\x36",
+ },
+};
+
+/*
+ * MD5 test vectors from RFC1321
+ */
+#define MD5_TEST_VECTORS 7
+
+static struct hash_testvec md5_tv_template[] = {
+ {
+ .digest = "\xd4\x1d\x8c\xd9\x8f\x00\xb2\x04"
+ "\xe9\x80\x09\x98\xec\xf8\x42\x7e",
+ }, {
+ .plaintext = "a",
+ .psize = 1,
+ .digest = "\x0c\xc1\x75\xb9\xc0\xf1\xb6\xa8"
+ "\x31\xc3\x99\xe2\x69\x77\x26\x61",
+ }, {
+ .plaintext = "abc",
+ .psize = 3,
+ .digest = "\x90\x01\x50\x98\x3c\xd2\x4f\xb0"
+ "\xd6\x96\x3f\x7d\x28\xe1\x7f\x72",
+ }, {
+ .plaintext = "message digest",
+ .psize = 14,
+ .digest = "\xf9\x6b\x69\x7d\x7c\xb7\x93\x8d"
+ "\x52\x5a\x2f\x31\xaa\xf1\x61\xd0",
+ }, {
+ .plaintext = "abcdefghijklmnopqrstuvwxyz",
+ .psize = 26,
+ .digest = "\xc3\xfc\xd3\xd7\x61\x92\xe4\x00"
+ "\x7d\xfb\x49\x6c\xca\x67\xe1\x3b",
+ .np = 2,
+ .tap = {13, 13}
+ }, {
+ .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
+ .psize = 62,
+ .digest = "\xd1\x74\xab\x98\xd2\x77\xd9\xf5"
+ "\xa5\x61\x1c\x2c\x9f\x41\x9d\x9f",
+ }, {
+ .plaintext = "12345678901234567890123456789012345678901234567890123456789012"
+ "345678901234567890",
+ .psize = 80,
+ .digest = "\x57\xed\xf4\xa2\x2b\xe3\xc9\x55"
+ "\xac\x49\xda\x2e\x21\x07\xb6\x7a",
+ }
+
+};
+
+/*
+ * RIPEMD-128 test vectors from ISO/IEC 10118-3:2004(E)
+ */
+#define RMD128_TEST_VECTORS 10
+
+static struct hash_testvec rmd128_tv_template[] = {
+ {
+ .digest = "\xcd\xf2\x62\x13\xa1\x50\xdc\x3e"
+ "\xcb\x61\x0f\x18\xf6\xb3\x8b\x46",
+ }, {
+ .plaintext = "a",
+ .psize = 1,
+ .digest = "\x86\xbe\x7a\xfa\x33\x9d\x0f\xc7"
+ "\xcf\xc7\x85\xe7\x2f\x57\x8d\x33",
+ }, {
+ .plaintext = "abc",
+ .psize = 3,
+ .digest = "\xc1\x4a\x12\x19\x9c\x66\xe4\xba"
+ "\x84\x63\x6b\x0f\x69\x14\x4c\x77",
+ }, {
+ .plaintext = "message digest",
+ .psize = 14,
+ .digest = "\x9e\x32\x7b\x3d\x6e\x52\x30\x62"
+ "\xaf\xc1\x13\x2d\x7d\xf9\xd1\xb8",
+ }, {
+ .plaintext = "abcdefghijklmnopqrstuvwxyz",
+ .psize = 26,
+ .digest = "\xfd\x2a\xa6\x07\xf7\x1d\xc8\xf5"
+ "\x10\x71\x49\x22\xb3\x71\x83\x4e",
+ }, {
+ .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcde"
+ "fghijklmnopqrstuvwxyz0123456789",
+ .psize = 62,
+ .digest = "\xd1\xe9\x59\xeb\x17\x9c\x91\x1f"
+ "\xae\xa4\x62\x4c\x60\xc5\xc7\x02",
+ }, {
+ .plaintext = "1234567890123456789012345678901234567890"
+ "1234567890123456789012345678901234567890",
+ .psize = 80,
+ .digest = "\x3f\x45\xef\x19\x47\x32\xc2\xdb"
+ "\xb2\xc4\xa2\xc7\x69\x79\x5f\xa3",
+ }, {
+ .plaintext = "abcdbcdecdefdefgefghfghighij"
+ "hijkijkljklmklmnlmnomnopnopq",
+ .psize = 56,
+ .digest = "\xa1\xaa\x06\x89\xd0\xfa\xfa\x2d"
+ "\xdc\x22\xe8\x8b\x49\x13\x3a\x06",
+ .np = 2,
+ .tap = { 28, 28 },
+ }, {
+ .plaintext = "abcdefghbcdefghicdefghijdefghijkefghijklfghi"
+ "jklmghijklmnhijklmnoijklmnopjklmnopqklmnopqr"
+ "lmnopqrsmnopqrstnopqrstu",
+ .psize = 112,
+ .digest = "\xd4\xec\xc9\x13\xe1\xdf\x77\x6b"
+ "\xf4\x8d\xe9\xd5\x5b\x1f\x25\x46",
+ }, {
+ .plaintext = "abcdbcdecdefdefgefghfghighijhijk",
+ .psize = 32,
+ .digest = "\x13\xfc\x13\xe8\xef\xff\x34\x7d"
+ "\xe1\x93\xff\x46\xdb\xac\xcf\xd4",
+ }
+};
+
+/*
+ * RIPEMD-160 test vectors from ISO/IEC 10118-3:2004(E)
+ */
+#define RMD160_TEST_VECTORS 10
+
+static struct hash_testvec rmd160_tv_template[] = {
+ {
+ .digest = "\x9c\x11\x85\xa5\xc5\xe9\xfc\x54\x61\x28"
+ "\x08\x97\x7e\xe8\xf5\x48\xb2\x25\x8d\x31",
+ }, {
+ .plaintext = "a",
+ .psize = 1,
+ .digest = "\x0b\xdc\x9d\x2d\x25\x6b\x3e\xe9\xda\xae"
+ "\x34\x7b\xe6\xf4\xdc\x83\x5a\x46\x7f\xfe",
+ }, {
+ .plaintext = "abc",
+ .psize = 3,
+ .digest = "\x8e\xb2\x08\xf7\xe0\x5d\x98\x7a\x9b\x04"
+ "\x4a\x8e\x98\xc6\xb0\x87\xf1\x5a\x0b\xfc",
+ }, {
+ .plaintext = "message digest",
+ .psize = 14,
+ .digest = "\x5d\x06\x89\xef\x49\xd2\xfa\xe5\x72\xb8"
+ "\x81\xb1\x23\xa8\x5f\xfa\x21\x59\x5f\x36",
+ }, {
+ .plaintext = "abcdefghijklmnopqrstuvwxyz",
+ .psize = 26,
+ .digest = "\xf7\x1c\x27\x10\x9c\x69\x2c\x1b\x56\xbb"
+ "\xdc\xeb\x5b\x9d\x28\x65\xb3\x70\x8d\xbc",
+ }, {
+ .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcde"
+ "fghijklmnopqrstuvwxyz0123456789",
+ .psize = 62,
+ .digest = "\xb0\xe2\x0b\x6e\x31\x16\x64\x02\x86\xed"
+ "\x3a\x87\xa5\x71\x30\x79\xb2\x1f\x51\x89",
+ }, {
+ .plaintext = "1234567890123456789012345678901234567890"
+ "1234567890123456789012345678901234567890",
+ .psize = 80,
+ .digest = "\x9b\x75\x2e\x45\x57\x3d\x4b\x39\xf4\xdb"
+ "\xd3\x32\x3c\xab\x82\xbf\x63\x32\x6b\xfb",
+ }, {
+ .plaintext = "abcdbcdecdefdefgefghfghighij"
+ "hijkijkljklmklmnlmnomnopnopq",
+ .psize = 56,
+ .digest = "\x12\xa0\x53\x38\x4a\x9c\x0c\x88\xe4\x05"
+ "\xa0\x6c\x27\xdc\xf4\x9a\xda\x62\xeb\x2b",
+ .np = 2,
+ .tap = { 28, 28 },
+ }, {
+ .plaintext = "abcdefghbcdefghicdefghijdefghijkefghijklfghi"
+ "jklmghijklmnhijklmnoijklmnopjklmnopqklmnopqr"
+ "lmnopqrsmnopqrstnopqrstu",
+ .psize = 112,
+ .digest = "\x6f\x3f\xa3\x9b\x6b\x50\x3c\x38\x4f\x91"
+ "\x9a\x49\xa7\xaa\x5c\x2c\x08\xbd\xfb\x45",
+ }, {
+ .plaintext = "abcdbcdecdefdefgefghfghighijhijk",
+ .psize = 32,
+ .digest = "\x94\xc2\x64\x11\x54\x04\xe6\x33\x79\x0d"
+ "\xfc\xc8\x7b\x58\x7d\x36\x77\x06\x7d\x9f",
+ }
+};
+
+/*
+ * RIPEMD-256 test vectors
+ */
+#define RMD256_TEST_VECTORS 8
+
+static struct hash_testvec rmd256_tv_template[] = {
+ {
+ .digest = "\x02\xba\x4c\x4e\x5f\x8e\xcd\x18"
+ "\x77\xfc\x52\xd6\x4d\x30\xe3\x7a"
+ "\x2d\x97\x74\xfb\x1e\x5d\x02\x63"
+ "\x80\xae\x01\x68\xe3\xc5\x52\x2d",
+ }, {
+ .plaintext = "a",
+ .psize = 1,
+ .digest = "\xf9\x33\x3e\x45\xd8\x57\xf5\xd9"
+ "\x0a\x91\xba\xb7\x0a\x1e\xba\x0c"
+ "\xfb\x1b\xe4\xb0\x78\x3c\x9a\xcf"
+ "\xcd\x88\x3a\x91\x34\x69\x29\x25",
+ }, {
+ .plaintext = "abc",
+ .psize = 3,
+ .digest = "\xaf\xbd\x6e\x22\x8b\x9d\x8c\xbb"
+ "\xce\xf5\xca\x2d\x03\xe6\xdb\xa1"
+ "\x0a\xc0\xbc\x7d\xcb\xe4\x68\x0e"
+ "\x1e\x42\xd2\xe9\x75\x45\x9b\x65",
+ }, {
+ .plaintext = "message digest",
+ .psize = 14,
+ .digest = "\x87\xe9\x71\x75\x9a\x1c\xe4\x7a"
+ "\x51\x4d\x5c\x91\x4c\x39\x2c\x90"
+ "\x18\xc7\xc4\x6b\xc1\x44\x65\x55"
+ "\x4a\xfc\xdf\x54\xa5\x07\x0c\x0e",
+ }, {
+ .plaintext = "abcdefghijklmnopqrstuvwxyz",
+ .psize = 26,
+ .digest = "\x64\x9d\x30\x34\x75\x1e\xa2\x16"
+ "\x77\x6b\xf9\xa1\x8a\xcc\x81\xbc"
+ "\x78\x96\x11\x8a\x51\x97\x96\x87"
+ "\x82\xdd\x1f\xd9\x7d\x8d\x51\x33",
+ }, {
+ .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcde"
+ "fghijklmnopqrstuvwxyz0123456789",
+ .psize = 62,
+ .digest = "\x57\x40\xa4\x08\xac\x16\xb7\x20"
+ "\xb8\x44\x24\xae\x93\x1c\xbb\x1f"
+ "\xe3\x63\xd1\xd0\xbf\x40\x17\xf1"
+ "\xa8\x9f\x7e\xa6\xde\x77\xa0\xb8",
+ }, {
+ .plaintext = "1234567890123456789012345678901234567890"
+ "1234567890123456789012345678901234567890",
+ .psize = 80,
+ .digest = "\x06\xfd\xcc\x7a\x40\x95\x48\xaa"
+ "\xf9\x13\x68\xc0\x6a\x62\x75\xb5"
+ "\x53\xe3\xf0\x99\xbf\x0e\xa4\xed"
+ "\xfd\x67\x78\xdf\x89\xa8\x90\xdd",
+ }, {
+ .plaintext = "abcdbcdecdefdefgefghfghighij"
+ "hijkijkljklmklmnlmnomnopnopq",
+ .psize = 56,
+ .digest = "\x38\x43\x04\x55\x83\xaa\xc6\xc8"
+ "\xc8\xd9\x12\x85\x73\xe7\xa9\x80"
+ "\x9a\xfb\x2a\x0f\x34\xcc\xc3\x6e"
+ "\xa9\xe7\x2f\x16\xf6\x36\x8e\x3f",
+ .np = 2,
+ .tap = { 28, 28 },
+ }
+};
+
+/*
+ * RIPEMD-320 test vectors
+ */
+#define RMD320_TEST_VECTORS 8
+
+static struct hash_testvec rmd320_tv_template[] = {
+ {
+ .digest = "\x22\xd6\x5d\x56\x61\x53\x6c\xdc\x75\xc1"
+ "\xfd\xf5\xc6\xde\x7b\x41\xb9\xf2\x73\x25"
+ "\xeb\xc6\x1e\x85\x57\x17\x7d\x70\x5a\x0e"
+ "\xc8\x80\x15\x1c\x3a\x32\xa0\x08\x99\xb8",
+ }, {
+ .plaintext = "a",
+ .psize = 1,
+ .digest = "\xce\x78\x85\x06\x38\xf9\x26\x58\xa5\xa5"
+ "\x85\x09\x75\x79\x92\x6d\xda\x66\x7a\x57"
+ "\x16\x56\x2c\xfc\xf6\xfb\xe7\x7f\x63\x54"
+ "\x2f\x99\xb0\x47\x05\xd6\x97\x0d\xff\x5d",
+ }, {
+ .plaintext = "abc",
+ .psize = 3,
+ .digest = "\xde\x4c\x01\xb3\x05\x4f\x89\x30\xa7\x9d"
+ "\x09\xae\x73\x8e\x92\x30\x1e\x5a\x17\x08"
+ "\x5b\xef\xfd\xc1\xb8\xd1\x16\x71\x3e\x74"
+ "\xf8\x2f\xa9\x42\xd6\x4c\xdb\xc4\x68\x2d",
+ }, {
+ .plaintext = "message digest",
+ .psize = 14,
+ .digest = "\x3a\x8e\x28\x50\x2e\xd4\x5d\x42\x2f\x68"
+ "\x84\x4f\x9d\xd3\x16\xe7\xb9\x85\x33\xfa"
+ "\x3f\x2a\x91\xd2\x9f\x84\xd4\x25\xc8\x8d"
+ "\x6b\x4e\xff\x72\x7d\xf6\x6a\x7c\x01\x97",
+ }, {
+ .plaintext = "abcdefghijklmnopqrstuvwxyz",
+ .psize = 26,
+ .digest = "\xca\xbd\xb1\x81\x0b\x92\x47\x0a\x20\x93"
+ "\xaa\x6b\xce\x05\x95\x2c\x28\x34\x8c\xf4"
+ "\x3f\xf6\x08\x41\x97\x51\x66\xbb\x40\xed"
+ "\x23\x40\x04\xb8\x82\x44\x63\xe6\xb0\x09",
+ }, {
+ .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcde"
+ "fghijklmnopqrstuvwxyz0123456789",
+ .psize = 62,
+ .digest = "\xed\x54\x49\x40\xc8\x6d\x67\xf2\x50\xd2"
+ "\x32\xc3\x0b\x7b\x3e\x57\x70\xe0\xc6\x0c"
+ "\x8c\xb9\xa4\xca\xfe\x3b\x11\x38\x8a\xf9"
+ "\x92\x0e\x1b\x99\x23\x0b\x84\x3c\x86\xa4",
+ }, {
+ .plaintext = "1234567890123456789012345678901234567890"
+ "1234567890123456789012345678901234567890",
+ .psize = 80,
+ .digest = "\x55\x78\x88\xaf\x5f\x6d\x8e\xd6\x2a\xb6"
+ "\x69\x45\xc6\xd2\xa0\xa4\x7e\xcd\x53\x41"
+ "\xe9\x15\xeb\x8f\xea\x1d\x05\x24\x95\x5f"
+ "\x82\x5d\xc7\x17\xe4\xa0\x08\xab\x2d\x42",
+ }, {
+ .plaintext = "abcdbcdecdefdefgefghfghighij"
+ "hijkijkljklmklmnlmnomnopnopq",
+ .psize = 56,
+ .digest = "\xd0\x34\xa7\x95\x0c\xf7\x22\x02\x1b\xa4"
+ "\xb8\x4d\xf7\x69\xa5\xde\x20\x60\xe2\x59"
+ "\xdf\x4c\x9b\xb4\xa4\x26\x8c\x0e\x93\x5b"
+ "\xbc\x74\x70\xa9\x69\xc9\xd0\x72\xa1\xac",
+ .np = 2,
+ .tap = { 28, 28 },
+ }
+};
+
+/*
+ * SHA1 test vectors from from FIPS PUB 180-1
+ */
+#define SHA1_TEST_VECTORS 2
+
+static struct hash_testvec sha1_tv_template[] = {
+ {
+ .plaintext = "abc",
+ .psize = 3,
+ .digest = "\xa9\x99\x3e\x36\x47\x06\x81\x6a\xba\x3e"
+ "\x25\x71\x78\x50\xc2\x6c\x9c\xd0\xd8\x9d",
+ }, {
+ .plaintext = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
+ .psize = 56,
+ .digest = "\x84\x98\x3e\x44\x1c\x3b\xd2\x6e\xba\xae"
+ "\x4a\xa1\xf9\x51\x29\xe5\xe5\x46\x70\xf1",
+ .np = 2,
+ .tap = { 28, 28 }
+ }
+};
+
+
+/*
+ * SHA224 test vectors from from FIPS PUB 180-2
+ */
+#define SHA224_TEST_VECTORS 2
+
+static struct hash_testvec sha224_tv_template[] = {
+ {
+ .plaintext = "abc",
+ .psize = 3,
+ .digest = "\x23\x09\x7D\x22\x34\x05\xD8\x22"
+ "\x86\x42\xA4\x77\xBD\xA2\x55\xB3"
+ "\x2A\xAD\xBC\xE4\xBD\xA0\xB3\xF7"
+ "\xE3\x6C\x9D\xA7",
+ }, {
+ .plaintext =
+ "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
+ .psize = 56,
+ .digest = "\x75\x38\x8B\x16\x51\x27\x76\xCC"
+ "\x5D\xBA\x5D\xA1\xFD\x89\x01\x50"
+ "\xB0\xC6\x45\x5C\xB4\xF5\x8B\x19"
+ "\x52\x52\x25\x25",
+ .np = 2,
+ .tap = { 28, 28 }
+ }
+};
+
+/*
+ * SHA256 test vectors from from NIST
+ */
+#define SHA256_TEST_VECTORS 2
+
+static struct hash_testvec sha256_tv_template[] = {
+ {
+ .plaintext = "abc",
+ .psize = 3,
+ .digest = "\xba\x78\x16\xbf\x8f\x01\xcf\xea"
+ "\x41\x41\x40\xde\x5d\xae\x22\x23"
+ "\xb0\x03\x61\xa3\x96\x17\x7a\x9c"
+ "\xb4\x10\xff\x61\xf2\x00\x15\xad",
+ }, {
+ .plaintext = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
+ .psize = 56,
+ .digest = "\x24\x8d\x6a\x61\xd2\x06\x38\xb8"
+ "\xe5\xc0\x26\x93\x0c\x3e\x60\x39"
+ "\xa3\x3c\xe4\x59\x64\xff\x21\x67"
+ "\xf6\xec\xed\xd4\x19\xdb\x06\xc1",
+ .np = 2,
+ .tap = { 28, 28 }
+ },
+};
+
+/*
+ * SHA384 test vectors from from NIST and kerneli
+ */
+#define SHA384_TEST_VECTORS 4
+
+static struct hash_testvec sha384_tv_template[] = {
+ {
+ .plaintext= "abc",
+ .psize = 3,
+ .digest = "\xcb\x00\x75\x3f\x45\xa3\x5e\x8b"
+ "\xb5\xa0\x3d\x69\x9a\xc6\x50\x07"
+ "\x27\x2c\x32\xab\x0e\xde\xd1\x63"
+ "\x1a\x8b\x60\x5a\x43\xff\x5b\xed"
+ "\x80\x86\x07\x2b\xa1\xe7\xcc\x23"
+ "\x58\xba\xec\xa1\x34\xc8\x25\xa7",
+ }, {
+ .plaintext = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
+ .psize = 56,
+ .digest = "\x33\x91\xfd\xdd\xfc\x8d\xc7\x39"
+ "\x37\x07\xa6\x5b\x1b\x47\x09\x39"
+ "\x7c\xf8\xb1\xd1\x62\xaf\x05\xab"
+ "\xfe\x8f\x45\x0d\xe5\xf3\x6b\xc6"
+ "\xb0\x45\x5a\x85\x20\xbc\x4e\x6f"
+ "\x5f\xe9\x5b\x1f\xe3\xc8\x45\x2b",
+ }, {
+ .plaintext = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn"
+ "hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu",
+ .psize = 112,
+ .digest = "\x09\x33\x0c\x33\xf7\x11\x47\xe8"
+ "\x3d\x19\x2f\xc7\x82\xcd\x1b\x47"
+ "\x53\x11\x1b\x17\x3b\x3b\x05\xd2"
+ "\x2f\xa0\x80\x86\xe3\xb0\xf7\x12"
+ "\xfc\xc7\xc7\x1a\x55\x7e\x2d\xb9"
+ "\x66\xc3\xe9\xfa\x91\x74\x60\x39",
+ }, {
+ .plaintext = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd"
+ "efghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz",
+ .psize = 104,
+ .digest = "\x3d\x20\x89\x73\xab\x35\x08\xdb"
+ "\xbd\x7e\x2c\x28\x62\xba\x29\x0a"
+ "\xd3\x01\x0e\x49\x78\xc1\x98\xdc"
+ "\x4d\x8f\xd0\x14\xe5\x82\x82\x3a"
+ "\x89\xe1\x6f\x9b\x2a\x7b\xbc\x1a"
+ "\xc9\x38\xe2\xd1\x99\xe8\xbe\xa4",
+ .np = 4,
+ .tap = { 26, 26, 26, 26 }
+ },
+};
+
+/*
+ * SHA512 test vectors from from NIST and kerneli
+ */
+#define SHA512_TEST_VECTORS 4
+
+static struct hash_testvec sha512_tv_template[] = {
+ {
+ .plaintext = "abc",
+ .psize = 3,
+ .digest = "\xdd\xaf\x35\xa1\x93\x61\x7a\xba"
+ "\xcc\x41\x73\x49\xae\x20\x41\x31"
+ "\x12\xe6\xfa\x4e\x89\xa9\x7e\xa2"
+ "\x0a\x9e\xee\xe6\x4b\x55\xd3\x9a"
+ "\x21\x92\x99\x2a\x27\x4f\xc1\xa8"
+ "\x36\xba\x3c\x23\xa3\xfe\xeb\xbd"
+ "\x45\x4d\x44\x23\x64\x3c\xe8\x0e"
+ "\x2a\x9a\xc9\x4f\xa5\x4c\xa4\x9f",
+ }, {
+ .plaintext = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
+ .psize = 56,
+ .digest = "\x20\x4a\x8f\xc6\xdd\xa8\x2f\x0a"
+ "\x0c\xed\x7b\xeb\x8e\x08\xa4\x16"
+ "\x57\xc1\x6e\xf4\x68\xb2\x28\xa8"
+ "\x27\x9b\xe3\x31\xa7\x03\xc3\x35"
+ "\x96\xfd\x15\xc1\x3b\x1b\x07\xf9"
+ "\xaa\x1d\x3b\xea\x57\x78\x9c\xa0"
+ "\x31\xad\x85\xc7\xa7\x1d\xd7\x03"
+ "\x54\xec\x63\x12\x38\xca\x34\x45",
+ }, {
+ .plaintext = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn"
+ "hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu",
+ .psize = 112,
+ .digest = "\x8e\x95\x9b\x75\xda\xe3\x13\xda"
+ "\x8c\xf4\xf7\x28\x14\xfc\x14\x3f"
+ "\x8f\x77\x79\xc6\xeb\x9f\x7f\xa1"
+ "\x72\x99\xae\xad\xb6\x88\x90\x18"
+ "\x50\x1d\x28\x9e\x49\x00\xf7\xe4"
+ "\x33\x1b\x99\xde\xc4\xb5\x43\x3a"
+ "\xc7\xd3\x29\xee\xb6\xdd\x26\x54"
+ "\x5e\x96\xe5\x5b\x87\x4b\xe9\x09",
+ }, {
+ .plaintext = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd"
+ "efghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz",
+ .psize = 104,
+ .digest = "\x93\x0d\x0c\xef\xcb\x30\xff\x11"
+ "\x33\xb6\x89\x81\x21\xf1\xcf\x3d"
+ "\x27\x57\x8a\xfc\xaf\xe8\x67\x7c"
+ "\x52\x57\xcf\x06\x99\x11\xf7\x5d"
+ "\x8f\x58\x31\xb5\x6e\xbf\xda\x67"
+ "\xb2\x78\xe6\x6d\xff\x8b\x84\xfe"
+ "\x2b\x28\x70\xf7\x42\xa5\x80\xd8"
+ "\xed\xb4\x19\x87\x23\x28\x50\xc9",
+ .np = 4,
+ .tap = { 26, 26, 26, 26 }
+ },
+};
+
+
+/*
+ * WHIRLPOOL test vectors from Whirlpool package
+ * by Vincent Rijmen and Paulo S. L. M. Barreto as part of the NESSIE
+ * submission
+ */
+#define WP512_TEST_VECTORS 8
+
+static struct hash_testvec wp512_tv_template[] = {
+ {
+ .plaintext = "",
+ .psize = 0,
+ .digest = "\x19\xFA\x61\xD7\x55\x22\xA4\x66"
+ "\x9B\x44\xE3\x9C\x1D\x2E\x17\x26"
+ "\xC5\x30\x23\x21\x30\xD4\x07\xF8"
+ "\x9A\xFE\xE0\x96\x49\x97\xF7\xA7"
+ "\x3E\x83\xBE\x69\x8B\x28\x8F\xEB"
+ "\xCF\x88\xE3\xE0\x3C\x4F\x07\x57"
+ "\xEA\x89\x64\xE5\x9B\x63\xD9\x37"
+ "\x08\xB1\x38\xCC\x42\xA6\x6E\xB3",
+
+
+ }, {
+ .plaintext = "a",
+ .psize = 1,
+ .digest = "\x8A\xCA\x26\x02\x79\x2A\xEC\x6F"
+ "\x11\xA6\x72\x06\x53\x1F\xB7\xD7"
+ "\xF0\xDF\xF5\x94\x13\x14\x5E\x69"
+ "\x73\xC4\x50\x01\xD0\x08\x7B\x42"
+ "\xD1\x1B\xC6\x45\x41\x3A\xEF\xF6"
+ "\x3A\x42\x39\x1A\x39\x14\x5A\x59"
+ "\x1A\x92\x20\x0D\x56\x01\x95\xE5"
+ "\x3B\x47\x85\x84\xFD\xAE\x23\x1A",
+ }, {
+ .plaintext = "abc",
+ .psize = 3,
+ .digest = "\x4E\x24\x48\xA4\xC6\xF4\x86\xBB"
+ "\x16\xB6\x56\x2C\x73\xB4\x02\x0B"
+ "\xF3\x04\x3E\x3A\x73\x1B\xCE\x72"
+ "\x1A\xE1\xB3\x03\xD9\x7E\x6D\x4C"
+ "\x71\x81\xEE\xBD\xB6\xC5\x7E\x27"
+ "\x7D\x0E\x34\x95\x71\x14\xCB\xD6"
+ "\xC7\x97\xFC\x9D\x95\xD8\xB5\x82"
+ "\xD2\x25\x29\x20\x76\xD4\xEE\xF5",
+ }, {
+ .plaintext = "message digest",
+ .psize = 14,
+ .digest = "\x37\x8C\x84\xA4\x12\x6E\x2D\xC6"
+ "\xE5\x6D\xCC\x74\x58\x37\x7A\xAC"
+ "\x83\x8D\x00\x03\x22\x30\xF5\x3C"
+ "\xE1\xF5\x70\x0C\x0F\xFB\x4D\x3B"
+ "\x84\x21\x55\x76\x59\xEF\x55\xC1"
+ "\x06\xB4\xB5\x2A\xC5\xA4\xAA\xA6"
+ "\x92\xED\x92\x00\x52\x83\x8F\x33"
+ "\x62\xE8\x6D\xBD\x37\xA8\x90\x3E",
+ }, {
+ .plaintext = "abcdefghijklmnopqrstuvwxyz",
+ .psize = 26,
+ .digest = "\xF1\xD7\x54\x66\x26\x36\xFF\xE9"
+ "\x2C\x82\xEB\xB9\x21\x2A\x48\x4A"
+ "\x8D\x38\x63\x1E\xAD\x42\x38\xF5"
+ "\x44\x2E\xE1\x3B\x80\x54\xE4\x1B"
+ "\x08\xBF\x2A\x92\x51\xC3\x0B\x6A"
+ "\x0B\x8A\xAE\x86\x17\x7A\xB4\xA6"
+ "\xF6\x8F\x67\x3E\x72\x07\x86\x5D"
+ "\x5D\x98\x19\xA3\xDB\xA4\xEB\x3B",
+ }, {
+ .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "abcdefghijklmnopqrstuvwxyz0123456789",
+ .psize = 62,
+ .digest = "\xDC\x37\xE0\x08\xCF\x9E\xE6\x9B"
+ "\xF1\x1F\x00\xED\x9A\xBA\x26\x90"
+ "\x1D\xD7\xC2\x8C\xDE\xC0\x66\xCC"
+ "\x6A\xF4\x2E\x40\xF8\x2F\x3A\x1E"
+ "\x08\xEB\xA2\x66\x29\x12\x9D\x8F"
+ "\xB7\xCB\x57\x21\x1B\x92\x81\xA6"
+ "\x55\x17\xCC\x87\x9D\x7B\x96\x21"
+ "\x42\xC6\x5F\x5A\x7A\xF0\x14\x67",
+ }, {
+ .plaintext = "1234567890123456789012345678901234567890"
+ "1234567890123456789012345678901234567890",
+ .psize = 80,
+ .digest = "\x46\x6E\xF1\x8B\xAB\xB0\x15\x4D"
+ "\x25\xB9\xD3\x8A\x64\x14\xF5\xC0"
+ "\x87\x84\x37\x2B\xCC\xB2\x04\xD6"
+ "\x54\x9C\x4A\xFA\xDB\x60\x14\x29"
+ "\x4D\x5B\xD8\xDF\x2A\x6C\x44\xE5"
+ "\x38\xCD\x04\x7B\x26\x81\xA5\x1A"
+ "\x2C\x60\x48\x1E\x88\xC5\xA2\x0B"
+ "\x2C\x2A\x80\xCF\x3A\x9A\x08\x3B",
+ }, {
+ .plaintext = "abcdbcdecdefdefgefghfghighijhijk",
+ .psize = 32,
+ .digest = "\x2A\x98\x7E\xA4\x0F\x91\x70\x61"
+ "\xF5\xD6\xF0\xA0\xE4\x64\x4F\x48"
+ "\x8A\x7A\x5A\x52\xDE\xEE\x65\x62"
+ "\x07\xC5\x62\xF9\x88\xE9\x5C\x69"
+ "\x16\xBD\xC8\x03\x1B\xC5\xBE\x1B"
+ "\x7B\x94\x76\x39\xFE\x05\x0B\x56"
+ "\x93\x9B\xAA\xA0\xAD\xFF\x9A\xE6"
+ "\x74\x5B\x7B\x18\x1C\x3B\xE3\xFD",
+ },
+};
+
+#define WP384_TEST_VECTORS 8
+
+static struct hash_testvec wp384_tv_template[] = {
+ {
+ .plaintext = "",
+ .psize = 0,
+ .digest = "\x19\xFA\x61\xD7\x55\x22\xA4\x66"
+ "\x9B\x44\xE3\x9C\x1D\x2E\x17\x26"
+ "\xC5\x30\x23\x21\x30\xD4\x07\xF8"
+ "\x9A\xFE\xE0\x96\x49\x97\xF7\xA7"
+ "\x3E\x83\xBE\x69\x8B\x28\x8F\xEB"
+ "\xCF\x88\xE3\xE0\x3C\x4F\x07\x57",
+
+
+ }, {
+ .plaintext = "a",
+ .psize = 1,
+ .digest = "\x8A\xCA\x26\x02\x79\x2A\xEC\x6F"
+ "\x11\xA6\x72\x06\x53\x1F\xB7\xD7"
+ "\xF0\xDF\xF5\x94\x13\x14\x5E\x69"
+ "\x73\xC4\x50\x01\xD0\x08\x7B\x42"
+ "\xD1\x1B\xC6\x45\x41\x3A\xEF\xF6"
+ "\x3A\x42\x39\x1A\x39\x14\x5A\x59",
+ }, {
+ .plaintext = "abc",
+ .psize = 3,
+ .digest = "\x4E\x24\x48\xA4\xC6\xF4\x86\xBB"
+ "\x16\xB6\x56\x2C\x73\xB4\x02\x0B"
+ "\xF3\x04\x3E\x3A\x73\x1B\xCE\x72"
+ "\x1A\xE1\xB3\x03\xD9\x7E\x6D\x4C"
+ "\x71\x81\xEE\xBD\xB6\xC5\x7E\x27"
+ "\x7D\x0E\x34\x95\x71\x14\xCB\xD6",
+ }, {
+ .plaintext = "message digest",
+ .psize = 14,
+ .digest = "\x37\x8C\x84\xA4\x12\x6E\x2D\xC6"
+ "\xE5\x6D\xCC\x74\x58\x37\x7A\xAC"
+ "\x83\x8D\x00\x03\x22\x30\xF5\x3C"
+ "\xE1\xF5\x70\x0C\x0F\xFB\x4D\x3B"
+ "\x84\x21\x55\x76\x59\xEF\x55\xC1"
+ "\x06\xB4\xB5\x2A\xC5\xA4\xAA\xA6",
+ }, {
+ .plaintext = "abcdefghijklmnopqrstuvwxyz",
+ .psize = 26,
+ .digest = "\xF1\xD7\x54\x66\x26\x36\xFF\xE9"
+ "\x2C\x82\xEB\xB9\x21\x2A\x48\x4A"
+ "\x8D\x38\x63\x1E\xAD\x42\x38\xF5"
+ "\x44\x2E\xE1\x3B\x80\x54\xE4\x1B"
+ "\x08\xBF\x2A\x92\x51\xC3\x0B\x6A"
+ "\x0B\x8A\xAE\x86\x17\x7A\xB4\xA6",
+ }, {
+ .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "abcdefghijklmnopqrstuvwxyz0123456789",
+ .psize = 62,
+ .digest = "\xDC\x37\xE0\x08\xCF\x9E\xE6\x9B"
+ "\xF1\x1F\x00\xED\x9A\xBA\x26\x90"
+ "\x1D\xD7\xC2\x8C\xDE\xC0\x66\xCC"
+ "\x6A\xF4\x2E\x40\xF8\x2F\x3A\x1E"
+ "\x08\xEB\xA2\x66\x29\x12\x9D\x8F"
+ "\xB7\xCB\x57\x21\x1B\x92\x81\xA6",
+ }, {
+ .plaintext = "1234567890123456789012345678901234567890"
+ "1234567890123456789012345678901234567890",
+ .psize = 80,
+ .digest = "\x46\x6E\xF1\x8B\xAB\xB0\x15\x4D"
+ "\x25\xB9\xD3\x8A\x64\x14\xF5\xC0"
+ "\x87\x84\x37\x2B\xCC\xB2\x04\xD6"
+ "\x54\x9C\x4A\xFA\xDB\x60\x14\x29"
+ "\x4D\x5B\xD8\xDF\x2A\x6C\x44\xE5"
+ "\x38\xCD\x04\x7B\x26\x81\xA5\x1A",
+ }, {
+ .plaintext = "abcdbcdecdefdefgefghfghighijhijk",
+ .psize = 32,
+ .digest = "\x2A\x98\x7E\xA4\x0F\x91\x70\x61"
+ "\xF5\xD6\xF0\xA0\xE4\x64\x4F\x48"
+ "\x8A\x7A\x5A\x52\xDE\xEE\x65\x62"
+ "\x07\xC5\x62\xF9\x88\xE9\x5C\x69"
+ "\x16\xBD\xC8\x03\x1B\xC5\xBE\x1B"
+ "\x7B\x94\x76\x39\xFE\x05\x0B\x56",
+ },
+};
+
+#define WP256_TEST_VECTORS 8
+
+static struct hash_testvec wp256_tv_template[] = {
+ {
+ .plaintext = "",
+ .psize = 0,
+ .digest = "\x19\xFA\x61\xD7\x55\x22\xA4\x66"
+ "\x9B\x44\xE3\x9C\x1D\x2E\x17\x26"
+ "\xC5\x30\x23\x21\x30\xD4\x07\xF8"
+ "\x9A\xFE\xE0\x96\x49\x97\xF7\xA7",
+
+
+ }, {
+ .plaintext = "a",
+ .psize = 1,
+ .digest = "\x8A\xCA\x26\x02\x79\x2A\xEC\x6F"
+ "\x11\xA6\x72\x06\x53\x1F\xB7\xD7"
+ "\xF0\xDF\xF5\x94\x13\x14\x5E\x69"
+ "\x73\xC4\x50\x01\xD0\x08\x7B\x42",
+ }, {
+ .plaintext = "abc",
+ .psize = 3,
+ .digest = "\x4E\x24\x48\xA4\xC6\xF4\x86\xBB"
+ "\x16\xB6\x56\x2C\x73\xB4\x02\x0B"
+ "\xF3\x04\x3E\x3A\x73\x1B\xCE\x72"
+ "\x1A\xE1\xB3\x03\xD9\x7E\x6D\x4C",
+ }, {
+ .plaintext = "message digest",
+ .psize = 14,
+ .digest = "\x37\x8C\x84\xA4\x12\x6E\x2D\xC6"
+ "\xE5\x6D\xCC\x74\x58\x37\x7A\xAC"
+ "\x83\x8D\x00\x03\x22\x30\xF5\x3C"
+ "\xE1\xF5\x70\x0C\x0F\xFB\x4D\x3B",
+ }, {
+ .plaintext = "abcdefghijklmnopqrstuvwxyz",
+ .psize = 26,
+ .digest = "\xF1\xD7\x54\x66\x26\x36\xFF\xE9"
+ "\x2C\x82\xEB\xB9\x21\x2A\x48\x4A"
+ "\x8D\x38\x63\x1E\xAD\x42\x38\xF5"
+ "\x44\x2E\xE1\x3B\x80\x54\xE4\x1B",
+ }, {
+ .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "abcdefghijklmnopqrstuvwxyz0123456789",
+ .psize = 62,
+ .digest = "\xDC\x37\xE0\x08\xCF\x9E\xE6\x9B"
+ "\xF1\x1F\x00\xED\x9A\xBA\x26\x90"
+ "\x1D\xD7\xC2\x8C\xDE\xC0\x66\xCC"
+ "\x6A\xF4\x2E\x40\xF8\x2F\x3A\x1E",
+ }, {
+ .plaintext = "1234567890123456789012345678901234567890"
+ "1234567890123456789012345678901234567890",
+ .psize = 80,
+ .digest = "\x46\x6E\xF1\x8B\xAB\xB0\x15\x4D"
+ "\x25\xB9\xD3\x8A\x64\x14\xF5\xC0"
+ "\x87\x84\x37\x2B\xCC\xB2\x04\xD6"
+ "\x54\x9C\x4A\xFA\xDB\x60\x14\x29",
+ }, {
+ .plaintext = "abcdbcdecdefdefgefghfghighijhijk",
+ .psize = 32,
+ .digest = "\x2A\x98\x7E\xA4\x0F\x91\x70\x61"
+ "\xF5\xD6\xF0\xA0\xE4\x64\x4F\x48"
+ "\x8A\x7A\x5A\x52\xDE\xEE\x65\x62"
+ "\x07\xC5\x62\xF9\x88\xE9\x5C\x69",
+ },
+};
+
+/*
+ * TIGER test vectors from Tiger website
+ */
+#define TGR192_TEST_VECTORS 6
+
+static struct hash_testvec tgr192_tv_template[] = {
+ {
+ .plaintext = "",
+ .psize = 0,
+ .digest = "\x24\xf0\x13\x0c\x63\xac\x93\x32"
+ "\x16\x16\x6e\x76\xb1\xbb\x92\x5f"
+ "\xf3\x73\xde\x2d\x49\x58\x4e\x7a",
+ }, {
+ .plaintext = "abc",
+ .psize = 3,
+ .digest = "\xf2\x58\xc1\xe8\x84\x14\xab\x2a"
+ "\x52\x7a\xb5\x41\xff\xc5\xb8\xbf"
+ "\x93\x5f\x7b\x95\x1c\x13\x29\x51",
+ }, {
+ .plaintext = "Tiger",
+ .psize = 5,
+ .digest = "\x9f\x00\xf5\x99\x07\x23\x00\xdd"
+ "\x27\x6a\xbb\x38\xc8\xeb\x6d\xec"
+ "\x37\x79\x0c\x11\x6f\x9d\x2b\xdf",
+ }, {
+ .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-",
+ .psize = 64,
+ .digest = "\x87\xfb\x2a\x90\x83\x85\x1c\xf7"
+ "\x47\x0d\x2c\xf8\x10\xe6\xdf\x9e"
+ "\xb5\x86\x44\x50\x34\xa5\xa3\x86",
+ }, {
+ .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZ=abcdefghijklmnopqrstuvwxyz+0123456789",
+ .psize = 64,
+ .digest = "\x46\x7d\xb8\x08\x63\xeb\xce\x48"
+ "\x8d\xf1\xcd\x12\x61\x65\x5d\xe9"
+ "\x57\x89\x65\x65\x97\x5f\x91\x97",
+ }, {
+ .plaintext = "Tiger - A Fast New Hash Function, "
+ "by Ross Anderson and Eli Biham, "
+ "proceedings of Fast Software Encryption 3, "
+ "Cambridge, 1996.",
+ .psize = 125,
+ .digest = "\x3d\x9a\xeb\x03\xd1\xbd\x1a\x63"
+ "\x57\xb2\x77\x4d\xfd\x6d\x5b\x24"
+ "\xdd\x68\x15\x1d\x50\x39\x74\xfc",
+ },
+};
+
+#define TGR160_TEST_VECTORS 6
+
+static struct hash_testvec tgr160_tv_template[] = {
+ {
+ .plaintext = "",
+ .psize = 0,
+ .digest = "\x24\xf0\x13\x0c\x63\xac\x93\x32"
+ "\x16\x16\x6e\x76\xb1\xbb\x92\x5f"
+ "\xf3\x73\xde\x2d",
+ }, {
+ .plaintext = "abc",
+ .psize = 3,
+ .digest = "\xf2\x58\xc1\xe8\x84\x14\xab\x2a"
+ "\x52\x7a\xb5\x41\xff\xc5\xb8\xbf"
+ "\x93\x5f\x7b\x95",
+ }, {
+ .plaintext = "Tiger",
+ .psize = 5,
+ .digest = "\x9f\x00\xf5\x99\x07\x23\x00\xdd"
+ "\x27\x6a\xbb\x38\xc8\xeb\x6d\xec"
+ "\x37\x79\x0c\x11",
+ }, {
+ .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-",
+ .psize = 64,
+ .digest = "\x87\xfb\x2a\x90\x83\x85\x1c\xf7"
+ "\x47\x0d\x2c\xf8\x10\xe6\xdf\x9e"
+ "\xb5\x86\x44\x50",
+ }, {
+ .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZ=abcdefghijklmnopqrstuvwxyz+0123456789",
+ .psize = 64,
+ .digest = "\x46\x7d\xb8\x08\x63\xeb\xce\x48"
+ "\x8d\xf1\xcd\x12\x61\x65\x5d\xe9"
+ "\x57\x89\x65\x65",
+ }, {
+ .plaintext = "Tiger - A Fast New Hash Function, "
+ "by Ross Anderson and Eli Biham, "
+ "proceedings of Fast Software Encryption 3, "
+ "Cambridge, 1996.",
+ .psize = 125,
+ .digest = "\x3d\x9a\xeb\x03\xd1\xbd\x1a\x63"
+ "\x57\xb2\x77\x4d\xfd\x6d\x5b\x24"
+ "\xdd\x68\x15\x1d",
+ },
+};
+
+#define TGR128_TEST_VECTORS 6
+
+static struct hash_testvec tgr128_tv_template[] = {
+ {
+ .plaintext = "",
+ .psize = 0,
+ .digest = "\x24\xf0\x13\x0c\x63\xac\x93\x32"
+ "\x16\x16\x6e\x76\xb1\xbb\x92\x5f",
+ }, {
+ .plaintext = "abc",
+ .psize = 3,
+ .digest = "\xf2\x58\xc1\xe8\x84\x14\xab\x2a"
+ "\x52\x7a\xb5\x41\xff\xc5\xb8\xbf",
+ }, {
+ .plaintext = "Tiger",
+ .psize = 5,
+ .digest = "\x9f\x00\xf5\x99\x07\x23\x00\xdd"
+ "\x27\x6a\xbb\x38\xc8\xeb\x6d\xec",
+ }, {
+ .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-",
+ .psize = 64,
+ .digest = "\x87\xfb\x2a\x90\x83\x85\x1c\xf7"
+ "\x47\x0d\x2c\xf8\x10\xe6\xdf\x9e",
+ }, {
+ .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZ=abcdefghijklmnopqrstuvwxyz+0123456789",
+ .psize = 64,
+ .digest = "\x46\x7d\xb8\x08\x63\xeb\xce\x48"
+ "\x8d\xf1\xcd\x12\x61\x65\x5d\xe9",
+ }, {
+ .plaintext = "Tiger - A Fast New Hash Function, "
+ "by Ross Anderson and Eli Biham, "
+ "proceedings of Fast Software Encryption 3, "
+ "Cambridge, 1996.",
+ .psize = 125,
+ .digest = "\x3d\x9a\xeb\x03\xd1\xbd\x1a\x63"
+ "\x57\xb2\x77\x4d\xfd\x6d\x5b\x24",
+ },
+};
+
+/*
+ * HMAC-MD5 test vectors from RFC2202
+ * (These need to be fixed to not use strlen).
+ */
+#ifndef CONFIG_CRYPTO_DEV_MD5_HMAC
+#define HMAC_MD5_TEST_VECTORS 7
+#else
+#define HMAC_MD5_TEST_VECTORS 5
+#endif
+
+static struct hash_testvec hmac_md5_tv_template[] =
+{
+ {
+ .key = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b",
+ .ksize = 16,
+ .plaintext = "Hi There",
+ .psize = 8,
+ .digest = "\x92\x94\x72\x7a\x36\x38\xbb\x1c"
+ "\x13\xf4\x8e\xf8\x15\x8b\xfc\x9d",
+ }, {
+ .key = "Jefe",
+ .ksize = 4,
+ .plaintext = "what do ya want for nothing?",
+ .psize = 28,
+ .digest = "\x75\x0c\x78\x3e\x6a\xb0\xb5\x03"
+ "\xea\xa8\x6e\x31\x0a\x5d\xb7\x38",
+ .np = 2,
+ .tap = {14, 14}
+ }, {
+ .key = "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa",
+ .ksize = 16,
+ .plaintext = "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
+ "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
+ "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
+ "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd",
+ .psize = 50,
+ .digest = "\x56\xbe\x34\x52\x1d\x14\x4c\x88"
+ "\xdb\xb8\xc7\x33\xf0\xe8\xb3\xf6",
+ }, {
+ .key = "\x01\x02\x03\x04\x05\x06\x07\x08"
+ "\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10"
+ "\x11\x12\x13\x14\x15\x16\x17\x18\x19",
+ .ksize = 25,
+ .plaintext = "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
+ "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
+ "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
+ "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd",
+ .psize = 50,
+ .digest = "\x69\x7e\xaf\x0a\xca\x3a\x3a\xea"
+ "\x3a\x75\x16\x47\x46\xff\xaa\x79",
+ }, {
+ .key = "\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c",
+ .ksize = 16,
+ .plaintext = "Test With Truncation",
+ .psize = 20,
+ .digest = "\x56\x46\x1e\xf2\x34\x2e\xdc\x00"
+ "\xf9\xba\xb9\x95\x69\x0e\xfd\x4c",
+#ifndef CONFIG_CRYPTO_DEV_MD5_HMAC
+ }, {
+ .key = "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa",
+ .ksize = 80,
+ .plaintext = "Test Using Larger Than Block-Size Key - Hash Key First",
+ .psize = 54,
+ .digest = "\x6b\x1a\xb7\xfe\x4b\xd7\xbf\x8f"
+ "\x0b\x62\xe6\xce\x61\xb9\xd0\xcd",
+ }, {
+ .key = "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa",
+ .ksize = 80,
+ .plaintext = "Test Using Larger Than Block-Size Key and Larger Than One "
+ "Block-Size Data",
+ .psize = 73,
+ .digest = "\x6f\x63\x0f\xad\x67\xcd\xa0\xee"
+ "\x1f\xb1\xf5\x62\xdb\x3a\xa5\x3e",
+#endif /* CONFIG_CRYPTO_DEV_MD5_HMAC */
+ },
+};
+
+/*
+ * HMAC-RIPEMD128 test vectors from RFC2286
+ */
+#define HMAC_RMD128_TEST_VECTORS 7
+
+static struct hash_testvec hmac_rmd128_tv_template[] = {
+ {
+ .key = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b",
+ .ksize = 16,
+ .plaintext = "Hi There",
+ .psize = 8,
+ .digest = "\xfb\xf6\x1f\x94\x92\xaa\x4b\xbf"
+ "\x81\xc1\x72\xe8\x4e\x07\x34\xdb",
+ }, {
+ .key = "Jefe",
+ .ksize = 4,
+ .plaintext = "what do ya want for nothing?",
+ .psize = 28,
+ .digest = "\x87\x5f\x82\x88\x62\xb6\xb3\x34"
+ "\xb4\x27\xc5\x5f\x9f\x7f\xf0\x9b",
+ .np = 2,
+ .tap = { 14, 14 },
+ }, {
+ .key = "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa",
+ .ksize = 16,
+ .plaintext = "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
+ "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
+ "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
+ "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd",
+ .psize = 50,
+ .digest = "\x09\xf0\xb2\x84\x6d\x2f\x54\x3d"
+ "\xa3\x63\xcb\xec\x8d\x62\xa3\x8d",
+ }, {
+ .key = "\x01\x02\x03\x04\x05\x06\x07\x08"
+ "\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10"
+ "\x11\x12\x13\x14\x15\x16\x17\x18\x19",
+ .ksize = 25,
+ .plaintext = "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
+ "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
+ "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
+ "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd",
+ .psize = 50,
+ .digest = "\xbd\xbb\xd7\xcf\x03\xe4\x4b\x5a"
+ "\xa6\x0a\xf8\x15\xbe\x4d\x22\x94",
+ }, {
+ .key = "\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c",
+ .ksize = 16,
+ .plaintext = "Test With Truncation",
+ .psize = 20,
+ .digest = "\xe7\x98\x08\xf2\x4b\x25\xfd\x03"
+ "\x1c\x15\x5f\x0d\x55\x1d\x9a\x3a",
+ }, {
+ .key = "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa",
+ .ksize = 80,
+ .plaintext = "Test Using Larger Than Block-Size Key - Hash Key First",
+ .psize = 54,
+ .digest = "\xdc\x73\x29\x28\xde\x98\x10\x4a"
+ "\x1f\x59\xd3\x73\xc1\x50\xac\xbb",
+ }, {
+ .key = "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa",
+ .ksize = 80,
+ .plaintext = "Test Using Larger Than Block-Size Key and Larger Than One "
+ "Block-Size Data",
+ .psize = 73,
+ .digest = "\x5c\x6b\xec\x96\x79\x3e\x16\xd4"
+ "\x06\x90\xc2\x37\x63\x5f\x30\xc5",
+ },
+};
+
+/*
+ * HMAC-RIPEMD160 test vectors from RFC2286
+ */
+#define HMAC_RMD160_TEST_VECTORS 7
+
+static struct hash_testvec hmac_rmd160_tv_template[] = {
+ {
+ .key = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b",
+ .ksize = 20,
+ .plaintext = "Hi There",
+ .psize = 8,
+ .digest = "\x24\xcb\x4b\xd6\x7d\x20\xfc\x1a\x5d\x2e"
+ "\xd7\x73\x2d\xcc\x39\x37\x7f\x0a\x56\x68",
+ }, {
+ .key = "Jefe",
+ .ksize = 4,
+ .plaintext = "what do ya want for nothing?",
+ .psize = 28,
+ .digest = "\xdd\xa6\xc0\x21\x3a\x48\x5a\x9e\x24\xf4"
+ "\x74\x20\x64\xa7\xf0\x33\xb4\x3c\x40\x69",
+ .np = 2,
+ .tap = { 14, 14 },
+ }, {
+ .key = "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa",
+ .ksize = 20,
+ .plaintext = "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
+ "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
+ "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
+ "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd",
+ .psize = 50,
+ .digest = "\xb0\xb1\x05\x36\x0d\xe7\x59\x96\x0a\xb4"
+ "\xf3\x52\x98\xe1\x16\xe2\x95\xd8\xe7\xc1",
+ }, {
+ .key = "\x01\x02\x03\x04\x05\x06\x07\x08"
+ "\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10"
+ "\x11\x12\x13\x14\x15\x16\x17\x18\x19",
+ .ksize = 25,
+ .plaintext = "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
+ "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
+ "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
+ "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd",
+ .psize = 50,
+ .digest = "\xd5\xca\x86\x2f\x4d\x21\xd5\xe6\x10\xe1"
+ "\x8b\x4c\xf1\xbe\xb9\x7a\x43\x65\xec\xf4",
+ }, {
+ .key = "\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c",
+ .ksize = 20,
+ .plaintext = "Test With Truncation",
+ .psize = 20,
+ .digest = "\x76\x19\x69\x39\x78\xf9\x1d\x90\x53\x9a"
+ "\xe7\x86\x50\x0f\xf3\xd8\xe0\x51\x8e\x39",
+ }, {
+ .key = "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa",
+ .ksize = 80,
+ .plaintext = "Test Using Larger Than Block-Size Key - Hash Key First",
+ .psize = 54,
+ .digest = "\x64\x66\xca\x07\xac\x5e\xac\x29\xe1\xbd"
+ "\x52\x3e\x5a\xda\x76\x05\xb7\x91\xfd\x8b",
+ }, {
+ .key = "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa",
+ .ksize = 80,
+ .plaintext = "Test Using Larger Than Block-Size Key and Larger Than One "
+ "Block-Size Data",
+ .psize = 73,
+ .digest = "\x69\xea\x60\x79\x8d\x71\x61\x6c\xce\x5f"
+ "\xd0\x87\x1e\x23\x75\x4c\xd7\x5d\x5a\x0a",
+ },
+};
+
+/*
+ * HMAC-SHA1 test vectors from RFC2202
+ */
+#ifndef CONFIG_CRYPTO_DEV_SHA1_HMAC
+#define HMAC_SHA1_TEST_VECTORS 7
+#else
+#define HMAC_SHA1_TEST_VECTORS 5
+#endif
+
+static struct hash_testvec hmac_sha1_tv_template[] = {
+ {
+ .key = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b",
+ .ksize = 20,
+ .plaintext = "Hi There",
+ .psize = 8,
+ .digest = "\xb6\x17\x31\x86\x55\x05\x72\x64"
+ "\xe2\x8b\xc0\xb6\xfb\x37\x8c\x8e\xf1"
+ "\x46\xbe",
+ }, {
+ .key = "Jefe",
+ .ksize = 4,
+ .plaintext = "what do ya want for nothing?",
+ .psize = 28,
+ .digest = "\xef\xfc\xdf\x6a\xe5\xeb\x2f\xa2\xd2\x74"
+ "\x16\xd5\xf1\x84\xdf\x9c\x25\x9a\x7c\x79",
+ .np = 2,
+ .tap = { 14, 14 }
+ }, {
+ .key = "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa",
+ .ksize = 20,
+ .plaintext = "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
+ "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
+ "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
+ "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd",
+ .psize = 50,
+ .digest = "\x12\x5d\x73\x42\xb9\xac\x11\xcd\x91\xa3"
+ "\x9a\xf4\x8a\xa1\x7b\x4f\x63\xf1\x75\xd3",
+ }, {
+ .key = "\x01\x02\x03\x04\x05\x06\x07\x08"
+ "\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10"
+ "\x11\x12\x13\x14\x15\x16\x17\x18\x19",
+ .ksize = 25,
+ .plaintext = "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
+ "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
+ "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
+ "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd",
+ .psize = 50,
+ .digest = "\x4c\x90\x07\xf4\x02\x62\x50\xc6\xbc\x84"
+ "\x14\xf9\xbf\x50\xc8\x6c\x2d\x72\x35\xda",
+ }, {
+ .key = "\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c",
+ .ksize = 20,
+ .plaintext = "Test With Truncation",
+ .psize = 20,
+ .digest = "\x4c\x1a\x03\x42\x4b\x55\xe0\x7f\xe7\xf2"
+ "\x7b\xe1\xd5\x8b\xb9\x32\x4a\x9a\x5a\x04",
+
+#ifndef CONFIG_CRYPTO_DEV_SHA1_HMAC
+ }, {
+ .key = "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa",
+ .ksize = 80,
+ .plaintext = "Test Using Larger Than Block-Size Key - Hash Key First",
+ .psize = 54,
+ .digest = "\xaa\x4a\xe5\xe1\x52\x72\xd0\x0e\x95\x70"
+ "\x56\x37\xce\x8a\x3b\x55\xed\x40\x21\x12",
+ }, {
+ .key = "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa",
+ .ksize = 80,
+ .plaintext = "Test Using Larger Than Block-Size Key and Larger Than One "
+ "Block-Size Data",
+ .psize = 73,
+ .digest = "\xe8\xe9\x9d\x0f\x45\x23\x7d\x78\x6d\x6b"
+ "\xba\xa7\x96\x5c\x78\x08\xbb\xff\x1a\x91",
+#endif
+ },
+};
+
+
+/*
+ * SHA224 HMAC test vectors from RFC4231
+ */
+#define HMAC_SHA224_TEST_VECTORS 4
+
+static struct hash_testvec hmac_sha224_tv_template[] = {
+ {
+ .key = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
+ "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
+ "\x0b\x0b\x0b\x0b",
+ .ksize = 20,
+ /* ("Hi There") */
+ .plaintext = "\x48\x69\x20\x54\x68\x65\x72\x65",
+ .psize = 8,
+ .digest = "\x89\x6f\xb1\x12\x8a\xbb\xdf\x19"
+ "\x68\x32\x10\x7c\xd4\x9d\xf3\x3f"
+ "\x47\xb4\xb1\x16\x99\x12\xba\x4f"
+ "\x53\x68\x4b\x22",
+ }, {
+ .key = "Jefe",
+ .ksize = 4,
+ /* ("what do ya want for nothing?") */
+ .plaintext = "\x77\x68\x61\x74\x20\x64\x6f\x20"
+ "\x79\x61\x20\x77\x61\x6e\x74\x20"
+ "\x66\x6f\x72\x20\x6e\x6f\x74\x68"
+ "\x69\x6e\x67\x3f",
+ .psize = 28,
+ .digest = "\xa3\x0e\x01\x09\x8b\xc6\xdb\xbf"
+ "\x45\x69\x0f\x3a\x7e\x9e\x6d\x0f"
+ "\x8b\xbe\xa2\xa3\x9e\x61\x48\x00"
+ "\x8f\xd0\x5e\x44",
+ .np = 4,
+ .tap = { 7, 7, 7, 7 }
+ }, {
+ .key = "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa",
+ .ksize = 131,
+ /* ("Test Using Larger Than Block-Size Key - Hash Key First") */
+ .plaintext = "\x54\x65\x73\x74\x20\x55\x73\x69"
+ "\x6e\x67\x20\x4c\x61\x72\x67\x65"
+ "\x72\x20\x54\x68\x61\x6e\x20\x42"
+ "\x6c\x6f\x63\x6b\x2d\x53\x69\x7a"
+ "\x65\x20\x4b\x65\x79\x20\x2d\x20"
+ "\x48\x61\x73\x68\x20\x4b\x65\x79"
+ "\x20\x46\x69\x72\x73\x74",
+ .psize = 54,
+ .digest = "\x95\xe9\xa0\xdb\x96\x20\x95\xad"
+ "\xae\xbe\x9b\x2d\x6f\x0d\xbc\xe2"
+ "\xd4\x99\xf1\x12\xf2\xd2\xb7\x27"
+ "\x3f\xa6\x87\x0e",
+ }, {
+ .key = "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa",
+ .ksize = 131,
+ /* ("This is a test using a larger than block-size key and a")
+ (" larger than block-size data. The key needs to be")
+ (" hashed before being used by the HMAC algorithm.") */
+ .plaintext = "\x54\x68\x69\x73\x20\x69\x73\x20"
+ "\x61\x20\x74\x65\x73\x74\x20\x75"
+ "\x73\x69\x6e\x67\x20\x61\x20\x6c"
+ "\x61\x72\x67\x65\x72\x20\x74\x68"
+ "\x61\x6e\x20\x62\x6c\x6f\x63\x6b"
+ "\x2d\x73\x69\x7a\x65\x20\x6b\x65"
+ "\x79\x20\x61\x6e\x64\x20\x61\x20"
+ "\x6c\x61\x72\x67\x65\x72\x20\x74"
+ "\x68\x61\x6e\x20\x62\x6c\x6f\x63"
+ "\x6b\x2d\x73\x69\x7a\x65\x20\x64"
+ "\x61\x74\x61\x2e\x20\x54\x68\x65"
+ "\x20\x6b\x65\x79\x20\x6e\x65\x65"
+ "\x64\x73\x20\x74\x6f\x20\x62\x65"
+ "\x20\x68\x61\x73\x68\x65\x64\x20"
+ "\x62\x65\x66\x6f\x72\x65\x20\x62"
+ "\x65\x69\x6e\x67\x20\x75\x73\x65"
+ "\x64\x20\x62\x79\x20\x74\x68\x65"
+ "\x20\x48\x4d\x41\x43\x20\x61\x6c"
+ "\x67\x6f\x72\x69\x74\x68\x6d\x2e",
+ .psize = 152,
+ .digest = "\x3a\x85\x41\x66\xac\x5d\x9f\x02"
+ "\x3f\x54\xd5\x17\xd0\xb3\x9d\xbd"
+ "\x94\x67\x70\xdb\x9c\x2b\x95\xc9"
+ "\xf6\xf5\x65\xd1",
+ },
+};
+
+/*
+ * HMAC-SHA256 test vectors from
+ * draft-ietf-ipsec-ciph-sha-256-01.txt
+ */
+#define HMAC_SHA256_TEST_VECTORS 10
+
+static struct hash_testvec hmac_sha256_tv_template[] = {
+ {
+ .key = "\x01\x02\x03\x04\x05\x06\x07\x08"
+ "\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10"
+ "\x11\x12\x13\x14\x15\x16\x17\x18"
+ "\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20",
+ .ksize = 32,
+ .plaintext = "abc",
+ .psize = 3,
+ .digest = "\xa2\x1b\x1f\x5d\x4c\xf4\xf7\x3a"
+ "\x4d\xd9\x39\x75\x0f\x7a\x06\x6a"
+ "\x7f\x98\xcc\x13\x1c\xb1\x6a\x66"
+ "\x92\x75\x90\x21\xcf\xab\x81\x81",
+ }, {
+ .key = "\x01\x02\x03\x04\x05\x06\x07\x08"
+ "\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10"
+ "\x11\x12\x13\x14\x15\x16\x17\x18"
+ "\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20",
+ .ksize = 32,
+ .plaintext = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
+ .psize = 56,
+ .digest = "\x10\x4f\xdc\x12\x57\x32\x8f\x08"
+ "\x18\x4b\xa7\x31\x31\xc5\x3c\xae"
+ "\xe6\x98\xe3\x61\x19\x42\x11\x49"
+ "\xea\x8c\x71\x24\x56\x69\x7d\x30",
+ }, {
+ .key = "\x01\x02\x03\x04\x05\x06\x07\x08"
+ "\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10"
+ "\x11\x12\x13\x14\x15\x16\x17\x18"
+ "\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20",
+ .ksize = 32,
+ .plaintext = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
+ "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
+ .psize = 112,
+ .digest = "\x47\x03\x05\xfc\x7e\x40\xfe\x34"
+ "\xd3\xee\xb3\xe7\x73\xd9\x5a\xab"
+ "\x73\xac\xf0\xfd\x06\x04\x47\xa5"
+ "\xeb\x45\x95\xbf\x33\xa9\xd1\xa3",
+ }, {
+ .key = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
+ "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
+ "\x0b\x0b\x0b\x0b\x0b\x0b",
+ .ksize = 32,
+ .plaintext = "Hi There",
+ .psize = 8,
+ .digest = "\x19\x8a\x60\x7e\xb4\x4b\xfb\xc6"
+ "\x99\x03\xa0\xf1\xcf\x2b\xbd\xc5"
+ "\xba\x0a\xa3\xf3\xd9\xae\x3c\x1c"
+ "\x7a\x3b\x16\x96\xa0\xb6\x8c\xf7",
+ }, {
+ .key = "Jefe",
+ .ksize = 4,
+ .plaintext = "what do ya want for nothing?",
+ .psize = 28,
+ .digest = "\x5b\xdc\xc1\x46\xbf\x60\x75\x4e"
+ "\x6a\x04\x24\x26\x08\x95\x75\xc7"
+ "\x5a\x00\x3f\x08\x9d\x27\x39\x83"
+ "\x9d\xec\x58\xb9\x64\xec\x38\x43",
+ .np = 2,
+ .tap = { 14, 14 }
+ }, {
+ .key = "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa",
+ .ksize = 32,
+ .plaintext = "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
+ "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
+ "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
+ "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd",
+ .psize = 50,
+ .digest = "\xcd\xcb\x12\x20\xd1\xec\xcc\xea"
+ "\x91\xe5\x3a\xba\x30\x92\xf9\x62"
+ "\xe5\x49\xfe\x6c\xe9\xed\x7f\xdc"
+ "\x43\x19\x1f\xbd\xe4\x5c\x30\xb0",
+ }, {
+ .key = "\x01\x02\x03\x04\x05\x06\x07\x08"
+ "\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10"
+ "\x11\x12\x13\x14\x15\x16\x17\x18"
+ "\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20"
+ "\x21\x22\x23\x24\x25",
+ .ksize = 37,
+ .plaintext = "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
+ "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
+ "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
+ "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd",
+ .psize = 50,
+ .digest = "\xd4\x63\x3c\x17\xf6\xfb\x8d\x74"
+ "\x4c\x66\xde\xe0\xf8\xf0\x74\x55"
+ "\x6e\xc4\xaf\x55\xef\x07\x99\x85"
+ "\x41\x46\x8e\xb4\x9b\xd2\xe9\x17",
+ }, {
+ .key = "\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c"
+ "\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c"
+ "\x0c\x0c\x0c\x0c\x0c\x0c",
+ .ksize = 32,
+ .plaintext = "Test With Truncation",
+ .psize = 20,
+ .digest = "\x75\x46\xaf\x01\x84\x1f\xc0\x9b"
+ "\x1a\xb9\xc3\x74\x9a\x5f\x1c\x17"
+ "\xd4\xf5\x89\x66\x8a\x58\x7b\x27"
+ "\x00\xa9\xc9\x7c\x11\x93\xcf\x42",
+ }, {
+ .key = "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa",
+ .ksize = 80,
+ .plaintext = "Test Using Larger Than Block-Size Key - Hash Key First",
+ .psize = 54,
+ .digest = "\x69\x53\x02\x5e\xd9\x6f\x0c\x09"
+ "\xf8\x0a\x96\xf7\x8e\x65\x38\xdb"
+ "\xe2\xe7\xb8\x20\xe3\xdd\x97\x0e"
+ "\x7d\xdd\x39\x09\x1b\x32\x35\x2f",
+ }, {
+ .key = "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa",
+ .ksize = 80,
+ .plaintext = "Test Using Larger Than Block-Size Key and Larger Than "
+ "One Block-Size Data",
+ .psize = 73,
+ .digest = "\x63\x55\xac\x22\xe8\x90\xd0\xa3"
+ "\xc8\x48\x1a\x5c\xa4\x82\x5b\xc8"
+ "\x84\xd3\xe7\xa1\xff\x98\xa2\xfc"
+ "\x2a\xc7\xd8\xe0\x64\xc3\xb2\xe6",
+ },
+};
+
+#define XCBC_AES_TEST_VECTORS 6
+
+static struct hash_testvec aes_xcbc128_tv_template[] = {
+ {
+ .key = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .plaintext = zeroed_string,
+ .digest = "\x75\xf0\x25\x1d\x52\x8a\xc0\x1c"
+ "\x45\x73\xdf\xd5\x84\xd7\x9f\x29",
+ .psize = 0,
+ .ksize = 16,
+ }, {
+ .key = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .plaintext = "\x00\x01\x02",
+ .digest = "\x5b\x37\x65\x80\xae\x2f\x19\xaf"
+ "\xe7\x21\x9c\xee\xf1\x72\x75\x6f",
+ .psize = 3,
+ .ksize = 16,
+ } , {
+ .key = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .plaintext = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .digest = "\xd2\xa2\x46\xfa\x34\x9b\x68\xa7"
+ "\x99\x98\xa4\x39\x4f\xf7\xa2\x63",
+ .psize = 16,
+ .ksize = 16,
+ }, {
+ .key = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .plaintext = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13",
+ .digest = "\x47\xf5\x1b\x45\x64\x96\x62\x15"
+ "\xb8\x98\x5c\x63\x05\x5e\xd3\x08",
+ .tap = { 10, 10 },
+ .psize = 20,
+ .np = 2,
+ .ksize = 16,
+ }, {
+ .key = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .plaintext = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
+ .digest = "\xf5\x4f\x0e\xc8\xd2\xb9\xf3\xd3"
+ "\x68\x07\x73\x4b\xd5\x28\x3f\xd4",
+ .psize = 32,
+ .ksize = 16,
+ }, {
+ .key = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .plaintext = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
+ "\x20\x21",
+ .digest = "\xbe\xcb\xb3\xbc\xcd\xb5\x18\xa3"
+ "\x06\x77\xd5\x48\x1f\xb6\xb4\xd8",
+ .tap = { 17, 17 },
+ .psize = 34,
+ .np = 2,
+ .ksize = 16,
+ }
+};
+
+#define VMAC_AES_TEST_VECTORS 1
+static char vmac_string[128] = {'\x01', '\x01', '\x01', '\x01',
+ '\x02', '\x03', '\x02', '\x02',
+ '\x02', '\x04', '\x01', '\x07',
+ '\x04', '\x01', '\x04', '\x03',};
+static struct hash_testvec aes_vmac128_tv_template[] = {
+ {
+ .key = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .plaintext = vmac_string,
+ .digest = "\xcb\xd7\x8a\xfd\xb7\x33\x79\xe7",
+ .psize = 128,
+ .ksize = 16,
+ },
+};
+
+/*
+ * SHA384 HMAC test vectors from RFC4231
+ */
+
+#define HMAC_SHA384_TEST_VECTORS 4
+
+static struct hash_testvec hmac_sha384_tv_template[] = {
+ {
+ .key = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
+ "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
+ "\x0b\x0b\x0b\x0b",
+ .ksize = 20,
+ .plaintext = "Hi There",
+ .psize = 8,
+ .digest = "\xaf\xd0\x39\x44\xd8\x48\x95\x62"
+ "\x6b\x08\x25\xf4\xab\x46\x90\x7f"
+ "\x15\xf9\xda\xdb\xe4\x10\x1e\xc6"
+ "\x82\xaa\x03\x4c\x7c\xeb\xc5\x9c"
+ "\xfa\xea\x9e\xa9\x07\x6e\xde\x7f"
+ "\x4a\xf1\x52\xe8\xb2\xfa\x9c\xb6",
+ }, {
+ .key = "Jefe",
+ .ksize = 4,
+ .plaintext = "what do ya want for nothing?",
+ .psize = 28,
+ .digest = "\xaf\x45\xd2\xe3\x76\x48\x40\x31"
+ "\x61\x7f\x78\xd2\xb5\x8a\x6b\x1b"
+ "\x9c\x7e\xf4\x64\xf5\xa0\x1b\x47"
+ "\xe4\x2e\xc3\x73\x63\x22\x44\x5e"
+ "\x8e\x22\x40\xca\x5e\x69\xe2\xc7"
+ "\x8b\x32\x39\xec\xfa\xb2\x16\x49",
+ .np = 4,
+ .tap = { 7, 7, 7, 7 }
+ }, {
+ .key = "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa",
+ .ksize = 131,
+ .plaintext = "Test Using Larger Than Block-Siz"
+ "e Key - Hash Key First",
+ .psize = 54,
+ .digest = "\x4e\xce\x08\x44\x85\x81\x3e\x90"
+ "\x88\xd2\xc6\x3a\x04\x1b\xc5\xb4"
+ "\x4f\x9e\xf1\x01\x2a\x2b\x58\x8f"
+ "\x3c\xd1\x1f\x05\x03\x3a\xc4\xc6"
+ "\x0c\x2e\xf6\xab\x40\x30\xfe\x82"
+ "\x96\x24\x8d\xf1\x63\xf4\x49\x52",
+ }, {
+ .key = "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa",
+ .ksize = 131,
+ .plaintext = "This is a test u"
+ "sing a larger th"
+ "an block-size ke"
+ "y and a larger t"
+ "han block-size d"
+ "ata. The key nee"
+ "ds to be hashed "
+ "before being use"
+ "d by the HMAC al"
+ "gorithm.",
+ .psize = 152,
+ .digest = "\x66\x17\x17\x8e\x94\x1f\x02\x0d"
+ "\x35\x1e\x2f\x25\x4e\x8f\xd3\x2c"
+ "\x60\x24\x20\xfe\xb0\xb8\xfb\x9a"
+ "\xdc\xce\xbb\x82\x46\x1e\x99\xc5"
+ "\xa6\x78\xcc\x31\xe7\x99\x17\x6d"
+ "\x38\x60\xe6\x11\x0c\x46\x52\x3e",
+ },
+};
+
+/*
+ * SHA512 HMAC test vectors from RFC4231
+ */
+
+#define HMAC_SHA512_TEST_VECTORS 4
+
+static struct hash_testvec hmac_sha512_tv_template[] = {
+ {
+ .key = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
+ "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
+ "\x0b\x0b\x0b\x0b",
+ .ksize = 20,
+ .plaintext = "Hi There",
+ .psize = 8,
+ .digest = "\x87\xaa\x7c\xde\xa5\xef\x61\x9d"
+ "\x4f\xf0\xb4\x24\x1a\x1d\x6c\xb0"
+ "\x23\x79\xf4\xe2\xce\x4e\xc2\x78"
+ "\x7a\xd0\xb3\x05\x45\xe1\x7c\xde"
+ "\xda\xa8\x33\xb7\xd6\xb8\xa7\x02"
+ "\x03\x8b\x27\x4e\xae\xa3\xf4\xe4"
+ "\xbe\x9d\x91\x4e\xeb\x61\xf1\x70"
+ "\x2e\x69\x6c\x20\x3a\x12\x68\x54",
+ }, {
+ .key = "Jefe",
+ .ksize = 4,
+ .plaintext = "what do ya want for nothing?",
+ .psize = 28,
+ .digest = "\x16\x4b\x7a\x7b\xfc\xf8\x19\xe2"
+ "\xe3\x95\xfb\xe7\x3b\x56\xe0\xa3"
+ "\x87\xbd\x64\x22\x2e\x83\x1f\xd6"
+ "\x10\x27\x0c\xd7\xea\x25\x05\x54"
+ "\x97\x58\xbf\x75\xc0\x5a\x99\x4a"
+ "\x6d\x03\x4f\x65\xf8\xf0\xe6\xfd"
+ "\xca\xea\xb1\xa3\x4d\x4a\x6b\x4b"
+ "\x63\x6e\x07\x0a\x38\xbc\xe7\x37",
+ .np = 4,
+ .tap = { 7, 7, 7, 7 }
+ }, {
+ .key = "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa",
+ .ksize = 131,
+ .plaintext = "Test Using Large"
+ "r Than Block-Siz"
+ "e Key - Hash Key"
+ " First",
+ .psize = 54,
+ .digest = "\x80\xb2\x42\x63\xc7\xc1\xa3\xeb"
+ "\xb7\x14\x93\xc1\xdd\x7b\xe8\xb4"
+ "\x9b\x46\xd1\xf4\x1b\x4a\xee\xc1"
+ "\x12\x1b\x01\x37\x83\xf8\xf3\x52"
+ "\x6b\x56\xd0\x37\xe0\x5f\x25\x98"
+ "\xbd\x0f\xd2\x21\x5d\x6a\x1e\x52"
+ "\x95\xe6\x4f\x73\xf6\x3f\x0a\xec"
+ "\x8b\x91\x5a\x98\x5d\x78\x65\x98",
+ }, {
+ .key = "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa",
+ .ksize = 131,
+ .plaintext =
+ "This is a test u"
+ "sing a larger th"
+ "an block-size ke"
+ "y and a larger t"
+ "han block-size d"
+ "ata. The key nee"
+ "ds to be hashed "
+ "before being use"
+ "d by the HMAC al"
+ "gorithm.",
+ .psize = 152,
+ .digest = "\xe3\x7b\x6a\x77\x5d\xc8\x7d\xba"
+ "\xa4\xdf\xa9\xf9\x6e\x5e\x3f\xfd"
+ "\xde\xbd\x71\xf8\x86\x72\x89\x86"
+ "\x5d\xf5\xa3\x2d\x20\xcd\xc9\x44"
+ "\xb6\x02\x2c\xac\x3c\x49\x82\xb1"
+ "\x0d\x5e\xeb\x55\xc3\xe4\xde\x15"
+ "\x13\x46\x76\xfb\x6d\xe0\x44\x60"
+ "\x65\xc9\x74\x40\xfa\x8c\x6a\x58",
+ },
+};
+
+/*
+ * DES test vectors.
+ */
+#if defined(CONFIG_CRYPTO_DEV_DES) || defined (CONFIG_CRYPTO_ASYNC_DES)
+#define DES_ENC_TEST_VECTORS 5
+#define DES_DEC_TEST_VECTORS 3
+#define DES_CBC_ENC_TEST_VECTORS 4
+#define DES_CBC_DEC_TEST_VECTORS 3
+#define DES3_EDE_ENC_TEST_VECTORS 3
+#define DES3_EDE_DEC_TEST_VECTORS 3
+#define DES3_EDE_CBC_ENC_TEST_VECTORS 1
+#define DES3_EDE_CBC_DEC_TEST_VECTORS 1
+#else
+#define DES_ENC_TEST_VECTORS 10
+#define DES_DEC_TEST_VECTORS 4
+#define DES_CBC_ENC_TEST_VECTORS 5
+#define DES_CBC_DEC_TEST_VECTORS 4
+#define DES3_EDE_ENC_TEST_VECTORS 3
+#define DES3_EDE_DEC_TEST_VECTORS 3
+#define DES3_EDE_CBC_ENC_TEST_VECTORS 1
+#define DES3_EDE_CBC_DEC_TEST_VECTORS 1
+#endif /*CONFIG_CRYPTO_DEV_DES*/
+
+static struct cipher_testvec des_enc_tv_template[] = {
+ { /* From Applied Cryptography */
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .klen = 8,
+ .input = "\x01\x23\x45\x67\x89\xab\xcd\xe7",
+ .ilen = 8,
+ .result = "\xc9\x57\x44\x25\x6a\x5e\xd3\x1d",
+ .rlen = 8,
+ }, { /* Same key, different plaintext block */
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .klen = 8,
+ .input = "\x22\x33\x44\x55\x66\x77\x88\x99",
+ .ilen = 8,
+ .result = "\xf7\x9c\x89\x2a\x33\x8f\x4a\x8b",
+ .rlen = 8,
+ }, { /* Sbox test from NBS */
+ .key = "\x7c\xa1\x10\x45\x4a\x1a\x6e\x57",
+ .klen = 8,
+ .input = "\x01\xa1\xd6\xd0\x39\x77\x67\x42",
+ .ilen = 8,
+ .result = "\x69\x0f\x5b\x0d\x9a\x26\x93\x9b",
+ .rlen = 8,
+ }, { /* Three blocks */
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .klen = 8,
+ .input = "\x01\x23\x45\x67\x89\xab\xcd\xe7"
+ "\x22\x33\x44\x55\x66\x77\x88\x99"
+ "\xca\xfe\xba\xbe\xfe\xed\xbe\xef",
+ .ilen = 24,
+ .result = "\xc9\x57\x44\x25\x6a\x5e\xd3\x1d"
+ "\xf7\x9c\x89\x2a\x33\x8f\x4a\x8b"
+ "\xb4\x99\x26\xf7\x1f\xe1\xd4\x90",
+ .rlen = 24,
+//#if !defined(CONFIG_CRYPTO_DEV_DES) && !defined(CONFIG_CRYPTO_ASYNC_DES)
+#if 0
+ }, { /* Weak key */
+ .fail = 1,
+ .wk = 1,
+ .key = "\x01\x01\x01\x01\x01\x01\x01\x01",
+ .klen = 8,
+ .input = "\x01\x23\x45\x67\x89\xab\xcd\xe7",
+ .ilen = 8,
+ .result = "\xc9\x57\x44\x25\x6a\x5e\xd3\x1d",
+ .rlen = 8,
+#endif
+ }, { /* Two blocks -- for testing encryption across pages */
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .klen = 8,
+ .input = "\x01\x23\x45\x67\x89\xab\xcd\xe7"
+ "\x22\x33\x44\x55\x66\x77\x88\x99",
+ .ilen = 16,
+ .result = "\xc9\x57\x44\x25\x6a\x5e\xd3\x1d"
+ "\xf7\x9c\x89\x2a\x33\x8f\x4a\x8b",
+ .rlen = 16,
+ .np = 2,
+ .tap = { 8, 8 }
+//#if !defined(CONFIG_CRYPTO_DEV_DES) && !defined(CONFIG_CRYPTO_ASYNC_DES)
+#if 0
+ }, { /* Four blocks -- for testing encryption with chunking */
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .klen = 8,
+ .input = "\x01\x23\x45\x67\x89\xab\xcd\xe7"
+ "\x22\x33\x44\x55\x66\x77\x88\x99"
+ "\xca\xfe\xba\xbe\xfe\xed\xbe\xef"
+ "\x22\x33\x44\x55\x66\x77\x88\x99",
+ .ilen = 32,
+ .result = "\xc9\x57\x44\x25\x6a\x5e\xd3\x1d"
+ "\xf7\x9c\x89\x2a\x33\x8f\x4a\x8b"
+ "\xb4\x99\x26\xf7\x1f\xe1\xd4\x90"
+ "\xf7\x9c\x89\x2a\x33\x8f\x4a\x8b",
+ .rlen = 32,
+ .np = 3,
+ .tap = { 14, 10, 8 }
+ }, {
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .klen = 8,
+ .input = "\x01\x23\x45\x67\x89\xab\xcd\xe7"
+ "\x22\x33\x44\x55\x66\x77\x88\x99"
+ "\xca\xfe\xba\xbe\xfe\xed\xbe\xef",
+ .ilen = 24,
+ .result = "\xc9\x57\x44\x25\x6a\x5e\xd3\x1d"
+ "\xf7\x9c\x89\x2a\x33\x8f\x4a\x8b"
+ "\xb4\x99\x26\xf7\x1f\xe1\xd4\x90",
+ .rlen = 24,
+ .np = 4,
+ .tap = { 2, 1, 3, 18 }
+ }, {
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .klen = 8,
+ .input = "\x01\x23\x45\x67\x89\xab\xcd\xe7"
+ "\x22\x33\x44\x55\x66\x77\x88\x99",
+ .ilen = 16,
+ .result = "\xc9\x57\x44\x25\x6a\x5e\xd3\x1d"
+ "\xf7\x9c\x89\x2a\x33\x8f\x4a\x8b",
+ .rlen = 16,
+ .np = 5,
+ .tap = { 2, 2, 2, 2, 8 }
+ }, {
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .klen = 8,
+ .input = "\x01\x23\x45\x67\x89\xab\xcd\xe7",
+ .ilen = 8,
+ .result = "\xc9\x57\x44\x25\x6a\x5e\xd3\x1d",
+ .rlen = 8,
+ .np = 8,
+ .tap = { 1, 1, 1, 1, 1, 1, 1, 1 }
+#endif
+ },
+};
+
+static struct cipher_testvec des_dec_tv_template[] = {
+ { /* From Applied Cryptography */
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .klen = 8,
+ .input = "\xc9\x57\x44\x25\x6a\x5e\xd3\x1d",
+ .ilen = 8,
+ .result = "\x01\x23\x45\x67\x89\xab\xcd\xe7",
+ .rlen = 8,
+ }, { /* Sbox test from NBS */
+ .key = "\x7c\xa1\x10\x45\x4a\x1a\x6e\x57",
+ .klen = 8,
+ .input = "\x69\x0f\x5b\x0d\x9a\x26\x93\x9b",
+ .ilen = 8,
+ .result = "\x01\xa1\xd6\xd0\x39\x77\x67\x42",
+ .rlen = 8,
+ }, { /* Two blocks, for chunking test */
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .klen = 8,
+ .input = "\xc9\x57\x44\x25\x6a\x5e\xd3\x1d"
+ "\x69\x0f\x5b\x0d\x9a\x26\x93\x9b",
+ .ilen = 16,
+ .result = "\x01\x23\x45\x67\x89\xab\xcd\xe7"
+ "\xa3\x99\x7b\xca\xaf\x69\xa0\xf5",
+ .rlen = 16,
+ .np = 2,
+ .tap = { 8, 8 }
+ }, {
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .klen = 8,
+ .input = "\xc9\x57\x44\x25\x6a\x5e\xd3\x1d"
+ "\x69\x0f\x5b\x0d\x9a\x26\x93\x9b",
+ .ilen = 16,
+ .result = "\x01\x23\x45\x67\x89\xab\xcd\xe7"
+ "\xa3\x99\x7b\xca\xaf\x69\xa0\xf5",
+ .rlen = 16,
+ .np = 3,
+ .tap = { 3, 12, 1 }
+ },
+};
+
+static struct cipher_testvec des_cbc_enc_tv_template[] = {
+ { /* From OpenSSL */
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .klen = 8,
+ .iv = "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .input = "\x37\x36\x35\x34\x33\x32\x31\x20"
+ "\x4e\x6f\x77\x20\x69\x73\x20\x74"
+ "\x68\x65\x20\x74\x69\x6d\x65\x20",
+ .ilen = 24,
+ .result = "\xcc\xd1\x73\xff\xab\x20\x39\xf4"
+ "\xac\xd8\xae\xfd\xdf\xd8\xa1\xeb"
+ "\x46\x8e\x91\x15\x78\x88\xba\x68",
+ .rlen = 24,
+ }, { /* FIPS Pub 81 */
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .klen = 8,
+ .iv = "\x12\x34\x56\x78\x90\xab\xcd\xef",
+ .input = "\x4e\x6f\x77\x20\x69\x73\x20\x74",
+ .ilen = 8,
+ .result = "\xe5\xc7\xcd\xde\x87\x2b\xf2\x7c",
+ .rlen = 8,
+ }, {
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .klen = 8,
+ .iv = "\xe5\xc7\xcd\xde\x87\x2b\xf2\x7c",
+ .input = "\x68\x65\x20\x74\x69\x6d\x65\x20",
+ .ilen = 8,
+ .result = "\x43\xe9\x34\x00\x8c\x38\x9c\x0f",
+ .rlen = 8,
+ }, {
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .klen = 8,
+ .iv = "\x43\xe9\x34\x00\x8c\x38\x9c\x0f",
+ .input = "\x66\x6f\x72\x20\x61\x6c\x6c\x20",
+ .ilen = 8,
+ .result = "\x68\x37\x88\x49\x9a\x7c\x05\xf6",
+ .rlen = 8,
+#if 0
+ }, { /* Copy of openssl vector for chunk testing */
+ /* From OpenSSL */
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .klen = 8,
+ .iv = "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .input = "\x37\x36\x35\x34\x33\x32\x31\x20"
+ "\x4e\x6f\x77\x20\x69\x73\x20\x74"
+ "\x68\x65\x20\x74\x69\x6d\x65\x20",
+ .ilen = 24,
+ .result = "\xcc\xd1\x73\xff\xab\x20\x39\xf4"
+ "\xac\xd8\xae\xfd\xdf\xd8\xa1\xeb"
+ "\x46\x8e\x91\x15\x78\x88\xba\x68",
+ .rlen = 24,
+ .np = 2,
+ .tap = { 13, 11 }
+#endif
+ },
+};
+
+static struct cipher_testvec des_cbc_dec_tv_template[] = {
+ { /* FIPS Pub 81 */
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .klen = 8,
+ .iv = "\x12\x34\x56\x78\x90\xab\xcd\xef",
+ .input = "\xe5\xc7\xcd\xde\x87\x2b\xf2\x7c",
+ .ilen = 8,
+ .result = "\x4e\x6f\x77\x20\x69\x73\x20\x74",
+ .rlen = 8,
+ }, {
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .klen = 8,
+ .iv = "\xe5\xc7\xcd\xde\x87\x2b\xf2\x7c",
+ .input = "\x43\xe9\x34\x00\x8c\x38\x9c\x0f",
+ .ilen = 8,
+ .result = "\x68\x65\x20\x74\x69\x6d\x65\x20",
+ .rlen = 8,
+ }, {
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .klen = 8,
+ .iv = "\x43\xe9\x34\x00\x8c\x38\x9c\x0f",
+ .input = "\x68\x37\x88\x49\x9a\x7c\x05\xf6",
+ .ilen = 8,
+ .result = "\x66\x6f\x72\x20\x61\x6c\x6c\x20",
+ .rlen = 8,
+ }, { /* Copy of above, for chunk testing */
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .klen = 8,
+ .iv = "\x43\xe9\x34\x00\x8c\x38\x9c\x0f",
+ .input = "\x68\x37\x88\x49\x9a\x7c\x05\xf6",
+ .ilen = 8,
+ .result = "\x66\x6f\x72\x20\x61\x6c\x6c\x20",
+ .rlen = 8,
+ .np = 2,
+ .tap = { 4, 4 }
+ },
+};
+
+static struct cipher_testvec des3_ede_enc_tv_template[] = {
+ { /* These are from openssl */
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef"
+ "\x55\x55\x55\x55\x55\x55\x55\x55"
+ "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .klen = 24,
+ .input = "\x73\x6f\x6d\x65\x64\x61\x74\x61",
+ .ilen = 8,
+ .result = "\x18\xd7\x48\xe5\x63\x62\x05\x72",
+ .rlen = 8,
+ }, {
+ .key = "\x03\x52\x02\x07\x67\x20\x82\x17"
+ "\x86\x02\x87\x66\x59\x08\x21\x98"
+ "\x64\x05\x6a\xbd\xfe\xa9\x34\x57",
+ .klen = 24,
+ .input = "\x73\x71\x75\x69\x67\x67\x6c\x65",
+ .ilen = 8,
+ .result = "\xc0\x7d\x2a\x0f\xa5\x66\xfa\x30",
+ .rlen = 8,
+ }, {
+ .key = "\x10\x46\x10\x34\x89\x98\x80\x20"
+ "\x91\x07\xd0\x15\x89\x19\x01\x01"
+ "\x19\x07\x92\x10\x98\x1a\x01\x01",
+ .klen = 24,
+ .input = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .ilen = 8,
+ .result = "\xe1\xef\x62\xc3\x32\xfe\x82\x5b",
+ .rlen = 8,
+ },
+};
+
+static struct cipher_testvec des3_ede_dec_tv_template[] = {
+ { /* These are from openssl */
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef"
+ "\x55\x55\x55\x55\x55\x55\x55\x55"
+ "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .klen = 24,
+ .input = "\x18\xd7\x48\xe5\x63\x62\x05\x72",
+ .ilen = 8,
+ .result = "\x73\x6f\x6d\x65\x64\x61\x74\x61",
+ .rlen = 8,
+ }, {
+ .key = "\x03\x52\x02\x07\x67\x20\x82\x17"
+ "\x86\x02\x87\x66\x59\x08\x21\x98"
+ "\x64\x05\x6a\xbd\xfe\xa9\x34\x57",
+ .klen = 24,
+ .input = "\xc0\x7d\x2a\x0f\xa5\x66\xfa\x30",
+ .ilen = 8,
+ .result = "\x73\x71\x75\x69\x67\x67\x6c\x65",
+ .rlen = 8,
+ }, {
+ .key = "\x10\x46\x10\x34\x89\x98\x80\x20"
+ "\x91\x07\xd0\x15\x89\x19\x01\x01"
+ "\x19\x07\x92\x10\x98\x1a\x01\x01",
+ .klen = 24,
+ .input = "\xe1\xef\x62\xc3\x32\xfe\x82\x5b",
+ .ilen = 8,
+ .result = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .rlen = 8,
+ },
+};
+
+static struct cipher_testvec des3_ede_cbc_enc_tv_template[] = {
+ { /* Generated from openssl */
+ .key = "\xE9\xC0\xFF\x2E\x76\x0B\x64\x24"
+ "\x44\x4D\x99\x5A\x12\xD6\x40\xC0"
+ "\xEA\xC2\x84\xE8\x14\x95\xDB\xE8",
+ .klen = 24,
+ .iv = "\x7D\x33\x88\x93\x0F\x93\xB2\x42",
+ .input = "\x6f\x54\x20\x6f\x61\x4d\x79\x6e"
+ "\x53\x20\x63\x65\x65\x72\x73\x74"
+ "\x54\x20\x6f\x6f\x4d\x20\x6e\x61"
+ "\x20\x79\x65\x53\x72\x63\x74\x65"
+ "\x20\x73\x6f\x54\x20\x6f\x61\x4d"
+ "\x79\x6e\x53\x20\x63\x65\x65\x72"
+ "\x73\x74\x54\x20\x6f\x6f\x4d\x20"
+ "\x6e\x61\x20\x79\x65\x53\x72\x63"
+ "\x74\x65\x20\x73\x6f\x54\x20\x6f"
+ "\x61\x4d\x79\x6e\x53\x20\x63\x65"
+ "\x65\x72\x73\x74\x54\x20\x6f\x6f"
+ "\x4d\x20\x6e\x61\x20\x79\x65\x53"
+ "\x72\x63\x74\x65\x20\x73\x6f\x54"
+ "\x20\x6f\x61\x4d\x79\x6e\x53\x20"
+ "\x63\x65\x65\x72\x73\x74\x54\x20"
+ "\x6f\x6f\x4d\x20\x6e\x61\x0a\x79",
+ .ilen = 128,
+ .result = "\x0e\x2d\xb6\x97\x3c\x56\x33\xf4"
+ "\x67\x17\x21\xc7\x6e\x8a\xd5\x49"
+ "\x74\xb3\x49\x05\xc5\x1c\xd0\xed"
+ "\x12\x56\x5c\x53\x96\xb6\x00\x7d"
+ "\x90\x48\xfc\xf5\x8d\x29\x39\xcc"
+ "\x8a\xd5\x35\x18\x36\x23\x4e\xd7"
+ "\x76\xd1\xda\x0c\x94\x67\xbb\x04"
+ "\x8b\xf2\x03\x6c\xa8\xcf\xb6\xea"
+ "\x22\x64\x47\xaa\x8f\x75\x13\xbf"
+ "\x9f\xc2\xc3\xf0\xc9\x56\xc5\x7a"
+ "\x71\x63\x2e\x89\x7b\x1e\x12\xca"
+ "\xe2\x5f\xaf\xd8\xa4\xf8\xc9\x7a"
+ "\xd6\xf9\x21\x31\x62\x44\x45\xa6"
+ "\xd6\xbc\x5a\xd3\x2d\x54\x43\xcc"
+ "\x9d\xde\xa5\x70\xe9\x42\x45\x8a"
+ "\x6b\xfa\xb1\x91\x13\xb0\xd9\x19",
+ .rlen = 128,
+ },
+};
+
+static struct cipher_testvec des3_ede_cbc_dec_tv_template[] = {
+ { /* Generated from openssl */
+ .key = "\xE9\xC0\xFF\x2E\x76\x0B\x64\x24"
+ "\x44\x4D\x99\x5A\x12\xD6\x40\xC0"
+ "\xEA\xC2\x84\xE8\x14\x95\xDB\xE8",
+ .klen = 24,
+ .iv = "\x7D\x33\x88\x93\x0F\x93\xB2\x42",
+ .input = "\x0e\x2d\xb6\x97\x3c\x56\x33\xf4"
+ "\x67\x17\x21\xc7\x6e\x8a\xd5\x49"
+ "\x74\xb3\x49\x05\xc5\x1c\xd0\xed"
+ "\x12\x56\x5c\x53\x96\xb6\x00\x7d"
+ "\x90\x48\xfc\xf5\x8d\x29\x39\xcc"
+ "\x8a\xd5\x35\x18\x36\x23\x4e\xd7"
+ "\x76\xd1\xda\x0c\x94\x67\xbb\x04"
+ "\x8b\xf2\x03\x6c\xa8\xcf\xb6\xea"
+ "\x22\x64\x47\xaa\x8f\x75\x13\xbf"
+ "\x9f\xc2\xc3\xf0\xc9\x56\xc5\x7a"
+ "\x71\x63\x2e\x89\x7b\x1e\x12\xca"
+ "\xe2\x5f\xaf\xd8\xa4\xf8\xc9\x7a"
+ "\xd6\xf9\x21\x31\x62\x44\x45\xa6"
+ "\xd6\xbc\x5a\xd3\x2d\x54\x43\xcc"
+ "\x9d\xde\xa5\x70\xe9\x42\x45\x8a"
+ "\x6b\xfa\xb1\x91\x13\xb0\xd9\x19",
+ .ilen = 128,
+ .result = "\x6f\x54\x20\x6f\x61\x4d\x79\x6e"
+ "\x53\x20\x63\x65\x65\x72\x73\x74"
+ "\x54\x20\x6f\x6f\x4d\x20\x6e\x61"
+ "\x20\x79\x65\x53\x72\x63\x74\x65"
+ "\x20\x73\x6f\x54\x20\x6f\x61\x4d"
+ "\x79\x6e\x53\x20\x63\x65\x65\x72"
+ "\x73\x74\x54\x20\x6f\x6f\x4d\x20"
+ "\x6e\x61\x20\x79\x65\x53\x72\x63"
+ "\x74\x65\x20\x73\x6f\x54\x20\x6f"
+ "\x61\x4d\x79\x6e\x53\x20\x63\x65"
+ "\x65\x72\x73\x74\x54\x20\x6f\x6f"
+ "\x4d\x20\x6e\x61\x20\x79\x65\x53"
+ "\x72\x63\x74\x65\x20\x73\x6f\x54"
+ "\x20\x6f\x61\x4d\x79\x6e\x53\x20"
+ "\x63\x65\x65\x72\x73\x74\x54\x20"
+ "\x6f\x6f\x4d\x20\x6e\x61\x0a\x79",
+ .rlen = 128,
+ },
+};
+
+/*
+ * Blowfish test vectors.
+ */
+#define BF_ENC_TEST_VECTORS 6
+#define BF_DEC_TEST_VECTORS 6
+#define BF_CBC_ENC_TEST_VECTORS 1
+#define BF_CBC_DEC_TEST_VECTORS 1
+
+static struct cipher_testvec bf_enc_tv_template[] = {
+ { /* DES test vectors from OpenSSL */
+ .key = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .klen = 8,
+ .input = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .ilen = 8,
+ .result = "\x4e\xf9\x97\x45\x61\x98\xdd\x78",
+ .rlen = 8,
+ }, {
+ .key = "\x1f\x1f\x1f\x1f\x0e\x0e\x0e\x0e",
+ .klen = 8,
+ .input = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .ilen = 8,
+ .result = "\xa7\x90\x79\x51\x08\xea\x3c\xae",
+ .rlen = 8,
+ }, {
+ .key = "\xf0\xe1\xd2\xc3\xb4\xa5\x96\x87",
+ .klen = 8,
+ .input = "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .ilen = 8,
+ .result = "\xe8\x7a\x24\x4e\x2c\xc8\x5e\x82",
+ .rlen = 8,
+ }, { /* Vary the keylength... */
+ .key = "\xf0\xe1\xd2\xc3\xb4\xa5\x96\x87"
+ "\x78\x69\x5a\x4b\x3c\x2d\x1e\x0f",
+ .klen = 16,
+ .input = "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .ilen = 8,
+ .result = "\x93\x14\x28\x87\xee\x3b\xe1\x5c",
+ .rlen = 8,
+ }, {
+ .key = "\xf0\xe1\xd2\xc3\xb4\xa5\x96\x87"
+ "\x78\x69\x5a\x4b\x3c\x2d\x1e\x0f"
+ "\x00\x11\x22\x33\x44",
+ .klen = 21,
+ .input = "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .ilen = 8,
+ .result = "\xe6\xf5\x1e\xd7\x9b\x9d\xb2\x1f",
+ .rlen = 8,
+ }, { /* Generated with bf488 */
+ .key = "\xf0\xe1\xd2\xc3\xb4\xa5\x96\x87"
+ "\x78\x69\x5a\x4b\x3c\x2d\x1e\x0f"
+ "\x00\x11\x22\x33\x44\x55\x66\x77"
+ "\x04\x68\x91\x04\xc2\xfd\x3b\x2f"
+ "\x58\x40\x23\x64\x1a\xba\x61\x76"
+ "\x1f\x1f\x1f\x1f\x0e\x0e\x0e\x0e"
+ "\xff\xff\xff\xff\xff\xff\xff\xff",
+ .klen = 56,
+ .input = "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .ilen = 8,
+ .result = "\xc0\x45\x04\x01\x2e\x4e\x1f\x53",
+ .rlen = 8,
+ },
+};
+
+static struct cipher_testvec bf_dec_tv_template[] = {
+ { /* DES test vectors from OpenSSL */
+ .key = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .klen = 8,
+ .input = "\x4e\xf9\x97\x45\x61\x98\xdd\x78",
+ .ilen = 8,
+ .result = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .rlen = 8,
+ }, {
+ .key = "\x1f\x1f\x1f\x1f\x0e\x0e\x0e\x0e",
+ .klen = 8,
+ .input = "\xa7\x90\x79\x51\x08\xea\x3c\xae",
+ .ilen = 8,
+ .result = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .rlen = 8,
+ }, {
+ .key = "\xf0\xe1\xd2\xc3\xb4\xa5\x96\x87",
+ .klen = 8,
+ .input = "\xe8\x7a\x24\x4e\x2c\xc8\x5e\x82",
+ .ilen = 8,
+ .result = "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .rlen = 8,
+ }, { /* Vary the keylength... */
+ .key = "\xf0\xe1\xd2\xc3\xb4\xa5\x96\x87"
+ "\x78\x69\x5a\x4b\x3c\x2d\x1e\x0f",
+ .klen = 16,
+ .input = "\x93\x14\x28\x87\xee\x3b\xe1\x5c",
+ .ilen = 8,
+ .result = "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .rlen = 8,
+ }, {
+ .key = "\xf0\xe1\xd2\xc3\xb4\xa5\x96\x87"
+ "\x78\x69\x5a\x4b\x3c\x2d\x1e\x0f"
+ "\x00\x11\x22\x33\x44",
+ .klen = 21,
+ .input = "\xe6\xf5\x1e\xd7\x9b\x9d\xb2\x1f",
+ .ilen = 8,
+ .result = "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .rlen = 8,
+ }, { /* Generated with bf488, using OpenSSL, Libgcrypt and Nettle */
+ .key = "\xf0\xe1\xd2\xc3\xb4\xa5\x96\x87"
+ "\x78\x69\x5a\x4b\x3c\x2d\x1e\x0f"
+ "\x00\x11\x22\x33\x44\x55\x66\x77"
+ "\x04\x68\x91\x04\xc2\xfd\x3b\x2f"
+ "\x58\x40\x23\x64\x1a\xba\x61\x76"
+ "\x1f\x1f\x1f\x1f\x0e\x0e\x0e\x0e"
+ "\xff\xff\xff\xff\xff\xff\xff\xff",
+ .klen = 56,
+ .input = "\xc0\x45\x04\x01\x2e\x4e\x1f\x53",
+ .ilen = 8,
+ .result = "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .rlen = 8,
+ },
+};
+
+static struct cipher_testvec bf_cbc_enc_tv_template[] = {
+ { /* From OpenSSL */
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef"
+ "\xf0\xe1\xd2\xc3\xb4\xa5\x96\x87",
+ .klen = 16,
+ .iv = "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .input = "\x37\x36\x35\x34\x33\x32\x31\x20"
+ "\x4e\x6f\x77\x20\x69\x73\x20\x74"
+ "\x68\x65\x20\x74\x69\x6d\x65\x20"
+ "\x66\x6f\x72\x20\x00\x00\x00\x00",
+ .ilen = 32,
+ .result = "\x6b\x77\xb4\xd6\x30\x06\xde\xe6"
+ "\x05\xb1\x56\xe2\x74\x03\x97\x93"
+ "\x58\xde\xb9\xe7\x15\x46\x16\xd9"
+ "\x59\xf1\x65\x2b\xd5\xff\x92\xcc",
+ .rlen = 32,
+ },
+};
+
+static struct cipher_testvec bf_cbc_dec_tv_template[] = {
+ { /* From OpenSSL */
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef"
+ "\xf0\xe1\xd2\xc3\xb4\xa5\x96\x87",
+ .klen = 16,
+ .iv = "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .input = "\x6b\x77\xb4\xd6\x30\x06\xde\xe6"
+ "\x05\xb1\x56\xe2\x74\x03\x97\x93"
+ "\x58\xde\xb9\xe7\x15\x46\x16\xd9"
+ "\x59\xf1\x65\x2b\xd5\xff\x92\xcc",
+ .ilen = 32,
+ .result = "\x37\x36\x35\x34\x33\x32\x31\x20"
+ "\x4e\x6f\x77\x20\x69\x73\x20\x74"
+ "\x68\x65\x20\x74\x69\x6d\x65\x20"
+ "\x66\x6f\x72\x20\x00\x00\x00\x00",
+ .rlen = 32,
+ },
+};
+
+/*
+ * Twofish test vectors.
+ */
+#define TF_ENC_TEST_VECTORS 3
+#define TF_DEC_TEST_VECTORS 3
+#define TF_CBC_ENC_TEST_VECTORS 4
+#define TF_CBC_DEC_TEST_VECTORS 4
+
+static struct cipher_testvec tf_enc_tv_template[] = {
+ {
+ .key = zeroed_string,
+ .klen = 16,
+ .input = zeroed_string,
+ .ilen = 16,
+ .result = "\x9f\x58\x9f\x5c\xf6\x12\x2c\x32"
+ "\xb6\xbf\xec\x2f\x2a\xe8\xc3\x5a",
+ .rlen = 16,
+ }, {
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef"
+ "\xfe\xdc\xba\x98\x76\x54\x32\x10"
+ "\x00\x11\x22\x33\x44\x55\x66\x77",
+ .klen = 24,
+ .input = zeroed_string,
+ .ilen = 16,
+ .result = "\xcf\xd1\xd2\xe5\xa9\xbe\x9c\xdf"
+ "\x50\x1f\x13\xb8\x92\xbd\x22\x48",
+ .rlen = 16,
+ }, {
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef"
+ "\xfe\xdc\xba\x98\x76\x54\x32\x10"
+ "\x00\x11\x22\x33\x44\x55\x66\x77"
+ "\x88\x99\xaa\xbb\xcc\xdd\xee\xff",
+ .klen = 32,
+ .input = zeroed_string,
+ .ilen = 16,
+ .result = "\x37\x52\x7b\xe0\x05\x23\x34\xb8"
+ "\x9f\x0c\xfc\xca\xe8\x7c\xfa\x20",
+ .rlen = 16,
+ },
+};
+
+static struct cipher_testvec tf_dec_tv_template[] = {
+ {
+ .key = zeroed_string,
+ .klen = 16,
+ .input = "\x9f\x58\x9f\x5c\xf6\x12\x2c\x32"
+ "\xb6\xbf\xec\x2f\x2a\xe8\xc3\x5a",
+ .ilen = 16,
+ .result = zeroed_string,
+ .rlen = 16,
+ }, {
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef"
+ "\xfe\xdc\xba\x98\x76\x54\x32\x10"
+ "\x00\x11\x22\x33\x44\x55\x66\x77",
+ .klen = 24,
+ .input = "\xcf\xd1\xd2\xe5\xa9\xbe\x9c\xdf"
+ "\x50\x1f\x13\xb8\x92\xbd\x22\x48",
+ .ilen = 16,
+ .result = zeroed_string,
+ .rlen = 16,
+ }, {
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef"
+ "\xfe\xdc\xba\x98\x76\x54\x32\x10"
+ "\x00\x11\x22\x33\x44\x55\x66\x77"
+ "\x88\x99\xaa\xbb\xcc\xdd\xee\xff",
+ .klen = 32,
+ .input = "\x37\x52\x7b\xe0\x05\x23\x34\xb8"
+ "\x9f\x0c\xfc\xca\xe8\x7c\xfa\x20",
+ .ilen = 16,
+ .result = zeroed_string,
+ .rlen = 16,
+ },
+};
+
+static struct cipher_testvec tf_cbc_enc_tv_template[] = {
+ { /* Generated with Nettle */
+ .key = zeroed_string,
+ .klen = 16,
+ .iv = zeroed_string,
+ .input = zeroed_string,
+ .ilen = 16,
+ .result = "\x9f\x58\x9f\x5c\xf6\x12\x2c\x32"
+ "\xb6\xbf\xec\x2f\x2a\xe8\xc3\x5a",
+ .rlen = 16,
+ }, {
+ .key = zeroed_string,
+ .klen = 16,
+ .iv = "\x9f\x58\x9f\x5c\xf6\x12\x2c\x32"
+ "\xb6\xbf\xec\x2f\x2a\xe8\xc3\x5a",
+ .input = zeroed_string,
+ .ilen = 16,
+ .result = "\xd4\x91\xdb\x16\xe7\xb1\xc3\x9e"
+ "\x86\xcb\x08\x6b\x78\x9f\x54\x19",
+ .rlen = 16,
+ }, {
+ .key = zeroed_string,
+ .klen = 16,
+ .iv = "\xd4\x91\xdb\x16\xe7\xb1\xc3\x9e"
+ "\x86\xcb\x08\x6b\x78\x9f\x54\x19",
+ .input = zeroed_string,
+ .ilen = 16,
+ .result = "\x05\xef\x8c\x61\xa8\x11\x58\x26"
+ "\x34\xba\x5c\xb7\x10\x6a\xa6\x41",
+ .rlen = 16,
+ }, {
+ .key = zeroed_string,
+ .klen = 16,
+ .iv = zeroed_string,
+ .input = zeroed_string,
+ .ilen = 48,
+ .result = "\x9f\x58\x9f\x5c\xf6\x12\x2c\x32"
+ "\xb6\xbf\xec\x2f\x2a\xe8\xc3\x5a"
+ "\xd4\x91\xdb\x16\xe7\xb1\xc3\x9e"
+ "\x86\xcb\x08\x6b\x78\x9f\x54\x19"
+ "\x05\xef\x8c\x61\xa8\x11\x58\x26"
+ "\x34\xba\x5c\xb7\x10\x6a\xa6\x41",
+ .rlen = 48,
+ },
+};
+
+static struct cipher_testvec tf_cbc_dec_tv_template[] = {
+ { /* Reverse of the first four above */
+ .key = zeroed_string,
+ .klen = 16,
+ .iv = zeroed_string,
+ .input = "\x9f\x58\x9f\x5c\xf6\x12\x2c\x32"
+ "\xb6\xbf\xec\x2f\x2a\xe8\xc3\x5a",
+ .ilen = 16,
+ .result = zeroed_string,
+ .rlen = 16,
+ }, {
+ .key = zeroed_string,
+ .klen = 16,
+ .iv = "\x9f\x58\x9f\x5c\xf6\x12\x2c\x32"
+ "\xb6\xbf\xec\x2f\x2a\xe8\xc3\x5a",
+ .input = "\xd4\x91\xdb\x16\xe7\xb1\xc3\x9e"
+ "\x86\xcb\x08\x6b\x78\x9f\x54\x19",
+ .ilen = 16,
+ .result = zeroed_string,
+ .rlen = 16,
+ }, {
+ .key = zeroed_string,
+ .klen = 16,
+ .iv = "\xd4\x91\xdb\x16\xe7\xb1\xc3\x9e"
+ "\x86\xcb\x08\x6b\x78\x9f\x54\x19",
+ .input = "\x05\xef\x8c\x61\xa8\x11\x58\x26"
+ "\x34\xba\x5c\xb7\x10\x6a\xa6\x41",
+ .ilen = 16,
+ .result = zeroed_string,
+ .rlen = 16,
+ }, {
+ .key = zeroed_string,
+ .klen = 16,
+ .iv = zeroed_string,
+ .input = "\x9f\x58\x9f\x5c\xf6\x12\x2c\x32"
+ "\xb6\xbf\xec\x2f\x2a\xe8\xc3\x5a"
+ "\xd4\x91\xdb\x16\xe7\xb1\xc3\x9e"
+ "\x86\xcb\x08\x6b\x78\x9f\x54\x19"
+ "\x05\xef\x8c\x61\xa8\x11\x58\x26"
+ "\x34\xba\x5c\xb7\x10\x6a\xa6\x41",
+ .ilen = 48,
+ .result = zeroed_string,
+ .rlen = 48,
+ },
+};
+
+/*
+ * Serpent test vectors. These are backwards because Serpent writes
+ * octet sequences in right-to-left mode.
+ */
+#define SERPENT_ENC_TEST_VECTORS 4
+#define SERPENT_DEC_TEST_VECTORS 4
+
+#define TNEPRES_ENC_TEST_VECTORS 4
+#define TNEPRES_DEC_TEST_VECTORS 4
+
+static struct cipher_testvec serpent_enc_tv_template[] = {
+ {
+ .input = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .ilen = 16,
+ .result = "\x12\x07\xfc\xce\x9b\xd0\xd6\x47"
+ "\x6a\xe9\x8f\xbe\xd1\x43\xa0\xe2",
+ .rlen = 16,
+ }, {
+ .key = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .klen = 16,
+ .input = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .ilen = 16,
+ .result = "\x4c\x7d\x8a\x32\x80\x72\xa2\x2c"
+ "\x82\x3e\x4a\x1f\x3a\xcd\xa1\x6d",
+ .rlen = 16,
+ }, {
+ .key = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
+ .klen = 32,
+ .input = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .ilen = 16,
+ .result = "\xde\x26\x9f\xf8\x33\xe4\x32\xb8"
+ "\x5b\x2e\x88\xd2\x70\x1c\xe7\x5c",
+ .rlen = 16,
+ }, {
+ .key = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80",
+ .klen = 16,
+ .input = zeroed_string,
+ .ilen = 16,
+ .result = "\xdd\xd2\x6b\x98\xa5\xff\xd8\x2c"
+ "\x05\x34\x5a\x9d\xad\xbf\xaf\x49",
+ .rlen = 16,
+ },
+};
+
+static struct cipher_testvec tnepres_enc_tv_template[] = {
+ { /* KeySize=128, PT=0, I=1 */
+ .input = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .key = "\x80\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .klen = 16,
+ .ilen = 16,
+ .result = "\x49\xaf\xbf\xad\x9d\x5a\x34\x05"
+ "\x2c\xd8\xff\xa5\x98\x6b\xd2\xdd",
+ .rlen = 16,
+ }, { /* KeySize=192, PT=0, I=1 */
+ .key = "\x80\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .klen = 24,
+ .input = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .ilen = 16,
+ .result = "\xe7\x8e\x54\x02\xc7\x19\x55\x68"
+ "\xac\x36\x78\xf7\xa3\xf6\x0c\x66",
+ .rlen = 16,
+ }, { /* KeySize=256, PT=0, I=1 */
+ .key = "\x80\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .klen = 32,
+ .input = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .ilen = 16,
+ .result = "\xab\xed\x96\xe7\x66\xbf\x28\xcb"
+ "\xc0\xeb\xd2\x1a\x82\xef\x08\x19",
+ .rlen = 16,
+ }, { /* KeySize=256, I=257 */
+ .key = "\x1f\x1e\x1d\x1c\x1b\x1a\x19\x18"
+ "\x17\x16\x15\x14\x13\x12\x11\x10"
+ "\x0f\x0e\x0d\x0c\x0b\x0a\x09\x08"
+ "\x07\x06\x05\x04\x03\x02\x01\x00",
+ .klen = 32,
+ .input = "\x0f\x0e\x0d\x0c\x0b\x0a\x09\x08"
+ "\x07\x06\x05\x04\x03\x02\x01\x00",
+ .ilen = 16,
+ .result = "\x5c\xe7\x1c\x70\xd2\x88\x2e\x5b"
+ "\xb8\x32\xe4\x33\xf8\x9f\x26\xde",
+ .rlen = 16,
+ },
+};
+
+
+static struct cipher_testvec serpent_dec_tv_template[] = {
+ {
+ .input = "\x12\x07\xfc\xce\x9b\xd0\xd6\x47"
+ "\x6a\xe9\x8f\xbe\xd1\x43\xa0\xe2",
+ .ilen = 16,
+ .result = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .rlen = 16,
+ }, {
+ .key = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .klen = 16,
+ .input = "\x4c\x7d\x8a\x32\x80\x72\xa2\x2c"
+ "\x82\x3e\x4a\x1f\x3a\xcd\xa1\x6d",
+ .ilen = 16,
+ .result = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .rlen = 16,
+ }, {
+ .key = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
+ .klen = 32,
+ .input = "\xde\x26\x9f\xf8\x33\xe4\x32\xb8"
+ "\x5b\x2e\x88\xd2\x70\x1c\xe7\x5c",
+ .ilen = 16,
+ .result = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .rlen = 16,
+ }, {
+ .key = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80",
+ .klen = 16,
+ .input = "\xdd\xd2\x6b\x98\xa5\xff\xd8\x2c"
+ "\x05\x34\x5a\x9d\xad\xbf\xaf\x49",
+ .ilen = 16,
+ .result = zeroed_string,
+ .rlen = 16,
+ },
+};
+
+static struct cipher_testvec tnepres_dec_tv_template[] = {
+ {
+ .input = "\x41\xcc\x6b\x31\x59\x31\x45\x97"
+ "\x6d\x6f\xbb\x38\x4b\x37\x21\x28",
+ .ilen = 16,
+ .result = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .rlen = 16,
+ }, {
+ .key = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .klen = 16,
+ .input = "\xea\xf4\xd7\xfc\xd8\x01\x34\x47"
+ "\x81\x45\x0b\xfa\x0c\xd6\xad\x6e",
+ .ilen = 16,
+ .result = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .rlen = 16,
+ }, {
+ .key = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
+ .klen = 32,
+ .input = "\x64\xa9\x1a\x37\xed\x9f\xe7\x49"
+ "\xa8\x4e\x76\xd6\xf5\x0d\x78\xee",
+ .ilen = 16,
+ .result = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .rlen = 16,
+ }, { /* KeySize=128, I=121 */
+ .key = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80",
+ .klen = 16,
+ .input = "\x3d\xda\xbf\xc0\x06\xda\xab\x06"
+ "\x46\x2a\xf4\xef\x81\x54\x4e\x26",
+ .ilen = 16,
+ .result = zeroed_string,
+ .rlen = 16,
+ },
+};
+
+
+/* Cast6 test vectors from RFC 2612 */
+#define CAST6_ENC_TEST_VECTORS 3
+#define CAST6_DEC_TEST_VECTORS 3
+
+static struct cipher_testvec cast6_enc_tv_template[] = {
+ {
+ .key = "\x23\x42\xbb\x9e\xfa\x38\x54\x2c"
+ "\x0a\xf7\x56\x47\xf2\x9f\x61\x5d",
+ .klen = 16,
+ .input = zeroed_string,
+ .ilen = 16,
+ .result = "\xc8\x42\xa0\x89\x72\xb4\x3d\x20"
+ "\x83\x6c\x91\xd1\xb7\x53\x0f\x6b",
+ .rlen = 16,
+ }, {
+ .key = "\x23\x42\xbb\x9e\xfa\x38\x54\x2c"
+ "\xbe\xd0\xac\x83\x94\x0a\xc2\x98"
+ "\xba\xc7\x7a\x77\x17\x94\x28\x63",
+ .klen = 24,
+ .input = zeroed_string,
+ .ilen = 16,
+ .result = "\x1b\x38\x6c\x02\x10\xdc\xad\xcb"
+ "\xdd\x0e\x41\xaa\x08\xa7\xa7\xe8",
+ .rlen = 16,
+ }, {
+ .key = "\x23\x42\xbb\x9e\xfa\x38\x54\x2c"
+ "\xbe\xd0\xac\x83\x94\x0a\xc2\x98"
+ "\x8d\x7c\x47\xce\x26\x49\x08\x46"
+ "\x1c\xc1\xb5\x13\x7a\xe6\xb6\x04",
+ .klen = 32,
+ .input = zeroed_string,
+ .ilen = 16,
+ .result = "\x4f\x6a\x20\x38\x28\x68\x97\xb9"
+ "\xc9\x87\x01\x36\x55\x33\x17\xfa",
+ .rlen = 16,
+ },
+};
+
+static struct cipher_testvec cast6_dec_tv_template[] = {
+ {
+ .key = "\x23\x42\xbb\x9e\xfa\x38\x54\x2c"
+ "\x0a\xf7\x56\x47\xf2\x9f\x61\x5d",
+ .klen = 16,
+ .input = "\xc8\x42\xa0\x89\x72\xb4\x3d\x20"
+ "\x83\x6c\x91\xd1\xb7\x53\x0f\x6b",
+ .ilen = 16,
+ .result = zeroed_string,
+ .rlen = 16,
+ }, {
+ .key = "\x23\x42\xbb\x9e\xfa\x38\x54\x2c"
+ "\xbe\xd0\xac\x83\x94\x0a\xc2\x98"
+ "\xba\xc7\x7a\x77\x17\x94\x28\x63",
+ .klen = 24,
+ .input = "\x1b\x38\x6c\x02\x10\xdc\xad\xcb"
+ "\xdd\x0e\x41\xaa\x08\xa7\xa7\xe8",
+ .ilen = 16,
+ .result = zeroed_string,
+ .rlen = 16,
+ }, {
+ .key = "\x23\x42\xbb\x9e\xfa\x38\x54\x2c"
+ "\xbe\xd0\xac\x83\x94\x0a\xc2\x98"
+ "\x8d\x7c\x47\xce\x26\x49\x08\x46"
+ "\x1c\xc1\xb5\x13\x7a\xe6\xb6\x04",
+ .klen = 32,
+ .input = "\x4f\x6a\x20\x38\x28\x68\x97\xb9"
+ "\xc9\x87\x01\x36\x55\x33\x17\xfa",
+ .ilen = 16,
+ .result = zeroed_string,
+ .rlen = 16,
+ },
+};
+
+
+/*
+ * AES test vectors.
+ */
+#if !defined(CONFIG_CRYPTO_DEV_AES) && !defined(CONFIG_CRYPTO_ASYNC_AES)
+#define AES_ENC_TEST_VECTORS 3
+#define AES_DEC_TEST_VECTORS 3
+#define AES_CBC_ENC_TEST_VECTORS 4
+#define AES_CBC_DEC_TEST_VECTORS 4
+#define AES_LRW_ENC_TEST_VECTORS 8
+#define AES_LRW_DEC_TEST_VECTORS 8
+#define AES_XTS_ENC_TEST_VECTORS 4
+#define AES_XTS_DEC_TEST_VECTORS 4
+#define AES_CTR_ENC_TEST_VECTORS 3
+#define AES_CTR_DEC_TEST_VECTORS 3
+#define AES_CTR_3686_ENC_TEST_VECTORS 7
+#define AES_CTR_3686_DEC_TEST_VECTORS 6
+#define AES_GCM_ENC_TEST_VECTORS 9
+#define AES_GCM_DEC_TEST_VECTORS 8
+#define AES_CCM_ENC_TEST_VECTORS 7
+#define AES_CCM_DEC_TEST_VECTORS 7
+#define AES_CCM_4309_ENC_TEST_VECTORS 7
+#define AES_CCM_4309_DEC_TEST_VECTORS 10
+#else
+#define AES_ENC_TEST_VECTORS 3
+#define AES_DEC_TEST_VECTORS 3
+#define AES_CBC_ENC_TEST_VECTORS 3
+#define AES_CBC_DEC_TEST_VECTORS 3
+#define AES_CTR_ENC_TEST_VECTORS 3
+#define AES_CTR_DEC_TEST_VECTORS 3
+#define AES_GCM_ENC_TEST_VECTORS 9
+#define AES_GCM_DEC_TEST_VECTORS 8
+#define AES_CCM_ENC_TEST_VECTORS 7
+#define AES_CCM_DEC_TEST_VECTORS 7
+#define AES_CCM_4309_ENC_TEST_VECTORS 7
+#define AES_CCM_4309_DEC_TEST_VECTORS 10
+#define AES_CTR_3686_ENC_TEST_VECTORS 6
+#define AES_CTR_3686_DEC_TEST_VECTORS 6
+#endif /* CONFIG_CRYPTO_DEV_AES */
+
+static struct cipher_testvec aes_enc_tv_template[] = {
+ { /* From FIPS-197 */
+ .key = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .klen = 16,
+ .input = "\x00\x11\x22\x33\x44\x55\x66\x77"
+ "\x88\x99\xaa\xbb\xcc\xdd\xee\xff",
+ .ilen = 16,
+ .result = "\x69\xc4\xe0\xd8\x6a\x7b\x04\x30"
+ "\xd8\xcd\xb7\x80\x70\xb4\xc5\x5a",
+ .rlen = 16,
+ }, {
+ .key = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17",
+ .klen = 24,
+ .input = "\x00\x11\x22\x33\x44\x55\x66\x77"
+ "\x88\x99\xaa\xbb\xcc\xdd\xee\xff",
+ .ilen = 16,
+ .result = "\xdd\xa9\x7c\xa4\x86\x4c\xdf\xe0"
+ "\x6e\xaf\x70\xa0\xec\x0d\x71\x91",
+ .rlen = 16,
+ }, {
+ .key = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
+ .klen = 32,
+ .input = "\x00\x11\x22\x33\x44\x55\x66\x77"
+ "\x88\x99\xaa\xbb\xcc\xdd\xee\xff",
+ .ilen = 16,
+ .result = "\x8e\xa2\xb7\xca\x51\x67\x45\xbf"
+ "\xea\xfc\x49\x90\x4b\x49\x60\x89",
+ .rlen = 16,
+ },
+};
+
+static struct cipher_testvec aes_dec_tv_template[] = {
+ { /* From FIPS-197 */
+ .key = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .klen = 16,
+ .input = "\x69\xc4\xe0\xd8\x6a\x7b\x04\x30"
+ "\xd8\xcd\xb7\x80\x70\xb4\xc5\x5a",
+ .ilen = 16,
+ .result = "\x00\x11\x22\x33\x44\x55\x66\x77"
+ "\x88\x99\xaa\xbb\xcc\xdd\xee\xff",
+ .rlen = 16,
+ }, {
+ .key = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17",
+ .klen = 24,
+ .input = "\xdd\xa9\x7c\xa4\x86\x4c\xdf\xe0"
+ "\x6e\xaf\x70\xa0\xec\x0d\x71\x91",
+ .ilen = 16,
+ .result = "\x00\x11\x22\x33\x44\x55\x66\x77"
+ "\x88\x99\xaa\xbb\xcc\xdd\xee\xff",
+ .rlen = 16,
+ }, {
+ .key = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
+ .klen = 32,
+ .input = "\x8e\xa2\xb7\xca\x51\x67\x45\xbf"
+ "\xea\xfc\x49\x90\x4b\x49\x60\x89",
+ .ilen = 16,
+ .result = "\x00\x11\x22\x33\x44\x55\x66\x77"
+ "\x88\x99\xaa\xbb\xcc\xdd\xee\xff",
+ .rlen = 16,
+ },
+};
+
+static struct cipher_testvec aes_cbc_enc_tv_template[] = {
+ { /* From RFC 3602 */
+ .key = "\x06\xa9\x21\x40\x36\xb8\xa1\x5b"
+ "\x51\x2e\x03\xd5\x34\x12\x00\x06",
+ .klen = 16,
+ .iv = "\x3d\xaf\xba\x42\x9d\x9e\xb4\x30"
+ "\xb4\x22\xda\x80\x2c\x9f\xac\x41",
+ .input = "Single block msg",
+ .ilen = 16,
+ .result = "\xe3\x53\x77\x9c\x10\x79\xae\xb8"
+ "\x27\x08\x94\x2d\xbe\x77\x18\x1a",
+ .rlen = 16,
+ }, {
+ .key = "\xc2\x86\x69\x6d\x88\x7c\x9a\xa0"
+ "\x61\x1b\xbb\x3e\x20\x25\xa4\x5a",
+ .klen = 16,
+ .iv = "\x56\x2e\x17\x99\x6d\x09\x3d\x28"
+ "\xdd\xb3\xba\x69\x5a\x2e\x6f\x58",
+ .input = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
+ .ilen = 32,
+ .result = "\xd2\x96\xcd\x94\xc2\xcc\xcf\x8a"
+ "\x3a\x86\x30\x28\xb5\xe1\xdc\x0a"
+ "\x75\x86\x60\x2d\x25\x3c\xff\xf9"
+ "\x1b\x82\x66\xbe\xa6\xd6\x1a\xb1",
+ .rlen = 32,
+ }, { /* From NIST SP800-38A */
+ .key = "\x8e\x73\xb0\xf7\xda\x0e\x64\x52"
+ "\xc8\x10\xf3\x2b\x80\x90\x79\xe5"
+ "\x62\xf8\xea\xd2\x52\x2c\x6b\x7b",
+ .klen = 24,
+ .iv = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .input = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96"
+ "\xe9\x3d\x7e\x11\x73\x93\x17\x2a"
+ "\xae\x2d\x8a\x57\x1e\x03\xac\x9c"
+ "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51"
+ "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11"
+ "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef"
+ "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17"
+ "\xad\x2b\x41\x7b\xe6\x6c\x37\x10",
+ .ilen = 64,
+ .result = "\x4f\x02\x1d\xb2\x43\xbc\x63\x3d"
+ "\x71\x78\x18\x3a\x9f\xa0\x71\xe8"
+ "\xb4\xd9\xad\xa9\xad\x7d\xed\xf4"
+ "\xe5\xe7\x38\x76\x3f\x69\x14\x5a"
+ "\x57\x1b\x24\x20\x12\xfb\x7a\xe0"
+ "\x7f\xa9\xba\xac\x3d\xf1\x02\xe0"
+ "\x08\xb0\xe2\x79\x88\x59\x88\x81"
+ "\xd9\x20\xa9\xe6\x4f\x56\x15\xcd",
+ .rlen = 64,
+#if !defined(CONFIG_CRYPTO_DEV_AES) && !defined(CONFIG_CRYPTO_ASYNC_AES)
+ }, {
+ .key = "\x60\x3d\xeb\x10\x15\xca\x71\xbe"
+ "\x2b\x73\xae\xf0\x85\x7d\x77\x81"
+ "\x1f\x35\x2c\x07\x3b\x61\x08\xd7"
+ "\x2d\x98\x10\xa3\x09\x14\xdf\xf4",
+ .klen = 32,
+ .iv = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .input = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96"
+ "\xe9\x3d\x7e\x11\x73\x93\x17\x2a"
+ "\xae\x2d\x8a\x57\x1e\x03\xac\x9c"
+ "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51"
+ "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11"
+ "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef"
+ "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17"
+ "\xad\x2b\x41\x7b\xe6\x6c\x37\x10",
+ .ilen = 64,
+ .result = "\xf5\x8c\x4c\x04\xd6\xe5\xf1\xba"
+ "\x77\x9e\xab\xfb\x5f\x7b\xfb\xd6"
+ "\x9c\xfc\x4e\x96\x7e\xdb\x80\x8d"
+ "\x67\x9f\x77\x7b\xc6\x70\x2c\x7d"
+ "\x39\xf2\x33\x69\xa9\xd9\xba\xcf"
+ "\xa5\x30\xe2\x63\x04\x23\x14\x61"
+ "\xb2\xeb\x05\xe2\xc3\x9b\xe9\xfc"
+ "\xda\x6c\x19\x07\x8c\x6a\x9d\x1b",
+ .rlen = 64,
+#endif
+ },
+};
+
+static struct cipher_testvec aes_cbc_dec_tv_template[] = {
+ { /* From RFC 3602 */
+ .key = "\x06\xa9\x21\x40\x36\xb8\xa1\x5b"
+ "\x51\x2e\x03\xd5\x34\x12\x00\x06",
+ .klen = 16,
+ .iv = "\x3d\xaf\xba\x42\x9d\x9e\xb4\x30"
+ "\xb4\x22\xda\x80\x2c\x9f\xac\x41",
+ .input = "\xe3\x53\x77\x9c\x10\x79\xae\xb8"
+ "\x27\x08\x94\x2d\xbe\x77\x18\x1a",
+ .ilen = 16,
+ .result = "Single block msg",
+ .rlen = 16,
+ }, {
+ .key = "\xc2\x86\x69\x6d\x88\x7c\x9a\xa0"
+ "\x61\x1b\xbb\x3e\x20\x25\xa4\x5a",
+ .klen = 16,
+ .iv = "\x56\x2e\x17\x99\x6d\x09\x3d\x28"
+ "\xdd\xb3\xba\x69\x5a\x2e\x6f\x58",
+ .input = "\xd2\x96\xcd\x94\xc2\xcc\xcf\x8a"
+ "\x3a\x86\x30\x28\xb5\xe1\xdc\x0a"
+ "\x75\x86\x60\x2d\x25\x3c\xff\xf9"
+ "\x1b\x82\x66\xbe\xa6\xd6\x1a\xb1",
+ .ilen = 32,
+ .result = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
+ .rlen = 32,
+ }, { /* From NIST SP800-38A */
+ .key = "\x8e\x73\xb0\xf7\xda\x0e\x64\x52"
+ "\xc8\x10\xf3\x2b\x80\x90\x79\xe5"
+ "\x62\xf8\xea\xd2\x52\x2c\x6b\x7b",
+ .klen = 24,
+ .iv = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .input = "\x4f\x02\x1d\xb2\x43\xbc\x63\x3d"
+ "\x71\x78\x18\x3a\x9f\xa0\x71\xe8"
+ "\xb4\xd9\xad\xa9\xad\x7d\xed\xf4"
+ "\xe5\xe7\x38\x76\x3f\x69\x14\x5a"
+ "\x57\x1b\x24\x20\x12\xfb\x7a\xe0"
+ "\x7f\xa9\xba\xac\x3d\xf1\x02\xe0"
+ "\x08\xb0\xe2\x79\x88\x59\x88\x81"
+ "\xd9\x20\xa9\xe6\x4f\x56\x15\xcd",
+ .ilen = 64,
+ .result = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96"
+ "\xe9\x3d\x7e\x11\x73\x93\x17\x2a"
+ "\xae\x2d\x8a\x57\x1e\x03\xac\x9c"
+ "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51"
+ "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11"
+ "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef"
+ "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17"
+ "\xad\x2b\x41\x7b\xe6\x6c\x37\x10",
+ .rlen = 64,
+#if !defined(CONFIG_CRYPTO_DEV_AES) && !defined(CONFIG_CRYPTO_ASYNC_AES)
+ }, {
+ .key = "\x60\x3d\xeb\x10\x15\xca\x71\xbe"
+ "\x2b\x73\xae\xf0\x85\x7d\x77\x81"
+ "\x1f\x35\x2c\x07\x3b\x61\x08\xd7"
+ "\x2d\x98\x10\xa3\x09\x14\xdf\xf4",
+ .klen = 32,
+ .iv = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .input = "\xf5\x8c\x4c\x04\xd6\xe5\xf1\xba"
+ "\x77\x9e\xab\xfb\x5f\x7b\xfb\xd6"
+ "\x9c\xfc\x4e\x96\x7e\xdb\x80\x8d"
+ "\x67\x9f\x77\x7b\xc6\x70\x2c\x7d"
+ "\x39\xf2\x33\x69\xa9\xd9\xba\xcf"
+ "\xa5\x30\xe2\x63\x04\x23\x14\x61"
+ "\xb2\xeb\x05\xe2\xc3\x9b\xe9\xfc"
+ "\xda\x6c\x19\x07\x8c\x6a\x9d\x1b",
+ .ilen = 64,
+ .result = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96"
+ "\xe9\x3d\x7e\x11\x73\x93\x17\x2a"
+ "\xae\x2d\x8a\x57\x1e\x03\xac\x9c"
+ "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51"
+ "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11"
+ "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef"
+ "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17"
+ "\xad\x2b\x41\x7b\xe6\x6c\x37\x10",
+ .rlen = 64,
+#endif
+ },
+};
+
+#if !defined(CONFIG_CRYPTO_DEV_AES) && !defined(CONFIG_CRYPTO_ASYNC_AES)
+
+static struct cipher_testvec aes_lrw_enc_tv_template[] = {
+ /* from http://grouper.ieee.org/groups/1619/email/pdf00017.pdf */
+ { /* LRW-32-AES 1 */
+ .key = "\x45\x62\xac\x25\xf8\x28\x17\x6d"
+ "\x4c\x26\x84\x14\xb5\x68\x01\x85"
+ "\x25\x8e\x2a\x05\xe7\x3e\x9d\x03"
+ "\xee\x5a\x83\x0c\xcc\x09\x4c\x87",
+ .klen = 32,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x01",
+ .input = "\x30\x31\x32\x33\x34\x35\x36\x37"
+ "\x38\x39\x41\x42\x43\x44\x45\x46",
+ .ilen = 16,
+ .result = "\xf1\xb2\x73\xcd\x65\xa3\xdf\x5f"
+ "\xe9\x5d\x48\x92\x54\x63\x4e\xb8",
+ .rlen = 16,
+ }, { /* LRW-32-AES 2 */
+ .key = "\x59\x70\x47\x14\xf5\x57\x47\x8c"
+ "\xd7\x79\xe8\x0f\x54\x88\x79\x44"
+ "\x0d\x48\xf0\xb7\xb1\x5a\x53\xea"
+ "\x1c\xaa\x6b\x29\xc2\xca\xfb\xaf",
+ .klen = 32,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x02",
+ .input = "\x30\x31\x32\x33\x34\x35\x36\x37"
+ "\x38\x39\x41\x42\x43\x44\x45\x46",
+ .ilen = 16,
+ .result = "\x00\xc8\x2b\xae\x95\xbb\xcd\xe5"
+ "\x27\x4f\x07\x69\xb2\x60\xe1\x36",
+ .rlen = 16,
+ }, { /* LRW-32-AES 3 */
+ .key = "\xd8\x2a\x91\x34\xb2\x6a\x56\x50"
+ "\x30\xfe\x69\xe2\x37\x7f\x98\x47"
+ "\xcd\xf9\x0b\x16\x0c\x64\x8f\xb6"
+ "\xb0\x0d\x0d\x1b\xae\x85\x87\x1f",
+ .klen = 32,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x02\x00\x00\x00\x00",
+ .input = "\x30\x31\x32\x33\x34\x35\x36\x37"
+ "\x38\x39\x41\x42\x43\x44\x45\x46",
+ .ilen = 16,
+ .result = "\x76\x32\x21\x83\xed\x8f\xf1\x82"
+ "\xf9\x59\x62\x03\x69\x0e\x5e\x01",
+ .rlen = 16,
+ }, { /* LRW-32-AES 4 */
+ .key = "\x0f\x6a\xef\xf8\xd3\xd2\xbb\x15"
+ "\x25\x83\xf7\x3c\x1f\x01\x28\x74"
+ "\xca\xc6\xbc\x35\x4d\x4a\x65\x54"
+ "\x90\xae\x61\xcf\x7b\xae\xbd\xcc"
+ "\xad\xe4\x94\xc5\x4a\x29\xae\x70",
+ .klen = 40,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x01",
+ .input = "\x30\x31\x32\x33\x34\x35\x36\x37"
+ "\x38\x39\x41\x42\x43\x44\x45\x46",
+ .ilen = 16,
+ .result = "\x9c\x0f\x15\x2f\x55\xa2\xd8\xf0"
+ "\xd6\x7b\x8f\x9e\x28\x22\xbc\x41",
+ .rlen = 16,
+ }, { /* LRW-32-AES 5 */
+ .key = "\x8a\xd4\xee\x10\x2f\xbd\x81\xff"
+ "\xf8\x86\xce\xac\x93\xc5\xad\xc6"
+ "\xa0\x19\x07\xc0\x9d\xf7\xbb\xdd"
+ "\x52\x13\xb2\xb7\xf0\xff\x11\xd8"
+ "\xd6\x08\xd0\xcd\x2e\xb1\x17\x6f",
+ .klen = 40,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x02\x00\x00\x00\x00",
+ .input = "\x30\x31\x32\x33\x34\x35\x36\x37"
+ "\x38\x39\x41\x42\x43\x44\x45\x46",
+ .ilen = 16,
+ .result = "\xd4\x27\x6a\x7f\x14\x91\x3d\x65"
+ "\xc8\x60\x48\x02\x87\xe3\x34\x06",
+ .rlen = 16,
+ }, { /* LRW-32-AES 6 */
+ .key = "\xf8\xd4\x76\xff\xd6\x46\xee\x6c"
+ "\x23\x84\xcb\x1c\x77\xd6\x19\x5d"
+ "\xfe\xf1\xa9\xf3\x7b\xbc\x8d\x21"
+ "\xa7\x9c\x21\xf8\xcb\x90\x02\x89"
+ "\xa8\x45\x34\x8e\xc8\xc5\xb5\xf1"
+ "\x26\xf5\x0e\x76\xfe\xfd\x1b\x1e",
+ .klen = 48,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x01",
+ .input = "\x30\x31\x32\x33\x34\x35\x36\x37"
+ "\x38\x39\x41\x42\x43\x44\x45\x46",
+ .ilen = 16,
+ .result = "\xbd\x06\xb8\xe1\xdb\x98\x89\x9e"
+ "\xc4\x98\xe4\x91\xcf\x1c\x70\x2b",
+ .rlen = 16,
+ }, { /* LRW-32-AES 7 */
+ .key = "\xfb\x76\x15\xb2\x3d\x80\x89\x1d"
+ "\xd4\x70\x98\x0b\xc7\x95\x84\xc8"
+ "\xb2\xfb\x64\xce\x60\x97\x87\x8d"
+ "\x17\xfc\xe4\x5a\x49\xe8\x30\xb7"
+ "\x6e\x78\x17\xe7\x2d\x5e\x12\xd4"
+ "\x60\x64\x04\x7a\xf1\x2f\x9e\x0c",
+ .klen = 48,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x02\x00\x00\x00\x00",
+ .input = "\x30\x31\x32\x33\x34\x35\x36\x37"
+ "\x38\x39\x41\x42\x43\x44\x45\x46",
+ .ilen = 16,
+ .result = "\x5b\x90\x8e\xc1\xab\xdd\x67\x5f"
+ "\x3d\x69\x8a\x95\x53\xc8\x9c\xe5",
+ .rlen = 16,
+ }, {
+/* http://www.mail-archive.com/stds-p1619@listserv.ieee.org/msg00173.html */
+ .key = "\xf8\xd4\x76\xff\xd6\x46\xee\x6c"
+ "\x23\x84\xcb\x1c\x77\xd6\x19\x5d"
+ "\xfe\xf1\xa9\xf3\x7b\xbc\x8d\x21"
+ "\xa7\x9c\x21\xf8\xcb\x90\x02\x89"
+ "\xa8\x45\x34\x8e\xc8\xc5\xb5\xf1"
+ "\x26\xf5\x0e\x76\xfe\xfd\x1b\x1e",
+ .klen = 48,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x01",
+ .input = "\x05\x11\xb7\x18\xab\xc6\x2d\xac"
+ "\x70\x5d\xf6\x22\x94\xcd\xe5\x6c"
+ "\x17\x6b\xf6\x1c\xf0\xf3\x6e\xf8"
+ "\x50\x38\x1f\x71\x49\xb6\x57\xd6"
+ "\x8f\xcb\x8d\x6b\xe3\xa6\x29\x90"
+ "\xfe\x2a\x62\x82\xae\x6d\x8b\xf6"
+ "\xad\x1e\x9e\x20\x5f\x38\xbe\x04"
+ "\xda\x10\x8e\xed\xa2\xa4\x87\xab"
+ "\xda\x6b\xb4\x0c\x75\xba\xd3\x7c"
+ "\xc9\xac\x42\x31\x95\x7c\xc9\x04"
+ "\xeb\xd5\x6e\x32\x69\x8a\xdb\xa6"
+ "\x15\xd7\x3f\x4f\x2f\x66\x69\x03"
+ "\x9c\x1f\x54\x0f\xde\x1f\xf3\x65"
+ "\x4c\x96\x12\xed\x7c\x92\x03\x01"
+ "\x6f\xbc\x35\x93\xac\xf1\x27\xf1"
+ "\xb4\x96\x82\x5a\x5f\xb0\xa0\x50"
+ "\x89\xa4\x8e\x66\x44\x85\xcc\xfd"
+ "\x33\x14\x70\xe3\x96\xb2\xc3\xd3"
+ "\xbb\x54\x5a\x1a\xf9\x74\xa2\xc5"
+ "\x2d\x64\x75\xdd\xb4\x54\xe6\x74"
+ "\x8c\xd3\x9d\x9e\x86\xab\x51\x53"
+ "\xb7\x93\x3e\x6f\xd0\x4e\x2c\x40"
+ "\xf6\xa8\x2e\x3e\x9d\xf4\x66\xa5"
+ "\x76\x12\x73\x44\x1a\x56\xd7\x72"
+ "\x88\xcd\x21\x8c\x4c\x0f\xfe\xda"
+ "\x95\xe0\x3a\xa6\xa5\x84\x46\xcd"
+ "\xd5\x3e\x9d\x3a\xe2\x67\xe6\x60"
+ "\x1a\xe2\x70\x85\x58\xc2\x1b\x09"
+ "\xe1\xd7\x2c\xca\xad\xa8\x8f\xf9"
+ "\xac\xb3\x0e\xdb\xca\x2e\xe2\xb8"
+ "\x51\x71\xd9\x3c\x6c\xf1\x56\xf8"
+ "\xea\x9c\xf1\xfb\x0c\xe6\xb7\x10"
+ "\x1c\xf8\xa9\x7c\xe8\x53\x35\xc1"
+ "\x90\x3e\x76\x4a\x74\xa4\x21\x2c"
+ "\xf6\x2c\x4e\x0f\x94\x3a\x88\x2e"
+ "\x41\x09\x6a\x33\x7d\xf6\xdd\x3f"
+ "\x8d\x23\x31\x74\x84\xeb\x88\x6e"
+ "\xcc\xb9\xbc\x22\x83\x19\x07\x22"
+ "\xa5\x2d\xdf\xa5\xf3\x80\x85\x78"
+ "\x84\x39\x6a\x6d\x6a\x99\x4f\xa5"
+ "\x15\xfe\x46\xb0\xe4\x6c\xa5\x41"
+ "\x3c\xce\x8f\x42\x60\x71\xa7\x75"
+ "\x08\x40\x65\x8a\x82\xbf\xf5\x43"
+ "\x71\x96\xa9\x4d\x44\x8a\x20\xbe"
+ "\xfa\x4d\xbb\xc0\x7d\x31\x96\x65"
+ "\xe7\x75\xe5\x3e\xfd\x92\x3b\xc9"
+ "\x55\xbb\x16\x7e\xf7\xc2\x8c\xa4"
+ "\x40\x1d\xe5\xef\x0e\xdf\xe4\x9a"
+ "\x62\x73\x65\xfd\x46\x63\x25\x3d"
+ "\x2b\xaf\xe5\x64\xfe\xa5\x5c\xcf"
+ "\x24\xf3\xb4\xac\x64\xba\xdf\x4b"
+ "\xc6\x96\x7d\x81\x2d\x8d\x97\xf7"
+ "\xc5\x68\x77\x84\x32\x2b\xcc\x85"
+ "\x74\x96\xf0\x12\x77\x61\xb9\xeb"
+ "\x71\xaa\x82\xcb\x1c\xdb\x89\xc8"
+ "\xc6\xb5\xe3\x5c\x7d\x39\x07\x24"
+ "\xda\x39\x87\x45\xc0\x2b\xbb\x01"
+ "\xac\xbc\x2a\x5c\x7f\xfc\xe8\xce"
+ "\x6d\x9c\x6f\xed\xd3\xc1\xa1\xd6"
+ "\xc5\x55\xa9\x66\x2f\xe1\xc8\x32"
+ "\xa6\x5d\xa4\x3a\x98\x73\xe8\x45"
+ "\xa4\xc7\xa8\xb4\xf6\x13\x03\xf6"
+ "\xe9\x2e\xc4\x29\x0f\x84\xdb\xc4"
+ "\x21\xc4\xc2\x75\x67\x89\x37\x0a",
+ .ilen = 512,
+ .result = "\x1a\x1d\xa9\x30\xad\xf9\x2f\x9b"
+ "\xb6\x1d\xae\xef\xf0\x2f\xf8\x5a"
+ "\x39\x3c\xbf\x2a\xb2\x45\xb2\x23"
+ "\x1b\x63\x3c\xcf\xaa\xbe\xcf\x4e"
+ "\xfa\xe8\x29\xc2\x20\x68\x2b\x3c"
+ "\x2e\x8b\xf7\x6e\x25\xbd\xe3\x3d"
+ "\x66\x27\xd6\xaf\xd6\x64\x3e\xe3"
+ "\xe8\x58\x46\x97\x39\x51\x07\xde"
+ "\xcb\x37\xbc\xa9\xc0\x5f\x75\xc3"
+ "\x0e\x84\x23\x1d\x16\xd4\x1c\x59"
+ "\x9c\x1a\x02\x55\xab\x3a\x97\x1d"
+ "\xdf\xdd\xc7\x06\x51\xd7\x70\xae"
+ "\x23\xc6\x8c\xf5\x1e\xa0\xe5\x82"
+ "\xb8\xb2\xbf\x04\xa0\x32\x8e\x68"
+ "\xeb\xaf\x6e\x2d\x94\x22\x2f\xce"
+ "\x4c\xb5\x59\xe2\xa2\x2f\xa0\x98"
+ "\x1a\x97\xc6\xd4\xb5\x00\x59\xf2"
+ "\x84\x14\x72\xb1\x9a\x6e\xa3\x7f"
+ "\xea\x20\xe7\xcb\x65\x77\x3a\xdf"
+ "\xc8\x97\x67\x15\xc2\x2a\x27\xcc"
+ "\x18\x55\xa1\x24\x0b\x24\x24\xaf"
+ "\x5b\xec\x68\xb8\xc8\xf5\xba\x63"
+ "\xff\xed\x89\xce\xd5\x3d\x88\xf3"
+ "\x25\xef\x05\x7c\x3a\xef\xeb\xd8"
+ "\x7a\x32\x0d\xd1\x1e\x58\x59\x99"
+ "\x90\x25\xb5\x26\xb0\xe3\x2b\x6c"
+ "\x4c\xa9\x8b\x84\x4f\x5e\x01\x50"
+ "\x41\x30\x58\xc5\x62\x74\x52\x1d"
+ "\x45\x24\x6a\x42\x64\x4f\x97\x1c"
+ "\xa8\x66\xb5\x6d\x79\xd4\x0d\x48"
+ "\xc5\x5f\xf3\x90\x32\xdd\xdd\xe1"
+ "\xe4\xa9\x9f\xfc\xc3\x52\x5a\x46"
+ "\xe4\x81\x84\x95\x36\x59\x7a\x6b"
+ "\xaa\xb3\x60\xad\xce\x9f\x9f\x28"
+ "\xe0\x01\x75\x22\xc4\x4e\xa9\x62"
+ "\x5c\x62\x0d\x00\xcb\x13\xe8\x43"
+ "\x72\xd4\x2d\x53\x46\xb5\xd1\x16"
+ "\x22\x18\xdf\x34\x33\xf5\xd6\x1c"
+ "\xb8\x79\x78\x97\x94\xff\x72\x13"
+ "\x4c\x27\xfc\xcb\xbf\x01\x53\xa6"
+ "\xb4\x50\x6e\xde\xdf\xb5\x43\xa4"
+ "\x59\xdf\x52\xf9\x7c\xe0\x11\x6f"
+ "\x2d\x14\x8e\x24\x61\x2c\xe1\x17"
+ "\xcc\xce\x51\x0c\x19\x8a\x82\x30"
+ "\x94\xd5\x3d\x6a\x53\x06\x5e\xbd"
+ "\xb7\xeb\xfa\xfd\x27\x51\xde\x85"
+ "\x1e\x86\x53\x11\x53\x94\x00\xee"
+ "\x2b\x8c\x08\x2a\xbf\xdd\xae\x11"
+ "\xcb\x1e\xa2\x07\x9a\x80\xcf\x62"
+ "\x9b\x09\xdc\x95\x3c\x96\x8e\xb1"
+ "\x09\xbd\xe4\xeb\xdb\xca\x70\x7a"
+ "\x9e\xfa\x31\x18\x45\x3c\x21\x33"
+ "\xb0\xb3\x2b\xea\xf3\x71\x2d\xe1"
+ "\x03\xad\x1b\x48\xd4\x67\x27\xf0"
+ "\x62\xe4\x3d\xfb\x9b\x08\x76\xe7"
+ "\xdd\x2b\x01\x39\x04\x5a\x58\x7a"
+ "\xf7\x11\x90\xec\xbd\x51\x5c\x32"
+ "\x6b\xd7\x35\x39\x02\x6b\xf2\xa6"
+ "\xd0\x0d\x07\xe1\x06\xc4\x5b\x7d"
+ "\xe4\x6a\xd7\xee\x15\x1f\x83\xb4"
+ "\xa3\xa7\x5e\xc3\x90\xb7\xef\xd3"
+ "\xb7\x4f\xf8\x92\x4c\xb7\x3c\x29"
+ "\xcd\x7e\x2b\x5d\x43\xea\x42\xe7"
+ "\x74\x3f\x7d\x58\x88\x75\xde\x3e",
+ .rlen = 512,
+ }
+};
+
+static struct cipher_testvec aes_lrw_dec_tv_template[] = {
+ /* from http://grouper.ieee.org/groups/1619/email/pdf00017.pdf */
+ /* same as enc vectors with input and result reversed */
+ { /* LRW-32-AES 1 */
+ .key = "\x45\x62\xac\x25\xf8\x28\x17\x6d"
+ "\x4c\x26\x84\x14\xb5\x68\x01\x85"
+ "\x25\x8e\x2a\x05\xe7\x3e\x9d\x03"
+ "\xee\x5a\x83\x0c\xcc\x09\x4c\x87",
+ .klen = 32,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x01",
+ .input = "\xf1\xb2\x73\xcd\x65\xa3\xdf\x5f"
+ "\xe9\x5d\x48\x92\x54\x63\x4e\xb8",
+ .ilen = 16,
+ .result = "\x30\x31\x32\x33\x34\x35\x36\x37"
+ "\x38\x39\x41\x42\x43\x44\x45\x46",
+ .rlen = 16,
+ }, { /* LRW-32-AES 2 */
+ .key = "\x59\x70\x47\x14\xf5\x57\x47\x8c"
+ "\xd7\x79\xe8\x0f\x54\x88\x79\x44"
+ "\x0d\x48\xf0\xb7\xb1\x5a\x53\xea"
+ "\x1c\xaa\x6b\x29\xc2\xca\xfb\xaf",
+ .klen = 32,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x02",
+ .input = "\x00\xc8\x2b\xae\x95\xbb\xcd\xe5"
+ "\x27\x4f\x07\x69\xb2\x60\xe1\x36",
+ .ilen = 16,
+ .result = "\x30\x31\x32\x33\x34\x35\x36\x37"
+ "\x38\x39\x41\x42\x43\x44\x45\x46",
+ .rlen = 16,
+ }, { /* LRW-32-AES 3 */
+ .key = "\xd8\x2a\x91\x34\xb2\x6a\x56\x50"
+ "\x30\xfe\x69\xe2\x37\x7f\x98\x47"
+ "\xcd\xf9\x0b\x16\x0c\x64\x8f\xb6"
+ "\xb0\x0d\x0d\x1b\xae\x85\x87\x1f",
+ .klen = 32,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x02\x00\x00\x00\x00",
+ .input = "\x76\x32\x21\x83\xed\x8f\xf1\x82"
+ "\xf9\x59\x62\x03\x69\x0e\x5e\x01",
+ .ilen = 16,
+ .result = "\x30\x31\x32\x33\x34\x35\x36\x37"
+ "\x38\x39\x41\x42\x43\x44\x45\x46",
+ .rlen = 16,
+ }, { /* LRW-32-AES 4 */
+ .key = "\x0f\x6a\xef\xf8\xd3\xd2\xbb\x15"
+ "\x25\x83\xf7\x3c\x1f\x01\x28\x74"
+ "\xca\xc6\xbc\x35\x4d\x4a\x65\x54"
+ "\x90\xae\x61\xcf\x7b\xae\xbd\xcc"
+ "\xad\xe4\x94\xc5\x4a\x29\xae\x70",
+ .klen = 40,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x01",
+ .input = "\x9c\x0f\x15\x2f\x55\xa2\xd8\xf0"
+ "\xd6\x7b\x8f\x9e\x28\x22\xbc\x41",
+ .ilen = 16,
+ .result = "\x30\x31\x32\x33\x34\x35\x36\x37"
+ "\x38\x39\x41\x42\x43\x44\x45\x46",
+ .rlen = 16,
+ }, { /* LRW-32-AES 5 */
+ .key = "\x8a\xd4\xee\x10\x2f\xbd\x81\xff"
+ "\xf8\x86\xce\xac\x93\xc5\xad\xc6"
+ "\xa0\x19\x07\xc0\x9d\xf7\xbb\xdd"
+ "\x52\x13\xb2\xb7\xf0\xff\x11\xd8"
+ "\xd6\x08\xd0\xcd\x2e\xb1\x17\x6f",
+ .klen = 40,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x02\x00\x00\x00\x00",
+ .input = "\xd4\x27\x6a\x7f\x14\x91\x3d\x65"
+ "\xc8\x60\x48\x02\x87\xe3\x34\x06",
+ .ilen = 16,
+ .result = "\x30\x31\x32\x33\x34\x35\x36\x37"
+ "\x38\x39\x41\x42\x43\x44\x45\x46",
+ .rlen = 16,
+ }, { /* LRW-32-AES 6 */
+ .key = "\xf8\xd4\x76\xff\xd6\x46\xee\x6c"
+ "\x23\x84\xcb\x1c\x77\xd6\x19\x5d"
+ "\xfe\xf1\xa9\xf3\x7b\xbc\x8d\x21"
+ "\xa7\x9c\x21\xf8\xcb\x90\x02\x89"
+ "\xa8\x45\x34\x8e\xc8\xc5\xb5\xf1"
+ "\x26\xf5\x0e\x76\xfe\xfd\x1b\x1e",
+ .klen = 48,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x01",
+ .input = "\xbd\x06\xb8\xe1\xdb\x98\x89\x9e"
+ "\xc4\x98\xe4\x91\xcf\x1c\x70\x2b",
+ .ilen = 16,
+ .result = "\x30\x31\x32\x33\x34\x35\x36\x37"
+ "\x38\x39\x41\x42\x43\x44\x45\x46",
+ .rlen = 16,
+ }, { /* LRW-32-AES 7 */
+ .key = "\xfb\x76\x15\xb2\x3d\x80\x89\x1d"
+ "\xd4\x70\x98\x0b\xc7\x95\x84\xc8"
+ "\xb2\xfb\x64\xce\x60\x97\x87\x8d"
+ "\x17\xfc\xe4\x5a\x49\xe8\x30\xb7"
+ "\x6e\x78\x17\xe7\x2d\x5e\x12\xd4"
+ "\x60\x64\x04\x7a\xf1\x2f\x9e\x0c",
+ .klen = 48,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x02\x00\x00\x00\x00",
+ .input = "\x5b\x90\x8e\xc1\xab\xdd\x67\x5f"
+ "\x3d\x69\x8a\x95\x53\xc8\x9c\xe5",
+ .ilen = 16,
+ .result = "\x30\x31\x32\x33\x34\x35\x36\x37"
+ "\x38\x39\x41\x42\x43\x44\x45\x46",
+ .rlen = 16,
+ }, {
+/* http://www.mail-archive.com/stds-p1619@listserv.ieee.org/msg00173.html */
+ .key = "\xf8\xd4\x76\xff\xd6\x46\xee\x6c"
+ "\x23\x84\xcb\x1c\x77\xd6\x19\x5d"
+ "\xfe\xf1\xa9\xf3\x7b\xbc\x8d\x21"
+ "\xa7\x9c\x21\xf8\xcb\x90\x02\x89"
+ "\xa8\x45\x34\x8e\xc8\xc5\xb5\xf1"
+ "\x26\xf5\x0e\x76\xfe\xfd\x1b\x1e",
+ .klen = 48,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x01",
+ .input = "\x1a\x1d\xa9\x30\xad\xf9\x2f\x9b"
+ "\xb6\x1d\xae\xef\xf0\x2f\xf8\x5a"
+ "\x39\x3c\xbf\x2a\xb2\x45\xb2\x23"
+ "\x1b\x63\x3c\xcf\xaa\xbe\xcf\x4e"
+ "\xfa\xe8\x29\xc2\x20\x68\x2b\x3c"
+ "\x2e\x8b\xf7\x6e\x25\xbd\xe3\x3d"
+ "\x66\x27\xd6\xaf\xd6\x64\x3e\xe3"
+ "\xe8\x58\x46\x97\x39\x51\x07\xde"
+ "\xcb\x37\xbc\xa9\xc0\x5f\x75\xc3"
+ "\x0e\x84\x23\x1d\x16\xd4\x1c\x59"
+ "\x9c\x1a\x02\x55\xab\x3a\x97\x1d"
+ "\xdf\xdd\xc7\x06\x51\xd7\x70\xae"
+ "\x23\xc6\x8c\xf5\x1e\xa0\xe5\x82"
+ "\xb8\xb2\xbf\x04\xa0\x32\x8e\x68"
+ "\xeb\xaf\x6e\x2d\x94\x22\x2f\xce"
+ "\x4c\xb5\x59\xe2\xa2\x2f\xa0\x98"
+ "\x1a\x97\xc6\xd4\xb5\x00\x59\xf2"
+ "\x84\x14\x72\xb1\x9a\x6e\xa3\x7f"
+ "\xea\x20\xe7\xcb\x65\x77\x3a\xdf"
+ "\xc8\x97\x67\x15\xc2\x2a\x27\xcc"
+ "\x18\x55\xa1\x24\x0b\x24\x24\xaf"
+ "\x5b\xec\x68\xb8\xc8\xf5\xba\x63"
+ "\xff\xed\x89\xce\xd5\x3d\x88\xf3"
+ "\x25\xef\x05\x7c\x3a\xef\xeb\xd8"
+ "\x7a\x32\x0d\xd1\x1e\x58\x59\x99"
+ "\x90\x25\xb5\x26\xb0\xe3\x2b\x6c"
+ "\x4c\xa9\x8b\x84\x4f\x5e\x01\x50"
+ "\x41\x30\x58\xc5\x62\x74\x52\x1d"
+ "\x45\x24\x6a\x42\x64\x4f\x97\x1c"
+ "\xa8\x66\xb5\x6d\x79\xd4\x0d\x48"
+ "\xc5\x5f\xf3\x90\x32\xdd\xdd\xe1"
+ "\xe4\xa9\x9f\xfc\xc3\x52\x5a\x46"
+ "\xe4\x81\x84\x95\x36\x59\x7a\x6b"
+ "\xaa\xb3\x60\xad\xce\x9f\x9f\x28"
+ "\xe0\x01\x75\x22\xc4\x4e\xa9\x62"
+ "\x5c\x62\x0d\x00\xcb\x13\xe8\x43"
+ "\x72\xd4\x2d\x53\x46\xb5\xd1\x16"
+ "\x22\x18\xdf\x34\x33\xf5\xd6\x1c"
+ "\xb8\x79\x78\x97\x94\xff\x72\x13"
+ "\x4c\x27\xfc\xcb\xbf\x01\x53\xa6"
+ "\xb4\x50\x6e\xde\xdf\xb5\x43\xa4"
+ "\x59\xdf\x52\xf9\x7c\xe0\x11\x6f"
+ "\x2d\x14\x8e\x24\x61\x2c\xe1\x17"
+ "\xcc\xce\x51\x0c\x19\x8a\x82\x30"
+ "\x94\xd5\x3d\x6a\x53\x06\x5e\xbd"
+ "\xb7\xeb\xfa\xfd\x27\x51\xde\x85"
+ "\x1e\x86\x53\x11\x53\x94\x00\xee"
+ "\x2b\x8c\x08\x2a\xbf\xdd\xae\x11"
+ "\xcb\x1e\xa2\x07\x9a\x80\xcf\x62"
+ "\x9b\x09\xdc\x95\x3c\x96\x8e\xb1"
+ "\x09\xbd\xe4\xeb\xdb\xca\x70\x7a"
+ "\x9e\xfa\x31\x18\x45\x3c\x21\x33"
+ "\xb0\xb3\x2b\xea\xf3\x71\x2d\xe1"
+ "\x03\xad\x1b\x48\xd4\x67\x27\xf0"
+ "\x62\xe4\x3d\xfb\x9b\x08\x76\xe7"
+ "\xdd\x2b\x01\x39\x04\x5a\x58\x7a"
+ "\xf7\x11\x90\xec\xbd\x51\x5c\x32"
+ "\x6b\xd7\x35\x39\x02\x6b\xf2\xa6"
+ "\xd0\x0d\x07\xe1\x06\xc4\x5b\x7d"
+ "\xe4\x6a\xd7\xee\x15\x1f\x83\xb4"
+ "\xa3\xa7\x5e\xc3\x90\xb7\xef\xd3"
+ "\xb7\x4f\xf8\x92\x4c\xb7\x3c\x29"
+ "\xcd\x7e\x2b\x5d\x43\xea\x42\xe7"
+ "\x74\x3f\x7d\x58\x88\x75\xde\x3e",
+ .ilen = 512,
+ .result = "\x05\x11\xb7\x18\xab\xc6\x2d\xac"
+ "\x70\x5d\xf6\x22\x94\xcd\xe5\x6c"
+ "\x17\x6b\xf6\x1c\xf0\xf3\x6e\xf8"
+ "\x50\x38\x1f\x71\x49\xb6\x57\xd6"
+ "\x8f\xcb\x8d\x6b\xe3\xa6\x29\x90"
+ "\xfe\x2a\x62\x82\xae\x6d\x8b\xf6"
+ "\xad\x1e\x9e\x20\x5f\x38\xbe\x04"
+ "\xda\x10\x8e\xed\xa2\xa4\x87\xab"
+ "\xda\x6b\xb4\x0c\x75\xba\xd3\x7c"
+ "\xc9\xac\x42\x31\x95\x7c\xc9\x04"
+ "\xeb\xd5\x6e\x32\x69\x8a\xdb\xa6"
+ "\x15\xd7\x3f\x4f\x2f\x66\x69\x03"
+ "\x9c\x1f\x54\x0f\xde\x1f\xf3\x65"
+ "\x4c\x96\x12\xed\x7c\x92\x03\x01"
+ "\x6f\xbc\x35\x93\xac\xf1\x27\xf1"
+ "\xb4\x96\x82\x5a\x5f\xb0\xa0\x50"
+ "\x89\xa4\x8e\x66\x44\x85\xcc\xfd"
+ "\x33\x14\x70\xe3\x96\xb2\xc3\xd3"
+ "\xbb\x54\x5a\x1a\xf9\x74\xa2\xc5"
+ "\x2d\x64\x75\xdd\xb4\x54\xe6\x74"
+ "\x8c\xd3\x9d\x9e\x86\xab\x51\x53"
+ "\xb7\x93\x3e\x6f\xd0\x4e\x2c\x40"
+ "\xf6\xa8\x2e\x3e\x9d\xf4\x66\xa5"
+ "\x76\x12\x73\x44\x1a\x56\xd7\x72"
+ "\x88\xcd\x21\x8c\x4c\x0f\xfe\xda"
+ "\x95\xe0\x3a\xa6\xa5\x84\x46\xcd"
+ "\xd5\x3e\x9d\x3a\xe2\x67\xe6\x60"
+ "\x1a\xe2\x70\x85\x58\xc2\x1b\x09"
+ "\xe1\xd7\x2c\xca\xad\xa8\x8f\xf9"
+ "\xac\xb3\x0e\xdb\xca\x2e\xe2\xb8"
+ "\x51\x71\xd9\x3c\x6c\xf1\x56\xf8"
+ "\xea\x9c\xf1\xfb\x0c\xe6\xb7\x10"
+ "\x1c\xf8\xa9\x7c\xe8\x53\x35\xc1"
+ "\x90\x3e\x76\x4a\x74\xa4\x21\x2c"
+ "\xf6\x2c\x4e\x0f\x94\x3a\x88\x2e"
+ "\x41\x09\x6a\x33\x7d\xf6\xdd\x3f"
+ "\x8d\x23\x31\x74\x84\xeb\x88\x6e"
+ "\xcc\xb9\xbc\x22\x83\x19\x07\x22"
+ "\xa5\x2d\xdf\xa5\xf3\x80\x85\x78"
+ "\x84\x39\x6a\x6d\x6a\x99\x4f\xa5"
+ "\x15\xfe\x46\xb0\xe4\x6c\xa5\x41"
+ "\x3c\xce\x8f\x42\x60\x71\xa7\x75"
+ "\x08\x40\x65\x8a\x82\xbf\xf5\x43"
+ "\x71\x96\xa9\x4d\x44\x8a\x20\xbe"
+ "\xfa\x4d\xbb\xc0\x7d\x31\x96\x65"
+ "\xe7\x75\xe5\x3e\xfd\x92\x3b\xc9"
+ "\x55\xbb\x16\x7e\xf7\xc2\x8c\xa4"
+ "\x40\x1d\xe5\xef\x0e\xdf\xe4\x9a"
+ "\x62\x73\x65\xfd\x46\x63\x25\x3d"
+ "\x2b\xaf\xe5\x64\xfe\xa5\x5c\xcf"
+ "\x24\xf3\xb4\xac\x64\xba\xdf\x4b"
+ "\xc6\x96\x7d\x81\x2d\x8d\x97\xf7"
+ "\xc5\x68\x77\x84\x32\x2b\xcc\x85"
+ "\x74\x96\xf0\x12\x77\x61\xb9\xeb"
+ "\x71\xaa\x82\xcb\x1c\xdb\x89\xc8"
+ "\xc6\xb5\xe3\x5c\x7d\x39\x07\x24"
+ "\xda\x39\x87\x45\xc0\x2b\xbb\x01"
+ "\xac\xbc\x2a\x5c\x7f\xfc\xe8\xce"
+ "\x6d\x9c\x6f\xed\xd3\xc1\xa1\xd6"
+ "\xc5\x55\xa9\x66\x2f\xe1\xc8\x32"
+ "\xa6\x5d\xa4\x3a\x98\x73\xe8\x45"
+ "\xa4\xc7\xa8\xb4\xf6\x13\x03\xf6"
+ "\xe9\x2e\xc4\x29\x0f\x84\xdb\xc4"
+ "\x21\xc4\xc2\x75\x67\x89\x37\x0a",
+ .rlen = 512,
+ }
+};
+
+static struct cipher_testvec aes_xts_enc_tv_template[] = {
+ /* http://grouper.ieee.org/groups/1619/email/pdf00086.pdf */
+ { /* XTS-AES 1 */
+ .key = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .klen = 32,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .input = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .ilen = 32,
+ .result = "\x91\x7c\xf6\x9e\xbd\x68\xb2\xec"
+ "\x9b\x9f\xe9\xa3\xea\xdd\xa6\x92"
+ "\xcd\x43\xd2\xf5\x95\x98\xed\x85"
+ "\x8c\x02\xc2\x65\x2f\xbf\x92\x2e",
+ .rlen = 32,
+ }, { /* XTS-AES 2 */
+ .key = "\x11\x11\x11\x11\x11\x11\x11\x11"
+ "\x11\x11\x11\x11\x11\x11\x11\x11"
+ "\x22\x22\x22\x22\x22\x22\x22\x22"
+ "\x22\x22\x22\x22\x22\x22\x22\x22",
+ .klen = 32,
+ .iv = "\x33\x33\x33\x33\x33\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .input = "\x44\x44\x44\x44\x44\x44\x44\x44"
+ "\x44\x44\x44\x44\x44\x44\x44\x44"
+ "\x44\x44\x44\x44\x44\x44\x44\x44"
+ "\x44\x44\x44\x44\x44\x44\x44\x44",
+ .ilen = 32,
+ .result = "\xc4\x54\x18\x5e\x6a\x16\x93\x6e"
+ "\x39\x33\x40\x38\xac\xef\x83\x8b"
+ "\xfb\x18\x6f\xff\x74\x80\xad\xc4"
+ "\x28\x93\x82\xec\xd6\xd3\x94\xf0",
+ .rlen = 32,
+ }, { /* XTS-AES 3 */
+ .key = "\xff\xfe\xfd\xfc\xfb\xfa\xf9\xf8"
+ "\xf7\xf6\xf5\xf4\xf3\xf2\xf1\xf0"
+ "\x22\x22\x22\x22\x22\x22\x22\x22"
+ "\x22\x22\x22\x22\x22\x22\x22\x22",
+ .klen = 32,
+ .iv = "\x33\x33\x33\x33\x33\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .input = "\x44\x44\x44\x44\x44\x44\x44\x44"
+ "\x44\x44\x44\x44\x44\x44\x44\x44"
+ "\x44\x44\x44\x44\x44\x44\x44\x44"
+ "\x44\x44\x44\x44\x44\x44\x44\x44",
+ .ilen = 32,
+ .result = "\xaf\x85\x33\x6b\x59\x7a\xfc\x1a"
+ "\x90\x0b\x2e\xb2\x1e\xc9\x49\xd2"
+ "\x92\xdf\x4c\x04\x7e\x0b\x21\x53"
+ "\x21\x86\xa5\x97\x1a\x22\x7a\x89",
+ .rlen = 32,
+ }, { /* XTS-AES 4 */
+ .key = "\x27\x18\x28\x18\x28\x45\x90\x45"
+ "\x23\x53\x60\x28\x74\x71\x35\x26"
+ "\x31\x41\x59\x26\x53\x58\x97\x93"
+ "\x23\x84\x62\x64\x33\x83\x27\x95",
+ .klen = 32,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .input = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
+ "\x20\x21\x22\x23\x24\x25\x26\x27"
+ "\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f"
+ "\x30\x31\x32\x33\x34\x35\x36\x37"
+ "\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f"
+ "\x40\x41\x42\x43\x44\x45\x46\x47"
+ "\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f"
+ "\x50\x51\x52\x53\x54\x55\x56\x57"
+ "\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f"
+ "\x60\x61\x62\x63\x64\x65\x66\x67"
+ "\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f"
+ "\x70\x71\x72\x73\x74\x75\x76\x77"
+ "\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f"
+ "\x80\x81\x82\x83\x84\x85\x86\x87"
+ "\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
+ "\x90\x91\x92\x93\x94\x95\x96\x97"
+ "\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
+ "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7"
+ "\xa8\xa9\xaa\xab\xac\xad\xae\xaf"
+ "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7"
+ "\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf"
+ "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
+ "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
+ "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7"
+ "\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf"
+ "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7"
+ "\xe8\xe9\xea\xeb\xec\xed\xee\xef"
+ "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7"
+ "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"
+ "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
+ "\x20\x21\x22\x23\x24\x25\x26\x27"
+ "\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f"
+ "\x30\x31\x32\x33\x34\x35\x36\x37"
+ "\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f"
+ "\x40\x41\x42\x43\x44\x45\x46\x47"
+ "\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f"
+ "\x50\x51\x52\x53\x54\x55\x56\x57"
+ "\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f"
+ "\x60\x61\x62\x63\x64\x65\x66\x67"
+ "\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f"
+ "\x70\x71\x72\x73\x74\x75\x76\x77"
+ "\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f"
+ "\x80\x81\x82\x83\x84\x85\x86\x87"
+ "\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
+ "\x90\x91\x92\x93\x94\x95\x96\x97"
+ "\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
+ "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7"
+ "\xa8\xa9\xaa\xab\xac\xad\xae\xaf"
+ "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7"
+ "\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf"
+ "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
+ "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
+ "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7"
+ "\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf"
+ "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7"
+ "\xe8\xe9\xea\xeb\xec\xed\xee\xef"
+ "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7"
+ "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff",
+ .ilen = 512,
+ .result = "\x27\xa7\x47\x9b\xef\xa1\xd4\x76"
+ "\x48\x9f\x30\x8c\xd4\xcf\xa6\xe2"
+ "\xa9\x6e\x4b\xbe\x32\x08\xff\x25"
+ "\x28\x7d\xd3\x81\x96\x16\xe8\x9c"
+ "\xc7\x8c\xf7\xf5\xe5\x43\x44\x5f"
+ "\x83\x33\xd8\xfa\x7f\x56\x00\x00"
+ "\x05\x27\x9f\xa5\xd8\xb5\xe4\xad"
+ "\x40\xe7\x36\xdd\xb4\xd3\x54\x12"
+ "\x32\x80\x63\xfd\x2a\xab\x53\xe5"
+ "\xea\x1e\x0a\x9f\x33\x25\x00\xa5"
+ "\xdf\x94\x87\xd0\x7a\x5c\x92\xcc"
+ "\x51\x2c\x88\x66\xc7\xe8\x60\xce"
+ "\x93\xfd\xf1\x66\xa2\x49\x12\xb4"
+ "\x22\x97\x61\x46\xae\x20\xce\x84"
+ "\x6b\xb7\xdc\x9b\xa9\x4a\x76\x7a"
+ "\xae\xf2\x0c\x0d\x61\xad\x02\x65"
+ "\x5e\xa9\x2d\xc4\xc4\xe4\x1a\x89"
+ "\x52\xc6\x51\xd3\x31\x74\xbe\x51"
+ "\xa1\x0c\x42\x11\x10\xe6\xd8\x15"
+ "\x88\xed\xe8\x21\x03\xa2\x52\xd8"
+ "\xa7\x50\xe8\x76\x8d\xef\xff\xed"
+ "\x91\x22\x81\x0a\xae\xb9\x9f\x91"
+ "\x72\xaf\x82\xb6\x04\xdc\x4b\x8e"
+ "\x51\xbc\xb0\x82\x35\xa6\xf4\x34"
+ "\x13\x32\xe4\xca\x60\x48\x2a\x4b"
+ "\xa1\xa0\x3b\x3e\x65\x00\x8f\xc5"
+ "\xda\x76\xb7\x0b\xf1\x69\x0d\xb4"
+ "\xea\xe2\x9c\x5f\x1b\xad\xd0\x3c"
+ "\x5c\xcf\x2a\x55\xd7\x05\xdd\xcd"
+ "\x86\xd4\x49\x51\x1c\xeb\x7e\xc3"
+ "\x0b\xf1\x2b\x1f\xa3\x5b\x91\x3f"
+ "\x9f\x74\x7a\x8a\xfd\x1b\x13\x0e"
+ "\x94\xbf\xf9\x4e\xff\xd0\x1a\x91"
+ "\x73\x5c\xa1\x72\x6a\xcd\x0b\x19"
+ "\x7c\x4e\x5b\x03\x39\x36\x97\xe1"
+ "\x26\x82\x6f\xb6\xbb\xde\x8e\xcc"
+ "\x1e\x08\x29\x85\x16\xe2\xc9\xed"
+ "\x03\xff\x3c\x1b\x78\x60\xf6\xde"
+ "\x76\xd4\xce\xcd\x94\xc8\x11\x98"
+ "\x55\xef\x52\x97\xca\x67\xe9\xf3"
+ "\xe7\xff\x72\xb1\xe9\x97\x85\xca"
+ "\x0a\x7e\x77\x20\xc5\xb3\x6d\xc6"
+ "\xd7\x2c\xac\x95\x74\xc8\xcb\xbc"
+ "\x2f\x80\x1e\x23\xe5\x6f\xd3\x44"
+ "\xb0\x7f\x22\x15\x4b\xeb\xa0\xf0"
+ "\x8c\xe8\x89\x1e\x64\x3e\xd9\x95"
+ "\xc9\x4d\x9a\x69\xc9\xf1\xb5\xf4"
+ "\x99\x02\x7a\x78\x57\x2a\xee\xbd"
+ "\x74\xd2\x0c\xc3\x98\x81\xc2\x13"
+ "\xee\x77\x0b\x10\x10\xe4\xbe\xa7"
+ "\x18\x84\x69\x77\xae\x11\x9f\x7a"
+ "\x02\x3a\xb5\x8c\xca\x0a\xd7\x52"
+ "\xaf\xe6\x56\xbb\x3c\x17\x25\x6a"
+ "\x9f\x6e\x9b\xf1\x9f\xdd\x5a\x38"
+ "\xfc\x82\xbb\xe8\x72\xc5\x53\x9e"
+ "\xdb\x60\x9e\xf4\xf7\x9c\x20\x3e"
+ "\xbb\x14\x0f\x2e\x58\x3c\xb2\xad"
+ "\x15\xb4\xaa\x5b\x65\x50\x16\xa8"
+ "\x44\x92\x77\xdb\xd4\x77\xef\x2c"
+ "\x8d\x6c\x01\x7d\xb7\x38\xb1\x8d"
+ "\xeb\x4a\x42\x7d\x19\x23\xce\x3f"
+ "\xf2\x62\x73\x57\x79\xa4\x18\xf2"
+ "\x0a\x28\x2d\xf9\x20\x14\x7b\xea"
+ "\xbe\x42\x1e\xe5\x31\x9d\x05\x68",
+ .rlen = 512,
+ }
+};
+
+static struct cipher_testvec aes_xts_dec_tv_template[] = {
+ /* http://grouper.ieee.org/groups/1619/email/pdf00086.pdf */
+ { /* XTS-AES 1 */
+ .key = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .klen = 32,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .input = "\x91\x7c\xf6\x9e\xbd\x68\xb2\xec"
+ "\x9b\x9f\xe9\xa3\xea\xdd\xa6\x92"
+ "\xcd\x43\xd2\xf5\x95\x98\xed\x85"
+ "\x8c\x02\xc2\x65\x2f\xbf\x92\x2e",
+ .ilen = 32,
+ .result = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .rlen = 32,
+ }, { /* XTS-AES 2 */
+ .key = "\x11\x11\x11\x11\x11\x11\x11\x11"
+ "\x11\x11\x11\x11\x11\x11\x11\x11"
+ "\x22\x22\x22\x22\x22\x22\x22\x22"
+ "\x22\x22\x22\x22\x22\x22\x22\x22",
+ .klen = 32,
+ .iv = "\x33\x33\x33\x33\x33\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .input = "\xc4\x54\x18\x5e\x6a\x16\x93\x6e"
+ "\x39\x33\x40\x38\xac\xef\x83\x8b"
+ "\xfb\x18\x6f\xff\x74\x80\xad\xc4"
+ "\x28\x93\x82\xec\xd6\xd3\x94\xf0",
+ .ilen = 32,
+ .result = "\x44\x44\x44\x44\x44\x44\x44\x44"
+ "\x44\x44\x44\x44\x44\x44\x44\x44"
+ "\x44\x44\x44\x44\x44\x44\x44\x44"
+ "\x44\x44\x44\x44\x44\x44\x44\x44",
+ .rlen = 32,
+ }, { /* XTS-AES 3 */
+ .key = "\xff\xfe\xfd\xfc\xfb\xfa\xf9\xf8"
+ "\xf7\xf6\xf5\xf4\xf3\xf2\xf1\xf0"
+ "\x22\x22\x22\x22\x22\x22\x22\x22"
+ "\x22\x22\x22\x22\x22\x22\x22\x22",
+ .klen = 32,
+ .iv = "\x33\x33\x33\x33\x33\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .input = "\xaf\x85\x33\x6b\x59\x7a\xfc\x1a"
+ "\x90\x0b\x2e\xb2\x1e\xc9\x49\xd2"
+ "\x92\xdf\x4c\x04\x7e\x0b\x21\x53"
+ "\x21\x86\xa5\x97\x1a\x22\x7a\x89",
+ .ilen = 32,
+ .result = "\x44\x44\x44\x44\x44\x44\x44\x44"
+ "\x44\x44\x44\x44\x44\x44\x44\x44"
+ "\x44\x44\x44\x44\x44\x44\x44\x44"
+ "\x44\x44\x44\x44\x44\x44\x44\x44",
+ .rlen = 32,
+ }, { /* XTS-AES 4 */
+ .key = "\x27\x18\x28\x18\x28\x45\x90\x45"
+ "\x23\x53\x60\x28\x74\x71\x35\x26"
+ "\x31\x41\x59\x26\x53\x58\x97\x93"
+ "\x23\x84\x62\x64\x33\x83\x27\x95",
+ .klen = 32,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .input = "\x27\xa7\x47\x9b\xef\xa1\xd4\x76"
+ "\x48\x9f\x30\x8c\xd4\xcf\xa6\xe2"
+ "\xa9\x6e\x4b\xbe\x32\x08\xff\x25"
+ "\x28\x7d\xd3\x81\x96\x16\xe8\x9c"
+ "\xc7\x8c\xf7\xf5\xe5\x43\x44\x5f"
+ "\x83\x33\xd8\xfa\x7f\x56\x00\x00"
+ "\x05\x27\x9f\xa5\xd8\xb5\xe4\xad"
+ "\x40\xe7\x36\xdd\xb4\xd3\x54\x12"
+ "\x32\x80\x63\xfd\x2a\xab\x53\xe5"
+ "\xea\x1e\x0a\x9f\x33\x25\x00\xa5"
+ "\xdf\x94\x87\xd0\x7a\x5c\x92\xcc"
+ "\x51\x2c\x88\x66\xc7\xe8\x60\xce"
+ "\x93\xfd\xf1\x66\xa2\x49\x12\xb4"
+ "\x22\x97\x61\x46\xae\x20\xce\x84"
+ "\x6b\xb7\xdc\x9b\xa9\x4a\x76\x7a"
+ "\xae\xf2\x0c\x0d\x61\xad\x02\x65"
+ "\x5e\xa9\x2d\xc4\xc4\xe4\x1a\x89"
+ "\x52\xc6\x51\xd3\x31\x74\xbe\x51"
+ "\xa1\x0c\x42\x11\x10\xe6\xd8\x15"
+ "\x88\xed\xe8\x21\x03\xa2\x52\xd8"
+ "\xa7\x50\xe8\x76\x8d\xef\xff\xed"
+ "\x91\x22\x81\x0a\xae\xb9\x9f\x91"
+ "\x72\xaf\x82\xb6\x04\xdc\x4b\x8e"
+ "\x51\xbc\xb0\x82\x35\xa6\xf4\x34"
+ "\x13\x32\xe4\xca\x60\x48\x2a\x4b"
+ "\xa1\xa0\x3b\x3e\x65\x00\x8f\xc5"
+ "\xda\x76\xb7\x0b\xf1\x69\x0d\xb4"
+ "\xea\xe2\x9c\x5f\x1b\xad\xd0\x3c"
+ "\x5c\xcf\x2a\x55\xd7\x05\xdd\xcd"
+ "\x86\xd4\x49\x51\x1c\xeb\x7e\xc3"
+ "\x0b\xf1\x2b\x1f\xa3\x5b\x91\x3f"
+ "\x9f\x74\x7a\x8a\xfd\x1b\x13\x0e"
+ "\x94\xbf\xf9\x4e\xff\xd0\x1a\x91"
+ "\x73\x5c\xa1\x72\x6a\xcd\x0b\x19"
+ "\x7c\x4e\x5b\x03\x39\x36\x97\xe1"
+ "\x26\x82\x6f\xb6\xbb\xde\x8e\xcc"
+ "\x1e\x08\x29\x85\x16\xe2\xc9\xed"
+ "\x03\xff\x3c\x1b\x78\x60\xf6\xde"
+ "\x76\xd4\xce\xcd\x94\xc8\x11\x98"
+ "\x55\xef\x52\x97\xca\x67\xe9\xf3"
+ "\xe7\xff\x72\xb1\xe9\x97\x85\xca"
+ "\x0a\x7e\x77\x20\xc5\xb3\x6d\xc6"
+ "\xd7\x2c\xac\x95\x74\xc8\xcb\xbc"
+ "\x2f\x80\x1e\x23\xe5\x6f\xd3\x44"
+ "\xb0\x7f\x22\x15\x4b\xeb\xa0\xf0"
+ "\x8c\xe8\x89\x1e\x64\x3e\xd9\x95"
+ "\xc9\x4d\x9a\x69\xc9\xf1\xb5\xf4"
+ "\x99\x02\x7a\x78\x57\x2a\xee\xbd"
+ "\x74\xd2\x0c\xc3\x98\x81\xc2\x13"
+ "\xee\x77\x0b\x10\x10\xe4\xbe\xa7"
+ "\x18\x84\x69\x77\xae\x11\x9f\x7a"
+ "\x02\x3a\xb5\x8c\xca\x0a\xd7\x52"
+ "\xaf\xe6\x56\xbb\x3c\x17\x25\x6a"
+ "\x9f\x6e\x9b\xf1\x9f\xdd\x5a\x38"
+ "\xfc\x82\xbb\xe8\x72\xc5\x53\x9e"
+ "\xdb\x60\x9e\xf4\xf7\x9c\x20\x3e"
+ "\xbb\x14\x0f\x2e\x58\x3c\xb2\xad"
+ "\x15\xb4\xaa\x5b\x65\x50\x16\xa8"
+ "\x44\x92\x77\xdb\xd4\x77\xef\x2c"
+ "\x8d\x6c\x01\x7d\xb7\x38\xb1\x8d"
+ "\xeb\x4a\x42\x7d\x19\x23\xce\x3f"
+ "\xf2\x62\x73\x57\x79\xa4\x18\xf2"
+ "\x0a\x28\x2d\xf9\x20\x14\x7b\xea"
+ "\xbe\x42\x1e\xe5\x31\x9d\x05\x68",
+ .ilen = 512,
+ .result = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
+ "\x20\x21\x22\x23\x24\x25\x26\x27"
+ "\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f"
+ "\x30\x31\x32\x33\x34\x35\x36\x37"
+ "\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f"
+ "\x40\x41\x42\x43\x44\x45\x46\x47"
+ "\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f"
+ "\x50\x51\x52\x53\x54\x55\x56\x57"
+ "\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f"
+ "\x60\x61\x62\x63\x64\x65\x66\x67"
+ "\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f"
+ "\x70\x71\x72\x73\x74\x75\x76\x77"
+ "\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f"
+ "\x80\x81\x82\x83\x84\x85\x86\x87"
+ "\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
+ "\x90\x91\x92\x93\x94\x95\x96\x97"
+ "\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
+ "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7"
+ "\xa8\xa9\xaa\xab\xac\xad\xae\xaf"
+ "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7"
+ "\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf"
+ "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
+ "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
+ "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7"
+ "\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf"
+ "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7"
+ "\xe8\xe9\xea\xeb\xec\xed\xee\xef"
+ "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7"
+ "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"
+ "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
+ "\x20\x21\x22\x23\x24\x25\x26\x27"
+ "\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f"
+ "\x30\x31\x32\x33\x34\x35\x36\x37"
+ "\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f"
+ "\x40\x41\x42\x43\x44\x45\x46\x47"
+ "\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f"
+ "\x50\x51\x52\x53\x54\x55\x56\x57"
+ "\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f"
+ "\x60\x61\x62\x63\x64\x65\x66\x67"
+ "\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f"
+ "\x70\x71\x72\x73\x74\x75\x76\x77"
+ "\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f"
+ "\x80\x81\x82\x83\x84\x85\x86\x87"
+ "\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
+ "\x90\x91\x92\x93\x94\x95\x96\x97"
+ "\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
+ "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7"
+ "\xa8\xa9\xaa\xab\xac\xad\xae\xaf"
+ "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7"
+ "\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf"
+ "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
+ "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
+ "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7"
+ "\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf"
+ "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7"
+ "\xe8\xe9\xea\xeb\xec\xed\xee\xef"
+ "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7"
+ "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff",
+ .rlen = 512,
+ }
+};
+
+#endif
+
+static struct cipher_testvec aes_ctr_enc_tv_template[] = {
+ { /* From NIST Special Publication 800-38A, Appendix F.5 */
+ .key = "\x2b\x7e\x15\x16\x28\xae\xd2\xa6"
+ "\xab\xf7\x15\x88\x09\xcf\x4f\x3c",
+ .klen = 16,
+ .iv = "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7"
+ "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff",
+ .input = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96"
+ "\xe9\x3d\x7e\x11\x73\x93\x17\x2a"
+ "\xae\x2d\x8a\x57\x1e\x03\xac\x9c"
+ "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51"
+ "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11"
+ "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef"
+ "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17"
+ "\xad\x2b\x41\x7b\xe6\x6c\x37\x10",
+ .ilen = 64,
+ .result = "\x87\x4d\x61\x91\xb6\x20\xe3\x26"
+ "\x1b\xef\x68\x64\x99\x0d\xb6\xce"
+ "\x98\x06\xf6\x6b\x79\x70\xfd\xff"
+ "\x86\x17\x18\x7b\xb9\xff\xfd\xff"
+ "\x5a\xe4\xdf\x3e\xdb\xd5\xd3\x5e"
+ "\x5b\x4f\x09\x02\x0d\xb0\x3e\xab"
+ "\x1e\x03\x1d\xda\x2f\xbe\x03\xd1"
+ "\x79\x21\x70\xa0\xf3\x00\x9c\xee",
+ .rlen = 64,
+ }, {
+ .key = "\x8e\x73\xb0\xf7\xda\x0e\x64\x52"
+ "\xc8\x10\xf3\x2b\x80\x90\x79\xe5"
+ "\x62\xf8\xea\xd2\x52\x2c\x6b\x7b",
+ .klen = 24,
+ .iv = "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7"
+ "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff",
+ .input = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96"
+ "\xe9\x3d\x7e\x11\x73\x93\x17\x2a"
+ "\xae\x2d\x8a\x57\x1e\x03\xac\x9c"
+ "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51"
+ "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11"
+ "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef"
+ "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17"
+ "\xad\x2b\x41\x7b\xe6\x6c\x37\x10",
+ .ilen = 64,
+ .result = "\x1a\xbc\x93\x24\x17\x52\x1c\xa2"
+ "\x4f\x2b\x04\x59\xfe\x7e\x6e\x0b"
+ "\x09\x03\x39\xec\x0a\xa6\xfa\xef"
+ "\xd5\xcc\xc2\xc6\xf4\xce\x8e\x94"
+ "\x1e\x36\xb2\x6b\xd1\xeb\xc6\x70"
+ "\xd1\xbd\x1d\x66\x56\x20\xab\xf7"
+ "\x4f\x78\xa7\xf6\xd2\x98\x09\x58"
+ "\x5a\x97\xda\xec\x58\xc6\xb0\x50",
+ .rlen = 64,
+ }, {
+ .key = "\x60\x3d\xeb\x10\x15\xca\x71\xbe"
+ "\x2b\x73\xae\xf0\x85\x7d\x77\x81"
+ "\x1f\x35\x2c\x07\x3b\x61\x08\xd7"
+ "\x2d\x98\x10\xa3\x09\x14\xdf\xf4",
+ .klen = 32,
+ .iv = "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7"
+ "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff",
+ .input = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96"
+ "\xe9\x3d\x7e\x11\x73\x93\x17\x2a"
+ "\xae\x2d\x8a\x57\x1e\x03\xac\x9c"
+ "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51"
+ "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11"
+ "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef"
+ "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17"
+ "\xad\x2b\x41\x7b\xe6\x6c\x37\x10",
+ .ilen = 64,
+ .result = "\x60\x1e\xc3\x13\x77\x57\x89\xa5"
+ "\xb7\xa7\xf5\x04\xbb\xf3\xd2\x28"
+ "\xf4\x43\xe3\xca\x4d\x62\xb5\x9a"
+ "\xca\x84\xe9\x90\xca\xca\xf5\xc5"
+ "\x2b\x09\x30\xda\xa2\x3d\xe9\x4c"
+ "\xe8\x70\x17\xba\x2d\x84\x98\x8d"
+ "\xdf\xc9\xc5\x8d\xb6\x7a\xad\xa6"
+ "\x13\xc2\xdd\x08\x45\x79\x41\xa6",
+ .rlen = 64,
+ }
+};
+
+static struct cipher_testvec aes_ctr_dec_tv_template[] = {
+ { /* From NIST Special Publication 800-38A, Appendix F.5 */
+ .key = "\x2b\x7e\x15\x16\x28\xae\xd2\xa6"
+ "\xab\xf7\x15\x88\x09\xcf\x4f\x3c",
+ .klen = 16,
+ .iv = "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7"
+ "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff",
+ .input = "\x87\x4d\x61\x91\xb6\x20\xe3\x26"
+ "\x1b\xef\x68\x64\x99\x0d\xb6\xce"
+ "\x98\x06\xf6\x6b\x79\x70\xfd\xff"
+ "\x86\x17\x18\x7b\xb9\xff\xfd\xff"
+ "\x5a\xe4\xdf\x3e\xdb\xd5\xd3\x5e"
+ "\x5b\x4f\x09\x02\x0d\xb0\x3e\xab"
+ "\x1e\x03\x1d\xda\x2f\xbe\x03\xd1"
+ "\x79\x21\x70\xa0\xf3\x00\x9c\xee",
+ .ilen = 64,
+ .result = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96"
+ "\xe9\x3d\x7e\x11\x73\x93\x17\x2a"
+ "\xae\x2d\x8a\x57\x1e\x03\xac\x9c"
+ "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51"
+ "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11"
+ "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef"
+ "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17"
+ "\xad\x2b\x41\x7b\xe6\x6c\x37\x10",
+ .rlen = 64,
+ }, {
+ .key = "\x8e\x73\xb0\xf7\xda\x0e\x64\x52"
+ "\xc8\x10\xf3\x2b\x80\x90\x79\xe5"
+ "\x62\xf8\xea\xd2\x52\x2c\x6b\x7b",
+ .klen = 24,
+ .iv = "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7"
+ "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff",
+ .input = "\x1a\xbc\x93\x24\x17\x52\x1c\xa2"
+ "\x4f\x2b\x04\x59\xfe\x7e\x6e\x0b"
+ "\x09\x03\x39\xec\x0a\xa6\xfa\xef"
+ "\xd5\xcc\xc2\xc6\xf4\xce\x8e\x94"
+ "\x1e\x36\xb2\x6b\xd1\xeb\xc6\x70"
+ "\xd1\xbd\x1d\x66\x56\x20\xab\xf7"
+ "\x4f\x78\xa7\xf6\xd2\x98\x09\x58"
+ "\x5a\x97\xda\xec\x58\xc6\xb0\x50",
+ .ilen = 64,
+ .result = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96"
+ "\xe9\x3d\x7e\x11\x73\x93\x17\x2a"
+ "\xae\x2d\x8a\x57\x1e\x03\xac\x9c"
+ "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51"
+ "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11"
+ "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef"
+ "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17"
+ "\xad\x2b\x41\x7b\xe6\x6c\x37\x10",
+ .rlen = 64,
+ }, {
+ .key = "\x60\x3d\xeb\x10\x15\xca\x71\xbe"
+ "\x2b\x73\xae\xf0\x85\x7d\x77\x81"
+ "\x1f\x35\x2c\x07\x3b\x61\x08\xd7"
+ "\x2d\x98\x10\xa3\x09\x14\xdf\xf4",
+ .klen = 32,
+ .iv = "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7"
+ "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff",
+ .input = "\x60\x1e\xc3\x13\x77\x57\x89\xa5"
+ "\xb7\xa7\xf5\x04\xbb\xf3\xd2\x28"
+ "\xf4\x43\xe3\xca\x4d\x62\xb5\x9a"
+ "\xca\x84\xe9\x90\xca\xca\xf5\xc5"
+ "\x2b\x09\x30\xda\xa2\x3d\xe9\x4c"
+ "\xe8\x70\x17\xba\x2d\x84\x98\x8d"
+ "\xdf\xc9\xc5\x8d\xb6\x7a\xad\xa6"
+ "\x13\xc2\xdd\x08\x45\x79\x41\xa6",
+ .ilen = 64,
+ .result = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96"
+ "\xe9\x3d\x7e\x11\x73\x93\x17\x2a"
+ "\xae\x2d\x8a\x57\x1e\x03\xac\x9c"
+ "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51"
+ "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11"
+ "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef"
+ "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17"
+ "\xad\x2b\x41\x7b\xe6\x6c\x37\x10",
+ .rlen = 64,
+ }
+};
+
+static struct cipher_testvec aes_ctr_rfc3686_enc_tv_template[] = {
+ { /* From RFC 3686 */
+ .key = "\xae\x68\x52\xf8\x12\x10\x67\xcc"
+ "\x4b\xf7\xa5\x76\x55\x77\xf3\x9e"
+ "\x00\x00\x00\x30",
+ .klen = 20,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .input = "Single block msg",
+ .ilen = 16,
+ .result = "\xe4\x09\x5d\x4f\xb7\xa7\xb3\x79"
+ "\x2d\x61\x75\xa3\x26\x13\x11\xb8",
+ .rlen = 16,
+ }, {
+ .key = "\x7e\x24\x06\x78\x17\xfa\xe0\xd7"
+ "\x43\xd6\xce\x1f\x32\x53\x91\x63"
+ "\x00\x6c\xb6\xdb",
+ .klen = 20,
+ .iv = "\xc0\x54\x3b\x59\xda\x48\xd9\x0b",
+ .input = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
+ .ilen = 32,
+ .result = "\x51\x04\xa1\x06\x16\x8a\x72\xd9"
+ "\x79\x0d\x41\xee\x8e\xda\xd3\x88"
+ "\xeb\x2e\x1e\xfc\x46\xda\x57\xc8"
+ "\xfc\xe6\x30\xdf\x91\x41\xbe\x28",
+ .rlen = 32,
+ }, {
+ .key = "\x16\xaf\x5b\x14\x5f\xc9\xf5\x79"
+ "\xc1\x75\xf9\x3e\x3b\xfb\x0e\xed"
+ "\x86\x3d\x06\xcc\xfd\xb7\x85\x15"
+ "\x00\x00\x00\x48",
+ .klen = 28,
+ .iv = "\x36\x73\x3c\x14\x7d\x6d\x93\xcb",
+ .input = "Single block msg",
+ .ilen = 16,
+ .result = "\x4b\x55\x38\x4f\xe2\x59\xc9\xc8"
+ "\x4e\x79\x35\xa0\x03\xcb\xe9\x28",
+ .rlen = 16,
+ }, {
+ .key = "\x7c\x5c\xb2\x40\x1b\x3d\xc3\x3c"
+ "\x19\xe7\x34\x08\x19\xe0\xf6\x9c"
+ "\x67\x8c\x3d\xb8\xe6\xf6\xa9\x1a"
+ "\x00\x96\xb0\x3b",
+ .klen = 28,
+ .iv = "\x02\x0c\x6e\xad\xc2\xcb\x50\x0d",
+ .input = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
+ .ilen = 32,
+ .result = "\x45\x32\x43\xfc\x60\x9b\x23\x32"
+ "\x7e\xdf\xaa\xfa\x71\x31\xcd\x9f"
+ "\x84\x90\x70\x1c\x5a\xd4\xa7\x9c"
+ "\xfc\x1f\xe0\xff\x42\xf4\xfb\x00",
+ .rlen = 32,
+ }, {
+ .key = "\x77\x6b\xef\xf2\x85\x1d\xb0\x6f"
+ "\x4c\x8a\x05\x42\xc8\x69\x6f\x6c"
+ "\x6a\x81\xaf\x1e\xec\x96\xb4\xd3"
+ "\x7f\xc1\xd6\x89\xe6\xc1\xc1\x04"
+ "\x00\x00\x00\x60",
+ .klen = 36,
+ .iv = "\xdb\x56\x72\xc9\x7a\xa8\xf0\xb2",
+ .input = "Single block msg",
+ .ilen = 16,
+ .result = "\x14\x5a\xd0\x1d\xbf\x82\x4e\xc7"
+ "\x56\x08\x63\xdc\x71\xe3\xe0\xc0",
+ .rlen = 16,
+ }, {
+ .key = "\xf6\xd6\x6d\x6b\xd5\x2d\x59\xbb"
+ "\x07\x96\x36\x58\x79\xef\xf8\x86"
+ "\xc6\x6d\xd5\x1a\x5b\x6a\x99\x74"
+ "\x4b\x50\x59\x0c\x87\xa2\x38\x84"
+ "\x00\xfa\xac\x24",
+ .klen = 36,
+ .iv = "\xc1\x58\x5e\xf1\x5a\x43\xd8\x75",
+ .input = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
+ .ilen = 32,
+ .result = "\xf0\x5e\x23\x1b\x38\x94\x61\x2c"
+ "\x49\xee\x00\x0b\x80\x4e\xb2\xa9"
+ "\xb8\x30\x6b\x50\x8f\x83\x9d\x6a"
+ "\x55\x30\x83\x1d\x93\x44\xaf\x1c",
+ .rlen = 32,
+ }, {
+#if 0
+ // generated using Crypto++
+ .key = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
+ "\x00\x00\x00\x00",
+ .klen = 32 + 4,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .input =
+ "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
+ "\x20\x21\x22\x23\x24\x25\x26\x27"
+ "\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f"
+ "\x30\x31\x32\x33\x34\x35\x36\x37"
+ "\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f"
+ "\x40\x41\x42\x43\x44\x45\x46\x47"
+ "\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f"
+ "\x50\x51\x52\x53\x54\x55\x56\x57"
+ "\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f"
+ "\x60\x61\x62\x63\x64\x65\x66\x67"
+ "\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f"
+ "\x70\x71\x72\x73\x74\x75\x76\x77"
+ "\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f"
+ "\x80\x81\x82\x83\x84\x85\x86\x87"
+ "\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
+ "\x90\x91\x92\x93\x94\x95\x96\x97"
+ "\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
+ "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7"
+ "\xa8\xa9\xaa\xab\xac\xad\xae\xaf"
+ "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7"
+ "\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf"
+ "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
+ "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
+ "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7"
+ "\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf"
+ "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7"
+ "\xe8\xe9\xea\xeb\xec\xed\xee\xef"
+ "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7"
+ "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"
+ "\x00\x03\x06\x09\x0c\x0f\x12\x15"
+ "\x18\x1b\x1e\x21\x24\x27\x2a\x2d"
+ "\x30\x33\x36\x39\x3c\x3f\x42\x45"
+ "\x48\x4b\x4e\x51\x54\x57\x5a\x5d"
+ "\x60\x63\x66\x69\x6c\x6f\x72\x75"
+ "\x78\x7b\x7e\x81\x84\x87\x8a\x8d"
+ "\x90\x93\x96\x99\x9c\x9f\xa2\xa5"
+ "\xa8\xab\xae\xb1\xb4\xb7\xba\xbd"
+ "\xc0\xc3\xc6\xc9\xcc\xcf\xd2\xd5"
+ "\xd8\xdb\xde\xe1\xe4\xe7\xea\xed"
+ "\xf0\xf3\xf6\xf9\xfc\xff\x02\x05"
+ "\x08\x0b\x0e\x11\x14\x17\x1a\x1d"
+ "\x20\x23\x26\x29\x2c\x2f\x32\x35"
+ "\x38\x3b\x3e\x41\x44\x47\x4a\x4d"
+ "\x50\x53\x56\x59\x5c\x5f\x62\x65"
+ "\x68\x6b\x6e\x71\x74\x77\x7a\x7d"
+ "\x80\x83\x86\x89\x8c\x8f\x92\x95"
+ "\x98\x9b\x9e\xa1\xa4\xa7\xaa\xad"
+ "\xb0\xb3\xb6\xb9\xbc\xbf\xc2\xc5"
+ "\xc8\xcb\xce\xd1\xd4\xd7\xda\xdd"
+ "\xe0\xe3\xe6\xe9\xec\xef\xf2\xf5"
+ "\xf8\xfb\xfe\x01\x04\x07\x0a\x0d"
+ "\x10\x13\x16\x19\x1c\x1f\x22\x25"
+ "\x28\x2b\x2e\x31\x34\x37\x3a\x3d"
+ "\x40\x43\x46\x49\x4c\x4f\x52\x55"
+ "\x58\x5b\x5e\x61\x64\x67\x6a\x6d"
+ "\x70\x73\x76\x79\x7c\x7f\x82\x85"
+ "\x88\x8b\x8e\x91\x94\x97\x9a\x9d"
+ "\xa0\xa3\xa6\xa9\xac\xaf\xb2\xb5"
+ "\xb8\xbb\xbe\xc1\xc4\xc7\xca\xcd"
+ "\xd0\xd3\xd6\xd9\xdc\xdf\xe2\xe5"
+ "\xe8\xeb\xee\xf1\xf4\xf7\xfa\xfd"
+ "\x00\x05\x0a\x0f\x14\x19\x1e\x23"
+ "\x28\x2d\x32\x37\x3c\x41\x46\x4b"
+ "\x50\x55\x5a\x5f\x64\x69\x6e\x73"
+ "\x78\x7d\x82\x87\x8c\x91\x96\x9b"
+ "\xa0\xa5\xaa\xaf\xb4\xb9\xbe\xc3"
+ "\xc8\xcd\xd2\xd7\xdc\xe1\xe6\xeb"
+ "\xf0\xf5\xfa\xff\x04\x09\x0e\x13"
+ "\x18\x1d\x22\x27\x2c\x31\x36\x3b"
+ "\x40\x45\x4a\x4f\x54\x59\x5e\x63"
+ "\x68\x6d\x72\x77\x7c\x81\x86\x8b"
+ "\x90\x95\x9a\x9f\xa4\xa9\xae\xb3"
+ "\xb8\xbd\xc2\xc7\xcc\xd1\xd6\xdb"
+ "\xe0\xe5\xea\xef\xf4\xf9\xfe\x03"
+ "\x08\x0d\x12\x17\x1c\x21\x26\x2b"
+ "\x30\x35\x3a\x3f\x44\x49\x4e\x53"
+ "\x58\x5d\x62\x67\x6c\x71\x76\x7b"
+ "\x80\x85\x8a\x8f\x94\x99\x9e\xa3"
+ "\xa8\xad\xb2\xb7\xbc\xc1\xc6\xcb"
+ "\xd0\xd5\xda\xdf\xe4\xe9\xee\xf3"
+ "\xf8\xfd\x02\x07\x0c\x11\x16\x1b"
+ "\x20\x25\x2a\x2f\x34\x39\x3e\x43"
+ "\x48\x4d\x52\x57\x5c\x61\x66\x6b"
+ "\x70\x75\x7a\x7f\x84\x89\x8e\x93"
+ "\x98\x9d\xa2\xa7\xac\xb1\xb6\xbb"
+ "\xc0\xc5\xca\xcf\xd4\xd9\xde\xe3"
+ "\xe8\xed\xf2\xf7\xfc\x01\x06\x0b"
+ "\x10\x15\x1a\x1f\x24\x29\x2e\x33"
+ "\x38\x3d\x42\x47\x4c\x51\x56\x5b"
+ "\x60\x65\x6a\x6f\x74\x79\x7e\x83"
+ "\x88\x8d\x92\x97\x9c\xa1\xa6\xab"
+ "\xb0\xb5\xba\xbf\xc4\xc9\xce\xd3"
+ "\xd8\xdd\xe2\xe7\xec\xf1\xf6\xfb"
+ "\x00\x07\x0e\x15\x1c\x23\x2a\x31"
+ "\x38\x3f\x46\x4d\x54\x5b\x62\x69"
+ "\x70\x77\x7e\x85\x8c\x93\x9a\xa1"
+ "\xa8\xaf\xb6\xbd\xc4\xcb\xd2\xd9"
+ "\xe0\xe7\xee\xf5\xfc\x03\x0a\x11"
+ "\x18\x1f\x26\x2d\x34\x3b\x42\x49"
+ "\x50\x57\x5e\x65\x6c\x73\x7a\x81"
+ "\x88\x8f\x96\x9d\xa4\xab\xb2\xb9"
+ "\xc0\xc7\xce\xd5\xdc\xe3\xea\xf1"
+ "\xf8\xff\x06\x0d\x14\x1b\x22\x29"
+ "\x30\x37\x3e\x45\x4c\x53\x5a\x61"
+ "\x68\x6f\x76\x7d\x84\x8b\x92\x99"
+ "\xa0\xa7\xae\xb5\xbc\xc3\xca\xd1"
+ "\xd8\xdf\xe6\xed\xf4\xfb\x02\x09"
+ "\x10\x17\x1e\x25\x2c\x33\x3a\x41"
+ "\x48\x4f\x56\x5d\x64\x6b\x72\x79"
+ "\x80\x87\x8e\x95\x9c\xa3\xaa\xb1"
+ "\xb8\xbf\xc6\xcd\xd4\xdb\xe2\xe9"
+ "\xf0\xf7\xfe\x05\x0c\x13\x1a\x21"
+ "\x28\x2f\x36\x3d\x44\x4b\x52\x59"
+ "\x60\x67\x6e\x75\x7c\x83\x8a\x91"
+ "\x98\x9f\xa6\xad\xb4\xbb\xc2\xc9"
+ "\xd0\xd7\xde\xe5\xec\xf3\xfa\x01"
+ "\x08\x0f\x16\x1d\x24\x2b\x32\x39"
+ "\x40\x47\x4e\x55\x5c\x63\x6a\x71"
+ "\x78\x7f\x86\x8d\x94\x9b\xa2\xa9"
+ "\xb0\xb7\xbe\xc5\xcc\xd3\xda\xe1"
+ "\xe8\xef\xf6\xfd\x04\x0b\x12\x19"
+ "\x20\x27\x2e\x35\x3c\x43\x4a\x51"
+ "\x58\x5f\x66\x6d\x74\x7b\x82\x89"
+ "\x90\x97\x9e\xa5\xac\xb3\xba\xc1"
+ "\xc8\xcf\xd6\xdd\xe4\xeb\xf2\xf9"
+ "\x00\x09\x12\x1b\x24\x2d\x36\x3f"
+ "\x48\x51\x5a\x63\x6c\x75\x7e\x87"
+ "\x90\x99\xa2\xab\xb4\xbd\xc6\xcf"
+ "\xd8\xe1\xea\xf3\xfc\x05\x0e\x17"
+ "\x20\x29\x32\x3b\x44\x4d\x56\x5f"
+ "\x68\x71\x7a\x83\x8c\x95\x9e\xa7"
+ "\xb0\xb9\xc2\xcb\xd4\xdd\xe6\xef"
+ "\xf8\x01\x0a\x13\x1c\x25\x2e\x37"
+ "\x40\x49\x52\x5b\x64\x6d\x76\x7f"
+ "\x88\x91\x9a\xa3\xac\xb5\xbe\xc7"
+ "\xd0\xd9\xe2\xeb\xf4\xfd\x06\x0f"
+ "\x18\x21\x2a\x33\x3c\x45\x4e\x57"
+ "\x60\x69\x72\x7b\x84\x8d\x96\x9f"
+ "\xa8\xb1\xba\xc3\xcc\xd5\xde\xe7"
+ "\xf0\xf9\x02\x0b\x14\x1d\x26\x2f"
+ "\x38\x41\x4a\x53\x5c\x65\x6e\x77"
+ "\x80\x89\x92\x9b\xa4\xad\xb6\xbf"
+ "\xc8\xd1\xda\xe3\xec\xf5\xfe\x07"
+ "\x10\x19\x22\x2b\x34\x3d\x46\x4f"
+ "\x58\x61\x6a\x73\x7c\x85\x8e\x97"
+ "\xa0\xa9\xb2\xbb\xc4\xcd\xd6\xdf"
+ "\xe8\xf1\xfa\x03\x0c\x15\x1e\x27"
+ "\x30\x39\x42\x4b\x54\x5d\x66\x6f"
+ "\x78\x81\x8a\x93\x9c\xa5\xae\xb7"
+ "\xc0\xc9\xd2\xdb\xe4\xed\xf6\xff"
+ "\x08\x11\x1a\x23\x2c\x35\x3e\x47"
+ "\x50\x59\x62\x6b\x74\x7d\x86\x8f"
+ "\x98\xa1\xaa\xb3\xbc\xc5\xce\xd7"
+ "\xe0\xe9\xf2\xfb\x04\x0d\x16\x1f"
+ "\x28\x31\x3a\x43\x4c\x55\x5e\x67"
+ "\x70\x79\x82\x8b\x94\x9d\xa6\xaf"
+ "\xb8\xc1\xca\xd3\xdc\xe5\xee\xf7"
+ "\x00\x0b\x16\x21\x2c\x37\x42\x4d"
+ "\x58\x63\x6e\x79\x84\x8f\x9a\xa5"
+ "\xb0\xbb\xc6\xd1\xdc\xe7\xf2\xfd"
+ "\x08\x13\x1e\x29\x34\x3f\x4a\x55"
+ "\x60\x6b\x76\x81\x8c\x97\xa2\xad"
+ "\xb8\xc3\xce\xd9\xe4\xef\xfa\x05"
+ "\x10\x1b\x26\x31\x3c\x47\x52\x5d"
+ "\x68\x73\x7e\x89\x94\x9f\xaa\xb5"
+ "\xc0\xcb\xd6\xe1\xec\xf7\x02\x0d"
+ "\x18\x23\x2e\x39\x44\x4f\x5a\x65"
+ "\x70\x7b\x86\x91\x9c\xa7\xb2\xbd"
+ "\xc8\xd3\xde\xe9\xf4\xff\x0a\x15"
+ "\x20\x2b\x36\x41\x4c\x57\x62\x6d"
+ "\x78\x83\x8e\x99\xa4\xaf\xba\xc5"
+ "\xd0\xdb\xe6\xf1\xfc\x07\x12\x1d"
+ "\x28\x33\x3e\x49\x54\x5f\x6a\x75"
+ "\x80\x8b\x96\xa1\xac\xb7\xc2\xcd"
+ "\xd8\xe3\xee\xf9\x04\x0f\x1a\x25"
+ "\x30\x3b\x46\x51\x5c\x67\x72\x7d"
+ "\x88\x93\x9e\xa9\xb4\xbf\xca\xd5"
+ "\xe0\xeb\xf6\x01\x0c\x17\x22\x2d"
+ "\x38\x43\x4e\x59\x64\x6f\x7a\x85"
+ "\x90\x9b\xa6\xb1\xbc\xc7\xd2\xdd"
+ "\xe8\xf3\xfe\x09\x14\x1f\x2a\x35"
+ "\x40\x4b\x56\x61\x6c\x77\x82\x8d"
+ "\x98\xa3\xae\xb9\xc4\xcf\xda\xe5"
+ "\xf0\xfb\x06\x11\x1c\x27\x32\x3d"
+ "\x48\x53\x5e\x69\x74\x7f\x8a\x95"
+ "\xa0\xab\xb6\xc1\xcc\xd7\xe2\xed"
+ "\xf8\x03\x0e\x19\x24\x2f\x3a\x45"
+ "\x50\x5b\x66\x71\x7c\x87\x92\x9d"
+ "\xa8\xb3\xbe\xc9\xd4\xdf\xea\xf5"
+ "\x00\x0d\x1a\x27\x34\x41\x4e\x5b"
+ "\x68\x75\x82\x8f\x9c\xa9\xb6\xc3"
+ "\xd0\xdd\xea\xf7\x04\x11\x1e\x2b"
+ "\x38\x45\x52\x5f\x6c\x79\x86\x93"
+ "\xa0\xad\xba\xc7\xd4\xe1\xee\xfb"
+ "\x08\x15\x22\x2f\x3c\x49\x56\x63"
+ "\x70\x7d\x8a\x97\xa4\xb1\xbe\xcb"
+ "\xd8\xe5\xf2\xff\x0c\x19\x26\x33"
+ "\x40\x4d\x5a\x67\x74\x81\x8e\x9b"
+ "\xa8\xb5\xc2\xcf\xdc\xe9\xf6\x03"
+ "\x10\x1d\x2a\x37\x44\x51\x5e\x6b"
+ "\x78\x85\x92\x9f\xac\xb9\xc6\xd3"
+ "\xe0\xed\xfa\x07\x14\x21\x2e\x3b"
+ "\x48\x55\x62\x6f\x7c\x89\x96\xa3"
+ "\xb0\xbd\xca\xd7\xe4\xf1\xfe\x0b"
+ "\x18\x25\x32\x3f\x4c\x59\x66\x73"
+ "\x80\x8d\x9a\xa7\xb4\xc1\xce\xdb"
+ "\xe8\xf5\x02\x0f\x1c\x29\x36\x43"
+ "\x50\x5d\x6a\x77\x84\x91\x9e\xab"
+ "\xb8\xc5\xd2\xdf\xec\xf9\x06\x13"
+ "\x20\x2d\x3a\x47\x54\x61\x6e\x7b"
+ "\x88\x95\xa2\xaf\xbc\xc9\xd6\xe3"
+ "\xf0\xfd\x0a\x17\x24\x31\x3e\x4b"
+ "\x58\x65\x72\x7f\x8c\x99\xa6\xb3"
+ "\xc0\xcd\xda\xe7\xf4\x01\x0e\x1b"
+ "\x28\x35\x42\x4f\x5c\x69\x76\x83"
+ "\x90\x9d\xaa\xb7\xc4\xd1\xde\xeb"
+ "\xf8\x05\x12\x1f\x2c\x39\x46\x53"
+ "\x60\x6d\x7a\x87\x94\xa1\xae\xbb"
+ "\xc8\xd5\xe2\xef\xfc\x09\x16\x23"
+ "\x30\x3d\x4a\x57\x64\x71\x7e\x8b"
+ "\x98\xa5\xb2\xbf\xcc\xd9\xe6\xf3"
+ "\x00\x0f\x1e\x2d\x3c\x4b\x5a\x69"
+ "\x78\x87\x96\xa5\xb4\xc3\xd2\xe1"
+ "\xf0\xff\x0e\x1d\x2c\x3b\x4a\x59"
+ "\x68\x77\x86\x95\xa4\xb3\xc2\xd1"
+ "\xe0\xef\xfe\x0d\x1c\x2b\x3a\x49"
+ "\x58\x67\x76\x85\x94\xa3\xb2\xc1"
+ "\xd0\xdf\xee\xfd\x0c\x1b\x2a\x39"
+ "\x48\x57\x66\x75\x84\x93\xa2\xb1"
+ "\xc0\xcf\xde\xed\xfc\x0b\x1a\x29"
+ "\x38\x47\x56\x65\x74\x83\x92\xa1"
+ "\xb0\xbf\xce\xdd\xec\xfb\x0a\x19"
+ "\x28\x37\x46\x55\x64\x73\x82\x91"
+ "\xa0\xaf\xbe\xcd\xdc\xeb\xfa\x09"
+ "\x18\x27\x36\x45\x54\x63\x72\x81"
+ "\x90\x9f\xae\xbd\xcc\xdb\xea\xf9"
+ "\x08\x17\x26\x35\x44\x53\x62\x71"
+ "\x80\x8f\x9e\xad\xbc\xcb\xda\xe9"
+ "\xf8\x07\x16\x25\x34\x43\x52\x61"
+ "\x70\x7f\x8e\x9d\xac\xbb\xca\xd9"
+ "\xe8\xf7\x06\x15\x24\x33\x42\x51"
+ "\x60\x6f\x7e\x8d\x9c\xab\xba\xc9"
+ "\xd8\xe7\xf6\x05\x14\x23\x32\x41"
+ "\x50\x5f\x6e\x7d\x8c\x9b\xaa\xb9"
+ "\xc8\xd7\xe6\xf5\x04\x13\x22\x31"
+ "\x40\x4f\x5e\x6d\x7c\x8b\x9a\xa9"
+ "\xb8\xc7\xd6\xe5\xf4\x03\x12\x21"
+ "\x30\x3f\x4e\x5d\x6c\x7b\x8a\x99"
+ "\xa8\xb7\xc6\xd5\xe4\xf3\x02\x11"
+ "\x20\x2f\x3e\x4d\x5c\x6b\x7a\x89"
+ "\x98\xa7\xb6\xc5\xd4\xe3\xf2\x01"
+ "\x10\x1f\x2e\x3d\x4c\x5b\x6a\x79"
+ "\x88\x97\xa6\xb5\xc4\xd3\xe2\xf1"
+ "\x00\x11\x22\x33\x44\x55\x66\x77"
+ "\x88\x99\xaa\xbb\xcc\xdd\xee\xff"
+ "\x10\x21\x32\x43\x54\x65\x76\x87"
+ "\x98\xa9\xba\xcb\xdc\xed\xfe\x0f"
+ "\x20\x31\x42\x53\x64\x75\x86\x97"
+ "\xa8\xb9\xca\xdb\xec\xfd\x0e\x1f"
+ "\x30\x41\x52\x63\x74\x85\x96\xa7"
+ "\xb8\xc9\xda\xeb\xfc\x0d\x1e\x2f"
+ "\x40\x51\x62\x73\x84\x95\xa6\xb7"
+ "\xc8\xd9\xea\xfb\x0c\x1d\x2e\x3f"
+ "\x50\x61\x72\x83\x94\xa5\xb6\xc7"
+ "\xd8\xe9\xfa\x0b\x1c\x2d\x3e\x4f"
+ "\x60\x71\x82\x93\xa4\xb5\xc6\xd7"
+ "\xe8\xf9\x0a\x1b\x2c\x3d\x4e\x5f"
+ "\x70\x81\x92\xa3\xb4\xc5\xd6\xe7"
+ "\xf8\x09\x1a\x2b\x3c\x4d\x5e\x6f"
+ "\x80\x91\xa2\xb3\xc4\xd5\xe6\xf7"
+ "\x08\x19\x2a\x3b\x4c\x5d\x6e\x7f"
+ "\x90\xa1\xb2\xc3\xd4\xe5\xf6\x07"
+ "\x18\x29\x3a\x4b\x5c\x6d\x7e\x8f"
+ "\xa0\xb1\xc2\xd3\xe4\xf5\x06\x17"
+ "\x28\x39\x4a\x5b\x6c\x7d\x8e\x9f"
+ "\xb0\xc1\xd2\xe3\xf4\x05\x16\x27"
+ "\x38\x49\x5a\x6b\x7c\x8d\x9e\xaf"
+ "\xc0\xd1\xe2\xf3\x04\x15\x26\x37"
+ "\x48\x59\x6a\x7b\x8c\x9d\xae\xbf"
+ "\xd0\xe1\xf2\x03\x14\x25\x36\x47"
+ "\x58\x69\x7a\x8b\x9c\xad\xbe\xcf"
+ "\xe0\xf1\x02\x13\x24\x35\x46\x57"
+ "\x68\x79\x8a\x9b\xac\xbd\xce\xdf"
+ "\xf0\x01\x12\x23\x34\x45\x56\x67"
+ "\x78\x89\x9a\xab\xbc\xcd\xde\xef"
+ "\x00\x13\x26\x39\x4c\x5f\x72\x85"
+ "\x98\xab\xbe\xd1\xe4\xf7\x0a\x1d"
+ "\x30\x43\x56\x69\x7c\x8f\xa2\xb5"
+ "\xc8\xdb\xee\x01\x14\x27\x3a\x4d"
+ "\x60\x73\x86\x99\xac\xbf\xd2\xe5"
+ "\xf8\x0b\x1e\x31\x44\x57\x6a\x7d"
+ "\x90\xa3\xb6\xc9\xdc\xef\x02\x15"
+ "\x28\x3b\x4e\x61\x74\x87\x9a\xad"
+ "\xc0\xd3\xe6\xf9\x0c\x1f\x32\x45"
+ "\x58\x6b\x7e\x91\xa4\xb7\xca\xdd"
+ "\xf0\x03\x16\x29\x3c\x4f\x62\x75"
+ "\x88\x9b\xae\xc1\xd4\xe7\xfa\x0d"
+ "\x20\x33\x46\x59\x6c\x7f\x92\xa5"
+ "\xb8\xcb\xde\xf1\x04\x17\x2a\x3d"
+ "\x50\x63\x76\x89\x9c\xaf\xc2\xd5"
+ "\xe8\xfb\x0e\x21\x34\x47\x5a\x6d"
+ "\x80\x93\xa6\xb9\xcc\xdf\xf2\x05"
+ "\x18\x2b\x3e\x51\x64\x77\x8a\x9d"
+ "\xb0\xc3\xd6\xe9\xfc\x0f\x22\x35"
+ "\x48\x5b\x6e\x81\x94\xa7\xba\xcd"
+ "\xe0\xf3\x06\x19\x2c\x3f\x52\x65"
+ "\x78\x8b\x9e\xb1\xc4\xd7\xea\xfd"
+ "\x10\x23\x36\x49\x5c\x6f\x82\x95"
+ "\xa8\xbb\xce\xe1\xf4\x07\x1a\x2d"
+ "\x40\x53\x66\x79\x8c\x9f\xb2\xc5"
+ "\xd8\xeb\xfe\x11\x24\x37\x4a\x5d"
+ "\x70\x83\x96\xa9\xbc\xcf\xe2\xf5"
+ "\x08\x1b\x2e\x41\x54\x67\x7a\x8d"
+ "\xa0\xb3\xc6\xd9\xec\xff\x12\x25"
+ "\x38\x4b\x5e\x71\x84\x97\xaa\xbd"
+ "\xd0\xe3\xf6\x09\x1c\x2f\x42\x55"
+ "\x68\x7b\x8e\xa1\xb4\xc7\xda\xed"
+ "\x00\x15\x2a\x3f\x54\x69\x7e\x93"
+ "\xa8\xbd\xd2\xe7\xfc\x11\x26\x3b"
+ "\x50\x65\x7a\x8f\xa4\xb9\xce\xe3"
+ "\xf8\x0d\x22\x37\x4c\x61\x76\x8b"
+ "\xa0\xb5\xca\xdf\xf4\x09\x1e\x33"
+ "\x48\x5d\x72\x87\x9c\xb1\xc6\xdb"
+ "\xf0\x05\x1a\x2f\x44\x59\x6e\x83"
+ "\x98\xad\xc2\xd7\xec\x01\x16\x2b"
+ "\x40\x55\x6a\x7f\x94\xa9\xbe\xd3"
+ "\xe8\xfd\x12\x27\x3c\x51\x66\x7b"
+ "\x90\xa5\xba\xcf\xe4\xf9\x0e\x23"
+ "\x38\x4d\x62\x77\x8c\xa1\xb6\xcb"
+ "\xe0\xf5\x0a\x1f\x34\x49\x5e\x73"
+ "\x88\x9d\xb2\xc7\xdc\xf1\x06\x1b"
+ "\x30\x45\x5a\x6f\x84\x99\xae\xc3"
+ "\xd8\xed\x02\x17\x2c\x41\x56\x6b"
+ "\x80\x95\xaa\xbf\xd4\xe9\xfe\x13"
+ "\x28\x3d\x52\x67\x7c\x91\xa6\xbb"
+ "\xd0\xe5\xfa\x0f\x24\x39\x4e\x63"
+ "\x78\x8d\xa2\xb7\xcc\xe1\xf6\x0b"
+ "\x20\x35\x4a\x5f\x74\x89\x9e\xb3"
+ "\xc8\xdd\xf2\x07\x1c\x31\x46\x5b"
+ "\x70\x85\x9a\xaf\xc4\xd9\xee\x03"
+ "\x18\x2d\x42\x57\x6c\x81\x96\xab"
+ "\xc0\xd5\xea\xff\x14\x29\x3e\x53"
+ "\x68\x7d\x92\xa7\xbc\xd1\xe6\xfb"
+ "\x10\x25\x3a\x4f\x64\x79\x8e\xa3"
+ "\xb8\xcd\xe2\xf7\x0c\x21\x36\x4b"
+ "\x60\x75\x8a\x9f\xb4\xc9\xde\xf3"
+ "\x08\x1d\x32\x47\x5c\x71\x86\x9b"
+ "\xb0\xc5\xda\xef\x04\x19\x2e\x43"
+ "\x58\x6d\x82\x97\xac\xc1\xd6\xeb"
+ "\x00\x17\x2e\x45\x5c\x73\x8a\xa1"
+ "\xb8\xcf\xe6\xfd\x14\x2b\x42\x59"
+ "\x70\x87\x9e\xb5\xcc\xe3\xfa\x11"
+ "\x28\x3f\x56\x6d\x84\x9b\xb2\xc9"
+ "\xe0\xf7\x0e\x25\x3c\x53\x6a\x81"
+ "\x98\xaf\xc6\xdd\xf4\x0b\x22\x39"
+ "\x50\x67\x7e\x95\xac\xc3\xda\xf1"
+ "\x08\x1f\x36\x4d\x64\x7b\x92\xa9"
+ "\xc0\xd7\xee\x05\x1c\x33\x4a\x61"
+ "\x78\x8f\xa6\xbd\xd4\xeb\x02\x19"
+ "\x30\x47\x5e\x75\x8c\xa3\xba\xd1"
+ "\xe8\xff\x16\x2d\x44\x5b\x72\x89"
+ "\xa0\xb7\xce\xe5\xfc\x13\x2a\x41"
+ "\x58\x6f\x86\x9d\xb4\xcb\xe2\xf9"
+ "\x10\x27\x3e\x55\x6c\x83\x9a\xb1"
+ "\xc8\xdf\xf6\x0d\x24\x3b\x52\x69"
+ "\x80\x97\xae\xc5\xdc\xf3\x0a\x21"
+ "\x38\x4f\x66\x7d\x94\xab\xc2\xd9"
+ "\xf0\x07\x1e\x35\x4c\x63\x7a\x91"
+ "\xa8\xbf\xd6\xed\x04\x1b\x32\x49"
+ "\x60\x77\x8e\xa5\xbc\xd3\xea\x01"
+ "\x18\x2f\x46\x5d\x74\x8b\xa2\xb9"
+ "\xd0\xe7\xfe\x15\x2c\x43\x5a\x71"
+ "\x88\x9f\xb6\xcd\xe4\xfb\x12\x29"
+ "\x40\x57\x6e\x85\x9c\xb3\xca\xe1"
+ "\xf8\x0f\x26\x3d\x54\x6b\x82\x99"
+ "\xb0\xc7\xde\xf5\x0c\x23\x3a\x51"
+ "\x68\x7f\x96\xad\xc4\xdb\xf2\x09"
+ "\x20\x37\x4e\x65\x7c\x93\xaa\xc1"
+ "\xd8\xef\x06\x1d\x34\x4b\x62\x79"
+ "\x90\xa7\xbe\xd5\xec\x03\x1a\x31"
+ "\x48\x5f\x76\x8d\xa4\xbb\xd2\xe9"
+ "\x00\x19\x32\x4b\x64\x7d\x96\xaf"
+ "\xc8\xe1\xfa\x13\x2c\x45\x5e\x77"
+ "\x90\xa9\xc2\xdb\xf4\x0d\x26\x3f"
+ "\x58\x71\x8a\xa3\xbc\xd5\xee\x07"
+ "\x20\x39\x52\x6b\x84\x9d\xb6\xcf"
+ "\xe8\x01\x1a\x33\x4c\x65\x7e\x97"
+ "\xb0\xc9\xe2\xfb\x14\x2d\x46\x5f"
+ "\x78\x91\xaa\xc3\xdc\xf5\x0e\x27"
+ "\x40\x59\x72\x8b\xa4\xbd\xd6\xef"
+ "\x08\x21\x3a\x53\x6c\x85\x9e\xb7"
+ "\xd0\xe9\x02\x1b\x34\x4d\x66\x7f"
+ "\x98\xb1\xca\xe3\xfc\x15\x2e\x47"
+ "\x60\x79\x92\xab\xc4\xdd\xf6\x0f"
+ "\x28\x41\x5a\x73\x8c\xa5\xbe\xd7"
+ "\xf0\x09\x22\x3b\x54\x6d\x86\x9f"
+ "\xb8\xd1\xea\x03\x1c\x35\x4e\x67"
+ "\x80\x99\xb2\xcb\xe4\xfd\x16\x2f"
+ "\x48\x61\x7a\x93\xac\xc5\xde\xf7"
+ "\x10\x29\x42\x5b\x74\x8d\xa6\xbf"
+ "\xd8\xf1\x0a\x23\x3c\x55\x6e\x87"
+ "\xa0\xb9\xd2\xeb\x04\x1d\x36\x4f"
+ "\x68\x81\x9a\xb3\xcc\xe5\xfe\x17"
+ "\x30\x49\x62\x7b\x94\xad\xc6\xdf"
+ "\xf8\x11\x2a\x43\x5c\x75\x8e\xa7"
+ "\xc0\xd9\xf2\x0b\x24\x3d\x56\x6f"
+ "\x88\xa1\xba\xd3\xec\x05\x1e\x37"
+ "\x50\x69\x82\x9b\xb4\xcd\xe6\xff"
+ "\x18\x31\x4a\x63\x7c\x95\xae\xc7"
+ "\xe0\xf9\x12\x2b\x44\x5d\x76\x8f"
+ "\xa8\xc1\xda\xf3\x0c\x25\x3e\x57"
+ "\x70\x89\xa2\xbb\xd4\xed\x06\x1f"
+ "\x38\x51\x6a\x83\x9c\xb5\xce\xe7"
+ "\x00\x1b\x36\x51\x6c\x87\xa2\xbd"
+ "\xd8\xf3\x0e\x29\x44\x5f\x7a\x95"
+ "\xb0\xcb\xe6\x01\x1c\x37\x52\x6d"
+ "\x88\xa3\xbe\xd9\xf4\x0f\x2a\x45"
+ "\x60\x7b\x96\xb1\xcc\xe7\x02\x1d"
+ "\x38\x53\x6e\x89\xa4\xbf\xda\xf5"
+ "\x10\x2b\x46\x61\x7c\x97\xb2\xcd"
+ "\xe8\x03\x1e\x39\x54\x6f\x8a\xa5"
+ "\xc0\xdb\xf6\x11\x2c\x47\x62\x7d"
+ "\x98\xb3\xce\xe9\x04\x1f\x3a\x55"
+ "\x70\x8b\xa6\xc1\xdc\xf7\x12\x2d"
+ "\x48\x63\x7e\x99\xb4\xcf\xea\x05"
+ "\x20\x3b\x56\x71\x8c\xa7\xc2\xdd"
+ "\xf8\x13\x2e\x49\x64\x7f\x9a\xb5"
+ "\xd0\xeb\x06\x21\x3c\x57\x72\x8d"
+ "\xa8\xc3\xde\xf9\x14\x2f\x4a\x65"
+ "\x80\x9b\xb6\xd1\xec\x07\x22\x3d"
+ "\x58\x73\x8e\xa9\xc4\xdf\xfa\x15"
+ "\x30\x4b\x66\x81\x9c\xb7\xd2\xed"
+ "\x08\x23\x3e\x59\x74\x8f\xaa\xc5"
+ "\xe0\xfb\x16\x31\x4c\x67\x82\x9d"
+ "\xb8\xd3\xee\x09\x24\x3f\x5a\x75"
+ "\x90\xab\xc6\xe1\xfc\x17\x32\x4d"
+ "\x68\x83\x9e\xb9\xd4\xef\x0a\x25"
+ "\x40\x5b\x76\x91\xac\xc7\xe2\xfd"
+ "\x18\x33\x4e\x69\x84\x9f\xba\xd5"
+ "\xf0\x0b\x26\x41\x5c\x77\x92\xad"
+ "\xc8\xe3\xfe\x19\x34\x4f\x6a\x85"
+ "\xa0\xbb\xd6\xf1\x0c\x27\x42\x5d"
+ "\x78\x93\xae\xc9\xe4\xff\x1a\x35"
+ "\x50\x6b\x86\xa1\xbc\xd7\xf2\x0d"
+ "\x28\x43\x5e\x79\x94\xaf\xca\xe5"
+ "\x00\x1d\x3a\x57\x74\x91\xae\xcb"
+ "\xe8\x05\x22\x3f\x5c\x79\x96\xb3"
+ "\xd0\xed\x0a\x27\x44\x61\x7e\x9b"
+ "\xb8\xd5\xf2\x0f\x2c\x49\x66\x83"
+ "\xa0\xbd\xda\xf7\x14\x31\x4e\x6b"
+ "\x88\xa5\xc2\xdf\xfc\x19\x36\x53"
+ "\x70\x8d\xaa\xc7\xe4\x01\x1e\x3b"
+ "\x58\x75\x92\xaf\xcc\xe9\x06\x23"
+ "\x40\x5d\x7a\x97\xb4\xd1\xee\x0b"
+ "\x28\x45\x62\x7f\x9c\xb9\xd6\xf3"
+ "\x10\x2d\x4a\x67\x84\xa1\xbe\xdb"
+ "\xf8\x15\x32\x4f\x6c\x89\xa6\xc3"
+ "\xe0\xfd\x1a\x37\x54\x71\x8e\xab"
+ "\xc8\xe5\x02\x1f\x3c\x59\x76\x93"
+ "\xb0\xcd\xea\x07\x24\x41\x5e\x7b"
+ "\x98\xb5\xd2\xef\x0c\x29\x46\x63"
+ "\x80\x9d\xba\xd7\xf4\x11\x2e\x4b"
+ "\x68\x85\xa2\xbf\xdc\xf9\x16\x33"
+ "\x50\x6d\x8a\xa7\xc4\xe1\xfe\x1b"
+ "\x38\x55\x72\x8f\xac\xc9\xe6\x03"
+ "\x20\x3d\x5a\x77\x94\xb1\xce\xeb"
+ "\x08\x25\x42\x5f\x7c\x99\xb6\xd3"
+ "\xf0\x0d\x2a\x47\x64\x81\x9e\xbb"
+ "\xd8\xf5\x12\x2f\x4c\x69\x86\xa3"
+ "\xc0\xdd\xfa\x17\x34\x51\x6e\x8b"
+ "\xa8\xc5\xe2\xff\x1c\x39\x56\x73"
+ "\x90\xad\xca\xe7\x04\x21\x3e\x5b"
+ "\x78\x95\xb2\xcf\xec\x09\x26\x43"
+ "\x60\x7d\x9a\xb7\xd4\xf1\x0e\x2b"
+ "\x48\x65\x82\x9f\xbc\xd9\xf6\x13"
+ "\x30\x4d\x6a\x87\xa4\xc1\xde\xfb"
+ "\x18\x35\x52\x6f\x8c\xa9\xc6\xe3"
+ "\x00\x1f\x3e\x5d\x7c\x9b\xba\xd9"
+ "\xf8\x17\x36\x55\x74\x93\xb2\xd1"
+ "\xf0\x0f\x2e\x4d\x6c\x8b\xaa\xc9"
+ "\xe8\x07\x26\x45\x64\x83\xa2\xc1"
+ "\xe0\xff\x1e\x3d\x5c\x7b\x9a\xb9"
+ "\xd8\xf7\x16\x35\x54\x73\x92\xb1"
+ "\xd0\xef\x0e\x2d\x4c\x6b\x8a\xa9"
+ "\xc8\xe7\x06\x25\x44\x63\x82\xa1"
+ "\xc0\xdf\xfe\x1d\x3c\x5b\x7a\x99"
+ "\xb8\xd7\xf6\x15\x34\x53\x72\x91"
+ "\xb0\xcf\xee\x0d\x2c\x4b\x6a\x89"
+ "\xa8\xc7\xe6\x05\x24\x43\x62\x81"
+ "\xa0\xbf\xde\xfd\x1c\x3b\x5a\x79"
+ "\x98\xb7\xd6\xf5\x14\x33\x52\x71"
+ "\x90\xaf\xce\xed\x0c\x2b\x4a\x69"
+ "\x88\xa7\xc6\xe5\x04\x23\x42\x61"
+ "\x80\x9f\xbe\xdd\xfc\x1b\x3a\x59"
+ "\x78\x97\xb6\xd5\xf4\x13\x32\x51"
+ "\x70\x8f\xae\xcd\xec\x0b\x2a\x49"
+ "\x68\x87\xa6\xc5\xe4\x03\x22\x41"
+ "\x60\x7f\x9e\xbd\xdc\xfb\x1a\x39"
+ "\x58\x77\x96\xb5\xd4\xf3\x12\x31"
+ "\x50\x6f\x8e\xad\xcc\xeb\x0a\x29"
+ "\x48\x67\x86\xa5\xc4\xe3\x02\x21"
+ "\x40\x5f\x7e\x9d\xbc\xdb\xfa\x19"
+ "\x38\x57\x76\x95\xb4\xd3\xf2\x11"
+ "\x30\x4f\x6e\x8d\xac\xcb\xea\x09"
+ "\x28\x47\x66\x85\xa4\xc3\xe2\x01"
+ "\x20\x3f\x5e\x7d\x9c\xbb\xda\xf9"
+ "\x18\x37\x56\x75\x94\xb3\xd2\xf1"
+ "\x10\x2f\x4e\x6d\x8c\xab\xca\xe9"
+ "\x08\x27\x46\x65\x84\xa3\xc2\xe1"
+ "\x00\x21\x42\x63",
+ .ilen = 4100,
+ .result =
+ "\xf0\x5c\x74\xad\x4e\xbc\x99\xe2"
+ "\xae\xff\x91\x3a\x44\xcf\x38\x32"
+ "\x1e\xad\xa7\xcd\xa1\x39\x95\xaa"
+ "\x10\xb1\xb3\x2e\x04\x31\x8f\x86"
+ "\xf2\x62\x74\x70\x0c\xa4\x46\x08"
+ "\xa8\xb7\x99\xa8\xe9\xd2\x73\x79"
+ "\x7e\x6e\xd4\x8f\x1e\xc7\x8e\x31"
+ "\x0b\xfa\x4b\xce\xfd\xf3\x57\x71"
+ "\xe9\x46\x03\xa5\x3d\x34\x00\xe2"
+ "\x18\xff\x75\x6d\x06\x2d\x00\xab"
+ "\xb9\x3e\x6c\x59\xc5\x84\x06\xb5"
+ "\x8b\xd0\x89\x9c\x4a\x79\x16\xc6"
+ "\x3d\x74\x54\xfa\x44\xcd\x23\x26"
+ "\x5c\xcf\x7e\x28\x92\x32\xbf\xdf"
+ "\xa7\x20\x3c\x74\x58\x2a\x9a\xde"
+ "\x61\x00\x1c\x4f\xff\x59\xc4\x22"
+ "\xac\x3c\xd0\xe8\x6c\xf9\x97\x1b"
+ "\x58\x9b\xad\x71\xe8\xa9\xb5\x0d"
+ "\xee\x2f\x04\x1f\x7f\xbc\x99\xee"
+ "\x84\xff\x42\x60\xdc\x3a\x18\xa5"
+ "\x81\xf9\xef\xdc\x7a\x0f\x65\x41"
+ "\x2f\xa3\xd3\xf9\xc2\xcb\xc0\x4d"
+ "\x8f\xd3\x76\x96\xad\x49\x6d\x38"
+ "\x3d\x39\x0b\x6c\x80\xb7\x54\x69"
+ "\xf0\x2c\x90\x02\x29\x0d\x1c\x12"
+ "\xad\x55\xc3\x8b\x68\xd9\xcc\xb3"
+ "\xb2\x64\x33\x90\x5e\xca\x4b\xe2"
+ "\xfb\x75\xdc\x63\xf7\x9f\x82\x74"
+ "\xf0\xc9\xaa\x7f\xe9\x2a\x9b\x33"
+ "\xbc\x88\x00\x7f\xca\xb2\x1f\x14"
+ "\xdb\xc5\x8e\x7b\x11\x3c\x3e\x08"
+ "\xf3\x83\xe8\xe0\x94\x86\x2e\x92"
+ "\x78\x6b\x01\xc9\xc7\x83\xba\x21"
+ "\x6a\x25\x15\x33\x4e\x45\x08\xec"
+ "\x35\xdb\xe0\x6e\x31\x51\x79\xa9"
+ "\x42\x44\x65\xc1\xa0\xf1\xf9\x2a"
+ "\x70\xd5\xb6\xc6\xc1\x8c\x39\xfc"
+ "\x25\xa6\x55\xd9\xdd\x2d\x4c\xec"
+ "\x49\xc6\xeb\x0e\xa8\x25\x2a\x16"
+ "\x1b\x66\x84\xda\xe2\x92\xe5\xc0"
+ "\xc8\x53\x07\xaf\x80\x84\xec\xfd"
+ "\xcd\xd1\x6e\xcd\x6f\x6a\xf5\x36"
+ "\xc5\x15\xe5\x25\x7d\x77\xd1\x1a"
+ "\x93\x36\xa9\xcf\x7c\xa4\x54\x4a"
+ "\x06\x51\x48\x4e\xf6\x59\x87\xd2"
+ "\x04\x02\xef\xd3\x44\xde\x76\x31"
+ "\xb3\x34\x17\x1b\x9d\x66\x11\x9f"
+ "\x1e\xcc\x17\xe9\xc7\x3c\x1b\xe7"
+ "\xcb\x50\x08\xfc\xdc\x2b\x24\xdb"
+ "\x65\x83\xd0\x3b\xe3\x30\xea\x94"
+ "\x6c\xe7\xe8\x35\x32\xc7\xdb\x64"
+ "\xb4\x01\xab\x36\x2c\x77\x13\xaf"
+ "\xf8\x2b\x88\x3f\x54\x39\xc4\x44"
+ "\xfe\xef\x6f\x68\x34\xbe\x0f\x05"
+ "\x16\x6d\xf6\x0a\x30\xe7\xe3\xed"
+ "\xc4\xde\x3c\x1b\x13\xd8\xdb\xfe"
+ "\x41\x62\xe5\x28\xd4\x8d\xa3\xc7"
+ "\x93\x97\xc6\x48\x45\x1d\x9f\x83"
+ "\xdf\x4b\x40\x3e\x42\x25\x87\x80"
+ "\x4c\x7d\xa8\xd4\x98\x23\x95\x75"
+ "\x41\x8c\xda\x41\x9b\xd4\xa7\x06"
+ "\xb5\xf1\x71\x09\x53\xbe\xca\xbf"
+ "\x32\x03\xed\xf0\x50\x1c\x56\x39"
+ "\x5b\xa4\x75\x18\xf7\x9b\x58\xef"
+ "\x53\xfc\x2a\x38\x23\x15\x75\xcd"
+ "\x45\xe5\x5a\x82\x55\xba\x21\xfa"
+ "\xd4\xbd\xc6\x94\x7c\xc5\x80\x12"
+ "\xf7\x4b\x32\xc4\x9a\x82\xd8\x28"
+ "\x8f\xd9\xc2\x0f\x60\x03\xbe\x5e"
+ "\x21\xd6\x5f\x58\xbf\x5c\xb1\x32"
+ "\x82\x8d\xa9\xe5\xf2\x66\x1a\xc0"
+ "\xa0\xbc\x58\x2f\x71\xf5\x2f\xed"
+ "\xd1\x26\xb9\xd8\x49\x5a\x07\x19"
+ "\x01\x7c\x59\xb0\xf8\xa4\xb7\xd3"
+ "\x7b\x1a\x8c\x38\xf4\x50\xa4\x59"
+ "\xb0\xcc\x41\x0b\x88\x7f\xe5\x31"
+ "\xb3\x42\xba\xa2\x7e\xd4\x32\x71"
+ "\x45\x87\x48\xa9\xc2\xf2\x89\xb3"
+ "\xe4\xa7\x7e\x52\x15\x61\xfa\xfe"
+ "\xc9\xdd\x81\xeb\x13\xab\xab\xc3"
+ "\x98\x59\xd8\x16\x3d\x14\x7a\x1c"
+ "\x3c\x41\x9a\x16\x16\x9b\xd2\xd2"
+ "\x69\x3a\x29\x23\xac\x86\x32\xa5"
+ "\x48\x9c\x9e\xf3\x47\x77\x81\x70"
+ "\x24\xe8\x85\xd2\xf5\xb5\xfa\xff"
+ "\x59\x6a\xd3\x50\x59\x43\x59\xde"
+ "\xd9\xf1\x55\xa5\x0c\xc3\x1a\x1a"
+ "\x18\x34\x0d\x1a\x63\x33\xed\x10"
+ "\xe0\x1d\x2a\x18\xd2\xc0\x54\xa8"
+ "\xca\xb5\x9a\xd3\xdd\xca\x45\x84"
+ "\x50\xe7\x0f\xfe\xa4\x99\x5a\xbe"
+ "\x43\x2d\x9a\xcb\x92\x3f\x5a\x1d"
+ "\x85\xd8\xc9\xdf\x68\xc9\x12\x80"
+ "\x56\x0c\xdc\x00\xdc\x3a\x7d\x9d"
+ "\xa3\xa2\xe8\x4d\xbf\xf9\x70\xa0"
+ "\xa4\x13\x4f\x6b\xaf\x0a\x89\x7f"
+ "\xda\xf0\xbf\x9b\xc8\x1d\xe5\xf8"
+ "\x2e\x8b\x07\xb5\x73\x1b\xcc\xa2"
+ "\xa6\xad\x30\xbc\x78\x3c\x5b\x10"
+ "\xfa\x5e\x62\x2d\x9e\x64\xb3\x33"
+ "\xce\xf9\x1f\x86\xe7\x8b\xa2\xb8"
+ "\xe8\x99\x57\x8c\x11\xed\x66\xd9"
+ "\x3c\x72\xb9\xc3\xe6\x4e\x17\x3a"
+ "\x6a\xcb\x42\x24\x06\xed\x3e\x4e"
+ "\xa3\xe8\x6a\x94\xda\x0d\x4e\xd5"
+ "\x14\x19\xcf\xb6\x26\xd8\x2e\xcc"
+ "\x64\x76\x38\x49\x4d\xfe\x30\x6d"
+ "\xe4\xc8\x8c\x7b\xc4\xe0\x35\xba"
+ "\x22\x6e\x76\xe1\x1a\xf2\x53\xc3"
+ "\x28\xa2\x82\x1f\x61\x69\xad\xc1"
+ "\x7b\x28\x4b\x1e\x6c\x85\x95\x9b"
+ "\x51\xb5\x17\x7f\x12\x69\x8c\x24"
+ "\xd5\xc7\x5a\x5a\x11\x54\xff\x5a"
+ "\xf7\x16\xc3\x91\xa6\xf0\xdc\x0a"
+ "\xb6\xa7\x4a\x0d\x7a\x58\xfe\xa5"
+ "\xf5\xcb\x8f\x7b\x0e\xea\x57\xe7"
+ "\xbd\x79\xd6\x1c\x88\x23\x6c\xf2"
+ "\x4d\x29\x77\x53\x35\x6a\x00\x8d"
+ "\xcd\xa3\x58\xbe\x77\x99\x18\xf8"
+ "\xe6\xe1\x8f\xe9\x37\x8f\xe3\xe2"
+ "\x5a\x8a\x93\x25\xaf\xf3\x78\x80"
+ "\xbe\xa6\x1b\xc6\xac\x8b\x1c\x91"
+ "\x58\xe1\x9f\x89\x35\x9d\x1d\x21"
+ "\x29\x9f\xf4\x99\x02\x27\x0f\xa8"
+ "\x4f\x79\x94\x2b\x33\x2c\xda\xa2"
+ "\x26\x39\x83\x94\xef\x27\xd8\x53"
+ "\x8f\x66\x0d\xe4\x41\x7d\x34\xcd"
+ "\x43\x7c\x95\x0a\x53\xef\x66\xda"
+ "\x7e\x9b\xf3\x93\xaf\xd0\x73\x71"
+ "\xba\x40\x9b\x74\xf8\xd7\xd7\x41"
+ "\x6d\xaf\x72\x9c\x8d\x21\x87\x3c"
+ "\xfd\x0a\x90\xa9\x47\x96\x9e\xd3"
+ "\x88\xee\x73\xcf\x66\x2f\x52\x56"
+ "\x6d\xa9\x80\x4c\xe2\x6f\x62\x88"
+ "\x3f\x0e\x54\x17\x48\x80\x5d\xd3"
+ "\xc3\xda\x25\x3d\xa1\xc8\xcb\x9f"
+ "\x9b\x70\xb3\xa1\xeb\x04\x52\xa1"
+ "\xf2\x22\x0f\xfc\xc8\x18\xfa\xf9"
+ "\x85\x9c\xf1\xac\xeb\x0c\x02\x46"
+ "\x75\xd2\xf5\x2c\xe3\xd2\x59\x94"
+ "\x12\xf3\x3c\xfc\xd7\x92\xfa\x36"
+ "\xba\x61\x34\x38\x7c\xda\x48\x3e"
+ "\x08\xc9\x39\x23\x5e\x02\x2c\x1a"
+ "\x18\x7e\xb4\xd9\xfd\x9e\x40\x02"
+ "\xb1\x33\x37\x32\xe7\xde\xd6\xd0"
+ "\x7c\x58\x65\x4b\xf8\x34\x27\x9c"
+ "\x44\xb4\xbd\xe9\xe9\x4c\x78\x7d"
+ "\x4b\x9f\xce\xb1\xcd\x47\xa5\x37"
+ "\xe5\x6d\xbd\xb9\x43\x94\x0a\xd4"
+ "\xd6\xf9\x04\x5f\xb5\x66\x6c\x1a"
+ "\x35\x12\xe3\x36\x28\x27\x36\x58"
+ "\x01\x2b\x79\xe4\xba\x6d\x10\x7d"
+ "\x65\xdf\x84\x95\xf4\xd5\xb6\x8f"
+ "\x2b\x9f\x96\x00\x86\x60\xf0\x21"
+ "\x76\xa8\x6a\x8c\x28\x1c\xb3\x6b"
+ "\x97\xd7\xb6\x53\x2a\xcc\xab\x40"
+ "\x9d\x62\x79\x58\x52\xe6\x65\xb7"
+ "\xab\x55\x67\x9c\x89\x7c\x03\xb0"
+ "\x73\x59\xc5\x81\xf5\x18\x17\x5c"
+ "\x89\xf3\x78\x35\x44\x62\x78\x72"
+ "\xd0\x96\xeb\x31\xe7\x87\x77\x14"
+ "\x99\x51\xf2\x59\x26\x9e\xb5\xa6"
+ "\x45\xfe\x6e\xbd\x07\x4c\x94\x5a"
+ "\xa5\x7d\xfc\xf1\x2b\x77\xe2\xfe"
+ "\x17\xd4\x84\xa0\xac\xb5\xc7\xda"
+ "\xa9\x1a\xb6\xf3\x74\x11\xb4\x9d"
+ "\xfb\x79\x2e\x04\x2d\x50\x28\x83"
+ "\xbf\xc6\x52\xd3\x34\xd6\xe8\x7a"
+ "\xb6\xea\xe7\xa8\x6c\x15\x1e\x2c"
+ "\x57\xbc\x48\x4e\x5f\x5c\xb6\x92"
+ "\xd2\x49\x77\x81\x6d\x90\x70\xae"
+ "\x98\xa1\x03\x0d\x6b\xb9\x77\x14"
+ "\xf1\x4e\x23\xd3\xf8\x68\xbd\xc2"
+ "\xfe\x04\xb7\x5c\xc5\x17\x60\x8f"
+ "\x65\x54\xa4\x7a\x42\xdc\x18\x0d"
+ "\xb5\xcf\x0f\xd3\xc7\x91\x66\x1b"
+ "\x45\x42\x27\x75\x50\xe5\xee\xb8"
+ "\x7f\x33\x2c\xba\x4a\x92\x4d\x2c"
+ "\x3c\xe3\x0d\x80\x01\xba\x0d\x29"
+ "\xd8\x3c\xe9\x13\x16\x57\xe6\xea"
+ "\x94\x52\xe7\x00\x4d\x30\xb0\x0f"
+ "\x35\xb8\xb8\xa7\xb1\xb5\x3b\x44"
+ "\xe1\x2f\xfd\x88\xed\x43\xe7\x52"
+ "\x10\x93\xb3\x8a\x30\x6b\x0a\xf7"
+ "\x23\xc6\x50\x9d\x4a\xb0\xde\xc3"
+ "\xdc\x9b\x2f\x01\x56\x36\x09\xc5"
+ "\x2f\x6b\xfe\xf1\xd8\x27\x45\x03"
+ "\x30\x5e\x5c\x5b\xb4\x62\x0e\x1a"
+ "\xa9\x21\x2b\x92\x94\x87\x62\x57"
+ "\x4c\x10\x74\x1a\xf1\x0a\xc5\x84"
+ "\x3b\x9e\x72\x02\xd7\xcc\x09\x56"
+ "\xbd\x54\xc1\xf0\xc3\xe3\xb3\xf8"
+ "\xd2\x0d\x61\xcb\xef\xce\x0d\x05"
+ "\xb0\x98\xd9\x8e\x4f\xf9\xbc\x93"
+ "\xa6\xea\xc8\xcf\x10\x53\x4b\xf1"
+ "\xec\xfc\x89\xf9\x64\xb0\x22\xbf"
+ "\x9e\x55\x46\x9f\x7c\x50\x8e\x84"
+ "\x54\x20\x98\xd7\x6c\x40\x1e\xdb"
+ "\x69\x34\x78\x61\x24\x21\x9c\x8a"
+ "\xb3\x62\x31\x8b\x6e\xf5\x2a\x35"
+ "\x86\x13\xb1\x6c\x64\x2e\x41\xa5"
+ "\x05\xf2\x42\xba\xd2\x3a\x0d\x8e"
+ "\x8a\x59\x94\x3c\xcf\x36\x27\x82"
+ "\xc2\x45\xee\x58\xcd\x88\xb4\xec"
+ "\xde\xb2\x96\x0a\xaf\x38\x6f\x88"
+ "\xd7\xd8\xe1\xdf\xb9\x96\xa9\x0a"
+ "\xb1\x95\x28\x86\x20\xe9\x17\x49"
+ "\xa2\x29\x38\xaa\xa5\xe9\x6e\xf1"
+ "\x19\x27\xc0\xd5\x2a\x22\xc3\x0b"
+ "\xdb\x7c\x73\x10\xb9\xba\x89\x76"
+ "\x54\xae\x7d\x71\xb3\x93\xf6\x32"
+ "\xe6\x47\x43\x55\xac\xa0\x0d\xc2"
+ "\x93\x27\x4a\x8e\x0e\x74\x15\xc7"
+ "\x0b\x85\xd9\x0c\xa9\x30\x7a\x3e"
+ "\xea\x8f\x85\x6d\x3a\x12\x4f\x72"
+ "\x69\x58\x7a\x80\xbb\xb5\x97\xf3"
+ "\xcf\x70\xd2\x5d\xdd\x4d\x21\x79"
+ "\x54\x4d\xe4\x05\xe8\xbd\xc2\x62"
+ "\xb1\x3b\x77\x1c\xd6\x5c\xf3\xa0"
+ "\x79\x00\xa8\x6c\x29\xd9\x18\x24"
+ "\x36\xa2\x46\xc0\x96\x65\x7f\xbd"
+ "\x2a\xed\x36\x16\x0c\xaa\x9f\xf4"
+ "\xc5\xb4\xe2\x12\xed\x69\xed\x4f"
+ "\x26\x2c\x39\x52\x89\x98\xe7\x2c"
+ "\x99\xa4\x9e\xa3\x9b\x99\x46\x7a"
+ "\x3a\xdc\xa8\x59\xa3\xdb\xc3\x3b"
+ "\x95\x0d\x3b\x09\x6e\xee\x83\x5d"
+ "\x32\x4d\xed\xab\xfa\x98\x14\x4e"
+ "\xc3\x15\x45\x53\x61\xc4\x93\xbd"
+ "\x90\xf4\x99\x95\x4c\xe6\x76\x92"
+ "\x29\x90\x46\x30\x92\x69\x7d\x13"
+ "\xf2\xa5\xcd\x69\x49\x44\xb2\x0f"
+ "\x63\x40\x36\x5f\x09\xe2\x78\xf8"
+ "\x91\xe3\xe2\xfa\x10\xf7\xc8\x24"
+ "\xa8\x89\x32\x5c\x37\x25\x1d\xb2"
+ "\xea\x17\x8a\x0a\xa9\x64\xc3\x7c"
+ "\x3c\x7c\xbd\xc6\x79\x34\xe7\xe2"
+ "\x85\x8e\xbf\xf8\xde\x92\xa0\xae"
+ "\x20\xc4\xf6\xbb\x1f\x38\x19\x0e"
+ "\xe8\x79\x9c\xa1\x23\xe9\x54\x7e"
+ "\x37\x2f\xe2\x94\x32\xaf\xa0\x23"
+ "\x49\xe4\xc0\xb3\xac\x00\x8f\x36"
+ "\x05\xc4\xa6\x96\xec\x05\x98\x4f"
+ "\x96\x67\x57\x1f\x20\x86\x1b\x2d"
+ "\x69\xe4\x29\x93\x66\x5f\xaf\x6b"
+ "\x88\x26\x2c\x67\x02\x4b\x52\xd0"
+ "\x83\x7a\x43\x1f\xc0\x71\x15\x25"
+ "\x77\x65\x08\x60\x11\x76\x4c\x8d"
+ "\xed\xa9\x27\xc6\xb1\x2a\x2c\x6a"
+ "\x4a\x97\xf5\xc6\xb7\x70\x42\xd3"
+ "\x03\xd1\x24\x95\xec\x6d\xab\x38"
+ "\x72\xce\xe2\x8b\x33\xd7\x51\x09"
+ "\xdc\x45\xe0\x09\x96\x32\xf3\xc4"
+ "\x84\xdc\x73\x73\x2d\x1b\x11\x98"
+ "\xc5\x0e\x69\x28\x94\xc7\xb5\x4d"
+ "\xc8\x8a\xd0\xaa\x13\x2e\x18\x74"
+ "\xdd\xd1\x1e\xf3\x90\xe8\xfc\x9a"
+ "\x72\x4a\x0e\xd1\xe4\xfb\x0d\x96"
+ "\xd1\x0c\x79\x85\x1b\x1c\xfe\xe1"
+ "\x62\x8f\x7a\x73\x32\xab\xc8\x18"
+ "\x69\xe3\x34\x30\xdf\x13\xa6\xe5"
+ "\xe8\x0e\x67\x7f\x81\x11\xb4\x60"
+ "\xc7\xbd\x79\x65\x50\xdc\xc4\x5b"
+ "\xde\x39\xa4\x01\x72\x63\xf3\xd1"
+ "\x64\x4e\xdf\xfc\x27\x92\x37\x0d"
+ "\x57\xcd\x11\x4f\x11\x04\x8e\x1d"
+ "\x16\xf7\xcd\x92\x9a\x99\x30\x14"
+ "\xf1\x7c\x67\x1b\x1f\x41\x0b\xe8"
+ "\x32\xe8\xb8\xc1\x4f\x54\x86\x4f"
+ "\xe5\x79\x81\x73\xcd\x43\x59\x68"
+ "\x73\x02\x3b\x78\x21\x72\x43\x00"
+ "\x49\x17\xf7\x00\xaf\x68\x24\x53"
+ "\x05\x0a\xc3\x33\xe0\x33\x3f\x69"
+ "\xd2\x84\x2f\x0b\xed\xde\x04\xf4"
+ "\x11\x94\x13\x69\x51\x09\x28\xde"
+ "\x57\x5c\xef\xdc\x9a\x49\x1c\x17"
+ "\x97\xf3\x96\xc1\x7f\x5d\x2e\x7d"
+ "\x55\xb8\xb3\x02\x09\xb3\x1f\xe7"
+ "\xc9\x8d\xa3\x36\x34\x8a\x77\x13"
+ "\x30\x63\x4c\xa5\xcd\xc3\xe0\x7e"
+ "\x05\xa1\x7b\x0c\xcb\x74\x47\x31"
+ "\x62\x03\x43\xf1\x87\xb4\xb0\x85"
+ "\x87\x8e\x4b\x25\xc7\xcf\xae\x4b"
+ "\x36\x46\x3e\x62\xbc\x6f\xeb\x5f"
+ "\x73\xac\xe6\x07\xee\xc1\xa1\xd6"
+ "\xc4\xab\xc9\xd6\x89\x45\xe1\xf1"
+ "\x04\x4e\x1a\x6f\xbb\x4f\x3a\xa3"
+ "\xa0\xcb\xa3\x0a\xd8\x71\x35\x55"
+ "\xe4\xbc\x2e\x04\x06\xe6\xff\x5b"
+ "\x1c\xc0\x11\x7c\xc5\x17\xf3\x38"
+ "\xcf\xe9\xba\x0f\x0e\xef\x02\xc2"
+ "\x8d\xc6\xbc\x4b\x67\x20\x95\xd7"
+ "\x2c\x45\x5b\x86\x44\x8c\x6f\x2e"
+ "\x7e\x9f\x1c\x77\xba\x6b\x0e\xa3"
+ "\x69\xdc\xab\x24\x57\x60\x47\xc1"
+ "\xd1\xa5\x9d\x23\xe6\xb1\x37\xfe"
+ "\x93\xd2\x4c\x46\xf9\x0c\xc6\xfb"
+ "\xd6\x9d\x99\x69\xab\x7a\x07\x0c"
+ "\x65\xe7\xc4\x08\x96\xe2\xa5\x01"
+ "\x3f\x46\x07\x05\x7e\xe8\x9a\x90"
+ "\x50\xdc\xe9\x7a\xea\xa1\x39\x6e"
+ "\x66\xe4\x6f\xa5\x5f\xb2\xd9\x5b"
+ "\xf5\xdb\x2a\x32\xf0\x11\x6f\x7c"
+ "\x26\x10\x8f\x3d\x80\xe9\x58\xf7"
+ "\xe0\xa8\x57\xf8\xdb\x0e\xce\x99"
+ "\x63\x19\x3d\xd5\xec\x1b\x77\x69"
+ "\x98\xf6\xe4\x5f\x67\x17\x4b\x09"
+ "\x85\x62\x82\x70\x18\xe2\x9a\x78"
+ "\xe2\x62\xbd\xb4\xf1\x42\xc6\xfb"
+ "\x08\xd0\xbd\xeb\x4e\x09\xf2\xc8"
+ "\x1e\xdc\x3d\x32\x21\x56\x9c\x4f"
+ "\x35\xf3\x61\x06\x72\x84\xc4\x32"
+ "\xf2\xf1\xfa\x0b\x2f\xc3\xdb\x02"
+ "\x04\xc2\xde\x57\x64\x60\x8d\xcf"
+ "\xcb\x86\x5d\x97\x3e\xb1\x9c\x01"
+ "\xd6\x28\x8f\x99\xbc\x46\xeb\x05"
+ "\xaf\x7e\xb8\x21\x2a\x56\x85\x1c"
+ "\xb3\x71\xa0\xde\xca\x96\xf1\x78"
+ "\x49\xa2\x99\x81\x80\x5c\x01\xf5"
+ "\xa0\xa2\x56\x63\xe2\x70\x07\xa5"
+ "\x95\xd6\x85\xeb\x36\x9e\xa9\x51"
+ "\x66\x56\x5f\x1d\x02\x19\xe2\xf6"
+ "\x4f\x73\x38\x09\x75\x64\x48\xe0"
+ "\xf1\x7e\x0e\xe8\x9d\xf9\xed\x94"
+ "\xfe\x16\x26\x62\x49\x74\xf4\xb0"
+ "\xd4\xa9\x6c\xb0\xfd\x53\xe9\x81"
+ "\xe0\x7a\xbf\xcf\xb5\xc4\x01\x81"
+ "\x79\x99\x77\x01\x3b\xe9\xa2\xb6"
+ "\xe6\x6a\x8a\x9e\x56\x1c\x8d\x1e"
+ "\x8f\x06\x55\x2c\x6c\xdc\x92\x87"
+ "\x64\x3b\x4b\x19\xa1\x13\x64\x1d"
+ "\x4a\xe9\xc0\x00\xb8\x95\xef\x6b"
+ "\x1a\x86\x6d\x37\x52\x02\xc2\xe0"
+ "\xc8\xbb\x42\x0c\x02\x21\x4a\xc9"
+ "\xef\xa0\x54\xe4\x5e\x16\x53\x81"
+ "\x70\x62\x10\xaf\xde\xb8\xb5\xd3"
+ "\xe8\x5e\x6c\xc3\x8a\x3e\x18\x07"
+ "\xf2\x2f\x7d\xa7\xe1\x3d\x4e\xb4"
+ "\x26\xa7\xa3\x93\x86\xb2\x04\x1e"
+ "\x53\x5d\x86\xd6\xde\x65\xca\xe3"
+ "\x4e\xc1\xcf\xef\xc8\x70\x1b\x83"
+ "\x13\xdd\x18\x8b\x0d\x76\xd2\xf6"
+ "\x37\x7a\x93\x7a\x50\x11\x9f\x96"
+ "\x86\x25\xfd\xac\xdc\xbe\x18\x93"
+ "\x19\x6b\xec\x58\x4f\xb9\x75\xa7"
+ "\xdd\x3f\x2f\xec\xc8\x5a\x84\xab"
+ "\xd5\xe4\x8a\x07\xf6\x4d\x23\xd6"
+ "\x03\xfb\x03\x6a\xea\x66\xbf\xd4"
+ "\xb1\x34\xfb\x78\xe9\x55\xdc\x7c"
+ "\x3d\x9c\xe5\x9a\xac\xc3\x7a\x80"
+ "\x24\x6d\xa0\xef\x25\x7c\xb7\xea"
+ "\xce\x4d\x5f\x18\x60\xce\x87\x22"
+ "\x66\x2f\xd5\xdd\xdd\x02\x21\x75"
+ "\x82\xa0\x1f\x58\xc6\xd3\x62\xf7"
+ "\x32\xd8\xaf\x1e\x07\x77\x51\x96"
+ "\xd5\x6b\x1e\x7e\x80\x02\xe8\x67"
+ "\xea\x17\x0b\x10\xd2\x3f\x28\x25"
+ "\x4f\x05\x77\x02\x14\x69\xf0\x2c"
+ "\xbe\x0c\xf1\x74\x30\xd1\xb9\x9b"
+ "\xfc\x8c\xbb\x04\x16\xd9\xba\xc3"
+ "\xbc\x91\x8a\xc4\x30\xa4\xb0\x12"
+ "\x4c\x21\x87\xcb\xc9\x1d\x16\x96"
+ "\x07\x6f\x23\x54\xb9\x6f\x79\xe5"
+ "\x64\xc0\x64\xda\xb1\xae\xdd\x60"
+ "\x6c\x1a\x9d\xd3\x04\x8e\x45\xb0"
+ "\x92\x61\xd0\x48\x81\xed\x5e\x1d"
+ "\xa0\xc9\xa4\x33\xc7\x13\x51\x5d"
+ "\x7f\x83\x73\xb6\x70\x18\x65\x3e"
+ "\x2f\x0e\x7a\x12\x39\x98\xab\xd8"
+ "\x7e\x6f\xa3\xd1\xba\x56\xad\xbd"
+ "\xf0\x03\x01\x1c\x85\x35\x9f\xeb"
+ "\x19\x63\xa1\xaf\xfe\x2d\x35\x50"
+ "\x39\xa0\x65\x7c\x95\x7e\x6b\xfe"
+ "\xc1\xac\x07\x7c\x98\x4f\xbe\x57"
+ "\xa7\x22\xec\xe2\x7e\x29\x09\x53"
+ "\xe8\xbf\xb4\x7e\x3f\x8f\xfc\x14"
+ "\xce\x54\xf9\x18\x58\xb5\xff\x44"
+ "\x05\x9d\xce\x1b\xb6\x82\x23\xc8"
+ "\x2e\xbc\x69\xbb\x4a\x29\x0f\x65"
+ "\x94\xf0\x63\x06\x0e\xef\x8c\xbd"
+ "\xff\xfd\xb0\x21\x6e\x57\x05\x75"
+ "\xda\xd5\xc4\xeb\x8d\x32\xf7\x50"
+ "\xd3\x6f\x22\xed\x5f\x8e\xa2\x5b"
+ "\x80\x8c\xc8\x78\x40\x24\x4b\x89"
+ "\x30\xce\x7a\x97\x0e\xc4\xaf\xef"
+ "\x9b\xb4\xcd\x66\x74\x14\x04\x2b"
+ "\xf7\xce\x0b\x1c\x6e\xc2\x78\x8c"
+ "\xca\xc5\xd0\x1c\x95\x4a\x91\x2d"
+ "\xa7\x20\xeb\x86\x52\xb7\x67\xd8"
+ "\x0c\xd6\x04\x14\xde\x51\x74\x75"
+ "\xe7\x11\xb4\x87\xa3\x3d\x2d\xad"
+ "\x4f\xef\xa0\x0f\x70\x00\x6d\x13"
+ "\x19\x1d\x41\x50\xe9\xd8\xf0\x32"
+ "\x71\xbc\xd3\x11\xf2\xac\xbe\xaf"
+ "\x75\x46\x65\x4e\x07\x34\x37\xa3"
+ "\x89\xfe\x75\xd4\x70\x4c\xc6\x3f"
+ "\x69\x24\x0e\x38\x67\x43\x8c\xde"
+ "\x06\xb5\xb8\xe7\xc4\xf0\x41\x8f"
+ "\xf0\xbd\x2f\x0b\xb9\x18\xf8\xde"
+ "\x64\xb1\xdb\xee\x00\x50\x77\xe1"
+ "\xc7\xff\xa6\xfa\xdd\x70\xf4\xe3"
+ "\x93\xe9\x77\x35\x3d\x4b\x2f\x2b"
+ "\x6d\x55\xf0\xfc\x88\x54\x4e\x89"
+ "\xc1\x8a\x23\x31\x2d\x14\x2a\xb8"
+ "\x1b\x15\xdd\x9e\x6e\x7b\xda\x05"
+ "\x91\x7d\x62\x64\x96\x72\xde\xfc"
+ "\xc1\xec\xf0\x23\x51\x6f\xdb\x5b"
+ "\x1d\x08\x57\xce\x09\xb8\xf6\xcd"
+ "\x8d\x95\xf2\x20\xbf\x0f\x20\x57"
+ "\x98\x81\x84\x4f\x15\x5c\x76\xe7"
+ "\x3e\x0a\x3a\x6c\xc4\x8a\xbe\x78"
+ "\x74\x77\xc3\x09\x4b\x5d\x48\xe4"
+ "\xc8\xcb\x0b\xea\x17\x28\xcf\xcf"
+ "\x31\x32\x44\xa4\xe5\x0e\x1a\x98"
+ "\x94\xc4\xf0\xff\xae\x3e\x44\xe8"
+ "\xa5\xb3\xb5\x37\x2f\xe8\xaf\x6f"
+ "\x28\xc1\x37\x5f\x31\xd2\xb9\x33"
+ "\xb1\xb2\x52\x94\x75\x2c\x29\x59"
+ "\x06\xc2\x25\xe8\x71\x65\x4e\xed"
+ "\xc0\x9c\xb1\xbb\x25\xdc\x6c\xe7"
+ "\x4b\xa5\x7a\x54\x7a\x60\xff\x7a"
+ "\xe0\x50\x40\x96\x35\x63\xe4\x0b"
+ "\x76\xbd\xa4\x65\x00\x1b\x57\x88"
+ "\xae\xed\x39\x88\x42\x11\x3c\xed"
+ "\x85\x67\x7d\xb9\x68\x82\xe9\x43"
+ "\x3c\x47\x53\xfa\xe8\xf8\x9f\x1f"
+ "\x9f\xef\x0f\xf7\x30\xd9\x30\x0e"
+ "\xb9\x9f\x69\x18\x2f\x7e\xf8\xf8"
+ "\xf8\x8c\x0f\xd4\x02\x4d\xea\xcd"
+ "\x0a\x9c\x6f\x71\x6d\x5a\x4c\x60"
+ "\xce\x20\x56\x32\xc6\xc5\x99\x1f"
+ "\x09\xe6\x4e\x18\x1a\x15\x13\xa8"
+ "\x7d\xb1\x6b\xc0\xb2\x6d\xf8\x26"
+ "\x66\xf8\x3d\x18\x74\x70\x66\x7a"
+ "\x34\x17\xde\xba\x47\xf1\x06\x18"
+ "\xcb\xaf\xeb\x4a\x1e\x8f\xa7\x77"
+ "\xe0\x3b\x78\x62\x66\xc9\x10\xea"
+ "\x1f\xb7\x29\x0a\x45\xa1\x1d\x1e"
+ "\x1d\xe2\x65\x61\x50\x9c\xd7\x05"
+ "\xf2\x0b\x5b\x12\x61\x02\xc8\xe5"
+ "\x63\x4f\x20\x0c\x07\x17\x33\x5e"
+ "\x03\x9a\x53\x0f\x2e\x55\xfe\x50"
+ "\x43\x7d\xd0\xb6\x7e\x5a\xda\xae"
+ "\x58\xef\x15\xa9\x83\xd9\x46\xb1"
+ "\x42\xaa\xf5\x02\x6c\xce\x92\x06"
+ "\x1b\xdb\x66\x45\x91\x79\xc2\x2d"
+ "\xe6\x53\xd3\x14\xfd\xbb\x44\x63"
+ "\xc6\xd7\x3d\x7a\x0c\x75\x78\x9d"
+ "\x5c\xa6\x39\xb3\xe5\x63\xca\x8b"
+ "\xfe\xd3\xef\x60\x83\xf6\x8e\x70"
+ "\xb6\x67\xc7\x77\xed\x23\xef\x4c"
+ "\xf0\xed\x2d\x07\x59\x6f\xc1\x01"
+ "\x34\x37\x08\xab\xd9\x1f\x09\xb1"
+ "\xce\x5b\x17\xff\x74\xf8\x9c\xd5"
+ "\x2c\x56\x39\x79\x0f\x69\x44\x75"
+ "\x58\x27\x01\xc4\xbf\xa7\xa1\x1d"
+ "\x90\x17\x77\x86\x5a\x3f\xd9\xd1"
+ "\x0e\xa0\x10\xf8\xec\x1e\xa5\x7f"
+ "\x5e\x36\xd1\xe3\x04\x2c\x70\xf7"
+ "\x8e\xc0\x98\x2f\x6c\x94\x2b\x41"
+ "\xb7\x60\x00\xb7\x2e\xb8\x02\x8d"
+ "\xb8\xb0\xd3\x86\xba\x1d\xd7\x90"
+ "\xd6\xb6\xe1\xfc\xd7\xd8\x28\x06"
+ "\x63\x9b\xce\x61\x24\x79\xc0\x70"
+ "\x52\xd0\xb6\xd4\x28\x95\x24\x87"
+ "\x03\x1f\xb7\x9a\xda\xa3\xfb\x52"
+ "\x5b\x68\xe7\x4c\x8c\x24\xe1\x42"
+ "\xf7\xd5\xfd\xad\x06\x32\x9f\xba"
+ "\xc1\xfc\xdd\xc6\xfc\xfc\xb3\x38"
+ "\x74\x56\x58\x40\x02\x37\x52\x2c"
+ "\x55\xcc\xb3\x9e\x7a\xe9\xd4\x38"
+ "\x41\x5e\x0c\x35\xe2\x11\xd1\x13"
+ "\xf8\xb7\x8d\x72\x6b\x22\x2a\xb0"
+ "\xdb\x08\xba\x35\xb9\x3f\xc8\xd3"
+ "\x24\x90\xec\x58\xd2\x09\xc7\x2d"
+ "\xed\x38\x80\x36\x72\x43\x27\x49"
+ "\x4a\x80\x8a\xa2\xe8\xd3\xda\x30"
+ "\x7d\xb6\x82\x37\x86\x92\x86\x3e"
+ "\x08\xb2\x28\x5a\x55\x44\x24\x7d"
+ "\x40\x48\x8a\xb6\x89\x58\x08\xa0"
+ "\xd6\x6d\x3a\x17\xbf\xf6\x54\xa2"
+ "\xf5\xd3\x8c\x0f\x78\x12\x57\x8b"
+ "\xd5\xc2\xfd\x58\x5b\x7f\x38\xe3"
+ "\xcc\xb7\x7c\x48\xb3\x20\xe8\x81"
+ "\x14\x32\x45\x05\xe0\xdb\x9f\x75"
+ "\x85\xb4\x6a\xfc\x95\xe3\x54\x22"
+ "\x12\xee\x30\xfe\xd8\x30\xef\x34"
+ "\x50\xab\x46\x30\x98\x2f\xb7\xc0"
+ "\x15\xa2\x83\xb6\xf2\x06\x21\xa2"
+ "\xc3\x26\x37\x14\xd1\x4d\xb5\x10"
+ "\x52\x76\x4d\x6a\xee\xb5\x2b\x15"
+ "\xb7\xf9\x51\xe8\x2a\xaf\xc7\xfa"
+ "\x77\xaf\xb0\x05\x4d\xd1\x68\x8e"
+ "\x74\x05\x9f\x9d\x93\xa5\x3e\x7f"
+ "\x4e\x5f\x9d\xcb\x09\xc7\x83\xe3"
+ "\x02\x9d\x27\x1f\xef\x85\x05\x8d"
+ "\xec\x55\x88\x0f\x0d\x7c\x4c\xe8"
+ "\xa1\x75\xa0\xd8\x06\x47\x14\xef"
+ "\xaa\x61\xcf\x26\x15\xad\xd8\xa3"
+ "\xaa\x75\xf2\x78\x4a\x5a\x61\xdf"
+ "\x8b\xc7\x04\xbc\xb2\x32\xd2\x7e"
+ "\x42\xee\xb4\x2f\x51\xff\x7b\x2e"
+ "\xd3\x02\xe8\xdc\x5d\x0d\x50\xdc"
+ "\xae\xb7\x46\xf9\xa8\xe6\xd0\x16"
+ "\xcc\xe6\x2c\x81\xc7\xad\xe9\xf0"
+ "\x05\x72\x6d\x3d\x0a\x7a\xa9\x02"
+ "\xac\x82\x93\x6e\xb6\x1c\x28\xfc"
+ "\x44\x12\xfb\x73\x77\xd4\x13\x39"
+ "\x29\x88\x8a\xf3\x5c\xa6\x36\xa0"
+ "\x2a\xed\x7e\xb1\x1d\xd6\x4c\x6b"
+ "\x41\x01\x18\x5d\x5d\x07\x97\xa6"
+ "\x4b\xef\x31\x18\xea\xac\xb1\x84"
+ "\x21\xed\xda\x86",
+ .rlen = 4100,
+ .np = 2,
+ .tap = { 4064, 36 },
+#endif
+ },
+};
+
+static struct cipher_testvec aes_ctr_rfc3686_dec_tv_template[] = {
+ { /* From RFC 3686 */
+ .key = "\xae\x68\x52\xf8\x12\x10\x67\xcc"
+ "\x4b\xf7\xa5\x76\x55\x77\xf3\x9e"
+ "\x00\x00\x00\x30",
+ .klen = 20,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .input = "\xe4\x09\x5d\x4f\xb7\xa7\xb3\x79"
+ "\x2d\x61\x75\xa3\x26\x13\x11\xb8",
+ .ilen = 16,
+ .result = "Single block msg",
+ .rlen = 16,
+ }, {
+ .key = "\x7e\x24\x06\x78\x17\xfa\xe0\xd7"
+ "\x43\xd6\xce\x1f\x32\x53\x91\x63"
+ "\x00\x6c\xb6\xdb",
+ .klen = 20,
+ .iv = "\xc0\x54\x3b\x59\xda\x48\xd9\x0b",
+ .input = "\x51\x04\xa1\x06\x16\x8a\x72\xd9"
+ "\x79\x0d\x41\xee\x8e\xda\xd3\x88"
+ "\xeb\x2e\x1e\xfc\x46\xda\x57\xc8"
+ "\xfc\xe6\x30\xdf\x91\x41\xbe\x28",
+ .ilen = 32,
+ .result = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
+ .rlen = 32,
+ }, {
+ .key = "\x16\xaf\x5b\x14\x5f\xc9\xf5\x79"
+ "\xc1\x75\xf9\x3e\x3b\xfb\x0e\xed"
+ "\x86\x3d\x06\xcc\xfd\xb7\x85\x15"
+ "\x00\x00\x00\x48",
+ .klen = 28,
+ .iv = "\x36\x73\x3c\x14\x7d\x6d\x93\xcb",
+ .input = "\x4b\x55\x38\x4f\xe2\x59\xc9\xc8"
+ "\x4e\x79\x35\xa0\x03\xcb\xe9\x28",
+ .ilen = 16,
+ .result = "Single block msg",
+ .rlen = 16,
+ }, {
+ .key = "\x7c\x5c\xb2\x40\x1b\x3d\xc3\x3c"
+ "\x19\xe7\x34\x08\x19\xe0\xf6\x9c"
+ "\x67\x8c\x3d\xb8\xe6\xf6\xa9\x1a"
+ "\x00\x96\xb0\x3b",
+ .klen = 28,
+ .iv = "\x02\x0c\x6e\xad\xc2\xcb\x50\x0d",
+ .input = "\x45\x32\x43\xfc\x60\x9b\x23\x32"
+ "\x7e\xdf\xaa\xfa\x71\x31\xcd\x9f"
+ "\x84\x90\x70\x1c\x5a\xd4\xa7\x9c"
+ "\xfc\x1f\xe0\xff\x42\xf4\xfb\x00",
+ .ilen = 32,
+ .result = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
+ .rlen = 32,
+ }, {
+ .key = "\x77\x6b\xef\xf2\x85\x1d\xb0\x6f"
+ "\x4c\x8a\x05\x42\xc8\x69\x6f\x6c"
+ "\x6a\x81\xaf\x1e\xec\x96\xb4\xd3"
+ "\x7f\xc1\xd6\x89\xe6\xc1\xc1\x04"
+ "\x00\x00\x00\x60",
+ .klen = 36,
+ .iv = "\xdb\x56\x72\xc9\x7a\xa8\xf0\xb2",
+ .input = "\x14\x5a\xd0\x1d\xbf\x82\x4e\xc7"
+ "\x56\x08\x63\xdc\x71\xe3\xe0\xc0",
+ .ilen = 16,
+ .result = "Single block msg",
+ .rlen = 16,
+ }, {
+ .key = "\xf6\xd6\x6d\x6b\xd5\x2d\x59\xbb"
+ "\x07\x96\x36\x58\x79\xef\xf8\x86"
+ "\xc6\x6d\xd5\x1a\x5b\x6a\x99\x74"
+ "\x4b\x50\x59\x0c\x87\xa2\x38\x84"
+ "\x00\xfa\xac\x24",
+ .klen = 36,
+ .iv = "\xc1\x58\x5e\xf1\x5a\x43\xd8\x75",
+ .input = "\xf0\x5e\x23\x1b\x38\x94\x61\x2c"
+ "\x49\xee\x00\x0b\x80\x4e\xb2\xa9"
+ "\xb8\x30\x6b\x50\x8f\x83\x9d\x6a"
+ "\x55\x30\x83\x1d\x93\x44\xaf\x1c",
+ .ilen = 32,
+ .result = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
+ .rlen = 32,
+ },
+};
+
+static struct aead_testvec aes_gcm_enc_tv_template[] = {
+ { /* From McGrew & Viega - http://citeseer.ist.psu.edu/656989.html */
+ .key = zeroed_string,
+ .klen = 16,
+ .result = "\x58\xe2\xfc\xce\xfa\x7e\x30\x61"
+ "\x36\x7f\x1d\x57\xa4\xe7\x45\x5a",
+ .rlen = 16,
+ }, {
+ .key = zeroed_string,
+ .klen = 16,
+ .input = zeroed_string,
+ .ilen = 16,
+ .result = "\x03\x88\xda\xce\x60\xb6\xa3\x92"
+ "\xf3\x28\xc2\xb9\x71\xb2\xfe\x78"
+ "\xab\x6e\x47\xd4\x2c\xec\x13\xbd"
+ "\xf5\x3a\x67\xb2\x12\x57\xbd\xdf",
+ .rlen = 32,
+ }, {
+ .key = "\xfe\xff\xe9\x92\x86\x65\x73\x1c"
+ "\x6d\x6a\x8f\x94\x67\x30\x83\x08",
+ .klen = 16,
+ .iv = "\xca\xfe\xba\xbe\xfa\xce\xdb\xad"
+ "\xde\xca\xf8\x88",
+ .input = "\xd9\x31\x32\x25\xf8\x84\x06\xe5"
+ "\xa5\x59\x09\xc5\xaf\xf5\x26\x9a"
+ "\x86\xa7\xa9\x53\x15\x34\xf7\xda"
+ "\x2e\x4c\x30\x3d\x8a\x31\x8a\x72"
+ "\x1c\x3c\x0c\x95\x95\x68\x09\x53"
+ "\x2f\xcf\x0e\x24\x49\xa6\xb5\x25"
+ "\xb1\x6a\xed\xf5\xaa\x0d\xe6\x57"
+ "\xba\x63\x7b\x39\x1a\xaf\xd2\x55",
+ .ilen = 64,
+ .result = "\x42\x83\x1e\xc2\x21\x77\x74\x24"
+ "\x4b\x72\x21\xb7\x84\xd0\xd4\x9c"
+ "\xe3\xaa\x21\x2f\x2c\x02\xa4\xe0"
+ "\x35\xc1\x7e\x23\x29\xac\xa1\x2e"
+ "\x21\xd5\x14\xb2\x54\x66\x93\x1c"
+ "\x7d\x8f\x6a\x5a\xac\x84\xaa\x05"
+ "\x1b\xa3\x0b\x39\x6a\x0a\xac\x97"
+ "\x3d\x58\xe0\x91\x47\x3f\x59\x85"
+ "\x4d\x5c\x2a\xf3\x27\xcd\x64\xa6"
+ "\x2c\xf3\x5a\xbd\x2b\xa6\xfa\xb4",
+ .rlen = 80,
+ }, {
+ .key = "\xfe\xff\xe9\x92\x86\x65\x73\x1c"
+ "\x6d\x6a\x8f\x94\x67\x30\x83\x08",
+ .klen = 16,
+ .iv = "\xca\xfe\xba\xbe\xfa\xce\xdb\xad"
+ "\xde\xca\xf8\x88",
+ .input = "\xd9\x31\x32\x25\xf8\x84\x06\xe5"
+ "\xa5\x59\x09\xc5\xaf\xf5\x26\x9a"
+ "\x86\xa7\xa9\x53\x15\x34\xf7\xda"
+ "\x2e\x4c\x30\x3d\x8a\x31\x8a\x72"
+ "\x1c\x3c\x0c\x95\x95\x68\x09\x53"
+ "\x2f\xcf\x0e\x24\x49\xa6\xb5\x25"
+ "\xb1\x6a\xed\xf5\xaa\x0d\xe6\x57"
+ "\xba\x63\x7b\x39",
+ .ilen = 60,
+ .assoc = "\xfe\xed\xfa\xce\xde\xad\xbe\xef"
+ "\xfe\xed\xfa\xce\xde\xad\xbe\xef"
+ "\xab\xad\xda\xd2",
+ .alen = 20,
+ .result = "\x42\x83\x1e\xc2\x21\x77\x74\x24"
+ "\x4b\x72\x21\xb7\x84\xd0\xd4\x9c"
+ "\xe3\xaa\x21\x2f\x2c\x02\xa4\xe0"
+ "\x35\xc1\x7e\x23\x29\xac\xa1\x2e"
+ "\x21\xd5\x14\xb2\x54\x66\x93\x1c"
+ "\x7d\x8f\x6a\x5a\xac\x84\xaa\x05"
+ "\x1b\xa3\x0b\x39\x6a\x0a\xac\x97"
+ "\x3d\x58\xe0\x91"
+ "\x5b\xc9\x4f\xbc\x32\x21\xa5\xdb"
+ "\x94\xfa\xe9\x5a\xe7\x12\x1a\x47",
+ .rlen = 76,
+ }, {
+ .key = zeroed_string,
+ .klen = 24,
+ .result = "\xcd\x33\xb2\x8a\xc7\x73\xf7\x4b"
+ "\xa0\x0e\xd1\xf3\x12\x57\x24\x35",
+ .rlen = 16,
+ }, {
+ .key = zeroed_string,
+ .klen = 24,
+ .input = zeroed_string,
+ .ilen = 16,
+ .result = "\x98\xe7\x24\x7c\x07\xf0\xfe\x41"
+ "\x1c\x26\x7e\x43\x84\xb0\xf6\x00"
+ "\x2f\xf5\x8d\x80\x03\x39\x27\xab"
+ "\x8e\xf4\xd4\x58\x75\x14\xf0\xfb",
+ .rlen = 32,
+ }, {
+ .key = "\xfe\xff\xe9\x92\x86\x65\x73\x1c"
+ "\x6d\x6a\x8f\x94\x67\x30\x83\x08"
+ "\xfe\xff\xe9\x92\x86\x65\x73\x1c",
+ .klen = 24,
+ .iv = "\xca\xfe\xba\xbe\xfa\xce\xdb\xad"
+ "\xde\xca\xf8\x88",
+ .input = "\xd9\x31\x32\x25\xf8\x84\x06\xe5"
+ "\xa5\x59\x09\xc5\xaf\xf5\x26\x9a"
+ "\x86\xa7\xa9\x53\x15\x34\xf7\xda"
+ "\x2e\x4c\x30\x3d\x8a\x31\x8a\x72"
+ "\x1c\x3c\x0c\x95\x95\x68\x09\x53"
+ "\x2f\xcf\x0e\x24\x49\xa6\xb5\x25"
+ "\xb1\x6a\xed\xf5\xaa\x0d\xe6\x57"
+ "\xba\x63\x7b\x39\x1a\xaf\xd2\x55",
+ .ilen = 64,
+ .result = "\x39\x80\xca\x0b\x3c\x00\xe8\x41"
+ "\xeb\x06\xfa\xc4\x87\x2a\x27\x57"
+ "\x85\x9e\x1c\xea\xa6\xef\xd9\x84"
+ "\x62\x85\x93\xb4\x0c\xa1\xe1\x9c"
+ "\x7d\x77\x3d\x00\xc1\x44\xc5\x25"
+ "\xac\x61\x9d\x18\xc8\x4a\x3f\x47"
+ "\x18\xe2\x44\x8b\x2f\xe3\x24\xd9"
+ "\xcc\xda\x27\x10\xac\xad\xe2\x56"
+ "\x99\x24\xa7\xc8\x58\x73\x36\xbf"
+ "\xb1\x18\x02\x4d\xb8\x67\x4a\x14",
+ .rlen = 80,
+ }, {
+ .key = "\xfe\xff\xe9\x92\x86\x65\x73\x1c"
+ "\x6d\x6a\x8f\x94\x67\x30\x83\x08"
+ "\xfe\xff\xe9\x92\x86\x65\x73\x1c",
+ .klen = 24,
+ .iv = "\xca\xfe\xba\xbe\xfa\xce\xdb\xad"
+ "\xde\xca\xf8\x88",
+ .input = "\xd9\x31\x32\x25\xf8\x84\x06\xe5"
+ "\xa5\x59\x09\xc5\xaf\xf5\x26\x9a"
+ "\x86\xa7\xa9\x53\x15\x34\xf7\xda"
+ "\x2e\x4c\x30\x3d\x8a\x31\x8a\x72"
+ "\x1c\x3c\x0c\x95\x95\x68\x09\x53"
+ "\x2f\xcf\x0e\x24\x49\xa6\xb5\x25"
+ "\xb1\x6a\xed\xf5\xaa\x0d\xe6\x57"
+ "\xba\x63\x7b\x39",
+ .ilen = 60,
+ .assoc = "\xfe\xed\xfa\xce\xde\xad\xbe\xef"
+ "\xfe\xed\xfa\xce\xde\xad\xbe\xef"
+ "\xab\xad\xda\xd2",
+ .alen = 20,
+ .result = "\x39\x80\xca\x0b\x3c\x00\xe8\x41"
+ "\xeb\x06\xfa\xc4\x87\x2a\x27\x57"
+ "\x85\x9e\x1c\xea\xa6\xef\xd9\x84"
+ "\x62\x85\x93\xb4\x0c\xa1\xe1\x9c"
+ "\x7d\x77\x3d\x00\xc1\x44\xc5\x25"
+ "\xac\x61\x9d\x18\xc8\x4a\x3f\x47"
+ "\x18\xe2\x44\x8b\x2f\xe3\x24\xd9"
+ "\xcc\xda\x27\x10"
+ "\x25\x19\x49\x8e\x80\xf1\x47\x8f"
+ "\x37\xba\x55\xbd\x6d\x27\x61\x8c",
+ .rlen = 76,
+ .np = 2,
+ .tap = { 32, 28 },
+ .anp = 2,
+ .atap = { 8, 12 }
+ }, {
+ .key = zeroed_string,
+ .klen = 32,
+ .result = "\x53\x0f\x8a\xfb\xc7\x45\x36\xb9"
+ "\xa9\x63\xb4\xf1\xc4\xcb\x73\x8b",
+ .rlen = 16,
+ }
+};
+
+static struct aead_testvec aes_gcm_dec_tv_template[] = {
+ { /* From McGrew & Viega - http://citeseer.ist.psu.edu/656989.html */
+ .key = zeroed_string,
+ .klen = 32,
+ .input = "\xce\xa7\x40\x3d\x4d\x60\x6b\x6e"
+ "\x07\x4e\xc5\xd3\xba\xf3\x9d\x18"
+ "\xd0\xd1\xc8\xa7\x99\x99\x6b\xf0"
+ "\x26\x5b\x98\xb5\xd4\x8a\xb9\x19",
+ .ilen = 32,
+ .result = zeroed_string,
+ .rlen = 16,
+ }, {
+ .key = "\xfe\xff\xe9\x92\x86\x65\x73\x1c"
+ "\x6d\x6a\x8f\x94\x67\x30\x83\x08"
+ "\xfe\xff\xe9\x92\x86\x65\x73\x1c"
+ "\x6d\x6a\x8f\x94\x67\x30\x83\x08",
+ .klen = 32,
+ .iv = "\xca\xfe\xba\xbe\xfa\xce\xdb\xad"
+ "\xde\xca\xf8\x88",
+ .input = "\x52\x2d\xc1\xf0\x99\x56\x7d\x07"
+ "\xf4\x7f\x37\xa3\x2a\x84\x42\x7d"
+ "\x64\x3a\x8c\xdc\xbf\xe5\xc0\xc9"
+ "\x75\x98\xa2\xbd\x25\x55\xd1\xaa"
+ "\x8c\xb0\x8e\x48\x59\x0d\xbb\x3d"
+ "\xa7\xb0\x8b\x10\x56\x82\x88\x38"
+ "\xc5\xf6\x1e\x63\x93\xba\x7a\x0a"
+ "\xbc\xc9\xf6\x62\x89\x80\x15\xad"
+ "\xb0\x94\xda\xc5\xd9\x34\x71\xbd"
+ "\xec\x1a\x50\x22\x70\xe3\xcc\x6c",
+ .ilen = 80,
+ .result = "\xd9\x31\x32\x25\xf8\x84\x06\xe5"
+ "\xa5\x59\x09\xc5\xaf\xf5\x26\x9a"
+ "\x86\xa7\xa9\x53\x15\x34\xf7\xda"
+ "\x2e\x4c\x30\x3d\x8a\x31\x8a\x72"
+ "\x1c\x3c\x0c\x95\x95\x68\x09\x53"
+ "\x2f\xcf\x0e\x24\x49\xa6\xb5\x25"
+ "\xb1\x6a\xed\xf5\xaa\x0d\xe6\x57"
+ "\xba\x63\x7b\x39\x1a\xaf\xd2\x55",
+ .rlen = 64,
+ }, {
+ .key = "\xfe\xff\xe9\x92\x86\x65\x73\x1c"
+ "\x6d\x6a\x8f\x94\x67\x30\x83\x08"
+ "\xfe\xff\xe9\x92\x86\x65\x73\x1c"
+ "\x6d\x6a\x8f\x94\x67\x30\x83\x08",
+ .klen = 32,
+ .iv = "\xca\xfe\xba\xbe\xfa\xce\xdb\xad"
+ "\xde\xca\xf8\x88",
+ .input = "\x52\x2d\xc1\xf0\x99\x56\x7d\x07"
+ "\xf4\x7f\x37\xa3\x2a\x84\x42\x7d"
+ "\x64\x3a\x8c\xdc\xbf\xe5\xc0\xc9"
+ "\x75\x98\xa2\xbd\x25\x55\xd1\xaa"
+ "\x8c\xb0\x8e\x48\x59\x0d\xbb\x3d"
+ "\xa7\xb0\x8b\x10\x56\x82\x88\x38"
+ "\xc5\xf6\x1e\x63\x93\xba\x7a\x0a"
+ "\xbc\xc9\xf6\x62"
+ "\x76\xfc\x6e\xce\x0f\x4e\x17\x68"
+ "\xcd\xdf\x88\x53\xbb\x2d\x55\x1b",
+ .ilen = 76,
+ .assoc = "\xfe\xed\xfa\xce\xde\xad\xbe\xef"
+ "\xfe\xed\xfa\xce\xde\xad\xbe\xef"
+ "\xab\xad\xda\xd2",
+ .alen = 20,
+ .result = "\xd9\x31\x32\x25\xf8\x84\x06\xe5"
+ "\xa5\x59\x09\xc5\xaf\xf5\x26\x9a"
+ "\x86\xa7\xa9\x53\x15\x34\xf7\xda"
+ "\x2e\x4c\x30\x3d\x8a\x31\x8a\x72"
+ "\x1c\x3c\x0c\x95\x95\x68\x09\x53"
+ "\x2f\xcf\x0e\x24\x49\xa6\xb5\x25"
+ "\xb1\x6a\xed\xf5\xaa\x0d\xe6\x57"
+ "\xba\x63\x7b\x39",
+ .rlen = 60,
+ .np = 2,
+ .tap = { 48, 28 },
+ .anp = 3,
+ .atap = { 8, 8, 4 }
+ }, {
+ .key = "\xfe\xff\xe9\x92\x86\x65\x73\x1c"
+ "\x6d\x6a\x8f\x94\x67\x30\x83\x08",
+ .klen = 16,
+ .iv = "\xca\xfe\xba\xbe\xfa\xce\xdb\xad"
+ "\xde\xca\xf8\x88",
+ .input = "\x42\x83\x1e\xc2\x21\x77\x74\x24"
+ "\x4b\x72\x21\xb7\x84\xd0\xd4\x9c"
+ "\xe3\xaa\x21\x2f\x2c\x02\xa4\xe0"
+ "\x35\xc1\x7e\x23\x29\xac\xa1\x2e"
+ "\x21\xd5\x14\xb2\x54\x66\x93\x1c"
+ "\x7d\x8f\x6a\x5a\xac\x84\xaa\x05"
+ "\x1b\xa3\x0b\x39\x6a\x0a\xac\x97"
+ "\x3d\x58\xe0\x91\x47\x3f\x59\x85"
+ "\x4d\x5c\x2a\xf3\x27\xcd\x64\xa6"
+ "\x2c\xf3\x5a\xbd\x2b\xa6\xfa\xb4",
+ .ilen = 80,
+ .result = "\xd9\x31\x32\x25\xf8\x84\x06\xe5"
+ "\xa5\x59\x09\xc5\xaf\xf5\x26\x9a"
+ "\x86\xa7\xa9\x53\x15\x34\xf7\xda"
+ "\x2e\x4c\x30\x3d\x8a\x31\x8a\x72"
+ "\x1c\x3c\x0c\x95\x95\x68\x09\x53"
+ "\x2f\xcf\x0e\x24\x49\xa6\xb5\x25"
+ "\xb1\x6a\xed\xf5\xaa\x0d\xe6\x57"
+ "\xba\x63\x7b\x39\x1a\xaf\xd2\x55",
+ .rlen = 64,
+ }, {
+ .key = "\xfe\xff\xe9\x92\x86\x65\x73\x1c"
+ "\x6d\x6a\x8f\x94\x67\x30\x83\x08",
+ .klen = 16,
+ .iv = "\xca\xfe\xba\xbe\xfa\xce\xdb\xad"
+ "\xde\xca\xf8\x88",
+ .input = "\x42\x83\x1e\xc2\x21\x77\x74\x24"
+ "\x4b\x72\x21\xb7\x84\xd0\xd4\x9c"
+ "\xe3\xaa\x21\x2f\x2c\x02\xa4\xe0"
+ "\x35\xc1\x7e\x23\x29\xac\xa1\x2e"
+ "\x21\xd5\x14\xb2\x54\x66\x93\x1c"
+ "\x7d\x8f\x6a\x5a\xac\x84\xaa\x05"
+ "\x1b\xa3\x0b\x39\x6a\x0a\xac\x97"
+ "\x3d\x58\xe0\x91"
+ "\x5b\xc9\x4f\xbc\x32\x21\xa5\xdb"
+ "\x94\xfa\xe9\x5a\xe7\x12\x1a\x47",
+ .ilen = 76,
+ .assoc = "\xfe\xed\xfa\xce\xde\xad\xbe\xef"
+ "\xfe\xed\xfa\xce\xde\xad\xbe\xef"
+ "\xab\xad\xda\xd2",
+ .alen = 20,
+ .result = "\xd9\x31\x32\x25\xf8\x84\x06\xe5"
+ "\xa5\x59\x09\xc5\xaf\xf5\x26\x9a"
+ "\x86\xa7\xa9\x53\x15\x34\xf7\xda"
+ "\x2e\x4c\x30\x3d\x8a\x31\x8a\x72"
+ "\x1c\x3c\x0c\x95\x95\x68\x09\x53"
+ "\x2f\xcf\x0e\x24\x49\xa6\xb5\x25"
+ "\xb1\x6a\xed\xf5\xaa\x0d\xe6\x57"
+ "\xba\x63\x7b\x39",
+ .rlen = 60,
+ }, {
+ .key = zeroed_string,
+ .klen = 24,
+ .input = "\x98\xe7\x24\x7c\x07\xf0\xfe\x41"
+ "\x1c\x26\x7e\x43\x84\xb0\xf6\x00"
+ "\x2f\xf5\x8d\x80\x03\x39\x27\xab"
+ "\x8e\xf4\xd4\x58\x75\x14\xf0\xfb",
+ .ilen = 32,
+ .result = zeroed_string,
+ .rlen = 16,
+ }, {
+ .key = "\xfe\xff\xe9\x92\x86\x65\x73\x1c"
+ "\x6d\x6a\x8f\x94\x67\x30\x83\x08"
+ "\xfe\xff\xe9\x92\x86\x65\x73\x1c",
+ .klen = 24,
+ .iv = "\xca\xfe\xba\xbe\xfa\xce\xdb\xad"
+ "\xde\xca\xf8\x88",
+ .input = "\x39\x80\xca\x0b\x3c\x00\xe8\x41"
+ "\xeb\x06\xfa\xc4\x87\x2a\x27\x57"
+ "\x85\x9e\x1c\xea\xa6\xef\xd9\x84"
+ "\x62\x85\x93\xb4\x0c\xa1\xe1\x9c"
+ "\x7d\x77\x3d\x00\xc1\x44\xc5\x25"
+ "\xac\x61\x9d\x18\xc8\x4a\x3f\x47"
+ "\x18\xe2\x44\x8b\x2f\xe3\x24\xd9"
+ "\xcc\xda\x27\x10\xac\xad\xe2\x56"
+ "\x99\x24\xa7\xc8\x58\x73\x36\xbf"
+ "\xb1\x18\x02\x4d\xb8\x67\x4a\x14",
+ .ilen = 80,
+ .result = "\xd9\x31\x32\x25\xf8\x84\x06\xe5"
+ "\xa5\x59\x09\xc5\xaf\xf5\x26\x9a"
+ "\x86\xa7\xa9\x53\x15\x34\xf7\xda"
+ "\x2e\x4c\x30\x3d\x8a\x31\x8a\x72"
+ "\x1c\x3c\x0c\x95\x95\x68\x09\x53"
+ "\x2f\xcf\x0e\x24\x49\xa6\xb5\x25"
+ "\xb1\x6a\xed\xf5\xaa\x0d\xe6\x57"
+ "\xba\x63\x7b\x39\x1a\xaf\xd2\x55",
+ .rlen = 64,
+ }, {
+ .key = "\xfe\xff\xe9\x92\x86\x65\x73\x1c"
+ "\x6d\x6a\x8f\x94\x67\x30\x83\x08"
+ "\xfe\xff\xe9\x92\x86\x65\x73\x1c",
+ .klen = 24,
+ .iv = "\xca\xfe\xba\xbe\xfa\xce\xdb\xad"
+ "\xde\xca\xf8\x88",
+ .input = "\x39\x80\xca\x0b\x3c\x00\xe8\x41"
+ "\xeb\x06\xfa\xc4\x87\x2a\x27\x57"
+ "\x85\x9e\x1c\xea\xa6\xef\xd9\x84"
+ "\x62\x85\x93\xb4\x0c\xa1\xe1\x9c"
+ "\x7d\x77\x3d\x00\xc1\x44\xc5\x25"
+ "\xac\x61\x9d\x18\xc8\x4a\x3f\x47"
+ "\x18\xe2\x44\x8b\x2f\xe3\x24\xd9"
+ "\xcc\xda\x27\x10"
+ "\x25\x19\x49\x8e\x80\xf1\x47\x8f"
+ "\x37\xba\x55\xbd\x6d\x27\x61\x8c",
+ .ilen = 76,
+ .assoc = "\xfe\xed\xfa\xce\xde\xad\xbe\xef"
+ "\xfe\xed\xfa\xce\xde\xad\xbe\xef"
+ "\xab\xad\xda\xd2",
+ .alen = 20,
+ .result = "\xd9\x31\x32\x25\xf8\x84\x06\xe5"
+ "\xa5\x59\x09\xc5\xaf\xf5\x26\x9a"
+ "\x86\xa7\xa9\x53\x15\x34\xf7\xda"
+ "\x2e\x4c\x30\x3d\x8a\x31\x8a\x72"
+ "\x1c\x3c\x0c\x95\x95\x68\x09\x53"
+ "\x2f\xcf\x0e\x24\x49\xa6\xb5\x25"
+ "\xb1\x6a\xed\xf5\xaa\x0d\xe6\x57"
+ "\xba\x63\x7b\x39",
+ .rlen = 60,
+ }
+};
+
+static struct aead_testvec aes_ccm_enc_tv_template[] = {
+ { /* From RFC 3610 */
+ .key = "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
+ "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf",
+ .klen = 16,
+ .iv = "\x01\x00\x00\x00\x03\x02\x01\x00"
+ "\xa0\xa1\xa2\xa3\xa4\xa5\x00\x00",
+ .assoc = "\x00\x01\x02\x03\x04\x05\x06\x07",
+ .alen = 8,
+ .input = "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e",
+ .ilen = 23,
+ .result = "\x58\x8c\x97\x9a\x61\xc6\x63\xd2"
+ "\xf0\x66\xd0\xc2\xc0\xf9\x89\x80"
+ "\x6d\x5f\x6b\x61\xda\xc3\x84\x17"
+ "\xe8\xd1\x2c\xfd\xf9\x26\xe0",
+ .rlen = 31,
+ }, {
+ .key = "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
+ "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf",
+ .klen = 16,
+ .iv = "\x01\x00\x00\x00\x07\x06\x05\x04"
+ "\xa0\xa1\xa2\xa3\xa4\xa5\x00\x00",
+ .assoc = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b",
+ .alen = 12,
+ .input = "\x0c\x0d\x0e\x0f\x10\x11\x12\x13"
+ "\x14\x15\x16\x17\x18\x19\x1a\x1b"
+ "\x1c\x1d\x1e\x1f",
+ .ilen = 20,
+ .result = "\xdc\xf1\xfb\x7b\x5d\x9e\x23\xfb"
+ "\x9d\x4e\x13\x12\x53\x65\x8a\xd8"
+ "\x6e\xbd\xca\x3e\x51\xe8\x3f\x07"
+ "\x7d\x9c\x2d\x93",
+ .rlen = 28,
+ }, {
+ .key = "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
+ "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf",
+ .klen = 16,
+ .iv = "\x01\x00\x00\x00\x0b\x0a\x09\x08"
+ "\xa0\xa1\xa2\xa3\xa4\xa5\x00\x00",
+ .assoc = "\x00\x01\x02\x03\x04\x05\x06\x07",
+ .alen = 8,
+ .input = "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
+ "\x20",
+ .ilen = 25,
+ .result = "\x82\x53\x1a\x60\xcc\x24\x94\x5a"
+ "\x4b\x82\x79\x18\x1a\xb5\xc8\x4d"
+ "\xf2\x1c\xe7\xf9\xb7\x3f\x42\xe1"
+ "\x97\xea\x9c\x07\xe5\x6b\x5e\xb1"
+ "\x7e\x5f\x4e",
+ .rlen = 35,
+ }, {
+ .key = "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
+ "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf",
+ .klen = 16,
+ .iv = "\x01\x00\x00\x00\x0c\x0b\x0a\x09"
+ "\xa0\xa1\xa2\xa3\xa4\xa5\x00\x00",
+ .assoc = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b",
+ .alen = 12,
+ .input = "\x0c\x0d\x0e\x0f\x10\x11\x12\x13"
+ "\x14\x15\x16\x17\x18\x19\x1a\x1b"
+ "\x1c\x1d\x1e",
+ .ilen = 19,
+ .result = "\x07\x34\x25\x94\x15\x77\x85\x15"
+ "\x2b\x07\x40\x98\x33\x0a\xbb\x14"
+ "\x1b\x94\x7b\x56\x6a\xa9\x40\x6b"
+ "\x4d\x99\x99\x88\xdd",
+ .rlen = 29,
+ }, {
+ .key = "\xd7\x82\x8d\x13\xb2\xb0\xbd\xc3"
+ "\x25\xa7\x62\x36\xdf\x93\xcc\x6b",
+ .klen = 16,
+ .iv = "\x01\x00\x33\x56\x8e\xf7\xb2\x63"
+ "\x3c\x96\x96\x76\x6c\xfa\x00\x00",
+ .assoc = "\x63\x01\x8f\x76\xdc\x8a\x1b\xcb",
+ .alen = 8,
+ .input = "\x90\x20\xea\x6f\x91\xbd\xd8\x5a"
+ "\xfa\x00\x39\xba\x4b\xaf\xf9\xbf"
+ "\xb7\x9c\x70\x28\x94\x9c\xd0\xec",
+ .ilen = 24,
+ .result = "\x4c\xcb\x1e\x7c\xa9\x81\xbe\xfa"
+ "\xa0\x72\x6c\x55\xd3\x78\x06\x12"
+ "\x98\xc8\x5c\x92\x81\x4a\xbc\x33"
+ "\xc5\x2e\xe8\x1d\x7d\x77\xc0\x8a",
+ .rlen = 32,
+ }, {
+ .key = "\xd7\x82\x8d\x13\xb2\xb0\xbd\xc3"
+ "\x25\xa7\x62\x36\xdf\x93\xcc\x6b",
+ .klen = 16,
+ .iv = "\x01\x00\xd5\x60\x91\x2d\x3f\x70"
+ "\x3c\x96\x96\x76\x6c\xfa\x00\x00",
+ .assoc = "\xcd\x90\x44\xd2\xb7\x1f\xdb\x81"
+ "\x20\xea\x60\xc0",
+ .alen = 12,
+ .input = "\x64\x35\xac\xba\xfb\x11\xa8\x2e"
+ "\x2f\x07\x1d\x7c\xa4\xa5\xeb\xd9"
+ "\x3a\x80\x3b\xa8\x7f",
+ .ilen = 21,
+ .result = "\x00\x97\x69\xec\xab\xdf\x48\x62"
+ "\x55\x94\xc5\x92\x51\xe6\x03\x57"
+ "\x22\x67\x5e\x04\xc8\x47\x09\x9e"
+ "\x5a\xe0\x70\x45\x51",
+ .rlen = 29,
+ }, {
+ .key = "\xd7\x82\x8d\x13\xb2\xb0\xbd\xc3"
+ "\x25\xa7\x62\x36\xdf\x93\xcc\x6b",
+ .klen = 16,
+ .iv = "\x01\x00\x42\xff\xf8\xf1\x95\x1c"
+ "\x3c\x96\x96\x76\x6c\xfa\x00\x00",
+ .assoc = "\xd8\x5b\xc7\xe6\x9f\x94\x4f\xb8",
+ .alen = 8,
+ .input = "\x8a\x19\xb9\x50\xbc\xf7\x1a\x01"
+ "\x8e\x5e\x67\x01\xc9\x17\x87\x65"
+ "\x98\x09\xd6\x7d\xbe\xdd\x18",
+ .ilen = 23,
+ .result = "\xbc\x21\x8d\xaa\x94\x74\x27\xb6"
+ "\xdb\x38\x6a\x99\xac\x1a\xef\x23"
+ "\xad\xe0\xb5\x29\x39\xcb\x6a\x63"
+ "\x7c\xf9\xbe\xc2\x40\x88\x97\xc6"
+ "\xba",
+ .rlen = 33,
+ },
+};
+
+static struct aead_testvec aes_ccm_dec_tv_template[] = {
+ { /* From RFC 3610 */
+ .key = "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
+ "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf",
+ .klen = 16,
+ .iv = "\x01\x00\x00\x00\x03\x02\x01\x00"
+ "\xa0\xa1\xa2\xa3\xa4\xa5\x00\x00",
+ .assoc = "\x00\x01\x02\x03\x04\x05\x06\x07",
+ .alen = 8,
+ .input = "\x58\x8c\x97\x9a\x61\xc6\x63\xd2"
+ "\xf0\x66\xd0\xc2\xc0\xf9\x89\x80"
+ "\x6d\x5f\x6b\x61\xda\xc3\x84\x17"
+ "\xe8\xd1\x2c\xfd\xf9\x26\xe0",
+ .ilen = 31,
+ .result = "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e",
+ .rlen = 23,
+ }, {
+ .key = "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
+ "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf",
+ .klen = 16,
+ .iv = "\x01\x00\x00\x00\x07\x06\x05\x04"
+ "\xa0\xa1\xa2\xa3\xa4\xa5\x00\x00",
+ .assoc = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b",
+ .alen = 12,
+ .input = "\xdc\xf1\xfb\x7b\x5d\x9e\x23\xfb"
+ "\x9d\x4e\x13\x12\x53\x65\x8a\xd8"
+ "\x6e\xbd\xca\x3e\x51\xe8\x3f\x07"
+ "\x7d\x9c\x2d\x93",
+ .ilen = 28,
+ .result = "\x0c\x0d\x0e\x0f\x10\x11\x12\x13"
+ "\x14\x15\x16\x17\x18\x19\x1a\x1b"
+ "\x1c\x1d\x1e\x1f",
+ .rlen = 20,
+ }, {
+ .key = "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
+ "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf",
+ .klen = 16,
+ .iv = "\x01\x00\x00\x00\x0b\x0a\x09\x08"
+ "\xa0\xa1\xa2\xa3\xa4\xa5\x00\x00",
+ .assoc = "\x00\x01\x02\x03\x04\x05\x06\x07",
+ .alen = 8,
+ .input = "\x82\x53\x1a\x60\xcc\x24\x94\x5a"
+ "\x4b\x82\x79\x18\x1a\xb5\xc8\x4d"
+ "\xf2\x1c\xe7\xf9\xb7\x3f\x42\xe1"
+ "\x97\xea\x9c\x07\xe5\x6b\x5e\xb1"
+ "\x7e\x5f\x4e",
+ .ilen = 35,
+ .result = "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
+ "\x20",
+ .rlen = 25,
+ }, {
+ .key = "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
+ "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf",
+ .klen = 16,
+ .iv = "\x01\x00\x00\x00\x0c\x0b\x0a\x09"
+ "\xa0\xa1\xa2\xa3\xa4\xa5\x00\x00",
+ .assoc = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b",
+ .alen = 12,
+ .input = "\x07\x34\x25\x94\x15\x77\x85\x15"
+ "\x2b\x07\x40\x98\x33\x0a\xbb\x14"
+ "\x1b\x94\x7b\x56\x6a\xa9\x40\x6b"
+ "\x4d\x99\x99\x88\xdd",
+ .ilen = 29,
+ .result = "\x0c\x0d\x0e\x0f\x10\x11\x12\x13"
+ "\x14\x15\x16\x17\x18\x19\x1a\x1b"
+ "\x1c\x1d\x1e",
+ .rlen = 19,
+ }, {
+ .key = "\xd7\x82\x8d\x13\xb2\xb0\xbd\xc3"
+ "\x25\xa7\x62\x36\xdf\x93\xcc\x6b",
+ .klen = 16,
+ .iv = "\x01\x00\x33\x56\x8e\xf7\xb2\x63"
+ "\x3c\x96\x96\x76\x6c\xfa\x00\x00",
+ .assoc = "\x63\x01\x8f\x76\xdc\x8a\x1b\xcb",
+ .alen = 8,
+ .input = "\x4c\xcb\x1e\x7c\xa9\x81\xbe\xfa"
+ "\xa0\x72\x6c\x55\xd3\x78\x06\x12"
+ "\x98\xc8\x5c\x92\x81\x4a\xbc\x33"
+ "\xc5\x2e\xe8\x1d\x7d\x77\xc0\x8a",
+ .ilen = 32,
+ .result = "\x90\x20\xea\x6f\x91\xbd\xd8\x5a"
+ "\xfa\x00\x39\xba\x4b\xaf\xf9\xbf"
+ "\xb7\x9c\x70\x28\x94\x9c\xd0\xec",
+ .rlen = 24,
+ }, {
+ .key = "\xd7\x82\x8d\x13\xb2\xb0\xbd\xc3"
+ "\x25\xa7\x62\x36\xdf\x93\xcc\x6b",
+ .klen = 16,
+ .iv = "\x01\x00\xd5\x60\x91\x2d\x3f\x70"
+ "\x3c\x96\x96\x76\x6c\xfa\x00\x00",
+ .assoc = "\xcd\x90\x44\xd2\xb7\x1f\xdb\x81"
+ "\x20\xea\x60\xc0",
+ .alen = 12,
+ .input = "\x00\x97\x69\xec\xab\xdf\x48\x62"
+ "\x55\x94\xc5\x92\x51\xe6\x03\x57"
+ "\x22\x67\x5e\x04\xc8\x47\x09\x9e"
+ "\x5a\xe0\x70\x45\x51",
+ .ilen = 29,
+ .result = "\x64\x35\xac\xba\xfb\x11\xa8\x2e"
+ "\x2f\x07\x1d\x7c\xa4\xa5\xeb\xd9"
+ "\x3a\x80\x3b\xa8\x7f",
+ .rlen = 21,
+ }, {
+ .key = "\xd7\x82\x8d\x13\xb2\xb0\xbd\xc3"
+ "\x25\xa7\x62\x36\xdf\x93\xcc\x6b",
+ .klen = 16,
+ .iv = "\x01\x00\x42\xff\xf8\xf1\x95\x1c"
+ "\x3c\x96\x96\x76\x6c\xfa\x00\x00",
+ .assoc = "\xd8\x5b\xc7\xe6\x9f\x94\x4f\xb8",
+ .alen = 8,
+ .input = "\xbc\x21\x8d\xaa\x94\x74\x27\xb6"
+ "\xdb\x38\x6a\x99\xac\x1a\xef\x23"
+ "\xad\xe0\xb5\x29\x39\xcb\x6a\x63"
+ "\x7c\xf9\xbe\xc2\x40\x88\x97\xc6"
+ "\xba",
+ .ilen = 33,
+ .result = "\x8a\x19\xb9\x50\xbc\xf7\x1a\x01"
+ "\x8e\x5e\x67\x01\xc9\x17\x87\x65"
+ "\x98\x09\xd6\x7d\xbe\xdd\x18",
+ .rlen = 23,
+ },
+};
+
+/*
+ * rfc4309 refers to section 8 of rfc3610 for test vectors, but they all
+ * use a 13-byte nonce, we only support an 11-byte nonce. Similarly, all of
+ * Special Publication 800-38C's test vectors also use nonce lengths our
+ * implementation doesn't support. The following are taken from fips cavs
+ * fax files on hand at Red Hat.
+ *
+ * nb: actual key lengths are (klen - 3), the last 3 bytes are actually
+ * part of the nonce which combine w/the iv, but need to be input this way.
+ */
+static struct aead_testvec aes_ccm_rfc4309_enc_tv_template[] = {
+ {
+ .key = "\x83\xac\x54\x66\xc2\xeb\xe5\x05"
+ "\x2e\x01\xd1\xfc\x5d\x82\x66\x2e"
+ "\x96\xac\x59",
+ .klen = 19,
+ .iv = "\x30\x07\xa1\xe2\xa2\xc7\x55\x24",
+ .alen = 0,
+ .input = "\x19\xc8\x81\xf6\xe9\x86\xff\x93"
+ "\x0b\x78\x67\xe5\xbb\xb7\xfc\x6e"
+ "\x83\x77\xb3\xa6\x0c\x8c\x9f\x9c"
+ "\x35\x2e\xad\xe0\x62\xf9\x91\xa1",
+ .ilen = 32,
+ .result = "\xab\x6f\xe1\x69\x1d\x19\x99\xa8"
+ "\x92\xa0\xc4\x6f\x7e\xe2\x8b\xb1"
+ "\x70\xbb\x8c\xa6\x4c\x6e\x97\x8a"
+ "\x57\x2b\xbe\x5d\x98\xa6\xb1\x32"
+ "\xda\x24\xea\xd9\xa1\x39\x98\xfd"
+ "\xa4\xbe\xd9\xf2\x1a\x6d\x22\xa8",
+ .rlen = 48,
+ }, {
+ .key = "\x1e\x2c\x7e\x01\x41\x9a\xef\xc0"
+ "\x0d\x58\x96\x6e\x5c\xa2\x4b\xd3"
+ "\x4f\xa3\x19",
+ .klen = 19,
+ .iv = "\xd3\x01\x5a\xd8\x30\x60\x15\x56",
+ .assoc = "\xda\xe6\x28\x9c\x45\x2d\xfd\x63"
+ "\x5e\xda\x4c\xb6\xe6\xfc\xf9\xb7"
+ "\x0c\x56\xcb\xe4\xe0\x05\x7a\xe1"
+ "\x0a\x63\x09\x78\xbc\x2c\x55\xde",
+ .alen = 32,
+ .input = "\x87\xa3\x36\xfd\x96\xb3\x93\x78"
+ "\xa9\x28\x63\xba\x12\xa3\x14\x85"
+ "\x57\x1e\x06\xc9\x7b\x21\xef\x76"
+ "\x7f\x38\x7e\x8e\x29\xa4\x3e\x7e",
+ .ilen = 32,
+ .result = "\x8a\x1e\x11\xf0\x02\x6b\xe2\x19"
+ "\xfc\x70\xc4\x6d\x8e\xb7\x99\xab"
+ "\xc5\x4b\xa2\xac\xd3\xf3\x48\xff"
+ "\x3b\xb5\xce\x53\xef\xde\xbb\x02"
+ "\xa9\x86\x15\x6c\x13\xfe\xda\x0a"
+ "\x22\xb8\x29\x3d\xd8\x39\x9a\x23",
+ .rlen = 48,
+ }, {
+ .key = "\xf4\x6b\xc2\x75\x62\xfe\xb4\xe1"
+ "\xa3\xf0\xff\xdd\x4e\x4b\x12\x75"
+ "\x53\x14\x73\x66\x8d\x88\xf6\x80"
+ "\xa0\x20\x35",
+ .klen = 27,
+ .iv = "\x26\xf2\x21\x8d\x50\x20\xda\xe2",
+ .assoc = "\x5b\x9e\x13\x67\x02\x5e\xef\xc1"
+ "\x6c\xf9\xd7\x1e\x52\x8f\x7a\x47"
+ "\xe9\xd4\xcf\x20\x14\x6e\xf0\x2d"
+ "\xd8\x9e\x2b\x56\x10\x23\x56\xe7",
+ .alen = 32,
+ .ilen = 0,
+ .result = "\x36\xea\x7a\x70\x08\xdc\x6a\xbc"
+ "\xad\x0c\x7a\x63\xf6\x61\xfd\x9b",
+ .rlen = 16,
+ }, {
+ .key = "\x56\xdf\x5c\x8f\x26\x3f\x0e\x42"
+ "\xef\x7a\xd3\xce\xfc\x84\x60\x62"
+ "\xca\xb4\x40\xaf\x5f\xc9\xc9\x01"
+ "\xd6\x3c\x8c",
+ .klen = 27,
+ .iv = "\x86\x84\xb6\xcd\xef\x09\x2e\x94",
+ .assoc = "\x02\x65\x78\x3c\xe9\x21\x30\x91"
+ "\xb1\xb9\xda\x76\x9a\x78\x6d\x95"
+ "\xf2\x88\x32\xa3\xf2\x50\xcb\x4c"
+ "\xe3\x00\x73\x69\x84\x69\x87\x79",
+ .alen = 32,
+ .input = "\x9f\xd2\x02\x4b\x52\x49\x31\x3c"
+ "\x43\x69\x3a\x2d\x8e\x70\xad\x7e"
+ "\xe0\xe5\x46\x09\x80\x89\x13\xb2"
+ "\x8c\x8b\xd9\x3f\x86\xfb\xb5\x6b",
+ .ilen = 32,
+ .result = "\x39\xdf\x7c\x3c\x5a\x29\xb9\x62"
+ "\x5d\x51\xc2\x16\xd8\xbd\x06\x9f"
+ "\x9b\x6a\x09\x70\xc1\x51\x83\xc2"
+ "\x66\x88\x1d\x4f\x9a\xda\xe0\x1e"
+ "\xc7\x79\x11\x58\xe5\x6b\x20\x40"
+ "\x7a\xea\x46\x42\x8b\xe4\x6f\xe1",
+ .rlen = 48,
+ }, {
+ .key = "\xe0\x8d\x99\x71\x60\xd7\x97\x1a"
+ "\xbd\x01\x99\xd5\x8a\xdf\x71\x3a"
+ "\xd3\xdf\x24\x4b\x5e\x3d\x4b\x4e"
+ "\x30\x7a\xb9\xd8\x53\x0a\x5e\x2b"
+ "\x1e\x29\x91",
+ .klen = 35,
+ .iv = "\xad\x8e\xc1\x53\x0a\xcf\x2d\xbe",
+ .assoc = "\x19\xb6\x1f\x57\xc4\xf3\xf0\x8b"
+ "\x78\x2b\x94\x02\x29\x0f\x42\x27"
+ "\x6b\x75\xcb\x98\x34\x08\x7e\x79"
+ "\xe4\x3e\x49\x0d\x84\x8b\x22\x87",
+ .alen = 32,
+ .input = "\xe1\xd9\xd8\x13\xeb\x3a\x75\x3f"
+ "\x9d\xbd\x5f\x66\xbe\xdc\xbb\x66"
+ "\xbf\x17\x99\x62\x4a\x39\x27\x1f"
+ "\x1d\xdc\x24\xae\x19\x2f\x98\x4c",
+ .ilen = 32,
+ .result = "\x19\xb8\x61\x33\x45\x2b\x43\x96"
+ "\x6f\x51\xd0\x20\x30\x7d\x9b\xc6"
+ "\x26\x3d\xf8\xc9\x65\x16\xa8\x9f"
+ "\xf0\x62\x17\x34\xf2\x1e\x8d\x75"
+ "\x4e\x13\xcc\xc0\xc3\x2a\x54\x2d",
+ .rlen = 40,
+ }, {
+ .key = "\x7c\xc8\x18\x3b\x8d\x99\xe0\x7c"
+ "\x45\x41\xb8\xbd\x5c\xa7\xc2\x32"
+ "\x8a\xb8\x02\x59\xa4\xfe\xa9\x2c"
+ "\x09\x75\x9a\x9b\x3c\x9b\x27\x39"
+ "\xf9\xd9\x4e",
+ .klen = 35,
+ .iv = "\x63\xb5\x3d\x9d\x43\xf6\x1e\x50",
+ .assoc = "\x57\xf5\x6b\x8b\x57\x5c\x3d\x3b"
+ "\x13\x02\x01\x0c\x83\x4c\x96\x35"
+ "\x8e\xd6\x39\xcf\x7d\x14\x9b\x94"
+ "\xb0\x39\x36\xe6\x8f\x57\xe0\x13",
+ .alen = 32,
+ .input = "\x3b\x6c\x29\x36\xb6\xef\x07\xa6"
+ "\x83\x72\x07\x4f\xcf\xfa\x66\x89"
+ "\x5f\xca\xb1\xba\xd5\x8f\x2c\x27"
+ "\x30\xdb\x75\x09\x93\xd4\x65\xe4",
+ .ilen = 32,
+ .result = "\xb0\x88\x5a\x33\xaa\xe5\xc7\x1d"
+ "\x85\x23\xc7\xc6\x2f\xf4\x1e\x3d"
+ "\xcc\x63\x44\x25\x07\x78\x4f\x9e"
+ "\x96\xb8\x88\xeb\xbc\x48\x1f\x06"
+ "\x39\xaf\x39\xac\xd8\x4a\x80\x39"
+ "\x7b\x72\x8a\xf7",
+ .rlen = 44,
+ }, {
+ .key = "\xab\xd0\xe9\x33\x07\x26\xe5\x83"
+ "\x8c\x76\x95\xd4\xb6\xdc\xf3\x46"
+ "\xf9\x8f\xad\xe3\x02\x13\x83\x77"
+ "\x3f\xb0\xf1\xa1\xa1\x22\x0f\x2b"
+ "\x24\xa7\x8b",
+ .klen = 35,
+ .iv = "\x07\xcb\xcc\x0e\xe6\x33\xbf\xf5",
+ .assoc = "\xd4\xdb\x30\x1d\x03\xfe\xfd\x5f"
+ "\x87\xd4\x8c\xb6\xb6\xf1\x7a\x5d"
+ "\xab\x90\x65\x8d\x8e\xca\x4d\x4f"
+ "\x16\x0c\x40\x90\x4b\xc7\x36\x73",
+ .alen = 32,
+ .input = "\xf5\xc6\x7d\x48\xc1\xb7\xe6\x92"
+ "\x97\x5a\xca\xc4\xa9\x6d\xf9\x3d"
+ "\x6c\xde\xbc\xf1\x90\xea\x6a\xb2"
+ "\x35\x86\x36\xaf\x5c\xfe\x4b\x3a",
+ .ilen = 32,
+ .result = "\x83\x6f\x40\x87\x72\xcf\xc1\x13"
+ "\xef\xbb\x80\x21\x04\x6c\x58\x09"
+ "\x07\x1b\xfc\xdf\xc0\x3f\x5b\xc7"
+ "\xe0\x79\xa8\x6e\x71\x7c\x3f\xcf"
+ "\x5c\xda\xb2\x33\xe5\x13\xe2\x0d"
+ "\x74\xd1\xef\xb5\x0f\x3a\xb5\xf8",
+ .rlen = 48,
+ },
+};
+
+static struct aead_testvec aes_ccm_rfc4309_dec_tv_template[] = {
+ {
+ .key = "\xab\x2f\x8a\x74\xb7\x1c\xd2\xb1"
+ "\xff\x80\x2e\x48\x7d\x82\xf8\xb9"
+ "\xc6\xfb\x7d",
+ .klen = 19,
+ .iv = "\x80\x0d\x13\xab\xd8\xa6\xb2\xd8",
+ .alen = 0,
+ .input = "\xd5\xe8\x93\x9f\xc7\x89\x2e\x2b",
+ .ilen = 8,
+ .result = "\x00",
+ .rlen = 0,
+ .novrfy = 1,
+ }, {
+ .key = "\xab\x2f\x8a\x74\xb7\x1c\xd2\xb1"
+ "\xff\x80\x2e\x48\x7d\x82\xf8\xb9"
+ "\xaf\x94\x87",
+ .klen = 19,
+ .iv = "\x78\x35\x82\x81\x7f\x88\x94\x68",
+ .alen = 0,
+ .input = "\x41\x3c\xb8\x87\x73\xcb\xf3\xf3",
+ .ilen = 8,
+ .result = "\x00",
+ .rlen = 0,
+ }, {
+ .key = "\x61\x0e\x8c\xae\xe3\x23\xb6\x38"
+ "\x76\x1c\xf6\x3a\x67\xa3\x9c\xd8"
+ "\xc6\xfb\x7d",
+ .klen = 19,
+ .iv = "\x80\x0d\x13\xab\xd8\xa6\xb2\xd8",
+ .assoc = "\xf3\x94\x87\x78\x35\x82\x81\x7f"
+ "\x88\x94\x68\xb1\x78\x6b\x2b\xd6"
+ "\x04\x1f\x4e\xed\x78\xd5\x33\x66"
+ "\xd8\x94\x99\x91\x81\x54\x62\x57",
+ .alen = 32,
+ .input = "\xf0\x7c\x29\x02\xae\x1c\x2f\x55"
+ "\xd0\xd1\x3d\x1a\xa3\x6d\xe4\x0a"
+ "\x86\xb0\x87\x6b\x62\x33\x8c\x34"
+ "\xce\xab\x57\xcc\x79\x0b\xe0\x6f"
+ "\x5c\x3e\x48\x1f\x6c\x46\xf7\x51"
+ "\x8b\x84\x83\x2a\xc1\x05\xb8\xc5",
+ .ilen = 48,
+ .result = "\x50\x82\x3e\x07\xe2\x1e\xb6\xfb"
+ "\x33\xe4\x73\xce\xd2\xfb\x95\x79"
+ "\xe8\xb4\xb5\x77\x11\x10\x62\x6f"
+ "\x6a\x82\xd1\x13\xec\xf5\xd0\x48",
+ .rlen = 32,
+ .novrfy = 1,
+ }, {
+ .key = "\x61\x0e\x8c\xae\xe3\x23\xb6\x38"
+ "\x76\x1c\xf6\x3a\x67\xa3\x9c\xd8"
+ "\x05\xe0\xc9",
+ .klen = 19,
+ .iv = "\x0f\xed\x34\xea\x97\xd4\x3b\xdf",
+ .assoc = "\x49\x5c\x50\x1f\x1d\x94\xcc\x81"
+ "\xba\xb7\xb6\x03\xaf\xa5\xc1\xa1"
+ "\xd8\x5c\x42\x68\xe0\x6c\xda\x89"
+ "\x05\xac\x56\xac\x1b\x2a\xd3\x86",
+ .alen = 32,
+ .input = "\x39\xbe\x7d\x15\x62\x77\xf3\x3c"
+ "\xad\x83\x52\x6d\x71\x03\x25\x1c"
+ "\xed\x81\x3a\x9a\x16\x7d\x19\x80"
+ "\x72\x04\x72\xd0\xf6\xff\x05\x0f"
+ "\xb7\x14\x30\x00\x32\x9e\xa0\xa6"
+ "\x9e\x5a\x18\xa1\xb8\xfe\xdb\xd3",
+ .ilen = 48,
+ .result = "\x75\x05\xbe\xc2\xd9\x1e\xde\x60"
+ "\x47\x3d\x8c\x7d\xbd\xb5\xd9\xb7"
+ "\xf2\xae\x61\x05\x8f\x82\x24\x3f"
+ "\x9c\x67\x91\xe1\x38\x4f\xe4\x0c",
+ .rlen = 32,
+ }, {
+ .key = "\x39\xbb\xa7\xbe\x59\x97\x9e\x73"
+ "\xa2\xbc\x6b\x98\xd7\x75\x7f\xe3"
+ "\xa4\x48\x93\x39\x26\x71\x4a\xc6"
+ "\xee\x49\x83",
+ .klen = 27,
+ .iv = "\xe9\xa9\xff\xe9\x57\xba\xfd\x9e",
+ .assoc = "\x44\xa6\x2c\x05\xe9\xe1\x43\xb1"
+ "\x58\x7c\xf2\x5c\x6d\x39\x0a\x64"
+ "\xa4\xf0\x13\x05\xd1\x77\x99\x67"
+ "\x11\xc4\xc6\xdb\x00\x56\x36\x61",
+ .alen = 32,
+ .input = "\x71\x99\xfa\xf4\x44\x12\x68\x9b",
+ .ilen = 8,
+ .result = "\x00",
+ .rlen = 0,
+ }, {
+ .key = "\x58\x5d\xa0\x96\x65\x1a\x04\xd7"
+ "\x96\xe5\xc5\x68\xaa\x95\x35\xe0"
+ "\x29\xa0\xba\x9e\x48\x78\xd1\xba"
+ "\xee\x49\x83",
+ .klen = 27,
+ .iv = "\xe9\xa9\xff\xe9\x57\xba\xfd\x9e",
+ .assoc = "\x44\xa6\x2c\x05\xe9\xe1\x43\xb1"
+ "\x58\x7c\xf2\x5c\x6d\x39\x0a\x64"
+ "\xa4\xf0\x13\x05\xd1\x77\x99\x67"
+ "\x11\xc4\xc6\xdb\x00\x56\x36\x61",
+ .alen = 32,
+ .input = "\xfb\xe5\x5d\x34\xbe\xe5\xe8\xe7"
+ "\x5a\xef\x2f\xbf\x1f\x7f\xd4\xb2"
+ "\x66\xca\x61\x1e\x96\x7a\x61\xb3"
+ "\x1c\x16\x45\x52\xba\x04\x9c\x9f"
+ "\xb1\xd2\x40\xbc\x52\x7c\x6f\xb1",
+ .ilen = 40,
+ .result = "\x85\x34\x66\x42\xc8\x92\x0f\x36"
+ "\x58\xe0\x6b\x91\x3c\x98\x5c\xbb"
+ "\x0a\x85\xcc\x02\xad\x7a\x96\xe9"
+ "\x65\x43\xa4\xc3\x0f\xdc\x55\x81",
+ .rlen = 32,
+ }, {
+ .key = "\x58\x5d\xa0\x96\x65\x1a\x04\xd7"
+ "\x96\xe5\xc5\x68\xaa\x95\x35\xe0"
+ "\x29\xa0\xba\x9e\x48\x78\xd1\xba"
+ "\xd1\xfc\x57",
+ .klen = 27,
+ .iv = "\x9c\xfe\xb8\x9c\xad\x71\xaa\x1f",
+ .assoc = "\x86\x67\xa5\xa9\x14\x5f\x0d\xc6"
+ "\xff\x14\xc7\x44\xbf\x6c\x3a\xc3"
+ "\xff\xb6\x81\xbd\xe2\xd5\x06\xc7"
+ "\x3c\xa1\x52\x13\x03\x8a\x23\x3a",
+ .alen = 32,
+ .input = "\x3f\x66\xb0\x9d\xe5\x4b\x38\x00"
+ "\xc6\x0e\x6e\xe5\xd6\x98\xa6\x37"
+ "\x8c\x26\x33\xc6\xb2\xa2\x17\xfa"
+ "\x64\x19\xc0\x30\xd7\xfc\x14\x6b"
+ "\xe3\x33\xc2\x04\xb0\x37\xbe\x3f"
+ "\xa9\xb4\x2d\x68\x03\xa3\x44\xef",
+ .ilen = 48,
+ .result = "\x02\x87\x4d\x28\x80\x6e\xb2\xed"
+ "\x99\x2a\xa8\xca\x04\x25\x45\x90"
+ "\x1d\xdd\x5a\xd9\xe4\xdb\x9c\x9c"
+ "\x49\xe9\x01\xfe\xa7\x80\x6d\x6b",
+ .rlen = 32,
+ .novrfy = 1,
+ }, {
+ .key = "\xa4\x4b\x54\x29\x0a\xb8\x6d\x01"
+ "\x5b\x80\x2a\xcf\x25\xc4\xb7\x5c"
+ "\x20\x2c\xad\x30\xc2\x2b\x41\xfb"
+ "\x0e\x85\xbc\x33\xad\x0f\x2b\xff"
+ "\xee\x49\x83",
+ .klen = 35,
+ .iv = "\xe9\xa9\xff\xe9\x57\xba\xfd\x9e",
+ .alen = 0,
+ .input = "\x1f\xb8\x8f\xa3\xdd\x54\x00\xf2",
+ .ilen = 8,
+ .result = "\x00",
+ .rlen = 0,
+ }, {
+ .key = "\x39\xbb\xa7\xbe\x59\x97\x9e\x73"
+ "\xa2\xbc\x6b\x98\xd7\x75\x7f\xe3"
+ "\xa4\x48\x93\x39\x26\x71\x4a\xc6"
+ "\xae\x8f\x11\x4c\xc2\x9c\x4a\xbb"
+ "\x85\x34\x66",
+ .klen = 35,
+ .iv = "\x42\xc8\x92\x0f\x36\x58\xe0\x6b",
+ .alen = 0,
+ .input = "\x48\x01\x5e\x02\x24\x04\x66\x47"
+ "\xa1\xea\x6f\xaf\xe8\xfc\xfb\xdd"
+ "\xa5\xa9\x87\x8d\x84\xee\x2e\x77"
+ "\xbb\x86\xb9\xf5\x5c\x6c\xff\xf6"
+ "\x72\xc3\x8e\xf7\x70\xb1\xb2\x07"
+ "\xbc\xa8\xa3\xbd\x83\x7c\x1d\x2a",
+ .ilen = 48,
+ .result = "\xdc\x56\xf2\x71\xb0\xb1\xa0\x6c"
+ "\xf0\x97\x3a\xfb\x6d\xe7\x32\x99"
+ "\x3e\xaf\x70\x5e\xb2\x4d\xea\x39"
+ "\x89\xd4\x75\x7a\x63\xb1\xda\x93",
+ .rlen = 32,
+ .novrfy = 1,
+ }, {
+ .key = "\x58\x5d\xa0\x96\x65\x1a\x04\xd7"
+ "\x96\xe5\xc5\x68\xaa\x95\x35\xe0"
+ "\x29\xa0\xba\x9e\x48\x78\xd1\xba"
+ "\x0d\x1a\x53\x3b\xb5\xe3\xf8\x8b"
+ "\xcf\x76\x3f",
+ .klen = 35,
+ .iv = "\xd9\x95\x75\x8f\x44\x89\x40\x7b",
+ .assoc = "\x8f\x86\x6c\x4d\x1d\xc5\x39\x88"
+ "\xc8\xf3\x5c\x52\x10\x63\x6f\x2b"
+ "\x8a\x2a\xc5\x6f\x30\x23\x58\x7b"
+ "\xfb\x36\x03\x11\xb4\xd9\xf2\xfe",
+ .alen = 32,
+ .input = "\x48\x58\xd6\xf3\xad\x63\x58\xbf"
+ "\xae\xc7\x5e\xae\x83\x8f\x7b\xe4"
+ "\x78\x5c\x4c\x67\x71\x89\x94\xbf"
+ "\x47\xf1\x63\x7e\x1c\x59\xbd\xc5"
+ "\x7f\x44\x0a\x0c\x01\x18\x07\x92"
+ "\xe1\xd3\x51\xce\x32\x6d\x0c\x5b",
+ .ilen = 48,
+ .result = "\xc2\x54\xc8\xde\x78\x87\x77\x40"
+ "\x49\x71\xe4\xb7\xe7\xcb\x76\x61"
+ "\x0a\x41\xb9\xe9\xc0\x76\x54\xab"
+ "\x04\x49\x3b\x19\x93\x57\x25\x5d",
+ .rlen = 32,
+ },
+};
+
+/*
+ * ANSI X9.31 Continuous Pseudo-Random Number Generator (
+ * test vectors, taken from Appendix B.2.9 and B.2.10:
+ * http://csrc.nist.gov/groups/STM/cavp/documents/rng/RNGVS.pdf
+ * Only AES-128 is supported at this time.
+ */
+#define ANSI_CPRNG_AES_TEST_VECTORS 6
+
+static struct cprng_testvec ansi_cprng_aes_tv_template[] = {
+ {
+ .key = "\xf3\xb1\x66\x6d\x13\x60\x72\x42"
+ "\xed\x06\x1c\xab\xb8\xd4\x62\x02",
+ .klen = 16,
+ .dt = "\xe6\xb3\xbe\x78\x2a\x23\xfa\x62"
+ "\xd7\x1d\x4a\xfb\xb0\xe9\x22\xf9",
+ .dtlen = 16,
+ .v = "\x80\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .vlen = 16,
+ .result = "\x59\x53\x1e\xd1\x3b\xb0\xc0\x55"
+ "\x84\x79\x66\x85\xc1\x2f\x76\x41",
+ .rlen = 16,
+ .loops = 1,
+ }, {
+ .key = "\xf3\xb1\x66\x6d\x13\x60\x72\x42"
+ "\xed\x06\x1c\xab\xb8\xd4\x62\x02",
+ .klen = 16,
+ .dt = "\xe6\xb3\xbe\x78\x2a\x23\xfa\x62"
+ "\xd7\x1d\x4a\xfb\xb0\xe9\x22\xfa",
+ .dtlen = 16,
+ .v = "\xc0\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .vlen = 16,
+ .result = "\x7c\x22\x2c\xf4\xca\x8f\xa2\x4c"
+ "\x1c\x9c\xb6\x41\xa9\xf3\x22\x0d",
+ .rlen = 16,
+ .loops = 1,
+ }, {
+ .key = "\xf3\xb1\x66\x6d\x13\x60\x72\x42"
+ "\xed\x06\x1c\xab\xb8\xd4\x62\x02",
+ .klen = 16,
+ .dt = "\xe6\xb3\xbe\x78\x2a\x23\xfa\x62"
+ "\xd7\x1d\x4a\xfb\xb0\xe9\x22\xfb",
+ .dtlen = 16,
+ .v = "\xe0\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .vlen = 16,
+ .result = "\x8a\xaa\x00\x39\x66\x67\x5b\xe5"
+ "\x29\x14\x28\x81\xa9\x4d\x4e\xc7",
+ .rlen = 16,
+ .loops = 1,
+ }, {
+ .key = "\xf3\xb1\x66\x6d\x13\x60\x72\x42"
+ "\xed\x06\x1c\xab\xb8\xd4\x62\x02",
+ .klen = 16,
+ .dt = "\xe6\xb3\xbe\x78\x2a\x23\xfa\x62"
+ "\xd7\x1d\x4a\xfb\xb0\xe9\x22\xfc",
+ .dtlen = 16,
+ .v = "\xf0\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .vlen = 16,
+ .result = "\x88\xdd\xa4\x56\x30\x24\x23\xe5"
+ "\xf6\x9d\xa5\x7e\x7b\x95\xc7\x3a",
+ .rlen = 16,
+ .loops = 1,
+ }, {
+ .key = "\xf3\xb1\x66\x6d\x13\x60\x72\x42"
+ "\xed\x06\x1c\xab\xb8\xd4\x62\x02",
+ .klen = 16,
+ .dt = "\xe6\xb3\xbe\x78\x2a\x23\xfa\x62"
+ "\xd7\x1d\x4a\xfb\xb0\xe9\x22\xfd",
+ .dtlen = 16,
+ .v = "\xf8\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .vlen = 16,
+ .result = "\x05\x25\x92\x46\x61\x79\xd2\xcb"
+ "\x78\xc4\x0b\x14\x0a\x5a\x9a\xc8",
+ .rlen = 16,
+ .loops = 1,
+ }, { /* Monte Carlo Test */
+ .key = "\x9f\x5b\x51\x20\x0b\xf3\x34\xb5"
+ "\xd8\x2b\xe8\xc3\x72\x55\xc8\x48",
+ .klen = 16,
+ .dt = "\x63\x76\xbb\xe5\x29\x02\xba\x3b"
+ "\x67\xc9\x25\xfa\x70\x1f\x11\xac",
+ .dtlen = 16,
+ .v = "\x57\x2c\x8e\x76\x87\x26\x47\x97"
+ "\x7e\x74\xfb\xdd\xc4\x95\x01\xd1",
+ .vlen = 16,
+ .result = "\x48\xe9\xbd\x0d\x06\xee\x18\xfb"
+ "\xe4\x57\x90\xd5\xc3\xfc\x9b\x73",
+ .rlen = 16,
+ .loops = 10000,
+ },
+};
+
+/* Cast5 test vectors from RFC 2144 */
+#define CAST5_ENC_TEST_VECTORS 3
+#define CAST5_DEC_TEST_VECTORS 3
+
+static struct cipher_testvec cast5_enc_tv_template[] = {
+ {
+ .key = "\x01\x23\x45\x67\x12\x34\x56\x78"
+ "\x23\x45\x67\x89\x34\x56\x78\x9a",
+ .klen = 16,
+ .input = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .ilen = 8,
+ .result = "\x23\x8b\x4f\xe5\x84\x7e\x44\xb2",
+ .rlen = 8,
+ }, {
+ .key = "\x01\x23\x45\x67\x12\x34\x56\x78"
+ "\x23\x45",
+ .klen = 10,
+ .input = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .ilen = 8,
+ .result = "\xeb\x6a\x71\x1a\x2c\x02\x27\x1b",
+ .rlen = 8,
+ }, {
+ .key = "\x01\x23\x45\x67\x12",
+ .klen = 5,
+ .input = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .ilen = 8,
+ .result = "\x7a\xc8\x16\xd1\x6e\x9b\x30\x2e",
+ .rlen = 8,
+ },
+};
+
+static struct cipher_testvec cast5_dec_tv_template[] = {
+ {
+ .key = "\x01\x23\x45\x67\x12\x34\x56\x78"
+ "\x23\x45\x67\x89\x34\x56\x78\x9a",
+ .klen = 16,
+ .input = "\x23\x8b\x4f\xe5\x84\x7e\x44\xb2",
+ .ilen = 8,
+ .result = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .rlen = 8,
+ }, {
+ .key = "\x01\x23\x45\x67\x12\x34\x56\x78"
+ "\x23\x45",
+ .klen = 10,
+ .input = "\xeb\x6a\x71\x1a\x2c\x02\x27\x1b",
+ .ilen = 8,
+ .result = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .rlen = 8,
+ }, {
+ .key = "\x01\x23\x45\x67\x12",
+ .klen = 5,
+ .input = "\x7a\xc8\x16\xd1\x6e\x9b\x30\x2e",
+ .ilen = 8,
+ .result = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .rlen = 8,
+ },
+};
+
+/*
+ * ARC4 test vectors from OpenSSL
+ */
+#define ARC4_ENC_TEST_VECTORS 7
+#define ARC4_DEC_TEST_VECTORS 7
+
+static struct cipher_testvec arc4_enc_tv_template[] = {
+ {
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .klen = 8,
+ .input = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .ilen = 8,
+ .result = "\x75\xb7\x87\x80\x99\xe0\xc5\x96",
+ .rlen = 8,
+ }, {
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .klen = 8,
+ .input = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .ilen = 8,
+ .result = "\x74\x94\xc2\xe7\x10\x4b\x08\x79",
+ .rlen = 8,
+ }, {
+ .key = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .klen = 8,
+ .input = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .ilen = 8,
+ .result = "\xde\x18\x89\x41\xa3\x37\x5d\x3a",
+ .rlen = 8,
+ }, {
+ .key = "\xef\x01\x23\x45",
+ .klen = 4,
+ .input = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00",
+ .ilen = 20,
+ .result = "\xd6\xa1\x41\xa7\xec\x3c\x38\xdf"
+ "\xbd\x61\x5a\x11\x62\xe1\xc7\xba"
+ "\x36\xb6\x78\x58",
+ .rlen = 20,
+ }, {
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .klen = 8,
+ .input = "\x12\x34\x56\x78\x9A\xBC\xDE\xF0"
+ "\x12\x34\x56\x78\x9A\xBC\xDE\xF0"
+ "\x12\x34\x56\x78\x9A\xBC\xDE\xF0"
+ "\x12\x34\x56\x78",
+ .ilen = 28,
+ .result = "\x66\xa0\x94\x9f\x8a\xf7\xd6\x89"
+ "\x1f\x7f\x83\x2b\xa8\x33\xc0\x0c"
+ "\x89\x2e\xbe\x30\x14\x3c\xe2\x87"
+ "\x40\x01\x1e\xcf",
+ .rlen = 28,
+ }, {
+ .key = "\xef\x01\x23\x45",
+ .klen = 4,
+ .input = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00",
+ .ilen = 10,
+ .result = "\xd6\xa1\x41\xa7\xec\x3c\x38\xdf"
+ "\xbd\x61",
+ .rlen = 10,
+ }, {
+ .key = "\x01\x23\x45\x67\x89\xAB\xCD\xEF"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .klen = 16,
+ .input = "\x01\x23\x45\x67\x89\xAB\xCD\xEF",
+ .ilen = 8,
+ .result = "\x69\x72\x36\x59\x1B\x52\x42\xB1",
+ .rlen = 8,
+ },
+};
+
+static struct cipher_testvec arc4_dec_tv_template[] = {
+ {
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .klen = 8,
+ .input = "\x75\xb7\x87\x80\x99\xe0\xc5\x96",
+ .ilen = 8,
+ .result = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .rlen = 8,
+ }, {
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .klen = 8,
+ .input = "\x74\x94\xc2\xe7\x10\x4b\x08\x79",
+ .ilen = 8,
+ .result = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .rlen = 8,
+ }, {
+ .key = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .klen = 8,
+ .input = "\xde\x18\x89\x41\xa3\x37\x5d\x3a",
+ .ilen = 8,
+ .result = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .rlen = 8,
+ }, {
+ .key = "\xef\x01\x23\x45",
+ .klen = 4,
+ .input = "\xd6\xa1\x41\xa7\xec\x3c\x38\xdf"
+ "\xbd\x61\x5a\x11\x62\xe1\xc7\xba"
+ "\x36\xb6\x78\x58",
+ .ilen = 20,
+ .result = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00",
+ .rlen = 20,
+ }, {
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef",
+ .klen = 8,
+ .input = "\x66\xa0\x94\x9f\x8a\xf7\xd6\x89"
+ "\x1f\x7f\x83\x2b\xa8\x33\xc0\x0c"
+ "\x89\x2e\xbe\x30\x14\x3c\xe2\x87"
+ "\x40\x01\x1e\xcf",
+ .ilen = 28,
+ .result = "\x12\x34\x56\x78\x9A\xBC\xDE\xF0"
+ "\x12\x34\x56\x78\x9A\xBC\xDE\xF0"
+ "\x12\x34\x56\x78\x9A\xBC\xDE\xF0"
+ "\x12\x34\x56\x78",
+ .rlen = 28,
+ }, {
+ .key = "\xef\x01\x23\x45",
+ .klen = 4,
+ .input = "\xd6\xa1\x41\xa7\xec\x3c\x38\xdf"
+ "\xbd\x61",
+ .ilen = 10,
+ .result = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00",
+ .rlen = 10,
+ }, {
+ .key = "\x01\x23\x45\x67\x89\xAB\xCD\xEF"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .klen = 16,
+ .input = "\x69\x72\x36\x59\x1B\x52\x42\xB1",
+ .ilen = 8,
+ .result = "\x01\x23\x45\x67\x89\xAB\xCD\xEF",
+ .rlen = 8,
+ },
+};
+
+/*
+ * TEA test vectors
+ */
+#define TEA_ENC_TEST_VECTORS 4
+#define TEA_DEC_TEST_VECTORS 4
+
+static struct cipher_testvec tea_enc_tv_template[] = {
+ {
+ .key = zeroed_string,
+ .klen = 16,
+ .input = zeroed_string,
+ .ilen = 8,
+ .result = "\x0a\x3a\xea\x41\x40\xa9\xba\x94",
+ .rlen = 8,
+ }, {
+ .key = "\x2b\x02\x05\x68\x06\x14\x49\x76"
+ "\x77\x5d\x0e\x26\x6c\x28\x78\x43",
+ .klen = 16,
+ .input = "\x74\x65\x73\x74\x20\x6d\x65\x2e",
+ .ilen = 8,
+ .result = "\x77\x5d\x2a\x6a\xf6\xce\x92\x09",
+ .rlen = 8,
+ }, {
+ .key = "\x09\x65\x43\x11\x66\x44\x39\x25"
+ "\x51\x3a\x16\x10\x0a\x08\x12\x6e",
+ .klen = 16,
+ .input = "\x6c\x6f\x6e\x67\x65\x72\x5f\x74"
+ "\x65\x73\x74\x5f\x76\x65\x63\x74",
+ .ilen = 16,
+ .result = "\xbe\x7a\xbb\x81\x95\x2d\x1f\x1e"
+ "\xdd\x89\xa1\x25\x04\x21\xdf\x95",
+ .rlen = 16,
+ }, {
+ .key = "\x4d\x76\x32\x17\x05\x3f\x75\x2c"
+ "\x5d\x04\x16\x36\x15\x72\x63\x2f",
+ .klen = 16,
+ .input = "\x54\x65\x61\x20\x69\x73\x20\x67"
+ "\x6f\x6f\x64\x20\x66\x6f\x72\x20"
+ "\x79\x6f\x75\x21\x21\x21\x20\x72"
+ "\x65\x61\x6c\x6c\x79\x21\x21\x21",
+ .ilen = 32,
+ .result = "\xe0\x4d\x5d\x3c\xb7\x8c\x36\x47"
+ "\x94\x18\x95\x91\xa9\xfc\x49\xf8"
+ "\x44\xd1\x2d\xc2\x99\xb8\x08\x2a"
+ "\x07\x89\x73\xc2\x45\x92\xc6\x90",
+ .rlen = 32,
+ }
+};
+
+static struct cipher_testvec tea_dec_tv_template[] = {
+ {
+ .key = zeroed_string,
+ .klen = 16,
+ .input = "\x0a\x3a\xea\x41\x40\xa9\xba\x94",
+ .ilen = 8,
+ .result = zeroed_string,
+ .rlen = 8,
+ }, {
+ .key = "\x2b\x02\x05\x68\x06\x14\x49\x76"
+ "\x77\x5d\x0e\x26\x6c\x28\x78\x43",
+ .klen = 16,
+ .input = "\x77\x5d\x2a\x6a\xf6\xce\x92\x09",
+ .ilen = 8,
+ .result = "\x74\x65\x73\x74\x20\x6d\x65\x2e",
+ .rlen = 8,
+ }, {
+ .key = "\x09\x65\x43\x11\x66\x44\x39\x25"
+ "\x51\x3a\x16\x10\x0a\x08\x12\x6e",
+ .klen = 16,
+ .input = "\xbe\x7a\xbb\x81\x95\x2d\x1f\x1e"
+ "\xdd\x89\xa1\x25\x04\x21\xdf\x95",
+ .ilen = 16,
+ .result = "\x6c\x6f\x6e\x67\x65\x72\x5f\x74"
+ "\x65\x73\x74\x5f\x76\x65\x63\x74",
+ .rlen = 16,
+ }, {
+ .key = "\x4d\x76\x32\x17\x05\x3f\x75\x2c"
+ "\x5d\x04\x16\x36\x15\x72\x63\x2f",
+ .klen = 16,
+ .input = "\xe0\x4d\x5d\x3c\xb7\x8c\x36\x47"
+ "\x94\x18\x95\x91\xa9\xfc\x49\xf8"
+ "\x44\xd1\x2d\xc2\x99\xb8\x08\x2a"
+ "\x07\x89\x73\xc2\x45\x92\xc6\x90",
+ .ilen = 32,
+ .result = "\x54\x65\x61\x20\x69\x73\x20\x67"
+ "\x6f\x6f\x64\x20\x66\x6f\x72\x20"
+ "\x79\x6f\x75\x21\x21\x21\x20\x72"
+ "\x65\x61\x6c\x6c\x79\x21\x21\x21",
+ .rlen = 32,
+ }
+};
+
+/*
+ * XTEA test vectors
+ */
+#define XTEA_ENC_TEST_VECTORS 4
+#define XTEA_DEC_TEST_VECTORS 4
+
+static struct cipher_testvec xtea_enc_tv_template[] = {
+ {
+ .key = zeroed_string,
+ .klen = 16,
+ .input = zeroed_string,
+ .ilen = 8,
+ .result = "\xd8\xd4\xe9\xde\xd9\x1e\x13\xf7",
+ .rlen = 8,
+ }, {
+ .key = "\x2b\x02\x05\x68\x06\x14\x49\x76"
+ "\x77\x5d\x0e\x26\x6c\x28\x78\x43",
+ .klen = 16,
+ .input = "\x74\x65\x73\x74\x20\x6d\x65\x2e",
+ .ilen = 8,
+ .result = "\x94\xeb\xc8\x96\x84\x6a\x49\xa8",
+ .rlen = 8,
+ }, {
+ .key = "\x09\x65\x43\x11\x66\x44\x39\x25"
+ "\x51\x3a\x16\x10\x0a\x08\x12\x6e",
+ .klen = 16,
+ .input = "\x6c\x6f\x6e\x67\x65\x72\x5f\x74"
+ "\x65\x73\x74\x5f\x76\x65\x63\x74",
+ .ilen = 16,
+ .result = "\x3e\xce\xae\x22\x60\x56\xa8\x9d"
+ "\x77\x4d\xd4\xb4\x87\x24\xe3\x9a",
+ .rlen = 16,
+ }, {
+ .key = "\x4d\x76\x32\x17\x05\x3f\x75\x2c"
+ "\x5d\x04\x16\x36\x15\x72\x63\x2f",
+ .klen = 16,
+ .input = "\x54\x65\x61\x20\x69\x73\x20\x67"
+ "\x6f\x6f\x64\x20\x66\x6f\x72\x20"
+ "\x79\x6f\x75\x21\x21\x21\x20\x72"
+ "\x65\x61\x6c\x6c\x79\x21\x21\x21",
+ .ilen = 32,
+ .result = "\x99\x81\x9f\x5d\x6f\x4b\x31\x3a"
+ "\x86\xff\x6f\xd0\xe3\x87\x70\x07"
+ "\x4d\xb8\xcf\xf3\x99\x50\xb3\xd4"
+ "\x73\xa2\xfa\xc9\x16\x59\x5d\x81",
+ .rlen = 32,
+ }
+};
+
+static struct cipher_testvec xtea_dec_tv_template[] = {
+ {
+ .key = zeroed_string,
+ .klen = 16,
+ .input = "\xd8\xd4\xe9\xde\xd9\x1e\x13\xf7",
+ .ilen = 8,
+ .result = zeroed_string,
+ .rlen = 8,
+ }, {
+ .key = "\x2b\x02\x05\x68\x06\x14\x49\x76"
+ "\x77\x5d\x0e\x26\x6c\x28\x78\x43",
+ .klen = 16,
+ .input = "\x94\xeb\xc8\x96\x84\x6a\x49\xa8",
+ .ilen = 8,
+ .result = "\x74\x65\x73\x74\x20\x6d\x65\x2e",
+ .rlen = 8,
+ }, {
+ .key = "\x09\x65\x43\x11\x66\x44\x39\x25"
+ "\x51\x3a\x16\x10\x0a\x08\x12\x6e",
+ .klen = 16,
+ .input = "\x3e\xce\xae\x22\x60\x56\xa8\x9d"
+ "\x77\x4d\xd4\xb4\x87\x24\xe3\x9a",
+ .ilen = 16,
+ .result = "\x6c\x6f\x6e\x67\x65\x72\x5f\x74"
+ "\x65\x73\x74\x5f\x76\x65\x63\x74",
+ .rlen = 16,
+ }, {
+ .key = "\x4d\x76\x32\x17\x05\x3f\x75\x2c"
+ "\x5d\x04\x16\x36\x15\x72\x63\x2f",
+ .klen = 16,
+ .input = "\x99\x81\x9f\x5d\x6f\x4b\x31\x3a"
+ "\x86\xff\x6f\xd0\xe3\x87\x70\x07"
+ "\x4d\xb8\xcf\xf3\x99\x50\xb3\xd4"
+ "\x73\xa2\xfa\xc9\x16\x59\x5d\x81",
+ .ilen = 32,
+ .result = "\x54\x65\x61\x20\x69\x73\x20\x67"
+ "\x6f\x6f\x64\x20\x66\x6f\x72\x20"
+ "\x79\x6f\x75\x21\x21\x21\x20\x72"
+ "\x65\x61\x6c\x6c\x79\x21\x21\x21",
+ .rlen = 32,
+ }
+};
+
+/*
+ * KHAZAD test vectors.
+ */
+#define KHAZAD_ENC_TEST_VECTORS 5
+#define KHAZAD_DEC_TEST_VECTORS 5
+
+static struct cipher_testvec khazad_enc_tv_template[] = {
+ {
+ .key = "\x80\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .klen = 16,
+ .input = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .ilen = 8,
+ .result = "\x49\xa4\xce\x32\xac\x19\x0e\x3f",
+ .rlen = 8,
+ }, {
+ .key = "\x38\x38\x38\x38\x38\x38\x38\x38"
+ "\x38\x38\x38\x38\x38\x38\x38\x38",
+ .klen = 16,
+ .input = "\x38\x38\x38\x38\x38\x38\x38\x38",
+ .ilen = 8,
+ .result = "\x7e\x82\x12\xa1\xd9\x5b\xe4\xf9",
+ .rlen = 8,
+ }, {
+ .key = "\xa2\xa2\xa2\xa2\xa2\xa2\xa2\xa2"
+ "\xa2\xa2\xa2\xa2\xa2\xa2\xa2\xa2",
+ .klen = 16,
+ .input = "\xa2\xa2\xa2\xa2\xa2\xa2\xa2\xa2",
+ .ilen = 8,
+ .result = "\xaa\xbe\xc1\x95\xc5\x94\x1a\x9c",
+ .rlen = 8,
+ }, {
+ .key = "\x2f\x2f\x2f\x2f\x2f\x2f\x2f\x2f"
+ "\x2f\x2f\x2f\x2f\x2f\x2f\x2f\x2f",
+ .klen = 16,
+ .input = "\x2f\x2f\x2f\x2f\x2f\x2f\x2f\x2f",
+ .ilen = 8,
+ .result = "\x04\x74\xf5\x70\x50\x16\xd3\xb8",
+ .rlen = 8,
+ }, {
+ .key = "\x2f\x2f\x2f\x2f\x2f\x2f\x2f\x2f"
+ "\x2f\x2f\x2f\x2f\x2f\x2f\x2f\x2f",
+ .klen = 16,
+ .input = "\x2f\x2f\x2f\x2f\x2f\x2f\x2f\x2f"
+ "\x2f\x2f\x2f\x2f\x2f\x2f\x2f\x2f",
+ .ilen = 16,
+ .result = "\x04\x74\xf5\x70\x50\x16\xd3\xb8"
+ "\x04\x74\xf5\x70\x50\x16\xd3\xb8",
+ .rlen = 16,
+ },
+};
+
+static struct cipher_testvec khazad_dec_tv_template[] = {
+ {
+ .key = "\x80\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .klen = 16,
+ .input = "\x49\xa4\xce\x32\xac\x19\x0e\x3f",
+ .ilen = 8,
+ .result = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .rlen = 8,
+ }, {
+ .key = "\x38\x38\x38\x38\x38\x38\x38\x38"
+ "\x38\x38\x38\x38\x38\x38\x38\x38",
+ .klen = 16,
+ .input = "\x7e\x82\x12\xa1\xd9\x5b\xe4\xf9",
+ .ilen = 8,
+ .result = "\x38\x38\x38\x38\x38\x38\x38\x38",
+ .rlen = 8,
+ }, {
+ .key = "\xa2\xa2\xa2\xa2\xa2\xa2\xa2\xa2"
+ "\xa2\xa2\xa2\xa2\xa2\xa2\xa2\xa2",
+ .klen = 16,
+ .input = "\xaa\xbe\xc1\x95\xc5\x94\x1a\x9c",
+ .ilen = 8,
+ .result = "\xa2\xa2\xa2\xa2\xa2\xa2\xa2\xa2",
+ .rlen = 8,
+ }, {
+ .key = "\x2f\x2f\x2f\x2f\x2f\x2f\x2f\x2f"
+ "\x2f\x2f\x2f\x2f\x2f\x2f\x2f\x2f",
+ .klen = 16,
+ .input = "\x04\x74\xf5\x70\x50\x16\xd3\xb8",
+ .ilen = 8,
+ .result = "\x2f\x2f\x2f\x2f\x2f\x2f\x2f\x2f",
+ .rlen = 8,
+ }, {
+ .key = "\x2f\x2f\x2f\x2f\x2f\x2f\x2f\x2f"
+ "\x2f\x2f\x2f\x2f\x2f\x2f\x2f\x2f",
+ .klen = 16,
+ .input = "\x04\x74\xf5\x70\x50\x16\xd3\xb8"
+ "\x04\x74\xf5\x70\x50\x16\xd3\xb8",
+ .ilen = 16,
+ .result = "\x2f\x2f\x2f\x2f\x2f\x2f\x2f\x2f"
+ "\x2f\x2f\x2f\x2f\x2f\x2f\x2f\x2f",
+ .rlen = 16,
+ },
+};
+
+/*
+ * Anubis test vectors.
+ */
+
+#define ANUBIS_ENC_TEST_VECTORS 5
+#define ANUBIS_DEC_TEST_VECTORS 5
+#define ANUBIS_CBC_ENC_TEST_VECTORS 2
+#define ANUBIS_CBC_DEC_TEST_VECTORS 2
+
+static struct cipher_testvec anubis_enc_tv_template[] = {
+ {
+ .key = "\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe"
+ "\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe",
+ .klen = 16,
+ .input = "\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe"
+ "\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe",
+ .ilen = 16,
+ .result = "\x6d\xc5\xda\xa2\x26\x7d\x62\x6f"
+ "\x08\xb7\x52\x8e\x6e\x6e\x86\x90",
+ .rlen = 16,
+ }, {
+
+ .key = "\x03\x03\x03\x03\x03\x03\x03\x03"
+ "\x03\x03\x03\x03\x03\x03\x03\x03"
+ "\x03\x03\x03\x03",
+ .klen = 20,
+ .input = "\x03\x03\x03\x03\x03\x03\x03\x03"
+ "\x03\x03\x03\x03\x03\x03\x03\x03",
+ .ilen = 16,
+ .result = "\xdb\xf1\x42\xf4\xd1\x8a\xc7\x49"
+ "\x87\x41\x6f\x82\x0a\x98\x64\xae",
+ .rlen = 16,
+ }, {
+ .key = "\x24\x24\x24\x24\x24\x24\x24\x24"
+ "\x24\x24\x24\x24\x24\x24\x24\x24"
+ "\x24\x24\x24\x24\x24\x24\x24\x24"
+ "\x24\x24\x24\x24",
+ .klen = 28,
+ .input = "\x24\x24\x24\x24\x24\x24\x24\x24"
+ "\x24\x24\x24\x24\x24\x24\x24\x24",
+ .ilen = 16,
+ .result = "\xfd\x1b\x4a\xe3\xbf\xf0\xad\x3d"
+ "\x06\xd3\x61\x27\xfd\x13\x9e\xde",
+ .rlen = 16,
+ }, {
+ .key = "\x25\x25\x25\x25\x25\x25\x25\x25"
+ "\x25\x25\x25\x25\x25\x25\x25\x25"
+ "\x25\x25\x25\x25\x25\x25\x25\x25"
+ "\x25\x25\x25\x25\x25\x25\x25\x25",
+ .klen = 32,
+ .input = "\x25\x25\x25\x25\x25\x25\x25\x25"
+ "\x25\x25\x25\x25\x25\x25\x25\x25",
+ .ilen = 16,
+ .result = "\x1a\x91\xfb\x2b\xb7\x78\x6b\xc4"
+ "\x17\xd9\xff\x40\x3b\x0e\xe5\xfe",
+ .rlen = 16,
+ }, {
+ .key = "\x35\x35\x35\x35\x35\x35\x35\x35"
+ "\x35\x35\x35\x35\x35\x35\x35\x35"
+ "\x35\x35\x35\x35\x35\x35\x35\x35"
+ "\x35\x35\x35\x35\x35\x35\x35\x35"
+ "\x35\x35\x35\x35\x35\x35\x35\x35",
+ .klen = 40,
+ .input = "\x35\x35\x35\x35\x35\x35\x35\x35"
+ "\x35\x35\x35\x35\x35\x35\x35\x35",
+ .ilen = 16,
+ .result = "\xa5\x2c\x85\x6f\x9c\xba\xa0\x97"
+ "\x9e\xc6\x84\x0f\x17\x21\x07\xee",
+ .rlen = 16,
+ },
+};
+
+static struct cipher_testvec anubis_dec_tv_template[] = {
+ {
+ .key = "\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe"
+ "\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe",
+ .klen = 16,
+ .input = "\x6d\xc5\xda\xa2\x26\x7d\x62\x6f"
+ "\x08\xb7\x52\x8e\x6e\x6e\x86\x90",
+ .ilen = 16,
+ .result = "\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe"
+ "\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe",
+ .rlen = 16,
+ }, {
+
+ .key = "\x03\x03\x03\x03\x03\x03\x03\x03"
+ "\x03\x03\x03\x03\x03\x03\x03\x03"
+ "\x03\x03\x03\x03",
+ .klen = 20,
+ .input = "\xdb\xf1\x42\xf4\xd1\x8a\xc7\x49"
+ "\x87\x41\x6f\x82\x0a\x98\x64\xae",
+ .ilen = 16,
+ .result = "\x03\x03\x03\x03\x03\x03\x03\x03"
+ "\x03\x03\x03\x03\x03\x03\x03\x03",
+ .rlen = 16,
+ }, {
+ .key = "\x24\x24\x24\x24\x24\x24\x24\x24"
+ "\x24\x24\x24\x24\x24\x24\x24\x24"
+ "\x24\x24\x24\x24\x24\x24\x24\x24"
+ "\x24\x24\x24\x24",
+ .klen = 28,
+ .input = "\xfd\x1b\x4a\xe3\xbf\xf0\xad\x3d"
+ "\x06\xd3\x61\x27\xfd\x13\x9e\xde",
+ .ilen = 16,
+ .result = "\x24\x24\x24\x24\x24\x24\x24\x24"
+ "\x24\x24\x24\x24\x24\x24\x24\x24",
+ .rlen = 16,
+ }, {
+ .key = "\x25\x25\x25\x25\x25\x25\x25\x25"
+ "\x25\x25\x25\x25\x25\x25\x25\x25"
+ "\x25\x25\x25\x25\x25\x25\x25\x25"
+ "\x25\x25\x25\x25\x25\x25\x25\x25",
+ .klen = 32,
+ .input = "\x1a\x91\xfb\x2b\xb7\x78\x6b\xc4"
+ "\x17\xd9\xff\x40\x3b\x0e\xe5\xfe",
+ .ilen = 16,
+ .result = "\x25\x25\x25\x25\x25\x25\x25\x25"
+ "\x25\x25\x25\x25\x25\x25\x25\x25",
+ .rlen = 16,
+ }, {
+ .key = "\x35\x35\x35\x35\x35\x35\x35\x35"
+ "\x35\x35\x35\x35\x35\x35\x35\x35"
+ "\x35\x35\x35\x35\x35\x35\x35\x35"
+ "\x35\x35\x35\x35\x35\x35\x35\x35"
+ "\x35\x35\x35\x35\x35\x35\x35\x35",
+ .input = "\xa5\x2c\x85\x6f\x9c\xba\xa0\x97"
+ "\x9e\xc6\x84\x0f\x17\x21\x07\xee",
+ .klen = 40,
+ .ilen = 16,
+ .result = "\x35\x35\x35\x35\x35\x35\x35\x35"
+ "\x35\x35\x35\x35\x35\x35\x35\x35",
+ .rlen = 16,
+ },
+};
+
+static struct cipher_testvec anubis_cbc_enc_tv_template[] = {
+ {
+ .key = "\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe"
+ "\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe",
+ .klen = 16,
+ .input = "\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe"
+ "\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe"
+ "\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe"
+ "\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe",
+ .ilen = 32,
+ .result = "\x6d\xc5\xda\xa2\x26\x7d\x62\x6f"
+ "\x08\xb7\x52\x8e\x6e\x6e\x86\x90"
+ "\x86\xd8\xb5\x6f\x98\x5e\x8a\x66"
+ "\x4f\x1f\x78\xa1\xbb\x37\xf1\xbe",
+ .rlen = 32,
+ }, {
+ .key = "\x35\x35\x35\x35\x35\x35\x35\x35"
+ "\x35\x35\x35\x35\x35\x35\x35\x35"
+ "\x35\x35\x35\x35\x35\x35\x35\x35"
+ "\x35\x35\x35\x35\x35\x35\x35\x35"
+ "\x35\x35\x35\x35\x35\x35\x35\x35",
+ .klen = 40,
+ .input = "\x35\x35\x35\x35\x35\x35\x35\x35"
+ "\x35\x35\x35\x35\x35\x35\x35\x35"
+ "\x35\x35\x35\x35\x35\x35\x35\x35"
+ "\x35\x35\x35\x35\x35\x35\x35\x35",
+ .ilen = 32,
+ .result = "\xa5\x2c\x85\x6f\x9c\xba\xa0\x97"
+ "\x9e\xc6\x84\x0f\x17\x21\x07\xee"
+ "\xa2\xbc\x06\x98\xc6\x4b\xda\x75"
+ "\x2e\xaa\xbe\x58\xce\x01\x5b\xc7",
+ .rlen = 32,
+ },
+};
+
+static struct cipher_testvec anubis_cbc_dec_tv_template[] = {
+ {
+ .key = "\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe"
+ "\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe",
+ .klen = 16,
+ .input = "\x6d\xc5\xda\xa2\x26\x7d\x62\x6f"
+ "\x08\xb7\x52\x8e\x6e\x6e\x86\x90"
+ "\x86\xd8\xb5\x6f\x98\x5e\x8a\x66"
+ "\x4f\x1f\x78\xa1\xbb\x37\xf1\xbe",
+ .ilen = 32,
+ .result = "\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe"
+ "\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe"
+ "\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe"
+ "\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe",
+ .rlen = 32,
+ }, {
+ .key = "\x35\x35\x35\x35\x35\x35\x35\x35"
+ "\x35\x35\x35\x35\x35\x35\x35\x35"
+ "\x35\x35\x35\x35\x35\x35\x35\x35"
+ "\x35\x35\x35\x35\x35\x35\x35\x35"
+ "\x35\x35\x35\x35\x35\x35\x35\x35",
+ .klen = 40,
+ .input = "\xa5\x2c\x85\x6f\x9c\xba\xa0\x97"
+ "\x9e\xc6\x84\x0f\x17\x21\x07\xee"
+ "\xa2\xbc\x06\x98\xc6\x4b\xda\x75"
+ "\x2e\xaa\xbe\x58\xce\x01\x5b\xc7",
+ .ilen = 32,
+ .result = "\x35\x35\x35\x35\x35\x35\x35\x35"
+ "\x35\x35\x35\x35\x35\x35\x35\x35"
+ "\x35\x35\x35\x35\x35\x35\x35\x35"
+ "\x35\x35\x35\x35\x35\x35\x35\x35",
+ .rlen = 32,
+ },
+};
+
+/*
+ * XETA test vectors
+ */
+#define XETA_ENC_TEST_VECTORS 4
+#define XETA_DEC_TEST_VECTORS 4
+
+static struct cipher_testvec xeta_enc_tv_template[] = {
+ {
+ .key = zeroed_string,
+ .klen = 16,
+ .input = zeroed_string,
+ .ilen = 8,
+ .result = "\xaa\x22\x96\xe5\x6c\x61\xf3\x45",
+ .rlen = 8,
+ }, {
+ .key = "\x2b\x02\x05\x68\x06\x14\x49\x76"
+ "\x77\x5d\x0e\x26\x6c\x28\x78\x43",
+ .klen = 16,
+ .input = "\x74\x65\x73\x74\x20\x6d\x65\x2e",
+ .ilen = 8,
+ .result = "\x82\x3e\xeb\x35\xdc\xdd\xd9\xc3",
+ .rlen = 8,
+ }, {
+ .key = "\x09\x65\x43\x11\x66\x44\x39\x25"
+ "\x51\x3a\x16\x10\x0a\x08\x12\x6e",
+ .klen = 16,
+ .input = "\x6c\x6f\x6e\x67\x65\x72\x5f\x74"
+ "\x65\x73\x74\x5f\x76\x65\x63\x74",
+ .ilen = 16,
+ .result = "\xe2\x04\xdb\xf2\x89\x85\x9e\xea"
+ "\x61\x35\xaa\xed\xb5\xcb\x71\x2c",
+ .rlen = 16,
+ }, {
+ .key = "\x4d\x76\x32\x17\x05\x3f\x75\x2c"
+ "\x5d\x04\x16\x36\x15\x72\x63\x2f",
+ .klen = 16,
+ .input = "\x54\x65\x61\x20\x69\x73\x20\x67"
+ "\x6f\x6f\x64\x20\x66\x6f\x72\x20"
+ "\x79\x6f\x75\x21\x21\x21\x20\x72"
+ "\x65\x61\x6c\x6c\x79\x21\x21\x21",
+ .ilen = 32,
+ .result = "\x0b\x03\xcd\x8a\xbe\x95\xfd\xb1"
+ "\xc1\x44\x91\x0b\xa5\xc9\x1b\xb4"
+ "\xa9\xda\x1e\x9e\xb1\x3e\x2a\x8f"
+ "\xea\xa5\x6a\x85\xd1\xf4\xa8\xa5",
+ .rlen = 32,
+ }
+};
+
+static struct cipher_testvec xeta_dec_tv_template[] = {
+ {
+ .key = zeroed_string,
+ .klen = 16,
+ .input = "\xaa\x22\x96\xe5\x6c\x61\xf3\x45",
+ .ilen = 8,
+ .result = zeroed_string,
+ .rlen = 8,
+ }, {
+ .key = "\x2b\x02\x05\x68\x06\x14\x49\x76"
+ "\x77\x5d\x0e\x26\x6c\x28\x78\x43",
+ .klen = 16,
+ .input = "\x82\x3e\xeb\x35\xdc\xdd\xd9\xc3",
+ .ilen = 8,
+ .result = "\x74\x65\x73\x74\x20\x6d\x65\x2e",
+ .rlen = 8,
+ }, {
+ .key = "\x09\x65\x43\x11\x66\x44\x39\x25"
+ "\x51\x3a\x16\x10\x0a\x08\x12\x6e",
+ .klen = 16,
+ .input = "\xe2\x04\xdb\xf2\x89\x85\x9e\xea"
+ "\x61\x35\xaa\xed\xb5\xcb\x71\x2c",
+ .ilen = 16,
+ .result = "\x6c\x6f\x6e\x67\x65\x72\x5f\x74"
+ "\x65\x73\x74\x5f\x76\x65\x63\x74",
+ .rlen = 16,
+ }, {
+ .key = "\x4d\x76\x32\x17\x05\x3f\x75\x2c"
+ "\x5d\x04\x16\x36\x15\x72\x63\x2f",
+ .klen = 16,
+ .input = "\x0b\x03\xcd\x8a\xbe\x95\xfd\xb1"
+ "\xc1\x44\x91\x0b\xa5\xc9\x1b\xb4"
+ "\xa9\xda\x1e\x9e\xb1\x3e\x2a\x8f"
+ "\xea\xa5\x6a\x85\xd1\xf4\xa8\xa5",
+ .ilen = 32,
+ .result = "\x54\x65\x61\x20\x69\x73\x20\x67"
+ "\x6f\x6f\x64\x20\x66\x6f\x72\x20"
+ "\x79\x6f\x75\x21\x21\x21\x20\x72"
+ "\x65\x61\x6c\x6c\x79\x21\x21\x21",
+ .rlen = 32,
+ }
+};
+
+/*
+ * FCrypt test vectors
+ */
+#define FCRYPT_ENC_TEST_VECTORS ARRAY_SIZE(fcrypt_pcbc_enc_tv_template)
+#define FCRYPT_DEC_TEST_VECTORS ARRAY_SIZE(fcrypt_pcbc_dec_tv_template)
+
+static struct cipher_testvec fcrypt_pcbc_enc_tv_template[] = {
+ { /* http://www.openafs.org/pipermail/openafs-devel/2000-December/005320.html */
+ .key = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .klen = 8,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .input = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .ilen = 8,
+ .result = "\x0E\x09\x00\xC7\x3E\xF7\xED\x41",
+ .rlen = 8,
+ }, {
+ .key = "\x11\x44\x77\xAA\xDD\x00\x33\x66",
+ .klen = 8,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .input = "\x12\x34\x56\x78\x9A\xBC\xDE\xF0",
+ .ilen = 8,
+ .result = "\xD8\xED\x78\x74\x77\xEC\x06\x80",
+ .rlen = 8,
+ }, { /* From Arla */
+ .key = "\xf0\xe1\xd2\xc3\xb4\xa5\x96\x87",
+ .klen = 8,
+ .iv = "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .input = "The quick brown fox jumps over the lazy dogs.\0\0",
+ .ilen = 48,
+ .result = "\x00\xf0\x0e\x11\x75\xe6\x23\x82"
+ "\xee\xac\x98\x62\x44\x51\xe4\x84"
+ "\xc3\x59\xd8\xaa\x64\x60\xae\xf7"
+ "\xd2\xd9\x13\x79\x72\xa3\x45\x03"
+ "\x23\xb5\x62\xd7\x0c\xf5\x27\xd1"
+ "\xf8\x91\x3c\xac\x44\x22\x92\xef",
+ .rlen = 48,
+ }, {
+ .key = "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .klen = 8,
+ .iv = "\xf0\xe1\xd2\xc3\xb4\xa5\x96\x87",
+ .input = "The quick brown fox jumps over the lazy dogs.\0\0",
+ .ilen = 48,
+ .result = "\xca\x90\xf5\x9d\xcb\xd4\xd2\x3c"
+ "\x01\x88\x7f\x3e\x31\x6e\x62\x9d"
+ "\xd8\xe0\x57\xa3\x06\x3a\x42\x58"
+ "\x2a\x28\xfe\x72\x52\x2f\xdd\xe0"
+ "\x19\x89\x09\x1c\x2a\x8e\x8c\x94"
+ "\xfc\xc7\x68\xe4\x88\xaa\xde\x0f",
+ .rlen = 48,
+ }, { /* split-page version */
+ .key = "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .klen = 8,
+ .iv = "\xf0\xe1\xd2\xc3\xb4\xa5\x96\x87",
+ .input = "The quick brown fox jumps over the lazy dogs.\0\0",
+ .ilen = 48,
+ .result = "\xca\x90\xf5\x9d\xcb\xd4\xd2\x3c"
+ "\x01\x88\x7f\x3e\x31\x6e\x62\x9d"
+ "\xd8\xe0\x57\xa3\x06\x3a\x42\x58"
+ "\x2a\x28\xfe\x72\x52\x2f\xdd\xe0"
+ "\x19\x89\x09\x1c\x2a\x8e\x8c\x94"
+ "\xfc\xc7\x68\xe4\x88\xaa\xde\x0f",
+ .rlen = 48,
+ .np = 2,
+ .tap = { 20, 28 },
+ }
+};
+
+static struct cipher_testvec fcrypt_pcbc_dec_tv_template[] = {
+ { /* http://www.openafs.org/pipermail/openafs-devel/2000-December/005320.html */
+ .key = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .klen = 8,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .input = "\x0E\x09\x00\xC7\x3E\xF7\xED\x41",
+ .ilen = 8,
+ .result = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .rlen = 8,
+ }, {
+ .key = "\x11\x44\x77\xAA\xDD\x00\x33\x66",
+ .klen = 8,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .input = "\xD8\xED\x78\x74\x77\xEC\x06\x80",
+ .ilen = 8,
+ .result = "\x12\x34\x56\x78\x9A\xBC\xDE\xF0",
+ .rlen = 8,
+ }, { /* From Arla */
+ .key = "\xf0\xe1\xd2\xc3\xb4\xa5\x96\x87",
+ .klen = 8,
+ .iv = "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .input = "\x00\xf0\x0e\x11\x75\xe6\x23\x82"
+ "\xee\xac\x98\x62\x44\x51\xe4\x84"
+ "\xc3\x59\xd8\xaa\x64\x60\xae\xf7"
+ "\xd2\xd9\x13\x79\x72\xa3\x45\x03"
+ "\x23\xb5\x62\xd7\x0c\xf5\x27\xd1"
+ "\xf8\x91\x3c\xac\x44\x22\x92\xef",
+ .ilen = 48,
+ .result = "The quick brown fox jumps over the lazy dogs.\0\0",
+ .rlen = 48,
+ }, {
+ .key = "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .klen = 8,
+ .iv = "\xf0\xe1\xd2\xc3\xb4\xa5\x96\x87",
+ .input = "\xca\x90\xf5\x9d\xcb\xd4\xd2\x3c"
+ "\x01\x88\x7f\x3e\x31\x6e\x62\x9d"
+ "\xd8\xe0\x57\xa3\x06\x3a\x42\x58"
+ "\x2a\x28\xfe\x72\x52\x2f\xdd\xe0"
+ "\x19\x89\x09\x1c\x2a\x8e\x8c\x94"
+ "\xfc\xc7\x68\xe4\x88\xaa\xde\x0f",
+ .ilen = 48,
+ .result = "The quick brown fox jumps over the lazy dogs.\0\0",
+ .rlen = 48,
+ }, { /* split-page version */
+ .key = "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .klen = 8,
+ .iv = "\xf0\xe1\xd2\xc3\xb4\xa5\x96\x87",
+ .input = "\xca\x90\xf5\x9d\xcb\xd4\xd2\x3c"
+ "\x01\x88\x7f\x3e\x31\x6e\x62\x9d"
+ "\xd8\xe0\x57\xa3\x06\x3a\x42\x58"
+ "\x2a\x28\xfe\x72\x52\x2f\xdd\xe0"
+ "\x19\x89\x09\x1c\x2a\x8e\x8c\x94"
+ "\xfc\xc7\x68\xe4\x88\xaa\xde\x0f",
+ .ilen = 48,
+ .result = "The quick brown fox jumps over the lazy dogs.\0\0",
+ .rlen = 48,
+ .np = 2,
+ .tap = { 20, 28 },
+ }
+};
+
+/*
+ * CAMELLIA test vectors.
+ */
+#define CAMELLIA_ENC_TEST_VECTORS 3
+#define CAMELLIA_DEC_TEST_VECTORS 3
+#define CAMELLIA_CBC_ENC_TEST_VECTORS 2
+#define CAMELLIA_CBC_DEC_TEST_VECTORS 2
+
+static struct cipher_testvec camellia_enc_tv_template[] = {
+ {
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef"
+ "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .klen = 16,
+ .input = "\x01\x23\x45\x67\x89\xab\xcd\xef"
+ "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .ilen = 16,
+ .result = "\x67\x67\x31\x38\x54\x96\x69\x73"
+ "\x08\x57\x06\x56\x48\xea\xbe\x43",
+ .rlen = 16,
+ }, {
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef"
+ "\xfe\xdc\xba\x98\x76\x54\x32\x10"
+ "\x00\x11\x22\x33\x44\x55\x66\x77",
+ .klen = 24,
+ .input = "\x01\x23\x45\x67\x89\xab\xcd\xef"
+ "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .ilen = 16,
+ .result = "\xb4\x99\x34\x01\xb3\xe9\x96\xf8"
+ "\x4e\xe5\xce\xe7\xd7\x9b\x09\xb9",
+ .rlen = 16,
+ }, {
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef"
+ "\xfe\xdc\xba\x98\x76\x54\x32\x10"
+ "\x00\x11\x22\x33\x44\x55\x66\x77"
+ "\x88\x99\xaa\xbb\xcc\xdd\xee\xff",
+ .klen = 32,
+ .input = "\x01\x23\x45\x67\x89\xab\xcd\xef"
+ "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .ilen = 16,
+ .result = "\x9a\xcc\x23\x7d\xff\x16\xd7\x6c"
+ "\x20\xef\x7c\x91\x9e\x3a\x75\x09",
+ .rlen = 16,
+ },
+};
+
+static struct cipher_testvec camellia_dec_tv_template[] = {
+ {
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef"
+ "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .klen = 16,
+ .input = "\x67\x67\x31\x38\x54\x96\x69\x73"
+ "\x08\x57\x06\x56\x48\xea\xbe\x43",
+ .ilen = 16,
+ .result = "\x01\x23\x45\x67\x89\xab\xcd\xef"
+ "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .rlen = 16,
+ }, {
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef"
+ "\xfe\xdc\xba\x98\x76\x54\x32\x10"
+ "\x00\x11\x22\x33\x44\x55\x66\x77",
+ .klen = 24,
+ .input = "\xb4\x99\x34\x01\xb3\xe9\x96\xf8"
+ "\x4e\xe5\xce\xe7\xd7\x9b\x09\xb9",
+ .ilen = 16,
+ .result = "\x01\x23\x45\x67\x89\xab\xcd\xef"
+ "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .rlen = 16,
+ }, {
+ .key = "\x01\x23\x45\x67\x89\xab\xcd\xef"
+ "\xfe\xdc\xba\x98\x76\x54\x32\x10"
+ "\x00\x11\x22\x33\x44\x55\x66\x77"
+ "\x88\x99\xaa\xbb\xcc\xdd\xee\xff",
+ .klen = 32,
+ .input = "\x9a\xcc\x23\x7d\xff\x16\xd7\x6c"
+ "\x20\xef\x7c\x91\x9e\x3a\x75\x09",
+ .ilen = 16,
+ .result = "\x01\x23\x45\x67\x89\xab\xcd\xef"
+ "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .rlen = 16,
+ },
+};
+
+static struct cipher_testvec camellia_cbc_enc_tv_template[] = {
+ {
+ .key = "\x06\xa9\x21\x40\x36\xb8\xa1\x5b"
+ "\x51\x2e\x03\xd5\x34\x12\x00\x06",
+ .klen = 16,
+ .iv = "\x3d\xaf\xba\x42\x9d\x9e\xb4\x30"
+ "\xb4\x22\xda\x80\x2c\x9f\xac\x41",
+ .input = "Single block msg",
+ .ilen = 16,
+ .result = "\xea\x32\x12\x76\x3b\x50\x10\xe7"
+ "\x18\xf6\xfd\x5d\xf6\x8f\x13\x51",
+ .rlen = 16,
+ }, {
+ .key = "\xc2\x86\x69\x6d\x88\x7c\x9a\xa0"
+ "\x61\x1b\xbb\x3e\x20\x25\xa4\x5a",
+ .klen = 16,
+ .iv = "\x56\x2e\x17\x99\x6d\x09\x3d\x28"
+ "\xdd\xb3\xba\x69\x5a\x2e\x6f\x58",
+ .input = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
+ .ilen = 32,
+ .result = "\xa5\xdf\x6e\x50\xda\x70\x6c\x01"
+ "\x4a\xab\xf3\xf2\xd6\xfc\x6c\xfd"
+ "\x19\xb4\x3e\x57\x1c\x02\x5e\xa0"
+ "\x15\x78\xe0\x5e\xf2\xcb\x87\x16",
+ .rlen = 32,
+ },
+};
+
+static struct cipher_testvec camellia_cbc_dec_tv_template[] = {
+ {
+ .key = "\x06\xa9\x21\x40\x36\xb8\xa1\x5b"
+ "\x51\x2e\x03\xd5\x34\x12\x00\x06",
+ .klen = 16,
+ .iv = "\x3d\xaf\xba\x42\x9d\x9e\xb4\x30"
+ "\xb4\x22\xda\x80\x2c\x9f\xac\x41",
+ .input = "\xea\x32\x12\x76\x3b\x50\x10\xe7"
+ "\x18\xf6\xfd\x5d\xf6\x8f\x13\x51",
+ .ilen = 16,
+ .result = "Single block msg",
+ .rlen = 16,
+ }, {
+ .key = "\xc2\x86\x69\x6d\x88\x7c\x9a\xa0"
+ "\x61\x1b\xbb\x3e\x20\x25\xa4\x5a",
+ .klen = 16,
+ .iv = "\x56\x2e\x17\x99\x6d\x09\x3d\x28"
+ "\xdd\xb3\xba\x69\x5a\x2e\x6f\x58",
+ .input = "\xa5\xdf\x6e\x50\xda\x70\x6c\x01"
+ "\x4a\xab\xf3\xf2\xd6\xfc\x6c\xfd"
+ "\x19\xb4\x3e\x57\x1c\x02\x5e\xa0"
+ "\x15\x78\xe0\x5e\xf2\xcb\x87\x16",
+ .ilen = 32,
+ .result = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
+ .rlen = 32,
+ },
+};
+
+/*
+ * SEED test vectors
+ */
+#define SEED_ENC_TEST_VECTORS 4
+#define SEED_DEC_TEST_VECTORS 4
+
+static struct cipher_testvec seed_enc_tv_template[] = {
+ {
+ .key = zeroed_string,
+ .klen = 16,
+ .input = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .ilen = 16,
+ .result = "\x5e\xba\xc6\xe0\x05\x4e\x16\x68"
+ "\x19\xaf\xf1\xcc\x6d\x34\x6c\xdb",
+ .rlen = 16,
+ }, {
+ .key = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .klen = 16,
+ .input = zeroed_string,
+ .ilen = 16,
+ .result = "\xc1\x1f\x22\xf2\x01\x40\x50\x50"
+ "\x84\x48\x35\x97\xe4\x37\x0f\x43",
+ .rlen = 16,
+ }, {
+ .key = "\x47\x06\x48\x08\x51\xe6\x1b\xe8"
+ "\x5d\x74\xbf\xb3\xfd\x95\x61\x85",
+ .klen = 16,
+ .input = "\x83\xa2\xf8\xa2\x88\x64\x1f\xb9"
+ "\xa4\xe9\xa5\xcc\x2f\x13\x1c\x7d",
+ .ilen = 16,
+ .result = "\xee\x54\xd1\x3e\xbc\xae\x70\x6d"
+ "\x22\x6b\xc3\x14\x2c\xd4\x0d\x4a",
+ .rlen = 16,
+ }, {
+ .key = "\x28\xdb\xc3\xbc\x49\xff\xd8\x7d"
+ "\xcf\xa5\x09\xb1\x1d\x42\x2b\xe7",
+ .klen = 16,
+ .input = "\xb4\x1e\x6b\xe2\xeb\xa8\x4a\x14"
+ "\x8e\x2e\xed\x84\x59\x3c\x5e\xc7",
+ .ilen = 16,
+ .result = "\x9b\x9b\x7b\xfc\xd1\x81\x3c\xb9"
+ "\x5d\x0b\x36\x18\xf4\x0f\x51\x22",
+ .rlen = 16,
+ }
+};
+
+static struct cipher_testvec seed_dec_tv_template[] = {
+ {
+ .key = zeroed_string,
+ .klen = 16,
+ .input = "\x5e\xba\xc6\xe0\x05\x4e\x16\x68"
+ "\x19\xaf\xf1\xcc\x6d\x34\x6c\xdb",
+ .ilen = 16,
+ .result = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .rlen = 16,
+ }, {
+ .key = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .klen = 16,
+ .input = "\xc1\x1f\x22\xf2\x01\x40\x50\x50"
+ "\x84\x48\x35\x97\xe4\x37\x0f\x43",
+ .ilen = 16,
+ .result = zeroed_string,
+ .rlen = 16,
+ }, {
+ .key = "\x47\x06\x48\x08\x51\xe6\x1b\xe8"
+ "\x5d\x74\xbf\xb3\xfd\x95\x61\x85",
+ .klen = 16,
+ .input = "\xee\x54\xd1\x3e\xbc\xae\x70\x6d"
+ "\x22\x6b\xc3\x14\x2c\xd4\x0d\x4a",
+ .ilen = 16,
+ .result = "\x83\xa2\xf8\xa2\x88\x64\x1f\xb9"
+ "\xa4\xe9\xa5\xcc\x2f\x13\x1c\x7d",
+ .rlen = 16,
+ }, {
+ .key = "\x28\xdb\xc3\xbc\x49\xff\xd8\x7d"
+ "\xcf\xa5\x09\xb1\x1d\x42\x2b\xe7",
+ .klen = 16,
+ .input = "\x9b\x9b\x7b\xfc\xd1\x81\x3c\xb9"
+ "\x5d\x0b\x36\x18\xf4\x0f\x51\x22",
+ .ilen = 16,
+ .result = "\xb4\x1e\x6b\xe2\xeb\xa8\x4a\x14"
+ "\x8e\x2e\xed\x84\x59\x3c\x5e\xc7",
+ .rlen = 16,
+ }
+};
+
+#define SALSA20_STREAM_ENC_TEST_VECTORS 5
+static struct cipher_testvec salsa20_stream_enc_tv_template[] = {
+ /*
+ * Testvectors from verified.test-vectors submitted to ECRYPT.
+ * They are truncated to size 39, 64, 111, 129 to test a variety
+ * of input length.
+ */
+ { /* Set 3, vector 0 */
+ .key = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F",
+ .klen = 16,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .input = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00",
+ .ilen = 39,
+ .result = "\x2D\xD5\xC3\xF7\xBA\x2B\x20\xF7"
+ "\x68\x02\x41\x0C\x68\x86\x88\x89"
+ "\x5A\xD8\xC1\xBD\x4E\xA6\xC9\xB1"
+ "\x40\xFB\x9B\x90\xE2\x10\x49\xBF"
+ "\x58\x3F\x52\x79\x70\xEB\xC1",
+ .rlen = 39,
+ }, { /* Set 5, vector 0 */
+ .key = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .klen = 16,
+ .iv = "\x80\x00\x00\x00\x00\x00\x00\x00",
+ .input = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .ilen = 64,
+ .result = "\xB6\x6C\x1E\x44\x46\xDD\x95\x57"
+ "\xE5\x78\xE2\x23\xB0\xB7\x68\x01"
+ "\x7B\x23\xB2\x67\xBB\x02\x34\xAE"
+ "\x46\x26\xBF\x44\x3F\x21\x97\x76"
+ "\x43\x6F\xB1\x9F\xD0\xE8\x86\x6F"
+ "\xCD\x0D\xE9\xA9\x53\x8F\x4A\x09"
+ "\xCA\x9A\xC0\x73\x2E\x30\xBC\xF9"
+ "\x8E\x4F\x13\xE4\xB9\xE2\x01\xD9",
+ .rlen = 64,
+ }, { /* Set 3, vector 27 */
+ .key = "\x1B\x1C\x1D\x1E\x1F\x20\x21\x22"
+ "\x23\x24\x25\x26\x27\x28\x29\x2A"
+ "\x2B\x2C\x2D\x2E\x2F\x30\x31\x32"
+ "\x33\x34\x35\x36\x37\x38\x39\x3A",
+ .klen = 32,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .input = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00",
+ .ilen = 111,
+ .result = "\xAE\x39\x50\x8E\xAC\x9A\xEC\xE7"
+ "\xBF\x97\xBB\x20\xB9\xDE\xE4\x1F"
+ "\x87\xD9\x47\xF8\x28\x91\x35\x98"
+ "\xDB\x72\xCC\x23\x29\x48\x56\x5E"
+ "\x83\x7E\x0B\xF3\x7D\x5D\x38\x7B"
+ "\x2D\x71\x02\xB4\x3B\xB5\xD8\x23"
+ "\xB0\x4A\xDF\x3C\xEC\xB6\xD9\x3B"
+ "\x9B\xA7\x52\xBE\xC5\xD4\x50\x59"
+ "\x15\x14\xB4\x0E\x40\xE6\x53\xD1"
+ "\x83\x9C\x5B\xA0\x92\x29\x6B\x5E"
+ "\x96\x5B\x1E\x2F\xD3\xAC\xC1\x92"
+ "\xB1\x41\x3F\x19\x2F\xC4\x3B\xC6"
+ "\x95\x46\x45\x54\xE9\x75\x03\x08"
+ "\x44\xAF\xE5\x8A\x81\x12\x09",
+ .rlen = 111,
+ }, { /* Set 5, vector 27 */
+ .key = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .klen = 32,
+ .iv = "\x00\x00\x00\x10\x00\x00\x00\x00",
+ .input = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00",
+ .ilen = 129,
+ .result = "\xD2\xDB\x1A\x5C\xF1\xC1\xAC\xDB"
+ "\xE8\x1A\x7A\x43\x40\xEF\x53\x43"
+ "\x5E\x7F\x4B\x1A\x50\x52\x3F\x8D"
+ "\x28\x3D\xCF\x85\x1D\x69\x6E\x60"
+ "\xF2\xDE\x74\x56\x18\x1B\x84\x10"
+ "\xD4\x62\xBA\x60\x50\xF0\x61\xF2"
+ "\x1C\x78\x7F\xC1\x24\x34\xAF\x58"
+ "\xBF\x2C\x59\xCA\x90\x77\xF3\xB0"
+ "\x5B\x4A\xDF\x89\xCE\x2C\x2F\xFC"
+ "\x67\xF0\xE3\x45\xE8\xB3\xB3\x75"
+ "\xA0\x95\x71\xA1\x29\x39\x94\xCA"
+ "\x45\x2F\xBD\xCB\x10\xB6\xBE\x9F"
+ "\x8E\xF9\xB2\x01\x0A\x5A\x0A\xB7"
+ "\x6B\x9D\x70\x8E\x4B\xD6\x2F\xCD"
+ "\x2E\x40\x48\x75\xE9\xE2\x21\x45"
+ "\x0B\xC9\xB6\xB5\x66\xBC\x9A\x59"
+ "\x5A",
+ .rlen = 129,
+ }, { /* large test vector generated using Crypto++ */
+ .key = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
+ .klen = 32,
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .input =
+ "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
+ "\x20\x21\x22\x23\x24\x25\x26\x27"
+ "\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f"
+ "\x30\x31\x32\x33\x34\x35\x36\x37"
+ "\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f"
+ "\x40\x41\x42\x43\x44\x45\x46\x47"
+ "\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f"
+ "\x50\x51\x52\x53\x54\x55\x56\x57"
+ "\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f"
+ "\x60\x61\x62\x63\x64\x65\x66\x67"
+ "\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f"
+ "\x70\x71\x72\x73\x74\x75\x76\x77"
+ "\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f"
+ "\x80\x81\x82\x83\x84\x85\x86\x87"
+ "\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
+ "\x90\x91\x92\x93\x94\x95\x96\x97"
+ "\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
+ "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7"
+ "\xa8\xa9\xaa\xab\xac\xad\xae\xaf"
+ "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7"
+ "\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf"
+ "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
+ "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
+ "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7"
+ "\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf"
+ "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7"
+ "\xe8\xe9\xea\xeb\xec\xed\xee\xef"
+ "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7"
+ "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"
+ "\x00\x03\x06\x09\x0c\x0f\x12\x15"
+ "\x18\x1b\x1e\x21\x24\x27\x2a\x2d"
+ "\x30\x33\x36\x39\x3c\x3f\x42\x45"
+ "\x48\x4b\x4e\x51\x54\x57\x5a\x5d"
+ "\x60\x63\x66\x69\x6c\x6f\x72\x75"
+ "\x78\x7b\x7e\x81\x84\x87\x8a\x8d"
+ "\x90\x93\x96\x99\x9c\x9f\xa2\xa5"
+ "\xa8\xab\xae\xb1\xb4\xb7\xba\xbd"
+ "\xc0\xc3\xc6\xc9\xcc\xcf\xd2\xd5"
+ "\xd8\xdb\xde\xe1\xe4\xe7\xea\xed"
+ "\xf0\xf3\xf6\xf9\xfc\xff\x02\x05"
+ "\x08\x0b\x0e\x11\x14\x17\x1a\x1d"
+ "\x20\x23\x26\x29\x2c\x2f\x32\x35"
+ "\x38\x3b\x3e\x41\x44\x47\x4a\x4d"
+ "\x50\x53\x56\x59\x5c\x5f\x62\x65"
+ "\x68\x6b\x6e\x71\x74\x77\x7a\x7d"
+ "\x80\x83\x86\x89\x8c\x8f\x92\x95"
+ "\x98\x9b\x9e\xa1\xa4\xa7\xaa\xad"
+ "\xb0\xb3\xb6\xb9\xbc\xbf\xc2\xc5"
+ "\xc8\xcb\xce\xd1\xd4\xd7\xda\xdd"
+ "\xe0\xe3\xe6\xe9\xec\xef\xf2\xf5"
+ "\xf8\xfb\xfe\x01\x04\x07\x0a\x0d"
+ "\x10\x13\x16\x19\x1c\x1f\x22\x25"
+ "\x28\x2b\x2e\x31\x34\x37\x3a\x3d"
+ "\x40\x43\x46\x49\x4c\x4f\x52\x55"
+ "\x58\x5b\x5e\x61\x64\x67\x6a\x6d"
+ "\x70\x73\x76\x79\x7c\x7f\x82\x85"
+ "\x88\x8b\x8e\x91\x94\x97\x9a\x9d"
+ "\xa0\xa3\xa6\xa9\xac\xaf\xb2\xb5"
+ "\xb8\xbb\xbe\xc1\xc4\xc7\xca\xcd"
+ "\xd0\xd3\xd6\xd9\xdc\xdf\xe2\xe5"
+ "\xe8\xeb\xee\xf1\xf4\xf7\xfa\xfd"
+ "\x00\x05\x0a\x0f\x14\x19\x1e\x23"
+ "\x28\x2d\x32\x37\x3c\x41\x46\x4b"
+ "\x50\x55\x5a\x5f\x64\x69\x6e\x73"
+ "\x78\x7d\x82\x87\x8c\x91\x96\x9b"
+ "\xa0\xa5\xaa\xaf\xb4\xb9\xbe\xc3"
+ "\xc8\xcd\xd2\xd7\xdc\xe1\xe6\xeb"
+ "\xf0\xf5\xfa\xff\x04\x09\x0e\x13"
+ "\x18\x1d\x22\x27\x2c\x31\x36\x3b"
+ "\x40\x45\x4a\x4f\x54\x59\x5e\x63"
+ "\x68\x6d\x72\x77\x7c\x81\x86\x8b"
+ "\x90\x95\x9a\x9f\xa4\xa9\xae\xb3"
+ "\xb8\xbd\xc2\xc7\xcc\xd1\xd6\xdb"
+ "\xe0\xe5\xea\xef\xf4\xf9\xfe\x03"
+ "\x08\x0d\x12\x17\x1c\x21\x26\x2b"
+ "\x30\x35\x3a\x3f\x44\x49\x4e\x53"
+ "\x58\x5d\x62\x67\x6c\x71\x76\x7b"
+ "\x80\x85\x8a\x8f\x94\x99\x9e\xa3"
+ "\xa8\xad\xb2\xb7\xbc\xc1\xc6\xcb"
+ "\xd0\xd5\xda\xdf\xe4\xe9\xee\xf3"
+ "\xf8\xfd\x02\x07\x0c\x11\x16\x1b"
+ "\x20\x25\x2a\x2f\x34\x39\x3e\x43"
+ "\x48\x4d\x52\x57\x5c\x61\x66\x6b"
+ "\x70\x75\x7a\x7f\x84\x89\x8e\x93"
+ "\x98\x9d\xa2\xa7\xac\xb1\xb6\xbb"
+ "\xc0\xc5\xca\xcf\xd4\xd9\xde\xe3"
+ "\xe8\xed\xf2\xf7\xfc\x01\x06\x0b"
+ "\x10\x15\x1a\x1f\x24\x29\x2e\x33"
+ "\x38\x3d\x42\x47\x4c\x51\x56\x5b"
+ "\x60\x65\x6a\x6f\x74\x79\x7e\x83"
+ "\x88\x8d\x92\x97\x9c\xa1\xa6\xab"
+ "\xb0\xb5\xba\xbf\xc4\xc9\xce\xd3"
+ "\xd8\xdd\xe2\xe7\xec\xf1\xf6\xfb"
+ "\x00\x07\x0e\x15\x1c\x23\x2a\x31"
+ "\x38\x3f\x46\x4d\x54\x5b\x62\x69"
+ "\x70\x77\x7e\x85\x8c\x93\x9a\xa1"
+ "\xa8\xaf\xb6\xbd\xc4\xcb\xd2\xd9"
+ "\xe0\xe7\xee\xf5\xfc\x03\x0a\x11"
+ "\x18\x1f\x26\x2d\x34\x3b\x42\x49"
+ "\x50\x57\x5e\x65\x6c\x73\x7a\x81"
+ "\x88\x8f\x96\x9d\xa4\xab\xb2\xb9"
+ "\xc0\xc7\xce\xd5\xdc\xe3\xea\xf1"
+ "\xf8\xff\x06\x0d\x14\x1b\x22\x29"
+ "\x30\x37\x3e\x45\x4c\x53\x5a\x61"
+ "\x68\x6f\x76\x7d\x84\x8b\x92\x99"
+ "\xa0\xa7\xae\xb5\xbc\xc3\xca\xd1"
+ "\xd8\xdf\xe6\xed\xf4\xfb\x02\x09"
+ "\x10\x17\x1e\x25\x2c\x33\x3a\x41"
+ "\x48\x4f\x56\x5d\x64\x6b\x72\x79"
+ "\x80\x87\x8e\x95\x9c\xa3\xaa\xb1"
+ "\xb8\xbf\xc6\xcd\xd4\xdb\xe2\xe9"
+ "\xf0\xf7\xfe\x05\x0c\x13\x1a\x21"
+ "\x28\x2f\x36\x3d\x44\x4b\x52\x59"
+ "\x60\x67\x6e\x75\x7c\x83\x8a\x91"
+ "\x98\x9f\xa6\xad\xb4\xbb\xc2\xc9"
+ "\xd0\xd7\xde\xe5\xec\xf3\xfa\x01"
+ "\x08\x0f\x16\x1d\x24\x2b\x32\x39"
+ "\x40\x47\x4e\x55\x5c\x63\x6a\x71"
+ "\x78\x7f\x86\x8d\x94\x9b\xa2\xa9"
+ "\xb0\xb7\xbe\xc5\xcc\xd3\xda\xe1"
+ "\xe8\xef\xf6\xfd\x04\x0b\x12\x19"
+ "\x20\x27\x2e\x35\x3c\x43\x4a\x51"
+ "\x58\x5f\x66\x6d\x74\x7b\x82\x89"
+ "\x90\x97\x9e\xa5\xac\xb3\xba\xc1"
+ "\xc8\xcf\xd6\xdd\xe4\xeb\xf2\xf9"
+ "\x00\x09\x12\x1b\x24\x2d\x36\x3f"
+ "\x48\x51\x5a\x63\x6c\x75\x7e\x87"
+ "\x90\x99\xa2\xab\xb4\xbd\xc6\xcf"
+ "\xd8\xe1\xea\xf3\xfc\x05\x0e\x17"
+ "\x20\x29\x32\x3b\x44\x4d\x56\x5f"
+ "\x68\x71\x7a\x83\x8c\x95\x9e\xa7"
+ "\xb0\xb9\xc2\xcb\xd4\xdd\xe6\xef"
+ "\xf8\x01\x0a\x13\x1c\x25\x2e\x37"
+ "\x40\x49\x52\x5b\x64\x6d\x76\x7f"
+ "\x88\x91\x9a\xa3\xac\xb5\xbe\xc7"
+ "\xd0\xd9\xe2\xeb\xf4\xfd\x06\x0f"
+ "\x18\x21\x2a\x33\x3c\x45\x4e\x57"
+ "\x60\x69\x72\x7b\x84\x8d\x96\x9f"
+ "\xa8\xb1\xba\xc3\xcc\xd5\xde\xe7"
+ "\xf0\xf9\x02\x0b\x14\x1d\x26\x2f"
+ "\x38\x41\x4a\x53\x5c\x65\x6e\x77"
+ "\x80\x89\x92\x9b\xa4\xad\xb6\xbf"
+ "\xc8\xd1\xda\xe3\xec\xf5\xfe\x07"
+ "\x10\x19\x22\x2b\x34\x3d\x46\x4f"
+ "\x58\x61\x6a\x73\x7c\x85\x8e\x97"
+ "\xa0\xa9\xb2\xbb\xc4\xcd\xd6\xdf"
+ "\xe8\xf1\xfa\x03\x0c\x15\x1e\x27"
+ "\x30\x39\x42\x4b\x54\x5d\x66\x6f"
+ "\x78\x81\x8a\x93\x9c\xa5\xae\xb7"
+ "\xc0\xc9\xd2\xdb\xe4\xed\xf6\xff"
+ "\x08\x11\x1a\x23\x2c\x35\x3e\x47"
+ "\x50\x59\x62\x6b\x74\x7d\x86\x8f"
+ "\x98\xa1\xaa\xb3\xbc\xc5\xce\xd7"
+ "\xe0\xe9\xf2\xfb\x04\x0d\x16\x1f"
+ "\x28\x31\x3a\x43\x4c\x55\x5e\x67"
+ "\x70\x79\x82\x8b\x94\x9d\xa6\xaf"
+ "\xb8\xc1\xca\xd3\xdc\xe5\xee\xf7"
+ "\x00\x0b\x16\x21\x2c\x37\x42\x4d"
+ "\x58\x63\x6e\x79\x84\x8f\x9a\xa5"
+ "\xb0\xbb\xc6\xd1\xdc\xe7\xf2\xfd"
+ "\x08\x13\x1e\x29\x34\x3f\x4a\x55"
+ "\x60\x6b\x76\x81\x8c\x97\xa2\xad"
+ "\xb8\xc3\xce\xd9\xe4\xef\xfa\x05"
+ "\x10\x1b\x26\x31\x3c\x47\x52\x5d"
+ "\x68\x73\x7e\x89\x94\x9f\xaa\xb5"
+ "\xc0\xcb\xd6\xe1\xec\xf7\x02\x0d"
+ "\x18\x23\x2e\x39\x44\x4f\x5a\x65"
+ "\x70\x7b\x86\x91\x9c\xa7\xb2\xbd"
+ "\xc8\xd3\xde\xe9\xf4\xff\x0a\x15"
+ "\x20\x2b\x36\x41\x4c\x57\x62\x6d"
+ "\x78\x83\x8e\x99\xa4\xaf\xba\xc5"
+ "\xd0\xdb\xe6\xf1\xfc\x07\x12\x1d"
+ "\x28\x33\x3e\x49\x54\x5f\x6a\x75"
+ "\x80\x8b\x96\xa1\xac\xb7\xc2\xcd"
+ "\xd8\xe3\xee\xf9\x04\x0f\x1a\x25"
+ "\x30\x3b\x46\x51\x5c\x67\x72\x7d"
+ "\x88\x93\x9e\xa9\xb4\xbf\xca\xd5"
+ "\xe0\xeb\xf6\x01\x0c\x17\x22\x2d"
+ "\x38\x43\x4e\x59\x64\x6f\x7a\x85"
+ "\x90\x9b\xa6\xb1\xbc\xc7\xd2\xdd"
+ "\xe8\xf3\xfe\x09\x14\x1f\x2a\x35"
+ "\x40\x4b\x56\x61\x6c\x77\x82\x8d"
+ "\x98\xa3\xae\xb9\xc4\xcf\xda\xe5"
+ "\xf0\xfb\x06\x11\x1c\x27\x32\x3d"
+ "\x48\x53\x5e\x69\x74\x7f\x8a\x95"
+ "\xa0\xab\xb6\xc1\xcc\xd7\xe2\xed"
+ "\xf8\x03\x0e\x19\x24\x2f\x3a\x45"
+ "\x50\x5b\x66\x71\x7c\x87\x92\x9d"
+ "\xa8\xb3\xbe\xc9\xd4\xdf\xea\xf5"
+ "\x00\x0d\x1a\x27\x34\x41\x4e\x5b"
+ "\x68\x75\x82\x8f\x9c\xa9\xb6\xc3"
+ "\xd0\xdd\xea\xf7\x04\x11\x1e\x2b"
+ "\x38\x45\x52\x5f\x6c\x79\x86\x93"
+ "\xa0\xad\xba\xc7\xd4\xe1\xee\xfb"
+ "\x08\x15\x22\x2f\x3c\x49\x56\x63"
+ "\x70\x7d\x8a\x97\xa4\xb1\xbe\xcb"
+ "\xd8\xe5\xf2\xff\x0c\x19\x26\x33"
+ "\x40\x4d\x5a\x67\x74\x81\x8e\x9b"
+ "\xa8\xb5\xc2\xcf\xdc\xe9\xf6\x03"
+ "\x10\x1d\x2a\x37\x44\x51\x5e\x6b"
+ "\x78\x85\x92\x9f\xac\xb9\xc6\xd3"
+ "\xe0\xed\xfa\x07\x14\x21\x2e\x3b"
+ "\x48\x55\x62\x6f\x7c\x89\x96\xa3"
+ "\xb0\xbd\xca\xd7\xe4\xf1\xfe\x0b"
+ "\x18\x25\x32\x3f\x4c\x59\x66\x73"
+ "\x80\x8d\x9a\xa7\xb4\xc1\xce\xdb"
+ "\xe8\xf5\x02\x0f\x1c\x29\x36\x43"
+ "\x50\x5d\x6a\x77\x84\x91\x9e\xab"
+ "\xb8\xc5\xd2\xdf\xec\xf9\x06\x13"
+ "\x20\x2d\x3a\x47\x54\x61\x6e\x7b"
+ "\x88\x95\xa2\xaf\xbc\xc9\xd6\xe3"
+ "\xf0\xfd\x0a\x17\x24\x31\x3e\x4b"
+ "\x58\x65\x72\x7f\x8c\x99\xa6\xb3"
+ "\xc0\xcd\xda\xe7\xf4\x01\x0e\x1b"
+ "\x28\x35\x42\x4f\x5c\x69\x76\x83"
+ "\x90\x9d\xaa\xb7\xc4\xd1\xde\xeb"
+ "\xf8\x05\x12\x1f\x2c\x39\x46\x53"
+ "\x60\x6d\x7a\x87\x94\xa1\xae\xbb"
+ "\xc8\xd5\xe2\xef\xfc\x09\x16\x23"
+ "\x30\x3d\x4a\x57\x64\x71\x7e\x8b"
+ "\x98\xa5\xb2\xbf\xcc\xd9\xe6\xf3"
+ "\x00\x0f\x1e\x2d\x3c\x4b\x5a\x69"
+ "\x78\x87\x96\xa5\xb4\xc3\xd2\xe1"
+ "\xf0\xff\x0e\x1d\x2c\x3b\x4a\x59"
+ "\x68\x77\x86\x95\xa4\xb3\xc2\xd1"
+ "\xe0\xef\xfe\x0d\x1c\x2b\x3a\x49"
+ "\x58\x67\x76\x85\x94\xa3\xb2\xc1"
+ "\xd0\xdf\xee\xfd\x0c\x1b\x2a\x39"
+ "\x48\x57\x66\x75\x84\x93\xa2\xb1"
+ "\xc0\xcf\xde\xed\xfc\x0b\x1a\x29"
+ "\x38\x47\x56\x65\x74\x83\x92\xa1"
+ "\xb0\xbf\xce\xdd\xec\xfb\x0a\x19"
+ "\x28\x37\x46\x55\x64\x73\x82\x91"
+ "\xa0\xaf\xbe\xcd\xdc\xeb\xfa\x09"
+ "\x18\x27\x36\x45\x54\x63\x72\x81"
+ "\x90\x9f\xae\xbd\xcc\xdb\xea\xf9"
+ "\x08\x17\x26\x35\x44\x53\x62\x71"
+ "\x80\x8f\x9e\xad\xbc\xcb\xda\xe9"
+ "\xf8\x07\x16\x25\x34\x43\x52\x61"
+ "\x70\x7f\x8e\x9d\xac\xbb\xca\xd9"
+ "\xe8\xf7\x06\x15\x24\x33\x42\x51"
+ "\x60\x6f\x7e\x8d\x9c\xab\xba\xc9"
+ "\xd8\xe7\xf6\x05\x14\x23\x32\x41"
+ "\x50\x5f\x6e\x7d\x8c\x9b\xaa\xb9"
+ "\xc8\xd7\xe6\xf5\x04\x13\x22\x31"
+ "\x40\x4f\x5e\x6d\x7c\x8b\x9a\xa9"
+ "\xb8\xc7\xd6\xe5\xf4\x03\x12\x21"
+ "\x30\x3f\x4e\x5d\x6c\x7b\x8a\x99"
+ "\xa8\xb7\xc6\xd5\xe4\xf3\x02\x11"
+ "\x20\x2f\x3e\x4d\x5c\x6b\x7a\x89"
+ "\x98\xa7\xb6\xc5\xd4\xe3\xf2\x01"
+ "\x10\x1f\x2e\x3d\x4c\x5b\x6a\x79"
+ "\x88\x97\xa6\xb5\xc4\xd3\xe2\xf1"
+ "\x00\x11\x22\x33\x44\x55\x66\x77"
+ "\x88\x99\xaa\xbb\xcc\xdd\xee\xff"
+ "\x10\x21\x32\x43\x54\x65\x76\x87"
+ "\x98\xa9\xba\xcb\xdc\xed\xfe\x0f"
+ "\x20\x31\x42\x53\x64\x75\x86\x97"
+ "\xa8\xb9\xca\xdb\xec\xfd\x0e\x1f"
+ "\x30\x41\x52\x63\x74\x85\x96\xa7"
+ "\xb8\xc9\xda\xeb\xfc\x0d\x1e\x2f"
+ "\x40\x51\x62\x73\x84\x95\xa6\xb7"
+ "\xc8\xd9\xea\xfb\x0c\x1d\x2e\x3f"
+ "\x50\x61\x72\x83\x94\xa5\xb6\xc7"
+ "\xd8\xe9\xfa\x0b\x1c\x2d\x3e\x4f"
+ "\x60\x71\x82\x93\xa4\xb5\xc6\xd7"
+ "\xe8\xf9\x0a\x1b\x2c\x3d\x4e\x5f"
+ "\x70\x81\x92\xa3\xb4\xc5\xd6\xe7"
+ "\xf8\x09\x1a\x2b\x3c\x4d\x5e\x6f"
+ "\x80\x91\xa2\xb3\xc4\xd5\xe6\xf7"
+ "\x08\x19\x2a\x3b\x4c\x5d\x6e\x7f"
+ "\x90\xa1\xb2\xc3\xd4\xe5\xf6\x07"
+ "\x18\x29\x3a\x4b\x5c\x6d\x7e\x8f"
+ "\xa0\xb1\xc2\xd3\xe4\xf5\x06\x17"
+ "\x28\x39\x4a\x5b\x6c\x7d\x8e\x9f"
+ "\xb0\xc1\xd2\xe3\xf4\x05\x16\x27"
+ "\x38\x49\x5a\x6b\x7c\x8d\x9e\xaf"
+ "\xc0\xd1\xe2\xf3\x04\x15\x26\x37"
+ "\x48\x59\x6a\x7b\x8c\x9d\xae\xbf"
+ "\xd0\xe1\xf2\x03\x14\x25\x36\x47"
+ "\x58\x69\x7a\x8b\x9c\xad\xbe\xcf"
+ "\xe0\xf1\x02\x13\x24\x35\x46\x57"
+ "\x68\x79\x8a\x9b\xac\xbd\xce\xdf"
+ "\xf0\x01\x12\x23\x34\x45\x56\x67"
+ "\x78\x89\x9a\xab\xbc\xcd\xde\xef"
+ "\x00\x13\x26\x39\x4c\x5f\x72\x85"
+ "\x98\xab\xbe\xd1\xe4\xf7\x0a\x1d"
+ "\x30\x43\x56\x69\x7c\x8f\xa2\xb5"
+ "\xc8\xdb\xee\x01\x14\x27\x3a\x4d"
+ "\x60\x73\x86\x99\xac\xbf\xd2\xe5"
+ "\xf8\x0b\x1e\x31\x44\x57\x6a\x7d"
+ "\x90\xa3\xb6\xc9\xdc\xef\x02\x15"
+ "\x28\x3b\x4e\x61\x74\x87\x9a\xad"
+ "\xc0\xd3\xe6\xf9\x0c\x1f\x32\x45"
+ "\x58\x6b\x7e\x91\xa4\xb7\xca\xdd"
+ "\xf0\x03\x16\x29\x3c\x4f\x62\x75"
+ "\x88\x9b\xae\xc1\xd4\xe7\xfa\x0d"
+ "\x20\x33\x46\x59\x6c\x7f\x92\xa5"
+ "\xb8\xcb\xde\xf1\x04\x17\x2a\x3d"
+ "\x50\x63\x76\x89\x9c\xaf\xc2\xd5"
+ "\xe8\xfb\x0e\x21\x34\x47\x5a\x6d"
+ "\x80\x93\xa6\xb9\xcc\xdf\xf2\x05"
+ "\x18\x2b\x3e\x51\x64\x77\x8a\x9d"
+ "\xb0\xc3\xd6\xe9\xfc\x0f\x22\x35"
+ "\x48\x5b\x6e\x81\x94\xa7\xba\xcd"
+ "\xe0\xf3\x06\x19\x2c\x3f\x52\x65"
+ "\x78\x8b\x9e\xb1\xc4\xd7\xea\xfd"
+ "\x10\x23\x36\x49\x5c\x6f\x82\x95"
+ "\xa8\xbb\xce\xe1\xf4\x07\x1a\x2d"
+ "\x40\x53\x66\x79\x8c\x9f\xb2\xc5"
+ "\xd8\xeb\xfe\x11\x24\x37\x4a\x5d"
+ "\x70\x83\x96\xa9\xbc\xcf\xe2\xf5"
+ "\x08\x1b\x2e\x41\x54\x67\x7a\x8d"
+ "\xa0\xb3\xc6\xd9\xec\xff\x12\x25"
+ "\x38\x4b\x5e\x71\x84\x97\xaa\xbd"
+ "\xd0\xe3\xf6\x09\x1c\x2f\x42\x55"
+ "\x68\x7b\x8e\xa1\xb4\xc7\xda\xed"
+ "\x00\x15\x2a\x3f\x54\x69\x7e\x93"
+ "\xa8\xbd\xd2\xe7\xfc\x11\x26\x3b"
+ "\x50\x65\x7a\x8f\xa4\xb9\xce\xe3"
+ "\xf8\x0d\x22\x37\x4c\x61\x76\x8b"
+ "\xa0\xb5\xca\xdf\xf4\x09\x1e\x33"
+ "\x48\x5d\x72\x87\x9c\xb1\xc6\xdb"
+ "\xf0\x05\x1a\x2f\x44\x59\x6e\x83"
+ "\x98\xad\xc2\xd7\xec\x01\x16\x2b"
+ "\x40\x55\x6a\x7f\x94\xa9\xbe\xd3"
+ "\xe8\xfd\x12\x27\x3c\x51\x66\x7b"
+ "\x90\xa5\xba\xcf\xe4\xf9\x0e\x23"
+ "\x38\x4d\x62\x77\x8c\xa1\xb6\xcb"
+ "\xe0\xf5\x0a\x1f\x34\x49\x5e\x73"
+ "\x88\x9d\xb2\xc7\xdc\xf1\x06\x1b"
+ "\x30\x45\x5a\x6f\x84\x99\xae\xc3"
+ "\xd8\xed\x02\x17\x2c\x41\x56\x6b"
+ "\x80\x95\xaa\xbf\xd4\xe9\xfe\x13"
+ "\x28\x3d\x52\x67\x7c\x91\xa6\xbb"
+ "\xd0\xe5\xfa\x0f\x24\x39\x4e\x63"
+ "\x78\x8d\xa2\xb7\xcc\xe1\xf6\x0b"
+ "\x20\x35\x4a\x5f\x74\x89\x9e\xb3"
+ "\xc8\xdd\xf2\x07\x1c\x31\x46\x5b"
+ "\x70\x85\x9a\xaf\xc4\xd9\xee\x03"
+ "\x18\x2d\x42\x57\x6c\x81\x96\xab"
+ "\xc0\xd5\xea\xff\x14\x29\x3e\x53"
+ "\x68\x7d\x92\xa7\xbc\xd1\xe6\xfb"
+ "\x10\x25\x3a\x4f\x64\x79\x8e\xa3"
+ "\xb8\xcd\xe2\xf7\x0c\x21\x36\x4b"
+ "\x60\x75\x8a\x9f\xb4\xc9\xde\xf3"
+ "\x08\x1d\x32\x47\x5c\x71\x86\x9b"
+ "\xb0\xc5\xda\xef\x04\x19\x2e\x43"
+ "\x58\x6d\x82\x97\xac\xc1\xd6\xeb"
+ "\x00\x17\x2e\x45\x5c\x73\x8a\xa1"
+ "\xb8\xcf\xe6\xfd\x14\x2b\x42\x59"
+ "\x70\x87\x9e\xb5\xcc\xe3\xfa\x11"
+ "\x28\x3f\x56\x6d\x84\x9b\xb2\xc9"
+ "\xe0\xf7\x0e\x25\x3c\x53\x6a\x81"
+ "\x98\xaf\xc6\xdd\xf4\x0b\x22\x39"
+ "\x50\x67\x7e\x95\xac\xc3\xda\xf1"
+ "\x08\x1f\x36\x4d\x64\x7b\x92\xa9"
+ "\xc0\xd7\xee\x05\x1c\x33\x4a\x61"
+ "\x78\x8f\xa6\xbd\xd4\xeb\x02\x19"
+ "\x30\x47\x5e\x75\x8c\xa3\xba\xd1"
+ "\xe8\xff\x16\x2d\x44\x5b\x72\x89"
+ "\xa0\xb7\xce\xe5\xfc\x13\x2a\x41"
+ "\x58\x6f\x86\x9d\xb4\xcb\xe2\xf9"
+ "\x10\x27\x3e\x55\x6c\x83\x9a\xb1"
+ "\xc8\xdf\xf6\x0d\x24\x3b\x52\x69"
+ "\x80\x97\xae\xc5\xdc\xf3\x0a\x21"
+ "\x38\x4f\x66\x7d\x94\xab\xc2\xd9"
+ "\xf0\x07\x1e\x35\x4c\x63\x7a\x91"
+ "\xa8\xbf\xd6\xed\x04\x1b\x32\x49"
+ "\x60\x77\x8e\xa5\xbc\xd3\xea\x01"
+ "\x18\x2f\x46\x5d\x74\x8b\xa2\xb9"
+ "\xd0\xe7\xfe\x15\x2c\x43\x5a\x71"
+ "\x88\x9f\xb6\xcd\xe4\xfb\x12\x29"
+ "\x40\x57\x6e\x85\x9c\xb3\xca\xe1"
+ "\xf8\x0f\x26\x3d\x54\x6b\x82\x99"
+ "\xb0\xc7\xde\xf5\x0c\x23\x3a\x51"
+ "\x68\x7f\x96\xad\xc4\xdb\xf2\x09"
+ "\x20\x37\x4e\x65\x7c\x93\xaa\xc1"
+ "\xd8\xef\x06\x1d\x34\x4b\x62\x79"
+ "\x90\xa7\xbe\xd5\xec\x03\x1a\x31"
+ "\x48\x5f\x76\x8d\xa4\xbb\xd2\xe9"
+ "\x00\x19\x32\x4b\x64\x7d\x96\xaf"
+ "\xc8\xe1\xfa\x13\x2c\x45\x5e\x77"
+ "\x90\xa9\xc2\xdb\xf4\x0d\x26\x3f"
+ "\x58\x71\x8a\xa3\xbc\xd5\xee\x07"
+ "\x20\x39\x52\x6b\x84\x9d\xb6\xcf"
+ "\xe8\x01\x1a\x33\x4c\x65\x7e\x97"
+ "\xb0\xc9\xe2\xfb\x14\x2d\x46\x5f"
+ "\x78\x91\xaa\xc3\xdc\xf5\x0e\x27"
+ "\x40\x59\x72\x8b\xa4\xbd\xd6\xef"
+ "\x08\x21\x3a\x53\x6c\x85\x9e\xb7"
+ "\xd0\xe9\x02\x1b\x34\x4d\x66\x7f"
+ "\x98\xb1\xca\xe3\xfc\x15\x2e\x47"
+ "\x60\x79\x92\xab\xc4\xdd\xf6\x0f"
+ "\x28\x41\x5a\x73\x8c\xa5\xbe\xd7"
+ "\xf0\x09\x22\x3b\x54\x6d\x86\x9f"
+ "\xb8\xd1\xea\x03\x1c\x35\x4e\x67"
+ "\x80\x99\xb2\xcb\xe4\xfd\x16\x2f"
+ "\x48\x61\x7a\x93\xac\xc5\xde\xf7"
+ "\x10\x29\x42\x5b\x74\x8d\xa6\xbf"
+ "\xd8\xf1\x0a\x23\x3c\x55\x6e\x87"
+ "\xa0\xb9\xd2\xeb\x04\x1d\x36\x4f"
+ "\x68\x81\x9a\xb3\xcc\xe5\xfe\x17"
+ "\x30\x49\x62\x7b\x94\xad\xc6\xdf"
+ "\xf8\x11\x2a\x43\x5c\x75\x8e\xa7"
+ "\xc0\xd9\xf2\x0b\x24\x3d\x56\x6f"
+ "\x88\xa1\xba\xd3\xec\x05\x1e\x37"
+ "\x50\x69\x82\x9b\xb4\xcd\xe6\xff"
+ "\x18\x31\x4a\x63\x7c\x95\xae\xc7"
+ "\xe0\xf9\x12\x2b\x44\x5d\x76\x8f"
+ "\xa8\xc1\xda\xf3\x0c\x25\x3e\x57"
+ "\x70\x89\xa2\xbb\xd4\xed\x06\x1f"
+ "\x38\x51\x6a\x83\x9c\xb5\xce\xe7"
+ "\x00\x1b\x36\x51\x6c\x87\xa2\xbd"
+ "\xd8\xf3\x0e\x29\x44\x5f\x7a\x95"
+ "\xb0\xcb\xe6\x01\x1c\x37\x52\x6d"
+ "\x88\xa3\xbe\xd9\xf4\x0f\x2a\x45"
+ "\x60\x7b\x96\xb1\xcc\xe7\x02\x1d"
+ "\x38\x53\x6e\x89\xa4\xbf\xda\xf5"
+ "\x10\x2b\x46\x61\x7c\x97\xb2\xcd"
+ "\xe8\x03\x1e\x39\x54\x6f\x8a\xa5"
+ "\xc0\xdb\xf6\x11\x2c\x47\x62\x7d"
+ "\x98\xb3\xce\xe9\x04\x1f\x3a\x55"
+ "\x70\x8b\xa6\xc1\xdc\xf7\x12\x2d"
+ "\x48\x63\x7e\x99\xb4\xcf\xea\x05"
+ "\x20\x3b\x56\x71\x8c\xa7\xc2\xdd"
+ "\xf8\x13\x2e\x49\x64\x7f\x9a\xb5"
+ "\xd0\xeb\x06\x21\x3c\x57\x72\x8d"
+ "\xa8\xc3\xde\xf9\x14\x2f\x4a\x65"
+ "\x80\x9b\xb6\xd1\xec\x07\x22\x3d"
+ "\x58\x73\x8e\xa9\xc4\xdf\xfa\x15"
+ "\x30\x4b\x66\x81\x9c\xb7\xd2\xed"
+ "\x08\x23\x3e\x59\x74\x8f\xaa\xc5"
+ "\xe0\xfb\x16\x31\x4c\x67\x82\x9d"
+ "\xb8\xd3\xee\x09\x24\x3f\x5a\x75"
+ "\x90\xab\xc6\xe1\xfc\x17\x32\x4d"
+ "\x68\x83\x9e\xb9\xd4\xef\x0a\x25"
+ "\x40\x5b\x76\x91\xac\xc7\xe2\xfd"
+ "\x18\x33\x4e\x69\x84\x9f\xba\xd5"
+ "\xf0\x0b\x26\x41\x5c\x77\x92\xad"
+ "\xc8\xe3\xfe\x19\x34\x4f\x6a\x85"
+ "\xa0\xbb\xd6\xf1\x0c\x27\x42\x5d"
+ "\x78\x93\xae\xc9\xe4\xff\x1a\x35"
+ "\x50\x6b\x86\xa1\xbc\xd7\xf2\x0d"
+ "\x28\x43\x5e\x79\x94\xaf\xca\xe5"
+ "\x00\x1d\x3a\x57\x74\x91\xae\xcb"
+ "\xe8\x05\x22\x3f\x5c\x79\x96\xb3"
+ "\xd0\xed\x0a\x27\x44\x61\x7e\x9b"
+ "\xb8\xd5\xf2\x0f\x2c\x49\x66\x83"
+ "\xa0\xbd\xda\xf7\x14\x31\x4e\x6b"
+ "\x88\xa5\xc2\xdf\xfc\x19\x36\x53"
+ "\x70\x8d\xaa\xc7\xe4\x01\x1e\x3b"
+ "\x58\x75\x92\xaf\xcc\xe9\x06\x23"
+ "\x40\x5d\x7a\x97\xb4\xd1\xee\x0b"
+ "\x28\x45\x62\x7f\x9c\xb9\xd6\xf3"
+ "\x10\x2d\x4a\x67\x84\xa1\xbe\xdb"
+ "\xf8\x15\x32\x4f\x6c\x89\xa6\xc3"
+ "\xe0\xfd\x1a\x37\x54\x71\x8e\xab"
+ "\xc8\xe5\x02\x1f\x3c\x59\x76\x93"
+ "\xb0\xcd\xea\x07\x24\x41\x5e\x7b"
+ "\x98\xb5\xd2\xef\x0c\x29\x46\x63"
+ "\x80\x9d\xba\xd7\xf4\x11\x2e\x4b"
+ "\x68\x85\xa2\xbf\xdc\xf9\x16\x33"
+ "\x50\x6d\x8a\xa7\xc4\xe1\xfe\x1b"
+ "\x38\x55\x72\x8f\xac\xc9\xe6\x03"
+ "\x20\x3d\x5a\x77\x94\xb1\xce\xeb"
+ "\x08\x25\x42\x5f\x7c\x99\xb6\xd3"
+ "\xf0\x0d\x2a\x47\x64\x81\x9e\xbb"
+ "\xd8\xf5\x12\x2f\x4c\x69\x86\xa3"
+ "\xc0\xdd\xfa\x17\x34\x51\x6e\x8b"
+ "\xa8\xc5\xe2\xff\x1c\x39\x56\x73"
+ "\x90\xad\xca\xe7\x04\x21\x3e\x5b"
+ "\x78\x95\xb2\xcf\xec\x09\x26\x43"
+ "\x60\x7d\x9a\xb7\xd4\xf1\x0e\x2b"
+ "\x48\x65\x82\x9f\xbc\xd9\xf6\x13"
+ "\x30\x4d\x6a\x87\xa4\xc1\xde\xfb"
+ "\x18\x35\x52\x6f\x8c\xa9\xc6\xe3"
+ "\x00\x1f\x3e\x5d\x7c\x9b\xba\xd9"
+ "\xf8\x17\x36\x55\x74\x93\xb2\xd1"
+ "\xf0\x0f\x2e\x4d\x6c\x8b\xaa\xc9"
+ "\xe8\x07\x26\x45\x64\x83\xa2\xc1"
+ "\xe0\xff\x1e\x3d\x5c\x7b\x9a\xb9"
+ "\xd8\xf7\x16\x35\x54\x73\x92\xb1"
+ "\xd0\xef\x0e\x2d\x4c\x6b\x8a\xa9"
+ "\xc8\xe7\x06\x25\x44\x63\x82\xa1"
+ "\xc0\xdf\xfe\x1d\x3c\x5b\x7a\x99"
+ "\xb8\xd7\xf6\x15\x34\x53\x72\x91"
+ "\xb0\xcf\xee\x0d\x2c\x4b\x6a\x89"
+ "\xa8\xc7\xe6\x05\x24\x43\x62\x81"
+ "\xa0\xbf\xde\xfd\x1c\x3b\x5a\x79"
+ "\x98\xb7\xd6\xf5\x14\x33\x52\x71"
+ "\x90\xaf\xce\xed\x0c\x2b\x4a\x69"
+ "\x88\xa7\xc6\xe5\x04\x23\x42\x61"
+ "\x80\x9f\xbe\xdd\xfc\x1b\x3a\x59"
+ "\x78\x97\xb6\xd5\xf4\x13\x32\x51"
+ "\x70\x8f\xae\xcd\xec\x0b\x2a\x49"
+ "\x68\x87\xa6\xc5\xe4\x03\x22\x41"
+ "\x60\x7f\x9e\xbd\xdc\xfb\x1a\x39"
+ "\x58\x77\x96\xb5\xd4\xf3\x12\x31"
+ "\x50\x6f\x8e\xad\xcc\xeb\x0a\x29"
+ "\x48\x67\x86\xa5\xc4\xe3\x02\x21"
+ "\x40\x5f\x7e\x9d\xbc\xdb\xfa\x19"
+ "\x38\x57\x76\x95\xb4\xd3\xf2\x11"
+ "\x30\x4f\x6e\x8d\xac\xcb\xea\x09"
+ "\x28\x47\x66\x85\xa4\xc3\xe2\x01"
+ "\x20\x3f\x5e\x7d\x9c\xbb\xda\xf9"
+ "\x18\x37\x56\x75\x94\xb3\xd2\xf1"
+ "\x10\x2f\x4e\x6d\x8c\xab\xca\xe9"
+ "\x08\x27\x46\x65\x84\xa3\xc2\xe1"
+ "\x00\x21\x42\x63",
+ .ilen = 4100,
+ .result =
+ "\xb5\x81\xf5\x64\x18\x73\xe3\xf0"
+ "\x4c\x13\xf2\x77\x18\x60\x65\x5e"
+ "\x29\x01\xce\x98\x55\x53\xf9\x0c"
+ "\x2a\x08\xd5\x09\xb3\x57\x55\x56"
+ "\xc5\xe9\x56\x90\xcb\x6a\xa3\xc0"
+ "\xff\xc4\x79\xb4\xd2\x97\x5d\xc4"
+ "\x43\xd1\xfe\x94\x7b\x88\x06\x5a"
+ "\xb2\x9e\x2c\xfc\x44\x03\xb7\x90"
+ "\xa0\xc1\xba\x6a\x33\xb8\xc7\xb2"
+ "\x9d\xe1\x12\x4f\xc0\x64\xd4\x01"
+ "\xfe\x8c\x7a\x66\xf7\xe6\x5a\x91"
+ "\xbb\xde\x56\x86\xab\x65\x21\x30"
+ "\x00\x84\x65\x24\xa5\x7d\x85\xb4"
+ "\xe3\x17\xed\x3a\xb7\x6f\xb4\x0b"
+ "\x0b\xaf\x15\xae\x5a\x8f\xf2\x0c"
+ "\x2f\x27\xf4\x09\xd8\xd2\x96\xb7"
+ "\x71\xf2\xc5\x99\x4d\x7e\x7f\x75"
+ "\x77\x89\x30\x8b\x59\xdb\xa2\xb2"
+ "\xa0\xf3\x19\x39\x2b\xc5\x7e\x3f"
+ "\x4f\xd9\xd3\x56\x28\x97\x44\xdc"
+ "\xc0\x8b\x77\x24\xd9\x52\xe7\xc5"
+ "\xaf\xf6\x7d\x59\xb2\x44\x05\x1d"
+ "\xb1\xb0\x11\xa5\x0f\xec\x33\xe1"
+ "\x6d\x1b\x4e\x1f\xff\x57\x91\xb4"
+ "\x5b\x9a\x96\xc5\x53\xbc\xae\x20"
+ "\x3c\xbb\x14\xe2\xe8\x22\x33\xc1"
+ "\x5e\x76\x9e\x46\x99\xf6\x2a\x15"
+ "\xc6\x97\x02\xa0\x66\x43\xd1\xa6"
+ "\x31\xa6\x9f\xfb\xf4\xd3\x69\xe5"
+ "\xcd\x76\x95\xb8\x7a\x82\x7f\x21"
+ "\x45\xff\x3f\xce\x55\xf6\x95\x10"
+ "\x08\x77\x10\x43\xc6\xf3\x09\xe5"
+ "\x68\xe7\x3c\xad\x00\x52\x45\x0d"
+ "\xfe\x2d\xc6\xc2\x94\x8c\x12\x1d"
+ "\xe6\x25\xae\x98\x12\x8e\x19\x9c"
+ "\x81\x68\xb1\x11\xf6\x69\xda\xe3"
+ "\x62\x08\x18\x7a\x25\x49\x28\xac"
+ "\xba\x71\x12\x0b\xe4\xa2\xe5\xc7"
+ "\x5d\x8e\xec\x49\x40\x21\xbf\x5a"
+ "\x98\xf3\x02\x68\x55\x03\x7f\x8a"
+ "\xe5\x94\x0c\x32\x5c\x07\x82\x63"
+ "\xaf\x6f\x91\x40\x84\x8e\x52\x25"
+ "\xd0\xb0\x29\x53\x05\xe2\x50\x7a"
+ "\x34\xeb\xc9\x46\x20\xa8\x3d\xde"
+ "\x7f\x16\x5f\x36\xc5\x2e\xdc\xd1"
+ "\x15\x47\xc7\x50\x40\x6d\x91\xc5"
+ "\xe7\x93\x95\x1a\xd3\x57\xbc\x52"
+ "\x33\xee\x14\x19\x22\x52\x89\xa7"
+ "\x4a\x25\x56\x77\x4b\xca\xcf\x0a"
+ "\xe1\xf5\x35\x85\x30\x7e\x59\x4a"
+ "\xbd\x14\x5b\xdf\xe3\x46\xcb\xac"
+ "\x1f\x6c\x96\x0e\xf4\x81\xd1\x99"
+ "\xca\x88\x63\x3d\x02\x58\x6b\xa9"
+ "\xe5\x9f\xb3\x00\xb2\x54\xc6\x74"
+ "\x1c\xbf\x46\xab\x97\xcc\xf8\x54"
+ "\x04\x07\x08\x52\xe6\xc0\xda\x93"
+ "\x74\x7d\x93\x99\x5d\x78\x68\xa6"
+ "\x2e\x6b\xd3\x6a\x69\xcc\x12\x6b"
+ "\xd4\xc7\xa5\xc6\xe7\xf6\x03\x04"
+ "\x5d\xcd\x61\x5e\x17\x40\xdc\xd1"
+ "\x5c\xf5\x08\xdf\x5c\x90\x85\xa4"
+ "\xaf\xf6\x78\xbb\x0d\xf1\xf4\xa4"
+ "\x54\x26\x72\x9e\x61\xfa\x86\xcf"
+ "\xe8\x9e\xa1\xe0\xc7\x48\x23\xae"
+ "\x5a\x90\xae\x75\x0a\x74\x18\x89"
+ "\x05\xb1\x92\xb2\x7f\xd0\x1b\xa6"
+ "\x62\x07\x25\x01\xc7\xc2\x4f\xf9"
+ "\xe8\xfe\x63\x95\x80\x07\xb4\x26"
+ "\xcc\xd1\x26\xb6\xc4\x3f\x9e\xcb"
+ "\x8e\x3b\x2e\x44\x16\xd3\x10\x9a"
+ "\x95\x08\xeb\xc8\xcb\xeb\xbf\x6f"
+ "\x0b\xcd\x1f\xc8\xca\x86\xaa\xec"
+ "\x33\xe6\x69\xf4\x45\x25\x86\x3a"
+ "\x22\x94\x4f\x00\x23\x6a\x44\xc2"
+ "\x49\x97\x33\xab\x36\x14\x0a\x70"
+ "\x24\xc3\xbe\x04\x3b\x79\xa0\xf9"
+ "\xb8\xe7\x76\x29\x22\x83\xd7\xf2"
+ "\x94\xf4\x41\x49\xba\x5f\x7b\x07"
+ "\xb5\xfb\xdb\x03\x1a\x9f\xb6\x4c"
+ "\xc2\x2e\x37\x40\x49\xc3\x38\x16"
+ "\xe2\x4f\x77\x82\xb0\x68\x4c\x71"
+ "\x1d\x57\x61\x9c\xd9\x4e\x54\x99"
+ "\x47\x13\x28\x73\x3c\xbb\x00\x90"
+ "\xf3\x4d\xc9\x0e\xfd\xe7\xb1\x71"
+ "\xd3\x15\x79\xbf\xcc\x26\x2f\xbd"
+ "\xad\x6c\x50\x69\x6c\x3e\x6d\x80"
+ "\x9a\xea\x78\xaf\x19\xb2\x0d\x4d"
+ "\xad\x04\x07\xae\x22\x90\x4a\x93"
+ "\x32\x0e\x36\x9b\x1b\x46\xba\x3b"
+ "\xb4\xac\xc6\xd1\xa2\x31\x53\x3b"
+ "\x2a\x3d\x45\xfe\x03\x61\x10\x85"
+ "\x17\x69\xa6\x78\xcc\x6c\x87\x49"
+ "\x53\xf9\x80\x10\xde\x80\xa2\x41"
+ "\x6a\xc3\x32\x02\xad\x6d\x3c\x56"
+ "\x00\x71\x51\x06\xa7\xbd\xfb\xef"
+ "\x3c\xb5\x9f\xfc\x48\x7d\x53\x7c"
+ "\x66\xb0\x49\x23\xc4\x47\x10\x0e"
+ "\xe5\x6c\x74\x13\xe6\xc5\x3f\xaa"
+ "\xde\xff\x07\x44\xdd\x56\x1b\xad"
+ "\x09\x77\xfb\x5b\x12\xb8\x0d\x38"
+ "\x17\x37\x35\x7b\x9b\xbc\xfe\xd4"
+ "\x7e\x8b\xda\x7e\x5b\x04\xa7\x22"
+ "\xa7\x31\xa1\x20\x86\xc7\x1b\x99"
+ "\xdb\xd1\x89\xf4\x94\xa3\x53\x69"
+ "\x8d\xe7\xe8\x74\x11\x8d\x74\xd6"
+ "\x07\x37\x91\x9f\xfd\x67\x50\x3a"
+ "\xc9\xe1\xf4\x36\xd5\xa0\x47\xd1"
+ "\xf9\xe5\x39\xa3\x31\xac\x07\x36"
+ "\x23\xf8\x66\x18\x14\x28\x34\x0f"
+ "\xb8\xd0\xe7\x29\xb3\x04\x4b\x55"
+ "\x01\x41\xb2\x75\x8d\xcb\x96\x85"
+ "\x3a\xfb\xab\x2b\x9e\xfa\x58\x20"
+ "\x44\x1f\xc0\x14\x22\x75\x61\xe8"
+ "\xaa\x19\xcf\xf1\x82\x56\xf4\xd7"
+ "\x78\x7b\x3d\x5f\xb3\x9e\x0b\x8a"
+ "\x57\x50\xdb\x17\x41\x65\x4d\xa3"
+ "\x02\xc9\x9c\x9c\x53\xfb\x39\x39"
+ "\x9b\x1d\x72\x24\xda\xb7\x39\xbe"
+ "\x13\x3b\xfa\x29\xda\x9e\x54\x64"
+ "\x6e\xba\xd8\xa1\xcb\xb3\x36\xfa"
+ "\xcb\x47\x85\xe9\x61\x38\xbc\xbe"
+ "\xc5\x00\x38\x2a\x54\xf7\xc4\xb9"
+ "\xb3\xd3\x7b\xa0\xa0\xf8\x72\x7f"
+ "\x8c\x8e\x82\x0e\xc6\x1c\x75\x9d"
+ "\xca\x8e\x61\x87\xde\xad\x80\xd2"
+ "\xf5\xf9\x80\xef\x15\x75\xaf\xf5"
+ "\x80\xfb\xff\x6d\x1e\x25\xb7\x40"
+ "\x61\x6a\x39\x5a\x6a\xb5\x31\xab"
+ "\x97\x8a\x19\x89\x44\x40\xc0\xa6"
+ "\xb4\x4e\x30\x32\x7b\x13\xe7\x67"
+ "\xa9\x8b\x57\x04\xc2\x01\xa6\xf4"
+ "\x28\x99\xad\x2c\x76\xa3\x78\xc2"
+ "\x4a\xe6\xca\x5c\x50\x6a\xc1\xb0"
+ "\x62\x4b\x10\x8e\x7c\x17\x43\xb3"
+ "\x17\x66\x1c\x3e\x8d\x69\xf0\x5a"
+ "\x71\xf5\x97\xdc\xd1\x45\xdd\x28"
+ "\xf3\x5d\xdf\x53\x7b\x11\xe5\xbc"
+ "\x4c\xdb\x1b\x51\x6b\xe9\xfb\x3d"
+ "\xc1\xc3\x2c\xb9\x71\xf5\xb6\xb2"
+ "\x13\x36\x79\x80\x53\xe8\xd3\xa6"
+ "\x0a\xaf\xfd\x56\x97\xf7\x40\x8e"
+ "\x45\xce\xf8\xb0\x9e\x5c\x33\x82"
+ "\xb0\x44\x56\xfc\x05\x09\xe9\x2a"
+ "\xac\x26\x80\x14\x1d\xc8\x3a\x35"
+ "\x4c\x82\x97\xfd\x76\xb7\xa9\x0a"
+ "\x35\x58\x79\x8e\x0f\x66\xea\xaf"
+ "\x51\x6c\x09\xa9\x6e\x9b\xcb\x9a"
+ "\x31\x47\xa0\x2f\x7c\x71\xb4\x4a"
+ "\x11\xaa\x8c\x66\xc5\x64\xe6\x3a"
+ "\x54\xda\x24\x6a\xc4\x41\x65\x46"
+ "\x82\xa0\x0a\x0f\x5f\xfb\x25\xd0"
+ "\x2c\x91\xa7\xee\xc4\x81\x07\x86"
+ "\x75\x5e\x33\x69\x97\xe4\x2c\xa8"
+ "\x9d\x9f\x0b\x6a\xbe\xad\x98\xda"
+ "\x6d\x94\x41\xda\x2c\x1e\x89\xc4"
+ "\xc2\xaf\x1e\x00\x05\x0b\x83\x60"
+ "\xbd\x43\xea\x15\x23\x7f\xb9\xac"
+ "\xee\x4f\x2c\xaf\x2a\xf3\xdf\xd0"
+ "\xf3\x19\x31\xbb\x4a\x74\x84\x17"
+ "\x52\x32\x2c\x7d\x61\xe4\xcb\xeb"
+ "\x80\x38\x15\x52\xcb\x6f\xea\xe5"
+ "\x73\x9c\xd9\x24\x69\xc6\x95\x32"
+ "\x21\xc8\x11\xe4\xdc\x36\xd7\x93"
+ "\x38\x66\xfb\xb2\x7f\x3a\xb9\xaf"
+ "\x31\xdd\x93\x75\x78\x8a\x2c\x94"
+ "\x87\x1a\x58\xec\x9e\x7d\x4d\xba"
+ "\xe1\xe5\x4d\xfc\xbc\xa4\x2a\x14"
+ "\xef\xcc\xa7\xec\xab\x43\x09\x18"
+ "\xd3\xab\x68\xd1\x07\x99\x44\x47"
+ "\xd6\x83\x85\x3b\x30\xea\xa9\x6b"
+ "\x63\xea\xc4\x07\xfb\x43\x2f\xa4"
+ "\xaa\xb0\xab\x03\x89\xce\x3f\x8c"
+ "\x02\x7c\x86\x54\xbc\x88\xaf\x75"
+ "\xd2\xdc\x63\x17\xd3\x26\xf6\x96"
+ "\xa9\x3c\xf1\x61\x8c\x11\x18\xcc"
+ "\xd6\xea\x5b\xe2\xcd\xf0\xf1\xb2"
+ "\xe5\x35\x90\x1f\x85\x4c\x76\x5b"
+ "\x66\xce\x44\xa4\x32\x9f\xe6\x7b"
+ "\x71\x6e\x9f\x58\x15\x67\x72\x87"
+ "\x64\x8e\x3a\x44\x45\xd4\x76\xfa"
+ "\xc2\xf6\xef\x85\x05\x18\x7a\x9b"
+ "\xba\x41\x54\xac\xf0\xfc\x59\x12"
+ "\x3f\xdf\xa0\xe5\x8a\x65\xfd\x3a"
+ "\x62\x8d\x83\x2c\x03\xbe\x05\x76"
+ "\x2e\x53\x49\x97\x94\x33\xae\x40"
+ "\x81\x15\xdb\x6e\xad\xaa\xf5\x4b"
+ "\xe3\x98\x70\xdf\xe0\x7c\xcd\xdb"
+ "\x02\xd4\x7d\x2f\xc1\xe6\xb4\xf3"
+ "\xd7\x0d\x7a\xd9\x23\x9e\x87\x2d"
+ "\xce\x87\xad\xcc\x72\x05\x00\x29"
+ "\xdc\x73\x7f\x64\xc1\x15\x0e\xc2"
+ "\xdf\xa7\x5f\xeb\x41\xa1\xcd\xef"
+ "\x5c\x50\x79\x2a\x56\x56\x71\x8c"
+ "\xac\xc0\x79\x50\x69\xca\x59\x32"
+ "\x65\xf2\x54\xe4\x52\x38\x76\xd1"
+ "\x5e\xde\x26\x9e\xfb\x75\x2e\x11"
+ "\xb5\x10\xf4\x17\x73\xf5\x89\xc7"
+ "\x4f\x43\x5c\x8e\x7c\xb9\x05\x52"
+ "\x24\x40\x99\xfe\x9b\x85\x0b\x6c"
+ "\x22\x3e\x8b\xae\x86\xa1\xd2\x79"
+ "\x05\x68\x6b\xab\xe3\x41\x49\xed"
+ "\x15\xa1\x8d\x40\x2d\x61\xdf\x1a"
+ "\x59\xc9\x26\x8b\xef\x30\x4c\x88"
+ "\x4b\x10\xf8\x8d\xa6\x92\x9f\x4b"
+ "\xf3\xc4\x53\x0b\x89\x5d\x28\x92"
+ "\xcf\x78\xb2\xc0\x5d\xed\x7e\xfc"
+ "\xc0\x12\x23\x5f\x5a\x78\x86\x43"
+ "\x6e\x27\xf7\x5a\xa7\x6a\xed\x19"
+ "\x04\xf0\xb3\x12\xd1\xbd\x0e\x89"
+ "\x6e\xbc\x96\xa8\xd8\x49\x39\x9f"
+ "\x7e\x67\xf0\x2e\x3e\x01\xa9\xba"
+ "\xec\x8b\x62\x8e\xcb\x4a\x70\x43"
+ "\xc7\xc2\xc4\xca\x82\x03\x73\xe9"
+ "\x11\xdf\xcf\x54\xea\xc9\xb0\x95"
+ "\x51\xc0\x13\x3d\x92\x05\xfa\xf4"
+ "\xa9\x34\xc8\xce\x6c\x3d\x54\xcc"
+ "\xc4\xaf\xf1\xdc\x11\x44\x26\xa2"
+ "\xaf\xf1\x85\x75\x7d\x03\x61\x68"
+ "\x4e\x78\xc6\x92\x7d\x86\x7d\x77"
+ "\xdc\x71\x72\xdb\xc6\xae\xa1\xcb"
+ "\x70\x9a\x0b\x19\xbe\x4a\x6c\x2a"
+ "\xe2\xba\x6c\x64\x9a\x13\x28\xdf"
+ "\x85\x75\xe6\x43\xf6\x87\x08\x68"
+ "\x6e\xba\x6e\x79\x9f\x04\xbc\x23"
+ "\x50\xf6\x33\x5c\x1f\x24\x25\xbe"
+ "\x33\x47\x80\x45\x56\xa3\xa7\xd7"
+ "\x7a\xb1\x34\x0b\x90\x3c\x9c\xad"
+ "\x44\x5f\x9e\x0e\x9d\xd4\xbd\x93"
+ "\x5e\xfa\x3c\xe0\xb0\xd9\xed\xf3"
+ "\xd6\x2e\xff\x24\xd8\x71\x6c\xed"
+ "\xaf\x55\xeb\x22\xac\x93\x68\x32"
+ "\x05\x5b\x47\xdd\xc6\x4a\xcb\xc7"
+ "\x10\xe1\x3c\x92\x1a\xf3\x23\x78"
+ "\x2b\xa1\xd2\x80\xf4\x12\xb1\x20"
+ "\x8f\xff\x26\x35\xdd\xfb\xc7\x4e"
+ "\x78\xf1\x2d\x50\x12\x77\xa8\x60"
+ "\x7c\x0f\xf5\x16\x2f\x63\x70\x2a"
+ "\xc0\x96\x80\x4e\x0a\xb4\x93\x35"
+ "\x5d\x1d\x3f\x56\xf7\x2f\xbb\x90"
+ "\x11\x16\x8f\xa2\xec\x47\xbe\xac"
+ "\x56\x01\x26\x56\xb1\x8c\xb2\x10"
+ "\xf9\x1a\xca\xf5\xd1\xb7\x39\x20"
+ "\x63\xf1\x69\x20\x4f\x13\x12\x1f"
+ "\x5b\x65\xfc\x98\xf7\xc4\x7a\xbe"
+ "\xf7\x26\x4d\x2b\x84\x7b\x42\xad"
+ "\xd8\x7a\x0a\xb4\xd8\x74\xbf\xc1"
+ "\xf0\x6e\xb4\x29\xa3\xbb\xca\x46"
+ "\x67\x70\x6a\x2d\xce\x0e\xa2\x8a"
+ "\xa9\x87\xbf\x05\xc4\xc1\x04\xa3"
+ "\xab\xd4\x45\x43\x8c\xb6\x02\xb0"
+ "\x41\xc8\xfc\x44\x3d\x59\xaa\x2e"
+ "\x44\x21\x2a\x8d\x88\x9d\x57\xf4"
+ "\xa0\x02\x77\xb8\xa6\xa0\xe6\x75"
+ "\x5c\x82\x65\x3e\x03\x5c\x29\x8f"
+ "\x38\x55\xab\x33\x26\xef\x9f\x43"
+ "\x52\xfd\x68\xaf\x36\xb4\xbb\x9a"
+ "\x58\x09\x09\x1b\xc3\x65\x46\x46"
+ "\x1d\xa7\x94\x18\x23\x50\x2c\xca"
+ "\x2c\x55\x19\x97\x01\x9d\x93\x3b"
+ "\x63\x86\xf2\x03\x67\x45\xd2\x72"
+ "\x28\x52\x6c\xf4\xe3\x1c\xb5\x11"
+ "\x13\xf1\xeb\x21\xc7\xd9\x56\x82"
+ "\x2b\x82\x39\xbd\x69\x54\xed\x62"
+ "\xc3\xe2\xde\x73\xd4\x6a\x12\xae"
+ "\x13\x21\x7f\x4b\x5b\xfc\xbf\xe8"
+ "\x2b\xbe\x56\xba\x68\x8b\x9a\xb1"
+ "\x6e\xfa\xbf\x7e\x5a\x4b\xf1\xac"
+ "\x98\x65\x85\xd1\x93\x53\xd3\x7b"
+ "\x09\xdd\x4b\x10\x6d\x84\xb0\x13"
+ "\x65\xbd\xcf\x52\x09\xc4\x85\xe2"
+ "\x84\x74\x15\x65\xb7\xf7\x51\xaf"
+ "\x55\xad\xa4\xd1\x22\x54\x70\x94"
+ "\xa0\x1c\x90\x41\xfd\x99\xd7\x5a"
+ "\x31\xef\xaa\x25\xd0\x7f\x4f\xea"
+ "\x1d\x55\x42\xe5\x49\xb0\xd0\x46"
+ "\x62\x36\x43\xb2\x82\x15\x75\x50"
+ "\xa4\x72\xeb\x54\x27\x1f\x8a\xe4"
+ "\x7d\xe9\x66\xc5\xf1\x53\xa4\xd1"
+ "\x0c\xeb\xb8\xf8\xbc\xd4\xe2\xe7"
+ "\xe1\xf8\x4b\xcb\xa9\xa1\xaf\x15"
+ "\x83\xcb\x72\xd0\x33\x79\x00\x2d"
+ "\x9f\xd7\xf1\x2e\x1e\x10\xe4\x45"
+ "\xc0\x75\x3a\x39\xea\x68\xf7\x5d"
+ "\x1b\x73\x8f\xe9\x8e\x0f\x72\x47"
+ "\xae\x35\x0a\x31\x7a\x14\x4d\x4a"
+ "\x6f\x47\xf7\x7e\x91\x6e\x74\x8b"
+ "\x26\x47\xf9\xc3\xf9\xde\x70\xf5"
+ "\x61\xab\xa9\x27\x9f\x82\xe4\x9c"
+ "\x89\x91\x3f\x2e\x6a\xfd\xb5\x49"
+ "\xe9\xfd\x59\x14\x36\x49\x40\x6d"
+ "\x32\xd8\x85\x42\xf3\xa5\xdf\x0c"
+ "\xa8\x27\xd7\x54\xe2\x63\x2f\xf2"
+ "\x7e\x8b\x8b\xe7\xf1\x9a\x95\x35"
+ "\x43\xdc\x3a\xe4\xb6\xf4\xd0\xdf"
+ "\x9c\xcb\x94\xf3\x21\xa0\x77\x50"
+ "\xe2\xc6\xc4\xc6\x5f\x09\x64\x5b"
+ "\x92\x90\xd8\xe1\xd1\xed\x4b\x42"
+ "\xd7\x37\xaf\x65\x3d\x11\x39\xb6"
+ "\x24\x8a\x60\xae\xd6\x1e\xbf\x0e"
+ "\x0d\xd7\xdc\x96\x0e\x65\x75\x4e"
+ "\x29\x06\x9d\xa4\x51\x3a\x10\x63"
+ "\x8f\x17\x07\xd5\x8e\x3c\xf4\x28"
+ "\x00\x5a\x5b\x05\x19\xd8\xc0\x6c"
+ "\xe5\x15\xe4\x9c\x9d\x71\x9d\x5e"
+ "\x94\x29\x1a\xa7\x80\xfa\x0e\x33"
+ "\x03\xdd\xb7\x3e\x9a\xa9\x26\x18"
+ "\x37\xa9\x64\x08\x4d\x94\x5a\x88"
+ "\xca\x35\xce\x81\x02\xe3\x1f\x1b"
+ "\x89\x1a\x77\x85\xe3\x41\x6d\x32"
+ "\x42\x19\x23\x7d\xc8\x73\xee\x25"
+ "\x85\x0d\xf8\x31\x25\x79\x1b\x6f"
+ "\x79\x25\xd2\xd8\xd4\x23\xfd\xf7"
+ "\x82\x36\x6a\x0c\x46\x22\x15\xe9"
+ "\xff\x72\x41\x91\x91\x7d\x3a\xb7"
+ "\xdd\x65\x99\x70\xf6\x8d\x84\xf8"
+ "\x67\x15\x20\x11\xd6\xb2\x55\x7b"
+ "\xdb\x87\xee\xef\x55\x89\x2a\x59"
+ "\x2b\x07\x8f\x43\x8a\x59\x3c\x01"
+ "\x8b\x65\x54\xa1\x66\xd5\x38\xbd"
+ "\xc6\x30\xa9\xcc\x49\xb6\xa8\x1b"
+ "\xb8\xc0\x0e\xe3\x45\x28\xe2\xff"
+ "\x41\x9f\x7e\x7c\xd1\xae\x9e\x25"
+ "\x3f\x4c\x7c\x7c\xf4\xa8\x26\x4d"
+ "\x5c\xfd\x4b\x27\x18\xf9\x61\x76"
+ "\x48\xba\x0c\x6b\xa9\x4d\xfc\xf5"
+ "\x3b\x35\x7e\x2f\x4a\xa9\xc2\x9a"
+ "\xae\xab\x86\x09\x89\xc9\xc2\x40"
+ "\x39\x2c\x81\xb3\xb8\x17\x67\xc2"
+ "\x0d\x32\x4a\x3a\x67\x81\xd7\x1a"
+ "\x34\x52\xc5\xdb\x0a\xf5\x63\x39"
+ "\xea\x1f\xe1\x7c\xa1\x9e\xc1\x35"
+ "\xe3\xb1\x18\x45\x67\xf9\x22\x38"
+ "\x95\xd9\x34\x34\x86\xc6\x41\x94"
+ "\x15\xf9\x5b\x41\xa6\x87\x8b\xf8"
+ "\xd5\xe1\x1b\xe2\x5b\xf3\x86\x10"
+ "\xff\xe6\xae\x69\x76\xbc\x0d\xb4"
+ "\x09\x90\x0c\xa2\x65\x0c\xad\x74"
+ "\xf5\xd7\xff\xda\xc1\xce\x85\xbe"
+ "\x00\xa7\xff\x4d\x2f\x65\xd3\x8c"
+ "\x86\x2d\x05\xe8\xed\x3e\x6b\x8b"
+ "\x0f\x3d\x83\x8c\xf1\x1d\x5b\x96"
+ "\x2e\xb1\x9c\xc2\x98\xe1\x70\xb9"
+ "\xba\x5c\x8a\x43\xd6\x34\xa7\x2d"
+ "\xc9\x92\xae\xf2\xa5\x7b\x05\x49"
+ "\xa7\x33\x34\x86\xca\xe4\x96\x23"
+ "\x76\x5b\xf2\xc6\xf1\x51\x28\x42"
+ "\x7b\xcc\x76\x8f\xfa\xa2\xad\x31"
+ "\xd4\xd6\x7a\x6d\x25\x25\x54\xe4"
+ "\x3f\x50\x59\xe1\x5c\x05\xb7\x27"
+ "\x48\xbf\x07\xec\x1b\x13\xbe\x2b"
+ "\xa1\x57\x2b\xd5\xab\xd7\xd0\x4c"
+ "\x1e\xcb\x71\x9b\xc5\x90\x85\xd3"
+ "\xde\x59\xec\x71\xeb\x89\xbb\xd0"
+ "\x09\x50\xe1\x16\x3f\xfd\x1c\x34"
+ "\xc3\x1c\xa1\x10\x77\x53\x98\xef"
+ "\xf2\xfd\xa5\x01\x59\xc2\x9b\x26"
+ "\xc7\x42\xd9\x49\xda\x58\x2b\x6e"
+ "\x9f\x53\x19\x76\x7e\xd9\xc9\x0e"
+ "\x68\xc8\x7f\x51\x22\x42\xef\x49"
+ "\xa4\x55\xb6\x36\xac\x09\xc7\x31"
+ "\x88\x15\x4b\x2e\x8f\x3a\x08\xf7"
+ "\xd8\xf7\xa8\xc5\xa9\x33\xa6\x45"
+ "\xe4\xc4\x94\x76\xf3\x0d\x8f\x7e"
+ "\xc8\xf6\xbc\x23\x0a\xb6\x4c\xd3"
+ "\x6a\xcd\x36\xc2\x90\x5c\x5c\x3c"
+ "\x65\x7b\xc2\xd6\xcc\xe6\x0d\x87"
+ "\x73\x2e\x71\x79\x16\x06\x63\x28"
+ "\x09\x15\xd8\x89\x38\x38\x3d\xb5"
+ "\x42\x1c\x08\x24\xf7\x2a\xd2\x9d"
+ "\xc8\xca\xef\xf9\x27\xd8\x07\x86"
+ "\xf7\x43\x0b\x55\x15\x3f\x9f\x83"
+ "\xef\xdc\x49\x9d\x2a\xc1\x54\x62"
+ "\xbd\x9b\x66\x55\x9f\xb7\x12\xf3"
+ "\x1b\x4d\x9d\x2a\x5c\xed\x87\x75"
+ "\x87\x26\xec\x61\x2c\xb4\x0f\x89"
+ "\xb0\xfb\x2e\x68\x5d\x15\xc7\x8d"
+ "\x2e\xc0\xd9\xec\xaf\x4f\xd2\x25"
+ "\x29\xe8\xd2\x26\x2b\x67\xe9\xfc"
+ "\x2b\xa8\x67\x96\x12\x1f\x5b\x96"
+ "\xc6\x14\x53\xaf\x44\xea\xd6\xe2"
+ "\x94\x98\xe4\x12\x93\x4c\x92\xe0"
+ "\x18\xa5\x8d\x2d\xe4\x71\x3c\x47"
+ "\x4c\xf7\xe6\x47\x9e\xc0\x68\xdf"
+ "\xd4\xf5\x5a\x74\xb1\x2b\x29\x03"
+ "\x19\x07\xaf\x90\x62\x5c\x68\x98"
+ "\x48\x16\x11\x02\x9d\xee\xb4\x9b"
+ "\xe5\x42\x7f\x08\xfd\x16\x32\x0b"
+ "\xd0\xb3\xfa\x2b\xb7\x99\xf9\x29"
+ "\xcd\x20\x45\x9f\xb3\x1a\x5d\xa2"
+ "\xaf\x4d\xe0\xbd\x42\x0d\xbc\x74"
+ "\x99\x9c\x8e\x53\x1a\xb4\x3e\xbd"
+ "\xa2\x9a\x2d\xf7\xf8\x39\x0f\x67"
+ "\x63\xfc\x6b\xc0\xaf\xb3\x4b\x4f"
+ "\x55\xc4\xcf\xa7\xc8\x04\x11\x3e"
+ "\x14\x32\xbb\x1b\x38\x77\xd6\x7f"
+ "\x54\x4c\xdf\x75\xf3\x07\x2d\x33"
+ "\x9b\xa8\x20\xe1\x7b\x12\xb5\xf3"
+ "\xef\x2f\xce\x72\xe5\x24\x60\xc1"
+ "\x30\xe2\xab\xa1\x8e\x11\x09\xa8"
+ "\x21\x33\x44\xfe\x7f\x35\x32\x93"
+ "\x39\xa7\xad\x8b\x79\x06\xb2\xcb"
+ "\x4e\xa9\x5f\xc7\xba\x74\x29\xec"
+ "\x93\xa0\x4e\x54\x93\xc0\xbc\x55"
+ "\x64\xf0\x48\xe5\x57\x99\xee\x75"
+ "\xd6\x79\x0f\x66\xb7\xc6\x57\x76"
+ "\xf7\xb7\xf3\x9c\xc5\x60\xe8\x7f"
+ "\x83\x76\xd6\x0e\xaa\xe6\x90\x39"
+ "\x1d\xa6\x32\x6a\x34\xe3\x55\xf8"
+ "\x58\xa0\x58\x7d\x33\xe0\x22\x39"
+ "\x44\x64\x87\x86\x5a\x2f\xa7\x7e"
+ "\x0f\x38\xea\xb0\x30\xcc\x61\xa5"
+ "\x6a\x32\xae\x1e\xf7\xe9\xd0\xa9"
+ "\x0c\x32\x4b\xb5\x49\x28\xab\x85"
+ "\x2f\x8e\x01\x36\x38\x52\xd0\xba"
+ "\xd6\x02\x78\xf8\x0e\x3e\x9c\x8b"
+ "\x6b\x45\x99\x3f\x5c\xfe\x58\xf1"
+ "\x5c\x94\x04\xe1\xf5\x18\x6d\x51"
+ "\xb2\x5d\x18\x20\xb6\xc2\x9a\x42"
+ "\x1d\xb3\xab\x3c\xb6\x3a\x13\x03"
+ "\xb2\x46\x82\x4f\xfc\x64\xbc\x4f"
+ "\xca\xfa\x9c\xc0\xd5\xa7\xbd\x11"
+ "\xb7\xe4\x5a\xf6\x6f\x4d\x4d\x54"
+ "\xea\xa4\x98\x66\xd4\x22\x3b\xd3"
+ "\x8f\x34\x47\xd9\x7c\xf4\x72\x3b"
+ "\x4d\x02\x77\xf6\xd6\xdd\x08\x0a"
+ "\x81\xe1\x86\x89\x3e\x56\x10\x3c"
+ "\xba\xd7\x81\x8c\x08\xbc\x8b\xe2"
+ "\x53\xec\xa7\x89\xee\xc8\x56\xb5"
+ "\x36\x2c\xb2\x03\xba\x99\xdd\x7c"
+ "\x48\xa0\xb0\xbc\x91\x33\xe9\xa8"
+ "\xcb\xcd\xcf\x59\x5f\x1f\x15\xe2"
+ "\x56\xf5\x4e\x01\x35\x27\x45\x77"
+ "\x47\xc8\xbc\xcb\x7e\x39\xc1\x97"
+ "\x28\xd3\x84\xfc\x2c\x3e\xc8\xad"
+ "\x9c\xf8\x8a\x61\x9c\x28\xaa\xc5"
+ "\x99\x20\x43\x85\x9d\xa5\xe2\x8b"
+ "\xb8\xae\xeb\xd0\x32\x0d\x52\x78"
+ "\x09\x56\x3f\xc7\xd8\x7e\x26\xfc"
+ "\x37\xfb\x6f\x04\xfc\xfa\x92\x10"
+ "\xac\xf8\x3e\x21\xdc\x8c\x21\x16"
+ "\x7d\x67\x6e\xf6\xcd\xda\xb6\x98"
+ "\x23\xab\x23\x3c\xb2\x10\xa0\x53"
+ "\x5a\x56\x9f\xc5\xd0\xff\xbb\xe4"
+ "\x98\x3c\x69\x1e\xdb\x38\x8f\x7e"
+ "\x0f\xd2\x98\x88\x81\x8b\x45\x67"
+ "\xea\x33\xf1\xeb\xe9\x97\x55\x2e"
+ "\xd9\xaa\xeb\x5a\xec\xda\xe1\x68"
+ "\xa8\x9d\x3c\x84\x7c\x05\x3d\x62"
+ "\x87\x8f\x03\x21\x28\x95\x0c\x89"
+ "\x25\x22\x4a\xb0\x93\xa9\x50\xa2"
+ "\x2f\x57\x6e\x18\x42\x19\x54\x0c"
+ "\x55\x67\xc6\x11\x49\xf4\x5c\xd2"
+ "\xe9\x3d\xdd\x8b\x48\x71\x21\x00"
+ "\xc3\x9a\x6c\x85\x74\x28\x83\x4a"
+ "\x1b\x31\x05\xe1\x06\x92\xe7\xda"
+ "\x85\x73\x78\x45\x20\x7f\xae\x13"
+ "\x7c\x33\x06\x22\xf4\x83\xf9\x35"
+ "\x3f\x6c\x71\xa8\x4e\x48\xbe\x9b"
+ "\xce\x8a\xba\xda\xbe\x28\x08\xf7"
+ "\xe2\x14\x8c\x71\xea\x72\xf9\x33"
+ "\xf2\x88\x3f\xd7\xbb\x69\x6c\x29"
+ "\x19\xdc\x84\xce\x1f\x12\x4f\xc8"
+ "\xaf\xa5\x04\xba\x5a\xab\xb0\xd9"
+ "\x14\x1f\x6c\x68\x98\x39\x89\x7a"
+ "\xd9\xd8\x2f\xdf\xa8\x47\x4a\x25"
+ "\xe2\xfb\x33\xf4\x59\x78\xe1\x68"
+ "\x85\xcf\xfe\x59\x20\xd4\x05\x1d"
+ "\x80\x99\xae\xbc\xca\xae\x0f\x2f"
+ "\x65\x43\x34\x8e\x7e\xac\xd3\x93"
+ "\x2f\xac\x6d\x14\x3d\x02\x07\x70"
+ "\x9d\xa4\xf3\x1b\x5c\x36\xfc\x01"
+ "\x73\x34\x85\x0c\x6c\xd6\xf1\xbd"
+ "\x3f\xdf\xee\xf5\xd9\xba\x56\xef"
+ "\xf4\x9b\x6b\xee\x9f\x5a\x78\x6d"
+ "\x32\x19\xf4\xf7\xf8\x4c\x69\x0b"
+ "\x4b\xbc\xbb\xb7\xf2\x85\xaf\x70"
+ "\x75\x24\x6c\x54\xa7\x0e\x4d\x1d"
+ "\x01\xbf\x08\xac\xcf\x7f\x2c\xe3"
+ "\x14\x89\x5e\x70\x5a\x99\x92\xcd"
+ "\x01\x84\xc8\xd2\xab\xe5\x4f\x58"
+ "\xe7\x0f\x2f\x0e\xff\x68\xea\xfd"
+ "\x15\xb3\x17\xe6\xb0\xe7\x85\xd8"
+ "\x23\x2e\x05\xc7\xc9\xc4\x46\x1f"
+ "\xe1\x9e\x49\x20\x23\x24\x4d\x7e"
+ "\x29\x65\xff\xf4\xb6\xfd\x1a\x85"
+ "\xc4\x16\xec\xfc\xea\x7b\xd6\x2c"
+ "\x43\xf8\xb7\xbf\x79\xc0\x85\xcd"
+ "\xef\xe1\x98\xd3\xa5\xf7\x90\x8c"
+ "\xe9\x7f\x80\x6b\xd2\xac\x4c\x30"
+ "\xa7\xc6\x61\x6c\xd2\xf9\x2c\xff"
+ "\x30\xbc\x22\x81\x7d\x93\x12\xe4"
+ "\x0a\xcd\xaf\xdd\xe8\xab\x0a\x1e"
+ "\x13\xa4\x27\xc3\x5f\xf7\x4b\xbb"
+ "\x37\x09\x4b\x91\x6f\x92\x4f\xaf"
+ "\x52\xee\xdf\xef\x09\x6f\xf7\x5c"
+ "\x6e\x12\x17\x72\x63\x57\xc7\xba"
+ "\x3b\x6b\x38\x32\x73\x1b\x9c\x80"
+ "\xc1\x7a\xc6\xcf\xcd\x35\xc0\x6b"
+ "\x31\x1a\x6b\xe9\xd8\x2c\x29\x3f"
+ "\x96\xfb\xb6\xcd\x13\x91\x3b\xc2"
+ "\xd2\xa3\x31\x8d\xa4\xcd\x57\xcd"
+ "\x13\x3d\x64\xfd\x06\xce\xe6\xdc"
+ "\x0c\x24\x43\x31\x40\x57\xf1\x72"
+ "\x17\xe3\x3a\x63\x6d\x35\xcf\x5d"
+ "\x97\x40\x59\xdd\xf7\x3c\x02\xf7"
+ "\x1c\x7e\x05\xbb\xa9\x0d\x01\xb1"
+ "\x8e\xc0\x30\xa9\x53\x24\xc9\x89"
+ "\x84\x6d\xaa\xd0\xcd\x91\xc2\x4d"
+ "\x91\xb0\x89\xe2\xbf\x83\x44\xaa"
+ "\x28\x72\x23\xa0\xc2\xad\xad\x1c"
+ "\xfc\x3f\x09\x7a\x0b\xdc\xc5\x1b"
+ "\x87\x13\xc6\x5b\x59\x8d\xf2\xc8"
+ "\xaf\xdf\x11\x95",
+ .rlen = 4100,
+ .np = 2,
+ .tap = { 4064, 36 },
+ },
+};
+
+/*
+ * CTS (Cipher Text Stealing) mode tests
+ */
+#define CTS_MODE_ENC_TEST_VECTORS 6
+#define CTS_MODE_DEC_TEST_VECTORS 6
+static struct cipher_testvec cts_mode_enc_tv_template[] = {
+ { /* from rfc3962 */
+ .klen = 16,
+ .key = "\x63\x68\x69\x63\x6b\x65\x6e\x20"
+ "\x74\x65\x72\x69\x79\x61\x6b\x69",
+ .ilen = 17,
+ .input = "\x49\x20\x77\x6f\x75\x6c\x64\x20"
+ "\x6c\x69\x6b\x65\x20\x74\x68\x65"
+ "\x20",
+ .rlen = 17,
+ .result = "\xc6\x35\x35\x68\xf2\xbf\x8c\xb4"
+ "\xd8\xa5\x80\x36\x2d\xa7\xff\x7f"
+ "\x97",
+ }, {
+ .klen = 16,
+ .key = "\x63\x68\x69\x63\x6b\x65\x6e\x20"
+ "\x74\x65\x72\x69\x79\x61\x6b\x69",
+ .ilen = 31,
+ .input = "\x49\x20\x77\x6f\x75\x6c\x64\x20"
+ "\x6c\x69\x6b\x65\x20\x74\x68\x65"
+ "\x20\x47\x65\x6e\x65\x72\x61\x6c"
+ "\x20\x47\x61\x75\x27\x73\x20",
+ .rlen = 31,
+ .result = "\xfc\x00\x78\x3e\x0e\xfd\xb2\xc1"
+ "\xd4\x45\xd4\xc8\xef\xf7\xed\x22"
+ "\x97\x68\x72\x68\xd6\xec\xcc\xc0"
+ "\xc0\x7b\x25\xe2\x5e\xcf\xe5",
+ }, {
+ .klen = 16,
+ .key = "\x63\x68\x69\x63\x6b\x65\x6e\x20"
+ "\x74\x65\x72\x69\x79\x61\x6b\x69",
+ .ilen = 32,
+ .input = "\x49\x20\x77\x6f\x75\x6c\x64\x20"
+ "\x6c\x69\x6b\x65\x20\x74\x68\x65"
+ "\x20\x47\x65\x6e\x65\x72\x61\x6c"
+ "\x20\x47\x61\x75\x27\x73\x20\x43",
+ .rlen = 32,
+ .result = "\x39\x31\x25\x23\xa7\x86\x62\xd5"
+ "\xbe\x7f\xcb\xcc\x98\xeb\xf5\xa8"
+ "\x97\x68\x72\x68\xd6\xec\xcc\xc0"
+ "\xc0\x7b\x25\xe2\x5e\xcf\xe5\x84",
+ }, {
+ .klen = 16,
+ .key = "\x63\x68\x69\x63\x6b\x65\x6e\x20"
+ "\x74\x65\x72\x69\x79\x61\x6b\x69",
+ .ilen = 47,
+ .input = "\x49\x20\x77\x6f\x75\x6c\x64\x20"
+ "\x6c\x69\x6b\x65\x20\x74\x68\x65"
+ "\x20\x47\x65\x6e\x65\x72\x61\x6c"
+ "\x20\x47\x61\x75\x27\x73\x20\x43"
+ "\x68\x69\x63\x6b\x65\x6e\x2c\x20"
+ "\x70\x6c\x65\x61\x73\x65\x2c",
+ .rlen = 47,
+ .result = "\x97\x68\x72\x68\xd6\xec\xcc\xc0"
+ "\xc0\x7b\x25\xe2\x5e\xcf\xe5\x84"
+ "\xb3\xff\xfd\x94\x0c\x16\xa1\x8c"
+ "\x1b\x55\x49\xd2\xf8\x38\x02\x9e"
+ "\x39\x31\x25\x23\xa7\x86\x62\xd5"
+ "\xbe\x7f\xcb\xcc\x98\xeb\xf5",
+ }, {
+ .klen = 16,
+ .key = "\x63\x68\x69\x63\x6b\x65\x6e\x20"
+ "\x74\x65\x72\x69\x79\x61\x6b\x69",
+ .ilen = 48,
+ .input = "\x49\x20\x77\x6f\x75\x6c\x64\x20"
+ "\x6c\x69\x6b\x65\x20\x74\x68\x65"
+ "\x20\x47\x65\x6e\x65\x72\x61\x6c"
+ "\x20\x47\x61\x75\x27\x73\x20\x43"
+ "\x68\x69\x63\x6b\x65\x6e\x2c\x20"
+ "\x70\x6c\x65\x61\x73\x65\x2c\x20",
+ .rlen = 48,
+ .result = "\x97\x68\x72\x68\xd6\xec\xcc\xc0"
+ "\xc0\x7b\x25\xe2\x5e\xcf\xe5\x84"
+ "\x9d\xad\x8b\xbb\x96\xc4\xcd\xc0"
+ "\x3b\xc1\x03\xe1\xa1\x94\xbb\xd8"
+ "\x39\x31\x25\x23\xa7\x86\x62\xd5"
+ "\xbe\x7f\xcb\xcc\x98\xeb\xf5\xa8",
+ }, {
+ .klen = 16,
+ .key = "\x63\x68\x69\x63\x6b\x65\x6e\x20"
+ "\x74\x65\x72\x69\x79\x61\x6b\x69",
+ .ilen = 64,
+ .input = "\x49\x20\x77\x6f\x75\x6c\x64\x20"
+ "\x6c\x69\x6b\x65\x20\x74\x68\x65"
+ "\x20\x47\x65\x6e\x65\x72\x61\x6c"
+ "\x20\x47\x61\x75\x27\x73\x20\x43"
+ "\x68\x69\x63\x6b\x65\x6e\x2c\x20"
+ "\x70\x6c\x65\x61\x73\x65\x2c\x20"
+ "\x61\x6e\x64\x20\x77\x6f\x6e\x74"
+ "\x6f\x6e\x20\x73\x6f\x75\x70\x2e",
+ .rlen = 64,
+ .result = "\x97\x68\x72\x68\xd6\xec\xcc\xc0"
+ "\xc0\x7b\x25\xe2\x5e\xcf\xe5\x84"
+ "\x39\x31\x25\x23\xa7\x86\x62\xd5"
+ "\xbe\x7f\xcb\xcc\x98\xeb\xf5\xa8"
+ "\x48\x07\xef\xe8\x36\xee\x89\xa5"
+ "\x26\x73\x0d\xbc\x2f\x7b\xc8\x40"
+ "\x9d\xad\x8b\xbb\x96\xc4\xcd\xc0"
+ "\x3b\xc1\x03\xe1\xa1\x94\xbb\xd8",
+ }
+};
+
+static struct cipher_testvec cts_mode_dec_tv_template[] = {
+ { /* from rfc3962 */
+ .klen = 16,
+ .key = "\x63\x68\x69\x63\x6b\x65\x6e\x20"
+ "\x74\x65\x72\x69\x79\x61\x6b\x69",
+ .rlen = 17,
+ .result = "\x49\x20\x77\x6f\x75\x6c\x64\x20"
+ "\x6c\x69\x6b\x65\x20\x74\x68\x65"
+ "\x20",
+ .ilen = 17,
+ .input = "\xc6\x35\x35\x68\xf2\xbf\x8c\xb4"
+ "\xd8\xa5\x80\x36\x2d\xa7\xff\x7f"
+ "\x97",
+ }, {
+ .klen = 16,
+ .key = "\x63\x68\x69\x63\x6b\x65\x6e\x20"
+ "\x74\x65\x72\x69\x79\x61\x6b\x69",
+ .rlen = 31,
+ .result = "\x49\x20\x77\x6f\x75\x6c\x64\x20"
+ "\x6c\x69\x6b\x65\x20\x74\x68\x65"
+ "\x20\x47\x65\x6e\x65\x72\x61\x6c"
+ "\x20\x47\x61\x75\x27\x73\x20",
+ .ilen = 31,
+ .input = "\xfc\x00\x78\x3e\x0e\xfd\xb2\xc1"
+ "\xd4\x45\xd4\xc8\xef\xf7\xed\x22"
+ "\x97\x68\x72\x68\xd6\xec\xcc\xc0"
+ "\xc0\x7b\x25\xe2\x5e\xcf\xe5",
+ }, {
+ .klen = 16,
+ .key = "\x63\x68\x69\x63\x6b\x65\x6e\x20"
+ "\x74\x65\x72\x69\x79\x61\x6b\x69",
+ .rlen = 32,
+ .result = "\x49\x20\x77\x6f\x75\x6c\x64\x20"
+ "\x6c\x69\x6b\x65\x20\x74\x68\x65"
+ "\x20\x47\x65\x6e\x65\x72\x61\x6c"
+ "\x20\x47\x61\x75\x27\x73\x20\x43",
+ .ilen = 32,
+ .input = "\x39\x31\x25\x23\xa7\x86\x62\xd5"
+ "\xbe\x7f\xcb\xcc\x98\xeb\xf5\xa8"
+ "\x97\x68\x72\x68\xd6\xec\xcc\xc0"
+ "\xc0\x7b\x25\xe2\x5e\xcf\xe5\x84",
+ }, {
+ .klen = 16,
+ .key = "\x63\x68\x69\x63\x6b\x65\x6e\x20"
+ "\x74\x65\x72\x69\x79\x61\x6b\x69",
+ .rlen = 47,
+ .result = "\x49\x20\x77\x6f\x75\x6c\x64\x20"
+ "\x6c\x69\x6b\x65\x20\x74\x68\x65"
+ "\x20\x47\x65\x6e\x65\x72\x61\x6c"
+ "\x20\x47\x61\x75\x27\x73\x20\x43"
+ "\x68\x69\x63\x6b\x65\x6e\x2c\x20"
+ "\x70\x6c\x65\x61\x73\x65\x2c",
+ .ilen = 47,
+ .input = "\x97\x68\x72\x68\xd6\xec\xcc\xc0"
+ "\xc0\x7b\x25\xe2\x5e\xcf\xe5\x84"
+ "\xb3\xff\xfd\x94\x0c\x16\xa1\x8c"
+ "\x1b\x55\x49\xd2\xf8\x38\x02\x9e"
+ "\x39\x31\x25\x23\xa7\x86\x62\xd5"
+ "\xbe\x7f\xcb\xcc\x98\xeb\xf5",
+ }, {
+ .klen = 16,
+ .key = "\x63\x68\x69\x63\x6b\x65\x6e\x20"
+ "\x74\x65\x72\x69\x79\x61\x6b\x69",
+ .rlen = 48,
+ .result = "\x49\x20\x77\x6f\x75\x6c\x64\x20"
+ "\x6c\x69\x6b\x65\x20\x74\x68\x65"
+ "\x20\x47\x65\x6e\x65\x72\x61\x6c"
+ "\x20\x47\x61\x75\x27\x73\x20\x43"
+ "\x68\x69\x63\x6b\x65\x6e\x2c\x20"
+ "\x70\x6c\x65\x61\x73\x65\x2c\x20",
+ .ilen = 48,
+ .input = "\x97\x68\x72\x68\xd6\xec\xcc\xc0"
+ "\xc0\x7b\x25\xe2\x5e\xcf\xe5\x84"
+ "\x9d\xad\x8b\xbb\x96\xc4\xcd\xc0"
+ "\x3b\xc1\x03\xe1\xa1\x94\xbb\xd8"
+ "\x39\x31\x25\x23\xa7\x86\x62\xd5"
+ "\xbe\x7f\xcb\xcc\x98\xeb\xf5\xa8",
+ }, {
+ .klen = 16,
+ .key = "\x63\x68\x69\x63\x6b\x65\x6e\x20"
+ "\x74\x65\x72\x69\x79\x61\x6b\x69",
+ .rlen = 64,
+ .result = "\x49\x20\x77\x6f\x75\x6c\x64\x20"
+ "\x6c\x69\x6b\x65\x20\x74\x68\x65"
+ "\x20\x47\x65\x6e\x65\x72\x61\x6c"
+ "\x20\x47\x61\x75\x27\x73\x20\x43"
+ "\x68\x69\x63\x6b\x65\x6e\x2c\x20"
+ "\x70\x6c\x65\x61\x73\x65\x2c\x20"
+ "\x61\x6e\x64\x20\x77\x6f\x6e\x74"
+ "\x6f\x6e\x20\x73\x6f\x75\x70\x2e",
+ .ilen = 64,
+ .input = "\x97\x68\x72\x68\xd6\xec\xcc\xc0"
+ "\xc0\x7b\x25\xe2\x5e\xcf\xe5\x84"
+ "\x39\x31\x25\x23\xa7\x86\x62\xd5"
+ "\xbe\x7f\xcb\xcc\x98\xeb\xf5\xa8"
+ "\x48\x07\xef\xe8\x36\xee\x89\xa5"
+ "\x26\x73\x0d\xbc\x2f\x7b\xc8\x40"
+ "\x9d\xad\x8b\xbb\x96\xc4\xcd\xc0"
+ "\x3b\xc1\x03\xe1\xa1\x94\xbb\xd8",
+ }
+};
+
+/*
+ * Compression stuff.
+ */
+#define COMP_BUF_SIZE 512
+
+struct comp_testvec {
+ int inlen, outlen;
+ char input[COMP_BUF_SIZE];
+ char output[COMP_BUF_SIZE];
+};
+
+struct pcomp_testvec {
+ void *params;
+ unsigned int paramsize;
+ int inlen, outlen;
+ char input[COMP_BUF_SIZE];
+ char output[COMP_BUF_SIZE];
+};
+
+/*
+ * Deflate test vectors (null-terminated strings).
+ * Params: winbits=-11, Z_DEFAULT_COMPRESSION, MAX_MEM_LEVEL.
+ */
+
+#define DEFLATE_COMP_TEST_VECTORS 2
+#define DEFLATE_DECOMP_TEST_VECTORS 2
+
+static struct comp_testvec deflate_comp_tv_template[] = {
+ {
+ .inlen = 70,
+ .outlen = 38,
+ .input = "Join us now and share the software "
+ "Join us now and share the software ",
+ .output = "\xf3\xca\xcf\xcc\x53\x28\x2d\x56"
+ "\xc8\xcb\x2f\x57\x48\xcc\x4b\x51"
+ "\x28\xce\x48\x2c\x4a\x55\x28\xc9"
+ "\x48\x55\x28\xce\x4f\x2b\x29\x07"
+ "\x71\xbc\x08\x2b\x01\x00",
+ }, {
+ .inlen = 191,
+ .outlen = 122,
+ .input = "This document describes a compression method based on the DEFLATE"
+ "compression algorithm. This document defines the application of "
+ "the DEFLATE algorithm to the IP Payload Compression Protocol.",
+ .output = "\x5d\x8d\x31\x0e\xc2\x30\x10\x04"
+ "\xbf\xb2\x2f\xc8\x1f\x10\x04\x09"
+ "\x89\xc2\x85\x3f\x70\xb1\x2f\xf8"
+ "\x24\xdb\x67\xd9\x47\xc1\xef\x49"
+ "\x68\x12\x51\xae\x76\x67\xd6\x27"
+ "\x19\x88\x1a\xde\x85\xab\x21\xf2"
+ "\x08\x5d\x16\x1e\x20\x04\x2d\xad"
+ "\xf3\x18\xa2\x15\x85\x2d\x69\xc4"
+ "\x42\x83\x23\xb6\x6c\x89\x71\x9b"
+ "\xef\xcf\x8b\x9f\xcf\x33\xca\x2f"
+ "\xed\x62\xa9\x4c\x80\xff\x13\xaf"
+ "\x52\x37\xed\x0e\x52\x6b\x59\x02"
+ "\xd9\x4e\xe8\x7a\x76\x1d\x02\x98"
+ "\xfe\x8a\x87\x83\xa3\x4f\x56\x8a"
+ "\xb8\x9e\x8e\x5c\x57\xd3\xa0\x79"
+ "\xfa\x02",
+ },
+};
+
+static struct comp_testvec deflate_decomp_tv_template[] = {
+ {
+ .inlen = 122,
+ .outlen = 191,
+ .input = "\x5d\x8d\x31\x0e\xc2\x30\x10\x04"
+ "\xbf\xb2\x2f\xc8\x1f\x10\x04\x09"
+ "\x89\xc2\x85\x3f\x70\xb1\x2f\xf8"
+ "\x24\xdb\x67\xd9\x47\xc1\xef\x49"
+ "\x68\x12\x51\xae\x76\x67\xd6\x27"
+ "\x19\x88\x1a\xde\x85\xab\x21\xf2"
+ "\x08\x5d\x16\x1e\x20\x04\x2d\xad"
+ "\xf3\x18\xa2\x15\x85\x2d\x69\xc4"
+ "\x42\x83\x23\xb6\x6c\x89\x71\x9b"
+ "\xef\xcf\x8b\x9f\xcf\x33\xca\x2f"
+ "\xed\x62\xa9\x4c\x80\xff\x13\xaf"
+ "\x52\x37\xed\x0e\x52\x6b\x59\x02"
+ "\xd9\x4e\xe8\x7a\x76\x1d\x02\x98"
+ "\xfe\x8a\x87\x83\xa3\x4f\x56\x8a"
+ "\xb8\x9e\x8e\x5c\x57\xd3\xa0\x79"
+ "\xfa\x02",
+ .output = "This document describes a compression method based on the DEFLATE"
+ "compression algorithm. This document defines the application of "
+ "the DEFLATE algorithm to the IP Payload Compression Protocol.",
+ }, {
+ .inlen = 38,
+ .outlen = 70,
+ .input = "\xf3\xca\xcf\xcc\x53\x28\x2d\x56"
+ "\xc8\xcb\x2f\x57\x48\xcc\x4b\x51"
+ "\x28\xce\x48\x2c\x4a\x55\x28\xc9"
+ "\x48\x55\x28\xce\x4f\x2b\x29\x07"
+ "\x71\xbc\x08\x2b\x01\x00",
+ .output = "Join us now and share the software "
+ "Join us now and share the software ",
+ },
+};
+
+#define ZLIB_COMP_TEST_VECTORS 2
+#define ZLIB_DECOMP_TEST_VECTORS 2
+
+static const struct {
+ struct nlattr nla;
+ int val;
+} deflate_comp_params[] = {
+ {
+ .nla = {
+ .nla_len = NLA_HDRLEN + sizeof(int),
+ .nla_type = ZLIB_COMP_LEVEL,
+ },
+ .val = Z_DEFAULT_COMPRESSION,
+ }, {
+ .nla = {
+ .nla_len = NLA_HDRLEN + sizeof(int),
+ .nla_type = ZLIB_COMP_METHOD,
+ },
+ .val = Z_DEFLATED,
+ }, {
+ .nla = {
+ .nla_len = NLA_HDRLEN + sizeof(int),
+ .nla_type = ZLIB_COMP_WINDOWBITS,
+ },
+ .val = -11,
+ }, {
+ .nla = {
+ .nla_len = NLA_HDRLEN + sizeof(int),
+ .nla_type = ZLIB_COMP_MEMLEVEL,
+ },
+ .val = MAX_MEM_LEVEL,
+ }, {
+ .nla = {
+ .nla_len = NLA_HDRLEN + sizeof(int),
+ .nla_type = ZLIB_COMP_STRATEGY,
+ },
+ .val = Z_DEFAULT_STRATEGY,
+ }
+};
+
+static const struct {
+ struct nlattr nla;
+ int val;
+} deflate_decomp_params[] = {
+ {
+ .nla = {
+ .nla_len = NLA_HDRLEN + sizeof(int),
+ .nla_type = ZLIB_DECOMP_WINDOWBITS,
+ },
+ .val = -11,
+ }
+};
+
+static struct pcomp_testvec zlib_comp_tv_template[] = {
+ {
+ .params = &deflate_comp_params,
+ .paramsize = sizeof(deflate_comp_params),
+ .inlen = 70,
+ .outlen = 38,
+ .input = "Join us now and share the software "
+ "Join us now and share the software ",
+ .output = "\xf3\xca\xcf\xcc\x53\x28\x2d\x56"
+ "\xc8\xcb\x2f\x57\x48\xcc\x4b\x51"
+ "\x28\xce\x48\x2c\x4a\x55\x28\xc9"
+ "\x48\x55\x28\xce\x4f\x2b\x29\x07"
+ "\x71\xbc\x08\x2b\x01\x00",
+ }, {
+ .params = &deflate_comp_params,
+ .paramsize = sizeof(deflate_comp_params),
+ .inlen = 191,
+ .outlen = 122,
+ .input = "This document describes a compression method based on the DEFLATE"
+ "compression algorithm. This document defines the application of "
+ "the DEFLATE algorithm to the IP Payload Compression Protocol.",
+ .output = "\x5d\x8d\x31\x0e\xc2\x30\x10\x04"
+ "\xbf\xb2\x2f\xc8\x1f\x10\x04\x09"
+ "\x89\xc2\x85\x3f\x70\xb1\x2f\xf8"
+ "\x24\xdb\x67\xd9\x47\xc1\xef\x49"
+ "\x68\x12\x51\xae\x76\x67\xd6\x27"
+ "\x19\x88\x1a\xde\x85\xab\x21\xf2"
+ "\x08\x5d\x16\x1e\x20\x04\x2d\xad"
+ "\xf3\x18\xa2\x15\x85\x2d\x69\xc4"
+ "\x42\x83\x23\xb6\x6c\x89\x71\x9b"
+ "\xef\xcf\x8b\x9f\xcf\x33\xca\x2f"
+ "\xed\x62\xa9\x4c\x80\xff\x13\xaf"
+ "\x52\x37\xed\x0e\x52\x6b\x59\x02"
+ "\xd9\x4e\xe8\x7a\x76\x1d\x02\x98"
+ "\xfe\x8a\x87\x83\xa3\x4f\x56\x8a"
+ "\xb8\x9e\x8e\x5c\x57\xd3\xa0\x79"
+ "\xfa\x02",
+ },
+};
+
+static struct pcomp_testvec zlib_decomp_tv_template[] = {
+ {
+ .params = &deflate_decomp_params,
+ .paramsize = sizeof(deflate_decomp_params),
+ .inlen = 122,
+ .outlen = 191,
+ .input = "\x5d\x8d\x31\x0e\xc2\x30\x10\x04"
+ "\xbf\xb2\x2f\xc8\x1f\x10\x04\x09"
+ "\x89\xc2\x85\x3f\x70\xb1\x2f\xf8"
+ "\x24\xdb\x67\xd9\x47\xc1\xef\x49"
+ "\x68\x12\x51\xae\x76\x67\xd6\x27"
+ "\x19\x88\x1a\xde\x85\xab\x21\xf2"
+ "\x08\x5d\x16\x1e\x20\x04\x2d\xad"
+ "\xf3\x18\xa2\x15\x85\x2d\x69\xc4"
+ "\x42\x83\x23\xb6\x6c\x89\x71\x9b"
+ "\xef\xcf\x8b\x9f\xcf\x33\xca\x2f"
+ "\xed\x62\xa9\x4c\x80\xff\x13\xaf"
+ "\x52\x37\xed\x0e\x52\x6b\x59\x02"
+ "\xd9\x4e\xe8\x7a\x76\x1d\x02\x98"
+ "\xfe\x8a\x87\x83\xa3\x4f\x56\x8a"
+ "\xb8\x9e\x8e\x5c\x57\xd3\xa0\x79"
+ "\xfa\x02",
+ .output = "This document describes a compression method based on the DEFLATE"
+ "compression algorithm. This document defines the application of "
+ "the DEFLATE algorithm to the IP Payload Compression Protocol.",
+ }, {
+ .params = &deflate_decomp_params,
+ .paramsize = sizeof(deflate_decomp_params),
+ .inlen = 38,
+ .outlen = 70,
+ .input = "\xf3\xca\xcf\xcc\x53\x28\x2d\x56"
+ "\xc8\xcb\x2f\x57\x48\xcc\x4b\x51"
+ "\x28\xce\x48\x2c\x4a\x55\x28\xc9"
+ "\x48\x55\x28\xce\x4f\x2b\x29\x07"
+ "\x71\xbc\x08\x2b\x01\x00",
+ .output = "Join us now and share the software "
+ "Join us now and share the software ",
+ },
+};
+
+/*
+ * LZO test vectors (null-terminated strings).
+ */
+#define LZO_COMP_TEST_VECTORS 2
+#define LZO_DECOMP_TEST_VECTORS 2
+
+static struct comp_testvec lzo_comp_tv_template[] = {
+ {
+ .inlen = 70,
+ .outlen = 46,
+ .input = "Join us now and share the software "
+ "Join us now and share the software ",
+ .output = "\x00\x0d\x4a\x6f\x69\x6e\x20\x75"
+ "\x73\x20\x6e\x6f\x77\x20\x61\x6e"
+ "\x64\x20\x73\x68\x61\x72\x65\x20"
+ "\x74\x68\x65\x20\x73\x6f\x66\x74"
+ "\x77\x70\x01\x01\x4a\x6f\x69\x6e"
+ "\x3d\x88\x00\x11\x00\x00",
+ }, {
+ .inlen = 159,
+ .outlen = 133,
+ .input = "This document describes a compression method based on the LZO "
+ "compression algorithm. This document defines the application of "
+ "the LZO algorithm used in UBIFS.",
+ .output = "\x00\x2b\x54\x68\x69\x73\x20\x64"
+ "\x6f\x63\x75\x6d\x65\x6e\x74\x20"
+ "\x64\x65\x73\x63\x72\x69\x62\x65"
+ "\x73\x20\x61\x20\x63\x6f\x6d\x70"
+ "\x72\x65\x73\x73\x69\x6f\x6e\x20"
+ "\x6d\x65\x74\x68\x6f\x64\x20\x62"
+ "\x61\x73\x65\x64\x20\x6f\x6e\x20"
+ "\x74\x68\x65\x20\x4c\x5a\x4f\x2b"
+ "\x8c\x00\x0d\x61\x6c\x67\x6f\x72"
+ "\x69\x74\x68\x6d\x2e\x20\x20\x54"
+ "\x68\x69\x73\x2a\x54\x01\x02\x66"
+ "\x69\x6e\x65\x73\x94\x06\x05\x61"
+ "\x70\x70\x6c\x69\x63\x61\x74\x76"
+ "\x0a\x6f\x66\x88\x02\x60\x09\x27"
+ "\xf0\x00\x0c\x20\x75\x73\x65\x64"
+ "\x20\x69\x6e\x20\x55\x42\x49\x46"
+ "\x53\x2e\x11\x00\x00",
+ },
+};
+
+static struct comp_testvec lzo_decomp_tv_template[] = {
+ {
+ .inlen = 133,
+ .outlen = 159,
+ .input = "\x00\x2b\x54\x68\x69\x73\x20\x64"
+ "\x6f\x63\x75\x6d\x65\x6e\x74\x20"
+ "\x64\x65\x73\x63\x72\x69\x62\x65"
+ "\x73\x20\x61\x20\x63\x6f\x6d\x70"
+ "\x72\x65\x73\x73\x69\x6f\x6e\x20"
+ "\x6d\x65\x74\x68\x6f\x64\x20\x62"
+ "\x61\x73\x65\x64\x20\x6f\x6e\x20"
+ "\x74\x68\x65\x20\x4c\x5a\x4f\x2b"
+ "\x8c\x00\x0d\x61\x6c\x67\x6f\x72"
+ "\x69\x74\x68\x6d\x2e\x20\x20\x54"
+ "\x68\x69\x73\x2a\x54\x01\x02\x66"
+ "\x69\x6e\x65\x73\x94\x06\x05\x61"
+ "\x70\x70\x6c\x69\x63\x61\x74\x76"
+ "\x0a\x6f\x66\x88\x02\x60\x09\x27"
+ "\xf0\x00\x0c\x20\x75\x73\x65\x64"
+ "\x20\x69\x6e\x20\x55\x42\x49\x46"
+ "\x53\x2e\x11\x00\x00",
+ .output = "This document describes a compression method based on the LZO "
+ "compression algorithm. This document defines the application of "
+ "the LZO algorithm used in UBIFS.",
+ }, {
+ .inlen = 46,
+ .outlen = 70,
+ .input = "\x00\x0d\x4a\x6f\x69\x6e\x20\x75"
+ "\x73\x20\x6e\x6f\x77\x20\x61\x6e"
+ "\x64\x20\x73\x68\x61\x72\x65\x20"
+ "\x74\x68\x65\x20\x73\x6f\x66\x74"
+ "\x77\x70\x01\x01\x4a\x6f\x69\x6e"
+ "\x3d\x88\x00\x11\x00\x00",
+ .output = "Join us now and share the software "
+ "Join us now and share the software ",
+ },
+};
+
+/*
+ * Michael MIC test vectors from IEEE 802.11i
+ */
+#define MICHAEL_MIC_TEST_VECTORS 6
+
+static struct hash_testvec michael_mic_tv_template[] = {
+ {
+ .key = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .ksize = 8,
+ .plaintext = zeroed_string,
+ .psize = 0,
+ .digest = "\x82\x92\x5c\x1c\xa1\xd1\x30\xb8",
+ },
+ {
+ .key = "\x82\x92\x5c\x1c\xa1\xd1\x30\xb8",
+ .ksize = 8,
+ .plaintext = "M",
+ .psize = 1,
+ .digest = "\x43\x47\x21\xca\x40\x63\x9b\x3f",
+ },
+ {
+ .key = "\x43\x47\x21\xca\x40\x63\x9b\x3f",
+ .ksize = 8,
+ .plaintext = "Mi",
+ .psize = 2,
+ .digest = "\xe8\xf9\xbe\xca\xe9\x7e\x5d\x29",
+ },
+ {
+ .key = "\xe8\xf9\xbe\xca\xe9\x7e\x5d\x29",
+ .ksize = 8,
+ .plaintext = "Mic",
+ .psize = 3,
+ .digest = "\x90\x03\x8f\xc6\xcf\x13\xc1\xdb",
+ },
+ {
+ .key = "\x90\x03\x8f\xc6\xcf\x13\xc1\xdb",
+ .ksize = 8,
+ .plaintext = "Mich",
+ .psize = 4,
+ .digest = "\xd5\x5e\x10\x05\x10\x12\x89\x86",
+ },
+ {
+ .key = "\xd5\x5e\x10\x05\x10\x12\x89\x86",
+ .ksize = 8,
+ .plaintext = "Michael",
+ .psize = 7,
+ .digest = "\x0a\x94\x2b\x12\x4e\xca\xa5\x46",
+ }
+};
+
+/*
+ * CRC32C test vectors
+ */
+#define CRC32C_TEST_VECTORS 14
+
+static struct hash_testvec crc32c_tv_template[] = {
+ {
+ .psize = 0,
+ .digest = "\x00\x00\x00\x00",
+ },
+ {
+ .key = "\x87\xa9\xcb\xed",
+ .ksize = 4,
+ .psize = 0,
+ .digest = "\x78\x56\x34\x12",
+ },
+ {
+ .key = "\xff\xff\xff\xff",
+ .ksize = 4,
+ .plaintext = "\x01\x02\x03\x04\x05\x06\x07\x08"
+ "\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10"
+ "\x11\x12\x13\x14\x15\x16\x17\x18"
+ "\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20"
+ "\x21\x22\x23\x24\x25\x26\x27\x28",
+ .psize = 40,
+ .digest = "\x7f\x15\x2c\x0e",
+ },
+ {
+ .key = "\xff\xff\xff\xff",
+ .ksize = 4,
+ .plaintext = "\x29\x2a\x2b\x2c\x2d\x2e\x2f\x30"
+ "\x31\x32\x33\x34\x35\x36\x37\x38"
+ "\x39\x3a\x3b\x3c\x3d\x3e\x3f\x40"
+ "\x41\x42\x43\x44\x45\x46\x47\x48"
+ "\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50",
+ .psize = 40,
+ .digest = "\xf6\xeb\x80\xe9",
+ },
+ {
+ .key = "\xff\xff\xff\xff",
+ .ksize = 4,
+ .plaintext = "\x51\x52\x53\x54\x55\x56\x57\x58"
+ "\x59\x5a\x5b\x5c\x5d\x5e\x5f\x60"
+ "\x61\x62\x63\x64\x65\x66\x67\x68"
+ "\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70"
+ "\x71\x72\x73\x74\x75\x76\x77\x78",
+ .psize = 40,
+ .digest = "\xed\xbd\x74\xde",
+ },
+ {
+ .key = "\xff\xff\xff\xff",
+ .ksize = 4,
+ .plaintext = "\x79\x7a\x7b\x7c\x7d\x7e\x7f\x80"
+ "\x81\x82\x83\x84\x85\x86\x87\x88"
+ "\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90"
+ "\x91\x92\x93\x94\x95\x96\x97\x98"
+ "\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0",
+ .psize = 40,
+ .digest = "\x62\xc8\x79\xd5",
+ },
+ {
+ .key = "\xff\xff\xff\xff",
+ .ksize = 4,
+ .plaintext = "\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8"
+ "\xa9\xaa\xab\xac\xad\xae\xaf\xb0"
+ "\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8"
+ "\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0"
+ "\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8",
+ .psize = 40,
+ .digest = "\xd0\x9a\x97\xba",
+ },
+ {
+ .key = "\xff\xff\xff\xff",
+ .ksize = 4,
+ .plaintext = "\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0"
+ "\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8"
+ "\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0"
+ "\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8"
+ "\xe9\xea\xeb\xec\xed\xee\xef\xf0",
+ .psize = 40,
+ .digest = "\x13\xd9\x29\x2b",
+ },
+ {
+ .key = "\x80\xea\xd3\xf1",
+ .ksize = 4,
+ .plaintext = "\x29\x2a\x2b\x2c\x2d\x2e\x2f\x30"
+ "\x31\x32\x33\x34\x35\x36\x37\x38"
+ "\x39\x3a\x3b\x3c\x3d\x3e\x3f\x40"
+ "\x41\x42\x43\x44\x45\x46\x47\x48"
+ "\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50",
+ .psize = 40,
+ .digest = "\x0c\xb5\xe2\xa2",
+ },
+ {
+ .key = "\xf3\x4a\x1d\x5d",
+ .ksize = 4,
+ .plaintext = "\x51\x52\x53\x54\x55\x56\x57\x58"
+ "\x59\x5a\x5b\x5c\x5d\x5e\x5f\x60"
+ "\x61\x62\x63\x64\x65\x66\x67\x68"
+ "\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70"
+ "\x71\x72\x73\x74\x75\x76\x77\x78",
+ .psize = 40,
+ .digest = "\xd1\x7f\xfb\xa6",
+ },
+ {
+ .key = "\x2e\x80\x04\x59",
+ .ksize = 4,
+ .plaintext = "\x79\x7a\x7b\x7c\x7d\x7e\x7f\x80"
+ "\x81\x82\x83\x84\x85\x86\x87\x88"
+ "\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90"
+ "\x91\x92\x93\x94\x95\x96\x97\x98"
+ "\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0",
+ .psize = 40,
+ .digest = "\x59\x33\xe6\x7a",
+ },
+ {
+ .key = "\xa6\xcc\x19\x85",
+ .ksize = 4,
+ .plaintext = "\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8"
+ "\xa9\xaa\xab\xac\xad\xae\xaf\xb0"
+ "\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8"
+ "\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0"
+ "\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8",
+ .psize = 40,
+ .digest = "\xbe\x03\x01\xd2",
+ },
+ {
+ .key = "\x41\xfc\xfe\x2d",
+ .ksize = 4,
+ .plaintext = "\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0"
+ "\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8"
+ "\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0"
+ "\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8"
+ "\xe9\xea\xeb\xec\xed\xee\xef\xf0",
+ .psize = 40,
+ .digest = "\x75\xd3\xc5\x24",
+ },
+ {
+ .key = "\xff\xff\xff\xff",
+ .ksize = 4,
+ .plaintext = "\x01\x02\x03\x04\x05\x06\x07\x08"
+ "\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10"
+ "\x11\x12\x13\x14\x15\x16\x17\x18"
+ "\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20"
+ "\x21\x22\x23\x24\x25\x26\x27\x28"
+ "\x29\x2a\x2b\x2c\x2d\x2e\x2f\x30"
+ "\x31\x32\x33\x34\x35\x36\x37\x38"
+ "\x39\x3a\x3b\x3c\x3d\x3e\x3f\x40"
+ "\x41\x42\x43\x44\x45\x46\x47\x48"
+ "\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50"
+ "\x51\x52\x53\x54\x55\x56\x57\x58"
+ "\x59\x5a\x5b\x5c\x5d\x5e\x5f\x60"
+ "\x61\x62\x63\x64\x65\x66\x67\x68"
+ "\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70"
+ "\x71\x72\x73\x74\x75\x76\x77\x78"
+ "\x79\x7a\x7b\x7c\x7d\x7e\x7f\x80"
+ "\x81\x82\x83\x84\x85\x86\x87\x88"
+ "\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90"
+ "\x91\x92\x93\x94\x95\x96\x97\x98"
+ "\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0"
+ "\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8"
+ "\xa9\xaa\xab\xac\xad\xae\xaf\xb0"
+ "\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8"
+ "\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0"
+ "\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8"
+ "\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0"
+ "\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8"
+ "\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0"
+ "\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8"
+ "\xe9\xea\xeb\xec\xed\xee\xef\xf0",
+ .psize = 240,
+ .digest = "\x75\xd3\xc5\x24",
+ .np = 2,
+ .tap = { 31, 209 }
+ },
+};
+
+#endif /* _IFXMIPS_CRYPTO_TESTMGR_H */
diff --git a/package/platform/lantiq/ltq-deu/src/internal.h b/package/platform/lantiq/ltq-deu/src/internal.h
new file mode 100644
index 0000000..2d22636
--- /dev/null
+++ b/package/platform/lantiq/ltq-deu/src/internal.h
@@ -0,0 +1,141 @@
+/*
+ * Cryptographic API.
+ *
+ * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
+ * Copyright (c) 2005 Herbert Xu <herbert@gondor.apana.org.au>
+ *
+ * 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 of the License, or (at your option)
+ * any later version.
+ *
+ */
+#ifndef _CRYPTO_INTERNAL_H
+#define _CRYPTO_INTERNAL_H
+
+#include <crypto/algapi.h>
+#include <linux/completion.h>
+#include <linux/mm.h>
+#include <linux/highmem.h>
+#include <linux/interrupt.h>
+#include <linux/init.h>
+#include <linux/list.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/notifier.h>
+#include <linux/rwsem.h>
+#include <linux/slab.h>
+#include <linux/fips.h>
+
+/* Crypto notification events. */
+enum {
+ CRYPTO_MSG_ALG_REQUEST,
+ CRYPTO_MSG_ALG_REGISTER,
+ CRYPTO_MSG_ALG_UNREGISTER,
+ CRYPTO_MSG_TMPL_REGISTER,
+ CRYPTO_MSG_TMPL_UNREGISTER,
+};
+
+struct crypto_instance;
+struct crypto_template;
+
+struct crypto_larval {
+ struct crypto_alg alg;
+ struct crypto_alg *adult;
+ struct completion completion;
+ u32 mask;
+};
+
+extern struct list_head crypto_alg_list;
+extern struct rw_semaphore crypto_alg_sem;
+extern struct blocking_notifier_head crypto_chain;
+
+#ifdef CONFIG_PROC_FS
+void __init crypto_init_proc(void);
+void __exit crypto_exit_proc(void);
+#else
+static inline void crypto_init_proc(void)
+{ }
+static inline void crypto_exit_proc(void)
+{ }
+#endif
+
+static inline unsigned int crypto_cipher_ctxsize(struct crypto_alg *alg)
+{
+ return alg->cra_ctxsize;
+}
+
+static inline unsigned int crypto_compress_ctxsize(struct crypto_alg *alg)
+{
+ return alg->cra_ctxsize;
+}
+
+struct crypto_alg *crypto_mod_get(struct crypto_alg *alg);
+struct crypto_alg *crypto_alg_lookup(const char *name, u32 type, u32 mask);
+struct crypto_alg *crypto_alg_mod_lookup(const char *name, u32 type, u32 mask);
+
+int crypto_init_cipher_ops(struct crypto_tfm *tfm);
+int crypto_init_compress_ops(struct crypto_tfm *tfm);
+
+void crypto_exit_cipher_ops(struct crypto_tfm *tfm);
+void crypto_exit_compress_ops(struct crypto_tfm *tfm);
+
+struct crypto_larval *crypto_larval_alloc(const char *name, u32 type, u32 mask);
+void crypto_larval_kill(struct crypto_alg *alg);
+struct crypto_alg *crypto_larval_lookup(const char *name, u32 type, u32 mask);
+void crypto_larval_error(const char *name, u32 type, u32 mask);
+void crypto_alg_tested(const char *name, int err);
+
+void crypto_shoot_alg(struct crypto_alg *alg);
+struct crypto_tfm *__crypto_alloc_tfm(struct crypto_alg *alg, u32 type,
+ u32 mask);
+void *crypto_create_tfm(struct crypto_alg *alg,
+ const struct crypto_type *frontend);
+struct crypto_alg *crypto_find_alg(const char *alg_name,
+ const struct crypto_type *frontend,
+ u32 type, u32 mask);
+void *crypto_alloc_tfm(const char *alg_name,
+ const struct crypto_type *frontend, u32 type, u32 mask);
+
+int crypto_register_notifier(struct notifier_block *nb);
+int crypto_unregister_notifier(struct notifier_block *nb);
+int crypto_probing_notify(unsigned long val, void *v);
+
+static inline void crypto_alg_put(struct crypto_alg *alg)
+{
+ if (atomic_dec_and_test(&alg->cra_refcnt) && alg->cra_destroy)
+ alg->cra_destroy(alg);
+}
+
+static inline int crypto_tmpl_get(struct crypto_template *tmpl)
+{
+ return try_module_get(tmpl->module);
+}
+
+static inline void crypto_tmpl_put(struct crypto_template *tmpl)
+{
+ module_put(tmpl->module);
+}
+
+static inline int crypto_is_larval(struct crypto_alg *alg)
+{
+ return alg->cra_flags & CRYPTO_ALG_LARVAL;
+}
+
+static inline int crypto_is_dead(struct crypto_alg *alg)
+{
+ return alg->cra_flags & CRYPTO_ALG_DEAD;
+}
+
+static inline int crypto_is_moribund(struct crypto_alg *alg)
+{
+ return alg->cra_flags & (CRYPTO_ALG_DEAD | CRYPTO_ALG_DYING);
+}
+
+static inline void crypto_notify(unsigned long val, void *v)
+{
+ blocking_notifier_call_chain(&crypto_chain, val, v);
+}
+
+#endif /* _CRYPTO_INTERNAL_H */
+
diff --git a/package/platform/lantiq/ltq-deu/src/ltq_deu_testmgr.c b/package/platform/lantiq/ltq-deu/src/ltq_deu_testmgr.c
new file mode 100644
index 0000000..f1b5752
--- /dev/null
+++ b/package/platform/lantiq/ltq-deu/src/ltq_deu_testmgr.c
@@ -0,0 +1,3957 @@
+/*
+ * Algorithm testing framework and tests.
+ *
+ * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
+ * Copyright (c) 2002 Jean-Francois Dive <jef@linuxbe.org>
+ * Copyright (c) 2007 Nokia Siemens Networks
+ * Copyright (c) 2008 Herbert Xu <herbert@gondor.apana.org.au>
+ *
+ * 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 of the License, or (at your option)
+ * any later version.
+ *
+ */
+
+#include <crypto/hash.h>
+#include <linux/err.h>
+#include <linux/module.h>
+#include <linux/scatterlist.h>
+#include <linux/slab.h>
+#include <linux/string.h>
+#include <crypto/rng.h>
+#include <linux/jiffies.h>
+#include <linux/init.h>
+#include <linux/moduleparam.h>
+#include <linux/delay.h>
+#include <linux/types.h>
+#include <linux/sched.h>
+
+#include "internal.h"
+#include "ifxmips_testmgr.h"
+#include "ifxmips_tcrypt.h"
+#include "ifxmips_deu.h"
+
+/* changes for LQ ablkcipher speedtest */
+#include <linux/timex.h>
+#include <linux/interrupt.h>
+#include <asm/mipsregs.h>
+
+/*
+ * Need slab memory for testing (size in number of pages).
+ */
+#define XBUFSIZE 8
+
+/*
+ * Indexes into the xbuf to simulate cross-page access.
+ */
+#define IDX1 32
+#define IDX2 32400
+#define IDX3 1
+#define IDX4 8193
+#define IDX5 22222
+#define IDX6 17101
+#define IDX7 27333
+#define IDX8 3000
+
+/*
+* Used by test_cipher()
+*/
+#define ENCRYPT 1
+#define DECRYPT 0
+
+/*
+ * Need slab memory for testing (size in number of pages).
+ */
+#define TVMEMSIZE 4
+
+/*
+* Used by test_cipher_speed()
+*/
+#define ENCRYPT 1
+#define DECRYPT 0
+
+/*
+ * Used by test_cipher_speed()
+ */
+
+
+static unsigned int sec;
+
+static char *alg = NULL;
+static u32 type;
+static u32 mask;
+static int mode;
+static char *tvmem[TVMEMSIZE];
+
+static char *check[] = {
+ "des", "md5", "des3_ede", "rot13", "sha1", "sha224", "sha256",
+ "blowfish", "twofish", "serpent", "sha384", "sha512", "md4", "aes",
+ "cast6", "arc4", "michael_mic", "deflate", "crc32c", "tea", "xtea",
+ "khazad", "wp512", "wp384", "wp256", "tnepres", "xeta", "fcrypt",
+ "camellia", "seed", "salsa20", "rmd128", "rmd160", "rmd256", "rmd320",
+ "lzo", "cts", "zlib", NULL
+};
+struct tcrypt_result {
+ struct completion completion;
+ int err;
+};
+
+struct aead_test_suite {
+ struct {
+ struct aead_testvec *vecs;
+ unsigned int count;
+ } enc, dec;
+};
+
+struct cipher_test_suite {
+ struct {
+ struct cipher_testvec *vecs;
+ unsigned int count;
+ } enc, dec;
+};
+
+struct comp_test_suite {
+ struct {
+ struct comp_testvec *vecs;
+ unsigned int count;
+ } comp, decomp;
+};
+
+struct pcomp_test_suite {
+ struct {
+ struct pcomp_testvec *vecs;
+ unsigned int count;
+ } comp, decomp;
+};
+
+struct hash_test_suite {
+ struct hash_testvec *vecs;
+ unsigned int count;
+};
+
+struct cprng_test_suite {
+ struct cprng_testvec *vecs;
+ unsigned int count;
+};
+
+struct alg_test_desc {
+ const char *alg;
+ int (*test)(const struct alg_test_desc *desc, const char *driver,
+ u32 type, u32 mask);
+ int fips_allowed; /* set if alg is allowed in fips mode */
+
+ union {
+ struct aead_test_suite aead;
+ struct cipher_test_suite cipher;
+ struct comp_test_suite comp;
+ struct pcomp_test_suite pcomp;
+ struct hash_test_suite hash;
+ struct cprng_test_suite cprng;
+ } suite;
+};
+
+static unsigned int IDX[8] = { IDX1, IDX2, IDX3, IDX4, IDX5, IDX6, IDX7, IDX8 };
+
+static void hexdump(unsigned char *buf, unsigned int len)
+{
+ print_hex_dump(KERN_CONT, "", DUMP_PREFIX_OFFSET,
+ 16, 1,
+ buf, len, false);
+}
+
+static void tcrypt_complete(struct crypto_async_request *req, int err)
+{
+ struct tcrypt_result *res = req->data;
+
+ //printk("Signal done test\n");
+
+ if (err == -EINPROGRESS) {
+ printk("********************* Completion didnt go too well **************************** \n");
+ return;
+ }
+
+ res->err = err;
+ complete_all(&res->completion);
+}
+
+static int testmgr_alloc_buf(char *buf[XBUFSIZE])
+{
+ int i;
+
+ for (i = 0; i < XBUFSIZE; i++) {
+ buf[i] = (void *)__get_free_page(GFP_KERNEL);
+ if (!buf[i])
+ goto err_free_buf;
+ }
+
+ return 0;
+
+err_free_buf:
+ while (i-- > 0)
+ free_page((unsigned long)buf[i]);
+
+ return -ENOMEM;
+}
+
+static void testmgr_free_buf(char *buf[XBUFSIZE])
+{
+ int i;
+
+ for (i = 0; i < XBUFSIZE; i++)
+ free_page((unsigned long)buf[i]);
+}
+
+static int test_hash(struct crypto_ahash *tfm, struct hash_testvec *template,
+ unsigned int tcount)
+{
+ const char *algo = crypto_tfm_alg_driver_name(crypto_ahash_tfm(tfm));
+ unsigned int i, j, k, temp;
+ struct scatterlist sg[8];
+ char result[64];
+ struct ahash_request *req;
+ struct tcrypt_result tresult;
+ void *hash_buff;
+ char *xbuf[XBUFSIZE];
+ int ret = -ENOMEM;
+
+ if (testmgr_alloc_buf(xbuf))
+ goto out_nobuf;
+
+ init_completion(&tresult.completion);
+
+ req = ahash_request_alloc(tfm, GFP_KERNEL);
+ if (!req) {
+ printk(KERN_ERR "alg: hash: Failed to allocate request for "
+ "%s\n", algo);
+ goto out_noreq;
+ }
+ ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG,
+ tcrypt_complete, &tresult);
+
+ j = 0;
+ for (i = 0; i < tcount; i++) {
+ if (template[i].np)
+ continue;
+
+ j++;
+ memset(result, 0, 64);
+
+ hash_buff = xbuf[0];
+
+ memcpy(hash_buff, template[i].plaintext, template[i].psize);
+ sg_init_one(&sg[0], hash_buff, template[i].psize);
+
+ if (template[i].ksize) {
+ crypto_ahash_clear_flags(tfm, ~0);
+ ret = crypto_ahash_setkey(tfm, template[i].key,
+ template[i].ksize);
+ if (ret) {
+ printk(KERN_ERR "alg: hash: setkey failed on "
+ "test %d for %s: ret=%d\n", j, algo,
+ -ret);
+ goto out;
+ }
+ }
+
+ ahash_request_set_crypt(req, sg, result, template[i].psize);
+ ret = crypto_ahash_digest(req);
+ switch (ret) {
+ case 0:
+ break;
+ case -EINPROGRESS:
+ case -EBUSY:
+ ret = wait_for_completion_interruptible(
+ &tresult.completion);
+ if (!ret && !(ret = tresult.err)) {
+ INIT_COMPLETION(tresult.completion);
+ break;
+ }
+ /* fall through */
+ default:
+ printk(KERN_ERR "alg: hash: digest failed on test %d "
+ "for %s: ret=%d\n", j, algo, -ret);
+ goto out;
+ }
+
+ if (memcmp(result, template[i].digest,
+ crypto_ahash_digestsize(tfm))) {
+ printk(KERN_ERR "alg: hash: Test %d failed for %s\n",
+ j, algo);
+ hexdump(result, crypto_ahash_digestsize(tfm));
+ ret = -EINVAL;
+ goto out;
+ }
+ else {
+ printk(KERN_ERR "alg: hash: Test %d passed for %s\n",
+ j, algo);
+ hexdump(result, crypto_ahash_digestsize(tfm));
+ }
+ }
+
+ j = 0;
+ for (i = 0; i < tcount; i++) {
+ if (template[i].np) {
+ j++;
+ memset(result, 0, 64);
+
+ temp = 0;
+ sg_init_table(sg, template[i].np);
+ ret = -EINVAL;
+ for (k = 0; k < template[i].np; k++) {
+ if (WARN_ON(offset_in_page(IDX[k]) +
+ template[i].tap[k] > PAGE_SIZE))
+ goto out;
+ sg_set_buf(&sg[k],
+ memcpy(xbuf[IDX[k] >> PAGE_SHIFT] +
+ offset_in_page(IDX[k]),
+ template[i].plaintext + temp,
+ template[i].tap[k]),
+ template[i].tap[k]);
+ temp += template[i].tap[k];
+ }
+
+ if (template[i].ksize) {
+ crypto_ahash_clear_flags(tfm, ~0);
+ ret = crypto_ahash_setkey(tfm, template[i].key,
+ template[i].ksize);
+
+ if (ret) {
+ printk(KERN_ERR "alg: hash: setkey "
+ "failed on chunking test %d "
+ "for %s: ret=%d\n", j, algo,
+ -ret);
+ goto out;
+ }
+ }
+
+ ahash_request_set_crypt(req, sg, result,
+ template[i].psize);
+ ret = crypto_ahash_digest(req);
+ switch (ret) {
+ case 0:
+ break;
+ case -EINPROGRESS:
+ case -EBUSY:
+ ret = wait_for_completion_interruptible(
+ &tresult.completion);
+ if (!ret && !(ret = tresult.err)) {
+ INIT_COMPLETION(tresult.completion);
+ break;
+ }
+ /* fall through */
+ default:
+ printk(KERN_ERR "alg: hash: digest failed "
+ "on chunking test %d for %s: "
+ "ret=%d\n", j, algo, -ret);
+ goto out;
+ }
+
+ if (memcmp(result, template[i].digest,
+ crypto_ahash_digestsize(tfm))) {
+ printk(KERN_ERR "alg: hash: Chunking test %d "
+ "failed for %s\n", j, algo);
+ hexdump(result, crypto_ahash_digestsize(tfm));
+ ret = -EINVAL;
+ goto out;
+ }
+ else {
+ printk(KERN_ERR "alg: hash: Chunking test %d "
+ "passed for %s\n", j, algo);
+ hexdump(result, crypto_ahash_digestsize(tfm));
+ }
+ }
+ }
+
+ ret = 0;
+
+out:
+ ahash_request_free(req);
+out_noreq:
+ testmgr_free_buf(xbuf);
+out_nobuf:
+ return ret;
+}
+
+static int test_aead(struct crypto_aead *tfm, int enc,
+ struct aead_testvec *template, unsigned int tcount)
+{
+ const char *algo = crypto_tfm_alg_driver_name(crypto_aead_tfm(tfm));
+ unsigned int i, j, k, n, temp;
+ int ret = -ENOMEM;
+ char *q;
+ char *key;
+ struct aead_request *req;
+ struct scatterlist sg[8];
+ struct scatterlist asg[8];
+ const char *e;
+ struct tcrypt_result result;
+ unsigned int authsize;
+ void *input;
+ void *assoc;
+ char iv[MAX_IVLEN];
+ char *xbuf[XBUFSIZE];
+ char *axbuf[XBUFSIZE];
+
+ if (testmgr_alloc_buf(xbuf))
+ goto out_noxbuf;
+ if (testmgr_alloc_buf(axbuf))
+ goto out_noaxbuf;
+
+ if (enc == ENCRYPT)
+ e = "encryption";
+ else
+ e = "decryption";
+
+ init_completion(&result.completion);
+
+ req = aead_request_alloc(tfm, GFP_KERNEL);
+ if (!req) {
+ printk(KERN_ERR "alg: aead: Failed to allocate request for "
+ "%s\n", algo);
+ goto out;
+ }
+
+ aead_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG,
+ tcrypt_complete, &result);
+
+ for (i = 0, j = 0; i < tcount; i++) {
+ if (!template[i].np) {
+ j++;
+
+ /* some tepmplates have no input data but they will
+ * touch input
+ */
+ input = xbuf[0];
+ assoc = axbuf[0];
+
+ ret = -EINVAL;
+ if (WARN_ON(template[i].ilen > PAGE_SIZE ||
+ template[i].alen > PAGE_SIZE))
+ goto out;
+
+ memcpy(input, template[i].input, template[i].ilen);
+ memcpy(assoc, template[i].assoc, template[i].alen);
+ if (template[i].iv)
+ memcpy(iv, template[i].iv, MAX_IVLEN);
+ else
+ memset(iv, 0, MAX_IVLEN);
+
+ crypto_aead_clear_flags(tfm, ~0);
+ if (template[i].wk)
+ crypto_aead_set_flags(
+ tfm, CRYPTO_TFM_REQ_WEAK_KEY);
+
+ key = template[i].key;
+
+ ret = crypto_aead_setkey(tfm, key,
+ template[i].klen);
+ if (!ret == template[i].fail) {
+ printk(KERN_ERR "alg: aead: setkey failed on "
+ "test %d for %s: flags=%x\n", j, algo,
+ crypto_aead_get_flags(tfm));
+ goto out;
+ } else if (ret)
+ continue;
+
+ authsize = abs(template[i].rlen - template[i].ilen);
+ ret = crypto_aead_setauthsize(tfm, authsize);
+ if (ret) {
+ printk(KERN_ERR "alg: aead: Failed to set "
+ "authsize to %u on test %d for %s\n",
+ authsize, j, algo);
+ goto out;
+ }
+
+ sg_init_one(&sg[0], input,
+ template[i].ilen + (enc ? authsize : 0));
+
+ sg_init_one(&asg[0], assoc, template[i].alen);
+
+ aead_request_set_crypt(req, sg, sg,
+ template[i].ilen, iv);
+
+ aead_request_set_assoc(req, asg, template[i].alen);
+
+ ret = enc ?
+ crypto_aead_encrypt(req) :
+ crypto_aead_decrypt(req);
+
+ switch (ret) {
+ case 0:
+ if (template[i].novrfy) {
+ /* verification was supposed to fail */
+ printk(KERN_ERR "alg: aead: %s failed "
+ "on test %d for %s: ret was 0, "
+ "expected -EBADMSG\n",
+ e, j, algo);
+ /* so really, we got a bad message */
+ ret = -EBADMSG;
+ goto out;
+ }
+ break;
+ case -EINPROGRESS:
+ case -EBUSY:
+ ret = wait_for_completion_interruptible(
+ &result.completion);
+ if (!ret && !(ret = result.err)) {
+ INIT_COMPLETION(result.completion);
+ break;
+ }
+ case -EBADMSG:
+ if (template[i].novrfy)
+ /* verification failure was expected */
+ continue;
+ /* fall through */
+ default:
+ printk(KERN_ERR "alg: aead: %s failed on test "
+ "%d for %s: ret=%d\n", e, j, algo, -ret);
+ goto out;
+ }
+
+ q = input;
+ if (memcmp(q, template[i].result, template[i].rlen)) {
+ printk(KERN_ERR "alg: aead: Test %d failed on "
+ "%s for %s\n", j, e, algo);
+ hexdump(q, template[i].rlen);
+ ret = -EINVAL;
+ goto out;
+ }
+ else {
+ printk(KERN_ERR "alg: aead: Test %d passed on "
+ "%s for %s\n", j, e, algo);
+ hexdump(q, template[i].rlen);
+ }
+ }
+ }
+
+ for (i = 0, j = 0; i < tcount; i++) {
+ if (template[i].np) {
+ j++;
+
+ if (template[i].iv)
+ memcpy(iv, template[i].iv, MAX_IVLEN);
+ else
+ memset(iv, 0, MAX_IVLEN);
+
+ crypto_aead_clear_flags(tfm, ~0);
+ if (template[i].wk)
+ crypto_aead_set_flags(
+ tfm, CRYPTO_TFM_REQ_WEAK_KEY);
+ key = template[i].key;
+
+ ret = crypto_aead_setkey(tfm, key, template[i].klen);
+ if (!ret == template[i].fail) {
+ printk(KERN_ERR "alg: aead: setkey failed on "
+ "chunk test %d for %s: flags=%x\n", j,
+ algo, crypto_aead_get_flags(tfm));
+ goto out;
+ } else if (ret)
+ continue;
+
+ authsize = abs(template[i].rlen - template[i].ilen);
+
+ ret = -EINVAL;
+ sg_init_table(sg, template[i].np);
+ for (k = 0, temp = 0; k < template[i].np; k++) {
+ if (WARN_ON(offset_in_page(IDX[k]) +
+ template[i].tap[k] > PAGE_SIZE))
+ goto out;
+
+ q = xbuf[IDX[k] >> PAGE_SHIFT] +
+ offset_in_page(IDX[k]);
+
+ memcpy(q, template[i].input + temp,
+ template[i].tap[k]);
+
+ n = template[i].tap[k];
+ if (k == template[i].np - 1 && enc)
+ n += authsize;
+ if (offset_in_page(q) + n < PAGE_SIZE)
+ q[n] = 0;
+
+ sg_set_buf(&sg[k], q, template[i].tap[k]);
+ temp += template[i].tap[k];
+ }
+
+ ret = crypto_aead_setauthsize(tfm, authsize);
+ if (ret) {
+ printk(KERN_ERR "alg: aead: Failed to set "
+ "authsize to %u on chunk test %d for "
+ "%s\n", authsize, j, algo);
+ goto out;
+ }
+
+ if (enc) {
+ if (WARN_ON(sg[k - 1].offset +
+ sg[k - 1].length + authsize >
+ PAGE_SIZE)) {
+ ret = -EINVAL;
+ goto out;
+ }
+
+ sg[k - 1].length += authsize;
+ }
+
+ sg_init_table(asg, template[i].anp);
+ ret = -EINVAL;
+ for (k = 0, temp = 0; k < template[i].anp; k++) {
+ if (WARN_ON(offset_in_page(IDX[k]) +
+ template[i].atap[k] > PAGE_SIZE))
+ goto out;
+ sg_set_buf(&asg[k],
+ memcpy(axbuf[IDX[k] >> PAGE_SHIFT] +
+ offset_in_page(IDX[k]),
+ template[i].assoc + temp,
+ template[i].atap[k]),
+ template[i].atap[k]);
+ temp += template[i].atap[k];
+ }
+
+ aead_request_set_crypt(req, sg, sg,
+ template[i].ilen,
+ iv);
+
+ aead_request_set_assoc(req, asg, template[i].alen);
+
+ ret = enc ?
+ crypto_aead_encrypt(req) :
+ crypto_aead_decrypt(req);
+
+ switch (ret) {
+ case 0:
+ if (template[i].novrfy) {
+ /* verification was supposed to fail */
+ printk(KERN_ERR "alg: aead: %s failed "
+ "on chunk test %d for %s: ret "
+ "was 0, expected -EBADMSG\n",
+ e, j, algo);
+ /* so really, we got a bad message */
+ ret = -EBADMSG;
+ goto out;
+ }
+ break;
+ case -EINPROGRESS:
+ case -EBUSY:
+ ret = wait_for_completion_interruptible(
+ &result.completion);
+ if (!ret && !(ret = result.err)) {
+ INIT_COMPLETION(result.completion);
+ break;
+ }
+ case -EBADMSG:
+ if (template[i].novrfy)
+ /* verification failure was expected */
+ continue;
+ /* fall through */
+ default:
+ printk(KERN_ERR "alg: aead: %s failed on "
+ "chunk test %d for %s: ret=%d\n", e, j,
+ algo, -ret);
+ goto out;
+ }
+
+ ret = -EINVAL;
+ for (k = 0, temp = 0; k < template[i].np; k++) {
+ q = xbuf[IDX[k] >> PAGE_SHIFT] +
+ offset_in_page(IDX[k]);
+
+ n = template[i].tap[k];
+ if (k == template[i].np - 1)
+ n += enc ? authsize : -authsize;
+
+ if (memcmp(q, template[i].result + temp, n)) {
+ printk(KERN_ERR "alg: aead: Chunk "
+ "test %d failed on %s at page "
+ "%u for %s\n", j, e, k, algo);
+ hexdump(q, n);
+ goto out;
+ }
+ else {
+ printk(KERN_ERR "alg: aead: Chunk "
+ "test %d passed on %s at page "
+ "%u for %s\n", j, e, k, algo);
+ hexdump(q, n);
+ }
+
+ q += n;
+ if (k == template[i].np - 1 && !enc) {
+ if (memcmp(q, template[i].input +
+ temp + n, authsize))
+ n = authsize;
+ else
+ n = 0;
+ } else {
+ for (n = 0; offset_in_page(q + n) &&
+ q[n]; n++)
+ ;
+ }
+ if (n) {
+ printk(KERN_ERR "alg: aead: Result "
+ "buffer corruption in chunk "
+ "test %d on %s at page %u for "
+ "%s: %u bytes:\n", j, e, k,
+ algo, n);
+ hexdump(q, n);
+ goto out;
+ }
+ temp += template[i].tap[k];
+ }
+ }
+ }
+
+ ret = 0;
+
+out:
+ aead_request_free(req);
+ testmgr_free_buf(axbuf);
+out_noaxbuf:
+ testmgr_free_buf(xbuf);
+out_noxbuf:
+ return ret;
+}
+
+static int test_cipher(struct crypto_cipher *tfm, int enc,
+ struct cipher_testvec *template, unsigned int tcount)
+{
+ const char *algo = crypto_tfm_alg_driver_name(crypto_cipher_tfm(tfm));
+ unsigned int i, j, k;
+ char *q;
+ const char *e;
+ void *data;
+ char *xbuf[XBUFSIZE];
+ int ret = -ENOMEM;
+
+ if (testmgr_alloc_buf(xbuf))
+ goto out_nobuf;
+
+ if (enc == ENCRYPT)
+ e = "encryption";
+ else
+ e = "decryption";
+
+ j = 0;
+ for (i = 0; i < tcount; i++) {
+ if (template[i].np)
+ continue;
+
+ j++;
+
+ ret = -EINVAL;
+ if (WARN_ON(template[i].ilen > PAGE_SIZE))
+ goto out;
+
+ data = xbuf[0];
+ memcpy(data, template[i].input, template[i].ilen);
+
+ crypto_cipher_clear_flags(tfm, ~0);
+ if (template[i].wk)
+ crypto_cipher_set_flags(tfm, CRYPTO_TFM_REQ_WEAK_KEY);
+
+ ret = crypto_cipher_setkey(tfm, template[i].key,
+ template[i].klen);
+ if (!ret == template[i].fail) {
+ printk(KERN_ERR "alg: cipher: setkey failed "
+ "on test %d for %s: flags=%x\n", j,
+ algo, crypto_cipher_get_flags(tfm));
+ goto out;
+ } else if (ret)
+ continue;
+
+ for (k = 0; k < template[i].ilen;
+ k += crypto_cipher_blocksize(tfm)) {
+ if (enc)
+ crypto_cipher_encrypt_one(tfm, data + k,
+ data + k);
+ else
+ crypto_cipher_decrypt_one(tfm, data + k,
+ data + k);
+ }
+
+ q = data;
+ if (memcmp(q, template[i].result, template[i].rlen)) {
+ printk(KERN_ERR "alg: cipher: Test %d failed "
+ "on %s for %s\n", j, e, algo);
+ hexdump(q, template[i].rlen);
+ ret = -EINVAL;
+ goto out;
+ }
+ else {
+ printk(KERN_ERR "alg: cipher: Test %d passed "
+ "on %s for %s\n", j, e, algo);
+ hexdump(q, template[i].rlen);
+ }
+ }
+
+ ret = 0;
+
+out:
+ testmgr_free_buf(xbuf);
+out_nobuf:
+ return ret;
+}
+
+static int test_skcipher(struct crypto_ablkcipher *tfm, int enc,
+ struct cipher_testvec *template, unsigned int tcount)
+{
+ const char *algo =
+ crypto_tfm_alg_driver_name(crypto_ablkcipher_tfm(tfm));
+ unsigned int i, j, k, n, temp;
+ char *q;
+ struct ablkcipher_request *req;
+ struct scatterlist sg[8];
+ const char *e;
+ struct tcrypt_result result;
+ void *data;
+ char iv[MAX_IVLEN];
+ char *xbuf[XBUFSIZE];
+ int ret = -ENOMEM;
+
+ if (testmgr_alloc_buf(xbuf))
+ goto out_nobuf;
+
+ if (enc == ENCRYPT)
+ e = "encryption";
+ else
+ e = "decryption";
+
+ init_completion(&result.completion);
+
+ req = ablkcipher_request_alloc(tfm, GFP_KERNEL);
+ if (!req) {
+ printk(KERN_ERR "alg: skcipher: Failed to allocate request "
+ "for %s\n", algo);
+ goto out;
+ }
+
+ //printk("tcount: %u\n", tcount);
+
+ ablkcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG,
+ tcrypt_complete, &result);
+
+ j = 0;
+ for (i = 0; i < tcount; i++) {
+ if (template[i].iv)
+ memcpy(iv, template[i].iv, MAX_IVLEN);
+ else
+ memset(iv, 0, MAX_IVLEN);
+
+ if (!(template[i].np)) {
+ //printk("np: %d, i: %d, j: %d\n", template[i].np, i, j);
+ j++;
+
+ ret = -EINVAL;
+ if (WARN_ON(template[i].ilen > PAGE_SIZE))
+ goto out;
+
+ data = xbuf[0];
+ memcpy(data, template[i].input, template[i].ilen);
+
+ crypto_ablkcipher_clear_flags(tfm, ~0);
+ if (template[i].wk)
+ crypto_ablkcipher_set_flags(
+ tfm, CRYPTO_TFM_REQ_WEAK_KEY);
+
+ ret = crypto_ablkcipher_setkey(tfm, template[i].key,
+ template[i].klen);
+ if (!ret == template[i].fail) {
+ printk(KERN_ERR "alg: skcipher: setkey failed "
+ "on test %d for %s: flags=%x\n", j,
+ algo, crypto_ablkcipher_get_flags(tfm));
+ printk("ERROR\n");
+ goto out;
+ } else if (ret)
+ continue;
+
+ sg_init_one(&sg[0], data, template[i].ilen);
+
+ ablkcipher_request_set_crypt(req, sg, sg,
+ template[i].ilen, iv);
+ ret = enc ?
+ crypto_ablkcipher_encrypt(req) :
+ crypto_ablkcipher_decrypt(req);
+
+ switch (ret) {
+ case 0:
+ break;
+ case -EINPROGRESS:
+ case -EBUSY:
+ ret = wait_for_completion_interruptible(
+ &result.completion);
+ if (!ret && !((ret = result.err))) {
+ INIT_COMPLETION(result.completion);
+ break;
+ }
+ /* fall through */
+ default:
+ printk(KERN_ERR "alg: skcipher: %s failed on "
+ "test %d for %s: ret=%d\n", e, j, algo,
+ -ret);
+ printk("ERROR\n");
+ goto out;
+ }
+ q = data;
+ if (memcmp(q, template[i].result, template[i].rlen)) {
+ printk(KERN_ERR "alg: skcipher: Test %d "
+ "failed on %s for %s\n", j, e, algo);
+ hexdump(q, template[i].rlen);
+ printk("ERROR\n");
+ ret = -EINVAL;
+ goto out;
+ }
+ else {
+ printk(KERN_ERR "alg: skcipher: Test %d "
+ "*PASSED* on %s for %s\n", j, e, algo);
+ hexdump(q, template[i].rlen);
+ printk("DONE\n");
+ }
+ }
+ }
+ printk("Testing %s chunking across pages.\n", algo);
+ j = 0;
+ for (i = 0; i < tcount; i++) {
+ if (template[i].iv)
+ memcpy(iv, template[i].iv, MAX_IVLEN);
+ else
+ memset(iv, 0, MAX_IVLEN);
+
+ if (template[i].np) {
+ j++;
+
+ crypto_ablkcipher_clear_flags(tfm, ~0);
+ if (template[i].wk)
+ crypto_ablkcipher_set_flags(
+ tfm, CRYPTO_TFM_REQ_WEAK_KEY);
+
+ ret = crypto_ablkcipher_setkey(tfm, template[i].key,
+ template[i].klen);
+ if (!ret == template[i].fail) {
+ printk(KERN_ERR "alg: skcipher: setkey failed "
+ "on chunk test %d for %s: flags=%x\n",
+ j, algo,
+ crypto_ablkcipher_get_flags(tfm));
+ printk("ERROR\n");
+ goto out;
+ } else if (ret)
+ continue;
+
+ temp = 0;
+ ret = -EINVAL;
+ sg_init_table(sg, template[i].np);
+ for (k = 0; k < template[i].np; k++) {
+ if (WARN_ON(offset_in_page(IDX[k]) +
+ template[i].tap[k] > PAGE_SIZE))
+ goto out;
+
+ q = xbuf[IDX[k] >> PAGE_SHIFT] +
+ offset_in_page(IDX[k]);
+
+ memcpy(q, template[i].input + temp,
+ template[i].tap[k]);
+
+ if (offset_in_page(q) + template[i].tap[k] <
+ PAGE_SIZE)
+ q[template[i].tap[k]] = 0;
+
+ sg_set_buf(&sg[k], q, template[i].tap[k]);
+
+ temp += template[i].tap[k];
+ }
+
+ ablkcipher_request_set_crypt(req, sg, sg,
+ template[i].ilen, iv);
+
+ ret = enc ?
+ crypto_ablkcipher_encrypt(req) :
+ crypto_ablkcipher_decrypt(req);
+
+ switch (ret) {
+ case 0:
+ break;
+ case -EINPROGRESS:
+ case -EBUSY:
+ ret = wait_for_completion_interruptible(
+ &result.completion);
+ if (!ret && !((ret = result.err))) {
+ INIT_COMPLETION(result.completion);
+ break;
+ }
+ /* fall through */
+ default:
+ printk(KERN_ERR "alg: skcipher: %s failed on "
+ "chunk test %d for %s: ret=%d\n", e, j,
+ algo, -ret);
+ printk("ERROR\n");
+ goto out;
+ }
+
+ temp = 0;
+ ret = -EINVAL;
+ for (k = 0; k < template[i].np; k++) {
+ q = xbuf[IDX[k] >> PAGE_SHIFT] +
+ offset_in_page(IDX[k]);
+
+ if (memcmp(q, template[i].result + temp,
+ template[i].tap[k])) {
+ printk(KERN_ERR "alg: skcipher: Chunk "
+ "test %d failed on %s at page "
+ "%u for %s\n", j, e, k, algo);
+ hexdump(q, template[i].tap[k]);
+ printk("ERROR\n");
+ goto out;
+ }
+ else {
+ printk(KERN_ERR "alg: skcipher: Chunk "
+ "test %d *PASSED* on %s at page "
+ "%u for %s\n", j, e, k, algo);
+ hexdump(q, template[i].tap[k]);
+ printk("DONE\n");
+ }
+
+ q += template[i].tap[k];
+ for (n = 0; offset_in_page(q + n) && q[n]; n++)
+ ;
+#if 1
+ if (n) {
+ printk(KERN_ERR "alg: skcipher: "
+ "Result buffer corruption in "
+ "chunk test %d on %s at page "
+ "%u for %s: %u bytes:\n", j, e,
+ k, algo, n);
+ hexdump(q, n);
+ printk("ERROR\n");
+ goto out;
+ }
+ else {
+ printk(KERN_ERR "alg: skcipher: "
+ "Result buffer clean in "
+ "chunk test %d on %s at page "
+ "%u for %s: %u bytes:\n", j, e,
+ k, algo, n);
+ hexdump(q, n);
+ printk("Chunk Buffer clean\n");
+ }
+#endif
+ temp += template[i].tap[k];
+ }
+ }
+ }
+
+ ret = 0;
+out:
+ ablkcipher_request_free(req);
+ testmgr_free_buf(xbuf);
+out_nobuf:
+ return ret;
+}
+
+static int test_comp(struct crypto_comp *tfm, struct comp_testvec *ctemplate,
+ struct comp_testvec *dtemplate, int ctcount, int dtcount)
+{
+ const char *algo = crypto_tfm_alg_driver_name(crypto_comp_tfm(tfm));
+ unsigned int i;
+ char result[COMP_BUF_SIZE];
+ int ret;
+
+ for (i = 0; i < ctcount; i++) {
+ int ilen;
+ unsigned int dlen = COMP_BUF_SIZE;
+
+ memset(result, 0, sizeof (result));
+
+ ilen = ctemplate[i].inlen;
+ ret = crypto_comp_compress(tfm, ctemplate[i].input,
+ ilen, result, &dlen);
+ if (ret) {
+ printk(KERN_ERR "alg: comp: compression failed "
+ "on test %d for %s: ret=%d\n", i + 1, algo,
+ -ret);
+ goto out;
+ }
+
+ if (dlen != ctemplate[i].outlen) {
+ printk(KERN_ERR "alg: comp: Compression test %d "
+ "failed for %s: output len = %d\n", i + 1, algo,
+ dlen);
+ ret = -EINVAL;
+ goto out;
+ }
+
+ if (memcmp(result, ctemplate[i].output, dlen)) {
+ printk(KERN_ERR "alg: comp: Compression test %d "
+ "failed for %s\n", i + 1, algo);
+ hexdump(result, dlen);
+ ret = -EINVAL;
+ goto out;
+ }
+ else {
+ printk(KERN_ERR "alg: comp: Compression test %d "
+ "passed for %s\n", i + 1, algo);
+ hexdump(result, dlen);
+ }
+ }
+
+ for (i = 0; i < dtcount; i++) {
+ int ilen;
+ unsigned int dlen = COMP_BUF_SIZE;
+
+ memset(result, 0, sizeof (result));
+
+ ilen = dtemplate[i].inlen;
+ ret = crypto_comp_decompress(tfm, dtemplate[i].input,
+ ilen, result, &dlen);
+ if (ret) {
+ printk(KERN_ERR "alg: comp: decompression failed "
+ "on test %d for %s: ret=%d\n", i + 1, algo,
+ -ret);
+ goto out;
+ }
+
+ if (dlen != dtemplate[i].outlen) {
+ printk(KERN_ERR "alg: comp: Decompression test %d "
+ "failed for %s: output len = %d\n", i + 1, algo,
+ dlen);
+ ret = -EINVAL;
+ goto out;
+ }
+
+ if (memcmp(result, dtemplate[i].output, dlen)) {
+ printk(KERN_ERR "alg: comp: Decompression test %d "
+ "failed for %s\n", i + 1, algo);
+ hexdump(result, dlen);
+ ret = -EINVAL;
+ goto out;
+ }
+ else {
+ printk(KERN_ERR "alg: comp: Decompression test %d "
+ "passed for %s\n", i + 1, algo);
+ hexdump(result, dlen);
+ }
+ }
+
+ ret = 0;
+
+out:
+ return ret;
+}
+
+static int test_pcomp(struct crypto_pcomp *tfm,
+ struct pcomp_testvec *ctemplate,
+ struct pcomp_testvec *dtemplate, int ctcount,
+ int dtcount)
+{
+ const char *algo = crypto_tfm_alg_driver_name(crypto_pcomp_tfm(tfm));
+ unsigned int i;
+ char result[COMP_BUF_SIZE];
+ int res;
+
+ for (i = 0; i < ctcount; i++) {
+ struct comp_request req;
+ unsigned int produced = 0;
+
+ res = crypto_compress_setup(tfm, ctemplate[i].params,
+ ctemplate[i].paramsize);
+ if (res) {
+ pr_err("alg: pcomp: compression setup failed on test "
+ "%d for %s: error=%d\n", i + 1, algo, res);
+ return res;
+ }
+
+ res = crypto_compress_init(tfm);
+ if (res) {
+ pr_err("alg: pcomp: compression init failed on test "
+ "%d for %s: error=%d\n", i + 1, algo, res);
+ return res;
+ }
+
+ memset(result, 0, sizeof(result));
+
+ req.next_in = ctemplate[i].input;
+ req.avail_in = ctemplate[i].inlen / 2;
+ req.next_out = result;
+ req.avail_out = ctemplate[i].outlen / 2;
+
+ res = crypto_compress_update(tfm, &req);
+ if (res < 0 && (res != -EAGAIN || req.avail_in)) {
+ pr_err("alg: pcomp: compression update failed on test "
+ "%d for %s: error=%d\n", i + 1, algo, res);
+ return res;
+ }
+ if (res > 0)
+ produced += res;
+
+ /* Add remaining input data */
+ req.avail_in += (ctemplate[i].inlen + 1) / 2;
+
+ res = crypto_compress_update(tfm, &req);
+ if (res < 0 && (res != -EAGAIN || req.avail_in)) {
+ pr_err("alg: pcomp: compression update failed on test "
+ "%d for %s: error=%d\n", i + 1, algo, res);
+ return res;
+ }
+ if (res > 0)
+ produced += res;
+
+ /* Provide remaining output space */
+ req.avail_out += COMP_BUF_SIZE - ctemplate[i].outlen / 2;
+
+ res = crypto_compress_final(tfm, &req);
+ if (res < 0) {
+ pr_err("alg: pcomp: compression final failed on test "
+ "%d for %s: error=%d\n", i + 1, algo, res);
+ return res;
+ }
+ produced += res;
+
+ if (COMP_BUF_SIZE - req.avail_out != ctemplate[i].outlen) {
+ pr_err("alg: comp: Compression test %d failed for %s: "
+ "output len = %d (expected %d)\n", i + 1, algo,
+ COMP_BUF_SIZE - req.avail_out,
+ ctemplate[i].outlen);
+ return -EINVAL;
+ }
+
+ if (produced != ctemplate[i].outlen) {
+ pr_err("alg: comp: Compression test %d failed for %s: "
+ "returned len = %u (expected %d)\n", i + 1,
+ algo, produced, ctemplate[i].outlen);
+ return -EINVAL;
+ }
+
+ if (memcmp(result, ctemplate[i].output, ctemplate[i].outlen)) {
+ pr_err("alg: pcomp: Compression test %d failed for "
+ "%s\n", i + 1, algo);
+ hexdump(result, ctemplate[i].outlen);
+ return -EINVAL;
+ }
+ }
+
+ for (i = 0; i < dtcount; i++) {
+ struct comp_request req;
+ unsigned int produced = 0;
+
+ res = crypto_decompress_setup(tfm, dtemplate[i].params,
+ dtemplate[i].paramsize);
+ if (res) {
+ pr_err("alg: pcomp: decompression setup failed on "
+ "test %d for %s: error=%d\n", i + 1, algo, res);
+ return res;
+ }
+
+ res = crypto_decompress_init(tfm);
+ if (res) {
+ pr_err("alg: pcomp: decompression init failed on test "
+ "%d for %s: error=%d\n", i + 1, algo, res);
+ return res;
+ }
+
+ memset(result, 0, sizeof(result));
+
+ req.next_in = dtemplate[i].input;
+ req.avail_in = dtemplate[i].inlen / 2;
+ req.next_out = result;
+ req.avail_out = dtemplate[i].outlen / 2;
+
+ res = crypto_decompress_update(tfm, &req);
+ if (res < 0 && (res != -EAGAIN || req.avail_in)) {
+ pr_err("alg: pcomp: decompression update failed on "
+ "test %d for %s: error=%d\n", i + 1, algo, res);
+ return res;
+ }
+ if (res > 0)
+ produced += res;
+
+ /* Add remaining input data */
+ req.avail_in += (dtemplate[i].inlen + 1) / 2;
+
+ res = crypto_decompress_update(tfm, &req);
+ if (res < 0 && (res != -EAGAIN || req.avail_in)) {
+ pr_err("alg: pcomp: decompression update failed on "
+ "test %d for %s: error=%d\n", i + 1, algo, res);
+ return res;
+ }
+ if (res > 0)
+ produced += res;
+
+ /* Provide remaining output space */
+ req.avail_out += COMP_BUF_SIZE - dtemplate[i].outlen / 2;
+
+ res = crypto_decompress_final(tfm, &req);
+ if (res < 0 && (res != -EAGAIN || req.avail_in)) {
+ pr_err("alg: pcomp: decompression final failed on "
+ "test %d for %s: error=%d\n", i + 1, algo, res);
+ return res;
+ }
+ if (res > 0)
+ produced += res;
+
+ if (COMP_BUF_SIZE - req.avail_out != dtemplate[i].outlen) {
+ pr_err("alg: comp: Decompression test %d failed for "
+ "%s: output len = %d (expected %d)\n", i + 1,
+ algo, COMP_BUF_SIZE - req.avail_out,
+ dtemplate[i].outlen);
+ return -EINVAL;
+ }
+
+ if (produced != dtemplate[i].outlen) {
+ pr_err("alg: comp: Decompression test %d failed for "
+ "%s: returned len = %u (expected %d)\n", i + 1,
+ algo, produced, dtemplate[i].outlen);
+ return -EINVAL;
+ }
+
+ if (memcmp(result, dtemplate[i].output, dtemplate[i].outlen)) {
+ pr_err("alg: pcomp: Decompression test %d failed for "
+ "%s\n", i + 1, algo);
+ hexdump(result, dtemplate[i].outlen);
+ return -EINVAL;
+ }
+ }
+
+ return 0;
+}
+
+static int test_ablkcipher_jiffies(struct ablkcipher_request *req, int enc,
+ int sec, struct tcrypt_result *result,
+ int blen)
+{
+ unsigned long start, end;
+ int bcount;
+ int ret;
+
+ for (start = jiffies, end = start + sec * HZ, bcount = 0;
+ time_before(jiffies, end); bcount++) {
+
+ if (enc)
+ ret = crypto_ablkcipher_encrypt(req);
+ else
+ ret = crypto_ablkcipher_decrypt(req);
+
+ switch (ret) {
+ case 0:
+ break;
+ case -EINPROGRESS:
+ case -EBUSY:
+ ret = wait_for_completion_interruptible(
+ &result->completion);
+ if (!ret && !((ret = result->err))) {
+ INIT_COMPLETION(result->completion);
+ break;
+ }
+ default:
+ printk("ERROR\n");
+ return ret;
+ }
+ }
+
+ printk("%d operations in %d seconds (%ld bytes)\n",
+ bcount, sec, (long)bcount * blen);
+
+ return 0;
+}
+
+static int test_ablkcipher_cycles(struct ablkcipher_request *req, int enc,
+ int sec, struct tcrypt_result *result,
+ int blen)
+{
+ unsigned long cycles = 0;
+ int ret = 0;
+ int i;
+ unsigned long start, end = 0;
+ //local_bh_disable();
+ //local_irq_disable();
+ /* Warm-up run. */
+ for (i = 0; i < 4; i++) {
+ if (enc)
+ ret = crypto_ablkcipher_encrypt(req);
+ else
+ ret = crypto_ablkcipher_decrypt(req);
+
+ switch (ret) {
+ case 0:
+ break;
+ case -EINPROGRESS:
+ case -EBUSY:
+#if 0
+ ret = wait_for_completion_interruptible(
+ &result->completion);
+ if (!ret && !((ret = result->err))) {
+ INIT_COMPLETION(result->completion);
+ break;
+ }
+#else
+
+ wait_for_completion(&result->completion);
+ INIT_COMPLETION(result->completion);
+ break;
+#endif
+ default:
+ printk("ERROR\n");
+ return ret;
+ }
+
+ if (signal_pending(current)) {
+ printk("Signal caught\n");
+ break;
+ }
+
+ }
+
+ //printk("Debug ln: (%d), fn: %s\n", __LINE__, __func__);
+ /* The real thing. */
+ for (i = 0; i < 8; i++) {
+ end = 0;
+ start = 0;
+ start = read_c0_count();
+ if (enc)
+ ret = crypto_ablkcipher_encrypt(req);
+ else
+ ret = crypto_ablkcipher_decrypt(req);
+
+ switch (ret) {
+ case 0:
+ break;
+ case -EINPROGRESS:
+ case -EBUSY:
+#if 0
+ ret = wait_for_completion_interruptible(
+ &result->completion);
+ end = get_cycles();
+ if (!ret && !((ret = result->err))) {
+ INIT_COMPLETION(result->completion);
+ break;
+ }
+#else
+ wait_for_completion(&result->completion);
+ end = read_c0_count();
+ INIT_COMPLETION(result->completion);
+ break;
+#endif
+ default:
+ printk("ERROR\n");
+ return ret;
+ }
+
+ if (signal_pending(current)) {
+ printk("Signal caught\n");
+ break;
+ }
+
+ cycles += end - start;
+ }
+
+ // local_irq_enable();
+ // local_bh_enable();
+
+ printk("1 operation in %lu cycles (%d bytes)\n",
+ (cycles + 4) / 8, blen);
+
+ return 0;
+
+}
+
+static u32 b_size[] = {16, 64, 256, 1024, 8192, 0};
+
+static int test_skcipher_speed(struct crypto_ablkcipher *tfm, int enc,
+ struct cipher_speed_template *template,
+ unsigned int tcount, unsigned int sec,
+ u8* keysize)
+{
+ const char *algo =
+ crypto_tfm_alg_driver_name(crypto_ablkcipher_tfm(tfm));
+
+ unsigned int i = 0, j, iv_len;
+ struct ablkcipher_request *req;
+ //struct scatterlist sg[8];
+ const char *e;
+ struct tcrypt_result result;
+ char iv[MAX_IVLEN];
+ static char *xbuf[XBUFSIZE];
+ int ret = -ENOMEM;
+ u32 *block_size;
+ static char *tvmem_buf[4];
+ const char *key;
+
+ if (testmgr_alloc_buf(xbuf))
+ goto out_nobuf;
+
+ if (enc == ENCRYPT)
+ e = "encryption";
+ else
+ e = "decryption";
+
+ init_completion(&result.completion);
+
+ printk("Start ablkcipher speed test\n");
+
+ req = ablkcipher_request_alloc(tfm, GFP_KERNEL);
+ if (!req) {
+ printk(KERN_ERR "alg: skcipher: Failed to allocate request "
+ "for %s\n", algo);
+ goto out;
+ }
+
+// ablkcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG,
+ ablkcipher_request_set_callback(req, 0,
+ tcrypt_complete, &result);
+
+ do {
+
+ block_size = b_size;
+
+ do {
+ struct scatterlist sg[4];
+ if ((*keysize + *block_size) > 4 * PAGE_SIZE) {
+ printk("template (%u) too big for "
+ "tvmem_buf (%lu)\n", *keysize + *block_size,
+ 4 * PAGE_SIZE);
+ goto out;
+ }
+ crypto_ablkcipher_clear_flags(tfm, ~0);
+
+ printk("test %u (%d bit key, %d byte blocks): ", i,
+ *keysize * 8, *block_size);
+
+ memset(tvmem_buf[0], 0xff, PAGE_SIZE);
+ key = tvmem_buf[0];
+
+ for (j = 0; j < tcount; j++) {
+ if (template[j].klen == *keysize) {
+ key = template[j].key;
+ break;
+ }
+ }
+ ret = crypto_ablkcipher_setkey(tfm, key, *keysize);
+ if (ret) {
+ printk("Error setting of keys\n");
+ goto out;
+ }
+
+ sg_init_table(sg, 4);
+
+ for (j = 0; j < 4; j++) {
+ tvmem_buf[j] = xbuf[j];
+ memset(tvmem_buf[j], 0xff, PAGE_SIZE);
+ sg_set_buf(sg + j, tvmem_buf[j], PAGE_SIZE);
+ }
+
+ iv_len = crypto_ablkcipher_ivsize(tfm);
+ if (iv_len) {
+ memset(&iv, 0xff, iv_len);
+ }
+
+ ablkcipher_request_set_crypt(req, sg, sg,
+ *block_size, iv);
+
+ //printk("Debug ln: %d, %s\n", __LINE__, __func__);
+ if (sec)
+ ret = test_ablkcipher_jiffies(req, enc, sec,
+ &result, *block_size);
+ else
+ ret = test_ablkcipher_cycles(req, enc, sec,
+ &result, *block_size);
+
+
+ if (ret) {
+ printk(KERN_ERR "alg: skcipher: %s failed on "
+ "test %d for %s: ret=%d\n", e, j, algo,
+ -ret);
+ goto out;
+ }
+
+ block_size++;
+ i++;
+ } while (*block_size);
+ keysize++;
+ } while (*keysize);
+
+ ret = 0;
+out:
+ printk("End ablkcipher speed test\n");
+ ablkcipher_request_free(req);
+ testmgr_free_buf(xbuf);
+#if 0
+ if (!completion_done(&result->completion)) {
+ printk("There are threads waiting for completion, completing all\n");
+ complete_all(&result->completion);
+ }
+#endif
+
+ //testmgr_free_buf(tvbuf);
+out_nobuf:
+ return ret;
+
+}
+
+static int test_cprng(struct crypto_rng *tfm, struct cprng_testvec *template,
+ unsigned int tcount)
+{
+ const char *algo = crypto_tfm_alg_driver_name(crypto_rng_tfm(tfm));
+ int err = 0, i, j, seedsize;
+ u8 *seed;
+ char result[32];
+
+ seedsize = crypto_rng_seedsize(tfm);
+
+ seed = kmalloc(seedsize, GFP_KERNEL);
+ if (!seed) {
+ printk(KERN_ERR "alg: cprng: Failed to allocate seed space "
+ "for %s\n", algo);
+ return -ENOMEM;
+ }
+
+ for (i = 0; i < tcount; i++) {
+ memset(result, 0, 32);
+
+ memcpy(seed, template[i].v, template[i].vlen);
+ memcpy(seed + template[i].vlen, template[i].key,
+ template[i].klen);
+ memcpy(seed + template[i].vlen + template[i].klen,
+ template[i].dt, template[i].dtlen);
+
+ err = crypto_rng_reset(tfm, seed, seedsize);
+ if (err) {
+ printk(KERN_ERR "alg: cprng: Failed to reset rng "
+ "for %s\n", algo);
+ goto out;
+ }
+
+ for (j = 0; j < template[i].loops; j++) {
+ err = crypto_rng_get_bytes(tfm, result,
+ template[i].rlen);
+ if (err != template[i].rlen) {
+ printk(KERN_ERR "alg: cprng: Failed to obtain "
+ "the correct amount of random data for "
+ "%s (requested %d, got %d)\n", algo,
+ template[i].rlen, err);
+ goto out;
+ }
+ }
+
+ err = memcmp(result, template[i].result,
+ template[i].rlen);
+ if (err) {
+ printk(KERN_ERR "alg: cprng: Test %d failed for %s\n",
+ i, algo);
+ hexdump(result, template[i].rlen);
+ err = -EINVAL;
+ goto out;
+ }
+ }
+
+out:
+ kfree(seed);
+ return err;
+}
+
+static int alg_test_aead(const struct alg_test_desc *desc, const char *driver,
+ u32 type, u32 mask)
+{
+ struct crypto_aead *tfm;
+ int err = 0;
+
+ tfm = crypto_alloc_aead(driver, type, mask);
+ if (IS_ERR(tfm)) {
+ printk(KERN_ERR "alg: aead: Failed to load transform for %s: "
+ "%ld\n", driver, PTR_ERR(tfm));
+ return PTR_ERR(tfm);
+ }
+
+ if (desc->suite.aead.enc.vecs) {
+ err = test_aead(tfm, ENCRYPT, desc->suite.aead.enc.vecs,
+ desc->suite.aead.enc.count);
+ if (err)
+ goto out;
+ }
+
+ if (!err && desc->suite.aead.dec.vecs)
+ err = test_aead(tfm, DECRYPT, desc->suite.aead.dec.vecs,
+ desc->suite.aead.dec.count);
+
+out:
+ crypto_free_aead(tfm);
+ return err;
+}
+
+static int alg_test_cipher(const struct alg_test_desc *desc,
+ const char *driver, u32 type, u32 mask)
+{
+ struct crypto_cipher *tfm;
+ int err = 0;
+
+ tfm = crypto_alloc_cipher(driver, type, mask);
+ if (IS_ERR(tfm)) {
+ printk(KERN_ERR "alg: cipher: Failed to load transform for "
+ "%s: %ld\n", driver, PTR_ERR(tfm));
+ return PTR_ERR(tfm);
+ }
+
+ if (desc->suite.cipher.enc.vecs) {
+ err = test_cipher(tfm, ENCRYPT, desc->suite.cipher.enc.vecs,
+ desc->suite.cipher.enc.count);
+ if (err)
+ goto out;
+ }
+
+ if (desc->suite.cipher.dec.vecs)
+ err = test_cipher(tfm, DECRYPT, desc->suite.cipher.dec.vecs,
+ desc->suite.cipher.dec.count);
+
+out:
+ crypto_free_cipher(tfm);
+ return err;
+}
+
+static int alg_test_skcipher(const struct alg_test_desc *desc,
+ const char *driver, u32 type, u32 mask)
+{
+ struct crypto_ablkcipher *tfm;
+ int err = 0;
+
+ tfm = crypto_alloc_ablkcipher(driver, type, mask);
+ if (IS_ERR(tfm)) {
+ printk(KERN_ERR "alg: skcipher: Failed to load transform for "
+ "%s: %ld\n", driver, PTR_ERR(tfm));
+ return PTR_ERR(tfm);
+ }
+
+ if (desc->suite.cipher.enc.vecs) {
+ err = test_skcipher(tfm, ENCRYPT, desc->suite.cipher.enc.vecs,
+ desc->suite.cipher.enc.count);
+ if (err)
+ goto out;
+ }
+
+ if (desc->suite.cipher.dec.vecs)
+ err = test_skcipher(tfm, DECRYPT, desc->suite.cipher.dec.vecs,
+ desc->suite.cipher.dec.count);
+
+out:
+ crypto_free_ablkcipher(tfm);
+ return err;
+}
+
+static int alg_test_comp(const struct alg_test_desc *desc, const char *driver,
+ u32 type, u32 mask)
+{
+ struct crypto_comp *tfm;
+ int err;
+
+ tfm = crypto_alloc_comp(driver, type, mask);
+ if (IS_ERR(tfm)) {
+ printk(KERN_ERR "alg: comp: Failed to load transform for %s: "
+ "%ld\n", driver, PTR_ERR(tfm));
+ return PTR_ERR(tfm);
+ }
+
+ err = test_comp(tfm, desc->suite.comp.comp.vecs,
+ desc->suite.comp.decomp.vecs,
+ desc->suite.comp.comp.count,
+ desc->suite.comp.decomp.count);
+
+ crypto_free_comp(tfm);
+ return err;
+}
+
+static int alg_test_pcomp(const struct alg_test_desc *desc, const char *driver,
+ u32 type, u32 mask)
+{
+ struct crypto_pcomp *tfm;
+ int err;
+
+ tfm = crypto_alloc_pcomp(driver, type, mask);
+ if (IS_ERR(tfm)) {
+ pr_err("alg: pcomp: Failed to load transform for %s: %ld\n",
+ driver, PTR_ERR(tfm));
+ return PTR_ERR(tfm);
+ }
+
+ err = test_pcomp(tfm, desc->suite.pcomp.comp.vecs,
+ desc->suite.pcomp.decomp.vecs,
+ desc->suite.pcomp.comp.count,
+ desc->suite.pcomp.decomp.count);
+
+ crypto_free_pcomp(tfm);
+ return err;
+}
+
+static int alg_test_hash(const struct alg_test_desc *desc, const char *driver,
+ u32 type, u32 mask)
+{
+ struct crypto_ahash *tfm;
+ int err;
+
+ tfm = crypto_alloc_ahash(driver, type, mask);
+ if (IS_ERR(tfm)) {
+ printk(KERN_ERR "alg: hash: Failed to load transform for %s: "
+ "%ld\n", driver, PTR_ERR(tfm));
+ return PTR_ERR(tfm);
+ }
+
+ err = test_hash(tfm, desc->suite.hash.vecs, desc->suite.hash.count);
+
+ crypto_free_ahash(tfm);
+ return err;
+}
+
+static int alg_test_crc32c(const struct alg_test_desc *desc,
+ const char *driver, u32 type, u32 mask)
+{
+ struct crypto_shash *tfm;
+ u32 val;
+ int err;
+
+ err = alg_test_hash(desc, driver, type, mask);
+ if (err)
+ goto out;
+
+ tfm = crypto_alloc_shash(driver, type, mask);
+ if (IS_ERR(tfm)) {
+ printk(KERN_ERR "alg: crc32c: Failed to load transform for %s: "
+ "%ld\n", driver, PTR_ERR(tfm));
+ err = PTR_ERR(tfm);
+ goto out;
+ }
+
+ do {
+ struct {
+ struct shash_desc shash;
+ char ctx[crypto_shash_descsize(tfm)];
+ } sdesc;
+
+ sdesc.shash.tfm = tfm;
+ sdesc.shash.flags = 0;
+
+ *(u32 *)sdesc.ctx = le32_to_cpu(420553207);
+ err = crypto_shash_final(&sdesc.shash, (u8 *)&val);
+ if (err) {
+ printk(KERN_ERR "alg: crc32c: Operation failed for "
+ "%s: %d\n", driver, err);
+ break;
+ }
+
+ if (val != ~420553207) {
+ printk(KERN_ERR "alg: crc32c: Test failed for %s: "
+ "%d\n", driver, val);
+ err = -EINVAL;
+ }
+ } while (0);
+
+ crypto_free_shash(tfm);
+
+out:
+ return err;
+}
+
+static int alg_test_cprng(const struct alg_test_desc *desc, const char *driver,
+ u32 type, u32 mask)
+{
+ struct crypto_rng *rng;
+ int err = 0;
+
+ rng = crypto_alloc_rng(driver, type, mask);
+ if (IS_ERR(rng)) {
+ printk(KERN_ERR "alg: cprng: Failed to load transform for %s: "
+ "%ld\n", driver, PTR_ERR(rng));
+ return PTR_ERR(rng);
+ }
+
+ err = test_cprng(rng, desc->suite.cprng.vecs, desc->suite.cprng.count);
+
+ crypto_free_rng(rng);
+
+ return err;
+}
+
+/* Please keep this list sorted by algorithm name. */
+static const struct alg_test_desc alg_test_descs[] = {
+ {
+ .alg = "ansi_cprng",
+ .test = alg_test_cprng,
+ .fips_allowed = 1,
+ .suite = {
+ .cprng = {
+ .vecs = ansi_cprng_aes_tv_template,
+ .count = ANSI_CPRNG_AES_TEST_VECTORS
+ }
+ }
+ }, {
+ .alg = "cbc(aes)",
+ .test = alg_test_skcipher,
+ .fips_allowed = 1,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = aes_cbc_enc_tv_template,
+ .count = AES_CBC_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = aes_cbc_dec_tv_template,
+ .count = AES_CBC_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "cbc(anubis)",
+ .test = alg_test_skcipher,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = anubis_cbc_enc_tv_template,
+ .count = ANUBIS_CBC_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = anubis_cbc_dec_tv_template,
+ .count = ANUBIS_CBC_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "cbc(blowfish)",
+ .test = alg_test_skcipher,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = bf_cbc_enc_tv_template,
+ .count = BF_CBC_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = bf_cbc_dec_tv_template,
+ .count = BF_CBC_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "cbc(camellia)",
+ .test = alg_test_skcipher,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = camellia_cbc_enc_tv_template,
+ .count = CAMELLIA_CBC_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = camellia_cbc_dec_tv_template,
+ .count = CAMELLIA_CBC_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "cbc(des)",
+ .test = alg_test_skcipher,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = des_cbc_enc_tv_template,
+ .count = DES_CBC_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = des_cbc_dec_tv_template,
+ .count = DES_CBC_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "cbc(des3_ede)",
+ .test = alg_test_skcipher,
+ .fips_allowed = 1,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = des3_ede_cbc_enc_tv_template,
+ .count = DES3_EDE_CBC_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = des3_ede_cbc_dec_tv_template,
+ .count = DES3_EDE_CBC_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "cbc(twofish)",
+ .test = alg_test_skcipher,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = tf_cbc_enc_tv_template,
+ .count = TF_CBC_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = tf_cbc_dec_tv_template,
+ .count = TF_CBC_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "ccm(aes)",
+ .test = alg_test_aead,
+ .fips_allowed = 1,
+ .suite = {
+ .aead = {
+ .enc = {
+ .vecs = aes_ccm_enc_tv_template,
+ .count = AES_CCM_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = aes_ccm_dec_tv_template,
+ .count = AES_CCM_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "crc32c",
+ .test = alg_test_crc32c,
+ .fips_allowed = 1,
+ .suite = {
+ .hash = {
+ .vecs = crc32c_tv_template,
+ .count = CRC32C_TEST_VECTORS
+ }
+ }
+ }, {
+ .alg = "ctr(aes)",
+ .test = alg_test_skcipher,
+ .fips_allowed = 1,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = aes_ctr_enc_tv_template,
+ .count = AES_CTR_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = aes_ctr_dec_tv_template,
+ .count = AES_CTR_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "cts(cbc(aes))",
+ .test = alg_test_skcipher,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = cts_mode_enc_tv_template,
+ .count = CTS_MODE_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = cts_mode_dec_tv_template,
+ .count = CTS_MODE_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "deflate",
+ .test = alg_test_comp,
+ .suite = {
+ .comp = {
+ .comp = {
+ .vecs = deflate_comp_tv_template,
+ .count = DEFLATE_COMP_TEST_VECTORS
+ },
+ .decomp = {
+ .vecs = deflate_decomp_tv_template,
+ .count = DEFLATE_DECOMP_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "ecb(aes)",
+ .test = alg_test_skcipher,
+ .fips_allowed = 1,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = aes_enc_tv_template,
+ .count = AES_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = aes_dec_tv_template,
+ .count = AES_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "ecb(anubis)",
+ .test = alg_test_skcipher,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = anubis_enc_tv_template,
+ .count = ANUBIS_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = anubis_dec_tv_template,
+ .count = ANUBIS_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "ecb(arc4)",
+ .test = alg_test_skcipher,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = arc4_enc_tv_template,
+ .count = ARC4_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = arc4_dec_tv_template,
+ .count = ARC4_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "ecb(blowfish)",
+ .test = alg_test_skcipher,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = bf_enc_tv_template,
+ .count = BF_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = bf_dec_tv_template,
+ .count = BF_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "ecb(camellia)",
+ .test = alg_test_skcipher,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = camellia_enc_tv_template,
+ .count = CAMELLIA_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = camellia_dec_tv_template,
+ .count = CAMELLIA_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "ecb(cast5)",
+ .test = alg_test_skcipher,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = cast5_enc_tv_template,
+ .count = CAST5_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = cast5_dec_tv_template,
+ .count = CAST5_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "ecb(cast6)",
+ .test = alg_test_skcipher,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = cast6_enc_tv_template,
+ .count = CAST6_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = cast6_dec_tv_template,
+ .count = CAST6_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "ecb(des)",
+ .test = alg_test_skcipher,
+ .fips_allowed = 1,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = des_enc_tv_template,
+ .count = DES_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = des_dec_tv_template,
+ .count = DES_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "ecb(des3_ede)",
+ .test = alg_test_skcipher,
+ .fips_allowed = 1,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = des3_ede_enc_tv_template,
+ .count = DES3_EDE_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = des3_ede_dec_tv_template,
+ .count = DES3_EDE_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "ecb(khazad)",
+ .test = alg_test_skcipher,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = khazad_enc_tv_template,
+ .count = KHAZAD_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = khazad_dec_tv_template,
+ .count = KHAZAD_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "ecb(seed)",
+ .test = alg_test_skcipher,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = seed_enc_tv_template,
+ .count = SEED_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = seed_dec_tv_template,
+ .count = SEED_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "ecb(serpent)",
+ .test = alg_test_skcipher,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = serpent_enc_tv_template,
+ .count = SERPENT_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = serpent_dec_tv_template,
+ .count = SERPENT_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "ecb(tea)",
+ .test = alg_test_skcipher,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = tea_enc_tv_template,
+ .count = TEA_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = tea_dec_tv_template,
+ .count = TEA_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "ecb(tnepres)",
+ .test = alg_test_skcipher,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = tnepres_enc_tv_template,
+ .count = TNEPRES_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = tnepres_dec_tv_template,
+ .count = TNEPRES_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "ecb(twofish)",
+ .test = alg_test_skcipher,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = tf_enc_tv_template,
+ .count = TF_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = tf_dec_tv_template,
+ .count = TF_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "ecb(xeta)",
+ .test = alg_test_skcipher,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = xeta_enc_tv_template,
+ .count = XETA_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = xeta_dec_tv_template,
+ .count = XETA_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "ecb(xtea)",
+ .test = alg_test_skcipher,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = xtea_enc_tv_template,
+ .count = XTEA_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = xtea_dec_tv_template,
+ .count = XTEA_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "gcm(aes)",
+ .test = alg_test_aead,
+ .fips_allowed = 1,
+ .suite = {
+ .aead = {
+ .enc = {
+ .vecs = aes_gcm_enc_tv_template,
+ .count = AES_GCM_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = aes_gcm_dec_tv_template,
+ .count = AES_GCM_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "hmac(md5)",
+ .test = alg_test_hash,
+ .suite = {
+ .hash = {
+ .vecs = hmac_md5_tv_template,
+ .count = HMAC_MD5_TEST_VECTORS
+ }
+ }
+ }, {
+ .alg = "hmac(rmd128)",
+ .test = alg_test_hash,
+ .suite = {
+ .hash = {
+ .vecs = hmac_rmd128_tv_template,
+ .count = HMAC_RMD128_TEST_VECTORS
+ }
+ }
+ }, {
+ .alg = "hmac(rmd160)",
+ .test = alg_test_hash,
+ .suite = {
+ .hash = {
+ .vecs = hmac_rmd160_tv_template,
+ .count = HMAC_RMD160_TEST_VECTORS
+ }
+ }
+ }, {
+ .alg = "hmac(sha1)",
+ .test = alg_test_hash,
+ .fips_allowed = 1,
+ .suite = {
+ .hash = {
+ .vecs = hmac_sha1_tv_template,
+ .count = HMAC_SHA1_TEST_VECTORS
+ }
+ }
+ }, {
+ .alg = "hmac(sha224)",
+ .test = alg_test_hash,
+ .fips_allowed = 1,
+ .suite = {
+ .hash = {
+ .vecs = hmac_sha224_tv_template,
+ .count = HMAC_SHA224_TEST_VECTORS
+ }
+ }
+ }, {
+ .alg = "hmac(sha256)",
+ .test = alg_test_hash,
+ .fips_allowed = 1,
+ .suite = {
+ .hash = {
+ .vecs = hmac_sha256_tv_template,
+ .count = HMAC_SHA256_TEST_VECTORS
+ }
+ }
+ }, {
+ .alg = "hmac(sha384)",
+ .test = alg_test_hash,
+ .fips_allowed = 1,
+ .suite = {
+ .hash = {
+ .vecs = hmac_sha384_tv_template,
+ .count = HMAC_SHA384_TEST_VECTORS
+ }
+ }
+ }, {
+ .alg = "hmac(sha512)",
+ .test = alg_test_hash,
+ .fips_allowed = 1,
+ .suite = {
+ .hash = {
+ .vecs = hmac_sha512_tv_template,
+ .count = HMAC_SHA512_TEST_VECTORS
+ }
+ }
+#if !defined(CONFIG_CRYPTO_DEV_AES) && !defined(CONFIG_CRYPTO_ASYNC_AES)
+ }, {
+ .alg = "lrw(aes)",
+ .test = alg_test_skcipher,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = aes_lrw_enc_tv_template,
+ .count = AES_LRW_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = aes_lrw_dec_tv_template,
+ .count = AES_LRW_DEC_TEST_VECTORS
+ }
+ }
+ }
+#endif
+ }, {
+ .alg = "lzo",
+ .test = alg_test_comp,
+ .suite = {
+ .comp = {
+ .comp = {
+ .vecs = lzo_comp_tv_template,
+ .count = LZO_COMP_TEST_VECTORS
+ },
+ .decomp = {
+ .vecs = lzo_decomp_tv_template,
+ .count = LZO_DECOMP_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "md4",
+ .test = alg_test_hash,
+ .suite = {
+ .hash = {
+ .vecs = md4_tv_template,
+ .count = MD4_TEST_VECTORS
+ }
+ }
+ }, {
+ .alg = "md5",
+ .test = alg_test_hash,
+ .suite = {
+ .hash = {
+ .vecs = md5_tv_template,
+ .count = MD5_TEST_VECTORS
+ }
+ }
+ }, {
+ .alg = "michael_mic",
+ .test = alg_test_hash,
+ .suite = {
+ .hash = {
+ .vecs = michael_mic_tv_template,
+ .count = MICHAEL_MIC_TEST_VECTORS
+ }
+ }
+ }, {
+ .alg = "pcbc(fcrypt)",
+ .test = alg_test_skcipher,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = fcrypt_pcbc_enc_tv_template,
+ .count = FCRYPT_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = fcrypt_pcbc_dec_tv_template,
+ .count = FCRYPT_DEC_TEST_VECTORS
+ }
+ }
+ }
+
+ }, {
+ .alg = "rfc3686(ctr(aes))",
+ .test = alg_test_skcipher,
+ .fips_allowed = 1,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = aes_ctr_rfc3686_enc_tv_template,
+ .count = AES_CTR_3686_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = aes_ctr_rfc3686_dec_tv_template,
+ .count = AES_CTR_3686_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "rfc4309(ccm(aes))",
+ .test = alg_test_aead,
+ .fips_allowed = 1,
+ .suite = {
+ .aead = {
+ .enc = {
+ .vecs = aes_ccm_rfc4309_enc_tv_template,
+ .count = AES_CCM_4309_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = aes_ccm_rfc4309_dec_tv_template,
+ .count = AES_CCM_4309_DEC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "rmd128",
+ .test = alg_test_hash,
+ .suite = {
+ .hash = {
+ .vecs = rmd128_tv_template,
+ .count = RMD128_TEST_VECTORS
+ }
+ }
+ }, {
+ .alg = "rmd160",
+ .test = alg_test_hash,
+ .suite = {
+ .hash = {
+ .vecs = rmd160_tv_template,
+ .count = RMD160_TEST_VECTORS
+ }
+ }
+ }, {
+ .alg = "rmd256",
+ .test = alg_test_hash,
+ .suite = {
+ .hash = {
+ .vecs = rmd256_tv_template,
+ .count = RMD256_TEST_VECTORS
+ }
+ }
+ }, {
+ .alg = "rmd320",
+ .test = alg_test_hash,
+ .suite = {
+ .hash = {
+ .vecs = rmd320_tv_template,
+ .count = RMD320_TEST_VECTORS
+ }
+ }
+ }, {
+ .alg = "salsa20",
+ .test = alg_test_skcipher,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = salsa20_stream_enc_tv_template,
+ .count = SALSA20_STREAM_ENC_TEST_VECTORS
+ }
+ }
+ }
+ }, {
+ .alg = "sha1",
+ .test = alg_test_hash,
+ .fips_allowed = 1,
+ .suite = {
+ .hash = {
+ .vecs = sha1_tv_template,
+ .count = SHA1_TEST_VECTORS
+ }
+ }
+ }, {
+ .alg = "sha224",
+ .test = alg_test_hash,
+ .fips_allowed = 1,
+ .suite = {
+ .hash = {
+ .vecs = sha224_tv_template,
+ .count = SHA224_TEST_VECTORS
+ }
+ }
+ }, {
+ .alg = "sha256",
+ .test = alg_test_hash,
+ .fips_allowed = 1,
+ .suite = {
+ .hash = {
+ .vecs = sha256_tv_template,
+ .count = SHA256_TEST_VECTORS
+ }
+ }
+ }, {
+ .alg = "sha384",
+ .test = alg_test_hash,
+ .fips_allowed = 1,
+ .suite = {
+ .hash = {
+ .vecs = sha384_tv_template,
+ .count = SHA384_TEST_VECTORS
+ }
+ }
+ }, {
+ .alg = "sha512",
+ .test = alg_test_hash,
+ .fips_allowed = 1,
+ .suite = {
+ .hash = {
+ .vecs = sha512_tv_template,
+ .count = SHA512_TEST_VECTORS
+ }
+ }
+ }, {
+ .alg = "tgr128",
+ .test = alg_test_hash,
+ .suite = {
+ .hash = {
+ .vecs = tgr128_tv_template,
+ .count = TGR128_TEST_VECTORS
+ }
+ }
+ }, {
+ .alg = "tgr160",
+ .test = alg_test_hash,
+ .suite = {
+ .hash = {
+ .vecs = tgr160_tv_template,
+ .count = TGR160_TEST_VECTORS
+ }
+ }
+ }, {
+ .alg = "tgr192",
+ .test = alg_test_hash,
+ .suite = {
+ .hash = {
+ .vecs = tgr192_tv_template,
+ .count = TGR192_TEST_VECTORS
+ }
+ }
+ }, {
+ .alg = "vmac(aes)",
+ .test = alg_test_hash,
+ .suite = {
+ .hash = {
+ .vecs = aes_vmac128_tv_template,
+ .count = VMAC_AES_TEST_VECTORS
+ }
+ }
+ }, {
+ .alg = "wp256",
+ .test = alg_test_hash,
+ .suite = {
+ .hash = {
+ .vecs = wp256_tv_template,
+ .count = WP256_TEST_VECTORS
+ }
+ }
+ }, {
+ .alg = "wp384",
+ .test = alg_test_hash,
+ .suite = {
+ .hash = {
+ .vecs = wp384_tv_template,
+ .count = WP384_TEST_VECTORS
+ }
+ }
+ }, {
+ .alg = "wp512",
+ .test = alg_test_hash,
+ .suite = {
+ .hash = {
+ .vecs = wp512_tv_template,
+ .count = WP512_TEST_VECTORS
+ }
+ }
+ }, {
+ .alg = "xcbc(aes)",
+ .test = alg_test_hash,
+ .suite = {
+ .hash = {
+ .vecs = aes_xcbc128_tv_template,
+ .count = XCBC_AES_TEST_VECTORS
+ }
+ }
+#if 0
+ }, {
+ .alg = "xts(aes)",
+ .test = alg_test_skcipher,
+ .suite = {
+ .cipher = {
+ .enc = {
+ .vecs = aes_xts_enc_tv_template,
+ .count = AES_XTS_ENC_TEST_VECTORS
+ },
+ .dec = {
+ .vecs = aes_xts_dec_tv_template,
+ .count = AES_XTS_DEC_TEST_VECTORS
+ }
+ }
+ }
+#endif
+ }, {
+ .alg = "zlib",
+ .test = alg_test_pcomp,
+ .suite = {
+ .pcomp = {
+ .comp = {
+ .vecs = zlib_comp_tv_template,
+ .count = ZLIB_COMP_TEST_VECTORS
+ },
+ .decomp = {
+ .vecs = zlib_decomp_tv_template,
+ .count = ZLIB_DECOMP_TEST_VECTORS
+ }
+ }
+ }
+ }
+};
+
+static int alg_find_test(const char *alg)
+{
+ int start = 0;
+ int end = ARRAY_SIZE(alg_test_descs);
+
+ while (start < end) {
+ int i = (start + end) / 2;
+ int diff = strcmp(alg_test_descs[i].alg, alg);
+
+ if (diff > 0) {
+ end = i;
+ continue;
+ }
+
+ if (diff < 0) {
+ start = i + 1;
+ continue;
+ }
+
+ return i;
+ }
+
+ return -1;
+}
+
+static int ifx_alg_test(const char *driver, const char *alg, u32 type, u32 mask)
+{
+ int i;
+ int j;
+ int rc;
+
+ if ((type & CRYPTO_ALG_TYPE_MASK) == CRYPTO_ALG_TYPE_CIPHER) {
+ char nalg[CRYPTO_MAX_ALG_NAME];
+
+ if (snprintf(nalg, sizeof(nalg), "ecb(%s)", alg) >=
+ sizeof(nalg))
+ return -ENAMETOOLONG;
+
+ i = alg_find_test(nalg);
+ if (i < 0)
+ goto notest;
+
+ if (fips_enabled && !alg_test_descs[i].fips_allowed)
+ goto non_fips_alg;
+
+ rc = alg_test_cipher(alg_test_descs + i, driver, type, mask);
+ goto test_done;
+ }
+
+ i = alg_find_test(alg);
+ j = alg_find_test(driver);
+ if (i < 0 && j < 0)
+ goto notest;
+
+ if (fips_enabled && ((i >= 0 && !alg_test_descs[i].fips_allowed) ||
+ (j >= 0 && !alg_test_descs[j].fips_allowed)))
+ goto non_fips_alg;
+
+ rc = 0;
+ if (i >= 0)
+ rc |= alg_test_descs[i].test(alg_test_descs + i, driver,
+ type, mask);
+ if (j >= 0)
+ rc |= alg_test_descs[j].test(alg_test_descs + j, driver,
+ type, mask);
+
+test_done:
+ if (fips_enabled && rc)
+ panic("%s: %s alg self test failed in fips mode!\n", driver, alg);
+
+ if (fips_enabled && !rc)
+ printk(KERN_INFO "alg: self-tests for %s (%s) passed\n",
+ driver, alg);
+
+ return rc;
+
+notest:
+ printk(KERN_INFO "alg: No test for %s (%s)\n", alg, driver);
+ return 0;
+non_fips_alg:
+ return -EINVAL;
+}
+EXPORT_SYMBOL_GPL(ifx_alg_test);
+
+/* Modified speed test for async block cipher mode*/
+
+static int ifx_alg_speed_test(const char *driver, const char *alg,
+ unsigned int sec,
+ struct cipher_speed_template *template,
+ unsigned int tcount, u8 *keysize)
+{
+ int i;
+ int j;
+ int err;
+ int type = 0, mask = 0;
+ struct crypto_ablkcipher *tfm;
+
+ i = alg_find_test(alg);
+ j = alg_find_test(driver);
+
+ if (i < 0 && j < 0)
+ goto notest;
+
+ if (fips_enabled && ((i >= 0 && !alg_test_descs[i].fips_allowed) ||
+ (j >= 0 && !alg_test_descs[j].fips_allowed)))
+ goto non_fips_alg;
+
+ tfm = crypto_alloc_ablkcipher(driver, type, mask);
+
+ if (IS_ERR(tfm)) {
+ printk(KERN_ERR "alg: skcipher: Failed to load transform for "
+ "%s: %ld\n", driver, PTR_ERR(tfm));
+ return PTR_ERR(tfm);
+ }
+ err = test_skcipher_speed(tfm, ENCRYPT, template,
+ tcount, sec, keysize);
+ if (err)
+ goto test_done;
+
+ err = test_skcipher_speed(tfm, DECRYPT, template,
+ tcount, sec, keysize);
+ if (!err)
+ goto test_done;
+
+notest:
+ return 0;
+non_fips_alg:
+ return -EINVAL;
+
+test_done:
+ if (fips_enabled && err)
+ panic("%s: %s alg self test failed in fips mode!\n", driver, alg);
+
+ if (fips_enabled && !err)
+ printk(KERN_INFO "alg: self-tests for %s (%s) passed\n",
+ driver, alg);
+
+ crypto_free_ablkcipher(tfm);
+ return err;
+}
+EXPORT_SYMBOL_GPL(ifx_alg_speed_test);
+
+
+static int test_cipher_jiffies(struct blkcipher_desc *desc, int enc,
+ struct scatterlist *sg, int blen, int sec)
+{
+ unsigned long start, end;
+ int bcount;
+ int ret;
+
+ for (start = jiffies, end = start + sec * HZ, bcount = 0;
+ time_before(jiffies, end); bcount++) {
+ if (enc)
+ ret = crypto_blkcipher_encrypt(desc, sg, sg, blen);
+ else
+ ret = crypto_blkcipher_decrypt(desc, sg, sg, blen);
+
+ if (ret)
+ return ret;
+ }
+
+ printk("%d operations in %d seconds (%ld bytes)\n",
+ bcount, sec, (long)bcount * blen);
+ return 0;
+}
+
+static int test_cipher_cycles(struct blkcipher_desc *desc, int enc,
+ struct scatterlist *sg, int blen)
+{
+ unsigned long cycles = 0;
+ unsigned long start, end;
+ int ret = 0;
+ int i;
+
+ local_bh_disable();
+ local_irq_disable();
+
+ /* Warm-up run. */
+ for (i = 0; i < 4; i++) {
+ if (enc)
+ ret = crypto_blkcipher_encrypt(desc, sg, sg, blen);
+ else
+ ret = crypto_blkcipher_decrypt(desc, sg, sg, blen);
+
+ if (ret)
+ goto out;
+ }
+
+ /* The real thing. */
+ for (i = 0; i < 8; i++) {
+ /* Original code to get cycles, does not work with MIPS
+ * cycles_t start, end;
+ * start = get_cycles();
+ */
+
+ start = read_c0_count(); // LQ modified tcrypt
+
+ if (enc)
+ ret = crypto_blkcipher_encrypt(desc, sg, sg, blen);
+ else
+ ret = crypto_blkcipher_decrypt(desc, sg, sg, blen);
+
+ /* Original code to get cycles, does not work with MIPS
+ * end = get_cycles();
+ */
+
+ end = read_c0_count(); //LQ modified tcrypt
+
+ if (ret)
+ goto out;
+
+ cycles += end - start;
+ }
+
+out:
+ local_irq_enable();
+ local_bh_enable();
+
+ if (ret == 0)
+ printk("1 operation in %lu cycles (%d bytes)\n",
+ (cycles + 4) / 8, blen);
+
+ return ret;
+}
+
+static u32 block_sizes[] = { 16, 64, 256, 1024, 8192, 0 };
+
+static void test_cipher_speed(const char *algo, int enc, unsigned int sec,
+ struct cipher_speed_template *template,
+ unsigned int tcount, u8 *keysize)
+{
+ unsigned int ret, i, j, iv_len;
+ const char *key, iv[128];
+ struct crypto_blkcipher *tfm;
+ struct blkcipher_desc desc;
+ const char *e;
+ u32 *b_size;
+
+ if (enc == ENCRYPT)
+ e = "encryption";
+ else
+ e = "decryption";
+
+ printk("\n ******* testing speed of %s %s ******* \n", algo, e);
+
+ tfm = crypto_alloc_blkcipher(algo, 0, CRYPTO_ALG_ASYNC);
+
+ if (IS_ERR(tfm)) {
+ printk("failed to load transform for %s: %ld\n", algo,
+ PTR_ERR(tfm));
+ return;
+ }
+ desc.tfm = tfm;
+ desc.flags = 0;
+
+ i = 0;
+ do {
+
+ b_size = block_sizes;
+ do {
+ struct scatterlist sg[TVMEMSIZE];
+
+ if ((*keysize + *b_size) > TVMEMSIZE * PAGE_SIZE) {
+ printk("template (%u) too big for "
+ "tvmem (%lu)\n", *keysize + *b_size,
+ TVMEMSIZE * PAGE_SIZE);
+ goto out;
+ }
+
+ printk("test %u (%d bit key, %d byte blocks): ", i,
+ *keysize * 8, *b_size);
+
+ memset(tvmem[0], 0xff, PAGE_SIZE);
+
+ /* set key, plain text and IV */
+ key = tvmem[0];
+ for (j = 0; j < tcount; j++) {
+ if (template[j].klen == *keysize) {
+ key = template[j].key;
+ break;
+ }
+ }
+
+ ret = crypto_blkcipher_setkey(tfm, key, *keysize);
+ if (ret) {
+ printk("setkey() failed flags=%x\n",
+ crypto_blkcipher_get_flags(tfm));
+ goto out;
+ }
+
+ sg_init_table(sg, TVMEMSIZE);
+ sg_set_buf(sg, tvmem[0] + *keysize,
+ PAGE_SIZE - *keysize);
+ for (j = 1; j < TVMEMSIZE; j++) {
+ sg_set_buf(sg + j, tvmem[j], PAGE_SIZE);
+ memset (tvmem[j], 0xff, PAGE_SIZE);
+ }
+
+ iv_len = crypto_blkcipher_ivsize(tfm);
+ if (iv_len) {
+ memset(&iv, 0xff, iv_len);
+ crypto_blkcipher_set_iv(tfm, iv, iv_len);
+ }
+
+ if (sec)
+ ret = test_cipher_jiffies(&desc, enc, sg,
+ *b_size, sec);
+ else
+ ret = test_cipher_cycles(&desc, enc, sg,
+ *b_size);
+
+ if (ret) {
+ printk("%s() failed flags=%x\n", e, desc.flags);
+ break;
+ }
+ b_size++;
+ i++;
+ } while (*b_size);
+ keysize++;
+ } while (*keysize);
+
+out:
+ crypto_free_blkcipher(tfm);
+}
+
+static int test_hash_jiffies_digest(struct hash_desc *desc,
+ struct scatterlist *sg, int blen,
+ char *out, int sec)
+{
+ unsigned long start, end;
+ int bcount;
+ int ret;
+
+ for (start = jiffies, end = start + sec * HZ, bcount = 0;
+ time_before(jiffies, end); bcount++) {
+ ret = crypto_hash_digest(desc, sg, blen, out);
+ if (ret)
+ return ret;
+ }
+
+ printk("%6u opers/sec, %9lu bytes/sec\n",
+ bcount / sec, ((long)bcount * blen) / sec);
+
+ return 0;
+}
+
+static int test_hash_jiffies(struct hash_desc *desc, struct scatterlist *sg,
+ int blen, int plen, char *out, int sec)
+{
+ unsigned long start, end;
+ int bcount, pcount;
+ int ret;
+
+ if (plen == blen)
+ return test_hash_jiffies_digest(desc, sg, blen, out, sec);
+
+ for (start = jiffies, end = start + sec * HZ, bcount = 0;
+ time_before(jiffies, end); bcount++) {
+ ret = crypto_hash_init(desc);
+ if (ret)
+ return ret;
+ for (pcount = 0; pcount < blen; pcount += plen) {
+ ret = crypto_hash_update(desc, sg, plen);
+ if (ret)
+ return ret;
+ }
+ /* we assume there is enough space in 'out' for the result */
+ ret = crypto_hash_final(desc, out);
+ if (ret)
+ return ret;
+ }
+
+ printk("%6u opers/sec, %9lu bytes/sec\n",
+ bcount / sec, ((long)bcount * blen) / sec);
+
+ return 0;
+}
+
+static int test_hash_cycles_digest(struct hash_desc *desc,
+ struct scatterlist *sg, int blen, char *out)
+{
+ unsigned long cycles = 0;
+ unsigned long start, end;
+ int i;
+ int ret;
+
+ local_bh_disable();
+ local_irq_disable();
+
+ /* Warm-up run. */
+ for (i = 0; i < 4; i++) {
+ ret = crypto_hash_digest(desc, sg, blen, out);
+ if (ret)
+ goto out;
+ }
+
+ /* The real thing. */
+ for (i = 0; i < 8; i++) {
+
+ /* Original code to get cycles, does not work with MIPS
+ * cycles_t start, end;
+ * start = get_cycles();
+ */
+
+ start = read_c0_count(); // LQ modified tcrypt
+
+ ret = crypto_hash_digest(desc, sg, blen, out);
+ if (ret)
+ goto out;
+
+ /* Original code to get cycles, does not work with MIPS
+ * end = get_cycles();
+ */
+
+ end = read_c0_count(); // LQ modified tcrypt
+
+ cycles += end - start;
+ }
+
+out:
+ local_irq_enable();
+ local_bh_enable();
+
+ if (ret)
+ return ret;
+
+ printk("%6lu cycles/operation, %4lu cycles/byte\n",
+ cycles / 8, cycles / (8 * blen));
+
+ return 0;
+}
+
+static int test_hash_cycles(struct hash_desc *desc, struct scatterlist *sg,
+ int blen, int plen, char *out)
+{
+ unsigned long cycles = 0;
+ unsigned long start, end;
+ int i, pcount;
+ int ret;
+
+ if (plen == blen)
+ return test_hash_cycles_digest(desc, sg, blen, out);
+
+ local_bh_disable();
+ local_irq_disable();
+
+ /* Warm-up run. */
+ for (i = 0; i < 4; i++) {
+ ret = crypto_hash_init(desc);
+ if (ret)
+ goto out;
+ for (pcount = 0; pcount < blen; pcount += plen) {
+ ret = crypto_hash_update(desc, sg, plen);
+ if (ret)
+ goto out;
+ }
+ ret = crypto_hash_final(desc, out);
+ if (ret)
+ goto out;
+ }
+
+ /* The real thing. */
+ for (i = 0; i < 8; i++) {
+
+ /* Original code for getting cycles, not working for MIPS
+ * cycle_t start, end;
+ * end = get_cycles();
+ */
+
+ start = read_c0_count(); // LQ modified tcrypt
+
+ ret = crypto_hash_init(desc);
+ if (ret)
+ goto out;
+ for (pcount = 0; pcount < blen; pcount += plen) {
+ ret = crypto_hash_update(desc, sg, plen);
+ if (ret)
+ goto out;
+ }
+ ret = crypto_hash_final(desc, out);
+ if (ret)
+ goto out;
+
+ /* Original code for getting cycles, not working for MIPS
+ * end = get_cycles();
+ */
+
+ end = read_c0_count(); // LQ modified tcrypt
+
+ cycles += end - start;
+ }
+
+out:
+ local_irq_enable();
+ local_bh_enable();
+
+ if (ret)
+ return ret;
+
+ printk("%6lu cycles/operation, %4lu cycles/byte\n",
+ cycles / 8, cycles / (8 * blen));
+
+ return 0;
+}
+
+static void test_hash_speed(const char *algo, unsigned int sec,
+ struct hash_speed *speed)
+{
+ struct scatterlist sg[TVMEMSIZE];
+ struct crypto_hash *tfm;
+ struct hash_desc desc;
+ static char output[1024];
+ int i;
+ int ret;
+
+ printk(KERN_INFO "\ntesting speed of %s\n", algo);
+
+ tfm = crypto_alloc_hash(algo, 0, CRYPTO_ALG_ASYNC);
+
+ if (IS_ERR(tfm)) {
+ printk(KERN_ERR "failed to load transform for %s: %ld\n", algo,
+ PTR_ERR(tfm));
+ return;
+ }
+
+ desc.tfm = tfm;
+ desc.flags = 0;
+
+ if (crypto_hash_digestsize(tfm) > sizeof(output)) {
+ printk(KERN_ERR "digestsize(%u) > outputbuffer(%zu)\n",
+ crypto_hash_digestsize(tfm), sizeof(output));
+ goto out;
+ }
+
+ sg_init_table(sg, TVMEMSIZE);
+ for (i = 0; i < TVMEMSIZE; i++) {
+ sg_set_buf(sg + i, tvmem[i], PAGE_SIZE);
+ memset(tvmem[i], 0xff, PAGE_SIZE);
+ }
+
+ for (i = 0; speed[i].blen != 0; i++) {
+ if (speed[i].blen > TVMEMSIZE * PAGE_SIZE) {
+ printk(KERN_ERR
+ "template (%u) too big for tvmem (%lu)\n",
+ speed[i].blen, TVMEMSIZE * PAGE_SIZE);
+ goto out;
+ }
+
+ printk(KERN_INFO "test%3u "
+ "(%5u byte blocks,%5u bytes per update,%4u updates): ",
+ i, speed[i].blen, speed[i].plen, speed[i].blen / speed[i].plen);
+
+ if (sec)
+ ret = test_hash_jiffies(&desc, sg, speed[i].blen,
+ speed[i].plen, output, sec);
+ else
+ ret = test_hash_cycles(&desc, sg, speed[i].blen,
+ speed[i].plen, output);
+
+ if (ret) {
+ printk(KERN_ERR "hashing failed ret=%d\n", ret);
+ break;
+ }
+ }
+
+out:
+ crypto_free_hash(tfm);
+}
+
+
+static void test_available(void)
+{
+ char **name = check;
+
+ while (*name) {
+ printk("alg %s ", *name);
+ printk(crypto_has_alg(*name, 0, 0) ?
+ "found\n" : "not found\n");
+ name++;
+ }
+}
+
+static inline int tcrypt_test(const char *alg)
+{
+ int ret;
+
+ printk("Running test %s\n", alg);
+ ret = ifx_alg_test(alg, alg, 0, 0);
+ /* non-fips algs return -EINVAL in fips mode */
+ if (fips_enabled && ret == -EINVAL)
+ ret = 0;
+ return ret;
+}
+
+static inline int tcrypt_speedtest(const char *alg,
+ struct cipher_speed_template *template,
+ unsigned int tcount, u8 *keysize)
+{
+ int ret;
+
+ printk("[****** Running speedtest %s *******]\n", alg);
+ ret = ifx_alg_speed_test(alg, alg, sec, template, tcount, keysize);
+ if (fips_enabled && ret == -EINVAL)
+ ret = 0;
+ return ret;
+}
+
+
+static int do_test(int m)
+{
+ int i;
+ int ret = 0;
+
+ switch (m) {
+ case 0:
+ for (i = 1; i < 200; i++)
+ ret += do_test(i);
+ break;
+
+ case 1:
+ ret += tcrypt_test("md5");
+ break;
+
+ case 2:
+ ret += tcrypt_test("sha1");
+ break;
+
+ case 3:
+ ret += tcrypt_test("ecb(des)");
+ ret += tcrypt_test("cbc(des)");
+ break;
+
+ case 4:
+ ret += tcrypt_test("ecb(des3_ede)");
+ ret += tcrypt_test("cbc(des3_ede)");
+ break;
+
+ case 5:
+ ret += tcrypt_test("md4");
+ break;
+
+ case 6:
+ ret += tcrypt_test("sha256");
+ break;
+
+ case 7:
+ ret += tcrypt_test("ecb(blowfish)");
+ ret += tcrypt_test("cbc(blowfish)");
+ break;
+
+ case 8:
+ ret += tcrypt_test("ecb(twofish)");
+ ret += tcrypt_test("cbc(twofish)");
+ break;
+
+ case 9:
+ ret += tcrypt_test("ecb(serpent)");
+ break;
+
+ case 10:
+ ret += tcrypt_test("ecb(aes)");
+ ret += tcrypt_test("cbc(aes)");
+ // ret += tcrypt_test("lrw(aes)");
+ // ret += tcrypt_test("xts(aes)");
+ ret += tcrypt_test("ctr(aes)");
+ ret += tcrypt_test("rfc3686(ctr(aes))");
+ break;
+
+ case 11:
+ ret += tcrypt_test("sha384");
+ break;
+
+ case 12:
+ ret += tcrypt_test("sha512");
+ break;
+
+ case 13:
+ ret += tcrypt_test("deflate");
+ break;
+
+ case 14:
+ ret += tcrypt_test("ecb(cast5)");
+ break;
+
+ case 15:
+ ret += tcrypt_test("ecb(cast6)");
+ break;
+
+ case 16:
+ ret += tcrypt_test("ecb(arc4)");
+ break;
+
+ case 17:
+ ret += tcrypt_test("michael_mic");
+ break;
+
+ case 18:
+ ret += tcrypt_test("crc32c");
+ break;
+
+ case 19:
+ ret += tcrypt_test("ecb(tea)");
+ break;
+
+ case 20:
+ ret += tcrypt_test("ecb(xtea)");
+ break;
+
+ case 21:
+ ret += tcrypt_test("ecb(khazad)");
+ break;
+
+ case 22:
+ ret += tcrypt_test("wp512");
+ break;
+
+ case 23:
+ ret += tcrypt_test("wp384");
+ break;
+
+ case 24:
+ ret += tcrypt_test("wp256");
+ break;
+
+ case 25:
+ ret += tcrypt_test("ecb(tnepres)");
+ break;
+
+ case 26:
+ ret += tcrypt_test("ecb(anubis)");
+ ret += tcrypt_test("cbc(anubis)");
+ break;
+
+ case 27:
+ ret += tcrypt_test("tgr192");
+ break;
+
+ case 28:
+
+ ret += tcrypt_test("tgr160");
+ break;
+
+ case 29:
+ ret += tcrypt_test("tgr128");
+ break;
+
+ case 30:
+ ret += tcrypt_test("ecb(xeta)");
+ break;
+
+ case 31:
+ ret += tcrypt_test("pcbc(fcrypt)");
+ break;
+
+ case 32:
+ ret += tcrypt_test("ecb(camellia)");
+ ret += tcrypt_test("cbc(camellia)");
+ break;
+ case 33:
+ ret += tcrypt_test("sha224");
+ break;
+
+ case 34:
+ ret += tcrypt_test("salsa20");
+ break;
+
+ case 35:
+ ret += tcrypt_test("gcm(aes)");
+ break;
+
+ case 36:
+ ret += tcrypt_test("lzo");
+ break;
+
+ case 37:
+ ret += tcrypt_test("ccm(aes)");
+ break;
+
+ case 38:
+ ret += tcrypt_test("cts(cbc(aes))");
+ break;
+
+ case 39:
+ ret += tcrypt_test("rmd128");
+ break;
+
+ case 40:
+ ret += tcrypt_test("rmd160");
+ break;
+
+ case 41:
+ ret += tcrypt_test("rmd256");
+ break;
+
+ case 42:
+ ret += tcrypt_test("rmd320");
+ break;
+
+ case 43:
+ ret += tcrypt_test("ecb(seed)");
+ break;
+
+ case 44:
+ ret += tcrypt_test("zlib");
+ break;
+
+ case 45:
+ ret += tcrypt_test("rfc4309(ccm(aes))");
+ break;
+
+ case 100:
+ ret += tcrypt_test("hmac(md5)");
+ break;
+
+ case 101:
+ ret += tcrypt_test("hmac(sha1)");
+ break;
+
+ case 102:
+ ret += tcrypt_test("hmac(sha256)");
+ break;
+
+ case 103:
+ ret += tcrypt_test("hmac(sha384)");
+ break;
+
+ case 104:
+ ret += tcrypt_test("hmac(sha512)");
+ break;
+
+ case 105:
+ ret += tcrypt_test("hmac(sha224)");
+ break;
+
+ case 106:
+ ret += tcrypt_test("xcbc(aes)");
+ break;
+
+ case 107:
+ ret += tcrypt_test("hmac(rmd128)");
+ break;
+
+ case 108:
+ ret += tcrypt_test("hmac(rmd160)");
+ break;
+
+ case 109:
+ ret += tcrypt_test("vmac(aes)");
+ break;
+
+ case 150:
+ ret += tcrypt_test("ansi_cprng");
+ break;
+
+ case 200:
+ test_cipher_speed("ecb(aes)", ENCRYPT, sec, NULL, 0,
+ speed_template_16_24_32);
+ test_cipher_speed("ecb(aes)", DECRYPT, sec, NULL, 0,
+ speed_template_16_24_32);
+ test_cipher_speed("cbc(aes)", ENCRYPT, sec, NULL, 0,
+ speed_template_16_24_32);
+ test_cipher_speed("cbc(aes)", DECRYPT, sec, NULL, 0,
+ speed_template_16_24_32);
+#if !defined(CONFIG_CRYPTO_DEV_AES) && !defined(CONFIG_CRYPTO_ASYNC_AES)
+ test_cipher_speed("lrw(aes)", ENCRYPT, sec, NULL, 0,
+ speed_template_32_40_48);
+ test_cipher_speed("lrw(aes)", DECRYPT, sec, NULL, 0,
+ speed_template_32_40_48);
+ test_cipher_speed("xts(aes)", ENCRYPT, sec, NULL, 0,
+ speed_template_32_48_64);
+ test_cipher_speed("xts(aes)", DECRYPT, sec, NULL, 0,
+ speed_template_32_48_64);
+#endif
+ break;
+
+ case 201:
+ test_cipher_speed("ecb(des3_ede)", ENCRYPT, sec,
+ des3_speed_template, DES3_SPEED_VECTORS,
+ speed_template_24);
+ test_cipher_speed("ecb(des3_ede)", DECRYPT, sec,
+ des3_speed_template, DES3_SPEED_VECTORS,
+ speed_template_24);
+ test_cipher_speed("cbc(des3_ede)", ENCRYPT, sec,
+ des3_speed_template, DES3_SPEED_VECTORS,
+ speed_template_24);
+ test_cipher_speed("cbc(des3_ede)", DECRYPT, sec,
+ des3_speed_template, DES3_SPEED_VECTORS,
+ speed_template_24);
+ break;
+
+ case 202:
+ test_cipher_speed("ecb(twofish)", ENCRYPT, sec, NULL, 0,
+ speed_template_16_24_32);
+ test_cipher_speed("ecb(twofish)", DECRYPT, sec, NULL, 0,
+ speed_template_16_24_32);
+ test_cipher_speed("cbc(twofish)", ENCRYPT, sec, NULL, 0,
+ speed_template_16_24_32);
+ test_cipher_speed("cbc(twofish)", DECRYPT, sec, NULL, 0,
+ speed_template_16_24_32);
+ break;
+
+ case 203:
+ test_cipher_speed("ecb(blowfish)", ENCRYPT, sec, NULL, 0,
+ speed_template_8_32);
+ test_cipher_speed("ecb(blowfish)", DECRYPT, sec, NULL, 0,
+ speed_template_8_32);
+ test_cipher_speed("cbc(blowfish)", ENCRYPT, sec, NULL, 0,
+ speed_template_8_32);
+ test_cipher_speed("cbc(blowfish)", DECRYPT, sec, NULL, 0,
+ speed_template_8_32);
+ break;
+
+ case 204:
+ test_cipher_speed("ecb(des)", ENCRYPT, sec, NULL, 0,
+ speed_template_8);
+ test_cipher_speed("ecb(des)", DECRYPT, sec, NULL, 0,
+ speed_template_8);
+ test_cipher_speed("cbc(des)", ENCRYPT, sec, NULL, 0,
+ speed_template_8);
+ test_cipher_speed("cbc(des)", DECRYPT, sec, NULL, 0,
+ speed_template_8);
+ break;
+
+ case 205:
+ test_cipher_speed("ecb(camellia)", ENCRYPT, sec, NULL, 0,
+ speed_template_16_24_32);
+ test_cipher_speed("ecb(camellia)", DECRYPT, sec, NULL, 0,
+ speed_template_16_24_32);
+ test_cipher_speed("cbc(camellia)", ENCRYPT, sec, NULL, 0,
+ speed_template_16_24_32);
+ test_cipher_speed("cbc(camellia)", DECRYPT, sec, NULL, 0,
+ speed_template_16_24_32);
+ break;
+
+ case 206:
+ test_cipher_speed("salsa20", ENCRYPT, sec, NULL, 0,
+ speed_template_16_32);
+ break;
+
+ case 300:
+ /* fall through */
+
+ case 301:
+ test_hash_speed("md4", sec, generic_hash_speed_template);
+ if (mode > 300 && mode < 400) break;
+
+ case 302:
+ test_hash_speed("md5", sec, generic_hash_speed_template);
+ if (mode > 300 && mode < 400) break;
+
+ case 303:
+ test_hash_speed("sha1", sec, generic_hash_speed_template);
+ if (mode > 300 && mode < 400) break;
+
+ case 304:
+ test_hash_speed("sha256", sec, generic_hash_speed_template);
+ if (mode > 300 && mode < 400) break;
+
+ case 305:
+ test_hash_speed("sha384", sec, generic_hash_speed_template);
+ if (mode > 300 && mode < 400) break;
+
+ case 306:
+ test_hash_speed("sha512", sec, generic_hash_speed_template);
+ if (mode > 300 && mode < 400) break;
+
+ case 307:
+ test_hash_speed("wp256", sec, generic_hash_speed_template);
+ if (mode > 300 && mode < 400) break;
+
+ case 308:
+ test_hash_speed("wp384", sec, generic_hash_speed_template);
+ if (mode > 300 && mode < 400) break;
+
+ case 309:
+ test_hash_speed("wp512", sec, generic_hash_speed_template);
+ if (mode > 300 && mode < 400) break;
+
+ case 310:
+ test_hash_speed("tgr128", sec, generic_hash_speed_template);
+ if (mode > 300 && mode < 400) break;
+
+ case 311:
+ test_hash_speed("tgr160", sec, generic_hash_speed_template);
+ if (mode > 300 && mode < 400) break;
+
+ case 312:
+ test_hash_speed("tgr192", sec, generic_hash_speed_template);
+ if (mode > 300 && mode < 400) break;
+
+ case 313:
+ test_hash_speed("sha224", sec, generic_hash_speed_template);
+ if (mode > 300 && mode < 400) break;
+
+ case 314:
+ test_hash_speed("rmd128", sec, generic_hash_speed_template);
+ if (mode > 300 && mode < 400) break;
+
+ case 315:
+ test_hash_speed("rmd160", sec, generic_hash_speed_template);
+ if (mode > 300 && mode < 400) break;
+
+ case 316:
+ test_hash_speed("rmd256", sec, generic_hash_speed_template);
+ if (mode > 300 && mode < 400) break;
+
+ case 317:
+ test_hash_speed("rmd320", sec, generic_hash_speed_template);
+ if (mode > 300 && mode < 400) break;
+
+ case 399:
+ break;
+
+ /* Modified speed test for async block cipher mode */
+ case 400:
+ tcrypt_speedtest("ecb(aes)", NULL, 0,
+ speed_template_16_24_32);
+ tcrypt_speedtest("cbc(aes)", NULL, 0,
+ speed_template_16_24_32);
+ break;
+
+ case 401:
+ tcrypt_speedtest("ecb(des3_ede)", des3_speed_template,
+ DES3_SPEED_VECTORS,speed_template_24);
+ tcrypt_speedtest("cbc(des3_ede)", des3_speed_template,
+ DES3_SPEED_VECTORS,speed_template_24);
+ break;
+
+ case 404:
+ tcrypt_speedtest("ecb(des)", NULL, 0,
+ speed_template_8);
+ tcrypt_speedtest("cbc(des)", NULL, 0,
+ speed_template_8);
+ break;
+
+ case 1000:
+ test_available();
+ break;
+ }
+
+ return ret;
+}
+#if !defined(CONFIG_CRYPTO_DEV_DEU)
+static int do_alg_test(const char *alg, u32 type, u32 mask)
+{
+ return crypto_has_alg(alg, type, mask ?: CRYPTO_ALG_TYPE_MASK) ?
+ 0 : -ENOENT;
+}
+#endif
+
+static int __init tcrypt_mod_init(void)
+{
+ int err = -ENOMEM;
+ int i;
+
+ printk("Starting Lantiq DEU Crypto TESTS . . . . . . .\n");
+
+ for (i = 0; i < TVMEMSIZE; i++) {
+ tvmem[i] = (void *)__get_free_page(GFP_KERNEL);
+ if (!tvmem[i])
+ goto err_free_tv;
+ }
+
+#if defined(CONFIG_CRYPTO_DEV_DEU)
+#if defined(CONFIG_CRYPTO_DEV_MD5)
+ mode = 1; // test md5 only
+ err = do_test(mode);
+ if (err)
+ goto md5_err;
+
+md5_err:
+ if (err) {
+ printk(KERN_ERR "md5: one or more tests failed!\n");
+ goto err_free_tv;
+ }
+#endif
+#if defined(CONFIG_CRYPTO_DEV_SHA1)
+ mode = 2; // test sha1 only
+ err = do_test(mode);
+ if (err)
+ goto sha1_err;
+
+sha1_err:
+ if (err) {
+ printk(KERN_ERR "sha1: one or more tests failed!\n");
+ goto err_free_tv;
+ }
+#endif
+#if defined (CONFIG_CRYPTO_DEV_DES) || defined (CONFIG_CRYPTO_ASYNC_DES)
+ mode = 3; // test des only
+ err = do_test(mode);
+ if (err)
+ goto des_err;
+
+ mode = 4; // test des3 only
+ err = do_test(mode);
+ if (err)
+ goto des_err;
+
+des_err:
+ if (err) {
+ printk(KERN_ERR "des3: one or more tests failed!\n");
+ goto err_free_tv;
+ }
+#endif
+#if defined (CONFIG_CRYPTO_ASYNC_AES) || defined (CONFIG_CRYPTO_DEV_AES)
+ mode = 10; // test aes only
+ err = do_test(mode);
+ if (err)
+ goto aes_err;
+
+aes_err:
+ if (err) {
+ printk(KERN_ERR "aes: one or more tests failed!\n");
+ goto err_free_tv;
+ }
+#endif
+#if defined(CONFIG_CRYPTO_DEV_ARC4)
+ mode = 16;
+ err = do_test(mode);
+
+ if (err) {
+ printk(KERN_ERR "arc4: one or more tests failed!\n");
+ goto err_free_tv;
+ }
+#endif
+#if defined (CONFIG_CRYPTO_DEV_MD5_HMAC)
+ mode = 100;
+ err = do_test(mode);
+
+ if (err) {
+ printk(KERN_ERR "tcrypt: one or more tests failed!\n");
+ goto err_free_tv;
+ }
+#endif
+#if defined (CONFIG_CRYPTO_DEV_SHA1_HMAC)
+ mode = 101;
+ err = do_test(mode);
+
+ if (err) {
+ printk(KERN_ERR "tcrypt: one or more tests failed!\n");
+ goto err_free_tv;
+ }
+#endif
+
+/* Start Speed tests test modes */
+#if defined(CONFIG_CRYPTO_DEV_SPEED_TEST)
+#if defined(CONFIG_CRYPTO_DEV_AES)
+ mode = 200;
+ err = do_test(mode);
+ if (err)
+ goto speed_err;
+#endif
+#if defined (CONFIG_CRYPTO_DEV_DES)
+ mode = 201;
+ err = do_test(mode);
+ if (err)
+ goto speed_err;
+
+ mode = 204;
+ err = do_test(mode);
+ if (err)
+ goto speed_err;
+#endif
+#if defined (CONFIG_CRYPTO_DEV_MD5)
+ mode = 302;
+ err = do_test(mode);
+ if (err)
+ goto speed_err;
+#endif
+#if defined (CONFIG_CRYPTO_DEV_SHA1)
+ mode = 303;
+ err = do_test(mode);
+ if (err)
+ goto speed_err;
+#endif
+ printk("Speed tests finished successfully\n");
+ goto fips_check;
+
+speed_err:
+ printk(KERN_ERR "tcrypt: one or more tests failed!\n");
+ goto err_free_tv;
+#endif /* CONFIG_CRYPTO_DEV_SPEED_TEST */
+
+#else
+ if (alg)
+ err = do_alg_test(alg, type, mask);
+ else
+ err = do_test(mode);
+
+ if (err) {
+ printk(KERN_ERR "tcrypt: one or more tests failed!\n");
+ goto err_free_tv;
+ }
+#endif /* CONFIG_CRYPTO_DEV_DEU */
+
+fips_check:
+ /* We intentionaly return -EAGAIN to prevent keeping the module,
+ * unless we're running in fips mode. It does all its work from
+ * init() and doesn't offer any runtime functionality, but in
+ * the fips case, checking for a successful load is helpful.
+ * => we don't need it in the memory, do we?
+ * -- mludvig
+ */
+ if (!fips_enabled)
+ err = -EAGAIN;
+
+err_free_tv:
+ for (i = 0; i < TVMEMSIZE && tvmem[i]; i++ ){
+ printk("Freeing page: %d\n", i);
+ free_page((unsigned long)tvmem[i]);
+ }
+
+ printk("Finished DEU testing . . . . . .\n");
+ return err;
+}
+
+/*
+ * If an init function is provided, an exit function must also be provided
+ * to allow module unload.
+ */
+static void __exit tcrypt_mod_fini(void) {}
+
+
+module_init(tcrypt_mod_init);
+module_exit(tcrypt_mod_fini);
+
+module_param(alg, charp, 0);
+module_param(type, uint, 0);
+module_param(mask, uint, 0);
+module_param(mode, int, 0);
+module_param(sec, uint, 0);
+MODULE_PARM_DESC(sec, "Length in seconds of speed tests "
+ "(defaults to zero which uses CPU cycles instead)");
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("Quick & dirty crypto testing module");
+MODULE_AUTHOR("James Morris <jmorris@intercode.com.au>");
+
diff --git a/package/platform/lantiq/ltq-hcd/.svn/entries b/package/platform/lantiq/ltq-hcd/.svn/entries
new file mode 100644
index 0000000..f09538f
--- /dev/null
+++ b/package/platform/lantiq/ltq-hcd/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/platform/lantiq/ltq-hcd
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-14T18:42:57.683038Z
+36019
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+src
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:12.000000Z
+528792004772d0af1b06ade09e1ab49c
+2013-03-14T18:42:57.683038Z
+36019
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1590
+
diff --git a/package/platform/lantiq/ltq-hcd/.svn/text-base/Makefile.svn-base b/package/platform/lantiq/ltq-hcd/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..74218c8
--- /dev/null
+++ b/package/platform/lantiq/ltq-hcd/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,53 @@
+# Copyright (C) 2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=ltq-hcd
+PKG_RELEASE:=1
+PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/ltq-hcd-$(BUILD_VARIANT)
+
+PKG_MAINTAINER:=John Crispin <blogic@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/ltq-hcd-template
+ SECTION:=sys
+ CATEGORY:=Kernel modules
+ SUBMENU:=USB Support
+ TITLE:=USB driver for $(1)
+ URL:=http://www.lantiq.com/
+ VARIANT:=$(1)
+ DEPENDS:=@TARGET_lantiq_$(2) +kmod-usb-core
+ FILES:=$(PKG_BUILD_DIR)/ltq_hcd_$(1).ko
+ AUTOLOAD:=$(call AutoLoad,50,ltq_hcd_$(1),1)
+endef
+
+KernelPackage/ltq-hcd-ase=$(call KernelPackage/ltq-hcd-template,ase,ase)
+KernelPackage/ltq-hcd-danube=$(call KernelPackage/ltq-hcd-template,danube,xway)
+KernelPackage/ltq-hcd-ar9=$(call KernelPackage/ltq-hcd-template,ar9,xway)
+KernelPackage/ltq-hcd-vr9=$(call KernelPackage/ltq-hcd-template,vr9,xway)
+KernelPackage/ltq-hcd-ar10=$(call KernelPackage/ltq-hcd-template,ar10,xway)
+
+define Build/Prepare
+ $(INSTALL_DIR) $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+ cd $(LINUX_DIR); \
+ ARCH=mips CROSS_COMPILE="$(KERNEL_CROSS)" \
+ $(MAKE) BUILD_VARIANT=$(BUILD_VARIANT) M=$(PKG_BUILD_DIR) V=1 modules
+endef
+
+$(eval $(call KernelPackage,ltq-hcd-ase))
+$(eval $(call KernelPackage,ltq-hcd-danube))
+$(eval $(call KernelPackage,ltq-hcd-ar9))
+$(eval $(call KernelPackage,ltq-hcd-vr9))
+$(eval $(call KernelPackage,ltq-hcd-ar10))
diff --git a/package/platform/lantiq/ltq-hcd/Makefile b/package/platform/lantiq/ltq-hcd/Makefile
new file mode 100644
index 0000000..74218c8
--- /dev/null
+++ b/package/platform/lantiq/ltq-hcd/Makefile
@@ -0,0 +1,53 @@
+# Copyright (C) 2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=ltq-hcd
+PKG_RELEASE:=1
+PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/ltq-hcd-$(BUILD_VARIANT)
+
+PKG_MAINTAINER:=John Crispin <blogic@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/ltq-hcd-template
+ SECTION:=sys
+ CATEGORY:=Kernel modules
+ SUBMENU:=USB Support
+ TITLE:=USB driver for $(1)
+ URL:=http://www.lantiq.com/
+ VARIANT:=$(1)
+ DEPENDS:=@TARGET_lantiq_$(2) +kmod-usb-core
+ FILES:=$(PKG_BUILD_DIR)/ltq_hcd_$(1).ko
+ AUTOLOAD:=$(call AutoLoad,50,ltq_hcd_$(1),1)
+endef
+
+KernelPackage/ltq-hcd-ase=$(call KernelPackage/ltq-hcd-template,ase,ase)
+KernelPackage/ltq-hcd-danube=$(call KernelPackage/ltq-hcd-template,danube,xway)
+KernelPackage/ltq-hcd-ar9=$(call KernelPackage/ltq-hcd-template,ar9,xway)
+KernelPackage/ltq-hcd-vr9=$(call KernelPackage/ltq-hcd-template,vr9,xway)
+KernelPackage/ltq-hcd-ar10=$(call KernelPackage/ltq-hcd-template,ar10,xway)
+
+define Build/Prepare
+ $(INSTALL_DIR) $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+ cd $(LINUX_DIR); \
+ ARCH=mips CROSS_COMPILE="$(KERNEL_CROSS)" \
+ $(MAKE) BUILD_VARIANT=$(BUILD_VARIANT) M=$(PKG_BUILD_DIR) V=1 modules
+endef
+
+$(eval $(call KernelPackage,ltq-hcd-ase))
+$(eval $(call KernelPackage,ltq-hcd-danube))
+$(eval $(call KernelPackage,ltq-hcd-ar9))
+$(eval $(call KernelPackage,ltq-hcd-vr9))
+$(eval $(call KernelPackage,ltq-hcd-ar10))
diff --git a/package/platform/lantiq/ltq-hcd/src/.svn/entries b/package/platform/lantiq/ltq-hcd/src/.svn/entries
new file mode 100644
index 0000000..5bd58d3
--- /dev/null
+++ b/package/platform/lantiq/ltq-hcd/src/.svn/entries
@@ -0,0 +1,606 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/platform/lantiq/ltq-hcd/src
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-14T18:42:57.683038Z
+36019
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+Kconfig
+file
+
+
+
+
+2013-03-17T12:13:12.000000Z
+c5e0308ca0298cac4c24949c1f5534d3
+2012-12-15T01:59:53.791806Z
+34688
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2429
+
+ifxhcd_intr.c
+file
+
+
+
+
+2013-03-17T12:13:12.000000Z
+193c0f7d1284d3caf60ec63f9c18782a
+2012-12-15T01:59:53.791806Z
+34688
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+137394
+
+ifxusb_ctl.c
+file
+
+
+
+
+2013-03-17T12:13:12.000000Z
+54a0512a87d966348e9c9cea829cd10b
+2012-12-15T01:59:53.791806Z
+34688
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+142106
+
+ifxhcd.c
+file
+
+
+
+
+2013-03-17T12:13:12.000000Z
+56777342a0a6063d4902ed0abde868c4
+2012-12-18T19:31:46.654408Z
+34770
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+65652
+
+ifxhcd_queue.c
+file
+
+
+
+
+2013-03-17T12:13:12.000000Z
+bce028ed09419d0df9dbb1ea4106e831
+2012-12-15T01:59:53.791806Z
+34688
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+14030
+
+ifxusb_version.h
+file
+
+
+
+
+2013-03-17T12:13:12.000000Z
+52b8f169a8597413a539d0d5d2461786
+2012-12-15T01:59:53.791806Z
+34688
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+69
+
+ifxhcd.h
+file
+
+
+
+
+2013-03-17T12:13:12.000000Z
+c3fac63dd9b28fe93409fa967640c116
+2012-12-15T01:59:53.791806Z
+34688
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+35498
+
+ifxusb_driver.c
+file
+
+
+
+
+2013-03-17T12:13:12.000000Z
+452ccfd315e56a277ef1ff6ea5dd84ed
+2013-03-14T18:42:57.683038Z
+36019
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+42944
+
+ifxusb_cif.c
+file
+
+
+
+
+2013-03-17T12:13:12.000000Z
+8907e4840968bcdac835cad1cf5f7537
+2012-12-15T01:59:53.791806Z
+34688
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+56106
+
+ifxusb_host.ko
+file
+
+
+
+
+2013-03-17T12:13:12.000000Z
+e951c7b965f194f6a6fb92c17cf3f1e0
+2012-12-15T01:59:53.791806Z
+34688
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+181257
+
+ifxusb_cif_d.c
+file
+
+
+
+
+2013-03-17T12:13:12.000000Z
+2f3b739b88f7d7ece21fab47e43b0379
+2012-12-15T01:59:53.791806Z
+34688
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+19184
+
+ifxusb_regs.h
+file
+
+
+
+
+2013-03-17T12:13:12.000000Z
+d944ac8d23c17bbede70ac78afbe5329
+2012-12-15T01:59:53.791806Z
+34688
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+56324
+
+ifxusb_plat.h
+file
+
+
+
+
+2013-03-17T12:13:12.000000Z
+f53d7882b1f609d2bed47fdf9f4dcfdf
+2012-12-15T01:59:53.791806Z
+34688
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+47979
+
+ifxusb_cif.h
+file
+
+
+
+
+2013-03-17T12:13:12.000000Z
+c179b25353ca88b0f5fa64c7143dc1ef
+2012-12-15T01:59:53.791806Z
+34688
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+28768
+
+ifxusb_cif_h.c
+file
+
+
+
+
+2013-03-17T12:13:12.000000Z
+05b970409a01908511c57f7e857e3c4e
+2012-12-15T01:59:53.791806Z
+34688
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+49193
+
+ifxhcd_es.c
+file
+
+
+
+
+2013-03-17T12:13:12.000000Z
+a00dd563aa5a5cafe71df8f951ec0e89
+2012-12-15T01:59:53.791806Z
+34688
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+18024
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:12.000000Z
+4809cc2cbf8fff0186064c974415a5a7
+2012-12-15T01:59:53.791806Z
+34688
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1956
+
diff --git a/package/platform/lantiq/ltq-hcd/src/.svn/text-base/Kconfig.svn-base b/package/platform/lantiq/ltq-hcd/src/.svn/text-base/Kconfig.svn-base
new file mode 100644
index 0000000..2a3a38d
--- /dev/null
+++ b/package/platform/lantiq/ltq-hcd/src/.svn/text-base/Kconfig.svn-base
@@ -0,0 +1,104 @@
+
+config USB_HOST_IFX
+ tristate "Infineon USB Host Controller Driver"
+ depends on USB
+ default n
+ help
+ Infineon USB Host Controller
+
+choice
+ prompt "Infineon USB Host Controller Driver Operation mode"
+ depends on USB_HOST_IFX && ( AMAZON_S || AR9 || VR9 || AR10 || MIPS_AMAZON_S || MIPS_AR9 || MIPS_VR9 || MIPS_AR10 )
+ help
+ The IFX USB core can be configured as dual-host and single host.
+ The unused core can be set as Device-mode.
+
+config USB_HOST_IFX_B
+ boolean "USB host mode on core 1 and 2"
+ help
+ Both cores run as host
+
+config USB_HOST_IFX_1
+ boolean "USB host mode on core 1 only"
+ help
+ Core #1 runs as host
+
+config USB_HOST_IFX_2
+ boolean "USB host mode on core 2 only"
+ help
+ Core #2 runs as host
+
+endchoice
+
+config USB_HOST_IFX_FORCE_USB11
+ boolean "Forced USB1.1"
+ depends on USB_HOST_IFX
+ default n
+ help
+ force to be USB 1.1
+
+config USB_HOST_IFX_WITH_HS_ELECT_TST
+ boolean "With HS_Electrical Test"
+ depends on USB_HOST_IFX
+ default n
+ help
+ With USBIF HSET routines
+
+config USB_HOST_IFX_WITH_ISO
+ boolean "With ISO transfer"
+ depends on USB_HOST_IFX
+ default n
+ help
+ With USBIF ISO transfer
+
+config USB_HOST_IFX_COC
+ boolean "CoC in USB Host"
+ depends on USB_HOST_IFX
+ default n
+ help
+ With CoC on Host
+
+choice
+ prompt "IFX unaligned buffer policy"
+ depends on USB_HOST_IFX
+ help
+ IFX unaligned buffer policy
+
+config USB_HOST_IFX_UNALIGNED_ADJ
+ boolean "Adjust"
+ help
+ USB_HOST_IFX_UNALIGNED_ADJ
+
+config USB_HOST_IFX_UNALIGNED_CHK
+ boolean "Check-only"
+ help
+ USB_HOST_IFX_UNALIGNED_CHK
+
+config USB_HOST_IFX_UNALIGNED_NONE
+ boolean "No process"
+ help
+ USB_HOST_IFX_UNALIGNED_NONE
+
+endchoice
+
+
+config USB_HOST_IFX_XHCI
+ tristate "xHCI HCD (USB 3.0) support (EXPERIMENTAL)"
+ depends on USB && PCI && ( VR9 || MIPS_VR9 || AR10 || MIPS_AR10 )
+ ---help---
+ The eXtensible Host Controller Interface (xHCI) is standard for USB 3.0
+ "SuperSpeed" host controller hardware.
+
+ To compile this driver as a module, choose M here: the
+ module will be called xhci-hcd.
+
+config USB_HOST_IFX_XHCI_DEBUGGING
+ bool "Debugging for the xHCI host controller"
+ depends on USB_HOST_IFX_XHCI
+ ---help---
+ Say 'Y' to turn on debugging for the xHCI host controller driver.
+ This will spew debugging output, even in interrupt context.
+ This should only be used for debugging xHCI driver bugs.
+
+ If unsure, say N.
+
diff --git a/package/platform/lantiq/ltq-hcd/src/.svn/text-base/Makefile.svn-base b/package/platform/lantiq/ltq-hcd/src/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..153fd42
--- /dev/null
+++ b/package/platform/lantiq/ltq-hcd/src/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,74 @@
+ltq_hcd_$(BUILD_VARIANT)-objs := ifxusb_driver.o ifxusb_ctl.o ifxusb_cif.o \
+ ifxusb_cif_h.o ifxhcd.o ifxhcd_es.o \
+ ifxhcd_intr.o ifxhcd_queue.o
+obj-m = ltq_hcd_$(BUILD_VARIANT).o
+
+ifeq ($(BUILD_VARIANT),danube)
+ EXTRA_CFLAGS += -D__IS_DANUBE__
+endif
+
+ifeq ($(BUILD_VARIANT),ase)
+ EXTRA_CFLAGS += -D__IS_AMAZON_SE__
+endif
+
+ifeq ($(BUILD_VARIANT),ar9)
+ EXTRA_CFLAGS += -D__IS_AR9__
+ EXTRA_CFLAGS += -D__IS_DUAL__
+endif
+
+ifeq ($(BUILD_VARIANT),vr9)
+ EXTRA_CFLAGS += -D__IS_VR9__
+ EXTRA_CFLAGS += -D__PHY_LONG_PREEMP__
+ EXTRA_CFLAGS += -D__PINGSTOP_CTRL__
+ EXTRA_CFLAGS += -D__PINGSTOP_BULK__
+ EXTRA_CFLAGS += -D__IS_DUAL__
+endif
+
+ifeq ($(BUILD_VARIANT),ar10)
+ EXTRA_CFLAGS += -D__IS_AR10__
+ EXTRA_CFLAGS += -D__PHY_LONG_PREEMP__
+ EXTRA_CFLAGS += -D__PINGSTOP_CTRL__
+ EXTRA_CFLAGS += -D__PINGSTOP_BULK__
+endif
+
+ifeq ($(CONFIG_USB_HOST_IFX_FORCE_USB11),y)
+ EXTRA_CFLAGS += -D__FORCE_USB11__
+endif
+ifeq ($(CONFIG_USB_HOST_IFX_WITH_HS_ELECT_TST),y)
+ EXTRA_CFLAGS += -D__WITH_HS_ELECT_TST__
+endif
+ifeq ($(CONFIG_USB_HOST_IFX_WITH_ISO),y)
+ EXTRA_CFLAGS += -D__EN_ISOC__
+endif
+#ifeq ($(CONFIG_USB_HOST_IFX_UNALIGNED_ADJ),y)
+ EXTRA_CFLAGS += -D__UNALIGNED_BUF_ADJ__
+#endif
+ifeq ($(CONFIG_USB_HOST_IFX_UNALIGNED_CHK),y)
+ EXTRA_CFLAGS += -D__UNALIGNED_BUF_CHK__
+endif
+ifeq ($(CONFIG_USB_HOST_IFX_COC),y)
+ EXTRA_CFLAGS += -D__HOST_COC__
+endif
+
+# EXTRA_CFLAGS += -D__IS_FIRST__
+# EXTRA_CFLAGS += -D__IS_SECOND__
+
+# EXTRA_CFLAGS += -D__EN_ISOC__
+# EXTRA_CFLAGS += -D__EN_ISOC_SPLIT__
+# EXTRA_CFLAGS += -D__EPQD_DESTROY_TIMEOUT__
+# EXTRA_CFLAGS += -D__INNAKSTOP_CTRL__
+
+EXTRA_CFLAGS += -Dlinux -D__LINUX__
+EXTRA_CFLAGS += -D__IS_HOST__
+EXTRA_CFLAGS += -D__KERNEL__
+#EXTRA_CFLAGS += -D__DEBUG__
+#EXTRA_CFLAGS += -D__ENABLE_DUMP__
+
+EXTRA_CFLAGS += -D__DYN_SOF_INTR__
+EXTRA_CFLAGS += -D__UEIP__
+EXTRA_CFLAGS += -D__DO_OC_INT__
+EXTRA_CFLAGS += -D__INNAKSTOP_BULK__
+
+EXTRA_CFLAGS += -D__INTRNAKRETRY__
+EXTRA_CFLAGS += -D__INTRINCRETRY__
+
diff --git a/package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxhcd.c.svn-base b/package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxhcd.c.svn-base
new file mode 100644
index 0000000..be0a91d
--- /dev/null
+++ b/package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxhcd.c.svn-base
@@ -0,0 +1,2141 @@
+/*****************************************************************************
+ ** FILE NAME : ifxhcd.c
+ ** PROJECT : IFX USB sub-system V3
+ ** MODULES : IFX USB sub-system Host and Device driver
+ ** SRC VERSION : 3.2
+ ** DATE : 1/Jan/2011
+ ** AUTHOR : Chen, Howard
+ ** DESCRIPTION : This file contains the structures, constants, and
+ ** interfaces for the Host Contoller Driver (HCD).
+ **
+ ** The Host Controller Driver (HCD) is responsible for
+ ** translating requests from the USB Driver into the
+ ** appropriate actions on the IFXUSB controller.
+ ** It isolates the USBD from the specifics of the
+ ** controller by providing an API to the USBD.
+ ** FUNCTIONS :
+ ** COMPILER : gcc
+ ** REFERENCE : Synopsys DWC-OTG Driver 2.7
+ ** COPYRIGHT : Copyright (c) 2010
+ ** LANTIQ DEUTSCHLAND GMBH,
+ ** Am Campeon 3, 85579 Neubiberg, Germany
+ **
+ ** 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 of the License, or
+ ** (at your option) any later version.
+ **
+ ** Version Control Section **
+ ** $Author$
+ ** $Date$
+ ** $Revisions$
+ ** $Log$ Revision history
+ *****************************************************************************/
+
+/*
+ * This file contains code fragments from Synopsys HS OTG Linux Software Driver.
+ * For this code the following notice is applicable:
+ *
+ * ==========================================================================
+ *
+ * Synopsys HS OTG Linux Software Driver and documentation (hereinafter,
+ * "Software") is an Unsupported proprietary work of Synopsys, Inc. unless
+ * otherwise expressly agreed to in writing between Synopsys and you.
+ *
+ * The Software IS NOT an item of Licensed Software or Licensed Product under
+ * any End User Software License Agreement or Agreement for Licensed Product
+ * with Synopsys or any supplement thereto. You are permitted to use and
+ * redistribute this Software in source and binary forms, with or without
+ * modification, provided that redistributions of source code must retain this
+ * notice. You may not view, use, disclose, copy or distribute this file or
+ * any information contained herein except pursuant to this license grant from
+ * Synopsys. If you do not agree with this notice, including the disclaimer
+ * below, then you are not authorized to use the Software.
+ *
+ * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" BASIS
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ * ========================================================================== */
+
+/*!
+ \file ifxhcd.c
+ \ingroup IFXUSB_DRIVER_V3
+ \brief This file contains the implementation of the HCD. In Linux,
+ the HCD implements the hc_driver API.
+*/
+
+#include <linux/version.h>
+#include "ifxusb_version.h"
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/init.h>
+
+#include <linux/device.h>
+
+#include <linux/errno.h>
+#include <linux/list.h>
+#include <linux/interrupt.h>
+#include <linux/string.h>
+
+#include <linux/dma-mapping.h>
+
+
+#include "ifxusb_plat.h"
+#include "ifxusb_regs.h"
+#include "ifxusb_cif.h"
+#include "ifxhcd.h"
+
+#include <asm/irq.h>
+
+#ifdef __DEBUG__
+ static void dump_urb_info(struct urb *_urb, char* _fn_name);
+#if 0
+ static void dump_channel_info(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_epqh_t *_epqh);
+#endif
+#endif
+
+static void ifxhcd_complete_urb_sub(ifxhcd_urbd_t *_urbd)
+{
+ ifxhcd_hcd_t *ifxhcd;
+ struct urb *urb=NULL;
+
+ if (!list_empty(&_urbd->ql))
+ {
+ list_del_init(&_urbd->ql);
+ _urbd->epqh->urbd_count--;
+ }
+ else
+ IFX_ERROR("%s: urb(%p) not connect to any epqh\n",
+ __func__,_urbd);
+
+ ifxhcd=_urbd->epqh->ifxhcd;
+ urb =_urbd->urb;
+ if(!urb)
+ IFX_ERROR("%s: invalid urb\n",__func__);
+ else if(urb->hcpriv)
+ {
+ if(urb->hcpriv != _urbd)
+ IFX_ERROR("%s: invalid"
+ " urb(%p)->hcpriv(%p) != _urbd(%p)\n",
+ __func__,
+ urb,
+ urb->hcpriv,
+ _urbd);
+ #if defined(__UNALIGNED_BUF_ADJ__)
+ if(_urbd->is_in &&
+// _urbd->using_aligned_buf &&
+ _urbd->aligned_buf)
+ memcpy(_urbd->xfer_buff,
+ _urbd->aligned_buf,
+ _urbd->xfer_len);
+ if(_urbd->aligned_buf)
+ ifxusb_free_buf_h(_urbd->aligned_buf);
+ #endif
+ urb->hcpriv = NULL;
+ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)
+ urb->status=_urbd->status;
+ usb_hcd_giveback_urb(ifxhcd_to_syshcd(ifxhcd), urb);
+ #else
+ usb_hcd_giveback_urb(ifxhcd_to_syshcd(ifxhcd), urb,
+ _urbd->status);
+ #endif
+ }
+ kfree(_urbd);
+}
+
+#ifdef __STRICT_ORDER__
+ static void ifxhcd_complete_urb_func(unsigned long data)
+ {
+ unsigned long flags;
+ ifxhcd_urbd_t *urbd;
+ ifxhcd_epqh_t *epqh;
+ struct list_head *item;
+
+ int count=10;
+
+ epqh=((ifxhcd_epqh_t *)data);
+
+ while (!list_empty(&epqh->release_list) && count)
+ {
+ item = epqh->release_list.next;
+ urbd = list_entry(item, ifxhcd_urbd_t, ql);
+ if (!urbd)
+ IFX_ERROR("%s: invalid urbd\n",__func__);
+ else if (!urbd->epqh)
+ IFX_ERROR("%s: invalid epqd\n",__func__);
+ else
+ {
+ ifxhcd_epqh_t *epqh2;
+ epqh2=urbd->epqh;
+ local_irq_save(flags);
+ LOCK_URBD_LIST(epqh2);
+ ifxhcd_complete_urb_sub(urbd);
+ UNLOCK_URBD_LIST(epqh2);
+ local_irq_restore (flags);
+ }
+ count--;
+ }
+ if(!list_empty(&epqh->release_list))
+ tasklet_schedule(&epqh->complete_urb_sub);
+ }
+
+ /*!
+ \brief Sets the final status of an URB and returns it to the device
+ driver. Any required cleanup of the URB is performed.
+ */
+ void ifxhcd_complete_urb(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_urbd_t *_urbd,
+ int _status)
+ {
+ unsigned long flags;
+
+ if(!_urbd)
+ {
+ IFX_ERROR("%s: invalid urbd\n",__func__);
+ return;
+ }
+ if (!_urbd->epqh)
+ {
+ IFX_ERROR("%s: invalid epqh\n",__func__);
+ return;
+ }
+
+ local_irq_save(flags);
+ LOCK_URBD_LIST(_urbd->epqh);
+ #ifdef __DEBUG__
+ if (CHK_DEBUG_LEVEL(DBG_HCDV | DBG_HCD_URB))
+ {
+ IFX_PRINT("%s: ehqh %p _urbd %p, urb %p,"
+ " device %d, ep %d %s/%s, status=%d\n",
+ __func__,_urbd->epqh,
+ _urbd,_urbd->urb,
+ (_urbd->urb)?usb_pipedevice(_urbd->urb->pipe):-1,
+ (_urbd->urb)?usb_pipeendpoint(_urbd->urb->pipe):-1,
+ (_urbd->urb)?(usb_pipein(_urbd->urb->pipe) ? "IN" : "OUT"):"--",
+ (_urbd->is_in) ? "IN" : "OUT",
+ _status);
+ if ((_urbd->urb)&& _urbd->epqh->ep_type == IFXUSB_EP_TYPE_ISOC)
+ {
+ int i;
+ for (i = 0; i < _urbd->urb->number_of_packets; i++)
+ IFX_PRINT(" ISO Desc %d status: %d\n", i, _urbd->urb->iso_frame_desc[i].status);
+ }
+ }
+ #endif
+ _urbd->status = _status;
+
+ if(_urbd->phase!=URBD_FINISHING)
+ {
+ if(_urbd->phase!=URBD_DEQUEUEING && _urbd->phase!=URBD_COMPLETING)
+ printk(KERN_INFO "Warning: %s() Strange URBD PHASE %d\n",__func__,_urbd->phase);
+ if(_urbd->urb)
+ {
+ if( _urbd->status == 0
+ && _urbd->phase==URBD_COMPLETING
+ && in_irq())
+ {
+ list_move_tail(&_urbd->ql,&_urbd->epqh->release_list);
+ if(!_urbd->epqh->complete_urb_sub.func)
+ {
+ _urbd->epqh->complete_urb_sub.next = NULL;
+ _urbd->epqh->complete_urb_sub.state = 0;
+ atomic_set( &_urbd->epqh->complete_urb_sub.count, 0);
+ _urbd->epqh->complete_urb_sub.func = ifxhcd_complete_urb_func;
+ _urbd->epqh->complete_urb_sub.data = (unsigned long)_urbd->epqh;
+ }
+ tasklet_schedule(&_urbd->epqh->complete_urb_sub);
+ }
+ else
+ {
+ _urbd->phase=URBD_FINISHING;
+ ifxhcd_complete_urb_sub(_urbd);
+ }
+ UNLOCK_URBD_LIST(_urbd->epqh);
+ }
+ else
+ {
+ UNLOCK_URBD_LIST(_urbd->epqh);
+ kfree(_urbd);
+ }
+ }
+ else
+ {
+ printk(KERN_INFO "Warning: %s() Double Completing \n",__func__);
+ UNLOCK_URBD_LIST(_urbd->epqh);
+ }
+
+ local_irq_restore (flags);
+ }
+#else
+ static void ifxhcd_complete_urb_func(unsigned long data)
+ {
+ unsigned long flags;
+ ifxhcd_urbd_t *urbd;
+
+ urbd=((ifxhcd_urbd_t *)data);
+
+ // local_irq_save(flags);
+ if (!urbd)
+ IFX_ERROR("%s: invalid urbd\n",__func__);
+ else if (!urbd->epqh)
+ IFX_ERROR("%s: invalid epqd\n",__func__);
+ else
+ {
+ local_irq_save(flags);
+ LOCK_URBD_LIST(urbd->epqh);
+ ifxhcd_complete_urb_sub(urbd);
+ UNLOCK_URBD_LIST(urbd->epqh);
+ local_irq_restore (flags);
+ }
+ // local_irq_restore (flags);
+ }
+
+
+ /*!
+ \brief Sets the final status of an URB and returns it to the device driver. Any
+ required cleanup of the URB is performed.
+ */
+ void ifxhcd_complete_urb(ifxhcd_hcd_t *_ifxhcd, ifxhcd_urbd_t *_urbd, int _status)
+ {
+ unsigned long flags;
+
+ if(!_urbd)
+ {
+ IFX_ERROR("%s: invalid urbd\n",__func__);
+ return;
+ }
+ if (!_urbd->epqh)
+ {
+ IFX_ERROR("%s: invalid epqh\n",__func__);
+ return;
+ }
+
+ local_irq_save(flags);
+ LOCK_URBD_LIST(_urbd->epqh);
+ #ifdef __DEBUG__
+ if (CHK_DEBUG_LEVEL(DBG_HCDV | DBG_HCD_URB))
+ {
+ IFX_PRINT("%s: ehqh %p _urbd %p, urb %p, device %d, ep %d %s/%s, status=%d\n",
+ __func__,_urbd->epqh, _urbd,_urbd->urb,
+ (_urbd->urb)?usb_pipedevice(_urbd->urb->pipe):-1,
+ (_urbd->urb)?usb_pipeendpoint(_urbd->urb->pipe):-1,
+ (_urbd->urb)?(usb_pipein(_urbd->urb->pipe) ? "IN" : "OUT"):"--",
+ (_urbd->is_in) ? "IN" : "OUT",
+ _status);
+ if ((_urbd->urb)&& _urbd->epqh->ep_type == IFXUSB_EP_TYPE_ISOC)
+ {
+ int i;
+ for (i = 0; i < _urbd->urb->number_of_packets; i++)
+ IFX_PRINT(" ISO Desc %d status: %d\n", i, _urbd->urb->iso_frame_desc[i].status);
+ }
+ }
+ #endif
+ _urbd->status = _status;
+
+ if(_urbd->phase!=URBD_FINISHING)
+ {
+ if(_urbd->phase!=URBD_DEQUEUEING && _urbd->phase!=URBD_COMPLETING)
+ printk(KERN_INFO "Warning: %s() Strange URBD PHASE %d\n",__func__,_urbd->phase);
+ if(_urbd->urb)
+ {
+ if( _urbd->status == 0
+ && _urbd->phase==URBD_COMPLETING
+ && in_irq())
+ {
+ if(_urbd->complete_urb_sub.func)
+ printk(KERN_INFO "Warning: %s() URBD Tasklet is on already\n",__func__);
+ _urbd->phase=URBD_FINISHING;
+ _urbd->complete_urb_sub.next = NULL;
+ _urbd->complete_urb_sub.state = 0;
+ atomic_set( &_urbd->complete_urb_sub.count, 0);
+ _urbd->complete_urb_sub.func = ifxhcd_complete_urb_func;
+ _urbd->complete_urb_sub.data = (unsigned long)_urbd;
+ tasklet_schedule(&_urbd->complete_urb_sub);
+ }
+ else
+ {
+ _urbd->phase=URBD_FINISHING;
+ ifxhcd_complete_urb_sub(_urbd);
+ }
+ }
+ else
+ kfree(_urbd);
+ }
+ else
+ printk(KERN_INFO "Warning: %s() Double Completing \n",__func__);
+ UNLOCK_URBD_LIST(_urbd->epqh);
+ local_irq_restore (flags);
+ }
+#endif
+
+/*!
+ \brief Processes all the URBs in a single EPQHs. Completes them with
+ status and frees the URBD.
+ */
+static
+void kill_all_urbs_in_epqh(ifxhcd_hcd_t *_ifxhcd, ifxhcd_epqh_t *_epqh, int _status)
+{
+ struct list_head *item;
+ struct list_head *next;
+ ifxhcd_urbd_t *urbd;
+
+ if(!_epqh)
+ return;
+
+ IFX_DEBUGPL(DBG_HCDV, "%s %p\n",__func__,_epqh);
+ LOCK_URBD_LIST(_epqh);
+ list_for_each(item, &_epqh->urbd_list)
+ {
+ urbd = list_entry(item, ifxhcd_urbd_t, ql);
+ if( urbd->phase==URBD_IDLE
+ || urbd->phase==URBD_ACTIVE
+// || urbd->phase==URBD_STARTING
+ )
+ urbd->phase=URBD_DEQUEUEING;
+ }
+ list_for_each_safe(item, next, &_epqh->urbd_list)
+ {
+ urbd = list_entry(item, ifxhcd_urbd_t, ql);
+ if(urbd->phase==URBD_DEQUEUEING)
+ {
+ urbd->urb->status = _status;
+ urbd->phase = URBD_FINISHING;
+ ifxhcd_complete_urb_sub(urbd);
+ }
+ else if( urbd->phase==URBD_STARTED
+ || urbd->phase==URBD_STARTING
+// || urbd->phase==URBD_ACTIVE
+ )
+ {
+ if(ifxhcd_hc_halt(&_ifxhcd->core_if, _epqh->hc, HC_XFER_URB_DEQUEUE))
+ {
+ urbd->urb->status = _status;
+ urbd->phase=URBD_FINISHING;
+ ifxhcd_complete_urb_sub(urbd);
+ }
+ }
+ else
+ IFX_ERROR("%s: invalid urb phase:%d \n",__func__,urbd->phase);
+ }
+ UNLOCK_URBD_LIST(_epqh);
+ IFX_DEBUGPL(DBG_HCDV, "%s %p finish\n",__func__,_epqh);
+}
+
+
+/*!
+ \brief Free all EPS in one Processes all the URBs in a single list of EPQHs. Completes them with
+ -ETIMEDOUT and frees the URBD.
+ */
+static
+void epqh_list_free_1(ifxhcd_hcd_t *_ifxhcd, struct list_head *_epqh_list)
+{
+ ifxhcd_epqh_t *epqh;
+ struct list_head *item;
+ if (!_ifxhcd)
+ return;
+ if (!_epqh_list)
+ return;
+
+ IFX_DEBUGPL(DBG_HCDV, "%s %p\n",__func__,_epqh_list);
+
+ item = _epqh_list->next;
+ while(item != _epqh_list && item != item->next)
+ {
+ epqh = list_entry(item, ifxhcd_epqh_t, ql);
+ epqh->phase=EPQH_DISABLING;
+ item = item->next;
+ kill_all_urbs_in_epqh(_ifxhcd, epqh, -ETIMEDOUT);
+ #ifdef __STRICT_ORDER__
+ if(list_empty(&epqh->urbd_list) && list_empty(&epqh->release_list))
+ #else
+ if(list_empty(&epqh->urbd_list))
+ #endif
+ ifxhcd_epqh_free(epqh);
+ }
+ IFX_DEBUGPL(DBG_HCDV, "%s %p finish\n",__func__,_epqh_list);
+ /* Ensure there are no URBDs or URBs left. */
+}
+
+static
+void epqh_list_free_2(ifxhcd_hcd_t *_ifxhcd, struct list_head *_epqh_list)
+{
+ ifxhcd_epqh_t *epqh;
+ struct list_head *item;
+ struct list_head *next;
+ if (!_ifxhcd)
+ return;
+ if (!_epqh_list)
+ return;
+
+ IFX_DEBUGPL(DBG_HCDV, "%s %p\n",__func__,_epqh_list);
+ list_for_each_safe(item, next, _epqh_list)
+ {
+ epqh = list_entry(item, ifxhcd_epqh_t, ql);
+ if(item == item->next)
+ {
+ ifxhcd_epqh_free(epqh);
+ }
+ else
+ {
+ uint32_t count=0x80000;
+ #ifdef __STRICT_ORDER__
+ for(;(!list_empty(&epqh->urbd_list) || !list_empty(&epqh->release_list))&& count> 0; count--) udelay(1);
+ #else
+ for(;!list_empty(&epqh->urbd_list) && count> 0; count--) udelay(1);
+ #endif
+ if(!count)
+ IFX_ERROR("%s: unable to clear urbd in epqh \n",__func__);
+ ifxhcd_epqh_free(epqh);
+ }
+ }
+ IFX_DEBUGPL(DBG_HCDV, "%s %p finish\n",__func__,_epqh_list);
+ /* Ensure there are no URBDs or URBs left. */
+}
+
+static
+void epqh_list_free_all_sub(unsigned long data)
+{
+ ifxhcd_hcd_t *ifxhcd;
+
+ ifxhcd=(ifxhcd_hcd_t *)data;
+ epqh_list_free_1(ifxhcd, &ifxhcd->epqh_list_np );
+ epqh_list_free_1(ifxhcd, &ifxhcd->epqh_list_intr);
+ #ifdef __EN_ISOC__
+ epqh_list_free_1(ifxhcd, &ifxhcd->epqh_list_isoc);
+ #endif
+
+ epqh_list_free_2(ifxhcd, &ifxhcd->epqh_list_np );
+ epqh_list_free_2(ifxhcd, &ifxhcd->epqh_list_intr);
+ #ifdef __EN_ISOC__
+ epqh_list_free_2(ifxhcd, &ifxhcd->epqh_list_isoc);
+ #endif
+}
+
+static
+void epqh_list_free_all(ifxhcd_hcd_t *_ifxhcd)
+{
+ _ifxhcd->tasklet_free_epqh_list.next = NULL;
+ _ifxhcd->tasklet_free_epqh_list.state = 0;
+ atomic_set( &_ifxhcd->tasklet_free_epqh_list.count, 0);
+ _ifxhcd->tasklet_free_epqh_list.func=epqh_list_free_all_sub;
+ _ifxhcd->tasklet_free_epqh_list.data = (unsigned long)_ifxhcd;
+ tasklet_schedule(&_ifxhcd->tasklet_free_epqh_list);
+}
+
+
+/*!
+ \brief This function is called to handle the disconnection of host port.
+ */
+int32_t ifxhcd_disconnect(ifxhcd_hcd_t *_ifxhcd)
+{
+ IFX_DEBUGPL(DBG_HCDV, "%s(%p)\n", __func__, _ifxhcd);
+
+ _ifxhcd->disconnecting=1;
+ /* Set status flags for the hub driver. */
+ _ifxhcd->flags.b.port_connect_status_change = 1;
+ _ifxhcd->flags.b.port_connect_status = 0;
+
+ /*
+ * Shutdown any transfers in process by clearing the Tx FIFO Empty
+ * interrupt mask and status bits and disabling subsequent host
+ * channel interrupts.
+ */
+ {
+ gint_data_t intr = { .d32 = 0 };
+ intr.b.nptxfempty = 1;
+ intr.b.ptxfempty = 1;
+ intr.b.hcintr = 1;
+ ifxusb_mreg (&_ifxhcd->core_if.core_global_regs->gintmsk, intr.d32, 0);
+ ifxusb_mreg (&_ifxhcd->core_if.core_global_regs->gintsts, intr.d32, 0);
+ }
+
+ /* Respond with an error status to all URBs in the schedule. */
+ epqh_list_free_all(_ifxhcd);
+
+ /* Clean up any host channels that were in use. */
+ {
+ int num_channels;
+ ifxhcd_hc_t *channel;
+ ifxusb_hc_regs_t *hc_regs;
+ hcchar_data_t hcchar;
+ int i;
+
+ num_channels = _ifxhcd->core_if.params.host_channels;
+
+ for (i = 0; i < num_channels; i++)
+ {
+ channel = &_ifxhcd->ifxhc[i];
+ hc_regs = _ifxhcd->core_if.hc_regs[i];
+ hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
+ if (hcchar.b.chen)
+ printk(KERN_INFO "Warning: %s() HC still enabled\n",__func__);
+ ifxhcd_hc_cleanup(&_ifxhcd->core_if, channel);
+ }
+ }
+ IFX_DEBUGPL(DBG_HCDV, "%s(%p) finish\n", __func__, _ifxhcd);
+ return 1;
+}
+
+
+/*!
+ \brief Frees secondary storage associated with the ifxhcd_hcd structure contained
+ in the struct usb_hcd field.
+ */
+static void ifxhcd_freeextra(struct usb_hcd *_syshcd)
+{
+ ifxhcd_hcd_t *ifxhcd = syshcd_to_ifxhcd(_syshcd);
+
+ IFX_DEBUGPL(DBG_HCD, "IFXUSB HCD FREE\n");
+
+ /* Free memory for EPQH/URBD lists */
+ epqh_list_free_all(ifxhcd);
+
+ /* Free memory for the host channels. */
+ ifxusb_free_buf_h(ifxhcd->status_buf);
+ return;
+}
+
+/*!
+ \brief Initializes the HCD. This function allocates memory for and initializes the
+ static parts of the usb_hcd and ifxhcd_hcd structures. It also registers the
+ USB bus with the core and calls the hc_driver->start() function. It returns
+ a negative error on failure.
+ */
+int ifxhcd_init(ifxhcd_hcd_t *_ifxhcd)
+{
+ int retval = 0;
+ struct usb_hcd *syshcd = NULL;
+
+ IFX_DEBUGPL(DBG_HCD, "IFX USB HCD INIT\n");
+
+ INIT_EPQH_LIST_ALL(_ifxhcd);
+ INIT_EPQH_LIST(_ifxhcd);
+
+ init_timer(&_ifxhcd->autoprobe_timer);
+ init_timer(&_ifxhcd->host_probe_timer);
+ _ifxhcd->probe_sec = 5;
+ _ifxhcd->autoprobe_sec = 30;
+
+ _ifxhcd->hc_driver.description = _ifxhcd->core_if.core_name;
+ _ifxhcd->hc_driver.product_desc = "IFX USB Controller";
+ //_ifxhcd->hc_driver.hcd_priv_size = sizeof(ifxhcd_hcd_t);
+ _ifxhcd->hc_driver.hcd_priv_size = sizeof(unsigned long);
+ _ifxhcd->hc_driver.irq = ifxhcd_irq;
+ _ifxhcd->hc_driver.flags = HCD_MEMORY | HCD_USB2;
+ _ifxhcd->hc_driver.start = ifxhcd_start;
+ _ifxhcd->hc_driver.stop = ifxhcd_stop;
+ //_ifxhcd->hc_driver.reset =
+ //_ifxhcd->hc_driver.suspend =
+ //_ifxhcd->hc_driver.resume =
+ _ifxhcd->hc_driver.urb_enqueue = ifxhcd_urb_enqueue;
+ _ifxhcd->hc_driver.urb_dequeue = ifxhcd_urb_dequeue;
+ _ifxhcd->hc_driver.endpoint_disable = ifxhcd_endpoint_disable;
+ _ifxhcd->hc_driver.get_frame_number = ifxhcd_get_frame_number;
+ _ifxhcd->hc_driver.hub_status_data = ifxhcd_hub_status_data;
+ _ifxhcd->hc_driver.hub_control = ifxhcd_hub_control;
+ //_ifxhcd->hc_driver.hub_suspend =
+ //_ifxhcd->hc_driver.hub_resume =
+ _ifxhcd->pkt_remaining_reload_hs=PKT_REMAINING_RELOAD_HS;
+ _ifxhcd->pkt_remaining_reload_fs=PKT_REMAINING_RELOAD_FS;
+ _ifxhcd->pkt_remaining_reload_ls=PKT_REMAINING_RELOAD_LS;
+ _ifxhcd->pkt_count_limit_bo =8;
+ _ifxhcd->pkt_count_limit_bi =8;
+
+ /* Allocate memory for and initialize the base HCD and */
+ //syshcd = usb_create_hcd(&_ifxhcd->hc_driver, _ifxhcd->dev, _ifxhcd->dev->bus_id);
+ syshcd = usb_create_hcd(&_ifxhcd->hc_driver, _ifxhcd->dev, _ifxhcd->core_if.core_name);
+
+ if (syshcd == NULL)
+ {
+ retval = -ENOMEM;
+ goto error1;
+ }
+
+ syshcd->rsrc_start = (unsigned long)_ifxhcd->core_if.core_global_regs;
+ syshcd->regs = (void *)_ifxhcd->core_if.core_global_regs;
+ syshcd->self.otg_port = 0;
+
+ //*((unsigned long *)(&(syshcd->hcd_priv)))=(unsigned long)_ifxhcd;
+ //*((unsigned long *)(&(syshcd->hcd_priv[0])))=(unsigned long)_ifxhcd;
+ syshcd->hcd_priv[0]=(unsigned long)_ifxhcd;
+ _ifxhcd->syshcd=syshcd;
+ INIT_LIST_HEAD(&_ifxhcd->epqh_list_all );
+ INIT_LIST_HEAD(&_ifxhcd->epqh_list_np );
+ INIT_LIST_HEAD(&_ifxhcd->epqh_list_intr );
+ #ifdef __EN_ISOC__
+ INIT_LIST_HEAD(&_ifxhcd->epqh_list_isoc);
+ #endif
+
+ /*
+ * Create a host channel descriptor for each host channel implemented
+ * in the controller. Initialize the channel descriptor array.
+ */
+ {
+ int num_channels = _ifxhcd->core_if.params.host_channels;
+ int i;
+ for (i = 0; i < num_channels; i++)
+ {
+ _ifxhcd->ifxhc[i].hc_num = i;
+ IFX_DEBUGPL(DBG_HCDV, "HCD Added channel #%d\n", i);
+ }
+ }
+
+ /* Set device flags indicating whether the HCD supports DMA. */
+ if(_ifxhcd->dev->dma_mask)
+ *(_ifxhcd->dev->dma_mask) = ~0;
+ _ifxhcd->dev->coherent_dma_mask = ~0;
+
+ /*
+ * Finish generic HCD initialization and start the HCD. This function
+ * allocates the DMA buffer pool, registers the USB bus, requests the
+ * IRQ line, and calls ifxusb_hcd_start method.
+ */
+ retval = usb_add_hcd(syshcd, _ifxhcd->core_if.irq, 0
+ |IRQF_DISABLED
+ |IRQF_SHARED
+ );
+ if (retval < 0)
+ goto error2;
+
+ /*
+ * Allocate space for storing data on status transactions. Normally no
+ * data is sent, but this space acts as a bit bucket. This must be
+ * done after usb_add_hcd since that function allocates the DMA buffer
+ * pool.
+ */
+ _ifxhcd->status_buf = ifxusb_alloc_buf_h(IFXHCD_STATUS_BUF_SIZE, 1);
+
+ if (_ifxhcd->status_buf)
+ {
+ IFX_DEBUGPL(DBG_HCD, "IFX USB HCD Initialized, bus=%s, usbbus=%d\n", _ifxhcd->core_if.core_name, syshcd->self.busnum);
+ return 0;
+ }
+ IFX_ERROR("%s: status_buf allocation failed\n", __func__);
+
+ /* Error conditions */
+ usb_remove_hcd(syshcd);
+error2:
+ ifxhcd_freeextra(syshcd);
+ usb_put_hcd(syshcd);
+error1:
+ return retval;
+}
+
+/*!
+ \brief Removes the HCD.
+ Frees memory and resources associated with the HCD and deregisters the bus.
+ */
+void ifxhcd_remove(ifxhcd_hcd_t *_ifxhcd)
+{
+ struct usb_hcd *syshcd = ifxhcd_to_syshcd(_ifxhcd);
+
+ IFX_DEBUGPL(DBG_HCD, "IFX USB HCD REMOVE\n");
+
+ /* Turn off all interrupts */
+ ifxusb_wreg (&_ifxhcd->core_if.core_global_regs->gintmsk, 0);
+ ifxusb_mreg (&_ifxhcd->core_if.core_global_regs->gahbcfg, 1, 0);
+
+ usb_remove_hcd(syshcd);
+ ifxhcd_freeextra(syshcd);
+ usb_put_hcd(syshcd);
+
+ return;
+}
+
+
+/* =========================================================================
+ * Linux HC Driver Functions
+ * ========================================================================= */
+
+/*!
+ \brief Initializes the IFXUSB controller and its root hub and prepares it for host
+ mode operation. Activates the root port. Returns 0 on success and a negative
+ error code on failure.
+ Called by USB stack.
+ */
+int ifxhcd_start(struct usb_hcd *_syshcd)
+{
+ ifxhcd_hcd_t *ifxhcd = syshcd_to_ifxhcd (_syshcd);
+ ifxusb_core_if_t *core_if = &ifxhcd->core_if;
+ struct usb_bus *bus;
+
+ IFX_DEBUGPL(DBG_HCD, "IFX USB HCD START\n");
+
+ bus = hcd_to_bus(_syshcd);
+
+ /* Initialize the bus state. */
+ _syshcd->state = HC_STATE_RUNNING;
+
+ /* Initialize and connect root hub if one is not already attached */
+ if (bus->root_hub)
+ {
+ IFX_DEBUGPL(DBG_HCD, "IFX USB HCD Has Root Hub\n");
+ /* Inform the HUB driver to resume. */
+ usb_hcd_resume_root_hub(_syshcd);
+ }
+
+ ifxhcd->flags.d32 = 0;
+
+ /* Put all channels in the free channel list and clean up channel states.*/
+ {
+ int num_channels = ifxhcd->core_if.params.host_channels;
+ int i;
+ for (i = 0; i < num_channels; i++)
+ {
+ ifxhcd_hc_t *channel;
+ channel = &ifxhcd->ifxhc[i];
+ ifxhcd_hc_cleanup(&ifxhcd->core_if, channel);
+ }
+ }
+ /* Initialize the USB core for host mode operation. */
+
+ ifxusb_host_enable_interrupts(core_if);
+ ifxusb_enable_global_interrupts_h(core_if);
+ ifxusb_phy_power_on_h (core_if);
+
+ ifxusb_vbus_init(core_if);
+
+ /* Turn on the vbus power. */
+ {
+ hprt0_data_t hprt0;
+ hprt0.d32 = ifxusb_read_hprt0(core_if);
+
+ IFX_PRINT("Init: Power Port (%d)\n", hprt0.b.prtpwr);
+ if (hprt0.b.prtpwr == 0 )
+ {
+ hprt0.b.prtpwr = 1;
+ ifxusb_wreg(core_if->hprt0, hprt0.d32);
+ ifxusb_vbus_on(core_if);
+ }
+ }
+ return 0;
+}
+
+/*!
+ \brief Halts the IFXUSB host mode operations in a clean manner. USB transfers are
+ stopped.
+ */
+ #if defined(__IS_AR10__)
+void ifxusb_oc_int_free(int port);
+ #else
+void ifxusb_oc_int_free(void);
+ #endif
+
+void ifxhcd_stop(struct usb_hcd *_syshcd)
+{
+ ifxhcd_hcd_t *ifxhcd = syshcd_to_ifxhcd(_syshcd);
+ hprt0_data_t hprt0 = { .d32=0 };
+
+ IFX_DEBUGPL(DBG_HCD, "IFX USB HCD STOP\n");
+
+ /* Turn off all interrupts. */
+ ifxusb_disable_global_interrupts_h(&ifxhcd->core_if );
+ ifxusb_host_disable_interrupts(&ifxhcd->core_if );
+
+ /*
+ * The root hub should be disconnected before this function is called.
+ * The disconnect will clear the URBD lists (via ..._hcd_urb_dequeue)
+ * and the EPQH lists (via ..._hcd_endpoint_disable).
+ */
+
+ /* Turn off the vbus power */
+ IFX_PRINT("PortPower off\n");
+
+ ifxusb_vbus_off(&ifxhcd->core_if );
+
+
+ #if defined(__IS_AR10__)
+ ifxusb_oc_int_free(ifxhcd->core_if.core_no);
+ #else
+ ifxusb_oc_int_free();
+ #endif
+
+
+ ifxusb_vbus_free(&ifxhcd->core_if );
+ hprt0.b.prtpwr = 0;
+ ifxusb_wreg(ifxhcd->core_if.hprt0, hprt0.d32);
+ return;
+}
+
+/*!
+ \brief Returns the current frame number
+ */
+int ifxhcd_get_frame_number(struct usb_hcd *_syshcd)
+{
+ ifxhcd_hcd_t *ifxhcd = syshcd_to_ifxhcd(_syshcd);
+ hfnum_data_t hfnum;
+
+ hfnum.d32 = ifxusb_rreg(&ifxhcd->core_if.host_global_regs->hfnum);
+
+ return hfnum.b.frnum;
+}
+
+/*!
+ \brief Starts processing a USB transfer request specified by a USB Request Block
+ (URB). mem_flags indicates the type of memory allocation to use while
+ processing this URB.
+ */
+int ifxhcd_urb_enqueue( struct usb_hcd *_syshcd,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)
+ struct usb_host_endpoint *_sysep,
+#endif
+ struct urb *_urb,
+ gfp_t _mem_flags)
+{
+ ifxhcd_hcd_t *ifxhcd = syshcd_to_ifxhcd (_syshcd);
+ ifxhcd_epqh_t *epqh = NULL;
+
+ #ifdef __DEBUG__
+ if (CHK_DEBUG_LEVEL(DBG_HCDV | DBG_HCD_URB))
+ dump_urb_info(_urb, "ifxusb_hcd_urb_enqueue");
+ #endif //__DEBUG__
+
+ if (!ifxhcd->flags.b.port_connect_status) /* No longer connected. */
+ return -ENODEV;
+
+ #if !defined(__EN_ISOC__)
+ if(usb_pipetype(_urb->pipe) == PIPE_ISOCHRONOUS)
+ {
+ IFX_ERROR("ISOC transfer not supported!!!\n");
+ return -ENODEV;
+ }
+ #endif
+
+ if(_urb->hcpriv)
+ {
+ IFX_WARN("%s() Previous urb->hcpriv exist %p\n",__func__,_urb->hcpriv);
+ #if 1
+ return -ENOSPC;
+ #endif
+ }
+
+ epqh=ifxhcd_urbd_create (ifxhcd,_urb);
+ if (!epqh)
+ {
+ IFX_ERROR("IFXUSB HCD URB Enqueue failed creating URBD\n");
+ return -ENOSPC;
+ }
+ if(epqh->phase==EPQH_DISABLING )
+ {
+ IFX_ERROR("Enqueue to a DISABLING EP!!!\n");
+ return -ENODEV;
+ }
+
+ #ifdef __DYN_SOF_INTR__
+ ifxhcd->dyn_sof_count = DYN_SOF_COUNT_DEF;
+ #endif
+ //enable_sof(ifxhcd);
+ {
+ gint_data_t gintsts;
+ gintsts.d32=0;
+ gintsts.b.sofintr = 1;
+ ifxusb_mreg(&ifxhcd->core_if.core_global_regs->gintmsk, 0,gintsts.d32);
+ }
+
+ if(epqh->phase==EPQH_IDLE || epqh->phase==EPQH_STDBY )
+ {
+ epqh->phase=EPQH_READY;
+ #ifdef __EPQD_DESTROY_TIMEOUT__
+ del_timer(&epqh->destroy_timer);
+ #endif
+ }
+ select_eps(ifxhcd);
+ return 0;
+}
+
+/*!
+ \brief Aborts/cancels a USB transfer request. Always returns 0 to indicate
+ success.
+ */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)
+int ifxhcd_urb_dequeue(struct usb_hcd *_syshcd, struct urb *_urb)
+#else
+int ifxhcd_urb_dequeue(struct usb_hcd *_syshcd, struct urb *_urb, int status)
+#endif
+{
+ ifxhcd_hcd_t *ifxhcd;
+ struct usb_host_endpoint *sysep;
+ ifxhcd_urbd_t *urbd;
+ ifxhcd_epqh_t *epqh;
+
+ IFX_DEBUGPL(DBG_HCD, "IFXUSB HCD URB Dequeue\n");
+ #if !defined(__EN_ISOC__)
+ if(usb_pipetype(_urb->pipe) == PIPE_ISOCHRONOUS)
+ return 0;
+ #endif
+
+ ifxhcd = syshcd_to_ifxhcd(_syshcd);
+
+ urbd = (ifxhcd_urbd_t *) _urb->hcpriv;
+ if(!urbd)
+ {
+ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)
+ _urb->status=-ETIMEDOUT;
+ usb_hcd_giveback_urb(_syshcd, _urb);
+ #else
+// usb_hcd_giveback_urb(_syshcd, _urb,-ETIMEDOUT);
+ usb_hcd_giveback_urb(_syshcd, _urb,status);
+ #endif
+ return 0;
+ }
+
+ sysep = ifxhcd_urb_to_endpoint(_urb);
+ if(sysep)
+ {
+ LOCK_EPQH_LIST_ALL(ifxhcd);
+ epqh = sysep_to_epqh(ifxhcd,sysep);
+ UNLOCK_EPQH_LIST_ALL(ifxhcd);
+ if(epqh!=urbd->epqh)
+ IFX_ERROR("%s inconsistant epqh %p %p\n",__func__,epqh,urbd->epqh);
+ }
+ else
+ epqh = (ifxhcd_epqh_t *) urbd->epqh;
+ if(!ifxhcd->flags.b.port_connect_status || !epqh)
+ {
+ urbd->phase=URBD_DEQUEUEING;
+ ifxhcd_complete_urb(ifxhcd, urbd, -ENODEV);
+ }
+ else
+ {
+ LOCK_URBD_LIST(epqh);
+ if( urbd->phase==URBD_IDLE
+ || urbd->phase==URBD_ACTIVE
+// || urbd->phase==URBD_STARTING
+ )
+ {
+ urbd->phase=URBD_DEQUEUEING;
+ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)
+ ifxhcd_complete_urb(ifxhcd, urbd, -ETIMEDOUT);
+ #else
+ ifxhcd_complete_urb(ifxhcd, urbd, status);
+ #endif
+ }
+ else if( urbd->phase==URBD_STARTED
+ || urbd->phase==URBD_STARTING
+// || urbd->phase==URBD_ACTIVE
+ )
+ {
+ if(ifxhcd_hc_halt(&ifxhcd->core_if, epqh->hc, HC_XFER_URB_DEQUEUE))
+ {
+ urbd->phase=URBD_DEQUEUEING;
+ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)
+ ifxhcd_complete_urb(ifxhcd, urbd, -ETIMEDOUT);
+ #else
+ ifxhcd_complete_urb(ifxhcd, urbd, status);
+ #endif
+ ifxhcd_epqh_idle(epqh);
+ }
+ }
+ UNLOCK_URBD_LIST(epqh);
+ }
+ return 0;
+}
+
+
+/*!
+ \brief Frees resources in the IFXUSB controller related to a given endpoint. Also
+ clears state in the HCD related to the endpoint. Any URBs for the endpoint
+ must already be dequeued.
+ */
+void ifxhcd_endpoint_disable( struct usb_hcd *_syshcd,
+ struct usb_host_endpoint *_sysep)
+{
+ ifxhcd_hcd_t *ifxhcd;
+ ifxhcd_epqh_t *epqh;
+
+ IFX_DEBUGPL(DBG_HCD, "IFXUSB HCD EP DISABLE: _bEndpointAddress=0x%02x, "
+ "endpoint=%d\n", _sysep->desc.bEndpointAddress,
+ ifxhcd_ep_addr_to_endpoint(_sysep->desc.bEndpointAddress));
+
+ ifxhcd = syshcd_to_ifxhcd(_syshcd);
+
+ LOCK_EPQH_LIST_ALL(ifxhcd);
+ epqh = sysep_to_epqh(ifxhcd,_sysep);
+ UNLOCK_EPQH_LIST_ALL(ifxhcd);
+
+ if (!epqh)
+ {
+ return;
+ }
+ else
+ {
+ if (epqh->sysep!=_sysep)
+ {
+ IFX_ERROR("%s inconsistant sysep %p %p %p\n",__func__,epqh,epqh->sysep,_sysep);
+ return;
+ }
+
+ epqh->phase=EPQH_DISABLING;
+ kill_all_urbs_in_epqh(ifxhcd, epqh, -ETIMEDOUT);
+ {
+ uint32_t count=0x80000;
+ for(;!list_empty(&epqh->urbd_list) && count> 0; count--) udelay(1);
+ if(!count)
+ IFX_ERROR("%s: unable to clear urbd in epqh \n",__func__);
+ }
+ ifxhcd_epqh_free(epqh);
+ }
+ IFX_DEBUGPL(DBG_HCD, "IFXUSB HCD EP DISABLE: done\n");
+}
+
+
+/*!
+ \brief Handles host mode interrupts for the IFXUSB controller. Returns IRQ_NONE if
+ there was no interrupt to handle. Returns IRQ_HANDLED if there was a valid
+ interrupt.
+
+ This function is called by the USB core when an interrupt occurs
+ */
+irqreturn_t ifxhcd_irq(struct usb_hcd *_syshcd)
+{
+ ifxhcd_hcd_t *ifxhcd = syshcd_to_ifxhcd (_syshcd);
+ int32_t retval=0;
+
+ //mask_and_ack_ifx_irq (ifxhcd->core_if.irq);
+ retval = ifxhcd_handle_intr(ifxhcd);
+ return IRQ_RETVAL(retval);
+}
+
+
+
+/*!
+ \brief Creates Status Change bitmap for the root hub and root port. The bitmap is
+ returned in buf. Bit 0 is the status change indicator for the root hub. Bit 1
+ is the status change indicator for the single root port. Returns 1 if either
+ change indicator is 1, otherwise returns 0.
+ */
+int ifxhcd_hub_status_data(struct usb_hcd *_syshcd, char *_buf)
+{
+ ifxhcd_hcd_t *ifxhcd = syshcd_to_ifxhcd (_syshcd);
+
+ _buf[0] = 0;
+ _buf[0] |= (ifxhcd->flags.b.port_connect_status_change ||
+ ifxhcd->flags.b.port_reset_change ||
+ ifxhcd->flags.b.port_enable_change ||
+ ifxhcd->flags.b.port_suspend_change ||
+ ifxhcd->flags.b.port_over_current_change) << 1;
+
+ #ifdef __DEBUG__
+ if (_buf[0])
+ {
+ IFX_DEBUGPL(DBG_HCD, "IFXUSB HCD HUB STATUS DATA:"
+ " Root port status changed\n");
+ IFX_DEBUGPL(DBG_HCDV, " port_connect_status_change: %d\n",
+ ifxhcd->flags.b.port_connect_status_change);
+ IFX_DEBUGPL(DBG_HCDV, " port_reset_change: %d\n",
+ ifxhcd->flags.b.port_reset_change);
+ IFX_DEBUGPL(DBG_HCDV, " port_enable_change: %d\n",
+ ifxhcd->flags.b.port_enable_change);
+ IFX_DEBUGPL(DBG_HCDV, " port_suspend_change: %d\n",
+ ifxhcd->flags.b.port_suspend_change);
+ IFX_DEBUGPL(DBG_HCDV, " port_over_current_change: %d\n",
+ ifxhcd->flags.b.port_over_current_change);
+ {
+ hprt0_data_t hprt0;
+ hprt0.d32 = ifxusb_rreg(ifxhcd->core_if.hprt0);
+ IFX_DEBUGPL(DBG_HCDV, " port reg :%08X\n",hprt0.d32);
+ IFX_DEBUGPL(DBG_HCDV, " port reg :connect: %d/%d\n",hprt0.b.prtconnsts,hprt0.b.prtconndet);
+ IFX_DEBUGPL(DBG_HCDV, " port reg :enable: %d/%d\n",hprt0.b.prtena,hprt0.b.prtenchng);
+ IFX_DEBUGPL(DBG_HCDV, " port reg :OC: %d/%d\n",hprt0.b.prtovrcurract,hprt0.b.prtovrcurrchng);
+ IFX_DEBUGPL(DBG_HCDV, " port reg :rsume/suspend/reset: %d/%d/%d\n",hprt0.b.prtres,hprt0.b.prtsusp,hprt0.b.prtrst);
+ IFX_DEBUGPL(DBG_HCDV, " port reg :port power: %d/\n",hprt0.b.prtpwr);
+ IFX_DEBUGPL(DBG_HCDV, " port reg :speed: %d/\n",hprt0.b.prtspd);
+ }
+ }
+ #endif //__DEBUG__
+ return (_buf[0] != 0);
+}
+
+#ifdef __WITH_HS_ELECT_TST__
+ extern void do_setup(ifxusb_core_if_t *_core_if) ;
+ extern void do_in_ack(ifxusb_core_if_t *_core_if);
+#endif //__WITH_HS_ELECT_TST__
+
+/*!
+ \brief Handles hub class-specific requests.
+ */
+int ifxhcd_hub_control( struct usb_hcd *_syshcd,
+ u16 _typeReq,
+ u16 _wValue,
+ u16 _wIndex,
+ char *_buf,
+ u16 _wLength)
+{
+ int retval = 0;
+ ifxhcd_hcd_t *ifxhcd = syshcd_to_ifxhcd (_syshcd);
+ ifxusb_core_if_t *core_if = &ifxhcd->core_if;
+ struct usb_hub_descriptor *desc;
+ hprt0_data_t hprt0 = {.d32 = 0};
+
+ uint32_t port_status;
+
+ switch (_typeReq)
+ {
+ case ClearHubFeature:
+ IFX_DEBUGPL (DBG_HCD, "IFXUSB HCD HUB CONTROL - "
+ "ClearHubFeature 0x%x\n", _wValue);
+ switch (_wValue)
+ {
+ case C_HUB_LOCAL_POWER:
+ case C_HUB_OVER_CURRENT:
+ /* Nothing required here */
+ break;
+ default:
+ retval = -EINVAL;
+ IFX_ERROR ("IFXUSB HCD - "
+ "ClearHubFeature request %xh unknown\n", _wValue);
+ }
+ break;
+ case ClearPortFeature:
+ if (!_wIndex || _wIndex > 1)
+ goto error;
+
+ switch (_wValue)
+ {
+ case USB_PORT_FEAT_ENABLE:
+ IFX_DEBUGPL (DBG_ANY, "IFXUSB HCD HUB CONTROL - "
+ "ClearPortFeature USB_PORT_FEAT_ENABLE\n");
+ hprt0.d32 = ifxusb_read_hprt0 (core_if);
+ hprt0.b.prtena = 1;
+ ifxusb_wreg(core_if->hprt0, hprt0.d32);
+ break;
+ case USB_PORT_FEAT_SUSPEND:
+ IFX_DEBUGPL (DBG_HCD, "IFXUSB HCD HUB CONTROL - "
+ "ClearPortFeature USB_PORT_FEAT_SUSPEND\n");
+ hprt0.d32 = ifxusb_read_hprt0 (core_if);
+ hprt0.b.prtres = 1;
+ ifxusb_wreg(core_if->hprt0, hprt0.d32);
+ /* Clear Resume bit */
+ mdelay (100);
+ hprt0.b.prtres = 0;
+ ifxusb_wreg(core_if->hprt0, hprt0.d32);
+ break;
+ case USB_PORT_FEAT_POWER:
+ IFX_DEBUGPL (DBG_HCD, "IFXUSB HCD HUB CONTROL - "
+ "ClearPortFeature USB_PORT_FEAT_POWER\n");
+ #ifdef __IS_DUAL__
+ ifxusb_vbus_off(core_if);
+ #else
+ ifxusb_vbus_off(core_if);
+ #endif
+ hprt0.d32 = ifxusb_read_hprt0 (core_if);
+ hprt0.b.prtpwr = 0;
+ ifxusb_wreg(core_if->hprt0, hprt0.d32);
+ break;
+ case USB_PORT_FEAT_INDICATOR:
+ IFX_DEBUGPL (DBG_HCD, "IFXUSB HCD HUB CONTROL - "
+ "ClearPortFeature USB_PORT_FEAT_INDICATOR\n");
+ /* Port inidicator not supported */
+ break;
+ case USB_PORT_FEAT_C_CONNECTION:
+ /* Clears drivers internal connect status change
+ * flag */
+ IFX_DEBUGPL (DBG_HCD, "IFXUSB HCD HUB CONTROL - "
+ "ClearPortFeature USB_PORT_FEAT_C_CONNECTION\n");
+ ifxhcd->flags.b.port_connect_status_change = 0;
+ break;
+ case USB_PORT_FEAT_C_RESET:
+ /* Clears the driver's internal Port Reset Change
+ * flag */
+ IFX_DEBUGPL (DBG_HCD, "IFXUSB HCD HUB CONTROL - "
+ "ClearPortFeature USB_PORT_FEAT_C_RESET\n");
+ ifxhcd->flags.b.port_reset_change = 0;
+ break;
+ case USB_PORT_FEAT_C_ENABLE:
+ /* Clears the driver's internal Port
+ * Enable/Disable Change flag */
+ IFX_DEBUGPL (DBG_HCD, "IFXUSB HCD HUB CONTROL - "
+ "ClearPortFeature USB_PORT_FEAT_C_ENABLE\n");
+ ifxhcd->flags.b.port_enable_change = 0;
+ break;
+ case USB_PORT_FEAT_C_SUSPEND:
+ /* Clears the driver's internal Port Suspend
+ * Change flag, which is set when resume signaling on
+ * the host port is complete */
+ IFX_DEBUGPL (DBG_HCD, "IFXUSB HCD HUB CONTROL - "
+ "ClearPortFeature USB_PORT_FEAT_C_SUSPEND\n");
+ ifxhcd->flags.b.port_suspend_change = 0;
+ break;
+ case USB_PORT_FEAT_C_OVER_CURRENT:
+ IFX_DEBUGPL (DBG_HCD, "IFXUSB HCD HUB CONTROL - "
+ "ClearPortFeature USB_PORT_FEAT_C_OVER_CURRENT\n");
+ ifxhcd->flags.b.port_over_current_change = 0;
+ break;
+ default:
+ retval = -EINVAL;
+ IFX_ERROR ("IFXUSB HCD - "
+ "ClearPortFeature request %xh "
+ "unknown or unsupported\n", _wValue);
+ }
+ break;
+ case GetHubDescriptor:
+ IFX_DEBUGPL (DBG_HCD, "IFXUSB HCD HUB CONTROL - "
+ "GetHubDescriptor\n");
+ desc = (struct usb_hub_descriptor *)_buf;
+ desc->bDescLength = 9;
+ desc->bDescriptorType = 0x29;
+ desc->bNbrPorts = 1;
+ desc->wHubCharacteristics = 0x08;
+ desc->bPwrOn2PwrGood = 1;
+ desc->bHubContrCurrent = 0;
+
+ desc->u.hs.DeviceRemovable[0] = 0;
+ desc->u.hs.DeviceRemovable[1] = 1;
+ /*desc->bitmap[0] = 0;
+ desc->bitmap[1] = 0xff;*/
+ break;
+ case GetHubStatus:
+ IFX_DEBUGPL (DBG_HCD, "IFXUSB HCD HUB CONTROL - "
+ "GetHubStatus\n");
+ memset (_buf, 0, 4);
+ break;
+ case GetPortStatus:
+ IFX_DEBUGPL (DBG_HCD, "IFXUSB HCD HUB CONTROL - "
+ "GetPortStatus\n");
+ if (!_wIndex || _wIndex > 1)
+ goto error;
+ port_status = 0;
+ if (ifxhcd->flags.b.port_connect_status_change)
+ port_status |= (1 << USB_PORT_FEAT_C_CONNECTION);
+ if (ifxhcd->flags.b.port_enable_change)
+ port_status |= (1 << USB_PORT_FEAT_C_ENABLE);
+ if (ifxhcd->flags.b.port_suspend_change)
+ port_status |= (1 << USB_PORT_FEAT_C_SUSPEND);
+ if (ifxhcd->flags.b.port_reset_change)
+ port_status |= (1 << USB_PORT_FEAT_C_RESET);
+ if (ifxhcd->flags.b.port_over_current_change)
+ {
+ IFX_ERROR("Device Not Supported\n");
+ port_status |= (1 << USB_PORT_FEAT_C_OVER_CURRENT);
+ }
+ if (!ifxhcd->flags.b.port_connect_status)
+ {
+ /*
+ * The port is disconnected, which means the core is
+ * either in device mode or it soon will be. Just
+ * return 0's for the remainder of the port status
+ * since the port register can't be read if the core
+ * is in device mode.
+ */
+ *((u32 *) _buf) = cpu_to_le32(port_status);
+ break;
+ }
+
+ hprt0.d32 = ifxusb_rreg(core_if->hprt0);
+ IFX_DEBUGPL(DBG_HCDV, " HPRT0: 0x%08x\n", hprt0.d32);
+ if (hprt0.b.prtconnsts)
+ port_status |= (1 << USB_PORT_FEAT_CONNECTION);
+ if (hprt0.b.prtena)
+ {
+ ifxhcd->disconnecting=0;
+ port_status |= (1 << USB_PORT_FEAT_ENABLE);
+ }
+ if (hprt0.b.prtsusp)
+ port_status |= (1 << USB_PORT_FEAT_SUSPEND);
+ if (hprt0.b.prtovrcurract)
+ port_status |= (1 << USB_PORT_FEAT_OVER_CURRENT);
+ if (hprt0.b.prtrst)
+ port_status |= (1 << USB_PORT_FEAT_RESET);
+ if (hprt0.b.prtpwr)
+ port_status |= (1 << USB_PORT_FEAT_POWER);
+ if (hprt0.b.prtspd == IFXUSB_HPRT0_PRTSPD_HIGH_SPEED)
+ port_status |= USB_PORT_STAT_HIGH_SPEED;
+ else if (hprt0.b.prtspd == IFXUSB_HPRT0_PRTSPD_LOW_SPEED)
+ port_status |= USB_PORT_STAT_LOW_SPEED;
+ if (hprt0.b.prttstctl)
+ port_status |= (1 << USB_PORT_FEAT_TEST);
+ /* USB_PORT_FEAT_INDICATOR unsupported always 0 */
+ *((u32 *) _buf) = cpu_to_le32(port_status);
+ break;
+ case SetHubFeature:
+ IFX_DEBUGPL (DBG_HCD, "IFXUSB HCD HUB CONTROL - "
+ "SetHubFeature\n");
+ /* No HUB features supported */
+ break;
+ case SetPortFeature:
+ if (_wValue != USB_PORT_FEAT_TEST && (!_wIndex || _wIndex > 1))
+ goto error;
+ /*
+ * The port is disconnected, which means the core is
+ * either in device mode or it soon will be. Just
+ * return without doing anything since the port
+ * register can't be written if the core is in device
+ * mode.
+ */
+ if (!ifxhcd->flags.b.port_connect_status)
+ break;
+ switch (_wValue)
+ {
+ case USB_PORT_FEAT_SUSPEND:
+ IFX_DEBUGPL (DBG_HCD, "IFXUSB HCD HUB CONTROL - "
+ "SetPortFeature - USB_PORT_FEAT_SUSPEND\n");
+ hprt0.d32 = ifxusb_read_hprt0 (core_if);
+ hprt0.b.prtsusp = 1;
+ ifxusb_wreg(core_if->hprt0, hprt0.d32);
+ //IFX_PRINT( "SUSPEND: HPRT0=%0x\n", hprt0.d32);
+ /* Suspend the Phy Clock */
+ {
+ pcgcctl_data_t pcgcctl = {.d32=0};
+ pcgcctl.b.stoppclk = 1;
+ ifxusb_wreg(core_if->pcgcctl, pcgcctl.d32);
+ }
+ break;
+ case USB_PORT_FEAT_POWER:
+ IFX_DEBUGPL (DBG_HCD, "IFXUSB HCD HUB CONTROL - "
+ "SetPortFeature - USB_PORT_FEAT_POWER\n");
+ ifxusb_vbus_on (core_if);
+ hprt0.d32 = ifxusb_read_hprt0 (core_if);
+ hprt0.b.prtpwr = 1;
+ ifxusb_wreg(core_if->hprt0, hprt0.d32);
+ break;
+ case USB_PORT_FEAT_RESET:
+ IFX_DEBUGPL (DBG_HCD, "IFXUSB HCD HUB CONTROL - "
+ "SetPortFeature - USB_PORT_FEAT_RESET\n");
+ hprt0.d32 = ifxusb_read_hprt0 (core_if);
+ hprt0.b.prtrst = 1;
+ ifxusb_wreg(core_if->hprt0, hprt0.d32);
+ /* Clear reset bit in 10ms (FS/LS) or 50ms (HS) */
+ MDELAY (60);
+ hprt0.b.prtrst = 0;
+ ifxusb_wreg(core_if->hprt0, hprt0.d32);
+ break;
+ #ifdef __WITH_HS_ELECT_TST__
+ case USB_PORT_FEAT_TEST:
+ {
+ uint32_t t;
+ gint_data_t gintmsk;
+ t = (_wIndex >> 8); /* MSB wIndex USB */
+ IFX_DEBUGPL (DBG_HCD, "IFXUSB HCD HUB CONTROL - "
+ "SetPortFeature - USB_PORT_FEAT_TEST %d\n", t);
+ warn("USB_PORT_FEAT_TEST %d\n", t);
+ if (t < 6)
+ {
+ hprt0.d32 = ifxusb_read_hprt0 (core_if);
+ hprt0.b.prttstctl = t;
+ ifxusb_wreg(core_if->hprt0, hprt0.d32);
+ }
+ else if (t == 6) /* HS_HOST_PORT_SUSPEND_RESUME */
+ {
+ /* Save current interrupt mask */
+ gintmsk.d32 = ifxusb_rreg(&core_if->core_global_regs->gintmsk);
+
+ /* Disable all interrupts while we muck with
+ * the hardware directly
+ */
+ ifxusb_wreg(&core_if->core_global_regs->gintmsk, 0);
+
+ /* 15 second delay per the test spec */
+ mdelay(15000);
+
+ /* Drive suspend on the root port */
+ hprt0.d32 = ifxusb_read_hprt0 (core_if);
+ hprt0.b.prtsusp = 1;
+ hprt0.b.prtres = 0;
+ ifxusb_wreg(core_if->hprt0, hprt0.d32);
+
+ /* 15 second delay per the test spec */
+ mdelay(15000);
+
+ /* Drive resume on the root port */
+ hprt0.d32 = ifxusb_read_hprt0 (core_if);
+ hprt0.b.prtsusp = 0;
+ hprt0.b.prtres = 1;
+ ifxusb_wreg(core_if->hprt0, hprt0.d32);
+ mdelay(100);
+
+ /* Clear the resume bit */
+ hprt0.b.prtres = 0;
+ ifxusb_wreg(core_if->hprt0, hprt0.d32);
+
+ /* Restore interrupts */
+ ifxusb_wreg(&core_if->core_global_regs->gintmsk, gintmsk.d32);
+ }
+ else if (t == 7) /* SINGLE_STEP_GET_DEVICE_DESCRIPTOR setup */
+ {
+ /* Save current interrupt mask */
+ gintmsk.d32 = ifxusb_rreg(&core_if->core_global_regs->gintmsk);
+
+ /* Disable all interrupts while we muck with
+ * the hardware directly
+ */
+ ifxusb_wreg(&core_if->core_global_regs->gintmsk, 0);
+
+ /* 15 second delay per the test spec */
+ mdelay(15000);
+
+ /* Send the Setup packet */
+ do_setup(core_if);
+
+ /* 15 second delay so nothing else happens for awhile */
+ mdelay(15000);
+
+ /* Restore interrupts */
+ ifxusb_wreg(&core_if->core_global_regs->gintmsk, gintmsk.d32);
+ }
+
+ else if (t == 8) /* SINGLE_STEP_GET_DEVICE_DESCRIPTOR execute */
+ {
+ /* Save current interrupt mask */
+ gintmsk.d32 = ifxusb_rreg(&core_if->core_global_regs->gintmsk);
+
+ /* Disable all interrupts while we muck with
+ * the hardware directly
+ */
+ ifxusb_wreg(&core_if->core_global_regs->gintmsk, 0);
+
+ /* Send the Setup packet */
+ do_setup(core_if);
+
+ /* 15 second delay so nothing else happens for awhile */
+ mdelay(15000);
+
+ /* Send the In and Ack packets */
+ do_in_ack(core_if);
+
+ /* 15 second delay so nothing else happens for awhile */
+ mdelay(15000);
+
+ /* Restore interrupts */
+ ifxusb_wreg(&core_if->core_global_regs->gintmsk, gintmsk.d32);
+ }
+ }
+ break;
+ #endif //__WITH_HS_ELECT_TST__
+ case USB_PORT_FEAT_INDICATOR:
+ IFX_DEBUGPL (DBG_HCD, "IFXUSB HCD HUB CONTROL - "
+ "SetPortFeature - USB_PORT_FEAT_INDICATOR\n");
+ /* Not supported */
+ break;
+ default:
+ retval = -EINVAL;
+ IFX_ERROR ("IFXUSB HCD - "
+ "SetPortFeature request %xh "
+ "unknown or unsupported\n", _wValue);
+ }
+ break;
+ default:
+ error:
+ retval = -EINVAL;
+ IFX_WARN ("IFXUSB HCD - "
+ "Unknown hub control request type or invalid typeReq: %xh wIndex: %xh wValue: %xh\n",
+ _typeReq, _wIndex, _wValue);
+ }
+ return retval;
+}
+
+
+
+
+/*!
+ \brief This function trigger a data transfer for a host channel and
+ starts the transfer.
+
+ For a PING transfer in Slave mode, the Do Ping bit is set in the HCTSIZ
+ register along with a packet count of 1 and the channel is enabled. This
+ causes a single PING transaction to occur. Other fields in HCTSIZ are
+ simply set to 0 since no data transfer occurs in this case.
+
+ For a PING transfer in DMA mode, the HCTSIZ register is initialized with
+ all the information required to perform the subsequent data transfer. In
+ addition, the Do Ping bit is set in the HCTSIZ register. In this case, the
+ controller performs the entire PING protocol, then starts the data
+ transfer.
+ \param _core_if Pointer of core_if structure
+ \param _ifxhc Information needed to initialize the host channel. The xfer_len
+ value may be reduced to accommodate the max widths of the XferSize and
+ PktCnt fields in the HCTSIZn register. The multi_count value may be changed
+ to reflect the final xfer_len value.
+ */
+void ifxhcd_hc_start(ifxhcd_hcd_t *_ifxhcd, ifxhcd_hc_t *_ifxhc)
+{
+ ifxusb_core_if_t *core_if = &_ifxhcd->core_if;
+ uint32_t max_hc_xfer_size = core_if->params.max_transfer_size;
+ uint16_t max_hc_pkt_count = core_if->params.max_packet_count;
+ ifxusb_hc_regs_t *hc_regs = core_if->hc_regs[_ifxhc->hc_num];
+ hfnum_data_t hfnum;
+
+ hprt0_data_t hprt0;
+
+ if(_ifxhc->epqh->urbd->phase==URBD_DEQUEUEING)
+ return;
+
+ hprt0.d32 = ifxusb_read_hprt0(core_if);
+
+ if(_ifxhcd->pkt_remaining==0)
+ return;
+
+#if 0
+ if(_ifxhc->phase!=HC_WAITING)
+ printk(KERN_INFO "%s() line %d: _ifxhc->phase!=HC_WAITING :%d\n",__func__,__LINE__,_ifxhc->phase);
+ if(_ifxhc->epqh->urbd->phase==URBD_IDLE ) printk(KERN_INFO "%s() line %d: _ifxhc->epqh->urbd->phase==URBD_IDLE\n",__func__,__LINE__);
+// if(_ifxhc->epqh->urbd->phase==URBD_ACTIVE ) printk(KERN_INFO "%s() line %d: _ifxhc->epqh->urbd->phase==URBD_ACTIVE\n",__func__,__LINE__);
+ if(_ifxhc->epqh->urbd->phase==URBD_STARTING ) printk(KERN_INFO "%s() line %d: _ifxhc->epqh->urbd->phase==URBD_STARTING\n",__func__,__LINE__);
+ if(_ifxhc->epqh->urbd->phase==URBD_STARTED ) printk(KERN_INFO "%s() line %d: _ifxhc->epqh->urbd->phase==URBD_STARTED\n",__func__,__LINE__);
+ if(_ifxhc->epqh->urbd->phase==URBD_COMPLETING) printk(KERN_INFO "%s() line %d: _ifxhc->epqh->urbd->phase==URBD_COMPLETING\n",__func__,__LINE__);
+ if(_ifxhc->epqh->urbd->phase==URBD_DEQUEUEING) printk(KERN_INFO "%s() line %d: _ifxhc->epqh->urbd->phase==URBD_DEQUEUEING\n",__func__,__LINE__);
+ if(_ifxhc->epqh->urbd->phase==URBD_FINISHING ) printk(KERN_INFO "%s() line %d: _ifxhc->epqh->urbd->phase==URBD_FINISHING\n",__func__,__LINE__);
+#endif
+
+ if (hprt0.b.prtspd == IFXUSB_HPRT0_PRTSPD_HIGH_SPEED)
+ {
+ if (_ifxhc->split)
+ {
+ if(max_hc_pkt_count > _ifxhcd->pkt_remaining)
+ max_hc_pkt_count = _ifxhcd->pkt_remaining;
+ }
+ else if(_ifxhc->ep_type == IFXUSB_EP_TYPE_BULK)
+ {
+ if( _ifxhc->is_in && _ifxhcd->pkt_count_limit_bi && max_hc_pkt_count > _ifxhcd->pkt_count_limit_bi)
+ max_hc_pkt_count = _ifxhcd->pkt_count_limit_bi;
+ if(!_ifxhc->is_in && _ifxhcd->pkt_count_limit_bo && max_hc_pkt_count > _ifxhcd->pkt_count_limit_bo)
+ max_hc_pkt_count = _ifxhcd->pkt_count_limit_bo;
+ if(max_hc_pkt_count*8 > _ifxhcd->pkt_remaining)
+ max_hc_pkt_count = _ifxhcd->pkt_remaining/8;
+ }
+ else
+ {
+ if(max_hc_pkt_count > _ifxhcd->pkt_remaining)
+ max_hc_pkt_count = _ifxhcd->pkt_remaining;
+ }
+ }
+ else if (hprt0.b.prtspd == IFXUSB_HPRT0_PRTSPD_LOW_SPEED)
+ {
+ if(max_hc_pkt_count > _ifxhcd->pkt_remaining)
+ max_hc_pkt_count = _ifxhcd->pkt_remaining;
+ }
+ else
+ {
+ if(max_hc_pkt_count > _ifxhcd->pkt_remaining)
+ max_hc_pkt_count = _ifxhcd->pkt_remaining;
+ }
+
+ if(max_hc_pkt_count==0)
+ return;
+
+ if(max_hc_pkt_count * _ifxhc->mps < max_hc_xfer_size)
+ max_hc_xfer_size = max_hc_pkt_count * _ifxhc->mps;
+
+ _ifxhc->epqh->urbd->phase=URBD_STARTING;
+
+ if(_ifxhc->is_in || _ifxhc->speed != IFXUSB_EP_SPEED_HIGH || _ifxhc->xfer_len==0)
+ _ifxhc->epqh->do_ping=0;
+ if(_ifxhc->ep_type == IFXUSB_EP_TYPE_INTR || _ifxhc->ep_type == IFXUSB_EP_TYPE_ISOC)
+ _ifxhc->epqh->do_ping=0;
+ if(_ifxhc->ep_type == IFXUSB_EP_TYPE_CTRL && _ifxhc->control_phase != IFXHCD_CONTROL_DATA )
+ _ifxhc->epqh->do_ping=0;
+
+ if (_ifxhc->split > 0)
+ {
+ _ifxhc->start_pkt_count = 1;
+ if(!_ifxhc->is_in && _ifxhc->split>1) // OUT CSPLIT
+ _ifxhc->xfer_len = 0;
+ if (_ifxhc->xfer_len > _ifxhc->mps)
+ _ifxhc->xfer_len = _ifxhc->mps;
+ if (_ifxhc->xfer_len > 188)
+ _ifxhc->xfer_len = 188;
+ }
+ else if(_ifxhc->is_in)
+ {
+ _ifxhc->short_rw = 0;
+ if (_ifxhc->xfer_len > 0)
+ {
+ if (_ifxhc->xfer_len > max_hc_xfer_size)
+ _ifxhc->xfer_len = max_hc_xfer_size - _ifxhc->mps + 1;
+ _ifxhc->start_pkt_count = (_ifxhc->xfer_len + _ifxhc->mps - 1) / _ifxhc->mps;
+ if (_ifxhc->start_pkt_count > max_hc_pkt_count)
+ _ifxhc->start_pkt_count = max_hc_pkt_count;
+ }
+ else /* Need 1 packet for transfer length of 0. */
+ _ifxhc->start_pkt_count = 1;
+ _ifxhc->xfer_len = _ifxhc->start_pkt_count * _ifxhc->mps;
+ }
+ else //non-split out
+ {
+ if (_ifxhc->xfer_len == 0)
+ {
+ if(_ifxhc->short_rw==0)
+ printk(KERN_INFO "Info: %s() line %d: ZLP write without short_rw set! xfer_count:%d/%d \n",__func__,__LINE__,
+ _ifxhc->xfer_count,
+ _ifxhc->epqh->urbd->xfer_len);
+ _ifxhc->start_pkt_count = 1;
+ }
+ else
+ {
+ if (_ifxhc->xfer_len > max_hc_xfer_size)
+ {
+ _ifxhc->start_pkt_count = (max_hc_xfer_size / _ifxhc->mps);
+ _ifxhc->xfer_len = _ifxhc->start_pkt_count * _ifxhc->mps;
+ }
+ else
+ {
+ _ifxhc->start_pkt_count = (_ifxhc->xfer_len+_ifxhc->mps-1) / _ifxhc->mps;
+// if(_ifxhc->start_pkt_count * _ifxhc->mps == _ifxhc->xfer_len )
+// _ifxhc->start_pkt_count += _ifxhc->short_rw;
+ }
+ }
+ }
+
+ if (hprt0.b.prtspd == IFXUSB_HPRT0_PRTSPD_HIGH_SPEED)
+ {
+ if (_ifxhc->split)
+ {
+ if( _ifxhcd->pkt_remaining > _ifxhc->start_pkt_count)
+ _ifxhcd->pkt_remaining -= _ifxhc->start_pkt_count;
+ else
+ _ifxhcd->pkt_remaining = 0;
+ }
+ else if(_ifxhc->ep_type == IFXUSB_EP_TYPE_BULK)
+ {
+ if( _ifxhcd->pkt_remaining*8 > _ifxhc->start_pkt_count)
+ _ifxhcd->pkt_remaining -= (_ifxhc->start_pkt_count*8);
+ else
+ _ifxhcd->pkt_remaining = 0;
+ }
+ else
+ {
+ if( _ifxhcd->pkt_remaining > _ifxhc->start_pkt_count)
+ _ifxhcd->pkt_remaining -= _ifxhc->start_pkt_count;
+ else
+ _ifxhcd->pkt_remaining = 0;
+ }
+ }
+ else if (hprt0.b.prtspd == IFXUSB_HPRT0_PRTSPD_LOW_SPEED)
+ {
+ if( _ifxhcd->pkt_remaining > _ifxhc->start_pkt_count)
+ _ifxhcd->pkt_remaining -= _ifxhc->start_pkt_count;
+ else
+ _ifxhcd->pkt_remaining = 0;
+ }
+ else
+ {
+ if( _ifxhcd->pkt_remaining > _ifxhc->start_pkt_count)
+ _ifxhcd->pkt_remaining -= _ifxhc->start_pkt_count;
+ else
+ _ifxhcd->pkt_remaining = 0;
+ }
+
+ #ifdef __EN_ISOC__
+ if (_ifxhc->ep_type == IFXUSB_EP_TYPE_ISOC)
+ {
+ /* Set up the initial PID for the transfer. */
+ #if 1
+ _ifxhc->data_pid_start = IFXUSB_HC_PID_DATA0;
+ #else
+ if (_ifxhc->speed == IFXUSB_EP_SPEED_HIGH)
+ {
+ if (_ifxhc->is_in)
+ {
+ if (_ifxhc->multi_count == 1)
+ _ifxhc->data_pid_start = IFXUSB_HC_PID_DATA0;
+ else if (_ifxhc->multi_count == 2)
+ _ifxhc->data_pid_start = IFXUSB_HC_PID_DATA1;
+ else
+ _ifxhc->data_pid_start = IFXUSB_HC_PID_DATA2;
+ }
+ else
+ {
+ if (_ifxhc->multi_count == 1)
+ _ifxhc->data_pid_start = IFXUSB_HC_PID_DATA0;
+ else
+ _ifxhc->data_pid_start = IFXUSB_HC_PID_MDATA;
+ }
+ }
+ else
+ _ifxhc->data_pid_start = IFXUSB_HC_PID_DATA0;
+ #endif
+ }
+ #endif
+
+ IFX_DEBUGPL(DBG_HCDV, "%s: Channel %d\n", __func__, _ifxhc->hc_num);
+ {
+ hctsiz_data_t hctsiz= { .d32=0 };
+
+ hctsiz.b.dopng = _ifxhc->epqh->do_ping;
+ _ifxhc->epqh->do_ping=0;
+
+ if(_ifxhc->is_in || _ifxhc->speed != IFXUSB_EP_SPEED_HIGH || _ifxhc->xfer_len==0)
+ hctsiz.b.dopng = 0;
+ if(_ifxhc->ep_type == IFXUSB_EP_TYPE_INTR || _ifxhc->ep_type == IFXUSB_EP_TYPE_ISOC)
+ hctsiz.b.dopng = 0;
+ if(_ifxhc->ep_type == IFXUSB_EP_TYPE_CTRL && _ifxhc->control_phase != IFXHCD_CONTROL_DATA )
+ hctsiz.b.dopng = 0;
+
+ hctsiz.b.xfersize = _ifxhc->xfer_len;
+ hctsiz.b.pktcnt = _ifxhc->start_pkt_count;
+ hctsiz.b.pid = _ifxhc->data_pid_start;
+ ifxusb_wreg(&hc_regs->hctsiz, hctsiz.d32);
+
+ IFX_DEBUGPL(DBG_HCDV, " Xfer Size: %d\n", hctsiz.b.xfersize);
+ IFX_DEBUGPL(DBG_HCDV, " Num Pkts: %d\n" , hctsiz.b.pktcnt);
+ IFX_DEBUGPL(DBG_HCDV, " Start PID: %d\n", hctsiz.b.pid);
+ }
+ IFX_DEBUGPL(DBG_HCDV, " DMA: 0x%08x\n", (uint32_t)(CPHYSADDR( ((uint32_t)(_ifxhc->xfer_buff))+ _ifxhc->xfer_count )));
+ ifxusb_wreg(&hc_regs->hcdma, (uint32_t)(CPHYSADDR( ((uint32_t)(_ifxhc->xfer_buff))+ _ifxhc->xfer_count )));
+
+ /* Start the split */
+ if (_ifxhc->split>0)
+ {
+ hcsplt_data_t hcsplt;
+ hcsplt.d32 = ifxusb_rreg (&hc_regs->hcsplt);
+ hcsplt.b.spltena = 1;
+ if (_ifxhc->split>1)
+ hcsplt.b.compsplt = 1;
+ else
+ hcsplt.b.compsplt = 0;
+
+ #if defined(__EN_ISOC__) && defined(__EN_ISOC_SPLIT__)
+ if (_ifxhc->ep_type == IFXUSB_EP_TYPE_ISOC)
+ hcsplt.b.xactpos = _ifxhc->isoc_xact_pos;
+ else
+ #endif
+ hcsplt.b.xactpos = IFXUSB_HCSPLIT_XACTPOS_ALL;// if not ISO
+ ifxusb_wreg(&hc_regs->hcsplt, hcsplt.d32);
+ IFX_DEBUGPL(DBG_HCDV, " SPLIT: XACT_POS:0x%08x\n", hcsplt.d32);
+ }
+
+ {
+ hcchar_data_t hcchar;
+ hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
+// hcchar.b.multicnt = _ifxhc->multi_count;
+ hcchar.b.multicnt = 1;
+
+ if (_ifxhc->ep_type == IFXUSB_EP_TYPE_INTR || _ifxhc->ep_type == IFXUSB_EP_TYPE_ISOC)
+ {
+ hfnum.d32 = ifxusb_rreg(&core_if->host_global_regs->hfnum);
+ /* 1 if _next_ frame is odd, 0 if it's even */
+ hcchar.b.oddfrm = (hfnum.b.frnum & 0x1) ? 0 : 1;
+ }
+
+ #ifdef __DEBUG__
+ _ifxhc->start_hcchar_val = hcchar.d32;
+ if (hcchar.b.chdis)
+ IFX_WARN("%s: chdis set, channel %d, hcchar 0x%08x\n",
+ __func__, _ifxhc->hc_num, hcchar.d32);
+ #endif
+
+ /* Set host channel enable after all other setup is complete. */
+ hcchar.b.chen = 1;
+ hcchar.b.chdis = 0;
+ hcchar.b.epdir = _ifxhc->is_in;
+ _ifxhc->hcchar=hcchar.d32;
+ }
+
+ IFX_DEBUGPL(DBG_HCDV, " HCCHART: 0x%08x\n", _ifxhc->hcchar);
+
+ _ifxhc->phase=HC_STARTING;
+}
+
+/*!
+ \brief Attempts to halt a host channel. This function should only be called
+ to abort a transfer in DMA mode. Under normal circumstances in DMA mode, the
+ controller halts the channel when the transfer is complete or a condition
+ occurs that requires application intervention.
+
+ In DMA mode, always sets the Channel Enable and Channel Disable bits of the
+ HCCHARn register. The controller ensures there is space in the request
+ queue before submitting the halt request.
+
+ Some time may elapse before the core flushes any posted requests for this
+ host channel and halts. The Channel Halted interrupt handler completes the
+ deactivation of the host channel.
+ */
+int ifxhcd_hc_halt(ifxusb_core_if_t *_core_if,
+ ifxhcd_hc_t *_ifxhc,
+ ifxhcd_halt_status_e _halt_status)
+{
+ hcchar_data_t hcchar;
+ ifxusb_hc_regs_t *hc_regs;
+ hc_regs = _core_if->hc_regs[_ifxhc->hc_num];
+
+ WARN_ON(_halt_status == HC_XFER_NO_HALT_STATUS);
+
+ {
+ hprt0_data_t hprt0;
+ hprt0.d32 = ifxusb_rreg(_core_if->hprt0);
+ if(hprt0.b.prtena == 0)
+ return -1;
+ }
+
+ if (_halt_status == HC_XFER_URB_DEQUEUE ||
+ _halt_status == HC_XFER_AHB_ERR)
+ {
+ /*
+ * Disable all channel interrupts except Ch Halted. The URBD
+ * and EPQH state associated with this transfer has been cleared
+ * (in the case of URB_DEQUEUE), so the channel needs to be
+ * shut down carefully to prevent crashes.
+ */
+ hcint_data_t hcintmsk;
+ hcintmsk.d32 = 0;
+ hcintmsk.b.chhltd = 1;
+ ifxusb_wreg(&hc_regs->hcintmsk, hcintmsk.d32);
+
+ /*
+ * Make sure no other interrupts besides halt are currently
+ * pending. Handling another interrupt could cause a crash due
+ * to the URBD and EPQH state.
+ */
+ ifxusb_wreg(&hc_regs->hcint, ~hcintmsk.d32);
+
+ /*
+ * Make sure the halt status is set to URB_DEQUEUE or AHB_ERR
+ * even if the channel was already halted for some other
+ * reason.
+ */
+ _ifxhc->halt_status = _halt_status;
+ }
+
+ hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
+ if (hcchar.b.chen == 0)
+ {
+ /*
+ * The channel is either already halted or it hasn't
+ * started yet. In DMA mode, the transfer may halt if
+ * it finishes normally or a condition occurs that
+ * requires driver intervention. Don't want to halt
+ * the channel again. In either Slave or DMA mode,
+ * it's possible that the transfer has been assigned
+ * to a channel, but not started yet when an URB is
+ * dequeued. Don't want to halt a channel that hasn't
+ * started yet.
+ */
+ _ifxhc->phase=HC_IDLE;
+ return -1;
+ }
+
+ if (_ifxhc->phase==HC_STOPPING)
+ {
+ /*
+ * A halt has already been issued for this channel. This might
+ * happen when a transfer is aborted by a higher level in
+ * the stack.
+ */
+ #ifdef __DEBUG__
+ IFX_PRINT("*** %s: Channel %d, double halt a channel***\n",
+ __func__, _ifxhc->hc_num);
+ #endif
+ return 0;
+ }
+ hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
+ hcchar.b.chen = 1;
+ hcchar.b.chdis = 1;
+
+ ifxusb_wreg(&hc_regs->hcchar, hcchar.d32);
+
+ _ifxhc->halt_status = _halt_status;
+ _ifxhc->phase=HC_STOPPING;
+
+ IFX_DEBUGPL(DBG_HCDV, "%s: Channel %d\n" , __func__, _ifxhc->hc_num);
+ IFX_DEBUGPL(DBG_HCDV, " hcchar: 0x%08x\n" , hcchar.d32);
+ IFX_DEBUGPL(DBG_HCDV, " halt_status: %d\n" , _ifxhc->halt_status);
+
+ return 0;
+}
+
+/*!
+ \brief Clears a host channel.
+ */
+void ifxhcd_hc_cleanup(ifxusb_core_if_t *_core_if, ifxhcd_hc_t *_ifxhc)
+{
+ ifxusb_hc_regs_t *hc_regs;
+
+ _ifxhc->phase=HC_IDLE;
+ _ifxhc->epqh=0;
+
+ /*
+ * Clear channel interrupt enables and any unhandled channel interrupt
+ * conditions.
+ */
+ hc_regs = _core_if->hc_regs[_ifxhc->hc_num];
+ ifxusb_wreg(&hc_regs->hcintmsk, 0);
+ ifxusb_wreg(&hc_regs->hcint, 0xFFFFFFFF);
+
+ #ifdef __DEBUG__
+ {
+ hcchar_data_t hcchar;
+ hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
+ if (hcchar.b.chdis)
+ IFX_WARN("%s: chdis set, channel %d, hcchar 0x%08x\n", __func__, _ifxhc->hc_num, hcchar.d32);
+ }
+ #endif
+}
+
+
+
+
+
+#ifdef __DEBUG__
+ static void dump_urb_info(struct urb *_urb, char* _fn_name)
+ {
+ IFX_PRINT("%s, urb %p\n" , _fn_name, _urb);
+ IFX_PRINT(" Device address: %d\n", usb_pipedevice(_urb->pipe));
+ IFX_PRINT(" Endpoint: %d, %s\n" , usb_pipeendpoint(_urb->pipe),
+ (usb_pipein(_urb->pipe) ? "IN" : "OUT"));
+ IFX_PRINT(" Endpoint type: %s\n",
+ ({ char *pipetype;
+ switch (usb_pipetype(_urb->pipe)) {
+ case PIPE_CONTROL: pipetype = "CONTROL"; break;
+ case PIPE_BULK: pipetype = "BULK"; break;
+ case PIPE_INTERRUPT: pipetype = "INTERRUPT"; break;
+ case PIPE_ISOCHRONOUS: pipetype = "ISOCHRONOUS"; break;
+ default: pipetype = "UNKNOWN"; break;
+ };
+ pipetype;
+ }));
+ IFX_PRINT(" Speed: %s\n",
+ ({ char *speed;
+ switch (_urb->dev->speed) {
+ case USB_SPEED_HIGH: speed = "HIGH"; break;
+ case USB_SPEED_FULL: speed = "FULL"; break;
+ case USB_SPEED_LOW: speed = "LOW"; break;
+ default: speed = "UNKNOWN"; break;
+ };
+ speed;
+ }));
+ IFX_PRINT(" Max packet size: %d\n",
+ usb_maxpacket(_urb->dev, _urb->pipe, usb_pipeout(_urb->pipe)));
+ IFX_PRINT(" Data buffer length: %d\n", _urb->transfer_buffer_length);
+ IFX_PRINT(" Transfer buffer: %p, Transfer DMA: %p\n",
+ _urb->transfer_buffer, (void *)_urb->transfer_dma);
+ IFX_PRINT(" Setup buffer: %p, Setup DMA: %p\n",
+ _urb->setup_packet, (void *)_urb->setup_dma);
+ IFX_PRINT(" Interval: %d\n", _urb->interval);
+ if (usb_pipetype(_urb->pipe) == PIPE_ISOCHRONOUS)
+ {
+ int i;
+ for (i = 0; i < _urb->number_of_packets; i++)
+ {
+ IFX_PRINT(" ISO Desc %d:\n", i);
+ IFX_PRINT(" offset: %d, length %d\n",
+ _urb->iso_frame_desc[i].offset,
+ _urb->iso_frame_desc[i].length);
+ }
+ }
+ }
+
+#if 0
+ static void dump_channel_info(ifxhcd_hcd_t *_ifxhcd, ifxhcd_epqh_t *_epqh)
+ {
+ if (_epqh->hc != NULL)
+ {
+ ifxhcd_hc_t *hc = _epqh->hc;
+ struct list_head *item;
+ ifxhcd_epqh_t *epqh_item;
+
+ ifxusb_hc_regs_t *hc_regs;
+
+ hcchar_data_t hcchar;
+ hcsplt_data_t hcsplt;
+ hctsiz_data_t hctsiz;
+ uint32_t hcdma;
+
+ hc_regs = _ifxhcd->core_if.hc_regs[hc->hc_num];
+ hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
+ hcsplt.d32 = ifxusb_rreg(&hc_regs->hcsplt);
+ hctsiz.d32 = ifxusb_rreg(&hc_regs->hctsiz);
+ hcdma = ifxusb_rreg(&hc_regs->hcdma);
+
+ IFX_PRINT(" Assigned to channel %d:\n" , hc->hc_num);
+ IFX_PRINT(" hcchar 0x%08x, hcsplt 0x%08x\n", hcchar.d32, hcsplt.d32);
+ IFX_PRINT(" hctsiz 0x%08x, hcdma 0x%08x\n" , hctsiz.d32, hcdma);
+ IFX_PRINT(" dev_addr: %d, ep_num: %d, is_in: %d\n",
+ hc->dev_addr, hc->ep_num, hc->is_in);
+ IFX_PRINT(" ep_type: %d\n" , hc->ep_type);
+ IFX_PRINT(" max_packet_size: %d\n", hc->mps);
+ IFX_PRINT(" data_pid_start: %d\n" , hc->data_pid_start);
+ IFX_PRINT(" halt_status: %d\n" , hc->halt_status);
+ IFX_PRINT(" xfer_buff: %p\n" , hc->xfer_buff);
+ IFX_PRINT(" xfer_len: %d\n" , hc->xfer_len);
+ IFX_PRINT(" epqh: %p\n" , hc->epqh);
+ IFX_PRINT(" NP :\n");
+ list_for_each(item, &_ifxhcd->epqh_list_np)
+ {
+ epqh_item = list_entry(item, ifxhcd_epqh_t, ql);
+ IFX_PRINT(" %p\n", epqh_item);
+ }
+ IFX_PRINT(" INTR :\n");
+ list_for_each(item, &_ifxhcd->epqh_list_intr)
+ {
+ epqh_item = list_entry(item, ifxhcd_epqh_t, ql);
+ IFX_PRINT(" %p\n", epqh_item);
+ }
+ #ifdef __EN_ISOC__
+ IFX_PRINT(" ISOC:\n");
+ list_for_each(item, &_ifxhcd->epqh_list_isoc)
+ {
+ epqh_item = list_entry(item, ifxhcd_epqh_t, ql);
+ IFX_PRINT(" %p\n", epqh_item);
+ }
+ #endif
+ }
+ }
+#endif
+#endif //__DEBUG__
+
+
+/*!
+ \brief This function writes a packet into the Tx FIFO associated with the Host
+ Channel. For a channel associated with a non-periodic EP, the non-periodic
+ Tx FIFO is written. For a channel associated with a periodic EP, the
+ periodic Tx FIFO is written. This function should only be called in Slave
+ mode.
+
+ Upon return the xfer_buff and xfer_count fields in _hc are incremented by
+ then number of bytes written to the Tx FIFO.
+ */
+
+#ifdef __ENABLE_DUMP__
+ void ifxhcd_dump_state(ifxhcd_hcd_t *_ifxhcd)
+ {
+ int num_channels;
+ int i;
+ num_channels = _ifxhcd->core_if.params.host_channels;
+ IFX_PRINT("\n");
+ IFX_PRINT("************************************************************\n");
+ IFX_PRINT("HCD State:\n");
+ IFX_PRINT(" Num channels: %d\n", num_channels);
+ for (i = 0; i < num_channels; i++) {
+ ifxhcd_hc_t *hc = &_ifxhcd->ifxhc[i];
+ IFX_PRINT(" Channel %d:\n", hc->hc_num);
+ IFX_PRINT(" dev_addr: %d, ep_num: %d, ep_is_in: %d\n",
+ hc->dev_addr, hc->ep_num, hc->is_in);
+ IFX_PRINT(" speed: %d\n" , hc->speed);
+ IFX_PRINT(" ep_type: %d\n" , hc->ep_type);
+ IFX_PRINT(" mps: %d\n", hc->mps);
+ IFX_PRINT(" data_pid_start: %d\n" , hc->data_pid_start);
+ IFX_PRINT(" xfer_buff: %p\n" , hc->xfer_buff);
+ IFX_PRINT(" xfer_len: %d\n" , hc->xfer_len);
+ IFX_PRINT(" xfer_count: %d\n" , hc->xfer_count);
+ IFX_PRINT(" halt_status: %d\n" , hc->halt_status);
+ IFX_PRINT(" split: %d\n" , hc->split);
+ IFX_PRINT(" hub_addr: %d\n" , hc->hub_addr);
+ IFX_PRINT(" port_addr: %d\n" , hc->port_addr);
+ #if defined(__EN_ISOC__) && defined(__EN_ISOC_SPLIT__)
+ IFX_PRINT(" isoc_xact_pos: %d\n" , hc->isoc_xact_pos);
+ #endif
+
+ IFX_PRINT(" epqh: %p\n" , hc->epqh);
+ IFX_PRINT(" short_rw: %d\n" , hc->short_rw);
+ IFX_PRINT(" control_phase: %d\n" , hc->control_phase);
+ if(hc->epqh)
+ {
+ IFX_PRINT(" do_ping: %d\n" , hc->epqh->do_ping);
+ }
+ IFX_PRINT(" start_pkt_count: %d\n" , hc->start_pkt_count);
+ }
+ IFX_PRINT("************************************************************\n");
+ IFX_PRINT("\n");
+ }
+#endif //__ENABLE_DUMP__
+
diff --git a/package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxhcd.h.svn-base b/package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxhcd.h.svn-base
new file mode 100644
index 0000000..243c5f5
--- /dev/null
+++ b/package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxhcd.h.svn-base
@@ -0,0 +1,758 @@
+/*****************************************************************************
+ ** FILE NAME : ifxhcd.h
+ ** PROJECT : IFX USB sub-system V3
+ ** MODULES : IFX USB sub-system Host and Device driver
+ ** SRC VERSION : 3.2
+ ** DATE : 1/Jan/2011
+ ** AUTHOR : Chen, Howard
+ ** DESCRIPTION : This file contains the structures, constants, and interfaces for
+ ** the Host Contoller Driver (HCD).
+ **
+ ** The Host Controller Driver (HCD) is responsible for translating requests
+ ** from the USB Driver into the appropriate actions on the IFXUSB controller.
+ ** It isolates the USBD from the specifics of the controller by providing an
+ ** API to the USBD.
+ ** FUNCTIONS :
+ ** COMPILER : gcc
+ ** REFERENCE : Synopsys DWC-OTG Driver 2.7
+ ** COPYRIGHT : Copyright (c) 2010
+ ** LANTIQ DEUTSCHLAND GMBH,
+ ** Am Campeon 3, 85579 Neubiberg, Germany
+ **
+ ** 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 of the License, or
+ ** (at your option) any later version.
+ **
+ ** Version Control Section **
+ ** $Author$
+ ** $Date$
+ ** $Revisions$
+ ** $Log$ Revision history
+ *****************************************************************************/
+
+/*
+ * This file contains code fragments from Synopsys HS OTG Linux Software Driver.
+ * For this code the following notice is applicable:
+ *
+ * ==========================================================================
+ *
+ * Synopsys HS OTG Linux Software Driver and documentation (hereinafter,
+ * "Software") is an Unsupported proprietary work of Synopsys, Inc. unless
+ * otherwise expressly agreed to in writing between Synopsys and you.
+ *
+ * The Software IS NOT an item of Licensed Software or Licensed Product under
+ * any End User Software License Agreement or Agreement for Licensed Product
+ * with Synopsys or any supplement thereto. You are permitted to use and
+ * redistribute this Software in source and binary forms, with or without
+ * modification, provided that redistributions of source code must retain this
+ * notice. You may not view, use, disclose, copy or distribute this file or
+ * any information contained herein except pursuant to this license grant from
+ * Synopsys. If you do not agree with this notice, including the disclaimer
+ * below, then you are not authorized to use the Software.
+ *
+ * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" BASIS
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ * ========================================================================== */
+
+/*!
+ \defgroup IFXUSB_HCD HCD Interface
+ \ingroup IFXUSB_DRIVER_V3
+ \brief The Host Controller Driver (HCD) is responsible for translating requests
+ from the USB Driver into the appropriate actions on the IFXUSB controller.
+ It isolates the USBD from the specifics of the controller by providing an
+ API to the USBD.
+ */
+
+
+/*!
+ \file ifxhcd.h
+ \ingroup IFXUSB_DRIVER_V3
+ \brief This file contains the structures, constants, and interfaces for
+ the Host Contoller Driver (HCD).
+ */
+
+#if !defined(__IFXHCD_H__)
+#define __IFXHCD_H__
+
+
+#define __STRICT_ORDER__
+
+
+#include <linux/list.h>
+#include <linux/usb.h>
+
+#include <linux/usb/hcd.h>
+
+#include "ifxusb_cif.h"
+#include "ifxusb_plat.h"
+
+
+#undef __INNAKSTOP__
+#if !defined(__INNAKSTOP__) && defined(__INNAKSTOP_CTRL__)
+ #define __INNAKSTOP__ 1
+#endif
+#if !defined(__INNAKSTOP__) && defined(__INNAKSTOP_BULK__)
+ #define __INNAKSTOP__ 1
+#endif
+
+#undef __PINGSTOP__
+#if !defined(__PINGSTOP__) && defined(__PINGSTOP_CTRL__)
+ #define __PINGSTOP__ 1
+#endif
+#if !defined(__PINGSTOP__) && defined(__PINGSTOP_BULK__)
+ #define __PINGSTOP__ 1
+#endif
+
+#undef __NAKSTOP__
+#if defined(__INNAKSTOP__) || defined(__PINGSTOP__)
+ #define __NAKSTOP__ 1
+#endif
+
+
+/* Phases for control transfers.*/
+typedef enum ifxhcd_epqh_phase {
+ EPQH_IDLE=0,
+ EPQH_DISABLING,
+// EPQH_COMPLETING,
+ EPQH_STDBY,
+ EPQH_READY,
+ EPQH_ACTIVE
+} ifxhcd_epqh_phase_e;
+
+/* Phases for control transfers.*/
+typedef enum ifxhcd_urbd_phase {
+ URBD_IDLE=0,
+ URBD_ACTIVE,
+ URBD_STARTING,
+ URBD_STARTED,
+ URBD_FINISHING, //URB_Complete already scheduled
+ URBD_COMPLETING, //To URB_Complete, it's normal finish
+ URBD_DEQUEUEING, //To URB_Complete, it's abnormal finish
+} ifxhcd_urbd_phase_e;
+
+/* Phases for control transfers.*/
+typedef enum ifxhcd_hc_phase {
+ HC_IDLE=0,
+ HC_ASSIGNED,
+ HC_WAITING,
+ HC_STARTING,
+ HC_STARTED,
+ HC_STOPPING,
+ HC_STOPPED,
+} ifxhcd_hc_phase_e;
+
+/*!
+ \addtogroup IFXUSB_HCD
+ */
+/*@{*/
+
+/*! \typedef ifxhcd_control_phase_e
+ \brief Phases for control transfers.
+*/
+
+typedef enum ifxhcd_control_phase {
+ IFXHCD_CONTROL_SETUP,
+ IFXHCD_CONTROL_DATA,
+ IFXHCD_CONTROL_STATUS
+} ifxhcd_control_phase_e;
+
+/*! \typedef ifxhcd_halt_status_e
+ \brief Reasons for halting a host channel.
+*/
+typedef enum ifxhcd_halt_status
+{
+ HC_XFER_NO_HALT_STATUS, // Initial
+ HC_XFER_COMPLETE, // Xact complete without error, upward
+ HC_XFER_URB_COMPLETE, // Xfer complete without error, short upward
+ HC_XFER_STALL, // HC stopped abnormally, upward/downward
+ HC_XFER_XACT_ERR, // HC stopped abnormally, upward
+ HC_XFER_FRAME_OVERRUN, // HC stopped abnormally, upward
+ HC_XFER_BABBLE_ERR, // HC stopped abnormally, upward
+ HC_XFER_AHB_ERR, // HC stopped abnormally, upward
+ HC_XFER_DATA_TOGGLE_ERR,
+ HC_XFER_URB_DEQUEUE, // HC stopper manually, downward
+ HC_XFER_NO_URB, // HC stopper manually, downward
+ HC_XFER_NO_EPQH, // HC stopper manually, downward
+ #ifdef __NAKSTOP__
+ HC_XFER_NAK, // HC stopped by nak monitor, downward
+ #endif
+ #if defined(__INTRNAKRETRY__) || defined(__INTRINCRETRY__)
+ HC_XFER_INTR_NAK_RETRY, // HC stopped by nak monitor, downward
+ #endif
+} ifxhcd_halt_status_e;
+
+struct ifxhcd_urbd;
+struct ifxhcd_hc ;
+struct ifxhcd_epqh ;
+struct ifxhcd_hcd;
+
+/*! typedef ifxhcd_urbd_t
+ \brief A URB Descriptor (URBD) holds the state of a bulk, control,
+ interrupt, or isochronous transfer. A single URBD is created for each URB
+ (of one of these types) submitted to the HCD. The transfer associated with
+ a URBD may require one or multiple transactions.
+
+ A URBD is linked to a EP Queue Head, which is entered in either the
+ isoc, intr or non-periodic schedule for execution. When a URBD is chosen for
+ execution, some or all of its transactions may be executed. After
+ execution, the state of the URBD is updated. The URBD may be retired if all
+ its transactions are complete or if an error occurred. Otherwise, it
+ remains in the schedule so more transactions can be executed later.
+ */
+typedef struct ifxhcd_urbd {
+ ifxhcd_urbd_phase_e phase;
+ struct list_head ql; // Hook for EPQH->urbd_list
+ struct urb *urb; /*!< URB for this transfer */
+ //struct urb {
+ // struct list_head urb_list;
+ // struct list_head anchor_list;
+ // struct usb_anchor * anchor;
+ // struct usb_device * dev;
+ // struct usb_host_endpoint * ep;
+ // unsigned int pipe;
+ // int status;
+ // unsigned int transfer_flags;
+ // void * transfer_buffer;
+ // dma_addr_t transfer_dma;
+ // u32 transfer_buffer_length;
+ // u32 actual_length;
+ // unsigned char * setup_packet;
+ // dma_addr_t setup_dma;
+ // int start_frame;
+ // int number_of_packets;
+ // int interval;
+ // int error_count;
+ // void * context;
+ // usb_complete_t complete;
+ // struct usb_iso_packet_descriptor iso_frame_desc[0];
+ //};
+ //urb_list For use by current owner of the URB.
+ //anchor_list membership in the list of an anchor
+ //anchor to anchor URBs to a common mooring
+ //dev Identifies the USB device to perform the request.
+ //ep Points to the endpoint's data structure. Will
+ // eventually replace pipe.
+ //pipe Holds endpoint number, direction, type, and more.
+ // Create these values with the eight macros available; u
+ // sb_{snd,rcv}TYPEpipe(dev,endpoint), where the TYPE is
+ // "ctrl", "bulk", "int" or "iso". For example
+ // usb_sndbulkpipe or usb_rcvintpipe. Endpoint numbers
+ // range from zero to fifteen. Note that "in" endpoint two
+ // is a different endpoint (and pipe) from "out" endpoint
+ // two. The current configuration controls the existence,
+ // type, and maximum packet size of any given endpoint.
+ //status This is read in non-iso completion functions to get
+ // the status of the particular request. ISO requests
+ // only use it to tell whether the URB was unlinked;
+ // detailed status for each frame is in the fields of
+ // the iso_frame-desc.
+ //transfer_flags A variety of flags may be used to affect how URB
+ // submission, unlinking, or operation are handled.
+ // Different kinds of URB can use different flags.
+ // URB_SHORT_NOT_OK
+ // URB_ISO_ASAP
+ // URB_NO_TRANSFER_DMA_MAP
+ // URB_NO_SETUP_DMA_MAP
+ // URB_NO_FSBR
+ // URB_ZERO_PACKET
+ // URB_NO_INTERRUPT
+ //transfer_buffer This identifies the buffer to (or from) which the I/O
+ // request will be performed (unless URB_NO_TRANSFER_DMA_MAP
+ // is set). This buffer must be suitable for DMA; allocate it
+ // with kmalloc or equivalent. For transfers to "in"
+ // endpoints, contents of this buffer will be modified. This
+ // buffer is used for the data stage of control transfers.
+ //transfer_dma When transfer_flags includes URB_NO_TRANSFER_DMA_MAP, the
+ // device driver is saying that it provided this DMA address,
+ // which the host controller driver should use in preference
+ // to the transfer_buffer.
+ //transfer_buffer_length How big is transfer_buffer. The transfer may be broken
+ // up into chunks according to the current maximum packet size
+ // for the endpoint, which is a function of the configuration
+ // and is encoded in the pipe. When the length is zero, neither
+ // transfer_buffer nor transfer_dma is used.
+ //actual_length This is read in non-iso completion functions, and it tells
+ // how many bytes (out of transfer_buffer_length) were transferred.
+ // It will normally be the same as requested, unless either an error
+ // was reported or a short read was performed. The URB_SHORT_NOT_OK
+ // transfer flag may be used to make such short reads be reported
+ // as errors.
+ //setup_packet Only used for control transfers, this points to eight bytes of
+ // setup data. Control transfers always start by sending this data
+ // to the device. Then transfer_buffer is read or written, if needed.
+ //setup_dma For control transfers with URB_NO_SETUP_DMA_MAP set, the device
+ // driver has provided this DMA address for the setup packet. The
+ // host controller driver should use this in preference to setup_packet.
+ //start_frame Returns the initial frame for isochronous transfers.
+ //number_of_packets Lists the number of ISO transfer buffers.
+ //interval Specifies the polling interval for interrupt or isochronous transfers.
+ // The units are frames (milliseconds) for for full and low speed devices,
+ // and microframes (1/8 millisecond) for highspeed ones.
+ //error_count Returns the number of ISO transfers that reported errors.
+ //context For use in completion functions. This normally points to request-specific
+ // driver context.
+ //complete Completion handler. This URB is passed as the parameter to the completion
+ // function. The completion function may then do what it likes with the URB,
+ // including resubmitting or freeing it.
+ //iso_frame_desc[0] Used to provide arrays of ISO transfer buffers and to collect the transfer
+ // status for each buffer.
+
+ struct ifxhcd_epqh *epqh;
+ // Actual data portion, not SETUP or STATUS in case of CTRL XFER
+ // DMA adjusted
+ uint8_t *setup_buff; /*!< Pointer to the entire transfer buffer. (CPU accessable)*/
+ uint8_t *xfer_buff; /*!< Pointer to the entire transfer buffer. (CPU accessable)*/
+ uint32_t xfer_len; /*!< Total number of bytes to transfer in this xfer. */
+
+ #if defined(__UNALIGNED_BUF_ADJ__)
+// uint8_t using_aligned_setup;
+ uint8_t *aligned_setup;
+// uint8_t using_aligned_buf;
+ uint8_t *aligned_buf;
+ unsigned aligned_buf_len : 19;
+ #endif
+ #if defined(__UNALIGNED_BUF_ADJ__) || defined(__UNALIGNED_BUF_CHK__)
+ unsigned aligned_checked : 1;
+ #endif
+ unsigned is_in :1;
+ #ifndef __STRICT_ORDER__
+ struct tasklet_struct complete_urb_sub;
+ #endif
+
+ // For ALL XFER
+ uint8_t error_count; /*!< Holds the number of bus errors that have occurred for a transaction
+ within this transfer.
+ */
+ // For ISOC XFER only
+ #ifdef __EN_ISOC__
+ int isoc_frame_index; /*!< Index of the next frame descriptor for an isochronous transfer. A
+ frame descriptor describes the buffer position and length of the
+ data to be transferred in the next scheduled (micro)frame of an
+ isochronous transfer. It also holds status for that transaction.
+ The frame index starts at 0.
+ */
+ #endif
+ int status;
+} ifxhcd_urbd_t;
+
+/*! typedef ifxhcd_epqh_t
+ \brief A EP Queue Head (EPQH) holds the static characteristics of an endpoint and
+ maintains a list of transfers (URBDs) for that endpoint. A EPQH structure may
+ be entered in either the isoc, intr or non-periodic schedule.
+ */
+
+typedef struct ifxhcd_epqh {
+ struct ifxhcd_hcd *ifxhcd;
+ struct usb_host_endpoint *sysep;
+ uint8_t devno;
+
+ ifxhcd_epqh_phase_e phase;
+ struct list_head ql_all;
+ struct list_head ql; // Hook for EP Queues
+ struct list_head urbd_list; /*!< List of URBDs for this EPQH. */
+ #ifdef __STRICT_ORDER__
+ struct list_head release_list;
+ struct tasklet_struct complete_urb_sub;
+ #endif
+ struct ifxhcd_hc *hc; /*!< Host channel currently processing transfers for this EPQH. */
+ struct ifxhcd_urbd *urbd; /*!< URBD currently assigned to a host channel for this EPQH. */
+ uint8_t ep_type; /*!< Endpoint type. One of the following values:
+ - IFXUSB_EP_TYPE_CTRL
+ - IFXUSB_EP_TYPE_ISOC
+ - IFXUSB_EP_TYPE_BULK
+ - IFXUSB_EP_TYPE_INTR
+ */
+ uint16_t mps; /*!< wMaxPacketSize Field of Endpoint Descriptor. */
+ #ifdef __EPQD_DESTROY_TIMEOUT__
+ struct timer_list destroy_timer;
+ #endif
+
+ unsigned need_split : 1 ;
+ unsigned do_ping : 1 ; /*!< Set to 1 to indicate that a PING request should be issued on this
+ channel. If 0, process normally.
+ */
+ unsigned pause : 1;
+ unsigned period_do : 1;
+ uint16_t interval; /*!< Interval between transfers in (micro)frames. (for INTR)*/
+ uint16_t period_counter; /*!< Interval between transfers in (micro)frames. */
+
+ #ifdef __EN_ISOC__
+ struct tasklet_struct tasklet_next_isoc;
+ uint8_t isoc_now;
+ uint32_t isoc_start_frame;
+ // For SPLITed ISOC XFER only
+ #ifdef __EN_ISOC_SPLIT__
+ uint8_t isoc_split_pos; /*!< Position of the ISOC split on full/low speed */
+ uint16_t isoc_split_offset;/*!< Position of the ISOC split in the buffer for the current frame */
+ #endif
+ #endif
+ spinlock_t urbd_list_lock;
+ int urbd_count;
+} ifxhcd_epqh_t;
+
+
+/*! typedef ifxhcd_hc_t
+ \brief Host channel descriptor. This structure represents the state of a single
+ host channel when acting in host mode. It contains the data items needed to
+ transfer packets to an endpoint via a host channel.
+ */
+typedef struct ifxhcd_hc
+{
+ struct ifxhcd_epqh *epqh ; /*!< EP Queue Head for the transfer being processed by this channel. */
+ uint8_t hc_num ; /*!< Host channel number used for register address lookup */
+ uint8_t *xfer_buff ; /*!< Pointer to the entire transfer buffer. */
+ uint32_t xfer_count ; /*!< Number of bytes transferred so far. The offset of the begin of the buf */
+ uint32_t xfer_len ; /*!< Total number of bytes to transfer in this xfer. */
+ uint16_t start_pkt_count ; /*!< Packet count at start of transfer. Used to calculate the actual xfer size*/
+ ifxhcd_halt_status_e halt_status; /*!< Reason for halting the host channel. */
+ ifxhcd_hc_phase_e phase;
+
+ unsigned dev_addr : 7; /*!< Device to access */
+ unsigned ep_num : 4; /*!< EP to access */
+ unsigned is_in : 1; /*!< EP direction. 0: OUT, 1: IN */
+ unsigned speed : 2; /*!< EP speed. */
+ unsigned ep_type : 2; /*!< Endpoint type. */
+ unsigned mps :11; /*!< Max packet size in bytes */
+ unsigned data_pid_start : 2; /*!< PID for initial transaction. */
+ unsigned short_rw : 1; /*!< When Tx, means termination needed.
+ When Rx, indicate Short Read */
+ /* Split settings for the host channel */
+ unsigned split : 2; /*!< Split: 0-Non Split, 1-SSPLIT, 2&3 CSPLIT */
+
+ unsigned sof_delay :16;
+ unsigned erron : 1;
+
+ #ifdef __NAKSTOP__
+ unsigned stop_on : 1;
+// unsigned wait_for_sof_quick : 1;
+ #endif
+
+ ifxhcd_control_phase_e control_phase; /*!< Current phase for control transfers (Setup, Data, or Status). */
+ uint32_t ssplit_out_xfer_count; /*!< How many bytes transferred during SSPLIT OUT */
+ #ifdef __DEBUG__
+ uint32_t start_hcchar_val;
+ #endif
+ uint32_t hcchar;
+
+ /* Split settings for the host channel */
+ uint8_t hub_addr; /*!< Address of high speed hub */
+ uint8_t port_addr; /*!< Port of the low/full speed device */
+ #if defined(__EN_ISOC__) && defined(__EN_ISOC_SPLIT__)
+ uint8_t isoc_xact_pos; /*!< Split transaction position */
+ #endif
+} ifxhcd_hc_t;
+
+
+/*! typedef ifxhcd_hcd_t
+ \brief This structure holds the state of the HCD, including the non-periodic and
+ periodic schedules.
+ */
+typedef struct ifxhcd_hcd
+{
+ struct device *dev;
+ struct hc_driver hc_driver;
+ ifxusb_core_if_t core_if; /*!< Pointer to the core interface structure. */
+ struct usb_hcd *syshcd;
+
+ volatile union
+ {
+ uint32_t d32;
+ struct
+ {
+ unsigned port_connect_status_change : 1;
+ unsigned port_connect_status : 1;
+ unsigned port_reset_change : 1;
+ unsigned port_enable_change : 1;
+ unsigned port_suspend_change : 1;
+ unsigned port_over_current_change : 1;
+ unsigned reserved : 27;
+ } b;
+ } flags; /*!< Internal HCD Flags */
+
+ struct ifxhcd_hc ifxhc[MAX_EPS_CHANNELS]; /*!< Array of pointers to the host channel descriptors. Allows accessing
+ a host channel descriptor given the host channel number. This is
+ useful in interrupt handlers.
+ */
+ uint8_t *status_buf; /*!< Buffer to use for any data received during the status phase of a
+ control transfer. Normally no data is transferred during the status
+ phase. This buffer is used as a bit bucket.
+ */
+ #define IFXHCD_STATUS_BUF_SIZE 64 /*!< buffer size of status phase in CTRL xfer */
+
+ struct list_head epqh_list_all;
+ struct list_head epqh_list_np;
+ struct list_head epqh_list_intr;
+ #ifdef __EN_ISOC__
+ struct list_head epqh_list_isoc;
+ #endif
+
+ uint32_t lastframe;
+
+ uint16_t pkt_remaining;
+ uint16_t pkt_remaining_reload;
+ uint16_t pkt_remaining_reload_hs;
+ uint16_t pkt_remaining_reload_fs;
+ uint16_t pkt_remaining_reload_ls;
+ #define PKT_REMAINING_RELOAD_HS 88
+ #define PKT_REMAINING_RELOAD_FS 10
+ #define PKT_REMAINING_RELOAD_LS 20
+ #ifdef __EN_ISOC__
+ uint8_t isoc_ep_count;
+ #endif
+
+ spinlock_t epqh_list_lock;
+ spinlock_t epqh_list_all_lock;
+
+ struct timer_list host_probe_timer;
+ struct timer_list autoprobe_timer;
+
+ unsigned power_status;
+ int probe_sec;
+ int autoprobe_sec;
+ #ifdef __DYN_SOF_INTR__
+ uint32_t dyn_sof_count;
+ #define DYN_SOF_COUNT_DEF 40000
+ #endif
+ struct tasklet_struct tasklet_select_eps; /*!< Tasket to do a reset */
+ struct tasklet_struct tasklet_free_epqh_list ; /*!< Tasket to do a reset */
+ unsigned disconnecting : 1 ;
+
+ uint8_t pkt_count_limit_bo;
+ uint8_t pkt_count_limit_bi;
+} ifxhcd_hcd_t;
+
+/* Gets the ifxhcd_hcd from a struct usb_hcd */
+static inline ifxhcd_hcd_t *syshcd_to_ifxhcd(struct usb_hcd *syshcd)
+{
+ return (ifxhcd_hcd_t *)(syshcd->hcd_priv[0]);
+}
+
+/* Gets the struct usb_hcd that contains a ifxhcd_hcd_t. */
+static inline struct usb_hcd *ifxhcd_to_syshcd(ifxhcd_hcd_t *ifxhcd)
+{
+ return (struct usb_hcd *)(ifxhcd->syshcd);
+}
+
+
+extern ifxhcd_epqh_t * sysep_to_epqh(ifxhcd_hcd_t *_ifxhcd, struct usb_host_endpoint *_sysep);
+
+/* HCD Create/Destroy Functions */
+ extern int ifxhcd_init (ifxhcd_hcd_t *_ifxhcd);
+ extern void ifxhcd_remove(ifxhcd_hcd_t *_ifxhcd);
+
+/*Linux HC Driver API Functions */
+
+extern int ifxhcd_start(struct usb_hcd *hcd);
+extern void ifxhcd_stop (struct usb_hcd *hcd);
+extern int ifxhcd_get_frame_number(struct usb_hcd *hcd);
+
+
+/*!
+ \brief This function does the setup for a data transfer for a host channel and
+ starts the transfer. May be called in either Slave mode or DMA mode. In
+ Slave mode, the caller must ensure that there is sufficient space in the
+ request queue and Tx Data FIFO.
+
+ For an OUT transfer in Slave mode, it loads a data packet into the
+ appropriate FIFO. If necessary, additional data packets will be loaded in
+ the Host ISR.
+
+ For an IN transfer in Slave mode, a data packet is requested. The data
+ packets are unloaded from the Rx FIFO in the Host ISR. If necessary,
+ additional data packets are requested in the Host ISR.
+
+ For a PING transfer in Slave mode, the Do Ping bit is set in the HCTSIZ
+ register along with a packet count of 1 and the channel is enabled. This
+ causes a single PING transaction to occur. Other fields in HCTSIZ are
+ simply set to 0 since no data transfer occurs in this case.
+
+ For a PING transfer in DMA mode, the HCTSIZ register is initialized with
+ all the information required to perform the subsequent data transfer. In
+ addition, the Do Ping bit is set in the HCTSIZ register. In this case, the
+ controller performs the entire PING protocol, then starts the data
+ transfer.
+
+ @param _ifxhc Information needed to initialize the host channel. The xfer_len
+ value may be reduced to accommodate the max widths of the XferSize and
+ PktCnt fields in the HCTSIZn register. The multi_count value may be changed
+ to reflect the final xfer_len value.
+ */
+extern void ifxhcd_hc_start(ifxhcd_hcd_t *_ifxhcd, ifxhcd_hc_t *_ifxhc);
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)
+extern int ifxhcd_urb_enqueue(struct usb_hcd *_syshcd, struct usb_host_endpoint *_sysep, struct urb *_urb, gfp_t mem_flags);
+extern int ifxhcd_urb_dequeue(struct usb_hcd *_syshcd, struct urb *_urb);
+#else
+extern int ifxhcd_urb_enqueue(struct usb_hcd *_syshcd, struct urb *_urb, gfp_t mem_flags);
+extern int ifxhcd_urb_dequeue(struct usb_hcd *_syshcd, struct urb *_urb, int status);
+#endif
+extern irqreturn_t ifxhcd_irq(struct usb_hcd *_syshcd);
+
+extern void ifxhcd_endpoint_disable(struct usb_hcd *_syshcd, struct usb_host_endpoint *_sysep);
+
+extern int ifxhcd_hub_status_data(struct usb_hcd *_syshcd, char *_buf);
+extern int ifxhcd_hub_control( struct usb_hcd *_syshcd,
+ u16 _typeReq,
+ u16 _wValue,
+ u16 _wIndex,
+ char *_buf,
+ u16 _wLength);
+
+/*@}*/
+
+/*! \brief Transaction Execution Functions */
+/*@{*/
+extern void ifxhcd_complete_urb (ifxhcd_hcd_t *_ifxhcd, ifxhcd_urbd_t *_urbd, int _status);
+
+/*!
+ \brief Clears the transfer state for a host channel. This function is normally
+ called after a transfer is done and the host channel is being released.
+ */
+extern void ifxhcd_hc_cleanup(ifxusb_core_if_t *_core_if, ifxhcd_hc_t *_ifxhc);
+
+/*!
+ \brief Attempts to halt a host channel. This function should only be called in
+ Slave mode or to abort a transfer in either Slave mode or DMA mode. Under
+ normal circumstances in DMA mode, the controller halts the channel when the
+ transfer is complete or a condition occurs that requires application
+ intervention.
+
+ In DMA mode, always sets the Channel Enable and Channel Disable bits of the
+ HCCHARn register. The controller ensures there is space in the request
+ queue before submitting the halt request.
+
+ Some time may elapse before the core flushes any posted requests for this
+ host channel and halts. The Channel Halted interrupt handler completes the
+ deactivation of the host channel.
+ */
+extern int ifxhcd_hc_halt(ifxusb_core_if_t *_core_if,
+ ifxhcd_hc_t *_ifxhc,
+ ifxhcd_halt_status_e _halt_status);
+
+/*!
+ \brief Prepares a host channel for transferring packets to/from a specific
+ endpoint. The HCCHARn register is set up with the characteristics specified
+ in _ifxhc. Host channel interrupts that may need to be serviced while this
+ transfer is in progress are enabled.
+ */
+extern void ifxhcd_hc_init(ifxusb_core_if_t *_core_if, ifxhcd_hc_t *_ifxhc);
+
+/*!
+ \brief This function is called to handle the disconnection of host port.
+ */
+int32_t ifxhcd_disconnect(ifxhcd_hcd_t *_ifxhcd);
+/*@}*/
+
+/*! \brief Interrupt Handler Functions */
+/*@{*/
+extern irqreturn_t ifxhcd_oc_irq(int _irq, void *_dev);
+
+extern int32_t ifxhcd_handle_oc_intr(ifxhcd_hcd_t *_ifxhcd);
+extern int32_t ifxhcd_handle_intr (ifxhcd_hcd_t *_ifxhcd);
+/*@}*/
+
+
+/*! \brief Schedule Queue Functions */
+/*@{*/
+extern void ifxhcd_epqh_free (ifxhcd_epqh_t *_epqh);
+extern void select_eps (ifxhcd_hcd_t *_ifxhcd);
+extern void ifxhcd_epqh_idle(ifxhcd_epqh_t *_epqh);
+extern void ifxhcd_epqh_idle_periodic(ifxhcd_epqh_t *_epqh);
+extern ifxhcd_epqh_t *ifxhcd_urbd_create (ifxhcd_hcd_t *_ifxhcd,struct urb *_urb);
+/*@}*/
+
+/*! \brief Gets the usb_host_endpoint associated with an URB. */
+static inline struct usb_host_endpoint *ifxhcd_urb_to_endpoint(struct urb *_urb)
+{
+ struct usb_device *dev = _urb->dev;
+ int ep_num = usb_pipeendpoint(_urb->pipe);
+
+ return (usb_pipein(_urb->pipe))?(dev->ep_in[ep_num]):(dev->ep_out[ep_num]);
+}
+
+/*!
+ * \brief Gets the endpoint number from a _bEndpointAddress argument. The endpoint is
+ * qualified with its direction (possible 32 endpoints per device).
+ */
+#define ifxhcd_ep_addr_to_endpoint(_bEndpointAddress_) ((_bEndpointAddress_ & USB_ENDPOINT_NUMBER_MASK) | \
+ ((_bEndpointAddress_ & USB_DIR_IN) != 0) << 4)
+
+
+
+/*! Internal debug function */
+void ifxhcd_dump_state(ifxhcd_hcd_t *_ifxhcd);
+
+/*@}*//*IFXUSB_HCD*/
+
+extern struct usb_device *usb_alloc_dev (struct usb_device *parent, struct usb_bus *, unsigned port);
+extern int usb_add_hcd (struct usb_hcd *syshcd, unsigned int irqnum, unsigned long irqflags);
+extern void usb_remove_hcd (struct usb_hcd *syshcd);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)
+extern struct usb_hcd *usb_create_hcd (const struct hc_driver *driver, struct device *dev, char *bus_name);
+#else
+extern struct usb_hcd *usb_create_hcd (const struct hc_driver *driver, struct device *dev, const char *bus_name);
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)
+extern void usb_hcd_giveback_urb (struct usb_hcd *syshcd, struct urb *urb);
+#else
+extern void usb_hcd_giveback_urb (struct usb_hcd *syshcd, struct urb *urb,int status);
+#endif
+
+extern void usb_put_hcd (struct usb_hcd *syshcd);
+extern long usb_calc_bus_time (int speed, int is_input, int isoc, int bytecount);
+extern char *syserr(int errno);
+
+
+
+static inline void INIT_EPQH_LIST_ALL(ifxhcd_hcd_t *_ifxhcd)
+{
+ spin_lock_init(&_ifxhcd->epqh_list_all_lock);
+}
+static inline void LOCK_EPQH_LIST_ALL(ifxhcd_hcd_t *_ifxhcd)
+{
+ spin_lock(&_ifxhcd->epqh_list_all_lock);
+}
+static inline void UNLOCK_EPQH_LIST_ALL(ifxhcd_hcd_t *_ifxhcd)
+{
+ spin_unlock(&_ifxhcd->epqh_list_all_lock);
+}
+
+static inline void INIT_EPQH_LIST(ifxhcd_hcd_t *_ifxhcd)
+{
+ spin_lock_init(&_ifxhcd->epqh_list_lock);
+}
+static inline void LOCK_EPQH_LIST(ifxhcd_hcd_t *_ifxhcd)
+{
+ spin_lock(&_ifxhcd->epqh_list_lock);
+}
+static inline void UNLOCK_EPQH_LIST(ifxhcd_hcd_t *_ifxhcd)
+{
+ spin_unlock(&_ifxhcd->epqh_list_lock);
+}
+
+static inline void INIT_URBD_LIST(ifxhcd_epqh_t *_epqh)
+{
+ spin_lock_init(&_epqh->urbd_list_lock);
+}
+static inline void LOCK_URBD_LIST(ifxhcd_epqh_t *_epqh)
+{
+ spin_lock(&_epqh->urbd_list_lock);
+}
+static inline void UNLOCK_URBD_LIST(ifxhcd_epqh_t *_epqh)
+{
+ spin_unlock(&_epqh->urbd_list_lock);
+}
+
+#endif // __IFXHCD_H__
+
diff --git a/package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxhcd_es.c.svn-base b/package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxhcd_es.c.svn-base
new file mode 100644
index 0000000..a7d18dd
--- /dev/null
+++ b/package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxhcd_es.c.svn-base
@@ -0,0 +1,599 @@
+/*****************************************************************************
+ ** FILE NAME : ifxhcd_es.c
+ ** PROJECT : IFX USB sub-system V3
+ ** MODULES : IFX USB sub-system Host and Device driver
+ ** SRC VERSION : 1.0
+ ** DATE : 1/Jan/2009
+ ** AUTHOR : Chen, Howard
+ ** DESCRIPTION : The file contain function to enable host mode USB-IF Electrical Test function.
+ ** FUNCTIONS :
+ ** COMPILER : gcc
+ ** REFERENCE : Synopsys DWC-OTG Driver 2.7
+ ** COPYRIGHT : Copyright (c) 2010
+ ** LANTIQ DEUTSCHLAND GMBH,
+ ** Am Campeon 3, 85579 Neubiberg, Germany
+ **
+ ** 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 of the License, or
+ ** (at your option) any later version.
+ **
+ ** Version Control Section **
+ ** $Author$
+ ** $Date$
+ ** $Revisions$
+ ** $Log$ Revision history
+ *****************************************************************************/
+
+/*
+ * This file contains code fragments from Synopsys HS OTG Linux Software Driver.
+ * For this code the following notice is applicable:
+ *
+ * ==========================================================================
+ *
+ * Synopsys HS OTG Linux Software Driver and documentation (hereinafter,
+ * "Software") is an Unsupported proprietary work of Synopsys, Inc. unless
+ * otherwise expressly agreed to in writing between Synopsys and you.
+ *
+ * The Software IS NOT an item of Licensed Software or Licensed Product under
+ * any End User Software License Agreement or Agreement for Licensed Product
+ * with Synopsys or any supplement thereto. You are permitted to use and
+ * redistribute this Software in source and binary forms, with or without
+ * modification, provided that redistributions of source code must retain this
+ * notice. You may not view, use, disclose, copy or distribute this file or
+ * any information contained herein except pursuant to this license grant from
+ * Synopsys. If you do not agree with this notice, including the disclaimer
+ * below, then you are not authorized to use the Software.
+ *
+ * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" BASIS
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ * ========================================================================== */
+
+/*!
+ \file ifxhcd_es.c
+ \ingroup IFXUSB_DRIVER_V3
+ \brief The file contain function to enable host mode USB-IF Electrical Test function.
+*/
+
+#include <linux/version.h>
+#include "ifxusb_version.h"
+
+#include <linux/kernel.h>
+
+#include <linux/errno.h>
+
+#include <linux/dma-mapping.h>
+
+#include "ifxusb_plat.h"
+#include "ifxusb_regs.h"
+#include "ifxusb_cif.h"
+#include "ifxhcd.h"
+
+
+#ifdef __WITH_HS_ELECT_TST__
+ /*
+ * Quick and dirty hack to implement the HS Electrical Test
+ * SINGLE_STEP_GET_DEVICE_DESCRIPTOR feature.
+ *
+ * This code was copied from our userspace app "hset". It sends a
+ * Get Device Descriptor control sequence in two parts, first the
+ * Setup packet by itself, followed some time later by the In and
+ * Ack packets. Rather than trying to figure out how to add this
+ * functionality to the normal driver code, we just hijack the
+ * hardware, using these two function to drive the hardware
+ * directly.
+ */
+
+
+ void do_setup(ifxusb_core_if_t *_core_if)
+ {
+
+ ifxusb_core_global_regs_t *global_regs = _core_if->core_global_regs;
+ ifxusb_host_global_regs_t *hc_global_regs = _core_if->host_global_regs;
+ ifxusb_hc_regs_t *hc_regs = _core_if->hc_regs[0];
+ uint32_t *data_fifo = _core_if->data_fifo[0];
+
+ gint_data_t gintsts;
+ hctsiz_data_t hctsiz;
+ hcchar_data_t hcchar;
+ haint_data_t haint;
+ hcint_data_t hcint;
+
+
+ /* Enable HAINTs */
+ ifxusb_wreg(&hc_global_regs->haintmsk, 0x0001);
+
+ /* Enable HCINTs */
+ ifxusb_wreg(&hc_regs->hcintmsk, 0x04a3);
+
+ /* Read GINTSTS */
+ gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
+ //fprintf(stderr, "GINTSTS: %08x\n", gintsts.d32);
+
+ /* Read HAINT */
+ haint.d32 = ifxusb_rreg(&hc_global_regs->haint);
+ //fprintf(stderr, "HAINT: %08x\n", haint.d32);
+
+ /* Read HCINT */
+ hcint.d32 = ifxusb_rreg(&hc_regs->hcint);
+ //fprintf(stderr, "HCINT: %08x\n", hcint.d32);
+
+ /* Read HCCHAR */
+ hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
+ //fprintf(stderr, "HCCHAR: %08x\n", hcchar.d32);
+
+ /* Clear HCINT */
+ ifxusb_wreg(&hc_regs->hcint, hcint.d32);
+
+ /* Clear HAINT */
+ ifxusb_wreg(&hc_global_regs->haint, haint.d32);
+
+ /* Clear GINTSTS */
+ ifxusb_wreg(&global_regs->gintsts, gintsts.d32);
+
+ /* Read GINTSTS */
+ gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
+ //fprintf(stderr, "GINTSTS: %08x\n", gintsts.d32);
+
+ /*
+ * Send Setup packet (Get Device Descriptor)
+ */
+
+ /* Make sure channel is disabled */
+ hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
+ if (hcchar.b.chen) {
+ //fprintf(stderr, "Channel already enabled 1, HCCHAR = %08x\n", hcchar.d32);
+ hcchar.b.chdis = 1;
+ // hcchar.b.chen = 1;
+ ifxusb_wreg(&hc_regs->hcchar, hcchar.d32);
+ //sleep(1);
+ mdelay(1000);
+
+ /* Read GINTSTS */
+ gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
+ //fprintf(stderr, "GINTSTS: %08x\n", gintsts.d32);
+
+ /* Read HAINT */
+ haint.d32 = ifxusb_rreg(&hc_global_regs->haint);
+ //fprintf(stderr, "HAINT: %08x\n", haint.d32);
+
+ /* Read HCINT */
+ hcint.d32 = ifxusb_rreg(&hc_regs->hcint);
+ //fprintf(stderr, "HCINT: %08x\n", hcint.d32);
+
+ /* Read HCCHAR */
+ hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
+ //fprintf(stderr, "HCCHAR: %08x\n", hcchar.d32);
+
+ /* Clear HCINT */
+ ifxusb_wreg(&hc_regs->hcint, hcint.d32);
+
+ /* Clear HAINT */
+ ifxusb_wreg(&hc_global_regs->haint, haint.d32);
+
+ /* Clear GINTSTS */
+ ifxusb_wreg(&global_regs->gintsts, gintsts.d32);
+
+ hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
+ //if (hcchar.b.chen) {
+ // fprintf(stderr, "** Channel _still_ enabled 1, HCCHAR = %08x **\n", hcchar.d32);
+ //}
+ }
+
+ /* Set HCTSIZ */
+ hctsiz.d32 = 0;
+ hctsiz.b.xfersize = 8;
+ hctsiz.b.pktcnt = 1;
+ hctsiz.b.pid = IFXUSB_HC_PID_SETUP;
+ ifxusb_wreg(&hc_regs->hctsiz, hctsiz.d32);
+
+ /* Set HCCHAR */
+ hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
+ hcchar.b.eptype = IFXUSB_EP_TYPE_CTRL;
+ hcchar.b.epdir = 0;
+ hcchar.b.epnum = 0;
+ hcchar.b.mps = 8;
+ hcchar.b.chen = 1;
+ ifxusb_wreg(&hc_regs->hcchar, hcchar.d32);
+
+ /* Fill FIFO with Setup data for Get Device Descriptor */
+ ifxusb_wreg(data_fifo++, 0x01000680);
+ ifxusb_wreg(data_fifo++, 0x00080000);
+
+ gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
+ //fprintf(stderr, "Waiting for HCINTR intr 1, GINTSTS = %08x\n", gintsts.d32);
+
+ /* Wait for host channel interrupt */
+ do {
+ gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
+ } while (gintsts.b.hcintr == 0);
+
+ //fprintf(stderr, "Got HCINTR intr 1, GINTSTS = %08x\n", gintsts.d32);
+
+ /* Disable HCINTs */
+ ifxusb_wreg(&hc_regs->hcintmsk, 0x0000);
+
+ /* Disable HAINTs */
+ ifxusb_wreg(&hc_global_regs->haintmsk, 0x0000);
+
+ /* Read HAINT */
+ haint.d32 = ifxusb_rreg(&hc_global_regs->haint);
+ //fprintf(stderr, "HAINT: %08x\n", haint.d32);
+
+ /* Read HCINT */
+ hcint.d32 = ifxusb_rreg(&hc_regs->hcint);
+ //fprintf(stderr, "HCINT: %08x\n", hcint.d32);
+
+ /* Read HCCHAR */
+ hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
+ //fprintf(stderr, "HCCHAR: %08x\n", hcchar.d32);
+
+ /* Clear HCINT */
+ ifxusb_wreg(&hc_regs->hcint, hcint.d32);
+
+ /* Clear HAINT */
+ ifxusb_wreg(&hc_global_regs->haint, haint.d32);
+
+ /* Clear GINTSTS */
+ ifxusb_wreg(&global_regs->gintsts, gintsts.d32);
+
+ /* Read GINTSTS */
+ gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
+ //fprintf(stderr, "GINTSTS: %08x\n", gintsts.d32);
+ }
+
+ void do_in_ack(ifxusb_core_if_t *_core_if)
+ {
+
+ ifxusb_core_global_regs_t *global_regs = _core_if->core_global_regs;
+ ifxusb_host_global_regs_t *hc_global_regs = _core_if->host_global_regs;
+ ifxusb_hc_regs_t *hc_regs = _core_if->hc_regs[0];
+ uint32_t *data_fifo = _core_if->data_fifo[0];
+
+ gint_data_t gintsts;
+ hctsiz_data_t hctsiz;
+ hcchar_data_t hcchar;
+ haint_data_t haint;
+ hcint_data_t hcint;
+ grxsts_data_t grxsts;
+
+ /* Enable HAINTs */
+ ifxusb_wreg(&hc_global_regs->haintmsk, 0x0001);
+
+ /* Enable HCINTs */
+ ifxusb_wreg(&hc_regs->hcintmsk, 0x04a3);
+
+ /* Read GINTSTS */
+ gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
+ //fprintf(stderr, "GINTSTS: %08x\n", gintsts.d32);
+
+ /* Read HAINT */
+ haint.d32 = ifxusb_rreg(&hc_global_regs->haint);
+ //fprintf(stderr, "HAINT: %08x\n", haint.d32);
+
+ /* Read HCINT */
+ hcint.d32 = ifxusb_rreg(&hc_regs->hcint);
+ //fprintf(stderr, "HCINT: %08x\n", hcint.d32);
+
+ /* Read HCCHAR */
+ hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
+ //fprintf(stderr, "HCCHAR: %08x\n", hcchar.d32);
+
+ /* Clear HCINT */
+ ifxusb_wreg(&hc_regs->hcint, hcint.d32);
+
+ /* Clear HAINT */
+ ifxusb_wreg(&hc_global_regs->haint, haint.d32);
+
+ /* Clear GINTSTS */
+ ifxusb_wreg(&global_regs->gintsts, gintsts.d32);
+
+ /* Read GINTSTS */
+ gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
+ //fprintf(stderr, "GINTSTS: %08x\n", gintsts.d32);
+
+ /*
+ * Receive Control In packet
+ */
+
+ /* Make sure channel is disabled */
+ hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
+ if (hcchar.b.chen) {
+ //fprintf(stderr, "Channel already enabled 2, HCCHAR = %08x\n", hcchar.d32);
+ hcchar.b.chdis = 1;
+ hcchar.b.chen = 1;
+ ifxusb_wreg(&hc_regs->hcchar, hcchar.d32);
+ //sleep(1);
+ mdelay(1000);
+
+ /* Read GINTSTS */
+ gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
+ //fprintf(stderr, "GINTSTS: %08x\n", gintsts.d32);
+
+ /* Read HAINT */
+ haint.d32 = ifxusb_rreg(&hc_global_regs->haint);
+ //fprintf(stderr, "HAINT: %08x\n", haint.d32);
+
+ /* Read HCINT */
+ hcint.d32 = ifxusb_rreg(&hc_regs->hcint);
+ //fprintf(stderr, "HCINT: %08x\n", hcint.d32);
+
+ /* Read HCCHAR */
+ hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
+ //fprintf(stderr, "HCCHAR: %08x\n", hcchar.d32);
+
+ /* Clear HCINT */
+ ifxusb_wreg(&hc_regs->hcint, hcint.d32);
+
+ /* Clear HAINT */
+ ifxusb_wreg(&hc_global_regs->haint, haint.d32);
+
+ /* Clear GINTSTS */
+ ifxusb_wreg(&global_regs->gintsts, gintsts.d32);
+
+ hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
+ //if (hcchar.b.chen) {
+ // fprintf(stderr, "** Channel _still_ enabled 2, HCCHAR = %08x **\n", hcchar.d32);
+ //}
+ }
+
+ /* Set HCTSIZ */
+ hctsiz.d32 = 0;
+ hctsiz.b.xfersize = 8;
+ hctsiz.b.pktcnt = 1;
+ hctsiz.b.pid = IFXUSB_HC_PID_DATA1;
+ ifxusb_wreg(&hc_regs->hctsiz, hctsiz.d32);
+
+ /* Set HCCHAR */
+ hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
+ hcchar.b.eptype = IFXUSB_EP_TYPE_CTRL;
+ hcchar.b.epdir = 1;
+ hcchar.b.epnum = 0;
+ hcchar.b.mps = 8;
+ hcchar.b.chen = 1;
+ ifxusb_wreg(&hc_regs->hcchar, hcchar.d32);
+
+ gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
+ //fprintf(stderr, "Waiting for RXSTSQLVL intr 1, GINTSTS = %08x\n", gintsts.d32);
+
+ /* Wait for receive status queue interrupt */
+ do {
+ gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
+ } while (gintsts.b.rxstsqlvl == 0);
+
+ //fprintf(stderr, "Got RXSTSQLVL intr 1, GINTSTS = %08x\n", gintsts.d32);
+
+ /* Read RXSTS */
+ grxsts.d32 = ifxusb_rreg(&global_regs->grxstsp);
+ //fprintf(stderr, "GRXSTS: %08x\n", grxsts.d32);
+
+ /* Clear RXSTSQLVL in GINTSTS */
+ gintsts.d32 = 0;
+ gintsts.b.rxstsqlvl = 1;
+ ifxusb_wreg(&global_regs->gintsts, gintsts.d32);
+
+ switch (grxsts.hb.pktsts) {
+ case IFXUSB_HSTS_DATA_UPDT:
+ /* Read the data into the host buffer */
+ if (grxsts.hb.bcnt > 0) {
+ int i;
+ int word_count = (grxsts.hb.bcnt + 3) / 4;
+
+ for (i = 0; i < word_count; i++) {
+ (void)ifxusb_rreg(data_fifo++);
+ }
+ }
+
+ //fprintf(stderr, "Received %u bytes\n", (unsigned)grxsts.hb.bcnt);
+ break;
+
+ default:
+ //fprintf(stderr, "** Unexpected GRXSTS packet status 1 **\n");
+ break;
+ }
+
+ gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
+ //fprintf(stderr, "Waiting for RXSTSQLVL intr 2, GINTSTS = %08x\n", gintsts.d32);
+
+ /* Wait for receive status queue interrupt */
+ do {
+ gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
+ } while (gintsts.b.rxstsqlvl == 0);
+
+ //fprintf(stderr, "Got RXSTSQLVL intr 2, GINTSTS = %08x\n", gintsts.d32);
+
+ /* Read RXSTS */
+ grxsts.d32 = ifxusb_rreg(&global_regs->grxstsp);
+ //fprintf(stderr, "GRXSTS: %08x\n", grxsts.d32);
+
+ /* Clear RXSTSQLVL in GINTSTS */
+ gintsts.d32 = 0;
+ gintsts.b.rxstsqlvl = 1;
+ ifxusb_wreg(&global_regs->gintsts, gintsts.d32);
+
+ switch (grxsts.hb.pktsts) {
+ case IFXUSB_HSTS_XFER_COMP:
+ break;
+
+ default:
+ //fprintf(stderr, "** Unexpected GRXSTS packet status 2 **\n");
+ break;
+ }
+
+ gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
+ //fprintf(stderr, "Waiting for HCINTR intr 2, GINTSTS = %08x\n", gintsts.d32);
+
+ /* Wait for host channel interrupt */
+ do {
+ gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
+ } while (gintsts.b.hcintr == 0);
+
+ //fprintf(stderr, "Got HCINTR intr 2, GINTSTS = %08x\n", gintsts.d32);
+
+ /* Read HAINT */
+ haint.d32 = ifxusb_rreg(&hc_global_regs->haint);
+ //fprintf(stderr, "HAINT: %08x\n", haint.d32);
+
+ /* Read HCINT */
+ hcint.d32 = ifxusb_rreg(&hc_regs->hcint);
+ //fprintf(stderr, "HCINT: %08x\n", hcint.d32);
+
+ /* Read HCCHAR */
+ hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
+ //fprintf(stderr, "HCCHAR: %08x\n", hcchar.d32);
+
+ /* Clear HCINT */
+ ifxusb_wreg(&hc_regs->hcint, hcint.d32);
+
+ /* Clear HAINT */
+ ifxusb_wreg(&hc_global_regs->haint, haint.d32);
+
+ /* Clear GINTSTS */
+ ifxusb_wreg(&global_regs->gintsts, gintsts.d32);
+
+ /* Read GINTSTS */
+ gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
+ //fprintf(stderr, "GINTSTS: %08x\n", gintsts.d32);
+
+ // usleep(100000);
+ // mdelay(100);
+ mdelay(1);
+
+ /*
+ * Send handshake packet
+ */
+
+ /* Read HAINT */
+ haint.d32 = ifxusb_rreg(&hc_global_regs->haint);
+ //fprintf(stderr, "HAINT: %08x\n", haint.d32);
+
+ /* Read HCINT */
+ hcint.d32 = ifxusb_rreg(&hc_regs->hcint);
+ //fprintf(stderr, "HCINT: %08x\n", hcint.d32);
+
+ /* Read HCCHAR */
+ hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
+ //fprintf(stderr, "HCCHAR: %08x\n", hcchar.d32);
+
+ /* Clear HCINT */
+ ifxusb_wreg(&hc_regs->hcint, hcint.d32);
+
+ /* Clear HAINT */
+ ifxusb_wreg(&hc_global_regs->haint, haint.d32);
+
+ /* Clear GINTSTS */
+ ifxusb_wreg(&global_regs->gintsts, gintsts.d32);
+
+ /* Read GINTSTS */
+ gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
+ //fprintf(stderr, "GINTSTS: %08x\n", gintsts.d32);
+
+ /* Make sure channel is disabled */
+ hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
+ if (hcchar.b.chen) {
+ //fprintf(stderr, "Channel already enabled 3, HCCHAR = %08x\n", hcchar.d32);
+ hcchar.b.chdis = 1;
+ hcchar.b.chen = 1;
+ ifxusb_wreg(&hc_regs->hcchar, hcchar.d32);
+ //sleep(1);
+ mdelay(1000);
+
+ /* Read GINTSTS */
+ gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
+ //fprintf(stderr, "GINTSTS: %08x\n", gintsts.d32);
+
+ /* Read HAINT */
+ haint.d32 = ifxusb_rreg(&hc_global_regs->haint);
+ //fprintf(stderr, "HAINT: %08x\n", haint.d32);
+
+ /* Read HCINT */
+ hcint.d32 = ifxusb_rreg(&hc_regs->hcint);
+ //fprintf(stderr, "HCINT: %08x\n", hcint.d32);
+
+ /* Read HCCHAR */
+ hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
+ //fprintf(stderr, "HCCHAR: %08x\n", hcchar.d32);
+
+ /* Clear HCINT */
+ ifxusb_wreg(&hc_regs->hcint, hcint.d32);
+
+ /* Clear HAINT */
+ ifxusb_wreg(&hc_global_regs->haint, haint.d32);
+
+ /* Clear GINTSTS */
+ ifxusb_wreg(&global_regs->gintsts, gintsts.d32);
+
+ hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
+ //if (hcchar.b.chen) {
+ // fprintf(stderr, "** Channel _still_ enabled 3, HCCHAR = %08x **\n", hcchar.d32);
+ //}
+ }
+
+ /* Set HCTSIZ */
+ hctsiz.d32 = 0;
+ hctsiz.b.xfersize = 0;
+ hctsiz.b.pktcnt = 1;
+ hctsiz.b.pid = IFXUSB_HC_PID_DATA1;
+ ifxusb_wreg(&hc_regs->hctsiz, hctsiz.d32);
+
+ /* Set HCCHAR */
+ hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
+ hcchar.b.eptype = IFXUSB_EP_TYPE_CTRL;
+ hcchar.b.epdir = 0;
+ hcchar.b.epnum = 0;
+ hcchar.b.mps = 8;
+ hcchar.b.chen = 1;
+ ifxusb_wreg(&hc_regs->hcchar, hcchar.d32);
+
+ gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
+ //fprintf(stderr, "Waiting for HCINTR intr 3, GINTSTS = %08x\n", gintsts.d32);
+
+ /* Wait for host channel interrupt */
+ do {
+ gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
+ } while (gintsts.b.hcintr == 0);
+
+ //fprintf(stderr, "Got HCINTR intr 3, GINTSTS = %08x\n", gintsts.d32);
+
+ /* Disable HCINTs */
+ ifxusb_wreg(&hc_regs->hcintmsk, 0x0000);
+
+ /* Disable HAINTs */
+ ifxusb_wreg(&hc_global_regs->haintmsk, 0x0000);
+
+ /* Read HAINT */
+ haint.d32 = ifxusb_rreg(&hc_global_regs->haint);
+ //fprintf(stderr, "HAINT: %08x\n", haint.d32);
+
+ /* Read HCINT */
+ hcint.d32 = ifxusb_rreg(&hc_regs->hcint);
+ //fprintf(stderr, "HCINT: %08x\n", hcint.d32);
+
+ /* Read HCCHAR */
+ hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
+ //fprintf(stderr, "HCCHAR: %08x\n", hcchar.d32);
+
+ /* Clear HCINT */
+ ifxusb_wreg(&hc_regs->hcint, hcint.d32);
+
+ /* Clear HAINT */
+ ifxusb_wreg(&hc_global_regs->haint, haint.d32);
+
+ /* Clear GINTSTS */
+ ifxusb_wreg(&global_regs->gintsts, gintsts.d32);
+
+ /* Read GINTSTS */
+ gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
+ //fprintf(stderr, "GINTSTS: %08x\n", gintsts.d32);
+ }
+#endif //__WITH_HS_ELECT_TST__
+
diff --git a/package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxhcd_intr.c.svn-base b/package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxhcd_intr.c.svn-base
new file mode 100644
index 0000000..27885bb
--- /dev/null
+++ b/package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxhcd_intr.c.svn-base
@@ -0,0 +1,4844 @@
+/*****************************************************************************
+ ** FILE NAME : ifxhcd_intr.c
+ ** PROJECT : IFX USB sub-system V3
+ ** MODULES : IFX USB sub-system Host and Device driver
+ ** SRC VERSION : 3.2
+ ** DATE : 1/Jan/2011
+ ** AUTHOR : Chen, Howard
+ ** DESCRIPTION : This file contains the implementation of the HCD Interrupt handlers.
+ ** FUNCTIONS :
+ ** COMPILER : gcc
+ ** REFERENCE : Synopsys DWC-OTG Driver 2.7
+ ** COPYRIGHT : Copyright (c) 2010
+ ** LANTIQ DEUTSCHLAND GMBH,
+ ** Am Campeon 3, 85579 Neubiberg, Germany
+ **
+ ** 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 of the License, or
+ ** (at your option) any later version.
+ **
+ ** Version Control Section **
+ ** $Author$
+ ** $Date$
+ ** $Revisions$
+ ** $Log$ Revision history
+ *****************************************************************************/
+
+/*
+ * This file contains code fragments from Synopsys HS OTG Linux Software Driver.
+ * For this code the following notice is applicable:
+ *
+ * ==========================================================================
+ *
+ * Synopsys HS OTG Linux Software Driver and documentation (hereinafter,
+ * "Software") is an Unsupported proprietary work of Synopsys, Inc. unless
+ * otherwise expressly agreed to in writing between Synopsys and you.
+ *
+ * The Software IS NOT an item of Licensed Software or Licensed Product under
+ * any End User Software License Agreement or Agreement for Licensed Product
+ * with Synopsys or any supplement thereto. You are permitted to use and
+ * redistribute this Software in source and binary forms, with or without
+ * modification, provided that redistributions of source code must retain this
+ * notice. You may not view, use, disclose, copy or distribute this file or
+ * any information contained herein except pursuant to this license grant from
+ * Synopsys. If you do not agree with this notice, including the disclaimer
+ * below, then you are not authorized to use the Software.
+ *
+ * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" BASIS
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ * ========================================================================== */
+
+/*!
+ \file ifxhcd_intr.c
+ \ingroup IFXUSB_DRIVER_V3
+ \brief This file contains the implementation of the HCD Interrupt handlers.
+*/
+
+
+#include <linux/version.h>
+#include "ifxusb_version.h"
+
+#include "ifxusb_plat.h"
+#include "ifxusb_regs.h"
+#include "ifxusb_cif.h"
+
+#include "ifxhcd.h"
+
+/* Macro used to clear one channel interrupt */
+#define clear_hc_int(_hc_regs_,_intr_) \
+ do { \
+ hcint_data_t hcint_clear = {.d32 = 0}; \
+ hcint_clear.b._intr_ = 1; \
+ ifxusb_wreg(&((_hc_regs_)->hcint), hcint_clear.d32); \
+ } while (0)
+
+/*
+ * Macro used to disable one channel interrupt. Channel interrupts are
+ * disabled when the channel is halted or released by the interrupt handler.
+ * There is no need to handle further interrupts of that type until the
+ * channel is re-assigned. In fact, subsequent handling may cause crashes
+ * because the channel structures are cleaned up when the channel is released.
+ */
+#define disable_hc_int(_hc_regs_,_intr_) \
+ do { \
+ hcint_data_t hcintmsk = {.d32 = 0}; \
+ hcintmsk.b._intr_ = 1; \
+ ifxusb_mreg(&((_hc_regs_)->hcintmsk), hcintmsk.d32, 0); \
+ } while (0)
+
+#define enable_hc_int(_hc_regs_,_intr_) \
+ do { \
+ hcint_data_t hcintmsk = {.d32 = 0}; \
+ hcintmsk.b._intr_ = 1; \
+ ifxusb_mreg(&((_hc_regs_)->hcintmsk),0, hcintmsk.d32); \
+ } while (0)
+
+/*
+ * Save the starting data toggle for the next transfer. The data toggle is
+ * saved in the QH for non-control transfers and it's saved in the QTD for
+ * control transfers.
+ */
+uint8_t read_data_toggle(ifxusb_hc_regs_t *_hc_regs)
+{
+ hctsiz_data_t hctsiz;
+ hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
+ return(hctsiz.b.pid);
+}
+
+
+static void release_channel_dump(ifxhcd_hc_t *ifxhc,
+ struct urb *urb,
+ ifxhcd_epqh_t *epqh,
+ ifxhcd_urbd_t *urbd,
+ ifxhcd_halt_status_e halt_status)
+{
+ #ifdef __DEBUG__
+ printk(KERN_INFO);
+ switch (halt_status)
+ {
+ case HC_XFER_NO_HALT_STATUS:
+ printk("HC_XFER_NO_HALT_STATUS");break;
+ case HC_XFER_URB_COMPLETE:
+ printk("HC_XFER_URB_COMPLETE");break;
+ case HC_XFER_AHB_ERR:
+ printk("HC_XFER_AHB_ERR");break;
+ case HC_XFER_STALL:
+ printk("HC_XFER_STALL");break;
+ case HC_XFER_BABBLE_ERR:
+ printk("HC_XFER_BABBLE_ERR");break;
+ case HC_XFER_XACT_ERR:
+ printk("HC_XFER_XACT_ERR");break;
+ case HC_XFER_URB_DEQUEUE:
+ printk("HC_XFER_URB_DEQUEUE");break;
+ case HC_XFER_FRAME_OVERRUN:
+ printk("HC_XFER_FRAME_OVERRUN");break;
+ case HC_XFER_DATA_TOGGLE_ERR:
+ printk("HC_XFER_DATA_TOGGLE_ERR");break;
+ #ifdef __NAKSTOP__
+ case HC_XFER_NAK:
+ printk("HC_XFER_NAK");break;
+ #endif
+ case HC_XFER_COMPLETE:
+ printk("HC_XFER_COMPLETE");break;
+ default:
+ printk("KNOWN");break;
+ }
+ if(ifxhc)
+ printk("Ch %d %s%s S%d " , ifxhc->hc_num
+ ,(ifxhc->ep_type == IFXUSB_EP_TYPE_CTRL)?"CTRL-":
+ ((ifxhc->ep_type == IFXUSB_EP_TYPE_BULK)?"BULK-":
+ ((ifxhc->ep_type == IFXUSB_EP_TYPE_INTR)?"INTR-":
+ ((ifxhc->ep_type == IFXUSB_EP_TYPE_ISOC)?"ISOC-":"????"
+ )
+ )
+ )
+ ,(ifxhc->is_in)?"IN":"OUT"
+ ,(ifxhc->split)
+ );
+ else
+ printk(" [NULL HC] ");
+ printk("urb=%p epqh=%p urbd=%p\n",urb,epqh,urbd);
+
+ if(urb)
+ {
+ printk(KERN_INFO " Device address: %d\n", usb_pipedevice(urb->pipe));
+ printk(KERN_INFO " Endpoint: %d, %s\n", usb_pipeendpoint(urb->pipe),
+ (usb_pipein(urb->pipe) ? "IN" : "OUT"));
+ printk(KERN_INFO " Endpoint type: %s\n",
+ ({char *pipetype;
+ switch (usb_pipetype(urb->pipe)) {
+ case PIPE_CONTROL: pipetype = "CTRL"; break;
+ case PIPE_BULK: pipetype = "BULK"; break;
+ case PIPE_INTERRUPT: pipetype = "INTR"; break;
+ case PIPE_ISOCHRONOUS: pipetype = "ISOC"; break;
+ default: pipetype = "????"; break;
+ }; pipetype;}));
+ printk(KERN_INFO " Speed: %s\n",
+ ({char *speed;
+ switch (urb->dev->speed) {
+ case USB_SPEED_HIGH: speed = "HS"; break;
+ case USB_SPEED_FULL: speed = "FS"; break;
+ case USB_SPEED_LOW: speed = "LS"; break;
+ default: speed = "????"; break;
+ }; speed;}));
+ printk(KERN_INFO " Max packet size: %d\n",
+ usb_maxpacket(urb->dev, urb->pipe, usb_pipeout(urb->pipe)));
+ printk(KERN_INFO " Data buffer length: %d/%d\n",urb->actual_length, urb->transfer_buffer_length);
+ printk(KERN_INFO " Transfer buffer: %p, Transfer DMA: %p\n",
+ urb->transfer_buffer, (void *)urb->transfer_dma);
+ printk(KERN_INFO " Setup buffer: %p, Setup DMA: %p\n",
+ urb->setup_packet, (void *)urb->setup_dma);
+ printk(KERN_INFO " Interval: %d\n", urb->interval);
+ }
+ if(urbd)
+ {
+ switch (urbd->status)
+ {
+ case HC_XFER_NO_HALT_STATUS:
+ printk(KERN_INFO " STATUS:HC_XFER_NO_HALT_STATUS\n");break;
+ case HC_XFER_URB_COMPLETE:
+ printk(KERN_INFO " STATUS:HC_XFER_URB_COMPLETE\n");break;
+ case HC_XFER_AHB_ERR:
+ printk(KERN_INFO " STATUS:HC_XFER_AHB_ERR\n");break;
+ case HC_XFER_STALL:
+ printk(KERN_INFO " STATUS:HC_XFER_STALL\n");break;
+ case HC_XFER_BABBLE_ERR:
+ printk(KERN_INFO " STATUS:HC_XFER_BABBLE_ERR\n");break;
+ case HC_XFER_XACT_ERR:
+ printk(KERN_INFO " STATUS:HC_XFER_XACT_ERR\n");break;
+ case HC_XFER_URB_DEQUEUE:
+ printk(KERN_INFO " STATUS:HC_XFER_URB_DEQUEUE\n");break;
+ case HC_XFER_FRAME_OVERRUN:
+ printk(KERN_INFO " STATUS:HC_XFER_FRAME_OVERRUN\n");break;
+ case HC_XFER_DATA_TOGGLE_ERR:
+ printk(KERN_INFO " STATUS:HC_XFER_DATA_TOGGLE_ERR\n");break;
+ case HC_XFER_COMPLETE:
+ printk(KERN_INFO " STATUS:HC_XFER_COMPLETE\n");break;
+ default:
+ printk(KERN_INFO " STATUS:UNKKNOWN %d\n",urbd->status);break;
+ }
+ }
+ #endif
+}
+
+/*!
+ \fn static void release_channel(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxhcd_halt_status_e _halt_status)
+ \brief Release the halted channel.
+ \param _ifxhcd Pointer to the sate of HCD structure
+ \param _ifxhc Pointer to host channel descriptor
+ \param _halt_status Halt satus
+ \return None
+ \ingroup IFXUSB_HCD
+ */
+
+static void release_channel(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxhcd_halt_status_e _halt_status)
+{
+ ifxusb_hc_regs_t *hc_regs = _ifxhcd->core_if.hc_regs[_ifxhc->hc_num];
+ struct urb *urb = NULL;
+ ifxhcd_epqh_t *epqh = NULL;
+ ifxhcd_urbd_t *urbd = NULL;
+
+ IFX_DEBUGPL(DBG_HCDV, " %s: channel %d, halt_status %d\n",
+ __func__, _ifxhc->hc_num, _halt_status);
+
+ epqh=_ifxhc->epqh;
+
+ if(!epqh)
+ {
+ if(_halt_status!=HC_XFER_NO_EPQH)
+ IFX_ERROR("%s epqh=null\n",__func__);
+ }
+ else
+ {
+ urbd=epqh->urbd;
+ if(!urbd)
+ IFX_ERROR("%s urbd=null\n",__func__);
+ else
+ {
+ urb=urbd->urb;
+ if(!urb)
+ {
+ if(_halt_status!=HC_XFER_NO_URB)
+ IFX_ERROR("%s urb =null\n",__func__);
+ }
+ else
+ {
+ if (read_data_toggle(hc_regs) == IFXUSB_HCTSIZ_DATA0)
+ usb_settoggle (urb->dev,usb_pipeendpoint (urb->pipe), (_ifxhc->is_in)?0:1,0);
+ else if (read_data_toggle(hc_regs) == IFXUSB_HCTSIZ_DATA1)
+ usb_settoggle (urb->dev,usb_pipeendpoint (urb->pipe), (_ifxhc->is_in)?0:1,1);
+ }
+ }
+ }
+
+ switch (_halt_status)
+ {
+ case HC_XFER_NO_HALT_STATUS:
+ IFX_ERROR("%s: No halt_status, channel %d\n", __func__, _ifxhc->hc_num);
+// return;
+ break;
+ case HC_XFER_COMPLETE:
+ IFX_ERROR("%s: Inavalid halt_status HC_XFER_COMPLETE, channel %d\n", __func__, _ifxhc->hc_num);
+// return;
+ break;
+ case HC_XFER_NO_URB:
+ break;
+ case HC_XFER_NO_EPQH:
+ break;
+ case HC_XFER_URB_DEQUEUE:
+ case HC_XFER_AHB_ERR:
+ case HC_XFER_XACT_ERR:
+ case HC_XFER_FRAME_OVERRUN:
+ if(urbd && urb)
+ {
+ urbd->phase=URBD_DEQUEUEING;
+ ifxhcd_complete_urb(_ifxhcd, urbd, urbd->status);
+ }
+ else
+ {
+ IFX_WARN("WARNING %s():%d urbd=%p urb=%p\n",__func__,__LINE__,urbd,urb);
+ release_channel_dump(_ifxhc,urb,epqh,urbd,_halt_status);
+ }
+ break;
+ case HC_XFER_URB_COMPLETE:
+ if(urbd && urb)
+ {
+ urbd->phase=URBD_COMPLETING;
+ ifxhcd_complete_urb(_ifxhcd, urbd, urbd->status);
+ }
+ else
+ {
+ IFX_WARN("WARNING %s():%d urbd=%p urb=%p\n",__func__,__LINE__,urbd,urb);
+ release_channel_dump(_ifxhc,urb,epqh,urbd,_halt_status);
+ }
+ break;
+ case HC_XFER_STALL:
+ if(urbd)
+ {
+ urbd->phase=URBD_DEQUEUEING;
+ ifxhcd_complete_urb(_ifxhcd, urbd, -EPIPE);
+ }
+ else
+ {
+ IFX_WARN("WARNING %s():%d urbd=%p urb=%p\n",__func__,__LINE__,urbd,urb);
+ release_channel_dump(_ifxhc,urb,epqh,urbd,_halt_status);
+ }
+ if(epqh && urb && urb->dev && urb->pipe)
+ usb_settoggle(urb->dev, usb_pipeendpoint (urb->pipe), !usb_pipein(urb->pipe), IFXUSB_HC_PID_DATA0);
+ break;
+ case HC_XFER_BABBLE_ERR:
+ case HC_XFER_DATA_TOGGLE_ERR:
+ if(urbd)
+ {
+ urbd->phase=URBD_DEQUEUEING;
+ ifxhcd_complete_urb(_ifxhcd, urbd, -EOVERFLOW);
+ }
+ else
+ {
+ IFX_WARN("WARNING %s():%d urbd=%p urb=%p\n",__func__,__LINE__,urbd,urb);
+ release_channel_dump(_ifxhc,urb,epqh,urbd,_halt_status);
+ }
+ break;
+ #ifdef __NAKSTOP__
+ case HC_XFER_NAK:
+ if (_ifxhc->is_in)
+ {
+ if(urbd && urb)
+ {
+ urbd->phase=URBD_COMPLETING;
+ ifxhcd_complete_urb(_ifxhcd, urbd, 0);
+ }
+ else
+ {
+ IFX_WARN("WARNING %s():%d urbd=%p urb=%p\n",__func__,__LINE__,urbd,urb);
+ release_channel_dump(_ifxhc,urb,epqh,urbd,_halt_status);
+ }
+ }
+ else
+ {
+ IFX_WARN("WARNING %s():%d urbd=%p urb=%p\n",__func__,__LINE__,urbd,urb);
+ release_channel_dump(_ifxhc,urb,epqh,urbd,_halt_status);
+ }
+ break;
+ #endif
+ #if defined(__INTRNAKRETRY__) || defined(__INTRINCRETRY__)
+ case HC_XFER_INTR_NAK_RETRY:
+ epqh->phase=EPQH_READY;
+ urbd->phase=URBD_IDLE;
+ ifxhcd_hc_cleanup(&_ifxhcd->core_if, _ifxhc);
+ select_eps(_ifxhcd);
+ return;
+ break;
+
+ #endif
+ }
+ if(epqh)
+ {
+ ifxhcd_epqh_idle(epqh);
+ }
+ else if(_halt_status!=HC_XFER_NO_EPQH)
+ {
+ IFX_WARN("WARNING %s():%d epqh=%p\n",__func__,__LINE__,epqh);
+ release_channel_dump(_ifxhc,urb,epqh,urbd,_halt_status);
+ }
+ ifxhcd_hc_cleanup(&_ifxhcd->core_if, _ifxhc);
+ select_eps(_ifxhcd);
+}
+
+/*
+ * Updates the state of the URB after a Transfer Complete interrupt on the
+ * host channel. Updates the actual_length field of the URB based on the
+ * number of bytes transferred via the host channel. Sets the URB status
+ * if the data transfer is finished.
+ *
+ * @return 1 if the data transfer specified by the URB is completely finished,
+ * 0 otherwise.
+ */
+static int update_urb_state_xfer_comp(ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ struct urb *_urb,
+ ifxhcd_urbd_t *_urbd)
+{
+ int xfer_done = 0;
+
+ #ifdef __EN_ISOC__
+ if(_urbd->epqh->ep_type==IFXUSB_EP_TYPE_ISOC)
+ {
+ struct usb_iso_packet_descriptor *frame_desc;
+ frame_desc = &_urb->iso_frame_desc[_urbd->isoc_frame_index];
+ if (_ifxhc->is_in)
+ {
+ hctsiz_data_t hctsiz;
+ hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
+ frame_desc->actual_length += (_ifxhc->xfer_len - hctsiz.b.xfersize);
+ if ((hctsiz.b.xfersize != 0) || (frame_desc->actual_length >= _urbd->xfer_len))
+ {
+ xfer_done = 1;
+ frame_desc->status = 0;
+ #if 0
+ if (frame_desc->actual_length < frame_desc->length && _urb->transfer_flags & URB_SHORT_NOT_OK)
+ frame_desc->status = -EREMOTEIO;
+ #endif
+ }
+ }
+ else
+ {
+ if (_ifxhc->split)
+ frame_desc->actual_length += _ifxhc->ssplit_out_xfer_count;
+ else
+ frame_desc->actual_length += _ifxhc->xfer_len;
+ if (frame_desc->actual_length >= _urbd->xfer_len)
+ {
+ xfer_done = 1;
+ frame_desc->status = 0;
+ }
+ }
+ }
+ else
+ #endif
+ if (_ifxhc->is_in)
+ {
+ hctsiz_data_t hctsiz;
+ hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
+ _urb->actual_length += (_ifxhc->xfer_len - hctsiz.b.xfersize);
+#ifdef __INTRINCRETRY__
+ if(_urbd->epqh->ep_type==IFXUSB_EP_TYPE_INTR)
+ {
+ if(_ifxhc->xfer_len != hctsiz.b.xfersize)
+ {
+ xfer_done = 1;
+ _urbd->status = 0;
+ }
+ }
+ else
+#endif
+ if ((hctsiz.b.xfersize != 0) || (_urb->actual_length >= _urb->transfer_buffer_length))
+ {
+ xfer_done = 1;
+ _urbd->status = 0;
+ if(_urb->transfer_flags & URB_SHORT_NOT_OK)
+ {
+ if (_urb->actual_length < _urb->transfer_buffer_length)
+ _urbd->status = -EREMOTEIO;
+ }
+ }
+ }
+ else if(_urb->transfer_buffer_length%_ifxhc->mps) // OUT without ZLP
+ {
+ if (_ifxhc->split)
+ _urb->actual_length += _ifxhc->ssplit_out_xfer_count;
+ else
+ _urb->actual_length += _ifxhc->xfer_len;
+ if (_urb->actual_length >= _urb->transfer_buffer_length)
+ {
+ xfer_done = 1;
+ _urbd->status = 0;
+ }
+ }
+ else if (_urb->actual_length >= _urb->transfer_buffer_length) //OUT with ZLP
+ {
+ xfer_done = 1;
+ _urbd->status = 0;
+ }
+ else //OUT without ZLP, unfinished
+ {
+ if (_ifxhc->split)
+ _urb->actual_length += _ifxhc->ssplit_out_xfer_count;
+ else
+ _urb->actual_length += _ifxhc->xfer_len;
+ if (!_ifxhc->short_rw && _urb->actual_length >= _urb->transfer_buffer_length)
+ {
+ xfer_done = 1;
+ _urbd->status = 0;
+ }
+ }
+
+ #ifdef __DEBUG__
+ {
+ hctsiz_data_t hctsiz;
+ hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
+ IFX_DEBUGPL(DBG_HCDV, "IFXUSB: %s: %s, channel %d\n",
+ __func__, (_ifxhc->is_in ? "IN" : "OUT"), _ifxhc->hc_num);
+ IFX_DEBUGPL(DBG_HCDV, " hc->xfer_len %d\n", _ifxhc->xfer_len);
+ IFX_DEBUGPL(DBG_HCDV, " hctsiz.xfersize %d\n", hctsiz.b.xfersize);
+ #ifdef __EN_ISOC__
+ if(_urbd->epqh->ep_type==IFXUSB_EP_TYPE_ISOC)
+ {
+ IFX_DEBUGPL(DBG_HCDV, " descritor # %d\n", _urbd->isoc_frame_index);
+ IFX_DEBUGPL(DBG_HCDV, " buffer_length %d\n",
+ _urb->iso_frame_desc[_urbd->isoc_frame_index].length);
+ IFX_DEBUGPL(DBG_HCDV, " actual_length %d\n", _urb->iso_frame_desc[_urbd->isoc_frame_index].actual_length);
+ }
+ else
+ #endif
+ {
+ IFX_DEBUGPL(DBG_HCDV, " urb->transfer_buffer_length %d\n",
+ _urb->transfer_buffer_length);
+ IFX_DEBUGPL(DBG_HCDV, " urb->actual_length %d\n", _urb->actual_length);
+ }
+ }
+ #endif
+ return xfer_done;
+}
+
+#ifdef __EN_ISOC__
+ static void next_isoc_sub(unsigned long data)
+ {
+ ifxhcd_urbd_t *urbd;
+ ifxhcd_hcd_t *ifxhcd;
+
+ urbd=((ifxhcd_urbd_t *)data);
+ ifxhcd=urbd->epqh->ifxhcd;
+
+ if (!urbd->epqh)
+ IFX_ERROR("%s: invalid epqd\n",__func__);
+ #if defined(__UNALIGNED_BUF_ADJ__)
+ else
+ {
+ if( urbd->aligned_checked &&
+// urbd->using_aligned_buf &&
+ urbd->xfer_buff &&
+ urbd->is_in)
+ {
+ uint8_t *buf;
+
+ buf=urbd->xfer_buff;
+ buf+=urbd->urb->iso_frame_desc[urbd->isoc_frame_index].offset;
+ memcpy(buf,urbd->aligned_buf,urbd->urb->iso_frame_desc[urbd->isoc_frame_index].length);
+ }
+// urbd->using_aligned_buf=0;
+// urbd->using_aligned_setup=0;
+ }
+ #endif
+
+ urbd->isoc_frame_index++;
+ if(urbd->isoc_frame_index>=urbd->urb->number_of_packets)
+ release_channel(ifxhcd,urbd->epqh->hc,HC_XFER_URB_COMPLETE);
+ else
+ init_hc(urbd->epqh);
+ }
+#endif
+
+/*!
+ \fn static void complete_channel(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxhcd_urbd_t *_urbd)
+ \brief Complete the transaction on the channel.
+ \param _ifxhcd Pointer to the sate of HCD structure
+ \param _ifxhc Pointer to host channel descriptor
+ \param _urbd Pointer to URB descriptor
+ \return None
+ \ingroup IFXUSB_HCD
+ */
+static void complete_channel(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxhcd_urbd_t *_urbd)
+{
+ ifxusb_hc_regs_t *hc_regs = _ifxhcd->core_if.hc_regs[_ifxhc->hc_num];
+ struct urb *urb = NULL;
+ ifxhcd_epqh_t *epqh = NULL;
+ int urb_xfer_done;
+
+ IFX_DEBUGPL(DBG_HCD, "--Complete Channel %d : \n", _ifxhc->hc_num);
+
+ if(!_urbd)
+ {
+ IFX_ERROR("ERROR %s():%d urbd=%p\n",__func__,__LINE__,_urbd);
+ return;
+ }
+
+ urb = _urbd->urb;
+ epqh = _urbd->epqh;
+
+ if(!epqh)
+ {
+ release_channel(_ifxhcd,_ifxhc,HC_XFER_NO_EPQH);
+ return;
+ }
+ if(!urb || (unsigned long)urb->hcpriv!=(unsigned long)_urbd)
+ {
+ release_channel(_ifxhcd,_ifxhc,HC_XFER_NO_URB);
+ return;
+ }
+
+ if (_ifxhc->split)
+ _ifxhc->split = 1;
+
+ switch (epqh->ep_type)
+ {
+ case IFXUSB_EP_TYPE_CTRL:
+ switch (_ifxhc->control_phase)
+ {
+ case IFXHCD_CONTROL_SETUP:
+ if (_urbd->xfer_len > 0)
+ {
+ _ifxhc->control_phase = IFXHCD_CONTROL_DATA;
+ IFX_DEBUGPL(DBG_HCDV, " Control setup transaction done Data Stage now\n");
+ _ifxhc->is_in = _urbd->is_in;
+ _ifxhc->xfer_len = _urbd->xfer_len;
+ #if defined(__UNALIGNED_BUF_ADJ__)
+ if(_urbd->aligned_buf)
+ _ifxhc->xfer_buff = _urbd->aligned_buf;
+ else
+ #endif
+ _ifxhc->xfer_buff = _urbd->xfer_buff;
+ #ifdef __NAKSTOP__
+ if(!_ifxhc->split)
+ {
+ #ifdef __INNAKSTOP_CTRL__
+ if(_ifxhc->is_in)
+ _ifxhc->stop_on=1;
+ #endif
+ #ifdef __PINGSTOP_CTRL__
+ if(!_ifxhc->is_in)
+ _ifxhc->stop_on=1;
+ #endif
+ }
+ #endif
+ }
+ else
+ {
+ IFX_DEBUGPL(DBG_HCDV, " Control setup transaction done Status Stage now\n");
+ _ifxhc->control_phase = IFXHCD_CONTROL_STATUS;
+ _ifxhc->is_in = 1;
+ _ifxhc->xfer_len = 0;
+ _ifxhc->xfer_buff = _ifxhcd->status_buf;
+ #ifdef __NAKSTOP__
+ _ifxhc->stop_on=0;
+ #endif
+ }
+ if(_ifxhc->is_in)
+ _ifxhc->short_rw =0;
+ else
+ _ifxhc->short_rw =(urb->transfer_flags & URB_ZERO_PACKET)?1:0;
+ _ifxhc->data_pid_start = IFXUSB_HC_PID_DATA1;
+ _ifxhc->xfer_count = 0;
+ _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ break;
+ case IFXHCD_CONTROL_DATA:
+ urb_xfer_done = update_urb_state_xfer_comp(_ifxhc, hc_regs, urb, _urbd);
+ if (urb_xfer_done)
+ {
+ _ifxhc->control_phase = IFXHCD_CONTROL_STATUS;
+ IFX_DEBUGPL(DBG_HCDV, " Control data transaction done Status Stage now\n");
+ _ifxhc->is_in = (_urbd->is_in)?0:1;
+ _ifxhc->xfer_len = 0;
+ _ifxhc->xfer_count = 0;
+ _ifxhc->xfer_buff = _ifxhcd->status_buf;
+ _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
+ _ifxhc->data_pid_start = IFXUSB_HC_PID_DATA1;
+ if(_ifxhc->is_in)
+ _ifxhc->short_rw =0;
+ else
+ _ifxhc->short_rw =1;
+ #ifdef __NAKSTOP__
+ _ifxhc->stop_on=0;
+ #endif
+ }
+ else // continue
+ {
+ IFX_DEBUGPL(DBG_HCDV, " Control data transaction continue\n");
+ _ifxhc->xfer_len = _urbd->xfer_len - urb->actual_length;
+ _ifxhc->xfer_count = urb->actual_length;
+ _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
+ _ifxhc->data_pid_start = read_data_toggle(hc_regs);
+ }
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ break;
+ case IFXHCD_CONTROL_STATUS:
+ IFX_DEBUGPL(DBG_HCDV, " Control status transaction done\n");
+ if (_urbd->status == -EINPROGRESS)
+ _urbd->status = 0;
+ release_channel(_ifxhcd,_ifxhc,HC_XFER_URB_COMPLETE);
+ break;
+ }
+ break;
+ case IFXUSB_EP_TYPE_BULK:
+ IFX_DEBUGPL(DBG_HCDV, " Bulk transfer complete\n");
+ urb_xfer_done = update_urb_state_xfer_comp(_ifxhc, hc_regs, urb, _urbd);
+ if (urb_xfer_done)
+ release_channel(_ifxhcd,_ifxhc,HC_XFER_URB_COMPLETE);
+ else
+ {
+ _ifxhc->xfer_len = _urbd->xfer_len - urb->actual_length;
+ _ifxhc->xfer_count = urb->actual_length;
+ _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
+ _ifxhc->data_pid_start = read_data_toggle(hc_regs);
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ break;
+ case IFXUSB_EP_TYPE_INTR:
+ urb_xfer_done = update_urb_state_xfer_comp(_ifxhc, hc_regs, urb, _urbd);
+
+ #ifdef __INTRINCRETRY__
+ if(!urb_xfer_done)
+ release_channel(_ifxhcd,_ifxhc,HC_XFER_INTR_NAK_RETRY);
+ else
+ #endif
+ release_channel(_ifxhcd,_ifxhc,HC_XFER_URB_COMPLETE);
+ break;
+ case IFXUSB_EP_TYPE_ISOC:
+ #ifdef __EN_ISOC__
+ urb_xfer_done = update_urb_state_xfer_comp(_ifxhc, hc_regs, urb, _urbd);
+ if (urb_xfer_done)
+ {
+ #if defined(__UNALIGNED_BUF_ADJ__)
+ if(in_irq())
+ {
+ if(!epqh->tasklet_next_isoc.func)
+ {
+ epqh->tasklet_next_isoc.next = NULL;
+ epqh->tasklet_next_isoc.state = 0;
+ atomic_set( &epqh->tasklet_next_isoc.count, 0);
+ epqh->tasklet_next_isoc.func = next_isoc_sub;
+ epqh->tasklet_next_isoc.data = (unsigned long)_urbd;
+ }
+ tasklet_schedule(&epqh->tasklet_next_isoc);
+ }
+ else
+ #endif
+ {
+ next_isoc_sub((unsigned long)_urbd);
+ }
+ }
+ else
+ {
+ struct usb_iso_packet_descriptor *frame_desc;
+ frame_desc = &urb->iso_frame_desc[_urbd->isoc_frame_index];
+ _ifxhc->xfer_len = _urbd->xfer_len - frame_desc->actual_length;
+ _ifxhc->xfer_count = frame_desc->actual_length;
+ _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
+ _ifxhc->data_pid_start = read_data_toggle(hc_regs);
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ #endif
+ break;
+ }
+}
+
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+static int32_t chhltd_ctrl_rx_nonsplit(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ hcint_data_t hcint;
+ hcint_data_t hcintmsk;
+ hctsiz_data_t hctsiz;
+
+ hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
+ hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
+ hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
+
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nak);
+ disable_hc_int(_hc_regs,nyet);
+
+ #ifdef __INNAKSTOP_CTRL__
+ if (_ifxhc->halt_status == HC_XFER_NAK)
+ {
+ if(_ifxhc->control_phase == IFXHCD_CONTROL_DATA)
+ {
+ u32 actual_length;
+ actual_length = _urbd->urb->actual_length + (_ifxhc->xfer_len - hctsiz.b.xfersize);
+
+ if(_urbd->xfer_len && actual_length >= _urbd->xfer_len)
+ {
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ else
+ {
+ _ifxhc->xfer_count =
+ _urbd->urb->actual_length = actual_length;
+ _ifxhc->xfer_len = _urbd->xfer_len - actual_length;
+ _ifxhc->data_pid_start = read_data_toggle(_hc_regs);
+ _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ }
+ else
+ {
+ printk(KERN_INFO "Warning: %s() %d Invalid CTRL Phase:%d\n",__func__,__LINE__,_ifxhc->control_phase);
+ release_channel(_ifxhcd, _ifxhc, _ifxhc->halt_status);
+ }
+ return 1;
+ }
+ #endif
+
+ if (hcint.b.xfercomp || hcint.d32 == 0x02)
+ {
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ return 1;
+ }
+ else if (hcint.b.stall)
+ {
+ _urbd->error_count =0;
+ // ZLP shortcut
+ #if 0
+ if(hctsiz.b.pktcnt==0)
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ else
+ #endif
+ #if 0
+ if(_ifxhc->control_phase == IFXHCD_CONTROL_STATUS)
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ else
+ #endif
+ {
+ if(_ifxhc->control_phase == IFXHCD_CONTROL_DATA)
+ _urbd->urb->actual_length += (_ifxhc->xfer_len - hctsiz.b.xfersize);
+// if( _urbd->urb->actual_length > _ifxhc->xfer_len) _urbd->urb->actual_length = _urbd->xfer_len;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_STALL);
+ }
+ return 1;
+ }
+ else if (hcint.b.bblerr)
+ {
+ _urbd->error_count =0;
+
+ // ZLP shortcut
+ #if 0
+ if(hctsiz.b.pktcnt==0)
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ else
+ #endif
+ #if 0
+ if(_ifxhc->control_phase == IFXHCD_CONTROL_STATUS)
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ else
+ #endif
+ {
+ if(_ifxhc->control_phase == IFXHCD_CONTROL_DATA)
+ _urbd->urb->actual_length += (_ifxhc->xfer_len - hctsiz.b.xfersize);
+// if( _urbd->urb->actual_length > _ifxhc->xfer_len) _urbd->urb->actual_length = _urbd->xfer_len;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_BABBLE_ERR);
+ }
+ return 1;
+ }
+ else if (hcint.b.xacterr)
+ {
+ // ZLP shortcut
+ #if 1
+ if(hctsiz.b.pktcnt==0)
+ {
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ else
+ #endif
+ #if 1
+ if(_ifxhc->control_phase == IFXHCD_CONTROL_STATUS)
+ {
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ else
+ #endif
+ if(_ifxhc->control_phase == IFXHCD_CONTROL_DATA)
+ {
+ #if 1
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ #else
+ u32 actual_length;
+ actual_length = _urbd->urb->actual_length + (_ifxhc->xfer_len - hctsiz.b.xfersize);
+ if(actual_length >= _urbd->xfer_len)
+ {
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ else
+ {
+ _urbd->error_count++;
+ _ifxhc->xfer_count =
+ _urbd->urb->actual_length = actual_length;
+ _ifxhc->xfer_len = _urbd->xfer_len - actual_length;
+ _ifxhc->data_pid_start = read_data_toggle(_hc_regs);
+ if (_urbd->error_count >= 3)
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ }
+ else
+ {
+ _ifxhc->erron=1;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ }
+ #endif
+ }
+ else
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ }
+ return 1;
+ }
+ else if(hcint.b.datatglerr )
+ {
+ #if 0
+ #if 1
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ #else
+ u32 actual_length;
+ actual_length = _urbd->urb->actual_length + (_ifxhc->xfer_len - hctsiz.b.xfersize);
+ if(actual_length>=_urbd->xfer_len)
+ {
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ else
+ {
+ _urbd->urb->actual_length = actual_length;
+ _ifxhc->data_pid_start = read_data_toggle(_hc_regs);
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_DATA_TOGGLE_ERR);
+ }
+ #endif
+ #else
+ if(_ifxhc->control_phase == IFXHCD_CONTROL_DATA)
+ _urbd->urb->actual_length += (_ifxhc->xfer_len - hctsiz.b.xfersize);
+// if( _urbd->urb->actual_length > _ifxhc->xfer_len) _urbd->urb->actual_length = _urbd->xfer_len;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_DATA_TOGGLE_ERR);
+ #endif
+ return 1;
+ }
+ else if(hcint.b.frmovrun )
+ {
+ if(_ifxhc->control_phase == IFXHCD_CONTROL_DATA)
+ _urbd->urb->actual_length += (_ifxhc->xfer_len - hctsiz.b.xfersize);
+// if( _urbd->urb->actual_length > _ifxhc->xfer_len) _urbd->urb->actual_length = _urbd->xfer_len;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_FRAME_OVERRUN);
+ return 1;
+ }
+ else
+ {
+ _urbd->error_count =0;
+ IFX_ERROR("ERROR %s():%d invalid chhlt condition %08X/%08X %d\n",__func__,__LINE__,hcint.d32,hcintmsk.d32,_ifxhc->halt_status);
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ return 1;
+ }
+
+ return 0;
+}
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+static int32_t chhltd_ctrl_tx_nonsplit(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ hcint_data_t hcint;
+ hcint_data_t hcintmsk;
+ hctsiz_data_t hctsiz;
+
+ hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
+ hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
+ hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
+
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nak);
+ disable_hc_int(_hc_regs,nyet);
+
+ #ifdef __PINGSTOP_CTRL__
+ if (_ifxhc->halt_status == HC_XFER_NAK)
+ {
+ if(_ifxhc->control_phase == IFXHCD_CONTROL_DATA)
+ {
+ u32 actual_length;
+ actual_length = _urbd->urb->actual_length + ((_ifxhc->start_pkt_count - hctsiz.b.pktcnt ) * _ifxhc->mps);
+
+ if(_urbd->xfer_len && actual_length >= _urbd->xfer_len)
+ {
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ else
+ {
+ _ifxhc->xfer_count =
+ _urbd->urb->actual_length = actual_length;
+ _ifxhc->xfer_len = _urbd->xfer_len - actual_length;
+ _ifxhc->data_pid_start = read_data_toggle(_hc_regs);
+ _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ }
+ else
+ {
+ printk(KERN_INFO "Warning: %s() %d Invalid CTRL Phase:%d\n",__func__,__LINE__,_ifxhc->control_phase);
+ release_channel(_ifxhcd, _ifxhc, _ifxhc->halt_status);
+ }
+ return 1;
+ }
+ #endif
+
+
+ if (hcint.b.xfercomp || hcint.d32 == 0x02)
+ {
+ _urbd->error_count =0;
+ if(_ifxhc->xfer_len==0 && !hcint.b.ack && hcint.b.nak)
+ {
+ // Walkaround: When sending ZLP and receive NAK but also issue CMPT intr
+ // Solution: NoSplit: Resend at next SOF
+ // Split : Resend at next SOF with SSPLIT
+ if(hcint.b.nyet)
+ _ifxhc->epqh->do_ping=1;
+
+ _ifxhc->xfer_len = 0;
+ _ifxhc->xfer_count = 0;
+ _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ else
+ {
+ if(hcint.b.nyet)
+ _ifxhc->epqh->do_ping=1;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ return 1;
+ }
+ else if (hcint.b.stall)
+ {
+ _urbd->error_count =0;
+
+ // ZLP shortcut
+ #if 1
+ if(hctsiz.b.pktcnt==0)
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ else
+ #endif
+ {
+ if(_ifxhc->control_phase == IFXHCD_CONTROL_DATA)
+ {
+ _urbd->urb->actual_length += ((_ifxhc->start_pkt_count - hctsiz.b.pktcnt ) * _ifxhc->mps);
+// if( _urbd->urb->actual_length > _ifxhc->xfer_len) _urbd->urb->actual_length = _urbd->xfer_len;
+ }
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_STALL);
+ }
+ return 1;
+ }
+ else if (hcint.b.xacterr)
+ {
+ // ZLP shortcut
+ #if 1
+ if(hctsiz.b.pktcnt==0)
+ {
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ else
+ #endif
+ if(_ifxhc->control_phase == IFXHCD_CONTROL_STATUS)
+ {
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ else if(_ifxhc->control_phase == IFXHCD_CONTROL_SETUP)
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ }
+ else if(_ifxhc->control_phase == IFXHCD_CONTROL_DATA)
+ {
+ #if 0
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ #else
+ u32 actual_length;
+ actual_length = _urbd->urb->actual_length + ((_ifxhc->start_pkt_count - hctsiz.b.pktcnt ) * _ifxhc->mps);
+ if(actual_length>=_urbd->xfer_len)
+ {
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ else
+ {
+ _urbd->error_count++;
+ _ifxhc->xfer_count =
+ _urbd->urb->actual_length = actual_length;
+ _ifxhc->xfer_len = _urbd->xfer_len - actual_length;
+ _ifxhc->data_pid_start = read_data_toggle(_hc_regs);
+ if (_urbd->error_count >= 3)
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ }
+ else
+ {
+ _ifxhc->erron=1;
+ _ifxhc->phase=HC_WAITING;
+ _ifxhc->epqh->do_ping=1;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ }
+ #endif
+ }
+ else
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ }
+ return 1;
+ }
+ else if(hcint.b.bblerr )
+ {
+ if(_ifxhc->control_phase == IFXHCD_CONTROL_DATA)
+ {
+ _urbd->urb->actual_length += ((_ifxhc->start_pkt_count - hctsiz.b.pktcnt ) * _ifxhc->mps);
+// if( _urbd->urb->actual_length > _ifxhc->xfer_len) _urbd->urb->actual_length = _urbd->xfer_len;
+ }
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_BABBLE_ERR);
+ return 1;
+ }
+ else if(hcint.b.nak || hcint.b.nyet)
+ {
+ #ifdef __PINGSTOP_CTRL__
+ _urbd->error_count =0;
+ IFX_ERROR("ERROR %s():%d invalid chhlt condition\n",__func__,__LINE__);
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ #else
+ // ZLP shortcut
+ #if 1
+ if(hctsiz.b.pktcnt==0)
+ {
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ else
+ #endif
+ if(_ifxhc->control_phase == IFXHCD_CONTROL_STATUS)
+ {
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ else if(_ifxhc->control_phase == IFXHCD_CONTROL_SETUP)
+ {
+ _urbd->error_count =0;
+ IFX_ERROR("ERROR %s():%d invalid chhlt condition\n",__func__,__LINE__);
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ }
+ else if(_ifxhc->control_phase == IFXHCD_CONTROL_DATA)
+ {
+ #if 0
+ _ifxhc->epqh->do_ping=1;
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ #else
+ u32 actual_length;
+ _ifxhc->epqh->do_ping=1;
+ actual_length = _urbd->urb->actual_length + ((_ifxhc->start_pkt_count - hctsiz.b.pktcnt ) * _ifxhc->mps);
+ if(actual_length>=_urbd->xfer_len)
+ {
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ else
+ {
+ _ifxhc->xfer_count =
+ _urbd->urb->actual_length = actual_length;
+ _ifxhc->xfer_len = _urbd->xfer_len - actual_length;
+ _ifxhc->data_pid_start = read_data_toggle(_hc_regs);
+ _ifxhc->erron=1;
+ _ifxhc->epqh->do_ping=1;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ #endif
+ }
+ #endif
+ return 1;
+ }
+ else if(hcint.b.datatglerr )
+ {
+ if(_ifxhc->control_phase == IFXHCD_CONTROL_DATA)
+ {
+ _urbd->urb->actual_length += ((_ifxhc->start_pkt_count - hctsiz.b.pktcnt ) * _ifxhc->mps);
+// if( _urbd->urb->actual_length > _ifxhc->xfer_len) _urbd->urb->actual_length = _urbd->xfer_len;
+ }
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_DATA_TOGGLE_ERR);
+ return 1;
+ }
+ else if(hcint.b.frmovrun )
+ {
+ if(_ifxhc->control_phase == IFXHCD_CONTROL_DATA)
+ {
+ _urbd->urb->actual_length += ((_ifxhc->start_pkt_count - hctsiz.b.pktcnt ) * _ifxhc->mps);
+// if( _urbd->urb->actual_length > _ifxhc->xfer_len) _urbd->urb->actual_length = _urbd->xfer_len;
+ }
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_FRAME_OVERRUN);
+ return 1;
+ }
+ else
+ {
+ _urbd->error_count =0;
+ IFX_ERROR("ERROR %s():%d invalid chhlt condition %08X/%08X %d\n",__func__,__LINE__,hcint.d32,hcintmsk.d32,_ifxhc->halt_status);
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ return 1;
+ }
+ return 0;
+}
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+static int32_t chhltd_bulk_rx_nonsplit(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ hcint_data_t hcint;
+ hcint_data_t hcintmsk;
+ hctsiz_data_t hctsiz;
+
+ hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
+ hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
+ hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
+
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nak);
+ disable_hc_int(_hc_regs,nyet);
+
+ #ifdef __INNAKSTOP_BULK__
+ if(_ifxhc->halt_status == HC_XFER_NAK)
+ {
+ u32 actual_length;
+ actual_length = _urbd->urb->actual_length + (_ifxhc->xfer_len - hctsiz.b.xfersize);
+
+ if(
+ (_urbd->xfer_len && actual_length>=_urbd->xfer_len)
+ || hctsiz.b.pktcnt==0
+ || (hctsiz.b.xfersize % _ifxhc->mps)>0
+ )
+ {
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ else
+ {
+ _urbd->urb->actual_length = actual_length;
+ _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
+ _ifxhc->xfer_count = _urbd->urb->actual_length;
+ _ifxhc->data_pid_start = read_data_toggle(_hc_regs);
+ _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ return 1;
+ }
+ #endif
+
+ if (hcint.b.xfercomp || hcint.d32 == 0x02)
+ {
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ return 1;
+ }
+ else if (hcint.b.stall)
+ {
+ _urbd->error_count =0;
+ // ZLP shortcut
+ #if 0
+ if(hctsiz.b.pktcnt==0)
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ else
+ #endif
+ {
+ _urbd->urb->actual_length += (_ifxhc->xfer_len - hctsiz.b.xfersize);
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_STALL);
+ }
+ return 1;
+ }
+ else if (hcint.b.bblerr)
+ {
+ _urbd->error_count =0;
+
+ // ZLP shortcut
+ #if 0
+ if(hctsiz.b.pktcnt==0)
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ else
+ #endif
+ {
+ _urbd->urb->actual_length += (_ifxhc->xfer_len - hctsiz.b.xfersize);
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_BABBLE_ERR);
+ }
+ return 1;
+ }
+ else if (hcint.b.xacterr)
+ {
+ // ZLP shortcut
+ #if 1
+ if(hctsiz.b.pktcnt==0)
+ {
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ else
+ #endif
+ {
+ #if 0
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ #else
+ u32 actual_length;
+ actual_length = _urbd->urb->actual_length + (_ifxhc->xfer_len - hctsiz.b.xfersize);
+ if(actual_length >= _urbd->xfer_len)
+ {
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ else
+ {
+ _urbd->error_count++;
+ _ifxhc->xfer_count =
+ _urbd->urb->actual_length = actual_length;
+ _ifxhc->xfer_len = _urbd->xfer_len - actual_length;
+ _ifxhc->data_pid_start = read_data_toggle(_hc_regs);
+ if (_urbd->error_count >= 3)
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ }
+ else
+ {
+ _ifxhc->erron=1;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ }
+ #endif
+ }
+ return 1;
+ }
+ else if(hcint.b.datatglerr )
+ {
+ #if 0
+ #if 1
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ #else
+ u32 actual_length;
+ actual_length = _urbd->urb->actual_length + (_ifxhc->xfer_len - hctsiz.b.xfersize);
+ if(actual_length >= _urbd->xfer_len)
+ {
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ else
+ {
+ _urbd->urb->actual_length = actual_length;
+ _ifxhc->data_pid_start = read_data_toggle(_hc_regs);
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_DATA_TOGGLE_ERR);
+ }
+ #endif
+ #else
+ _urbd->urb->actual_length += (_ifxhc->xfer_len - hctsiz.b.xfersize);
+// if( _urbd->urb->actual_length > _ifxhc->xfer_len) _urbd->urb->actual_length = _urbd->xfer_len;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_DATA_TOGGLE_ERR);
+ #endif
+ return 1;
+ }
+ else if(hcint.b.frmovrun )
+ {
+// if( _urbd->urb->actual_length > _ifxhc->xfer_len) _urbd->urb->actual_length = _urbd->xfer_len;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_FRAME_OVERRUN);
+ return 1;
+ }
+ else
+ {
+ _urbd->error_count =0;
+ IFX_ERROR("ERROR %s():%d invalid chhlt condition %08X/%08X %d sz:%d/%d/%d/%d\n",__func__,__LINE__,hcint.d32,hcintmsk.d32,_ifxhc->halt_status , hctsiz.b.xfersize, _ifxhc->xfer_len-_ifxhc->xfer_len,_ifxhc->xfer_len,_urbd->xfer_len);
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ return 1;
+ }
+ return 0;
+}
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+static int32_t chhltd_bulk_tx_nonsplit(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ hcint_data_t hcint;
+ hcint_data_t hcintmsk;
+ hctsiz_data_t hctsiz;
+ int out_nak_enh = 0;
+
+ if (_ifxhcd->core_if.snpsid >= 0x4f54271a && _ifxhc->speed == IFXUSB_EP_SPEED_HIGH)
+ out_nak_enh = 1;
+
+ hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
+ hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
+ hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nak);
+ disable_hc_int(_hc_regs,nyet);
+
+ #ifdef __PINGSTOP_BULK__
+ if (_ifxhc->halt_status == HC_XFER_NAK)
+ {
+ u32 actual_length;
+ actual_length = _urbd->urb->actual_length + ((_ifxhc->start_pkt_count - hctsiz.b.pktcnt ) * _ifxhc->mps);
+
+ if(_urbd->xfer_len && actual_length >= _urbd->xfer_len)
+ {
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ else
+ {
+ _ifxhc->xfer_count =
+ _urbd->urb->actual_length = actual_length;
+ _ifxhc->xfer_len = _urbd->xfer_len - actual_length;
+ _ifxhc->data_pid_start = read_data_toggle(_hc_regs);
+ _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ return 1;
+ }
+ #endif
+
+ if (hcint.b.xfercomp || hcint.d32 == 0x02)
+ {
+ _urbd->error_count =0;
+ if(_ifxhc->xfer_len==0 && !hcint.b.ack && hcint.b.nak)
+ {
+ // Walkaround: When sending ZLP and receive NAK but also issue CMPT intr
+ // Solution: NoSplit: Resend at next SOF
+ // Split : Resend at next SOF with SSPLIT
+ if(hcint.b.nyet)
+ _ifxhc->epqh->do_ping=1;
+
+ _ifxhc->xfer_len = 0;
+ _ifxhc->xfer_count = 0;
+ _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ else
+ {
+ if(hcint.b.nyet)
+ _ifxhc->epqh->do_ping=1;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ return 1;
+ }
+ else if (hcint.b.stall)
+ {
+ _urbd->error_count =0;
+
+ // ZLP shortcut
+ #if 1
+ if(hctsiz.b.pktcnt==0)
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ else
+ #endif
+ {
+ _urbd->urb->actual_length += ((_ifxhc->start_pkt_count - hctsiz.b.pktcnt ) * _ifxhc->mps);
+ if(_urbd->urb->actual_length>_urbd->xfer_len) _urbd->urb->actual_length=_urbd->xfer_len;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_STALL);
+ }
+ return 1;
+ }
+ else if (hcint.b.xacterr)
+ {
+ // ZLP shortcut
+ #if 1
+ if(hctsiz.b.pktcnt==0)
+ {
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ else
+ #endif
+ {
+ #if 0
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ #else
+ u32 actual_length;
+ actual_length = _urbd->urb->actual_length + ((_ifxhc->start_pkt_count - hctsiz.b.pktcnt ) * _ifxhc->mps);
+ if(actual_length >= _urbd->xfer_len)
+ {
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ else
+ {
+ _urbd->error_count++;
+ _ifxhc->xfer_count =
+ _urbd->urb->actual_length = actual_length;
+ _ifxhc->xfer_len = _urbd->xfer_len - actual_length;
+ _ifxhc->data_pid_start = read_data_toggle(_hc_regs);
+ if (_urbd->error_count >= 3)
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ }
+ else
+ {
+ _ifxhc->erron=1;
+ _ifxhc->phase=HC_WAITING;
+ _ifxhc->epqh->do_ping=1;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ }
+ #endif
+ }
+ return 1;
+ }
+ else if(hcint.b.bblerr )
+ {
+ _urbd->urb->actual_length += ((_ifxhc->start_pkt_count - hctsiz.b.pktcnt ) * _ifxhc->mps);
+ if(_urbd->urb->actual_length>_urbd->xfer_len) _urbd->urb->actual_length=_urbd->xfer_len;
+ IFX_ERROR("ERROR %s():%d invalid packet babble\n",__func__,__LINE__);
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_BABBLE_ERR);
+ return 1;
+ }
+ else if(hcint.b.nak || hcint.b.nyet)
+ {
+ #ifdef __PINGSTOP_BULK__
+ _urbd->error_count =0;
+ IFX_ERROR("ERROR %s():%d invalid chhlt condition\n",__func__,__LINE__);
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ #else
+ // ZLP shortcut
+ #if 1
+ if(hctsiz.b.pktcnt==0)
+ {
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ else
+ #endif
+ {
+ #if 0
+ _ifxhc->epqh->do_ping=1;
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ #else
+ u32 actual_length;
+ _ifxhc->epqh->do_ping=1;
+ actual_length = _urbd->urb->actual_length + ((_ifxhc->start_pkt_count - hctsiz.b.pktcnt ) * _ifxhc->mps);
+ if(actual_length>=_urbd->xfer_len)
+ {
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ else
+ {
+ _ifxhc->xfer_count =
+ _urbd->urb->actual_length = actual_length;
+ _ifxhc->xfer_len = _urbd->xfer_len - actual_length;
+ _ifxhc->data_pid_start = read_data_toggle(_hc_regs);
+ _ifxhc->erron=1;
+ _ifxhc->epqh->do_ping=1;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ #endif
+ }
+ #endif
+ return 1;
+ }
+ else if(hcint.b.datatglerr )
+ {
+ _urbd->urb->actual_length += ((_ifxhc->start_pkt_count - hctsiz.b.pktcnt ) * _ifxhc->mps);
+// if( _urbd->urb->actual_length > _ifxhc->xfer_len) _urbd->urb->actual_length = _urbd->xfer_len;
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_DATA_TOGGLE_ERR);
+ return 1;
+ }
+ else if(hcint.b.frmovrun )
+ {
+ _urbd->urb->actual_length += ((_ifxhc->start_pkt_count - hctsiz.b.pktcnt ) * _ifxhc->mps);
+// if( _urbd->urb->actual_length > _ifxhc->xfer_len) _urbd->urb->actual_length = _urbd->xfer_len;
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_FRAME_OVERRUN);
+ return 1;
+ }
+ else
+ {
+ _urbd->error_count =0;
+ IFX_ERROR("ERROR %s():%d invalid chhlt condition %08X/%08X %d\n",__func__,__LINE__,hcint.d32,hcintmsk.d32,_ifxhc->halt_status);
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ return 1;
+ }
+ return 0;
+}
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+static int32_t chhltd_intr_rx_nonsplit(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ hcint_data_t hcint;
+ hcint_data_t hcintmsk;
+ hctsiz_data_t hctsiz;
+
+ hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
+ hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
+ hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nak);
+ disable_hc_int(_hc_regs,nyet);
+
+ if (hcint.b.xfercomp || hcint.d32 == 0x02)
+ {
+ _urbd->error_count =0;
+ //restart INTR immediately
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ return 1;
+ }
+ else if (hcint.b.stall)
+ {
+ _urbd->error_count =0;
+
+ // Don't care shortcut
+ #if 0
+ if(hctsiz.b.pktcnt==0)
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ else
+ #endif
+ {
+ _urbd->urb->actual_length += (_ifxhc->xfer_len - hctsiz.b.xfersize);
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_STALL);
+ }
+ return 1;
+ }
+ else if (hcint.b.bblerr)
+ {
+ _urbd->error_count =0;
+
+ // Don't care shortcut
+ #if 0
+ if(hctsiz.b.pktcnt==0)
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ else
+ #endif
+ {
+ _urbd->urb->actual_length += (_ifxhc->xfer_len - hctsiz.b.xfersize);
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_BABBLE_ERR);
+ }
+ return 1;
+ }
+ else if (hcint.b.datatglerr || hcint.b.frmovrun)
+ {
+ _urbd->error_count =0;
+ //restart INTR immediately
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ return 1;
+ }
+ else if (hcint.b.xacterr)
+ {
+ // ZLP shortcut
+ #if 1
+ if(hctsiz.b.pktcnt==0)
+ {
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ else
+ #endif
+ {
+ _urbd->error_count++;
+ if(_urbd->error_count>=3)
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ }
+ else
+ {
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ }
+ return 1;
+ }
+ else if(hcint.b.nyet )
+ {
+ return 1;
+ }
+ else if (hcint.b.nak)
+ {
+
+ #ifdef __INTRNAKRETRY__
+ if(hctsiz.b.pktcnt)
+ {
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_INTR_NAK_RETRY);
+ return 1;
+ }
+ #endif
+ _urbd->error_count =0;
+ //restart INTR immediately
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ return 1;
+ }
+ else
+ {
+ _urbd->error_count =0;
+ //restart INTR immediately
+ #if 0
+ if(hctsiz.b.pktcnt>0)
+ {
+ // TODO Re-initialize Channel (in next b_interval - 1 uF/F)
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ else
+ #endif
+ {
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ return 1;
+ }
+
+ return 0;
+}
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+static int32_t chhltd_intr_tx_nonsplit(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ hcint_data_t hcint;
+ hcint_data_t hcintmsk;
+ hctsiz_data_t hctsiz;
+ int out_nak_enh = 0;
+
+ if (_ifxhcd->core_if.snpsid >= 0x4f54271a && _ifxhc->speed == IFXUSB_EP_SPEED_HIGH)
+ out_nak_enh = 1;
+
+ hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
+ hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
+ hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
+
+ if (hcint.b.xfercomp || hcint.d32 == 0x02)
+ {
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nak);
+ disable_hc_int(_hc_regs,nyet);
+ _urbd->error_count =0;
+ //restart INTR immediately
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ return 1;
+ }
+ else if (hcint.b.stall)
+ {
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nyet);
+ disable_hc_int(_hc_regs,nak);
+ _urbd->error_count =0;
+
+ // Don't care shortcut
+ #if 0
+ if(hctsiz.b.pktcnt==0)
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ else
+ #endif
+ {
+ if(_ifxhc->xfer_len!=0)// !_ifxhc->is_in
+ _urbd->urb->actual_length += ((_ifxhc->start_pkt_count - hctsiz.b.pktcnt ) * _ifxhc->mps);
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_STALL);
+ }
+ return 1;
+ }
+ else if(hcint.b.nak || hcint.b.frmovrun )
+ {
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nyet);
+ disable_hc_int(_hc_regs,nak);
+ _urbd->error_count =0;
+ //restart INTR immediately
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ return 1;
+ }
+ else if(hcint.b.xacterr )
+ {
+ // ZLP shortcut
+ #if 1
+ if(hctsiz.b.pktcnt==0)
+ {
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ else
+ #endif
+ {
+ _urbd->error_count++;
+ if(_urbd->error_count>=3)
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ }
+ else
+ {
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ }
+ return 1;
+ }
+ else if(hcint.b.bblerr )
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_BABBLE_ERR);
+ return 1;
+ }
+ else if(hcint.b.datatglerr )
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_DATA_TOGGLE_ERR);
+ return 1;
+ }
+ return 0;
+}
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+static int32_t chhltd_isoc_rx_nonsplit(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ #ifdef __EN_ISOC__
+ hcint_data_t hcint;
+ hcint_data_t hcintmsk;
+ hctsiz_data_t hctsiz;
+
+ hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
+ hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
+ hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
+
+ if (hcint.b.xfercomp || hcint.b.frmovrun || hcint.d32 == 0x02)
+ {
+ _urbd->error_count=0;
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nak);
+ disable_hc_int(_hc_regs,nyet);
+ if (hcint.b.xfercomp)
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ else
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_FRAME_OVERRUN);
+ }
+ else if (hcint.b.xacterr || hcint.b.bblerr)
+ {
+ #ifndef VR9Skip
+ if(hctsiz.b.pktcnt==0)
+ {
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ else
+ {
+ _urbd->urb->actual_length += (_ifxhc->xfer_len - hctsiz.b.xfersize);
+ _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
+ _ifxhc->xfer_count = _urbd->urb->actual_length;
+ _ifxhc->data_pid_start = read_data_toggle(_hc_regs);
+ _urbd->error_count++;
+ if(_urbd->error_count>=3)
+ {
+ _urbd->error_count=0;
+ if (hcint.b.bblerr)
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_BABBLE_ERR);
+ else if (hcint.b.xacterr)
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ }
+ else
+ {
+ enable_hc_int(_hc_regs,ack);
+ enable_hc_int(_hc_regs,nak);
+ enable_hc_int(_hc_regs,nyet);
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ }
+ #endif
+ }
+ else if(hcint.b.datatglerr )
+ {
+ return 1;
+ }
+ else if(hcint.b.stall )
+ {
+ return 1;
+ }
+ #endif
+ return 0;
+}
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+static int32_t chhltd_isoc_tx_nonsplit(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ #ifdef __EN_ISOC__
+ hcint_data_t hcint;
+ hcint_data_t hcintmsk;
+ hctsiz_data_t hctsiz;
+ int out_nak_enh = 0;
+
+ if (_ifxhcd->core_if.snpsid >= 0x4f54271a && _ifxhc->speed == IFXUSB_EP_SPEED_HIGH)
+ out_nak_enh = 1;
+
+ hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
+ hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
+ hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
+
+ if (hcint.b.xfercomp || hcint.d32 == 0x02)
+ {
+ _urbd->error_count=0;
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nak);
+ disable_hc_int(_hc_regs,nyet);
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ return 1;
+ }
+ else if (hcint.b.frmovrun)
+ {
+ #ifndef VR9Skip
+ _urbd->error_count=0;
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nak);
+ disable_hc_int(_hc_regs,nyet);
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_FRAME_OVERRUN);
+ #endif
+ }
+ else if(hcint.b.datatglerr )
+ {
+ return 1;
+ }
+ else if(hcint.b.bblerr )
+ {
+ #ifndef VR9Skip
+ if(hctsiz.b.pktcnt==0)
+ {
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ else
+ {
+ _urbd->urb->actual_length += (_ifxhc->xfer_len - hctsiz.b.xfersize);
+ _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
+ _ifxhc->xfer_count = _urbd->urb->actual_length;
+ _ifxhc->data_pid_start = read_data_toggle(_hc_regs);
+ _urbd->error_count++;
+ if(_urbd->error_count>=3)
+ {
+ _urbd->error_count=0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_BABBLE_ERR);
+ }
+ else
+ {
+ enable_hc_int(_hc_regs,ack);
+ enable_hc_int(_hc_regs,nak);
+ enable_hc_int(_hc_regs,nyet);
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ }
+ #endif
+ }
+ else if(hcint.b.xacterr )
+ {
+ if(hctsiz.b.pktcnt==0)
+ {
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ return 1;
+ }
+ _urbd->error_count++;
+ if(_urbd->error_count>=3)
+ {
+ _urbd->error_count=0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ }
+ else
+ {
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ return 1;
+ }
+ else if(hcint.b.stall )
+ {
+ return 1;
+ }
+ #endif
+ return 0;
+}
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+static int32_t chhltd_ctrl_rx_ssplit(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ hcint_data_t hcint;
+ hcint_data_t hcintmsk;
+ hctsiz_data_t hctsiz;
+
+ hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
+ hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
+ hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
+
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nak);
+ disable_hc_int(_hc_regs,nyet);
+
+ if (hcint.b.ack)
+ {
+ _urbd->error_count=0;
+ _ifxhc->split=2;
+ _ifxhc->data_pid_start = read_data_toggle(_hc_regs);
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if (hcint.b.nak)
+ {
+ _urbd->error_count = 0;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if (hcint.b.xacterr)
+ {
+ _urbd->error_count++;
+ if(_urbd->error_count>=3)
+ {
+ _urbd->error_count=0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ }
+ else
+ {
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ return 1;
+ }
+ else if(hcint.b.bblerr )
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_BABBLE_ERR);
+ return 1;
+ }
+ else if(hcint.b.stall )
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_STALL);
+ return 1;
+ }
+ else if(hcint.b.datatglerr )
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_DATA_TOGGLE_ERR);
+ return 1;
+ }
+ else if(hcint.b.frmovrun )
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_FRAME_OVERRUN);
+ return 1;
+ }
+ else if(hcint.b.nyet )
+ {
+ }
+ else if(hcint.b.xfercomp )
+ {
+ }
+ return 0;
+}
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+static int32_t chhltd_ctrl_tx_ssplit(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ hcint_data_t hcint;
+ hcint_data_t hcintmsk;
+ hctsiz_data_t hctsiz;
+ int out_nak_enh = 0;
+
+ if (_ifxhcd->core_if.snpsid >= 0x4f54271a && _ifxhc->speed == IFXUSB_EP_SPEED_HIGH)
+ out_nak_enh = 1;
+
+ hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
+ hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
+ hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nak);
+ disable_hc_int(_hc_regs,nyet);
+
+ if (hcint.b.ack )
+ {
+ _urbd->error_count=0;
+ if (_ifxhc->control_phase != IFXHCD_CONTROL_SETUP)
+ _ifxhc->ssplit_out_xfer_count = _ifxhc->xfer_len;
+ _ifxhc->split=2;
+ _ifxhc->data_pid_start =read_data_toggle(_hc_regs);
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.nyet)
+ {
+ _urbd->error_count=0;
+ if (_ifxhc->control_phase != IFXHCD_CONTROL_SETUP)
+ _ifxhc->ssplit_out_xfer_count = _ifxhc->xfer_len;
+ _ifxhc->split=2;
+ _ifxhc->data_pid_start =read_data_toggle(_hc_regs);
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.nak )
+ {
+ _urbd->error_count =0;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.xacterr )
+ {
+ _urbd->error_count++;
+ if(_urbd->error_count>=3)
+ {
+ _urbd->error_count=0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ }
+ else
+ {
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ return 1;
+ }
+ else if(hcint.b.datatglerr )
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_DATA_TOGGLE_ERR);
+ return 1;
+ }
+ else if(hcint.b.bblerr )
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_BABBLE_ERR);
+ return 1;
+ }
+ else if(hcint.b.stall )
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_STALL);
+ return 1;
+ }
+ else if(hcint.b.frmovrun )
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_FRAME_OVERRUN);
+ return 1;
+ }
+ else if(hcint.b.xfercomp )
+ {
+ printk(KERN_INFO "Warning: %s() %d CTRL OUT SPLIT1 COMPLETE\n",__func__,__LINE__);
+ }
+ return 0;
+}
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+static int32_t chhltd_bulk_rx_ssplit(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ hcint_data_t hcint;
+ hcint_data_t hcintmsk;
+ hctsiz_data_t hctsiz;
+
+ hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
+ hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
+ hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
+
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nak);
+ disable_hc_int(_hc_regs,nyet);
+
+ if (hcint.b.ack)
+ {
+ _urbd->error_count=0;
+ _ifxhc->split=2;
+ _ifxhc->data_pid_start = read_data_toggle(_hc_regs);
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if (hcint.b.nak)
+ {
+ _urbd->error_count = 0;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if (hcint.b.xacterr)
+ {
+ _urbd->error_count++;
+ if(_urbd->error_count>=3)
+ {
+ _urbd->error_count=0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ }
+ else
+ {
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ return 1;
+ }
+ else if(hcint.b.bblerr )
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_BABBLE_ERR);
+ return 1;
+ }
+ else if(hcint.b.stall )
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_STALL);
+ return 1;
+ }
+ else if(hcint.b.datatglerr )
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_DATA_TOGGLE_ERR);
+ return 1;
+ }
+ else if(hcint.b.frmovrun )
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_FRAME_OVERRUN);
+ return 1;
+ }
+ else if(hcint.b.nyet )
+ {
+ }
+ else if(hcint.b.xfercomp )
+ {
+ }
+ return 0;
+}
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+static int32_t chhltd_bulk_tx_ssplit(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ hcint_data_t hcint;
+ hcint_data_t hcintmsk;
+ hctsiz_data_t hctsiz;
+ int out_nak_enh = 0;
+
+ if (_ifxhcd->core_if.snpsid >= 0x4f54271a && _ifxhc->speed == IFXUSB_EP_SPEED_HIGH)
+ out_nak_enh = 1;
+
+ hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
+ hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
+ hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nak);
+ disable_hc_int(_hc_regs,nyet);
+
+ if (hcint.b.ack )
+ {
+ _urbd->error_count=0;
+ _ifxhc->ssplit_out_xfer_count = _ifxhc->xfer_len;
+ _ifxhc->split=2;
+ _ifxhc->data_pid_start =read_data_toggle(_hc_regs);
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.nyet)
+ {
+ _urbd->error_count=0;
+ _ifxhc->ssplit_out_xfer_count = _ifxhc->xfer_len;
+ _ifxhc->split=2;
+ _ifxhc->data_pid_start =read_data_toggle(_hc_regs);
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.nak )
+ {
+ _urbd->error_count =0;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.xacterr )
+ {
+ _urbd->error_count++;
+ if(_urbd->error_count>=3)
+ {
+ _urbd->error_count=0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ }
+ else
+ {
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ return 1;
+ }
+ else if(hcint.b.datatglerr )
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_DATA_TOGGLE_ERR);
+ return 1;
+ }
+ else if(hcint.b.bblerr )
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_BABBLE_ERR);
+ return 1;
+ }
+ else if(hcint.b.stall )
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_STALL);
+ return 1;
+ }
+ else if(hcint.b.frmovrun )
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_FRAME_OVERRUN);
+ return 1;
+ }
+ else if(hcint.b.xfercomp )
+ {
+ printk(KERN_INFO "Warning: %s() %d BULK OUT SPLIT1 COMPLETE\n",__func__,__LINE__);
+ }
+ return 0;
+}
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+static int32_t chhltd_intr_rx_ssplit(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ hcint_data_t hcint;
+ hcint_data_t hcintmsk;
+ hctsiz_data_t hctsiz;
+
+ hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
+ hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
+ hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
+
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nak);
+ disable_hc_int(_hc_regs,nyet);
+
+ if (hcint.b.ack)
+ {
+ _urbd->error_count=0;
+ _ifxhc->split=2;
+ _ifxhc->data_pid_start = read_data_toggle(_hc_regs);
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.nak)
+ {
+ _urbd->error_count=0;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.xacterr)
+ {
+ hcchar_data_t hcchar;
+ hcchar.d32 = ifxusb_rreg(&_hc_regs->hcchar);
+ _urbd->error_count=hcchar.b.multicnt;
+ if(_urbd->error_count>=3)
+ {
+ _urbd->error_count=0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ }
+ else
+ {
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ return 1;
+ }
+ else if(hcint.b.stall )
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_STALL);
+ return 1;
+ }
+ else if(hcint.b.bblerr )
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_BABBLE_ERR);
+ return 1;
+ }
+ else if(hcint.b.frmovrun )
+ {
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.datatglerr )
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_DATA_TOGGLE_ERR);
+ return 1;
+ }
+ else if(hcint.b.xfercomp )
+ {
+ }
+ return 0;
+}
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+static int32_t chhltd_intr_tx_ssplit(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ hcint_data_t hcint;
+ hcint_data_t hcintmsk;
+ hctsiz_data_t hctsiz;
+ int out_nak_enh = 0;
+
+ if (_ifxhcd->core_if.snpsid >= 0x4f54271a && _ifxhc->speed == IFXUSB_EP_SPEED_HIGH)
+ out_nak_enh = 1;
+
+ hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
+ hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
+ hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
+
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nak);
+ disable_hc_int(_hc_regs,nyet);
+
+ if (hcint.b.ack )
+ {
+ _urbd->error_count=0;
+ _ifxhc->ssplit_out_xfer_count = _ifxhc->xfer_len;
+ _ifxhc->split=2;
+ _ifxhc->data_pid_start = read_data_toggle(_hc_regs);
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.nyet)
+ {
+ _urbd->error_count=0;
+ _ifxhc->ssplit_out_xfer_count = _ifxhc->xfer_len;
+ _ifxhc->split=2;
+ _ifxhc->data_pid_start = read_data_toggle(_hc_regs);
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.nak )
+ {
+ _urbd->error_count =0;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.frmovrun )
+ {
+ _urbd->error_count =0;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.xacterr )
+ {
+ hcchar_data_t hcchar;
+ hcchar.d32 = ifxusb_rreg(&_hc_regs->hcchar);
+ _urbd->error_count=hcchar.b.multicnt;
+ if(_urbd->error_count>=3)
+ {
+ _urbd->error_count=0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ }
+ else
+ {
+ enable_hc_int(_hc_regs,ack);
+ enable_hc_int(_hc_regs,nak);
+ enable_hc_int(_hc_regs,nyet);
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ return 1;
+ }
+ else if(hcint.b.datatglerr )
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_DATA_TOGGLE_ERR);
+ return 1;
+ }
+ else if(hcint.b.bblerr )
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_BABBLE_ERR);
+ return 1;
+ }
+ else if(hcint.b.stall )
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_STALL);
+ return 1;
+ }
+ else if(hcint.b.xfercomp )
+ {
+ }
+ return 0;
+}
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+static int32_t chhltd_isoc_rx_ssplit(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ #if defined(__EN_ISOC__) && defined(__EN_ISOC_SPLIT__)
+ hcint_data_t hcint;
+ hcint_data_t hcintmsk;
+ hctsiz_data_t hctsiz;
+
+ hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
+ hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
+ hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
+ if (hcint.b.ack )
+ {
+ Do Complete Split
+ }
+ else if(hcint.b.frmovrun )
+ {
+ Rewind Buffer Pointers
+ Retry Start Split (in next b_interval ¡V 1 uF)
+ }
+ else if(hcint.b.datatglerr )
+ {
+ //warning
+ }
+ else if(hcint.b.bblerr )
+ {
+ //warning
+ }
+ else if(hcint.b.xacterr )
+ {
+ //warning
+ }
+ else if(hcint.b.stall )
+ {
+ //warning
+ }
+ else if(hcint.b.nak )
+ {
+ //warning
+ }
+ else if(hcint.b.xfercomp )
+ {
+ //warning
+ }
+ else if(hcint.b.nyet)
+ {
+ //warning
+ }
+ #endif
+ return 0;
+}
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+static int32_t chhltd_isoc_tx_ssplit(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ #if defined(__EN_ISOC__) && defined(__EN_ISOC_SPLIT__)
+ hcint_data_t hcint;
+ hcint_data_t hcintmsk;
+ hctsiz_data_t hctsiz;
+ int out_nak_enh = 0;
+
+ if (_ifxhcd->core_if.snpsid >= 0x4f54271a && _ifxhc->speed == IFXUSB_EP_SPEED_HIGH)
+ out_nak_enh = 1;
+
+ hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
+ hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
+ hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
+ if (hcint.b.ack )
+ {
+ //Do Next Start Split (in next b_interval ¡V 1 uF)
+ }
+ else if(hcint.b.frmovrun )
+ {
+ //Do Next Transaction in next frame.
+ }
+ else if(hcint.b.datatglerr )
+ {
+ //warning
+ }
+ else if(hcint.b.bblerr )
+ {
+ //warning
+ }
+ else if(hcint.b.xacterr )
+ {
+ //warning
+ }
+ else if(hcint.b.stall )
+ {
+ //warning
+ }
+ else if(hcint.b.nak )
+ {
+ //warning
+ }
+ else if(hcint.b.xfercomp )
+ {
+ //warning
+ }
+ else if(hcint.b.nyet)
+ {
+ //warning
+ }
+ #endif
+ return 0;
+}
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+static int32_t chhltd_ctrl_rx_csplit(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ hcint_data_t hcint;
+ hcint_data_t hcintmsk;
+ hctsiz_data_t hctsiz;
+
+ hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
+ hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
+ hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nak);
+ disable_hc_int(_hc_regs,nyet);
+
+ if (hcint.b.xfercomp)
+ {
+ _urbd->error_count =0;
+ _ifxhc->split=1;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ return 1;
+ }
+ else if (hcint.b.nak)
+ {
+ _ifxhc->split = 1;
+ if(_ifxhc->control_phase == IFXHCD_CONTROL_DATA)
+ {
+ _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
+ _ifxhc->xfer_count = _urbd->urb->actual_length;
+ }
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.nyet)
+ {
+ _urbd->error_count=0;
+ _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.stall || hcint.b.bblerr )
+ {
+ _urbd->error_count=0;
+ if (hcint.b.stall)
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_STALL);
+ else if(hcint.b.bblerr )
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_BABBLE_ERR);
+ return 1;
+ }
+ else if(hcint.b.xacterr )
+ {
+ _urbd->error_count++;
+ if(_urbd->error_count>=3)
+ {
+ _urbd->error_count=0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ }
+ else
+ {
+ _ifxhc->split=1;
+ if(_ifxhc->control_phase == IFXHCD_CONTROL_DATA)
+ {
+ _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
+ _ifxhc->xfer_count = _urbd->urb->actual_length;
+ }
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ return 1;
+ }
+ else if(hcint.b.datatglerr )
+ {
+ if(_ifxhc->data_pid_start == IFXUSB_HC_PID_DATA0)
+ _ifxhc->data_pid_start = IFXUSB_HC_PID_DATA1;
+ else
+ _ifxhc->data_pid_start = IFXUSB_HC_PID_DATA0;
+ _ifxhc->split=1;
+ if(_ifxhc->control_phase == IFXHCD_CONTROL_DATA)
+ {
+ _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
+ _ifxhc->xfer_count = _urbd->urb->actual_length;
+ }
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.frmovrun )
+ {
+ _urbd->error_count=0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_FRAME_OVERRUN);
+ return 1;
+ }
+ return 0;
+}
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+static int32_t chhltd_ctrl_tx_csplit(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ hcint_data_t hcint;
+ hcint_data_t hcintmsk;
+ hctsiz_data_t hctsiz;
+ int out_nak_enh = 0;
+
+ if (_ifxhcd->core_if.snpsid >= 0x4f54271a && _ifxhc->speed == IFXUSB_EP_SPEED_HIGH)
+ out_nak_enh = 1;
+
+ hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
+ hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
+ hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nak);
+ disable_hc_int(_hc_regs,nyet);
+
+ if(hcint.b.xfercomp )
+ {
+ _urbd->error_count=0;
+ _ifxhc->split=1;
+ #if 0
+ if(_ifxhc->xfer_len==0 && !hcint.b.ack && (hcint.b.nak || hcint.b.nyet))
+ {
+ // Walkaround: When sending ZLP and receive NYEY or NAK but also issue CMPT intr
+ // Solution: NoSplit: Resend at next SOF
+ // Split : Resend at next SOF with SSPLIT
+ _ifxhc->xfer_len = 0;
+ _ifxhc->xfer_count = 0;
+ _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ else
+ #endif
+ {
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ return 1;
+ }
+ else if(hcint.b.nak )
+ {
+ _ifxhc->split = 1;
+ if(_ifxhc->control_phase == IFXHCD_CONTROL_DATA)
+ {
+ _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
+ _ifxhc->xfer_count = _urbd->urb->actual_length;
+ }
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.nyet)
+ {
+ //Retry Complete Split
+ // Issue Retry instantly on next SOF, without gothrough process_channels
+ _urbd->error_count=0;
+ _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.stall )
+ {
+ _urbd->error_count=0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_STALL);
+ return 1;
+ }
+ else if(hcint.b.xacterr )
+ {
+ _urbd->error_count++;
+ if(_urbd->error_count>=3)
+ {
+ _urbd->error_count=0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ }
+ else
+ {
+ _ifxhc->split=1;
+ if(_ifxhc->control_phase == IFXHCD_CONTROL_DATA)
+ {
+ _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
+ _ifxhc->xfer_count = _urbd->urb->actual_length;
+ }
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ return 1;
+ }
+ else if(hcint.b.datatglerr )
+ {
+ if(_ifxhc->data_pid_start == IFXUSB_HC_PID_DATA0)
+ _ifxhc->data_pid_start = IFXUSB_HC_PID_DATA1;
+ else
+ _ifxhc->data_pid_start = IFXUSB_HC_PID_DATA0;
+ _ifxhc->split=1;
+ if(_ifxhc->control_phase == IFXHCD_CONTROL_DATA)
+ {
+ _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
+ _ifxhc->xfer_count = _urbd->urb->actual_length;
+ }
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.frmovrun )
+ {
+ _urbd->error_count=0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_FRAME_OVERRUN);
+ return 1;
+ }
+ else if(hcint.b.bblerr )
+ {
+ _urbd->error_count=0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_BABBLE_ERR);
+ return 1;
+ }
+ return 0;
+}
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+static int32_t chhltd_bulk_rx_csplit(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ hcint_data_t hcint;
+ hcint_data_t hcintmsk;
+ hctsiz_data_t hctsiz;
+
+ hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
+ hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
+ hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nak);
+ disable_hc_int(_hc_regs,nyet);
+
+ if (hcint.b.xfercomp)
+ {
+ _urbd->error_count =0;
+ _ifxhc->split=1;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ return 1;
+ }
+ else if (hcint.b.nak)
+ {
+ _ifxhc->split = 1;
+ _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
+ _ifxhc->xfer_count = _urbd->urb->actual_length;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.nyet)
+ {
+ _urbd->error_count=0;
+ _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.stall || hcint.b.bblerr )
+ {
+ _urbd->error_count=0;
+ if (hcint.b.stall)
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_STALL);
+ else if(hcint.b.bblerr )
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_BABBLE_ERR);
+ return 1;
+ }
+ else if(hcint.b.xacterr )
+ {
+ _urbd->error_count++;
+ if(_urbd->error_count>=3)
+ {
+ _urbd->error_count=0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ }
+ else
+ {
+ _ifxhc->split=1;
+ _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
+ _ifxhc->xfer_count = _urbd->urb->actual_length;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ return 1;
+ }
+ else if(hcint.b.datatglerr )
+ {
+ if(_ifxhc->data_pid_start == IFXUSB_HC_PID_DATA0)
+ _ifxhc->data_pid_start = IFXUSB_HC_PID_DATA1;
+ else
+ _ifxhc->data_pid_start = IFXUSB_HC_PID_DATA0;
+ _ifxhc->split=1;
+ _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
+ _ifxhc->xfer_count = _urbd->urb->actual_length;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.frmovrun )
+ {
+ _urbd->error_count=0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_FRAME_OVERRUN);
+ return 1;
+ }
+ return 0;
+}
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+static int32_t chhltd_bulk_tx_csplit(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ hcint_data_t hcint;
+ hcint_data_t hcintmsk;
+ hctsiz_data_t hctsiz;
+ int out_nak_enh = 0;
+
+ if (_ifxhcd->core_if.snpsid >= 0x4f54271a && _ifxhc->speed == IFXUSB_EP_SPEED_HIGH)
+ out_nak_enh = 1;
+
+ hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
+ hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
+ hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nak);
+ disable_hc_int(_hc_regs,nyet);
+
+ if(hcint.b.xfercomp )
+ {
+ _urbd->error_count=0;
+ _ifxhc->split=1;
+ #if 0
+ if(_ifxhc->xfer_len==0 && !hcint.b.ack && (hcint.b.nak || hcint.b.nyet))
+ {
+ // Walkaround: When sending ZLP and receive NYEY or NAK but also issue CMPT intr
+ // Solution: NoSplit: Resend at next SOF
+ // Split : Resend at next SOF with SSPLIT
+ _ifxhc->xfer_len = 0;
+ _ifxhc->xfer_count = 0;
+ _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ else
+ #endif
+ {
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ return 1;
+ }
+ else if(hcint.b.nak )
+ {
+ _ifxhc->split = 1;
+ _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
+ _ifxhc->xfer_count = _urbd->urb->actual_length;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.nyet)
+ {
+ //Retry Complete Split
+ // Issue Retry instantly on next SOF, without gothrough process_channels
+ _urbd->error_count=0;
+ _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.stall )
+ {
+ _urbd->error_count=0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_STALL);
+ return 1;
+ }
+ else if(hcint.b.xacterr )
+ {
+ _urbd->error_count++;
+ if(_urbd->error_count>=3)
+ {
+ _urbd->error_count=0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ }
+ else
+ {
+ _ifxhc->split=1;
+ _ifxhc->epqh->do_ping=1;
+ _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
+ _ifxhc->xfer_count = _urbd->urb->actual_length;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ return 1;
+ }
+ else if(hcint.b.datatglerr )
+ {
+ if(_ifxhc->data_pid_start == IFXUSB_HC_PID_DATA0)
+ _ifxhc->data_pid_start = IFXUSB_HC_PID_DATA1;
+ else
+ _ifxhc->data_pid_start = IFXUSB_HC_PID_DATA0;
+ _ifxhc->split=1;
+ _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
+ _ifxhc->xfer_count = _urbd->urb->actual_length;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.frmovrun )
+ {
+ _urbd->error_count=0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_FRAME_OVERRUN);
+ return 1;
+ }
+ else if(hcint.b.bblerr )
+ {
+ _urbd->error_count=0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_BABBLE_ERR);
+ return 1;
+ }
+ return 0;
+}
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+static int32_t chhltd_intr_rx_csplit(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ hcint_data_t hcint;
+ hcint_data_t hcintmsk;
+ hctsiz_data_t hctsiz;
+
+ hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
+ hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
+ hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nak);
+ disable_hc_int(_hc_regs,nyet);
+
+ if (hcint.b.xfercomp )
+ {
+ _urbd->error_count=0;
+ _ifxhc->split=1;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ return 1;
+ }
+ else if(hcint.b.nak )
+ {
+ _ifxhc->split = 1;
+ _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
+ _ifxhc->xfer_count = _urbd->urb->actual_length;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.nyet)
+ {
+ _urbd->error_count=0;
+ _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.frmovrun || hcint.b.bblerr || hcint.b.stall )
+ {
+ _urbd->error_count=0;
+ if (hcint.b.stall)
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_STALL);
+ else if(hcint.b.bblerr )
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_BABBLE_ERR);
+ else if(hcint.b.frmovrun )
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_FRAME_OVERRUN);
+ return 1;
+ }
+ else if(hcint.b.xacterr )
+ {
+ hcchar_data_t hcchar;
+ hcchar.d32 = ifxusb_rreg(&_hc_regs->hcchar);
+ _urbd->error_count=hcchar.b.multicnt;
+ if(_urbd->error_count>=3)
+ {
+ _urbd->error_count=0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ }
+ else
+ {
+ _ifxhc->split=1;
+ _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
+ _ifxhc->xfer_count = _urbd->urb->actual_length;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ return 1;
+ }
+ else if(hcint.b.datatglerr )
+ {
+ if(_ifxhc->data_pid_start == IFXUSB_HC_PID_DATA0)
+ _ifxhc->data_pid_start = IFXUSB_HC_PID_DATA1;
+ else
+ _ifxhc->data_pid_start = IFXUSB_HC_PID_DATA0;
+ _ifxhc->split=1;
+ _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
+ _ifxhc->xfer_count = _urbd->urb->actual_length;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ return 0;
+}
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+static int32_t chhltd_intr_tx_csplit(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ hcint_data_t hcint;
+ hcint_data_t hcintmsk;
+ hctsiz_data_t hctsiz;
+ int out_nak_enh = 0;
+
+ if (_ifxhcd->core_if.snpsid >= 0x4f54271a && _ifxhc->speed == IFXUSB_EP_SPEED_HIGH)
+ out_nak_enh = 1;
+
+ hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
+ hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
+ hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nak);
+ disable_hc_int(_hc_regs,nyet);
+
+ if(hcint.b.xfercomp )
+ {
+ _urbd->error_count=0;
+ _ifxhc->split=1;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ return 1;
+ }
+ else if(hcint.b.nak )
+ {
+ _ifxhc->split = 1;
+ _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
+ _ifxhc->xfer_count = _urbd->urb->actual_length;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.nyet)
+ {
+ _urbd->error_count=0;
+ _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.stall || hcint.b.frmovrun)
+ {
+ _urbd->error_count=0;
+ if (hcint.b.stall)
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_STALL);
+ else if(hcint.b.frmovrun )
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_FRAME_OVERRUN);
+ return 1;
+ }
+ else if(hcint.b.xacterr )
+ {
+ hcchar_data_t hcchar;
+ hcchar.d32 = ifxusb_rreg(&_hc_regs->hcchar);
+ _urbd->error_count=hcchar.b.multicnt;
+ if(_urbd->error_count>=3)
+ {
+ _urbd->error_count=0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ }
+ else
+ {
+ _ifxhc->split=1;
+ _ifxhc->epqh->do_ping=1;
+ _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
+ _ifxhc->xfer_count = _urbd->urb->actual_length;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ return 1;
+ }
+ else if(hcint.b.datatglerr )
+ {
+ if(_ifxhc->data_pid_start == IFXUSB_HC_PID_DATA0)
+ _ifxhc->data_pid_start = IFXUSB_HC_PID_DATA1;
+ else
+ _ifxhc->data_pid_start = IFXUSB_HC_PID_DATA0;
+ _ifxhc->split=1;
+ _ifxhc->epqh->do_ping=1;
+ _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
+ _ifxhc->xfer_count = _urbd->urb->actual_length;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.bblerr )
+ {
+ _urbd->error_count=0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_BABBLE_ERR);
+ return 1;
+ }
+ return 0;
+}
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+static int32_t chhltd_isoc_rx_csplit(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ #if defined(__EN_ISOC__) && defined(__EN_ISOC_SPLIT__)
+ hcint_data_t hcint;
+ hcint_data_t hcintmsk;
+ hctsiz_data_t hctsiz;
+
+ hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
+ hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
+ hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
+ if(hcint.b.xfercomp )
+ {
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nak);
+ disable_hc_int(_hc_regs,nyet);
+ _urbd->error_count=0;
+ _ifxhc->split=1;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ return 1;
+ }
+ else if(hcint.b.nak )
+ {
+ Retry Start Split (in next b_interval ¡V 1 uF)
+ }
+ else if(hcint.b.nyet)
+ {
+ //Do Next Complete Split
+ // Issue Retry instantly on next SOF, without gothrough process_channels
+ _urbd->error_count=0;
+ //disable_hc_int(_hc_regs,ack);
+ //disable_hc_int(_hc_regs,nak);
+ //disable_hc_int(_hc_regs,datatglerr);
+ _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.frmovrun || hcint.b.stall || hcint.b.bblerr)
+ {
+ _urbd->error_count=0;
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nyet);
+ disable_hc_int(_hc_regs,nak);
+ _ifxhc->wait_for_sof = 0;
+
+ //if(hctsiz.b.pktcnt==0)
+ //{
+ // complete_channel(_ifxhcd, _ifxhc, _urbd);
+ // return 1;
+ //}
+ //else
+ // _urbd->urb->actual_length += (_ifxhc->xfer_len - hctsiz.b.xfersize);
+ if (hcint.b.stall)
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_STALL);
+ else if(hcint.b.frmovrun )
+ else if(hcint.b.bblerr )
+ return 1;
+ }
+ else if(hcint.b.xacterr )
+ {
+ Rewind Buffer Pointers
+ if (HCCHARn.EC = = 3) // ERR response received
+ {
+ Record ERR error
+ Do Next Start Split (in next frame)
+ }
+ else
+ {
+ De-allocate Channel
+ }
+ }
+ else if(hcint.b.datatglerr )
+ {
+ warning
+ }
+ else if(hcint.b.ack )
+ {
+ warning
+ }
+ #endif
+ return 0;
+}
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+static int32_t chhltd_isoc_tx_csplit(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ #if defined(__EN_ISOC__) && defined(__EN_ISOC_SPLIT__)
+ hcint_data_t hcint;
+ hcint_data_t hcintmsk;
+ hctsiz_data_t hctsiz;
+ int out_nak_enh = 0;
+
+ if (_ifxhcd->core_if.snpsid >= 0x4f54271a && _ifxhc->speed == IFXUSB_EP_SPEED_HIGH)
+ out_nak_enh = 1;
+
+ hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
+ hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
+ hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
+ warning
+ #endif
+ return 0;
+}
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+/*!
+ \fn static int32_t handle_hc_chhltd_intr(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+ \brief This function handles halted interrupts of host channels.
+ \param _ifxhcd Pointer to the sate of HCD structure
+ \param _ifxhc Pointer to host channel descriptor
+ \param _hc_regs Pointer to host channel registers
+ \param _urbd Pointer to URB descriptor
+ \return 0 OK
+ \ingroup IFXUSB_HCD
+ */
+static
+int32_t handle_hc_chhltd_intr(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ IFX_DEBUGPL(DBG_HCD, "--Host Channel %d Interrupt: Channel Halted--\n", _ifxhc->hc_num);
+
+ _ifxhc->phase = HC_STOPPED;
+ if(_ifxhc->epqh)
+ if(_ifxhc->epqh->urbd)
+ _ifxhc->epqh->urbd->phase=URBD_ACTIVE;
+
+ if (_ifxhc->halt_status == HC_XFER_URB_DEQUEUE ||
+ _ifxhc->halt_status == HC_XFER_AHB_ERR) {
+ /*
+ * Just release the channel. A dequeue can happen on a
+ * transfer timeout. In the case of an AHB Error, the channel
+ * was forced to halt because there's no way to gracefully
+ * recover.
+ */
+ if(_ifxhc->epqh)
+ if(_ifxhc->epqh->urbd)
+ _ifxhc->epqh->urbd->phase=URBD_DEQUEUEING;
+ release_channel(_ifxhcd, _ifxhc, _ifxhc->halt_status);
+ return 1;
+ }
+
+ if (_ifxhc->ep_type == IFXUSB_EP_TYPE_CTRL)
+ {
+ if (_ifxhc->split==0)
+ {
+ if(_ifxhc->is_in)
+ return (chhltd_ctrl_rx_nonsplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
+ else
+ return (chhltd_ctrl_tx_nonsplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
+ }
+ else if(_ifxhc->split==1)
+ {
+ if(_ifxhc->is_in)
+ return (chhltd_ctrl_rx_ssplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
+ else
+ return (chhltd_ctrl_tx_ssplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
+ }
+ else if(_ifxhc->split==2)
+ {
+ if(_ifxhc->is_in)
+ return (chhltd_ctrl_rx_csplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
+ else
+ return (chhltd_ctrl_tx_csplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
+ }
+ }
+ else if(_ifxhc->ep_type == IFXUSB_EP_TYPE_BULK)
+ {
+ if (_ifxhc->split==0)
+ {
+ if(_ifxhc->is_in)
+ return (chhltd_bulk_rx_nonsplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
+ else
+ return (chhltd_bulk_tx_nonsplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
+ }
+ else if(_ifxhc->split==1)
+ {
+ if(_ifxhc->is_in)
+ return (chhltd_bulk_rx_ssplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
+ else
+ return (chhltd_bulk_tx_ssplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
+ }
+ else if(_ifxhc->split==2)
+ {
+ if(_ifxhc->is_in)
+ return (chhltd_bulk_rx_csplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
+ else
+ return (chhltd_bulk_tx_csplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
+ }
+ }
+ else if(_ifxhc->ep_type == IFXUSB_EP_TYPE_INTR)
+ {
+ if (_ifxhc->split==0)
+ {
+ if(_ifxhc->is_in)
+ return (chhltd_intr_rx_nonsplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
+ else
+ return (chhltd_intr_tx_nonsplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
+ }
+ else if(_ifxhc->split==1)
+ {
+ if(_ifxhc->is_in)
+ return (chhltd_intr_rx_ssplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
+ else
+ return (chhltd_intr_tx_ssplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
+ }
+ else if(_ifxhc->split==2)
+ {
+ if(_ifxhc->is_in)
+ return (chhltd_intr_rx_csplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
+ else
+ return (chhltd_intr_tx_csplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
+ }
+ }
+ else if(_ifxhc->ep_type == IFXUSB_EP_TYPE_ISOC)
+ {
+ if (_ifxhc->split==0)
+ {
+ if(_ifxhc->is_in)
+ return (chhltd_isoc_rx_nonsplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
+ else
+ return (chhltd_isoc_tx_nonsplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
+ }
+ else if(_ifxhc->split==1)
+ {
+ if(_ifxhc->is_in)
+ return (chhltd_isoc_rx_ssplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
+ else
+ return (chhltd_isoc_tx_ssplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
+ }
+ else if(_ifxhc->split==2)
+ {
+ if(_ifxhc->is_in)
+ return (chhltd_isoc_rx_csplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
+ else
+ return (chhltd_isoc_tx_csplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
+ }
+ }
+ return 0;
+}
+
+/*
+ * Handles a host channel AHB error interrupt. This handler is only called in
+ * DMA mode.
+ */
+static void hc_other_intr_dump(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ #ifdef __DEBUG__
+ hcchar_data_t hcchar;
+ hcsplt_data_t hcsplt;
+ hctsiz_data_t hctsiz;
+ uint32_t hcdma;
+ struct urb *urb = _urbd->urb;
+ hcchar.d32 = ifxusb_rreg(&_hc_regs->hcchar);
+ hcsplt.d32 = ifxusb_rreg(&_hc_regs->hcsplt);
+ hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
+ hcdma = ifxusb_rreg(&_hc_regs->hcdma);
+
+ IFX_ERROR("Channel %d\n", _ifxhc->hc_num);
+ IFX_ERROR(" hcchar 0x%08x, hcsplt 0x%08x\n", hcchar.d32, hcsplt.d32);
+ IFX_ERROR(" hctsiz 0x%08x, hcdma 0x%08x\n", hctsiz.d32, hcdma);
+ IFX_ERROR(" Device address: %d\n", usb_pipedevice(urb->pipe));
+ IFX_ERROR(" Endpoint: %d, %s\n", usb_pipeendpoint(urb->pipe),
+ (usb_pipein(urb->pipe) ? "IN" : "OUT"));
+ IFX_ERROR(" Endpoint type: %s\n",
+ ({char *pipetype;
+ switch (usb_pipetype(urb->pipe)) {
+ case PIPE_CONTROL: pipetype = "CTRL"; break;
+ case PIPE_BULK: pipetype = "BULK"; break;
+ case PIPE_INTERRUPT: pipetype = "INTR"; break;
+ case PIPE_ISOCHRONOUS: pipetype = "ISOC"; break;
+ default: pipetype = "????"; break;
+ }; pipetype;}));
+ IFX_ERROR(" Speed: %s\n",
+ ({char *speed;
+ switch (urb->dev->speed) {
+ case USB_SPEED_HIGH: speed = "HS"; break;
+ case USB_SPEED_FULL: speed = "FS"; break;
+ case USB_SPEED_LOW: speed = "LS"; break;
+ default: speed = "????"; break;
+ }; speed;}));
+ IFX_ERROR(" Max packet size: %d\n",
+ usb_maxpacket(urb->dev, urb->pipe, usb_pipeout(urb->pipe)));
+ IFX_ERROR(" Data buffer length: %d\n", urb->transfer_buffer_length);
+ IFX_ERROR(" Transfer buffer: %p, Transfer DMA: %p\n",
+ urb->transfer_buffer, (void *)urb->transfer_dma);
+ IFX_ERROR(" Setup buffer: %p, Setup DMA: %p\n",
+ urb->setup_packet, (void *)urb->setup_dma);
+ IFX_ERROR(" Interval: %d\n", urb->interval);
+ #endif //__DEBUG__
+}
+
+/*
+ * Handles a host channel ACK interrupt. This interrupt is enabled when
+ * errors occur, and during Start Split transactions.
+ */
+static
+int32_t handle_hc_ack_intr(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ _urbd->error_count=0;
+ _ifxhc->erron = 0;
+
+ disable_hc_int(_hc_regs,nyet);
+
+ #ifdef __NAKSTOP__
+ if(!_ifxhc->stop_on)
+ {
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nak);
+ }
+ #else
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nak);
+ #endif
+ return 1;
+}
+
+/*
+ * Handles a host channel ACK interrupt. This interrupt is enabled when
+ * errors occur, and during Start Split transactions.
+ */
+static
+int32_t handle_hc_nak_intr(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ _urbd->error_count=0;
+ _ifxhc->erron=0;
+ disable_hc_int(_hc_regs,nyet);
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nak);
+ #ifdef __NAKSTOP__
+ if(_ifxhc->stop_on)
+ {
+ hcchar_data_t hcchar;
+ hcchar.d32 = ifxusb_rreg(&_hc_regs->hcchar);
+ if(hcchar.b.chen)
+ {
+ hcchar.b.chdis = 1;
+ _ifxhc->halt_status = HC_XFER_NAK;
+ ifxusb_wreg(&_hc_regs->hcchar, hcchar.d32);
+ }
+ }
+ #endif
+ return 1;
+}
+
+static
+int32_t handle_hc_nyet_intr(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ _urbd->error_count=0;
+ _ifxhc->erron = 0;
+
+ disable_hc_int(_hc_regs,nyet);
+ #ifdef __NAKSTOP__
+ if(!_ifxhc->stop_on)
+ {
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nak);
+ }
+ #else
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nak);
+ #endif
+ return 1;
+}
+
+/*
+ * Handles a host channel AHB error interrupt. This handler is only called in
+ * DMA mode.
+ */
+static int32_t handle_hc_ahberr_intr(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ IFX_DEBUGPL(DBG_HCD, "--Host Channel %d Interrupt: "
+ "AHB Error--\n", _ifxhc->hc_num);
+ hc_other_intr_dump(_ifxhcd,_ifxhc,_hc_regs,_urbd);
+
+ ifxhcd_hc_halt(&_ifxhcd->core_if, _ifxhc, HC_XFER_AHB_ERR);
+ return 1;
+}
+
+/*
+ * Datatoggle
+ */
+static int32_t handle_hc_datatglerr_intr(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ IFX_ERROR( "--Host Channel %d Interrupt: "
+ "DATATOGGLE Error--\n", _ifxhc->hc_num);
+ hc_other_intr_dump(_ifxhcd,_ifxhc,_hc_regs,_urbd);
+ disable_hc_int(_hc_regs,datatglerr);
+ return 1;
+}
+
+
+/*
+ * Interrupts which should not been triggered
+ */
+static int32_t handle_hc_frmovrun_intr(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ IFX_ERROR( "--Host Channel %d Interrupt: "
+ "FrameOverRun Error--\n", _ifxhc->hc_num);
+ hc_other_intr_dump(_ifxhcd,_ifxhc,_hc_regs,_urbd);
+ disable_hc_int(_hc_regs,frmovrun);
+ return 1;
+}
+
+static int32_t handle_hc_bblerr_intr(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ IFX_ERROR( "--Host Channel %d Interrupt: "
+ "BBL Error--\n", _ifxhc->hc_num);
+ hc_other_intr_dump(_ifxhcd,_ifxhc,_hc_regs,_urbd);
+ disable_hc_int(_hc_regs,bblerr);
+ return 1;
+}
+
+static int32_t handle_hc_xacterr_intr(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ IFX_ERROR( "--Host Channel %d Interrupt: "
+ "XACT Error--\n", _ifxhc->hc_num);
+ hc_other_intr_dump(_ifxhcd,_ifxhc,_hc_regs,_urbd);
+ disable_hc_int(_hc_regs,xacterr);
+ return 1;
+}
+
+
+static int32_t handle_hc_stall_intr(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ IFX_ERROR( "--Host Channel %d Interrupt: "
+ "STALL--\n", _ifxhc->hc_num);
+ hc_other_intr_dump(_ifxhcd,_ifxhc,_hc_regs,_urbd);
+ disable_hc_int(_hc_regs,stall);
+ return 1;
+}
+
+static int32_t handle_hc_xfercomp_intr(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ IFX_ERROR( "--Host Channel %d Interrupt: "
+ "XFERCOMP--\n", _ifxhc->hc_num);
+ hc_other_intr_dump(_ifxhcd,_ifxhc,_hc_regs,_urbd);
+ disable_hc_int(_hc_regs,xfercomp);
+ return 1;
+}
+
+/* This interrupt indicates that the specified host channels has a pending
+ * interrupt. There are multiple conditions that can cause each host channel
+ * interrupt. This function determines which conditions have occurred for this
+ * host channel interrupt and handles them appropriately. */
+static int32_t handle_hc_n_intr (ifxhcd_hcd_t *_ifxhcd, uint32_t _num)
+{
+ uint32_t hcintval,hcintmsk;
+ hcint_data_t hcint;
+ ifxhcd_hc_t *ifxhc;
+ ifxusb_hc_regs_t *hc_regs;
+ ifxhcd_urbd_t *urbd;
+
+ int retval = 0;
+
+ IFX_DEBUGPL(DBG_HCDV, "--Host Channel Interrupt--, Channel %d\n", _num);
+
+ ifxhc = &_ifxhcd->ifxhc[_num];
+ hc_regs = _ifxhcd->core_if.hc_regs[_num];
+
+ hcintval = ifxusb_rreg(&hc_regs->hcint);
+ hcintmsk = ifxusb_rreg(&hc_regs->hcintmsk);
+ hcint.d32 = hcintval & hcintmsk;
+ IFX_DEBUGPL(DBG_HCDV, " 0x%08x & 0x%08x = 0x%08x\n",
+ hcintval, hcintmsk, hcint.d32);
+
+ urbd = ifxhc->epqh->urbd;
+
+ if (hcint.b.ahberr)
+ retval |= handle_hc_ahberr_intr(_ifxhcd, ifxhc, hc_regs, urbd);
+ else if (hcint.b.chhltd)
+ retval |= handle_hc_chhltd_intr(_ifxhcd, ifxhc, hc_regs, urbd);
+ else
+ {
+ if (hcint.b.datatglerr)
+ retval |= handle_hc_datatglerr_intr(_ifxhcd, ifxhc, hc_regs, urbd);
+ if (hcint.b.frmovrun)
+ retval |= handle_hc_frmovrun_intr(_ifxhcd, ifxhc, hc_regs, urbd);
+ if (hcint.b.bblerr)
+ retval |= handle_hc_bblerr_intr(_ifxhcd, ifxhc, hc_regs, urbd);
+ if (hcint.b.xacterr)
+ retval |= handle_hc_xacterr_intr(_ifxhcd, ifxhc, hc_regs, urbd);
+ if (hcint.b.nyet)
+ retval |= handle_hc_nyet_intr(_ifxhcd, ifxhc, hc_regs, urbd);
+ if (hcint.b.ack)
+ retval |= handle_hc_ack_intr(_ifxhcd, ifxhc, hc_regs, urbd);
+ if (hcint.b.nak)
+ retval |= handle_hc_nak_intr(_ifxhcd, ifxhc, hc_regs, urbd);
+ if (hcint.b.stall)
+ retval |= handle_hc_stall_intr(_ifxhcd, ifxhc, hc_regs, urbd);
+ if (hcint.b.xfercomp)
+ retval |= handle_hc_xfercomp_intr(_ifxhcd, ifxhc, hc_regs, urbd);
+ }
+
+ ifxusb_wreg(&hc_regs->hcint,hcintval);
+
+ return retval;
+}
+
+
+static uint8_t update_interval_counter(ifxhcd_epqh_t *_epqh,uint32_t _diff)
+{
+ if(_diff>=_epqh->period_counter)
+ {
+ _epqh->period_do=1;
+ if(_diff>_epqh->interval)
+ _epqh->period_counter=1;
+ else
+ _epqh->period_counter=_epqh->period_counter+_epqh->interval-_diff;
+ return 1;
+ }
+ _epqh->period_counter=_epqh->period_counter-_diff;
+ return 0;
+}
+
+static
+void process_unaligned( ifxhcd_epqh_t *_epqh, ifxusb_core_if_t *_core_if)
+{
+ ifxhcd_urbd_t *urbd;
+ urbd =_epqh->urbd;
+
+ #if defined(__UNALIGNED_BUF_ADJ__) || defined(__UNALIGNED_BUF_CHK__)
+ if(!urbd->aligned_checked)
+ {
+ #if defined(__UNALIGNED_BUF_ADJ__)
+ uint32_t xfer_len;
+ xfer_len=urbd->xfer_len;
+ if(urbd->is_in && xfer_len<_epqh->mps)
+ xfer_len = _epqh->mps;
+// urbd->using_aligned_buf=0;
+
+ if(xfer_len > 0 && ((unsigned long)urbd->xfer_buff) & _core_if->unaligned_mask)
+ {
+ if( urbd->aligned_buf
+ && urbd->aligned_buf_len > 0
+ && urbd->aligned_buf_len < xfer_len
+ )
+ {
+ ifxusb_free_buf_h(urbd->aligned_buf);
+ urbd->aligned_buf=NULL;
+ urbd->aligned_buf_len=0;
+ }
+ if(! urbd->aligned_buf || ! urbd->aligned_buf_len)
+ {
+ urbd->aligned_buf = ifxusb_alloc_buf_h(xfer_len, urbd->is_in);
+ if(urbd->aligned_buf)
+ urbd->aligned_buf_len = xfer_len;
+ }
+ if(urbd->aligned_buf)
+ {
+ if(!urbd->is_in)
+ memcpy(urbd->aligned_buf, urbd->xfer_buff, xfer_len);
+// urbd->using_aligned_buf=1;
+ _epqh->hc->xfer_buff = urbd->aligned_buf;
+ }
+ else
+ IFX_WARN("%s():%d\n",__func__,__LINE__);
+ }
+ if(_epqh->ep_type==IFXUSB_EP_TYPE_CTRL)
+ {
+// urbd->using_aligned_setup=0;
+ if(((unsigned long)urbd->setup_buff) & _core_if->unaligned_mask)
+ {
+ if(! urbd->aligned_setup)
+ urbd->aligned_setup = ifxusb_alloc_buf_h(8,0);
+ if(urbd->aligned_setup)
+ {
+ memcpy(urbd->aligned_setup, urbd->setup_buff, 8);
+// urbd->using_aligned_setup=1;
+ }
+ else
+ IFX_WARN("%s():%d\n",__func__,__LINE__);
+ _epqh->hc->xfer_buff = urbd->aligned_setup;
+ }
+ }
+ #elif defined(__UNALIGNED_BUF_CHK__)
+ if(_epqh->urbd->is_in)
+ {
+ if(_epqh->urbd->xfer_len==0)
+ IFX_WARN("%s():%d IN xfer while length is zero \n",__func__,__LINE__);
+ else{
+ if(_epqh->urbd->xfer_len < _epqh->mps)
+ IFX_WARN("%s():%d IN xfer while length < mps \n",__func__,__LINE__);
+ if(((unsigned long)_epqh->urbd->xfer_buff) & _core_if->unaligned_mask)
+ IFX_WARN("%s():%d IN xfer Buffer UNALIGNED\n",__func__,__LINE__);
+ }
+ }
+ else
+ {
+ if(_epqh->urbd->xfer_len > 0 && (((unsigned long)_epqh->urbd->xfer_buff) & _core_if->unaligned_mask))
+ IFX_WARN("%s():%d OUT xfer Buffer UNALIGNED\n",__func__,__LINE__);
+ }
+ if(_epqh->ep_type==IFXUSB_EP_TYPE_CTRL)
+ {
+ if(((unsigned long)_epqh->urbd->setup_buff) & _core_if->unaligned_mask)
+ IFX_WARN("%s():%d SETUP xfer Buffer UNALIGNED\n",__func__,__LINE__);
+ }
+ #endif
+ }
+ urbd->aligned_checked=1;
+ #endif
+}
+
+/*!
+ \brief Assigns transactions from a URBD to a free host channel and initializes the
+ host channel to perform the transactions. The host channel is removed from
+ the free list.
+ \param _ifxhcd The HCD state structure.
+ \param _epqh Transactions from the first URBD for this EPQH are selected and assigned to a free host channel.
+ */
+static
+int assign_hc(ifxhcd_hcd_t *_ifxhcd, ifxhcd_epqh_t *_epqh,ifxhcd_urbd_t *_urbd)
+{
+ ifxhcd_hc_t *ifxhc;
+ struct urb *urb;
+
+ IFX_DEBUGPL(DBG_HCDV, "%s(%p,%p)\n", __func__, _ifxhcd, _epqh);
+
+ if(_ifxhcd->disconnecting)
+ {
+ printk(KERN_INFO "Warning: %s() Port is in discoonection\n",__func__);
+ return 0;
+ }
+
+ if(!_epqh) return 0;
+ if(!_urbd) return 0;
+ if(!_urbd->urb) return 0;
+
+ {
+ int i;
+ int num_channels = _ifxhcd->core_if.params.host_channels;
+ for(i=0;i<num_channels ; i++)
+ {
+ hcchar_data_t hcchar;
+ ifxusb_hc_regs_t *hc_regs;
+ hc_regs = _ifxhcd->core_if.hc_regs[i];
+ if(_ifxhcd->ifxhc[i].phase!=HC_IDLE)
+ {
+ continue;
+ }
+ hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
+ if(hcchar.b.chen || hcchar.b.chdis)
+ {
+ continue;
+ }
+ break;
+ }
+
+ if(i<num_channels)
+ {
+ ifxhc=&_ifxhcd->ifxhc[i];
+ ifxhc->phase=HC_ASSIGNED;
+ }
+ else
+ return 0;
+ }
+
+ urb = _urbd->urb;
+ _epqh->hc = ifxhc;
+ _epqh->urbd = _urbd;
+ ifxhc->epqh = _epqh;
+ /*
+ * Use usb_pipedevice to determine device address. This address is
+ * 0 before the SET_ADDRESS command and the correct address afterward.
+ */
+ ifxhc->dev_addr = usb_pipedevice(urb->pipe);
+ ifxhc->ep_num = usb_pipeendpoint(urb->pipe);
+
+ if (urb->dev->speed == USB_SPEED_LOW) ifxhc->speed = IFXUSB_EP_SPEED_LOW;
+ else if (urb->dev->speed == USB_SPEED_FULL) ifxhc->speed = IFXUSB_EP_SPEED_FULL;
+ else ifxhc->speed = IFXUSB_EP_SPEED_HIGH;
+
+ ifxhc->mps = _epqh->mps;
+ ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
+ ifxhc->ep_type = _epqh->ep_type;
+
+ ifxhc->split = 0;
+ if (_epqh->need_split)
+ {
+ ifxhc->split = 1;
+ ifxhc->hub_addr = urb->dev->tt->hub->devnum;
+ ifxhc->port_addr = urb->dev->ttport;
+ }
+ return 1;
+}
+
+/*!
+ \brief Assigns transactions from a URBD to a free host channel and initializes the
+ host channel to perform the transactions. The host channel is removed from
+ the free list.
+ \param _ifxhcd The HCD state structure.
+ \param _epqh Transactions from the first URBD for this EPQH are selected and assigned to a free host channel.
+ */
+static
+void init_hc(ifxhcd_epqh_t *_epqh)
+{
+ ifxhcd_hc_t *ifxhc;
+ ifxhcd_urbd_t *urbd;
+ struct urb *urb;
+ ifxhcd_hcd_t *ifxhcd;
+
+ IFX_DEBUGPL(DBG_HCDV, "%s(%p)\n", __func__, _epqh);
+
+ ifxhc =_epqh->hc;
+ urbd =_epqh->urbd;
+ ifxhcd=_epqh->ifxhcd;
+ urb = urbd->urb;
+ #if defined(__UNALIGNED_BUF_ADJ__) || defined(__UNALIGNED_BUF_CHK__)
+ urbd->aligned_checked=0;
+ #endif
+
+ ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
+
+ if(_epqh->ep_type==IFXUSB_EP_TYPE_CTRL)
+ {
+ ifxhc->control_phase =IFXHCD_CONTROL_SETUP;
+ ifxhc->is_in = 0;
+ ifxhc->data_pid_start = IFXUSB_HC_PID_SETUP;
+ ifxhc->xfer_buff = urbd->setup_buff;
+ ifxhc->xfer_len = 8;
+ ifxhc->xfer_count = 0;
+ ifxhc->short_rw =(urb->transfer_flags & URB_ZERO_PACKET)?1:0;
+ ifxhc->sof_delay = 0;
+ _epqh->do_ping=0;
+ if(!ifxhc->is_in && ifxhc->split==0)
+ _epqh->do_ping=1;
+ }
+ else if(_epqh->ep_type==IFXUSB_EP_TYPE_ISOC)
+ {
+ #ifdef __EN_ISOC__
+ struct usb_iso_packet_descriptor *frame_desc;
+ ifxhc->is_in = urbd->is_in;
+ frame_desc = &urb->iso_frame_desc[urbd->isoc_frame_index];
+ urbd->xfer_len = ifxhc->xfer_len = frame_desc->length;
+ ifxhc->xfer_buff = urbd->xfer_buff;
+ ifxhc->xfer_buff += frame_desc->offset;
+ ifxhc->xfer_count = 0;
+ ifxhc->sof_delay = 0;
+ if(usb_gettoggle (urb->dev,usb_pipeendpoint (urb->pipe), (ifxhc->is_in)?0:1))
+ ifxhc->data_pid_start = IFXUSB_HCTSIZ_DATA1;
+ else
+ ifxhc->data_pid_start = IFXUSB_HCTSIZ_DATA0;
+
+ if(ifxhc->is_in)
+ ifxhc->short_rw =0;
+ else
+ ifxhc->short_rw =(urb->transfer_flags & URB_ZERO_PACKET)?1:0;
+ #ifdef __EN_ISOC_SPLIT__
+ ifxhc->isoc_xact_pos = IFXUSB_HCSPLIT_XACTPOS_ALL;
+ #endif
+
+ _epqh->isoc_frame_index=0;
+ _epqh->isoc_now=0;
+ _epqh->isoc_start_frame=0;
+ if(_urb->transfer_flags && URB_ISO_ASAP)
+ _epqh->isoc_now=1;
+ else
+ _epqh->isoc_start_frame=_urb->start_frame;
+ #ifdef __EN_ISOC_SPLIT__
+ _epqh->isoc_split_pos =0;
+ _epqh->isoc_split_offset=0;
+ #endif
+ _epqh->do_ping=0;
+ #endif
+ }
+ else
+ {
+ ifxhc->is_in = urbd->is_in;
+ ifxhc->xfer_buff = urbd->xfer_buff;
+ ifxhc->xfer_len = urbd->xfer_len;
+ ifxhc->xfer_count = 0;
+ ifxhc->sof_delay = 0;
+// if(ifxhc->xfer_len==13 && ifxhc->is_in && _epqh->ep_type==IFXUSB_EP_TYPE_BULK && ifxhc->split==0)
+// ifxhc->sof_delay = 8;
+ if(usb_gettoggle (urb->dev,usb_pipeendpoint (urb->pipe), (ifxhc->is_in)?0:1))
+ ifxhc->data_pid_start = IFXUSB_HCTSIZ_DATA1;
+ else
+ ifxhc->data_pid_start = IFXUSB_HCTSIZ_DATA0;
+ if(ifxhc->is_in)
+ ifxhc->short_rw =0;
+ else
+ ifxhc->short_rw =(urb->transfer_flags & URB_ZERO_PACKET)?1:0;
+ _epqh->do_ping=0;
+ if(!ifxhc->is_in && ifxhc->split==0)
+ {
+ if(_epqh->ep_type==IFXUSB_EP_TYPE_BULK) _epqh->do_ping=1;
+ }
+ }
+
+ {
+ hcint_data_t hc_intr_mask;
+ uint8_t hc_num = ifxhc->hc_num;
+ ifxusb_hc_regs_t *hc_regs = ifxhcd->core_if.hc_regs[hc_num];
+
+ /* Clear old interrupt conditions for this host channel. */
+ hc_intr_mask.d32 = 0xFFFFFFFF;
+ hc_intr_mask.b.reserved = 0;
+ ifxusb_wreg(&hc_regs->hcint, hc_intr_mask.d32);
+
+ /* Enable channel interrupts required for this transfer. */
+ hc_intr_mask.d32 = 0;
+ hc_intr_mask.b.chhltd = 1;
+ hc_intr_mask.b.ahberr = 1;
+
+ ifxusb_wreg(&hc_regs->hcintmsk, hc_intr_mask.d32);
+
+ /* Enable the top level host channel interrupt. */
+ {
+ uint32_t intr_enable;
+ intr_enable = (1 << hc_num);
+ ifxusb_mreg(&ifxhcd->core_if.host_global_regs->haintmsk, 0, intr_enable);
+ }
+
+ /* Make sure host channel interrupts are enabled. */
+ {
+ gint_data_t gintmsk ={.d32 = 0};
+ gintmsk.b.hcintr = 1;
+ ifxusb_mreg(&ifxhcd->core_if.core_global_regs->gintmsk, 0, gintmsk.d32);
+ }
+
+ /*
+ * Program the HCCHARn register with the endpoint characteristics for
+ * the current transfer.
+ */
+ {
+ hcchar_data_t hcchar;
+
+ hcchar.d32 = 0;
+ hcchar.b.devaddr = ifxhc->dev_addr;
+ hcchar.b.epnum = ifxhc->ep_num;
+ hcchar.b.lspddev = (ifxhc->speed == IFXUSB_EP_SPEED_LOW);
+ hcchar.b.eptype = ifxhc->ep_type;
+ hcchar.b.mps = ifxhc->mps;
+ ifxusb_wreg(&hc_regs->hcchar, hcchar.d32);
+
+ IFX_DEBUGPL(DBG_HCDV, "%s: Channel %d\n", __func__, ifxhc->hc_num);
+ IFX_DEBUGPL(DBG_HCDV, " Dev Addr: %d\n" , hcchar.b.devaddr);
+ IFX_DEBUGPL(DBG_HCDV, " Ep Num: %d\n" , hcchar.b.epnum);
+ IFX_DEBUGPL(DBG_HCDV, " Is Low Speed: %d\n", hcchar.b.lspddev);
+ IFX_DEBUGPL(DBG_HCDV, " Ep Type: %d\n" , hcchar.b.eptype);
+ IFX_DEBUGPL(DBG_HCDV, " Max Pkt: %d\n" , hcchar.b.mps);
+ IFX_DEBUGPL(DBG_HCDV, " Multi Cnt: %d\n" , hcchar.b.multicnt);
+ }
+ /* Program the HCSPLIT register for SPLITs */
+ {
+ hcsplt_data_t hcsplt;
+
+ hcsplt.d32 = 0;
+ if (ifxhc->split)
+ {
+ IFX_DEBUGPL(DBG_HCDV, "Programming HC %d with split --> %s\n", ifxhc->hc_num,
+ (ifxhc->split==2) ? "CSPLIT" : "SSPLIT");
+ hcsplt.b.spltena = 1;
+ hcsplt.b.compsplt = (ifxhc->split==2);
+ #if defined(__EN_ISOC__) && defined(__EN_ISOC_SPLIT__)
+ if(_epqh->ep_type==IFXUSB_EP_TYPE_ISOC)
+ hcsplt.b.xactpos = ifxhc->isoc_xact_pos;
+ else
+ #endif
+ hcsplt.b.xactpos = IFXUSB_HCSPLIT_XACTPOS_ALL;
+ hcsplt.b.hubaddr = ifxhc->hub_addr;
+ hcsplt.b.prtaddr = ifxhc->port_addr;
+ IFX_DEBUGPL(DBG_HCDV, " comp split %d\n" , hcsplt.b.compsplt);
+ IFX_DEBUGPL(DBG_HCDV, " xact pos %d\n" , hcsplt.b.xactpos);
+ IFX_DEBUGPL(DBG_HCDV, " hub addr %d\n" , hcsplt.b.hubaddr);
+ IFX_DEBUGPL(DBG_HCDV, " port addr %d\n" , hcsplt.b.prtaddr);
+ IFX_DEBUGPL(DBG_HCDV, " is_in %d\n" , ifxhc->is_in);
+ IFX_DEBUGPL(DBG_HCDV, " Max Pkt: %d\n" , ifxhc->mps);
+ IFX_DEBUGPL(DBG_HCDV, " xferlen: %d\n" , ifxhc->xfer_len);
+ }
+ ifxusb_wreg(&hc_regs->hcsplt, hcsplt.d32);
+ }
+ }
+ process_unaligned(_epqh,&ifxhcd->core_if);
+
+
+ #ifdef __NAKSTOP__
+ ifxhc->stop_on=0;
+ if (!ifxhc->split && ifxhc->ep_type == IFXUSB_EP_TYPE_BULK)
+ {
+ #ifdef __INNAKSTOP_BULK__
+ if(ifxhc->is_in)
+ ifxhc->stop_on=1;
+ #endif
+ #ifdef __PINGSTOP_BULK__
+ if(!ifxhc->is_in)
+ ifxhc->stop_on=1;
+ #endif
+ }
+ #endif
+}
+
+
+static
+void select_eps_sub(ifxhcd_hcd_t *_ifxhcd)
+{
+ struct list_head *epqh_ptr;
+ ifxhcd_epqh_t *epqh;
+ struct list_head *urbd_ptr;
+ unsigned long flags;
+ ifxhcd_urbd_t *urbd;
+
+ hfnum_data_t hfnum;
+ uint32_t fndiff;
+
+ if(_ifxhcd->disconnecting)
+ {
+// printk(KERN_INFO "Warning: %s() Port is in discoonection\n",__func__);
+ return ;
+ }
+
+ local_irq_save(flags);
+ LOCK_EPQH_LIST(_ifxhcd);
+
+ hfnum.d32 = ifxusb_rreg(&_ifxhcd->core_if.host_global_regs->hfnum);
+ fndiff = hfnum.b.frnum;
+ fndiff+= 0x00004000;
+ fndiff-= _ifxhcd->lastframe ;
+ fndiff&= 0x00003FFF;
+ if(!fndiff) fndiff =1;
+
+ #ifdef __EN_ISOC__
+ epqh_ptr = _ifxhcd->epqh_list_isoc.next;
+ while (epqh_ptr != &_ifxhcd->epqh_list_isoc)
+ {
+ epqh = list_entry(epqh_ptr, ifxhcd_epqh_t, ql);
+ epqh_ptr = epqh_ptr->next;
+
+ #ifdef __DYN_SOF_INTR__
+ if (!list_empty(&epqh->urbd_list))
+ _ifxhcd->dyn_sof_count = DYN_SOF_COUNT_DEF;
+ #endif
+
+ if(epqh->pause)
+ continue;
+ if(epqh->phase==EPQH_READY)
+ {
+ if(update_interval_counter(epqh,fndiff) || epqh->isoc_now)
+ {
+ LOCK_URBD_LIST(epqh);
+ urbd_ptr = epqh->urbd_list.next;
+ while (urbd_ptr != &epqh->urbd_list)
+ {
+ urbd = list_entry(urbd_ptr, ifxhcd_urbd_t, ql);
+ urbd_ptr=urbd_ptr->next;
+ if(urbd->phase==URBD_IDLE)
+ {
+ if(assign_hc(_ifxhcd, epqh,urbd))
+ {
+ IFX_DEBUGPL(DBG_HCD, " select_eps ISOC\n");
+ #ifdef __EPQD_DESTROY_TIMEOUT__
+ del_timer(&epqh->destroy_timer);
+ #endif
+ epqh->isoc_now=0;
+ list_del_init (&epqh->ql);
+ list_add_tail(&epqh->ql, &_ifxhcd->epqh_list_isoc);
+ init_hc(epqh);
+ epqh->phase=EPQH_ACTIVE;
+ urbd->phase==URBD_ACTIVE;
+ epqh->hc.phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, epqh->hc);
+ }
+ break;
+ }
+ }
+ UNLOCK_URBD_LIST(epqh);
+ }
+ }
+ }
+ #endif //__EN_ISOC__
+
+ epqh_ptr = _ifxhcd->epqh_list_intr.next;
+ while (epqh_ptr != &_ifxhcd->epqh_list_intr)
+ {
+ epqh = list_entry(epqh_ptr, ifxhcd_epqh_t, ql);
+ epqh_ptr = epqh_ptr->next;
+ #ifdef __DYN_SOF_INTR__
+ if (!list_empty(&epqh->urbd_list))
+ _ifxhcd->dyn_sof_count = DYN_SOF_COUNT_DEF;
+ #endif
+ if(epqh->pause)
+ continue;
+ if(epqh->phase==EPQH_READY)
+ {
+ if(update_interval_counter(epqh,fndiff))
+ {
+ LOCK_URBD_LIST(epqh);
+ urbd_ptr = epqh->urbd_list.next;
+ while (urbd_ptr != &epqh->urbd_list)
+ {
+ urbd = list_entry(urbd_ptr, ifxhcd_urbd_t, ql);
+ urbd_ptr=urbd_ptr->next;
+ if(urbd->phase==URBD_IDLE)
+ {
+ if(assign_hc(_ifxhcd, epqh,urbd))
+ {
+ IFX_DEBUGPL(DBG_HCD, " select_eps INTR\n");
+ #ifdef __EPQD_DESTROY_TIMEOUT__
+ del_timer(&epqh->destroy_timer);
+ #endif
+ list_del_init (&epqh->ql);
+ list_add_tail(&epqh->ql, &_ifxhcd->epqh_list_intr);
+ init_hc(epqh);
+ epqh->phase=EPQH_ACTIVE;
+ urbd->phase=URBD_ACTIVE;
+ epqh->hc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, epqh->hc);
+ }
+ break;
+ }
+ }
+ UNLOCK_URBD_LIST(epqh);
+ }
+ }
+ else if(epqh->phase==EPQH_STDBY)
+ {
+ if(epqh->period_counter > 0 )
+ epqh->period_counter --;
+ if(epqh->period_counter == 0)
+ ifxhcd_epqh_idle_periodic(epqh);
+ update_interval_counter(epqh,fndiff);
+ }
+ else
+ update_interval_counter(epqh,fndiff);
+ }
+
+ epqh_ptr = _ifxhcd->epqh_list_np.next;
+ while (epqh_ptr != &_ifxhcd->epqh_list_np) // may need to preserve at lease one for period
+ {
+ epqh = list_entry(epqh_ptr, ifxhcd_epqh_t, ql);
+ epqh_ptr = epqh_ptr->next;
+ #ifdef __DYN_SOF_INTR__
+ if (!list_empty(&epqh->urbd_list))
+ _ifxhcd->dyn_sof_count = DYN_SOF_COUNT_DEF;
+ #endif
+ if(epqh->pause)
+ continue;
+ if(epqh->phase==EPQH_READY)
+ {
+ LOCK_URBD_LIST(epqh);
+ urbd_ptr = epqh->urbd_list.next;
+ while (urbd_ptr != &epqh->urbd_list)
+ {
+ urbd = list_entry(urbd_ptr, ifxhcd_urbd_t, ql);
+ urbd_ptr=urbd_ptr->next;
+ if(urbd->phase==URBD_IDLE)
+ {
+ if(assign_hc(_ifxhcd, epqh,urbd))
+ {
+ IFX_DEBUGPL(DBG_HCD, " select_eps Non-Period\n");
+ #ifdef __EPQD_DESTROY_TIMEOUT__
+ del_timer(&epqh->destroy_timer);
+ #endif
+ list_del_init (&epqh->ql);
+ list_add_tail(&epqh->ql, &_ifxhcd->epqh_list_np);
+ init_hc(epqh);
+ epqh->phase=EPQH_ACTIVE;
+ urbd->phase=URBD_ACTIVE;
+ epqh->hc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, epqh->hc);
+ }
+ break;
+ }
+ }
+ UNLOCK_URBD_LIST(epqh);
+ }
+ }
+
+ _ifxhcd->lastframe=hfnum.b.frnum;
+
+ UNLOCK_EPQH_LIST(_ifxhcd);
+ local_irq_restore(flags);
+}
+
+static
+void select_eps_func(unsigned long data)
+{
+ ifxhcd_hcd_t *ifxhcd;
+ ifxhcd=((ifxhcd_hcd_t *)data);
+
+ select_eps_sub(ifxhcd);
+}
+
+/*!
+ \fn void select_eps(ifxhcd_hcd_t *_ifxhcd)
+ \brief This function selects transactions from the HCD transfer schedule and assigns them to available host channels.
+ \param _ifxhcd Pointer to the sate of HCD structure
+ \ingroup IFXUSB_HCD
+ */
+void select_eps(ifxhcd_hcd_t *_ifxhcd)
+{
+ if(in_irq())
+ {
+ if(!_ifxhcd->tasklet_select_eps.func)
+ {
+ _ifxhcd->tasklet_select_eps.next = NULL;
+ _ifxhcd->tasklet_select_eps.state = 0;
+ atomic_set( &_ifxhcd->tasklet_select_eps.count, 0);
+ _ifxhcd->tasklet_select_eps.func = select_eps_func;
+ _ifxhcd->tasklet_select_eps.data = (unsigned long)_ifxhcd;
+ }
+ tasklet_schedule(&_ifxhcd->tasklet_select_eps);
+ }
+ else
+ {
+ select_eps_sub(_ifxhcd);
+ }
+}
+
+static
+void ifxhcd_hc_kickstart(ifxhcd_hcd_t *_ifxhcd)
+{
+ int num_channels;
+ ifxusb_hc_regs_t *hc_regs;
+ int i;
+ ifxhcd_hc_t *ifxhc;
+ num_channels = _ifxhcd->core_if.params.host_channels;
+
+ for (i = 0; i < num_channels; i++)
+ {
+ ifxhc=&_ifxhcd->ifxhc[i];
+ if(ifxhc->phase==HC_STARTING)
+ {
+ if(ifxhc->sof_delay) ifxhc->sof_delay--;
+ if(!ifxhc->sof_delay)
+ {
+ hcint_data_t hcint;
+// ifxhc->erron=0;
+ hc_regs = _ifxhcd->core_if.hc_regs[i];
+ hcint.d32 =0xFFFFFFFF;
+ ifxusb_wreg(&hc_regs->hcint, hcint.d32);
+ hcint.d32 =ifxusb_rreg(&hc_regs->hcintmsk);
+ hcint.b.nak =0;
+ hcint.b.ack =0;
+ hcint.b.nyet=0;
+ if(ifxhc->erron)
+ {
+ hcint.b.ack =1;
+ hcint.b.nak =1;
+ hcint.b.nyet =1;
+ }
+ #ifdef __NAKSTOP__
+ if(ifxhc->stop_on)
+ {
+ hcint.b.ack =1;
+ hcint.b.nak =1;
+ }
+ #endif
+ ifxusb_wreg(&hc_regs->hcintmsk, hcint.d32);
+ ifxusb_wreg(&hc_regs->hcchar, ifxhc->hcchar);
+ ifxhc->phase=HC_STARTED;
+ }
+ }
+ }
+
+ for (i = 0; i < num_channels; i++)
+ {
+ ifxhc=&_ifxhcd->ifxhc[i];
+ if(ifxhc->phase==HC_WAITING &&
+ (ifxhc->ep_type == IFXUSB_EP_TYPE_INTR || ifxhc->ep_type == IFXUSB_EP_TYPE_ISOC)
+ )
+ {
+ ifxhcd_hc_start(_ifxhcd, ifxhc);
+ }
+ }
+
+ for (i = 0; i < num_channels; i++)
+ {
+ ifxhc=&_ifxhcd->ifxhc[i];
+ if(ifxhc->phase==HC_WAITING)
+ {
+ ifxhcd_hc_start(_ifxhcd, ifxhc);
+ }
+ }
+}
+
+/*
+ * Handles the start-of-frame interrupt in host mode. Non-periodic
+ * transactions may be queued to the DWC_otg controller for the current
+ * (micro)frame. Periodic transactions may be queued to the controller for the
+ * next (micro)frame.
+ */
+static
+int32_t handle_sof_intr (ifxhcd_hcd_t *_ifxhcd)
+{
+ _ifxhcd->pkt_remaining=_ifxhcd->pkt_remaining_reload;
+ ifxhcd_hc_kickstart(_ifxhcd);
+
+ select_eps(_ifxhcd);
+
+ /* Clear interrupt */
+ {
+ gint_data_t gintsts;
+ gintsts.d32=0;
+ gintsts.b.sofintr = 1;
+ ifxusb_wreg(&_ifxhcd->core_if.core_global_regs->gintsts, gintsts.d32);
+
+ #ifdef __DYN_SOF_INTR__
+ if(_ifxhcd->dyn_sof_count)
+ _ifxhcd->dyn_sof_count--;
+ if(!_ifxhcd->dyn_sof_count)
+ ifxusb_mreg(&_ifxhcd->core_if.core_global_regs->gintmsk, gintsts.d32,0);
+ #endif
+ }
+ return 1;
+}
+
+
+
+/* There are multiple conditions that can cause a port interrupt. This function
+ * determines which interrupt conditions have occurred and handles them
+ * appropriately. */
+static int32_t handle_port_intr (ifxhcd_hcd_t *_ifxhcd)
+{
+ int retval = 0;
+ hprt0_data_t hprt0;
+ hprt0_data_t hprt0_modify;
+
+ hprt0.d32 =
+ hprt0_modify.d32 = ifxusb_rreg(_ifxhcd->core_if.hprt0);
+
+ /* Clear appropriate bits in HPRT0 to clear the interrupt bit in
+ * GINTSTS */
+
+ hprt0_modify.b.prtena = 0;
+ hprt0_modify.b.prtconndet = 0;
+ hprt0_modify.b.prtenchng = 0;
+ hprt0_modify.b.prtovrcurrchng = 0;
+
+ /* Port Connect Detected
+ * Set flag and clear if detected */
+ if (hprt0.b.prtconndet) {
+ IFX_DEBUGPL(DBG_HCD, "--Port Interrupt HPRT0=0x%08x "
+ "Port Connect Detected--\n", hprt0.d32);
+ _ifxhcd->flags.b.port_connect_status_change = 1;
+ _ifxhcd->flags.b.port_connect_status = 1;
+ hprt0_modify.b.prtconndet = 1;
+
+ /* The Hub driver asserts a reset when it sees port connect
+ * status change flag */
+ retval |= 1;
+ }
+
+ /* Port Enable Changed
+ * Clear if detected - Set internal flag if disabled */
+ if (hprt0.b.prtenchng) {
+ IFX_DEBUGPL(DBG_HCD, " --Port Interrupt HPRT0=0x%08x "
+ "Port Enable Changed--\n", hprt0.d32);
+ hprt0_modify.b.prtenchng = 1;
+ if (hprt0.b.prtena == 1)
+ {
+ /* Port has been enabled set the reset change flag */
+ _ifxhcd->flags.b.port_reset_change = 1;
+ if (hprt0.b.prtspd == IFXUSB_HPRT0_PRTSPD_HIGH_SPEED)
+ _ifxhcd->pkt_remaining_reload=_ifxhcd->pkt_remaining_reload_hs;
+ else if (hprt0.b.prtspd == IFXUSB_HPRT0_PRTSPD_LOW_SPEED)
+ _ifxhcd->pkt_remaining_reload=_ifxhcd->pkt_remaining_reload_ls;
+ else
+ _ifxhcd->pkt_remaining_reload=_ifxhcd->pkt_remaining_reload_fs;
+ }
+ else
+ _ifxhcd->flags.b.port_enable_change = 1;
+ retval |= 1;
+ }
+
+ /* Overcurrent Change Interrupt */
+
+ if (hprt0.b.prtovrcurrchng) {
+ IFX_DEBUGPL(DBG_HCD, " --Port Interrupt HPRT0=0x%08x "
+ "Port Overcurrent Changed--\n", hprt0.d32);
+ _ifxhcd->flags.b.port_over_current_change = 1;
+ hprt0_modify.b.prtovrcurrchng = 1;
+ retval |= 1;
+ }
+
+ /* Clear Port Interrupts */
+ ifxusb_wreg(_ifxhcd->core_if.hprt0, hprt0_modify.d32);
+ return retval;
+}
+
+/*
+ * This interrupt indicates that SUSPEND state has been detected on
+ * the USB.
+ * No Functioning in Host Mode
+ */
+static int32_t handle_usb_suspend_intr(ifxhcd_hcd_t *_ifxhcd)
+{
+ gint_data_t gintsts;
+ IFX_DEBUGP("USB SUSPEND RECEIVED!\n");
+ /* Clear interrupt */
+ gintsts.d32 = 0;
+ gintsts.b.usbsuspend = 1;
+ ifxusb_wreg(&_ifxhcd->core_if.core_global_regs->gintsts, gintsts.d32);
+ return 1;
+}
+
+/*
+ * This interrupt indicates that the IFXUSB controller has detected a
+ * resume or remote wakeup sequence. If the IFXUSB controller is in
+ * low power mode, the handler must brings the controller out of low
+ * power mode. The controller automatically begins resume
+ * signaling. The handler schedules a time to stop resume signaling.
+ */
+static int32_t handle_wakeup_detected_intr(ifxhcd_hcd_t *_ifxhcd)
+{
+ gint_data_t gintsts;
+ hprt0_data_t hprt0 = {.d32=0};
+ pcgcctl_data_t pcgcctl = {.d32=0};
+ ifxusb_core_if_t *core_if = &_ifxhcd->core_if;
+
+ IFX_DEBUGPL(DBG_ANY, "++Resume and Remote Wakeup Detected Interrupt++\n");
+
+ /*
+ * Clear the Resume after 70ms. (Need 20 ms minimum. Use 70 ms
+ * so that OPT tests pass with all PHYs).
+ */
+ /* Restart the Phy Clock */
+ pcgcctl.b.stoppclk = 1;
+ ifxusb_mreg(core_if->pcgcctl, pcgcctl.d32, 0);
+ UDELAY(10);
+
+ /* Now wait for 70 ms. */
+ hprt0.d32 = ifxusb_read_hprt0( core_if );
+ IFX_DEBUGPL(DBG_ANY,"Resume: HPRT0=%0x\n", hprt0.d32);
+ MDELAY(70);
+ hprt0.b.prtres = 0; /* Resume */
+ ifxusb_wreg(core_if->hprt0, hprt0.d32);
+ IFX_DEBUGPL(DBG_ANY,"Clear Resume: HPRT0=%0x\n", ifxusb_rreg(core_if->hprt0));
+
+ /* Clear interrupt */
+ gintsts.d32 = 0;
+ gintsts.b.wkupintr = 1;
+ ifxusb_wreg(&core_if->core_global_regs->gintsts, gintsts.d32);
+ return 1;
+}
+
+/*
+ * This interrupt indicates that a device is initiating the Session
+ * Request Protocol to request the host to turn on bus power so a new
+ * session can begin. The handler responds by turning on bus power. If
+ * the DWC_otg controller is in low power mode, the handler brings the
+ * controller out of low power mode before turning on bus power.
+ */
+static int32_t handle_session_req_intr(ifxhcd_hcd_t *_ifxhcd)
+{
+ /* Clear interrupt */
+ gint_data_t gintsts = { .d32 = 0 };
+ gintsts.b.sessreqintr = 1;
+ ifxusb_wreg(&_ifxhcd->core_if.core_global_regs->gintsts, gintsts.d32);
+ return 1;
+}
+
+/*
+ * This interrupt indicates that a device has been disconnected from
+ * the root port.
+ */
+static int32_t handle_disconnect_intr(ifxhcd_hcd_t *_ifxhcd)
+{
+ gint_data_t gintsts;
+
+ ifxhcd_disconnect(_ifxhcd);
+
+ gintsts.d32 = 0;
+ gintsts.b.disconnect = 1;
+ ifxusb_wreg(&_ifxhcd->core_if.core_global_regs->gintsts, gintsts.d32);
+ return 1;
+}
+
+/*
+ * This function handles the Connector ID Status Change Interrupt. It
+ * reads the OTG Interrupt Register (GOTCTL) to determine whether this
+ * is a Device to Host Mode transition or a Host Mode to Device
+ * Transition.
+ * This only occurs when the cable is connected/removed from the PHY
+ * connector.
+ */
+static int32_t handle_conn_id_status_change_intr(ifxhcd_hcd_t *_ifxhcd)
+{
+ gint_data_t gintsts;
+
+ IFX_WARN("ID Status Change Interrupt: currently in %s mode\n",
+ ifxusb_mode(&_ifxhcd->core_if) ? "Host" : "Device");
+
+ gintsts.d32 = 0;
+ gintsts.b.conidstschng = 1;
+ ifxusb_wreg(&_ifxhcd->core_if.core_global_regs->gintsts, gintsts.d32);
+ return 1;
+}
+
+static int32_t handle_otg_intr(ifxhcd_hcd_t *_ifxhcd)
+{
+ ifxusb_core_global_regs_t *global_regs = _ifxhcd->core_if.core_global_regs;
+ gotgint_data_t gotgint;
+ gotgint.d32 = ifxusb_rreg( &global_regs->gotgint);
+ /* Clear GOTGINT */
+ ifxusb_wreg (&global_regs->gotgint, gotgint.d32);
+ return 1;
+}
+
+/** This function will log a debug message */
+static int32_t handle_mode_mismatch_intr(ifxhcd_hcd_t *_ifxhcd)
+{
+ gint_data_t gintsts;
+
+ IFX_WARN("Mode Mismatch Interrupt: currently in %s mode\n",
+ ifxusb_mode(&_ifxhcd->core_if) ? "Host" : "Device");
+ gintsts.d32 = 0;
+ gintsts.b.modemismatch = 1;
+ ifxusb_wreg(&_ifxhcd->core_if.core_global_regs->gintsts, gintsts.d32);
+ return 1;
+}
+
+/** This function handles interrupts for the HCD. */
+int32_t ifxhcd_handle_intr (ifxhcd_hcd_t *_ifxhcd)
+{
+ int retval = 0;
+
+ ifxusb_core_if_t *core_if = &_ifxhcd->core_if;
+ gint_data_t gintsts,gintsts2;
+
+ /* Check if HOST Mode */
+ if (ifxusb_is_device_mode(core_if))
+ {
+ IFX_ERROR("%s() CRITICAL! IN DEVICE MODE\n", __func__);
+ return 0;
+ }
+
+ gintsts.d32 = ifxusb_read_core_intr(core_if);
+ gintsts2.d32 = 0;
+
+ if (!gintsts.d32)
+ return 0;
+
+ //Common INT
+ if (gintsts.b.modemismatch)
+ {
+ retval |= handle_mode_mismatch_intr(_ifxhcd);
+ gintsts.b.modemismatch=0;
+ gintsts2.b.modemismatch=1;
+ }
+ if (gintsts.b.otgintr)
+ {
+ retval |= handle_otg_intr(_ifxhcd);
+ gintsts.b.otgintr=0;
+ gintsts2.b.otgintr=1;
+ }
+ if (gintsts.b.conidstschng)
+ {
+ retval |= handle_conn_id_status_change_intr(_ifxhcd);
+ gintsts.b.conidstschng=0;
+ gintsts2.b.conidstschng=1;
+ }
+ if (gintsts.b.disconnect)
+ {
+ retval |= handle_disconnect_intr(_ifxhcd);
+ gintsts.b.disconnect=0;
+ gintsts2.b.disconnect=1;
+ }
+ if (gintsts.b.sessreqintr)
+ {
+ retval |= handle_session_req_intr(_ifxhcd);
+ gintsts.b.sessreqintr=0;
+ gintsts2.b.sessreqintr=1;
+ }
+ if (gintsts.b.wkupintr)
+ {
+ retval |= handle_wakeup_detected_intr(_ifxhcd);
+ gintsts.b.wkupintr=0;
+ gintsts2.b.wkupintr=1;
+ }
+ if (gintsts.b.usbsuspend)
+ {
+ retval |= handle_usb_suspend_intr(_ifxhcd);
+ gintsts.b.usbsuspend=0;
+ gintsts2.b.usbsuspend=1;
+ }
+
+ //Host Int
+ if (gintsts.b.sofintr)
+ {
+ retval |= handle_sof_intr (_ifxhcd);
+ gintsts.b.sofintr=0;
+ gintsts2.b.sofintr=1;
+ }
+ if (gintsts.b.portintr)
+ {
+ retval |= handle_port_intr (_ifxhcd);
+ gintsts.b.portintr=0;
+ gintsts2.b.portintr=1;
+ }
+ if (gintsts.b.hcintr)
+ {
+ int i;
+ haint_data_t haint;
+ haint.d32 = ifxusb_read_host_all_channels_intr(core_if);
+ for (i=0; i<MAX_EPS_CHANNELS && i< core_if->params.host_channels; i++)
+ if (haint.b2.chint & (1 << i))
+ retval |= handle_hc_n_intr (_ifxhcd, i);
+ gintsts.b.hcintr=0;
+ gintsts2.b.hcintr=1;
+ }
+ return retval;
+}
+
diff --git a/package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxhcd_queue.c.svn-base b/package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxhcd_queue.c.svn-base
new file mode 100644
index 0000000..a30fcd0
--- /dev/null
+++ b/package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxhcd_queue.c.svn-base
@@ -0,0 +1,485 @@
+/*****************************************************************************
+ ** FILE NAME : ifxhcd_queue.c
+ ** PROJECT : IFX USB sub-system V3
+ ** MODULES : IFX USB sub-system Host and Device driver
+ ** SRC VERSION : 3.2
+ ** DATE : 1/Jan/2011
+ ** AUTHOR : Chen, Howard
+ ** DESCRIPTION : This file contains the functions to manage Queue Heads and Queue
+ ** Transfer Descriptors.
+ ** FUNCTIONS :
+ ** COMPILER : gcc
+ ** REFERENCE : Synopsys DWC-OTG Driver 2.7
+ ** COPYRIGHT : Copyright (c) 2010
+ ** LANTIQ DEUTSCHLAND GMBH,
+ ** Am Campeon 3, 85579 Neubiberg, Germany
+ **
+ ** 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 of the License, or
+ ** (at your option) any later version.
+ **
+ ** Version Control Section **
+ ** $Author$
+ ** $Date$
+ ** $Revisions$
+ ** $Log$ Revision history
+ *****************************************************************************/
+
+/*
+ * This file contains code fragments from Synopsys HS OTG Linux Software Driver.
+ * For this code the following notice is applicable:
+ *
+ * ==========================================================================
+ *
+ * Synopsys HS OTG Linux Software Driver and documentation (hereinafter,
+ * "Software") is an Unsupported proprietary work of Synopsys, Inc. unless
+ * otherwise expressly agreed to in writing between Synopsys and you.
+ *
+ * The Software IS NOT an item of Licensed Software or Licensed Product under
+ * any End User Software License Agreement or Agreement for Licensed Product
+ * with Synopsys or any supplement thereto. You are permitted to use and
+ * redistribute this Software in source and binary forms, with or without
+ * modification, provided that redistributions of source code must retain this
+ * notice. You may not view, use, disclose, copy or distribute this file or
+ * any information contained herein except pursuant to this license grant from
+ * Synopsys. If you do not agree with this notice, including the disclaimer
+ * below, then you are not authorized to use the Software.
+ *
+ * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" BASIS
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ * ========================================================================== */
+
+/*!
+ \file ifxhcd_queue.c
+ \ingroup IFXUSB_DRIVER_V3
+ \brief This file contains the functions to manage Queue Heads and Queue
+ Transfer Descriptors.
+*/
+#include <linux/version.h>
+#include "ifxusb_version.h"
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/init.h>
+#include <linux/device.h>
+#include <linux/errno.h>
+#include <linux/list.h>
+#include <linux/interrupt.h>
+#include <linux/string.h>
+
+#include "ifxusb_plat.h"
+#include "ifxusb_regs.h"
+#include "ifxusb_cif.h"
+#include "ifxhcd.h"
+
+#ifdef __EPQD_DESTROY_TIMEOUT__
+ #define epqh_self_destroy_timeout 300
+ static void eqph_destroy_func(unsigned long _ptr)
+ {
+ ifxhcd_epqh_t *epqh=(ifxhcd_epqh_t *)_ptr;
+ if(epqh)
+ {
+ if(epqh->sysep)
+ {
+ epqh->sysep->hcpriv=NULL;
+ }
+ ifxhcd_epqh_free (epqh);
+ }
+ }
+#endif
+
+/*!
+ \brief This function allocates and initializes a EPQH.
+
+ \param _ifxhcd The HCD state structure for the USB Host controller.
+ \param[in] _urb Holds the information about the device/endpoint that we need
+ to initialize the EPQH.
+
+ \return Returns pointer to the newly allocated EPQH, or NULL on error.
+ */
+static ifxhcd_epqh_t *ifxhcd_epqh_create (ifxhcd_hcd_t *_ifxhcd, struct urb *_urb)
+{
+ ifxhcd_epqh_t *epqh;
+
+ hprt0_data_t hprt0;
+ struct usb_host_endpoint *sysep = ifxhcd_urb_to_endpoint(_urb);
+
+ /* Allocate memory */
+// epqh=(ifxhcd_epqh_t *) kmalloc (sizeof(ifxhcd_epqh_t), GFP_KERNEL);
+ epqh=(ifxhcd_epqh_t *) kmalloc (sizeof(ifxhcd_epqh_t), GFP_ATOMIC);
+
+ if(epqh == NULL)
+ return NULL;
+
+ memset (epqh, 0, sizeof (ifxhcd_epqh_t));
+
+ epqh->sysep=sysep;
+
+ epqh->devno=_urb->dev->devnum;
+
+ epqh->ifxhcd=_ifxhcd;
+ epqh->phase=EPQH_IDLE;
+
+ /* Initialize EPQH */
+ switch (usb_pipetype(_urb->pipe))
+ {
+ case PIPE_CONTROL : epqh->ep_type = IFXUSB_EP_TYPE_CTRL; break;
+ case PIPE_BULK : epqh->ep_type = IFXUSB_EP_TYPE_BULK; break;
+ case PIPE_ISOCHRONOUS: epqh->ep_type = IFXUSB_EP_TYPE_ISOC; break;
+ case PIPE_INTERRUPT : epqh->ep_type = IFXUSB_EP_TYPE_INTR; break;
+ }
+
+ usb_settoggle(_urb->dev, usb_pipeendpoint (_urb->pipe), !usb_pipein(_urb->pipe), IFXUSB_HC_PID_DATA0);
+ epqh->mps = usb_maxpacket(_urb->dev, _urb->pipe, !(usb_pipein(_urb->pipe)));
+
+ INIT_LIST_HEAD(&epqh->urbd_list);
+ #ifdef __STRICT_ORDER__
+ INIT_LIST_HEAD(&epqh->release_list);
+ #endif
+ INIT_LIST_HEAD(&epqh->ql);
+ INIT_LIST_HEAD(&epqh->ql_all);
+ INIT_URBD_LIST(epqh);
+
+ epqh->hc = NULL;
+
+ /* FS/LS Enpoint on HS Hub
+ * NOT virtual root hub */
+ epqh->need_split = 0;
+ hprt0.d32 = ifxusb_read_hprt0 (&_ifxhcd->core_if);
+ if (hprt0.b.prtspd == IFXUSB_HPRT0_PRTSPD_HIGH_SPEED &&
+ ((_urb->dev->speed == USB_SPEED_LOW) ||
+ (_urb->dev->speed == USB_SPEED_FULL)) &&
+ (_urb->dev->tt) && (_urb->dev->tt->hub) && (_urb->dev->tt->hub->devnum != 1))
+ {
+ IFX_DEBUGPL(DBG_HCD, "QH init: EP %d: TT found at hub addr %d, for port %d\n",
+ usb_pipeendpoint(_urb->pipe), _urb->dev->tt->hub->devnum,
+ _urb->dev->ttport);
+ epqh->need_split = 1;
+ }
+
+ if (epqh->ep_type == IFXUSB_EP_TYPE_INTR ||
+ epqh->ep_type == IFXUSB_EP_TYPE_ISOC)
+ {
+ /* Compute scheduling parameters once and save them. */
+ epqh->interval = _urb->interval;
+ if(epqh->need_split)
+ epqh->interval *= 8;
+ }
+
+ #ifdef __EN_ISOC__
+ if (epqh->ep_type == IFXUSB_EP_TYPE_ISOC)
+ _ifxhcd->isoc_ep_count++;
+ #endif
+
+ epqh->period_counter=0;
+
+ #ifdef __EPQD_DESTROY_TIMEOUT__
+ /* Start a timer for this transfer. */
+ init_timer(&epqh->destroy_timer);
+ epqh->destroy_timer.function = eqph_destroy_func;
+ epqh->destroy_timer.data = (unsigned long)(epqh);
+ #endif
+
+ #ifdef __DEBUG__
+ IFX_DEBUGPL(DBG_HCD , "IFXUSB HCD EPQH Initialized\n");
+ IFX_DEBUGPL(DBG_HCDV, "IFXUSB HCD EPQH - epqh = %p\n", epqh);
+ IFX_DEBUGPL(DBG_HCDV, "IFXUSB HCD EPQH - Device Address = %d EP %d, %s\n",
+ _urb->dev->devnum,
+ usb_pipeendpoint(_urb->pipe),
+ usb_pipein(_urb->pipe) == USB_DIR_IN ? "IN" : "OUT");
+ IFX_DEBUGPL(DBG_HCDV, "IFXUSB HCD EPQH - Speed = %s\n",
+ ({ char *speed; switch (_urb->dev->speed) {
+ case USB_SPEED_LOW: speed = "low" ; break;
+ case USB_SPEED_FULL: speed = "full"; break;
+ case USB_SPEED_HIGH: speed = "high"; break;
+ default: speed = "?"; break;
+ }; speed;}));
+ IFX_DEBUGPL(DBG_HCDV, "IFXUSB HCD EPQH - Type = %s\n",
+ ({
+ char *type; switch (epqh->ep_type)
+ {
+ case IFXUSB_EP_TYPE_ISOC: type = "isochronous"; break;
+ case IFXUSB_EP_TYPE_INTR: type = "interrupt" ; break;
+ case IFXUSB_EP_TYPE_CTRL: type = "control" ; break;
+ case IFXUSB_EP_TYPE_BULK: type = "bulk" ; break;
+ default: type = "?"; break;
+ };
+ type;
+ }));
+ if (epqh->ep_type == IFXUSB_EP_TYPE_INTR)
+ IFX_DEBUGPL(DBG_HCDV, "IFXUSB HCD EPQH - interval = %d\n", epqh->interval);
+ #endif
+
+ LOCK_EPQH_LIST_ALL(_ifxhcd);
+ list_add_tail(&epqh->ql_all, &_ifxhcd->epqh_list_all);
+ UNLOCK_EPQH_LIST_ALL(_ifxhcd);
+
+ LOCK_EPQH_LIST(_ifxhcd);
+ switch (epqh->ep_type)
+ {
+ case IFXUSB_EP_TYPE_CTRL:
+ case IFXUSB_EP_TYPE_BULK:
+
+ list_add_tail(&epqh->ql, &_ifxhcd->epqh_list_np);
+ break;
+ case IFXUSB_EP_TYPE_INTR:
+ list_add_tail(&epqh->ql, &_ifxhcd->epqh_list_intr);
+ break;
+ #ifdef __EN_ISOC__
+ case IFXUSB_EP_TYPE_ISOC:
+ list_add_tail(&epqh->ql, &_ifxhcd->epqh_list_isoc);
+
+ break;
+ #endif
+ }
+ UNLOCK_EPQH_LIST(_ifxhcd);
+ return epqh;
+}
+
+
+
+
+
+
+/*!
+ \brief Free the EPQH. EPQH should already be removed from a list.
+ URBD list should already be empty if called from URB Dequeue.
+
+ \param[in] _epqh The EPQH to free.
+ */
+void ifxhcd_epqh_free (ifxhcd_epqh_t *_epqh)
+{
+ unsigned long flags;
+ if(!_epqh)
+ return;
+
+ if(_epqh->sysep) _epqh->sysep->hcpriv=NULL;
+ _epqh->sysep=NULL;
+
+ local_irq_save (flags);
+ if (!list_empty(&_epqh->urbd_list))
+ IFX_WARN("%s() invalid epqh state\n",__func__);
+ else
+ {
+ LOCK_EPQH_LIST_ALL(_epqh->ifxhcd);
+ if (!list_empty(&_epqh->ql_all))
+ list_del_init (&_epqh->ql_all);
+ UNLOCK_EPQH_LIST_ALL(_epqh->ifxhcd);
+
+ LOCK_EPQH_LIST(_epqh->ifxhcd);
+ if (!list_empty(&_epqh->ql))
+ list_del_init (&_epqh->ql);
+ UNLOCK_EPQH_LIST(_epqh->ifxhcd);
+
+ #ifdef __EPQD_DESTROY_TIMEOUT__
+ del_timer(&_epqh->destroy_timer);
+ #endif
+ kfree (_epqh);
+ }
+ local_irq_restore (flags);
+}
+
+
+void ifxhcd_epqh_idle(ifxhcd_epqh_t *_epqh)
+{
+ unsigned long flags;
+ local_irq_save(flags);
+ LOCK_URBD_LIST(_epqh);
+ if (list_empty(&_epqh->urbd_list))
+ {
+ if(_epqh->ep_type == IFXUSB_EP_TYPE_ISOC || _epqh->ep_type == IFXUSB_EP_TYPE_INTR)
+ _epqh->phase=EPQH_STDBY;
+ else
+ {
+ _epqh->phase=EPQH_IDLE;
+ #ifdef __EPQD_DESTROY_TIMEOUT__
+ del_timer(&_epqh->destroy_timer);
+ _epqh->destroy_timer.expires = jiffies + (HZ*epqh_self_destroy_timeout);
+ add_timer(&_epqh->destroy_timer );
+ #endif
+ }
+ }
+ else
+ {
+ _epqh->phase=EPQH_READY;
+ #ifdef __EPQD_DESTROY_TIMEOUT__
+ del_timer(&_epqh->destroy_timer);
+ #endif
+ }
+ UNLOCK_URBD_LIST(_epqh);
+ local_irq_restore(flags);
+}
+
+
+void ifxhcd_epqh_idle_periodic(ifxhcd_epqh_t *_epqh)
+{
+ unsigned long flags;
+ if(_epqh->ep_type != IFXUSB_EP_TYPE_ISOC && _epqh->ep_type != IFXUSB_EP_TYPE_INTR && _epqh->phase!=EPQH_STDBY)
+ return;
+
+ local_irq_save(flags);
+ LOCK_URBD_LIST(_epqh);
+ if (!list_empty(&_epqh->urbd_list))
+ IFX_WARN("%s() invalid epqh state(not empty)\n",__func__);
+
+ _epqh->phase=EPQH_IDLE;
+
+ #ifdef __EPQD_DESTROY_TIMEOUT__
+ del_timer(&_epqh->destroy_timer);
+ _epqh->destroy_timer.expires = jiffies + (HZ*epqh_self_destroy_timeout);
+ add_timer(&_epqh->destroy_timer );
+ #endif
+
+ #ifdef __EN_ISOC__
+ if (_epqh->ep_type == IFXUSB_EP_TYPE_ISOC)
+ _epqh->ifxhcd->isoc_ep_count--;
+ #endif
+ UNLOCK_URBD_LIST(_epqh);
+ local_irq_restore(flags);
+}
+
+
+ifxhcd_epqh_t *ifxhcd_urbd_create (ifxhcd_hcd_t *_ifxhcd,struct urb *_urb)
+{
+ ifxhcd_urbd_t *urbd;
+ struct usb_host_endpoint *sysep;
+ ifxhcd_epqh_t *epqh=NULL;
+ unsigned long flags;
+
+ local_irq_save(flags);
+
+ sysep = ifxhcd_urb_to_endpoint(_urb);
+
+ LOCK_EPQH_LIST_ALL(_ifxhcd);
+ epqh = sysep_to_epqh(_ifxhcd, sysep);
+
+ if (!epqh)
+ {
+ sysep->hcpriv = NULL;
+ epqh = ifxhcd_epqh_create (_ifxhcd, _urb);
+ }
+ UNLOCK_EPQH_LIST_ALL(_ifxhcd);
+
+ if (!epqh)
+ {
+ IFX_ERROR("EPQH Error alloc\n");
+ local_irq_restore (flags);
+ return (ifxhcd_epqh_t *)NULL;
+ }
+ if(epqh->phase==EPQH_DISABLING)
+ {
+ IFX_ERROR("EPQH Error alloc while disabling\n");
+ local_irq_restore (flags);
+ return (ifxhcd_epqh_t *)NULL;
+ }
+ sysep->hcpriv = epqh;
+
+ if(_urb->hcpriv)
+ {
+ IFX_WARN("%s() Previous urb->hcpriv exist %p\n",__func__,_urb->hcpriv);
+ #if 1
+ local_irq_restore (flags);
+ return (ifxhcd_epqh_t *)NULL;
+ #else
+ urbd = _urb->hcpriv;
+ if(urbd->epqh!=epqh)
+ IFX_WARN("%s() Previous urb->hcpriv exist %p and epqh not the same %p %p\n",__func__,_urb->hcpriv,urbd->epqh,epqh);
+ #endif
+ }
+ else
+ {
+ urbd = (ifxhcd_urbd_t *) kmalloc (sizeof(ifxhcd_urbd_t), GFP_ATOMIC);
+ if (!urbd)
+ {
+ local_irq_restore (flags);
+ return (ifxhcd_epqh_t *)NULL;
+ }
+ memset (urbd, 0, sizeof (ifxhcd_urbd_t));
+ INIT_LIST_HEAD(&urbd->ql);
+ }
+
+ _urb->hcpriv = urbd;
+ urbd->urb = _urb;
+ urbd->epqh = epqh;
+ urbd->status= -EINPROGRESS;
+
+ urbd->is_in=usb_pipein(_urb->pipe) ? 1 : 0;
+#define URB_NO_SETUP_DMA_MAP 0
+ #ifdef __EN_ISOC__
+ if(epqh->ep_type == IFXUSB_EP_TYPE_ISOC)
+ {
+ if(_urb->transfer_flags && URB_NO_TRANSFER_DMA_MAP)
+ urbd->xfer_buff = (uint8_t *) (KSEG1ADDR((uint32_t *)_urb->transfer_dma));
+ else
+ urbd->xfer_buff = (uint8_t *) _urb->transfer_buffer;
+ }
+ else
+ #endif
+ {
+ urbd->xfer_len=_urb->transfer_buffer_length;
+ if(urbd->xfer_len>0)
+ {
+ if(_urb->transfer_flags && URB_NO_TRANSFER_DMA_MAP)
+ urbd->xfer_buff = (uint8_t *) (KSEG1ADDR((uint32_t *)_urb->transfer_dma));
+ else
+ urbd->xfer_buff = (uint8_t *) _urb->transfer_buffer;
+ }
+ }
+
+ #if 1 // cache write-back, so DMA engine can get correct content. Precaution
+ if(urbd->xfer_len)
+ dma_cache_wback_inv((unsigned long)urbd->xfer_buff, urbd->xfer_len);
+ #endif
+
+ if(epqh->ep_type == IFXUSB_EP_TYPE_CTRL)
+ {
+ if(_urb->transfer_flags && URB_NO_SETUP_DMA_MAP)
+ urbd->setup_buff = (uint8_t *) (KSEG1ADDR((uint32_t *)_urb->setup_dma));
+ else
+ urbd->setup_buff = (uint8_t *) _urb->setup_packet;
+ #if 1 // cache write-back, so DMA engine can get correct content. Precaution
+ dma_cache_wback_inv((unsigned long)urbd->setup_buff, 16);
+ #endif
+ }
+
+ LOCK_URBD_LIST(epqh);
+ if (!list_empty(&urbd->ql))
+ list_del_init(&urbd->ql);
+ list_add_tail(&urbd->ql, &epqh->urbd_list);
+ epqh->urbd_count++;
+ UNLOCK_URBD_LIST(epqh);
+
+ local_irq_restore (flags);
+ return epqh;
+}
+
+
+
+ifxhcd_epqh_t * sysep_to_epqh(ifxhcd_hcd_t *_ifxhcd, struct usb_host_endpoint *_sysep)
+{
+ ifxhcd_epqh_t *epqh;
+
+ LOCK_EPQH_LIST_ALL(_ifxhcd);
+ list_for_each_entry( epqh, &_ifxhcd->epqh_list_all, ql_all)
+ {
+ if(epqh->sysep==_sysep)
+ {
+ UNLOCK_EPQH_LIST_ALL(_ifxhcd);
+ return epqh;
+ }
+ }
+ UNLOCK_EPQH_LIST_ALL(_ifxhcd);
+ return NULL;
+}
+
diff --git a/package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxusb_cif.c.svn-base b/package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxusb_cif.c.svn-base
new file mode 100644
index 0000000..9f02625
--- /dev/null
+++ b/package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxusb_cif.c.svn-base
@@ -0,0 +1,1686 @@
+/*****************************************************************************
+ ** FILE NAME : ifxusb_cif.c
+ ** PROJECT : IFX USB sub-system V3
+ ** MODULES : IFX USB sub-system Host and Device driver
+ ** SRC VERSION : 1.0
+ ** SRC VERSION : 3.2
+ ** DATE : 1/Jan/2011
+ ** DESCRIPTION : The Core Interface provides basic services for accessing and
+ ** managing the IFX USB hardware. These services are used by both the
+ ** Host Controller Driver and the Peripheral Controller Driver.
+ ** FUNCTIONS :
+ ** COMPILER : gcc
+ ** REFERENCE : Synopsys DWC-OTG Driver 2.7
+ ** COPYRIGHT : Copyright (c) 2010
+ ** LANTIQ DEUTSCHLAND GMBH,
+ ** Am Campeon 3, 85579 Neubiberg, Germany
+ **
+ ** 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 of the License, or
+ ** (at your option) any later version.
+ **
+ ** Version Control Section **
+ ** $Author$
+ ** $Date$
+ ** $Revisions$
+ ** $Log$ Revision history
+ *****************************************************************************/
+
+/*
+ * This file contains code fragments from Synopsys HS OTG Linux Software Driver.
+ * For this code the following notice is applicable:
+ *
+ * ==========================================================================
+ *
+ * Synopsys HS OTG Linux Software Driver and documentation (hereinafter,
+ * "Software") is an Unsupported proprietary work of Synopsys, Inc. unless
+ * otherwise expressly agreed to in writing between Synopsys and you.
+ *
+ * The Software IS NOT an item of Licensed Software or Licensed Product under
+ * any End User Software License Agreement or Agreement for Licensed Product
+ * with Synopsys or any supplement thereto. You are permitted to use and
+ * redistribute this Software in source and binary forms, with or without
+ * modification, provided that redistributions of source code must retain this
+ * notice. You may not view, use, disclose, copy or distribute this file or
+ * any information contained herein except pursuant to this license grant from
+ * Synopsys. If you do not agree with this notice, including the disclaimer
+ * below, then you are not authorized to use the Software.
+ *
+ * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" BASIS
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ * ========================================================================== */
+
+/*!
+ \file ifxusb_cif.c
+ \ingroup IFXUSB_DRIVER_V3
+ \brief This file contains the interface to the IFX USB Core.
+*/
+
+#include <linux/version.h>
+#include "ifxusb_version.h"
+
+#include <asm/byteorder.h>
+#include <asm/unaligned.h>
+
+#ifdef __DEBUG__
+ #include <linux/jiffies.h>
+#include <linux/platform_device.h>
+#include <linux/kernel.h>
+#include <linux/ioport.h>
+#endif
+
+
+#include "ifxusb_plat.h"
+#include "ifxusb_regs.h"
+#include "ifxusb_cif.h"
+
+
+#ifdef __IS_DEVICE__
+ #include "ifxpcd.h"
+#endif
+
+#ifdef __IS_HOST__
+ #include "ifxhcd.h"
+#endif
+
+#include <linux/mm.h>
+
+#include <linux/gfp.h>
+
+#include <lantiq_soc.h>
+
+#if defined(__UEIP__)
+ #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__) || defined(__IS_AMAZON_SE__)
+ #ifndef USB_CTRL_PMU_SETUP
+ #define USB_CTRL_PMU_SETUP(__x) USB0_CTRL_PMU_SETUP(__x)
+ #endif
+ #ifndef USB_PHY_PMU_SETUP
+ #define USB_PHY_PMU_SETUP(__x) USB0_PHY_PMU_SETUP(__x)
+ #endif
+ #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__) || defined(__IS_AMAZON_SE__)
+#endif // defined(__UEIP__)
+
+/*!
+ \brief This function is called to allocate buffer of specified size.
+ The allocated buffer is mapped into DMA accessable address.
+ \param size Size in BYTE to be allocated
+ \param clear 0: don't do clear after buffer allocated, other: do clear to zero
+ \return 0/NULL: Fail; uncached pointer of allocated buffer
+ */
+#ifdef __IS_HOST__
+void *ifxusb_alloc_buf_h(size_t size, int clear)
+#else
+void *ifxusb_alloc_buf_d(size_t size, int clear)
+#endif
+{
+ uint32_t *cached,*uncached;
+ uint32_t totalsize,page;
+
+ if(!size)
+ return 0;
+
+ size=(size+3)&0xFFFFFFFC;
+ totalsize=size + 12;
+ page=get_order(totalsize);
+
+ cached = (void *) __get_free_pages(( GFP_ATOMIC | GFP_DMA), page);
+
+ if(!cached)
+ {
+ IFX_PRINT("%s Allocation Failed size:%d\n",__func__,size);
+ return NULL;
+ }
+
+ uncached = (uint32_t *)(KSEG1ADDR(cached));
+ if(clear)
+ memset(uncached, 0, totalsize);
+
+ *(uncached+0)=totalsize;
+ *(uncached+1)=page;
+ *(uncached+2)=(uint32_t)cached;
+ return (void *)(uncached+3);
+}
+
+
+/*!
+ \brief This function is called to free allocated buffer.
+ \param vaddr the uncached pointer of the buffer
+ */
+#ifdef __IS_HOST__
+void ifxusb_free_buf_h(void *vaddr)
+#else
+void ifxusb_free_buf_d(void *vaddr)
+#endif
+{
+ uint32_t totalsize,page;
+ uint32_t *cached,*uncached;
+
+ if(vaddr != NULL)
+ {
+ uncached=vaddr;
+ uncached-=3;
+ totalsize=*(uncached+0);
+ page=*(uncached+1);
+ cached=(uint32_t *)(*(uncached+2));
+ if(totalsize && page==get_order(totalsize) && cached==(uint32_t *)(KSEG0ADDR(uncached)))
+ {
+ free_pages((unsigned long)cached, page);
+ return;
+ }
+ // the memory is not allocated by ifxusb_alloc_buf. Allowed but must be careful.
+ return;
+ }
+}
+
+
+
+/*!
+ \brief This function is called to initialize the IFXUSB CSR data
+ structures. The register addresses in the device and host
+ structures are initialized from the base address supplied by the
+ caller. The calling function must make the OS calls to get the
+ base address of the IFXUSB controller registers.
+
+ \param _core_if Pointer of core_if structure
+ \param _irq irq number
+ \param _reg_base_addr Base address of IFXUSB core registers
+ \param _fifo_base_addr Fifo base address
+ \param _fifo_dbg_addr Fifo debug address
+ \return 0: success;
+ */
+#ifdef __IS_HOST__
+int ifxusb_core_if_init_h(ifxusb_core_if_t *_core_if,
+#else
+int ifxusb_core_if_init_d(ifxusb_core_if_t *_core_if,
+#endif
+ int _irq,
+ uint32_t _reg_base_addr,
+ uint32_t _fifo_base_addr,
+ uint32_t _fifo_dbg_addr)
+{
+ int retval = 0;
+ uint32_t *reg_base =NULL;
+ uint32_t *fifo_base =NULL;
+ uint32_t *fifo_dbg =NULL;
+
+ int i;
+
+ IFX_DEBUGPL(DBG_CILV, "%s(%p,%d,0x%08X,0x%08X,0x%08X)\n", __func__,
+ _core_if,
+ _irq,
+ _reg_base_addr,
+ _fifo_base_addr,
+ _fifo_dbg_addr);
+
+ if( _core_if == NULL)
+ {
+ IFX_ERROR("%s() invalid _core_if\n", __func__);
+ retval = -ENOMEM;
+ goto fail;
+ }
+
+ //memset(_core_if, 0, sizeof(ifxusb_core_if_t));
+
+ _core_if->irq=_irq;
+
+ reg_base =ioremap_nocache(_reg_base_addr , IFXUSB_IOMEM_SIZE );
+ fifo_base =ioremap_nocache(_fifo_base_addr, IFXUSB_FIFOMEM_SIZE);
+ fifo_dbg =ioremap_nocache(_fifo_dbg_addr , IFXUSB_FIFODBG_SIZE);
+ if( reg_base == NULL || fifo_base == NULL || fifo_dbg == NULL)
+ {
+ IFX_ERROR("%s() usb ioremap() failed\n", __func__);
+ retval = -ENOMEM;
+ goto fail;
+ }
+
+ _core_if->core_global_regs = (ifxusb_core_global_regs_t *)reg_base;
+
+ /*
+ * Attempt to ensure this device is really a IFXUSB Controller.
+ * Read and verify the SNPSID register contents. The value should be
+ * 0x45F42XXX
+ */
+ {
+ int32_t snpsid;
+ snpsid = ifxusb_rreg(&_core_if->core_global_regs->gsnpsid);
+ if ((snpsid & 0xFFFFF000) != 0x4F542000)
+ {
+ IFX_ERROR("%s() snpsid error(0x%08x) failed\n", __func__,snpsid);
+ retval = -EINVAL;
+ goto fail;
+ }
+ _core_if->snpsid=snpsid;
+ }
+
+ #ifdef __IS_HOST__
+ _core_if->host_global_regs = (ifxusb_host_global_regs_t *)
+ ((uint32_t)reg_base + IFXUSB_HOST_GLOBAL_REG_OFFSET);
+ _core_if->hprt0 = (uint32_t*)((uint32_t)reg_base + IFXUSB_HOST_PORT_REGS_OFFSET);
+
+ for (i=0; i<MAX_EPS_CHANNELS; i++)
+ {
+ _core_if->hc_regs[i] = (ifxusb_hc_regs_t *)
+ ((uint32_t)reg_base + IFXUSB_HOST_CHAN_REGS_OFFSET +
+ (i * IFXUSB_CHAN_REGS_OFFSET));
+ IFX_DEBUGPL(DBG_CILV, "hc_reg[%d]->hcchar=%p\n",
+ i, &_core_if->hc_regs[i]->hcchar);
+ }
+ #endif //__IS_HOST__
+
+ #ifdef __IS_DEVICE__
+ _core_if->dev_global_regs =
+ (ifxusb_device_global_regs_t *)((uint32_t)reg_base + IFXUSB_DEV_GLOBAL_REG_OFFSET);
+
+ for (i=0; i<MAX_EPS_CHANNELS; i++)
+ {
+ _core_if->in_ep_regs[i] = (ifxusb_dev_in_ep_regs_t *)
+ ((uint32_t)reg_base + IFXUSB_DEV_IN_EP_REG_OFFSET +
+ (i * IFXUSB_EP_REG_OFFSET));
+ _core_if->out_ep_regs[i] = (ifxusb_dev_out_ep_regs_t *)
+ ((uint32_t)reg_base + IFXUSB_DEV_OUT_EP_REG_OFFSET +
+ (i * IFXUSB_EP_REG_OFFSET));
+ IFX_DEBUGPL(DBG_CILV, "in_ep_regs[%d]->diepctl=%p/%p %p/0x%08X/0x%08X\n",
+ i, &_core_if->in_ep_regs[i]->diepctl, _core_if->in_ep_regs[i],
+ reg_base,IFXUSB_DEV_IN_EP_REG_OFFSET,(i * IFXUSB_EP_REG_OFFSET)
+ );
+ IFX_DEBUGPL(DBG_CILV, "out_ep_regs[%d]->doepctl=%p/%p %p/0x%08X/0x%08X\n",
+ i, &_core_if->out_ep_regs[i]->doepctl, _core_if->out_ep_regs[i],
+ reg_base,IFXUSB_DEV_OUT_EP_REG_OFFSET,(i * IFXUSB_EP_REG_OFFSET)
+ );
+ }
+ #endif //__IS_DEVICE__
+
+ /* Setting the FIFO and other Address. */
+ for (i=0; i<MAX_EPS_CHANNELS; i++)
+ {
+ _core_if->data_fifo[i] = fifo_base + (i * IFXUSB_DATA_FIFO_SIZE);
+ IFX_DEBUGPL(DBG_CILV, "data_fifo[%d]=0x%08x\n",
+ i, (unsigned)_core_if->data_fifo[i]);
+ }
+
+ _core_if->data_fifo_dbg = fifo_dbg;
+ _core_if->pcgcctl = (uint32_t*)(((uint32_t)reg_base) + IFXUSB_PCGCCTL_OFFSET);
+
+ /*
+ * Store the contents of the hardware configuration registers here for
+ * easy access later.
+ */
+ _core_if->hwcfg1.d32 = ifxusb_rreg(&_core_if->core_global_regs->ghwcfg1);
+ _core_if->hwcfg2.d32 = ifxusb_rreg(&_core_if->core_global_regs->ghwcfg2);
+ _core_if->hwcfg3.d32 = ifxusb_rreg(&_core_if->core_global_regs->ghwcfg3);
+ _core_if->hwcfg4.d32 = ifxusb_rreg(&_core_if->core_global_regs->ghwcfg4);
+
+ IFX_DEBUGPL(DBG_CILV,"hwcfg1=%08x\n",_core_if->hwcfg1.d32);
+ IFX_DEBUGPL(DBG_CILV,"hwcfg2=%08x\n",_core_if->hwcfg2.d32);
+ IFX_DEBUGPL(DBG_CILV,"hwcfg3=%08x\n",_core_if->hwcfg3.d32);
+ IFX_DEBUGPL(DBG_CILV,"hwcfg4=%08x\n",_core_if->hwcfg4.d32);
+
+
+ #ifdef __DED_FIFO__
+ {
+ unsigned int countdown=0xFFFF;
+ IFX_PRINT("Waiting for PHY Clock Lock!\n");
+ while(--countdown && !( ifxusb_rreg(&_core_if->core_global_regs->grxfsiz) & (1<<9)))
+ {
+ UDELAY(1);
+ }
+ if(countdown)
+ IFX_PRINT("PHY Clock Locked!\n");
+ else
+ IFX_PRINT("PHY Clock Not Locked! %08X\n",ifxusb_rreg(&_core_if->core_global_regs->grxfsiz));
+ }
+ #endif
+
+ /* Create new workqueue and init works */
+#if 0
+ _core_if->wq_usb = create_singlethread_workqueue(_core_if->core_name);
+
+ if(_core_if->wq_usb == 0)
+ {
+ IFX_DEBUGPL(DBG_CIL, "Creation of wq_usb failed\n");
+ retval = -EINVAL;
+ goto fail;
+ }
+
+ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
+ INIT_WORK(&core_if->w_conn_id, w_conn_id_status_change, core_if);
+ INIT_WORK(&core_if->w_wkp, w_wakeup_detected, core_if);
+ #else
+ INIT_WORK(&core_if->w_conn_id, w_conn_id_status_change);
+ INIT_DELAYED_WORK(&core_if->w_wkp, w_wakeup_detected);
+ #endif
+#endif
+ return 0;
+
+fail:
+ if( reg_base != NULL) iounmap(reg_base );
+ if( fifo_base != NULL) iounmap(fifo_base);
+ if( fifo_dbg != NULL) iounmap(fifo_dbg );
+ return retval;
+}
+
+/*!
+ \brief This function free the mapped address in the IFXUSB CSR data structures.
+ \param _core_if Pointer of core_if structure
+ */
+#ifdef __IS_HOST__
+void ifxusb_core_if_remove_h(ifxusb_core_if_t *_core_if)
+#else
+void ifxusb_core_if_remove_d(ifxusb_core_if_t *_core_if)
+#endif
+{
+ /* Disable all interrupts */
+ if( _core_if->core_global_regs != NULL)
+ {
+ gusbcfg_data_t usbcfg ={.d32 = 0};
+ usbcfg.d32 = ifxusb_rreg( &_core_if->core_global_regs->gusbcfg);
+ usbcfg.b.ForceDevMode=0;
+ usbcfg.b.ForceHstMode=0;
+ ifxusb_wreg( &_core_if->core_global_regs->gusbcfg,usbcfg.d32);
+ ifxusb_mreg( &_core_if->core_global_regs->gahbcfg, 1, 0);
+ ifxusb_wreg( &_core_if->core_global_regs->gintmsk, 0);
+ }
+
+ if( _core_if->core_global_regs != NULL) iounmap(_core_if->core_global_regs );
+ if( _core_if->data_fifo[0] != NULL) iounmap(_core_if->data_fifo[0] );
+ if( _core_if->data_fifo_dbg != NULL) iounmap(_core_if->data_fifo_dbg );
+
+#if 0
+ if (_core_if->wq_usb)
+ destroy_workqueue(_core_if->wq_usb);
+#endif
+ memset(_core_if, 0, sizeof(ifxusb_core_if_t));
+}
+
+
+
+
+/*!
+ \brief This function enbles the controller's Global Interrupt in the AHB Config register.
+ \param _core_if Pointer of core_if structure
+ */
+#ifdef __IS_HOST__
+void ifxusb_enable_global_interrupts_h( ifxusb_core_if_t *_core_if )
+#else
+void ifxusb_enable_global_interrupts_d( ifxusb_core_if_t *_core_if )
+#endif
+{
+ gahbcfg_data_t ahbcfg ={ .d32 = 0};
+ ahbcfg.b.glblintrmsk = 1; /* Enable interrupts */
+ ifxusb_mreg(&_core_if->core_global_regs->gahbcfg, 0, ahbcfg.d32);
+}
+
+/*!
+ \brief This function disables the controller's Global Interrupt in the AHB Config register.
+ \param _core_if Pointer of core_if structure
+ */
+#ifdef __IS_HOST__
+void ifxusb_disable_global_interrupts_h( ifxusb_core_if_t *_core_if )
+#else
+void ifxusb_disable_global_interrupts_d( ifxusb_core_if_t *_core_if )
+#endif
+{
+ gahbcfg_data_t ahbcfg ={ .d32 = 0};
+ ahbcfg.b.glblintrmsk = 1; /* Enable interrupts */
+ ifxusb_mreg(&_core_if->core_global_regs->gahbcfg, ahbcfg.d32, 0);
+}
+
+
+
+
+/*!
+ \brief Flush Tx and Rx FIFO.
+ \param _core_if Pointer of core_if structure
+ */
+#ifdef __IS_HOST__
+void ifxusb_flush_both_fifo_h( ifxusb_core_if_t *_core_if )
+#else
+void ifxusb_flush_both_fifo_d( ifxusb_core_if_t *_core_if )
+#endif
+{
+ ifxusb_core_global_regs_t *global_regs = _core_if->core_global_regs;
+ volatile grstctl_t greset ={ .d32 = 0};
+ int count = 0;
+
+ IFX_DEBUGPL((DBG_CIL|DBG_PCDV), "%s\n", __func__);
+ greset.b.rxfflsh = 1;
+ greset.b.txfflsh = 1;
+ greset.b.txfnum = 0x10;
+ greset.b.intknqflsh=1;
+ greset.b.hstfrm=1;
+ ifxusb_wreg( &global_regs->grstctl, greset.d32 );
+
+ do
+ {
+ greset.d32 = ifxusb_rreg( &global_regs->grstctl);
+ if (++count > 10000)
+ {
+ IFX_WARN("%s() HANG! GRSTCTL=%0x\n", __func__, greset.d32);
+ break;
+ }
+ } while (greset.b.rxfflsh == 1 || greset.b.txfflsh == 1);
+ /* Wait for 3 PHY Clocks*/
+ UDELAY(1);
+}
+
+/*!
+ \brief Flush a Tx FIFO.
+ \param _core_if Pointer of core_if structure
+ \param _num Tx FIFO to flush. ( 0x10 for ALL TX FIFO )
+ */
+#ifdef __IS_HOST__
+void ifxusb_flush_tx_fifo_h( ifxusb_core_if_t *_core_if, const int _num )
+#else
+void ifxusb_flush_tx_fifo_d( ifxusb_core_if_t *_core_if, const int _num )
+#endif
+{
+ ifxusb_core_global_regs_t *global_regs = _core_if->core_global_regs;
+ volatile grstctl_t greset ={ .d32 = 0};
+ int count = 0;
+
+ IFX_DEBUGPL((DBG_CIL|DBG_PCDV), "Flush Tx FIFO %d\n", _num);
+
+ greset.b.intknqflsh=1;
+ greset.b.txfflsh = 1;
+ greset.b.txfnum = _num;
+ ifxusb_wreg( &global_regs->grstctl, greset.d32 );
+
+ do
+ {
+ greset.d32 = ifxusb_rreg( &global_regs->grstctl);
+ if (++count > 10000&&(_num==0 ||_num==0x10))
+ {
+ IFX_WARN("%s() HANG! GRSTCTL=%0x GNPTXSTS=0x%08x\n",
+ __func__, greset.d32,
+ ifxusb_rreg( &global_regs->gnptxsts));
+ break;
+ }
+ } while (greset.b.txfflsh == 1);
+ /* Wait for 3 PHY Clocks*/
+ UDELAY(1);
+}
+
+
+/*!
+ \brief Flush Rx FIFO.
+ \param _core_if Pointer of core_if structure
+ */
+#ifdef __IS_HOST__
+void ifxusb_flush_rx_fifo_h( ifxusb_core_if_t *_core_if )
+#else
+void ifxusb_flush_rx_fifo_d( ifxusb_core_if_t *_core_if )
+#endif
+{
+ ifxusb_core_global_regs_t *global_regs = _core_if->core_global_regs;
+ volatile grstctl_t greset ={ .d32 = 0};
+ int count = 0;
+
+ IFX_DEBUGPL((DBG_CIL|DBG_PCDV), "%s\n", __func__);
+ greset.b.rxfflsh = 1;
+ ifxusb_wreg( &global_regs->grstctl, greset.d32 );
+
+ do
+ {
+ greset.d32 = ifxusb_rreg( &global_regs->grstctl);
+ if (++count > 10000)
+ {
+ IFX_WARN("%s() HANG! GRSTCTL=%0x\n", __func__, greset.d32);
+ break;
+ }
+ } while (greset.b.rxfflsh == 1);
+ /* Wait for 3 PHY Clocks*/
+ UDELAY(1);
+}
+
+
+#define SOFT_RESET_DELAY 100 /*!< Delay in msec of detection after soft-reset of usb core */
+
+/*!
+ \brief Do a soft reset of the core. Be careful with this because it
+ resets all the internal state machines of the core.
+ \param _core_if Pointer of core_if structure
+ */
+#ifdef __IS_HOST__
+int ifxusb_core_soft_reset_h(ifxusb_core_if_t *_core_if)
+#else
+int ifxusb_core_soft_reset_d(ifxusb_core_if_t *_core_if)
+#endif
+{
+ ifxusb_core_global_regs_t *global_regs = _core_if->core_global_regs;
+ volatile grstctl_t greset ={ .d32 = 0};
+ int count = 0;
+
+ IFX_DEBUGPL(DBG_CILV, "%s\n", __func__);
+ /* Wait for AHB master IDLE state. */
+ do
+ {
+ UDELAY(10);
+ greset.d32 = ifxusb_rreg( &global_regs->grstctl);
+ if (++count > 100000)
+ {
+ IFX_WARN("%s() HANG! AHB Idle GRSTCTL=%0x %x\n", __func__,
+ greset.d32, greset.b.ahbidle);
+ break;
+ }
+ } while (greset.b.ahbidle == 0);
+
+ UDELAY(1);
+
+ /* Core Soft Reset */
+ count = 0;
+ greset.b.csftrst = 1;
+ ifxusb_wreg( &global_regs->grstctl, greset.d32 );
+
+ #ifdef SOFT_RESET_DELAY
+ MDELAY(SOFT_RESET_DELAY);
+ #endif
+
+ do
+ {
+ UDELAY(10);
+ greset.d32 = ifxusb_rreg( &global_regs->grstctl);
+ if (++count > 100000)
+ {
+ IFX_WARN("%s() HANG! Soft Reset GRSTCTL=%0x\n", __func__, greset.d32);
+ return -1;
+ }
+ } while (greset.b.csftrst == 1);
+
+ #ifdef SOFT_RESET_DELAY
+ MDELAY(SOFT_RESET_DELAY);
+ #endif
+
+ // This is to reset the PHY of VR9
+ #if defined(__IS_VR9__)
+ if(_core_if->core_no==0)
+ {
+ set_bit (4, VR9_RCU_USBRESET2);
+ MDELAY(50);
+ clear_bit (4, VR9_RCU_USBRESET2);
+ }
+ else
+ {
+ set_bit (5, VR9_RCU_USBRESET2);
+ MDELAY(50);
+ clear_bit (5, VR9_RCU_USBRESET2);
+ }
+ MDELAY(50);
+ #endif //defined(__IS_VR9__)
+
+ IFX_PRINT("USB core #%d soft-reset\n",_core_if->core_no);
+
+ return 0;
+}
+
+/*!
+ \brief Turn on the USB Core Power
+ \param _core_if Pointer of core_if structure
+*/
+#ifdef __IS_HOST__
+void ifxusb_power_on_h (ifxusb_core_if_t *_core_if)
+#else
+void ifxusb_power_on_d (ifxusb_core_if_t *_core_if)
+#endif
+{
+ IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
+ #if defined(__UEIP__)
+
+ // set clock gating
+ #if defined(__IS_TWINPASS) || defined(__IS_DANUBE__)
+ set_bit (4, (volatile unsigned long *)DANUBE_CGU_IFCCR);
+ set_bit (5, (volatile unsigned long *)DANUBE_CGU_IFCCR);
+ #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ #if defined(__IS_AMAZON_SE__)
+ // clear_bit (4, (volatile unsigned long *)AMAZON_SE_CGU_IFCCR);
+ clear_bit (5, (volatile unsigned long *)AMAZON_SE_CGU_IFCCR);
+ #endif //defined(__IS_AMAZON_SE__)
+ #if defined(__IS_AR9__)
+ set_bit (0, (volatile unsigned long *)AR9_CGU_IFCCR);
+ set_bit (1, (volatile unsigned long *)AR9_CGU_IFCCR);
+ #endif //defined(__IS_AR9__)
+ #if defined(__IS_VR9__)
+// set_bit (0, (volatile unsigned long *)VR9_CGU_IFCCR);
+// set_bit (1, (volatile unsigned long *)VR9_CGU_IFCCR);
+ #endif //defined(__IS_VR9__)
+ #if defined(__IS_AR10__)
+// set_bit (0, (volatile unsigned long *)VR9_CGU_IFCCR);
+// set_bit (1, (volatile unsigned long *)VR9_CGU_IFCCR);
+ #endif //defined(__IS_AR10__)
+
+ MDELAY(50);
+#define PMU_AHBM BIT(15)
+#define PMU_USB0 BIT(6)
+#define PMU_USB1 BIT(27)
+#define PMU_USB0_P BIT(0)
+#define PMU_USB1_P BIT(26)
+ // set power
+ ltq_pmu_enable(PMU_AHBM);
+ #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__) || defined(__IS_AMAZON_SE__)
+ ltq_pmu_enable(PMU_USB0);
+ //#if defined(__IS_TWINPASS__)
+ // ifxusb_enable_afe_oc();
+ //#endif
+ #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__) || defined(__IS_AMAZON_SE__)
+ #if defined(__IS_AR9__) || defined(__IS_VR9__)
+ if(_core_if->core_no==0)
+ ltq_pmu_enable(PMU_USB0);
+ else
+ ltq_pmu_enable(PMU_USB1);
+ #endif //defined(__IS_AR9__) || defined(__IS_VR9__)
+ #if defined(__IS_AR10__)
+ //if(_core_if->core_no==0)
+ // USB0_CTRL_PMU_SETUP(IFX_PMU_ENABLE);
+ //else
+ // USB1_CTRL_PMU_SETUP(IFX_PMU_ENABLE);
+ #endif //defined(__IS_AR10__)
+
+ MDELAY(50);
+
+ if(_core_if->pcgcctl)
+ {
+ pcgcctl_data_t pcgcctl = {.d32=0};
+ pcgcctl.b.gatehclk = 1;
+ ifxusb_mreg(_core_if->pcgcctl, pcgcctl.d32, 0);
+ }
+
+
+ if(_core_if->core_global_regs)
+ {
+ // PHY configurations.
+ #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
+ #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ #if defined(__IS_AMAZON_SE__)
+ ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
+ #endif //defined(__IS_AMAZON_SE__)
+ #if defined(__IS_AR9__)
+ ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
+ #endif //defined(__IS_AR9__)
+ #if defined(__IS_VR9__)
+ //ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
+ #endif //defined(__IS_VR9__)
+ #if defined(__IS_AR10__)
+ //ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
+ #endif //defined(__IS_AR10__)
+ }
+ #else //defined(__UEIP__)
+ // set clock gating
+ #if defined(__IS_TWINPASS) || defined(__IS_DANUBE__)
+ set_bit (4, (volatile unsigned long *)DANUBE_CGU_IFCCR);
+ set_bit (5, (volatile unsigned long *)DANUBE_CGU_IFCCR);
+ #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ #if defined(__IS_AMAZON_SE__)
+ // clear_bit (4, (volatile unsigned long *)AMAZON_SE_CGU_IFCCR);
+ clear_bit (5, (volatile unsigned long *)AMAZON_SE_CGU_IFCCR);
+ #endif //defined(__IS_AMAZON_SE__)
+ #if defined(__IS_AR9__)
+ set_bit (0, (volatile unsigned long *)AMAZON_S_CGU_IFCCR);
+ set_bit (1, (volatile unsigned long *)AMAZON_S_CGU_IFCCR);
+ #endif //defined(__IS_AR9__)
+
+ MDELAY(50);
+
+ // set power
+ #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ clear_bit (6, (volatile unsigned long *)DANUBE_PMU_PWDCR);//USB
+ clear_bit (9, (volatile unsigned long *)DANUBE_PMU_PWDCR);//DSL
+ clear_bit (15, (volatile unsigned long *)DANUBE_PMU_PWDCR);//AHB
+ #if defined(__IS_TWINPASS__)
+ ifxusb_enable_afe_oc();
+ #endif
+ #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ #if defined(__IS_AMAZON_SE__)
+ clear_bit (6, (volatile unsigned long *)AMAZON_SE_PMU_PWDCR);
+ clear_bit (9, (volatile unsigned long *)AMAZON_SE_PMU_PWDCR);
+ clear_bit (15, (volatile unsigned long *)AMAZON_SE_PMU_PWDCR);
+ #endif //defined(__IS_AMAZON_SE__)
+ #if defined(__IS_AR9__)
+ if(_core_if->core_no==0)
+ clear_bit (6, (volatile unsigned long *)AMAZON_S_PMU_PWDCR);//USB
+ else
+ clear_bit (27, (volatile unsigned long *)AMAZON_S_PMU_PWDCR);//USB
+ clear_bit (9, (volatile unsigned long *)AMAZON_S_PMU_PWDCR);//DSL
+ clear_bit (15, (volatile unsigned long *)AMAZON_S_PMU_PWDCR);//AHB
+ #endif //defined(__IS_AR9__)
+
+ if(_core_if->core_global_regs)
+ {
+ // PHY configurations.
+ #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
+ #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ #if defined(__IS_AMAZON_SE__)
+ ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
+ #endif //defined(__IS_AMAZON_SE__)
+ #if defined(__IS_AR9__)
+ ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
+ #endif //defined(__IS_AR9__)
+ }
+
+ #endif //defined(__UEIP__)
+}
+
+/*!
+ \brief Turn off the USB Core Power
+ \param _core_if Pointer of core_if structure
+*/
+#ifdef __IS_HOST__
+void ifxusb_power_off_h (ifxusb_core_if_t *_core_if)
+#else
+void ifxusb_power_off_d (ifxusb_core_if_t *_core_if)
+#endif
+
+{
+ #ifdef __IS_HOST__
+ ifxusb_phy_power_off_h (_core_if);
+ #else
+ ifxusb_phy_power_off_d (_core_if);
+ #endif
+
+ #if defined(__UEIP__)
+ //AHBM_PMU_SETUP(IFX_PMU_DISABLE);
+ // set power
+ if(_core_if->pcgcctl)
+ {
+ pcgcctl_data_t pcgcctl = {.d32=0};
+ pcgcctl.b.gatehclk = 1;
+ pcgcctl.b.stoppclk = 1;
+ ifxusb_mreg(_core_if->pcgcctl, 0, pcgcctl.d32);
+ }
+ #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__) || defined(__IS_AMAZON_SE__)
+ //USB_CTRL_PMU_SETUP(IFX_PMU_DISABLE);
+ #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__) || defined(__IS_AMAZON_SE__)
+ #if defined(__IS_AR9__) || defined(__IS_VR9__)
+ /* if(_core_if->core_no==0)
+ USB0_CTRL_PMU_SETUP(IFX_PMU_DISABLE);
+ else
+ USB1_CTRL_PMU_SETUP(IFX_PMU_DISABLE);*/
+ #endif //defined(__IS_AR9__) || defined(__IS_VR9__)
+ #if defined(__IS_AR10__)
+ //if(_core_if->core_no==0)
+ // USB0_CTRL_PMU_SETUP(IFX_PMU_DISABLE);
+ //else
+ // USB1_CTRL_PMU_SETUP(IFX_PMU_DISABLE);
+ #endif //defined(__IS_AR10__)
+ #else //defined(__UEIP__)
+ // set power
+ #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ set_bit (6, (volatile unsigned long *)DANUBE_PMU_PWDCR);//USB
+ #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ #if defined(__IS_AMAZON_SE__)
+ set_bit (6, (volatile unsigned long *)AMAZON_SE_PMU_PWDCR);//USB
+ #endif //defined(__IS_AMAZON_SE__)
+ #if defined(__IS_AR9__)
+ if(_core_if->core_no==0)
+ set_bit (6, (volatile unsigned long *)AMAZON_S_PMU_PWDCR);//USB
+ else
+ set_bit (27, (volatile unsigned long *)AMAZON_S_PMU_PWDCR);//USB
+ #endif //defined(__IS_AR9__)
+ #endif //defined(__UEIP__)
+}
+
+/*!
+ \brief Turn on the USB PHY Power
+ \param _core_if Pointer of core_if structure
+*/
+#ifdef __IS_HOST__
+void ifxusb_phy_power_on_h (ifxusb_core_if_t *_core_if)
+#else
+void ifxusb_phy_power_on_d (ifxusb_core_if_t *_core_if)
+#endif
+{
+ #if defined(__UEIP__)
+ if(_core_if->core_global_regs)
+ {
+ #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
+ #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ #if defined(__IS_AMAZON_SE__)
+ ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
+ #endif //defined(__IS_AMAZON_SE__)
+ #if defined(__IS_AR9__)
+ ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
+ #endif //defined(__IS_AR9__)
+ #if ( defined(__IS_VR9__) || defined(__IS_AR10__)) && defined(__PHY_LONG_PREEMP__)
+ if(_core_if->core_no==0)
+ set_bit (0, VR9_RCU_USB_ANA_CFG1A);
+ else
+ set_bit (0, VR9_RCU_USB_ANA_CFG1B);
+ #endif //( defined(__IS_VR9__) || defined(__IS_AR10__)) && defined(__PHY_LONG_PREEMP__)
+
+ if(_core_if->pcgcctl)
+ {
+ pcgcctl_data_t pcgcctl = {.d32=0};
+ pcgcctl.b.stoppclk = 1;
+ ifxusb_mreg(_core_if->pcgcctl, pcgcctl.d32, 0);
+ }
+ }
+
+ #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__) || defined(__IS_AMAZON_SE__)
+ ltq_pmu_enable(PMU_USB0_P);
+ #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__) || defined(__IS_AMAZON_SE__)
+ #if defined(__IS_AR9__) || defined(__IS_VR9__) || defined(__IS_AR10__)
+ if(_core_if->core_no==0)
+ ltq_pmu_enable(PMU_USB0_P);
+ else
+ ltq_pmu_enable(PMU_USB1_P);
+ #endif //defined(__IS_AR9__) || defined(__IS_VR9__)
+
+ // PHY configurations.
+ if(_core_if->core_global_regs)
+ {
+ #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
+ #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ #if defined(__IS_AMAZON_SE__)
+ ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
+ #endif //defined(__IS_AMAZON_SE__)
+ #if defined(__IS_AR9__)
+ ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
+ #endif //defined(__IS_AR9__)
+ #if ( defined(__IS_VR9__) || defined(__IS_AR10__)) && defined(__PHY_LONG_PREEMP__)
+ if(_core_if->core_no==0)
+ set_bit (0, VR9_RCU_USB_ANA_CFG1A);
+ else
+ set_bit (0, VR9_RCU_USB_ANA_CFG1B);
+ #endif //( defined(__IS_VR9__) || defined(__IS_AR10__)) && defined(__PHY_LONG_PREEMP__)
+ }
+ #else //defined(__UEIP__)
+ // PHY configurations.
+ if(_core_if->core_global_regs)
+ {
+ #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
+ #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ #if defined(__IS_AMAZON_SE__)
+ ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
+ #endif //defined(__IS_AMAZON_SE__)
+ #if defined(__IS_AR9__)
+ ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
+ #endif //defined(__IS_AR9__)
+ }
+
+ #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ clear_bit (0, (volatile unsigned long *)DANUBE_PMU_PWDCR);//PHY
+ #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ #if defined(__IS_AMAZON_SE__)
+ clear_bit (0, (volatile unsigned long *)AMAZON_SE_PMU_PWDCR);
+ #endif //defined(__IS_AMAZON_SE__)
+ #if defined(__IS_AR9__)
+ if(_core_if->core_no==0)
+ clear_bit (0, (volatile unsigned long *)AMAZON_S_PMU_PWDCR);//PHY
+ else
+ clear_bit (26, (volatile unsigned long *)AMAZON_S_PMU_PWDCR);//PHY
+ #endif //defined(__IS_AR9__)
+
+ // PHY configurations.
+ if(_core_if->core_global_regs)
+ {
+ #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
+ #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ #if defined(__IS_AMAZON_SE__)
+ ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
+ #endif //defined(__IS_AMAZON_SE__)
+ #if defined(__IS_AR9__)
+ ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
+ #endif //defined(__IS_AR9__)
+ }
+ #endif //defined(__UEIP__)
+}
+
+
+/*!
+ \brief Turn off the USB PHY Power
+ \param _core_if Pointer of core_if structure
+*/
+#ifdef __IS_HOST__
+void ifxusb_phy_power_off_h (ifxusb_core_if_t *_core_if)
+#else
+void ifxusb_phy_power_off_d (ifxusb_core_if_t *_core_if)
+#endif
+{
+ #if defined(__UEIP__)
+ if(_core_if->pcgcctl)
+ {
+ pcgcctl_data_t pcgcctl = {.d32=0};
+ pcgcctl.b.stoppclk = 1;
+ ifxusb_mreg(_core_if->pcgcctl, 0, pcgcctl.d32);
+ }
+ #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__) || defined(__IS_AMAZON_SE__)
+ //USB_PHY_PMU_SETUP(IFX_PMU_DISABLE);
+ #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__) || defined(__IS_AMAZON_SE__)
+ #if defined(__IS_AR9__) || defined(__IS_VR9__) || defined(__IS_AR10__)
+/* if(_core_if->core_no==0)
+ USB0_PHY_PMU_SETUP(IFX_PMU_DISABLE);
+ else
+ USB1_PHY_PMU_SETUP(IFX_PMU_DISABLE);*/
+ #endif // defined(__IS_AR9__) || defined(__IS_VR9__)
+ #else //defined(__UEIP__)
+ #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ set_bit (0, (volatile unsigned long *)DANUBE_PMU_PWDCR);//PHY
+ #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ #if defined(__IS_AMAZON_SE__)
+ set_bit (0, (volatile unsigned long *)AMAZON_SE_PMU_PWDCR);//PHY
+ #endif //defined(__IS_AMAZON_SE__)
+ #if defined(__IS_AR9__)
+ if(_core_if->core_no==0)
+ set_bit (0, (volatile unsigned long *)AMAZON_S_PMU_PWDCR);//PHY
+ else
+ set_bit (26, (volatile unsigned long *)AMAZON_S_PMU_PWDCR);//PHY
+ #endif //defined(__IS_AR9__)
+ #endif //defined(__UEIP__)
+}
+
+
+/*!
+ \brief Reset on the USB Core RCU
+ \param _core_if Pointer of core_if structure
+ */
+#if defined(__IS_VR9__) || defined(__IS_AR10__)
+static int CheckAlready(void)
+{
+ gusbcfg_data_t usbcfg ={.d32 = 0};
+ usbcfg.d32 = ifxusb_rreg((volatile uint32_t *)0xBE10100C);
+ if(usbcfg.b.ForceDevMode)
+ return 1;
+ if(usbcfg.b.ForceHstMode)
+ return 1;
+ usbcfg.d32 = ifxusb_rreg((volatile uint32_t *)0xBE10600C);
+ if(usbcfg.b.ForceDevMode)
+ return 1;
+ if(usbcfg.b.ForceHstMode)
+ return 1;
+ return 0;
+}
+#endif
+
+#ifdef __IS_HOST__
+ void ifxusb_hard_reset_h(ifxusb_core_if_t *_core_if)
+#else
+ void ifxusb_hard_reset_d(ifxusb_core_if_t *_core_if)
+#endif
+{
+ #if defined(__UEIP__)
+ #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ #if defined (__IS_HOST__)
+ clear_bit (DANUBE_USBCFG_HDSEL_BIT, (volatile unsigned long *)DANUBE_RCU_USBCFG);
+ #elif defined (__IS_DEVICE__)
+ set_bit (DANUBE_USBCFG_HDSEL_BIT, (volatile unsigned long *)DANUBE_RCU_USBCFG);
+ #endif
+ #endif //defined(__IS_AMAZON_SE__)
+
+ #if defined(__IS_AMAZON_SE__)
+ #if defined (__IS_HOST__)
+ clear_bit (AMAZON_SE_USBCFG_HDSEL_BIT, (volatile unsigned long *)AMAZON_SE_RCU_USBCFG);
+ #elif defined (__IS_DEVICE__)
+ set_bit (AMAZON_SE_USBCFG_HDSEL_BIT, (volatile unsigned long *)AMAZON_SE_RCU_USBCFG);
+ #endif
+ #endif //defined(__IS_AMAZON_SE__)
+
+ #if defined(__IS_AR9__)
+ if(_core_if->core_no==0)
+ {
+ #if defined (__IS_HOST__)
+ clear_bit (AR9_USBCFG_HDSEL_BIT, (volatile unsigned long *)AR9_RCU_USB1CFG);
+ #elif defined (__IS_DEVICE__)
+ set_bit (AR9_USBCFG_HDSEL_BIT, (volatile unsigned long *)AR9_RCU_USB1CFG);
+ #endif
+ }
+ else
+ {
+ #if defined (__IS_HOST__)
+ clear_bit (AR9_USBCFG_HDSEL_BIT, (volatile unsigned long *)AR9_RCU_USB2CFG);
+ #elif defined (__IS_DEVICE__)
+ set_bit (AR9_USBCFG_HDSEL_BIT, (volatile unsigned long *)AR9_RCU_USB2CFG);
+ #endif
+ }
+ #endif //defined(__IS_AR9__)
+
+ #if defined(__IS_VR9__)
+ if(!CheckAlready())
+ {
+ #if defined (__IS_HOST__)
+ #if defined (__IS_DUAL__)
+ clear_bit (VR9_USBCFG_HDSEL_BIT, (volatile unsigned long *)VR9_RCU_USB1CFG);
+ clear_bit (VR9_USBCFG_HDSEL_BIT, (volatile unsigned long *)VR9_RCU_USB2CFG);
+ #elif defined (__IS_FIRST__)
+ clear_bit (VR9_USBCFG_HDSEL_BIT, (volatile unsigned long *)VR9_RCU_USB1CFG);
+ set_bit (VR9_USBCFG_HDSEL_BIT, (volatile unsigned long *)VR9_RCU_USB2CFG);
+ #elif defined (__IS_SECOND__)
+ set_bit (VR9_USBCFG_HDSEL_BIT, (volatile unsigned long *)VR9_RCU_USB1CFG);
+ clear_bit (VR9_USBCFG_HDSEL_BIT, (volatile unsigned long *)VR9_RCU_USB2CFG);
+ #endif
+ #endif
+ #if defined (__IS_DEVICE__)
+ #if defined (__IS_FIRST__)
+ set_bit (VR9_USBCFG_HDSEL_BIT, (volatile unsigned long *)VR9_RCU_USB1CFG);
+ clear_bit (VR9_USBCFG_HDSEL_BIT, (volatile unsigned long *)VR9_RCU_USB2CFG);
+ #elif defined (__IS_SECOND__)
+ clear_bit (VR9_USBCFG_HDSEL_BIT, (volatile unsigned long *)VR9_RCU_USB1CFG);
+ set_bit (VR9_USBCFG_HDSEL_BIT, (volatile unsigned long *)VR9_RCU_USB2CFG);
+ #endif
+ #endif
+ }
+ #endif //defined(__IS_VR9__)
+
+ #if defined(__IS_AR10__)
+ if(!CheckAlready())
+ {
+ #if defined (__IS_HOST__)
+ #if defined (__IS_DUAL__)
+ clear_bit (AR10_USBCFG_HDSEL_BIT, (volatile unsigned long *)AR10_RCU_USB1CFG);
+ clear_bit (AR10_USBCFG_HDSEL_BIT, (volatile unsigned long *)AR10_RCU_USB2CFG);
+ #elif defined (__IS_FIRST__)
+ clear_bit (AR10_USBCFG_HDSEL_BIT, (volatile unsigned long *)AR10_RCU_USB1CFG);
+ set_bit (AR10_USBCFG_HDSEL_BIT, (volatile unsigned long *)AR10_RCU_USB2CFG);
+ #elif defined (__IS_SECOND__)
+ set_bit (AR10_USBCFG_HDSEL_BIT, (volatile unsigned long *)AR10_RCU_USB1CFG);
+ clear_bit (AR10_USBCFG_HDSEL_BIT, (volatile unsigned long *)AR10_RCU_USB2CFG);
+ #endif
+ #endif
+ #if defined (__IS_DEVICE__)
+ #if defined (__IS_FIRST__)
+ set_bit (AR10_USBCFG_HDSEL_BIT, (volatile unsigned long *)AR10_RCU_USB1CFG);
+ clear_bit (AR10_USBCFG_HDSEL_BIT, (volatile unsigned long *)AR10_RCU_USB2CFG);
+ #elif defined (__IS_SECOND__)
+ clear_bit (AR10_USBCFG_HDSEL_BIT, (volatile unsigned long *)AR10_RCU_USB1CFG);
+ set_bit (AR10_USBCFG_HDSEL_BIT, (volatile unsigned long *)AR10_RCU_USB2CFG);
+ #endif
+ #endif
+ }
+ #endif //defined(__IS_AR10__)
+
+ // set the HC's byte-order to big-endian
+ #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ set_bit (DANUBE_USBCFG_HOST_END_BIT, (volatile unsigned long *)DANUBE_RCU_USBCFG);
+ clear_bit (DANUBE_USBCFG_SLV_END_BIT, (volatile unsigned long *)DANUBE_RCU_USBCFG);
+ #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ #if defined(__IS_AMAZON_SE__)
+ set_bit (AMAZON_SE_USBCFG_HOST_END_BIT, (volatile unsigned long *)AMAZON_SE_RCU_USBCFG);
+ clear_bit (AMAZON_SE_USBCFG_SLV_END_BIT, (volatile unsigned long *)AMAZON_SE_RCU_USBCFG);
+ #endif //defined(__IS_AMAZON_SE__)
+ #if defined(__IS_AR9__)
+ if(_core_if->core_no==0)
+ {
+ set_bit (AR9_USBCFG_HOST_END_BIT, (volatile unsigned long *)AR9_RCU_USB1CFG);
+ clear_bit (AR9_USBCFG_SLV_END_BIT, (volatile unsigned long *)AR9_RCU_USB1CFG);
+ }
+ else
+ {
+ set_bit (AR9_USBCFG_HOST_END_BIT, (volatile unsigned long *)AR9_RCU_USB2CFG);
+ clear_bit (AR9_USBCFG_SLV_END_BIT, (volatile unsigned long *)AR9_RCU_USB2CFG);
+ }
+ #endif //defined(__IS_AR9__)
+ #if defined(__IS_VR9__)
+ if(_core_if->core_no==0)
+ {
+ set_bit (VR9_USBCFG_HOST_END_BIT, (volatile unsigned long *)VR9_RCU_USB1CFG);
+ clear_bit (VR9_USBCFG_SLV_END_BIT, (volatile unsigned long *)VR9_RCU_USB1CFG);
+ }
+ else
+ {
+ set_bit (VR9_USBCFG_HOST_END_BIT, (volatile unsigned long *)VR9_RCU_USB2CFG);
+ clear_bit (VR9_USBCFG_SLV_END_BIT, (volatile unsigned long *)VR9_RCU_USB2CFG);
+ }
+ #endif //defined(__IS_VR9__)
+ #if defined(__IS_AR10__)
+ if(_core_if->core_no==0)
+ {
+ set_bit (AR10_USBCFG_HOST_END_BIT, (volatile unsigned long *)AR10_RCU_USB1CFG);
+ clear_bit (AR10_USBCFG_SLV_END_BIT, (volatile unsigned long *)AR10_RCU_USB1CFG);
+ }
+ else
+ {
+ set_bit (AR10_USBCFG_HOST_END_BIT, (volatile unsigned long *)AR10_RCU_USB2CFG);
+ clear_bit (AR10_USBCFG_SLV_END_BIT, (volatile unsigned long *)AR10_RCU_USB2CFG);
+ }
+ #endif //defined(__IS_AR10__)
+
+ #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ set_bit (4, DANUBE_RCU_RESET);
+ MDELAY(50);
+ clear_bit (4, DANUBE_RCU_RESET);
+ MDELAY(50);
+ #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+
+ #if defined(__IS_AMAZON_SE__)
+ set_bit (4, AMAZON_SE_RCU_RESET);
+ MDELAY(50);
+ clear_bit (4, AMAZON_SE_RCU_RESET);
+ MDELAY(50);
+ #endif //defined(__IS_AMAZON_SE__)
+
+ #if defined(__IS_AR9__)
+ if(_core_if->core_no==0)
+ {
+ set_bit (4, AR9_RCU_USBRESET);
+ MDELAY(50);
+ clear_bit (4, AR9_RCU_USBRESET);
+ }
+ else
+ {
+ set_bit (28, AR9_RCU_USBRESET);
+ MDELAY(50);
+ clear_bit (28, AR9_RCU_USBRESET);
+ }
+ MDELAY(50);
+ #endif //defined(__IS_AR9__)
+ #if defined(__IS_VR9__)
+ if(!CheckAlready())
+ {
+ set_bit (4, VR9_RCU_USBRESET);
+ MDELAY(50);
+ clear_bit (4, VR9_RCU_USBRESET);
+ MDELAY(50);
+ }
+ #endif //defined(__IS_VR9__)
+ #if defined(__IS_AR10__)
+ if(!CheckAlready())
+ {
+ set_bit (4, AR10_RCU_USBRESET);
+ MDELAY(50);
+ clear_bit (4, AR10_RCU_USBRESET);
+ MDELAY(50);
+ }
+ #endif //defined(__IS_AR10__)
+
+ #if defined(__IS_TWINPASS__)
+ ifxusb_enable_afe_oc();
+ #endif
+
+ if(_core_if->core_global_regs)
+ {
+ // PHY configurations.
+ #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
+ #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ #if defined(__IS_AMAZON_SE__)
+ ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
+ #endif //defined(__IS_AMAZON_SE__)
+ #if defined(__IS_AR9__)
+ ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
+ #endif //defined(__IS_AR9__)
+ #if defined(__IS_VR9__)
+ // ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
+ #endif //defined(__IS_VR9__)
+ #if defined(__IS_AR10__)
+ // ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
+ #endif //defined(__IS_AR10__)
+ }
+ #else //defined(__UEIP__)
+ #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ #if defined (__IS_HOST__)
+ clear_bit (DANUBE_USBCFG_HDSEL_BIT, (volatile unsigned long *)DANUBE_RCU_USBCFG);
+ #elif defined (__IS_DEVICE__)
+ set_bit (DANUBE_USBCFG_HDSEL_BIT, (volatile unsigned long *)DANUBE_RCU_USBCFG);
+ #endif
+ #endif //defined(__IS_AMAZON_SE__)
+
+ #if defined(__IS_AMAZON_SE__)
+ #if defined (__IS_HOST__)
+ clear_bit (AMAZON_SE_USBCFG_HDSEL_BIT, (volatile unsigned long *)AMAZON_SE_RCU_USBCFG);
+ #elif defined (__IS_DEVICE__)
+ set_bit (AMAZON_SE_USBCFG_HDSEL_BIT, (volatile unsigned long *)AMAZON_SE_RCU_USBCFG);
+ #endif
+ #endif //defined(__IS_AMAZON_SE__)
+
+ #if defined(__IS_AR9__)
+ if(_core_if->core_no==0)
+ {
+ #if defined (__IS_HOST__)
+ clear_bit (AMAZON_S_USBCFG_HDSEL_BIT, (volatile unsigned long *)AMAZON_S_RCU_USB1CFG);
+ #elif defined (__IS_DEVICE__)
+ set_bit (AMAZON_S_USBCFG_HDSEL_BIT, (volatile unsigned long *)AMAZON_S_RCU_USB1CFG);
+ #endif
+ }
+ else
+ {
+ #if defined (__IS_HOST__)
+ clear_bit (AMAZON_S_USBCFG_HDSEL_BIT, (volatile unsigned long *)AMAZON_S_RCU_USB2CFG);
+ #elif defined (__IS_DEVICE__)
+ set_bit (AMAZON_S_USBCFG_HDSEL_BIT, (volatile unsigned long *)AMAZON_S_RCU_USB2CFG);
+ #endif
+ }
+ #endif //defined(__IS_AR9__)
+
+ // set the HC's byte-order to big-endian
+ #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ set_bit (DANUBE_USBCFG_HOST_END_BIT, (volatile unsigned long *)DANUBE_RCU_USBCFG);
+ clear_bit (DANUBE_USBCFG_SLV_END_BIT, (volatile unsigned long *)DANUBE_RCU_USBCFG);
+ #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ #if defined(__IS_AMAZON_SE__)
+ set_bit (AMAZON_SE_USBCFG_HOST_END_BIT, (volatile unsigned long *)AMAZON_SE_RCU_USBCFG);
+ clear_bit (AMAZON_SE_USBCFG_SLV_END_BIT, (volatile unsigned long *)AMAZON_SE_RCU_USBCFG);
+ #endif //defined(__IS_AMAZON_SE__)
+ #if defined(__IS_AR9__)
+ if(_core_if->core_no==0)
+ {
+ set_bit (AMAZON_S_USBCFG_HOST_END_BIT, (volatile unsigned long *)AMAZON_S_RCU_USB1CFG);
+ clear_bit (AMAZON_S_USBCFG_SLV_END_BIT, (volatile unsigned long *)AMAZON_S_RCU_USB1CFG);
+ }
+ else
+ {
+ set_bit (AMAZON_S_USBCFG_HOST_END_BIT, (volatile unsigned long *)AMAZON_S_RCU_USB2CFG);
+ clear_bit (AMAZON_S_USBCFG_SLV_END_BIT, (volatile unsigned long *)AMAZON_S_RCU_USB2CFG);
+ }
+ #endif //defined(__IS_AR9__)
+
+ #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ set_bit (4, DANUBE_RCU_RESET);
+ #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ #if defined(__IS_AMAZON_SE__)
+ set_bit (4, AMAZON_SE_RCU_RESET);
+ #endif //defined(__IS_AMAZON_SE__)
+ #if defined(__IS_AR9__)
+ if(_core_if->core_no==0)
+ {
+ set_bit (4, AMAZON_S_RCU_USBRESET);
+ }
+ else
+ {
+ set_bit (28, AMAZON_S_RCU_USBRESET);
+ }
+ #endif //defined(__IS_AR9__)
+
+ MDELAY(50);
+
+ #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ clear_bit (4, DANUBE_RCU_RESET);
+ #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ #if defined(__IS_AMAZON_SE__)
+ clear_bit (4, AMAZON_SE_RCU_RESET);
+ #endif //defined(__IS_AMAZON_SE__)
+ #if defined(__IS_AR9__)
+ if(_core_if->core_no==0)
+ {
+ clear_bit (4, AMAZON_S_RCU_USBRESET);
+ }
+ else
+ {
+ clear_bit (28, AMAZON_S_RCU_USBRESET);
+ }
+ #endif //defined(__IS_AR9__)
+
+ MDELAY(50);
+
+ #if defined(__IS_TWINPASS__)
+ ifxusb_enable_afe_oc();
+ #endif
+
+ if(_core_if->core_global_regs)
+ {
+ // PHY configurations.
+ #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
+ #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ #if defined(__IS_AMAZON_SE__)
+ ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
+ #endif //defined(__IS_AMAZON_SE__)
+ #if defined(__IS_AR9__)
+ ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
+ #endif //defined(__IS_AR9__)
+ }
+ #endif //defined(__UEIP__)
+}
+
+#if defined(__GADGET_LED__) || defined(__HOST_LED__)
+ #if defined(__UEIP__)
+ static void *g_usb_led_trigger = NULL;
+ #endif
+
+ void ifxusb_led_init(ifxusb_core_if_t *_core_if)
+ {
+ #if defined(__UEIP__)
+ #if defined(IFX_LEDGPIO_USB_LED) || defined(IFX_LEDLED_USB_LED)
+ if ( !g_usb_led_trigger )
+ {
+ ifx_led_trigger_register("usb_link", &g_usb_led_trigger);
+ if ( g_usb_led_trigger != NULL )
+ {
+ struct ifx_led_trigger_attrib attrib = {0};
+ attrib.delay_on = 250;
+ attrib.delay_off = 250;
+ attrib.timeout = 2000;
+ attrib.def_value = 1;
+ attrib.flags = IFX_LED_TRIGGER_ATTRIB_DELAY_ON | IFX_LED_TRIGGER_ATTRIB_DELAY_OFF | IFX_LED_TRIGGER_ATTRIB_TIMEOUT | IFX_LED_TRIGGER_ATTRIB_DEF_VALUE;
+ IFX_DEBUGP("Reg USB LED!!\n");
+ ifx_led_trigger_set_attrib(g_usb_led_trigger, &attrib);
+ }
+ }
+ #endif
+ #endif //defined(__UEIP__)
+ }
+
+ void ifxusb_led_free(ifxusb_core_if_t *_core_if)
+ {
+ #if defined(__UEIP__)
+ if ( g_usb_led_trigger )
+ {
+ ifx_led_trigger_deregister(g_usb_led_trigger);
+ g_usb_led_trigger = NULL;
+ }
+ #endif //defined(__UEIP__)
+ }
+
+ /*!
+ \brief Turn off the USB 5V VBus Power
+ \param _core_if Pointer of core_if structure
+ */
+ void ifxusb_led(ifxusb_core_if_t *_core_if)
+ {
+ #if defined(__UEIP__)
+ if(g_usb_led_trigger)
+ ifx_led_trigger_activate(g_usb_led_trigger);
+ #else
+ #endif //defined(__UEIP__)
+ }
+#endif // defined(__GADGET_LED__) || defined(__HOST_LED__)
+
+
+
+/*!
+ \brief internal routines for debugging
+ */
+#ifdef __IS_HOST__
+void ifxusb_dump_msg_h(const u8 *buf, unsigned int length)
+#else
+void ifxusb_dump_msg_d(const u8 *buf, unsigned int length)
+#endif
+{
+#ifdef __DEBUG__
+ unsigned int start, num, i;
+ char line[52], *p;
+
+ if (length >= 512)
+ return;
+ start = 0;
+ while (length > 0)
+ {
+ num = min(length, 16u);
+ p = line;
+ for (i = 0; i < num; ++i)
+ {
+ if (i == 8)
+ *p++ = ' ';
+ sprintf(p, " %02x", buf[i]);
+ p += 3;
+ }
+ *p = 0;
+ IFX_PRINT( "%6x: %s\n", start, line);
+ buf += num;
+ start += num;
+ length -= num;
+ }
+#endif
+}
+
+/*!
+ \brief internal routines for debugging, reads the SPRAM and prints its content
+ */
+#ifdef __IS_HOST__
+void ifxusb_dump_spram_h(ifxusb_core_if_t *_core_if)
+#else
+void ifxusb_dump_spram_d(ifxusb_core_if_t *_core_if)
+#endif
+{
+#ifdef __ENABLE_DUMP__
+ volatile uint8_t *addr, *start_addr, *end_addr;
+ uint32_t size;
+ IFX_PRINT("SPRAM Data:\n");
+ start_addr = (void*)_core_if->core_global_regs;
+ IFX_PRINT("Base Address: 0x%8X\n", (uint32_t)start_addr);
+
+ start_addr = (void*)_core_if->data_fifo_dbg;
+ IFX_PRINT("Starting Address: 0x%8X\n", (uint32_t)start_addr);
+
+ size=_core_if->hwcfg3.b.dfifo_depth;
+ size<<=2;
+ size+=0x200;
+ size&=0x0003FFFC;
+
+ end_addr = (void*)_core_if->data_fifo_dbg;
+ end_addr += size;
+
+ for(addr = start_addr; addr < end_addr; addr+=16)
+ {
+ IFX_PRINT("0x%8X: %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X \n", (uint32_t)addr,
+ addr[ 0], addr[ 1], addr[ 2], addr[ 3],
+ addr[ 4], addr[ 5], addr[ 6], addr[ 7],
+ addr[ 8], addr[ 9], addr[10], addr[11],
+ addr[12], addr[13], addr[14], addr[15]
+ );
+ }
+ return;
+#endif //__ENABLE_DUMP__
+}
+
+/*!
+ \brief internal routines for debugging, reads the core global registers and prints them
+ */
+#ifdef __IS_HOST__
+void ifxusb_dump_registers_h(ifxusb_core_if_t *_core_if)
+#else
+void ifxusb_dump_registers_d(ifxusb_core_if_t *_core_if)
+#endif
+{
+#ifdef __ENABLE_DUMP__
+ int i;
+ volatile uint32_t *addr;
+ #ifdef __IS_DEVICE__
+ volatile uint32_t *addri,*addro;
+ #endif
+
+ IFX_PRINT("Core #%d\n",_core_if->core_no);
+ IFX_PRINT("========================================\n");
+ IFX_PRINT("Core Global Registers\n");
+ addr=&_core_if->core_global_regs->gotgctl;
+ IFX_PRINT(" GOTGCTL @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->core_global_regs->gotgint;
+ IFX_PRINT(" GOTGINT @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->core_global_regs->gahbcfg;
+ IFX_PRINT(" GAHBCFG @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->core_global_regs->gusbcfg;
+ IFX_PRINT(" GUSBCFG @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->core_global_regs->grstctl;
+ IFX_PRINT(" GRSTCTL @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->core_global_regs->gintsts;
+ IFX_PRINT(" GINTSTS @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->core_global_regs->gintmsk;
+ IFX_PRINT(" GINTMSK @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->core_global_regs->gi2cctl;
+ IFX_PRINT(" GI2CCTL @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->core_global_regs->gpvndctl;
+ IFX_PRINT(" GPVNDCTL @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->core_global_regs->ggpio;
+ IFX_PRINT(" GGPIO @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->core_global_regs->guid;
+ IFX_PRINT(" GUID @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->core_global_regs->gsnpsid;
+ IFX_PRINT(" GSNPSID @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->core_global_regs->ghwcfg1;
+ IFX_PRINT(" GHWCFG1 @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->core_global_regs->ghwcfg2;
+ IFX_PRINT(" GHWCFG2 @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->core_global_regs->ghwcfg3;
+ IFX_PRINT(" GHWCFG3 @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->core_global_regs->ghwcfg4;
+ IFX_PRINT(" GHWCFG4 @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+
+ addr=_core_if->pcgcctl;
+ IFX_PRINT(" PCGCCTL @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+
+ addr=&_core_if->core_global_regs->grxfsiz;
+ IFX_PRINT(" GRXFSIZ @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+
+ #ifdef __IS_HOST__
+ addr=&_core_if->core_global_regs->gnptxfsiz;
+ IFX_PRINT(" GNPTXFSIZ @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->core_global_regs->hptxfsiz;
+ IFX_PRINT(" HPTXFSIZ @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ #endif //__IS_HOST__
+
+ #ifdef __IS_DEVICE__
+ #ifdef __DED_FIFO__
+ addr=&_core_if->core_global_regs->gnptxfsiz;
+ IFX_PRINT(" GNPTXFSIZ @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ for (i=0; i<= _core_if->hwcfg4.b.num_in_eps; i++)
+ {
+ addr=&_core_if->core_global_regs->dptxfsiz_dieptxf[i];
+ IFX_PRINT(" DPTXFSIZ[%d] @0x%08X : 0x%08X\n",i,(uint32_t)addr,ifxusb_rreg(addr));
+ }
+ #else
+ addr=&_core_if->core_global_regs->gnptxfsiz;
+ IFX_PRINT(" TXFSIZ[00] @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ for (i=0; i< _core_if->hwcfg4.b.num_dev_perio_in_ep; i++)
+ {
+ addr=&_core_if->core_global_regs->dptxfsiz_dieptxf[i];
+ IFX_PRINT(" TXFSIZ[%02d] @0x%08X : 0x%08X\n",i+1,(uint32_t)addr,ifxusb_rreg(addr));
+ }
+ #endif
+ #endif //__IS_DEVICE__
+
+ #ifdef __IS_HOST__
+ IFX_PRINT(" Host Global Registers\n");
+ addr=&_core_if->host_global_regs->hcfg;
+ IFX_PRINT(" HCFG @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->host_global_regs->hfir;
+ IFX_PRINT(" HFIR @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->host_global_regs->hfnum;
+ IFX_PRINT(" HFNUM @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->host_global_regs->hptxsts;
+ IFX_PRINT(" HPTXSTS @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->host_global_regs->haint;
+ IFX_PRINT(" HAINT @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->host_global_regs->haintmsk;
+ IFX_PRINT(" HAINTMSK @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr= _core_if->hprt0;
+ IFX_PRINT(" HPRT0 @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+
+ for (i=0; i<MAX_EPS_CHANNELS; i++)
+ {
+ addr=&_core_if->hc_regs[i]->hcchar;
+ IFX_PRINT(" Host Channel %d Specific Registers\n", i);
+ IFX_PRINT(" HCCHAR @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->hc_regs[i]->hcsplt;
+ IFX_PRINT(" HCSPLT @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->hc_regs[i]->hcint;
+ IFX_PRINT(" HCINT @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->hc_regs[i]->hcintmsk;
+ IFX_PRINT(" HCINTMSK @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->hc_regs[i]->hctsiz;
+ IFX_PRINT(" HCTSIZ @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->hc_regs[i]->hcdma;
+ IFX_PRINT(" HCDMA @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ }
+ #endif //__IS_HOST__
+
+ #ifdef __IS_DEVICE__
+ IFX_PRINT(" Device Global Registers\n");
+ addr=&_core_if->dev_global_regs->dcfg;
+ IFX_PRINT(" DCFG @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->dev_global_regs->dctl;
+ IFX_PRINT(" DCTL @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->dev_global_regs->dsts;
+ IFX_PRINT(" DSTS @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->dev_global_regs->diepmsk;
+ IFX_PRINT(" DIEPMSK @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->dev_global_regs->doepmsk;
+ IFX_PRINT(" DOEPMSK @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->dev_global_regs->daintmsk;
+ IFX_PRINT(" DAINTMSK @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->dev_global_regs->daint;
+ IFX_PRINT(" DAINT @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->dev_global_regs->dvbusdis;
+ IFX_PRINT(" DVBUSID @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->dev_global_regs->dvbuspulse;
+ IFX_PRINT(" DVBUSPULS @0x%08X : 0x%08X\n", (uint32_t)addr,ifxusb_rreg(addr));
+
+ addr=&_core_if->dev_global_regs->dtknqr1;
+ IFX_PRINT(" DTKNQR1 @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ if (_core_if->hwcfg2.b.dev_token_q_depth > 6) {
+ addr=&_core_if->dev_global_regs->dtknqr2;
+ IFX_PRINT(" DTKNQR2 @0x%08X : 0x%08X\n", (uint32_t)addr,ifxusb_rreg(addr));
+ }
+
+ if (_core_if->hwcfg2.b.dev_token_q_depth > 14)
+ {
+ addr=&_core_if->dev_global_regs->dtknqr3_dthrctl;
+ IFX_PRINT(" DTKNQR3_DTHRCTL @0x%08X : 0x%08X\n", (uint32_t)addr, ifxusb_rreg(addr));
+ }
+
+ if (_core_if->hwcfg2.b.dev_token_q_depth > 22)
+ {
+ addr=&_core_if->dev_global_regs->dtknqr4_fifoemptymsk;
+ IFX_PRINT(" DTKNQR4 @0x%08X : 0x%08X\n", (uint32_t)addr, ifxusb_rreg(addr));
+ }
+
+ //for (i=0; i<= MAX_EPS_CHANNELS; i++)
+ //for (i=0; i<= 10; i++)
+ for (i=0; i<= 3; i++)
+ {
+ IFX_PRINT(" Device EP %d Registers\n", i);
+ addri=&_core_if->in_ep_regs[i]->diepctl;addro=&_core_if->out_ep_regs[i]->doepctl;
+ IFX_PRINT(" DEPCTL I: 0x%08X O: 0x%08X\n",ifxusb_rreg(addri),ifxusb_rreg(addro));
+ addro=&_core_if->out_ep_regs[i]->doepfn;
+ IFX_PRINT(" DEPFN I: O: 0x%08X\n",ifxusb_rreg(addro));
+ addri=&_core_if->in_ep_regs[i]->diepint;addro=&_core_if->out_ep_regs[i]->doepint;
+ IFX_PRINT(" DEPINT I: 0x%08X O: 0x%08X\n",ifxusb_rreg(addri),ifxusb_rreg(addro));
+ addri=&_core_if->in_ep_regs[i]->dieptsiz;addro=&_core_if->out_ep_regs[i]->doeptsiz;
+ IFX_PRINT(" DETSIZ I: 0x%08X O: 0x%08X\n",ifxusb_rreg(addri),ifxusb_rreg(addro));
+ addri=&_core_if->in_ep_regs[i]->diepdma;addro=&_core_if->out_ep_regs[i]->doepdma;
+ IFX_PRINT(" DEPDMA I: 0x%08X O: 0x%08X\n",ifxusb_rreg(addri),ifxusb_rreg(addro));
+ addri=&_core_if->in_ep_regs[i]->dtxfsts;
+ IFX_PRINT(" DTXFSTS I: 0x%08X\n",ifxusb_rreg(addri) );
+ addri=&_core_if->in_ep_regs[i]->diepdmab;addro=&_core_if->out_ep_regs[i]->doepdmab;
+ IFX_PRINT(" DEPDMAB I: 0x%08X O: 0x%08X\n",ifxusb_rreg(addri),ifxusb_rreg(addro));
+ }
+ #endif //__IS_DEVICE__
+#endif //__ENABLE_DUMP__
+}
+
+#ifdef __IS_HOST__
+void do_suspend_h(ifxusb_core_if_t *core_if)
+{
+ ifxusb_vbus_off(core_if);
+ mdelay(100);
+ ifxusb_power_off_h(core_if);
+}
+void do_resume_h(ifxusb_core_if_t *core_if)
+{
+ ifxusb_vbus_on(core_if);
+ mdelay(100);
+ ifxusb_power_on_h(core_if);
+ ifxusb_phy_power_on_h(core_if);
+}
+#endif
+#ifdef __IS_DEVICE__
+void do_suspend_d(ifxusb_core_if_t *core_if)
+{
+ ifxusb_power_off_d(core_if);
+}
+void do_resume_d(ifxusb_core_if_t *core_if)
+{
+ dctl_data_t dctl = {.d32=0};
+
+ ifxusb_power_on_d(core_if);
+ ifxusb_phy_power_on_d(core_if);
+ dctl.d32=ifxusb_rreg(&core_if->dev_global_regs->dctl);
+ dctl.b.sftdiscon=1;
+ ifxusb_wreg(&core_if->dev_global_regs->dctl,dctl.d32);
+ mdelay(50);
+ dctl.b.sftdiscon=0;
+ ifxusb_wreg(&core_if->dev_global_regs->dctl,dctl.d32);
+}
+#endif
+
diff --git a/package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxusb_cif.h.svn-base b/package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxusb_cif.h.svn-base
new file mode 100644
index 0000000..5af988f
--- /dev/null
+++ b/package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxusb_cif.h.svn-base
@@ -0,0 +1,767 @@
+/*****************************************************************************
+ ** FILE NAME : ifxusb_cif.h
+ ** PROJECT : IFX USB sub-system V3
+ ** MODULES : IFX USB sub-system Host and Device driver
+ ** SRC VERSION : 3.2
+ ** DATE : 1/Jan/2011
+ ** AUTHOR : Chen, Howard
+ ** DESCRIPTION : The Core Interface provides basic services for accessing and
+ ** managing the IFX USB hardware. These services are used by both the
+ ** Host Controller Driver and the Peripheral Controller Driver.
+ ** FUNCTIONS :
+ ** COMPILER : gcc
+ ** REFERENCE : Synopsys DWC-OTG Driver 2.7
+ ** COPYRIGHT : Copyright (c) 2010
+ ** LANTIQ DEUTSCHLAND GMBH,
+ ** Am Campeon 3, 85579 Neubiberg, Germany
+ **
+ ** 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 of the License, or
+ ** (at your option) any later version.
+ **
+ ** Version Control Section **
+ ** $Author$
+ ** $Date$
+ ** $Revisions$
+ ** $Log$ Revision history
+ *****************************************************************************/
+
+/*
+ * This file contains code fragments from Synopsys HS OTG Linux Software Driver.
+ * For this code the following notice is applicable:
+ *
+ * ==========================================================================
+ *
+ * Synopsys HS OTG Linux Software Driver and documentation (hereinafter,
+ * "Software") is an Unsupported proprietary work of Synopsys, Inc. unless
+ * otherwise expressly agreed to in writing between Synopsys and you.
+ *
+ * The Software IS NOT an item of Licensed Software or Licensed Product under
+ * any End User Software License Agreement or Agreement for Licensed Product
+ * with Synopsys or any supplement thereto. You are permitted to use and
+ * redistribute this Software in source and binary forms, with or without
+ * modification, provided that redistributions of source code must retain this
+ * notice. You may not view, use, disclose, copy or distribute this file or
+ * any information contained herein except pursuant to this license grant from
+ * Synopsys. If you do not agree with this notice, including the disclaimer
+ * below, then you are not authorized to use the Software.
+ *
+ * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" BASIS
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ * ========================================================================== */
+
+/*!
+ \defgroup IFXUSB_DRIVER_V3 IFX USB SS Project
+ \brief IFX USB subsystem V3.x
+ */
+
+/*!
+ \defgroup IFXUSB_CIF Core Interface APIs
+ \ingroup IFXUSB_DRIVER_V3
+ \brief The Core Interface provides basic services for accessing and
+ managing the IFXUSB hardware. These services are used by both the
+ Host Controller Driver and the Peripheral Controller Driver.
+ */
+
+
+/*!
+ \file ifxusb_cif.h
+ \ingroup IFXUSB_DRIVER_V3
+ \brief This file contains the interface to the IFX USB Core.
+ */
+
+#if !defined(__IFXUSB_CIF_H__)
+#define __IFXUSB_CIF_H__
+
+#include <linux/workqueue.h>
+
+#include <linux/version.h>
+#include <asm/param.h>
+
+#include "ifxusb_plat.h"
+#include "ifxusb_regs.h"
+
+#ifdef __DEBUG__
+ #include "linux/timer.h"
+#endif
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#define IFXUSB_PARAM_SPEED_HIGH 0 /*!< Build stage parameter: High Speed */
+#define IFXUSB_PARAM_SPEED_FULL 1 /*!< Build stage parameter: Full Speed */
+
+#define IFXUSB_EP_SPEED_LOW 0 /*!< Run-Time Status: High Speed */
+#define IFXUSB_EP_SPEED_FULL 1 /*!< Run-Time Status: Full Speed */
+#define IFXUSB_EP_SPEED_HIGH 2 /*!< Run-Time Status: Low Speed */
+
+#define IFXUSB_EP_TYPE_CTRL 0 /*!< Run-Time Status: CTRL */
+#define IFXUSB_EP_TYPE_ISOC 1 /*!< Run-Time Status: ISOC */
+#define IFXUSB_EP_TYPE_BULK 2 /*!< Run-Time Status: BULK */
+#define IFXUSB_EP_TYPE_INTR 3 /*!< Run-Time Status: INTR */
+
+#define IFXUSB_HC_PID_DATA0 0 /*!< Run-Time Data Toggle: Data 0 */
+#define IFXUSB_HC_PID_DATA2 1 /*!< Run-Time Data Toggle: Data 2 */
+#define IFXUSB_HC_PID_DATA1 2 /*!< Run-Time Data Toggle: Data 1 */
+#define IFXUSB_HC_PID_MDATA 3 /*!< Run-Time Data Toggle: MData */
+#define IFXUSB_HC_PID_SETUP 3 /*!< Run-Time Data Toggle: Setup */
+
+
+/*!
+ \addtogroup IFXUSB_CIF
+ */
+/*@{*/
+
+/*! typedef ifxusb_params_t
+ \brief IFXUSB Parameters structure.
+ This structure is used for both importing from insmod stage and run-time storage.
+ These parameters define how the IFXUSB controller should be configured.
+ */
+typedef struct ifxusb_params
+{
+ int32_t dma_burst_size; /*!< The DMA Burst size (applicable only for Internal DMA
+ Mode). 0(for single), 1(incr), 4(incr4), 8(incr8) 16(incr16)
+ */
+ /* Translate this to GAHBCFG values */
+ int32_t speed; /*!< Specifies the maximum speed of operation in host and device mode.
+ The actual speed depends on the speed of the attached device and
+ the value of phy_type. The actual speed depends on the speed of the
+ attached device.
+ 0 - High Speed (default)
+ 1 - Full Speed
+ */
+
+ int32_t data_fifo_size; /*!< Total number of dwords in the data FIFO memory. This
+ memory includes the Rx FIFO, non-periodic Tx FIFO, and periodic
+ Tx FIFOs.
+ 32 to 32768
+ */
+ #ifdef __IS_DEVICE__
+ int32_t rx_fifo_size; /*!< Number of dwords in the Rx FIFO in device mode.
+ 16 to 32768
+ */
+
+
+ int32_t tx_fifo_size[MAX_EPS_CHANNELS]; /*!< Number of dwords in each of the Tx FIFOs in device mode.
+ 4 to 768
+ */
+ #ifdef __DED_FIFO__
+ int32_t thr_ctl; /*!< Threshold control on/off */
+ int32_t tx_thr_length; /*!< Threshold length for Tx */
+ int32_t rx_thr_length; /*!< Threshold length for Rx*/
+ #endif
+ #else //__IS_HOST__
+ int32_t host_channels; /*!< The number of host channel registers to use.
+ 1 to 16
+ */
+
+ int32_t rx_fifo_size; /*!< Number of dwords in the Rx FIFO in host mode.
+ 16 to 32768
+ */
+
+ int32_t nperio_tx_fifo_size;/*!< Number of dwords in the non-periodic Tx FIFO in host mode.
+ 16 to 32768
+ */
+
+ int32_t perio_tx_fifo_size; /*!< Number of dwords in the host periodic Tx FIFO.
+ 16 to 32768
+ */
+ #endif //__IS_HOST__
+
+ int32_t max_transfer_size; /*!< The maximum transfer size supported in bytes.
+ 2047 to 65,535
+ */
+
+ int32_t max_packet_count; /*!< The maximum number of packets in a transfer.
+ 15 to 511 (default 511)
+ */
+ int32_t phy_utmi_width; /*!< Specifies the UTMI+ Data Width.
+ 8 or 16 bits (default 16)
+ */
+
+ int32_t turn_around_time_hs; /*!< Specifies the Turn-Around time at HS*/
+ int32_t turn_around_time_fs; /*!< Specifies the Turn-Around time at FS*/
+
+ int32_t timeout_cal_hs; /*!< Specifies the Timeout_Calibration at HS*/
+ int32_t timeout_cal_fs; /*!< Specifies the Timeout_Calibration at FS*/
+} ifxusb_params_t;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+/*! typedef ifxusb_core_if_t
+ \brief The ifx_core_if structure contains information needed to manage
+ the IFX USB controller acting in either host or device mode. It
+ represents the programming view of the controller as a whole.
+ */
+typedef struct ifxusb_core_if
+{
+ ifxusb_params_t params; /*!< Run-time Parameters */
+
+ uint8_t core_no; /*!< core number (used as id when multi-core case */
+ char *core_name; /*!< core name used for registration and informative purpose*/
+ int irq; /*!< irq number this core is hooked */
+
+ /*****************************************************************
+ * Structures and pointers to physical register interface.
+ *****************************************************************/
+ /** Core Global registers starting at offset 000h. */
+ ifxusb_core_global_regs_t *core_global_regs; /*!< pointer to Core Global Registers, offset at 000h */
+
+ /** Host-specific registers */
+ #ifdef __IS_HOST__
+ /** Host Global Registers starting at offset 400h.*/
+ ifxusb_host_global_regs_t *host_global_regs; /*!< pointer to Host Global Registers, offset at 400h */
+ #define IFXUSB_HOST_GLOBAL_REG_OFFSET 0x400
+ /** Host Port 0 Control and Status Register */
+ volatile uint32_t *hprt0; /*!< pointer to HPRT0 Registers, offset at 440h */
+ #define IFXUSB_HOST_PORT_REGS_OFFSET 0x440
+ /** Host Channel Specific Registers at offsets 500h-5FCh. */
+ ifxusb_hc_regs_t *hc_regs[MAX_EPS_CHANNELS]; /*!< pointer to Host-Channel n Registers, offset at 500h */
+ #define IFXUSB_HOST_CHAN_REGS_OFFSET 0x500
+ #define IFXUSB_CHAN_REGS_OFFSET 0x20
+ #endif
+
+ /** Device-specific registers */
+ #ifdef __IS_DEVICE__
+ /** Device Global Registers starting at offset 800h */
+ ifxusb_device_global_regs_t *dev_global_regs; /*!< pointer to Device Global Registers, offset at 800h */
+ #define IFXUSB_DEV_GLOBAL_REG_OFFSET 0x800
+
+ /** Device Logical IN Endpoint-Specific Registers 900h-AFCh */
+ ifxusb_dev_in_ep_regs_t *in_ep_regs[MAX_EPS_CHANNELS]; /*!< pointer to Device IN-EP Registers, offset at 900h */
+ #define IFXUSB_DEV_IN_EP_REG_OFFSET 0x900
+ #define IFXUSB_EP_REG_OFFSET 0x20
+ /** Device Logical OUT Endpoint-Specific Registers B00h-CFCh */
+ ifxusb_dev_out_ep_regs_t *out_ep_regs[MAX_EPS_CHANNELS];/*!< pointer to Device OUT-EP Registers, offset at 900h */
+ #define IFXUSB_DEV_OUT_EP_REG_OFFSET 0xB00
+ #endif
+
+ /** Power and Clock Gating Control Register */
+ volatile uint32_t *pcgcctl; /*!< pointer to Power and Clock Gating Control Registers, offset at E00h */
+ #define IFXUSB_PCGCCTL_OFFSET 0xE00
+
+ /** Push/pop addresses for endpoints or host channels.*/
+ uint32_t *data_fifo[MAX_EPS_CHANNELS]; /*!< pointer to FIFO access windows, offset at 1000h */
+ #define IFXUSB_DATA_FIFO_OFFSET 0x1000
+ #define IFXUSB_DATA_FIFO_SIZE 0x1000
+
+ uint32_t *data_fifo_dbg; /*!< pointer to FIFO debug windows, offset at 1000h */
+
+ /** Hardware Configuration -- stored here for convenience.*/
+ hwcfg1_data_t hwcfg1; /*!< preserved Hardware Configuration 1 */
+ hwcfg2_data_t hwcfg2; /*!< preserved Hardware Configuration 2 */
+ hwcfg3_data_t hwcfg3; /*!< preserved Hardware Configuration 3 */
+ hwcfg4_data_t hwcfg4; /*!< preserved Hardware Configuration 3 */
+ uint32_t snpsid; /*!< preserved SNPSID */
+
+ /*****************************************************************
+ * Run-time informations.
+ *****************************************************************/
+ /* Set to 1 if the core PHY interface bits in USBCFG have been initialized. */
+ uint8_t phy_init_done; /*!< indicated PHY is initialized. */
+
+ #ifdef __IS_HOST__
+ uint8_t queuing_high_bandwidth; /*!< Host mode, Queueing High Bandwidth. */
+ #endif
+
+ #if defined(__UNALIGNED_BUF_ADJ__) || defined(__UNALIGNED_BUF_CHK__)
+ uint32_t unaligned_mask;
+ #endif
+} ifxusb_core_if_t;
+
+/*@}*//*IFXUSB_CIF*/
+
+
+/*!
+ \fn void *ifxusb_alloc_buf(size_t size, int clear)
+ \brief This function is called to allocate buffer of specified size.
+ The allocated buffer is mapped into DMA accessable address.
+ \param size Size in BYTE to be allocated
+ \param clear 0: don't do clear after buffer allocated, other: do clear to zero
+ \return 0/NULL: Fail; uncached pointer of allocated buffer
+ \ingroup IFXUSB_CIF
+ */
+#ifdef __IS_HOST__
+extern void *ifxusb_alloc_buf_h(size_t size, int clear);
+#else
+extern void *ifxusb_alloc_buf_d(size_t size, int clear);
+#endif
+
+
+/*!
+ \fn void ifxusb_free_buf(void *vaddr)
+ \brief This function is called to free allocated buffer.
+ \param vaddr the uncached pointer of the buffer
+ \ingroup IFXUSB_CIF
+ */
+#ifdef __IS_HOST__
+extern void ifxusb_free_buf_h(void *vaddr);
+#else
+extern void ifxusb_free_buf_d(void *vaddr);
+#endif
+
+/*!
+ \fn int ifxusb_core_if_init(ifxusb_core_if_t *_core_if,
+ int _irq,
+ uint32_t _reg_base_addr,
+ uint32_t _fifo_base_addr,
+ uint32_t _fifo_dbg_addr)
+ \brief This function is called to initialize the IFXUSB CSR data
+ structures. The register addresses in the device and host
+ structures are initialized from the base address supplied by the
+ caller. The calling function must make the OS calls to get the
+ base address of the IFXUSB controller registers.
+ \param _core_if Pointer of core_if structure
+ \param _irq irq number
+ \param _reg_base_addr Base address of IFXUSB core registers
+ \param _fifo_base_addr Fifo base address
+ \param _fifo_dbg_addr Fifo debug address
+ \return 0: success;
+ \ingroup IFXUSB_CIF
+ */
+#ifdef __IS_HOST__
+extern int ifxusb_core_if_init_h(ifxusb_core_if_t *_core_if,
+#else
+extern int ifxusb_core_if_init_d(ifxusb_core_if_t *_core_if,
+#endif
+ int _irq,
+ uint32_t _reg_base_addr,
+ uint32_t _fifo_base_addr,
+ uint32_t _fifo_dbg_addr);
+
+
+/*!
+ \fn void ifxusb_core_if_remove(ifxusb_core_if_t *_core_if)
+ \brief This function free the mapped address in the IFXUSB CSR data structures.
+ \param _core_if Pointer of core_if structure
+ \ingroup IFXUSB_CIF
+ */
+#ifdef __IS_HOST__
+extern void ifxusb_core_if_remove_h(ifxusb_core_if_t *_core_if);
+#else
+extern void ifxusb_core_if_remove_d(ifxusb_core_if_t *_core_if);
+#endif
+
+/*!
+ \fn void ifxusb_enable_global_interrupts( ifxusb_core_if_t *_core_if )
+ \brief This function enbles the controller's Global Interrupt in the AHB Config register.
+ \param _core_if Pointer of core_if structure
+ */
+#ifdef __IS_HOST__
+extern void ifxusb_enable_global_interrupts_h( ifxusb_core_if_t *_core_if );
+#else
+extern void ifxusb_enable_global_interrupts_d( ifxusb_core_if_t *_core_if );
+#endif
+
+/*!
+ \fn void ifxusb_disable_global_interrupts( ifxusb_core_if_t *_core_if )
+ \brief This function disables the controller's Global Interrupt in the AHB Config register.
+ \param _core_if Pointer of core_if structure
+ \ingroup IFXUSB_CIF
+ */
+#ifdef __IS_HOST__
+extern void ifxusb_disable_global_interrupts_h( ifxusb_core_if_t *_core_if );
+#else
+extern void ifxusb_disable_global_interrupts_d( ifxusb_core_if_t *_core_if );
+#endif
+
+/*!
+ \fn void ifxusb_flush_tx_fifo( ifxusb_core_if_t *_core_if, const int _num )
+ \brief Flush a Tx FIFO.
+ \param _core_if Pointer of core_if structure
+ \param _num Tx FIFO to flush. ( 0x10 for ALL TX FIFO )
+ \ingroup IFXUSB_CIF
+ */
+#ifdef __IS_HOST__
+extern void ifxusb_flush_tx_fifo_h( ifxusb_core_if_t *_core_if, const int _num );
+#else
+extern void ifxusb_flush_tx_fifo_d( ifxusb_core_if_t *_core_if, const int _num );
+#endif
+
+/*!
+ \fn void ifxusb_flush_rx_fifo( ifxusb_core_if_t *_core_if )
+ \brief Flush Rx FIFO.
+ \param _core_if Pointer of core_if structure
+ \ingroup IFXUSB_CIF
+ */
+#ifdef __IS_HOST__
+extern void ifxusb_flush_rx_fifo_h( ifxusb_core_if_t *_core_if );
+#else
+extern void ifxusb_flush_rx_fifo_d( ifxusb_core_if_t *_core_if );
+#endif
+
+/*!
+ \fn void ifxusb_flush_both_fifo( ifxusb_core_if_t *_core_if )
+ \brief Flush ALL Rx and Tx FIFO.
+ \param _core_if Pointer of core_if structure
+ \ingroup IFXUSB_CIF
+ */
+#ifdef __IS_HOST__
+extern void ifxusb_flush_both_fifo_h( ifxusb_core_if_t *_core_if );
+#else
+extern void ifxusb_flush_both_fifo_d( ifxusb_core_if_t *_core_if );
+#endif
+
+
+/*!
+ \fn int ifxusb_core_soft_reset(ifxusb_core_if_t *_core_if)
+ \brief Do core a soft reset of the core. Be careful with this because it
+ resets all the internal state machines of the core.
+ \param _core_if Pointer of core_if structure
+ \ingroup IFXUSB_CIF
+ */
+#ifdef __IS_HOST__
+extern int ifxusb_core_soft_reset_h(ifxusb_core_if_t *_core_if);
+#else
+extern int ifxusb_core_soft_reset_d(ifxusb_core_if_t *_core_if);
+#endif
+
+
+/*!
+ \brief Turn on the USB Core Power
+ \param _core_if Pointer of core_if structure
+ \ingroup IFXUSB_CIF
+*/
+#ifdef __IS_HOST__
+ extern void ifxusb_power_on_h (ifxusb_core_if_t *_core_if);
+#else
+ extern void ifxusb_power_on_d (ifxusb_core_if_t *_core_if);
+#endif
+
+/*!
+ \fn void ifxusb_power_off (ifxusb_core_if_t *_core_if)
+ \brief Turn off the USB Core Power
+ \param _core_if Pointer of core_if structure
+ \ingroup IFXUSB_CIF
+*/
+#ifdef __IS_HOST__
+ extern void ifxusb_power_off_h (ifxusb_core_if_t *_core_if);
+#else
+ extern void ifxusb_power_off_d (ifxusb_core_if_t *_core_if);
+#endif
+
+/*!
+ \fn void ifxusb_phy_power_on (ifxusb_core_if_t *_core_if)
+ \brief Turn on the USB PHY Power
+ \param _core_if Pointer of core_if structure
+ \ingroup IFXUSB_CIF
+*/
+#ifdef __IS_HOST__
+ extern void ifxusb_phy_power_on_h (ifxusb_core_if_t *_core_if);
+#else
+ extern void ifxusb_phy_power_on_d (ifxusb_core_if_t *_core_if);
+#endif
+
+
+/*!
+ \fn void ifxusb_phy_power_off (ifxusb_core_if_t *_core_if)
+ \brief Turn off the USB PHY Power
+ \param _core_if Pointer of core_if structure
+ \ingroup IFXUSB_CIF
+*/
+#ifdef __IS_HOST__
+ extern void ifxusb_phy_power_off_h (ifxusb_core_if_t *_core_if);
+#else
+ extern void ifxusb_phy_power_off_d (ifxusb_core_if_t *_core_if);
+#endif
+
+/*!
+ \fn void ifxusb_hard_reset(ifxusb_core_if_t *_core_if)
+ \brief Reset on the USB Core RCU
+ \param _core_if Pointer of core_if structure
+ \ingroup IFXUSB_CIF
+ */
+#ifdef __IS_HOST__
+ extern void ifxusb_hard_reset_h(ifxusb_core_if_t *_core_if);
+#else
+ extern void ifxusb_hard_reset_d(ifxusb_core_if_t *_core_if);
+#endif
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+
+#ifdef __IS_HOST__
+ /*!
+ \fn void ifxusb_host_core_init(ifxusb_core_if_t *_core_if, ifxusb_params_t *_params)
+ \brief This function initializes the IFXUSB controller registers for Host mode.
+ This function flushes the Tx and Rx FIFOs and it flushes any entries in the
+ request queues.
+ \param _core_if Pointer of core_if structure
+ \param _params parameters to be set
+ \ingroup IFXUSB_CIF
+ */
+ extern void ifxusb_host_core_init(ifxusb_core_if_t *_core_if, ifxusb_params_t *_params);
+
+ /*!
+ \fn void ifxusb_host_enable_interrupts(ifxusb_core_if_t *_core_if)
+ \brief This function enables the Host mode interrupts.
+ \param _core_if Pointer of core_if structure
+ \ingroup IFXUSB_CIF
+ */
+ extern void ifxusb_host_enable_interrupts(ifxusb_core_if_t *_core_if);
+
+ /*!
+ \fn void ifxusb_host_disable_interrupts(ifxusb_core_if_t *_core_if)
+ \brief This function disables the Host mode interrupts.
+ \param _core_if Pointer of core_if structure
+ \ingroup IFXUSB_CIF
+ */
+ extern void ifxusb_host_disable_interrupts(ifxusb_core_if_t *_core_if);
+
+ #if defined(__IS_TWINPASS__)
+ extern void ifxusb_enable_afe_oc(void);
+ #endif
+
+ /*!
+ \fn void ifxusb_vbus_init(ifxusb_core_if_t *_core_if)
+ \brief This function init the VBUS control.
+ \param _core_if Pointer of core_if structure
+ \ingroup IFXUSB_CIF
+ */
+ extern void ifxusb_vbus_init(ifxusb_core_if_t *_core_if);
+
+ /*!
+ \fn void ifxusb_vbus_free(ifxusb_core_if_t *_core_if)
+ \brief This function free the VBUS control.
+ \param _core_if Pointer of core_if structure
+ \ingroup IFXUSB_CIF
+ */
+ extern void ifxusb_vbus_free(ifxusb_core_if_t *_core_if);
+
+ /*!
+ \fn void ifxusb_vbus_on(ifxusb_core_if_t *_core_if)
+ \brief Turn on the USB 5V VBus Power
+ \param _core_if Pointer of core_if structure
+ \ingroup IFXUSB_CIF
+ */
+ extern void ifxusb_vbus_on(ifxusb_core_if_t *_core_if);
+
+ /*!
+ \fn void ifxusb_vbus_off(ifxusb_core_if_t *_core_if)
+ \brief Turn off the USB 5V VBus Power
+ \param _core_if Pointer of core_if structure
+ \ingroup IFXUSB_CIF
+ */
+ extern void ifxusb_vbus_off(ifxusb_core_if_t *_core_if);
+
+ /*!
+ \fn int ifxusb_vbus(ifxusb_core_if_t *_core_if)
+ \brief Read Current VBus status
+ \param _core_if Pointer of core_if structure
+ \ingroup IFXUSB_CIF
+ */
+ extern int ifxusb_vbus(ifxusb_core_if_t *_core_if);
+#endif
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+
+#ifdef __IS_DEVICE__
+ /*!
+ \fn void ifxusb_dev_enable_interrupts(ifxusb_core_if_t *_core_if)
+ \brief This function enables the Device mode interrupts.
+ \param _core_if Pointer of core_if structure
+ \ingroup IFXUSB_CIF
+ */
+ extern void ifxusb_dev_enable_interrupts(ifxusb_core_if_t *_core_if);
+
+ /*!
+ \fn uint32_t ifxusb_dev_get_frame_number(ifxusb_core_if_t *_core_if)
+ \brief Gets the current USB frame number. This is the frame number from the last SOF packet.
+ \param _core_if Pointer of core_if structure
+ \ingroup IFXUSB_CIF
+ */
+ extern uint32_t ifxusb_dev_get_frame_number(ifxusb_core_if_t *_core_if);
+
+ /*!
+ \fn void ifxusb_dev_ep_set_stall(ifxusb_core_if_t *_core_if, uint8_t _epno, uint8_t _is_in)
+ \brief Set the EP STALL.
+ \param _core_if Pointer of core_if structure
+ \param _epno EP number
+ \param _is_in 1: is IN transfer
+ \ingroup IFXUSB_CIF
+ */
+ extern void ifxusb_dev_ep_set_stall(ifxusb_core_if_t *_core_if, uint8_t _epno, uint8_t _is_in);
+
+ /*!
+ \fn void ifxusb_dev_ep_clear_stall(ifxusb_core_if_t *_core_if, uint8_t _epno, uint8_t _ep_type, uint8_t _is_in)
+ \brief Set the EP STALL.
+ \param _core_if Pointer of core_if structure
+ \param _epno EP number
+ \param _ep_type EP Type
+ \ingroup IFXUSB_CIF
+ */
+ extern void ifxusb_dev_ep_clear_stall(ifxusb_core_if_t *_core_if, uint8_t _epno, uint8_t _ep_type, uint8_t _is_in);
+
+ /*!
+ \fn void ifxusb_dev_core_init(ifxusb_core_if_t *_core_if, ifxusb_params_t *_params)
+ \brief This function initializes the IFXUSB controller registers for Device mode.
+ This function flushes the Tx and Rx FIFOs and it flushes any entries in the
+ request queues.
+ This function validate the imported parameters and store the result in the CIF structure.
+ After
+ \param _core_if Pointer of core_if structure
+ \param _params structure of inported parameters
+ \ingroup IFXUSB_CIF
+ */
+ extern void ifxusb_dev_core_init(ifxusb_core_if_t *_core_if, ifxusb_params_t *_params);
+#endif
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#if defined(__GADGET_LED__) || defined(__HOST_LED__)
+ /*!
+ \fn void ifxusb_led_init(ifxusb_core_if_t *_core_if)
+ \brief This function init the LED control.
+ \param _core_if Pointer of core_if structure
+ \ingroup IFXUSB_CIF
+ */
+ extern void ifxusb_led_init(ifxusb_core_if_t *_core_if);
+
+ /*!
+ \fn void ifxusb_led_free(ifxusb_core_if_t *_core_if)
+ \brief This function free the LED control.
+ \param _core_if Pointer of core_if structure
+ \ingroup IFXUSB_CIF
+ */
+ extern void ifxusb_led_free(ifxusb_core_if_t *_core_if);
+
+ /*!
+ \fn void ifxusb_led(ifxusb_core_if_t *_core_if)
+ \brief This function trigger the LED access.
+ \param _core_if Pointer of core_if structure
+ \ingroup IFXUSB_CIF
+ */
+ extern void ifxusb_led(ifxusb_core_if_t *_core_if);
+#endif
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+/* internal routines for debugging */
+#ifdef __IS_HOST__
+ extern void ifxusb_dump_msg_h(const u8 *buf, unsigned int length);
+ extern void ifxusb_dump_spram_h(ifxusb_core_if_t *_core_if);
+ extern void ifxusb_dump_registers_h(ifxusb_core_if_t *_core_if);
+#else
+ extern void ifxusb_dump_msg_d(const u8 *buf, unsigned int length);
+ extern void ifxusb_dump_spram_d(ifxusb_core_if_t *_core_if);
+ extern void ifxusb_dump_registers_d(ifxusb_core_if_t *_core_if);
+#endif
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+static inline uint32_t ifxusb_read_core_intr(ifxusb_core_if_t *_core_if)
+{
+ return (ifxusb_rreg(&_core_if->core_global_regs->gintsts) &
+ ifxusb_rreg(&_core_if->core_global_regs->gintmsk));
+}
+
+static inline uint32_t ifxusb_read_otg_intr (ifxusb_core_if_t *_core_if)
+{
+ return (ifxusb_rreg (&_core_if->core_global_regs->gotgint));
+}
+
+static inline uint32_t ifxusb_mode(ifxusb_core_if_t *_core_if)
+{
+ return (ifxusb_rreg( &_core_if->core_global_regs->gintsts ) & 0x1);
+}
+static inline uint8_t ifxusb_is_device_mode(ifxusb_core_if_t *_core_if)
+{
+ return (ifxusb_mode(_core_if) != 1);
+}
+static inline uint8_t ifxusb_is_host_mode(ifxusb_core_if_t *_core_if)
+{
+ return (ifxusb_mode(_core_if) == 1);
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifdef __IS_HOST__
+ static inline uint32_t ifxusb_read_hprt0(ifxusb_core_if_t *_core_if)
+ {
+ hprt0_data_t hprt0;
+ hprt0.d32 = ifxusb_rreg(_core_if->hprt0);
+ hprt0.b.prtena = 0;
+ hprt0.b.prtconndet = 0;
+ hprt0.b.prtenchng = 0;
+ hprt0.b.prtovrcurrchng = 0;
+ return hprt0.d32;
+ }
+
+ static inline uint32_t ifxusb_read_host_all_channels_intr (ifxusb_core_if_t *_core_if)
+ {
+ return (ifxusb_rreg (&_core_if->host_global_regs->haint));
+ }
+
+ static inline uint32_t ifxusb_read_host_channel_intr (ifxusb_core_if_t *_core_if, int hc_num)
+ {
+ return (ifxusb_rreg (&_core_if->hc_regs[hc_num]->hcint));
+ }
+#endif
+
+#ifdef __IS_DEVICE__
+ static inline uint32_t ifxusb_read_dev_all_in_ep_intr(ifxusb_core_if_t *_core_if)
+ {
+ uint32_t v;
+ v = ifxusb_rreg(&_core_if->dev_global_regs->daint) &
+ ifxusb_rreg(&_core_if->dev_global_regs->daintmsk);
+ return (v & 0xffff);
+ }
+
+ static inline uint32_t ifxusb_read_dev_all_out_ep_intr(ifxusb_core_if_t *_core_if)
+ {
+ uint32_t v;
+ v = ifxusb_rreg(&_core_if->dev_global_regs->daint) &
+ ifxusb_rreg(&_core_if->dev_global_regs->daintmsk);
+ return ((v & 0xffff0000) >> 16);
+ }
+
+ static inline uint32_t ifxusb_read_dev_in_ep_intr(ifxusb_core_if_t *_core_if, int _ep_num)
+ {
+ uint32_t v;
+ v = ifxusb_rreg(&_core_if->in_ep_regs[_ep_num]->diepint) &
+ ifxusb_rreg(&_core_if->dev_global_regs->diepmsk);
+ return v;
+ }
+
+ static inline uint32_t ifxusb_read_dev_out_ep_intr(ifxusb_core_if_t *_core_if, int _ep_num)
+ {
+ uint32_t v;
+ v = ifxusb_rreg(&_core_if->out_ep_regs[_ep_num]->doepint) &
+ ifxusb_rreg(&_core_if->dev_global_regs->doepmsk);
+ return v;
+ }
+
+#endif
+
+#ifdef __IS_HOST__
+extern void ifxusb_attr_create_h (void *_dev);
+extern void ifxusb_attr_remove_h (void *_dev);
+#else
+extern void ifxusb_attr_create_d (void *_dev);
+extern void ifxusb_attr_remove_d (void *_dev);
+#endif
+
+#ifdef __IS_HOST__
+extern void do_suspend_h(ifxusb_core_if_t *core_if);
+extern void do_resume_h(ifxusb_core_if_t *_core_if);
+#else
+extern void do_suspend_d(ifxusb_core_if_t *core_if);
+extern void do_resume_d(ifxusb_core_if_t *_core_if);
+#endif
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#endif // !defined(__IFXUSB_CIF_H__)
+
diff --git a/package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxusb_cif_d.c.svn-base b/package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxusb_cif_d.c.svn-base
new file mode 100644
index 0000000..19f7650
--- /dev/null
+++ b/package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxusb_cif_d.c.svn-base
@@ -0,0 +1,535 @@
+/*****************************************************************************
+ ** FILE NAME : ifxusb_cif_d.c
+ ** PROJECT : IFX USB sub-system V3
+ ** MODULES : IFX USB sub-system Host and Device driver
+ ** SRC VERSION : 3.2
+ ** DATE : 1/Jan/2011
+ ** AUTHOR : Chen, Howard
+ ** DESCRIPTION : The Core Interface provides basic services for accessing and
+ ** managing the IFX USB hardware. These services are used by the
+ ** Peripheral Controller Driver only.
+ ** FUNCTIONS :
+ ** COMPILER : gcc
+ ** REFERENCE : Synopsys DWC-OTG Driver 2.7
+ ** COPYRIGHT : Copyright (c) 2010
+ ** LANTIQ DEUTSCHLAND GMBH,
+ ** Am Campeon 3, 85579 Neubiberg, Germany
+ **
+ ** 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 of the License, or
+ ** (at your option) any later version.
+ **
+ ** Version Control Section **
+ ** $Author$
+ ** $Date$
+ ** $Revisions$
+ ** $Log$ Revision history
+ *****************************************************************************/
+
+/*
+ * This file contains code fragments from Synopsys HS OTG Linux Software Driver.
+ * For this code the following notice is applicable:
+ *
+ * ==========================================================================
+ *
+ * Synopsys HS OTG Linux Software Driver and documentation (hereinafter,
+ * "Software") is an Unsupported proprietary work of Synopsys, Inc. unless
+ * otherwise expressly agreed to in writing between Synopsys and you.
+ *
+ * The Software IS NOT an item of Licensed Software or Licensed Product under
+ * any End User Software License Agreement or Agreement for Licensed Product
+ * with Synopsys or any supplement thereto. You are permitted to use and
+ * redistribute this Software in source and binary forms, with or without
+ * modification, provided that redistributions of source code must retain this
+ * notice. You may not view, use, disclose, copy or distribute this file or
+ * any information contained herein except pursuant to this license grant from
+ * Synopsys. If you do not agree with this notice, including the disclaimer
+ * below, then you are not authorized to use the Software.
+ *
+ * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" BASIS
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ * ========================================================================== */
+
+/*!
+ \file ifxusb_cif_d.c
+ \ingroup IFXUSB_DRIVER_V3
+ \brief This file contains the interface to the IFX USB Core.
+*/
+
+#include <linux/version.h>
+#include "ifxusb_version.h"
+
+
+#include <asm/byteorder.h>
+#include <asm/unaligned.h>
+
+#ifdef __DEBUG__
+ #include <linux/jiffies.h>
+#endif
+
+#include "ifxusb_plat.h"
+#include "ifxusb_regs.h"
+#include "ifxusb_cif.h"
+
+#include "ifxpcd.h"
+
+
+
+/*!
+ \brief Initializes the DevSpd field of the DCFG register depending on the PHY type
+ and the enumeration speed of the device.
+ \param _core_if Pointer of core_if structure
+ */
+void ifxusb_dev_init_spd(ifxusb_core_if_t *_core_if)
+{
+ uint32_t val;
+ dcfg_data_t dcfg;
+
+ IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
+ if (_core_if->params.speed == IFXUSB_PARAM_SPEED_FULL)
+ /* High speed PHY running at full speed */
+ val = 0x1;
+ else
+ /* High speed PHY running at high speed and full speed*/
+ val = 0x0;
+
+ IFX_DEBUGPL(DBG_CIL, "Initializing DCFG.DevSpd to 0x%1x\n", val);
+ dcfg.d32 = ifxusb_rreg(&_core_if->dev_global_regs->dcfg);
+ dcfg.b.devspd = val;
+ ifxusb_wreg(&_core_if->dev_global_regs->dcfg, dcfg.d32);
+}
+
+
+/*!
+ \brief This function enables the Device mode interrupts.
+ \param _core_if Pointer of core_if structure
+ */
+void ifxusb_dev_enable_interrupts(ifxusb_core_if_t *_core_if)
+{
+ gint_data_t intr_mask ={ .d32 = 0};
+ ifxusb_core_global_regs_t *global_regs = _core_if->core_global_regs;
+
+ IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
+ IFX_DEBUGPL(DBG_CIL, "%s()\n", __func__);
+
+ /* Clear any pending OTG Interrupts */
+ ifxusb_wreg( &global_regs->gotgint, 0xFFFFFFFF);
+
+ /* Clear any pending interrupts */
+ ifxusb_wreg( &global_regs->gintsts, 0xFFFFFFFF);
+
+ /* Enable the interrupts in the GINTMSK.*/
+ intr_mask.b.modemismatch = 1;
+ intr_mask.b.conidstschng = 1;
+ intr_mask.b.wkupintr = 1;
+ intr_mask.b.disconnect = 1;
+ intr_mask.b.usbsuspend = 1;
+
+ intr_mask.b.usbreset = 1;
+ intr_mask.b.enumdone = 1;
+ intr_mask.b.inepintr = 1;
+ intr_mask.b.outepintr = 1;
+ intr_mask.b.erlysuspend = 1;
+ #ifndef __DED_FIFO__
+ #ifndef __DED_INTR__
+ intr_mask.b.epmismatch = 1;
+ #endif
+ #endif
+
+ ifxusb_mreg( &global_regs->gintmsk, intr_mask.d32, intr_mask.d32);
+ IFX_DEBUGPL(DBG_CIL, "%s() gintmsk=%0x\n", __func__, ifxusb_rreg( &global_regs->gintmsk));
+}
+
+/*!
+ \brief Gets the current USB frame number. This is the frame number from the last SOF packet.
+ \param _core_if Pointer of core_if structure
+ */
+uint32_t ifxusb_dev_get_frame_number(ifxusb_core_if_t *_core_if)
+{
+ dsts_data_t dsts;
+ IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
+ dsts.d32 = ifxusb_rreg(&_core_if->dev_global_regs->dsts);
+ /* read current frame/microfreme number from DSTS register */
+ return dsts.b.soffn;
+}
+
+
+/*!
+ \brief Set the EP STALL.
+ */
+void ifxusb_dev_ep_set_stall(ifxusb_core_if_t *_core_if, uint8_t _epno, uint8_t _is_in)
+{
+ depctl_data_t depctl;
+ volatile uint32_t *depctl_addr;
+
+ IFX_DEBUGPL(DBG_PCD, "%s ep%d-%s\n", __func__, _epno, (_is_in?"IN":"OUT"));
+
+ depctl_addr = (_is_in)? (&(_core_if->in_ep_regs [_epno]->diepctl)):
+ (&(_core_if->out_ep_regs[_epno]->doepctl));
+ depctl.d32 = ifxusb_rreg(depctl_addr);
+ depctl.b.stall = 1;
+
+ if (_is_in && depctl.b.epena)
+ depctl.b.epdis = 1;
+
+ ifxusb_wreg(depctl_addr, depctl.d32);
+ IFX_DEBUGPL(DBG_PCD,"DEPCTL=%0x\n",ifxusb_rreg(depctl_addr));
+ return;
+}
+
+/*!
+\brief Clear the EP STALL.
+ */
+void ifxusb_dev_ep_clear_stall(ifxusb_core_if_t *_core_if, uint8_t _epno, uint8_t _ep_type, uint8_t _is_in)
+{
+ depctl_data_t depctl;
+ volatile uint32_t *depctl_addr;
+
+ IFX_DEBUGPL(DBG_PCD, "%s ep%d-%s\n", __func__, _epno, (_is_in?"IN":"OUT"));
+
+ depctl_addr = (_is_in)? (&(_core_if->in_ep_regs [_epno]->diepctl)):
+ (&(_core_if->out_ep_regs[_epno]->doepctl));
+
+ depctl.d32 = ifxusb_rreg(depctl_addr);
+ /* clear the stall bits */
+ depctl.b.stall = 0;
+
+ /*
+ * USB Spec 9.4.5: For endpoints using data toggle, regardless
+ * of whether an endpoint has the Halt feature set, a
+ * ClearFeature(ENDPOINT_HALT) request always results in the
+ * data toggle being reinitialized to DATA0.
+ */
+ if (_ep_type == IFXUSB_EP_TYPE_INTR || _ep_type == IFXUSB_EP_TYPE_BULK)
+ depctl.b.setd0pid = 1; /* DATA0 */
+
+ ifxusb_wreg(depctl_addr, depctl.d32);
+ IFX_DEBUGPL(DBG_PCD,"DEPCTL=%0x\n",ifxusb_rreg(depctl_addr));
+ return;
+}
+
+/*!
+ \brief This function initializes the IFXUSB controller registers for Device mode.
+ This function flushes the Tx and Rx FIFOs and it flushes any entries in the
+ request queues.
+ \param _core_if Pointer of core_if structure
+ \param _params parameters to be set
+ */
+void ifxusb_dev_core_init(ifxusb_core_if_t *_core_if, ifxusb_params_t *_params)
+{
+ ifxusb_core_global_regs_t *global_regs = _core_if->core_global_regs;
+
+ gusbcfg_data_t usbcfg ={.d32 = 0};
+ gahbcfg_data_t ahbcfg ={.d32 = 0};
+ dcfg_data_t dcfg ={.d32 = 0};
+ grstctl_t resetctl ={.d32 = 0};
+ gotgctl_data_t gotgctl ={.d32 = 0};
+
+ uint32_t dir;
+ int i;
+
+ IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
+ IFX_DEBUGPL(DBG_CILV, "%s(%p)\n",__func__,_core_if);
+
+ /* Copy Params */
+ _core_if->params.dma_burst_size = _params->dma_burst_size;
+ _core_if->params.speed = _params->speed;
+ if(_params->max_transfer_size < 2048 || _params->max_transfer_size > ((1 << (_core_if->hwcfg3.b.xfer_size_cntr_width + 11)) - 1) )
+ _core_if->params.max_transfer_size = ((1 << (_core_if->hwcfg3.b.xfer_size_cntr_width + 11)) - 1);
+ else
+ _core_if->params.max_transfer_size = _params->max_transfer_size;
+
+ if(_params->max_packet_count < 16 || _params->max_packet_count > ((1 << (_core_if->hwcfg3.b.packet_size_cntr_width + 4)) - 1) )
+ _core_if->params.max_packet_count= ((1 << (_core_if->hwcfg3.b.packet_size_cntr_width + 4)) - 1);
+ else
+ _core_if->params.max_packet_count= _params->max_packet_count;
+ _core_if->params.phy_utmi_width = _params->phy_utmi_width;
+ _core_if->params.turn_around_time_hs = _params->turn_around_time_hs;
+ _core_if->params.turn_around_time_fs = _params->turn_around_time_fs;
+ _core_if->params.timeout_cal_hs = _params->timeout_cal_hs;
+ _core_if->params.timeout_cal_fs = _params->timeout_cal_fs;
+
+ #ifdef __DED_FIFO__
+ _core_if->params.thr_ctl = _params->thr_ctl;
+ _core_if->params.tx_thr_length = _params->tx_thr_length;
+ _core_if->params.rx_thr_length = _params->rx_thr_length;
+ #endif
+
+ /* Reset the Controller */
+ do
+ {
+ while(ifxusb_core_soft_reset_d( _core_if ))
+ ifxusb_hard_reset_d(_core_if);
+ } while (ifxusb_is_host_mode(_core_if));
+
+ usbcfg.d32 = ifxusb_rreg(&global_regs->gusbcfg);
+
+ usbcfg.b.ForceDevMode = 1;
+ usbcfg.b.ForceHstMode = 0;
+
+ usbcfg.b.term_sel_dl_pulse = 0;
+ ifxusb_wreg (&global_regs->gusbcfg, usbcfg.d32);
+
+ /* This programming sequence needs to happen in FS mode before any other
+ * programming occurs */
+ /* High speed PHY. */
+ if (!_core_if->phy_init_done)
+ {
+ _core_if->phy_init_done = 1;
+ /* HS PHY parameters. These parameters are preserved
+ * during soft reset so only program the first time. Do
+ * a soft reset immediately after setting phyif. */
+ usbcfg.b.ulpi_utmi_sel = 0; //UTMI+
+ usbcfg.b.phyif = ( _core_if->params.phy_utmi_width == 16)?1:0;
+ ifxusb_wreg( &global_regs->gusbcfg, usbcfg.d32);
+ /* Reset after setting the PHY parameters */
+ ifxusb_core_soft_reset_d( _core_if );
+ }
+
+ /* Program the GAHBCFG Register.*/
+ switch (_core_if->params.dma_burst_size)
+ {
+ case 0 :
+ ahbcfg.b.hburstlen = IFXUSB_GAHBCFG_INT_DMA_BURST_SINGLE;
+ break;
+ case 1 :
+ ahbcfg.b.hburstlen = IFXUSB_GAHBCFG_INT_DMA_BURST_INCR;
+ break;
+ case 4 :
+ ahbcfg.b.hburstlen = IFXUSB_GAHBCFG_INT_DMA_BURST_INCR4;
+ break;
+ case 8 :
+ ahbcfg.b.hburstlen = IFXUSB_GAHBCFG_INT_DMA_BURST_INCR8;
+ break;
+ case 16:
+ ahbcfg.b.hburstlen = IFXUSB_GAHBCFG_INT_DMA_BURST_INCR16;
+ break;
+ }
+ #if defined(__UNALIGNED_BUF_ADJ__) || defined(__UNALIGNED_BUF_CHK__)
+ _core_if->unaligned_mask=3;
+ #if defined(__UNALIGNED_BUF_BURST__)
+ switch (_core_if->params.dma_burst_size)
+ {
+ case 4 :
+ _core_if->unaligned_mask=15;
+ break;
+ case 8 :
+ _core_if->unaligned_mask=31;
+ break;
+ case 16:
+ _core_if->unaligned_mask=63;
+ break;
+ case 0 :
+ case 1 :
+ break;
+ }
+ #endif //defined(__UNALIGNED_BUF_BURST__)
+ #endif //defined(__UNALIGNED_BUF_ADJ__) || defined(__UNALIGNED_BUF_CHK__)
+ ahbcfg.b.dmaenable = 1;
+ ifxusb_wreg(&global_regs->gahbcfg, ahbcfg.d32);
+
+ /* Program the GUSBCFG register. */
+ usbcfg.d32 = ifxusb_rreg( &global_regs->gusbcfg );
+ usbcfg.b.hnpcap = 0;
+ usbcfg.b.srpcap = 0;
+ ifxusb_wreg( &global_regs->gusbcfg, usbcfg.d32);
+
+ {
+ dctl_data_t dctl = {.d32=0};
+ dctl.d32=ifxusb_rreg(&_core_if->dev_global_regs->dctl);
+ dctl.b.sftdiscon=1;
+ ifxusb_wreg(&_core_if->dev_global_regs->dctl,dctl.d32);
+ }
+
+ /* Restart the Phy Clock */
+ ifxusb_wreg(_core_if->pcgcctl, 0);
+
+ /* Device configuration register */
+ ifxusb_dev_init_spd(_core_if);
+ dcfg.d32 = ifxusb_rreg( &_core_if->dev_global_regs->dcfg);
+ dcfg.b.perfrint = IFXUSB_DCFG_FRAME_INTERVAL_80;
+ #if defined(__DED_FIFO__)
+ #if defined(__DESC_DMA__)
+ dcfg.b.descdma = 1;
+ #else
+ dcfg.b.descdma = 0;
+ #endif
+ #endif
+
+ ifxusb_wreg( &_core_if->dev_global_regs->dcfg, dcfg.d32 );
+
+ /* Configure data FIFO sizes */
+ _core_if->params.data_fifo_size = _core_if->hwcfg3.b.dfifo_depth;
+ _core_if->params.rx_fifo_size = ifxusb_rreg(&global_regs->grxfsiz);
+ IFX_DEBUGPL(DBG_CIL, "Initial: FIFO Size=0x%06X\n" , _core_if->params.data_fifo_size);
+ IFX_DEBUGPL(DBG_CIL, " Rx FIFO Size=0x%06X\n", _core_if->params.rx_fifo_size);
+
+ _core_if->params.tx_fifo_size[0]= ifxusb_rreg(&global_regs->gnptxfsiz) >> 16;
+
+ #ifdef __DED_FIFO__
+ for (i=1; i <= _core_if->hwcfg4.b.num_in_eps; i++)
+ _core_if->params.tx_fifo_size[i] =
+ ifxusb_rreg(&global_regs->dptxfsiz_dieptxf[i-1]) >> 16;
+ #else
+ for (i=0; i < _core_if->hwcfg4.b.num_dev_perio_in_ep; i++)
+ _core_if->params.tx_fifo_size[i+1] =
+ ifxusb_rreg(&global_regs->dptxfsiz_dieptxf[i]) >> 16;
+ #endif
+
+ #ifdef __DEBUG__
+ #ifdef __DED_FIFO__
+ for (i=0; i <= _core_if->hwcfg4.b.num_in_eps; i++)
+ IFX_DEBUGPL(DBG_CIL, " Tx[%02d] FIFO Size=0x%06X\n",i, _core_if->params.tx_fifo_size[i]);
+ #else
+ IFX_DEBUGPL(DBG_CIL, " NPTx FIFO Size=0x%06X\n", _core_if->params.tx_fifo_size[0]);
+ for (i=0; i < _core_if->hwcfg4.b.num_dev_perio_in_ep; i++)
+ IFX_DEBUGPL(DBG_CIL, " PTx[%02d] FIFO Size=0x%06X\n",i, _core_if->params.tx_fifo_size[i+1]);
+ #endif
+ #endif
+
+ {
+ fifosize_data_t txfifosize;
+ if(_params->data_fifo_size >=0 && _params->data_fifo_size < _core_if->params.data_fifo_size)
+ _core_if->params.data_fifo_size = _params->data_fifo_size;
+
+
+ if(_params->rx_fifo_size >=0 && _params->rx_fifo_size < _core_if->params.rx_fifo_size)
+ _core_if->params.rx_fifo_size = _params->rx_fifo_size;
+ if(_core_if->params.data_fifo_size < _core_if->params.rx_fifo_size)
+ _core_if->params.rx_fifo_size = _core_if->params.data_fifo_size;
+ ifxusb_wreg( &global_regs->grxfsiz, _core_if->params.rx_fifo_size);
+
+ for (i=0; i < MAX_EPS_CHANNELS; i++)
+ if(_params->tx_fifo_size[i] >=0 && _params->tx_fifo_size[i] < _core_if->params.tx_fifo_size[i])
+ _core_if->params.tx_fifo_size[i] = _params->tx_fifo_size[i];
+
+ txfifosize.b.startaddr = _core_if->params.rx_fifo_size;
+ #ifdef __DED_FIFO__
+ if(txfifosize.b.startaddr + _core_if->params.tx_fifo_size[0] > _core_if->params.data_fifo_size)
+ _core_if->params.tx_fifo_size[0]= _core_if->params.data_fifo_size - txfifosize.b.startaddr;
+ txfifosize.b.depth=_core_if->params.tx_fifo_size[0];
+ ifxusb_wreg( &global_regs->gnptxfsiz, txfifosize.d32);
+ txfifosize.b.startaddr += _core_if->params.tx_fifo_size[0];
+ for (i=1; i <= _core_if->hwcfg4.b.num_in_eps; i++)
+ {
+ if(txfifosize.b.startaddr + _core_if->params.tx_fifo_size[i] > _core_if->params.data_fifo_size)
+ _core_if->params.tx_fifo_size[i]= _core_if->params.data_fifo_size - txfifosize.b.startaddr;
+ txfifosize.b.depth=_core_if->params.tx_fifo_size[i];
+ ifxusb_wreg( &global_regs->dptxfsiz_dieptxf[i-1], txfifosize.d32);
+ txfifosize.b.startaddr += _core_if->params.tx_fifo_size[i];
+ }
+ #else
+ if(txfifosize.b.startaddr + _core_if->params.tx_fifo_size[0] > _core_if->params.data_fifo_size)
+ _core_if->params.tx_fifo_size[0]= _core_if->params.data_fifo_size - txfifosize.b.startaddr;
+ txfifosize.b.depth=_core_if->params.tx_fifo_size[0];
+ ifxusb_wreg( &global_regs->gnptxfsiz, txfifosize.d32);
+ txfifosize.b.startaddr += _core_if->params.tx_fifo_size[0];
+ for (i=0; i < _core_if->hwcfg4.b.num_dev_perio_in_ep; i++)
+ {
+ if(txfifosize.b.startaddr + _core_if->params.tx_fifo_size[i+1] > _core_if->params.data_fifo_size)
+ _core_if->params.tx_fifo_size[i+1]= _core_if->params.data_fifo_size - txfifosize.b.startaddr;
+ //txfifosize.b.depth=_core_if->params.tx_fifo_size[i+1];
+ ifxusb_wreg( &global_regs->dptxfsiz_dieptxf[i], txfifosize.d32);
+ txfifosize.b.startaddr += _core_if->params.tx_fifo_size[i+1];
+ }
+ #endif
+ }
+
+ #ifdef __DEBUG__
+ {
+ fifosize_data_t fifosize;
+ IFX_DEBUGPL(DBG_CIL, "Result : FIFO Size=0x%06X\n" , _core_if->params.data_fifo_size);
+
+ IFX_DEBUGPL(DBG_CIL, " Rx FIFO =0x%06X Sz=0x%06X\n", 0,ifxusb_rreg(&global_regs->grxfsiz));
+ #ifdef __DED_FIFO__
+ fifosize.d32=ifxusb_rreg(&global_regs->gnptxfsiz);
+ IFX_DEBUGPL(DBG_CIL, " Tx[00] FIFO =0x%06X Sz=0x%06X\n", fifosize.b.startaddr,fifosize.b.depth);
+ for (i=1; i <= _core_if->hwcfg4.b.num_in_eps; i++)
+ {
+ fifosize.d32=ifxusb_rreg(&global_regs->dptxfsiz_dieptxf[i-1]);
+ IFX_DEBUGPL(DBG_CIL, " Tx[%02d] FIFO 0x%06X Sz=0x%06X\n",i, fifosize.b.startaddr,fifosize.b.depth);
+ }
+ #else
+ fifosize.d32=ifxusb_rreg(&global_regs->gnptxfsiz);
+ IFX_DEBUGPL(DBG_CIL, " NPTx FIFO =0x%06X Sz=0x%06X\n", fifosize.b.startaddr,fifosize.b.depth);
+ for (i=0; i < _core_if->hwcfg4.b.num_dev_perio_in_ep; i++)
+ {
+ fifosize.d32=ifxusb_rreg(&global_regs->dptxfsiz_dieptxf[i]);
+ IFX_DEBUGPL(DBG_CIL, " PTx[%02d] FIFO 0x%06X Sz=0x%06X\n",i, fifosize.b.startaddr,fifosize.b.depth);
+ }
+ #endif
+ }
+ #endif
+
+ /* Clear Host Set HNP Enable in the OTG Control Register */
+ gotgctl.b.hstsethnpen = 1;
+ ifxusb_mreg( &global_regs->gotgctl, gotgctl.d32, 0);
+
+ /* Flush the FIFOs */
+ ifxusb_flush_tx_fifo_d(_core_if, 0x10); /* all Tx FIFOs */
+ ifxusb_flush_rx_fifo_d(_core_if);
+
+ /* Flush the Learning Queue. */
+ resetctl.b.intknqflsh = 1;
+ ifxusb_wreg( &global_regs->grstctl, resetctl.d32);
+
+ /* Clear all pending Device Interrupts */
+ ifxusb_wreg( &_core_if->dev_global_regs->diepmsk , 0 );
+ ifxusb_wreg( &_core_if->dev_global_regs->doepmsk , 0 );
+ ifxusb_wreg( &_core_if->dev_global_regs->daint , 0xFFFFFFFF );
+ ifxusb_wreg( &_core_if->dev_global_regs->daintmsk, 0 );
+
+ dir=_core_if->hwcfg1.d32;
+ for (i=0; i <= _core_if->hwcfg2.b.num_dev_ep ; i++,dir>>=2)
+ {
+ depctl_data_t depctl;
+ if((dir&0x03)==0 || (dir&0x03) ==1)
+ {
+ depctl.d32 = ifxusb_rreg(&_core_if->in_ep_regs[i]->diepctl);
+ if (depctl.b.epena)
+ {
+ depctl.d32 = 0;
+ depctl.b.epdis = 1;
+ depctl.b.snak = 1;
+ }
+ else
+ depctl.d32 = 0;
+ ifxusb_wreg( &_core_if->in_ep_regs[i]->diepctl, depctl.d32);
+ #ifndef __DESC_DMA__
+ ifxusb_wreg( &_core_if->in_ep_regs[i]->dieptsiz, 0);
+ #endif
+ ifxusb_wreg( &_core_if->in_ep_regs[i]->diepdma, 0);
+ ifxusb_wreg( &_core_if->in_ep_regs[i]->diepint, 0xFF);
+ }
+
+ if((dir&0x03)==0 || (dir&0x03) ==2)
+ {
+ depctl.d32 = ifxusb_rreg(&_core_if->out_ep_regs[i]->doepctl);
+ if (depctl.b.epena)
+ {
+ depctl.d32 = 0;
+ depctl.b.epdis = 1;
+ depctl.b.snak = 1;
+ }
+ else
+ depctl.d32 = 0;
+ ifxusb_wreg( &_core_if->out_ep_regs[i]->doepctl, depctl.d32);
+ #ifndef __DESC_DMA__
+ ifxusb_wreg( &_core_if->out_ep_regs[i]->doeptsiz, 0);
+ #endif
+ ifxusb_wreg( &_core_if->out_ep_regs[i]->doepdma, 0);
+ ifxusb_wreg( &_core_if->out_ep_regs[i]->doepint, 0xFF);
+ }
+ }
+}
+
diff --git a/package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxusb_cif_h.c.svn-base b/package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxusb_cif_h.c.svn-base
new file mode 100644
index 0000000..e9e67bf
--- /dev/null
+++ b/package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxusb_cif_h.c.svn-base
@@ -0,0 +1,1599 @@
+/*****************************************************************************
+ ** FILE NAME : ifxusb_cif_h.c
+ ** PROJECT : IFX USB sub-system V3
+ ** MODULES : IFX USB sub-system Host and Device driver
+ ** SRC VERSION : 3.2
+ ** DATE : 1/Jan/2011
+ ** AUTHOR : Chen, Howard
+ ** DESCRIPTION : The Core Interface provides basic services for accessing and
+ ** managing the IFX USB hardware. These services are used by the
+ ** Host Controller Driver only.
+ ** FUNCTIONS :
+ ** COMPILER : gcc
+ ** REFERENCE : Synopsys DWC-OTG Driver 2.7
+ ** COPYRIGHT : Copyright (c) 2010
+ ** LANTIQ DEUTSCHLAND GMBH,
+ ** Am Campeon 3, 85579 Neubiberg, Germany
+ **
+ ** 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 of the License, or
+ ** (at your option) any later version.
+ **
+ ** Version Control Section **
+ ** $Author$
+ ** $Date$
+ ** $Revisions$
+ ** $Log$ Revision history
+ *****************************************************************************/
+
+/*
+ * This file contains code fragments from Synopsys HS OTG Linux Software Driver.
+ * For this code the following notice is applicable:
+ *
+ * ==========================================================================
+ *
+ * Synopsys HS OTG Linux Software Driver and documentation (hereinafter,
+ * "Software") is an Unsupported proprietary work of Synopsys, Inc. unless
+ * otherwise expressly agreed to in writing between Synopsys and you.
+ *
+ * The Software IS NOT an item of Licensed Software or Licensed Product under
+ * any End User Software License Agreement or Agreement for Licensed Product
+ * with Synopsys or any supplement thereto. You are permitted to use and
+ * redistribute this Software in source and binary forms, with or without
+ * modification, provided that redistributions of source code must retain this
+ * notice. You may not view, use, disclose, copy or distribute this file or
+ * any information contained herein except pursuant to this license grant from
+ * Synopsys. If you do not agree with this notice, including the disclaimer
+ * below, then you are not authorized to use the Software.
+ *
+ * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" BASIS
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ * ========================================================================== */
+
+/*!
+ \file ifxusb_cif_h.c
+ \ingroup IFXUSB_DRIVER_V3
+ \brief This file contains the interface to the IFX USB Core.
+*/
+#include <linux/version.h>
+#include "ifxusb_version.h"
+
+#include <asm/byteorder.h>
+#include <asm/unaligned.h>
+
+#ifdef __DEBUG__
+ #include <linux/jiffies.h>
+#endif
+#include <linux/platform_device.h>
+#include <linux/kernel.h>
+#include <linux/ioport.h>
+
+#include "ifxusb_plat.h"
+#include "ifxusb_regs.h"
+#include "ifxusb_cif.h"
+
+#include "ifxhcd.h"
+
+#if !defined(__UEIP__)
+ #undef __USING_LED_AS_GPIO__
+#endif
+
+
+/*!
+ \brief This function enables the Host mode interrupts.
+ \param _core_if Pointer of core_if structure
+ */
+void ifxusb_host_enable_interrupts(ifxusb_core_if_t *_core_if)
+{
+ gint_data_t intr_mask ={ .d32 = 0};
+ ifxusb_core_global_regs_t *global_regs = _core_if->core_global_regs;
+
+ IFX_DEBUGPL(DBG_CIL, "%s()\n", __func__);
+
+ /* Clear any pending OTG Interrupts */
+ ifxusb_wreg( &global_regs->gotgint, 0xFFFFFFFF);
+
+ /* Clear any pending interrupts */
+ ifxusb_wreg( &global_regs->gintsts, 0xFFFFFFFF);
+
+ /* Enable the interrupts in the GINTMSK.*/
+
+ /* Common interrupts */
+ intr_mask.b.modemismatch = 1;
+ intr_mask.b.conidstschng = 1;
+ intr_mask.b.wkupintr = 1;
+ intr_mask.b.disconnect = 1;
+ intr_mask.b.usbsuspend = 1;
+
+ /* Host interrupts */
+ intr_mask.b.sofintr = 1;
+ intr_mask.b.portintr = 1;
+ intr_mask.b.hcintr = 1;
+
+ ifxusb_mreg( &global_regs->gintmsk, intr_mask.d32, intr_mask.d32);
+ IFX_DEBUGPL(DBG_CIL, "%s() gintmsk=%0x\n", __func__, ifxusb_rreg( &global_regs->gintmsk));
+}
+
+/*!
+ \brief This function disables the Host mode interrupts.
+ \param _core_if Pointer of core_if structure
+ */
+void ifxusb_host_disable_interrupts(ifxusb_core_if_t *_core_if)
+{
+ ifxusb_core_global_regs_t *global_regs = _core_if->core_global_regs;
+
+ IFX_DEBUGPL(DBG_CILV, "%s()\n", __func__);
+
+ #if 1
+ ifxusb_wreg( &global_regs->gintmsk, 0);
+ #else
+ /* Common interrupts */
+ {
+ gint_data_t intr_mask ={.d32 = 0};
+ intr_mask.b.modemismatch = 1;
+ intr_mask.b.rxstsqlvl = 1;
+ intr_mask.b.conidstschng = 1;
+ intr_mask.b.wkupintr = 1;
+ intr_mask.b.disconnect = 1;
+ intr_mask.b.usbsuspend = 1;
+
+ /* Host interrupts */
+ intr_mask.b.sofintr = 1;
+ intr_mask.b.portintr = 1;
+ intr_mask.b.hcintr = 1;
+ intr_mask.b.ptxfempty = 1;
+ intr_mask.b.nptxfempty = 1;
+ ifxusb_mreg(&global_regs->gintmsk, intr_mask.d32, 0);
+ }
+ #endif
+}
+
+/*!
+ \brief This function initializes the IFXUSB controller registers for Host mode.
+ This function flushes the Tx and Rx FIFOs and it flushes any entries in the
+ request queues.
+ \param _core_if Pointer of core_if structure
+ \param _params parameters to be set
+ */
+void ifxusb_host_core_init(ifxusb_core_if_t *_core_if, ifxusb_params_t *_params)
+{
+ ifxusb_core_global_regs_t *global_regs = _core_if->core_global_regs;
+
+ gusbcfg_data_t usbcfg ={.d32 = 0};
+ gahbcfg_data_t ahbcfg ={.d32 = 0};
+ gotgctl_data_t gotgctl ={.d32 = 0};
+
+ int i;
+
+ IFX_DEBUGPL(DBG_CILV, "%s(%p)\n",__func__,_core_if);
+
+ /* Copy Params */
+
+ _core_if->params.dma_burst_size = _params->dma_burst_size;
+ _core_if->params.speed = _params->speed;
+ if(_params->max_transfer_size < 2048 || _params->max_transfer_size > ((1 << (_core_if->hwcfg3.b.xfer_size_cntr_width + 11)) - 1) )
+ _core_if->params.max_transfer_size = ((1 << (_core_if->hwcfg3.b.xfer_size_cntr_width + 11)) - 1);
+ else
+ _core_if->params.max_transfer_size = _params->max_transfer_size;
+
+ if(_params->max_packet_count < 16 || _params->max_packet_count > ((1 << (_core_if->hwcfg3.b.packet_size_cntr_width + 4)) - 1) )
+ _core_if->params.max_packet_count= ((1 << (_core_if->hwcfg3.b.packet_size_cntr_width + 4)) - 1);
+ else
+ _core_if->params.max_packet_count= _params->max_packet_count;
+ _core_if->params.phy_utmi_width = _params->phy_utmi_width;
+ _core_if->params.turn_around_time_hs = _params->turn_around_time_hs;
+ _core_if->params.turn_around_time_fs = _params->turn_around_time_fs;
+ _core_if->params.timeout_cal_hs = _params->timeout_cal_hs;
+ _core_if->params.timeout_cal_fs = _params->timeout_cal_fs;
+ usbcfg.d32 = ifxusb_rreg(&global_regs->gusbcfg);
+// usbcfg.b.ulpi_ext_vbus_drv = 1;
+ usbcfg.b.term_sel_dl_pulse = 0;
+ usbcfg.b.ForceDevMode = 0;
+ usbcfg.b.ForceHstMode = 1;
+ ifxusb_wreg (&global_regs->gusbcfg, usbcfg.d32);
+ /* Reset the Controller */
+ do
+ {
+ while(ifxusb_core_soft_reset_h( _core_if ))
+ ifxusb_hard_reset_h(_core_if);
+ } while (ifxusb_is_device_mode(_core_if));
+
+ usbcfg.d32 = ifxusb_rreg(&global_regs->gusbcfg);
+// usbcfg.b.ulpi_ext_vbus_drv = 1;
+ usbcfg.b.term_sel_dl_pulse = 0;
+ ifxusb_wreg (&global_regs->gusbcfg, usbcfg.d32);
+
+ /* This programming sequence needs to happen in FS mode before any other
+ * programming occurs */
+ /* High speed PHY. */
+ if (!_core_if->phy_init_done)
+ {
+ _core_if->phy_init_done = 1;
+ /* HS PHY parameters. These parameters are preserved
+ * during soft reset so only program the first time. Do
+ * a soft reset immediately after setting phyif. */
+ usbcfg.b.ulpi_utmi_sel = 0; //UTMI+
+ usbcfg.b.phyif = ( _core_if->params.phy_utmi_width == 16)?1:0;
+ ifxusb_wreg( &global_regs->gusbcfg, usbcfg.d32);
+ /* Reset after setting the PHY parameters */
+ ifxusb_core_soft_reset_h( _core_if );
+ }
+
+ usbcfg.d32 = ifxusb_rreg(&global_regs->gusbcfg);
+// usbcfg.b.ulpi_fsls = 0;
+// usbcfg.b.ulpi_clk_sus_m = 0;
+ usbcfg.b.term_sel_dl_pulse = 0;
+ usbcfg.b.ForceDevMode = 0;
+ usbcfg.b.ForceHstMode = 1;
+ ifxusb_wreg(&global_regs->gusbcfg, usbcfg.d32);
+
+ /* Program the GAHBCFG Register.*/
+ switch (_core_if->params.dma_burst_size)
+ {
+ case 0 :
+ ahbcfg.b.hburstlen = IFXUSB_GAHBCFG_INT_DMA_BURST_SINGLE;
+ break;
+ case 1 :
+ ahbcfg.b.hburstlen = IFXUSB_GAHBCFG_INT_DMA_BURST_INCR;
+ break;
+ case 4 :
+ ahbcfg.b.hburstlen = IFXUSB_GAHBCFG_INT_DMA_BURST_INCR4;
+ break;
+ case 8 :
+ ahbcfg.b.hburstlen = IFXUSB_GAHBCFG_INT_DMA_BURST_INCR8;
+ break;
+ case 16:
+ ahbcfg.b.hburstlen = IFXUSB_GAHBCFG_INT_DMA_BURST_INCR16;
+ break;
+ }
+ #if defined(__UNALIGNED_BUF_ADJ__) || defined(__UNALIGNED_BUF_CHK__)
+ _core_if->unaligned_mask=3;
+ #if defined(__UNALIGNED_BUF_BURST__)
+ switch(_core_if->params.dma_burst_size)
+ {
+ case 4 :
+ _core_if->unaligned_mask=15;
+ break;
+ case 8 :
+ _core_if->unaligned_mask=31;
+ break;
+ case 16:
+ _core_if->unaligned_mask=63;
+ break;
+ case 0 :
+ case 1 :
+ break;
+ default:
+ break;
+ }
+ #endif //defined(__UNALIGNED_BUF_BURST__)
+ #endif //defined(__UNALIGNED_BUF_ADJ__) || defined(__UNALIGNED_BUF_CHK__)
+ ahbcfg.b.dmaenable = 1;
+ ifxusb_wreg(&global_regs->gahbcfg, ahbcfg.d32);
+
+ /* Program the GUSBCFG register. */
+ usbcfg.d32 = ifxusb_rreg( &global_regs->gusbcfg );
+ usbcfg.b.hnpcap = 0;
+ usbcfg.b.srpcap = 0;
+ ifxusb_wreg( &global_regs->gusbcfg, usbcfg.d32);
+
+ /* Restart the Phy Clock */
+ ifxusb_wreg(_core_if->pcgcctl, 0);
+
+ /* Initialize Host Configuration Register */
+ {
+ hcfg_data_t hcfg;
+ hcfg.d32 = ifxusb_rreg(&_core_if->host_global_regs->hcfg);
+ hcfg.b.fslspclksel = IFXUSB_HCFG_30_60_MHZ;
+ if (_params->speed == IFXUSB_PARAM_SPEED_FULL)
+ hcfg.b.fslssupp = 1;
+ ifxusb_wreg(&_core_if->host_global_regs->hcfg, hcfg.d32);
+ }
+
+ _core_if->params.host_channels=(_core_if->hwcfg2.b.num_host_chan + 1);
+
+ if(_params->host_channels>0 && _params->host_channels < _core_if->params.host_channels)
+ _core_if->params.host_channels = _params->host_channels;
+
+ /* Configure data FIFO sizes */
+ _core_if->params.data_fifo_size = _core_if->hwcfg3.b.dfifo_depth;
+ _core_if->params.rx_fifo_size = ifxusb_rreg(&global_regs->grxfsiz);
+ _core_if->params.nperio_tx_fifo_size= ifxusb_rreg(&global_regs->gnptxfsiz) >> 16;
+ _core_if->params.perio_tx_fifo_size = ifxusb_rreg(&global_regs->hptxfsiz) >> 16;
+ IFX_DEBUGPL(DBG_CIL, "Initial: FIFO Size=0x%06X\n" , _core_if->params.data_fifo_size);
+ IFX_DEBUGPL(DBG_CIL, " Rx FIFO Size=0x%06X\n", _core_if->params.rx_fifo_size);
+ IFX_DEBUGPL(DBG_CIL, " NPTx FIFO Size=0x%06X\n", _core_if->params.nperio_tx_fifo_size);
+ IFX_DEBUGPL(DBG_CIL, " PTx FIFO Size=0x%06X\n", _core_if->params.perio_tx_fifo_size);
+
+ {
+ fifosize_data_t txfifosize;
+ if(_params->data_fifo_size >=0 && _params->data_fifo_size < _core_if->params.data_fifo_size)
+ _core_if->params.data_fifo_size = _params->data_fifo_size;
+
+ if( _params->rx_fifo_size >= 0 && _params->rx_fifo_size < _core_if->params.rx_fifo_size)
+ _core_if->params.rx_fifo_size = _params->rx_fifo_size;
+ if( _params->nperio_tx_fifo_size >=0 && _params->nperio_tx_fifo_size < _core_if->params.nperio_tx_fifo_size)
+ _core_if->params.nperio_tx_fifo_size = _params->nperio_tx_fifo_size;
+ if( _params->perio_tx_fifo_size >=0 && _params->perio_tx_fifo_size < _core_if->params.perio_tx_fifo_size)
+ _core_if->params.perio_tx_fifo_size = _params->perio_tx_fifo_size;
+
+ if(_core_if->params.data_fifo_size < _core_if->params.rx_fifo_size)
+ _core_if->params.rx_fifo_size = _core_if->params.data_fifo_size;
+ ifxusb_wreg( &global_regs->grxfsiz, _core_if->params.rx_fifo_size);
+ txfifosize.b.startaddr = _core_if->params.rx_fifo_size;
+
+ if(txfifosize.b.startaddr + _core_if->params.nperio_tx_fifo_size > _core_if->params.data_fifo_size)
+ _core_if->params.nperio_tx_fifo_size = _core_if->params.data_fifo_size - txfifosize.b.startaddr;
+ txfifosize.b.depth=_core_if->params.nperio_tx_fifo_size;
+ ifxusb_wreg( &global_regs->gnptxfsiz, txfifosize.d32);
+ txfifosize.b.startaddr += _core_if->params.nperio_tx_fifo_size;
+
+ if(txfifosize.b.startaddr + _core_if->params.perio_tx_fifo_size > _core_if->params.data_fifo_size)
+ _core_if->params.perio_tx_fifo_size = _core_if->params.data_fifo_size - txfifosize.b.startaddr;
+ txfifosize.b.depth=_core_if->params.perio_tx_fifo_size;
+ ifxusb_wreg( &global_regs->hptxfsiz, txfifosize.d32);
+ txfifosize.b.startaddr += _core_if->params.perio_tx_fifo_size;
+ }
+
+ #ifdef __DEBUG__
+ {
+ fifosize_data_t fifosize;
+ IFX_DEBUGPL(DBG_CIL, "Result : FIFO Size=0x%06X\n" , _core_if->params.data_fifo_size);
+
+ fifosize.d32=ifxusb_rreg(&global_regs->grxfsiz);
+ IFX_DEBUGPL(DBG_CIL, " Rx FIFO =0x%06X 0x%06X\n", fifosize.b.startaddr,fifosize.b.depth);
+ fifosize.d32=ifxusb_rreg(&global_regs->gnptxfsiz);
+ IFX_DEBUGPL(DBG_CIL, " NPTx FIFO =0x%06X 0x%06X\n", fifosize.b.startaddr,fifosize.b.depth);
+ fifosize.d32=ifxusb_rreg(&global_regs->hptxfsiz);
+ IFX_DEBUGPL(DBG_CIL, " PTx FIFO =0x%06X 0x%06X\n", fifosize.b.startaddr,fifosize.b.depth);
+ }
+ #endif
+
+ /* Clear Host Set HNP Enable in the OTG Control Register */
+ gotgctl.b.hstsethnpen = 1;
+ ifxusb_mreg( &global_regs->gotgctl, gotgctl.d32, 0);
+
+ /* Flush the FIFOs */
+ ifxusb_flush_tx_fifo_h(_core_if, 0x10); /* all Tx FIFOs */
+ ifxusb_flush_rx_fifo_h(_core_if);
+
+ for (i = 0; i < _core_if->hwcfg2.b.num_host_chan + 1; i++)
+ {
+ hcchar_data_t hcchar;
+ hcchar.d32 = ifxusb_rreg(&_core_if->hc_regs[i]->hcchar);
+ hcchar.b.chen = 0;
+ hcchar.b.chdis = 1;
+ hcchar.b.epdir = 0;
+ ifxusb_wreg(&_core_if->hc_regs[i]->hcchar, hcchar.d32);
+ }
+ /* Halt all channels to put them into a known state. */
+ for (i = 0; i < _core_if->hwcfg2.b.num_host_chan + 1; i++)
+ {
+ hcchar_data_t hcchar;
+ int count = 0;
+
+ hcchar.d32 = ifxusb_rreg(&_core_if->hc_regs[i]->hcchar);
+ hcchar.b.chen = 1;
+ hcchar.b.chdis = 1;
+ hcchar.b.epdir = 0;
+ ifxusb_wreg(&_core_if->hc_regs[i]->hcchar, hcchar.d32);
+
+ IFX_DEBUGPL(DBG_HCDV, "%s: Halt channel %d\n", __func__, i);
+ do{
+ hcchar.d32 = ifxusb_rreg(&_core_if->hc_regs[i]->hcchar);
+ if (++count > 1000)
+ {
+ IFX_ERROR("%s: Unable to clear halt on channel %d\n", __func__, i);
+ break;
+ }
+ } while (hcchar.b.chen);
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#if defined(__UEIP__)
+ #if defined(IFX_GPIO_USB_VBUS) || defined(IFX_LEDGPIO_USB_VBUS) || defined(IFX_LEDLED_USB_VBUS)
+ int ifxusb_vbus_status =-1;
+ #endif
+
+ #if defined(IFX_GPIO_USB_VBUS1) || defined(IFX_LEDGPIO_USB_VBUS1) || defined(IFX_LEDLED_USB_VBUS1)
+ int ifxusb_vbus1_status =-1;
+ #endif
+
+ #if defined(IFX_GPIO_USB_VBUS2) || defined(IFX_LEDGPIO_USB_VBUS2) || defined(IFX_LEDLED_USB_VBUS2)
+ int ifxusb_vbus2_status =-1;
+ #endif
+
+ #if defined(IFX_LEDGPIO_USB_VBUS) || defined(IFX_LEDLED_USB_VBUS)
+ static void *g_usb_vbus_trigger = NULL;
+ #endif
+ #if defined(IFX_LEDGPIO_USB_VBUS1) || defined(IFX_LEDLED_USB_VBUS1)
+ static void *g_usb_vbus1_trigger = NULL;
+ #endif
+ #if defined(IFX_LEDGPIO_USB_VBUS2) || defined(IFX_LEDLED_USB_VBUS2)
+ static void *g_usb_vbus2_trigger = NULL;
+ #endif
+
+ #if defined(IFX_GPIO_USB_VBUS) || defined(IFX_GPIO_USB_VBUS1) || defined(IFX_GPIO_USB_VBUS2)
+ int ifxusb_vbus_gpio_inited=0;
+ #endif
+
+#else //defined(__UEIP__)
+ int ifxusb_vbus_status =-1;
+ int ifxusb_vbus1_status =-1;
+ int ifxusb_vbus2_status =-1;
+ int ifxusb_vbus_gpio_inited=0;
+#endif
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+/*!
+ \fn void ifxusb_vbus_init(ifxusb_core_if_t *_core_if)
+ \brief This function init the VBUS control.
+ \param _core_if Pointer of core_if structure
+ \ingroup IFXUSB_CIF
+ */
+void ifxusb_vbus_init(ifxusb_core_if_t *_core_if)
+{
+ #if defined(__UEIP__)
+ #if defined(IFX_LEDGPIO_USB_VBUS) || defined(IFX_LEDLED_USB_VBUS)
+ if ( !g_usb_vbus_trigger )
+ {
+ ifx_led_trigger_register("USB_VBUS", &g_usb_vbus_trigger);
+ if ( g_usb_vbus_trigger != NULL )
+ {
+ struct ifx_led_trigger_attrib attrib = {0};
+ attrib.delay_on = 0;
+ attrib.delay_off = 0;
+ attrib.timeout = 0;
+ attrib.def_value = 0;
+ attrib.flags = IFX_LED_TRIGGER_ATTRIB_DELAY_ON | IFX_LED_TRIGGER_ATTRIB_DELAY_OFF | IFX_LED_TRIGGER_ATTRIB_TIMEOUT | IFX_LED_TRIGGER_ATTRIB_DEF_VALUE;
+ IFX_DEBUGP("Reg USB power!!\n");
+ ifx_led_trigger_set_attrib(g_usb_vbus_trigger, &attrib);
+ ifxusb_vbus_status =0;
+ }
+ }
+ #endif
+ #if defined(IFX_LEDGPIO_USB_VBUS1) || defined(IFX_LEDLED_USB_VBUS1)
+ if(_core_if->core_no==0 && !g_usb_vbus1_trigger )
+ {
+ ifx_led_trigger_register("USB_VBUS1", &g_usb_vbus1_trigger);
+ if ( g_usb_vbus1_trigger != NULL )
+ {
+ struct ifx_led_trigger_attrib attrib = {0};
+ attrib.delay_on = 0;
+ attrib.delay_off = 0;
+ attrib.timeout = 0;
+ attrib.def_value = 0;
+ attrib.flags = IFX_LED_TRIGGER_ATTRIB_DELAY_ON | IFX_LED_TRIGGER_ATTRIB_DELAY_OFF | IFX_LED_TRIGGER_ATTRIB_TIMEOUT | IFX_LED_TRIGGER_ATTRIB_DEF_VALUE;
+ IFX_DEBUGP("Reg USB1 power!!\n");
+ ifx_led_trigger_set_attrib(g_usb_vbus1_trigger, &attrib);
+ ifxusb_vbus1_status =0;
+ }
+ }
+ #endif
+ #if defined(IFX_LEDGPIO_USB_VBUS2) || defined(IFX_LEDLED_USB_VBUS2)
+ if(_core_if->core_no==1 && !g_usb_vbus2_trigger )
+ {
+ ifx_led_trigger_register("USB_VBUS2", &g_usb_vbus2_trigger);
+ if ( g_usb_vbus2_trigger != NULL )
+ {
+ struct ifx_led_trigger_attrib attrib = {0};
+ attrib.delay_on = 0;
+ attrib.delay_off = 0;
+ attrib.timeout = 0;
+ attrib.def_value = 0;
+ attrib.flags = IFX_LED_TRIGGER_ATTRIB_DELAY_ON | IFX_LED_TRIGGER_ATTRIB_DELAY_OFF | IFX_LED_TRIGGER_ATTRIB_TIMEOUT | IFX_LED_TRIGGER_ATTRIB_DEF_VALUE;
+ IFX_DEBUGP("Reg USB2 power!!\n");
+ ifx_led_trigger_set_attrib(g_usb_vbus2_trigger, &attrib);
+ ifxusb_vbus2_status =0;
+ }
+ }
+ #endif
+
+ #if defined(IFX_GPIO_USB_VBUS) || defined(IFX_GPIO_USB_VBUS1) || defined(IFX_GPIO_USB_VBUS2)
+ if(!ifxusb_vbus_gpio_inited)
+ {
+ if(!ifx_gpio_register(IFX_GPIO_MODULE_USB))
+ {
+ IFX_DEBUGP("Register USB VBus through GPIO OK!!\n");
+ #ifdef IFX_GPIO_USB_VBUS
+ ifxusb_vbus_status =0;
+ #endif //IFX_GPIO_USB_VBUS
+ #ifdef IFX_GPIO_USB_VBUS1
+ ifxusb_vbus1_status=0;
+ #endif //IFX_GPIO_USB_VBUS1
+ #ifdef IFX_GPIO_USB_VBUS2
+ ifxusb_vbus2_status=0;
+ #endif //IFX_GPIO_USB_VBUS2
+ }
+ else
+ IFX_PRINT("Register USB VBus Failed!!\n");
+ ifxusb_vbus_gpio_inited=1;
+ }
+ #endif //defined(IFX_GPIO_USB_VBUS) || defined(IFX_GPIO_USB_VBUS1) || defined(IFX_GPIO_USB_VBUS2)
+ #endif //defined(__UEIP__)
+}
+
+/*!
+ \fn void ifxusb_vbus_free(ifxusb_core_if_t *_core_if)
+ \brief This function free the VBUS control.
+ \param _core_if Pointer of core_if structure
+ \ingroup IFXUSB_CIF
+ */
+void ifxusb_vbus_free(ifxusb_core_if_t *_core_if)
+{
+ #if defined(__UEIP__)
+ #if defined(IFX_LEDGPIO_USB_VBUS) || defined(IFX_LEDLED_USB_VBUS)
+ if ( g_usb_vbus_trigger )
+ {
+ ifx_led_trigger_deregister(g_usb_vbus_trigger);
+ g_usb_vbus_trigger = NULL;
+ ifxusb_vbus_status =-1;
+ }
+ #endif
+ #if defined(IFX_LEDGPIO_USB_VBUS1) || defined(IFX_LEDLED_USB_VBUS1)
+ if(_core_if->core_no==0 && g_usb_vbus1_trigger )
+ {
+ ifx_led_trigger_deregister(g_usb_vbus1_trigger);
+ g_usb_vbus1_trigger = NULL;
+ ifxusb_vbus1_status =-1;
+ }
+ #endif
+ #if defined(IFX_LEDGPIO_USB_VBUS2) || defined(IFX_LEDLED_USB_VBUS2)
+ if(_core_if->core_no==1 && g_usb_vbus2_trigger )
+ {
+ ifx_led_trigger_deregister(g_usb_vbus2_trigger);
+ g_usb_vbus2_trigger = NULL;
+ ifxusb_vbus2_status =-1;
+ }
+ #endif
+
+ #if defined(IFX_GPIO_USB_VBUS) || defined(IFX_GPIO_USB_VBUS1) || defined(IFX_GPIO_USB_VBUS2)
+ if(ifxusb_vbus_gpio_inited)
+ {
+ ifx_gpio_deregister(IFX_GPIO_MODULE_USB);
+ #ifdef IFX_GPIO_USB_VBUS
+ ifxusb_vbus_status =-1;
+ #endif //IFX_GPIO_USB_VBUS
+ #ifdef IFX_GPIO_USB_VBUS1
+ ifxusb_vbus1_status=-1;
+ #endif //IFX_GPIO_USB_VBUS1
+ #ifdef IFX_GPIO_USB_VBUS2
+ ifxusb_vbus2_status=-1;
+ #endif //IFX_GPIO_USB_VBUS2
+ ifxusb_vbus_gpio_inited=0;
+ }
+ #endif //defined(IFX_GPIO_USB_VBUS) || defined(IFX_GPIO_USB_VBUS1) || defined(IFX_GPIO_USB_VBUS2)
+ #endif //defined(__UEIP__)
+}
+
+
+#if defined(__DO_OC_INT__)
+
+#define OC_Timer_Stable 3
+#define OC_Timer_Sleep 200
+#define OC_Timer_Max 3
+
+
+ #if defined(__IS_AR10__)
+ #if defined(__IS_DUAL__)
+ unsigned int oc1_int_installed=0;
+ unsigned int oc2_int_installed=0;
+ unsigned int oc1_int_count=0;
+ unsigned int oc2_int_count=0;
+ extern ifxhcd_hcd_t *oc1_int_id;
+ extern ifxhcd_hcd_t *oc2_int_id;
+
+ /*!
+ \brief Handles host mode Over Current Interrupt
+ */
+ struct timer_list oc1_retry_timer;
+ struct timer_list oc2_retry_timer;
+
+ void oc_retry_timer_func(unsigned long arg)
+ {
+ if(arg==1)
+ {
+ if(oc1_int_installed==0) //not installed
+ {
+ }
+ else if(oc1_int_installed==1) //disabled
+ {
+ }
+ else if(oc1_int_installed==2) //stablizing
+ {
+ oc1_int_installed=4;
+ oc1_int_count=0;
+ }
+ else if(oc1_int_installed==3) // sleeping
+ {
+ mod_timer(&oc1_retry_timer,jiffies + HZ*OC_Timer_Stable);
+ oc1_int_installed=2;
+ enable_irq(IFXUSB1_OC_IRQ);
+ }
+ else if(oc1_int_installed==4) //
+ {
+ oc1_int_count=0;
+ }
+ else if(oc1_int_installed==5) // Stable sleeping
+ {
+ mod_timer(&oc1_retry_timer,jiffies + HZ*OC_Timer_Stable);
+ oc1_int_installed=4;
+ enable_irq(IFXUSB1_OC_IRQ);
+ }
+ else
+ {
+ }
+ }
+ else
+ {
+ if(oc2_int_installed==0) //not installed
+ {
+ }
+ else if(oc2_int_installed==1) //disabled
+ {
+ }
+ else if(oc2_int_installed==2) //stablizing
+ {
+ oc2_int_installed=4;
+ oc2_int_count=0;
+ }
+ else if(oc2_int_installed==3) // sleeping
+ {
+ mod_timer(&oc2_retry_timer,jiffies + HZ*OC_Timer_Stable);
+ oc2_int_installed=2;
+ enable_irq(IFXUSB2_OC_IRQ);
+ }
+ else if(oc2_int_installed==4) //
+ {
+ oc2_int_count=0;
+ }
+ else if(oc2_int_installed==5) // Stable sleeping
+ {
+ mod_timer(&oc2_retry_timer,jiffies + HZ*OC_Timer_Stable);
+ oc2_int_installed=4;
+ enable_irq(IFXUSB2_OC_IRQ);
+ }
+ else
+ {
+ }
+ }
+ }
+
+ irqreturn_t ifxhcd_oc_irq(int _irq , void *_dev)
+ {
+ //ifxhcd_hcd_t *ifxhcd= _dev;
+ int32_t retval=1;
+ if(_irq==IFXUSB1_OC_IRQ)
+ {
+ if(oc1_int_installed==0) //not installed
+ {
+ }
+ else if(oc1_int_installed==1) //disabled
+ {
+ }
+ else if(oc1_int_installed==2) //stablizing
+ {
+ disable_irq_nosync(IFXUSB1_OC_IRQ);
+ mod_timer(&oc1_retry_timer,jiffies + HZ/OC_Timer_Sleep);
+ oc1_int_installed=3;
+ }
+ else if(oc1_int_installed==3) // sleeping
+ {
+ }
+ else if(oc1_int_installed==4) //
+ {
+ oc1_int_count++;
+ if(oc1_int_count>=OC_Timer_Max)
+ {
+ IFX_DEBUGP("OC INTERRUPT port #1\n");
+ oc1_int_id->flags.b.port_over_current_change = 1;
+ ifxusb_vbus_off(&oc1_int_id->core_if);
+ IFX_DEBUGP("Turning off port #1\n");
+ }
+ else
+ {
+ disable_irq_nosync(IFXUSB1_OC_IRQ);
+ mod_timer(&oc1_retry_timer,jiffies + HZ/OC_Timer_Sleep);
+ oc1_int_installed=5;
+ }
+ }
+ else if(oc1_int_installed==5) // Stable sleeping
+ {
+ }
+ }
+ else
+ {
+ if(oc2_int_installed==0) //not installed
+ {
+ }
+ else if(oc2_int_installed==1) //disabled
+ {
+ }
+ else if(oc2_int_installed==2) //stablizing
+ {
+ disable_irq_nosync(IFXUSB2_OC_IRQ);
+ mod_timer(&oc2_retry_timer,jiffies + HZ/OC_Timer_Sleep);
+ oc2_int_installed=3;
+ }
+ else if(oc2_int_installed==3) // sleeping
+ {
+ }
+ else if(oc2_int_installed==4) //
+ {
+ oc2_int_count++;
+ if(oc2_int_count>=OC_Timer_Max)
+ {
+ IFX_DEBUGP("OC INTERRUPT port #2\n");
+ oc2_int_id->flags.b.port_over_current_change = 1;
+ ifxusb_vbus_off(&oc2_int_id->core_if);
+ IFX_DEBUGP("Turning off port #2\n");
+ }
+ else
+ {
+ disable_irq_nosync(IFXUSB2_OC_IRQ);
+ mod_timer(&oc2_retry_timer,jiffies + HZ/OC_Timer_Sleep);
+ oc2_int_installed=5;
+ }
+ }
+ else if(oc2_int_installed==5) // Stable sleeping
+ {
+ }
+ }
+ return IRQ_RETVAL(retval);
+ }
+
+ void ifxusb_oc_int_on(int port)
+ {
+ if(port==1)
+ IFX_DEBUGPL( DBG_CIL, "registering (overcurrent) handler for port #1 irq%d\n", IFXUSB1_OC_IRQ);
+ else
+ IFX_DEBUGPL( DBG_CIL, "registering (overcurrent) handler for port #2 irq%d\n", IFXUSB2_OC_IRQ);
+ if((port==1&&oc1_int_id) || (port==2&&oc2_int_id)
+ {
+ if((port==1&&oc1_int_installed==0)||(port==2&&oc2_int_installed==0))
+ {
+ if(port==1)
+ {
+ oc1_int_installed=2;
+ init_timer(&oc1_retry_timer);
+ oc1_retry_timer.function = oc_retry_timer_func;
+ oc1_retry_timer.data=1;
+ if(request_irq((unsigned int)IFXUSB1_OC_IRQ, &ifxhcd_oc_irq,
+ IRQF_TRIGGER_NONE
+ // | IRQF_TRIGGER_RISING
+ // | IRQF_TRIGGER_FALLING
+ // | IRQF_TRIGGER_HIGH
+ // | IRQF_TRIGGER_LOW
+ // | IRQF_TRIGGER_PROBE
+ | IRQF_DISABLED
+ // | IRQF_SAMPLE_RANDOM
+ // | IRQF_SHARED
+ | IRQF_PROBE_SHARED
+ // | IRQF_TIMER
+ // | IRQF_PERCPU
+ // | IRQF_NOBALANCING
+ // | IRQF_IRQPOLL
+ // | IRQF_ONESHOT
+ ,
+ "ifxusb1_oc", (void *)oc1_int_id))
+ oc1_int_installed=0;
+ else
+ mod_timer(&oc1_retry_timer,jiffies + HZ*OC_Timer_Stable);
+ }
+ else
+ {
+ oc2_int_installed=2;
+ init_timer(&oc2_retry_timer);
+ oc2_retry_timer.function = oc_retry_timer_func;
+ oc2_retry_timer.data=2;
+ if(request_irq((unsigned int)IFXUSB2_OC_IRQ, &ifxhcd_oc_irq,
+ IRQF_TRIGGER_NONE
+ // | IRQF_TRIGGER_RISING
+ // | IRQF_TRIGGER_FALLING
+ // | IRQF_TRIGGER_HIGH
+ // | IRQF_TRIGGER_LOW
+ // | IRQF_TRIGGER_PROBE
+ | IRQF_DISABLED
+ // | IRQF_SAMPLE_RANDOM
+ // | IRQF_SHARED
+ | IRQF_PROBE_SHARED
+ // | IRQF_TIMER
+ // | IRQF_PERCPU
+ // | IRQF_NOBALANCING
+ // | IRQF_IRQPOLL
+ // | IRQF_ONESHOT
+ ,
+ "ifxusb2_oc", (void *)oc2_int_id))
+ oc2_int_installed=0;
+ else
+ mod_timer(&oc2_retry_timer,jiffies + HZ*OC_Timer_Stable);
+ }
+ /* Poll the event ring */
+ }
+ else if(port==1 && oc1_int_installed!=2 && oc1_int_installed!=4 )
+ {
+ oc1_int_installed=2;
+ enable_irq(IFXUSB1_OC_IRQ);
+ mod_timer(&oc1_retry_timer,jiffies + HZ*OC_Timer_Stable);
+ }
+ else if(port==2 && oc2_int_installed!=2 && oc2_int_installed!=4 )
+ {
+ oc2_int_installed=2;
+ enable_irq(IFXUSB2_OC_IRQ);
+ mod_timer(&oc2_retry_timer,jiffies + HZ*OC_Timer_Stable);
+ }
+ }
+ }
+
+ void ifxusb_oc_int_off(int port)
+ {
+ if(port==1)
+ {
+ disable_irq_nosync(IFXUSB1_OC_IRQ);
+ if(oc1_int_installed)
+ oc1_int_installed=1;
+ }
+ else
+ {
+ disable_irq_nosync(IFXUSB2_OC_IRQ);
+ if(oc2_int_installed)
+ oc2_int_installed=1;
+ }
+ }
+
+
+ void ifxusb_oc_int_free(int port)
+ {
+ if(port==1)
+ {
+ del_timer(&oc1_retry_timer);
+ disable_irq_nosync(IFXUSB1_OC_IRQ);
+ free_irq(IFXUSB1_OC_IRQ, (void *)oc1_int_id);
+ oc1_int_installed=0;
+ }
+ else
+ {
+ del_timer(&oc1_retry_timer);
+ disable_irq_nosync(IFXUSB1_OC_IRQ);
+ free_irq(IFXUSB2_OC_IRQ, (void *)oc2_int_id);
+ oc2_int_installed=0;
+ }
+ }
+
+ #elif defined(__IS_FIRST__) || defined(__IS_SECOND__)
+ unsigned int oc_int_installed=0;
+ unsigned int oc_int_count=0;
+ extern ifxhcd_hcd_t *oc_int_id;
+
+ /*!
+ \brief Handles host mode Over Current Interrupt
+ */
+ struct timer_list oc_retry_timer;
+
+ void oc_retry_timer_func(void)
+ {
+ if(oc_int_installed==0) //not installed
+ {
+ }
+ else if(oc_int_installed==1) //disabled
+ {
+ }
+ else if(oc_int_installed==2) //stablizing
+ {
+ oc_int_installed=4;
+ oc_int_count=0;
+ }
+ else if(oc_int_installed==3) // sleeping
+ {
+ mod_timer(&oc_retry_timer,jiffies + HZ*OC_Timer_Stable);
+ oc_int_installed=2;
+ #if defined(__IS_FIRST__)
+ enable_irq(IFXUSB1_OC_IRQ);
+ #else
+ enable_irq(IFXUSB2_OC_IRQ);
+ #endif
+ }
+ else if(oc_int_installed==4) //
+ {
+ oc_int_count=0;
+ }
+ else if(oc_int_installed==5) // Stable sleeping
+ {
+ mod_timer(&oc_retry_timer,jiffies + HZ*OC_Timer_Stable);
+ oc_int_installed=4;
+ #if defined(__IS_FIRST__)
+ enable_irq(IFXUSB1_OC_IRQ);
+ #else
+ enable_irq(IFXUSB2_OC_IRQ);
+ #endif
+ }
+ else
+ {
+ }
+ }
+
+ irqreturn_t ifxhcd_oc_irq(int _irq , void *_dev)
+ {
+ //ifxhcd_hcd_t *ifxhcd= _dev;
+ int32_t retval=1;
+ if(oc_int_installed==0) //not installed
+ {
+ }
+ else if(oc_int_installed==1) //disabled
+ {
+ }
+ else if(oc_int_installed==2) //stablizing
+ {
+ #if defined(__IS_FIRST__)
+ disable_irq_nosync(IFXUSB1_OC_IRQ);
+ #else
+ disable_irq_nosync(IFXUSB2_OC_IRQ);
+ #endif
+ mod_timer(&oc_retry_timer,jiffies + HZ/OC_Timer_Sleep);
+ oc_int_installed=3;
+ }
+ else if(oc_int_installed==3) // sleeping
+ {
+ }
+ else if(oc_int_installed==4) //
+ {
+ oc_int_count++;
+ if(oc_int_count>=OC_Timer_Max)
+ {
+ #if defined(__IS_FIRST__)
+ IFX_DEBUGP("OC INTERRUPT port #1\n");
+ #else
+ IFX_DEBUGP("OC INTERRUPT port #2\n");
+ #endif
+ oc_int_id->flags.b.port_over_current_change = 1;
+ ifxusb_vbus_off(&oc_int_id->core_if);
+ #if defined(__IS_FIRST__)
+ IFX_DEBUGP("Turning off port #1\n");
+ #else
+ IFX_DEBUGP("Turning off port #2\n");
+ #endif
+ }
+ else
+ {
+ #if defined(__IS_FIRST__)
+ disable_irq_nosync(IFXUSB1_OC_IRQ);
+ #else
+ disable_irq_nosync(IFXUSB2_OC_IRQ);
+ #endif
+ mod_timer(&oc_retry_timer,jiffies + HZ/OC_Timer_Sleep);
+ oc_int_installed=5;
+ }
+ }
+ else if(oc_int_installed==5) // Stable sleeping
+ {
+ }
+ return IRQ_RETVAL(retval);
+ }
+
+ void ifxusb_oc_int_on(void)
+ {
+ #if defined(__IS_FIRST__)
+ IFX_DEBUGPL( DBG_CIL, "registering (overcurrent) handler for port #1 irq%d\n", IFXUSB1_OC_IRQ);
+ #else
+ IFX_DEBUGPL( DBG_CIL, "registering (overcurrent) handler for port #2 irq%d\n", IFXUSB2_OC_IRQ);
+ #endif
+ if(oc_int_id)
+ {
+ if(oc_int_installed==0)
+ {
+ oc_int_installed=2;
+ init_timer(&oc_retry_timer);
+ oc_retry_timer.function = oc_retry_timer_func;
+ oc_retry_timer.data=1;
+ #if defined(__IS_FIRST__)
+ if(request_irq((unsigned int)IFXUSB1_OC_IRQ, &ifxhcd_oc_irq,
+ #else
+ if(request_irq((unsigned int)IFXUSB2_OC_IRQ, &ifxhcd_oc_irq,
+ #endif
+ IRQF_TRIGGER_NONE
+ // | IRQF_TRIGGER_RISING
+ // | IRQF_TRIGGER_FALLING
+ // | IRQF_TRIGGER_HIGH
+ // | IRQF_TRIGGER_LOW
+ // | IRQF_TRIGGER_PROBE
+ | IRQF_DISABLED
+ // | IRQF_SAMPLE_RANDOM
+ // | IRQF_SHARED
+ | IRQF_PROBE_SHARED
+ // | IRQF_TIMER
+ // | IRQF_PERCPU
+ // | IRQF_NOBALANCING
+ // | IRQF_IRQPOLL
+ // | IRQF_ONESHOT
+ ,
+ "ifxusb_oc", (void *)oc_int_id))
+ oc_int_installed=0;
+ else
+ mod_timer(&oc1_retry_timer,jiffies + HZ*OC_Timer_Stable);
+ }
+ else if(oc_int_installed!=2 && oc_int_installed!=4 )
+ {
+ oc_int_installed=2;
+ #if defined(__IS_FIRST__)
+ enable_irq(IFXUSB1_OC_IRQ);
+ #else
+ enable_irq(IFXUSB2_OC_IRQ);
+ #endif
+ mod_timer(&oc_retry_timer,jiffies + HZ*OC_Timer_Stable);
+ }
+ }
+ }
+
+ void ifxusb_oc_int_off(int port)
+ {
+ #if defined(__IS_FIRST__)
+ disable_irq_nosync(IFXUSB1_OC_IRQ);
+ #else
+ disable_irq_nosync(IFXUSB2_OC_IRQ);
+ #endif
+ }
+ void ifxusb_oc_int_free(int port)
+ {
+ #if defined(__IS_FIRST__)
+ free_irq(IFXUSB1_OC_IRQ, (void *)oc_int_id);
+ #else
+ free_irq(IFXUSB2_OC_IRQ, (void *)oc_int_id);
+ #endif
+ }
+ #endif
+ #else //!defined(__IS_AR10__)
+ unsigned int oc_int_installed=0;
+ unsigned int oc_int_count=0;
+ extern ifxhcd_hcd_t *oc_int_id;
+ #ifdef __IS_DUAL__
+ extern ifxhcd_hcd_t *oc_int_id_1;
+ extern ifxhcd_hcd_t *oc_int_id_2;
+ #endif
+
+ /*!
+ \brief Handles host mode Over Current Interrupt
+ */
+ struct timer_list oc_retry_timer;
+
+ void oc_retry_timer_func(unsigned long arg)
+ {
+ if(oc_int_installed==0) //not installed
+ {
+ }
+ else if(oc_int_installed==1) //disabled
+ {
+ }
+ else if(oc_int_installed==2) //stablizing
+ {
+ oc_int_installed=4;
+ oc_int_count=0;
+ }
+ else if(oc_int_installed==3) // sleeping
+ {
+ mod_timer(&oc_retry_timer,jiffies + HZ*OC_Timer_Stable);
+ oc_int_installed=2;
+ enable_irq(IFXUSB_OC_IRQ);
+ }
+ else if(oc_int_installed==4) //
+ {
+ oc_int_count=0;
+ }
+ else if(oc_int_installed==5) // Stable sleeping
+ {
+ mod_timer(&oc_retry_timer,jiffies + HZ*OC_Timer_Stable);
+ oc_int_installed=4;
+ enable_irq(IFXUSB_OC_IRQ);
+ }
+ else
+ {
+ }
+ }
+
+ irqreturn_t ifxhcd_oc_irq(int _irq , void *_dev)
+ {
+ //ifxhcd_hcd_t *ifxhcd= _dev;
+ int32_t retval=1;
+
+ if(oc_int_installed==0) //not installed
+ {
+ }
+ else if(oc_int_installed==1) //disabled
+ {
+ }
+ else if(oc_int_installed==2) //stablizing
+ {
+ disable_irq_nosync(IFXUSB_OC_IRQ);
+ mod_timer(&oc_retry_timer,jiffies + HZ/OC_Timer_Sleep);
+ oc_int_installed=3;
+ }
+ else if(oc_int_installed==3) // sleeping
+ {
+ }
+ else if(oc_int_installed==4) //
+ {
+ oc_int_count++;
+ if(oc_int_count>=OC_Timer_Max)
+ {
+ IFX_DEBUGP("OC INTERRUPT port #%d\n",oc_int_id->core_if.core_no);
+ #ifdef __IS_DUAL__
+ oc_int_id_1->flags.b.port_over_current_change = 1;
+ oc_int_id_2->flags.b.port_over_current_change = 1;
+ ifxusb_vbus_off(&oc_int_id_1->core_if);
+ IFX_DEBUGP("Turning off port #%d\n",oc_int_id_1->core_if.core_no);
+ ifxusb_vbus_off(&oc_int_id_2->core_if);
+ IFX_DEBUGP("Turning off port #%d\n",oc_int_id_2->core_if.core_no);
+ #else
+ oc_int_id->flags.b.port_over_current_change = 1;
+ ifxusb_vbus_off(&oc_int_id->core_if);
+ IFX_DEBUGP("Turning off port #%d\n",oc_int_id->core_if.core_no);
+ #endif
+ }
+ else
+ {
+ disable_irq_nosync(IFXUSB_OC_IRQ);
+ mod_timer(&oc_retry_timer,jiffies + HZ/OC_Timer_Sleep);
+ oc_int_installed=5;
+ }
+ }
+ else if(oc_int_installed==5) // Stable sleeping
+ {
+ }
+
+ return IRQ_RETVAL(retval);
+ }
+
+ void ifxusb_oc_int_on(void)
+ {
+ IFX_DEBUGPL( DBG_CIL, "registering (overcurrent) handler for irq%d\n", IFXUSB_OC_IRQ);
+ if(oc_int_id)
+ {
+ if(oc_int_installed==0)
+ {
+ oc_int_installed=2;
+ init_timer(&oc_retry_timer);
+ oc_retry_timer.function = oc_retry_timer_func;
+ /* Poll the event ring */
+
+ if(request_irq((unsigned int)IFXUSB_OC_IRQ, &ifxhcd_oc_irq,
+ IRQF_TRIGGER_NONE
+ // | IRQF_TRIGGER_RISING
+ // | IRQF_TRIGGER_FALLING
+ // | IRQF_TRIGGER_HIGH
+ // | IRQF_TRIGGER_LOW
+ // | IRQF_TRIGGER_PROBE
+ | IRQF_DISABLED
+ // | IRQF_SAMPLE_RANDOM
+ // | IRQF_SHARED
+ // | IRQF_PROBE_SHARED
+ // | IRQF_TIMER
+ // | IRQF_PERCPU
+ // | IRQF_NOBALANCING
+ // | IRQF_IRQPOLL
+ // | IRQF_ONESHOT
+ ,
+ "ifxusb_oc", (void *)oc_int_id))
+ oc_int_installed=0;
+ else
+ mod_timer(&oc_retry_timer,jiffies + HZ*OC_Timer_Stable);
+ }
+ else if(oc_int_installed!=2 && oc_int_installed!=4 )
+ {
+ oc_int_installed=2;
+ enable_irq(IFXUSB_OC_IRQ);
+ mod_timer(&oc_retry_timer,jiffies + HZ*OC_Timer_Stable);
+ }
+ }
+ }
+
+ void ifxusb_oc_int_off(void)
+ {
+ disable_irq_nosync(IFXUSB_OC_IRQ);
+ if(oc_int_installed)
+ oc_int_installed=1;
+ }
+
+ void ifxusb_oc_int_free(void)
+ {
+ del_timer(&oc_retry_timer);
+ disable_irq_nosync(IFXUSB_OC_IRQ);
+ if(oc_int_installed)
+ free_irq(IFXUSB_OC_IRQ, (void *)oc_int_id);
+ oc_int_installed=0;
+ }
+ #endif
+#endif
+
+
+/*!
+ \fn void ifxusb_vbus_on(ifxusb_core_if_t *_core_if)
+ \brief Turn on the USB 5V VBus Power
+ \param _core_if Pointer of core_if structure
+ \ingroup IFXUSB_CIF
+ */
+void ifxusb_vbus_on(ifxusb_core_if_t *_core_if)
+{
+ IFX_DEBUGP("SENDING VBus POWER UP\n");
+ #if defined(__UEIP__)
+ #if defined(IFX_LEDGPIO_USB_VBUS) || defined(IFX_LEDLED_USB_VBUS)
+ if ( g_usb_vbus_trigger && ifxusb_vbus_status==0)
+ {
+ ifx_led_trigger_activate(g_usb_vbus_trigger);
+ IFX_DEBUGP("Enable USB power!!\n");
+ ifxusb_vbus_status=1;
+ }
+ #endif
+ #if defined(IFX_LEDGPIO_USB_VBUS1) || defined(IFX_LEDLED_USB_VBUS1)
+ if(_core_if->core_no==0 && g_usb_vbus1_trigger && ifxusb_vbus1_status==0)
+ {
+ ifx_led_trigger_activate(g_usb_vbus1_trigger);
+ IFX_DEBUGP("Enable USB1 power!!\n");
+ ifxusb_vbus1_status=1;
+ }
+ #endif
+ #if defined(IFX_LEDGPIO_USB_VBUS2) || defined(IFX_LEDLED_USB_VBUS2)
+ if(_core_if->core_no==1 && g_usb_vbus2_trigger && ifxusb_vbus2_status==0)
+ {
+ ifx_led_trigger_activate(g_usb_vbus2_trigger);
+ IFX_DEBUGP("Enable USB2 power!!\n");
+ ifxusb_vbus2_status=1;
+ }
+ #endif
+
+ #if defined(IFX_GPIO_USB_VBUS) || defined(IFX_GPIO_USB_VBUS1) || defined(IFX_GPIO_USB_VBUS2)
+ if(ifxusb_vbus_gpio_inited)
+ {
+ #if defined(IFX_GPIO_USB_VBUS)
+ if(ifxusb_vbus_status==0)
+ {
+ ifx_gpio_output_set(IFX_GPIO_USB_VBUS,IFX_GPIO_MODULE_USB);
+ ifxusb_vbus_status=1;
+ }
+ #endif
+ #if defined(IFX_GPIO_USB_VBUS1)
+ if(_core_if->core_no==0 && ifxusb_vbus1_status==0)
+ {
+ ifx_gpio_output_set(IFX_GPIO_USB_VBUS1,IFX_GPIO_MODULE_USB);
+ ifxusb_vbus1_status=1;
+ }
+ #endif
+ #if defined(IFX_GPIO_USB_VBUS2)
+ if(_core_if->core_no==1 && ifxusb_vbus2_status==0)
+ {
+ ifx_gpio_output_set(IFX_GPIO_USB_VBUS2,IFX_GPIO_MODULE_USB);
+ ifxusb_vbus2_status=1;
+ }
+ #endif
+ }
+ #endif //defined(IFX_GPIO_USB_VBUS) || defined(IFX_GPIO_USB_VBUS1) || defined(IFX_GPIO_USB_VBUS2)
+ #else
+ #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ ifxusb_vbus_status=1;
+ //usb_set_vbus_on();
+ #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ #if defined(__IS_AMAZON_SE__)
+ set_bit (4, (volatile unsigned long *)AMAZON_SE_GPIO_P0_OUT);
+ ifxusb_vbus_status=1;
+ #endif //defined(__IS_AMAZON_SE__)
+ #if defined(__IS_AR9__)
+ if(_core_if->core_no==0)
+ {
+ if (bsp_port_reserve_pin(1, 13, PORT_MODULE_USB) != 0)
+ {
+ IFX_PRINT("Can't enable USB1 5.5V power!!\n");
+ return;
+ }
+ bsp_port_clear_altsel0(1, 13, PORT_MODULE_USB);
+ bsp_port_clear_altsel1(1, 13, PORT_MODULE_USB);
+ bsp_port_set_dir_out(1, 13, PORT_MODULE_USB);
+ bsp_port_set_pudsel(1, 13, PORT_MODULE_USB);
+ bsp_port_set_puden(1, 13, PORT_MODULE_USB);
+ bsp_port_set_output(1, 13, PORT_MODULE_USB);
+ IFX_DEBUGP("Enable USB1 power!!\n");
+ ifxusb_vbus1_status=1;
+ }
+ else
+ {
+ if (bsp_port_reserve_pin(3, 4, PORT_MODULE_USB) != 0)
+ {
+ IFX_PRINT("Can't enable USB2 5.5V power!!\n");
+ return;
+ }
+ bsp_port_clear_altsel0(3, 4, PORT_MODULE_USB);
+ bsp_port_clear_altsel1(3, 4, PORT_MODULE_USB);
+ bsp_port_set_dir_out(3, 4, PORT_MODULE_USB);
+ bsp_port_set_pudsel(3, 4, PORT_MODULE_USB);
+ bsp_port_set_puden(3, 4, PORT_MODULE_USB);
+ bsp_port_set_output(3, 4, PORT_MODULE_USB);
+ IFX_DEBUGP("Enable USB2 power!!\n");
+ ifxusb_vbus2_status=1;
+ }
+ #endif //defined(__IS_AR9__)
+ #if defined(__IS_VR9__)
+ if(_core_if->core_no==0)
+ {
+ ifxusb_vbus1_status=1;
+ }
+ else
+ {
+ ifxusb_vbus2_status=1;
+ }
+ #endif //defined(__IS_VR9__)
+ #endif //defined(__UEIP__)
+
+ #if defined(__DO_OC_INT__)
+ #if defined(__IS_AR10__) && defined(__IS_DUAL__)
+ if(_core_if->core_no==0)
+ ifxusb_oc_int_on(1);
+ else
+ ifxusb_oc_int_on(2);
+ #else
+ ifxusb_oc_int_on();
+ #endif
+ #endif
+
+}
+
+
+/*!
+ \fn void ifxusb_vbus_off(ifxusb_core_if_t *_core_if)
+ \brief Turn off the USB 5V VBus Power
+ \param _core_if Pointer of core_if structure
+ \ingroup IFXUSB_CIF
+ */
+void ifxusb_vbus_off(ifxusb_core_if_t *_core_if)
+{
+ IFX_DEBUGP("SENDING VBus POWER OFF\n");
+
+ #if defined(__UEIP__)
+ #if defined(IFX_LEDGPIO_USB_VBUS) || defined(IFX_LEDLED_USB_VBUS)
+ if ( g_usb_vbus_trigger && ifxusb_vbus_status==1)
+ {
+ ifx_led_trigger_deactivate(g_usb_vbus_trigger);
+ IFX_DEBUGP("Disable USB power!!\n");
+ ifxusb_vbus_status=0;
+ }
+ #endif
+ #if defined(IFX_LEDGPIO_USB_VBUS1) || defined(IFX_LEDLED_USB_VBUS1)
+ if(_core_if->core_no==0 && g_usb_vbus1_trigger && ifxusb_vbus1_status==1)
+ {
+ ifx_led_trigger_deactivate(g_usb_vbus1_trigger);
+ IFX_DEBUGP("Disable USB1 power!!\n");
+ ifxusb_vbus1_status=0;
+ }
+ #endif
+ #if defined(IFX_LEDGPIO_USB_VBUS2) || defined(IFX_LEDLED_USB_VBUS2)
+ if(_core_if->core_no==1 && g_usb_vbus2_trigger && ifxusb_vbus2_status==1)
+ {
+ ifx_led_trigger_deactivate(g_usb_vbus2_trigger);
+ IFX_DEBUGP("Disable USB2 power!!\n");
+ ifxusb_vbus2_status=0;
+ }
+ #endif
+
+ #if defined(IFX_GPIO_USB_VBUS) || defined(IFX_GPIO_USB_VBUS1) || defined(IFX_GPIO_USB_VBUS2)
+ if(ifxusb_vbus_gpio_inited)
+ {
+ #if defined(IFX_GPIO_USB_VBUS)
+ if(ifxusb_vbus_status==1)
+ {
+ ifx_gpio_output_clear(IFX_GPIO_USB_VBUS,IFX_GPIO_MODULE_USB);
+ ifxusb_vbus_status=0;
+ }
+ #endif
+ #if defined(IFX_GPIO_USB_VBUS1)
+ if(_core_if->core_no==0 && ifxusb_vbus1_status==1)
+ {
+ ifx_gpio_output_clear(IFX_GPIO_USB_VBUS1,IFX_GPIO_MODULE_USB);
+ ifxusb_vbus1_status=0;
+ }
+ #endif
+ #if defined(IFX_GPIO_USB_VBUS2)
+ if(_core_if->core_no==1 && ifxusb_vbus2_status==1)
+ {
+ ifx_gpio_output_clear(IFX_GPIO_USB_VBUS2,IFX_GPIO_MODULE_USB);
+ ifxusb_vbus2_status=0;
+ }
+ #endif
+ }
+ #endif //defined(IFX_GPIO_USB_VBUS) || defined(IFX_GPIO_USB_VBUS1) || defined(IFX_GPIO_USB_VBUS2)
+ #else
+ #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ ifxusb_vbus_status=0;
+ //usb_set_vbus_on();
+ #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ #if defined(__IS_AMAZON_SE__)
+ clear_bit (4, (volatile unsigned long *)AMAZON_SE_GPIO_P0_OUT);
+ ifxusb_vbus_status=0;
+ #endif //defined(__IS_AMAZON_SE__)
+ #if defined(__IS_AR9__)
+ if(_core_if->core_no==0)
+ {
+ if (bsp_port_reserve_pin(1, 13, PORT_MODULE_USB) != 0) {
+ IFX_PRINT("Can't Disable USB1 5.5V power!!\n");
+ return;
+ }
+ bsp_port_clear_altsel0(1, 13, PORT_MODULE_USB);
+ bsp_port_clear_altsel1(1, 13, PORT_MODULE_USB);
+ bsp_port_set_dir_out(1, 13, PORT_MODULE_USB);
+ bsp_port_set_pudsel(1, 13, PORT_MODULE_USB);
+ bsp_port_set_puden(1, 13, PORT_MODULE_USB);
+ bsp_port_clear_output(1, 13, PORT_MODULE_USB);
+ IFX_DEBUGP("Disable USB1 power!!\n");
+ ifxusb_vbus1_status=0;
+ }
+ else
+ {
+ if (bsp_port_reserve_pin(3, 4, PORT_MODULE_USB) != 0) {
+ IFX_PRINT("Can't Disable USB2 5.5V power!!\n");
+ return;
+ }
+ bsp_port_clear_altsel0(3, 4, PORT_MODULE_USB);
+ bsp_port_clear_altsel1(3, 4, PORT_MODULE_USB);
+ bsp_port_set_dir_out(3, 4, PORT_MODULE_USB);
+ bsp_port_set_pudsel(3, 4, PORT_MODULE_USB);
+ bsp_port_set_puden(3, 4, PORT_MODULE_USB);
+ bsp_port_clear_output(3, 4, PORT_MODULE_USB);
+ IFX_DEBUGP("Disable USB2 power!!\n");
+
+ ifxusb_vbus2_status=0;
+ }
+ #endif //defined(__IS_AR9__)
+ #if defined(__IS_VR9__)
+ if(_core_if->core_no==0)
+ {
+ ifxusb_vbus1_status=0;
+ }
+ else
+ {
+ ifxusb_vbus2_status=0;
+ }
+ #endif //defined(__IS_VR9__)
+ #endif //defined(__UEIP__)
+ #if defined(__DO_OC_INT__)
+ #if defined(__IS_AR10__) && defined(__IS_DUAL__)
+ if(_core_if->core_no==0)
+ ifxusb_oc_int_off(1);
+ else
+ ifxusb_oc_int_off(2);
+ #else
+ ifxusb_oc_int_off();
+ #endif
+ #endif
+}
+
+
+/*!
+ \fn int ifxusb_vbus(ifxusb_core_if_t *_core_if)
+ \brief Read Current VBus status
+ \param _core_if Pointer of core_if structure
+ \ingroup IFXUSB_CIF
+ */
+int ifxusb_vbus(ifxusb_core_if_t *_core_if)
+{
+#if defined(__UEIP__)
+ #if defined(IFX_GPIO_USB_VBUS) || defined(IFX_LEDGPIO_USB_VBUS) || defined(IFX_LEDLED_USB_VBUS)
+ return (ifxusb_vbus_status);
+ #endif
+
+ #if defined(IFX_GPIO_USB_VBUS1) || defined(IFX_LEDGPIO_USB_VBUS1) || defined(IFX_LEDLED_USB_VBUS1)
+ if(_core_if->core_no==0)
+ return (ifxusb_vbus1_status);
+ #endif
+
+ #if defined(IFX_GPIO_USB_VBUS2) || defined(IFX_LEDGPIO_USB_VBUS2) || defined(IFX_LEDLED_USB_VBUS2)
+ if(_core_if->core_no==1)
+ return (ifxusb_vbus2_status);
+ #endif
+#else //defined(__UEIP__)
+#endif
+ return -1;
+}
+
+#if defined(__UEIP__)
+#else
+ #if defined(__IS_TWINPASS__)
+ #define ADSL_BASE 0x20000
+ #define CRI_BASE 0x31F00
+ #define CRI_CCR0 CRI_BASE + 0x00
+ #define CRI_CCR1 CRI_BASE + 0x01*4
+ #define CRI_CDC0 CRI_BASE + 0x02*4
+ #define CRI_CDC1 CRI_BASE + 0x03*4
+ #define CRI_RST CRI_BASE + 0x04*4
+ #define CRI_MASK0 CRI_BASE + 0x05*4
+ #define CRI_MASK1 CRI_BASE + 0x06*4
+ #define CRI_MASK2 CRI_BASE + 0x07*4
+ #define CRI_STATUS0 CRI_BASE + 0x08*4
+ #define CRI_STATUS1 CRI_BASE + 0x09*4
+ #define CRI_STATUS2 CRI_BASE + 0x0A*4
+ #define CRI_AMASK0 CRI_BASE + 0x0B*4
+ #define CRI_AMASK1 CRI_BASE + 0x0C*4
+ #define CRI_UPDCTL CRI_BASE + 0x0D*4
+ #define CRI_MADST CRI_BASE + 0x0E*4
+ // 0x0f is missing
+ #define CRI_EVENT0 CRI_BASE + 0x10*4
+ #define CRI_EVENT1 CRI_BASE + 0x11*4
+ #define CRI_EVENT2 CRI_BASE + 0x12*4
+
+ #define IRI_I_ENABLE 0x32000
+ #define STY_SMODE 0x3c004
+ #define AFE_TCR_0 0x3c0dc
+ #define AFE_ADDR_ADDR 0x3c0e8
+ #define AFE_RDATA_ADDR 0x3c0ec
+ #define AFE_WDATA_ADDR 0x3c0f0
+ #define AFE_CONFIG 0x3c0f4
+ #define AFE_SERIAL_CFG 0x3c0fc
+
+ #define DFE_BASE_ADDR 0xBE116000
+ //#define DFE_BASE_ADDR 0x9E116000
+
+ #define MEI_FR_ARCINT_C (DFE_BASE_ADDR + 0x0000001C)
+ #define MEI_DBG_WADDR_C (DFE_BASE_ADDR + 0x00000024)
+ #define MEI_DBG_RADDR_C (DFE_BASE_ADDR + 0x00000028)
+ #define MEI_DBG_DATA_C (DFE_BASE_ADDR + 0x0000002C)
+ #define MEI_DBG_DECO_C (DFE_BASE_ADDR + 0x00000030)
+ #define MEI_DBG_MASTER_C (DFE_BASE_ADDR + 0x0000003C)
+
+ static void WriteARCmem(uint32_t addr, uint32_t data)
+ {
+ writel(1 ,(volatile uint32_t *)MEI_DBG_MASTER_C);
+ writel(1 ,(volatile uint32_t *)MEI_DBG_DECO_C );
+ writel(addr ,(volatile uint32_t *)MEI_DBG_WADDR_C );
+ writel(data ,(volatile uint32_t *)MEI_DBG_DATA_C );
+ while( (ifxusb_rreg((volatile uint32_t *)MEI_FR_ARCINT_C) & 0x20) != 0x20 ){};
+ writel(0 ,(volatile uint32_t *)MEI_DBG_MASTER_C);
+ IFX_DEBUGP("WriteARCmem %08x %08x\n",addr,data);
+ };
+
+ static uint32_t ReadARCmem(uint32_t addr)
+ {
+ u32 data;
+ writel(1 ,(volatile uint32_t *)MEI_DBG_MASTER_C);
+ writel(1 ,(volatile uint32_t *)MEI_DBG_DECO_C );
+ writel(addr ,(volatile uint32_t *)MEI_DBG_RADDR_C );
+ while( (ifxusb_rreg((volatile uint32_t *)MEI_FR_ARCINT_C) & 0x20) != 0x20 ){};
+ data = ifxusb_rreg((volatile uint32_t *)MEI_DBG_DATA_C );
+ writel(0 ,(volatile uint32_t *)MEI_DBG_MASTER_C);
+ IFX_DEBUGP("ReadARCmem %08x %08x\n",addr,data);
+ return data;
+ };
+
+ void ifxusb_enable_afe_oc(void)
+ {
+ /* Start the clock */
+ WriteARCmem(CRI_UPDCTL ,0x00000008);
+ WriteARCmem(CRI_CCR0 ,0x00000014);
+ WriteARCmem(CRI_CCR1 ,0x00000500);
+ WriteARCmem(AFE_CONFIG ,0x000001c8);
+ WriteARCmem(AFE_SERIAL_CFG,0x00000016); // (DANUBE_PCI_CFG_BASE+(1<<addrline))AFE serial interface clock & data latch edge
+ WriteARCmem(AFE_TCR_0 ,0x00000002);
+ //Take afe out of reset
+ WriteARCmem(AFE_CONFIG ,0x000000c0);
+ WriteARCmem(IRI_I_ENABLE ,0x00000101);
+ WriteARCmem(STY_SMODE ,0x00001980);
+
+ ReadARCmem(CRI_UPDCTL );
+ ReadARCmem(CRI_CCR0 );
+ ReadARCmem(CRI_CCR1 );
+ ReadARCmem(AFE_CONFIG );
+ ReadARCmem(AFE_SERIAL_CFG); // (DANUBE_PCI_CFG_BASE+(1<<addrline))AFE serial interface clock & data latch edge
+ ReadARCmem(AFE_TCR_0 );
+ ReadARCmem(AFE_CONFIG );
+ ReadARCmem(IRI_I_ENABLE );
+ ReadARCmem(STY_SMODE );
+ }
+ #endif //defined(__IS_TWINPASS__)
+#endif //defined(__UEIP__)
+
diff --git a/package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxusb_ctl.c.svn-base b/package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxusb_ctl.c.svn-base
new file mode 100644
index 0000000..32878e3
--- /dev/null
+++ b/package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxusb_ctl.c.svn-base
@@ -0,0 +1,3825 @@
+/*****************************************************************************
+ ** FILE NAME : ifxusb_ctl.c
+ ** PROJECT : IFX USB sub-system V3
+ ** MODULES : IFX USB sub-system Host and Device driver
+ ** SRC VERSION : 1.0
+ ** SRC VERSION : 3.2
+ ** DATE : 1/Jan/2011
+ ** DESCRIPTION : Implementing the procfs and sysfs for IFX USB driver
+ ** FUNCTIONS :
+ ** COMPILER : gcc
+ ** REFERENCE : Synopsys DWC-OTG Driver 2.7
+ ** COPYRIGHT : Copyright (c) 2010
+ ** LANTIQ DEUTSCHLAND GMBH,
+ ** Am Campeon 3, 85579 Neubiberg, Germany
+ **
+ ** 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 of the License, or
+ ** (at your option) any later version.
+ **
+ ** Version Control Section **
+ ** $Author$
+ ** $Date$
+ ** $Revisions$
+ ** $Log$ Revision history
+ *****************************************************************************/
+
+/*
+ * This file contains code fragments from Synopsys HS OTG Linux Software Driver.
+ * For this code the following notice is applicable:
+ *
+ * ==========================================================================
+ *
+ * Synopsys HS OTG Linux Software Driver and documentation (hereinafter,
+ * "Software") is an Unsupported proprietary work of Synopsys, Inc. unless
+ * otherwise expressly agreed to in writing between Synopsys and you.
+ *
+ * The Software IS NOT an item of Licensed Software or Licensed Product under
+ * any End User Software License Agreement or Agreement for Licensed Product
+ * with Synopsys or any supplement thereto. You are permitted to use and
+ * redistribute this Software in source and binary forms, with or without
+ * modification, provided that redistributions of source code must retain this
+ * notice. You may not view, use, disclose, copy or distribute this file or
+ * any information contained herein except pursuant to this license grant from
+ * Synopsys. If you do not agree with this notice, including the disclaimer
+ * below, then you are not authorized to use the Software.
+ *
+ * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" BASIS
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ * ========================================================================== */
+
+/*! \file ifxusb_ctl.c
+ \ingroup IFXUSB_DRIVER_V3
+ \brief Implementing the procfs and sysfs for IFX USB driver
+*/
+
+#include <linux/version.h>
+#include "ifxusb_version.h"
+
+
+#include <linux/proc_fs.h>
+#include <asm/byteorder.h>
+#include <asm/unaligned.h>
+#include <asm/uaccess.h>
+
+#include "ifxusb_plat.h"
+#include "ifxusb_regs.h"
+#include "ifxusb_cif.h"
+
+#ifdef __IS_DEVICE__
+ #include "ifxpcd.h"
+ #ifdef __GADGET_COC__
+ #include <asm/ifx/ifx_types.h>
+ #include <asm/ifx/ifx_pmcu.h>
+ IFX_PMCU_REGISTER_t pmcuRegisterUSBGadget;
+ #endif
+#endif
+
+#ifdef __IS_HOST__
+ #include "ifxhcd.h"
+ #ifdef __HOST_COC__
+ #include <asm/ifx/ifx_types.h>
+ #include <asm/ifx/ifx_pmcu.h>
+ #ifdef __IS_DUAL__
+ IFX_PMCU_REGISTER_t pmcuRegisterUSBHost_1;
+ IFX_PMCU_REGISTER_t pmcuRegisterUSBHost_2;
+ #else
+ IFX_PMCU_REGISTER_t pmcuRegisterUSBHost;
+ #endif
+ #endif
+#endif
+
+#include <linux/device.h>
+#include <linux/platform_device.h>
+#include <linux/gfp.h>
+
+#ifdef __IS_HOST__
+ extern char ifxusb_hcd_driver_name[];
+
+ #ifdef __IS_DUAL__
+ extern ifxhcd_hcd_t ifxusb_hcd_1;
+ extern ifxhcd_hcd_t ifxusb_hcd_2;
+ extern char ifxusb_hcd_name_1[];
+ extern char ifxusb_hcd_name_2[];
+ #else
+ extern ifxhcd_hcd_t ifxusb_hcd;
+ extern char ifxusb_hcd_name[];
+ #endif
+
+#endif
+
+#ifdef __IS_DEVICE__
+ extern char ifxusb_pcd_driver_name[];
+
+ extern ifxpcd_pcd_t ifxusb_pcd;
+ extern char ifxusb_pcd_name[];
+#endif
+
+
+//Attributes for sysfs (for 2.6 only)
+
+#ifdef __IS_HOST__
+extern struct device_attribute dev_attr_version_h;
+#else
+extern struct device_attribute dev_attr_version_d;
+#endif
+#ifdef __IS_HOST__
+extern struct device_attribute dev_attr_dbglevel_h;
+#else
+extern struct device_attribute dev_attr_dbglevel_d;
+#endif
+#ifdef __IS_HOST__
+ #ifdef __IS_DUAL__
+ extern struct device_attribute dev_attr_suspend_host_1;
+ extern struct device_attribute dev_attr_suspend_host_2;
+ extern struct device_attribute dev_attr_probe_host_1;
+ extern struct device_attribute dev_attr_probe_host_2;
+ extern struct device_attribute dev_attr_probe_timer1_val_h;
+ extern struct device_attribute dev_attr_probe_timer2_val_h;
+ extern struct device_attribute dev_attr_autoprobe_timer1_val_h;
+ extern struct device_attribute dev_attr_autoprobe_timer2_val_h;
+ #else
+ extern struct device_attribute dev_attr_suspend_host;
+ extern struct device_attribute dev_attr_probe_host;
+ extern struct device_attribute dev_attr_probe_timer_val_h;
+ extern struct device_attribute dev_attr_autoprobe_timer_val_h;
+ #endif
+#endif
+
+#ifdef __IS_DEVICE__
+ extern struct device_attribute dev_attr_suspend_device;
+ extern struct device_attribute dev_attr_probe_device;
+ extern struct device_attribute dev_attr_probe_timer_val_d;
+ extern struct device_attribute dev_attr_autoprobe_timer_val_d;
+#endif
+
+#ifdef __IS_HOST__
+ #ifdef __IS_DUAL__
+ extern struct device_attribute dev_attr_dump_params_h_1;
+ extern struct device_attribute dev_attr_dump_params_h_2;
+ extern struct device_attribute dev_attr_mode_h_1;
+ extern struct device_attribute dev_attr_mode_h_2;
+ #else
+ extern struct device_attribute dev_attr_dump_params_h;
+ extern struct device_attribute dev_attr_mode_h;
+ #endif
+#else
+ extern struct device_attribute dev_attr_dump_params_d;
+ extern struct device_attribute dev_attr_mode_d;
+#endif
+
+#ifdef __IS_HOST__
+ #ifdef __IS_DUAL__
+ extern struct device_attribute dev_attr_pkt_count_limit_bi_1;
+ extern struct device_attribute dev_attr_pkt_count_limit_bo_1;
+ extern struct device_attribute dev_attr_pkt_count_limit_bi_2;
+ extern struct device_attribute dev_attr_pkt_count_limit_bo_2;
+ extern struct device_attribute dev_attr_bandwidth_fs_1;
+ extern struct device_attribute dev_attr_bandwidth_ls_1;
+ extern struct device_attribute dev_attr_bandwidth_hs_2;
+ extern struct device_attribute dev_attr_bandwidth_fs_2;
+ extern struct device_attribute dev_attr_bandwidth_ls_2;
+ extern struct device_attribute dev_attr_buspower_1;
+ extern struct device_attribute dev_attr_buspower_2;
+ extern struct device_attribute dev_attr_bussuspend_1;
+ extern struct device_attribute dev_attr_bussuspend_2;
+ extern struct device_attribute dev_attr_busconnected_1;
+ extern struct device_attribute dev_attr_busconnected_2;
+ extern struct device_attribute dev_attr_connectspeed_1;
+ extern struct device_attribute dev_attr_connectspeed_1;
+ #else
+ extern struct device_attribute dev_attr_pkt_count_limit_bi;
+ extern struct device_attribute dev_attr_pkt_count_limit_bo;
+ extern struct device_attribute dev_attr_bandwidth_hs;
+ extern struct device_attribute dev_attr_bandwidth_fs;
+ extern struct device_attribute dev_attr_bandwidth_ls;
+ extern struct device_attribute dev_attr_buspower;
+ extern struct device_attribute dev_attr_bussuspend;
+ extern struct device_attribute dev_attr_busconnected;
+ extern struct device_attribute dev_attr_connectspeed;
+ #endif
+#endif //__IS_HOST__
+
+#ifdef __IS_DEVICE__
+ extern struct device_attribute dev_attr_devspeed;
+ extern struct device_attribute dev_attr_enumspeed;
+#endif //__IS_DEVICE__
+
+#ifdef __ENABLE_DUMP__
+ #ifdef __IS_HOST__
+ #ifdef __IS_DUAL__
+ extern struct device_attribute dev_attr_dump_reg_h_1;
+ extern struct device_attribute dev_attr_dump_reg_h_2;
+ extern struct device_attribute dev_attr_dump_spram_h_1;
+ extern struct device_attribute dev_attr_dump_spram_h_2;
+ extern struct device_attribute dev_attr_dump_host_state_1;
+ extern struct device_attribute dev_attr_dump_host_state_2;
+ #else
+ extern struct device_attribute dev_attr_dump_reg_h;
+ extern struct device_attribute dev_attr_dump_spram_h;
+ extern struct device_attribute dev_attr_dump_host_state;
+ #endif
+ #else
+ extern struct device_attribute dev_attr_dump_reg_d;
+ extern struct device_attribute dev_attr_dump_spram_d;
+ #endif
+#endif //__ENABLE_DUMP__
+
+
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+
+static ssize_t procfs_version_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+{
+ return sprintf( buf, "%s\n",IFXUSB_VERSION );
+}
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_version_show( struct device *_dev, struct device_attribute *attr,char *buf)
+#else
+ static ssize_t sysfs_version_show( struct device *_dev, char *buf)
+#endif
+{
+ return sprintf( buf, "%s\n",IFXUSB_VERSION );
+}
+
+#ifdef __IS_HOST__
+DEVICE_ATTR(version_h, S_IRUGO|S_IWUSR, sysfs_version_show, NULL);
+#else
+DEVICE_ATTR(version_d, S_IRUGO|S_IWUSR, sysfs_version_show, NULL);
+#endif
+
+
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+
+static ssize_t procfs_dbglevel_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+{
+ #ifdef __IS_HOST__
+ return sprintf( buf, "%08X\n",h_dbg_lvl );
+ #else
+ return sprintf( buf, "%08X\n",d_dbg_lvl );
+ #endif
+}
+
+static ssize_t procfs_dbglevel_store(struct file *file, const char *buffer, unsigned long count, void *data)
+{
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 16);
+ #ifdef __IS_HOST__
+ h_dbg_lvl =value;
+ #else
+ d_dbg_lvl =value;
+ #endif
+ //turn on and off power
+ return count;
+}
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_dbglevel_show( struct device *_dev, struct device_attribute *attr,char *buf)
+#else
+ static ssize_t sysfs_dbglevel_show( struct device *_dev, char *buf)
+#endif
+{
+ #ifdef __IS_HOST__
+ return sprintf( buf, "%08X\n",h_dbg_lvl );
+ #else
+ return sprintf( buf, "%08X\n",d_dbg_lvl );
+ #endif
+}
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_dbglevel_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+#else
+ static ssize_t sysfs_dbglevel_store( struct device *_dev, const char *buffer, size_t count )
+#endif
+{
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 16);
+ #ifdef __IS_HOST__
+ h_dbg_lvl =value;
+ #else
+ d_dbg_lvl =value;
+ #endif
+ //turn on and off power
+ return count;
+}
+
+#ifdef __IS_HOST__
+DEVICE_ATTR(dbglevel_h, S_IRUGO|S_IWUSR, sysfs_dbglevel_show, sysfs_dbglevel_store);
+#else
+DEVICE_ATTR(dbglevel_d, S_IRUGO|S_IWUSR, sysfs_dbglevel_show, sysfs_dbglevel_store);
+#endif
+
+
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+
+static void ifxusb_dump_params(ifxusb_core_if_t *_core_if);
+
+#ifdef __IS_DUAL__
+ static void dump_params_1(void)
+ {
+ ifxusb_dump_params(&ifxusb_hcd_1.core_if);
+ }
+ static void dump_params_2(void)
+ {
+ ifxusb_dump_params(&ifxusb_hcd_2.core_if);
+ }
+
+ static ssize_t procfs_dump_params_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ dump_params_1();
+ return 0;
+ }
+ static ssize_t procfs_dump_params_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ dump_params_2();
+ return 0;
+ }
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_dump_params_show_1( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_dump_params_show_1( struct device *_dev,char *buf)
+ #endif
+ {
+ dump_params_1();
+ return 0;
+ }
+ DEVICE_ATTR(dump_params_h_1, S_IRUGO|S_IWUSR, sysfs_dump_params_show_1, NULL);
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_dump_params_show_2( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_dump_params_show_2( struct device *_dev,char *buf)
+ #endif
+ {
+ dump_params_2();
+ return 0;
+ }
+
+ DEVICE_ATTR(dump_params_h_2, S_IRUGO|S_IWUSR, sysfs_dump_params_show_2, NULL);
+#else
+ static void dump_params(void)
+ {
+ #ifdef __IS_HOST__
+ ifxusb_dump_params(&ifxusb_hcd.core_if);
+ #else
+ ifxusb_dump_params(&ifxusb_pcd.core_if);
+ #endif
+ }
+
+ static ssize_t procfs_dump_params_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ dump_params();
+ return 0;
+ }
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_dump_params_show( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_dump_params_show( struct device *_dev,char *buf)
+ #endif
+ {
+ dump_params();
+ return 0;
+ }
+
+ #ifdef __IS_HOST__
+ DEVICE_ATTR(dump_params_h, S_IRUGO|S_IWUSR, sysfs_dump_params_show, NULL);
+ #else
+ DEVICE_ATTR(dump_params_d, S_IRUGO|S_IWUSR, sysfs_dump_params_show, NULL);
+ #endif
+#endif
+
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifdef __IS_DUAL__
+ static ssize_t mode_show_1(char *buf)
+ {
+ if((ifxusb_rreg(&ifxusb_hcd_1.core_if.core_global_regs->gintsts ) & 0x1) == 1)
+ return sprintf( buf, "HOST\n" );
+ else
+ return sprintf( buf, "DEVICE(INCORRECT!)\n" );
+ }
+
+ static ssize_t mode_show_2(char *buf)
+ {
+ if((ifxusb_rreg(&ifxusb_hcd_2.core_if.core_global_regs->gintsts ) & 0x1) == 1)
+ return sprintf( buf, "HOST\n" );
+ else
+ return sprintf( buf, "DEVICE(INCORRECT!)\n" );
+ }
+
+ static ssize_t procfs_mode_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return mode_show_1(buf);
+ }
+ static ssize_t procfs_mode_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return mode_show_2(buf);
+ }
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_mode_show_1( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_mode_show_1( struct device *_dev,char *buf)
+ #endif
+ {
+ return mode_show_1(buf);
+ }
+
+ DEVICE_ATTR(mode_h_1, S_IRUGO|S_IWUSR, sysfs_mode_show_1, 0);
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_mode_show_2( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_mode_show_2( struct device *_dev,char *buf)
+ #endif
+ {
+ return mode_show_2(buf);
+ }
+ DEVICE_ATTR(mode_h_2, S_IRUGO|S_IWUSR, sysfs_mode_show_2, NULL);
+#else
+ static ssize_t mode_show(char *buf)
+ {
+ #ifdef __IS_HOST__
+ if((ifxusb_rreg(&ifxusb_hcd.core_if.core_global_regs->gintsts ) & 0x1) == 1)
+ return sprintf( buf, "HOST\n" );
+ else
+ return sprintf( buf, "DEVICE(INCORRECT!)\n" );
+ #else
+ if((ifxusb_rreg(&ifxusb_pcd.core_if.core_global_regs->gintsts ) & 0x1) != 1)
+ return sprintf( buf, "DEVICE\n" );
+ else
+ return sprintf( buf, "HOST(INCORRECT!)\n" );
+ #endif
+ }
+ static ssize_t procfs_mode_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return mode_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_mode_show( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_mode_show( struct device *_dev, char *buf)
+ #endif
+ {
+ return mode_show(buf);
+ }
+ #ifdef __IS_HOST__
+ DEVICE_ATTR(mode_h, S_IRUGO|S_IWUSR, sysfs_mode_show, NULL);
+ #else
+ DEVICE_ATTR(mode_d, S_IRUGO|S_IWUSR, sysfs_mode_show, NULL);
+ #endif
+#endif
+
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifdef __IS_HOST__
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+ #ifdef __IS_DUAL__
+ static ssize_t bandwidth_hs_show_1(char *buf)
+ {
+ return sprintf( buf, "%d\n",ifxusb_hcd_1.pkt_remaining_reload_hs );
+ }
+ static ssize_t bandwidth_fs_show_1(char *buf)
+ {
+ return sprintf( buf, "%d\n",ifxusb_hcd_1.pkt_remaining_reload_fs );
+ }
+ static ssize_t bandwidth_ls_show_1(char *buf)
+ {
+ return sprintf( buf, "%d\n",ifxusb_hcd_1.pkt_remaining_reload_ls );
+ }
+ static void bandwidth_hs_store_1(uint32_t value)
+ {
+ if(value>16 && value<120)
+ {
+ hprt0_data_t hprt0;
+ ifxusb_hcd_1.pkt_remaining_reload_hs = value;
+ hprt0.d32 = ifxusb_rreg(ifxusb_hcd_1.core_if.hprt0);
+ if(hprt0.b.prtspd == IFXUSB_HPRT0_PRTSPD_HIGH_SPEED)
+ ifxusb_hcd_1.pkt_remaining_reload=value;
+ }
+ }
+ static void bandwidth_fs_store_1(uint32_t value)
+ {
+ if (value>2 && value<30)
+ {
+ hprt0_data_t hprt0;
+ ifxusb_hcd_1.pkt_remaining_reload_fs = value;
+ hprt0.d32 = ifxusb_rreg(ifxusb_hcd_1.core_if.hprt0);
+ if(hprt0.b.prtspd != IFXUSB_HPRT0_PRTSPD_LOW_SPEED && hprt0.b.prtspd != IFXUSB_HPRT0_PRTSPD_HIGH_SPEED)
+ ifxusb_hcd_1.pkt_remaining_reload=value;
+ }
+ }
+ static void bandwidth_ls_store_1(uint32_t value)
+ {
+ if (value>2 && value<30)
+ {
+ hprt0_data_t hprt0;
+ ifxusb_hcd_1.pkt_remaining_reload_ls = value;
+ hprt0.d32 = ifxusb_rreg(ifxusb_hcd_1.core_if.hprt0);
+ if(hprt0.b.prtspd == IFXUSB_HPRT0_PRTSPD_LOW_SPEED)
+ ifxusb_hcd_1.pkt_remaining_reload=value;
+ }
+ }
+ static ssize_t bandwidth_hs_show_2(char *buf)
+ {
+ return sprintf( buf, "%d\n",ifxusb_hcd_2.pkt_remaining_reload_hs );
+ }
+ static ssize_t bandwidth_fs_show_2(char *buf)
+ {
+ return sprintf( buf, "%d\n",ifxusb_hcd_2.pkt_remaining_reload_fs );
+ }
+ static ssize_t bandwidth_ls_show_2(char *buf)
+ {
+ return sprintf( buf, "%d\n",ifxusb_hcd_2.pkt_remaining_reload_ls );
+ }
+ static void bandwidth_hs_store_2(uint32_t value)
+ {
+ if(value>16 && value<120)
+ {
+ hprt0_data_t hprt0;
+ ifxusb_hcd_2.pkt_remaining_reload_hs = value;
+ hprt0.d32 = ifxusb_rreg(ifxusb_hcd_2.core_if.hprt0);
+ if(hprt0.b.prtspd == IFXUSB_HPRT0_PRTSPD_HIGH_SPEED)
+ ifxusb_hcd_2.pkt_remaining_reload=value;
+ }
+ }
+ static void bandwidth_fs_store_2(uint32_t value)
+ {
+ if (value>2 && value<30)
+ {
+ hprt0_data_t hprt0;
+ ifxusb_hcd_2.pkt_remaining_reload_fs = value;
+ hprt0.d32 = ifxusb_rreg(ifxusb_hcd_2.core_if.hprt0);
+ if(hprt0.b.prtspd != IFXUSB_HPRT0_PRTSPD_LOW_SPEED && hprt0.b.prtspd != IFXUSB_HPRT0_PRTSPD_HIGH_SPEED)
+ ifxusb_hcd_2.pkt_remaining_reload=value;
+ }
+ }
+ static void bandwidth_ls_store_2(uint32_t value)
+ {
+ if (value>2 && value<30)
+ {
+ hprt0_data_t hprt0;
+ ifxusb_hcd_2.pkt_remaining_reload_ls = value;
+ hprt0.d32 = ifxusb_rreg(ifxusb_hcd_2.core_if.hprt0);
+ if(hprt0.b.prtspd == IFXUSB_HPRT0_PRTSPD_LOW_SPEED)
+ ifxusb_hcd_2.pkt_remaining_reload=value;
+ }
+ }
+ static ssize_t procfs_bandwidth_hs_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return bandwidth_hs_show_1(buf);
+ }
+ static ssize_t procfs_bandwidth_fs_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return bandwidth_fs_show_1(buf);
+ }
+ static ssize_t procfs_bandwidth_ls_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return bandwidth_ls_show_1(buf);
+ }
+ static ssize_t procfs_bandwidth_hs_store_1(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ bandwidth_hs_store_1(value);
+ return count;
+ }
+ static ssize_t procfs_bandwidth_fs_store_1(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ bandwidth_fs_store_1(value);
+ return count;
+ }
+ static ssize_t procfs_bandwidth_ls_store_1(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ bandwidth_ls_store_1(value);
+ return count;
+ }
+ static ssize_t procfs_bandwidth_hs_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return bandwidth_hs_show_2(buf);
+ }
+ static ssize_t procfs_bandwidth_fs_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return bandwidth_fs_show_2(buf);
+ }
+ static ssize_t procfs_bandwidth_ls_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return bandwidth_ls_show_2(buf);
+ }
+ static ssize_t procfs_bandwidth_hs_store_2(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ bandwidth_hs_store_2(value);
+ return count;
+ }
+ static ssize_t procfs_bandwidth_fs_store_2(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ bandwidth_fs_store_2(value);
+ return count;
+ }
+ static ssize_t procfs_bandwidth_ls_store_2(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ bandwidth_ls_store_2(value);
+ return count;
+ }
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_bandwidth_hs_show_1( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_bandwidth_hs_show_1( struct device *_dev,char *buf)
+ #endif
+ {
+ return bandwidth_hs_show_1(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_bandwidth_hs_store_1( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_bandwidth_hs_store_1( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ bandwidth_hs_store_1(value);
+ return count;
+ }
+ DEVICE_ATTR(bandwidth_hs_1, S_IRUGO|S_IWUSR, sysfs_bandwidth_hs_show_1, sysfs_bandwidth_hs_store_1);
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_bandwidth_fs_show_1( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_bandwidth_fs_show_1( struct device *_dev,char *buf)
+ #endif
+ {
+ return bandwidth_fs_show_1(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_bandwidth_fs_store_1( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_bandwidth_fs_store_1( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ bandwidth_fs_store_1(value);
+ return count;
+ }
+ DEVICE_ATTR(bandwidth_fs_1, S_IRUGO|S_IWUSR, sysfs_bandwidth_fs_show_1, sysfs_bandwidth_fs_store_1);
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_bandwidth_ls_show_1( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_bandwidth_ls_show_1( struct device *_dev,char *buf)
+ #endif
+ {
+ return bandwidth_ls_show_1(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_bandwidth_ls_store_1( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_bandwidth_ls_store_1( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ bandwidth_ls_store_1(value);
+ return count;
+ }
+ DEVICE_ATTR(bandwidth_ls_1, S_IRUGO|S_IWUSR, sysfs_bandwidth_ls_show_1, sysfs_bandwidth_ls_store_1);
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_bandwidth_hs_show_2( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_bandwidth_hs_show_2( struct device *_dev,char *buf)
+ #endif
+ {
+ return bandwidth_hs_show_2(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_bandwidth_hs_store_2( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_bandwidth_hs_store_2( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ bandwidth_hs_store_2(value);
+ return count;
+ }
+ DEVICE_ATTR(bandwidth_hs_2, S_IRUGO|S_IWUSR, sysfs_bandwidth_hs_show_2, sysfs_bandwidth_hs_store_2);
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_bandwidth_fs_show_2( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_bandwidth_fs_show_2( struct device *_dev,char *buf)
+ #endif
+ {
+ return bandwidth_fs_show_2(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_bandwidth_fs_store_2( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_bandwidth_fs_store_2( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ bandwidth_fs_store_2(value);
+ return count;
+ }
+ DEVICE_ATTR(bandwidth_fs_2, S_IRUGO|S_IWUSR, sysfs_bandwidth_fs_show_2, sysfs_bandwidth_fs_store_2);
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_bandwidth_ls_show_2( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_bandwidth_ls_show_2( struct device *_dev,char *buf)
+ #endif
+ {
+ return bandwidth_ls_show_2(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_bandwidth_ls_store_2( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_bandwidth_ls_store_2( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ bandwidth_ls_store_2(value);
+ return count;
+ }
+ DEVICE_ATTR(bandwidth_ls_2, S_IRUGO|S_IWUSR, sysfs_bandwidth_ls_show_2, sysfs_bandwidth_ls_store_2);
+ #else
+ static ssize_t bandwidth_hs_show(char *buf)
+ {
+ return sprintf( buf, "%d\n",ifxusb_hcd.pkt_remaining_reload_hs );
+ }
+ static ssize_t bandwidth_fs_show(char *buf)
+ {
+ return sprintf( buf, "%d\n",ifxusb_hcd.pkt_remaining_reload_fs );
+ }
+ static ssize_t bandwidth_ls_show(char *buf)
+ {
+ return sprintf( buf, "%d\n",ifxusb_hcd.pkt_remaining_reload_ls );
+ }
+ static void bandwidth_hs_store(uint32_t value)
+ {
+ if (value>16 && value<120)
+ {
+ hprt0_data_t hprt0;
+ ifxusb_hcd.pkt_remaining_reload_hs = value;
+ hprt0.d32 = ifxusb_rreg(ifxusb_hcd.core_if.hprt0);
+ if(hprt0.b.prtspd == IFXUSB_HPRT0_PRTSPD_HIGH_SPEED)
+ ifxusb_hcd.pkt_remaining_reload=value;
+ }
+ }
+ static void bandwidth_fs_store(uint32_t value)
+ {
+ if (value>2 && value<30)
+ {
+ hprt0_data_t hprt0;
+ ifxusb_hcd.pkt_remaining_reload_fs = value;
+ hprt0.d32 = ifxusb_rreg(ifxusb_hcd.core_if.hprt0);
+ if(hprt0.b.prtspd != IFXUSB_HPRT0_PRTSPD_LOW_SPEED && hprt0.b.prtspd != IFXUSB_HPRT0_PRTSPD_HIGH_SPEED)
+ ifxusb_hcd.pkt_remaining_reload=value;
+ }
+ }
+ static void bandwidth_ls_store(uint32_t value)
+ {
+ if (value>2 && value<30)
+ {
+ hprt0_data_t hprt0;
+ ifxusb_hcd.pkt_remaining_reload_hs = value;
+ hprt0.d32 = ifxusb_rreg(ifxusb_hcd.core_if.hprt0);
+ if(hprt0.b.prtspd == IFXUSB_HPRT0_PRTSPD_LOW_SPEED)
+ ifxusb_hcd.pkt_remaining_reload=value;
+ }
+ }
+ static ssize_t procfs_bandwidth_hs_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return bandwidth_hs_show(buf);
+ }
+ static ssize_t procfs_bandwidth_fs_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return bandwidth_fs_show(buf);
+ }
+ static ssize_t procfs_bandwidth_ls_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return bandwidth_ls_show(buf);
+ }
+ static ssize_t procfs_bandwidth_hs_store(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ bandwidth_hs_store(value);
+ return count;
+ }
+ static ssize_t procfs_bandwidth_fs_store(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ bandwidth_fs_store(value);
+ return count;
+ }
+ static ssize_t procfs_bandwidth_ls_store(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ bandwidth_ls_store(value);
+ return count;
+ }
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_bandwidth_hs_show( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_bandwidth_hs_show( struct device *_dev,char *buf)
+ #endif
+ {
+ return bandwidth_hs_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_bandwidth_hs_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_bandwidth_hs_store( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ bandwidth_hs_store(value);
+ return count;
+ }
+ DEVICE_ATTR(bandwidth_hs, S_IRUGO|S_IWUSR, sysfs_bandwidth_hs_show, sysfs_bandwidth_hs_store);
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_bandwidth_fs_show( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_bandwidth_fs_show( struct device *_dev,char *buf)
+ #endif
+ {
+ return bandwidth_fs_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_bandwidth_fs_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_bandwidth_fs_store( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ bandwidth_fs_store(value);
+ return count;
+ }
+ DEVICE_ATTR(bandwidth_fs, S_IRUGO|S_IWUSR, sysfs_bandwidth_fs_show, sysfs_bandwidth_fs_store);
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_bandwidth_ls_show( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_bandwidth_ls_show( struct device *_dev,char *buf)
+ #endif
+ {
+ return bandwidth_ls_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_bandwidth_ls_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_bandwidth_ls_store( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ bandwidth_ls_store(value);
+ return count;
+ }
+ DEVICE_ATTR(bandwidth_ls, S_IRUGO|S_IWUSR, sysfs_bandwidth_ls_show, sysfs_bandwidth_ls_store);
+ #endif
+
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+ #ifdef __IS_DUAL__
+ static ssize_t pkt_count_limit_bi_show_1(char *buf)
+ {
+ return sprintf( buf, "%d\n",ifxusb_hcd_1.pkt_count_limit_bi );
+ }
+ static ssize_t pkt_count_limit_bo_show_1(char *buf)
+ {
+ return sprintf( buf, "%d\n",ifxusb_hcd_1.pkt_count_limit_bo );
+ }
+ static void pkt_count_limit_bi_store_1(uint32_t value)
+ {
+ if(value<=13)
+ ifxusb_hcd_1.pkt_count_limit_bi = value;
+ }
+ static void pkt_count_limit_bo_store_1(uint32_t value)
+ {
+ if (value<=13)
+ ifxusb_hcd_1.pkt_count_limit_bo = value;
+ }
+ static ssize_t pkt_count_limit_bi_show_2(char *buf)
+ {
+ return sprintf( buf, "%d\n",ifxusb_hcd_2.pkt_count_limit_bi );
+ }
+ static ssize_t pkt_count_limit_bo_show_2(char *buf)
+ {
+ return sprintf( buf, "%d\n",ifxusb_hcd_2.pkt_count_limit_bo );
+ }
+ static void pkt_count_limit_bi_store_2(uint32_t value)
+ {
+ if(value<=13)
+ ifxusb_hcd_2.pkt_count_limit_bi = value;
+ }
+ static void pkt_count_limit_bo_store_2(uint32_t value)
+ {
+ if(value<=13)
+ ifxusb_hcd_2.pkt_count_limit_bo = value;
+ }
+ static ssize_t procfs_pkt_count_limit_bi_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return pkt_count_limit_bi_show_1(buf);
+ }
+ static ssize_t procfs_pkt_count_limit_bo_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return pkt_count_limit_bo_show_1(buf);
+ }
+ static ssize_t procfs_pkt_count_limit_bi_store_1(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ pkt_count_limit_bi_store_1(value);
+ return count;
+ }
+ static ssize_t procfs_pkt_count_limit_bo_store_1(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ pkt_count_limit_bo_store_1(value);
+ return count;
+ }
+ static ssize_t procfs_pkt_count_limit_bi_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return pkt_count_limit_bi_show_2(buf);
+ }
+ static ssize_t procfs_pkt_count_limit_bo_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return pkt_count_limit_bo_show_2(buf);
+ }
+ static ssize_t procfs_pkt_count_limit_bi_store_2(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ pkt_count_limit_bi_store_2(value);
+ return count;
+ }
+ static ssize_t procfs_pkt_count_limit_bo_store_2(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ pkt_count_limit_bo_store_2(value);
+ return count;
+ }
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_pkt_count_limit_bi_show_1( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_pkt_count_limit_bi_show_1( struct device *_dev,char *buf)
+ #endif
+ {
+ return pkt_count_limit_bi_show_1(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_pkt_count_limit_bi_store_1( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_pkt_count_limit_bi_store_1( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ pkt_count_limit_bi_store_1(value);
+ return count;
+ }
+ DEVICE_ATTR(pkt_count_limit_bi_1, S_IRUGO|S_IWUSR, sysfs_pkt_count_limit_bi_show_1, sysfs_pkt_count_limit_bi_store_1);
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_pkt_count_limit_bo_show_1( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_pkt_count_limit_bo_show_1( struct device *_dev,char *buf)
+ #endif
+ {
+ return pkt_count_limit_bo_show_1(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_pkt_count_limit_bo_store_1( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_pkt_count_limit_bo_store_1( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ pkt_count_limit_bo_store_1(value);
+ return count;
+ }
+ DEVICE_ATTR(pkt_count_limit_bo_1, S_IRUGO|S_IWUSR, sysfs_pkt_count_limit_bo_show_1, sysfs_pkt_count_limit_bo_store_1);
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_pkt_count_limit_bi_show_2( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_pkt_count_limit_bi_show_2( struct device *_dev,char *buf)
+ #endif
+ {
+ return pkt_count_limit_bi_show_2(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_pkt_count_limit_bi_store_2( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_pkt_count_limit_bi_2( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ pkt_count_limit_bi_store_2(value);
+ return count;
+ }
+ DEVICE_ATTR(pkt_count_limit_bi_2, S_IRUGO|S_IWUSR, sysfs_pkt_count_limit_bi_show_2, sysfs_pkt_count_limit_bi_store_2);
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_pkt_count_limit_bo_show_2( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_pkt_count_limit_bo_show_2( struct device *_dev,char *buf)
+ #endif
+ {
+ return pkt_count_limit_bo_show_2(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_pkt_count_limit_bo_store_2( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_pkt_count_limit_bo_store_2( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ pkt_count_limit_bo_store_2(value);
+ return count;
+ }
+ DEVICE_ATTR(pkt_count_limit_bo_2, S_IRUGO|S_IWUSR, sysfs_pkt_count_limit_bo_show_2, sysfs_pkt_count_limit_bo_store_2);
+ #else
+ static ssize_t pkt_count_limit_bi_show(char *buf)
+ {
+ return sprintf( buf, "%d\n",ifxusb_hcd.pkt_count_limit_bi );
+ }
+ static ssize_t pkt_count_limit_bo_show(char *buf)
+ {
+ return sprintf( buf, "%d\n",ifxusb_hcd.pkt_count_limit_bo );
+ }
+ static void pkt_count_limit_bi_store(uint32_t value)
+ {
+ if (value<=13)
+ ifxusb_hcd.pkt_count_limit_bi = value;
+ }
+ static void pkt_count_limit_bo_store(uint32_t value)
+ {
+ if (value<=13)
+ ifxusb_hcd.pkt_count_limit_bo = value;
+ }
+ static ssize_t procfs_pkt_count_limit_bi_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return pkt_count_limit_bi_show(buf);
+ }
+ static ssize_t procfs_pkt_count_limit_bo_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return pkt_count_limit_bo_show(buf);
+ }
+ static ssize_t procfs_pkt_count_limit_bi_store(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ pkt_count_limit_bi_store(value);
+ return count;
+ }
+ static ssize_t procfs_pkt_count_limit_bo_store(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ pkt_count_limit_bo_store(value);
+ return count;
+ }
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_pkt_count_limit_bi_show( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_pkt_count_limit_bi_show( struct device *_dev,char *buf)
+ #endif
+ {
+ return pkt_count_limit_bi_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_pkt_count_limit_bi_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_pkt_count_limit_bi_store( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ pkt_count_limit_bi_store(value);
+ return count;
+ }
+ DEVICE_ATTR(pkt_count_limit_bi, S_IRUGO|S_IWUSR, sysfs_pkt_count_limit_bi_show, sysfs_pkt_count_limit_bi_store);
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_pkt_count_limit_bo_show( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_pkt_count_limit_bo_show( struct device *_dev,char *buf)
+ #endif
+ {
+ return pkt_count_limit_bo_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_pkt_count_limit_bo_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_pkt_count_limit_bo_store( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ pkt_count_limit_bo_store(value);
+ return count;
+ }
+ DEVICE_ATTR(pkt_count_limit_bo, S_IRUGO|S_IWUSR, sysfs_pkt_count_limit_bo_show, sysfs_pkt_count_limit_bo_store);
+ #endif
+
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+
+ #ifdef __IS_DUAL__
+ static ssize_t buspower_show_1(char *buf)
+ {
+ if(ifxusb_vbus (&ifxusb_hcd_1.core_if)==1) return sprintf( buf, "1\n" );
+ if(ifxusb_vbus (&ifxusb_hcd_1.core_if)==0) return sprintf( buf, "0\n" );
+ return sprintf( buf, "UNKNOWN\n" );
+ }
+ static void buspower_store_1(uint32_t value)
+ {
+ if (value==1) ifxusb_vbus_on (&ifxusb_hcd_1.core_if);
+ else if(value==0) ifxusb_vbus_off(&ifxusb_hcd_1.core_if);
+ }
+ static ssize_t buspower_show_2(char *buf)
+ {
+ if(ifxusb_vbus (&ifxusb_hcd_2.core_if)==1) return sprintf( buf, "1\n" );
+ if(ifxusb_vbus (&ifxusb_hcd_2.core_if)==0) return sprintf( buf, "0\n" );
+ return sprintf( buf, "UNKNOWN\n" );
+ }
+ static void buspower_store_2(uint32_t value)
+ {
+ if (value==1) ifxusb_vbus_on (&ifxusb_hcd_2.core_if);
+ else if(value==0) ifxusb_vbus_off(&ifxusb_hcd_2.core_if);
+ }
+ static ssize_t procfs_buspower_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return buspower_show_1(buf);
+ }
+ static ssize_t procfs_buspower_store_1(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ buspower_store_1(value);
+ return count;
+ }
+ static ssize_t procfs_buspower_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return buspower_show_2(buf);
+ }
+ static ssize_t procfs_buspower_store_2(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ buspower_store_2(value);
+ return count;
+ }
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_buspower_show_1( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_buspower_show_1( struct device *_dev,char *buf)
+ #endif
+ {
+ return buspower_show_1(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_buspower_store_1( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_buspower_store_1( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ buspower_store_1(value);
+ return count;
+ }
+ DEVICE_ATTR(buspower_1, S_IRUGO|S_IWUSR, sysfs_buspower_show_1, sysfs_buspower_store_1);
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_buspower_show_2( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_buspower_show_2( struct device *_dev,char *buf)
+ #endif
+ {
+ return buspower_show_2(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_buspower_store_2( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_buspower_store_2( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ buspower_store_2(value);
+ return count;
+ }
+ DEVICE_ATTR(buspower_2, S_IRUGO|S_IWUSR, sysfs_buspower_show_2, sysfs_buspower_store_2);
+ #else
+ static ssize_t buspower_show(char *buf)
+ {
+ if(ifxusb_vbus (&ifxusb_hcd.core_if)==1) return sprintf( buf, "1\n" );
+ if(ifxusb_vbus (&ifxusb_hcd.core_if)==0) return sprintf( buf, "0\n" );
+ return sprintf( buf, "UNKNOWN\n" );
+ }
+ static void buspower_store(uint32_t value)
+ {
+ if (value==1) ifxusb_vbus_on (&ifxusb_hcd.core_if);
+ else if(value==0) ifxusb_vbus_off(&ifxusb_hcd.core_if);
+ }
+ static ssize_t procfs_buspower_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return buspower_show(buf);
+ }
+ static ssize_t procfs_buspower_store(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ buspower_store(value);
+ return count;
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_buspower_show( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_buspower_show( struct device *_dev, char *buf)
+ #endif
+ {
+ return buspower_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_buspower_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_buspower_store( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ buspower_store(value);
+ return count;
+ }
+ DEVICE_ATTR(buspower, S_IRUGO|S_IWUSR, sysfs_buspower_show, sysfs_buspower_store);
+ #endif
+
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+
+
+ #ifdef __IS_DUAL__
+ static ssize_t bussuspend_show_1(char *buf)
+ {
+ hprt0_data_t val;
+ val.d32 = ifxusb_rreg(ifxusb_hcd_1.core_if.hprt0);
+ return sprintf (buf, "Bus Suspend = 0x%x\n", val.b.prtsusp);
+ }
+ static ssize_t bussuspend_show_2(char *buf)
+ {
+ hprt0_data_t val;
+ val.d32 = ifxusb_rreg(ifxusb_hcd_2.core_if.hprt0);
+ return sprintf (buf, "Bus Suspend = 0x%x\n", val.b.prtsusp);
+ }
+
+ static ssize_t procfs_bussuspend_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return bussuspend_show_1(buf);
+ }
+ static ssize_t procfs_bussuspend_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return bussuspend_show_2(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_bussuspend_show_1( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_bussuspend_show_1( struct device *_dev,char *buf)
+ #endif
+ {
+ return bussuspend_show_1(buf);
+ }
+ DEVICE_ATTR(bussuspend_1, S_IRUGO|S_IWUSR, sysfs_bussuspend_show_1, 0);
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_bussuspend_show_2( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_bussuspend_show_2( struct device *_dev,char *buf)
+ #endif
+ {
+ return bussuspend_show_2(buf);
+ }
+ DEVICE_ATTR(bussuspend_2, S_IRUGO|S_IWUSR, sysfs_bussuspend_show_2, 0);
+ #else
+ static ssize_t bussuspend_show(char *buf)
+ {
+ hprt0_data_t val;
+ val.d32 = ifxusb_rreg(ifxusb_hcd.core_if.hprt0);
+ return sprintf (buf, "Bus Suspend = 0x%x\n", val.b.prtsusp);
+ }
+ static ssize_t procfs_bussuspend_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return bussuspend_show(buf);
+ }
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_bussuspend_show( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_bussuspend_show( struct device *_dev, char *buf)
+ #endif
+ {
+ return bussuspend_show(buf);
+ }
+ DEVICE_ATTR(bussuspend, S_IRUGO|S_IWUSR, sysfs_bussuspend_show, 0);
+ #endif
+
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+
+ #ifdef __IS_DUAL__
+ static ssize_t busconnected_show_1(char *buf)
+ {
+ hprt0_data_t val;
+ val.d32 = ifxusb_rreg(ifxusb_hcd_1.core_if.hprt0);
+ return sprintf (buf, "Bus Connected = 0x%x\n", val.b.prtconnsts);
+ }
+ static ssize_t busconnected_show_2(char *buf)
+ {
+ hprt0_data_t val;
+ val.d32 = ifxusb_rreg(ifxusb_hcd_2.core_if.hprt0);
+ return sprintf (buf, "Bus Connected = 0x%x\n", val.b.prtconnsts);
+ }
+
+ static ssize_t procfs_busconnected_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return busconnected_show_1(buf);
+ }
+ static ssize_t procfs_busconnected_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return busconnected_show_2(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_busconnected_show_1( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_busconnected_show_1( struct device *_dev,char *buf)
+ #endif
+ {
+ return busconnected_show_1(buf);
+ }
+ DEVICE_ATTR(busconnected_1, S_IRUGO|S_IWUSR, sysfs_busconnected_show_1, 0);
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_busconnected_show_2( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_busconnected_show_2( struct device *_dev,char *buf)
+ #endif
+ {
+ return busconnected_show_2(buf);
+ }
+ DEVICE_ATTR(busconnected_2, S_IRUGO|S_IWUSR, sysfs_busconnected_show_2, 0);
+ #else
+ static ssize_t busconnected_show(char *buf)
+ {
+ hprt0_data_t val;
+ val.d32 = ifxusb_rreg(ifxusb_hcd.core_if.hprt0);
+ return sprintf (buf, "Bus Connected = 0x%x\n", val.b.prtconnsts);
+ }
+ static ssize_t procfs_busconnected_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return busconnected_show(buf);
+ }
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_busconnected_show( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_busconnected_show( struct device *_dev, char *buf)
+ #endif
+ {
+ return busconnected_show(buf);
+ }
+ DEVICE_ATTR(busconnected, S_IRUGO|S_IWUSR, sysfs_busconnected_show, 0);
+ #endif
+
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+
+ #ifdef __IS_DUAL__
+ static ssize_t connectspeed_show_1(char *buf)
+ {
+ hprt0_data_t val;
+ val.d32 = ifxusb_rreg(ifxusb_hcd_1.core_if.hprt0);
+ if( val.b.prtspd ==0) return sprintf (buf, "Bus Speed = High (%d)\n", val.b.prtspd);
+ if( val.b.prtspd ==1) return sprintf (buf, "Bus Speed = Full (%d)\n", val.b.prtspd);
+ if( val.b.prtspd ==2) return sprintf (buf, "Bus Speed = Low (%d)\n", val.b.prtspd);
+ return sprintf (buf, "Bus Speed = Unknown (%d)\n", val.b.prtspd);
+ }
+ static ssize_t connectspeed_show_2(char *buf)
+ {
+ hprt0_data_t val;
+ val.d32 = ifxusb_rreg(ifxusb_hcd_2.core_if.hprt0);
+ if( val.b.prtspd ==0) return sprintf (buf, "Bus Speed = High (%d)\n", val.b.prtspd);
+ if( val.b.prtspd ==1) return sprintf (buf, "Bus Speed = Full (%d)\n", val.b.prtspd);
+ if( val.b.prtspd ==2) return sprintf (buf, "Bus Speed = Low (%d)\n", val.b.prtspd);
+ return sprintf (buf, "Bus Speed = Unknown (%d)\n", val.b.prtspd);
+ }
+
+ static ssize_t procfs_connectspeed_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return connectspeed_show_1(buf);
+ }
+ static ssize_t procfs_connectspeed_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return connectspeed_show_2(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_connectspeed_show_1( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_connectspeed_show_1( struct device *_dev,char *buf)
+ #endif
+ {
+ return connectspeed_show_1(buf);
+ }
+ DEVICE_ATTR(connectspeed_1, S_IRUGO|S_IWUSR, sysfs_connectspeed_show_1, 0);
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_connectspeed_show_2( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_connectspeed_show_2( struct device *_dev,char *buf)
+ #endif
+ {
+ return connectspeed_show_2(buf);
+ }
+ DEVICE_ATTR(connectspeed_2, S_IRUGO|S_IWUSR, sysfs_connectspeed_show_2, 0);
+ #else
+ static ssize_t connectspeed_show(char *buf)
+ {
+ hprt0_data_t val;
+ val.d32 = ifxusb_rreg(ifxusb_hcd.core_if.hprt0);
+ if( val.b.prtspd ==0) return sprintf (buf, "Bus Speed = High (%d)\n", val.b.prtspd);
+ if( val.b.prtspd ==1) return sprintf (buf, "Bus Speed = Full (%d)\n", val.b.prtspd);
+ if( val.b.prtspd ==2) return sprintf (buf, "Bus Speed = Low (%d)\n", val.b.prtspd);
+ return sprintf (buf, "Bus Speed = Unknown (%d)\n", val.b.prtspd);
+ }
+
+ static ssize_t procfs_connectspeed_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return connectspeed_show(buf);
+ }
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_connectspeed_show( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_connectspeed_show( struct device *_dev, char *buf)
+ #endif
+ {
+ return connectspeed_show(buf);
+ }
+ DEVICE_ATTR(connectspeed, S_IRUGO|S_IWUSR, sysfs_connectspeed_show, 0);
+ #endif
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+#endif
+
+
+#ifdef __IS_DEVICE__
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+ static ssize_t devspeed_show(char *buf)
+ {
+ dcfg_data_t val;
+ val.d32 = ifxusb_rreg(&ifxusb_pcd.core_if.dev_global_regs->dcfg);
+ if( val.b.devspd ==0) return sprintf (buf, "Dev Speed = High (%d)\n", val.b.devspd);
+ if( val.b.devspd ==1) return sprintf (buf, "Dev Speed = Full (%d)\n", val.b.devspd);
+ if( val.b.devspd ==3) return sprintf (buf, "Dev Speed = Full (%d)\n", val.b.devspd);
+ return sprintf (buf, "Dev Speed = Unknown (%d)\n", val.b.devspd);
+ }
+
+ static ssize_t procfs_devspeed_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return devspeed_show(buf);
+ }
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_devspeed_show( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_devspeed_show( struct device *_dev, char *buf)
+ #endif
+ {
+ return devspeed_show(buf);
+ }
+ DEVICE_ATTR(devspeed, S_IRUGO|S_IWUSR, sysfs_devspeed_show, 0);
+
+ static ssize_t enumspeed_show(char *buf)
+ {
+ dsts_data_t val;
+ val.d32 = ifxusb_rreg(&ifxusb_pcd.core_if.dev_global_regs->dsts);
+ if( val.b.enumspd ==0) return sprintf (buf, "Enum Speed = High (%d)\n", val.b.enumspd);
+ if( val.b.enumspd ==1) return sprintf (buf, "Enum Speed = Full (%d)\n", val.b.enumspd);
+ if( val.b.enumspd ==2) return sprintf (buf, "Enum Speed = Low (%d)\n", val.b.enumspd);
+ return sprintf (buf, "Enum Speed = invalid(%d)\n", val.b.enumspd);
+ }
+
+ static ssize_t procfs_enumspeed_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return enumspeed_show(buf);
+ }
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_enumspeed_show( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_enumspeed_show( struct device *_dev, char *buf)
+ #endif
+ {
+ return enumspeed_show(buf);
+ }
+ DEVICE_ATTR(enumspeed, S_IRUGO|S_IWUSR, sysfs_enumspeed_show, 0);
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+#endif
+
+
+//////////////////////////////////////////////////////////////////////////////////
+#ifdef __ENABLE_DUMP__
+
+ #ifdef __IS_DUAL__
+ static void dump_reg_1(void)
+ {
+ ifxusb_dump_registers_h(&ifxusb_hcd_1.core_if);
+ }
+ static void dump_reg_2(void)
+ {
+ ifxusb_dump_registers_h(&ifxusb_hcd_2.core_if);
+ }
+
+ static ssize_t procfs_dump_reg_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ dump_reg_1();
+ return 0;
+ }
+ static ssize_t procfs_dump_reg_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ dump_reg_2();
+ return 0;
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_dump_reg_show_1( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_dump_reg_show_1( struct device *_dev,char *buf)
+ #endif
+ {
+ dump_reg_1();
+ return 0;
+ }
+ DEVICE_ATTR(dump_reg_h_1, S_IRUGO|S_IWUSR, sysfs_dump_reg_show_1, 0);
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_dump_reg_show_2( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_dump_reg_show_2( struct device *_dev,char *buf)
+ #endif
+ {
+ dump_reg_2();
+ return 0;
+ }
+ DEVICE_ATTR(dump_reg_h_2, S_IRUGO|S_IWUSR, sysfs_dump_reg_show_2, 0);
+ #else
+ static void dump_reg(void)
+ {
+ #ifdef __IS_HOST__
+ ifxusb_dump_registers_h(&ifxusb_hcd.core_if);
+ #endif
+ #ifdef __IS_DEVICE__
+ ifxusb_dump_registers_d(&ifxusb_pcd.core_if);
+ #endif
+ }
+ static ssize_t procfs_dump_reg_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ dump_reg();
+ return 0;
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_dump_reg_show( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_dump_reg_show( struct device *_dev,char *buf)
+ #endif
+ {
+ dump_reg();
+ return 0;
+ }
+ #ifdef __IS_HOST__
+ DEVICE_ATTR(dump_reg_h, S_IRUGO|S_IWUSR, sysfs_dump_reg_show, 0);
+ #else
+ DEVICE_ATTR(dump_reg_d, S_IRUGO|S_IWUSR, sysfs_dump_reg_show, 0);
+ #endif
+ #endif
+
+
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+
+ #ifdef __IS_DUAL__
+ static void dump_spram_1(void)
+ {
+ ifxusb_dump_spram_h(&ifxusb_hcd_1.core_if);
+ }
+ static void dump_spram_2(void)
+ {
+ ifxusb_dump_spram_h(&ifxusb_hcd_2.core_if);
+ }
+
+ static ssize_t procfs_dump_spram_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ dump_spram_1();
+ return 0;
+ }
+ static ssize_t procfs_dump_spram_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ dump_spram_2();
+ return 0;
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_dump_spram_show_1( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_dump_spram_show_1( struct device *_dev,char *buf)
+ #endif
+ {
+ dump_spram_1();
+ return 0;
+ }
+ DEVICE_ATTR(dump_spram_h_1, S_IRUGO|S_IWUSR, sysfs_dump_spram_show_1, 0);
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_dump_spram_show_2( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_dump_spram_show_2( struct device *_dev,char *buf)
+ #endif
+ {
+ dump_spram_2();
+ return 0;
+ }
+ DEVICE_ATTR(dump_spram_h_2, S_IRUGO|S_IWUSR, sysfs_dump_spram_show_2, 0);
+ #else
+ static void dump_spram(void)
+ {
+ #ifdef __IS_HOST__
+ ifxusb_dump_spram_h(&ifxusb_hcd.core_if);
+ #endif
+ #ifdef __IS_DEVICE__
+ ifxusb_dump_spram_d(&ifxusb_pcd.core_if);
+ #endif
+ }
+ static ssize_t procfs_dump_spram_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ dump_spram();
+ return 0;
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_dump_spram_show( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_dump_spram_show( struct device *_dev,char *buf)
+ #endif
+ {
+ dump_spram();
+ return 0;
+ }
+ #ifdef __IS_HOST__
+ DEVICE_ATTR(dump_spram_h, S_IRUGO|S_IWUSR, sysfs_dump_spram_show, 0);
+ #else
+ DEVICE_ATTR(dump_spram_d, S_IRUGO|S_IWUSR, sysfs_dump_spram_show, 0);
+ #endif
+
+ #endif
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+
+ #ifdef __IS_HOST__
+ #ifdef __IS_DUAL__
+ static ssize_t procfs_dump_host_state_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ ifxhcd_dump_state(&ifxusb_hcd_1);
+ return 0;
+ }
+ static ssize_t procfs_dump_host_state_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ ifxhcd_dump_state(&ifxusb_hcd_2);
+ return 0;
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_dump_host_state_show_1( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_dump_host_state_show_1( struct device *_dev,char *buf)
+ #endif
+ {
+ ifxhcd_dump_state(&ifxusb_hcd_1);
+ return 0;
+ }
+ DEVICE_ATTR(dump_host_state_1, S_IRUGO|S_IWUSR, sysfs_dump_host_state_show_1, 0);
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_dump_host_state_show_2( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_dump_host_state_show_2( struct device *_dev,char *buf)
+ #endif
+ {
+ ifxhcd_dump_state(&ifxusb_hcd_2);
+ return 0;
+ }
+ DEVICE_ATTR(dump_host_state_2, S_IRUGO|S_IWUSR, sysfs_dump_host_state_show_2, 0);
+ #else
+ static ssize_t procfs_dump_host_state_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ ifxhcd_dump_state(&ifxusb_hcd);
+ return 0;
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_dump_host_state_show( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_dump_host_state_show( struct device *_dev,char *buf)
+ #endif
+ {
+ ifxhcd_dump_state(&ifxusb_hcd);
+ return 0;
+ }
+ DEVICE_ATTR(dump_host_state, S_IRUGO|S_IWUSR, sysfs_dump_host_state_show, 0);
+ #endif
+
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+
+ #endif //IS_HOST_
+
+#endif //__ENABLE_DUMP__
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+#ifdef __IS_HOST__
+ static void host_probe(unsigned long _ptr)
+ {
+ ifxhcd_hcd_t *ifxhcd = (ifxhcd_hcd_t *)_ptr;
+
+ if(ifxhcd->flags.b.port_connect_status)
+ {
+ del_timer(&ifxhcd->host_probe_timer);
+ del_timer(&ifxhcd->autoprobe_timer);
+ ifxhcd->power_status = 0;
+ }
+ else
+ {
+ del_timer(&ifxhcd->autoprobe_timer);
+ ifxhcd->autoprobe_timer.expires = jiffies + (HZ*ifxhcd->autoprobe_sec);
+ add_timer(&ifxhcd->autoprobe_timer);
+ ifxhcd->power_status = 2;
+ del_timer(&ifxhcd->host_probe_timer);
+ do_suspend_h(&ifxhcd->core_if);
+ }
+ }
+
+ static void host_autoprobe(unsigned long _ptr)
+ {
+ ifxhcd_hcd_t *ifxhcd = (ifxhcd_hcd_t *)_ptr;
+ del_timer(&ifxhcd->host_probe_timer);
+ ifxhcd->host_probe_timer.function = host_probe;
+ ifxhcd->host_probe_timer.expires = jiffies + (HZ*ifxhcd->probe_sec);
+ ifxhcd->host_probe_timer.data = (unsigned long)ifxhcd;
+ add_timer(&ifxhcd->host_probe_timer);
+ do_resume_h(&ifxhcd->core_if);
+ }
+
+ static void suspend_host_store(ifxhcd_hcd_t *ifxhcd , uint32_t value)
+ {
+ if(value==2)
+ {
+ del_timer(&ifxhcd->autoprobe_timer);
+ ifxhcd->autoprobe_timer.function = host_autoprobe;
+ ifxhcd->autoprobe_timer.expires = jiffies + (HZ*ifxhcd->autoprobe_sec);
+ ifxhcd->autoprobe_timer.data = (unsigned long)ifxhcd;
+ add_timer(&ifxhcd->autoprobe_timer);
+ ifxhcd->power_status = 2;
+ }
+ else if(value==1)
+ {
+ do_suspend_h(&ifxhcd->core_if);
+ ifxhcd->power_status = 1;
+ del_timer(&ifxhcd->host_probe_timer);
+ del_timer(&ifxhcd->autoprobe_timer);
+ }
+ else if(value==0)
+ {
+ do_resume_h(&ifxhcd->core_if);
+ ifxhcd->power_status = 0;
+ del_timer(&ifxhcd->host_probe_timer);
+ del_timer(&ifxhcd->autoprobe_timer);
+ }
+ }
+ #ifdef __IS_DUAL__
+ static ssize_t procfs_suspend_host_2_store(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ suspend_host_store(&ifxusb_hcd_2,value);
+ return count;
+ }
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_suspend_host_2_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_suspend_host_2_store( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ suspend_host_store(&ifxusb_hcd_2,value);
+ return count;
+ }
+
+ static ssize_t procfs_suspend_host_1_store(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ suspend_host_store(&ifxusb_hcd_1,value);
+ return count;
+ }
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_suspend_host_1_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_suspend_host_1_store( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ suspend_host_store(&ifxusb_hcd_1,value);
+ return count;
+ }
+ DEVICE_ATTR(suspend_host_2, S_IWUSR,NULL, sysfs_suspend_host_2_store);
+ DEVICE_ATTR(suspend_host_1, S_IWUSR,NULL, sysfs_suspend_host_1_store);
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+ #else
+ static ssize_t procfs_suspend_host_store(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ suspend_host_store(&ifxusb_hcd,value);
+ return count;
+ }
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_suspend_host_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_suspend_host_store( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ suspend_host_store(&ifxusb_hcd,value);
+ return count;
+ }
+ DEVICE_ATTR(suspend_host, S_IWUSR,NULL, sysfs_suspend_host_store);
+ #endif
+#endif
+
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+#ifdef __IS_HOST__
+ static void probe_host_store(ifxhcd_hcd_t *ifxhcd, uint32_t value)
+ {
+ if(ifxhcd->power_status == 1)
+ {
+ del_timer(&ifxhcd->host_probe_timer);
+ ifxhcd->host_probe_timer.function = host_probe;
+ ifxhcd->host_probe_timer.expires = jiffies + (HZ*ifxhcd->probe_sec);
+ ifxhcd->host_probe_timer.data = (unsigned long) ifxhcd;
+ add_timer(&ifxhcd->host_probe_timer);
+ do_resume_h(&ifxhcd->core_if);
+ }
+ }
+ #ifdef __IS_DUAL__
+ static ssize_t probe_host_2_show(char *buf)
+ {
+ if(ifxusb_hcd_2.power_status == 0)
+ return sprintf (buf,"Host 2 power status is ON\n");
+ else if(ifxusb_hcd_2.power_status == 1)
+ return sprintf (buf,"Host 2 power status is Suspend\n");
+ else
+ return sprintf (buf,"Host 2 power status is Auto-probing\n");
+ }
+ static ssize_t probe_host_1_show(char *buf)
+ {
+ if(ifxusb_hcd_1.power_status == 0)
+ return sprintf (buf,"Host 1 power status is ON\n");
+ else if(ifxusb_hcd_1.power_status == 1)
+ return sprintf (buf,"Host 1 power status is Suspend\n");
+ else
+ return sprintf (buf,"Host 1 power status is Auto-probing\n");
+ }
+ static ssize_t procfs_probe_host_2_store(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ probe_host_store(&ifxusb_hcd_2,value);
+ return count;
+ }
+ static ssize_t procfs_probe_host_2_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return probe_host_2_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_probe_host_2_show( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_probe_host_2_show( struct device *_dev, char *buf)
+ #endif
+ {
+ return probe_host_2_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_probe_host_2_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_probe_host_2_store( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ probe_host_store(&ifxusb_hcd_2,value);
+ return count;
+ }
+
+ static ssize_t procfs_probe_host_1_store(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ probe_host_store(&ifxusb_hcd_1,value);
+ return count;
+ }
+ static ssize_t procfs_probe_host_1_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return probe_host_1_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_probe_host_1_show( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_probe_host_1_show( struct device *_dev, char *buf)
+ #endif
+ {
+ return probe_host_1_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_probe_host_1_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_probe_host_1_store( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ probe_host_store(&ifxusb_hcd_1,value);
+ return count;
+ }
+ DEVICE_ATTR(probe_host_2, S_IRUGO|S_IWUSR, sysfs_probe_host_2_show, sysfs_probe_host_2_store);
+ DEVICE_ATTR(probe_host_1, S_IRUGO|S_IWUSR, sysfs_probe_host_1_show, sysfs_probe_host_1_store);
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+ #else
+ static ssize_t probe_host_show(char *buf)
+ {
+ if(ifxusb_hcd.power_status == 0)
+ return sprintf (buf,"Host power status is ON\n");
+ else if(ifxusb_hcd.power_status == 1)
+ return sprintf (buf,"Host power status is Suspend\n");
+ else
+ return sprintf (buf,"Host power status is Auto-probing\n");
+ }
+ static ssize_t procfs_probe_host_store(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ probe_host_store(&ifxusb_hcd,value);
+ return count;
+ }
+ static ssize_t procfs_probe_host_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return probe_host_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_probe_host_show( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_probe_host_show( struct device *_dev, char *buf)
+ #endif
+ {
+ return probe_host_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_probe_host_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_probe_host_store( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ probe_host_store(&ifxusb_hcd,value);
+ return count;
+ }
+ DEVICE_ATTR(probe_host, S_IRUGO|S_IWUSR, sysfs_probe_host_show, sysfs_probe_host_store);
+ #endif
+#endif
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+#ifdef __IS_DEVICE__
+ static void device_probe(unsigned long _ptr)
+ {
+ if(ifxusb_pcd.power_status == 2)
+ {
+ del_timer(&ifxusb_pcd.device_autoprobe_timer);
+ ifxusb_pcd.device_autoprobe_timer.expires = jiffies + (HZ*ifxusb_pcd.autoprobe_sec);
+ add_timer(&ifxusb_pcd.device_autoprobe_timer);
+ ifxusb_pcd.power_status = 2;
+ do_suspend_d(&ifxusb_pcd.core_if);
+ }
+ else if(ifxusb_pcd.power_status == 1)
+ {
+ do_suspend_d(&ifxusb_pcd.core_if);
+ ifxusb_pcd.power_status = 1;
+ }
+ }
+ static void device_autoprobe(unsigned long _ptr)
+ {
+ init_timer(&ifxusb_pcd.device_probe_timer);
+ ifxusb_pcd.device_probe_timer.function = device_probe;
+ ifxusb_pcd.device_probe_timer.expires = jiffies + (HZ*ifxusb_pcd.probe_sec);
+ add_timer(&ifxusb_pcd.device_probe_timer);
+ do_resume_d(&ifxusb_pcd.core_if);
+ }
+ static void suspend_device_store(uint32_t value)
+ {
+ if(value==2)
+ {
+ del_timer(&ifxusb_pcd.device_autoprobe_timer);
+ ifxusb_pcd.device_autoprobe_timer.function = device_autoprobe;
+ ifxusb_pcd.device_autoprobe_timer.expires = jiffies + (HZ*ifxusb_pcd.autoprobe_sec);
+ add_timer(&ifxusb_pcd.device_autoprobe_timer);
+ ifxusb_pcd.power_status = 2;
+ }
+ else if(value==1)
+ {
+ do_suspend_d(&ifxusb_pcd.core_if);
+ ifxusb_pcd.power_status = 1;
+ del_timer(&ifxusb_pcd.device_autoprobe_timer);
+ del_timer(&ifxusb_pcd.device_probe_timer);
+ }
+ else if(value==0)
+ {
+ do_resume_d(&ifxusb_pcd.core_if);
+ ifxusb_pcd.power_status = 0;
+ del_timer(&ifxusb_pcd.device_autoprobe_timer);
+ del_timer(&ifxusb_pcd.device_probe_timer);
+ }
+ }
+ static ssize_t procfs_suspend_device_store(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ suspend_device_store(value);
+ return count;
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_suspend_device_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_suspend_device_store( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ suspend_device_store(value);
+ return count;
+ }
+ DEVICE_ATTR(suspend_device, S_IWUSR,NULL,sysfs_suspend_device_store);
+#endif
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+#ifdef __IS_DEVICE__
+ static ssize_t probe_device_show(char *buf)
+ {
+ if(ifxusb_pcd.power_status == 0)
+ return sprintf (buf,"Device power status is ON\n");
+ else if(ifxusb_pcd.power_status == 1)
+ return sprintf (buf,"Device power status is Suspend\n");
+ else
+ return printk(buf,"Device power status is Auto-probing\n");
+ }
+ static void probe_device_store(uint32_t value)
+ {
+
+ if(ifxusb_pcd.power_status == 1)
+ {
+ del_timer(&ifxusb_pcd.device_probe_timer);
+ ifxusb_pcd.device_probe_timer.function = device_probe;
+ ifxusb_pcd.device_probe_timer.expires = jiffies + (HZ*ifxusb_pcd.probe_sec);
+ add_timer(&ifxusb_pcd.device_probe_timer);
+ do_resume_d(&ifxusb_pcd.core_if);
+ }
+ }
+ static ssize_t procfs_probe_device_store(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ probe_device_store(value);
+ return count;
+ }
+ static ssize_t procfs_probe_device_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return probe_device_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_probe_device_show( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_probe_device_show( struct device *_dev, char *buf)
+ #endif
+ {
+ return probe_device_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_probe_device_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_probe_device_store( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ probe_device_store(value);
+ return count;
+ }
+ DEVICE_ATTR(probe_device, S_IRUGO|S_IWUSR, sysfs_probe_device_show, sysfs_probe_device_store);
+#endif
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+#ifdef __IS_HOST__
+ #ifdef __IS_DUAL__
+ static ssize_t autoprobe_timer2_val_show(char *buf)
+ {
+ return sprintf (buf,"Host 2 auto-probe timer is %d second\n",ifxusb_hcd_2.autoprobe_sec);
+ }
+ static ssize_t procfs_autoprobe_timer2_val_store(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ if((value > 0)&&(value < 300))
+ ifxusb_hcd_2.autoprobe_sec = value;
+ return count;
+ }
+ static ssize_t procfs_autoprobe_timer2_val_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return autoprobe_timer2_val_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_autoprobe_timer2_val_show( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_autoprobe_timer2_val_show( struct device *_dev, char *buf)
+ #endif
+ {
+ return autoprobe_timer2_val_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_autoprobe_timer2_val_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_autoprobe_timer2_val_store( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ if((value > 0)&&(value < 300))
+ ifxusb_hcd_2.autoprobe_sec = value;
+ return count;
+ }
+
+ static ssize_t autoprobe_timer1_val_show(char *buf)
+ {
+ return sprintf (buf,"Host 1 auto-probe timer is %d second\n",ifxusb_hcd_1.autoprobe_sec);
+ }
+ static ssize_t procfs_autoprobe_timer1_val_store(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ if((value > 0)&&(value < 300))
+ ifxusb_hcd_1.autoprobe_sec = value;
+ return count;
+ }
+ static ssize_t procfs_autoprobe_timer1_val_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return autoprobe_timer1_val_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_autoprobe_timer1_val_show( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_autoprobe_timer1_val_show( struct device *_dev, char *buf)
+ #endif
+ {
+ return autoprobe_timer1_val_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_autoprobe_timer1_val_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_autoautoprobe_timer1_val_store( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ if((value > 0)&&(value < 300))
+ ifxusb_hcd_1.autoprobe_sec = value;
+ return count;
+ }
+
+ static ssize_t probe_timer2_val_show(char *buf)
+ {
+ return sprintf (buf,"Host 2 probe timer is %d second\n",ifxusb_hcd_2.probe_sec);
+ }
+ static ssize_t procfs_probe_timer2_val_store(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ if((value > 0)&&(value < 10))
+ ifxusb_hcd_2.probe_sec = value;
+ return count;
+ }
+ static ssize_t procfs_probe_timer2_val_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return probe_timer2_val_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_probe_timer2_val_show( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_probe_timer2_val_show( struct device *_dev, char *buf)
+ #endif
+ {
+ return probe_timer2_val_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_probe_timer2_val_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_probe_timer2_val_store( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ if((value > 0)&&(value < 10))
+ ifxusb_hcd_2.probe_sec = value;
+ return count;
+ }
+
+ static ssize_t probe_timer1_val_show(char *buf)
+ {
+ return sprintf (buf,"Host 1 probe timer is %d second\n",ifxusb_hcd_1.probe_sec);
+ }
+ static ssize_t procfs_probe_timer1_val_store(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ if((value > 0)&&(value < 10))
+ ifxusb_hcd_1.probe_sec = value;
+ return count;
+ }
+ static ssize_t procfs_probe_timer1_val_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return probe_timer1_val_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_probe_timer1_val_show( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_probe_timer1_val_show( struct device *_dev, char *buf)
+ #endif
+ {
+ return probe_timer1_val_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_probe_timer1_val_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_probe_timer1_val_store( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ if((value > 0)&&(value < 10))
+ ifxusb_hcd_1.probe_sec = value;
+ return count;
+ }
+ DEVICE_ATTR(probe_timer1_val_h, S_IRUGO|S_IWUSR, sysfs_probe_timer1_val_show, sysfs_probe_timer1_val_store);
+ DEVICE_ATTR(probe_timer2_val_h, S_IRUGO|S_IWUSR, sysfs_probe_timer2_val_show, sysfs_probe_timer2_val_store);
+ DEVICE_ATTR(autoprobe_timer1_val_h, S_IRUGO|S_IWUSR, sysfs_autoprobe_timer1_val_show, sysfs_autoprobe_timer1_val_store);
+ DEVICE_ATTR(autoprobe_timer2_val_h, S_IRUGO|S_IWUSR, sysfs_autoprobe_timer2_val_show, sysfs_autoprobe_timer2_val_store);
+ #else
+ static ssize_t autoprobe_timer_val_show(char *buf)
+ {
+ return sprintf (buf,"Host auto-probe timer is %d second\n",ifxusb_hcd.autoprobe_sec);
+ }
+ static ssize_t procfs_autoprobe_timer_val_store(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ if((value > 0)&&(value < 300))
+ ifxusb_hcd.autoprobe_sec = value;
+ return count;
+ }
+ static ssize_t procfs_autoprobe_timer_val_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return autoprobe_timer_val_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_autoprobe_timer_val_show( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_autoprobe_timer_val_show( struct device *_dev, char *buf)
+ #endif
+ {
+ return autoprobe_timer_val_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_autoprobe_timer_val_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_autoautoprobe_timer_val_store( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ if((value > 0)&&(value < 300))
+ ifxusb_hcd.autoprobe_sec = value;
+ return count;
+ }
+ static ssize_t probe_timer_val_show(char *buf)
+ {
+ return sprintf (buf,"Host probe timer is %d second\n",ifxusb_hcd.probe_sec);
+ }
+ static ssize_t procfs_probe_timer_val_store(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ if((value > 0)&&(value < 10))
+ ifxusb_hcd.probe_sec = value;
+ return count;
+ }
+ static ssize_t procfs_probe_timer_val_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return probe_timer_val_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_probe_timer_val_show( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_probe_timer_val_show( struct device *_dev, char *buf)
+ #endif
+ {
+ return probe_timer_val_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_probe_timer_val_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_probe_timer_val_store( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ if((value > 0)&&(value < 10))
+ ifxusb_hcd.probe_sec = value;
+ return count;
+ }
+ DEVICE_ATTR(probe_timer_val_h, S_IRUGO|S_IWUSR, sysfs_probe_timer_val_show, sysfs_probe_timer_val_store);
+ DEVICE_ATTR(autoprobe_timer_val_h, S_IRUGO|S_IWUSR, sysfs_autoprobe_timer_val_show, sysfs_autoprobe_timer_val_store);
+ #endif
+#endif
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+#ifdef __IS_DEVICE__
+ static ssize_t autoprobe_timer_val_show(char *buf)
+ {
+ return sprintf (buf,"Device auto-probe timer is %d second\n",ifxusb_pcd.autoprobe_sec);
+ }
+ static ssize_t procfs_autoprobe_timer_val_store(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ if((value > 0)&&(value < 300))
+ ifxusb_pcd.autoprobe_sec = value;
+ return count;
+ }
+ static ssize_t procfs_autoprobe_timer_val_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return autoprobe_timer_val_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_autoprobe_timer_val_show( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_autoprobe_timer_val_show( struct device *_dev, char *buf)
+ #endif
+ {
+ return autoprobe_timer_val_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_autoprobe_timer_val_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_autoautoprobe_timer_val_store( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ if((value > 0)&&(value < 300))
+ ifxusb_pcd.autoprobe_sec = value;
+ return count;
+ }
+ static ssize_t probe_timer_val_show(char *buf)
+ {
+ return sprintf (buf,"Device probe timer is %d second\n",ifxusb_pcd.probe_sec);
+ }
+ static ssize_t procfs_probe_timer_val_store(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ if((value > 0)&&(value < 10))
+ ifxusb_pcd.probe_sec = value;
+ return count;
+ }
+ static ssize_t procfs_probe_timer_val_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return probe_timer_val_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_probe_timer_val_show( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_probe_timer_val_show( struct device *_dev, char *buf)
+ #endif
+ {
+ return probe_timer_val_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_probe_timer_val_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_probe_timer_val_store( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ if((value > 0)&&(value < 10))
+ ifxusb_pcd.probe_sec = value;
+ return count;
+ }
+ DEVICE_ATTR(probe_timer_val_d, S_IRUGO|S_IWUSR, sysfs_probe_timer_val_show, sysfs_probe_timer_val_store);
+ DEVICE_ATTR(autoprobe_timer_val_d, S_IRUGO|S_IWUSR, sysfs_autoprobe_timer_val_show, sysfs_autoprobe_timer_val_store);
+#endif
+//////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////
+
+static int ifx_proc_addproc(char *funcname, read_proc_t *hookfuncr, write_proc_t *hookfuncw);
+static void ifx_proc_delproc(char *funcname);
+
+//////////////////////////////////////////////////////////////////////////////////
+
+#if defined(__IS_HOST__) && defined(__HOST_COC__)
+ #ifdef __IS_DUAL__
+ static IFX_PMCU_MODULE_DEP_t depListUSBHost_1=
+ {
+ 1,
+ {
+ {IFX_PMCU_MODULE_CPU, IFX_PMCU_STATE_D0, IFX_PMCU_STATE_D0D3, IFX_PMCU_STATE_D0D3, IFX_PMCU_STATE_D0D3}
+ }
+ };
+ static IFX_PMCU_MODULE_DEP_t depListUSBHost_2=
+ {
+ 1,
+ {
+ {IFX_PMCU_MODULE_CPU, IFX_PMCU_STATE_D0, IFX_PMCU_STATE_D0D3, IFX_PMCU_STATE_D0D3, IFX_PMCU_STATE_D0D3}
+ }
+ };
+ // This functions returns the current power state of the module
+ static IFX_PMCU_RETURN_t
+ ifx_usbhost_stateGet_1(IFX_PMCU_STATE_t *pmcuModState) {
+ printk(KERN_DEBUG "ifx_usbhost_stateGet_1 is called\n");
+ if(ifxusb_hcd_1.power_status == 0){
+ printk(KERN_DEBUG "current power state of USB Host #1 is D0\n");
+ *pmcuModState = IFX_PMCU_STATE_D0; // set here the right value
+ }
+ else if(ifxusb_hcd_1.power_status == 1){
+ printk(KERN_DEBUG "current power state of USB Host #1 is D3 (Suspend)\n");
+ *pmcuModState = IFX_PMCU_STATE_D3; // set here the right value
+ }
+ else if(ifxusb_hcd_1.power_status == 2){
+ printk(KERN_DEBUG "current power state of USB Host #1 is D3 (Auto-Probing)\n");
+ *pmcuModState = IFX_PMCU_STATE_D3; // set here the right value
+ }
+ else{
+ printk(KERN_DEBUG "current power state of USB Host #1 is unknown (%d)\n",ifxusb_hcd_1.power_status);
+ *pmcuModState = IFX_PMCU_STATE_INVALID; // must be set to INVALID
+ }
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ static IFX_PMCU_RETURN_t
+ ifx_usbhost_stateGet_2(IFX_PMCU_STATE_t *pmcuModState) {
+ printk(KERN_DEBUG "ifx_usbhost_stateGet_2 is called\n");
+ if(ifxusb_hcd_2.power_status == 0){
+ printk(KERN_DEBUG "current power state of USB Host #2 is D0\n");
+ *pmcuModState = IFX_PMCU_STATE_D0; // set here the right value
+ }
+ else if(ifxusb_hcd_2.power_status == 1){
+ printk(KERN_DEBUG "current power state of USB Host #2 is D3 (Suspend)\n");
+ *pmcuModState = IFX_PMCU_STATE_D3; // set here the right value
+ }
+ else if(ifxusb_hcd_2.power_status == 2){
+ printk(KERN_DEBUG "current power state of USB Host #2 is D3 (Auto-Probing)\n");
+ *pmcuModState = IFX_PMCU_STATE_D3; // set here the right value
+ }
+ else{
+ printk(KERN_DEBUG "current power state of USB Host #2 is unknown (%d)\n",ifxusb_hcd_2.power_status);
+ *pmcuModState = IFX_PMCU_STATE_INVALID; // must be set to INVALID
+ }
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+
+
+ // The function should be used to enable/disable the module specific power saving methods
+ static IFX_PMCU_RETURN_t
+ ifx_usbhost_pwrFeatureSwitch_1(IFX_PMCU_PWR_STATE_ENA_t pmcuPwrStateEna)
+ {
+ if (pmcuPwrStateEna == IFX_PMCU_PWR_STATE_ON) {
+ suspend_host_store(&ifxusb_hcd_1, 0);
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ if (pmcuPwrStateEna == IFX_PMCU_PWR_STATE_OFF) {
+ suspend_host_store(&ifxusb_hcd_1, 1);
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ static IFX_PMCU_RETURN_t
+ ifx_usbhost_pwrFeatureSwitch_2(IFX_PMCU_PWR_STATE_ENA_t pmcuPwrStateEna)
+ {
+ if (pmcuPwrStateEna == IFX_PMCU_PWR_STATE_ON) {
+ suspend_host_store(&ifxusb_hcd_2, 0);
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ if (pmcuPwrStateEna == IFX_PMCU_PWR_STATE_OFF) {
+ suspend_host_store(&ifxusb_hcd_2, 1);
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+
+ // This function should be used to do all the necessary clean-up's before a the real
+ // power state change is initiated; e.g. flush all serial buffers inside the UART before
+ // the frequency will be changed.
+ static IFX_PMCU_RETURN_t
+ ifx_usbhost_preChange_1(IFX_PMCU_MODULE_t pmcuModule, IFX_PMCU_STATE_t newState, IFX_PMCU_STATE_t oldState)
+ {
+ printk(KERN_DEBUG "ifx_usbhost_preChange_1 is called\n");
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ static IFX_PMCU_RETURN_t
+ ifx_usbhost_preChange_2(IFX_PMCU_MODULE_t pmcuModule, IFX_PMCU_STATE_t newState, IFX_PMCU_STATE_t oldState)
+ {
+ printk(KERN_DEBUG "ifx_usbhost_preChange_2 is called\n");
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+
+
+ // This function initiate the real power state change. The module should do all the necessary
+ // adpations to the new state.
+ static IFX_PMCU_RETURN_t
+ ifx_usbhost_stateChange_1(IFX_PMCU_STATE_t newState)
+ {
+ printk(KERN_DEBUG "ifx_usbhost_stateChange_1 is called\n");
+ if (newState == IFX_PMCU_STATE_D0) {
+ suspend_host_store(&ifxusb_hcd_1, 0);
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ if (newState == IFX_PMCU_STATE_D1) {
+ suspend_host_store(&ifxusb_hcd_1, 1);
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ if (newState == IFX_PMCU_STATE_D2) {
+ suspend_host_store(&ifxusb_hcd_1, 1);
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ if (newState == IFX_PMCU_STATE_D3) {
+ suspend_host_store(&ifxusb_hcd_1, 1);
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ static IFX_PMCU_RETURN_t
+ ifx_usbhost_stateChange_2(IFX_PMCU_STATE_t newState)
+ {
+ printk(KERN_DEBUG "ifx_usbhost_stateChange_2 is called\n");
+ if (newState == IFX_PMCU_STATE_D0) {
+ suspend_host_store(&ifxusb_hcd_2, 0);
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ if (newState == IFX_PMCU_STATE_D1) {
+ suspend_host_store(&ifxusb_hcd_2, 1);
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ if (newState == IFX_PMCU_STATE_D2) {
+ suspend_host_store(&ifxusb_hcd_2, 1);
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ if (newState == IFX_PMCU_STATE_D3) {
+ suspend_host_store(&ifxusb_hcd_2, 1);
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+
+ // This function should be used to do all the necessary post processing after a the real
+ // power state change was initiated.
+ static IFX_PMCU_RETURN_t
+ ifx_usbhost_postChange_1(IFX_PMCU_MODULE_t pmcuModule, IFX_PMCU_STATE_t newState, IFX_PMCU_STATE_t oldState)
+ {
+ printk(KERN_DEBUG "ifx_usbhost_postChange_1 is called\n");
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ static IFX_PMCU_RETURN_t
+ ifx_usbhost_postChange_2(IFX_PMCU_MODULE_t pmcuModule, IFX_PMCU_STATE_t newState, IFX_PMCU_STATE_t oldState)
+ {
+ printk(KERN_DEBUG "ifx_usbhost_postChange_2 is called\n");
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ #else
+ static IFX_PMCU_MODULE_DEP_t depListUSBHost=
+ {
+ 1,
+ {
+ {IFX_PMCU_MODULE_CPU, IFX_PMCU_STATE_D0, IFX_PMCU_STATE_D0D3, IFX_PMCU_STATE_D0D3, IFX_PMCU_STATE_D0D3}
+ }
+ };
+ // This functions returns the current power state of the module
+ static IFX_PMCU_RETURN_t
+ ifx_usbhost_stateGet(IFX_PMCU_STATE_t *pmcuModState) {
+ printk(KERN_DEBUG "ifx_usbhost_stateGet is called\n");
+ if(ifxusb_hcd.power_status == 0){
+ printk(KERN_DEBUG "current power state of USB Host is D0\n");
+ *pmcuModState = IFX_PMCU_STATE_D0; // set here the right value
+ }
+ else if(ifxusb_hcd.power_status == 1){
+ printk(KERN_DEBUG "current power state of USB Host is D3 (Suspend)\n");
+ *pmcuModState = IFX_PMCU_STATE_D3; // set here the right value
+ }
+ else if(ifxusb_hcd.power_status == 2){
+ printk(KERN_DEBUG "current power state of USB Host is D3 (Auto-Probing)\n");
+ *pmcuModState = IFX_PMCU_STATE_D3; // set here the right value
+ }
+ else{
+ printk(KERN_DEBUG "current power state of USB Host is unknown (%d)\n",ifxusb_hcd.power_status);
+ *pmcuModState = IFX_PMCU_STATE_INVALID; // must be set to INVALID
+ }
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ // The function should be used to enable/disable the module specific power saving methods
+ static IFX_PMCU_RETURN_t
+ ifx_usbhost_pwrFeatureSwitch(IFX_PMCU_PWR_STATE_ENA_t pmcuPwrStateEna)
+ {
+ if (pmcuPwrStateEna == IFX_PMCU_PWR_STATE_ON) {
+ suspend_host_store(&ifxusb_hcd, 0);
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ if (pmcuPwrStateEna == IFX_PMCU_PWR_STATE_OFF) {
+ suspend_host_store(&ifxusb_hcd, 1);
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+
+ // This function should be used to do all the necessary clean-up's before a the real
+ // power state change is initiated; e.g. flush all serial buffers inside the UART before
+ // the frequency will be changed.
+ static IFX_PMCU_RETURN_t
+ ifx_usbhost_preChange(IFX_PMCU_MODULE_t pmcuModule, IFX_PMCU_STATE_t newState, IFX_PMCU_STATE_t oldState)
+ {
+ printk(KERN_DEBUG "ifx_usbhost_preChange is called\n");
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+
+
+ // This function initiate the real power state change. The module should do all the necessary
+ // adpations to the new state.
+ static IFX_PMCU_RETURN_t
+ ifx_usbhost_stateChange(IFX_PMCU_STATE_t newState)
+ {
+ printk(KERN_DEBUG "ifx_usbhost_stateChange is called\n");
+ if (newState == IFX_PMCU_STATE_D0) {
+ suspend_host_store(&ifxusb_hcd, 0);
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ if (newState == IFX_PMCU_STATE_D1) {
+ suspend_host_store(&ifxusb_hcd, 1);
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ if (newState == IFX_PMCU_STATE_D2) {
+ suspend_host_store(&ifxusb_hcd, 1);
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ if (newState == IFX_PMCU_STATE_D3) {
+ suspend_host_store(&ifxusb_hcd, 1);
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+
+ // This function should be used to do all the necessary post processing after a the real
+ // power state change was initiated.
+ static IFX_PMCU_RETURN_t
+ ifx_usbhost_postChange(IFX_PMCU_MODULE_t pmcuModule, IFX_PMCU_STATE_t newState, IFX_PMCU_STATE_t oldState)
+ {
+ printk(KERN_DEBUG "ifx_usbhost_postChange is called\n");
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ #endif
+#endif
+#if defined(__IS_DEVICE__) && defined(__GADGET_COC__)
+ static IFX_PMCU_MODULE_DEP_t depListUSBGadget=
+ {
+ 1,
+ {
+ {IFX_PMCU_MODULE_CPU, IFX_PMCU_STATE_D0, IFX_PMCU_STATE_D0D3, IFX_PMCU_STATE_D0D3, IFX_PMCU_STATE_D0D3}
+ }
+ };
+ // This functions returns the current power state of the module
+ static IFX_PMCU_RETURN_t
+ ifx_usbgadget_stateGet(IFX_PMCU_STATE_t *pmcuModState) {
+ printk(KERN_DEBUG "ifx_usbgadget_stateGet is called\n");
+ if(ifxusb_pcd.power_status == 0){
+ printk(KERN_DEBUG "current power state of USB Gadget is D0\n");
+ *pmcuModState = IFX_PMCU_STATE_D0; // set here the right value
+ }
+ else if(ifxusb_pcd.power_status == 1){
+ printk(KERN_DEBUG "current power state of USB Gadget is D3 (Suspend)\n");
+ *pmcuModState = IFX_PMCU_STATE_D3; // set here the right value
+ }
+ else if(ifxusb_pcd.power_status == 2){
+ printk(KERN_DEBUG "current power state of USB Gadget is D3 (Auto-Probing)\n");
+ *pmcuModState = IFX_PMCU_STATE_D3; // set here the right value
+ }
+ else{
+ printk(KERN_DEBUG "current power state of USB Gadget is unknown (%d)\n",ifxusb_pcd.power_status);
+ *pmcuModState = IFX_PMCU_STATE_INVALID; // must be set to INVALID
+ }
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ // The function should be used to enable/disable the module specific power saving methods
+ static IFX_PMCU_RETURN_t
+ ifx_usbgadget_pwrFeatureSwitch(IFX_PMCU_PWR_STATE_ENA_t pmcuPwrStateEna)
+ {
+ if (pmcuPwrStateEna == IFX_PMCU_PWR_STATE_ON) {
+ suspend_device_store(0);
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ if (pmcuPwrStateEna == IFX_PMCU_PWR_STATE_OFF) {
+ suspend_device_store(1);
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+
+ // This function should be used to do all the necessary clean-up's before a the real
+ // power state change is initiated; e.g. flush all serial buffers inside the UART before
+ // the frequency will be changed.
+ static IFX_PMCU_RETURN_t
+ ifx_usbgadget_preChange(IFX_PMCU_MODULE_t pmcuModule, IFX_PMCU_STATE_t newState, IFX_PMCU_STATE_t oldState)
+ {
+ printk(KERN_DEBUG "ifx_usbgadget_preChange is called\n");
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+
+
+ // This function initiate the real power state change. The module should do all the necessary
+ // adpations to the new state.
+ static IFX_PMCU_RETURN_t
+ ifx_usbgadget_stateChange(IFX_PMCU_STATE_t newState)
+ {
+ printk(KERN_DEBUG "ifx_usbgadget_stateChange is called\n");
+ if (newState == IFX_PMCU_STATE_D0) {
+ suspend_device_store(0);
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ if (newState == IFX_PMCU_STATE_D1) {
+ suspend_device_store(1);
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ if (newState == IFX_PMCU_STATE_D2) {
+ suspend_device_store(1);
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ if (newState == IFX_PMCU_STATE_D3) {
+ suspend_device_store(1);
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+
+ // This function should be used to do all the necessary post processing after a the real
+ // power state change was initiated.
+ static IFX_PMCU_RETURN_t
+ ifx_usbgadget_postChange(IFX_PMCU_MODULE_t pmcuModule, IFX_PMCU_STATE_t newState, IFX_PMCU_STATE_t oldState)
+ {
+ printk(KERN_DEBUG "ifx_usbgadget_postChange is called\n");
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+#endif
+
+
+/*!
+ \brief This function create the sysfs and procfs entries
+ \param[in] _dev Pointer of device structure, if applied
+ */
+#ifdef __IS_HOST__
+void ifxusb_attr_create_h (void *_dev)
+#else
+void ifxusb_attr_create_d (void *_dev)
+#endif
+{
+ int error;
+
+ struct device *dev = (struct device *) _dev;
+
+ IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
+
+ error = ifx_proc_addproc("dbglevel", procfs_dbglevel_show, procfs_dbglevel_store);
+ #ifdef __IS_HOST__
+ error = device_create_file(dev, &dev_attr_dbglevel_h);
+ #else
+ error = device_create_file(dev, &dev_attr_dbglevel_d);
+ #endif
+
+ #ifdef __IS_HOST__
+ #ifdef __IS_DUAL__
+ error = ifx_proc_addproc("dump_params_1", procfs_dump_params_show_1, NULL);
+ error = ifx_proc_addproc("dump_params_2", procfs_dump_params_show_2, NULL);
+ error = device_create_file(dev, &dev_attr_dump_params_h_1);
+ error = device_create_file(dev, &dev_attr_dump_params_h_2);
+
+ error = ifx_proc_addproc("mode_1", procfs_mode_show_1, NULL);
+ error = ifx_proc_addproc("mode_2", procfs_mode_show_2, NULL);
+ error = device_create_file(dev, &dev_attr_mode_h_1);
+ error = device_create_file(dev, &dev_attr_mode_h_2);
+ #else
+ error = ifx_proc_addproc("dump_params", procfs_dump_params_show, NULL);
+ error = device_create_file(dev, &dev_attr_dump_params_h);
+ error = ifx_proc_addproc("mode", procfs_mode_show, NULL);
+ error = device_create_file(dev, &dev_attr_mode_h);
+ #endif
+ #else
+ error = ifx_proc_addproc("dump_params", procfs_dump_params_show, NULL);
+ error = device_create_file(dev, &dev_attr_dump_params_d);
+
+ error = ifx_proc_addproc("mode", procfs_mode_show, NULL);
+ error = device_create_file(dev, &dev_attr_mode_d);
+ #endif
+
+ #ifdef __IS_HOST__
+ error = ifx_proc_addproc("version", procfs_version_show, NULL);
+ error = device_create_file(dev, &dev_attr_version_h);
+ #else
+ error = ifx_proc_addproc("version", procfs_version_show, NULL);
+ error = device_create_file(dev, &dev_attr_version_d);
+ #endif
+
+
+ #ifdef __IS_HOST__
+ #ifdef __IS_DUAL__
+ error = ifx_proc_addproc("pkt_count_limit_bi_1", procfs_pkt_count_limit_bi_show_1, procfs_pkt_count_limit_bi_store_1);
+ error = ifx_proc_addproc("pkt_count_limit_bo_1", procfs_pkt_count_limit_bo_show_1, procfs_pkt_count_limit_bo_store_1);
+ error = ifx_proc_addproc("pkt_count_limit_bi_2", procfs_pkt_count_limit_bi_show_2, procfs_pkt_count_limit_bi_store_2);
+ error = ifx_proc_addproc("pkt_count_limit_bo_2", procfs_pkt_count_limit_bo_show_2, procfs_pkt_count_limit_bo_store_2);
+ error = ifx_proc_addproc("bandwidth_hs_1", procfs_bandwidth_hs_show_1, procfs_bandwidth_hs_store_1);
+ error = ifx_proc_addproc("bandwidth_fs_1", procfs_bandwidth_fs_show_1, procfs_bandwidth_fs_store_1);
+ error = ifx_proc_addproc("bandwidth_ls_1", procfs_bandwidth_ls_show_1, procfs_bandwidth_ls_store_1);
+ error = ifx_proc_addproc("bandwidth_hs_2", procfs_bandwidth_hs_show_2, procfs_bandwidth_hs_store_2);
+ error = ifx_proc_addproc("bandwidth_fs_2", procfs_bandwidth_fs_show_2, procfs_bandwidth_fs_store_2);
+ error = ifx_proc_addproc("bandwidth_ls_2", procfs_bandwidth_ls_show_2, procfs_bandwidth_ls_store_2);
+ error = device_create_file(dev, &dev_attr_pkt_count_limit_bi_1);
+ error = device_create_file(dev, &dev_attr_pkt_count_limit_bo_1);
+ error = device_create_file(dev, &dev_attr_pkt_count_limit_bi_2);
+ error = device_create_file(dev, &dev_attr_pkt_count_limit_bo_2);
+ error = device_create_file(dev, &dev_attr_bandwidth_hs_1);
+ error = device_create_file(dev, &dev_attr_bandwidth_fs_1);
+ error = device_create_file(dev, &dev_attr_bandwidth_ls_1);
+ error = device_create_file(dev, &dev_attr_bandwidth_hs_2);
+ error = device_create_file(dev, &dev_attr_bandwidth_fs_2);
+ error = device_create_file(dev, &dev_attr_bandwidth_ls_2);
+ #else
+ error = ifx_proc_addproc("pkt_count_limit_bi", procfs_pkt_count_limit_bi_show, procfs_pkt_count_limit_bi_store);
+ error = ifx_proc_addproc("pkt_count_limit_bo", procfs_pkt_count_limit_bo_show, procfs_pkt_count_limit_bo_store);
+ error = ifx_proc_addproc("bandwidth_hs", procfs_bandwidth_hs_show, procfs_bandwidth_hs_store);
+ error = ifx_proc_addproc("bandwidth_fs", procfs_bandwidth_fs_show, procfs_bandwidth_fs_store);
+ error = ifx_proc_addproc("bandwidth_ls", procfs_bandwidth_ls_show, procfs_bandwidth_ls_store);
+ error = device_create_file(dev, &dev_attr_pkt_count_limit_bi);
+ error = device_create_file(dev, &dev_attr_pkt_count_limit_bo);
+ error = device_create_file(dev, &dev_attr_bandwidth_hs);
+ error = device_create_file(dev, &dev_attr_bandwidth_fs);
+ error = device_create_file(dev, &dev_attr_bandwidth_ls);
+ #endif
+
+ #ifdef __IS_DUAL__
+ error = ifx_proc_addproc("buspower_1", procfs_buspower_show_1, procfs_buspower_store_1);
+ error = ifx_proc_addproc("buspower_2", procfs_buspower_show_2, procfs_buspower_store_2);
+ error = device_create_file(dev, &dev_attr_buspower_1);
+ error = device_create_file(dev, &dev_attr_buspower_2);
+ #else
+ error = ifx_proc_addproc("buspower", procfs_buspower_show, procfs_buspower_store);
+ error = device_create_file(dev, &dev_attr_buspower);
+ #endif
+
+ #ifdef __IS_DUAL__
+ error = ifx_proc_addproc("bussuspend_1", procfs_bussuspend_show_1, NULL);
+ error = ifx_proc_addproc("bussuspend_2", procfs_bussuspend_show_2, NULL);
+ error = device_create_file(dev, &dev_attr_bussuspend_1);
+ error = device_create_file(dev, &dev_attr_bussuspend_2);
+ #else
+ error = ifx_proc_addproc("bussuspend", procfs_bussuspend_show, NULL);
+ error = device_create_file(dev, &dev_attr_bussuspend);
+ #endif
+
+ #ifdef __IS_DUAL__
+ error = ifx_proc_addproc("busconnected_1", procfs_busconnected_show_1, NULL);
+ error = ifx_proc_addproc("busconnected_2", procfs_busconnected_show_2, NULL);
+ error = device_create_file(dev, &dev_attr_busconnected_1);
+ error = device_create_file(dev, &dev_attr_busconnected_2);
+ #else
+ error = ifx_proc_addproc("busconnected", procfs_busconnected_show, NULL);
+ error = device_create_file(dev, &dev_attr_busconnected);
+ #endif
+
+ #ifdef __IS_DUAL__
+ error = ifx_proc_addproc("connectspeed_1", procfs_connectspeed_show_1, NULL);
+ error = ifx_proc_addproc("connectspeed_2", procfs_connectspeed_show_2, NULL);
+ error = device_create_file(dev, &dev_attr_connectspeed_1);
+ error = device_create_file(dev, &dev_attr_connectspeed_2);
+ #else
+ error = ifx_proc_addproc("connectspeed", procfs_connectspeed_show, NULL);
+ error = device_create_file(dev, &dev_attr_connectspeed);
+ #endif
+ #endif
+
+ #ifdef __IS_DEVICE__
+ error = ifx_proc_addproc("devspeed", procfs_devspeed_show, NULL);
+ error = device_create_file(dev, &dev_attr_devspeed);
+ error = ifx_proc_addproc("enumspeed", procfs_enumspeed_show, NULL);
+ error = device_create_file(dev, &dev_attr_enumspeed);
+ #endif
+
+ //////////////////////////////////////////////////////
+ #ifdef __ENABLE_DUMP__
+
+ #ifdef __IS_HOST__
+ #ifdef __IS_DUAL__
+ error = ifx_proc_addproc("dump_reg_1", procfs_dump_reg_show_1, NULL);
+ error = ifx_proc_addproc("dump_reg_2", procfs_dump_reg_show_2, NULL);
+ error = device_create_file(dev, &dev_attr_dump_reg_h_1);
+ error = device_create_file(dev, &dev_attr_dump_reg_h_2);
+ #else
+ error = ifx_proc_addproc("dump_reg", procfs_dump_reg_show, NULL);
+ error = device_create_file(dev, &dev_attr_dump_reg_h);
+ #endif
+
+ #ifdef __IS_DUAL__
+ error = ifx_proc_addproc("dump_spram_1", procfs_dump_spram_show_1, NULL);
+ error = ifx_proc_addproc("dump_spram_2", procfs_dump_spram_show_2, NULL);
+ error = device_create_file(dev, &dev_attr_dump_spram_h_1);
+ error = device_create_file(dev, &dev_attr_dump_spram_h_2);
+ #else
+ error = ifx_proc_addproc("dump_spram", procfs_dump_spram_show, NULL);
+ error = device_create_file(dev, &dev_attr_dump_spram_h);
+ #endif
+
+ #ifdef __IS_DUAL__
+ error = ifx_proc_addproc("dump_host_state_1", procfs_dump_host_state_show_1, NULL);
+ error = ifx_proc_addproc("dump_host_state_2", procfs_dump_host_state_show_2, NULL);
+ error = device_create_file(dev, &dev_attr_dump_host_state_1);
+ error = device_create_file(dev, &dev_attr_dump_host_state_2);
+ #else
+ error = ifx_proc_addproc("dump_host_state", procfs_dump_host_state_show, NULL);
+ error = device_create_file(dev, &dev_attr_dump_host_state);
+ #endif
+ #else
+ error = ifx_proc_addproc("dump_reg", procfs_dump_reg_show, NULL);
+ error = device_create_file(dev, &dev_attr_dump_reg_d);
+ error = ifx_proc_addproc("dump_spram", procfs_dump_spram_show, NULL);
+ error = device_create_file(dev, &dev_attr_dump_spram_d);
+ #endif
+ #endif //__ENABLE_DUMP__
+ //////////////////////////////////////////////////////
+#ifdef __IS_HOST__
+ #ifdef __IS_DUAL__
+ error = ifx_proc_addproc("suspend_host_1",NULL, procfs_suspend_host_1_store);
+ error = device_create_file(dev, &dev_attr_suspend_host_1);
+
+ error = ifx_proc_addproc("probe_host_1", procfs_probe_host_1_show, procfs_probe_host_1_store);
+ error = device_create_file(dev, &dev_attr_probe_host_1);
+
+ error = ifx_proc_addproc("suspend_host_2",NULL, procfs_suspend_host_2_store);
+ error = device_create_file(dev, &dev_attr_suspend_host_2);
+
+ error = ifx_proc_addproc("probe_host_2", procfs_probe_host_2_show, procfs_probe_host_2_store);
+ error = device_create_file(dev, &dev_attr_probe_host_2);
+
+ error = ifx_proc_addproc("probe_timer1", procfs_probe_timer1_val_show, procfs_probe_timer1_val_store);
+ error = device_create_file(dev, &dev_attr_probe_timer1_val_h);
+
+ error = ifx_proc_addproc("probe_timer2", procfs_probe_timer2_val_show, procfs_probe_timer2_val_store);
+ error = device_create_file(dev, &dev_attr_probe_timer2_val_h);
+
+ error = ifx_proc_addproc("autoprobe_timer1", procfs_autoprobe_timer1_val_show, procfs_autoprobe_timer1_val_store);
+ error = device_create_file(dev, &dev_attr_autoprobe_timer1_val_h);
+
+ error = ifx_proc_addproc("autoprobe_timer2", procfs_autoprobe_timer2_val_show, procfs_autoprobe_timer2_val_store);
+ error = device_create_file(dev, &dev_attr_autoprobe_timer2_val_h);
+ #else
+ error = ifx_proc_addproc("suspend_host",NULL, procfs_suspend_host_store);
+ error = device_create_file(dev, &dev_attr_suspend_host);
+
+ error = ifx_proc_addproc("probe_host", procfs_probe_host_show, procfs_probe_host_store);
+ error = device_create_file(dev, &dev_attr_probe_host);
+
+ error = ifx_proc_addproc("probe_timer", procfs_probe_timer_val_show, procfs_probe_timer_val_store);
+ error = device_create_file(dev, &dev_attr_probe_timer_val_h);
+
+ error = ifx_proc_addproc("autoprobe_timer", procfs_autoprobe_timer_val_show, procfs_autoprobe_timer_val_store);
+ error = device_create_file(dev, &dev_attr_autoprobe_timer_val_h);
+ #endif
+#endif
+
+#ifdef __IS_DEVICE__
+ error = ifx_proc_addproc("suspend_device",NULL, procfs_suspend_device_store);
+ error = device_create_file(dev, &dev_attr_suspend_device);
+
+ error = ifx_proc_addproc("probe_device", procfs_probe_device_show, procfs_probe_device_store);
+ error = device_create_file(dev, &dev_attr_probe_device);
+
+ error = ifx_proc_addproc("probe_timer", procfs_probe_timer_val_show, procfs_probe_timer_val_store);
+ error = device_create_file(dev, &dev_attr_probe_timer_val_d);
+
+ error = ifx_proc_addproc("autoprobe_timer", procfs_autoprobe_timer_val_show, procfs_autoprobe_timer_val_store);
+ error = device_create_file(dev, &dev_attr_autoprobe_timer_val_d);
+#endif
+#if defined(__IS_HOST__) && defined(__HOST_COC__)
+ #ifdef __IS_DUAL__
+ memset (&pmcuRegisterUSBHost_1, 0, sizeof(pmcuRegisterUSBHost_1));
+ memset (&pmcuRegisterUSBHost_2, 0, sizeof(pmcuRegisterUSBHost_2));
+ pmcuRegisterUSBHost_1.pmcuModule=
+ pmcuRegisterUSBHost_2.pmcuModule=IFX_PMCU_MODULE_USB;
+ pmcuRegisterUSBHost_1.pmcuModuleNr=1;
+ pmcuRegisterUSBHost_2.pmcuModuleNr=2;
+ pmcuRegisterUSBHost_1.pmcuModuleDep = &depListUSBHost_1;
+ pmcuRegisterUSBHost_2.pmcuModuleDep = &depListUSBHost_2;
+ pmcuRegisterUSBHost_1.pre = ifx_usbhost_preChange_1;
+ pmcuRegisterUSBHost_2.pre = ifx_usbhost_preChange_2;
+ pmcuRegisterUSBHost_1.post = ifx_usbhost_postChange_1;
+ pmcuRegisterUSBHost_2.post = ifx_usbhost_postChange_2;
+ pmcuRegisterUSBHost_1.ifx_pmcu_state_change = ifx_usbhost_stateChange_1;
+ pmcuRegisterUSBHost_2.ifx_pmcu_state_change = ifx_usbhost_stateChange_2;
+ pmcuRegisterUSBHost_1.ifx_pmcu_state_get = ifx_usbhost_stateGet_1;
+ pmcuRegisterUSBHost_2.ifx_pmcu_state_get = ifx_usbhost_stateGet_2;
+ pmcuRegisterUSBHost_1.ifx_pmcu_pwr_feature_switch = ifx_usbhost_pwrFeatureSwitch_1;
+ pmcuRegisterUSBHost_2.ifx_pmcu_pwr_feature_switch = ifx_usbhost_pwrFeatureSwitch_2;
+ ifx_pmcu_register ( &pmcuRegisterUSBHost_1 );
+ ifx_pmcu_register ( &pmcuRegisterUSBHost_2 );
+ #else
+ memset (&pmcuRegisterUSBHost, 0, sizeof(pmcuRegisterUSBHost));
+ pmcuRegisterUSBHost.pmcuModule=IFX_PMCU_MODULE_USB;
+ pmcuRegisterUSBHost.pmcuModuleNr=1;
+ pmcuRegisterUSBHost.pmcuModuleDep = &depListUSBHost;
+ pmcuRegisterUSBHost.pre = ifx_usbhost_preChange;
+ pmcuRegisterUSBHost.post = ifx_usbhost_postChange;
+ pmcuRegisterUSBHost.ifx_pmcu_state_change = ifx_usbhost_stateChange;
+ pmcuRegisterUSBHost.ifx_pmcu_state_get = ifx_usbhost_stateGet;
+ pmcuRegisterUSBHost.ifx_pmcu_pwr_feature_switch = ifx_usbhost_pwrFeatureSwitch;
+ ifx_pmcu_register ( &pmcuRegisterUSBHost );
+ #endif
+#endif
+#if defined(__IS_DEVICE__) && defined(__GADGET_COC__)
+ memset (&pmcuRegisterUSBGadget, 0, sizeof(pmcuRegisterUSBGadget));
+ pmcuRegisterUSBGadget.pmcuModule=IFX_PMCU_MODULE_USB;
+ pmcuRegisterUSBGadget.pmcuModuleNr=0;
+ pmcuRegisterUSBGadget.pmcuModuleDep = &depListUSBGadget;
+ pmcuRegisterUSBGadget.pre = ifx_usbgadget_preChange;
+ pmcuRegisterUSBGadget.post = ifx_usbgadget_postChange;
+ pmcuRegisterUSBGadget.ifx_pmcu_state_change = ifx_usbgadget_stateChange;
+ pmcuRegisterUSBGadget.ifx_pmcu_state_get = ifx_usbgadget_stateGet;
+ pmcuRegisterUSBGadget.ifx_pmcu_pwr_feature_switch = ifx_usbgadget_pwrFeatureSwitch;
+ ifx_pmcu_register ( &pmcuRegisterUSBGadget );
+#endif
+}
+
+
+/*!
+ \brief This function remove the sysfs and procfs entries
+ \param[in] _dev Pointer of device structure, if applied
+ */
+#ifdef __IS_HOST__
+void ifxusb_attr_remove_h (void *_dev)
+#else
+void ifxusb_attr_remove_d (void *_dev)
+#endif
+{
+ struct device *dev = (struct device *) _dev;
+
+ IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
+ ifx_proc_delproc("dbglevel");
+ #ifdef __IS_HOST__
+ device_remove_file(dev, &dev_attr_dbglevel_h);
+ #else
+ device_remove_file(dev, &dev_attr_dbglevel_d);
+ #endif
+
+ #ifdef __IS_HOST__
+ #ifdef __IS_DUAL__
+ ifx_proc_delproc("dump_params_1");
+ ifx_proc_delproc("dump_params_2");
+ device_remove_file(dev, &dev_attr_dump_params_h_1);
+ device_remove_file(dev, &dev_attr_dump_params_h_2);
+ #else
+ ifx_proc_delproc("dump_params");
+ device_remove_file(dev, &dev_attr_dump_params_h);
+ #endif
+
+ #ifdef __IS_DUAL__
+ ifx_proc_delproc("mode_1");
+ ifx_proc_delproc("mode_2");
+ device_remove_file(dev, &dev_attr_mode_h_1);
+ device_remove_file(dev, &dev_attr_mode_h_2);
+ #else
+ ifx_proc_delproc("mode");
+ device_remove_file(dev, &dev_attr_mode_h);
+ #endif
+ #else
+ ifx_proc_delproc("dump_params");
+ device_remove_file(dev, &dev_attr_dump_params_d);
+ ifx_proc_delproc("mode");
+ device_remove_file(dev, &dev_attr_mode_d);
+ #endif
+
+ #ifdef __IS_HOST__
+ ifx_proc_delproc("version");
+ device_remove_file(dev, &dev_attr_version_h);
+ #else
+ ifx_proc_delproc("version");
+ device_remove_file(dev, &dev_attr_version_d);
+ #endif
+
+
+ #ifdef __IS_HOST__
+ #ifdef __IS_DUAL__
+ ifx_proc_delproc("pkt_count_limit_bi_1");
+ ifx_proc_delproc("pkt_count_limit_bo_1");
+ ifx_proc_delproc("pkt_count_limit_bi_2");
+ ifx_proc_delproc("pkt_count_limit_bo_2");
+ ifx_proc_delproc("bandwidth_hs_1");
+ ifx_proc_delproc("bandwidth_fs_1");
+ ifx_proc_delproc("bandwidth_ls_1");
+ ifx_proc_delproc("bandwidth_hs_2");
+ ifx_proc_delproc("bandwidth_fs_2");
+ ifx_proc_delproc("bandwidth_ls_2");
+ device_remove_file(dev, &dev_attr_pkt_count_limit_bi_1);
+ device_remove_file(dev, &dev_attr_pkt_count_limit_bo_1);
+ device_remove_file(dev, &dev_attr_pkt_count_limit_bi_2);
+ device_remove_file(dev, &dev_attr_pkt_count_limit_bo_2);
+ device_remove_file(dev, &dev_attr_bandwidth_hs_1);
+ device_remove_file(dev, &dev_attr_bandwidth_fs_1);
+ device_remove_file(dev, &dev_attr_bandwidth_ls_1);
+ device_remove_file(dev, &dev_attr_bandwidth_hs_2);
+ device_remove_file(dev, &dev_attr_bandwidth_fs_2);
+ device_remove_file(dev, &dev_attr_bandwidth_ls_2);
+ #else
+ ifx_proc_delproc("pkt_count_limit_bi");
+ ifx_proc_delproc("pkt_count_limit_bo");
+ ifx_proc_delproc("bandwidth_hs");
+ ifx_proc_delproc("bandwidth_fs");
+ ifx_proc_delproc("bandwidth_ls");
+ device_remove_file(dev, &dev_attr_pkt_count_limit_bi);
+ device_remove_file(dev, &dev_attr_pkt_count_limit_bo);
+ device_remove_file(dev, &dev_attr_bandwidth_hs);
+ device_remove_file(dev, &dev_attr_bandwidth_fs);
+ device_remove_file(dev, &dev_attr_bandwidth_ls);
+ #endif
+ #endif
+
+ #ifdef __IS_HOST__
+ #ifdef __IS_DUAL__
+ ifx_proc_delproc("buspower_1");
+ ifx_proc_delproc("buspower_2");
+ device_remove_file(dev, &dev_attr_buspower_1);
+ device_remove_file(dev, &dev_attr_buspower_2);
+ #else
+ ifx_proc_delproc("buspower");
+ device_remove_file(dev, &dev_attr_buspower);
+ #endif
+
+ #ifdef __IS_DUAL__
+ ifx_proc_delproc("bussuspend_1");
+ ifx_proc_delproc("bussuspend_2");
+ device_remove_file(dev, &dev_attr_bussuspend_1);
+ device_remove_file(dev, &dev_attr_bussuspend_2);
+ #else
+ ifx_proc_delproc("bussuspend");
+ device_remove_file(dev, &dev_attr_bussuspend);
+ #endif
+
+ #ifdef __IS_DUAL__
+ ifx_proc_delproc("busconnected_1");
+ ifx_proc_delproc("busconnected_2");
+ device_remove_file(dev, &dev_attr_busconnected_1);
+ device_remove_file(dev, &dev_attr_busconnected_2);
+ #else
+ ifx_proc_delproc("busconnected");
+ device_remove_file(dev, &dev_attr_busconnected);
+ #endif
+
+ #ifdef __IS_DUAL__
+ ifx_proc_delproc("connectspeed_1");
+ ifx_proc_delproc("connectspeed_2");
+ device_remove_file(dev, &dev_attr_connectspeed_1);
+ device_remove_file(dev, &dev_attr_connectspeed_2);
+ #else
+ ifx_proc_delproc("connectspeed");
+ device_remove_file(dev, &dev_attr_connectspeed);
+ #endif
+ #endif
+
+ #ifdef __IS_DEVICE__
+ ifx_proc_delproc("devspeed");
+ device_remove_file(dev, &dev_attr_devspeed);
+ ifx_proc_delproc("enumspeed");
+ device_remove_file(dev, &dev_attr_enumspeed);
+ #endif
+
+ #ifdef __ENABLE_DUMP__
+ #ifdef __IS_HOST__
+ #ifdef __IS_DUAL__
+ ifx_proc_delproc("dump_reg_1");
+ ifx_proc_delproc("dump_reg_2");
+ device_remove_file(dev, &dev_attr_dump_reg_h_1);
+ device_remove_file(dev, &dev_attr_dump_reg_h_2);
+ #else
+ ifx_proc_delproc("dump_reg");
+ device_remove_file(dev, &dev_attr_dump_reg_h);
+ #endif
+
+ #ifdef __IS_DUAL__
+ ifx_proc_delproc("dump_spram_1");
+ ifx_proc_delproc("dump_spram_2");
+ device_remove_file(dev, &dev_attr_dump_spram_h_1);
+ device_remove_file(dev, &dev_attr_dump_spram_h_2);
+ #else
+ ifx_proc_delproc("dump_spram");
+ device_remove_file(dev, &dev_attr_dump_spram_h);
+ #endif
+
+ #ifdef __IS_DUAL__
+ ifx_proc_delproc("dump_host_state_1");
+ ifx_proc_delproc("dump_host_state_2");
+ device_remove_file(dev, &dev_attr_dump_host_state_1);
+ device_remove_file(dev, &dev_attr_dump_host_state_2);
+ #else
+ ifx_proc_delproc("dump_host_state");
+ device_remove_file(dev, &dev_attr_dump_host_state);
+ #endif
+ #else
+ ifx_proc_delproc("dump_reg");
+ device_remove_file(dev, &dev_attr_dump_reg_d);
+ ifx_proc_delproc("dump_spram");
+ device_remove_file(dev, &dev_attr_dump_spram_d);
+ #endif
+
+ #ifdef __IS_HOST__
+ #endif
+ #endif //__ENABLE_DUMP__
+#ifdef __IS_HOST__
+ #ifdef __IS_DUAL__
+ ifx_proc_delproc("suspend_host_1");
+ ifx_proc_delproc("probe_host_1");
+ device_remove_file(dev, &dev_attr_suspend_host_1);
+ device_remove_file(dev, &dev_attr_probe_host_1);
+ ifx_proc_delproc("suspend_host_2");
+ ifx_proc_delproc("probe_host_2");
+ device_remove_file(dev, &dev_attr_suspend_host_2);
+ device_remove_file(dev, &dev_attr_probe_host_2);
+ ifx_proc_delproc("probe_timer1");
+ ifx_proc_delproc("autoprobe_timer1");
+ device_remove_file(dev, &dev_attr_probe_timer1_val_h);
+ device_remove_file(dev, &dev_attr_autoprobe_timer1_val_h);
+ ifx_proc_delproc("probe_timer2");
+ ifx_proc_delproc("autoprobe_timer2");
+ device_remove_file(dev, &dev_attr_probe_timer2_val_h);
+ device_remove_file(dev, &dev_attr_autoprobe_timer2_val_h);
+ #else
+ ifx_proc_delproc("suspend_host");
+ ifx_proc_delproc("probe_host");
+ device_remove_file(dev, &dev_attr_suspend_host);
+ device_remove_file(dev, &dev_attr_probe_host);
+ ifx_proc_delproc("probe_timer");
+ ifx_proc_delproc("autoprobe_timer");
+ device_remove_file(dev, &dev_attr_probe_timer_val_h);
+ device_remove_file(dev, &dev_attr_autoprobe_timer_val_h);
+ #endif
+ remove_proc_entry(ifxusb_hcd_driver_name, (void *)0);
+#endif
+
+#ifdef __IS_DEVICE__
+ ifx_proc_delproc("suspend_device");
+ ifx_proc_delproc("probe_device");
+ device_remove_file(dev, &dev_attr_suspend_device);
+ device_remove_file(dev, &dev_attr_probe_device);
+ ifx_proc_delproc("probe_timer");
+ ifx_proc_delproc("autoprobe_timer");
+ device_remove_file(dev, &dev_attr_probe_timer_val_d);
+ device_remove_file(dev, &dev_attr_autoprobe_timer_val_d);
+ remove_proc_entry(ifxusb_pcd_driver_name, (void *)0);
+#endif
+#if defined(__IS_HOST__) && defined(__HOST_COC__)
+ #ifdef __IS_DUAL__
+ ifx_pmcu_unregister ( &pmcuRegisterUSBHost_1 );
+ ifx_pmcu_unregister ( &pmcuRegisterUSBHost_2 );
+ #else
+ ifx_pmcu_unregister ( &pmcuRegisterUSBHost );
+ #endif
+#endif
+#if defined(__IS_DEVICE__) && defined(__GADGET_COC__)
+ ifx_pmcu_unregister ( &pmcuRegisterUSBGadget );
+#endif
+
+}
+
+static struct proc_dir_entry * proc_ifx_root = NULL;
+
+/* initialize the proc file system and make a dir named /proc/[name] */
+static void ifx_proc_init(void)
+{
+ IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
+#ifdef __IS_HOST__
+ proc_ifx_root = proc_mkdir(ifxusb_hcd_driver_name, (void *)0);
+ if (!proc_ifx_root){
+ IFX_PRINT("%s proc initialization failed! \n", ifxusb_hcd_driver_name);
+ return;
+ }
+#else
+ proc_ifx_root = proc_mkdir(ifxusb_pcd_driver_name, (void *)0);
+ if (!proc_ifx_root){
+ IFX_PRINT("%s proc initialization failed! \n", ifxusb_pcd_driver_name);
+ return;
+ }
+#endif
+}
+
+/* proc file system add function for debugging. */
+static int ifx_proc_addproc(char *funcname, read_proc_t *hookfuncr, write_proc_t *hookfuncw)
+{
+ struct proc_dir_entry *pe;
+ IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
+ if (!proc_ifx_root)
+ ifx_proc_init();
+
+ if (hookfuncw == NULL)
+ {
+ pe = create_proc_read_entry(funcname, S_IRUGO, proc_ifx_root, hookfuncr, NULL);
+ if (!pe)
+ {
+ IFX_PRINT("ERROR in creating read proc entry (%s)! \n", funcname);
+ return -1;
+ }
+ }
+ else
+ {
+ pe = create_proc_entry(funcname, S_IRUGO | S_IWUGO, proc_ifx_root);
+ if (pe)
+ {
+ pe->read_proc = hookfuncr;
+ pe->write_proc = hookfuncw;
+ }
+ else
+ {
+ IFX_PRINT("ERROR in creating proc entry (%s)! \n", funcname);
+ return -1;
+ }
+ }
+ return 0;
+}
+
+
+/* proc file system del function for removing module. */
+static void ifx_proc_delproc(char *funcname)
+{
+ char pname[30];
+ IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
+ sprintf(pname, "%s", funcname);
+
+ remove_proc_entry(pname, proc_ifx_root);
+
+}
+
+static void ifxusb_dump_params(ifxusb_core_if_t *_core_if)
+{
+ ifxusb_params_t *params=&_core_if->params;
+
+ #ifdef __IS_HOST__
+ IFX_PRINT("IFXUSB Dump Parameters ( Host Mode) \n");
+ #endif //__IS_HOST__
+ #ifdef __IS_DEVICE__
+ IFX_PRINT("IFXUSB Dump Parameters ( Device Mode) \n");
+ #endif //__IS_DEVICE__
+
+ #ifdef __DESC_DMA__
+ IFX_PRINT("DMA: Hermes DMA\n");
+ #else
+ IFX_PRINT("DMA: Non-Desc DMA\n");
+ #endif
+ IFX_PRINT(" Burst size: %d\n",params->dma_burst_size);
+
+ if (params->speed==1)
+ IFX_PRINT("Full Speed only\n");
+ else if(params->speed==0)
+ IFX_PRINT("Full/Hign Speed\n");
+ else
+ IFX_PRINT("Unkonwn setting (%d) for Speed\n",params->speed);
+
+ IFX_PRINT("Total Data FIFO size: %d(0x%06X) DWord, %d(0x%06X) Bytes\n",
+ params->data_fifo_size,params->data_fifo_size,
+ params->data_fifo_size*4, params->data_fifo_size*4
+ );
+
+ #ifdef __IS_DEVICE__
+ IFX_PRINT("Rx FIFO size: %d(0x%06X) DWord, %d(0x%06X) Bytes\n",
+ params->rx_fifo_size,params->rx_fifo_size,
+ params->rx_fifo_size*4, params->rx_fifo_size*4
+ );
+ {
+ int i;
+ for(i=0;i<MAX_EPS_CHANNELS;i++)
+ {
+ IFX_PRINT("Tx FIFO #%d size: %d(0x%06X) DWord, %d(0x%06X) Bytes\n",i,
+ params->tx_fifo_size[i],params->tx_fifo_size[i],
+ params->tx_fifo_size[i]*4, params->tx_fifo_size[i]*4
+ );
+ }
+ }
+ #ifdef __DED_FIFO__
+ IFX_PRINT("Treshold : %s Rx:%d Tx:%d \n",
+ (params->thr_ctl)?"On":"Off",params->tx_thr_length,params->rx_thr_length);
+ #endif
+ #else //__IS_HOST__
+ IFX_PRINT("Host Channels: %d\n",params->host_channels);
+
+ IFX_PRINT("Rx FIFO size: %d(0x%06X) DWord, %d(0x%06X) Bytes\n",
+ params->data_fifo_size,params->data_fifo_size,
+ params->data_fifo_size*4, params->data_fifo_size*4
+ );
+
+ IFX_PRINT("NP Tx FIFO size: %d(0x%06X) DWord, %d(0x%06X) Bytes\n",
+ params->nperio_tx_fifo_size,params->nperio_tx_fifo_size,
+ params->nperio_tx_fifo_size*4, params->nperio_tx_fifo_size*4
+ );
+
+ IFX_PRINT(" P Tx FIFO size: %d(0x%06X) DWord, %d(0x%06X) Bytes\n",
+ params->perio_tx_fifo_size,params->perio_tx_fifo_size,
+ params->perio_tx_fifo_size*4, params->perio_tx_fifo_size*4
+ );
+ #endif //__IS_HOST__
+
+ IFX_PRINT("Max Transfer size: %d(0x%06X) Bytes\n",
+ params->max_transfer_size,params->max_transfer_size
+ );
+ IFX_PRINT("Max Packet Count: %d(0x%06X)\n",
+ params->max_packet_count,params->max_packet_count
+ );
+
+ IFX_PRINT("PHY UTMI Width: %d\n",params->phy_utmi_width);
+
+ IFX_PRINT("Turn Around Time: HS:%d FS:%d\n",params->turn_around_time_hs,params->turn_around_time_fs);
+ IFX_PRINT("Timeout Calibration: HS:%d FS:%d\n",params->timeout_cal_hs,params->timeout_cal_fs);
+
+
+ IFX_PRINT("==================================================\n");
+ IFX_PRINT("End of Parameters Dump\n");
+ IFX_PRINT("==================================================\n");
+}
+
diff --git a/package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxusb_driver.c.svn-base b/package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxusb_driver.c.svn-base
new file mode 100644
index 0000000..04346b9
--- /dev/null
+++ b/package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxusb_driver.c.svn-base
@@ -0,0 +1,1286 @@
+/*****************************************************************************
+ ** FILE NAME : ifxusb_driver.c
+ ** PROJECT : IFX USB sub-system V3
+ ** MODULES : IFX USB sub-system Host and Device driver
+ ** SRC VERSION : 3.2
+ ** DATE : 1/Jan/2011
+ ** AUTHOR : Chen, Howard
+ ** DESCRIPTION : The provides the initialization and cleanup entry
+ ** points for the IFX USB driver. This module can be
+ ** dynamically loaded with insmod command or built-in
+ ** with kernel. When loaded or executed the ifxusb_driver_init
+ ** function is called. When the module is removed (using rmmod),
+ ** the ifxusb_driver_cleanup function is called.
+ ** FUNCTIONS :
+ ** COMPILER : gcc
+ ** REFERENCE : Synopsys DWC-OTG Driver 2.7
+ ** COPYRIGHT : Copyright (c) 2010
+ ** LANTIQ DEUTSCHLAND GMBH,
+ ** Am Campeon 3, 85579 Neubiberg, Germany
+ **
+ ** 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 of the License, or
+ ** (at your option) any later version.
+ **
+ ** Version Control Section **
+ ** $Author$
+ ** $Date$
+ ** $Revisions$
+ ** $Log$ Revision history
+ *****************************************************************************/
+
+/*
+ * This file contains code fragments from Synopsys HS OTG Linux Software Driver.
+ * For this code the following notice is applicable:
+ *
+ * ==========================================================================
+ *
+ * Synopsys HS OTG Linux Software Driver and documentation (hereinafter,
+ * "Software") is an Unsupported proprietary work of Synopsys, Inc. unless
+ * otherwise expressly agreed to in writing between Synopsys and you.
+ *
+ * The Software IS NOT an item of Licensed Software or Licensed Product under
+ * any End User Software License Agreement or Agreement for Licensed Product
+ * with Synopsys or any supplement thereto. You are permitted to use and
+ * redistribute this Software in source and binary forms, with or without
+ * modification, provided that redistributions of source code must retain this
+ * notice. You may not view, use, disclose, copy or distribute this file or
+ * any information contained herein except pursuant to this license grant from
+ * Synopsys. If you do not agree with this notice, including the disclaimer
+ * below, then you are not authorized to use the Software.
+ *
+ * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" BASIS
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ * ========================================================================== */
+
+/*!
+ \file ifxusb_driver.c
+ \brief This file contains the loading/unloading interface to the Linux driver.
+*/
+
+#include <linux/version.h>
+#include "ifxusb_version.h"
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/init.h>
+
+#include <linux/device.h>
+#include <linux/of_platform.h>
+#include <linux/of_gpio.h>
+
+#include <linux/errno.h>
+#include <linux/types.h>
+#include <linux/stat.h> /* permission constants */
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ #include <linux/irq.h>
+#endif
+
+#include <asm/io.h>
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
+ #include <asm/irq.h>
+#endif
+
+#include "ifxusb_plat.h"
+
+#include "ifxusb_cif.h"
+
+#ifdef __IS_HOST__
+ #include "ifxhcd.h"
+
+ #define USB_DRIVER_DESC "IFX USB HCD driver"
+ const char ifxusb_hcd_driver_name[] = "ifxusb_hcd";
+ #ifdef __IS_DUAL__
+ ifxhcd_hcd_t ifxusb_hcd_1;
+ ifxhcd_hcd_t ifxusb_hcd_2;
+ const char ifxusb_hcd_name_1[] = "ifxusb_hcd_1";
+ const char ifxusb_hcd_name_2[] = "ifxusb_hcd_2";
+ #else
+ ifxhcd_hcd_t ifxusb_hcd;
+ const char ifxusb_hcd_name[] = "ifxusb_hcd";
+ #endif
+
+ #if defined(__DO_OC_INT__)
+ ifxhcd_hcd_t *oc_int_id=NULL;
+ #ifdef __IS_DUAL__
+ ifxhcd_hcd_t *oc_int_id_1=NULL;
+ ifxhcd_hcd_t *oc_int_id_2=NULL;
+ #endif
+ #endif
+#endif
+
+#ifdef __IS_DEVICE__
+ #include "ifxpcd.h"
+
+ #define USB_DRIVER_DESC "IFX USB PCD driver"
+ const char ifxusb_pcd_driver_name[] = "ifxusb_pcd";
+ ifxpcd_pcd_t ifxusb_pcd;
+ const char ifxusb_pcd_name[] = "ifxusb_pcd";
+#endif
+
+/* Global Debug Level Mask. */
+#ifdef __IS_HOST__
+ uint32_t h_dbg_lvl = 0xff;
+#endif
+
+#ifdef __IS_DEVICE__
+ uint32_t d_dbg_lvl = 0x00;
+#endif
+
+#ifdef __IS_HOST__
+ifxusb_params_t ifxusb_module_params_h;
+#else
+ifxusb_params_t ifxusb_module_params_d;
+#endif
+
+static void parse_parms(void);
+
+
+#if defined(__IS_TWINPASS__)
+#warning "Compiled as TWINPASS"
+#elif defined(__IS_DANUBE__)
+#warning "Compiled as DANUBE"
+#elif defined(__IS_AMAZON_SE__)
+#warning "Compiled as AMAZON_SE"
+#elif defined(__IS_AR9__)
+#warning "Compiled as AR9"
+#elif defined(__IS_VR9__)
+#warning "Compiled as VR9"
+#elif defined(__IS_AR10__)
+#warning "Compiled as AR10"
+#else
+#error "No Platform defined"
+#endif
+
+
+/* Function to setup the structures to control one usb core running as host*/
+#ifdef __IS_HOST__
+/*!
+ \brief inlined by ifxusb_driver_probe(), handling host mode probing. Run at each host core.
+*/
+ static inline int ifxusb_driver_probe_h(ifxhcd_hcd_t *_hcd,
+ int _irq,
+ uint32_t _iobase,
+ uint32_t _fifomem,
+ uint32_t _fifodbg
+ )
+ {
+ int retval = 0;
+
+ IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
+
+ ifxusb_power_on_h (&_hcd->core_if);
+ mdelay(50);
+ ifxusb_phy_power_on_h (&_hcd->core_if); // Test
+ mdelay(50);
+ ifxusb_hard_reset_h(&_hcd->core_if);
+ retval =ifxusb_core_if_init_h(&_hcd->core_if,
+ _irq,
+ _iobase,
+ _fifomem,
+ _fifodbg);
+ if(retval)
+ return retval;
+
+ ifxusb_host_core_init(&_hcd->core_if,&ifxusb_module_params_h);
+
+ ifxusb_disable_global_interrupts_h( &_hcd->core_if);
+
+ /* The driver is now initialized and need to be registered into Linux USB sub-system */
+
+ retval = ifxhcd_init(_hcd); // hook the hcd into usb ss
+
+ if (retval != 0)
+ {
+ IFX_ERROR("_hcd_init failed\n");
+ return retval;
+ }
+
+ //ifxusb_enable_global_interrupts_h( _hcd->core_if ); // this should be done at hcd_start , including hcd_interrupt
+ return 0;
+ }
+#endif //__IS_HOST__
+
+#ifdef __IS_DEVICE__
+/*!
+ \brief inlined by ifxusb_driver_probe(), handling device mode probing.
+*/
+ static inline int ifxusb_driver_probe_d(ifxpcd_pcd_t *_pcd,
+ int _irq,
+ uint32_t _iobase,
+ uint32_t _fifomem,
+ uint32_t _fifodbg
+ )
+ {
+ int retval = 0;
+
+ IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
+ ifxusb_power_on_d (&_pcd->core_if);
+ mdelay(50);
+ ifxusb_phy_power_on_d (&_pcd->core_if); // Test
+ mdelay(50);
+ ifxusb_hard_reset_d(&_pcd->core_if);
+ retval =ifxusb_core_if_init_d(&_pcd->core_if,
+ _irq,
+ _iobase,
+ _fifomem,
+ _fifodbg);
+ if(retval)
+ return retval;
+
+ IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
+ ifxusb_dev_core_init(&_pcd->core_if,&ifxusb_module_params_d);
+
+ IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
+ ifxusb_disable_global_interrupts_d( &_pcd->core_if);
+
+ /* The driver is now initialized and need to be registered into
+ Linux USB Gadget sub-system
+ */
+ retval = ifxpcd_init();
+ IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
+
+ if (retval != 0)
+ {
+ IFX_ERROR("_pcd_init failed\n");
+ return retval;
+ }
+ //ifxusb_enable_global_interrupts_d( _pcd->core_if ); // this should be done at gadget bind or start
+ return 0;
+ }
+#endif //__IS_DEVICE__
+
+/*!
+ \brief This function is called when a driver is unregistered. This happens when
+ the rmmod command is executed. The device may or may not be electrically
+ present. If it is present, the driver stops device processing. Any resources
+ used on behalf of this device are freed.
+*/
+static int ifxusb_driver_remove(struct platform_device *_pdev)
+{
+ IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
+ #ifdef __IS_HOST__
+ #if defined(__IS_DUAL__)
+ ifxhcd_remove(&ifxusb_hcd_1);
+ ifxusb_core_if_remove_h(&ifxusb_hcd_1.core_if );
+ ifxhcd_remove(&ifxusb_hcd_2);
+ ifxusb_core_if_remove_h(&ifxusb_hcd_2.core_if );
+ #else
+ ifxhcd_remove(&ifxusb_hcd);
+ ifxusb_core_if_remove_h(&ifxusb_hcd.core_if );
+ #endif
+ #endif
+ #ifdef __IS_DEVICE__
+ ifxpcd_remove();
+ ifxusb_core_if_remove_d(&ifxusb_pcd.core_if );
+ #endif
+ /* Remove the device attributes */
+ #ifdef __IS_HOST__
+ ifxusb_attr_remove_h(&_pdev->dev);
+ #else
+ ifxusb_attr_remove_d(&_pdev->dev);
+ #endif
+ return 0;
+}
+
+/*!
+ \brief This function is called by module management in 2.6 kernel or by ifxusb_driver_init with 2.4 kernel
+ It is to probe and setup IFXUSB core(s).
+*/
+static int ifxusb_driver_probe(struct platform_device *_pdev)
+{
+ int retval = 0;
+ struct device_node *np;
+ int gpio_count;
+ u32 port_mask = 0x1;
+
+#ifdef __IS_DANUBE__
+ np = of_find_compatible_node(NULL, NULL, "lantiq,ifxhcd-danube");
+#elif defined __IS_AMAZON_SE__
+ np = of_find_compatible_node(NULL, NULL, "lantiq,ifxhcd-ase");
+#elif defined __IS_AR9__
+ np = of_find_compatible_node(NULL, NULL, "lantiq,ifxhcd-arx100");
+#elif defined __IS_VR9__
+ np = of_find_compatible_node(NULL, NULL, "lantiq,ifxhcd-xrx200");
+#elif defined __IS_AR10__
+ np = of_find_compatible_node(NULL, NULL, "lantiq,ifxhcd-arx300");
+#endif
+ if (!np) {
+ dev_err(&_pdev->dev, "failed to find hcd device node\n");
+ return -ENODEV;
+ }
+ of_property_read_u32(np, "lantiq,portmask", &port_mask);
+ // Parsing and store the parameters
+ IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
+ parse_parms();
+
+ #ifdef __IS_HOST__
+ #if defined(__DO_OC_INT__)
+ if(!oc_int_id)
+ {
+ #if defined(__IS_DUAL__)
+ oc_int_id=&ifxusb_hcd_1;
+ oc_int_id_1=&ifxusb_hcd_1;
+ oc_int_id_2=&ifxusb_hcd_2;
+ #else
+ oc_int_id=&ifxusb_hcd;
+ #endif
+ }
+ #endif
+
+ #if defined(__IS_DUAL__)
+ memset(&ifxusb_hcd_1, 0, sizeof(ifxhcd_hcd_t));
+ memset(&ifxusb_hcd_2, 0, sizeof(ifxhcd_hcd_t));
+
+ ifxusb_hcd_1.core_if.core_no=0;
+ ifxusb_hcd_2.core_if.core_no=1;
+ ifxusb_hcd_1.core_if.core_name=(char *)ifxusb_hcd_name_1;
+ ifxusb_hcd_2.core_if.core_name=(char *)ifxusb_hcd_name_2;
+
+ ifxusb_hcd_1.dev=&_pdev->dev;
+ ifxusb_hcd_2.dev=&_pdev->dev;
+
+ if (port_mask & 0x1) {
+ retval = ifxusb_driver_probe_h(&ifxusb_hcd_1,
+ IFXUSB1_IRQ,
+ IFXUSB1_IOMEM_BASE,
+ IFXUSB1_FIFOMEM_BASE,
+ IFXUSB1_FIFODBG_BASE
+ );
+ if(retval)
+ goto ifxusb_driver_probe_fail;
+ }
+
+ if (port_mask & 0x2) {
+ retval = ifxusb_driver_probe_h(&ifxusb_hcd_2,
+ IFXUSB2_IRQ,
+ IFXUSB2_IOMEM_BASE,
+ IFXUSB2_FIFOMEM_BASE,
+ IFXUSB2_FIFODBG_BASE
+ );
+ if(retval)
+ goto ifxusb_driver_probe_fail;
+ }
+ #elif defined(__IS_FIRST__)
+ memset(&ifxusb_hcd, 0, sizeof(ifxhcd_hcd_t));
+
+ ifxusb_hcd.core_if.core_no=0;
+ ifxusb_hcd.core_if.core_name=(char *)ifxusb_hcd_name;
+
+ ifxusb_hcd.dev=&_pdev->dev;
+
+ retval = ifxusb_driver_probe_h(&ifxusb_hcd,
+ IFXUSB1_IRQ,
+ IFXUSB1_IOMEM_BASE,
+ IFXUSB1_FIFOMEM_BASE,
+ IFXUSB1_FIFODBG_BASE
+ );
+ if(retval)
+ goto ifxusb_driver_probe_fail;
+
+ #elif defined(__IS_SECOND__)
+ memset(&ifxusb_hcd, 0, sizeof(ifxhcd_hcd_t));
+
+ ifxusb_hcd.core_if.core_no=1;
+ ifxusb_hcd.core_if.core_name=(char *)ifxusb_hcd_name;
+
+ ifxusb_hcd.dev=&_pdev->dev;
+
+ retval = ifxusb_driver_probe_h(&ifxusb_hcd,
+ IFXUSB2_IRQ,
+ IFXUSB2_IOMEM_BASE,
+ IFXUSB2_FIFOMEM_BASE,
+ IFXUSB2_FIFODBG_BASE
+ );
+ if(retval)
+ goto ifxusb_driver_probe_fail;
+
+ #else
+ memset(&ifxusb_hcd, 0, sizeof(ifxhcd_hcd_t));
+
+ ifxusb_hcd.core_if.core_no=0;
+ ifxusb_hcd.core_if.core_name=(char *)ifxusb_hcd_name;
+
+ ifxusb_hcd.dev=&_pdev->dev;
+
+ retval = ifxusb_driver_probe_h(&ifxusb_hcd,
+ IFXUSB_IRQ,
+ IFXUSB_IOMEM_BASE,
+ IFXUSB_FIFOMEM_BASE,
+ IFXUSB_FIFODBG_BASE
+ );
+ if(retval)
+ goto ifxusb_driver_probe_fail;
+ #endif
+ #endif
+
+ #ifdef __IS_DEVICE__
+ memset(&ifxusb_pcd, 0, sizeof(ifxpcd_pcd_t));
+ ifxusb_pcd.core_if.core_name=(char *)&ifxusb_pcd_name[0];
+
+ ifxusb_pcd.dev=&_pdev->dev;
+
+ #if defined(__IS_FIRST__)
+ ifxusb_pcd.core_if.core_no=0;
+ retval = ifxusb_driver_probe_d(&ifxusb_pcd,
+ IFXUSB1_IRQ,
+ IFXUSB1_IOMEM_BASE,
+ IFXUSB1_FIFOMEM_BASE,
+ IFXUSB1_FIFODBG_BASE
+ );
+ #elif defined(__IS_SECOND__)
+ ifxusb_pcd.core_if.core_no=1;
+ retval = ifxusb_driver_probe_d(&ifxusb_pcd,
+ IFXUSB2_IRQ,
+ IFXUSB2_IOMEM_BASE,
+ IFXUSB2_FIFOMEM_BASE,
+ IFXUSB2_FIFODBG_BASE
+ );
+ #else
+ ifxusb_pcd.core_if.core_no=0;
+ retval = ifxusb_driver_probe_d(&ifxusb_pcd,
+ IFXUSB_IRQ,
+ IFXUSB_IOMEM_BASE,
+ IFXUSB_FIFOMEM_BASE,
+ IFXUSB_FIFODBG_BASE
+ );
+ #endif
+ if(retval)
+ goto ifxusb_driver_probe_fail;
+ #endif
+
+ #ifdef __IS_HOST__
+ ifxusb_attr_create_h(&_pdev->dev);
+ #else
+ ifxusb_attr_create_d(&_pdev->dev);
+ #endif
+
+ gpio_count = of_gpio_count(np);
+ while (gpio_count) {
+ enum of_gpio_flags flags;
+ int gpio = of_get_gpio_flags(np, --gpio_count, &flags);
+ if (gpio_request(gpio, "usb"))
+ continue;
+ dev_info(&_pdev->dev, "requested GPIO %d\n", gpio);
+ gpio_direction_output(gpio, (flags & OF_GPIO_ACTIVE_LOW) ? (0) : (1));
+ }
+
+
+ return 0;
+
+ifxusb_driver_probe_fail:
+ ifxusb_driver_remove(_pdev);
+ return retval;
+}
+
+static struct resource ifxusb_device_resources[] =
+{
+ #if defined(__IS_DUAL__)
+ [0] = { .start = IFXUSB1_IRQ,
+ .flags = IORESOURCE_IRQ,
+ },
+ [1] = { .start = IFXUSB1_IOMEM_BASE,
+ .end = IFXUSB1_IOMEM_BASE + IFXUSB_IOMEM_SIZE-1,
+ .flags = IORESOURCE_MEM,
+ },
+ [2] = { .start = IFXUSB2_IRQ,
+ .flags = IORESOURCE_IRQ,
+ },
+ [3] = { .start = IFXUSB2_IOMEM_BASE,
+ .end = IFXUSB2_IOMEM_BASE + IFXUSB_IOMEM_SIZE-1,
+ .flags = IORESOURCE_MEM,
+ },
+ [4] = { .start = IFXUSB1_FIFOMEM_BASE,
+ .end = IFXUSB1_FIFOMEM_BASE + IFXUSB_FIFOMEM_SIZE-1,
+ .flags = IORESOURCE_MEM,
+ },
+ [5] = { .start = IFXUSB2_FIFOMEM_BASE,
+ .end = IFXUSB2_FIFOMEM_BASE + IFXUSB_FIFOMEM_SIZE-1,
+ .flags = IORESOURCE_MEM,
+ },
+ [6] = { .start = IFXUSB1_FIFODBG_BASE,
+ .end = IFXUSB1_FIFODBG_BASE + IFXUSB_FIFODBG_SIZE-1,
+ .flags = IORESOURCE_MEM,
+ },
+ [7] = { .start = IFXUSB2_FIFODBG_BASE,
+ .end = IFXUSB2_FIFODBG_BASE + IFXUSB_FIFODBG_SIZE-1,
+ .flags = IORESOURCE_MEM,
+ },
+ #elif defined(__IS_FIRST__)
+ [0] = { .start = IFXUSB1_IRQ,
+ .flags = IORESOURCE_IRQ,
+ },
+ [1] = { .start = IFXUSB1_IOMEM_BASE,
+ .end = IFXUSB1_IOMEM_BASE + IFXUSB_IOMEM_SIZE-1,
+ .flags = IORESOURCE_MEM,
+ },
+ [2] = { .start = IFXUSB1_FIFOMEM_BASE,
+ .end = IFXUSB1_FIFOMEM_BASE + IFXUSB_FIFOMEM_SIZE-1,
+ .flags = IORESOURCE_MEM,
+ },
+ [3] = { .start = IFXUSB1_FIFODBG_BASE,
+ .end = IFXUSB1_FIFODBG_BASE + IFXUSB_FIFODBG_SIZE-1,
+ .flags = IORESOURCE_MEM,
+ },
+ #elif defined(__IS_SECOND__)
+ [0] = { .start = IFXUSB2_IRQ,
+ .flags = IORESOURCE_IRQ,
+ },
+ [1] = { .start = IFXUSB2_IOMEM_BASE,
+ .end = IFXUSB2_IOMEM_BASE + IFXUSB_IOMEM_SIZE-1,
+ .flags = IORESOURCE_MEM,
+ },
+ [2] = { .start = IFXUSB2_FIFOMEM_BASE,
+ .end = IFXUSB2_FIFOMEM_BASE + IFXUSB_FIFOMEM_SIZE-1,
+ .flags = IORESOURCE_MEM,
+ },
+ [3] = { .start = IFXUSB2_FIFODBG_BASE,
+ .end = IFXUSB2_FIFODBG_BASE + IFXUSB_FIFODBG_SIZE-1,
+ .flags = IORESOURCE_MEM,
+ },
+ #else
+ [0] = { .start = IFXUSB_IRQ,
+ .flags = IORESOURCE_IRQ,
+ },
+ [1] = { .start = IFXUSB_IOMEM_BASE,
+ .end = IFXUSB_IOMEM_BASE + IFXUSB_IOMEM_SIZE-1,
+ .flags = IORESOURCE_MEM,
+ },
+ [2] = { .start = IFXUSB_FIFOMEM_BASE,
+ .end = IFXUSB_FIFOMEM_BASE+IFXUSB_FIFOMEM_SIZE-1,
+ .flags = IORESOURCE_MEM,
+ },
+ [3] = { .start = IFXUSB_FIFODBG_BASE,
+ .end = IFXUSB_FIFODBG_BASE+IFXUSB_FIFODBG_SIZE-1,
+ .flags = IORESOURCE_MEM,
+ },
+ #endif //__IS_DUAL__
+};
+
+static u64 ifxusb_dmamask = (u32)0x1fffffff;
+
+static void ifxusb_device_release(struct device * dev)
+{
+ IFX_PRINT("IFX USB platform_dev release\n");
+ dev->parent = NULL;
+}
+
+static struct platform_device ifxusb_device =
+{
+ .id = -1,
+ .dev =
+ {
+ .release = ifxusb_device_release,
+ .dma_mask = &ifxusb_dmamask,
+ },
+ .resource = ifxusb_device_resources,
+ .num_resources = ARRAY_SIZE(ifxusb_device_resources),
+};
+
+
+/*!
+ \brief This function is called when the ifxusb_driver is installed with the insmod command.
+*/
+static struct platform_driver ifxusb_driver = {
+ .probe = ifxusb_driver_probe,
+ .remove = ifxusb_driver_remove,
+ .driver ={
+ .owner = THIS_MODULE,
+ #ifdef __IS_HOST__
+ .name = ifxusb_hcd_driver_name,
+ #else
+ .name = ifxusb_pcd_driver_name,
+ #endif
+ },
+};
+
+#ifdef __IS_HOST__
+ int __init ifxusb_hcd_driver_init(void)
+#else
+ int __init ifxusb_pcd_driver_init(void)
+#endif
+{
+ int retval = 0;
+ IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
+ #if defined(__IS_HOST__)
+ IFX_PRINT("%s: version %s\n", ifxusb_hcd_driver_name, IFXUSB_VERSION);
+ #else
+ IFX_PRINT("%s: version %s\n", ifxusb_pcd_driver_name, IFXUSB_VERSION);
+ #endif
+
+ #if 0
+ #if defined(__IS_TWINPASS__)
+ IFX_PRINT(" OPTION: __IS_TWINPASS__\n");
+ #elif defined(__IS_DANUBE__)
+ IFX_PRINT(" OPTION: __IS_DANUBE__\n");
+ #elif defined(__IS_AMAZON_SE__)
+ IFX_PRINT(" OPTION: __IS_AMAZON_SE__\n");
+ #elif defined(__IS_AR9__)
+ IFX_PRINT(" OPTION: __IS_AR9__\n");
+ #elif defined(__IS_VR9__)
+ IFX_PRINT(" OPTION: __IS_VR9__\n");
+ #elif defined(__IS_AR10__)
+ IFX_PRINT(" OPTION: __IS_AR10__\n");
+ #else
+ IFX_PRINT(" OPTION: NO PLATFORM DEFINED\n");
+ #endif
+
+ #ifdef __UEIP__
+ IFX_PRINT(" OPTION: __UEIP__\n");
+ #endif
+
+ #ifdef __PHY_LONG_PREEMP__
+ IFX_PRINT(" OPTION: __PHY_LONG_PREEMP__\n");
+ #endif
+ #ifdef __FORCE_USB11__
+ IFX_PRINT(" OPTION: __FORCE_USB11__\n");
+ #endif
+ #ifdef __UNALIGNED_BUF_ADJ__
+ IFX_PRINT(" OPTION: __UNALIGNED_BUF_ADJ__\n");
+ #endif
+ #ifdef __UNALIGNED_BUF_CHK__
+ IFX_PRINT(" OPTION: __UNALIGNED_BUF_CHK__\n");
+ #endif
+ #ifdef __UNALIGNED_BUF_BURST__
+ IFX_PRINT(" OPTION: __UNALIGNED_BUF_BURST__\n");
+ #endif
+ #ifdef __DEBUG__
+ IFX_PRINT(" OPTION: __DEBUG__\n");
+ #endif
+ #ifdef __ENABLE_DUMP__
+ IFX_PRINT(" OPTION: __ENABLE_DUMP__\n");
+ #endif
+
+ #ifdef __IS_HOST__
+ IFX_PRINT(" OPTION: __IS_HOST__\n");
+ #ifdef __IS_DUAL__
+ IFX_PRINT(" __IS_DUAL__\n");
+ #endif
+ #ifdef __IS_FIRST__
+ IFX_PRINT(" __IS_FIRST__\n");
+ #endif
+ #ifdef __IS_SECOND__
+ IFX_PRINT(" __IS_SECOND__\n");
+ #endif
+ #ifdef __WITH_HS_ELECT_TST__
+ IFX_PRINT(" __WITH_HS_ELECT_TST__\n");
+ #endif
+ #ifdef __EN_ISOC__
+ IFX_PRINT(" __EN_ISOC__\n");
+ #endif
+ #ifdef __EN_ISOC_SPLIT__
+ IFX_PRINT(" __EN_ISOC_SPLIT__\n");
+ #endif
+ #ifdef __EPQD_DESTROY_TIMEOUT__
+ IFX_PRINT(" __EPQD_DESTROY_TIMEOUT__\n");
+ #endif
+ #ifdef __DYN_SOF_INTR__
+ IFX_PRINT(" __DYN_SOF_INTR__\n");
+ #endif
+ #else
+ IFX_PRINT(" OPTION: __IS_DEVICE__\n");
+ #ifdef __DED_INTR__
+ IFX_PRINT(" __DED_INTR__\n");
+ #endif
+ #ifdef __DED_FIFO__
+ IFX_PRINT(" __DED_FIFO__\n");
+ #endif
+ #ifdef __DESC_DMA__
+ IFX_PRINT(" __DESC_DMA__\n");
+ #endif
+ #ifdef __IS_FIRST__
+ IFX_PRINT(" __IS_FIRST__\n");
+ #endif
+ #ifdef __IS_SECOND__
+ IFX_PRINT(" __IS_SECOND__\n");
+ #endif
+ #ifdef __GADGET_TASKLET_TX__
+ IFX_PRINT(" __GADGET_TASKLET_TX__\n");
+ #endif
+ #ifdef __GADGET_TASKLET_RX__
+ IFX_PRINT(" __GADGET_TASKLET_RX__\n");
+ #endif
+ #ifdef __GADGET_TASKLET_HIGH__
+ IFX_PRINT(" __GADGET_TASKLET_HIGH__\n");
+ #endif
+ #ifdef __DO_PCD_UNLOCK__
+ IFX_PRINT(" __DO_PCD_UNLOCK__\n");
+ #endif
+ #ifdef __GADGET_LED__
+ IFX_PRINT(" __GADGET_LED__\n");
+ #endif
+
+ #ifdef __ECM_NO_INTR__
+ IFX_PRINT(" __ECM_NO_INTR__\n");
+ #endif
+ #ifdef __NOSWAPINCTRL__
+ IFX_PRINT(" __NOSWAPINCTRL__\n");
+ #endif
+ #ifdef __MAC_ECM_FIX__
+ IFX_PRINT(" __MAC_ECM_FIX__\n");
+ #endif
+ #ifdef __RETAIN_BUF_TX__
+ IFX_PRINT(" __RETAIN_BUF_TX__\n");
+ #endif
+ #ifdef __RETAIN_BUF_RX__
+ IFX_PRINT(" __RETAIN_BUF_RX__\n");
+ #endif
+ #ifdef __QUICKNAK__
+ IFX_PRINT(" __QUICKNAK__\n");
+ #endif
+ #endif
+ #endif
+
+ retval = platform_driver_register(&ifxusb_driver);
+
+ if (retval < 0) {
+ IFX_ERROR("%s retval=%d\n", __func__, retval);
+ return retval;
+ }
+
+ #ifdef __IS_HOST__
+ ifxusb_device.name = ifxusb_hcd_driver_name;
+ #else
+ ifxusb_device.name = ifxusb_pcd_driver_name;
+ #endif
+
+ if (ifxusb_device.dev.parent)
+ retval = -EBUSY;
+ else
+ retval = platform_device_register(&ifxusb_device);
+
+ if (retval < 0)
+ {
+ IFX_ERROR("%s retval=%d\n", __func__, retval);
+ platform_driver_unregister(&ifxusb_driver);
+ return retval;
+ }
+ return retval;
+}
+
+#ifdef __IS_HOST__
+ module_init(ifxusb_hcd_driver_init);
+#else
+ module_init(ifxusb_pcd_driver_init);
+#endif
+
+/*!
+ \brief This function is called when the driver is removed from the kernel
+ with the rmmod command. The driver unregisters itself with its bus
+ driver.
+*/
+#ifdef __IS_HOST__
+ void __exit ifxusb_hcd_driver_cleanup(void)
+ {
+ IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
+ platform_device_unregister(&ifxusb_device);
+ platform_driver_unregister(&ifxusb_driver);
+ IFX_PRINT("%s module removed\n", ifxusb_hcd_driver_name);
+ }
+ module_exit(ifxusb_hcd_driver_cleanup);
+#else
+ void __exit ifxusb_pcd_driver_cleanup(void)
+ {
+ IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
+ platform_device_unregister(&ifxusb_device);
+ platform_driver_unregister(&ifxusb_driver);
+ IFX_PRINT("%s module removed\n", ifxusb_pcd_driver_name);
+ }
+ module_exit(ifxusb_pcd_driver_cleanup);
+#endif
+MODULE_DESCRIPTION(USB_DRIVER_DESC);
+MODULE_AUTHOR("Lantiq");
+MODULE_LICENSE("GPL");
+
+
+
+// Parameters set when loaded
+//static long dbg_lvl =0xFFFFFFFF;
+static long dbg_lvl =0;
+static short dma_burst_size =-1;
+static short speed =-1;
+static long data_fifo_size =-1;
+#ifdef __IS_DEVICE__
+ static long rx_fifo_size =-1;
+ #ifdef __DED_FIFO__
+ static long tx_fifo_size_00 =-1;
+ static long tx_fifo_size_01 =-1;
+ static long tx_fifo_size_02 =-1;
+ static long tx_fifo_size_03 =-1;
+ static long tx_fifo_size_04 =-1;
+ static long tx_fifo_size_05 =-1;
+ static long tx_fifo_size_06 =-1;
+ static long tx_fifo_size_07 =-1;
+ static long tx_fifo_size_08 =-1;
+ static long tx_fifo_size_09 =-1;
+ static long tx_fifo_size_10 =-1;
+ static long tx_fifo_size_11 =-1;
+ static long tx_fifo_size_12 =-1;
+ static long tx_fifo_size_13 =-1;
+ static long tx_fifo_size_14 =-1;
+ static long tx_fifo_size_15 =-1;
+ static short thr_ctl=-1;
+ static long tx_thr_length =-1;
+ static long rx_thr_length =-1;
+ #else
+ static long nperio_tx_fifo_size =-1;
+ static long perio_tx_fifo_size_01 =-1;
+ static long perio_tx_fifo_size_02 =-1;
+ static long perio_tx_fifo_size_03 =-1;
+ static long perio_tx_fifo_size_04 =-1;
+ static long perio_tx_fifo_size_05 =-1;
+ static long perio_tx_fifo_size_06 =-1;
+ static long perio_tx_fifo_size_07 =-1;
+ static long perio_tx_fifo_size_08 =-1;
+ static long perio_tx_fifo_size_09 =-1;
+ static long perio_tx_fifo_size_10 =-1;
+ static long perio_tx_fifo_size_11 =-1;
+ static long perio_tx_fifo_size_12 =-1;
+ static long perio_tx_fifo_size_13 =-1;
+ static long perio_tx_fifo_size_14 =-1;
+ static long perio_tx_fifo_size_15 =-1;
+ #endif
+ static short dev_endpoints =-1;
+#endif
+
+#ifdef __IS_HOST__
+ static long rx_fifo_size =-1;
+ static long nperio_tx_fifo_size =-1;
+ static long perio_tx_fifo_size =-1;
+ static short host_channels =-1;
+#endif
+
+static long max_transfer_size =-1;
+static long max_packet_count =-1;
+static long phy_utmi_width =-1;
+static long turn_around_time_hs =-1;
+static long turn_around_time_fs =-1;
+static long timeout_cal_hs =-1;
+static long timeout_cal_fs =-1;
+
+/*!
+ \brief Parsing the parameters taken when module load
+*/
+static void parse_parms(void)
+{
+
+ ifxusb_params_t *params;
+ IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
+ #ifdef __IS_HOST__
+ h_dbg_lvl=dbg_lvl;
+ params=&ifxusb_module_params_h;
+ #endif
+ #ifdef __IS_DEVICE__
+ d_dbg_lvl=dbg_lvl;
+ params=&ifxusb_module_params_d;
+ #endif
+
+ switch(dma_burst_size)
+ {
+ case 0:
+ case 1:
+ case 4:
+ case 8:
+ case 16:
+ params->dma_burst_size=dma_burst_size;
+ break;
+ default:
+ #if defined(__IS_VR9__)
+ {
+ unsigned int chipid;
+ unsigned int partnum;
+ chipid=*((volatile uint32_t *)IFX_MPS_CHIPID);
+ partnum=(chipid&0x0FFFF000)>>12;
+ switch(partnum)
+ {
+ case 0x000B: //VRX288_A2x
+ case 0x000E: //VRX282_A2x
+ case 0x000C: //VRX268_A2x
+ case 0x000D: //GRX288_A2x
+ params->dma_burst_size=default_param_dma_burst_size_n;
+ break;
+ default:
+ params->dma_burst_size=default_param_dma_burst_size;
+ }
+ printk(KERN_INFO "Chip Version :%04x BurstSize=%d\n",partnum,params->dma_burst_size);
+ }
+ #else
+ params->dma_burst_size=default_param_dma_burst_size;
+ #endif
+ }
+
+ if(speed==0 || speed==1)
+ params->speed=speed;
+ else
+ params->speed=default_param_speed;
+
+ if(max_transfer_size>=2048 && max_transfer_size<=65535)
+ params->max_transfer_size=max_transfer_size;
+ else
+ params->max_transfer_size=default_param_max_transfer_size;
+
+ if(max_packet_count>=15 && max_packet_count<=511)
+ params->max_packet_count=max_packet_count;
+ else
+ params->max_packet_count=default_param_max_packet_count;
+
+ switch(phy_utmi_width)
+ {
+ case 8:
+ case 16:
+ params->phy_utmi_width=phy_utmi_width;
+ break;
+ default:
+ params->phy_utmi_width=default_param_phy_utmi_width;
+ }
+
+ if(turn_around_time_hs>=0 && turn_around_time_hs<=7)
+ params->turn_around_time_hs=turn_around_time_hs;
+ else
+ params->turn_around_time_hs=default_param_turn_around_time_hs;
+
+ if(turn_around_time_fs>=0 && turn_around_time_fs<=7)
+ params->turn_around_time_fs=turn_around_time_fs;
+ else
+ params->turn_around_time_fs=default_param_turn_around_time_fs;
+
+ if(timeout_cal_hs>=0 && timeout_cal_hs<=7)
+ params->timeout_cal_hs=timeout_cal_hs;
+ else
+ params->timeout_cal_hs=default_param_timeout_cal_hs;
+
+ if(timeout_cal_fs>=0 && timeout_cal_fs<=7)
+ params->timeout_cal_fs=timeout_cal_fs;
+ else
+ params->timeout_cal_fs=default_param_timeout_cal_fs;
+
+ if(data_fifo_size>=32 && data_fifo_size<=32768)
+ params->data_fifo_size=data_fifo_size;
+ else
+ params->data_fifo_size=default_param_data_fifo_size;
+
+ #ifdef __IS_HOST__
+ if(host_channels>=1 && host_channels<=16)
+ params->host_channels=host_channels;
+ else
+ params->host_channels=default_param_host_channels;
+
+ if(rx_fifo_size>=16 && rx_fifo_size<=32768)
+ params->rx_fifo_size=rx_fifo_size;
+ else
+ params->rx_fifo_size=default_param_rx_fifo_size;
+
+ if(nperio_tx_fifo_size>=16 && nperio_tx_fifo_size<=32768)
+ params->nperio_tx_fifo_size=nperio_tx_fifo_size;
+ else
+ params->nperio_tx_fifo_size=default_param_nperio_tx_fifo_size;
+
+ if(perio_tx_fifo_size>=16 && perio_tx_fifo_size<=32768)
+ params->perio_tx_fifo_size=perio_tx_fifo_size;
+ else
+ params->perio_tx_fifo_size=default_param_perio_tx_fifo_size;
+ #endif //__IS_HOST__
+
+ #ifdef __IS_DEVICE__
+ if(rx_fifo_size>=16 && rx_fifo_size<=32768)
+ params->rx_fifo_size=rx_fifo_size;
+ else
+ params->rx_fifo_size=default_param_rx_fifo_size;
+ #ifdef __DED_FIFO__
+ if(tx_fifo_size_00>=16 && tx_fifo_size_00<=32768)
+ params->tx_fifo_size[ 0]=tx_fifo_size_00;
+ else
+ params->tx_fifo_size[ 0]=default_param_tx_fifo_size_00;
+ if(tx_fifo_size_01>=0 && tx_fifo_size_01<=32768)
+ params->tx_fifo_size[ 1]=tx_fifo_size_01;
+ else
+ params->tx_fifo_size[ 1]=default_param_tx_fifo_size_01;
+ if(tx_fifo_size_02>=0 && tx_fifo_size_02<=32768)
+ params->tx_fifo_size[ 2]=tx_fifo_size_02;
+ else
+ params->tx_fifo_size[ 2]=default_param_tx_fifo_size_02;
+ if(tx_fifo_size_03>=0 && tx_fifo_size_03<=32768)
+ params->tx_fifo_size[ 3]=tx_fifo_size_03;
+ else
+ params->tx_fifo_size[ 3]=default_param_tx_fifo_size_03;
+ if(tx_fifo_size_04>=0 && tx_fifo_size_04<=32768)
+ params->tx_fifo_size[ 4]=tx_fifo_size_04;
+ else
+ params->tx_fifo_size[ 4]=default_param_tx_fifo_size_04;
+ if(tx_fifo_size_05>=0 && tx_fifo_size_05<=32768)
+ params->tx_fifo_size[ 5]=tx_fifo_size_05;
+ else
+ params->tx_fifo_size[ 5]=default_param_tx_fifo_size_05;
+ if(tx_fifo_size_06>=0 && tx_fifo_size_06<=32768)
+ params->tx_fifo_size[ 6]=tx_fifo_size_06;
+ else
+ params->tx_fifo_size[ 6]=default_param_tx_fifo_size_06;
+ if(tx_fifo_size_07>=0 && tx_fifo_size_07<=32768)
+ params->tx_fifo_size[ 7]=tx_fifo_size_07;
+ else
+ params->tx_fifo_size[ 7]=default_param_tx_fifo_size_07;
+ if(tx_fifo_size_08>=0 && tx_fifo_size_08<=32768)
+ params->tx_fifo_size[ 8]=tx_fifo_size_08;
+ else
+ params->tx_fifo_size[ 8]=default_param_tx_fifo_size_08;
+ if(tx_fifo_size_09>=0 && tx_fifo_size_09<=32768)
+ params->tx_fifo_size[ 9]=tx_fifo_size_09;
+ else
+ params->tx_fifo_size[ 9]=default_param_tx_fifo_size_09;
+ if(tx_fifo_size_10>=0 && tx_fifo_size_10<=32768)
+ params->tx_fifo_size[10]=tx_fifo_size_10;
+ else
+ params->tx_fifo_size[10]=default_param_tx_fifo_size_10;
+ if(tx_fifo_size_11>=0 && tx_fifo_size_11<=32768)
+ params->tx_fifo_size[11]=tx_fifo_size_11;
+ else
+ params->tx_fifo_size[11]=default_param_tx_fifo_size_11;
+ if(tx_fifo_size_12>=0 && tx_fifo_size_12<=32768)
+ params->tx_fifo_size[12]=tx_fifo_size_12;
+ else
+ params->tx_fifo_size[12]=default_param_tx_fifo_size_12;
+ if(tx_fifo_size_13>=0 && tx_fifo_size_13<=32768)
+ params->tx_fifo_size[13]=tx_fifo_size_13;
+ else
+ params->tx_fifo_size[13]=default_param_tx_fifo_size_13;
+ if(tx_fifo_size_14>=0 && tx_fifo_size_14<=32768)
+ params->tx_fifo_size[14]=tx_fifo_size_14;
+ else
+ params->tx_fifo_size[14]=default_param_tx_fifo_size_14;
+ if(tx_fifo_size_15>=0 && tx_fifo_size_15<=32768)
+ params->tx_fifo_size[15]=tx_fifo_size_15;
+ else
+ params->tx_fifo_size[15]=default_param_tx_fifo_size_15;
+ if(thr_ctl==0 || thr_ctl==1)
+ params->thr_ctl=thr_ctl;
+ else
+ params->thr_ctl=default_param_thr_ctl;
+ if(tx_thr_length>=16 && tx_thr_length<=511)
+ params->tx_thr_length=tx_thr_length;
+ else
+ params->tx_thr_length=default_param_tx_thr_length;
+ if(rx_thr_length>=16 && rx_thr_length<=511)
+ params->rx_thr_length=rx_thr_length;
+ else
+ params->rx_thr_length=default_param_rx_thr_length;
+ #else //__DED_FIFO__
+ if(nperio_tx_fifo_size>=16 && nperio_tx_fifo_size<=32768)
+ params->tx_fifo_size[ 0]=nperio_tx_fifo_size;
+ else
+ params->tx_fifo_size[ 0]=default_param_nperio_tx_fifo_size;
+ if(perio_tx_fifo_size_01>=0 && perio_tx_fifo_size_01<=32768)
+ params->tx_fifo_size[ 1]=perio_tx_fifo_size_01;
+ else
+ params->tx_fifo_size[ 1]=default_param_perio_tx_fifo_size_01;
+ if(perio_tx_fifo_size_02>=0 && perio_tx_fifo_size_02<=32768)
+ params->tx_fifo_size[ 2]=perio_tx_fifo_size_02;
+ else
+ params->tx_fifo_size[ 2]=default_param_perio_tx_fifo_size_02;
+ if(perio_tx_fifo_size_03>=0 && perio_tx_fifo_size_03<=32768)
+ params->tx_fifo_size[ 3]=perio_tx_fifo_size_03;
+ else
+ params->tx_fifo_size[ 3]=default_param_perio_tx_fifo_size_03;
+ if(perio_tx_fifo_size_04>=0 && perio_tx_fifo_size_04<=32768)
+ params->tx_fifo_size[ 4]=perio_tx_fifo_size_04;
+ else
+ params->tx_fifo_size[ 4]=default_param_perio_tx_fifo_size_04;
+ if(perio_tx_fifo_size_05>=0 && perio_tx_fifo_size_05<=32768)
+ params->tx_fifo_size[ 5]=perio_tx_fifo_size_05;
+ else
+ params->tx_fifo_size[ 5]=default_param_perio_tx_fifo_size_05;
+ if(perio_tx_fifo_size_06>=0 && perio_tx_fifo_size_06<=32768)
+ params->tx_fifo_size[ 6]=perio_tx_fifo_size_06;
+ else
+ params->tx_fifo_size[ 6]=default_param_perio_tx_fifo_size_06;
+ if(perio_tx_fifo_size_07>=0 && perio_tx_fifo_size_07<=32768)
+ params->tx_fifo_size[ 7]=perio_tx_fifo_size_07;
+ else
+ params->tx_fifo_size[ 7]=default_param_perio_tx_fifo_size_07;
+ if(perio_tx_fifo_size_08>=0 && perio_tx_fifo_size_08<=32768)
+ params->tx_fifo_size[ 8]=perio_tx_fifo_size_08;
+ else
+ params->tx_fifo_size[ 8]=default_param_perio_tx_fifo_size_08;
+ if(perio_tx_fifo_size_09>=0 && perio_tx_fifo_size_09<=32768)
+ params->tx_fifo_size[ 9]=perio_tx_fifo_size_09;
+ else
+ params->tx_fifo_size[ 9]=default_param_perio_tx_fifo_size_09;
+ if(perio_tx_fifo_size_10>=0 && perio_tx_fifo_size_10<=32768)
+ params->tx_fifo_size[10]=perio_tx_fifo_size_10;
+ else
+ params->tx_fifo_size[10]=default_param_perio_tx_fifo_size_10;
+ if(perio_tx_fifo_size_11>=0 && perio_tx_fifo_size_11<=32768)
+ params->tx_fifo_size[11]=perio_tx_fifo_size_11;
+ else
+ params->tx_fifo_size[11]=default_param_perio_tx_fifo_size_11;
+ if(perio_tx_fifo_size_12>=0 && perio_tx_fifo_size_12<=32768)
+ params->tx_fifo_size[12]=perio_tx_fifo_size_12;
+ else
+ params->tx_fifo_size[12]=default_param_perio_tx_fifo_size_12;
+ if(perio_tx_fifo_size_13>=0 && perio_tx_fifo_size_13<=32768)
+ params->tx_fifo_size[13]=perio_tx_fifo_size_13;
+ else
+ params->tx_fifo_size[13]=default_param_perio_tx_fifo_size_13;
+ if(perio_tx_fifo_size_14>=0 && perio_tx_fifo_size_14<=32768)
+ params->tx_fifo_size[14]=perio_tx_fifo_size_14;
+ else
+ params->tx_fifo_size[14]=default_param_perio_tx_fifo_size_14;
+ if(perio_tx_fifo_size_15>=0 && perio_tx_fifo_size_15<=32768)
+ params->tx_fifo_size[15]=perio_tx_fifo_size_15;
+ else
+ params->tx_fifo_size[15]=default_param_perio_tx_fifo_size_15;
+ #endif //__DED_FIFO__
+ #endif //__IS_DEVICE__
+}
+
+
+
+
+
+
+
+module_param(dbg_lvl, long, 0444);
+MODULE_PARM_DESC(dbg_lvl, "Debug level.");
+
+module_param(dma_burst_size, short, 0444);
+MODULE_PARM_DESC(dma_burst_size, "DMA Burst Size 0, 1, 4, 8, 16");
+
+module_param(speed, short, 0444);
+MODULE_PARM_DESC(speed, "Speed 0=High Speed 1=Full Speed");
+
+module_param(data_fifo_size, long, 0444);
+MODULE_PARM_DESC(data_fifo_size, "Total number of words in the data FIFO memory 32-32768");
+
+#ifdef __IS_DEVICE__
+ module_param(rx_fifo_size, long, 0444);
+ MODULE_PARM_DESC(rx_fifo_size, "Number of words in the Rx FIFO 16-32768");
+
+ #ifdef __DED_FIFO__
+ module_param(tx_fifo_size_00, long, 0444);
+ MODULE_PARM_DESC(tx_fifo_size_00, "Number of words in the Tx FIFO #00 16-32768");
+ module_param(tx_fifo_size_01, long, 0444);
+ MODULE_PARM_DESC(tx_fifo_size_01, "Number of words in the Tx FIFO #01 0-32768");
+ module_param(tx_fifo_size_02, long, 0444);
+ MODULE_PARM_DESC(tx_fifo_size_02, "Number of words in the Tx FIFO #02 0-32768");
+ module_param(tx_fifo_size_03, long, 0444);
+ MODULE_PARM_DESC(tx_fifo_size_03, "Number of words in the Tx FIFO #03 0-32768");
+ module_param(tx_fifo_size_04, long, 0444);
+ MODULE_PARM_DESC(tx_fifo_size_04, "Number of words in the Tx FIFO #04 0-32768");
+ module_param(tx_fifo_size_05, long, 0444);
+ MODULE_PARM_DESC(tx_fifo_size_05, "Number of words in the Tx FIFO #05 0-32768");
+ module_param(tx_fifo_size_06, long, 0444);
+ MODULE_PARM_DESC(tx_fifo_size_06, "Number of words in the Tx FIFO #06 0-32768");
+ module_param(tx_fifo_size_07, long, 0444);
+ MODULE_PARM_DESC(tx_fifo_size_07, "Number of words in the Tx FIFO #07 0-32768");
+ module_param(tx_fifo_size_08, long, 0444);
+ MODULE_PARM_DESC(tx_fifo_size_08, "Number of words in the Tx FIFO #08 0-32768");
+ module_param(tx_fifo_size_09, long, 0444);
+ MODULE_PARM_DESC(tx_fifo_size_09, "Number of words in the Tx FIFO #09 0-32768");
+ module_param(tx_fifo_size_10, long, 0444);
+ MODULE_PARM_DESC(tx_fifo_size_10, "Number of words in the Tx FIFO #10 0-32768");
+ module_param(tx_fifo_size_11, long, 0444);
+ MODULE_PARM_DESC(tx_fifo_size_11, "Number of words in the Tx FIFO #11 0-32768");
+ module_param(tx_fifo_size_12, long, 0444);
+ MODULE_PARM_DESC(tx_fifo_size_12, "Number of words in the Tx FIFO #12 0-32768");
+ module_param(tx_fifo_size_13, long, 0444);
+ MODULE_PARM_DESC(tx_fifo_size_13, "Number of words in the Tx FIFO #13 0-32768");
+ module_param(tx_fifo_size_14, long, 0444);
+ MODULE_PARM_DESC(tx_fifo_size_14, "Number of words in the Tx FIFO #14 0-32768");
+ module_param(tx_fifo_size_15, long, 0444);
+ MODULE_PARM_DESC(tx_fifo_size_15, "Number of words in the Tx FIFO #15 0-32768");
+
+ module_param(thr_ctl, short, 0444);
+ MODULE_PARM_DESC(thr_ctl, "0=Without 1=With Theshold Ctrl");
+
+ module_param(tx_thr_length, long, 0444);
+ MODULE_PARM_DESC(tx_thr_length, "TX Threshold length");
+
+ module_param(rx_thr_length, long, 0444);
+ MODULE_PARM_DESC(rx_thr_length, "RX Threshold length");
+
+ #else
+ module_param(nperio_tx_fifo_size, long, 0444);
+ MODULE_PARM_DESC(nperio_tx_fifo_size, "Number of words in the non-periodic Tx FIFO 16-32768");
+
+ module_param(perio_tx_fifo_size_01, long, 0444);
+ MODULE_PARM_DESC(perio_tx_fifo_size_01, "Number of words in the periodic Tx FIFO #01 0-32768");
+ module_param(perio_tx_fifo_size_02, long, 0444);
+ MODULE_PARM_DESC(perio_tx_fifo_size_02, "Number of words in the periodic Tx FIFO #02 0-32768");
+ module_param(perio_tx_fifo_size_03, long, 0444);
+ MODULE_PARM_DESC(perio_tx_fifo_size_03, "Number of words in the periodic Tx FIFO #03 0-32768");
+ module_param(perio_tx_fifo_size_04, long, 0444);
+ MODULE_PARM_DESC(perio_tx_fifo_size_04, "Number of words in the periodic Tx FIFO #04 0-32768");
+ module_param(perio_tx_fifo_size_05, long, 0444);
+ MODULE_PARM_DESC(perio_tx_fifo_size_05, "Number of words in the periodic Tx FIFO #05 0-32768");
+ module_param(perio_tx_fifo_size_06, long, 0444);
+ MODULE_PARM_DESC(perio_tx_fifo_size_06, "Number of words in the periodic Tx FIFO #06 0-32768");
+ module_param(perio_tx_fifo_size_07, long, 0444);
+ MODULE_PARM_DESC(perio_tx_fifo_size_07, "Number of words in the periodic Tx FIFO #07 0-32768");
+ module_param(perio_tx_fifo_size_08, long, 0444);
+ MODULE_PARM_DESC(perio_tx_fifo_size_08, "Number of words in the periodic Tx FIFO #08 0-32768");
+ module_param(perio_tx_fifo_size_09, long, 0444);
+ MODULE_PARM_DESC(perio_tx_fifo_size_09, "Number of words in the periodic Tx FIFO #09 0-32768");
+ module_param(perio_tx_fifo_size_10, long, 0444);
+ MODULE_PARM_DESC(perio_tx_fifo_size_10, "Number of words in the periodic Tx FIFO #10 0-32768");
+ module_param(perio_tx_fifo_size_11, long, 0444);
+ MODULE_PARM_DESC(perio_tx_fifo_size_11, "Number of words in the periodic Tx FIFO #11 0-32768");
+ module_param(perio_tx_fifo_size_12, long, 0444);
+ MODULE_PARM_DESC(perio_tx_fifo_size_12, "Number of words in the periodic Tx FIFO #12 0-32768");
+ module_param(perio_tx_fifo_size_13, long, 0444);
+ MODULE_PARM_DESC(perio_tx_fifo_size_13, "Number of words in the periodic Tx FIFO #13 0-32768");
+ module_param(perio_tx_fifo_size_14, long, 0444);
+ MODULE_PARM_DESC(perio_tx_fifo_size_14, "Number of words in the periodic Tx FIFO #14 0-32768");
+ module_param(perio_tx_fifo_size_15, long, 0444);
+ MODULE_PARM_DESC(perio_tx_fifo_size_15, "Number of words in the periodic Tx FIFO #15 0-32768");
+ #endif//__DED_FIFO__
+ module_param(dev_endpoints, short, 0444);
+ MODULE_PARM_DESC(dev_endpoints, "The number of endpoints in addition to EP0 available for device mode 1-15");
+#endif
+
+#ifdef __IS_HOST__
+ module_param(rx_fifo_size, long, 0444);
+ MODULE_PARM_DESC(rx_fifo_size, "Number of words in the Rx FIFO 16-32768");
+
+ module_param(nperio_tx_fifo_size, long, 0444);
+ MODULE_PARM_DESC(nperio_tx_fifo_size, "Number of words in the non-periodic Tx FIFO 16-32768");
+
+ module_param(perio_tx_fifo_size, long, 0444);
+ MODULE_PARM_DESC(perio_tx_fifo_size, "Number of words in the host periodic Tx FIFO 16-32768");
+
+ module_param(host_channels, short, 0444);
+ MODULE_PARM_DESC(host_channels, "The number of host channel registers to use 1-16");
+#endif
+
+module_param(max_transfer_size, long, 0444);
+MODULE_PARM_DESC(max_transfer_size, "The maximum transfer size supported in bytes 2047-65535");
+
+module_param(max_packet_count, long, 0444);
+MODULE_PARM_DESC(max_packet_count, "The maximum number of packets in a transfer 15-511");
+
+module_param(phy_utmi_width, long, 0444);
+MODULE_PARM_DESC(phy_utmi_width, "Specifies the UTMI+ Data Width 8 or 16 bits");
+
+module_param(turn_around_time_hs, long, 0444);
+MODULE_PARM_DESC(turn_around_time_hs, "Turn-Around time for HS");
+
+module_param(turn_around_time_fs, long, 0444);
+MODULE_PARM_DESC(turn_around_time_fs, "Turn-Around time for FS");
+
+module_param(timeout_cal_hs, long, 0444);
+MODULE_PARM_DESC(timeout_cal_hs, "Timeout Cal for HS");
+
+module_param(timeout_cal_fs, long, 0444);
+MODULE_PARM_DESC(timeout_cal_fs, "Timeout Cal for FS");
+
diff --git a/package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxusb_host.ko.svn-base b/package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxusb_host.ko.svn-base
new file mode 100644
index 0000000..1dd25ca
--- /dev/null
+++ b/package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxusb_host.ko.svn-base
Binary files differ
diff --git a/package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxusb_plat.h.svn-base b/package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxusb_plat.h.svn-base
new file mode 100644
index 0000000..df959cf
--- /dev/null
+++ b/package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxusb_plat.h.svn-base
@@ -0,0 +1,1184 @@
+/*****************************************************************************
+ ** FILE NAME : ifxusb_plat.h
+ ** PROJECT : IFX USB sub-system V3
+ ** MODULES : IFX USB sub-system Host and Device driver
+ ** SRC VERSION : 3.2
+ ** DATE : 1/Jan/2011
+ ** AUTHOR : Chen, Howard
+ ** DESCRIPTION : This file contains the Platform Specific constants, interfaces
+ ** (functions and macros).
+ ** FUNCTIONS :
+ ** COMPILER : gcc
+ ** REFERENCE : Synopsys DWC-OTG Driver 2.7
+ ** COPYRIGHT : Copyright (c) 2010
+ ** LANTIQ DEUTSCHLAND GMBH,
+ ** Am Campeon 3, 85579 Neubiberg, Germany
+ **
+ ** 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 of the License, or
+ ** (at your option) any later version.
+ **
+ ** Version Control Section **
+ ** $Author$
+ ** $Date$
+ ** $Revisions$
+ ** $Log$ Revision history
+ *****************************************************************************/
+
+/*
+ * This file contains code fragments from Synopsys HS OTG Linux Software Driver.
+ * For this code the following notice is applicable:
+ *
+ * ==========================================================================
+ *
+ * Synopsys HS OTG Linux Software Driver and documentation (hereinafter,
+ * "Software") is an Unsupported proprietary work of Synopsys, Inc. unless
+ * otherwise expressly agreed to in writing between Synopsys and you.
+ *
+ * The Software IS NOT an item of Licensed Software or Licensed Product under
+ * any End User Software License Agreement or Agreement for Licensed Product
+ * with Synopsys or any supplement thereto. You are permitted to use and
+ * redistribute this Software in source and binary forms, with or without
+ * modification, provided that redistributions of source code must retain this
+ * notice. You may not view, use, disclose, copy or distribute this file or
+ * any information contained herein except pursuant to this license grant from
+ * Synopsys. If you do not agree with this notice, including the disclaimer
+ * below, then you are not authorized to use the Software.
+ *
+ * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" BASIS
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ * ========================================================================== */
+
+
+/*!
+ \defgroup IFXUSB_PLATEFORM_DEFINITION Platform Specific constants, interfaces (functions and macros).
+ \ingroup IFXUSB_DRIVER_V3
+ \brief Maintain plateform specific definitions and macros in this file.
+ Each plateform has its own definition zone.
+ */
+
+/*!
+ \defgroup IFXUSB_PLATEFORM_MEM_ADDR Definition of memory address and size and default parameters
+ \ingroup IFXUSB_PLATEFORM_DEFINITION
+ */
+
+/*!
+ \defgroup IFXUSB_DBG_ROUTINE Routines for debug message
+ \ingroup IFXUSB_PLATEFORM_DEFINITION
+ */
+
+
+/*! \file ifxusb_plat.h
+ \ingroup IFXUSB_DRIVER_V3
+ \brief This file contains the Platform Specific constants, interfaces (functions and macros).
+*/
+
+#if !defined(__IFXUSB_PLAT_H__)
+#define __IFXUSB_PLAT_H__
+
+
+#include <linux/types.h>
+#include <linux/slab.h>
+#include <linux/list.h>
+#include <linux/delay.h>
+#include <asm/io.h>
+
+
+#define IFXUSB_IOMEM_SIZE 0x00001000
+#define IFXUSB_FIFOMEM_SIZE 0x00010000
+#define IFXUSB_FIFODBG_SIZE 0x00020000
+
+
+
+/*!
+ \addtogroup IFXUSB_PLATEFORM_MEM_ADDR
+ */
+/*@{*/
+#if defined(__UEIP__)
+ #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ #define IFXUSB_IRQ 62
+ #define IFXUSB_IOMEM_BASE 0x1e101000
+ #define IFXUSB_FIFOMEM_BASE 0x1e120000
+ #define IFXUSB_FIFODBG_BASE 0x1e140000
+ #define IFXUSB_OC_IRQ 159
+
+ #ifndef DANUBE_RCU_BASE_ADDR
+ #define DANUBE_RCU_BASE_ADDR (0xBF203000)
+ #endif
+
+ #ifndef DANUBE_CGU
+ #define DANUBE_CGU (0xBF103000)
+ #endif
+ #ifndef DANUBE_CGU_IFCCR
+ #define DANUBE_CGU_IFCCR ((volatile unsigned long *)(DANUBE_CGU+ 0x0018))
+ #endif
+ #ifndef DANUBE_PMU
+ #define DANUBE_PMU (KSEG1+0x1F102000)
+ #endif
+ #ifndef DANUBE_PMU_PWDCR
+ #define DANUBE_PMU_PWDCR ((volatile unsigned long *)(DANUBE_PMU+0x001C))
+ #endif
+
+ #ifndef DANUBE_GPIO_P0_OUT
+ #define DANUBE_GPIO_P0_OUT (0xBF103000+0x10)
+ #define DANUBE_GPIO_P0_DIR (0xBF103000+0x18)
+ #define DANUBE_GPIO_P0_ALTSEL0 (0xBF103000+0x1C)
+ #define DANUBE_GPIO_P0_ALTSEL1 (0xBF103000+0x20)
+ #define DANUBE_GPIO_P0_OD (0xBF103000+0x24)
+ #define DANUBE_GPIO_P0_PUDSEL (0xBF103000+0x2C)
+ #define DANUBE_GPIO_P0_PUDEN (0xBF103000+0x30)
+ #define DANUBE_GPIO_P1_OUT (0xBF103000+0x40)
+ #define DANUBE_GPIO_P1_DIR (0xBF103000+0x48)
+ #define DANUBE_GPIO_P1_ALTSEL0 (0xBF103000+0x4C)
+ #define DANUBE_GPIO_P1_ALTSEL1 (0xBF103000+0x50)
+ #define DANUBE_GPIO_P1_OD (0xBF103000+0x54)
+ #define DANUBE_GPIO_P1_PUDSEL (0xBF103000+0x5C)
+ #define DANUBE_GPIO_P1_PUDEN (0xBF103000+0x60)
+ #endif
+
+ #define DANUBE_RCU_USBCFG ((volatile unsigned long *)(DANUBE_RCU_BASE_ADDR + 0x18))
+ #define DANUBE_RCU_RESET ((volatile unsigned long *)(DANUBE_RCU_BASE_ADDR + 0x10))
+ #define DANUBE_USBCFG_HDSEL_BIT 11 // 0:host, 1:device
+ #define DANUBE_USBCFG_HOST_END_BIT 10 // 0:little_end, 1:big_end
+ #define DANUBE_USBCFG_SLV_END_BIT 9 // 0:little_end, 1:big_end
+
+ #define default_param_dma_burst_size 4
+
+ #define default_param_speed IFXUSB_PARAM_SPEED_HIGH
+
+ #define default_param_max_transfer_size -1 //(Max, hwcfg)
+ #define default_param_max_packet_count -1 //(Max, hwcfg)
+ #define default_param_phy_utmi_width 16
+
+ #define default_param_turn_around_time_hs 4
+ #define default_param_turn_around_time_fs 4
+ #define default_param_timeout_cal_hs -1 //(NoChange)
+ #define default_param_timeout_cal_fs -1 //(NoChange)
+
+ #define default_param_data_fifo_size -1 //(Max, hwcfg)
+
+ #ifdef __IS_HOST__
+ #define default_param_host_channels -1 //(Max, hwcfg)
+ #define default_param_rx_fifo_size 640
+ #define default_param_nperio_tx_fifo_size 640
+ #define default_param_perio_tx_fifo_size 768
+ #endif //__IS_HOST__
+
+ #ifdef __IS_DEVICE__
+ #ifdef __DED_INTR__
+// #define default_param_rx_fifo_size 1024
+// #define default_param_nperio_tx_fifo_size 1016
+// #define default_param_perio_tx_fifo_size_01 8
+ #define default_param_rx_fifo_size 1008
+ #define default_param_nperio_tx_fifo_size 1008
+ #define default_param_perio_tx_fifo_size_01 32
+ #else
+ #define default_param_rx_fifo_size 1024
+ #define default_param_nperio_tx_fifo_size 1024
+ #define default_param_perio_tx_fifo_size_01 0
+ #endif
+ #define default_param_perio_tx_fifo_size_02 0
+ #define default_param_perio_tx_fifo_size_03 0
+ #define default_param_perio_tx_fifo_size_04 0
+ #define default_param_perio_tx_fifo_size_05 0
+ #define default_param_perio_tx_fifo_size_06 0
+ #define default_param_perio_tx_fifo_size_07 0
+ #define default_param_perio_tx_fifo_size_08 0
+ #define default_param_perio_tx_fifo_size_09 0
+ #define default_param_perio_tx_fifo_size_10 0
+ #define default_param_perio_tx_fifo_size_11 0
+ #define default_param_perio_tx_fifo_size_12 0
+ #define default_param_perio_tx_fifo_size_13 0
+ #define default_param_perio_tx_fifo_size_14 0
+ #define default_param_perio_tx_fifo_size_15 0
+ #endif //__IS_DEVICE__
+
+ #elif defined(__IS_AMAZON_SE__)
+ //#include <asm/amazon_se/amazon_se.h>
+ //#include <asm/amazon_se/irq.h>
+
+ #define IFXUSB_IRQ 39
+ #define IFXUSB_IOMEM_BASE 0x1e101000
+ #define IFXUSB_FIFOMEM_BASE 0x1e120000
+ #define IFXUSB_FIFODBG_BASE 0x1e140000
+ #define IFXUSB_OC_IRQ 20
+
+ #ifndef AMAZON_SE_RCU_BASE_ADDR
+ #define AMAZON_SE_RCU_BASE_ADDR (0xBF203000)
+ #endif
+ #define AMAZON_SE_RCU_USBCFG ((volatile unsigned long *)(AMAZON_SE_RCU_BASE_ADDR + 0x18))
+ #define AMAZON_SE_RCU_RESET ((volatile unsigned long *)(AMAZON_SE_RCU_BASE_ADDR + 0x10))
+ #define AMAZON_SE_USBCFG_HDSEL_BIT 11 // 0:host, 1:device
+ #define AMAZON_SE_USBCFG_HOST_END_BIT 10 // 0:little_end, 1:big_end
+ #define AMAZON_SE_USBCFG_SLV_END_BIT 9 // 0:little_end, 1:big_end
+
+ #ifndef AMAZON_SE_GPIO_P0_OUT
+ #define AMAZON_SE_GPIO_P0_OUT (0xBF103000+0x10)
+ #define AMAZON_SE_GPIO_P0_DIR (0xBF103000+0x18)
+ #define AMAZON_SE_GPIO_P0_ALTSEL0 (0xBF103000+0x1C)
+ #define AMAZON_SE_GPIO_P0_ALTSEL1 (0xBF103000+0x20)
+ #define AMAZON_SE_GPIO_P0_OD (0xBF103000+0x24)
+ #define AMAZON_SE_GPIO_P0_PUDSEL (0xBF103000+0x2C)
+ #define AMAZON_SE_GPIO_P0_PUDEN (0xBF103000+0x30)
+ #define AMAZON_SE_GPIO_P1_OUT (0xBF103000+0x40)
+ #define AMAZON_SE_GPIO_P1_DIR (0xBF103000+0x48)
+ #define AMAZON_SE_GPIO_P1_ALTSEL0 (0xBF103000+0x4C)
+ #define AMAZON_SE_GPIO_P1_ALTSEL1 (0xBF103000+0x50)
+ #define AMAZON_SE_GPIO_P1_OD (0xBF103000+0x54)
+ #define AMAZON_SE_GPIO_P1_PUDSEL (0xBF103000+0x5C)
+ #define AMAZON_SE_GPIO_P1_PUDEN (0xBF103000+0x60)
+ #endif
+
+ #ifndef AMAZON_SE_CGU
+ #define AMAZON_SE_CGU (0xBF103000)
+ #endif
+ #ifndef AMAZON_SE_CGU_IFCCR
+ #define AMAZON_SE_CGU_IFCCR ((volatile unsigned long *)(AMAZON_SE_CGU+ 0x0018))
+ #endif
+ #ifndef AMAZON_SE_PMU
+ #define AMAZON_SE_PMU (KSEG1+0x1F102000)
+ #endif
+ #ifndef AMAZON_SE_PMU_PWDCR
+ #define AMAZON_SE_PMU_PWDCR ((volatile unsigned long *)(AMAZON_SE_PMU+0x001C))
+ #endif
+
+ #define default_param_dma_burst_size 4
+
+ #define default_param_speed IFXUSB_PARAM_SPEED_HIGH
+
+ #define default_param_max_transfer_size -1 //(Max, hwcfg)
+ #define default_param_max_packet_count -1 //(Max, hwcfg)
+ #define default_param_phy_utmi_width 16
+
+ #define default_param_turn_around_time_hs 4 //(NoChange)
+ #define default_param_turn_around_time_fs 4 //(NoChange)
+ #define default_param_timeout_cal_hs -1 //(NoChange)
+ #define default_param_timeout_cal_fs -1 //(NoChange)
+
+ #define default_param_data_fifo_size -1 //(Max, hwcfg)
+
+ #ifdef __IS_HOST__
+ #define default_param_host_channels -1 //(Max, hwcfg)
+ #define default_param_rx_fifo_size 240
+ #define default_param_nperio_tx_fifo_size 240
+ #define default_param_perio_tx_fifo_size 32
+ #endif //__IS_HOST__
+ #ifdef __IS_DEVICE__
+ #ifdef __DED_INTR__
+// #define default_param_rx_fifo_size 256
+// #define default_param_nperio_tx_fifo_size 248
+// #define default_param_perio_tx_fifo_size_01 8
+ #define default_param_rx_fifo_size 240
+ #define default_param_nperio_tx_fifo_size 240
+ #define default_param_perio_tx_fifo_size_01 32
+ #else
+ #define default_param_rx_fifo_size 256
+ #define default_param_nperio_tx_fifo_size 256
+ #define default_param_perio_tx_fifo_size_01 0
+ #endif
+ #define default_param_perio_tx_fifo_size_02 0
+ #define default_param_perio_tx_fifo_size_03 0
+ #define default_param_perio_tx_fifo_size_04 0
+ #define default_param_perio_tx_fifo_size_05 0
+ #define default_param_perio_tx_fifo_size_06 0
+ #define default_param_perio_tx_fifo_size_07 0
+ #define default_param_perio_tx_fifo_size_08 0
+ #define default_param_perio_tx_fifo_size_09 0
+ #define default_param_perio_tx_fifo_size_10 0
+ #define default_param_perio_tx_fifo_size_11 0
+ #define default_param_perio_tx_fifo_size_12 0
+ #define default_param_perio_tx_fifo_size_13 0
+ #define default_param_perio_tx_fifo_size_14 0
+ #define default_param_perio_tx_fifo_size_15 0
+ #endif //__IS_DEVICE__
+
+ #elif defined(__IS_AR9__)
+ #define IFXUSB1_IRQ 62
+ #define IFXUSB1_IOMEM_BASE 0x1E101000
+ #define IFXUSB1_FIFOMEM_BASE 0x1E120000
+ #define IFXUSB1_FIFODBG_BASE 0x1E140000
+
+ #define IFXUSB2_IRQ 91
+ #define IFXUSB2_IOMEM_BASE 0x1E106000
+ #define IFXUSB2_FIFOMEM_BASE 0x1E1E0000
+ #define IFXUSB2_FIFODBG_BASE 0x1E1C0000
+
+ #define IFXUSB_OC_IRQ 68
+
+ #ifndef AR9_RCU_BASE_ADDR
+ #define AR9_RCU_BASE_ADDR (0xBF203000)
+ #endif
+
+ #ifndef AR9_CGU
+ #define AR9_CGU (0xBF103000)
+ #endif
+ #ifndef AR9_CGU_IFCCR
+ #define AR9_CGU_IFCCR ((volatile unsigned long *)(AR9_CGU+ 0x0018))
+ #endif
+
+ #ifndef AR9_PMU
+ #define AR9_PMU (KSEG1+0x1F102000)
+ #endif
+ #ifndef AR9_PMU_PWDCR
+ #define AR9_PMU_PWDCR ((volatile unsigned long *)(AR9_PMU+0x001C))
+ #endif
+
+ #ifndef AR9_GPIO_P0_OUT
+ #define AR9_GPIO_P0_OUT (0xBF103000+0x10)
+ #define AR9_GPIO_P0_DIR (0xBF103000+0x18)
+ #define AR9_GPIO_P0_ALTSEL0 (0xBF103000+0x1C)
+ #define AR9_GPIO_P0_ALTSEL1 (0xBF103000+0x20)
+ #define AR9_GPIO_P0_OD (0xBF103000+0x24)
+ #define AR9_GPIO_P0_PUDSEL (0xBF103000+0x2C)
+ #define AR9_GPIO_P0_PUDEN (0xBF103000+0x30)
+ #define AR9_GPIO_P1_OUT (0xBF103000+0x40)
+ #define AR9_GPIO_P1_DIR (0xBF103000+0x48)
+ #define AR9_GPIO_P1_ALTSEL0 (0xBF103000+0x4C)
+ #define AR9_GPIO_P1_ALTSEL1 (0xBF103000+0x50)
+ #define AR9_GPIO_P1_OD (0xBF103000+0x54)
+ #define AR9_GPIO_P1_PUDSEL (0xBF103000+0x5C)
+ #define AR9_GPIO_P1_PUDEN (0xBF103000+0x60)
+ #endif
+
+ #define AR9_RCU_USB1CFG ((volatile unsigned long *)(AR9_RCU_BASE_ADDR + 0x18))
+ #define AR9_RCU_USB2CFG ((volatile unsigned long *)(AR9_RCU_BASE_ADDR + 0x34))
+ #define AR9_RCU_USBRESET ((volatile unsigned long *)(AR9_RCU_BASE_ADDR + 0x10))
+ #define AR9_USBCFG_ARB 7 //
+ #define AR9_USBCFG_HDSEL_BIT 11 // 0:host, 1:device
+ #define AR9_USBCFG_HOST_END_BIT 10 // 0:little_end, 1:big_end
+ #define AR9_USBCFG_SLV_END_BIT 17 // 0:little_end, 1:big_end
+
+ #define default_param_dma_burst_size 4
+
+ #define default_param_speed IFXUSB_PARAM_SPEED_HIGH
+
+ #define default_param_max_transfer_size -1 //(Max, hwcfg)
+ #define default_param_max_packet_count -1 //(Max, hwcfg)
+ #define default_param_phy_utmi_width 16
+
+ #define default_param_turn_around_time_hs 4 //(NoChange)
+ #define default_param_turn_around_time_fs 4 //(NoChange)
+ #define default_param_timeout_cal_hs -1 //(NoChange)
+ #define default_param_timeout_cal_fs -1 //(NoChange)
+
+ #define default_param_data_fifo_size -1 //(Max, hwcfg)
+
+ #ifdef __IS_HOST__
+ #define default_param_host_channels -1 //(Max, hwcfg)
+ #define default_param_rx_fifo_size 240
+ #define default_param_nperio_tx_fifo_size 240
+ #define default_param_perio_tx_fifo_size 32
+ #endif //__IS_HOST__
+ #ifdef __IS_DEVICE__
+ #ifdef __DED_INTR__
+// #define default_param_rx_fifo_size 256
+// #define default_param_nperio_tx_fifo_size 248
+// #define default_param_perio_tx_fifo_size_01 8
+ #define default_param_rx_fifo_size 240
+ #define default_param_nperio_tx_fifo_size 240
+ #define default_param_perio_tx_fifo_size_01 32
+ #else
+ #define default_param_rx_fifo_size 256
+ #define default_param_nperio_tx_fifo_size 256
+ #define default_param_perio_tx_fifo_size_01 0
+ #endif
+ #define default_param_perio_tx_fifo_size_02 0
+ #define default_param_perio_tx_fifo_size_03 0
+ #define default_param_perio_tx_fifo_size_04 0
+ #define default_param_perio_tx_fifo_size_05 0
+ #define default_param_perio_tx_fifo_size_06 0
+ #define default_param_perio_tx_fifo_size_07 0
+ #define default_param_perio_tx_fifo_size_08 0
+ #define default_param_perio_tx_fifo_size_09 0
+ #define default_param_perio_tx_fifo_size_10 0
+ #define default_param_perio_tx_fifo_size_11 0
+ #define default_param_perio_tx_fifo_size_12 0
+ #define default_param_perio_tx_fifo_size_13 0
+ #define default_param_perio_tx_fifo_size_14 0
+ #define default_param_perio_tx_fifo_size_15 0
+ #endif //__IS_DEVICE__
+
+ #elif defined(__IS_VR9__)
+ #define IFXUSB1_IRQ 62
+ #define IFXUSB1_IOMEM_BASE 0x1E101000
+ #define IFXUSB1_FIFOMEM_BASE 0x1E120000
+ #define IFXUSB1_FIFODBG_BASE 0x1E140000
+
+ #define IFXUSB2_IRQ 91
+ #define IFXUSB2_IOMEM_BASE 0x1E106000
+ #define IFXUSB2_FIFOMEM_BASE 0x1E1E0000
+ #define IFXUSB2_FIFODBG_BASE 0x1E1C0000
+ #define IFXUSB_OC_IRQ 60
+
+ #ifndef IFX_MPS
+ #define IFX_MPS (KSEG1+0x1F107000)
+ #endif
+ #ifndef IFX_MPS_CHIPID
+ #define IFX_MPS_CHIPID ((volatile unsigned long *)(IFX_MPS + 0x0344))
+ #endif
+
+ #ifndef VR9_RCU_BASE_ADDR
+ #define VR9_RCU_BASE_ADDR (0xBF203000)
+ #endif
+
+ #ifndef VR9_CGU
+ #define VR9_CGU (0xBF103000)
+ #endif
+ #ifndef VR9_CGU_IFCCR
+ #define VR9_CGU_IFCCR ((volatile unsigned long *)(VR9_CGU+ 0x0018))
+ #endif
+
+ #ifndef VR9_PMU
+ #define VR9_PMU (KSEG1+0x1F102000)
+ #endif
+ #ifndef VR9_PMU_PWDCR
+ #define VR9_PMU_PWDCR ((volatile unsigned long *)(VR9_PMU+0x001C))
+ #endif
+
+ #ifndef VR9_GPIO_P0_OUT
+ #define VR9_GPIO_P0_OUT (0xBF103000+0x10)
+ #define VR9_GPIO_P0_DIR (0xBF103000+0x18)
+ #define VR9_GPIO_P0_ALTSEL0 (0xBF103000+0x1C)
+ #define VR9_GPIO_P0_ALTSEL1 (0xBF103000+0x20)
+ #define VR9_GPIO_P0_OD (0xBF103000+0x24)
+ #define VR9_GPIO_P0_PUDSEL (0xBF103000+0x2C)
+ #define VR9_GPIO_P0_PUDEN (0xBF103000+0x30)
+ #define VR9_GPIO_P1_OUT (0xBF103000+0x40)
+ #define VR9_GPIO_P1_DIR (0xBF103000+0x48)
+ #define VR9_GPIO_P1_ALTSEL0 (0xBF103000+0x4C)
+ #define VR9_GPIO_P1_ALTSEL1 (0xBF103000+0x50)
+ #define VR9_GPIO_P1_OD (0xBF103000+0x54)
+ #define VR9_GPIO_P1_PUDSEL (0xBF103000+0x5C)
+ #define VR9_GPIO_P1_PUDEN (0xBF103000+0x60)
+ #endif
+
+ #define VR9_RCU_USB1CFG ((volatile unsigned long *)(VR9_RCU_BASE_ADDR + 0x18))
+ #define VR9_RCU_USB2CFG ((volatile unsigned long *)(VR9_RCU_BASE_ADDR + 0x34))
+ #define VR9_RCU_USB_ANA_CFG1A ((volatile unsigned long *)(VR9_RCU_BASE_ADDR + 0x38))
+ #define VR9_RCU_USB_ANA_CFG1B ((volatile unsigned long *)(VR9_RCU_BASE_ADDR + 0x3C))
+ #define VR9_RCU_USBRESET ((volatile unsigned long *)(VR9_RCU_BASE_ADDR + 0x10))
+ #define VR9_RCU_USBRESET2 ((volatile unsigned long *)(VR9_RCU_BASE_ADDR + 0x48))
+ #define VR9_USBCFG_ARB 7 //
+ #define VR9_USBCFG_HDSEL_BIT 11 // 0:host, 1:device
+ #define VR9_USBCFG_HOST_END_BIT 10 // 0:little_end, 1:big_end
+ #define VR9_USBCFG_SLV_END_BIT 9 // 0:little_end, 1:big_end
+
+// #define default_param_dma_burst_size 4 //(ALL)
+ //WA for AHB
+ #define default_param_dma_burst_size 0 //(ALL)
+ #define default_param_dma_burst_size_n 4 //(ALL)
+
+ #define default_param_speed IFXUSB_PARAM_SPEED_HIGH
+
+ #define default_param_max_transfer_size -1 //(Max, hwcfg)
+ #define default_param_max_packet_count -1 //(Max, hwcfg)
+ #define default_param_phy_utmi_width 16
+
+ #define default_param_turn_around_time_hs 6 //(NoChange) snpsid >= 0x4f54260a
+ #define default_param_turn_around_time_fs 6 //(NoChange) snpsid >= 0x4f54260a
+ #define default_param_timeout_cal_hs -1 //(NoChange)
+ #define default_param_timeout_cal_fs -1 //(NoChange)
+
+ #define default_param_data_fifo_size -1 //(Max, hwcfg)
+
+ #ifdef __IS_HOST__
+ #define default_param_host_channels -1 //(Max, hwcfg)
+ #define default_param_rx_fifo_size 240
+ #define default_param_nperio_tx_fifo_size 240
+ #define default_param_perio_tx_fifo_size 32
+ #endif //__IS_HOST__
+ #ifdef __IS_DEVICE__
+#if 0
+ #define default_param_rx_fifo_size 256
+ #define default_param_tx_fifo_size_00 -1
+ #define default_param_tx_fifo_size_01 -1
+ #define default_param_tx_fifo_size_02 -1
+#else
+ #define default_param_rx_fifo_size 256
+ #define default_param_tx_fifo_size_00 32
+ #define default_param_tx_fifo_size_01 200
+ #define default_param_tx_fifo_size_02 8
+#endif
+ #define default_param_tx_fifo_size_03 -1
+ #define default_param_tx_fifo_size_04 -1
+ #define default_param_tx_fifo_size_05 -1
+ #define default_param_tx_fifo_size_06 -1
+ #define default_param_tx_fifo_size_07 -1
+ #define default_param_tx_fifo_size_08 -1
+ #define default_param_tx_fifo_size_09 -1
+ #define default_param_tx_fifo_size_10 -1
+ #define default_param_tx_fifo_size_11 -1
+ #define default_param_tx_fifo_size_12 -1
+ #define default_param_tx_fifo_size_13 -1
+ #define default_param_tx_fifo_size_14 -1
+ #define default_param_tx_fifo_size_15 -1
+ #define default_param_dma_unalgned_tx -1
+ #define default_param_dma_unalgned_rx -1
+ #define default_param_thr_ctl -1
+ #define default_param_tx_thr_length -1
+ #define default_param_rx_thr_length -1
+ #endif //__IS_DEVICE__
+
+ #elif defined(__IS_AR10__)
+ #define IFXUSB1_IRQ 54
+ #define IFXUSB1_IOMEM_BASE 0x1E101000
+ #define IFXUSB1_FIFOMEM_BASE 0x1E120000
+ #define IFXUSB1_FIFODBG_BASE 0x1E140000
+ #define IFXUSB1_OC_IRQ 60
+
+ #define IFXUSB2_IRQ 83
+ #define IFXUSB2_IOMEM_BASE 0x1E106000
+ #define IFXUSB2_FIFOMEM_BASE 0x1E1E0000
+ #define IFXUSB2_FIFODBG_BASE 0x1E1C0000
+ #define IFXUSB2_OC_IRQ 56
+
+ #ifndef AR10_RCU_BASE_ADDR
+ #define AR10_RCU_BASE_ADDR (0xBF203000)
+ #endif
+ #ifndef AR10_CGU
+ #define AR10_CGU (0xBF103000)
+ #endif
+
+ #ifndef AR10_CGU_IFCCR
+ #define AR10_CGU_IFCCR ((volatile unsigned long *)(AR10_CGU+ 0x0018))
+ #endif
+ #ifndef AR10_PMU
+ #define AR10_PMU (KSEG1+0x1F102000)
+ #endif
+ #ifndef AR10_PMU_PWDCR
+ #define AR10_PMU_PWDCR ((volatile unsigned long *)(AR10_PMU+0x0044))
+ #endif
+
+ #ifndef AR10_GPIO_P0_OUT
+ #define AR10_GPIO_P0_OUT (0xBF103000+0x10)
+ #define AR10_GPIO_P0_DIR (0xBF103000+0x18)
+ #define AR10_GPIO_P0_ALTSEL0 (0xBF103000+0x1C)
+ #define AR10_GPIO_P0_ALTSEL1 (0xBF103000+0x20)
+ #define AR10_GPIO_P0_OD (0xBF103000+0x24)
+ #define AR10_GPIO_P0_PUDSEL (0xBF103000+0x2C)
+ #define AR10_GPIO_P0_PUDEN (0xBF103000+0x30)
+ #define AR10_GPIO_P1_OUT (0xBF103000+0x40)
+ #define AR10_GPIO_P1_DIR (0xBF103000+0x48)
+ #define AR10_GPIO_P1_ALTSEL0 (0xBF103000+0x4C)
+ #define AR10_GPIO_P1_ALTSEL1 (0xBF103000+0x50)
+ #define AR10_GPIO_P1_OD (0xBF103000+0x54)
+ #define AR10_GPIO_P1_PUDSEL (0xBF103000+0x5C)
+ #define AR10_GPIO_P1_PUDEN (0xBF103000+0x60)
+ #endif
+
+ #define AR10_RCU_USB1CFG ((volatile unsigned long *)(AR10_RCU_BASE_ADDR + 0x18))
+ #define AR10_RCU_USB2CFG ((volatile unsigned long *)(AR10_RCU_BASE_ADDR + 0x34))
+ #define AR10_RCU_USB_ANA_CFG1A ((volatile unsigned long *)(AR10_RCU_BASE_ADDR + 0x38))
+ #define AR10_RCU_USB_ANA_CFG1B ((volatile unsigned long *)(AR10_RCU_BASE_ADDR + 0x3C))
+
+ #define AR10_RCU_USBRESET ((volatile unsigned long *)(AR10_RCU_BASE_ADDR + 0x10))
+
+ #define AR10_USBCFG_ARB 7 //
+ #define AR10_USBCFG_HDSEL_BIT 11 // 0:host, 1:device
+ #define AR10_USBCFG_HOST_END_BIT 10 // 0:little_end, 1:big_end
+ #define AR10_USBCFG_SLV_END_BIT 9 // 0:little_end, 1:big_end
+
+// #define default_param_dma_burst_size 4 //(ALL)
+ //WA for AHB
+ #define default_param_dma_burst_size 0 //(ALL)
+
+ #define default_param_speed IFXUSB_PARAM_SPEED_HIGH
+
+ #define default_param_max_transfer_size -1 //(Max, hwcfg)
+ #define default_param_max_packet_count -1 //(Max, hwcfg)
+ #define default_param_phy_utmi_width 16
+
+ #define default_param_turn_around_time_hs 6 //(NoChange) snpsid >= 0x4f54260a
+ #define default_param_turn_around_time_fs 6 //(NoChange) snpsid >= 0x4f54260a
+ #define default_param_timeout_cal_hs -1 //(NoChange)
+ #define default_param_timeout_cal_fs -1 //(NoChange)
+
+ #define default_param_data_fifo_size -1 //(Max, hwcfg)
+
+ #ifdef __IS_HOST__
+ #define default_param_host_channels -1 //(Max, hwcfg)
+ #define default_param_rx_fifo_size 240
+ #define default_param_nperio_tx_fifo_size 240
+ #define default_param_perio_tx_fifo_size 32
+ #endif //__IS_HOST__
+ #ifdef __IS_DEVICE__
+#if 0
+ #define default_param_rx_fifo_size 256
+ #define default_param_tx_fifo_size_00 -1
+ #define default_param_tx_fifo_size_01 -1
+ #define default_param_tx_fifo_size_02 -1
+#else
+ #define default_param_rx_fifo_size 256
+ #define default_param_tx_fifo_size_00 32
+ #define default_param_tx_fifo_size_01 200
+ #define default_param_tx_fifo_size_02 8
+#endif
+ #define default_param_tx_fifo_size_03 -1
+ #define default_param_tx_fifo_size_04 -1
+ #define default_param_tx_fifo_size_05 -1
+ #define default_param_tx_fifo_size_06 -1
+ #define default_param_tx_fifo_size_07 -1
+ #define default_param_tx_fifo_size_08 -1
+ #define default_param_tx_fifo_size_09 -1
+ #define default_param_tx_fifo_size_10 -1
+ #define default_param_tx_fifo_size_11 -1
+ #define default_param_tx_fifo_size_12 -1
+ #define default_param_tx_fifo_size_13 -1
+ #define default_param_tx_fifo_size_14 -1
+ #define default_param_tx_fifo_size_15 -1
+ #define default_param_dma_unalgned_tx -1
+ #define default_param_dma_unalgned_rx -1
+ #define default_param_thr_ctl -1
+ #define default_param_tx_thr_length -1
+ #define default_param_rx_thr_length -1
+ #endif //__IS_DEVICE__
+ #else // __IS_AR10__
+ #error "Please choose one platform!!"
+ #endif // __IS_VR9__
+
+#else //UEIP
+ #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ #define IFXUSB_IRQ 54
+ #define IFXUSB_IOMEM_BASE 0x1e101000
+ #define IFXUSB_FIFOMEM_BASE 0x1e120000
+ #define IFXUSB_FIFODBG_BASE 0x1e140000
+ #define IFXUSB_OC_IRQ 151
+
+
+ #ifndef DANUBE_RCU_BASE_ADDR
+ #define DANUBE_RCU_BASE_ADDR (0xBF203000)
+ #endif
+
+ #ifndef DANUBE_CGU
+ #define DANUBE_CGU (0xBF103000)
+ #endif
+ #ifndef DANUBE_CGU_IFCCR
+ #define DANUBE_CGU_IFCCR ((volatile unsigned long *)(DANUBE_CGU+ 0x0018))
+ #endif
+ #ifndef DANUBE_PMU
+ #define DANUBE_PMU (KSEG1+0x1F102000)
+ #endif
+ #ifndef DANUBE_PMU_PWDCR
+ #define DANUBE_PMU_PWDCR ((volatile unsigned long *)(DANUBE_PMU+0x001C))
+ #endif
+
+ #ifndef DANUBE_GPIO_P0_OUT
+ #define DANUBE_GPIO_P0_OUT (0xBF103000+0x10)
+ #define DANUBE_GPIO_P0_DIR (0xBF103000+0x18)
+ #define DANUBE_GPIO_P0_ALTSEL0 (0xBF103000+0x1C)
+ #define DANUBE_GPIO_P0_ALTSEL1 (0xBF103000+0x20)
+ #define DANUBE_GPIO_P0_OD (0xBF103000+0x24)
+ #define DANUBE_GPIO_P0_PUDSEL (0xBF103000+0x2C)
+ #define DANUBE_GPIO_P0_PUDEN (0xBF103000+0x30)
+ #define DANUBE_GPIO_P1_OUT (0xBF103000+0x40)
+ #define DANUBE_GPIO_P1_DIR (0xBF103000+0x48)
+ #define DANUBE_GPIO_P1_ALTSEL0 (0xBF103000+0x4C)
+ #define DANUBE_GPIO_P1_ALTSEL1 (0xBF103000+0x50)
+ #define DANUBE_GPIO_P1_OD (0xBF103000+0x54)
+ #define DANUBE_GPIO_P1_PUDSEL (0xBF103000+0x5C)
+ #define DANUBE_GPIO_P1_PUDEN (0xBF103000+0x60)
+ #endif
+
+
+ #define DANUBE_RCU_USBCFG ((volatile unsigned long *)(DANUBE_RCU_BASE_ADDR + 0x18))
+ #define DANUBE_RCU_RESET ((volatile unsigned long *)(DANUBE_RCU_BASE_ADDR + 0x10))
+ #define DANUBE_USBCFG_HDSEL_BIT 11 // 0:host, 1:device
+ #define DANUBE_USBCFG_HOST_END_BIT 10 // 0:little_end, 1:big_end
+ #define DANUBE_USBCFG_SLV_END_BIT 9 // 0:little_end, 1:big_end
+
+ #define default_param_dma_burst_size 4
+
+ #define default_param_speed IFXUSB_PARAM_SPEED_HIGH
+
+ #define default_param_max_transfer_size -1 //(Max, hwcfg)
+ #define default_param_max_packet_count -1 //(Max, hwcfg)
+ #define default_param_phy_utmi_width 16
+
+ #define default_param_turn_around_time_hs 4 //(NoChange)
+ #define default_param_turn_around_time_fs 4 //(NoChange)
+ #define default_param_timeout_cal_hs -1 //(NoChange)
+ #define default_param_timeout_cal_fs -1 //(NoChange)
+
+ #define default_param_data_fifo_size -1 //(Max, hwcfg)
+ #ifdef __IS_HOST__
+ #define default_param_host_channels -1 //(Max, hwcfg)
+ #define default_param_rx_fifo_size 640
+ #define default_param_nperio_tx_fifo_size 640
+ #define default_param_perio_tx_fifo_size 768
+ #endif //__IS_HOST__
+
+ #ifdef __IS_DEVICE__
+ #ifdef __DED_INTR__
+ #define default_param_rx_fifo_size 1024
+ #define default_param_nperio_tx_fifo_size 1016
+ #define default_param_perio_tx_fifo_size_01 8
+ #else
+ #define default_param_rx_fifo_size 1024
+ #define default_param_nperio_tx_fifo_size 1024
+ #define default_param_perio_tx_fifo_size_01 0
+ #endif
+ #define default_param_perio_tx_fifo_size_02 0
+ #define default_param_perio_tx_fifo_size_03 0
+ #define default_param_perio_tx_fifo_size_04 0
+ #define default_param_perio_tx_fifo_size_05 0
+ #define default_param_perio_tx_fifo_size_06 0
+ #define default_param_perio_tx_fifo_size_07 0
+ #define default_param_perio_tx_fifo_size_08 0
+ #define default_param_perio_tx_fifo_size_09 0
+ #define default_param_perio_tx_fifo_size_10 0
+ #define default_param_perio_tx_fifo_size_11 0
+ #define default_param_perio_tx_fifo_size_12 0
+ #define default_param_perio_tx_fifo_size_13 0
+ #define default_param_perio_tx_fifo_size_14 0
+ #define default_param_perio_tx_fifo_size_15 0
+ #endif //__IS_DEVICE__
+
+ #elif defined(__IS_AMAZON_SE__)
+ #include <asm/amazon_se/amazon_se.h>
+ //#include <asm/amazon_se/irq.h>
+
+ #define IFXUSB_IRQ 31
+ #define IFXUSB_IOMEM_BASE 0x1e101000
+ #define IFXUSB_FIFOMEM_BASE 0x1e120000
+ #define IFXUSB_FIFODBG_BASE 0x1e140000
+ #define IFXUSB_OC_IRQ 20
+
+ #define AMAZON_SE_RCU_USBCFG ((volatile unsigned long *)(AMAZON_SE_RCU_BASE_ADDR + 0x18))
+ #define AMAZON_SE_RCU_RESET ((volatile unsigned long *)(AMAZON_SE_RCU_BASE_ADDR + 0x10))
+ #define AMAZON_SE_USBCFG_HDSEL_BIT 11 // 0:host, 1:device
+ #define AMAZON_SE_USBCFG_HOST_END_BIT 10 // 0:little_end, 1:big_end
+ #define AMAZON_SE_USBCFG_SLV_END_BIT 9 // 0:little_end, 1:big_end
+
+ #ifndef AMAZON_SE_GPIO_P0_OUT
+ #define AMAZON_SE_GPIO_P0_OUT (0xBF103000+0x10)
+ #define AMAZON_SE_GPIO_P0_DIR (0xBF103000+0x18)
+ #define AMAZON_SE_GPIO_P0_ALTSEL0 (0xBF103000+0x1C)
+ #define AMAZON_SE_GPIO_P0_ALTSEL1 (0xBF103000+0x20)
+ #define AMAZON_SE_GPIO_P0_OD (0xBF103000+0x24)
+ #define AMAZON_SE_GPIO_P0_PUDSEL (0xBF103000+0x2C)
+ #define AMAZON_SE_GPIO_P0_PUDEN (0xBF103000+0x30)
+ #define AMAZON_SE_GPIO_P1_OUT (0xBF103000+0x40)
+ #define AMAZON_SE_GPIO_P1_DIR (0xBF103000+0x48)
+ #define AMAZON_SE_GPIO_P1_ALTSEL0 (0xBF103000+0x4C)
+ #define AMAZON_SE_GPIO_P1_ALTSEL1 (0xBF103000+0x50)
+ #define AMAZON_SE_GPIO_P1_OD (0xBF103000+0x54)
+ #define AMAZON_SE_GPIO_P1_PUDSEL (0xBF103000+0x5C)
+ #define AMAZON_SE_GPIO_P1_PUDEN (0xBF103000+0x60)
+ #endif
+
+
+ #ifndef AMAZON_SE_CGU
+ #define AMAZON_SE_CGU (0xBF103000)
+ #endif
+ #ifndef AMAZON_SE_CGU_IFCCR
+ #define AMAZON_SE_CGU_IFCCR ((volatile unsigned long *)(AMAZON_SE_CGU+ 0x0018))
+ #endif
+ #ifndef AMAZON_SE_PMU
+ #define AMAZON_SE_PMU (KSEG1+0x1F102000)
+ #endif
+ #ifndef AMAZON_SE_PMU_PWDCR
+ #define AMAZON_SE_PMU_PWDCR ((volatile unsigned long *)(AMAZON_SE_PMU+0x001C))
+ #endif
+
+ #define default_param_dma_burst_size 4
+
+ #define default_param_speed IFXUSB_PARAM_SPEED_HIGH
+
+ #define default_param_max_transfer_size -1 //(Max, hwcfg)
+ #define default_param_max_packet_count -1 //(Max, hwcfg)
+ #define default_param_phy_utmi_width 16
+
+ #define default_param_turn_around_time_hs 4 //(NoChange)
+ #define default_param_turn_around_time_fs 4 //(NoChange)
+ #define default_param_timeout_cal_hs -1 //(NoChange)
+ #define default_param_timeout_cal_fs -1 //(NoChange)
+
+ #define default_param_data_fifo_size -1 //(Max, hwcfg)
+
+ #ifdef __IS_HOST__
+ #define default_param_host_channels -1 //(Max, hwcfg)
+ #define default_param_rx_fifo_size 240
+ #define default_param_nperio_tx_fifo_size 240
+ #define default_param_perio_tx_fifo_size 32
+ #endif //__IS_HOST__
+ #ifdef __IS_DEVICE__
+ #ifdef __DED_INTR__
+ #define default_param_rx_fifo_size 256
+ #define default_param_nperio_tx_fifo_size 248
+ #define default_param_perio_tx_fifo_size_01 8
+ #else
+ #define default_param_rx_fifo_size 256
+ #define default_param_nperio_tx_fifo_size 256
+ #define default_param_perio_tx_fifo_size_01 0
+ #endif
+ #define default_param_perio_tx_fifo_size_02 0
+ #define default_param_perio_tx_fifo_size_03 0
+ #define default_param_perio_tx_fifo_size_04 0
+ #define default_param_perio_tx_fifo_size_05 0
+ #define default_param_perio_tx_fifo_size_06 0
+ #define default_param_perio_tx_fifo_size_07 0
+ #define default_param_perio_tx_fifo_size_08 0
+ #define default_param_perio_tx_fifo_size_09 0
+ #define default_param_perio_tx_fifo_size_10 0
+ #define default_param_perio_tx_fifo_size_11 0
+ #define default_param_perio_tx_fifo_size_12 0
+ #define default_param_perio_tx_fifo_size_13 0
+ #define default_param_perio_tx_fifo_size_14 0
+ #define default_param_perio_tx_fifo_size_15 0
+ #endif //__IS_DEVICE__
+
+ #elif defined(__IS_AR9__)
+ #define IFXUSB1_IRQ 54
+ #define IFXUSB1_IOMEM_BASE 0x1E101000
+ #define IFXUSB1_FIFOMEM_BASE 0x1E120000
+ #define IFXUSB1_FIFODBG_BASE 0x1E140000
+
+ #define IFXUSB2_IRQ 83
+ #define IFXUSB2_IOMEM_BASE 0x1E106000
+ #define IFXUSB2_FIFOMEM_BASE 0x1E1E0000
+ #define IFXUSB2_FIFODBG_BASE 0x1E1C0000
+
+ #define IFXUSB_OC_IRQ 60
+
+ #ifndef AMAZON_S_RCU_BASE_ADDR
+ #define AMAZON_S_RCU_BASE_ADDR (0xBF203000)
+ #endif
+
+ #ifndef AMAZON_S_CGU
+ #define AMAZON_S_CGU (0xBF103000)
+ #endif
+ #ifndef AMAZON_S_CGU_IFCCR
+ #define AMAZON_S_CGU_IFCCR ((volatile unsigned long *)(AMAZON_S_CGU+ 0x0018))
+ #endif
+
+ #ifndef AMAZON_S_PMU
+ #define AMAZON_S_PMU (KSEG1+0x1F102000)
+ #endif
+ #ifndef AMAZON_S_PMU_PWDCR
+ #define AMAZON_S_PMU_PWDCR ((volatile unsigned long *)(AMAZON_S_PMU+0x001C))
+ #endif
+
+ #ifndef AMAZON_S_GPIO_P0_OUT
+ #define AMAZON_S_GPIO_P0_OUT (0xBF103000+0x10)
+ #define AMAZON_S_GPIO_P0_DIR (0xBF103000+0x18)
+ #define AMAZON_S_GPIO_P0_ALTSEL0 (0xBF103000+0x1C)
+ #define AMAZON_S_GPIO_P0_ALTSEL1 (0xBF103000+0x20)
+ #define AMAZON_S_GPIO_P0_OD (0xBF103000+0x24)
+ #define AMAZON_S_GPIO_P0_PUDSEL (0xBF103000+0x2C)
+ #define AMAZON_S_GPIO_P0_PUDEN (0xBF103000+0x30)
+ #define AMAZON_S_GPIO_P1_OUT (0xBF103000+0x40)
+ #define AMAZON_S_GPIO_P1_DIR (0xBF103000+0x48)
+ #define AMAZON_S_GPIO_P1_ALTSEL0 (0xBF103000+0x4C)
+ #define AMAZON_S_GPIO_P1_ALTSEL1 (0xBF103000+0x50)
+ #define AMAZON_S_GPIO_P1_OD (0xBF103000+0x54)
+ #define AMAZON_S_GPIO_P1_PUDSEL (0xBF103000+0x5C)
+ #define AMAZON_S_GPIO_P1_PUDEN (0xBF103000+0x60)
+ #endif
+
+ #define AMAZON_S_RCU_USB1CFG ((volatile unsigned long *)(AMAZON_S_RCU_BASE_ADDR + 0x18))
+ #define AMAZON_S_RCU_USB2CFG ((volatile unsigned long *)(AMAZON_S_RCU_BASE_ADDR + 0x34))
+ #define AMAZON_S_RCU_USBRESET ((volatile unsigned long *)(AMAZON_S_RCU_BASE_ADDR + 0x10))
+ #define AMAZON_S_USBCFG_ARB 7 //
+ #define AMAZON_S_USBCFG_HDSEL_BIT 11 // 0:host, 1:device
+ #define AMAZON_S_USBCFG_HOST_END_BIT 10 // 0:little_end, 1:big_end
+ #define AMAZON_S_USBCFG_SLV_END_BIT 17 // 0:little_end, 1:big_end
+
+ #define default_param_dma_burst_size 4
+
+ #define default_param_speed IFXUSB_PARAM_SPEED_HIGH
+
+ #define default_param_max_transfer_size -1 //(Max, hwcfg)
+ #define default_param_max_packet_count -1 //(Max, hwcfg)
+ #define default_param_phy_utmi_width 16
+
+ #define default_param_turn_around_time_hs 4 //(NoChange)
+ #define default_param_turn_around_time_fs 4 //(NoChange)
+ #define default_param_timeout_cal_hs -1 //(NoChange)
+ #define default_param_timeout_cal_fs -1 //(NoChange)
+
+ #define default_param_data_fifo_size -1 //(Max, hwcfg)
+
+ #ifdef __IS_HOST__
+ #define default_param_host_channels -1 //(Max, hwcfg)
+ #define default_param_rx_fifo_size 240
+ #define default_param_nperio_tx_fifo_size 240
+ #define default_param_perio_tx_fifo_size 32
+ #endif //__IS_HOST__
+ #ifdef __IS_DEVICE__
+ #ifdef __DED_INTR__
+ #define default_param_rx_fifo_size 256
+ #define default_param_nperio_tx_fifo_size 248
+ #define default_param_perio_tx_fifo_size_01 8
+ #else
+ #define default_param_rx_fifo_size 256
+ #define default_param_nperio_tx_fifo_size 256
+ #define default_param_perio_tx_fifo_size_01 0
+ #endif
+ #define default_param_perio_tx_fifo_size_02 0
+ #define default_param_perio_tx_fifo_size_03 0
+ #define default_param_perio_tx_fifo_size_04 0
+ #define default_param_perio_tx_fifo_size_05 0
+ #define default_param_perio_tx_fifo_size_06 0
+ #define default_param_perio_tx_fifo_size_07 0
+ #define default_param_perio_tx_fifo_size_08 0
+ #define default_param_perio_tx_fifo_size_09 0
+ #define default_param_perio_tx_fifo_size_10 0
+ #define default_param_perio_tx_fifo_size_11 0
+ #define default_param_perio_tx_fifo_size_12 0
+ #define default_param_perio_tx_fifo_size_13 0
+ #define default_param_perio_tx_fifo_size_14 0
+ #define default_param_perio_tx_fifo_size_15 0
+ #endif //__IS_DEVICE__
+
+ #elif defined(__IS_VR9__)
+ #define IFXUSB1_IRQ 54
+ #define IFXUSB1_IOMEM_BASE 0x1E101000
+ #define IFXUSB1_FIFOMEM_BASE 0x1E120000
+ #define IFXUSB1_FIFODBG_BASE 0x1E140000
+
+ #define IFXUSB2_IRQ 83
+ #define IFXUSB2_IOMEM_BASE 0x1E106000
+ #define IFXUSB2_FIFOMEM_BASE 0x1E1E0000
+ #define IFXUSB2_FIFODBG_BASE 0x1E1C0000
+ #define IFXUSB_OC_IRQ 68
+
+ #ifndef AMAZON_S_RCU_BASE_ADDR
+ #define AMAZON_S_RCU_BASE_ADDR (0xBF203000)
+ #endif
+
+ #ifndef AMAZON_S_CGU
+ #define AMAZON_S_CGU (0xBF103000)
+ #endif
+ #ifndef AMAZON_S_CGU_IFCCR
+ #define AMAZON_S_CGU_IFCCR ((volatile unsigned long *)(AMAZON_S_CGU+ 0x0018))
+ #endif
+
+ #ifndef AMAZON_S_PMU
+ #define AMAZON_S_PMU (KSEG1+0x1F102000)
+ #endif
+ #ifndef AMAZON_S_PMU_PWDCR
+ #define AMAZON_S_PMU_PWDCR ((volatile unsigned long *)(AMAZON_S_PMU+0x001C))
+ #endif
+
+ #ifndef AMAZON_S_GPIO_P0_OUT
+ #define AMAZON_S_GPIO_P0_OUT (0xBF103000+0x10)
+ #define AMAZON_S_GPIO_P0_DIR (0xBF103000+0x18)
+ #define AMAZON_S_GPIO_P0_ALTSEL0 (0xBF103000+0x1C)
+ #define AMAZON_S_GPIO_P0_ALTSEL1 (0xBF103000+0x20)
+ #define AMAZON_S_GPIO_P0_OD (0xBF103000+0x24)
+ #define AMAZON_S_GPIO_P0_PUDSEL (0xBF103000+0x2C)
+ #define AMAZON_S_GPIO_P0_PUDEN (0xBF103000+0x30)
+ #define AMAZON_S_GPIO_P1_OUT (0xBF103000+0x40)
+ #define AMAZON_S_GPIO_P1_DIR (0xBF103000+0x48)
+ #define AMAZON_S_GPIO_P1_ALTSEL0 (0xBF103000+0x4C)
+ #define AMAZON_S_GPIO_P1_ALTSEL1 (0xBF103000+0x50)
+ #define AMAZON_S_GPIO_P1_OD (0xBF103000+0x54)
+ #define AMAZON_S_GPIO_P1_PUDSEL (0xBF103000+0x5C)
+ #define AMAZON_S_GPIO_P1_PUDEN (0xBF103000+0x60)
+ #endif
+
+ #define AMAZON_S_RCU_USB1CFG ((volatile unsigned long *)(AMAZON_S_RCU_BASE_ADDR + 0x18))
+ #define AMAZON_S_RCU_USB2CFG ((volatile unsigned long *)(AMAZON_S_RCU_BASE_ADDR + 0x34))
+ #define AMAZON_S_RCU_USBRESET ((volatile unsigned long *)(AMAZON_S_RCU_BASE_ADDR + 0x10))
+ #define AMAZON_S_USBCFG_ARB 7 //
+ #define AMAZON_S_USBCFG_HDSEL_BIT 11 // 0:host, 1:device
+ #define AMAZON_S_USBCFG_HOST_END_BIT 10 // 0:little_end, 1:big_end
+ #define AMAZON_S_USBCFG_SLV_END_BIT 17 // 0:little_end, 1:big_end
+
+ #define default_param_dma_burst_size 4 //(ALL)
+
+ #define default_param_speed IFXUSB_PARAM_SPEED_HIGH
+
+ #define default_param_max_transfer_size -1 //(Max, hwcfg)
+ #define default_param_max_packet_count -1 //(Max, hwcfg)
+ #define default_param_phy_utmi_width 16
+
+ #define default_param_turn_around_time_hs 6 //(NoChange) snpsid >= 0x4f54260a
+ #define default_param_turn_around_time_fs 6 //(NoChange) snpsid >= 0x4f54260a
+ #define default_param_timeout_cal_hs -1 //(NoChange)
+ #define default_param_timeout_cal_fs -1 //(NoChange)
+
+ #define default_param_data_fifo_size -1 //(Max, hwcfg)
+
+ #ifdef __IS_HOST__
+ #define default_param_host_channels -1 //(Max, hwcfg)
+ #define default_param_rx_fifo_size 240
+ #define default_param_nperio_tx_fifo_size 240
+ #define default_param_perio_tx_fifo_size 32
+ #endif //__IS_HOST__
+ #ifdef __IS_DEVICE__
+ #define default_param_rx_fifo_size 256
+ #define default_param_tx_fifo_size_00 -1
+ #define default_param_tx_fifo_size_01 -1
+ #define default_param_tx_fifo_size_02 -1
+ #define default_param_tx_fifo_size_03 -1
+ #define default_param_tx_fifo_size_04 -1
+ #define default_param_tx_fifo_size_05 -1
+ #define default_param_tx_fifo_size_06 -1
+ #define default_param_tx_fifo_size_07 -1
+ #define default_param_tx_fifo_size_08 -1
+ #define default_param_tx_fifo_size_09 -1
+ #define default_param_tx_fifo_size_10 -1
+ #define default_param_tx_fifo_size_11 -1
+ #define default_param_tx_fifo_size_12 -1
+ #define default_param_tx_fifo_size_13 -1
+ #define default_param_tx_fifo_size_14 -1
+ #define default_param_tx_fifo_size_15 -1
+ #define default_param_dma_unalgned_tx -1
+ #define default_param_dma_unalgned_rx -1
+ #define default_param_thr_ctl -1
+ #define default_param_tx_thr_length -1
+ #define default_param_rx_thr_length -1
+ #endif //__IS_DEVICE__
+ #else // __IS_VR9__
+ #error "Please choose one platform!!"
+ #endif // __IS_VR9__
+#endif //UEIP
+
+/*@}*//*IFXUSB_PLATEFORM_MEM_ADDR*/
+
+/////////////////////////////////////////////////////////////////////////
+
+#ifdef __IS_HOST__
+ #if defined(CONFIG_USB_HOST_IFX_FORCE_USB11) || defined(__FORCE_USB11__)
+ #undef default_param_speed
+ #define default_param_speed IFXUSB_PARAM_SPEED_FULL
+ #endif
+#endif
+#ifdef __IS_DEVICE__
+ #if !defined(CONFIG_USB_GADGET_DUALSPEED) || defined(__FORCE_USB11__)
+ #undef default_param_speed
+ #define default_param_speed IFXUSB_PARAM_SPEED_FULL
+ #endif
+#endif
+
+/////////////////////////////////////////////////////////////////////////
+
+static __inline__ void UDELAY( const uint32_t _usecs )
+{
+ udelay( _usecs );
+}
+
+static __inline__ void MDELAY( const uint32_t _msecs )
+{
+ mdelay( _msecs );
+}
+
+static __inline__ void SPIN_LOCK( spinlock_t *_lock )
+{
+ spin_lock(_lock);
+}
+
+static __inline__ void SPIN_UNLOCK( spinlock_t *_lock )
+{
+ spin_unlock(_lock);
+}
+
+#define SPIN_LOCK_IRQSAVE( _l, _f ) \
+ { \
+ spin_lock_irqsave(_l,_f); \
+ }
+
+#define SPIN_UNLOCK_IRQRESTORE( _l,_f ) \
+ { \
+ spin_unlock_irqrestore(_l,_f); \
+ }
+
+/////////////////////////////////////////////////////////////////////////
+/*!
+ \addtogroup IFXUSB_DBG_ROUTINE
+ */
+/*@{*/
+#ifdef __IS_HOST__
+ extern uint32_t h_dbg_lvl;
+#endif
+
+#ifdef __IS_DEVICE__
+ extern uint32_t d_dbg_lvl;
+#endif
+
+/*! \brief When debug level has the DBG_CIL bit set, display CIL Debug messages. */
+#define DBG_CIL (0x2)
+/*! \brief When debug level has the DBG_CILV bit set, display CIL Verbose debug messages */
+#define DBG_CILV (0x20)
+/*! \brief When debug level has the DBG_PCD bit set, display PCD (Device) debug messages */
+#define DBG_PCD (0x4)
+/*! \brief When debug level has the DBG_PCDV set, display PCD (Device) Verbose debug messages */
+#define DBG_PCDV (0x40)
+/*! \brief When debug level has the DBG_HCD bit set, display Host debug messages */
+#define DBG_HCD (0x8)
+/*! \brief When debug level has the DBG_HCDV bit set, display Verbose Host debug messages */
+#define DBG_HCDV (0x80)
+/*! \brief When debug level has the DBG_HCD_URB bit set, display enqueued URBs in host mode. */
+#define DBG_HCD_URB (0x800)
+/*! \brief When debug level has any bit set, display debug messages */
+#define DBG_ANY (0xFF)
+/*! \brief All debug messages off */
+#define DBG_OFF 0
+
+#define DBG_ENTRY (0x8000)
+
+#define IFXUSB "IFXUSB: "
+
+/*!
+ \fn inline uint32_t SET_DEBUG_LEVEL( const uint32_t _new )
+ \brief Set the Debug Level variable.
+ \param _new 32-bit mask of debug level.
+ \return previous debug level
+ */
+static inline uint32_t SET_DEBUG_LEVEL( const uint32_t _new )
+{
+ #ifdef __IS_HOST__
+ uint32_t old = h_dbg_lvl;
+ h_dbg_lvl = _new;
+ #endif
+
+ #ifdef __IS_DEVICE__
+ uint32_t old = d_dbg_lvl;
+ d_dbg_lvl = _new;
+ #endif
+ return old;
+}
+
+#ifdef __DEBUG__
+ #ifdef __IS_HOST__
+ # define IFX_DEBUGPL(lvl, x...) do{ if ((lvl)&h_dbg_lvl)printk( KERN_DEBUG IFXUSB x ); }while(0)
+ # define CHK_DEBUG_LEVEL(level) ((level) & h_dbg_lvl)
+ #endif
+
+ #ifdef __IS_DEVICE__
+ # define IFX_DEBUGPL(lvl, x...) do{ if ((lvl)&d_dbg_lvl)printk( KERN_DEBUG IFXUSB x ); }while(0)
+ # define CHK_DEBUG_LEVEL(level) ((level) & d_dbg_lvl)
+ #endif
+
+ # define IFX_DEBUGP(x...) IFX_DEBUGPL(DBG_ANY, x )
+#else
+ # define IFX_DEBUGPL(lvl, x...) do{}while(0)
+ # define IFX_DEBUGP(x...)
+ # define CHK_DEBUG_LEVEL(level) (0)
+#endif //__DEBUG__
+
+/* Print an Error message. */
+#define IFX_ERROR(x...) printk( KERN_ERR IFXUSB x )
+/* Print a Warning message. */
+#define IFX_WARN(x...) printk( KERN_WARNING IFXUSB x )
+/* Print a notice (normal but significant message). */
+#define IFX_NOTICE(x...) printk( KERN_NOTICE IFXUSB x )
+/* Basic message printing. */
+#define IFX_PRINT(x...) printk( KERN_INFO IFXUSB x )
+
+/*@}*//*IFXUSB_DBG_ROUTINE*/
+
+
+#endif //__IFXUSB_PLAT_H__
+
diff --git a/package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxusb_regs.h.svn-base b/package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxusb_regs.h.svn-base
new file mode 100644
index 0000000..4b43821
--- /dev/null
+++ b/package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxusb_regs.h.svn-base
@@ -0,0 +1,1471 @@
+/*****************************************************************************
+ ** FILE NAME : ifxusb_regs.h
+ ** PROJECT : IFX USB sub-system V3
+ ** MODULES : IFX USB sub-system Host and Device driver
+ ** SRC VERSION : 3.2
+ ** DATE : 1/Jan/2011
+ ** AUTHOR : Chen, Howard
+ ** DESCRIPTION : This file contains the data structures for accessing the IFXUSB core
+ ** registers.
+ ** The application interfaces with the USB core by reading from and
+ ** writing to the Control and Status Register (CSR) space through the
+ ** AHB Slave interface. These registers are 32 bits wide, and the
+ ** addresses are 32-bit-block aligned.
+ ** CSRs are classified as follows:
+ ** - Core Global Registers
+ ** - Device Mode Registers
+ ** - Device Global Registers
+ ** - Device Endpoint Specific Registers
+ ** - Host Mode Registers
+ ** - Host Global Registers
+ ** - Host Port CSRs
+ ** - Host Channel Specific Registers
+ **
+ ** Only the Core Global registers can be accessed in both Device and
+ ** Host modes. When the USB core is operating in one mode, either
+ ** Device or Host, the application must not access registers from the
+ ** other mode. When the core switches from one mode to another, the
+ ** registers in the new mode of operation must be reprogrammed as they
+ ** would be after a power-on reset.
+ ** FUNCTIONS :
+ ** COMPILER : gcc
+ ** REFERENCE : Synopsys DWC-OTG Driver 2.7
+ ** COPYRIGHT : Copyright (c) 2010
+ ** LANTIQ DEUTSCHLAND GMBH,
+ ** Am Campeon 3, 85579 Neubiberg, Germany
+ **
+ ** 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 of the License, or
+ ** (at your option) any later version.
+ **
+ ** Version Control Section **
+ ** $Author$
+ ** $Date$
+ ** $Revisions$
+ ** $Log$ Revision history
+*****************************************************************************/
+/******************************************************************************
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 10 NOV 2008 Wu Qi Ming Initial Version, to comply with COC
+*******************************************************************************/
+
+
+/*
+ * This file contains code fragments from Synopsys HS OTG Linux Software Driver.
+ * For this code the following notice is applicable:
+ *
+ * ==========================================================================
+ *
+ * Synopsys HS OTG Linux Software Driver and documentation (hereinafter,
+ * "Software") is an Unsupported proprietary work of Synopsys, Inc. unless
+ * otherwise expressly agreed to in writing between Synopsys and you.
+ *
+ * The Software IS NOT an item of Licensed Software or Licensed Product under
+ * any End User Software License Agreement or Agreement for Licensed Product
+ * with Synopsys or any supplement thereto. You are permitted to use and
+ * redistribute this Software in source and binary forms, with or without
+ * modification, provided that redistributions of source code must retain this
+ * notice. You may not view, use, disclose, copy or distribute this file or
+ * any information contained herein except pursuant to this license grant from
+ * Synopsys. If you do not agree with this notice, including the disclaimer
+ * below, then you are not authorized to use the Software.
+ *
+ * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" BASIS
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ * ========================================================================== */
+
+
+/*!
+ \defgroup IFXUSB_CSR_DEFINITION Control and Status Register bit-map definition
+ \ingroup IFXUSB_DRIVER_V3
+ \brief Data structures for accessing the IFXUSB core registers.
+ The application interfaces with the USB core by reading from and
+ writing to the Control and Status Register (CSR) space through the
+ AHB Slave interface. These registers are 32 bits wide, and the
+ addresses are 32-bit-block aligned.
+ CSRs are classified as follows:
+ - Core Global Registers
+ - Device Mode Registers
+ - Device Global Registers
+ - Device Endpoint Specific Registers
+ - Host Mode Registers
+ - Host Global Registers
+ - Host Port CSRs
+ - Host Channel Specific Registers
+
+ Only the Core Global registers can be accessed in both Device andHost modes.
+ When the USB core is operating in one mode, either Device or Host, the
+ application must not access registers from the other mode. When the core
+ switches from one mode to another, the registers in the new mode of operation
+ must be reprogrammed as they would be after a power-on reset.
+ */
+
+/*!
+ \defgroup IFXUSB_CSR_DEVICE_GLOBAL_REG Device Mode Registers
+ \ingroup IFXUSB_CSR_DEFINITION
+ \brief Bit-mapped structure to access Device Mode Global Registers
+ */
+
+/*!
+ \defgroup IFXUSB_CSR_DEVICE_EP_REG Device Mode EP Registers
+ \ingroup IFXUSB_CSR_DEFINITION
+ \brief Bit-mapped structure to access Device Mode EP Registers
+ There will be one set of endpoint registers per logical endpoint
+ implemented.
+ These registers are visible only in Device mode and must not be
+ accessed in Host mode, as the results are unknown.
+ */
+
+/*!
+ \defgroup IFXUSB_CSR_DEVICE_DMA_DESC Device mode scatter dma descriptor strusture
+ \ingroup IFXUSB_CSR_DEFINITION
+ \brief Bit-mapped structure to DMA descriptor
+ */
+
+
+/*!
+ \defgroup IFXUSB_CSR_HOST_GLOBAL_REG Host Mode Registers
+ \ingroup IFXUSB_CSR_DEFINITION
+ \brief Bit-mapped structure to access Host Mode Global Registers
+ */
+
+/*!
+ \defgroup IFXUSB_CSR_HOST_HC_REG Host Mode HC Registers
+ \ingroup IFXUSB_CSR_DEFINITION
+ \brief Bit-mapped structure to access Host Mode Host Channel Registers
+ There will be one set of endpoint registers per host channel
+ implemented.
+ These registers are visible only in Host mode and must not be
+ accessed in Device mode, as the results are unknown.
+ */
+
+/*!
+ \defgroup IFXUSB_CSR_PWR_CLK_GATING_REG Power and Clock Gating Control Register
+ \ingroup IFXUSB_CSR_DEFINITION
+ \brief Bit-mapped structure to Power and Clock Gating Control Register
+ */
+
+/*!
+ \defgroup IFXUSB_CSR_CORE_GLOBAL_REG Core Global Registers
+ \ingroup IFXUSB_CSR_DEFINITION
+ \brief Bit-mapped structure to access Core Global Registers
+ */
+
+/*!
+ \defgroup IFXUSB_CSR_CORE_GLOBAL_REG Core Global Registers
+ \ingroup IFXUSB_CSR_DEFINITION
+ \brief Bit-mapped structure to access Core Global Registers
+ */
+
+
+
+/*!
+ \defgroup IFXUSB_CSR_ACCESS_MACROS Macros to manipulate CSRs
+ \ingroup IFXUSB_CSR_DEFINITION
+ \brief Macros to manipulate CSRs
+ */
+
+
+
+
+
+
+/*!
+ \file ifxusb_regs.h
+ \ingroup IFXUSB_DRIVER_V3
+ \brief This file contains the data structures for accessing the IFXUSB core registers.
+ */
+
+
+#ifndef __IFXUSB_REGS_H__
+#define __IFXUSB_REGS_H__
+
+/****************************************************************************/
+
+#define MAX_PERIO_FIFOS 15 /** Maximum number of Periodic FIFOs */
+#define MAX_TX_FIFOS 15 /** Maximum number of Periodic FIFOs */
+#define MAX_EPS_CHANNELS 16 /** Maximum number of Endpoints/HostChannels */
+
+/****************************************************************************/
+
+//#define __RecordRegRW__
+
+/*!
+ \fn static __inline__ uint32_t ifxusb_rreg( volatile uint32_t *_reg)
+ \brief Reads the content of a register.
+ \param _reg address of register to read.
+ \return contents of the register.
+ \ingroup IFXUSB_CSR_ACCESS_MACROS
+ */
+static __inline__ uint32_t ifxusb_rreg( volatile uint32_t *_reg)
+{
+ #ifdef __RecordRegRW__
+ uint32_t r;
+ r=*(_reg);
+ return (r);
+ #else
+ return (*(_reg));
+ #endif
+};
+
+
+/*!
+ \fn static __inline__ void ifxusb_wreg( volatile uint32_t *_reg, const uint32_t _value)
+ \brief Writes a register with a 32 bit value.
+ \param _reg address of register to write.
+ \param _value value to write to _reg.
+ \ingroup IFXUSB_CSR_ACCESS_MACROS
+ */
+static __inline__ void ifxusb_wreg( volatile uint32_t *_reg, const uint32_t _value)
+{
+ #ifdef __RecordRegRW__
+ printk(KERN_INFO "[W %p<-%08X]\n",_reg,_value);
+ #else
+ *(_reg)=_value;
+ #endif
+};
+
+/*!
+ \fn static __inline__ void ifxusb_mreg( volatile uint32_t *_reg, const uint32_t _clear_mask, const uint32_t _set_mask)
+ \brief Modifies bit values in a register. Using the
+ algorithm: (reg_contents & ~clear_mask) | set_mask.
+ \param _reg address of register to modify.
+ \param _clear_mask bit mask to be cleared.
+ \param _set_mask bit mask to be set.
+ \ingroup IFXUSB_CSR_ACCESS_MACROS
+ */
+static __inline__ void ifxusb_mreg( volatile uint32_t *_reg, const uint32_t _clear_mask, const uint32_t _set_mask)
+{
+ uint32_t v;
+ #ifdef __RecordRegRW__
+ uint32_t r;
+ v= *(_reg);
+ r=v;
+ r&=(~_clear_mask);
+ r|= _set_mask;
+ *(_reg)=r ;
+ printk(KERN_INFO "[M %p->%08X+%08X/%08X<-%08X]\n",_reg,r,_clear_mask,_set_mask,r);
+ #else
+ v= *(_reg);
+ v&=(~_clear_mask);
+ v|= _set_mask;
+ *(_reg)=v ;
+ #endif
+};
+
+/****************************************************************************/
+
+/*!
+ \addtogroup IFXUSB_CSR_CORE_GLOBAL_REG
+ */
+/*@{*/
+
+/*! typedef ifxusb_core_global_regs_t
+ \brief IFXUSB Core registers .
+ The ifxusb_core_global_regs structure defines the size
+ and relative field offsets for the Core Global registers.
+ */
+typedef struct ifxusb_core_global_regs
+{
+ volatile uint32_t gotgctl; /*!< 000h OTG Control and Status Register. */
+ volatile uint32_t gotgint; /*!< 004h OTG Interrupt Register. */
+ volatile uint32_t gahbcfg; /*!< 008h Core AHB Configuration Register. */
+ volatile uint32_t gusbcfg; /*!< 00Ch Core USB Configuration Register. */
+ volatile uint32_t grstctl; /*!< 010h Core Reset Register. */
+ volatile uint32_t gintsts; /*!< 014h Core Interrupt Register. */
+ volatile uint32_t gintmsk; /*!< 018h Core Interrupt Mask Register. */
+ volatile uint32_t grxstsr; /*!< 01Ch Receive Status Queue Read Register (Read Only). */
+ volatile uint32_t grxstsp; /*!< 020h Receive Status Queue Read & POP Register (Read Only). */
+ volatile uint32_t grxfsiz; /*!< 024h Receive FIFO Size Register. */
+ volatile uint32_t gnptxfsiz; /*!< 028h Non Periodic Transmit FIFO Size Register. */
+ volatile uint32_t gnptxsts; /*!< 02Ch Non Periodic Transmit FIFO/Queue Status Register (Read Only). */
+ volatile uint32_t gi2cctl; /*!< 030h I2C Access Register. */
+ volatile uint32_t gpvndctl; /*!< 034h PHY Vendor Control Register. */
+ volatile uint32_t ggpio; /*!< 038h General Purpose Input/Output Register. */
+ volatile uint32_t guid; /*!< 03Ch User ID Register. */
+ volatile uint32_t gsnpsid; /*!< 040h Synopsys ID Register (Read Only). */
+ volatile uint32_t ghwcfg1; /*!< 044h User HW Config1 Register (Read Only). */
+ volatile uint32_t ghwcfg2; /*!< 048h User HW Config2 Register (Read Only). */
+ volatile uint32_t ghwcfg3; /*!< 04Ch User HW Config3 Register (Read Only). */
+ volatile uint32_t ghwcfg4; /*!< 050h User HW Config4 Register (Read Only). */
+ volatile uint32_t reserved[43]; /*!< 054h Reserved 054h-0FFh */
+ volatile uint32_t hptxfsiz; /*!< 100h Host Periodic Transmit FIFO Size Register. */
+ volatile uint32_t dptxfsiz_dieptxf[15];/*!< 104h + (FIFO_Number-1)*04h, 1 <= FIFO Number <= 15.
+ Device Periodic Transmit FIFO#n Register if dedicated
+ fifos are disabled, otherwise Device Transmit FIFO#n
+ Register.
+ */
+} ifxusb_core_global_regs_t;
+
+/*!
+ \brief Bits of the Core OTG Control and Status Register (GOTGCTL).
+ */
+typedef union gotgctl_data
+{
+ uint32_t d32;
+ struct{
+ unsigned reserved21_31 : 11;
+ unsigned currmod : 1 ; /*!< 20 */
+ unsigned bsesvld : 1 ; /*!< 19 */
+ unsigned asesvld : 1 ; /*!< 18 */
+ unsigned reserved17 : 1 ;
+ unsigned conidsts : 1 ; /*!< 16 */
+ unsigned reserved12_15 : 4 ;
+ unsigned devhnpen : 1 ; /*!< 11 */
+ unsigned hstsethnpen : 1 ; /*!< 10 */
+ unsigned hnpreq : 1 ; /*!< 09 */
+ unsigned hstnegscs : 1 ; /*!< 08 */
+ unsigned reserved2_7 : 6 ;
+ unsigned sesreq : 1 ; /*!< 01 */
+ unsigned sesreqscs : 1 ; /*!< 00 */
+ } b;
+} gotgctl_data_t;
+
+/*!
+ \brief Bit fields of the Core OTG Interrupt Register (GOTGINT).
+ */
+typedef union gotgint_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned reserved31_20 : 12;
+ unsigned debdone : 1 ; /*!< 19 Debounce Done */
+ unsigned adevtoutchng : 1 ; /*!< 18 A-Device Timeout Change */
+ unsigned hstnegdet : 1 ; /*!< 17 Host Negotiation Detected */
+ unsigned reserver10_16 : 7 ;
+ unsigned hstnegsucstschng : 1 ; /*!< 09 Host Negotiation Success Status Change */
+ unsigned sesreqsucstschng : 1 ; /*!< 08 Session Request Success Status Change */
+ unsigned reserved3_7 : 5 ;
+ unsigned sesenddet : 1 ; /*!< 02 Session End Detected */
+ unsigned reserved0_1 : 2 ;
+ } b;
+} gotgint_data_t;
+
+/*!
+ \brief Bit fields of the Core AHB Configuration Register (GAHBCFG).
+ */
+typedef union gahbcfg_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned reserved9_31 : 23;
+ unsigned ptxfemplvl : 1 ; /*!< 08 Periodic FIFO empty level trigger condition*/
+ unsigned nptxfemplvl : 1 ; /*!< 07 Non-Periodic FIFO empty level trigger condition*/
+ #define IFXUSB_GAHBCFG_TXFEMPTYLVL_EMPTY 1
+ #define IFXUSB_GAHBCFG_TXFEMPTYLVL_HALFEMPTY 0
+ unsigned reserved : 1 ;
+ unsigned dmaenable : 1 ; /*!< 05 DMA enable*/
+ #define IFXUSB_GAHBCFG_DMAENABLE 1
+ unsigned hburstlen : 4 ; /*!< 01-04 DMA Burst-length*/
+ #define IFXUSB_GAHBCFG_INT_DMA_BURST_SINGLE 0
+ #define IFXUSB_GAHBCFG_INT_DMA_BURST_INCR 1
+ #define IFXUSB_GAHBCFG_INT_DMA_BURST_INCR4 3
+ #define IFXUSB_GAHBCFG_INT_DMA_BURST_INCR8 5
+ #define IFXUSB_GAHBCFG_INT_DMA_BURST_INCR16 7
+ unsigned glblintrmsk : 1 ; /*!< 00 USB Global Interrupt Enable */
+ #define IFXUSB_GAHBCFG_GLBINT_ENABLE 1
+ } b;
+} gahbcfg_data_t;
+
+/*!
+ \brief Bit fields of the Core USB Configuration Register (GUSBCFG).
+*/
+typedef union gusbcfg_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned reserved31 : 1;
+ unsigned ForceDevMode : 1; /*!< 30 Force Device Mode */
+ unsigned ForceHstMode : 1; /*!< 29 Force Host Mode */
+ unsigned TxEndDelay : 1; /*!< 28 Tx End Delay */
+ unsigned reserved2723 : 5;
+ unsigned term_sel_dl_pulse : 1; /*!< 22 TermSel DLine Pulsing Selection */
+ unsigned reserved2117 : 5;
+ unsigned otgutmifssel : 1; /*!< 16 UTMIFS Select */
+ unsigned phylpwrclksel : 1; /*!< 15 PHY Low-Power Clock Select */
+ unsigned reserved14 : 1;
+ unsigned usbtrdtim : 4; /*!< 13-10 USB Turnaround Time */
+ unsigned hnpcap : 1; /*!< 09 HNP-Capable */
+ unsigned srpcap : 1; /*!< 08 SRP-Capable */
+ unsigned reserved07 : 1;
+ unsigned physel : 1; /*!< 06 USB 2.0 High-Speed PHY or
+ USB 1.1 Full-Speed Serial
+ Transceiver Select */
+ unsigned fsintf : 1; /*!< 05 Full-Speed Serial Interface Select */
+ unsigned ulpi_utmi_sel : 1; /*!< 04 ULPI or UTMI+ Select */
+ unsigned phyif : 1; /*!< 03 PHY Interface */
+ unsigned toutcal : 3; /*!< 00-02 HS/FS Timeout Calibration */
+ }b;
+} gusbcfg_data_t;
+
+/*!
+ \brief Bit fields of the Core Reset Register (GRSTCTL).
+ */
+typedef union grstctl_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned ahbidle : 1; /*!< 31 AHB Master Idle. Indicates the AHB Master State
+ Machine is in IDLE condition. */
+ unsigned dmareq : 1; /*!< 30 DMA Request Signal. Indicated DMA request is in
+ probress. Used for debug purpose. */
+ unsigned reserved11_29 :19;
+ unsigned txfnum : 5; /*!< 10-06 TxFIFO Number (TxFNum) to be flushed.
+ 0x00: Non Periodic TxFIFO Flush or TxFIFO 0
+ 0x01-0x0F: Periodic TxFIFO Flush or TxFIFO n
+ 0x10: Flush all TxFIFO
+ */
+ unsigned txfflsh : 1; /*!< 05 TxFIFO Flush */
+ unsigned rxfflsh : 1; /*!< 04 RxFIFO Flush */
+ unsigned intknqflsh : 1; /*!< 03 In Token Sequence Learning Queue Flush (Device Only) */
+ unsigned hstfrm : 1; /*!< 02 Host Frame Counter Reset (Host Only) */
+ unsigned hsftrst : 1; /*!< 01 Hclk Soft Reset */
+
+ unsigned csftrst : 1; /*!< 00 Core Soft Reset
+ The application can flush the control logic in the
+ entire core using this bit. This bit resets the
+ pipelines in the AHB Clock domain as well as the
+ PHY Clock domain.
+ The state machines are reset to an IDLE state, the
+ control bits in the CSRs are cleared, all the
+ transmit FIFOs and the receive FIFO are flushed.
+ The status mask bits that control the generation of
+ the interrupt, are cleared, to clear the
+ interrupt. The interrupt status bits are not
+ cleared, so the application can get the status of
+ any events that occurred in the core after it has
+ set this bit.
+ Any transactions on the AHB are terminated as soon
+ as possible following the protocol. Any
+ transactions on the USB are terminated immediately.
+ The configuration settings in the CSRs are
+ unchanged, so the software doesn't have to
+ reprogram these registers (Device
+ Configuration/Host Configuration/Core System
+ Configuration/Core PHY Configuration).
+ The application can write to this bit, any time it
+ wants to reset the core. This is a self clearing
+ bit and the core clears this bit after all the
+ necessary logic is reset in the core, which may
+ take several clocks, depending on the current state
+ of the core.
+ */
+ }b;
+} grstctl_t;
+
+/*!
+ \brief Bit fields of the Core Interrupt Mask Register (GINTMSK) and
+ Core Interrupt Register (GINTSTS).
+ */
+typedef union gint_data
+{
+ uint32_t d32;
+ #define IFXUSB_SOF_INTR_MASK 0x0008
+ struct
+ {
+ unsigned wkupintr : 1; /*!< 31 Resume/Remote Wakeup Detected Interrupt */
+ unsigned sessreqintr : 1; /*!< 30 Session Request/New Session Detected Interrupt */
+ unsigned disconnect : 1; /*!< 29 Disconnect Detected Interrupt */
+ unsigned conidstschng : 1; /*!< 28 Connector ID Status Change */
+ unsigned reserved27 : 1;
+ unsigned ptxfempty : 1; /*!< 26 Periodic TxFIFO Empty */
+ unsigned hcintr : 1; /*!< 25 Host Channels Interrupt */
+ unsigned portintr : 1; /*!< 24 Host Port Interrupt */
+ unsigned reserved23 : 1;
+ unsigned fetsuspmsk : 1; /*!< 22 Data Fetch Suspended */
+ unsigned incomplisoout : 1; /*!< 21 Incomplete IsochronousOUT/Period Transfer */
+ unsigned incomplisoin : 1; /*!< 20 Incomplete Isochronous IN Transfer */
+ unsigned outepintr : 1; /*!< 19 OUT Endpoints Interrupt */
+ unsigned inepintr : 1; /*!< 18 IN Endpoints Interrupt */
+ unsigned epmismatch : 1; /*!< 17 Endpoint Mismatch Interrupt */
+ unsigned reserved16 : 1;
+ unsigned eopframe : 1; /*!< 15 End of Periodic Frame Interrupt */
+ unsigned isooutdrop : 1; /*!< 14 Isochronous OUT Packet Dropped Interrupt */
+ unsigned enumdone : 1; /*!< 13 Enumeration Done */
+ unsigned usbreset : 1; /*!< 12 USB Reset */
+ unsigned usbsuspend : 1; /*!< 11 USB Suspend */
+ unsigned erlysuspend : 1; /*!< 10 Early Suspend */
+ unsigned i2cintr : 1; /*!< 09 I2C Interrupt */
+ unsigned reserved8 : 1;
+ unsigned goutnakeff : 1; /*!< 07 Global OUT NAK Effective */
+ unsigned ginnakeff : 1; /*!< 06 Global Non-periodic IN NAK Effective */
+ unsigned nptxfempty : 1; /*!< 05 Non-periodic TxFIFO Empty */
+ unsigned rxstsqlvl : 1; /*!< 04 Receive FIFO Non-Empty */
+ unsigned sofintr : 1; /*!< 03 Start of (u)Frame */
+ unsigned otgintr : 1; /*!< 02 OTG Interrupt */
+ unsigned modemismatch : 1; /*!< 01 Mode Mismatch Interrupt */
+ unsigned reserved0 : 1;
+ } b;
+} gint_data_t;
+
+/*!
+ \brief Bit fields in the Receive Status Read and Pop Registers (GRXSTSR, GRXSTSP)
+ */
+typedef union grxsts_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned reserved : 7;
+ unsigned fn : 4; /*!< 24-21 Frame Number */
+ unsigned pktsts : 4; /*!< 20-17 Packet Status */
+ #define IFXUSB_DSTS_DATA_UPDT 0x2 // OUT Data Packet
+ #define IFXUSB_DSTS_XFER_COMP 0x3 // OUT Data Transfer Complete
+ #define IFXUSB_DSTS_GOUT_NAK 0x1 // Global OUT NAK
+ #define IFXUSB_DSTS_SETUP_COMP 0x4 // Setup Phase Complete
+ #define IFXUSB_DSTS_SETUP_UPDT 0x6 // SETUP Packet
+ unsigned dpid : 2; /*!< 16-15 Data PID */
+ unsigned bcnt :11; /*!< 14-04 Byte Count */
+ unsigned epnum : 4; /*!< 03-00 Endpoint Number */
+ } db;
+ struct
+ {
+ unsigned reserved :11;
+ unsigned pktsts : 4; /*!< 20-17 Packet Status */
+ #define IFXUSB_HSTS_DATA_UPDT 0x2 // OUT Data Packet
+ #define IFXUSB_HSTS_XFER_COMP 0x3 // OUT Data Transfer Complete
+ #define IFXUSB_HSTS_DATA_TOGGLE_ERR 0x5 // DATA TOGGLE Error
+ #define IFXUSB_HSTS_CH_HALTED 0x7 // Channel Halted
+ unsigned dpid : 2; /*!< 16-15 Data PID */
+ unsigned bcnt :11; /*!< 14-04 Byte Count */
+ unsigned chnum : 4; /*!< 03-00 Channel Number */
+ } hb;
+} grxsts_data_t;
+
+/*!
+ \brief Bit fields in the FIFO Size Registers (HPTXFSIZ, GNPTXFSIZ, DPTXFSIZn).
+ */
+typedef union fifosize_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned depth : 16; /*!< 31-16 TxFIFO Depth (in DWord)*/
+ unsigned startaddr : 16; /*!< 15-00 RAM Starting address */
+ } b;
+} fifosize_data_t;
+
+/*!
+ \brief Bit fields in the Non-Periodic Transmit FIFO/Queue Status Register (GNPTXSTS).
+ */
+
+typedef union gnptxsts_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned reserved : 1;
+ unsigned nptxqtop_chnep : 4; /*!< 30-27 Channel/EP Number of top of the Non-Periodic
+ Transmit Request Queue
+ */
+ unsigned nptxqtop_token : 2; /*!< 26-25 Token Type top of the Non-Periodic
+ Transmit Request Queue
+ 0 - IN/OUT
+ 1 - Zero Length OUT
+ 2 - PING/Complete Split
+ 3 - Channel Halt
+ */
+ unsigned nptxqtop_terminate : 1; /*!< 24 Terminate (Last entry for the selected
+ channel/EP)*/
+ unsigned nptxqspcavail : 8; /*!< 23-16 Transmit Request Queue Space Available */
+ unsigned nptxfspcavail :16; /*!< 15-00 TxFIFO Space Avail (in DWord)*/
+ }b;
+} gnptxsts_data_t;
+
+
+/*!
+ \brief Bit fields in the Transmit FIFO Status Register (DTXFSTS).
+ */
+typedef union dtxfsts_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned reserved : 16;
+ unsigned txfspcavail : 16; /*!< 15-00 TxFIFO Space Avail (in DWord)*/
+ }b;
+} dtxfsts_data_t;
+
+
+/*!
+ \brief Bit fields in the I2C Control Register (I2CCTL).
+ */
+typedef union gi2cctl_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned bsydne : 1; /*!< 31 I2C Busy/Done*/
+ unsigned rw : 1; /*!< 30 Read/Write Indicator */
+ unsigned reserved : 2;
+ unsigned i2cdevaddr : 2; /*!< 27-26 I2C Device Address */
+ unsigned i2csuspctl : 1; /*!< 25 I2C Suspend Control */
+ unsigned ack : 1; /*!< 24 I2C ACK */
+ unsigned i2cen : 1; /*!< 23 I2C Enable */
+ unsigned addr : 7; /*!< 22-16 I2C Address */
+ unsigned regaddr : 8; /*!< 15-08 I2C Register Addr */
+ unsigned rwdata : 8; /*!< I2C Read/Write Data */
+ } b;
+} gi2cctl_data_t;
+
+
+/*!
+ \brief Bit fields in the User HW Config1 Register.
+ */
+typedef union hwcfg1_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned ep_dir15 : 2; /*!< Direction of each EP
+ 0: BIDIR (IN and OUT) endpoint
+ 1: IN endpoint
+ 2: OUT endpoint
+ 3: Reserved
+ */
+ unsigned ep_dir14 : 2;
+ unsigned ep_dir13 : 2;
+ unsigned ep_dir12 : 2;
+ unsigned ep_dir11 : 2;
+ unsigned ep_dir10 : 2;
+ unsigned ep_dir09 : 2;
+ unsigned ep_dir08 : 2;
+ unsigned ep_dir07 : 2;
+ unsigned ep_dir06 : 2;
+ unsigned ep_dir05 : 2;
+ unsigned ep_dir04 : 2;
+ unsigned ep_dir03 : 2;
+ unsigned ep_dir02 : 2;
+ unsigned ep_dir01 : 2;
+ unsigned ep_dir00 : 2;
+ }b;
+} hwcfg1_data_t;
+
+/*!
+ \brief Bit fields in the User HW Config2 Register.
+ */
+typedef union hwcfg2_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned reserved31 : 1;
+ unsigned dev_token_q_depth : 5; /*!< 30-26 Device Mode IN Token Sequence Learning Queue Depth */
+ unsigned host_perio_tx_q_depth : 2; /*!< 25-24 Host Mode Periodic Request Queue Depth */
+ unsigned nonperio_tx_q_depth : 2; /*!< 23-22 Non-periodic Request Queue Depth */
+ unsigned rx_status_q_depth : 2; /*!< 21-20 Multi Processor Interrupt Enabled */
+ unsigned dynamic_fifo : 1; /*!< 19 Dynamic FIFO Sizing Enabled */
+ unsigned perio_ep_supported : 1; /*!< 18 Periodic OUT Channels Supported in Host Mode */
+ unsigned num_host_chan : 4; /*!< 17-14 Number of Host Channels */
+ unsigned num_dev_ep : 4; /*!< 13-10 Number of Device Endpoints */
+ unsigned fs_phy_type : 2; /*!< 09-08 Full-Speed PHY Interface Type */
+ #define IFXUSB_HWCFG2_FS_PHY_TYPE_NOT_SUPPORTED 0
+ #define IFXUSB_HWCFG2_FS_PHY_TYPE_DEDICATE 1
+ #define IFXUSB_HWCFG2_FS_PHY_TYPE_UTMI 2
+ #define IFXUSB_HWCFG2_FS_PHY_TYPE_ULPI 3
+ unsigned hs_phy_type : 2; /*!< 07-06 High-Speed PHY Interface Type */
+ #define IFXUSB_HWCFG2_HS_PHY_TYPE_NOT_SUPPORTED 0
+ #define IFXUSB_HWCFG2_HS_PHY_TYPE_UTMI 1
+ #define IFXUSB_HWCFG2_HS_PHY_TYPE_ULPI 2
+ #define IFXUSB_HWCFG2_HS_PHY_TYPE_UTMI_ULPI 3
+ unsigned point2point : 1; /*!< 05 Point-to-Point */
+ unsigned architecture : 2; /*!< 04-03 Architecture */
+ #define IFXUSB_HWCFG2_ARCH_SLAVE_ONLY 0
+ #define IFXUSB_HWCFG2_ARCH_EXT_DMA 1
+ #define IFXUSB_HWCFG2_ARCH_INT_DMA 2
+ unsigned op_mode : 3; /*!< 02-00 Mode of Operation */
+ #define IFXUSB_HWCFG2_OP_MODE_HNP_SRP_CAPABLE_OTG 0
+ #define IFXUSB_HWCFG2_OP_MODE_SRP_ONLY_CAPABLE_OTG 1
+ #define IFXUSB_HWCFG2_OP_MODE_NO_HNP_SRP_CAPABLE_OTG 2
+ #define IFXUSB_HWCFG2_OP_MODE_SRP_CAPABLE_DEVICE 3
+ #define IFXUSB_HWCFG2_OP_MODE_NO_SRP_CAPABLE_DEVICE 4
+ #define IFXUSB_HWCFG2_OP_MODE_SRP_CAPABLE_HOST 5
+ #define IFXUSB_HWCFG2_OP_MODE_NO_SRP_CAPABLE_HOST 6
+ } b;
+} hwcfg2_data_t;
+
+/*!
+ \brief Bit fields in the User HW Config3 Register.
+ */
+typedef union hwcfg3_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned dfifo_depth :16; /*!< 31-16 DFIFO Depth */
+ unsigned reserved15_12 : 4;
+ unsigned synch_reset_type : 1; /*!< 11 Reset Style for Clocked always Blocks in RTL */
+ unsigned optional_features : 1; /*!< 10 Optional Features Removed */
+ unsigned vendor_ctrl_if : 1; /*!< 09 Vendor Control Interface Support */
+ unsigned i2c : 1; /*!< 08 I2C Selection */
+ unsigned otg_func : 1; /*!< 07 OTG Function Enabled */
+ unsigned packet_size_cntr_width : 3; /*!< 06-04 Width of Packet Size Counters */
+ unsigned xfer_size_cntr_width : 4; /*!< 03-00 Width of Transfer Size Counters */
+ } b;
+} hwcfg3_data_t;
+
+/*!
+ \brief Bit fields in the User HW Config4
+ * Register. Read the register into the <i>d32</i> element then read
+ * out the bits using the <i>b</i>it elements.
+ */
+typedef union hwcfg4_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned desc_dma_dyn : 1; /*!< 31 Scatter/Gather DMA */
+ unsigned desc_dma : 1; /*!< 30 Scatter/Gather DMA configuration */
+ unsigned num_in_eps : 4; /*!< 29-26 Number of Device Mode IN Endpoints Including Control Endpoints */
+ unsigned ded_fifo_en : 1; /*!< 25 Enable Dedicated Transmit FIFO for device IN Endpoints */
+ unsigned session_end_filt_en : 1; /*!< 24 session_end Filter Enabled */
+ unsigned b_valid_filt_en : 1; /*!< 23 b_valid Filter Enabled */
+ unsigned a_valid_filt_en : 1; /*!< 22 a_valid Filter Enabled */
+ unsigned vbus_valid_filt_en : 1; /*!< 21 vbus_valid Filter Enabled */
+ unsigned iddig_filt_en : 1; /*!< 20 iddig Filter Enable */
+ unsigned num_dev_mode_ctrl_ep : 4; /*!< 19-16 Number of Device Mode Control Endpoints in Addition to Endpoint 0 */
+ unsigned utmi_phy_data_width : 2; /*!< 15-14 UTMI+ PHY/ULPI-to-Internal UTMI+ Wrapper Data Width */
+ unsigned reserved13_06 : 8;
+ unsigned min_ahb_freq : 1; /*!< 05 Minimum AHB Frequency Less Than 60 MHz */
+ unsigned power_optimiz : 1; /*!< 04 Enable Power Optimization? */
+ unsigned num_dev_perio_in_ep : 4; /*!< 03-00 Number of Device Mode Periodic IN Endpoints */
+ } b;
+} hwcfg4_data_t;
+
+/*@}*//*IFXUSB_CSR_CORE_GLOBAL_REG*/
+
+/****************************************************************************/
+/*!
+ \addtogroup IFXUSB_CSR_DEVICE_GLOBAL_REG
+ */
+/*@{*/
+
+/*! typedef ifxusb_dev_global_regs_t
+ \brief IFXUSB Device Mode Global registers. Offsets 800h-BFFh
+ The ifxusb_dev_global_regs structure defines the size
+ and relative field offsets for the Device Global registers.
+ These registers are visible only in Device mode and must not be
+ accessed in Host mode, as the results are unknown.
+ */
+typedef struct ifxusb_dev_global_regs
+{
+ volatile uint32_t dcfg; /*!< 800h Device Configuration Register. */
+ volatile uint32_t dctl; /*!< 804h Device Control Register. */
+ volatile uint32_t dsts; /*!< 808h Device Status Register (Read Only). */
+ uint32_t unused;
+ volatile uint32_t diepmsk; /*!< 810h Device IN Endpoint Common Interrupt Mask Register. */
+ volatile uint32_t doepmsk; /*!< 814h Device OUT Endpoint Common Interrupt Mask Register. */
+ volatile uint32_t daint; /*!< 818h Device All Endpoints Interrupt Register. */
+ volatile uint32_t daintmsk; /*!< 81Ch Device All Endpoints Interrupt Mask Register. */
+ volatile uint32_t dtknqr1; /*!< 820h Device IN Token Queue Read Register-1 (Read Only). */
+ volatile uint32_t dtknqr2; /*!< 824h Device IN Token Queue Read Register-2 (Read Only). */
+ volatile uint32_t dvbusdis; /*!< 828h Device VBUS discharge Register.*/
+ volatile uint32_t dvbuspulse; /*!< 82Ch Device VBUS Pulse Register. */
+ volatile uint32_t dtknqr3_dthrctl; /*!< 830h Device IN Token Queue Read Register-3 (Read Only).
+ Device Thresholding control register (Read/Write)
+ */
+ volatile uint32_t dtknqr4_fifoemptymsk; /*!< 834h Device IN Token Queue Read Register-4 (Read Only).
+ Device IN EPs empty Inr. Mask Register (Read/Write)
+ */
+} ifxusb_device_global_regs_t;
+
+/*!
+ \brief Bit fields in the Device Configuration Register.
+ */
+
+typedef union dcfg_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned reserved31_26 : 6;
+ unsigned perschintvl : 2; /*!< 25-24 Periodic Scheduling Interval */
+ unsigned descdma : 1; /*!< 23 Enable Descriptor DMA in Device mode */
+ unsigned epmscnt : 5; /*!< 22-18 In Endpoint Mis-match count */
+ unsigned reserved13_17 : 5;
+ unsigned perfrint : 2; /*!< 12-11 Periodic Frame Interval */
+ #define IFXUSB_DCFG_FRAME_INTERVAL_80 0
+ #define IFXUSB_DCFG_FRAME_INTERVAL_85 1
+ #define IFXUSB_DCFG_FRAME_INTERVAL_90 2
+ #define IFXUSB_DCFG_FRAME_INTERVAL_95 3
+ unsigned devaddr : 7; /*!< 10-04 Device Addresses */
+ unsigned reserved3 : 1;
+ unsigned nzstsouthshk : 1; /*!< 02 Non Zero Length Status OUT Handshake */
+ #define IFXUSB_DCFG_SEND_STALL 1
+ unsigned devspd : 2; /*!< 01-00 Device Speed */
+ } b;
+} dcfg_data_t;
+
+/*!
+ \brief Bit fields in the Device Control Register.
+ */
+typedef union dctl_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned reserved16_31 :16;
+ unsigned ifrmnum : 1; /*!< 15 Ignore Frame Number for ISOC EPs */
+ unsigned gmc : 2; /*!< 14-13 Global Multi Count */
+ unsigned gcontbna : 1; /*!< 12 Global Continue on BNA */
+ unsigned pwronprgdone : 1; /*!< 11 Power-On Programming Done */
+ unsigned cgoutnak : 1; /*!< 10 Clear Global OUT NAK */
+ unsigned sgoutnak : 1; /*!< 09 Set Global OUT NAK */
+ unsigned cgnpinnak : 1; /*!< 08 Clear Global Non-Periodic IN NAK */
+ unsigned sgnpinnak : 1; /*!< 07 Set Global Non-Periodic IN NAK */
+ unsigned tstctl : 3; /*!< 06-04 Test Control */
+ unsigned goutnaksts : 1; /*!< 03 Global OUT NAK Status */
+ unsigned gnpinnaksts : 1; /*!< 02 Global Non-Periodic IN NAK Status */
+ unsigned sftdiscon : 1; /*!< 01 Soft Disconnect */
+ unsigned rmtwkupsig : 1; /*!< 00 Remote Wakeup */
+ } b;
+} dctl_data_t;
+
+
+/*!
+ \brief Bit fields in the Device Status Register.
+ */
+typedef union dsts_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned reserved22_31 :10;
+ unsigned soffn :14; /*!< 21-08 Frame or Microframe Number of the received SOF */
+ unsigned reserved4_7 : 4;
+ unsigned errticerr : 1; /*!< 03 Erratic Error */
+ unsigned enumspd : 2; /*!< 02-01 Enumerated Speed */
+ #define IFXUSB_DSTS_ENUMSPD_HS_PHY_30MHZ_OR_60MHZ 0
+ #define IFXUSB_DSTS_ENUMSPD_FS_PHY_30MHZ_OR_60MHZ 1
+ #define IFXUSB_DSTS_ENUMSPD_LS_PHY_6MHZ 2
+ #define IFXUSB_DSTS_ENUMSPD_FS_PHY_48MHZ 3
+ unsigned suspsts : 1; /*!< 00 Suspend Status */
+ } b;
+} dsts_data_t;
+
+/*!
+ \brief Bit fields in the Device IN EP Interrupt Register
+ and the Device IN EP Common Mask Register.
+ */
+typedef union diepint_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned reserved14_31 :18;
+ unsigned nakmsk : 1; /*!< 13 NAK interrupt Mask */
+ unsigned reserved10_12 : 3;
+ unsigned bna : 1; /*!< 09 BNA Interrupt mask */
+ unsigned txfifoundrn : 1; /*!< 08 Fifo Underrun Mask */
+ unsigned emptyintr : 1; /*!< 07 IN Endpoint HAK Effective mask */
+ unsigned inepnakeff : 1; /*!< 06 IN Endpoint HAK Effective mask */
+ unsigned intknepmis : 1; /*!< 05 IN Token Received with EP mismatch mask */
+ unsigned intktxfemp : 1; /*!< 04 IN Token received with TxF Empty mask */
+ unsigned timeout : 1; /*!< 03 TimeOUT Handshake mask (non-ISOC EPs) */
+ unsigned ahberr : 1; /*!< 02 AHB Error mask */
+ unsigned epdisabled : 1; /*!< 01 Endpoint disable mask */
+ unsigned xfercompl : 1; /*!< 00 Transfer complete mask */
+ } b;
+} diepint_data_t;
+
+
+/*!
+ \brief Bit fields in the Device OUT EP Interrupt Register and
+ Device OUT EP Common Interrupt Mask Register.
+ */
+typedef union doepint_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned reserved15_31 :17;
+ unsigned nyetmsk : 1; /*!< 14 NYET Interrupt */
+ unsigned nakmsk : 1; /*!< 13 NAK Interrupt */
+ unsigned bbleerrmsk : 1; /*!< 12 Babble Interrupt */
+ unsigned reserved10_11 : 2;
+ unsigned bna : 1; /*!< 09 BNA Interrupt */
+ unsigned outpkterr : 1; /*!< 08 OUT packet Error */
+ unsigned reserved07 : 1;
+ unsigned back2backsetup : 1; /*!< 06 Back-to-Back SETUP Packets Received */
+ unsigned stsphsercvd : 1; /*!< 05 */
+ unsigned outtknepdis : 1; /*!< 04 OUT Token Received when Endpoint Disabled */
+ unsigned setup : 1; /*!< 03 Setup Phase Done (contorl EPs) */
+ unsigned ahberr : 1; /*!< 02 AHB Error */
+ unsigned epdisabled : 1; /*!< 01 Endpoint disable */
+ unsigned xfercompl : 1; /*!< 00 Transfer complete */
+ } b;
+} doepint_data_t;
+
+
+/*!
+ \brief Bit fields in the Device All EP Interrupt Registers.
+ */
+typedef union daint_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned out : 16; /*!< 31-16 OUT Endpoint bits */
+ unsigned in : 16; /*!< 15-00 IN Endpoint bits */
+ } eps;
+ struct
+ {
+ /** OUT Endpoint bits */
+ unsigned outep15 : 1;
+ unsigned outep14 : 1;
+ unsigned outep13 : 1;
+ unsigned outep12 : 1;
+ unsigned outep11 : 1;
+ unsigned outep10 : 1;
+ unsigned outep09 : 1;
+ unsigned outep08 : 1;
+ unsigned outep07 : 1;
+ unsigned outep06 : 1;
+ unsigned outep05 : 1;
+ unsigned outep04 : 1;
+ unsigned outep03 : 1;
+ unsigned outep02 : 1;
+ unsigned outep01 : 1;
+ unsigned outep00 : 1;
+ /** IN Endpoint bits */
+ unsigned inep15 : 1;
+ unsigned inep14 : 1;
+ unsigned inep13 : 1;
+ unsigned inep12 : 1;
+ unsigned inep11 : 1;
+ unsigned inep10 : 1;
+ unsigned inep09 : 1;
+ unsigned inep08 : 1;
+ unsigned inep07 : 1;
+ unsigned inep06 : 1;
+ unsigned inep05 : 1;
+ unsigned inep04 : 1;
+ unsigned inep03 : 1;
+ unsigned inep02 : 1;
+ unsigned inep01 : 1;
+ unsigned inep00 : 1;
+ } ep;
+} daint_data_t;
+
+
+/*!
+ \brief Bit fields in the Device IN Token Queue Read Registers.
+ */
+typedef union dtknq1_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned epnums0_5 :24; /*!< 31-08 EP Numbers of IN Tokens 0 ... 4 */
+ unsigned wrap_bit : 1; /*!< 07 write pointer has wrapped */
+ unsigned reserved05_06 : 2;
+ unsigned intknwptr : 5; /*!< 04-00 In Token Queue Write Pointer */
+ }b;
+} dtknq1_data_t;
+
+
+/*!
+ \brief Bit fields in Threshold control Register
+ */
+typedef union dthrctl_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned reserved26_31 : 6;
+ unsigned rx_thr_len : 9; /*!< 25-17 Rx Thr. Length */
+ unsigned rx_thr_en : 1; /*!< 16 Rx Thr. Enable */
+ unsigned reserved11_15 : 5;
+ unsigned tx_thr_len : 9; /*!< 10-02 Tx Thr. Length */
+ unsigned iso_thr_en : 1; /*!< 01 ISO Tx Thr. Enable */
+ unsigned non_iso_thr_en : 1; /*!< 00 non ISO Tx Thr. Enable */
+ } b;
+} dthrctl_data_t;
+
+/*@}*//*IFXUSB_CSR_DEVICE_GLOBAL_REG*/
+
+/****************************************************************************/
+
+/*!
+ \addtogroup IFXUSB_CSR_DEVICE_EP_REG
+ */
+/*@{*/
+
+/*! typedef ifxusb_dev_in_ep_regs_t
+ \brief Device Logical IN Endpoint-Specific Registers.
+ There will be one set of endpoint registers per logical endpoint
+ implemented.
+ each EP's IN EP Register are offset at :
+ 900h + * (ep_num * 20h)
+ */
+
+typedef struct ifxusb_dev_in_ep_regs
+{
+ volatile uint32_t diepctl; /*!< 00h: Endpoint Control Register */
+ uint32_t reserved04; /*!< 04h: */
+ volatile uint32_t diepint; /*!< 08h: Endpoint Interrupt Register */
+ uint32_t reserved0C; /*!< 0Ch: */
+ volatile uint32_t dieptsiz; /*!< 10h: Endpoint Transfer Size Register.*/
+ volatile uint32_t diepdma; /*!< 14h: Endpoint DMA Address Register. */
+ volatile uint32_t dtxfsts; /*!< 18h: Endpoint Transmit FIFO Status Register. */
+ volatile uint32_t diepdmab; /*!< 1Ch: Endpoint DMA Buffer Register. */
+} ifxusb_dev_in_ep_regs_t;
+
+/*! typedef ifxusb_dev_out_ep_regs_t
+ \brief Device Logical OUT Endpoint-Specific Registers.
+ There will be one set of endpoint registers per logical endpoint
+ implemented.
+ each EP's OUT EP Register are offset at :
+ B00h + * (ep_num * 20h) + 00h
+ */
+typedef struct ifxusb_dev_out_ep_regs
+{
+ volatile uint32_t doepctl; /*!< 00h: Endpoint Control Register */
+ volatile uint32_t doepfn; /*!< 04h: Endpoint Frame number Register */
+ volatile uint32_t doepint; /*!< 08h: Endpoint Interrupt Register */
+ uint32_t reserved0C; /*!< 0Ch: */
+ volatile uint32_t doeptsiz; /*!< 10h: Endpoint Transfer Size Register.*/
+ volatile uint32_t doepdma; /*!< 14h: Endpoint DMA Address Register. */
+ uint32_t reserved18; /*!< 18h: */
+ volatile uint32_t doepdmab; /*!< 1Ch: Endpoint DMA Buffer Register. */
+} ifxusb_dev_out_ep_regs_t;
+
+
+/*!
+ \brief Bit fields in the Device EP Control
+ Register.
+ */
+typedef union depctl_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned epena : 1; /*!< 31 Endpoint Enable */
+ unsigned epdis : 1; /*!< 30 Endpoint Disable */
+ unsigned setd1pid : 1; /*!< 29 Set DATA1 PID (INTR/Bulk IN and OUT endpoints) */
+ unsigned setd0pid : 1; /*!< 28 Set DATA0 PID (INTR/Bulk IN and OUT endpoints) */
+ unsigned snak : 1; /*!< 27 Set NAK */
+ unsigned cnak : 1; /*!< 26 Clear NAK */
+ unsigned txfnum : 4; /*!< 25-22 Tx Fifo Number */
+ unsigned stall : 1; /*!< 21 Stall Handshake */
+ unsigned snp : 1; /*!< 20 Snoop Mode */
+ unsigned eptype : 2; /*!< 19-18 Endpoint Type
+ 0: Control
+ 1: Isochronous
+ 2: Bulk
+ 3: Interrupt
+ */
+ unsigned naksts : 1; /*!< 17 NAK Status */
+ unsigned dpid : 1; /*!< 16 Endpoint DPID (INTR/Bulk IN and OUT endpoints) */
+ unsigned usbactep : 1; /*!< 15 USB Active Endpoint */
+ unsigned nextep : 4; /*!< 14-11 Next Endpoint */
+ unsigned mps :11; /*!< 10-00 Maximum Packet Size */
+ #define IFXUSB_DEP0CTL_MPS_64 0
+ #define IFXUSB_DEP0CTL_MPS_32 1
+ #define IFXUSB_DEP0CTL_MPS_16 2
+ #define IFXUSB_DEP0CTL_MPS_8 3
+ } b;
+} depctl_data_t;
+
+
+/*!
+ \brief Bit fields in the Device EP Transfer Size Register. (EP0 and EPn)
+ */
+typedef union deptsiz_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned reserved31 : 1;
+ unsigned supcnt : 2; /*!< 30-29 Setup Packet Count */
+ #ifdef __DED_FIFO__
+ unsigned reserved21_28 : 8;
+ unsigned pktcnt : 2; /*!< 19-20 Packet Count */
+ #else
+ unsigned reserved20_28 : 9;
+ unsigned pktcnt : 1; /*!< 19 Packet Count */
+ #endif
+ unsigned reserved7_18 :12;
+ unsigned xfersize : 7; /*!< 06-00 Transfer size */
+ }b0;
+ struct
+ {
+ unsigned reserved : 1;
+ unsigned mc : 2; /*!< 30-29 Multi Count */
+ unsigned pktcnt :10; /*!< 28-19 Packet Count */
+ unsigned xfersize :19; /*!< 18-00 Transfer size */
+ } b;
+} deptsiz_data_t;
+
+/*@}*//*IFXUSB_CSR_DEVICE_EP_REG*/
+/****************************************************************************/
+
+/*!
+ \addtogroup IFXUSB_CSR_DEVICE_DMA_DESC
+ */
+/*@{*/
+/*!
+ \brief Bit fields in the DMA Descriptor status quadlet.
+ */
+typedef union desc_sts_data
+{
+ struct
+ {
+ unsigned bs : 2; /*!< 31-30 Buffer Status */
+ #define BS_HOST_READY 0x0
+ #define BS_DMA_BUSY 0x1
+ #define BS_DMA_DONE 0x2
+ #define BS_HOST_BUSY 0x3
+ unsigned sts : 2; /*!< 29-28 Receive/Trasmit Status */
+ #define RTS_SUCCESS 0x0
+ #define RTS_BUFFLUSH 0x1
+ #define RTS_RESERVED 0x2
+ #define RTS_BUFERR 0x3
+ unsigned l : 1; /*!< 27 Last */
+ unsigned sp : 1; /*!< 26 Short Packet */
+ unsigned ioc : 1; /*!< 25 Interrupt On Complete */
+ unsigned sr : 1; /*!< 24 Setup Packet received */
+ unsigned mtrf : 1; /*!< 23 Multiple Transfer */
+ unsigned reserved16_22 : 7;
+ unsigned bytes :16; /*!< 15-00 Transfer size in bytes */
+ } b;
+ uint32_t d32; /*!< DMA Descriptor data buffer pointer */
+} desc_sts_data_t;
+
+/*@}*//*IFXUSB_CSR_DEVICE_DMA_DESC*/
+/****************************************************************************/
+
+/*!
+ \addtogroup IFXUSB_CSR_HOST_GLOBAL_REG
+ */
+/*@{*/
+/*! typedef ifxusb_host_global_regs_t
+ \brief IFXUSB Host Mode Global registers. Offsets 400h-7FFh
+ The ifxusb_host_global_regs structure defines the size
+ and relative field offsets for the Host Global registers.
+ These registers are visible only in Host mode and must not be
+ accessed in Device mode, as the results are unknown.
+ */
+typedef struct ifxusb_host_global_regs
+{
+ volatile uint32_t hcfg; /*!< 400h Host Configuration Register. */
+ volatile uint32_t hfir; /*!< 404h Host Frame Interval Register. */
+ volatile uint32_t hfnum; /*!< 408h Host Frame Number / Frame Remaining Register. */
+ uint32_t reserved40C;
+ volatile uint32_t hptxsts; /*!< 410h Host Periodic Transmit FIFO/ Queue Status Register. */
+ volatile uint32_t haint; /*!< 414h Host All Channels Interrupt Register. */
+ volatile uint32_t haintmsk; /*!< 418h Host All Channels Interrupt Mask Register. */
+} ifxusb_host_global_regs_t;
+
+/*!
+ \brief Bit fields in the Host Configuration Register.
+ */
+typedef union hcfg_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned reserved31_03 :29;
+ unsigned fslssupp : 1; /*!< 02 FS/LS Only Support */
+ unsigned fslspclksel : 2; /*!< 01-00 FS/LS Phy Clock Select */
+ #define IFXUSB_HCFG_30_60_MHZ 0
+ #define IFXUSB_HCFG_48_MHZ 1
+ #define IFXUSB_HCFG_6_MHZ 2
+ } b;
+} hcfg_data_t;
+
+/*!
+ \brief Bit fields in the Host Frame Interval Register.
+ */
+typedef union hfir_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned reserved : 16;
+ unsigned frint : 16; /*!< 15-00 Frame Interval */
+ } b;
+} hfir_data_t;
+
+/*!
+ \brief Bit fields in the Host Frame Time Remaing/Number Register.
+ */
+typedef union hfnum_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned frrem : 16; /*!< 31-16 Frame Time Remaining */
+ unsigned frnum : 16; /*!< 15-00 Frame Number*/
+ #define IFXUSB_HFNUM_MAX_FRNUM 0x3FFF
+ } b;
+} hfnum_data_t;
+
+/*!
+ \brief Bit fields in the Host Periodic Transmit FIFO/Queue Status Register
+ */
+typedef union hptxsts_data
+{
+ /** raw register data */
+ uint32_t d32;
+ struct
+ {
+ /** Top of the Periodic Transmit Request Queue
+ * - bit 24 - Terminate (last entry for the selected channel)
+ */
+ unsigned ptxqtop_odd : 1; /*!< 31 Top of the Periodic Transmit Request
+ Queue Odd/even microframe*/
+ unsigned ptxqtop_chnum : 4; /*!< 30-27 Top of the Periodic Transmit Request
+ Channel Number */
+ unsigned ptxqtop_token : 2; /*!< 26-25 Top of the Periodic Transmit Request
+ Token Type
+ 0 - Zero length
+ 1 - Ping
+ 2 - Disable
+ */
+ unsigned ptxqtop_terminate : 1; /*!< 24 Top of the Periodic Transmit Request
+ Terminate (last entry for the selected channel)*/
+ unsigned ptxqspcavail : 8; /*!< 23-16 Periodic Transmit Request Queue Space Available */
+ unsigned ptxfspcavail :16; /*!< 15-00 Periodic Transmit Data FIFO Space Available */
+ } b;
+} hptxsts_data_t;
+
+/*!
+ \brief Bit fields in the Host Port Control and Status Register.
+ */
+typedef union hprt0_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned reserved19_31 :13;
+ unsigned prtspd : 2; /*!< 18-17 Port Speed */
+ #define IFXUSB_HPRT0_PRTSPD_HIGH_SPEED 0
+ #define IFXUSB_HPRT0_PRTSPD_FULL_SPEED 1
+ #define IFXUSB_HPRT0_PRTSPD_LOW_SPEED 2
+ unsigned prttstctl : 4; /*!< 16-13 Port Test Control */
+ unsigned prtpwr : 1; /*!< 12 Port Power */
+ unsigned prtlnsts : 2; /*!< 11-10 Port Line Status */
+ unsigned reserved9 : 1;
+ unsigned prtrst : 1; /*!< 08 Port Reset */
+ unsigned prtsusp : 1; /*!< 07 Port Suspend */
+ unsigned prtres : 1; /*!< 06 Port Resume */
+ unsigned prtovrcurrchng : 1; /*!< 05 Port Overcurrent Change */
+ unsigned prtovrcurract : 1; /*!< 04 Port Overcurrent Active */
+ unsigned prtenchng : 1; /*!< 03 Port Enable/Disable Change */
+ unsigned prtena : 1; /*!< 02 Port Enable */
+ unsigned prtconndet : 1; /*!< 01 Port Connect Detected */
+ unsigned prtconnsts : 1; /*!< 00 Port Connect Status */
+ }b;
+} hprt0_data_t;
+
+/*!
+ \brief Bit fields in the Host All Interrupt Register.
+ */
+typedef union haint_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned reserved : 16;
+ unsigned ch15 : 1;
+ unsigned ch14 : 1;
+ unsigned ch13 : 1;
+ unsigned ch12 : 1;
+ unsigned ch11 : 1;
+ unsigned ch10 : 1;
+ unsigned ch09 : 1;
+ unsigned ch08 : 1;
+ unsigned ch07 : 1;
+ unsigned ch06 : 1;
+ unsigned ch05 : 1;
+ unsigned ch04 : 1;
+ unsigned ch03 : 1;
+ unsigned ch02 : 1;
+ unsigned ch01 : 1;
+ unsigned ch00 : 1;
+ } b;
+ struct
+ {
+ unsigned reserved : 16;
+ unsigned chint : 16;
+ } b2;
+} haint_data_t;
+/*@}*//*IFXUSB_CSR_HOST_GLOBAL_REG*/
+/****************************************************************************/
+/*!
+ \addtogroup IFXUSB_CSR_HOST_HC_REG
+ */
+/*@{*/
+/*! typedef ifxusb_hc_regs_t
+ \brief Host Channel Specific Registers
+ There will be one set of hc registers per host channelimplemented.
+ each HC's Register are offset at :
+ 500h + * (hc_num * 20h)
+ */
+typedef struct ifxusb_hc_regs
+{
+ volatile uint32_t hcchar; /*!< 00h Host Channel Characteristic Register.*/
+ volatile uint32_t hcsplt; /*!< 04h Host Channel Split Control Register.*/
+ volatile uint32_t hcint; /*!< 08h Host Channel Interrupt Register. */
+ volatile uint32_t hcintmsk; /*!< 0Ch Host Channel Interrupt Mask Register. */
+ volatile uint32_t hctsiz; /*!< 10h Host Channel Transfer Size Register. */
+ volatile uint32_t hcdma; /*!< 14h Host Channel DMA Address Register. */
+ uint32_t reserved[2]; /*!< 18h Reserved. */
+} ifxusb_hc_regs_t;
+
+
+/*!
+ \brief Bit fields in the Host Channel Characteristics Register.
+ */
+typedef union hcchar_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned chen : 1; /*!< 31 Channel enable */
+ unsigned chdis : 1; /*!< 30 Channel disable */
+ unsigned oddfrm : 1; /*!< 29 Frame to transmit periodic transaction */
+ unsigned devaddr : 7; /*!< 28-22 Device address */
+ unsigned multicnt : 2; /*!< 21-20 Packets per frame for periodic transfers */
+ unsigned eptype : 2; /*!< 19-18 0: Control, 1: Isoc, 2: Bulk, 3: Intr */
+ unsigned lspddev : 1; /*!< 17 0: Full/high speed device, 1: Low speed device */
+ unsigned reserved : 1;
+ unsigned epdir : 1; /*!< 15 0: OUT, 1: IN */
+ unsigned epnum : 4; /*!< 14-11 Endpoint number */
+ unsigned mps :11; /*!< 10-00 Maximum packet size in bytes */
+ } b;
+} hcchar_data_t;
+
+/*!
+ \brief Bit fields in the Host Channel Split Control Register
+ */
+typedef union hcsplt_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned spltena : 1; /*!< 31 Split Enble */
+ unsigned reserved :14;
+ unsigned compsplt : 1; /*!< 16 Do Complete Split */
+ unsigned xactpos : 2; /*!< 15-14 Transaction Position */
+ #define IFXUSB_HCSPLIT_XACTPOS_MID 0
+ #define IFXUSB_HCSPLIT_XACTPOS_END 1
+ #define IFXUSB_HCSPLIT_XACTPOS_BEGIN 2
+ #define IFXUSB_HCSPLIT_XACTPOS_ALL 3
+ unsigned hubaddr : 7; /*!< 13-07 Hub Address */
+ unsigned prtaddr : 7; /*!< 06-00 Port Address */
+ } b;
+} hcsplt_data_t;
+
+/*!
+ \brief Bit fields in the Host Interrupt Register.
+ */
+typedef union hcint_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned reserved :21;
+ unsigned datatglerr : 1; /*!< 10 Data Toggle Error */
+ unsigned frmovrun : 1; /*!< 09 Frame Overrun */
+ unsigned bblerr : 1; /*!< 08 Babble Error */
+ unsigned xacterr : 1; /*!< 07 Transaction Err */
+ unsigned nyet : 1; /*!< 06 NYET Response Received */
+ unsigned ack : 1; /*!< 05 ACK Response Received */
+ unsigned nak : 1; /*!< 04 NAK Response Received */
+ unsigned stall : 1; /*!< 03 STALL Response Received */
+ unsigned ahberr : 1; /*!< 02 AHB Error */
+ unsigned chhltd : 1; /*!< 01 Channel Halted */
+ unsigned xfercomp : 1; /*!< 00 Channel Halted */
+ }b;
+} hcint_data_t;
+
+
+/*!
+ \brief Bit fields in the Host Channel Transfer Size
+ Register.
+ */
+typedef union hctsiz_data
+{
+ uint32_t d32;
+ struct
+ {
+ /** */
+ unsigned dopng : 1; /*!< 31 Do PING protocol when 1 */
+ /**
+ * Packet ID for next data packet
+ * 0: DATA0
+ * 1: DATA2
+ * 2: DATA1
+ * 3: MDATA (non-Control), SETUP (Control)
+ */
+ unsigned pid : 2; /*!< 30-29 Packet ID for next data packet
+ 0: DATA0
+ 1: DATA2
+ 2: DATA1
+ 3: MDATA (non-Control), SETUP (Control)
+ */
+ #define IFXUSB_HCTSIZ_DATA0 0
+ #define IFXUSB_HCTSIZ_DATA1 2
+ #define IFXUSB_HCTSIZ_DATA2 1
+ #define IFXUSB_HCTSIZ_MDATA 3
+ #define IFXUSB_HCTSIZ_SETUP 3
+ unsigned pktcnt :10; /*!< 28-19 Data packets to transfer */
+ unsigned xfersize :19; /*!< 18-00 Total transfer size in bytes */
+ }b;
+} hctsiz_data_t;
+
+/*@}*//*IFXUSB_CSR_HOST_HC_REG*/
+
+/****************************************************************************/
+
+/*!
+ \addtogroup IFXUSB_CSR_PWR_CLK_GATING_REG
+ */
+/*@{*/
+/*!
+ \brief Bit fields in the Power and Clock Gating Control Register
+ */
+typedef union pcgcctl_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned reserved : 27;
+ unsigned physuspended : 1; /*!< 04 PHY Suspended */
+ unsigned rstpdwnmodule : 1; /*!< 03 Reset Power Down Modules */
+ unsigned pwrclmp : 1; /*!< 02 Power Clamp */
+ unsigned gatehclk : 1; /*!< 01 Gate Hclk */
+ unsigned stoppclk : 1; /*!< 00 Stop Pclk */
+ } b;
+} pcgcctl_data_t;
+/*@}*//*IFXUSB_CSR_PWR_CLK_GATING_REG*/
+
+/****************************************************************************/
+
+#endif //__IFXUSB_REGS_H__
diff --git a/package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxusb_version.h.svn-base b/package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxusb_version.h.svn-base
new file mode 100644
index 0000000..11e346e
--- /dev/null
+++ b/package/platform/lantiq/ltq-hcd/src/.svn/text-base/ifxusb_version.h.svn-base
@@ -0,0 +1,5 @@
+
+#ifndef IFXUSB_VERSION
+#define IFXUSB_VERSION "3.2 B110801"
+#endif
+
diff --git a/package/platform/lantiq/ltq-hcd/src/Kconfig b/package/platform/lantiq/ltq-hcd/src/Kconfig
new file mode 100644
index 0000000..2a3a38d
--- /dev/null
+++ b/package/platform/lantiq/ltq-hcd/src/Kconfig
@@ -0,0 +1,104 @@
+
+config USB_HOST_IFX
+ tristate "Infineon USB Host Controller Driver"
+ depends on USB
+ default n
+ help
+ Infineon USB Host Controller
+
+choice
+ prompt "Infineon USB Host Controller Driver Operation mode"
+ depends on USB_HOST_IFX && ( AMAZON_S || AR9 || VR9 || AR10 || MIPS_AMAZON_S || MIPS_AR9 || MIPS_VR9 || MIPS_AR10 )
+ help
+ The IFX USB core can be configured as dual-host and single host.
+ The unused core can be set as Device-mode.
+
+config USB_HOST_IFX_B
+ boolean "USB host mode on core 1 and 2"
+ help
+ Both cores run as host
+
+config USB_HOST_IFX_1
+ boolean "USB host mode on core 1 only"
+ help
+ Core #1 runs as host
+
+config USB_HOST_IFX_2
+ boolean "USB host mode on core 2 only"
+ help
+ Core #2 runs as host
+
+endchoice
+
+config USB_HOST_IFX_FORCE_USB11
+ boolean "Forced USB1.1"
+ depends on USB_HOST_IFX
+ default n
+ help
+ force to be USB 1.1
+
+config USB_HOST_IFX_WITH_HS_ELECT_TST
+ boolean "With HS_Electrical Test"
+ depends on USB_HOST_IFX
+ default n
+ help
+ With USBIF HSET routines
+
+config USB_HOST_IFX_WITH_ISO
+ boolean "With ISO transfer"
+ depends on USB_HOST_IFX
+ default n
+ help
+ With USBIF ISO transfer
+
+config USB_HOST_IFX_COC
+ boolean "CoC in USB Host"
+ depends on USB_HOST_IFX
+ default n
+ help
+ With CoC on Host
+
+choice
+ prompt "IFX unaligned buffer policy"
+ depends on USB_HOST_IFX
+ help
+ IFX unaligned buffer policy
+
+config USB_HOST_IFX_UNALIGNED_ADJ
+ boolean "Adjust"
+ help
+ USB_HOST_IFX_UNALIGNED_ADJ
+
+config USB_HOST_IFX_UNALIGNED_CHK
+ boolean "Check-only"
+ help
+ USB_HOST_IFX_UNALIGNED_CHK
+
+config USB_HOST_IFX_UNALIGNED_NONE
+ boolean "No process"
+ help
+ USB_HOST_IFX_UNALIGNED_NONE
+
+endchoice
+
+
+config USB_HOST_IFX_XHCI
+ tristate "xHCI HCD (USB 3.0) support (EXPERIMENTAL)"
+ depends on USB && PCI && ( VR9 || MIPS_VR9 || AR10 || MIPS_AR10 )
+ ---help---
+ The eXtensible Host Controller Interface (xHCI) is standard for USB 3.0
+ "SuperSpeed" host controller hardware.
+
+ To compile this driver as a module, choose M here: the
+ module will be called xhci-hcd.
+
+config USB_HOST_IFX_XHCI_DEBUGGING
+ bool "Debugging for the xHCI host controller"
+ depends on USB_HOST_IFX_XHCI
+ ---help---
+ Say 'Y' to turn on debugging for the xHCI host controller driver.
+ This will spew debugging output, even in interrupt context.
+ This should only be used for debugging xHCI driver bugs.
+
+ If unsure, say N.
+
diff --git a/package/platform/lantiq/ltq-hcd/src/Makefile b/package/platform/lantiq/ltq-hcd/src/Makefile
new file mode 100644
index 0000000..153fd42
--- /dev/null
+++ b/package/platform/lantiq/ltq-hcd/src/Makefile
@@ -0,0 +1,74 @@
+ltq_hcd_$(BUILD_VARIANT)-objs := ifxusb_driver.o ifxusb_ctl.o ifxusb_cif.o \
+ ifxusb_cif_h.o ifxhcd.o ifxhcd_es.o \
+ ifxhcd_intr.o ifxhcd_queue.o
+obj-m = ltq_hcd_$(BUILD_VARIANT).o
+
+ifeq ($(BUILD_VARIANT),danube)
+ EXTRA_CFLAGS += -D__IS_DANUBE__
+endif
+
+ifeq ($(BUILD_VARIANT),ase)
+ EXTRA_CFLAGS += -D__IS_AMAZON_SE__
+endif
+
+ifeq ($(BUILD_VARIANT),ar9)
+ EXTRA_CFLAGS += -D__IS_AR9__
+ EXTRA_CFLAGS += -D__IS_DUAL__
+endif
+
+ifeq ($(BUILD_VARIANT),vr9)
+ EXTRA_CFLAGS += -D__IS_VR9__
+ EXTRA_CFLAGS += -D__PHY_LONG_PREEMP__
+ EXTRA_CFLAGS += -D__PINGSTOP_CTRL__
+ EXTRA_CFLAGS += -D__PINGSTOP_BULK__
+ EXTRA_CFLAGS += -D__IS_DUAL__
+endif
+
+ifeq ($(BUILD_VARIANT),ar10)
+ EXTRA_CFLAGS += -D__IS_AR10__
+ EXTRA_CFLAGS += -D__PHY_LONG_PREEMP__
+ EXTRA_CFLAGS += -D__PINGSTOP_CTRL__
+ EXTRA_CFLAGS += -D__PINGSTOP_BULK__
+endif
+
+ifeq ($(CONFIG_USB_HOST_IFX_FORCE_USB11),y)
+ EXTRA_CFLAGS += -D__FORCE_USB11__
+endif
+ifeq ($(CONFIG_USB_HOST_IFX_WITH_HS_ELECT_TST),y)
+ EXTRA_CFLAGS += -D__WITH_HS_ELECT_TST__
+endif
+ifeq ($(CONFIG_USB_HOST_IFX_WITH_ISO),y)
+ EXTRA_CFLAGS += -D__EN_ISOC__
+endif
+#ifeq ($(CONFIG_USB_HOST_IFX_UNALIGNED_ADJ),y)
+ EXTRA_CFLAGS += -D__UNALIGNED_BUF_ADJ__
+#endif
+ifeq ($(CONFIG_USB_HOST_IFX_UNALIGNED_CHK),y)
+ EXTRA_CFLAGS += -D__UNALIGNED_BUF_CHK__
+endif
+ifeq ($(CONFIG_USB_HOST_IFX_COC),y)
+ EXTRA_CFLAGS += -D__HOST_COC__
+endif
+
+# EXTRA_CFLAGS += -D__IS_FIRST__
+# EXTRA_CFLAGS += -D__IS_SECOND__
+
+# EXTRA_CFLAGS += -D__EN_ISOC__
+# EXTRA_CFLAGS += -D__EN_ISOC_SPLIT__
+# EXTRA_CFLAGS += -D__EPQD_DESTROY_TIMEOUT__
+# EXTRA_CFLAGS += -D__INNAKSTOP_CTRL__
+
+EXTRA_CFLAGS += -Dlinux -D__LINUX__
+EXTRA_CFLAGS += -D__IS_HOST__
+EXTRA_CFLAGS += -D__KERNEL__
+#EXTRA_CFLAGS += -D__DEBUG__
+#EXTRA_CFLAGS += -D__ENABLE_DUMP__
+
+EXTRA_CFLAGS += -D__DYN_SOF_INTR__
+EXTRA_CFLAGS += -D__UEIP__
+EXTRA_CFLAGS += -D__DO_OC_INT__
+EXTRA_CFLAGS += -D__INNAKSTOP_BULK__
+
+EXTRA_CFLAGS += -D__INTRNAKRETRY__
+EXTRA_CFLAGS += -D__INTRINCRETRY__
+
diff --git a/package/platform/lantiq/ltq-hcd/src/ifxhcd.c b/package/platform/lantiq/ltq-hcd/src/ifxhcd.c
new file mode 100644
index 0000000..be0a91d
--- /dev/null
+++ b/package/platform/lantiq/ltq-hcd/src/ifxhcd.c
@@ -0,0 +1,2141 @@
+/*****************************************************************************
+ ** FILE NAME : ifxhcd.c
+ ** PROJECT : IFX USB sub-system V3
+ ** MODULES : IFX USB sub-system Host and Device driver
+ ** SRC VERSION : 3.2
+ ** DATE : 1/Jan/2011
+ ** AUTHOR : Chen, Howard
+ ** DESCRIPTION : This file contains the structures, constants, and
+ ** interfaces for the Host Contoller Driver (HCD).
+ **
+ ** The Host Controller Driver (HCD) is responsible for
+ ** translating requests from the USB Driver into the
+ ** appropriate actions on the IFXUSB controller.
+ ** It isolates the USBD from the specifics of the
+ ** controller by providing an API to the USBD.
+ ** FUNCTIONS :
+ ** COMPILER : gcc
+ ** REFERENCE : Synopsys DWC-OTG Driver 2.7
+ ** COPYRIGHT : Copyright (c) 2010
+ ** LANTIQ DEUTSCHLAND GMBH,
+ ** Am Campeon 3, 85579 Neubiberg, Germany
+ **
+ ** 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 of the License, or
+ ** (at your option) any later version.
+ **
+ ** Version Control Section **
+ ** $Author$
+ ** $Date$
+ ** $Revisions$
+ ** $Log$ Revision history
+ *****************************************************************************/
+
+/*
+ * This file contains code fragments from Synopsys HS OTG Linux Software Driver.
+ * For this code the following notice is applicable:
+ *
+ * ==========================================================================
+ *
+ * Synopsys HS OTG Linux Software Driver and documentation (hereinafter,
+ * "Software") is an Unsupported proprietary work of Synopsys, Inc. unless
+ * otherwise expressly agreed to in writing between Synopsys and you.
+ *
+ * The Software IS NOT an item of Licensed Software or Licensed Product under
+ * any End User Software License Agreement or Agreement for Licensed Product
+ * with Synopsys or any supplement thereto. You are permitted to use and
+ * redistribute this Software in source and binary forms, with or without
+ * modification, provided that redistributions of source code must retain this
+ * notice. You may not view, use, disclose, copy or distribute this file or
+ * any information contained herein except pursuant to this license grant from
+ * Synopsys. If you do not agree with this notice, including the disclaimer
+ * below, then you are not authorized to use the Software.
+ *
+ * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" BASIS
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ * ========================================================================== */
+
+/*!
+ \file ifxhcd.c
+ \ingroup IFXUSB_DRIVER_V3
+ \brief This file contains the implementation of the HCD. In Linux,
+ the HCD implements the hc_driver API.
+*/
+
+#include <linux/version.h>
+#include "ifxusb_version.h"
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/init.h>
+
+#include <linux/device.h>
+
+#include <linux/errno.h>
+#include <linux/list.h>
+#include <linux/interrupt.h>
+#include <linux/string.h>
+
+#include <linux/dma-mapping.h>
+
+
+#include "ifxusb_plat.h"
+#include "ifxusb_regs.h"
+#include "ifxusb_cif.h"
+#include "ifxhcd.h"
+
+#include <asm/irq.h>
+
+#ifdef __DEBUG__
+ static void dump_urb_info(struct urb *_urb, char* _fn_name);
+#if 0
+ static void dump_channel_info(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_epqh_t *_epqh);
+#endif
+#endif
+
+static void ifxhcd_complete_urb_sub(ifxhcd_urbd_t *_urbd)
+{
+ ifxhcd_hcd_t *ifxhcd;
+ struct urb *urb=NULL;
+
+ if (!list_empty(&_urbd->ql))
+ {
+ list_del_init(&_urbd->ql);
+ _urbd->epqh->urbd_count--;
+ }
+ else
+ IFX_ERROR("%s: urb(%p) not connect to any epqh\n",
+ __func__,_urbd);
+
+ ifxhcd=_urbd->epqh->ifxhcd;
+ urb =_urbd->urb;
+ if(!urb)
+ IFX_ERROR("%s: invalid urb\n",__func__);
+ else if(urb->hcpriv)
+ {
+ if(urb->hcpriv != _urbd)
+ IFX_ERROR("%s: invalid"
+ " urb(%p)->hcpriv(%p) != _urbd(%p)\n",
+ __func__,
+ urb,
+ urb->hcpriv,
+ _urbd);
+ #if defined(__UNALIGNED_BUF_ADJ__)
+ if(_urbd->is_in &&
+// _urbd->using_aligned_buf &&
+ _urbd->aligned_buf)
+ memcpy(_urbd->xfer_buff,
+ _urbd->aligned_buf,
+ _urbd->xfer_len);
+ if(_urbd->aligned_buf)
+ ifxusb_free_buf_h(_urbd->aligned_buf);
+ #endif
+ urb->hcpriv = NULL;
+ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)
+ urb->status=_urbd->status;
+ usb_hcd_giveback_urb(ifxhcd_to_syshcd(ifxhcd), urb);
+ #else
+ usb_hcd_giveback_urb(ifxhcd_to_syshcd(ifxhcd), urb,
+ _urbd->status);
+ #endif
+ }
+ kfree(_urbd);
+}
+
+#ifdef __STRICT_ORDER__
+ static void ifxhcd_complete_urb_func(unsigned long data)
+ {
+ unsigned long flags;
+ ifxhcd_urbd_t *urbd;
+ ifxhcd_epqh_t *epqh;
+ struct list_head *item;
+
+ int count=10;
+
+ epqh=((ifxhcd_epqh_t *)data);
+
+ while (!list_empty(&epqh->release_list) && count)
+ {
+ item = epqh->release_list.next;
+ urbd = list_entry(item, ifxhcd_urbd_t, ql);
+ if (!urbd)
+ IFX_ERROR("%s: invalid urbd\n",__func__);
+ else if (!urbd->epqh)
+ IFX_ERROR("%s: invalid epqd\n",__func__);
+ else
+ {
+ ifxhcd_epqh_t *epqh2;
+ epqh2=urbd->epqh;
+ local_irq_save(flags);
+ LOCK_URBD_LIST(epqh2);
+ ifxhcd_complete_urb_sub(urbd);
+ UNLOCK_URBD_LIST(epqh2);
+ local_irq_restore (flags);
+ }
+ count--;
+ }
+ if(!list_empty(&epqh->release_list))
+ tasklet_schedule(&epqh->complete_urb_sub);
+ }
+
+ /*!
+ \brief Sets the final status of an URB and returns it to the device
+ driver. Any required cleanup of the URB is performed.
+ */
+ void ifxhcd_complete_urb(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_urbd_t *_urbd,
+ int _status)
+ {
+ unsigned long flags;
+
+ if(!_urbd)
+ {
+ IFX_ERROR("%s: invalid urbd\n",__func__);
+ return;
+ }
+ if (!_urbd->epqh)
+ {
+ IFX_ERROR("%s: invalid epqh\n",__func__);
+ return;
+ }
+
+ local_irq_save(flags);
+ LOCK_URBD_LIST(_urbd->epqh);
+ #ifdef __DEBUG__
+ if (CHK_DEBUG_LEVEL(DBG_HCDV | DBG_HCD_URB))
+ {
+ IFX_PRINT("%s: ehqh %p _urbd %p, urb %p,"
+ " device %d, ep %d %s/%s, status=%d\n",
+ __func__,_urbd->epqh,
+ _urbd,_urbd->urb,
+ (_urbd->urb)?usb_pipedevice(_urbd->urb->pipe):-1,
+ (_urbd->urb)?usb_pipeendpoint(_urbd->urb->pipe):-1,
+ (_urbd->urb)?(usb_pipein(_urbd->urb->pipe) ? "IN" : "OUT"):"--",
+ (_urbd->is_in) ? "IN" : "OUT",
+ _status);
+ if ((_urbd->urb)&& _urbd->epqh->ep_type == IFXUSB_EP_TYPE_ISOC)
+ {
+ int i;
+ for (i = 0; i < _urbd->urb->number_of_packets; i++)
+ IFX_PRINT(" ISO Desc %d status: %d\n", i, _urbd->urb->iso_frame_desc[i].status);
+ }
+ }
+ #endif
+ _urbd->status = _status;
+
+ if(_urbd->phase!=URBD_FINISHING)
+ {
+ if(_urbd->phase!=URBD_DEQUEUEING && _urbd->phase!=URBD_COMPLETING)
+ printk(KERN_INFO "Warning: %s() Strange URBD PHASE %d\n",__func__,_urbd->phase);
+ if(_urbd->urb)
+ {
+ if( _urbd->status == 0
+ && _urbd->phase==URBD_COMPLETING
+ && in_irq())
+ {
+ list_move_tail(&_urbd->ql,&_urbd->epqh->release_list);
+ if(!_urbd->epqh->complete_urb_sub.func)
+ {
+ _urbd->epqh->complete_urb_sub.next = NULL;
+ _urbd->epqh->complete_urb_sub.state = 0;
+ atomic_set( &_urbd->epqh->complete_urb_sub.count, 0);
+ _urbd->epqh->complete_urb_sub.func = ifxhcd_complete_urb_func;
+ _urbd->epqh->complete_urb_sub.data = (unsigned long)_urbd->epqh;
+ }
+ tasklet_schedule(&_urbd->epqh->complete_urb_sub);
+ }
+ else
+ {
+ _urbd->phase=URBD_FINISHING;
+ ifxhcd_complete_urb_sub(_urbd);
+ }
+ UNLOCK_URBD_LIST(_urbd->epqh);
+ }
+ else
+ {
+ UNLOCK_URBD_LIST(_urbd->epqh);
+ kfree(_urbd);
+ }
+ }
+ else
+ {
+ printk(KERN_INFO "Warning: %s() Double Completing \n",__func__);
+ UNLOCK_URBD_LIST(_urbd->epqh);
+ }
+
+ local_irq_restore (flags);
+ }
+#else
+ static void ifxhcd_complete_urb_func(unsigned long data)
+ {
+ unsigned long flags;
+ ifxhcd_urbd_t *urbd;
+
+ urbd=((ifxhcd_urbd_t *)data);
+
+ // local_irq_save(flags);
+ if (!urbd)
+ IFX_ERROR("%s: invalid urbd\n",__func__);
+ else if (!urbd->epqh)
+ IFX_ERROR("%s: invalid epqd\n",__func__);
+ else
+ {
+ local_irq_save(flags);
+ LOCK_URBD_LIST(urbd->epqh);
+ ifxhcd_complete_urb_sub(urbd);
+ UNLOCK_URBD_LIST(urbd->epqh);
+ local_irq_restore (flags);
+ }
+ // local_irq_restore (flags);
+ }
+
+
+ /*!
+ \brief Sets the final status of an URB and returns it to the device driver. Any
+ required cleanup of the URB is performed.
+ */
+ void ifxhcd_complete_urb(ifxhcd_hcd_t *_ifxhcd, ifxhcd_urbd_t *_urbd, int _status)
+ {
+ unsigned long flags;
+
+ if(!_urbd)
+ {
+ IFX_ERROR("%s: invalid urbd\n",__func__);
+ return;
+ }
+ if (!_urbd->epqh)
+ {
+ IFX_ERROR("%s: invalid epqh\n",__func__);
+ return;
+ }
+
+ local_irq_save(flags);
+ LOCK_URBD_LIST(_urbd->epqh);
+ #ifdef __DEBUG__
+ if (CHK_DEBUG_LEVEL(DBG_HCDV | DBG_HCD_URB))
+ {
+ IFX_PRINT("%s: ehqh %p _urbd %p, urb %p, device %d, ep %d %s/%s, status=%d\n",
+ __func__,_urbd->epqh, _urbd,_urbd->urb,
+ (_urbd->urb)?usb_pipedevice(_urbd->urb->pipe):-1,
+ (_urbd->urb)?usb_pipeendpoint(_urbd->urb->pipe):-1,
+ (_urbd->urb)?(usb_pipein(_urbd->urb->pipe) ? "IN" : "OUT"):"--",
+ (_urbd->is_in) ? "IN" : "OUT",
+ _status);
+ if ((_urbd->urb)&& _urbd->epqh->ep_type == IFXUSB_EP_TYPE_ISOC)
+ {
+ int i;
+ for (i = 0; i < _urbd->urb->number_of_packets; i++)
+ IFX_PRINT(" ISO Desc %d status: %d\n", i, _urbd->urb->iso_frame_desc[i].status);
+ }
+ }
+ #endif
+ _urbd->status = _status;
+
+ if(_urbd->phase!=URBD_FINISHING)
+ {
+ if(_urbd->phase!=URBD_DEQUEUEING && _urbd->phase!=URBD_COMPLETING)
+ printk(KERN_INFO "Warning: %s() Strange URBD PHASE %d\n",__func__,_urbd->phase);
+ if(_urbd->urb)
+ {
+ if( _urbd->status == 0
+ && _urbd->phase==URBD_COMPLETING
+ && in_irq())
+ {
+ if(_urbd->complete_urb_sub.func)
+ printk(KERN_INFO "Warning: %s() URBD Tasklet is on already\n",__func__);
+ _urbd->phase=URBD_FINISHING;
+ _urbd->complete_urb_sub.next = NULL;
+ _urbd->complete_urb_sub.state = 0;
+ atomic_set( &_urbd->complete_urb_sub.count, 0);
+ _urbd->complete_urb_sub.func = ifxhcd_complete_urb_func;
+ _urbd->complete_urb_sub.data = (unsigned long)_urbd;
+ tasklet_schedule(&_urbd->complete_urb_sub);
+ }
+ else
+ {
+ _urbd->phase=URBD_FINISHING;
+ ifxhcd_complete_urb_sub(_urbd);
+ }
+ }
+ else
+ kfree(_urbd);
+ }
+ else
+ printk(KERN_INFO "Warning: %s() Double Completing \n",__func__);
+ UNLOCK_URBD_LIST(_urbd->epqh);
+ local_irq_restore (flags);
+ }
+#endif
+
+/*!
+ \brief Processes all the URBs in a single EPQHs. Completes them with
+ status and frees the URBD.
+ */
+static
+void kill_all_urbs_in_epqh(ifxhcd_hcd_t *_ifxhcd, ifxhcd_epqh_t *_epqh, int _status)
+{
+ struct list_head *item;
+ struct list_head *next;
+ ifxhcd_urbd_t *urbd;
+
+ if(!_epqh)
+ return;
+
+ IFX_DEBUGPL(DBG_HCDV, "%s %p\n",__func__,_epqh);
+ LOCK_URBD_LIST(_epqh);
+ list_for_each(item, &_epqh->urbd_list)
+ {
+ urbd = list_entry(item, ifxhcd_urbd_t, ql);
+ if( urbd->phase==URBD_IDLE
+ || urbd->phase==URBD_ACTIVE
+// || urbd->phase==URBD_STARTING
+ )
+ urbd->phase=URBD_DEQUEUEING;
+ }
+ list_for_each_safe(item, next, &_epqh->urbd_list)
+ {
+ urbd = list_entry(item, ifxhcd_urbd_t, ql);
+ if(urbd->phase==URBD_DEQUEUEING)
+ {
+ urbd->urb->status = _status;
+ urbd->phase = URBD_FINISHING;
+ ifxhcd_complete_urb_sub(urbd);
+ }
+ else if( urbd->phase==URBD_STARTED
+ || urbd->phase==URBD_STARTING
+// || urbd->phase==URBD_ACTIVE
+ )
+ {
+ if(ifxhcd_hc_halt(&_ifxhcd->core_if, _epqh->hc, HC_XFER_URB_DEQUEUE))
+ {
+ urbd->urb->status = _status;
+ urbd->phase=URBD_FINISHING;
+ ifxhcd_complete_urb_sub(urbd);
+ }
+ }
+ else
+ IFX_ERROR("%s: invalid urb phase:%d \n",__func__,urbd->phase);
+ }
+ UNLOCK_URBD_LIST(_epqh);
+ IFX_DEBUGPL(DBG_HCDV, "%s %p finish\n",__func__,_epqh);
+}
+
+
+/*!
+ \brief Free all EPS in one Processes all the URBs in a single list of EPQHs. Completes them with
+ -ETIMEDOUT and frees the URBD.
+ */
+static
+void epqh_list_free_1(ifxhcd_hcd_t *_ifxhcd, struct list_head *_epqh_list)
+{
+ ifxhcd_epqh_t *epqh;
+ struct list_head *item;
+ if (!_ifxhcd)
+ return;
+ if (!_epqh_list)
+ return;
+
+ IFX_DEBUGPL(DBG_HCDV, "%s %p\n",__func__,_epqh_list);
+
+ item = _epqh_list->next;
+ while(item != _epqh_list && item != item->next)
+ {
+ epqh = list_entry(item, ifxhcd_epqh_t, ql);
+ epqh->phase=EPQH_DISABLING;
+ item = item->next;
+ kill_all_urbs_in_epqh(_ifxhcd, epqh, -ETIMEDOUT);
+ #ifdef __STRICT_ORDER__
+ if(list_empty(&epqh->urbd_list) && list_empty(&epqh->release_list))
+ #else
+ if(list_empty(&epqh->urbd_list))
+ #endif
+ ifxhcd_epqh_free(epqh);
+ }
+ IFX_DEBUGPL(DBG_HCDV, "%s %p finish\n",__func__,_epqh_list);
+ /* Ensure there are no URBDs or URBs left. */
+}
+
+static
+void epqh_list_free_2(ifxhcd_hcd_t *_ifxhcd, struct list_head *_epqh_list)
+{
+ ifxhcd_epqh_t *epqh;
+ struct list_head *item;
+ struct list_head *next;
+ if (!_ifxhcd)
+ return;
+ if (!_epqh_list)
+ return;
+
+ IFX_DEBUGPL(DBG_HCDV, "%s %p\n",__func__,_epqh_list);
+ list_for_each_safe(item, next, _epqh_list)
+ {
+ epqh = list_entry(item, ifxhcd_epqh_t, ql);
+ if(item == item->next)
+ {
+ ifxhcd_epqh_free(epqh);
+ }
+ else
+ {
+ uint32_t count=0x80000;
+ #ifdef __STRICT_ORDER__
+ for(;(!list_empty(&epqh->urbd_list) || !list_empty(&epqh->release_list))&& count> 0; count--) udelay(1);
+ #else
+ for(;!list_empty(&epqh->urbd_list) && count> 0; count--) udelay(1);
+ #endif
+ if(!count)
+ IFX_ERROR("%s: unable to clear urbd in epqh \n",__func__);
+ ifxhcd_epqh_free(epqh);
+ }
+ }
+ IFX_DEBUGPL(DBG_HCDV, "%s %p finish\n",__func__,_epqh_list);
+ /* Ensure there are no URBDs or URBs left. */
+}
+
+static
+void epqh_list_free_all_sub(unsigned long data)
+{
+ ifxhcd_hcd_t *ifxhcd;
+
+ ifxhcd=(ifxhcd_hcd_t *)data;
+ epqh_list_free_1(ifxhcd, &ifxhcd->epqh_list_np );
+ epqh_list_free_1(ifxhcd, &ifxhcd->epqh_list_intr);
+ #ifdef __EN_ISOC__
+ epqh_list_free_1(ifxhcd, &ifxhcd->epqh_list_isoc);
+ #endif
+
+ epqh_list_free_2(ifxhcd, &ifxhcd->epqh_list_np );
+ epqh_list_free_2(ifxhcd, &ifxhcd->epqh_list_intr);
+ #ifdef __EN_ISOC__
+ epqh_list_free_2(ifxhcd, &ifxhcd->epqh_list_isoc);
+ #endif
+}
+
+static
+void epqh_list_free_all(ifxhcd_hcd_t *_ifxhcd)
+{
+ _ifxhcd->tasklet_free_epqh_list.next = NULL;
+ _ifxhcd->tasklet_free_epqh_list.state = 0;
+ atomic_set( &_ifxhcd->tasklet_free_epqh_list.count, 0);
+ _ifxhcd->tasklet_free_epqh_list.func=epqh_list_free_all_sub;
+ _ifxhcd->tasklet_free_epqh_list.data = (unsigned long)_ifxhcd;
+ tasklet_schedule(&_ifxhcd->tasklet_free_epqh_list);
+}
+
+
+/*!
+ \brief This function is called to handle the disconnection of host port.
+ */
+int32_t ifxhcd_disconnect(ifxhcd_hcd_t *_ifxhcd)
+{
+ IFX_DEBUGPL(DBG_HCDV, "%s(%p)\n", __func__, _ifxhcd);
+
+ _ifxhcd->disconnecting=1;
+ /* Set status flags for the hub driver. */
+ _ifxhcd->flags.b.port_connect_status_change = 1;
+ _ifxhcd->flags.b.port_connect_status = 0;
+
+ /*
+ * Shutdown any transfers in process by clearing the Tx FIFO Empty
+ * interrupt mask and status bits and disabling subsequent host
+ * channel interrupts.
+ */
+ {
+ gint_data_t intr = { .d32 = 0 };
+ intr.b.nptxfempty = 1;
+ intr.b.ptxfempty = 1;
+ intr.b.hcintr = 1;
+ ifxusb_mreg (&_ifxhcd->core_if.core_global_regs->gintmsk, intr.d32, 0);
+ ifxusb_mreg (&_ifxhcd->core_if.core_global_regs->gintsts, intr.d32, 0);
+ }
+
+ /* Respond with an error status to all URBs in the schedule. */
+ epqh_list_free_all(_ifxhcd);
+
+ /* Clean up any host channels that were in use. */
+ {
+ int num_channels;
+ ifxhcd_hc_t *channel;
+ ifxusb_hc_regs_t *hc_regs;
+ hcchar_data_t hcchar;
+ int i;
+
+ num_channels = _ifxhcd->core_if.params.host_channels;
+
+ for (i = 0; i < num_channels; i++)
+ {
+ channel = &_ifxhcd->ifxhc[i];
+ hc_regs = _ifxhcd->core_if.hc_regs[i];
+ hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
+ if (hcchar.b.chen)
+ printk(KERN_INFO "Warning: %s() HC still enabled\n",__func__);
+ ifxhcd_hc_cleanup(&_ifxhcd->core_if, channel);
+ }
+ }
+ IFX_DEBUGPL(DBG_HCDV, "%s(%p) finish\n", __func__, _ifxhcd);
+ return 1;
+}
+
+
+/*!
+ \brief Frees secondary storage associated with the ifxhcd_hcd structure contained
+ in the struct usb_hcd field.
+ */
+static void ifxhcd_freeextra(struct usb_hcd *_syshcd)
+{
+ ifxhcd_hcd_t *ifxhcd = syshcd_to_ifxhcd(_syshcd);
+
+ IFX_DEBUGPL(DBG_HCD, "IFXUSB HCD FREE\n");
+
+ /* Free memory for EPQH/URBD lists */
+ epqh_list_free_all(ifxhcd);
+
+ /* Free memory for the host channels. */
+ ifxusb_free_buf_h(ifxhcd->status_buf);
+ return;
+}
+
+/*!
+ \brief Initializes the HCD. This function allocates memory for and initializes the
+ static parts of the usb_hcd and ifxhcd_hcd structures. It also registers the
+ USB bus with the core and calls the hc_driver->start() function. It returns
+ a negative error on failure.
+ */
+int ifxhcd_init(ifxhcd_hcd_t *_ifxhcd)
+{
+ int retval = 0;
+ struct usb_hcd *syshcd = NULL;
+
+ IFX_DEBUGPL(DBG_HCD, "IFX USB HCD INIT\n");
+
+ INIT_EPQH_LIST_ALL(_ifxhcd);
+ INIT_EPQH_LIST(_ifxhcd);
+
+ init_timer(&_ifxhcd->autoprobe_timer);
+ init_timer(&_ifxhcd->host_probe_timer);
+ _ifxhcd->probe_sec = 5;
+ _ifxhcd->autoprobe_sec = 30;
+
+ _ifxhcd->hc_driver.description = _ifxhcd->core_if.core_name;
+ _ifxhcd->hc_driver.product_desc = "IFX USB Controller";
+ //_ifxhcd->hc_driver.hcd_priv_size = sizeof(ifxhcd_hcd_t);
+ _ifxhcd->hc_driver.hcd_priv_size = sizeof(unsigned long);
+ _ifxhcd->hc_driver.irq = ifxhcd_irq;
+ _ifxhcd->hc_driver.flags = HCD_MEMORY | HCD_USB2;
+ _ifxhcd->hc_driver.start = ifxhcd_start;
+ _ifxhcd->hc_driver.stop = ifxhcd_stop;
+ //_ifxhcd->hc_driver.reset =
+ //_ifxhcd->hc_driver.suspend =
+ //_ifxhcd->hc_driver.resume =
+ _ifxhcd->hc_driver.urb_enqueue = ifxhcd_urb_enqueue;
+ _ifxhcd->hc_driver.urb_dequeue = ifxhcd_urb_dequeue;
+ _ifxhcd->hc_driver.endpoint_disable = ifxhcd_endpoint_disable;
+ _ifxhcd->hc_driver.get_frame_number = ifxhcd_get_frame_number;
+ _ifxhcd->hc_driver.hub_status_data = ifxhcd_hub_status_data;
+ _ifxhcd->hc_driver.hub_control = ifxhcd_hub_control;
+ //_ifxhcd->hc_driver.hub_suspend =
+ //_ifxhcd->hc_driver.hub_resume =
+ _ifxhcd->pkt_remaining_reload_hs=PKT_REMAINING_RELOAD_HS;
+ _ifxhcd->pkt_remaining_reload_fs=PKT_REMAINING_RELOAD_FS;
+ _ifxhcd->pkt_remaining_reload_ls=PKT_REMAINING_RELOAD_LS;
+ _ifxhcd->pkt_count_limit_bo =8;
+ _ifxhcd->pkt_count_limit_bi =8;
+
+ /* Allocate memory for and initialize the base HCD and */
+ //syshcd = usb_create_hcd(&_ifxhcd->hc_driver, _ifxhcd->dev, _ifxhcd->dev->bus_id);
+ syshcd = usb_create_hcd(&_ifxhcd->hc_driver, _ifxhcd->dev, _ifxhcd->core_if.core_name);
+
+ if (syshcd == NULL)
+ {
+ retval = -ENOMEM;
+ goto error1;
+ }
+
+ syshcd->rsrc_start = (unsigned long)_ifxhcd->core_if.core_global_regs;
+ syshcd->regs = (void *)_ifxhcd->core_if.core_global_regs;
+ syshcd->self.otg_port = 0;
+
+ //*((unsigned long *)(&(syshcd->hcd_priv)))=(unsigned long)_ifxhcd;
+ //*((unsigned long *)(&(syshcd->hcd_priv[0])))=(unsigned long)_ifxhcd;
+ syshcd->hcd_priv[0]=(unsigned long)_ifxhcd;
+ _ifxhcd->syshcd=syshcd;
+ INIT_LIST_HEAD(&_ifxhcd->epqh_list_all );
+ INIT_LIST_HEAD(&_ifxhcd->epqh_list_np );
+ INIT_LIST_HEAD(&_ifxhcd->epqh_list_intr );
+ #ifdef __EN_ISOC__
+ INIT_LIST_HEAD(&_ifxhcd->epqh_list_isoc);
+ #endif
+
+ /*
+ * Create a host channel descriptor for each host channel implemented
+ * in the controller. Initialize the channel descriptor array.
+ */
+ {
+ int num_channels = _ifxhcd->core_if.params.host_channels;
+ int i;
+ for (i = 0; i < num_channels; i++)
+ {
+ _ifxhcd->ifxhc[i].hc_num = i;
+ IFX_DEBUGPL(DBG_HCDV, "HCD Added channel #%d\n", i);
+ }
+ }
+
+ /* Set device flags indicating whether the HCD supports DMA. */
+ if(_ifxhcd->dev->dma_mask)
+ *(_ifxhcd->dev->dma_mask) = ~0;
+ _ifxhcd->dev->coherent_dma_mask = ~0;
+
+ /*
+ * Finish generic HCD initialization and start the HCD. This function
+ * allocates the DMA buffer pool, registers the USB bus, requests the
+ * IRQ line, and calls ifxusb_hcd_start method.
+ */
+ retval = usb_add_hcd(syshcd, _ifxhcd->core_if.irq, 0
+ |IRQF_DISABLED
+ |IRQF_SHARED
+ );
+ if (retval < 0)
+ goto error2;
+
+ /*
+ * Allocate space for storing data on status transactions. Normally no
+ * data is sent, but this space acts as a bit bucket. This must be
+ * done after usb_add_hcd since that function allocates the DMA buffer
+ * pool.
+ */
+ _ifxhcd->status_buf = ifxusb_alloc_buf_h(IFXHCD_STATUS_BUF_SIZE, 1);
+
+ if (_ifxhcd->status_buf)
+ {
+ IFX_DEBUGPL(DBG_HCD, "IFX USB HCD Initialized, bus=%s, usbbus=%d\n", _ifxhcd->core_if.core_name, syshcd->self.busnum);
+ return 0;
+ }
+ IFX_ERROR("%s: status_buf allocation failed\n", __func__);
+
+ /* Error conditions */
+ usb_remove_hcd(syshcd);
+error2:
+ ifxhcd_freeextra(syshcd);
+ usb_put_hcd(syshcd);
+error1:
+ return retval;
+}
+
+/*!
+ \brief Removes the HCD.
+ Frees memory and resources associated with the HCD and deregisters the bus.
+ */
+void ifxhcd_remove(ifxhcd_hcd_t *_ifxhcd)
+{
+ struct usb_hcd *syshcd = ifxhcd_to_syshcd(_ifxhcd);
+
+ IFX_DEBUGPL(DBG_HCD, "IFX USB HCD REMOVE\n");
+
+ /* Turn off all interrupts */
+ ifxusb_wreg (&_ifxhcd->core_if.core_global_regs->gintmsk, 0);
+ ifxusb_mreg (&_ifxhcd->core_if.core_global_regs->gahbcfg, 1, 0);
+
+ usb_remove_hcd(syshcd);
+ ifxhcd_freeextra(syshcd);
+ usb_put_hcd(syshcd);
+
+ return;
+}
+
+
+/* =========================================================================
+ * Linux HC Driver Functions
+ * ========================================================================= */
+
+/*!
+ \brief Initializes the IFXUSB controller and its root hub and prepares it for host
+ mode operation. Activates the root port. Returns 0 on success and a negative
+ error code on failure.
+ Called by USB stack.
+ */
+int ifxhcd_start(struct usb_hcd *_syshcd)
+{
+ ifxhcd_hcd_t *ifxhcd = syshcd_to_ifxhcd (_syshcd);
+ ifxusb_core_if_t *core_if = &ifxhcd->core_if;
+ struct usb_bus *bus;
+
+ IFX_DEBUGPL(DBG_HCD, "IFX USB HCD START\n");
+
+ bus = hcd_to_bus(_syshcd);
+
+ /* Initialize the bus state. */
+ _syshcd->state = HC_STATE_RUNNING;
+
+ /* Initialize and connect root hub if one is not already attached */
+ if (bus->root_hub)
+ {
+ IFX_DEBUGPL(DBG_HCD, "IFX USB HCD Has Root Hub\n");
+ /* Inform the HUB driver to resume. */
+ usb_hcd_resume_root_hub(_syshcd);
+ }
+
+ ifxhcd->flags.d32 = 0;
+
+ /* Put all channels in the free channel list and clean up channel states.*/
+ {
+ int num_channels = ifxhcd->core_if.params.host_channels;
+ int i;
+ for (i = 0; i < num_channels; i++)
+ {
+ ifxhcd_hc_t *channel;
+ channel = &ifxhcd->ifxhc[i];
+ ifxhcd_hc_cleanup(&ifxhcd->core_if, channel);
+ }
+ }
+ /* Initialize the USB core for host mode operation. */
+
+ ifxusb_host_enable_interrupts(core_if);
+ ifxusb_enable_global_interrupts_h(core_if);
+ ifxusb_phy_power_on_h (core_if);
+
+ ifxusb_vbus_init(core_if);
+
+ /* Turn on the vbus power. */
+ {
+ hprt0_data_t hprt0;
+ hprt0.d32 = ifxusb_read_hprt0(core_if);
+
+ IFX_PRINT("Init: Power Port (%d)\n", hprt0.b.prtpwr);
+ if (hprt0.b.prtpwr == 0 )
+ {
+ hprt0.b.prtpwr = 1;
+ ifxusb_wreg(core_if->hprt0, hprt0.d32);
+ ifxusb_vbus_on(core_if);
+ }
+ }
+ return 0;
+}
+
+/*!
+ \brief Halts the IFXUSB host mode operations in a clean manner. USB transfers are
+ stopped.
+ */
+ #if defined(__IS_AR10__)
+void ifxusb_oc_int_free(int port);
+ #else
+void ifxusb_oc_int_free(void);
+ #endif
+
+void ifxhcd_stop(struct usb_hcd *_syshcd)
+{
+ ifxhcd_hcd_t *ifxhcd = syshcd_to_ifxhcd(_syshcd);
+ hprt0_data_t hprt0 = { .d32=0 };
+
+ IFX_DEBUGPL(DBG_HCD, "IFX USB HCD STOP\n");
+
+ /* Turn off all interrupts. */
+ ifxusb_disable_global_interrupts_h(&ifxhcd->core_if );
+ ifxusb_host_disable_interrupts(&ifxhcd->core_if );
+
+ /*
+ * The root hub should be disconnected before this function is called.
+ * The disconnect will clear the URBD lists (via ..._hcd_urb_dequeue)
+ * and the EPQH lists (via ..._hcd_endpoint_disable).
+ */
+
+ /* Turn off the vbus power */
+ IFX_PRINT("PortPower off\n");
+
+ ifxusb_vbus_off(&ifxhcd->core_if );
+
+
+ #if defined(__IS_AR10__)
+ ifxusb_oc_int_free(ifxhcd->core_if.core_no);
+ #else
+ ifxusb_oc_int_free();
+ #endif
+
+
+ ifxusb_vbus_free(&ifxhcd->core_if );
+ hprt0.b.prtpwr = 0;
+ ifxusb_wreg(ifxhcd->core_if.hprt0, hprt0.d32);
+ return;
+}
+
+/*!
+ \brief Returns the current frame number
+ */
+int ifxhcd_get_frame_number(struct usb_hcd *_syshcd)
+{
+ ifxhcd_hcd_t *ifxhcd = syshcd_to_ifxhcd(_syshcd);
+ hfnum_data_t hfnum;
+
+ hfnum.d32 = ifxusb_rreg(&ifxhcd->core_if.host_global_regs->hfnum);
+
+ return hfnum.b.frnum;
+}
+
+/*!
+ \brief Starts processing a USB transfer request specified by a USB Request Block
+ (URB). mem_flags indicates the type of memory allocation to use while
+ processing this URB.
+ */
+int ifxhcd_urb_enqueue( struct usb_hcd *_syshcd,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)
+ struct usb_host_endpoint *_sysep,
+#endif
+ struct urb *_urb,
+ gfp_t _mem_flags)
+{
+ ifxhcd_hcd_t *ifxhcd = syshcd_to_ifxhcd (_syshcd);
+ ifxhcd_epqh_t *epqh = NULL;
+
+ #ifdef __DEBUG__
+ if (CHK_DEBUG_LEVEL(DBG_HCDV | DBG_HCD_URB))
+ dump_urb_info(_urb, "ifxusb_hcd_urb_enqueue");
+ #endif //__DEBUG__
+
+ if (!ifxhcd->flags.b.port_connect_status) /* No longer connected. */
+ return -ENODEV;
+
+ #if !defined(__EN_ISOC__)
+ if(usb_pipetype(_urb->pipe) == PIPE_ISOCHRONOUS)
+ {
+ IFX_ERROR("ISOC transfer not supported!!!\n");
+ return -ENODEV;
+ }
+ #endif
+
+ if(_urb->hcpriv)
+ {
+ IFX_WARN("%s() Previous urb->hcpriv exist %p\n",__func__,_urb->hcpriv);
+ #if 1
+ return -ENOSPC;
+ #endif
+ }
+
+ epqh=ifxhcd_urbd_create (ifxhcd,_urb);
+ if (!epqh)
+ {
+ IFX_ERROR("IFXUSB HCD URB Enqueue failed creating URBD\n");
+ return -ENOSPC;
+ }
+ if(epqh->phase==EPQH_DISABLING )
+ {
+ IFX_ERROR("Enqueue to a DISABLING EP!!!\n");
+ return -ENODEV;
+ }
+
+ #ifdef __DYN_SOF_INTR__
+ ifxhcd->dyn_sof_count = DYN_SOF_COUNT_DEF;
+ #endif
+ //enable_sof(ifxhcd);
+ {
+ gint_data_t gintsts;
+ gintsts.d32=0;
+ gintsts.b.sofintr = 1;
+ ifxusb_mreg(&ifxhcd->core_if.core_global_regs->gintmsk, 0,gintsts.d32);
+ }
+
+ if(epqh->phase==EPQH_IDLE || epqh->phase==EPQH_STDBY )
+ {
+ epqh->phase=EPQH_READY;
+ #ifdef __EPQD_DESTROY_TIMEOUT__
+ del_timer(&epqh->destroy_timer);
+ #endif
+ }
+ select_eps(ifxhcd);
+ return 0;
+}
+
+/*!
+ \brief Aborts/cancels a USB transfer request. Always returns 0 to indicate
+ success.
+ */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)
+int ifxhcd_urb_dequeue(struct usb_hcd *_syshcd, struct urb *_urb)
+#else
+int ifxhcd_urb_dequeue(struct usb_hcd *_syshcd, struct urb *_urb, int status)
+#endif
+{
+ ifxhcd_hcd_t *ifxhcd;
+ struct usb_host_endpoint *sysep;
+ ifxhcd_urbd_t *urbd;
+ ifxhcd_epqh_t *epqh;
+
+ IFX_DEBUGPL(DBG_HCD, "IFXUSB HCD URB Dequeue\n");
+ #if !defined(__EN_ISOC__)
+ if(usb_pipetype(_urb->pipe) == PIPE_ISOCHRONOUS)
+ return 0;
+ #endif
+
+ ifxhcd = syshcd_to_ifxhcd(_syshcd);
+
+ urbd = (ifxhcd_urbd_t *) _urb->hcpriv;
+ if(!urbd)
+ {
+ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)
+ _urb->status=-ETIMEDOUT;
+ usb_hcd_giveback_urb(_syshcd, _urb);
+ #else
+// usb_hcd_giveback_urb(_syshcd, _urb,-ETIMEDOUT);
+ usb_hcd_giveback_urb(_syshcd, _urb,status);
+ #endif
+ return 0;
+ }
+
+ sysep = ifxhcd_urb_to_endpoint(_urb);
+ if(sysep)
+ {
+ LOCK_EPQH_LIST_ALL(ifxhcd);
+ epqh = sysep_to_epqh(ifxhcd,sysep);
+ UNLOCK_EPQH_LIST_ALL(ifxhcd);
+ if(epqh!=urbd->epqh)
+ IFX_ERROR("%s inconsistant epqh %p %p\n",__func__,epqh,urbd->epqh);
+ }
+ else
+ epqh = (ifxhcd_epqh_t *) urbd->epqh;
+ if(!ifxhcd->flags.b.port_connect_status || !epqh)
+ {
+ urbd->phase=URBD_DEQUEUEING;
+ ifxhcd_complete_urb(ifxhcd, urbd, -ENODEV);
+ }
+ else
+ {
+ LOCK_URBD_LIST(epqh);
+ if( urbd->phase==URBD_IDLE
+ || urbd->phase==URBD_ACTIVE
+// || urbd->phase==URBD_STARTING
+ )
+ {
+ urbd->phase=URBD_DEQUEUEING;
+ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)
+ ifxhcd_complete_urb(ifxhcd, urbd, -ETIMEDOUT);
+ #else
+ ifxhcd_complete_urb(ifxhcd, urbd, status);
+ #endif
+ }
+ else if( urbd->phase==URBD_STARTED
+ || urbd->phase==URBD_STARTING
+// || urbd->phase==URBD_ACTIVE
+ )
+ {
+ if(ifxhcd_hc_halt(&ifxhcd->core_if, epqh->hc, HC_XFER_URB_DEQUEUE))
+ {
+ urbd->phase=URBD_DEQUEUEING;
+ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)
+ ifxhcd_complete_urb(ifxhcd, urbd, -ETIMEDOUT);
+ #else
+ ifxhcd_complete_urb(ifxhcd, urbd, status);
+ #endif
+ ifxhcd_epqh_idle(epqh);
+ }
+ }
+ UNLOCK_URBD_LIST(epqh);
+ }
+ return 0;
+}
+
+
+/*!
+ \brief Frees resources in the IFXUSB controller related to a given endpoint. Also
+ clears state in the HCD related to the endpoint. Any URBs for the endpoint
+ must already be dequeued.
+ */
+void ifxhcd_endpoint_disable( struct usb_hcd *_syshcd,
+ struct usb_host_endpoint *_sysep)
+{
+ ifxhcd_hcd_t *ifxhcd;
+ ifxhcd_epqh_t *epqh;
+
+ IFX_DEBUGPL(DBG_HCD, "IFXUSB HCD EP DISABLE: _bEndpointAddress=0x%02x, "
+ "endpoint=%d\n", _sysep->desc.bEndpointAddress,
+ ifxhcd_ep_addr_to_endpoint(_sysep->desc.bEndpointAddress));
+
+ ifxhcd = syshcd_to_ifxhcd(_syshcd);
+
+ LOCK_EPQH_LIST_ALL(ifxhcd);
+ epqh = sysep_to_epqh(ifxhcd,_sysep);
+ UNLOCK_EPQH_LIST_ALL(ifxhcd);
+
+ if (!epqh)
+ {
+ return;
+ }
+ else
+ {
+ if (epqh->sysep!=_sysep)
+ {
+ IFX_ERROR("%s inconsistant sysep %p %p %p\n",__func__,epqh,epqh->sysep,_sysep);
+ return;
+ }
+
+ epqh->phase=EPQH_DISABLING;
+ kill_all_urbs_in_epqh(ifxhcd, epqh, -ETIMEDOUT);
+ {
+ uint32_t count=0x80000;
+ for(;!list_empty(&epqh->urbd_list) && count> 0; count--) udelay(1);
+ if(!count)
+ IFX_ERROR("%s: unable to clear urbd in epqh \n",__func__);
+ }
+ ifxhcd_epqh_free(epqh);
+ }
+ IFX_DEBUGPL(DBG_HCD, "IFXUSB HCD EP DISABLE: done\n");
+}
+
+
+/*!
+ \brief Handles host mode interrupts for the IFXUSB controller. Returns IRQ_NONE if
+ there was no interrupt to handle. Returns IRQ_HANDLED if there was a valid
+ interrupt.
+
+ This function is called by the USB core when an interrupt occurs
+ */
+irqreturn_t ifxhcd_irq(struct usb_hcd *_syshcd)
+{
+ ifxhcd_hcd_t *ifxhcd = syshcd_to_ifxhcd (_syshcd);
+ int32_t retval=0;
+
+ //mask_and_ack_ifx_irq (ifxhcd->core_if.irq);
+ retval = ifxhcd_handle_intr(ifxhcd);
+ return IRQ_RETVAL(retval);
+}
+
+
+
+/*!
+ \brief Creates Status Change bitmap for the root hub and root port. The bitmap is
+ returned in buf. Bit 0 is the status change indicator for the root hub. Bit 1
+ is the status change indicator for the single root port. Returns 1 if either
+ change indicator is 1, otherwise returns 0.
+ */
+int ifxhcd_hub_status_data(struct usb_hcd *_syshcd, char *_buf)
+{
+ ifxhcd_hcd_t *ifxhcd = syshcd_to_ifxhcd (_syshcd);
+
+ _buf[0] = 0;
+ _buf[0] |= (ifxhcd->flags.b.port_connect_status_change ||
+ ifxhcd->flags.b.port_reset_change ||
+ ifxhcd->flags.b.port_enable_change ||
+ ifxhcd->flags.b.port_suspend_change ||
+ ifxhcd->flags.b.port_over_current_change) << 1;
+
+ #ifdef __DEBUG__
+ if (_buf[0])
+ {
+ IFX_DEBUGPL(DBG_HCD, "IFXUSB HCD HUB STATUS DATA:"
+ " Root port status changed\n");
+ IFX_DEBUGPL(DBG_HCDV, " port_connect_status_change: %d\n",
+ ifxhcd->flags.b.port_connect_status_change);
+ IFX_DEBUGPL(DBG_HCDV, " port_reset_change: %d\n",
+ ifxhcd->flags.b.port_reset_change);
+ IFX_DEBUGPL(DBG_HCDV, " port_enable_change: %d\n",
+ ifxhcd->flags.b.port_enable_change);
+ IFX_DEBUGPL(DBG_HCDV, " port_suspend_change: %d\n",
+ ifxhcd->flags.b.port_suspend_change);
+ IFX_DEBUGPL(DBG_HCDV, " port_over_current_change: %d\n",
+ ifxhcd->flags.b.port_over_current_change);
+ {
+ hprt0_data_t hprt0;
+ hprt0.d32 = ifxusb_rreg(ifxhcd->core_if.hprt0);
+ IFX_DEBUGPL(DBG_HCDV, " port reg :%08X\n",hprt0.d32);
+ IFX_DEBUGPL(DBG_HCDV, " port reg :connect: %d/%d\n",hprt0.b.prtconnsts,hprt0.b.prtconndet);
+ IFX_DEBUGPL(DBG_HCDV, " port reg :enable: %d/%d\n",hprt0.b.prtena,hprt0.b.prtenchng);
+ IFX_DEBUGPL(DBG_HCDV, " port reg :OC: %d/%d\n",hprt0.b.prtovrcurract,hprt0.b.prtovrcurrchng);
+ IFX_DEBUGPL(DBG_HCDV, " port reg :rsume/suspend/reset: %d/%d/%d\n",hprt0.b.prtres,hprt0.b.prtsusp,hprt0.b.prtrst);
+ IFX_DEBUGPL(DBG_HCDV, " port reg :port power: %d/\n",hprt0.b.prtpwr);
+ IFX_DEBUGPL(DBG_HCDV, " port reg :speed: %d/\n",hprt0.b.prtspd);
+ }
+ }
+ #endif //__DEBUG__
+ return (_buf[0] != 0);
+}
+
+#ifdef __WITH_HS_ELECT_TST__
+ extern void do_setup(ifxusb_core_if_t *_core_if) ;
+ extern void do_in_ack(ifxusb_core_if_t *_core_if);
+#endif //__WITH_HS_ELECT_TST__
+
+/*!
+ \brief Handles hub class-specific requests.
+ */
+int ifxhcd_hub_control( struct usb_hcd *_syshcd,
+ u16 _typeReq,
+ u16 _wValue,
+ u16 _wIndex,
+ char *_buf,
+ u16 _wLength)
+{
+ int retval = 0;
+ ifxhcd_hcd_t *ifxhcd = syshcd_to_ifxhcd (_syshcd);
+ ifxusb_core_if_t *core_if = &ifxhcd->core_if;
+ struct usb_hub_descriptor *desc;
+ hprt0_data_t hprt0 = {.d32 = 0};
+
+ uint32_t port_status;
+
+ switch (_typeReq)
+ {
+ case ClearHubFeature:
+ IFX_DEBUGPL (DBG_HCD, "IFXUSB HCD HUB CONTROL - "
+ "ClearHubFeature 0x%x\n", _wValue);
+ switch (_wValue)
+ {
+ case C_HUB_LOCAL_POWER:
+ case C_HUB_OVER_CURRENT:
+ /* Nothing required here */
+ break;
+ default:
+ retval = -EINVAL;
+ IFX_ERROR ("IFXUSB HCD - "
+ "ClearHubFeature request %xh unknown\n", _wValue);
+ }
+ break;
+ case ClearPortFeature:
+ if (!_wIndex || _wIndex > 1)
+ goto error;
+
+ switch (_wValue)
+ {
+ case USB_PORT_FEAT_ENABLE:
+ IFX_DEBUGPL (DBG_ANY, "IFXUSB HCD HUB CONTROL - "
+ "ClearPortFeature USB_PORT_FEAT_ENABLE\n");
+ hprt0.d32 = ifxusb_read_hprt0 (core_if);
+ hprt0.b.prtena = 1;
+ ifxusb_wreg(core_if->hprt0, hprt0.d32);
+ break;
+ case USB_PORT_FEAT_SUSPEND:
+ IFX_DEBUGPL (DBG_HCD, "IFXUSB HCD HUB CONTROL - "
+ "ClearPortFeature USB_PORT_FEAT_SUSPEND\n");
+ hprt0.d32 = ifxusb_read_hprt0 (core_if);
+ hprt0.b.prtres = 1;
+ ifxusb_wreg(core_if->hprt0, hprt0.d32);
+ /* Clear Resume bit */
+ mdelay (100);
+ hprt0.b.prtres = 0;
+ ifxusb_wreg(core_if->hprt0, hprt0.d32);
+ break;
+ case USB_PORT_FEAT_POWER:
+ IFX_DEBUGPL (DBG_HCD, "IFXUSB HCD HUB CONTROL - "
+ "ClearPortFeature USB_PORT_FEAT_POWER\n");
+ #ifdef __IS_DUAL__
+ ifxusb_vbus_off(core_if);
+ #else
+ ifxusb_vbus_off(core_if);
+ #endif
+ hprt0.d32 = ifxusb_read_hprt0 (core_if);
+ hprt0.b.prtpwr = 0;
+ ifxusb_wreg(core_if->hprt0, hprt0.d32);
+ break;
+ case USB_PORT_FEAT_INDICATOR:
+ IFX_DEBUGPL (DBG_HCD, "IFXUSB HCD HUB CONTROL - "
+ "ClearPortFeature USB_PORT_FEAT_INDICATOR\n");
+ /* Port inidicator not supported */
+ break;
+ case USB_PORT_FEAT_C_CONNECTION:
+ /* Clears drivers internal connect status change
+ * flag */
+ IFX_DEBUGPL (DBG_HCD, "IFXUSB HCD HUB CONTROL - "
+ "ClearPortFeature USB_PORT_FEAT_C_CONNECTION\n");
+ ifxhcd->flags.b.port_connect_status_change = 0;
+ break;
+ case USB_PORT_FEAT_C_RESET:
+ /* Clears the driver's internal Port Reset Change
+ * flag */
+ IFX_DEBUGPL (DBG_HCD, "IFXUSB HCD HUB CONTROL - "
+ "ClearPortFeature USB_PORT_FEAT_C_RESET\n");
+ ifxhcd->flags.b.port_reset_change = 0;
+ break;
+ case USB_PORT_FEAT_C_ENABLE:
+ /* Clears the driver's internal Port
+ * Enable/Disable Change flag */
+ IFX_DEBUGPL (DBG_HCD, "IFXUSB HCD HUB CONTROL - "
+ "ClearPortFeature USB_PORT_FEAT_C_ENABLE\n");
+ ifxhcd->flags.b.port_enable_change = 0;
+ break;
+ case USB_PORT_FEAT_C_SUSPEND:
+ /* Clears the driver's internal Port Suspend
+ * Change flag, which is set when resume signaling on
+ * the host port is complete */
+ IFX_DEBUGPL (DBG_HCD, "IFXUSB HCD HUB CONTROL - "
+ "ClearPortFeature USB_PORT_FEAT_C_SUSPEND\n");
+ ifxhcd->flags.b.port_suspend_change = 0;
+ break;
+ case USB_PORT_FEAT_C_OVER_CURRENT:
+ IFX_DEBUGPL (DBG_HCD, "IFXUSB HCD HUB CONTROL - "
+ "ClearPortFeature USB_PORT_FEAT_C_OVER_CURRENT\n");
+ ifxhcd->flags.b.port_over_current_change = 0;
+ break;
+ default:
+ retval = -EINVAL;
+ IFX_ERROR ("IFXUSB HCD - "
+ "ClearPortFeature request %xh "
+ "unknown or unsupported\n", _wValue);
+ }
+ break;
+ case GetHubDescriptor:
+ IFX_DEBUGPL (DBG_HCD, "IFXUSB HCD HUB CONTROL - "
+ "GetHubDescriptor\n");
+ desc = (struct usb_hub_descriptor *)_buf;
+ desc->bDescLength = 9;
+ desc->bDescriptorType = 0x29;
+ desc->bNbrPorts = 1;
+ desc->wHubCharacteristics = 0x08;
+ desc->bPwrOn2PwrGood = 1;
+ desc->bHubContrCurrent = 0;
+
+ desc->u.hs.DeviceRemovable[0] = 0;
+ desc->u.hs.DeviceRemovable[1] = 1;
+ /*desc->bitmap[0] = 0;
+ desc->bitmap[1] = 0xff;*/
+ break;
+ case GetHubStatus:
+ IFX_DEBUGPL (DBG_HCD, "IFXUSB HCD HUB CONTROL - "
+ "GetHubStatus\n");
+ memset (_buf, 0, 4);
+ break;
+ case GetPortStatus:
+ IFX_DEBUGPL (DBG_HCD, "IFXUSB HCD HUB CONTROL - "
+ "GetPortStatus\n");
+ if (!_wIndex || _wIndex > 1)
+ goto error;
+ port_status = 0;
+ if (ifxhcd->flags.b.port_connect_status_change)
+ port_status |= (1 << USB_PORT_FEAT_C_CONNECTION);
+ if (ifxhcd->flags.b.port_enable_change)
+ port_status |= (1 << USB_PORT_FEAT_C_ENABLE);
+ if (ifxhcd->flags.b.port_suspend_change)
+ port_status |= (1 << USB_PORT_FEAT_C_SUSPEND);
+ if (ifxhcd->flags.b.port_reset_change)
+ port_status |= (1 << USB_PORT_FEAT_C_RESET);
+ if (ifxhcd->flags.b.port_over_current_change)
+ {
+ IFX_ERROR("Device Not Supported\n");
+ port_status |= (1 << USB_PORT_FEAT_C_OVER_CURRENT);
+ }
+ if (!ifxhcd->flags.b.port_connect_status)
+ {
+ /*
+ * The port is disconnected, which means the core is
+ * either in device mode or it soon will be. Just
+ * return 0's for the remainder of the port status
+ * since the port register can't be read if the core
+ * is in device mode.
+ */
+ *((u32 *) _buf) = cpu_to_le32(port_status);
+ break;
+ }
+
+ hprt0.d32 = ifxusb_rreg(core_if->hprt0);
+ IFX_DEBUGPL(DBG_HCDV, " HPRT0: 0x%08x\n", hprt0.d32);
+ if (hprt0.b.prtconnsts)
+ port_status |= (1 << USB_PORT_FEAT_CONNECTION);
+ if (hprt0.b.prtena)
+ {
+ ifxhcd->disconnecting=0;
+ port_status |= (1 << USB_PORT_FEAT_ENABLE);
+ }
+ if (hprt0.b.prtsusp)
+ port_status |= (1 << USB_PORT_FEAT_SUSPEND);
+ if (hprt0.b.prtovrcurract)
+ port_status |= (1 << USB_PORT_FEAT_OVER_CURRENT);
+ if (hprt0.b.prtrst)
+ port_status |= (1 << USB_PORT_FEAT_RESET);
+ if (hprt0.b.prtpwr)
+ port_status |= (1 << USB_PORT_FEAT_POWER);
+ if (hprt0.b.prtspd == IFXUSB_HPRT0_PRTSPD_HIGH_SPEED)
+ port_status |= USB_PORT_STAT_HIGH_SPEED;
+ else if (hprt0.b.prtspd == IFXUSB_HPRT0_PRTSPD_LOW_SPEED)
+ port_status |= USB_PORT_STAT_LOW_SPEED;
+ if (hprt0.b.prttstctl)
+ port_status |= (1 << USB_PORT_FEAT_TEST);
+ /* USB_PORT_FEAT_INDICATOR unsupported always 0 */
+ *((u32 *) _buf) = cpu_to_le32(port_status);
+ break;
+ case SetHubFeature:
+ IFX_DEBUGPL (DBG_HCD, "IFXUSB HCD HUB CONTROL - "
+ "SetHubFeature\n");
+ /* No HUB features supported */
+ break;
+ case SetPortFeature:
+ if (_wValue != USB_PORT_FEAT_TEST && (!_wIndex || _wIndex > 1))
+ goto error;
+ /*
+ * The port is disconnected, which means the core is
+ * either in device mode or it soon will be. Just
+ * return without doing anything since the port
+ * register can't be written if the core is in device
+ * mode.
+ */
+ if (!ifxhcd->flags.b.port_connect_status)
+ break;
+ switch (_wValue)
+ {
+ case USB_PORT_FEAT_SUSPEND:
+ IFX_DEBUGPL (DBG_HCD, "IFXUSB HCD HUB CONTROL - "
+ "SetPortFeature - USB_PORT_FEAT_SUSPEND\n");
+ hprt0.d32 = ifxusb_read_hprt0 (core_if);
+ hprt0.b.prtsusp = 1;
+ ifxusb_wreg(core_if->hprt0, hprt0.d32);
+ //IFX_PRINT( "SUSPEND: HPRT0=%0x\n", hprt0.d32);
+ /* Suspend the Phy Clock */
+ {
+ pcgcctl_data_t pcgcctl = {.d32=0};
+ pcgcctl.b.stoppclk = 1;
+ ifxusb_wreg(core_if->pcgcctl, pcgcctl.d32);
+ }
+ break;
+ case USB_PORT_FEAT_POWER:
+ IFX_DEBUGPL (DBG_HCD, "IFXUSB HCD HUB CONTROL - "
+ "SetPortFeature - USB_PORT_FEAT_POWER\n");
+ ifxusb_vbus_on (core_if);
+ hprt0.d32 = ifxusb_read_hprt0 (core_if);
+ hprt0.b.prtpwr = 1;
+ ifxusb_wreg(core_if->hprt0, hprt0.d32);
+ break;
+ case USB_PORT_FEAT_RESET:
+ IFX_DEBUGPL (DBG_HCD, "IFXUSB HCD HUB CONTROL - "
+ "SetPortFeature - USB_PORT_FEAT_RESET\n");
+ hprt0.d32 = ifxusb_read_hprt0 (core_if);
+ hprt0.b.prtrst = 1;
+ ifxusb_wreg(core_if->hprt0, hprt0.d32);
+ /* Clear reset bit in 10ms (FS/LS) or 50ms (HS) */
+ MDELAY (60);
+ hprt0.b.prtrst = 0;
+ ifxusb_wreg(core_if->hprt0, hprt0.d32);
+ break;
+ #ifdef __WITH_HS_ELECT_TST__
+ case USB_PORT_FEAT_TEST:
+ {
+ uint32_t t;
+ gint_data_t gintmsk;
+ t = (_wIndex >> 8); /* MSB wIndex USB */
+ IFX_DEBUGPL (DBG_HCD, "IFXUSB HCD HUB CONTROL - "
+ "SetPortFeature - USB_PORT_FEAT_TEST %d\n", t);
+ warn("USB_PORT_FEAT_TEST %d\n", t);
+ if (t < 6)
+ {
+ hprt0.d32 = ifxusb_read_hprt0 (core_if);
+ hprt0.b.prttstctl = t;
+ ifxusb_wreg(core_if->hprt0, hprt0.d32);
+ }
+ else if (t == 6) /* HS_HOST_PORT_SUSPEND_RESUME */
+ {
+ /* Save current interrupt mask */
+ gintmsk.d32 = ifxusb_rreg(&core_if->core_global_regs->gintmsk);
+
+ /* Disable all interrupts while we muck with
+ * the hardware directly
+ */
+ ifxusb_wreg(&core_if->core_global_regs->gintmsk, 0);
+
+ /* 15 second delay per the test spec */
+ mdelay(15000);
+
+ /* Drive suspend on the root port */
+ hprt0.d32 = ifxusb_read_hprt0 (core_if);
+ hprt0.b.prtsusp = 1;
+ hprt0.b.prtres = 0;
+ ifxusb_wreg(core_if->hprt0, hprt0.d32);
+
+ /* 15 second delay per the test spec */
+ mdelay(15000);
+
+ /* Drive resume on the root port */
+ hprt0.d32 = ifxusb_read_hprt0 (core_if);
+ hprt0.b.prtsusp = 0;
+ hprt0.b.prtres = 1;
+ ifxusb_wreg(core_if->hprt0, hprt0.d32);
+ mdelay(100);
+
+ /* Clear the resume bit */
+ hprt0.b.prtres = 0;
+ ifxusb_wreg(core_if->hprt0, hprt0.d32);
+
+ /* Restore interrupts */
+ ifxusb_wreg(&core_if->core_global_regs->gintmsk, gintmsk.d32);
+ }
+ else if (t == 7) /* SINGLE_STEP_GET_DEVICE_DESCRIPTOR setup */
+ {
+ /* Save current interrupt mask */
+ gintmsk.d32 = ifxusb_rreg(&core_if->core_global_regs->gintmsk);
+
+ /* Disable all interrupts while we muck with
+ * the hardware directly
+ */
+ ifxusb_wreg(&core_if->core_global_regs->gintmsk, 0);
+
+ /* 15 second delay per the test spec */
+ mdelay(15000);
+
+ /* Send the Setup packet */
+ do_setup(core_if);
+
+ /* 15 second delay so nothing else happens for awhile */
+ mdelay(15000);
+
+ /* Restore interrupts */
+ ifxusb_wreg(&core_if->core_global_regs->gintmsk, gintmsk.d32);
+ }
+
+ else if (t == 8) /* SINGLE_STEP_GET_DEVICE_DESCRIPTOR execute */
+ {
+ /* Save current interrupt mask */
+ gintmsk.d32 = ifxusb_rreg(&core_if->core_global_regs->gintmsk);
+
+ /* Disable all interrupts while we muck with
+ * the hardware directly
+ */
+ ifxusb_wreg(&core_if->core_global_regs->gintmsk, 0);
+
+ /* Send the Setup packet */
+ do_setup(core_if);
+
+ /* 15 second delay so nothing else happens for awhile */
+ mdelay(15000);
+
+ /* Send the In and Ack packets */
+ do_in_ack(core_if);
+
+ /* 15 second delay so nothing else happens for awhile */
+ mdelay(15000);
+
+ /* Restore interrupts */
+ ifxusb_wreg(&core_if->core_global_regs->gintmsk, gintmsk.d32);
+ }
+ }
+ break;
+ #endif //__WITH_HS_ELECT_TST__
+ case USB_PORT_FEAT_INDICATOR:
+ IFX_DEBUGPL (DBG_HCD, "IFXUSB HCD HUB CONTROL - "
+ "SetPortFeature - USB_PORT_FEAT_INDICATOR\n");
+ /* Not supported */
+ break;
+ default:
+ retval = -EINVAL;
+ IFX_ERROR ("IFXUSB HCD - "
+ "SetPortFeature request %xh "
+ "unknown or unsupported\n", _wValue);
+ }
+ break;
+ default:
+ error:
+ retval = -EINVAL;
+ IFX_WARN ("IFXUSB HCD - "
+ "Unknown hub control request type or invalid typeReq: %xh wIndex: %xh wValue: %xh\n",
+ _typeReq, _wIndex, _wValue);
+ }
+ return retval;
+}
+
+
+
+
+/*!
+ \brief This function trigger a data transfer for a host channel and
+ starts the transfer.
+
+ For a PING transfer in Slave mode, the Do Ping bit is set in the HCTSIZ
+ register along with a packet count of 1 and the channel is enabled. This
+ causes a single PING transaction to occur. Other fields in HCTSIZ are
+ simply set to 0 since no data transfer occurs in this case.
+
+ For a PING transfer in DMA mode, the HCTSIZ register is initialized with
+ all the information required to perform the subsequent data transfer. In
+ addition, the Do Ping bit is set in the HCTSIZ register. In this case, the
+ controller performs the entire PING protocol, then starts the data
+ transfer.
+ \param _core_if Pointer of core_if structure
+ \param _ifxhc Information needed to initialize the host channel. The xfer_len
+ value may be reduced to accommodate the max widths of the XferSize and
+ PktCnt fields in the HCTSIZn register. The multi_count value may be changed
+ to reflect the final xfer_len value.
+ */
+void ifxhcd_hc_start(ifxhcd_hcd_t *_ifxhcd, ifxhcd_hc_t *_ifxhc)
+{
+ ifxusb_core_if_t *core_if = &_ifxhcd->core_if;
+ uint32_t max_hc_xfer_size = core_if->params.max_transfer_size;
+ uint16_t max_hc_pkt_count = core_if->params.max_packet_count;
+ ifxusb_hc_regs_t *hc_regs = core_if->hc_regs[_ifxhc->hc_num];
+ hfnum_data_t hfnum;
+
+ hprt0_data_t hprt0;
+
+ if(_ifxhc->epqh->urbd->phase==URBD_DEQUEUEING)
+ return;
+
+ hprt0.d32 = ifxusb_read_hprt0(core_if);
+
+ if(_ifxhcd->pkt_remaining==0)
+ return;
+
+#if 0
+ if(_ifxhc->phase!=HC_WAITING)
+ printk(KERN_INFO "%s() line %d: _ifxhc->phase!=HC_WAITING :%d\n",__func__,__LINE__,_ifxhc->phase);
+ if(_ifxhc->epqh->urbd->phase==URBD_IDLE ) printk(KERN_INFO "%s() line %d: _ifxhc->epqh->urbd->phase==URBD_IDLE\n",__func__,__LINE__);
+// if(_ifxhc->epqh->urbd->phase==URBD_ACTIVE ) printk(KERN_INFO "%s() line %d: _ifxhc->epqh->urbd->phase==URBD_ACTIVE\n",__func__,__LINE__);
+ if(_ifxhc->epqh->urbd->phase==URBD_STARTING ) printk(KERN_INFO "%s() line %d: _ifxhc->epqh->urbd->phase==URBD_STARTING\n",__func__,__LINE__);
+ if(_ifxhc->epqh->urbd->phase==URBD_STARTED ) printk(KERN_INFO "%s() line %d: _ifxhc->epqh->urbd->phase==URBD_STARTED\n",__func__,__LINE__);
+ if(_ifxhc->epqh->urbd->phase==URBD_COMPLETING) printk(KERN_INFO "%s() line %d: _ifxhc->epqh->urbd->phase==URBD_COMPLETING\n",__func__,__LINE__);
+ if(_ifxhc->epqh->urbd->phase==URBD_DEQUEUEING) printk(KERN_INFO "%s() line %d: _ifxhc->epqh->urbd->phase==URBD_DEQUEUEING\n",__func__,__LINE__);
+ if(_ifxhc->epqh->urbd->phase==URBD_FINISHING ) printk(KERN_INFO "%s() line %d: _ifxhc->epqh->urbd->phase==URBD_FINISHING\n",__func__,__LINE__);
+#endif
+
+ if (hprt0.b.prtspd == IFXUSB_HPRT0_PRTSPD_HIGH_SPEED)
+ {
+ if (_ifxhc->split)
+ {
+ if(max_hc_pkt_count > _ifxhcd->pkt_remaining)
+ max_hc_pkt_count = _ifxhcd->pkt_remaining;
+ }
+ else if(_ifxhc->ep_type == IFXUSB_EP_TYPE_BULK)
+ {
+ if( _ifxhc->is_in && _ifxhcd->pkt_count_limit_bi && max_hc_pkt_count > _ifxhcd->pkt_count_limit_bi)
+ max_hc_pkt_count = _ifxhcd->pkt_count_limit_bi;
+ if(!_ifxhc->is_in && _ifxhcd->pkt_count_limit_bo && max_hc_pkt_count > _ifxhcd->pkt_count_limit_bo)
+ max_hc_pkt_count = _ifxhcd->pkt_count_limit_bo;
+ if(max_hc_pkt_count*8 > _ifxhcd->pkt_remaining)
+ max_hc_pkt_count = _ifxhcd->pkt_remaining/8;
+ }
+ else
+ {
+ if(max_hc_pkt_count > _ifxhcd->pkt_remaining)
+ max_hc_pkt_count = _ifxhcd->pkt_remaining;
+ }
+ }
+ else if (hprt0.b.prtspd == IFXUSB_HPRT0_PRTSPD_LOW_SPEED)
+ {
+ if(max_hc_pkt_count > _ifxhcd->pkt_remaining)
+ max_hc_pkt_count = _ifxhcd->pkt_remaining;
+ }
+ else
+ {
+ if(max_hc_pkt_count > _ifxhcd->pkt_remaining)
+ max_hc_pkt_count = _ifxhcd->pkt_remaining;
+ }
+
+ if(max_hc_pkt_count==0)
+ return;
+
+ if(max_hc_pkt_count * _ifxhc->mps < max_hc_xfer_size)
+ max_hc_xfer_size = max_hc_pkt_count * _ifxhc->mps;
+
+ _ifxhc->epqh->urbd->phase=URBD_STARTING;
+
+ if(_ifxhc->is_in || _ifxhc->speed != IFXUSB_EP_SPEED_HIGH || _ifxhc->xfer_len==0)
+ _ifxhc->epqh->do_ping=0;
+ if(_ifxhc->ep_type == IFXUSB_EP_TYPE_INTR || _ifxhc->ep_type == IFXUSB_EP_TYPE_ISOC)
+ _ifxhc->epqh->do_ping=0;
+ if(_ifxhc->ep_type == IFXUSB_EP_TYPE_CTRL && _ifxhc->control_phase != IFXHCD_CONTROL_DATA )
+ _ifxhc->epqh->do_ping=0;
+
+ if (_ifxhc->split > 0)
+ {
+ _ifxhc->start_pkt_count = 1;
+ if(!_ifxhc->is_in && _ifxhc->split>1) // OUT CSPLIT
+ _ifxhc->xfer_len = 0;
+ if (_ifxhc->xfer_len > _ifxhc->mps)
+ _ifxhc->xfer_len = _ifxhc->mps;
+ if (_ifxhc->xfer_len > 188)
+ _ifxhc->xfer_len = 188;
+ }
+ else if(_ifxhc->is_in)
+ {
+ _ifxhc->short_rw = 0;
+ if (_ifxhc->xfer_len > 0)
+ {
+ if (_ifxhc->xfer_len > max_hc_xfer_size)
+ _ifxhc->xfer_len = max_hc_xfer_size - _ifxhc->mps + 1;
+ _ifxhc->start_pkt_count = (_ifxhc->xfer_len + _ifxhc->mps - 1) / _ifxhc->mps;
+ if (_ifxhc->start_pkt_count > max_hc_pkt_count)
+ _ifxhc->start_pkt_count = max_hc_pkt_count;
+ }
+ else /* Need 1 packet for transfer length of 0. */
+ _ifxhc->start_pkt_count = 1;
+ _ifxhc->xfer_len = _ifxhc->start_pkt_count * _ifxhc->mps;
+ }
+ else //non-split out
+ {
+ if (_ifxhc->xfer_len == 0)
+ {
+ if(_ifxhc->short_rw==0)
+ printk(KERN_INFO "Info: %s() line %d: ZLP write without short_rw set! xfer_count:%d/%d \n",__func__,__LINE__,
+ _ifxhc->xfer_count,
+ _ifxhc->epqh->urbd->xfer_len);
+ _ifxhc->start_pkt_count = 1;
+ }
+ else
+ {
+ if (_ifxhc->xfer_len > max_hc_xfer_size)
+ {
+ _ifxhc->start_pkt_count = (max_hc_xfer_size / _ifxhc->mps);
+ _ifxhc->xfer_len = _ifxhc->start_pkt_count * _ifxhc->mps;
+ }
+ else
+ {
+ _ifxhc->start_pkt_count = (_ifxhc->xfer_len+_ifxhc->mps-1) / _ifxhc->mps;
+// if(_ifxhc->start_pkt_count * _ifxhc->mps == _ifxhc->xfer_len )
+// _ifxhc->start_pkt_count += _ifxhc->short_rw;
+ }
+ }
+ }
+
+ if (hprt0.b.prtspd == IFXUSB_HPRT0_PRTSPD_HIGH_SPEED)
+ {
+ if (_ifxhc->split)
+ {
+ if( _ifxhcd->pkt_remaining > _ifxhc->start_pkt_count)
+ _ifxhcd->pkt_remaining -= _ifxhc->start_pkt_count;
+ else
+ _ifxhcd->pkt_remaining = 0;
+ }
+ else if(_ifxhc->ep_type == IFXUSB_EP_TYPE_BULK)
+ {
+ if( _ifxhcd->pkt_remaining*8 > _ifxhc->start_pkt_count)
+ _ifxhcd->pkt_remaining -= (_ifxhc->start_pkt_count*8);
+ else
+ _ifxhcd->pkt_remaining = 0;
+ }
+ else
+ {
+ if( _ifxhcd->pkt_remaining > _ifxhc->start_pkt_count)
+ _ifxhcd->pkt_remaining -= _ifxhc->start_pkt_count;
+ else
+ _ifxhcd->pkt_remaining = 0;
+ }
+ }
+ else if (hprt0.b.prtspd == IFXUSB_HPRT0_PRTSPD_LOW_SPEED)
+ {
+ if( _ifxhcd->pkt_remaining > _ifxhc->start_pkt_count)
+ _ifxhcd->pkt_remaining -= _ifxhc->start_pkt_count;
+ else
+ _ifxhcd->pkt_remaining = 0;
+ }
+ else
+ {
+ if( _ifxhcd->pkt_remaining > _ifxhc->start_pkt_count)
+ _ifxhcd->pkt_remaining -= _ifxhc->start_pkt_count;
+ else
+ _ifxhcd->pkt_remaining = 0;
+ }
+
+ #ifdef __EN_ISOC__
+ if (_ifxhc->ep_type == IFXUSB_EP_TYPE_ISOC)
+ {
+ /* Set up the initial PID for the transfer. */
+ #if 1
+ _ifxhc->data_pid_start = IFXUSB_HC_PID_DATA0;
+ #else
+ if (_ifxhc->speed == IFXUSB_EP_SPEED_HIGH)
+ {
+ if (_ifxhc->is_in)
+ {
+ if (_ifxhc->multi_count == 1)
+ _ifxhc->data_pid_start = IFXUSB_HC_PID_DATA0;
+ else if (_ifxhc->multi_count == 2)
+ _ifxhc->data_pid_start = IFXUSB_HC_PID_DATA1;
+ else
+ _ifxhc->data_pid_start = IFXUSB_HC_PID_DATA2;
+ }
+ else
+ {
+ if (_ifxhc->multi_count == 1)
+ _ifxhc->data_pid_start = IFXUSB_HC_PID_DATA0;
+ else
+ _ifxhc->data_pid_start = IFXUSB_HC_PID_MDATA;
+ }
+ }
+ else
+ _ifxhc->data_pid_start = IFXUSB_HC_PID_DATA0;
+ #endif
+ }
+ #endif
+
+ IFX_DEBUGPL(DBG_HCDV, "%s: Channel %d\n", __func__, _ifxhc->hc_num);
+ {
+ hctsiz_data_t hctsiz= { .d32=0 };
+
+ hctsiz.b.dopng = _ifxhc->epqh->do_ping;
+ _ifxhc->epqh->do_ping=0;
+
+ if(_ifxhc->is_in || _ifxhc->speed != IFXUSB_EP_SPEED_HIGH || _ifxhc->xfer_len==0)
+ hctsiz.b.dopng = 0;
+ if(_ifxhc->ep_type == IFXUSB_EP_TYPE_INTR || _ifxhc->ep_type == IFXUSB_EP_TYPE_ISOC)
+ hctsiz.b.dopng = 0;
+ if(_ifxhc->ep_type == IFXUSB_EP_TYPE_CTRL && _ifxhc->control_phase != IFXHCD_CONTROL_DATA )
+ hctsiz.b.dopng = 0;
+
+ hctsiz.b.xfersize = _ifxhc->xfer_len;
+ hctsiz.b.pktcnt = _ifxhc->start_pkt_count;
+ hctsiz.b.pid = _ifxhc->data_pid_start;
+ ifxusb_wreg(&hc_regs->hctsiz, hctsiz.d32);
+
+ IFX_DEBUGPL(DBG_HCDV, " Xfer Size: %d\n", hctsiz.b.xfersize);
+ IFX_DEBUGPL(DBG_HCDV, " Num Pkts: %d\n" , hctsiz.b.pktcnt);
+ IFX_DEBUGPL(DBG_HCDV, " Start PID: %d\n", hctsiz.b.pid);
+ }
+ IFX_DEBUGPL(DBG_HCDV, " DMA: 0x%08x\n", (uint32_t)(CPHYSADDR( ((uint32_t)(_ifxhc->xfer_buff))+ _ifxhc->xfer_count )));
+ ifxusb_wreg(&hc_regs->hcdma, (uint32_t)(CPHYSADDR( ((uint32_t)(_ifxhc->xfer_buff))+ _ifxhc->xfer_count )));
+
+ /* Start the split */
+ if (_ifxhc->split>0)
+ {
+ hcsplt_data_t hcsplt;
+ hcsplt.d32 = ifxusb_rreg (&hc_regs->hcsplt);
+ hcsplt.b.spltena = 1;
+ if (_ifxhc->split>1)
+ hcsplt.b.compsplt = 1;
+ else
+ hcsplt.b.compsplt = 0;
+
+ #if defined(__EN_ISOC__) && defined(__EN_ISOC_SPLIT__)
+ if (_ifxhc->ep_type == IFXUSB_EP_TYPE_ISOC)
+ hcsplt.b.xactpos = _ifxhc->isoc_xact_pos;
+ else
+ #endif
+ hcsplt.b.xactpos = IFXUSB_HCSPLIT_XACTPOS_ALL;// if not ISO
+ ifxusb_wreg(&hc_regs->hcsplt, hcsplt.d32);
+ IFX_DEBUGPL(DBG_HCDV, " SPLIT: XACT_POS:0x%08x\n", hcsplt.d32);
+ }
+
+ {
+ hcchar_data_t hcchar;
+ hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
+// hcchar.b.multicnt = _ifxhc->multi_count;
+ hcchar.b.multicnt = 1;
+
+ if (_ifxhc->ep_type == IFXUSB_EP_TYPE_INTR || _ifxhc->ep_type == IFXUSB_EP_TYPE_ISOC)
+ {
+ hfnum.d32 = ifxusb_rreg(&core_if->host_global_regs->hfnum);
+ /* 1 if _next_ frame is odd, 0 if it's even */
+ hcchar.b.oddfrm = (hfnum.b.frnum & 0x1) ? 0 : 1;
+ }
+
+ #ifdef __DEBUG__
+ _ifxhc->start_hcchar_val = hcchar.d32;
+ if (hcchar.b.chdis)
+ IFX_WARN("%s: chdis set, channel %d, hcchar 0x%08x\n",
+ __func__, _ifxhc->hc_num, hcchar.d32);
+ #endif
+
+ /* Set host channel enable after all other setup is complete. */
+ hcchar.b.chen = 1;
+ hcchar.b.chdis = 0;
+ hcchar.b.epdir = _ifxhc->is_in;
+ _ifxhc->hcchar=hcchar.d32;
+ }
+
+ IFX_DEBUGPL(DBG_HCDV, " HCCHART: 0x%08x\n", _ifxhc->hcchar);
+
+ _ifxhc->phase=HC_STARTING;
+}
+
+/*!
+ \brief Attempts to halt a host channel. This function should only be called
+ to abort a transfer in DMA mode. Under normal circumstances in DMA mode, the
+ controller halts the channel when the transfer is complete or a condition
+ occurs that requires application intervention.
+
+ In DMA mode, always sets the Channel Enable and Channel Disable bits of the
+ HCCHARn register. The controller ensures there is space in the request
+ queue before submitting the halt request.
+
+ Some time may elapse before the core flushes any posted requests for this
+ host channel and halts. The Channel Halted interrupt handler completes the
+ deactivation of the host channel.
+ */
+int ifxhcd_hc_halt(ifxusb_core_if_t *_core_if,
+ ifxhcd_hc_t *_ifxhc,
+ ifxhcd_halt_status_e _halt_status)
+{
+ hcchar_data_t hcchar;
+ ifxusb_hc_regs_t *hc_regs;
+ hc_regs = _core_if->hc_regs[_ifxhc->hc_num];
+
+ WARN_ON(_halt_status == HC_XFER_NO_HALT_STATUS);
+
+ {
+ hprt0_data_t hprt0;
+ hprt0.d32 = ifxusb_rreg(_core_if->hprt0);
+ if(hprt0.b.prtena == 0)
+ return -1;
+ }
+
+ if (_halt_status == HC_XFER_URB_DEQUEUE ||
+ _halt_status == HC_XFER_AHB_ERR)
+ {
+ /*
+ * Disable all channel interrupts except Ch Halted. The URBD
+ * and EPQH state associated with this transfer has been cleared
+ * (in the case of URB_DEQUEUE), so the channel needs to be
+ * shut down carefully to prevent crashes.
+ */
+ hcint_data_t hcintmsk;
+ hcintmsk.d32 = 0;
+ hcintmsk.b.chhltd = 1;
+ ifxusb_wreg(&hc_regs->hcintmsk, hcintmsk.d32);
+
+ /*
+ * Make sure no other interrupts besides halt are currently
+ * pending. Handling another interrupt could cause a crash due
+ * to the URBD and EPQH state.
+ */
+ ifxusb_wreg(&hc_regs->hcint, ~hcintmsk.d32);
+
+ /*
+ * Make sure the halt status is set to URB_DEQUEUE or AHB_ERR
+ * even if the channel was already halted for some other
+ * reason.
+ */
+ _ifxhc->halt_status = _halt_status;
+ }
+
+ hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
+ if (hcchar.b.chen == 0)
+ {
+ /*
+ * The channel is either already halted or it hasn't
+ * started yet. In DMA mode, the transfer may halt if
+ * it finishes normally or a condition occurs that
+ * requires driver intervention. Don't want to halt
+ * the channel again. In either Slave or DMA mode,
+ * it's possible that the transfer has been assigned
+ * to a channel, but not started yet when an URB is
+ * dequeued. Don't want to halt a channel that hasn't
+ * started yet.
+ */
+ _ifxhc->phase=HC_IDLE;
+ return -1;
+ }
+
+ if (_ifxhc->phase==HC_STOPPING)
+ {
+ /*
+ * A halt has already been issued for this channel. This might
+ * happen when a transfer is aborted by a higher level in
+ * the stack.
+ */
+ #ifdef __DEBUG__
+ IFX_PRINT("*** %s: Channel %d, double halt a channel***\n",
+ __func__, _ifxhc->hc_num);
+ #endif
+ return 0;
+ }
+ hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
+ hcchar.b.chen = 1;
+ hcchar.b.chdis = 1;
+
+ ifxusb_wreg(&hc_regs->hcchar, hcchar.d32);
+
+ _ifxhc->halt_status = _halt_status;
+ _ifxhc->phase=HC_STOPPING;
+
+ IFX_DEBUGPL(DBG_HCDV, "%s: Channel %d\n" , __func__, _ifxhc->hc_num);
+ IFX_DEBUGPL(DBG_HCDV, " hcchar: 0x%08x\n" , hcchar.d32);
+ IFX_DEBUGPL(DBG_HCDV, " halt_status: %d\n" , _ifxhc->halt_status);
+
+ return 0;
+}
+
+/*!
+ \brief Clears a host channel.
+ */
+void ifxhcd_hc_cleanup(ifxusb_core_if_t *_core_if, ifxhcd_hc_t *_ifxhc)
+{
+ ifxusb_hc_regs_t *hc_regs;
+
+ _ifxhc->phase=HC_IDLE;
+ _ifxhc->epqh=0;
+
+ /*
+ * Clear channel interrupt enables and any unhandled channel interrupt
+ * conditions.
+ */
+ hc_regs = _core_if->hc_regs[_ifxhc->hc_num];
+ ifxusb_wreg(&hc_regs->hcintmsk, 0);
+ ifxusb_wreg(&hc_regs->hcint, 0xFFFFFFFF);
+
+ #ifdef __DEBUG__
+ {
+ hcchar_data_t hcchar;
+ hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
+ if (hcchar.b.chdis)
+ IFX_WARN("%s: chdis set, channel %d, hcchar 0x%08x\n", __func__, _ifxhc->hc_num, hcchar.d32);
+ }
+ #endif
+}
+
+
+
+
+
+#ifdef __DEBUG__
+ static void dump_urb_info(struct urb *_urb, char* _fn_name)
+ {
+ IFX_PRINT("%s, urb %p\n" , _fn_name, _urb);
+ IFX_PRINT(" Device address: %d\n", usb_pipedevice(_urb->pipe));
+ IFX_PRINT(" Endpoint: %d, %s\n" , usb_pipeendpoint(_urb->pipe),
+ (usb_pipein(_urb->pipe) ? "IN" : "OUT"));
+ IFX_PRINT(" Endpoint type: %s\n",
+ ({ char *pipetype;
+ switch (usb_pipetype(_urb->pipe)) {
+ case PIPE_CONTROL: pipetype = "CONTROL"; break;
+ case PIPE_BULK: pipetype = "BULK"; break;
+ case PIPE_INTERRUPT: pipetype = "INTERRUPT"; break;
+ case PIPE_ISOCHRONOUS: pipetype = "ISOCHRONOUS"; break;
+ default: pipetype = "UNKNOWN"; break;
+ };
+ pipetype;
+ }));
+ IFX_PRINT(" Speed: %s\n",
+ ({ char *speed;
+ switch (_urb->dev->speed) {
+ case USB_SPEED_HIGH: speed = "HIGH"; break;
+ case USB_SPEED_FULL: speed = "FULL"; break;
+ case USB_SPEED_LOW: speed = "LOW"; break;
+ default: speed = "UNKNOWN"; break;
+ };
+ speed;
+ }));
+ IFX_PRINT(" Max packet size: %d\n",
+ usb_maxpacket(_urb->dev, _urb->pipe, usb_pipeout(_urb->pipe)));
+ IFX_PRINT(" Data buffer length: %d\n", _urb->transfer_buffer_length);
+ IFX_PRINT(" Transfer buffer: %p, Transfer DMA: %p\n",
+ _urb->transfer_buffer, (void *)_urb->transfer_dma);
+ IFX_PRINT(" Setup buffer: %p, Setup DMA: %p\n",
+ _urb->setup_packet, (void *)_urb->setup_dma);
+ IFX_PRINT(" Interval: %d\n", _urb->interval);
+ if (usb_pipetype(_urb->pipe) == PIPE_ISOCHRONOUS)
+ {
+ int i;
+ for (i = 0; i < _urb->number_of_packets; i++)
+ {
+ IFX_PRINT(" ISO Desc %d:\n", i);
+ IFX_PRINT(" offset: %d, length %d\n",
+ _urb->iso_frame_desc[i].offset,
+ _urb->iso_frame_desc[i].length);
+ }
+ }
+ }
+
+#if 0
+ static void dump_channel_info(ifxhcd_hcd_t *_ifxhcd, ifxhcd_epqh_t *_epqh)
+ {
+ if (_epqh->hc != NULL)
+ {
+ ifxhcd_hc_t *hc = _epqh->hc;
+ struct list_head *item;
+ ifxhcd_epqh_t *epqh_item;
+
+ ifxusb_hc_regs_t *hc_regs;
+
+ hcchar_data_t hcchar;
+ hcsplt_data_t hcsplt;
+ hctsiz_data_t hctsiz;
+ uint32_t hcdma;
+
+ hc_regs = _ifxhcd->core_if.hc_regs[hc->hc_num];
+ hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
+ hcsplt.d32 = ifxusb_rreg(&hc_regs->hcsplt);
+ hctsiz.d32 = ifxusb_rreg(&hc_regs->hctsiz);
+ hcdma = ifxusb_rreg(&hc_regs->hcdma);
+
+ IFX_PRINT(" Assigned to channel %d:\n" , hc->hc_num);
+ IFX_PRINT(" hcchar 0x%08x, hcsplt 0x%08x\n", hcchar.d32, hcsplt.d32);
+ IFX_PRINT(" hctsiz 0x%08x, hcdma 0x%08x\n" , hctsiz.d32, hcdma);
+ IFX_PRINT(" dev_addr: %d, ep_num: %d, is_in: %d\n",
+ hc->dev_addr, hc->ep_num, hc->is_in);
+ IFX_PRINT(" ep_type: %d\n" , hc->ep_type);
+ IFX_PRINT(" max_packet_size: %d\n", hc->mps);
+ IFX_PRINT(" data_pid_start: %d\n" , hc->data_pid_start);
+ IFX_PRINT(" halt_status: %d\n" , hc->halt_status);
+ IFX_PRINT(" xfer_buff: %p\n" , hc->xfer_buff);
+ IFX_PRINT(" xfer_len: %d\n" , hc->xfer_len);
+ IFX_PRINT(" epqh: %p\n" , hc->epqh);
+ IFX_PRINT(" NP :\n");
+ list_for_each(item, &_ifxhcd->epqh_list_np)
+ {
+ epqh_item = list_entry(item, ifxhcd_epqh_t, ql);
+ IFX_PRINT(" %p\n", epqh_item);
+ }
+ IFX_PRINT(" INTR :\n");
+ list_for_each(item, &_ifxhcd->epqh_list_intr)
+ {
+ epqh_item = list_entry(item, ifxhcd_epqh_t, ql);
+ IFX_PRINT(" %p\n", epqh_item);
+ }
+ #ifdef __EN_ISOC__
+ IFX_PRINT(" ISOC:\n");
+ list_for_each(item, &_ifxhcd->epqh_list_isoc)
+ {
+ epqh_item = list_entry(item, ifxhcd_epqh_t, ql);
+ IFX_PRINT(" %p\n", epqh_item);
+ }
+ #endif
+ }
+ }
+#endif
+#endif //__DEBUG__
+
+
+/*!
+ \brief This function writes a packet into the Tx FIFO associated with the Host
+ Channel. For a channel associated with a non-periodic EP, the non-periodic
+ Tx FIFO is written. For a channel associated with a periodic EP, the
+ periodic Tx FIFO is written. This function should only be called in Slave
+ mode.
+
+ Upon return the xfer_buff and xfer_count fields in _hc are incremented by
+ then number of bytes written to the Tx FIFO.
+ */
+
+#ifdef __ENABLE_DUMP__
+ void ifxhcd_dump_state(ifxhcd_hcd_t *_ifxhcd)
+ {
+ int num_channels;
+ int i;
+ num_channels = _ifxhcd->core_if.params.host_channels;
+ IFX_PRINT("\n");
+ IFX_PRINT("************************************************************\n");
+ IFX_PRINT("HCD State:\n");
+ IFX_PRINT(" Num channels: %d\n", num_channels);
+ for (i = 0; i < num_channels; i++) {
+ ifxhcd_hc_t *hc = &_ifxhcd->ifxhc[i];
+ IFX_PRINT(" Channel %d:\n", hc->hc_num);
+ IFX_PRINT(" dev_addr: %d, ep_num: %d, ep_is_in: %d\n",
+ hc->dev_addr, hc->ep_num, hc->is_in);
+ IFX_PRINT(" speed: %d\n" , hc->speed);
+ IFX_PRINT(" ep_type: %d\n" , hc->ep_type);
+ IFX_PRINT(" mps: %d\n", hc->mps);
+ IFX_PRINT(" data_pid_start: %d\n" , hc->data_pid_start);
+ IFX_PRINT(" xfer_buff: %p\n" , hc->xfer_buff);
+ IFX_PRINT(" xfer_len: %d\n" , hc->xfer_len);
+ IFX_PRINT(" xfer_count: %d\n" , hc->xfer_count);
+ IFX_PRINT(" halt_status: %d\n" , hc->halt_status);
+ IFX_PRINT(" split: %d\n" , hc->split);
+ IFX_PRINT(" hub_addr: %d\n" , hc->hub_addr);
+ IFX_PRINT(" port_addr: %d\n" , hc->port_addr);
+ #if defined(__EN_ISOC__) && defined(__EN_ISOC_SPLIT__)
+ IFX_PRINT(" isoc_xact_pos: %d\n" , hc->isoc_xact_pos);
+ #endif
+
+ IFX_PRINT(" epqh: %p\n" , hc->epqh);
+ IFX_PRINT(" short_rw: %d\n" , hc->short_rw);
+ IFX_PRINT(" control_phase: %d\n" , hc->control_phase);
+ if(hc->epqh)
+ {
+ IFX_PRINT(" do_ping: %d\n" , hc->epqh->do_ping);
+ }
+ IFX_PRINT(" start_pkt_count: %d\n" , hc->start_pkt_count);
+ }
+ IFX_PRINT("************************************************************\n");
+ IFX_PRINT("\n");
+ }
+#endif //__ENABLE_DUMP__
+
diff --git a/package/platform/lantiq/ltq-hcd/src/ifxhcd.h b/package/platform/lantiq/ltq-hcd/src/ifxhcd.h
new file mode 100644
index 0000000..243c5f5
--- /dev/null
+++ b/package/platform/lantiq/ltq-hcd/src/ifxhcd.h
@@ -0,0 +1,758 @@
+/*****************************************************************************
+ ** FILE NAME : ifxhcd.h
+ ** PROJECT : IFX USB sub-system V3
+ ** MODULES : IFX USB sub-system Host and Device driver
+ ** SRC VERSION : 3.2
+ ** DATE : 1/Jan/2011
+ ** AUTHOR : Chen, Howard
+ ** DESCRIPTION : This file contains the structures, constants, and interfaces for
+ ** the Host Contoller Driver (HCD).
+ **
+ ** The Host Controller Driver (HCD) is responsible for translating requests
+ ** from the USB Driver into the appropriate actions on the IFXUSB controller.
+ ** It isolates the USBD from the specifics of the controller by providing an
+ ** API to the USBD.
+ ** FUNCTIONS :
+ ** COMPILER : gcc
+ ** REFERENCE : Synopsys DWC-OTG Driver 2.7
+ ** COPYRIGHT : Copyright (c) 2010
+ ** LANTIQ DEUTSCHLAND GMBH,
+ ** Am Campeon 3, 85579 Neubiberg, Germany
+ **
+ ** 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 of the License, or
+ ** (at your option) any later version.
+ **
+ ** Version Control Section **
+ ** $Author$
+ ** $Date$
+ ** $Revisions$
+ ** $Log$ Revision history
+ *****************************************************************************/
+
+/*
+ * This file contains code fragments from Synopsys HS OTG Linux Software Driver.
+ * For this code the following notice is applicable:
+ *
+ * ==========================================================================
+ *
+ * Synopsys HS OTG Linux Software Driver and documentation (hereinafter,
+ * "Software") is an Unsupported proprietary work of Synopsys, Inc. unless
+ * otherwise expressly agreed to in writing between Synopsys and you.
+ *
+ * The Software IS NOT an item of Licensed Software or Licensed Product under
+ * any End User Software License Agreement or Agreement for Licensed Product
+ * with Synopsys or any supplement thereto. You are permitted to use and
+ * redistribute this Software in source and binary forms, with or without
+ * modification, provided that redistributions of source code must retain this
+ * notice. You may not view, use, disclose, copy or distribute this file or
+ * any information contained herein except pursuant to this license grant from
+ * Synopsys. If you do not agree with this notice, including the disclaimer
+ * below, then you are not authorized to use the Software.
+ *
+ * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" BASIS
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ * ========================================================================== */
+
+/*!
+ \defgroup IFXUSB_HCD HCD Interface
+ \ingroup IFXUSB_DRIVER_V3
+ \brief The Host Controller Driver (HCD) is responsible for translating requests
+ from the USB Driver into the appropriate actions on the IFXUSB controller.
+ It isolates the USBD from the specifics of the controller by providing an
+ API to the USBD.
+ */
+
+
+/*!
+ \file ifxhcd.h
+ \ingroup IFXUSB_DRIVER_V3
+ \brief This file contains the structures, constants, and interfaces for
+ the Host Contoller Driver (HCD).
+ */
+
+#if !defined(__IFXHCD_H__)
+#define __IFXHCD_H__
+
+
+#define __STRICT_ORDER__
+
+
+#include <linux/list.h>
+#include <linux/usb.h>
+
+#include <linux/usb/hcd.h>
+
+#include "ifxusb_cif.h"
+#include "ifxusb_plat.h"
+
+
+#undef __INNAKSTOP__
+#if !defined(__INNAKSTOP__) && defined(__INNAKSTOP_CTRL__)
+ #define __INNAKSTOP__ 1
+#endif
+#if !defined(__INNAKSTOP__) && defined(__INNAKSTOP_BULK__)
+ #define __INNAKSTOP__ 1
+#endif
+
+#undef __PINGSTOP__
+#if !defined(__PINGSTOP__) && defined(__PINGSTOP_CTRL__)
+ #define __PINGSTOP__ 1
+#endif
+#if !defined(__PINGSTOP__) && defined(__PINGSTOP_BULK__)
+ #define __PINGSTOP__ 1
+#endif
+
+#undef __NAKSTOP__
+#if defined(__INNAKSTOP__) || defined(__PINGSTOP__)
+ #define __NAKSTOP__ 1
+#endif
+
+
+/* Phases for control transfers.*/
+typedef enum ifxhcd_epqh_phase {
+ EPQH_IDLE=0,
+ EPQH_DISABLING,
+// EPQH_COMPLETING,
+ EPQH_STDBY,
+ EPQH_READY,
+ EPQH_ACTIVE
+} ifxhcd_epqh_phase_e;
+
+/* Phases for control transfers.*/
+typedef enum ifxhcd_urbd_phase {
+ URBD_IDLE=0,
+ URBD_ACTIVE,
+ URBD_STARTING,
+ URBD_STARTED,
+ URBD_FINISHING, //URB_Complete already scheduled
+ URBD_COMPLETING, //To URB_Complete, it's normal finish
+ URBD_DEQUEUEING, //To URB_Complete, it's abnormal finish
+} ifxhcd_urbd_phase_e;
+
+/* Phases for control transfers.*/
+typedef enum ifxhcd_hc_phase {
+ HC_IDLE=0,
+ HC_ASSIGNED,
+ HC_WAITING,
+ HC_STARTING,
+ HC_STARTED,
+ HC_STOPPING,
+ HC_STOPPED,
+} ifxhcd_hc_phase_e;
+
+/*!
+ \addtogroup IFXUSB_HCD
+ */
+/*@{*/
+
+/*! \typedef ifxhcd_control_phase_e
+ \brief Phases for control transfers.
+*/
+
+typedef enum ifxhcd_control_phase {
+ IFXHCD_CONTROL_SETUP,
+ IFXHCD_CONTROL_DATA,
+ IFXHCD_CONTROL_STATUS
+} ifxhcd_control_phase_e;
+
+/*! \typedef ifxhcd_halt_status_e
+ \brief Reasons for halting a host channel.
+*/
+typedef enum ifxhcd_halt_status
+{
+ HC_XFER_NO_HALT_STATUS, // Initial
+ HC_XFER_COMPLETE, // Xact complete without error, upward
+ HC_XFER_URB_COMPLETE, // Xfer complete without error, short upward
+ HC_XFER_STALL, // HC stopped abnormally, upward/downward
+ HC_XFER_XACT_ERR, // HC stopped abnormally, upward
+ HC_XFER_FRAME_OVERRUN, // HC stopped abnormally, upward
+ HC_XFER_BABBLE_ERR, // HC stopped abnormally, upward
+ HC_XFER_AHB_ERR, // HC stopped abnormally, upward
+ HC_XFER_DATA_TOGGLE_ERR,
+ HC_XFER_URB_DEQUEUE, // HC stopper manually, downward
+ HC_XFER_NO_URB, // HC stopper manually, downward
+ HC_XFER_NO_EPQH, // HC stopper manually, downward
+ #ifdef __NAKSTOP__
+ HC_XFER_NAK, // HC stopped by nak monitor, downward
+ #endif
+ #if defined(__INTRNAKRETRY__) || defined(__INTRINCRETRY__)
+ HC_XFER_INTR_NAK_RETRY, // HC stopped by nak monitor, downward
+ #endif
+} ifxhcd_halt_status_e;
+
+struct ifxhcd_urbd;
+struct ifxhcd_hc ;
+struct ifxhcd_epqh ;
+struct ifxhcd_hcd;
+
+/*! typedef ifxhcd_urbd_t
+ \brief A URB Descriptor (URBD) holds the state of a bulk, control,
+ interrupt, or isochronous transfer. A single URBD is created for each URB
+ (of one of these types) submitted to the HCD. The transfer associated with
+ a URBD may require one or multiple transactions.
+
+ A URBD is linked to a EP Queue Head, which is entered in either the
+ isoc, intr or non-periodic schedule for execution. When a URBD is chosen for
+ execution, some or all of its transactions may be executed. After
+ execution, the state of the URBD is updated. The URBD may be retired if all
+ its transactions are complete or if an error occurred. Otherwise, it
+ remains in the schedule so more transactions can be executed later.
+ */
+typedef struct ifxhcd_urbd {
+ ifxhcd_urbd_phase_e phase;
+ struct list_head ql; // Hook for EPQH->urbd_list
+ struct urb *urb; /*!< URB for this transfer */
+ //struct urb {
+ // struct list_head urb_list;
+ // struct list_head anchor_list;
+ // struct usb_anchor * anchor;
+ // struct usb_device * dev;
+ // struct usb_host_endpoint * ep;
+ // unsigned int pipe;
+ // int status;
+ // unsigned int transfer_flags;
+ // void * transfer_buffer;
+ // dma_addr_t transfer_dma;
+ // u32 transfer_buffer_length;
+ // u32 actual_length;
+ // unsigned char * setup_packet;
+ // dma_addr_t setup_dma;
+ // int start_frame;
+ // int number_of_packets;
+ // int interval;
+ // int error_count;
+ // void * context;
+ // usb_complete_t complete;
+ // struct usb_iso_packet_descriptor iso_frame_desc[0];
+ //};
+ //urb_list For use by current owner of the URB.
+ //anchor_list membership in the list of an anchor
+ //anchor to anchor URBs to a common mooring
+ //dev Identifies the USB device to perform the request.
+ //ep Points to the endpoint's data structure. Will
+ // eventually replace pipe.
+ //pipe Holds endpoint number, direction, type, and more.
+ // Create these values with the eight macros available; u
+ // sb_{snd,rcv}TYPEpipe(dev,endpoint), where the TYPE is
+ // "ctrl", "bulk", "int" or "iso". For example
+ // usb_sndbulkpipe or usb_rcvintpipe. Endpoint numbers
+ // range from zero to fifteen. Note that "in" endpoint two
+ // is a different endpoint (and pipe) from "out" endpoint
+ // two. The current configuration controls the existence,
+ // type, and maximum packet size of any given endpoint.
+ //status This is read in non-iso completion functions to get
+ // the status of the particular request. ISO requests
+ // only use it to tell whether the URB was unlinked;
+ // detailed status for each frame is in the fields of
+ // the iso_frame-desc.
+ //transfer_flags A variety of flags may be used to affect how URB
+ // submission, unlinking, or operation are handled.
+ // Different kinds of URB can use different flags.
+ // URB_SHORT_NOT_OK
+ // URB_ISO_ASAP
+ // URB_NO_TRANSFER_DMA_MAP
+ // URB_NO_SETUP_DMA_MAP
+ // URB_NO_FSBR
+ // URB_ZERO_PACKET
+ // URB_NO_INTERRUPT
+ //transfer_buffer This identifies the buffer to (or from) which the I/O
+ // request will be performed (unless URB_NO_TRANSFER_DMA_MAP
+ // is set). This buffer must be suitable for DMA; allocate it
+ // with kmalloc or equivalent. For transfers to "in"
+ // endpoints, contents of this buffer will be modified. This
+ // buffer is used for the data stage of control transfers.
+ //transfer_dma When transfer_flags includes URB_NO_TRANSFER_DMA_MAP, the
+ // device driver is saying that it provided this DMA address,
+ // which the host controller driver should use in preference
+ // to the transfer_buffer.
+ //transfer_buffer_length How big is transfer_buffer. The transfer may be broken
+ // up into chunks according to the current maximum packet size
+ // for the endpoint, which is a function of the configuration
+ // and is encoded in the pipe. When the length is zero, neither
+ // transfer_buffer nor transfer_dma is used.
+ //actual_length This is read in non-iso completion functions, and it tells
+ // how many bytes (out of transfer_buffer_length) were transferred.
+ // It will normally be the same as requested, unless either an error
+ // was reported or a short read was performed. The URB_SHORT_NOT_OK
+ // transfer flag may be used to make such short reads be reported
+ // as errors.
+ //setup_packet Only used for control transfers, this points to eight bytes of
+ // setup data. Control transfers always start by sending this data
+ // to the device. Then transfer_buffer is read or written, if needed.
+ //setup_dma For control transfers with URB_NO_SETUP_DMA_MAP set, the device
+ // driver has provided this DMA address for the setup packet. The
+ // host controller driver should use this in preference to setup_packet.
+ //start_frame Returns the initial frame for isochronous transfers.
+ //number_of_packets Lists the number of ISO transfer buffers.
+ //interval Specifies the polling interval for interrupt or isochronous transfers.
+ // The units are frames (milliseconds) for for full and low speed devices,
+ // and microframes (1/8 millisecond) for highspeed ones.
+ //error_count Returns the number of ISO transfers that reported errors.
+ //context For use in completion functions. This normally points to request-specific
+ // driver context.
+ //complete Completion handler. This URB is passed as the parameter to the completion
+ // function. The completion function may then do what it likes with the URB,
+ // including resubmitting or freeing it.
+ //iso_frame_desc[0] Used to provide arrays of ISO transfer buffers and to collect the transfer
+ // status for each buffer.
+
+ struct ifxhcd_epqh *epqh;
+ // Actual data portion, not SETUP or STATUS in case of CTRL XFER
+ // DMA adjusted
+ uint8_t *setup_buff; /*!< Pointer to the entire transfer buffer. (CPU accessable)*/
+ uint8_t *xfer_buff; /*!< Pointer to the entire transfer buffer. (CPU accessable)*/
+ uint32_t xfer_len; /*!< Total number of bytes to transfer in this xfer. */
+
+ #if defined(__UNALIGNED_BUF_ADJ__)
+// uint8_t using_aligned_setup;
+ uint8_t *aligned_setup;
+// uint8_t using_aligned_buf;
+ uint8_t *aligned_buf;
+ unsigned aligned_buf_len : 19;
+ #endif
+ #if defined(__UNALIGNED_BUF_ADJ__) || defined(__UNALIGNED_BUF_CHK__)
+ unsigned aligned_checked : 1;
+ #endif
+ unsigned is_in :1;
+ #ifndef __STRICT_ORDER__
+ struct tasklet_struct complete_urb_sub;
+ #endif
+
+ // For ALL XFER
+ uint8_t error_count; /*!< Holds the number of bus errors that have occurred for a transaction
+ within this transfer.
+ */
+ // For ISOC XFER only
+ #ifdef __EN_ISOC__
+ int isoc_frame_index; /*!< Index of the next frame descriptor for an isochronous transfer. A
+ frame descriptor describes the buffer position and length of the
+ data to be transferred in the next scheduled (micro)frame of an
+ isochronous transfer. It also holds status for that transaction.
+ The frame index starts at 0.
+ */
+ #endif
+ int status;
+} ifxhcd_urbd_t;
+
+/*! typedef ifxhcd_epqh_t
+ \brief A EP Queue Head (EPQH) holds the static characteristics of an endpoint and
+ maintains a list of transfers (URBDs) for that endpoint. A EPQH structure may
+ be entered in either the isoc, intr or non-periodic schedule.
+ */
+
+typedef struct ifxhcd_epqh {
+ struct ifxhcd_hcd *ifxhcd;
+ struct usb_host_endpoint *sysep;
+ uint8_t devno;
+
+ ifxhcd_epqh_phase_e phase;
+ struct list_head ql_all;
+ struct list_head ql; // Hook for EP Queues
+ struct list_head urbd_list; /*!< List of URBDs for this EPQH. */
+ #ifdef __STRICT_ORDER__
+ struct list_head release_list;
+ struct tasklet_struct complete_urb_sub;
+ #endif
+ struct ifxhcd_hc *hc; /*!< Host channel currently processing transfers for this EPQH. */
+ struct ifxhcd_urbd *urbd; /*!< URBD currently assigned to a host channel for this EPQH. */
+ uint8_t ep_type; /*!< Endpoint type. One of the following values:
+ - IFXUSB_EP_TYPE_CTRL
+ - IFXUSB_EP_TYPE_ISOC
+ - IFXUSB_EP_TYPE_BULK
+ - IFXUSB_EP_TYPE_INTR
+ */
+ uint16_t mps; /*!< wMaxPacketSize Field of Endpoint Descriptor. */
+ #ifdef __EPQD_DESTROY_TIMEOUT__
+ struct timer_list destroy_timer;
+ #endif
+
+ unsigned need_split : 1 ;
+ unsigned do_ping : 1 ; /*!< Set to 1 to indicate that a PING request should be issued on this
+ channel. If 0, process normally.
+ */
+ unsigned pause : 1;
+ unsigned period_do : 1;
+ uint16_t interval; /*!< Interval between transfers in (micro)frames. (for INTR)*/
+ uint16_t period_counter; /*!< Interval between transfers in (micro)frames. */
+
+ #ifdef __EN_ISOC__
+ struct tasklet_struct tasklet_next_isoc;
+ uint8_t isoc_now;
+ uint32_t isoc_start_frame;
+ // For SPLITed ISOC XFER only
+ #ifdef __EN_ISOC_SPLIT__
+ uint8_t isoc_split_pos; /*!< Position of the ISOC split on full/low speed */
+ uint16_t isoc_split_offset;/*!< Position of the ISOC split in the buffer for the current frame */
+ #endif
+ #endif
+ spinlock_t urbd_list_lock;
+ int urbd_count;
+} ifxhcd_epqh_t;
+
+
+/*! typedef ifxhcd_hc_t
+ \brief Host channel descriptor. This structure represents the state of a single
+ host channel when acting in host mode. It contains the data items needed to
+ transfer packets to an endpoint via a host channel.
+ */
+typedef struct ifxhcd_hc
+{
+ struct ifxhcd_epqh *epqh ; /*!< EP Queue Head for the transfer being processed by this channel. */
+ uint8_t hc_num ; /*!< Host channel number used for register address lookup */
+ uint8_t *xfer_buff ; /*!< Pointer to the entire transfer buffer. */
+ uint32_t xfer_count ; /*!< Number of bytes transferred so far. The offset of the begin of the buf */
+ uint32_t xfer_len ; /*!< Total number of bytes to transfer in this xfer. */
+ uint16_t start_pkt_count ; /*!< Packet count at start of transfer. Used to calculate the actual xfer size*/
+ ifxhcd_halt_status_e halt_status; /*!< Reason for halting the host channel. */
+ ifxhcd_hc_phase_e phase;
+
+ unsigned dev_addr : 7; /*!< Device to access */
+ unsigned ep_num : 4; /*!< EP to access */
+ unsigned is_in : 1; /*!< EP direction. 0: OUT, 1: IN */
+ unsigned speed : 2; /*!< EP speed. */
+ unsigned ep_type : 2; /*!< Endpoint type. */
+ unsigned mps :11; /*!< Max packet size in bytes */
+ unsigned data_pid_start : 2; /*!< PID for initial transaction. */
+ unsigned short_rw : 1; /*!< When Tx, means termination needed.
+ When Rx, indicate Short Read */
+ /* Split settings for the host channel */
+ unsigned split : 2; /*!< Split: 0-Non Split, 1-SSPLIT, 2&3 CSPLIT */
+
+ unsigned sof_delay :16;
+ unsigned erron : 1;
+
+ #ifdef __NAKSTOP__
+ unsigned stop_on : 1;
+// unsigned wait_for_sof_quick : 1;
+ #endif
+
+ ifxhcd_control_phase_e control_phase; /*!< Current phase for control transfers (Setup, Data, or Status). */
+ uint32_t ssplit_out_xfer_count; /*!< How many bytes transferred during SSPLIT OUT */
+ #ifdef __DEBUG__
+ uint32_t start_hcchar_val;
+ #endif
+ uint32_t hcchar;
+
+ /* Split settings for the host channel */
+ uint8_t hub_addr; /*!< Address of high speed hub */
+ uint8_t port_addr; /*!< Port of the low/full speed device */
+ #if defined(__EN_ISOC__) && defined(__EN_ISOC_SPLIT__)
+ uint8_t isoc_xact_pos; /*!< Split transaction position */
+ #endif
+} ifxhcd_hc_t;
+
+
+/*! typedef ifxhcd_hcd_t
+ \brief This structure holds the state of the HCD, including the non-periodic and
+ periodic schedules.
+ */
+typedef struct ifxhcd_hcd
+{
+ struct device *dev;
+ struct hc_driver hc_driver;
+ ifxusb_core_if_t core_if; /*!< Pointer to the core interface structure. */
+ struct usb_hcd *syshcd;
+
+ volatile union
+ {
+ uint32_t d32;
+ struct
+ {
+ unsigned port_connect_status_change : 1;
+ unsigned port_connect_status : 1;
+ unsigned port_reset_change : 1;
+ unsigned port_enable_change : 1;
+ unsigned port_suspend_change : 1;
+ unsigned port_over_current_change : 1;
+ unsigned reserved : 27;
+ } b;
+ } flags; /*!< Internal HCD Flags */
+
+ struct ifxhcd_hc ifxhc[MAX_EPS_CHANNELS]; /*!< Array of pointers to the host channel descriptors. Allows accessing
+ a host channel descriptor given the host channel number. This is
+ useful in interrupt handlers.
+ */
+ uint8_t *status_buf; /*!< Buffer to use for any data received during the status phase of a
+ control transfer. Normally no data is transferred during the status
+ phase. This buffer is used as a bit bucket.
+ */
+ #define IFXHCD_STATUS_BUF_SIZE 64 /*!< buffer size of status phase in CTRL xfer */
+
+ struct list_head epqh_list_all;
+ struct list_head epqh_list_np;
+ struct list_head epqh_list_intr;
+ #ifdef __EN_ISOC__
+ struct list_head epqh_list_isoc;
+ #endif
+
+ uint32_t lastframe;
+
+ uint16_t pkt_remaining;
+ uint16_t pkt_remaining_reload;
+ uint16_t pkt_remaining_reload_hs;
+ uint16_t pkt_remaining_reload_fs;
+ uint16_t pkt_remaining_reload_ls;
+ #define PKT_REMAINING_RELOAD_HS 88
+ #define PKT_REMAINING_RELOAD_FS 10
+ #define PKT_REMAINING_RELOAD_LS 20
+ #ifdef __EN_ISOC__
+ uint8_t isoc_ep_count;
+ #endif
+
+ spinlock_t epqh_list_lock;
+ spinlock_t epqh_list_all_lock;
+
+ struct timer_list host_probe_timer;
+ struct timer_list autoprobe_timer;
+
+ unsigned power_status;
+ int probe_sec;
+ int autoprobe_sec;
+ #ifdef __DYN_SOF_INTR__
+ uint32_t dyn_sof_count;
+ #define DYN_SOF_COUNT_DEF 40000
+ #endif
+ struct tasklet_struct tasklet_select_eps; /*!< Tasket to do a reset */
+ struct tasklet_struct tasklet_free_epqh_list ; /*!< Tasket to do a reset */
+ unsigned disconnecting : 1 ;
+
+ uint8_t pkt_count_limit_bo;
+ uint8_t pkt_count_limit_bi;
+} ifxhcd_hcd_t;
+
+/* Gets the ifxhcd_hcd from a struct usb_hcd */
+static inline ifxhcd_hcd_t *syshcd_to_ifxhcd(struct usb_hcd *syshcd)
+{
+ return (ifxhcd_hcd_t *)(syshcd->hcd_priv[0]);
+}
+
+/* Gets the struct usb_hcd that contains a ifxhcd_hcd_t. */
+static inline struct usb_hcd *ifxhcd_to_syshcd(ifxhcd_hcd_t *ifxhcd)
+{
+ return (struct usb_hcd *)(ifxhcd->syshcd);
+}
+
+
+extern ifxhcd_epqh_t * sysep_to_epqh(ifxhcd_hcd_t *_ifxhcd, struct usb_host_endpoint *_sysep);
+
+/* HCD Create/Destroy Functions */
+ extern int ifxhcd_init (ifxhcd_hcd_t *_ifxhcd);
+ extern void ifxhcd_remove(ifxhcd_hcd_t *_ifxhcd);
+
+/*Linux HC Driver API Functions */
+
+extern int ifxhcd_start(struct usb_hcd *hcd);
+extern void ifxhcd_stop (struct usb_hcd *hcd);
+extern int ifxhcd_get_frame_number(struct usb_hcd *hcd);
+
+
+/*!
+ \brief This function does the setup for a data transfer for a host channel and
+ starts the transfer. May be called in either Slave mode or DMA mode. In
+ Slave mode, the caller must ensure that there is sufficient space in the
+ request queue and Tx Data FIFO.
+
+ For an OUT transfer in Slave mode, it loads a data packet into the
+ appropriate FIFO. If necessary, additional data packets will be loaded in
+ the Host ISR.
+
+ For an IN transfer in Slave mode, a data packet is requested. The data
+ packets are unloaded from the Rx FIFO in the Host ISR. If necessary,
+ additional data packets are requested in the Host ISR.
+
+ For a PING transfer in Slave mode, the Do Ping bit is set in the HCTSIZ
+ register along with a packet count of 1 and the channel is enabled. This
+ causes a single PING transaction to occur. Other fields in HCTSIZ are
+ simply set to 0 since no data transfer occurs in this case.
+
+ For a PING transfer in DMA mode, the HCTSIZ register is initialized with
+ all the information required to perform the subsequent data transfer. In
+ addition, the Do Ping bit is set in the HCTSIZ register. In this case, the
+ controller performs the entire PING protocol, then starts the data
+ transfer.
+
+ @param _ifxhc Information needed to initialize the host channel. The xfer_len
+ value may be reduced to accommodate the max widths of the XferSize and
+ PktCnt fields in the HCTSIZn register. The multi_count value may be changed
+ to reflect the final xfer_len value.
+ */
+extern void ifxhcd_hc_start(ifxhcd_hcd_t *_ifxhcd, ifxhcd_hc_t *_ifxhc);
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)
+extern int ifxhcd_urb_enqueue(struct usb_hcd *_syshcd, struct usb_host_endpoint *_sysep, struct urb *_urb, gfp_t mem_flags);
+extern int ifxhcd_urb_dequeue(struct usb_hcd *_syshcd, struct urb *_urb);
+#else
+extern int ifxhcd_urb_enqueue(struct usb_hcd *_syshcd, struct urb *_urb, gfp_t mem_flags);
+extern int ifxhcd_urb_dequeue(struct usb_hcd *_syshcd, struct urb *_urb, int status);
+#endif
+extern irqreturn_t ifxhcd_irq(struct usb_hcd *_syshcd);
+
+extern void ifxhcd_endpoint_disable(struct usb_hcd *_syshcd, struct usb_host_endpoint *_sysep);
+
+extern int ifxhcd_hub_status_data(struct usb_hcd *_syshcd, char *_buf);
+extern int ifxhcd_hub_control( struct usb_hcd *_syshcd,
+ u16 _typeReq,
+ u16 _wValue,
+ u16 _wIndex,
+ char *_buf,
+ u16 _wLength);
+
+/*@}*/
+
+/*! \brief Transaction Execution Functions */
+/*@{*/
+extern void ifxhcd_complete_urb (ifxhcd_hcd_t *_ifxhcd, ifxhcd_urbd_t *_urbd, int _status);
+
+/*!
+ \brief Clears the transfer state for a host channel. This function is normally
+ called after a transfer is done and the host channel is being released.
+ */
+extern void ifxhcd_hc_cleanup(ifxusb_core_if_t *_core_if, ifxhcd_hc_t *_ifxhc);
+
+/*!
+ \brief Attempts to halt a host channel. This function should only be called in
+ Slave mode or to abort a transfer in either Slave mode or DMA mode. Under
+ normal circumstances in DMA mode, the controller halts the channel when the
+ transfer is complete or a condition occurs that requires application
+ intervention.
+
+ In DMA mode, always sets the Channel Enable and Channel Disable bits of the
+ HCCHARn register. The controller ensures there is space in the request
+ queue before submitting the halt request.
+
+ Some time may elapse before the core flushes any posted requests for this
+ host channel and halts. The Channel Halted interrupt handler completes the
+ deactivation of the host channel.
+ */
+extern int ifxhcd_hc_halt(ifxusb_core_if_t *_core_if,
+ ifxhcd_hc_t *_ifxhc,
+ ifxhcd_halt_status_e _halt_status);
+
+/*!
+ \brief Prepares a host channel for transferring packets to/from a specific
+ endpoint. The HCCHARn register is set up with the characteristics specified
+ in _ifxhc. Host channel interrupts that may need to be serviced while this
+ transfer is in progress are enabled.
+ */
+extern void ifxhcd_hc_init(ifxusb_core_if_t *_core_if, ifxhcd_hc_t *_ifxhc);
+
+/*!
+ \brief This function is called to handle the disconnection of host port.
+ */
+int32_t ifxhcd_disconnect(ifxhcd_hcd_t *_ifxhcd);
+/*@}*/
+
+/*! \brief Interrupt Handler Functions */
+/*@{*/
+extern irqreturn_t ifxhcd_oc_irq(int _irq, void *_dev);
+
+extern int32_t ifxhcd_handle_oc_intr(ifxhcd_hcd_t *_ifxhcd);
+extern int32_t ifxhcd_handle_intr (ifxhcd_hcd_t *_ifxhcd);
+/*@}*/
+
+
+/*! \brief Schedule Queue Functions */
+/*@{*/
+extern void ifxhcd_epqh_free (ifxhcd_epqh_t *_epqh);
+extern void select_eps (ifxhcd_hcd_t *_ifxhcd);
+extern void ifxhcd_epqh_idle(ifxhcd_epqh_t *_epqh);
+extern void ifxhcd_epqh_idle_periodic(ifxhcd_epqh_t *_epqh);
+extern ifxhcd_epqh_t *ifxhcd_urbd_create (ifxhcd_hcd_t *_ifxhcd,struct urb *_urb);
+/*@}*/
+
+/*! \brief Gets the usb_host_endpoint associated with an URB. */
+static inline struct usb_host_endpoint *ifxhcd_urb_to_endpoint(struct urb *_urb)
+{
+ struct usb_device *dev = _urb->dev;
+ int ep_num = usb_pipeendpoint(_urb->pipe);
+
+ return (usb_pipein(_urb->pipe))?(dev->ep_in[ep_num]):(dev->ep_out[ep_num]);
+}
+
+/*!
+ * \brief Gets the endpoint number from a _bEndpointAddress argument. The endpoint is
+ * qualified with its direction (possible 32 endpoints per device).
+ */
+#define ifxhcd_ep_addr_to_endpoint(_bEndpointAddress_) ((_bEndpointAddress_ & USB_ENDPOINT_NUMBER_MASK) | \
+ ((_bEndpointAddress_ & USB_DIR_IN) != 0) << 4)
+
+
+
+/*! Internal debug function */
+void ifxhcd_dump_state(ifxhcd_hcd_t *_ifxhcd);
+
+/*@}*//*IFXUSB_HCD*/
+
+extern struct usb_device *usb_alloc_dev (struct usb_device *parent, struct usb_bus *, unsigned port);
+extern int usb_add_hcd (struct usb_hcd *syshcd, unsigned int irqnum, unsigned long irqflags);
+extern void usb_remove_hcd (struct usb_hcd *syshcd);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)
+extern struct usb_hcd *usb_create_hcd (const struct hc_driver *driver, struct device *dev, char *bus_name);
+#else
+extern struct usb_hcd *usb_create_hcd (const struct hc_driver *driver, struct device *dev, const char *bus_name);
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)
+extern void usb_hcd_giveback_urb (struct usb_hcd *syshcd, struct urb *urb);
+#else
+extern void usb_hcd_giveback_urb (struct usb_hcd *syshcd, struct urb *urb,int status);
+#endif
+
+extern void usb_put_hcd (struct usb_hcd *syshcd);
+extern long usb_calc_bus_time (int speed, int is_input, int isoc, int bytecount);
+extern char *syserr(int errno);
+
+
+
+static inline void INIT_EPQH_LIST_ALL(ifxhcd_hcd_t *_ifxhcd)
+{
+ spin_lock_init(&_ifxhcd->epqh_list_all_lock);
+}
+static inline void LOCK_EPQH_LIST_ALL(ifxhcd_hcd_t *_ifxhcd)
+{
+ spin_lock(&_ifxhcd->epqh_list_all_lock);
+}
+static inline void UNLOCK_EPQH_LIST_ALL(ifxhcd_hcd_t *_ifxhcd)
+{
+ spin_unlock(&_ifxhcd->epqh_list_all_lock);
+}
+
+static inline void INIT_EPQH_LIST(ifxhcd_hcd_t *_ifxhcd)
+{
+ spin_lock_init(&_ifxhcd->epqh_list_lock);
+}
+static inline void LOCK_EPQH_LIST(ifxhcd_hcd_t *_ifxhcd)
+{
+ spin_lock(&_ifxhcd->epqh_list_lock);
+}
+static inline void UNLOCK_EPQH_LIST(ifxhcd_hcd_t *_ifxhcd)
+{
+ spin_unlock(&_ifxhcd->epqh_list_lock);
+}
+
+static inline void INIT_URBD_LIST(ifxhcd_epqh_t *_epqh)
+{
+ spin_lock_init(&_epqh->urbd_list_lock);
+}
+static inline void LOCK_URBD_LIST(ifxhcd_epqh_t *_epqh)
+{
+ spin_lock(&_epqh->urbd_list_lock);
+}
+static inline void UNLOCK_URBD_LIST(ifxhcd_epqh_t *_epqh)
+{
+ spin_unlock(&_epqh->urbd_list_lock);
+}
+
+#endif // __IFXHCD_H__
+
diff --git a/package/platform/lantiq/ltq-hcd/src/ifxhcd_es.c b/package/platform/lantiq/ltq-hcd/src/ifxhcd_es.c
new file mode 100644
index 0000000..a7d18dd
--- /dev/null
+++ b/package/platform/lantiq/ltq-hcd/src/ifxhcd_es.c
@@ -0,0 +1,599 @@
+/*****************************************************************************
+ ** FILE NAME : ifxhcd_es.c
+ ** PROJECT : IFX USB sub-system V3
+ ** MODULES : IFX USB sub-system Host and Device driver
+ ** SRC VERSION : 1.0
+ ** DATE : 1/Jan/2009
+ ** AUTHOR : Chen, Howard
+ ** DESCRIPTION : The file contain function to enable host mode USB-IF Electrical Test function.
+ ** FUNCTIONS :
+ ** COMPILER : gcc
+ ** REFERENCE : Synopsys DWC-OTG Driver 2.7
+ ** COPYRIGHT : Copyright (c) 2010
+ ** LANTIQ DEUTSCHLAND GMBH,
+ ** Am Campeon 3, 85579 Neubiberg, Germany
+ **
+ ** 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 of the License, or
+ ** (at your option) any later version.
+ **
+ ** Version Control Section **
+ ** $Author$
+ ** $Date$
+ ** $Revisions$
+ ** $Log$ Revision history
+ *****************************************************************************/
+
+/*
+ * This file contains code fragments from Synopsys HS OTG Linux Software Driver.
+ * For this code the following notice is applicable:
+ *
+ * ==========================================================================
+ *
+ * Synopsys HS OTG Linux Software Driver and documentation (hereinafter,
+ * "Software") is an Unsupported proprietary work of Synopsys, Inc. unless
+ * otherwise expressly agreed to in writing between Synopsys and you.
+ *
+ * The Software IS NOT an item of Licensed Software or Licensed Product under
+ * any End User Software License Agreement or Agreement for Licensed Product
+ * with Synopsys or any supplement thereto. You are permitted to use and
+ * redistribute this Software in source and binary forms, with or without
+ * modification, provided that redistributions of source code must retain this
+ * notice. You may not view, use, disclose, copy or distribute this file or
+ * any information contained herein except pursuant to this license grant from
+ * Synopsys. If you do not agree with this notice, including the disclaimer
+ * below, then you are not authorized to use the Software.
+ *
+ * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" BASIS
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ * ========================================================================== */
+
+/*!
+ \file ifxhcd_es.c
+ \ingroup IFXUSB_DRIVER_V3
+ \brief The file contain function to enable host mode USB-IF Electrical Test function.
+*/
+
+#include <linux/version.h>
+#include "ifxusb_version.h"
+
+#include <linux/kernel.h>
+
+#include <linux/errno.h>
+
+#include <linux/dma-mapping.h>
+
+#include "ifxusb_plat.h"
+#include "ifxusb_regs.h"
+#include "ifxusb_cif.h"
+#include "ifxhcd.h"
+
+
+#ifdef __WITH_HS_ELECT_TST__
+ /*
+ * Quick and dirty hack to implement the HS Electrical Test
+ * SINGLE_STEP_GET_DEVICE_DESCRIPTOR feature.
+ *
+ * This code was copied from our userspace app "hset". It sends a
+ * Get Device Descriptor control sequence in two parts, first the
+ * Setup packet by itself, followed some time later by the In and
+ * Ack packets. Rather than trying to figure out how to add this
+ * functionality to the normal driver code, we just hijack the
+ * hardware, using these two function to drive the hardware
+ * directly.
+ */
+
+
+ void do_setup(ifxusb_core_if_t *_core_if)
+ {
+
+ ifxusb_core_global_regs_t *global_regs = _core_if->core_global_regs;
+ ifxusb_host_global_regs_t *hc_global_regs = _core_if->host_global_regs;
+ ifxusb_hc_regs_t *hc_regs = _core_if->hc_regs[0];
+ uint32_t *data_fifo = _core_if->data_fifo[0];
+
+ gint_data_t gintsts;
+ hctsiz_data_t hctsiz;
+ hcchar_data_t hcchar;
+ haint_data_t haint;
+ hcint_data_t hcint;
+
+
+ /* Enable HAINTs */
+ ifxusb_wreg(&hc_global_regs->haintmsk, 0x0001);
+
+ /* Enable HCINTs */
+ ifxusb_wreg(&hc_regs->hcintmsk, 0x04a3);
+
+ /* Read GINTSTS */
+ gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
+ //fprintf(stderr, "GINTSTS: %08x\n", gintsts.d32);
+
+ /* Read HAINT */
+ haint.d32 = ifxusb_rreg(&hc_global_regs->haint);
+ //fprintf(stderr, "HAINT: %08x\n", haint.d32);
+
+ /* Read HCINT */
+ hcint.d32 = ifxusb_rreg(&hc_regs->hcint);
+ //fprintf(stderr, "HCINT: %08x\n", hcint.d32);
+
+ /* Read HCCHAR */
+ hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
+ //fprintf(stderr, "HCCHAR: %08x\n", hcchar.d32);
+
+ /* Clear HCINT */
+ ifxusb_wreg(&hc_regs->hcint, hcint.d32);
+
+ /* Clear HAINT */
+ ifxusb_wreg(&hc_global_regs->haint, haint.d32);
+
+ /* Clear GINTSTS */
+ ifxusb_wreg(&global_regs->gintsts, gintsts.d32);
+
+ /* Read GINTSTS */
+ gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
+ //fprintf(stderr, "GINTSTS: %08x\n", gintsts.d32);
+
+ /*
+ * Send Setup packet (Get Device Descriptor)
+ */
+
+ /* Make sure channel is disabled */
+ hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
+ if (hcchar.b.chen) {
+ //fprintf(stderr, "Channel already enabled 1, HCCHAR = %08x\n", hcchar.d32);
+ hcchar.b.chdis = 1;
+ // hcchar.b.chen = 1;
+ ifxusb_wreg(&hc_regs->hcchar, hcchar.d32);
+ //sleep(1);
+ mdelay(1000);
+
+ /* Read GINTSTS */
+ gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
+ //fprintf(stderr, "GINTSTS: %08x\n", gintsts.d32);
+
+ /* Read HAINT */
+ haint.d32 = ifxusb_rreg(&hc_global_regs->haint);
+ //fprintf(stderr, "HAINT: %08x\n", haint.d32);
+
+ /* Read HCINT */
+ hcint.d32 = ifxusb_rreg(&hc_regs->hcint);
+ //fprintf(stderr, "HCINT: %08x\n", hcint.d32);
+
+ /* Read HCCHAR */
+ hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
+ //fprintf(stderr, "HCCHAR: %08x\n", hcchar.d32);
+
+ /* Clear HCINT */
+ ifxusb_wreg(&hc_regs->hcint, hcint.d32);
+
+ /* Clear HAINT */
+ ifxusb_wreg(&hc_global_regs->haint, haint.d32);
+
+ /* Clear GINTSTS */
+ ifxusb_wreg(&global_regs->gintsts, gintsts.d32);
+
+ hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
+ //if (hcchar.b.chen) {
+ // fprintf(stderr, "** Channel _still_ enabled 1, HCCHAR = %08x **\n", hcchar.d32);
+ //}
+ }
+
+ /* Set HCTSIZ */
+ hctsiz.d32 = 0;
+ hctsiz.b.xfersize = 8;
+ hctsiz.b.pktcnt = 1;
+ hctsiz.b.pid = IFXUSB_HC_PID_SETUP;
+ ifxusb_wreg(&hc_regs->hctsiz, hctsiz.d32);
+
+ /* Set HCCHAR */
+ hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
+ hcchar.b.eptype = IFXUSB_EP_TYPE_CTRL;
+ hcchar.b.epdir = 0;
+ hcchar.b.epnum = 0;
+ hcchar.b.mps = 8;
+ hcchar.b.chen = 1;
+ ifxusb_wreg(&hc_regs->hcchar, hcchar.d32);
+
+ /* Fill FIFO with Setup data for Get Device Descriptor */
+ ifxusb_wreg(data_fifo++, 0x01000680);
+ ifxusb_wreg(data_fifo++, 0x00080000);
+
+ gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
+ //fprintf(stderr, "Waiting for HCINTR intr 1, GINTSTS = %08x\n", gintsts.d32);
+
+ /* Wait for host channel interrupt */
+ do {
+ gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
+ } while (gintsts.b.hcintr == 0);
+
+ //fprintf(stderr, "Got HCINTR intr 1, GINTSTS = %08x\n", gintsts.d32);
+
+ /* Disable HCINTs */
+ ifxusb_wreg(&hc_regs->hcintmsk, 0x0000);
+
+ /* Disable HAINTs */
+ ifxusb_wreg(&hc_global_regs->haintmsk, 0x0000);
+
+ /* Read HAINT */
+ haint.d32 = ifxusb_rreg(&hc_global_regs->haint);
+ //fprintf(stderr, "HAINT: %08x\n", haint.d32);
+
+ /* Read HCINT */
+ hcint.d32 = ifxusb_rreg(&hc_regs->hcint);
+ //fprintf(stderr, "HCINT: %08x\n", hcint.d32);
+
+ /* Read HCCHAR */
+ hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
+ //fprintf(stderr, "HCCHAR: %08x\n", hcchar.d32);
+
+ /* Clear HCINT */
+ ifxusb_wreg(&hc_regs->hcint, hcint.d32);
+
+ /* Clear HAINT */
+ ifxusb_wreg(&hc_global_regs->haint, haint.d32);
+
+ /* Clear GINTSTS */
+ ifxusb_wreg(&global_regs->gintsts, gintsts.d32);
+
+ /* Read GINTSTS */
+ gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
+ //fprintf(stderr, "GINTSTS: %08x\n", gintsts.d32);
+ }
+
+ void do_in_ack(ifxusb_core_if_t *_core_if)
+ {
+
+ ifxusb_core_global_regs_t *global_regs = _core_if->core_global_regs;
+ ifxusb_host_global_regs_t *hc_global_regs = _core_if->host_global_regs;
+ ifxusb_hc_regs_t *hc_regs = _core_if->hc_regs[0];
+ uint32_t *data_fifo = _core_if->data_fifo[0];
+
+ gint_data_t gintsts;
+ hctsiz_data_t hctsiz;
+ hcchar_data_t hcchar;
+ haint_data_t haint;
+ hcint_data_t hcint;
+ grxsts_data_t grxsts;
+
+ /* Enable HAINTs */
+ ifxusb_wreg(&hc_global_regs->haintmsk, 0x0001);
+
+ /* Enable HCINTs */
+ ifxusb_wreg(&hc_regs->hcintmsk, 0x04a3);
+
+ /* Read GINTSTS */
+ gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
+ //fprintf(stderr, "GINTSTS: %08x\n", gintsts.d32);
+
+ /* Read HAINT */
+ haint.d32 = ifxusb_rreg(&hc_global_regs->haint);
+ //fprintf(stderr, "HAINT: %08x\n", haint.d32);
+
+ /* Read HCINT */
+ hcint.d32 = ifxusb_rreg(&hc_regs->hcint);
+ //fprintf(stderr, "HCINT: %08x\n", hcint.d32);
+
+ /* Read HCCHAR */
+ hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
+ //fprintf(stderr, "HCCHAR: %08x\n", hcchar.d32);
+
+ /* Clear HCINT */
+ ifxusb_wreg(&hc_regs->hcint, hcint.d32);
+
+ /* Clear HAINT */
+ ifxusb_wreg(&hc_global_regs->haint, haint.d32);
+
+ /* Clear GINTSTS */
+ ifxusb_wreg(&global_regs->gintsts, gintsts.d32);
+
+ /* Read GINTSTS */
+ gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
+ //fprintf(stderr, "GINTSTS: %08x\n", gintsts.d32);
+
+ /*
+ * Receive Control In packet
+ */
+
+ /* Make sure channel is disabled */
+ hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
+ if (hcchar.b.chen) {
+ //fprintf(stderr, "Channel already enabled 2, HCCHAR = %08x\n", hcchar.d32);
+ hcchar.b.chdis = 1;
+ hcchar.b.chen = 1;
+ ifxusb_wreg(&hc_regs->hcchar, hcchar.d32);
+ //sleep(1);
+ mdelay(1000);
+
+ /* Read GINTSTS */
+ gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
+ //fprintf(stderr, "GINTSTS: %08x\n", gintsts.d32);
+
+ /* Read HAINT */
+ haint.d32 = ifxusb_rreg(&hc_global_regs->haint);
+ //fprintf(stderr, "HAINT: %08x\n", haint.d32);
+
+ /* Read HCINT */
+ hcint.d32 = ifxusb_rreg(&hc_regs->hcint);
+ //fprintf(stderr, "HCINT: %08x\n", hcint.d32);
+
+ /* Read HCCHAR */
+ hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
+ //fprintf(stderr, "HCCHAR: %08x\n", hcchar.d32);
+
+ /* Clear HCINT */
+ ifxusb_wreg(&hc_regs->hcint, hcint.d32);
+
+ /* Clear HAINT */
+ ifxusb_wreg(&hc_global_regs->haint, haint.d32);
+
+ /* Clear GINTSTS */
+ ifxusb_wreg(&global_regs->gintsts, gintsts.d32);
+
+ hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
+ //if (hcchar.b.chen) {
+ // fprintf(stderr, "** Channel _still_ enabled 2, HCCHAR = %08x **\n", hcchar.d32);
+ //}
+ }
+
+ /* Set HCTSIZ */
+ hctsiz.d32 = 0;
+ hctsiz.b.xfersize = 8;
+ hctsiz.b.pktcnt = 1;
+ hctsiz.b.pid = IFXUSB_HC_PID_DATA1;
+ ifxusb_wreg(&hc_regs->hctsiz, hctsiz.d32);
+
+ /* Set HCCHAR */
+ hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
+ hcchar.b.eptype = IFXUSB_EP_TYPE_CTRL;
+ hcchar.b.epdir = 1;
+ hcchar.b.epnum = 0;
+ hcchar.b.mps = 8;
+ hcchar.b.chen = 1;
+ ifxusb_wreg(&hc_regs->hcchar, hcchar.d32);
+
+ gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
+ //fprintf(stderr, "Waiting for RXSTSQLVL intr 1, GINTSTS = %08x\n", gintsts.d32);
+
+ /* Wait for receive status queue interrupt */
+ do {
+ gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
+ } while (gintsts.b.rxstsqlvl == 0);
+
+ //fprintf(stderr, "Got RXSTSQLVL intr 1, GINTSTS = %08x\n", gintsts.d32);
+
+ /* Read RXSTS */
+ grxsts.d32 = ifxusb_rreg(&global_regs->grxstsp);
+ //fprintf(stderr, "GRXSTS: %08x\n", grxsts.d32);
+
+ /* Clear RXSTSQLVL in GINTSTS */
+ gintsts.d32 = 0;
+ gintsts.b.rxstsqlvl = 1;
+ ifxusb_wreg(&global_regs->gintsts, gintsts.d32);
+
+ switch (grxsts.hb.pktsts) {
+ case IFXUSB_HSTS_DATA_UPDT:
+ /* Read the data into the host buffer */
+ if (grxsts.hb.bcnt > 0) {
+ int i;
+ int word_count = (grxsts.hb.bcnt + 3) / 4;
+
+ for (i = 0; i < word_count; i++) {
+ (void)ifxusb_rreg(data_fifo++);
+ }
+ }
+
+ //fprintf(stderr, "Received %u bytes\n", (unsigned)grxsts.hb.bcnt);
+ break;
+
+ default:
+ //fprintf(stderr, "** Unexpected GRXSTS packet status 1 **\n");
+ break;
+ }
+
+ gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
+ //fprintf(stderr, "Waiting for RXSTSQLVL intr 2, GINTSTS = %08x\n", gintsts.d32);
+
+ /* Wait for receive status queue interrupt */
+ do {
+ gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
+ } while (gintsts.b.rxstsqlvl == 0);
+
+ //fprintf(stderr, "Got RXSTSQLVL intr 2, GINTSTS = %08x\n", gintsts.d32);
+
+ /* Read RXSTS */
+ grxsts.d32 = ifxusb_rreg(&global_regs->grxstsp);
+ //fprintf(stderr, "GRXSTS: %08x\n", grxsts.d32);
+
+ /* Clear RXSTSQLVL in GINTSTS */
+ gintsts.d32 = 0;
+ gintsts.b.rxstsqlvl = 1;
+ ifxusb_wreg(&global_regs->gintsts, gintsts.d32);
+
+ switch (grxsts.hb.pktsts) {
+ case IFXUSB_HSTS_XFER_COMP:
+ break;
+
+ default:
+ //fprintf(stderr, "** Unexpected GRXSTS packet status 2 **\n");
+ break;
+ }
+
+ gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
+ //fprintf(stderr, "Waiting for HCINTR intr 2, GINTSTS = %08x\n", gintsts.d32);
+
+ /* Wait for host channel interrupt */
+ do {
+ gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
+ } while (gintsts.b.hcintr == 0);
+
+ //fprintf(stderr, "Got HCINTR intr 2, GINTSTS = %08x\n", gintsts.d32);
+
+ /* Read HAINT */
+ haint.d32 = ifxusb_rreg(&hc_global_regs->haint);
+ //fprintf(stderr, "HAINT: %08x\n", haint.d32);
+
+ /* Read HCINT */
+ hcint.d32 = ifxusb_rreg(&hc_regs->hcint);
+ //fprintf(stderr, "HCINT: %08x\n", hcint.d32);
+
+ /* Read HCCHAR */
+ hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
+ //fprintf(stderr, "HCCHAR: %08x\n", hcchar.d32);
+
+ /* Clear HCINT */
+ ifxusb_wreg(&hc_regs->hcint, hcint.d32);
+
+ /* Clear HAINT */
+ ifxusb_wreg(&hc_global_regs->haint, haint.d32);
+
+ /* Clear GINTSTS */
+ ifxusb_wreg(&global_regs->gintsts, gintsts.d32);
+
+ /* Read GINTSTS */
+ gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
+ //fprintf(stderr, "GINTSTS: %08x\n", gintsts.d32);
+
+ // usleep(100000);
+ // mdelay(100);
+ mdelay(1);
+
+ /*
+ * Send handshake packet
+ */
+
+ /* Read HAINT */
+ haint.d32 = ifxusb_rreg(&hc_global_regs->haint);
+ //fprintf(stderr, "HAINT: %08x\n", haint.d32);
+
+ /* Read HCINT */
+ hcint.d32 = ifxusb_rreg(&hc_regs->hcint);
+ //fprintf(stderr, "HCINT: %08x\n", hcint.d32);
+
+ /* Read HCCHAR */
+ hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
+ //fprintf(stderr, "HCCHAR: %08x\n", hcchar.d32);
+
+ /* Clear HCINT */
+ ifxusb_wreg(&hc_regs->hcint, hcint.d32);
+
+ /* Clear HAINT */
+ ifxusb_wreg(&hc_global_regs->haint, haint.d32);
+
+ /* Clear GINTSTS */
+ ifxusb_wreg(&global_regs->gintsts, gintsts.d32);
+
+ /* Read GINTSTS */
+ gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
+ //fprintf(stderr, "GINTSTS: %08x\n", gintsts.d32);
+
+ /* Make sure channel is disabled */
+ hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
+ if (hcchar.b.chen) {
+ //fprintf(stderr, "Channel already enabled 3, HCCHAR = %08x\n", hcchar.d32);
+ hcchar.b.chdis = 1;
+ hcchar.b.chen = 1;
+ ifxusb_wreg(&hc_regs->hcchar, hcchar.d32);
+ //sleep(1);
+ mdelay(1000);
+
+ /* Read GINTSTS */
+ gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
+ //fprintf(stderr, "GINTSTS: %08x\n", gintsts.d32);
+
+ /* Read HAINT */
+ haint.d32 = ifxusb_rreg(&hc_global_regs->haint);
+ //fprintf(stderr, "HAINT: %08x\n", haint.d32);
+
+ /* Read HCINT */
+ hcint.d32 = ifxusb_rreg(&hc_regs->hcint);
+ //fprintf(stderr, "HCINT: %08x\n", hcint.d32);
+
+ /* Read HCCHAR */
+ hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
+ //fprintf(stderr, "HCCHAR: %08x\n", hcchar.d32);
+
+ /* Clear HCINT */
+ ifxusb_wreg(&hc_regs->hcint, hcint.d32);
+
+ /* Clear HAINT */
+ ifxusb_wreg(&hc_global_regs->haint, haint.d32);
+
+ /* Clear GINTSTS */
+ ifxusb_wreg(&global_regs->gintsts, gintsts.d32);
+
+ hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
+ //if (hcchar.b.chen) {
+ // fprintf(stderr, "** Channel _still_ enabled 3, HCCHAR = %08x **\n", hcchar.d32);
+ //}
+ }
+
+ /* Set HCTSIZ */
+ hctsiz.d32 = 0;
+ hctsiz.b.xfersize = 0;
+ hctsiz.b.pktcnt = 1;
+ hctsiz.b.pid = IFXUSB_HC_PID_DATA1;
+ ifxusb_wreg(&hc_regs->hctsiz, hctsiz.d32);
+
+ /* Set HCCHAR */
+ hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
+ hcchar.b.eptype = IFXUSB_EP_TYPE_CTRL;
+ hcchar.b.epdir = 0;
+ hcchar.b.epnum = 0;
+ hcchar.b.mps = 8;
+ hcchar.b.chen = 1;
+ ifxusb_wreg(&hc_regs->hcchar, hcchar.d32);
+
+ gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
+ //fprintf(stderr, "Waiting for HCINTR intr 3, GINTSTS = %08x\n", gintsts.d32);
+
+ /* Wait for host channel interrupt */
+ do {
+ gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
+ } while (gintsts.b.hcintr == 0);
+
+ //fprintf(stderr, "Got HCINTR intr 3, GINTSTS = %08x\n", gintsts.d32);
+
+ /* Disable HCINTs */
+ ifxusb_wreg(&hc_regs->hcintmsk, 0x0000);
+
+ /* Disable HAINTs */
+ ifxusb_wreg(&hc_global_regs->haintmsk, 0x0000);
+
+ /* Read HAINT */
+ haint.d32 = ifxusb_rreg(&hc_global_regs->haint);
+ //fprintf(stderr, "HAINT: %08x\n", haint.d32);
+
+ /* Read HCINT */
+ hcint.d32 = ifxusb_rreg(&hc_regs->hcint);
+ //fprintf(stderr, "HCINT: %08x\n", hcint.d32);
+
+ /* Read HCCHAR */
+ hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
+ //fprintf(stderr, "HCCHAR: %08x\n", hcchar.d32);
+
+ /* Clear HCINT */
+ ifxusb_wreg(&hc_regs->hcint, hcint.d32);
+
+ /* Clear HAINT */
+ ifxusb_wreg(&hc_global_regs->haint, haint.d32);
+
+ /* Clear GINTSTS */
+ ifxusb_wreg(&global_regs->gintsts, gintsts.d32);
+
+ /* Read GINTSTS */
+ gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
+ //fprintf(stderr, "GINTSTS: %08x\n", gintsts.d32);
+ }
+#endif //__WITH_HS_ELECT_TST__
+
diff --git a/package/platform/lantiq/ltq-hcd/src/ifxhcd_intr.c b/package/platform/lantiq/ltq-hcd/src/ifxhcd_intr.c
new file mode 100644
index 0000000..27885bb
--- /dev/null
+++ b/package/platform/lantiq/ltq-hcd/src/ifxhcd_intr.c
@@ -0,0 +1,4844 @@
+/*****************************************************************************
+ ** FILE NAME : ifxhcd_intr.c
+ ** PROJECT : IFX USB sub-system V3
+ ** MODULES : IFX USB sub-system Host and Device driver
+ ** SRC VERSION : 3.2
+ ** DATE : 1/Jan/2011
+ ** AUTHOR : Chen, Howard
+ ** DESCRIPTION : This file contains the implementation of the HCD Interrupt handlers.
+ ** FUNCTIONS :
+ ** COMPILER : gcc
+ ** REFERENCE : Synopsys DWC-OTG Driver 2.7
+ ** COPYRIGHT : Copyright (c) 2010
+ ** LANTIQ DEUTSCHLAND GMBH,
+ ** Am Campeon 3, 85579 Neubiberg, Germany
+ **
+ ** 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 of the License, or
+ ** (at your option) any later version.
+ **
+ ** Version Control Section **
+ ** $Author$
+ ** $Date$
+ ** $Revisions$
+ ** $Log$ Revision history
+ *****************************************************************************/
+
+/*
+ * This file contains code fragments from Synopsys HS OTG Linux Software Driver.
+ * For this code the following notice is applicable:
+ *
+ * ==========================================================================
+ *
+ * Synopsys HS OTG Linux Software Driver and documentation (hereinafter,
+ * "Software") is an Unsupported proprietary work of Synopsys, Inc. unless
+ * otherwise expressly agreed to in writing between Synopsys and you.
+ *
+ * The Software IS NOT an item of Licensed Software or Licensed Product under
+ * any End User Software License Agreement or Agreement for Licensed Product
+ * with Synopsys or any supplement thereto. You are permitted to use and
+ * redistribute this Software in source and binary forms, with or without
+ * modification, provided that redistributions of source code must retain this
+ * notice. You may not view, use, disclose, copy or distribute this file or
+ * any information contained herein except pursuant to this license grant from
+ * Synopsys. If you do not agree with this notice, including the disclaimer
+ * below, then you are not authorized to use the Software.
+ *
+ * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" BASIS
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ * ========================================================================== */
+
+/*!
+ \file ifxhcd_intr.c
+ \ingroup IFXUSB_DRIVER_V3
+ \brief This file contains the implementation of the HCD Interrupt handlers.
+*/
+
+
+#include <linux/version.h>
+#include "ifxusb_version.h"
+
+#include "ifxusb_plat.h"
+#include "ifxusb_regs.h"
+#include "ifxusb_cif.h"
+
+#include "ifxhcd.h"
+
+/* Macro used to clear one channel interrupt */
+#define clear_hc_int(_hc_regs_,_intr_) \
+ do { \
+ hcint_data_t hcint_clear = {.d32 = 0}; \
+ hcint_clear.b._intr_ = 1; \
+ ifxusb_wreg(&((_hc_regs_)->hcint), hcint_clear.d32); \
+ } while (0)
+
+/*
+ * Macro used to disable one channel interrupt. Channel interrupts are
+ * disabled when the channel is halted or released by the interrupt handler.
+ * There is no need to handle further interrupts of that type until the
+ * channel is re-assigned. In fact, subsequent handling may cause crashes
+ * because the channel structures are cleaned up when the channel is released.
+ */
+#define disable_hc_int(_hc_regs_,_intr_) \
+ do { \
+ hcint_data_t hcintmsk = {.d32 = 0}; \
+ hcintmsk.b._intr_ = 1; \
+ ifxusb_mreg(&((_hc_regs_)->hcintmsk), hcintmsk.d32, 0); \
+ } while (0)
+
+#define enable_hc_int(_hc_regs_,_intr_) \
+ do { \
+ hcint_data_t hcintmsk = {.d32 = 0}; \
+ hcintmsk.b._intr_ = 1; \
+ ifxusb_mreg(&((_hc_regs_)->hcintmsk),0, hcintmsk.d32); \
+ } while (0)
+
+/*
+ * Save the starting data toggle for the next transfer. The data toggle is
+ * saved in the QH for non-control transfers and it's saved in the QTD for
+ * control transfers.
+ */
+uint8_t read_data_toggle(ifxusb_hc_regs_t *_hc_regs)
+{
+ hctsiz_data_t hctsiz;
+ hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
+ return(hctsiz.b.pid);
+}
+
+
+static void release_channel_dump(ifxhcd_hc_t *ifxhc,
+ struct urb *urb,
+ ifxhcd_epqh_t *epqh,
+ ifxhcd_urbd_t *urbd,
+ ifxhcd_halt_status_e halt_status)
+{
+ #ifdef __DEBUG__
+ printk(KERN_INFO);
+ switch (halt_status)
+ {
+ case HC_XFER_NO_HALT_STATUS:
+ printk("HC_XFER_NO_HALT_STATUS");break;
+ case HC_XFER_URB_COMPLETE:
+ printk("HC_XFER_URB_COMPLETE");break;
+ case HC_XFER_AHB_ERR:
+ printk("HC_XFER_AHB_ERR");break;
+ case HC_XFER_STALL:
+ printk("HC_XFER_STALL");break;
+ case HC_XFER_BABBLE_ERR:
+ printk("HC_XFER_BABBLE_ERR");break;
+ case HC_XFER_XACT_ERR:
+ printk("HC_XFER_XACT_ERR");break;
+ case HC_XFER_URB_DEQUEUE:
+ printk("HC_XFER_URB_DEQUEUE");break;
+ case HC_XFER_FRAME_OVERRUN:
+ printk("HC_XFER_FRAME_OVERRUN");break;
+ case HC_XFER_DATA_TOGGLE_ERR:
+ printk("HC_XFER_DATA_TOGGLE_ERR");break;
+ #ifdef __NAKSTOP__
+ case HC_XFER_NAK:
+ printk("HC_XFER_NAK");break;
+ #endif
+ case HC_XFER_COMPLETE:
+ printk("HC_XFER_COMPLETE");break;
+ default:
+ printk("KNOWN");break;
+ }
+ if(ifxhc)
+ printk("Ch %d %s%s S%d " , ifxhc->hc_num
+ ,(ifxhc->ep_type == IFXUSB_EP_TYPE_CTRL)?"CTRL-":
+ ((ifxhc->ep_type == IFXUSB_EP_TYPE_BULK)?"BULK-":
+ ((ifxhc->ep_type == IFXUSB_EP_TYPE_INTR)?"INTR-":
+ ((ifxhc->ep_type == IFXUSB_EP_TYPE_ISOC)?"ISOC-":"????"
+ )
+ )
+ )
+ ,(ifxhc->is_in)?"IN":"OUT"
+ ,(ifxhc->split)
+ );
+ else
+ printk(" [NULL HC] ");
+ printk("urb=%p epqh=%p urbd=%p\n",urb,epqh,urbd);
+
+ if(urb)
+ {
+ printk(KERN_INFO " Device address: %d\n", usb_pipedevice(urb->pipe));
+ printk(KERN_INFO " Endpoint: %d, %s\n", usb_pipeendpoint(urb->pipe),
+ (usb_pipein(urb->pipe) ? "IN" : "OUT"));
+ printk(KERN_INFO " Endpoint type: %s\n",
+ ({char *pipetype;
+ switch (usb_pipetype(urb->pipe)) {
+ case PIPE_CONTROL: pipetype = "CTRL"; break;
+ case PIPE_BULK: pipetype = "BULK"; break;
+ case PIPE_INTERRUPT: pipetype = "INTR"; break;
+ case PIPE_ISOCHRONOUS: pipetype = "ISOC"; break;
+ default: pipetype = "????"; break;
+ }; pipetype;}));
+ printk(KERN_INFO " Speed: %s\n",
+ ({char *speed;
+ switch (urb->dev->speed) {
+ case USB_SPEED_HIGH: speed = "HS"; break;
+ case USB_SPEED_FULL: speed = "FS"; break;
+ case USB_SPEED_LOW: speed = "LS"; break;
+ default: speed = "????"; break;
+ }; speed;}));
+ printk(KERN_INFO " Max packet size: %d\n",
+ usb_maxpacket(urb->dev, urb->pipe, usb_pipeout(urb->pipe)));
+ printk(KERN_INFO " Data buffer length: %d/%d\n",urb->actual_length, urb->transfer_buffer_length);
+ printk(KERN_INFO " Transfer buffer: %p, Transfer DMA: %p\n",
+ urb->transfer_buffer, (void *)urb->transfer_dma);
+ printk(KERN_INFO " Setup buffer: %p, Setup DMA: %p\n",
+ urb->setup_packet, (void *)urb->setup_dma);
+ printk(KERN_INFO " Interval: %d\n", urb->interval);
+ }
+ if(urbd)
+ {
+ switch (urbd->status)
+ {
+ case HC_XFER_NO_HALT_STATUS:
+ printk(KERN_INFO " STATUS:HC_XFER_NO_HALT_STATUS\n");break;
+ case HC_XFER_URB_COMPLETE:
+ printk(KERN_INFO " STATUS:HC_XFER_URB_COMPLETE\n");break;
+ case HC_XFER_AHB_ERR:
+ printk(KERN_INFO " STATUS:HC_XFER_AHB_ERR\n");break;
+ case HC_XFER_STALL:
+ printk(KERN_INFO " STATUS:HC_XFER_STALL\n");break;
+ case HC_XFER_BABBLE_ERR:
+ printk(KERN_INFO " STATUS:HC_XFER_BABBLE_ERR\n");break;
+ case HC_XFER_XACT_ERR:
+ printk(KERN_INFO " STATUS:HC_XFER_XACT_ERR\n");break;
+ case HC_XFER_URB_DEQUEUE:
+ printk(KERN_INFO " STATUS:HC_XFER_URB_DEQUEUE\n");break;
+ case HC_XFER_FRAME_OVERRUN:
+ printk(KERN_INFO " STATUS:HC_XFER_FRAME_OVERRUN\n");break;
+ case HC_XFER_DATA_TOGGLE_ERR:
+ printk(KERN_INFO " STATUS:HC_XFER_DATA_TOGGLE_ERR\n");break;
+ case HC_XFER_COMPLETE:
+ printk(KERN_INFO " STATUS:HC_XFER_COMPLETE\n");break;
+ default:
+ printk(KERN_INFO " STATUS:UNKKNOWN %d\n",urbd->status);break;
+ }
+ }
+ #endif
+}
+
+/*!
+ \fn static void release_channel(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxhcd_halt_status_e _halt_status)
+ \brief Release the halted channel.
+ \param _ifxhcd Pointer to the sate of HCD structure
+ \param _ifxhc Pointer to host channel descriptor
+ \param _halt_status Halt satus
+ \return None
+ \ingroup IFXUSB_HCD
+ */
+
+static void release_channel(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxhcd_halt_status_e _halt_status)
+{
+ ifxusb_hc_regs_t *hc_regs = _ifxhcd->core_if.hc_regs[_ifxhc->hc_num];
+ struct urb *urb = NULL;
+ ifxhcd_epqh_t *epqh = NULL;
+ ifxhcd_urbd_t *urbd = NULL;
+
+ IFX_DEBUGPL(DBG_HCDV, " %s: channel %d, halt_status %d\n",
+ __func__, _ifxhc->hc_num, _halt_status);
+
+ epqh=_ifxhc->epqh;
+
+ if(!epqh)
+ {
+ if(_halt_status!=HC_XFER_NO_EPQH)
+ IFX_ERROR("%s epqh=null\n",__func__);
+ }
+ else
+ {
+ urbd=epqh->urbd;
+ if(!urbd)
+ IFX_ERROR("%s urbd=null\n",__func__);
+ else
+ {
+ urb=urbd->urb;
+ if(!urb)
+ {
+ if(_halt_status!=HC_XFER_NO_URB)
+ IFX_ERROR("%s urb =null\n",__func__);
+ }
+ else
+ {
+ if (read_data_toggle(hc_regs) == IFXUSB_HCTSIZ_DATA0)
+ usb_settoggle (urb->dev,usb_pipeendpoint (urb->pipe), (_ifxhc->is_in)?0:1,0);
+ else if (read_data_toggle(hc_regs) == IFXUSB_HCTSIZ_DATA1)
+ usb_settoggle (urb->dev,usb_pipeendpoint (urb->pipe), (_ifxhc->is_in)?0:1,1);
+ }
+ }
+ }
+
+ switch (_halt_status)
+ {
+ case HC_XFER_NO_HALT_STATUS:
+ IFX_ERROR("%s: No halt_status, channel %d\n", __func__, _ifxhc->hc_num);
+// return;
+ break;
+ case HC_XFER_COMPLETE:
+ IFX_ERROR("%s: Inavalid halt_status HC_XFER_COMPLETE, channel %d\n", __func__, _ifxhc->hc_num);
+// return;
+ break;
+ case HC_XFER_NO_URB:
+ break;
+ case HC_XFER_NO_EPQH:
+ break;
+ case HC_XFER_URB_DEQUEUE:
+ case HC_XFER_AHB_ERR:
+ case HC_XFER_XACT_ERR:
+ case HC_XFER_FRAME_OVERRUN:
+ if(urbd && urb)
+ {
+ urbd->phase=URBD_DEQUEUEING;
+ ifxhcd_complete_urb(_ifxhcd, urbd, urbd->status);
+ }
+ else
+ {
+ IFX_WARN("WARNING %s():%d urbd=%p urb=%p\n",__func__,__LINE__,urbd,urb);
+ release_channel_dump(_ifxhc,urb,epqh,urbd,_halt_status);
+ }
+ break;
+ case HC_XFER_URB_COMPLETE:
+ if(urbd && urb)
+ {
+ urbd->phase=URBD_COMPLETING;
+ ifxhcd_complete_urb(_ifxhcd, urbd, urbd->status);
+ }
+ else
+ {
+ IFX_WARN("WARNING %s():%d urbd=%p urb=%p\n",__func__,__LINE__,urbd,urb);
+ release_channel_dump(_ifxhc,urb,epqh,urbd,_halt_status);
+ }
+ break;
+ case HC_XFER_STALL:
+ if(urbd)
+ {
+ urbd->phase=URBD_DEQUEUEING;
+ ifxhcd_complete_urb(_ifxhcd, urbd, -EPIPE);
+ }
+ else
+ {
+ IFX_WARN("WARNING %s():%d urbd=%p urb=%p\n",__func__,__LINE__,urbd,urb);
+ release_channel_dump(_ifxhc,urb,epqh,urbd,_halt_status);
+ }
+ if(epqh && urb && urb->dev && urb->pipe)
+ usb_settoggle(urb->dev, usb_pipeendpoint (urb->pipe), !usb_pipein(urb->pipe), IFXUSB_HC_PID_DATA0);
+ break;
+ case HC_XFER_BABBLE_ERR:
+ case HC_XFER_DATA_TOGGLE_ERR:
+ if(urbd)
+ {
+ urbd->phase=URBD_DEQUEUEING;
+ ifxhcd_complete_urb(_ifxhcd, urbd, -EOVERFLOW);
+ }
+ else
+ {
+ IFX_WARN("WARNING %s():%d urbd=%p urb=%p\n",__func__,__LINE__,urbd,urb);
+ release_channel_dump(_ifxhc,urb,epqh,urbd,_halt_status);
+ }
+ break;
+ #ifdef __NAKSTOP__
+ case HC_XFER_NAK:
+ if (_ifxhc->is_in)
+ {
+ if(urbd && urb)
+ {
+ urbd->phase=URBD_COMPLETING;
+ ifxhcd_complete_urb(_ifxhcd, urbd, 0);
+ }
+ else
+ {
+ IFX_WARN("WARNING %s():%d urbd=%p urb=%p\n",__func__,__LINE__,urbd,urb);
+ release_channel_dump(_ifxhc,urb,epqh,urbd,_halt_status);
+ }
+ }
+ else
+ {
+ IFX_WARN("WARNING %s():%d urbd=%p urb=%p\n",__func__,__LINE__,urbd,urb);
+ release_channel_dump(_ifxhc,urb,epqh,urbd,_halt_status);
+ }
+ break;
+ #endif
+ #if defined(__INTRNAKRETRY__) || defined(__INTRINCRETRY__)
+ case HC_XFER_INTR_NAK_RETRY:
+ epqh->phase=EPQH_READY;
+ urbd->phase=URBD_IDLE;
+ ifxhcd_hc_cleanup(&_ifxhcd->core_if, _ifxhc);
+ select_eps(_ifxhcd);
+ return;
+ break;
+
+ #endif
+ }
+ if(epqh)
+ {
+ ifxhcd_epqh_idle(epqh);
+ }
+ else if(_halt_status!=HC_XFER_NO_EPQH)
+ {
+ IFX_WARN("WARNING %s():%d epqh=%p\n",__func__,__LINE__,epqh);
+ release_channel_dump(_ifxhc,urb,epqh,urbd,_halt_status);
+ }
+ ifxhcd_hc_cleanup(&_ifxhcd->core_if, _ifxhc);
+ select_eps(_ifxhcd);
+}
+
+/*
+ * Updates the state of the URB after a Transfer Complete interrupt on the
+ * host channel. Updates the actual_length field of the URB based on the
+ * number of bytes transferred via the host channel. Sets the URB status
+ * if the data transfer is finished.
+ *
+ * @return 1 if the data transfer specified by the URB is completely finished,
+ * 0 otherwise.
+ */
+static int update_urb_state_xfer_comp(ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ struct urb *_urb,
+ ifxhcd_urbd_t *_urbd)
+{
+ int xfer_done = 0;
+
+ #ifdef __EN_ISOC__
+ if(_urbd->epqh->ep_type==IFXUSB_EP_TYPE_ISOC)
+ {
+ struct usb_iso_packet_descriptor *frame_desc;
+ frame_desc = &_urb->iso_frame_desc[_urbd->isoc_frame_index];
+ if (_ifxhc->is_in)
+ {
+ hctsiz_data_t hctsiz;
+ hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
+ frame_desc->actual_length += (_ifxhc->xfer_len - hctsiz.b.xfersize);
+ if ((hctsiz.b.xfersize != 0) || (frame_desc->actual_length >= _urbd->xfer_len))
+ {
+ xfer_done = 1;
+ frame_desc->status = 0;
+ #if 0
+ if (frame_desc->actual_length < frame_desc->length && _urb->transfer_flags & URB_SHORT_NOT_OK)
+ frame_desc->status = -EREMOTEIO;
+ #endif
+ }
+ }
+ else
+ {
+ if (_ifxhc->split)
+ frame_desc->actual_length += _ifxhc->ssplit_out_xfer_count;
+ else
+ frame_desc->actual_length += _ifxhc->xfer_len;
+ if (frame_desc->actual_length >= _urbd->xfer_len)
+ {
+ xfer_done = 1;
+ frame_desc->status = 0;
+ }
+ }
+ }
+ else
+ #endif
+ if (_ifxhc->is_in)
+ {
+ hctsiz_data_t hctsiz;
+ hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
+ _urb->actual_length += (_ifxhc->xfer_len - hctsiz.b.xfersize);
+#ifdef __INTRINCRETRY__
+ if(_urbd->epqh->ep_type==IFXUSB_EP_TYPE_INTR)
+ {
+ if(_ifxhc->xfer_len != hctsiz.b.xfersize)
+ {
+ xfer_done = 1;
+ _urbd->status = 0;
+ }
+ }
+ else
+#endif
+ if ((hctsiz.b.xfersize != 0) || (_urb->actual_length >= _urb->transfer_buffer_length))
+ {
+ xfer_done = 1;
+ _urbd->status = 0;
+ if(_urb->transfer_flags & URB_SHORT_NOT_OK)
+ {
+ if (_urb->actual_length < _urb->transfer_buffer_length)
+ _urbd->status = -EREMOTEIO;
+ }
+ }
+ }
+ else if(_urb->transfer_buffer_length%_ifxhc->mps) // OUT without ZLP
+ {
+ if (_ifxhc->split)
+ _urb->actual_length += _ifxhc->ssplit_out_xfer_count;
+ else
+ _urb->actual_length += _ifxhc->xfer_len;
+ if (_urb->actual_length >= _urb->transfer_buffer_length)
+ {
+ xfer_done = 1;
+ _urbd->status = 0;
+ }
+ }
+ else if (_urb->actual_length >= _urb->transfer_buffer_length) //OUT with ZLP
+ {
+ xfer_done = 1;
+ _urbd->status = 0;
+ }
+ else //OUT without ZLP, unfinished
+ {
+ if (_ifxhc->split)
+ _urb->actual_length += _ifxhc->ssplit_out_xfer_count;
+ else
+ _urb->actual_length += _ifxhc->xfer_len;
+ if (!_ifxhc->short_rw && _urb->actual_length >= _urb->transfer_buffer_length)
+ {
+ xfer_done = 1;
+ _urbd->status = 0;
+ }
+ }
+
+ #ifdef __DEBUG__
+ {
+ hctsiz_data_t hctsiz;
+ hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
+ IFX_DEBUGPL(DBG_HCDV, "IFXUSB: %s: %s, channel %d\n",
+ __func__, (_ifxhc->is_in ? "IN" : "OUT"), _ifxhc->hc_num);
+ IFX_DEBUGPL(DBG_HCDV, " hc->xfer_len %d\n", _ifxhc->xfer_len);
+ IFX_DEBUGPL(DBG_HCDV, " hctsiz.xfersize %d\n", hctsiz.b.xfersize);
+ #ifdef __EN_ISOC__
+ if(_urbd->epqh->ep_type==IFXUSB_EP_TYPE_ISOC)
+ {
+ IFX_DEBUGPL(DBG_HCDV, " descritor # %d\n", _urbd->isoc_frame_index);
+ IFX_DEBUGPL(DBG_HCDV, " buffer_length %d\n",
+ _urb->iso_frame_desc[_urbd->isoc_frame_index].length);
+ IFX_DEBUGPL(DBG_HCDV, " actual_length %d\n", _urb->iso_frame_desc[_urbd->isoc_frame_index].actual_length);
+ }
+ else
+ #endif
+ {
+ IFX_DEBUGPL(DBG_HCDV, " urb->transfer_buffer_length %d\n",
+ _urb->transfer_buffer_length);
+ IFX_DEBUGPL(DBG_HCDV, " urb->actual_length %d\n", _urb->actual_length);
+ }
+ }
+ #endif
+ return xfer_done;
+}
+
+#ifdef __EN_ISOC__
+ static void next_isoc_sub(unsigned long data)
+ {
+ ifxhcd_urbd_t *urbd;
+ ifxhcd_hcd_t *ifxhcd;
+
+ urbd=((ifxhcd_urbd_t *)data);
+ ifxhcd=urbd->epqh->ifxhcd;
+
+ if (!urbd->epqh)
+ IFX_ERROR("%s: invalid epqd\n",__func__);
+ #if defined(__UNALIGNED_BUF_ADJ__)
+ else
+ {
+ if( urbd->aligned_checked &&
+// urbd->using_aligned_buf &&
+ urbd->xfer_buff &&
+ urbd->is_in)
+ {
+ uint8_t *buf;
+
+ buf=urbd->xfer_buff;
+ buf+=urbd->urb->iso_frame_desc[urbd->isoc_frame_index].offset;
+ memcpy(buf,urbd->aligned_buf,urbd->urb->iso_frame_desc[urbd->isoc_frame_index].length);
+ }
+// urbd->using_aligned_buf=0;
+// urbd->using_aligned_setup=0;
+ }
+ #endif
+
+ urbd->isoc_frame_index++;
+ if(urbd->isoc_frame_index>=urbd->urb->number_of_packets)
+ release_channel(ifxhcd,urbd->epqh->hc,HC_XFER_URB_COMPLETE);
+ else
+ init_hc(urbd->epqh);
+ }
+#endif
+
+/*!
+ \fn static void complete_channel(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxhcd_urbd_t *_urbd)
+ \brief Complete the transaction on the channel.
+ \param _ifxhcd Pointer to the sate of HCD structure
+ \param _ifxhc Pointer to host channel descriptor
+ \param _urbd Pointer to URB descriptor
+ \return None
+ \ingroup IFXUSB_HCD
+ */
+static void complete_channel(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxhcd_urbd_t *_urbd)
+{
+ ifxusb_hc_regs_t *hc_regs = _ifxhcd->core_if.hc_regs[_ifxhc->hc_num];
+ struct urb *urb = NULL;
+ ifxhcd_epqh_t *epqh = NULL;
+ int urb_xfer_done;
+
+ IFX_DEBUGPL(DBG_HCD, "--Complete Channel %d : \n", _ifxhc->hc_num);
+
+ if(!_urbd)
+ {
+ IFX_ERROR("ERROR %s():%d urbd=%p\n",__func__,__LINE__,_urbd);
+ return;
+ }
+
+ urb = _urbd->urb;
+ epqh = _urbd->epqh;
+
+ if(!epqh)
+ {
+ release_channel(_ifxhcd,_ifxhc,HC_XFER_NO_EPQH);
+ return;
+ }
+ if(!urb || (unsigned long)urb->hcpriv!=(unsigned long)_urbd)
+ {
+ release_channel(_ifxhcd,_ifxhc,HC_XFER_NO_URB);
+ return;
+ }
+
+ if (_ifxhc->split)
+ _ifxhc->split = 1;
+
+ switch (epqh->ep_type)
+ {
+ case IFXUSB_EP_TYPE_CTRL:
+ switch (_ifxhc->control_phase)
+ {
+ case IFXHCD_CONTROL_SETUP:
+ if (_urbd->xfer_len > 0)
+ {
+ _ifxhc->control_phase = IFXHCD_CONTROL_DATA;
+ IFX_DEBUGPL(DBG_HCDV, " Control setup transaction done Data Stage now\n");
+ _ifxhc->is_in = _urbd->is_in;
+ _ifxhc->xfer_len = _urbd->xfer_len;
+ #if defined(__UNALIGNED_BUF_ADJ__)
+ if(_urbd->aligned_buf)
+ _ifxhc->xfer_buff = _urbd->aligned_buf;
+ else
+ #endif
+ _ifxhc->xfer_buff = _urbd->xfer_buff;
+ #ifdef __NAKSTOP__
+ if(!_ifxhc->split)
+ {
+ #ifdef __INNAKSTOP_CTRL__
+ if(_ifxhc->is_in)
+ _ifxhc->stop_on=1;
+ #endif
+ #ifdef __PINGSTOP_CTRL__
+ if(!_ifxhc->is_in)
+ _ifxhc->stop_on=1;
+ #endif
+ }
+ #endif
+ }
+ else
+ {
+ IFX_DEBUGPL(DBG_HCDV, " Control setup transaction done Status Stage now\n");
+ _ifxhc->control_phase = IFXHCD_CONTROL_STATUS;
+ _ifxhc->is_in = 1;
+ _ifxhc->xfer_len = 0;
+ _ifxhc->xfer_buff = _ifxhcd->status_buf;
+ #ifdef __NAKSTOP__
+ _ifxhc->stop_on=0;
+ #endif
+ }
+ if(_ifxhc->is_in)
+ _ifxhc->short_rw =0;
+ else
+ _ifxhc->short_rw =(urb->transfer_flags & URB_ZERO_PACKET)?1:0;
+ _ifxhc->data_pid_start = IFXUSB_HC_PID_DATA1;
+ _ifxhc->xfer_count = 0;
+ _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ break;
+ case IFXHCD_CONTROL_DATA:
+ urb_xfer_done = update_urb_state_xfer_comp(_ifxhc, hc_regs, urb, _urbd);
+ if (urb_xfer_done)
+ {
+ _ifxhc->control_phase = IFXHCD_CONTROL_STATUS;
+ IFX_DEBUGPL(DBG_HCDV, " Control data transaction done Status Stage now\n");
+ _ifxhc->is_in = (_urbd->is_in)?0:1;
+ _ifxhc->xfer_len = 0;
+ _ifxhc->xfer_count = 0;
+ _ifxhc->xfer_buff = _ifxhcd->status_buf;
+ _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
+ _ifxhc->data_pid_start = IFXUSB_HC_PID_DATA1;
+ if(_ifxhc->is_in)
+ _ifxhc->short_rw =0;
+ else
+ _ifxhc->short_rw =1;
+ #ifdef __NAKSTOP__
+ _ifxhc->stop_on=0;
+ #endif
+ }
+ else // continue
+ {
+ IFX_DEBUGPL(DBG_HCDV, " Control data transaction continue\n");
+ _ifxhc->xfer_len = _urbd->xfer_len - urb->actual_length;
+ _ifxhc->xfer_count = urb->actual_length;
+ _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
+ _ifxhc->data_pid_start = read_data_toggle(hc_regs);
+ }
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ break;
+ case IFXHCD_CONTROL_STATUS:
+ IFX_DEBUGPL(DBG_HCDV, " Control status transaction done\n");
+ if (_urbd->status == -EINPROGRESS)
+ _urbd->status = 0;
+ release_channel(_ifxhcd,_ifxhc,HC_XFER_URB_COMPLETE);
+ break;
+ }
+ break;
+ case IFXUSB_EP_TYPE_BULK:
+ IFX_DEBUGPL(DBG_HCDV, " Bulk transfer complete\n");
+ urb_xfer_done = update_urb_state_xfer_comp(_ifxhc, hc_regs, urb, _urbd);
+ if (urb_xfer_done)
+ release_channel(_ifxhcd,_ifxhc,HC_XFER_URB_COMPLETE);
+ else
+ {
+ _ifxhc->xfer_len = _urbd->xfer_len - urb->actual_length;
+ _ifxhc->xfer_count = urb->actual_length;
+ _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
+ _ifxhc->data_pid_start = read_data_toggle(hc_regs);
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ break;
+ case IFXUSB_EP_TYPE_INTR:
+ urb_xfer_done = update_urb_state_xfer_comp(_ifxhc, hc_regs, urb, _urbd);
+
+ #ifdef __INTRINCRETRY__
+ if(!urb_xfer_done)
+ release_channel(_ifxhcd,_ifxhc,HC_XFER_INTR_NAK_RETRY);
+ else
+ #endif
+ release_channel(_ifxhcd,_ifxhc,HC_XFER_URB_COMPLETE);
+ break;
+ case IFXUSB_EP_TYPE_ISOC:
+ #ifdef __EN_ISOC__
+ urb_xfer_done = update_urb_state_xfer_comp(_ifxhc, hc_regs, urb, _urbd);
+ if (urb_xfer_done)
+ {
+ #if defined(__UNALIGNED_BUF_ADJ__)
+ if(in_irq())
+ {
+ if(!epqh->tasklet_next_isoc.func)
+ {
+ epqh->tasklet_next_isoc.next = NULL;
+ epqh->tasklet_next_isoc.state = 0;
+ atomic_set( &epqh->tasklet_next_isoc.count, 0);
+ epqh->tasklet_next_isoc.func = next_isoc_sub;
+ epqh->tasklet_next_isoc.data = (unsigned long)_urbd;
+ }
+ tasklet_schedule(&epqh->tasklet_next_isoc);
+ }
+ else
+ #endif
+ {
+ next_isoc_sub((unsigned long)_urbd);
+ }
+ }
+ else
+ {
+ struct usb_iso_packet_descriptor *frame_desc;
+ frame_desc = &urb->iso_frame_desc[_urbd->isoc_frame_index];
+ _ifxhc->xfer_len = _urbd->xfer_len - frame_desc->actual_length;
+ _ifxhc->xfer_count = frame_desc->actual_length;
+ _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
+ _ifxhc->data_pid_start = read_data_toggle(hc_regs);
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ #endif
+ break;
+ }
+}
+
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+static int32_t chhltd_ctrl_rx_nonsplit(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ hcint_data_t hcint;
+ hcint_data_t hcintmsk;
+ hctsiz_data_t hctsiz;
+
+ hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
+ hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
+ hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
+
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nak);
+ disable_hc_int(_hc_regs,nyet);
+
+ #ifdef __INNAKSTOP_CTRL__
+ if (_ifxhc->halt_status == HC_XFER_NAK)
+ {
+ if(_ifxhc->control_phase == IFXHCD_CONTROL_DATA)
+ {
+ u32 actual_length;
+ actual_length = _urbd->urb->actual_length + (_ifxhc->xfer_len - hctsiz.b.xfersize);
+
+ if(_urbd->xfer_len && actual_length >= _urbd->xfer_len)
+ {
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ else
+ {
+ _ifxhc->xfer_count =
+ _urbd->urb->actual_length = actual_length;
+ _ifxhc->xfer_len = _urbd->xfer_len - actual_length;
+ _ifxhc->data_pid_start = read_data_toggle(_hc_regs);
+ _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ }
+ else
+ {
+ printk(KERN_INFO "Warning: %s() %d Invalid CTRL Phase:%d\n",__func__,__LINE__,_ifxhc->control_phase);
+ release_channel(_ifxhcd, _ifxhc, _ifxhc->halt_status);
+ }
+ return 1;
+ }
+ #endif
+
+ if (hcint.b.xfercomp || hcint.d32 == 0x02)
+ {
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ return 1;
+ }
+ else if (hcint.b.stall)
+ {
+ _urbd->error_count =0;
+ // ZLP shortcut
+ #if 0
+ if(hctsiz.b.pktcnt==0)
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ else
+ #endif
+ #if 0
+ if(_ifxhc->control_phase == IFXHCD_CONTROL_STATUS)
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ else
+ #endif
+ {
+ if(_ifxhc->control_phase == IFXHCD_CONTROL_DATA)
+ _urbd->urb->actual_length += (_ifxhc->xfer_len - hctsiz.b.xfersize);
+// if( _urbd->urb->actual_length > _ifxhc->xfer_len) _urbd->urb->actual_length = _urbd->xfer_len;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_STALL);
+ }
+ return 1;
+ }
+ else if (hcint.b.bblerr)
+ {
+ _urbd->error_count =0;
+
+ // ZLP shortcut
+ #if 0
+ if(hctsiz.b.pktcnt==0)
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ else
+ #endif
+ #if 0
+ if(_ifxhc->control_phase == IFXHCD_CONTROL_STATUS)
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ else
+ #endif
+ {
+ if(_ifxhc->control_phase == IFXHCD_CONTROL_DATA)
+ _urbd->urb->actual_length += (_ifxhc->xfer_len - hctsiz.b.xfersize);
+// if( _urbd->urb->actual_length > _ifxhc->xfer_len) _urbd->urb->actual_length = _urbd->xfer_len;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_BABBLE_ERR);
+ }
+ return 1;
+ }
+ else if (hcint.b.xacterr)
+ {
+ // ZLP shortcut
+ #if 1
+ if(hctsiz.b.pktcnt==0)
+ {
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ else
+ #endif
+ #if 1
+ if(_ifxhc->control_phase == IFXHCD_CONTROL_STATUS)
+ {
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ else
+ #endif
+ if(_ifxhc->control_phase == IFXHCD_CONTROL_DATA)
+ {
+ #if 1
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ #else
+ u32 actual_length;
+ actual_length = _urbd->urb->actual_length + (_ifxhc->xfer_len - hctsiz.b.xfersize);
+ if(actual_length >= _urbd->xfer_len)
+ {
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ else
+ {
+ _urbd->error_count++;
+ _ifxhc->xfer_count =
+ _urbd->urb->actual_length = actual_length;
+ _ifxhc->xfer_len = _urbd->xfer_len - actual_length;
+ _ifxhc->data_pid_start = read_data_toggle(_hc_regs);
+ if (_urbd->error_count >= 3)
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ }
+ else
+ {
+ _ifxhc->erron=1;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ }
+ #endif
+ }
+ else
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ }
+ return 1;
+ }
+ else if(hcint.b.datatglerr )
+ {
+ #if 0
+ #if 1
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ #else
+ u32 actual_length;
+ actual_length = _urbd->urb->actual_length + (_ifxhc->xfer_len - hctsiz.b.xfersize);
+ if(actual_length>=_urbd->xfer_len)
+ {
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ else
+ {
+ _urbd->urb->actual_length = actual_length;
+ _ifxhc->data_pid_start = read_data_toggle(_hc_regs);
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_DATA_TOGGLE_ERR);
+ }
+ #endif
+ #else
+ if(_ifxhc->control_phase == IFXHCD_CONTROL_DATA)
+ _urbd->urb->actual_length += (_ifxhc->xfer_len - hctsiz.b.xfersize);
+// if( _urbd->urb->actual_length > _ifxhc->xfer_len) _urbd->urb->actual_length = _urbd->xfer_len;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_DATA_TOGGLE_ERR);
+ #endif
+ return 1;
+ }
+ else if(hcint.b.frmovrun )
+ {
+ if(_ifxhc->control_phase == IFXHCD_CONTROL_DATA)
+ _urbd->urb->actual_length += (_ifxhc->xfer_len - hctsiz.b.xfersize);
+// if( _urbd->urb->actual_length > _ifxhc->xfer_len) _urbd->urb->actual_length = _urbd->xfer_len;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_FRAME_OVERRUN);
+ return 1;
+ }
+ else
+ {
+ _urbd->error_count =0;
+ IFX_ERROR("ERROR %s():%d invalid chhlt condition %08X/%08X %d\n",__func__,__LINE__,hcint.d32,hcintmsk.d32,_ifxhc->halt_status);
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ return 1;
+ }
+
+ return 0;
+}
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+static int32_t chhltd_ctrl_tx_nonsplit(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ hcint_data_t hcint;
+ hcint_data_t hcintmsk;
+ hctsiz_data_t hctsiz;
+
+ hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
+ hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
+ hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
+
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nak);
+ disable_hc_int(_hc_regs,nyet);
+
+ #ifdef __PINGSTOP_CTRL__
+ if (_ifxhc->halt_status == HC_XFER_NAK)
+ {
+ if(_ifxhc->control_phase == IFXHCD_CONTROL_DATA)
+ {
+ u32 actual_length;
+ actual_length = _urbd->urb->actual_length + ((_ifxhc->start_pkt_count - hctsiz.b.pktcnt ) * _ifxhc->mps);
+
+ if(_urbd->xfer_len && actual_length >= _urbd->xfer_len)
+ {
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ else
+ {
+ _ifxhc->xfer_count =
+ _urbd->urb->actual_length = actual_length;
+ _ifxhc->xfer_len = _urbd->xfer_len - actual_length;
+ _ifxhc->data_pid_start = read_data_toggle(_hc_regs);
+ _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ }
+ else
+ {
+ printk(KERN_INFO "Warning: %s() %d Invalid CTRL Phase:%d\n",__func__,__LINE__,_ifxhc->control_phase);
+ release_channel(_ifxhcd, _ifxhc, _ifxhc->halt_status);
+ }
+ return 1;
+ }
+ #endif
+
+
+ if (hcint.b.xfercomp || hcint.d32 == 0x02)
+ {
+ _urbd->error_count =0;
+ if(_ifxhc->xfer_len==0 && !hcint.b.ack && hcint.b.nak)
+ {
+ // Walkaround: When sending ZLP and receive NAK but also issue CMPT intr
+ // Solution: NoSplit: Resend at next SOF
+ // Split : Resend at next SOF with SSPLIT
+ if(hcint.b.nyet)
+ _ifxhc->epqh->do_ping=1;
+
+ _ifxhc->xfer_len = 0;
+ _ifxhc->xfer_count = 0;
+ _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ else
+ {
+ if(hcint.b.nyet)
+ _ifxhc->epqh->do_ping=1;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ return 1;
+ }
+ else if (hcint.b.stall)
+ {
+ _urbd->error_count =0;
+
+ // ZLP shortcut
+ #if 1
+ if(hctsiz.b.pktcnt==0)
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ else
+ #endif
+ {
+ if(_ifxhc->control_phase == IFXHCD_CONTROL_DATA)
+ {
+ _urbd->urb->actual_length += ((_ifxhc->start_pkt_count - hctsiz.b.pktcnt ) * _ifxhc->mps);
+// if( _urbd->urb->actual_length > _ifxhc->xfer_len) _urbd->urb->actual_length = _urbd->xfer_len;
+ }
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_STALL);
+ }
+ return 1;
+ }
+ else if (hcint.b.xacterr)
+ {
+ // ZLP shortcut
+ #if 1
+ if(hctsiz.b.pktcnt==0)
+ {
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ else
+ #endif
+ if(_ifxhc->control_phase == IFXHCD_CONTROL_STATUS)
+ {
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ else if(_ifxhc->control_phase == IFXHCD_CONTROL_SETUP)
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ }
+ else if(_ifxhc->control_phase == IFXHCD_CONTROL_DATA)
+ {
+ #if 0
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ #else
+ u32 actual_length;
+ actual_length = _urbd->urb->actual_length + ((_ifxhc->start_pkt_count - hctsiz.b.pktcnt ) * _ifxhc->mps);
+ if(actual_length>=_urbd->xfer_len)
+ {
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ else
+ {
+ _urbd->error_count++;
+ _ifxhc->xfer_count =
+ _urbd->urb->actual_length = actual_length;
+ _ifxhc->xfer_len = _urbd->xfer_len - actual_length;
+ _ifxhc->data_pid_start = read_data_toggle(_hc_regs);
+ if (_urbd->error_count >= 3)
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ }
+ else
+ {
+ _ifxhc->erron=1;
+ _ifxhc->phase=HC_WAITING;
+ _ifxhc->epqh->do_ping=1;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ }
+ #endif
+ }
+ else
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ }
+ return 1;
+ }
+ else if(hcint.b.bblerr )
+ {
+ if(_ifxhc->control_phase == IFXHCD_CONTROL_DATA)
+ {
+ _urbd->urb->actual_length += ((_ifxhc->start_pkt_count - hctsiz.b.pktcnt ) * _ifxhc->mps);
+// if( _urbd->urb->actual_length > _ifxhc->xfer_len) _urbd->urb->actual_length = _urbd->xfer_len;
+ }
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_BABBLE_ERR);
+ return 1;
+ }
+ else if(hcint.b.nak || hcint.b.nyet)
+ {
+ #ifdef __PINGSTOP_CTRL__
+ _urbd->error_count =0;
+ IFX_ERROR("ERROR %s():%d invalid chhlt condition\n",__func__,__LINE__);
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ #else
+ // ZLP shortcut
+ #if 1
+ if(hctsiz.b.pktcnt==0)
+ {
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ else
+ #endif
+ if(_ifxhc->control_phase == IFXHCD_CONTROL_STATUS)
+ {
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ else if(_ifxhc->control_phase == IFXHCD_CONTROL_SETUP)
+ {
+ _urbd->error_count =0;
+ IFX_ERROR("ERROR %s():%d invalid chhlt condition\n",__func__,__LINE__);
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ }
+ else if(_ifxhc->control_phase == IFXHCD_CONTROL_DATA)
+ {
+ #if 0
+ _ifxhc->epqh->do_ping=1;
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ #else
+ u32 actual_length;
+ _ifxhc->epqh->do_ping=1;
+ actual_length = _urbd->urb->actual_length + ((_ifxhc->start_pkt_count - hctsiz.b.pktcnt ) * _ifxhc->mps);
+ if(actual_length>=_urbd->xfer_len)
+ {
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ else
+ {
+ _ifxhc->xfer_count =
+ _urbd->urb->actual_length = actual_length;
+ _ifxhc->xfer_len = _urbd->xfer_len - actual_length;
+ _ifxhc->data_pid_start = read_data_toggle(_hc_regs);
+ _ifxhc->erron=1;
+ _ifxhc->epqh->do_ping=1;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ #endif
+ }
+ #endif
+ return 1;
+ }
+ else if(hcint.b.datatglerr )
+ {
+ if(_ifxhc->control_phase == IFXHCD_CONTROL_DATA)
+ {
+ _urbd->urb->actual_length += ((_ifxhc->start_pkt_count - hctsiz.b.pktcnt ) * _ifxhc->mps);
+// if( _urbd->urb->actual_length > _ifxhc->xfer_len) _urbd->urb->actual_length = _urbd->xfer_len;
+ }
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_DATA_TOGGLE_ERR);
+ return 1;
+ }
+ else if(hcint.b.frmovrun )
+ {
+ if(_ifxhc->control_phase == IFXHCD_CONTROL_DATA)
+ {
+ _urbd->urb->actual_length += ((_ifxhc->start_pkt_count - hctsiz.b.pktcnt ) * _ifxhc->mps);
+// if( _urbd->urb->actual_length > _ifxhc->xfer_len) _urbd->urb->actual_length = _urbd->xfer_len;
+ }
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_FRAME_OVERRUN);
+ return 1;
+ }
+ else
+ {
+ _urbd->error_count =0;
+ IFX_ERROR("ERROR %s():%d invalid chhlt condition %08X/%08X %d\n",__func__,__LINE__,hcint.d32,hcintmsk.d32,_ifxhc->halt_status);
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ return 1;
+ }
+ return 0;
+}
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+static int32_t chhltd_bulk_rx_nonsplit(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ hcint_data_t hcint;
+ hcint_data_t hcintmsk;
+ hctsiz_data_t hctsiz;
+
+ hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
+ hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
+ hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
+
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nak);
+ disable_hc_int(_hc_regs,nyet);
+
+ #ifdef __INNAKSTOP_BULK__
+ if(_ifxhc->halt_status == HC_XFER_NAK)
+ {
+ u32 actual_length;
+ actual_length = _urbd->urb->actual_length + (_ifxhc->xfer_len - hctsiz.b.xfersize);
+
+ if(
+ (_urbd->xfer_len && actual_length>=_urbd->xfer_len)
+ || hctsiz.b.pktcnt==0
+ || (hctsiz.b.xfersize % _ifxhc->mps)>0
+ )
+ {
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ else
+ {
+ _urbd->urb->actual_length = actual_length;
+ _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
+ _ifxhc->xfer_count = _urbd->urb->actual_length;
+ _ifxhc->data_pid_start = read_data_toggle(_hc_regs);
+ _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ return 1;
+ }
+ #endif
+
+ if (hcint.b.xfercomp || hcint.d32 == 0x02)
+ {
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ return 1;
+ }
+ else if (hcint.b.stall)
+ {
+ _urbd->error_count =0;
+ // ZLP shortcut
+ #if 0
+ if(hctsiz.b.pktcnt==0)
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ else
+ #endif
+ {
+ _urbd->urb->actual_length += (_ifxhc->xfer_len - hctsiz.b.xfersize);
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_STALL);
+ }
+ return 1;
+ }
+ else if (hcint.b.bblerr)
+ {
+ _urbd->error_count =0;
+
+ // ZLP shortcut
+ #if 0
+ if(hctsiz.b.pktcnt==0)
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ else
+ #endif
+ {
+ _urbd->urb->actual_length += (_ifxhc->xfer_len - hctsiz.b.xfersize);
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_BABBLE_ERR);
+ }
+ return 1;
+ }
+ else if (hcint.b.xacterr)
+ {
+ // ZLP shortcut
+ #if 1
+ if(hctsiz.b.pktcnt==0)
+ {
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ else
+ #endif
+ {
+ #if 0
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ #else
+ u32 actual_length;
+ actual_length = _urbd->urb->actual_length + (_ifxhc->xfer_len - hctsiz.b.xfersize);
+ if(actual_length >= _urbd->xfer_len)
+ {
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ else
+ {
+ _urbd->error_count++;
+ _ifxhc->xfer_count =
+ _urbd->urb->actual_length = actual_length;
+ _ifxhc->xfer_len = _urbd->xfer_len - actual_length;
+ _ifxhc->data_pid_start = read_data_toggle(_hc_regs);
+ if (_urbd->error_count >= 3)
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ }
+ else
+ {
+ _ifxhc->erron=1;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ }
+ #endif
+ }
+ return 1;
+ }
+ else if(hcint.b.datatglerr )
+ {
+ #if 0
+ #if 1
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ #else
+ u32 actual_length;
+ actual_length = _urbd->urb->actual_length + (_ifxhc->xfer_len - hctsiz.b.xfersize);
+ if(actual_length >= _urbd->xfer_len)
+ {
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ else
+ {
+ _urbd->urb->actual_length = actual_length;
+ _ifxhc->data_pid_start = read_data_toggle(_hc_regs);
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_DATA_TOGGLE_ERR);
+ }
+ #endif
+ #else
+ _urbd->urb->actual_length += (_ifxhc->xfer_len - hctsiz.b.xfersize);
+// if( _urbd->urb->actual_length > _ifxhc->xfer_len) _urbd->urb->actual_length = _urbd->xfer_len;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_DATA_TOGGLE_ERR);
+ #endif
+ return 1;
+ }
+ else if(hcint.b.frmovrun )
+ {
+// if( _urbd->urb->actual_length > _ifxhc->xfer_len) _urbd->urb->actual_length = _urbd->xfer_len;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_FRAME_OVERRUN);
+ return 1;
+ }
+ else
+ {
+ _urbd->error_count =0;
+ IFX_ERROR("ERROR %s():%d invalid chhlt condition %08X/%08X %d sz:%d/%d/%d/%d\n",__func__,__LINE__,hcint.d32,hcintmsk.d32,_ifxhc->halt_status , hctsiz.b.xfersize, _ifxhc->xfer_len-_ifxhc->xfer_len,_ifxhc->xfer_len,_urbd->xfer_len);
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ return 1;
+ }
+ return 0;
+}
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+static int32_t chhltd_bulk_tx_nonsplit(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ hcint_data_t hcint;
+ hcint_data_t hcintmsk;
+ hctsiz_data_t hctsiz;
+ int out_nak_enh = 0;
+
+ if (_ifxhcd->core_if.snpsid >= 0x4f54271a && _ifxhc->speed == IFXUSB_EP_SPEED_HIGH)
+ out_nak_enh = 1;
+
+ hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
+ hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
+ hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nak);
+ disable_hc_int(_hc_regs,nyet);
+
+ #ifdef __PINGSTOP_BULK__
+ if (_ifxhc->halt_status == HC_XFER_NAK)
+ {
+ u32 actual_length;
+ actual_length = _urbd->urb->actual_length + ((_ifxhc->start_pkt_count - hctsiz.b.pktcnt ) * _ifxhc->mps);
+
+ if(_urbd->xfer_len && actual_length >= _urbd->xfer_len)
+ {
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ else
+ {
+ _ifxhc->xfer_count =
+ _urbd->urb->actual_length = actual_length;
+ _ifxhc->xfer_len = _urbd->xfer_len - actual_length;
+ _ifxhc->data_pid_start = read_data_toggle(_hc_regs);
+ _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ return 1;
+ }
+ #endif
+
+ if (hcint.b.xfercomp || hcint.d32 == 0x02)
+ {
+ _urbd->error_count =0;
+ if(_ifxhc->xfer_len==0 && !hcint.b.ack && hcint.b.nak)
+ {
+ // Walkaround: When sending ZLP and receive NAK but also issue CMPT intr
+ // Solution: NoSplit: Resend at next SOF
+ // Split : Resend at next SOF with SSPLIT
+ if(hcint.b.nyet)
+ _ifxhc->epqh->do_ping=1;
+
+ _ifxhc->xfer_len = 0;
+ _ifxhc->xfer_count = 0;
+ _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ else
+ {
+ if(hcint.b.nyet)
+ _ifxhc->epqh->do_ping=1;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ return 1;
+ }
+ else if (hcint.b.stall)
+ {
+ _urbd->error_count =0;
+
+ // ZLP shortcut
+ #if 1
+ if(hctsiz.b.pktcnt==0)
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ else
+ #endif
+ {
+ _urbd->urb->actual_length += ((_ifxhc->start_pkt_count - hctsiz.b.pktcnt ) * _ifxhc->mps);
+ if(_urbd->urb->actual_length>_urbd->xfer_len) _urbd->urb->actual_length=_urbd->xfer_len;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_STALL);
+ }
+ return 1;
+ }
+ else if (hcint.b.xacterr)
+ {
+ // ZLP shortcut
+ #if 1
+ if(hctsiz.b.pktcnt==0)
+ {
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ else
+ #endif
+ {
+ #if 0
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ #else
+ u32 actual_length;
+ actual_length = _urbd->urb->actual_length + ((_ifxhc->start_pkt_count - hctsiz.b.pktcnt ) * _ifxhc->mps);
+ if(actual_length >= _urbd->xfer_len)
+ {
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ else
+ {
+ _urbd->error_count++;
+ _ifxhc->xfer_count =
+ _urbd->urb->actual_length = actual_length;
+ _ifxhc->xfer_len = _urbd->xfer_len - actual_length;
+ _ifxhc->data_pid_start = read_data_toggle(_hc_regs);
+ if (_urbd->error_count >= 3)
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ }
+ else
+ {
+ _ifxhc->erron=1;
+ _ifxhc->phase=HC_WAITING;
+ _ifxhc->epqh->do_ping=1;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ }
+ #endif
+ }
+ return 1;
+ }
+ else if(hcint.b.bblerr )
+ {
+ _urbd->urb->actual_length += ((_ifxhc->start_pkt_count - hctsiz.b.pktcnt ) * _ifxhc->mps);
+ if(_urbd->urb->actual_length>_urbd->xfer_len) _urbd->urb->actual_length=_urbd->xfer_len;
+ IFX_ERROR("ERROR %s():%d invalid packet babble\n",__func__,__LINE__);
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_BABBLE_ERR);
+ return 1;
+ }
+ else if(hcint.b.nak || hcint.b.nyet)
+ {
+ #ifdef __PINGSTOP_BULK__
+ _urbd->error_count =0;
+ IFX_ERROR("ERROR %s():%d invalid chhlt condition\n",__func__,__LINE__);
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ #else
+ // ZLP shortcut
+ #if 1
+ if(hctsiz.b.pktcnt==0)
+ {
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ else
+ #endif
+ {
+ #if 0
+ _ifxhc->epqh->do_ping=1;
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ #else
+ u32 actual_length;
+ _ifxhc->epqh->do_ping=1;
+ actual_length = _urbd->urb->actual_length + ((_ifxhc->start_pkt_count - hctsiz.b.pktcnt ) * _ifxhc->mps);
+ if(actual_length>=_urbd->xfer_len)
+ {
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ else
+ {
+ _ifxhc->xfer_count =
+ _urbd->urb->actual_length = actual_length;
+ _ifxhc->xfer_len = _urbd->xfer_len - actual_length;
+ _ifxhc->data_pid_start = read_data_toggle(_hc_regs);
+ _ifxhc->erron=1;
+ _ifxhc->epqh->do_ping=1;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ #endif
+ }
+ #endif
+ return 1;
+ }
+ else if(hcint.b.datatglerr )
+ {
+ _urbd->urb->actual_length += ((_ifxhc->start_pkt_count - hctsiz.b.pktcnt ) * _ifxhc->mps);
+// if( _urbd->urb->actual_length > _ifxhc->xfer_len) _urbd->urb->actual_length = _urbd->xfer_len;
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_DATA_TOGGLE_ERR);
+ return 1;
+ }
+ else if(hcint.b.frmovrun )
+ {
+ _urbd->urb->actual_length += ((_ifxhc->start_pkt_count - hctsiz.b.pktcnt ) * _ifxhc->mps);
+// if( _urbd->urb->actual_length > _ifxhc->xfer_len) _urbd->urb->actual_length = _urbd->xfer_len;
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_FRAME_OVERRUN);
+ return 1;
+ }
+ else
+ {
+ _urbd->error_count =0;
+ IFX_ERROR("ERROR %s():%d invalid chhlt condition %08X/%08X %d\n",__func__,__LINE__,hcint.d32,hcintmsk.d32,_ifxhc->halt_status);
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ return 1;
+ }
+ return 0;
+}
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+static int32_t chhltd_intr_rx_nonsplit(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ hcint_data_t hcint;
+ hcint_data_t hcintmsk;
+ hctsiz_data_t hctsiz;
+
+ hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
+ hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
+ hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nak);
+ disable_hc_int(_hc_regs,nyet);
+
+ if (hcint.b.xfercomp || hcint.d32 == 0x02)
+ {
+ _urbd->error_count =0;
+ //restart INTR immediately
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ return 1;
+ }
+ else if (hcint.b.stall)
+ {
+ _urbd->error_count =0;
+
+ // Don't care shortcut
+ #if 0
+ if(hctsiz.b.pktcnt==0)
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ else
+ #endif
+ {
+ _urbd->urb->actual_length += (_ifxhc->xfer_len - hctsiz.b.xfersize);
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_STALL);
+ }
+ return 1;
+ }
+ else if (hcint.b.bblerr)
+ {
+ _urbd->error_count =0;
+
+ // Don't care shortcut
+ #if 0
+ if(hctsiz.b.pktcnt==0)
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ else
+ #endif
+ {
+ _urbd->urb->actual_length += (_ifxhc->xfer_len - hctsiz.b.xfersize);
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_BABBLE_ERR);
+ }
+ return 1;
+ }
+ else if (hcint.b.datatglerr || hcint.b.frmovrun)
+ {
+ _urbd->error_count =0;
+ //restart INTR immediately
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ return 1;
+ }
+ else if (hcint.b.xacterr)
+ {
+ // ZLP shortcut
+ #if 1
+ if(hctsiz.b.pktcnt==0)
+ {
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ else
+ #endif
+ {
+ _urbd->error_count++;
+ if(_urbd->error_count>=3)
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ }
+ else
+ {
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ }
+ return 1;
+ }
+ else if(hcint.b.nyet )
+ {
+ return 1;
+ }
+ else if (hcint.b.nak)
+ {
+
+ #ifdef __INTRNAKRETRY__
+ if(hctsiz.b.pktcnt)
+ {
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_INTR_NAK_RETRY);
+ return 1;
+ }
+ #endif
+ _urbd->error_count =0;
+ //restart INTR immediately
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ return 1;
+ }
+ else
+ {
+ _urbd->error_count =0;
+ //restart INTR immediately
+ #if 0
+ if(hctsiz.b.pktcnt>0)
+ {
+ // TODO Re-initialize Channel (in next b_interval - 1 uF/F)
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ else
+ #endif
+ {
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ return 1;
+ }
+
+ return 0;
+}
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+static int32_t chhltd_intr_tx_nonsplit(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ hcint_data_t hcint;
+ hcint_data_t hcintmsk;
+ hctsiz_data_t hctsiz;
+ int out_nak_enh = 0;
+
+ if (_ifxhcd->core_if.snpsid >= 0x4f54271a && _ifxhc->speed == IFXUSB_EP_SPEED_HIGH)
+ out_nak_enh = 1;
+
+ hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
+ hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
+ hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
+
+ if (hcint.b.xfercomp || hcint.d32 == 0x02)
+ {
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nak);
+ disable_hc_int(_hc_regs,nyet);
+ _urbd->error_count =0;
+ //restart INTR immediately
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ return 1;
+ }
+ else if (hcint.b.stall)
+ {
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nyet);
+ disable_hc_int(_hc_regs,nak);
+ _urbd->error_count =0;
+
+ // Don't care shortcut
+ #if 0
+ if(hctsiz.b.pktcnt==0)
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ else
+ #endif
+ {
+ if(_ifxhc->xfer_len!=0)// !_ifxhc->is_in
+ _urbd->urb->actual_length += ((_ifxhc->start_pkt_count - hctsiz.b.pktcnt ) * _ifxhc->mps);
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_STALL);
+ }
+ return 1;
+ }
+ else if(hcint.b.nak || hcint.b.frmovrun )
+ {
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nyet);
+ disable_hc_int(_hc_regs,nak);
+ _urbd->error_count =0;
+ //restart INTR immediately
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ return 1;
+ }
+ else if(hcint.b.xacterr )
+ {
+ // ZLP shortcut
+ #if 1
+ if(hctsiz.b.pktcnt==0)
+ {
+ _urbd->error_count =0;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ else
+ #endif
+ {
+ _urbd->error_count++;
+ if(_urbd->error_count>=3)
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ }
+ else
+ {
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ }
+ return 1;
+ }
+ else if(hcint.b.bblerr )
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_BABBLE_ERR);
+ return 1;
+ }
+ else if(hcint.b.datatglerr )
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_DATA_TOGGLE_ERR);
+ return 1;
+ }
+ return 0;
+}
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+static int32_t chhltd_isoc_rx_nonsplit(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ #ifdef __EN_ISOC__
+ hcint_data_t hcint;
+ hcint_data_t hcintmsk;
+ hctsiz_data_t hctsiz;
+
+ hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
+ hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
+ hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
+
+ if (hcint.b.xfercomp || hcint.b.frmovrun || hcint.d32 == 0x02)
+ {
+ _urbd->error_count=0;
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nak);
+ disable_hc_int(_hc_regs,nyet);
+ if (hcint.b.xfercomp)
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ else
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_FRAME_OVERRUN);
+ }
+ else if (hcint.b.xacterr || hcint.b.bblerr)
+ {
+ #ifndef VR9Skip
+ if(hctsiz.b.pktcnt==0)
+ {
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ else
+ {
+ _urbd->urb->actual_length += (_ifxhc->xfer_len - hctsiz.b.xfersize);
+ _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
+ _ifxhc->xfer_count = _urbd->urb->actual_length;
+ _ifxhc->data_pid_start = read_data_toggle(_hc_regs);
+ _urbd->error_count++;
+ if(_urbd->error_count>=3)
+ {
+ _urbd->error_count=0;
+ if (hcint.b.bblerr)
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_BABBLE_ERR);
+ else if (hcint.b.xacterr)
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ }
+ else
+ {
+ enable_hc_int(_hc_regs,ack);
+ enable_hc_int(_hc_regs,nak);
+ enable_hc_int(_hc_regs,nyet);
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ }
+ #endif
+ }
+ else if(hcint.b.datatglerr )
+ {
+ return 1;
+ }
+ else if(hcint.b.stall )
+ {
+ return 1;
+ }
+ #endif
+ return 0;
+}
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+static int32_t chhltd_isoc_tx_nonsplit(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ #ifdef __EN_ISOC__
+ hcint_data_t hcint;
+ hcint_data_t hcintmsk;
+ hctsiz_data_t hctsiz;
+ int out_nak_enh = 0;
+
+ if (_ifxhcd->core_if.snpsid >= 0x4f54271a && _ifxhc->speed == IFXUSB_EP_SPEED_HIGH)
+ out_nak_enh = 1;
+
+ hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
+ hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
+ hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
+
+ if (hcint.b.xfercomp || hcint.d32 == 0x02)
+ {
+ _urbd->error_count=0;
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nak);
+ disable_hc_int(_hc_regs,nyet);
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ return 1;
+ }
+ else if (hcint.b.frmovrun)
+ {
+ #ifndef VR9Skip
+ _urbd->error_count=0;
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nak);
+ disable_hc_int(_hc_regs,nyet);
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_FRAME_OVERRUN);
+ #endif
+ }
+ else if(hcint.b.datatglerr )
+ {
+ return 1;
+ }
+ else if(hcint.b.bblerr )
+ {
+ #ifndef VR9Skip
+ if(hctsiz.b.pktcnt==0)
+ {
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ else
+ {
+ _urbd->urb->actual_length += (_ifxhc->xfer_len - hctsiz.b.xfersize);
+ _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
+ _ifxhc->xfer_count = _urbd->urb->actual_length;
+ _ifxhc->data_pid_start = read_data_toggle(_hc_regs);
+ _urbd->error_count++;
+ if(_urbd->error_count>=3)
+ {
+ _urbd->error_count=0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_BABBLE_ERR);
+ }
+ else
+ {
+ enable_hc_int(_hc_regs,ack);
+ enable_hc_int(_hc_regs,nak);
+ enable_hc_int(_hc_regs,nyet);
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ }
+ #endif
+ }
+ else if(hcint.b.xacterr )
+ {
+ if(hctsiz.b.pktcnt==0)
+ {
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ return 1;
+ }
+ _urbd->error_count++;
+ if(_urbd->error_count>=3)
+ {
+ _urbd->error_count=0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ }
+ else
+ {
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ return 1;
+ }
+ else if(hcint.b.stall )
+ {
+ return 1;
+ }
+ #endif
+ return 0;
+}
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+static int32_t chhltd_ctrl_rx_ssplit(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ hcint_data_t hcint;
+ hcint_data_t hcintmsk;
+ hctsiz_data_t hctsiz;
+
+ hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
+ hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
+ hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
+
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nak);
+ disable_hc_int(_hc_regs,nyet);
+
+ if (hcint.b.ack)
+ {
+ _urbd->error_count=0;
+ _ifxhc->split=2;
+ _ifxhc->data_pid_start = read_data_toggle(_hc_regs);
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if (hcint.b.nak)
+ {
+ _urbd->error_count = 0;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if (hcint.b.xacterr)
+ {
+ _urbd->error_count++;
+ if(_urbd->error_count>=3)
+ {
+ _urbd->error_count=0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ }
+ else
+ {
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ return 1;
+ }
+ else if(hcint.b.bblerr )
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_BABBLE_ERR);
+ return 1;
+ }
+ else if(hcint.b.stall )
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_STALL);
+ return 1;
+ }
+ else if(hcint.b.datatglerr )
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_DATA_TOGGLE_ERR);
+ return 1;
+ }
+ else if(hcint.b.frmovrun )
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_FRAME_OVERRUN);
+ return 1;
+ }
+ else if(hcint.b.nyet )
+ {
+ }
+ else if(hcint.b.xfercomp )
+ {
+ }
+ return 0;
+}
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+static int32_t chhltd_ctrl_tx_ssplit(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ hcint_data_t hcint;
+ hcint_data_t hcintmsk;
+ hctsiz_data_t hctsiz;
+ int out_nak_enh = 0;
+
+ if (_ifxhcd->core_if.snpsid >= 0x4f54271a && _ifxhc->speed == IFXUSB_EP_SPEED_HIGH)
+ out_nak_enh = 1;
+
+ hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
+ hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
+ hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nak);
+ disable_hc_int(_hc_regs,nyet);
+
+ if (hcint.b.ack )
+ {
+ _urbd->error_count=0;
+ if (_ifxhc->control_phase != IFXHCD_CONTROL_SETUP)
+ _ifxhc->ssplit_out_xfer_count = _ifxhc->xfer_len;
+ _ifxhc->split=2;
+ _ifxhc->data_pid_start =read_data_toggle(_hc_regs);
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.nyet)
+ {
+ _urbd->error_count=0;
+ if (_ifxhc->control_phase != IFXHCD_CONTROL_SETUP)
+ _ifxhc->ssplit_out_xfer_count = _ifxhc->xfer_len;
+ _ifxhc->split=2;
+ _ifxhc->data_pid_start =read_data_toggle(_hc_regs);
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.nak )
+ {
+ _urbd->error_count =0;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.xacterr )
+ {
+ _urbd->error_count++;
+ if(_urbd->error_count>=3)
+ {
+ _urbd->error_count=0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ }
+ else
+ {
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ return 1;
+ }
+ else if(hcint.b.datatglerr )
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_DATA_TOGGLE_ERR);
+ return 1;
+ }
+ else if(hcint.b.bblerr )
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_BABBLE_ERR);
+ return 1;
+ }
+ else if(hcint.b.stall )
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_STALL);
+ return 1;
+ }
+ else if(hcint.b.frmovrun )
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_FRAME_OVERRUN);
+ return 1;
+ }
+ else if(hcint.b.xfercomp )
+ {
+ printk(KERN_INFO "Warning: %s() %d CTRL OUT SPLIT1 COMPLETE\n",__func__,__LINE__);
+ }
+ return 0;
+}
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+static int32_t chhltd_bulk_rx_ssplit(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ hcint_data_t hcint;
+ hcint_data_t hcintmsk;
+ hctsiz_data_t hctsiz;
+
+ hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
+ hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
+ hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
+
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nak);
+ disable_hc_int(_hc_regs,nyet);
+
+ if (hcint.b.ack)
+ {
+ _urbd->error_count=0;
+ _ifxhc->split=2;
+ _ifxhc->data_pid_start = read_data_toggle(_hc_regs);
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if (hcint.b.nak)
+ {
+ _urbd->error_count = 0;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if (hcint.b.xacterr)
+ {
+ _urbd->error_count++;
+ if(_urbd->error_count>=3)
+ {
+ _urbd->error_count=0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ }
+ else
+ {
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ return 1;
+ }
+ else if(hcint.b.bblerr )
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_BABBLE_ERR);
+ return 1;
+ }
+ else if(hcint.b.stall )
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_STALL);
+ return 1;
+ }
+ else if(hcint.b.datatglerr )
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_DATA_TOGGLE_ERR);
+ return 1;
+ }
+ else if(hcint.b.frmovrun )
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_FRAME_OVERRUN);
+ return 1;
+ }
+ else if(hcint.b.nyet )
+ {
+ }
+ else if(hcint.b.xfercomp )
+ {
+ }
+ return 0;
+}
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+static int32_t chhltd_bulk_tx_ssplit(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ hcint_data_t hcint;
+ hcint_data_t hcintmsk;
+ hctsiz_data_t hctsiz;
+ int out_nak_enh = 0;
+
+ if (_ifxhcd->core_if.snpsid >= 0x4f54271a && _ifxhc->speed == IFXUSB_EP_SPEED_HIGH)
+ out_nak_enh = 1;
+
+ hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
+ hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
+ hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nak);
+ disable_hc_int(_hc_regs,nyet);
+
+ if (hcint.b.ack )
+ {
+ _urbd->error_count=0;
+ _ifxhc->ssplit_out_xfer_count = _ifxhc->xfer_len;
+ _ifxhc->split=2;
+ _ifxhc->data_pid_start =read_data_toggle(_hc_regs);
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.nyet)
+ {
+ _urbd->error_count=0;
+ _ifxhc->ssplit_out_xfer_count = _ifxhc->xfer_len;
+ _ifxhc->split=2;
+ _ifxhc->data_pid_start =read_data_toggle(_hc_regs);
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.nak )
+ {
+ _urbd->error_count =0;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.xacterr )
+ {
+ _urbd->error_count++;
+ if(_urbd->error_count>=3)
+ {
+ _urbd->error_count=0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ }
+ else
+ {
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ return 1;
+ }
+ else if(hcint.b.datatglerr )
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_DATA_TOGGLE_ERR);
+ return 1;
+ }
+ else if(hcint.b.bblerr )
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_BABBLE_ERR);
+ return 1;
+ }
+ else if(hcint.b.stall )
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_STALL);
+ return 1;
+ }
+ else if(hcint.b.frmovrun )
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_FRAME_OVERRUN);
+ return 1;
+ }
+ else if(hcint.b.xfercomp )
+ {
+ printk(KERN_INFO "Warning: %s() %d BULK OUT SPLIT1 COMPLETE\n",__func__,__LINE__);
+ }
+ return 0;
+}
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+static int32_t chhltd_intr_rx_ssplit(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ hcint_data_t hcint;
+ hcint_data_t hcintmsk;
+ hctsiz_data_t hctsiz;
+
+ hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
+ hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
+ hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
+
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nak);
+ disable_hc_int(_hc_regs,nyet);
+
+ if (hcint.b.ack)
+ {
+ _urbd->error_count=0;
+ _ifxhc->split=2;
+ _ifxhc->data_pid_start = read_data_toggle(_hc_regs);
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.nak)
+ {
+ _urbd->error_count=0;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.xacterr)
+ {
+ hcchar_data_t hcchar;
+ hcchar.d32 = ifxusb_rreg(&_hc_regs->hcchar);
+ _urbd->error_count=hcchar.b.multicnt;
+ if(_urbd->error_count>=3)
+ {
+ _urbd->error_count=0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ }
+ else
+ {
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ return 1;
+ }
+ else if(hcint.b.stall )
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_STALL);
+ return 1;
+ }
+ else if(hcint.b.bblerr )
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_BABBLE_ERR);
+ return 1;
+ }
+ else if(hcint.b.frmovrun )
+ {
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.datatglerr )
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_DATA_TOGGLE_ERR);
+ return 1;
+ }
+ else if(hcint.b.xfercomp )
+ {
+ }
+ return 0;
+}
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+static int32_t chhltd_intr_tx_ssplit(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ hcint_data_t hcint;
+ hcint_data_t hcintmsk;
+ hctsiz_data_t hctsiz;
+ int out_nak_enh = 0;
+
+ if (_ifxhcd->core_if.snpsid >= 0x4f54271a && _ifxhc->speed == IFXUSB_EP_SPEED_HIGH)
+ out_nak_enh = 1;
+
+ hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
+ hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
+ hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
+
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nak);
+ disable_hc_int(_hc_regs,nyet);
+
+ if (hcint.b.ack )
+ {
+ _urbd->error_count=0;
+ _ifxhc->ssplit_out_xfer_count = _ifxhc->xfer_len;
+ _ifxhc->split=2;
+ _ifxhc->data_pid_start = read_data_toggle(_hc_regs);
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.nyet)
+ {
+ _urbd->error_count=0;
+ _ifxhc->ssplit_out_xfer_count = _ifxhc->xfer_len;
+ _ifxhc->split=2;
+ _ifxhc->data_pid_start = read_data_toggle(_hc_regs);
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.nak )
+ {
+ _urbd->error_count =0;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.frmovrun )
+ {
+ _urbd->error_count =0;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.xacterr )
+ {
+ hcchar_data_t hcchar;
+ hcchar.d32 = ifxusb_rreg(&_hc_regs->hcchar);
+ _urbd->error_count=hcchar.b.multicnt;
+ if(_urbd->error_count>=3)
+ {
+ _urbd->error_count=0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ }
+ else
+ {
+ enable_hc_int(_hc_regs,ack);
+ enable_hc_int(_hc_regs,nak);
+ enable_hc_int(_hc_regs,nyet);
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ return 1;
+ }
+ else if(hcint.b.datatglerr )
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_DATA_TOGGLE_ERR);
+ return 1;
+ }
+ else if(hcint.b.bblerr )
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_BABBLE_ERR);
+ return 1;
+ }
+ else if(hcint.b.stall )
+ {
+ _urbd->error_count =0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_STALL);
+ return 1;
+ }
+ else if(hcint.b.xfercomp )
+ {
+ }
+ return 0;
+}
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+static int32_t chhltd_isoc_rx_ssplit(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ #if defined(__EN_ISOC__) && defined(__EN_ISOC_SPLIT__)
+ hcint_data_t hcint;
+ hcint_data_t hcintmsk;
+ hctsiz_data_t hctsiz;
+
+ hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
+ hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
+ hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
+ if (hcint.b.ack )
+ {
+ Do Complete Split
+ }
+ else if(hcint.b.frmovrun )
+ {
+ Rewind Buffer Pointers
+ Retry Start Split (in next b_interval ¡V 1 uF)
+ }
+ else if(hcint.b.datatglerr )
+ {
+ //warning
+ }
+ else if(hcint.b.bblerr )
+ {
+ //warning
+ }
+ else if(hcint.b.xacterr )
+ {
+ //warning
+ }
+ else if(hcint.b.stall )
+ {
+ //warning
+ }
+ else if(hcint.b.nak )
+ {
+ //warning
+ }
+ else if(hcint.b.xfercomp )
+ {
+ //warning
+ }
+ else if(hcint.b.nyet)
+ {
+ //warning
+ }
+ #endif
+ return 0;
+}
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+static int32_t chhltd_isoc_tx_ssplit(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ #if defined(__EN_ISOC__) && defined(__EN_ISOC_SPLIT__)
+ hcint_data_t hcint;
+ hcint_data_t hcintmsk;
+ hctsiz_data_t hctsiz;
+ int out_nak_enh = 0;
+
+ if (_ifxhcd->core_if.snpsid >= 0x4f54271a && _ifxhc->speed == IFXUSB_EP_SPEED_HIGH)
+ out_nak_enh = 1;
+
+ hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
+ hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
+ hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
+ if (hcint.b.ack )
+ {
+ //Do Next Start Split (in next b_interval ¡V 1 uF)
+ }
+ else if(hcint.b.frmovrun )
+ {
+ //Do Next Transaction in next frame.
+ }
+ else if(hcint.b.datatglerr )
+ {
+ //warning
+ }
+ else if(hcint.b.bblerr )
+ {
+ //warning
+ }
+ else if(hcint.b.xacterr )
+ {
+ //warning
+ }
+ else if(hcint.b.stall )
+ {
+ //warning
+ }
+ else if(hcint.b.nak )
+ {
+ //warning
+ }
+ else if(hcint.b.xfercomp )
+ {
+ //warning
+ }
+ else if(hcint.b.nyet)
+ {
+ //warning
+ }
+ #endif
+ return 0;
+}
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+static int32_t chhltd_ctrl_rx_csplit(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ hcint_data_t hcint;
+ hcint_data_t hcintmsk;
+ hctsiz_data_t hctsiz;
+
+ hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
+ hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
+ hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nak);
+ disable_hc_int(_hc_regs,nyet);
+
+ if (hcint.b.xfercomp)
+ {
+ _urbd->error_count =0;
+ _ifxhc->split=1;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ return 1;
+ }
+ else if (hcint.b.nak)
+ {
+ _ifxhc->split = 1;
+ if(_ifxhc->control_phase == IFXHCD_CONTROL_DATA)
+ {
+ _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
+ _ifxhc->xfer_count = _urbd->urb->actual_length;
+ }
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.nyet)
+ {
+ _urbd->error_count=0;
+ _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.stall || hcint.b.bblerr )
+ {
+ _urbd->error_count=0;
+ if (hcint.b.stall)
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_STALL);
+ else if(hcint.b.bblerr )
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_BABBLE_ERR);
+ return 1;
+ }
+ else if(hcint.b.xacterr )
+ {
+ _urbd->error_count++;
+ if(_urbd->error_count>=3)
+ {
+ _urbd->error_count=0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ }
+ else
+ {
+ _ifxhc->split=1;
+ if(_ifxhc->control_phase == IFXHCD_CONTROL_DATA)
+ {
+ _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
+ _ifxhc->xfer_count = _urbd->urb->actual_length;
+ }
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ return 1;
+ }
+ else if(hcint.b.datatglerr )
+ {
+ if(_ifxhc->data_pid_start == IFXUSB_HC_PID_DATA0)
+ _ifxhc->data_pid_start = IFXUSB_HC_PID_DATA1;
+ else
+ _ifxhc->data_pid_start = IFXUSB_HC_PID_DATA0;
+ _ifxhc->split=1;
+ if(_ifxhc->control_phase == IFXHCD_CONTROL_DATA)
+ {
+ _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
+ _ifxhc->xfer_count = _urbd->urb->actual_length;
+ }
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.frmovrun )
+ {
+ _urbd->error_count=0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_FRAME_OVERRUN);
+ return 1;
+ }
+ return 0;
+}
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+static int32_t chhltd_ctrl_tx_csplit(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ hcint_data_t hcint;
+ hcint_data_t hcintmsk;
+ hctsiz_data_t hctsiz;
+ int out_nak_enh = 0;
+
+ if (_ifxhcd->core_if.snpsid >= 0x4f54271a && _ifxhc->speed == IFXUSB_EP_SPEED_HIGH)
+ out_nak_enh = 1;
+
+ hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
+ hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
+ hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nak);
+ disable_hc_int(_hc_regs,nyet);
+
+ if(hcint.b.xfercomp )
+ {
+ _urbd->error_count=0;
+ _ifxhc->split=1;
+ #if 0
+ if(_ifxhc->xfer_len==0 && !hcint.b.ack && (hcint.b.nak || hcint.b.nyet))
+ {
+ // Walkaround: When sending ZLP and receive NYEY or NAK but also issue CMPT intr
+ // Solution: NoSplit: Resend at next SOF
+ // Split : Resend at next SOF with SSPLIT
+ _ifxhc->xfer_len = 0;
+ _ifxhc->xfer_count = 0;
+ _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ else
+ #endif
+ {
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ return 1;
+ }
+ else if(hcint.b.nak )
+ {
+ _ifxhc->split = 1;
+ if(_ifxhc->control_phase == IFXHCD_CONTROL_DATA)
+ {
+ _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
+ _ifxhc->xfer_count = _urbd->urb->actual_length;
+ }
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.nyet)
+ {
+ //Retry Complete Split
+ // Issue Retry instantly on next SOF, without gothrough process_channels
+ _urbd->error_count=0;
+ _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.stall )
+ {
+ _urbd->error_count=0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_STALL);
+ return 1;
+ }
+ else if(hcint.b.xacterr )
+ {
+ _urbd->error_count++;
+ if(_urbd->error_count>=3)
+ {
+ _urbd->error_count=0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ }
+ else
+ {
+ _ifxhc->split=1;
+ if(_ifxhc->control_phase == IFXHCD_CONTROL_DATA)
+ {
+ _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
+ _ifxhc->xfer_count = _urbd->urb->actual_length;
+ }
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ return 1;
+ }
+ else if(hcint.b.datatglerr )
+ {
+ if(_ifxhc->data_pid_start == IFXUSB_HC_PID_DATA0)
+ _ifxhc->data_pid_start = IFXUSB_HC_PID_DATA1;
+ else
+ _ifxhc->data_pid_start = IFXUSB_HC_PID_DATA0;
+ _ifxhc->split=1;
+ if(_ifxhc->control_phase == IFXHCD_CONTROL_DATA)
+ {
+ _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
+ _ifxhc->xfer_count = _urbd->urb->actual_length;
+ }
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.frmovrun )
+ {
+ _urbd->error_count=0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_FRAME_OVERRUN);
+ return 1;
+ }
+ else if(hcint.b.bblerr )
+ {
+ _urbd->error_count=0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_BABBLE_ERR);
+ return 1;
+ }
+ return 0;
+}
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+static int32_t chhltd_bulk_rx_csplit(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ hcint_data_t hcint;
+ hcint_data_t hcintmsk;
+ hctsiz_data_t hctsiz;
+
+ hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
+ hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
+ hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nak);
+ disable_hc_int(_hc_regs,nyet);
+
+ if (hcint.b.xfercomp)
+ {
+ _urbd->error_count =0;
+ _ifxhc->split=1;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ return 1;
+ }
+ else if (hcint.b.nak)
+ {
+ _ifxhc->split = 1;
+ _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
+ _ifxhc->xfer_count = _urbd->urb->actual_length;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.nyet)
+ {
+ _urbd->error_count=0;
+ _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.stall || hcint.b.bblerr )
+ {
+ _urbd->error_count=0;
+ if (hcint.b.stall)
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_STALL);
+ else if(hcint.b.bblerr )
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_BABBLE_ERR);
+ return 1;
+ }
+ else if(hcint.b.xacterr )
+ {
+ _urbd->error_count++;
+ if(_urbd->error_count>=3)
+ {
+ _urbd->error_count=0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ }
+ else
+ {
+ _ifxhc->split=1;
+ _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
+ _ifxhc->xfer_count = _urbd->urb->actual_length;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ return 1;
+ }
+ else if(hcint.b.datatglerr )
+ {
+ if(_ifxhc->data_pid_start == IFXUSB_HC_PID_DATA0)
+ _ifxhc->data_pid_start = IFXUSB_HC_PID_DATA1;
+ else
+ _ifxhc->data_pid_start = IFXUSB_HC_PID_DATA0;
+ _ifxhc->split=1;
+ _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
+ _ifxhc->xfer_count = _urbd->urb->actual_length;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.frmovrun )
+ {
+ _urbd->error_count=0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_FRAME_OVERRUN);
+ return 1;
+ }
+ return 0;
+}
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+static int32_t chhltd_bulk_tx_csplit(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ hcint_data_t hcint;
+ hcint_data_t hcintmsk;
+ hctsiz_data_t hctsiz;
+ int out_nak_enh = 0;
+
+ if (_ifxhcd->core_if.snpsid >= 0x4f54271a && _ifxhc->speed == IFXUSB_EP_SPEED_HIGH)
+ out_nak_enh = 1;
+
+ hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
+ hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
+ hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nak);
+ disable_hc_int(_hc_regs,nyet);
+
+ if(hcint.b.xfercomp )
+ {
+ _urbd->error_count=0;
+ _ifxhc->split=1;
+ #if 0
+ if(_ifxhc->xfer_len==0 && !hcint.b.ack && (hcint.b.nak || hcint.b.nyet))
+ {
+ // Walkaround: When sending ZLP and receive NYEY or NAK but also issue CMPT intr
+ // Solution: NoSplit: Resend at next SOF
+ // Split : Resend at next SOF with SSPLIT
+ _ifxhc->xfer_len = 0;
+ _ifxhc->xfer_count = 0;
+ _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ else
+ #endif
+ {
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ }
+ return 1;
+ }
+ else if(hcint.b.nak )
+ {
+ _ifxhc->split = 1;
+ _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
+ _ifxhc->xfer_count = _urbd->urb->actual_length;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.nyet)
+ {
+ //Retry Complete Split
+ // Issue Retry instantly on next SOF, without gothrough process_channels
+ _urbd->error_count=0;
+ _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.stall )
+ {
+ _urbd->error_count=0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_STALL);
+ return 1;
+ }
+ else if(hcint.b.xacterr )
+ {
+ _urbd->error_count++;
+ if(_urbd->error_count>=3)
+ {
+ _urbd->error_count=0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ }
+ else
+ {
+ _ifxhc->split=1;
+ _ifxhc->epqh->do_ping=1;
+ _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
+ _ifxhc->xfer_count = _urbd->urb->actual_length;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ return 1;
+ }
+ else if(hcint.b.datatglerr )
+ {
+ if(_ifxhc->data_pid_start == IFXUSB_HC_PID_DATA0)
+ _ifxhc->data_pid_start = IFXUSB_HC_PID_DATA1;
+ else
+ _ifxhc->data_pid_start = IFXUSB_HC_PID_DATA0;
+ _ifxhc->split=1;
+ _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
+ _ifxhc->xfer_count = _urbd->urb->actual_length;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.frmovrun )
+ {
+ _urbd->error_count=0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_FRAME_OVERRUN);
+ return 1;
+ }
+ else if(hcint.b.bblerr )
+ {
+ _urbd->error_count=0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_BABBLE_ERR);
+ return 1;
+ }
+ return 0;
+}
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+static int32_t chhltd_intr_rx_csplit(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ hcint_data_t hcint;
+ hcint_data_t hcintmsk;
+ hctsiz_data_t hctsiz;
+
+ hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
+ hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
+ hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nak);
+ disable_hc_int(_hc_regs,nyet);
+
+ if (hcint.b.xfercomp )
+ {
+ _urbd->error_count=0;
+ _ifxhc->split=1;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ return 1;
+ }
+ else if(hcint.b.nak )
+ {
+ _ifxhc->split = 1;
+ _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
+ _ifxhc->xfer_count = _urbd->urb->actual_length;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.nyet)
+ {
+ _urbd->error_count=0;
+ _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.frmovrun || hcint.b.bblerr || hcint.b.stall )
+ {
+ _urbd->error_count=0;
+ if (hcint.b.stall)
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_STALL);
+ else if(hcint.b.bblerr )
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_BABBLE_ERR);
+ else if(hcint.b.frmovrun )
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_FRAME_OVERRUN);
+ return 1;
+ }
+ else if(hcint.b.xacterr )
+ {
+ hcchar_data_t hcchar;
+ hcchar.d32 = ifxusb_rreg(&_hc_regs->hcchar);
+ _urbd->error_count=hcchar.b.multicnt;
+ if(_urbd->error_count>=3)
+ {
+ _urbd->error_count=0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ }
+ else
+ {
+ _ifxhc->split=1;
+ _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
+ _ifxhc->xfer_count = _urbd->urb->actual_length;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ return 1;
+ }
+ else if(hcint.b.datatglerr )
+ {
+ if(_ifxhc->data_pid_start == IFXUSB_HC_PID_DATA0)
+ _ifxhc->data_pid_start = IFXUSB_HC_PID_DATA1;
+ else
+ _ifxhc->data_pid_start = IFXUSB_HC_PID_DATA0;
+ _ifxhc->split=1;
+ _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
+ _ifxhc->xfer_count = _urbd->urb->actual_length;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ return 0;
+}
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+static int32_t chhltd_intr_tx_csplit(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ hcint_data_t hcint;
+ hcint_data_t hcintmsk;
+ hctsiz_data_t hctsiz;
+ int out_nak_enh = 0;
+
+ if (_ifxhcd->core_if.snpsid >= 0x4f54271a && _ifxhc->speed == IFXUSB_EP_SPEED_HIGH)
+ out_nak_enh = 1;
+
+ hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
+ hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
+ hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nak);
+ disable_hc_int(_hc_regs,nyet);
+
+ if(hcint.b.xfercomp )
+ {
+ _urbd->error_count=0;
+ _ifxhc->split=1;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ return 1;
+ }
+ else if(hcint.b.nak )
+ {
+ _ifxhc->split = 1;
+ _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
+ _ifxhc->xfer_count = _urbd->urb->actual_length;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.nyet)
+ {
+ _urbd->error_count=0;
+ _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.stall || hcint.b.frmovrun)
+ {
+ _urbd->error_count=0;
+ if (hcint.b.stall)
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_STALL);
+ else if(hcint.b.frmovrun )
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_FRAME_OVERRUN);
+ return 1;
+ }
+ else if(hcint.b.xacterr )
+ {
+ hcchar_data_t hcchar;
+ hcchar.d32 = ifxusb_rreg(&_hc_regs->hcchar);
+ _urbd->error_count=hcchar.b.multicnt;
+ if(_urbd->error_count>=3)
+ {
+ _urbd->error_count=0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_XACT_ERR);
+ }
+ else
+ {
+ _ifxhc->split=1;
+ _ifxhc->epqh->do_ping=1;
+ _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
+ _ifxhc->xfer_count = _urbd->urb->actual_length;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ }
+ return 1;
+ }
+ else if(hcint.b.datatglerr )
+ {
+ if(_ifxhc->data_pid_start == IFXUSB_HC_PID_DATA0)
+ _ifxhc->data_pid_start = IFXUSB_HC_PID_DATA1;
+ else
+ _ifxhc->data_pid_start = IFXUSB_HC_PID_DATA0;
+ _ifxhc->split=1;
+ _ifxhc->epqh->do_ping=1;
+ _ifxhc->xfer_len = _urbd->xfer_len - _urbd->urb->actual_length;
+ _ifxhc->xfer_count = _urbd->urb->actual_length;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.bblerr )
+ {
+ _urbd->error_count=0;
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_BABBLE_ERR);
+ return 1;
+ }
+ return 0;
+}
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+static int32_t chhltd_isoc_rx_csplit(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ #if defined(__EN_ISOC__) && defined(__EN_ISOC_SPLIT__)
+ hcint_data_t hcint;
+ hcint_data_t hcintmsk;
+ hctsiz_data_t hctsiz;
+
+ hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
+ hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
+ hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
+ if(hcint.b.xfercomp )
+ {
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nak);
+ disable_hc_int(_hc_regs,nyet);
+ _urbd->error_count=0;
+ _ifxhc->split=1;
+ complete_channel(_ifxhcd, _ifxhc, _urbd);
+ return 1;
+ }
+ else if(hcint.b.nak )
+ {
+ Retry Start Split (in next b_interval ¡V 1 uF)
+ }
+ else if(hcint.b.nyet)
+ {
+ //Do Next Complete Split
+ // Issue Retry instantly on next SOF, without gothrough process_channels
+ _urbd->error_count=0;
+ //disable_hc_int(_hc_regs,ack);
+ //disable_hc_int(_hc_regs,nak);
+ //disable_hc_int(_hc_regs,datatglerr);
+ _ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
+ _ifxhc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, _ifxhc);
+ return 1;
+ }
+ else if(hcint.b.frmovrun || hcint.b.stall || hcint.b.bblerr)
+ {
+ _urbd->error_count=0;
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nyet);
+ disable_hc_int(_hc_regs,nak);
+ _ifxhc->wait_for_sof = 0;
+
+ //if(hctsiz.b.pktcnt==0)
+ //{
+ // complete_channel(_ifxhcd, _ifxhc, _urbd);
+ // return 1;
+ //}
+ //else
+ // _urbd->urb->actual_length += (_ifxhc->xfer_len - hctsiz.b.xfersize);
+ if (hcint.b.stall)
+ release_channel(_ifxhcd, _ifxhc, HC_XFER_STALL);
+ else if(hcint.b.frmovrun )
+ else if(hcint.b.bblerr )
+ return 1;
+ }
+ else if(hcint.b.xacterr )
+ {
+ Rewind Buffer Pointers
+ if (HCCHARn.EC = = 3) // ERR response received
+ {
+ Record ERR error
+ Do Next Start Split (in next frame)
+ }
+ else
+ {
+ De-allocate Channel
+ }
+ }
+ else if(hcint.b.datatglerr )
+ {
+ warning
+ }
+ else if(hcint.b.ack )
+ {
+ warning
+ }
+ #endif
+ return 0;
+}
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+static int32_t chhltd_isoc_tx_csplit(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ #if defined(__EN_ISOC__) && defined(__EN_ISOC_SPLIT__)
+ hcint_data_t hcint;
+ hcint_data_t hcintmsk;
+ hctsiz_data_t hctsiz;
+ int out_nak_enh = 0;
+
+ if (_ifxhcd->core_if.snpsid >= 0x4f54271a && _ifxhc->speed == IFXUSB_EP_SPEED_HIGH)
+ out_nak_enh = 1;
+
+ hcint.d32 = ifxusb_rreg(&_hc_regs->hcint);
+ hcintmsk.d32 = ifxusb_rreg(&_hc_regs->hcintmsk);
+ hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
+ warning
+ #endif
+ return 0;
+}
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+/*!
+ \fn static int32_t handle_hc_chhltd_intr(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+ \brief This function handles halted interrupts of host channels.
+ \param _ifxhcd Pointer to the sate of HCD structure
+ \param _ifxhc Pointer to host channel descriptor
+ \param _hc_regs Pointer to host channel registers
+ \param _urbd Pointer to URB descriptor
+ \return 0 OK
+ \ingroup IFXUSB_HCD
+ */
+static
+int32_t handle_hc_chhltd_intr(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ IFX_DEBUGPL(DBG_HCD, "--Host Channel %d Interrupt: Channel Halted--\n", _ifxhc->hc_num);
+
+ _ifxhc->phase = HC_STOPPED;
+ if(_ifxhc->epqh)
+ if(_ifxhc->epqh->urbd)
+ _ifxhc->epqh->urbd->phase=URBD_ACTIVE;
+
+ if (_ifxhc->halt_status == HC_XFER_URB_DEQUEUE ||
+ _ifxhc->halt_status == HC_XFER_AHB_ERR) {
+ /*
+ * Just release the channel. A dequeue can happen on a
+ * transfer timeout. In the case of an AHB Error, the channel
+ * was forced to halt because there's no way to gracefully
+ * recover.
+ */
+ if(_ifxhc->epqh)
+ if(_ifxhc->epqh->urbd)
+ _ifxhc->epqh->urbd->phase=URBD_DEQUEUEING;
+ release_channel(_ifxhcd, _ifxhc, _ifxhc->halt_status);
+ return 1;
+ }
+
+ if (_ifxhc->ep_type == IFXUSB_EP_TYPE_CTRL)
+ {
+ if (_ifxhc->split==0)
+ {
+ if(_ifxhc->is_in)
+ return (chhltd_ctrl_rx_nonsplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
+ else
+ return (chhltd_ctrl_tx_nonsplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
+ }
+ else if(_ifxhc->split==1)
+ {
+ if(_ifxhc->is_in)
+ return (chhltd_ctrl_rx_ssplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
+ else
+ return (chhltd_ctrl_tx_ssplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
+ }
+ else if(_ifxhc->split==2)
+ {
+ if(_ifxhc->is_in)
+ return (chhltd_ctrl_rx_csplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
+ else
+ return (chhltd_ctrl_tx_csplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
+ }
+ }
+ else if(_ifxhc->ep_type == IFXUSB_EP_TYPE_BULK)
+ {
+ if (_ifxhc->split==0)
+ {
+ if(_ifxhc->is_in)
+ return (chhltd_bulk_rx_nonsplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
+ else
+ return (chhltd_bulk_tx_nonsplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
+ }
+ else if(_ifxhc->split==1)
+ {
+ if(_ifxhc->is_in)
+ return (chhltd_bulk_rx_ssplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
+ else
+ return (chhltd_bulk_tx_ssplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
+ }
+ else if(_ifxhc->split==2)
+ {
+ if(_ifxhc->is_in)
+ return (chhltd_bulk_rx_csplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
+ else
+ return (chhltd_bulk_tx_csplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
+ }
+ }
+ else if(_ifxhc->ep_type == IFXUSB_EP_TYPE_INTR)
+ {
+ if (_ifxhc->split==0)
+ {
+ if(_ifxhc->is_in)
+ return (chhltd_intr_rx_nonsplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
+ else
+ return (chhltd_intr_tx_nonsplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
+ }
+ else if(_ifxhc->split==1)
+ {
+ if(_ifxhc->is_in)
+ return (chhltd_intr_rx_ssplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
+ else
+ return (chhltd_intr_tx_ssplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
+ }
+ else if(_ifxhc->split==2)
+ {
+ if(_ifxhc->is_in)
+ return (chhltd_intr_rx_csplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
+ else
+ return (chhltd_intr_tx_csplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
+ }
+ }
+ else if(_ifxhc->ep_type == IFXUSB_EP_TYPE_ISOC)
+ {
+ if (_ifxhc->split==0)
+ {
+ if(_ifxhc->is_in)
+ return (chhltd_isoc_rx_nonsplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
+ else
+ return (chhltd_isoc_tx_nonsplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
+ }
+ else if(_ifxhc->split==1)
+ {
+ if(_ifxhc->is_in)
+ return (chhltd_isoc_rx_ssplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
+ else
+ return (chhltd_isoc_tx_ssplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
+ }
+ else if(_ifxhc->split==2)
+ {
+ if(_ifxhc->is_in)
+ return (chhltd_isoc_rx_csplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
+ else
+ return (chhltd_isoc_tx_csplit(_ifxhcd,_ifxhc,_hc_regs,_urbd));
+ }
+ }
+ return 0;
+}
+
+/*
+ * Handles a host channel AHB error interrupt. This handler is only called in
+ * DMA mode.
+ */
+static void hc_other_intr_dump(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ #ifdef __DEBUG__
+ hcchar_data_t hcchar;
+ hcsplt_data_t hcsplt;
+ hctsiz_data_t hctsiz;
+ uint32_t hcdma;
+ struct urb *urb = _urbd->urb;
+ hcchar.d32 = ifxusb_rreg(&_hc_regs->hcchar);
+ hcsplt.d32 = ifxusb_rreg(&_hc_regs->hcsplt);
+ hctsiz.d32 = ifxusb_rreg(&_hc_regs->hctsiz);
+ hcdma = ifxusb_rreg(&_hc_regs->hcdma);
+
+ IFX_ERROR("Channel %d\n", _ifxhc->hc_num);
+ IFX_ERROR(" hcchar 0x%08x, hcsplt 0x%08x\n", hcchar.d32, hcsplt.d32);
+ IFX_ERROR(" hctsiz 0x%08x, hcdma 0x%08x\n", hctsiz.d32, hcdma);
+ IFX_ERROR(" Device address: %d\n", usb_pipedevice(urb->pipe));
+ IFX_ERROR(" Endpoint: %d, %s\n", usb_pipeendpoint(urb->pipe),
+ (usb_pipein(urb->pipe) ? "IN" : "OUT"));
+ IFX_ERROR(" Endpoint type: %s\n",
+ ({char *pipetype;
+ switch (usb_pipetype(urb->pipe)) {
+ case PIPE_CONTROL: pipetype = "CTRL"; break;
+ case PIPE_BULK: pipetype = "BULK"; break;
+ case PIPE_INTERRUPT: pipetype = "INTR"; break;
+ case PIPE_ISOCHRONOUS: pipetype = "ISOC"; break;
+ default: pipetype = "????"; break;
+ }; pipetype;}));
+ IFX_ERROR(" Speed: %s\n",
+ ({char *speed;
+ switch (urb->dev->speed) {
+ case USB_SPEED_HIGH: speed = "HS"; break;
+ case USB_SPEED_FULL: speed = "FS"; break;
+ case USB_SPEED_LOW: speed = "LS"; break;
+ default: speed = "????"; break;
+ }; speed;}));
+ IFX_ERROR(" Max packet size: %d\n",
+ usb_maxpacket(urb->dev, urb->pipe, usb_pipeout(urb->pipe)));
+ IFX_ERROR(" Data buffer length: %d\n", urb->transfer_buffer_length);
+ IFX_ERROR(" Transfer buffer: %p, Transfer DMA: %p\n",
+ urb->transfer_buffer, (void *)urb->transfer_dma);
+ IFX_ERROR(" Setup buffer: %p, Setup DMA: %p\n",
+ urb->setup_packet, (void *)urb->setup_dma);
+ IFX_ERROR(" Interval: %d\n", urb->interval);
+ #endif //__DEBUG__
+}
+
+/*
+ * Handles a host channel ACK interrupt. This interrupt is enabled when
+ * errors occur, and during Start Split transactions.
+ */
+static
+int32_t handle_hc_ack_intr(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ _urbd->error_count=0;
+ _ifxhc->erron = 0;
+
+ disable_hc_int(_hc_regs,nyet);
+
+ #ifdef __NAKSTOP__
+ if(!_ifxhc->stop_on)
+ {
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nak);
+ }
+ #else
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nak);
+ #endif
+ return 1;
+}
+
+/*
+ * Handles a host channel ACK interrupt. This interrupt is enabled when
+ * errors occur, and during Start Split transactions.
+ */
+static
+int32_t handle_hc_nak_intr(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ _urbd->error_count=0;
+ _ifxhc->erron=0;
+ disable_hc_int(_hc_regs,nyet);
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nak);
+ #ifdef __NAKSTOP__
+ if(_ifxhc->stop_on)
+ {
+ hcchar_data_t hcchar;
+ hcchar.d32 = ifxusb_rreg(&_hc_regs->hcchar);
+ if(hcchar.b.chen)
+ {
+ hcchar.b.chdis = 1;
+ _ifxhc->halt_status = HC_XFER_NAK;
+ ifxusb_wreg(&_hc_regs->hcchar, hcchar.d32);
+ }
+ }
+ #endif
+ return 1;
+}
+
+static
+int32_t handle_hc_nyet_intr(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ _urbd->error_count=0;
+ _ifxhc->erron = 0;
+
+ disable_hc_int(_hc_regs,nyet);
+ #ifdef __NAKSTOP__
+ if(!_ifxhc->stop_on)
+ {
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nak);
+ }
+ #else
+ disable_hc_int(_hc_regs,ack);
+ disable_hc_int(_hc_regs,nak);
+ #endif
+ return 1;
+}
+
+/*
+ * Handles a host channel AHB error interrupt. This handler is only called in
+ * DMA mode.
+ */
+static int32_t handle_hc_ahberr_intr(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ IFX_DEBUGPL(DBG_HCD, "--Host Channel %d Interrupt: "
+ "AHB Error--\n", _ifxhc->hc_num);
+ hc_other_intr_dump(_ifxhcd,_ifxhc,_hc_regs,_urbd);
+
+ ifxhcd_hc_halt(&_ifxhcd->core_if, _ifxhc, HC_XFER_AHB_ERR);
+ return 1;
+}
+
+/*
+ * Datatoggle
+ */
+static int32_t handle_hc_datatglerr_intr(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ IFX_ERROR( "--Host Channel %d Interrupt: "
+ "DATATOGGLE Error--\n", _ifxhc->hc_num);
+ hc_other_intr_dump(_ifxhcd,_ifxhc,_hc_regs,_urbd);
+ disable_hc_int(_hc_regs,datatglerr);
+ return 1;
+}
+
+
+/*
+ * Interrupts which should not been triggered
+ */
+static int32_t handle_hc_frmovrun_intr(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ IFX_ERROR( "--Host Channel %d Interrupt: "
+ "FrameOverRun Error--\n", _ifxhc->hc_num);
+ hc_other_intr_dump(_ifxhcd,_ifxhc,_hc_regs,_urbd);
+ disable_hc_int(_hc_regs,frmovrun);
+ return 1;
+}
+
+static int32_t handle_hc_bblerr_intr(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ IFX_ERROR( "--Host Channel %d Interrupt: "
+ "BBL Error--\n", _ifxhc->hc_num);
+ hc_other_intr_dump(_ifxhcd,_ifxhc,_hc_regs,_urbd);
+ disable_hc_int(_hc_regs,bblerr);
+ return 1;
+}
+
+static int32_t handle_hc_xacterr_intr(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ IFX_ERROR( "--Host Channel %d Interrupt: "
+ "XACT Error--\n", _ifxhc->hc_num);
+ hc_other_intr_dump(_ifxhcd,_ifxhc,_hc_regs,_urbd);
+ disable_hc_int(_hc_regs,xacterr);
+ return 1;
+}
+
+
+static int32_t handle_hc_stall_intr(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ IFX_ERROR( "--Host Channel %d Interrupt: "
+ "STALL--\n", _ifxhc->hc_num);
+ hc_other_intr_dump(_ifxhcd,_ifxhc,_hc_regs,_urbd);
+ disable_hc_int(_hc_regs,stall);
+ return 1;
+}
+
+static int32_t handle_hc_xfercomp_intr(ifxhcd_hcd_t *_ifxhcd,
+ ifxhcd_hc_t *_ifxhc,
+ ifxusb_hc_regs_t *_hc_regs,
+ ifxhcd_urbd_t *_urbd)
+{
+ IFX_ERROR( "--Host Channel %d Interrupt: "
+ "XFERCOMP--\n", _ifxhc->hc_num);
+ hc_other_intr_dump(_ifxhcd,_ifxhc,_hc_regs,_urbd);
+ disable_hc_int(_hc_regs,xfercomp);
+ return 1;
+}
+
+/* This interrupt indicates that the specified host channels has a pending
+ * interrupt. There are multiple conditions that can cause each host channel
+ * interrupt. This function determines which conditions have occurred for this
+ * host channel interrupt and handles them appropriately. */
+static int32_t handle_hc_n_intr (ifxhcd_hcd_t *_ifxhcd, uint32_t _num)
+{
+ uint32_t hcintval,hcintmsk;
+ hcint_data_t hcint;
+ ifxhcd_hc_t *ifxhc;
+ ifxusb_hc_regs_t *hc_regs;
+ ifxhcd_urbd_t *urbd;
+
+ int retval = 0;
+
+ IFX_DEBUGPL(DBG_HCDV, "--Host Channel Interrupt--, Channel %d\n", _num);
+
+ ifxhc = &_ifxhcd->ifxhc[_num];
+ hc_regs = _ifxhcd->core_if.hc_regs[_num];
+
+ hcintval = ifxusb_rreg(&hc_regs->hcint);
+ hcintmsk = ifxusb_rreg(&hc_regs->hcintmsk);
+ hcint.d32 = hcintval & hcintmsk;
+ IFX_DEBUGPL(DBG_HCDV, " 0x%08x & 0x%08x = 0x%08x\n",
+ hcintval, hcintmsk, hcint.d32);
+
+ urbd = ifxhc->epqh->urbd;
+
+ if (hcint.b.ahberr)
+ retval |= handle_hc_ahberr_intr(_ifxhcd, ifxhc, hc_regs, urbd);
+ else if (hcint.b.chhltd)
+ retval |= handle_hc_chhltd_intr(_ifxhcd, ifxhc, hc_regs, urbd);
+ else
+ {
+ if (hcint.b.datatglerr)
+ retval |= handle_hc_datatglerr_intr(_ifxhcd, ifxhc, hc_regs, urbd);
+ if (hcint.b.frmovrun)
+ retval |= handle_hc_frmovrun_intr(_ifxhcd, ifxhc, hc_regs, urbd);
+ if (hcint.b.bblerr)
+ retval |= handle_hc_bblerr_intr(_ifxhcd, ifxhc, hc_regs, urbd);
+ if (hcint.b.xacterr)
+ retval |= handle_hc_xacterr_intr(_ifxhcd, ifxhc, hc_regs, urbd);
+ if (hcint.b.nyet)
+ retval |= handle_hc_nyet_intr(_ifxhcd, ifxhc, hc_regs, urbd);
+ if (hcint.b.ack)
+ retval |= handle_hc_ack_intr(_ifxhcd, ifxhc, hc_regs, urbd);
+ if (hcint.b.nak)
+ retval |= handle_hc_nak_intr(_ifxhcd, ifxhc, hc_regs, urbd);
+ if (hcint.b.stall)
+ retval |= handle_hc_stall_intr(_ifxhcd, ifxhc, hc_regs, urbd);
+ if (hcint.b.xfercomp)
+ retval |= handle_hc_xfercomp_intr(_ifxhcd, ifxhc, hc_regs, urbd);
+ }
+
+ ifxusb_wreg(&hc_regs->hcint,hcintval);
+
+ return retval;
+}
+
+
+static uint8_t update_interval_counter(ifxhcd_epqh_t *_epqh,uint32_t _diff)
+{
+ if(_diff>=_epqh->period_counter)
+ {
+ _epqh->period_do=1;
+ if(_diff>_epqh->interval)
+ _epqh->period_counter=1;
+ else
+ _epqh->period_counter=_epqh->period_counter+_epqh->interval-_diff;
+ return 1;
+ }
+ _epqh->period_counter=_epqh->period_counter-_diff;
+ return 0;
+}
+
+static
+void process_unaligned( ifxhcd_epqh_t *_epqh, ifxusb_core_if_t *_core_if)
+{
+ ifxhcd_urbd_t *urbd;
+ urbd =_epqh->urbd;
+
+ #if defined(__UNALIGNED_BUF_ADJ__) || defined(__UNALIGNED_BUF_CHK__)
+ if(!urbd->aligned_checked)
+ {
+ #if defined(__UNALIGNED_BUF_ADJ__)
+ uint32_t xfer_len;
+ xfer_len=urbd->xfer_len;
+ if(urbd->is_in && xfer_len<_epqh->mps)
+ xfer_len = _epqh->mps;
+// urbd->using_aligned_buf=0;
+
+ if(xfer_len > 0 && ((unsigned long)urbd->xfer_buff) & _core_if->unaligned_mask)
+ {
+ if( urbd->aligned_buf
+ && urbd->aligned_buf_len > 0
+ && urbd->aligned_buf_len < xfer_len
+ )
+ {
+ ifxusb_free_buf_h(urbd->aligned_buf);
+ urbd->aligned_buf=NULL;
+ urbd->aligned_buf_len=0;
+ }
+ if(! urbd->aligned_buf || ! urbd->aligned_buf_len)
+ {
+ urbd->aligned_buf = ifxusb_alloc_buf_h(xfer_len, urbd->is_in);
+ if(urbd->aligned_buf)
+ urbd->aligned_buf_len = xfer_len;
+ }
+ if(urbd->aligned_buf)
+ {
+ if(!urbd->is_in)
+ memcpy(urbd->aligned_buf, urbd->xfer_buff, xfer_len);
+// urbd->using_aligned_buf=1;
+ _epqh->hc->xfer_buff = urbd->aligned_buf;
+ }
+ else
+ IFX_WARN("%s():%d\n",__func__,__LINE__);
+ }
+ if(_epqh->ep_type==IFXUSB_EP_TYPE_CTRL)
+ {
+// urbd->using_aligned_setup=0;
+ if(((unsigned long)urbd->setup_buff) & _core_if->unaligned_mask)
+ {
+ if(! urbd->aligned_setup)
+ urbd->aligned_setup = ifxusb_alloc_buf_h(8,0);
+ if(urbd->aligned_setup)
+ {
+ memcpy(urbd->aligned_setup, urbd->setup_buff, 8);
+// urbd->using_aligned_setup=1;
+ }
+ else
+ IFX_WARN("%s():%d\n",__func__,__LINE__);
+ _epqh->hc->xfer_buff = urbd->aligned_setup;
+ }
+ }
+ #elif defined(__UNALIGNED_BUF_CHK__)
+ if(_epqh->urbd->is_in)
+ {
+ if(_epqh->urbd->xfer_len==0)
+ IFX_WARN("%s():%d IN xfer while length is zero \n",__func__,__LINE__);
+ else{
+ if(_epqh->urbd->xfer_len < _epqh->mps)
+ IFX_WARN("%s():%d IN xfer while length < mps \n",__func__,__LINE__);
+ if(((unsigned long)_epqh->urbd->xfer_buff) & _core_if->unaligned_mask)
+ IFX_WARN("%s():%d IN xfer Buffer UNALIGNED\n",__func__,__LINE__);
+ }
+ }
+ else
+ {
+ if(_epqh->urbd->xfer_len > 0 && (((unsigned long)_epqh->urbd->xfer_buff) & _core_if->unaligned_mask))
+ IFX_WARN("%s():%d OUT xfer Buffer UNALIGNED\n",__func__,__LINE__);
+ }
+ if(_epqh->ep_type==IFXUSB_EP_TYPE_CTRL)
+ {
+ if(((unsigned long)_epqh->urbd->setup_buff) & _core_if->unaligned_mask)
+ IFX_WARN("%s():%d SETUP xfer Buffer UNALIGNED\n",__func__,__LINE__);
+ }
+ #endif
+ }
+ urbd->aligned_checked=1;
+ #endif
+}
+
+/*!
+ \brief Assigns transactions from a URBD to a free host channel and initializes the
+ host channel to perform the transactions. The host channel is removed from
+ the free list.
+ \param _ifxhcd The HCD state structure.
+ \param _epqh Transactions from the first URBD for this EPQH are selected and assigned to a free host channel.
+ */
+static
+int assign_hc(ifxhcd_hcd_t *_ifxhcd, ifxhcd_epqh_t *_epqh,ifxhcd_urbd_t *_urbd)
+{
+ ifxhcd_hc_t *ifxhc;
+ struct urb *urb;
+
+ IFX_DEBUGPL(DBG_HCDV, "%s(%p,%p)\n", __func__, _ifxhcd, _epqh);
+
+ if(_ifxhcd->disconnecting)
+ {
+ printk(KERN_INFO "Warning: %s() Port is in discoonection\n",__func__);
+ return 0;
+ }
+
+ if(!_epqh) return 0;
+ if(!_urbd) return 0;
+ if(!_urbd->urb) return 0;
+
+ {
+ int i;
+ int num_channels = _ifxhcd->core_if.params.host_channels;
+ for(i=0;i<num_channels ; i++)
+ {
+ hcchar_data_t hcchar;
+ ifxusb_hc_regs_t *hc_regs;
+ hc_regs = _ifxhcd->core_if.hc_regs[i];
+ if(_ifxhcd->ifxhc[i].phase!=HC_IDLE)
+ {
+ continue;
+ }
+ hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
+ if(hcchar.b.chen || hcchar.b.chdis)
+ {
+ continue;
+ }
+ break;
+ }
+
+ if(i<num_channels)
+ {
+ ifxhc=&_ifxhcd->ifxhc[i];
+ ifxhc->phase=HC_ASSIGNED;
+ }
+ else
+ return 0;
+ }
+
+ urb = _urbd->urb;
+ _epqh->hc = ifxhc;
+ _epqh->urbd = _urbd;
+ ifxhc->epqh = _epqh;
+ /*
+ * Use usb_pipedevice to determine device address. This address is
+ * 0 before the SET_ADDRESS command and the correct address afterward.
+ */
+ ifxhc->dev_addr = usb_pipedevice(urb->pipe);
+ ifxhc->ep_num = usb_pipeendpoint(urb->pipe);
+
+ if (urb->dev->speed == USB_SPEED_LOW) ifxhc->speed = IFXUSB_EP_SPEED_LOW;
+ else if (urb->dev->speed == USB_SPEED_FULL) ifxhc->speed = IFXUSB_EP_SPEED_FULL;
+ else ifxhc->speed = IFXUSB_EP_SPEED_HIGH;
+
+ ifxhc->mps = _epqh->mps;
+ ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
+ ifxhc->ep_type = _epqh->ep_type;
+
+ ifxhc->split = 0;
+ if (_epqh->need_split)
+ {
+ ifxhc->split = 1;
+ ifxhc->hub_addr = urb->dev->tt->hub->devnum;
+ ifxhc->port_addr = urb->dev->ttport;
+ }
+ return 1;
+}
+
+/*!
+ \brief Assigns transactions from a URBD to a free host channel and initializes the
+ host channel to perform the transactions. The host channel is removed from
+ the free list.
+ \param _ifxhcd The HCD state structure.
+ \param _epqh Transactions from the first URBD for this EPQH are selected and assigned to a free host channel.
+ */
+static
+void init_hc(ifxhcd_epqh_t *_epqh)
+{
+ ifxhcd_hc_t *ifxhc;
+ ifxhcd_urbd_t *urbd;
+ struct urb *urb;
+ ifxhcd_hcd_t *ifxhcd;
+
+ IFX_DEBUGPL(DBG_HCDV, "%s(%p)\n", __func__, _epqh);
+
+ ifxhc =_epqh->hc;
+ urbd =_epqh->urbd;
+ ifxhcd=_epqh->ifxhcd;
+ urb = urbd->urb;
+ #if defined(__UNALIGNED_BUF_ADJ__) || defined(__UNALIGNED_BUF_CHK__)
+ urbd->aligned_checked=0;
+ #endif
+
+ ifxhc->halt_status = HC_XFER_NO_HALT_STATUS;
+
+ if(_epqh->ep_type==IFXUSB_EP_TYPE_CTRL)
+ {
+ ifxhc->control_phase =IFXHCD_CONTROL_SETUP;
+ ifxhc->is_in = 0;
+ ifxhc->data_pid_start = IFXUSB_HC_PID_SETUP;
+ ifxhc->xfer_buff = urbd->setup_buff;
+ ifxhc->xfer_len = 8;
+ ifxhc->xfer_count = 0;
+ ifxhc->short_rw =(urb->transfer_flags & URB_ZERO_PACKET)?1:0;
+ ifxhc->sof_delay = 0;
+ _epqh->do_ping=0;
+ if(!ifxhc->is_in && ifxhc->split==0)
+ _epqh->do_ping=1;
+ }
+ else if(_epqh->ep_type==IFXUSB_EP_TYPE_ISOC)
+ {
+ #ifdef __EN_ISOC__
+ struct usb_iso_packet_descriptor *frame_desc;
+ ifxhc->is_in = urbd->is_in;
+ frame_desc = &urb->iso_frame_desc[urbd->isoc_frame_index];
+ urbd->xfer_len = ifxhc->xfer_len = frame_desc->length;
+ ifxhc->xfer_buff = urbd->xfer_buff;
+ ifxhc->xfer_buff += frame_desc->offset;
+ ifxhc->xfer_count = 0;
+ ifxhc->sof_delay = 0;
+ if(usb_gettoggle (urb->dev,usb_pipeendpoint (urb->pipe), (ifxhc->is_in)?0:1))
+ ifxhc->data_pid_start = IFXUSB_HCTSIZ_DATA1;
+ else
+ ifxhc->data_pid_start = IFXUSB_HCTSIZ_DATA0;
+
+ if(ifxhc->is_in)
+ ifxhc->short_rw =0;
+ else
+ ifxhc->short_rw =(urb->transfer_flags & URB_ZERO_PACKET)?1:0;
+ #ifdef __EN_ISOC_SPLIT__
+ ifxhc->isoc_xact_pos = IFXUSB_HCSPLIT_XACTPOS_ALL;
+ #endif
+
+ _epqh->isoc_frame_index=0;
+ _epqh->isoc_now=0;
+ _epqh->isoc_start_frame=0;
+ if(_urb->transfer_flags && URB_ISO_ASAP)
+ _epqh->isoc_now=1;
+ else
+ _epqh->isoc_start_frame=_urb->start_frame;
+ #ifdef __EN_ISOC_SPLIT__
+ _epqh->isoc_split_pos =0;
+ _epqh->isoc_split_offset=0;
+ #endif
+ _epqh->do_ping=0;
+ #endif
+ }
+ else
+ {
+ ifxhc->is_in = urbd->is_in;
+ ifxhc->xfer_buff = urbd->xfer_buff;
+ ifxhc->xfer_len = urbd->xfer_len;
+ ifxhc->xfer_count = 0;
+ ifxhc->sof_delay = 0;
+// if(ifxhc->xfer_len==13 && ifxhc->is_in && _epqh->ep_type==IFXUSB_EP_TYPE_BULK && ifxhc->split==0)
+// ifxhc->sof_delay = 8;
+ if(usb_gettoggle (urb->dev,usb_pipeendpoint (urb->pipe), (ifxhc->is_in)?0:1))
+ ifxhc->data_pid_start = IFXUSB_HCTSIZ_DATA1;
+ else
+ ifxhc->data_pid_start = IFXUSB_HCTSIZ_DATA0;
+ if(ifxhc->is_in)
+ ifxhc->short_rw =0;
+ else
+ ifxhc->short_rw =(urb->transfer_flags & URB_ZERO_PACKET)?1:0;
+ _epqh->do_ping=0;
+ if(!ifxhc->is_in && ifxhc->split==0)
+ {
+ if(_epqh->ep_type==IFXUSB_EP_TYPE_BULK) _epqh->do_ping=1;
+ }
+ }
+
+ {
+ hcint_data_t hc_intr_mask;
+ uint8_t hc_num = ifxhc->hc_num;
+ ifxusb_hc_regs_t *hc_regs = ifxhcd->core_if.hc_regs[hc_num];
+
+ /* Clear old interrupt conditions for this host channel. */
+ hc_intr_mask.d32 = 0xFFFFFFFF;
+ hc_intr_mask.b.reserved = 0;
+ ifxusb_wreg(&hc_regs->hcint, hc_intr_mask.d32);
+
+ /* Enable channel interrupts required for this transfer. */
+ hc_intr_mask.d32 = 0;
+ hc_intr_mask.b.chhltd = 1;
+ hc_intr_mask.b.ahberr = 1;
+
+ ifxusb_wreg(&hc_regs->hcintmsk, hc_intr_mask.d32);
+
+ /* Enable the top level host channel interrupt. */
+ {
+ uint32_t intr_enable;
+ intr_enable = (1 << hc_num);
+ ifxusb_mreg(&ifxhcd->core_if.host_global_regs->haintmsk, 0, intr_enable);
+ }
+
+ /* Make sure host channel interrupts are enabled. */
+ {
+ gint_data_t gintmsk ={.d32 = 0};
+ gintmsk.b.hcintr = 1;
+ ifxusb_mreg(&ifxhcd->core_if.core_global_regs->gintmsk, 0, gintmsk.d32);
+ }
+
+ /*
+ * Program the HCCHARn register with the endpoint characteristics for
+ * the current transfer.
+ */
+ {
+ hcchar_data_t hcchar;
+
+ hcchar.d32 = 0;
+ hcchar.b.devaddr = ifxhc->dev_addr;
+ hcchar.b.epnum = ifxhc->ep_num;
+ hcchar.b.lspddev = (ifxhc->speed == IFXUSB_EP_SPEED_LOW);
+ hcchar.b.eptype = ifxhc->ep_type;
+ hcchar.b.mps = ifxhc->mps;
+ ifxusb_wreg(&hc_regs->hcchar, hcchar.d32);
+
+ IFX_DEBUGPL(DBG_HCDV, "%s: Channel %d\n", __func__, ifxhc->hc_num);
+ IFX_DEBUGPL(DBG_HCDV, " Dev Addr: %d\n" , hcchar.b.devaddr);
+ IFX_DEBUGPL(DBG_HCDV, " Ep Num: %d\n" , hcchar.b.epnum);
+ IFX_DEBUGPL(DBG_HCDV, " Is Low Speed: %d\n", hcchar.b.lspddev);
+ IFX_DEBUGPL(DBG_HCDV, " Ep Type: %d\n" , hcchar.b.eptype);
+ IFX_DEBUGPL(DBG_HCDV, " Max Pkt: %d\n" , hcchar.b.mps);
+ IFX_DEBUGPL(DBG_HCDV, " Multi Cnt: %d\n" , hcchar.b.multicnt);
+ }
+ /* Program the HCSPLIT register for SPLITs */
+ {
+ hcsplt_data_t hcsplt;
+
+ hcsplt.d32 = 0;
+ if (ifxhc->split)
+ {
+ IFX_DEBUGPL(DBG_HCDV, "Programming HC %d with split --> %s\n", ifxhc->hc_num,
+ (ifxhc->split==2) ? "CSPLIT" : "SSPLIT");
+ hcsplt.b.spltena = 1;
+ hcsplt.b.compsplt = (ifxhc->split==2);
+ #if defined(__EN_ISOC__) && defined(__EN_ISOC_SPLIT__)
+ if(_epqh->ep_type==IFXUSB_EP_TYPE_ISOC)
+ hcsplt.b.xactpos = ifxhc->isoc_xact_pos;
+ else
+ #endif
+ hcsplt.b.xactpos = IFXUSB_HCSPLIT_XACTPOS_ALL;
+ hcsplt.b.hubaddr = ifxhc->hub_addr;
+ hcsplt.b.prtaddr = ifxhc->port_addr;
+ IFX_DEBUGPL(DBG_HCDV, " comp split %d\n" , hcsplt.b.compsplt);
+ IFX_DEBUGPL(DBG_HCDV, " xact pos %d\n" , hcsplt.b.xactpos);
+ IFX_DEBUGPL(DBG_HCDV, " hub addr %d\n" , hcsplt.b.hubaddr);
+ IFX_DEBUGPL(DBG_HCDV, " port addr %d\n" , hcsplt.b.prtaddr);
+ IFX_DEBUGPL(DBG_HCDV, " is_in %d\n" , ifxhc->is_in);
+ IFX_DEBUGPL(DBG_HCDV, " Max Pkt: %d\n" , ifxhc->mps);
+ IFX_DEBUGPL(DBG_HCDV, " xferlen: %d\n" , ifxhc->xfer_len);
+ }
+ ifxusb_wreg(&hc_regs->hcsplt, hcsplt.d32);
+ }
+ }
+ process_unaligned(_epqh,&ifxhcd->core_if);
+
+
+ #ifdef __NAKSTOP__
+ ifxhc->stop_on=0;
+ if (!ifxhc->split && ifxhc->ep_type == IFXUSB_EP_TYPE_BULK)
+ {
+ #ifdef __INNAKSTOP_BULK__
+ if(ifxhc->is_in)
+ ifxhc->stop_on=1;
+ #endif
+ #ifdef __PINGSTOP_BULK__
+ if(!ifxhc->is_in)
+ ifxhc->stop_on=1;
+ #endif
+ }
+ #endif
+}
+
+
+static
+void select_eps_sub(ifxhcd_hcd_t *_ifxhcd)
+{
+ struct list_head *epqh_ptr;
+ ifxhcd_epqh_t *epqh;
+ struct list_head *urbd_ptr;
+ unsigned long flags;
+ ifxhcd_urbd_t *urbd;
+
+ hfnum_data_t hfnum;
+ uint32_t fndiff;
+
+ if(_ifxhcd->disconnecting)
+ {
+// printk(KERN_INFO "Warning: %s() Port is in discoonection\n",__func__);
+ return ;
+ }
+
+ local_irq_save(flags);
+ LOCK_EPQH_LIST(_ifxhcd);
+
+ hfnum.d32 = ifxusb_rreg(&_ifxhcd->core_if.host_global_regs->hfnum);
+ fndiff = hfnum.b.frnum;
+ fndiff+= 0x00004000;
+ fndiff-= _ifxhcd->lastframe ;
+ fndiff&= 0x00003FFF;
+ if(!fndiff) fndiff =1;
+
+ #ifdef __EN_ISOC__
+ epqh_ptr = _ifxhcd->epqh_list_isoc.next;
+ while (epqh_ptr != &_ifxhcd->epqh_list_isoc)
+ {
+ epqh = list_entry(epqh_ptr, ifxhcd_epqh_t, ql);
+ epqh_ptr = epqh_ptr->next;
+
+ #ifdef __DYN_SOF_INTR__
+ if (!list_empty(&epqh->urbd_list))
+ _ifxhcd->dyn_sof_count = DYN_SOF_COUNT_DEF;
+ #endif
+
+ if(epqh->pause)
+ continue;
+ if(epqh->phase==EPQH_READY)
+ {
+ if(update_interval_counter(epqh,fndiff) || epqh->isoc_now)
+ {
+ LOCK_URBD_LIST(epqh);
+ urbd_ptr = epqh->urbd_list.next;
+ while (urbd_ptr != &epqh->urbd_list)
+ {
+ urbd = list_entry(urbd_ptr, ifxhcd_urbd_t, ql);
+ urbd_ptr=urbd_ptr->next;
+ if(urbd->phase==URBD_IDLE)
+ {
+ if(assign_hc(_ifxhcd, epqh,urbd))
+ {
+ IFX_DEBUGPL(DBG_HCD, " select_eps ISOC\n");
+ #ifdef __EPQD_DESTROY_TIMEOUT__
+ del_timer(&epqh->destroy_timer);
+ #endif
+ epqh->isoc_now=0;
+ list_del_init (&epqh->ql);
+ list_add_tail(&epqh->ql, &_ifxhcd->epqh_list_isoc);
+ init_hc(epqh);
+ epqh->phase=EPQH_ACTIVE;
+ urbd->phase==URBD_ACTIVE;
+ epqh->hc.phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, epqh->hc);
+ }
+ break;
+ }
+ }
+ UNLOCK_URBD_LIST(epqh);
+ }
+ }
+ }
+ #endif //__EN_ISOC__
+
+ epqh_ptr = _ifxhcd->epqh_list_intr.next;
+ while (epqh_ptr != &_ifxhcd->epqh_list_intr)
+ {
+ epqh = list_entry(epqh_ptr, ifxhcd_epqh_t, ql);
+ epqh_ptr = epqh_ptr->next;
+ #ifdef __DYN_SOF_INTR__
+ if (!list_empty(&epqh->urbd_list))
+ _ifxhcd->dyn_sof_count = DYN_SOF_COUNT_DEF;
+ #endif
+ if(epqh->pause)
+ continue;
+ if(epqh->phase==EPQH_READY)
+ {
+ if(update_interval_counter(epqh,fndiff))
+ {
+ LOCK_URBD_LIST(epqh);
+ urbd_ptr = epqh->urbd_list.next;
+ while (urbd_ptr != &epqh->urbd_list)
+ {
+ urbd = list_entry(urbd_ptr, ifxhcd_urbd_t, ql);
+ urbd_ptr=urbd_ptr->next;
+ if(urbd->phase==URBD_IDLE)
+ {
+ if(assign_hc(_ifxhcd, epqh,urbd))
+ {
+ IFX_DEBUGPL(DBG_HCD, " select_eps INTR\n");
+ #ifdef __EPQD_DESTROY_TIMEOUT__
+ del_timer(&epqh->destroy_timer);
+ #endif
+ list_del_init (&epqh->ql);
+ list_add_tail(&epqh->ql, &_ifxhcd->epqh_list_intr);
+ init_hc(epqh);
+ epqh->phase=EPQH_ACTIVE;
+ urbd->phase=URBD_ACTIVE;
+ epqh->hc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, epqh->hc);
+ }
+ break;
+ }
+ }
+ UNLOCK_URBD_LIST(epqh);
+ }
+ }
+ else if(epqh->phase==EPQH_STDBY)
+ {
+ if(epqh->period_counter > 0 )
+ epqh->period_counter --;
+ if(epqh->period_counter == 0)
+ ifxhcd_epqh_idle_periodic(epqh);
+ update_interval_counter(epqh,fndiff);
+ }
+ else
+ update_interval_counter(epqh,fndiff);
+ }
+
+ epqh_ptr = _ifxhcd->epqh_list_np.next;
+ while (epqh_ptr != &_ifxhcd->epqh_list_np) // may need to preserve at lease one for period
+ {
+ epqh = list_entry(epqh_ptr, ifxhcd_epqh_t, ql);
+ epqh_ptr = epqh_ptr->next;
+ #ifdef __DYN_SOF_INTR__
+ if (!list_empty(&epqh->urbd_list))
+ _ifxhcd->dyn_sof_count = DYN_SOF_COUNT_DEF;
+ #endif
+ if(epqh->pause)
+ continue;
+ if(epqh->phase==EPQH_READY)
+ {
+ LOCK_URBD_LIST(epqh);
+ urbd_ptr = epqh->urbd_list.next;
+ while (urbd_ptr != &epqh->urbd_list)
+ {
+ urbd = list_entry(urbd_ptr, ifxhcd_urbd_t, ql);
+ urbd_ptr=urbd_ptr->next;
+ if(urbd->phase==URBD_IDLE)
+ {
+ if(assign_hc(_ifxhcd, epqh,urbd))
+ {
+ IFX_DEBUGPL(DBG_HCD, " select_eps Non-Period\n");
+ #ifdef __EPQD_DESTROY_TIMEOUT__
+ del_timer(&epqh->destroy_timer);
+ #endif
+ list_del_init (&epqh->ql);
+ list_add_tail(&epqh->ql, &_ifxhcd->epqh_list_np);
+ init_hc(epqh);
+ epqh->phase=EPQH_ACTIVE;
+ urbd->phase=URBD_ACTIVE;
+ epqh->hc->phase=HC_WAITING;
+ ifxhcd_hc_start(_ifxhcd, epqh->hc);
+ }
+ break;
+ }
+ }
+ UNLOCK_URBD_LIST(epqh);
+ }
+ }
+
+ _ifxhcd->lastframe=hfnum.b.frnum;
+
+ UNLOCK_EPQH_LIST(_ifxhcd);
+ local_irq_restore(flags);
+}
+
+static
+void select_eps_func(unsigned long data)
+{
+ ifxhcd_hcd_t *ifxhcd;
+ ifxhcd=((ifxhcd_hcd_t *)data);
+
+ select_eps_sub(ifxhcd);
+}
+
+/*!
+ \fn void select_eps(ifxhcd_hcd_t *_ifxhcd)
+ \brief This function selects transactions from the HCD transfer schedule and assigns them to available host channels.
+ \param _ifxhcd Pointer to the sate of HCD structure
+ \ingroup IFXUSB_HCD
+ */
+void select_eps(ifxhcd_hcd_t *_ifxhcd)
+{
+ if(in_irq())
+ {
+ if(!_ifxhcd->tasklet_select_eps.func)
+ {
+ _ifxhcd->tasklet_select_eps.next = NULL;
+ _ifxhcd->tasklet_select_eps.state = 0;
+ atomic_set( &_ifxhcd->tasklet_select_eps.count, 0);
+ _ifxhcd->tasklet_select_eps.func = select_eps_func;
+ _ifxhcd->tasklet_select_eps.data = (unsigned long)_ifxhcd;
+ }
+ tasklet_schedule(&_ifxhcd->tasklet_select_eps);
+ }
+ else
+ {
+ select_eps_sub(_ifxhcd);
+ }
+}
+
+static
+void ifxhcd_hc_kickstart(ifxhcd_hcd_t *_ifxhcd)
+{
+ int num_channels;
+ ifxusb_hc_regs_t *hc_regs;
+ int i;
+ ifxhcd_hc_t *ifxhc;
+ num_channels = _ifxhcd->core_if.params.host_channels;
+
+ for (i = 0; i < num_channels; i++)
+ {
+ ifxhc=&_ifxhcd->ifxhc[i];
+ if(ifxhc->phase==HC_STARTING)
+ {
+ if(ifxhc->sof_delay) ifxhc->sof_delay--;
+ if(!ifxhc->sof_delay)
+ {
+ hcint_data_t hcint;
+// ifxhc->erron=0;
+ hc_regs = _ifxhcd->core_if.hc_regs[i];
+ hcint.d32 =0xFFFFFFFF;
+ ifxusb_wreg(&hc_regs->hcint, hcint.d32);
+ hcint.d32 =ifxusb_rreg(&hc_regs->hcintmsk);
+ hcint.b.nak =0;
+ hcint.b.ack =0;
+ hcint.b.nyet=0;
+ if(ifxhc->erron)
+ {
+ hcint.b.ack =1;
+ hcint.b.nak =1;
+ hcint.b.nyet =1;
+ }
+ #ifdef __NAKSTOP__
+ if(ifxhc->stop_on)
+ {
+ hcint.b.ack =1;
+ hcint.b.nak =1;
+ }
+ #endif
+ ifxusb_wreg(&hc_regs->hcintmsk, hcint.d32);
+ ifxusb_wreg(&hc_regs->hcchar, ifxhc->hcchar);
+ ifxhc->phase=HC_STARTED;
+ }
+ }
+ }
+
+ for (i = 0; i < num_channels; i++)
+ {
+ ifxhc=&_ifxhcd->ifxhc[i];
+ if(ifxhc->phase==HC_WAITING &&
+ (ifxhc->ep_type == IFXUSB_EP_TYPE_INTR || ifxhc->ep_type == IFXUSB_EP_TYPE_ISOC)
+ )
+ {
+ ifxhcd_hc_start(_ifxhcd, ifxhc);
+ }
+ }
+
+ for (i = 0; i < num_channels; i++)
+ {
+ ifxhc=&_ifxhcd->ifxhc[i];
+ if(ifxhc->phase==HC_WAITING)
+ {
+ ifxhcd_hc_start(_ifxhcd, ifxhc);
+ }
+ }
+}
+
+/*
+ * Handles the start-of-frame interrupt in host mode. Non-periodic
+ * transactions may be queued to the DWC_otg controller for the current
+ * (micro)frame. Periodic transactions may be queued to the controller for the
+ * next (micro)frame.
+ */
+static
+int32_t handle_sof_intr (ifxhcd_hcd_t *_ifxhcd)
+{
+ _ifxhcd->pkt_remaining=_ifxhcd->pkt_remaining_reload;
+ ifxhcd_hc_kickstart(_ifxhcd);
+
+ select_eps(_ifxhcd);
+
+ /* Clear interrupt */
+ {
+ gint_data_t gintsts;
+ gintsts.d32=0;
+ gintsts.b.sofintr = 1;
+ ifxusb_wreg(&_ifxhcd->core_if.core_global_regs->gintsts, gintsts.d32);
+
+ #ifdef __DYN_SOF_INTR__
+ if(_ifxhcd->dyn_sof_count)
+ _ifxhcd->dyn_sof_count--;
+ if(!_ifxhcd->dyn_sof_count)
+ ifxusb_mreg(&_ifxhcd->core_if.core_global_regs->gintmsk, gintsts.d32,0);
+ #endif
+ }
+ return 1;
+}
+
+
+
+/* There are multiple conditions that can cause a port interrupt. This function
+ * determines which interrupt conditions have occurred and handles them
+ * appropriately. */
+static int32_t handle_port_intr (ifxhcd_hcd_t *_ifxhcd)
+{
+ int retval = 0;
+ hprt0_data_t hprt0;
+ hprt0_data_t hprt0_modify;
+
+ hprt0.d32 =
+ hprt0_modify.d32 = ifxusb_rreg(_ifxhcd->core_if.hprt0);
+
+ /* Clear appropriate bits in HPRT0 to clear the interrupt bit in
+ * GINTSTS */
+
+ hprt0_modify.b.prtena = 0;
+ hprt0_modify.b.prtconndet = 0;
+ hprt0_modify.b.prtenchng = 0;
+ hprt0_modify.b.prtovrcurrchng = 0;
+
+ /* Port Connect Detected
+ * Set flag and clear if detected */
+ if (hprt0.b.prtconndet) {
+ IFX_DEBUGPL(DBG_HCD, "--Port Interrupt HPRT0=0x%08x "
+ "Port Connect Detected--\n", hprt0.d32);
+ _ifxhcd->flags.b.port_connect_status_change = 1;
+ _ifxhcd->flags.b.port_connect_status = 1;
+ hprt0_modify.b.prtconndet = 1;
+
+ /* The Hub driver asserts a reset when it sees port connect
+ * status change flag */
+ retval |= 1;
+ }
+
+ /* Port Enable Changed
+ * Clear if detected - Set internal flag if disabled */
+ if (hprt0.b.prtenchng) {
+ IFX_DEBUGPL(DBG_HCD, " --Port Interrupt HPRT0=0x%08x "
+ "Port Enable Changed--\n", hprt0.d32);
+ hprt0_modify.b.prtenchng = 1;
+ if (hprt0.b.prtena == 1)
+ {
+ /* Port has been enabled set the reset change flag */
+ _ifxhcd->flags.b.port_reset_change = 1;
+ if (hprt0.b.prtspd == IFXUSB_HPRT0_PRTSPD_HIGH_SPEED)
+ _ifxhcd->pkt_remaining_reload=_ifxhcd->pkt_remaining_reload_hs;
+ else if (hprt0.b.prtspd == IFXUSB_HPRT0_PRTSPD_LOW_SPEED)
+ _ifxhcd->pkt_remaining_reload=_ifxhcd->pkt_remaining_reload_ls;
+ else
+ _ifxhcd->pkt_remaining_reload=_ifxhcd->pkt_remaining_reload_fs;
+ }
+ else
+ _ifxhcd->flags.b.port_enable_change = 1;
+ retval |= 1;
+ }
+
+ /* Overcurrent Change Interrupt */
+
+ if (hprt0.b.prtovrcurrchng) {
+ IFX_DEBUGPL(DBG_HCD, " --Port Interrupt HPRT0=0x%08x "
+ "Port Overcurrent Changed--\n", hprt0.d32);
+ _ifxhcd->flags.b.port_over_current_change = 1;
+ hprt0_modify.b.prtovrcurrchng = 1;
+ retval |= 1;
+ }
+
+ /* Clear Port Interrupts */
+ ifxusb_wreg(_ifxhcd->core_if.hprt0, hprt0_modify.d32);
+ return retval;
+}
+
+/*
+ * This interrupt indicates that SUSPEND state has been detected on
+ * the USB.
+ * No Functioning in Host Mode
+ */
+static int32_t handle_usb_suspend_intr(ifxhcd_hcd_t *_ifxhcd)
+{
+ gint_data_t gintsts;
+ IFX_DEBUGP("USB SUSPEND RECEIVED!\n");
+ /* Clear interrupt */
+ gintsts.d32 = 0;
+ gintsts.b.usbsuspend = 1;
+ ifxusb_wreg(&_ifxhcd->core_if.core_global_regs->gintsts, gintsts.d32);
+ return 1;
+}
+
+/*
+ * This interrupt indicates that the IFXUSB controller has detected a
+ * resume or remote wakeup sequence. If the IFXUSB controller is in
+ * low power mode, the handler must brings the controller out of low
+ * power mode. The controller automatically begins resume
+ * signaling. The handler schedules a time to stop resume signaling.
+ */
+static int32_t handle_wakeup_detected_intr(ifxhcd_hcd_t *_ifxhcd)
+{
+ gint_data_t gintsts;
+ hprt0_data_t hprt0 = {.d32=0};
+ pcgcctl_data_t pcgcctl = {.d32=0};
+ ifxusb_core_if_t *core_if = &_ifxhcd->core_if;
+
+ IFX_DEBUGPL(DBG_ANY, "++Resume and Remote Wakeup Detected Interrupt++\n");
+
+ /*
+ * Clear the Resume after 70ms. (Need 20 ms minimum. Use 70 ms
+ * so that OPT tests pass with all PHYs).
+ */
+ /* Restart the Phy Clock */
+ pcgcctl.b.stoppclk = 1;
+ ifxusb_mreg(core_if->pcgcctl, pcgcctl.d32, 0);
+ UDELAY(10);
+
+ /* Now wait for 70 ms. */
+ hprt0.d32 = ifxusb_read_hprt0( core_if );
+ IFX_DEBUGPL(DBG_ANY,"Resume: HPRT0=%0x\n", hprt0.d32);
+ MDELAY(70);
+ hprt0.b.prtres = 0; /* Resume */
+ ifxusb_wreg(core_if->hprt0, hprt0.d32);
+ IFX_DEBUGPL(DBG_ANY,"Clear Resume: HPRT0=%0x\n", ifxusb_rreg(core_if->hprt0));
+
+ /* Clear interrupt */
+ gintsts.d32 = 0;
+ gintsts.b.wkupintr = 1;
+ ifxusb_wreg(&core_if->core_global_regs->gintsts, gintsts.d32);
+ return 1;
+}
+
+/*
+ * This interrupt indicates that a device is initiating the Session
+ * Request Protocol to request the host to turn on bus power so a new
+ * session can begin. The handler responds by turning on bus power. If
+ * the DWC_otg controller is in low power mode, the handler brings the
+ * controller out of low power mode before turning on bus power.
+ */
+static int32_t handle_session_req_intr(ifxhcd_hcd_t *_ifxhcd)
+{
+ /* Clear interrupt */
+ gint_data_t gintsts = { .d32 = 0 };
+ gintsts.b.sessreqintr = 1;
+ ifxusb_wreg(&_ifxhcd->core_if.core_global_regs->gintsts, gintsts.d32);
+ return 1;
+}
+
+/*
+ * This interrupt indicates that a device has been disconnected from
+ * the root port.
+ */
+static int32_t handle_disconnect_intr(ifxhcd_hcd_t *_ifxhcd)
+{
+ gint_data_t gintsts;
+
+ ifxhcd_disconnect(_ifxhcd);
+
+ gintsts.d32 = 0;
+ gintsts.b.disconnect = 1;
+ ifxusb_wreg(&_ifxhcd->core_if.core_global_regs->gintsts, gintsts.d32);
+ return 1;
+}
+
+/*
+ * This function handles the Connector ID Status Change Interrupt. It
+ * reads the OTG Interrupt Register (GOTCTL) to determine whether this
+ * is a Device to Host Mode transition or a Host Mode to Device
+ * Transition.
+ * This only occurs when the cable is connected/removed from the PHY
+ * connector.
+ */
+static int32_t handle_conn_id_status_change_intr(ifxhcd_hcd_t *_ifxhcd)
+{
+ gint_data_t gintsts;
+
+ IFX_WARN("ID Status Change Interrupt: currently in %s mode\n",
+ ifxusb_mode(&_ifxhcd->core_if) ? "Host" : "Device");
+
+ gintsts.d32 = 0;
+ gintsts.b.conidstschng = 1;
+ ifxusb_wreg(&_ifxhcd->core_if.core_global_regs->gintsts, gintsts.d32);
+ return 1;
+}
+
+static int32_t handle_otg_intr(ifxhcd_hcd_t *_ifxhcd)
+{
+ ifxusb_core_global_regs_t *global_regs = _ifxhcd->core_if.core_global_regs;
+ gotgint_data_t gotgint;
+ gotgint.d32 = ifxusb_rreg( &global_regs->gotgint);
+ /* Clear GOTGINT */
+ ifxusb_wreg (&global_regs->gotgint, gotgint.d32);
+ return 1;
+}
+
+/** This function will log a debug message */
+static int32_t handle_mode_mismatch_intr(ifxhcd_hcd_t *_ifxhcd)
+{
+ gint_data_t gintsts;
+
+ IFX_WARN("Mode Mismatch Interrupt: currently in %s mode\n",
+ ifxusb_mode(&_ifxhcd->core_if) ? "Host" : "Device");
+ gintsts.d32 = 0;
+ gintsts.b.modemismatch = 1;
+ ifxusb_wreg(&_ifxhcd->core_if.core_global_regs->gintsts, gintsts.d32);
+ return 1;
+}
+
+/** This function handles interrupts for the HCD. */
+int32_t ifxhcd_handle_intr (ifxhcd_hcd_t *_ifxhcd)
+{
+ int retval = 0;
+
+ ifxusb_core_if_t *core_if = &_ifxhcd->core_if;
+ gint_data_t gintsts,gintsts2;
+
+ /* Check if HOST Mode */
+ if (ifxusb_is_device_mode(core_if))
+ {
+ IFX_ERROR("%s() CRITICAL! IN DEVICE MODE\n", __func__);
+ return 0;
+ }
+
+ gintsts.d32 = ifxusb_read_core_intr(core_if);
+ gintsts2.d32 = 0;
+
+ if (!gintsts.d32)
+ return 0;
+
+ //Common INT
+ if (gintsts.b.modemismatch)
+ {
+ retval |= handle_mode_mismatch_intr(_ifxhcd);
+ gintsts.b.modemismatch=0;
+ gintsts2.b.modemismatch=1;
+ }
+ if (gintsts.b.otgintr)
+ {
+ retval |= handle_otg_intr(_ifxhcd);
+ gintsts.b.otgintr=0;
+ gintsts2.b.otgintr=1;
+ }
+ if (gintsts.b.conidstschng)
+ {
+ retval |= handle_conn_id_status_change_intr(_ifxhcd);
+ gintsts.b.conidstschng=0;
+ gintsts2.b.conidstschng=1;
+ }
+ if (gintsts.b.disconnect)
+ {
+ retval |= handle_disconnect_intr(_ifxhcd);
+ gintsts.b.disconnect=0;
+ gintsts2.b.disconnect=1;
+ }
+ if (gintsts.b.sessreqintr)
+ {
+ retval |= handle_session_req_intr(_ifxhcd);
+ gintsts.b.sessreqintr=0;
+ gintsts2.b.sessreqintr=1;
+ }
+ if (gintsts.b.wkupintr)
+ {
+ retval |= handle_wakeup_detected_intr(_ifxhcd);
+ gintsts.b.wkupintr=0;
+ gintsts2.b.wkupintr=1;
+ }
+ if (gintsts.b.usbsuspend)
+ {
+ retval |= handle_usb_suspend_intr(_ifxhcd);
+ gintsts.b.usbsuspend=0;
+ gintsts2.b.usbsuspend=1;
+ }
+
+ //Host Int
+ if (gintsts.b.sofintr)
+ {
+ retval |= handle_sof_intr (_ifxhcd);
+ gintsts.b.sofintr=0;
+ gintsts2.b.sofintr=1;
+ }
+ if (gintsts.b.portintr)
+ {
+ retval |= handle_port_intr (_ifxhcd);
+ gintsts.b.portintr=0;
+ gintsts2.b.portintr=1;
+ }
+ if (gintsts.b.hcintr)
+ {
+ int i;
+ haint_data_t haint;
+ haint.d32 = ifxusb_read_host_all_channels_intr(core_if);
+ for (i=0; i<MAX_EPS_CHANNELS && i< core_if->params.host_channels; i++)
+ if (haint.b2.chint & (1 << i))
+ retval |= handle_hc_n_intr (_ifxhcd, i);
+ gintsts.b.hcintr=0;
+ gintsts2.b.hcintr=1;
+ }
+ return retval;
+}
+
diff --git a/package/platform/lantiq/ltq-hcd/src/ifxhcd_queue.c b/package/platform/lantiq/ltq-hcd/src/ifxhcd_queue.c
new file mode 100644
index 0000000..a30fcd0
--- /dev/null
+++ b/package/platform/lantiq/ltq-hcd/src/ifxhcd_queue.c
@@ -0,0 +1,485 @@
+/*****************************************************************************
+ ** FILE NAME : ifxhcd_queue.c
+ ** PROJECT : IFX USB sub-system V3
+ ** MODULES : IFX USB sub-system Host and Device driver
+ ** SRC VERSION : 3.2
+ ** DATE : 1/Jan/2011
+ ** AUTHOR : Chen, Howard
+ ** DESCRIPTION : This file contains the functions to manage Queue Heads and Queue
+ ** Transfer Descriptors.
+ ** FUNCTIONS :
+ ** COMPILER : gcc
+ ** REFERENCE : Synopsys DWC-OTG Driver 2.7
+ ** COPYRIGHT : Copyright (c) 2010
+ ** LANTIQ DEUTSCHLAND GMBH,
+ ** Am Campeon 3, 85579 Neubiberg, Germany
+ **
+ ** 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 of the License, or
+ ** (at your option) any later version.
+ **
+ ** Version Control Section **
+ ** $Author$
+ ** $Date$
+ ** $Revisions$
+ ** $Log$ Revision history
+ *****************************************************************************/
+
+/*
+ * This file contains code fragments from Synopsys HS OTG Linux Software Driver.
+ * For this code the following notice is applicable:
+ *
+ * ==========================================================================
+ *
+ * Synopsys HS OTG Linux Software Driver and documentation (hereinafter,
+ * "Software") is an Unsupported proprietary work of Synopsys, Inc. unless
+ * otherwise expressly agreed to in writing between Synopsys and you.
+ *
+ * The Software IS NOT an item of Licensed Software or Licensed Product under
+ * any End User Software License Agreement or Agreement for Licensed Product
+ * with Synopsys or any supplement thereto. You are permitted to use and
+ * redistribute this Software in source and binary forms, with or without
+ * modification, provided that redistributions of source code must retain this
+ * notice. You may not view, use, disclose, copy or distribute this file or
+ * any information contained herein except pursuant to this license grant from
+ * Synopsys. If you do not agree with this notice, including the disclaimer
+ * below, then you are not authorized to use the Software.
+ *
+ * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" BASIS
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ * ========================================================================== */
+
+/*!
+ \file ifxhcd_queue.c
+ \ingroup IFXUSB_DRIVER_V3
+ \brief This file contains the functions to manage Queue Heads and Queue
+ Transfer Descriptors.
+*/
+#include <linux/version.h>
+#include "ifxusb_version.h"
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/init.h>
+#include <linux/device.h>
+#include <linux/errno.h>
+#include <linux/list.h>
+#include <linux/interrupt.h>
+#include <linux/string.h>
+
+#include "ifxusb_plat.h"
+#include "ifxusb_regs.h"
+#include "ifxusb_cif.h"
+#include "ifxhcd.h"
+
+#ifdef __EPQD_DESTROY_TIMEOUT__
+ #define epqh_self_destroy_timeout 300
+ static void eqph_destroy_func(unsigned long _ptr)
+ {
+ ifxhcd_epqh_t *epqh=(ifxhcd_epqh_t *)_ptr;
+ if(epqh)
+ {
+ if(epqh->sysep)
+ {
+ epqh->sysep->hcpriv=NULL;
+ }
+ ifxhcd_epqh_free (epqh);
+ }
+ }
+#endif
+
+/*!
+ \brief This function allocates and initializes a EPQH.
+
+ \param _ifxhcd The HCD state structure for the USB Host controller.
+ \param[in] _urb Holds the information about the device/endpoint that we need
+ to initialize the EPQH.
+
+ \return Returns pointer to the newly allocated EPQH, or NULL on error.
+ */
+static ifxhcd_epqh_t *ifxhcd_epqh_create (ifxhcd_hcd_t *_ifxhcd, struct urb *_urb)
+{
+ ifxhcd_epqh_t *epqh;
+
+ hprt0_data_t hprt0;
+ struct usb_host_endpoint *sysep = ifxhcd_urb_to_endpoint(_urb);
+
+ /* Allocate memory */
+// epqh=(ifxhcd_epqh_t *) kmalloc (sizeof(ifxhcd_epqh_t), GFP_KERNEL);
+ epqh=(ifxhcd_epqh_t *) kmalloc (sizeof(ifxhcd_epqh_t), GFP_ATOMIC);
+
+ if(epqh == NULL)
+ return NULL;
+
+ memset (epqh, 0, sizeof (ifxhcd_epqh_t));
+
+ epqh->sysep=sysep;
+
+ epqh->devno=_urb->dev->devnum;
+
+ epqh->ifxhcd=_ifxhcd;
+ epqh->phase=EPQH_IDLE;
+
+ /* Initialize EPQH */
+ switch (usb_pipetype(_urb->pipe))
+ {
+ case PIPE_CONTROL : epqh->ep_type = IFXUSB_EP_TYPE_CTRL; break;
+ case PIPE_BULK : epqh->ep_type = IFXUSB_EP_TYPE_BULK; break;
+ case PIPE_ISOCHRONOUS: epqh->ep_type = IFXUSB_EP_TYPE_ISOC; break;
+ case PIPE_INTERRUPT : epqh->ep_type = IFXUSB_EP_TYPE_INTR; break;
+ }
+
+ usb_settoggle(_urb->dev, usb_pipeendpoint (_urb->pipe), !usb_pipein(_urb->pipe), IFXUSB_HC_PID_DATA0);
+ epqh->mps = usb_maxpacket(_urb->dev, _urb->pipe, !(usb_pipein(_urb->pipe)));
+
+ INIT_LIST_HEAD(&epqh->urbd_list);
+ #ifdef __STRICT_ORDER__
+ INIT_LIST_HEAD(&epqh->release_list);
+ #endif
+ INIT_LIST_HEAD(&epqh->ql);
+ INIT_LIST_HEAD(&epqh->ql_all);
+ INIT_URBD_LIST(epqh);
+
+ epqh->hc = NULL;
+
+ /* FS/LS Enpoint on HS Hub
+ * NOT virtual root hub */
+ epqh->need_split = 0;
+ hprt0.d32 = ifxusb_read_hprt0 (&_ifxhcd->core_if);
+ if (hprt0.b.prtspd == IFXUSB_HPRT0_PRTSPD_HIGH_SPEED &&
+ ((_urb->dev->speed == USB_SPEED_LOW) ||
+ (_urb->dev->speed == USB_SPEED_FULL)) &&
+ (_urb->dev->tt) && (_urb->dev->tt->hub) && (_urb->dev->tt->hub->devnum != 1))
+ {
+ IFX_DEBUGPL(DBG_HCD, "QH init: EP %d: TT found at hub addr %d, for port %d\n",
+ usb_pipeendpoint(_urb->pipe), _urb->dev->tt->hub->devnum,
+ _urb->dev->ttport);
+ epqh->need_split = 1;
+ }
+
+ if (epqh->ep_type == IFXUSB_EP_TYPE_INTR ||
+ epqh->ep_type == IFXUSB_EP_TYPE_ISOC)
+ {
+ /* Compute scheduling parameters once and save them. */
+ epqh->interval = _urb->interval;
+ if(epqh->need_split)
+ epqh->interval *= 8;
+ }
+
+ #ifdef __EN_ISOC__
+ if (epqh->ep_type == IFXUSB_EP_TYPE_ISOC)
+ _ifxhcd->isoc_ep_count++;
+ #endif
+
+ epqh->period_counter=0;
+
+ #ifdef __EPQD_DESTROY_TIMEOUT__
+ /* Start a timer for this transfer. */
+ init_timer(&epqh->destroy_timer);
+ epqh->destroy_timer.function = eqph_destroy_func;
+ epqh->destroy_timer.data = (unsigned long)(epqh);
+ #endif
+
+ #ifdef __DEBUG__
+ IFX_DEBUGPL(DBG_HCD , "IFXUSB HCD EPQH Initialized\n");
+ IFX_DEBUGPL(DBG_HCDV, "IFXUSB HCD EPQH - epqh = %p\n", epqh);
+ IFX_DEBUGPL(DBG_HCDV, "IFXUSB HCD EPQH - Device Address = %d EP %d, %s\n",
+ _urb->dev->devnum,
+ usb_pipeendpoint(_urb->pipe),
+ usb_pipein(_urb->pipe) == USB_DIR_IN ? "IN" : "OUT");
+ IFX_DEBUGPL(DBG_HCDV, "IFXUSB HCD EPQH - Speed = %s\n",
+ ({ char *speed; switch (_urb->dev->speed) {
+ case USB_SPEED_LOW: speed = "low" ; break;
+ case USB_SPEED_FULL: speed = "full"; break;
+ case USB_SPEED_HIGH: speed = "high"; break;
+ default: speed = "?"; break;
+ }; speed;}));
+ IFX_DEBUGPL(DBG_HCDV, "IFXUSB HCD EPQH - Type = %s\n",
+ ({
+ char *type; switch (epqh->ep_type)
+ {
+ case IFXUSB_EP_TYPE_ISOC: type = "isochronous"; break;
+ case IFXUSB_EP_TYPE_INTR: type = "interrupt" ; break;
+ case IFXUSB_EP_TYPE_CTRL: type = "control" ; break;
+ case IFXUSB_EP_TYPE_BULK: type = "bulk" ; break;
+ default: type = "?"; break;
+ };
+ type;
+ }));
+ if (epqh->ep_type == IFXUSB_EP_TYPE_INTR)
+ IFX_DEBUGPL(DBG_HCDV, "IFXUSB HCD EPQH - interval = %d\n", epqh->interval);
+ #endif
+
+ LOCK_EPQH_LIST_ALL(_ifxhcd);
+ list_add_tail(&epqh->ql_all, &_ifxhcd->epqh_list_all);
+ UNLOCK_EPQH_LIST_ALL(_ifxhcd);
+
+ LOCK_EPQH_LIST(_ifxhcd);
+ switch (epqh->ep_type)
+ {
+ case IFXUSB_EP_TYPE_CTRL:
+ case IFXUSB_EP_TYPE_BULK:
+
+ list_add_tail(&epqh->ql, &_ifxhcd->epqh_list_np);
+ break;
+ case IFXUSB_EP_TYPE_INTR:
+ list_add_tail(&epqh->ql, &_ifxhcd->epqh_list_intr);
+ break;
+ #ifdef __EN_ISOC__
+ case IFXUSB_EP_TYPE_ISOC:
+ list_add_tail(&epqh->ql, &_ifxhcd->epqh_list_isoc);
+
+ break;
+ #endif
+ }
+ UNLOCK_EPQH_LIST(_ifxhcd);
+ return epqh;
+}
+
+
+
+
+
+
+/*!
+ \brief Free the EPQH. EPQH should already be removed from a list.
+ URBD list should already be empty if called from URB Dequeue.
+
+ \param[in] _epqh The EPQH to free.
+ */
+void ifxhcd_epqh_free (ifxhcd_epqh_t *_epqh)
+{
+ unsigned long flags;
+ if(!_epqh)
+ return;
+
+ if(_epqh->sysep) _epqh->sysep->hcpriv=NULL;
+ _epqh->sysep=NULL;
+
+ local_irq_save (flags);
+ if (!list_empty(&_epqh->urbd_list))
+ IFX_WARN("%s() invalid epqh state\n",__func__);
+ else
+ {
+ LOCK_EPQH_LIST_ALL(_epqh->ifxhcd);
+ if (!list_empty(&_epqh->ql_all))
+ list_del_init (&_epqh->ql_all);
+ UNLOCK_EPQH_LIST_ALL(_epqh->ifxhcd);
+
+ LOCK_EPQH_LIST(_epqh->ifxhcd);
+ if (!list_empty(&_epqh->ql))
+ list_del_init (&_epqh->ql);
+ UNLOCK_EPQH_LIST(_epqh->ifxhcd);
+
+ #ifdef __EPQD_DESTROY_TIMEOUT__
+ del_timer(&_epqh->destroy_timer);
+ #endif
+ kfree (_epqh);
+ }
+ local_irq_restore (flags);
+}
+
+
+void ifxhcd_epqh_idle(ifxhcd_epqh_t *_epqh)
+{
+ unsigned long flags;
+ local_irq_save(flags);
+ LOCK_URBD_LIST(_epqh);
+ if (list_empty(&_epqh->urbd_list))
+ {
+ if(_epqh->ep_type == IFXUSB_EP_TYPE_ISOC || _epqh->ep_type == IFXUSB_EP_TYPE_INTR)
+ _epqh->phase=EPQH_STDBY;
+ else
+ {
+ _epqh->phase=EPQH_IDLE;
+ #ifdef __EPQD_DESTROY_TIMEOUT__
+ del_timer(&_epqh->destroy_timer);
+ _epqh->destroy_timer.expires = jiffies + (HZ*epqh_self_destroy_timeout);
+ add_timer(&_epqh->destroy_timer );
+ #endif
+ }
+ }
+ else
+ {
+ _epqh->phase=EPQH_READY;
+ #ifdef __EPQD_DESTROY_TIMEOUT__
+ del_timer(&_epqh->destroy_timer);
+ #endif
+ }
+ UNLOCK_URBD_LIST(_epqh);
+ local_irq_restore(flags);
+}
+
+
+void ifxhcd_epqh_idle_periodic(ifxhcd_epqh_t *_epqh)
+{
+ unsigned long flags;
+ if(_epqh->ep_type != IFXUSB_EP_TYPE_ISOC && _epqh->ep_type != IFXUSB_EP_TYPE_INTR && _epqh->phase!=EPQH_STDBY)
+ return;
+
+ local_irq_save(flags);
+ LOCK_URBD_LIST(_epqh);
+ if (!list_empty(&_epqh->urbd_list))
+ IFX_WARN("%s() invalid epqh state(not empty)\n",__func__);
+
+ _epqh->phase=EPQH_IDLE;
+
+ #ifdef __EPQD_DESTROY_TIMEOUT__
+ del_timer(&_epqh->destroy_timer);
+ _epqh->destroy_timer.expires = jiffies + (HZ*epqh_self_destroy_timeout);
+ add_timer(&_epqh->destroy_timer );
+ #endif
+
+ #ifdef __EN_ISOC__
+ if (_epqh->ep_type == IFXUSB_EP_TYPE_ISOC)
+ _epqh->ifxhcd->isoc_ep_count--;
+ #endif
+ UNLOCK_URBD_LIST(_epqh);
+ local_irq_restore(flags);
+}
+
+
+ifxhcd_epqh_t *ifxhcd_urbd_create (ifxhcd_hcd_t *_ifxhcd,struct urb *_urb)
+{
+ ifxhcd_urbd_t *urbd;
+ struct usb_host_endpoint *sysep;
+ ifxhcd_epqh_t *epqh=NULL;
+ unsigned long flags;
+
+ local_irq_save(flags);
+
+ sysep = ifxhcd_urb_to_endpoint(_urb);
+
+ LOCK_EPQH_LIST_ALL(_ifxhcd);
+ epqh = sysep_to_epqh(_ifxhcd, sysep);
+
+ if (!epqh)
+ {
+ sysep->hcpriv = NULL;
+ epqh = ifxhcd_epqh_create (_ifxhcd, _urb);
+ }
+ UNLOCK_EPQH_LIST_ALL(_ifxhcd);
+
+ if (!epqh)
+ {
+ IFX_ERROR("EPQH Error alloc\n");
+ local_irq_restore (flags);
+ return (ifxhcd_epqh_t *)NULL;
+ }
+ if(epqh->phase==EPQH_DISABLING)
+ {
+ IFX_ERROR("EPQH Error alloc while disabling\n");
+ local_irq_restore (flags);
+ return (ifxhcd_epqh_t *)NULL;
+ }
+ sysep->hcpriv = epqh;
+
+ if(_urb->hcpriv)
+ {
+ IFX_WARN("%s() Previous urb->hcpriv exist %p\n",__func__,_urb->hcpriv);
+ #if 1
+ local_irq_restore (flags);
+ return (ifxhcd_epqh_t *)NULL;
+ #else
+ urbd = _urb->hcpriv;
+ if(urbd->epqh!=epqh)
+ IFX_WARN("%s() Previous urb->hcpriv exist %p and epqh not the same %p %p\n",__func__,_urb->hcpriv,urbd->epqh,epqh);
+ #endif
+ }
+ else
+ {
+ urbd = (ifxhcd_urbd_t *) kmalloc (sizeof(ifxhcd_urbd_t), GFP_ATOMIC);
+ if (!urbd)
+ {
+ local_irq_restore (flags);
+ return (ifxhcd_epqh_t *)NULL;
+ }
+ memset (urbd, 0, sizeof (ifxhcd_urbd_t));
+ INIT_LIST_HEAD(&urbd->ql);
+ }
+
+ _urb->hcpriv = urbd;
+ urbd->urb = _urb;
+ urbd->epqh = epqh;
+ urbd->status= -EINPROGRESS;
+
+ urbd->is_in=usb_pipein(_urb->pipe) ? 1 : 0;
+#define URB_NO_SETUP_DMA_MAP 0
+ #ifdef __EN_ISOC__
+ if(epqh->ep_type == IFXUSB_EP_TYPE_ISOC)
+ {
+ if(_urb->transfer_flags && URB_NO_TRANSFER_DMA_MAP)
+ urbd->xfer_buff = (uint8_t *) (KSEG1ADDR((uint32_t *)_urb->transfer_dma));
+ else
+ urbd->xfer_buff = (uint8_t *) _urb->transfer_buffer;
+ }
+ else
+ #endif
+ {
+ urbd->xfer_len=_urb->transfer_buffer_length;
+ if(urbd->xfer_len>0)
+ {
+ if(_urb->transfer_flags && URB_NO_TRANSFER_DMA_MAP)
+ urbd->xfer_buff = (uint8_t *) (KSEG1ADDR((uint32_t *)_urb->transfer_dma));
+ else
+ urbd->xfer_buff = (uint8_t *) _urb->transfer_buffer;
+ }
+ }
+
+ #if 1 // cache write-back, so DMA engine can get correct content. Precaution
+ if(urbd->xfer_len)
+ dma_cache_wback_inv((unsigned long)urbd->xfer_buff, urbd->xfer_len);
+ #endif
+
+ if(epqh->ep_type == IFXUSB_EP_TYPE_CTRL)
+ {
+ if(_urb->transfer_flags && URB_NO_SETUP_DMA_MAP)
+ urbd->setup_buff = (uint8_t *) (KSEG1ADDR((uint32_t *)_urb->setup_dma));
+ else
+ urbd->setup_buff = (uint8_t *) _urb->setup_packet;
+ #if 1 // cache write-back, so DMA engine can get correct content. Precaution
+ dma_cache_wback_inv((unsigned long)urbd->setup_buff, 16);
+ #endif
+ }
+
+ LOCK_URBD_LIST(epqh);
+ if (!list_empty(&urbd->ql))
+ list_del_init(&urbd->ql);
+ list_add_tail(&urbd->ql, &epqh->urbd_list);
+ epqh->urbd_count++;
+ UNLOCK_URBD_LIST(epqh);
+
+ local_irq_restore (flags);
+ return epqh;
+}
+
+
+
+ifxhcd_epqh_t * sysep_to_epqh(ifxhcd_hcd_t *_ifxhcd, struct usb_host_endpoint *_sysep)
+{
+ ifxhcd_epqh_t *epqh;
+
+ LOCK_EPQH_LIST_ALL(_ifxhcd);
+ list_for_each_entry( epqh, &_ifxhcd->epqh_list_all, ql_all)
+ {
+ if(epqh->sysep==_sysep)
+ {
+ UNLOCK_EPQH_LIST_ALL(_ifxhcd);
+ return epqh;
+ }
+ }
+ UNLOCK_EPQH_LIST_ALL(_ifxhcd);
+ return NULL;
+}
+
diff --git a/package/platform/lantiq/ltq-hcd/src/ifxusb_cif.c b/package/platform/lantiq/ltq-hcd/src/ifxusb_cif.c
new file mode 100644
index 0000000..9f02625
--- /dev/null
+++ b/package/platform/lantiq/ltq-hcd/src/ifxusb_cif.c
@@ -0,0 +1,1686 @@
+/*****************************************************************************
+ ** FILE NAME : ifxusb_cif.c
+ ** PROJECT : IFX USB sub-system V3
+ ** MODULES : IFX USB sub-system Host and Device driver
+ ** SRC VERSION : 1.0
+ ** SRC VERSION : 3.2
+ ** DATE : 1/Jan/2011
+ ** DESCRIPTION : The Core Interface provides basic services for accessing and
+ ** managing the IFX USB hardware. These services are used by both the
+ ** Host Controller Driver and the Peripheral Controller Driver.
+ ** FUNCTIONS :
+ ** COMPILER : gcc
+ ** REFERENCE : Synopsys DWC-OTG Driver 2.7
+ ** COPYRIGHT : Copyright (c) 2010
+ ** LANTIQ DEUTSCHLAND GMBH,
+ ** Am Campeon 3, 85579 Neubiberg, Germany
+ **
+ ** 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 of the License, or
+ ** (at your option) any later version.
+ **
+ ** Version Control Section **
+ ** $Author$
+ ** $Date$
+ ** $Revisions$
+ ** $Log$ Revision history
+ *****************************************************************************/
+
+/*
+ * This file contains code fragments from Synopsys HS OTG Linux Software Driver.
+ * For this code the following notice is applicable:
+ *
+ * ==========================================================================
+ *
+ * Synopsys HS OTG Linux Software Driver and documentation (hereinafter,
+ * "Software") is an Unsupported proprietary work of Synopsys, Inc. unless
+ * otherwise expressly agreed to in writing between Synopsys and you.
+ *
+ * The Software IS NOT an item of Licensed Software or Licensed Product under
+ * any End User Software License Agreement or Agreement for Licensed Product
+ * with Synopsys or any supplement thereto. You are permitted to use and
+ * redistribute this Software in source and binary forms, with or without
+ * modification, provided that redistributions of source code must retain this
+ * notice. You may not view, use, disclose, copy or distribute this file or
+ * any information contained herein except pursuant to this license grant from
+ * Synopsys. If you do not agree with this notice, including the disclaimer
+ * below, then you are not authorized to use the Software.
+ *
+ * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" BASIS
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ * ========================================================================== */
+
+/*!
+ \file ifxusb_cif.c
+ \ingroup IFXUSB_DRIVER_V3
+ \brief This file contains the interface to the IFX USB Core.
+*/
+
+#include <linux/version.h>
+#include "ifxusb_version.h"
+
+#include <asm/byteorder.h>
+#include <asm/unaligned.h>
+
+#ifdef __DEBUG__
+ #include <linux/jiffies.h>
+#include <linux/platform_device.h>
+#include <linux/kernel.h>
+#include <linux/ioport.h>
+#endif
+
+
+#include "ifxusb_plat.h"
+#include "ifxusb_regs.h"
+#include "ifxusb_cif.h"
+
+
+#ifdef __IS_DEVICE__
+ #include "ifxpcd.h"
+#endif
+
+#ifdef __IS_HOST__
+ #include "ifxhcd.h"
+#endif
+
+#include <linux/mm.h>
+
+#include <linux/gfp.h>
+
+#include <lantiq_soc.h>
+
+#if defined(__UEIP__)
+ #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__) || defined(__IS_AMAZON_SE__)
+ #ifndef USB_CTRL_PMU_SETUP
+ #define USB_CTRL_PMU_SETUP(__x) USB0_CTRL_PMU_SETUP(__x)
+ #endif
+ #ifndef USB_PHY_PMU_SETUP
+ #define USB_PHY_PMU_SETUP(__x) USB0_PHY_PMU_SETUP(__x)
+ #endif
+ #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__) || defined(__IS_AMAZON_SE__)
+#endif // defined(__UEIP__)
+
+/*!
+ \brief This function is called to allocate buffer of specified size.
+ The allocated buffer is mapped into DMA accessable address.
+ \param size Size in BYTE to be allocated
+ \param clear 0: don't do clear after buffer allocated, other: do clear to zero
+ \return 0/NULL: Fail; uncached pointer of allocated buffer
+ */
+#ifdef __IS_HOST__
+void *ifxusb_alloc_buf_h(size_t size, int clear)
+#else
+void *ifxusb_alloc_buf_d(size_t size, int clear)
+#endif
+{
+ uint32_t *cached,*uncached;
+ uint32_t totalsize,page;
+
+ if(!size)
+ return 0;
+
+ size=(size+3)&0xFFFFFFFC;
+ totalsize=size + 12;
+ page=get_order(totalsize);
+
+ cached = (void *) __get_free_pages(( GFP_ATOMIC | GFP_DMA), page);
+
+ if(!cached)
+ {
+ IFX_PRINT("%s Allocation Failed size:%d\n",__func__,size);
+ return NULL;
+ }
+
+ uncached = (uint32_t *)(KSEG1ADDR(cached));
+ if(clear)
+ memset(uncached, 0, totalsize);
+
+ *(uncached+0)=totalsize;
+ *(uncached+1)=page;
+ *(uncached+2)=(uint32_t)cached;
+ return (void *)(uncached+3);
+}
+
+
+/*!
+ \brief This function is called to free allocated buffer.
+ \param vaddr the uncached pointer of the buffer
+ */
+#ifdef __IS_HOST__
+void ifxusb_free_buf_h(void *vaddr)
+#else
+void ifxusb_free_buf_d(void *vaddr)
+#endif
+{
+ uint32_t totalsize,page;
+ uint32_t *cached,*uncached;
+
+ if(vaddr != NULL)
+ {
+ uncached=vaddr;
+ uncached-=3;
+ totalsize=*(uncached+0);
+ page=*(uncached+1);
+ cached=(uint32_t *)(*(uncached+2));
+ if(totalsize && page==get_order(totalsize) && cached==(uint32_t *)(KSEG0ADDR(uncached)))
+ {
+ free_pages((unsigned long)cached, page);
+ return;
+ }
+ // the memory is not allocated by ifxusb_alloc_buf. Allowed but must be careful.
+ return;
+ }
+}
+
+
+
+/*!
+ \brief This function is called to initialize the IFXUSB CSR data
+ structures. The register addresses in the device and host
+ structures are initialized from the base address supplied by the
+ caller. The calling function must make the OS calls to get the
+ base address of the IFXUSB controller registers.
+
+ \param _core_if Pointer of core_if structure
+ \param _irq irq number
+ \param _reg_base_addr Base address of IFXUSB core registers
+ \param _fifo_base_addr Fifo base address
+ \param _fifo_dbg_addr Fifo debug address
+ \return 0: success;
+ */
+#ifdef __IS_HOST__
+int ifxusb_core_if_init_h(ifxusb_core_if_t *_core_if,
+#else
+int ifxusb_core_if_init_d(ifxusb_core_if_t *_core_if,
+#endif
+ int _irq,
+ uint32_t _reg_base_addr,
+ uint32_t _fifo_base_addr,
+ uint32_t _fifo_dbg_addr)
+{
+ int retval = 0;
+ uint32_t *reg_base =NULL;
+ uint32_t *fifo_base =NULL;
+ uint32_t *fifo_dbg =NULL;
+
+ int i;
+
+ IFX_DEBUGPL(DBG_CILV, "%s(%p,%d,0x%08X,0x%08X,0x%08X)\n", __func__,
+ _core_if,
+ _irq,
+ _reg_base_addr,
+ _fifo_base_addr,
+ _fifo_dbg_addr);
+
+ if( _core_if == NULL)
+ {
+ IFX_ERROR("%s() invalid _core_if\n", __func__);
+ retval = -ENOMEM;
+ goto fail;
+ }
+
+ //memset(_core_if, 0, sizeof(ifxusb_core_if_t));
+
+ _core_if->irq=_irq;
+
+ reg_base =ioremap_nocache(_reg_base_addr , IFXUSB_IOMEM_SIZE );
+ fifo_base =ioremap_nocache(_fifo_base_addr, IFXUSB_FIFOMEM_SIZE);
+ fifo_dbg =ioremap_nocache(_fifo_dbg_addr , IFXUSB_FIFODBG_SIZE);
+ if( reg_base == NULL || fifo_base == NULL || fifo_dbg == NULL)
+ {
+ IFX_ERROR("%s() usb ioremap() failed\n", __func__);
+ retval = -ENOMEM;
+ goto fail;
+ }
+
+ _core_if->core_global_regs = (ifxusb_core_global_regs_t *)reg_base;
+
+ /*
+ * Attempt to ensure this device is really a IFXUSB Controller.
+ * Read and verify the SNPSID register contents. The value should be
+ * 0x45F42XXX
+ */
+ {
+ int32_t snpsid;
+ snpsid = ifxusb_rreg(&_core_if->core_global_regs->gsnpsid);
+ if ((snpsid & 0xFFFFF000) != 0x4F542000)
+ {
+ IFX_ERROR("%s() snpsid error(0x%08x) failed\n", __func__,snpsid);
+ retval = -EINVAL;
+ goto fail;
+ }
+ _core_if->snpsid=snpsid;
+ }
+
+ #ifdef __IS_HOST__
+ _core_if->host_global_regs = (ifxusb_host_global_regs_t *)
+ ((uint32_t)reg_base + IFXUSB_HOST_GLOBAL_REG_OFFSET);
+ _core_if->hprt0 = (uint32_t*)((uint32_t)reg_base + IFXUSB_HOST_PORT_REGS_OFFSET);
+
+ for (i=0; i<MAX_EPS_CHANNELS; i++)
+ {
+ _core_if->hc_regs[i] = (ifxusb_hc_regs_t *)
+ ((uint32_t)reg_base + IFXUSB_HOST_CHAN_REGS_OFFSET +
+ (i * IFXUSB_CHAN_REGS_OFFSET));
+ IFX_DEBUGPL(DBG_CILV, "hc_reg[%d]->hcchar=%p\n",
+ i, &_core_if->hc_regs[i]->hcchar);
+ }
+ #endif //__IS_HOST__
+
+ #ifdef __IS_DEVICE__
+ _core_if->dev_global_regs =
+ (ifxusb_device_global_regs_t *)((uint32_t)reg_base + IFXUSB_DEV_GLOBAL_REG_OFFSET);
+
+ for (i=0; i<MAX_EPS_CHANNELS; i++)
+ {
+ _core_if->in_ep_regs[i] = (ifxusb_dev_in_ep_regs_t *)
+ ((uint32_t)reg_base + IFXUSB_DEV_IN_EP_REG_OFFSET +
+ (i * IFXUSB_EP_REG_OFFSET));
+ _core_if->out_ep_regs[i] = (ifxusb_dev_out_ep_regs_t *)
+ ((uint32_t)reg_base + IFXUSB_DEV_OUT_EP_REG_OFFSET +
+ (i * IFXUSB_EP_REG_OFFSET));
+ IFX_DEBUGPL(DBG_CILV, "in_ep_regs[%d]->diepctl=%p/%p %p/0x%08X/0x%08X\n",
+ i, &_core_if->in_ep_regs[i]->diepctl, _core_if->in_ep_regs[i],
+ reg_base,IFXUSB_DEV_IN_EP_REG_OFFSET,(i * IFXUSB_EP_REG_OFFSET)
+ );
+ IFX_DEBUGPL(DBG_CILV, "out_ep_regs[%d]->doepctl=%p/%p %p/0x%08X/0x%08X\n",
+ i, &_core_if->out_ep_regs[i]->doepctl, _core_if->out_ep_regs[i],
+ reg_base,IFXUSB_DEV_OUT_EP_REG_OFFSET,(i * IFXUSB_EP_REG_OFFSET)
+ );
+ }
+ #endif //__IS_DEVICE__
+
+ /* Setting the FIFO and other Address. */
+ for (i=0; i<MAX_EPS_CHANNELS; i++)
+ {
+ _core_if->data_fifo[i] = fifo_base + (i * IFXUSB_DATA_FIFO_SIZE);
+ IFX_DEBUGPL(DBG_CILV, "data_fifo[%d]=0x%08x\n",
+ i, (unsigned)_core_if->data_fifo[i]);
+ }
+
+ _core_if->data_fifo_dbg = fifo_dbg;
+ _core_if->pcgcctl = (uint32_t*)(((uint32_t)reg_base) + IFXUSB_PCGCCTL_OFFSET);
+
+ /*
+ * Store the contents of the hardware configuration registers here for
+ * easy access later.
+ */
+ _core_if->hwcfg1.d32 = ifxusb_rreg(&_core_if->core_global_regs->ghwcfg1);
+ _core_if->hwcfg2.d32 = ifxusb_rreg(&_core_if->core_global_regs->ghwcfg2);
+ _core_if->hwcfg3.d32 = ifxusb_rreg(&_core_if->core_global_regs->ghwcfg3);
+ _core_if->hwcfg4.d32 = ifxusb_rreg(&_core_if->core_global_regs->ghwcfg4);
+
+ IFX_DEBUGPL(DBG_CILV,"hwcfg1=%08x\n",_core_if->hwcfg1.d32);
+ IFX_DEBUGPL(DBG_CILV,"hwcfg2=%08x\n",_core_if->hwcfg2.d32);
+ IFX_DEBUGPL(DBG_CILV,"hwcfg3=%08x\n",_core_if->hwcfg3.d32);
+ IFX_DEBUGPL(DBG_CILV,"hwcfg4=%08x\n",_core_if->hwcfg4.d32);
+
+
+ #ifdef __DED_FIFO__
+ {
+ unsigned int countdown=0xFFFF;
+ IFX_PRINT("Waiting for PHY Clock Lock!\n");
+ while(--countdown && !( ifxusb_rreg(&_core_if->core_global_regs->grxfsiz) & (1<<9)))
+ {
+ UDELAY(1);
+ }
+ if(countdown)
+ IFX_PRINT("PHY Clock Locked!\n");
+ else
+ IFX_PRINT("PHY Clock Not Locked! %08X\n",ifxusb_rreg(&_core_if->core_global_regs->grxfsiz));
+ }
+ #endif
+
+ /* Create new workqueue and init works */
+#if 0
+ _core_if->wq_usb = create_singlethread_workqueue(_core_if->core_name);
+
+ if(_core_if->wq_usb == 0)
+ {
+ IFX_DEBUGPL(DBG_CIL, "Creation of wq_usb failed\n");
+ retval = -EINVAL;
+ goto fail;
+ }
+
+ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
+ INIT_WORK(&core_if->w_conn_id, w_conn_id_status_change, core_if);
+ INIT_WORK(&core_if->w_wkp, w_wakeup_detected, core_if);
+ #else
+ INIT_WORK(&core_if->w_conn_id, w_conn_id_status_change);
+ INIT_DELAYED_WORK(&core_if->w_wkp, w_wakeup_detected);
+ #endif
+#endif
+ return 0;
+
+fail:
+ if( reg_base != NULL) iounmap(reg_base );
+ if( fifo_base != NULL) iounmap(fifo_base);
+ if( fifo_dbg != NULL) iounmap(fifo_dbg );
+ return retval;
+}
+
+/*!
+ \brief This function free the mapped address in the IFXUSB CSR data structures.
+ \param _core_if Pointer of core_if structure
+ */
+#ifdef __IS_HOST__
+void ifxusb_core_if_remove_h(ifxusb_core_if_t *_core_if)
+#else
+void ifxusb_core_if_remove_d(ifxusb_core_if_t *_core_if)
+#endif
+{
+ /* Disable all interrupts */
+ if( _core_if->core_global_regs != NULL)
+ {
+ gusbcfg_data_t usbcfg ={.d32 = 0};
+ usbcfg.d32 = ifxusb_rreg( &_core_if->core_global_regs->gusbcfg);
+ usbcfg.b.ForceDevMode=0;
+ usbcfg.b.ForceHstMode=0;
+ ifxusb_wreg( &_core_if->core_global_regs->gusbcfg,usbcfg.d32);
+ ifxusb_mreg( &_core_if->core_global_regs->gahbcfg, 1, 0);
+ ifxusb_wreg( &_core_if->core_global_regs->gintmsk, 0);
+ }
+
+ if( _core_if->core_global_regs != NULL) iounmap(_core_if->core_global_regs );
+ if( _core_if->data_fifo[0] != NULL) iounmap(_core_if->data_fifo[0] );
+ if( _core_if->data_fifo_dbg != NULL) iounmap(_core_if->data_fifo_dbg );
+
+#if 0
+ if (_core_if->wq_usb)
+ destroy_workqueue(_core_if->wq_usb);
+#endif
+ memset(_core_if, 0, sizeof(ifxusb_core_if_t));
+}
+
+
+
+
+/*!
+ \brief This function enbles the controller's Global Interrupt in the AHB Config register.
+ \param _core_if Pointer of core_if structure
+ */
+#ifdef __IS_HOST__
+void ifxusb_enable_global_interrupts_h( ifxusb_core_if_t *_core_if )
+#else
+void ifxusb_enable_global_interrupts_d( ifxusb_core_if_t *_core_if )
+#endif
+{
+ gahbcfg_data_t ahbcfg ={ .d32 = 0};
+ ahbcfg.b.glblintrmsk = 1; /* Enable interrupts */
+ ifxusb_mreg(&_core_if->core_global_regs->gahbcfg, 0, ahbcfg.d32);
+}
+
+/*!
+ \brief This function disables the controller's Global Interrupt in the AHB Config register.
+ \param _core_if Pointer of core_if structure
+ */
+#ifdef __IS_HOST__
+void ifxusb_disable_global_interrupts_h( ifxusb_core_if_t *_core_if )
+#else
+void ifxusb_disable_global_interrupts_d( ifxusb_core_if_t *_core_if )
+#endif
+{
+ gahbcfg_data_t ahbcfg ={ .d32 = 0};
+ ahbcfg.b.glblintrmsk = 1; /* Enable interrupts */
+ ifxusb_mreg(&_core_if->core_global_regs->gahbcfg, ahbcfg.d32, 0);
+}
+
+
+
+
+/*!
+ \brief Flush Tx and Rx FIFO.
+ \param _core_if Pointer of core_if structure
+ */
+#ifdef __IS_HOST__
+void ifxusb_flush_both_fifo_h( ifxusb_core_if_t *_core_if )
+#else
+void ifxusb_flush_both_fifo_d( ifxusb_core_if_t *_core_if )
+#endif
+{
+ ifxusb_core_global_regs_t *global_regs = _core_if->core_global_regs;
+ volatile grstctl_t greset ={ .d32 = 0};
+ int count = 0;
+
+ IFX_DEBUGPL((DBG_CIL|DBG_PCDV), "%s\n", __func__);
+ greset.b.rxfflsh = 1;
+ greset.b.txfflsh = 1;
+ greset.b.txfnum = 0x10;
+ greset.b.intknqflsh=1;
+ greset.b.hstfrm=1;
+ ifxusb_wreg( &global_regs->grstctl, greset.d32 );
+
+ do
+ {
+ greset.d32 = ifxusb_rreg( &global_regs->grstctl);
+ if (++count > 10000)
+ {
+ IFX_WARN("%s() HANG! GRSTCTL=%0x\n", __func__, greset.d32);
+ break;
+ }
+ } while (greset.b.rxfflsh == 1 || greset.b.txfflsh == 1);
+ /* Wait for 3 PHY Clocks*/
+ UDELAY(1);
+}
+
+/*!
+ \brief Flush a Tx FIFO.
+ \param _core_if Pointer of core_if structure
+ \param _num Tx FIFO to flush. ( 0x10 for ALL TX FIFO )
+ */
+#ifdef __IS_HOST__
+void ifxusb_flush_tx_fifo_h( ifxusb_core_if_t *_core_if, const int _num )
+#else
+void ifxusb_flush_tx_fifo_d( ifxusb_core_if_t *_core_if, const int _num )
+#endif
+{
+ ifxusb_core_global_regs_t *global_regs = _core_if->core_global_regs;
+ volatile grstctl_t greset ={ .d32 = 0};
+ int count = 0;
+
+ IFX_DEBUGPL((DBG_CIL|DBG_PCDV), "Flush Tx FIFO %d\n", _num);
+
+ greset.b.intknqflsh=1;
+ greset.b.txfflsh = 1;
+ greset.b.txfnum = _num;
+ ifxusb_wreg( &global_regs->grstctl, greset.d32 );
+
+ do
+ {
+ greset.d32 = ifxusb_rreg( &global_regs->grstctl);
+ if (++count > 10000&&(_num==0 ||_num==0x10))
+ {
+ IFX_WARN("%s() HANG! GRSTCTL=%0x GNPTXSTS=0x%08x\n",
+ __func__, greset.d32,
+ ifxusb_rreg( &global_regs->gnptxsts));
+ break;
+ }
+ } while (greset.b.txfflsh == 1);
+ /* Wait for 3 PHY Clocks*/
+ UDELAY(1);
+}
+
+
+/*!
+ \brief Flush Rx FIFO.
+ \param _core_if Pointer of core_if structure
+ */
+#ifdef __IS_HOST__
+void ifxusb_flush_rx_fifo_h( ifxusb_core_if_t *_core_if )
+#else
+void ifxusb_flush_rx_fifo_d( ifxusb_core_if_t *_core_if )
+#endif
+{
+ ifxusb_core_global_regs_t *global_regs = _core_if->core_global_regs;
+ volatile grstctl_t greset ={ .d32 = 0};
+ int count = 0;
+
+ IFX_DEBUGPL((DBG_CIL|DBG_PCDV), "%s\n", __func__);
+ greset.b.rxfflsh = 1;
+ ifxusb_wreg( &global_regs->grstctl, greset.d32 );
+
+ do
+ {
+ greset.d32 = ifxusb_rreg( &global_regs->grstctl);
+ if (++count > 10000)
+ {
+ IFX_WARN("%s() HANG! GRSTCTL=%0x\n", __func__, greset.d32);
+ break;
+ }
+ } while (greset.b.rxfflsh == 1);
+ /* Wait for 3 PHY Clocks*/
+ UDELAY(1);
+}
+
+
+#define SOFT_RESET_DELAY 100 /*!< Delay in msec of detection after soft-reset of usb core */
+
+/*!
+ \brief Do a soft reset of the core. Be careful with this because it
+ resets all the internal state machines of the core.
+ \param _core_if Pointer of core_if structure
+ */
+#ifdef __IS_HOST__
+int ifxusb_core_soft_reset_h(ifxusb_core_if_t *_core_if)
+#else
+int ifxusb_core_soft_reset_d(ifxusb_core_if_t *_core_if)
+#endif
+{
+ ifxusb_core_global_regs_t *global_regs = _core_if->core_global_regs;
+ volatile grstctl_t greset ={ .d32 = 0};
+ int count = 0;
+
+ IFX_DEBUGPL(DBG_CILV, "%s\n", __func__);
+ /* Wait for AHB master IDLE state. */
+ do
+ {
+ UDELAY(10);
+ greset.d32 = ifxusb_rreg( &global_regs->grstctl);
+ if (++count > 100000)
+ {
+ IFX_WARN("%s() HANG! AHB Idle GRSTCTL=%0x %x\n", __func__,
+ greset.d32, greset.b.ahbidle);
+ break;
+ }
+ } while (greset.b.ahbidle == 0);
+
+ UDELAY(1);
+
+ /* Core Soft Reset */
+ count = 0;
+ greset.b.csftrst = 1;
+ ifxusb_wreg( &global_regs->grstctl, greset.d32 );
+
+ #ifdef SOFT_RESET_DELAY
+ MDELAY(SOFT_RESET_DELAY);
+ #endif
+
+ do
+ {
+ UDELAY(10);
+ greset.d32 = ifxusb_rreg( &global_regs->grstctl);
+ if (++count > 100000)
+ {
+ IFX_WARN("%s() HANG! Soft Reset GRSTCTL=%0x\n", __func__, greset.d32);
+ return -1;
+ }
+ } while (greset.b.csftrst == 1);
+
+ #ifdef SOFT_RESET_DELAY
+ MDELAY(SOFT_RESET_DELAY);
+ #endif
+
+ // This is to reset the PHY of VR9
+ #if defined(__IS_VR9__)
+ if(_core_if->core_no==0)
+ {
+ set_bit (4, VR9_RCU_USBRESET2);
+ MDELAY(50);
+ clear_bit (4, VR9_RCU_USBRESET2);
+ }
+ else
+ {
+ set_bit (5, VR9_RCU_USBRESET2);
+ MDELAY(50);
+ clear_bit (5, VR9_RCU_USBRESET2);
+ }
+ MDELAY(50);
+ #endif //defined(__IS_VR9__)
+
+ IFX_PRINT("USB core #%d soft-reset\n",_core_if->core_no);
+
+ return 0;
+}
+
+/*!
+ \brief Turn on the USB Core Power
+ \param _core_if Pointer of core_if structure
+*/
+#ifdef __IS_HOST__
+void ifxusb_power_on_h (ifxusb_core_if_t *_core_if)
+#else
+void ifxusb_power_on_d (ifxusb_core_if_t *_core_if)
+#endif
+{
+ IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
+ #if defined(__UEIP__)
+
+ // set clock gating
+ #if defined(__IS_TWINPASS) || defined(__IS_DANUBE__)
+ set_bit (4, (volatile unsigned long *)DANUBE_CGU_IFCCR);
+ set_bit (5, (volatile unsigned long *)DANUBE_CGU_IFCCR);
+ #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ #if defined(__IS_AMAZON_SE__)
+ // clear_bit (4, (volatile unsigned long *)AMAZON_SE_CGU_IFCCR);
+ clear_bit (5, (volatile unsigned long *)AMAZON_SE_CGU_IFCCR);
+ #endif //defined(__IS_AMAZON_SE__)
+ #if defined(__IS_AR9__)
+ set_bit (0, (volatile unsigned long *)AR9_CGU_IFCCR);
+ set_bit (1, (volatile unsigned long *)AR9_CGU_IFCCR);
+ #endif //defined(__IS_AR9__)
+ #if defined(__IS_VR9__)
+// set_bit (0, (volatile unsigned long *)VR9_CGU_IFCCR);
+// set_bit (1, (volatile unsigned long *)VR9_CGU_IFCCR);
+ #endif //defined(__IS_VR9__)
+ #if defined(__IS_AR10__)
+// set_bit (0, (volatile unsigned long *)VR9_CGU_IFCCR);
+// set_bit (1, (volatile unsigned long *)VR9_CGU_IFCCR);
+ #endif //defined(__IS_AR10__)
+
+ MDELAY(50);
+#define PMU_AHBM BIT(15)
+#define PMU_USB0 BIT(6)
+#define PMU_USB1 BIT(27)
+#define PMU_USB0_P BIT(0)
+#define PMU_USB1_P BIT(26)
+ // set power
+ ltq_pmu_enable(PMU_AHBM);
+ #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__) || defined(__IS_AMAZON_SE__)
+ ltq_pmu_enable(PMU_USB0);
+ //#if defined(__IS_TWINPASS__)
+ // ifxusb_enable_afe_oc();
+ //#endif
+ #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__) || defined(__IS_AMAZON_SE__)
+ #if defined(__IS_AR9__) || defined(__IS_VR9__)
+ if(_core_if->core_no==0)
+ ltq_pmu_enable(PMU_USB0);
+ else
+ ltq_pmu_enable(PMU_USB1);
+ #endif //defined(__IS_AR9__) || defined(__IS_VR9__)
+ #if defined(__IS_AR10__)
+ //if(_core_if->core_no==0)
+ // USB0_CTRL_PMU_SETUP(IFX_PMU_ENABLE);
+ //else
+ // USB1_CTRL_PMU_SETUP(IFX_PMU_ENABLE);
+ #endif //defined(__IS_AR10__)
+
+ MDELAY(50);
+
+ if(_core_if->pcgcctl)
+ {
+ pcgcctl_data_t pcgcctl = {.d32=0};
+ pcgcctl.b.gatehclk = 1;
+ ifxusb_mreg(_core_if->pcgcctl, pcgcctl.d32, 0);
+ }
+
+
+ if(_core_if->core_global_regs)
+ {
+ // PHY configurations.
+ #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
+ #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ #if defined(__IS_AMAZON_SE__)
+ ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
+ #endif //defined(__IS_AMAZON_SE__)
+ #if defined(__IS_AR9__)
+ ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
+ #endif //defined(__IS_AR9__)
+ #if defined(__IS_VR9__)
+ //ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
+ #endif //defined(__IS_VR9__)
+ #if defined(__IS_AR10__)
+ //ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
+ #endif //defined(__IS_AR10__)
+ }
+ #else //defined(__UEIP__)
+ // set clock gating
+ #if defined(__IS_TWINPASS) || defined(__IS_DANUBE__)
+ set_bit (4, (volatile unsigned long *)DANUBE_CGU_IFCCR);
+ set_bit (5, (volatile unsigned long *)DANUBE_CGU_IFCCR);
+ #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ #if defined(__IS_AMAZON_SE__)
+ // clear_bit (4, (volatile unsigned long *)AMAZON_SE_CGU_IFCCR);
+ clear_bit (5, (volatile unsigned long *)AMAZON_SE_CGU_IFCCR);
+ #endif //defined(__IS_AMAZON_SE__)
+ #if defined(__IS_AR9__)
+ set_bit (0, (volatile unsigned long *)AMAZON_S_CGU_IFCCR);
+ set_bit (1, (volatile unsigned long *)AMAZON_S_CGU_IFCCR);
+ #endif //defined(__IS_AR9__)
+
+ MDELAY(50);
+
+ // set power
+ #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ clear_bit (6, (volatile unsigned long *)DANUBE_PMU_PWDCR);//USB
+ clear_bit (9, (volatile unsigned long *)DANUBE_PMU_PWDCR);//DSL
+ clear_bit (15, (volatile unsigned long *)DANUBE_PMU_PWDCR);//AHB
+ #if defined(__IS_TWINPASS__)
+ ifxusb_enable_afe_oc();
+ #endif
+ #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ #if defined(__IS_AMAZON_SE__)
+ clear_bit (6, (volatile unsigned long *)AMAZON_SE_PMU_PWDCR);
+ clear_bit (9, (volatile unsigned long *)AMAZON_SE_PMU_PWDCR);
+ clear_bit (15, (volatile unsigned long *)AMAZON_SE_PMU_PWDCR);
+ #endif //defined(__IS_AMAZON_SE__)
+ #if defined(__IS_AR9__)
+ if(_core_if->core_no==0)
+ clear_bit (6, (volatile unsigned long *)AMAZON_S_PMU_PWDCR);//USB
+ else
+ clear_bit (27, (volatile unsigned long *)AMAZON_S_PMU_PWDCR);//USB
+ clear_bit (9, (volatile unsigned long *)AMAZON_S_PMU_PWDCR);//DSL
+ clear_bit (15, (volatile unsigned long *)AMAZON_S_PMU_PWDCR);//AHB
+ #endif //defined(__IS_AR9__)
+
+ if(_core_if->core_global_regs)
+ {
+ // PHY configurations.
+ #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
+ #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ #if defined(__IS_AMAZON_SE__)
+ ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
+ #endif //defined(__IS_AMAZON_SE__)
+ #if defined(__IS_AR9__)
+ ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
+ #endif //defined(__IS_AR9__)
+ }
+
+ #endif //defined(__UEIP__)
+}
+
+/*!
+ \brief Turn off the USB Core Power
+ \param _core_if Pointer of core_if structure
+*/
+#ifdef __IS_HOST__
+void ifxusb_power_off_h (ifxusb_core_if_t *_core_if)
+#else
+void ifxusb_power_off_d (ifxusb_core_if_t *_core_if)
+#endif
+
+{
+ #ifdef __IS_HOST__
+ ifxusb_phy_power_off_h (_core_if);
+ #else
+ ifxusb_phy_power_off_d (_core_if);
+ #endif
+
+ #if defined(__UEIP__)
+ //AHBM_PMU_SETUP(IFX_PMU_DISABLE);
+ // set power
+ if(_core_if->pcgcctl)
+ {
+ pcgcctl_data_t pcgcctl = {.d32=0};
+ pcgcctl.b.gatehclk = 1;
+ pcgcctl.b.stoppclk = 1;
+ ifxusb_mreg(_core_if->pcgcctl, 0, pcgcctl.d32);
+ }
+ #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__) || defined(__IS_AMAZON_SE__)
+ //USB_CTRL_PMU_SETUP(IFX_PMU_DISABLE);
+ #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__) || defined(__IS_AMAZON_SE__)
+ #if defined(__IS_AR9__) || defined(__IS_VR9__)
+ /* if(_core_if->core_no==0)
+ USB0_CTRL_PMU_SETUP(IFX_PMU_DISABLE);
+ else
+ USB1_CTRL_PMU_SETUP(IFX_PMU_DISABLE);*/
+ #endif //defined(__IS_AR9__) || defined(__IS_VR9__)
+ #if defined(__IS_AR10__)
+ //if(_core_if->core_no==0)
+ // USB0_CTRL_PMU_SETUP(IFX_PMU_DISABLE);
+ //else
+ // USB1_CTRL_PMU_SETUP(IFX_PMU_DISABLE);
+ #endif //defined(__IS_AR10__)
+ #else //defined(__UEIP__)
+ // set power
+ #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ set_bit (6, (volatile unsigned long *)DANUBE_PMU_PWDCR);//USB
+ #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ #if defined(__IS_AMAZON_SE__)
+ set_bit (6, (volatile unsigned long *)AMAZON_SE_PMU_PWDCR);//USB
+ #endif //defined(__IS_AMAZON_SE__)
+ #if defined(__IS_AR9__)
+ if(_core_if->core_no==0)
+ set_bit (6, (volatile unsigned long *)AMAZON_S_PMU_PWDCR);//USB
+ else
+ set_bit (27, (volatile unsigned long *)AMAZON_S_PMU_PWDCR);//USB
+ #endif //defined(__IS_AR9__)
+ #endif //defined(__UEIP__)
+}
+
+/*!
+ \brief Turn on the USB PHY Power
+ \param _core_if Pointer of core_if structure
+*/
+#ifdef __IS_HOST__
+void ifxusb_phy_power_on_h (ifxusb_core_if_t *_core_if)
+#else
+void ifxusb_phy_power_on_d (ifxusb_core_if_t *_core_if)
+#endif
+{
+ #if defined(__UEIP__)
+ if(_core_if->core_global_regs)
+ {
+ #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
+ #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ #if defined(__IS_AMAZON_SE__)
+ ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
+ #endif //defined(__IS_AMAZON_SE__)
+ #if defined(__IS_AR9__)
+ ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
+ #endif //defined(__IS_AR9__)
+ #if ( defined(__IS_VR9__) || defined(__IS_AR10__)) && defined(__PHY_LONG_PREEMP__)
+ if(_core_if->core_no==0)
+ set_bit (0, VR9_RCU_USB_ANA_CFG1A);
+ else
+ set_bit (0, VR9_RCU_USB_ANA_CFG1B);
+ #endif //( defined(__IS_VR9__) || defined(__IS_AR10__)) && defined(__PHY_LONG_PREEMP__)
+
+ if(_core_if->pcgcctl)
+ {
+ pcgcctl_data_t pcgcctl = {.d32=0};
+ pcgcctl.b.stoppclk = 1;
+ ifxusb_mreg(_core_if->pcgcctl, pcgcctl.d32, 0);
+ }
+ }
+
+ #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__) || defined(__IS_AMAZON_SE__)
+ ltq_pmu_enable(PMU_USB0_P);
+ #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__) || defined(__IS_AMAZON_SE__)
+ #if defined(__IS_AR9__) || defined(__IS_VR9__) || defined(__IS_AR10__)
+ if(_core_if->core_no==0)
+ ltq_pmu_enable(PMU_USB0_P);
+ else
+ ltq_pmu_enable(PMU_USB1_P);
+ #endif //defined(__IS_AR9__) || defined(__IS_VR9__)
+
+ // PHY configurations.
+ if(_core_if->core_global_regs)
+ {
+ #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
+ #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ #if defined(__IS_AMAZON_SE__)
+ ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
+ #endif //defined(__IS_AMAZON_SE__)
+ #if defined(__IS_AR9__)
+ ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
+ #endif //defined(__IS_AR9__)
+ #if ( defined(__IS_VR9__) || defined(__IS_AR10__)) && defined(__PHY_LONG_PREEMP__)
+ if(_core_if->core_no==0)
+ set_bit (0, VR9_RCU_USB_ANA_CFG1A);
+ else
+ set_bit (0, VR9_RCU_USB_ANA_CFG1B);
+ #endif //( defined(__IS_VR9__) || defined(__IS_AR10__)) && defined(__PHY_LONG_PREEMP__)
+ }
+ #else //defined(__UEIP__)
+ // PHY configurations.
+ if(_core_if->core_global_regs)
+ {
+ #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
+ #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ #if defined(__IS_AMAZON_SE__)
+ ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
+ #endif //defined(__IS_AMAZON_SE__)
+ #if defined(__IS_AR9__)
+ ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
+ #endif //defined(__IS_AR9__)
+ }
+
+ #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ clear_bit (0, (volatile unsigned long *)DANUBE_PMU_PWDCR);//PHY
+ #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ #if defined(__IS_AMAZON_SE__)
+ clear_bit (0, (volatile unsigned long *)AMAZON_SE_PMU_PWDCR);
+ #endif //defined(__IS_AMAZON_SE__)
+ #if defined(__IS_AR9__)
+ if(_core_if->core_no==0)
+ clear_bit (0, (volatile unsigned long *)AMAZON_S_PMU_PWDCR);//PHY
+ else
+ clear_bit (26, (volatile unsigned long *)AMAZON_S_PMU_PWDCR);//PHY
+ #endif //defined(__IS_AR9__)
+
+ // PHY configurations.
+ if(_core_if->core_global_regs)
+ {
+ #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
+ #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ #if defined(__IS_AMAZON_SE__)
+ ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
+ #endif //defined(__IS_AMAZON_SE__)
+ #if defined(__IS_AR9__)
+ ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
+ #endif //defined(__IS_AR9__)
+ }
+ #endif //defined(__UEIP__)
+}
+
+
+/*!
+ \brief Turn off the USB PHY Power
+ \param _core_if Pointer of core_if structure
+*/
+#ifdef __IS_HOST__
+void ifxusb_phy_power_off_h (ifxusb_core_if_t *_core_if)
+#else
+void ifxusb_phy_power_off_d (ifxusb_core_if_t *_core_if)
+#endif
+{
+ #if defined(__UEIP__)
+ if(_core_if->pcgcctl)
+ {
+ pcgcctl_data_t pcgcctl = {.d32=0};
+ pcgcctl.b.stoppclk = 1;
+ ifxusb_mreg(_core_if->pcgcctl, 0, pcgcctl.d32);
+ }
+ #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__) || defined(__IS_AMAZON_SE__)
+ //USB_PHY_PMU_SETUP(IFX_PMU_DISABLE);
+ #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__) || defined(__IS_AMAZON_SE__)
+ #if defined(__IS_AR9__) || defined(__IS_VR9__) || defined(__IS_AR10__)
+/* if(_core_if->core_no==0)
+ USB0_PHY_PMU_SETUP(IFX_PMU_DISABLE);
+ else
+ USB1_PHY_PMU_SETUP(IFX_PMU_DISABLE);*/
+ #endif // defined(__IS_AR9__) || defined(__IS_VR9__)
+ #else //defined(__UEIP__)
+ #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ set_bit (0, (volatile unsigned long *)DANUBE_PMU_PWDCR);//PHY
+ #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ #if defined(__IS_AMAZON_SE__)
+ set_bit (0, (volatile unsigned long *)AMAZON_SE_PMU_PWDCR);//PHY
+ #endif //defined(__IS_AMAZON_SE__)
+ #if defined(__IS_AR9__)
+ if(_core_if->core_no==0)
+ set_bit (0, (volatile unsigned long *)AMAZON_S_PMU_PWDCR);//PHY
+ else
+ set_bit (26, (volatile unsigned long *)AMAZON_S_PMU_PWDCR);//PHY
+ #endif //defined(__IS_AR9__)
+ #endif //defined(__UEIP__)
+}
+
+
+/*!
+ \brief Reset on the USB Core RCU
+ \param _core_if Pointer of core_if structure
+ */
+#if defined(__IS_VR9__) || defined(__IS_AR10__)
+static int CheckAlready(void)
+{
+ gusbcfg_data_t usbcfg ={.d32 = 0};
+ usbcfg.d32 = ifxusb_rreg((volatile uint32_t *)0xBE10100C);
+ if(usbcfg.b.ForceDevMode)
+ return 1;
+ if(usbcfg.b.ForceHstMode)
+ return 1;
+ usbcfg.d32 = ifxusb_rreg((volatile uint32_t *)0xBE10600C);
+ if(usbcfg.b.ForceDevMode)
+ return 1;
+ if(usbcfg.b.ForceHstMode)
+ return 1;
+ return 0;
+}
+#endif
+
+#ifdef __IS_HOST__
+ void ifxusb_hard_reset_h(ifxusb_core_if_t *_core_if)
+#else
+ void ifxusb_hard_reset_d(ifxusb_core_if_t *_core_if)
+#endif
+{
+ #if defined(__UEIP__)
+ #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ #if defined (__IS_HOST__)
+ clear_bit (DANUBE_USBCFG_HDSEL_BIT, (volatile unsigned long *)DANUBE_RCU_USBCFG);
+ #elif defined (__IS_DEVICE__)
+ set_bit (DANUBE_USBCFG_HDSEL_BIT, (volatile unsigned long *)DANUBE_RCU_USBCFG);
+ #endif
+ #endif //defined(__IS_AMAZON_SE__)
+
+ #if defined(__IS_AMAZON_SE__)
+ #if defined (__IS_HOST__)
+ clear_bit (AMAZON_SE_USBCFG_HDSEL_BIT, (volatile unsigned long *)AMAZON_SE_RCU_USBCFG);
+ #elif defined (__IS_DEVICE__)
+ set_bit (AMAZON_SE_USBCFG_HDSEL_BIT, (volatile unsigned long *)AMAZON_SE_RCU_USBCFG);
+ #endif
+ #endif //defined(__IS_AMAZON_SE__)
+
+ #if defined(__IS_AR9__)
+ if(_core_if->core_no==0)
+ {
+ #if defined (__IS_HOST__)
+ clear_bit (AR9_USBCFG_HDSEL_BIT, (volatile unsigned long *)AR9_RCU_USB1CFG);
+ #elif defined (__IS_DEVICE__)
+ set_bit (AR9_USBCFG_HDSEL_BIT, (volatile unsigned long *)AR9_RCU_USB1CFG);
+ #endif
+ }
+ else
+ {
+ #if defined (__IS_HOST__)
+ clear_bit (AR9_USBCFG_HDSEL_BIT, (volatile unsigned long *)AR9_RCU_USB2CFG);
+ #elif defined (__IS_DEVICE__)
+ set_bit (AR9_USBCFG_HDSEL_BIT, (volatile unsigned long *)AR9_RCU_USB2CFG);
+ #endif
+ }
+ #endif //defined(__IS_AR9__)
+
+ #if defined(__IS_VR9__)
+ if(!CheckAlready())
+ {
+ #if defined (__IS_HOST__)
+ #if defined (__IS_DUAL__)
+ clear_bit (VR9_USBCFG_HDSEL_BIT, (volatile unsigned long *)VR9_RCU_USB1CFG);
+ clear_bit (VR9_USBCFG_HDSEL_BIT, (volatile unsigned long *)VR9_RCU_USB2CFG);
+ #elif defined (__IS_FIRST__)
+ clear_bit (VR9_USBCFG_HDSEL_BIT, (volatile unsigned long *)VR9_RCU_USB1CFG);
+ set_bit (VR9_USBCFG_HDSEL_BIT, (volatile unsigned long *)VR9_RCU_USB2CFG);
+ #elif defined (__IS_SECOND__)
+ set_bit (VR9_USBCFG_HDSEL_BIT, (volatile unsigned long *)VR9_RCU_USB1CFG);
+ clear_bit (VR9_USBCFG_HDSEL_BIT, (volatile unsigned long *)VR9_RCU_USB2CFG);
+ #endif
+ #endif
+ #if defined (__IS_DEVICE__)
+ #if defined (__IS_FIRST__)
+ set_bit (VR9_USBCFG_HDSEL_BIT, (volatile unsigned long *)VR9_RCU_USB1CFG);
+ clear_bit (VR9_USBCFG_HDSEL_BIT, (volatile unsigned long *)VR9_RCU_USB2CFG);
+ #elif defined (__IS_SECOND__)
+ clear_bit (VR9_USBCFG_HDSEL_BIT, (volatile unsigned long *)VR9_RCU_USB1CFG);
+ set_bit (VR9_USBCFG_HDSEL_BIT, (volatile unsigned long *)VR9_RCU_USB2CFG);
+ #endif
+ #endif
+ }
+ #endif //defined(__IS_VR9__)
+
+ #if defined(__IS_AR10__)
+ if(!CheckAlready())
+ {
+ #if defined (__IS_HOST__)
+ #if defined (__IS_DUAL__)
+ clear_bit (AR10_USBCFG_HDSEL_BIT, (volatile unsigned long *)AR10_RCU_USB1CFG);
+ clear_bit (AR10_USBCFG_HDSEL_BIT, (volatile unsigned long *)AR10_RCU_USB2CFG);
+ #elif defined (__IS_FIRST__)
+ clear_bit (AR10_USBCFG_HDSEL_BIT, (volatile unsigned long *)AR10_RCU_USB1CFG);
+ set_bit (AR10_USBCFG_HDSEL_BIT, (volatile unsigned long *)AR10_RCU_USB2CFG);
+ #elif defined (__IS_SECOND__)
+ set_bit (AR10_USBCFG_HDSEL_BIT, (volatile unsigned long *)AR10_RCU_USB1CFG);
+ clear_bit (AR10_USBCFG_HDSEL_BIT, (volatile unsigned long *)AR10_RCU_USB2CFG);
+ #endif
+ #endif
+ #if defined (__IS_DEVICE__)
+ #if defined (__IS_FIRST__)
+ set_bit (AR10_USBCFG_HDSEL_BIT, (volatile unsigned long *)AR10_RCU_USB1CFG);
+ clear_bit (AR10_USBCFG_HDSEL_BIT, (volatile unsigned long *)AR10_RCU_USB2CFG);
+ #elif defined (__IS_SECOND__)
+ clear_bit (AR10_USBCFG_HDSEL_BIT, (volatile unsigned long *)AR10_RCU_USB1CFG);
+ set_bit (AR10_USBCFG_HDSEL_BIT, (volatile unsigned long *)AR10_RCU_USB2CFG);
+ #endif
+ #endif
+ }
+ #endif //defined(__IS_AR10__)
+
+ // set the HC's byte-order to big-endian
+ #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ set_bit (DANUBE_USBCFG_HOST_END_BIT, (volatile unsigned long *)DANUBE_RCU_USBCFG);
+ clear_bit (DANUBE_USBCFG_SLV_END_BIT, (volatile unsigned long *)DANUBE_RCU_USBCFG);
+ #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ #if defined(__IS_AMAZON_SE__)
+ set_bit (AMAZON_SE_USBCFG_HOST_END_BIT, (volatile unsigned long *)AMAZON_SE_RCU_USBCFG);
+ clear_bit (AMAZON_SE_USBCFG_SLV_END_BIT, (volatile unsigned long *)AMAZON_SE_RCU_USBCFG);
+ #endif //defined(__IS_AMAZON_SE__)
+ #if defined(__IS_AR9__)
+ if(_core_if->core_no==0)
+ {
+ set_bit (AR9_USBCFG_HOST_END_BIT, (volatile unsigned long *)AR9_RCU_USB1CFG);
+ clear_bit (AR9_USBCFG_SLV_END_BIT, (volatile unsigned long *)AR9_RCU_USB1CFG);
+ }
+ else
+ {
+ set_bit (AR9_USBCFG_HOST_END_BIT, (volatile unsigned long *)AR9_RCU_USB2CFG);
+ clear_bit (AR9_USBCFG_SLV_END_BIT, (volatile unsigned long *)AR9_RCU_USB2CFG);
+ }
+ #endif //defined(__IS_AR9__)
+ #if defined(__IS_VR9__)
+ if(_core_if->core_no==0)
+ {
+ set_bit (VR9_USBCFG_HOST_END_BIT, (volatile unsigned long *)VR9_RCU_USB1CFG);
+ clear_bit (VR9_USBCFG_SLV_END_BIT, (volatile unsigned long *)VR9_RCU_USB1CFG);
+ }
+ else
+ {
+ set_bit (VR9_USBCFG_HOST_END_BIT, (volatile unsigned long *)VR9_RCU_USB2CFG);
+ clear_bit (VR9_USBCFG_SLV_END_BIT, (volatile unsigned long *)VR9_RCU_USB2CFG);
+ }
+ #endif //defined(__IS_VR9__)
+ #if defined(__IS_AR10__)
+ if(_core_if->core_no==0)
+ {
+ set_bit (AR10_USBCFG_HOST_END_BIT, (volatile unsigned long *)AR10_RCU_USB1CFG);
+ clear_bit (AR10_USBCFG_SLV_END_BIT, (volatile unsigned long *)AR10_RCU_USB1CFG);
+ }
+ else
+ {
+ set_bit (AR10_USBCFG_HOST_END_BIT, (volatile unsigned long *)AR10_RCU_USB2CFG);
+ clear_bit (AR10_USBCFG_SLV_END_BIT, (volatile unsigned long *)AR10_RCU_USB2CFG);
+ }
+ #endif //defined(__IS_AR10__)
+
+ #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ set_bit (4, DANUBE_RCU_RESET);
+ MDELAY(50);
+ clear_bit (4, DANUBE_RCU_RESET);
+ MDELAY(50);
+ #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+
+ #if defined(__IS_AMAZON_SE__)
+ set_bit (4, AMAZON_SE_RCU_RESET);
+ MDELAY(50);
+ clear_bit (4, AMAZON_SE_RCU_RESET);
+ MDELAY(50);
+ #endif //defined(__IS_AMAZON_SE__)
+
+ #if defined(__IS_AR9__)
+ if(_core_if->core_no==0)
+ {
+ set_bit (4, AR9_RCU_USBRESET);
+ MDELAY(50);
+ clear_bit (4, AR9_RCU_USBRESET);
+ }
+ else
+ {
+ set_bit (28, AR9_RCU_USBRESET);
+ MDELAY(50);
+ clear_bit (28, AR9_RCU_USBRESET);
+ }
+ MDELAY(50);
+ #endif //defined(__IS_AR9__)
+ #if defined(__IS_VR9__)
+ if(!CheckAlready())
+ {
+ set_bit (4, VR9_RCU_USBRESET);
+ MDELAY(50);
+ clear_bit (4, VR9_RCU_USBRESET);
+ MDELAY(50);
+ }
+ #endif //defined(__IS_VR9__)
+ #if defined(__IS_AR10__)
+ if(!CheckAlready())
+ {
+ set_bit (4, AR10_RCU_USBRESET);
+ MDELAY(50);
+ clear_bit (4, AR10_RCU_USBRESET);
+ MDELAY(50);
+ }
+ #endif //defined(__IS_AR10__)
+
+ #if defined(__IS_TWINPASS__)
+ ifxusb_enable_afe_oc();
+ #endif
+
+ if(_core_if->core_global_regs)
+ {
+ // PHY configurations.
+ #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
+ #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ #if defined(__IS_AMAZON_SE__)
+ ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
+ #endif //defined(__IS_AMAZON_SE__)
+ #if defined(__IS_AR9__)
+ ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
+ #endif //defined(__IS_AR9__)
+ #if defined(__IS_VR9__)
+ // ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
+ #endif //defined(__IS_VR9__)
+ #if defined(__IS_AR10__)
+ // ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
+ #endif //defined(__IS_AR10__)
+ }
+ #else //defined(__UEIP__)
+ #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ #if defined (__IS_HOST__)
+ clear_bit (DANUBE_USBCFG_HDSEL_BIT, (volatile unsigned long *)DANUBE_RCU_USBCFG);
+ #elif defined (__IS_DEVICE__)
+ set_bit (DANUBE_USBCFG_HDSEL_BIT, (volatile unsigned long *)DANUBE_RCU_USBCFG);
+ #endif
+ #endif //defined(__IS_AMAZON_SE__)
+
+ #if defined(__IS_AMAZON_SE__)
+ #if defined (__IS_HOST__)
+ clear_bit (AMAZON_SE_USBCFG_HDSEL_BIT, (volatile unsigned long *)AMAZON_SE_RCU_USBCFG);
+ #elif defined (__IS_DEVICE__)
+ set_bit (AMAZON_SE_USBCFG_HDSEL_BIT, (volatile unsigned long *)AMAZON_SE_RCU_USBCFG);
+ #endif
+ #endif //defined(__IS_AMAZON_SE__)
+
+ #if defined(__IS_AR9__)
+ if(_core_if->core_no==0)
+ {
+ #if defined (__IS_HOST__)
+ clear_bit (AMAZON_S_USBCFG_HDSEL_BIT, (volatile unsigned long *)AMAZON_S_RCU_USB1CFG);
+ #elif defined (__IS_DEVICE__)
+ set_bit (AMAZON_S_USBCFG_HDSEL_BIT, (volatile unsigned long *)AMAZON_S_RCU_USB1CFG);
+ #endif
+ }
+ else
+ {
+ #if defined (__IS_HOST__)
+ clear_bit (AMAZON_S_USBCFG_HDSEL_BIT, (volatile unsigned long *)AMAZON_S_RCU_USB2CFG);
+ #elif defined (__IS_DEVICE__)
+ set_bit (AMAZON_S_USBCFG_HDSEL_BIT, (volatile unsigned long *)AMAZON_S_RCU_USB2CFG);
+ #endif
+ }
+ #endif //defined(__IS_AR9__)
+
+ // set the HC's byte-order to big-endian
+ #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ set_bit (DANUBE_USBCFG_HOST_END_BIT, (volatile unsigned long *)DANUBE_RCU_USBCFG);
+ clear_bit (DANUBE_USBCFG_SLV_END_BIT, (volatile unsigned long *)DANUBE_RCU_USBCFG);
+ #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ #if defined(__IS_AMAZON_SE__)
+ set_bit (AMAZON_SE_USBCFG_HOST_END_BIT, (volatile unsigned long *)AMAZON_SE_RCU_USBCFG);
+ clear_bit (AMAZON_SE_USBCFG_SLV_END_BIT, (volatile unsigned long *)AMAZON_SE_RCU_USBCFG);
+ #endif //defined(__IS_AMAZON_SE__)
+ #if defined(__IS_AR9__)
+ if(_core_if->core_no==0)
+ {
+ set_bit (AMAZON_S_USBCFG_HOST_END_BIT, (volatile unsigned long *)AMAZON_S_RCU_USB1CFG);
+ clear_bit (AMAZON_S_USBCFG_SLV_END_BIT, (volatile unsigned long *)AMAZON_S_RCU_USB1CFG);
+ }
+ else
+ {
+ set_bit (AMAZON_S_USBCFG_HOST_END_BIT, (volatile unsigned long *)AMAZON_S_RCU_USB2CFG);
+ clear_bit (AMAZON_S_USBCFG_SLV_END_BIT, (volatile unsigned long *)AMAZON_S_RCU_USB2CFG);
+ }
+ #endif //defined(__IS_AR9__)
+
+ #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ set_bit (4, DANUBE_RCU_RESET);
+ #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ #if defined(__IS_AMAZON_SE__)
+ set_bit (4, AMAZON_SE_RCU_RESET);
+ #endif //defined(__IS_AMAZON_SE__)
+ #if defined(__IS_AR9__)
+ if(_core_if->core_no==0)
+ {
+ set_bit (4, AMAZON_S_RCU_USBRESET);
+ }
+ else
+ {
+ set_bit (28, AMAZON_S_RCU_USBRESET);
+ }
+ #endif //defined(__IS_AR9__)
+
+ MDELAY(50);
+
+ #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ clear_bit (4, DANUBE_RCU_RESET);
+ #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ #if defined(__IS_AMAZON_SE__)
+ clear_bit (4, AMAZON_SE_RCU_RESET);
+ #endif //defined(__IS_AMAZON_SE__)
+ #if defined(__IS_AR9__)
+ if(_core_if->core_no==0)
+ {
+ clear_bit (4, AMAZON_S_RCU_USBRESET);
+ }
+ else
+ {
+ clear_bit (28, AMAZON_S_RCU_USBRESET);
+ }
+ #endif //defined(__IS_AR9__)
+
+ MDELAY(50);
+
+ #if defined(__IS_TWINPASS__)
+ ifxusb_enable_afe_oc();
+ #endif
+
+ if(_core_if->core_global_regs)
+ {
+ // PHY configurations.
+ #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
+ #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ #if defined(__IS_AMAZON_SE__)
+ ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
+ #endif //defined(__IS_AMAZON_SE__)
+ #if defined(__IS_AR9__)
+ ifxusb_wreg (&_core_if->core_global_regs->guid,0x14014);
+ #endif //defined(__IS_AR9__)
+ }
+ #endif //defined(__UEIP__)
+}
+
+#if defined(__GADGET_LED__) || defined(__HOST_LED__)
+ #if defined(__UEIP__)
+ static void *g_usb_led_trigger = NULL;
+ #endif
+
+ void ifxusb_led_init(ifxusb_core_if_t *_core_if)
+ {
+ #if defined(__UEIP__)
+ #if defined(IFX_LEDGPIO_USB_LED) || defined(IFX_LEDLED_USB_LED)
+ if ( !g_usb_led_trigger )
+ {
+ ifx_led_trigger_register("usb_link", &g_usb_led_trigger);
+ if ( g_usb_led_trigger != NULL )
+ {
+ struct ifx_led_trigger_attrib attrib = {0};
+ attrib.delay_on = 250;
+ attrib.delay_off = 250;
+ attrib.timeout = 2000;
+ attrib.def_value = 1;
+ attrib.flags = IFX_LED_TRIGGER_ATTRIB_DELAY_ON | IFX_LED_TRIGGER_ATTRIB_DELAY_OFF | IFX_LED_TRIGGER_ATTRIB_TIMEOUT | IFX_LED_TRIGGER_ATTRIB_DEF_VALUE;
+ IFX_DEBUGP("Reg USB LED!!\n");
+ ifx_led_trigger_set_attrib(g_usb_led_trigger, &attrib);
+ }
+ }
+ #endif
+ #endif //defined(__UEIP__)
+ }
+
+ void ifxusb_led_free(ifxusb_core_if_t *_core_if)
+ {
+ #if defined(__UEIP__)
+ if ( g_usb_led_trigger )
+ {
+ ifx_led_trigger_deregister(g_usb_led_trigger);
+ g_usb_led_trigger = NULL;
+ }
+ #endif //defined(__UEIP__)
+ }
+
+ /*!
+ \brief Turn off the USB 5V VBus Power
+ \param _core_if Pointer of core_if structure
+ */
+ void ifxusb_led(ifxusb_core_if_t *_core_if)
+ {
+ #if defined(__UEIP__)
+ if(g_usb_led_trigger)
+ ifx_led_trigger_activate(g_usb_led_trigger);
+ #else
+ #endif //defined(__UEIP__)
+ }
+#endif // defined(__GADGET_LED__) || defined(__HOST_LED__)
+
+
+
+/*!
+ \brief internal routines for debugging
+ */
+#ifdef __IS_HOST__
+void ifxusb_dump_msg_h(const u8 *buf, unsigned int length)
+#else
+void ifxusb_dump_msg_d(const u8 *buf, unsigned int length)
+#endif
+{
+#ifdef __DEBUG__
+ unsigned int start, num, i;
+ char line[52], *p;
+
+ if (length >= 512)
+ return;
+ start = 0;
+ while (length > 0)
+ {
+ num = min(length, 16u);
+ p = line;
+ for (i = 0; i < num; ++i)
+ {
+ if (i == 8)
+ *p++ = ' ';
+ sprintf(p, " %02x", buf[i]);
+ p += 3;
+ }
+ *p = 0;
+ IFX_PRINT( "%6x: %s\n", start, line);
+ buf += num;
+ start += num;
+ length -= num;
+ }
+#endif
+}
+
+/*!
+ \brief internal routines for debugging, reads the SPRAM and prints its content
+ */
+#ifdef __IS_HOST__
+void ifxusb_dump_spram_h(ifxusb_core_if_t *_core_if)
+#else
+void ifxusb_dump_spram_d(ifxusb_core_if_t *_core_if)
+#endif
+{
+#ifdef __ENABLE_DUMP__
+ volatile uint8_t *addr, *start_addr, *end_addr;
+ uint32_t size;
+ IFX_PRINT("SPRAM Data:\n");
+ start_addr = (void*)_core_if->core_global_regs;
+ IFX_PRINT("Base Address: 0x%8X\n", (uint32_t)start_addr);
+
+ start_addr = (void*)_core_if->data_fifo_dbg;
+ IFX_PRINT("Starting Address: 0x%8X\n", (uint32_t)start_addr);
+
+ size=_core_if->hwcfg3.b.dfifo_depth;
+ size<<=2;
+ size+=0x200;
+ size&=0x0003FFFC;
+
+ end_addr = (void*)_core_if->data_fifo_dbg;
+ end_addr += size;
+
+ for(addr = start_addr; addr < end_addr; addr+=16)
+ {
+ IFX_PRINT("0x%8X: %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X \n", (uint32_t)addr,
+ addr[ 0], addr[ 1], addr[ 2], addr[ 3],
+ addr[ 4], addr[ 5], addr[ 6], addr[ 7],
+ addr[ 8], addr[ 9], addr[10], addr[11],
+ addr[12], addr[13], addr[14], addr[15]
+ );
+ }
+ return;
+#endif //__ENABLE_DUMP__
+}
+
+/*!
+ \brief internal routines for debugging, reads the core global registers and prints them
+ */
+#ifdef __IS_HOST__
+void ifxusb_dump_registers_h(ifxusb_core_if_t *_core_if)
+#else
+void ifxusb_dump_registers_d(ifxusb_core_if_t *_core_if)
+#endif
+{
+#ifdef __ENABLE_DUMP__
+ int i;
+ volatile uint32_t *addr;
+ #ifdef __IS_DEVICE__
+ volatile uint32_t *addri,*addro;
+ #endif
+
+ IFX_PRINT("Core #%d\n",_core_if->core_no);
+ IFX_PRINT("========================================\n");
+ IFX_PRINT("Core Global Registers\n");
+ addr=&_core_if->core_global_regs->gotgctl;
+ IFX_PRINT(" GOTGCTL @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->core_global_regs->gotgint;
+ IFX_PRINT(" GOTGINT @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->core_global_regs->gahbcfg;
+ IFX_PRINT(" GAHBCFG @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->core_global_regs->gusbcfg;
+ IFX_PRINT(" GUSBCFG @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->core_global_regs->grstctl;
+ IFX_PRINT(" GRSTCTL @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->core_global_regs->gintsts;
+ IFX_PRINT(" GINTSTS @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->core_global_regs->gintmsk;
+ IFX_PRINT(" GINTMSK @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->core_global_regs->gi2cctl;
+ IFX_PRINT(" GI2CCTL @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->core_global_regs->gpvndctl;
+ IFX_PRINT(" GPVNDCTL @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->core_global_regs->ggpio;
+ IFX_PRINT(" GGPIO @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->core_global_regs->guid;
+ IFX_PRINT(" GUID @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->core_global_regs->gsnpsid;
+ IFX_PRINT(" GSNPSID @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->core_global_regs->ghwcfg1;
+ IFX_PRINT(" GHWCFG1 @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->core_global_regs->ghwcfg2;
+ IFX_PRINT(" GHWCFG2 @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->core_global_regs->ghwcfg3;
+ IFX_PRINT(" GHWCFG3 @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->core_global_regs->ghwcfg4;
+ IFX_PRINT(" GHWCFG4 @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+
+ addr=_core_if->pcgcctl;
+ IFX_PRINT(" PCGCCTL @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+
+ addr=&_core_if->core_global_regs->grxfsiz;
+ IFX_PRINT(" GRXFSIZ @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+
+ #ifdef __IS_HOST__
+ addr=&_core_if->core_global_regs->gnptxfsiz;
+ IFX_PRINT(" GNPTXFSIZ @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->core_global_regs->hptxfsiz;
+ IFX_PRINT(" HPTXFSIZ @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ #endif //__IS_HOST__
+
+ #ifdef __IS_DEVICE__
+ #ifdef __DED_FIFO__
+ addr=&_core_if->core_global_regs->gnptxfsiz;
+ IFX_PRINT(" GNPTXFSIZ @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ for (i=0; i<= _core_if->hwcfg4.b.num_in_eps; i++)
+ {
+ addr=&_core_if->core_global_regs->dptxfsiz_dieptxf[i];
+ IFX_PRINT(" DPTXFSIZ[%d] @0x%08X : 0x%08X\n",i,(uint32_t)addr,ifxusb_rreg(addr));
+ }
+ #else
+ addr=&_core_if->core_global_regs->gnptxfsiz;
+ IFX_PRINT(" TXFSIZ[00] @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ for (i=0; i< _core_if->hwcfg4.b.num_dev_perio_in_ep; i++)
+ {
+ addr=&_core_if->core_global_regs->dptxfsiz_dieptxf[i];
+ IFX_PRINT(" TXFSIZ[%02d] @0x%08X : 0x%08X\n",i+1,(uint32_t)addr,ifxusb_rreg(addr));
+ }
+ #endif
+ #endif //__IS_DEVICE__
+
+ #ifdef __IS_HOST__
+ IFX_PRINT(" Host Global Registers\n");
+ addr=&_core_if->host_global_regs->hcfg;
+ IFX_PRINT(" HCFG @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->host_global_regs->hfir;
+ IFX_PRINT(" HFIR @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->host_global_regs->hfnum;
+ IFX_PRINT(" HFNUM @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->host_global_regs->hptxsts;
+ IFX_PRINT(" HPTXSTS @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->host_global_regs->haint;
+ IFX_PRINT(" HAINT @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->host_global_regs->haintmsk;
+ IFX_PRINT(" HAINTMSK @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr= _core_if->hprt0;
+ IFX_PRINT(" HPRT0 @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+
+ for (i=0; i<MAX_EPS_CHANNELS; i++)
+ {
+ addr=&_core_if->hc_regs[i]->hcchar;
+ IFX_PRINT(" Host Channel %d Specific Registers\n", i);
+ IFX_PRINT(" HCCHAR @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->hc_regs[i]->hcsplt;
+ IFX_PRINT(" HCSPLT @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->hc_regs[i]->hcint;
+ IFX_PRINT(" HCINT @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->hc_regs[i]->hcintmsk;
+ IFX_PRINT(" HCINTMSK @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->hc_regs[i]->hctsiz;
+ IFX_PRINT(" HCTSIZ @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->hc_regs[i]->hcdma;
+ IFX_PRINT(" HCDMA @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ }
+ #endif //__IS_HOST__
+
+ #ifdef __IS_DEVICE__
+ IFX_PRINT(" Device Global Registers\n");
+ addr=&_core_if->dev_global_regs->dcfg;
+ IFX_PRINT(" DCFG @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->dev_global_regs->dctl;
+ IFX_PRINT(" DCTL @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->dev_global_regs->dsts;
+ IFX_PRINT(" DSTS @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->dev_global_regs->diepmsk;
+ IFX_PRINT(" DIEPMSK @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->dev_global_regs->doepmsk;
+ IFX_PRINT(" DOEPMSK @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->dev_global_regs->daintmsk;
+ IFX_PRINT(" DAINTMSK @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->dev_global_regs->daint;
+ IFX_PRINT(" DAINT @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->dev_global_regs->dvbusdis;
+ IFX_PRINT(" DVBUSID @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ addr=&_core_if->dev_global_regs->dvbuspulse;
+ IFX_PRINT(" DVBUSPULS @0x%08X : 0x%08X\n", (uint32_t)addr,ifxusb_rreg(addr));
+
+ addr=&_core_if->dev_global_regs->dtknqr1;
+ IFX_PRINT(" DTKNQR1 @0x%08X : 0x%08X\n",(uint32_t)addr,ifxusb_rreg(addr));
+ if (_core_if->hwcfg2.b.dev_token_q_depth > 6) {
+ addr=&_core_if->dev_global_regs->dtknqr2;
+ IFX_PRINT(" DTKNQR2 @0x%08X : 0x%08X\n", (uint32_t)addr,ifxusb_rreg(addr));
+ }
+
+ if (_core_if->hwcfg2.b.dev_token_q_depth > 14)
+ {
+ addr=&_core_if->dev_global_regs->dtknqr3_dthrctl;
+ IFX_PRINT(" DTKNQR3_DTHRCTL @0x%08X : 0x%08X\n", (uint32_t)addr, ifxusb_rreg(addr));
+ }
+
+ if (_core_if->hwcfg2.b.dev_token_q_depth > 22)
+ {
+ addr=&_core_if->dev_global_regs->dtknqr4_fifoemptymsk;
+ IFX_PRINT(" DTKNQR4 @0x%08X : 0x%08X\n", (uint32_t)addr, ifxusb_rreg(addr));
+ }
+
+ //for (i=0; i<= MAX_EPS_CHANNELS; i++)
+ //for (i=0; i<= 10; i++)
+ for (i=0; i<= 3; i++)
+ {
+ IFX_PRINT(" Device EP %d Registers\n", i);
+ addri=&_core_if->in_ep_regs[i]->diepctl;addro=&_core_if->out_ep_regs[i]->doepctl;
+ IFX_PRINT(" DEPCTL I: 0x%08X O: 0x%08X\n",ifxusb_rreg(addri),ifxusb_rreg(addro));
+ addro=&_core_if->out_ep_regs[i]->doepfn;
+ IFX_PRINT(" DEPFN I: O: 0x%08X\n",ifxusb_rreg(addro));
+ addri=&_core_if->in_ep_regs[i]->diepint;addro=&_core_if->out_ep_regs[i]->doepint;
+ IFX_PRINT(" DEPINT I: 0x%08X O: 0x%08X\n",ifxusb_rreg(addri),ifxusb_rreg(addro));
+ addri=&_core_if->in_ep_regs[i]->dieptsiz;addro=&_core_if->out_ep_regs[i]->doeptsiz;
+ IFX_PRINT(" DETSIZ I: 0x%08X O: 0x%08X\n",ifxusb_rreg(addri),ifxusb_rreg(addro));
+ addri=&_core_if->in_ep_regs[i]->diepdma;addro=&_core_if->out_ep_regs[i]->doepdma;
+ IFX_PRINT(" DEPDMA I: 0x%08X O: 0x%08X\n",ifxusb_rreg(addri),ifxusb_rreg(addro));
+ addri=&_core_if->in_ep_regs[i]->dtxfsts;
+ IFX_PRINT(" DTXFSTS I: 0x%08X\n",ifxusb_rreg(addri) );
+ addri=&_core_if->in_ep_regs[i]->diepdmab;addro=&_core_if->out_ep_regs[i]->doepdmab;
+ IFX_PRINT(" DEPDMAB I: 0x%08X O: 0x%08X\n",ifxusb_rreg(addri),ifxusb_rreg(addro));
+ }
+ #endif //__IS_DEVICE__
+#endif //__ENABLE_DUMP__
+}
+
+#ifdef __IS_HOST__
+void do_suspend_h(ifxusb_core_if_t *core_if)
+{
+ ifxusb_vbus_off(core_if);
+ mdelay(100);
+ ifxusb_power_off_h(core_if);
+}
+void do_resume_h(ifxusb_core_if_t *core_if)
+{
+ ifxusb_vbus_on(core_if);
+ mdelay(100);
+ ifxusb_power_on_h(core_if);
+ ifxusb_phy_power_on_h(core_if);
+}
+#endif
+#ifdef __IS_DEVICE__
+void do_suspend_d(ifxusb_core_if_t *core_if)
+{
+ ifxusb_power_off_d(core_if);
+}
+void do_resume_d(ifxusb_core_if_t *core_if)
+{
+ dctl_data_t dctl = {.d32=0};
+
+ ifxusb_power_on_d(core_if);
+ ifxusb_phy_power_on_d(core_if);
+ dctl.d32=ifxusb_rreg(&core_if->dev_global_regs->dctl);
+ dctl.b.sftdiscon=1;
+ ifxusb_wreg(&core_if->dev_global_regs->dctl,dctl.d32);
+ mdelay(50);
+ dctl.b.sftdiscon=0;
+ ifxusb_wreg(&core_if->dev_global_regs->dctl,dctl.d32);
+}
+#endif
+
diff --git a/package/platform/lantiq/ltq-hcd/src/ifxusb_cif.h b/package/platform/lantiq/ltq-hcd/src/ifxusb_cif.h
new file mode 100644
index 0000000..5af988f
--- /dev/null
+++ b/package/platform/lantiq/ltq-hcd/src/ifxusb_cif.h
@@ -0,0 +1,767 @@
+/*****************************************************************************
+ ** FILE NAME : ifxusb_cif.h
+ ** PROJECT : IFX USB sub-system V3
+ ** MODULES : IFX USB sub-system Host and Device driver
+ ** SRC VERSION : 3.2
+ ** DATE : 1/Jan/2011
+ ** AUTHOR : Chen, Howard
+ ** DESCRIPTION : The Core Interface provides basic services for accessing and
+ ** managing the IFX USB hardware. These services are used by both the
+ ** Host Controller Driver and the Peripheral Controller Driver.
+ ** FUNCTIONS :
+ ** COMPILER : gcc
+ ** REFERENCE : Synopsys DWC-OTG Driver 2.7
+ ** COPYRIGHT : Copyright (c) 2010
+ ** LANTIQ DEUTSCHLAND GMBH,
+ ** Am Campeon 3, 85579 Neubiberg, Germany
+ **
+ ** 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 of the License, or
+ ** (at your option) any later version.
+ **
+ ** Version Control Section **
+ ** $Author$
+ ** $Date$
+ ** $Revisions$
+ ** $Log$ Revision history
+ *****************************************************************************/
+
+/*
+ * This file contains code fragments from Synopsys HS OTG Linux Software Driver.
+ * For this code the following notice is applicable:
+ *
+ * ==========================================================================
+ *
+ * Synopsys HS OTG Linux Software Driver and documentation (hereinafter,
+ * "Software") is an Unsupported proprietary work of Synopsys, Inc. unless
+ * otherwise expressly agreed to in writing between Synopsys and you.
+ *
+ * The Software IS NOT an item of Licensed Software or Licensed Product under
+ * any End User Software License Agreement or Agreement for Licensed Product
+ * with Synopsys or any supplement thereto. You are permitted to use and
+ * redistribute this Software in source and binary forms, with or without
+ * modification, provided that redistributions of source code must retain this
+ * notice. You may not view, use, disclose, copy or distribute this file or
+ * any information contained herein except pursuant to this license grant from
+ * Synopsys. If you do not agree with this notice, including the disclaimer
+ * below, then you are not authorized to use the Software.
+ *
+ * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" BASIS
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ * ========================================================================== */
+
+/*!
+ \defgroup IFXUSB_DRIVER_V3 IFX USB SS Project
+ \brief IFX USB subsystem V3.x
+ */
+
+/*!
+ \defgroup IFXUSB_CIF Core Interface APIs
+ \ingroup IFXUSB_DRIVER_V3
+ \brief The Core Interface provides basic services for accessing and
+ managing the IFXUSB hardware. These services are used by both the
+ Host Controller Driver and the Peripheral Controller Driver.
+ */
+
+
+/*!
+ \file ifxusb_cif.h
+ \ingroup IFXUSB_DRIVER_V3
+ \brief This file contains the interface to the IFX USB Core.
+ */
+
+#if !defined(__IFXUSB_CIF_H__)
+#define __IFXUSB_CIF_H__
+
+#include <linux/workqueue.h>
+
+#include <linux/version.h>
+#include <asm/param.h>
+
+#include "ifxusb_plat.h"
+#include "ifxusb_regs.h"
+
+#ifdef __DEBUG__
+ #include "linux/timer.h"
+#endif
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#define IFXUSB_PARAM_SPEED_HIGH 0 /*!< Build stage parameter: High Speed */
+#define IFXUSB_PARAM_SPEED_FULL 1 /*!< Build stage parameter: Full Speed */
+
+#define IFXUSB_EP_SPEED_LOW 0 /*!< Run-Time Status: High Speed */
+#define IFXUSB_EP_SPEED_FULL 1 /*!< Run-Time Status: Full Speed */
+#define IFXUSB_EP_SPEED_HIGH 2 /*!< Run-Time Status: Low Speed */
+
+#define IFXUSB_EP_TYPE_CTRL 0 /*!< Run-Time Status: CTRL */
+#define IFXUSB_EP_TYPE_ISOC 1 /*!< Run-Time Status: ISOC */
+#define IFXUSB_EP_TYPE_BULK 2 /*!< Run-Time Status: BULK */
+#define IFXUSB_EP_TYPE_INTR 3 /*!< Run-Time Status: INTR */
+
+#define IFXUSB_HC_PID_DATA0 0 /*!< Run-Time Data Toggle: Data 0 */
+#define IFXUSB_HC_PID_DATA2 1 /*!< Run-Time Data Toggle: Data 2 */
+#define IFXUSB_HC_PID_DATA1 2 /*!< Run-Time Data Toggle: Data 1 */
+#define IFXUSB_HC_PID_MDATA 3 /*!< Run-Time Data Toggle: MData */
+#define IFXUSB_HC_PID_SETUP 3 /*!< Run-Time Data Toggle: Setup */
+
+
+/*!
+ \addtogroup IFXUSB_CIF
+ */
+/*@{*/
+
+/*! typedef ifxusb_params_t
+ \brief IFXUSB Parameters structure.
+ This structure is used for both importing from insmod stage and run-time storage.
+ These parameters define how the IFXUSB controller should be configured.
+ */
+typedef struct ifxusb_params
+{
+ int32_t dma_burst_size; /*!< The DMA Burst size (applicable only for Internal DMA
+ Mode). 0(for single), 1(incr), 4(incr4), 8(incr8) 16(incr16)
+ */
+ /* Translate this to GAHBCFG values */
+ int32_t speed; /*!< Specifies the maximum speed of operation in host and device mode.
+ The actual speed depends on the speed of the attached device and
+ the value of phy_type. The actual speed depends on the speed of the
+ attached device.
+ 0 - High Speed (default)
+ 1 - Full Speed
+ */
+
+ int32_t data_fifo_size; /*!< Total number of dwords in the data FIFO memory. This
+ memory includes the Rx FIFO, non-periodic Tx FIFO, and periodic
+ Tx FIFOs.
+ 32 to 32768
+ */
+ #ifdef __IS_DEVICE__
+ int32_t rx_fifo_size; /*!< Number of dwords in the Rx FIFO in device mode.
+ 16 to 32768
+ */
+
+
+ int32_t tx_fifo_size[MAX_EPS_CHANNELS]; /*!< Number of dwords in each of the Tx FIFOs in device mode.
+ 4 to 768
+ */
+ #ifdef __DED_FIFO__
+ int32_t thr_ctl; /*!< Threshold control on/off */
+ int32_t tx_thr_length; /*!< Threshold length for Tx */
+ int32_t rx_thr_length; /*!< Threshold length for Rx*/
+ #endif
+ #else //__IS_HOST__
+ int32_t host_channels; /*!< The number of host channel registers to use.
+ 1 to 16
+ */
+
+ int32_t rx_fifo_size; /*!< Number of dwords in the Rx FIFO in host mode.
+ 16 to 32768
+ */
+
+ int32_t nperio_tx_fifo_size;/*!< Number of dwords in the non-periodic Tx FIFO in host mode.
+ 16 to 32768
+ */
+
+ int32_t perio_tx_fifo_size; /*!< Number of dwords in the host periodic Tx FIFO.
+ 16 to 32768
+ */
+ #endif //__IS_HOST__
+
+ int32_t max_transfer_size; /*!< The maximum transfer size supported in bytes.
+ 2047 to 65,535
+ */
+
+ int32_t max_packet_count; /*!< The maximum number of packets in a transfer.
+ 15 to 511 (default 511)
+ */
+ int32_t phy_utmi_width; /*!< Specifies the UTMI+ Data Width.
+ 8 or 16 bits (default 16)
+ */
+
+ int32_t turn_around_time_hs; /*!< Specifies the Turn-Around time at HS*/
+ int32_t turn_around_time_fs; /*!< Specifies the Turn-Around time at FS*/
+
+ int32_t timeout_cal_hs; /*!< Specifies the Timeout_Calibration at HS*/
+ int32_t timeout_cal_fs; /*!< Specifies the Timeout_Calibration at FS*/
+} ifxusb_params_t;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+/*! typedef ifxusb_core_if_t
+ \brief The ifx_core_if structure contains information needed to manage
+ the IFX USB controller acting in either host or device mode. It
+ represents the programming view of the controller as a whole.
+ */
+typedef struct ifxusb_core_if
+{
+ ifxusb_params_t params; /*!< Run-time Parameters */
+
+ uint8_t core_no; /*!< core number (used as id when multi-core case */
+ char *core_name; /*!< core name used for registration and informative purpose*/
+ int irq; /*!< irq number this core is hooked */
+
+ /*****************************************************************
+ * Structures and pointers to physical register interface.
+ *****************************************************************/
+ /** Core Global registers starting at offset 000h. */
+ ifxusb_core_global_regs_t *core_global_regs; /*!< pointer to Core Global Registers, offset at 000h */
+
+ /** Host-specific registers */
+ #ifdef __IS_HOST__
+ /** Host Global Registers starting at offset 400h.*/
+ ifxusb_host_global_regs_t *host_global_regs; /*!< pointer to Host Global Registers, offset at 400h */
+ #define IFXUSB_HOST_GLOBAL_REG_OFFSET 0x400
+ /** Host Port 0 Control and Status Register */
+ volatile uint32_t *hprt0; /*!< pointer to HPRT0 Registers, offset at 440h */
+ #define IFXUSB_HOST_PORT_REGS_OFFSET 0x440
+ /** Host Channel Specific Registers at offsets 500h-5FCh. */
+ ifxusb_hc_regs_t *hc_regs[MAX_EPS_CHANNELS]; /*!< pointer to Host-Channel n Registers, offset at 500h */
+ #define IFXUSB_HOST_CHAN_REGS_OFFSET 0x500
+ #define IFXUSB_CHAN_REGS_OFFSET 0x20
+ #endif
+
+ /** Device-specific registers */
+ #ifdef __IS_DEVICE__
+ /** Device Global Registers starting at offset 800h */
+ ifxusb_device_global_regs_t *dev_global_regs; /*!< pointer to Device Global Registers, offset at 800h */
+ #define IFXUSB_DEV_GLOBAL_REG_OFFSET 0x800
+
+ /** Device Logical IN Endpoint-Specific Registers 900h-AFCh */
+ ifxusb_dev_in_ep_regs_t *in_ep_regs[MAX_EPS_CHANNELS]; /*!< pointer to Device IN-EP Registers, offset at 900h */
+ #define IFXUSB_DEV_IN_EP_REG_OFFSET 0x900
+ #define IFXUSB_EP_REG_OFFSET 0x20
+ /** Device Logical OUT Endpoint-Specific Registers B00h-CFCh */
+ ifxusb_dev_out_ep_regs_t *out_ep_regs[MAX_EPS_CHANNELS];/*!< pointer to Device OUT-EP Registers, offset at 900h */
+ #define IFXUSB_DEV_OUT_EP_REG_OFFSET 0xB00
+ #endif
+
+ /** Power and Clock Gating Control Register */
+ volatile uint32_t *pcgcctl; /*!< pointer to Power and Clock Gating Control Registers, offset at E00h */
+ #define IFXUSB_PCGCCTL_OFFSET 0xE00
+
+ /** Push/pop addresses for endpoints or host channels.*/
+ uint32_t *data_fifo[MAX_EPS_CHANNELS]; /*!< pointer to FIFO access windows, offset at 1000h */
+ #define IFXUSB_DATA_FIFO_OFFSET 0x1000
+ #define IFXUSB_DATA_FIFO_SIZE 0x1000
+
+ uint32_t *data_fifo_dbg; /*!< pointer to FIFO debug windows, offset at 1000h */
+
+ /** Hardware Configuration -- stored here for convenience.*/
+ hwcfg1_data_t hwcfg1; /*!< preserved Hardware Configuration 1 */
+ hwcfg2_data_t hwcfg2; /*!< preserved Hardware Configuration 2 */
+ hwcfg3_data_t hwcfg3; /*!< preserved Hardware Configuration 3 */
+ hwcfg4_data_t hwcfg4; /*!< preserved Hardware Configuration 3 */
+ uint32_t snpsid; /*!< preserved SNPSID */
+
+ /*****************************************************************
+ * Run-time informations.
+ *****************************************************************/
+ /* Set to 1 if the core PHY interface bits in USBCFG have been initialized. */
+ uint8_t phy_init_done; /*!< indicated PHY is initialized. */
+
+ #ifdef __IS_HOST__
+ uint8_t queuing_high_bandwidth; /*!< Host mode, Queueing High Bandwidth. */
+ #endif
+
+ #if defined(__UNALIGNED_BUF_ADJ__) || defined(__UNALIGNED_BUF_CHK__)
+ uint32_t unaligned_mask;
+ #endif
+} ifxusb_core_if_t;
+
+/*@}*//*IFXUSB_CIF*/
+
+
+/*!
+ \fn void *ifxusb_alloc_buf(size_t size, int clear)
+ \brief This function is called to allocate buffer of specified size.
+ The allocated buffer is mapped into DMA accessable address.
+ \param size Size in BYTE to be allocated
+ \param clear 0: don't do clear after buffer allocated, other: do clear to zero
+ \return 0/NULL: Fail; uncached pointer of allocated buffer
+ \ingroup IFXUSB_CIF
+ */
+#ifdef __IS_HOST__
+extern void *ifxusb_alloc_buf_h(size_t size, int clear);
+#else
+extern void *ifxusb_alloc_buf_d(size_t size, int clear);
+#endif
+
+
+/*!
+ \fn void ifxusb_free_buf(void *vaddr)
+ \brief This function is called to free allocated buffer.
+ \param vaddr the uncached pointer of the buffer
+ \ingroup IFXUSB_CIF
+ */
+#ifdef __IS_HOST__
+extern void ifxusb_free_buf_h(void *vaddr);
+#else
+extern void ifxusb_free_buf_d(void *vaddr);
+#endif
+
+/*!
+ \fn int ifxusb_core_if_init(ifxusb_core_if_t *_core_if,
+ int _irq,
+ uint32_t _reg_base_addr,
+ uint32_t _fifo_base_addr,
+ uint32_t _fifo_dbg_addr)
+ \brief This function is called to initialize the IFXUSB CSR data
+ structures. The register addresses in the device and host
+ structures are initialized from the base address supplied by the
+ caller. The calling function must make the OS calls to get the
+ base address of the IFXUSB controller registers.
+ \param _core_if Pointer of core_if structure
+ \param _irq irq number
+ \param _reg_base_addr Base address of IFXUSB core registers
+ \param _fifo_base_addr Fifo base address
+ \param _fifo_dbg_addr Fifo debug address
+ \return 0: success;
+ \ingroup IFXUSB_CIF
+ */
+#ifdef __IS_HOST__
+extern int ifxusb_core_if_init_h(ifxusb_core_if_t *_core_if,
+#else
+extern int ifxusb_core_if_init_d(ifxusb_core_if_t *_core_if,
+#endif
+ int _irq,
+ uint32_t _reg_base_addr,
+ uint32_t _fifo_base_addr,
+ uint32_t _fifo_dbg_addr);
+
+
+/*!
+ \fn void ifxusb_core_if_remove(ifxusb_core_if_t *_core_if)
+ \brief This function free the mapped address in the IFXUSB CSR data structures.
+ \param _core_if Pointer of core_if structure
+ \ingroup IFXUSB_CIF
+ */
+#ifdef __IS_HOST__
+extern void ifxusb_core_if_remove_h(ifxusb_core_if_t *_core_if);
+#else
+extern void ifxusb_core_if_remove_d(ifxusb_core_if_t *_core_if);
+#endif
+
+/*!
+ \fn void ifxusb_enable_global_interrupts( ifxusb_core_if_t *_core_if )
+ \brief This function enbles the controller's Global Interrupt in the AHB Config register.
+ \param _core_if Pointer of core_if structure
+ */
+#ifdef __IS_HOST__
+extern void ifxusb_enable_global_interrupts_h( ifxusb_core_if_t *_core_if );
+#else
+extern void ifxusb_enable_global_interrupts_d( ifxusb_core_if_t *_core_if );
+#endif
+
+/*!
+ \fn void ifxusb_disable_global_interrupts( ifxusb_core_if_t *_core_if )
+ \brief This function disables the controller's Global Interrupt in the AHB Config register.
+ \param _core_if Pointer of core_if structure
+ \ingroup IFXUSB_CIF
+ */
+#ifdef __IS_HOST__
+extern void ifxusb_disable_global_interrupts_h( ifxusb_core_if_t *_core_if );
+#else
+extern void ifxusb_disable_global_interrupts_d( ifxusb_core_if_t *_core_if );
+#endif
+
+/*!
+ \fn void ifxusb_flush_tx_fifo( ifxusb_core_if_t *_core_if, const int _num )
+ \brief Flush a Tx FIFO.
+ \param _core_if Pointer of core_if structure
+ \param _num Tx FIFO to flush. ( 0x10 for ALL TX FIFO )
+ \ingroup IFXUSB_CIF
+ */
+#ifdef __IS_HOST__
+extern void ifxusb_flush_tx_fifo_h( ifxusb_core_if_t *_core_if, const int _num );
+#else
+extern void ifxusb_flush_tx_fifo_d( ifxusb_core_if_t *_core_if, const int _num );
+#endif
+
+/*!
+ \fn void ifxusb_flush_rx_fifo( ifxusb_core_if_t *_core_if )
+ \brief Flush Rx FIFO.
+ \param _core_if Pointer of core_if structure
+ \ingroup IFXUSB_CIF
+ */
+#ifdef __IS_HOST__
+extern void ifxusb_flush_rx_fifo_h( ifxusb_core_if_t *_core_if );
+#else
+extern void ifxusb_flush_rx_fifo_d( ifxusb_core_if_t *_core_if );
+#endif
+
+/*!
+ \fn void ifxusb_flush_both_fifo( ifxusb_core_if_t *_core_if )
+ \brief Flush ALL Rx and Tx FIFO.
+ \param _core_if Pointer of core_if structure
+ \ingroup IFXUSB_CIF
+ */
+#ifdef __IS_HOST__
+extern void ifxusb_flush_both_fifo_h( ifxusb_core_if_t *_core_if );
+#else
+extern void ifxusb_flush_both_fifo_d( ifxusb_core_if_t *_core_if );
+#endif
+
+
+/*!
+ \fn int ifxusb_core_soft_reset(ifxusb_core_if_t *_core_if)
+ \brief Do core a soft reset of the core. Be careful with this because it
+ resets all the internal state machines of the core.
+ \param _core_if Pointer of core_if structure
+ \ingroup IFXUSB_CIF
+ */
+#ifdef __IS_HOST__
+extern int ifxusb_core_soft_reset_h(ifxusb_core_if_t *_core_if);
+#else
+extern int ifxusb_core_soft_reset_d(ifxusb_core_if_t *_core_if);
+#endif
+
+
+/*!
+ \brief Turn on the USB Core Power
+ \param _core_if Pointer of core_if structure
+ \ingroup IFXUSB_CIF
+*/
+#ifdef __IS_HOST__
+ extern void ifxusb_power_on_h (ifxusb_core_if_t *_core_if);
+#else
+ extern void ifxusb_power_on_d (ifxusb_core_if_t *_core_if);
+#endif
+
+/*!
+ \fn void ifxusb_power_off (ifxusb_core_if_t *_core_if)
+ \brief Turn off the USB Core Power
+ \param _core_if Pointer of core_if structure
+ \ingroup IFXUSB_CIF
+*/
+#ifdef __IS_HOST__
+ extern void ifxusb_power_off_h (ifxusb_core_if_t *_core_if);
+#else
+ extern void ifxusb_power_off_d (ifxusb_core_if_t *_core_if);
+#endif
+
+/*!
+ \fn void ifxusb_phy_power_on (ifxusb_core_if_t *_core_if)
+ \brief Turn on the USB PHY Power
+ \param _core_if Pointer of core_if structure
+ \ingroup IFXUSB_CIF
+*/
+#ifdef __IS_HOST__
+ extern void ifxusb_phy_power_on_h (ifxusb_core_if_t *_core_if);
+#else
+ extern void ifxusb_phy_power_on_d (ifxusb_core_if_t *_core_if);
+#endif
+
+
+/*!
+ \fn void ifxusb_phy_power_off (ifxusb_core_if_t *_core_if)
+ \brief Turn off the USB PHY Power
+ \param _core_if Pointer of core_if structure
+ \ingroup IFXUSB_CIF
+*/
+#ifdef __IS_HOST__
+ extern void ifxusb_phy_power_off_h (ifxusb_core_if_t *_core_if);
+#else
+ extern void ifxusb_phy_power_off_d (ifxusb_core_if_t *_core_if);
+#endif
+
+/*!
+ \fn void ifxusb_hard_reset(ifxusb_core_if_t *_core_if)
+ \brief Reset on the USB Core RCU
+ \param _core_if Pointer of core_if structure
+ \ingroup IFXUSB_CIF
+ */
+#ifdef __IS_HOST__
+ extern void ifxusb_hard_reset_h(ifxusb_core_if_t *_core_if);
+#else
+ extern void ifxusb_hard_reset_d(ifxusb_core_if_t *_core_if);
+#endif
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+
+#ifdef __IS_HOST__
+ /*!
+ \fn void ifxusb_host_core_init(ifxusb_core_if_t *_core_if, ifxusb_params_t *_params)
+ \brief This function initializes the IFXUSB controller registers for Host mode.
+ This function flushes the Tx and Rx FIFOs and it flushes any entries in the
+ request queues.
+ \param _core_if Pointer of core_if structure
+ \param _params parameters to be set
+ \ingroup IFXUSB_CIF
+ */
+ extern void ifxusb_host_core_init(ifxusb_core_if_t *_core_if, ifxusb_params_t *_params);
+
+ /*!
+ \fn void ifxusb_host_enable_interrupts(ifxusb_core_if_t *_core_if)
+ \brief This function enables the Host mode interrupts.
+ \param _core_if Pointer of core_if structure
+ \ingroup IFXUSB_CIF
+ */
+ extern void ifxusb_host_enable_interrupts(ifxusb_core_if_t *_core_if);
+
+ /*!
+ \fn void ifxusb_host_disable_interrupts(ifxusb_core_if_t *_core_if)
+ \brief This function disables the Host mode interrupts.
+ \param _core_if Pointer of core_if structure
+ \ingroup IFXUSB_CIF
+ */
+ extern void ifxusb_host_disable_interrupts(ifxusb_core_if_t *_core_if);
+
+ #if defined(__IS_TWINPASS__)
+ extern void ifxusb_enable_afe_oc(void);
+ #endif
+
+ /*!
+ \fn void ifxusb_vbus_init(ifxusb_core_if_t *_core_if)
+ \brief This function init the VBUS control.
+ \param _core_if Pointer of core_if structure
+ \ingroup IFXUSB_CIF
+ */
+ extern void ifxusb_vbus_init(ifxusb_core_if_t *_core_if);
+
+ /*!
+ \fn void ifxusb_vbus_free(ifxusb_core_if_t *_core_if)
+ \brief This function free the VBUS control.
+ \param _core_if Pointer of core_if structure
+ \ingroup IFXUSB_CIF
+ */
+ extern void ifxusb_vbus_free(ifxusb_core_if_t *_core_if);
+
+ /*!
+ \fn void ifxusb_vbus_on(ifxusb_core_if_t *_core_if)
+ \brief Turn on the USB 5V VBus Power
+ \param _core_if Pointer of core_if structure
+ \ingroup IFXUSB_CIF
+ */
+ extern void ifxusb_vbus_on(ifxusb_core_if_t *_core_if);
+
+ /*!
+ \fn void ifxusb_vbus_off(ifxusb_core_if_t *_core_if)
+ \brief Turn off the USB 5V VBus Power
+ \param _core_if Pointer of core_if structure
+ \ingroup IFXUSB_CIF
+ */
+ extern void ifxusb_vbus_off(ifxusb_core_if_t *_core_if);
+
+ /*!
+ \fn int ifxusb_vbus(ifxusb_core_if_t *_core_if)
+ \brief Read Current VBus status
+ \param _core_if Pointer of core_if structure
+ \ingroup IFXUSB_CIF
+ */
+ extern int ifxusb_vbus(ifxusb_core_if_t *_core_if);
+#endif
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+
+#ifdef __IS_DEVICE__
+ /*!
+ \fn void ifxusb_dev_enable_interrupts(ifxusb_core_if_t *_core_if)
+ \brief This function enables the Device mode interrupts.
+ \param _core_if Pointer of core_if structure
+ \ingroup IFXUSB_CIF
+ */
+ extern void ifxusb_dev_enable_interrupts(ifxusb_core_if_t *_core_if);
+
+ /*!
+ \fn uint32_t ifxusb_dev_get_frame_number(ifxusb_core_if_t *_core_if)
+ \brief Gets the current USB frame number. This is the frame number from the last SOF packet.
+ \param _core_if Pointer of core_if structure
+ \ingroup IFXUSB_CIF
+ */
+ extern uint32_t ifxusb_dev_get_frame_number(ifxusb_core_if_t *_core_if);
+
+ /*!
+ \fn void ifxusb_dev_ep_set_stall(ifxusb_core_if_t *_core_if, uint8_t _epno, uint8_t _is_in)
+ \brief Set the EP STALL.
+ \param _core_if Pointer of core_if structure
+ \param _epno EP number
+ \param _is_in 1: is IN transfer
+ \ingroup IFXUSB_CIF
+ */
+ extern void ifxusb_dev_ep_set_stall(ifxusb_core_if_t *_core_if, uint8_t _epno, uint8_t _is_in);
+
+ /*!
+ \fn void ifxusb_dev_ep_clear_stall(ifxusb_core_if_t *_core_if, uint8_t _epno, uint8_t _ep_type, uint8_t _is_in)
+ \brief Set the EP STALL.
+ \param _core_if Pointer of core_if structure
+ \param _epno EP number
+ \param _ep_type EP Type
+ \ingroup IFXUSB_CIF
+ */
+ extern void ifxusb_dev_ep_clear_stall(ifxusb_core_if_t *_core_if, uint8_t _epno, uint8_t _ep_type, uint8_t _is_in);
+
+ /*!
+ \fn void ifxusb_dev_core_init(ifxusb_core_if_t *_core_if, ifxusb_params_t *_params)
+ \brief This function initializes the IFXUSB controller registers for Device mode.
+ This function flushes the Tx and Rx FIFOs and it flushes any entries in the
+ request queues.
+ This function validate the imported parameters and store the result in the CIF structure.
+ After
+ \param _core_if Pointer of core_if structure
+ \param _params structure of inported parameters
+ \ingroup IFXUSB_CIF
+ */
+ extern void ifxusb_dev_core_init(ifxusb_core_if_t *_core_if, ifxusb_params_t *_params);
+#endif
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#if defined(__GADGET_LED__) || defined(__HOST_LED__)
+ /*!
+ \fn void ifxusb_led_init(ifxusb_core_if_t *_core_if)
+ \brief This function init the LED control.
+ \param _core_if Pointer of core_if structure
+ \ingroup IFXUSB_CIF
+ */
+ extern void ifxusb_led_init(ifxusb_core_if_t *_core_if);
+
+ /*!
+ \fn void ifxusb_led_free(ifxusb_core_if_t *_core_if)
+ \brief This function free the LED control.
+ \param _core_if Pointer of core_if structure
+ \ingroup IFXUSB_CIF
+ */
+ extern void ifxusb_led_free(ifxusb_core_if_t *_core_if);
+
+ /*!
+ \fn void ifxusb_led(ifxusb_core_if_t *_core_if)
+ \brief This function trigger the LED access.
+ \param _core_if Pointer of core_if structure
+ \ingroup IFXUSB_CIF
+ */
+ extern void ifxusb_led(ifxusb_core_if_t *_core_if);
+#endif
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+/* internal routines for debugging */
+#ifdef __IS_HOST__
+ extern void ifxusb_dump_msg_h(const u8 *buf, unsigned int length);
+ extern void ifxusb_dump_spram_h(ifxusb_core_if_t *_core_if);
+ extern void ifxusb_dump_registers_h(ifxusb_core_if_t *_core_if);
+#else
+ extern void ifxusb_dump_msg_d(const u8 *buf, unsigned int length);
+ extern void ifxusb_dump_spram_d(ifxusb_core_if_t *_core_if);
+ extern void ifxusb_dump_registers_d(ifxusb_core_if_t *_core_if);
+#endif
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+static inline uint32_t ifxusb_read_core_intr(ifxusb_core_if_t *_core_if)
+{
+ return (ifxusb_rreg(&_core_if->core_global_regs->gintsts) &
+ ifxusb_rreg(&_core_if->core_global_regs->gintmsk));
+}
+
+static inline uint32_t ifxusb_read_otg_intr (ifxusb_core_if_t *_core_if)
+{
+ return (ifxusb_rreg (&_core_if->core_global_regs->gotgint));
+}
+
+static inline uint32_t ifxusb_mode(ifxusb_core_if_t *_core_if)
+{
+ return (ifxusb_rreg( &_core_if->core_global_regs->gintsts ) & 0x1);
+}
+static inline uint8_t ifxusb_is_device_mode(ifxusb_core_if_t *_core_if)
+{
+ return (ifxusb_mode(_core_if) != 1);
+}
+static inline uint8_t ifxusb_is_host_mode(ifxusb_core_if_t *_core_if)
+{
+ return (ifxusb_mode(_core_if) == 1);
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifdef __IS_HOST__
+ static inline uint32_t ifxusb_read_hprt0(ifxusb_core_if_t *_core_if)
+ {
+ hprt0_data_t hprt0;
+ hprt0.d32 = ifxusb_rreg(_core_if->hprt0);
+ hprt0.b.prtena = 0;
+ hprt0.b.prtconndet = 0;
+ hprt0.b.prtenchng = 0;
+ hprt0.b.prtovrcurrchng = 0;
+ return hprt0.d32;
+ }
+
+ static inline uint32_t ifxusb_read_host_all_channels_intr (ifxusb_core_if_t *_core_if)
+ {
+ return (ifxusb_rreg (&_core_if->host_global_regs->haint));
+ }
+
+ static inline uint32_t ifxusb_read_host_channel_intr (ifxusb_core_if_t *_core_if, int hc_num)
+ {
+ return (ifxusb_rreg (&_core_if->hc_regs[hc_num]->hcint));
+ }
+#endif
+
+#ifdef __IS_DEVICE__
+ static inline uint32_t ifxusb_read_dev_all_in_ep_intr(ifxusb_core_if_t *_core_if)
+ {
+ uint32_t v;
+ v = ifxusb_rreg(&_core_if->dev_global_regs->daint) &
+ ifxusb_rreg(&_core_if->dev_global_regs->daintmsk);
+ return (v & 0xffff);
+ }
+
+ static inline uint32_t ifxusb_read_dev_all_out_ep_intr(ifxusb_core_if_t *_core_if)
+ {
+ uint32_t v;
+ v = ifxusb_rreg(&_core_if->dev_global_regs->daint) &
+ ifxusb_rreg(&_core_if->dev_global_regs->daintmsk);
+ return ((v & 0xffff0000) >> 16);
+ }
+
+ static inline uint32_t ifxusb_read_dev_in_ep_intr(ifxusb_core_if_t *_core_if, int _ep_num)
+ {
+ uint32_t v;
+ v = ifxusb_rreg(&_core_if->in_ep_regs[_ep_num]->diepint) &
+ ifxusb_rreg(&_core_if->dev_global_regs->diepmsk);
+ return v;
+ }
+
+ static inline uint32_t ifxusb_read_dev_out_ep_intr(ifxusb_core_if_t *_core_if, int _ep_num)
+ {
+ uint32_t v;
+ v = ifxusb_rreg(&_core_if->out_ep_regs[_ep_num]->doepint) &
+ ifxusb_rreg(&_core_if->dev_global_regs->doepmsk);
+ return v;
+ }
+
+#endif
+
+#ifdef __IS_HOST__
+extern void ifxusb_attr_create_h (void *_dev);
+extern void ifxusb_attr_remove_h (void *_dev);
+#else
+extern void ifxusb_attr_create_d (void *_dev);
+extern void ifxusb_attr_remove_d (void *_dev);
+#endif
+
+#ifdef __IS_HOST__
+extern void do_suspend_h(ifxusb_core_if_t *core_if);
+extern void do_resume_h(ifxusb_core_if_t *_core_if);
+#else
+extern void do_suspend_d(ifxusb_core_if_t *core_if);
+extern void do_resume_d(ifxusb_core_if_t *_core_if);
+#endif
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#endif // !defined(__IFXUSB_CIF_H__)
+
diff --git a/package/platform/lantiq/ltq-hcd/src/ifxusb_cif_d.c b/package/platform/lantiq/ltq-hcd/src/ifxusb_cif_d.c
new file mode 100644
index 0000000..19f7650
--- /dev/null
+++ b/package/platform/lantiq/ltq-hcd/src/ifxusb_cif_d.c
@@ -0,0 +1,535 @@
+/*****************************************************************************
+ ** FILE NAME : ifxusb_cif_d.c
+ ** PROJECT : IFX USB sub-system V3
+ ** MODULES : IFX USB sub-system Host and Device driver
+ ** SRC VERSION : 3.2
+ ** DATE : 1/Jan/2011
+ ** AUTHOR : Chen, Howard
+ ** DESCRIPTION : The Core Interface provides basic services for accessing and
+ ** managing the IFX USB hardware. These services are used by the
+ ** Peripheral Controller Driver only.
+ ** FUNCTIONS :
+ ** COMPILER : gcc
+ ** REFERENCE : Synopsys DWC-OTG Driver 2.7
+ ** COPYRIGHT : Copyright (c) 2010
+ ** LANTIQ DEUTSCHLAND GMBH,
+ ** Am Campeon 3, 85579 Neubiberg, Germany
+ **
+ ** 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 of the License, or
+ ** (at your option) any later version.
+ **
+ ** Version Control Section **
+ ** $Author$
+ ** $Date$
+ ** $Revisions$
+ ** $Log$ Revision history
+ *****************************************************************************/
+
+/*
+ * This file contains code fragments from Synopsys HS OTG Linux Software Driver.
+ * For this code the following notice is applicable:
+ *
+ * ==========================================================================
+ *
+ * Synopsys HS OTG Linux Software Driver and documentation (hereinafter,
+ * "Software") is an Unsupported proprietary work of Synopsys, Inc. unless
+ * otherwise expressly agreed to in writing between Synopsys and you.
+ *
+ * The Software IS NOT an item of Licensed Software or Licensed Product under
+ * any End User Software License Agreement or Agreement for Licensed Product
+ * with Synopsys or any supplement thereto. You are permitted to use and
+ * redistribute this Software in source and binary forms, with or without
+ * modification, provided that redistributions of source code must retain this
+ * notice. You may not view, use, disclose, copy or distribute this file or
+ * any information contained herein except pursuant to this license grant from
+ * Synopsys. If you do not agree with this notice, including the disclaimer
+ * below, then you are not authorized to use the Software.
+ *
+ * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" BASIS
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ * ========================================================================== */
+
+/*!
+ \file ifxusb_cif_d.c
+ \ingroup IFXUSB_DRIVER_V3
+ \brief This file contains the interface to the IFX USB Core.
+*/
+
+#include <linux/version.h>
+#include "ifxusb_version.h"
+
+
+#include <asm/byteorder.h>
+#include <asm/unaligned.h>
+
+#ifdef __DEBUG__
+ #include <linux/jiffies.h>
+#endif
+
+#include "ifxusb_plat.h"
+#include "ifxusb_regs.h"
+#include "ifxusb_cif.h"
+
+#include "ifxpcd.h"
+
+
+
+/*!
+ \brief Initializes the DevSpd field of the DCFG register depending on the PHY type
+ and the enumeration speed of the device.
+ \param _core_if Pointer of core_if structure
+ */
+void ifxusb_dev_init_spd(ifxusb_core_if_t *_core_if)
+{
+ uint32_t val;
+ dcfg_data_t dcfg;
+
+ IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
+ if (_core_if->params.speed == IFXUSB_PARAM_SPEED_FULL)
+ /* High speed PHY running at full speed */
+ val = 0x1;
+ else
+ /* High speed PHY running at high speed and full speed*/
+ val = 0x0;
+
+ IFX_DEBUGPL(DBG_CIL, "Initializing DCFG.DevSpd to 0x%1x\n", val);
+ dcfg.d32 = ifxusb_rreg(&_core_if->dev_global_regs->dcfg);
+ dcfg.b.devspd = val;
+ ifxusb_wreg(&_core_if->dev_global_regs->dcfg, dcfg.d32);
+}
+
+
+/*!
+ \brief This function enables the Device mode interrupts.
+ \param _core_if Pointer of core_if structure
+ */
+void ifxusb_dev_enable_interrupts(ifxusb_core_if_t *_core_if)
+{
+ gint_data_t intr_mask ={ .d32 = 0};
+ ifxusb_core_global_regs_t *global_regs = _core_if->core_global_regs;
+
+ IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
+ IFX_DEBUGPL(DBG_CIL, "%s()\n", __func__);
+
+ /* Clear any pending OTG Interrupts */
+ ifxusb_wreg( &global_regs->gotgint, 0xFFFFFFFF);
+
+ /* Clear any pending interrupts */
+ ifxusb_wreg( &global_regs->gintsts, 0xFFFFFFFF);
+
+ /* Enable the interrupts in the GINTMSK.*/
+ intr_mask.b.modemismatch = 1;
+ intr_mask.b.conidstschng = 1;
+ intr_mask.b.wkupintr = 1;
+ intr_mask.b.disconnect = 1;
+ intr_mask.b.usbsuspend = 1;
+
+ intr_mask.b.usbreset = 1;
+ intr_mask.b.enumdone = 1;
+ intr_mask.b.inepintr = 1;
+ intr_mask.b.outepintr = 1;
+ intr_mask.b.erlysuspend = 1;
+ #ifndef __DED_FIFO__
+ #ifndef __DED_INTR__
+ intr_mask.b.epmismatch = 1;
+ #endif
+ #endif
+
+ ifxusb_mreg( &global_regs->gintmsk, intr_mask.d32, intr_mask.d32);
+ IFX_DEBUGPL(DBG_CIL, "%s() gintmsk=%0x\n", __func__, ifxusb_rreg( &global_regs->gintmsk));
+}
+
+/*!
+ \brief Gets the current USB frame number. This is the frame number from the last SOF packet.
+ \param _core_if Pointer of core_if structure
+ */
+uint32_t ifxusb_dev_get_frame_number(ifxusb_core_if_t *_core_if)
+{
+ dsts_data_t dsts;
+ IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
+ dsts.d32 = ifxusb_rreg(&_core_if->dev_global_regs->dsts);
+ /* read current frame/microfreme number from DSTS register */
+ return dsts.b.soffn;
+}
+
+
+/*!
+ \brief Set the EP STALL.
+ */
+void ifxusb_dev_ep_set_stall(ifxusb_core_if_t *_core_if, uint8_t _epno, uint8_t _is_in)
+{
+ depctl_data_t depctl;
+ volatile uint32_t *depctl_addr;
+
+ IFX_DEBUGPL(DBG_PCD, "%s ep%d-%s\n", __func__, _epno, (_is_in?"IN":"OUT"));
+
+ depctl_addr = (_is_in)? (&(_core_if->in_ep_regs [_epno]->diepctl)):
+ (&(_core_if->out_ep_regs[_epno]->doepctl));
+ depctl.d32 = ifxusb_rreg(depctl_addr);
+ depctl.b.stall = 1;
+
+ if (_is_in && depctl.b.epena)
+ depctl.b.epdis = 1;
+
+ ifxusb_wreg(depctl_addr, depctl.d32);
+ IFX_DEBUGPL(DBG_PCD,"DEPCTL=%0x\n",ifxusb_rreg(depctl_addr));
+ return;
+}
+
+/*!
+\brief Clear the EP STALL.
+ */
+void ifxusb_dev_ep_clear_stall(ifxusb_core_if_t *_core_if, uint8_t _epno, uint8_t _ep_type, uint8_t _is_in)
+{
+ depctl_data_t depctl;
+ volatile uint32_t *depctl_addr;
+
+ IFX_DEBUGPL(DBG_PCD, "%s ep%d-%s\n", __func__, _epno, (_is_in?"IN":"OUT"));
+
+ depctl_addr = (_is_in)? (&(_core_if->in_ep_regs [_epno]->diepctl)):
+ (&(_core_if->out_ep_regs[_epno]->doepctl));
+
+ depctl.d32 = ifxusb_rreg(depctl_addr);
+ /* clear the stall bits */
+ depctl.b.stall = 0;
+
+ /*
+ * USB Spec 9.4.5: For endpoints using data toggle, regardless
+ * of whether an endpoint has the Halt feature set, a
+ * ClearFeature(ENDPOINT_HALT) request always results in the
+ * data toggle being reinitialized to DATA0.
+ */
+ if (_ep_type == IFXUSB_EP_TYPE_INTR || _ep_type == IFXUSB_EP_TYPE_BULK)
+ depctl.b.setd0pid = 1; /* DATA0 */
+
+ ifxusb_wreg(depctl_addr, depctl.d32);
+ IFX_DEBUGPL(DBG_PCD,"DEPCTL=%0x\n",ifxusb_rreg(depctl_addr));
+ return;
+}
+
+/*!
+ \brief This function initializes the IFXUSB controller registers for Device mode.
+ This function flushes the Tx and Rx FIFOs and it flushes any entries in the
+ request queues.
+ \param _core_if Pointer of core_if structure
+ \param _params parameters to be set
+ */
+void ifxusb_dev_core_init(ifxusb_core_if_t *_core_if, ifxusb_params_t *_params)
+{
+ ifxusb_core_global_regs_t *global_regs = _core_if->core_global_regs;
+
+ gusbcfg_data_t usbcfg ={.d32 = 0};
+ gahbcfg_data_t ahbcfg ={.d32 = 0};
+ dcfg_data_t dcfg ={.d32 = 0};
+ grstctl_t resetctl ={.d32 = 0};
+ gotgctl_data_t gotgctl ={.d32 = 0};
+
+ uint32_t dir;
+ int i;
+
+ IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
+ IFX_DEBUGPL(DBG_CILV, "%s(%p)\n",__func__,_core_if);
+
+ /* Copy Params */
+ _core_if->params.dma_burst_size = _params->dma_burst_size;
+ _core_if->params.speed = _params->speed;
+ if(_params->max_transfer_size < 2048 || _params->max_transfer_size > ((1 << (_core_if->hwcfg3.b.xfer_size_cntr_width + 11)) - 1) )
+ _core_if->params.max_transfer_size = ((1 << (_core_if->hwcfg3.b.xfer_size_cntr_width + 11)) - 1);
+ else
+ _core_if->params.max_transfer_size = _params->max_transfer_size;
+
+ if(_params->max_packet_count < 16 || _params->max_packet_count > ((1 << (_core_if->hwcfg3.b.packet_size_cntr_width + 4)) - 1) )
+ _core_if->params.max_packet_count= ((1 << (_core_if->hwcfg3.b.packet_size_cntr_width + 4)) - 1);
+ else
+ _core_if->params.max_packet_count= _params->max_packet_count;
+ _core_if->params.phy_utmi_width = _params->phy_utmi_width;
+ _core_if->params.turn_around_time_hs = _params->turn_around_time_hs;
+ _core_if->params.turn_around_time_fs = _params->turn_around_time_fs;
+ _core_if->params.timeout_cal_hs = _params->timeout_cal_hs;
+ _core_if->params.timeout_cal_fs = _params->timeout_cal_fs;
+
+ #ifdef __DED_FIFO__
+ _core_if->params.thr_ctl = _params->thr_ctl;
+ _core_if->params.tx_thr_length = _params->tx_thr_length;
+ _core_if->params.rx_thr_length = _params->rx_thr_length;
+ #endif
+
+ /* Reset the Controller */
+ do
+ {
+ while(ifxusb_core_soft_reset_d( _core_if ))
+ ifxusb_hard_reset_d(_core_if);
+ } while (ifxusb_is_host_mode(_core_if));
+
+ usbcfg.d32 = ifxusb_rreg(&global_regs->gusbcfg);
+
+ usbcfg.b.ForceDevMode = 1;
+ usbcfg.b.ForceHstMode = 0;
+
+ usbcfg.b.term_sel_dl_pulse = 0;
+ ifxusb_wreg (&global_regs->gusbcfg, usbcfg.d32);
+
+ /* This programming sequence needs to happen in FS mode before any other
+ * programming occurs */
+ /* High speed PHY. */
+ if (!_core_if->phy_init_done)
+ {
+ _core_if->phy_init_done = 1;
+ /* HS PHY parameters. These parameters are preserved
+ * during soft reset so only program the first time. Do
+ * a soft reset immediately after setting phyif. */
+ usbcfg.b.ulpi_utmi_sel = 0; //UTMI+
+ usbcfg.b.phyif = ( _core_if->params.phy_utmi_width == 16)?1:0;
+ ifxusb_wreg( &global_regs->gusbcfg, usbcfg.d32);
+ /* Reset after setting the PHY parameters */
+ ifxusb_core_soft_reset_d( _core_if );
+ }
+
+ /* Program the GAHBCFG Register.*/
+ switch (_core_if->params.dma_burst_size)
+ {
+ case 0 :
+ ahbcfg.b.hburstlen = IFXUSB_GAHBCFG_INT_DMA_BURST_SINGLE;
+ break;
+ case 1 :
+ ahbcfg.b.hburstlen = IFXUSB_GAHBCFG_INT_DMA_BURST_INCR;
+ break;
+ case 4 :
+ ahbcfg.b.hburstlen = IFXUSB_GAHBCFG_INT_DMA_BURST_INCR4;
+ break;
+ case 8 :
+ ahbcfg.b.hburstlen = IFXUSB_GAHBCFG_INT_DMA_BURST_INCR8;
+ break;
+ case 16:
+ ahbcfg.b.hburstlen = IFXUSB_GAHBCFG_INT_DMA_BURST_INCR16;
+ break;
+ }
+ #if defined(__UNALIGNED_BUF_ADJ__) || defined(__UNALIGNED_BUF_CHK__)
+ _core_if->unaligned_mask=3;
+ #if defined(__UNALIGNED_BUF_BURST__)
+ switch (_core_if->params.dma_burst_size)
+ {
+ case 4 :
+ _core_if->unaligned_mask=15;
+ break;
+ case 8 :
+ _core_if->unaligned_mask=31;
+ break;
+ case 16:
+ _core_if->unaligned_mask=63;
+ break;
+ case 0 :
+ case 1 :
+ break;
+ }
+ #endif //defined(__UNALIGNED_BUF_BURST__)
+ #endif //defined(__UNALIGNED_BUF_ADJ__) || defined(__UNALIGNED_BUF_CHK__)
+ ahbcfg.b.dmaenable = 1;
+ ifxusb_wreg(&global_regs->gahbcfg, ahbcfg.d32);
+
+ /* Program the GUSBCFG register. */
+ usbcfg.d32 = ifxusb_rreg( &global_regs->gusbcfg );
+ usbcfg.b.hnpcap = 0;
+ usbcfg.b.srpcap = 0;
+ ifxusb_wreg( &global_regs->gusbcfg, usbcfg.d32);
+
+ {
+ dctl_data_t dctl = {.d32=0};
+ dctl.d32=ifxusb_rreg(&_core_if->dev_global_regs->dctl);
+ dctl.b.sftdiscon=1;
+ ifxusb_wreg(&_core_if->dev_global_regs->dctl,dctl.d32);
+ }
+
+ /* Restart the Phy Clock */
+ ifxusb_wreg(_core_if->pcgcctl, 0);
+
+ /* Device configuration register */
+ ifxusb_dev_init_spd(_core_if);
+ dcfg.d32 = ifxusb_rreg( &_core_if->dev_global_regs->dcfg);
+ dcfg.b.perfrint = IFXUSB_DCFG_FRAME_INTERVAL_80;
+ #if defined(__DED_FIFO__)
+ #if defined(__DESC_DMA__)
+ dcfg.b.descdma = 1;
+ #else
+ dcfg.b.descdma = 0;
+ #endif
+ #endif
+
+ ifxusb_wreg( &_core_if->dev_global_regs->dcfg, dcfg.d32 );
+
+ /* Configure data FIFO sizes */
+ _core_if->params.data_fifo_size = _core_if->hwcfg3.b.dfifo_depth;
+ _core_if->params.rx_fifo_size = ifxusb_rreg(&global_regs->grxfsiz);
+ IFX_DEBUGPL(DBG_CIL, "Initial: FIFO Size=0x%06X\n" , _core_if->params.data_fifo_size);
+ IFX_DEBUGPL(DBG_CIL, " Rx FIFO Size=0x%06X\n", _core_if->params.rx_fifo_size);
+
+ _core_if->params.tx_fifo_size[0]= ifxusb_rreg(&global_regs->gnptxfsiz) >> 16;
+
+ #ifdef __DED_FIFO__
+ for (i=1; i <= _core_if->hwcfg4.b.num_in_eps; i++)
+ _core_if->params.tx_fifo_size[i] =
+ ifxusb_rreg(&global_regs->dptxfsiz_dieptxf[i-1]) >> 16;
+ #else
+ for (i=0; i < _core_if->hwcfg4.b.num_dev_perio_in_ep; i++)
+ _core_if->params.tx_fifo_size[i+1] =
+ ifxusb_rreg(&global_regs->dptxfsiz_dieptxf[i]) >> 16;
+ #endif
+
+ #ifdef __DEBUG__
+ #ifdef __DED_FIFO__
+ for (i=0; i <= _core_if->hwcfg4.b.num_in_eps; i++)
+ IFX_DEBUGPL(DBG_CIL, " Tx[%02d] FIFO Size=0x%06X\n",i, _core_if->params.tx_fifo_size[i]);
+ #else
+ IFX_DEBUGPL(DBG_CIL, " NPTx FIFO Size=0x%06X\n", _core_if->params.tx_fifo_size[0]);
+ for (i=0; i < _core_if->hwcfg4.b.num_dev_perio_in_ep; i++)
+ IFX_DEBUGPL(DBG_CIL, " PTx[%02d] FIFO Size=0x%06X\n",i, _core_if->params.tx_fifo_size[i+1]);
+ #endif
+ #endif
+
+ {
+ fifosize_data_t txfifosize;
+ if(_params->data_fifo_size >=0 && _params->data_fifo_size < _core_if->params.data_fifo_size)
+ _core_if->params.data_fifo_size = _params->data_fifo_size;
+
+
+ if(_params->rx_fifo_size >=0 && _params->rx_fifo_size < _core_if->params.rx_fifo_size)
+ _core_if->params.rx_fifo_size = _params->rx_fifo_size;
+ if(_core_if->params.data_fifo_size < _core_if->params.rx_fifo_size)
+ _core_if->params.rx_fifo_size = _core_if->params.data_fifo_size;
+ ifxusb_wreg( &global_regs->grxfsiz, _core_if->params.rx_fifo_size);
+
+ for (i=0; i < MAX_EPS_CHANNELS; i++)
+ if(_params->tx_fifo_size[i] >=0 && _params->tx_fifo_size[i] < _core_if->params.tx_fifo_size[i])
+ _core_if->params.tx_fifo_size[i] = _params->tx_fifo_size[i];
+
+ txfifosize.b.startaddr = _core_if->params.rx_fifo_size;
+ #ifdef __DED_FIFO__
+ if(txfifosize.b.startaddr + _core_if->params.tx_fifo_size[0] > _core_if->params.data_fifo_size)
+ _core_if->params.tx_fifo_size[0]= _core_if->params.data_fifo_size - txfifosize.b.startaddr;
+ txfifosize.b.depth=_core_if->params.tx_fifo_size[0];
+ ifxusb_wreg( &global_regs->gnptxfsiz, txfifosize.d32);
+ txfifosize.b.startaddr += _core_if->params.tx_fifo_size[0];
+ for (i=1; i <= _core_if->hwcfg4.b.num_in_eps; i++)
+ {
+ if(txfifosize.b.startaddr + _core_if->params.tx_fifo_size[i] > _core_if->params.data_fifo_size)
+ _core_if->params.tx_fifo_size[i]= _core_if->params.data_fifo_size - txfifosize.b.startaddr;
+ txfifosize.b.depth=_core_if->params.tx_fifo_size[i];
+ ifxusb_wreg( &global_regs->dptxfsiz_dieptxf[i-1], txfifosize.d32);
+ txfifosize.b.startaddr += _core_if->params.tx_fifo_size[i];
+ }
+ #else
+ if(txfifosize.b.startaddr + _core_if->params.tx_fifo_size[0] > _core_if->params.data_fifo_size)
+ _core_if->params.tx_fifo_size[0]= _core_if->params.data_fifo_size - txfifosize.b.startaddr;
+ txfifosize.b.depth=_core_if->params.tx_fifo_size[0];
+ ifxusb_wreg( &global_regs->gnptxfsiz, txfifosize.d32);
+ txfifosize.b.startaddr += _core_if->params.tx_fifo_size[0];
+ for (i=0; i < _core_if->hwcfg4.b.num_dev_perio_in_ep; i++)
+ {
+ if(txfifosize.b.startaddr + _core_if->params.tx_fifo_size[i+1] > _core_if->params.data_fifo_size)
+ _core_if->params.tx_fifo_size[i+1]= _core_if->params.data_fifo_size - txfifosize.b.startaddr;
+ //txfifosize.b.depth=_core_if->params.tx_fifo_size[i+1];
+ ifxusb_wreg( &global_regs->dptxfsiz_dieptxf[i], txfifosize.d32);
+ txfifosize.b.startaddr += _core_if->params.tx_fifo_size[i+1];
+ }
+ #endif
+ }
+
+ #ifdef __DEBUG__
+ {
+ fifosize_data_t fifosize;
+ IFX_DEBUGPL(DBG_CIL, "Result : FIFO Size=0x%06X\n" , _core_if->params.data_fifo_size);
+
+ IFX_DEBUGPL(DBG_CIL, " Rx FIFO =0x%06X Sz=0x%06X\n", 0,ifxusb_rreg(&global_regs->grxfsiz));
+ #ifdef __DED_FIFO__
+ fifosize.d32=ifxusb_rreg(&global_regs->gnptxfsiz);
+ IFX_DEBUGPL(DBG_CIL, " Tx[00] FIFO =0x%06X Sz=0x%06X\n", fifosize.b.startaddr,fifosize.b.depth);
+ for (i=1; i <= _core_if->hwcfg4.b.num_in_eps; i++)
+ {
+ fifosize.d32=ifxusb_rreg(&global_regs->dptxfsiz_dieptxf[i-1]);
+ IFX_DEBUGPL(DBG_CIL, " Tx[%02d] FIFO 0x%06X Sz=0x%06X\n",i, fifosize.b.startaddr,fifosize.b.depth);
+ }
+ #else
+ fifosize.d32=ifxusb_rreg(&global_regs->gnptxfsiz);
+ IFX_DEBUGPL(DBG_CIL, " NPTx FIFO =0x%06X Sz=0x%06X\n", fifosize.b.startaddr,fifosize.b.depth);
+ for (i=0; i < _core_if->hwcfg4.b.num_dev_perio_in_ep; i++)
+ {
+ fifosize.d32=ifxusb_rreg(&global_regs->dptxfsiz_dieptxf[i]);
+ IFX_DEBUGPL(DBG_CIL, " PTx[%02d] FIFO 0x%06X Sz=0x%06X\n",i, fifosize.b.startaddr,fifosize.b.depth);
+ }
+ #endif
+ }
+ #endif
+
+ /* Clear Host Set HNP Enable in the OTG Control Register */
+ gotgctl.b.hstsethnpen = 1;
+ ifxusb_mreg( &global_regs->gotgctl, gotgctl.d32, 0);
+
+ /* Flush the FIFOs */
+ ifxusb_flush_tx_fifo_d(_core_if, 0x10); /* all Tx FIFOs */
+ ifxusb_flush_rx_fifo_d(_core_if);
+
+ /* Flush the Learning Queue. */
+ resetctl.b.intknqflsh = 1;
+ ifxusb_wreg( &global_regs->grstctl, resetctl.d32);
+
+ /* Clear all pending Device Interrupts */
+ ifxusb_wreg( &_core_if->dev_global_regs->diepmsk , 0 );
+ ifxusb_wreg( &_core_if->dev_global_regs->doepmsk , 0 );
+ ifxusb_wreg( &_core_if->dev_global_regs->daint , 0xFFFFFFFF );
+ ifxusb_wreg( &_core_if->dev_global_regs->daintmsk, 0 );
+
+ dir=_core_if->hwcfg1.d32;
+ for (i=0; i <= _core_if->hwcfg2.b.num_dev_ep ; i++,dir>>=2)
+ {
+ depctl_data_t depctl;
+ if((dir&0x03)==0 || (dir&0x03) ==1)
+ {
+ depctl.d32 = ifxusb_rreg(&_core_if->in_ep_regs[i]->diepctl);
+ if (depctl.b.epena)
+ {
+ depctl.d32 = 0;
+ depctl.b.epdis = 1;
+ depctl.b.snak = 1;
+ }
+ else
+ depctl.d32 = 0;
+ ifxusb_wreg( &_core_if->in_ep_regs[i]->diepctl, depctl.d32);
+ #ifndef __DESC_DMA__
+ ifxusb_wreg( &_core_if->in_ep_regs[i]->dieptsiz, 0);
+ #endif
+ ifxusb_wreg( &_core_if->in_ep_regs[i]->diepdma, 0);
+ ifxusb_wreg( &_core_if->in_ep_regs[i]->diepint, 0xFF);
+ }
+
+ if((dir&0x03)==0 || (dir&0x03) ==2)
+ {
+ depctl.d32 = ifxusb_rreg(&_core_if->out_ep_regs[i]->doepctl);
+ if (depctl.b.epena)
+ {
+ depctl.d32 = 0;
+ depctl.b.epdis = 1;
+ depctl.b.snak = 1;
+ }
+ else
+ depctl.d32 = 0;
+ ifxusb_wreg( &_core_if->out_ep_regs[i]->doepctl, depctl.d32);
+ #ifndef __DESC_DMA__
+ ifxusb_wreg( &_core_if->out_ep_regs[i]->doeptsiz, 0);
+ #endif
+ ifxusb_wreg( &_core_if->out_ep_regs[i]->doepdma, 0);
+ ifxusb_wreg( &_core_if->out_ep_regs[i]->doepint, 0xFF);
+ }
+ }
+}
+
diff --git a/package/platform/lantiq/ltq-hcd/src/ifxusb_cif_h.c b/package/platform/lantiq/ltq-hcd/src/ifxusb_cif_h.c
new file mode 100644
index 0000000..e9e67bf
--- /dev/null
+++ b/package/platform/lantiq/ltq-hcd/src/ifxusb_cif_h.c
@@ -0,0 +1,1599 @@
+/*****************************************************************************
+ ** FILE NAME : ifxusb_cif_h.c
+ ** PROJECT : IFX USB sub-system V3
+ ** MODULES : IFX USB sub-system Host and Device driver
+ ** SRC VERSION : 3.2
+ ** DATE : 1/Jan/2011
+ ** AUTHOR : Chen, Howard
+ ** DESCRIPTION : The Core Interface provides basic services for accessing and
+ ** managing the IFX USB hardware. These services are used by the
+ ** Host Controller Driver only.
+ ** FUNCTIONS :
+ ** COMPILER : gcc
+ ** REFERENCE : Synopsys DWC-OTG Driver 2.7
+ ** COPYRIGHT : Copyright (c) 2010
+ ** LANTIQ DEUTSCHLAND GMBH,
+ ** Am Campeon 3, 85579 Neubiberg, Germany
+ **
+ ** 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 of the License, or
+ ** (at your option) any later version.
+ **
+ ** Version Control Section **
+ ** $Author$
+ ** $Date$
+ ** $Revisions$
+ ** $Log$ Revision history
+ *****************************************************************************/
+
+/*
+ * This file contains code fragments from Synopsys HS OTG Linux Software Driver.
+ * For this code the following notice is applicable:
+ *
+ * ==========================================================================
+ *
+ * Synopsys HS OTG Linux Software Driver and documentation (hereinafter,
+ * "Software") is an Unsupported proprietary work of Synopsys, Inc. unless
+ * otherwise expressly agreed to in writing between Synopsys and you.
+ *
+ * The Software IS NOT an item of Licensed Software or Licensed Product under
+ * any End User Software License Agreement or Agreement for Licensed Product
+ * with Synopsys or any supplement thereto. You are permitted to use and
+ * redistribute this Software in source and binary forms, with or without
+ * modification, provided that redistributions of source code must retain this
+ * notice. You may not view, use, disclose, copy or distribute this file or
+ * any information contained herein except pursuant to this license grant from
+ * Synopsys. If you do not agree with this notice, including the disclaimer
+ * below, then you are not authorized to use the Software.
+ *
+ * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" BASIS
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ * ========================================================================== */
+
+/*!
+ \file ifxusb_cif_h.c
+ \ingroup IFXUSB_DRIVER_V3
+ \brief This file contains the interface to the IFX USB Core.
+*/
+#include <linux/version.h>
+#include "ifxusb_version.h"
+
+#include <asm/byteorder.h>
+#include <asm/unaligned.h>
+
+#ifdef __DEBUG__
+ #include <linux/jiffies.h>
+#endif
+#include <linux/platform_device.h>
+#include <linux/kernel.h>
+#include <linux/ioport.h>
+
+#include "ifxusb_plat.h"
+#include "ifxusb_regs.h"
+#include "ifxusb_cif.h"
+
+#include "ifxhcd.h"
+
+#if !defined(__UEIP__)
+ #undef __USING_LED_AS_GPIO__
+#endif
+
+
+/*!
+ \brief This function enables the Host mode interrupts.
+ \param _core_if Pointer of core_if structure
+ */
+void ifxusb_host_enable_interrupts(ifxusb_core_if_t *_core_if)
+{
+ gint_data_t intr_mask ={ .d32 = 0};
+ ifxusb_core_global_regs_t *global_regs = _core_if->core_global_regs;
+
+ IFX_DEBUGPL(DBG_CIL, "%s()\n", __func__);
+
+ /* Clear any pending OTG Interrupts */
+ ifxusb_wreg( &global_regs->gotgint, 0xFFFFFFFF);
+
+ /* Clear any pending interrupts */
+ ifxusb_wreg( &global_regs->gintsts, 0xFFFFFFFF);
+
+ /* Enable the interrupts in the GINTMSK.*/
+
+ /* Common interrupts */
+ intr_mask.b.modemismatch = 1;
+ intr_mask.b.conidstschng = 1;
+ intr_mask.b.wkupintr = 1;
+ intr_mask.b.disconnect = 1;
+ intr_mask.b.usbsuspend = 1;
+
+ /* Host interrupts */
+ intr_mask.b.sofintr = 1;
+ intr_mask.b.portintr = 1;
+ intr_mask.b.hcintr = 1;
+
+ ifxusb_mreg( &global_regs->gintmsk, intr_mask.d32, intr_mask.d32);
+ IFX_DEBUGPL(DBG_CIL, "%s() gintmsk=%0x\n", __func__, ifxusb_rreg( &global_regs->gintmsk));
+}
+
+/*!
+ \brief This function disables the Host mode interrupts.
+ \param _core_if Pointer of core_if structure
+ */
+void ifxusb_host_disable_interrupts(ifxusb_core_if_t *_core_if)
+{
+ ifxusb_core_global_regs_t *global_regs = _core_if->core_global_regs;
+
+ IFX_DEBUGPL(DBG_CILV, "%s()\n", __func__);
+
+ #if 1
+ ifxusb_wreg( &global_regs->gintmsk, 0);
+ #else
+ /* Common interrupts */
+ {
+ gint_data_t intr_mask ={.d32 = 0};
+ intr_mask.b.modemismatch = 1;
+ intr_mask.b.rxstsqlvl = 1;
+ intr_mask.b.conidstschng = 1;
+ intr_mask.b.wkupintr = 1;
+ intr_mask.b.disconnect = 1;
+ intr_mask.b.usbsuspend = 1;
+
+ /* Host interrupts */
+ intr_mask.b.sofintr = 1;
+ intr_mask.b.portintr = 1;
+ intr_mask.b.hcintr = 1;
+ intr_mask.b.ptxfempty = 1;
+ intr_mask.b.nptxfempty = 1;
+ ifxusb_mreg(&global_regs->gintmsk, intr_mask.d32, 0);
+ }
+ #endif
+}
+
+/*!
+ \brief This function initializes the IFXUSB controller registers for Host mode.
+ This function flushes the Tx and Rx FIFOs and it flushes any entries in the
+ request queues.
+ \param _core_if Pointer of core_if structure
+ \param _params parameters to be set
+ */
+void ifxusb_host_core_init(ifxusb_core_if_t *_core_if, ifxusb_params_t *_params)
+{
+ ifxusb_core_global_regs_t *global_regs = _core_if->core_global_regs;
+
+ gusbcfg_data_t usbcfg ={.d32 = 0};
+ gahbcfg_data_t ahbcfg ={.d32 = 0};
+ gotgctl_data_t gotgctl ={.d32 = 0};
+
+ int i;
+
+ IFX_DEBUGPL(DBG_CILV, "%s(%p)\n",__func__,_core_if);
+
+ /* Copy Params */
+
+ _core_if->params.dma_burst_size = _params->dma_burst_size;
+ _core_if->params.speed = _params->speed;
+ if(_params->max_transfer_size < 2048 || _params->max_transfer_size > ((1 << (_core_if->hwcfg3.b.xfer_size_cntr_width + 11)) - 1) )
+ _core_if->params.max_transfer_size = ((1 << (_core_if->hwcfg3.b.xfer_size_cntr_width + 11)) - 1);
+ else
+ _core_if->params.max_transfer_size = _params->max_transfer_size;
+
+ if(_params->max_packet_count < 16 || _params->max_packet_count > ((1 << (_core_if->hwcfg3.b.packet_size_cntr_width + 4)) - 1) )
+ _core_if->params.max_packet_count= ((1 << (_core_if->hwcfg3.b.packet_size_cntr_width + 4)) - 1);
+ else
+ _core_if->params.max_packet_count= _params->max_packet_count;
+ _core_if->params.phy_utmi_width = _params->phy_utmi_width;
+ _core_if->params.turn_around_time_hs = _params->turn_around_time_hs;
+ _core_if->params.turn_around_time_fs = _params->turn_around_time_fs;
+ _core_if->params.timeout_cal_hs = _params->timeout_cal_hs;
+ _core_if->params.timeout_cal_fs = _params->timeout_cal_fs;
+ usbcfg.d32 = ifxusb_rreg(&global_regs->gusbcfg);
+// usbcfg.b.ulpi_ext_vbus_drv = 1;
+ usbcfg.b.term_sel_dl_pulse = 0;
+ usbcfg.b.ForceDevMode = 0;
+ usbcfg.b.ForceHstMode = 1;
+ ifxusb_wreg (&global_regs->gusbcfg, usbcfg.d32);
+ /* Reset the Controller */
+ do
+ {
+ while(ifxusb_core_soft_reset_h( _core_if ))
+ ifxusb_hard_reset_h(_core_if);
+ } while (ifxusb_is_device_mode(_core_if));
+
+ usbcfg.d32 = ifxusb_rreg(&global_regs->gusbcfg);
+// usbcfg.b.ulpi_ext_vbus_drv = 1;
+ usbcfg.b.term_sel_dl_pulse = 0;
+ ifxusb_wreg (&global_regs->gusbcfg, usbcfg.d32);
+
+ /* This programming sequence needs to happen in FS mode before any other
+ * programming occurs */
+ /* High speed PHY. */
+ if (!_core_if->phy_init_done)
+ {
+ _core_if->phy_init_done = 1;
+ /* HS PHY parameters. These parameters are preserved
+ * during soft reset so only program the first time. Do
+ * a soft reset immediately after setting phyif. */
+ usbcfg.b.ulpi_utmi_sel = 0; //UTMI+
+ usbcfg.b.phyif = ( _core_if->params.phy_utmi_width == 16)?1:0;
+ ifxusb_wreg( &global_regs->gusbcfg, usbcfg.d32);
+ /* Reset after setting the PHY parameters */
+ ifxusb_core_soft_reset_h( _core_if );
+ }
+
+ usbcfg.d32 = ifxusb_rreg(&global_regs->gusbcfg);
+// usbcfg.b.ulpi_fsls = 0;
+// usbcfg.b.ulpi_clk_sus_m = 0;
+ usbcfg.b.term_sel_dl_pulse = 0;
+ usbcfg.b.ForceDevMode = 0;
+ usbcfg.b.ForceHstMode = 1;
+ ifxusb_wreg(&global_regs->gusbcfg, usbcfg.d32);
+
+ /* Program the GAHBCFG Register.*/
+ switch (_core_if->params.dma_burst_size)
+ {
+ case 0 :
+ ahbcfg.b.hburstlen = IFXUSB_GAHBCFG_INT_DMA_BURST_SINGLE;
+ break;
+ case 1 :
+ ahbcfg.b.hburstlen = IFXUSB_GAHBCFG_INT_DMA_BURST_INCR;
+ break;
+ case 4 :
+ ahbcfg.b.hburstlen = IFXUSB_GAHBCFG_INT_DMA_BURST_INCR4;
+ break;
+ case 8 :
+ ahbcfg.b.hburstlen = IFXUSB_GAHBCFG_INT_DMA_BURST_INCR8;
+ break;
+ case 16:
+ ahbcfg.b.hburstlen = IFXUSB_GAHBCFG_INT_DMA_BURST_INCR16;
+ break;
+ }
+ #if defined(__UNALIGNED_BUF_ADJ__) || defined(__UNALIGNED_BUF_CHK__)
+ _core_if->unaligned_mask=3;
+ #if defined(__UNALIGNED_BUF_BURST__)
+ switch(_core_if->params.dma_burst_size)
+ {
+ case 4 :
+ _core_if->unaligned_mask=15;
+ break;
+ case 8 :
+ _core_if->unaligned_mask=31;
+ break;
+ case 16:
+ _core_if->unaligned_mask=63;
+ break;
+ case 0 :
+ case 1 :
+ break;
+ default:
+ break;
+ }
+ #endif //defined(__UNALIGNED_BUF_BURST__)
+ #endif //defined(__UNALIGNED_BUF_ADJ__) || defined(__UNALIGNED_BUF_CHK__)
+ ahbcfg.b.dmaenable = 1;
+ ifxusb_wreg(&global_regs->gahbcfg, ahbcfg.d32);
+
+ /* Program the GUSBCFG register. */
+ usbcfg.d32 = ifxusb_rreg( &global_regs->gusbcfg );
+ usbcfg.b.hnpcap = 0;
+ usbcfg.b.srpcap = 0;
+ ifxusb_wreg( &global_regs->gusbcfg, usbcfg.d32);
+
+ /* Restart the Phy Clock */
+ ifxusb_wreg(_core_if->pcgcctl, 0);
+
+ /* Initialize Host Configuration Register */
+ {
+ hcfg_data_t hcfg;
+ hcfg.d32 = ifxusb_rreg(&_core_if->host_global_regs->hcfg);
+ hcfg.b.fslspclksel = IFXUSB_HCFG_30_60_MHZ;
+ if (_params->speed == IFXUSB_PARAM_SPEED_FULL)
+ hcfg.b.fslssupp = 1;
+ ifxusb_wreg(&_core_if->host_global_regs->hcfg, hcfg.d32);
+ }
+
+ _core_if->params.host_channels=(_core_if->hwcfg2.b.num_host_chan + 1);
+
+ if(_params->host_channels>0 && _params->host_channels < _core_if->params.host_channels)
+ _core_if->params.host_channels = _params->host_channels;
+
+ /* Configure data FIFO sizes */
+ _core_if->params.data_fifo_size = _core_if->hwcfg3.b.dfifo_depth;
+ _core_if->params.rx_fifo_size = ifxusb_rreg(&global_regs->grxfsiz);
+ _core_if->params.nperio_tx_fifo_size= ifxusb_rreg(&global_regs->gnptxfsiz) >> 16;
+ _core_if->params.perio_tx_fifo_size = ifxusb_rreg(&global_regs->hptxfsiz) >> 16;
+ IFX_DEBUGPL(DBG_CIL, "Initial: FIFO Size=0x%06X\n" , _core_if->params.data_fifo_size);
+ IFX_DEBUGPL(DBG_CIL, " Rx FIFO Size=0x%06X\n", _core_if->params.rx_fifo_size);
+ IFX_DEBUGPL(DBG_CIL, " NPTx FIFO Size=0x%06X\n", _core_if->params.nperio_tx_fifo_size);
+ IFX_DEBUGPL(DBG_CIL, " PTx FIFO Size=0x%06X\n", _core_if->params.perio_tx_fifo_size);
+
+ {
+ fifosize_data_t txfifosize;
+ if(_params->data_fifo_size >=0 && _params->data_fifo_size < _core_if->params.data_fifo_size)
+ _core_if->params.data_fifo_size = _params->data_fifo_size;
+
+ if( _params->rx_fifo_size >= 0 && _params->rx_fifo_size < _core_if->params.rx_fifo_size)
+ _core_if->params.rx_fifo_size = _params->rx_fifo_size;
+ if( _params->nperio_tx_fifo_size >=0 && _params->nperio_tx_fifo_size < _core_if->params.nperio_tx_fifo_size)
+ _core_if->params.nperio_tx_fifo_size = _params->nperio_tx_fifo_size;
+ if( _params->perio_tx_fifo_size >=0 && _params->perio_tx_fifo_size < _core_if->params.perio_tx_fifo_size)
+ _core_if->params.perio_tx_fifo_size = _params->perio_tx_fifo_size;
+
+ if(_core_if->params.data_fifo_size < _core_if->params.rx_fifo_size)
+ _core_if->params.rx_fifo_size = _core_if->params.data_fifo_size;
+ ifxusb_wreg( &global_regs->grxfsiz, _core_if->params.rx_fifo_size);
+ txfifosize.b.startaddr = _core_if->params.rx_fifo_size;
+
+ if(txfifosize.b.startaddr + _core_if->params.nperio_tx_fifo_size > _core_if->params.data_fifo_size)
+ _core_if->params.nperio_tx_fifo_size = _core_if->params.data_fifo_size - txfifosize.b.startaddr;
+ txfifosize.b.depth=_core_if->params.nperio_tx_fifo_size;
+ ifxusb_wreg( &global_regs->gnptxfsiz, txfifosize.d32);
+ txfifosize.b.startaddr += _core_if->params.nperio_tx_fifo_size;
+
+ if(txfifosize.b.startaddr + _core_if->params.perio_tx_fifo_size > _core_if->params.data_fifo_size)
+ _core_if->params.perio_tx_fifo_size = _core_if->params.data_fifo_size - txfifosize.b.startaddr;
+ txfifosize.b.depth=_core_if->params.perio_tx_fifo_size;
+ ifxusb_wreg( &global_regs->hptxfsiz, txfifosize.d32);
+ txfifosize.b.startaddr += _core_if->params.perio_tx_fifo_size;
+ }
+
+ #ifdef __DEBUG__
+ {
+ fifosize_data_t fifosize;
+ IFX_DEBUGPL(DBG_CIL, "Result : FIFO Size=0x%06X\n" , _core_if->params.data_fifo_size);
+
+ fifosize.d32=ifxusb_rreg(&global_regs->grxfsiz);
+ IFX_DEBUGPL(DBG_CIL, " Rx FIFO =0x%06X 0x%06X\n", fifosize.b.startaddr,fifosize.b.depth);
+ fifosize.d32=ifxusb_rreg(&global_regs->gnptxfsiz);
+ IFX_DEBUGPL(DBG_CIL, " NPTx FIFO =0x%06X 0x%06X\n", fifosize.b.startaddr,fifosize.b.depth);
+ fifosize.d32=ifxusb_rreg(&global_regs->hptxfsiz);
+ IFX_DEBUGPL(DBG_CIL, " PTx FIFO =0x%06X 0x%06X\n", fifosize.b.startaddr,fifosize.b.depth);
+ }
+ #endif
+
+ /* Clear Host Set HNP Enable in the OTG Control Register */
+ gotgctl.b.hstsethnpen = 1;
+ ifxusb_mreg( &global_regs->gotgctl, gotgctl.d32, 0);
+
+ /* Flush the FIFOs */
+ ifxusb_flush_tx_fifo_h(_core_if, 0x10); /* all Tx FIFOs */
+ ifxusb_flush_rx_fifo_h(_core_if);
+
+ for (i = 0; i < _core_if->hwcfg2.b.num_host_chan + 1; i++)
+ {
+ hcchar_data_t hcchar;
+ hcchar.d32 = ifxusb_rreg(&_core_if->hc_regs[i]->hcchar);
+ hcchar.b.chen = 0;
+ hcchar.b.chdis = 1;
+ hcchar.b.epdir = 0;
+ ifxusb_wreg(&_core_if->hc_regs[i]->hcchar, hcchar.d32);
+ }
+ /* Halt all channels to put them into a known state. */
+ for (i = 0; i < _core_if->hwcfg2.b.num_host_chan + 1; i++)
+ {
+ hcchar_data_t hcchar;
+ int count = 0;
+
+ hcchar.d32 = ifxusb_rreg(&_core_if->hc_regs[i]->hcchar);
+ hcchar.b.chen = 1;
+ hcchar.b.chdis = 1;
+ hcchar.b.epdir = 0;
+ ifxusb_wreg(&_core_if->hc_regs[i]->hcchar, hcchar.d32);
+
+ IFX_DEBUGPL(DBG_HCDV, "%s: Halt channel %d\n", __func__, i);
+ do{
+ hcchar.d32 = ifxusb_rreg(&_core_if->hc_regs[i]->hcchar);
+ if (++count > 1000)
+ {
+ IFX_ERROR("%s: Unable to clear halt on channel %d\n", __func__, i);
+ break;
+ }
+ } while (hcchar.b.chen);
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#if defined(__UEIP__)
+ #if defined(IFX_GPIO_USB_VBUS) || defined(IFX_LEDGPIO_USB_VBUS) || defined(IFX_LEDLED_USB_VBUS)
+ int ifxusb_vbus_status =-1;
+ #endif
+
+ #if defined(IFX_GPIO_USB_VBUS1) || defined(IFX_LEDGPIO_USB_VBUS1) || defined(IFX_LEDLED_USB_VBUS1)
+ int ifxusb_vbus1_status =-1;
+ #endif
+
+ #if defined(IFX_GPIO_USB_VBUS2) || defined(IFX_LEDGPIO_USB_VBUS2) || defined(IFX_LEDLED_USB_VBUS2)
+ int ifxusb_vbus2_status =-1;
+ #endif
+
+ #if defined(IFX_LEDGPIO_USB_VBUS) || defined(IFX_LEDLED_USB_VBUS)
+ static void *g_usb_vbus_trigger = NULL;
+ #endif
+ #if defined(IFX_LEDGPIO_USB_VBUS1) || defined(IFX_LEDLED_USB_VBUS1)
+ static void *g_usb_vbus1_trigger = NULL;
+ #endif
+ #if defined(IFX_LEDGPIO_USB_VBUS2) || defined(IFX_LEDLED_USB_VBUS2)
+ static void *g_usb_vbus2_trigger = NULL;
+ #endif
+
+ #if defined(IFX_GPIO_USB_VBUS) || defined(IFX_GPIO_USB_VBUS1) || defined(IFX_GPIO_USB_VBUS2)
+ int ifxusb_vbus_gpio_inited=0;
+ #endif
+
+#else //defined(__UEIP__)
+ int ifxusb_vbus_status =-1;
+ int ifxusb_vbus1_status =-1;
+ int ifxusb_vbus2_status =-1;
+ int ifxusb_vbus_gpio_inited=0;
+#endif
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+/*!
+ \fn void ifxusb_vbus_init(ifxusb_core_if_t *_core_if)
+ \brief This function init the VBUS control.
+ \param _core_if Pointer of core_if structure
+ \ingroup IFXUSB_CIF
+ */
+void ifxusb_vbus_init(ifxusb_core_if_t *_core_if)
+{
+ #if defined(__UEIP__)
+ #if defined(IFX_LEDGPIO_USB_VBUS) || defined(IFX_LEDLED_USB_VBUS)
+ if ( !g_usb_vbus_trigger )
+ {
+ ifx_led_trigger_register("USB_VBUS", &g_usb_vbus_trigger);
+ if ( g_usb_vbus_trigger != NULL )
+ {
+ struct ifx_led_trigger_attrib attrib = {0};
+ attrib.delay_on = 0;
+ attrib.delay_off = 0;
+ attrib.timeout = 0;
+ attrib.def_value = 0;
+ attrib.flags = IFX_LED_TRIGGER_ATTRIB_DELAY_ON | IFX_LED_TRIGGER_ATTRIB_DELAY_OFF | IFX_LED_TRIGGER_ATTRIB_TIMEOUT | IFX_LED_TRIGGER_ATTRIB_DEF_VALUE;
+ IFX_DEBUGP("Reg USB power!!\n");
+ ifx_led_trigger_set_attrib(g_usb_vbus_trigger, &attrib);
+ ifxusb_vbus_status =0;
+ }
+ }
+ #endif
+ #if defined(IFX_LEDGPIO_USB_VBUS1) || defined(IFX_LEDLED_USB_VBUS1)
+ if(_core_if->core_no==0 && !g_usb_vbus1_trigger )
+ {
+ ifx_led_trigger_register("USB_VBUS1", &g_usb_vbus1_trigger);
+ if ( g_usb_vbus1_trigger != NULL )
+ {
+ struct ifx_led_trigger_attrib attrib = {0};
+ attrib.delay_on = 0;
+ attrib.delay_off = 0;
+ attrib.timeout = 0;
+ attrib.def_value = 0;
+ attrib.flags = IFX_LED_TRIGGER_ATTRIB_DELAY_ON | IFX_LED_TRIGGER_ATTRIB_DELAY_OFF | IFX_LED_TRIGGER_ATTRIB_TIMEOUT | IFX_LED_TRIGGER_ATTRIB_DEF_VALUE;
+ IFX_DEBUGP("Reg USB1 power!!\n");
+ ifx_led_trigger_set_attrib(g_usb_vbus1_trigger, &attrib);
+ ifxusb_vbus1_status =0;
+ }
+ }
+ #endif
+ #if defined(IFX_LEDGPIO_USB_VBUS2) || defined(IFX_LEDLED_USB_VBUS2)
+ if(_core_if->core_no==1 && !g_usb_vbus2_trigger )
+ {
+ ifx_led_trigger_register("USB_VBUS2", &g_usb_vbus2_trigger);
+ if ( g_usb_vbus2_trigger != NULL )
+ {
+ struct ifx_led_trigger_attrib attrib = {0};
+ attrib.delay_on = 0;
+ attrib.delay_off = 0;
+ attrib.timeout = 0;
+ attrib.def_value = 0;
+ attrib.flags = IFX_LED_TRIGGER_ATTRIB_DELAY_ON | IFX_LED_TRIGGER_ATTRIB_DELAY_OFF | IFX_LED_TRIGGER_ATTRIB_TIMEOUT | IFX_LED_TRIGGER_ATTRIB_DEF_VALUE;
+ IFX_DEBUGP("Reg USB2 power!!\n");
+ ifx_led_trigger_set_attrib(g_usb_vbus2_trigger, &attrib);
+ ifxusb_vbus2_status =0;
+ }
+ }
+ #endif
+
+ #if defined(IFX_GPIO_USB_VBUS) || defined(IFX_GPIO_USB_VBUS1) || defined(IFX_GPIO_USB_VBUS2)
+ if(!ifxusb_vbus_gpio_inited)
+ {
+ if(!ifx_gpio_register(IFX_GPIO_MODULE_USB))
+ {
+ IFX_DEBUGP("Register USB VBus through GPIO OK!!\n");
+ #ifdef IFX_GPIO_USB_VBUS
+ ifxusb_vbus_status =0;
+ #endif //IFX_GPIO_USB_VBUS
+ #ifdef IFX_GPIO_USB_VBUS1
+ ifxusb_vbus1_status=0;
+ #endif //IFX_GPIO_USB_VBUS1
+ #ifdef IFX_GPIO_USB_VBUS2
+ ifxusb_vbus2_status=0;
+ #endif //IFX_GPIO_USB_VBUS2
+ }
+ else
+ IFX_PRINT("Register USB VBus Failed!!\n");
+ ifxusb_vbus_gpio_inited=1;
+ }
+ #endif //defined(IFX_GPIO_USB_VBUS) || defined(IFX_GPIO_USB_VBUS1) || defined(IFX_GPIO_USB_VBUS2)
+ #endif //defined(__UEIP__)
+}
+
+/*!
+ \fn void ifxusb_vbus_free(ifxusb_core_if_t *_core_if)
+ \brief This function free the VBUS control.
+ \param _core_if Pointer of core_if structure
+ \ingroup IFXUSB_CIF
+ */
+void ifxusb_vbus_free(ifxusb_core_if_t *_core_if)
+{
+ #if defined(__UEIP__)
+ #if defined(IFX_LEDGPIO_USB_VBUS) || defined(IFX_LEDLED_USB_VBUS)
+ if ( g_usb_vbus_trigger )
+ {
+ ifx_led_trigger_deregister(g_usb_vbus_trigger);
+ g_usb_vbus_trigger = NULL;
+ ifxusb_vbus_status =-1;
+ }
+ #endif
+ #if defined(IFX_LEDGPIO_USB_VBUS1) || defined(IFX_LEDLED_USB_VBUS1)
+ if(_core_if->core_no==0 && g_usb_vbus1_trigger )
+ {
+ ifx_led_trigger_deregister(g_usb_vbus1_trigger);
+ g_usb_vbus1_trigger = NULL;
+ ifxusb_vbus1_status =-1;
+ }
+ #endif
+ #if defined(IFX_LEDGPIO_USB_VBUS2) || defined(IFX_LEDLED_USB_VBUS2)
+ if(_core_if->core_no==1 && g_usb_vbus2_trigger )
+ {
+ ifx_led_trigger_deregister(g_usb_vbus2_trigger);
+ g_usb_vbus2_trigger = NULL;
+ ifxusb_vbus2_status =-1;
+ }
+ #endif
+
+ #if defined(IFX_GPIO_USB_VBUS) || defined(IFX_GPIO_USB_VBUS1) || defined(IFX_GPIO_USB_VBUS2)
+ if(ifxusb_vbus_gpio_inited)
+ {
+ ifx_gpio_deregister(IFX_GPIO_MODULE_USB);
+ #ifdef IFX_GPIO_USB_VBUS
+ ifxusb_vbus_status =-1;
+ #endif //IFX_GPIO_USB_VBUS
+ #ifdef IFX_GPIO_USB_VBUS1
+ ifxusb_vbus1_status=-1;
+ #endif //IFX_GPIO_USB_VBUS1
+ #ifdef IFX_GPIO_USB_VBUS2
+ ifxusb_vbus2_status=-1;
+ #endif //IFX_GPIO_USB_VBUS2
+ ifxusb_vbus_gpio_inited=0;
+ }
+ #endif //defined(IFX_GPIO_USB_VBUS) || defined(IFX_GPIO_USB_VBUS1) || defined(IFX_GPIO_USB_VBUS2)
+ #endif //defined(__UEIP__)
+}
+
+
+#if defined(__DO_OC_INT__)
+
+#define OC_Timer_Stable 3
+#define OC_Timer_Sleep 200
+#define OC_Timer_Max 3
+
+
+ #if defined(__IS_AR10__)
+ #if defined(__IS_DUAL__)
+ unsigned int oc1_int_installed=0;
+ unsigned int oc2_int_installed=0;
+ unsigned int oc1_int_count=0;
+ unsigned int oc2_int_count=0;
+ extern ifxhcd_hcd_t *oc1_int_id;
+ extern ifxhcd_hcd_t *oc2_int_id;
+
+ /*!
+ \brief Handles host mode Over Current Interrupt
+ */
+ struct timer_list oc1_retry_timer;
+ struct timer_list oc2_retry_timer;
+
+ void oc_retry_timer_func(unsigned long arg)
+ {
+ if(arg==1)
+ {
+ if(oc1_int_installed==0) //not installed
+ {
+ }
+ else if(oc1_int_installed==1) //disabled
+ {
+ }
+ else if(oc1_int_installed==2) //stablizing
+ {
+ oc1_int_installed=4;
+ oc1_int_count=0;
+ }
+ else if(oc1_int_installed==3) // sleeping
+ {
+ mod_timer(&oc1_retry_timer,jiffies + HZ*OC_Timer_Stable);
+ oc1_int_installed=2;
+ enable_irq(IFXUSB1_OC_IRQ);
+ }
+ else if(oc1_int_installed==4) //
+ {
+ oc1_int_count=0;
+ }
+ else if(oc1_int_installed==5) // Stable sleeping
+ {
+ mod_timer(&oc1_retry_timer,jiffies + HZ*OC_Timer_Stable);
+ oc1_int_installed=4;
+ enable_irq(IFXUSB1_OC_IRQ);
+ }
+ else
+ {
+ }
+ }
+ else
+ {
+ if(oc2_int_installed==0) //not installed
+ {
+ }
+ else if(oc2_int_installed==1) //disabled
+ {
+ }
+ else if(oc2_int_installed==2) //stablizing
+ {
+ oc2_int_installed=4;
+ oc2_int_count=0;
+ }
+ else if(oc2_int_installed==3) // sleeping
+ {
+ mod_timer(&oc2_retry_timer,jiffies + HZ*OC_Timer_Stable);
+ oc2_int_installed=2;
+ enable_irq(IFXUSB2_OC_IRQ);
+ }
+ else if(oc2_int_installed==4) //
+ {
+ oc2_int_count=0;
+ }
+ else if(oc2_int_installed==5) // Stable sleeping
+ {
+ mod_timer(&oc2_retry_timer,jiffies + HZ*OC_Timer_Stable);
+ oc2_int_installed=4;
+ enable_irq(IFXUSB2_OC_IRQ);
+ }
+ else
+ {
+ }
+ }
+ }
+
+ irqreturn_t ifxhcd_oc_irq(int _irq , void *_dev)
+ {
+ //ifxhcd_hcd_t *ifxhcd= _dev;
+ int32_t retval=1;
+ if(_irq==IFXUSB1_OC_IRQ)
+ {
+ if(oc1_int_installed==0) //not installed
+ {
+ }
+ else if(oc1_int_installed==1) //disabled
+ {
+ }
+ else if(oc1_int_installed==2) //stablizing
+ {
+ disable_irq_nosync(IFXUSB1_OC_IRQ);
+ mod_timer(&oc1_retry_timer,jiffies + HZ/OC_Timer_Sleep);
+ oc1_int_installed=3;
+ }
+ else if(oc1_int_installed==3) // sleeping
+ {
+ }
+ else if(oc1_int_installed==4) //
+ {
+ oc1_int_count++;
+ if(oc1_int_count>=OC_Timer_Max)
+ {
+ IFX_DEBUGP("OC INTERRUPT port #1\n");
+ oc1_int_id->flags.b.port_over_current_change = 1;
+ ifxusb_vbus_off(&oc1_int_id->core_if);
+ IFX_DEBUGP("Turning off port #1\n");
+ }
+ else
+ {
+ disable_irq_nosync(IFXUSB1_OC_IRQ);
+ mod_timer(&oc1_retry_timer,jiffies + HZ/OC_Timer_Sleep);
+ oc1_int_installed=5;
+ }
+ }
+ else if(oc1_int_installed==5) // Stable sleeping
+ {
+ }
+ }
+ else
+ {
+ if(oc2_int_installed==0) //not installed
+ {
+ }
+ else if(oc2_int_installed==1) //disabled
+ {
+ }
+ else if(oc2_int_installed==2) //stablizing
+ {
+ disable_irq_nosync(IFXUSB2_OC_IRQ);
+ mod_timer(&oc2_retry_timer,jiffies + HZ/OC_Timer_Sleep);
+ oc2_int_installed=3;
+ }
+ else if(oc2_int_installed==3) // sleeping
+ {
+ }
+ else if(oc2_int_installed==4) //
+ {
+ oc2_int_count++;
+ if(oc2_int_count>=OC_Timer_Max)
+ {
+ IFX_DEBUGP("OC INTERRUPT port #2\n");
+ oc2_int_id->flags.b.port_over_current_change = 1;
+ ifxusb_vbus_off(&oc2_int_id->core_if);
+ IFX_DEBUGP("Turning off port #2\n");
+ }
+ else
+ {
+ disable_irq_nosync(IFXUSB2_OC_IRQ);
+ mod_timer(&oc2_retry_timer,jiffies + HZ/OC_Timer_Sleep);
+ oc2_int_installed=5;
+ }
+ }
+ else if(oc2_int_installed==5) // Stable sleeping
+ {
+ }
+ }
+ return IRQ_RETVAL(retval);
+ }
+
+ void ifxusb_oc_int_on(int port)
+ {
+ if(port==1)
+ IFX_DEBUGPL( DBG_CIL, "registering (overcurrent) handler for port #1 irq%d\n", IFXUSB1_OC_IRQ);
+ else
+ IFX_DEBUGPL( DBG_CIL, "registering (overcurrent) handler for port #2 irq%d\n", IFXUSB2_OC_IRQ);
+ if((port==1&&oc1_int_id) || (port==2&&oc2_int_id)
+ {
+ if((port==1&&oc1_int_installed==0)||(port==2&&oc2_int_installed==0))
+ {
+ if(port==1)
+ {
+ oc1_int_installed=2;
+ init_timer(&oc1_retry_timer);
+ oc1_retry_timer.function = oc_retry_timer_func;
+ oc1_retry_timer.data=1;
+ if(request_irq((unsigned int)IFXUSB1_OC_IRQ, &ifxhcd_oc_irq,
+ IRQF_TRIGGER_NONE
+ // | IRQF_TRIGGER_RISING
+ // | IRQF_TRIGGER_FALLING
+ // | IRQF_TRIGGER_HIGH
+ // | IRQF_TRIGGER_LOW
+ // | IRQF_TRIGGER_PROBE
+ | IRQF_DISABLED
+ // | IRQF_SAMPLE_RANDOM
+ // | IRQF_SHARED
+ | IRQF_PROBE_SHARED
+ // | IRQF_TIMER
+ // | IRQF_PERCPU
+ // | IRQF_NOBALANCING
+ // | IRQF_IRQPOLL
+ // | IRQF_ONESHOT
+ ,
+ "ifxusb1_oc", (void *)oc1_int_id))
+ oc1_int_installed=0;
+ else
+ mod_timer(&oc1_retry_timer,jiffies + HZ*OC_Timer_Stable);
+ }
+ else
+ {
+ oc2_int_installed=2;
+ init_timer(&oc2_retry_timer);
+ oc2_retry_timer.function = oc_retry_timer_func;
+ oc2_retry_timer.data=2;
+ if(request_irq((unsigned int)IFXUSB2_OC_IRQ, &ifxhcd_oc_irq,
+ IRQF_TRIGGER_NONE
+ // | IRQF_TRIGGER_RISING
+ // | IRQF_TRIGGER_FALLING
+ // | IRQF_TRIGGER_HIGH
+ // | IRQF_TRIGGER_LOW
+ // | IRQF_TRIGGER_PROBE
+ | IRQF_DISABLED
+ // | IRQF_SAMPLE_RANDOM
+ // | IRQF_SHARED
+ | IRQF_PROBE_SHARED
+ // | IRQF_TIMER
+ // | IRQF_PERCPU
+ // | IRQF_NOBALANCING
+ // | IRQF_IRQPOLL
+ // | IRQF_ONESHOT
+ ,
+ "ifxusb2_oc", (void *)oc2_int_id))
+ oc2_int_installed=0;
+ else
+ mod_timer(&oc2_retry_timer,jiffies + HZ*OC_Timer_Stable);
+ }
+ /* Poll the event ring */
+ }
+ else if(port==1 && oc1_int_installed!=2 && oc1_int_installed!=4 )
+ {
+ oc1_int_installed=2;
+ enable_irq(IFXUSB1_OC_IRQ);
+ mod_timer(&oc1_retry_timer,jiffies + HZ*OC_Timer_Stable);
+ }
+ else if(port==2 && oc2_int_installed!=2 && oc2_int_installed!=4 )
+ {
+ oc2_int_installed=2;
+ enable_irq(IFXUSB2_OC_IRQ);
+ mod_timer(&oc2_retry_timer,jiffies + HZ*OC_Timer_Stable);
+ }
+ }
+ }
+
+ void ifxusb_oc_int_off(int port)
+ {
+ if(port==1)
+ {
+ disable_irq_nosync(IFXUSB1_OC_IRQ);
+ if(oc1_int_installed)
+ oc1_int_installed=1;
+ }
+ else
+ {
+ disable_irq_nosync(IFXUSB2_OC_IRQ);
+ if(oc2_int_installed)
+ oc2_int_installed=1;
+ }
+ }
+
+
+ void ifxusb_oc_int_free(int port)
+ {
+ if(port==1)
+ {
+ del_timer(&oc1_retry_timer);
+ disable_irq_nosync(IFXUSB1_OC_IRQ);
+ free_irq(IFXUSB1_OC_IRQ, (void *)oc1_int_id);
+ oc1_int_installed=0;
+ }
+ else
+ {
+ del_timer(&oc1_retry_timer);
+ disable_irq_nosync(IFXUSB1_OC_IRQ);
+ free_irq(IFXUSB2_OC_IRQ, (void *)oc2_int_id);
+ oc2_int_installed=0;
+ }
+ }
+
+ #elif defined(__IS_FIRST__) || defined(__IS_SECOND__)
+ unsigned int oc_int_installed=0;
+ unsigned int oc_int_count=0;
+ extern ifxhcd_hcd_t *oc_int_id;
+
+ /*!
+ \brief Handles host mode Over Current Interrupt
+ */
+ struct timer_list oc_retry_timer;
+
+ void oc_retry_timer_func(void)
+ {
+ if(oc_int_installed==0) //not installed
+ {
+ }
+ else if(oc_int_installed==1) //disabled
+ {
+ }
+ else if(oc_int_installed==2) //stablizing
+ {
+ oc_int_installed=4;
+ oc_int_count=0;
+ }
+ else if(oc_int_installed==3) // sleeping
+ {
+ mod_timer(&oc_retry_timer,jiffies + HZ*OC_Timer_Stable);
+ oc_int_installed=2;
+ #if defined(__IS_FIRST__)
+ enable_irq(IFXUSB1_OC_IRQ);
+ #else
+ enable_irq(IFXUSB2_OC_IRQ);
+ #endif
+ }
+ else if(oc_int_installed==4) //
+ {
+ oc_int_count=0;
+ }
+ else if(oc_int_installed==5) // Stable sleeping
+ {
+ mod_timer(&oc_retry_timer,jiffies + HZ*OC_Timer_Stable);
+ oc_int_installed=4;
+ #if defined(__IS_FIRST__)
+ enable_irq(IFXUSB1_OC_IRQ);
+ #else
+ enable_irq(IFXUSB2_OC_IRQ);
+ #endif
+ }
+ else
+ {
+ }
+ }
+
+ irqreturn_t ifxhcd_oc_irq(int _irq , void *_dev)
+ {
+ //ifxhcd_hcd_t *ifxhcd= _dev;
+ int32_t retval=1;
+ if(oc_int_installed==0) //not installed
+ {
+ }
+ else if(oc_int_installed==1) //disabled
+ {
+ }
+ else if(oc_int_installed==2) //stablizing
+ {
+ #if defined(__IS_FIRST__)
+ disable_irq_nosync(IFXUSB1_OC_IRQ);
+ #else
+ disable_irq_nosync(IFXUSB2_OC_IRQ);
+ #endif
+ mod_timer(&oc_retry_timer,jiffies + HZ/OC_Timer_Sleep);
+ oc_int_installed=3;
+ }
+ else if(oc_int_installed==3) // sleeping
+ {
+ }
+ else if(oc_int_installed==4) //
+ {
+ oc_int_count++;
+ if(oc_int_count>=OC_Timer_Max)
+ {
+ #if defined(__IS_FIRST__)
+ IFX_DEBUGP("OC INTERRUPT port #1\n");
+ #else
+ IFX_DEBUGP("OC INTERRUPT port #2\n");
+ #endif
+ oc_int_id->flags.b.port_over_current_change = 1;
+ ifxusb_vbus_off(&oc_int_id->core_if);
+ #if defined(__IS_FIRST__)
+ IFX_DEBUGP("Turning off port #1\n");
+ #else
+ IFX_DEBUGP("Turning off port #2\n");
+ #endif
+ }
+ else
+ {
+ #if defined(__IS_FIRST__)
+ disable_irq_nosync(IFXUSB1_OC_IRQ);
+ #else
+ disable_irq_nosync(IFXUSB2_OC_IRQ);
+ #endif
+ mod_timer(&oc_retry_timer,jiffies + HZ/OC_Timer_Sleep);
+ oc_int_installed=5;
+ }
+ }
+ else if(oc_int_installed==5) // Stable sleeping
+ {
+ }
+ return IRQ_RETVAL(retval);
+ }
+
+ void ifxusb_oc_int_on(void)
+ {
+ #if defined(__IS_FIRST__)
+ IFX_DEBUGPL( DBG_CIL, "registering (overcurrent) handler for port #1 irq%d\n", IFXUSB1_OC_IRQ);
+ #else
+ IFX_DEBUGPL( DBG_CIL, "registering (overcurrent) handler for port #2 irq%d\n", IFXUSB2_OC_IRQ);
+ #endif
+ if(oc_int_id)
+ {
+ if(oc_int_installed==0)
+ {
+ oc_int_installed=2;
+ init_timer(&oc_retry_timer);
+ oc_retry_timer.function = oc_retry_timer_func;
+ oc_retry_timer.data=1;
+ #if defined(__IS_FIRST__)
+ if(request_irq((unsigned int)IFXUSB1_OC_IRQ, &ifxhcd_oc_irq,
+ #else
+ if(request_irq((unsigned int)IFXUSB2_OC_IRQ, &ifxhcd_oc_irq,
+ #endif
+ IRQF_TRIGGER_NONE
+ // | IRQF_TRIGGER_RISING
+ // | IRQF_TRIGGER_FALLING
+ // | IRQF_TRIGGER_HIGH
+ // | IRQF_TRIGGER_LOW
+ // | IRQF_TRIGGER_PROBE
+ | IRQF_DISABLED
+ // | IRQF_SAMPLE_RANDOM
+ // | IRQF_SHARED
+ | IRQF_PROBE_SHARED
+ // | IRQF_TIMER
+ // | IRQF_PERCPU
+ // | IRQF_NOBALANCING
+ // | IRQF_IRQPOLL
+ // | IRQF_ONESHOT
+ ,
+ "ifxusb_oc", (void *)oc_int_id))
+ oc_int_installed=0;
+ else
+ mod_timer(&oc1_retry_timer,jiffies + HZ*OC_Timer_Stable);
+ }
+ else if(oc_int_installed!=2 && oc_int_installed!=4 )
+ {
+ oc_int_installed=2;
+ #if defined(__IS_FIRST__)
+ enable_irq(IFXUSB1_OC_IRQ);
+ #else
+ enable_irq(IFXUSB2_OC_IRQ);
+ #endif
+ mod_timer(&oc_retry_timer,jiffies + HZ*OC_Timer_Stable);
+ }
+ }
+ }
+
+ void ifxusb_oc_int_off(int port)
+ {
+ #if defined(__IS_FIRST__)
+ disable_irq_nosync(IFXUSB1_OC_IRQ);
+ #else
+ disable_irq_nosync(IFXUSB2_OC_IRQ);
+ #endif
+ }
+ void ifxusb_oc_int_free(int port)
+ {
+ #if defined(__IS_FIRST__)
+ free_irq(IFXUSB1_OC_IRQ, (void *)oc_int_id);
+ #else
+ free_irq(IFXUSB2_OC_IRQ, (void *)oc_int_id);
+ #endif
+ }
+ #endif
+ #else //!defined(__IS_AR10__)
+ unsigned int oc_int_installed=0;
+ unsigned int oc_int_count=0;
+ extern ifxhcd_hcd_t *oc_int_id;
+ #ifdef __IS_DUAL__
+ extern ifxhcd_hcd_t *oc_int_id_1;
+ extern ifxhcd_hcd_t *oc_int_id_2;
+ #endif
+
+ /*!
+ \brief Handles host mode Over Current Interrupt
+ */
+ struct timer_list oc_retry_timer;
+
+ void oc_retry_timer_func(unsigned long arg)
+ {
+ if(oc_int_installed==0) //not installed
+ {
+ }
+ else if(oc_int_installed==1) //disabled
+ {
+ }
+ else if(oc_int_installed==2) //stablizing
+ {
+ oc_int_installed=4;
+ oc_int_count=0;
+ }
+ else if(oc_int_installed==3) // sleeping
+ {
+ mod_timer(&oc_retry_timer,jiffies + HZ*OC_Timer_Stable);
+ oc_int_installed=2;
+ enable_irq(IFXUSB_OC_IRQ);
+ }
+ else if(oc_int_installed==4) //
+ {
+ oc_int_count=0;
+ }
+ else if(oc_int_installed==5) // Stable sleeping
+ {
+ mod_timer(&oc_retry_timer,jiffies + HZ*OC_Timer_Stable);
+ oc_int_installed=4;
+ enable_irq(IFXUSB_OC_IRQ);
+ }
+ else
+ {
+ }
+ }
+
+ irqreturn_t ifxhcd_oc_irq(int _irq , void *_dev)
+ {
+ //ifxhcd_hcd_t *ifxhcd= _dev;
+ int32_t retval=1;
+
+ if(oc_int_installed==0) //not installed
+ {
+ }
+ else if(oc_int_installed==1) //disabled
+ {
+ }
+ else if(oc_int_installed==2) //stablizing
+ {
+ disable_irq_nosync(IFXUSB_OC_IRQ);
+ mod_timer(&oc_retry_timer,jiffies + HZ/OC_Timer_Sleep);
+ oc_int_installed=3;
+ }
+ else if(oc_int_installed==3) // sleeping
+ {
+ }
+ else if(oc_int_installed==4) //
+ {
+ oc_int_count++;
+ if(oc_int_count>=OC_Timer_Max)
+ {
+ IFX_DEBUGP("OC INTERRUPT port #%d\n",oc_int_id->core_if.core_no);
+ #ifdef __IS_DUAL__
+ oc_int_id_1->flags.b.port_over_current_change = 1;
+ oc_int_id_2->flags.b.port_over_current_change = 1;
+ ifxusb_vbus_off(&oc_int_id_1->core_if);
+ IFX_DEBUGP("Turning off port #%d\n",oc_int_id_1->core_if.core_no);
+ ifxusb_vbus_off(&oc_int_id_2->core_if);
+ IFX_DEBUGP("Turning off port #%d\n",oc_int_id_2->core_if.core_no);
+ #else
+ oc_int_id->flags.b.port_over_current_change = 1;
+ ifxusb_vbus_off(&oc_int_id->core_if);
+ IFX_DEBUGP("Turning off port #%d\n",oc_int_id->core_if.core_no);
+ #endif
+ }
+ else
+ {
+ disable_irq_nosync(IFXUSB_OC_IRQ);
+ mod_timer(&oc_retry_timer,jiffies + HZ/OC_Timer_Sleep);
+ oc_int_installed=5;
+ }
+ }
+ else if(oc_int_installed==5) // Stable sleeping
+ {
+ }
+
+ return IRQ_RETVAL(retval);
+ }
+
+ void ifxusb_oc_int_on(void)
+ {
+ IFX_DEBUGPL( DBG_CIL, "registering (overcurrent) handler for irq%d\n", IFXUSB_OC_IRQ);
+ if(oc_int_id)
+ {
+ if(oc_int_installed==0)
+ {
+ oc_int_installed=2;
+ init_timer(&oc_retry_timer);
+ oc_retry_timer.function = oc_retry_timer_func;
+ /* Poll the event ring */
+
+ if(request_irq((unsigned int)IFXUSB_OC_IRQ, &ifxhcd_oc_irq,
+ IRQF_TRIGGER_NONE
+ // | IRQF_TRIGGER_RISING
+ // | IRQF_TRIGGER_FALLING
+ // | IRQF_TRIGGER_HIGH
+ // | IRQF_TRIGGER_LOW
+ // | IRQF_TRIGGER_PROBE
+ | IRQF_DISABLED
+ // | IRQF_SAMPLE_RANDOM
+ // | IRQF_SHARED
+ // | IRQF_PROBE_SHARED
+ // | IRQF_TIMER
+ // | IRQF_PERCPU
+ // | IRQF_NOBALANCING
+ // | IRQF_IRQPOLL
+ // | IRQF_ONESHOT
+ ,
+ "ifxusb_oc", (void *)oc_int_id))
+ oc_int_installed=0;
+ else
+ mod_timer(&oc_retry_timer,jiffies + HZ*OC_Timer_Stable);
+ }
+ else if(oc_int_installed!=2 && oc_int_installed!=4 )
+ {
+ oc_int_installed=2;
+ enable_irq(IFXUSB_OC_IRQ);
+ mod_timer(&oc_retry_timer,jiffies + HZ*OC_Timer_Stable);
+ }
+ }
+ }
+
+ void ifxusb_oc_int_off(void)
+ {
+ disable_irq_nosync(IFXUSB_OC_IRQ);
+ if(oc_int_installed)
+ oc_int_installed=1;
+ }
+
+ void ifxusb_oc_int_free(void)
+ {
+ del_timer(&oc_retry_timer);
+ disable_irq_nosync(IFXUSB_OC_IRQ);
+ if(oc_int_installed)
+ free_irq(IFXUSB_OC_IRQ, (void *)oc_int_id);
+ oc_int_installed=0;
+ }
+ #endif
+#endif
+
+
+/*!
+ \fn void ifxusb_vbus_on(ifxusb_core_if_t *_core_if)
+ \brief Turn on the USB 5V VBus Power
+ \param _core_if Pointer of core_if structure
+ \ingroup IFXUSB_CIF
+ */
+void ifxusb_vbus_on(ifxusb_core_if_t *_core_if)
+{
+ IFX_DEBUGP("SENDING VBus POWER UP\n");
+ #if defined(__UEIP__)
+ #if defined(IFX_LEDGPIO_USB_VBUS) || defined(IFX_LEDLED_USB_VBUS)
+ if ( g_usb_vbus_trigger && ifxusb_vbus_status==0)
+ {
+ ifx_led_trigger_activate(g_usb_vbus_trigger);
+ IFX_DEBUGP("Enable USB power!!\n");
+ ifxusb_vbus_status=1;
+ }
+ #endif
+ #if defined(IFX_LEDGPIO_USB_VBUS1) || defined(IFX_LEDLED_USB_VBUS1)
+ if(_core_if->core_no==0 && g_usb_vbus1_trigger && ifxusb_vbus1_status==0)
+ {
+ ifx_led_trigger_activate(g_usb_vbus1_trigger);
+ IFX_DEBUGP("Enable USB1 power!!\n");
+ ifxusb_vbus1_status=1;
+ }
+ #endif
+ #if defined(IFX_LEDGPIO_USB_VBUS2) || defined(IFX_LEDLED_USB_VBUS2)
+ if(_core_if->core_no==1 && g_usb_vbus2_trigger && ifxusb_vbus2_status==0)
+ {
+ ifx_led_trigger_activate(g_usb_vbus2_trigger);
+ IFX_DEBUGP("Enable USB2 power!!\n");
+ ifxusb_vbus2_status=1;
+ }
+ #endif
+
+ #if defined(IFX_GPIO_USB_VBUS) || defined(IFX_GPIO_USB_VBUS1) || defined(IFX_GPIO_USB_VBUS2)
+ if(ifxusb_vbus_gpio_inited)
+ {
+ #if defined(IFX_GPIO_USB_VBUS)
+ if(ifxusb_vbus_status==0)
+ {
+ ifx_gpio_output_set(IFX_GPIO_USB_VBUS,IFX_GPIO_MODULE_USB);
+ ifxusb_vbus_status=1;
+ }
+ #endif
+ #if defined(IFX_GPIO_USB_VBUS1)
+ if(_core_if->core_no==0 && ifxusb_vbus1_status==0)
+ {
+ ifx_gpio_output_set(IFX_GPIO_USB_VBUS1,IFX_GPIO_MODULE_USB);
+ ifxusb_vbus1_status=1;
+ }
+ #endif
+ #if defined(IFX_GPIO_USB_VBUS2)
+ if(_core_if->core_no==1 && ifxusb_vbus2_status==0)
+ {
+ ifx_gpio_output_set(IFX_GPIO_USB_VBUS2,IFX_GPIO_MODULE_USB);
+ ifxusb_vbus2_status=1;
+ }
+ #endif
+ }
+ #endif //defined(IFX_GPIO_USB_VBUS) || defined(IFX_GPIO_USB_VBUS1) || defined(IFX_GPIO_USB_VBUS2)
+ #else
+ #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ ifxusb_vbus_status=1;
+ //usb_set_vbus_on();
+ #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ #if defined(__IS_AMAZON_SE__)
+ set_bit (4, (volatile unsigned long *)AMAZON_SE_GPIO_P0_OUT);
+ ifxusb_vbus_status=1;
+ #endif //defined(__IS_AMAZON_SE__)
+ #if defined(__IS_AR9__)
+ if(_core_if->core_no==0)
+ {
+ if (bsp_port_reserve_pin(1, 13, PORT_MODULE_USB) != 0)
+ {
+ IFX_PRINT("Can't enable USB1 5.5V power!!\n");
+ return;
+ }
+ bsp_port_clear_altsel0(1, 13, PORT_MODULE_USB);
+ bsp_port_clear_altsel1(1, 13, PORT_MODULE_USB);
+ bsp_port_set_dir_out(1, 13, PORT_MODULE_USB);
+ bsp_port_set_pudsel(1, 13, PORT_MODULE_USB);
+ bsp_port_set_puden(1, 13, PORT_MODULE_USB);
+ bsp_port_set_output(1, 13, PORT_MODULE_USB);
+ IFX_DEBUGP("Enable USB1 power!!\n");
+ ifxusb_vbus1_status=1;
+ }
+ else
+ {
+ if (bsp_port_reserve_pin(3, 4, PORT_MODULE_USB) != 0)
+ {
+ IFX_PRINT("Can't enable USB2 5.5V power!!\n");
+ return;
+ }
+ bsp_port_clear_altsel0(3, 4, PORT_MODULE_USB);
+ bsp_port_clear_altsel1(3, 4, PORT_MODULE_USB);
+ bsp_port_set_dir_out(3, 4, PORT_MODULE_USB);
+ bsp_port_set_pudsel(3, 4, PORT_MODULE_USB);
+ bsp_port_set_puden(3, 4, PORT_MODULE_USB);
+ bsp_port_set_output(3, 4, PORT_MODULE_USB);
+ IFX_DEBUGP("Enable USB2 power!!\n");
+ ifxusb_vbus2_status=1;
+ }
+ #endif //defined(__IS_AR9__)
+ #if defined(__IS_VR9__)
+ if(_core_if->core_no==0)
+ {
+ ifxusb_vbus1_status=1;
+ }
+ else
+ {
+ ifxusb_vbus2_status=1;
+ }
+ #endif //defined(__IS_VR9__)
+ #endif //defined(__UEIP__)
+
+ #if defined(__DO_OC_INT__)
+ #if defined(__IS_AR10__) && defined(__IS_DUAL__)
+ if(_core_if->core_no==0)
+ ifxusb_oc_int_on(1);
+ else
+ ifxusb_oc_int_on(2);
+ #else
+ ifxusb_oc_int_on();
+ #endif
+ #endif
+
+}
+
+
+/*!
+ \fn void ifxusb_vbus_off(ifxusb_core_if_t *_core_if)
+ \brief Turn off the USB 5V VBus Power
+ \param _core_if Pointer of core_if structure
+ \ingroup IFXUSB_CIF
+ */
+void ifxusb_vbus_off(ifxusb_core_if_t *_core_if)
+{
+ IFX_DEBUGP("SENDING VBus POWER OFF\n");
+
+ #if defined(__UEIP__)
+ #if defined(IFX_LEDGPIO_USB_VBUS) || defined(IFX_LEDLED_USB_VBUS)
+ if ( g_usb_vbus_trigger && ifxusb_vbus_status==1)
+ {
+ ifx_led_trigger_deactivate(g_usb_vbus_trigger);
+ IFX_DEBUGP("Disable USB power!!\n");
+ ifxusb_vbus_status=0;
+ }
+ #endif
+ #if defined(IFX_LEDGPIO_USB_VBUS1) || defined(IFX_LEDLED_USB_VBUS1)
+ if(_core_if->core_no==0 && g_usb_vbus1_trigger && ifxusb_vbus1_status==1)
+ {
+ ifx_led_trigger_deactivate(g_usb_vbus1_trigger);
+ IFX_DEBUGP("Disable USB1 power!!\n");
+ ifxusb_vbus1_status=0;
+ }
+ #endif
+ #if defined(IFX_LEDGPIO_USB_VBUS2) || defined(IFX_LEDLED_USB_VBUS2)
+ if(_core_if->core_no==1 && g_usb_vbus2_trigger && ifxusb_vbus2_status==1)
+ {
+ ifx_led_trigger_deactivate(g_usb_vbus2_trigger);
+ IFX_DEBUGP("Disable USB2 power!!\n");
+ ifxusb_vbus2_status=0;
+ }
+ #endif
+
+ #if defined(IFX_GPIO_USB_VBUS) || defined(IFX_GPIO_USB_VBUS1) || defined(IFX_GPIO_USB_VBUS2)
+ if(ifxusb_vbus_gpio_inited)
+ {
+ #if defined(IFX_GPIO_USB_VBUS)
+ if(ifxusb_vbus_status==1)
+ {
+ ifx_gpio_output_clear(IFX_GPIO_USB_VBUS,IFX_GPIO_MODULE_USB);
+ ifxusb_vbus_status=0;
+ }
+ #endif
+ #if defined(IFX_GPIO_USB_VBUS1)
+ if(_core_if->core_no==0 && ifxusb_vbus1_status==1)
+ {
+ ifx_gpio_output_clear(IFX_GPIO_USB_VBUS1,IFX_GPIO_MODULE_USB);
+ ifxusb_vbus1_status=0;
+ }
+ #endif
+ #if defined(IFX_GPIO_USB_VBUS2)
+ if(_core_if->core_no==1 && ifxusb_vbus2_status==1)
+ {
+ ifx_gpio_output_clear(IFX_GPIO_USB_VBUS2,IFX_GPIO_MODULE_USB);
+ ifxusb_vbus2_status=0;
+ }
+ #endif
+ }
+ #endif //defined(IFX_GPIO_USB_VBUS) || defined(IFX_GPIO_USB_VBUS1) || defined(IFX_GPIO_USB_VBUS2)
+ #else
+ #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ ifxusb_vbus_status=0;
+ //usb_set_vbus_on();
+ #endif //defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ #if defined(__IS_AMAZON_SE__)
+ clear_bit (4, (volatile unsigned long *)AMAZON_SE_GPIO_P0_OUT);
+ ifxusb_vbus_status=0;
+ #endif //defined(__IS_AMAZON_SE__)
+ #if defined(__IS_AR9__)
+ if(_core_if->core_no==0)
+ {
+ if (bsp_port_reserve_pin(1, 13, PORT_MODULE_USB) != 0) {
+ IFX_PRINT("Can't Disable USB1 5.5V power!!\n");
+ return;
+ }
+ bsp_port_clear_altsel0(1, 13, PORT_MODULE_USB);
+ bsp_port_clear_altsel1(1, 13, PORT_MODULE_USB);
+ bsp_port_set_dir_out(1, 13, PORT_MODULE_USB);
+ bsp_port_set_pudsel(1, 13, PORT_MODULE_USB);
+ bsp_port_set_puden(1, 13, PORT_MODULE_USB);
+ bsp_port_clear_output(1, 13, PORT_MODULE_USB);
+ IFX_DEBUGP("Disable USB1 power!!\n");
+ ifxusb_vbus1_status=0;
+ }
+ else
+ {
+ if (bsp_port_reserve_pin(3, 4, PORT_MODULE_USB) != 0) {
+ IFX_PRINT("Can't Disable USB2 5.5V power!!\n");
+ return;
+ }
+ bsp_port_clear_altsel0(3, 4, PORT_MODULE_USB);
+ bsp_port_clear_altsel1(3, 4, PORT_MODULE_USB);
+ bsp_port_set_dir_out(3, 4, PORT_MODULE_USB);
+ bsp_port_set_pudsel(3, 4, PORT_MODULE_USB);
+ bsp_port_set_puden(3, 4, PORT_MODULE_USB);
+ bsp_port_clear_output(3, 4, PORT_MODULE_USB);
+ IFX_DEBUGP("Disable USB2 power!!\n");
+
+ ifxusb_vbus2_status=0;
+ }
+ #endif //defined(__IS_AR9__)
+ #if defined(__IS_VR9__)
+ if(_core_if->core_no==0)
+ {
+ ifxusb_vbus1_status=0;
+ }
+ else
+ {
+ ifxusb_vbus2_status=0;
+ }
+ #endif //defined(__IS_VR9__)
+ #endif //defined(__UEIP__)
+ #if defined(__DO_OC_INT__)
+ #if defined(__IS_AR10__) && defined(__IS_DUAL__)
+ if(_core_if->core_no==0)
+ ifxusb_oc_int_off(1);
+ else
+ ifxusb_oc_int_off(2);
+ #else
+ ifxusb_oc_int_off();
+ #endif
+ #endif
+}
+
+
+/*!
+ \fn int ifxusb_vbus(ifxusb_core_if_t *_core_if)
+ \brief Read Current VBus status
+ \param _core_if Pointer of core_if structure
+ \ingroup IFXUSB_CIF
+ */
+int ifxusb_vbus(ifxusb_core_if_t *_core_if)
+{
+#if defined(__UEIP__)
+ #if defined(IFX_GPIO_USB_VBUS) || defined(IFX_LEDGPIO_USB_VBUS) || defined(IFX_LEDLED_USB_VBUS)
+ return (ifxusb_vbus_status);
+ #endif
+
+ #if defined(IFX_GPIO_USB_VBUS1) || defined(IFX_LEDGPIO_USB_VBUS1) || defined(IFX_LEDLED_USB_VBUS1)
+ if(_core_if->core_no==0)
+ return (ifxusb_vbus1_status);
+ #endif
+
+ #if defined(IFX_GPIO_USB_VBUS2) || defined(IFX_LEDGPIO_USB_VBUS2) || defined(IFX_LEDLED_USB_VBUS2)
+ if(_core_if->core_no==1)
+ return (ifxusb_vbus2_status);
+ #endif
+#else //defined(__UEIP__)
+#endif
+ return -1;
+}
+
+#if defined(__UEIP__)
+#else
+ #if defined(__IS_TWINPASS__)
+ #define ADSL_BASE 0x20000
+ #define CRI_BASE 0x31F00
+ #define CRI_CCR0 CRI_BASE + 0x00
+ #define CRI_CCR1 CRI_BASE + 0x01*4
+ #define CRI_CDC0 CRI_BASE + 0x02*4
+ #define CRI_CDC1 CRI_BASE + 0x03*4
+ #define CRI_RST CRI_BASE + 0x04*4
+ #define CRI_MASK0 CRI_BASE + 0x05*4
+ #define CRI_MASK1 CRI_BASE + 0x06*4
+ #define CRI_MASK2 CRI_BASE + 0x07*4
+ #define CRI_STATUS0 CRI_BASE + 0x08*4
+ #define CRI_STATUS1 CRI_BASE + 0x09*4
+ #define CRI_STATUS2 CRI_BASE + 0x0A*4
+ #define CRI_AMASK0 CRI_BASE + 0x0B*4
+ #define CRI_AMASK1 CRI_BASE + 0x0C*4
+ #define CRI_UPDCTL CRI_BASE + 0x0D*4
+ #define CRI_MADST CRI_BASE + 0x0E*4
+ // 0x0f is missing
+ #define CRI_EVENT0 CRI_BASE + 0x10*4
+ #define CRI_EVENT1 CRI_BASE + 0x11*4
+ #define CRI_EVENT2 CRI_BASE + 0x12*4
+
+ #define IRI_I_ENABLE 0x32000
+ #define STY_SMODE 0x3c004
+ #define AFE_TCR_0 0x3c0dc
+ #define AFE_ADDR_ADDR 0x3c0e8
+ #define AFE_RDATA_ADDR 0x3c0ec
+ #define AFE_WDATA_ADDR 0x3c0f0
+ #define AFE_CONFIG 0x3c0f4
+ #define AFE_SERIAL_CFG 0x3c0fc
+
+ #define DFE_BASE_ADDR 0xBE116000
+ //#define DFE_BASE_ADDR 0x9E116000
+
+ #define MEI_FR_ARCINT_C (DFE_BASE_ADDR + 0x0000001C)
+ #define MEI_DBG_WADDR_C (DFE_BASE_ADDR + 0x00000024)
+ #define MEI_DBG_RADDR_C (DFE_BASE_ADDR + 0x00000028)
+ #define MEI_DBG_DATA_C (DFE_BASE_ADDR + 0x0000002C)
+ #define MEI_DBG_DECO_C (DFE_BASE_ADDR + 0x00000030)
+ #define MEI_DBG_MASTER_C (DFE_BASE_ADDR + 0x0000003C)
+
+ static void WriteARCmem(uint32_t addr, uint32_t data)
+ {
+ writel(1 ,(volatile uint32_t *)MEI_DBG_MASTER_C);
+ writel(1 ,(volatile uint32_t *)MEI_DBG_DECO_C );
+ writel(addr ,(volatile uint32_t *)MEI_DBG_WADDR_C );
+ writel(data ,(volatile uint32_t *)MEI_DBG_DATA_C );
+ while( (ifxusb_rreg((volatile uint32_t *)MEI_FR_ARCINT_C) & 0x20) != 0x20 ){};
+ writel(0 ,(volatile uint32_t *)MEI_DBG_MASTER_C);
+ IFX_DEBUGP("WriteARCmem %08x %08x\n",addr,data);
+ };
+
+ static uint32_t ReadARCmem(uint32_t addr)
+ {
+ u32 data;
+ writel(1 ,(volatile uint32_t *)MEI_DBG_MASTER_C);
+ writel(1 ,(volatile uint32_t *)MEI_DBG_DECO_C );
+ writel(addr ,(volatile uint32_t *)MEI_DBG_RADDR_C );
+ while( (ifxusb_rreg((volatile uint32_t *)MEI_FR_ARCINT_C) & 0x20) != 0x20 ){};
+ data = ifxusb_rreg((volatile uint32_t *)MEI_DBG_DATA_C );
+ writel(0 ,(volatile uint32_t *)MEI_DBG_MASTER_C);
+ IFX_DEBUGP("ReadARCmem %08x %08x\n",addr,data);
+ return data;
+ };
+
+ void ifxusb_enable_afe_oc(void)
+ {
+ /* Start the clock */
+ WriteARCmem(CRI_UPDCTL ,0x00000008);
+ WriteARCmem(CRI_CCR0 ,0x00000014);
+ WriteARCmem(CRI_CCR1 ,0x00000500);
+ WriteARCmem(AFE_CONFIG ,0x000001c8);
+ WriteARCmem(AFE_SERIAL_CFG,0x00000016); // (DANUBE_PCI_CFG_BASE+(1<<addrline))AFE serial interface clock & data latch edge
+ WriteARCmem(AFE_TCR_0 ,0x00000002);
+ //Take afe out of reset
+ WriteARCmem(AFE_CONFIG ,0x000000c0);
+ WriteARCmem(IRI_I_ENABLE ,0x00000101);
+ WriteARCmem(STY_SMODE ,0x00001980);
+
+ ReadARCmem(CRI_UPDCTL );
+ ReadARCmem(CRI_CCR0 );
+ ReadARCmem(CRI_CCR1 );
+ ReadARCmem(AFE_CONFIG );
+ ReadARCmem(AFE_SERIAL_CFG); // (DANUBE_PCI_CFG_BASE+(1<<addrline))AFE serial interface clock & data latch edge
+ ReadARCmem(AFE_TCR_0 );
+ ReadARCmem(AFE_CONFIG );
+ ReadARCmem(IRI_I_ENABLE );
+ ReadARCmem(STY_SMODE );
+ }
+ #endif //defined(__IS_TWINPASS__)
+#endif //defined(__UEIP__)
+
diff --git a/package/platform/lantiq/ltq-hcd/src/ifxusb_ctl.c b/package/platform/lantiq/ltq-hcd/src/ifxusb_ctl.c
new file mode 100644
index 0000000..32878e3
--- /dev/null
+++ b/package/platform/lantiq/ltq-hcd/src/ifxusb_ctl.c
@@ -0,0 +1,3825 @@
+/*****************************************************************************
+ ** FILE NAME : ifxusb_ctl.c
+ ** PROJECT : IFX USB sub-system V3
+ ** MODULES : IFX USB sub-system Host and Device driver
+ ** SRC VERSION : 1.0
+ ** SRC VERSION : 3.2
+ ** DATE : 1/Jan/2011
+ ** DESCRIPTION : Implementing the procfs and sysfs for IFX USB driver
+ ** FUNCTIONS :
+ ** COMPILER : gcc
+ ** REFERENCE : Synopsys DWC-OTG Driver 2.7
+ ** COPYRIGHT : Copyright (c) 2010
+ ** LANTIQ DEUTSCHLAND GMBH,
+ ** Am Campeon 3, 85579 Neubiberg, Germany
+ **
+ ** 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 of the License, or
+ ** (at your option) any later version.
+ **
+ ** Version Control Section **
+ ** $Author$
+ ** $Date$
+ ** $Revisions$
+ ** $Log$ Revision history
+ *****************************************************************************/
+
+/*
+ * This file contains code fragments from Synopsys HS OTG Linux Software Driver.
+ * For this code the following notice is applicable:
+ *
+ * ==========================================================================
+ *
+ * Synopsys HS OTG Linux Software Driver and documentation (hereinafter,
+ * "Software") is an Unsupported proprietary work of Synopsys, Inc. unless
+ * otherwise expressly agreed to in writing between Synopsys and you.
+ *
+ * The Software IS NOT an item of Licensed Software or Licensed Product under
+ * any End User Software License Agreement or Agreement for Licensed Product
+ * with Synopsys or any supplement thereto. You are permitted to use and
+ * redistribute this Software in source and binary forms, with or without
+ * modification, provided that redistributions of source code must retain this
+ * notice. You may not view, use, disclose, copy or distribute this file or
+ * any information contained herein except pursuant to this license grant from
+ * Synopsys. If you do not agree with this notice, including the disclaimer
+ * below, then you are not authorized to use the Software.
+ *
+ * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" BASIS
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ * ========================================================================== */
+
+/*! \file ifxusb_ctl.c
+ \ingroup IFXUSB_DRIVER_V3
+ \brief Implementing the procfs and sysfs for IFX USB driver
+*/
+
+#include <linux/version.h>
+#include "ifxusb_version.h"
+
+
+#include <linux/proc_fs.h>
+#include <asm/byteorder.h>
+#include <asm/unaligned.h>
+#include <asm/uaccess.h>
+
+#include "ifxusb_plat.h"
+#include "ifxusb_regs.h"
+#include "ifxusb_cif.h"
+
+#ifdef __IS_DEVICE__
+ #include "ifxpcd.h"
+ #ifdef __GADGET_COC__
+ #include <asm/ifx/ifx_types.h>
+ #include <asm/ifx/ifx_pmcu.h>
+ IFX_PMCU_REGISTER_t pmcuRegisterUSBGadget;
+ #endif
+#endif
+
+#ifdef __IS_HOST__
+ #include "ifxhcd.h"
+ #ifdef __HOST_COC__
+ #include <asm/ifx/ifx_types.h>
+ #include <asm/ifx/ifx_pmcu.h>
+ #ifdef __IS_DUAL__
+ IFX_PMCU_REGISTER_t pmcuRegisterUSBHost_1;
+ IFX_PMCU_REGISTER_t pmcuRegisterUSBHost_2;
+ #else
+ IFX_PMCU_REGISTER_t pmcuRegisterUSBHost;
+ #endif
+ #endif
+#endif
+
+#include <linux/device.h>
+#include <linux/platform_device.h>
+#include <linux/gfp.h>
+
+#ifdef __IS_HOST__
+ extern char ifxusb_hcd_driver_name[];
+
+ #ifdef __IS_DUAL__
+ extern ifxhcd_hcd_t ifxusb_hcd_1;
+ extern ifxhcd_hcd_t ifxusb_hcd_2;
+ extern char ifxusb_hcd_name_1[];
+ extern char ifxusb_hcd_name_2[];
+ #else
+ extern ifxhcd_hcd_t ifxusb_hcd;
+ extern char ifxusb_hcd_name[];
+ #endif
+
+#endif
+
+#ifdef __IS_DEVICE__
+ extern char ifxusb_pcd_driver_name[];
+
+ extern ifxpcd_pcd_t ifxusb_pcd;
+ extern char ifxusb_pcd_name[];
+#endif
+
+
+//Attributes for sysfs (for 2.6 only)
+
+#ifdef __IS_HOST__
+extern struct device_attribute dev_attr_version_h;
+#else
+extern struct device_attribute dev_attr_version_d;
+#endif
+#ifdef __IS_HOST__
+extern struct device_attribute dev_attr_dbglevel_h;
+#else
+extern struct device_attribute dev_attr_dbglevel_d;
+#endif
+#ifdef __IS_HOST__
+ #ifdef __IS_DUAL__
+ extern struct device_attribute dev_attr_suspend_host_1;
+ extern struct device_attribute dev_attr_suspend_host_2;
+ extern struct device_attribute dev_attr_probe_host_1;
+ extern struct device_attribute dev_attr_probe_host_2;
+ extern struct device_attribute dev_attr_probe_timer1_val_h;
+ extern struct device_attribute dev_attr_probe_timer2_val_h;
+ extern struct device_attribute dev_attr_autoprobe_timer1_val_h;
+ extern struct device_attribute dev_attr_autoprobe_timer2_val_h;
+ #else
+ extern struct device_attribute dev_attr_suspend_host;
+ extern struct device_attribute dev_attr_probe_host;
+ extern struct device_attribute dev_attr_probe_timer_val_h;
+ extern struct device_attribute dev_attr_autoprobe_timer_val_h;
+ #endif
+#endif
+
+#ifdef __IS_DEVICE__
+ extern struct device_attribute dev_attr_suspend_device;
+ extern struct device_attribute dev_attr_probe_device;
+ extern struct device_attribute dev_attr_probe_timer_val_d;
+ extern struct device_attribute dev_attr_autoprobe_timer_val_d;
+#endif
+
+#ifdef __IS_HOST__
+ #ifdef __IS_DUAL__
+ extern struct device_attribute dev_attr_dump_params_h_1;
+ extern struct device_attribute dev_attr_dump_params_h_2;
+ extern struct device_attribute dev_attr_mode_h_1;
+ extern struct device_attribute dev_attr_mode_h_2;
+ #else
+ extern struct device_attribute dev_attr_dump_params_h;
+ extern struct device_attribute dev_attr_mode_h;
+ #endif
+#else
+ extern struct device_attribute dev_attr_dump_params_d;
+ extern struct device_attribute dev_attr_mode_d;
+#endif
+
+#ifdef __IS_HOST__
+ #ifdef __IS_DUAL__
+ extern struct device_attribute dev_attr_pkt_count_limit_bi_1;
+ extern struct device_attribute dev_attr_pkt_count_limit_bo_1;
+ extern struct device_attribute dev_attr_pkt_count_limit_bi_2;
+ extern struct device_attribute dev_attr_pkt_count_limit_bo_2;
+ extern struct device_attribute dev_attr_bandwidth_fs_1;
+ extern struct device_attribute dev_attr_bandwidth_ls_1;
+ extern struct device_attribute dev_attr_bandwidth_hs_2;
+ extern struct device_attribute dev_attr_bandwidth_fs_2;
+ extern struct device_attribute dev_attr_bandwidth_ls_2;
+ extern struct device_attribute dev_attr_buspower_1;
+ extern struct device_attribute dev_attr_buspower_2;
+ extern struct device_attribute dev_attr_bussuspend_1;
+ extern struct device_attribute dev_attr_bussuspend_2;
+ extern struct device_attribute dev_attr_busconnected_1;
+ extern struct device_attribute dev_attr_busconnected_2;
+ extern struct device_attribute dev_attr_connectspeed_1;
+ extern struct device_attribute dev_attr_connectspeed_1;
+ #else
+ extern struct device_attribute dev_attr_pkt_count_limit_bi;
+ extern struct device_attribute dev_attr_pkt_count_limit_bo;
+ extern struct device_attribute dev_attr_bandwidth_hs;
+ extern struct device_attribute dev_attr_bandwidth_fs;
+ extern struct device_attribute dev_attr_bandwidth_ls;
+ extern struct device_attribute dev_attr_buspower;
+ extern struct device_attribute dev_attr_bussuspend;
+ extern struct device_attribute dev_attr_busconnected;
+ extern struct device_attribute dev_attr_connectspeed;
+ #endif
+#endif //__IS_HOST__
+
+#ifdef __IS_DEVICE__
+ extern struct device_attribute dev_attr_devspeed;
+ extern struct device_attribute dev_attr_enumspeed;
+#endif //__IS_DEVICE__
+
+#ifdef __ENABLE_DUMP__
+ #ifdef __IS_HOST__
+ #ifdef __IS_DUAL__
+ extern struct device_attribute dev_attr_dump_reg_h_1;
+ extern struct device_attribute dev_attr_dump_reg_h_2;
+ extern struct device_attribute dev_attr_dump_spram_h_1;
+ extern struct device_attribute dev_attr_dump_spram_h_2;
+ extern struct device_attribute dev_attr_dump_host_state_1;
+ extern struct device_attribute dev_attr_dump_host_state_2;
+ #else
+ extern struct device_attribute dev_attr_dump_reg_h;
+ extern struct device_attribute dev_attr_dump_spram_h;
+ extern struct device_attribute dev_attr_dump_host_state;
+ #endif
+ #else
+ extern struct device_attribute dev_attr_dump_reg_d;
+ extern struct device_attribute dev_attr_dump_spram_d;
+ #endif
+#endif //__ENABLE_DUMP__
+
+
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+
+static ssize_t procfs_version_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+{
+ return sprintf( buf, "%s\n",IFXUSB_VERSION );
+}
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_version_show( struct device *_dev, struct device_attribute *attr,char *buf)
+#else
+ static ssize_t sysfs_version_show( struct device *_dev, char *buf)
+#endif
+{
+ return sprintf( buf, "%s\n",IFXUSB_VERSION );
+}
+
+#ifdef __IS_HOST__
+DEVICE_ATTR(version_h, S_IRUGO|S_IWUSR, sysfs_version_show, NULL);
+#else
+DEVICE_ATTR(version_d, S_IRUGO|S_IWUSR, sysfs_version_show, NULL);
+#endif
+
+
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+
+static ssize_t procfs_dbglevel_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+{
+ #ifdef __IS_HOST__
+ return sprintf( buf, "%08X\n",h_dbg_lvl );
+ #else
+ return sprintf( buf, "%08X\n",d_dbg_lvl );
+ #endif
+}
+
+static ssize_t procfs_dbglevel_store(struct file *file, const char *buffer, unsigned long count, void *data)
+{
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 16);
+ #ifdef __IS_HOST__
+ h_dbg_lvl =value;
+ #else
+ d_dbg_lvl =value;
+ #endif
+ //turn on and off power
+ return count;
+}
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_dbglevel_show( struct device *_dev, struct device_attribute *attr,char *buf)
+#else
+ static ssize_t sysfs_dbglevel_show( struct device *_dev, char *buf)
+#endif
+{
+ #ifdef __IS_HOST__
+ return sprintf( buf, "%08X\n",h_dbg_lvl );
+ #else
+ return sprintf( buf, "%08X\n",d_dbg_lvl );
+ #endif
+}
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_dbglevel_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+#else
+ static ssize_t sysfs_dbglevel_store( struct device *_dev, const char *buffer, size_t count )
+#endif
+{
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 16);
+ #ifdef __IS_HOST__
+ h_dbg_lvl =value;
+ #else
+ d_dbg_lvl =value;
+ #endif
+ //turn on and off power
+ return count;
+}
+
+#ifdef __IS_HOST__
+DEVICE_ATTR(dbglevel_h, S_IRUGO|S_IWUSR, sysfs_dbglevel_show, sysfs_dbglevel_store);
+#else
+DEVICE_ATTR(dbglevel_d, S_IRUGO|S_IWUSR, sysfs_dbglevel_show, sysfs_dbglevel_store);
+#endif
+
+
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+
+static void ifxusb_dump_params(ifxusb_core_if_t *_core_if);
+
+#ifdef __IS_DUAL__
+ static void dump_params_1(void)
+ {
+ ifxusb_dump_params(&ifxusb_hcd_1.core_if);
+ }
+ static void dump_params_2(void)
+ {
+ ifxusb_dump_params(&ifxusb_hcd_2.core_if);
+ }
+
+ static ssize_t procfs_dump_params_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ dump_params_1();
+ return 0;
+ }
+ static ssize_t procfs_dump_params_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ dump_params_2();
+ return 0;
+ }
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_dump_params_show_1( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_dump_params_show_1( struct device *_dev,char *buf)
+ #endif
+ {
+ dump_params_1();
+ return 0;
+ }
+ DEVICE_ATTR(dump_params_h_1, S_IRUGO|S_IWUSR, sysfs_dump_params_show_1, NULL);
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_dump_params_show_2( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_dump_params_show_2( struct device *_dev,char *buf)
+ #endif
+ {
+ dump_params_2();
+ return 0;
+ }
+
+ DEVICE_ATTR(dump_params_h_2, S_IRUGO|S_IWUSR, sysfs_dump_params_show_2, NULL);
+#else
+ static void dump_params(void)
+ {
+ #ifdef __IS_HOST__
+ ifxusb_dump_params(&ifxusb_hcd.core_if);
+ #else
+ ifxusb_dump_params(&ifxusb_pcd.core_if);
+ #endif
+ }
+
+ static ssize_t procfs_dump_params_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ dump_params();
+ return 0;
+ }
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_dump_params_show( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_dump_params_show( struct device *_dev,char *buf)
+ #endif
+ {
+ dump_params();
+ return 0;
+ }
+
+ #ifdef __IS_HOST__
+ DEVICE_ATTR(dump_params_h, S_IRUGO|S_IWUSR, sysfs_dump_params_show, NULL);
+ #else
+ DEVICE_ATTR(dump_params_d, S_IRUGO|S_IWUSR, sysfs_dump_params_show, NULL);
+ #endif
+#endif
+
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifdef __IS_DUAL__
+ static ssize_t mode_show_1(char *buf)
+ {
+ if((ifxusb_rreg(&ifxusb_hcd_1.core_if.core_global_regs->gintsts ) & 0x1) == 1)
+ return sprintf( buf, "HOST\n" );
+ else
+ return sprintf( buf, "DEVICE(INCORRECT!)\n" );
+ }
+
+ static ssize_t mode_show_2(char *buf)
+ {
+ if((ifxusb_rreg(&ifxusb_hcd_2.core_if.core_global_regs->gintsts ) & 0x1) == 1)
+ return sprintf( buf, "HOST\n" );
+ else
+ return sprintf( buf, "DEVICE(INCORRECT!)\n" );
+ }
+
+ static ssize_t procfs_mode_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return mode_show_1(buf);
+ }
+ static ssize_t procfs_mode_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return mode_show_2(buf);
+ }
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_mode_show_1( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_mode_show_1( struct device *_dev,char *buf)
+ #endif
+ {
+ return mode_show_1(buf);
+ }
+
+ DEVICE_ATTR(mode_h_1, S_IRUGO|S_IWUSR, sysfs_mode_show_1, 0);
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_mode_show_2( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_mode_show_2( struct device *_dev,char *buf)
+ #endif
+ {
+ return mode_show_2(buf);
+ }
+ DEVICE_ATTR(mode_h_2, S_IRUGO|S_IWUSR, sysfs_mode_show_2, NULL);
+#else
+ static ssize_t mode_show(char *buf)
+ {
+ #ifdef __IS_HOST__
+ if((ifxusb_rreg(&ifxusb_hcd.core_if.core_global_regs->gintsts ) & 0x1) == 1)
+ return sprintf( buf, "HOST\n" );
+ else
+ return sprintf( buf, "DEVICE(INCORRECT!)\n" );
+ #else
+ if((ifxusb_rreg(&ifxusb_pcd.core_if.core_global_regs->gintsts ) & 0x1) != 1)
+ return sprintf( buf, "DEVICE\n" );
+ else
+ return sprintf( buf, "HOST(INCORRECT!)\n" );
+ #endif
+ }
+ static ssize_t procfs_mode_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return mode_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_mode_show( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_mode_show( struct device *_dev, char *buf)
+ #endif
+ {
+ return mode_show(buf);
+ }
+ #ifdef __IS_HOST__
+ DEVICE_ATTR(mode_h, S_IRUGO|S_IWUSR, sysfs_mode_show, NULL);
+ #else
+ DEVICE_ATTR(mode_d, S_IRUGO|S_IWUSR, sysfs_mode_show, NULL);
+ #endif
+#endif
+
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifdef __IS_HOST__
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+ #ifdef __IS_DUAL__
+ static ssize_t bandwidth_hs_show_1(char *buf)
+ {
+ return sprintf( buf, "%d\n",ifxusb_hcd_1.pkt_remaining_reload_hs );
+ }
+ static ssize_t bandwidth_fs_show_1(char *buf)
+ {
+ return sprintf( buf, "%d\n",ifxusb_hcd_1.pkt_remaining_reload_fs );
+ }
+ static ssize_t bandwidth_ls_show_1(char *buf)
+ {
+ return sprintf( buf, "%d\n",ifxusb_hcd_1.pkt_remaining_reload_ls );
+ }
+ static void bandwidth_hs_store_1(uint32_t value)
+ {
+ if(value>16 && value<120)
+ {
+ hprt0_data_t hprt0;
+ ifxusb_hcd_1.pkt_remaining_reload_hs = value;
+ hprt0.d32 = ifxusb_rreg(ifxusb_hcd_1.core_if.hprt0);
+ if(hprt0.b.prtspd == IFXUSB_HPRT0_PRTSPD_HIGH_SPEED)
+ ifxusb_hcd_1.pkt_remaining_reload=value;
+ }
+ }
+ static void bandwidth_fs_store_1(uint32_t value)
+ {
+ if (value>2 && value<30)
+ {
+ hprt0_data_t hprt0;
+ ifxusb_hcd_1.pkt_remaining_reload_fs = value;
+ hprt0.d32 = ifxusb_rreg(ifxusb_hcd_1.core_if.hprt0);
+ if(hprt0.b.prtspd != IFXUSB_HPRT0_PRTSPD_LOW_SPEED && hprt0.b.prtspd != IFXUSB_HPRT0_PRTSPD_HIGH_SPEED)
+ ifxusb_hcd_1.pkt_remaining_reload=value;
+ }
+ }
+ static void bandwidth_ls_store_1(uint32_t value)
+ {
+ if (value>2 && value<30)
+ {
+ hprt0_data_t hprt0;
+ ifxusb_hcd_1.pkt_remaining_reload_ls = value;
+ hprt0.d32 = ifxusb_rreg(ifxusb_hcd_1.core_if.hprt0);
+ if(hprt0.b.prtspd == IFXUSB_HPRT0_PRTSPD_LOW_SPEED)
+ ifxusb_hcd_1.pkt_remaining_reload=value;
+ }
+ }
+ static ssize_t bandwidth_hs_show_2(char *buf)
+ {
+ return sprintf( buf, "%d\n",ifxusb_hcd_2.pkt_remaining_reload_hs );
+ }
+ static ssize_t bandwidth_fs_show_2(char *buf)
+ {
+ return sprintf( buf, "%d\n",ifxusb_hcd_2.pkt_remaining_reload_fs );
+ }
+ static ssize_t bandwidth_ls_show_2(char *buf)
+ {
+ return sprintf( buf, "%d\n",ifxusb_hcd_2.pkt_remaining_reload_ls );
+ }
+ static void bandwidth_hs_store_2(uint32_t value)
+ {
+ if(value>16 && value<120)
+ {
+ hprt0_data_t hprt0;
+ ifxusb_hcd_2.pkt_remaining_reload_hs = value;
+ hprt0.d32 = ifxusb_rreg(ifxusb_hcd_2.core_if.hprt0);
+ if(hprt0.b.prtspd == IFXUSB_HPRT0_PRTSPD_HIGH_SPEED)
+ ifxusb_hcd_2.pkt_remaining_reload=value;
+ }
+ }
+ static void bandwidth_fs_store_2(uint32_t value)
+ {
+ if (value>2 && value<30)
+ {
+ hprt0_data_t hprt0;
+ ifxusb_hcd_2.pkt_remaining_reload_fs = value;
+ hprt0.d32 = ifxusb_rreg(ifxusb_hcd_2.core_if.hprt0);
+ if(hprt0.b.prtspd != IFXUSB_HPRT0_PRTSPD_LOW_SPEED && hprt0.b.prtspd != IFXUSB_HPRT0_PRTSPD_HIGH_SPEED)
+ ifxusb_hcd_2.pkt_remaining_reload=value;
+ }
+ }
+ static void bandwidth_ls_store_2(uint32_t value)
+ {
+ if (value>2 && value<30)
+ {
+ hprt0_data_t hprt0;
+ ifxusb_hcd_2.pkt_remaining_reload_ls = value;
+ hprt0.d32 = ifxusb_rreg(ifxusb_hcd_2.core_if.hprt0);
+ if(hprt0.b.prtspd == IFXUSB_HPRT0_PRTSPD_LOW_SPEED)
+ ifxusb_hcd_2.pkt_remaining_reload=value;
+ }
+ }
+ static ssize_t procfs_bandwidth_hs_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return bandwidth_hs_show_1(buf);
+ }
+ static ssize_t procfs_bandwidth_fs_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return bandwidth_fs_show_1(buf);
+ }
+ static ssize_t procfs_bandwidth_ls_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return bandwidth_ls_show_1(buf);
+ }
+ static ssize_t procfs_bandwidth_hs_store_1(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ bandwidth_hs_store_1(value);
+ return count;
+ }
+ static ssize_t procfs_bandwidth_fs_store_1(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ bandwidth_fs_store_1(value);
+ return count;
+ }
+ static ssize_t procfs_bandwidth_ls_store_1(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ bandwidth_ls_store_1(value);
+ return count;
+ }
+ static ssize_t procfs_bandwidth_hs_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return bandwidth_hs_show_2(buf);
+ }
+ static ssize_t procfs_bandwidth_fs_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return bandwidth_fs_show_2(buf);
+ }
+ static ssize_t procfs_bandwidth_ls_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return bandwidth_ls_show_2(buf);
+ }
+ static ssize_t procfs_bandwidth_hs_store_2(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ bandwidth_hs_store_2(value);
+ return count;
+ }
+ static ssize_t procfs_bandwidth_fs_store_2(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ bandwidth_fs_store_2(value);
+ return count;
+ }
+ static ssize_t procfs_bandwidth_ls_store_2(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ bandwidth_ls_store_2(value);
+ return count;
+ }
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_bandwidth_hs_show_1( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_bandwidth_hs_show_1( struct device *_dev,char *buf)
+ #endif
+ {
+ return bandwidth_hs_show_1(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_bandwidth_hs_store_1( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_bandwidth_hs_store_1( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ bandwidth_hs_store_1(value);
+ return count;
+ }
+ DEVICE_ATTR(bandwidth_hs_1, S_IRUGO|S_IWUSR, sysfs_bandwidth_hs_show_1, sysfs_bandwidth_hs_store_1);
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_bandwidth_fs_show_1( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_bandwidth_fs_show_1( struct device *_dev,char *buf)
+ #endif
+ {
+ return bandwidth_fs_show_1(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_bandwidth_fs_store_1( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_bandwidth_fs_store_1( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ bandwidth_fs_store_1(value);
+ return count;
+ }
+ DEVICE_ATTR(bandwidth_fs_1, S_IRUGO|S_IWUSR, sysfs_bandwidth_fs_show_1, sysfs_bandwidth_fs_store_1);
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_bandwidth_ls_show_1( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_bandwidth_ls_show_1( struct device *_dev,char *buf)
+ #endif
+ {
+ return bandwidth_ls_show_1(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_bandwidth_ls_store_1( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_bandwidth_ls_store_1( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ bandwidth_ls_store_1(value);
+ return count;
+ }
+ DEVICE_ATTR(bandwidth_ls_1, S_IRUGO|S_IWUSR, sysfs_bandwidth_ls_show_1, sysfs_bandwidth_ls_store_1);
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_bandwidth_hs_show_2( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_bandwidth_hs_show_2( struct device *_dev,char *buf)
+ #endif
+ {
+ return bandwidth_hs_show_2(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_bandwidth_hs_store_2( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_bandwidth_hs_store_2( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ bandwidth_hs_store_2(value);
+ return count;
+ }
+ DEVICE_ATTR(bandwidth_hs_2, S_IRUGO|S_IWUSR, sysfs_bandwidth_hs_show_2, sysfs_bandwidth_hs_store_2);
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_bandwidth_fs_show_2( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_bandwidth_fs_show_2( struct device *_dev,char *buf)
+ #endif
+ {
+ return bandwidth_fs_show_2(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_bandwidth_fs_store_2( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_bandwidth_fs_store_2( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ bandwidth_fs_store_2(value);
+ return count;
+ }
+ DEVICE_ATTR(bandwidth_fs_2, S_IRUGO|S_IWUSR, sysfs_bandwidth_fs_show_2, sysfs_bandwidth_fs_store_2);
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_bandwidth_ls_show_2( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_bandwidth_ls_show_2( struct device *_dev,char *buf)
+ #endif
+ {
+ return bandwidth_ls_show_2(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_bandwidth_ls_store_2( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_bandwidth_ls_store_2( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ bandwidth_ls_store_2(value);
+ return count;
+ }
+ DEVICE_ATTR(bandwidth_ls_2, S_IRUGO|S_IWUSR, sysfs_bandwidth_ls_show_2, sysfs_bandwidth_ls_store_2);
+ #else
+ static ssize_t bandwidth_hs_show(char *buf)
+ {
+ return sprintf( buf, "%d\n",ifxusb_hcd.pkt_remaining_reload_hs );
+ }
+ static ssize_t bandwidth_fs_show(char *buf)
+ {
+ return sprintf( buf, "%d\n",ifxusb_hcd.pkt_remaining_reload_fs );
+ }
+ static ssize_t bandwidth_ls_show(char *buf)
+ {
+ return sprintf( buf, "%d\n",ifxusb_hcd.pkt_remaining_reload_ls );
+ }
+ static void bandwidth_hs_store(uint32_t value)
+ {
+ if (value>16 && value<120)
+ {
+ hprt0_data_t hprt0;
+ ifxusb_hcd.pkt_remaining_reload_hs = value;
+ hprt0.d32 = ifxusb_rreg(ifxusb_hcd.core_if.hprt0);
+ if(hprt0.b.prtspd == IFXUSB_HPRT0_PRTSPD_HIGH_SPEED)
+ ifxusb_hcd.pkt_remaining_reload=value;
+ }
+ }
+ static void bandwidth_fs_store(uint32_t value)
+ {
+ if (value>2 && value<30)
+ {
+ hprt0_data_t hprt0;
+ ifxusb_hcd.pkt_remaining_reload_fs = value;
+ hprt0.d32 = ifxusb_rreg(ifxusb_hcd.core_if.hprt0);
+ if(hprt0.b.prtspd != IFXUSB_HPRT0_PRTSPD_LOW_SPEED && hprt0.b.prtspd != IFXUSB_HPRT0_PRTSPD_HIGH_SPEED)
+ ifxusb_hcd.pkt_remaining_reload=value;
+ }
+ }
+ static void bandwidth_ls_store(uint32_t value)
+ {
+ if (value>2 && value<30)
+ {
+ hprt0_data_t hprt0;
+ ifxusb_hcd.pkt_remaining_reload_hs = value;
+ hprt0.d32 = ifxusb_rreg(ifxusb_hcd.core_if.hprt0);
+ if(hprt0.b.prtspd == IFXUSB_HPRT0_PRTSPD_LOW_SPEED)
+ ifxusb_hcd.pkt_remaining_reload=value;
+ }
+ }
+ static ssize_t procfs_bandwidth_hs_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return bandwidth_hs_show(buf);
+ }
+ static ssize_t procfs_bandwidth_fs_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return bandwidth_fs_show(buf);
+ }
+ static ssize_t procfs_bandwidth_ls_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return bandwidth_ls_show(buf);
+ }
+ static ssize_t procfs_bandwidth_hs_store(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ bandwidth_hs_store(value);
+ return count;
+ }
+ static ssize_t procfs_bandwidth_fs_store(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ bandwidth_fs_store(value);
+ return count;
+ }
+ static ssize_t procfs_bandwidth_ls_store(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ bandwidth_ls_store(value);
+ return count;
+ }
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_bandwidth_hs_show( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_bandwidth_hs_show( struct device *_dev,char *buf)
+ #endif
+ {
+ return bandwidth_hs_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_bandwidth_hs_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_bandwidth_hs_store( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ bandwidth_hs_store(value);
+ return count;
+ }
+ DEVICE_ATTR(bandwidth_hs, S_IRUGO|S_IWUSR, sysfs_bandwidth_hs_show, sysfs_bandwidth_hs_store);
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_bandwidth_fs_show( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_bandwidth_fs_show( struct device *_dev,char *buf)
+ #endif
+ {
+ return bandwidth_fs_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_bandwidth_fs_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_bandwidth_fs_store( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ bandwidth_fs_store(value);
+ return count;
+ }
+ DEVICE_ATTR(bandwidth_fs, S_IRUGO|S_IWUSR, sysfs_bandwidth_fs_show, sysfs_bandwidth_fs_store);
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_bandwidth_ls_show( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_bandwidth_ls_show( struct device *_dev,char *buf)
+ #endif
+ {
+ return bandwidth_ls_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_bandwidth_ls_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_bandwidth_ls_store( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ bandwidth_ls_store(value);
+ return count;
+ }
+ DEVICE_ATTR(bandwidth_ls, S_IRUGO|S_IWUSR, sysfs_bandwidth_ls_show, sysfs_bandwidth_ls_store);
+ #endif
+
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+ #ifdef __IS_DUAL__
+ static ssize_t pkt_count_limit_bi_show_1(char *buf)
+ {
+ return sprintf( buf, "%d\n",ifxusb_hcd_1.pkt_count_limit_bi );
+ }
+ static ssize_t pkt_count_limit_bo_show_1(char *buf)
+ {
+ return sprintf( buf, "%d\n",ifxusb_hcd_1.pkt_count_limit_bo );
+ }
+ static void pkt_count_limit_bi_store_1(uint32_t value)
+ {
+ if(value<=13)
+ ifxusb_hcd_1.pkt_count_limit_bi = value;
+ }
+ static void pkt_count_limit_bo_store_1(uint32_t value)
+ {
+ if (value<=13)
+ ifxusb_hcd_1.pkt_count_limit_bo = value;
+ }
+ static ssize_t pkt_count_limit_bi_show_2(char *buf)
+ {
+ return sprintf( buf, "%d\n",ifxusb_hcd_2.pkt_count_limit_bi );
+ }
+ static ssize_t pkt_count_limit_bo_show_2(char *buf)
+ {
+ return sprintf( buf, "%d\n",ifxusb_hcd_2.pkt_count_limit_bo );
+ }
+ static void pkt_count_limit_bi_store_2(uint32_t value)
+ {
+ if(value<=13)
+ ifxusb_hcd_2.pkt_count_limit_bi = value;
+ }
+ static void pkt_count_limit_bo_store_2(uint32_t value)
+ {
+ if(value<=13)
+ ifxusb_hcd_2.pkt_count_limit_bo = value;
+ }
+ static ssize_t procfs_pkt_count_limit_bi_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return pkt_count_limit_bi_show_1(buf);
+ }
+ static ssize_t procfs_pkt_count_limit_bo_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return pkt_count_limit_bo_show_1(buf);
+ }
+ static ssize_t procfs_pkt_count_limit_bi_store_1(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ pkt_count_limit_bi_store_1(value);
+ return count;
+ }
+ static ssize_t procfs_pkt_count_limit_bo_store_1(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ pkt_count_limit_bo_store_1(value);
+ return count;
+ }
+ static ssize_t procfs_pkt_count_limit_bi_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return pkt_count_limit_bi_show_2(buf);
+ }
+ static ssize_t procfs_pkt_count_limit_bo_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return pkt_count_limit_bo_show_2(buf);
+ }
+ static ssize_t procfs_pkt_count_limit_bi_store_2(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ pkt_count_limit_bi_store_2(value);
+ return count;
+ }
+ static ssize_t procfs_pkt_count_limit_bo_store_2(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ pkt_count_limit_bo_store_2(value);
+ return count;
+ }
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_pkt_count_limit_bi_show_1( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_pkt_count_limit_bi_show_1( struct device *_dev,char *buf)
+ #endif
+ {
+ return pkt_count_limit_bi_show_1(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_pkt_count_limit_bi_store_1( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_pkt_count_limit_bi_store_1( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ pkt_count_limit_bi_store_1(value);
+ return count;
+ }
+ DEVICE_ATTR(pkt_count_limit_bi_1, S_IRUGO|S_IWUSR, sysfs_pkt_count_limit_bi_show_1, sysfs_pkt_count_limit_bi_store_1);
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_pkt_count_limit_bo_show_1( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_pkt_count_limit_bo_show_1( struct device *_dev,char *buf)
+ #endif
+ {
+ return pkt_count_limit_bo_show_1(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_pkt_count_limit_bo_store_1( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_pkt_count_limit_bo_store_1( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ pkt_count_limit_bo_store_1(value);
+ return count;
+ }
+ DEVICE_ATTR(pkt_count_limit_bo_1, S_IRUGO|S_IWUSR, sysfs_pkt_count_limit_bo_show_1, sysfs_pkt_count_limit_bo_store_1);
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_pkt_count_limit_bi_show_2( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_pkt_count_limit_bi_show_2( struct device *_dev,char *buf)
+ #endif
+ {
+ return pkt_count_limit_bi_show_2(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_pkt_count_limit_bi_store_2( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_pkt_count_limit_bi_2( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ pkt_count_limit_bi_store_2(value);
+ return count;
+ }
+ DEVICE_ATTR(pkt_count_limit_bi_2, S_IRUGO|S_IWUSR, sysfs_pkt_count_limit_bi_show_2, sysfs_pkt_count_limit_bi_store_2);
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_pkt_count_limit_bo_show_2( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_pkt_count_limit_bo_show_2( struct device *_dev,char *buf)
+ #endif
+ {
+ return pkt_count_limit_bo_show_2(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_pkt_count_limit_bo_store_2( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_pkt_count_limit_bo_store_2( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ pkt_count_limit_bo_store_2(value);
+ return count;
+ }
+ DEVICE_ATTR(pkt_count_limit_bo_2, S_IRUGO|S_IWUSR, sysfs_pkt_count_limit_bo_show_2, sysfs_pkt_count_limit_bo_store_2);
+ #else
+ static ssize_t pkt_count_limit_bi_show(char *buf)
+ {
+ return sprintf( buf, "%d\n",ifxusb_hcd.pkt_count_limit_bi );
+ }
+ static ssize_t pkt_count_limit_bo_show(char *buf)
+ {
+ return sprintf( buf, "%d\n",ifxusb_hcd.pkt_count_limit_bo );
+ }
+ static void pkt_count_limit_bi_store(uint32_t value)
+ {
+ if (value<=13)
+ ifxusb_hcd.pkt_count_limit_bi = value;
+ }
+ static void pkt_count_limit_bo_store(uint32_t value)
+ {
+ if (value<=13)
+ ifxusb_hcd.pkt_count_limit_bo = value;
+ }
+ static ssize_t procfs_pkt_count_limit_bi_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return pkt_count_limit_bi_show(buf);
+ }
+ static ssize_t procfs_pkt_count_limit_bo_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return pkt_count_limit_bo_show(buf);
+ }
+ static ssize_t procfs_pkt_count_limit_bi_store(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ pkt_count_limit_bi_store(value);
+ return count;
+ }
+ static ssize_t procfs_pkt_count_limit_bo_store(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ pkt_count_limit_bo_store(value);
+ return count;
+ }
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_pkt_count_limit_bi_show( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_pkt_count_limit_bi_show( struct device *_dev,char *buf)
+ #endif
+ {
+ return pkt_count_limit_bi_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_pkt_count_limit_bi_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_pkt_count_limit_bi_store( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ pkt_count_limit_bi_store(value);
+ return count;
+ }
+ DEVICE_ATTR(pkt_count_limit_bi, S_IRUGO|S_IWUSR, sysfs_pkt_count_limit_bi_show, sysfs_pkt_count_limit_bi_store);
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_pkt_count_limit_bo_show( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_pkt_count_limit_bo_show( struct device *_dev,char *buf)
+ #endif
+ {
+ return pkt_count_limit_bo_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_pkt_count_limit_bo_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_pkt_count_limit_bo_store( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ pkt_count_limit_bo_store(value);
+ return count;
+ }
+ DEVICE_ATTR(pkt_count_limit_bo, S_IRUGO|S_IWUSR, sysfs_pkt_count_limit_bo_show, sysfs_pkt_count_limit_bo_store);
+ #endif
+
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+
+ #ifdef __IS_DUAL__
+ static ssize_t buspower_show_1(char *buf)
+ {
+ if(ifxusb_vbus (&ifxusb_hcd_1.core_if)==1) return sprintf( buf, "1\n" );
+ if(ifxusb_vbus (&ifxusb_hcd_1.core_if)==0) return sprintf( buf, "0\n" );
+ return sprintf( buf, "UNKNOWN\n" );
+ }
+ static void buspower_store_1(uint32_t value)
+ {
+ if (value==1) ifxusb_vbus_on (&ifxusb_hcd_1.core_if);
+ else if(value==0) ifxusb_vbus_off(&ifxusb_hcd_1.core_if);
+ }
+ static ssize_t buspower_show_2(char *buf)
+ {
+ if(ifxusb_vbus (&ifxusb_hcd_2.core_if)==1) return sprintf( buf, "1\n" );
+ if(ifxusb_vbus (&ifxusb_hcd_2.core_if)==0) return sprintf( buf, "0\n" );
+ return sprintf( buf, "UNKNOWN\n" );
+ }
+ static void buspower_store_2(uint32_t value)
+ {
+ if (value==1) ifxusb_vbus_on (&ifxusb_hcd_2.core_if);
+ else if(value==0) ifxusb_vbus_off(&ifxusb_hcd_2.core_if);
+ }
+ static ssize_t procfs_buspower_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return buspower_show_1(buf);
+ }
+ static ssize_t procfs_buspower_store_1(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ buspower_store_1(value);
+ return count;
+ }
+ static ssize_t procfs_buspower_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return buspower_show_2(buf);
+ }
+ static ssize_t procfs_buspower_store_2(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ buspower_store_2(value);
+ return count;
+ }
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_buspower_show_1( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_buspower_show_1( struct device *_dev,char *buf)
+ #endif
+ {
+ return buspower_show_1(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_buspower_store_1( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_buspower_store_1( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ buspower_store_1(value);
+ return count;
+ }
+ DEVICE_ATTR(buspower_1, S_IRUGO|S_IWUSR, sysfs_buspower_show_1, sysfs_buspower_store_1);
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_buspower_show_2( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_buspower_show_2( struct device *_dev,char *buf)
+ #endif
+ {
+ return buspower_show_2(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_buspower_store_2( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_buspower_store_2( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ buspower_store_2(value);
+ return count;
+ }
+ DEVICE_ATTR(buspower_2, S_IRUGO|S_IWUSR, sysfs_buspower_show_2, sysfs_buspower_store_2);
+ #else
+ static ssize_t buspower_show(char *buf)
+ {
+ if(ifxusb_vbus (&ifxusb_hcd.core_if)==1) return sprintf( buf, "1\n" );
+ if(ifxusb_vbus (&ifxusb_hcd.core_if)==0) return sprintf( buf, "0\n" );
+ return sprintf( buf, "UNKNOWN\n" );
+ }
+ static void buspower_store(uint32_t value)
+ {
+ if (value==1) ifxusb_vbus_on (&ifxusb_hcd.core_if);
+ else if(value==0) ifxusb_vbus_off(&ifxusb_hcd.core_if);
+ }
+ static ssize_t procfs_buspower_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return buspower_show(buf);
+ }
+ static ssize_t procfs_buspower_store(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ buspower_store(value);
+ return count;
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_buspower_show( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_buspower_show( struct device *_dev, char *buf)
+ #endif
+ {
+ return buspower_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_buspower_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_buspower_store( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ buspower_store(value);
+ return count;
+ }
+ DEVICE_ATTR(buspower, S_IRUGO|S_IWUSR, sysfs_buspower_show, sysfs_buspower_store);
+ #endif
+
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+
+
+ #ifdef __IS_DUAL__
+ static ssize_t bussuspend_show_1(char *buf)
+ {
+ hprt0_data_t val;
+ val.d32 = ifxusb_rreg(ifxusb_hcd_1.core_if.hprt0);
+ return sprintf (buf, "Bus Suspend = 0x%x\n", val.b.prtsusp);
+ }
+ static ssize_t bussuspend_show_2(char *buf)
+ {
+ hprt0_data_t val;
+ val.d32 = ifxusb_rreg(ifxusb_hcd_2.core_if.hprt0);
+ return sprintf (buf, "Bus Suspend = 0x%x\n", val.b.prtsusp);
+ }
+
+ static ssize_t procfs_bussuspend_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return bussuspend_show_1(buf);
+ }
+ static ssize_t procfs_bussuspend_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return bussuspend_show_2(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_bussuspend_show_1( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_bussuspend_show_1( struct device *_dev,char *buf)
+ #endif
+ {
+ return bussuspend_show_1(buf);
+ }
+ DEVICE_ATTR(bussuspend_1, S_IRUGO|S_IWUSR, sysfs_bussuspend_show_1, 0);
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_bussuspend_show_2( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_bussuspend_show_2( struct device *_dev,char *buf)
+ #endif
+ {
+ return bussuspend_show_2(buf);
+ }
+ DEVICE_ATTR(bussuspend_2, S_IRUGO|S_IWUSR, sysfs_bussuspend_show_2, 0);
+ #else
+ static ssize_t bussuspend_show(char *buf)
+ {
+ hprt0_data_t val;
+ val.d32 = ifxusb_rreg(ifxusb_hcd.core_if.hprt0);
+ return sprintf (buf, "Bus Suspend = 0x%x\n", val.b.prtsusp);
+ }
+ static ssize_t procfs_bussuspend_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return bussuspend_show(buf);
+ }
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_bussuspend_show( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_bussuspend_show( struct device *_dev, char *buf)
+ #endif
+ {
+ return bussuspend_show(buf);
+ }
+ DEVICE_ATTR(bussuspend, S_IRUGO|S_IWUSR, sysfs_bussuspend_show, 0);
+ #endif
+
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+
+ #ifdef __IS_DUAL__
+ static ssize_t busconnected_show_1(char *buf)
+ {
+ hprt0_data_t val;
+ val.d32 = ifxusb_rreg(ifxusb_hcd_1.core_if.hprt0);
+ return sprintf (buf, "Bus Connected = 0x%x\n", val.b.prtconnsts);
+ }
+ static ssize_t busconnected_show_2(char *buf)
+ {
+ hprt0_data_t val;
+ val.d32 = ifxusb_rreg(ifxusb_hcd_2.core_if.hprt0);
+ return sprintf (buf, "Bus Connected = 0x%x\n", val.b.prtconnsts);
+ }
+
+ static ssize_t procfs_busconnected_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return busconnected_show_1(buf);
+ }
+ static ssize_t procfs_busconnected_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return busconnected_show_2(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_busconnected_show_1( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_busconnected_show_1( struct device *_dev,char *buf)
+ #endif
+ {
+ return busconnected_show_1(buf);
+ }
+ DEVICE_ATTR(busconnected_1, S_IRUGO|S_IWUSR, sysfs_busconnected_show_1, 0);
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_busconnected_show_2( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_busconnected_show_2( struct device *_dev,char *buf)
+ #endif
+ {
+ return busconnected_show_2(buf);
+ }
+ DEVICE_ATTR(busconnected_2, S_IRUGO|S_IWUSR, sysfs_busconnected_show_2, 0);
+ #else
+ static ssize_t busconnected_show(char *buf)
+ {
+ hprt0_data_t val;
+ val.d32 = ifxusb_rreg(ifxusb_hcd.core_if.hprt0);
+ return sprintf (buf, "Bus Connected = 0x%x\n", val.b.prtconnsts);
+ }
+ static ssize_t procfs_busconnected_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return busconnected_show(buf);
+ }
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_busconnected_show( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_busconnected_show( struct device *_dev, char *buf)
+ #endif
+ {
+ return busconnected_show(buf);
+ }
+ DEVICE_ATTR(busconnected, S_IRUGO|S_IWUSR, sysfs_busconnected_show, 0);
+ #endif
+
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+
+ #ifdef __IS_DUAL__
+ static ssize_t connectspeed_show_1(char *buf)
+ {
+ hprt0_data_t val;
+ val.d32 = ifxusb_rreg(ifxusb_hcd_1.core_if.hprt0);
+ if( val.b.prtspd ==0) return sprintf (buf, "Bus Speed = High (%d)\n", val.b.prtspd);
+ if( val.b.prtspd ==1) return sprintf (buf, "Bus Speed = Full (%d)\n", val.b.prtspd);
+ if( val.b.prtspd ==2) return sprintf (buf, "Bus Speed = Low (%d)\n", val.b.prtspd);
+ return sprintf (buf, "Bus Speed = Unknown (%d)\n", val.b.prtspd);
+ }
+ static ssize_t connectspeed_show_2(char *buf)
+ {
+ hprt0_data_t val;
+ val.d32 = ifxusb_rreg(ifxusb_hcd_2.core_if.hprt0);
+ if( val.b.prtspd ==0) return sprintf (buf, "Bus Speed = High (%d)\n", val.b.prtspd);
+ if( val.b.prtspd ==1) return sprintf (buf, "Bus Speed = Full (%d)\n", val.b.prtspd);
+ if( val.b.prtspd ==2) return sprintf (buf, "Bus Speed = Low (%d)\n", val.b.prtspd);
+ return sprintf (buf, "Bus Speed = Unknown (%d)\n", val.b.prtspd);
+ }
+
+ static ssize_t procfs_connectspeed_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return connectspeed_show_1(buf);
+ }
+ static ssize_t procfs_connectspeed_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return connectspeed_show_2(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_connectspeed_show_1( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_connectspeed_show_1( struct device *_dev,char *buf)
+ #endif
+ {
+ return connectspeed_show_1(buf);
+ }
+ DEVICE_ATTR(connectspeed_1, S_IRUGO|S_IWUSR, sysfs_connectspeed_show_1, 0);
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_connectspeed_show_2( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_connectspeed_show_2( struct device *_dev,char *buf)
+ #endif
+ {
+ return connectspeed_show_2(buf);
+ }
+ DEVICE_ATTR(connectspeed_2, S_IRUGO|S_IWUSR, sysfs_connectspeed_show_2, 0);
+ #else
+ static ssize_t connectspeed_show(char *buf)
+ {
+ hprt0_data_t val;
+ val.d32 = ifxusb_rreg(ifxusb_hcd.core_if.hprt0);
+ if( val.b.prtspd ==0) return sprintf (buf, "Bus Speed = High (%d)\n", val.b.prtspd);
+ if( val.b.prtspd ==1) return sprintf (buf, "Bus Speed = Full (%d)\n", val.b.prtspd);
+ if( val.b.prtspd ==2) return sprintf (buf, "Bus Speed = Low (%d)\n", val.b.prtspd);
+ return sprintf (buf, "Bus Speed = Unknown (%d)\n", val.b.prtspd);
+ }
+
+ static ssize_t procfs_connectspeed_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return connectspeed_show(buf);
+ }
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_connectspeed_show( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_connectspeed_show( struct device *_dev, char *buf)
+ #endif
+ {
+ return connectspeed_show(buf);
+ }
+ DEVICE_ATTR(connectspeed, S_IRUGO|S_IWUSR, sysfs_connectspeed_show, 0);
+ #endif
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+#endif
+
+
+#ifdef __IS_DEVICE__
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+ static ssize_t devspeed_show(char *buf)
+ {
+ dcfg_data_t val;
+ val.d32 = ifxusb_rreg(&ifxusb_pcd.core_if.dev_global_regs->dcfg);
+ if( val.b.devspd ==0) return sprintf (buf, "Dev Speed = High (%d)\n", val.b.devspd);
+ if( val.b.devspd ==1) return sprintf (buf, "Dev Speed = Full (%d)\n", val.b.devspd);
+ if( val.b.devspd ==3) return sprintf (buf, "Dev Speed = Full (%d)\n", val.b.devspd);
+ return sprintf (buf, "Dev Speed = Unknown (%d)\n", val.b.devspd);
+ }
+
+ static ssize_t procfs_devspeed_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return devspeed_show(buf);
+ }
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_devspeed_show( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_devspeed_show( struct device *_dev, char *buf)
+ #endif
+ {
+ return devspeed_show(buf);
+ }
+ DEVICE_ATTR(devspeed, S_IRUGO|S_IWUSR, sysfs_devspeed_show, 0);
+
+ static ssize_t enumspeed_show(char *buf)
+ {
+ dsts_data_t val;
+ val.d32 = ifxusb_rreg(&ifxusb_pcd.core_if.dev_global_regs->dsts);
+ if( val.b.enumspd ==0) return sprintf (buf, "Enum Speed = High (%d)\n", val.b.enumspd);
+ if( val.b.enumspd ==1) return sprintf (buf, "Enum Speed = Full (%d)\n", val.b.enumspd);
+ if( val.b.enumspd ==2) return sprintf (buf, "Enum Speed = Low (%d)\n", val.b.enumspd);
+ return sprintf (buf, "Enum Speed = invalid(%d)\n", val.b.enumspd);
+ }
+
+ static ssize_t procfs_enumspeed_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return enumspeed_show(buf);
+ }
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_enumspeed_show( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_enumspeed_show( struct device *_dev, char *buf)
+ #endif
+ {
+ return enumspeed_show(buf);
+ }
+ DEVICE_ATTR(enumspeed, S_IRUGO|S_IWUSR, sysfs_enumspeed_show, 0);
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+#endif
+
+
+//////////////////////////////////////////////////////////////////////////////////
+#ifdef __ENABLE_DUMP__
+
+ #ifdef __IS_DUAL__
+ static void dump_reg_1(void)
+ {
+ ifxusb_dump_registers_h(&ifxusb_hcd_1.core_if);
+ }
+ static void dump_reg_2(void)
+ {
+ ifxusb_dump_registers_h(&ifxusb_hcd_2.core_if);
+ }
+
+ static ssize_t procfs_dump_reg_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ dump_reg_1();
+ return 0;
+ }
+ static ssize_t procfs_dump_reg_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ dump_reg_2();
+ return 0;
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_dump_reg_show_1( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_dump_reg_show_1( struct device *_dev,char *buf)
+ #endif
+ {
+ dump_reg_1();
+ return 0;
+ }
+ DEVICE_ATTR(dump_reg_h_1, S_IRUGO|S_IWUSR, sysfs_dump_reg_show_1, 0);
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_dump_reg_show_2( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_dump_reg_show_2( struct device *_dev,char *buf)
+ #endif
+ {
+ dump_reg_2();
+ return 0;
+ }
+ DEVICE_ATTR(dump_reg_h_2, S_IRUGO|S_IWUSR, sysfs_dump_reg_show_2, 0);
+ #else
+ static void dump_reg(void)
+ {
+ #ifdef __IS_HOST__
+ ifxusb_dump_registers_h(&ifxusb_hcd.core_if);
+ #endif
+ #ifdef __IS_DEVICE__
+ ifxusb_dump_registers_d(&ifxusb_pcd.core_if);
+ #endif
+ }
+ static ssize_t procfs_dump_reg_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ dump_reg();
+ return 0;
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_dump_reg_show( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_dump_reg_show( struct device *_dev,char *buf)
+ #endif
+ {
+ dump_reg();
+ return 0;
+ }
+ #ifdef __IS_HOST__
+ DEVICE_ATTR(dump_reg_h, S_IRUGO|S_IWUSR, sysfs_dump_reg_show, 0);
+ #else
+ DEVICE_ATTR(dump_reg_d, S_IRUGO|S_IWUSR, sysfs_dump_reg_show, 0);
+ #endif
+ #endif
+
+
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+
+ #ifdef __IS_DUAL__
+ static void dump_spram_1(void)
+ {
+ ifxusb_dump_spram_h(&ifxusb_hcd_1.core_if);
+ }
+ static void dump_spram_2(void)
+ {
+ ifxusb_dump_spram_h(&ifxusb_hcd_2.core_if);
+ }
+
+ static ssize_t procfs_dump_spram_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ dump_spram_1();
+ return 0;
+ }
+ static ssize_t procfs_dump_spram_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ dump_spram_2();
+ return 0;
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_dump_spram_show_1( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_dump_spram_show_1( struct device *_dev,char *buf)
+ #endif
+ {
+ dump_spram_1();
+ return 0;
+ }
+ DEVICE_ATTR(dump_spram_h_1, S_IRUGO|S_IWUSR, sysfs_dump_spram_show_1, 0);
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_dump_spram_show_2( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_dump_spram_show_2( struct device *_dev,char *buf)
+ #endif
+ {
+ dump_spram_2();
+ return 0;
+ }
+ DEVICE_ATTR(dump_spram_h_2, S_IRUGO|S_IWUSR, sysfs_dump_spram_show_2, 0);
+ #else
+ static void dump_spram(void)
+ {
+ #ifdef __IS_HOST__
+ ifxusb_dump_spram_h(&ifxusb_hcd.core_if);
+ #endif
+ #ifdef __IS_DEVICE__
+ ifxusb_dump_spram_d(&ifxusb_pcd.core_if);
+ #endif
+ }
+ static ssize_t procfs_dump_spram_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ dump_spram();
+ return 0;
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_dump_spram_show( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_dump_spram_show( struct device *_dev,char *buf)
+ #endif
+ {
+ dump_spram();
+ return 0;
+ }
+ #ifdef __IS_HOST__
+ DEVICE_ATTR(dump_spram_h, S_IRUGO|S_IWUSR, sysfs_dump_spram_show, 0);
+ #else
+ DEVICE_ATTR(dump_spram_d, S_IRUGO|S_IWUSR, sysfs_dump_spram_show, 0);
+ #endif
+
+ #endif
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+
+ #ifdef __IS_HOST__
+ #ifdef __IS_DUAL__
+ static ssize_t procfs_dump_host_state_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ ifxhcd_dump_state(&ifxusb_hcd_1);
+ return 0;
+ }
+ static ssize_t procfs_dump_host_state_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ ifxhcd_dump_state(&ifxusb_hcd_2);
+ return 0;
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_dump_host_state_show_1( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_dump_host_state_show_1( struct device *_dev,char *buf)
+ #endif
+ {
+ ifxhcd_dump_state(&ifxusb_hcd_1);
+ return 0;
+ }
+ DEVICE_ATTR(dump_host_state_1, S_IRUGO|S_IWUSR, sysfs_dump_host_state_show_1, 0);
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_dump_host_state_show_2( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_dump_host_state_show_2( struct device *_dev,char *buf)
+ #endif
+ {
+ ifxhcd_dump_state(&ifxusb_hcd_2);
+ return 0;
+ }
+ DEVICE_ATTR(dump_host_state_2, S_IRUGO|S_IWUSR, sysfs_dump_host_state_show_2, 0);
+ #else
+ static ssize_t procfs_dump_host_state_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ ifxhcd_dump_state(&ifxusb_hcd);
+ return 0;
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_dump_host_state_show( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_dump_host_state_show( struct device *_dev,char *buf)
+ #endif
+ {
+ ifxhcd_dump_state(&ifxusb_hcd);
+ return 0;
+ }
+ DEVICE_ATTR(dump_host_state, S_IRUGO|S_IWUSR, sysfs_dump_host_state_show, 0);
+ #endif
+
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+
+ #endif //IS_HOST_
+
+#endif //__ENABLE_DUMP__
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+#ifdef __IS_HOST__
+ static void host_probe(unsigned long _ptr)
+ {
+ ifxhcd_hcd_t *ifxhcd = (ifxhcd_hcd_t *)_ptr;
+
+ if(ifxhcd->flags.b.port_connect_status)
+ {
+ del_timer(&ifxhcd->host_probe_timer);
+ del_timer(&ifxhcd->autoprobe_timer);
+ ifxhcd->power_status = 0;
+ }
+ else
+ {
+ del_timer(&ifxhcd->autoprobe_timer);
+ ifxhcd->autoprobe_timer.expires = jiffies + (HZ*ifxhcd->autoprobe_sec);
+ add_timer(&ifxhcd->autoprobe_timer);
+ ifxhcd->power_status = 2;
+ del_timer(&ifxhcd->host_probe_timer);
+ do_suspend_h(&ifxhcd->core_if);
+ }
+ }
+
+ static void host_autoprobe(unsigned long _ptr)
+ {
+ ifxhcd_hcd_t *ifxhcd = (ifxhcd_hcd_t *)_ptr;
+ del_timer(&ifxhcd->host_probe_timer);
+ ifxhcd->host_probe_timer.function = host_probe;
+ ifxhcd->host_probe_timer.expires = jiffies + (HZ*ifxhcd->probe_sec);
+ ifxhcd->host_probe_timer.data = (unsigned long)ifxhcd;
+ add_timer(&ifxhcd->host_probe_timer);
+ do_resume_h(&ifxhcd->core_if);
+ }
+
+ static void suspend_host_store(ifxhcd_hcd_t *ifxhcd , uint32_t value)
+ {
+ if(value==2)
+ {
+ del_timer(&ifxhcd->autoprobe_timer);
+ ifxhcd->autoprobe_timer.function = host_autoprobe;
+ ifxhcd->autoprobe_timer.expires = jiffies + (HZ*ifxhcd->autoprobe_sec);
+ ifxhcd->autoprobe_timer.data = (unsigned long)ifxhcd;
+ add_timer(&ifxhcd->autoprobe_timer);
+ ifxhcd->power_status = 2;
+ }
+ else if(value==1)
+ {
+ do_suspend_h(&ifxhcd->core_if);
+ ifxhcd->power_status = 1;
+ del_timer(&ifxhcd->host_probe_timer);
+ del_timer(&ifxhcd->autoprobe_timer);
+ }
+ else if(value==0)
+ {
+ do_resume_h(&ifxhcd->core_if);
+ ifxhcd->power_status = 0;
+ del_timer(&ifxhcd->host_probe_timer);
+ del_timer(&ifxhcd->autoprobe_timer);
+ }
+ }
+ #ifdef __IS_DUAL__
+ static ssize_t procfs_suspend_host_2_store(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ suspend_host_store(&ifxusb_hcd_2,value);
+ return count;
+ }
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_suspend_host_2_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_suspend_host_2_store( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ suspend_host_store(&ifxusb_hcd_2,value);
+ return count;
+ }
+
+ static ssize_t procfs_suspend_host_1_store(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ suspend_host_store(&ifxusb_hcd_1,value);
+ return count;
+ }
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_suspend_host_1_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_suspend_host_1_store( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ suspend_host_store(&ifxusb_hcd_1,value);
+ return count;
+ }
+ DEVICE_ATTR(suspend_host_2, S_IWUSR,NULL, sysfs_suspend_host_2_store);
+ DEVICE_ATTR(suspend_host_1, S_IWUSR,NULL, sysfs_suspend_host_1_store);
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+ #else
+ static ssize_t procfs_suspend_host_store(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ suspend_host_store(&ifxusb_hcd,value);
+ return count;
+ }
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_suspend_host_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_suspend_host_store( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ suspend_host_store(&ifxusb_hcd,value);
+ return count;
+ }
+ DEVICE_ATTR(suspend_host, S_IWUSR,NULL, sysfs_suspend_host_store);
+ #endif
+#endif
+
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+#ifdef __IS_HOST__
+ static void probe_host_store(ifxhcd_hcd_t *ifxhcd, uint32_t value)
+ {
+ if(ifxhcd->power_status == 1)
+ {
+ del_timer(&ifxhcd->host_probe_timer);
+ ifxhcd->host_probe_timer.function = host_probe;
+ ifxhcd->host_probe_timer.expires = jiffies + (HZ*ifxhcd->probe_sec);
+ ifxhcd->host_probe_timer.data = (unsigned long) ifxhcd;
+ add_timer(&ifxhcd->host_probe_timer);
+ do_resume_h(&ifxhcd->core_if);
+ }
+ }
+ #ifdef __IS_DUAL__
+ static ssize_t probe_host_2_show(char *buf)
+ {
+ if(ifxusb_hcd_2.power_status == 0)
+ return sprintf (buf,"Host 2 power status is ON\n");
+ else if(ifxusb_hcd_2.power_status == 1)
+ return sprintf (buf,"Host 2 power status is Suspend\n");
+ else
+ return sprintf (buf,"Host 2 power status is Auto-probing\n");
+ }
+ static ssize_t probe_host_1_show(char *buf)
+ {
+ if(ifxusb_hcd_1.power_status == 0)
+ return sprintf (buf,"Host 1 power status is ON\n");
+ else if(ifxusb_hcd_1.power_status == 1)
+ return sprintf (buf,"Host 1 power status is Suspend\n");
+ else
+ return sprintf (buf,"Host 1 power status is Auto-probing\n");
+ }
+ static ssize_t procfs_probe_host_2_store(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ probe_host_store(&ifxusb_hcd_2,value);
+ return count;
+ }
+ static ssize_t procfs_probe_host_2_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return probe_host_2_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_probe_host_2_show( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_probe_host_2_show( struct device *_dev, char *buf)
+ #endif
+ {
+ return probe_host_2_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_probe_host_2_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_probe_host_2_store( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ probe_host_store(&ifxusb_hcd_2,value);
+ return count;
+ }
+
+ static ssize_t procfs_probe_host_1_store(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ probe_host_store(&ifxusb_hcd_1,value);
+ return count;
+ }
+ static ssize_t procfs_probe_host_1_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return probe_host_1_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_probe_host_1_show( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_probe_host_1_show( struct device *_dev, char *buf)
+ #endif
+ {
+ return probe_host_1_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_probe_host_1_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_probe_host_1_store( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ probe_host_store(&ifxusb_hcd_1,value);
+ return count;
+ }
+ DEVICE_ATTR(probe_host_2, S_IRUGO|S_IWUSR, sysfs_probe_host_2_show, sysfs_probe_host_2_store);
+ DEVICE_ATTR(probe_host_1, S_IRUGO|S_IWUSR, sysfs_probe_host_1_show, sysfs_probe_host_1_store);
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+ #else
+ static ssize_t probe_host_show(char *buf)
+ {
+ if(ifxusb_hcd.power_status == 0)
+ return sprintf (buf,"Host power status is ON\n");
+ else if(ifxusb_hcd.power_status == 1)
+ return sprintf (buf,"Host power status is Suspend\n");
+ else
+ return sprintf (buf,"Host power status is Auto-probing\n");
+ }
+ static ssize_t procfs_probe_host_store(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ probe_host_store(&ifxusb_hcd,value);
+ return count;
+ }
+ static ssize_t procfs_probe_host_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return probe_host_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_probe_host_show( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_probe_host_show( struct device *_dev, char *buf)
+ #endif
+ {
+ return probe_host_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_probe_host_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_probe_host_store( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ probe_host_store(&ifxusb_hcd,value);
+ return count;
+ }
+ DEVICE_ATTR(probe_host, S_IRUGO|S_IWUSR, sysfs_probe_host_show, sysfs_probe_host_store);
+ #endif
+#endif
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+#ifdef __IS_DEVICE__
+ static void device_probe(unsigned long _ptr)
+ {
+ if(ifxusb_pcd.power_status == 2)
+ {
+ del_timer(&ifxusb_pcd.device_autoprobe_timer);
+ ifxusb_pcd.device_autoprobe_timer.expires = jiffies + (HZ*ifxusb_pcd.autoprobe_sec);
+ add_timer(&ifxusb_pcd.device_autoprobe_timer);
+ ifxusb_pcd.power_status = 2;
+ do_suspend_d(&ifxusb_pcd.core_if);
+ }
+ else if(ifxusb_pcd.power_status == 1)
+ {
+ do_suspend_d(&ifxusb_pcd.core_if);
+ ifxusb_pcd.power_status = 1;
+ }
+ }
+ static void device_autoprobe(unsigned long _ptr)
+ {
+ init_timer(&ifxusb_pcd.device_probe_timer);
+ ifxusb_pcd.device_probe_timer.function = device_probe;
+ ifxusb_pcd.device_probe_timer.expires = jiffies + (HZ*ifxusb_pcd.probe_sec);
+ add_timer(&ifxusb_pcd.device_probe_timer);
+ do_resume_d(&ifxusb_pcd.core_if);
+ }
+ static void suspend_device_store(uint32_t value)
+ {
+ if(value==2)
+ {
+ del_timer(&ifxusb_pcd.device_autoprobe_timer);
+ ifxusb_pcd.device_autoprobe_timer.function = device_autoprobe;
+ ifxusb_pcd.device_autoprobe_timer.expires = jiffies + (HZ*ifxusb_pcd.autoprobe_sec);
+ add_timer(&ifxusb_pcd.device_autoprobe_timer);
+ ifxusb_pcd.power_status = 2;
+ }
+ else if(value==1)
+ {
+ do_suspend_d(&ifxusb_pcd.core_if);
+ ifxusb_pcd.power_status = 1;
+ del_timer(&ifxusb_pcd.device_autoprobe_timer);
+ del_timer(&ifxusb_pcd.device_probe_timer);
+ }
+ else if(value==0)
+ {
+ do_resume_d(&ifxusb_pcd.core_if);
+ ifxusb_pcd.power_status = 0;
+ del_timer(&ifxusb_pcd.device_autoprobe_timer);
+ del_timer(&ifxusb_pcd.device_probe_timer);
+ }
+ }
+ static ssize_t procfs_suspend_device_store(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ suspend_device_store(value);
+ return count;
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_suspend_device_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_suspend_device_store( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ suspend_device_store(value);
+ return count;
+ }
+ DEVICE_ATTR(suspend_device, S_IWUSR,NULL,sysfs_suspend_device_store);
+#endif
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+#ifdef __IS_DEVICE__
+ static ssize_t probe_device_show(char *buf)
+ {
+ if(ifxusb_pcd.power_status == 0)
+ return sprintf (buf,"Device power status is ON\n");
+ else if(ifxusb_pcd.power_status == 1)
+ return sprintf (buf,"Device power status is Suspend\n");
+ else
+ return printk(buf,"Device power status is Auto-probing\n");
+ }
+ static void probe_device_store(uint32_t value)
+ {
+
+ if(ifxusb_pcd.power_status == 1)
+ {
+ del_timer(&ifxusb_pcd.device_probe_timer);
+ ifxusb_pcd.device_probe_timer.function = device_probe;
+ ifxusb_pcd.device_probe_timer.expires = jiffies + (HZ*ifxusb_pcd.probe_sec);
+ add_timer(&ifxusb_pcd.device_probe_timer);
+ do_resume_d(&ifxusb_pcd.core_if);
+ }
+ }
+ static ssize_t procfs_probe_device_store(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ probe_device_store(value);
+ return count;
+ }
+ static ssize_t procfs_probe_device_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return probe_device_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_probe_device_show( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_probe_device_show( struct device *_dev, char *buf)
+ #endif
+ {
+ return probe_device_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_probe_device_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_probe_device_store( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ probe_device_store(value);
+ return count;
+ }
+ DEVICE_ATTR(probe_device, S_IRUGO|S_IWUSR, sysfs_probe_device_show, sysfs_probe_device_store);
+#endif
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+#ifdef __IS_HOST__
+ #ifdef __IS_DUAL__
+ static ssize_t autoprobe_timer2_val_show(char *buf)
+ {
+ return sprintf (buf,"Host 2 auto-probe timer is %d second\n",ifxusb_hcd_2.autoprobe_sec);
+ }
+ static ssize_t procfs_autoprobe_timer2_val_store(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ if((value > 0)&&(value < 300))
+ ifxusb_hcd_2.autoprobe_sec = value;
+ return count;
+ }
+ static ssize_t procfs_autoprobe_timer2_val_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return autoprobe_timer2_val_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_autoprobe_timer2_val_show( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_autoprobe_timer2_val_show( struct device *_dev, char *buf)
+ #endif
+ {
+ return autoprobe_timer2_val_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_autoprobe_timer2_val_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_autoprobe_timer2_val_store( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ if((value > 0)&&(value < 300))
+ ifxusb_hcd_2.autoprobe_sec = value;
+ return count;
+ }
+
+ static ssize_t autoprobe_timer1_val_show(char *buf)
+ {
+ return sprintf (buf,"Host 1 auto-probe timer is %d second\n",ifxusb_hcd_1.autoprobe_sec);
+ }
+ static ssize_t procfs_autoprobe_timer1_val_store(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ if((value > 0)&&(value < 300))
+ ifxusb_hcd_1.autoprobe_sec = value;
+ return count;
+ }
+ static ssize_t procfs_autoprobe_timer1_val_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return autoprobe_timer1_val_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_autoprobe_timer1_val_show( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_autoprobe_timer1_val_show( struct device *_dev, char *buf)
+ #endif
+ {
+ return autoprobe_timer1_val_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_autoprobe_timer1_val_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_autoautoprobe_timer1_val_store( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ if((value > 0)&&(value < 300))
+ ifxusb_hcd_1.autoprobe_sec = value;
+ return count;
+ }
+
+ static ssize_t probe_timer2_val_show(char *buf)
+ {
+ return sprintf (buf,"Host 2 probe timer is %d second\n",ifxusb_hcd_2.probe_sec);
+ }
+ static ssize_t procfs_probe_timer2_val_store(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ if((value > 0)&&(value < 10))
+ ifxusb_hcd_2.probe_sec = value;
+ return count;
+ }
+ static ssize_t procfs_probe_timer2_val_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return probe_timer2_val_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_probe_timer2_val_show( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_probe_timer2_val_show( struct device *_dev, char *buf)
+ #endif
+ {
+ return probe_timer2_val_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_probe_timer2_val_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_probe_timer2_val_store( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ if((value > 0)&&(value < 10))
+ ifxusb_hcd_2.probe_sec = value;
+ return count;
+ }
+
+ static ssize_t probe_timer1_val_show(char *buf)
+ {
+ return sprintf (buf,"Host 1 probe timer is %d second\n",ifxusb_hcd_1.probe_sec);
+ }
+ static ssize_t procfs_probe_timer1_val_store(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ if((value > 0)&&(value < 10))
+ ifxusb_hcd_1.probe_sec = value;
+ return count;
+ }
+ static ssize_t procfs_probe_timer1_val_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return probe_timer1_val_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_probe_timer1_val_show( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_probe_timer1_val_show( struct device *_dev, char *buf)
+ #endif
+ {
+ return probe_timer1_val_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_probe_timer1_val_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_probe_timer1_val_store( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ if((value > 0)&&(value < 10))
+ ifxusb_hcd_1.probe_sec = value;
+ return count;
+ }
+ DEVICE_ATTR(probe_timer1_val_h, S_IRUGO|S_IWUSR, sysfs_probe_timer1_val_show, sysfs_probe_timer1_val_store);
+ DEVICE_ATTR(probe_timer2_val_h, S_IRUGO|S_IWUSR, sysfs_probe_timer2_val_show, sysfs_probe_timer2_val_store);
+ DEVICE_ATTR(autoprobe_timer1_val_h, S_IRUGO|S_IWUSR, sysfs_autoprobe_timer1_val_show, sysfs_autoprobe_timer1_val_store);
+ DEVICE_ATTR(autoprobe_timer2_val_h, S_IRUGO|S_IWUSR, sysfs_autoprobe_timer2_val_show, sysfs_autoprobe_timer2_val_store);
+ #else
+ static ssize_t autoprobe_timer_val_show(char *buf)
+ {
+ return sprintf (buf,"Host auto-probe timer is %d second\n",ifxusb_hcd.autoprobe_sec);
+ }
+ static ssize_t procfs_autoprobe_timer_val_store(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ if((value > 0)&&(value < 300))
+ ifxusb_hcd.autoprobe_sec = value;
+ return count;
+ }
+ static ssize_t procfs_autoprobe_timer_val_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return autoprobe_timer_val_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_autoprobe_timer_val_show( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_autoprobe_timer_val_show( struct device *_dev, char *buf)
+ #endif
+ {
+ return autoprobe_timer_val_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_autoprobe_timer_val_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_autoautoprobe_timer_val_store( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ if((value > 0)&&(value < 300))
+ ifxusb_hcd.autoprobe_sec = value;
+ return count;
+ }
+ static ssize_t probe_timer_val_show(char *buf)
+ {
+ return sprintf (buf,"Host probe timer is %d second\n",ifxusb_hcd.probe_sec);
+ }
+ static ssize_t procfs_probe_timer_val_store(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ if((value > 0)&&(value < 10))
+ ifxusb_hcd.probe_sec = value;
+ return count;
+ }
+ static ssize_t procfs_probe_timer_val_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return probe_timer_val_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_probe_timer_val_show( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_probe_timer_val_show( struct device *_dev, char *buf)
+ #endif
+ {
+ return probe_timer_val_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_probe_timer_val_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_probe_timer_val_store( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ if((value > 0)&&(value < 10))
+ ifxusb_hcd.probe_sec = value;
+ return count;
+ }
+ DEVICE_ATTR(probe_timer_val_h, S_IRUGO|S_IWUSR, sysfs_probe_timer_val_show, sysfs_probe_timer_val_store);
+ DEVICE_ATTR(autoprobe_timer_val_h, S_IRUGO|S_IWUSR, sysfs_autoprobe_timer_val_show, sysfs_autoprobe_timer_val_store);
+ #endif
+#endif
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+#ifdef __IS_DEVICE__
+ static ssize_t autoprobe_timer_val_show(char *buf)
+ {
+ return sprintf (buf,"Device auto-probe timer is %d second\n",ifxusb_pcd.autoprobe_sec);
+ }
+ static ssize_t procfs_autoprobe_timer_val_store(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ if((value > 0)&&(value < 300))
+ ifxusb_pcd.autoprobe_sec = value;
+ return count;
+ }
+ static ssize_t procfs_autoprobe_timer_val_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return autoprobe_timer_val_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_autoprobe_timer_val_show( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_autoprobe_timer_val_show( struct device *_dev, char *buf)
+ #endif
+ {
+ return autoprobe_timer_val_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_autoprobe_timer_val_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_autoautoprobe_timer_val_store( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ if((value > 0)&&(value < 300))
+ ifxusb_pcd.autoprobe_sec = value;
+ return count;
+ }
+ static ssize_t probe_timer_val_show(char *buf)
+ {
+ return sprintf (buf,"Device probe timer is %d second\n",ifxusb_pcd.probe_sec);
+ }
+ static ssize_t procfs_probe_timer_val_store(struct file *file, const char *buffer, unsigned long count, void *data)
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ if((value > 0)&&(value < 10))
+ ifxusb_pcd.probe_sec = value;
+ return count;
+ }
+ static ssize_t procfs_probe_timer_val_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+ {
+ return probe_timer_val_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_probe_timer_val_show( struct device *_dev, struct device_attribute *attr,char *buf)
+ #else
+ static ssize_t sysfs_probe_timer_val_show( struct device *_dev, char *buf)
+ #endif
+ {
+ return probe_timer_val_show(buf);
+ }
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ static ssize_t sysfs_probe_timer_val_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
+ #else
+ static ssize_t sysfs_probe_timer_val_store( struct device *_dev, const char *buffer, size_t count )
+ #endif
+ {
+ char buf[10];
+ int i = 0;
+ uint32_t value;
+ if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
+ return -EFAULT;
+ value = simple_strtoul(buf, NULL, 10);
+ if((value > 0)&&(value < 10))
+ ifxusb_pcd.probe_sec = value;
+ return count;
+ }
+ DEVICE_ATTR(probe_timer_val_d, S_IRUGO|S_IWUSR, sysfs_probe_timer_val_show, sysfs_probe_timer_val_store);
+ DEVICE_ATTR(autoprobe_timer_val_d, S_IRUGO|S_IWUSR, sysfs_autoprobe_timer_val_show, sysfs_autoprobe_timer_val_store);
+#endif
+//////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////
+
+static int ifx_proc_addproc(char *funcname, read_proc_t *hookfuncr, write_proc_t *hookfuncw);
+static void ifx_proc_delproc(char *funcname);
+
+//////////////////////////////////////////////////////////////////////////////////
+
+#if defined(__IS_HOST__) && defined(__HOST_COC__)
+ #ifdef __IS_DUAL__
+ static IFX_PMCU_MODULE_DEP_t depListUSBHost_1=
+ {
+ 1,
+ {
+ {IFX_PMCU_MODULE_CPU, IFX_PMCU_STATE_D0, IFX_PMCU_STATE_D0D3, IFX_PMCU_STATE_D0D3, IFX_PMCU_STATE_D0D3}
+ }
+ };
+ static IFX_PMCU_MODULE_DEP_t depListUSBHost_2=
+ {
+ 1,
+ {
+ {IFX_PMCU_MODULE_CPU, IFX_PMCU_STATE_D0, IFX_PMCU_STATE_D0D3, IFX_PMCU_STATE_D0D3, IFX_PMCU_STATE_D0D3}
+ }
+ };
+ // This functions returns the current power state of the module
+ static IFX_PMCU_RETURN_t
+ ifx_usbhost_stateGet_1(IFX_PMCU_STATE_t *pmcuModState) {
+ printk(KERN_DEBUG "ifx_usbhost_stateGet_1 is called\n");
+ if(ifxusb_hcd_1.power_status == 0){
+ printk(KERN_DEBUG "current power state of USB Host #1 is D0\n");
+ *pmcuModState = IFX_PMCU_STATE_D0; // set here the right value
+ }
+ else if(ifxusb_hcd_1.power_status == 1){
+ printk(KERN_DEBUG "current power state of USB Host #1 is D3 (Suspend)\n");
+ *pmcuModState = IFX_PMCU_STATE_D3; // set here the right value
+ }
+ else if(ifxusb_hcd_1.power_status == 2){
+ printk(KERN_DEBUG "current power state of USB Host #1 is D3 (Auto-Probing)\n");
+ *pmcuModState = IFX_PMCU_STATE_D3; // set here the right value
+ }
+ else{
+ printk(KERN_DEBUG "current power state of USB Host #1 is unknown (%d)\n",ifxusb_hcd_1.power_status);
+ *pmcuModState = IFX_PMCU_STATE_INVALID; // must be set to INVALID
+ }
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ static IFX_PMCU_RETURN_t
+ ifx_usbhost_stateGet_2(IFX_PMCU_STATE_t *pmcuModState) {
+ printk(KERN_DEBUG "ifx_usbhost_stateGet_2 is called\n");
+ if(ifxusb_hcd_2.power_status == 0){
+ printk(KERN_DEBUG "current power state of USB Host #2 is D0\n");
+ *pmcuModState = IFX_PMCU_STATE_D0; // set here the right value
+ }
+ else if(ifxusb_hcd_2.power_status == 1){
+ printk(KERN_DEBUG "current power state of USB Host #2 is D3 (Suspend)\n");
+ *pmcuModState = IFX_PMCU_STATE_D3; // set here the right value
+ }
+ else if(ifxusb_hcd_2.power_status == 2){
+ printk(KERN_DEBUG "current power state of USB Host #2 is D3 (Auto-Probing)\n");
+ *pmcuModState = IFX_PMCU_STATE_D3; // set here the right value
+ }
+ else{
+ printk(KERN_DEBUG "current power state of USB Host #2 is unknown (%d)\n",ifxusb_hcd_2.power_status);
+ *pmcuModState = IFX_PMCU_STATE_INVALID; // must be set to INVALID
+ }
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+
+
+ // The function should be used to enable/disable the module specific power saving methods
+ static IFX_PMCU_RETURN_t
+ ifx_usbhost_pwrFeatureSwitch_1(IFX_PMCU_PWR_STATE_ENA_t pmcuPwrStateEna)
+ {
+ if (pmcuPwrStateEna == IFX_PMCU_PWR_STATE_ON) {
+ suspend_host_store(&ifxusb_hcd_1, 0);
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ if (pmcuPwrStateEna == IFX_PMCU_PWR_STATE_OFF) {
+ suspend_host_store(&ifxusb_hcd_1, 1);
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ static IFX_PMCU_RETURN_t
+ ifx_usbhost_pwrFeatureSwitch_2(IFX_PMCU_PWR_STATE_ENA_t pmcuPwrStateEna)
+ {
+ if (pmcuPwrStateEna == IFX_PMCU_PWR_STATE_ON) {
+ suspend_host_store(&ifxusb_hcd_2, 0);
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ if (pmcuPwrStateEna == IFX_PMCU_PWR_STATE_OFF) {
+ suspend_host_store(&ifxusb_hcd_2, 1);
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+
+ // This function should be used to do all the necessary clean-up's before a the real
+ // power state change is initiated; e.g. flush all serial buffers inside the UART before
+ // the frequency will be changed.
+ static IFX_PMCU_RETURN_t
+ ifx_usbhost_preChange_1(IFX_PMCU_MODULE_t pmcuModule, IFX_PMCU_STATE_t newState, IFX_PMCU_STATE_t oldState)
+ {
+ printk(KERN_DEBUG "ifx_usbhost_preChange_1 is called\n");
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ static IFX_PMCU_RETURN_t
+ ifx_usbhost_preChange_2(IFX_PMCU_MODULE_t pmcuModule, IFX_PMCU_STATE_t newState, IFX_PMCU_STATE_t oldState)
+ {
+ printk(KERN_DEBUG "ifx_usbhost_preChange_2 is called\n");
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+
+
+ // This function initiate the real power state change. The module should do all the necessary
+ // adpations to the new state.
+ static IFX_PMCU_RETURN_t
+ ifx_usbhost_stateChange_1(IFX_PMCU_STATE_t newState)
+ {
+ printk(KERN_DEBUG "ifx_usbhost_stateChange_1 is called\n");
+ if (newState == IFX_PMCU_STATE_D0) {
+ suspend_host_store(&ifxusb_hcd_1, 0);
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ if (newState == IFX_PMCU_STATE_D1) {
+ suspend_host_store(&ifxusb_hcd_1, 1);
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ if (newState == IFX_PMCU_STATE_D2) {
+ suspend_host_store(&ifxusb_hcd_1, 1);
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ if (newState == IFX_PMCU_STATE_D3) {
+ suspend_host_store(&ifxusb_hcd_1, 1);
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ static IFX_PMCU_RETURN_t
+ ifx_usbhost_stateChange_2(IFX_PMCU_STATE_t newState)
+ {
+ printk(KERN_DEBUG "ifx_usbhost_stateChange_2 is called\n");
+ if (newState == IFX_PMCU_STATE_D0) {
+ suspend_host_store(&ifxusb_hcd_2, 0);
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ if (newState == IFX_PMCU_STATE_D1) {
+ suspend_host_store(&ifxusb_hcd_2, 1);
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ if (newState == IFX_PMCU_STATE_D2) {
+ suspend_host_store(&ifxusb_hcd_2, 1);
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ if (newState == IFX_PMCU_STATE_D3) {
+ suspend_host_store(&ifxusb_hcd_2, 1);
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+
+ // This function should be used to do all the necessary post processing after a the real
+ // power state change was initiated.
+ static IFX_PMCU_RETURN_t
+ ifx_usbhost_postChange_1(IFX_PMCU_MODULE_t pmcuModule, IFX_PMCU_STATE_t newState, IFX_PMCU_STATE_t oldState)
+ {
+ printk(KERN_DEBUG "ifx_usbhost_postChange_1 is called\n");
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ static IFX_PMCU_RETURN_t
+ ifx_usbhost_postChange_2(IFX_PMCU_MODULE_t pmcuModule, IFX_PMCU_STATE_t newState, IFX_PMCU_STATE_t oldState)
+ {
+ printk(KERN_DEBUG "ifx_usbhost_postChange_2 is called\n");
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ #else
+ static IFX_PMCU_MODULE_DEP_t depListUSBHost=
+ {
+ 1,
+ {
+ {IFX_PMCU_MODULE_CPU, IFX_PMCU_STATE_D0, IFX_PMCU_STATE_D0D3, IFX_PMCU_STATE_D0D3, IFX_PMCU_STATE_D0D3}
+ }
+ };
+ // This functions returns the current power state of the module
+ static IFX_PMCU_RETURN_t
+ ifx_usbhost_stateGet(IFX_PMCU_STATE_t *pmcuModState) {
+ printk(KERN_DEBUG "ifx_usbhost_stateGet is called\n");
+ if(ifxusb_hcd.power_status == 0){
+ printk(KERN_DEBUG "current power state of USB Host is D0\n");
+ *pmcuModState = IFX_PMCU_STATE_D0; // set here the right value
+ }
+ else if(ifxusb_hcd.power_status == 1){
+ printk(KERN_DEBUG "current power state of USB Host is D3 (Suspend)\n");
+ *pmcuModState = IFX_PMCU_STATE_D3; // set here the right value
+ }
+ else if(ifxusb_hcd.power_status == 2){
+ printk(KERN_DEBUG "current power state of USB Host is D3 (Auto-Probing)\n");
+ *pmcuModState = IFX_PMCU_STATE_D3; // set here the right value
+ }
+ else{
+ printk(KERN_DEBUG "current power state of USB Host is unknown (%d)\n",ifxusb_hcd.power_status);
+ *pmcuModState = IFX_PMCU_STATE_INVALID; // must be set to INVALID
+ }
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ // The function should be used to enable/disable the module specific power saving methods
+ static IFX_PMCU_RETURN_t
+ ifx_usbhost_pwrFeatureSwitch(IFX_PMCU_PWR_STATE_ENA_t pmcuPwrStateEna)
+ {
+ if (pmcuPwrStateEna == IFX_PMCU_PWR_STATE_ON) {
+ suspend_host_store(&ifxusb_hcd, 0);
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ if (pmcuPwrStateEna == IFX_PMCU_PWR_STATE_OFF) {
+ suspend_host_store(&ifxusb_hcd, 1);
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+
+ // This function should be used to do all the necessary clean-up's before a the real
+ // power state change is initiated; e.g. flush all serial buffers inside the UART before
+ // the frequency will be changed.
+ static IFX_PMCU_RETURN_t
+ ifx_usbhost_preChange(IFX_PMCU_MODULE_t pmcuModule, IFX_PMCU_STATE_t newState, IFX_PMCU_STATE_t oldState)
+ {
+ printk(KERN_DEBUG "ifx_usbhost_preChange is called\n");
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+
+
+ // This function initiate the real power state change. The module should do all the necessary
+ // adpations to the new state.
+ static IFX_PMCU_RETURN_t
+ ifx_usbhost_stateChange(IFX_PMCU_STATE_t newState)
+ {
+ printk(KERN_DEBUG "ifx_usbhost_stateChange is called\n");
+ if (newState == IFX_PMCU_STATE_D0) {
+ suspend_host_store(&ifxusb_hcd, 0);
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ if (newState == IFX_PMCU_STATE_D1) {
+ suspend_host_store(&ifxusb_hcd, 1);
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ if (newState == IFX_PMCU_STATE_D2) {
+ suspend_host_store(&ifxusb_hcd, 1);
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ if (newState == IFX_PMCU_STATE_D3) {
+ suspend_host_store(&ifxusb_hcd, 1);
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+
+ // This function should be used to do all the necessary post processing after a the real
+ // power state change was initiated.
+ static IFX_PMCU_RETURN_t
+ ifx_usbhost_postChange(IFX_PMCU_MODULE_t pmcuModule, IFX_PMCU_STATE_t newState, IFX_PMCU_STATE_t oldState)
+ {
+ printk(KERN_DEBUG "ifx_usbhost_postChange is called\n");
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ #endif
+#endif
+#if defined(__IS_DEVICE__) && defined(__GADGET_COC__)
+ static IFX_PMCU_MODULE_DEP_t depListUSBGadget=
+ {
+ 1,
+ {
+ {IFX_PMCU_MODULE_CPU, IFX_PMCU_STATE_D0, IFX_PMCU_STATE_D0D3, IFX_PMCU_STATE_D0D3, IFX_PMCU_STATE_D0D3}
+ }
+ };
+ // This functions returns the current power state of the module
+ static IFX_PMCU_RETURN_t
+ ifx_usbgadget_stateGet(IFX_PMCU_STATE_t *pmcuModState) {
+ printk(KERN_DEBUG "ifx_usbgadget_stateGet is called\n");
+ if(ifxusb_pcd.power_status == 0){
+ printk(KERN_DEBUG "current power state of USB Gadget is D0\n");
+ *pmcuModState = IFX_PMCU_STATE_D0; // set here the right value
+ }
+ else if(ifxusb_pcd.power_status == 1){
+ printk(KERN_DEBUG "current power state of USB Gadget is D3 (Suspend)\n");
+ *pmcuModState = IFX_PMCU_STATE_D3; // set here the right value
+ }
+ else if(ifxusb_pcd.power_status == 2){
+ printk(KERN_DEBUG "current power state of USB Gadget is D3 (Auto-Probing)\n");
+ *pmcuModState = IFX_PMCU_STATE_D3; // set here the right value
+ }
+ else{
+ printk(KERN_DEBUG "current power state of USB Gadget is unknown (%d)\n",ifxusb_pcd.power_status);
+ *pmcuModState = IFX_PMCU_STATE_INVALID; // must be set to INVALID
+ }
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ // The function should be used to enable/disable the module specific power saving methods
+ static IFX_PMCU_RETURN_t
+ ifx_usbgadget_pwrFeatureSwitch(IFX_PMCU_PWR_STATE_ENA_t pmcuPwrStateEna)
+ {
+ if (pmcuPwrStateEna == IFX_PMCU_PWR_STATE_ON) {
+ suspend_device_store(0);
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ if (pmcuPwrStateEna == IFX_PMCU_PWR_STATE_OFF) {
+ suspend_device_store(1);
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+
+ // This function should be used to do all the necessary clean-up's before a the real
+ // power state change is initiated; e.g. flush all serial buffers inside the UART before
+ // the frequency will be changed.
+ static IFX_PMCU_RETURN_t
+ ifx_usbgadget_preChange(IFX_PMCU_MODULE_t pmcuModule, IFX_PMCU_STATE_t newState, IFX_PMCU_STATE_t oldState)
+ {
+ printk(KERN_DEBUG "ifx_usbgadget_preChange is called\n");
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+
+
+ // This function initiate the real power state change. The module should do all the necessary
+ // adpations to the new state.
+ static IFX_PMCU_RETURN_t
+ ifx_usbgadget_stateChange(IFX_PMCU_STATE_t newState)
+ {
+ printk(KERN_DEBUG "ifx_usbgadget_stateChange is called\n");
+ if (newState == IFX_PMCU_STATE_D0) {
+ suspend_device_store(0);
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ if (newState == IFX_PMCU_STATE_D1) {
+ suspend_device_store(1);
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ if (newState == IFX_PMCU_STATE_D2) {
+ suspend_device_store(1);
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ if (newState == IFX_PMCU_STATE_D3) {
+ suspend_device_store(1);
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+
+ // This function should be used to do all the necessary post processing after a the real
+ // power state change was initiated.
+ static IFX_PMCU_RETURN_t
+ ifx_usbgadget_postChange(IFX_PMCU_MODULE_t pmcuModule, IFX_PMCU_STATE_t newState, IFX_PMCU_STATE_t oldState)
+ {
+ printk(KERN_DEBUG "ifx_usbgadget_postChange is called\n");
+ return IFX_PMCU_RETURN_SUCCESS;
+ }
+#endif
+
+
+/*!
+ \brief This function create the sysfs and procfs entries
+ \param[in] _dev Pointer of device structure, if applied
+ */
+#ifdef __IS_HOST__
+void ifxusb_attr_create_h (void *_dev)
+#else
+void ifxusb_attr_create_d (void *_dev)
+#endif
+{
+ int error;
+
+ struct device *dev = (struct device *) _dev;
+
+ IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
+
+ error = ifx_proc_addproc("dbglevel", procfs_dbglevel_show, procfs_dbglevel_store);
+ #ifdef __IS_HOST__
+ error = device_create_file(dev, &dev_attr_dbglevel_h);
+ #else
+ error = device_create_file(dev, &dev_attr_dbglevel_d);
+ #endif
+
+ #ifdef __IS_HOST__
+ #ifdef __IS_DUAL__
+ error = ifx_proc_addproc("dump_params_1", procfs_dump_params_show_1, NULL);
+ error = ifx_proc_addproc("dump_params_2", procfs_dump_params_show_2, NULL);
+ error = device_create_file(dev, &dev_attr_dump_params_h_1);
+ error = device_create_file(dev, &dev_attr_dump_params_h_2);
+
+ error = ifx_proc_addproc("mode_1", procfs_mode_show_1, NULL);
+ error = ifx_proc_addproc("mode_2", procfs_mode_show_2, NULL);
+ error = device_create_file(dev, &dev_attr_mode_h_1);
+ error = device_create_file(dev, &dev_attr_mode_h_2);
+ #else
+ error = ifx_proc_addproc("dump_params", procfs_dump_params_show, NULL);
+ error = device_create_file(dev, &dev_attr_dump_params_h);
+ error = ifx_proc_addproc("mode", procfs_mode_show, NULL);
+ error = device_create_file(dev, &dev_attr_mode_h);
+ #endif
+ #else
+ error = ifx_proc_addproc("dump_params", procfs_dump_params_show, NULL);
+ error = device_create_file(dev, &dev_attr_dump_params_d);
+
+ error = ifx_proc_addproc("mode", procfs_mode_show, NULL);
+ error = device_create_file(dev, &dev_attr_mode_d);
+ #endif
+
+ #ifdef __IS_HOST__
+ error = ifx_proc_addproc("version", procfs_version_show, NULL);
+ error = device_create_file(dev, &dev_attr_version_h);
+ #else
+ error = ifx_proc_addproc("version", procfs_version_show, NULL);
+ error = device_create_file(dev, &dev_attr_version_d);
+ #endif
+
+
+ #ifdef __IS_HOST__
+ #ifdef __IS_DUAL__
+ error = ifx_proc_addproc("pkt_count_limit_bi_1", procfs_pkt_count_limit_bi_show_1, procfs_pkt_count_limit_bi_store_1);
+ error = ifx_proc_addproc("pkt_count_limit_bo_1", procfs_pkt_count_limit_bo_show_1, procfs_pkt_count_limit_bo_store_1);
+ error = ifx_proc_addproc("pkt_count_limit_bi_2", procfs_pkt_count_limit_bi_show_2, procfs_pkt_count_limit_bi_store_2);
+ error = ifx_proc_addproc("pkt_count_limit_bo_2", procfs_pkt_count_limit_bo_show_2, procfs_pkt_count_limit_bo_store_2);
+ error = ifx_proc_addproc("bandwidth_hs_1", procfs_bandwidth_hs_show_1, procfs_bandwidth_hs_store_1);
+ error = ifx_proc_addproc("bandwidth_fs_1", procfs_bandwidth_fs_show_1, procfs_bandwidth_fs_store_1);
+ error = ifx_proc_addproc("bandwidth_ls_1", procfs_bandwidth_ls_show_1, procfs_bandwidth_ls_store_1);
+ error = ifx_proc_addproc("bandwidth_hs_2", procfs_bandwidth_hs_show_2, procfs_bandwidth_hs_store_2);
+ error = ifx_proc_addproc("bandwidth_fs_2", procfs_bandwidth_fs_show_2, procfs_bandwidth_fs_store_2);
+ error = ifx_proc_addproc("bandwidth_ls_2", procfs_bandwidth_ls_show_2, procfs_bandwidth_ls_store_2);
+ error = device_create_file(dev, &dev_attr_pkt_count_limit_bi_1);
+ error = device_create_file(dev, &dev_attr_pkt_count_limit_bo_1);
+ error = device_create_file(dev, &dev_attr_pkt_count_limit_bi_2);
+ error = device_create_file(dev, &dev_attr_pkt_count_limit_bo_2);
+ error = device_create_file(dev, &dev_attr_bandwidth_hs_1);
+ error = device_create_file(dev, &dev_attr_bandwidth_fs_1);
+ error = device_create_file(dev, &dev_attr_bandwidth_ls_1);
+ error = device_create_file(dev, &dev_attr_bandwidth_hs_2);
+ error = device_create_file(dev, &dev_attr_bandwidth_fs_2);
+ error = device_create_file(dev, &dev_attr_bandwidth_ls_2);
+ #else
+ error = ifx_proc_addproc("pkt_count_limit_bi", procfs_pkt_count_limit_bi_show, procfs_pkt_count_limit_bi_store);
+ error = ifx_proc_addproc("pkt_count_limit_bo", procfs_pkt_count_limit_bo_show, procfs_pkt_count_limit_bo_store);
+ error = ifx_proc_addproc("bandwidth_hs", procfs_bandwidth_hs_show, procfs_bandwidth_hs_store);
+ error = ifx_proc_addproc("bandwidth_fs", procfs_bandwidth_fs_show, procfs_bandwidth_fs_store);
+ error = ifx_proc_addproc("bandwidth_ls", procfs_bandwidth_ls_show, procfs_bandwidth_ls_store);
+ error = device_create_file(dev, &dev_attr_pkt_count_limit_bi);
+ error = device_create_file(dev, &dev_attr_pkt_count_limit_bo);
+ error = device_create_file(dev, &dev_attr_bandwidth_hs);
+ error = device_create_file(dev, &dev_attr_bandwidth_fs);
+ error = device_create_file(dev, &dev_attr_bandwidth_ls);
+ #endif
+
+ #ifdef __IS_DUAL__
+ error = ifx_proc_addproc("buspower_1", procfs_buspower_show_1, procfs_buspower_store_1);
+ error = ifx_proc_addproc("buspower_2", procfs_buspower_show_2, procfs_buspower_store_2);
+ error = device_create_file(dev, &dev_attr_buspower_1);
+ error = device_create_file(dev, &dev_attr_buspower_2);
+ #else
+ error = ifx_proc_addproc("buspower", procfs_buspower_show, procfs_buspower_store);
+ error = device_create_file(dev, &dev_attr_buspower);
+ #endif
+
+ #ifdef __IS_DUAL__
+ error = ifx_proc_addproc("bussuspend_1", procfs_bussuspend_show_1, NULL);
+ error = ifx_proc_addproc("bussuspend_2", procfs_bussuspend_show_2, NULL);
+ error = device_create_file(dev, &dev_attr_bussuspend_1);
+ error = device_create_file(dev, &dev_attr_bussuspend_2);
+ #else
+ error = ifx_proc_addproc("bussuspend", procfs_bussuspend_show, NULL);
+ error = device_create_file(dev, &dev_attr_bussuspend);
+ #endif
+
+ #ifdef __IS_DUAL__
+ error = ifx_proc_addproc("busconnected_1", procfs_busconnected_show_1, NULL);
+ error = ifx_proc_addproc("busconnected_2", procfs_busconnected_show_2, NULL);
+ error = device_create_file(dev, &dev_attr_busconnected_1);
+ error = device_create_file(dev, &dev_attr_busconnected_2);
+ #else
+ error = ifx_proc_addproc("busconnected", procfs_busconnected_show, NULL);
+ error = device_create_file(dev, &dev_attr_busconnected);
+ #endif
+
+ #ifdef __IS_DUAL__
+ error = ifx_proc_addproc("connectspeed_1", procfs_connectspeed_show_1, NULL);
+ error = ifx_proc_addproc("connectspeed_2", procfs_connectspeed_show_2, NULL);
+ error = device_create_file(dev, &dev_attr_connectspeed_1);
+ error = device_create_file(dev, &dev_attr_connectspeed_2);
+ #else
+ error = ifx_proc_addproc("connectspeed", procfs_connectspeed_show, NULL);
+ error = device_create_file(dev, &dev_attr_connectspeed);
+ #endif
+ #endif
+
+ #ifdef __IS_DEVICE__
+ error = ifx_proc_addproc("devspeed", procfs_devspeed_show, NULL);
+ error = device_create_file(dev, &dev_attr_devspeed);
+ error = ifx_proc_addproc("enumspeed", procfs_enumspeed_show, NULL);
+ error = device_create_file(dev, &dev_attr_enumspeed);
+ #endif
+
+ //////////////////////////////////////////////////////
+ #ifdef __ENABLE_DUMP__
+
+ #ifdef __IS_HOST__
+ #ifdef __IS_DUAL__
+ error = ifx_proc_addproc("dump_reg_1", procfs_dump_reg_show_1, NULL);
+ error = ifx_proc_addproc("dump_reg_2", procfs_dump_reg_show_2, NULL);
+ error = device_create_file(dev, &dev_attr_dump_reg_h_1);
+ error = device_create_file(dev, &dev_attr_dump_reg_h_2);
+ #else
+ error = ifx_proc_addproc("dump_reg", procfs_dump_reg_show, NULL);
+ error = device_create_file(dev, &dev_attr_dump_reg_h);
+ #endif
+
+ #ifdef __IS_DUAL__
+ error = ifx_proc_addproc("dump_spram_1", procfs_dump_spram_show_1, NULL);
+ error = ifx_proc_addproc("dump_spram_2", procfs_dump_spram_show_2, NULL);
+ error = device_create_file(dev, &dev_attr_dump_spram_h_1);
+ error = device_create_file(dev, &dev_attr_dump_spram_h_2);
+ #else
+ error = ifx_proc_addproc("dump_spram", procfs_dump_spram_show, NULL);
+ error = device_create_file(dev, &dev_attr_dump_spram_h);
+ #endif
+
+ #ifdef __IS_DUAL__
+ error = ifx_proc_addproc("dump_host_state_1", procfs_dump_host_state_show_1, NULL);
+ error = ifx_proc_addproc("dump_host_state_2", procfs_dump_host_state_show_2, NULL);
+ error = device_create_file(dev, &dev_attr_dump_host_state_1);
+ error = device_create_file(dev, &dev_attr_dump_host_state_2);
+ #else
+ error = ifx_proc_addproc("dump_host_state", procfs_dump_host_state_show, NULL);
+ error = device_create_file(dev, &dev_attr_dump_host_state);
+ #endif
+ #else
+ error = ifx_proc_addproc("dump_reg", procfs_dump_reg_show, NULL);
+ error = device_create_file(dev, &dev_attr_dump_reg_d);
+ error = ifx_proc_addproc("dump_spram", procfs_dump_spram_show, NULL);
+ error = device_create_file(dev, &dev_attr_dump_spram_d);
+ #endif
+ #endif //__ENABLE_DUMP__
+ //////////////////////////////////////////////////////
+#ifdef __IS_HOST__
+ #ifdef __IS_DUAL__
+ error = ifx_proc_addproc("suspend_host_1",NULL, procfs_suspend_host_1_store);
+ error = device_create_file(dev, &dev_attr_suspend_host_1);
+
+ error = ifx_proc_addproc("probe_host_1", procfs_probe_host_1_show, procfs_probe_host_1_store);
+ error = device_create_file(dev, &dev_attr_probe_host_1);
+
+ error = ifx_proc_addproc("suspend_host_2",NULL, procfs_suspend_host_2_store);
+ error = device_create_file(dev, &dev_attr_suspend_host_2);
+
+ error = ifx_proc_addproc("probe_host_2", procfs_probe_host_2_show, procfs_probe_host_2_store);
+ error = device_create_file(dev, &dev_attr_probe_host_2);
+
+ error = ifx_proc_addproc("probe_timer1", procfs_probe_timer1_val_show, procfs_probe_timer1_val_store);
+ error = device_create_file(dev, &dev_attr_probe_timer1_val_h);
+
+ error = ifx_proc_addproc("probe_timer2", procfs_probe_timer2_val_show, procfs_probe_timer2_val_store);
+ error = device_create_file(dev, &dev_attr_probe_timer2_val_h);
+
+ error = ifx_proc_addproc("autoprobe_timer1", procfs_autoprobe_timer1_val_show, procfs_autoprobe_timer1_val_store);
+ error = device_create_file(dev, &dev_attr_autoprobe_timer1_val_h);
+
+ error = ifx_proc_addproc("autoprobe_timer2", procfs_autoprobe_timer2_val_show, procfs_autoprobe_timer2_val_store);
+ error = device_create_file(dev, &dev_attr_autoprobe_timer2_val_h);
+ #else
+ error = ifx_proc_addproc("suspend_host",NULL, procfs_suspend_host_store);
+ error = device_create_file(dev, &dev_attr_suspend_host);
+
+ error = ifx_proc_addproc("probe_host", procfs_probe_host_show, procfs_probe_host_store);
+ error = device_create_file(dev, &dev_attr_probe_host);
+
+ error = ifx_proc_addproc("probe_timer", procfs_probe_timer_val_show, procfs_probe_timer_val_store);
+ error = device_create_file(dev, &dev_attr_probe_timer_val_h);
+
+ error = ifx_proc_addproc("autoprobe_timer", procfs_autoprobe_timer_val_show, procfs_autoprobe_timer_val_store);
+ error = device_create_file(dev, &dev_attr_autoprobe_timer_val_h);
+ #endif
+#endif
+
+#ifdef __IS_DEVICE__
+ error = ifx_proc_addproc("suspend_device",NULL, procfs_suspend_device_store);
+ error = device_create_file(dev, &dev_attr_suspend_device);
+
+ error = ifx_proc_addproc("probe_device", procfs_probe_device_show, procfs_probe_device_store);
+ error = device_create_file(dev, &dev_attr_probe_device);
+
+ error = ifx_proc_addproc("probe_timer", procfs_probe_timer_val_show, procfs_probe_timer_val_store);
+ error = device_create_file(dev, &dev_attr_probe_timer_val_d);
+
+ error = ifx_proc_addproc("autoprobe_timer", procfs_autoprobe_timer_val_show, procfs_autoprobe_timer_val_store);
+ error = device_create_file(dev, &dev_attr_autoprobe_timer_val_d);
+#endif
+#if defined(__IS_HOST__) && defined(__HOST_COC__)
+ #ifdef __IS_DUAL__
+ memset (&pmcuRegisterUSBHost_1, 0, sizeof(pmcuRegisterUSBHost_1));
+ memset (&pmcuRegisterUSBHost_2, 0, sizeof(pmcuRegisterUSBHost_2));
+ pmcuRegisterUSBHost_1.pmcuModule=
+ pmcuRegisterUSBHost_2.pmcuModule=IFX_PMCU_MODULE_USB;
+ pmcuRegisterUSBHost_1.pmcuModuleNr=1;
+ pmcuRegisterUSBHost_2.pmcuModuleNr=2;
+ pmcuRegisterUSBHost_1.pmcuModuleDep = &depListUSBHost_1;
+ pmcuRegisterUSBHost_2.pmcuModuleDep = &depListUSBHost_2;
+ pmcuRegisterUSBHost_1.pre = ifx_usbhost_preChange_1;
+ pmcuRegisterUSBHost_2.pre = ifx_usbhost_preChange_2;
+ pmcuRegisterUSBHost_1.post = ifx_usbhost_postChange_1;
+ pmcuRegisterUSBHost_2.post = ifx_usbhost_postChange_2;
+ pmcuRegisterUSBHost_1.ifx_pmcu_state_change = ifx_usbhost_stateChange_1;
+ pmcuRegisterUSBHost_2.ifx_pmcu_state_change = ifx_usbhost_stateChange_2;
+ pmcuRegisterUSBHost_1.ifx_pmcu_state_get = ifx_usbhost_stateGet_1;
+ pmcuRegisterUSBHost_2.ifx_pmcu_state_get = ifx_usbhost_stateGet_2;
+ pmcuRegisterUSBHost_1.ifx_pmcu_pwr_feature_switch = ifx_usbhost_pwrFeatureSwitch_1;
+ pmcuRegisterUSBHost_2.ifx_pmcu_pwr_feature_switch = ifx_usbhost_pwrFeatureSwitch_2;
+ ifx_pmcu_register ( &pmcuRegisterUSBHost_1 );
+ ifx_pmcu_register ( &pmcuRegisterUSBHost_2 );
+ #else
+ memset (&pmcuRegisterUSBHost, 0, sizeof(pmcuRegisterUSBHost));
+ pmcuRegisterUSBHost.pmcuModule=IFX_PMCU_MODULE_USB;
+ pmcuRegisterUSBHost.pmcuModuleNr=1;
+ pmcuRegisterUSBHost.pmcuModuleDep = &depListUSBHost;
+ pmcuRegisterUSBHost.pre = ifx_usbhost_preChange;
+ pmcuRegisterUSBHost.post = ifx_usbhost_postChange;
+ pmcuRegisterUSBHost.ifx_pmcu_state_change = ifx_usbhost_stateChange;
+ pmcuRegisterUSBHost.ifx_pmcu_state_get = ifx_usbhost_stateGet;
+ pmcuRegisterUSBHost.ifx_pmcu_pwr_feature_switch = ifx_usbhost_pwrFeatureSwitch;
+ ifx_pmcu_register ( &pmcuRegisterUSBHost );
+ #endif
+#endif
+#if defined(__IS_DEVICE__) && defined(__GADGET_COC__)
+ memset (&pmcuRegisterUSBGadget, 0, sizeof(pmcuRegisterUSBGadget));
+ pmcuRegisterUSBGadget.pmcuModule=IFX_PMCU_MODULE_USB;
+ pmcuRegisterUSBGadget.pmcuModuleNr=0;
+ pmcuRegisterUSBGadget.pmcuModuleDep = &depListUSBGadget;
+ pmcuRegisterUSBGadget.pre = ifx_usbgadget_preChange;
+ pmcuRegisterUSBGadget.post = ifx_usbgadget_postChange;
+ pmcuRegisterUSBGadget.ifx_pmcu_state_change = ifx_usbgadget_stateChange;
+ pmcuRegisterUSBGadget.ifx_pmcu_state_get = ifx_usbgadget_stateGet;
+ pmcuRegisterUSBGadget.ifx_pmcu_pwr_feature_switch = ifx_usbgadget_pwrFeatureSwitch;
+ ifx_pmcu_register ( &pmcuRegisterUSBGadget );
+#endif
+}
+
+
+/*!
+ \brief This function remove the sysfs and procfs entries
+ \param[in] _dev Pointer of device structure, if applied
+ */
+#ifdef __IS_HOST__
+void ifxusb_attr_remove_h (void *_dev)
+#else
+void ifxusb_attr_remove_d (void *_dev)
+#endif
+{
+ struct device *dev = (struct device *) _dev;
+
+ IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
+ ifx_proc_delproc("dbglevel");
+ #ifdef __IS_HOST__
+ device_remove_file(dev, &dev_attr_dbglevel_h);
+ #else
+ device_remove_file(dev, &dev_attr_dbglevel_d);
+ #endif
+
+ #ifdef __IS_HOST__
+ #ifdef __IS_DUAL__
+ ifx_proc_delproc("dump_params_1");
+ ifx_proc_delproc("dump_params_2");
+ device_remove_file(dev, &dev_attr_dump_params_h_1);
+ device_remove_file(dev, &dev_attr_dump_params_h_2);
+ #else
+ ifx_proc_delproc("dump_params");
+ device_remove_file(dev, &dev_attr_dump_params_h);
+ #endif
+
+ #ifdef __IS_DUAL__
+ ifx_proc_delproc("mode_1");
+ ifx_proc_delproc("mode_2");
+ device_remove_file(dev, &dev_attr_mode_h_1);
+ device_remove_file(dev, &dev_attr_mode_h_2);
+ #else
+ ifx_proc_delproc("mode");
+ device_remove_file(dev, &dev_attr_mode_h);
+ #endif
+ #else
+ ifx_proc_delproc("dump_params");
+ device_remove_file(dev, &dev_attr_dump_params_d);
+ ifx_proc_delproc("mode");
+ device_remove_file(dev, &dev_attr_mode_d);
+ #endif
+
+ #ifdef __IS_HOST__
+ ifx_proc_delproc("version");
+ device_remove_file(dev, &dev_attr_version_h);
+ #else
+ ifx_proc_delproc("version");
+ device_remove_file(dev, &dev_attr_version_d);
+ #endif
+
+
+ #ifdef __IS_HOST__
+ #ifdef __IS_DUAL__
+ ifx_proc_delproc("pkt_count_limit_bi_1");
+ ifx_proc_delproc("pkt_count_limit_bo_1");
+ ifx_proc_delproc("pkt_count_limit_bi_2");
+ ifx_proc_delproc("pkt_count_limit_bo_2");
+ ifx_proc_delproc("bandwidth_hs_1");
+ ifx_proc_delproc("bandwidth_fs_1");
+ ifx_proc_delproc("bandwidth_ls_1");
+ ifx_proc_delproc("bandwidth_hs_2");
+ ifx_proc_delproc("bandwidth_fs_2");
+ ifx_proc_delproc("bandwidth_ls_2");
+ device_remove_file(dev, &dev_attr_pkt_count_limit_bi_1);
+ device_remove_file(dev, &dev_attr_pkt_count_limit_bo_1);
+ device_remove_file(dev, &dev_attr_pkt_count_limit_bi_2);
+ device_remove_file(dev, &dev_attr_pkt_count_limit_bo_2);
+ device_remove_file(dev, &dev_attr_bandwidth_hs_1);
+ device_remove_file(dev, &dev_attr_bandwidth_fs_1);
+ device_remove_file(dev, &dev_attr_bandwidth_ls_1);
+ device_remove_file(dev, &dev_attr_bandwidth_hs_2);
+ device_remove_file(dev, &dev_attr_bandwidth_fs_2);
+ device_remove_file(dev, &dev_attr_bandwidth_ls_2);
+ #else
+ ifx_proc_delproc("pkt_count_limit_bi");
+ ifx_proc_delproc("pkt_count_limit_bo");
+ ifx_proc_delproc("bandwidth_hs");
+ ifx_proc_delproc("bandwidth_fs");
+ ifx_proc_delproc("bandwidth_ls");
+ device_remove_file(dev, &dev_attr_pkt_count_limit_bi);
+ device_remove_file(dev, &dev_attr_pkt_count_limit_bo);
+ device_remove_file(dev, &dev_attr_bandwidth_hs);
+ device_remove_file(dev, &dev_attr_bandwidth_fs);
+ device_remove_file(dev, &dev_attr_bandwidth_ls);
+ #endif
+ #endif
+
+ #ifdef __IS_HOST__
+ #ifdef __IS_DUAL__
+ ifx_proc_delproc("buspower_1");
+ ifx_proc_delproc("buspower_2");
+ device_remove_file(dev, &dev_attr_buspower_1);
+ device_remove_file(dev, &dev_attr_buspower_2);
+ #else
+ ifx_proc_delproc("buspower");
+ device_remove_file(dev, &dev_attr_buspower);
+ #endif
+
+ #ifdef __IS_DUAL__
+ ifx_proc_delproc("bussuspend_1");
+ ifx_proc_delproc("bussuspend_2");
+ device_remove_file(dev, &dev_attr_bussuspend_1);
+ device_remove_file(dev, &dev_attr_bussuspend_2);
+ #else
+ ifx_proc_delproc("bussuspend");
+ device_remove_file(dev, &dev_attr_bussuspend);
+ #endif
+
+ #ifdef __IS_DUAL__
+ ifx_proc_delproc("busconnected_1");
+ ifx_proc_delproc("busconnected_2");
+ device_remove_file(dev, &dev_attr_busconnected_1);
+ device_remove_file(dev, &dev_attr_busconnected_2);
+ #else
+ ifx_proc_delproc("busconnected");
+ device_remove_file(dev, &dev_attr_busconnected);
+ #endif
+
+ #ifdef __IS_DUAL__
+ ifx_proc_delproc("connectspeed_1");
+ ifx_proc_delproc("connectspeed_2");
+ device_remove_file(dev, &dev_attr_connectspeed_1);
+ device_remove_file(dev, &dev_attr_connectspeed_2);
+ #else
+ ifx_proc_delproc("connectspeed");
+ device_remove_file(dev, &dev_attr_connectspeed);
+ #endif
+ #endif
+
+ #ifdef __IS_DEVICE__
+ ifx_proc_delproc("devspeed");
+ device_remove_file(dev, &dev_attr_devspeed);
+ ifx_proc_delproc("enumspeed");
+ device_remove_file(dev, &dev_attr_enumspeed);
+ #endif
+
+ #ifdef __ENABLE_DUMP__
+ #ifdef __IS_HOST__
+ #ifdef __IS_DUAL__
+ ifx_proc_delproc("dump_reg_1");
+ ifx_proc_delproc("dump_reg_2");
+ device_remove_file(dev, &dev_attr_dump_reg_h_1);
+ device_remove_file(dev, &dev_attr_dump_reg_h_2);
+ #else
+ ifx_proc_delproc("dump_reg");
+ device_remove_file(dev, &dev_attr_dump_reg_h);
+ #endif
+
+ #ifdef __IS_DUAL__
+ ifx_proc_delproc("dump_spram_1");
+ ifx_proc_delproc("dump_spram_2");
+ device_remove_file(dev, &dev_attr_dump_spram_h_1);
+ device_remove_file(dev, &dev_attr_dump_spram_h_2);
+ #else
+ ifx_proc_delproc("dump_spram");
+ device_remove_file(dev, &dev_attr_dump_spram_h);
+ #endif
+
+ #ifdef __IS_DUAL__
+ ifx_proc_delproc("dump_host_state_1");
+ ifx_proc_delproc("dump_host_state_2");
+ device_remove_file(dev, &dev_attr_dump_host_state_1);
+ device_remove_file(dev, &dev_attr_dump_host_state_2);
+ #else
+ ifx_proc_delproc("dump_host_state");
+ device_remove_file(dev, &dev_attr_dump_host_state);
+ #endif
+ #else
+ ifx_proc_delproc("dump_reg");
+ device_remove_file(dev, &dev_attr_dump_reg_d);
+ ifx_proc_delproc("dump_spram");
+ device_remove_file(dev, &dev_attr_dump_spram_d);
+ #endif
+
+ #ifdef __IS_HOST__
+ #endif
+ #endif //__ENABLE_DUMP__
+#ifdef __IS_HOST__
+ #ifdef __IS_DUAL__
+ ifx_proc_delproc("suspend_host_1");
+ ifx_proc_delproc("probe_host_1");
+ device_remove_file(dev, &dev_attr_suspend_host_1);
+ device_remove_file(dev, &dev_attr_probe_host_1);
+ ifx_proc_delproc("suspend_host_2");
+ ifx_proc_delproc("probe_host_2");
+ device_remove_file(dev, &dev_attr_suspend_host_2);
+ device_remove_file(dev, &dev_attr_probe_host_2);
+ ifx_proc_delproc("probe_timer1");
+ ifx_proc_delproc("autoprobe_timer1");
+ device_remove_file(dev, &dev_attr_probe_timer1_val_h);
+ device_remove_file(dev, &dev_attr_autoprobe_timer1_val_h);
+ ifx_proc_delproc("probe_timer2");
+ ifx_proc_delproc("autoprobe_timer2");
+ device_remove_file(dev, &dev_attr_probe_timer2_val_h);
+ device_remove_file(dev, &dev_attr_autoprobe_timer2_val_h);
+ #else
+ ifx_proc_delproc("suspend_host");
+ ifx_proc_delproc("probe_host");
+ device_remove_file(dev, &dev_attr_suspend_host);
+ device_remove_file(dev, &dev_attr_probe_host);
+ ifx_proc_delproc("probe_timer");
+ ifx_proc_delproc("autoprobe_timer");
+ device_remove_file(dev, &dev_attr_probe_timer_val_h);
+ device_remove_file(dev, &dev_attr_autoprobe_timer_val_h);
+ #endif
+ remove_proc_entry(ifxusb_hcd_driver_name, (void *)0);
+#endif
+
+#ifdef __IS_DEVICE__
+ ifx_proc_delproc("suspend_device");
+ ifx_proc_delproc("probe_device");
+ device_remove_file(dev, &dev_attr_suspend_device);
+ device_remove_file(dev, &dev_attr_probe_device);
+ ifx_proc_delproc("probe_timer");
+ ifx_proc_delproc("autoprobe_timer");
+ device_remove_file(dev, &dev_attr_probe_timer_val_d);
+ device_remove_file(dev, &dev_attr_autoprobe_timer_val_d);
+ remove_proc_entry(ifxusb_pcd_driver_name, (void *)0);
+#endif
+#if defined(__IS_HOST__) && defined(__HOST_COC__)
+ #ifdef __IS_DUAL__
+ ifx_pmcu_unregister ( &pmcuRegisterUSBHost_1 );
+ ifx_pmcu_unregister ( &pmcuRegisterUSBHost_2 );
+ #else
+ ifx_pmcu_unregister ( &pmcuRegisterUSBHost );
+ #endif
+#endif
+#if defined(__IS_DEVICE__) && defined(__GADGET_COC__)
+ ifx_pmcu_unregister ( &pmcuRegisterUSBGadget );
+#endif
+
+}
+
+static struct proc_dir_entry * proc_ifx_root = NULL;
+
+/* initialize the proc file system and make a dir named /proc/[name] */
+static void ifx_proc_init(void)
+{
+ IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
+#ifdef __IS_HOST__
+ proc_ifx_root = proc_mkdir(ifxusb_hcd_driver_name, (void *)0);
+ if (!proc_ifx_root){
+ IFX_PRINT("%s proc initialization failed! \n", ifxusb_hcd_driver_name);
+ return;
+ }
+#else
+ proc_ifx_root = proc_mkdir(ifxusb_pcd_driver_name, (void *)0);
+ if (!proc_ifx_root){
+ IFX_PRINT("%s proc initialization failed! \n", ifxusb_pcd_driver_name);
+ return;
+ }
+#endif
+}
+
+/* proc file system add function for debugging. */
+static int ifx_proc_addproc(char *funcname, read_proc_t *hookfuncr, write_proc_t *hookfuncw)
+{
+ struct proc_dir_entry *pe;
+ IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
+ if (!proc_ifx_root)
+ ifx_proc_init();
+
+ if (hookfuncw == NULL)
+ {
+ pe = create_proc_read_entry(funcname, S_IRUGO, proc_ifx_root, hookfuncr, NULL);
+ if (!pe)
+ {
+ IFX_PRINT("ERROR in creating read proc entry (%s)! \n", funcname);
+ return -1;
+ }
+ }
+ else
+ {
+ pe = create_proc_entry(funcname, S_IRUGO | S_IWUGO, proc_ifx_root);
+ if (pe)
+ {
+ pe->read_proc = hookfuncr;
+ pe->write_proc = hookfuncw;
+ }
+ else
+ {
+ IFX_PRINT("ERROR in creating proc entry (%s)! \n", funcname);
+ return -1;
+ }
+ }
+ return 0;
+}
+
+
+/* proc file system del function for removing module. */
+static void ifx_proc_delproc(char *funcname)
+{
+ char pname[30];
+ IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
+ sprintf(pname, "%s", funcname);
+
+ remove_proc_entry(pname, proc_ifx_root);
+
+}
+
+static void ifxusb_dump_params(ifxusb_core_if_t *_core_if)
+{
+ ifxusb_params_t *params=&_core_if->params;
+
+ #ifdef __IS_HOST__
+ IFX_PRINT("IFXUSB Dump Parameters ( Host Mode) \n");
+ #endif //__IS_HOST__
+ #ifdef __IS_DEVICE__
+ IFX_PRINT("IFXUSB Dump Parameters ( Device Mode) \n");
+ #endif //__IS_DEVICE__
+
+ #ifdef __DESC_DMA__
+ IFX_PRINT("DMA: Hermes DMA\n");
+ #else
+ IFX_PRINT("DMA: Non-Desc DMA\n");
+ #endif
+ IFX_PRINT(" Burst size: %d\n",params->dma_burst_size);
+
+ if (params->speed==1)
+ IFX_PRINT("Full Speed only\n");
+ else if(params->speed==0)
+ IFX_PRINT("Full/Hign Speed\n");
+ else
+ IFX_PRINT("Unkonwn setting (%d) for Speed\n",params->speed);
+
+ IFX_PRINT("Total Data FIFO size: %d(0x%06X) DWord, %d(0x%06X) Bytes\n",
+ params->data_fifo_size,params->data_fifo_size,
+ params->data_fifo_size*4, params->data_fifo_size*4
+ );
+
+ #ifdef __IS_DEVICE__
+ IFX_PRINT("Rx FIFO size: %d(0x%06X) DWord, %d(0x%06X) Bytes\n",
+ params->rx_fifo_size,params->rx_fifo_size,
+ params->rx_fifo_size*4, params->rx_fifo_size*4
+ );
+ {
+ int i;
+ for(i=0;i<MAX_EPS_CHANNELS;i++)
+ {
+ IFX_PRINT("Tx FIFO #%d size: %d(0x%06X) DWord, %d(0x%06X) Bytes\n",i,
+ params->tx_fifo_size[i],params->tx_fifo_size[i],
+ params->tx_fifo_size[i]*4, params->tx_fifo_size[i]*4
+ );
+ }
+ }
+ #ifdef __DED_FIFO__
+ IFX_PRINT("Treshold : %s Rx:%d Tx:%d \n",
+ (params->thr_ctl)?"On":"Off",params->tx_thr_length,params->rx_thr_length);
+ #endif
+ #else //__IS_HOST__
+ IFX_PRINT("Host Channels: %d\n",params->host_channels);
+
+ IFX_PRINT("Rx FIFO size: %d(0x%06X) DWord, %d(0x%06X) Bytes\n",
+ params->data_fifo_size,params->data_fifo_size,
+ params->data_fifo_size*4, params->data_fifo_size*4
+ );
+
+ IFX_PRINT("NP Tx FIFO size: %d(0x%06X) DWord, %d(0x%06X) Bytes\n",
+ params->nperio_tx_fifo_size,params->nperio_tx_fifo_size,
+ params->nperio_tx_fifo_size*4, params->nperio_tx_fifo_size*4
+ );
+
+ IFX_PRINT(" P Tx FIFO size: %d(0x%06X) DWord, %d(0x%06X) Bytes\n",
+ params->perio_tx_fifo_size,params->perio_tx_fifo_size,
+ params->perio_tx_fifo_size*4, params->perio_tx_fifo_size*4
+ );
+ #endif //__IS_HOST__
+
+ IFX_PRINT("Max Transfer size: %d(0x%06X) Bytes\n",
+ params->max_transfer_size,params->max_transfer_size
+ );
+ IFX_PRINT("Max Packet Count: %d(0x%06X)\n",
+ params->max_packet_count,params->max_packet_count
+ );
+
+ IFX_PRINT("PHY UTMI Width: %d\n",params->phy_utmi_width);
+
+ IFX_PRINT("Turn Around Time: HS:%d FS:%d\n",params->turn_around_time_hs,params->turn_around_time_fs);
+ IFX_PRINT("Timeout Calibration: HS:%d FS:%d\n",params->timeout_cal_hs,params->timeout_cal_fs);
+
+
+ IFX_PRINT("==================================================\n");
+ IFX_PRINT("End of Parameters Dump\n");
+ IFX_PRINT("==================================================\n");
+}
+
diff --git a/package/platform/lantiq/ltq-hcd/src/ifxusb_driver.c b/package/platform/lantiq/ltq-hcd/src/ifxusb_driver.c
new file mode 100644
index 0000000..04346b9
--- /dev/null
+++ b/package/platform/lantiq/ltq-hcd/src/ifxusb_driver.c
@@ -0,0 +1,1286 @@
+/*****************************************************************************
+ ** FILE NAME : ifxusb_driver.c
+ ** PROJECT : IFX USB sub-system V3
+ ** MODULES : IFX USB sub-system Host and Device driver
+ ** SRC VERSION : 3.2
+ ** DATE : 1/Jan/2011
+ ** AUTHOR : Chen, Howard
+ ** DESCRIPTION : The provides the initialization and cleanup entry
+ ** points for the IFX USB driver. This module can be
+ ** dynamically loaded with insmod command or built-in
+ ** with kernel. When loaded or executed the ifxusb_driver_init
+ ** function is called. When the module is removed (using rmmod),
+ ** the ifxusb_driver_cleanup function is called.
+ ** FUNCTIONS :
+ ** COMPILER : gcc
+ ** REFERENCE : Synopsys DWC-OTG Driver 2.7
+ ** COPYRIGHT : Copyright (c) 2010
+ ** LANTIQ DEUTSCHLAND GMBH,
+ ** Am Campeon 3, 85579 Neubiberg, Germany
+ **
+ ** 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 of the License, or
+ ** (at your option) any later version.
+ **
+ ** Version Control Section **
+ ** $Author$
+ ** $Date$
+ ** $Revisions$
+ ** $Log$ Revision history
+ *****************************************************************************/
+
+/*
+ * This file contains code fragments from Synopsys HS OTG Linux Software Driver.
+ * For this code the following notice is applicable:
+ *
+ * ==========================================================================
+ *
+ * Synopsys HS OTG Linux Software Driver and documentation (hereinafter,
+ * "Software") is an Unsupported proprietary work of Synopsys, Inc. unless
+ * otherwise expressly agreed to in writing between Synopsys and you.
+ *
+ * The Software IS NOT an item of Licensed Software or Licensed Product under
+ * any End User Software License Agreement or Agreement for Licensed Product
+ * with Synopsys or any supplement thereto. You are permitted to use and
+ * redistribute this Software in source and binary forms, with or without
+ * modification, provided that redistributions of source code must retain this
+ * notice. You may not view, use, disclose, copy or distribute this file or
+ * any information contained herein except pursuant to this license grant from
+ * Synopsys. If you do not agree with this notice, including the disclaimer
+ * below, then you are not authorized to use the Software.
+ *
+ * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" BASIS
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ * ========================================================================== */
+
+/*!
+ \file ifxusb_driver.c
+ \brief This file contains the loading/unloading interface to the Linux driver.
+*/
+
+#include <linux/version.h>
+#include "ifxusb_version.h"
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/init.h>
+
+#include <linux/device.h>
+#include <linux/of_platform.h>
+#include <linux/of_gpio.h>
+
+#include <linux/errno.h>
+#include <linux/types.h>
+#include <linux/stat.h> /* permission constants */
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+ #include <linux/irq.h>
+#endif
+
+#include <asm/io.h>
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
+ #include <asm/irq.h>
+#endif
+
+#include "ifxusb_plat.h"
+
+#include "ifxusb_cif.h"
+
+#ifdef __IS_HOST__
+ #include "ifxhcd.h"
+
+ #define USB_DRIVER_DESC "IFX USB HCD driver"
+ const char ifxusb_hcd_driver_name[] = "ifxusb_hcd";
+ #ifdef __IS_DUAL__
+ ifxhcd_hcd_t ifxusb_hcd_1;
+ ifxhcd_hcd_t ifxusb_hcd_2;
+ const char ifxusb_hcd_name_1[] = "ifxusb_hcd_1";
+ const char ifxusb_hcd_name_2[] = "ifxusb_hcd_2";
+ #else
+ ifxhcd_hcd_t ifxusb_hcd;
+ const char ifxusb_hcd_name[] = "ifxusb_hcd";
+ #endif
+
+ #if defined(__DO_OC_INT__)
+ ifxhcd_hcd_t *oc_int_id=NULL;
+ #ifdef __IS_DUAL__
+ ifxhcd_hcd_t *oc_int_id_1=NULL;
+ ifxhcd_hcd_t *oc_int_id_2=NULL;
+ #endif
+ #endif
+#endif
+
+#ifdef __IS_DEVICE__
+ #include "ifxpcd.h"
+
+ #define USB_DRIVER_DESC "IFX USB PCD driver"
+ const char ifxusb_pcd_driver_name[] = "ifxusb_pcd";
+ ifxpcd_pcd_t ifxusb_pcd;
+ const char ifxusb_pcd_name[] = "ifxusb_pcd";
+#endif
+
+/* Global Debug Level Mask. */
+#ifdef __IS_HOST__
+ uint32_t h_dbg_lvl = 0xff;
+#endif
+
+#ifdef __IS_DEVICE__
+ uint32_t d_dbg_lvl = 0x00;
+#endif
+
+#ifdef __IS_HOST__
+ifxusb_params_t ifxusb_module_params_h;
+#else
+ifxusb_params_t ifxusb_module_params_d;
+#endif
+
+static void parse_parms(void);
+
+
+#if defined(__IS_TWINPASS__)
+#warning "Compiled as TWINPASS"
+#elif defined(__IS_DANUBE__)
+#warning "Compiled as DANUBE"
+#elif defined(__IS_AMAZON_SE__)
+#warning "Compiled as AMAZON_SE"
+#elif defined(__IS_AR9__)
+#warning "Compiled as AR9"
+#elif defined(__IS_VR9__)
+#warning "Compiled as VR9"
+#elif defined(__IS_AR10__)
+#warning "Compiled as AR10"
+#else
+#error "No Platform defined"
+#endif
+
+
+/* Function to setup the structures to control one usb core running as host*/
+#ifdef __IS_HOST__
+/*!
+ \brief inlined by ifxusb_driver_probe(), handling host mode probing. Run at each host core.
+*/
+ static inline int ifxusb_driver_probe_h(ifxhcd_hcd_t *_hcd,
+ int _irq,
+ uint32_t _iobase,
+ uint32_t _fifomem,
+ uint32_t _fifodbg
+ )
+ {
+ int retval = 0;
+
+ IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
+
+ ifxusb_power_on_h (&_hcd->core_if);
+ mdelay(50);
+ ifxusb_phy_power_on_h (&_hcd->core_if); // Test
+ mdelay(50);
+ ifxusb_hard_reset_h(&_hcd->core_if);
+ retval =ifxusb_core_if_init_h(&_hcd->core_if,
+ _irq,
+ _iobase,
+ _fifomem,
+ _fifodbg);
+ if(retval)
+ return retval;
+
+ ifxusb_host_core_init(&_hcd->core_if,&ifxusb_module_params_h);
+
+ ifxusb_disable_global_interrupts_h( &_hcd->core_if);
+
+ /* The driver is now initialized and need to be registered into Linux USB sub-system */
+
+ retval = ifxhcd_init(_hcd); // hook the hcd into usb ss
+
+ if (retval != 0)
+ {
+ IFX_ERROR("_hcd_init failed\n");
+ return retval;
+ }
+
+ //ifxusb_enable_global_interrupts_h( _hcd->core_if ); // this should be done at hcd_start , including hcd_interrupt
+ return 0;
+ }
+#endif //__IS_HOST__
+
+#ifdef __IS_DEVICE__
+/*!
+ \brief inlined by ifxusb_driver_probe(), handling device mode probing.
+*/
+ static inline int ifxusb_driver_probe_d(ifxpcd_pcd_t *_pcd,
+ int _irq,
+ uint32_t _iobase,
+ uint32_t _fifomem,
+ uint32_t _fifodbg
+ )
+ {
+ int retval = 0;
+
+ IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
+ ifxusb_power_on_d (&_pcd->core_if);
+ mdelay(50);
+ ifxusb_phy_power_on_d (&_pcd->core_if); // Test
+ mdelay(50);
+ ifxusb_hard_reset_d(&_pcd->core_if);
+ retval =ifxusb_core_if_init_d(&_pcd->core_if,
+ _irq,
+ _iobase,
+ _fifomem,
+ _fifodbg);
+ if(retval)
+ return retval;
+
+ IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
+ ifxusb_dev_core_init(&_pcd->core_if,&ifxusb_module_params_d);
+
+ IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
+ ifxusb_disable_global_interrupts_d( &_pcd->core_if);
+
+ /* The driver is now initialized and need to be registered into
+ Linux USB Gadget sub-system
+ */
+ retval = ifxpcd_init();
+ IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
+
+ if (retval != 0)
+ {
+ IFX_ERROR("_pcd_init failed\n");
+ return retval;
+ }
+ //ifxusb_enable_global_interrupts_d( _pcd->core_if ); // this should be done at gadget bind or start
+ return 0;
+ }
+#endif //__IS_DEVICE__
+
+/*!
+ \brief This function is called when a driver is unregistered. This happens when
+ the rmmod command is executed. The device may or may not be electrically
+ present. If it is present, the driver stops device processing. Any resources
+ used on behalf of this device are freed.
+*/
+static int ifxusb_driver_remove(struct platform_device *_pdev)
+{
+ IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
+ #ifdef __IS_HOST__
+ #if defined(__IS_DUAL__)
+ ifxhcd_remove(&ifxusb_hcd_1);
+ ifxusb_core_if_remove_h(&ifxusb_hcd_1.core_if );
+ ifxhcd_remove(&ifxusb_hcd_2);
+ ifxusb_core_if_remove_h(&ifxusb_hcd_2.core_if );
+ #else
+ ifxhcd_remove(&ifxusb_hcd);
+ ifxusb_core_if_remove_h(&ifxusb_hcd.core_if );
+ #endif
+ #endif
+ #ifdef __IS_DEVICE__
+ ifxpcd_remove();
+ ifxusb_core_if_remove_d(&ifxusb_pcd.core_if );
+ #endif
+ /* Remove the device attributes */
+ #ifdef __IS_HOST__
+ ifxusb_attr_remove_h(&_pdev->dev);
+ #else
+ ifxusb_attr_remove_d(&_pdev->dev);
+ #endif
+ return 0;
+}
+
+/*!
+ \brief This function is called by module management in 2.6 kernel or by ifxusb_driver_init with 2.4 kernel
+ It is to probe and setup IFXUSB core(s).
+*/
+static int ifxusb_driver_probe(struct platform_device *_pdev)
+{
+ int retval = 0;
+ struct device_node *np;
+ int gpio_count;
+ u32 port_mask = 0x1;
+
+#ifdef __IS_DANUBE__
+ np = of_find_compatible_node(NULL, NULL, "lantiq,ifxhcd-danube");
+#elif defined __IS_AMAZON_SE__
+ np = of_find_compatible_node(NULL, NULL, "lantiq,ifxhcd-ase");
+#elif defined __IS_AR9__
+ np = of_find_compatible_node(NULL, NULL, "lantiq,ifxhcd-arx100");
+#elif defined __IS_VR9__
+ np = of_find_compatible_node(NULL, NULL, "lantiq,ifxhcd-xrx200");
+#elif defined __IS_AR10__
+ np = of_find_compatible_node(NULL, NULL, "lantiq,ifxhcd-arx300");
+#endif
+ if (!np) {
+ dev_err(&_pdev->dev, "failed to find hcd device node\n");
+ return -ENODEV;
+ }
+ of_property_read_u32(np, "lantiq,portmask", &port_mask);
+ // Parsing and store the parameters
+ IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
+ parse_parms();
+
+ #ifdef __IS_HOST__
+ #if defined(__DO_OC_INT__)
+ if(!oc_int_id)
+ {
+ #if defined(__IS_DUAL__)
+ oc_int_id=&ifxusb_hcd_1;
+ oc_int_id_1=&ifxusb_hcd_1;
+ oc_int_id_2=&ifxusb_hcd_2;
+ #else
+ oc_int_id=&ifxusb_hcd;
+ #endif
+ }
+ #endif
+
+ #if defined(__IS_DUAL__)
+ memset(&ifxusb_hcd_1, 0, sizeof(ifxhcd_hcd_t));
+ memset(&ifxusb_hcd_2, 0, sizeof(ifxhcd_hcd_t));
+
+ ifxusb_hcd_1.core_if.core_no=0;
+ ifxusb_hcd_2.core_if.core_no=1;
+ ifxusb_hcd_1.core_if.core_name=(char *)ifxusb_hcd_name_1;
+ ifxusb_hcd_2.core_if.core_name=(char *)ifxusb_hcd_name_2;
+
+ ifxusb_hcd_1.dev=&_pdev->dev;
+ ifxusb_hcd_2.dev=&_pdev->dev;
+
+ if (port_mask & 0x1) {
+ retval = ifxusb_driver_probe_h(&ifxusb_hcd_1,
+ IFXUSB1_IRQ,
+ IFXUSB1_IOMEM_BASE,
+ IFXUSB1_FIFOMEM_BASE,
+ IFXUSB1_FIFODBG_BASE
+ );
+ if(retval)
+ goto ifxusb_driver_probe_fail;
+ }
+
+ if (port_mask & 0x2) {
+ retval = ifxusb_driver_probe_h(&ifxusb_hcd_2,
+ IFXUSB2_IRQ,
+ IFXUSB2_IOMEM_BASE,
+ IFXUSB2_FIFOMEM_BASE,
+ IFXUSB2_FIFODBG_BASE
+ );
+ if(retval)
+ goto ifxusb_driver_probe_fail;
+ }
+ #elif defined(__IS_FIRST__)
+ memset(&ifxusb_hcd, 0, sizeof(ifxhcd_hcd_t));
+
+ ifxusb_hcd.core_if.core_no=0;
+ ifxusb_hcd.core_if.core_name=(char *)ifxusb_hcd_name;
+
+ ifxusb_hcd.dev=&_pdev->dev;
+
+ retval = ifxusb_driver_probe_h(&ifxusb_hcd,
+ IFXUSB1_IRQ,
+ IFXUSB1_IOMEM_BASE,
+ IFXUSB1_FIFOMEM_BASE,
+ IFXUSB1_FIFODBG_BASE
+ );
+ if(retval)
+ goto ifxusb_driver_probe_fail;
+
+ #elif defined(__IS_SECOND__)
+ memset(&ifxusb_hcd, 0, sizeof(ifxhcd_hcd_t));
+
+ ifxusb_hcd.core_if.core_no=1;
+ ifxusb_hcd.core_if.core_name=(char *)ifxusb_hcd_name;
+
+ ifxusb_hcd.dev=&_pdev->dev;
+
+ retval = ifxusb_driver_probe_h(&ifxusb_hcd,
+ IFXUSB2_IRQ,
+ IFXUSB2_IOMEM_BASE,
+ IFXUSB2_FIFOMEM_BASE,
+ IFXUSB2_FIFODBG_BASE
+ );
+ if(retval)
+ goto ifxusb_driver_probe_fail;
+
+ #else
+ memset(&ifxusb_hcd, 0, sizeof(ifxhcd_hcd_t));
+
+ ifxusb_hcd.core_if.core_no=0;
+ ifxusb_hcd.core_if.core_name=(char *)ifxusb_hcd_name;
+
+ ifxusb_hcd.dev=&_pdev->dev;
+
+ retval = ifxusb_driver_probe_h(&ifxusb_hcd,
+ IFXUSB_IRQ,
+ IFXUSB_IOMEM_BASE,
+ IFXUSB_FIFOMEM_BASE,
+ IFXUSB_FIFODBG_BASE
+ );
+ if(retval)
+ goto ifxusb_driver_probe_fail;
+ #endif
+ #endif
+
+ #ifdef __IS_DEVICE__
+ memset(&ifxusb_pcd, 0, sizeof(ifxpcd_pcd_t));
+ ifxusb_pcd.core_if.core_name=(char *)&ifxusb_pcd_name[0];
+
+ ifxusb_pcd.dev=&_pdev->dev;
+
+ #if defined(__IS_FIRST__)
+ ifxusb_pcd.core_if.core_no=0;
+ retval = ifxusb_driver_probe_d(&ifxusb_pcd,
+ IFXUSB1_IRQ,
+ IFXUSB1_IOMEM_BASE,
+ IFXUSB1_FIFOMEM_BASE,
+ IFXUSB1_FIFODBG_BASE
+ );
+ #elif defined(__IS_SECOND__)
+ ifxusb_pcd.core_if.core_no=1;
+ retval = ifxusb_driver_probe_d(&ifxusb_pcd,
+ IFXUSB2_IRQ,
+ IFXUSB2_IOMEM_BASE,
+ IFXUSB2_FIFOMEM_BASE,
+ IFXUSB2_FIFODBG_BASE
+ );
+ #else
+ ifxusb_pcd.core_if.core_no=0;
+ retval = ifxusb_driver_probe_d(&ifxusb_pcd,
+ IFXUSB_IRQ,
+ IFXUSB_IOMEM_BASE,
+ IFXUSB_FIFOMEM_BASE,
+ IFXUSB_FIFODBG_BASE
+ );
+ #endif
+ if(retval)
+ goto ifxusb_driver_probe_fail;
+ #endif
+
+ #ifdef __IS_HOST__
+ ifxusb_attr_create_h(&_pdev->dev);
+ #else
+ ifxusb_attr_create_d(&_pdev->dev);
+ #endif
+
+ gpio_count = of_gpio_count(np);
+ while (gpio_count) {
+ enum of_gpio_flags flags;
+ int gpio = of_get_gpio_flags(np, --gpio_count, &flags);
+ if (gpio_request(gpio, "usb"))
+ continue;
+ dev_info(&_pdev->dev, "requested GPIO %d\n", gpio);
+ gpio_direction_output(gpio, (flags & OF_GPIO_ACTIVE_LOW) ? (0) : (1));
+ }
+
+
+ return 0;
+
+ifxusb_driver_probe_fail:
+ ifxusb_driver_remove(_pdev);
+ return retval;
+}
+
+static struct resource ifxusb_device_resources[] =
+{
+ #if defined(__IS_DUAL__)
+ [0] = { .start = IFXUSB1_IRQ,
+ .flags = IORESOURCE_IRQ,
+ },
+ [1] = { .start = IFXUSB1_IOMEM_BASE,
+ .end = IFXUSB1_IOMEM_BASE + IFXUSB_IOMEM_SIZE-1,
+ .flags = IORESOURCE_MEM,
+ },
+ [2] = { .start = IFXUSB2_IRQ,
+ .flags = IORESOURCE_IRQ,
+ },
+ [3] = { .start = IFXUSB2_IOMEM_BASE,
+ .end = IFXUSB2_IOMEM_BASE + IFXUSB_IOMEM_SIZE-1,
+ .flags = IORESOURCE_MEM,
+ },
+ [4] = { .start = IFXUSB1_FIFOMEM_BASE,
+ .end = IFXUSB1_FIFOMEM_BASE + IFXUSB_FIFOMEM_SIZE-1,
+ .flags = IORESOURCE_MEM,
+ },
+ [5] = { .start = IFXUSB2_FIFOMEM_BASE,
+ .end = IFXUSB2_FIFOMEM_BASE + IFXUSB_FIFOMEM_SIZE-1,
+ .flags = IORESOURCE_MEM,
+ },
+ [6] = { .start = IFXUSB1_FIFODBG_BASE,
+ .end = IFXUSB1_FIFODBG_BASE + IFXUSB_FIFODBG_SIZE-1,
+ .flags = IORESOURCE_MEM,
+ },
+ [7] = { .start = IFXUSB2_FIFODBG_BASE,
+ .end = IFXUSB2_FIFODBG_BASE + IFXUSB_FIFODBG_SIZE-1,
+ .flags = IORESOURCE_MEM,
+ },
+ #elif defined(__IS_FIRST__)
+ [0] = { .start = IFXUSB1_IRQ,
+ .flags = IORESOURCE_IRQ,
+ },
+ [1] = { .start = IFXUSB1_IOMEM_BASE,
+ .end = IFXUSB1_IOMEM_BASE + IFXUSB_IOMEM_SIZE-1,
+ .flags = IORESOURCE_MEM,
+ },
+ [2] = { .start = IFXUSB1_FIFOMEM_BASE,
+ .end = IFXUSB1_FIFOMEM_BASE + IFXUSB_FIFOMEM_SIZE-1,
+ .flags = IORESOURCE_MEM,
+ },
+ [3] = { .start = IFXUSB1_FIFODBG_BASE,
+ .end = IFXUSB1_FIFODBG_BASE + IFXUSB_FIFODBG_SIZE-1,
+ .flags = IORESOURCE_MEM,
+ },
+ #elif defined(__IS_SECOND__)
+ [0] = { .start = IFXUSB2_IRQ,
+ .flags = IORESOURCE_IRQ,
+ },
+ [1] = { .start = IFXUSB2_IOMEM_BASE,
+ .end = IFXUSB2_IOMEM_BASE + IFXUSB_IOMEM_SIZE-1,
+ .flags = IORESOURCE_MEM,
+ },
+ [2] = { .start = IFXUSB2_FIFOMEM_BASE,
+ .end = IFXUSB2_FIFOMEM_BASE + IFXUSB_FIFOMEM_SIZE-1,
+ .flags = IORESOURCE_MEM,
+ },
+ [3] = { .start = IFXUSB2_FIFODBG_BASE,
+ .end = IFXUSB2_FIFODBG_BASE + IFXUSB_FIFODBG_SIZE-1,
+ .flags = IORESOURCE_MEM,
+ },
+ #else
+ [0] = { .start = IFXUSB_IRQ,
+ .flags = IORESOURCE_IRQ,
+ },
+ [1] = { .start = IFXUSB_IOMEM_BASE,
+ .end = IFXUSB_IOMEM_BASE + IFXUSB_IOMEM_SIZE-1,
+ .flags = IORESOURCE_MEM,
+ },
+ [2] = { .start = IFXUSB_FIFOMEM_BASE,
+ .end = IFXUSB_FIFOMEM_BASE+IFXUSB_FIFOMEM_SIZE-1,
+ .flags = IORESOURCE_MEM,
+ },
+ [3] = { .start = IFXUSB_FIFODBG_BASE,
+ .end = IFXUSB_FIFODBG_BASE+IFXUSB_FIFODBG_SIZE-1,
+ .flags = IORESOURCE_MEM,
+ },
+ #endif //__IS_DUAL__
+};
+
+static u64 ifxusb_dmamask = (u32)0x1fffffff;
+
+static void ifxusb_device_release(struct device * dev)
+{
+ IFX_PRINT("IFX USB platform_dev release\n");
+ dev->parent = NULL;
+}
+
+static struct platform_device ifxusb_device =
+{
+ .id = -1,
+ .dev =
+ {
+ .release = ifxusb_device_release,
+ .dma_mask = &ifxusb_dmamask,
+ },
+ .resource = ifxusb_device_resources,
+ .num_resources = ARRAY_SIZE(ifxusb_device_resources),
+};
+
+
+/*!
+ \brief This function is called when the ifxusb_driver is installed with the insmod command.
+*/
+static struct platform_driver ifxusb_driver = {
+ .probe = ifxusb_driver_probe,
+ .remove = ifxusb_driver_remove,
+ .driver ={
+ .owner = THIS_MODULE,
+ #ifdef __IS_HOST__
+ .name = ifxusb_hcd_driver_name,
+ #else
+ .name = ifxusb_pcd_driver_name,
+ #endif
+ },
+};
+
+#ifdef __IS_HOST__
+ int __init ifxusb_hcd_driver_init(void)
+#else
+ int __init ifxusb_pcd_driver_init(void)
+#endif
+{
+ int retval = 0;
+ IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
+ #if defined(__IS_HOST__)
+ IFX_PRINT("%s: version %s\n", ifxusb_hcd_driver_name, IFXUSB_VERSION);
+ #else
+ IFX_PRINT("%s: version %s\n", ifxusb_pcd_driver_name, IFXUSB_VERSION);
+ #endif
+
+ #if 0
+ #if defined(__IS_TWINPASS__)
+ IFX_PRINT(" OPTION: __IS_TWINPASS__\n");
+ #elif defined(__IS_DANUBE__)
+ IFX_PRINT(" OPTION: __IS_DANUBE__\n");
+ #elif defined(__IS_AMAZON_SE__)
+ IFX_PRINT(" OPTION: __IS_AMAZON_SE__\n");
+ #elif defined(__IS_AR9__)
+ IFX_PRINT(" OPTION: __IS_AR9__\n");
+ #elif defined(__IS_VR9__)
+ IFX_PRINT(" OPTION: __IS_VR9__\n");
+ #elif defined(__IS_AR10__)
+ IFX_PRINT(" OPTION: __IS_AR10__\n");
+ #else
+ IFX_PRINT(" OPTION: NO PLATFORM DEFINED\n");
+ #endif
+
+ #ifdef __UEIP__
+ IFX_PRINT(" OPTION: __UEIP__\n");
+ #endif
+
+ #ifdef __PHY_LONG_PREEMP__
+ IFX_PRINT(" OPTION: __PHY_LONG_PREEMP__\n");
+ #endif
+ #ifdef __FORCE_USB11__
+ IFX_PRINT(" OPTION: __FORCE_USB11__\n");
+ #endif
+ #ifdef __UNALIGNED_BUF_ADJ__
+ IFX_PRINT(" OPTION: __UNALIGNED_BUF_ADJ__\n");
+ #endif
+ #ifdef __UNALIGNED_BUF_CHK__
+ IFX_PRINT(" OPTION: __UNALIGNED_BUF_CHK__\n");
+ #endif
+ #ifdef __UNALIGNED_BUF_BURST__
+ IFX_PRINT(" OPTION: __UNALIGNED_BUF_BURST__\n");
+ #endif
+ #ifdef __DEBUG__
+ IFX_PRINT(" OPTION: __DEBUG__\n");
+ #endif
+ #ifdef __ENABLE_DUMP__
+ IFX_PRINT(" OPTION: __ENABLE_DUMP__\n");
+ #endif
+
+ #ifdef __IS_HOST__
+ IFX_PRINT(" OPTION: __IS_HOST__\n");
+ #ifdef __IS_DUAL__
+ IFX_PRINT(" __IS_DUAL__\n");
+ #endif
+ #ifdef __IS_FIRST__
+ IFX_PRINT(" __IS_FIRST__\n");
+ #endif
+ #ifdef __IS_SECOND__
+ IFX_PRINT(" __IS_SECOND__\n");
+ #endif
+ #ifdef __WITH_HS_ELECT_TST__
+ IFX_PRINT(" __WITH_HS_ELECT_TST__\n");
+ #endif
+ #ifdef __EN_ISOC__
+ IFX_PRINT(" __EN_ISOC__\n");
+ #endif
+ #ifdef __EN_ISOC_SPLIT__
+ IFX_PRINT(" __EN_ISOC_SPLIT__\n");
+ #endif
+ #ifdef __EPQD_DESTROY_TIMEOUT__
+ IFX_PRINT(" __EPQD_DESTROY_TIMEOUT__\n");
+ #endif
+ #ifdef __DYN_SOF_INTR__
+ IFX_PRINT(" __DYN_SOF_INTR__\n");
+ #endif
+ #else
+ IFX_PRINT(" OPTION: __IS_DEVICE__\n");
+ #ifdef __DED_INTR__
+ IFX_PRINT(" __DED_INTR__\n");
+ #endif
+ #ifdef __DED_FIFO__
+ IFX_PRINT(" __DED_FIFO__\n");
+ #endif
+ #ifdef __DESC_DMA__
+ IFX_PRINT(" __DESC_DMA__\n");
+ #endif
+ #ifdef __IS_FIRST__
+ IFX_PRINT(" __IS_FIRST__\n");
+ #endif
+ #ifdef __IS_SECOND__
+ IFX_PRINT(" __IS_SECOND__\n");
+ #endif
+ #ifdef __GADGET_TASKLET_TX__
+ IFX_PRINT(" __GADGET_TASKLET_TX__\n");
+ #endif
+ #ifdef __GADGET_TASKLET_RX__
+ IFX_PRINT(" __GADGET_TASKLET_RX__\n");
+ #endif
+ #ifdef __GADGET_TASKLET_HIGH__
+ IFX_PRINT(" __GADGET_TASKLET_HIGH__\n");
+ #endif
+ #ifdef __DO_PCD_UNLOCK__
+ IFX_PRINT(" __DO_PCD_UNLOCK__\n");
+ #endif
+ #ifdef __GADGET_LED__
+ IFX_PRINT(" __GADGET_LED__\n");
+ #endif
+
+ #ifdef __ECM_NO_INTR__
+ IFX_PRINT(" __ECM_NO_INTR__\n");
+ #endif
+ #ifdef __NOSWAPINCTRL__
+ IFX_PRINT(" __NOSWAPINCTRL__\n");
+ #endif
+ #ifdef __MAC_ECM_FIX__
+ IFX_PRINT(" __MAC_ECM_FIX__\n");
+ #endif
+ #ifdef __RETAIN_BUF_TX__
+ IFX_PRINT(" __RETAIN_BUF_TX__\n");
+ #endif
+ #ifdef __RETAIN_BUF_RX__
+ IFX_PRINT(" __RETAIN_BUF_RX__\n");
+ #endif
+ #ifdef __QUICKNAK__
+ IFX_PRINT(" __QUICKNAK__\n");
+ #endif
+ #endif
+ #endif
+
+ retval = platform_driver_register(&ifxusb_driver);
+
+ if (retval < 0) {
+ IFX_ERROR("%s retval=%d\n", __func__, retval);
+ return retval;
+ }
+
+ #ifdef __IS_HOST__
+ ifxusb_device.name = ifxusb_hcd_driver_name;
+ #else
+ ifxusb_device.name = ifxusb_pcd_driver_name;
+ #endif
+
+ if (ifxusb_device.dev.parent)
+ retval = -EBUSY;
+ else
+ retval = platform_device_register(&ifxusb_device);
+
+ if (retval < 0)
+ {
+ IFX_ERROR("%s retval=%d\n", __func__, retval);
+ platform_driver_unregister(&ifxusb_driver);
+ return retval;
+ }
+ return retval;
+}
+
+#ifdef __IS_HOST__
+ module_init(ifxusb_hcd_driver_init);
+#else
+ module_init(ifxusb_pcd_driver_init);
+#endif
+
+/*!
+ \brief This function is called when the driver is removed from the kernel
+ with the rmmod command. The driver unregisters itself with its bus
+ driver.
+*/
+#ifdef __IS_HOST__
+ void __exit ifxusb_hcd_driver_cleanup(void)
+ {
+ IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
+ platform_device_unregister(&ifxusb_device);
+ platform_driver_unregister(&ifxusb_driver);
+ IFX_PRINT("%s module removed\n", ifxusb_hcd_driver_name);
+ }
+ module_exit(ifxusb_hcd_driver_cleanup);
+#else
+ void __exit ifxusb_pcd_driver_cleanup(void)
+ {
+ IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
+ platform_device_unregister(&ifxusb_device);
+ platform_driver_unregister(&ifxusb_driver);
+ IFX_PRINT("%s module removed\n", ifxusb_pcd_driver_name);
+ }
+ module_exit(ifxusb_pcd_driver_cleanup);
+#endif
+MODULE_DESCRIPTION(USB_DRIVER_DESC);
+MODULE_AUTHOR("Lantiq");
+MODULE_LICENSE("GPL");
+
+
+
+// Parameters set when loaded
+//static long dbg_lvl =0xFFFFFFFF;
+static long dbg_lvl =0;
+static short dma_burst_size =-1;
+static short speed =-1;
+static long data_fifo_size =-1;
+#ifdef __IS_DEVICE__
+ static long rx_fifo_size =-1;
+ #ifdef __DED_FIFO__
+ static long tx_fifo_size_00 =-1;
+ static long tx_fifo_size_01 =-1;
+ static long tx_fifo_size_02 =-1;
+ static long tx_fifo_size_03 =-1;
+ static long tx_fifo_size_04 =-1;
+ static long tx_fifo_size_05 =-1;
+ static long tx_fifo_size_06 =-1;
+ static long tx_fifo_size_07 =-1;
+ static long tx_fifo_size_08 =-1;
+ static long tx_fifo_size_09 =-1;
+ static long tx_fifo_size_10 =-1;
+ static long tx_fifo_size_11 =-1;
+ static long tx_fifo_size_12 =-1;
+ static long tx_fifo_size_13 =-1;
+ static long tx_fifo_size_14 =-1;
+ static long tx_fifo_size_15 =-1;
+ static short thr_ctl=-1;
+ static long tx_thr_length =-1;
+ static long rx_thr_length =-1;
+ #else
+ static long nperio_tx_fifo_size =-1;
+ static long perio_tx_fifo_size_01 =-1;
+ static long perio_tx_fifo_size_02 =-1;
+ static long perio_tx_fifo_size_03 =-1;
+ static long perio_tx_fifo_size_04 =-1;
+ static long perio_tx_fifo_size_05 =-1;
+ static long perio_tx_fifo_size_06 =-1;
+ static long perio_tx_fifo_size_07 =-1;
+ static long perio_tx_fifo_size_08 =-1;
+ static long perio_tx_fifo_size_09 =-1;
+ static long perio_tx_fifo_size_10 =-1;
+ static long perio_tx_fifo_size_11 =-1;
+ static long perio_tx_fifo_size_12 =-1;
+ static long perio_tx_fifo_size_13 =-1;
+ static long perio_tx_fifo_size_14 =-1;
+ static long perio_tx_fifo_size_15 =-1;
+ #endif
+ static short dev_endpoints =-1;
+#endif
+
+#ifdef __IS_HOST__
+ static long rx_fifo_size =-1;
+ static long nperio_tx_fifo_size =-1;
+ static long perio_tx_fifo_size =-1;
+ static short host_channels =-1;
+#endif
+
+static long max_transfer_size =-1;
+static long max_packet_count =-1;
+static long phy_utmi_width =-1;
+static long turn_around_time_hs =-1;
+static long turn_around_time_fs =-1;
+static long timeout_cal_hs =-1;
+static long timeout_cal_fs =-1;
+
+/*!
+ \brief Parsing the parameters taken when module load
+*/
+static void parse_parms(void)
+{
+
+ ifxusb_params_t *params;
+ IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
+ #ifdef __IS_HOST__
+ h_dbg_lvl=dbg_lvl;
+ params=&ifxusb_module_params_h;
+ #endif
+ #ifdef __IS_DEVICE__
+ d_dbg_lvl=dbg_lvl;
+ params=&ifxusb_module_params_d;
+ #endif
+
+ switch(dma_burst_size)
+ {
+ case 0:
+ case 1:
+ case 4:
+ case 8:
+ case 16:
+ params->dma_burst_size=dma_burst_size;
+ break;
+ default:
+ #if defined(__IS_VR9__)
+ {
+ unsigned int chipid;
+ unsigned int partnum;
+ chipid=*((volatile uint32_t *)IFX_MPS_CHIPID);
+ partnum=(chipid&0x0FFFF000)>>12;
+ switch(partnum)
+ {
+ case 0x000B: //VRX288_A2x
+ case 0x000E: //VRX282_A2x
+ case 0x000C: //VRX268_A2x
+ case 0x000D: //GRX288_A2x
+ params->dma_burst_size=default_param_dma_burst_size_n;
+ break;
+ default:
+ params->dma_burst_size=default_param_dma_burst_size;
+ }
+ printk(KERN_INFO "Chip Version :%04x BurstSize=%d\n",partnum,params->dma_burst_size);
+ }
+ #else
+ params->dma_burst_size=default_param_dma_burst_size;
+ #endif
+ }
+
+ if(speed==0 || speed==1)
+ params->speed=speed;
+ else
+ params->speed=default_param_speed;
+
+ if(max_transfer_size>=2048 && max_transfer_size<=65535)
+ params->max_transfer_size=max_transfer_size;
+ else
+ params->max_transfer_size=default_param_max_transfer_size;
+
+ if(max_packet_count>=15 && max_packet_count<=511)
+ params->max_packet_count=max_packet_count;
+ else
+ params->max_packet_count=default_param_max_packet_count;
+
+ switch(phy_utmi_width)
+ {
+ case 8:
+ case 16:
+ params->phy_utmi_width=phy_utmi_width;
+ break;
+ default:
+ params->phy_utmi_width=default_param_phy_utmi_width;
+ }
+
+ if(turn_around_time_hs>=0 && turn_around_time_hs<=7)
+ params->turn_around_time_hs=turn_around_time_hs;
+ else
+ params->turn_around_time_hs=default_param_turn_around_time_hs;
+
+ if(turn_around_time_fs>=0 && turn_around_time_fs<=7)
+ params->turn_around_time_fs=turn_around_time_fs;
+ else
+ params->turn_around_time_fs=default_param_turn_around_time_fs;
+
+ if(timeout_cal_hs>=0 && timeout_cal_hs<=7)
+ params->timeout_cal_hs=timeout_cal_hs;
+ else
+ params->timeout_cal_hs=default_param_timeout_cal_hs;
+
+ if(timeout_cal_fs>=0 && timeout_cal_fs<=7)
+ params->timeout_cal_fs=timeout_cal_fs;
+ else
+ params->timeout_cal_fs=default_param_timeout_cal_fs;
+
+ if(data_fifo_size>=32 && data_fifo_size<=32768)
+ params->data_fifo_size=data_fifo_size;
+ else
+ params->data_fifo_size=default_param_data_fifo_size;
+
+ #ifdef __IS_HOST__
+ if(host_channels>=1 && host_channels<=16)
+ params->host_channels=host_channels;
+ else
+ params->host_channels=default_param_host_channels;
+
+ if(rx_fifo_size>=16 && rx_fifo_size<=32768)
+ params->rx_fifo_size=rx_fifo_size;
+ else
+ params->rx_fifo_size=default_param_rx_fifo_size;
+
+ if(nperio_tx_fifo_size>=16 && nperio_tx_fifo_size<=32768)
+ params->nperio_tx_fifo_size=nperio_tx_fifo_size;
+ else
+ params->nperio_tx_fifo_size=default_param_nperio_tx_fifo_size;
+
+ if(perio_tx_fifo_size>=16 && perio_tx_fifo_size<=32768)
+ params->perio_tx_fifo_size=perio_tx_fifo_size;
+ else
+ params->perio_tx_fifo_size=default_param_perio_tx_fifo_size;
+ #endif //__IS_HOST__
+
+ #ifdef __IS_DEVICE__
+ if(rx_fifo_size>=16 && rx_fifo_size<=32768)
+ params->rx_fifo_size=rx_fifo_size;
+ else
+ params->rx_fifo_size=default_param_rx_fifo_size;
+ #ifdef __DED_FIFO__
+ if(tx_fifo_size_00>=16 && tx_fifo_size_00<=32768)
+ params->tx_fifo_size[ 0]=tx_fifo_size_00;
+ else
+ params->tx_fifo_size[ 0]=default_param_tx_fifo_size_00;
+ if(tx_fifo_size_01>=0 && tx_fifo_size_01<=32768)
+ params->tx_fifo_size[ 1]=tx_fifo_size_01;
+ else
+ params->tx_fifo_size[ 1]=default_param_tx_fifo_size_01;
+ if(tx_fifo_size_02>=0 && tx_fifo_size_02<=32768)
+ params->tx_fifo_size[ 2]=tx_fifo_size_02;
+ else
+ params->tx_fifo_size[ 2]=default_param_tx_fifo_size_02;
+ if(tx_fifo_size_03>=0 && tx_fifo_size_03<=32768)
+ params->tx_fifo_size[ 3]=tx_fifo_size_03;
+ else
+ params->tx_fifo_size[ 3]=default_param_tx_fifo_size_03;
+ if(tx_fifo_size_04>=0 && tx_fifo_size_04<=32768)
+ params->tx_fifo_size[ 4]=tx_fifo_size_04;
+ else
+ params->tx_fifo_size[ 4]=default_param_tx_fifo_size_04;
+ if(tx_fifo_size_05>=0 && tx_fifo_size_05<=32768)
+ params->tx_fifo_size[ 5]=tx_fifo_size_05;
+ else
+ params->tx_fifo_size[ 5]=default_param_tx_fifo_size_05;
+ if(tx_fifo_size_06>=0 && tx_fifo_size_06<=32768)
+ params->tx_fifo_size[ 6]=tx_fifo_size_06;
+ else
+ params->tx_fifo_size[ 6]=default_param_tx_fifo_size_06;
+ if(tx_fifo_size_07>=0 && tx_fifo_size_07<=32768)
+ params->tx_fifo_size[ 7]=tx_fifo_size_07;
+ else
+ params->tx_fifo_size[ 7]=default_param_tx_fifo_size_07;
+ if(tx_fifo_size_08>=0 && tx_fifo_size_08<=32768)
+ params->tx_fifo_size[ 8]=tx_fifo_size_08;
+ else
+ params->tx_fifo_size[ 8]=default_param_tx_fifo_size_08;
+ if(tx_fifo_size_09>=0 && tx_fifo_size_09<=32768)
+ params->tx_fifo_size[ 9]=tx_fifo_size_09;
+ else
+ params->tx_fifo_size[ 9]=default_param_tx_fifo_size_09;
+ if(tx_fifo_size_10>=0 && tx_fifo_size_10<=32768)
+ params->tx_fifo_size[10]=tx_fifo_size_10;
+ else
+ params->tx_fifo_size[10]=default_param_tx_fifo_size_10;
+ if(tx_fifo_size_11>=0 && tx_fifo_size_11<=32768)
+ params->tx_fifo_size[11]=tx_fifo_size_11;
+ else
+ params->tx_fifo_size[11]=default_param_tx_fifo_size_11;
+ if(tx_fifo_size_12>=0 && tx_fifo_size_12<=32768)
+ params->tx_fifo_size[12]=tx_fifo_size_12;
+ else
+ params->tx_fifo_size[12]=default_param_tx_fifo_size_12;
+ if(tx_fifo_size_13>=0 && tx_fifo_size_13<=32768)
+ params->tx_fifo_size[13]=tx_fifo_size_13;
+ else
+ params->tx_fifo_size[13]=default_param_tx_fifo_size_13;
+ if(tx_fifo_size_14>=0 && tx_fifo_size_14<=32768)
+ params->tx_fifo_size[14]=tx_fifo_size_14;
+ else
+ params->tx_fifo_size[14]=default_param_tx_fifo_size_14;
+ if(tx_fifo_size_15>=0 && tx_fifo_size_15<=32768)
+ params->tx_fifo_size[15]=tx_fifo_size_15;
+ else
+ params->tx_fifo_size[15]=default_param_tx_fifo_size_15;
+ if(thr_ctl==0 || thr_ctl==1)
+ params->thr_ctl=thr_ctl;
+ else
+ params->thr_ctl=default_param_thr_ctl;
+ if(tx_thr_length>=16 && tx_thr_length<=511)
+ params->tx_thr_length=tx_thr_length;
+ else
+ params->tx_thr_length=default_param_tx_thr_length;
+ if(rx_thr_length>=16 && rx_thr_length<=511)
+ params->rx_thr_length=rx_thr_length;
+ else
+ params->rx_thr_length=default_param_rx_thr_length;
+ #else //__DED_FIFO__
+ if(nperio_tx_fifo_size>=16 && nperio_tx_fifo_size<=32768)
+ params->tx_fifo_size[ 0]=nperio_tx_fifo_size;
+ else
+ params->tx_fifo_size[ 0]=default_param_nperio_tx_fifo_size;
+ if(perio_tx_fifo_size_01>=0 && perio_tx_fifo_size_01<=32768)
+ params->tx_fifo_size[ 1]=perio_tx_fifo_size_01;
+ else
+ params->tx_fifo_size[ 1]=default_param_perio_tx_fifo_size_01;
+ if(perio_tx_fifo_size_02>=0 && perio_tx_fifo_size_02<=32768)
+ params->tx_fifo_size[ 2]=perio_tx_fifo_size_02;
+ else
+ params->tx_fifo_size[ 2]=default_param_perio_tx_fifo_size_02;
+ if(perio_tx_fifo_size_03>=0 && perio_tx_fifo_size_03<=32768)
+ params->tx_fifo_size[ 3]=perio_tx_fifo_size_03;
+ else
+ params->tx_fifo_size[ 3]=default_param_perio_tx_fifo_size_03;
+ if(perio_tx_fifo_size_04>=0 && perio_tx_fifo_size_04<=32768)
+ params->tx_fifo_size[ 4]=perio_tx_fifo_size_04;
+ else
+ params->tx_fifo_size[ 4]=default_param_perio_tx_fifo_size_04;
+ if(perio_tx_fifo_size_05>=0 && perio_tx_fifo_size_05<=32768)
+ params->tx_fifo_size[ 5]=perio_tx_fifo_size_05;
+ else
+ params->tx_fifo_size[ 5]=default_param_perio_tx_fifo_size_05;
+ if(perio_tx_fifo_size_06>=0 && perio_tx_fifo_size_06<=32768)
+ params->tx_fifo_size[ 6]=perio_tx_fifo_size_06;
+ else
+ params->tx_fifo_size[ 6]=default_param_perio_tx_fifo_size_06;
+ if(perio_tx_fifo_size_07>=0 && perio_tx_fifo_size_07<=32768)
+ params->tx_fifo_size[ 7]=perio_tx_fifo_size_07;
+ else
+ params->tx_fifo_size[ 7]=default_param_perio_tx_fifo_size_07;
+ if(perio_tx_fifo_size_08>=0 && perio_tx_fifo_size_08<=32768)
+ params->tx_fifo_size[ 8]=perio_tx_fifo_size_08;
+ else
+ params->tx_fifo_size[ 8]=default_param_perio_tx_fifo_size_08;
+ if(perio_tx_fifo_size_09>=0 && perio_tx_fifo_size_09<=32768)
+ params->tx_fifo_size[ 9]=perio_tx_fifo_size_09;
+ else
+ params->tx_fifo_size[ 9]=default_param_perio_tx_fifo_size_09;
+ if(perio_tx_fifo_size_10>=0 && perio_tx_fifo_size_10<=32768)
+ params->tx_fifo_size[10]=perio_tx_fifo_size_10;
+ else
+ params->tx_fifo_size[10]=default_param_perio_tx_fifo_size_10;
+ if(perio_tx_fifo_size_11>=0 && perio_tx_fifo_size_11<=32768)
+ params->tx_fifo_size[11]=perio_tx_fifo_size_11;
+ else
+ params->tx_fifo_size[11]=default_param_perio_tx_fifo_size_11;
+ if(perio_tx_fifo_size_12>=0 && perio_tx_fifo_size_12<=32768)
+ params->tx_fifo_size[12]=perio_tx_fifo_size_12;
+ else
+ params->tx_fifo_size[12]=default_param_perio_tx_fifo_size_12;
+ if(perio_tx_fifo_size_13>=0 && perio_tx_fifo_size_13<=32768)
+ params->tx_fifo_size[13]=perio_tx_fifo_size_13;
+ else
+ params->tx_fifo_size[13]=default_param_perio_tx_fifo_size_13;
+ if(perio_tx_fifo_size_14>=0 && perio_tx_fifo_size_14<=32768)
+ params->tx_fifo_size[14]=perio_tx_fifo_size_14;
+ else
+ params->tx_fifo_size[14]=default_param_perio_tx_fifo_size_14;
+ if(perio_tx_fifo_size_15>=0 && perio_tx_fifo_size_15<=32768)
+ params->tx_fifo_size[15]=perio_tx_fifo_size_15;
+ else
+ params->tx_fifo_size[15]=default_param_perio_tx_fifo_size_15;
+ #endif //__DED_FIFO__
+ #endif //__IS_DEVICE__
+}
+
+
+
+
+
+
+
+module_param(dbg_lvl, long, 0444);
+MODULE_PARM_DESC(dbg_lvl, "Debug level.");
+
+module_param(dma_burst_size, short, 0444);
+MODULE_PARM_DESC(dma_burst_size, "DMA Burst Size 0, 1, 4, 8, 16");
+
+module_param(speed, short, 0444);
+MODULE_PARM_DESC(speed, "Speed 0=High Speed 1=Full Speed");
+
+module_param(data_fifo_size, long, 0444);
+MODULE_PARM_DESC(data_fifo_size, "Total number of words in the data FIFO memory 32-32768");
+
+#ifdef __IS_DEVICE__
+ module_param(rx_fifo_size, long, 0444);
+ MODULE_PARM_DESC(rx_fifo_size, "Number of words in the Rx FIFO 16-32768");
+
+ #ifdef __DED_FIFO__
+ module_param(tx_fifo_size_00, long, 0444);
+ MODULE_PARM_DESC(tx_fifo_size_00, "Number of words in the Tx FIFO #00 16-32768");
+ module_param(tx_fifo_size_01, long, 0444);
+ MODULE_PARM_DESC(tx_fifo_size_01, "Number of words in the Tx FIFO #01 0-32768");
+ module_param(tx_fifo_size_02, long, 0444);
+ MODULE_PARM_DESC(tx_fifo_size_02, "Number of words in the Tx FIFO #02 0-32768");
+ module_param(tx_fifo_size_03, long, 0444);
+ MODULE_PARM_DESC(tx_fifo_size_03, "Number of words in the Tx FIFO #03 0-32768");
+ module_param(tx_fifo_size_04, long, 0444);
+ MODULE_PARM_DESC(tx_fifo_size_04, "Number of words in the Tx FIFO #04 0-32768");
+ module_param(tx_fifo_size_05, long, 0444);
+ MODULE_PARM_DESC(tx_fifo_size_05, "Number of words in the Tx FIFO #05 0-32768");
+ module_param(tx_fifo_size_06, long, 0444);
+ MODULE_PARM_DESC(tx_fifo_size_06, "Number of words in the Tx FIFO #06 0-32768");
+ module_param(tx_fifo_size_07, long, 0444);
+ MODULE_PARM_DESC(tx_fifo_size_07, "Number of words in the Tx FIFO #07 0-32768");
+ module_param(tx_fifo_size_08, long, 0444);
+ MODULE_PARM_DESC(tx_fifo_size_08, "Number of words in the Tx FIFO #08 0-32768");
+ module_param(tx_fifo_size_09, long, 0444);
+ MODULE_PARM_DESC(tx_fifo_size_09, "Number of words in the Tx FIFO #09 0-32768");
+ module_param(tx_fifo_size_10, long, 0444);
+ MODULE_PARM_DESC(tx_fifo_size_10, "Number of words in the Tx FIFO #10 0-32768");
+ module_param(tx_fifo_size_11, long, 0444);
+ MODULE_PARM_DESC(tx_fifo_size_11, "Number of words in the Tx FIFO #11 0-32768");
+ module_param(tx_fifo_size_12, long, 0444);
+ MODULE_PARM_DESC(tx_fifo_size_12, "Number of words in the Tx FIFO #12 0-32768");
+ module_param(tx_fifo_size_13, long, 0444);
+ MODULE_PARM_DESC(tx_fifo_size_13, "Number of words in the Tx FIFO #13 0-32768");
+ module_param(tx_fifo_size_14, long, 0444);
+ MODULE_PARM_DESC(tx_fifo_size_14, "Number of words in the Tx FIFO #14 0-32768");
+ module_param(tx_fifo_size_15, long, 0444);
+ MODULE_PARM_DESC(tx_fifo_size_15, "Number of words in the Tx FIFO #15 0-32768");
+
+ module_param(thr_ctl, short, 0444);
+ MODULE_PARM_DESC(thr_ctl, "0=Without 1=With Theshold Ctrl");
+
+ module_param(tx_thr_length, long, 0444);
+ MODULE_PARM_DESC(tx_thr_length, "TX Threshold length");
+
+ module_param(rx_thr_length, long, 0444);
+ MODULE_PARM_DESC(rx_thr_length, "RX Threshold length");
+
+ #else
+ module_param(nperio_tx_fifo_size, long, 0444);
+ MODULE_PARM_DESC(nperio_tx_fifo_size, "Number of words in the non-periodic Tx FIFO 16-32768");
+
+ module_param(perio_tx_fifo_size_01, long, 0444);
+ MODULE_PARM_DESC(perio_tx_fifo_size_01, "Number of words in the periodic Tx FIFO #01 0-32768");
+ module_param(perio_tx_fifo_size_02, long, 0444);
+ MODULE_PARM_DESC(perio_tx_fifo_size_02, "Number of words in the periodic Tx FIFO #02 0-32768");
+ module_param(perio_tx_fifo_size_03, long, 0444);
+ MODULE_PARM_DESC(perio_tx_fifo_size_03, "Number of words in the periodic Tx FIFO #03 0-32768");
+ module_param(perio_tx_fifo_size_04, long, 0444);
+ MODULE_PARM_DESC(perio_tx_fifo_size_04, "Number of words in the periodic Tx FIFO #04 0-32768");
+ module_param(perio_tx_fifo_size_05, long, 0444);
+ MODULE_PARM_DESC(perio_tx_fifo_size_05, "Number of words in the periodic Tx FIFO #05 0-32768");
+ module_param(perio_tx_fifo_size_06, long, 0444);
+ MODULE_PARM_DESC(perio_tx_fifo_size_06, "Number of words in the periodic Tx FIFO #06 0-32768");
+ module_param(perio_tx_fifo_size_07, long, 0444);
+ MODULE_PARM_DESC(perio_tx_fifo_size_07, "Number of words in the periodic Tx FIFO #07 0-32768");
+ module_param(perio_tx_fifo_size_08, long, 0444);
+ MODULE_PARM_DESC(perio_tx_fifo_size_08, "Number of words in the periodic Tx FIFO #08 0-32768");
+ module_param(perio_tx_fifo_size_09, long, 0444);
+ MODULE_PARM_DESC(perio_tx_fifo_size_09, "Number of words in the periodic Tx FIFO #09 0-32768");
+ module_param(perio_tx_fifo_size_10, long, 0444);
+ MODULE_PARM_DESC(perio_tx_fifo_size_10, "Number of words in the periodic Tx FIFO #10 0-32768");
+ module_param(perio_tx_fifo_size_11, long, 0444);
+ MODULE_PARM_DESC(perio_tx_fifo_size_11, "Number of words in the periodic Tx FIFO #11 0-32768");
+ module_param(perio_tx_fifo_size_12, long, 0444);
+ MODULE_PARM_DESC(perio_tx_fifo_size_12, "Number of words in the periodic Tx FIFO #12 0-32768");
+ module_param(perio_tx_fifo_size_13, long, 0444);
+ MODULE_PARM_DESC(perio_tx_fifo_size_13, "Number of words in the periodic Tx FIFO #13 0-32768");
+ module_param(perio_tx_fifo_size_14, long, 0444);
+ MODULE_PARM_DESC(perio_tx_fifo_size_14, "Number of words in the periodic Tx FIFO #14 0-32768");
+ module_param(perio_tx_fifo_size_15, long, 0444);
+ MODULE_PARM_DESC(perio_tx_fifo_size_15, "Number of words in the periodic Tx FIFO #15 0-32768");
+ #endif//__DED_FIFO__
+ module_param(dev_endpoints, short, 0444);
+ MODULE_PARM_DESC(dev_endpoints, "The number of endpoints in addition to EP0 available for device mode 1-15");
+#endif
+
+#ifdef __IS_HOST__
+ module_param(rx_fifo_size, long, 0444);
+ MODULE_PARM_DESC(rx_fifo_size, "Number of words in the Rx FIFO 16-32768");
+
+ module_param(nperio_tx_fifo_size, long, 0444);
+ MODULE_PARM_DESC(nperio_tx_fifo_size, "Number of words in the non-periodic Tx FIFO 16-32768");
+
+ module_param(perio_tx_fifo_size, long, 0444);
+ MODULE_PARM_DESC(perio_tx_fifo_size, "Number of words in the host periodic Tx FIFO 16-32768");
+
+ module_param(host_channels, short, 0444);
+ MODULE_PARM_DESC(host_channels, "The number of host channel registers to use 1-16");
+#endif
+
+module_param(max_transfer_size, long, 0444);
+MODULE_PARM_DESC(max_transfer_size, "The maximum transfer size supported in bytes 2047-65535");
+
+module_param(max_packet_count, long, 0444);
+MODULE_PARM_DESC(max_packet_count, "The maximum number of packets in a transfer 15-511");
+
+module_param(phy_utmi_width, long, 0444);
+MODULE_PARM_DESC(phy_utmi_width, "Specifies the UTMI+ Data Width 8 or 16 bits");
+
+module_param(turn_around_time_hs, long, 0444);
+MODULE_PARM_DESC(turn_around_time_hs, "Turn-Around time for HS");
+
+module_param(turn_around_time_fs, long, 0444);
+MODULE_PARM_DESC(turn_around_time_fs, "Turn-Around time for FS");
+
+module_param(timeout_cal_hs, long, 0444);
+MODULE_PARM_DESC(timeout_cal_hs, "Timeout Cal for HS");
+
+module_param(timeout_cal_fs, long, 0444);
+MODULE_PARM_DESC(timeout_cal_fs, "Timeout Cal for FS");
+
diff --git a/package/platform/lantiq/ltq-hcd/src/ifxusb_host.ko b/package/platform/lantiq/ltq-hcd/src/ifxusb_host.ko
new file mode 100644
index 0000000..1dd25ca
--- /dev/null
+++ b/package/platform/lantiq/ltq-hcd/src/ifxusb_host.ko
Binary files differ
diff --git a/package/platform/lantiq/ltq-hcd/src/ifxusb_plat.h b/package/platform/lantiq/ltq-hcd/src/ifxusb_plat.h
new file mode 100644
index 0000000..df959cf
--- /dev/null
+++ b/package/platform/lantiq/ltq-hcd/src/ifxusb_plat.h
@@ -0,0 +1,1184 @@
+/*****************************************************************************
+ ** FILE NAME : ifxusb_plat.h
+ ** PROJECT : IFX USB sub-system V3
+ ** MODULES : IFX USB sub-system Host and Device driver
+ ** SRC VERSION : 3.2
+ ** DATE : 1/Jan/2011
+ ** AUTHOR : Chen, Howard
+ ** DESCRIPTION : This file contains the Platform Specific constants, interfaces
+ ** (functions and macros).
+ ** FUNCTIONS :
+ ** COMPILER : gcc
+ ** REFERENCE : Synopsys DWC-OTG Driver 2.7
+ ** COPYRIGHT : Copyright (c) 2010
+ ** LANTIQ DEUTSCHLAND GMBH,
+ ** Am Campeon 3, 85579 Neubiberg, Germany
+ **
+ ** 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 of the License, or
+ ** (at your option) any later version.
+ **
+ ** Version Control Section **
+ ** $Author$
+ ** $Date$
+ ** $Revisions$
+ ** $Log$ Revision history
+ *****************************************************************************/
+
+/*
+ * This file contains code fragments from Synopsys HS OTG Linux Software Driver.
+ * For this code the following notice is applicable:
+ *
+ * ==========================================================================
+ *
+ * Synopsys HS OTG Linux Software Driver and documentation (hereinafter,
+ * "Software") is an Unsupported proprietary work of Synopsys, Inc. unless
+ * otherwise expressly agreed to in writing between Synopsys and you.
+ *
+ * The Software IS NOT an item of Licensed Software or Licensed Product under
+ * any End User Software License Agreement or Agreement for Licensed Product
+ * with Synopsys or any supplement thereto. You are permitted to use and
+ * redistribute this Software in source and binary forms, with or without
+ * modification, provided that redistributions of source code must retain this
+ * notice. You may not view, use, disclose, copy or distribute this file or
+ * any information contained herein except pursuant to this license grant from
+ * Synopsys. If you do not agree with this notice, including the disclaimer
+ * below, then you are not authorized to use the Software.
+ *
+ * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" BASIS
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ * ========================================================================== */
+
+
+/*!
+ \defgroup IFXUSB_PLATEFORM_DEFINITION Platform Specific constants, interfaces (functions and macros).
+ \ingroup IFXUSB_DRIVER_V3
+ \brief Maintain plateform specific definitions and macros in this file.
+ Each plateform has its own definition zone.
+ */
+
+/*!
+ \defgroup IFXUSB_PLATEFORM_MEM_ADDR Definition of memory address and size and default parameters
+ \ingroup IFXUSB_PLATEFORM_DEFINITION
+ */
+
+/*!
+ \defgroup IFXUSB_DBG_ROUTINE Routines for debug message
+ \ingroup IFXUSB_PLATEFORM_DEFINITION
+ */
+
+
+/*! \file ifxusb_plat.h
+ \ingroup IFXUSB_DRIVER_V3
+ \brief This file contains the Platform Specific constants, interfaces (functions and macros).
+*/
+
+#if !defined(__IFXUSB_PLAT_H__)
+#define __IFXUSB_PLAT_H__
+
+
+#include <linux/types.h>
+#include <linux/slab.h>
+#include <linux/list.h>
+#include <linux/delay.h>
+#include <asm/io.h>
+
+
+#define IFXUSB_IOMEM_SIZE 0x00001000
+#define IFXUSB_FIFOMEM_SIZE 0x00010000
+#define IFXUSB_FIFODBG_SIZE 0x00020000
+
+
+
+/*!
+ \addtogroup IFXUSB_PLATEFORM_MEM_ADDR
+ */
+/*@{*/
+#if defined(__UEIP__)
+ #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ #define IFXUSB_IRQ 62
+ #define IFXUSB_IOMEM_BASE 0x1e101000
+ #define IFXUSB_FIFOMEM_BASE 0x1e120000
+ #define IFXUSB_FIFODBG_BASE 0x1e140000
+ #define IFXUSB_OC_IRQ 159
+
+ #ifndef DANUBE_RCU_BASE_ADDR
+ #define DANUBE_RCU_BASE_ADDR (0xBF203000)
+ #endif
+
+ #ifndef DANUBE_CGU
+ #define DANUBE_CGU (0xBF103000)
+ #endif
+ #ifndef DANUBE_CGU_IFCCR
+ #define DANUBE_CGU_IFCCR ((volatile unsigned long *)(DANUBE_CGU+ 0x0018))
+ #endif
+ #ifndef DANUBE_PMU
+ #define DANUBE_PMU (KSEG1+0x1F102000)
+ #endif
+ #ifndef DANUBE_PMU_PWDCR
+ #define DANUBE_PMU_PWDCR ((volatile unsigned long *)(DANUBE_PMU+0x001C))
+ #endif
+
+ #ifndef DANUBE_GPIO_P0_OUT
+ #define DANUBE_GPIO_P0_OUT (0xBF103000+0x10)
+ #define DANUBE_GPIO_P0_DIR (0xBF103000+0x18)
+ #define DANUBE_GPIO_P0_ALTSEL0 (0xBF103000+0x1C)
+ #define DANUBE_GPIO_P0_ALTSEL1 (0xBF103000+0x20)
+ #define DANUBE_GPIO_P0_OD (0xBF103000+0x24)
+ #define DANUBE_GPIO_P0_PUDSEL (0xBF103000+0x2C)
+ #define DANUBE_GPIO_P0_PUDEN (0xBF103000+0x30)
+ #define DANUBE_GPIO_P1_OUT (0xBF103000+0x40)
+ #define DANUBE_GPIO_P1_DIR (0xBF103000+0x48)
+ #define DANUBE_GPIO_P1_ALTSEL0 (0xBF103000+0x4C)
+ #define DANUBE_GPIO_P1_ALTSEL1 (0xBF103000+0x50)
+ #define DANUBE_GPIO_P1_OD (0xBF103000+0x54)
+ #define DANUBE_GPIO_P1_PUDSEL (0xBF103000+0x5C)
+ #define DANUBE_GPIO_P1_PUDEN (0xBF103000+0x60)
+ #endif
+
+ #define DANUBE_RCU_USBCFG ((volatile unsigned long *)(DANUBE_RCU_BASE_ADDR + 0x18))
+ #define DANUBE_RCU_RESET ((volatile unsigned long *)(DANUBE_RCU_BASE_ADDR + 0x10))
+ #define DANUBE_USBCFG_HDSEL_BIT 11 // 0:host, 1:device
+ #define DANUBE_USBCFG_HOST_END_BIT 10 // 0:little_end, 1:big_end
+ #define DANUBE_USBCFG_SLV_END_BIT 9 // 0:little_end, 1:big_end
+
+ #define default_param_dma_burst_size 4
+
+ #define default_param_speed IFXUSB_PARAM_SPEED_HIGH
+
+ #define default_param_max_transfer_size -1 //(Max, hwcfg)
+ #define default_param_max_packet_count -1 //(Max, hwcfg)
+ #define default_param_phy_utmi_width 16
+
+ #define default_param_turn_around_time_hs 4
+ #define default_param_turn_around_time_fs 4
+ #define default_param_timeout_cal_hs -1 //(NoChange)
+ #define default_param_timeout_cal_fs -1 //(NoChange)
+
+ #define default_param_data_fifo_size -1 //(Max, hwcfg)
+
+ #ifdef __IS_HOST__
+ #define default_param_host_channels -1 //(Max, hwcfg)
+ #define default_param_rx_fifo_size 640
+ #define default_param_nperio_tx_fifo_size 640
+ #define default_param_perio_tx_fifo_size 768
+ #endif //__IS_HOST__
+
+ #ifdef __IS_DEVICE__
+ #ifdef __DED_INTR__
+// #define default_param_rx_fifo_size 1024
+// #define default_param_nperio_tx_fifo_size 1016
+// #define default_param_perio_tx_fifo_size_01 8
+ #define default_param_rx_fifo_size 1008
+ #define default_param_nperio_tx_fifo_size 1008
+ #define default_param_perio_tx_fifo_size_01 32
+ #else
+ #define default_param_rx_fifo_size 1024
+ #define default_param_nperio_tx_fifo_size 1024
+ #define default_param_perio_tx_fifo_size_01 0
+ #endif
+ #define default_param_perio_tx_fifo_size_02 0
+ #define default_param_perio_tx_fifo_size_03 0
+ #define default_param_perio_tx_fifo_size_04 0
+ #define default_param_perio_tx_fifo_size_05 0
+ #define default_param_perio_tx_fifo_size_06 0
+ #define default_param_perio_tx_fifo_size_07 0
+ #define default_param_perio_tx_fifo_size_08 0
+ #define default_param_perio_tx_fifo_size_09 0
+ #define default_param_perio_tx_fifo_size_10 0
+ #define default_param_perio_tx_fifo_size_11 0
+ #define default_param_perio_tx_fifo_size_12 0
+ #define default_param_perio_tx_fifo_size_13 0
+ #define default_param_perio_tx_fifo_size_14 0
+ #define default_param_perio_tx_fifo_size_15 0
+ #endif //__IS_DEVICE__
+
+ #elif defined(__IS_AMAZON_SE__)
+ //#include <asm/amazon_se/amazon_se.h>
+ //#include <asm/amazon_se/irq.h>
+
+ #define IFXUSB_IRQ 39
+ #define IFXUSB_IOMEM_BASE 0x1e101000
+ #define IFXUSB_FIFOMEM_BASE 0x1e120000
+ #define IFXUSB_FIFODBG_BASE 0x1e140000
+ #define IFXUSB_OC_IRQ 20
+
+ #ifndef AMAZON_SE_RCU_BASE_ADDR
+ #define AMAZON_SE_RCU_BASE_ADDR (0xBF203000)
+ #endif
+ #define AMAZON_SE_RCU_USBCFG ((volatile unsigned long *)(AMAZON_SE_RCU_BASE_ADDR + 0x18))
+ #define AMAZON_SE_RCU_RESET ((volatile unsigned long *)(AMAZON_SE_RCU_BASE_ADDR + 0x10))
+ #define AMAZON_SE_USBCFG_HDSEL_BIT 11 // 0:host, 1:device
+ #define AMAZON_SE_USBCFG_HOST_END_BIT 10 // 0:little_end, 1:big_end
+ #define AMAZON_SE_USBCFG_SLV_END_BIT 9 // 0:little_end, 1:big_end
+
+ #ifndef AMAZON_SE_GPIO_P0_OUT
+ #define AMAZON_SE_GPIO_P0_OUT (0xBF103000+0x10)
+ #define AMAZON_SE_GPIO_P0_DIR (0xBF103000+0x18)
+ #define AMAZON_SE_GPIO_P0_ALTSEL0 (0xBF103000+0x1C)
+ #define AMAZON_SE_GPIO_P0_ALTSEL1 (0xBF103000+0x20)
+ #define AMAZON_SE_GPIO_P0_OD (0xBF103000+0x24)
+ #define AMAZON_SE_GPIO_P0_PUDSEL (0xBF103000+0x2C)
+ #define AMAZON_SE_GPIO_P0_PUDEN (0xBF103000+0x30)
+ #define AMAZON_SE_GPIO_P1_OUT (0xBF103000+0x40)
+ #define AMAZON_SE_GPIO_P1_DIR (0xBF103000+0x48)
+ #define AMAZON_SE_GPIO_P1_ALTSEL0 (0xBF103000+0x4C)
+ #define AMAZON_SE_GPIO_P1_ALTSEL1 (0xBF103000+0x50)
+ #define AMAZON_SE_GPIO_P1_OD (0xBF103000+0x54)
+ #define AMAZON_SE_GPIO_P1_PUDSEL (0xBF103000+0x5C)
+ #define AMAZON_SE_GPIO_P1_PUDEN (0xBF103000+0x60)
+ #endif
+
+ #ifndef AMAZON_SE_CGU
+ #define AMAZON_SE_CGU (0xBF103000)
+ #endif
+ #ifndef AMAZON_SE_CGU_IFCCR
+ #define AMAZON_SE_CGU_IFCCR ((volatile unsigned long *)(AMAZON_SE_CGU+ 0x0018))
+ #endif
+ #ifndef AMAZON_SE_PMU
+ #define AMAZON_SE_PMU (KSEG1+0x1F102000)
+ #endif
+ #ifndef AMAZON_SE_PMU_PWDCR
+ #define AMAZON_SE_PMU_PWDCR ((volatile unsigned long *)(AMAZON_SE_PMU+0x001C))
+ #endif
+
+ #define default_param_dma_burst_size 4
+
+ #define default_param_speed IFXUSB_PARAM_SPEED_HIGH
+
+ #define default_param_max_transfer_size -1 //(Max, hwcfg)
+ #define default_param_max_packet_count -1 //(Max, hwcfg)
+ #define default_param_phy_utmi_width 16
+
+ #define default_param_turn_around_time_hs 4 //(NoChange)
+ #define default_param_turn_around_time_fs 4 //(NoChange)
+ #define default_param_timeout_cal_hs -1 //(NoChange)
+ #define default_param_timeout_cal_fs -1 //(NoChange)
+
+ #define default_param_data_fifo_size -1 //(Max, hwcfg)
+
+ #ifdef __IS_HOST__
+ #define default_param_host_channels -1 //(Max, hwcfg)
+ #define default_param_rx_fifo_size 240
+ #define default_param_nperio_tx_fifo_size 240
+ #define default_param_perio_tx_fifo_size 32
+ #endif //__IS_HOST__
+ #ifdef __IS_DEVICE__
+ #ifdef __DED_INTR__
+// #define default_param_rx_fifo_size 256
+// #define default_param_nperio_tx_fifo_size 248
+// #define default_param_perio_tx_fifo_size_01 8
+ #define default_param_rx_fifo_size 240
+ #define default_param_nperio_tx_fifo_size 240
+ #define default_param_perio_tx_fifo_size_01 32
+ #else
+ #define default_param_rx_fifo_size 256
+ #define default_param_nperio_tx_fifo_size 256
+ #define default_param_perio_tx_fifo_size_01 0
+ #endif
+ #define default_param_perio_tx_fifo_size_02 0
+ #define default_param_perio_tx_fifo_size_03 0
+ #define default_param_perio_tx_fifo_size_04 0
+ #define default_param_perio_tx_fifo_size_05 0
+ #define default_param_perio_tx_fifo_size_06 0
+ #define default_param_perio_tx_fifo_size_07 0
+ #define default_param_perio_tx_fifo_size_08 0
+ #define default_param_perio_tx_fifo_size_09 0
+ #define default_param_perio_tx_fifo_size_10 0
+ #define default_param_perio_tx_fifo_size_11 0
+ #define default_param_perio_tx_fifo_size_12 0
+ #define default_param_perio_tx_fifo_size_13 0
+ #define default_param_perio_tx_fifo_size_14 0
+ #define default_param_perio_tx_fifo_size_15 0
+ #endif //__IS_DEVICE__
+
+ #elif defined(__IS_AR9__)
+ #define IFXUSB1_IRQ 62
+ #define IFXUSB1_IOMEM_BASE 0x1E101000
+ #define IFXUSB1_FIFOMEM_BASE 0x1E120000
+ #define IFXUSB1_FIFODBG_BASE 0x1E140000
+
+ #define IFXUSB2_IRQ 91
+ #define IFXUSB2_IOMEM_BASE 0x1E106000
+ #define IFXUSB2_FIFOMEM_BASE 0x1E1E0000
+ #define IFXUSB2_FIFODBG_BASE 0x1E1C0000
+
+ #define IFXUSB_OC_IRQ 68
+
+ #ifndef AR9_RCU_BASE_ADDR
+ #define AR9_RCU_BASE_ADDR (0xBF203000)
+ #endif
+
+ #ifndef AR9_CGU
+ #define AR9_CGU (0xBF103000)
+ #endif
+ #ifndef AR9_CGU_IFCCR
+ #define AR9_CGU_IFCCR ((volatile unsigned long *)(AR9_CGU+ 0x0018))
+ #endif
+
+ #ifndef AR9_PMU
+ #define AR9_PMU (KSEG1+0x1F102000)
+ #endif
+ #ifndef AR9_PMU_PWDCR
+ #define AR9_PMU_PWDCR ((volatile unsigned long *)(AR9_PMU+0x001C))
+ #endif
+
+ #ifndef AR9_GPIO_P0_OUT
+ #define AR9_GPIO_P0_OUT (0xBF103000+0x10)
+ #define AR9_GPIO_P0_DIR (0xBF103000+0x18)
+ #define AR9_GPIO_P0_ALTSEL0 (0xBF103000+0x1C)
+ #define AR9_GPIO_P0_ALTSEL1 (0xBF103000+0x20)
+ #define AR9_GPIO_P0_OD (0xBF103000+0x24)
+ #define AR9_GPIO_P0_PUDSEL (0xBF103000+0x2C)
+ #define AR9_GPIO_P0_PUDEN (0xBF103000+0x30)
+ #define AR9_GPIO_P1_OUT (0xBF103000+0x40)
+ #define AR9_GPIO_P1_DIR (0xBF103000+0x48)
+ #define AR9_GPIO_P1_ALTSEL0 (0xBF103000+0x4C)
+ #define AR9_GPIO_P1_ALTSEL1 (0xBF103000+0x50)
+ #define AR9_GPIO_P1_OD (0xBF103000+0x54)
+ #define AR9_GPIO_P1_PUDSEL (0xBF103000+0x5C)
+ #define AR9_GPIO_P1_PUDEN (0xBF103000+0x60)
+ #endif
+
+ #define AR9_RCU_USB1CFG ((volatile unsigned long *)(AR9_RCU_BASE_ADDR + 0x18))
+ #define AR9_RCU_USB2CFG ((volatile unsigned long *)(AR9_RCU_BASE_ADDR + 0x34))
+ #define AR9_RCU_USBRESET ((volatile unsigned long *)(AR9_RCU_BASE_ADDR + 0x10))
+ #define AR9_USBCFG_ARB 7 //
+ #define AR9_USBCFG_HDSEL_BIT 11 // 0:host, 1:device
+ #define AR9_USBCFG_HOST_END_BIT 10 // 0:little_end, 1:big_end
+ #define AR9_USBCFG_SLV_END_BIT 17 // 0:little_end, 1:big_end
+
+ #define default_param_dma_burst_size 4
+
+ #define default_param_speed IFXUSB_PARAM_SPEED_HIGH
+
+ #define default_param_max_transfer_size -1 //(Max, hwcfg)
+ #define default_param_max_packet_count -1 //(Max, hwcfg)
+ #define default_param_phy_utmi_width 16
+
+ #define default_param_turn_around_time_hs 4 //(NoChange)
+ #define default_param_turn_around_time_fs 4 //(NoChange)
+ #define default_param_timeout_cal_hs -1 //(NoChange)
+ #define default_param_timeout_cal_fs -1 //(NoChange)
+
+ #define default_param_data_fifo_size -1 //(Max, hwcfg)
+
+ #ifdef __IS_HOST__
+ #define default_param_host_channels -1 //(Max, hwcfg)
+ #define default_param_rx_fifo_size 240
+ #define default_param_nperio_tx_fifo_size 240
+ #define default_param_perio_tx_fifo_size 32
+ #endif //__IS_HOST__
+ #ifdef __IS_DEVICE__
+ #ifdef __DED_INTR__
+// #define default_param_rx_fifo_size 256
+// #define default_param_nperio_tx_fifo_size 248
+// #define default_param_perio_tx_fifo_size_01 8
+ #define default_param_rx_fifo_size 240
+ #define default_param_nperio_tx_fifo_size 240
+ #define default_param_perio_tx_fifo_size_01 32
+ #else
+ #define default_param_rx_fifo_size 256
+ #define default_param_nperio_tx_fifo_size 256
+ #define default_param_perio_tx_fifo_size_01 0
+ #endif
+ #define default_param_perio_tx_fifo_size_02 0
+ #define default_param_perio_tx_fifo_size_03 0
+ #define default_param_perio_tx_fifo_size_04 0
+ #define default_param_perio_tx_fifo_size_05 0
+ #define default_param_perio_tx_fifo_size_06 0
+ #define default_param_perio_tx_fifo_size_07 0
+ #define default_param_perio_tx_fifo_size_08 0
+ #define default_param_perio_tx_fifo_size_09 0
+ #define default_param_perio_tx_fifo_size_10 0
+ #define default_param_perio_tx_fifo_size_11 0
+ #define default_param_perio_tx_fifo_size_12 0
+ #define default_param_perio_tx_fifo_size_13 0
+ #define default_param_perio_tx_fifo_size_14 0
+ #define default_param_perio_tx_fifo_size_15 0
+ #endif //__IS_DEVICE__
+
+ #elif defined(__IS_VR9__)
+ #define IFXUSB1_IRQ 62
+ #define IFXUSB1_IOMEM_BASE 0x1E101000
+ #define IFXUSB1_FIFOMEM_BASE 0x1E120000
+ #define IFXUSB1_FIFODBG_BASE 0x1E140000
+
+ #define IFXUSB2_IRQ 91
+ #define IFXUSB2_IOMEM_BASE 0x1E106000
+ #define IFXUSB2_FIFOMEM_BASE 0x1E1E0000
+ #define IFXUSB2_FIFODBG_BASE 0x1E1C0000
+ #define IFXUSB_OC_IRQ 60
+
+ #ifndef IFX_MPS
+ #define IFX_MPS (KSEG1+0x1F107000)
+ #endif
+ #ifndef IFX_MPS_CHIPID
+ #define IFX_MPS_CHIPID ((volatile unsigned long *)(IFX_MPS + 0x0344))
+ #endif
+
+ #ifndef VR9_RCU_BASE_ADDR
+ #define VR9_RCU_BASE_ADDR (0xBF203000)
+ #endif
+
+ #ifndef VR9_CGU
+ #define VR9_CGU (0xBF103000)
+ #endif
+ #ifndef VR9_CGU_IFCCR
+ #define VR9_CGU_IFCCR ((volatile unsigned long *)(VR9_CGU+ 0x0018))
+ #endif
+
+ #ifndef VR9_PMU
+ #define VR9_PMU (KSEG1+0x1F102000)
+ #endif
+ #ifndef VR9_PMU_PWDCR
+ #define VR9_PMU_PWDCR ((volatile unsigned long *)(VR9_PMU+0x001C))
+ #endif
+
+ #ifndef VR9_GPIO_P0_OUT
+ #define VR9_GPIO_P0_OUT (0xBF103000+0x10)
+ #define VR9_GPIO_P0_DIR (0xBF103000+0x18)
+ #define VR9_GPIO_P0_ALTSEL0 (0xBF103000+0x1C)
+ #define VR9_GPIO_P0_ALTSEL1 (0xBF103000+0x20)
+ #define VR9_GPIO_P0_OD (0xBF103000+0x24)
+ #define VR9_GPIO_P0_PUDSEL (0xBF103000+0x2C)
+ #define VR9_GPIO_P0_PUDEN (0xBF103000+0x30)
+ #define VR9_GPIO_P1_OUT (0xBF103000+0x40)
+ #define VR9_GPIO_P1_DIR (0xBF103000+0x48)
+ #define VR9_GPIO_P1_ALTSEL0 (0xBF103000+0x4C)
+ #define VR9_GPIO_P1_ALTSEL1 (0xBF103000+0x50)
+ #define VR9_GPIO_P1_OD (0xBF103000+0x54)
+ #define VR9_GPIO_P1_PUDSEL (0xBF103000+0x5C)
+ #define VR9_GPIO_P1_PUDEN (0xBF103000+0x60)
+ #endif
+
+ #define VR9_RCU_USB1CFG ((volatile unsigned long *)(VR9_RCU_BASE_ADDR + 0x18))
+ #define VR9_RCU_USB2CFG ((volatile unsigned long *)(VR9_RCU_BASE_ADDR + 0x34))
+ #define VR9_RCU_USB_ANA_CFG1A ((volatile unsigned long *)(VR9_RCU_BASE_ADDR + 0x38))
+ #define VR9_RCU_USB_ANA_CFG1B ((volatile unsigned long *)(VR9_RCU_BASE_ADDR + 0x3C))
+ #define VR9_RCU_USBRESET ((volatile unsigned long *)(VR9_RCU_BASE_ADDR + 0x10))
+ #define VR9_RCU_USBRESET2 ((volatile unsigned long *)(VR9_RCU_BASE_ADDR + 0x48))
+ #define VR9_USBCFG_ARB 7 //
+ #define VR9_USBCFG_HDSEL_BIT 11 // 0:host, 1:device
+ #define VR9_USBCFG_HOST_END_BIT 10 // 0:little_end, 1:big_end
+ #define VR9_USBCFG_SLV_END_BIT 9 // 0:little_end, 1:big_end
+
+// #define default_param_dma_burst_size 4 //(ALL)
+ //WA for AHB
+ #define default_param_dma_burst_size 0 //(ALL)
+ #define default_param_dma_burst_size_n 4 //(ALL)
+
+ #define default_param_speed IFXUSB_PARAM_SPEED_HIGH
+
+ #define default_param_max_transfer_size -1 //(Max, hwcfg)
+ #define default_param_max_packet_count -1 //(Max, hwcfg)
+ #define default_param_phy_utmi_width 16
+
+ #define default_param_turn_around_time_hs 6 //(NoChange) snpsid >= 0x4f54260a
+ #define default_param_turn_around_time_fs 6 //(NoChange) snpsid >= 0x4f54260a
+ #define default_param_timeout_cal_hs -1 //(NoChange)
+ #define default_param_timeout_cal_fs -1 //(NoChange)
+
+ #define default_param_data_fifo_size -1 //(Max, hwcfg)
+
+ #ifdef __IS_HOST__
+ #define default_param_host_channels -1 //(Max, hwcfg)
+ #define default_param_rx_fifo_size 240
+ #define default_param_nperio_tx_fifo_size 240
+ #define default_param_perio_tx_fifo_size 32
+ #endif //__IS_HOST__
+ #ifdef __IS_DEVICE__
+#if 0
+ #define default_param_rx_fifo_size 256
+ #define default_param_tx_fifo_size_00 -1
+ #define default_param_tx_fifo_size_01 -1
+ #define default_param_tx_fifo_size_02 -1
+#else
+ #define default_param_rx_fifo_size 256
+ #define default_param_tx_fifo_size_00 32
+ #define default_param_tx_fifo_size_01 200
+ #define default_param_tx_fifo_size_02 8
+#endif
+ #define default_param_tx_fifo_size_03 -1
+ #define default_param_tx_fifo_size_04 -1
+ #define default_param_tx_fifo_size_05 -1
+ #define default_param_tx_fifo_size_06 -1
+ #define default_param_tx_fifo_size_07 -1
+ #define default_param_tx_fifo_size_08 -1
+ #define default_param_tx_fifo_size_09 -1
+ #define default_param_tx_fifo_size_10 -1
+ #define default_param_tx_fifo_size_11 -1
+ #define default_param_tx_fifo_size_12 -1
+ #define default_param_tx_fifo_size_13 -1
+ #define default_param_tx_fifo_size_14 -1
+ #define default_param_tx_fifo_size_15 -1
+ #define default_param_dma_unalgned_tx -1
+ #define default_param_dma_unalgned_rx -1
+ #define default_param_thr_ctl -1
+ #define default_param_tx_thr_length -1
+ #define default_param_rx_thr_length -1
+ #endif //__IS_DEVICE__
+
+ #elif defined(__IS_AR10__)
+ #define IFXUSB1_IRQ 54
+ #define IFXUSB1_IOMEM_BASE 0x1E101000
+ #define IFXUSB1_FIFOMEM_BASE 0x1E120000
+ #define IFXUSB1_FIFODBG_BASE 0x1E140000
+ #define IFXUSB1_OC_IRQ 60
+
+ #define IFXUSB2_IRQ 83
+ #define IFXUSB2_IOMEM_BASE 0x1E106000
+ #define IFXUSB2_FIFOMEM_BASE 0x1E1E0000
+ #define IFXUSB2_FIFODBG_BASE 0x1E1C0000
+ #define IFXUSB2_OC_IRQ 56
+
+ #ifndef AR10_RCU_BASE_ADDR
+ #define AR10_RCU_BASE_ADDR (0xBF203000)
+ #endif
+ #ifndef AR10_CGU
+ #define AR10_CGU (0xBF103000)
+ #endif
+
+ #ifndef AR10_CGU_IFCCR
+ #define AR10_CGU_IFCCR ((volatile unsigned long *)(AR10_CGU+ 0x0018))
+ #endif
+ #ifndef AR10_PMU
+ #define AR10_PMU (KSEG1+0x1F102000)
+ #endif
+ #ifndef AR10_PMU_PWDCR
+ #define AR10_PMU_PWDCR ((volatile unsigned long *)(AR10_PMU+0x0044))
+ #endif
+
+ #ifndef AR10_GPIO_P0_OUT
+ #define AR10_GPIO_P0_OUT (0xBF103000+0x10)
+ #define AR10_GPIO_P0_DIR (0xBF103000+0x18)
+ #define AR10_GPIO_P0_ALTSEL0 (0xBF103000+0x1C)
+ #define AR10_GPIO_P0_ALTSEL1 (0xBF103000+0x20)
+ #define AR10_GPIO_P0_OD (0xBF103000+0x24)
+ #define AR10_GPIO_P0_PUDSEL (0xBF103000+0x2C)
+ #define AR10_GPIO_P0_PUDEN (0xBF103000+0x30)
+ #define AR10_GPIO_P1_OUT (0xBF103000+0x40)
+ #define AR10_GPIO_P1_DIR (0xBF103000+0x48)
+ #define AR10_GPIO_P1_ALTSEL0 (0xBF103000+0x4C)
+ #define AR10_GPIO_P1_ALTSEL1 (0xBF103000+0x50)
+ #define AR10_GPIO_P1_OD (0xBF103000+0x54)
+ #define AR10_GPIO_P1_PUDSEL (0xBF103000+0x5C)
+ #define AR10_GPIO_P1_PUDEN (0xBF103000+0x60)
+ #endif
+
+ #define AR10_RCU_USB1CFG ((volatile unsigned long *)(AR10_RCU_BASE_ADDR + 0x18))
+ #define AR10_RCU_USB2CFG ((volatile unsigned long *)(AR10_RCU_BASE_ADDR + 0x34))
+ #define AR10_RCU_USB_ANA_CFG1A ((volatile unsigned long *)(AR10_RCU_BASE_ADDR + 0x38))
+ #define AR10_RCU_USB_ANA_CFG1B ((volatile unsigned long *)(AR10_RCU_BASE_ADDR + 0x3C))
+
+ #define AR10_RCU_USBRESET ((volatile unsigned long *)(AR10_RCU_BASE_ADDR + 0x10))
+
+ #define AR10_USBCFG_ARB 7 //
+ #define AR10_USBCFG_HDSEL_BIT 11 // 0:host, 1:device
+ #define AR10_USBCFG_HOST_END_BIT 10 // 0:little_end, 1:big_end
+ #define AR10_USBCFG_SLV_END_BIT 9 // 0:little_end, 1:big_end
+
+// #define default_param_dma_burst_size 4 //(ALL)
+ //WA for AHB
+ #define default_param_dma_burst_size 0 //(ALL)
+
+ #define default_param_speed IFXUSB_PARAM_SPEED_HIGH
+
+ #define default_param_max_transfer_size -1 //(Max, hwcfg)
+ #define default_param_max_packet_count -1 //(Max, hwcfg)
+ #define default_param_phy_utmi_width 16
+
+ #define default_param_turn_around_time_hs 6 //(NoChange) snpsid >= 0x4f54260a
+ #define default_param_turn_around_time_fs 6 //(NoChange) snpsid >= 0x4f54260a
+ #define default_param_timeout_cal_hs -1 //(NoChange)
+ #define default_param_timeout_cal_fs -1 //(NoChange)
+
+ #define default_param_data_fifo_size -1 //(Max, hwcfg)
+
+ #ifdef __IS_HOST__
+ #define default_param_host_channels -1 //(Max, hwcfg)
+ #define default_param_rx_fifo_size 240
+ #define default_param_nperio_tx_fifo_size 240
+ #define default_param_perio_tx_fifo_size 32
+ #endif //__IS_HOST__
+ #ifdef __IS_DEVICE__
+#if 0
+ #define default_param_rx_fifo_size 256
+ #define default_param_tx_fifo_size_00 -1
+ #define default_param_tx_fifo_size_01 -1
+ #define default_param_tx_fifo_size_02 -1
+#else
+ #define default_param_rx_fifo_size 256
+ #define default_param_tx_fifo_size_00 32
+ #define default_param_tx_fifo_size_01 200
+ #define default_param_tx_fifo_size_02 8
+#endif
+ #define default_param_tx_fifo_size_03 -1
+ #define default_param_tx_fifo_size_04 -1
+ #define default_param_tx_fifo_size_05 -1
+ #define default_param_tx_fifo_size_06 -1
+ #define default_param_tx_fifo_size_07 -1
+ #define default_param_tx_fifo_size_08 -1
+ #define default_param_tx_fifo_size_09 -1
+ #define default_param_tx_fifo_size_10 -1
+ #define default_param_tx_fifo_size_11 -1
+ #define default_param_tx_fifo_size_12 -1
+ #define default_param_tx_fifo_size_13 -1
+ #define default_param_tx_fifo_size_14 -1
+ #define default_param_tx_fifo_size_15 -1
+ #define default_param_dma_unalgned_tx -1
+ #define default_param_dma_unalgned_rx -1
+ #define default_param_thr_ctl -1
+ #define default_param_tx_thr_length -1
+ #define default_param_rx_thr_length -1
+ #endif //__IS_DEVICE__
+ #else // __IS_AR10__
+ #error "Please choose one platform!!"
+ #endif // __IS_VR9__
+
+#else //UEIP
+ #if defined(__IS_TWINPASS__) || defined(__IS_DANUBE__)
+ #define IFXUSB_IRQ 54
+ #define IFXUSB_IOMEM_BASE 0x1e101000
+ #define IFXUSB_FIFOMEM_BASE 0x1e120000
+ #define IFXUSB_FIFODBG_BASE 0x1e140000
+ #define IFXUSB_OC_IRQ 151
+
+
+ #ifndef DANUBE_RCU_BASE_ADDR
+ #define DANUBE_RCU_BASE_ADDR (0xBF203000)
+ #endif
+
+ #ifndef DANUBE_CGU
+ #define DANUBE_CGU (0xBF103000)
+ #endif
+ #ifndef DANUBE_CGU_IFCCR
+ #define DANUBE_CGU_IFCCR ((volatile unsigned long *)(DANUBE_CGU+ 0x0018))
+ #endif
+ #ifndef DANUBE_PMU
+ #define DANUBE_PMU (KSEG1+0x1F102000)
+ #endif
+ #ifndef DANUBE_PMU_PWDCR
+ #define DANUBE_PMU_PWDCR ((volatile unsigned long *)(DANUBE_PMU+0x001C))
+ #endif
+
+ #ifndef DANUBE_GPIO_P0_OUT
+ #define DANUBE_GPIO_P0_OUT (0xBF103000+0x10)
+ #define DANUBE_GPIO_P0_DIR (0xBF103000+0x18)
+ #define DANUBE_GPIO_P0_ALTSEL0 (0xBF103000+0x1C)
+ #define DANUBE_GPIO_P0_ALTSEL1 (0xBF103000+0x20)
+ #define DANUBE_GPIO_P0_OD (0xBF103000+0x24)
+ #define DANUBE_GPIO_P0_PUDSEL (0xBF103000+0x2C)
+ #define DANUBE_GPIO_P0_PUDEN (0xBF103000+0x30)
+ #define DANUBE_GPIO_P1_OUT (0xBF103000+0x40)
+ #define DANUBE_GPIO_P1_DIR (0xBF103000+0x48)
+ #define DANUBE_GPIO_P1_ALTSEL0 (0xBF103000+0x4C)
+ #define DANUBE_GPIO_P1_ALTSEL1 (0xBF103000+0x50)
+ #define DANUBE_GPIO_P1_OD (0xBF103000+0x54)
+ #define DANUBE_GPIO_P1_PUDSEL (0xBF103000+0x5C)
+ #define DANUBE_GPIO_P1_PUDEN (0xBF103000+0x60)
+ #endif
+
+
+ #define DANUBE_RCU_USBCFG ((volatile unsigned long *)(DANUBE_RCU_BASE_ADDR + 0x18))
+ #define DANUBE_RCU_RESET ((volatile unsigned long *)(DANUBE_RCU_BASE_ADDR + 0x10))
+ #define DANUBE_USBCFG_HDSEL_BIT 11 // 0:host, 1:device
+ #define DANUBE_USBCFG_HOST_END_BIT 10 // 0:little_end, 1:big_end
+ #define DANUBE_USBCFG_SLV_END_BIT 9 // 0:little_end, 1:big_end
+
+ #define default_param_dma_burst_size 4
+
+ #define default_param_speed IFXUSB_PARAM_SPEED_HIGH
+
+ #define default_param_max_transfer_size -1 //(Max, hwcfg)
+ #define default_param_max_packet_count -1 //(Max, hwcfg)
+ #define default_param_phy_utmi_width 16
+
+ #define default_param_turn_around_time_hs 4 //(NoChange)
+ #define default_param_turn_around_time_fs 4 //(NoChange)
+ #define default_param_timeout_cal_hs -1 //(NoChange)
+ #define default_param_timeout_cal_fs -1 //(NoChange)
+
+ #define default_param_data_fifo_size -1 //(Max, hwcfg)
+ #ifdef __IS_HOST__
+ #define default_param_host_channels -1 //(Max, hwcfg)
+ #define default_param_rx_fifo_size 640
+ #define default_param_nperio_tx_fifo_size 640
+ #define default_param_perio_tx_fifo_size 768
+ #endif //__IS_HOST__
+
+ #ifdef __IS_DEVICE__
+ #ifdef __DED_INTR__
+ #define default_param_rx_fifo_size 1024
+ #define default_param_nperio_tx_fifo_size 1016
+ #define default_param_perio_tx_fifo_size_01 8
+ #else
+ #define default_param_rx_fifo_size 1024
+ #define default_param_nperio_tx_fifo_size 1024
+ #define default_param_perio_tx_fifo_size_01 0
+ #endif
+ #define default_param_perio_tx_fifo_size_02 0
+ #define default_param_perio_tx_fifo_size_03 0
+ #define default_param_perio_tx_fifo_size_04 0
+ #define default_param_perio_tx_fifo_size_05 0
+ #define default_param_perio_tx_fifo_size_06 0
+ #define default_param_perio_tx_fifo_size_07 0
+ #define default_param_perio_tx_fifo_size_08 0
+ #define default_param_perio_tx_fifo_size_09 0
+ #define default_param_perio_tx_fifo_size_10 0
+ #define default_param_perio_tx_fifo_size_11 0
+ #define default_param_perio_tx_fifo_size_12 0
+ #define default_param_perio_tx_fifo_size_13 0
+ #define default_param_perio_tx_fifo_size_14 0
+ #define default_param_perio_tx_fifo_size_15 0
+ #endif //__IS_DEVICE__
+
+ #elif defined(__IS_AMAZON_SE__)
+ #include <asm/amazon_se/amazon_se.h>
+ //#include <asm/amazon_se/irq.h>
+
+ #define IFXUSB_IRQ 31
+ #define IFXUSB_IOMEM_BASE 0x1e101000
+ #define IFXUSB_FIFOMEM_BASE 0x1e120000
+ #define IFXUSB_FIFODBG_BASE 0x1e140000
+ #define IFXUSB_OC_IRQ 20
+
+ #define AMAZON_SE_RCU_USBCFG ((volatile unsigned long *)(AMAZON_SE_RCU_BASE_ADDR + 0x18))
+ #define AMAZON_SE_RCU_RESET ((volatile unsigned long *)(AMAZON_SE_RCU_BASE_ADDR + 0x10))
+ #define AMAZON_SE_USBCFG_HDSEL_BIT 11 // 0:host, 1:device
+ #define AMAZON_SE_USBCFG_HOST_END_BIT 10 // 0:little_end, 1:big_end
+ #define AMAZON_SE_USBCFG_SLV_END_BIT 9 // 0:little_end, 1:big_end
+
+ #ifndef AMAZON_SE_GPIO_P0_OUT
+ #define AMAZON_SE_GPIO_P0_OUT (0xBF103000+0x10)
+ #define AMAZON_SE_GPIO_P0_DIR (0xBF103000+0x18)
+ #define AMAZON_SE_GPIO_P0_ALTSEL0 (0xBF103000+0x1C)
+ #define AMAZON_SE_GPIO_P0_ALTSEL1 (0xBF103000+0x20)
+ #define AMAZON_SE_GPIO_P0_OD (0xBF103000+0x24)
+ #define AMAZON_SE_GPIO_P0_PUDSEL (0xBF103000+0x2C)
+ #define AMAZON_SE_GPIO_P0_PUDEN (0xBF103000+0x30)
+ #define AMAZON_SE_GPIO_P1_OUT (0xBF103000+0x40)
+ #define AMAZON_SE_GPIO_P1_DIR (0xBF103000+0x48)
+ #define AMAZON_SE_GPIO_P1_ALTSEL0 (0xBF103000+0x4C)
+ #define AMAZON_SE_GPIO_P1_ALTSEL1 (0xBF103000+0x50)
+ #define AMAZON_SE_GPIO_P1_OD (0xBF103000+0x54)
+ #define AMAZON_SE_GPIO_P1_PUDSEL (0xBF103000+0x5C)
+ #define AMAZON_SE_GPIO_P1_PUDEN (0xBF103000+0x60)
+ #endif
+
+
+ #ifndef AMAZON_SE_CGU
+ #define AMAZON_SE_CGU (0xBF103000)
+ #endif
+ #ifndef AMAZON_SE_CGU_IFCCR
+ #define AMAZON_SE_CGU_IFCCR ((volatile unsigned long *)(AMAZON_SE_CGU+ 0x0018))
+ #endif
+ #ifndef AMAZON_SE_PMU
+ #define AMAZON_SE_PMU (KSEG1+0x1F102000)
+ #endif
+ #ifndef AMAZON_SE_PMU_PWDCR
+ #define AMAZON_SE_PMU_PWDCR ((volatile unsigned long *)(AMAZON_SE_PMU+0x001C))
+ #endif
+
+ #define default_param_dma_burst_size 4
+
+ #define default_param_speed IFXUSB_PARAM_SPEED_HIGH
+
+ #define default_param_max_transfer_size -1 //(Max, hwcfg)
+ #define default_param_max_packet_count -1 //(Max, hwcfg)
+ #define default_param_phy_utmi_width 16
+
+ #define default_param_turn_around_time_hs 4 //(NoChange)
+ #define default_param_turn_around_time_fs 4 //(NoChange)
+ #define default_param_timeout_cal_hs -1 //(NoChange)
+ #define default_param_timeout_cal_fs -1 //(NoChange)
+
+ #define default_param_data_fifo_size -1 //(Max, hwcfg)
+
+ #ifdef __IS_HOST__
+ #define default_param_host_channels -1 //(Max, hwcfg)
+ #define default_param_rx_fifo_size 240
+ #define default_param_nperio_tx_fifo_size 240
+ #define default_param_perio_tx_fifo_size 32
+ #endif //__IS_HOST__
+ #ifdef __IS_DEVICE__
+ #ifdef __DED_INTR__
+ #define default_param_rx_fifo_size 256
+ #define default_param_nperio_tx_fifo_size 248
+ #define default_param_perio_tx_fifo_size_01 8
+ #else
+ #define default_param_rx_fifo_size 256
+ #define default_param_nperio_tx_fifo_size 256
+ #define default_param_perio_tx_fifo_size_01 0
+ #endif
+ #define default_param_perio_tx_fifo_size_02 0
+ #define default_param_perio_tx_fifo_size_03 0
+ #define default_param_perio_tx_fifo_size_04 0
+ #define default_param_perio_tx_fifo_size_05 0
+ #define default_param_perio_tx_fifo_size_06 0
+ #define default_param_perio_tx_fifo_size_07 0
+ #define default_param_perio_tx_fifo_size_08 0
+ #define default_param_perio_tx_fifo_size_09 0
+ #define default_param_perio_tx_fifo_size_10 0
+ #define default_param_perio_tx_fifo_size_11 0
+ #define default_param_perio_tx_fifo_size_12 0
+ #define default_param_perio_tx_fifo_size_13 0
+ #define default_param_perio_tx_fifo_size_14 0
+ #define default_param_perio_tx_fifo_size_15 0
+ #endif //__IS_DEVICE__
+
+ #elif defined(__IS_AR9__)
+ #define IFXUSB1_IRQ 54
+ #define IFXUSB1_IOMEM_BASE 0x1E101000
+ #define IFXUSB1_FIFOMEM_BASE 0x1E120000
+ #define IFXUSB1_FIFODBG_BASE 0x1E140000
+
+ #define IFXUSB2_IRQ 83
+ #define IFXUSB2_IOMEM_BASE 0x1E106000
+ #define IFXUSB2_FIFOMEM_BASE 0x1E1E0000
+ #define IFXUSB2_FIFODBG_BASE 0x1E1C0000
+
+ #define IFXUSB_OC_IRQ 60
+
+ #ifndef AMAZON_S_RCU_BASE_ADDR
+ #define AMAZON_S_RCU_BASE_ADDR (0xBF203000)
+ #endif
+
+ #ifndef AMAZON_S_CGU
+ #define AMAZON_S_CGU (0xBF103000)
+ #endif
+ #ifndef AMAZON_S_CGU_IFCCR
+ #define AMAZON_S_CGU_IFCCR ((volatile unsigned long *)(AMAZON_S_CGU+ 0x0018))
+ #endif
+
+ #ifndef AMAZON_S_PMU
+ #define AMAZON_S_PMU (KSEG1+0x1F102000)
+ #endif
+ #ifndef AMAZON_S_PMU_PWDCR
+ #define AMAZON_S_PMU_PWDCR ((volatile unsigned long *)(AMAZON_S_PMU+0x001C))
+ #endif
+
+ #ifndef AMAZON_S_GPIO_P0_OUT
+ #define AMAZON_S_GPIO_P0_OUT (0xBF103000+0x10)
+ #define AMAZON_S_GPIO_P0_DIR (0xBF103000+0x18)
+ #define AMAZON_S_GPIO_P0_ALTSEL0 (0xBF103000+0x1C)
+ #define AMAZON_S_GPIO_P0_ALTSEL1 (0xBF103000+0x20)
+ #define AMAZON_S_GPIO_P0_OD (0xBF103000+0x24)
+ #define AMAZON_S_GPIO_P0_PUDSEL (0xBF103000+0x2C)
+ #define AMAZON_S_GPIO_P0_PUDEN (0xBF103000+0x30)
+ #define AMAZON_S_GPIO_P1_OUT (0xBF103000+0x40)
+ #define AMAZON_S_GPIO_P1_DIR (0xBF103000+0x48)
+ #define AMAZON_S_GPIO_P1_ALTSEL0 (0xBF103000+0x4C)
+ #define AMAZON_S_GPIO_P1_ALTSEL1 (0xBF103000+0x50)
+ #define AMAZON_S_GPIO_P1_OD (0xBF103000+0x54)
+ #define AMAZON_S_GPIO_P1_PUDSEL (0xBF103000+0x5C)
+ #define AMAZON_S_GPIO_P1_PUDEN (0xBF103000+0x60)
+ #endif
+
+ #define AMAZON_S_RCU_USB1CFG ((volatile unsigned long *)(AMAZON_S_RCU_BASE_ADDR + 0x18))
+ #define AMAZON_S_RCU_USB2CFG ((volatile unsigned long *)(AMAZON_S_RCU_BASE_ADDR + 0x34))
+ #define AMAZON_S_RCU_USBRESET ((volatile unsigned long *)(AMAZON_S_RCU_BASE_ADDR + 0x10))
+ #define AMAZON_S_USBCFG_ARB 7 //
+ #define AMAZON_S_USBCFG_HDSEL_BIT 11 // 0:host, 1:device
+ #define AMAZON_S_USBCFG_HOST_END_BIT 10 // 0:little_end, 1:big_end
+ #define AMAZON_S_USBCFG_SLV_END_BIT 17 // 0:little_end, 1:big_end
+
+ #define default_param_dma_burst_size 4
+
+ #define default_param_speed IFXUSB_PARAM_SPEED_HIGH
+
+ #define default_param_max_transfer_size -1 //(Max, hwcfg)
+ #define default_param_max_packet_count -1 //(Max, hwcfg)
+ #define default_param_phy_utmi_width 16
+
+ #define default_param_turn_around_time_hs 4 //(NoChange)
+ #define default_param_turn_around_time_fs 4 //(NoChange)
+ #define default_param_timeout_cal_hs -1 //(NoChange)
+ #define default_param_timeout_cal_fs -1 //(NoChange)
+
+ #define default_param_data_fifo_size -1 //(Max, hwcfg)
+
+ #ifdef __IS_HOST__
+ #define default_param_host_channels -1 //(Max, hwcfg)
+ #define default_param_rx_fifo_size 240
+ #define default_param_nperio_tx_fifo_size 240
+ #define default_param_perio_tx_fifo_size 32
+ #endif //__IS_HOST__
+ #ifdef __IS_DEVICE__
+ #ifdef __DED_INTR__
+ #define default_param_rx_fifo_size 256
+ #define default_param_nperio_tx_fifo_size 248
+ #define default_param_perio_tx_fifo_size_01 8
+ #else
+ #define default_param_rx_fifo_size 256
+ #define default_param_nperio_tx_fifo_size 256
+ #define default_param_perio_tx_fifo_size_01 0
+ #endif
+ #define default_param_perio_tx_fifo_size_02 0
+ #define default_param_perio_tx_fifo_size_03 0
+ #define default_param_perio_tx_fifo_size_04 0
+ #define default_param_perio_tx_fifo_size_05 0
+ #define default_param_perio_tx_fifo_size_06 0
+ #define default_param_perio_tx_fifo_size_07 0
+ #define default_param_perio_tx_fifo_size_08 0
+ #define default_param_perio_tx_fifo_size_09 0
+ #define default_param_perio_tx_fifo_size_10 0
+ #define default_param_perio_tx_fifo_size_11 0
+ #define default_param_perio_tx_fifo_size_12 0
+ #define default_param_perio_tx_fifo_size_13 0
+ #define default_param_perio_tx_fifo_size_14 0
+ #define default_param_perio_tx_fifo_size_15 0
+ #endif //__IS_DEVICE__
+
+ #elif defined(__IS_VR9__)
+ #define IFXUSB1_IRQ 54
+ #define IFXUSB1_IOMEM_BASE 0x1E101000
+ #define IFXUSB1_FIFOMEM_BASE 0x1E120000
+ #define IFXUSB1_FIFODBG_BASE 0x1E140000
+
+ #define IFXUSB2_IRQ 83
+ #define IFXUSB2_IOMEM_BASE 0x1E106000
+ #define IFXUSB2_FIFOMEM_BASE 0x1E1E0000
+ #define IFXUSB2_FIFODBG_BASE 0x1E1C0000
+ #define IFXUSB_OC_IRQ 68
+
+ #ifndef AMAZON_S_RCU_BASE_ADDR
+ #define AMAZON_S_RCU_BASE_ADDR (0xBF203000)
+ #endif
+
+ #ifndef AMAZON_S_CGU
+ #define AMAZON_S_CGU (0xBF103000)
+ #endif
+ #ifndef AMAZON_S_CGU_IFCCR
+ #define AMAZON_S_CGU_IFCCR ((volatile unsigned long *)(AMAZON_S_CGU+ 0x0018))
+ #endif
+
+ #ifndef AMAZON_S_PMU
+ #define AMAZON_S_PMU (KSEG1+0x1F102000)
+ #endif
+ #ifndef AMAZON_S_PMU_PWDCR
+ #define AMAZON_S_PMU_PWDCR ((volatile unsigned long *)(AMAZON_S_PMU+0x001C))
+ #endif
+
+ #ifndef AMAZON_S_GPIO_P0_OUT
+ #define AMAZON_S_GPIO_P0_OUT (0xBF103000+0x10)
+ #define AMAZON_S_GPIO_P0_DIR (0xBF103000+0x18)
+ #define AMAZON_S_GPIO_P0_ALTSEL0 (0xBF103000+0x1C)
+ #define AMAZON_S_GPIO_P0_ALTSEL1 (0xBF103000+0x20)
+ #define AMAZON_S_GPIO_P0_OD (0xBF103000+0x24)
+ #define AMAZON_S_GPIO_P0_PUDSEL (0xBF103000+0x2C)
+ #define AMAZON_S_GPIO_P0_PUDEN (0xBF103000+0x30)
+ #define AMAZON_S_GPIO_P1_OUT (0xBF103000+0x40)
+ #define AMAZON_S_GPIO_P1_DIR (0xBF103000+0x48)
+ #define AMAZON_S_GPIO_P1_ALTSEL0 (0xBF103000+0x4C)
+ #define AMAZON_S_GPIO_P1_ALTSEL1 (0xBF103000+0x50)
+ #define AMAZON_S_GPIO_P1_OD (0xBF103000+0x54)
+ #define AMAZON_S_GPIO_P1_PUDSEL (0xBF103000+0x5C)
+ #define AMAZON_S_GPIO_P1_PUDEN (0xBF103000+0x60)
+ #endif
+
+ #define AMAZON_S_RCU_USB1CFG ((volatile unsigned long *)(AMAZON_S_RCU_BASE_ADDR + 0x18))
+ #define AMAZON_S_RCU_USB2CFG ((volatile unsigned long *)(AMAZON_S_RCU_BASE_ADDR + 0x34))
+ #define AMAZON_S_RCU_USBRESET ((volatile unsigned long *)(AMAZON_S_RCU_BASE_ADDR + 0x10))
+ #define AMAZON_S_USBCFG_ARB 7 //
+ #define AMAZON_S_USBCFG_HDSEL_BIT 11 // 0:host, 1:device
+ #define AMAZON_S_USBCFG_HOST_END_BIT 10 // 0:little_end, 1:big_end
+ #define AMAZON_S_USBCFG_SLV_END_BIT 17 // 0:little_end, 1:big_end
+
+ #define default_param_dma_burst_size 4 //(ALL)
+
+ #define default_param_speed IFXUSB_PARAM_SPEED_HIGH
+
+ #define default_param_max_transfer_size -1 //(Max, hwcfg)
+ #define default_param_max_packet_count -1 //(Max, hwcfg)
+ #define default_param_phy_utmi_width 16
+
+ #define default_param_turn_around_time_hs 6 //(NoChange) snpsid >= 0x4f54260a
+ #define default_param_turn_around_time_fs 6 //(NoChange) snpsid >= 0x4f54260a
+ #define default_param_timeout_cal_hs -1 //(NoChange)
+ #define default_param_timeout_cal_fs -1 //(NoChange)
+
+ #define default_param_data_fifo_size -1 //(Max, hwcfg)
+
+ #ifdef __IS_HOST__
+ #define default_param_host_channels -1 //(Max, hwcfg)
+ #define default_param_rx_fifo_size 240
+ #define default_param_nperio_tx_fifo_size 240
+ #define default_param_perio_tx_fifo_size 32
+ #endif //__IS_HOST__
+ #ifdef __IS_DEVICE__
+ #define default_param_rx_fifo_size 256
+ #define default_param_tx_fifo_size_00 -1
+ #define default_param_tx_fifo_size_01 -1
+ #define default_param_tx_fifo_size_02 -1
+ #define default_param_tx_fifo_size_03 -1
+ #define default_param_tx_fifo_size_04 -1
+ #define default_param_tx_fifo_size_05 -1
+ #define default_param_tx_fifo_size_06 -1
+ #define default_param_tx_fifo_size_07 -1
+ #define default_param_tx_fifo_size_08 -1
+ #define default_param_tx_fifo_size_09 -1
+ #define default_param_tx_fifo_size_10 -1
+ #define default_param_tx_fifo_size_11 -1
+ #define default_param_tx_fifo_size_12 -1
+ #define default_param_tx_fifo_size_13 -1
+ #define default_param_tx_fifo_size_14 -1
+ #define default_param_tx_fifo_size_15 -1
+ #define default_param_dma_unalgned_tx -1
+ #define default_param_dma_unalgned_rx -1
+ #define default_param_thr_ctl -1
+ #define default_param_tx_thr_length -1
+ #define default_param_rx_thr_length -1
+ #endif //__IS_DEVICE__
+ #else // __IS_VR9__
+ #error "Please choose one platform!!"
+ #endif // __IS_VR9__
+#endif //UEIP
+
+/*@}*//*IFXUSB_PLATEFORM_MEM_ADDR*/
+
+/////////////////////////////////////////////////////////////////////////
+
+#ifdef __IS_HOST__
+ #if defined(CONFIG_USB_HOST_IFX_FORCE_USB11) || defined(__FORCE_USB11__)
+ #undef default_param_speed
+ #define default_param_speed IFXUSB_PARAM_SPEED_FULL
+ #endif
+#endif
+#ifdef __IS_DEVICE__
+ #if !defined(CONFIG_USB_GADGET_DUALSPEED) || defined(__FORCE_USB11__)
+ #undef default_param_speed
+ #define default_param_speed IFXUSB_PARAM_SPEED_FULL
+ #endif
+#endif
+
+/////////////////////////////////////////////////////////////////////////
+
+static __inline__ void UDELAY( const uint32_t _usecs )
+{
+ udelay( _usecs );
+}
+
+static __inline__ void MDELAY( const uint32_t _msecs )
+{
+ mdelay( _msecs );
+}
+
+static __inline__ void SPIN_LOCK( spinlock_t *_lock )
+{
+ spin_lock(_lock);
+}
+
+static __inline__ void SPIN_UNLOCK( spinlock_t *_lock )
+{
+ spin_unlock(_lock);
+}
+
+#define SPIN_LOCK_IRQSAVE( _l, _f ) \
+ { \
+ spin_lock_irqsave(_l,_f); \
+ }
+
+#define SPIN_UNLOCK_IRQRESTORE( _l,_f ) \
+ { \
+ spin_unlock_irqrestore(_l,_f); \
+ }
+
+/////////////////////////////////////////////////////////////////////////
+/*!
+ \addtogroup IFXUSB_DBG_ROUTINE
+ */
+/*@{*/
+#ifdef __IS_HOST__
+ extern uint32_t h_dbg_lvl;
+#endif
+
+#ifdef __IS_DEVICE__
+ extern uint32_t d_dbg_lvl;
+#endif
+
+/*! \brief When debug level has the DBG_CIL bit set, display CIL Debug messages. */
+#define DBG_CIL (0x2)
+/*! \brief When debug level has the DBG_CILV bit set, display CIL Verbose debug messages */
+#define DBG_CILV (0x20)
+/*! \brief When debug level has the DBG_PCD bit set, display PCD (Device) debug messages */
+#define DBG_PCD (0x4)
+/*! \brief When debug level has the DBG_PCDV set, display PCD (Device) Verbose debug messages */
+#define DBG_PCDV (0x40)
+/*! \brief When debug level has the DBG_HCD bit set, display Host debug messages */
+#define DBG_HCD (0x8)
+/*! \brief When debug level has the DBG_HCDV bit set, display Verbose Host debug messages */
+#define DBG_HCDV (0x80)
+/*! \brief When debug level has the DBG_HCD_URB bit set, display enqueued URBs in host mode. */
+#define DBG_HCD_URB (0x800)
+/*! \brief When debug level has any bit set, display debug messages */
+#define DBG_ANY (0xFF)
+/*! \brief All debug messages off */
+#define DBG_OFF 0
+
+#define DBG_ENTRY (0x8000)
+
+#define IFXUSB "IFXUSB: "
+
+/*!
+ \fn inline uint32_t SET_DEBUG_LEVEL( const uint32_t _new )
+ \brief Set the Debug Level variable.
+ \param _new 32-bit mask of debug level.
+ \return previous debug level
+ */
+static inline uint32_t SET_DEBUG_LEVEL( const uint32_t _new )
+{
+ #ifdef __IS_HOST__
+ uint32_t old = h_dbg_lvl;
+ h_dbg_lvl = _new;
+ #endif
+
+ #ifdef __IS_DEVICE__
+ uint32_t old = d_dbg_lvl;
+ d_dbg_lvl = _new;
+ #endif
+ return old;
+}
+
+#ifdef __DEBUG__
+ #ifdef __IS_HOST__
+ # define IFX_DEBUGPL(lvl, x...) do{ if ((lvl)&h_dbg_lvl)printk( KERN_DEBUG IFXUSB x ); }while(0)
+ # define CHK_DEBUG_LEVEL(level) ((level) & h_dbg_lvl)
+ #endif
+
+ #ifdef __IS_DEVICE__
+ # define IFX_DEBUGPL(lvl, x...) do{ if ((lvl)&d_dbg_lvl)printk( KERN_DEBUG IFXUSB x ); }while(0)
+ # define CHK_DEBUG_LEVEL(level) ((level) & d_dbg_lvl)
+ #endif
+
+ # define IFX_DEBUGP(x...) IFX_DEBUGPL(DBG_ANY, x )
+#else
+ # define IFX_DEBUGPL(lvl, x...) do{}while(0)
+ # define IFX_DEBUGP(x...)
+ # define CHK_DEBUG_LEVEL(level) (0)
+#endif //__DEBUG__
+
+/* Print an Error message. */
+#define IFX_ERROR(x...) printk( KERN_ERR IFXUSB x )
+/* Print a Warning message. */
+#define IFX_WARN(x...) printk( KERN_WARNING IFXUSB x )
+/* Print a notice (normal but significant message). */
+#define IFX_NOTICE(x...) printk( KERN_NOTICE IFXUSB x )
+/* Basic message printing. */
+#define IFX_PRINT(x...) printk( KERN_INFO IFXUSB x )
+
+/*@}*//*IFXUSB_DBG_ROUTINE*/
+
+
+#endif //__IFXUSB_PLAT_H__
+
diff --git a/package/platform/lantiq/ltq-hcd/src/ifxusb_regs.h b/package/platform/lantiq/ltq-hcd/src/ifxusb_regs.h
new file mode 100644
index 0000000..4b43821
--- /dev/null
+++ b/package/platform/lantiq/ltq-hcd/src/ifxusb_regs.h
@@ -0,0 +1,1471 @@
+/*****************************************************************************
+ ** FILE NAME : ifxusb_regs.h
+ ** PROJECT : IFX USB sub-system V3
+ ** MODULES : IFX USB sub-system Host and Device driver
+ ** SRC VERSION : 3.2
+ ** DATE : 1/Jan/2011
+ ** AUTHOR : Chen, Howard
+ ** DESCRIPTION : This file contains the data structures for accessing the IFXUSB core
+ ** registers.
+ ** The application interfaces with the USB core by reading from and
+ ** writing to the Control and Status Register (CSR) space through the
+ ** AHB Slave interface. These registers are 32 bits wide, and the
+ ** addresses are 32-bit-block aligned.
+ ** CSRs are classified as follows:
+ ** - Core Global Registers
+ ** - Device Mode Registers
+ ** - Device Global Registers
+ ** - Device Endpoint Specific Registers
+ ** - Host Mode Registers
+ ** - Host Global Registers
+ ** - Host Port CSRs
+ ** - Host Channel Specific Registers
+ **
+ ** Only the Core Global registers can be accessed in both Device and
+ ** Host modes. When the USB core is operating in one mode, either
+ ** Device or Host, the application must not access registers from the
+ ** other mode. When the core switches from one mode to another, the
+ ** registers in the new mode of operation must be reprogrammed as they
+ ** would be after a power-on reset.
+ ** FUNCTIONS :
+ ** COMPILER : gcc
+ ** REFERENCE : Synopsys DWC-OTG Driver 2.7
+ ** COPYRIGHT : Copyright (c) 2010
+ ** LANTIQ DEUTSCHLAND GMBH,
+ ** Am Campeon 3, 85579 Neubiberg, Germany
+ **
+ ** 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 of the License, or
+ ** (at your option) any later version.
+ **
+ ** Version Control Section **
+ ** $Author$
+ ** $Date$
+ ** $Revisions$
+ ** $Log$ Revision history
+*****************************************************************************/
+/******************************************************************************
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 10 NOV 2008 Wu Qi Ming Initial Version, to comply with COC
+*******************************************************************************/
+
+
+/*
+ * This file contains code fragments from Synopsys HS OTG Linux Software Driver.
+ * For this code the following notice is applicable:
+ *
+ * ==========================================================================
+ *
+ * Synopsys HS OTG Linux Software Driver and documentation (hereinafter,
+ * "Software") is an Unsupported proprietary work of Synopsys, Inc. unless
+ * otherwise expressly agreed to in writing between Synopsys and you.
+ *
+ * The Software IS NOT an item of Licensed Software or Licensed Product under
+ * any End User Software License Agreement or Agreement for Licensed Product
+ * with Synopsys or any supplement thereto. You are permitted to use and
+ * redistribute this Software in source and binary forms, with or without
+ * modification, provided that redistributions of source code must retain this
+ * notice. You may not view, use, disclose, copy or distribute this file or
+ * any information contained herein except pursuant to this license grant from
+ * Synopsys. If you do not agree with this notice, including the disclaimer
+ * below, then you are not authorized to use the Software.
+ *
+ * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" BASIS
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ * ========================================================================== */
+
+
+/*!
+ \defgroup IFXUSB_CSR_DEFINITION Control and Status Register bit-map definition
+ \ingroup IFXUSB_DRIVER_V3
+ \brief Data structures for accessing the IFXUSB core registers.
+ The application interfaces with the USB core by reading from and
+ writing to the Control and Status Register (CSR) space through the
+ AHB Slave interface. These registers are 32 bits wide, and the
+ addresses are 32-bit-block aligned.
+ CSRs are classified as follows:
+ - Core Global Registers
+ - Device Mode Registers
+ - Device Global Registers
+ - Device Endpoint Specific Registers
+ - Host Mode Registers
+ - Host Global Registers
+ - Host Port CSRs
+ - Host Channel Specific Registers
+
+ Only the Core Global registers can be accessed in both Device andHost modes.
+ When the USB core is operating in one mode, either Device or Host, the
+ application must not access registers from the other mode. When the core
+ switches from one mode to another, the registers in the new mode of operation
+ must be reprogrammed as they would be after a power-on reset.
+ */
+
+/*!
+ \defgroup IFXUSB_CSR_DEVICE_GLOBAL_REG Device Mode Registers
+ \ingroup IFXUSB_CSR_DEFINITION
+ \brief Bit-mapped structure to access Device Mode Global Registers
+ */
+
+/*!
+ \defgroup IFXUSB_CSR_DEVICE_EP_REG Device Mode EP Registers
+ \ingroup IFXUSB_CSR_DEFINITION
+ \brief Bit-mapped structure to access Device Mode EP Registers
+ There will be one set of endpoint registers per logical endpoint
+ implemented.
+ These registers are visible only in Device mode and must not be
+ accessed in Host mode, as the results are unknown.
+ */
+
+/*!
+ \defgroup IFXUSB_CSR_DEVICE_DMA_DESC Device mode scatter dma descriptor strusture
+ \ingroup IFXUSB_CSR_DEFINITION
+ \brief Bit-mapped structure to DMA descriptor
+ */
+
+
+/*!
+ \defgroup IFXUSB_CSR_HOST_GLOBAL_REG Host Mode Registers
+ \ingroup IFXUSB_CSR_DEFINITION
+ \brief Bit-mapped structure to access Host Mode Global Registers
+ */
+
+/*!
+ \defgroup IFXUSB_CSR_HOST_HC_REG Host Mode HC Registers
+ \ingroup IFXUSB_CSR_DEFINITION
+ \brief Bit-mapped structure to access Host Mode Host Channel Registers
+ There will be one set of endpoint registers per host channel
+ implemented.
+ These registers are visible only in Host mode and must not be
+ accessed in Device mode, as the results are unknown.
+ */
+
+/*!
+ \defgroup IFXUSB_CSR_PWR_CLK_GATING_REG Power and Clock Gating Control Register
+ \ingroup IFXUSB_CSR_DEFINITION
+ \brief Bit-mapped structure to Power and Clock Gating Control Register
+ */
+
+/*!
+ \defgroup IFXUSB_CSR_CORE_GLOBAL_REG Core Global Registers
+ \ingroup IFXUSB_CSR_DEFINITION
+ \brief Bit-mapped structure to access Core Global Registers
+ */
+
+/*!
+ \defgroup IFXUSB_CSR_CORE_GLOBAL_REG Core Global Registers
+ \ingroup IFXUSB_CSR_DEFINITION
+ \brief Bit-mapped structure to access Core Global Registers
+ */
+
+
+
+/*!
+ \defgroup IFXUSB_CSR_ACCESS_MACROS Macros to manipulate CSRs
+ \ingroup IFXUSB_CSR_DEFINITION
+ \brief Macros to manipulate CSRs
+ */
+
+
+
+
+
+
+/*!
+ \file ifxusb_regs.h
+ \ingroup IFXUSB_DRIVER_V3
+ \brief This file contains the data structures for accessing the IFXUSB core registers.
+ */
+
+
+#ifndef __IFXUSB_REGS_H__
+#define __IFXUSB_REGS_H__
+
+/****************************************************************************/
+
+#define MAX_PERIO_FIFOS 15 /** Maximum number of Periodic FIFOs */
+#define MAX_TX_FIFOS 15 /** Maximum number of Periodic FIFOs */
+#define MAX_EPS_CHANNELS 16 /** Maximum number of Endpoints/HostChannels */
+
+/****************************************************************************/
+
+//#define __RecordRegRW__
+
+/*!
+ \fn static __inline__ uint32_t ifxusb_rreg( volatile uint32_t *_reg)
+ \brief Reads the content of a register.
+ \param _reg address of register to read.
+ \return contents of the register.
+ \ingroup IFXUSB_CSR_ACCESS_MACROS
+ */
+static __inline__ uint32_t ifxusb_rreg( volatile uint32_t *_reg)
+{
+ #ifdef __RecordRegRW__
+ uint32_t r;
+ r=*(_reg);
+ return (r);
+ #else
+ return (*(_reg));
+ #endif
+};
+
+
+/*!
+ \fn static __inline__ void ifxusb_wreg( volatile uint32_t *_reg, const uint32_t _value)
+ \brief Writes a register with a 32 bit value.
+ \param _reg address of register to write.
+ \param _value value to write to _reg.
+ \ingroup IFXUSB_CSR_ACCESS_MACROS
+ */
+static __inline__ void ifxusb_wreg( volatile uint32_t *_reg, const uint32_t _value)
+{
+ #ifdef __RecordRegRW__
+ printk(KERN_INFO "[W %p<-%08X]\n",_reg,_value);
+ #else
+ *(_reg)=_value;
+ #endif
+};
+
+/*!
+ \fn static __inline__ void ifxusb_mreg( volatile uint32_t *_reg, const uint32_t _clear_mask, const uint32_t _set_mask)
+ \brief Modifies bit values in a register. Using the
+ algorithm: (reg_contents & ~clear_mask) | set_mask.
+ \param _reg address of register to modify.
+ \param _clear_mask bit mask to be cleared.
+ \param _set_mask bit mask to be set.
+ \ingroup IFXUSB_CSR_ACCESS_MACROS
+ */
+static __inline__ void ifxusb_mreg( volatile uint32_t *_reg, const uint32_t _clear_mask, const uint32_t _set_mask)
+{
+ uint32_t v;
+ #ifdef __RecordRegRW__
+ uint32_t r;
+ v= *(_reg);
+ r=v;
+ r&=(~_clear_mask);
+ r|= _set_mask;
+ *(_reg)=r ;
+ printk(KERN_INFO "[M %p->%08X+%08X/%08X<-%08X]\n",_reg,r,_clear_mask,_set_mask,r);
+ #else
+ v= *(_reg);
+ v&=(~_clear_mask);
+ v|= _set_mask;
+ *(_reg)=v ;
+ #endif
+};
+
+/****************************************************************************/
+
+/*!
+ \addtogroup IFXUSB_CSR_CORE_GLOBAL_REG
+ */
+/*@{*/
+
+/*! typedef ifxusb_core_global_regs_t
+ \brief IFXUSB Core registers .
+ The ifxusb_core_global_regs structure defines the size
+ and relative field offsets for the Core Global registers.
+ */
+typedef struct ifxusb_core_global_regs
+{
+ volatile uint32_t gotgctl; /*!< 000h OTG Control and Status Register. */
+ volatile uint32_t gotgint; /*!< 004h OTG Interrupt Register. */
+ volatile uint32_t gahbcfg; /*!< 008h Core AHB Configuration Register. */
+ volatile uint32_t gusbcfg; /*!< 00Ch Core USB Configuration Register. */
+ volatile uint32_t grstctl; /*!< 010h Core Reset Register. */
+ volatile uint32_t gintsts; /*!< 014h Core Interrupt Register. */
+ volatile uint32_t gintmsk; /*!< 018h Core Interrupt Mask Register. */
+ volatile uint32_t grxstsr; /*!< 01Ch Receive Status Queue Read Register (Read Only). */
+ volatile uint32_t grxstsp; /*!< 020h Receive Status Queue Read & POP Register (Read Only). */
+ volatile uint32_t grxfsiz; /*!< 024h Receive FIFO Size Register. */
+ volatile uint32_t gnptxfsiz; /*!< 028h Non Periodic Transmit FIFO Size Register. */
+ volatile uint32_t gnptxsts; /*!< 02Ch Non Periodic Transmit FIFO/Queue Status Register (Read Only). */
+ volatile uint32_t gi2cctl; /*!< 030h I2C Access Register. */
+ volatile uint32_t gpvndctl; /*!< 034h PHY Vendor Control Register. */
+ volatile uint32_t ggpio; /*!< 038h General Purpose Input/Output Register. */
+ volatile uint32_t guid; /*!< 03Ch User ID Register. */
+ volatile uint32_t gsnpsid; /*!< 040h Synopsys ID Register (Read Only). */
+ volatile uint32_t ghwcfg1; /*!< 044h User HW Config1 Register (Read Only). */
+ volatile uint32_t ghwcfg2; /*!< 048h User HW Config2 Register (Read Only). */
+ volatile uint32_t ghwcfg3; /*!< 04Ch User HW Config3 Register (Read Only). */
+ volatile uint32_t ghwcfg4; /*!< 050h User HW Config4 Register (Read Only). */
+ volatile uint32_t reserved[43]; /*!< 054h Reserved 054h-0FFh */
+ volatile uint32_t hptxfsiz; /*!< 100h Host Periodic Transmit FIFO Size Register. */
+ volatile uint32_t dptxfsiz_dieptxf[15];/*!< 104h + (FIFO_Number-1)*04h, 1 <= FIFO Number <= 15.
+ Device Periodic Transmit FIFO#n Register if dedicated
+ fifos are disabled, otherwise Device Transmit FIFO#n
+ Register.
+ */
+} ifxusb_core_global_regs_t;
+
+/*!
+ \brief Bits of the Core OTG Control and Status Register (GOTGCTL).
+ */
+typedef union gotgctl_data
+{
+ uint32_t d32;
+ struct{
+ unsigned reserved21_31 : 11;
+ unsigned currmod : 1 ; /*!< 20 */
+ unsigned bsesvld : 1 ; /*!< 19 */
+ unsigned asesvld : 1 ; /*!< 18 */
+ unsigned reserved17 : 1 ;
+ unsigned conidsts : 1 ; /*!< 16 */
+ unsigned reserved12_15 : 4 ;
+ unsigned devhnpen : 1 ; /*!< 11 */
+ unsigned hstsethnpen : 1 ; /*!< 10 */
+ unsigned hnpreq : 1 ; /*!< 09 */
+ unsigned hstnegscs : 1 ; /*!< 08 */
+ unsigned reserved2_7 : 6 ;
+ unsigned sesreq : 1 ; /*!< 01 */
+ unsigned sesreqscs : 1 ; /*!< 00 */
+ } b;
+} gotgctl_data_t;
+
+/*!
+ \brief Bit fields of the Core OTG Interrupt Register (GOTGINT).
+ */
+typedef union gotgint_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned reserved31_20 : 12;
+ unsigned debdone : 1 ; /*!< 19 Debounce Done */
+ unsigned adevtoutchng : 1 ; /*!< 18 A-Device Timeout Change */
+ unsigned hstnegdet : 1 ; /*!< 17 Host Negotiation Detected */
+ unsigned reserver10_16 : 7 ;
+ unsigned hstnegsucstschng : 1 ; /*!< 09 Host Negotiation Success Status Change */
+ unsigned sesreqsucstschng : 1 ; /*!< 08 Session Request Success Status Change */
+ unsigned reserved3_7 : 5 ;
+ unsigned sesenddet : 1 ; /*!< 02 Session End Detected */
+ unsigned reserved0_1 : 2 ;
+ } b;
+} gotgint_data_t;
+
+/*!
+ \brief Bit fields of the Core AHB Configuration Register (GAHBCFG).
+ */
+typedef union gahbcfg_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned reserved9_31 : 23;
+ unsigned ptxfemplvl : 1 ; /*!< 08 Periodic FIFO empty level trigger condition*/
+ unsigned nptxfemplvl : 1 ; /*!< 07 Non-Periodic FIFO empty level trigger condition*/
+ #define IFXUSB_GAHBCFG_TXFEMPTYLVL_EMPTY 1
+ #define IFXUSB_GAHBCFG_TXFEMPTYLVL_HALFEMPTY 0
+ unsigned reserved : 1 ;
+ unsigned dmaenable : 1 ; /*!< 05 DMA enable*/
+ #define IFXUSB_GAHBCFG_DMAENABLE 1
+ unsigned hburstlen : 4 ; /*!< 01-04 DMA Burst-length*/
+ #define IFXUSB_GAHBCFG_INT_DMA_BURST_SINGLE 0
+ #define IFXUSB_GAHBCFG_INT_DMA_BURST_INCR 1
+ #define IFXUSB_GAHBCFG_INT_DMA_BURST_INCR4 3
+ #define IFXUSB_GAHBCFG_INT_DMA_BURST_INCR8 5
+ #define IFXUSB_GAHBCFG_INT_DMA_BURST_INCR16 7
+ unsigned glblintrmsk : 1 ; /*!< 00 USB Global Interrupt Enable */
+ #define IFXUSB_GAHBCFG_GLBINT_ENABLE 1
+ } b;
+} gahbcfg_data_t;
+
+/*!
+ \brief Bit fields of the Core USB Configuration Register (GUSBCFG).
+*/
+typedef union gusbcfg_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned reserved31 : 1;
+ unsigned ForceDevMode : 1; /*!< 30 Force Device Mode */
+ unsigned ForceHstMode : 1; /*!< 29 Force Host Mode */
+ unsigned TxEndDelay : 1; /*!< 28 Tx End Delay */
+ unsigned reserved2723 : 5;
+ unsigned term_sel_dl_pulse : 1; /*!< 22 TermSel DLine Pulsing Selection */
+ unsigned reserved2117 : 5;
+ unsigned otgutmifssel : 1; /*!< 16 UTMIFS Select */
+ unsigned phylpwrclksel : 1; /*!< 15 PHY Low-Power Clock Select */
+ unsigned reserved14 : 1;
+ unsigned usbtrdtim : 4; /*!< 13-10 USB Turnaround Time */
+ unsigned hnpcap : 1; /*!< 09 HNP-Capable */
+ unsigned srpcap : 1; /*!< 08 SRP-Capable */
+ unsigned reserved07 : 1;
+ unsigned physel : 1; /*!< 06 USB 2.0 High-Speed PHY or
+ USB 1.1 Full-Speed Serial
+ Transceiver Select */
+ unsigned fsintf : 1; /*!< 05 Full-Speed Serial Interface Select */
+ unsigned ulpi_utmi_sel : 1; /*!< 04 ULPI or UTMI+ Select */
+ unsigned phyif : 1; /*!< 03 PHY Interface */
+ unsigned toutcal : 3; /*!< 00-02 HS/FS Timeout Calibration */
+ }b;
+} gusbcfg_data_t;
+
+/*!
+ \brief Bit fields of the Core Reset Register (GRSTCTL).
+ */
+typedef union grstctl_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned ahbidle : 1; /*!< 31 AHB Master Idle. Indicates the AHB Master State
+ Machine is in IDLE condition. */
+ unsigned dmareq : 1; /*!< 30 DMA Request Signal. Indicated DMA request is in
+ probress. Used for debug purpose. */
+ unsigned reserved11_29 :19;
+ unsigned txfnum : 5; /*!< 10-06 TxFIFO Number (TxFNum) to be flushed.
+ 0x00: Non Periodic TxFIFO Flush or TxFIFO 0
+ 0x01-0x0F: Periodic TxFIFO Flush or TxFIFO n
+ 0x10: Flush all TxFIFO
+ */
+ unsigned txfflsh : 1; /*!< 05 TxFIFO Flush */
+ unsigned rxfflsh : 1; /*!< 04 RxFIFO Flush */
+ unsigned intknqflsh : 1; /*!< 03 In Token Sequence Learning Queue Flush (Device Only) */
+ unsigned hstfrm : 1; /*!< 02 Host Frame Counter Reset (Host Only) */
+ unsigned hsftrst : 1; /*!< 01 Hclk Soft Reset */
+
+ unsigned csftrst : 1; /*!< 00 Core Soft Reset
+ The application can flush the control logic in the
+ entire core using this bit. This bit resets the
+ pipelines in the AHB Clock domain as well as the
+ PHY Clock domain.
+ The state machines are reset to an IDLE state, the
+ control bits in the CSRs are cleared, all the
+ transmit FIFOs and the receive FIFO are flushed.
+ The status mask bits that control the generation of
+ the interrupt, are cleared, to clear the
+ interrupt. The interrupt status bits are not
+ cleared, so the application can get the status of
+ any events that occurred in the core after it has
+ set this bit.
+ Any transactions on the AHB are terminated as soon
+ as possible following the protocol. Any
+ transactions on the USB are terminated immediately.
+ The configuration settings in the CSRs are
+ unchanged, so the software doesn't have to
+ reprogram these registers (Device
+ Configuration/Host Configuration/Core System
+ Configuration/Core PHY Configuration).
+ The application can write to this bit, any time it
+ wants to reset the core. This is a self clearing
+ bit and the core clears this bit after all the
+ necessary logic is reset in the core, which may
+ take several clocks, depending on the current state
+ of the core.
+ */
+ }b;
+} grstctl_t;
+
+/*!
+ \brief Bit fields of the Core Interrupt Mask Register (GINTMSK) and
+ Core Interrupt Register (GINTSTS).
+ */
+typedef union gint_data
+{
+ uint32_t d32;
+ #define IFXUSB_SOF_INTR_MASK 0x0008
+ struct
+ {
+ unsigned wkupintr : 1; /*!< 31 Resume/Remote Wakeup Detected Interrupt */
+ unsigned sessreqintr : 1; /*!< 30 Session Request/New Session Detected Interrupt */
+ unsigned disconnect : 1; /*!< 29 Disconnect Detected Interrupt */
+ unsigned conidstschng : 1; /*!< 28 Connector ID Status Change */
+ unsigned reserved27 : 1;
+ unsigned ptxfempty : 1; /*!< 26 Periodic TxFIFO Empty */
+ unsigned hcintr : 1; /*!< 25 Host Channels Interrupt */
+ unsigned portintr : 1; /*!< 24 Host Port Interrupt */
+ unsigned reserved23 : 1;
+ unsigned fetsuspmsk : 1; /*!< 22 Data Fetch Suspended */
+ unsigned incomplisoout : 1; /*!< 21 Incomplete IsochronousOUT/Period Transfer */
+ unsigned incomplisoin : 1; /*!< 20 Incomplete Isochronous IN Transfer */
+ unsigned outepintr : 1; /*!< 19 OUT Endpoints Interrupt */
+ unsigned inepintr : 1; /*!< 18 IN Endpoints Interrupt */
+ unsigned epmismatch : 1; /*!< 17 Endpoint Mismatch Interrupt */
+ unsigned reserved16 : 1;
+ unsigned eopframe : 1; /*!< 15 End of Periodic Frame Interrupt */
+ unsigned isooutdrop : 1; /*!< 14 Isochronous OUT Packet Dropped Interrupt */
+ unsigned enumdone : 1; /*!< 13 Enumeration Done */
+ unsigned usbreset : 1; /*!< 12 USB Reset */
+ unsigned usbsuspend : 1; /*!< 11 USB Suspend */
+ unsigned erlysuspend : 1; /*!< 10 Early Suspend */
+ unsigned i2cintr : 1; /*!< 09 I2C Interrupt */
+ unsigned reserved8 : 1;
+ unsigned goutnakeff : 1; /*!< 07 Global OUT NAK Effective */
+ unsigned ginnakeff : 1; /*!< 06 Global Non-periodic IN NAK Effective */
+ unsigned nptxfempty : 1; /*!< 05 Non-periodic TxFIFO Empty */
+ unsigned rxstsqlvl : 1; /*!< 04 Receive FIFO Non-Empty */
+ unsigned sofintr : 1; /*!< 03 Start of (u)Frame */
+ unsigned otgintr : 1; /*!< 02 OTG Interrupt */
+ unsigned modemismatch : 1; /*!< 01 Mode Mismatch Interrupt */
+ unsigned reserved0 : 1;
+ } b;
+} gint_data_t;
+
+/*!
+ \brief Bit fields in the Receive Status Read and Pop Registers (GRXSTSR, GRXSTSP)
+ */
+typedef union grxsts_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned reserved : 7;
+ unsigned fn : 4; /*!< 24-21 Frame Number */
+ unsigned pktsts : 4; /*!< 20-17 Packet Status */
+ #define IFXUSB_DSTS_DATA_UPDT 0x2 // OUT Data Packet
+ #define IFXUSB_DSTS_XFER_COMP 0x3 // OUT Data Transfer Complete
+ #define IFXUSB_DSTS_GOUT_NAK 0x1 // Global OUT NAK
+ #define IFXUSB_DSTS_SETUP_COMP 0x4 // Setup Phase Complete
+ #define IFXUSB_DSTS_SETUP_UPDT 0x6 // SETUP Packet
+ unsigned dpid : 2; /*!< 16-15 Data PID */
+ unsigned bcnt :11; /*!< 14-04 Byte Count */
+ unsigned epnum : 4; /*!< 03-00 Endpoint Number */
+ } db;
+ struct
+ {
+ unsigned reserved :11;
+ unsigned pktsts : 4; /*!< 20-17 Packet Status */
+ #define IFXUSB_HSTS_DATA_UPDT 0x2 // OUT Data Packet
+ #define IFXUSB_HSTS_XFER_COMP 0x3 // OUT Data Transfer Complete
+ #define IFXUSB_HSTS_DATA_TOGGLE_ERR 0x5 // DATA TOGGLE Error
+ #define IFXUSB_HSTS_CH_HALTED 0x7 // Channel Halted
+ unsigned dpid : 2; /*!< 16-15 Data PID */
+ unsigned bcnt :11; /*!< 14-04 Byte Count */
+ unsigned chnum : 4; /*!< 03-00 Channel Number */
+ } hb;
+} grxsts_data_t;
+
+/*!
+ \brief Bit fields in the FIFO Size Registers (HPTXFSIZ, GNPTXFSIZ, DPTXFSIZn).
+ */
+typedef union fifosize_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned depth : 16; /*!< 31-16 TxFIFO Depth (in DWord)*/
+ unsigned startaddr : 16; /*!< 15-00 RAM Starting address */
+ } b;
+} fifosize_data_t;
+
+/*!
+ \brief Bit fields in the Non-Periodic Transmit FIFO/Queue Status Register (GNPTXSTS).
+ */
+
+typedef union gnptxsts_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned reserved : 1;
+ unsigned nptxqtop_chnep : 4; /*!< 30-27 Channel/EP Number of top of the Non-Periodic
+ Transmit Request Queue
+ */
+ unsigned nptxqtop_token : 2; /*!< 26-25 Token Type top of the Non-Periodic
+ Transmit Request Queue
+ 0 - IN/OUT
+ 1 - Zero Length OUT
+ 2 - PING/Complete Split
+ 3 - Channel Halt
+ */
+ unsigned nptxqtop_terminate : 1; /*!< 24 Terminate (Last entry for the selected
+ channel/EP)*/
+ unsigned nptxqspcavail : 8; /*!< 23-16 Transmit Request Queue Space Available */
+ unsigned nptxfspcavail :16; /*!< 15-00 TxFIFO Space Avail (in DWord)*/
+ }b;
+} gnptxsts_data_t;
+
+
+/*!
+ \brief Bit fields in the Transmit FIFO Status Register (DTXFSTS).
+ */
+typedef union dtxfsts_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned reserved : 16;
+ unsigned txfspcavail : 16; /*!< 15-00 TxFIFO Space Avail (in DWord)*/
+ }b;
+} dtxfsts_data_t;
+
+
+/*!
+ \brief Bit fields in the I2C Control Register (I2CCTL).
+ */
+typedef union gi2cctl_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned bsydne : 1; /*!< 31 I2C Busy/Done*/
+ unsigned rw : 1; /*!< 30 Read/Write Indicator */
+ unsigned reserved : 2;
+ unsigned i2cdevaddr : 2; /*!< 27-26 I2C Device Address */
+ unsigned i2csuspctl : 1; /*!< 25 I2C Suspend Control */
+ unsigned ack : 1; /*!< 24 I2C ACK */
+ unsigned i2cen : 1; /*!< 23 I2C Enable */
+ unsigned addr : 7; /*!< 22-16 I2C Address */
+ unsigned regaddr : 8; /*!< 15-08 I2C Register Addr */
+ unsigned rwdata : 8; /*!< I2C Read/Write Data */
+ } b;
+} gi2cctl_data_t;
+
+
+/*!
+ \brief Bit fields in the User HW Config1 Register.
+ */
+typedef union hwcfg1_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned ep_dir15 : 2; /*!< Direction of each EP
+ 0: BIDIR (IN and OUT) endpoint
+ 1: IN endpoint
+ 2: OUT endpoint
+ 3: Reserved
+ */
+ unsigned ep_dir14 : 2;
+ unsigned ep_dir13 : 2;
+ unsigned ep_dir12 : 2;
+ unsigned ep_dir11 : 2;
+ unsigned ep_dir10 : 2;
+ unsigned ep_dir09 : 2;
+ unsigned ep_dir08 : 2;
+ unsigned ep_dir07 : 2;
+ unsigned ep_dir06 : 2;
+ unsigned ep_dir05 : 2;
+ unsigned ep_dir04 : 2;
+ unsigned ep_dir03 : 2;
+ unsigned ep_dir02 : 2;
+ unsigned ep_dir01 : 2;
+ unsigned ep_dir00 : 2;
+ }b;
+} hwcfg1_data_t;
+
+/*!
+ \brief Bit fields in the User HW Config2 Register.
+ */
+typedef union hwcfg2_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned reserved31 : 1;
+ unsigned dev_token_q_depth : 5; /*!< 30-26 Device Mode IN Token Sequence Learning Queue Depth */
+ unsigned host_perio_tx_q_depth : 2; /*!< 25-24 Host Mode Periodic Request Queue Depth */
+ unsigned nonperio_tx_q_depth : 2; /*!< 23-22 Non-periodic Request Queue Depth */
+ unsigned rx_status_q_depth : 2; /*!< 21-20 Multi Processor Interrupt Enabled */
+ unsigned dynamic_fifo : 1; /*!< 19 Dynamic FIFO Sizing Enabled */
+ unsigned perio_ep_supported : 1; /*!< 18 Periodic OUT Channels Supported in Host Mode */
+ unsigned num_host_chan : 4; /*!< 17-14 Number of Host Channels */
+ unsigned num_dev_ep : 4; /*!< 13-10 Number of Device Endpoints */
+ unsigned fs_phy_type : 2; /*!< 09-08 Full-Speed PHY Interface Type */
+ #define IFXUSB_HWCFG2_FS_PHY_TYPE_NOT_SUPPORTED 0
+ #define IFXUSB_HWCFG2_FS_PHY_TYPE_DEDICATE 1
+ #define IFXUSB_HWCFG2_FS_PHY_TYPE_UTMI 2
+ #define IFXUSB_HWCFG2_FS_PHY_TYPE_ULPI 3
+ unsigned hs_phy_type : 2; /*!< 07-06 High-Speed PHY Interface Type */
+ #define IFXUSB_HWCFG2_HS_PHY_TYPE_NOT_SUPPORTED 0
+ #define IFXUSB_HWCFG2_HS_PHY_TYPE_UTMI 1
+ #define IFXUSB_HWCFG2_HS_PHY_TYPE_ULPI 2
+ #define IFXUSB_HWCFG2_HS_PHY_TYPE_UTMI_ULPI 3
+ unsigned point2point : 1; /*!< 05 Point-to-Point */
+ unsigned architecture : 2; /*!< 04-03 Architecture */
+ #define IFXUSB_HWCFG2_ARCH_SLAVE_ONLY 0
+ #define IFXUSB_HWCFG2_ARCH_EXT_DMA 1
+ #define IFXUSB_HWCFG2_ARCH_INT_DMA 2
+ unsigned op_mode : 3; /*!< 02-00 Mode of Operation */
+ #define IFXUSB_HWCFG2_OP_MODE_HNP_SRP_CAPABLE_OTG 0
+ #define IFXUSB_HWCFG2_OP_MODE_SRP_ONLY_CAPABLE_OTG 1
+ #define IFXUSB_HWCFG2_OP_MODE_NO_HNP_SRP_CAPABLE_OTG 2
+ #define IFXUSB_HWCFG2_OP_MODE_SRP_CAPABLE_DEVICE 3
+ #define IFXUSB_HWCFG2_OP_MODE_NO_SRP_CAPABLE_DEVICE 4
+ #define IFXUSB_HWCFG2_OP_MODE_SRP_CAPABLE_HOST 5
+ #define IFXUSB_HWCFG2_OP_MODE_NO_SRP_CAPABLE_HOST 6
+ } b;
+} hwcfg2_data_t;
+
+/*!
+ \brief Bit fields in the User HW Config3 Register.
+ */
+typedef union hwcfg3_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned dfifo_depth :16; /*!< 31-16 DFIFO Depth */
+ unsigned reserved15_12 : 4;
+ unsigned synch_reset_type : 1; /*!< 11 Reset Style for Clocked always Blocks in RTL */
+ unsigned optional_features : 1; /*!< 10 Optional Features Removed */
+ unsigned vendor_ctrl_if : 1; /*!< 09 Vendor Control Interface Support */
+ unsigned i2c : 1; /*!< 08 I2C Selection */
+ unsigned otg_func : 1; /*!< 07 OTG Function Enabled */
+ unsigned packet_size_cntr_width : 3; /*!< 06-04 Width of Packet Size Counters */
+ unsigned xfer_size_cntr_width : 4; /*!< 03-00 Width of Transfer Size Counters */
+ } b;
+} hwcfg3_data_t;
+
+/*!
+ \brief Bit fields in the User HW Config4
+ * Register. Read the register into the <i>d32</i> element then read
+ * out the bits using the <i>b</i>it elements.
+ */
+typedef union hwcfg4_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned desc_dma_dyn : 1; /*!< 31 Scatter/Gather DMA */
+ unsigned desc_dma : 1; /*!< 30 Scatter/Gather DMA configuration */
+ unsigned num_in_eps : 4; /*!< 29-26 Number of Device Mode IN Endpoints Including Control Endpoints */
+ unsigned ded_fifo_en : 1; /*!< 25 Enable Dedicated Transmit FIFO for device IN Endpoints */
+ unsigned session_end_filt_en : 1; /*!< 24 session_end Filter Enabled */
+ unsigned b_valid_filt_en : 1; /*!< 23 b_valid Filter Enabled */
+ unsigned a_valid_filt_en : 1; /*!< 22 a_valid Filter Enabled */
+ unsigned vbus_valid_filt_en : 1; /*!< 21 vbus_valid Filter Enabled */
+ unsigned iddig_filt_en : 1; /*!< 20 iddig Filter Enable */
+ unsigned num_dev_mode_ctrl_ep : 4; /*!< 19-16 Number of Device Mode Control Endpoints in Addition to Endpoint 0 */
+ unsigned utmi_phy_data_width : 2; /*!< 15-14 UTMI+ PHY/ULPI-to-Internal UTMI+ Wrapper Data Width */
+ unsigned reserved13_06 : 8;
+ unsigned min_ahb_freq : 1; /*!< 05 Minimum AHB Frequency Less Than 60 MHz */
+ unsigned power_optimiz : 1; /*!< 04 Enable Power Optimization? */
+ unsigned num_dev_perio_in_ep : 4; /*!< 03-00 Number of Device Mode Periodic IN Endpoints */
+ } b;
+} hwcfg4_data_t;
+
+/*@}*//*IFXUSB_CSR_CORE_GLOBAL_REG*/
+
+/****************************************************************************/
+/*!
+ \addtogroup IFXUSB_CSR_DEVICE_GLOBAL_REG
+ */
+/*@{*/
+
+/*! typedef ifxusb_dev_global_regs_t
+ \brief IFXUSB Device Mode Global registers. Offsets 800h-BFFh
+ The ifxusb_dev_global_regs structure defines the size
+ and relative field offsets for the Device Global registers.
+ These registers are visible only in Device mode and must not be
+ accessed in Host mode, as the results are unknown.
+ */
+typedef struct ifxusb_dev_global_regs
+{
+ volatile uint32_t dcfg; /*!< 800h Device Configuration Register. */
+ volatile uint32_t dctl; /*!< 804h Device Control Register. */
+ volatile uint32_t dsts; /*!< 808h Device Status Register (Read Only). */
+ uint32_t unused;
+ volatile uint32_t diepmsk; /*!< 810h Device IN Endpoint Common Interrupt Mask Register. */
+ volatile uint32_t doepmsk; /*!< 814h Device OUT Endpoint Common Interrupt Mask Register. */
+ volatile uint32_t daint; /*!< 818h Device All Endpoints Interrupt Register. */
+ volatile uint32_t daintmsk; /*!< 81Ch Device All Endpoints Interrupt Mask Register. */
+ volatile uint32_t dtknqr1; /*!< 820h Device IN Token Queue Read Register-1 (Read Only). */
+ volatile uint32_t dtknqr2; /*!< 824h Device IN Token Queue Read Register-2 (Read Only). */
+ volatile uint32_t dvbusdis; /*!< 828h Device VBUS discharge Register.*/
+ volatile uint32_t dvbuspulse; /*!< 82Ch Device VBUS Pulse Register. */
+ volatile uint32_t dtknqr3_dthrctl; /*!< 830h Device IN Token Queue Read Register-3 (Read Only).
+ Device Thresholding control register (Read/Write)
+ */
+ volatile uint32_t dtknqr4_fifoemptymsk; /*!< 834h Device IN Token Queue Read Register-4 (Read Only).
+ Device IN EPs empty Inr. Mask Register (Read/Write)
+ */
+} ifxusb_device_global_regs_t;
+
+/*!
+ \brief Bit fields in the Device Configuration Register.
+ */
+
+typedef union dcfg_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned reserved31_26 : 6;
+ unsigned perschintvl : 2; /*!< 25-24 Periodic Scheduling Interval */
+ unsigned descdma : 1; /*!< 23 Enable Descriptor DMA in Device mode */
+ unsigned epmscnt : 5; /*!< 22-18 In Endpoint Mis-match count */
+ unsigned reserved13_17 : 5;
+ unsigned perfrint : 2; /*!< 12-11 Periodic Frame Interval */
+ #define IFXUSB_DCFG_FRAME_INTERVAL_80 0
+ #define IFXUSB_DCFG_FRAME_INTERVAL_85 1
+ #define IFXUSB_DCFG_FRAME_INTERVAL_90 2
+ #define IFXUSB_DCFG_FRAME_INTERVAL_95 3
+ unsigned devaddr : 7; /*!< 10-04 Device Addresses */
+ unsigned reserved3 : 1;
+ unsigned nzstsouthshk : 1; /*!< 02 Non Zero Length Status OUT Handshake */
+ #define IFXUSB_DCFG_SEND_STALL 1
+ unsigned devspd : 2; /*!< 01-00 Device Speed */
+ } b;
+} dcfg_data_t;
+
+/*!
+ \brief Bit fields in the Device Control Register.
+ */
+typedef union dctl_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned reserved16_31 :16;
+ unsigned ifrmnum : 1; /*!< 15 Ignore Frame Number for ISOC EPs */
+ unsigned gmc : 2; /*!< 14-13 Global Multi Count */
+ unsigned gcontbna : 1; /*!< 12 Global Continue on BNA */
+ unsigned pwronprgdone : 1; /*!< 11 Power-On Programming Done */
+ unsigned cgoutnak : 1; /*!< 10 Clear Global OUT NAK */
+ unsigned sgoutnak : 1; /*!< 09 Set Global OUT NAK */
+ unsigned cgnpinnak : 1; /*!< 08 Clear Global Non-Periodic IN NAK */
+ unsigned sgnpinnak : 1; /*!< 07 Set Global Non-Periodic IN NAK */
+ unsigned tstctl : 3; /*!< 06-04 Test Control */
+ unsigned goutnaksts : 1; /*!< 03 Global OUT NAK Status */
+ unsigned gnpinnaksts : 1; /*!< 02 Global Non-Periodic IN NAK Status */
+ unsigned sftdiscon : 1; /*!< 01 Soft Disconnect */
+ unsigned rmtwkupsig : 1; /*!< 00 Remote Wakeup */
+ } b;
+} dctl_data_t;
+
+
+/*!
+ \brief Bit fields in the Device Status Register.
+ */
+typedef union dsts_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned reserved22_31 :10;
+ unsigned soffn :14; /*!< 21-08 Frame or Microframe Number of the received SOF */
+ unsigned reserved4_7 : 4;
+ unsigned errticerr : 1; /*!< 03 Erratic Error */
+ unsigned enumspd : 2; /*!< 02-01 Enumerated Speed */
+ #define IFXUSB_DSTS_ENUMSPD_HS_PHY_30MHZ_OR_60MHZ 0
+ #define IFXUSB_DSTS_ENUMSPD_FS_PHY_30MHZ_OR_60MHZ 1
+ #define IFXUSB_DSTS_ENUMSPD_LS_PHY_6MHZ 2
+ #define IFXUSB_DSTS_ENUMSPD_FS_PHY_48MHZ 3
+ unsigned suspsts : 1; /*!< 00 Suspend Status */
+ } b;
+} dsts_data_t;
+
+/*!
+ \brief Bit fields in the Device IN EP Interrupt Register
+ and the Device IN EP Common Mask Register.
+ */
+typedef union diepint_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned reserved14_31 :18;
+ unsigned nakmsk : 1; /*!< 13 NAK interrupt Mask */
+ unsigned reserved10_12 : 3;
+ unsigned bna : 1; /*!< 09 BNA Interrupt mask */
+ unsigned txfifoundrn : 1; /*!< 08 Fifo Underrun Mask */
+ unsigned emptyintr : 1; /*!< 07 IN Endpoint HAK Effective mask */
+ unsigned inepnakeff : 1; /*!< 06 IN Endpoint HAK Effective mask */
+ unsigned intknepmis : 1; /*!< 05 IN Token Received with EP mismatch mask */
+ unsigned intktxfemp : 1; /*!< 04 IN Token received with TxF Empty mask */
+ unsigned timeout : 1; /*!< 03 TimeOUT Handshake mask (non-ISOC EPs) */
+ unsigned ahberr : 1; /*!< 02 AHB Error mask */
+ unsigned epdisabled : 1; /*!< 01 Endpoint disable mask */
+ unsigned xfercompl : 1; /*!< 00 Transfer complete mask */
+ } b;
+} diepint_data_t;
+
+
+/*!
+ \brief Bit fields in the Device OUT EP Interrupt Register and
+ Device OUT EP Common Interrupt Mask Register.
+ */
+typedef union doepint_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned reserved15_31 :17;
+ unsigned nyetmsk : 1; /*!< 14 NYET Interrupt */
+ unsigned nakmsk : 1; /*!< 13 NAK Interrupt */
+ unsigned bbleerrmsk : 1; /*!< 12 Babble Interrupt */
+ unsigned reserved10_11 : 2;
+ unsigned bna : 1; /*!< 09 BNA Interrupt */
+ unsigned outpkterr : 1; /*!< 08 OUT packet Error */
+ unsigned reserved07 : 1;
+ unsigned back2backsetup : 1; /*!< 06 Back-to-Back SETUP Packets Received */
+ unsigned stsphsercvd : 1; /*!< 05 */
+ unsigned outtknepdis : 1; /*!< 04 OUT Token Received when Endpoint Disabled */
+ unsigned setup : 1; /*!< 03 Setup Phase Done (contorl EPs) */
+ unsigned ahberr : 1; /*!< 02 AHB Error */
+ unsigned epdisabled : 1; /*!< 01 Endpoint disable */
+ unsigned xfercompl : 1; /*!< 00 Transfer complete */
+ } b;
+} doepint_data_t;
+
+
+/*!
+ \brief Bit fields in the Device All EP Interrupt Registers.
+ */
+typedef union daint_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned out : 16; /*!< 31-16 OUT Endpoint bits */
+ unsigned in : 16; /*!< 15-00 IN Endpoint bits */
+ } eps;
+ struct
+ {
+ /** OUT Endpoint bits */
+ unsigned outep15 : 1;
+ unsigned outep14 : 1;
+ unsigned outep13 : 1;
+ unsigned outep12 : 1;
+ unsigned outep11 : 1;
+ unsigned outep10 : 1;
+ unsigned outep09 : 1;
+ unsigned outep08 : 1;
+ unsigned outep07 : 1;
+ unsigned outep06 : 1;
+ unsigned outep05 : 1;
+ unsigned outep04 : 1;
+ unsigned outep03 : 1;
+ unsigned outep02 : 1;
+ unsigned outep01 : 1;
+ unsigned outep00 : 1;
+ /** IN Endpoint bits */
+ unsigned inep15 : 1;
+ unsigned inep14 : 1;
+ unsigned inep13 : 1;
+ unsigned inep12 : 1;
+ unsigned inep11 : 1;
+ unsigned inep10 : 1;
+ unsigned inep09 : 1;
+ unsigned inep08 : 1;
+ unsigned inep07 : 1;
+ unsigned inep06 : 1;
+ unsigned inep05 : 1;
+ unsigned inep04 : 1;
+ unsigned inep03 : 1;
+ unsigned inep02 : 1;
+ unsigned inep01 : 1;
+ unsigned inep00 : 1;
+ } ep;
+} daint_data_t;
+
+
+/*!
+ \brief Bit fields in the Device IN Token Queue Read Registers.
+ */
+typedef union dtknq1_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned epnums0_5 :24; /*!< 31-08 EP Numbers of IN Tokens 0 ... 4 */
+ unsigned wrap_bit : 1; /*!< 07 write pointer has wrapped */
+ unsigned reserved05_06 : 2;
+ unsigned intknwptr : 5; /*!< 04-00 In Token Queue Write Pointer */
+ }b;
+} dtknq1_data_t;
+
+
+/*!
+ \brief Bit fields in Threshold control Register
+ */
+typedef union dthrctl_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned reserved26_31 : 6;
+ unsigned rx_thr_len : 9; /*!< 25-17 Rx Thr. Length */
+ unsigned rx_thr_en : 1; /*!< 16 Rx Thr. Enable */
+ unsigned reserved11_15 : 5;
+ unsigned tx_thr_len : 9; /*!< 10-02 Tx Thr. Length */
+ unsigned iso_thr_en : 1; /*!< 01 ISO Tx Thr. Enable */
+ unsigned non_iso_thr_en : 1; /*!< 00 non ISO Tx Thr. Enable */
+ } b;
+} dthrctl_data_t;
+
+/*@}*//*IFXUSB_CSR_DEVICE_GLOBAL_REG*/
+
+/****************************************************************************/
+
+/*!
+ \addtogroup IFXUSB_CSR_DEVICE_EP_REG
+ */
+/*@{*/
+
+/*! typedef ifxusb_dev_in_ep_regs_t
+ \brief Device Logical IN Endpoint-Specific Registers.
+ There will be one set of endpoint registers per logical endpoint
+ implemented.
+ each EP's IN EP Register are offset at :
+ 900h + * (ep_num * 20h)
+ */
+
+typedef struct ifxusb_dev_in_ep_regs
+{
+ volatile uint32_t diepctl; /*!< 00h: Endpoint Control Register */
+ uint32_t reserved04; /*!< 04h: */
+ volatile uint32_t diepint; /*!< 08h: Endpoint Interrupt Register */
+ uint32_t reserved0C; /*!< 0Ch: */
+ volatile uint32_t dieptsiz; /*!< 10h: Endpoint Transfer Size Register.*/
+ volatile uint32_t diepdma; /*!< 14h: Endpoint DMA Address Register. */
+ volatile uint32_t dtxfsts; /*!< 18h: Endpoint Transmit FIFO Status Register. */
+ volatile uint32_t diepdmab; /*!< 1Ch: Endpoint DMA Buffer Register. */
+} ifxusb_dev_in_ep_regs_t;
+
+/*! typedef ifxusb_dev_out_ep_regs_t
+ \brief Device Logical OUT Endpoint-Specific Registers.
+ There will be one set of endpoint registers per logical endpoint
+ implemented.
+ each EP's OUT EP Register are offset at :
+ B00h + * (ep_num * 20h) + 00h
+ */
+typedef struct ifxusb_dev_out_ep_regs
+{
+ volatile uint32_t doepctl; /*!< 00h: Endpoint Control Register */
+ volatile uint32_t doepfn; /*!< 04h: Endpoint Frame number Register */
+ volatile uint32_t doepint; /*!< 08h: Endpoint Interrupt Register */
+ uint32_t reserved0C; /*!< 0Ch: */
+ volatile uint32_t doeptsiz; /*!< 10h: Endpoint Transfer Size Register.*/
+ volatile uint32_t doepdma; /*!< 14h: Endpoint DMA Address Register. */
+ uint32_t reserved18; /*!< 18h: */
+ volatile uint32_t doepdmab; /*!< 1Ch: Endpoint DMA Buffer Register. */
+} ifxusb_dev_out_ep_regs_t;
+
+
+/*!
+ \brief Bit fields in the Device EP Control
+ Register.
+ */
+typedef union depctl_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned epena : 1; /*!< 31 Endpoint Enable */
+ unsigned epdis : 1; /*!< 30 Endpoint Disable */
+ unsigned setd1pid : 1; /*!< 29 Set DATA1 PID (INTR/Bulk IN and OUT endpoints) */
+ unsigned setd0pid : 1; /*!< 28 Set DATA0 PID (INTR/Bulk IN and OUT endpoints) */
+ unsigned snak : 1; /*!< 27 Set NAK */
+ unsigned cnak : 1; /*!< 26 Clear NAK */
+ unsigned txfnum : 4; /*!< 25-22 Tx Fifo Number */
+ unsigned stall : 1; /*!< 21 Stall Handshake */
+ unsigned snp : 1; /*!< 20 Snoop Mode */
+ unsigned eptype : 2; /*!< 19-18 Endpoint Type
+ 0: Control
+ 1: Isochronous
+ 2: Bulk
+ 3: Interrupt
+ */
+ unsigned naksts : 1; /*!< 17 NAK Status */
+ unsigned dpid : 1; /*!< 16 Endpoint DPID (INTR/Bulk IN and OUT endpoints) */
+ unsigned usbactep : 1; /*!< 15 USB Active Endpoint */
+ unsigned nextep : 4; /*!< 14-11 Next Endpoint */
+ unsigned mps :11; /*!< 10-00 Maximum Packet Size */
+ #define IFXUSB_DEP0CTL_MPS_64 0
+ #define IFXUSB_DEP0CTL_MPS_32 1
+ #define IFXUSB_DEP0CTL_MPS_16 2
+ #define IFXUSB_DEP0CTL_MPS_8 3
+ } b;
+} depctl_data_t;
+
+
+/*!
+ \brief Bit fields in the Device EP Transfer Size Register. (EP0 and EPn)
+ */
+typedef union deptsiz_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned reserved31 : 1;
+ unsigned supcnt : 2; /*!< 30-29 Setup Packet Count */
+ #ifdef __DED_FIFO__
+ unsigned reserved21_28 : 8;
+ unsigned pktcnt : 2; /*!< 19-20 Packet Count */
+ #else
+ unsigned reserved20_28 : 9;
+ unsigned pktcnt : 1; /*!< 19 Packet Count */
+ #endif
+ unsigned reserved7_18 :12;
+ unsigned xfersize : 7; /*!< 06-00 Transfer size */
+ }b0;
+ struct
+ {
+ unsigned reserved : 1;
+ unsigned mc : 2; /*!< 30-29 Multi Count */
+ unsigned pktcnt :10; /*!< 28-19 Packet Count */
+ unsigned xfersize :19; /*!< 18-00 Transfer size */
+ } b;
+} deptsiz_data_t;
+
+/*@}*//*IFXUSB_CSR_DEVICE_EP_REG*/
+/****************************************************************************/
+
+/*!
+ \addtogroup IFXUSB_CSR_DEVICE_DMA_DESC
+ */
+/*@{*/
+/*!
+ \brief Bit fields in the DMA Descriptor status quadlet.
+ */
+typedef union desc_sts_data
+{
+ struct
+ {
+ unsigned bs : 2; /*!< 31-30 Buffer Status */
+ #define BS_HOST_READY 0x0
+ #define BS_DMA_BUSY 0x1
+ #define BS_DMA_DONE 0x2
+ #define BS_HOST_BUSY 0x3
+ unsigned sts : 2; /*!< 29-28 Receive/Trasmit Status */
+ #define RTS_SUCCESS 0x0
+ #define RTS_BUFFLUSH 0x1
+ #define RTS_RESERVED 0x2
+ #define RTS_BUFERR 0x3
+ unsigned l : 1; /*!< 27 Last */
+ unsigned sp : 1; /*!< 26 Short Packet */
+ unsigned ioc : 1; /*!< 25 Interrupt On Complete */
+ unsigned sr : 1; /*!< 24 Setup Packet received */
+ unsigned mtrf : 1; /*!< 23 Multiple Transfer */
+ unsigned reserved16_22 : 7;
+ unsigned bytes :16; /*!< 15-00 Transfer size in bytes */
+ } b;
+ uint32_t d32; /*!< DMA Descriptor data buffer pointer */
+} desc_sts_data_t;
+
+/*@}*//*IFXUSB_CSR_DEVICE_DMA_DESC*/
+/****************************************************************************/
+
+/*!
+ \addtogroup IFXUSB_CSR_HOST_GLOBAL_REG
+ */
+/*@{*/
+/*! typedef ifxusb_host_global_regs_t
+ \brief IFXUSB Host Mode Global registers. Offsets 400h-7FFh
+ The ifxusb_host_global_regs structure defines the size
+ and relative field offsets for the Host Global registers.
+ These registers are visible only in Host mode and must not be
+ accessed in Device mode, as the results are unknown.
+ */
+typedef struct ifxusb_host_global_regs
+{
+ volatile uint32_t hcfg; /*!< 400h Host Configuration Register. */
+ volatile uint32_t hfir; /*!< 404h Host Frame Interval Register. */
+ volatile uint32_t hfnum; /*!< 408h Host Frame Number / Frame Remaining Register. */
+ uint32_t reserved40C;
+ volatile uint32_t hptxsts; /*!< 410h Host Periodic Transmit FIFO/ Queue Status Register. */
+ volatile uint32_t haint; /*!< 414h Host All Channels Interrupt Register. */
+ volatile uint32_t haintmsk; /*!< 418h Host All Channels Interrupt Mask Register. */
+} ifxusb_host_global_regs_t;
+
+/*!
+ \brief Bit fields in the Host Configuration Register.
+ */
+typedef union hcfg_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned reserved31_03 :29;
+ unsigned fslssupp : 1; /*!< 02 FS/LS Only Support */
+ unsigned fslspclksel : 2; /*!< 01-00 FS/LS Phy Clock Select */
+ #define IFXUSB_HCFG_30_60_MHZ 0
+ #define IFXUSB_HCFG_48_MHZ 1
+ #define IFXUSB_HCFG_6_MHZ 2
+ } b;
+} hcfg_data_t;
+
+/*!
+ \brief Bit fields in the Host Frame Interval Register.
+ */
+typedef union hfir_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned reserved : 16;
+ unsigned frint : 16; /*!< 15-00 Frame Interval */
+ } b;
+} hfir_data_t;
+
+/*!
+ \brief Bit fields in the Host Frame Time Remaing/Number Register.
+ */
+typedef union hfnum_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned frrem : 16; /*!< 31-16 Frame Time Remaining */
+ unsigned frnum : 16; /*!< 15-00 Frame Number*/
+ #define IFXUSB_HFNUM_MAX_FRNUM 0x3FFF
+ } b;
+} hfnum_data_t;
+
+/*!
+ \brief Bit fields in the Host Periodic Transmit FIFO/Queue Status Register
+ */
+typedef union hptxsts_data
+{
+ /** raw register data */
+ uint32_t d32;
+ struct
+ {
+ /** Top of the Periodic Transmit Request Queue
+ * - bit 24 - Terminate (last entry for the selected channel)
+ */
+ unsigned ptxqtop_odd : 1; /*!< 31 Top of the Periodic Transmit Request
+ Queue Odd/even microframe*/
+ unsigned ptxqtop_chnum : 4; /*!< 30-27 Top of the Periodic Transmit Request
+ Channel Number */
+ unsigned ptxqtop_token : 2; /*!< 26-25 Top of the Periodic Transmit Request
+ Token Type
+ 0 - Zero length
+ 1 - Ping
+ 2 - Disable
+ */
+ unsigned ptxqtop_terminate : 1; /*!< 24 Top of the Periodic Transmit Request
+ Terminate (last entry for the selected channel)*/
+ unsigned ptxqspcavail : 8; /*!< 23-16 Periodic Transmit Request Queue Space Available */
+ unsigned ptxfspcavail :16; /*!< 15-00 Periodic Transmit Data FIFO Space Available */
+ } b;
+} hptxsts_data_t;
+
+/*!
+ \brief Bit fields in the Host Port Control and Status Register.
+ */
+typedef union hprt0_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned reserved19_31 :13;
+ unsigned prtspd : 2; /*!< 18-17 Port Speed */
+ #define IFXUSB_HPRT0_PRTSPD_HIGH_SPEED 0
+ #define IFXUSB_HPRT0_PRTSPD_FULL_SPEED 1
+ #define IFXUSB_HPRT0_PRTSPD_LOW_SPEED 2
+ unsigned prttstctl : 4; /*!< 16-13 Port Test Control */
+ unsigned prtpwr : 1; /*!< 12 Port Power */
+ unsigned prtlnsts : 2; /*!< 11-10 Port Line Status */
+ unsigned reserved9 : 1;
+ unsigned prtrst : 1; /*!< 08 Port Reset */
+ unsigned prtsusp : 1; /*!< 07 Port Suspend */
+ unsigned prtres : 1; /*!< 06 Port Resume */
+ unsigned prtovrcurrchng : 1; /*!< 05 Port Overcurrent Change */
+ unsigned prtovrcurract : 1; /*!< 04 Port Overcurrent Active */
+ unsigned prtenchng : 1; /*!< 03 Port Enable/Disable Change */
+ unsigned prtena : 1; /*!< 02 Port Enable */
+ unsigned prtconndet : 1; /*!< 01 Port Connect Detected */
+ unsigned prtconnsts : 1; /*!< 00 Port Connect Status */
+ }b;
+} hprt0_data_t;
+
+/*!
+ \brief Bit fields in the Host All Interrupt Register.
+ */
+typedef union haint_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned reserved : 16;
+ unsigned ch15 : 1;
+ unsigned ch14 : 1;
+ unsigned ch13 : 1;
+ unsigned ch12 : 1;
+ unsigned ch11 : 1;
+ unsigned ch10 : 1;
+ unsigned ch09 : 1;
+ unsigned ch08 : 1;
+ unsigned ch07 : 1;
+ unsigned ch06 : 1;
+ unsigned ch05 : 1;
+ unsigned ch04 : 1;
+ unsigned ch03 : 1;
+ unsigned ch02 : 1;
+ unsigned ch01 : 1;
+ unsigned ch00 : 1;
+ } b;
+ struct
+ {
+ unsigned reserved : 16;
+ unsigned chint : 16;
+ } b2;
+} haint_data_t;
+/*@}*//*IFXUSB_CSR_HOST_GLOBAL_REG*/
+/****************************************************************************/
+/*!
+ \addtogroup IFXUSB_CSR_HOST_HC_REG
+ */
+/*@{*/
+/*! typedef ifxusb_hc_regs_t
+ \brief Host Channel Specific Registers
+ There will be one set of hc registers per host channelimplemented.
+ each HC's Register are offset at :
+ 500h + * (hc_num * 20h)
+ */
+typedef struct ifxusb_hc_regs
+{
+ volatile uint32_t hcchar; /*!< 00h Host Channel Characteristic Register.*/
+ volatile uint32_t hcsplt; /*!< 04h Host Channel Split Control Register.*/
+ volatile uint32_t hcint; /*!< 08h Host Channel Interrupt Register. */
+ volatile uint32_t hcintmsk; /*!< 0Ch Host Channel Interrupt Mask Register. */
+ volatile uint32_t hctsiz; /*!< 10h Host Channel Transfer Size Register. */
+ volatile uint32_t hcdma; /*!< 14h Host Channel DMA Address Register. */
+ uint32_t reserved[2]; /*!< 18h Reserved. */
+} ifxusb_hc_regs_t;
+
+
+/*!
+ \brief Bit fields in the Host Channel Characteristics Register.
+ */
+typedef union hcchar_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned chen : 1; /*!< 31 Channel enable */
+ unsigned chdis : 1; /*!< 30 Channel disable */
+ unsigned oddfrm : 1; /*!< 29 Frame to transmit periodic transaction */
+ unsigned devaddr : 7; /*!< 28-22 Device address */
+ unsigned multicnt : 2; /*!< 21-20 Packets per frame for periodic transfers */
+ unsigned eptype : 2; /*!< 19-18 0: Control, 1: Isoc, 2: Bulk, 3: Intr */
+ unsigned lspddev : 1; /*!< 17 0: Full/high speed device, 1: Low speed device */
+ unsigned reserved : 1;
+ unsigned epdir : 1; /*!< 15 0: OUT, 1: IN */
+ unsigned epnum : 4; /*!< 14-11 Endpoint number */
+ unsigned mps :11; /*!< 10-00 Maximum packet size in bytes */
+ } b;
+} hcchar_data_t;
+
+/*!
+ \brief Bit fields in the Host Channel Split Control Register
+ */
+typedef union hcsplt_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned spltena : 1; /*!< 31 Split Enble */
+ unsigned reserved :14;
+ unsigned compsplt : 1; /*!< 16 Do Complete Split */
+ unsigned xactpos : 2; /*!< 15-14 Transaction Position */
+ #define IFXUSB_HCSPLIT_XACTPOS_MID 0
+ #define IFXUSB_HCSPLIT_XACTPOS_END 1
+ #define IFXUSB_HCSPLIT_XACTPOS_BEGIN 2
+ #define IFXUSB_HCSPLIT_XACTPOS_ALL 3
+ unsigned hubaddr : 7; /*!< 13-07 Hub Address */
+ unsigned prtaddr : 7; /*!< 06-00 Port Address */
+ } b;
+} hcsplt_data_t;
+
+/*!
+ \brief Bit fields in the Host Interrupt Register.
+ */
+typedef union hcint_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned reserved :21;
+ unsigned datatglerr : 1; /*!< 10 Data Toggle Error */
+ unsigned frmovrun : 1; /*!< 09 Frame Overrun */
+ unsigned bblerr : 1; /*!< 08 Babble Error */
+ unsigned xacterr : 1; /*!< 07 Transaction Err */
+ unsigned nyet : 1; /*!< 06 NYET Response Received */
+ unsigned ack : 1; /*!< 05 ACK Response Received */
+ unsigned nak : 1; /*!< 04 NAK Response Received */
+ unsigned stall : 1; /*!< 03 STALL Response Received */
+ unsigned ahberr : 1; /*!< 02 AHB Error */
+ unsigned chhltd : 1; /*!< 01 Channel Halted */
+ unsigned xfercomp : 1; /*!< 00 Channel Halted */
+ }b;
+} hcint_data_t;
+
+
+/*!
+ \brief Bit fields in the Host Channel Transfer Size
+ Register.
+ */
+typedef union hctsiz_data
+{
+ uint32_t d32;
+ struct
+ {
+ /** */
+ unsigned dopng : 1; /*!< 31 Do PING protocol when 1 */
+ /**
+ * Packet ID for next data packet
+ * 0: DATA0
+ * 1: DATA2
+ * 2: DATA1
+ * 3: MDATA (non-Control), SETUP (Control)
+ */
+ unsigned pid : 2; /*!< 30-29 Packet ID for next data packet
+ 0: DATA0
+ 1: DATA2
+ 2: DATA1
+ 3: MDATA (non-Control), SETUP (Control)
+ */
+ #define IFXUSB_HCTSIZ_DATA0 0
+ #define IFXUSB_HCTSIZ_DATA1 2
+ #define IFXUSB_HCTSIZ_DATA2 1
+ #define IFXUSB_HCTSIZ_MDATA 3
+ #define IFXUSB_HCTSIZ_SETUP 3
+ unsigned pktcnt :10; /*!< 28-19 Data packets to transfer */
+ unsigned xfersize :19; /*!< 18-00 Total transfer size in bytes */
+ }b;
+} hctsiz_data_t;
+
+/*@}*//*IFXUSB_CSR_HOST_HC_REG*/
+
+/****************************************************************************/
+
+/*!
+ \addtogroup IFXUSB_CSR_PWR_CLK_GATING_REG
+ */
+/*@{*/
+/*!
+ \brief Bit fields in the Power and Clock Gating Control Register
+ */
+typedef union pcgcctl_data
+{
+ uint32_t d32;
+ struct
+ {
+ unsigned reserved : 27;
+ unsigned physuspended : 1; /*!< 04 PHY Suspended */
+ unsigned rstpdwnmodule : 1; /*!< 03 Reset Power Down Modules */
+ unsigned pwrclmp : 1; /*!< 02 Power Clamp */
+ unsigned gatehclk : 1; /*!< 01 Gate Hclk */
+ unsigned stoppclk : 1; /*!< 00 Stop Pclk */
+ } b;
+} pcgcctl_data_t;
+/*@}*//*IFXUSB_CSR_PWR_CLK_GATING_REG*/
+
+/****************************************************************************/
+
+#endif //__IFXUSB_REGS_H__
diff --git a/package/platform/lantiq/ltq-hcd/src/ifxusb_version.h b/package/platform/lantiq/ltq-hcd/src/ifxusb_version.h
new file mode 100644
index 0000000..11e346e
--- /dev/null
+++ b/package/platform/lantiq/ltq-hcd/src/ifxusb_version.h
@@ -0,0 +1,5 @@
+
+#ifndef IFXUSB_VERSION
+#define IFXUSB_VERSION "3.2 B110801"
+#endif
+
diff --git a/package/platform/lantiq/ltq-ifxos/.svn/entries b/package/platform/lantiq/ltq-ifxos/.svn/entries
new file mode 100644
index 0000000..e584e8c
--- /dev/null
+++ b/package/platform/lantiq/ltq-ifxos/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/platform/lantiq/ltq-ifxos
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-14T18:43:02.717237Z
+36020
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+914330cb9c8e637a36b183831f671406
+2012-12-15T02:00:26.239609Z
+34692
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1415
+
diff --git a/package/platform/lantiq/ltq-ifxos/.svn/text-base/Makefile.svn-base b/package/platform/lantiq/ltq-ifxos/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..1364849
--- /dev/null
+++ b/package/platform/lantiq/ltq-ifxos/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,51 @@
+# Copyright (C) 2009-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=lib_ifxos
+PKG_VERSION:=1.5.14
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_RELEASE:=3
+PKG_SOURCE_URL:=http://mirror2.openwrt.org/sources
+PKG_MD5SUM:=bc107f9d8ff6bed4c2760a2817bbb029
+PKG_MAINTAINER:=John Crispin <blogic@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/ltq-ifxos
+ SECTION:=sys
+ CATEGORY:=Kernel modules
+ SUBMENU:=Libraries
+ TITLE:=Lantiq OS abstraction library
+ URL:=http://www.lantiq.com/
+ DEPENDS:=@TARGET_lantiq
+ FILES:=$(PKG_BUILD_DIR)/src/drv_ifxos.ko
+ AUTOLOAD:=$(call AutoLoad,10,drv_ifxos)
+endef
+
+CONFIGURE_ARGS += \
+ ARCH=$(LINUX_KARCH) \
+ --enable-linux-26 \
+ --enable-kernelbuild="$(LINUX_DIR)" \
+ --enable-kernelincl="$(LINUX_DIR)/include" \
+ --enable-add_drv_cflags="-fno-pic -mno-abicalls -mlong-calls -G 0"
+
+define Build/Configure
+ (cd $(PKG_BUILD_DIR); aclocal && autoconf && automake)
+ $(call Build/Configure/Default)
+endef
+
+ifdef CONFIG_TARGET_lantiq
+ define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/{lib,include/ifxos}
+ $(CP) $(PKG_BUILD_DIR)/src/include/* $(1)/usr/include/ifxos
+ mkdir -p $(1)/usr/lib
+ $(CP) $(PKG_BUILD_DIR)/src/libifxos.a $(1)/usr/lib/libifxos.a
+ endef
+endif
+
+$(eval $(call KernelPackage,ltq-ifxos))
diff --git a/package/platform/lantiq/ltq-ifxos/Makefile b/package/platform/lantiq/ltq-ifxos/Makefile
new file mode 100644
index 0000000..1364849
--- /dev/null
+++ b/package/platform/lantiq/ltq-ifxos/Makefile
@@ -0,0 +1,51 @@
+# Copyright (C) 2009-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=lib_ifxos
+PKG_VERSION:=1.5.14
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_RELEASE:=3
+PKG_SOURCE_URL:=http://mirror2.openwrt.org/sources
+PKG_MD5SUM:=bc107f9d8ff6bed4c2760a2817bbb029
+PKG_MAINTAINER:=John Crispin <blogic@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/ltq-ifxos
+ SECTION:=sys
+ CATEGORY:=Kernel modules
+ SUBMENU:=Libraries
+ TITLE:=Lantiq OS abstraction library
+ URL:=http://www.lantiq.com/
+ DEPENDS:=@TARGET_lantiq
+ FILES:=$(PKG_BUILD_DIR)/src/drv_ifxos.ko
+ AUTOLOAD:=$(call AutoLoad,10,drv_ifxos)
+endef
+
+CONFIGURE_ARGS += \
+ ARCH=$(LINUX_KARCH) \
+ --enable-linux-26 \
+ --enable-kernelbuild="$(LINUX_DIR)" \
+ --enable-kernelincl="$(LINUX_DIR)/include" \
+ --enable-add_drv_cflags="-fno-pic -mno-abicalls -mlong-calls -G 0"
+
+define Build/Configure
+ (cd $(PKG_BUILD_DIR); aclocal && autoconf && automake)
+ $(call Build/Configure/Default)
+endef
+
+ifdef CONFIG_TARGET_lantiq
+ define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/{lib,include/ifxos}
+ $(CP) $(PKG_BUILD_DIR)/src/include/* $(1)/usr/include/ifxos
+ mkdir -p $(1)/usr/lib
+ $(CP) $(PKG_BUILD_DIR)/src/libifxos.a $(1)/usr/lib/libifxos.a
+ endef
+endif
+
+$(eval $(call KernelPackage,ltq-ifxos))
diff --git a/package/platform/lantiq/ltq-ifxos/patches/.svn/entries b/package/platform/lantiq/ltq-ifxos/patches/.svn/entries
new file mode 100644
index 0000000..ecb518a
--- /dev/null
+++ b/package/platform/lantiq/ltq-ifxos/patches/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/platform/lantiq/ltq-ifxos/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-14T18:43:02.717237Z
+36020
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+100-compat.patch
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+e5a5f459bfbdc9e2484031a8a8a2bdc9
+2013-03-14T18:43:02.717237Z
+36020
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3876
+
diff --git a/package/platform/lantiq/ltq-ifxos/patches/.svn/text-base/100-compat.patch.svn-base b/package/platform/lantiq/ltq-ifxos/patches/.svn/text-base/100-compat.patch.svn-base
new file mode 100644
index 0000000..2fd7cd3
--- /dev/null
+++ b/package/platform/lantiq/ltq-ifxos/patches/.svn/text-base/100-compat.patch.svn-base
@@ -0,0 +1,96 @@
+Index: lib_ifxos-1.5.14/configure.in
+===================================================================
+--- lib_ifxos-1.5.14.orig/configure.in 2010-07-22 18:34:07.000000000 +0200
++++ lib_ifxos-1.5.14/configure.in 2013-03-14 08:23:57.481810836 +0100
+@@ -64,7 +64,7 @@
+ AC_ARG_ENABLE(kernelbuild,
+ AS_HELP_STRING(--enable-kernelbuild=x,Set the target kernel build path (only for kernel 2.6.x)),
+ [
+- if test -e $enableval/include/linux/autoconf.h; then
++ if test -e $enableval/include/linux/autoconf.h -o -e $enableval/include/generated/autoconf.h; then
+ AC_SUBST([KERNEL_BUILD_PATH],[$enableval])
+ else
+ AC_MSG_ERROR([The kernel build directory is not valid or not configured!])
+Index: lib_ifxos-1.5.14/src/linux/ifxos_linux_thread_drv.c
+===================================================================
+--- lib_ifxos-1.5.14.orig/src/linux/ifxos_linux_thread_drv.c 2010-01-08 18:10:47.000000000 +0100
++++ lib_ifxos-1.5.14/src/linux/ifxos_linux_thread_drv.c 2013-03-14 08:23:57.481810836 +0100
+@@ -34,8 +34,8 @@
+ #include <linux/sched.h>
+ #include <linux/version.h>
+ #include <linux/completion.h>
+-#include <linux/smp_lock.h>
+ #include <linux/signal.h>
++#include <linux/kthread.h>
+
+
+ #include "ifx_types.h"
+@@ -68,10 +68,6 @@
+ #if ( defined(IFXOS_HAVE_THREAD) && (IFXOS_HAVE_THREAD == 1) )
+
+
+-IFXOS_STATIC IFX_int32_t IFXOS_KernelThreadStartup(
+- IFXOS_ThreadCtrl_t *pThrCntrl);
+-
+-
+ /* ============================================================================
+ IFX Linux adaptation - Kernel Thread handling
+ ========================================================================= */
+@@ -96,9 +92,9 @@
+ - IFX_SUCCESS on success
+ - IFX_ERROR on error
+ */
+-IFXOS_STATIC IFX_int32_t IFXOS_KernelThreadStartup(
+- IFXOS_ThreadCtrl_t *pThrCntrl)
++int IFXOS_KernelThreadStartup(void *data)
+ {
++ IFXOS_ThreadCtrl_t *pThrCntrl = (IFXOS_ThreadCtrl_t*) data;
+ IFX_int32_t retVal = IFX_ERROR;
+ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
+ struct task_struct *kthread = current;
+@@ -139,7 +135,7 @@
+ /* let others run */
+ unlock_kernel();
+ #else
+- daemonize(pThrCntrl->thrParams.pName);
++ //daemonize(pThrCntrl->thrParams.pName);
+
+ /* Enable signals in Kernel >= 2.6 */
+ allow_signal(SIGKILL);
+@@ -218,9 +214,7 @@
+ init_completion(&pThrCntrl->thrCompletion);
+
+ /* start kernel thread via the wrapper function */
+- pThrCntrl->tid = kernel_thread( (IFXOS_KERNEL_THREAD_StartRoutine)IFXOS_KernelThreadStartup,
+- (void *)pThrCntrl,
+- IFXOS_DRV_THREAD_OPTIONS);
++ pThrCntrl->tid = kthread_run(IFXOS_KernelThreadStartup, (void *)pThrCntrl, "ifxos");
+
+ pThrCntrl->bValid = IFX_TRUE;
+
+Index: lib_ifxos-1.5.14/src/include/ifxos_thread.h
+===================================================================
+--- lib_ifxos-1.5.14.orig/src/include/ifxos_thread.h 2010-01-14 10:59:13.000000000 +0100
++++ lib_ifxos-1.5.14/src/include/ifxos_thread.h 2013-03-14 08:24:43.577812806 +0100
+@@ -111,7 +111,7 @@
+ /**
+ Function type of the user thread/task function.
+ */
+-typedef IFX_int32_t (*IFXOS_ThreadFunction_t)(IFXOS_ThreadParams_t *);
++typedef int (*IFXOS_ThreadFunction_t)(void*);
+
+ /** @} */
+
+Index: lib_ifxos-1.5.14/src/include/linux/ifxos_linux_thread.h
+===================================================================
+--- lib_ifxos-1.5.14.orig/src/include/linux/ifxos_linux_thread.h 2010-01-08 18:10:27.000000000 +0100
++++ lib_ifxos-1.5.14/src/include/linux/ifxos_linux_thread.h 2013-03-14 08:25:13.193814073 +0100
+@@ -152,7 +152,7 @@
+ IFXOS_ThreadFunction_t pThrFct;
+
+ /** Kernel thread process ID */
+- IFX_int32_t tid;
++ struct task_struct *tid;
+
+ /** requested kernel thread priority */
+ IFX_int32_t nPriority;
diff --git a/package/platform/lantiq/ltq-ifxos/patches/100-compat.patch b/package/platform/lantiq/ltq-ifxos/patches/100-compat.patch
new file mode 100644
index 0000000..2fd7cd3
--- /dev/null
+++ b/package/platform/lantiq/ltq-ifxos/patches/100-compat.patch
@@ -0,0 +1,96 @@
+Index: lib_ifxos-1.5.14/configure.in
+===================================================================
+--- lib_ifxos-1.5.14.orig/configure.in 2010-07-22 18:34:07.000000000 +0200
++++ lib_ifxos-1.5.14/configure.in 2013-03-14 08:23:57.481810836 +0100
+@@ -64,7 +64,7 @@
+ AC_ARG_ENABLE(kernelbuild,
+ AS_HELP_STRING(--enable-kernelbuild=x,Set the target kernel build path (only for kernel 2.6.x)),
+ [
+- if test -e $enableval/include/linux/autoconf.h; then
++ if test -e $enableval/include/linux/autoconf.h -o -e $enableval/include/generated/autoconf.h; then
+ AC_SUBST([KERNEL_BUILD_PATH],[$enableval])
+ else
+ AC_MSG_ERROR([The kernel build directory is not valid or not configured!])
+Index: lib_ifxos-1.5.14/src/linux/ifxos_linux_thread_drv.c
+===================================================================
+--- lib_ifxos-1.5.14.orig/src/linux/ifxos_linux_thread_drv.c 2010-01-08 18:10:47.000000000 +0100
++++ lib_ifxos-1.5.14/src/linux/ifxos_linux_thread_drv.c 2013-03-14 08:23:57.481810836 +0100
+@@ -34,8 +34,8 @@
+ #include <linux/sched.h>
+ #include <linux/version.h>
+ #include <linux/completion.h>
+-#include <linux/smp_lock.h>
+ #include <linux/signal.h>
++#include <linux/kthread.h>
+
+
+ #include "ifx_types.h"
+@@ -68,10 +68,6 @@
+ #if ( defined(IFXOS_HAVE_THREAD) && (IFXOS_HAVE_THREAD == 1) )
+
+
+-IFXOS_STATIC IFX_int32_t IFXOS_KernelThreadStartup(
+- IFXOS_ThreadCtrl_t *pThrCntrl);
+-
+-
+ /* ============================================================================
+ IFX Linux adaptation - Kernel Thread handling
+ ========================================================================= */
+@@ -96,9 +92,9 @@
+ - IFX_SUCCESS on success
+ - IFX_ERROR on error
+ */
+-IFXOS_STATIC IFX_int32_t IFXOS_KernelThreadStartup(
+- IFXOS_ThreadCtrl_t *pThrCntrl)
++int IFXOS_KernelThreadStartup(void *data)
+ {
++ IFXOS_ThreadCtrl_t *pThrCntrl = (IFXOS_ThreadCtrl_t*) data;
+ IFX_int32_t retVal = IFX_ERROR;
+ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
+ struct task_struct *kthread = current;
+@@ -139,7 +135,7 @@
+ /* let others run */
+ unlock_kernel();
+ #else
+- daemonize(pThrCntrl->thrParams.pName);
++ //daemonize(pThrCntrl->thrParams.pName);
+
+ /* Enable signals in Kernel >= 2.6 */
+ allow_signal(SIGKILL);
+@@ -218,9 +214,7 @@
+ init_completion(&pThrCntrl->thrCompletion);
+
+ /* start kernel thread via the wrapper function */
+- pThrCntrl->tid = kernel_thread( (IFXOS_KERNEL_THREAD_StartRoutine)IFXOS_KernelThreadStartup,
+- (void *)pThrCntrl,
+- IFXOS_DRV_THREAD_OPTIONS);
++ pThrCntrl->tid = kthread_run(IFXOS_KernelThreadStartup, (void *)pThrCntrl, "ifxos");
+
+ pThrCntrl->bValid = IFX_TRUE;
+
+Index: lib_ifxos-1.5.14/src/include/ifxos_thread.h
+===================================================================
+--- lib_ifxos-1.5.14.orig/src/include/ifxos_thread.h 2010-01-14 10:59:13.000000000 +0100
++++ lib_ifxos-1.5.14/src/include/ifxos_thread.h 2013-03-14 08:24:43.577812806 +0100
+@@ -111,7 +111,7 @@
+ /**
+ Function type of the user thread/task function.
+ */
+-typedef IFX_int32_t (*IFXOS_ThreadFunction_t)(IFXOS_ThreadParams_t *);
++typedef int (*IFXOS_ThreadFunction_t)(void*);
+
+ /** @} */
+
+Index: lib_ifxos-1.5.14/src/include/linux/ifxos_linux_thread.h
+===================================================================
+--- lib_ifxos-1.5.14.orig/src/include/linux/ifxos_linux_thread.h 2010-01-08 18:10:27.000000000 +0100
++++ lib_ifxos-1.5.14/src/include/linux/ifxos_linux_thread.h 2013-03-14 08:25:13.193814073 +0100
+@@ -152,7 +152,7 @@
+ IFXOS_ThreadFunction_t pThrFct;
+
+ /** Kernel thread process ID */
+- IFX_int32_t tid;
++ struct task_struct *tid;
+
+ /** requested kernel thread priority */
+ IFX_int32_t nPriority;
diff --git a/package/platform/lantiq/ltq-ptm/.svn/entries b/package/platform/lantiq/ltq-ptm/.svn/entries
new file mode 100644
index 0000000..5096326
--- /dev/null
+++ b/package/platform/lantiq/ltq-ptm/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/platform/lantiq/ltq-ptm
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-14T18:42:52.845455Z
+36018
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+src
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+99c6b4df8b303b57530aa1a4543d641b
+2012-12-15T02:00:13.935651Z
+34690
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1461
+
diff --git a/package/platform/lantiq/ltq-ptm/.svn/text-base/Makefile.svn-base b/package/platform/lantiq/ltq-ptm/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..f0fb25a
--- /dev/null
+++ b/package/platform/lantiq/ltq-ptm/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,52 @@
+# Copyright (C) 2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=ltq-ptm
+PKG_RELEASE:=1
+PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/ltq-ptm-$(BUILD_VARIANT)
+
+PKG_MAINTAINER:=John Crispin <blogic@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/ltq-ptm-template
+ SECTION:=sys
+ CATEGORY:=Kernel modules
+ SUBMENU:=Network Devices
+ TITLE:=ptm driver for $(1)
+ URL:=http://www.lantiq.com/
+ VARIANT:=$(1)
+ DEPENDS:=@TARGET_lantiq_$(2)
+ FILES:=$(PKG_BUILD_DIR)/ltq_ptm_$(1).ko
+ AUTOLOAD:=$(call AutoLoad,52,ltq_ptm_$(1))
+endef
+
+KernelPackage/ltq-ptm-danube=$(call KernelPackage/ltq-ptm-template,danube,xway)
+KernelPackage/ltq-ptm-ar9=$(call KernelPackage/ltq-ptm-template,ar9,xway)
+KernelPackage/ltq-ptm-ase=$(call KernelPackage/ltq-ptm-template,ase,ase)
+KernelPackage/ltq-ptm-vr9=$(call KernelPackage/ltq-ptm-template,vr9,xway)
+
+define Build/Prepare
+ $(INSTALL_DIR) $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+ cd $(LINUX_DIR); \
+ ARCH=mips CROSS_COMPILE="$(KERNEL_CROSS)" \
+ $(MAKE) BUILD_VARIANT=$(BUILD_VARIANT) M=$(PKG_BUILD_DIR) V=1 modules
+endef
+
+$(eval $(call KernelPackage,ltq-ptm-danube))
+$(eval $(call KernelPackage,ltq-ptm-ase))
+$(eval $(call KernelPackage,ltq-ptm-ar9))
+$(eval $(call KernelPackage,ltq-ptm-vr9))
diff --git a/package/platform/lantiq/ltq-ptm/Makefile b/package/platform/lantiq/ltq-ptm/Makefile
new file mode 100644
index 0000000..f0fb25a
--- /dev/null
+++ b/package/platform/lantiq/ltq-ptm/Makefile
@@ -0,0 +1,52 @@
+# Copyright (C) 2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=ltq-ptm
+PKG_RELEASE:=1
+PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/ltq-ptm-$(BUILD_VARIANT)
+
+PKG_MAINTAINER:=John Crispin <blogic@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/ltq-ptm-template
+ SECTION:=sys
+ CATEGORY:=Kernel modules
+ SUBMENU:=Network Devices
+ TITLE:=ptm driver for $(1)
+ URL:=http://www.lantiq.com/
+ VARIANT:=$(1)
+ DEPENDS:=@TARGET_lantiq_$(2)
+ FILES:=$(PKG_BUILD_DIR)/ltq_ptm_$(1).ko
+ AUTOLOAD:=$(call AutoLoad,52,ltq_ptm_$(1))
+endef
+
+KernelPackage/ltq-ptm-danube=$(call KernelPackage/ltq-ptm-template,danube,xway)
+KernelPackage/ltq-ptm-ar9=$(call KernelPackage/ltq-ptm-template,ar9,xway)
+KernelPackage/ltq-ptm-ase=$(call KernelPackage/ltq-ptm-template,ase,ase)
+KernelPackage/ltq-ptm-vr9=$(call KernelPackage/ltq-ptm-template,vr9,xway)
+
+define Build/Prepare
+ $(INSTALL_DIR) $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+ cd $(LINUX_DIR); \
+ ARCH=mips CROSS_COMPILE="$(KERNEL_CROSS)" \
+ $(MAKE) BUILD_VARIANT=$(BUILD_VARIANT) M=$(PKG_BUILD_DIR) V=1 modules
+endef
+
+$(eval $(call KernelPackage,ltq-ptm-danube))
+$(eval $(call KernelPackage,ltq-ptm-ase))
+$(eval $(call KernelPackage,ltq-ptm-ar9))
+$(eval $(call KernelPackage,ltq-ptm-vr9))
diff --git a/package/platform/lantiq/ltq-ptm/src/.svn/entries b/package/platform/lantiq/ltq-ptm/src/.svn/entries
new file mode 100644
index 0000000..1b02f79
--- /dev/null
+++ b/package/platform/lantiq/ltq-ptm/src/.svn/entries
@@ -0,0 +1,912 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/platform/lantiq/ltq-ptm/src
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-14T18:42:52.845455Z
+36018
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+ifxmips_ptm_fw_regs_danube.h
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+e57b59bb6fd1b9126288b9a1ac8660e2
+2012-12-15T02:00:13.935651Z
+34690
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2087
+
+ifxmips_ptm_test.c
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+d26fc4af6311f33c3a428badd6d41438
+2012-12-15T02:00:13.935651Z
+34690
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+29472
+
+ifxmips_ptm_vr9.c
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+626867082908d0de563a1ce19ef153b8
+2012-12-15T02:00:13.935651Z
+34690
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+7628
+
+ifxmips_ptm_fw_vr9.h
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+deff1d755e8c25795f1452f014617658
+2012-12-15T02:00:13.935651Z
+34690
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+34507
+
+ifxmips_ptm_adsl.c
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+9b8518b87117b08585e7c50c3c36a208
+2013-03-14T18:42:52.845455Z
+36018
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+50414
+
+ifxmips_ptm_ppe_amazon_se.h
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+a69ee7804609e870d7ba35ebe5179e6d
+2012-12-15T02:00:13.935651Z
+34690
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+10597
+
+ifxmips_ptm_adsl.h
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+b261d70b2c973e2d2c058e22a53ff30d
+2012-12-15T02:00:13.935651Z
+34690
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4024
+
+ifxmips_ptm_ppe_vr9.h
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+301741bdec544d98816fac00ed89e431
+2012-12-15T02:00:13.935651Z
+34690
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+11664
+
+ifxmips_ptm_fw_regs_vdsl.h
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+0164030c4c9cb68da37db21b956a48b9
+2012-12-15T02:00:13.935651Z
+34690
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+11737
+
+ifxmips_ptm_ar9.c
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+f389dfabe174de8586cfd3e7ac1047fe
+2012-12-15T02:00:13.935651Z
+34690
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+10820
+
+ifxmips_ptm_fw_ar9.h
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+19bc4e5ce4fa935bd497ca0943497796
+2012-12-15T02:00:13.935651Z
+34690
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+44423
+
+ifxmips_ptm_fw_regs_amazon_se.h
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+bff7fa41d1115741bb4ed3568e5672c6
+2012-12-15T02:00:13.935651Z
+34690
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2102
+
+ifxmips_ptm_common.h
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+8fc97396b3accaccc9f9e64234083d4b
+2012-12-15T02:00:13.935651Z
+34690
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3299
+
+ifxmips_ptm_danube.c
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+cd0b0ae828f2525ca83cb898053471a7
+2012-12-15T02:00:13.935651Z
+34690
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+7860
+
+ifxmips_ptm_fw_danube.h
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+b6e7a118a0da4cfd12eeef71c945a4d7
+2012-12-15T02:00:13.935651Z
+34690
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+45976
+
+ifxmips_ptm_fw_regs_vr9.h
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+0bbd6c0416ce854bdab0f38ccb6a940f
+2012-12-15T02:00:13.935651Z
+34690
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5441
+
+ifxmips_ptm_ppe_common.h
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+1494c0a1abd6ffd4a80c282cd37eb03b
+2012-12-15T02:00:13.935651Z
+34690
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+11759
+
+ifxmips_ptm_fw_regs_adsl.h
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+c42224721c45fa6553b99e5c01f68d9c
+2012-12-15T02:00:13.935651Z
+34690
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+8266
+
+ifxmips_ptm_ppe_ar9.h
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+9db933e0d7f8983710393de2b27988a6
+2012-12-15T02:00:13.935651Z
+34690
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+11709
+
+ifxmips_ptm_ppe_danube.h
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+781de14abe1859ab49fca0ec3d85db5c
+2012-12-15T02:00:13.935651Z
+34690
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+6424
+
+ifxmips_ptm_vdsl.c
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+8dce29ff62dd0c2ac4845415b11aa80f
+2013-03-14T18:42:52.845455Z
+36018
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+33938
+
+ifxmips_ptm_amazon_se.c
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+aed96bb742d4a074cf3a068f780cca94
+2012-12-15T02:00:13.935651Z
+34690
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+8110
+
+ifxmips_ptm_fw_regs_ar9.h
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+93f16b18314549f1d39dcad57f69235e
+2012-12-15T02:00:13.935651Z
+34690
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2072
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+292804e51d8ac4fa45acfa9f2deede01
+2012-12-15T02:00:13.935651Z
+34690
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+614
+
+ifxmips_ptm_fw_amazon_se.h
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+71e51e9e170967097d588a0de357027e
+2012-12-15T02:00:13.935651Z
+34690
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+46316
+
+ifxmips_ptm_vdsl.h
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+948f509f6f07317c04801d7aec34210a
+2012-12-15T02:00:13.935651Z
+34690
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3666
+
diff --git a/package/platform/lantiq/ltq-ptm/src/.svn/text-base/Makefile.svn-base b/package/platform/lantiq/ltq-ptm/src/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..0d0bda5
--- /dev/null
+++ b/package/platform/lantiq/ltq-ptm/src/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,23 @@
+ifeq ($(BUILD_VARIANT),danube)
+ CFLAGS_MODULE+=-DCONFIG_DANUBE
+ obj-m = ltq_ptm_danube.o
+ ltq_ptm_danube-objs = ifxmips_ptm_adsl.o ifxmips_ptm_danube.o
+endif
+
+ifeq ($(BUILD_VARIANT),ase)
+ CFLAGS_MODULE+=-DCONFIG_AMAZON_SE
+ obj-m = ltq_ptm_ase.o
+ ltq_ptm_ase-objs = ifxmips_ptm_adsl.o ifxmips_ptm_amazon_se.o
+endif
+
+ifeq ($(BUILD_VARIANT),ar9)
+ CFLAGS_MODULE+=-DCONFIG_AR9
+ obj-m = ltq_ptm_ar9.o
+ ltq_ptm_ar9-objs = ifxmips_ptm_adsl.o ifxmips_ptm_ar9.o
+endif
+
+ifeq ($(BUILD_VARIANT),vr9)
+ CFLAGS_MODULE+=-DCONFIG_VR9
+ obj-m = ltq_ptm_vr9.o
+ ltq_ptm_vr9-objs = ifxmips_ptm_vdsl.o ifxmips_ptm_vr9.o
+endif
diff --git a/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_adsl.c.svn-base b/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_adsl.c.svn-base
new file mode 100644
index 0000000..391d56c
--- /dev/null
+++ b/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_adsl.c.svn-base
@@ -0,0 +1,1551 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_ptm_adsl.c
+** PROJECT : UEIP
+** MODULES : PTM
+**
+** DATE : 7 Jul 2009
+** AUTHOR : Xu Liang
+** DESCRIPTION : PTM driver common source file (core functions for Danube/
+** Amazon-SE/AR9)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 07 JUL 2009 Xu Liang Init Version
+*******************************************************************************/
+
+
+
+/*
+ * ####################################
+ * Head File
+ * ####################################
+ */
+
+/*
+ * Common Head File
+ */
+#include <linux/version.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/proc_fs.h>
+#include <linux/init.h>
+#include <linux/ioctl.h>
+#include <linux/etherdevice.h>
+#include <linux/interrupt.h>
+#include <asm/io.h>
+
+/*
+ * Chip Specific Head File
+ */
+#include "ifxmips_ptm_adsl.h"
+
+
+#include <lantiq_soc.h>
+
+/*
+ * ####################################
+ * Kernel Version Adaption
+ * ####################################
+ */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,11)
+ #define MODULE_PARM_ARRAY(a, b) module_param_array(a, int, NULL, 0)
+ #define MODULE_PARM(a, b) module_param(a, int, 0)
+#else
+ #define MODULE_PARM_ARRAY(a, b) MODULE_PARM(a, b)
+#endif
+
+
+
+/*
+ * ####################################
+ * Parameters to Configure PPE
+ * ####################################
+ */
+
+static int write_desc_delay = 0x20; /* Write descriptor delay */
+
+static int rx_max_packet_size = ETH_MAX_FRAME_LENGTH;
+ /* Max packet size for RX */
+
+static int dma_rx_descriptor_length = 24; /* Number of descriptors per DMA RX channel */
+static int dma_tx_descriptor_length = 24; /* Number of descriptors per DMA TX channel */
+
+static int eth_efmtc_crc_cfg = 0x03100710; /* default: tx_eth_crc_check: 1, tx_tc_crc_check: 1, tx_tc_crc_len = 16 */
+ /* rx_eth_crc_present: 1, rx_eth_crc_check: 1, rx_tc_crc_check: 1, rx_tc_crc_len = 16 */
+
+MODULE_PARM(write_desc_delay, "i");
+MODULE_PARM_DESC(write_desc_delay, "PPE core clock cycles between descriptor write and effectiveness in external RAM");
+
+MODULE_PARM(rx_max_packet_size, "i");
+MODULE_PARM_DESC(rx_max_packet_size, "Max packet size in byte for downstream ethernet frames");
+
+MODULE_PARM(dma_rx_descriptor_length, "i");
+MODULE_PARM_DESC(dma_rx_descriptor_length, "Number of descriptor assigned to DMA RX channel (>16)");
+MODULE_PARM(dma_tx_descriptor_length, "i");
+MODULE_PARM_DESC(dma_tx_descriptor_length, "Number of descriptor assigned to DMA TX channel (>16)");
+
+MODULE_PARM(eth_efmtc_crc_cfg, "i");
+MODULE_PARM_DESC(eth_efmtc_crc_cfg, "Configuration for PTM TX/RX ethernet/efm-tc CRC");
+
+
+
+/*
+ * ####################################
+ * Definition
+ * ####################################
+ */
+
+
+#define DUMP_SKB_LEN ~0
+
+
+
+/*
+ * ####################################
+ * Declaration
+ * ####################################
+ */
+
+/*
+ * Network Operations
+ */
+static void ptm_setup(struct net_device *, int);
+static struct net_device_stats *ptm_get_stats(struct net_device *);
+static int ptm_open(struct net_device *);
+static int ptm_stop(struct net_device *);
+ static unsigned int ptm_poll(int, unsigned int);
+ static int ptm_napi_poll(struct napi_struct *, int);
+static int ptm_hard_start_xmit(struct sk_buff *, struct net_device *);
+static int ptm_ioctl(struct net_device *, struct ifreq *, int);
+static void ptm_tx_timeout(struct net_device *);
+
+/*
+ * DSL Data LED
+ */
+static INLINE void adsl_led_flash(void);
+
+/*
+ * buffer manage functions
+ */
+static INLINE struct sk_buff* alloc_skb_rx(void);
+//static INLINE struct sk_buff* alloc_skb_tx(unsigned int);
+static INLINE struct sk_buff *get_skb_rx_pointer(unsigned int);
+static INLINE int get_tx_desc(unsigned int, unsigned int *);
+
+/*
+ * Mailbox handler and signal function
+ */
+static INLINE int mailbox_rx_irq_handler(unsigned int);
+static irqreturn_t mailbox_irq_handler(int, void *);
+static INLINE void mailbox_signal(unsigned int, int);
+#ifdef CONFIG_IFX_PTM_RX_TASKLET
+ static void do_ptm_tasklet(unsigned long);
+#endif
+
+/*
+ * Debug Functions
+ */
+#if defined(DEBUG_DUMP_SKB) && DEBUG_DUMP_SKB
+ static void dump_skb(struct sk_buff *, u32, char *, int, int, int);
+#else
+ #define dump_skb(skb, len, title, port, ch, is_tx) do {} while (0)
+#endif
+#if defined(ENABLE_DBG_PROC) && ENABLE_DBG_PROC
+ static void skb_swap(struct sk_buff *);
+#else
+ #define skb_swap(skb) do {} while (0)
+#endif
+
+/*
+ * Proc File Functions
+ */
+static INLINE void proc_file_create(void);
+static INLINE void proc_file_delete(void);
+static int proc_read_version(char *, char **, off_t, int, int *, void *);
+static int proc_read_wanmib(char *, char **, off_t, int, int *, void *);
+static int proc_write_wanmib(struct file *, const char *, unsigned long, void *);
+#if defined(ENABLE_FW_PROC) && ENABLE_FW_PROC
+ static int proc_read_genconf(char *, char **, off_t, int, int *, void *);
+#endif
+#if defined(ENABLE_DBG_PROC) && ENABLE_DBG_PROC
+ static int proc_read_dbg(char *, char **, off_t, int, int *, void *);
+ static int proc_write_dbg(struct file *, const char *, unsigned long, void *);
+#endif
+
+/*
+ * Proc Help Functions
+ */
+static INLINE int stricmp(const char *, const char *);
+#if defined(ENABLE_DBG_PROC) && ENABLE_DBG_PROC
+ static INLINE int strincmp(const char *, const char *, int);
+#endif
+static INLINE int ifx_ptm_version(char *);
+
+/*
+ * Init & clean-up functions
+ */
+static INLINE void check_parameters(void);
+static INLINE int init_priv_data(void);
+static INLINE void clear_priv_data(void);
+static INLINE void init_tables(void);
+
+/*
+ * Exteranl Function
+ */
+#if defined(CONFIG_IFXMIPS_DSL_CPE_MEI) || defined(CONFIG_IFXMIPS_DSL_CPE_MEI_MODULE)
+ extern int ifx_mei_atm_showtime_check(int *is_showtime, struct port_cell_info *port_cell, void **xdata_addr);
+#else
+ static inline int ifx_mei_atm_showtime_check(int *is_showtime, struct port_cell_info *port_cell, void **xdata_addr)
+ {
+ if ( is_showtime != NULL )
+ *is_showtime = 0;
+ return 0;
+ }
+#endif
+
+/*
+ * External variable
+ */
+#if defined(CONFIG_IFXMIPS_DSL_CPE_MEI) || defined(CONFIG_IFXMIPS_DSL_CPE_MEI_MODULE)
+ extern int (*ifx_mei_atm_showtime_enter)(struct port_cell_info *, void *);
+ extern int (*ifx_mei_atm_showtime_exit)(void);
+#else
+ int (*ifx_mei_atm_showtime_enter)(struct port_cell_info *, void *) = NULL;
+ EXPORT_SYMBOL(ifx_mei_atm_showtime_enter);
+ int (*ifx_mei_atm_showtime_exit)(void) = NULL;
+ EXPORT_SYMBOL(ifx_mei_atm_showtime_exit);
+#endif
+
+
+
+/*
+ * ####################################
+ * Local Variable
+ * ####################################
+ */
+
+static struct ptm_priv_data g_ptm_priv_data;
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32)
+static struct net_device_ops g_ptm_netdev_ops = {
+ .ndo_get_stats = ptm_get_stats,
+ .ndo_open = ptm_open,
+ .ndo_stop = ptm_stop,
+ .ndo_start_xmit = ptm_hard_start_xmit,
+ .ndo_validate_addr = eth_validate_addr,
+ .ndo_set_mac_address = eth_mac_addr,
+ .ndo_change_mtu = eth_change_mtu,
+ .ndo_do_ioctl = ptm_ioctl,
+ .ndo_tx_timeout = ptm_tx_timeout,
+};
+#endif
+
+static struct net_device *g_net_dev[2] = {0};
+static char *g_net_dev_name[2] = {"ptm0", "ptmfast0"};
+
+#ifdef CONFIG_IFX_PTM_RX_TASKLET
+ static struct tasklet_struct g_ptm_tasklet[] = {
+ {NULL, 0, ATOMIC_INIT(0), do_ptm_tasklet, 0},
+ {NULL, 0, ATOMIC_INIT(0), do_ptm_tasklet, 1},
+ };
+#endif
+
+unsigned int ifx_ptm_dbg_enable = DBG_ENABLE_MASK_ERR;
+
+static struct proc_dir_entry* g_ptm_dir = NULL;
+
+static int g_showtime = 0;
+
+
+
+/*
+ * ####################################
+ * Local Function
+ * ####################################
+ */
+
+static void ptm_setup(struct net_device *dev, int ndev)
+{
+ /* hook network operations */
+ dev->netdev_ops = &g_ptm_netdev_ops;
+ netif_napi_add(dev, &g_ptm_priv_data.itf[ndev].napi, ptm_napi_poll, 25);
+ dev->watchdog_timeo = ETH_WATCHDOG_TIMEOUT;
+
+ dev->dev_addr[0] = 0x00;
+ dev->dev_addr[1] = 0x20;
+ dev->dev_addr[2] = 0xda;
+ dev->dev_addr[3] = 0x86;
+ dev->dev_addr[4] = 0x23;
+ dev->dev_addr[5] = 0x75 + ndev;
+}
+
+static struct net_device_stats *ptm_get_stats(struct net_device *dev)
+{
+ int ndev;
+
+ for ( ndev = 0; ndev < ARRAY_SIZE(g_net_dev) && g_net_dev[ndev] != dev; ndev++ );
+ ASSERT(ndev >= 0 && ndev < ARRAY_SIZE(g_net_dev), "ndev = %d (wrong value)", ndev);
+
+ g_ptm_priv_data.itf[ndev].stats.rx_errors = WAN_MIB_TABLE[ndev].wrx_tccrc_err_pdu + WAN_MIB_TABLE[ndev].wrx_ethcrc_err_pdu;
+ g_ptm_priv_data.itf[ndev].stats.rx_dropped = WAN_MIB_TABLE[ndev].wrx_nodesc_drop_pdu + WAN_MIB_TABLE[ndev].wrx_len_violation_drop_pdu + (WAN_MIB_TABLE[ndev].wrx_correct_pdu - g_ptm_priv_data.itf[ndev].stats.rx_packets);
+
+ return &g_ptm_priv_data.itf[ndev].stats;
+}
+
+static int ptm_open(struct net_device *dev)
+{
+ int ndev;
+
+ for ( ndev = 0; ndev < ARRAY_SIZE(g_net_dev) && g_net_dev[ndev] != dev; ndev++ );
+ ASSERT(ndev >= 0 && ndev < ARRAY_SIZE(g_net_dev), "ndev = %d (wrong value)", ndev);
+
+ napi_enable(&g_ptm_priv_data.itf[ndev].napi);
+
+ IFX_REG_W32_MASK(0, 1 << ndev, MBOX_IGU1_IER);
+
+ netif_start_queue(dev);
+
+ return 0;
+}
+
+static int ptm_stop(struct net_device *dev)
+{
+ int ndev;
+
+ for ( ndev = 0; ndev < ARRAY_SIZE(g_net_dev) && g_net_dev[ndev] != dev; ndev++ );
+ ASSERT(ndev >= 0 && ndev < ARRAY_SIZE(g_net_dev), "ndev = %d (wrong value)", ndev);
+
+ IFX_REG_W32_MASK((1 << ndev) | (1 << (ndev + 16)), 0, MBOX_IGU1_IER);
+
+ napi_disable(&g_ptm_priv_data.itf[ndev].napi);
+
+ netif_stop_queue(dev);
+
+ return 0;
+}
+
+static unsigned int ptm_poll(int ndev, unsigned int work_to_do)
+{
+ unsigned int work_done = 0;
+
+ ASSERT(ndev >= 0 && ndev < ARRAY_SIZE(g_net_dev), "ndev = %d (wrong value)", ndev);
+
+ while ( work_done < work_to_do && WRX_DMA_CHANNEL_CONFIG(ndev)->vlddes > 0 ) {
+ if ( mailbox_rx_irq_handler(ndev) < 0 )
+ break;
+
+ work_done++;
+ }
+
+ return work_done;
+}
+static int ptm_napi_poll(struct napi_struct *napi, int budget)
+{
+ int ndev;
+ unsigned int work_done;
+
+ for ( ndev = 0; ndev < ARRAY_SIZE(g_net_dev) && g_net_dev[ndev] != napi->dev; ndev++ );
+
+ work_done = ptm_poll(ndev, budget);
+
+ // interface down
+ if ( !netif_running(napi->dev) ) {
+ napi_complete(napi);
+ return work_done;
+ }
+
+ // no more traffic
+ if ( WRX_DMA_CHANNEL_CONFIG(ndev)->vlddes == 0 ) {
+ // clear interrupt
+ IFX_REG_W32_MASK(0, 1 << ndev, MBOX_IGU1_ISRC);
+ // double check
+ if ( WRX_DMA_CHANNEL_CONFIG(ndev)->vlddes == 0 ) {
+ napi_complete(napi);
+ IFX_REG_W32_MASK(0, 1 << ndev, MBOX_IGU1_IER);
+ return work_done;
+ }
+ }
+
+ // next round
+ return work_done;
+}
+
+static int ptm_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
+{
+ int ndev;
+ unsigned int f_full;
+ int desc_base;
+ register struct tx_descriptor reg_desc = {0};
+
+ for ( ndev = 0; ndev < ARRAY_SIZE(g_net_dev) && g_net_dev[ndev] != dev; ndev++ );
+ ASSERT(ndev >= 0 && ndev < ARRAY_SIZE(g_net_dev), "ndev = %d (wrong value)", ndev);
+
+ if ( !g_showtime ) {
+ err("not in showtime");
+ goto PTM_HARD_START_XMIT_FAIL;
+ }
+
+ /* allocate descriptor */
+ desc_base = get_tx_desc(ndev, &f_full);
+ if ( f_full ) {
+ dev->trans_start = jiffies;
+ netif_stop_queue(dev);
+
+ IFX_REG_W32_MASK(0, 1 << (ndev + 16), MBOX_IGU1_ISRC);
+ IFX_REG_W32_MASK(0, 1 << (ndev + 16), MBOX_IGU1_IER);
+ }
+ if ( desc_base < 0 )
+ goto PTM_HARD_START_XMIT_FAIL;
+
+ if ( g_ptm_priv_data.itf[ndev].tx_skb[desc_base] != NULL )
+ dev_kfree_skb_any(g_ptm_priv_data.itf[ndev].tx_skb[desc_base]);
+ g_ptm_priv_data.itf[ndev].tx_skb[desc_base] = skb;
+
+ reg_desc.dataptr = (unsigned int)skb->data >> 2;
+ reg_desc.datalen = skb->len < ETH_ZLEN ? ETH_ZLEN : skb->len;
+ reg_desc.byteoff = (unsigned int)skb->data & (DATA_BUFFER_ALIGNMENT - 1);
+ reg_desc.own = 1;
+ reg_desc.c = 1;
+ reg_desc.sop = reg_desc.eop = 1;
+
+ /* write discriptor to memory and write back cache */
+ g_ptm_priv_data.itf[ndev].tx_desc[desc_base] = reg_desc;
+ dma_cache_wback((unsigned long)skb->data, skb->len);
+ wmb();
+
+ dump_skb(skb, DUMP_SKB_LEN, (char *)__func__, ndev, ndev, 1);
+
+ if ( (ifx_ptm_dbg_enable & DBG_ENABLE_MASK_MAC_SWAP) ) {
+ skb_swap(skb);
+ }
+
+ g_ptm_priv_data.itf[ndev].stats.tx_packets++;
+ g_ptm_priv_data.itf[ndev].stats.tx_bytes += reg_desc.datalen;
+
+ dev->trans_start = jiffies;
+ mailbox_signal(ndev, 1);
+
+ adsl_led_flash();
+
+ return NETDEV_TX_OK;
+
+PTM_HARD_START_XMIT_FAIL:
+ dev_kfree_skb_any(skb);
+ g_ptm_priv_data.itf[ndev].stats.tx_dropped++;
+ return NETDEV_TX_OK;
+}
+
+static int ptm_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
+{
+ int ndev;
+
+ for ( ndev = 0; ndev < ARRAY_SIZE(g_net_dev) && g_net_dev[ndev] != dev; ndev++ );
+ ASSERT(ndev >= 0 && ndev < ARRAY_SIZE(g_net_dev), "ndev = %d (wrong value)", ndev);
+
+ switch ( cmd )
+ {
+ case IFX_PTM_MIB_CW_GET:
+ ((PTM_CW_IF_ENTRY_T *)ifr->ifr_data)->ifRxNoIdleCodewords = WAN_MIB_TABLE[ndev].wrx_nonidle_cw;
+ ((PTM_CW_IF_ENTRY_T *)ifr->ifr_data)->ifRxIdleCodewords = WAN_MIB_TABLE[ndev].wrx_idle_cw;
+ ((PTM_CW_IF_ENTRY_T *)ifr->ifr_data)->ifRxCodingViolation = WAN_MIB_TABLE[ndev].wrx_err_cw;
+ ((PTM_CW_IF_ENTRY_T *)ifr->ifr_data)->ifTxNoIdleCodewords = 0;
+ ((PTM_CW_IF_ENTRY_T *)ifr->ifr_data)->ifTxIdleCodewords = 0;
+ break;
+ case IFX_PTM_MIB_FRAME_GET:
+ ((PTM_FRAME_MIB_T *)ifr->ifr_data)->RxCorrect = WAN_MIB_TABLE[ndev].wrx_correct_pdu;
+ ((PTM_FRAME_MIB_T *)ifr->ifr_data)->TC_CrcError = WAN_MIB_TABLE[ndev].wrx_tccrc_err_pdu;
+ ((PTM_FRAME_MIB_T *)ifr->ifr_data)->RxDropped = WAN_MIB_TABLE[ndev].wrx_nodesc_drop_pdu + WAN_MIB_TABLE[ndev].wrx_len_violation_drop_pdu;
+ ((PTM_FRAME_MIB_T *)ifr->ifr_data)->TxSend = WAN_MIB_TABLE[ndev].wtx_total_pdu;
+ break;
+ case IFX_PTM_CFG_GET:
+ ((IFX_PTM_CFG_T *)ifr->ifr_data)->RxEthCrcPresent = CFG_ETH_EFMTC_CRC->rx_eth_crc_present;
+ ((IFX_PTM_CFG_T *)ifr->ifr_data)->RxEthCrcCheck = CFG_ETH_EFMTC_CRC->rx_eth_crc_check;
+ ((IFX_PTM_CFG_T *)ifr->ifr_data)->RxTcCrcCheck = CFG_ETH_EFMTC_CRC->rx_tc_crc_check;
+ ((IFX_PTM_CFG_T *)ifr->ifr_data)->RxTcCrcLen = CFG_ETH_EFMTC_CRC->rx_tc_crc_len;
+ ((IFX_PTM_CFG_T *)ifr->ifr_data)->TxEthCrcGen = CFG_ETH_EFMTC_CRC->tx_eth_crc_gen;
+ ((IFX_PTM_CFG_T *)ifr->ifr_data)->TxTcCrcGen = CFG_ETH_EFMTC_CRC->tx_tc_crc_gen;
+ ((IFX_PTM_CFG_T *)ifr->ifr_data)->TxTcCrcLen = CFG_ETH_EFMTC_CRC->tx_tc_crc_len;
+ break;
+ case IFX_PTM_CFG_SET:
+ CFG_ETH_EFMTC_CRC->rx_eth_crc_present = ((IFX_PTM_CFG_T *)ifr->ifr_data)->RxEthCrcPresent ? 1 : 0;
+ CFG_ETH_EFMTC_CRC->rx_eth_crc_check = ((IFX_PTM_CFG_T *)ifr->ifr_data)->RxEthCrcCheck ? 1 : 0;
+ if ( ((IFX_PTM_CFG_T *)ifr->ifr_data)->RxTcCrcCheck && (((IFX_PTM_CFG_T *)ifr->ifr_data)->RxTcCrcLen == 16 || ((IFX_PTM_CFG_T *)ifr->ifr_data)->RxTcCrcLen == 32) )
+ {
+ CFG_ETH_EFMTC_CRC->rx_tc_crc_check = 1;
+ CFG_ETH_EFMTC_CRC->rx_tc_crc_len = ((IFX_PTM_CFG_T *)ifr->ifr_data)->RxTcCrcLen;
+ }
+ else
+ {
+ CFG_ETH_EFMTC_CRC->rx_tc_crc_check = 0;
+ CFG_ETH_EFMTC_CRC->rx_tc_crc_len = 0;
+ }
+ CFG_ETH_EFMTC_CRC->tx_eth_crc_gen = ((IFX_PTM_CFG_T *)ifr->ifr_data)->TxEthCrcGen ? 1 : 0;
+ if ( ((IFX_PTM_CFG_T *)ifr->ifr_data)->TxTcCrcGen && (((IFX_PTM_CFG_T *)ifr->ifr_data)->TxTcCrcLen == 16 || ((IFX_PTM_CFG_T *)ifr->ifr_data)->TxTcCrcLen == 32) )
+ {
+ CFG_ETH_EFMTC_CRC->tx_tc_crc_gen = 1;
+ CFG_ETH_EFMTC_CRC->tx_tc_crc_len = ((IFX_PTM_CFG_T *)ifr->ifr_data)->TxTcCrcLen;
+ }
+ else
+ {
+ CFG_ETH_EFMTC_CRC->tx_tc_crc_gen = 0;
+ CFG_ETH_EFMTC_CRC->tx_tc_crc_len = 0;
+ }
+ break;
+ default:
+ return -EOPNOTSUPP;
+ }
+
+ return 0;
+}
+
+static void ptm_tx_timeout(struct net_device *dev)
+{
+ int ndev;
+
+ for ( ndev = 0; ndev < ARRAY_SIZE(g_net_dev) && g_net_dev[ndev] != dev; ndev++ );
+ ASSERT(ndev >= 0 && ndev < ARRAY_SIZE(g_net_dev), "ndev = %d (wrong value)", ndev);
+
+ /* disable TX irq, release skb when sending new packet */
+ IFX_REG_W32_MASK(1 << (ndev + 16), 0, MBOX_IGU1_IER);
+
+ /* wake up TX queue */
+ netif_wake_queue(dev);
+
+ return;
+}
+
+static INLINE void adsl_led_flash(void)
+{
+}
+
+static INLINE struct sk_buff* alloc_skb_rx(void)
+{
+ struct sk_buff *skb;
+
+ /* allocate memroy including trailer and padding */
+ skb = dev_alloc_skb(rx_max_packet_size + RX_HEAD_MAC_ADDR_ALIGNMENT + DATA_BUFFER_ALIGNMENT);
+ if ( skb != NULL ) {
+ /* must be burst length alignment and reserve two more bytes for MAC address alignment */
+ if ( ((unsigned int)skb->data & (DATA_BUFFER_ALIGNMENT - 1)) != 0 )
+ skb_reserve(skb, ~((unsigned int)skb->data + (DATA_BUFFER_ALIGNMENT - 1)) & (DATA_BUFFER_ALIGNMENT - 1));
+ /* pub skb in reserved area "skb->data - 4" */
+ *((struct sk_buff **)skb->data - 1) = skb;
+ wmb();
+ /* write back and invalidate cache */
+ dma_cache_wback_inv((unsigned long)skb->data - sizeof(skb), sizeof(skb));
+ /* invalidate cache */
+ dma_cache_inv((unsigned long)skb->data, (unsigned int)skb->end - (unsigned int)skb->data);
+ }
+
+ return skb;
+}
+
+#if 0
+static INLINE struct sk_buff* alloc_skb_tx(unsigned int size)
+{
+ struct sk_buff *skb;
+
+ /* allocate memory including padding */
+ size = (size + DATA_BUFFER_ALIGNMENT - 1) & ~(DATA_BUFFER_ALIGNMENT - 1);
+ skb = dev_alloc_skb(size + DATA_BUFFER_ALIGNMENT);
+ /* must be burst length alignment */
+ if ( skb != NULL )
+ skb_reserve(skb, ~((unsigned int)skb->data + (DATA_BUFFER_ALIGNMENT - 1)) & (DATA_BUFFER_ALIGNMENT - 1));
+ return skb;
+}
+#endif
+
+static INLINE struct sk_buff *get_skb_rx_pointer(unsigned int dataptr)
+{
+ unsigned int skb_dataptr;
+ struct sk_buff *skb;
+
+ skb_dataptr = ((dataptr - 1) << 2) | KSEG1;
+ skb = *(struct sk_buff **)skb_dataptr;
+
+ ASSERT((unsigned int)skb >= KSEG0, "invalid skb - skb = %#08x, dataptr = %#08x", (unsigned int)skb, dataptr);
+ ASSERT(((unsigned int)skb->data | KSEG1) == ((dataptr << 2) | KSEG1), "invalid skb - skb = %#08x, skb->data = %#08x, dataptr = %#08x", (unsigned int)skb, (unsigned int)skb->data, dataptr);
+
+ return skb;
+}
+
+static INLINE int get_tx_desc(unsigned int itf, unsigned int *f_full)
+{
+ int desc_base = -1;
+ struct ptm_itf *p_itf = &g_ptm_priv_data.itf[itf];
+
+ // assume TX is serial operation
+ // no protection provided
+
+ *f_full = 1;
+
+ if ( p_itf->tx_desc[p_itf->tx_desc_pos].own == 0 ) {
+ desc_base = p_itf->tx_desc_pos;
+ if ( ++(p_itf->tx_desc_pos) == dma_tx_descriptor_length )
+ p_itf->tx_desc_pos = 0;
+ if ( p_itf->tx_desc[p_itf->tx_desc_pos].own == 0 )
+ *f_full = 0;
+ }
+
+ return desc_base;
+}
+
+static INLINE int mailbox_rx_irq_handler(unsigned int ch) // return: < 0 - descriptor not available, 0 - received one packet
+{
+ unsigned int ndev = ch;
+ struct sk_buff *skb;
+ struct sk_buff *new_skb;
+ volatile struct rx_descriptor *desc;
+ struct rx_descriptor reg_desc;
+ int netif_rx_ret;
+
+ desc = &g_ptm_priv_data.itf[ndev].rx_desc[g_ptm_priv_data.itf[ndev].rx_desc_pos];
+ if ( desc->own || !desc->c ) // if PP32 hold descriptor or descriptor not completed
+ return -EAGAIN;
+ if ( ++g_ptm_priv_data.itf[ndev].rx_desc_pos == dma_rx_descriptor_length )
+ g_ptm_priv_data.itf[ndev].rx_desc_pos = 0;
+
+ reg_desc = *desc;
+ skb = get_skb_rx_pointer(reg_desc.dataptr);
+
+ if ( !reg_desc.err ) {
+ new_skb = alloc_skb_rx();
+ if ( new_skb != NULL ) {
+ skb_reserve(skb, reg_desc.byteoff);
+ skb_put(skb, reg_desc.datalen);
+
+ dump_skb(skb, DUMP_SKB_LEN, (char *)__func__, ndev, ndev, 0);
+
+ // parse protocol header
+ skb->dev = g_net_dev[ndev];
+ skb->protocol = eth_type_trans(skb, skb->dev);
+
+ g_net_dev[ndev]->last_rx = jiffies;
+
+ netif_rx_ret = netif_receive_skb(skb);
+
+ if ( netif_rx_ret != NET_RX_DROP ) {
+ g_ptm_priv_data.itf[ndev].stats.rx_packets++;
+ g_ptm_priv_data.itf[ndev].stats.rx_bytes += reg_desc.datalen;
+ }
+
+ reg_desc.dataptr = ((unsigned int)new_skb->data >> 2) & 0x0FFFFFFF;
+ reg_desc.byteoff = RX_HEAD_MAC_ADDR_ALIGNMENT;
+ }
+ }
+ else
+ reg_desc.err = 0;
+
+ reg_desc.datalen = rx_max_packet_size;
+ reg_desc.own = 1;
+ reg_desc.c = 0;
+
+ // update descriptor
+ *desc = reg_desc;
+ wmb();
+
+ mailbox_signal(ndev, 0);
+
+ adsl_led_flash();
+
+ return 0;
+}
+
+static irqreturn_t mailbox_irq_handler(int irq, void *dev_id)
+{
+ unsigned int isr;
+ int i;
+
+ isr = IFX_REG_R32(MBOX_IGU1_ISR);
+ IFX_REG_W32(isr, MBOX_IGU1_ISRC);
+ isr &= IFX_REG_R32(MBOX_IGU1_IER);
+
+ while ( (i = __fls(isr)) >= 0 ) {
+ isr ^= 1 << i;
+
+ if ( i >= 16 ) {
+ // TX
+ IFX_REG_W32_MASK(1 << i, 0, MBOX_IGU1_IER);
+ i -= 16;
+ if ( i < MAX_ITF_NUMBER )
+ netif_wake_queue(g_net_dev[i]);
+ }
+ else {
+ // RX
+#ifdef CONFIG_IFX_PTM_RX_INTERRUPT
+ while ( WRX_DMA_CHANNEL_CONFIG(i)->vlddes > 0 )
+ mailbox_rx_irq_handler(i);
+#else
+ IFX_REG_W32_MASK(1 << i, 0, MBOX_IGU1_IER);
+ napi_schedule(&g_ptm_priv_data.itf[i].napi);
+#endif
+ }
+ }
+
+ return IRQ_HANDLED;
+}
+
+static INLINE void mailbox_signal(unsigned int itf, int is_tx)
+{
+ int count = 1000;
+
+ if ( is_tx ) {
+ while ( MBOX_IGU3_ISR_ISR(itf + 16) && count > 0 )
+ count--;
+ IFX_REG_W32(MBOX_IGU3_ISRS_SET(itf + 16), MBOX_IGU3_ISRS);
+ }
+ else {
+ while ( MBOX_IGU3_ISR_ISR(itf) && count > 0 )
+ count--;
+ IFX_REG_W32(MBOX_IGU3_ISRS_SET(itf), MBOX_IGU3_ISRS);
+ }
+
+ ASSERT(count != 0, "MBOX_IGU3_ISR = 0x%08x", IFX_REG_R32(MBOX_IGU3_ISR));
+}
+
+#ifdef CONFIG_IFX_PTM_RX_TASKLET
+static void do_ptm_tasklet(unsigned long arg)
+{
+ unsigned int work_to_do = 25;
+ unsigned int work_done = 0;
+
+ ASSERT(arg >= 0 && arg < ARRAY_SIZE(g_net_dev), "arg = %lu (wrong value)", arg);
+
+ while ( work_done < work_to_do && WRX_DMA_CHANNEL_CONFIG(arg)->vlddes > 0 ) {
+ if ( mailbox_rx_irq_handler(arg) < 0 )
+ break;
+
+ work_done++;
+ }
+
+ // interface down
+ if ( !netif_running(g_net_dev[arg]) )
+ return;
+
+ // no more traffic
+ if ( WRX_DMA_CHANNEL_CONFIG(arg)->vlddes == 0 ) {
+ // clear interrupt
+ IFX_REG_W32_MASK(0, 1 << arg, MBOX_IGU1_ISRC);
+ // double check
+ if ( WRX_DMA_CHANNEL_CONFIG(arg)->vlddes == 0 ) {
+ IFX_REG_W32_MASK(0, 1 << arg, MBOX_IGU1_IER);
+ return;
+ }
+ }
+
+ // next round
+ tasklet_schedule(&g_ptm_tasklet[arg]);
+}
+#endif
+
+#if defined(DEBUG_DUMP_SKB) && DEBUG_DUMP_SKB
+static void dump_skb(struct sk_buff *skb, u32 len, char *title, int port, int ch, int is_tx)
+{
+ int i;
+
+ if ( !(ifx_ptm_dbg_enable & (is_tx ? DBG_ENABLE_MASK_DUMP_SKB_TX : DBG_ENABLE_MASK_DUMP_SKB_RX)) )
+ return;
+
+ if ( skb->len < len )
+ len = skb->len;
+
+ if ( len > rx_max_packet_size ) {
+ printk("too big data length: skb = %08x, skb->data = %08x, skb->len = %d\n", (u32)skb, (u32)skb->data, skb->len);
+ return;
+ }
+
+ if ( ch >= 0 )
+ printk("%s (port %d, ch %d)\n", title, port, ch);
+ else
+ printk("%s\n", title);
+ printk(" skb->data = %08X, skb->tail = %08X, skb->len = %d\n", (u32)skb->data, (u32)skb->tail, (int)skb->len);
+ for ( i = 1; i <= len; i++ ) {
+ if ( i % 16 == 1 )
+ printk(" %4d:", i - 1);
+ printk(" %02X", (int)(*((char*)skb->data + i - 1) & 0xFF));
+ if ( i % 16 == 0 )
+ printk("\n");
+ }
+ if ( (i - 1) % 16 != 0 )
+ printk("\n");
+}
+#endif
+
+#if defined(ENABLE_DBG_PROC) && ENABLE_DBG_PROC
+static void skb_swap(struct sk_buff *skb)
+{
+ unsigned char tmp[8];
+ unsigned char *p = skb->data;
+
+ if ( !(p[0] & 0x01) ) { // bypass broadcast/multicast
+ // swap MAC
+ memcpy(tmp, p, 6);
+ memcpy(p, p + 6, 6);
+ memcpy(p + 6, tmp, 6);
+ p += 12;
+
+ // bypass VLAN
+ while ( p[0] == 0x81 && p[1] == 0x00 )
+ p += 4;
+
+ // IP
+ if ( p[0] == 0x08 && p[1] == 0x00 ) {
+ p += 14;
+ memcpy(tmp, p, 4);
+ memcpy(p, p + 4, 4);
+ memcpy(p + 4, tmp, 4);
+ p += 8;
+ }
+
+ dma_cache_wback((unsigned long)skb->data, (unsigned long)p - (unsigned long)skb->data);
+ }
+}
+#endif
+
+static INLINE void proc_file_create(void)
+{
+ struct proc_dir_entry *res;
+
+ g_ptm_dir = proc_mkdir("driver/ifx_ptm", NULL);
+
+ create_proc_read_entry("version",
+ 0,
+ g_ptm_dir,
+ proc_read_version,
+ NULL);
+
+ res = create_proc_entry("wanmib",
+ 0,
+ g_ptm_dir);
+ if ( res != NULL ) {
+ res->read_proc = proc_read_wanmib;
+ res->write_proc = proc_write_wanmib;
+ }
+
+#if defined(ENABLE_FW_PROC) && ENABLE_FW_PROC
+ create_proc_read_entry("genconf",
+ 0,
+ g_ptm_dir,
+ proc_read_genconf,
+ NULL);
+
+ #ifdef CONFIG_AR9
+ create_proc_read_entry("regs",
+ 0,
+ g_ptm_dir,
+ ifx_ptm_proc_read_regs,
+ NULL);
+ #endif
+#endif
+
+#if defined(ENABLE_DBG_PROC) && ENABLE_DBG_PROC
+ res = create_proc_entry("dbg",
+ 0,
+ g_ptm_dir);
+ if ( res != NULL ) {
+ res->read_proc = proc_read_dbg;
+ res->write_proc = proc_write_dbg;
+ }
+#endif
+}
+
+static INLINE void proc_file_delete(void)
+{
+#if defined(ENABLE_DBG_PROC) && ENABLE_DBG_PROC
+ remove_proc_entry("dbg", g_ptm_dir);
+#endif
+
+#if defined(ENABLE_FW_PROC) && ENABLE_FW_PROC
+ #ifdef CONFIG_AR9
+ remove_proc_entry("regs", g_ptm_dir);
+ #endif
+
+ remove_proc_entry("genconf", g_ptm_dir);
+#endif
+
+ remove_proc_entry("wanmib", g_ptm_dir);
+
+ remove_proc_entry("version", g_ptm_dir);
+
+ remove_proc_entry("driver/ifx_ptm", NULL);
+}
+
+static int proc_read_version(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+{
+ int len = 0;
+
+ len += ifx_ptm_version(buf + len);
+
+ if ( offset >= len ) {
+ *start = buf;
+ *eof = 1;
+ return 0;
+ }
+ *start = buf + offset;
+ if ( (len -= offset) > count )
+ return count;
+ *eof = 1;
+ return len;
+}
+
+static int proc_read_wanmib(char *page, char **start, off_t off, int count, int *eof, void *data)
+{
+ int len = 0;
+ int i;
+ char *title[] = {
+ "ptm0\n",
+ "ptmfast0\n"
+ };
+
+ for ( i = 0; i < ARRAY_SIZE(title); i++ ) {
+ len += sprintf(page + off + len, title[i]);
+ len += sprintf(page + off + len, " wrx_correct_pdu = %d\n", WAN_MIB_TABLE[i].wrx_correct_pdu);
+ len += sprintf(page + off + len, " wrx_correct_pdu_bytes = %d\n", WAN_MIB_TABLE[i].wrx_correct_pdu_bytes);
+ len += sprintf(page + off + len, " wrx_tccrc_err_pdu = %d\n", WAN_MIB_TABLE[i].wrx_tccrc_err_pdu);
+ len += sprintf(page + off + len, " wrx_tccrc_err_pdu_bytes = %d\n", WAN_MIB_TABLE[i].wrx_tccrc_err_pdu_bytes);
+ len += sprintf(page + off + len, " wrx_ethcrc_err_pdu = %d\n", WAN_MIB_TABLE[i].wrx_ethcrc_err_pdu);
+ len += sprintf(page + off + len, " wrx_ethcrc_err_pdu_bytes = %d\n", WAN_MIB_TABLE[i].wrx_ethcrc_err_pdu_bytes);
+ len += sprintf(page + off + len, " wrx_nodesc_drop_pdu = %d\n", WAN_MIB_TABLE[i].wrx_nodesc_drop_pdu);
+ len += sprintf(page + off + len, " wrx_len_violation_drop_pdu = %d\n", WAN_MIB_TABLE[i].wrx_len_violation_drop_pdu);
+ len += sprintf(page + off + len, " wrx_idle_bytes = %d\n", WAN_MIB_TABLE[i].wrx_idle_bytes);
+ len += sprintf(page + off + len, " wrx_nonidle_cw = %d\n", WAN_MIB_TABLE[i].wrx_nonidle_cw);
+ len += sprintf(page + off + len, " wrx_idle_cw = %d\n", WAN_MIB_TABLE[i].wrx_idle_cw);
+ len += sprintf(page + off + len, " wrx_err_cw = %d\n", WAN_MIB_TABLE[i].wrx_err_cw);
+ len += sprintf(page + off + len, " wtx_total_pdu = %d\n", WAN_MIB_TABLE[i].wtx_total_pdu);
+ len += sprintf(page + off + len, " wtx_total_bytes = %d\n", WAN_MIB_TABLE[i].wtx_total_bytes);
+ }
+
+ *eof = 1;
+
+ return len;
+}
+
+static int proc_write_wanmib(struct file *file, const char *buf, unsigned long count, void *data)
+{
+ char str[2048];
+ char *p;
+ int len, rlen;
+
+ int i;
+
+ len = count < sizeof(str) ? count : sizeof(str) - 1;
+ rlen = len - copy_from_user(str, buf, len);
+ while ( rlen && str[rlen - 1] <= ' ' )
+ rlen--;
+ str[rlen] = 0;
+ for ( p = str; *p && *p <= ' '; p++, rlen-- );
+ if ( !*p )
+ return count;
+
+ if ( stricmp(p, "clear") == 0 || stricmp(p, "clean") == 0 ) {
+ for ( i = 0; i < 2; i++ )
+ memset((void*)&WAN_MIB_TABLE[i], 0, sizeof(WAN_MIB_TABLE[i]));
+ }
+
+ return count;
+}
+
+#if defined(ENABLE_FW_PROC) && ENABLE_FW_PROC
+
+static int proc_read_genconf(char *page, char **start, off_t off, int count, int *eof, void *data)
+{
+ int len = 0;
+ int len_max = off + count;
+ char *pstr;
+ char str[2048];
+ int llen = 0;
+ int i;
+ unsigned long bit;
+
+ pstr = *start = page;
+
+ __sync();
+
+ llen += sprintf(str + llen, "CFG_WAN_WRDES_DELAY (0x%08X): %d\n", (unsigned int)CFG_WAN_WRDES_DELAY, IFX_REG_R32(CFG_WAN_WRDES_DELAY));
+ llen += sprintf(str + llen, "CFG_WRX_DMACH_ON (0x%08X):", (unsigned int)CFG_WRX_DMACH_ON);
+ for ( i = 0, bit = 1; i < MAX_RX_DMA_CHANNEL_NUMBER; i++, bit <<= 1 )
+ llen += sprintf(str + llen, " %d - %s", i, (IFX_REG_R32(CFG_WRX_DMACH_ON) & bit) ? "on " : "off");
+ llen += sprintf(str + llen, "\n");
+ llen += sprintf(str + llen, "CFG_WTX_DMACH_ON (0x%08X):", (unsigned int)CFG_WTX_DMACH_ON);
+ for ( i = 0, bit = 1; i < MAX_TX_DMA_CHANNEL_NUMBER; i++, bit <<= 1 )
+ llen += sprintf(str + llen, " %d - %s", i, (IFX_REG_R32(CFG_WTX_DMACH_ON) & bit) ? "on " : "off");
+ llen += sprintf(str + llen, "\n");
+ llen += sprintf(str + llen, "CFG_WRX_LOOK_BITTH (0x%08X): %d\n", (unsigned int)CFG_WRX_LOOK_BITTH, IFX_REG_R32(CFG_WRX_LOOK_BITTH));
+ llen += sprintf(str + llen, "CFG_ETH_EFMTC_CRC (0x%08X): rx_tc_crc_len - %2d, rx_tc_crc_check - %s\n", (unsigned int)CFG_ETH_EFMTC_CRC, CFG_ETH_EFMTC_CRC->rx_tc_crc_len, CFG_ETH_EFMTC_CRC->rx_tc_crc_check ? " on" : "off");
+ llen += sprintf(str + llen, " rx_eth_crc_check - %s, rx_eth_crc_present - %s\n", CFG_ETH_EFMTC_CRC->rx_eth_crc_check ? " on" : "off", CFG_ETH_EFMTC_CRC->rx_eth_crc_present ? " on" : "off");
+ llen += sprintf(str + llen, " tx_tc_crc_len - %2d, tx_tc_crc_gen - %s\n", CFG_ETH_EFMTC_CRC->tx_tc_crc_len, CFG_ETH_EFMTC_CRC->tx_tc_crc_gen ? " on" : "off");
+ llen += sprintf(str + llen, " tx_eth_crc_gen - %s\n", CFG_ETH_EFMTC_CRC->tx_eth_crc_gen ? " on" : "off");
+
+ llen += sprintf(str + llen, "RX Port:\n");
+ for ( i = 0; i < MAX_RX_DMA_CHANNEL_NUMBER; i++ )
+ llen += sprintf(str + llen, " %d (0x%08X). mfs - %5d, dmach - %d, local_state - %d, partner_state - %d\n", i, (unsigned int)WRX_PORT_CONFIG(i), WRX_PORT_CONFIG(i)->mfs, WRX_PORT_CONFIG(i)->dmach, WRX_PORT_CONFIG(i)->local_state, WRX_PORT_CONFIG(i)->partner_state);
+ llen += sprintf(str + llen, "RX DMA Channel:\n");
+ for ( i = 0; i < MAX_RX_DMA_CHANNEL_NUMBER; i++ )
+ llen += sprintf(str + llen, " %d (0x%08X). desba - 0x%08X (0x%08X), deslen - %d, vlddes - %d\n", i, (unsigned int)WRX_DMA_CHANNEL_CONFIG(i), WRX_DMA_CHANNEL_CONFIG(i)->desba, ((unsigned int)WRX_DMA_CHANNEL_CONFIG(i)->desba << 2) | KSEG1, WRX_DMA_CHANNEL_CONFIG(i)->deslen, WRX_DMA_CHANNEL_CONFIG(i)->vlddes);
+
+ llen += sprintf(str + llen, "TX Port:\n");
+ for ( i = 0; i < MAX_TX_DMA_CHANNEL_NUMBER; i++ )
+ llen += sprintf(str + llen, " %d (0x%08X). tx_cwth2 - %d, tx_cwth1 - %d\n", i, (unsigned int)WTX_PORT_CONFIG(i), WTX_PORT_CONFIG(i)->tx_cwth2, WTX_PORT_CONFIG(i)->tx_cwth1);
+ llen += sprintf(str + llen, "TX DMA Channel:\n");
+ for ( i = 0; i < MAX_TX_DMA_CHANNEL_NUMBER; i++ )
+ llen += sprintf(str + llen, " %d (0x%08X). desba - 0x%08X (0x%08X), deslen - %d, vlddes - %d\n", i, (unsigned int)WTX_DMA_CHANNEL_CONFIG(i), WTX_DMA_CHANNEL_CONFIG(i)->desba, ((unsigned int)WTX_DMA_CHANNEL_CONFIG(i)->desba << 2) | KSEG1, WTX_DMA_CHANNEL_CONFIG(i)->deslen, WTX_DMA_CHANNEL_CONFIG(i)->vlddes);
+
+ if ( len <= off && len + llen > off )
+ {
+ memcpy(pstr, str + off - len, len + llen - off);
+ pstr += len + llen - off;
+ }
+ else if ( len > off )
+ {
+ memcpy(pstr, str, llen);
+ pstr += llen;
+ }
+ len += llen;
+ if ( len >= len_max )
+ goto PROC_READ_GENCONF_OVERRUN_END;
+
+ *eof = 1;
+
+ return len - off;
+
+PROC_READ_GENCONF_OVERRUN_END:
+ return len - llen - off;
+}
+
+#endif // defined(ENABLE_FW_PROC) && ENABLE_FW_PROC
+
+#if defined(ENABLE_DBG_PROC) && ENABLE_DBG_PROC
+
+static int proc_read_dbg(char *page, char **start, off_t off, int count, int *eof, void *data)
+{
+ int len = 0;
+
+ len += sprintf(page + off + len, "error print - %s\n", (ifx_ptm_dbg_enable & DBG_ENABLE_MASK_ERR) ? "enabled" : "disabled");
+ len += sprintf(page + off + len, "debug print - %s\n", (ifx_ptm_dbg_enable & DBG_ENABLE_MASK_DEBUG_PRINT) ? "enabled" : "disabled");
+ len += sprintf(page + off + len, "assert - %s\n", (ifx_ptm_dbg_enable & DBG_ENABLE_MASK_ASSERT) ? "enabled" : "disabled");
+ len += sprintf(page + off + len, "dump rx skb - %s\n", (ifx_ptm_dbg_enable & DBG_ENABLE_MASK_DUMP_SKB_RX) ? "enabled" : "disabled");
+ len += sprintf(page + off + len, "dump tx skb - %s\n", (ifx_ptm_dbg_enable & DBG_ENABLE_MASK_DUMP_SKB_TX) ? "enabled" : "disabled");
+ len += sprintf(page + off + len, "mac swap - %s\n", (ifx_ptm_dbg_enable & DBG_ENABLE_MASK_MAC_SWAP) ? "enabled" : "disabled");
+
+ *eof = 1;
+
+ return len;
+}
+
+static int proc_write_dbg(struct file *file, const char *buf, unsigned long count, void *data)
+{
+ static const char *dbg_enable_mask_str[] = {
+ " error print",
+ " err",
+ " debug print",
+ " dbg",
+ " assert",
+ " assert",
+ " dump rx skb",
+ " rx",
+ " dump tx skb",
+ " tx",
+ " dump init",
+ " init",
+ " dump qos",
+ " qos",
+ " mac swap",
+ " swap",
+ " all"
+ };
+ static const int dbg_enable_mask_str_len[] = {
+ 12, 4,
+ 12, 4,
+ 7, 7,
+ 12, 3,
+ 12, 3,
+ 10, 5,
+ 9, 4,
+ 9, 5,
+ 4
+ };
+ unsigned int dbg_enable_mask[] = {
+ DBG_ENABLE_MASK_ERR,
+ DBG_ENABLE_MASK_DEBUG_PRINT,
+ DBG_ENABLE_MASK_ASSERT,
+ DBG_ENABLE_MASK_DUMP_SKB_RX,
+ DBG_ENABLE_MASK_DUMP_SKB_TX,
+ DBG_ENABLE_MASK_DUMP_INIT,
+ DBG_ENABLE_MASK_DUMP_QOS,
+ DBG_ENABLE_MASK_MAC_SWAP,
+ DBG_ENABLE_MASK_ALL
+ };
+
+ char str[2048];
+ char *p;
+
+ int len, rlen;
+
+ int f_enable = 0;
+ int i;
+
+ len = count < sizeof(str) ? count : sizeof(str) - 1;
+ rlen = len - copy_from_user(str, buf, len);
+ while ( rlen && str[rlen - 1] <= ' ' )
+ rlen--;
+ str[rlen] = 0;
+ for ( p = str; *p && *p <= ' '; p++, rlen-- );
+ if ( !*p )
+ return 0;
+
+ // debugging feature for enter/leave showtime
+ if ( strincmp(p, "enter", 5) == 0 && ifx_mei_atm_showtime_enter != NULL )
+ ifx_mei_atm_showtime_enter(NULL, NULL);
+ else if ( strincmp(p, "leave", 5) == 0 && ifx_mei_atm_showtime_exit != NULL )
+ ifx_mei_atm_showtime_exit();
+
+ if ( strincmp(p, "enable", 6) == 0 ) {
+ p += 6;
+ f_enable = 1;
+ }
+ else if ( strincmp(p, "disable", 7) == 0 ) {
+ p += 7;
+ f_enable = -1;
+ }
+ else if ( strincmp(p, "help", 4) == 0 || *p == '?' ) {
+ printk("echo <enable/disable> [err/dbg/assert/rx/tx/init/qos/swap/all] > /proc/driver/ifx_ptm/dbg\n");
+ }
+
+ if ( f_enable ) {
+ if ( *p == 0 ) {
+ if ( f_enable > 0 )
+ ifx_ptm_dbg_enable |= DBG_ENABLE_MASK_ALL & ~DBG_ENABLE_MASK_MAC_SWAP;
+ else
+ ifx_ptm_dbg_enable &= ~DBG_ENABLE_MASK_ALL | DBG_ENABLE_MASK_MAC_SWAP;
+ }
+ else {
+ do {
+ for ( i = 0; i < ARRAY_SIZE(dbg_enable_mask_str); i++ )
+ if ( strincmp(p, dbg_enable_mask_str[i], dbg_enable_mask_str_len[i]) == 0 ) {
+ if ( f_enable > 0 )
+ ifx_ptm_dbg_enable |= dbg_enable_mask[i >> 1];
+ else
+ ifx_ptm_dbg_enable &= ~dbg_enable_mask[i >> 1];
+ p += dbg_enable_mask_str_len[i];
+ break;
+ }
+ } while ( i < ARRAY_SIZE(dbg_enable_mask_str) );
+ }
+ }
+
+ return count;
+}
+
+#endif // defined(ENABLE_DBG_PROC) && ENABLE_DBG_PROC
+
+static INLINE int stricmp(const char *p1, const char *p2)
+{
+ int c1, c2;
+
+ while ( *p1 && *p2 )
+ {
+ c1 = *p1 >= 'A' && *p1 <= 'Z' ? *p1 + 'a' - 'A' : *p1;
+ c2 = *p2 >= 'A' && *p2 <= 'Z' ? *p2 + 'a' - 'A' : *p2;
+ if ( (c1 -= c2) )
+ return c1;
+ p1++;
+ p2++;
+ }
+
+ return *p1 - *p2;
+}
+
+#if defined(ENABLE_DBG_PROC) && ENABLE_DBG_PROC
+static INLINE int strincmp(const char *p1, const char *p2, int n)
+{
+ int c1 = 0, c2;
+
+ while ( n && *p1 && *p2 )
+ {
+ c1 = *p1 >= 'A' && *p1 <= 'Z' ? *p1 + 'a' - 'A' : *p1;
+ c2 = *p2 >= 'A' && *p2 <= 'Z' ? *p2 + 'a' - 'A' : *p2;
+ if ( (c1 -= c2) )
+ return c1;
+ p1++;
+ p2++;
+ n--;
+ }
+
+ return n ? *p1 - *p2 : c1;
+}
+#endif
+
+static INLINE int ifx_ptm_version(char *buf)
+{
+ int len = 0;
+ unsigned int major, minor;
+
+ ifx_ptm_get_fw_ver(&major, &minor);
+
+ len += sprintf(buf + len, "PTM %d.%d.%d", IFX_PTM_VER_MAJOR, IFX_PTM_VER_MID, IFX_PTM_VER_MINOR);
+ len += sprintf(buf + len, " PTM (E1) firmware version %d.%d\n", major, minor);
+
+ return len;
+}
+
+static INLINE void check_parameters(void)
+{
+ /* There is a delay between PPE write descriptor and descriptor is */
+ /* really stored in memory. Host also has this delay when writing */
+ /* descriptor. So PPE will use this value to determine if the write */
+ /* operation makes effect. */
+ if ( write_desc_delay < 0 )
+ write_desc_delay = 0;
+
+ /* Because of the limitation of length field in descriptors, the packet */
+ /* size could not be larger than 64K minus overhead size. */
+ if ( rx_max_packet_size < ETH_MIN_FRAME_LENGTH )
+ rx_max_packet_size = ETH_MIN_FRAME_LENGTH;
+ else if ( rx_max_packet_size > 65536 - 1 )
+ rx_max_packet_size = 65536 - 1;
+
+ if ( dma_rx_descriptor_length < 2 )
+ dma_rx_descriptor_length = 2;
+ if ( dma_tx_descriptor_length < 2 )
+ dma_tx_descriptor_length = 2;
+}
+
+static INLINE int init_priv_data(void)
+{
+ void *p;
+ int i;
+ struct rx_descriptor rx_desc = {0};
+ struct sk_buff *skb;
+ volatile struct rx_descriptor *p_rx_desc;
+ volatile struct tx_descriptor *p_tx_desc;
+ struct sk_buff **ppskb;
+
+ // clear ptm private data structure
+ memset(&g_ptm_priv_data, 0, sizeof(g_ptm_priv_data));
+
+ // allocate memory for RX descriptors
+ p = kzalloc(MAX_ITF_NUMBER * dma_rx_descriptor_length * sizeof(struct rx_descriptor) + DESC_ALIGNMENT, GFP_KERNEL);
+ if ( p == NULL )
+ return -1;
+ dma_cache_inv((unsigned long)p, MAX_ITF_NUMBER * dma_rx_descriptor_length * sizeof(struct rx_descriptor) + DESC_ALIGNMENT);
+ g_ptm_priv_data.rx_desc_base = p;
+ //p = (void *)((((unsigned int)p + DESC_ALIGNMENT - 1) & ~(DESC_ALIGNMENT - 1)) | KSEG1);
+
+ // allocate memory for TX descriptors
+ p = kzalloc(MAX_ITF_NUMBER * dma_tx_descriptor_length * sizeof(struct tx_descriptor) + DESC_ALIGNMENT, GFP_KERNEL);
+ if ( p == NULL )
+ return -1;
+ dma_cache_inv((unsigned long)p, MAX_ITF_NUMBER * dma_tx_descriptor_length * sizeof(struct tx_descriptor) + DESC_ALIGNMENT);
+ g_ptm_priv_data.tx_desc_base = p;
+
+ // allocate memroy for TX skb pointers
+ p = kzalloc(MAX_ITF_NUMBER * dma_tx_descriptor_length * sizeof(struct sk_buff *) + 4, GFP_KERNEL);
+ if ( p == NULL )
+ return -1;
+ dma_cache_wback_inv((unsigned long)p, MAX_ITF_NUMBER * dma_tx_descriptor_length * sizeof(struct sk_buff *) + 4);
+ g_ptm_priv_data.tx_skb_base = p;
+
+ p_rx_desc = (volatile struct rx_descriptor *)((((unsigned int)g_ptm_priv_data.rx_desc_base + DESC_ALIGNMENT - 1) & ~(DESC_ALIGNMENT - 1)) | KSEG1);
+ p_tx_desc = (volatile struct tx_descriptor *)((((unsigned int)g_ptm_priv_data.tx_desc_base + DESC_ALIGNMENT - 1) & ~(DESC_ALIGNMENT - 1)) | KSEG1);
+ ppskb = (struct sk_buff **)(((unsigned int)g_ptm_priv_data.tx_skb_base + 3) & ~3);
+ for ( i = 0; i < MAX_ITF_NUMBER; i++ ) {
+ g_ptm_priv_data.itf[i].rx_desc = &p_rx_desc[i * dma_rx_descriptor_length];
+ g_ptm_priv_data.itf[i].tx_desc = &p_tx_desc[i * dma_tx_descriptor_length];
+ g_ptm_priv_data.itf[i].tx_skb = &ppskb[i * dma_tx_descriptor_length];
+ }
+
+ rx_desc.own = 1;
+ rx_desc.c = 0;
+ rx_desc.sop = 1;
+ rx_desc.eop = 1;
+ rx_desc.byteoff = RX_HEAD_MAC_ADDR_ALIGNMENT;
+ rx_desc.id = 0;
+ rx_desc.err = 0;
+ rx_desc.datalen = rx_max_packet_size;
+ for ( i = 0; i < MAX_ITF_NUMBER * dma_rx_descriptor_length; i++ ) {
+ skb = alloc_skb_rx();
+ if ( skb == NULL )
+ return -1;
+ rx_desc.dataptr = ((unsigned int)skb->data >> 2) & 0x0FFFFFFF;
+ p_rx_desc[i] = rx_desc;
+ }
+
+ return 0;
+}
+
+static INLINE void clear_priv_data(void)
+{
+ int i, j;
+ struct sk_buff *skb;
+
+ for ( i = 0; i < MAX_ITF_NUMBER; i++ ) {
+ if ( g_ptm_priv_data.itf[i].tx_skb != NULL ) {
+ for ( j = 0; j < dma_tx_descriptor_length; j++ )
+ if ( g_ptm_priv_data.itf[i].tx_skb[j] != NULL )
+ dev_kfree_skb_any(g_ptm_priv_data.itf[i].tx_skb[j]);
+ }
+ if ( g_ptm_priv_data.itf[i].rx_desc != NULL ) {
+ for ( j = 0; j < dma_rx_descriptor_length; j++ ) {
+ if ( g_ptm_priv_data.itf[i].rx_desc[j].sop || g_ptm_priv_data.itf[i].rx_desc[j].eop ) { // descriptor initialized
+ skb = get_skb_rx_pointer(g_ptm_priv_data.itf[i].rx_desc[j].dataptr);
+ dev_kfree_skb_any(skb);
+ }
+ }
+ }
+ }
+
+ if ( g_ptm_priv_data.rx_desc_base != NULL )
+ kfree(g_ptm_priv_data.rx_desc_base);
+
+ if ( g_ptm_priv_data.tx_desc_base != NULL )
+ kfree(g_ptm_priv_data.tx_desc_base);
+
+ if ( g_ptm_priv_data.tx_skb_base != NULL )
+ kfree(g_ptm_priv_data.tx_skb_base);
+}
+
+static INLINE void init_tables(void)
+{
+ int i;
+ volatile unsigned int *p;
+ struct wrx_dma_channel_config rx_config = {0};
+ struct wtx_dma_channel_config tx_config = {0};
+ struct wrx_port_cfg_status rx_port_cfg = { 0 };
+ struct wtx_port_cfg tx_port_cfg = { 0 };
+
+ /*
+ * CDM Block 1
+ */
+ IFX_REG_W32(CDM_CFG_RAM1_SET(0x00) | CDM_CFG_RAM0_SET(0x00), CDM_CFG); // CDM block 1 must be data memory and mapped to 0x5000 (dword addr)
+ p = CDM_DATA_MEMORY(0, 0); // Clear CDM block 1
+ for ( i = 0; i < CDM_DATA_MEMORY_DWLEN; i++, p++ )
+ IFX_REG_W32(0, p);
+
+ /*
+ * General Registers
+ */
+ IFX_REG_W32(write_desc_delay, CFG_WAN_WRDES_DELAY);
+ IFX_REG_W32((1 << MAX_RX_DMA_CHANNEL_NUMBER) - 1, CFG_WRX_DMACH_ON);
+ IFX_REG_W32((1 << MAX_TX_DMA_CHANNEL_NUMBER) - 1, CFG_WTX_DMACH_ON);
+
+ IFX_REG_W32(8, CFG_WRX_LOOK_BITTH); // WAN RX EFM-TC Looking Threshold
+
+ IFX_REG_W32(eth_efmtc_crc_cfg, CFG_ETH_EFMTC_CRC);
+
+ /*
+ * WRX DMA Channel Configuration Table
+ */
+ rx_config.deslen = dma_rx_descriptor_length;
+ rx_port_cfg.mfs = ETH_MAX_FRAME_LENGTH;
+ rx_port_cfg.local_state = 0; // looking for sync
+ rx_port_cfg.partner_state = 0; // parter receiver is out of sync
+
+ for ( i = 0; i < MAX_RX_DMA_CHANNEL_NUMBER; i++ ) {
+ rx_config.desba = ((unsigned int)g_ptm_priv_data.itf[i].rx_desc >> 2) & 0x0FFFFFFF;
+ *WRX_DMA_CHANNEL_CONFIG(i) = rx_config;
+
+ rx_port_cfg.dmach = i;
+ *WRX_PORT_CONFIG(i) = rx_port_cfg;
+ }
+
+ /*
+ * WTX DMA Channel Configuration Table
+ */
+ tx_config.deslen = dma_tx_descriptor_length;
+ tx_port_cfg.tx_cwth1 = 5;
+ tx_port_cfg.tx_cwth2 = 4;
+
+ for ( i = 0; i < MAX_TX_DMA_CHANNEL_NUMBER; i++ ) {
+ tx_config.desba = ((unsigned int)g_ptm_priv_data.itf[i].tx_desc >> 2) & 0x0FFFFFFF;
+ *WTX_DMA_CHANNEL_CONFIG(i) = tx_config;
+
+ *WTX_PORT_CONFIG(i) = tx_port_cfg;
+ }
+}
+
+
+
+/*
+ * ####################################
+ * Global Function
+ * ####################################
+ */
+
+static int ptm_showtime_enter(struct port_cell_info *port_cell, void *xdata_addr)
+{
+
+ g_showtime = 1;
+
+ printk("enter showtime\n");
+
+ return 0;
+}
+
+static int ptm_showtime_exit(void)
+{
+ if ( !g_showtime )
+ return -1;
+
+ g_showtime = 0;
+
+ printk("leave showtime\n");
+
+ return 0;
+}
+
+
+
+/*
+ * ####################################
+ * Init/Cleanup API
+ * ####################################
+ */
+
+/*
+ * Description:
+ * Initialize global variables, PP32, comunication structures, register IRQ
+ * and register device.
+ * Input:
+ * none
+ * Output:
+ * 0 --- successful
+ * else --- failure, usually it is negative value of error code
+ */
+static int ifx_ptm_init(void)
+{
+ int ret;
+ struct port_cell_info port_cell = {0};
+ void *xdata_addr = NULL;
+ int i;
+ char ver_str[256];
+
+ check_parameters();
+
+ ret = init_priv_data();
+ if ( ret != 0 ) {
+ err("INIT_PRIV_DATA_FAIL");
+ goto INIT_PRIV_DATA_FAIL;
+ }
+
+ ifx_ptm_init_chip();
+ init_tables();
+
+ for ( i = 0; i < ARRAY_SIZE(g_net_dev); i++ ) {
+ g_net_dev[i] = alloc_netdev(0, g_net_dev_name[i], ether_setup);
+ if ( g_net_dev[i] == NULL )
+ goto ALLOC_NETDEV_FAIL;
+ ptm_setup(g_net_dev[i], i);
+ }
+
+ for ( i = 0; i < ARRAY_SIZE(g_net_dev); i++ ) {
+ ret = register_netdev(g_net_dev[i]);
+ if ( ret != 0 )
+ goto REGISTER_NETDEV_FAIL;
+ }
+
+ /* register interrupt handler */
+ ret = request_irq(PPE_MAILBOX_IGU1_INT, mailbox_irq_handler, IRQF_DISABLED, "ptm_mailbox_isr", &g_ptm_priv_data);
+ if ( ret ) {
+ if ( ret == -EBUSY ) {
+ err("IRQ may be occupied by other driver, please reconfig to disable it.");
+ }
+ else {
+ err("request_irq fail");
+ }
+ goto REQUEST_IRQ_PPE_MAILBOX_IGU1_INT_FAIL;
+ }
+ disable_irq(PPE_MAILBOX_IGU1_INT);
+
+ ret = ifx_pp32_start(0);
+ if ( ret ) {
+ err("ifx_pp32_start fail!");
+ goto PP32_START_FAIL;
+ }
+ IFX_REG_W32(0, MBOX_IGU1_IER);
+ IFX_REG_W32(~0, MBOX_IGU1_ISRC);
+
+ enable_irq(PPE_MAILBOX_IGU1_INT);
+
+
+ proc_file_create();
+
+ port_cell.port_num = 1;
+ ifx_mei_atm_showtime_check(&g_showtime, &port_cell, &xdata_addr);
+
+ ifx_mei_atm_showtime_enter = ptm_showtime_enter;
+ ifx_mei_atm_showtime_exit = ptm_showtime_exit;
+
+ ifx_ptm_version(ver_str);
+ printk(KERN_INFO "%s", ver_str);
+
+ printk("ifxmips_ptm: PTM init succeed\n");
+
+ return 0;
+
+PP32_START_FAIL:
+ free_irq(PPE_MAILBOX_IGU1_INT, &g_ptm_priv_data);
+REQUEST_IRQ_PPE_MAILBOX_IGU1_INT_FAIL:
+ i = ARRAY_SIZE(g_net_dev);
+REGISTER_NETDEV_FAIL:
+ while ( i-- )
+ unregister_netdev(g_net_dev[i]);
+ i = ARRAY_SIZE(g_net_dev);
+ALLOC_NETDEV_FAIL:
+ while ( i-- ) {
+ free_netdev(g_net_dev[i]);
+ g_net_dev[i] = NULL;
+ }
+INIT_PRIV_DATA_FAIL:
+ clear_priv_data();
+ printk("ifxmips_ptm: PTM init failed\n");
+ return ret;
+}
+
+/*
+ * Description:
+ * Release memory, free IRQ, and deregister device.
+ * Input:
+ * none
+ * Output:
+ * none
+ */
+static void __exit ifx_ptm_exit(void)
+{
+ int i;
+
+ ifx_mei_atm_showtime_enter = NULL;
+ ifx_mei_atm_showtime_exit = NULL;
+
+ proc_file_delete();
+
+
+ ifx_pp32_stop(0);
+
+ free_irq(PPE_MAILBOX_IGU1_INT, &g_ptm_priv_data);
+
+ for ( i = 0; i < ARRAY_SIZE(g_net_dev); i++ )
+ unregister_netdev(g_net_dev[i]);
+
+ for ( i = 0; i < ARRAY_SIZE(g_net_dev); i++ ) {
+ free_netdev(g_net_dev[i]);
+ g_net_dev[i] = NULL;
+ }
+
+ ifx_ptm_uninit_chip();
+
+ clear_priv_data();
+}
+
+module_init(ifx_ptm_init);
+module_exit(ifx_ptm_exit);
diff --git a/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_adsl.h.svn-base b/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_adsl.h.svn-base
new file mode 100644
index 0000000..de307bf
--- /dev/null
+++ b/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_adsl.h.svn-base
@@ -0,0 +1,137 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_ptm_adsl.h
+** PROJECT : UEIP
+** MODULES : PTM
+**
+** DATE : 7 Jul 2009
+** AUTHOR : Xu Liang
+** DESCRIPTION : PTM driver header file (core functions for Danube/Amazon-SE/
+** AR9)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 17 JUN 2009 Xu Liang Init Version
+*******************************************************************************/
+
+#ifndef IFXMIPS_PTM_ADSL_H
+#define IFXMIPS_PTM_ADSL_H
+
+
+
+#include <linux/version.h>
+#include <linux/netdevice.h>
+#include <lantiq_ptm.h>
+#include "ifxmips_ptm_common.h"
+#include "ifxmips_ptm_ppe_common.h"
+#include "ifxmips_ptm_fw_regs_adsl.h"
+
+#define CONFIG_IFXMIPS_DSL_CPE_MEI
+#define INT_NUM_IM2_IRL24 (INT_NUM_IM2_IRL0 + 24)
+
+#define IFX_REG_W32(_v, _r) __raw_writel((_v), (volatile unsigned int *)(_r))
+#define IFX_REG_R32(_r) __raw_readl((volatile unsigned int *)(_r))
+#define IFX_REG_W32_MASK(_clr, _set, _r) IFX_REG_W32((IFX_REG_R32((_r)) & ~(_clr)) | (_set), (_r))
+#define SET_BITS(x, msb, lsb, value) (((x) & ~(((1 << ((msb) + 1)) - 1) ^ ((1 << (lsb)) - 1))) | (((value) & ((1 << (1 + (msb) - (lsb))) - 1)) << (lsb)))
+
+
+
+
+/*
+ * ####################################
+ * Definition
+ * ####################################
+ */
+
+/*
+ * Constant Definition
+ */
+#define ETH_WATCHDOG_TIMEOUT (2 * HZ)
+
+/*
+ * DMA RX/TX Channel Parameters
+ */
+#define MAX_ITF_NUMBER 2
+#define MAX_RX_DMA_CHANNEL_NUMBER MAX_ITF_NUMBER
+#define MAX_TX_DMA_CHANNEL_NUMBER MAX_ITF_NUMBER
+#define DATA_BUFFER_ALIGNMENT EMA_ALIGNMENT
+#define DESC_ALIGNMENT 8
+
+/*
+ * Ethernet Frame Definitions
+ */
+#define ETH_MAC_HEADER_LENGTH 14
+#define ETH_CRC_LENGTH 4
+#define ETH_MIN_FRAME_LENGTH 64
+#define ETH_MAX_FRAME_LENGTH (1518 + 4 * 2)
+
+/*
+ * RX Frame Definitions
+ */
+#define RX_HEAD_MAC_ADDR_ALIGNMENT 2
+#define RX_TAIL_CRC_LENGTH 0 // PTM firmware does not have ethernet frame CRC
+ // The len in descriptor doesn't include ETH_CRC
+ // because ETH_CRC may not present in some configuration
+
+
+
+/*
+ * ####################################
+ * Data Type
+ * ####################################
+ */
+
+struct ptm_itf {
+ volatile struct rx_descriptor *rx_desc;
+ unsigned int rx_desc_pos;
+
+ volatile struct tx_descriptor *tx_desc;
+ unsigned int tx_desc_pos;
+ struct sk_buff **tx_skb;
+
+ struct net_device_stats stats;
+
+ struct napi_struct napi;
+};
+
+struct ptm_priv_data {
+ struct ptm_itf itf[MAX_ITF_NUMBER];
+
+ void *rx_desc_base;
+ void *tx_desc_base;
+ void *tx_skb_base;
+};
+
+
+
+/*
+ * ####################################
+ * Declaration
+ * ####################################
+ */
+
+extern unsigned int ifx_ptm_dbg_enable;
+
+extern void ifx_ptm_get_fw_ver(unsigned int *major, unsigned int *minor);
+
+extern void ifx_ptm_init_chip(void);
+extern void ifx_ptm_uninit_chip(void);
+
+extern int ifx_pp32_start(int pp32);
+extern void ifx_pp32_stop(int pp32);
+
+extern void ifx_reset_ppe(void);
+
+extern int ifx_ptm_proc_read_regs(char *page, char **start, off_t off, int count, int *eof, void *data);
+
+
+
+#endif // IFXMIPS_PTM_ADSL_H
diff --git a/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_amazon_se.c.svn-base b/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_amazon_se.c.svn-base
new file mode 100644
index 0000000..077c900
--- /dev/null
+++ b/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_amazon_se.c.svn-base
@@ -0,0 +1,322 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_ptm_amazon_se.c
+** PROJECT : UEIP
+** MODULES : PTM
+**
+** DATE : 7 Jul 2009
+** AUTHOR : Xu Liang
+** DESCRIPTION : PTM driver common source file (core functions)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 07 JUL 2009 Xu Liang Init Version
+*******************************************************************************/
+
+
+
+/*
+ * ####################################
+ * Head File
+ * ####################################
+ */
+
+/*
+ * Common Head File
+ */
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/version.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/proc_fs.h>
+#include <linux/init.h>
+#include <linux/ioctl.h>
+#include <asm/delay.h>
+
+/*
+ * Chip Specific Head File
+ */
+#include <asm/ifx/ifx_types.h>
+#include <asm/ifx/ifx_regs.h>
+#include <asm/ifx/common_routines.h>
+#include <asm/ifx/ifx_pmu.h>
+#include <asm/ifx/ifx_rcu.h>
+#include "ifxmips_ptm_adsl.h"
+#include "ifxmips_ptm_fw_amazon_se.h"
+
+
+
+/*
+ * ####################################
+ * Definition
+ * ####################################
+ */
+
+/*
+ * EMA Settings
+ */
+#define EMA_CMD_BUF_LEN 0x0040
+#define EMA_CMD_BASE_ADDR (0x00001580 << 2)
+#define EMA_DATA_BUF_LEN 0x0100
+#define EMA_DATA_BASE_ADDR (0x00000B00 << 2)
+#define EMA_WRITE_BURST 0x2
+#define EMA_READ_BURST 0x2
+
+
+
+/*
+ * ####################################
+ * Declaration
+ * ####################################
+ */
+
+/*
+ * Hardware Init/Uninit Functions
+ */
+static inline void init_pmu(void);
+static inline void uninit_pmu(void);
+static inline void reset_ppe(void);
+static inline void init_ema(void);
+static inline void init_mailbox(void);
+static inline void init_atm_tc(void);
+static inline void clear_share_buffer(void);
+
+
+
+/*
+ * ####################################
+ * Local Variable
+ * ####################################
+ */
+
+
+
+/*
+ * ####################################
+ * Local Function
+ * ####################################
+ */
+
+static inline void init_pmu(void)
+{
+ //*(unsigned long *)0xBF10201C &= ~((1 << 15) | (1 << 13) | (1 << 9));
+ //PPE_TOP_PMU_SETUP(IFX_PMU_ENABLE);
+ PPE_SLL01_PMU_SETUP(IFX_PMU_ENABLE);
+ PPE_TC_PMU_SETUP(IFX_PMU_ENABLE);
+ PPE_EMA_PMU_SETUP(IFX_PMU_ENABLE);
+ //PPE_QSB_PMU_SETUP(IFX_PMU_ENABLE);
+ PPE_TPE_PMU_SETUP(IFX_PMU_ENABLE);
+ DSL_DFE_PMU_SETUP(IFX_PMU_ENABLE);
+}
+
+static inline void uninit_pmu(void)
+{
+ PPE_SLL01_PMU_SETUP(IFX_PMU_DISABLE);
+ PPE_TC_PMU_SETUP(IFX_PMU_DISABLE);
+ PPE_EMA_PMU_SETUP(IFX_PMU_DISABLE);
+ //PPE_QSB_PMU_SETUP(IFX_PMU_DISABLE);
+ PPE_TPE_PMU_SETUP(IFX_PMU_DISABLE);
+ DSL_DFE_PMU_SETUP(IFX_PMU_DISABLE);
+ //PPE_TOP_PMU_SETUP(IFX_PMU_DISABLE);
+}
+
+static inline void reset_ppe(void)
+{
+#ifdef MODULE
+ unsigned int etop_cfg;
+ unsigned int etop_mdio_cfg;
+ unsigned int etop_ig_plen_ctrl;
+ unsigned int enet_mac_cfg;
+
+ etop_cfg = *IFX_PP32_ETOP_CFG;
+ etop_mdio_cfg = *IFX_PP32_ETOP_MDIO_CFG;
+ etop_ig_plen_ctrl = *IFX_PP32_ETOP_IG_PLEN_CTRL;
+ enet_mac_cfg = *IFX_PP32_ENET_MAC_CFG;
+
+ *IFX_PP32_ETOP_CFG = (*IFX_PP32_ETOP_CFG & ~0x03C0) | 0x0001;
+
+ // reset PPE
+ ifx_rcu_rst(IFX_RCU_DOMAIN_PPE, IFX_RCU_MODULE_PTM);
+
+ *IFX_PP32_ETOP_MDIO_CFG = etop_mdio_cfg;
+ *IFX_PP32_ETOP_IG_PLEN_CTRL = etop_ig_plen_ctrl;
+ *IFX_PP32_ENET_MAC_CFG = enet_mac_cfg;
+ *IFX_PP32_ETOP_CFG = etop_cfg;
+#endif
+}
+
+static inline void init_ema(void)
+{
+ // Configure share buffer master selection
+ *SB_MST_PRI0 = 1;
+ *SB_MST_PRI1 = 1;
+
+ // EMA Settings
+ IFX_REG_W32((EMA_CMD_BUF_LEN << 16) | (EMA_CMD_BASE_ADDR >> 2), EMA_CMDCFG);
+ IFX_REG_W32((EMA_DATA_BUF_LEN << 16) | (EMA_DATA_BASE_ADDR >> 2), EMA_DATACFG);
+ IFX_REG_W32(0x000000FF, EMA_IER);
+ IFX_REG_W32(EMA_READ_BURST | (EMA_WRITE_BURST << 2), EMA_CFG);
+}
+
+static inline void init_mailbox(void)
+{
+ IFX_REG_W32(0xFFFFFFFF, MBOX_IGU1_ISRC);
+ IFX_REG_W32(0x00000000, MBOX_IGU1_IER);
+ IFX_REG_W32(0xFFFFFFFF, MBOX_IGU3_ISRC);
+ IFX_REG_W32(0x00000000, MBOX_IGU3_IER);
+}
+
+static inline void init_atm_tc(void)
+{
+ IFX_REG_W32(0x0F00, DREG_AT_CTRL);
+ IFX_REG_W32(0x3C00, DREG_AR_CTRL);
+ IFX_REG_W32(0x0, DREG_AT_IDLE0);
+ IFX_REG_W32(0x0, DREG_AT_IDLE1);
+ IFX_REG_W32(0x0, DREG_AR_IDLE0);
+ IFX_REG_W32(0x0, DREG_AR_IDLE1);
+ IFX_REG_W32(0x0, RFBI_CFG);
+ IFX_REG_W32(0x0200, SFSM_DBA0);
+ IFX_REG_W32(0x0800, SFSM_DBA1);
+ IFX_REG_W32(0x0321, SFSM_CBA0);
+ IFX_REG_W32(0x0921, SFSM_CBA1);
+ IFX_REG_W32(0x14011, SFSM_CFG0);
+ IFX_REG_W32(0x14011, SFSM_CFG1);
+ IFX_REG_W32(0x0332, FFSM_DBA0);
+ IFX_REG_W32(0x0932, FFSM_DBA1);
+ IFX_REG_W32(0x3000C, FFSM_CFG0);
+ IFX_REG_W32(0x3000C, FFSM_CFG1);
+ IFX_REG_W32(0xF0D10000, FFSM_IDLE_HEAD_BC0);
+ IFX_REG_W32(0xF0D10000, FFSM_IDLE_HEAD_BC1);
+}
+
+static inline void clear_share_buffer(void)
+{
+ volatile u32 *p = SB_RAM0_ADDR(0);
+ unsigned int i;
+
+ for ( i = 0; i < SB_RAM0_DWLEN + SB_RAM1_DWLEN; i++ )
+ IFX_REG_W32(0, p++);
+}
+
+/*
+ * Description:
+ * Download PPE firmware binary code.
+ * Input:
+ * src --- u32 *, binary code buffer
+ * dword_len --- unsigned int, binary code length in DWORD (32-bit)
+ * Output:
+ * int --- 0: Success
+ * else: Error Code
+ */
+static inline int pp32_download_code(u32 *code_src, unsigned int code_dword_len, u32 *data_src, unsigned int data_dword_len)
+{
+ volatile u32 *dest;
+
+ if ( code_src == 0 || ((unsigned long)code_src & 0x03) != 0
+ || data_src == 0 || ((unsigned long)data_src & 0x03) != 0 )
+ return -1;
+
+ if ( code_dword_len <= CDM_CODE_MEMORYn_DWLEN(0) )
+ IFX_REG_W32(0x00, CDM_CFG);
+ else
+ IFX_REG_W32(0x04, CDM_CFG);
+
+ /* copy code */
+ dest = CDM_CODE_MEMORY(0, 0);
+ while ( code_dword_len-- > 0 )
+ IFX_REG_W32(*code_src++, dest++);
+
+ /* copy data */
+ dest = CDM_DATA_MEMORY(0, 0);
+ while ( data_dword_len-- > 0 )
+ IFX_REG_W32(*data_src++, dest++);
+
+ return 0;
+}
+
+
+
+/*
+ * ####################################
+ * Global Function
+ * ####################################
+ */
+
+extern void ifx_ptm_get_fw_ver(unsigned int *major, unsigned int *minor)
+{
+ ASSERT(major != NULL, "pointer is NULL");
+ ASSERT(minor != NULL, "pointer is NULL");
+
+ *major = FW_VER_ID->major;
+ *minor = FW_VER_ID->minor;
+}
+
+void ifx_ptm_init_chip(void)
+{
+ init_pmu();
+
+ reset_ppe();
+
+ init_ema();
+
+ init_mailbox();
+
+ init_atm_tc();
+
+ clear_share_buffer();
+}
+
+void ifx_ptm_uninit_chip(void)
+{
+ uninit_pmu();
+}
+
+/*
+ * Description:
+ * Initialize and start up PP32.
+ * Input:
+ * none
+ * Output:
+ * int --- 0: Success
+ * else: Error Code
+ */
+int ifx_pp32_start(int pp32)
+{
+ int ret;
+
+ /* download firmware */
+ ret = pp32_download_code(firmware_binary_code, sizeof(firmware_binary_code) / sizeof(*firmware_binary_code), firmware_binary_data, sizeof(firmware_binary_data) / sizeof(*firmware_binary_data));
+ if ( ret != 0 )
+ return ret;
+
+ /* run PP32 */
+ IFX_REG_W32(DBG_CTRL_RESTART, PP32_DBG_CTRL(pp32));
+
+ /* idle for a while to let PP32 init itself */
+ udelay(10);
+
+ return 0;
+}
+
+/*
+ * Description:
+ * Halt PP32.
+ * Input:
+ * none
+ * Output:
+ * none
+ */
+void ifx_pp32_stop(int pp32)
+{
+ /* halt PP32 */
+ IFX_REG_W32(DBG_CTRL_STOP, PP32_DBG_CTRL(pp32));
+}
diff --git a/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_ar9.c.svn-base b/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_ar9.c.svn-base
new file mode 100644
index 0000000..777d5cf
--- /dev/null
+++ b/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_ar9.c.svn-base
@@ -0,0 +1,376 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_ptm_ar9.c
+** PROJECT : UEIP
+** MODULES : PTM
+**
+** DATE : 7 Jul 2009
+** AUTHOR : Xu Liang
+** DESCRIPTION : PTM driver common source file (core functions)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 07 JUL 2009 Xu Liang Init Version
+*******************************************************************************/
+
+
+
+/*
+ * ####################################
+ * Head File
+ * ####################################
+ */
+
+/*
+ * Common Head File
+ */
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/version.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/proc_fs.h>
+#include <linux/init.h>
+#include <linux/ioctl.h>
+#include <asm/delay.h>
+
+/*
+ * Chip Specific Head File
+ */
+#include "ifxmips_ptm_adsl.h"
+#include "ifxmips_ptm_fw_ar9.h"
+
+#include <lantiq_soc.h>
+
+
+/*
+ * ####################################
+ * Definition
+ * ####################################
+ */
+
+/*
+ * EMA Settings
+ */
+#define EMA_CMD_BUF_LEN 0x0040
+#define EMA_CMD_BASE_ADDR (0x00001B80 << 2)
+#define EMA_DATA_BUF_LEN 0x0100
+#define EMA_DATA_BASE_ADDR (0x00001C00 << 2)
+#define EMA_WRITE_BURST 0x2
+#define EMA_READ_BURST 0x2
+
+
+
+/*
+ * ####################################
+ * Declaration
+ * ####################################
+ */
+
+/*
+ * Hardware Init/Uninit Functions
+ */
+static inline void init_pmu(void);
+static inline void uninit_pmu(void);
+static inline void reset_ppe(void);
+static inline void init_ema(void);
+static inline void init_mailbox(void);
+static inline void init_atm_tc(void);
+static inline void clear_share_buffer(void);
+
+
+
+/*
+ * ####################################
+ * Local Variable
+ * ####################################
+ */
+
+
+
+/*
+ * ####################################
+ * Local Function
+ * ####################################
+ */
+
+#define IFX_PMU_MODULE_PPE_SLL01 BIT(19)
+#define IFX_PMU_MODULE_PPE_TC BIT(21)
+#define IFX_PMU_MODULE_PPE_EMA BIT(22)
+#define IFX_PMU_MODULE_PPE_QSB BIT(18)
+#define IFX_PMU_MODULE_TPE BIT(13)
+#define IFX_PMU_MODULE_DSL_DFE BIT(9)
+
+
+static inline void init_pmu(void)
+{
+ ltq_pmu_enable(IFX_PMU_MODULE_PPE_SLL01 |
+ IFX_PMU_MODULE_PPE_TC |
+ IFX_PMU_MODULE_PPE_EMA |
+ IFX_PMU_MODULE_TPE |
+ IFX_PMU_MODULE_DSL_DFE);
+
+}
+
+static inline void uninit_pmu(void)
+{
+ ltq_pmu_disable(IFX_PMU_MODULE_PPE_SLL01 |
+ IFX_PMU_MODULE_PPE_TC |
+ IFX_PMU_MODULE_PPE_EMA |
+ IFX_PMU_MODULE_TPE |
+ IFX_PMU_MODULE_DSL_DFE);
+
+}
+
+static inline void reset_ppe(void)
+{
+#ifdef MODULE
+ // reset PPE
+// ifx_rcu_rst(IFX_RCU_DOMAIN_PPE, IFX_RCU_MODULE_PTM);
+#endif
+}
+
+static inline void init_ema(void)
+{
+ // Configure share buffer master selection
+ IFX_REG_W32(1, SB_MST_PRI0);
+ IFX_REG_W32(1, SB_MST_PRI1);
+
+ // EMA Settings
+ IFX_REG_W32((EMA_CMD_BUF_LEN << 16) | (EMA_CMD_BASE_ADDR >> 2), EMA_CMDCFG);
+ IFX_REG_W32((EMA_DATA_BUF_LEN << 16) | (EMA_DATA_BASE_ADDR >> 2), EMA_DATACFG);
+ IFX_REG_W32(0x000000FF, EMA_IER);
+ IFX_REG_W32(EMA_READ_BURST | (EMA_WRITE_BURST << 2), EMA_CFG);
+}
+
+static inline void init_mailbox(void)
+{
+ IFX_REG_W32(0xFFFFFFFF, MBOX_IGU1_ISRC);
+ IFX_REG_W32(0x00000000, MBOX_IGU1_IER);
+ IFX_REG_W32(0xFFFFFFFF, MBOX_IGU3_ISRC);
+ IFX_REG_W32(0x00000000, MBOX_IGU3_IER);
+}
+
+static inline void init_atm_tc(void)
+{
+ IFX_REG_W32(0x0, RFBI_CFG);
+ IFX_REG_W32(0x1800, SFSM_DBA0);
+ IFX_REG_W32(0x1921, SFSM_DBA1);
+ IFX_REG_W32(0x1A42, SFSM_CBA0);
+ IFX_REG_W32(0x1A53, SFSM_CBA1);
+ IFX_REG_W32(0x14011, SFSM_CFG0);
+ IFX_REG_W32(0x14011, SFSM_CFG1);
+ IFX_REG_W32(0x1000, FFSM_DBA0);
+ IFX_REG_W32(0x1700, FFSM_DBA1);
+ IFX_REG_W32(0x3000C, FFSM_CFG0);
+ IFX_REG_W32(0x3000C, FFSM_CFG1);
+ IFX_REG_W32(0xF0D10000, FFSM_IDLE_HEAD_BC0);
+ IFX_REG_W32(0xF0D10000, FFSM_IDLE_HEAD_BC1);
+
+ /*
+ * 0. Backup port2 value to temp
+ * 1. Disable CPU port2 in switch (link and learning)
+ * 2. wait for a while
+ * 3. Configure DM register and counter
+ * 4. restore temp to CPU port2 in switch
+ * This code will cause network to stop working if there are heavy
+ * traffic during bootup. This part should be moved to switch and use
+ * the same code as ATM
+ */
+ {
+ int i;
+ u32 temp;
+
+ temp = IFX_REG_R32(SW_P2_CTL);
+
+ IFX_REG_W32(0x40020000, SW_P2_CTL);
+ for (i = 0; i < 200; i++)
+ udelay(2000);
+
+ IFX_REG_W32(0x00007028, DM_RXCFG);
+ IFX_REG_W32(0x00007028, DS_RXCFG);
+
+ IFX_REG_W32(0x00001100, DM_RXDB);
+ IFX_REG_W32(0x00001100, DS_RXDB);
+
+ IFX_REG_W32(0x00001600, DM_RXCB);
+ IFX_REG_W32(0x00001600, DS_RXCB);
+
+ /*
+ * For dynamic, must reset these counters,
+ * For once initialization, don't need to reset these counters
+ */
+ IFX_REG_W32(0x0, DM_RXPGCNT);
+ IFX_REG_W32(0x0, DS_RXPGCNT);
+ IFX_REG_W32(0x0, DM_RXPKTCNT);
+
+ IFX_REG_W32_MASK(0, 0x80000000, DM_RXCFG);
+ IFX_REG_W32_MASK(0, 0x8000, DS_RXCFG);
+
+ udelay(2000);
+ IFX_REG_W32(temp, SW_P2_CTL);
+ udelay(2000);
+ }
+}
+
+static inline void clear_share_buffer(void)
+{
+ volatile u32 *p = SB_RAM0_ADDR(0);
+ unsigned int i;
+
+ for ( i = 0; i < SB_RAM0_DWLEN + SB_RAM1_DWLEN + SB_RAM2_DWLEN + SB_RAM3_DWLEN + SB_RAM4_DWLEN; i++ )
+ IFX_REG_W32(0, p++);
+}
+
+/*
+ * Description:
+ * Download PPE firmware binary code.
+ * Input:
+ * src --- u32 *, binary code buffer
+ * dword_len --- unsigned int, binary code length in DWORD (32-bit)
+ * Output:
+ * int --- 0: Success
+ * else: Error Code
+ */
+static inline int pp32_download_code(u32 *code_src, unsigned int code_dword_len, u32 *data_src, unsigned int data_dword_len)
+{
+ volatile u32 *dest;
+
+ if ( code_src == 0 || ((unsigned long)code_src & 0x03) != 0
+ || data_src == 0 || ((unsigned long)data_src & 0x03) != 0 )
+ return -1;
+
+ if ( code_dword_len <= CDM_CODE_MEMORYn_DWLEN(0) )
+ IFX_REG_W32(0x00, CDM_CFG);
+ else
+ IFX_REG_W32(0x04, CDM_CFG);
+
+ /* copy code */
+ dest = CDM_CODE_MEMORY(0, 0);
+ while ( code_dword_len-- > 0 )
+ IFX_REG_W32(*code_src++, dest++);
+
+ /* copy data */
+ dest = CDM_DATA_MEMORY(0, 0);
+ while ( data_dword_len-- > 0 )
+ IFX_REG_W32(*data_src++, dest++);
+
+ return 0;
+}
+
+
+
+/*
+ * ####################################
+ * Global Function
+ * ####################################
+ */
+
+void ifx_ptm_get_fw_ver(unsigned int *major, unsigned int *minor)
+{
+ ASSERT(major != NULL, "pointer is NULL");
+ ASSERT(minor != NULL, "pointer is NULL");
+
+ *major = FW_VER_ID->major;
+ *minor = FW_VER_ID->minor;
+}
+
+void ifx_ptm_init_chip(void)
+{
+ init_pmu();
+
+ reset_ppe();
+
+ init_ema();
+
+ init_mailbox();
+
+ init_atm_tc();
+
+ clear_share_buffer();
+}
+
+void ifx_ptm_uninit_chip(void)
+{
+ uninit_pmu();
+}
+
+/*
+ * Description:
+ * Initialize and start up PP32.
+ * Input:
+ * none
+ * Output:
+ * int --- 0: Success
+ * else: Error Code
+ */
+int ifx_pp32_start(int pp32)
+{
+ int ret;
+
+ /* download firmware */
+ ret = pp32_download_code(firmware_binary_code, sizeof(firmware_binary_code) / sizeof(*firmware_binary_code), firmware_binary_data, sizeof(firmware_binary_data) / sizeof(*firmware_binary_data));
+ if ( ret != 0 )
+ return ret;
+
+ /* run PP32 */
+ IFX_REG_W32(DBG_CTRL_RESTART, PP32_DBG_CTRL(0));
+
+ /* idle for a while to let PP32 init itself */
+ udelay(10);
+
+ return 0;
+}
+
+/*
+ * Description:
+ * Halt PP32.
+ * Input:
+ * none
+ * Output:
+ * none
+ */
+void ifx_pp32_stop(int pp32)
+{
+ /* halt PP32 */
+ IFX_REG_W32(DBG_CTRL_STOP, PP32_DBG_CTRL(0));
+}
+
+int ifx_ptm_proc_read_regs(char *page, char **start, off_t off, int count, int *eof, void *data)
+{
+ int len = 0;
+
+ len += sprintf(page + off + len, "EMA:\n");
+ len += sprintf(page + off + len, " SB_MST_PRI0 - 0x%08X, SB_MST_PRI1 - 0x%08X\n", IFX_REG_R32(SB_MST_PRI0), IFX_REG_R32(SB_MST_PRI1));
+ len += sprintf(page + off + len, " EMA_CMDCFG - 0x%08X, EMA_DATACFG - 0x%08X\n", IFX_REG_R32(EMA_CMDCFG), IFX_REG_R32(EMA_DATACFG));
+ len += sprintf(page + off + len, " EMA_IER - 0x%08X, EMA_CFG - 0x%08X\n", IFX_REG_R32(EMA_IER), IFX_REG_R32(EMA_CFG));
+
+ len += sprintf(page + off + len, "Mailbox:\n");
+ len += sprintf(page + off + len, " MBOX_IGU1_IER - 0x%08X, MBOX_IGU1_ISR - 0x%08X\n", IFX_REG_R32(MBOX_IGU1_IER), IFX_REG_R32(MBOX_IGU1_ISR));
+ len += sprintf(page + off + len, " MBOX_IGU3_IER - 0x%08X, MBOX_IGU3_ISR - 0x%08X\n", IFX_REG_R32(MBOX_IGU3_IER), IFX_REG_R32(MBOX_IGU3_ISR));
+
+ len += sprintf(page + off + len, "TC:\n");
+ len += sprintf(page + off + len, " RFBI_CFG - 0x%08X\n", IFX_REG_R32(RFBI_CFG));
+ len += sprintf(page + off + len, " SFSM_DBA0 - 0x%08X, SFSM_CBA0 - 0x%08X, SFSM_CFG0 - 0x%08X\n", IFX_REG_R32(SFSM_DBA0), IFX_REG_R32(SFSM_CBA0), IFX_REG_R32(SFSM_CFG0));
+ len += sprintf(page + off + len, " SFSM_DBA1 - 0x%08X, SFSM_CBA1 - 0x%08X, SFSM_CFG1 - 0x%08X\n", IFX_REG_R32(SFSM_DBA1), IFX_REG_R32(SFSM_CBA1), IFX_REG_R32(SFSM_CFG1));
+ len += sprintf(page + off + len, " FFSM_DBA0 - 0x%08X, FFSM_CFG0 - 0x%08X, IDLE_HEAD - 0x%08X\n", IFX_REG_R32(FFSM_DBA0), IFX_REG_R32(FFSM_CFG0), IFX_REG_R32(FFSM_IDLE_HEAD_BC0));
+ len += sprintf(page + off + len, " FFSM_DBA1 - 0x%08X, FFSM_CFG1 - 0x%08X, IDLE_HEAD - 0x%08X\n", IFX_REG_R32(FFSM_DBA1), IFX_REG_R32(FFSM_CFG1), IFX_REG_R32(FFSM_IDLE_HEAD_BC1));
+
+ len += sprintf(page + off + len, "DPlus:\n");
+ len += sprintf(page + off + len, " DM_RXDB - 0x%08X, DM_RXCB - 0x%08X, DM_RXCFG - 0x%08X\n", IFX_REG_R32(DM_RXDB), IFX_REG_R32(DM_RXCB), IFX_REG_R32(DM_RXCFG));
+ len += sprintf(page + off + len, " DM_RXPGCNT - 0x%08X, DM_RXPKTCNT - 0x%08X\n", IFX_REG_R32(DM_RXPGCNT), IFX_REG_R32(DM_RXPKTCNT));
+ len += sprintf(page + off + len, " DS_RXDB - 0x%08X, DS_RXCB - 0x%08X, DS_RXCFG - 0x%08X\n", IFX_REG_R32(DS_RXDB), IFX_REG_R32(DS_RXCB), IFX_REG_R32(DS_RXCFG));
+ len += sprintf(page + off + len, " DS_RXPGCNT - 0x%08X\n", IFX_REG_R32(DS_RXPGCNT));
+
+ *eof = 1;
+
+ return len;
+}
diff --git a/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_common.h.svn-base b/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_common.h.svn-base
new file mode 100644
index 0000000..ccd19b1
--- /dev/null
+++ b/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_common.h.svn-base
@@ -0,0 +1,102 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_ptm_common.h
+** PROJECT : UEIP
+** MODULES : PTM
+**
+** DATE : 7 Jul 2009
+** AUTHOR : Xu Liang
+** DESCRIPTION : PTM driver header file (common definitions)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 17 JUN 2009 Xu Liang Init Version
+*******************************************************************************/
+
+#ifndef IFXMIPS_PTM_COMMON_H
+#define IFXMIPS_PTM_COMMON_H
+
+
+
+/*
+ * ####################################
+ * Version No.
+ * ####################################
+ */
+
+#define IFX_PTM_VER_MAJOR 1
+#define IFX_PTM_VER_MID 0
+#define IFX_PTM_VER_MINOR 27
+
+
+
+/*
+ * ####################################
+ * Definition
+ * ####################################
+ */
+
+/*
+ * Compile Options
+ */
+
+#define ENABLE_DEBUG 1
+
+#define ENABLE_ASSERT 1
+
+#define INLINE
+
+#define DEBUG_DUMP_SKB 1
+
+#define DEBUG_QOS 1
+
+#define ENABLE_DBG_PROC 1
+
+#define ENABLE_FW_PROC 1
+
+#if defined(CONFIG_DSL_MEI_CPE_DRV) && !defined(CONFIG_IFXMIPS_DSL_CPE_MEI)
+ #define CONFIG_IFXMIPS_DSL_CPE_MEI 1
+#endif
+
+/*
+ * Debug/Assert/Error Message
+ */
+
+#define DBG_ENABLE_MASK_ERR (1 << 0)
+#define DBG_ENABLE_MASK_DEBUG_PRINT (1 << 1)
+#define DBG_ENABLE_MASK_ASSERT (1 << 2)
+#define DBG_ENABLE_MASK_DUMP_SKB_RX (1 << 8)
+#define DBG_ENABLE_MASK_DUMP_SKB_TX (1 << 9)
+#define DBG_ENABLE_MASK_DUMP_QOS (1 << 10)
+#define DBG_ENABLE_MASK_DUMP_INIT (1 << 11)
+#define DBG_ENABLE_MASK_MAC_SWAP (1 << 12)
+#define DBG_ENABLE_MASK_ALL (DBG_ENABLE_MASK_ERR | DBG_ENABLE_MASK_DEBUG_PRINT | DBG_ENABLE_MASK_ASSERT | DBG_ENABLE_MASK_DUMP_SKB_RX | DBG_ENABLE_MASK_DUMP_SKB_TX | DBG_ENABLE_MASK_DUMP_QOS | DBG_ENABLE_MASK_DUMP_INIT | DBG_ENABLE_MASK_MAC_SWAP)
+
+#define err(format, arg...) do { if ( (ifx_ptm_dbg_enable & DBG_ENABLE_MASK_ERR) ) printk(KERN_ERR __FILE__ ":%d:%s: " format "\n", __LINE__, __FUNCTION__, ##arg); } while ( 0 )
+
+#if defined(ENABLE_DEBUG) && ENABLE_DEBUG
+ #undef dbg
+ #define dbg(format, arg...) do { if ( (ifx_ptm_dbg_enable & DBG_ENABLE_MASK_DEBUG_PRINT) ) printk(KERN_WARNING __FILE__ ":%d:%s: " format "\n", __LINE__, __FUNCTION__, ##arg); } while ( 0 )
+#else
+ #if !defined(dbg)
+ #define dbg(format, arg...)
+ #endif
+#endif
+
+#if defined(ENABLE_ASSERT) && ENABLE_ASSERT
+ #define ASSERT(cond, format, arg...) do { if ( (ifx_ptm_dbg_enable & DBG_ENABLE_MASK_ASSERT) && !(cond) ) printk(KERN_ERR __FILE__ ":%d:%s: " format "\n", __LINE__, __FUNCTION__, ##arg); } while ( 0 )
+#else
+ #define ASSERT(cond, format, arg...)
+#endif
+
+
+
+#endif // IFXMIPS_PTM_COMMON_H
diff --git a/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_danube.c.svn-base b/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_danube.c.svn-base
new file mode 100644
index 0000000..279b03b
--- /dev/null
+++ b/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_danube.c.svn-base
@@ -0,0 +1,317 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_ptm_danube.c
+** PROJECT : UEIP
+** MODULES : PTM
+**
+** DATE : 7 Jul 2009
+** AUTHOR : Xu Liang
+** DESCRIPTION : PTM driver common source file (core functions)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 07 JUL 2009 Xu Liang Init Version
+*******************************************************************************/
+
+
+
+/*
+ * ####################################
+ * Head File
+ * ####################################
+ */
+
+/*
+ * Common Head File
+ */
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/version.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/proc_fs.h>
+#include <linux/init.h>
+#include <linux/ioctl.h>
+#include <linux/delay.h>
+
+/*
+ * Chip Specific Head File
+ */
+#include "ifxmips_ptm_adsl.h"
+#include "ifxmips_ptm_fw_danube.h"
+
+#include <lantiq_soc.h>
+
+/*
+ * ####################################
+ * Definition
+ * ####################################
+ */
+
+/*
+ * EMA Settings
+ */
+#define EMA_CMD_BUF_LEN 0x0040
+#define EMA_CMD_BASE_ADDR (0x00001580 << 2)
+#define EMA_DATA_BUF_LEN 0x0100
+#define EMA_DATA_BASE_ADDR (0x00000B00 << 2)
+#define EMA_WRITE_BURST 0x2
+#define EMA_READ_BURST 0x2
+
+
+
+/*
+ * ####################################
+ * Declaration
+ * ####################################
+ */
+
+/*
+ * Hardware Init/Uninit Functions
+ */
+static inline void init_pmu(void);
+static inline void uninit_pmu(void);
+static inline void reset_ppe(void);
+static inline void init_ema(void);
+static inline void init_mailbox(void);
+static inline void init_atm_tc(void);
+static inline void clear_share_buffer(void);
+
+
+
+/*
+ * ####################################
+ * Local Variable
+ * ####################################
+ */
+
+
+#define IFX_PMU_MODULE_PPE_SLL01 BIT(19)
+#define IFX_PMU_MODULE_PPE_TC BIT(21)
+#define IFX_PMU_MODULE_PPE_EMA BIT(22)
+#define IFX_PMU_MODULE_PPE_QSB BIT(18)
+#define IFX_PMU_MODULE_TPE BIT(13)
+#define IFX_PMU_MODULE_DSL_DFE BIT(9)
+
+/*
+ * ####################################
+ * Local Function
+ * ####################################
+ */
+
+static inline void init_pmu(void)
+{
+ ltq_pmu_enable(IFX_PMU_MODULE_PPE_SLL01 |
+ IFX_PMU_MODULE_PPE_TC |
+ IFX_PMU_MODULE_PPE_EMA |
+ IFX_PMU_MODULE_TPE |
+ IFX_PMU_MODULE_DSL_DFE);
+}
+
+static inline void uninit_pmu(void)
+{
+ ltq_pmu_disable(IFX_PMU_MODULE_PPE_SLL01 |
+ IFX_PMU_MODULE_PPE_TC |
+ IFX_PMU_MODULE_PPE_EMA |
+ IFX_PMU_MODULE_TPE |
+ IFX_PMU_MODULE_DSL_DFE);
+}
+
+static inline void reset_ppe(void)
+{
+#ifdef MODULE
+ /*unsigned int etop_cfg;
+ unsigned int etop_mdio_cfg;
+ unsigned int etop_ig_plen_ctrl;
+ unsigned int enet_mac_cfg;
+
+ etop_cfg = *IFX_PP32_ETOP_CFG;
+ etop_mdio_cfg = *IFX_PP32_ETOP_MDIO_CFG;
+ etop_ig_plen_ctrl = *IFX_PP32_ETOP_IG_PLEN_CTRL;
+ enet_mac_cfg = *IFX_PP32_ENET_MAC_CFG;
+
+ *IFX_PP32_ETOP_CFG &= ~0x03C0;
+
+ // reset PPE
+ ifx_rcu_rst(IFX_RCU_DOMAIN_PPE, IFX_RCU_MODULE_PTM);
+
+ *IFX_PP32_ETOP_MDIO_CFG = etop_mdio_cfg;
+ *IFX_PP32_ETOP_IG_PLEN_CTRL = etop_ig_plen_ctrl;
+ *IFX_PP32_ENET_MAC_CFG = enet_mac_cfg;
+ *IFX_PP32_ETOP_CFG = etop_cfg;*/
+#endif
+}
+
+static inline void init_ema(void)
+{
+ // Configure share buffer master selection
+ *SB_MST_SEL |= 0x03;
+
+ // EMA Settings
+ IFX_REG_W32((EMA_CMD_BUF_LEN << 16) | (EMA_CMD_BASE_ADDR >> 2), EMA_CMDCFG);
+ IFX_REG_W32((EMA_DATA_BUF_LEN << 16) | (EMA_DATA_BASE_ADDR >> 2), EMA_DATACFG);
+ IFX_REG_W32(0x000000FF, EMA_IER);
+ IFX_REG_W32(EMA_READ_BURST | (EMA_WRITE_BURST << 2), EMA_CFG);
+}
+
+static inline void init_mailbox(void)
+{
+ IFX_REG_W32(0xFFFFFFFF, MBOX_IGU1_ISRC);
+ IFX_REG_W32(0x00000000, MBOX_IGU1_IER);
+ IFX_REG_W32(0xFFFFFFFF, MBOX_IGU3_ISRC);
+ IFX_REG_W32(0x00000000, MBOX_IGU3_IER);
+}
+
+static inline void init_atm_tc(void)
+{
+ IFX_REG_W32(0x0F00, DREG_AT_CTRL);
+ IFX_REG_W32(0x3C00, DREG_AR_CTRL);
+ IFX_REG_W32(0x0, DREG_AT_IDLE0);
+ IFX_REG_W32(0x0, DREG_AT_IDLE1);
+ IFX_REG_W32(0x0, DREG_AR_IDLE0);
+ IFX_REG_W32(0x0, DREG_AR_IDLE1);
+ IFX_REG_W32(0x0, RFBI_CFG);
+ IFX_REG_W32(0x1600, SFSM_DBA0);
+ IFX_REG_W32(0x1721, SFSM_DBA1);
+ IFX_REG_W32(0x1842, SFSM_CBA0);
+ IFX_REG_W32(0x1853, SFSM_CBA1);
+ IFX_REG_W32(0x14011, SFSM_CFG0);
+ IFX_REG_W32(0x14011, SFSM_CFG1);
+ IFX_REG_W32(0x1864, FFSM_DBA0);
+ IFX_REG_W32(0x1930, FFSM_DBA1);
+ IFX_REG_W32(0x3000C, FFSM_CFG0);
+ IFX_REG_W32(0x3000C, FFSM_CFG1);
+ IFX_REG_W32(0xF0D10000, FFSM_IDLE_HEAD_BC0);
+ IFX_REG_W32(0xF0D10000, FFSM_IDLE_HEAD_BC1);
+}
+
+static inline void clear_share_buffer(void)
+{
+ volatile u32 *p = SB_RAM0_ADDR(0);
+ unsigned int i;
+
+ for ( i = 0; i < SB_RAM0_DWLEN + SB_RAM1_DWLEN + SB_RAM2_DWLEN + SB_RAM3_DWLEN; i++ )
+ IFX_REG_W32(0, p++);
+}
+
+/*
+ * Description:
+ * Download PPE firmware binary code.
+ * Input:
+ * src --- u32 *, binary code buffer
+ * dword_len --- unsigned int, binary code length in DWORD (32-bit)
+ * Output:
+ * int --- 0: Success
+ * else: Error Code
+ */
+static inline int pp32_download_code(u32 *code_src, unsigned int code_dword_len, u32 *data_src, unsigned int data_dword_len)
+{
+ volatile u32 *dest;
+
+ if ( code_src == 0 || ((unsigned long)code_src & 0x03) != 0
+ || data_src == 0 || ((unsigned long)data_src & 0x03) != 0 )
+ return -1;
+
+ if ( code_dword_len <= CDM_CODE_MEMORYn_DWLEN(0) )
+ IFX_REG_W32(0x00, CDM_CFG);
+ else
+ IFX_REG_W32(0x04, CDM_CFG);
+
+ /* copy code */
+ dest = CDM_CODE_MEMORY(0, 0);
+ while ( code_dword_len-- > 0 )
+ IFX_REG_W32(*code_src++, dest++);
+
+ /* copy data */
+ dest = CDM_DATA_MEMORY(0, 0);
+ while ( data_dword_len-- > 0 )
+ IFX_REG_W32(*data_src++, dest++);
+
+ return 0;
+}
+
+
+
+/*
+ * ####################################
+ * Global Function
+ * ####################################
+ */
+
+extern void ifx_ptm_get_fw_ver(unsigned int *major, unsigned int *minor)
+{
+ ASSERT(major != NULL, "pointer is NULL");
+ ASSERT(minor != NULL, "pointer is NULL");
+
+ *major = FW_VER_ID->major;
+ *minor = FW_VER_ID->minor;
+}
+
+void ifx_ptm_init_chip(void)
+{
+ init_pmu();
+
+ reset_ppe();
+
+ init_ema();
+
+ init_mailbox();
+
+ init_atm_tc();
+
+ clear_share_buffer();
+}
+
+void ifx_ptm_uninit_chip(void)
+{
+ uninit_pmu();
+}
+
+/*
+ * Description:
+ * Initialize and start up PP32.
+ * Input:
+ * none
+ * Output:
+ * int --- 0: Success
+ * else: Error Code
+ */
+int ifx_pp32_start(int pp32)
+{
+ int ret;
+
+ /* download firmware */
+ ret = pp32_download_code(firmware_binary_code, sizeof(firmware_binary_code) / sizeof(*firmware_binary_code), firmware_binary_data, sizeof(firmware_binary_data) / sizeof(*firmware_binary_data));
+ if ( ret != 0 )
+ return ret;
+
+ /* run PP32 */
+ IFX_REG_W32(DBG_CTRL_START_SET(1), PP32_DBG_CTRL);
+
+ /* idle for a while to let PP32 init itself */
+ udelay(10);
+
+ return 0;
+}
+
+/*
+ * Description:
+ * Halt PP32.
+ * Input:
+ * none
+ * Output:
+ * none
+ */
+void ifx_pp32_stop(int pp32)
+{
+ /* halt PP32 */
+ IFX_REG_W32(DBG_CTRL_STOP_SET(1), PP32_DBG_CTRL);
+}
diff --git a/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_fw_amazon_se.h.svn-base b/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_fw_amazon_se.h.svn-base
new file mode 100644
index 0000000..ae33bcc
--- /dev/null
+++ b/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_fw_amazon_se.h.svn-base
@@ -0,0 +1,493 @@
+#ifndef IFXMIPS_PTM_FW_AMAZON_SE_H
+#define IFXMIPS_PTM_FW_AMAZON_SE_H
+
+
+/******************************************************************************
+**
+** FILE NAME : ifxmips_ptm_fw_amazon_se.h
+** PROJECT : UEIP
+** MODULES : PTM (ADSL)
+**
+** DATE : 1 AUG 2005
+** AUTHOR : Xu Liang
+** DESCRIPTION : PTM Driver (PP32 Firmware)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 4 AUG 2005 Xu Liang Initiate Version
+** 23 OCT 2006 Xu Liang Add GPL header.
+** 9 JAN 2007 Xu Liang First version got from Anand (IC designer)
+*******************************************************************************/
+
+
+#define PTM_FW_VER_MAJOR 0
+#define PTM_FW_VER_MINOR 17
+
+
+static unsigned int firmware_binary_code[] = {
+ 0x800004b8, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8000ffe0, 0x00000000, 0x00000000, 0x00000000,
+ 0xc1000002, 0xd90c00f8, 0xc2000002, 0xda0800f9, 0x800055e0, 0xc2000000, 0xda0800f9, 0x80005580,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x80005e58, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xc10e0002, 0xd90c00f8, 0xc0004808, 0xc84000f8, 0x80005250, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xc3e1fffe, 0x597dfffe, 0x593dfef4, 0x900004d9, 0x00000000, 0x00000000, 0x00000000, 0x90cc0481,
+ 0x00000000, 0x00000000, 0x00000000, 0xc3e06262, 0x5bfc0022, 0xc0004802, 0xcfc000f8, 0xc0004810,
+ 0xcbc000f8, 0x00000000, 0xc3800000, 0xc7f80038, 0x5fb80000, 0xc7fa0038, 0xc7bfe802, 0x5fb80000,
+ 0x00000000, 0xc7bff802, 0xdbd400f9, 0xc00049a0, 0xc3800002, 0xa7ca006a, 0xc1200000, 0x5911fffe,
+ 0xcd0000f9, 0xc1200000, 0x59102042, 0xcd0000f9, 0xc1000004, 0xcd0000f9, 0xc1200000, 0x59103a1e,
+ 0xcd0000f9, 0x80000060, 0xc121fffe, 0x5911fffe, 0xcd0000f9, 0xc1203db8, 0x5910de82, 0xcd0000f9,
+ 0xc1000006, 0xcd0000f9, 0xc120385a, 0x591033da, 0xcd0000f9, 0x5fb80002, 0x8800001a, 0x6ffe0010,
+ 0x8000ff28, 0xdd7c00f9, 0xc3800000, 0xc7f86010, 0x5bb80008, 0xc3540002, 0x777da000, 0xc1000008,
+ 0x4791c002, 0xcf8000f9, 0xdb900038, 0xc3800008, 0xc3720002, 0x777da000, 0xa7f00028, 0x47b9c002,
+ 0xc1000000, 0xc7d26010, 0x4391c000, 0xcf8000f8, 0xdb900838, 0xc3c00000, 0xdbc800f9, 0xc0400000,
+ 0xc11c0000, 0xc000082c, 0xcd05ce00, 0xc11c0002, 0xc000082c, 0xcd05ce00, 0xc0400002, 0xc11c0000,
+ 0xc000082c, 0xcd05ce00, 0xc11c0002, 0xc000082c, 0xcd05ce00, 0xc0000824, 0x00000000, 0xcbc000f9,
+ 0xcb8000f9, 0xcb4000f9, 0xcb0000f8, 0xc0004878, 0x5bfc4000, 0xcfc000f9, 0x5bb84000, 0xcf8000f9,
+ 0x5b744000, 0xcf4000f9, 0x5b304000, 0xcf0000f8, 0xc0000a10, 0x00000000, 0xcbc000f9, 0xcb8000f8,
+ 0xc0004874, 0x5bfc4000, 0xcfc000f9, 0x5bb84000, 0xcf8000f8, 0xc30001fe, 0xc000140a, 0xcf0000f8,
+ 0xc3000000, 0x7f018000, 0xc000042e, 0xcf0000f8, 0xc000040e, 0xcf0000f8, 0xc3c1fffe, 0xc000490e,
+ 0xcfc00078, 0xc000492c, 0xcfc00078, 0xc0004924, 0xcfc00038, 0xc0004912, 0xcfc00038, 0xc000498c,
+ 0xcfc00038, 0xc000498e, 0xcfc00078, 0xc0004990, 0xcfc00078, 0xc3c00000, 0xc2800004, 0xc3000000,
+ 0x7f018000, 0x6ff88000, 0x6fd44000, 0x4395c000, 0x5bb84a00, 0xc00049a0, 0xcb0000f8, 0x00000000,
+ 0x58380006, 0xcf0000f8, 0xc321fffe, 0x5b31fffe, 0x58380024, 0xcf0000f8, 0x5bfc0002, 0xb7e8ff90,
+ 0x00000000, 0xc3c00000, 0xc2800010, 0x6ff86000, 0x47bdc000, 0x5bb84c80, 0xc3400000, 0x58380004,
+ 0xcb420078, 0x00000000, 0x58380008, 0xcf400078, 0x5bfc0002, 0xb7e8ffb0, 0x00000000, 0xc3c00000,
+ 0xc2800004, 0xc3400022, 0xc3000000, 0x7f018000, 0xc2c00016, 0x6ff8a000, 0x47bdc000, 0x5bb84e20,
+ 0x58380008, 0xcf400038, 0xc00049a8, 0xcb0000f8, 0x00000000, 0x5838000a, 0xcf0000f8, 0xc321fffe,
+ 0x5b31fffe, 0x5838000c, 0xcf0000f8, 0x58380034, 0xcec00038, 0x5bfc0002, 0xb7e8ff78, 0x00000000,
+ 0x00000000, 0xc0004840, 0xc3e12624, 0x5bfc2320, 0xcfc000f9, 0xc3e02f2c, 0x5bfd2a28, 0xcfc000f9,
+ 0xc3e03734, 0x5bfd3230, 0xcfc000f9, 0xc3e13e3c, 0x5bfc3b38, 0xcfc000f9, 0xc3e14644, 0x5bfc4340,
+ 0xcfc000f9, 0xc3e04f4c, 0x5bfd4a48, 0xcfc000f9, 0xc3e05754, 0x5bfd5250, 0xcfc000f9, 0xc3e15e5c,
+ 0x5bfc5b58, 0xcfc000f9, 0xc3e06764, 0x5bfd6260, 0xcfc000f9, 0xc3e16e6c, 0x5bfc6b68, 0xcfc000f9,
+ 0xc3e17674, 0x5bfc7370, 0xcfc000f9, 0xc3e07f7c, 0x5bfd7a78, 0xcfc000f9, 0xc3e18684, 0x5bfc8380,
+ 0xcfc000f9, 0xc3e08f8c, 0x5bfd8a88, 0xcfc000f9, 0xc3e09794, 0x5bfd9290, 0xcfc000f9, 0xc3e19e9c,
+ 0x5bfc9b98, 0xcfc000f9, 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0xc1000000, 0xd91c00f8, 0xc3e01002, 0x5bfd88c0, 0xc3a00f88,
+ 0x5bb839a2, 0x990068d8, 0xdbd800f8, 0xdb9800f9, 0x00000000, 0xc3c00000, 0xdf7f0038, 0xa7ccfff0,
+ 0xc3800000, 0xc00048c0, 0xcb818078, 0xc0001408, 0xcfc000f8, 0xc10e0002, 0xd90c00f8, 0x5d3802a6,
+ 0xc1000002, 0xd91c1f02, 0xc121fffe, 0x5911fef4, 0x14100000, 0xa9fe0270, 0xc3c00000, 0xddfc00f0,
+ 0x5d3c0000, 0x84000100, 0xc0000c04, 0xcb8000f8, 0xc11c0002, 0x00000000, 0x7391c000, 0xcf8000f8,
+ 0xc3800000, 0xc3400080, 0xdf780038, 0xb7b4ffea, 0xc3203002, 0x5b3188c4, 0xc2e00f88, 0x5aec100e,
+ 0x990068d8, 0xdb1800f8, 0xdad800f9, 0x00000000, 0xc3800000, 0xc3400080, 0xdf780038, 0xb7b4ffea,
+ 0xc3205002, 0x5b3188c8, 0xc2e00f90, 0x5aec180c, 0x990068d8, 0xdb1800f8, 0xdad800f9, 0x00000000,
+ 0x80000128, 0xc00048cc, 0xca8000f8, 0x00000000, 0xc1000006, 0x76914000, 0x840000fa, 0x00000000,
+ 0xa6800070, 0xc3800000, 0xc3400080, 0xdf780038, 0xb7b4ffea, 0xc3202002, 0x5b31c8c6, 0xc2e00f88,
+ 0x5aec100e, 0x990068d8, 0xdb1800f8, 0xdad800f9, 0x00000000, 0xa6820068, 0xc3800000, 0xc3400080,
+ 0xdf780038, 0xb7b4ffea, 0xc3204002, 0x5b31c8ca, 0xc2e00f90, 0x5aec180c, 0x990068d8, 0xdb1800f8,
+ 0xdad800f9, 0x00000000, 0xc00048cc, 0xc2800000, 0xce8000f8, 0xc3a00140, 0x5bfc0002, 0x47bc8000,
+ 0xc1000000, 0xc53c00fe, 0xdbdc00f0, 0x80000028, 0x00000000, 0x800004e8, 0x00000000, 0x8000fd70,
+ 0xc0004918, 0xd28000f8, 0xc2000000, 0xdf600038, 0x5e600080, 0x840002b2, 0x00000000, 0xc161fffe,
+ 0x5955fffe, 0x14140000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xc000480a, 0xca0000f8, 0xc0004912, 0xca4000f8, 0xc0004924, 0xca8000f8, 0xc000498c, 0xcac000f8,
+ 0xc121fffe, 0x5911fef4, 0x14100000, 0x76250000, 0x76290000, 0x762d0000, 0x840001ea, 0xc0004918,
+ 0xca4000f8, 0xc28001fe, 0x76290000, 0x5a640002, 0x6a254010, 0x5ee80000, 0x8400001a, 0x6aa54000,
+ 0x80000010, 0xc62800f8, 0x62818008, 0xc0004918, 0xcf0000f8, 0xc161fffe, 0x5955fffe, 0x14140000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xc000498c, 0xca4000f8,
+ 0xc2000002, 0x6a310000, 0x7e010000, 0x76612000, 0xce4000f8, 0xc121fffe, 0x5911fef4, 0x14100000,
+ 0x6f346000, 0x4771a000, 0x5b744c80, 0xc2800000, 0x58340006, 0xca800078, 0xc2c00000, 0x58340000,
+ 0xcac000d8, 0xc2400000, 0x5834000a, 0xca420078, 0x6ea82000, 0x42e9e000, 0x6f2ca000, 0x42e56000,
+ 0x5aec1400, 0xc3990040, 0xc7381c18, 0xc6f80060, 0x990068d8, 0xdb9800f8, 0xdbd800f9, 0x00000000,
+ 0xdea000f8, 0x46310000, 0x8400fd40, 0xc000495a, 0xc84000f8, 0x00000000, 0xc3c00002, 0x787c2000,
+ 0xcc4000f8, 0xc0000838, 0xc3800000, 0xcb840028, 0x6c748000, 0x6c544000, 0x4355a000, 0x5b744a00,
+ 0x5ef80000, 0x8400fca2, 0x58340004, 0xcb0000f8, 0x00000000, 0x00000000, 0xa7060020, 0x00000000,
+ 0x5ef80002, 0x8400fc62, 0x5834000c, 0xc8800038, 0xc2000000, 0xc000082c, 0xca040028, 0x5a880002,
+ 0xc2400000, 0xc0004958, 0xce4000f8, 0xb6280018, 0x00000000, 0xc2800000, 0x58340002, 0xc2000000,
+ 0xca020008, 0xc0004956, 0xce8000f8, 0x5e600000, 0x84001ca2, 0x5e600002, 0x84004062, 0x00000000,
+ 0x800021d0, 0xc0004958, 0xca0000f8, 0xc0004956, 0xca8000f8, 0x5e200000, 0x84000020, 0xc2500002,
+ 0xc0000838, 0xce450800, 0x6c748000, 0x6c544000, 0x4355a000, 0x5b744a00, 0x5834000c, 0xc6900038,
+ 0xcd000038, 0x8000fb38, 0xc2000000, 0xdf600038, 0x5e200080, 0x8400028a, 0x00000000, 0xc161fffe,
+ 0x5955fffe, 0x14140000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xc000480c, 0xca0000f8, 0xc0004910, 0xca4000f8, 0xc000492c, 0xca8000f8, 0xc000498e, 0xcac000f8,
+ 0xc121fffe, 0x5911fef4, 0x14100000, 0x76250000, 0x76290000, 0x76e16000, 0x840001c2, 0xc0004926,
+ 0xca4000f8, 0xc201fffe, 0x76e16000, 0x5a640002, 0x6ae50010, 0x5f200000, 0x8400001a, 0x6a250000,
+ 0x80000010, 0xc6e000f8, 0x62014008, 0xc0004926, 0xce8000f8, 0xc161fffe, 0x5955fffe, 0x14140000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xc000498e, 0xca4000f8,
+ 0xc2000002, 0x6a290000, 0x7e010000, 0x76612000, 0xce4000f8, 0xc121fffe, 0x5911fef4, 0x14100000,
+ 0x6eb4a000, 0x4769a000, 0x5b744e20, 0x58340002, 0xc2000000, 0xca0000d8, 0x58340036, 0xc2400000,
+ 0xca400078, 0x6eb0a000, 0x47298000, 0x5b300e56, 0x5b300004, 0x6e642000, 0x4225e000, 0xc39a8024,
+ 0xc7380060, 0xc6b81c18, 0x990068d8, 0xdb9800f8, 0xdbd800f9, 0x00000000, 0xc2000000, 0xdf600038,
+ 0x5e200080, 0x840002da, 0x00000000, 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xc000490e, 0xca0000f8, 0xc000492a, 0xca4000f8,
+ 0xc0004990, 0xcb0000f8, 0xc000498a, 0xcac000f8, 0xc121fffe, 0x5911fef4, 0x14100000, 0x77218000,
+ 0x77258000, 0x8400021a, 0xc201fffe, 0x77218000, 0x5aec0002, 0x6b2d0010, 0x5ea00000, 0x8400001a,
+ 0x6a2d0000, 0x80000010, 0xc72000f8, 0x62016008, 0xc000498a, 0xcec000f8, 0xc161fffe, 0x5955fffe,
+ 0x14140000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xc0004990,
+ 0xca4000f8, 0xc2000002, 0x6a2d0000, 0x7e010000, 0x76612000, 0xce4000f8, 0xc121fffe, 0x5911fef4,
+ 0x14100000, 0x6ef4a000, 0x476da000, 0x5b744e20, 0x58340010, 0xc2000000, 0xca0000d8, 0x58340008,
+ 0xc2400000, 0xca420078, 0x5834000e, 0xc2800000, 0xca832010, 0xc3c00000, 0x47e48000, 0x6e644010,
+ 0xc7e800fc, 0x42250000, 0x4229e000, 0xc39a8008, 0x58340008, 0xcb801038, 0x58340008, 0xc2800000,
+ 0xca810010, 0x6ee0a000, 0x462d0000, 0x5a20000a, 0x5a200e28, 0x42290000, 0xc6380060, 0xc6f81c18,
+ 0x990068d8, 0xdb9800f8, 0xdbd800f9, 0x00000000, 0xc000495c, 0xc84000f8, 0xc3400000, 0xc3c00002,
+ 0x787c2000, 0xcc4000f8, 0x6c78a000, 0x4785c000, 0x5bb84e20, 0x58380034, 0xcb410038, 0xc0000a28,
+ 0xc3000000, 0xcb040028, 0xc0000a14, 0xc2c00000, 0x43358000, 0xcac40028, 0xc000490e, 0xca8000f8,
+ 0x5eec0002, 0x472d8000, 0x8800f258, 0x6bc5e000, 0x76bd4000, 0x8400f240, 0x6c7ca000, 0x47c5e000,
+ 0x5bfc4e20, 0x583c0008, 0xc2000000, 0xca020078, 0xc00049aa, 0x00000000, 0xca8000f9, 0xca4000f8,
+ 0xc0001008, 0xce8000f8, 0xc0001006, 0xce4000f8, 0x583c000a, 0xca4000f8, 0x00000000, 0xc000100a,
+ 0xce4000f8, 0xc2400006, 0xc0001000, 0xce4000f8, 0xc2600982, 0x5a643b6e, 0xc0001002, 0xce4000f8,
+ 0x583c000c, 0xca4000f8, 0x00000000, 0xc0001004, 0xce4000f8, 0x583c000e, 0xcb8000f8, 0x00000000,
+ 0xc2400000, 0xc7a40078, 0xc2800000, 0xc7aae020, 0xdaa000f9, 0x583c0034, 0xcb8000f8, 0x00000000,
+ 0xc2c00000, 0xc7ad0038, 0xc0004978, 0xcec000f8, 0xc0800000, 0xc7880038, 0xc3400000, 0xc7b60038,
+ 0xc0004980, 0xcf4000f8, 0x4661c000, 0x43a9c000, 0xc2400000, 0xc000497c, 0xce4000f8, 0xad2c0001,
+ 0xc2800000, 0x00000000, 0x80000010, 0xc2800002, 0xc0004976, 0xce8000f8, 0xc2c00000, 0xc34000a0,
+ 0xdb5c00f9, 0xc3400002, 0xc000497a, 0xcf4000f8, 0x5f600000, 0x84000180, 0xde2800f9, 0xc6a000f8,
+ 0x47a9c000, 0x583c0000, 0xc2800000, 0xca830038, 0xc0000a28, 0xc3000000, 0xcb040028, 0xc3400000,
+ 0xc0004976, 0x46b18000, 0x8800006a, 0xcf4000f8, 0x58880002, 0xc3000000, 0xc0000a14, 0xcb040028,
+ 0x00000000, 0x00000000, 0xb4b001a8, 0x00000000, 0xc0800000, 0x00000000, 0x80000188, 0xc0004980,
+ 0xcb4000f8, 0x00000000, 0x00000000, 0x5af40002, 0xacec0080, 0x00000000, 0xc2c00000, 0xc000497a,
+ 0xadec0001, 0x00000000, 0x00000000, 0xad2c007f, 0xc2800000, 0xce8000f8, 0x80000018, 0xc2800002,
+ 0xce8000f8, 0x5f6c0000, 0x840000e8, 0x00000000, 0x8000ff00, 0x5f780082, 0x88000258, 0xc3000002,
+ 0xc000497c, 0xcf0000f8, 0xc2800080, 0xc1000000, 0xdd110038, 0x46914000, 0x47a94000, 0x880001d8,
+ 0x4391a000, 0xc0004980, 0xcf4000f8, 0x6f684010, 0x6f77c000, 0x6f77c010, 0xc0004840, 0x40280000,
+ 0xca8000f8, 0xc3000000, 0x6f506000, 0x6a908010, 0xc5300038, 0xdb1c00f9, 0x8000fe30, 0xc3400000,
+ 0xc0000a10, 0xcb440060, 0x6cb04000, 0x6f288000, 0x6f744000, 0x42b14000, 0x43694000, 0xc3400000,
+ 0xc6b44060, 0xc0004000, 0x40340000, 0xc321e000, 0xcf0000f8, 0x5aa80008, 0x42ad4000, 0xc3400000,
+ 0xc6b44060, 0xc0004000, 0x40340000, 0xca4000f8, 0xc3000000, 0xc6f00008, 0xc1400000, 0xddd40039,
+ 0x6f306000, 0xc13001fe, 0x69308010, 0x7d008000, 0x76512000, 0x6d570000, 0x6970a010, 0x42552000,
+ 0xce4000f8, 0x5aa80002, 0x5aec0002, 0xacec0080, 0x00000000, 0xc2c00000, 0x5f6c0000, 0x84000118,
+ 0x00000000, 0x80000040, 0x4391a000, 0x5f740080, 0xc0004980, 0xcf4000f8, 0xc3000004, 0xc000497a,
+ 0xcf0000f8, 0x58880002, 0xc3400000, 0xc0000a14, 0xcb440028, 0x00000000, 0x00000000, 0xb4b40018,
+ 0x00000000, 0xc0800000, 0xc3400000, 0xc0000a10, 0xcb440060, 0x6cb04000, 0x6f248000, 0x6f744000,
+ 0x42712000, 0x43654000, 0xc3400000, 0xc6b44060, 0xc0004000, 0x40340000, 0xc3201e00, 0xcf0000f8,
+ 0x5aa80008, 0x42ad4000, 0xc000100c, 0xcb4000f8, 0xc3000000, 0x00000000, 0xc7340060, 0xc300fffe,
+ 0xc7341070, 0xcf4000f8, 0xc000100e, 0xcb4000f8, 0xc3000e28, 0x00000000, 0xc7340060, 0xc300fffe,
+ 0xc7341070, 0xcf4000f8, 0xc0001010, 0xcb4000f8, 0xc3000002, 0x00000000, 0xc7341a00, 0xc7341800,
+ 0xc3000000, 0xc7341900, 0xc6b40070, 0xcf4000f8, 0xc0004982, 0xce8000f8, 0x6c64a000, 0x46452000,
+ 0x5a64000a, 0xc0001012, 0xcb4000f8, 0xc2800002, 0x00000000, 0xc6740260, 0xc6340008, 0xc000497c,
+ 0xcb0000f8, 0xc6b41800, 0xc6b41b00, 0xc6b41c00, 0xc6b41d00, 0xc7341e00, 0xdd6800f9, 0x7e814000,
+ 0x6eab2010, 0x76b14000, 0xc6b41f00, 0xc2800000, 0xc6b41900, 0xc3000080, 0x472d8000, 0xc0004982,
+ 0xc90000f8, 0x47394000, 0x88000102, 0x41388000, 0xcd0000f8, 0xc7b41038, 0xc0004994, 0xce8000f8,
+ 0xde1000f9, 0x45208000, 0x840000b0, 0xc1000000, 0xdd110038, 0x41388000, 0x412c8000, 0x5d100080,
+ 0xc0004980, 0xcd0000f8, 0xc1000002, 0xc000497c, 0xcd0000f8, 0xc5341e00, 0xdd5000f9, 0x7d008000,
+ 0xc5373f00, 0xc000497a, 0xc90000f8, 0x42390000, 0x43adc000, 0x59100002, 0xcd0000f8, 0x80000050,
+ 0x42390000, 0x80000040, 0xc7341038, 0x41308000, 0xcd0000f8, 0x42310000, 0xc1000000, 0xc0004994,
+ 0xcd0000f8, 0xc0001012, 0xcf4000f8, 0xc000493c, 0xce0000f8, 0xc0004984, 0xcf8000f8, 0xc000497a,
+ 0xca4000f8, 0xc000497c, 0xca8000f8, 0x6c7ca000, 0x47c5e000, 0x5bfc4e20, 0xc0004976, 0xcac000f8,
+ 0xc0004978, 0xca0000f8, 0x5eec0002, 0x8400008a, 0x42250000, 0xc2400000, 0xc000497a, 0xce4000f8,
+ 0x583c0000, 0xc2c00000, 0xcac30038, 0x00000000, 0x00000000, 0x46e16000, 0x8800001a, 0x00000000,
+ 0xad280002, 0xc000497a, 0xce0000f8, 0xc2000000, 0x5fa80000, 0x840001da, 0x00000000, 0x6c508000,
+ 0xc0004880, 0x40100000, 0x58000018, 0xc90000f8, 0x00000000, 0x00000000, 0x59100002, 0xcd0000f8,
+ 0x583c000e, 0xc2c00000, 0xcac00078, 0xc1000000, 0xdd532201, 0x42d16000, 0x6c508000, 0xc0004880,
+ 0x40100000, 0x5800001a, 0xc90000f8, 0x00000000, 0x00000000, 0x412c8000, 0xcd0000f8, 0x99006968,
+ 0xd85800f8, 0xdbd800f9, 0x00000000, 0x990066b0, 0xc000491c, 0xc1400000, 0xc9420048, 0xc000491c,
+ 0x99006b68, 0xc94000f9, 0xc98000f8, 0x00000000, 0x990068d8, 0xd95800f8, 0xd99800f9, 0x00000000,
+ 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x98c06528, 0xd85800f8, 0xdbd800f9, 0xc45800f8, 0xc121fffe, 0x5911fef4, 0x14100000,
+ 0xade80003, 0xc000493c, 0xcb4000f8, 0x00000000, 0xc3000000, 0xc7701078, 0x80000010, 0xc3000000,
+ 0x583c0008, 0xcf021078, 0x6e210000, 0x583c0034, 0xce010838, 0xc0004980, 0xcb8000f8, 0x583c0034,
+ 0x00000000, 0x6fba0000, 0xcf821038, 0xc000490e, 0xca0000f8, 0xc2c00002, 0x6ac56000, 0x722d0000,
+ 0xce0000f8, 0x00000000, 0x00000000, 0x00000000, 0xa8e2ffe8, 0x00000000, 0xc1220002, 0xd90c00f8,
+ 0x5fa80000, 0x84000712, 0xc00049a8, 0xca0000f8, 0x583c000a, 0x00000000, 0xce0000f8, 0xc221fffe,
+ 0x5a21fffe, 0x583c000c, 0xce0000f8, 0xc0001004, 0xca0000f8, 0x00000000, 0x583c0012, 0x7e010000,
+ 0xce0000f8, 0xa97000e1, 0x00000000, 0x00000000, 0xa97200c9, 0xc0001010, 0xc2740000, 0xce435a00,
+ 0x6c64a000, 0x46452000, 0x5a64000a, 0x6e644000, 0xc0001012, 0xce400070, 0xc2600008, 0xce421038,
+ 0xc27e0002, 0xce43ff00, 0xc2760002, 0xce437b00, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0xa8e2ffe8, 0x00000000, 0xc1220002, 0xd90c00f8, 0xc1000000, 0xdd110038, 0x5d100000,
+ 0x84000412, 0xc0004982, 0xca0000f8, 0xc0004984, 0xca4000f8, 0xc2800000, 0xc361fffe, 0x5b75fffe,
+ 0xa96a001b, 0xdfec00f8, 0xc6ec1078, 0x7af56000, 0x6c40a000, 0x44040000, 0x58004e20, 0x58000014,
+ 0xcec000f8, 0xa972001b, 0x5c000002, 0xcec000f8, 0xc0001010, 0xc2f40002, 0xcec35a00, 0x6c6ca000,
+ 0x46c56000, 0x5aec000a, 0x6eec4000, 0xc0001012, 0xcec00070, 0xc0004994, 0xc98000f8, 0xc1400000,
+ 0xdd150038, 0xc55c00f8, 0x45948000, 0x00000000, 0xc59c00fc, 0x5d1c0000, 0x840000d2, 0xc0001012,
+ 0xc5d01038, 0xcd021038, 0xc2f60002, 0xcec37b00, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0xa8e2ffe8, 0x00000000, 0xc1220002, 0xd90c00f8, 0x45948000, 0x88000052, 0xc0004994,
+ 0xcd0000f8, 0xc0004980, 0xcbc000f8, 0x42150000, 0xc0004982, 0xce0000f8, 0x5ffc0000, 0x84000218,
+ 0x58880002, 0xc3800000, 0xc0000a14, 0xcb840028, 0xc3c00000, 0xc0000a10, 0xb4b80018, 0x00000000,
+ 0xc0800000, 0xcbc40060, 0x6cb84000, 0x6fac8000, 0x6ffc4000, 0x42f96000, 0x43ed0000, 0xc3400000,
+ 0xc6344060, 0xc0004000, 0x40340000, 0xc2a1e000, 0xce8000f8, 0x5a200008, 0xc0004980, 0xcbc000f8,
+ 0xc3400000, 0xc0004840, 0x6ff84010, 0xc7f40008, 0x40380000, 0xcb8000f8, 0xc2800000, 0x6f506000,
+ 0x6b908010, 0xc52c1838, 0xc3400000, 0xc6344060, 0xc0004000, 0x40340000, 0xcec000f8, 0x5a200002,
+ 0x5ffc0000, 0x84000092, 0xc0001010, 0xc62c0070, 0xcec00070, 0xc0001012, 0xc7ec1038, 0xcec21038,
+ 0xc2f60002, 0xcec37b00, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xa8e2ffe8,
+ 0x00000000, 0xc1220002, 0xd90c00f8, 0xc0004994, 0xc100007e, 0x453c8000, 0xcd0000f8, 0x423d0000,
+ 0xc0004982, 0xce0000f8, 0xc0004994, 0xca0000f8, 0xc0004980, 0xca4000f8, 0x5e200000, 0x8400015a,
+ 0xc2000000, 0xc2800000, 0x5a640002, 0xc6684028, 0xc0004982, 0xcb0000f8, 0xc0004000, 0xc2c00000,
+ 0xc72c4060, 0x402c0000, 0x6e67c000, 0x6e67c010, 0x5ee40002, 0x8400003a, 0x5ee40004, 0x8400004a,
+ 0x5ee40006, 0x8400005a, 0x00000000, 0x80000060, 0xce0000b8, 0x5aa80002, 0x5b300006, 0x80000040,
+ 0xce000078, 0x5aa80002, 0x5b300004, 0x80000020, 0xce000038, 0x5aa80002, 0x5b300002, 0x5ee80020,
+ 0x84000052, 0xc0004000, 0xc2c00000, 0xc72c4060, 0x402c0000, 0xce0000f8, 0x5aa80002, 0x5b300008,
+ 0x8000ffb8, 0x00000000, 0x80000040, 0x583c000a, 0xd7c000f8, 0xc0001004, 0xca4000f8, 0x00000000,
+ 0x583c000c, 0xce4000f8, 0xc000497a, 0xca4000f8, 0xc2800002, 0xc0000a28, 0xc6780928, 0xc6b80800,
+ 0xcf850830, 0x6c7ca000, 0x47c5e000, 0x5bfc4e20, 0x583c0034, 0xc4900038, 0xcd000038, 0x8000e418,
+ 0x6c6c8000, 0x6c544000, 0x42d56000, 0x5aec4a00, 0xc0000824, 0xca0400f8, 0x6ca48000, 0x42492000,
+ 0xc3000000, 0xc3400000, 0x42250000, 0x58204000, 0xca4000f8, 0x5a200002, 0xda2400f9, 0xc2800000,
+ 0xc000495e, 0xce8000f8, 0xda6000f8, 0xc2800000, 0xc66b0038, 0xdaa800f8, 0x582c0010, 0x6f206010,
+ 0x40200000, 0xd82800f9, 0xca0000f8, 0xc2400000, 0xc7240010, 0x6e644000, 0xda6400f8, 0x6a254010,
+ 0xc3c00000, 0xc6bc0018, 0xc3800000, 0xdea000f8, 0x5e60001e, 0x8400002a, 0x5e6001e0, 0x8400001a,
+ 0x00000000, 0x80000080, 0xc7f800f8, 0x5e7c0008, 0x8400006a, 0x5bbc0002, 0x5e780008, 0x84000028,
+ 0x5b740002, 0xc0004960, 0xcf0000f8, 0x80000030, 0x5e780006, 0x88000022, 0xc2800002, 0xc000495e,
+ 0xce8000f8, 0xde8000f9, 0xca8000f8, 0xde6000f8, 0xc240001e, 0x6a612000, 0x7e412000, 0x76a54000,
+ 0x6ba12000, 0x72a54000, 0xce8000f8, 0x5e300080, 0x840000ba, 0xc2000000, 0xc7200008, 0x5e600000,
+ 0x84000058, 0xde6000f9, 0x58204000, 0xca4000f8, 0x5a200002, 0xda2400f9, 0xc2800000, 0xc66b0038,
+ 0xdaa800f8, 0xda6000f8, 0x80000038, 0xc2800000, 0x6e206000, 0xde2400f8, 0x6a610000, 0xc62b0038,
+ 0xdaa800f8, 0x5b300002, 0x8000fde0, 0xc2000000, 0x582c0020, 0xca020078, 0x00000000, 0xc2400000,
+ 0x5a200002, 0xc6241078, 0xce421078, 0xc000480e, 0xca8000f8, 0x5e740000, 0x84000160, 0x46a12000,
+ 0x8800e048, 0xc2400000, 0xc0000808, 0xca440010, 0x582c0010, 0xc1400000, 0xcd4000f9, 0xcd4000f9,
+ 0xcd4000f9, 0xcd4000f9, 0xcd4000f9, 0xcd4000f9, 0xcd4000f9, 0xcd4000f9, 0xcd400018, 0x582c0020,
+ 0xce021078, 0xc2000010, 0x5a640002, 0xb6240018, 0x00000000, 0xc2400000, 0xc6600010, 0xc0000808,
+ 0xce040010, 0xc0004956, 0xca4000f8, 0xc11c0000, 0xc000082c, 0xcd05ce00, 0xc6600928, 0xc2400000,
+ 0xc6600028, 0xc0000838, 0xce0400f8, 0xc2400002, 0xc0004958, 0xce4000f8, 0xc11c0002, 0xc000082c,
+ 0xcd05ce00, 0x8000df00, 0xc000495e, 0xca0000f8, 0x5e740002, 0x8400dee0, 0x5e200000, 0x8400ded0,
+ 0xc0004960, 0xca4000f8, 0xc2200004, 0x582c0002, 0xce021008, 0xc2000082, 0x46250000, 0xc6280030,
+ 0xc0000810, 0xce840030, 0x99007000, 0x582c0002, 0xc94000f8, 0xc1a20000, 0x5e640000, 0x8400fed0,
+ 0x00000000, 0x8000de40, 0x6c6c8000, 0x6c544000, 0x42d56000, 0x5aec4a00, 0xc000487c, 0xc80400f8,
+ 0x00000000, 0x00000000, 0x40080000, 0xcb8000f8, 0xc42400f8, 0x00000000, 0xa78601a0, 0xc3c00000,
+ 0xc2000000, 0x582c000c, 0xca010038, 0x6c508000, 0xc0004880, 0x40100000, 0x58000016, 0xc90000f8,
+ 0x00000000, 0x00000000, 0x59100002, 0xcd0000f8, 0x5a200002, 0x582c000c, 0xc6100838, 0xcd010838,
+ 0x5e600002, 0x84000020, 0xc2200004, 0x582c0002, 0xce021008, 0x5e600008, 0x84000060, 0xc2200002,
+ 0x582c0002, 0xce021008, 0x582c000c, 0xcfc10838, 0xc2220002, 0xc0000a14, 0xce063100, 0xc22001a2,
+ 0xc0000a1c, 0xce061038, 0x6c6c8000, 0x6c544000, 0x42d56000, 0x5aec4a00, 0x582c0004, 0xcb0000f8,
+ 0xc3400000, 0x00000000, 0xa7060028, 0xcf406300, 0xc3100002, 0xc0000838, 0xcf050800, 0x582c000c,
+ 0xcf421000, 0x8000dc40, 0x582c000c, 0xcfc10838, 0xc2000000, 0xc7a06010, 0x5e200000, 0x84001c08,
+ 0x6c6c8000, 0x6c544000, 0x42d56000, 0x5aec4a00, 0xc000487c, 0xc80400f8, 0x00000000, 0x00000000,
+ 0x40080000, 0xcb8000f8, 0xc42400f8, 0x00000000, 0xc2800000, 0xc3400000, 0xc7b5c030, 0xc0004970,
+ 0xcf4000f8, 0xc2400000, 0xc7a4e030, 0xc000496c, 0xce4000f8, 0xc3000000, 0xc7b00010, 0xc3c00004,
+ 0xc000496e, 0xcfc000f8, 0x582c000c, 0xca0000f8, 0xc2400002, 0xc0004964, 0xce4000f8, 0xa6200372,
+ 0x00000000, 0x5e700004, 0x840000ea, 0x5e700006, 0x84000080, 0xc2000002, 0x582c0002, 0xce000000,
+ 0xc0000a14, 0xce863100, 0x6c508000, 0xc0004880, 0x40100000, 0x58000014, 0xc90000f8, 0x00000000,
+ 0x00000000, 0x59100002, 0xcd0000f8, 0x80001a58, 0x5e70000a, 0x84000040, 0xc2000000, 0x582c0002,
+ 0xce000000, 0xc2220002, 0xc0000a14, 0xce063100, 0x8000ff70, 0x5e700008, 0x84000228, 0xc2200002,
+ 0x582c000c, 0xce021000, 0x6c508000, 0xc0004880, 0x40100000, 0x58000012, 0xc90000f8, 0x00000000,
+ 0x00000000, 0x59100002, 0xcd0000f8, 0x5e340002, 0x6c508000, 0xc0004880, 0x40100000, 0x58000010,
+ 0xc90000f8, 0x00000000, 0x00000000, 0x41208000, 0xcd0000f8, 0xc0000a14, 0xce863100, 0xc0004970,
+ 0xcb4000f8, 0x6c6c8000, 0x6c544000, 0x42d56000, 0x5aec4a00, 0x582c000e, 0xc4900038, 0xcd000038,
+ 0x582c000e, 0xc7500838, 0xcd010838, 0xc2800000, 0x582c0004, 0xce821078, 0x582c0004, 0xce800000,
+ 0xc00049a0, 0xca4000f8, 0x00000000, 0x582c0006, 0xce4000f8, 0xc261fffe, 0x5a65fffe, 0x582c0024,
+ 0xce4000f8, 0xc2060002, 0x582c0004, 0xce006300, 0xc2400002, 0xc0004958, 0xce4000f8, 0xc0004878,
+ 0xc80400f8, 0x6c908000, 0x41088000, 0x40100000, 0x58000020, 0xc90000f8, 0x582c0026, 0x00000000,
+ 0xcd0000f8, 0x800017e8, 0x00000000, 0x6c508000, 0xc0004880, 0x40100000, 0x58000016, 0xc90000f8,
+ 0x00000000, 0x00000000, 0x59100002, 0xcd0000f8, 0x8000faf0, 0x5e700000, 0x840000c0, 0xc3400082,
+ 0xc0004970, 0xcf4000f8, 0xc2400080, 0xc000496c, 0xce4000f8, 0xc3c00002, 0xc000496e, 0xcfc000f8,
+ 0xc2400000, 0xc0004964, 0xce4000f8, 0xc0004878, 0xc80400f8, 0x6c908000, 0x41088000, 0x40100000,
+ 0x58000020, 0xc90000f8, 0x582c0026, 0x00000000, 0xcd0000f8, 0x80000078, 0x5e700002, 0x84000058,
+ 0xc3400082, 0xc0004970, 0xcf4000f8, 0xc3c00004, 0xc000496e, 0xcfc000f8, 0xc2200000, 0x582c000c,
+ 0xce021000, 0x80000030, 0x5e700004, 0x8400fe80, 0xc2600002, 0x582c000c, 0xce421000, 0xc0000a14,
+ 0xce863100, 0xc000496c, 0xca4000f8, 0x6c508000, 0xc0004880, 0x40100000, 0x58000012, 0xc90000f8,
+ 0x00000000, 0x00000000, 0x59100002, 0xcd0000f8, 0xc000496e, 0xcbc000f8, 0x00000000, 0x00000000,
+ 0x477d0000, 0x46250000, 0x6c508000, 0xc0004880, 0x40100000, 0x58000010, 0xc90000f8, 0x00000000,
+ 0x00000000, 0x41208000, 0xcd0000f8, 0x6c6c8000, 0x6c544000, 0x42d56000, 0x5aec4a00, 0x582c0004,
+ 0xca0000f8, 0x00000000, 0x00000000, 0xa60014e2, 0x00000000, 0x6c6c8000, 0x6c544000, 0x42d56000,
+ 0x5aec4a00, 0xc3000000, 0x582c0004, 0xcf006300, 0x582c0000, 0xcb002010, 0xc3c00000, 0x582c0004,
+ 0xcbc20078, 0xc000491a, 0xcf0000f8, 0xc000493c, 0xcfc000f8, 0x582c0008, 0xcb8000f8, 0x582c000a,
+ 0xca4000f8, 0xc0004930, 0xcf8000f8, 0xc0004932, 0xce4000f8, 0x5ffc0000, 0x840001f0, 0x00000000,
+ 0xa7be0102, 0xc2800000, 0x6f206000, 0x46310000, 0x5a204c80, 0x5820000c, 0xca800020, 0x00000000,
+ 0x00000000, 0x5ea80000, 0x84000112, 0x00000000, 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x990063c8, 0xc000491a, 0xc94000f8,
+ 0x00000000, 0xc121fffe, 0x5911fef4, 0x14100000, 0xc0004930, 0xcb8000f8, 0xc0004932, 0xca4000f8,
+ 0xc4781108, 0xc0004930, 0xcf8000f8, 0x582c0008, 0xcf8000f8, 0x582c000a, 0xce4000f8, 0xc7b6e108,
+ 0x582c0004, 0xcf402108, 0x80000090, 0x00000000, 0x6c508000, 0xc0004880, 0x40100000, 0x5800000c,
+ 0xc90000f8, 0x00000000, 0x00000000, 0x59100002, 0xcd0000f8, 0xc2000002, 0x582c0004, 0xce000000,
+ 0xc0000838, 0xc2500002, 0xce450800, 0x80001220, 0x6c7c8000, 0x6c544000, 0x43d5e000, 0x5bfc4a00,
+ 0x583c0006, 0xca0000f8, 0xc00049a2, 0x00000000, 0xca8000f9, 0xca4000f8, 0xc0001008, 0xce8000f8,
+ 0xc0001006, 0xce4000f8, 0xc000100a, 0xce0000f8, 0xc2400006, 0xc0001000, 0xce4000f8, 0xc2600982,
+ 0x5a643b6e, 0xc0001002, 0xce4000f8, 0x583c0024, 0xca4000f8, 0x00000000, 0xc0001004, 0xce4000f8,
+ 0xc0004862, 0xc2000000, 0xca000078, 0xc360fffe, 0xc0004862, 0xce0000f8, 0xc0000824, 0xcb440060,
+ 0x00000000, 0xc000100e, 0xcf4000f8, 0xc3801600, 0xc2400200, 0x6e644000, 0xc6781070, 0xc000100c,
+ 0xcf8000f8, 0xc3200a00, 0xc0001010, 0xcf031810, 0xc2e06200, 0xc0001012, 0xcec31838, 0xc2000000,
+ 0x583c0004, 0xca002008, 0xc2800000, 0xc0004966, 0xce0000f8, 0xc62400f8, 0xc3000000, 0xc000496a,
+ 0xcf0000f8, 0xc0004974, 0xcf0000f8, 0xc000493c, 0xcb4000f8, 0x583c000e, 0x00000000, 0x5f740000,
+ 0x84000180, 0xc3400000, 0xcb410038, 0xc3000002, 0xc000496a, 0x5fb40080, 0x84000152, 0xcf0000f8,
+ 0x583c000e, 0xc2c00000, 0xcac00038, 0xc3800080, 0x47b5c000, 0xc0004974, 0xcf8000f8, 0xc0001012,
+ 0x6fba0000, 0xcf821038, 0x6fba0010, 0x43a5c000, 0x5b380006, 0x6f284010, 0xc7a40008, 0x6eec4000,
+ 0x6ef08000, 0x432d8000, 0x43358000, 0x5b300008, 0xc0001012, 0xc7100070, 0xcd000070, 0xc2000200,
+ 0xc2c00000, 0xdf6d0048, 0x462d6000, 0x46e96000, 0x8800ffe2, 0xc2000000, 0xc0004862, 0xca000260,
+ 0x00000000, 0x583c0004, 0xca002008, 0xc3360002, 0xc0001010, 0xce000070, 0xc0001012, 0xcf037b00,
+ 0xc0004974, 0xcb8000f8, 0x00000000, 0x00000000, 0x5fb80000, 0x84000042, 0x00000000, 0x00000000,
+ 0x00000000, 0xa8e2ffe8, 0x00000000, 0xc1220002, 0xd90c00f8, 0xc000496c, 0xcac000f8, 0x00000000,
+ 0x00000000, 0x426dc000, 0x5b380006, 0x6f304010, 0xc7a40008, 0xc0004968, 0xce4000f8, 0xc000496e,
+ 0xcb4000f8, 0x6ca44000, 0x6e608000, 0x42250000, 0x5a200006, 0x42350000, 0xc0001012, 0xc6100070,
+ 0xcd000070, 0x6eee0000, 0xcec21038, 0xc2000200, 0xc2c00000, 0xdf6d0048, 0x462d6000, 0x42b14000,
+ 0x46e96000, 0x8800ffda, 0xc000493c, 0xcb4000f8, 0xc0000838, 0xc3100002, 0x5f740000, 0x84000060,
+ 0xcf050800, 0xc0004974, 0xcb8000f8, 0x00000000, 0x00000000, 0x5fb80000, 0x8400006a, 0xc0001012,
+ 0xc3360002, 0xcf037b00, 0x800000a0, 0x583c0022, 0xcb4000f8, 0xc0004862, 0xca0000f8, 0x00000000,
+ 0xc0005600, 0x40200000, 0xcf4000f8, 0xc2000000, 0xc0004862, 0xca000260, 0x00000000, 0x583c0004,
+ 0xca002008, 0xc3360002, 0xc0001010, 0xce000070, 0xc0001012, 0xcf037b00, 0xc0004968, 0xcbc000f8,
+ 0xc0004964, 0xca4000f8, 0xc7e000f8, 0x00000000, 0x5e640000, 0x84000012, 0xc2000000, 0xc0004974,
+ 0xca4000f8, 0xc000496c, 0xca8000f8, 0xc000493c, 0xcb8000f8, 0x42698000, 0x00000000, 0x43b1a000,
+ 0x5ef40080, 0x8800019a, 0xc0004966, 0xcac000f8, 0x6c648000, 0x6c544000, 0x42552000, 0x5a644a00,
+ 0x58240000, 0x436da000, 0x4761a000, 0xc2400000, 0xca420078, 0x00000000, 0x00000000, 0x46752000,
+ 0x88000122, 0x432d8000, 0x47218000, 0x88000010, 0xc3000000, 0x5b300006, 0x6f304010, 0xc000493a,
+ 0xcf0000f8, 0xc0004932, 0xc2400000, 0xca4000d8, 0x00000000, 0x6fb84010, 0x42792000, 0xc000491e,
+ 0xce4000f8, 0xc0004862, 0xca8000f8, 0x00000000, 0xc2c0000a, 0xc6e80d70, 0xc7281048, 0xc000491c,
+ 0xce8000f8, 0x6c708000, 0x6c544000, 0x43158000, 0x5b304a00, 0x6f760000, 0x58300004, 0xcf421078,
+ 0x6ffc2000, 0x58300004, 0xcfc02108, 0x800000d0, 0x6c708000, 0x6c544000, 0x43158000, 0x5b304a00,
+ 0xc2800002, 0x58300004, 0xce800000, 0x6c508000, 0xc0004880, 0x40100000, 0x5800000e, 0xc90000f8,
+ 0x00000000, 0x00000000, 0x59100002, 0xcd0000f8, 0x00000000, 0x00000000, 0x00000000, 0xa8e2ffe8,
+ 0x00000000, 0xc1220002, 0xd90c00f8, 0x80000920, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xa8e2ffe8, 0x00000000, 0xc1220002, 0xd90c00f8, 0xc0004964, 0xca0000f8, 0x6c7c8000, 0x6c544000,
+ 0x43d5e000, 0x5bfc4a00, 0xdfe400f8, 0x5e200002, 0x84000608, 0x00000000, 0x583c0004, 0xc2800000,
+ 0xca820078, 0xc0004930, 0xcac000f8, 0x00000000, 0x00000000, 0x6eece000, 0x6eefc010, 0x46aca000,
+ 0xc1000000, 0xdd500039, 0x6d106010, 0x4550a000, 0xc1000000, 0xdd514201, 0x4550c000, 0xa95000f1,
+ 0xc00049a6, 0xca0000f8, 0xa94a0023, 0x00000000, 0x6e660000, 0x6e660010, 0x46612000, 0x840000b2,
+ 0x00000000, 0x6c508000, 0xc0004880, 0x40100000, 0x58000004, 0xc90000f8, 0x00000000, 0x00000000,
+ 0x59100002, 0xcd0000f8, 0x6c508000, 0xc0004880, 0x40100000, 0x58000006, 0xc90000f8, 0x00000000,
+ 0x00000000, 0x41148000, 0xcd0000f8, 0x80000720, 0x00000000, 0xa95203c1, 0xc0001004, 0xcb8000f8,
+ 0xc3400000, 0xdd740039, 0x5f740000, 0x840000d0, 0xc1218e08, 0x5911baf6, 0x45388000, 0x84000372,
+ 0x00000000, 0x6c508000, 0xc0004880, 0x40100000, 0x58000008, 0xc90000f8, 0x00000000, 0x00000000,
+ 0x59100002, 0xcd0000f8, 0x6c508000, 0xc0004880, 0x40100000, 0x5800000a, 0xc90000f8, 0x00000000,
+ 0x00000000, 0x41148000, 0xcd0000f8, 0x80000620, 0x00000000, 0xc000496c, 0xcb0000f8, 0x583c0026,
+ 0xcac000f8, 0xc0004878, 0xc80400f8, 0x6c908000, 0x41088000, 0x40100000, 0x58000002, 0xca8000f8,
+ 0x00000000, 0x00000000, 0x6ea90000, 0x5d300008, 0x8800004a, 0x59300002, 0xc3000000, 0xc5300008,
+ 0x6d104010, 0x40100000, 0xca8000f8, 0x5c000002, 0xcac000f8, 0x5d300000, 0x8400003a, 0x6f246000,
+ 0x6ae56000, 0xc1000040, 0x45252000, 0x6aa54010, 0x42e96000, 0x583c0026, 0xcec000f8, 0xc1218e08,
+ 0x5911baf6, 0xc0001004, 0xcd0000f8, 0x593c0026, 0xc000100e, 0xcd000060, 0xc1340000, 0xc0001010,
+ 0xcd035a00, 0xc1200008, 0xa94a0023, 0xc0001012, 0xc1200004, 0x59100004, 0xcd0000b8, 0xc1360002,
+ 0xcd037b00, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xa8e2ffe8, 0x00000000,
+ 0xc1220002, 0xd90c00f8, 0xc0001004, 0xc90000f8, 0x00000000, 0x00000000, 0x45388000, 0x840000b2,
+ 0x00000000, 0x6c508000, 0xc0004880, 0x40100000, 0x58000008, 0xc90000f8, 0x00000000, 0x00000000,
+ 0x59100002, 0xcd0000f8, 0x6c508000, 0xc0004880, 0x40100000, 0x5800000a, 0xc90000f8, 0x00000000,
+ 0x00000000, 0x41148000, 0xcd0000f8, 0x80000360, 0x00000000, 0x6c508000, 0xc0004880, 0x40100000,
+ 0x58000000, 0xc90000f8, 0x00000000, 0x00000000, 0x59100002, 0xcd0000f8, 0x6c508000, 0xc0004880,
+ 0x40100000, 0x58000002, 0xc90000f8, 0x00000000, 0x00000000, 0x41148000, 0xcd0000f8, 0xc0004930,
+ 0xcd800078, 0xc3000000, 0x583c0008, 0xcf0000f8, 0x80000038, 0xc0001004, 0xca0000f8, 0x583c0006,
+ 0xce4000f8, 0x583c0024, 0xce0000f8, 0xc0004862, 0xc2000000, 0xca000078, 0xc000493a, 0xca4000f8,
+ 0x00000000, 0x00000000, 0x42254000, 0x5ee80200, 0x88000012, 0xc6e800f8, 0xc0004000, 0x58001600,
+ 0x40280000, 0xcb8000f8, 0x00000000, 0x583c0022, 0xcf8000f8, 0xc0004862, 0xce800078, 0xc0001406,
+ 0xcac000f8, 0xc2800002, 0x00000000, 0xc66c1048, 0xc6ac0a00, 0xcec000f8, 0xc2000000, 0xdf600038,
+ 0x5e600080, 0x8400ffea, 0xc000491c, 0xca4000f8, 0xc000491e, 0xca8000f8, 0x990068d8, 0xda5800f8,
+ 0xda9800f9, 0x00000000, 0xc0004964, 0xcbc000f8, 0x00000000, 0x00000000, 0x5ffc0000, 0x84000102,
+ 0xc2000000, 0xdf610048, 0x5e6001fe, 0x8800ffe8, 0xc000491a, 0xc98000f8, 0xc0004862, 0xc94000f8,
+ 0x6d9c6000, 0x45d8e000, 0x59dc4c80, 0x99006738, 0xd95800f8, 0xd99800f9, 0xd9d400f8, 0x990066b0,
+ 0xc000491c, 0xc1400000, 0xc9420048, 0xc2000000, 0xdf600038, 0x5e600080, 0x8400ffea, 0xc000491c,
+ 0xca4000f8, 0xc000491e, 0xca8000f8, 0x990068d8, 0xda5800f8, 0xda9800f9, 0x00000000, 0xc0004970,
+ 0xcb4000f8, 0x00000000, 0x00000000, 0x5e740082, 0x8400e6d8, 0x00000000, 0x8000c018, 0x00000000,
+ 0x6c508000, 0xc0004880, 0x40100000, 0x58000016, 0xc90000f8, 0x00000000, 0x00000000, 0x59100002,
+ 0xcd0000f8, 0x8000e308, 0x6c6c8000, 0x6c544000, 0x42d56000, 0x5aec4a00, 0xc000487c, 0xc80400f8,
+ 0x00000000, 0x00000000, 0x40080000, 0xca0000f8, 0xc42400f8, 0x00000000, 0xa60600f8, 0xc3c00000,
+ 0xc2000000, 0x582c000c, 0xca010038, 0x00000000, 0x00000000, 0x5a200002, 0xc6100838, 0xcd010838,
+ 0x5e60000e, 0x8400bf00, 0xc2200000, 0x582c0002, 0xce021008, 0x582c000c, 0xcfc10838, 0x582c0020,
+ 0xcfc21078, 0x582c0010, 0xc1400000, 0xcd4000f9, 0xcd4000f9, 0xcd4000f9, 0xcd4000f9, 0xcd4000f9,
+ 0xcd4000f9, 0xcd4000f9, 0xcd4000f9, 0xcd400018, 0x8000be68, 0xc2200004, 0x582c0002, 0xce021008,
+ 0x582c000c, 0xcfc10838, 0x99007000, 0x582c0002, 0xc94000f8, 0xc1a20000, 0x8000be18, 0xc3e1fffe,
+ 0x597dfffe, 0x593dfef4, 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0xc0800000, 0xdf4b0038,
+ 0xc0004900, 0xcb8000f8, 0xc2000000, 0xc000490a, 0xa78000d0, 0xcbc000f8, 0xc1000000, 0xd90000f9,
+ 0xc1000002, 0xd90c00f8, 0x6ff46000, 0x477da000, 0x5b744c80, 0xc2400000, 0x58340004, 0xca400078,
+ 0xc0004900, 0xce000000, 0x5a640002, 0x58340004, 0xc6500078, 0xcd000078, 0xc0004914, 0xca4000f8,
+ 0xc2000002, 0x6a3d0000, 0x72612000, 0xce4000f8, 0xc0000408, 0xce0000f8, 0xa78200c8, 0xc0004908,
+ 0xcbc000f8, 0xc1000000, 0xd90000f9, 0xc1000002, 0xd90c00f8, 0x6ff4a000, 0x477da000, 0x5b744e20,
+ 0xc2800000, 0x58340006, 0xca800078, 0xc2000000, 0xc0004900, 0xce002100, 0x5ea80002, 0x58340006,
+ 0xc6900078, 0xcd000078, 0x5a7c0020, 0xc2000002, 0x6a250000, 0xc0000408, 0xce0000f8, 0xdca800f9,
+ 0x5ea80000, 0x8400a860, 0x00000000, 0xa4800230, 0x00000000, 0xc3c00000, 0xc000140e, 0xcbc00018,
+ 0xc3400000, 0xc2400000, 0x6ff86000, 0x47bdc000, 0x5bb84c80, 0x58380008, 0xcb400078, 0x58380006,
+ 0xca400078, 0x5f740002, 0x58380008, 0xc7500078, 0xcd000078, 0xc2000000, 0x58380004, 0xca020078,
+ 0xc3000000, 0x5838000c, 0xcb000020, 0x5a640002, 0x46610000, 0x84000010, 0xc2400000, 0x58380006,
+ 0xc6500078, 0xcd000078, 0xc2000000, 0x5838000a, 0xca020078, 0x5b300002, 0x5838000c, 0xc7100020,
+ 0xcd000020, 0xc2420020, 0x5a200004, 0x46252000, 0x84000010, 0xc2000000, 0x5838000a, 0xc6101078,
+ 0xcd021078, 0xc000498c, 0xca4000f8, 0xc2000002, 0x6a3d0000, 0x72612000, 0xce4000f8, 0x5f740000,
+ 0x84000040, 0xc0004912, 0xca0000f8, 0xc2c00002, 0x6afd6000, 0x7ec16000, 0x762d0000, 0xce0000f8,
+ 0x5f300020, 0x84000040, 0xc0004924, 0xca0000f8, 0xc2c00002, 0x6afd6000, 0x7ec16000, 0x762d0000,
+ 0xce0000f8, 0xa4820070, 0xc2400000, 0xc000140e, 0xca408018, 0xc2000002, 0xc0004900, 0xce000000,
+ 0xc000490a, 0xce4000f8, 0xc1000000, 0xd90000f9, 0xd8400078, 0xc1000004, 0xd90000f9, 0xa48402d8,
+ 0x00000000, 0xc3c00000, 0xc000140e, 0xcbc10018, 0xc2800000, 0xc2000000, 0x6ff8a000, 0x47bdc000,
+ 0x5bb84e20, 0x58380036, 0xca800078, 0x58380006, 0xca020078, 0xc3400000, 0x58380036, 0xcb420078,
+ 0x5aa80002, 0x46a10000, 0x84000010, 0xc2800000, 0x58380036, 0xc6900078, 0xcd000078, 0x5f740002,
+ 0x58380036, 0xc7501078, 0xcd021078, 0xc000498e, 0xca4000f8, 0xc2000002, 0x6a3d0000, 0x72612000,
+ 0xce4000f8, 0xc000492a, 0xca8000f8, 0x5e740000, 0x84000040, 0xc0004910, 0xca0000f8, 0xc2c00002,
+ 0x6afd6000, 0x7ec16000, 0x762d0000, 0xce0000f8, 0x6abd4010, 0xa6800132, 0x00000000, 0x5838003a,
+ 0xca0000f8, 0x58000002, 0xca4000f8, 0x5838000e, 0x00000000, 0xce0000f9, 0xce4000f8, 0xc2400000,
+ 0xdd250038, 0xc1000080, 0x45248000, 0xc2400000, 0xc6240078, 0x46510000, 0x00000000, 0xc52400fc,
+ 0x5d240078, 0xc1000078, 0xc52400fc, 0xc6600078, 0x5c000002, 0xce000078, 0xc000492a, 0xca0000f8,
+ 0xc2c00002, 0x6afd6000, 0x722d0000, 0xce0000f8, 0xc000492c, 0xca0000f8, 0xc2c00002, 0x6afd6000,
+ 0x722d0000, 0xce0000f8, 0x80000040, 0xc000492c, 0xca0000f8, 0xc2c00002, 0x6afd6000, 0x7ec16000,
+ 0x762d0000, 0xce0000f8, 0xa4880088, 0xc2c00000, 0xc000140e, 0xcac20018, 0xc000490e, 0xca4000f8,
+ 0xc2000002, 0x6a2d0000, 0x7e010000, 0x76612000, 0xce4000f8, 0xc0004990, 0xca4000f8, 0xc2000002,
+ 0x6a2d0000, 0x72612000, 0xce4000f8, 0xa4860070, 0xc2400000, 0xc000140e, 0xca418018, 0xc2020002,
+ 0xc0004900, 0xce002100, 0xc0004908, 0xce4000f8, 0xc1000000, 0xd90000f9, 0xd8400078, 0xc1000004,
+ 0xd90000f9, 0xa48c00e8, 0xc2400000, 0xc000140e, 0xca430018, 0x00000000, 0x00000000, 0x5d240002,
+ 0x84000058, 0xc00048c4, 0xca0000f8, 0xc00048c6, 0xc1040002, 0x72110000, 0xce0000f8, 0xc1000002,
+ 0xc00048cc, 0xcd000000, 0x80000060, 0x5d240004, 0x84000050, 0xc00048c8, 0xca0000f8, 0xc00048ca,
+ 0xc1160002, 0x72110000, 0xce0000f8, 0xc1020002, 0xc00048cc, 0xcd002100, 0xc0001408, 0xcc8000f8,
+ 0xc10e0002, 0xd90c00f8, 0x8000f668, 0xdfbc00f9, 0xc0004992, 0x99007040, 0xc94000f8, 0xc7d800f8,
+ 0x00000000, 0xc57000f8, 0x5ef00020, 0x88000158, 0x6f346000, 0x4771a000, 0x5b744c80, 0x58340008,
+ 0xc2400000, 0xca400078, 0x00000000, 0xc2000000, 0x5a640002, 0xc6500078, 0xcd000078, 0x58340004,
+ 0xca000078, 0x00000000, 0x00000000, 0x5e200002, 0xc6100078, 0xcd000078, 0xc0004912, 0xca8000f8,
+ 0xc2400002, 0x6a712000, 0x72a54000, 0xce8000f8, 0x5e200000, 0x84000052, 0xc000480a, 0xca0000f8,
+ 0xc0000408, 0xca8000f8, 0x76250000, 0x00000000, 0x72a14000, 0xce8000f8, 0x80000038, 0xc0004914,
+ 0xca0000f8, 0x7e412000, 0x00000000, 0x76250000, 0xce0000f8, 0x800000c8, 0x6ef4a000, 0x476da000,
+ 0x5b744e20, 0x58340036, 0xc2400000, 0xca420078, 0x00000000, 0xc2000000, 0x5a640002, 0xc6501078,
+ 0xcd021078, 0x58340006, 0xca000078, 0x00000000, 0x00000000, 0x5a200002, 0xc6100078, 0xcd000078,
+ 0xc0004910, 0xca4000f8, 0xc2000002, 0x6a2d0000, 0x72612000, 0xce4000f8, 0xc2000002, 0x6a310000,
+ 0xc000042a, 0xce0000f8, 0xc1040002, 0xd90c00f8, 0x00000000, 0x8000f3d0, 0x00000000, 0xc4980928,
+ 0x9d000000, 0xc5580028, 0xc0000838, 0xcd8400f8, 0xc1440200, 0xc1c01600, 0xc55c1070, 0xc000100e,
+ 0x9d000000, 0xcd8000f8, 0xc000100c, 0xcdc000f8, 0xc0004862, 0xc9c000f8, 0x00000000, 0x00000000,
+ 0xd9d800f9, 0xc0005600, 0x401c0000, 0x5dc05800, 0x88000012, 0x5c000200, 0xcd8000f8, 0xc1f0000a,
+ 0x715ca000, 0xdd9800f8, 0xdd9c00f9, 0x41d8e000, 0xc5d40260, 0xc0001010, 0xcd4000f8, 0x6c9c8000,
+ 0x45c8e000, 0x45c8e000, 0x59dc0004, 0xc1601260, 0xc5d40260, 0x9d000000, 0xc0001012, 0xcd4000f8,
+ 0x00000000, 0x00000000, 0xd95800f8, 0x6d586000, 0x4594c000, 0x59984c80, 0xd99800f9, 0x5818000a,
+ 0xc1800000, 0xc9800078, 0xc0005400, 0x6d5ca000, 0x401c0000, 0x40180000, 0xc94000f8, 0x58000002,
+ 0x00000000, 0xc9c000f8, 0xc0004930, 0xcd4000f8, 0xc0004932, 0xcdc000f8, 0x59980004, 0xc1c20020,
+ 0xb59c0018, 0x00000000, 0xc1800000, 0xdd9c00f9, 0x581c000a, 0xcd800078, 0x581c000c, 0xc1800000,
+ 0xc9800020, 0xc1c00002, 0xdd9400f8, 0x69d4e000, 0x5d980002, 0xcd800020, 0xc0004924, 0xc98000f8,
+ 0x00000000, 0x9d000000, 0x00000000, 0x719cc000, 0xcd8000f8, 0xc000492a, 0xc94000f8, 0xc1c00002,
+ 0x69d8e000, 0x7dc0c000, 0x7558a000, 0xcd4000f8, 0xc000492c, 0xc94000f8, 0xdd8000f9, 0x5800003a,
+ 0x755ca000, 0x84000108, 0xc94000f9, 0xc98000f8, 0xdd8000f9, 0x5800000e, 0x00000000, 0xcd4000f9,
+ 0xcd8000f8, 0xc1800000, 0xdd190038, 0xc1000080, 0x45188000, 0xc1800000, 0xc5580078, 0x4590a000,
+ 0x00000000, 0xc51800fc, 0x5d180078, 0xc1000078, 0xc51800fc, 0xc5940078, 0x5c000002, 0xcd400078,
+ 0xc000492c, 0xc94000f8, 0xc000492a, 0xc98000f8, 0x715ca000, 0xc000492c, 0xcd4000f8, 0x719cc000,
+ 0xc000492a, 0xcd8000f8, 0x9cc00000, 0x00000000, 0x00000000, 0x00000000, 0xc0004862, 0xc98000f8,
+ 0x00000000, 0xc1c00200, 0x4194c000, 0x459ce000, 0x88000012, 0xc5d800f8, 0xc0004862, 0xcd8000f8,
+ 0xc0001406, 0xc98000f8, 0xc1c00002, 0x9d000000, 0xc5d80a00, 0xc5581048, 0xcd8000f8, 0xc0004930,
+ 0xc98000f8, 0xc0004932, 0xc9c000f8, 0xc140000e, 0xc5581c18, 0xdd9400f8, 0xc0005600, 0x40140000,
+ 0x5d405800, 0x88000012, 0x5c000200, 0xcd8000f8, 0x58000002, 0x5d405800, 0x88000012, 0x5c000200,
+ 0xcdc000f8, 0xdd5400f8, 0xc1c00000, 0x58140006, 0xc9c20078, 0xc1800000, 0x58140000, 0xc98000d8,
+ 0x6ddc2000, 0xc000491e, 0x41d8e000, 0xcdc000f8, 0xdd9800f8, 0xc1c00022, 0xc5d80d70, 0xdd9400f9,
+ 0xc5581c18, 0xc000491c, 0xcd8000f8, 0xdd5400f8, 0xc1c00000, 0x58140006, 0xc9c20078, 0xc1800000,
+ 0x58140004, 0xc9820078, 0x00000000, 0x59dc0002, 0x45d8c000, 0x84000010, 0xc1c00000, 0x9d000000,
+ 0x58140006, 0xc5d81078, 0xcd821078, 0xc0004860, 0xc94000f8, 0xc1820080, 0xc1d00002, 0x58146b00,
+ 0xd58000f8, 0x58000002, 0xd58000f9, 0x59540004, 0xb5580018, 0xc0004860, 0xc1400000, 0xcd4000f8,
+ 0xdd9800f9, 0x9d000000, 0xdd9400f8, 0xc0001404, 0xcdc10800, 0xc1c00000, 0xc1800200, 0x5d980004,
+ 0xdf5d0048, 0x459ca000, 0x8800fff2, 0xdd8000f9, 0x5800000e, 0x00000000, 0xc94000f9, 0xc98000f8,
+ 0xc1c00002, 0xc5d43f00, 0xc5d81e00, 0xc0004862, 0xc9c000f8, 0x00000000, 0x00000000, 0x581c5600,
+ 0x5dc05800, 0x88000012, 0x5c000200, 0xcd4000f8, 0x58000002, 0x5dc05800, 0x88000012, 0x5c000200,
+ 0xcd8000f8, 0xc0004862, 0xc9c000f8, 0x00000000, 0xc15004c0, 0xc5d40060, 0xdd9c00f8, 0xc5d41c18,
+ 0xc1c00000, 0xdd8000f9, 0x58000038, 0xc9c00078, 0xdd8000f9, 0xc1800000, 0x58000002, 0xc98000d8,
+ 0x6ddc2000, 0xc000491c, 0x41d8e000, 0xcd4000f9, 0xcdc000f8, 0xdd9400f9, 0xc1c00000, 0x58140038,
+ 0xc9c00078, 0xc1800000, 0x58140006, 0xc9820078, 0x00000000, 0x59dc0002, 0x45d8c000, 0x84000010,
+ 0xc1c00000, 0x9d000000, 0x58140038, 0xc5d80078, 0xcd800078, 0xc1c00000, 0xdf5c0038, 0x5ddc0080,
+ 0x8400ffea, 0x00000000, 0x9d000000, 0x00000000, 0x00000000, 0x00000000, 0xc160fffe, 0xc0000a10,
+ 0xc9440060, 0xc1a0fffe, 0x59980e28, 0xc000100c, 0xcd4000f8, 0xc000100e, 0xcd8000f8, 0xc0004962,
+ 0xc98000f8, 0x00000000, 0xc170000a, 0x7158a000, 0x6c988000, 0x4588c000, 0x4588c000, 0x59980004,
+ 0xc5940270, 0xc0001010, 0xcd4000f8, 0xc0004946, 0xc94000f8, 0x00000000, 0x00000000, 0x6d58a000,
+ 0x6d5c4000, 0x459cc000, 0x4594c000, 0xc000494a, 0xc94000f8, 0xc0004948, 0xc9c000f8, 0x4194c000,
+ 0xc1400012, 0xc55c1818, 0x9d000000, 0xc59c0268, 0xc0001012, 0xcdc000f8, 0xc1400000, 0x58000014,
+ 0xc9410038, 0xc0004950, 0xc9c000f8, 0xc55800f8, 0xc5940838, 0xc5581078, 0xd99400f8, 0xc000493c,
+ 0xc94000f8, 0xc0004954, 0xc98000f8, 0x59dc00a8, 0x45d4e000, 0x41d8e000, 0x5d5c0030, 0x88000010,
+ 0xc1c00030, 0xc1800000, 0xc5d84028, 0xc1400000, 0xc5d40008, 0x5dd40002, 0x84000072, 0x5dd40004,
+ 0x8400009a, 0x5dd40006, 0x840000c2, 0x5dd80026, 0x840000ea, 0xdd5400f8, 0xdd8000f9, 0x58000008,
+ 0x40180000, 0xcd4000f8, 0x59980002, 0x8000ffc0, 0xdd5400f8, 0xdd8000f9, 0x58000008, 0x40180000,
+ 0xcd4000b8, 0x59980002, 0x8000ff88, 0xdd5400f8, 0xdd8000f9, 0x58000008, 0x40180000, 0xcd400078,
+ 0x59980002, 0x8000ff50, 0xdd5400f8, 0xdd8000f9, 0x58000008, 0x40180000, 0xcd400038, 0x59980002,
+ 0x8000ff18, 0x00000000, 0x9d000000, 0x00000000, 0x00000000, 0x00000000, 0x58000014, 0xc94000f8,
+ 0xc0004954, 0xc9c000f8, 0xc0004950, 0xc9400078, 0xdd8000f9, 0x5800002a, 0x5d9c0000, 0x84000052,
+ 0x5d9c0002, 0x84000052, 0x5d9c0004, 0x8400006a, 0xc55b0038, 0xc55c08b8, 0xcd800039, 0xcdc108b8,
+ 0x80000060, 0xcd4000f8, 0x80000050, 0xc55900b8, 0xc55c1838, 0xcd8000b9, 0xcdc31838, 0x80000028,
+ 0xc55a0078, 0xc55c1078, 0xcd800079, 0xcdc21078, 0x9d000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xc1e00000, 0xa540001a, 0xc0000a14, 0xc1a20002, 0x9d000000, 0xcd863100, 0xc0000a1c, 0xcdc61038,
+ 0x59540002, 0x6994e018, 0x61c0c008, 0x4194a000, 0x5d940040, 0x88000012, 0xc59400f8, 0x9d000000,
+ 0xcd4000f8, 0x00000000, 0x00000000,
+};
+
+static unsigned int firmware_binary_data[] = {
+};
+
+
+#endif // IFXMIPS_PTM_FW_AMAZON_SE_H
diff --git a/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_fw_ar9.h.svn-base b/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_fw_ar9.h.svn-base
new file mode 100644
index 0000000..a61d313
--- /dev/null
+++ b/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_fw_ar9.h.svn-base
@@ -0,0 +1,473 @@
+#ifndef IFXMIPS_PTM_FW_AR9_H
+#define IFXMIPS_PTM_FW_AR9_H
+
+
+/******************************************************************************
+**
+** FILE NAME : ifxmips_ptm_fw_ar9.h
+** PROJECT : UEIP
+** MODULES : PTM (ADSL)
+**
+** DATE : 22 OCT 2007
+** AUTHOR : Xu Liang
+** DESCRIPTION : PTM Driver (PP32 Firmware)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 22 OCT 2007 Xu Liang Initiate Version, v00.01
+*******************************************************************************/
+
+
+#define PTM_FW_VER_MAJOR 0
+#define PTM_FW_VER_MINOR 17
+
+
+static unsigned int firmware_binary_code[] = {
+ 0x800004b8, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8000ffe0, 0x00000000, 0x00000000, 0x00000000,
+ 0xc1000002, 0xd90c00f8, 0xc2000002, 0xda0800f9, 0x80005270, 0xc2000000, 0xda0800f9, 0x80005210,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x80005a00, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xc10e0002, 0xd90c00f8, 0xc0004808, 0xc84000f8, 0x80004ee0, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xc3e1fffe, 0x597dfffe, 0x593dfef4, 0x900004d9, 0x00000000, 0x00000000, 0x00000000, 0x90cc0481,
+ 0x00000000, 0x00000000, 0x00000000, 0xc3e0a262, 0x5bfc0022, 0xc0004002, 0xcfc000f8, 0xc0004810,
+ 0xcbc000f8, 0x00000000, 0xc3800000, 0xc7f80038, 0x5fb80000, 0xc7fa0038, 0xc7bfe802, 0x5fb80000,
+ 0x00000000, 0xc7bff802, 0xdbd400f9, 0xc00049a0, 0xc3800002, 0xa7ca006a, 0xc1200000, 0x5911fffe,
+ 0xcd0000f9, 0xc1200000, 0x59102042, 0xcd0000f9, 0xc1000004, 0xcd0000f9, 0xc1200000, 0x59103a1e,
+ 0xcd0000f9, 0x80000060, 0xc121fffe, 0x5911fffe, 0xcd0000f9, 0xc1203db8, 0x5910de82, 0xcd0000f9,
+ 0xc1000006, 0xcd0000f9, 0xc120385a, 0x591033da, 0xcd0000f9, 0x5fb80002, 0x8800001a, 0x6ffe0010,
+ 0x8000ff28, 0xdd7c00f9, 0xc3800000, 0xc7f86010, 0x5bb80008, 0xc3540002, 0x777da000, 0xc1000008,
+ 0x4791c002, 0xcf8000f9, 0xdb900038, 0xc3800008, 0xc3720002, 0x777da000, 0xa7f00028, 0x47b9c002,
+ 0xc1000000, 0xc7d26010, 0x4391c000, 0xcf8000f8, 0xdb900838, 0xc3c00000, 0xdbc800f9, 0xc0400000,
+ 0xc11c0000, 0xc000082c, 0xcd05ce00, 0xc11c0002, 0xc000082c, 0xcd05ce00, 0xc0400002, 0xc11c0000,
+ 0xc000082c, 0xcd05ce00, 0xc11c0002, 0xc000082c, 0xcd05ce00, 0xc0000824, 0x00000000, 0xcbc000f9,
+ 0xcb8000f9, 0xcb4000f9, 0xcb0000f8, 0xc0004878, 0x5bfc4000, 0xcfc000f9, 0x5bb84000, 0xcf8000f9,
+ 0x5b744000, 0xcf4000f9, 0x5b304000, 0xcf0000f8, 0xc0000a10, 0x00000000, 0xcbc000f9, 0xcb8000f8,
+ 0xc0004874, 0x5bfc4000, 0xcfc000f9, 0x5bb84000, 0xcf8000f8, 0xc30001fe, 0xc000140a, 0xcf0000f8,
+ 0xc3000000, 0x7f018000, 0xc000042e, 0xcf0000f8, 0xc000040e, 0xcf0000f8, 0xc3c1fffe, 0xc000490e,
+ 0xcfc00078, 0xc000492c, 0xcfc00078, 0xc0004924, 0xcfc00038, 0xc0004912, 0xcfc00038, 0xc000498c,
+ 0xcfc00038, 0xc000498e, 0xcfc00078, 0xc0004990, 0xcfc00078, 0xc3c00000, 0xc2800004, 0xc3000000,
+ 0x7f018000, 0x6ff88000, 0x6fd44000, 0x4395c000, 0x5bb87e00, 0xc00049a0, 0xcb0000f8, 0x00000000,
+ 0x58380006, 0xcf0000f8, 0xc321fffe, 0x5b31fffe, 0x58380024, 0xcf0000f8, 0x5bfc0002, 0xb7e8ff90,
+ 0x00000000, 0xc3c00000, 0xc2800010, 0x6ff86000, 0x47bdc000, 0x5bb84c80, 0xc3400000, 0x58380004,
+ 0xcb420078, 0x00000000, 0x58380008, 0xcf400078, 0x5bfc0002, 0xb7e8ffb0, 0x00000000, 0xc3c00000,
+ 0xc2800004, 0xc3400022, 0xc3000000, 0x7f018000, 0xc2c00016, 0x6ff8a000, 0x47bdc000, 0x5bb87600,
+ 0x58380008, 0xcf400038, 0xc00049a8, 0xcb0000f8, 0x00000000, 0x5838000a, 0xcf0000f8, 0xc321fffe,
+ 0x5b31fffe, 0x5838000c, 0xcf0000f8, 0x58380034, 0xcec00038, 0x5bfc0002, 0xb7e8ff78, 0x00000000,
+ 0x00000000, 0xc0004840, 0xc3e12624, 0x5bfc2320, 0xcfc000f9, 0xc3e02f2c, 0x5bfd2a28, 0xcfc000f9,
+ 0xc3e03734, 0x5bfd3230, 0xcfc000f9, 0xc3e13e3c, 0x5bfc3b38, 0xcfc000f9, 0xc3e14644, 0x5bfc4340,
+ 0xcfc000f9, 0xc3e04f4c, 0x5bfd4a48, 0xcfc000f9, 0xc3e05754, 0x5bfd5250, 0xcfc000f9, 0xc3e15e5c,
+ 0x5bfc5b58, 0xcfc000f9, 0xc3e06764, 0x5bfd6260, 0xcfc000f9, 0xc3e16e6c, 0x5bfc6b68, 0xcfc000f9,
+ 0xc3e17674, 0x5bfc7370, 0xcfc000f9, 0xc3e07f7c, 0x5bfd7a78, 0xcfc000f9, 0xc3e18684, 0x5bfc8380,
+ 0xcfc000f9, 0xc3e08f8c, 0x5bfd8a88, 0xcfc000f9, 0xc3e09794, 0x5bfd9290, 0xcfc000f9, 0xc3e19e9c,
+ 0x5bfc9b98, 0xcfc000f9, 0xc121fffe, 0x5911fef4, 0x14100000, 0x80000028, 0x00000000, 0x800004e8,
+ 0x00000000, 0x8000ffe0, 0xc0004918, 0xd28000f8, 0xc2000000, 0xdf600038, 0x5e600080, 0x840002b2,
+ 0x00000000, 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0xc000480a, 0xca0000f8, 0xc0004912, 0xca4000f8, 0xc0004924, 0xca8000f8,
+ 0xc000498c, 0xcac000f8, 0xc121fffe, 0x5911fef4, 0x14100000, 0x76250000, 0x76290000, 0x762d0000,
+ 0x840001ea, 0xc0004918, 0xca4000f8, 0xc28001fe, 0x76290000, 0x5a640002, 0x6a254010, 0x5ee80000,
+ 0x8400001a, 0x6aa54000, 0x80000010, 0xc62800f8, 0x62818008, 0xc0004918, 0xcf0000f8, 0xc161fffe,
+ 0x5955fffe, 0x14140000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xc000498c, 0xca4000f8, 0xc2000002, 0x6a310000, 0x7e010000, 0x76612000, 0xce4000f8, 0xc121fffe,
+ 0x5911fef4, 0x14100000, 0x6f346000, 0x4771a000, 0x5b744c80, 0xc2800000, 0x58340006, 0xca800078,
+ 0xc2c00000, 0x58340000, 0xcac000d8, 0xc2400000, 0x5834000a, 0xca420078, 0x6ea82000, 0x42e9e000,
+ 0x6f2ca000, 0x42e56000, 0x5aec3680, 0xc3990040, 0xc7381c18, 0xc6f80060, 0x99006480, 0xdb9800f8,
+ 0xdbd800f9, 0x00000000, 0xdea000f8, 0x46310000, 0x8400fd40, 0xc000495a, 0xc84000f8, 0x00000000,
+ 0xc3c00002, 0x787c2000, 0xcc4000f8, 0xc0000838, 0xc3800000, 0xcb840028, 0x6c748000, 0x6c544000,
+ 0x4355a000, 0x5b747e00, 0x5ef80000, 0x8400fca2, 0x58340004, 0xcb0000f8, 0x00000000, 0x00000000,
+ 0xa7060020, 0x00000000, 0x5ef80002, 0x8400fc62, 0x5834000c, 0xc8800038, 0xc2000000, 0xc000082c,
+ 0xca040028, 0x5a880002, 0xc2400000, 0xc0004958, 0xce4000f8, 0xb6280018, 0x00000000, 0xc2800000,
+ 0x58340002, 0xc2000000, 0xca020008, 0xc0004956, 0xce8000f8, 0x5e600000, 0x84001ca2, 0x5e600002,
+ 0x84004062, 0x00000000, 0x800021d0, 0xc0004958, 0xca0000f8, 0xc0004956, 0xca8000f8, 0x5e200000,
+ 0x84000020, 0xc2500002, 0xc0000838, 0xce450800, 0x6c748000, 0x6c544000, 0x4355a000, 0x5b747e00,
+ 0x5834000c, 0xc6900038, 0xcd000038, 0x8000fb38, 0xc2000000, 0xdf600038, 0x5e200080, 0x8400028a,
+ 0x00000000, 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0xc000480c, 0xca0000f8, 0xc0004910, 0xca4000f8, 0xc000492c, 0xca8000f8,
+ 0xc000498e, 0xcac000f8, 0xc121fffe, 0x5911fef4, 0x14100000, 0x76250000, 0x76290000, 0x76e16000,
+ 0x840001c2, 0xc0004926, 0xca4000f8, 0xc201fffe, 0x76e16000, 0x5a640002, 0x6ae50010, 0x5f200000,
+ 0x8400001a, 0x6a250000, 0x80000010, 0xc6e000f8, 0x62014008, 0xc0004926, 0xce8000f8, 0xc161fffe,
+ 0x5955fffe, 0x14140000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xc000498e, 0xca4000f8, 0xc2000002, 0x6a290000, 0x7e010000, 0x76612000, 0xce4000f8, 0xc121fffe,
+ 0x5911fef4, 0x14100000, 0x6eb4a000, 0x4769a000, 0x5b747600, 0x58340002, 0xc2000000, 0xca0000d8,
+ 0x58340036, 0xc2400000, 0xca400078, 0x6eb0a000, 0x47298000, 0x5b303636, 0x5b300004, 0x6e642000,
+ 0x4225e000, 0xc39a8024, 0xc7380060, 0xc6b81c18, 0x99006480, 0xdb9800f8, 0xdbd800f9, 0x00000000,
+ 0xc2000000, 0xdf600038, 0x5e200080, 0x840002da, 0x00000000, 0xc161fffe, 0x5955fffe, 0x14140000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xc000490e, 0xca0000f8,
+ 0xc000492a, 0xca4000f8, 0xc0004990, 0xcb0000f8, 0xc000498a, 0xcac000f8, 0xc121fffe, 0x5911fef4,
+ 0x14100000, 0x77218000, 0x77258000, 0x8400021a, 0xc201fffe, 0x77218000, 0x5aec0002, 0x6b2d0010,
+ 0x5ea00000, 0x8400001a, 0x6a2d0000, 0x80000010, 0xc72000f8, 0x62016008, 0xc000498a, 0xcec000f8,
+ 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0xc0004990, 0xca4000f8, 0xc2000002, 0x6a2d0000, 0x7e010000, 0x76612000, 0xce4000f8,
+ 0xc121fffe, 0x5911fef4, 0x14100000, 0x6ef4a000, 0x476da000, 0x5b747600, 0x58340010, 0xc2000000,
+ 0xca0000d8, 0x58340008, 0xc2400000, 0xca420078, 0x5834000e, 0xc2800000, 0xca832010, 0xc3c00000,
+ 0x47e48000, 0x6e644010, 0xc7e800fc, 0x42250000, 0x4229e000, 0xc39a8008, 0x58340008, 0xcb801038,
+ 0x58340008, 0xc2800000, 0xca810010, 0x6ee0a000, 0x462d0000, 0x5a20000a, 0x5a203608, 0x42290000,
+ 0xc6380060, 0xc6f81c18, 0x99006480, 0xdb9800f8, 0xdbd800f9, 0x00000000, 0xc000495c, 0xc84000f8,
+ 0xc3400000, 0xc3c00002, 0x787c2000, 0xcc4000f8, 0x6c78a000, 0x4785c000, 0x5bb87600, 0x58380034,
+ 0xcb410038, 0xc0000a28, 0xc3000000, 0xcb040028, 0xc0000a14, 0xc2c00000, 0x43358000, 0xcac40028,
+ 0xc000490e, 0xca8000f8, 0x5eec0002, 0x472d8000, 0x8800f4c8, 0x6bc5e000, 0x76bd4000, 0x8400f4b0,
+ 0x6c7ca000, 0x47c5e000, 0x5bfc7600, 0x583c0008, 0xc2000000, 0xca020078, 0xc00049aa, 0x00000000,
+ 0xca8000f9, 0xca4000f8, 0xc0001008, 0xce8000f8, 0xc0001006, 0xce4000f8, 0x583c000a, 0xca4000f8,
+ 0x00000000, 0xc000100a, 0xce4000f8, 0xc2400006, 0xc0001000, 0xce4000f8, 0xc2600982, 0x5a643b6e,
+ 0xc0001002, 0xce4000f8, 0x583c000c, 0xca4000f8, 0x00000000, 0xc0001004, 0xce4000f8, 0x583c000e,
+ 0xcb8000f8, 0x00000000, 0xc2400000, 0xc7a40078, 0xc2800000, 0xc7aae020, 0xdaa000f9, 0x583c0034,
+ 0xcb8000f8, 0x00000000, 0xc2c00000, 0xc7ad0038, 0xc0004978, 0xcec000f8, 0xc0800000, 0xc7880038,
+ 0xc3400000, 0xc7b60038, 0xc0004980, 0xcf4000f8, 0x4661c000, 0x43a9c000, 0xc2400000, 0xc000497c,
+ 0xce4000f8, 0xad2c0001, 0xc2800000, 0x00000000, 0x80000010, 0xc2800002, 0xc0004976, 0xce8000f8,
+ 0xc2c00000, 0xc34000a0, 0xdb5c00f9, 0xc3400002, 0xc000497a, 0xcf4000f8, 0x5f600000, 0x84000180,
+ 0xde2800f9, 0xc6a000f8, 0x47a9c000, 0x583c0000, 0xc2800000, 0xca830038, 0xc0000a28, 0xc3000000,
+ 0xcb040028, 0xc3400000, 0xc0004976, 0x46b18000, 0x8800006a, 0xcf4000f8, 0x58880002, 0xc3000000,
+ 0xc0000a14, 0xcb040028, 0x00000000, 0x00000000, 0xb4b001a8, 0x00000000, 0xc0800000, 0x00000000,
+ 0x80000188, 0xc0004980, 0xcb4000f8, 0x00000000, 0x00000000, 0x5af40002, 0xacec0080, 0x00000000,
+ 0xc2c00000, 0xc000497a, 0xadec0001, 0x00000000, 0x00000000, 0xad2c007f, 0xc2800000, 0xce8000f8,
+ 0x80000018, 0xc2800002, 0xce8000f8, 0x5f6c0000, 0x840000e8, 0x00000000, 0x8000ff00, 0x5f780082,
+ 0x88000258, 0xc3000002, 0xc000497c, 0xcf0000f8, 0xc2800080, 0xc1000000, 0xdd110038, 0x46914000,
+ 0x47a94000, 0x880001d8, 0x4391a000, 0xc0004980, 0xcf4000f8, 0x6f684010, 0x6f77c000, 0x6f77c010,
+ 0xc0004840, 0x40280000, 0xca8000f8, 0xc3000000, 0x6f506000, 0x6a908010, 0xc5300038, 0xdb1c00f9,
+ 0x8000fe30, 0xc3400000, 0xc0000a10, 0xcb440060, 0x6cb04000, 0x6f288000, 0x6f744000, 0x42b14000,
+ 0x43694000, 0xc3400000, 0xc6b44060, 0xc0004000, 0x40340000, 0xc321e000, 0xcf0000f8, 0x5aa80008,
+ 0x42ad4000, 0xc3400000, 0xc6b44060, 0xc0004000, 0x40340000, 0xca4000f8, 0xc3000000, 0xc6f00008,
+ 0xc1400000, 0xddd40039, 0x6f306000, 0xc13001fe, 0x69308010, 0x7d008000, 0x76512000, 0x6d570000,
+ 0x6970a010, 0x42552000, 0xce4000f8, 0x5aa80002, 0x5aec0002, 0xacec0080, 0x00000000, 0xc2c00000,
+ 0x5f6c0000, 0x84000118, 0x00000000, 0x80000040, 0x4391a000, 0x5f740080, 0xc0004980, 0xcf4000f8,
+ 0xc3000004, 0xc000497a, 0xcf0000f8, 0x58880002, 0xc3400000, 0xc0000a14, 0xcb440028, 0x00000000,
+ 0x00000000, 0xb4b40018, 0x00000000, 0xc0800000, 0xc3400000, 0xc0000a10, 0xcb440060, 0x6cb04000,
+ 0x6f248000, 0x6f744000, 0x42712000, 0x43654000, 0xc3400000, 0xc6b44060, 0xc0004000, 0x40340000,
+ 0xc3201e00, 0xcf0000f8, 0x5aa80008, 0x42ad4000, 0xc000100c, 0xcb4000f8, 0xc3000000, 0x00000000,
+ 0xc7340060, 0xc300fffe, 0xc7341070, 0xcf4000f8, 0xc000100e, 0xcb4000f8, 0xc3003608, 0x00000000,
+ 0xc7340060, 0xc300fffe, 0xc7341070, 0xcf4000f8, 0xc0001010, 0xcb4000f8, 0xc3000002, 0x00000000,
+ 0xc7341a00, 0xc7341800, 0xc3000000, 0xc7341900, 0xc6b40070, 0xcf4000f8, 0xc0004982, 0xce8000f8,
+ 0x6c64a000, 0x46452000, 0x5a64000a, 0xc0001012, 0xcb4000f8, 0xc2800002, 0x00000000, 0xc6740260,
+ 0xc6340008, 0xc000497c, 0xcb0000f8, 0xc6b41800, 0xc6b41b00, 0xc6b41c00, 0xc6b41d00, 0xc7341e00,
+ 0xdd6800f9, 0x7e814000, 0x6eab2010, 0x76b14000, 0xc6b41f00, 0xc2800000, 0xc6b41900, 0xc3000080,
+ 0x472d8000, 0xc0004982, 0xc90000f8, 0x47394000, 0x88000102, 0x41388000, 0xcd0000f8, 0xc7b41038,
+ 0xc0004994, 0xce8000f8, 0xde1000f9, 0x45208000, 0x840000b0, 0xc1000000, 0xdd110038, 0x41388000,
+ 0x412c8000, 0x5d100080, 0xc0004980, 0xcd0000f8, 0xc1000002, 0xc000497c, 0xcd0000f8, 0xc5341e00,
+ 0xdd5000f9, 0x7d008000, 0xc5373f00, 0xc000497a, 0xc90000f8, 0x42390000, 0x43adc000, 0x59100002,
+ 0xcd0000f8, 0x80000050, 0x42390000, 0x80000040, 0xc7341038, 0x41308000, 0xcd0000f8, 0x42310000,
+ 0xc1000000, 0xc0004994, 0xcd0000f8, 0xc0001012, 0xcf4000f8, 0xc000493c, 0xce0000f8, 0xc0004984,
+ 0xcf8000f8, 0xc000497a, 0xca4000f8, 0xc000497c, 0xca8000f8, 0x6c7ca000, 0x47c5e000, 0x5bfc7600,
+ 0xc0004976, 0xcac000f8, 0xc0004978, 0xca0000f8, 0x5eec0002, 0x8400008a, 0x42250000, 0xc2400000,
+ 0xc000497a, 0xce4000f8, 0x583c0000, 0xc2c00000, 0xcac30038, 0x00000000, 0x00000000, 0x46e16000,
+ 0x8800001a, 0x00000000, 0xad280002, 0xc000497a, 0xce0000f8, 0xc2000000, 0x5fa80000, 0x840001da,
+ 0x00000000, 0x6c508000, 0xc0004880, 0x40100000, 0x58000018, 0xc90000f8, 0x00000000, 0x00000000,
+ 0x59100002, 0xcd0000f8, 0x583c000e, 0xc2c00000, 0xcac00078, 0xc1000000, 0xdd532201, 0x42d16000,
+ 0x6c508000, 0xc0004880, 0x40100000, 0x5800001a, 0xc90000f8, 0x00000000, 0x00000000, 0x412c8000,
+ 0xcd0000f8, 0x99006510, 0xd85800f8, 0xdbd800f9, 0x00000000, 0x99006258, 0xc000491c, 0xc1400000,
+ 0xc9420048, 0xc000491c, 0x99006710, 0xc94000f9, 0xc98000f8, 0x00000000, 0x99006480, 0xd95800f8,
+ 0xd99800f9, 0x00000000, 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x98c060d0, 0xd85800f8, 0xdbd800f9, 0xc45800f8, 0xc121fffe,
+ 0x5911fef4, 0x14100000, 0xade80003, 0xc000493c, 0xcb4000f8, 0x00000000, 0xc3000000, 0xc7701078,
+ 0x80000010, 0xc3000000, 0x583c0008, 0xcf021078, 0x6e210000, 0x583c0034, 0xce010838, 0xc0004980,
+ 0xcb8000f8, 0x583c0034, 0x00000000, 0x6fba0000, 0xcf821038, 0xc000490e, 0xca0000f8, 0xc2c00002,
+ 0x6ac56000, 0x722d0000, 0xce0000f8, 0x00000000, 0x00000000, 0x00000000, 0xa8e2ffe8, 0x00000000,
+ 0xc1220002, 0xd90c00f8, 0x5fa80000, 0x84000712, 0xc00049a8, 0xca0000f8, 0x583c000a, 0x00000000,
+ 0xce0000f8, 0xc221fffe, 0x5a21fffe, 0x583c000c, 0xce0000f8, 0xc0001004, 0xca0000f8, 0x00000000,
+ 0x583c0012, 0x7e010000, 0xce0000f8, 0xa97000e1, 0x00000000, 0x00000000, 0xa97200c9, 0xc0001010,
+ 0xc2740000, 0xce435a00, 0x6c64a000, 0x46452000, 0x5a64000a, 0x6e644000, 0xc0001012, 0xce400070,
+ 0xc2600008, 0xce421038, 0xc27e0002, 0xce43ff00, 0xc2760002, 0xce437b00, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0xa8e2ffe8, 0x00000000, 0xc1220002, 0xd90c00f8, 0xc1000000,
+ 0xdd110038, 0x5d100000, 0x84000412, 0xc0004982, 0xca0000f8, 0xc0004984, 0xca4000f8, 0xc2800000,
+ 0xc361fffe, 0x5b75fffe, 0xa96a001b, 0xdfec00f8, 0xc6ec1078, 0x7af56000, 0x6c40a000, 0x44040000,
+ 0x58007600, 0x58000014, 0xcec000f8, 0xa972001b, 0x5c000002, 0xcec000f8, 0xc0001010, 0xc2f40002,
+ 0xcec35a00, 0x6c6ca000, 0x46c56000, 0x5aec000a, 0x6eec4000, 0xc0001012, 0xcec00070, 0xc0004994,
+ 0xc98000f8, 0xc1400000, 0xdd150038, 0xc55c00f8, 0x45948000, 0x00000000, 0xc59c00fc, 0x5d1c0000,
+ 0x840000d2, 0xc0001012, 0xc5d01038, 0xcd021038, 0xc2f60002, 0xcec37b00, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0xa8e2ffe8, 0x00000000, 0xc1220002, 0xd90c00f8, 0x45948000,
+ 0x88000052, 0xc0004994, 0xcd0000f8, 0xc0004980, 0xcbc000f8, 0x42150000, 0xc0004982, 0xce0000f8,
+ 0x5ffc0000, 0x84000218, 0x58880002, 0xc3800000, 0xc0000a14, 0xcb840028, 0xc3c00000, 0xc0000a10,
+ 0xb4b80018, 0x00000000, 0xc0800000, 0xcbc40060, 0x6cb84000, 0x6fac8000, 0x6ffc4000, 0x42f96000,
+ 0x43ed0000, 0xc3400000, 0xc6344060, 0xc0004000, 0x40340000, 0xc2a1e000, 0xce8000f8, 0x5a200008,
+ 0xc0004980, 0xcbc000f8, 0xc3400000, 0xc0004840, 0x6ff84010, 0xc7f40008, 0x40380000, 0xcb8000f8,
+ 0xc2800000, 0x6f506000, 0x6b908010, 0xc52c1838, 0xc3400000, 0xc6344060, 0xc0004000, 0x40340000,
+ 0xcec000f8, 0x5a200002, 0x5ffc0000, 0x84000092, 0xc0001010, 0xc62c0070, 0xcec00070, 0xc0001012,
+ 0xc7ec1038, 0xcec21038, 0xc2f60002, 0xcec37b00, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0xa8e2ffe8, 0x00000000, 0xc1220002, 0xd90c00f8, 0xc0004994, 0xc100007e, 0x453c8000,
+ 0xcd0000f8, 0x423d0000, 0xc0004982, 0xce0000f8, 0xc0004994, 0xca0000f8, 0xc0004980, 0xca4000f8,
+ 0x5e200000, 0x8400015a, 0xc2000000, 0xc2800000, 0x5a640002, 0xc6684028, 0xc0004982, 0xcb0000f8,
+ 0xc0004000, 0xc2c00000, 0xc72c4060, 0x402c0000, 0x6e67c000, 0x6e67c010, 0x5ee40002, 0x8400003a,
+ 0x5ee40004, 0x8400004a, 0x5ee40006, 0x8400005a, 0x00000000, 0x80000060, 0xce0000b8, 0x5aa80002,
+ 0x5b300006, 0x80000040, 0xce000078, 0x5aa80002, 0x5b300004, 0x80000020, 0xce000038, 0x5aa80002,
+ 0x5b300002, 0x5ee80020, 0x84000052, 0xc0004000, 0xc2c00000, 0xc72c4060, 0x402c0000, 0xce0000f8,
+ 0x5aa80002, 0x5b300008, 0x8000ffb8, 0x00000000, 0x80000040, 0x583c000a, 0xd7c000f8, 0xc0001004,
+ 0xca4000f8, 0x00000000, 0x583c000c, 0xce4000f8, 0xc000497a, 0xca4000f8, 0xc2800002, 0xc0000a28,
+ 0xc6780928, 0xc6b80800, 0xcf850830, 0x6c7ca000, 0x47c5e000, 0x5bfc7600, 0x583c0034, 0xc4900038,
+ 0xcd000038, 0x8000e418, 0x6c6c8000, 0x6c544000, 0x42d56000, 0x5aec7e00, 0xc0000824, 0xca0400f8,
+ 0x6ca48000, 0x42492000, 0xc3000000, 0xc3400000, 0x42250000, 0x58204000, 0xca4000f8, 0x5a200002,
+ 0xda2400f9, 0xc2800000, 0xc000495e, 0xce8000f8, 0xda6000f8, 0xc2800000, 0xc66b0038, 0xdaa800f8,
+ 0x582c0010, 0x6f206010, 0x40200000, 0xd82800f9, 0xca0000f8, 0xc2400000, 0xc7240010, 0x6e644000,
+ 0xda6400f8, 0x6a254010, 0xc3c00000, 0xc6bc0018, 0xc3800000, 0xdea000f8, 0x5e60001e, 0x8400002a,
+ 0x5e6001e0, 0x8400001a, 0x00000000, 0x80000080, 0xc7f800f8, 0x5e7c0008, 0x8400006a, 0x5bbc0002,
+ 0x5e780008, 0x84000028, 0x5b740002, 0xc0004960, 0xcf0000f8, 0x80000030, 0x5e780006, 0x88000022,
+ 0xc2800002, 0xc000495e, 0xce8000f8, 0xde8000f9, 0xca8000f8, 0xde6000f8, 0xc240001e, 0x6a612000,
+ 0x7e412000, 0x76a54000, 0x6ba12000, 0x72a54000, 0xce8000f8, 0x5e300080, 0x840000ba, 0xc2000000,
+ 0xc7200008, 0x5e600000, 0x84000058, 0xde6000f9, 0x58204000, 0xca4000f8, 0x5a200002, 0xda2400f9,
+ 0xc2800000, 0xc66b0038, 0xdaa800f8, 0xda6000f8, 0x80000038, 0xc2800000, 0x6e206000, 0xde2400f8,
+ 0x6a610000, 0xc62b0038, 0xdaa800f8, 0x5b300002, 0x8000fde0, 0xc2000000, 0x582c0020, 0xca020078,
+ 0x00000000, 0xc2400000, 0x5a200002, 0xc6241078, 0xce421078, 0xc000480e, 0xca8000f8, 0x5e740000,
+ 0x84000160, 0x46a12000, 0x8800e048, 0xc2400000, 0xc0000808, 0xca440010, 0x582c0010, 0xc1400000,
+ 0xcd4000f9, 0xcd4000f9, 0xcd4000f9, 0xcd4000f9, 0xcd4000f9, 0xcd4000f9, 0xcd4000f9, 0xcd4000f9,
+ 0xcd400018, 0x582c0020, 0xce021078, 0xc2000010, 0x5a640002, 0xb6240018, 0x00000000, 0xc2400000,
+ 0xc6600010, 0xc0000808, 0xce040010, 0xc0004956, 0xca4000f8, 0xc11c0000, 0xc000082c, 0xcd05ce00,
+ 0xc6600928, 0xc2400000, 0xc6600028, 0xc0000838, 0xce0400f8, 0xc2400002, 0xc0004958, 0xce4000f8,
+ 0xc11c0002, 0xc000082c, 0xcd05ce00, 0x8000df00, 0xc000495e, 0xca0000f8, 0x5e740002, 0x8400dee0,
+ 0x5e200000, 0x8400ded0, 0xc0004960, 0xca4000f8, 0xc2200004, 0x582c0002, 0xce021008, 0xc2000082,
+ 0x46250000, 0xc6280030, 0xc0000810, 0xce840030, 0x99006ba8, 0x582c0002, 0xc94000f8, 0xc1a20000,
+ 0x5e640000, 0x8400fed0, 0x00000000, 0x8000de40, 0x6c6c8000, 0x6c544000, 0x42d56000, 0x5aec7e00,
+ 0xc000487c, 0xc80400f8, 0x00000000, 0x00000000, 0x40080000, 0xcb8000f8, 0xc42400f8, 0x00000000,
+ 0xa78601a0, 0xc3c00000, 0xc2000000, 0x582c000c, 0xca010038, 0x6c508000, 0xc0004880, 0x40100000,
+ 0x58000016, 0xc90000f8, 0x00000000, 0x00000000, 0x59100002, 0xcd0000f8, 0x5a200002, 0x582c000c,
+ 0xc6100838, 0xcd010838, 0x5e600002, 0x84000020, 0xc2200004, 0x582c0002, 0xce021008, 0x5e600008,
+ 0x84000060, 0xc2200002, 0x582c0002, 0xce021008, 0x582c000c, 0xcfc10838, 0xc2220002, 0xc0000a14,
+ 0xce063100, 0xc22001a2, 0xc0000a1c, 0xce061038, 0x6c6c8000, 0x6c544000, 0x42d56000, 0x5aec7e00,
+ 0x582c0004, 0xcb0000f8, 0xc3400000, 0x00000000, 0xa7060028, 0xcf406300, 0xc3100002, 0xc0000838,
+ 0xcf050800, 0x582c000c, 0xcf421000, 0x8000dc40, 0x582c000c, 0xcfc10838, 0xc2000000, 0xc7a06010,
+ 0x5e200000, 0x84001c08, 0x6c6c8000, 0x6c544000, 0x42d56000, 0x5aec7e00, 0xc000487c, 0xc80400f8,
+ 0x00000000, 0x00000000, 0x40080000, 0xcb8000f8, 0xc42400f8, 0x00000000, 0xc2800000, 0xc3400000,
+ 0xc7b5c030, 0xc0004970, 0xcf4000f8, 0xc2400000, 0xc7a4e030, 0xc000496c, 0xce4000f8, 0xc3000000,
+ 0xc7b00010, 0xc3c00004, 0xc000496e, 0xcfc000f8, 0x582c000c, 0xca0000f8, 0xc2400002, 0xc0004964,
+ 0xce4000f8, 0xa6200372, 0x00000000, 0x5e700004, 0x840000ea, 0x5e700006, 0x84000080, 0xc2000002,
+ 0x582c0002, 0xce000000, 0xc0000a14, 0xce863100, 0x6c508000, 0xc0004880, 0x40100000, 0x58000014,
+ 0xc90000f8, 0x00000000, 0x00000000, 0x59100002, 0xcd0000f8, 0x80001a58, 0x5e70000a, 0x84000040,
+ 0xc2000000, 0x582c0002, 0xce000000, 0xc2220002, 0xc0000a14, 0xce063100, 0x8000ff70, 0x5e700008,
+ 0x84000228, 0xc2200002, 0x582c000c, 0xce021000, 0x6c508000, 0xc0004880, 0x40100000, 0x58000012,
+ 0xc90000f8, 0x00000000, 0x00000000, 0x59100002, 0xcd0000f8, 0x5e340002, 0x6c508000, 0xc0004880,
+ 0x40100000, 0x58000010, 0xc90000f8, 0x00000000, 0x00000000, 0x41208000, 0xcd0000f8, 0xc0000a14,
+ 0xce863100, 0xc0004970, 0xcb4000f8, 0x6c6c8000, 0x6c544000, 0x42d56000, 0x5aec7e00, 0x582c000e,
+ 0xc4900038, 0xcd000038, 0x582c000e, 0xc7500838, 0xcd010838, 0xc2800000, 0x582c0004, 0xce821078,
+ 0x582c0004, 0xce800000, 0xc00049a0, 0xca4000f8, 0x00000000, 0x582c0006, 0xce4000f8, 0xc261fffe,
+ 0x5a65fffe, 0x582c0024, 0xce4000f8, 0xc2060002, 0x582c0004, 0xce006300, 0xc2400002, 0xc0004958,
+ 0xce4000f8, 0xc0004878, 0xc80400f8, 0x6c908000, 0x41088000, 0x40100000, 0x58000020, 0xc90000f8,
+ 0x582c0026, 0x00000000, 0xcd0000f8, 0x800017e8, 0x00000000, 0x6c508000, 0xc0004880, 0x40100000,
+ 0x58000016, 0xc90000f8, 0x00000000, 0x00000000, 0x59100002, 0xcd0000f8, 0x8000faf0, 0x5e700000,
+ 0x840000c0, 0xc3400082, 0xc0004970, 0xcf4000f8, 0xc2400080, 0xc000496c, 0xce4000f8, 0xc3c00002,
+ 0xc000496e, 0xcfc000f8, 0xc2400000, 0xc0004964, 0xce4000f8, 0xc0004878, 0xc80400f8, 0x6c908000,
+ 0x41088000, 0x40100000, 0x58000020, 0xc90000f8, 0x582c0026, 0x00000000, 0xcd0000f8, 0x80000078,
+ 0x5e700002, 0x84000058, 0xc3400082, 0xc0004970, 0xcf4000f8, 0xc3c00004, 0xc000496e, 0xcfc000f8,
+ 0xc2200000, 0x582c000c, 0xce021000, 0x80000030, 0x5e700004, 0x8400fe80, 0xc2600002, 0x582c000c,
+ 0xce421000, 0xc0000a14, 0xce863100, 0xc000496c, 0xca4000f8, 0x6c508000, 0xc0004880, 0x40100000,
+ 0x58000012, 0xc90000f8, 0x00000000, 0x00000000, 0x59100002, 0xcd0000f8, 0xc000496e, 0xcbc000f8,
+ 0x00000000, 0x00000000, 0x477d0000, 0x46250000, 0x6c508000, 0xc0004880, 0x40100000, 0x58000010,
+ 0xc90000f8, 0x00000000, 0x00000000, 0x41208000, 0xcd0000f8, 0x6c6c8000, 0x6c544000, 0x42d56000,
+ 0x5aec7e00, 0x582c0004, 0xca0000f8, 0x00000000, 0x00000000, 0xa60014e2, 0x00000000, 0x6c6c8000,
+ 0x6c544000, 0x42d56000, 0x5aec7e00, 0xc3000000, 0x582c0004, 0xcf006300, 0x582c0000, 0xcb002010,
+ 0xc3c00000, 0x582c0004, 0xcbc20078, 0xc000491a, 0xcf0000f8, 0xc000493c, 0xcfc000f8, 0x582c0008,
+ 0xcb8000f8, 0x582c000a, 0xca4000f8, 0xc0004930, 0xcf8000f8, 0xc0004932, 0xce4000f8, 0x5ffc0000,
+ 0x840001f0, 0x00000000, 0xa7be0102, 0xc2800000, 0x6f206000, 0x46310000, 0x5a204c80, 0x5820000c,
+ 0xca800020, 0x00000000, 0x00000000, 0x5ea80000, 0x84000112, 0x00000000, 0xc161fffe, 0x5955fffe,
+ 0x14140000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x99005f70,
+ 0xc000491a, 0xc94000f8, 0x00000000, 0xc121fffe, 0x5911fef4, 0x14100000, 0xc0004930, 0xcb8000f8,
+ 0xc0004932, 0xca4000f8, 0xc4781108, 0xc0004930, 0xcf8000f8, 0x582c0008, 0xcf8000f8, 0x582c000a,
+ 0xce4000f8, 0xc7b6e108, 0x582c0004, 0xcf402108, 0x80000090, 0x00000000, 0x6c508000, 0xc0004880,
+ 0x40100000, 0x5800000c, 0xc90000f8, 0x00000000, 0x00000000, 0x59100002, 0xcd0000f8, 0xc2000002,
+ 0x582c0004, 0xce000000, 0xc0000838, 0xc2500002, 0xce450800, 0x80001220, 0x6c7c8000, 0x6c544000,
+ 0x43d5e000, 0x5bfc7e00, 0x583c0006, 0xca0000f8, 0xc00049a2, 0x00000000, 0xca8000f9, 0xca4000f8,
+ 0xc0001008, 0xce8000f8, 0xc0001006, 0xce4000f8, 0xc000100a, 0xce0000f8, 0xc2400006, 0xc0001000,
+ 0xce4000f8, 0xc2600982, 0x5a643b6e, 0xc0001002, 0xce4000f8, 0x583c0024, 0xca4000f8, 0x00000000,
+ 0xc0001004, 0xce4000f8, 0xc0004862, 0xc2000000, 0xca000078, 0xc360fffe, 0xc0004862, 0xce0000f8,
+ 0xc0000824, 0xcb440060, 0x00000000, 0xc000100e, 0xcf4000f8, 0xc3803800, 0xc2400200, 0x6e644000,
+ 0xc6781070, 0xc000100c, 0xcf8000f8, 0xc3200a00, 0xc0001010, 0xcf031810, 0xc2e06200, 0xc0001012,
+ 0xcec31838, 0xc2000000, 0x583c0004, 0xca002008, 0xc2800000, 0xc0004966, 0xce0000f8, 0xc62400f8,
+ 0xc3000000, 0xc000496a, 0xcf0000f8, 0xc0004974, 0xcf0000f8, 0xc000493c, 0xcb4000f8, 0x583c000e,
+ 0x00000000, 0x5f740000, 0x84000180, 0xc3400000, 0xcb410038, 0xc3000002, 0xc000496a, 0x5fb40080,
+ 0x84000152, 0xcf0000f8, 0x583c000e, 0xc2c00000, 0xcac00038, 0xc3800080, 0x47b5c000, 0xc0004974,
+ 0xcf8000f8, 0xc0001012, 0x6fba0000, 0xcf821038, 0x6fba0010, 0x43a5c000, 0x5b380006, 0x6f284010,
+ 0xc7a40008, 0x6eec4000, 0x6ef08000, 0x432d8000, 0x43358000, 0x5b300008, 0xc0001012, 0xc7100070,
+ 0xcd000070, 0xc2000200, 0xc2c00000, 0xdf6d0048, 0x462d6000, 0x46e96000, 0x8800ffe2, 0xc2000000,
+ 0xc0004862, 0xca000260, 0x00000000, 0x583c0004, 0xca002008, 0xc3360002, 0xc0001010, 0xce000070,
+ 0xc0001012, 0xcf037b00, 0xc0004974, 0xcb8000f8, 0x00000000, 0x00000000, 0x5fb80000, 0x84000042,
+ 0x00000000, 0x00000000, 0x00000000, 0xa8e2ffe8, 0x00000000, 0xc1220002, 0xd90c00f8, 0xc000496c,
+ 0xcac000f8, 0x00000000, 0x00000000, 0x426dc000, 0x5b380006, 0x6f304010, 0xc7a40008, 0xc0004968,
+ 0xce4000f8, 0xc000496e, 0xcb4000f8, 0x6ca44000, 0x6e608000, 0x42250000, 0x5a200006, 0x42350000,
+ 0xc0001012, 0xc6100070, 0xcd000070, 0x6eee0000, 0xcec21038, 0xc2000200, 0xc2c00000, 0xdf6d0048,
+ 0x462d6000, 0x42b14000, 0x46e96000, 0x8800ffda, 0xc000493c, 0xcb4000f8, 0xc0000838, 0xc3100002,
+ 0x5f740000, 0x84000060, 0xcf050800, 0xc0004974, 0xcb8000f8, 0x00000000, 0x00000000, 0x5fb80000,
+ 0x8400006a, 0xc0001012, 0xc3360002, 0xcf037b00, 0x800000a0, 0x583c0022, 0xcb4000f8, 0xc0004862,
+ 0xca0000f8, 0x00000000, 0xc0007800, 0x40200000, 0xcf4000f8, 0xc2000000, 0xc0004862, 0xca000260,
+ 0x00000000, 0x583c0004, 0xca002008, 0xc3360002, 0xc0001010, 0xce000070, 0xc0001012, 0xcf037b00,
+ 0xc0004968, 0xcbc000f8, 0xc0004964, 0xca4000f8, 0xc7e000f8, 0x00000000, 0x5e640000, 0x84000012,
+ 0xc2000000, 0xc0004974, 0xca4000f8, 0xc000496c, 0xca8000f8, 0xc000493c, 0xcb8000f8, 0x42698000,
+ 0x00000000, 0x43b1a000, 0x5ef40080, 0x8800019a, 0xc0004966, 0xcac000f8, 0x6c648000, 0x6c544000,
+ 0x42552000, 0x5a647e00, 0x58240000, 0x436da000, 0x4761a000, 0xc2400000, 0xca420078, 0x00000000,
+ 0x00000000, 0x46752000, 0x88000122, 0x432d8000, 0x47218000, 0x88000010, 0xc3000000, 0x5b300006,
+ 0x6f304010, 0xc000493a, 0xcf0000f8, 0xc0004932, 0xc2400000, 0xca4000d8, 0x00000000, 0x6fb84010,
+ 0x42792000, 0xc000491e, 0xce4000f8, 0xc0004862, 0xca8000f8, 0x00000000, 0xc2c0000a, 0xc6e80d70,
+ 0xc7281048, 0xc000491c, 0xce8000f8, 0x6c708000, 0x6c544000, 0x43158000, 0x5b307e00, 0x6f760000,
+ 0x58300004, 0xcf421078, 0x6ffc2000, 0x58300004, 0xcfc02108, 0x800000d0, 0x6c708000, 0x6c544000,
+ 0x43158000, 0x5b307e00, 0xc2800002, 0x58300004, 0xce800000, 0x6c508000, 0xc0004880, 0x40100000,
+ 0x5800000e, 0xc90000f8, 0x00000000, 0x00000000, 0x59100002, 0xcd0000f8, 0x00000000, 0x00000000,
+ 0x00000000, 0xa8e2ffe8, 0x00000000, 0xc1220002, 0xd90c00f8, 0x80000920, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0xa8e2ffe8, 0x00000000, 0xc1220002, 0xd90c00f8, 0xc0004964, 0xca0000f8,
+ 0x6c7c8000, 0x6c544000, 0x43d5e000, 0x5bfc7e00, 0xdfe400f8, 0x5e200002, 0x84000608, 0x00000000,
+ 0x583c0004, 0xc2800000, 0xca820078, 0xc0004930, 0xcac000f8, 0x00000000, 0x00000000, 0x6eece000,
+ 0x6eefc010, 0x46aca000, 0xc1000000, 0xdd500039, 0x6d106010, 0x4550a000, 0xc1000000, 0xdd514201,
+ 0x4550c000, 0xa95000f1, 0xc00049a6, 0xca0000f8, 0xa94a0023, 0x00000000, 0x6e660000, 0x6e660010,
+ 0x46612000, 0x840000b2, 0x00000000, 0x6c508000, 0xc0004880, 0x40100000, 0x58000004, 0xc90000f8,
+ 0x00000000, 0x00000000, 0x59100002, 0xcd0000f8, 0x6c508000, 0xc0004880, 0x40100000, 0x58000006,
+ 0xc90000f8, 0x00000000, 0x00000000, 0x41148000, 0xcd0000f8, 0x80000720, 0x00000000, 0xa95203c1,
+ 0xc0001004, 0xcb8000f8, 0xc3400000, 0xdd740039, 0x5f740000, 0x840000d0, 0xc1218e08, 0x5911baf6,
+ 0x45388000, 0x84000372, 0x00000000, 0x6c508000, 0xc0004880, 0x40100000, 0x58000008, 0xc90000f8,
+ 0x00000000, 0x00000000, 0x59100002, 0xcd0000f8, 0x6c508000, 0xc0004880, 0x40100000, 0x5800000a,
+ 0xc90000f8, 0x00000000, 0x00000000, 0x41148000, 0xcd0000f8, 0x80000620, 0x00000000, 0xc000496c,
+ 0xcb0000f8, 0x583c0026, 0xcac000f8, 0xc0004878, 0xc80400f8, 0x6c908000, 0x41088000, 0x40100000,
+ 0x58000002, 0xca8000f8, 0x00000000, 0x00000000, 0x6ea90000, 0x5d300008, 0x8800004a, 0x59300002,
+ 0xc3000000, 0xc5300008, 0x6d104010, 0x40100000, 0xca8000f8, 0x5c000002, 0xcac000f8, 0x5d300000,
+ 0x8400003a, 0x6f246000, 0x6ae56000, 0xc1000040, 0x45252000, 0x6aa54010, 0x42e96000, 0x583c0026,
+ 0xcec000f8, 0xc1218e08, 0x5911baf6, 0xc0001004, 0xcd0000f8, 0x593c0026, 0xc000100e, 0xcd000060,
+ 0xc1340000, 0xc0001010, 0xcd035a00, 0xc1200008, 0xa94a0023, 0xc0001012, 0xc1200004, 0x59100004,
+ 0xcd0000b8, 0xc1360002, 0xcd037b00, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xa8e2ffe8, 0x00000000, 0xc1220002, 0xd90c00f8, 0xc0001004, 0xc90000f8, 0x00000000, 0x00000000,
+ 0x45388000, 0x840000b2, 0x00000000, 0x6c508000, 0xc0004880, 0x40100000, 0x58000008, 0xc90000f8,
+ 0x00000000, 0x00000000, 0x59100002, 0xcd0000f8, 0x6c508000, 0xc0004880, 0x40100000, 0x5800000a,
+ 0xc90000f8, 0x00000000, 0x00000000, 0x41148000, 0xcd0000f8, 0x80000360, 0x00000000, 0x6c508000,
+ 0xc0004880, 0x40100000, 0x58000000, 0xc90000f8, 0x00000000, 0x00000000, 0x59100002, 0xcd0000f8,
+ 0x6c508000, 0xc0004880, 0x40100000, 0x58000002, 0xc90000f8, 0x00000000, 0x00000000, 0x41148000,
+ 0xcd0000f8, 0xc0004930, 0xcd800078, 0xc3000000, 0x583c0008, 0xcf0000f8, 0x80000038, 0xc0001004,
+ 0xca0000f8, 0x583c0006, 0xce4000f8, 0x583c0024, 0xce0000f8, 0xc0004862, 0xc2000000, 0xca000078,
+ 0xc000493a, 0xca4000f8, 0x00000000, 0x00000000, 0x42254000, 0x5ee80200, 0x88000012, 0xc6e800f8,
+ 0xc0004000, 0x58003800, 0x40280000, 0xcb8000f8, 0x00000000, 0x583c0022, 0xcf8000f8, 0xc0004862,
+ 0xce800078, 0xc0001406, 0xcac000f8, 0xc2800002, 0x00000000, 0xc66c1048, 0xc6ac0a00, 0xcec000f8,
+ 0xc2000000, 0xdf600038, 0x5e600080, 0x8400ffea, 0xc000491c, 0xca4000f8, 0xc000491e, 0xca8000f8,
+ 0x99006480, 0xda5800f8, 0xda9800f9, 0x00000000, 0xc0004964, 0xcbc000f8, 0x00000000, 0x00000000,
+ 0x5ffc0000, 0x84000102, 0xc2000000, 0xdf610048, 0x5e6001fe, 0x8800ffe8, 0xc000491a, 0xc98000f8,
+ 0xc0004862, 0xc94000f8, 0x6d9c6000, 0x45d8e000, 0x59dc4c80, 0x990062e0, 0xd95800f8, 0xd99800f9,
+ 0xd9d400f8, 0x99006258, 0xc000491c, 0xc1400000, 0xc9420048, 0xc2000000, 0xdf600038, 0x5e600080,
+ 0x8400ffea, 0xc000491c, 0xca4000f8, 0xc000491e, 0xca8000f8, 0x99006480, 0xda5800f8, 0xda9800f9,
+ 0x00000000, 0xc0004970, 0xcb4000f8, 0x00000000, 0x00000000, 0x5e740082, 0x8400e6d8, 0x00000000,
+ 0x8000c018, 0x00000000, 0x6c508000, 0xc0004880, 0x40100000, 0x58000016, 0xc90000f8, 0x00000000,
+ 0x00000000, 0x59100002, 0xcd0000f8, 0x8000e308, 0x6c6c8000, 0x6c544000, 0x42d56000, 0x5aec7e00,
+ 0xc000487c, 0xc80400f8, 0x00000000, 0x00000000, 0x40080000, 0xca0000f8, 0xc42400f8, 0x00000000,
+ 0xa60600f8, 0xc3c00000, 0xc2000000, 0x582c000c, 0xca010038, 0x00000000, 0x00000000, 0x5a200002,
+ 0xc6100838, 0xcd010838, 0x5e60000e, 0x8400bf00, 0xc2200000, 0x582c0002, 0xce021008, 0x582c000c,
+ 0xcfc10838, 0x582c0020, 0xcfc21078, 0x582c0010, 0xc1400000, 0xcd4000f9, 0xcd4000f9, 0xcd4000f9,
+ 0xcd4000f9, 0xcd4000f9, 0xcd4000f9, 0xcd4000f9, 0xcd4000f9, 0xcd400018, 0x8000be68, 0xc2200004,
+ 0x582c0002, 0xce021008, 0x582c000c, 0xcfc10838, 0x99006ba8, 0x582c0002, 0xc94000f8, 0xc1a20000,
+ 0x8000be18, 0xc3e1fffe, 0x597dfffe, 0x593dfef4, 0x94000001, 0x00000000, 0x00000000, 0x00000000,
+ 0xc0800000, 0xdf4b0038, 0xc0004900, 0xcb8000f8, 0xc2000000, 0xc000490a, 0xa78000d0, 0xcbc000f8,
+ 0xc1000000, 0xd90000f9, 0xc1000002, 0xd90c00f8, 0x6ff46000, 0x477da000, 0x5b744c80, 0xc2400000,
+ 0x58340004, 0xca400078, 0xc0004900, 0xce000000, 0x5a640002, 0x58340004, 0xc6500078, 0xcd000078,
+ 0xc0004914, 0xca4000f8, 0xc2000002, 0x6a3d0000, 0x72612000, 0xce4000f8, 0xc0000408, 0xce0000f8,
+ 0xa78200c8, 0xc0004908, 0xcbc000f8, 0xc1000000, 0xd90000f9, 0xc1000002, 0xd90c00f8, 0x6ff4a000,
+ 0x477da000, 0x5b747600, 0xc2800000, 0x58340006, 0xca800078, 0xc2000000, 0xc0004900, 0xce002100,
+ 0x5ea80002, 0x58340006, 0xc6900078, 0xcd000078, 0x5a7c0020, 0xc2000002, 0x6a250000, 0xc0000408,
+ 0xce0000f8, 0xdca800f9, 0x5ea80000, 0x8400abd0, 0x00000000, 0xa4800230, 0x00000000, 0xc3c00000,
+ 0xc000140e, 0xcbc00018, 0xc3400000, 0xc2400000, 0x6ff86000, 0x47bdc000, 0x5bb84c80, 0x58380008,
+ 0xcb400078, 0x58380006, 0xca400078, 0x5f740002, 0x58380008, 0xc7500078, 0xcd000078, 0xc2000000,
+ 0x58380004, 0xca020078, 0xc3000000, 0x5838000c, 0xcb000020, 0x5a640002, 0x46610000, 0x84000010,
+ 0xc2400000, 0x58380006, 0xc6500078, 0xcd000078, 0xc2000000, 0x5838000a, 0xca020078, 0x5b300002,
+ 0x5838000c, 0xc7100020, 0xcd000020, 0xc2420020, 0x5a200004, 0x46252000, 0x84000010, 0xc2000000,
+ 0x5838000a, 0xc6101078, 0xcd021078, 0xc000498c, 0xca4000f8, 0xc2000002, 0x6a3d0000, 0x72612000,
+ 0xce4000f8, 0x5f740000, 0x84000040, 0xc0004912, 0xca0000f8, 0xc2c00002, 0x6afd6000, 0x7ec16000,
+ 0x762d0000, 0xce0000f8, 0x5f300020, 0x84000040, 0xc0004924, 0xca0000f8, 0xc2c00002, 0x6afd6000,
+ 0x7ec16000, 0x762d0000, 0xce0000f8, 0xa4820070, 0xc2400000, 0xc000140e, 0xca408018, 0xc2000002,
+ 0xc0004900, 0xce000000, 0xc000490a, 0xce4000f8, 0xc1000000, 0xd90000f9, 0xd8400078, 0xc1000004,
+ 0xd90000f9, 0xa48402d8, 0x00000000, 0xc3c00000, 0xc000140e, 0xcbc10018, 0xc2800000, 0xc2000000,
+ 0x6ff8a000, 0x47bdc000, 0x5bb87600, 0x58380036, 0xca800078, 0x58380006, 0xca020078, 0xc3400000,
+ 0x58380036, 0xcb420078, 0x5aa80002, 0x46a10000, 0x84000010, 0xc2800000, 0x58380036, 0xc6900078,
+ 0xcd000078, 0x5f740002, 0x58380036, 0xc7501078, 0xcd021078, 0xc000498e, 0xca4000f8, 0xc2000002,
+ 0x6a3d0000, 0x72612000, 0xce4000f8, 0xc000492a, 0xca8000f8, 0x5e740000, 0x84000040, 0xc0004910,
+ 0xca0000f8, 0xc2c00002, 0x6afd6000, 0x7ec16000, 0x762d0000, 0xce0000f8, 0x6abd4010, 0xa6800132,
+ 0x00000000, 0x5838003a, 0xca0000f8, 0x58000002, 0xca4000f8, 0x5838000e, 0x00000000, 0xce0000f9,
+ 0xce4000f8, 0xc2400000, 0xdd250038, 0xc1000080, 0x45248000, 0xc2400000, 0xc6240078, 0x46510000,
+ 0x00000000, 0xc52400fc, 0x5d240078, 0xc1000078, 0xc52400fc, 0xc6600078, 0x5c000002, 0xce000078,
+ 0xc000492a, 0xca0000f8, 0xc2c00002, 0x6afd6000, 0x722d0000, 0xce0000f8, 0xc000492c, 0xca0000f8,
+ 0xc2c00002, 0x6afd6000, 0x722d0000, 0xce0000f8, 0x80000040, 0xc000492c, 0xca0000f8, 0xc2c00002,
+ 0x6afd6000, 0x7ec16000, 0x762d0000, 0xce0000f8, 0xa4880088, 0xc2c00000, 0xc000140e, 0xcac20018,
+ 0xc000490e, 0xca4000f8, 0xc2000002, 0x6a2d0000, 0x7e010000, 0x76612000, 0xce4000f8, 0xc0004990,
+ 0xca4000f8, 0xc2000002, 0x6a2d0000, 0x72612000, 0xce4000f8, 0xa4860070, 0xc2400000, 0xc000140e,
+ 0xca418018, 0xc2020002, 0xc0004900, 0xce002100, 0xc0004908, 0xce4000f8, 0xc1000000, 0xd90000f9,
+ 0xd8400078, 0xc1000004, 0xd90000f9, 0xc0001408, 0xcc8000f8, 0xc10e0002, 0xd90c00f8, 0x8000f750,
+ 0xdfbc00f9, 0xc0004992, 0x99006be8, 0xc94000f8, 0xc7d800f8, 0x00000000, 0xc57000f8, 0x5ef00020,
+ 0x88000158, 0x6f346000, 0x4771a000, 0x5b744c80, 0x58340008, 0xc2400000, 0xca400078, 0x00000000,
+ 0xc2000000, 0x5a640002, 0xc6500078, 0xcd000078, 0x58340004, 0xca000078, 0x00000000, 0x00000000,
+ 0x5e200002, 0xc6100078, 0xcd000078, 0xc0004912, 0xca8000f8, 0xc2400002, 0x6a712000, 0x72a54000,
+ 0xce8000f8, 0x5e200000, 0x84000052, 0xc000480a, 0xca0000f8, 0xc0000408, 0xca8000f8, 0x76250000,
+ 0x00000000, 0x72a14000, 0xce8000f8, 0x80000038, 0xc0004914, 0xca0000f8, 0x7e412000, 0x00000000,
+ 0x76250000, 0xce0000f8, 0x800000c8, 0x6ef4a000, 0x476da000, 0x5b747600, 0x58340036, 0xc2400000,
+ 0xca420078, 0x00000000, 0xc2000000, 0x5a640002, 0xc6501078, 0xcd021078, 0x58340006, 0xca000078,
+ 0x00000000, 0x00000000, 0x5a200002, 0xc6100078, 0xcd000078, 0xc0004910, 0xca4000f8, 0xc2000002,
+ 0x6a2d0000, 0x72612000, 0xce4000f8, 0xc2000002, 0x6a310000, 0xc000042a, 0xce0000f8, 0xc1040002,
+ 0xd90c00f8, 0x00000000, 0x8000f4b8, 0x00000000, 0xc4980928, 0x9d000000, 0xc5580028, 0xc0000838,
+ 0xcd8400f8, 0xc1440200, 0xc1c03800, 0xc55c1070, 0xc000100e, 0x9d000000, 0xcd8000f8, 0xc000100c,
+ 0xcdc000f8, 0xc0004862, 0xc9c000f8, 0x00000000, 0x00000000, 0xd9d800f9, 0xc0007800, 0x401c0000,
+ 0x5dc07a00, 0x88000012, 0x5c000200, 0xcd8000f8, 0xc1f0000a, 0x715ca000, 0xdd9800f8, 0xdd9c00f9,
+ 0x41d8e000, 0xc5d40260, 0xc0001010, 0xcd4000f8, 0x6c9c8000, 0x45c8e000, 0x45c8e000, 0x59dc0004,
+ 0xc1601260, 0xc5d40260, 0x9d000000, 0xc0001012, 0xcd4000f8, 0x00000000, 0x00000000, 0xd95800f8,
+ 0x6d586000, 0x4594c000, 0x59984c80, 0xd99800f9, 0x5818000a, 0xc1800000, 0xc9800078, 0xc0007680,
+ 0x6d5ca000, 0x401c0000, 0x40180000, 0xc94000f8, 0x58000002, 0x00000000, 0xc9c000f8, 0xc0004930,
+ 0xcd4000f8, 0xc0004932, 0xcdc000f8, 0x59980004, 0xc1c20020, 0xb59c0018, 0x00000000, 0xc1800000,
+ 0xdd9c00f9, 0x581c000a, 0xcd800078, 0x581c000c, 0xc1800000, 0xc9800020, 0xc1c00002, 0xdd9400f8,
+ 0x69d4e000, 0x5d980002, 0xcd800020, 0xc0004924, 0xc98000f8, 0x00000000, 0x9d000000, 0x00000000,
+ 0x719cc000, 0xcd8000f8, 0xc000492a, 0xc94000f8, 0xc1c00002, 0x69d8e000, 0x7dc0c000, 0x7558a000,
+ 0xcd4000f8, 0xc000492c, 0xc94000f8, 0xdd8000f9, 0x5800003a, 0x755ca000, 0x84000108, 0xc94000f9,
+ 0xc98000f8, 0xdd8000f9, 0x5800000e, 0x00000000, 0xcd4000f9, 0xcd8000f8, 0xc1800000, 0xdd190038,
+ 0xc1000080, 0x45188000, 0xc1800000, 0xc5580078, 0x4590a000, 0x00000000, 0xc51800fc, 0x5d180078,
+ 0xc1000078, 0xc51800fc, 0xc5940078, 0x5c000002, 0xcd400078, 0xc000492c, 0xc94000f8, 0xc000492a,
+ 0xc98000f8, 0x715ca000, 0xc000492c, 0xcd4000f8, 0x719cc000, 0xc000492a, 0xcd8000f8, 0x9cc00000,
+ 0x00000000, 0x00000000, 0x00000000, 0xc0004862, 0xc98000f8, 0x00000000, 0xc1c00200, 0x4194c000,
+ 0x459ce000, 0x88000012, 0xc5d800f8, 0xc0004862, 0xcd8000f8, 0xc0001406, 0xc98000f8, 0xc1c00002,
+ 0x9d000000, 0xc5d80a00, 0xc5581048, 0xcd8000f8, 0xc0004930, 0xc98000f8, 0xc0004932, 0xc9c000f8,
+ 0xc140000e, 0xc5581c18, 0xdd9400f8, 0xc0007800, 0x40140000, 0x5d407a00, 0x88000012, 0x5c000200,
+ 0xcd8000f8, 0x58000002, 0x5d407a00, 0x88000012, 0x5c000200, 0xcdc000f8, 0xdd5400f8, 0xc1c00000,
+ 0x58140006, 0xc9c20078, 0xc1800000, 0x58140000, 0xc98000d8, 0x6ddc2000, 0xc000491e, 0x41d8e000,
+ 0xcdc000f8, 0xdd9800f8, 0xc1c00022, 0xc5d80d70, 0xdd9400f9, 0xc5581c18, 0xc000491c, 0xcd8000f8,
+ 0xdd5400f8, 0xc1c00000, 0x58140006, 0xc9c20078, 0xc1800000, 0x58140004, 0xc9820078, 0x00000000,
+ 0x59dc0002, 0x45d8c000, 0x84000010, 0xc1c00000, 0x9d000000, 0x58140006, 0xc5d81078, 0xcd821078,
+ 0xc0004860, 0xc94000f8, 0xc1820080, 0xc1d00002, 0x58147700, 0xd58000f8, 0x58000002, 0xd58000f9,
+ 0x59540004, 0xb5580018, 0xc0004860, 0xc1400000, 0xcd4000f8, 0xdd9800f9, 0x9d000000, 0xdd9400f8,
+ 0xc0001404, 0xcdc10800, 0xc1c00000, 0xc1800200, 0x5d980004, 0xdf5d0048, 0x459ca000, 0x8800fff2,
+ 0xdd8000f9, 0x5800000e, 0x00000000, 0xc94000f9, 0xc98000f8, 0xc1c00002, 0xc5d43f00, 0xc5d81e00,
+ 0xc0004862, 0xc9c000f8, 0x00000000, 0x00000000, 0x581c7800, 0x5dc07a00, 0x88000012, 0x5c000200,
+ 0xcd4000f8, 0x58000002, 0x5dc07a00, 0x88000012, 0x5c000200, 0xcd8000f8, 0xc0004862, 0xc9c000f8,
+ 0x00000000, 0xc15004c0, 0xc5d40060, 0xdd9c00f8, 0xc5d41c18, 0xc1c00000, 0xdd8000f9, 0x58000038,
+ 0xc9c00078, 0xdd8000f9, 0xc1800000, 0x58000002, 0xc98000d8, 0x6ddc2000, 0xc000491c, 0x41d8e000,
+ 0xcd4000f9, 0xcdc000f8, 0xdd9400f9, 0xc1c00000, 0x58140038, 0xc9c00078, 0xc1800000, 0x58140006,
+ 0xc9820078, 0x00000000, 0x59dc0002, 0x45d8c000, 0x84000010, 0xc1c00000, 0x9d000000, 0x58140038,
+ 0xc5d80078, 0xcd800078, 0xc1c00000, 0xdf5c0038, 0x5ddc0080, 0x8400ffea, 0x00000000, 0x9d000000,
+ 0x00000000, 0x00000000, 0x00000000, 0xc160fffe, 0xc0000a10, 0xc9440060, 0xc1a0fffe, 0x59983608,
+ 0xc000100c, 0xcd4000f8, 0xc000100e, 0xcd8000f8, 0xc0004962, 0xc98000f8, 0x00000000, 0xc170000a,
+ 0x7158a000, 0x6c988000, 0x4588c000, 0x4588c000, 0x59980004, 0xc5940270, 0xc0001010, 0xcd4000f8,
+ 0xc0004946, 0xc94000f8, 0x00000000, 0x00000000, 0x6d58a000, 0x6d5c4000, 0x459cc000, 0x4594c000,
+ 0xc000494a, 0xc94000f8, 0xc0004948, 0xc9c000f8, 0x4194c000, 0xc1400012, 0xc55c1818, 0x9d000000,
+ 0xc59c0268, 0xc0001012, 0xcdc000f8, 0xc1400000, 0x58000014, 0xc9410038, 0xc0004950, 0xc9c000f8,
+ 0xc55800f8, 0xc5940838, 0xc5581078, 0xd99400f8, 0xc000493c, 0xc94000f8, 0xc0004954, 0xc98000f8,
+ 0x59dc00a8, 0x45d4e000, 0x41d8e000, 0x5d5c0030, 0x88000010, 0xc1c00030, 0xc1800000, 0xc5d84028,
+ 0xc1400000, 0xc5d40008, 0x5dd40002, 0x84000072, 0x5dd40004, 0x8400009a, 0x5dd40006, 0x840000c2,
+ 0x5dd80026, 0x840000ea, 0xdd5400f8, 0xdd8000f9, 0x58000008, 0x40180000, 0xcd4000f8, 0x59980002,
+ 0x8000ffc0, 0xdd5400f8, 0xdd8000f9, 0x58000008, 0x40180000, 0xcd4000b8, 0x59980002, 0x8000ff88,
+ 0xdd5400f8, 0xdd8000f9, 0x58000008, 0x40180000, 0xcd400078, 0x59980002, 0x8000ff50, 0xdd5400f8,
+ 0xdd8000f9, 0x58000008, 0x40180000, 0xcd400038, 0x59980002, 0x8000ff18, 0x00000000, 0x9d000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x58000014, 0xc94000f8, 0xc0004954, 0xc9c000f8, 0xc0004950,
+ 0xc9400078, 0xdd8000f9, 0x5800002a, 0x5d9c0000, 0x84000052, 0x5d9c0002, 0x84000052, 0x5d9c0004,
+ 0x8400006a, 0xc55b0038, 0xc55c08b8, 0xcd800039, 0xcdc108b8, 0x80000060, 0xcd4000f8, 0x80000050,
+ 0xc55900b8, 0xc55c1838, 0xcd8000b9, 0xcdc31838, 0x80000028, 0xc55a0078, 0xc55c1078, 0xcd800079,
+ 0xcdc21078, 0x9d000000, 0x00000000, 0x00000000, 0x00000000, 0xc1e00000, 0xa540001a, 0xc0000a14,
+ 0xc1a20002, 0x9d000000, 0xcd863100, 0xc0000a1c, 0xcdc61038, 0x59540002, 0x6994e018, 0x61c0c008,
+ 0x4194a000, 0x5d940040, 0x88000012, 0xc59400f8, 0x9d000000, 0xcd4000f8, 0x00000000, 0x00000000,
+};
+
+static unsigned int firmware_binary_data[] = {
+};
+
+
+#endif // IFXMIPS_PTM_FW_AR9_H
diff --git a/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_fw_danube.h.svn-base b/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_fw_danube.h.svn-base
new file mode 100644
index 0000000..3451682
--- /dev/null
+++ b/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_fw_danube.h.svn-base
@@ -0,0 +1,489 @@
+#ifndef IFXMIPS_PTM_FW_DANUBE_H
+#define IFXMIPS_PTM_FW_DANUBE_H
+
+
+/******************************************************************************
+**
+** FILE NAME : ifxmips_ptm_fw_danube.h
+** PROJECT : Danube
+** MODULES : PTM (ADSL)
+**
+** DATE : 1 AUG 2005
+** AUTHOR : Xu Liang
+** DESCRIPTION : PTM Driver (PP32 Firmware)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 4 AUG 2005 Xu Liang Initiate Version
+** 23 OCT 2006 Xu Liang Add GPL header.
+*******************************************************************************/
+
+
+#define PTM_FW_VER_MAJOR 0
+#define PTM_FW_VER_MINOR 17
+
+
+static unsigned int firmware_binary_code[] = {
+ 0x800004a0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8000ffc8, 0x00000000, 0x00000000, 0x00000000,
+ 0xc1000002, 0xd90c0000, 0xc2000002, 0xda080001, 0x80005618, 0xc2000000, 0xda080001, 0x800055b8,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x80005da8, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xc10e0002, 0xd90c0000, 0xc0004808, 0xc8400000, 0x80005288, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xc3e1fffe, 0x597dfffe, 0x593dfef4, 0x900004d9, 0x00000000, 0x00000000, 0x00000000, 0x90cc0481,
+ 0x00000000, 0x00000000, 0x00000000, 0xc3e02262, 0x5bfc0022, 0xc0004002, 0xcfc00000, 0xc0004810,
+ 0xcbc00000, 0x00000000, 0xc3800000, 0xc7f80040, 0x5fb80000, 0xc7fa0040, 0xc7bfe80a, 0x5fb80000,
+ 0x00000000, 0xc7bff80a, 0xdbd40001, 0xc00049a0, 0xc3800002, 0xa7ca004a, 0xc1200000, 0x5911fffe,
+ 0xcd000001, 0xc1200000, 0x59102042, 0xcd000001, 0xc1000004, 0xcd000001, 0xc1200000, 0x59103a1e,
+ 0xcd000001, 0x80000048, 0xc121fffe, 0x5911fffe, 0xcd000001, 0xc1203db8, 0x5910de82, 0xcd000001,
+ 0xc1000006, 0xcd000001, 0xc120385a, 0x591033da, 0xcd000001, 0x5fb80002, 0x88000002, 0x6ffe0010,
+ 0x8000ff10, 0xdd7c0001, 0xc3800000, 0xc7f86018, 0x5bb80008, 0xc3540002, 0x77f5a000, 0xc1000008,
+ 0x4539c002, 0xcf800001, 0xdb900040, 0xc3800008, 0xc3720002, 0x77f5a000, 0xa7f00008, 0x47b9c002,
+ 0xc1000000, 0xc7d26018, 0x4391c000, 0xcf800000, 0xdb900840, 0xc3c00000, 0xdbc80001, 0xc0400000,
+ 0xc11c0000, 0xc000082c, 0xcd040e08, 0xc11c0002, 0xc000082c, 0xcd040e08, 0xc0400002, 0xc11c0000,
+ 0xc000082c, 0xcd040e08, 0xc11c0002, 0xc000082c, 0xcd040e08, 0xc0000824, 0x00000000, 0xcbc00001,
+ 0xcb800001, 0xcb400001, 0xcb000000, 0xc0004878, 0x5bfc4000, 0xcfc00001, 0x5bb84000, 0xcf800001,
+ 0x5b744000, 0xcf400001, 0x5b304000, 0xcf000000, 0xc0000a10, 0x00000000, 0xcbc00001, 0xcb800000,
+ 0xc0004874, 0x5bfc4000, 0xcfc00001, 0x5bb84000, 0xcf800000, 0xc30001fe, 0xc000140a, 0xcf000000,
+ 0xc3000000, 0x7f018000, 0xc000042e, 0xcf000000, 0xc000040e, 0xcf000000, 0xc3c1fffe, 0xc000490e,
+ 0xcfc00080, 0xc000492c, 0xcfc00080, 0xc0004924, 0xcfc00040, 0xc0004912, 0xcfc00040, 0xc000498c,
+ 0xcfc00040, 0xc000498e, 0xcfc00080, 0xc0004990, 0xcfc00080, 0xc3c00000, 0xc2800004, 0xc3000000,
+ 0x7f018000, 0x6ff88000, 0x6fd44000, 0x4395c000, 0x5bb84a00, 0xc00049a0, 0xcb000000, 0x00000000,
+ 0x58380006, 0xcf000000, 0xc321fffe, 0x5b31fffe, 0x58380024, 0xcf000000, 0x5bfc0002, 0xb7e8ff70,
+ 0x00000000, 0xc3c00000, 0xc2800010, 0x6ff86000, 0x47f9c000, 0x5bb84c80, 0xc3400000, 0x58380004,
+ 0xcb420080, 0x00000000, 0x58380008, 0xcf400080, 0x5bfc0002, 0xb7e8ff90, 0x00000000, 0xc3c00000,
+ 0xc2800004, 0xc3400022, 0xc3000000, 0x7f018000, 0xc2c00016, 0x6ff8a000, 0x47f9c000, 0x5bb84e20,
+ 0x58380008, 0xcf400040, 0xc00049a8, 0xcb000000, 0x00000000, 0x5838000a, 0xcf000000, 0xc321fffe,
+ 0x5b31fffe, 0x5838000c, 0xcf000000, 0x58380034, 0xcec00040, 0x5bfc0002, 0xb7e8ff58, 0x00000000,
+ 0x00000000, 0xc0004840, 0xc3e12624, 0x5bfc2320, 0xcfc00001, 0xc3e02f2c, 0x5bfd2a28, 0xcfc00001,
+ 0xc3e03734, 0x5bfd3230, 0xcfc00001, 0xc3e13e3c, 0x5bfc3b38, 0xcfc00001, 0xc3e14644, 0x5bfc4340,
+ 0xcfc00001, 0xc3e04f4c, 0x5bfd4a48, 0xcfc00001, 0xc3e05754, 0x5bfd5250, 0xcfc00001, 0xc3e15e5c,
+ 0x5bfc5b58, 0xcfc00001, 0xc3e06764, 0x5bfd6260, 0xcfc00001, 0xc3e16e6c, 0x5bfc6b68, 0xcfc00001,
+ 0xc3e17674, 0x5bfc7370, 0xcfc00001, 0xc3e07f7c, 0x5bfd7a78, 0xcfc00001, 0xc3e18684, 0x5bfc8380,
+ 0xcfc00001, 0xc3e08f8c, 0x5bfd8a88, 0xcfc00001, 0xc3e09794, 0x5bfd9290, 0xcfc00001, 0xc3e19e9c,
+ 0x5bfc9b98, 0xcfc00001, 0xc121fffe, 0x5911fef4, 0x15000000, 0x80000010, 0x00000000, 0x80000638,
+ 0x00000000, 0x8000ffc8, 0xc0004918, 0xd2800000, 0xc2000000, 0xdf600040, 0x5e600080, 0x8400029a,
+ 0x00000000, 0xc161fffe, 0x5955fffe, 0x15400000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0xc000480a, 0xca000000, 0xc0004912, 0xca400000, 0xc0004924, 0xca800000,
+ 0xc000498c, 0xcac00000, 0xc121fffe, 0x5911fef4, 0x15000000, 0x76610000, 0x76a10000, 0x76e10000,
+ 0x840001d2, 0xc0004918, 0xca400000, 0xc28001fe, 0x76a10000, 0x5a640002, 0x6a254010, 0x5ee80000,
+ 0x84000002, 0x6aa54000, 0x8000fff8, 0xc6280000, 0x62818008, 0xc0004918, 0xcf000000, 0xc161fffe,
+ 0x5955fffe, 0x15400000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xc000498c, 0xca400000, 0xc2000002, 0x6a310000, 0x7e010000, 0x76252000, 0xce400000, 0xc121fffe,
+ 0x5911fef4, 0x15000000, 0x6f346000, 0x4735a000, 0x5b744c80, 0xc2800000, 0x58340006, 0xca800080,
+ 0xc2c00000, 0x58340000, 0xcac000e0, 0xc2400000, 0x5834000a, 0xca420080, 0x6ea82000, 0x42e9e000,
+ 0x6f2ca000, 0x42e56000, 0x5aec1400, 0xc3990040, 0xc7381c20, 0xc6f80068, 0x99006840, 0xdb980000,
+ 0xdbd80001, 0x00000000, 0xdea00000, 0x47210000, 0x8400fd28, 0xc000495a, 0xc8400000, 0x00000000,
+ 0xc3c00002, 0x7bc42000, 0xcc400000, 0xc0000838, 0xc3800000, 0xcb840030, 0x6c748000, 0x6c544000,
+ 0x4355a000, 0x5b744a00, 0x5ef80000, 0x8400fc8a, 0x58340004, 0xcb000000, 0x00000000, 0x00000000,
+ 0xa7060000, 0x00000000, 0x5ef80002, 0x8400fc4a, 0x5834000c, 0xc8800040, 0xc2000000, 0xc000082c,
+ 0xca040030, 0x5a880002, 0xc2400000, 0xc0004958, 0xce400000, 0xb628fff8, 0x00000000, 0xc2800000,
+ 0x58340002, 0xc2000000, 0xca020010, 0xc0004956, 0xce800000, 0x5e600000, 0x84001df2, 0x5e600002,
+ 0x840043da, 0x00000000, 0x80002320, 0xc0004958, 0xca000000, 0xc0004956, 0xca800000, 0x5e200000,
+ 0x84000008, 0xc2500002, 0xc0000838, 0xce440808, 0x6c748000, 0x6c544000, 0x4355a000, 0x5b744a00,
+ 0x5834000c, 0xc6900040, 0xcd000040, 0x58340002, 0xc2000000, 0xca020010, 0x00000000, 0x00000000,
+ 0x5f600000, 0x84000122, 0xc0004818, 0xc8000000, 0x00000000, 0x00000000, 0x5c000000, 0x840000f2,
+ 0xc11c0000, 0xc000082c, 0xcd040e08, 0xc0000838, 0xc3800000, 0xc2400000, 0xcb840030, 0xca452030,
+ 0x00000000, 0x42b9a000, 0x5e340022, 0x88000012, 0xc200001e, 0x7635a000, 0x5f740002, 0x8000fff0,
+ 0x6e642010, 0x4675a000, 0x84000042, 0xc0004818, 0xc8000000, 0x00000000, 0x00000000, 0x5c000000,
+ 0x84000012, 0x00000000, 0x00000000, 0x00000000, 0x8000ffa0, 0xc11c0002, 0xc000082c, 0xcd040e08,
+ 0x8000f9b8, 0xc2000000, 0xdf600040, 0x5e200080, 0x84000272, 0x00000000, 0xc161fffe, 0x5955fffe,
+ 0x15400000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xc000480c,
+ 0xca000000, 0xc0004910, 0xca400000, 0xc000492c, 0xca800000, 0xc000498e, 0xcac00000, 0xc121fffe,
+ 0x5911fef4, 0x15000000, 0x76610000, 0x76a10000, 0x762d6000, 0x840001aa, 0xc0004926, 0xca400000,
+ 0xc201fffe, 0x762d6000, 0x5a640002, 0x6ae50010, 0x5f200000, 0x84000002, 0x6a250000, 0x8000fff8,
+ 0xc6e00000, 0x62014008, 0xc0004926, 0xce800000, 0xc161fffe, 0x5955fffe, 0x15400000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xc000498e, 0xca400000, 0xc2000002,
+ 0x6a290000, 0x7e010000, 0x76252000, 0xce400000, 0xc121fffe, 0x5911fef4, 0x15000000, 0x6eb4a000,
+ 0x46b5a000, 0x5b744e20, 0x58340002, 0xc2000000, 0xca0000e0, 0x58340036, 0xc2400000, 0xca400080,
+ 0x6eb0a000, 0x46b18000, 0x5b300e56, 0x5b300004, 0x6e642000, 0x4225e000, 0xc39a8024, 0xc7380068,
+ 0xc6b81c20, 0x99006840, 0xdb980000, 0xdbd80001, 0x00000000, 0xc2000000, 0xdf600040, 0x5e200080,
+ 0x840002c2, 0x00000000, 0xc161fffe, 0x5955fffe, 0x15400000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0xc000490e, 0xca000000, 0xc000492a, 0xca400000, 0xc0004990,
+ 0xcb000000, 0xc000498a, 0xcac00000, 0xc121fffe, 0x5911fef4, 0x15000000, 0x76318000, 0x76718000,
+ 0x84000202, 0xc201fffe, 0x76318000, 0x5aec0002, 0x6b2d0010, 0x5ea00000, 0x84000002, 0x6a2d0000,
+ 0x8000fff8, 0xc7200000, 0x62016008, 0xc000498a, 0xcec00000, 0xc161fffe, 0x5955fffe, 0x15400000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xc0004990, 0xca400000,
+ 0xc2000002, 0x6a2d0000, 0x7e010000, 0x76252000, 0xce400000, 0xc121fffe, 0x5911fef4, 0x15000000,
+ 0x6ef4a000, 0x46f5a000, 0x5b744e20, 0x58340010, 0xc2000000, 0xca0000e0, 0x58340008, 0xc2400000,
+ 0xca420080, 0x5834000e, 0xc2800000, 0xca832018, 0xc3c00000, 0x467c8000, 0x6e644010, 0xc7e80004,
+ 0x42250000, 0x4229e000, 0xc39a8008, 0x58340008, 0xcb801040, 0x58340008, 0xc2800000, 0xca810018,
+ 0x6ee0a000, 0x46e10000, 0x5a20000a, 0x5a200e28, 0x42290000, 0xc6380068, 0xc6f81c20, 0x99006840,
+ 0xdb980000, 0xdbd80001, 0x00000000, 0xc000495c, 0xc8400000, 0xc3400000, 0xc3c00002, 0x7bc42000,
+ 0xcc400000, 0x6c78a000, 0x4479c000, 0x5bb84e20, 0x58380034, 0xcb410040, 0xc0000a28, 0xc3000000,
+ 0xcb040030, 0xc0000a14, 0xc2c00000, 0x43358000, 0xcac40030, 0xc000490e, 0xca800000, 0x5eec0002,
+ 0x46f18000, 0x8800f348, 0x6bc5e000, 0x77e94000, 0x8400f330, 0x6c7ca000, 0x447de000, 0x5bfc4e20,
+ 0x583c0008, 0xc2000000, 0xca020080, 0xc00049aa, 0x00000000, 0xca800001, 0xca400000, 0xc0001008,
+ 0xce800000, 0xc0001006, 0xce400000, 0x583c000a, 0xca400000, 0x00000000, 0xc000100a, 0xce400000,
+ 0xc2400006, 0xc0001000, 0xce400000, 0xc2600982, 0x5a643b6e, 0xc0001002, 0xce400000, 0x583c000c,
+ 0xca400000, 0x00000000, 0xc0001004, 0xce400000, 0x583c000e, 0xcb800000, 0x00000000, 0xc2400000,
+ 0xc7a40080, 0xc2800000, 0xc7aae028, 0xdaa00001, 0x583c0034, 0xcb800000, 0x00000000, 0xc2c00000,
+ 0xc7ad0040, 0xc0004978, 0xcec00000, 0xc0800000, 0xc7880040, 0xc3400000, 0xc7b60040, 0xc0004980,
+ 0xcf400000, 0x4625c000, 0x43a9c000, 0xc2400000, 0xc000497c, 0xce400000, 0xac2c0001, 0xc2800000,
+ 0x00000000, 0x8000fff8, 0xc2800002, 0xc0004976, 0xce800000, 0xc2c00000, 0xc34000a0, 0xdb5c0001,
+ 0xc3400002, 0xc000497a, 0xcf400000, 0x5f600000, 0x84000168, 0xde280001, 0xc6a00000, 0x46b9c000,
+ 0x583c0000, 0xc2800000, 0xca830040, 0xc0000a28, 0xc3000000, 0xcb040030, 0xc3400000, 0xc0004976,
+ 0x47298000, 0x88000052, 0xcf400000, 0x58880002, 0xc3000000, 0xc0000a14, 0xcb040030, 0x00000000,
+ 0x00000000, 0xb4b00188, 0x00000000, 0xc0800000, 0x00000000, 0x80000170, 0xc0004980, 0xcb400000,
+ 0x00000000, 0x00000000, 0x5af40002, 0xafec0080, 0x00000000, 0xc2c00000, 0xc000497a, 0xacec0001,
+ 0x00000000, 0x00000000, 0xac2c007f, 0xc2800000, 0xce800000, 0x80000000, 0xc2800002, 0xce800000,
+ 0x5f6c0000, 0x840000d0, 0x00000000, 0x8000fee8, 0x5f780082, 0x88000240, 0xc3000002, 0xc000497c,
+ 0xcf000000, 0xc2800080, 0xc1000000, 0xdd110040, 0x45294000, 0x46b94000, 0x880001c0, 0x4391a000,
+ 0xc0004980, 0xcf400000, 0x6f684010, 0x6f77c000, 0x6f77c010, 0xc0004840, 0x40280000, 0xca800000,
+ 0xc3000000, 0x6f506000, 0x6a908010, 0xc5300040, 0xdb1c0001, 0x8000fe18, 0xc3400000, 0xc0000a10,
+ 0xcb440068, 0x6cb04000, 0x6f288000, 0x6f744000, 0x42b14000, 0x43694000, 0xc3400000, 0xc6b44068,
+ 0xc0004000, 0x40340000, 0xc321e000, 0xcf000000, 0x5aa80008, 0x42ad4000, 0xc3400000, 0xc6b44068,
+ 0xc0004000, 0x40340000, 0xca400000, 0xc3000000, 0xc6f00010, 0xc1400000, 0xddd40041, 0x6f306000,
+ 0xc13001fe, 0x69308010, 0x7d008000, 0x75252000, 0x6d570000, 0x6970a010, 0x42552000, 0xce400000,
+ 0x5aa80002, 0x5aec0002, 0xafec0080, 0x00000000, 0xc2c00000, 0x5f6c0000, 0x84000100, 0x00000000,
+ 0x80000028, 0x4391a000, 0x5f740080, 0xc0004980, 0xcf400000, 0xc3000004, 0xc000497a, 0xcf000000,
+ 0x58880002, 0xc3400000, 0xc0000a14, 0xcb440030, 0x00000000, 0x00000000, 0xb4b4fff8, 0x00000000,
+ 0xc0800000, 0xc3400000, 0xc0000a10, 0xcb440068, 0x6cb04000, 0x6f248000, 0x6f744000, 0x42712000,
+ 0x43654000, 0xc3400000, 0xc6b44068, 0xc0004000, 0x40340000, 0xc3201e00, 0xcf000000, 0x5aa80008,
+ 0x42ad4000, 0xc000100c, 0xcb400000, 0xc3000000, 0x00000000, 0xc7340068, 0xc300fffe, 0xc7341078,
+ 0xcf400000, 0xc000100e, 0xcb400000, 0xc3000e28, 0x00000000, 0xc7340068, 0xc300fffe, 0xc7341078,
+ 0xcf400000, 0xc0001010, 0xcb400000, 0xc3000002, 0x00000000, 0xc7341a08, 0xc7341808, 0xc3000000,
+ 0xc7341908, 0xc6b40078, 0xcf400000, 0xc0004982, 0xce800000, 0x6c64a000, 0x44652000, 0x5a64000a,
+ 0xc0001012, 0xcb400000, 0xc2800002, 0x00000000, 0xc6740268, 0xc6340010, 0xc000497c, 0xcb000000,
+ 0xc6b41808, 0xc6b41b08, 0xc6b41c08, 0xc6b41d08, 0xc7341e08, 0xdd680001, 0x7e814000, 0x6eab2010,
+ 0x77294000, 0xc6b41f08, 0xc2800000, 0xc6b41908, 0xc3000080, 0x46f18000, 0xc0004982, 0xc9000000,
+ 0x47b14000, 0x880000ea, 0x41388000, 0xcd000000, 0xc7b41040, 0xc0004994, 0xce800000, 0xde100001,
+ 0x46108000, 0x84000098, 0xc1000000, 0xdd110040, 0x41388000, 0x412c8000, 0x5d100080, 0xc0004980,
+ 0xcd000000, 0xc1000002, 0xc000497c, 0xcd000000, 0xc5341e08, 0xdd500001, 0x7d008000, 0xc5373f08,
+ 0xc000497a, 0xc9000000, 0x42390000, 0x43adc000, 0x59100002, 0xcd000000, 0x80000038, 0x42390000,
+ 0x80000028, 0xc7341040, 0x41308000, 0xcd000000, 0x42310000, 0xc1000000, 0xc0004994, 0xcd000000,
+ 0xc0001012, 0xcf400000, 0xc000493c, 0xce000000, 0xc0004984, 0xcf800000, 0xc000497a, 0xca400000,
+ 0xc000497c, 0xca800000, 0x6c7ca000, 0x447de000, 0x5bfc4e20, 0xc0004976, 0xcac00000, 0xc0004978,
+ 0xca000000, 0x5eec0002, 0x84000072, 0x42250000, 0xc2400000, 0xc000497a, 0xce400000, 0x583c0000,
+ 0xc2c00000, 0xcac30040, 0x00000000, 0x00000000, 0x462d6000, 0x88000002, 0x00000000, 0xac280002,
+ 0xc000497a, 0xce000000, 0xc2000000, 0x5fa80000, 0x840001c2, 0x00000000, 0x6c508000, 0xc0004880,
+ 0x40100000, 0x58000018, 0xc9000000, 0x00000000, 0x00000000, 0x59100002, 0xcd000000, 0x583c000e,
+ 0xc2c00000, 0xcac00080, 0xc1000000, 0xdd532209, 0x42d16000, 0x6c508000, 0xc0004880, 0x40100000,
+ 0x5800001a, 0xc9000000, 0x00000000, 0x00000000, 0x412c8000, 0xcd000000, 0x990068d0, 0xd8580000,
+ 0xdbd80001, 0x00000000, 0x99006618, 0xc000491c, 0xc1400000, 0xc9420050, 0xc000491c, 0x99006ad0,
+ 0xc9400001, 0xc9800000, 0x00000000, 0x99006840, 0xd9580000, 0xd9980001, 0x00000000, 0xc161fffe,
+ 0x5955fffe, 0x15400000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x98c06490, 0xd8580000, 0xdbd80001, 0xc4580000, 0xc121fffe, 0x5911fef4, 0x15000000, 0xace80003,
+ 0xc000493c, 0xcb400000, 0x00000000, 0xc3000000, 0xc7701080, 0x8000fff8, 0xc3000000, 0x583c0008,
+ 0xcf001080, 0x6e210000, 0x583c0034, 0xce000840, 0xc0004980, 0xcb800000, 0x583c0034, 0x00000000,
+ 0x6fba0000, 0xcf801040, 0xc000490e, 0xca000000, 0xc2c00002, 0x6ac56000, 0x72e10000, 0xce000000,
+ 0x00000000, 0x00000000, 0x00000000, 0xa8e2ffc8, 0x00000000, 0xc1220002, 0xd90c0000, 0x5fa80000,
+ 0x840006fa, 0xc00049a8, 0xca000000, 0x583c000a, 0x00000000, 0xce000000, 0xc221fffe, 0x5a21fffe,
+ 0x583c000c, 0xce000000, 0xc0001004, 0xca000000, 0x00000000, 0x583c0012, 0x7e010000, 0xce000000,
+ 0xa97000c1, 0x00000000, 0x00000000, 0xa97200a9, 0xc0001010, 0xc2740000, 0xce401a08, 0x6c64a000,
+ 0x44652000, 0x5a64000a, 0x6e644000, 0xc0001012, 0xce400078, 0xc2600008, 0xce401040, 0xc27e0002,
+ 0xce401f08, 0xc2760002, 0xce401b08, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xa8e2ffc8, 0x00000000, 0xc1220002, 0xd90c0000, 0xc1000000, 0xdd110040, 0x5d100000, 0x840003fa,
+ 0xc0004982, 0xca000000, 0xc0004984, 0xca400000, 0xc2800000, 0xc361fffe, 0x5b75fffe, 0xa96afffb,
+ 0xdfec0000, 0xc6ec1080, 0x7b6d6000, 0x6c40a000, 0x44400000, 0x58004e20, 0x58000014, 0xcec00000,
+ 0xa972fffb, 0x5c000002, 0xcec00000, 0xc0001010, 0xc2f40002, 0xcec01a08, 0x6c6ca000, 0x446d6000,
+ 0x5aec000a, 0x6eec4000, 0xc0001012, 0xcec00078, 0xc0004994, 0xc9800000, 0xc1400000, 0xdd150040,
+ 0xc55c0000, 0x45588000, 0x00000000, 0xc59c0004, 0x5d1c0000, 0x840000ba, 0xc0001012, 0xc5d01040,
+ 0xcd001040, 0xc2f60002, 0xcec01b08, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xa8e2ffc8, 0x00000000, 0xc1220002, 0xd90c0000, 0x45588000, 0x8800003a, 0xc0004994, 0xcd000000,
+ 0xc0004980, 0xcbc00000, 0x42150000, 0xc0004982, 0xce000000, 0x5ffc0000, 0x84000200, 0x58880002,
+ 0xc3800000, 0xc0000a14, 0xcb840030, 0xc3c00000, 0xc0000a10, 0xb4b8fff8, 0x00000000, 0xc0800000,
+ 0xcbc40068, 0x6cb84000, 0x6fac8000, 0x6ffc4000, 0x42f96000, 0x43ed0000, 0xc3400000, 0xc6344068,
+ 0xc0004000, 0x40340000, 0xc2a1e000, 0xce800000, 0x5a200008, 0xc0004980, 0xcbc00000, 0xc3400000,
+ 0xc0004840, 0x6ff84010, 0xc7f40010, 0x40380000, 0xcb800000, 0xc2800000, 0x6f506000, 0x6b908010,
+ 0xc52c1840, 0xc3400000, 0xc6344068, 0xc0004000, 0x40340000, 0xcec00000, 0x5a200002, 0x5ffc0000,
+ 0x8400007a, 0xc0001010, 0xc62c0078, 0xcec00078, 0xc0001012, 0xc7ec1040, 0xcec01040, 0xc2f60002,
+ 0xcec01b08, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xa8e2ffc8, 0x00000000,
+ 0xc1220002, 0xd90c0000, 0xc0004994, 0xc100007e, 0x47d08000, 0xcd000000, 0x423d0000, 0xc0004982,
+ 0xce000000, 0xc0004994, 0xca000000, 0xc0004980, 0xca400000, 0x5e200000, 0x84000142, 0xc2000000,
+ 0xc2800000, 0x5a640002, 0xc6684030, 0xc0004982, 0xcb000000, 0xc0004000, 0xc2c00000, 0xc72c4068,
+ 0x402c0000, 0x6e67c000, 0x6e67c010, 0x5ee40002, 0x84000022, 0x5ee40004, 0x84000032, 0x5ee40006,
+ 0x84000042, 0x00000000, 0x80000048, 0xce0000c0, 0x5aa80002, 0x5b300006, 0x80000028, 0xce000080,
+ 0x5aa80002, 0x5b300004, 0x80000008, 0xce000040, 0x5aa80002, 0x5b300002, 0x5ee80020, 0x8400003a,
+ 0xc0004000, 0xc2c00000, 0xc72c4068, 0x402c0000, 0xce000000, 0x5aa80002, 0x5b300008, 0x8000ffa0,
+ 0x00000000, 0x80000028, 0x583c000a, 0xd7c00000, 0xc0001004, 0xca400000, 0x00000000, 0x583c000c,
+ 0xce400000, 0xc000497a, 0xca400000, 0xc2800002, 0xc0000a28, 0xc6780930, 0xc6b80808, 0xcf840838,
+ 0x6c7ca000, 0x447de000, 0x5bfc4e20, 0x583c0034, 0xc4900040, 0xcd000040, 0x8000e400, 0x6c6c8000,
+ 0x6c544000, 0x42d56000, 0x5aec4a00, 0xc0000824, 0xca040000, 0x6ca48000, 0x42492000, 0xc3000000,
+ 0xc3400000, 0x42250000, 0x58204000, 0xca400000, 0x5a200002, 0xda240001, 0xc2800000, 0xc000495e,
+ 0xce800000, 0xda600000, 0xc2800000, 0xc66b0040, 0xdaa80000, 0x582c0010, 0x6f206010, 0x40200000,
+ 0xd8280001, 0xca000000, 0xc2400000, 0xc7240018, 0x6e644000, 0xda640000, 0x6a254010, 0xc3c00000,
+ 0xc6bc0020, 0xc3800000, 0xdea00000, 0x5e60001e, 0x84000012, 0x5e6001e0, 0x84000002, 0x00000000,
+ 0x80000068, 0xc7f80000, 0x5e7c0008, 0x84000052, 0x5bbc0002, 0x5e780008, 0x84000010, 0x5b740002,
+ 0xc0004960, 0xcf000000, 0x80000018, 0x5e780006, 0x8800000a, 0xc2800002, 0xc000495e, 0xce800000,
+ 0xde800001, 0xca800000, 0xde600000, 0xc240001e, 0x6a612000, 0x7e412000, 0x76694000, 0x6ba12000,
+ 0x72694000, 0xce800000, 0x5e300080, 0x840000a2, 0xc2000000, 0xc7200010, 0x5e600000, 0x84000040,
+ 0xde600001, 0x58204000, 0xca400000, 0x5a200002, 0xda240001, 0xc2800000, 0xc66b0040, 0xdaa80000,
+ 0xda600000, 0x80000020, 0xc2800000, 0x6e206000, 0xde240000, 0x6a610000, 0xc62b0040, 0xdaa80000,
+ 0x5b300002, 0x8000fdc8, 0xc2000000, 0x582c0020, 0xca020080, 0x00000000, 0xc2400000, 0x5a200002,
+ 0xc6241080, 0xce401080, 0xc000480e, 0xca800000, 0x5e740000, 0x84000148, 0x46292000, 0x8800dec8,
+ 0xc2400000, 0xc0000808, 0xca440018, 0x582c0010, 0xc1400000, 0xcd400001, 0xcd400001, 0xcd400001,
+ 0xcd400001, 0xcd400001, 0xcd400001, 0xcd400001, 0xcd400001, 0xcd400020, 0x582c0020, 0xce001080,
+ 0xc2000010, 0x5a640002, 0xb624fff8, 0x00000000, 0xc2400000, 0xc6600018, 0xc0000808, 0xce040018,
+ 0xc0004956, 0xca400000, 0xc11c0000, 0xc000082c, 0xcd040e08, 0xc6600930, 0xc2400000, 0xc6600030,
+ 0xc0000838, 0xce040000, 0xc2400002, 0xc0004958, 0xce400000, 0xc11c0002, 0xc000082c, 0xcd040e08,
+ 0x8000dd80, 0xc000495e, 0xca000000, 0x5e740002, 0x8400dd60, 0x5e200000, 0x8400dd50, 0xc0004960,
+ 0xca400000, 0xc2200004, 0x582c0002, 0xce001010, 0xc2000082, 0x46610000, 0xc6280038, 0xc0000810,
+ 0xce840038, 0x99006f68, 0x582c0002, 0xc9400000, 0xc1a20000, 0x5e640000, 0x8400feb8, 0x00000000,
+ 0x8000dcc0, 0x6c6c8000, 0x6c544000, 0x42d56000, 0x5aec4a00, 0xc000487c, 0xc8040000, 0x00000000,
+ 0x00000000, 0x40080000, 0xcb800000, 0xc4240000, 0x00000000, 0xa7860180, 0xc3c00000, 0xc2000000,
+ 0x582c000c, 0xca010040, 0x6c508000, 0xc0004880, 0x40100000, 0x58000016, 0xc9000000, 0x00000000,
+ 0x00000000, 0x59100002, 0xcd000000, 0x5a200002, 0x582c000c, 0xc6100840, 0xcd000840, 0x5e600002,
+ 0x84000008, 0xc2200004, 0x582c0002, 0xce001010, 0x5e600008, 0x84000048, 0xc2200002, 0x582c0002,
+ 0xce001010, 0x582c000c, 0xcfc00840, 0xc2220002, 0xc0000a14, 0xce041108, 0xc22001a2, 0xc0000a1c,
+ 0xce041040, 0x6c6c8000, 0x6c544000, 0x42d56000, 0x5aec4a00, 0x582c0004, 0xcb000000, 0xc3400000,
+ 0x00000000, 0xa7060008, 0xcf400308, 0xc3100002, 0xc0000838, 0xcf040808, 0x582c000c, 0xcf401008,
+ 0x8000dac0, 0x582c000c, 0xcfc00840, 0xc2000000, 0xc7a06018, 0x5e200000, 0x84001e18, 0x6c6c8000,
+ 0x6c544000, 0x42d56000, 0x5aec4a00, 0xc000487c, 0xc8040000, 0x00000000, 0x00000000, 0x40080000,
+ 0xcb800000, 0xc4240000, 0x00000000, 0xc2800000, 0xc3400000, 0xc7b5c038, 0xc0004970, 0xcf400000,
+ 0xc2400000, 0xc7a4e038, 0xc000496c, 0xce400000, 0xc3000000, 0xc7b00018, 0xc3c00004, 0xc000496e,
+ 0xcfc00000, 0x582c000c, 0xca000000, 0xc2400002, 0xc0004964, 0xce400000, 0xa6200352, 0x00000000,
+ 0x5e700004, 0x840000d2, 0x5e700006, 0x84000068, 0xc2000002, 0x582c0002, 0xce000008, 0xc0000a14,
+ 0xce841108, 0x6c508000, 0xc0004880, 0x40100000, 0x58000014, 0xc9000000, 0x00000000, 0x00000000,
+ 0x59100002, 0xcd000000, 0x80001c68, 0x5e70000a, 0x84000028, 0xc2000000, 0x582c0002, 0xce000008,
+ 0xc2220002, 0xc0000a14, 0xce041108, 0x8000ff58, 0x5e700008, 0x84000210, 0xc2200002, 0x582c000c,
+ 0xce001008, 0x6c508000, 0xc0004880, 0x40100000, 0x58000012, 0xc9000000, 0x00000000, 0x00000000,
+ 0x59100002, 0xcd000000, 0x5e340002, 0x6c508000, 0xc0004880, 0x40100000, 0x58000010, 0xc9000000,
+ 0x00000000, 0x00000000, 0x41208000, 0xcd000000, 0xc0000a14, 0xce841108, 0xc0004970, 0xcb400000,
+ 0x6c6c8000, 0x6c544000, 0x42d56000, 0x5aec4a00, 0x582c000e, 0xc4900040, 0xcd000040, 0x582c000e,
+ 0xc7500840, 0xcd000840, 0xc2800000, 0x582c0004, 0xce801080, 0x582c0004, 0xce800008, 0xc00049a0,
+ 0xca400000, 0x00000000, 0x582c0006, 0xce400000, 0xc261fffe, 0x5a65fffe, 0x582c0024, 0xce400000,
+ 0xc2060002, 0x582c0004, 0xce000308, 0xc2400002, 0xc0004958, 0xce400000, 0xc0004878, 0xc8040000,
+ 0x6c908000, 0x41088000, 0x40100000, 0x58000020, 0xc9000000, 0x582c0026, 0x00000000, 0xcd000000,
+ 0x800019f8, 0x00000000, 0x6c508000, 0xc0004880, 0x40100000, 0x58000016, 0xc9000000, 0x00000000,
+ 0x00000000, 0x59100002, 0xcd000000, 0x8000fad8, 0x5e700000, 0x840000a8, 0xc3400082, 0xc0004970,
+ 0xcf400000, 0xc2400080, 0xc000496c, 0xce400000, 0xc3c00002, 0xc000496e, 0xcfc00000, 0xc2400000,
+ 0xc0004964, 0xce400000, 0xc0004878, 0xc8040000, 0x6c908000, 0x41088000, 0x40100000, 0x58000020,
+ 0xc9000000, 0x582c0026, 0x00000000, 0xcd000000, 0x80000060, 0x5e700002, 0x84000040, 0xc3400082,
+ 0xc0004970, 0xcf400000, 0xc3c00004, 0xc000496e, 0xcfc00000, 0xc2200000, 0x582c000c, 0xce001008,
+ 0x80000018, 0x5e700004, 0x8400fe68, 0xc2600002, 0x582c000c, 0xce401008, 0xc0000a14, 0xce841108,
+ 0xc000496c, 0xca400000, 0x6c508000, 0xc0004880, 0x40100000, 0x58000012, 0xc9000000, 0x00000000,
+ 0x00000000, 0x59100002, 0xcd000000, 0xc000496e, 0xcbc00000, 0x00000000, 0x00000000, 0x47f50000,
+ 0x46610000, 0x6c508000, 0xc0004880, 0x40100000, 0x58000010, 0xc9000000, 0x00000000, 0x00000000,
+ 0x41208000, 0xcd000000, 0x6c6c8000, 0x6c544000, 0x42d56000, 0x5aec4a00, 0x582c0004, 0xca000000,
+ 0x00000000, 0x00000000, 0xa60016ea, 0x00000000, 0x6c6c8000, 0x6c544000, 0x42d56000, 0x5aec4a00,
+ 0xc3000000, 0x582c0004, 0xcf000308, 0x582c0000, 0xcb002018, 0xc3c00000, 0x582c0004, 0xcbc20080,
+ 0xc000491a, 0xcf000000, 0xc000493c, 0xcfc00000, 0x582c0008, 0xcb800000, 0x582c000a, 0xca400000,
+ 0xc0004930, 0xcf800000, 0xc0004932, 0xce400000, 0x5ffc0000, 0x840001d8, 0x00000000, 0xa7be00e2,
+ 0xc2800000, 0x6f206000, 0x47210000, 0x5a204c80, 0x5820000c, 0xca800028, 0x00000000, 0x00000000,
+ 0x5ea80000, 0x840000fa, 0x00000000, 0xc161fffe, 0x5955fffe, 0x15400000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x99006330, 0xc000491a, 0xc9400000, 0x00000000,
+ 0xc121fffe, 0x5911fef4, 0x15000000, 0xc0004930, 0xcb800000, 0xc0004932, 0xca400000, 0xc4781110,
+ 0xc0004930, 0xcf800000, 0x582c0008, 0xcf800000, 0x582c000a, 0xce400000, 0xc7b6e110, 0x582c0004,
+ 0xcf400110, 0x80000078, 0x00000000, 0x6c508000, 0xc0004880, 0x40100000, 0x5800000c, 0xc9000000,
+ 0x00000000, 0x00000000, 0x59100002, 0xcd000000, 0xc2000002, 0x582c0004, 0xce000008, 0xc0000838,
+ 0xc2500002, 0xce440808, 0x80001430, 0x6c7c8000, 0x6c544000, 0x43d5e000, 0x5bfc4a00, 0x583c0006,
+ 0xca000000, 0xc00049a2, 0x00000000, 0xca800001, 0xca400000, 0xc0001008, 0xce800000, 0xc0001006,
+ 0xce400000, 0xc000100a, 0xce000000, 0xc2400006, 0xc0001000, 0xce400000, 0xc2600982, 0x5a643b6e,
+ 0xc0001002, 0xce400000, 0x583c0024, 0xca400000, 0x00000000, 0xc0001004, 0xce400000, 0xc0004862,
+ 0xc2000000, 0xca000080, 0xc360fffe, 0xc0004862, 0xce000000, 0xc0000824, 0xcb440068, 0x00000000,
+ 0xc000100e, 0xcf400000, 0xc3801600, 0xc2400200, 0x6e644000, 0xc6781078, 0xc000100c, 0xcf800000,
+ 0xc3200a00, 0xc0001010, 0xcf001818, 0xc2e06200, 0xc0001012, 0xcec01840, 0xc2000000, 0x583c0004,
+ 0xca002010, 0xc2800000, 0xc0004966, 0xce000000, 0xc6240000, 0xc3000000, 0xc000496a, 0xcf000000,
+ 0xc0004974, 0xcf000000, 0xc000493c, 0xcb400000, 0x583c000e, 0x00000000, 0x5f740000, 0x84000168,
+ 0xc3400000, 0xcb410040, 0xc3000002, 0xc000496a, 0x5fb40080, 0x8400013a, 0xcf000000, 0x583c000e,
+ 0xc2c00000, 0xcac00040, 0xc3800080, 0x4779c000, 0xc0004974, 0xcf800000, 0xc0001012, 0x6fba0000,
+ 0xcf801040, 0x6fba0010, 0x43a5c000, 0x5b380006, 0x6f284010, 0xc7a40010, 0x6eec4000, 0x6ef08000,
+ 0x432d8000, 0x43358000, 0x5b300008, 0xc0001012, 0xc7100078, 0xcd000078, 0xc2000200, 0xc2c00000,
+ 0xdf6d0050, 0x46e16000, 0x46ad6000, 0x8800ffca, 0xc2000000, 0xc0004862, 0xca000268, 0x00000000,
+ 0x583c0004, 0xca002010, 0xc3360002, 0xc0001010, 0xce000078, 0xc0001012, 0xcf001b08, 0xc0004974,
+ 0xcb800000, 0x00000000, 0x00000000, 0x5fb80000, 0x8400002a, 0x00000000, 0x00000000, 0x00000000,
+ 0xa8e2ffc8, 0x00000000, 0xc1220002, 0xd90c0000, 0xc000496c, 0xcac00000, 0x00000000, 0x00000000,
+ 0x426dc000, 0x5b380006, 0x6f304010, 0xc7a40010, 0xc0004968, 0xce400000, 0xc000496e, 0xcb400000,
+ 0x6ca44000, 0x6e608000, 0x42250000, 0x5a200006, 0x42350000, 0xc0001012, 0xc6100078, 0xcd000078,
+ 0x6eee0000, 0xcec01040, 0xc2000200, 0xc2c00000, 0xdf6d0050, 0x46e16000, 0x42b14000, 0x46ad6000,
+ 0x8800ffc2, 0xc000493c, 0xcb400000, 0xc0000838, 0xc3100002, 0x5f740000, 0x84000048, 0xcf040808,
+ 0xc0004974, 0xcb800000, 0x00000000, 0x00000000, 0x5fb80000, 0x84000052, 0xc0001012, 0xc3360002,
+ 0xcf001b08, 0x80000088, 0x583c0022, 0xcb400000, 0xc0004862, 0xca000000, 0x00000000, 0xc0005600,
+ 0x40200000, 0xcf400000, 0xc2000000, 0xc0004862, 0xca000268, 0x00000000, 0x583c0004, 0xca002010,
+ 0xc3360002, 0xc0001010, 0xce000078, 0xc0001012, 0xcf001b08, 0xc0004968, 0xcbc00000, 0xc0004964,
+ 0xca400000, 0xc7e00000, 0x00000000, 0x5e640000, 0x8400fffa, 0xc2000000, 0xc0004974, 0xca400000,
+ 0xc000496c, 0xca800000, 0xc000493c, 0xcb800000, 0x42698000, 0x00000000, 0x43b1a000, 0x5ef40080,
+ 0x88000182, 0xc0004966, 0xcac00000, 0x6c648000, 0x6c544000, 0x42552000, 0x5a644a00, 0x58240000,
+ 0x436da000, 0x4635a000, 0xc2400000, 0xca420080, 0x00000000, 0x00000000, 0x47652000, 0x8800010a,
+ 0x432d8000, 0x46318000, 0x8800fff8, 0xc3000000, 0x5b300006, 0x6f304010, 0xc000493a, 0xcf000000,
+ 0xc0004932, 0xc2400000, 0xca4000e0, 0x00000000, 0x6fb84010, 0x42792000, 0xc000491e, 0xce400000,
+ 0xc0004862, 0xca800000, 0x00000000, 0xc2c0000a, 0xc6e80d78, 0xc7281050, 0xc000491c, 0xce800000,
+ 0x6c708000, 0x6c544000, 0x43158000, 0x5b304a00, 0x6f760000, 0x58300004, 0xcf401080, 0x6ffc2000,
+ 0x58300004, 0xcfc00110, 0x80000168, 0x6c708000, 0x6c544000, 0x43158000, 0x5b304a00, 0xc2800002,
+ 0x58300004, 0xce800008, 0x6c508000, 0xc0004880, 0x40100000, 0x5800000e, 0xc9000000, 0x00000000,
+ 0x00000000, 0x59100002, 0xcd000000, 0xc0004816, 0xc8000000, 0x00000000, 0x00000000, 0x5c000000,
+ 0x84000072, 0xc11c0000, 0xc000082c, 0xcd040e08, 0xc0004816, 0xc8000000, 0x00000000, 0x00000000,
+ 0x5c000000, 0x84000012, 0x00000000, 0x00000000, 0x00000000, 0x8000ffa0, 0xc11c0002, 0xc000082c,
+ 0xcd040e08, 0x00000000, 0x00000000, 0x00000000, 0xa8e2ffc8, 0x00000000, 0xc1220002, 0xd90c0000,
+ 0x80000a80, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xa8e2ffc8, 0x00000000, 0xc1220002,
+ 0xd90c0000, 0xc0004964, 0xca000000, 0x6c7c8000, 0x6c544000, 0x43d5e000, 0x5bfc4a00, 0xdfe40000,
+ 0x5e200002, 0x840006a0, 0x00000000, 0x583c0004, 0xc2800000, 0xca820080, 0xc0004930, 0xcac00000,
+ 0x00000000, 0x00000000, 0x6eece000, 0x6eefc010, 0x46e8a000, 0xc1000000, 0xdd500041, 0x6d106010,
+ 0x4514a000, 0xc1000000, 0xdd514209, 0x4514c000, 0xa9500181, 0xc00049a6, 0xca000000, 0xa94a0003,
+ 0x00000000, 0x6e660000, 0x6e660010, 0x46252000, 0x8400014a, 0x00000000, 0xc0004812, 0xc8000000,
+ 0x00000000, 0x00000000, 0x5c000000, 0x84000072, 0xc11c0000, 0xc000082c, 0xcd040e08, 0xc0004812,
+ 0xc8000000, 0x00000000, 0x00000000, 0x5c000000, 0x84000012, 0x00000000, 0x00000000, 0x00000000,
+ 0x8000ffa0, 0xc11c0002, 0xc000082c, 0xcd040e08, 0x6c508000, 0xc0004880, 0x40100000, 0x58000004,
+ 0xc9000000, 0x00000000, 0x00000000, 0x59100002, 0xcd000000, 0x6c508000, 0xc0004880, 0x40100000,
+ 0x58000006, 0xc9000000, 0x00000000, 0x00000000, 0x41148000, 0xcd000000, 0x800007d0, 0x00000000,
+ 0xa95203a1, 0xc0001004, 0xcb800000, 0xc3400000, 0xdd740041, 0x5f740000, 0x840000b8, 0xc1218e08,
+ 0x5911baf6, 0x47908000, 0x8400035a, 0x00000000, 0x6c508000, 0xc0004880, 0x40100000, 0x58000008,
+ 0xc9000000, 0x00000000, 0x00000000, 0x59100002, 0xcd000000, 0x6c508000, 0xc0004880, 0x40100000,
+ 0x5800000a, 0xc9000000, 0x00000000, 0x00000000, 0x41148000, 0xcd000000, 0x800006d0, 0x00000000,
+ 0xc000496c, 0xcb000000, 0x583c0026, 0xcac00000, 0xc0004878, 0xc8040000, 0x6c908000, 0x41088000,
+ 0x40100000, 0x58000002, 0xca800000, 0x00000000, 0x00000000, 0x6ea90000, 0x5d300008, 0x88000032,
+ 0x59300002, 0xc3000000, 0xc5300010, 0x6d104010, 0x40100000, 0xca800000, 0x5c000002, 0xcac00000,
+ 0x5d300000, 0x84000022, 0x6f246000, 0x6ae56000, 0xc1000040, 0x46512000, 0x6aa54010, 0x42e96000,
+ 0x583c0026, 0xcec00000, 0xc1218e08, 0x5911baf6, 0xc0001004, 0xcd000000, 0x593c0026, 0xc000100e,
+ 0xcd000068, 0xc1340000, 0xc0001010, 0xcd001a08, 0xc1200008, 0xa94a0003, 0xc0001012, 0xc1200004,
+ 0x59100004, 0xcd0000c0, 0xc1360002, 0xcd001b08, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0xa8e2ffc8, 0x00000000, 0xc1220002, 0xd90c0000, 0xc0001004, 0xc9000000, 0x00000000,
+ 0x00000000, 0x47908000, 0x8400009a, 0x00000000, 0x6c508000, 0xc0004880, 0x40100000, 0x58000008,
+ 0xc9000000, 0x00000000, 0x00000000, 0x59100002, 0xcd000000, 0x6c508000, 0xc0004880, 0x40100000,
+ 0x5800000a, 0xc9000000, 0x00000000, 0x00000000, 0x41148000, 0xcd000000, 0x80000410, 0x00000000,
+ 0x6c508000, 0xc0004880, 0x40100000, 0x58000000, 0xc9000000, 0x00000000, 0x00000000, 0x59100002,
+ 0xcd000000, 0x6c508000, 0xc0004880, 0x40100000, 0x58000002, 0xc9000000, 0x00000000, 0x00000000,
+ 0x41148000, 0xcd000000, 0xc0004930, 0xcd800080, 0xc3000000, 0x583c0008, 0xcf000000, 0x800000e8,
+ 0xc0001004, 0xca000000, 0x583c0006, 0xce400000, 0x583c0024, 0xce000000, 0xc0004814, 0xc8000000,
+ 0x00000000, 0x00000000, 0x5c000000, 0x8400008a, 0xc001fffe, 0x46400000, 0x84000070, 0xc11c0000,
+ 0xc000082c, 0xcd040e08, 0xc0004814, 0xc8000000, 0x00000000, 0x00000000, 0x5c000000, 0x84000012,
+ 0x00000000, 0x00000000, 0x00000000, 0x8000ffa0, 0xc11c0002, 0xc000082c, 0xcd040e08, 0xc0004862,
+ 0xc2000000, 0xca000080, 0xc000493a, 0xca400000, 0x00000000, 0x00000000, 0x42254000, 0x5ee80200,
+ 0x8800fffa, 0xc6e80000, 0xc0004000, 0x58001600, 0x40280000, 0xcb800000, 0x00000000, 0x583c0022,
+ 0xcf800000, 0xc0004862, 0xce800080, 0xc0001406, 0xcac00000, 0xc2800002, 0x00000000, 0xc66c1050,
+ 0xc6ac0a08, 0xcec00000, 0xc2000000, 0xdf600040, 0x5e600080, 0x8400ffd2, 0xc000491c, 0xca400000,
+ 0xc000491e, 0xca800000, 0x99006840, 0xda580000, 0xda980001, 0x00000000, 0xc0004964, 0xcbc00000,
+ 0x00000000, 0x00000000, 0x5ffc0000, 0x840000ea, 0xc2000000, 0xdf610050, 0x5e6001fe, 0x8800ffd0,
+ 0xc000491a, 0xc9800000, 0xc0004862, 0xc9400000, 0x6d9c6000, 0x459ce000, 0x59dc4c80, 0x990066a0,
+ 0xd9580000, 0xd9980001, 0xd9d40000, 0x99006618, 0xc000491c, 0xc1400000, 0xc9420050, 0xc2000000,
+ 0xdf600040, 0x5e600080, 0x8400ffd2, 0xc000491c, 0xca400000, 0xc000491e, 0xca800000, 0x99006840,
+ 0xda580000, 0xda980001, 0x00000000, 0xc0004970, 0xcb400000, 0x00000000, 0x00000000, 0x5e740082,
+ 0x8400e498, 0x00000000, 0x8000bc70, 0x00000000, 0x6c508000, 0xc0004880, 0x40100000, 0x58000016,
+ 0xc9000000, 0x00000000, 0x00000000, 0x59100002, 0xcd000000, 0x8000e0c8, 0x6c6c8000, 0x6c544000,
+ 0x42d56000, 0x5aec4a00, 0xc000487c, 0xc8040000, 0x00000000, 0x00000000, 0x40080000, 0xca000000,
+ 0xc4240000, 0x00000000, 0xa6060108, 0xc3c00000, 0xc2000000, 0x582c000c, 0xca010040, 0x00000000,
+ 0x00000000, 0x5a200002, 0xc6100840, 0xcd000840, 0x5e60000e, 0x8400bb58, 0xc2200000, 0x582c0002,
+ 0xce001010, 0x582c000c, 0xcfc00840, 0x582c0020, 0xcfc01080, 0x582c0010, 0xc1400000, 0xcd400001,
+ 0xcd400001, 0xcd400001, 0xcd400001, 0xcd400001, 0xcd400001, 0xcd400001, 0xcd400001, 0xcd400020,
+ 0xc000481a, 0xca000000, 0x00000000, 0x00000000, 0x5a200002, 0xce000000, 0x8000ba90, 0xc2200004,
+ 0x582c0002, 0xce001010, 0x582c000c, 0xcfc00840, 0x99006f68, 0x582c0002, 0xc9400000, 0xc1a20000,
+ 0x8000ba40, 0xc3e1fffe, 0x597dfffe, 0x593dfef4, 0x94000001, 0x00000000, 0x00000000, 0x00000000,
+ 0xc0800000, 0xdf4b0040, 0xc0004900, 0xcb800000, 0xc2000000, 0xc000490a, 0xa78000b0, 0xcbc00000,
+ 0xc1000000, 0xd9000001, 0xc1000002, 0xd90c0000, 0x6ff46000, 0x47f5a000, 0x5b744c80, 0xc2400000,
+ 0x58340004, 0xca400080, 0xc0004900, 0xce000008, 0x5a640002, 0x58340004, 0xc6500080, 0xcd000080,
+ 0xc0004914, 0xca400000, 0xc2000002, 0x6a3d0000, 0x72252000, 0xce400000, 0xc0000408, 0xce000000,
+ 0xa78200a8, 0xc0004908, 0xcbc00000, 0xc1000000, 0xd9000001, 0xc1000002, 0xd90c0000, 0x6ff4a000,
+ 0x47f5a000, 0x5b744e20, 0xc2800000, 0x58340006, 0xca800080, 0xc2000000, 0xc0004900, 0xce000108,
+ 0x5ea80002, 0x58340006, 0xc6900080, 0xcd000080, 0x5a7c0020, 0xc2000002, 0x6a250000, 0xc0000408,
+ 0xce000000, 0xdca80001, 0x5ea80000, 0x8400a7f8, 0x00000000, 0xa4800210, 0x00000000, 0xc3c00000,
+ 0xc000140e, 0xcbc00020, 0xc3400000, 0xc2400000, 0x6ff86000, 0x47f9c000, 0x5bb84c80, 0x58380008,
+ 0xcb400080, 0x58380006, 0xca400080, 0x5f740002, 0x58380008, 0xc7500080, 0xcd000080, 0xc2000000,
+ 0x58380004, 0xca020080, 0xc3000000, 0x5838000c, 0xcb000028, 0x5a640002, 0x46250000, 0x8400fff8,
+ 0xc2400000, 0x58380006, 0xc6500080, 0xcd000080, 0xc2000000, 0x5838000a, 0xca020080, 0x5b300002,
+ 0x5838000c, 0xc7100028, 0xcd000028, 0xc2420020, 0x5a200004, 0x46612000, 0x8400fff8, 0xc2000000,
+ 0x5838000a, 0xc6101080, 0xcd001080, 0xc000498c, 0xca400000, 0xc2000002, 0x6a3d0000, 0x72252000,
+ 0xce400000, 0x5f740000, 0x84000028, 0xc0004912, 0xca000000, 0xc2c00002, 0x6afd6000, 0x7ec16000,
+ 0x76e10000, 0xce000000, 0x5f300020, 0x84000028, 0xc0004924, 0xca000000, 0xc2c00002, 0x6afd6000,
+ 0x7ec16000, 0x76e10000, 0xce000000, 0xa4820050, 0xc2400000, 0xc000140e, 0xca408020, 0xc2000002,
+ 0xc0004900, 0xce000008, 0xc000490a, 0xce400000, 0xc1000000, 0xd9000001, 0xd8400080, 0xc1000004,
+ 0xd9000001, 0xa48402b8, 0x00000000, 0xc3c00000, 0xc000140e, 0xcbc10020, 0xc2800000, 0xc2000000,
+ 0x6ff8a000, 0x47f9c000, 0x5bb84e20, 0x58380036, 0xca800080, 0x58380006, 0xca020080, 0xc3400000,
+ 0x58380036, 0xcb420080, 0x5aa80002, 0x46290000, 0x8400fff8, 0xc2800000, 0x58380036, 0xc6900080,
+ 0xcd000080, 0x5f740002, 0x58380036, 0xc7501080, 0xcd001080, 0xc000498e, 0xca400000, 0xc2000002,
+ 0x6a3d0000, 0x72252000, 0xce400000, 0xc000492a, 0xca800000, 0x5e740000, 0x84000028, 0xc0004910,
+ 0xca000000, 0xc2c00002, 0x6afd6000, 0x7ec16000, 0x76e10000, 0xce000000, 0x6abd4010, 0xa6800112,
+ 0x00000000, 0x5838003a, 0xca000000, 0x58000002, 0xca400000, 0x5838000e, 0x00000000, 0xce000001,
+ 0xce400000, 0xc2400000, 0xdd250040, 0xc1000080, 0x46508000, 0xc2400000, 0xc6240080, 0x45250000,
+ 0x00000000, 0xc5240004, 0x5d240078, 0xc1000078, 0xc5240004, 0xc6600080, 0x5c000002, 0xce000080,
+ 0xc000492a, 0xca000000, 0xc2c00002, 0x6afd6000, 0x72e10000, 0xce000000, 0xc000492c, 0xca000000,
+ 0xc2c00002, 0x6afd6000, 0x72e10000, 0xce000000, 0x80000028, 0xc000492c, 0xca000000, 0xc2c00002,
+ 0x6afd6000, 0x7ec16000, 0x76e10000, 0xce000000, 0xa4880068, 0xc2c00000, 0xc000140e, 0xcac20020,
+ 0xc000490e, 0xca400000, 0xc2000002, 0x6a2d0000, 0x7e010000, 0x76252000, 0xce400000, 0xc0004990,
+ 0xca400000, 0xc2000002, 0x6a2d0000, 0x72252000, 0xce400000, 0xa4860050, 0xc2400000, 0xc000140e,
+ 0xca418020, 0xc2020002, 0xc0004900, 0xce000108, 0xc0004908, 0xce400000, 0xc1000000, 0xd9000001,
+ 0xd8400080, 0xc1000004, 0xd9000001, 0xc0001408, 0xcc800000, 0xc10e0002, 0xd90c0000, 0x8000f738,
+ 0xdfbc0001, 0xc0004992, 0x99006fa8, 0xc9400000, 0xc7d80000, 0x00000000, 0xc5700000, 0x5ef00020,
+ 0x88000140, 0x6f346000, 0x4735a000, 0x5b744c80, 0x58340008, 0xc2400000, 0xca400080, 0x00000000,
+ 0xc2000000, 0x5a640002, 0xc6500080, 0xcd000080, 0x58340004, 0xca000080, 0x00000000, 0x00000000,
+ 0x5e200002, 0xc6100080, 0xcd000080, 0xc0004912, 0xca800000, 0xc2400002, 0x6a712000, 0x72694000,
+ 0xce800000, 0x5e200000, 0x8400003a, 0xc000480a, 0xca000000, 0xc0000408, 0xca800000, 0x76610000,
+ 0x00000000, 0x72294000, 0xce800000, 0x80000020, 0xc0004914, 0xca000000, 0x7e412000, 0x00000000,
+ 0x76610000, 0xce000000, 0x800000b0, 0x6ef4a000, 0x46f5a000, 0x5b744e20, 0x58340036, 0xc2400000,
+ 0xca420080, 0x00000000, 0xc2000000, 0x5a640002, 0xc6501080, 0xcd001080, 0x58340006, 0xca000080,
+ 0x00000000, 0x00000000, 0x5a200002, 0xc6100080, 0xcd000080, 0xc0004910, 0xca400000, 0xc2000002,
+ 0x6a2d0000, 0x72252000, 0xce400000, 0xc2000002, 0x6a310000, 0xc000042a, 0xce000000, 0xc1040002,
+ 0xd90c0000, 0x00000000, 0x8000f4a0, 0x00000000, 0xc4980930, 0x9d000000, 0xc5580030, 0xc0000838,
+ 0xcd840000, 0xc1440200, 0xc1c01600, 0xc55c1078, 0xc000100e, 0x9d000000, 0xcd800000, 0xc000100c,
+ 0xcdc00000, 0xc0004862, 0xc9c00000, 0x00000000, 0x00000000, 0xd9d80001, 0xc0005600, 0x401c0000,
+ 0x5dc05800, 0x8800fffa, 0x5c000200, 0xcd800000, 0xc1f0000a, 0x71d4a000, 0xdd980000, 0xdd9c0001,
+ 0x41d8e000, 0xc5d40268, 0xc0001010, 0xcd400000, 0x6c9c8000, 0x449ce000, 0x449ce000, 0x59dc0004,
+ 0xc1601260, 0xc5d40268, 0x9d000000, 0xc0001012, 0xcd400000, 0x00000000, 0x00000000, 0xd9580000,
+ 0x6d586000, 0x4558c000, 0x59984c80, 0xd9980001, 0x5818000a, 0xc1800000, 0xc9800080, 0xc0005400,
+ 0x6d5ca000, 0x401c0000, 0x40180000, 0xc9400000, 0x58000002, 0x00000000, 0xc9c00000, 0xc0004930,
+ 0xcd400000, 0xc0004932, 0xcdc00000, 0x59980004, 0xc1c20020, 0xb59cfff8, 0x00000000, 0xc1800000,
+ 0xdd9c0001, 0x581c000a, 0xcd800080, 0x581c000c, 0xc1800000, 0xc9800028, 0xc1c00002, 0xdd940000,
+ 0x69d4e000, 0x5d980002, 0xcd800028, 0xc0004924, 0xc9800000, 0x00000000, 0x9d000000, 0x00000000,
+ 0x71d8c000, 0xcd800000, 0xc000492a, 0xc9400000, 0xc1c00002, 0x69d8e000, 0x7dc0c000, 0x7594a000,
+ 0xcd400000, 0xc000492c, 0xc9400000, 0xdd800001, 0x5800003a, 0x75d4a000, 0x840000f0, 0xc9400001,
+ 0xc9800000, 0xdd800001, 0x5800000e, 0x00000000, 0xcd400001, 0xcd800000, 0xc1800000, 0xdd190040,
+ 0xc1000080, 0x45908000, 0xc1800000, 0xc5580080, 0x4518a000, 0x00000000, 0xc5180004, 0x5d180078,
+ 0xc1000078, 0xc5180004, 0xc5940080, 0x5c000002, 0xcd400080, 0xc000492c, 0xc9400000, 0xc000492a,
+ 0xc9800000, 0x71d4a000, 0xc000492c, 0xcd400000, 0x71d8c000, 0xc000492a, 0xcd800000, 0x9cc00000,
+ 0x00000000, 0x00000000, 0x00000000, 0xc0004862, 0xc9800000, 0x00000000, 0xc1c00200, 0x4194c000,
+ 0x45d8e000, 0x8800fffa, 0xc5d80000, 0xc0004862, 0xcd800000, 0xc0001406, 0xc9800000, 0xc1c00002,
+ 0x9d000000, 0xc5d80a08, 0xc5581050, 0xcd800000, 0xc0004930, 0xc9800000, 0xc0004932, 0xc9c00000,
+ 0xc140000e, 0xc5581c20, 0xdd940000, 0xc0005600, 0x40140000, 0x5d405800, 0x8800fffa, 0x5c000200,
+ 0xcd800000, 0x58000002, 0x5d405800, 0x8800fffa, 0x5c000200, 0xcdc00000, 0xdd540000, 0xc1c00000,
+ 0x58140006, 0xc9c20080, 0xc1800000, 0x58140000, 0xc98000e0, 0x6ddc2000, 0xc000491e, 0x41d8e000,
+ 0xcdc00000, 0xdd980000, 0xc1c00022, 0xc5d80d78, 0xdd940001, 0xc5581c20, 0xc000491c, 0xcd800000,
+ 0xdd540000, 0xc1c00000, 0x58140006, 0xc9c20080, 0xc1800000, 0x58140004, 0xc9820080, 0x00000000,
+ 0x59dc0002, 0x459cc000, 0x8400fff8, 0xc1c00000, 0x9d000000, 0x58140006, 0xc5d81080, 0xcd801080,
+ 0xc0004860, 0xc9400000, 0xc1820080, 0xc1d00002, 0x58146b00, 0xd5800000, 0x58000002, 0xd5800001,
+ 0x59540004, 0xb558fff8, 0xc0004860, 0xc1400000, 0xcd400000, 0xdd980001, 0x9d000000, 0xdd940000,
+ 0xc0001404, 0xcdc00808, 0xc1c00000, 0xc1800200, 0x5d980004, 0xdf5d0050, 0x45d8a000, 0x8800ffda,
+ 0xdd800001, 0x5800000e, 0x00000000, 0xc9400001, 0xc9800000, 0xc1c00002, 0xc5d43f08, 0xc5d81e08,
+ 0xc0004862, 0xc9c00000, 0x00000000, 0x00000000, 0x581c5600, 0x5dc05800, 0x8800fffa, 0x5c000200,
+ 0xcd400000, 0x58000002, 0x5dc05800, 0x8800fffa, 0x5c000200, 0xcd800000, 0xc0004862, 0xc9c00000,
+ 0x00000000, 0xc15004c0, 0xc5d40068, 0xdd9c0000, 0xc5d41c20, 0xc1c00000, 0xdd800001, 0x58000038,
+ 0xc9c00080, 0xdd800001, 0xc1800000, 0x58000002, 0xc98000e0, 0x6ddc2000, 0xc000491c, 0x41d8e000,
+ 0xcd400001, 0xcdc00000, 0xdd940001, 0xc1c00000, 0x58140038, 0xc9c00080, 0xc1800000, 0x58140006,
+ 0xc9820080, 0x00000000, 0x59dc0002, 0x459cc000, 0x8400fff8, 0xc1c00000, 0x9d000000, 0x58140038,
+ 0xc5d80080, 0xcd800080, 0xc1c00000, 0xdf5c0040, 0x5ddc0080, 0x8400ffd2, 0x00000000, 0x9d000000,
+ 0x00000000, 0x00000000, 0x00000000, 0xc160fffe, 0xc0000a10, 0xc9440068, 0xc1a0fffe, 0x59980e28,
+ 0xc000100c, 0xcd400000, 0xc000100e, 0xcd800000, 0xc0004962, 0xc9800000, 0x00000000, 0xc170000a,
+ 0x7194a000, 0x6c988000, 0x4498c000, 0x4498c000, 0x59980004, 0xc5940278, 0xc0001010, 0xcd400000,
+ 0xc0004946, 0xc9400000, 0x00000000, 0x00000000, 0x6d58a000, 0x6d5c4000, 0x45d8c000, 0x4558c000,
+ 0xc000494a, 0xc9400000, 0xc0004948, 0xc9c00000, 0x4194c000, 0xc1400012, 0xc55c1820, 0x9d000000,
+ 0xc59c0270, 0xc0001012, 0xcdc00000, 0xc1400000, 0x58000014, 0xc9410040, 0xc0004950, 0xc9c00000,
+ 0xc5580000, 0xc5940840, 0xc5581080, 0xd9940000, 0xc000493c, 0xc9400000, 0xc0004954, 0xc9800000,
+ 0x59dc00a8, 0x455ce000, 0x41d8e000, 0x5d5c0030, 0x8800fff8, 0xc1c00030, 0xc1800000, 0xc5d84030,
+ 0xc1400000, 0xc5d40010, 0x5dd40002, 0x8400005a, 0x5dd40004, 0x84000082, 0x5dd40006, 0x840000aa,
+ 0x5dd80026, 0x840000d2, 0xdd540000, 0xdd800001, 0x58000008, 0x40180000, 0xcd400000, 0x59980002,
+ 0x8000ffa8, 0xdd540000, 0xdd800001, 0x58000008, 0x40180000, 0xcd4000c0, 0x59980002, 0x8000ff70,
+ 0xdd540000, 0xdd800001, 0x58000008, 0x40180000, 0xcd400080, 0x59980002, 0x8000ff38, 0xdd540000,
+ 0xdd800001, 0x58000008, 0x40180000, 0xcd400040, 0x59980002, 0x8000ff00, 0x00000000, 0x9d000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x58000014, 0xc9400000, 0xc0004954, 0xc9c00000, 0xc0004950,
+ 0xc9400080, 0xdd800001, 0x5800002a, 0x5d9c0000, 0x8400003a, 0x5d9c0002, 0x8400003a, 0x5d9c0004,
+ 0x84000052, 0xc55b0040, 0xc55c08c0, 0xcd800041, 0xcdc008c0, 0x80000048, 0xcd400000, 0x80000038,
+ 0xc55900c0, 0xc55c1840, 0xcd8000c1, 0xcdc01840, 0x80000010, 0xc55a0080, 0xc55c1080, 0xcd800081,
+ 0xcdc01080, 0x9d000000, 0x00000000, 0x00000000, 0x00000000, 0xc1e00000, 0xa540fffa, 0xc0000a14,
+ 0xc1a20002, 0x9d000000, 0xcd841108, 0xc0000a1c, 0xcdc41040, 0x59540002, 0x6994e018, 0x61c0c008,
+ 0x4194a000, 0x5d940040, 0x8800fffa, 0xc5940000, 0x9d000000, 0xcd400000, 0x00000000, 0x00000000,
+};
+
+static unsigned int firmware_binary_data[] = {
+};
+
+
+#endif // IFXMIPS_PTM_FW_DANUBE_H
diff --git a/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_fw_regs_adsl.h.svn-base b/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_fw_regs_adsl.h.svn-base
new file mode 100644
index 0000000..d6bdfd9
--- /dev/null
+++ b/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_fw_regs_adsl.h.svn-base
@@ -0,0 +1,284 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_ptm_fw_regs_adsl.h
+** PROJECT : UEIP
+** MODULES : PTM
+**
+** DATE : 7 Jul 2009
+** AUTHOR : Xu Liang
+** DESCRIPTION : PTM driver header file (firmware register for ADSL)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 07 JUL 2009 Xu Liang Init Version
+*******************************************************************************/
+
+
+
+#ifndef IFXMIPS_PTM_FW_REGS_ADSL_H
+#define IFXMIPS_PTM_FW_REGS_ADSL_H
+
+
+
+#if defined(CONFIG_DANUBE)
+ #include "ifxmips_ptm_fw_regs_danube.h"
+#elif defined(CONFIG_AMAZON_SE)
+ #include "ifxmips_ptm_fw_regs_amazon_se.h"
+#elif defined(CONFIG_AR9)
+ #include "ifxmips_ptm_fw_regs_ar9.h"
+#elif defined(CONFIG_VR9)
+ #error VR9 is not ADSL PTM mode!
+#else
+ #error Platform is not specified!
+#endif
+
+
+
+/*
+ * MIB Table Maintained by Firmware
+ */
+
+struct wan_mib_table {
+ unsigned int wrx_correct_pdu; /* 0 */
+ unsigned int wrx_correct_pdu_bytes; /* 1 */
+ unsigned int wrx_tccrc_err_pdu; /* 2 */
+ unsigned int wrx_tccrc_err_pdu_bytes; /* 3 */
+ unsigned int wrx_ethcrc_err_pdu; /* 4 */
+ unsigned int wrx_ethcrc_err_pdu_bytes; /* 5 */
+ unsigned int wrx_nodesc_drop_pdu; /* 6 */
+ unsigned int wrx_len_violation_drop_pdu; /* 7 */
+ unsigned int wrx_idle_bytes; /* 8 */
+ unsigned int wrx_nonidle_cw; /* 9 */
+ unsigned int wrx_idle_cw; /* A */
+ unsigned int wrx_err_cw; /* B */
+ unsigned int wtx_total_pdu; /* C */
+ unsigned int wtx_total_bytes; /* D */
+ unsigned int res0; /* E */
+ unsigned int res1; /* F */
+};
+
+
+/*
+ * Host-PPE Communication Data Structure
+ */
+
+#if defined(__BIG_ENDIAN)
+
+ struct fw_ver_id {
+ unsigned int family :4;
+ unsigned int fwtype :4;
+ unsigned int interface :4;
+ unsigned int fwmode :4;
+ unsigned int major :8;
+ unsigned int minor :8;
+ };
+
+ struct wrx_port_cfg_status {
+ /* 0h */
+ unsigned int mfs :16;
+ unsigned int res0 :12;
+ unsigned int dmach :3;
+ unsigned int res1 :1;
+
+ /* 1h */
+ unsigned int res2 :14;
+ unsigned int local_state :2; // init with 0, written by firmware only
+ unsigned int res3 :15;
+ unsigned int partner_state :1; // init with 0, written by firmware only
+
+ };
+
+ struct wrx_dma_channel_config {
+ /* 0h */
+ unsigned int res3 :1;
+ unsigned int res4 :2;
+ unsigned int res5 :1;
+ unsigned int desba :28;
+ /* 1h */
+ unsigned int res1 :16;
+ unsigned int res2 :16;
+ /* 2h */
+ unsigned int deslen :16;
+ unsigned int vlddes :16;
+ };
+
+ struct wtx_port_cfg {
+ /* 0h */
+ unsigned int tx_cwth2 :8;
+ unsigned int tx_cwth1 :8;
+ unsigned int res0 :16;
+ };
+
+ struct wtx_dma_channel_config {
+ /* 0h */
+ unsigned int res3 :1;
+ unsigned int res4 :2;
+ unsigned int res5 :1;
+ unsigned int desba :28;
+
+ /* 1h */
+ unsigned int res1 :16;
+ unsigned int res2 :16;
+
+ /* 2h */
+ unsigned int deslen :16;
+ unsigned int vlddes :16;
+ };
+
+ struct eth_efmtc_crc_cfg {
+ /* 0h */
+ unsigned int res0 :6;
+ unsigned int tx_eth_crc_gen :1;
+ unsigned int tx_tc_crc_gen :1;
+ unsigned int tx_tc_crc_len :8;
+ unsigned int res1 :5;
+ unsigned int rx_eth_crc_present :1;
+ unsigned int rx_eth_crc_check :1;
+ unsigned int rx_tc_crc_check :1;
+ unsigned int rx_tc_crc_len :8;
+ };
+
+ /* DMA descriptor */
+ struct rx_descriptor {
+ /* 0 - 3h */
+ unsigned int own :1;
+ unsigned int c :1;
+ unsigned int sop :1;
+ unsigned int eop :1;
+ unsigned int res1 :3;
+ unsigned int byteoff :2;
+ unsigned int res2 :2;
+ unsigned int id :4;
+ unsigned int err :1;
+ unsigned int datalen :16;
+ /* 4 - 7h */
+ unsigned int res3 :4;
+ unsigned int dataptr :28;
+ };
+
+ struct tx_descriptor {
+ /* 0 - 3h */
+ unsigned int own :1;
+ unsigned int c :1;
+ unsigned int sop :1;
+ unsigned int eop :1;
+ unsigned int byteoff :5;
+ unsigned int res1 :5;
+ unsigned int iscell :1;
+ unsigned int clp :1;
+ unsigned int datalen :16;
+ /* 4 - 7h */
+ unsigned int res2 :4;
+ unsigned int dataptr :28;
+ };
+
+#else /* defined(__BIG_ENDIAN) */
+
+ struct wrx_port_cfg_status {
+ /* 0h */
+ unsigned int res1 :1;
+ unsigned int dmach :3;
+ unsigned int res0 :12;
+ unsigned int mfs :16;
+
+ /* 1h */
+ unsigned int partner_state :1;
+ unsigned int res3 :15;
+ unsigned int local_state :2;
+ unsigned int res2 :14;
+ };
+
+ struct wrx_dma_channel_config {
+ /* 0h */
+ unsigned int desba :28;
+ unsigned int res5 :1;
+ unsigned int res4 :2;
+ unsigned int res3 :1;
+ /* 1h */
+ unsigned int res2 :16;
+ unsigned int res1 :16;
+ /* 2h */
+ unsigned int vlddes :16;
+ unsigned int deslen :16;
+ };
+
+ struct wtx_port_cfg {
+ /* 0h */
+ unsigned int res0 :16;
+ unsigned int tx_cwth1 :8;
+ unsigned int tx_cwth2 :8;
+ };
+
+ struct wtx_dma_channel_config {
+ /* 0h */
+ unsigned int desba :28;
+ unsigned int res5 :1;
+ unsigned int res4 :2;
+ unsigned int res3 :1;
+ /* 1h */
+ unsigned int res2 :16;
+ unsigned int res1 :16;
+ /* 2h */
+ unsigned int vlddes :16;
+ unsigned int deslen :16;
+ };
+
+ struct eth_efmtc_crc_cfg {
+ /* 0h */
+ unsigned int rx_tc_crc_len :8;
+ unsigned int rx_tc_crc_check :1;
+ unsigned int rx_eth_crc_check :1;
+ unsigned int rx_eth_crc_present :1;
+ unsigned int res1 :5;
+ unsigned int tx_tc_crc_len :8;
+ unsigned int tx_tc_crc_gen :1;
+ unsigned int tx_eth_crc_gen :1;
+ unsigned int res0 :6;
+ };
+
+ /* DMA descriptor */
+ struct rx_descriptor {
+ /* 4 - 7h */
+ unsigned int dataptr :28;
+ unsigned int res3 :4;
+ /* 0 - 3h */
+ unsigned int datalen :16;
+ unsigned int err :1;
+ unsigned int id :4;
+ unsigned int res2 :2;
+ unsigned int byteoff :2;
+ unsigned int res1 :3;
+ unsigned int eop :1;
+ unsigned int sop :1;
+ unsigned int c :1;
+ unsigned int own :1;
+ };
+
+ struct tx_descriptor {
+ /* 4 - 7h */
+ unsigned int dataptr :28;
+ unsigned int res2 :4;
+ /* 0 - 3h */
+ unsigned int datalen :16;
+ unsigned int clp :1;
+ unsigned int iscell :1;
+ unsigned int res1 :5;
+ unsigned int byteoff :5;
+ unsigned int eop :1;
+ unsigned int sop :1;
+ unsigned int c :1;
+ unsigned int own :1;
+ };
+#endif /* defined(__BIG_ENDIAN) */
+
+
+
+#endif // IFXMIPS_PTM_FW_REGS_ADSL_H
diff --git a/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_fw_regs_amazon_se.h.svn-base b/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_fw_regs_amazon_se.h.svn-base
new file mode 100644
index 0000000..1219b6b
--- /dev/null
+++ b/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_fw_regs_amazon_se.h.svn-base
@@ -0,0 +1,48 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_ptm_fw_regs_amazon_se.h
+** PROJECT : UEIP
+** MODULES : PTM
+**
+** DATE : 7 Jul 2009
+** AUTHOR : Xu Liang
+** DESCRIPTION : PTM driver header file (firmware register for Amazon-SE)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 07 JUL 2009 Xu Liang Init Version
+*******************************************************************************/
+
+
+
+#ifndef IFXMIPS_PTM_FW_REGS_AMAZON_SE_H
+#define IFXMIPS_PTM_FW_REGS_AMAZON_SE_H
+
+
+
+/*
+ * Host-PPE Communication Data Address Mapping
+ */
+#define FW_VER_ID ((volatile struct fw_ver_id *) SB_BUFFER(0x2401))
+#define CFG_WAN_WRDES_DELAY SB_BUFFER(0x2404)
+#define CFG_WRX_DMACH_ON SB_BUFFER(0x2405)
+#define CFG_WTX_DMACH_ON SB_BUFFER(0x2406)
+#define CFG_WRX_LOOK_BITTH SB_BUFFER(0x2407)
+#define CFG_ETH_EFMTC_CRC ((volatile struct eth_efmtc_crc_cfg *) SB_BUFFER(0x2408))
+#define WAN_MIB_TABLE ((volatile struct wan_mib_table*) SB_BUFFER(0x2440))
+#define WRX_PORT_CONFIG(i) ((volatile struct wrx_port_cfg_status*) SB_BUFFER(0x2500 + (i) * 20))
+#define WRX_DMA_CHANNEL_CONFIG(i) ((volatile struct wrx_dma_channel_config*) SB_BUFFER(0x2640 + (i) * 7))
+#define WTX_PORT_CONFIG(i) ((volatile struct wtx_port_cfg*) SB_BUFFER(0x2710 + (i) * 31))
+#define WTX_DMA_CHANNEL_CONFIG(i) ((volatile struct wtx_dma_channel_config*) SB_BUFFER(0x2711 + (i) * 31))
+
+
+
+#endif // IFXMIPS_PTM_FW_REGS_AMAZON_SE_H
diff --git a/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_fw_regs_ar9.h.svn-base b/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_fw_regs_ar9.h.svn-base
new file mode 100644
index 0000000..43f4da9
--- /dev/null
+++ b/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_fw_regs_ar9.h.svn-base
@@ -0,0 +1,48 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_ptm_fw_regs_ar9.h
+** PROJECT : UEIP
+** MODULES : PTM
+**
+** DATE : 7 Jul 2009
+** AUTHOR : Xu Liang
+** DESCRIPTION : PTM driver header file (firmware register for AR9)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 07 JUL 2009 Xu Liang Init Version
+*******************************************************************************/
+
+
+
+#ifndef IFXMIPS_PTM_FW_REGS_AR9_H
+#define IFXMIPS_PTM_FW_REGS_AR9_H
+
+
+
+/*
+ * Host-PPE Communication Data Address Mapping
+ */
+#define FW_VER_ID ((volatile struct fw_ver_id *) SB_BUFFER(0x2001))
+#define CFG_WAN_WRDES_DELAY SB_BUFFER(0x2404)
+#define CFG_WRX_DMACH_ON SB_BUFFER(0x2405)
+#define CFG_WTX_DMACH_ON SB_BUFFER(0x2406)
+#define CFG_WRX_LOOK_BITTH SB_BUFFER(0x2407)
+#define CFG_ETH_EFMTC_CRC ((volatile struct eth_efmtc_crc_cfg *) SB_BUFFER(0x2408))
+#define WAN_MIB_TABLE ((volatile struct wan_mib_table*) SB_BUFFER(0x2440))
+#define WRX_PORT_CONFIG(i) ((volatile struct wrx_port_cfg_status*) SB_BUFFER(0x3F00 + (i) * 20))
+#define WRX_DMA_CHANNEL_CONFIG(i) ((volatile struct wrx_dma_channel_config*) SB_BUFFER(0x2640 + (i) * 7))
+#define WTX_PORT_CONFIG(i) ((volatile struct wtx_port_cfg*) SB_BUFFER(0x3B00 + (i) * 31))
+#define WTX_DMA_CHANNEL_CONFIG(i) ((volatile struct wtx_dma_channel_config*) SB_BUFFER(0x3B01 + (i) * 31))
+
+
+
+#endif // IFXMIPS_PTM_FW_REGS_AR9_H
diff --git a/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_fw_regs_danube.h.svn-base b/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_fw_regs_danube.h.svn-base
new file mode 100644
index 0000000..d8685f3
--- /dev/null
+++ b/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_fw_regs_danube.h.svn-base
@@ -0,0 +1,48 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_ptm_fw_regs_danube.h
+** PROJECT : UEIP
+** MODULES : PTM
+**
+** DATE : 7 Jul 2009
+** AUTHOR : Xu Liang
+** DESCRIPTION : PTM driver header file (firmware register for Danube)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 07 JUL 2009 Xu Liang Init Version
+*******************************************************************************/
+
+
+
+#ifndef IFXMIPS_PTM_FW_REGS_DANUBE_H
+#define IFXMIPS_PTM_FW_REGS_DANUBE_H
+
+
+
+/*
+ * Host-PPE Communication Data Address Mapping
+ */
+#define FW_VER_ID ((volatile struct fw_ver_id *) SB_BUFFER(0x2001))
+#define CFG_WAN_WRDES_DELAY SB_BUFFER(0x2404)
+#define CFG_WRX_DMACH_ON SB_BUFFER(0x2405)
+#define CFG_WTX_DMACH_ON SB_BUFFER(0x2406)
+#define CFG_WRX_LOOK_BITTH SB_BUFFER(0x2407)
+#define CFG_ETH_EFMTC_CRC ((volatile struct eth_efmtc_crc_cfg *) SB_BUFFER(0x2408))
+#define WAN_MIB_TABLE ((volatile struct wan_mib_table*) SB_BUFFER(0x2440))
+#define WRX_PORT_CONFIG(i) ((volatile struct wrx_port_cfg_status*) SB_BUFFER(0x2500 + (i) * 20))
+#define WRX_DMA_CHANNEL_CONFIG(i) ((volatile struct wrx_dma_channel_config*) SB_BUFFER(0x2640 + (i) * 7))
+#define WTX_PORT_CONFIG(i) ((volatile struct wtx_port_cfg*) SB_BUFFER(0x2710 + (i) * 31))
+#define WTX_DMA_CHANNEL_CONFIG(i) ((volatile struct wtx_dma_channel_config*) SB_BUFFER(0x2711 + (i) * 31))
+
+
+
+#endif // IFXMIPS_PTM_FW_REGS_DANUBE_H
diff --git a/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_fw_regs_vdsl.h.svn-base b/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_fw_regs_vdsl.h.svn-base
new file mode 100644
index 0000000..e357197
--- /dev/null
+++ b/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_fw_regs_vdsl.h.svn-base
@@ -0,0 +1,278 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_ptm_fw_regs_vdsl.h
+** PROJECT : UEIP
+** MODULES : PTM
+**
+** DATE : 7 Jul 2009
+** AUTHOR : Xu Liang
+** DESCRIPTION : PTM driver header file (firmware register for VDSL)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 07 JUL 2009 Xu Liang Init Version
+*******************************************************************************/
+
+
+
+#ifndef IFXMIPS_PTM_FW_REGS_VDSL_H
+#define IFXMIPS_PTM_FW_REGS_VDSL_H
+
+
+
+#if defined(CONFIG_DANUBE)
+ #error Danube is not VDSL PTM mode!
+#elif defined(CONFIG_AMAZON_SE)
+ #error Amazon-SE is not VDSL PTM mode!
+#elif defined(CONFIG_AR9)
+ #error AR9 is not VDSL PTM mode!
+#elif defined(CONFIG_VR9)
+ #include "ifxmips_ptm_fw_regs_vr9.h"
+#else
+ #error Platform is not specified!
+#endif
+
+
+
+/*
+ * MIB Table Maintained by Firmware
+ */
+
+struct wan_rx_mib_table {
+ unsigned int res1[2];
+ unsigned int wrx_dropdes_pdu;
+ unsigned int wrx_total_bytes;
+ unsigned int res2[4];
+ // wrx_total_pdu is implemented with hardware counter (not used by PTM TC)
+ // check register "TC_RX_MIB_CMD"
+ // "HEC_INC" used to increase preemption Gamma interface (wrx_total_pdu)
+ // "AIIDLE_INC" used to increase normal Gamma interface (wrx_total_pdu)
+};
+
+struct wan_tx_mib_table {
+ //unsigned int wtx_total_pdu; // version before 0.26
+ //unsigned int small_pkt_drop_cnt;
+ //unsigned int total_pkt_drop_cnt;
+ unsigned int wrx_total_pdu; // version 0.26 and onwards
+ unsigned int wrx_total_bytes;
+ unsigned int wtx_total_pdu;
+ unsigned int wtx_total_bytes;
+
+ unsigned int wtx_cpu_dropsmall_pdu;
+ unsigned int wtx_cpu_dropdes_pdu;
+ unsigned int wtx_fast_dropsmall_pdu;
+ unsigned int wtx_fast_dropdes_pdu;
+};
+
+
+/*
+ * Host-PPE Communication Data Structure
+ */
+
+#if defined(__BIG_ENDIAN)
+
+ struct fw_ver_id {
+ unsigned int family :4;
+ unsigned int fwtype :4;
+ unsigned int interface :4;
+ unsigned int fwmode :4;
+ unsigned int major :8;
+ unsigned int minor :8;
+ };
+
+ struct cfg_std_data_len {
+ unsigned int res1 :14;
+ unsigned int byte_off :2; // byte offset in RX DMA channel
+ unsigned int data_len :16; // data length for standard size packet buffer
+ };
+
+ struct tx_qos_cfg {
+ unsigned int time_tick :16; // number of PP32 cycles per basic time tick
+ unsigned int overhd_bytes :8; // number of overhead bytes per packet in rate shaping
+ unsigned int eth1_eg_qnum :4; // number of egress QoS queues (< 8);
+ unsigned int eth1_burst_chk :1; // always 1, more accurate WFQ
+ unsigned int eth1_qss :1; // 1: FW QoS, 0: HW QoS
+ unsigned int shape_en :1; // 1: enable rate shaping, 0: disable
+ unsigned int wfq_en :1; // 1: WFQ enabled, 0: strict priority enabled
+ };
+
+ struct psave_cfg {
+ unsigned int res1 :15;
+ unsigned int start_state :1; // 1: start from partial PPE reset, 0: start from full PPE reset
+ unsigned int res2 :15;
+ unsigned int sleep_en :1; // 1: enable sleep mode, 0: disable sleep mode
+ };
+
+ struct eg_bwctrl_cfg {
+ unsigned int fdesc_wm :16; // if free descriptors in QoS/Swap channel is less than this watermark, large size packets are discarded
+ unsigned int class_len :16; // if packet length is not less than this value, the packet is recognized as large packet
+ };
+
+ struct test_mode {
+ unsigned int res1 :30;
+ unsigned int mib_clear_mode :1; // 1: MIB counter is cleared with TPS-TC software reset, 0: MIB counter not cleared
+ unsigned int test_mode :1; // 1: test mode, 0: normal mode
+ };
+
+ struct gpio_mode {
+ unsigned int res1 :3;
+ unsigned int gpio_bit_bc1 :5;
+ unsigned int res2 :3;
+ unsigned int gpio_bit_bc0 :5;
+
+ unsigned int res3 :7;
+ unsigned int gpio_bc1_en :1;
+
+ unsigned int res4 :7;
+ unsigned int gpio_bc0_en :1;
+ };
+
+ struct gpio_wm_cfg {
+ unsigned int stop_wm_bc1 :8;
+ unsigned int start_wm_bc1 :8;
+ unsigned int stop_wm_bc0 :8;
+ unsigned int start_wm_bc0 :8;
+ };
+
+ struct rx_bc_cfg {
+ unsigned int res1 :14;
+ unsigned int local_state :2; // 0: local receiver is "Looking", 1: local receiver is "Freewheel Sync False", 2: local receiver is "Synced", 3: local receiver is "Freewheel Sync Truee"
+ unsigned int res2 :15;
+ unsigned int remote_state :1; // 0: remote receiver is "Out-of-Sync", 1: remote receiver is "Synced"
+ unsigned int to_false_th :16; // the number of consecutive "Miss Sync" for leaving "Freewheel Sync False" to "Looking" (default 3)
+ unsigned int to_looking_th :16; // the number of consecutive "Miss Sync" for leaving "Freewheel Sync True" to "Freewheel Sync False" (default 7)
+ unsigned int res_word[30];
+ };
+
+ struct rx_gamma_itf_cfg {
+ unsigned int res1 :31;
+ unsigned int receive_state :1; // 0: "Out-of-Fragment", 1: "In-Fragment"
+ unsigned int res2 :16;
+ unsigned int rx_min_len :8; // min length of packet, padding if packet length is smaller than this value
+ unsigned int rx_pad_en :1; // 0: padding disabled, 1: padding enabled
+ unsigned int res3 :2;
+ unsigned int rx_eth_fcs_ver_dis :1; // 0: ETH FCS verification is enabled, 1: disabled
+ unsigned int rx_rm_eth_fcs :1; // 0: ETH FCS field is not removed, 1: ETH FCS field is removed
+ unsigned int rx_tc_crc_ver_dis :1; // 0: TC CRC verification enabled, 1: disabled
+ unsigned int rx_tc_crc_size :2; // 0: 0-bit, 1: 16-bit, 2: 32-bit
+ unsigned int rx_eth_fcs_result; // if the ETH FCS result matches this magic number, then the packet is valid packet
+ unsigned int rx_tc_crc_result; // if the TC CRC result matches this magic number, then the packet is valid packet
+ unsigned int rx_crc_cfg :16; // TC CRC config, please check the description of SAR context data structure in the hardware spec
+ unsigned int res4 :16;
+ unsigned int rx_eth_fcs_init_value; // ETH FCS initialization value
+ unsigned int rx_tc_crc_init_value; // TC CRC initialization value
+ unsigned int res_word1;
+ unsigned int rx_max_len_sel :1; // 0: normal, the max length is given by MAX_LEN_NORMAL, 1: fragment, the max length is given by MAX_LEN_FRAG
+ unsigned int res5 :2;
+ unsigned int rx_edit_num2 :4; // number of bytes to be inserted/removed
+ unsigned int rx_edit_pos2 :7; // first byte position to be edited
+ unsigned int rx_edit_type2 :1; // 0: remove, 1: insert
+ unsigned int rx_edit_en2 :1; // 0: disable insertion or removal of data, 1: enable
+ unsigned int res6 :3;
+ unsigned int rx_edit_num1 :4; // number of bytes to be inserted/removed
+ unsigned int rx_edit_pos1 :7; // first byte position to be edited
+ unsigned int rx_edit_type1 :1; // 0: remove, 1: insert
+ unsigned int rx_edit_en1 :1; // 0: disable insertion or removal of data, 1: enable
+ unsigned int res_word2[2];
+ unsigned int rx_inserted_bytes_1l;
+ unsigned int rx_inserted_bytes_1h;
+ unsigned int rx_inserted_bytes_2l;
+ unsigned int rx_inserted_bytes_2h;
+ int rx_len_adj; // the packet length adjustment, it is sign integer
+ unsigned int res_word3[16];
+ };
+
+ struct tx_bc_cfg {
+ unsigned int fill_wm :16; // default 2
+ unsigned int uflw_wm :16; // default 2
+ unsigned int res_word[31];
+ };
+
+ struct tx_gamma_itf_cfg {
+ unsigned int res_word1;
+ unsigned int res1 :8;
+ unsigned int tx_len_adj :4; // 4 * (not TX_ETH_FCS_GEN_DIS) + TX_TC_CRC_SIZE
+ unsigned int tx_crc_off_adj :4; // 4 + TX_TC_CRC_SIZE
+ unsigned int tx_min_len :8; // min length of packet, if length is less than this value, packet is padded
+ unsigned int res2 :3;
+ unsigned int tx_eth_fcs_gen_dis :1; // 0: ETH FCS generation enabled, 1: disabled
+ unsigned int res3 :2;
+ unsigned int tx_tc_crc_size :2; // 0: 0-bit, 1: 16-bit, 2: 32-bit
+ unsigned int res4 :24;
+ unsigned int queue_mapping :8; // TX queue attached to this Gamma interface
+ unsigned int res_word2;
+ unsigned int tx_crc_cfg :16; // TC CRC config, please check the description of SAR context data structure in the hardware spec
+ unsigned int res5 :16;
+ unsigned int tx_eth_fcs_init_value; // ETH FCS initialization value
+ unsigned int tx_tc_crc_init_value; // TC CRC initialization value
+ unsigned int res_word3[25];
+ };
+
+ struct wtx_qos_q_desc_cfg {
+ unsigned int threshold :8;
+ unsigned int length :8;
+ unsigned int addr :16;
+ unsigned int rd_ptr :16;
+ unsigned int wr_ptr :16;
+ };
+
+ struct wtx_eg_q_shaping_cfg {
+ unsigned int t :8;
+ unsigned int w :24;
+ unsigned int s :16;
+ unsigned int r :16;
+ unsigned int res1 :8;
+ unsigned int d :24; // ppe internal variable
+ unsigned int res2 :8;
+ unsigned int tick_cnt :8; // ppe internal variable
+ unsigned int b :16; // ppe internal variable
+ };
+
+ /* DMA descriptor */
+ struct rx_descriptor {
+ /* 0 - 3h */
+ unsigned int own :1; // 0: Central DMA TX or MIPS, 1: PPE
+ unsigned int c :1; // PPE tells current descriptor is complete
+ unsigned int sop :1;
+ unsigned int eop :1;
+ unsigned int res1 :3;
+ unsigned int byteoff :2;
+ unsigned int res2 :7;
+ unsigned int datalen :16;
+ /* 4 - 7h */
+ unsigned int res3 :4;
+ unsigned int dataptr :28; // byte address
+ };
+
+ struct tx_descriptor {
+ /* 0 - 3h */
+ unsigned int own :1; // CPU path - 0: MIPS, 1: PPE Dispatcher, Fastpath - 0: PPE Dispatcher, 1: Central DMA, QoS Queue - 0: PPE Dispatcher, 1: PPE DMA, SWAP Channel - 0: MIPS, 1: PPE Dispatcher
+ unsigned int c :1; // MIPS or central DMA tells PPE the current descriptor is complete
+ unsigned int sop :1;
+ unsigned int eop :1;
+ unsigned int byteoff :5;
+ unsigned int qid :4; // TX Queue ID, bit 3 is reserved
+ unsigned int res1 :3;
+ unsigned int datalen :16;
+ /* 4 - 7h */
+ unsigned int small :1; // 0: standard size, 1: less than standard size
+ unsigned int res2 :3;
+ unsigned int dataptr :28; // byte address
+ };
+
+#else /* defined(__BIG_ENDIAN) */
+ #error structures are defined in big endian
+#endif /* defined(__BIG_ENDIAN) */
+
+
+
+#endif // IFXMIPS_PTM_FW_REGS_VDSL_H
+
diff --git a/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_fw_regs_vr9.h.svn-base b/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_fw_regs_vr9.h.svn-base
new file mode 100644
index 0000000..a640cfb
--- /dev/null
+++ b/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_fw_regs_vr9.h.svn-base
@@ -0,0 +1,90 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_ptm_fw_regs_vr9.h
+** PROJECT : UEIP
+** MODULES : PTM
+**
+** DATE : 7 Jul 2009
+** AUTHOR : Xu Liang
+** DESCRIPTION : PTM driver header file (firmware register for VR9)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 07 JUL 2009 Xu Liang Init Version
+*******************************************************************************/
+
+
+
+#ifndef IFXMIPS_PTM_FW_REGS_VR9_H
+#define IFXMIPS_PTM_FW_REGS_VR9_H
+
+
+
+/*
+ * Host-PPE Communication Data Address Mapping
+ */
+#define FW_VER_ID ((volatile struct fw_ver_id *) SB_BUFFER(0x2001))
+#define CFG_STD_DATA_LEN ((volatile struct cfg_std_data_len *) SB_BUFFER(0x2011))
+#define TX_QOS_CFG ((volatile struct tx_qos_cfg *) SB_BUFFER(0x2012))
+#define EG_BWCTRL_CFG ((volatile struct eg_bwctrl_cfg *) SB_BUFFER(0x2013))
+#define PSAVE_CFG ((volatile struct psave_cfg *) SB_BUFFER(0x2014))
+#define GPIO_ADDR SB_BUFFER(0x2019)
+#define GPIO_MODE ((volatile struct gpio_mode *) SB_BUFFER(0x201C))
+#define GPIO_WM_CFG ((volatile struct gpio_wm_cfg *) SB_BUFFER(0x201D))
+#define TEST_MODE ((volatile struct test_mode *) SB_BUFFER(0x201F))
+#define WTX_QOS_Q_DESC_CFG(i) ((volatile struct wtx_qos_q_desc_cfg *) SB_BUFFER(0x2FF0 + (i) * 2)) /* i < 8 */
+#define WTX_EG_Q_PORT_SHAPING_CFG(i) ((volatile struct wtx_eg_q_shaping_cfg *) SB_BUFFER(0x2680 + (i) * 4)) /* i < 1 */
+#define WTX_EG_Q_SHAPING_CFG(i) ((volatile struct wtx_eg_q_shaping_cfg *) SB_BUFFER(0x2684 + (i) * 4)) /* i < 8 */
+#define TX_QUEUE_CFG(i) WTX_EG_Q_PORT_SHAPING_CFG(i) // i < 9
+#define RX_BC_CFG(i) ((volatile struct rx_bc_cfg *) SB_BUFFER(0x3E80 + (i) * 0x20)) // i < 2
+#define TX_BC_CFG(i) ((volatile struct tx_bc_cfg *) SB_BUFFER(0x3EC0 + (i) * 0x20)) // i < 2
+#define RX_GAMMA_ITF_CFG(i) ((volatile struct rx_gamma_itf_cfg *) SB_BUFFER(0x3D80 + (i) * 0x20)) // i < 4
+#define TX_GAMMA_ITF_CFG(i) ((volatile struct tx_gamma_itf_cfg *) SB_BUFFER(0x3E00 + (i) * 0x20)) // i < 4
+#define WAN_RX_MIB_TABLE(i) ((volatile struct wan_rx_mib_table *) SB_BUFFER(0x5B00 + (i) * 8)) // i < 4
+#define WAN_TX_MIB_TABLE(i) ((volatile struct wan_tx_mib_table *) SB_BUFFER(0x5B20 + (i) * 8)) // i < 8
+#define TX_CTRL_K_TABLE(i) SB_BUFFER(0x47F0 + (i)) // i < 16
+// following MIB for debugging purpose
+#define RECEIVE_NON_IDLE_CELL_CNT(i) SB_BUFFER(5020 + (i))
+#define RECEIVE_IDLE_CELL_CNT(i) SB_BUFFER(5022 + (i))
+#define TRANSMIT_CELL_CNT(i) SB_BUFFER(5024 + (i))
+#define FP_RECEIVE_PKT_CNT SB_BUFFER(5026)
+
+#define UTP_CFG SB_BUFFER(0x2018) // bit 0~3 - 0x0F: in showtime, 0x00: not in showtime
+
+/*
+ * Descriptor Base Address
+ */
+#define CPU_TO_WAN_TX_DESC_BASE ((volatile struct tx_descriptor *)SB_BUFFER(0x3D00))
+#define __ETH_WAN_TX_QUEUE_NUM g_wanqos_en
+#define __ETH_WAN_TX_QUEUE_LEN ((WAN_TX_DESC_NUM_TOTAL / __ETH_WAN_TX_QUEUE_NUM) < 256 ? (WAN_TX_DESC_NUM_TOTAL / __ETH_WAN_TX_QUEUE_NUM) : 255)
+#define __ETH_WAN_TX_DESC_BASE(i) (0x5C00 + (i) * 2 * __ETH_WAN_TX_QUEUE_LEN)
+#define WAN_TX_DESC_BASE(i) ((volatile struct tx_descriptor *)SB_BUFFER(__ETH_WAN_TX_DESC_BASE(i))) // i < __ETH_WAN_TX_QUEUE_NUM, __ETH_WAN_TX_QUEUE_LEN each queue
+#define WAN_SWAP_DESC_BASE ((volatile struct tx_descriptor *)SB_BUFFER(0x2E80))
+#define FASTPATH_TO_WAN_TX_DESC_BASE ((volatile struct tx_descriptor *)SB_BUFFER(0x2580))
+#define DMA_RX_CH1_DESC_BASE FASTPATH_TO_WAN_TX_DESC_BASE
+#define WAN_RX_DESC_BASE ((volatile struct rx_descriptor *)SB_BUFFER(0x2600))
+#define DMA_TX_CH1_DESC_BASE WAN_RX_DESC_BASE
+
+/*
+ * Descriptor Number
+ */
+#define CPU_TO_WAN_TX_DESC_NUM 64
+#define WAN_TX_DESC_NUM __ETH_WAN_TX_QUEUE_LEN
+#define WAN_SWAP_DESC_NUM 64
+#define WAN_TX_DESC_NUM_TOTAL 512
+#define FASTPATH_TO_WAN_TX_DESC_NUM 64
+#define DMA_RX_CH1_DESC_NUM FASTPATH_TO_WAN_TX_DESC_NUM
+#define WAN_RX_DESC_NUM 64
+#define DMA_TX_CH1_DESC_NUM WAN_RX_DESC_NUM
+
+
+
+#endif // IFXMIPS_PTM_FW_REGS_VR9_H
diff --git a/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_fw_vr9.h.svn-base b/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_fw_vr9.h.svn-base
new file mode 100644
index 0000000..c9f0893
--- /dev/null
+++ b/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_fw_vr9.h.svn-base
@@ -0,0 +1,380 @@
+#ifndef IFXMIPS_PTM_FW_VR9_H
+#define IFXMIPS_PTM_FW_VR9_H
+
+
+/******************************************************************************
+**
+** FILE NAME : ifxmips_ptm_fw_vr9.h
+** PROJECT : UEIP
+** MODULES : PTM (VDSL)
+**
+** DATE : 22 OCT 2007
+** AUTHOR : Xu Liang
+** DESCRIPTION : PTM Driver (PP32 Firmware)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 22 OCT 2007 Xu Liang Initiate Version, v00.01
+*******************************************************************************/
+
+
+#define PTM_FW_VER_MAJOR 0
+#define PTM_FW_VER_MINOR 30
+
+
+static unsigned int firmware_binary_code[] = {
+ 0x80000980, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8000ffe0, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xc1c20002, 0xd9cc00f8, 0xc0006950, 0xcbc000f8, 0xc0004024, 0xc8c000f8, 0xc0006950, 0x5bfc0002,
+ 0xcfc000f8, 0xa4c252a2, 0x00000000, 0x00000000, 0x800007a0, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xc0e1fffe, 0x58cdfffe, 0xc1e1fffa, 0x59ddfffe, 0x94000001, 0x00000000, 0x00000000, 0x00000000,
+ 0xc0e1fffe, 0x58cdfffe, 0xc1e1fffa, 0x59ddfffe, 0x900009a1, 0x00000000, 0x00000000, 0x00000000,
+ 0x90cc0941, 0x00000000, 0x00000000, 0x00000000, 0xc3e0e2a2, 0x5bfc003c, 0xc0004002, 0xcfc000f8,
+ 0xc3c00000, 0xc0004024, 0xcbc20078, 0x00000000, 0x00000000, 0xc1c00000, 0xd9c400f9, 0xdbc40078,
+ 0xc1c00006, 0xd9c400f9, 0xc3c0fc10, 0xc0006952, 0xcfc000f8, 0xc3c00000, 0xc3400000, 0xc3000040,
+ 0xc2c00080, 0x6ff8a000, 0x5bb87d00, 0x5838001c, 0xcf4000f8, 0x5838001e, 0xcec000f8, 0x58380020,
+ 0xcf4000f8, 0x58380022, 0xcf0000f8, 0x5bfc0002, 0x5ebc0004, 0x8400ffa0, 0x00000000, 0xc1e1fffe,
+ 0x59ddfffa, 0x141c0000, 0xc1c00000, 0xc000691c, 0xcdc000f8, 0xab64002a, 0xc3c00000, 0xab66001a,
+ 0xc3c00002, 0x80001130, 0xc1c00002, 0xc000691c, 0xcdc000f8, 0x6ff8a000, 0x5bb87d00, 0x58380004,
+ 0xcb4000f8, 0xc2800000, 0x58380000, 0xca820008, 0xc000e824, 0xc3000000, 0xcb3c0070, 0x6f5c8000,
+ 0x41f4e000, 0x431d8000, 0x5b304000, 0xc000e828, 0xc1c00000, 0xc9fc0070, 0x00000000, 0xc0004000,
+ 0x41f4e000, 0x401c0000, 0xcac000f8, 0x5de80004, 0x84000880, 0xa6c607ea, 0x00000000, 0x6fe42000,
+ 0xc6e4a000, 0x6e60a000, 0x5a207b00, 0xc1800000, 0x58200000, 0xc9800000, 0xc2800000, 0xc6e80010,
+ 0x5dd80000, 0x8400003a, 0x5de80008, 0xc6a82012, 0xc1c00004, 0x45e8e000, 0x88000030, 0x80000558,
+ 0x5de80004, 0xc6a8010a, 0x5de80008, 0x84000538, 0x58380000, 0xc1c00002, 0xcdc00000, 0x58200000,
+ 0xc1c00002, 0xcdc00000, 0x5de80002, 0xcdc00002, 0xc000ea14, 0xc1e20000, 0xcdfe3100, 0xc000fb60,
+ 0xc1c00002, 0xcdfc0000, 0xc0006940, 0xc9c000f8, 0x403c0000, 0x00000000, 0x59dc0002, 0xcdc000f8,
+ 0xc1c00004, 0x45e8e000, 0x880000fa, 0x58200020, 0xc9c000f8, 0xc0c00018, 0xc1000000, 0xa5c0002a,
+ 0xc1400080, 0x5de80000, 0xc6ccf930, 0xc54c1932, 0x5de80000, 0xc1c0000a, 0xc5cc1230, 0xc5cc3202,
+ 0x58200022, 0xc9c000f8, 0xc74c0b30, 0xc7cc0008, 0xc5cc0528, 0xc1800000, 0xc6982000, 0xc1c00000,
+ 0xc69c0000, 0x71d8e000, 0xc5cc0400, 0x98404c78, 0xc5d00000, 0x7d80e000, 0xc5d00100, 0x5dd80002,
+ 0x84000388, 0xc1c00000, 0xc6ddc030, 0x59dc0006, 0xc5ec0e30, 0xc0c00018, 0xc1000004, 0x59dc0002,
+ 0xc5cc1230, 0xc74c0b30, 0xc7cc0008, 0xc0000088, 0x441ce000, 0xc5cc1930, 0xa6cc02b0, 0xc1c80002,
+ 0x70dc6000, 0xc1400000, 0xc6d5c030, 0x5d540002, 0x6d5c4010, 0x431c0000, 0xc88000f8, 0xc1c00000,
+ 0xc55c0008, 0xc0000006, 0x441ce000, 0x6ddc6000, 0x689c4010, 0xc1c001fe, 0x749c4000, 0x59540002,
+ 0xc1c000fe, 0x749c4000, 0x5c880020, 0xc48c1930, 0x4148c000, 0x59980002, 0x5dd80088, 0x8800002a,
+ 0x58200000, 0xc1c00000, 0xcdc00000, 0x800000c8, 0xc1400000, 0x6d9c4010, 0x431c0000, 0xc94000f8,
+ 0xc1c00000, 0xc59c0008, 0xc0000006, 0x441ce000, 0x6ddc6000, 0x695ca010, 0xc1c001fe, 0x755ca000,
+ 0x00000000, 0x00000000, 0x5dd40000, 0x84000018, 0x59980002, 0x8000ff48, 0x59980002, 0xc0800002,
+ 0x5dd400a0, 0xc4902100, 0xc4ac2602, 0x4588c002, 0xdbc800f9, 0xda4800f8, 0xda1000f9, 0x90404391,
+ 0x58200020, 0xc9c000f8, 0x58200022, 0xc94000f8, 0x5ddc0002, 0xc1c00000, 0xc5cc1932, 0xc6ddc030,
+ 0x59dc0002, 0x98404c78, 0xc5cc1230, 0xc54c0528, 0xc4d08000, 0xa5020072, 0xc1c00002, 0xc5d00100,
+ 0xc5ac0e30, 0xa6ccfdc2, 0xc1c00000, 0xc5cc0400, 0xc1c00086, 0x45d8e000, 0xc5cc1930, 0x8000ff28,
+ 0x00000000, 0x00000000, 0x00000000, 0x80000070, 0xdbc800f9, 0xda4800f8, 0xda1000f9, 0x90404391,
+ 0x58200022, 0xc98000f8, 0x58200020, 0xc9c000f8, 0x00000000, 0x98404c78, 0x5ddc0002, 0xc58c0528,
+ 0xc5cc1932, 0x80000200, 0xc1400000, 0xc000403e, 0xc9400000, 0xc1800000, 0x58200000, 0xc9800000,
+ 0x5dd40002, 0x84000020, 0x5dd80002, 0x84000010, 0x80000110, 0x5de80006, 0x84000088, 0x58380000,
+ 0xc1c00002, 0xcdc00000, 0xc000ea14, 0xc1e20000, 0xcdfe3100, 0xc000fb60, 0xc1c20002, 0xcdfc2100,
+ 0xc0006944, 0xc9c000f8, 0x403c0000, 0x00000000, 0x59dc0002, 0xcdc000f8, 0x800000f0, 0x5de8000a,
+ 0x84000070, 0x58380000, 0xc1c00000, 0xcdc00000, 0xc000ea14, 0xc1e20002, 0xcdfe3100, 0xc000fb60,
+ 0xc1c20002, 0xcdfc2100, 0xc000facc, 0xc1c00002, 0xcdfc0000, 0x80000078, 0xa6ca0040, 0xc000facc,
+ 0xc1ca0002, 0xcdfca500, 0xc000fb64, 0xc1c60002, 0xcdfc6300, 0x80000038, 0xc000facc, 0xc1c80002,
+ 0xcdfc8400, 0xc000fb64, 0xc1c40002, 0xcdfc4200, 0xc0c00010, 0x98404c78, 0xc7cc0008, 0xc74c0b30,
+ 0xc1000004, 0x80000808, 0xc1c00002, 0x58380008, 0xcdc000f8, 0x58380000, 0xc1e00006, 0xcdc21008,
+ 0xc000facc, 0xc1c80002, 0xcdfc8400, 0xc000fb64, 0xc1c40002, 0xcdfc4200, 0xc0c00010, 0x98404c78,
+ 0xc7cc0008, 0xc74c0b30, 0xc1000004, 0x80000778, 0x5de80006, 0x84000170, 0xa6c60032, 0x00000000,
+ 0x58380000, 0xc1e00004, 0xcdc21008, 0x8000f760, 0x58380008, 0xca8000f8, 0xc2400000, 0x58380002,
+ 0xca420078, 0x00000000, 0x5aa80002, 0x58380008, 0xce8000f8, 0x46a4e000, 0x8800008a, 0x58380000,
+ 0xc1e00002, 0xcdc21008, 0x58380000, 0xc1c00000, 0xcdc00000, 0xc000facc, 0xc1c20002, 0xcdfc2100,
+ 0xc1e1e1a2, 0xc000ea1c, 0xcdfc00f8, 0xc000ea14, 0xc1e20002, 0xcdfe3100, 0x80000038, 0xc000facc,
+ 0xc1c80002, 0xcdfc8400, 0xc000fb64, 0xc1c40002, 0xcdfc4200, 0xc0c00010, 0x98404c78, 0xc7cc0008,
+ 0xc74c0b30, 0xc1000004, 0x80000600, 0x5de80002, 0x84000150, 0xa6c6004a, 0x00000000, 0x58380000,
+ 0xc1e00004, 0xcdc21008, 0xc1f8001e, 0xc000ea1c, 0xcdfc00f8, 0x8000f5d0, 0x58380008, 0xca8000f8,
+ 0xc2400000, 0x58380002, 0xca400078, 0xc000facc, 0xc1c20002, 0xcdfc2100, 0x5aa80002, 0x58380008,
+ 0xce8000f8, 0x46a4e000, 0x88000072, 0x58380000, 0xc1e00000, 0xcdc21008, 0xc1c00000, 0x58380006,
+ 0xcdc000f8, 0xc000e82c, 0xc1c00000, 0xcdfdce00, 0xc000e820, 0xc1c00000, 0xcdfc0000, 0x80000300,
+ 0xc0c00010, 0x98404c78, 0xc7cc0008, 0xc74c0b30, 0xc1000004, 0x800004a8, 0x5838001c, 0xca8000f8,
+ 0x5838001e, 0xca4000f8, 0x5aa80002, 0x5838001c, 0xce8000f8, 0x4668e000, 0x88000098, 0x58380022,
+ 0xca4000f8, 0x58380020, 0xca0000f8, 0xc000e82c, 0xc1c00000, 0xcdfdce00, 0xc000e810, 0xce7c0030,
+ 0xc2800000, 0x5838001c, 0xce8000f8, 0x5a200002, 0x58380020, 0xce0000f8, 0xc000e82c, 0xc1dc0002,
+ 0xcdfdce00, 0x58380006, 0xc8c000f8, 0x5830001c, 0xca8000f9, 0xca4000f9, 0xc2000000, 0xca000001,
+ 0x5dcc0006, 0x88000028, 0x58cc0002, 0x58380006, 0xccc000f8, 0x80000250, 0x5838000a, 0xc8c000f9,
+ 0xc90000f9, 0xc1400000, 0xc9400001, 0x74e86000, 0x75248000, 0x7560a000, 0x58380010, 0xca8000f9,
+ 0xca4000f9, 0xc2000000, 0xca000001, 0x98404de8, 0x74e86000, 0x75248000, 0x7560a000, 0x5dc800a0,
+ 0x840001ba, 0x58380016, 0xca8000f9, 0xca4000f9, 0xc2000000, 0xca000001, 0x98404de8, 0x74e86000,
+ 0x75248000, 0x7560a000, 0x5dc800a0, 0x84000162, 0x58380000, 0xc1e00004, 0xcdc21008, 0x5838001c,
+ 0xc1c00000, 0xcdc000f8, 0xc000e82c, 0xc1c00000, 0xcdfdce00, 0xc1f8001e, 0xc000ea1c, 0xcdfc00f8,
+ 0xc000e820, 0xc1c00002, 0xcdfc0000, 0xc1c00082, 0x45c8e000, 0xc000e810, 0xcdfc0030, 0xc2400000,
+ 0xc000e82c, 0xca7c0038, 0xc000e83c, 0xc2800000, 0xcabc0038, 0xc0c00010, 0x98404c78, 0xc7cc0008,
+ 0xc74c0b30, 0xc1000004, 0x5b740002, 0x4674e000, 0xc1c00000, 0xc5f400fe, 0x5ea80002, 0x8400ffb0,
+ 0xc000e83c, 0xc1c00000, 0xcdfc0038, 0xc000e82c, 0xc1dc0002, 0xcdfdce00, 0x80000178, 0x58380010,
+ 0xca8000f9, 0xca4000f9, 0xc2000000, 0xca000001, 0x58380016, 0xce8000f9, 0xce4000f9, 0xce000001,
+ 0x5838000a, 0xca8000f9, 0xca4000f9, 0xc2000000, 0xca000001, 0x58380010, 0xce8000f9, 0xce4000f9,
+ 0xce000001, 0x5830001c, 0xca8000f9, 0xca4000f9, 0xc2000000, 0xca000001, 0x5838000a, 0xce8000f9,
+ 0xce4000f9, 0xce000001, 0xc000facc, 0xc1c20002, 0xcdfc2100, 0xc0c00010, 0x98404c78, 0xc7cc0008,
+ 0xc74c0b30, 0xc1000004, 0xc000e83c, 0xc1d00002, 0xcdfd0800, 0xc0c00000, 0xc000e82c, 0xc8fc0038,
+ 0x5b740002, 0x00000000, 0x44f4e000, 0xc1c00000, 0xc5f400fe, 0x58380004, 0xcf4000f8, 0x98404ec0,
+ 0x00000000, 0x00000000, 0x00000000, 0xc0006914, 0xcbc000f8, 0xc2800000, 0xc2400000, 0x5bfc4b00,
+ 0xc7c000f8, 0xcb0000f8, 0x58000002, 0xcac000f8, 0xc0004026, 0xca800078, 0xc0004026, 0xca420078,
+ 0xc3400000, 0xc7366018, 0xa73e0172, 0x00000000, 0xc777e300, 0xc000694c, 0xc9c000f8, 0x00000000,
+ 0x00000000, 0x59dc0002, 0xcdc000f8, 0x6f5c6000, 0x58dcb640, 0x580c0000, 0xc90000f8, 0x580c0002,
+ 0xc94000f8, 0x59100002, 0x580c0000, 0xcd0000f8, 0xc1c00000, 0xc71c0078, 0x415ca000, 0x580c0002,
+ 0xcd4000f8, 0x98402008, 0x5834fc10, 0xc8c000f8, 0xc1000000, 0x5dc80000, 0x84000070, 0x6f402000,
+ 0x58005fe0, 0xc3800000, 0x58000000, 0xcb800078, 0xc1c00000, 0x58000002, 0xc9c00078, 0x984022c0,
+ 0x00000000, 0x439dc000, 0x00000000, 0x80000028, 0x98402098, 0xc48c00f8, 0x00000000, 0x00000000,
+ 0xc0006916, 0xcbc000f8, 0xc3400000, 0x00000000, 0x5bfc7a00, 0xc7c000f8, 0xcb0000f8, 0x58000002,
+ 0xcac000f8, 0xc7366018, 0xa73e0900, 0x00000000, 0xc777e300, 0xc000694e, 0xc9c000f8, 0x00000000,
+ 0x00000000, 0x59dc0002, 0xcdc000f8, 0x6f5c6000, 0x58dcb640, 0x580c0000, 0xc90000f8, 0x580c0002,
+ 0xc94000f8, 0x59100002, 0x580c0000, 0xcd0000f8, 0xc1c00000, 0xc71c0078, 0x415ca000, 0x580c0002,
+ 0xcd4000f8, 0x98402008, 0x5834fc10, 0xc8c000f8, 0xc1000000, 0x5dc80000, 0x84000070, 0x6f402000,
+ 0x58005fe0, 0xc3800000, 0x58000000, 0xcb800078, 0xc1c00000, 0x58000002, 0xc9c00078, 0x984025d0,
+ 0x00000000, 0x439dc000, 0x00000000, 0x800007b8, 0x984021c0, 0xc48c00f8, 0x00000000, 0x00000000,
+ 0x80000790, 0xc7100078, 0xc0800000, 0x6f402000, 0x58005fe0, 0xc1400000, 0x58000000, 0xc9420038,
+ 0x4690e000, 0x88000030, 0x454ca000, 0x9c400000, 0x4564e000, 0xc1c00004, 0xc5c800fe, 0x9c400000,
+ 0x454ce000, 0xc1c00002, 0xc5c800fe, 0xc0006914, 0xc90000f8, 0xc1400000, 0xc0004022, 0xc9400078,
+ 0x583c0000, 0xc1fc0000, 0xcdc3de00, 0x583c0000, 0xcd400078, 0x583c0000, 0xc1fe0002, 0xcdc3ff00,
+ 0x59100004, 0xc1c00100, 0x45d0e000, 0xc1c00000, 0xc5d000fe, 0xc0006914, 0xcd0000f8, 0x6f546000,
+ 0x5954b640, 0x5dcc0002, 0x84000038, 0x5814000c, 0xc9c000f8, 0x00000000, 0x00000000, 0x59dc0002,
+ 0xcdc000f8, 0x5814000e, 0xc9c000f8, 0x00000000, 0x9c400000, 0x59dc0002, 0xcdc000f8, 0x00000000,
+ 0xc0006916, 0xc90000f8, 0x583c0000, 0xc1fc0000, 0xcdc3de00, 0x583c0000, 0xc1fe0000, 0xcdc3ff00,
+ 0x59100004, 0xc1c00100, 0x45d0e000, 0xc1c00000, 0xc5d000fe, 0xc0006916, 0xcd0000f8, 0x6f546000,
+ 0x5954b640, 0x5dcc0002, 0x84000038, 0x58140008, 0xc9c000f8, 0x00000000, 0x00000000, 0x59dc0002,
+ 0xcdc000f8, 0x5814000a, 0xc9c000f8, 0x00000000, 0x9c400000, 0x59dc0002, 0xcdc000f8, 0x00000000,
+ 0x58380002, 0xc90000f8, 0x5c000002, 0xc8c000f8, 0xa53e0178, 0xc0006918, 0xca0000f8, 0x00000000,
+ 0x00000000, 0x5a205d00, 0xc60000f8, 0xc94000f8, 0x58000002, 0xc98000f8, 0xa57e006a, 0xc1c00000,
+ 0xc0c00004, 0xc71c0078, 0xc46000f8, 0x98402098, 0x45e8e000, 0xc1c00002, 0xc5cc00fe, 0x9e000000,
+ 0xc1e00002, 0xc000e408, 0xcdc21000, 0xc55c00f8, 0xc4d400f8, 0xc5cc00f8, 0xc59c00f8, 0xc51800f8,
+ 0xc5d000f8, 0xc1c00000, 0xc5d41f00, 0xc5d3ff00, 0x58200002, 0xcd8000f8, 0x5c000002, 0xcd4000f8,
+ 0x5e205d00, 0x5a200004, 0xc1c00100, 0x45e0e000, 0xc1c00000, 0xc5e000fe, 0xc0006918, 0xce0000f8,
+ 0xc1e00002, 0xc000e408, 0xcdc21000, 0xc6dc00f8, 0xc52c00f8, 0xc5d000f8, 0xc71c00f8, 0xc4f000f8,
+ 0xc5cc00f8, 0xc0004022, 0xcb000078, 0xc1c00002, 0xc5cc1f00, 0xc5f01f00, 0xc5f3fe00, 0x58380002,
+ 0xcd0000f8, 0x5c000002, 0xccc000f8, 0x6f402000, 0x58005fe0, 0xc1c00000, 0xc9c20138, 0xc2000000,
+ 0x58000002, 0xca000078, 0x00000000, 0x00000000, 0x5a200004, 0x45e0e000, 0xc1c00000, 0xc5e000fe,
+ 0xce000078, 0x5e3c4b00, 0x5a200004, 0xc1c00100, 0x45e0e000, 0xc1c00000, 0xc5e000fe, 0xc0006914,
+ 0xce0000f8, 0xc1c00002, 0x69f4e000, 0xc5dc0838, 0xd9f000f8, 0x583c0002, 0xcec000f8, 0x5c000002,
+ 0xcf0000f8, 0x9c400000, 0x58380002, 0xc90000f8, 0x5c000002, 0xc8c000f8, 0xc6dc00f8, 0xc52c00f8,
+ 0xc5d000f8, 0xc71c00f8, 0xc4f000f8, 0xc5cc00f8, 0xc1c00002, 0xc5cc1f00, 0xc1c00000, 0xc5f01f00,
+ 0xc5f3fe00, 0x58380002, 0xcd0000f8, 0x5c000002, 0xccc000f8, 0x6f402000, 0x58005fe0, 0xc1c00000,
+ 0xc9c20138, 0xc2000000, 0x58000002, 0xca000078, 0x00000000, 0x00000000, 0x5a200004, 0x45e0e000,
+ 0xc1c00000, 0xc5e000fe, 0xce000078, 0x5e3c7a00, 0x5a200004, 0xc1c00100, 0x45e0e000, 0xc1c00000,
+ 0xc5e000fe, 0xc0006916, 0xce0000f8, 0xc1c00002, 0x69f4e000, 0xc5dc0838, 0xd9f000f8, 0x583c0002,
+ 0xcec000f8, 0x5c000002, 0xcf0000f8, 0xc1e20002, 0xc000e408, 0xcdc23100, 0x9c400000, 0x00000000,
+ 0x00000000, 0x00000000, 0xc3c00000, 0x6ff8a000, 0x5bb87d80, 0x583cfb50, 0xc2800000, 0xca80c030,
+ 0xc2400000, 0x58380000, 0xca400078, 0x58380006, 0xca0000f8, 0x583cea28, 0xc9c000f8, 0xc0c00000,
+ 0x00000000, 0xc5cc0038, 0x420c8000, 0x4268a000, 0x4514e000, 0x880000aa, 0x58380004, 0xca4000f8,
+ 0xc000ea28, 0x6e1d2000, 0xcdfd2928, 0xc000ea28, 0xc1d00002, 0xcdfd0800, 0xc0006948, 0xc9c000f8,
+ 0x403c0000, 0x00000000, 0x41e0e000, 0xcdc000f8, 0x46612000, 0x58380004, 0xce4000f8, 0x58380006,
+ 0xc1c00000, 0xcdc000f8, 0x58380004, 0xca4000f8, 0x583cea28, 0xc9c000f8, 0xc0c00000, 0x00000000,
+ 0xc5cc0038, 0xc1400000, 0x58380000, 0xc9420078, 0x424d0000, 0x00000000, 0x42948000, 0x4520e000,
+ 0x8800163a, 0xc000fa40, 0xc9bc00f8, 0x6ff42000, 0xc3000000, 0xc5b4e000, 0xc2c07c00, 0x6f5ca000,
+ 0x42dd6000, 0x582c0022, 0xc98000f8, 0x00000000, 0x00000000, 0x5dd80000, 0x840003c2, 0x582c0026,
+ 0xca8000f8, 0x5838000a, 0xc98000f8, 0xc000ea10, 0xc2400000, 0xca7c0070, 0x6d9c8000, 0x41d8e000,
+ 0x425d2000, 0x5a644000, 0x582c002e, 0xc98000f8, 0x582c0030, 0xc94000f8, 0x00000000, 0x00000000,
+ 0x4194e000, 0xd9f800f8, 0x5ddc0080, 0x880000a2, 0x00000000, 0xa7400018, 0xc180001e, 0xc180015e,
+ 0xc1400000, 0x6d5c4010, 0x425c0000, 0xc1c00006, 0x755c8000, 0x5dd00000, 0xcd80183a, 0x5dd00002,
+ 0xcd80103a, 0x5dd00004, 0xcd80083a, 0x5dd00006, 0xcd80003a, 0x5b300008, 0x80000278, 0x58240002,
+ 0xc1800000, 0xcd8000f9, 0xcd8000f9, 0xcd8000f9, 0xcd8000f9, 0xcd8000f9, 0xcd8000f9, 0xcd8000f9,
+ 0xcd8000f9, 0xcd8000f9, 0xcd8000f9, 0xcd8000f9, 0xcd8000f9, 0xcd8000f9, 0xcd8000f9, 0xcd8000f9,
+ 0xcd8000f9, 0xa7400018, 0xc18001e0, 0xc18001ea, 0xc1400000, 0x6d5c4010, 0x425c0000, 0xc90000f8,
+ 0xc1c00000, 0xc55c0308, 0x691c8008, 0xc5901838, 0x691c8018, 0xcd0000f8, 0x6d5c4010, 0x425c0000,
+ 0xc1c00006, 0x755c8000, 0x5dd00000, 0xcd80183a, 0x5dd00002, 0xcd80103a, 0x5dd00004, 0xcd80083a,
+ 0x5dd00006, 0xcd80003a, 0x5b300008, 0xdf9400f8, 0xc1008fe0, 0x6d5c4010, 0x411c0000, 0xc98000f8,
+ 0xc1c00000, 0xc55c0308, 0x699cc000, 0x6d9b0010, 0x6f1c4010, 0x425c0000, 0xc94000f8, 0xc1c00000,
+ 0xc71c0308, 0x695ca008, 0xc5941838, 0x695ca018, 0xcd4000f8, 0x6f1c4010, 0x425c0000, 0xc1c00006,
+ 0x771ca000, 0x5dd40000, 0xcd80183a, 0x5dd40002, 0xcd80103a, 0x5dd40004, 0xcd80083a, 0x5dd40006,
+ 0xcd80003a, 0x5b300002, 0x582c0022, 0xc1c00000, 0xcdc000f8, 0x80000e18, 0xdb8800f9, 0xdb4800f8,
+ 0xc2400000, 0xdf240038, 0xc0004024, 0xcb8000f8, 0x00000000, 0xc3400000, 0xc7b50038, 0xc2800000,
+ 0xc7a88018, 0xc000fa40, 0xc8fc00f8, 0xc2800000, 0x582c0004, 0xca800038, 0xa4ce0042, 0x58ec0040,
+ 0xc1c00000, 0x580c0004, 0xc9c00038, 0x00000000, 0x00000000, 0x729d4000, 0x7e412000, 0x76692000,
+ 0xc0400000, 0xc7840008, 0xc000a0ae, 0x5de40000, 0x84000070, 0xc0c00000, 0xc8c000f8, 0x5dc40000,
+ 0xdcb800fb, 0xdcb400fa, 0x84000ffa, 0x5dcc0000, 0xdcb800fb, 0xdcb400fa, 0x84000fda, 0xc0c00000,
+ 0xccc000f8, 0x800001b8, 0xc0c00002, 0xccc000f8, 0xc65000f8, 0x61010028, 0x5dc40000, 0x84000018,
+ 0x62410008, 0x800002e8, 0x6e144000, 0x59544d08, 0xc0400000, 0x58140004, 0xc84000b8, 0xa78200d0,
+ 0xc0800000, 0xc1c00000, 0x6e1c2000, 0x59dc5fe0, 0x581c0002, 0xc8820078, 0x581c0000, 0xc9c00078,
+ 0xc1800000, 0x58140006, 0xc9800078, 0x409ce000, 0xc0800000, 0x581c0000, 0xc8800078, 0x00000000,
+ 0x00000000, 0x40b44000, 0x4588e000, 0x88000030, 0xc1c00002, 0x69e0e000, 0x7dc0e000, 0x765d2000,
+ 0x80000038, 0xa7800030, 0x5dc40000, 0x84000022, 0xc1ee0002, 0x75c4e000, 0xc4cc2002, 0x61010028,
+ 0xa60afed0, 0x00000000, 0x5de40000, 0xdcb800fb, 0xdcb400fa, 0x84000e22, 0x5dcc0000, 0x840000ba,
+ 0xa78000b0, 0x62810028, 0x840000a2, 0x6e0c4000, 0x58cc4d08, 0xc1000000, 0x580c0004, 0xc90000b8,
+ 0x580c0000, 0xc98000b8, 0x7d00a000, 0xc1f00002, 0x5ddc0002, 0x755ca000, 0x59540002, 0xc1ee0002,
+ 0x75d0e000, 0xc5d400fa, 0x45948000, 0x580c0004, 0xcd0000b8, 0x8000ff60, 0x5de40000, 0xdcb800fb,
+ 0xdcb400fa, 0x84000d42, 0x62410008, 0xa7800098, 0x00000000, 0xc0c00000, 0xc65000f8, 0x6100a028,
+ 0x6d584000, 0x59984d08, 0xc0400000, 0x58180004, 0xc84000b8, 0x00000000, 0x00000000, 0xa46e002a,
+ 0x44c4e000, 0x88000018, 0xc56000f8, 0xc44c00f8, 0x6100a028, 0xa54aff98, 0x6e184000, 0x59984d08,
+ 0xc0400000, 0xc0800000, 0x6e1c2000, 0x59dc5fe0, 0x581c0002, 0xc8420078, 0x581c0000, 0xc8800078,
+ 0xc1400000, 0x58180006, 0xc9400078, 0x40484000, 0xc0c00000, 0x58080000, 0xc8c00078, 0x00000000,
+ 0xa7820038, 0x40f42000, 0x5dd5fffe, 0x84000022, 0x4544a000, 0x58180006, 0xcd400078, 0xa7800088,
+ 0xc0400000, 0x58180000, 0xc84000b8, 0xc1000000, 0x58180004, 0xc90000b8, 0x5dc40000, 0x8400004a,
+ 0xc1ee0002, 0x5ddc0002, 0x445ce000, 0x8400002a, 0x450c8000, 0x45348000, 0x58180004, 0xcd0000b8,
+ 0x6e106000, 0x5910b640, 0x58100006, 0xc98000f8, 0x58100004, 0xc94000f8, 0x418cc000, 0x58100006,
+ 0xcd8000f8, 0x59540002, 0x58100004, 0xcd4000f8, 0x6e242000, 0x5a645fe0, 0xc0c00000, 0x58240002,
+ 0xc8c20078, 0xc1000000, 0x58240000, 0xc9020038, 0x582c002a, 0xcc8000f8, 0x582c002c, 0xce0000f8,
+ 0x6d102000, 0x58cc0004, 0x450ce000, 0xc1c00000, 0xc5cc00fe, 0x58240002, 0x6cde0000, 0xcdc21078,
+ 0xc0e00002, 0x68e06000, 0xd8f000f8, 0xdcb800f9, 0xdcb400f8, 0xc0006910, 0xc8c000f9, 0xc90000f8,
+ 0xc1c00000, 0xc1400040, 0x60c04000, 0x7494e000, 0x8400007a, 0xc1400080, 0x61004000, 0x58880040,
+ 0x7494e000, 0x84000052, 0x00000000, 0xab6c0002, 0x00000000, 0x00000000, 0x984047e8, 0xc0006902,
+ 0xc8c000f8, 0xc3c00000, 0x8000ff58, 0xc0006910, 0xc1c00000, 0xc49ca000, 0x401c0000, 0xc8c000f8,
+ 0xc1000002, 0xc1400000, 0xc4940020, 0x6914e000, 0x70dc6000, 0xccc000f8, 0x582c0020, 0xcc8000f8,
+ 0xc1c00002, 0x582c0022, 0xcdc000f8, 0xc2409c00, 0x6c9c6000, 0x425d2000, 0xc2807600, 0x6c9c6000,
+ 0x429d4000, 0x582c002c, 0xc98000f8, 0x582c0026, 0xce8000f8, 0x582c0028, 0xce4000f8, 0x58240008,
+ 0xcd8000f8, 0x5838000a, 0xc98000f8, 0xc000ea10, 0xc2000000, 0xca3c0070, 0x6d9c8000, 0x41d8e000,
+ 0x421d0000, 0x5a204000, 0x582c002a, 0xc98000f8, 0xc1400000, 0xc1000000, 0x58180000, 0xc942e020,
+ 0x58180002, 0xc90000e0, 0x5828000e, 0xcd8000f8, 0x58280002, 0xc1c00000, 0xcdc00078, 0x41148000,
+ 0x58280004, 0xcd0000e0, 0x58a40000, 0x586c0008, 0xc44000f8, 0xc8c000f9, 0xc90000f9, 0xc94000f8,
+ 0xc48000f8, 0xccc000f9, 0xcd0000f9, 0xcd4000f9, 0x5df00000, 0x84000138, 0x58200000, 0xc1800000,
+ 0xcd8000f9, 0xcd8000f9, 0xcd8000f9, 0xcd8000f9, 0xcd8000f9, 0xcd8000f9, 0xcd8000f9, 0xcd8000f9,
+ 0xcd8000f9, 0xcd8000f9, 0xcd8000f9, 0xcd8000f9, 0xcd8000f9, 0xcd8000f9, 0xcd8000f9, 0xcd8000f9,
+ 0xcd8000f9, 0xc18001ea, 0xc1c00002, 0x75f4e000, 0xc1c001e0, 0xc5d800fa, 0xc1400000, 0x6d5c4010,
+ 0x421c0000, 0xc1c00006, 0x755c8000, 0x5dd00000, 0xcd80183a, 0x5dd00002, 0xcd80103a, 0x5dd00004,
+ 0xcd80083a, 0x5dd00006, 0xcd80003a, 0x5b300008, 0xc000fa40, 0xc93c00f8, 0xc1400000, 0x582c0002,
+ 0xc9428018, 0xc0400000, 0xc0800080, 0x44944000, 0xc45800f8, 0xc1c00200, 0x75d0e000, 0xc49c00f8,
+ 0xc5d800fa, 0x582c0030, 0xcd4000f8, 0xd97800f8, 0x5828000e, 0xc9c000f8, 0xc0c00000, 0x582c0002,
+ 0xc8c10038, 0xc1000000, 0x581c0000, 0xc9000078, 0x00000000, 0x00000000, 0xc50800f8, 0x4518e000,
+ 0xc59c00f8, 0xc5c800fc, 0xc4d400f8, 0x44c8e000, 0xc49c00f8, 0xc5d400fc, 0x582c002e, 0xcd4000f8,
+ 0xdf9000f8, 0x4150e000, 0xd9f800f8, 0x41f0e000, 0x5ddc0086, 0x88000082, 0xc18000a0, 0x6f1c4010,
+ 0x421c0000, 0xc1c00006, 0x771ca000, 0x5dd40000, 0xcd80183a, 0x5dd40002, 0xcd80103a, 0x5dd40004,
+ 0xcd80083a, 0x5dd40006, 0xcd80003a, 0x5b300002, 0x80000158, 0x00000000, 0x00000000, 0x00000000,
+ 0xdf9400f8, 0xc1008fe0, 0x6d5c4010, 0x411c0000, 0xc98000f8, 0xc1c00000, 0xc55c0308, 0x699cc000,
+ 0x6d9b0010, 0x6f1c4010, 0x421c0000, 0xc1c00006, 0x771c6000, 0x5dcc0000, 0xcd80183a, 0x5dcc0002,
+ 0xcd80103a, 0x5dcc0004, 0xcd80083a, 0x5dcc0006, 0xcd80003a, 0x5b300002, 0xc18000a0, 0x6f1c4010,
+ 0x421c0000, 0xc1c00006, 0x771ca000, 0x5dd40000, 0xcd80183a, 0x5dd40002, 0xcd80103a, 0x5dd40004,
+ 0xcd80083a, 0x5dd40006, 0xcd80003a, 0x5b300002, 0x582c0022, 0xc1c00000, 0xcdc000f8, 0x00000000,
+ 0x00000000, 0x5df00088, 0x880002f8, 0x582c0020, 0xc98000f8, 0xc2800000, 0xc2400000, 0xc5a80528,
+ 0x582c002e, 0xc98000f8, 0xc1000088, 0x45308000, 0xc51400f8, 0x4590e000, 0xc59c00f8, 0xc5d400fc,
+ 0xc5681930, 0x5838000a, 0xc90000f8, 0xc7281230, 0xc7e80008, 0xc5280b30, 0xd93800f8, 0xc1c00002,
+ 0xc5e80400, 0x4594e000, 0x8400001a, 0xc1c00000, 0xc5e80400, 0x5dd80000, 0x8400002a, 0xc1c00002,
+ 0xc5e80300, 0xc1c00002, 0xc5e80200, 0x582c0022, 0xc94000f8, 0xc7640e08, 0x00000000, 0x5d540002,
+ 0x8400001a, 0xc1c00002, 0xc5e40d00, 0xc0c00000, 0xc68f2030, 0x430c8000, 0xc5241838, 0xc0800088,
+ 0x44904000, 0xc1c00000, 0xc5c800fc, 0x582c0030, 0xc94000f8, 0xc0400000, 0x582c0002, 0xc8420018,
+ 0xc49000f8, 0x4548e000, 0xc55c00f8, 0xc5d000fc, 0xc5241418, 0x44546000, 0xc4e41018, 0x4550a000,
+ 0x582c0030, 0xcd4000f8, 0xc0c00000, 0xc68f2030, 0x458cc000, 0x582c002e, 0xcd8000f8, 0x43118000,
+ 0x430d8000, 0xdf9800f8, 0xc000ea10, 0xc1400000, 0xc97c0070, 0x6d9c8000, 0x41d8e000, 0x415ca000,
+ 0x59544000, 0x00000000, 0xc1000000, 0xc0000000, 0xc9140038, 0x00000000, 0x00000000, 0x59100002,
+ 0xcd140038, 0x98404d30, 0xc68c00f8, 0xc65000f8, 0x00000000, 0x5df00088, 0x8800ef02, 0x00000000,
+ 0x80000008, 0x5df00000, 0x840000ba, 0xc1c00002, 0xc000691c, 0xcdc000f8, 0x5838000a, 0xc94000f8,
+ 0xc1000000, 0xc000ea14, 0xc93c0038, 0x59540002, 0x00000000, 0x4514e000, 0xc1c00000, 0xc5d400fe,
+ 0x5838000a, 0xcd4000f8, 0x58380004, 0xc94000f8, 0x00000000, 0x00000000, 0x59540002, 0x58380004,
+ 0xcd4000f8, 0x5df00000, 0x84000058, 0xa7400020, 0x00000000, 0x6ff42000, 0x8000ea00, 0x5bfc0002,
+ 0x5dfc0002, 0x8400e812, 0x00000000, 0x00000000, 0x00000000, 0xab6c0052, 0x984047e8, 0xc0006902,
+ 0xc8c000f8, 0xc3c00000, 0xab6c002a, 0x984047e8, 0xc0006902, 0xc8c000f8, 0xc3c00000, 0xc0004032,
+ 0xcbc000f8, 0xc0004038, 0xcb8000f8, 0xc000691a, 0xcb0000f8, 0xc000403a, 0xcb4000f8, 0xc72c00f8,
+ 0xa7800058, 0xc2800000, 0x00000000, 0x984041b8, 0xc0c07c80, 0xc0007c00, 0x00000000, 0x98404220,
+ 0xc0006952, 0xc80000f8, 0xc1000000, 0xa7900058, 0xc2800002, 0x00000000, 0x984041b8, 0xc0c07c80,
+ 0xc0007c00, 0x00000000, 0x98404220, 0xc0006952, 0xc80000f8, 0xc1000000, 0x472ce000, 0x8400023a,
+ 0xc0c00000, 0xc78e0020, 0xc1c00002, 0x69cc8000, 0xc78f0020, 0x69cce000, 0x711c8000, 0xc000f41a,
+ 0xcfc000f8, 0xc1c00000, 0xc7dc4050, 0x581cc000, 0xcb0000f8, 0x00000000, 0x00000000, 0x76d16000,
+ 0x7d008000, 0x77118000, 0x732d8000, 0xcf0000f8, 0xc000691a, 0xcec000f8, 0x80000180, 0x5ea80000,
+ 0xc40c00fa, 0xc2400000, 0x580c0004, 0xca400038, 0x58cc0040, 0xc1c00000, 0x580c0004, 0xc9c00038,
+ 0x9c400000, 0x00000000, 0x00000000, 0x725d2000, 0x62406028, 0x84000032, 0xc9cc00f8, 0x00000000,
+ 0x00000000, 0x411c8000, 0x8000ffd0, 0xc1400000, 0xc7970020, 0x6f4e0010, 0x5de80000, 0xc74c00fa,
+ 0xc7960022, 0xc1c00000, 0xc4dd0038, 0x45d0e000, 0x88000048, 0xc1c00000, 0xc4dc0038, 0x451ce000,
+ 0x88000050, 0x9c400000, 0x00000000, 0x00000000, 0x00000000, 0xc1c00002, 0x9c400000, 0x69d4e000,
+ 0x7dc0e000, 0x76dd6000, 0x9c400000, 0xc1c00002, 0x69d4e000, 0x72dd6000, 0xc0004028, 0xcbc000f8,
+ 0xc000691c, 0xcb8000f8, 0xa7c0c780, 0x00000000, 0x5df80000, 0x8400c768, 0xc1c00002, 0xc000e070,
+ 0xcdc00000, 0x8000c748, 0xdcbc00f9, 0xdcb800f8, 0xdd3400f9, 0xc2400040, 0xc000690c, 0xc8c000f9,
+ 0xc90000f8, 0xc1c00000, 0x60c18000, 0x7724e000, 0x84000052, 0x61018000, 0x7724e000, 0x84000032,
+ 0x98404ec0, 0x00000000, 0x00000000, 0x00000000, 0x8000ff90, 0x5b300040, 0xc2c09400, 0x6f1c6000,
+ 0x42dd6000, 0xc2809800, 0x429d4000, 0x58340022, 0xcf0000f8, 0x582c0008, 0xcf8000f8, 0xc000690c,
+ 0xc1c00000, 0xc71ca000, 0x401c0000, 0xc8c000f8, 0xc2000002, 0x6a30e000, 0x70dc6000, 0xccc000f8,
+ 0x58340008, 0xc8c000f9, 0xc90000f9, 0xc94000f9, 0x582c0000, 0xccc000f9, 0xcd0000f9, 0xcd4000f9,
+ 0x58340010, 0xc9c000f9, 0xc8c000f9, 0xc90000f9, 0xc94000f9, 0xc98000f9, 0xc84000f9, 0xc88000f9,
+ 0x58280000, 0xcdc000f9, 0xccc000f9, 0xcd0000f9, 0xcd4000f9, 0xcd8000f9, 0xcc4000f9, 0xcc8000f9,
+ 0xc1c00000, 0x5828000e, 0xc9c3e000, 0x00000000, 0x00000000, 0x5ddc0002, 0x840001ba, 0xc0006908,
+ 0xc8c000f8, 0xc0004c00, 0xc1000000, 0x400c0000, 0x58000000, 0xc903e000, 0x00000000, 0x00000000,
+ 0x5dd00002, 0x840000e8, 0xc1000000, 0x58000002, 0xc90000e0, 0xc1c00000, 0xc0004022, 0xc9c20008,
+ 0x5828000e, 0xcd0000e0, 0x411ce000, 0x58280004, 0xcdc000e0, 0x5828000e, 0xc1fe0002, 0xcdc3ff00,
+ 0x5828000e, 0xc1fc0000, 0xcdc3de00, 0x58340020, 0xc1c00000, 0xcdc000f8, 0x58cc0004, 0xc1c00100,
+ 0x45cce000, 0xc1c00000, 0xc5cc00fe, 0xc0006908, 0xccc000f8, 0x800000f8, 0xc0c0b600, 0x6f9c6000,
+ 0x40dc6000, 0x580c0004, 0xc90000f8, 0x5828000e, 0xc1fc0002, 0xcdc3de00, 0x58340020, 0xc1c00002,
+ 0xcdc000f8, 0x59100002, 0x580c0004, 0xcd0000f8, 0x80000080, 0xc0c00000, 0xc0004022, 0xc8c20008,
+ 0xc1000000, 0x5828000e, 0xc90000e0, 0x5828000e, 0xc1fc0000, 0xcdc3de00, 0x58340020, 0xc1c00000,
+ 0xcdc000f8, 0x410ce000, 0x58280004, 0xcdc000e0, 0x94000000, 0xc1c00002, 0xc000691c, 0xcdc000f8,
+ 0xd87800f8, 0xc3800000, 0x580c7400, 0xca4000f9, 0xca0000f8, 0xc3400000, 0xc67c0008, 0xc639c008,
+ 0xc674a028, 0xc0c00000, 0xc64d6030, 0xc000ea10, 0xc3000000, 0xcb3c0070, 0x6cdc8000, 0x41cce000,
+ 0x431d8000, 0x5b304000, 0x6faca000, 0x5aec7c00, 0xc0c00000, 0xc0000000, 0xc8f00038, 0x6f686000,
+ 0x5aa89c00, 0x5ccc0002, 0xccf00038, 0xc1000000, 0xc6128018, 0x5dd00000, 0x840000f2, 0xc1800000,
+ 0xc0800000, 0xc61a0018, 0xc60b0038, 0xc1c40002, 0x419cc000, 0x6d9c4010, 0x429c0000, 0xc94000f8,
+ 0xc1c00000, 0xc59c0308, 0x695ca000, 0x6d570010, 0x59980002, 0x6c9c4010, 0x431c0000, 0xc1c00006,
+ 0x749c2000, 0x5dc40000, 0xcd40183a, 0x5dc40002, 0xcd40103a, 0x5dc40004, 0xcd40083a, 0x5dc40006,
+ 0xcd40003a, 0x58880002, 0x5d100002, 0x8400ff50, 0xa61a00a0, 0x582c002a, 0xc90000f8, 0xc0000000,
+ 0xc1c00000, 0xcdd3ff00, 0xc1000002, 0x58280008, 0xc94000f8, 0x5df40040, 0xc0006912, 0x44100004,
+ 0xc98000f8, 0x6934e000, 0x7dc0e000, 0x759cc000, 0xcd8000f8, 0xc1b00002, 0x6994c000, 0xd9b000f8,
+ 0x5ccc0000, 0x84000160, 0x6fcca000, 0x58cc7d80, 0x580c0006, 0xc90000f8, 0xc1400000, 0xc615a000,
+ 0x59100002, 0x580c0006, 0xcd0000f8, 0xc1c00000, 0x7d40a000, 0xc55c0000, 0x582c0024, 0xcdc000f8,
+ 0xa61a00e8, 0x7f80e000, 0xc5f80000, 0x6faca000, 0x5aec7c00, 0x582c0024, 0xc94000f8, 0x580c0004,
+ 0xc98000f8, 0x5dd40002, 0x8400009a, 0xc000ea28, 0x6d1d2000, 0xcdfd2928, 0xc000ea28, 0xc1d00002,
+ 0xcdfd0800, 0xc0006948, 0xc9c000f8, 0x403c0000, 0x00000000, 0x41d0e000, 0xcdc000f8, 0x4590c000,
+ 0x580c0004, 0xcd8000f8, 0x580c0006, 0xc1c00000, 0xcdc000f8, 0xc0006902, 0xc8c000f8, 0x00000000,
+ 0x00000000, 0x58cc0004, 0xc1c00200, 0x45cce000, 0xc1c00000, 0xc5cc00fe, 0xccc000f8, 0xc000f01e,
+ 0xc1d00002, 0xcdc10800, 0xdf8400f8, 0x9c400000, 0x00000000, 0x00000000, 0x00000000, 0xc0006904,
+ 0xc94000f8, 0xab68008a, 0x00000000, 0x58147200, 0xccc000f9, 0xcd0000f9, 0xc000f016, 0xc1d00002,
+ 0xcdc10800, 0x59540004, 0xc1c00200, 0x45d4e000, 0xc1c00000, 0xc5d400fe, 0x9c400000, 0xc0006904,
+ 0xcd4000f8, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8000ff60, 0xc0006906, 0xc94000f8,
+ 0xab6a008a, 0x00000000, 0x58147400, 0xccc000f9, 0xcd0000f9, 0xc000f404, 0xc1d00002, 0xcdc10800,
+ 0x59540004, 0xc1c00200, 0x45d4e000, 0xc1c00000, 0xc5d400fe, 0x9c400000, 0xc0006906, 0xcd4000f8,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8000ff60, 0xc08000a0, 0x74d0c000, 0x84000090,
+ 0x78d0c000, 0x8400006a, 0x61800018, 0x6180e008, 0x441cc000, 0x84000060, 0x5d940000, 0x84000050,
+ 0x60c04008, 0xa48a0040, 0x9c400000, 0x61004008, 0x58880040, 0x00000000, 0xa5400018, 0x00000000,
+ 0xc0800080, 0x9c400000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xc000f412, 0xc9c000f8, 0xc1800000, 0xc0800000, 0xa5c004e8, 0xc5d82028, 0x6d886000, 0x59089800,
+ 0x5810000e, 0xc9c3c000, 0x59489400, 0xd9b800f8, 0xa5c0044a, 0x58140008, 0xc98000f8, 0xc0c07b00,
+ 0xc0800000, 0x6d9ca000, 0x40dc6000, 0xd9b800f8, 0x580c0002, 0xc8808000, 0x00000000, 0x00000000,
+ 0xa480004a, 0x580c0004, 0xc98000f8, 0x58140002, 0xc88000f8, 0x00000000, 0x00000000, 0x4498e000,
+ 0x84000110, 0xc1c00000, 0x580c0002, 0xc9c04000, 0x00000000, 0x00000000, 0xa5c0004a, 0x580c0006,
+ 0xc98000f8, 0x58140004, 0xc88000f8, 0x00000000, 0x00000000, 0x4498e000, 0x840000a0, 0xc0800000,
+ 0x58100002, 0xc8800078, 0x580c001e, 0xc94000f8, 0xc1800000, 0x580c0002, 0xc9810038, 0x40944000,
+ 0xa4be0052, 0xc1400000, 0x4498e000, 0x88000118, 0x580c0002, 0xc940e000, 0x00000000, 0x00000000,
+ 0xa54000ca, 0xc1c00000, 0x00000000, 0x00000000, 0x00000000, 0xdf9400f8, 0x00000000, 0x00000000,
+ 0xc1800000, 0xc5582000, 0xa5400042, 0xc000fb64, 0xc1c00002, 0xcdd80000, 0xc000facc, 0xc1c40002,
+ 0xcdd84200, 0x80000220, 0xc000fb64, 0xc1c20002, 0xcdd82100, 0xc000facc, 0xc1c60002, 0xcdd86300,
+ 0x800001e8, 0x580c0002, 0xc9c10038, 0x00000000, 0x00000000, 0x589c0000, 0xc000690a, 0xc94000f8,
+ 0xc1c00000, 0x5810000e, 0xc9c000e0, 0x59944c00, 0x58180000, 0xcc800078, 0x58180002, 0xcdc000e0,
+ 0x58180000, 0xc1fa0002, 0xcdc3bd00, 0x58180000, 0xc1f80002, 0xcdc39c00, 0x58180000, 0xc1fe0000,
+ 0xcdc3ff00, 0x59540004, 0xc1c00100, 0x45d4e000, 0xc1c00000, 0xc5d400fe, 0xc000690a, 0xcd4000f8,
+ 0xc000e408, 0xc1c00002, 0xcdc000f8, 0x5810000e, 0xc1fe0000, 0xcdc3ff00, 0xdf9400f8, 0xc1800000,
+ 0x58100002, 0xc9800078, 0x6d486000, 0x5888b600, 0x58080006, 0xc9c000f8, 0x00000000, 0x00000000,
+ 0x419cc000, 0x58080006, 0xcd8000f8, 0xc1800000, 0xc5582000, 0xa540002a, 0xc000fb60, 0xc1c40002,
+ 0xcdd84200, 0x80000020, 0xc000fb60, 0xc1c60002, 0xcdd86300, 0xdf9400f8, 0xc1800002, 0x00000000,
+ 0x00000000, 0x5dd40040, 0xc000690e, 0x44180004, 0xc88000f8, 0x6994e000, 0x7dc0e000, 0x749c4000,
+ 0xcc8000f8, 0x9c400000, 0x00000000, 0x00000000, 0x00000000, 0xc3c00000, 0xc4fc8018, 0xc3800000,
+ 0x6fb44000, 0x5b744d08, 0xc3000000, 0x58340006, 0xcb020038, 0xc2c00000, 0xc2800000, 0x5f300002,
+ 0x84000080, 0x58340006, 0xcac00078, 0x58340002, 0xca800078, 0xc2000000, 0x58340002, 0xca020078,
+ 0x42e92000, 0x00000000, 0x4624e000, 0xc62400fc, 0x58340000, 0xcb030038, 0x58340006, 0xce400078,
+ 0x58340006, 0x6f1e0000, 0xcdc21038, 0x5bb80002, 0x47bce000, 0x8800ff1a, 0x8000b410, 0x00000000,
+ 0x00000000, 0x00000000,};
+
+static unsigned int firmware_binary_data[] = {
+};
+
+
+#endif // IFXMIPS_PTM_FW_VR9_H
diff --git a/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_ppe_amazon_se.h.svn-base b/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_ppe_amazon_se.h.svn-base
new file mode 100644
index 0000000..f912039
--- /dev/null
+++ b/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_ppe_amazon_se.h.svn-base
@@ -0,0 +1,186 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_ptm_ppe_amazon_se.h
+** PROJECT : UEIP
+** MODULES : PTM
+**
+** DATE : 7 Jul 2009
+** AUTHOR : Xu Liang
+** DESCRIPTION : PTM driver header file (PPE register for Amazon-SE)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 07 JUL 2009 Xu Liang Init Version
+*******************************************************************************/
+
+
+
+#ifndef IFXMIPS_PTM_PPE_AMAZON_SE_H
+#define IFXMIPS_PTM_PPE_AMAZON_SE_H
+
+
+
+/*
+ * FPI Configuration Bus Register and Memory Address Mapping
+ */
+#define IFX_PPE (KSEG1 | 0x1E180000)
+#define PP32_DEBUG_REG_ADDR(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x0000) << 2)))
+#define PPM_INT_REG_ADDR(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x0030) << 2)))
+#define PP32_INTERNAL_RES_ADDR(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x0040) << 2)))
+#define CDM_CODE_MEMORY(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x1000) << 2)))
+#define PPE_REG_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x4000) << 2)))
+#define CDM_DATA_MEMORY(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x5000) << 2)))
+#define PPM_INT_UNIT_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6000) << 2)))
+#define PPM_TIMER0_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6100) << 2)))
+#define PPM_TASK_IND_REG_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6200) << 2)))
+#define PPS_BRK_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6300) << 2)))
+#define PPM_TIMER1_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6400) << 2)))
+#define SB_RAM0_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x8200) << 2)))
+#define SB_RAM1_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x8C00) << 2)))
+#define QSB_CONF_REG_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0xC000) << 2)))
+
+/*
+ * DWORD-Length of Memory Blocks
+ */
+#define PP32_DEBUG_REG_DWLEN 0x0030
+#define PPM_INT_REG_DWLEN 0x0010
+#define PP32_INTERNAL_RES_DWLEN 0x00C0
+#define CDM_CODE_MEMORYn_DWLEN(n) ((n) == 0 ? 0x1000 : 0x0800)
+#define PPE_REG_DWLEN 0x1000
+#define CDM_DATA_MEMORY_DWLEN CDM_CODE_MEMORYn_DWLEN(1)
+#define PPM_INT_UNIT_DWLEN 0x0100
+#define PPM_TIMER0_DWLEN 0x0100
+#define PPM_TASK_IND_REG_DWLEN 0x0100
+#define PPS_BRK_DWLEN 0x0100
+#define PPM_TIMER1_DWLEN 0x0100
+#define SB_RAM0_DWLEN 0x0A00
+#define SB_RAM1_DWLEN 0x0A00
+#define QSB_CONF_REG_DWLEN 0x0100
+
+/*
+ * PP32 to FPI Address Mapping
+ */
+#define SB_BUFFER(__sb_addr) ((volatile unsigned int *)((((__sb_addr) >= 0x0000) && ((__sb_addr) <= 0x0FFF)) ? PPE_REG_ADDR((__sb_addr) - 0x0000) : \
+ (((__sb_addr) >= 0x2200) && ((__sb_addr) <= 0x2BFF)) ? SB_RAM0_ADDR((__sb_addr) - 0x2200) : \
+ (((__sb_addr) >= 0x2C00) && ((__sb_addr) <= 0x35FF)) ? SB_RAM1_ADDR((__sb_addr) - 0x2C00) : \
+ 0))
+
+/*
+ * PP32 Debug Control Register
+ */
+#define NUM_OF_PP32 1
+
+#define PP32_DBG_CTRL(n) PP32_DEBUG_REG_ADDR(n, 0x0000)
+
+#define DBG_CTRL_RESTART 0
+#define DBG_CTRL_STOP 1
+
+#define PP32_CTRL_CMD(n) PP32_DEBUG_REG_ADDR(n, 0x0B00)
+ #define PP32_CTRL_CMD_RESTART (1 << 0)
+ #define PP32_CTRL_CMD_STOP (1 << 1)
+ #define PP32_CTRL_CMD_STEP (1 << 2)
+ #define PP32_CTRL_CMD_BREAKOUT (1 << 3)
+
+#define PP32_CTRL_OPT(n) PP32_DEBUG_REG_ADDR(n, 0x0C00)
+ #define PP32_CTRL_OPT_BREAKOUT_ON_STOP_ON (3 << 0)
+ #define PP32_CTRL_OPT_BREAKOUT_ON_STOP_OFF (2 << 0)
+ #define PP32_CTRL_OPT_BREAKOUT_ON_BREAKIN_ON (3 << 2)
+ #define PP32_CTRL_OPT_BREAKOUT_ON_BREAKIN_OFF (2 << 2)
+ #define PP32_CTRL_OPT_STOP_ON_BREAKIN_ON (3 << 4)
+ #define PP32_CTRL_OPT_STOP_ON_BREAKIN_OFF (2 << 4)
+ #define PP32_CTRL_OPT_STOP_ON_BREAKPOINT_ON (3 << 6)
+ #define PP32_CTRL_OPT_STOP_ON_BREAKPOINT_OFF (2 << 6)
+ #define PP32_CTRL_OPT_BREAKOUT_ON_STOP(n) (*PP32_CTRL_OPT(n) & (1 << 0))
+ #define PP32_CTRL_OPT_BREAKOUT_ON_BREAKIN(n) (*PP32_CTRL_OPT(n) & (1 << 2))
+ #define PP32_CTRL_OPT_STOP_ON_BREAKIN(n) (*PP32_CTRL_OPT(n) & (1 << 4))
+ #define PP32_CTRL_OPT_STOP_ON_BREAKPOINT(n) (*PP32_CTRL_OPT(n) & (1 << 6))
+
+#define PP32_BRK_PC(n, i) PP32_DEBUG_REG_ADDR(n, 0x0900 + (i) * 2)
+#define PP32_BRK_PC_MASK(n, i) PP32_DEBUG_REG_ADDR(n, 0x0901 + (i) * 2)
+#define PP32_BRK_DATA_ADDR(n, i) PP32_DEBUG_REG_ADDR(n, 0x0904 + (i) * 2)
+#define PP32_BRK_DATA_ADDR_MASK(n, i) PP32_DEBUG_REG_ADDR(n, 0x0905 + (i) * 2)
+#define PP32_BRK_DATA_VALUE_RD(n, i) PP32_DEBUG_REG_ADDR(n, 0x0908 + (i) * 2)
+#define PP32_BRK_DATA_VALUE_RD_MASK(n, i) PP32_DEBUG_REG_ADDR(n, 0x0909 + (i) * 2)
+#define PP32_BRK_DATA_VALUE_WR(n, i) PP32_DEBUG_REG_ADDR(n, 0x090C + (i) * 2)
+#define PP32_BRK_DATA_VALUE_WR_MASK(n, i) PP32_DEBUG_REG_ADDR(n, 0x090D + (i) * 2)
+ #define PP32_BRK_CONTEXT_MASK(i) (1 << (i))
+ #define PP32_BRK_CONTEXT_MASK_EN (1 << 4)
+ #define PP32_BRK_COMPARE_GREATER_EQUAL (1 << 5) // valid for break data value rd/wr only
+ #define PP32_BRK_COMPARE_LOWER_EQUAL (1 << 6)
+ #define PP32_BRK_COMPARE_EN (1 << 7)
+
+#define PP32_BRK_SRC(n) PP32_DEBUG_REG_ADDR(n, 0x0F00)
+#define PP32_BRK_TRIG(n) PP32_BRK_SRC(n)
+ #define PP32_BRK_GRPi_PCn_ON(i, n) ((3 << ((n) * 2)) << ((i) * 16))
+ #define PP32_BRK_GRPi_PCn_OFF(i, n) ((2 << ((n) * 2)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_ADDRn_ON(i, n) ((3 << ((n) * 2 + 4)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_ADDRn_OFF(i, n) ((2 << ((n) * 2 + 4)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_VALUE_RDn_ON(i, n) ((3 << ((n) * 2 + 8)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_VALUE_RDn_OFF(i, n)((2 << ((n) * 2 + 8)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_VALUE_WRn_ON(i, n) ((3 << ((n) * 2 + 12)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_VALUE_WRn_OFF(i, n)((2 << ((n) * 2 + 12)) << ((i) * 16))
+ #define PP32_BRK_GRPi_PCn(k, i, n) (*PP32_BRK_TRIG(k) & ((1 << ((n))) << ((i) * 8)))
+ #define PP32_BRK_GRPi_DATA_ADDRn(k, i, n) (*PP32_BRK_TRIG(k) & ((1 << ((n) + 2)) << ((i) * 8)))
+ #define PP32_BRK_GRPi_DATA_VALUE_RDn(k, i, n) (*PP32_BRK_TRIG(k) & ((1 << ((n) + 4)) << ((i) * 8)))
+ #define PP32_BRK_GRPi_DATA_VALUE_WRn(k, i, n) (*PP32_BRK_TRIG(k) & ((1 << ((n) + 6)) << ((i) * 8)))
+
+#define PP32_CPU_STATUS(n) PP32_DEBUG_REG_ADDR(n, 0x0D00)
+#define PP32_HALT_STAT(n) PP32_CPU_STATUS(n)
+#define PP32_DBG_CUR_PC(n) PP32_DEBUG_REG_ADDR(n, 0x0F80)
+ #define PP32_CPU_USER_STOPPED(n) (*PP32_CPU_STATUS(n) & (1 << 0))
+ #define PP32_CPU_USER_BREAKIN_RCV(n) (*PP32_CPU_STATUS(n) & (1 << 1))
+ #define PP32_CPU_USER_BREAKPOINT_MET(n) (*PP32_CPU_STATUS(n) & (1 << 2))
+ #define PP32_CPU_CUR_PC(n) (*PP32_DBG_CUR_PC(n) & 0xFFFF)
+
+#define PP32_BREAKPOINT_REASONS(n) PP32_DEBUG_REG_ADDR(n, 0x0A00)
+ #define PP32_BRK_PC_MET(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << (i)))
+ #define PP32_BRK_DATA_ADDR_MET(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) + 2)))
+ #define PP32_BRK_DATA_VALUE_RD_MET(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) + 4)))
+ #define PP32_BRK_DATA_VALUE_WR_MET(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) + 6)))
+ #define PP32_BRK_DATA_VALUE_RD_LO_EQ(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) * 2 + 8)))
+ #define PP32_BRK_DATA_VALUE_RD_GT_EQ(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) * 2 + 9)))
+ #define PP32_BRK_DATA_VALUE_WR_LO_EQ(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) * 2 + 12)))
+ #define PP32_BRK_DATA_VALUE_WR_GT_EQ(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) * 2 + 13)))
+// #define PP32_BRK_CUR_CONTEXT(n) ((*PP32_BREAKPOINT_REASONS(n) >> 16) & 0x03)
+#define PP32_DBG_TASK_NO(n) PP32_DEBUG_REG_ADDR(n, 0x0F81)
+ #define PP32_BRK_CUR_CONTEXT(n) (*PP32_DBG_TASK_NO(n) & 0x03)
+
+#define PP32_GP_REG_BASE(n) PP32_DEBUG_REG_ADDR(n, 0x0E00)
+#define PP32_GP_CONTEXTi_REGn(n, i, j) PP32_DEBUG_REG_ADDR(n, 0x0E00 + (i) * 16 + (j))
+
+/*
+ * Share Buffer
+ */
+#define SB_MST_PRI0 PPE_REG_ADDR(0x0300)
+#define SB_MST_PRI1 PPE_REG_ADDR(0x0301)
+
+/*
+ * EMA Registers
+ */
+#define EMA_CMDCFG PPE_REG_ADDR(0x0A00)
+#define EMA_DATACFG PPE_REG_ADDR(0x0A01)
+#define EMA_CMDCNT PPE_REG_ADDR(0x0A02)
+#define EMA_DATACNT PPE_REG_ADDR(0x0A03)
+#define EMA_ISR PPE_REG_ADDR(0x0A04)
+#define EMA_IER PPE_REG_ADDR(0x0A05)
+#define EMA_CFG PPE_REG_ADDR(0x0A06)
+#define EMA_SUBID PPE_REG_ADDR(0x0A07)
+
+#define EMA_ALIGNMENT 4
+
+/*
+ * Mailbox IGU1 Interrupt
+ */
+#define PPE_MAILBOX_IGU1_INT INT_NUM_IM2_IRL13
+
+
+
+#endif // IFXMIPS_PTM_PPE_AMAZON_SE_H
diff --git a/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_ppe_ar9.h.svn-base b/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_ppe_ar9.h.svn-base
new file mode 100644
index 0000000..9355747
--- /dev/null
+++ b/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_ppe_ar9.h.svn-base
@@ -0,0 +1,213 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_ptm_ppe_ar9.h
+** PROJECT : UEIP
+** MODULES : PTM
+**
+** DATE : 7 Jul 2009
+** AUTHOR : Xu Liang
+** DESCRIPTION : PTM driver header file (PPE register for AR9)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 07 JUL 2009 Xu Liang Init Version
+*******************************************************************************/
+
+
+
+#ifndef IFXMIPS_PTM_PPE_AR9_H
+#define IFXMIPS_PTM_PPE_AR9_H
+
+
+
+/*
+ * FPI Configuration Bus Register and Memory Address Mapping
+ */
+#define IFX_PPE (KSEG1 | 0x1E180000)
+#define PP32_DEBUG_REG_ADDR(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x0000) << 2)))
+#define PPM_INT_REG_ADDR(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x0030) << 2)))
+#define PP32_INTERNAL_RES_ADDR(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x0040) << 2)))
+#define CDM_CODE_MEMORY(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x1000) << 2)))
+#define PPE_REG_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x4000) << 2)))
+#define CDM_DATA_MEMORY(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x5000) << 2)))
+#define PPM_INT_UNIT_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6000) << 2)))
+#define PPM_TIMER0_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6100) << 2)))
+#define PPM_TASK_IND_REG_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6200) << 2)))
+#define PPS_BRK_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6300) << 2)))
+#define PPM_TIMER1_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6400) << 2)))
+#define SB_RAM0_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x8000) << 2)))
+#define SB_RAM1_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x8800) << 2)))
+#define SB_RAM2_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x9000) << 2)))
+#define SB_RAM3_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x9800) << 2)))
+#define SB_RAM4_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0xA000) << 2)))
+#define QSB_CONF_REG_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0xC000) << 2)))
+
+/*
+ * DWORD-Length of Memory Blocks
+ */
+#define PP32_DEBUG_REG_DWLEN 0x0030
+#define PPM_INT_REG_DWLEN 0x0010
+#define PP32_INTERNAL_RES_DWLEN 0x00C0
+#define CDM_CODE_MEMORYn_DWLEN(n) 0x1000
+#define PPE_REG_DWLEN 0x1000
+#define CDM_DATA_MEMORY_DWLEN CDM_CODE_MEMORYn_DWLEN(1)
+#define PPM_INT_UNIT_DWLEN 0x0100
+#define PPM_TIMER0_DWLEN 0x0100
+#define PPM_TASK_IND_REG_DWLEN 0x0100
+#define PPS_BRK_DWLEN 0x0100
+#define PPM_TIMER1_DWLEN 0x0100
+#define SB_RAM0_DWLEN 0x0800
+#define SB_RAM1_DWLEN 0x0800
+#define SB_RAM2_DWLEN 0x0800
+#define SB_RAM3_DWLEN 0x0800
+#define SB_RAM4_DWLEN 0x0C00
+#define QSB_CONF_REG_DWLEN 0x0100
+
+/*
+ * PP32 to FPI Address Mapping
+ */
+#define SB_BUFFER(__sb_addr) ((volatile unsigned int *)((((__sb_addr) >= 0x0000) && ((__sb_addr) <= 0x0FFF)) ? PP32_DEBUG_REG_ADDR(0, (__sb_addr)): \
+ (((__sb_addr) >= 0x2000) && ((__sb_addr) <= 0x27FF)) ? SB_RAM0_ADDR((__sb_addr) - 0x2000) : \
+ (((__sb_addr) >= 0x2800) && ((__sb_addr) <= 0x2FFF)) ? SB_RAM1_ADDR((__sb_addr) - 0x2800) : \
+ (((__sb_addr) >= 0x3000) && ((__sb_addr) <= 0x37FF)) ? SB_RAM2_ADDR((__sb_addr) - 0x3000) : \
+ (((__sb_addr) >= 0x3800) && ((__sb_addr) <= 0x3FFF)) ? SB_RAM3_ADDR((__sb_addr) - 0x3800) : \
+ (((__sb_addr) >= 0x4000) && ((__sb_addr) <= 0x4BFF)) ? SB_RAM4_ADDR((__sb_addr) - 0x4000) : \
+ 0))
+
+/*
+ * PP32 Debug Control Register
+ */
+#define NUM_OF_PP32 1
+
+#define PP32_DBG_CTRL(n) PP32_DEBUG_REG_ADDR(n, 0x0000)
+
+#define DBG_CTRL_RESTART 0
+#define DBG_CTRL_STOP 1
+
+#define PP32_CTRL_CMD(n) PP32_DEBUG_REG_ADDR(n, 0x0B00)
+ #define PP32_CTRL_CMD_RESTART (1 << 0)
+ #define PP32_CTRL_CMD_STOP (1 << 1)
+ #define PP32_CTRL_CMD_STEP (1 << 2)
+ #define PP32_CTRL_CMD_BREAKOUT (1 << 3)
+
+#define PP32_CTRL_OPT(n) PP32_DEBUG_REG_ADDR(n, 0x0C00)
+ #define PP32_CTRL_OPT_BREAKOUT_ON_STOP_ON (3 << 0)
+ #define PP32_CTRL_OPT_BREAKOUT_ON_STOP_OFF (2 << 0)
+ #define PP32_CTRL_OPT_BREAKOUT_ON_BREAKIN_ON (3 << 2)
+ #define PP32_CTRL_OPT_BREAKOUT_ON_BREAKIN_OFF (2 << 2)
+ #define PP32_CTRL_OPT_STOP_ON_BREAKIN_ON (3 << 4)
+ #define PP32_CTRL_OPT_STOP_ON_BREAKIN_OFF (2 << 4)
+ #define PP32_CTRL_OPT_STOP_ON_BREAKPOINT_ON (3 << 6)
+ #define PP32_CTRL_OPT_STOP_ON_BREAKPOINT_OFF (2 << 6)
+ #define PP32_CTRL_OPT_BREAKOUT_ON_STOP(n) (*PP32_CTRL_OPT(n) & (1 << 0))
+ #define PP32_CTRL_OPT_BREAKOUT_ON_BREAKIN(n) (*PP32_CTRL_OPT(n) & (1 << 2))
+ #define PP32_CTRL_OPT_STOP_ON_BREAKIN(n) (*PP32_CTRL_OPT(n) & (1 << 4))
+ #define PP32_CTRL_OPT_STOP_ON_BREAKPOINT(n) (*PP32_CTRL_OPT(n) & (1 << 6))
+
+#define PP32_BRK_PC(n, i) PP32_DEBUG_REG_ADDR(n, 0x0900 + (i) * 2)
+#define PP32_BRK_PC_MASK(n, i) PP32_DEBUG_REG_ADDR(n, 0x0901 + (i) * 2)
+#define PP32_BRK_DATA_ADDR(n, i) PP32_DEBUG_REG_ADDR(n, 0x0904 + (i) * 2)
+#define PP32_BRK_DATA_ADDR_MASK(n, i) PP32_DEBUG_REG_ADDR(n, 0x0905 + (i) * 2)
+#define PP32_BRK_DATA_VALUE_RD(n, i) PP32_DEBUG_REG_ADDR(n, 0x0908 + (i) * 2)
+#define PP32_BRK_DATA_VALUE_RD_MASK(n, i) PP32_DEBUG_REG_ADDR(n, 0x0909 + (i) * 2)
+#define PP32_BRK_DATA_VALUE_WR(n, i) PP32_DEBUG_REG_ADDR(n, 0x090C + (i) * 2)
+#define PP32_BRK_DATA_VALUE_WR_MASK(n, i) PP32_DEBUG_REG_ADDR(n, 0x090D + (i) * 2)
+ #define PP32_BRK_CONTEXT_MASK(i) (1 << (i))
+ #define PP32_BRK_CONTEXT_MASK_EN (1 << 4)
+ #define PP32_BRK_COMPARE_GREATER_EQUAL (1 << 5) // valid for break data value rd/wr only
+ #define PP32_BRK_COMPARE_LOWER_EQUAL (1 << 6)
+ #define PP32_BRK_COMPARE_EN (1 << 7)
+
+#define PP32_BRK_TRIG(n) PP32_DEBUG_REG_ADDR(n, 0x0F00)
+ #define PP32_BRK_GRPi_PCn_ON(i, n) ((3 << ((n) * 2)) << ((i) * 16))
+ #define PP32_BRK_GRPi_PCn_OFF(i, n) ((2 << ((n) * 2)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_ADDRn_ON(i, n) ((3 << ((n) * 2 + 4)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_ADDRn_OFF(i, n) ((2 << ((n) * 2 + 4)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_VALUE_RDn_ON(i, n) ((3 << ((n) * 2 + 8)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_VALUE_RDn_OFF(i, n)((2 << ((n) * 2 + 8)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_VALUE_WRn_ON(i, n) ((3 << ((n) * 2 + 12)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_VALUE_WRn_OFF(i, n)((2 << ((n) * 2 + 12)) << ((i) * 16))
+ #define PP32_BRK_GRPi_PCn(k, i, n) (*PP32_BRK_TRIG(k) & ((1 << ((n))) << ((i) * 8)))
+ #define PP32_BRK_GRPi_DATA_ADDRn(k, i, n) (*PP32_BRK_TRIG(k) & ((1 << ((n) + 2)) << ((i) * 8)))
+ #define PP32_BRK_GRPi_DATA_VALUE_RDn(k, i, n) (*PP32_BRK_TRIG(k) & ((1 << ((n) + 4)) << ((i) * 8)))
+ #define PP32_BRK_GRPi_DATA_VALUE_WRn(k, i, n) (*PP32_BRK_TRIG(k) & ((1 << ((n) + 6)) << ((i) * 8)))
+
+#define PP32_CPU_STATUS(n) PP32_DEBUG_REG_ADDR(n, 0x0D00)
+#define PP32_HALT_STAT(n) PP32_CPU_STATUS(n)
+#define PP32_DBG_CUR_PC(n) PP32_CPU_STATUS(n)
+ #define PP32_CPU_USER_STOPPED(n) (*PP32_CPU_STATUS(n) & (1 << 0))
+ #define PP32_CPU_USER_BREAKIN_RCV(n) (*PP32_CPU_STATUS(n) & (1 << 1))
+ #define PP32_CPU_USER_BREAKPOINT_MET(n) (*PP32_CPU_STATUS(n) & (1 << 2))
+ #define PP32_CPU_CUR_PC(n) (*PP32_CPU_STATUS(n) >> 16)
+
+#define PP32_BREAKPOINT_REASONS(n) PP32_DEBUG_REG_ADDR(n, 0x0A00)
+ #define PP32_BRK_PC_MET(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << (i)))
+ #define PP32_BRK_DATA_ADDR_MET(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) + 2)))
+ #define PP32_BRK_DATA_VALUE_RD_MET(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) + 4)))
+ #define PP32_BRK_DATA_VALUE_WR_MET(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) + 6)))
+ #define PP32_BRK_DATA_VALUE_RD_LO_EQ(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) * 2 + 8)))
+ #define PP32_BRK_DATA_VALUE_RD_GT_EQ(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) * 2 + 9)))
+ #define PP32_BRK_DATA_VALUE_WR_LO_EQ(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) * 2 + 12)))
+ #define PP32_BRK_DATA_VALUE_WR_GT_EQ(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) * 2 + 13)))
+ #define PP32_BRK_CUR_CONTEXT(n) ((*PP32_BREAKPOINT_REASONS(n) >> 16) & 0x03)
+
+#define PP32_GP_REG_BASE(n) PP32_DEBUG_REG_ADDR(n, 0x0E00)
+#define PP32_GP_CONTEXTi_REGn(n, i, j) PP32_DEBUG_REG_ADDR(n, 0x0E00 + (i) * 16 + (j))
+
+/*
+ * Share Buffer Registers
+ */
+#define SB_MST_PRI0 PPE_REG_ADDR(0x0300)
+#define SB_MST_PRI1 PPE_REG_ADDR(0x0301)
+
+/*
+ * EMA Registers
+ */
+#define EMA_CMDCFG PPE_REG_ADDR(0x0A00)
+#define EMA_DATACFG PPE_REG_ADDR(0x0A01)
+#define EMA_CMDCNT PPE_REG_ADDR(0x0A02)
+#define EMA_DATACNT PPE_REG_ADDR(0x0A03)
+#define EMA_ISR PPE_REG_ADDR(0x0A04)
+#define EMA_IER PPE_REG_ADDR(0x0A05)
+#define EMA_CFG PPE_REG_ADDR(0x0A06)
+#define EMA_SUBID PPE_REG_ADDR(0x0A07)
+
+#define EMA_ALIGNMENT 4
+
+/*
+ * DPlus Registers
+ */
+#define DM_RXDB PPE_REG_ADDR(0x0612)
+#define DM_RXCB PPE_REG_ADDR(0x0613)
+#define DM_RXCFG PPE_REG_ADDR(0x0614)
+#define DM_RXPGCNT PPE_REG_ADDR(0x0615)
+#define DM_RXPKTCNT PPE_REG_ADDR(0x0616)
+#define DS_RXDB PPE_REG_ADDR(0x0710)
+#define DS_RXCB PPE_REG_ADDR(0x0711)
+#define DS_RXCFG PPE_REG_ADDR(0x0712)
+#define DS_RXPGCNT PPE_REG_ADDR(0x0713)
+
+/*
+ * 3-Port Switch Registers (partial)
+ */
+#define IFX_SW (KSEG1 | 0x1E108000)
+#define SW_REG(off) ((volatile unsigned int*)(IFX_SW + (off)))
+#define SW_P2_CTL SW_REG(0x00C)
+
+
+/*
+ * Mailbox IGU1 Interrupt
+ */
+#define PPE_MAILBOX_IGU1_INT INT_NUM_IM2_IRL24
+
+
+
+#endif // IFXMIPS_PTM_PPE_AR9_H
diff --git a/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_ppe_common.h.svn-base b/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_ppe_common.h.svn-base
new file mode 100644
index 0000000..63a5a37
--- /dev/null
+++ b/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_ppe_common.h.svn-base
@@ -0,0 +1,311 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_ptm_ppe_common.h
+** PROJECT : UEIP
+** MODULES : PTM
+**
+** DATE : 7 Jul 2009
+** AUTHOR : Xu Liang
+** DESCRIPTION : PTM driver header file (PPE register for all platform)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 07 JUL 2009 Xu Liang Init Version
+*******************************************************************************/
+
+
+
+#ifndef IFXMIPS_PTM_PPE_COMMON_H
+#define IFXMIPS_PTM_PPE_COMMON_H
+
+
+
+#if defined(CONFIG_DANUBE)
+ #include "ifxmips_ptm_ppe_danube.h"
+#elif defined(CONFIG_AMAZON_SE)
+ #include "ifxmips_ptm_ppe_amazon_se.h"
+#elif defined(CONFIG_AR9)
+ #include "ifxmips_ptm_ppe_ar9.h"
+#elif defined(CONFIG_VR9)
+ #include "ifxmips_ptm_ppe_vr9.h"
+#else
+ #error Platform is not specified!
+#endif
+
+
+
+/*
+ * Code/Data Memory (CDM) Interface Configuration Register
+ */
+#define CDM_CFG PPE_REG_ADDR(0x0100)
+
+#define CDM_CFG_RAM1 GET_BITS(*CDM_CFG, 3, 2)
+#define CDM_CFG_RAM0 (*CDM_CFG & (1 << 1))
+
+#define CDM_CFG_RAM1_SET(value) SET_BITS(0, 3, 2, value)
+#define CDM_CFG_RAM0_SET(value) ((value) ? (1 << 1) : 0)
+
+/*
+ * QSB Internal Cell Delay Variation Register
+ */
+#define QSB_ICDV QSB_CONF_REG_ADDR(0x0007)
+
+#define QSB_ICDV_TAU GET_BITS(*QSB_ICDV, 5, 0)
+
+#define QSB_ICDV_TAU_SET(value) SET_BITS(0, 5, 0, value)
+
+/*
+ * QSB Scheduler Burst Limit Register
+ */
+#define QSB_SBL QSB_CONF_REG_ADDR(0x0009)
+
+#define QSB_SBL_SBL GET_BITS(*QSB_SBL, 3, 0)
+
+#define QSB_SBL_SBL_SET(value) SET_BITS(0, 3, 0, value)
+
+/*
+ * QSB Configuration Register
+ */
+#define QSB_CFG QSB_CONF_REG_ADDR(0x000A)
+
+#define QSB_CFG_TSTEPC GET_BITS(*QSB_CFG, 1, 0)
+
+#define QSB_CFG_TSTEPC_SET(value) SET_BITS(0, 1, 0, value)
+
+/*
+ * QSB RAM Transfer Table Register
+ */
+#define QSB_RTM QSB_CONF_REG_ADDR(0x000B)
+
+#define QSB_RTM_DM (*QSB_RTM)
+
+#define QSB_RTM_DM_SET(value) ((value) & 0xFFFFFFFF)
+
+/*
+ * QSB RAM Transfer Data Register
+ */
+#define QSB_RTD QSB_CONF_REG_ADDR(0x000C)
+
+#define QSB_RTD_TTV (*QSB_RTD)
+
+#define QSB_RTD_TTV_SET(value) ((value) & 0xFFFFFFFF)
+
+/*
+ * QSB RAM Access Register
+ */
+#define QSB_RAMAC QSB_CONF_REG_ADDR(0x000D)
+
+#define QSB_RAMAC_RW (*QSB_RAMAC & (1 << 31))
+#define QSB_RAMAC_TSEL GET_BITS(*QSB_RAMAC, 27, 24)
+#define QSB_RAMAC_LH (*QSB_RAMAC & (1 << 16))
+#define QSB_RAMAC_TESEL GET_BITS(*QSB_RAMAC, 9, 0)
+
+#define QSB_RAMAC_RW_SET(value) ((value) ? (1 << 31) : 0)
+#define QSB_RAMAC_TSEL_SET(value) SET_BITS(0, 27, 24, value)
+#define QSB_RAMAC_LH_SET(value) ((value) ? (1 << 16) : 0)
+#define QSB_RAMAC_TESEL_SET(value) SET_BITS(0, 9, 0, value)
+
+/*
+ * QSB Queue Scheduling and Shaping Definitions
+ */
+#define QSB_WFQ_NONUBR_MAX 0x3f00
+#define QSB_WFQ_UBR_BYPASS 0x3fff
+#define QSB_TP_TS_MAX 65472
+#define QSB_TAUS_MAX 64512
+#define QSB_GCR_MIN 18
+
+/*
+ * QSB Constant
+ */
+#define QSB_RAMAC_RW_READ 0
+#define QSB_RAMAC_RW_WRITE 1
+
+#define QSB_RAMAC_TSEL_QPT 0x01
+#define QSB_RAMAC_TSEL_SCT 0x02
+#define QSB_RAMAC_TSEL_SPT 0x03
+#define QSB_RAMAC_TSEL_VBR 0x08
+
+#define QSB_RAMAC_LH_LOW 0
+#define QSB_RAMAC_LH_HIGH 1
+
+#define QSB_QPT_SET_MASK 0x0
+#define QSB_QVPT_SET_MASK 0x0
+#define QSB_SET_SCT_MASK 0x0
+#define QSB_SET_SPT_MASK 0x0
+#define QSB_SET_SPT_SBVALID_MASK 0x7FFFFFFF
+
+#define QSB_SPT_SBV_VALID (1 << 31)
+#define QSB_SPT_PN_SET(value) (((value) & 0x01) ? (1 << 16) : 0)
+#define QSB_SPT_INTRATE_SET(value) SET_BITS(0, 13, 0, value)
+
+/*
+ * QSB Queue Parameter Table Entry and Queue VBR Parameter Table Entry
+ */
+#if defined(__BIG_ENDIAN)
+ union qsb_queue_parameter_table {
+ struct {
+ unsigned int res1 :1;
+ unsigned int vbr :1;
+ unsigned int wfqf :14;
+ unsigned int tp :16;
+ } bit;
+ u32 dword;
+ };
+
+ union qsb_queue_vbr_parameter_table {
+ struct {
+ unsigned int taus :16;
+ unsigned int ts :16;
+ } bit;
+ u32 dword;
+ };
+#else
+ union qsb_queue_parameter_table {
+ struct {
+ unsigned int tp :16;
+ unsigned int wfqf :14;
+ unsigned int vbr :1;
+ unsigned int res1 :1;
+ } bit;
+ u32 dword;
+ };
+
+ union qsb_queue_vbr_parameter_table {
+ struct {
+ unsigned int ts :16;
+ unsigned int taus :16;
+ } bit;
+ u32 dword;
+ };
+#endif // defined(__BIG_ENDIAN)
+
+/*
+ * Mailbox IGU0 Registers
+ */
+#define MBOX_IGU0_ISRS PPE_REG_ADDR(0x0200)
+#define MBOX_IGU0_ISRC PPE_REG_ADDR(0x0201)
+#define MBOX_IGU0_ISR PPE_REG_ADDR(0x0202)
+#define MBOX_IGU0_IER PPE_REG_ADDR(0x0203)
+
+#define MBOX_IGU0_ISRS_SET(n) (1 << (n))
+#define MBOX_IGU0_ISRC_CLEAR(n) (1 << (n))
+#define MBOX_IGU0_ISR_ISR(n) (*MBOX_IGU0_ISR & (1 << (n)))
+#define MBOX_IGU0_IER_EN(n) (*MBOX_IGU0_IER & (1 << (n)))
+#define MBOX_IGU0_IER_EN_SET(n) (1 << (n))
+
+/*
+ * Mailbox IGU1 Registers
+ */
+#define MBOX_IGU1_ISRS PPE_REG_ADDR(0x0204)
+#define MBOX_IGU1_ISRC PPE_REG_ADDR(0x0205)
+#define MBOX_IGU1_ISR PPE_REG_ADDR(0x0206)
+#define MBOX_IGU1_IER PPE_REG_ADDR(0x0207)
+
+#define MBOX_IGU1_ISRS_SET(n) (1 << (n))
+#define MBOX_IGU1_ISRC_CLEAR(n) (1 << (n))
+#define MBOX_IGU1_ISR_ISR(n) (*MBOX_IGU1_ISR & (1 << (n)))
+#define MBOX_IGU1_IER_EN(n) (*MBOX_IGU1_IER & (1 << (n)))
+#define MBOX_IGU1_IER_EN_SET(n) (1 << (n))
+
+/*
+ * Mailbox IGU3 Registers
+ */
+#define MBOX_IGU3_ISRS PPE_REG_ADDR(0x0214)
+#define MBOX_IGU3_ISRC PPE_REG_ADDR(0x0215)
+#define MBOX_IGU3_ISR PPE_REG_ADDR(0x0216)
+#define MBOX_IGU3_IER PPE_REG_ADDR(0x0217)
+
+#define MBOX_IGU3_ISRS_SET(n) (1 << (n))
+#define MBOX_IGU3_ISRC_CLEAR(n) (1 << (n))
+#define MBOX_IGU3_ISR_ISR(n) (*MBOX_IGU3_ISR & (1 << (n)))
+#define MBOX_IGU3_IER_EN(n) (*MBOX_IGU3_IER & (1 << (n)))
+#define MBOX_IGU3_IER_EN_SET(n) (1 << (n))
+
+/*
+ * RTHA/TTHA Registers
+ */
+#define RFBI_CFG PPE_REG_ADDR(0x0400)
+#define RBA_CFG0 PPE_REG_ADDR(0x0404)
+#define RBA_CFG1 PPE_REG_ADDR(0x0405)
+#define RCA_CFG0 PPE_REG_ADDR(0x0408)
+#define RCA_CFG1 PPE_REG_ADDR(0x0409)
+#define RDES_CFG0 PPE_REG_ADDR(0x040C)
+#define RDES_CFG1 PPE_REG_ADDR(0x040D)
+#define SFSM_STATE0 PPE_REG_ADDR(0x0410)
+#define SFSM_STATE1 PPE_REG_ADDR(0x0411)
+#define SFSM_DBA0 PPE_REG_ADDR(0x0412)
+#define SFSM_DBA1 PPE_REG_ADDR(0x0413)
+#define SFSM_CBA0 PPE_REG_ADDR(0x0414)
+#define SFSM_CBA1 PPE_REG_ADDR(0x0415)
+#define SFSM_CFG0 PPE_REG_ADDR(0x0416)
+#define SFSM_CFG1 PPE_REG_ADDR(0x0417)
+#define SFSM_PGCNT0 PPE_REG_ADDR(0x041C)
+#define SFSM_PGCNT1 PPE_REG_ADDR(0x041D)
+#define FFSM_DBA0 PPE_REG_ADDR(0x0508)
+#define FFSM_DBA1 PPE_REG_ADDR(0x0509)
+#define FFSM_CFG0 PPE_REG_ADDR(0x050A)
+#define FFSM_CFG1 PPE_REG_ADDR(0x050B)
+#define FFSM_IDLE_HEAD_BC0 PPE_REG_ADDR(0x050E)
+#define FFSM_IDLE_HEAD_BC1 PPE_REG_ADDR(0x050F)
+#define FFSM_PGCNT0 PPE_REG_ADDR(0x0514)
+#define FFSM_PGCNT1 PPE_REG_ADDR(0x0515)
+
+/*
+ * PPE TC Logic Registers (partial)
+ */
+#define DREG_A_VERSION PPE_REG_ADDR(0x0D00)
+#define DREG_A_CFG PPE_REG_ADDR(0x0D01)
+#define DREG_AT_CTRL PPE_REG_ADDR(0x0D02)
+#define DREG_AT_CB_CFG0 PPE_REG_ADDR(0x0D03)
+#define DREG_AT_CB_CFG1 PPE_REG_ADDR(0x0D04)
+#define DREG_AR_CTRL PPE_REG_ADDR(0x0D08)
+#define DREG_AR_CB_CFG0 PPE_REG_ADDR(0x0D09)
+#define DREG_AR_CB_CFG1 PPE_REG_ADDR(0x0D0A)
+#define DREG_A_UTPCFG PPE_REG_ADDR(0x0D0E)
+#define DREG_A_STATUS PPE_REG_ADDR(0x0D0F)
+#define DREG_AT_CFG0 PPE_REG_ADDR(0x0D20)
+#define DREG_AT_CFG1 PPE_REG_ADDR(0x0D21)
+#define DREG_AT_FB_SIZE0 PPE_REG_ADDR(0x0D22)
+#define DREG_AT_FB_SIZE1 PPE_REG_ADDR(0x0D23)
+#define DREG_AT_CELL0 PPE_REG_ADDR(0x0D24)
+#define DREG_AT_CELL1 PPE_REG_ADDR(0x0D25)
+#define DREG_AT_IDLE_CNT0 PPE_REG_ADDR(0x0D26)
+#define DREG_AT_IDLE_CNT1 PPE_REG_ADDR(0x0D27)
+#define DREG_AT_IDLE0 PPE_REG_ADDR(0x0D28)
+#define DREG_AT_IDLE1 PPE_REG_ADDR(0x0D29)
+#define DREG_AR_CFG0 PPE_REG_ADDR(0x0D60)
+#define DREG_AR_CFG1 PPE_REG_ADDR(0x0D61)
+#define DREG_AR_CELL0 PPE_REG_ADDR(0x0D68)
+#define DREG_AR_CELL1 PPE_REG_ADDR(0x0D69)
+#define DREG_AR_IDLE_CNT0 PPE_REG_ADDR(0x0D6A)
+#define DREG_AR_IDLE_CNT1 PPE_REG_ADDR(0x0D6B)
+#define DREG_AR_AIIDLE_CNT0 PPE_REG_ADDR(0x0D6C)
+#define DREG_AR_AIIDLE_CNT1 PPE_REG_ADDR(0x0D6D)
+#define DREG_AR_BE_CNT0 PPE_REG_ADDR(0x0D6E)
+#define DREG_AR_BE_CNT1 PPE_REG_ADDR(0x0D6F)
+#define DREG_AR_HEC_CNT0 PPE_REG_ADDR(0x0D70)
+#define DREG_AR_HEC_CNT1 PPE_REG_ADDR(0x0D71)
+#define DREG_AR_IDLE0 PPE_REG_ADDR(0x0D74)
+#define DREG_AR_IDLE1 PPE_REG_ADDR(0x0D75)
+#define DREG_AR_CERRN_CNT0 PPE_REG_ADDR(0x0DA0)
+#define DREG_AR_CERRN_CNT1 PPE_REG_ADDR(0x0DA1)
+#define DREG_AR_CERRNP_CNT0 PPE_REG_ADDR(0x0DA2)
+#define DREG_AR_CERRNP_CNT1 PPE_REG_ADDR(0x0DA3)
+#define DREG_AR_CVN_CNT0 PPE_REG_ADDR(0x0DA4)
+#define DREG_AR_CVN_CNT1 PPE_REG_ADDR(0x0DA5)
+#define DREG_AR_CVNP_CNT0 PPE_REG_ADDR(0x0DA6)
+#define DREG_AR_CVNP_CNT1 PPE_REG_ADDR(0x0DA7)
+#define DREG_B0_LADR PPE_REG_ADDR(0x0DA8)
+#define DREG_B1_LADR PPE_REG_ADDR(0x0DA9)
+
+
+
+#endif // IFXMIPS_PTM_PPE_COMMON_H
diff --git a/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_ppe_danube.h.svn-base b/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_ppe_danube.h.svn-base
new file mode 100644
index 0000000..5f896e6
--- /dev/null
+++ b/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_ppe_danube.h.svn-base
@@ -0,0 +1,135 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_ptm_ppe_danube.h
+** PROJECT : UEIP
+** MODULES : PTM
+**
+** DATE : 7 Jul 2009
+** AUTHOR : Xu Liang
+** DESCRIPTION : PTM driver header file (PPE register for Danube)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 07 JUL 2009 Xu Liang Init Version
+*******************************************************************************/
+
+
+
+#ifndef IFXMIPS_PTM_PPE_DANUBE_H
+#define IFXMIPS_PTM_PPE_DANUBE_H
+
+
+
+/*
+ * FPI Configuration Bus Register and Memory Address Mapping
+ */
+#define IFX_PPE (KSEG1 | 0x1E180000)
+#define PP32_DEBUG_REG_ADDR(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x0000) << 2)))
+#define PPM_INT_REG_ADDR(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x0030) << 2)))
+#define PP32_INTERNAL_RES_ADDR(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x0040) << 2)))
+#define CDM_CODE_MEMORY(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x1000) << 2)))
+#define PPE_REG_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x4000) << 2)))
+#define CDM_DATA_MEMORY(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x5000) << 2)))
+#define PPM_INT_UNIT_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6000) << 2)))
+#define PPM_TIMER0_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6100) << 2)))
+#define PPM_TASK_IND_REG_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6200) << 2)))
+#define PPS_BRK_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6300) << 2)))
+#define PPM_TIMER1_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6400) << 2)))
+#define SB_RAM0_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x8000) << 2)))
+#define SB_RAM1_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x8400) << 2)))
+#define SB_RAM2_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x8C00) << 2)))
+#define SB_RAM3_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x9600) << 2)))
+#define QSB_CONF_REG_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0xC000) << 2)))
+
+/*
+ * DWORD-Length of Memory Blocks
+ */
+#define PP32_DEBUG_REG_DWLEN 0x0030
+#define PPM_INT_REG_DWLEN 0x0010
+#define PP32_INTERNAL_RES_DWLEN 0x00C0
+#define CDM_CODE_MEMORYn_DWLEN(n) ((n) == 0 ? 0x1000 : 0x0800)
+#define PPE_REG_DWLEN 0x1000
+#define CDM_DATA_MEMORY_DWLEN CDM_CODE_MEMORYn_DWLEN(1)
+#define PPM_INT_UNIT_DWLEN 0x0100
+#define PPM_TIMER0_DWLEN 0x0100
+#define PPM_TASK_IND_REG_DWLEN 0x0100
+#define PPS_BRK_DWLEN 0x0100
+#define PPM_TIMER1_DWLEN 0x0100
+#define SB_RAM0_DWLEN 0x0400
+#define SB_RAM1_DWLEN 0x0800
+#define SB_RAM2_DWLEN 0x0A00
+#define SB_RAM3_DWLEN 0x0400
+#define QSB_CONF_REG_DWLEN 0x0100
+
+/*
+ * PP32 to FPI Address Mapping
+ */
+#define SB_BUFFER(__sb_addr) ((volatile unsigned int *)((((__sb_addr) >= 0x2000) && ((__sb_addr) <= 0x23FF)) ? SB_RAM0_ADDR((__sb_addr) - 0x2000) : \
+ (((__sb_addr) >= 0x2400) && ((__sb_addr) <= 0x2BFF)) ? SB_RAM1_ADDR((__sb_addr) - 0x2400) : \
+ (((__sb_addr) >= 0x2C00) && ((__sb_addr) <= 0x35FF)) ? SB_RAM2_ADDR((__sb_addr) - 0x2C00) : \
+ (((__sb_addr) >= 0x3600) && ((__sb_addr) <= 0x39FF)) ? SB_RAM3_ADDR((__sb_addr) - 0x3600) : \
+ 0))
+
+/*
+ * PP32 Debug Control Register
+ */
+#define PP32_DBG_CTRL PP32_DEBUG_REG_ADDR(0, 0x0000)
+
+#define DBG_CTRL_START_SET(value) ((value) ? (1 << 0) : 0)
+#define DBG_CTRL_STOP_SET(value) ((value) ? (1 << 1) : 0)
+#define DBG_CTRL_STEP_SET(value) ((value) ? (1 << 2) : 0)
+
+#define PP32_HALT_STAT PP32_DEBUG_REG_ADDR(0, 0x0001)
+
+#define PP32_BRK_SRC PP32_DEBUG_REG_ADDR(0, 0x0002)
+ #define PP32_BRK_SRC_PC(i) (1 << (i))
+ #define PP32_BRK_SRC_DATA(i, cmd) ((cmd) << ((i) * 3 + 8))
+
+#define PP32_DBG_PC_MIN(i) PP32_DEBUG_REG_ADDR(0, 0x0010 + (i))
+#define PP32_DBG_PC_MAX(i) PP32_DEBUG_REG_ADDR(0, 0x0014 + (i))
+#define PP32_DBG_DATA_MIN(i) PP32_DEBUG_REG_ADDR(0, 0x0018 + (i))
+#define PP32_DBG_DATA_MAX(i) PP32_DEBUG_REG_ADDR(0, 0x001A + (i))
+#define PP32_DBG_DATA_VAL(i) PP32_DEBUG_REG_ADDR(0, 0x001C + (i))
+
+#define PP32_DBG_TASK_GPR(task, i) PP32_DEBUG_REG_ADDR(0, 0x0040 + (task) * 0x0010 + (i))
+
+#define PP32_DBG_CUR_PC PP32_DEBUG_REG_ADDR(0, 0x0080)
+#define PP32_DBG_TASK_NO PP32_DEBUG_REG_ADDR(0, 0x0081)
+#define PP32_DBG_TASK_PRIO PP32_DEBUG_REG_ADDR(0, 0x0086)
+#define PP32_DBG_PC_OF_TASK(i) PP32_DEBUG_REG_ADDR(0, 0x0087 + (i))
+
+/*
+ * Share Buffer Registers
+ */
+#define SB_MST_SEL PPE_REG_ADDR(0x0304)
+
+/*
+ * EMA Registers
+ */
+#define EMA_CMDCFG PPE_REG_ADDR(0x0A00)
+#define EMA_DATACFG PPE_REG_ADDR(0x0A01)
+#define EMA_CMDCNT PPE_REG_ADDR(0x0A02)
+#define EMA_DATACNT PPE_REG_ADDR(0x0A03)
+#define EMA_ISR PPE_REG_ADDR(0x0A04)
+#define EMA_IER PPE_REG_ADDR(0x0A05)
+#define EMA_CFG PPE_REG_ADDR(0x0A06)
+#define EMA_SUBID PPE_REG_ADDR(0x0A07)
+
+#define EMA_ALIGNMENT 4
+
+/*
+ * Mailbox IGU1 Interrupt
+ */
+#define PPE_MAILBOX_IGU1_INT INT_NUM_IM2_IRL24
+
+
+
+#endif // IFXMIPS_PTM_PPE_DANUBE_H
diff --git a/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_ppe_vr9.h.svn-base b/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_ppe_vr9.h.svn-base
new file mode 100644
index 0000000..4a8c2f7
--- /dev/null
+++ b/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_ppe_vr9.h.svn-base
@@ -0,0 +1,205 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_ptm_ppe_vr9.h
+** PROJECT : UEIP
+** MODULES : PTM
+**
+** DATE : 7 Jul 2009
+** AUTHOR : Xu Liang
+** DESCRIPTION : PTM driver header file (PPE register for VR9)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 07 JUL 2009 Xu Liang Init Version
+*******************************************************************************/
+
+
+
+#ifndef IFXMIPS_PTM_PPE_VR9_H
+#define IFXMIPS_PTM_PPE_VR9_H
+
+
+
+/*
+ * FPI Configuration Bus Register and Memory Address Mapping
+ */
+#define IFX_PPE (KSEG1 | 0x1E200000)
+#define PP32_DEBUG_REG_ADDR(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x000000 + (i) * 0x00010000) << 2)))
+#define CDM_CODE_MEMORY(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x001000 + (i) * 0x00010000) << 2)))
+#define CDM_DATA_MEMORY(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x004000 + (i) * 0x00010000) << 2)))
+#define SB_RAM0_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x008000) << 2)))
+#define SB_RAM1_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x009000) << 2)))
+#define SB_RAM2_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x00A000) << 2)))
+#define SB_RAM3_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x00B000) << 2)))
+#define PPE_REG_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x00D000) << 2)))
+#define QSB_CONF_REG_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x00E000) << 2)))
+#define SB_RAM6_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x018000) << 2)))
+
+/*
+ * DWORD-Length of Memory Blocks
+ */
+#define PP32_DEBUG_REG_DWLEN 0x0030
+#define CDM_CODE_MEMORYn_DWLEN(n) ((n) == 0 ? 0x1000 : 0x0800)
+#define CDM_DATA_MEMORY_DWLEN CDM_CODE_MEMORYn_DWLEN(1)
+#define SB_RAM0_DWLEN 0x1000
+#define SB_RAM1_DWLEN 0x1000
+#define SB_RAM2_DWLEN 0x1000
+#define SB_RAM3_DWLEN 0x1000
+#define SB_RAM6_DWLEN 0x8000
+#define QSB_CONF_REG_DWLEN 0x0100
+
+/*
+ * PP32 to FPI Address Mapping
+ */
+#define SB_BUFFER(__sb_addr) ((volatile unsigned int *)((((__sb_addr) >= 0x0000) && ((__sb_addr) <= 0x1FFF)) ? PPE_REG_ADDR((__sb_addr)) : \
+ (((__sb_addr) >= 0x2000) && ((__sb_addr) <= 0x2FFF)) ? SB_RAM0_ADDR((__sb_addr) - 0x2000) : \
+ (((__sb_addr) >= 0x3000) && ((__sb_addr) <= 0x3FFF)) ? SB_RAM1_ADDR((__sb_addr) - 0x3000) : \
+ (((__sb_addr) >= 0x4000) && ((__sb_addr) <= 0x4FFF)) ? SB_RAM2_ADDR((__sb_addr) - 0x4000) : \
+ (((__sb_addr) >= 0x5000) && ((__sb_addr) <= 0x5FFF)) ? SB_RAM3_ADDR((__sb_addr) - 0x5000) : \
+ (((__sb_addr) >= 0x7000) && ((__sb_addr) <= 0x7FFF)) ? PPE_REG_ADDR((__sb_addr) - 0x7000) : \
+ (((__sb_addr) >= 0x8000) && ((__sb_addr) <= 0xFFFF)) ? SB_RAM6_ADDR((__sb_addr) - 0x8000) : \
+ 0))
+
+/*
+ * PP32 Debug Control Register
+ */
+#define NUM_OF_PP32 2
+
+#define PP32_FREEZE PPE_REG_ADDR(0x0000)
+#define PP32_SRST PPE_REG_ADDR(0x0020)
+
+#define PP32_DBG_CTRL(n) PP32_DEBUG_REG_ADDR(n, 0x0000)
+
+#define DBG_CTRL_RESTART 0
+#define DBG_CTRL_STOP 1
+
+#define PP32_CTRL_CMD(n) PP32_DEBUG_REG_ADDR(n, 0x0B00)
+ #define PP32_CTRL_CMD_RESTART (1 << 0)
+ #define PP32_CTRL_CMD_STOP (1 << 1)
+ #define PP32_CTRL_CMD_STEP (1 << 2)
+ #define PP32_CTRL_CMD_BREAKOUT (1 << 3)
+
+#define PP32_CTRL_OPT(n) PP32_DEBUG_REG_ADDR(n, 0x0C00)
+ #define PP32_CTRL_OPT_BREAKOUT_ON_STOP_ON (3 << 0)
+ #define PP32_CTRL_OPT_BREAKOUT_ON_STOP_OFF (2 << 0)
+ #define PP32_CTRL_OPT_BREAKOUT_ON_BREAKIN_ON (3 << 2)
+ #define PP32_CTRL_OPT_BREAKOUT_ON_BREAKIN_OFF (2 << 2)
+ #define PP32_CTRL_OPT_STOP_ON_BREAKIN_ON (3 << 4)
+ #define PP32_CTRL_OPT_STOP_ON_BREAKIN_OFF (2 << 4)
+ #define PP32_CTRL_OPT_STOP_ON_BREAKPOINT_ON (3 << 6)
+ #define PP32_CTRL_OPT_STOP_ON_BREAKPOINT_OFF (2 << 6)
+ #define PP32_CTRL_OPT_BREAKOUT_ON_STOP(n) (*PP32_CTRL_OPT(n) & (1 << 0))
+ #define PP32_CTRL_OPT_BREAKOUT_ON_BREAKIN(n) (*PP32_CTRL_OPT(n) & (1 << 2))
+ #define PP32_CTRL_OPT_STOP_ON_BREAKIN(n) (*PP32_CTRL_OPT(n) & (1 << 4))
+ #define PP32_CTRL_OPT_STOP_ON_BREAKPOINT(n) (*PP32_CTRL_OPT(n) & (1 << 6))
+
+#define PP32_BRK_PC(n, i) PP32_DEBUG_REG_ADDR(n, 0x0900 + (i) * 2)
+#define PP32_BRK_PC_MASK(n, i) PP32_DEBUG_REG_ADDR(n, 0x0901 + (i) * 2)
+#define PP32_BRK_DATA_ADDR(n, i) PP32_DEBUG_REG_ADDR(n, 0x0904 + (i) * 2)
+#define PP32_BRK_DATA_ADDR_MASK(n, i) PP32_DEBUG_REG_ADDR(n, 0x0905 + (i) * 2)
+#define PP32_BRK_DATA_VALUE_RD(n, i) PP32_DEBUG_REG_ADDR(n, 0x0908 + (i) * 2)
+#define PP32_BRK_DATA_VALUE_RD_MASK(n, i) PP32_DEBUG_REG_ADDR(n, 0x0909 + (i) * 2)
+#define PP32_BRK_DATA_VALUE_WR(n, i) PP32_DEBUG_REG_ADDR(n, 0x090C + (i) * 2)
+#define PP32_BRK_DATA_VALUE_WR_MASK(n, i) PP32_DEBUG_REG_ADDR(n, 0x090D + (i) * 2)
+ #define PP32_BRK_CONTEXT_MASK(i) (1 << (i))
+ #define PP32_BRK_CONTEXT_MASK_EN (1 << 4)
+ #define PP32_BRK_COMPARE_GREATER_EQUAL (1 << 5) // valid for break data value rd/wr only
+ #define PP32_BRK_COMPARE_LOWER_EQUAL (1 << 6)
+ #define PP32_BRK_COMPARE_EN (1 << 7)
+
+#define PP32_BRK_TRIG(n) PP32_DEBUG_REG_ADDR(n, 0x0F00)
+ #define PP32_BRK_GRPi_PCn_ON(i, n) ((3 << ((n) * 2)) << ((i) * 16))
+ #define PP32_BRK_GRPi_PCn_OFF(i, n) ((2 << ((n) * 2)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_ADDRn_ON(i, n) ((3 << ((n) * 2 + 4)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_ADDRn_OFF(i, n) ((2 << ((n) * 2 + 4)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_VALUE_RDn_ON(i, n) ((3 << ((n) * 2 + 8)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_VALUE_RDn_OFF(i, n)((2 << ((n) * 2 + 8)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_VALUE_WRn_ON(i, n) ((3 << ((n) * 2 + 12)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_VALUE_WRn_OFF(i, n)((2 << ((n) * 2 + 12)) << ((i) * 16))
+ #define PP32_BRK_GRPi_PCn(k, i, n) (*PP32_BRK_TRIG(k) & ((1 << ((n))) << ((i) * 8)))
+ #define PP32_BRK_GRPi_DATA_ADDRn(k, i, n) (*PP32_BRK_TRIG(k) & ((1 << ((n) + 2)) << ((i) * 8)))
+ #define PP32_BRK_GRPi_DATA_VALUE_RDn(k, i, n) (*PP32_BRK_TRIG(k) & ((1 << ((n) + 4)) << ((i) * 8)))
+ #define PP32_BRK_GRPi_DATA_VALUE_WRn(k, i, n) (*PP32_BRK_TRIG(k) & ((1 << ((n) + 6)) << ((i) * 8)))
+
+#define PP32_CPU_STATUS(n) PP32_DEBUG_REG_ADDR(n, 0x0D00)
+#define PP32_HALT_STAT(n) PP32_CPU_STATUS(n)
+#define PP32_DBG_CUR_PC(n) PP32_CPU_STATUS(n)
+ #define PP32_CPU_USER_STOPPED(n) (*PP32_CPU_STATUS(n) & (1 << 0))
+ #define PP32_CPU_USER_BREAKIN_RCV(n) (*PP32_CPU_STATUS(n) & (1 << 1))
+ #define PP32_CPU_USER_BREAKPOINT_MET(n) (*PP32_CPU_STATUS(n) & (1 << 2))
+ #define PP32_CPU_CUR_PC(n) (*PP32_CPU_STATUS(n) >> 16)
+
+#define PP32_BREAKPOINT_REASONS(n) PP32_DEBUG_REG_ADDR(n, 0x0A00)
+ #define PP32_BRK_PC_MET(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << (i)))
+ #define PP32_BRK_DATA_ADDR_MET(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) + 2)))
+ #define PP32_BRK_DATA_VALUE_RD_MET(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) + 4)))
+ #define PP32_BRK_DATA_VALUE_WR_MET(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) + 6)))
+ #define PP32_BRK_DATA_VALUE_RD_LO_EQ(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) * 2 + 8)))
+ #define PP32_BRK_DATA_VALUE_RD_GT_EQ(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) * 2 + 9)))
+ #define PP32_BRK_DATA_VALUE_WR_LO_EQ(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) * 2 + 12)))
+ #define PP32_BRK_DATA_VALUE_WR_GT_EQ(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) * 2 + 13)))
+ #define PP32_BRK_CUR_CONTEXT(n) ((*PP32_BREAKPOINT_REASONS(n) >> 16) & 0x03)
+
+#define PP32_GP_REG_BASE(n) PP32_DEBUG_REG_ADDR(n, 0x0E00)
+#define PP32_GP_CONTEXTi_REGn(n, i, j) PP32_DEBUG_REG_ADDR(n, 0x0E00 + (i) * 16 + (j))
+
+/*
+ * SAR Registers
+ */
+#define SAR_MODE_CFG PPE_REG_ADDR(0x080A)
+#define SAR_RX_CMD_CNT PPE_REG_ADDR(0x080B)
+#define SAR_TX_CMD_CNT PPE_REG_ADDR(0x080C)
+#define SAR_RX_CTX_CFG PPE_REG_ADDR(0x080D)
+#define SAR_TX_CTX_CFG PPE_REG_ADDR(0x080E)
+#define SAR_TX_CMD_DONE_CNT PPE_REG_ADDR(0x080F)
+#define SAR_POLY_CFG_SET0 PPE_REG_ADDR(0x0812)
+#define SAR_POLY_CFG_SET1 PPE_REG_ADDR(0x0813)
+#define SAR_POLY_CFG_SET2 PPE_REG_ADDR(0x0814)
+#define SAR_POLY_CFG_SET3 PPE_REG_ADDR(0x0815)
+#define SAR_CRC_SIZE_CFG PPE_REG_ADDR(0x0816)
+
+/*
+ * PDMA/EMA Registers
+ */
+#define PDMA_CFG PPE_REG_ADDR(0x0A00)
+#define PDMA_RX_CMDCNT PPE_REG_ADDR(0x0A01)
+#define PDMA_TX_CMDCNT PPE_REG_ADDR(0x0A02)
+#define PDMA_RX_FWDATACNT PPE_REG_ADDR(0x0A03)
+#define PDMA_TX_FWDATACNT PPE_REG_ADDR(0x0A04)
+#define PDMA_RX_CTX_CFG PPE_REG_ADDR(0x0A05)
+#define PDMA_TX_CTX_CFG PPE_REG_ADDR(0x0A06)
+#define PDMA_RX_MAX_LEN_REG PPE_REG_ADDR(0x0A07)
+#define PDMA_RX_DELAY_CFG PPE_REG_ADDR(0x0A08)
+#define PDMA_INT_FIFO_RD PPE_REG_ADDR(0x0A09)
+#define PDMA_ISR PPE_REG_ADDR(0x0A0A)
+#define PDMA_IER PPE_REG_ADDR(0x0A0B)
+#define PDMA_SUBID PPE_REG_ADDR(0x0A0C)
+#define PDMA_BAR0 PPE_REG_ADDR(0x0A0D)
+#define PDMA_BAR1 PPE_REG_ADDR(0x0A0E)
+
+#define SAR_PDMA_RX_CMDBUF_CFG PPE_REG_ADDR(0x0F00)
+#define SAR_PDMA_TX_CMDBUF_CFG PPE_REG_ADDR(0x0F01)
+#define SAR_PDMA_RX_FW_CMDBUF_CFG PPE_REG_ADDR(0x0F02)
+#define SAR_PDMA_TX_FW_CMDBUF_CFG PPE_REG_ADDR(0x0F03)
+#define SAR_PDMA_RX_CMDBUF_STATUS PPE_REG_ADDR(0x0F04)
+#define SAR_PDMA_TX_CMDBUF_STATUS PPE_REG_ADDR(0x0F05)
+
+#define PDMA_ALIGNMENT 32 // same as Central DMA because of descriptor swap
+#define EMA_ALIGNMENT PDMA_ALIGNMENT
+
+/*
+ * Mailbox IGU1 Interrupt
+ */
+#define PPE_MAILBOX_IGU1_INT INT_NUM_IM2_IRL24
+
+
+
+#endif // IFXMIPS_PTM_PPE_VR9_H
diff --git a/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_test.c.svn-base b/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_test.c.svn-base
new file mode 100644
index 0000000..15d8352
--- /dev/null
+++ b/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_test.c.svn-base
@@ -0,0 +1,943 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_ptm_vdsl.c
+** PROJECT : UEIP
+** MODULES : PTM
+**
+** DATE : 7 Jul 2009
+** AUTHOR : Xu Liang
+** DESCRIPTION : PTM driver common source file (core functions for VR9)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 07 JUL 2009 Xu Liang Init Version
+*******************************************************************************/
+
+
+
+#ifdef CONFIG_IFX_PTM_TEST_PROC
+
+/*
+ * ####################################
+ * Head File
+ * ####################################
+ */
+
+/*
+ * Common Head File
+ */
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/version.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/proc_fs.h>
+#include <linux/init.h>
+#include <linux/ioctl.h>
+#include <linux/etherdevice.h>
+
+/*
+ * Chip Specific Head File
+ */
+#include <asm/ifx/ifx_types.h>
+#include <asm/ifx/ifx_regs.h>
+#include <asm/ifx/common_routines.h>
+#include "ifxmips_ptm_common.h"
+#include "ifxmips_ptm_ppe_common.h"
+
+
+
+/*
+ * ####################################
+ * Definition
+ * ####################################
+ */
+
+
+
+/*
+ * ####################################
+ * Declaration
+ * ####################################
+ */
+
+/*
+ * Proc File Functions
+ */
+static inline void proc_file_create(void);
+static inline void proc_file_delete(void);
+
+/*
+ * Proc Help Functions
+ */
+static int proc_write_mem(struct file *, const char *, unsigned long, void *);
+static int proc_read_pp32(char *, char **, off_t, int, int *, void *);
+static int proc_write_pp32(struct file *, const char *, unsigned long, void *);
+static int stricmp(const char *, const char *);
+static int strincmp(const char *, const char *, int);
+static int get_token(char **, char **, int *, int *);
+static int get_number(char **, int *, int);
+static inline void ignore_space(char **, int *);
+
+
+
+/*
+ * ####################################
+ * Local Variable
+ * ####################################
+ */
+
+
+
+/*
+ * ####################################
+ * Local Function
+ * ####################################
+ */
+
+static inline void proc_file_create(void)
+{
+ struct proc_dir_entry *res;
+
+ res = create_proc_entry("driver/ifx_ptm/mem",
+ 0,
+ NULL);
+ if ( res != NULL )
+ res->write_proc = proc_write_mem;
+ else
+ printk("%s:%s:%d: failed to create proc mem!", __FILE__, __func__, __LINE__);
+
+ res = create_proc_entry("driver/ifx_ptm/pp32",
+ 0,
+ NULL);
+ if ( res != NULL ) {
+ res->read_proc = proc_read_pp32;
+ res->write_proc = proc_write_pp32;
+ }
+ else
+ printk("%s:%s:%d: failed to create proc pp32!", __FILE__, __func__, __LINE__);
+}
+
+static inline void proc_file_delete(void)
+{
+ remove_proc_entry("driver/ifx_ptm/pp32", NULL);
+
+ remove_proc_entry("driver/ifx_ptm/mem", NULL);
+}
+
+static inline unsigned long sb_addr_to_fpi_addr_convert(unsigned long sb_addr)
+{
+#define PP32_SB_ADDR_END 0xFFFF
+
+ if ( sb_addr < PP32_SB_ADDR_END) {
+ return (unsigned long ) SB_BUFFER(sb_addr);
+ }
+ else {
+ return sb_addr;
+ }
+}
+
+static int proc_write_mem(struct file *file, const char *buf, unsigned long count, void *data)
+{
+ char *p1, *p2;
+ int len;
+ int colon;
+ unsigned long *p;
+ char local_buf[1024];
+ int i, n, l;
+
+ len = sizeof(local_buf) < count ? sizeof(local_buf) - 1 : count;
+ len = len - copy_from_user(local_buf, buf, len);
+ local_buf[len] = 0;
+
+ p1 = local_buf;
+ colon = 1;
+ while ( get_token(&p1, &p2, &len, &colon) )
+ {
+ if ( stricmp(p1, "w") == 0 || stricmp(p1, "write") == 0 || stricmp(p1, "r") == 0 || stricmp(p1, "read") == 0 )
+ break;
+
+ p1 = p2;
+ colon = 1;
+ }
+
+ if ( *p1 == 'w' )
+ {
+ ignore_space(&p2, &len);
+ p = (unsigned long *)get_number(&p2, &len, 1);
+ p = (unsigned long *)sb_addr_to_fpi_addr_convert( (unsigned long) p);
+
+ if ( (u32)p >= KSEG0 )
+ while ( 1 )
+ {
+ ignore_space(&p2, &len);
+ if ( !len || !((*p2 >= '0' && *p2 <= '9') || (*p2 >= 'a' && *p2 <= 'f') || (*p2 >= 'A' && *p2 <= 'F')) )
+ break;
+
+ *p++ = (u32)get_number(&p2, &len, 1);
+ }
+ }
+ else if ( *p1 == 'r' )
+ {
+ ignore_space(&p2, &len);
+ p = (unsigned long *)get_number(&p2, &len, 1);
+ p = (unsigned long *)sb_addr_to_fpi_addr_convert( (unsigned long) p);
+
+ if ( (u32)p >= KSEG0 )
+ {
+ ignore_space(&p2, &len);
+ n = (int)get_number(&p2, &len, 0);
+ if ( n )
+ {
+ char str[32] = {0};
+ char *pch = str;
+ int k;
+ u32 data;
+ char c;
+
+ n += (l = ((int)p >> 2) & 0x03);
+ p = (unsigned long *)((u32)p & ~0x0F);
+ for ( i = 0; i < n; i++ )
+ {
+ if ( (i & 0x03) == 0 )
+ {
+ printk("%08X:", (u32)p);
+ pch = str;
+ }
+ if ( i < l )
+ {
+ printk(" ");
+ sprintf(pch, " ");
+ }
+ else
+ {
+ data = (u32)*p;
+ printk(" %08X", data);
+ for ( k = 0; k < 4; k++ )
+ {
+ c = ((char*)&data)[k];
+ pch[k] = c < ' ' ? '.' : c;
+ }
+ }
+ p++;
+ pch += 4;
+ if ( (i & 0x03) == 0x03 )
+ {
+ pch[0] = 0;
+ printk(" ; %s\n", str);
+ }
+ }
+ if ( (n & 0x03) != 0x00 )
+ {
+ for ( k = 4 - (n & 0x03); k > 0; k-- )
+ printk(" ");
+ pch[0] = 0;
+ printk(" ; %s\n", str);
+ }
+ }
+ }
+ }
+
+ return count;
+}
+
+#ifdef CONFIG_DANUBE
+
+static int proc_read_pp32(char *page, char **start, off_t off, int count, int *eof, void *data)
+{
+ static const char *halt_stat[] = {
+ "reset",
+ "break in line",
+ "stop",
+ "step",
+ "code",
+ "data0",
+ "data1"
+ };
+ static const char *brk_src_data[] = {
+ "off",
+ "read",
+ "write",
+ "read/write",
+ "write_equal",
+ "N/A",
+ "N/A",
+ "N/A"
+ };
+ static const char *brk_src_code[] = {
+ "off",
+ "on"
+ };
+
+ int len = 0;
+ int cur_task;
+ int i, j;
+ int k;
+ unsigned long bit;
+
+ len += sprintf(page + off + len, "Task No %d, PC %04x\n", *PP32_DBG_TASK_NO & 0x03, *PP32_DBG_CUR_PC & 0xFFFF);
+
+ if ( !(*PP32_HALT_STAT & 0x01) )
+ len += sprintf(page + off + len, " Halt State: Running\n");
+ else
+ {
+ len += sprintf(page + off + len, " Halt State: Stopped");
+ k = 0;
+ for ( bit = 2, i = 0; bit <= (1 << 7); bit <<= 1, i++ )
+ if ( (*PP32_HALT_STAT & bit) )
+ {
+ if ( !k )
+ {
+ len += sprintf(page + off + len, ", ");
+ k++;
+ }
+ else
+ len += sprintf(page + off + len, " | ");
+ len += sprintf(page + off + len, halt_stat[i]);
+ }
+
+ len += sprintf(page + off + len, "\n");
+
+ cur_task = *PP32_DBG_TASK_NO & 0x03;
+ len += sprintf(page + off + len, "General Purpose Register (Task %d):\n", cur_task);
+ for ( i = 0; i < 4; i++ )
+ {
+ for ( j = 0; j < 4; j++ )
+ len += sprintf(page + off + len, " %2d: %08x", i + j * 4, *PP32_DBG_TASK_GPR(cur_task, i + j * 4));
+ len += sprintf(page + off + len, "\n");
+ }
+ }
+
+ len += sprintf(page + off + len, " Break Src: data1 - %s, data0 - %s, pc3 - %s, pc2 - %s, pc1 - %s, pc0 - %s\n",
+ brk_src_data[(*PP32_BRK_SRC >> 11) & 0x07], brk_src_data[(*PP32_BRK_SRC >> 8) & 0x07], brk_src_code[(*PP32_BRK_SRC >> 3) & 0x01], brk_src_code[(*PP32_BRK_SRC >> 2) & 0x01], brk_src_code[(*PP32_BRK_SRC >> 1) & 0x01], brk_src_code[*PP32_BRK_SRC & 0x01]);
+
+ for ( i = 0; i < 4; i++ )
+ len += sprintf(page + off + len, " pc%d: %04x - %04x\n", i, *PP32_DBG_PC_MIN(i), *PP32_DBG_PC_MAX(i));
+
+ for ( i = 0; i < 2; i++ )
+ len += sprintf(page + off + len, " data%d: %04x - %04x (%08x)\n", i, *PP32_DBG_DATA_MIN(i), *PP32_DBG_DATA_MAX(i), *PP32_DBG_DATA_VAL(i));
+
+ *eof = 1;
+
+ return len;
+}
+
+static int proc_write_pp32(struct file *file, const char *buf, unsigned long count, void *data)
+{
+ char str[2048];
+ char *p;
+ int len, rlen;
+
+ int id;
+ u32 addr;
+ u32 cmd;
+
+ len = count < sizeof(str) ? count : sizeof(str) - 1;
+ rlen = len - copy_from_user(str, buf, len);
+ while ( rlen && str[rlen - 1] <= ' ' )
+ rlen--;
+ str[rlen] = 0;
+ for ( p = str; *p && *p <= ' '; p++, rlen-- );
+ if ( !*p )
+ {
+ return 0;
+ }
+
+ if ( stricmp(str, "start") == 0 )
+ *PP32_DBG_CTRL = DBG_CTRL_START_SET(1);
+ else if ( stricmp(str, "stop") == 0 )
+ *PP32_DBG_CTRL = DBG_CTRL_STOP_SET(1);
+ else if ( stricmp(str, "step") == 0 )
+ *PP32_DBG_CTRL = DBG_CTRL_STEP_SET(1);
+ else if ( strincmp(p, "pc", 2) == 0 && p[2] >= '0' && p[2] <= '3' && p[3] == ' ' )
+ {
+ id = (int)(p[2] - '0');
+ p += 4;
+ rlen -= 4;
+ *PP32_BRK_SRC &= ~PP32_BRK_SRC_PC(id);
+ if ( stricmp(p, "off") != 0 )
+ {
+ ignore_space(&p, &rlen);
+ *PP32_DBG_PC_MIN(id) = *PP32_DBG_PC_MAX(id) = get_number(&p, &rlen, 1);
+ ignore_space(&p, &rlen);
+ if ( rlen > 0 )
+ {
+ addr = get_number(&p, &rlen, 1);
+ if ( addr >= *PP32_DBG_PC_MIN(id) )
+ *PP32_DBG_PC_MAX(id) = addr;
+ else
+ *PP32_DBG_PC_MIN(id) = addr;
+ }
+ *PP32_BRK_SRC |= PP32_BRK_SRC_PC(id);
+ }
+ }
+ else if ( strincmp(p, "daddr", 5) == 0 && p[5] >= '0' && p[5] <= '1' && p[6] == ' ' )
+ {
+ id = (int)(p[5] - '0');
+ p += 7;
+ rlen -= 7;
+ *PP32_BRK_SRC &= ~PP32_BRK_SRC_DATA(id, 7);
+ if ( stricmp(p, "off") != 0 )
+ {
+ ignore_space(&p, &rlen);
+ *PP32_DBG_DATA_MIN(id) = *PP32_DBG_DATA_MAX(id) = get_number(&p, &rlen, 1);
+ cmd = 1;
+ ignore_space(&p, &rlen);
+ if ( rlen > 0 && ((*p >= '0' && *p <= '9') || (*p >= 'a' && *p <= 'f') || (*p >= 'A' && *p <= 'F')) )
+ {
+ addr = get_number(&p, &rlen, 1);
+ if ( addr >= *PP32_DBG_PC_MIN(id) )
+ *PP32_DBG_DATA_MAX(id) = addr;
+ else
+ *PP32_DBG_DATA_MIN(id) = addr;
+ ignore_space(&p, &rlen);
+ }
+ if ( *p == 'w' )
+ cmd = 2;
+ else if ( *p == 'r' && p[1] == 'w' )
+ {
+ cmd = 3;
+ p++;
+ rlen--;
+ }
+ p++;
+ rlen--;
+ if ( rlen > 0 )
+ {
+ ignore_space(&p, &rlen);
+ if ( (*p >= '0' && *p <= '9') || (*p >= 'a' && *p <= 'f') || (*p >= 'A' && *p <= 'F'))
+ {
+ *PP32_DBG_DATA_VAL(id) = get_number(&p, &rlen, 1);
+ cmd = 4;
+ }
+ }
+ *PP32_BRK_SRC |= PP32_BRK_SRC_DATA(id, cmd);
+ }
+ }
+ else
+ {
+ printk("echo \"<command>\" > /proc/driver/ifx_ptm/pp32\n");
+ printk(" command:\n");
+ printk(" start - run pp32\n");
+ printk(" stop - stop pp32\n");
+ printk(" step - run pp32 with one step only\n");
+ printk(" pc0 - pc0 <addr_min [addr_max]>/off, set break point PC0\n");
+ printk(" pc1 - pc1 <addr_min [addr_max]>/off, set break point PC1\n");
+ printk(" pc2 - pc2 <addr_min [addr_max]>/off, set break point PC2\n");
+ printk(" pc3 - pc3 <addr_min [addr_max]>/off, set break point PC3\n");
+ printk(" daddr0 - daddr0 <addr_min [addr_max] r/w/rw [value]>/off, set break point data address 0\n");
+ printk(" daddr1 - daddr1 <addr_min [addr_max] r/w/rw [value]>/off, set break point data address 1\n");
+ printk(" help - print this screen\n");
+ }
+
+ return count;
+}
+
+#else
+
+static int proc_read_pp32(char *page, char **start, off_t off, int count, int *eof, void *data)
+{
+ static const char *stron = " on";
+ static const char *stroff = "off";
+
+ int len = 0;
+ int cur_context;
+ int f_stopped;
+ char str[256];
+ char strlength;
+ int i, j;
+
+ int pp32;
+
+ for ( pp32 = 0; pp32 < NUM_OF_PP32; pp32++ )
+ {
+ f_stopped = 0;
+
+ len += sprintf(page + off + len, "===== pp32 core %d =====\n", pp32);
+
+ #ifdef CONFIG_VR9
+ if ( (*PP32_FREEZE & (1 << (pp32 << 4))) != 0 )
+ {
+ sprintf(str, "freezed");
+ f_stopped = 1;
+ }
+ #else
+ if ( 0 )
+ {
+ }
+ #endif
+ else if ( PP32_CPU_USER_STOPPED(pp32) || PP32_CPU_USER_BREAKIN_RCV(pp32) || PP32_CPU_USER_BREAKPOINT_MET(pp32) )
+ {
+ strlength = 0;
+ if ( PP32_CPU_USER_STOPPED(pp32) )
+ strlength += sprintf(str + strlength, "stopped");
+ if ( PP32_CPU_USER_BREAKPOINT_MET(pp32) )
+ strlength += sprintf(str + strlength, strlength ? " | breakpoint" : "breakpoint");
+ if ( PP32_CPU_USER_BREAKIN_RCV(pp32) )
+ strlength += sprintf(str + strlength, strlength ? " | breakin" : "breakin");
+ f_stopped = 1;
+ }
+ else if ( PP32_CPU_CUR_PC(pp32) == PP32_CPU_CUR_PC(pp32) )
+ {
+ unsigned int pc_value[64] = {0};
+
+ f_stopped = 1;
+ for ( i = 0; f_stopped && i < NUM_ENTITY(pc_value); i++ )
+ {
+ pc_value[i] = PP32_CPU_CUR_PC(pp32);
+ for ( j = 0; j < i; j++ )
+ if ( pc_value[j] != pc_value[i] )
+ {
+ f_stopped = 0;
+ break;
+ }
+ }
+ if ( f_stopped )
+ sprintf(str, "hang");
+ }
+ if ( !f_stopped )
+ sprintf(str, "running");
+ cur_context = PP32_BRK_CUR_CONTEXT(pp32);
+ len += sprintf(page + off + len, "Context: %d, PC: 0x%04x, %s\n", cur_context, PP32_CPU_CUR_PC(pp32), str);
+
+ if ( PP32_CPU_USER_BREAKPOINT_MET(pp32) )
+ {
+ strlength = 0;
+ if ( PP32_BRK_PC_MET(pp32, 0) )
+ strlength += sprintf(str + strlength, "pc0");
+ if ( PP32_BRK_PC_MET(pp32, 1) )
+ strlength += sprintf(str + strlength, strlength ? " | pc1" : "pc1");
+ if ( PP32_BRK_DATA_ADDR_MET(pp32, 0) )
+ strlength += sprintf(str + strlength, strlength ? " | daddr0" : "daddr0");
+ if ( PP32_BRK_DATA_ADDR_MET(pp32, 1) )
+ strlength += sprintf(str + strlength, strlength ? " | daddr1" : "daddr1");
+ if ( PP32_BRK_DATA_VALUE_RD_MET(pp32, 0) )
+ {
+ strlength += sprintf(str + strlength, strlength ? " | rdval0" : "rdval0");
+ if ( PP32_BRK_DATA_VALUE_RD_LO_EQ(pp32, 0) )
+ {
+ if ( PP32_BRK_DATA_VALUE_RD_GT_EQ(pp32, 0) )
+ strlength += sprintf(str + strlength, " ==");
+ else
+ strlength += sprintf(str + strlength, " <=");
+ }
+ else if ( PP32_BRK_DATA_VALUE_RD_GT_EQ(pp32, 0) )
+ strlength += sprintf(str + strlength, " >=");
+ }
+ if ( PP32_BRK_DATA_VALUE_RD_MET(pp32, 1) )
+ {
+ strlength += sprintf(str + strlength, strlength ? " | rdval1" : "rdval1");
+ if ( PP32_BRK_DATA_VALUE_RD_LO_EQ(pp32, 1) )
+ {
+ if ( PP32_BRK_DATA_VALUE_RD_GT_EQ(pp32, 1) )
+ strlength += sprintf(str + strlength, " ==");
+ else
+ strlength += sprintf(str + strlength, " <=");
+ }
+ else if ( PP32_BRK_DATA_VALUE_RD_GT_EQ(pp32, 1) )
+ strlength += sprintf(str + strlength, " >=");
+ }
+ if ( PP32_BRK_DATA_VALUE_WR_MET(pp32, 0) )
+ {
+ strlength += sprintf(str + strlength, strlength ? " | wtval0" : "wtval0");
+ if ( PP32_BRK_DATA_VALUE_WR_LO_EQ(pp32, 0) )
+ {
+ if ( PP32_BRK_DATA_VALUE_WR_GT_EQ(pp32, 0) )
+ strlength += sprintf(str + strlength, " ==");
+ else
+ strlength += sprintf(str + strlength, " <=");
+ }
+ else if ( PP32_BRK_DATA_VALUE_WR_GT_EQ(pp32, 0) )
+ strlength += sprintf(str + strlength, " >=");
+ }
+ if ( PP32_BRK_DATA_VALUE_WR_MET(pp32, 1) )
+ {
+ strlength += sprintf(str + strlength, strlength ? " | wtval1" : "wtval1");
+ if ( PP32_BRK_DATA_VALUE_WR_LO_EQ(pp32, 1) )
+ {
+ if ( PP32_BRK_DATA_VALUE_WR_GT_EQ(pp32, 1) )
+ strlength += sprintf(str + strlength, " ==");
+ else
+ strlength += sprintf(str + strlength, " <=");
+ }
+ else if ( PP32_BRK_DATA_VALUE_WR_GT_EQ(pp32, 1) )
+ strlength += sprintf(str + strlength, " >=");
+ }
+ len += sprintf(page + off + len, "break reason: %s\n", str);
+ }
+
+ if ( f_stopped )
+ {
+ len += sprintf(page + off + len, "General Purpose Register (Context %d):\n", cur_context);
+ for ( i = 0; i < 4; i++ )
+ {
+ for ( j = 0; j < 4; j++ )
+ len += sprintf(page + off + len, " %2d: %08x", i + j * 4, *PP32_GP_CONTEXTi_REGn(pp32, cur_context, i + j * 4));
+ len += sprintf(page + off + len, "\n");
+ }
+ }
+
+ len += sprintf(page + off + len, "break out on: break in - %s, stop - %s\n",
+ PP32_CTRL_OPT_BREAKOUT_ON_BREAKIN(pp32) ? stron : stroff,
+ PP32_CTRL_OPT_BREAKOUT_ON_STOP(pp32) ? stron : stroff);
+ len += sprintf(page + off + len, " stop on: break in - %s, break point - %s\n",
+ PP32_CTRL_OPT_STOP_ON_BREAKIN(pp32) ? stron : stroff,
+ PP32_CTRL_OPT_STOP_ON_BREAKPOINT(pp32) ? stron : stroff);
+ len += sprintf(page + off + len, "breakpoint:\n");
+ len += sprintf(page + off + len, " pc0: 0x%08x, %s\n", *PP32_BRK_PC(pp32, 0), PP32_BRK_GRPi_PCn(pp32, 0, 0) ? "group 0" : "off");
+ len += sprintf(page + off + len, " pc1: 0x%08x, %s\n", *PP32_BRK_PC(pp32, 1), PP32_BRK_GRPi_PCn(pp32, 1, 1) ? "group 1" : "off");
+ len += sprintf(page + off + len, " daddr0: 0x%08x, %s\n", *PP32_BRK_DATA_ADDR(pp32, 0), PP32_BRK_GRPi_DATA_ADDRn(pp32, 0, 0) ? "group 0" : "off");
+ len += sprintf(page + off + len, " daddr1: 0x%08x, %s\n", *PP32_BRK_DATA_ADDR(pp32, 1), PP32_BRK_GRPi_DATA_ADDRn(pp32, 1, 1) ? "group 1" : "off");
+ len += sprintf(page + off + len, " rdval0: 0x%08x\n", *PP32_BRK_DATA_VALUE_RD(pp32, 0));
+ len += sprintf(page + off + len, " rdval1: 0x%08x\n", *PP32_BRK_DATA_VALUE_RD(pp32, 1));
+ len += sprintf(page + off + len, " wrval0: 0x%08x\n", *PP32_BRK_DATA_VALUE_WR(pp32, 0));
+ len += sprintf(page + off + len, " wrval1: 0x%08x\n", *PP32_BRK_DATA_VALUE_WR(pp32, 1));
+ }
+
+ *eof = 1;
+
+ return len;
+}
+
+static int proc_write_pp32(struct file *file, const char *buf, unsigned long count, void *data)
+{
+ char str[2048];
+ char *p;
+ int len, rlen;
+
+ int pp32 = 0;
+ u32 addr;
+
+ len = count < sizeof(str) ? count : sizeof(str) - 1;
+ rlen = len - copy_from_user(str, buf, len);
+ while ( rlen && str[rlen - 1] <= ' ' )
+ rlen--;
+ str[rlen] = 0;
+ for ( p = str; *p && *p <= ' '; p++, rlen-- );
+ if ( !*p )
+ return 0;
+
+ if ( strincmp(p, "pp32 ", 5) == 0 )
+ {
+ p += 5;
+ rlen -= 5;
+
+ while ( rlen > 0 && *p >= '0' && *p <= '9' )
+ {
+ pp32 += *p - '0';
+ p++;
+ rlen--;
+ }
+ while ( rlen > 0 && *p && *p <= ' ' )
+ {
+ p++;
+ rlen--;
+ }
+
+ if ( pp32 >= NUM_OF_PP32 )
+ {
+ printk(KERN_ERR __FILE__ ":%d:%s: incorrect pp32 index - %d\n", __LINE__, __FUNCTION__, pp32);
+ return count;
+ }
+ }
+
+ if ( stricmp(p, "start") == 0 )
+ {
+ #ifdef CONFIG_AMAZON_SE
+ *PP32_CTRL_CMD(pp32) = 0;
+ #endif
+ *PP32_CTRL_CMD(pp32) = PP32_CTRL_CMD_RESTART;
+ }
+ else if ( stricmp(p, "stop") == 0 )
+ {
+ #ifdef CONFIG_AMAZON_SE
+ *PP32_CTRL_CMD(pp32) = 0;
+ #endif
+ *PP32_CTRL_CMD(pp32) = PP32_CTRL_CMD_STOP;
+ }
+ else if ( stricmp(p, "step") == 0 )
+ {
+ #ifdef CONFIG_AMAZON_SE
+ *PP32_CTRL_CMD(pp32) = 0;
+ #endif
+ *PP32_CTRL_CMD(pp32) = PP32_CTRL_CMD_STEP;
+ }
+ #ifdef CONFIG_VR9
+ else if ( stricmp(p, "unfreeze") == 0 )
+ *PP32_FREEZE &= ~(1 << (pp32 << 4));
+ else if ( stricmp(p, "freeze") == 0 )
+ *PP32_FREEZE |= 1 << (pp32 << 4);
+ #else
+ else if ( stricmp(p, "unfreeze") == 0 )
+ *PP32_DBG_CTRL(pp32) = DBG_CTRL_RESTART;
+ else if ( stricmp(p, "freeze") == 0 )
+ *PP32_DBG_CTRL(pp32) = DBG_CTRL_STOP;
+ #endif
+ else if ( strincmp(p, "pc0 ", 4) == 0 )
+ {
+ p += 4;
+ rlen -= 4;
+ if ( stricmp(p, "off") == 0 )
+ {
+ *PP32_BRK_TRIG(pp32) = PP32_BRK_GRPi_PCn_OFF(0, 0);
+ *PP32_BRK_PC_MASK(pp32, 0) = PP32_BRK_CONTEXT_MASK_EN;
+ *PP32_BRK_PC(pp32, 0) = 0;
+ }
+ else
+ {
+ addr = get_number(&p, &rlen, 1);
+ *PP32_BRK_PC(pp32, 0) = addr;
+ *PP32_BRK_PC_MASK(pp32, 0) = PP32_BRK_CONTEXT_MASK_EN | PP32_BRK_CONTEXT_MASK(0) | PP32_BRK_CONTEXT_MASK(1) | PP32_BRK_CONTEXT_MASK(2) | PP32_BRK_CONTEXT_MASK(3);
+ *PP32_BRK_TRIG(pp32) = PP32_BRK_GRPi_PCn_ON(0, 0);
+ }
+ }
+ else if ( strincmp(p, "pc1 ", 4) == 0 )
+ {
+ p += 4;
+ rlen -= 4;
+ if ( stricmp(p, "off") == 0 )
+ {
+ *PP32_BRK_TRIG(pp32) = PP32_BRK_GRPi_PCn_OFF(1, 1);
+ *PP32_BRK_PC_MASK(pp32, 1) = PP32_BRK_CONTEXT_MASK_EN;
+ *PP32_BRK_PC(pp32, 1) = 0;
+ }
+ else
+ {
+ addr = get_number(&p, &rlen, 1);
+ *PP32_BRK_PC(pp32, 1) = addr;
+ *PP32_BRK_PC_MASK(pp32, 1) = PP32_BRK_CONTEXT_MASK_EN | PP32_BRK_CONTEXT_MASK(0) | PP32_BRK_CONTEXT_MASK(1) | PP32_BRK_CONTEXT_MASK(2) | PP32_BRK_CONTEXT_MASK(3);
+ *PP32_BRK_TRIG(pp32) = PP32_BRK_GRPi_PCn_ON(1, 1);
+ }
+ }
+ else if ( strincmp(p, "daddr0 ", 7) == 0 )
+ {
+ p += 7;
+ rlen -= 7;
+ if ( stricmp(p, "off") == 0 )
+ {
+ *PP32_BRK_TRIG(pp32) = PP32_BRK_GRPi_DATA_ADDRn_OFF(0, 0);
+ *PP32_BRK_DATA_ADDR_MASK(pp32, 0) = PP32_BRK_CONTEXT_MASK_EN;
+ *PP32_BRK_DATA_ADDR(pp32, 0) = 0;
+ }
+ else
+ {
+ addr = get_number(&p, &rlen, 1);
+ *PP32_BRK_DATA_ADDR(pp32, 0) = addr;
+ *PP32_BRK_DATA_ADDR_MASK(pp32, 0) = PP32_BRK_CONTEXT_MASK_EN | PP32_BRK_CONTEXT_MASK(0) | PP32_BRK_CONTEXT_MASK(1) | PP32_BRK_CONTEXT_MASK(2) | PP32_BRK_CONTEXT_MASK(3);
+ *PP32_BRK_TRIG(pp32) = PP32_BRK_GRPi_DATA_ADDRn_ON(0, 0);
+ }
+ }
+ else if ( strincmp(p, "daddr1 ", 7) == 0 )
+ {
+ p += 7;
+ rlen -= 7;
+ if ( stricmp(p, "off") == 0 )
+ {
+ *PP32_BRK_TRIG(pp32) = PP32_BRK_GRPi_DATA_ADDRn_OFF(1, 1);
+ *PP32_BRK_DATA_ADDR_MASK(pp32, 1) = PP32_BRK_CONTEXT_MASK_EN;
+ *PP32_BRK_DATA_ADDR(pp32, 1) = 0;
+ }
+ else
+ {
+ addr = get_number(&p, &rlen, 1);
+ *PP32_BRK_DATA_ADDR(pp32, 1) = addr;
+ *PP32_BRK_DATA_ADDR_MASK(pp32, 1) = PP32_BRK_CONTEXT_MASK_EN | PP32_BRK_CONTEXT_MASK(0) | PP32_BRK_CONTEXT_MASK(1) | PP32_BRK_CONTEXT_MASK(2) | PP32_BRK_CONTEXT_MASK(3);
+ *PP32_BRK_TRIG(pp32) = PP32_BRK_GRPi_DATA_ADDRn_ON(1, 1);
+ }
+ }
+ else
+ {
+
+ printk("echo \"<command>\" > /proc/driver/ifx_ptm/pp32\n");
+ printk(" command:\n");
+ printk(" unfreeze - unfreeze pp32\n");
+ printk(" freeze - freeze pp32\n");
+ printk(" start - run pp32\n");
+ printk(" stop - stop pp32\n");
+ printk(" step - run pp32 with one step only\n");
+ printk(" pc0 - pc0 <addr>/off, set break point PC0\n");
+ printk(" pc1 - pc1 <addr>/off, set break point PC1\n");
+ printk(" daddr0 - daddr0 <addr>/off, set break point data address 0\n");
+ printk(" daddr1 - daddr1 <addr>/off, set break point data address 1\n");
+ printk(" help - print this screen\n");
+ }
+
+ if ( *PP32_BRK_TRIG(pp32) )
+ *PP32_CTRL_OPT(pp32) = PP32_CTRL_OPT_STOP_ON_BREAKPOINT_ON;
+ else
+ *PP32_CTRL_OPT(pp32) = PP32_CTRL_OPT_STOP_ON_BREAKPOINT_OFF;
+
+ return count;
+}
+
+#endif
+
+static int stricmp(const char *p1, const char *p2)
+{
+ int c1, c2;
+
+ while ( *p1 && *p2 )
+ {
+ c1 = *p1 >= 'A' && *p1 <= 'Z' ? *p1 + 'a' - 'A' : *p1;
+ c2 = *p2 >= 'A' && *p2 <= 'Z' ? *p2 + 'a' - 'A' : *p2;
+ if ( (c1 -= c2) )
+ return c1;
+ p1++;
+ p2++;
+ }
+
+ return *p1 - *p2;
+}
+
+static int strincmp(const char *p1, const char *p2, int n)
+{
+ int c1 = 0, c2;
+
+ while ( n && *p1 && *p2 )
+ {
+ c1 = *p1 >= 'A' && *p1 <= 'Z' ? *p1 + 'a' - 'A' : *p1;
+ c2 = *p2 >= 'A' && *p2 <= 'Z' ? *p2 + 'a' - 'A' : *p2;
+ if ( (c1 -= c2) )
+ return c1;
+ p1++;
+ p2++;
+ n--;
+ }
+
+ return n ? *p1 - *p2 : c1;
+}
+
+static int get_token(char **p1, char **p2, int *len, int *colon)
+{
+ int tlen = 0;
+
+ while ( *len && !((**p1 >= 'A' && **p1 <= 'Z') || (**p1 >= 'a' && **p1<= 'z')) )
+ {
+ (*p1)++;
+ (*len)--;
+ }
+ if ( !*len )
+ return 0;
+
+ if ( *colon )
+ {
+ *colon = 0;
+ *p2 = *p1;
+ while ( *len && **p2 > ' ' && **p2 != ',' )
+ {
+ if ( **p2 == ':' )
+ {
+ *colon = 1;
+ break;
+ }
+ (*p2)++;
+ (*len)--;
+ tlen++;
+ }
+ **p2 = 0;
+ }
+ else
+ {
+ *p2 = *p1;
+ while ( *len && **p2 > ' ' && **p2 != ',' )
+ {
+ (*p2)++;
+ (*len)--;
+ tlen++;
+ }
+ **p2 = 0;
+ }
+
+ return tlen;
+}
+
+static int get_number(char **p, int *len, int is_hex)
+{
+ int ret = 0;
+ int n = 0;
+
+ if ( (*p)[0] == '0' && (*p)[1] == 'x' )
+ {
+ is_hex = 1;
+ (*p) += 2;
+ (*len) -= 2;
+ }
+
+ if ( is_hex )
+ {
+ while ( *len && ((**p >= '0' && **p <= '9') || (**p >= 'a' && **p <= 'f') || (**p >= 'A' && **p <= 'F')) )
+ {
+ if ( **p >= '0' && **p <= '9' )
+ n = **p - '0';
+ else if ( **p >= 'a' && **p <= 'f' )
+ n = **p - 'a' + 10;
+ else if ( **p >= 'A' && **p <= 'F' )
+ n = **p - 'A' + 10;
+ ret = (ret << 4) | n;
+ (*p)++;
+ (*len)--;
+ }
+ }
+ else
+ {
+ while ( *len && **p >= '0' && **p <= '9' )
+ {
+ n = **p - '0';
+ ret = ret * 10 + n;
+ (*p)++;
+ (*len)--;
+ }
+ }
+
+ return ret;
+}
+
+static inline void ignore_space(char **p, int *len)
+{
+ while ( *len && (**p <= ' ' || **p == ':' || **p == '.' || **p == ',') )
+ {
+ (*p)++;
+ (*len)--;
+ }
+}
+
+
+
+/*
+ * ####################################
+ * Global Function
+ * ####################################
+ */
+
+
+
+/*
+ * ####################################
+ * Init/Cleanup API
+ * ####################################
+ */
+
+static int __init ifx_ptm_test_init(void)
+{
+ proc_file_create();
+
+ return 0;
+}
+
+static void __exit ifx_ptm_test_exit(void)
+{
+ proc_file_delete();
+}
+
+module_init(ifx_ptm_test_init);
+module_exit(ifx_ptm_test_exit);
+
+#endif
diff --git a/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_vdsl.c.svn-base b/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_vdsl.c.svn-base
new file mode 100644
index 0000000..745eb03
--- /dev/null
+++ b/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_vdsl.c.svn-base
@@ -0,0 +1,1080 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_ptm_vdsl.c
+** PROJECT : UEIP
+** MODULES : PTM
+**
+** DATE : 7 Jul 2009
+** AUTHOR : Xu Liang
+** DESCRIPTION : PTM driver common source file (core functions for VR9)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 07 JUL 2009 Xu Liang Init Version
+*******************************************************************************/
+
+#include <linux/version.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/ctype.h>
+#include <linux/errno.h>
+#include <linux/proc_fs.h>
+#include <linux/init.h>
+#include <linux/ioctl.h>
+#include <linux/etherdevice.h>
+#include <linux/interrupt.h>
+
+#include "ifxmips_ptm_vdsl.h"
+#include <lantiq_soc.h>
+
+#define MODULE_PARM_ARRAY(a, b) module_param_array(a, int, NULL, 0)
+#define MODULE_PARM(a, b) module_param(a, int, 0)
+
+static int wanqos_en = 0;
+static int queue_gamma_map[4] = {0xFE, 0x01, 0x00, 0x00};
+
+MODULE_PARM(wanqos_en, "i");
+MODULE_PARM_DESC(wanqos_en, "WAN QoS support, 1 - enabled, 0 - disabled.");
+
+MODULE_PARM_ARRAY(queue_gamma_map, "4-4i");
+MODULE_PARM_DESC(queue_gamma_map, "TX QoS queues mapping to 4 TX Gamma interfaces.");
+
+extern int (*ifx_mei_atm_showtime_enter)(struct port_cell_info *, void *);
+extern int (*ifx_mei_atm_showtime_exit)(void);
+extern int ifx_mei_atm_showtime_check(int *is_showtime, struct port_cell_info *port_cell, void **xdata_addr);
+
+static int g_showtime = 0;
+static void *g_xdata_addr = NULL;
+
+
+#define ENABLE_TMP_DBG 0
+
+unsigned long cgu_get_pp32_clock(void)
+{
+ struct clk *c = clk_get_ppe();
+ unsigned long rate = clk_get_rate(c);
+ clk_put(c);
+ return rate;
+}
+
+static void ptm_setup(struct net_device *, int);
+static struct net_device_stats *ptm_get_stats(struct net_device *);
+static int ptm_open(struct net_device *);
+static int ptm_stop(struct net_device *);
+ static unsigned int ptm_poll(int, unsigned int);
+ static int ptm_napi_poll(struct napi_struct *, int);
+static int ptm_hard_start_xmit(struct sk_buff *, struct net_device *);
+static int ptm_ioctl(struct net_device *, struct ifreq *, int);
+static void ptm_tx_timeout(struct net_device *);
+
+static inline struct sk_buff* alloc_skb_rx(void);
+static inline struct sk_buff* alloc_skb_tx(unsigned int);
+static inline struct sk_buff *get_skb_pointer(unsigned int);
+static inline int get_tx_desc(unsigned int, unsigned int *);
+
+/*
+ * Mailbox handler and signal function
+ */
+static irqreturn_t mailbox_irq_handler(int, void *);
+
+/*
+ * Tasklet to Handle Swap Descriptors
+ */
+static void do_swap_desc_tasklet(unsigned long);
+
+
+/*
+ * Init & clean-up functions
+ */
+static inline int init_priv_data(void);
+static inline void clear_priv_data(void);
+static inline int init_tables(void);
+static inline void clear_tables(void);
+
+static int g_wanqos_en = 0;
+
+static int g_queue_gamma_map[4];
+
+static struct ptm_priv_data g_ptm_priv_data;
+
+static struct net_device_ops g_ptm_netdev_ops = {
+ .ndo_get_stats = ptm_get_stats,
+ .ndo_open = ptm_open,
+ .ndo_stop = ptm_stop,
+ .ndo_start_xmit = ptm_hard_start_xmit,
+ .ndo_validate_addr = eth_validate_addr,
+ .ndo_set_mac_address = eth_mac_addr,
+ .ndo_change_mtu = eth_change_mtu,
+ .ndo_do_ioctl = ptm_ioctl,
+ .ndo_tx_timeout = ptm_tx_timeout,
+};
+
+static struct net_device *g_net_dev[1] = {0};
+static char *g_net_dev_name[1] = {"ptm0"};
+
+static int g_ptm_prio_queue_map[8];
+
+static DECLARE_TASKLET(g_swap_desc_tasklet, do_swap_desc_tasklet, 0);
+
+
+unsigned int ifx_ptm_dbg_enable = DBG_ENABLE_MASK_ERR;
+
+/*
+ * ####################################
+ * Local Function
+ * ####################################
+ */
+
+static void ptm_setup(struct net_device *dev, int ndev)
+{
+ dev->netdev_ops = &g_ptm_netdev_ops;
+ netif_napi_add(dev, &g_ptm_priv_data.itf[ndev].napi, ptm_napi_poll, 16);
+ dev->watchdog_timeo = ETH_WATCHDOG_TIMEOUT;
+
+ dev->dev_addr[0] = 0x00;
+ dev->dev_addr[1] = 0x20;
+ dev->dev_addr[2] = 0xda;
+ dev->dev_addr[3] = 0x86;
+ dev->dev_addr[4] = 0x23;
+ dev->dev_addr[5] = 0x75 + ndev;
+}
+
+static struct net_device_stats *ptm_get_stats(struct net_device *dev)
+{
+ struct net_device_stats *s;
+
+ if ( dev != g_net_dev[0] )
+ return NULL;
+s = &g_ptm_priv_data.itf[0].stats;
+
+ return s;
+}
+
+static int ptm_open(struct net_device *dev)
+{
+ ASSERT(dev == g_net_dev[0], "incorrect device");
+
+ napi_enable(&g_ptm_priv_data.itf[0].napi);
+
+ IFX_REG_W32_MASK(0, 1, MBOX_IGU1_IER);
+
+ netif_start_queue(dev);
+
+ return 0;
+}
+
+static int ptm_stop(struct net_device *dev)
+{
+ ASSERT(dev == g_net_dev[0], "incorrect device");
+
+ IFX_REG_W32_MASK(1 | (1 << 17), 0, MBOX_IGU1_IER);
+
+ napi_disable(&g_ptm_priv_data.itf[0].napi);
+
+ netif_stop_queue(dev);
+
+ return 0;
+}
+
+static unsigned int ptm_poll(int ndev, unsigned int work_to_do)
+{
+ unsigned int work_done = 0;
+ volatile struct rx_descriptor *desc;
+ struct rx_descriptor reg_desc;
+ struct sk_buff *skb, *new_skb;
+
+ ASSERT(ndev >= 0 && ndev < ARRAY_SIZE(g_net_dev), "ndev = %d (wrong value)", ndev);
+
+ while ( work_done < work_to_do ) {
+ desc = &WAN_RX_DESC_BASE[g_ptm_priv_data.itf[0].rx_desc_pos];
+ if ( desc->own /* || !desc->c */ ) // if PP32 hold descriptor or descriptor not completed
+ break;
+ if ( ++g_ptm_priv_data.itf[0].rx_desc_pos == WAN_RX_DESC_NUM )
+ g_ptm_priv_data.itf[0].rx_desc_pos = 0;
+
+ reg_desc = *desc;
+ skb = get_skb_pointer(reg_desc.dataptr);
+ ASSERT(skb != NULL, "invalid pointer skb == NULL");
+
+ new_skb = alloc_skb_rx();
+ if ( new_skb != NULL ) {
+ skb_reserve(skb, reg_desc.byteoff);
+ skb_put(skb, reg_desc.datalen);
+
+ // parse protocol header
+ skb->dev = g_net_dev[0];
+ skb->protocol = eth_type_trans(skb, skb->dev);
+
+ g_net_dev[0]->last_rx = jiffies;
+
+ netif_receive_skb(skb);
+
+ g_ptm_priv_data.itf[0].stats.rx_packets++;
+ g_ptm_priv_data.itf[0].stats.rx_bytes += reg_desc.datalen;
+
+ reg_desc.dataptr = (unsigned int)new_skb->data & 0x0FFFFFFF;
+ reg_desc.byteoff = RX_HEAD_MAC_ADDR_ALIGNMENT;
+ }
+
+ reg_desc.datalen = RX_MAX_BUFFER_SIZE - RX_HEAD_MAC_ADDR_ALIGNMENT;
+ reg_desc.own = 1;
+ reg_desc.c = 0;
+
+ /* write discriptor to memory */
+ *((volatile unsigned int *)desc + 1) = *((unsigned int *)&reg_desc + 1);
+ wmb();
+ *(volatile unsigned int *)desc = *(unsigned int *)&reg_desc;
+
+ work_done++;
+ }
+
+ return work_done;
+}
+
+static int ptm_napi_poll(struct napi_struct *napi, int budget)
+{
+ int ndev = 0;
+ unsigned int work_done;
+
+ work_done = ptm_poll(ndev, budget);
+
+ // interface down
+ if ( !netif_running(napi->dev) ) {
+ napi_complete(napi);
+ return work_done;
+ }
+
+ // clear interrupt
+ IFX_REG_W32_MASK(0, 1, MBOX_IGU1_ISRC);
+ // no more traffic
+ if ( WAN_RX_DESC_BASE[g_ptm_priv_data.itf[0].rx_desc_pos].own ) { // if PP32 hold descriptor
+ napi_complete(napi);
+ IFX_REG_W32_MASK(0, 1, MBOX_IGU1_IER);
+ return work_done;
+ }
+
+ // next round
+ return work_done;
+}
+
+static int ptm_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
+{
+ unsigned int f_full;
+ int desc_base;
+ volatile struct tx_descriptor *desc;
+ struct tx_descriptor reg_desc = {0};
+ struct sk_buff *skb_to_free;
+ unsigned int byteoff;
+
+ ASSERT(dev == g_net_dev[0], "incorrect device");
+
+ if ( !g_showtime ) {
+ err("not in showtime");
+ goto PTM_HARD_START_XMIT_FAIL;
+ }
+
+ /* allocate descriptor */
+ desc_base = get_tx_desc(0, &f_full);
+ if ( f_full ) {
+ dev->trans_start = jiffies;
+ netif_stop_queue(dev);
+
+ IFX_REG_W32_MASK(0, 1 << 17, MBOX_IGU1_ISRC);
+ IFX_REG_W32_MASK(0, 1 << 17, MBOX_IGU1_IER);
+ }
+ if ( desc_base < 0 )
+ goto PTM_HARD_START_XMIT_FAIL;
+ desc = &CPU_TO_WAN_TX_DESC_BASE[desc_base];
+
+ byteoff = (unsigned int)skb->data & (DATA_BUFFER_ALIGNMENT - 1);
+ if ( skb_headroom(skb) < sizeof(struct sk_buff *) + byteoff || skb_cloned(skb) ) {
+ struct sk_buff *new_skb;
+
+ ASSERT(skb_headroom(skb) >= sizeof(struct sk_buff *) + byteoff, "skb_headroom(skb) < sizeof(struct sk_buff *) + byteoff");
+ ASSERT(!skb_cloned(skb), "skb is cloned");
+
+ new_skb = alloc_skb_tx(skb->len);
+ if ( new_skb == NULL ) {
+ dbg("no memory");
+ goto ALLOC_SKB_TX_FAIL;
+ }
+ skb_put(new_skb, skb->len);
+ memcpy(new_skb->data, skb->data, skb->len);
+ dev_kfree_skb_any(skb);
+ skb = new_skb;
+ byteoff = (unsigned int)skb->data & (DATA_BUFFER_ALIGNMENT - 1);
+ /* write back to physical memory */
+ dma_cache_wback((unsigned long)skb->data, skb->len);
+ }
+
+ *(struct sk_buff **)((unsigned int)skb->data - byteoff - sizeof(struct sk_buff *)) = skb;
+ /* write back to physical memory */
+ dma_cache_wback((unsigned long)skb->data - byteoff - sizeof(struct sk_buff *), skb->len + byteoff + sizeof(struct sk_buff *));
+
+ /* free previous skb */
+ skb_to_free = get_skb_pointer(desc->dataptr);
+ if ( skb_to_free != NULL )
+ dev_kfree_skb_any(skb_to_free);
+
+ /* update descriptor */
+ reg_desc.small = 0;
+ reg_desc.dataptr = (unsigned int)skb->data & (0x0FFFFFFF ^ (DATA_BUFFER_ALIGNMENT - 1));
+ reg_desc.datalen = skb->len < ETH_ZLEN ? ETH_ZLEN : skb->len;
+ reg_desc.qid = g_ptm_prio_queue_map[skb->priority > 7 ? 7 : skb->priority];
+ reg_desc.byteoff = byteoff;
+ reg_desc.own = 1;
+ reg_desc.c = 1;
+ reg_desc.sop = reg_desc.eop = 1;
+
+ /* update MIB */
+ g_ptm_priv_data.itf[0].stats.tx_packets++;
+ g_ptm_priv_data.itf[0].stats.tx_bytes += reg_desc.datalen;
+
+ /* write discriptor to memory */
+ *((volatile unsigned int *)desc + 1) = *((unsigned int *)&reg_desc + 1);
+ wmb();
+ *(volatile unsigned int *)desc = *(unsigned int *)&reg_desc;
+
+ dev->trans_start = jiffies;
+
+ return 0;
+
+ALLOC_SKB_TX_FAIL:
+PTM_HARD_START_XMIT_FAIL:
+ dev_kfree_skb_any(skb);
+ g_ptm_priv_data.itf[0].stats.tx_dropped++;
+ return 0;
+}
+
+static int ptm_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
+{
+ ASSERT(dev == g_net_dev[0], "incorrect device");
+
+ switch ( cmd )
+ {
+ case IFX_PTM_MIB_CW_GET:
+ ((PTM_CW_IF_ENTRY_T *)ifr->ifr_data)->ifRxNoIdleCodewords = IFX_REG_R32(DREG_AR_CELL0) + IFX_REG_R32(DREG_AR_CELL1);
+ ((PTM_CW_IF_ENTRY_T *)ifr->ifr_data)->ifRxIdleCodewords = IFX_REG_R32(DREG_AR_IDLE_CNT0) + IFX_REG_R32(DREG_AR_IDLE_CNT1);
+ ((PTM_CW_IF_ENTRY_T *)ifr->ifr_data)->ifRxCodingViolation = IFX_REG_R32(DREG_AR_CVN_CNT0) + IFX_REG_R32(DREG_AR_CVN_CNT1) + IFX_REG_R32(DREG_AR_CVNP_CNT0) + IFX_REG_R32(DREG_AR_CVNP_CNT1);
+ ((PTM_CW_IF_ENTRY_T *)ifr->ifr_data)->ifTxNoIdleCodewords = IFX_REG_R32(DREG_AT_CELL0) + IFX_REG_R32(DREG_AT_CELL1);
+ ((PTM_CW_IF_ENTRY_T *)ifr->ifr_data)->ifTxIdleCodewords = IFX_REG_R32(DREG_AT_IDLE_CNT0) + IFX_REG_R32(DREG_AT_IDLE_CNT1);
+ break;
+ case IFX_PTM_MIB_FRAME_GET:
+ {
+ PTM_FRAME_MIB_T data = {0};
+ int i;
+
+ data.RxCorrect = IFX_REG_R32(DREG_AR_HEC_CNT0) + IFX_REG_R32(DREG_AR_HEC_CNT1) + IFX_REG_R32(DREG_AR_AIIDLE_CNT0) + IFX_REG_R32(DREG_AR_AIIDLE_CNT1);
+ for ( i = 0; i < 4; i++ )
+ data.RxDropped += WAN_RX_MIB_TABLE(i)->wrx_dropdes_pdu;
+ for ( i = 0; i < 8; i++ )
+ data.TxSend += WAN_TX_MIB_TABLE(i)->wtx_total_pdu;
+
+ *((PTM_FRAME_MIB_T *)ifr->ifr_data) = data;
+ }
+ break;
+ case IFX_PTM_CFG_GET:
+ // use bear channel 0 preemption gamma interface settings
+ ((IFX_PTM_CFG_T *)ifr->ifr_data)->RxEthCrcPresent = 1;
+ ((IFX_PTM_CFG_T *)ifr->ifr_data)->RxEthCrcCheck = RX_GAMMA_ITF_CFG(0)->rx_eth_fcs_ver_dis == 0 ? 1 : 0;
+ ((IFX_PTM_CFG_T *)ifr->ifr_data)->RxTcCrcCheck = RX_GAMMA_ITF_CFG(0)->rx_tc_crc_ver_dis == 0 ? 1 : 0;;
+ ((IFX_PTM_CFG_T *)ifr->ifr_data)->RxTcCrcLen = RX_GAMMA_ITF_CFG(0)->rx_tc_crc_size == 0 ? 0 : (RX_GAMMA_ITF_CFG(0)->rx_tc_crc_size * 16);
+ ((IFX_PTM_CFG_T *)ifr->ifr_data)->TxEthCrcGen = TX_GAMMA_ITF_CFG(0)->tx_eth_fcs_gen_dis == 0 ? 1 : 0;
+ ((IFX_PTM_CFG_T *)ifr->ifr_data)->TxTcCrcGen = TX_GAMMA_ITF_CFG(0)->tx_tc_crc_size == 0 ? 0 : 1;
+ ((IFX_PTM_CFG_T *)ifr->ifr_data)->TxTcCrcLen = TX_GAMMA_ITF_CFG(0)->tx_tc_crc_size == 0 ? 0 : (TX_GAMMA_ITF_CFG(0)->tx_tc_crc_size * 16);
+ break;
+ case IFX_PTM_CFG_SET:
+ {
+ int i;
+
+ for ( i = 0; i < 4; i++ ) {
+ RX_GAMMA_ITF_CFG(i)->rx_eth_fcs_ver_dis = ((IFX_PTM_CFG_T *)ifr->ifr_data)->RxEthCrcCheck ? 0 : 1;
+
+ RX_GAMMA_ITF_CFG(0)->rx_tc_crc_ver_dis = ((IFX_PTM_CFG_T *)ifr->ifr_data)->RxTcCrcCheck ? 0 : 1;
+
+ switch ( ((IFX_PTM_CFG_T *)ifr->ifr_data)->RxTcCrcLen ) {
+ case 16: RX_GAMMA_ITF_CFG(0)->rx_tc_crc_size = 1; break;
+ case 32: RX_GAMMA_ITF_CFG(0)->rx_tc_crc_size = 2; break;
+ default: RX_GAMMA_ITF_CFG(0)->rx_tc_crc_size = 0;
+ }
+
+ TX_GAMMA_ITF_CFG(0)->tx_eth_fcs_gen_dis = ((IFX_PTM_CFG_T *)ifr->ifr_data)->TxEthCrcGen ? 0 : 1;
+
+ if ( ((IFX_PTM_CFG_T *)ifr->ifr_data)->TxTcCrcGen ) {
+ switch ( ((IFX_PTM_CFG_T *)ifr->ifr_data)->TxTcCrcLen ) {
+ case 16: TX_GAMMA_ITF_CFG(0)->tx_tc_crc_size = 1; break;
+ case 32: TX_GAMMA_ITF_CFG(0)->tx_tc_crc_size = 2; break;
+ default: TX_GAMMA_ITF_CFG(0)->tx_tc_crc_size = 0;
+ }
+ }
+ else
+ TX_GAMMA_ITF_CFG(0)->tx_tc_crc_size = 0;
+ }
+ }
+ break;
+ case IFX_PTM_MAP_PKT_PRIO_TO_Q:
+ {
+ struct ppe_prio_q_map cmd;
+
+ if ( copy_from_user(&cmd, ifr->ifr_data, sizeof(cmd)) )
+ return -EFAULT;
+
+ if ( cmd.pkt_prio < 0 || cmd.pkt_prio >= ARRAY_SIZE(g_ptm_prio_queue_map) )
+ return -EINVAL;
+
+ if ( cmd.qid < 0 || cmd.qid >= g_wanqos_en )
+ return -EINVAL;
+
+ g_ptm_prio_queue_map[cmd.pkt_prio] = cmd.qid;
+ }
+ break;
+ default:
+ return -EOPNOTSUPP;
+ }
+
+ return 0;
+}
+
+static void ptm_tx_timeout(struct net_device *dev)
+{
+ ASSERT(dev == g_net_dev[0], "incorrect device");
+
+ /* disable TX irq, release skb when sending new packet */
+ IFX_REG_W32_MASK(1 << 17, 0, MBOX_IGU1_IER);
+
+ /* wake up TX queue */
+ netif_wake_queue(dev);
+
+ return;
+}
+
+static inline struct sk_buff* alloc_skb_rx(void)
+{
+ struct sk_buff *skb;
+
+ /* allocate memroy including trailer and padding */
+ skb = dev_alloc_skb(RX_MAX_BUFFER_SIZE + DATA_BUFFER_ALIGNMENT);
+ if ( skb != NULL ) {
+ /* must be burst length alignment and reserve two more bytes for MAC address alignment */
+ if ( ((unsigned int)skb->data & (DATA_BUFFER_ALIGNMENT - 1)) != 0 )
+ skb_reserve(skb, ~((unsigned int)skb->data + (DATA_BUFFER_ALIGNMENT - 1)) & (DATA_BUFFER_ALIGNMENT - 1));
+ /* pub skb in reserved area "skb->data - 4" */
+ *((struct sk_buff **)skb->data - 1) = skb;
+ wmb();
+ /* write back and invalidate cache */
+ dma_cache_wback_inv((unsigned long)skb->data - sizeof(skb), sizeof(skb));
+ /* invalidate cache */
+ dma_cache_inv((unsigned long)skb->data, (unsigned int)skb->end - (unsigned int)skb->data);
+ }
+
+ return skb;
+}
+
+static inline struct sk_buff* alloc_skb_tx(unsigned int size)
+{
+ struct sk_buff *skb;
+
+ /* allocate memory including padding */
+ size = RX_MAX_BUFFER_SIZE;
+ size = (size + DATA_BUFFER_ALIGNMENT - 1) & ~(DATA_BUFFER_ALIGNMENT - 1);
+ skb = dev_alloc_skb(size + DATA_BUFFER_ALIGNMENT);
+ /* must be burst length alignment */
+ if ( skb != NULL )
+ skb_reserve(skb, ~((unsigned int)skb->data + (DATA_BUFFER_ALIGNMENT - 1)) & (DATA_BUFFER_ALIGNMENT - 1));
+ return skb;
+}
+
+static inline struct sk_buff *get_skb_pointer(unsigned int dataptr)
+{
+ unsigned int skb_dataptr;
+ struct sk_buff *skb;
+
+ // usually, CPE memory is less than 256M bytes
+ // so NULL means invalid pointer
+ if ( dataptr == 0 ) {
+ dbg("dataptr is 0, it's supposed to be invalid pointer");
+ return NULL;
+ }
+
+ skb_dataptr = (dataptr - 4) | KSEG1;
+ skb = *(struct sk_buff **)skb_dataptr;
+
+ ASSERT((unsigned int)skb >= KSEG0, "invalid skb - skb = %#08x, dataptr = %#08x", (unsigned int)skb, dataptr);
+ ASSERT((((unsigned int)skb->data & (0x0FFFFFFF ^ (DATA_BUFFER_ALIGNMENT - 1))) | KSEG1) == (dataptr | KSEG1), "invalid skb - skb = %#08x, skb->data = %#08x, dataptr = %#08x", (unsigned int)skb, (unsigned int)skb->data, dataptr);
+
+ return skb;
+}
+
+static inline int get_tx_desc(unsigned int itf, unsigned int *f_full)
+{
+ int desc_base = -1;
+ struct ptm_itf *p_itf = &g_ptm_priv_data.itf[0];
+
+ // assume TX is serial operation
+ // no protection provided
+
+ *f_full = 1;
+
+ if ( CPU_TO_WAN_TX_DESC_BASE[p_itf->tx_desc_pos].own == 0 ) {
+ desc_base = p_itf->tx_desc_pos;
+ if ( ++(p_itf->tx_desc_pos) == CPU_TO_WAN_TX_DESC_NUM )
+ p_itf->tx_desc_pos = 0;
+ if ( CPU_TO_WAN_TX_DESC_BASE[p_itf->tx_desc_pos].own == 0 )
+ *f_full = 0;
+ }
+
+ return desc_base;
+}
+
+static irqreturn_t mailbox_irq_handler(int irq, void *dev_id)
+{
+ unsigned int isr;
+ int i;
+
+ isr = IFX_REG_R32(MBOX_IGU1_ISR);
+ IFX_REG_W32(isr, MBOX_IGU1_ISRC);
+ isr &= IFX_REG_R32(MBOX_IGU1_IER);
+
+ if (isr & BIT(0)) {
+ IFX_REG_W32_MASK(1, 0, MBOX_IGU1_IER);
+ napi_schedule(&g_ptm_priv_data.itf[0].napi);
+#if defined(ENABLE_TMP_DBG) && ENABLE_TMP_DBG
+ {
+ volatile struct rx_descriptor *desc = &WAN_RX_DESC_BASE[g_ptm_priv_data.itf[0].rx_desc_pos];
+
+ if ( desc->own ) { // PP32 hold
+ err("invalid interrupt");
+ }
+ }
+#endif
+ }
+ if (isr & BIT(16)) {
+ IFX_REG_W32_MASK(1 << 16, 0, MBOX_IGU1_IER);
+ tasklet_hi_schedule(&g_swap_desc_tasklet);
+ }
+ if (isr & BIT(17)) {
+ IFX_REG_W32_MASK(1 << 17, 0, MBOX_IGU1_IER);
+ netif_wake_queue(g_net_dev[0]);
+ }
+
+ return IRQ_HANDLED;
+}
+
+static void do_swap_desc_tasklet(unsigned long arg)
+{
+ int budget = 32;
+ volatile struct tx_descriptor *desc;
+ struct sk_buff *skb;
+ unsigned int byteoff;
+
+ while ( budget-- > 0 ) {
+ if ( WAN_SWAP_DESC_BASE[g_ptm_priv_data.itf[0].tx_swap_desc_pos].own ) // if PP32 hold descriptor
+ break;
+
+ desc = &WAN_SWAP_DESC_BASE[g_ptm_priv_data.itf[0].tx_swap_desc_pos];
+ if ( ++g_ptm_priv_data.itf[0].tx_swap_desc_pos == WAN_SWAP_DESC_NUM )
+ g_ptm_priv_data.itf[0].tx_swap_desc_pos = 0;
+
+ skb = get_skb_pointer(desc->dataptr);
+ if ( skb != NULL )
+ dev_kfree_skb_any(skb);
+
+ skb = alloc_skb_tx(RX_MAX_BUFFER_SIZE);
+ if ( skb == NULL )
+ panic("can't allocate swap buffer for PPE firmware use\n");
+ byteoff = (unsigned int)skb->data & (DATA_BUFFER_ALIGNMENT - 1);
+ *(struct sk_buff **)((unsigned int)skb->data - byteoff - sizeof(struct sk_buff *)) = skb;
+
+ desc->dataptr = (unsigned int)skb->data & 0x0FFFFFFF;
+ desc->own = 1;
+ }
+
+ // clear interrupt
+ IFX_REG_W32_MASK(0, 16, MBOX_IGU1_ISRC);
+ // no more skb to be replaced
+ if ( WAN_SWAP_DESC_BASE[g_ptm_priv_data.itf[0].tx_swap_desc_pos].own ) { // if PP32 hold descriptor
+ IFX_REG_W32_MASK(0, 1 << 16, MBOX_IGU1_IER);
+ return;
+ }
+
+ tasklet_hi_schedule(&g_swap_desc_tasklet);
+ return;
+}
+
+
+static inline int ifx_ptm_version(char *buf)
+{
+ int len = 0;
+ unsigned int major, minor;
+
+ ifx_ptm_get_fw_ver(&major, &minor);
+
+ len += sprintf(buf + len, "PTM %d.%d.%d", IFX_PTM_VER_MAJOR, IFX_PTM_VER_MID, IFX_PTM_VER_MINOR);
+ len += sprintf(buf + len, " PTM (E1) firmware version %d.%d\n", major, minor);
+
+ return len;
+}
+
+static inline int init_priv_data(void)
+{
+ int i, j;
+
+ g_wanqos_en = wanqos_en ? wanqos_en : 8;
+ if ( g_wanqos_en > 8 )
+ g_wanqos_en = 8;
+
+ for ( i = 0; i < ARRAY_SIZE(g_queue_gamma_map); i++ )
+ {
+ g_queue_gamma_map[i] = queue_gamma_map[i] & ((1 << g_wanqos_en) - 1);
+ for ( j = 0; j < i; j++ )
+ g_queue_gamma_map[i] &= ~g_queue_gamma_map[j];
+ }
+
+ memset(&g_ptm_priv_data, 0, sizeof(g_ptm_priv_data));
+
+ {
+ int max_packet_priority = ARRAY_SIZE(g_ptm_prio_queue_map);
+ int tx_num_q;
+ int q_step, q_accum, p_step;
+
+ tx_num_q = __ETH_WAN_TX_QUEUE_NUM;
+ q_step = tx_num_q - 1;
+ p_step = max_packet_priority - 1;
+ for ( j = 0, q_accum = 0; j < max_packet_priority; j++, q_accum += q_step )
+ g_ptm_prio_queue_map[j] = q_step - (q_accum + (p_step >> 1)) / p_step;
+ }
+
+ return 0;
+}
+
+static inline void clear_priv_data(void)
+{
+}
+
+static inline int init_tables(void)
+{
+ struct sk_buff *skb_pool[WAN_RX_DESC_NUM] = {0};
+ struct cfg_std_data_len cfg_std_data_len = {0};
+ struct tx_qos_cfg tx_qos_cfg = {0};
+ struct psave_cfg psave_cfg = {0};
+ struct eg_bwctrl_cfg eg_bwctrl_cfg = {0};
+ struct test_mode test_mode = {0};
+ struct rx_bc_cfg rx_bc_cfg = {0};
+ struct tx_bc_cfg tx_bc_cfg = {0};
+ struct gpio_mode gpio_mode = {0};
+ struct gpio_wm_cfg gpio_wm_cfg = {0};
+ struct rx_gamma_itf_cfg rx_gamma_itf_cfg = {0};
+ struct tx_gamma_itf_cfg tx_gamma_itf_cfg = {0};
+ struct wtx_qos_q_desc_cfg wtx_qos_q_desc_cfg = {0};
+ struct rx_descriptor rx_desc = {0};
+ struct tx_descriptor tx_desc = {0};
+ int i;
+
+ for ( i = 0; i < WAN_RX_DESC_NUM; i++ ) {
+ skb_pool[i] = alloc_skb_rx();
+ if ( skb_pool[i] == NULL )
+ goto ALLOC_SKB_RX_FAIL;
+ }
+
+ cfg_std_data_len.byte_off = RX_HEAD_MAC_ADDR_ALIGNMENT; // this field replaces byte_off in rx descriptor of VDSL ingress
+ cfg_std_data_len.data_len = 1600;
+ *CFG_STD_DATA_LEN = cfg_std_data_len;
+
+ tx_qos_cfg.time_tick = cgu_get_pp32_clock() / 62500; // 16 * (cgu_get_pp32_clock() / 1000000)
+ tx_qos_cfg.overhd_bytes = 0;
+ tx_qos_cfg.eth1_eg_qnum = __ETH_WAN_TX_QUEUE_NUM;
+ tx_qos_cfg.eth1_burst_chk = 1;
+ tx_qos_cfg.eth1_qss = 0;
+ tx_qos_cfg.shape_en = 0; // disable
+ tx_qos_cfg.wfq_en = 0; // strict priority
+ *TX_QOS_CFG = tx_qos_cfg;
+
+ psave_cfg.start_state = 0;
+ psave_cfg.sleep_en = 1; // enable sleep mode
+ *PSAVE_CFG = psave_cfg;
+
+ eg_bwctrl_cfg.fdesc_wm = 16;
+ eg_bwctrl_cfg.class_len = 128;
+ *EG_BWCTRL_CFG = eg_bwctrl_cfg;
+
+ //*GPIO_ADDR = (unsigned int)IFX_GPIO_P0_OUT;
+ *GPIO_ADDR = (unsigned int)0x00000000; // disabled by default
+
+ gpio_mode.gpio_bit_bc1 = 2;
+ gpio_mode.gpio_bit_bc0 = 1;
+ gpio_mode.gpio_bc1_en = 0;
+ gpio_mode.gpio_bc0_en = 0;
+ *GPIO_MODE = gpio_mode;
+
+ gpio_wm_cfg.stop_wm_bc1 = 2;
+ gpio_wm_cfg.start_wm_bc1 = 4;
+ gpio_wm_cfg.stop_wm_bc0 = 2;
+ gpio_wm_cfg.start_wm_bc0 = 4;
+ *GPIO_WM_CFG = gpio_wm_cfg;
+
+ test_mode.mib_clear_mode = 0;
+ test_mode.test_mode = 0;
+ *TEST_MODE = test_mode;
+
+ rx_bc_cfg.local_state = 0;
+ rx_bc_cfg.remote_state = 0;
+ rx_bc_cfg.to_false_th = 7;
+ rx_bc_cfg.to_looking_th = 3;
+ *RX_BC_CFG(0) = rx_bc_cfg;
+ *RX_BC_CFG(1) = rx_bc_cfg;
+
+ tx_bc_cfg.fill_wm = 2;
+ tx_bc_cfg.uflw_wm = 2;
+ *TX_BC_CFG(0) = tx_bc_cfg;
+ *TX_BC_CFG(1) = tx_bc_cfg;
+
+ rx_gamma_itf_cfg.receive_state = 0;
+ rx_gamma_itf_cfg.rx_min_len = 60;
+ rx_gamma_itf_cfg.rx_pad_en = 1;
+ rx_gamma_itf_cfg.rx_eth_fcs_ver_dis = 0;
+ rx_gamma_itf_cfg.rx_rm_eth_fcs = 1;
+ rx_gamma_itf_cfg.rx_tc_crc_ver_dis = 0;
+ rx_gamma_itf_cfg.rx_tc_crc_size = 1;
+ rx_gamma_itf_cfg.rx_eth_fcs_result = 0xC704DD7B;
+ rx_gamma_itf_cfg.rx_tc_crc_result = 0x1D0F1D0F;
+ rx_gamma_itf_cfg.rx_crc_cfg = 0x2500;
+ rx_gamma_itf_cfg.rx_eth_fcs_init_value = 0xFFFFFFFF;
+ rx_gamma_itf_cfg.rx_tc_crc_init_value = 0x0000FFFF;
+ rx_gamma_itf_cfg.rx_max_len_sel = 0;
+ rx_gamma_itf_cfg.rx_edit_num2 = 0;
+ rx_gamma_itf_cfg.rx_edit_pos2 = 0;
+ rx_gamma_itf_cfg.rx_edit_type2 = 0;
+ rx_gamma_itf_cfg.rx_edit_en2 = 0;
+ rx_gamma_itf_cfg.rx_edit_num1 = 0;
+ rx_gamma_itf_cfg.rx_edit_pos1 = 0;
+ rx_gamma_itf_cfg.rx_edit_type1 = 0;
+ rx_gamma_itf_cfg.rx_edit_en1 = 0;
+ rx_gamma_itf_cfg.rx_inserted_bytes_1l = 0;
+ rx_gamma_itf_cfg.rx_inserted_bytes_1h = 0;
+ rx_gamma_itf_cfg.rx_inserted_bytes_2l = 0;
+ rx_gamma_itf_cfg.rx_inserted_bytes_2h = 0;
+ rx_gamma_itf_cfg.rx_len_adj = -6;
+ for ( i = 0; i < 4; i++ )
+ *RX_GAMMA_ITF_CFG(i) = rx_gamma_itf_cfg;
+
+ tx_gamma_itf_cfg.tx_len_adj = 6;
+ tx_gamma_itf_cfg.tx_crc_off_adj = 6;
+ tx_gamma_itf_cfg.tx_min_len = 0;
+ tx_gamma_itf_cfg.tx_eth_fcs_gen_dis = 0;
+ tx_gamma_itf_cfg.tx_tc_crc_size = 1;
+ tx_gamma_itf_cfg.tx_crc_cfg = 0x2F00;
+ tx_gamma_itf_cfg.tx_eth_fcs_init_value = 0xFFFFFFFF;
+ tx_gamma_itf_cfg.tx_tc_crc_init_value = 0x0000FFFF;
+ for ( i = 0; i < ARRAY_SIZE(g_queue_gamma_map); i++ ) {
+ tx_gamma_itf_cfg.queue_mapping = g_queue_gamma_map[i];
+ *TX_GAMMA_ITF_CFG(i) = tx_gamma_itf_cfg;
+ }
+
+ for ( i = 0; i < __ETH_WAN_TX_QUEUE_NUM; i++ ) {
+ wtx_qos_q_desc_cfg.length = WAN_TX_DESC_NUM;
+ wtx_qos_q_desc_cfg.addr = __ETH_WAN_TX_DESC_BASE(i);
+ *WTX_QOS_Q_DESC_CFG(i) = wtx_qos_q_desc_cfg;
+ }
+
+ // default TX queue QoS config is all ZERO
+
+ // TX Ctrl K Table
+ IFX_REG_W32(0x90111293, TX_CTRL_K_TABLE(0));
+ IFX_REG_W32(0x14959617, TX_CTRL_K_TABLE(1));
+ IFX_REG_W32(0x18999A1B, TX_CTRL_K_TABLE(2));
+ IFX_REG_W32(0x9C1D1E9F, TX_CTRL_K_TABLE(3));
+ IFX_REG_W32(0xA02122A3, TX_CTRL_K_TABLE(4));
+ IFX_REG_W32(0x24A5A627, TX_CTRL_K_TABLE(5));
+ IFX_REG_W32(0x28A9AA2B, TX_CTRL_K_TABLE(6));
+ IFX_REG_W32(0xAC2D2EAF, TX_CTRL_K_TABLE(7));
+ IFX_REG_W32(0x30B1B233, TX_CTRL_K_TABLE(8));
+ IFX_REG_W32(0xB43536B7, TX_CTRL_K_TABLE(9));
+ IFX_REG_W32(0xB8393ABB, TX_CTRL_K_TABLE(10));
+ IFX_REG_W32(0x3CBDBE3F, TX_CTRL_K_TABLE(11));
+ IFX_REG_W32(0xC04142C3, TX_CTRL_K_TABLE(12));
+ IFX_REG_W32(0x44C5C647, TX_CTRL_K_TABLE(13));
+ IFX_REG_W32(0x48C9CA4B, TX_CTRL_K_TABLE(14));
+ IFX_REG_W32(0xCC4D4ECF, TX_CTRL_K_TABLE(15));
+
+ // init RX descriptor
+ rx_desc.own = 1;
+ rx_desc.c = 0;
+ rx_desc.sop = 1;
+ rx_desc.eop = 1;
+ rx_desc.byteoff = RX_HEAD_MAC_ADDR_ALIGNMENT;
+ rx_desc.datalen = RX_MAX_BUFFER_SIZE - RX_HEAD_MAC_ADDR_ALIGNMENT;
+ for ( i = 0; i < WAN_RX_DESC_NUM; i++ ) {
+ rx_desc.dataptr = (unsigned int)skb_pool[i]->data & 0x0FFFFFFF;
+ WAN_RX_DESC_BASE[i] = rx_desc;
+ }
+
+ // init TX descriptor
+ tx_desc.own = 0;
+ tx_desc.c = 0;
+ tx_desc.sop = 1;
+ tx_desc.eop = 1;
+ tx_desc.byteoff = 0;
+ tx_desc.qid = 0;
+ tx_desc.datalen = 0;
+ tx_desc.small = 0;
+ tx_desc.dataptr = 0;
+ for ( i = 0; i < CPU_TO_WAN_TX_DESC_NUM; i++ )
+ CPU_TO_WAN_TX_DESC_BASE[i] = tx_desc;
+ for ( i = 0; i < WAN_TX_DESC_NUM_TOTAL; i++ )
+ WAN_TX_DESC_BASE(0)[i] = tx_desc;
+
+ // init Swap descriptor
+ for ( i = 0; i < WAN_SWAP_DESC_NUM; i++ )
+ WAN_SWAP_DESC_BASE[i] = tx_desc;
+
+ // init fastpath TX descriptor
+ tx_desc.own = 1;
+ for ( i = 0; i < FASTPATH_TO_WAN_TX_DESC_NUM; i++ )
+ FASTPATH_TO_WAN_TX_DESC_BASE[i] = tx_desc;
+
+ return 0;
+
+ALLOC_SKB_RX_FAIL:
+ while ( i-- > 0 )
+ dev_kfree_skb_any(skb_pool[i]);
+ return -1;
+}
+
+static inline void clear_tables(void)
+{
+ struct sk_buff *skb;
+ int i, j;
+
+ for ( i = 0; i < WAN_RX_DESC_NUM; i++ ) {
+ skb = get_skb_pointer(WAN_RX_DESC_BASE[i].dataptr);
+ if ( skb != NULL )
+ dev_kfree_skb_any(skb);
+ }
+
+ for ( i = 0; i < CPU_TO_WAN_TX_DESC_NUM; i++ ) {
+ skb = get_skb_pointer(CPU_TO_WAN_TX_DESC_BASE[i].dataptr);
+ if ( skb != NULL )
+ dev_kfree_skb_any(skb);
+ }
+
+ for ( j = 0; j < 8; j++ )
+ for ( i = 0; i < WAN_TX_DESC_NUM; i++ ) {
+ skb = get_skb_pointer(WAN_TX_DESC_BASE(j)[i].dataptr);
+ if ( skb != NULL )
+ dev_kfree_skb_any(skb);
+ }
+
+ for ( i = 0; i < WAN_SWAP_DESC_NUM; i++ ) {
+ skb = get_skb_pointer(WAN_SWAP_DESC_BASE[i].dataptr);
+ if ( skb != NULL )
+ dev_kfree_skb_any(skb);
+ }
+
+ for ( i = 0; i < FASTPATH_TO_WAN_TX_DESC_NUM; i++ ) {
+ skb = get_skb_pointer(FASTPATH_TO_WAN_TX_DESC_BASE[i].dataptr);
+ if ( skb != NULL )
+ dev_kfree_skb_any(skb);
+ }
+}
+
+static int ptm_showtime_enter(struct port_cell_info *port_cell, void *xdata_addr)
+{
+ ASSERT(port_cell != NULL, "port_cell is NULL");
+ ASSERT(xdata_addr != NULL, "xdata_addr is NULL");
+
+ // TODO: ReTX set xdata_addr
+ g_xdata_addr = xdata_addr;
+
+ g_showtime = 1;
+
+ IFX_REG_W32(0x0F, UTP_CFG);
+
+ //#ifdef CONFIG_VR9
+ // IFX_REG_W32_MASK(1 << 17, 0, FFSM_CFG0);
+ //#endif
+
+ printk("enter showtime\n");
+
+ return 0;
+}
+
+static int ptm_showtime_exit(void)
+{
+ if ( !g_showtime )
+ return -1;
+
+ //#ifdef CONFIG_VR9
+ // IFX_REG_W32_MASK(0, 1 << 17, FFSM_CFG0);
+ //#endif
+
+ IFX_REG_W32(0x00, UTP_CFG);
+
+ g_showtime = 0;
+
+ // TODO: ReTX clean state
+ g_xdata_addr = NULL;
+
+ printk("leave showtime\n");
+
+ return 0;
+}
+
+
+
+static int ifx_ptm_init(void)
+{
+ int ret;
+ int i;
+ char ver_str[128];
+ struct port_cell_info port_cell = {0};
+
+ ret = init_priv_data();
+ if ( ret != 0 ) {
+ err("INIT_PRIV_DATA_FAIL");
+ goto INIT_PRIV_DATA_FAIL;
+ }
+
+ ifx_ptm_init_chip();
+ ret = init_tables();
+ if ( ret != 0 ) {
+ err("INIT_TABLES_FAIL");
+ goto INIT_TABLES_FAIL;
+ }
+
+ for ( i = 0; i < ARRAY_SIZE(g_net_dev); i++ ) {
+ g_net_dev[i] = alloc_netdev(0, g_net_dev_name[i], ether_setup);
+ if ( g_net_dev[i] == NULL )
+ goto ALLOC_NETDEV_FAIL;
+ ptm_setup(g_net_dev[i], i);
+ }
+
+ for ( i = 0; i < ARRAY_SIZE(g_net_dev); i++ ) {
+ ret = register_netdev(g_net_dev[i]);
+ if ( ret != 0 )
+ goto REGISTER_NETDEV_FAIL;
+ }
+
+ /* register interrupt handler */
+ ret = request_irq(PPE_MAILBOX_IGU1_INT, mailbox_irq_handler, IRQF_DISABLED, "ptm_mailbox_isr", &g_ptm_priv_data);
+ if ( ret ) {
+ if ( ret == -EBUSY ) {
+ err("IRQ may be occupied by other driver, please reconfig to disable it.");
+ }
+ else {
+ err("request_irq fail");
+ }
+ goto REQUEST_IRQ_PPE_MAILBOX_IGU1_INT_FAIL;
+ }
+ disable_irq(PPE_MAILBOX_IGU1_INT);
+
+ ret = ifx_pp32_start(0);
+ if ( ret ) {
+ err("ifx_pp32_start fail!");
+ goto PP32_START_FAIL;
+ }
+ IFX_REG_W32(1 << 16, MBOX_IGU1_IER); // enable SWAP interrupt
+ IFX_REG_W32(~0, MBOX_IGU1_ISRC);
+
+ enable_irq(PPE_MAILBOX_IGU1_INT);
+
+ ifx_mei_atm_showtime_check(&g_showtime, &port_cell, &g_xdata_addr);
+
+ ifx_mei_atm_showtime_enter = ptm_showtime_enter;
+ ifx_mei_atm_showtime_exit = ptm_showtime_exit;
+
+ ifx_ptm_version(ver_str);
+ printk(KERN_INFO "%s", ver_str);
+
+ printk("ifxmips_ptm: PTM init succeed\n");
+
+ return 0;
+
+PP32_START_FAIL:
+ free_irq(PPE_MAILBOX_IGU1_INT, &g_ptm_priv_data);
+REQUEST_IRQ_PPE_MAILBOX_IGU1_INT_FAIL:
+ i = ARRAY_SIZE(g_net_dev);
+REGISTER_NETDEV_FAIL:
+ while ( i-- )
+ unregister_netdev(g_net_dev[i]);
+ i = ARRAY_SIZE(g_net_dev);
+ALLOC_NETDEV_FAIL:
+ while ( i-- ) {
+ free_netdev(g_net_dev[i]);
+ g_net_dev[i] = NULL;
+ }
+INIT_TABLES_FAIL:
+INIT_PRIV_DATA_FAIL:
+ clear_priv_data();
+ printk("ifxmips_ptm: PTM init failed\n");
+ return ret;
+}
+
+static void __exit ifx_ptm_exit(void)
+{
+ int i;
+ ifx_mei_atm_showtime_enter = NULL;
+ ifx_mei_atm_showtime_exit = NULL;
+
+
+ ifx_pp32_stop(0);
+
+ free_irq(PPE_MAILBOX_IGU1_INT, &g_ptm_priv_data);
+
+ for ( i = 0; i < ARRAY_SIZE(g_net_dev); i++ )
+ unregister_netdev(g_net_dev[i]);
+
+ for ( i = 0; i < ARRAY_SIZE(g_net_dev); i++ ) {
+ free_netdev(g_net_dev[i]);
+ g_net_dev[i] = NULL;
+ }
+
+ clear_tables();
+
+ ifx_ptm_uninit_chip();
+
+ clear_priv_data();
+}
+
+#ifndef MODULE
+static int __init wanqos_en_setup(char *line)
+{
+ wanqos_en = simple_strtoul(line, NULL, 0);
+
+ if ( wanqos_en < 1 || wanqos_en > 8 )
+ wanqos_en = 0;
+
+ return 0;
+}
+
+static int __init queue_gamma_map_setup(char *line)
+{
+ char *p;
+ int i;
+
+ for ( i = 0, p = line; i < ARRAY_SIZE(queue_gamma_map) && isxdigit(*p); i++ )
+ {
+ queue_gamma_map[i] = simple_strtoul(p, &p, 0);
+ if ( *p == ',' || *p == ';' || *p == ':' )
+ p++;
+ }
+
+ return 0;
+}
+#endif
+module_init(ifx_ptm_init);
+module_exit(ifx_ptm_exit);
+#ifndef MODULE
+ __setup("wanqos_en=", wanqos_en_setup);
+ __setup("queue_gamma_map=", queue_gamma_map_setup);
+#endif
+
+MODULE_LICENSE("GPL");
diff --git a/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_vdsl.h.svn-base b/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_vdsl.h.svn-base
new file mode 100644
index 0000000..b06232d
--- /dev/null
+++ b/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_vdsl.h.svn-base
@@ -0,0 +1,126 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_ptm_vdsl.h
+** PROJECT : UEIP
+** MODULES : PTM
+**
+** DATE : 7 Jul 2009
+** AUTHOR : Xu Liang
+** DESCRIPTION : PTM driver header file (core functions for VR9)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 07 JUL 2009 Xu Liang Init Version
+*******************************************************************************/
+
+#ifndef IFXMIPS_PTM_VDSL_H
+#define IFXMIPS_PTM_VDSL_H
+
+#include <linux/version.h>
+#include <linux/netdevice.h>
+#include <lantiq_ptm.h>
+#include "ifxmips_ptm_common.h"
+#include "ifxmips_ptm_ppe_common.h"
+#include "ifxmips_ptm_fw_regs_vdsl.h"
+
+#define INT_NUM_IM2_IRL24 (INT_NUM_IM2_IRL0 + 24)
+
+#define IFX_REG_W32(_v, _r) __raw_writel((_v), (volatile unsigned int *)(_r))
+#define IFX_REG_R32(_r) __raw_readl((volatile unsigned int *)(_r))
+#define IFX_REG_W32_MASK(_clr, _set, _r) IFX_REG_W32((IFX_REG_R32((_r)) & ~(_clr)) | (_set), (_r))
+#define SET_BITS(x, msb, lsb, value) (((x) & ~(((1 << ((msb) + 1)) - 1) ^ ((1 << (lsb)) - 1))) | (((value) & ((1 << (1 + (msb) - (lsb))) - 1)) << (lsb)))
+
+
+
+/*
+ * ####################################
+ * Definition
+ * ####################################
+ */
+
+/*
+ * Constant Definition
+ */
+#define ETH_WATCHDOG_TIMEOUT (10 * HZ)
+
+/*
+ * DMA RX/TX Channel Parameters
+ */
+#define MAX_ITF_NUMBER 1
+#define MAX_RX_DMA_CHANNEL_NUMBER 1
+#define MAX_TX_DMA_CHANNEL_NUMBER 1
+#define DATA_BUFFER_ALIGNMENT EMA_ALIGNMENT
+#define DESC_ALIGNMENT 8
+
+/*
+ * Ethernet Frame Definitions
+ */
+#define ETH_MAC_HEADER_LENGTH 14
+#define ETH_CRC_LENGTH 4
+#define ETH_MIN_FRAME_LENGTH 64
+#define ETH_MAX_FRAME_LENGTH (1518 + 4 * 2)
+
+/*
+ * RX Frame Definitions
+ */
+#define RX_MAX_BUFFER_SIZE (1600 + RX_HEAD_MAC_ADDR_ALIGNMENT)
+#define RX_HEAD_MAC_ADDR_ALIGNMENT 2
+#define RX_TAIL_CRC_LENGTH 0 // PTM firmware does not have ethernet frame CRC
+ // The len in descriptor doesn't include ETH_CRC
+ // because ETH_CRC may not present in some configuration
+
+
+
+/*
+ * ####################################
+ * Data Type
+ * ####################################
+ */
+
+struct ptm_itf {
+ unsigned int rx_desc_pos;
+
+ unsigned int tx_desc_pos;
+
+ unsigned int tx_swap_desc_pos;
+
+ struct net_device_stats stats;
+
+ struct napi_struct napi;
+};
+
+struct ptm_priv_data {
+ struct ptm_itf itf[MAX_ITF_NUMBER];
+};
+
+
+
+/*
+ * ####################################
+ * Declaration
+ * ####################################
+ */
+
+extern unsigned int ifx_ptm_dbg_enable;
+
+extern void ifx_ptm_get_fw_ver(unsigned int *major, unsigned int *minor);
+
+extern void ifx_ptm_init_chip(void);
+extern void ifx_ptm_uninit_chip(void);
+
+extern int ifx_pp32_start(int pp32);
+extern void ifx_pp32_stop(int pp32);
+
+extern void ifx_reset_ppe(void);
+
+
+
+#endif // IFXMIPS_PTM_VDSL_H
diff --git a/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_vr9.c.svn-base b/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_vr9.c.svn-base
new file mode 100644
index 0000000..0a02569
--- /dev/null
+++ b/package/platform/lantiq/ltq-ptm/src/.svn/text-base/ifxmips_ptm_vr9.c.svn-base
@@ -0,0 +1,295 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_ptm_vr9.c
+** PROJECT : UEIP
+** MODULES : PTM
+**
+** DATE : 7 Jul 2009
+** AUTHOR : Xu Liang
+** DESCRIPTION : PTM driver common source file (core functions)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 07 JUL 2009 Xu Liang Init Version
+*******************************************************************************/
+
+
+
+/*
+ * ####################################
+ * Head File
+ * ####################################
+ */
+
+/*
+ * Common Head File
+ */
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/version.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/proc_fs.h>
+#include <linux/init.h>
+#include <linux/ioctl.h>
+#include <asm/delay.h>
+
+/*
+ * Chip Specific Head File
+ */
+#include "ifxmips_ptm_vdsl.h"
+#include "ifxmips_ptm_fw_vr9.h"
+
+#include <lantiq_soc.h>
+
+static inline void init_pmu(void);
+static inline void uninit_pmu(void);
+static inline void reset_ppe(void);
+static inline void init_pdma(void);
+static inline void init_mailbox(void);
+static inline void init_atm_tc(void);
+static inline void clear_share_buffer(void);
+
+#define IFX_PMU_MODULE_PPE_SLL01 BIT(19)
+#define IFX_PMU_MODULE_PPE_TC BIT(21)
+#define IFX_PMU_MODULE_PPE_EMA BIT(22)
+#define IFX_PMU_MODULE_PPE_QSB BIT(18)
+#define IFX_PMU_MODULE_AHBS BIT(13)
+#define IFX_PMU_MODULE_DSL_DFE BIT(9)
+
+
+static inline void init_pmu(void)
+{
+ ltq_pmu_enable(IFX_PMU_MODULE_PPE_SLL01 |
+ IFX_PMU_MODULE_PPE_TC |
+ IFX_PMU_MODULE_PPE_EMA |
+ IFX_PMU_MODULE_AHBS |
+ IFX_PMU_MODULE_DSL_DFE);
+
+}
+
+static inline void uninit_pmu(void)
+{
+}
+
+static inline void reset_ppe(void)
+{
+/*#ifdef MODULE
+ // reset PPE
+ ifx_rcu_rst(IFX_RCU_DOMAIN_DSLDFE, IFX_RCU_MODULE_PTM);
+ udelay(1000);
+ ifx_rcu_rst(IFX_RCU_DOMAIN_DSLTC, IFX_RCU_MODULE_PTM);
+ udelay(1000);
+ ifx_rcu_rst(IFX_RCU_DOMAIN_PPE, IFX_RCU_MODULE_PTM);
+ udelay(1000);
+ *PP32_SRST &= ~0x000303CF;
+ udelay(1000);
+ *PP32_SRST |= 0x000303CF;
+ udelay(1000);
+#endif*/
+}
+
+static inline void init_pdma(void)
+{
+ IFX_REG_W32(0x00000001, PDMA_CFG);
+ IFX_REG_W32(0x00082C00, PDMA_RX_CTX_CFG);
+ IFX_REG_W32(0x00081B00, PDMA_TX_CTX_CFG);
+ IFX_REG_W32(0x02040604, PDMA_RX_MAX_LEN_REG);
+ IFX_REG_W32(0x000F003F, PDMA_RX_DELAY_CFG);
+
+ IFX_REG_W32(0x00000011, SAR_MODE_CFG);
+ IFX_REG_W32(0x00082A00, SAR_RX_CTX_CFG);
+ IFX_REG_W32(0x00082E00, SAR_TX_CTX_CFG);
+ IFX_REG_W32(0x00001021, SAR_POLY_CFG_SET0);
+ IFX_REG_W32(0x1EDC6F41, SAR_POLY_CFG_SET1);
+ IFX_REG_W32(0x04C11DB7, SAR_POLY_CFG_SET2);
+ IFX_REG_W32(0x00000F3E, SAR_CRC_SIZE_CFG);
+
+ IFX_REG_W32(0x01001900, SAR_PDMA_RX_CMDBUF_CFG);
+ IFX_REG_W32(0x01001A00, SAR_PDMA_TX_CMDBUF_CFG);
+}
+
+static inline void init_mailbox(void)
+{
+ IFX_REG_W32(0xFFFFFFFF, MBOX_IGU1_ISRC);
+ IFX_REG_W32(0x00000000, MBOX_IGU1_IER);
+ IFX_REG_W32(0xFFFFFFFF, MBOX_IGU3_ISRC);
+ IFX_REG_W32(0x00000000, MBOX_IGU3_IER);
+}
+
+static inline void init_atm_tc(void)
+{
+ IFX_REG_W32(0x00010040, SFSM_CFG0);
+ IFX_REG_W32(0x00010040, SFSM_CFG1);
+ IFX_REG_W32(0x00020000, SFSM_PGCNT0);
+ IFX_REG_W32(0x00020000, SFSM_PGCNT1);
+ IFX_REG_W32(0x00000000, DREG_AT_IDLE0);
+ IFX_REG_W32(0x00000000, DREG_AT_IDLE1);
+ IFX_REG_W32(0x00000000, DREG_AR_IDLE0);
+ IFX_REG_W32(0x00000000, DREG_AR_IDLE1);
+ IFX_REG_W32(0x0000080C, DREG_B0_LADR);
+ IFX_REG_W32(0x0000080C, DREG_B1_LADR);
+
+ IFX_REG_W32(0x000001F0, DREG_AR_CFG0);
+ IFX_REG_W32(0x000001F0, DREG_AR_CFG1);
+ IFX_REG_W32(0x000001E0, DREG_AT_CFG0);
+ IFX_REG_W32(0x000001E0, DREG_AT_CFG1);
+
+ /* clear sync state */
+ //IFX_REG_W32(0, SFSM_STATE0);
+ //IFX_REG_W32(0, SFSM_STATE1);
+
+ IFX_REG_W32_MASK(0, 1 << 14, SFSM_CFG0); // enable SFSM storing
+ IFX_REG_W32_MASK(0, 1 << 14, SFSM_CFG1);
+
+ IFX_REG_W32_MASK(0, 1 << 15, SFSM_CFG0); // HW keep the IDLE cells in RTHA buffer
+ IFX_REG_W32_MASK(0, 1 << 15, SFSM_CFG1);
+
+ IFX_REG_W32(0xF0D10000, FFSM_IDLE_HEAD_BC0);
+ IFX_REG_W32(0xF0D10000, FFSM_IDLE_HEAD_BC1);
+ IFX_REG_W32(0x00030028, FFSM_CFG0); // Force_idle
+ IFX_REG_W32(0x00030028, FFSM_CFG1);
+}
+
+static inline void clear_share_buffer(void)
+{
+ volatile u32 *p;
+ unsigned int i;
+
+ p = SB_RAM0_ADDR(0);
+ for ( i = 0; i < SB_RAM0_DWLEN + SB_RAM1_DWLEN + SB_RAM2_DWLEN + SB_RAM3_DWLEN; i++ )
+ IFX_REG_W32(0, p++);
+
+ p = SB_RAM6_ADDR(0);
+ for ( i = 0; i < SB_RAM6_DWLEN; i++ )
+ IFX_REG_W32(0, p++);
+}
+
+/*
+ * Description:
+ * Download PPE firmware binary code.
+ * Input:
+ * pp32 --- int, which pp32 core
+ * src --- u32 *, binary code buffer
+ * dword_len --- unsigned int, binary code length in DWORD (32-bit)
+ * Output:
+ * int --- 0: Success
+ * else: Error Code
+ */
+static inline int pp32_download_code(int pp32, u32 *code_src, unsigned int code_dword_len, u32 *data_src, unsigned int data_dword_len)
+{
+ unsigned int clr, set;
+ volatile u32 *dest;
+
+ if ( code_src == 0 || ((unsigned long)code_src & 0x03) != 0
+ || data_src == 0 || ((unsigned long)data_src & 0x03) != 0 )
+ return -1;
+
+ clr = pp32 ? 0xF0 : 0x0F;
+ if ( code_dword_len <= CDM_CODE_MEMORYn_DWLEN(0) )
+ set = pp32 ? (3 << 6): (2 << 2);
+ else
+ set = 0x00;
+ IFX_REG_W32_MASK(clr, set, CDM_CFG);
+
+ /* copy code */
+ dest = CDM_CODE_MEMORY(pp32, 0);
+ while ( code_dword_len-- > 0 )
+ IFX_REG_W32(*code_src++, dest++);
+
+ /* copy data */
+ dest = CDM_DATA_MEMORY(pp32, 0);
+ while ( data_dword_len-- > 0 )
+ IFX_REG_W32(*data_src++, dest++);
+
+ return 0;
+}
+
+
+
+/*
+ * ####################################
+ * Global Function
+ * ####################################
+ */
+
+extern void ifx_ptm_get_fw_ver(unsigned int *major, unsigned int *minor)
+{
+ ASSERT(major != NULL, "pointer is NULL");
+ ASSERT(minor != NULL, "pointer is NULL");
+
+ *major = FW_VER_ID->major;
+ *minor = FW_VER_ID->minor;
+}
+
+void ifx_ptm_init_chip(void)
+{
+ init_pmu();
+
+ reset_ppe();
+
+ init_pdma();
+
+ init_mailbox();
+
+ init_atm_tc();
+
+ clear_share_buffer();
+}
+
+void ifx_ptm_uninit_chip(void)
+{
+ uninit_pmu();
+}
+
+/*
+ * Description:
+ * Initialize and start up PP32.
+ * Input:
+ * none
+ * Output:
+ * int --- 0: Success
+ * else: Error Code
+ */
+int ifx_pp32_start(int pp32)
+{
+ unsigned int mask = 1 << (pp32 << 4);
+ int ret;
+
+ /* download firmware */
+ ret = pp32_download_code(pp32, firmware_binary_code, sizeof(firmware_binary_code) / sizeof(*firmware_binary_code), firmware_binary_data, sizeof(firmware_binary_data) / sizeof(*firmware_binary_data));
+ if ( ret != 0 )
+ return ret;
+
+ /* run PP32 */
+ IFX_REG_W32_MASK(mask, 0, PP32_FREEZE);
+
+ /* idle for a while to let PP32 init itself */
+ udelay(10);
+
+ return 0;
+}
+
+/*
+ * Description:
+ * Halt PP32.
+ * Input:
+ * none
+ * Output:
+ * none
+ */
+void ifx_pp32_stop(int pp32)
+{
+ unsigned int mask = 1 << (pp32 << 4);
+
+ /* halt PP32 */
+ IFX_REG_W32_MASK(0, mask, PP32_FREEZE);
+}
diff --git a/package/platform/lantiq/ltq-ptm/src/Makefile b/package/platform/lantiq/ltq-ptm/src/Makefile
new file mode 100644
index 0000000..0d0bda5
--- /dev/null
+++ b/package/platform/lantiq/ltq-ptm/src/Makefile
@@ -0,0 +1,23 @@
+ifeq ($(BUILD_VARIANT),danube)
+ CFLAGS_MODULE+=-DCONFIG_DANUBE
+ obj-m = ltq_ptm_danube.o
+ ltq_ptm_danube-objs = ifxmips_ptm_adsl.o ifxmips_ptm_danube.o
+endif
+
+ifeq ($(BUILD_VARIANT),ase)
+ CFLAGS_MODULE+=-DCONFIG_AMAZON_SE
+ obj-m = ltq_ptm_ase.o
+ ltq_ptm_ase-objs = ifxmips_ptm_adsl.o ifxmips_ptm_amazon_se.o
+endif
+
+ifeq ($(BUILD_VARIANT),ar9)
+ CFLAGS_MODULE+=-DCONFIG_AR9
+ obj-m = ltq_ptm_ar9.o
+ ltq_ptm_ar9-objs = ifxmips_ptm_adsl.o ifxmips_ptm_ar9.o
+endif
+
+ifeq ($(BUILD_VARIANT),vr9)
+ CFLAGS_MODULE+=-DCONFIG_VR9
+ obj-m = ltq_ptm_vr9.o
+ ltq_ptm_vr9-objs = ifxmips_ptm_vdsl.o ifxmips_ptm_vr9.o
+endif
diff --git a/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_adsl.c b/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_adsl.c
new file mode 100644
index 0000000..391d56c
--- /dev/null
+++ b/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_adsl.c
@@ -0,0 +1,1551 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_ptm_adsl.c
+** PROJECT : UEIP
+** MODULES : PTM
+**
+** DATE : 7 Jul 2009
+** AUTHOR : Xu Liang
+** DESCRIPTION : PTM driver common source file (core functions for Danube/
+** Amazon-SE/AR9)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 07 JUL 2009 Xu Liang Init Version
+*******************************************************************************/
+
+
+
+/*
+ * ####################################
+ * Head File
+ * ####################################
+ */
+
+/*
+ * Common Head File
+ */
+#include <linux/version.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/proc_fs.h>
+#include <linux/init.h>
+#include <linux/ioctl.h>
+#include <linux/etherdevice.h>
+#include <linux/interrupt.h>
+#include <asm/io.h>
+
+/*
+ * Chip Specific Head File
+ */
+#include "ifxmips_ptm_adsl.h"
+
+
+#include <lantiq_soc.h>
+
+/*
+ * ####################################
+ * Kernel Version Adaption
+ * ####################################
+ */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,11)
+ #define MODULE_PARM_ARRAY(a, b) module_param_array(a, int, NULL, 0)
+ #define MODULE_PARM(a, b) module_param(a, int, 0)
+#else
+ #define MODULE_PARM_ARRAY(a, b) MODULE_PARM(a, b)
+#endif
+
+
+
+/*
+ * ####################################
+ * Parameters to Configure PPE
+ * ####################################
+ */
+
+static int write_desc_delay = 0x20; /* Write descriptor delay */
+
+static int rx_max_packet_size = ETH_MAX_FRAME_LENGTH;
+ /* Max packet size for RX */
+
+static int dma_rx_descriptor_length = 24; /* Number of descriptors per DMA RX channel */
+static int dma_tx_descriptor_length = 24; /* Number of descriptors per DMA TX channel */
+
+static int eth_efmtc_crc_cfg = 0x03100710; /* default: tx_eth_crc_check: 1, tx_tc_crc_check: 1, tx_tc_crc_len = 16 */
+ /* rx_eth_crc_present: 1, rx_eth_crc_check: 1, rx_tc_crc_check: 1, rx_tc_crc_len = 16 */
+
+MODULE_PARM(write_desc_delay, "i");
+MODULE_PARM_DESC(write_desc_delay, "PPE core clock cycles between descriptor write and effectiveness in external RAM");
+
+MODULE_PARM(rx_max_packet_size, "i");
+MODULE_PARM_DESC(rx_max_packet_size, "Max packet size in byte for downstream ethernet frames");
+
+MODULE_PARM(dma_rx_descriptor_length, "i");
+MODULE_PARM_DESC(dma_rx_descriptor_length, "Number of descriptor assigned to DMA RX channel (>16)");
+MODULE_PARM(dma_tx_descriptor_length, "i");
+MODULE_PARM_DESC(dma_tx_descriptor_length, "Number of descriptor assigned to DMA TX channel (>16)");
+
+MODULE_PARM(eth_efmtc_crc_cfg, "i");
+MODULE_PARM_DESC(eth_efmtc_crc_cfg, "Configuration for PTM TX/RX ethernet/efm-tc CRC");
+
+
+
+/*
+ * ####################################
+ * Definition
+ * ####################################
+ */
+
+
+#define DUMP_SKB_LEN ~0
+
+
+
+/*
+ * ####################################
+ * Declaration
+ * ####################################
+ */
+
+/*
+ * Network Operations
+ */
+static void ptm_setup(struct net_device *, int);
+static struct net_device_stats *ptm_get_stats(struct net_device *);
+static int ptm_open(struct net_device *);
+static int ptm_stop(struct net_device *);
+ static unsigned int ptm_poll(int, unsigned int);
+ static int ptm_napi_poll(struct napi_struct *, int);
+static int ptm_hard_start_xmit(struct sk_buff *, struct net_device *);
+static int ptm_ioctl(struct net_device *, struct ifreq *, int);
+static void ptm_tx_timeout(struct net_device *);
+
+/*
+ * DSL Data LED
+ */
+static INLINE void adsl_led_flash(void);
+
+/*
+ * buffer manage functions
+ */
+static INLINE struct sk_buff* alloc_skb_rx(void);
+//static INLINE struct sk_buff* alloc_skb_tx(unsigned int);
+static INLINE struct sk_buff *get_skb_rx_pointer(unsigned int);
+static INLINE int get_tx_desc(unsigned int, unsigned int *);
+
+/*
+ * Mailbox handler and signal function
+ */
+static INLINE int mailbox_rx_irq_handler(unsigned int);
+static irqreturn_t mailbox_irq_handler(int, void *);
+static INLINE void mailbox_signal(unsigned int, int);
+#ifdef CONFIG_IFX_PTM_RX_TASKLET
+ static void do_ptm_tasklet(unsigned long);
+#endif
+
+/*
+ * Debug Functions
+ */
+#if defined(DEBUG_DUMP_SKB) && DEBUG_DUMP_SKB
+ static void dump_skb(struct sk_buff *, u32, char *, int, int, int);
+#else
+ #define dump_skb(skb, len, title, port, ch, is_tx) do {} while (0)
+#endif
+#if defined(ENABLE_DBG_PROC) && ENABLE_DBG_PROC
+ static void skb_swap(struct sk_buff *);
+#else
+ #define skb_swap(skb) do {} while (0)
+#endif
+
+/*
+ * Proc File Functions
+ */
+static INLINE void proc_file_create(void);
+static INLINE void proc_file_delete(void);
+static int proc_read_version(char *, char **, off_t, int, int *, void *);
+static int proc_read_wanmib(char *, char **, off_t, int, int *, void *);
+static int proc_write_wanmib(struct file *, const char *, unsigned long, void *);
+#if defined(ENABLE_FW_PROC) && ENABLE_FW_PROC
+ static int proc_read_genconf(char *, char **, off_t, int, int *, void *);
+#endif
+#if defined(ENABLE_DBG_PROC) && ENABLE_DBG_PROC
+ static int proc_read_dbg(char *, char **, off_t, int, int *, void *);
+ static int proc_write_dbg(struct file *, const char *, unsigned long, void *);
+#endif
+
+/*
+ * Proc Help Functions
+ */
+static INLINE int stricmp(const char *, const char *);
+#if defined(ENABLE_DBG_PROC) && ENABLE_DBG_PROC
+ static INLINE int strincmp(const char *, const char *, int);
+#endif
+static INLINE int ifx_ptm_version(char *);
+
+/*
+ * Init & clean-up functions
+ */
+static INLINE void check_parameters(void);
+static INLINE int init_priv_data(void);
+static INLINE void clear_priv_data(void);
+static INLINE void init_tables(void);
+
+/*
+ * Exteranl Function
+ */
+#if defined(CONFIG_IFXMIPS_DSL_CPE_MEI) || defined(CONFIG_IFXMIPS_DSL_CPE_MEI_MODULE)
+ extern int ifx_mei_atm_showtime_check(int *is_showtime, struct port_cell_info *port_cell, void **xdata_addr);
+#else
+ static inline int ifx_mei_atm_showtime_check(int *is_showtime, struct port_cell_info *port_cell, void **xdata_addr)
+ {
+ if ( is_showtime != NULL )
+ *is_showtime = 0;
+ return 0;
+ }
+#endif
+
+/*
+ * External variable
+ */
+#if defined(CONFIG_IFXMIPS_DSL_CPE_MEI) || defined(CONFIG_IFXMIPS_DSL_CPE_MEI_MODULE)
+ extern int (*ifx_mei_atm_showtime_enter)(struct port_cell_info *, void *);
+ extern int (*ifx_mei_atm_showtime_exit)(void);
+#else
+ int (*ifx_mei_atm_showtime_enter)(struct port_cell_info *, void *) = NULL;
+ EXPORT_SYMBOL(ifx_mei_atm_showtime_enter);
+ int (*ifx_mei_atm_showtime_exit)(void) = NULL;
+ EXPORT_SYMBOL(ifx_mei_atm_showtime_exit);
+#endif
+
+
+
+/*
+ * ####################################
+ * Local Variable
+ * ####################################
+ */
+
+static struct ptm_priv_data g_ptm_priv_data;
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32)
+static struct net_device_ops g_ptm_netdev_ops = {
+ .ndo_get_stats = ptm_get_stats,
+ .ndo_open = ptm_open,
+ .ndo_stop = ptm_stop,
+ .ndo_start_xmit = ptm_hard_start_xmit,
+ .ndo_validate_addr = eth_validate_addr,
+ .ndo_set_mac_address = eth_mac_addr,
+ .ndo_change_mtu = eth_change_mtu,
+ .ndo_do_ioctl = ptm_ioctl,
+ .ndo_tx_timeout = ptm_tx_timeout,
+};
+#endif
+
+static struct net_device *g_net_dev[2] = {0};
+static char *g_net_dev_name[2] = {"ptm0", "ptmfast0"};
+
+#ifdef CONFIG_IFX_PTM_RX_TASKLET
+ static struct tasklet_struct g_ptm_tasklet[] = {
+ {NULL, 0, ATOMIC_INIT(0), do_ptm_tasklet, 0},
+ {NULL, 0, ATOMIC_INIT(0), do_ptm_tasklet, 1},
+ };
+#endif
+
+unsigned int ifx_ptm_dbg_enable = DBG_ENABLE_MASK_ERR;
+
+static struct proc_dir_entry* g_ptm_dir = NULL;
+
+static int g_showtime = 0;
+
+
+
+/*
+ * ####################################
+ * Local Function
+ * ####################################
+ */
+
+static void ptm_setup(struct net_device *dev, int ndev)
+{
+ /* hook network operations */
+ dev->netdev_ops = &g_ptm_netdev_ops;
+ netif_napi_add(dev, &g_ptm_priv_data.itf[ndev].napi, ptm_napi_poll, 25);
+ dev->watchdog_timeo = ETH_WATCHDOG_TIMEOUT;
+
+ dev->dev_addr[0] = 0x00;
+ dev->dev_addr[1] = 0x20;
+ dev->dev_addr[2] = 0xda;
+ dev->dev_addr[3] = 0x86;
+ dev->dev_addr[4] = 0x23;
+ dev->dev_addr[5] = 0x75 + ndev;
+}
+
+static struct net_device_stats *ptm_get_stats(struct net_device *dev)
+{
+ int ndev;
+
+ for ( ndev = 0; ndev < ARRAY_SIZE(g_net_dev) && g_net_dev[ndev] != dev; ndev++ );
+ ASSERT(ndev >= 0 && ndev < ARRAY_SIZE(g_net_dev), "ndev = %d (wrong value)", ndev);
+
+ g_ptm_priv_data.itf[ndev].stats.rx_errors = WAN_MIB_TABLE[ndev].wrx_tccrc_err_pdu + WAN_MIB_TABLE[ndev].wrx_ethcrc_err_pdu;
+ g_ptm_priv_data.itf[ndev].stats.rx_dropped = WAN_MIB_TABLE[ndev].wrx_nodesc_drop_pdu + WAN_MIB_TABLE[ndev].wrx_len_violation_drop_pdu + (WAN_MIB_TABLE[ndev].wrx_correct_pdu - g_ptm_priv_data.itf[ndev].stats.rx_packets);
+
+ return &g_ptm_priv_data.itf[ndev].stats;
+}
+
+static int ptm_open(struct net_device *dev)
+{
+ int ndev;
+
+ for ( ndev = 0; ndev < ARRAY_SIZE(g_net_dev) && g_net_dev[ndev] != dev; ndev++ );
+ ASSERT(ndev >= 0 && ndev < ARRAY_SIZE(g_net_dev), "ndev = %d (wrong value)", ndev);
+
+ napi_enable(&g_ptm_priv_data.itf[ndev].napi);
+
+ IFX_REG_W32_MASK(0, 1 << ndev, MBOX_IGU1_IER);
+
+ netif_start_queue(dev);
+
+ return 0;
+}
+
+static int ptm_stop(struct net_device *dev)
+{
+ int ndev;
+
+ for ( ndev = 0; ndev < ARRAY_SIZE(g_net_dev) && g_net_dev[ndev] != dev; ndev++ );
+ ASSERT(ndev >= 0 && ndev < ARRAY_SIZE(g_net_dev), "ndev = %d (wrong value)", ndev);
+
+ IFX_REG_W32_MASK((1 << ndev) | (1 << (ndev + 16)), 0, MBOX_IGU1_IER);
+
+ napi_disable(&g_ptm_priv_data.itf[ndev].napi);
+
+ netif_stop_queue(dev);
+
+ return 0;
+}
+
+static unsigned int ptm_poll(int ndev, unsigned int work_to_do)
+{
+ unsigned int work_done = 0;
+
+ ASSERT(ndev >= 0 && ndev < ARRAY_SIZE(g_net_dev), "ndev = %d (wrong value)", ndev);
+
+ while ( work_done < work_to_do && WRX_DMA_CHANNEL_CONFIG(ndev)->vlddes > 0 ) {
+ if ( mailbox_rx_irq_handler(ndev) < 0 )
+ break;
+
+ work_done++;
+ }
+
+ return work_done;
+}
+static int ptm_napi_poll(struct napi_struct *napi, int budget)
+{
+ int ndev;
+ unsigned int work_done;
+
+ for ( ndev = 0; ndev < ARRAY_SIZE(g_net_dev) && g_net_dev[ndev] != napi->dev; ndev++ );
+
+ work_done = ptm_poll(ndev, budget);
+
+ // interface down
+ if ( !netif_running(napi->dev) ) {
+ napi_complete(napi);
+ return work_done;
+ }
+
+ // no more traffic
+ if ( WRX_DMA_CHANNEL_CONFIG(ndev)->vlddes == 0 ) {
+ // clear interrupt
+ IFX_REG_W32_MASK(0, 1 << ndev, MBOX_IGU1_ISRC);
+ // double check
+ if ( WRX_DMA_CHANNEL_CONFIG(ndev)->vlddes == 0 ) {
+ napi_complete(napi);
+ IFX_REG_W32_MASK(0, 1 << ndev, MBOX_IGU1_IER);
+ return work_done;
+ }
+ }
+
+ // next round
+ return work_done;
+}
+
+static int ptm_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
+{
+ int ndev;
+ unsigned int f_full;
+ int desc_base;
+ register struct tx_descriptor reg_desc = {0};
+
+ for ( ndev = 0; ndev < ARRAY_SIZE(g_net_dev) && g_net_dev[ndev] != dev; ndev++ );
+ ASSERT(ndev >= 0 && ndev < ARRAY_SIZE(g_net_dev), "ndev = %d (wrong value)", ndev);
+
+ if ( !g_showtime ) {
+ err("not in showtime");
+ goto PTM_HARD_START_XMIT_FAIL;
+ }
+
+ /* allocate descriptor */
+ desc_base = get_tx_desc(ndev, &f_full);
+ if ( f_full ) {
+ dev->trans_start = jiffies;
+ netif_stop_queue(dev);
+
+ IFX_REG_W32_MASK(0, 1 << (ndev + 16), MBOX_IGU1_ISRC);
+ IFX_REG_W32_MASK(0, 1 << (ndev + 16), MBOX_IGU1_IER);
+ }
+ if ( desc_base < 0 )
+ goto PTM_HARD_START_XMIT_FAIL;
+
+ if ( g_ptm_priv_data.itf[ndev].tx_skb[desc_base] != NULL )
+ dev_kfree_skb_any(g_ptm_priv_data.itf[ndev].tx_skb[desc_base]);
+ g_ptm_priv_data.itf[ndev].tx_skb[desc_base] = skb;
+
+ reg_desc.dataptr = (unsigned int)skb->data >> 2;
+ reg_desc.datalen = skb->len < ETH_ZLEN ? ETH_ZLEN : skb->len;
+ reg_desc.byteoff = (unsigned int)skb->data & (DATA_BUFFER_ALIGNMENT - 1);
+ reg_desc.own = 1;
+ reg_desc.c = 1;
+ reg_desc.sop = reg_desc.eop = 1;
+
+ /* write discriptor to memory and write back cache */
+ g_ptm_priv_data.itf[ndev].tx_desc[desc_base] = reg_desc;
+ dma_cache_wback((unsigned long)skb->data, skb->len);
+ wmb();
+
+ dump_skb(skb, DUMP_SKB_LEN, (char *)__func__, ndev, ndev, 1);
+
+ if ( (ifx_ptm_dbg_enable & DBG_ENABLE_MASK_MAC_SWAP) ) {
+ skb_swap(skb);
+ }
+
+ g_ptm_priv_data.itf[ndev].stats.tx_packets++;
+ g_ptm_priv_data.itf[ndev].stats.tx_bytes += reg_desc.datalen;
+
+ dev->trans_start = jiffies;
+ mailbox_signal(ndev, 1);
+
+ adsl_led_flash();
+
+ return NETDEV_TX_OK;
+
+PTM_HARD_START_XMIT_FAIL:
+ dev_kfree_skb_any(skb);
+ g_ptm_priv_data.itf[ndev].stats.tx_dropped++;
+ return NETDEV_TX_OK;
+}
+
+static int ptm_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
+{
+ int ndev;
+
+ for ( ndev = 0; ndev < ARRAY_SIZE(g_net_dev) && g_net_dev[ndev] != dev; ndev++ );
+ ASSERT(ndev >= 0 && ndev < ARRAY_SIZE(g_net_dev), "ndev = %d (wrong value)", ndev);
+
+ switch ( cmd )
+ {
+ case IFX_PTM_MIB_CW_GET:
+ ((PTM_CW_IF_ENTRY_T *)ifr->ifr_data)->ifRxNoIdleCodewords = WAN_MIB_TABLE[ndev].wrx_nonidle_cw;
+ ((PTM_CW_IF_ENTRY_T *)ifr->ifr_data)->ifRxIdleCodewords = WAN_MIB_TABLE[ndev].wrx_idle_cw;
+ ((PTM_CW_IF_ENTRY_T *)ifr->ifr_data)->ifRxCodingViolation = WAN_MIB_TABLE[ndev].wrx_err_cw;
+ ((PTM_CW_IF_ENTRY_T *)ifr->ifr_data)->ifTxNoIdleCodewords = 0;
+ ((PTM_CW_IF_ENTRY_T *)ifr->ifr_data)->ifTxIdleCodewords = 0;
+ break;
+ case IFX_PTM_MIB_FRAME_GET:
+ ((PTM_FRAME_MIB_T *)ifr->ifr_data)->RxCorrect = WAN_MIB_TABLE[ndev].wrx_correct_pdu;
+ ((PTM_FRAME_MIB_T *)ifr->ifr_data)->TC_CrcError = WAN_MIB_TABLE[ndev].wrx_tccrc_err_pdu;
+ ((PTM_FRAME_MIB_T *)ifr->ifr_data)->RxDropped = WAN_MIB_TABLE[ndev].wrx_nodesc_drop_pdu + WAN_MIB_TABLE[ndev].wrx_len_violation_drop_pdu;
+ ((PTM_FRAME_MIB_T *)ifr->ifr_data)->TxSend = WAN_MIB_TABLE[ndev].wtx_total_pdu;
+ break;
+ case IFX_PTM_CFG_GET:
+ ((IFX_PTM_CFG_T *)ifr->ifr_data)->RxEthCrcPresent = CFG_ETH_EFMTC_CRC->rx_eth_crc_present;
+ ((IFX_PTM_CFG_T *)ifr->ifr_data)->RxEthCrcCheck = CFG_ETH_EFMTC_CRC->rx_eth_crc_check;
+ ((IFX_PTM_CFG_T *)ifr->ifr_data)->RxTcCrcCheck = CFG_ETH_EFMTC_CRC->rx_tc_crc_check;
+ ((IFX_PTM_CFG_T *)ifr->ifr_data)->RxTcCrcLen = CFG_ETH_EFMTC_CRC->rx_tc_crc_len;
+ ((IFX_PTM_CFG_T *)ifr->ifr_data)->TxEthCrcGen = CFG_ETH_EFMTC_CRC->tx_eth_crc_gen;
+ ((IFX_PTM_CFG_T *)ifr->ifr_data)->TxTcCrcGen = CFG_ETH_EFMTC_CRC->tx_tc_crc_gen;
+ ((IFX_PTM_CFG_T *)ifr->ifr_data)->TxTcCrcLen = CFG_ETH_EFMTC_CRC->tx_tc_crc_len;
+ break;
+ case IFX_PTM_CFG_SET:
+ CFG_ETH_EFMTC_CRC->rx_eth_crc_present = ((IFX_PTM_CFG_T *)ifr->ifr_data)->RxEthCrcPresent ? 1 : 0;
+ CFG_ETH_EFMTC_CRC->rx_eth_crc_check = ((IFX_PTM_CFG_T *)ifr->ifr_data)->RxEthCrcCheck ? 1 : 0;
+ if ( ((IFX_PTM_CFG_T *)ifr->ifr_data)->RxTcCrcCheck && (((IFX_PTM_CFG_T *)ifr->ifr_data)->RxTcCrcLen == 16 || ((IFX_PTM_CFG_T *)ifr->ifr_data)->RxTcCrcLen == 32) )
+ {
+ CFG_ETH_EFMTC_CRC->rx_tc_crc_check = 1;
+ CFG_ETH_EFMTC_CRC->rx_tc_crc_len = ((IFX_PTM_CFG_T *)ifr->ifr_data)->RxTcCrcLen;
+ }
+ else
+ {
+ CFG_ETH_EFMTC_CRC->rx_tc_crc_check = 0;
+ CFG_ETH_EFMTC_CRC->rx_tc_crc_len = 0;
+ }
+ CFG_ETH_EFMTC_CRC->tx_eth_crc_gen = ((IFX_PTM_CFG_T *)ifr->ifr_data)->TxEthCrcGen ? 1 : 0;
+ if ( ((IFX_PTM_CFG_T *)ifr->ifr_data)->TxTcCrcGen && (((IFX_PTM_CFG_T *)ifr->ifr_data)->TxTcCrcLen == 16 || ((IFX_PTM_CFG_T *)ifr->ifr_data)->TxTcCrcLen == 32) )
+ {
+ CFG_ETH_EFMTC_CRC->tx_tc_crc_gen = 1;
+ CFG_ETH_EFMTC_CRC->tx_tc_crc_len = ((IFX_PTM_CFG_T *)ifr->ifr_data)->TxTcCrcLen;
+ }
+ else
+ {
+ CFG_ETH_EFMTC_CRC->tx_tc_crc_gen = 0;
+ CFG_ETH_EFMTC_CRC->tx_tc_crc_len = 0;
+ }
+ break;
+ default:
+ return -EOPNOTSUPP;
+ }
+
+ return 0;
+}
+
+static void ptm_tx_timeout(struct net_device *dev)
+{
+ int ndev;
+
+ for ( ndev = 0; ndev < ARRAY_SIZE(g_net_dev) && g_net_dev[ndev] != dev; ndev++ );
+ ASSERT(ndev >= 0 && ndev < ARRAY_SIZE(g_net_dev), "ndev = %d (wrong value)", ndev);
+
+ /* disable TX irq, release skb when sending new packet */
+ IFX_REG_W32_MASK(1 << (ndev + 16), 0, MBOX_IGU1_IER);
+
+ /* wake up TX queue */
+ netif_wake_queue(dev);
+
+ return;
+}
+
+static INLINE void adsl_led_flash(void)
+{
+}
+
+static INLINE struct sk_buff* alloc_skb_rx(void)
+{
+ struct sk_buff *skb;
+
+ /* allocate memroy including trailer and padding */
+ skb = dev_alloc_skb(rx_max_packet_size + RX_HEAD_MAC_ADDR_ALIGNMENT + DATA_BUFFER_ALIGNMENT);
+ if ( skb != NULL ) {
+ /* must be burst length alignment and reserve two more bytes for MAC address alignment */
+ if ( ((unsigned int)skb->data & (DATA_BUFFER_ALIGNMENT - 1)) != 0 )
+ skb_reserve(skb, ~((unsigned int)skb->data + (DATA_BUFFER_ALIGNMENT - 1)) & (DATA_BUFFER_ALIGNMENT - 1));
+ /* pub skb in reserved area "skb->data - 4" */
+ *((struct sk_buff **)skb->data - 1) = skb;
+ wmb();
+ /* write back and invalidate cache */
+ dma_cache_wback_inv((unsigned long)skb->data - sizeof(skb), sizeof(skb));
+ /* invalidate cache */
+ dma_cache_inv((unsigned long)skb->data, (unsigned int)skb->end - (unsigned int)skb->data);
+ }
+
+ return skb;
+}
+
+#if 0
+static INLINE struct sk_buff* alloc_skb_tx(unsigned int size)
+{
+ struct sk_buff *skb;
+
+ /* allocate memory including padding */
+ size = (size + DATA_BUFFER_ALIGNMENT - 1) & ~(DATA_BUFFER_ALIGNMENT - 1);
+ skb = dev_alloc_skb(size + DATA_BUFFER_ALIGNMENT);
+ /* must be burst length alignment */
+ if ( skb != NULL )
+ skb_reserve(skb, ~((unsigned int)skb->data + (DATA_BUFFER_ALIGNMENT - 1)) & (DATA_BUFFER_ALIGNMENT - 1));
+ return skb;
+}
+#endif
+
+static INLINE struct sk_buff *get_skb_rx_pointer(unsigned int dataptr)
+{
+ unsigned int skb_dataptr;
+ struct sk_buff *skb;
+
+ skb_dataptr = ((dataptr - 1) << 2) | KSEG1;
+ skb = *(struct sk_buff **)skb_dataptr;
+
+ ASSERT((unsigned int)skb >= KSEG0, "invalid skb - skb = %#08x, dataptr = %#08x", (unsigned int)skb, dataptr);
+ ASSERT(((unsigned int)skb->data | KSEG1) == ((dataptr << 2) | KSEG1), "invalid skb - skb = %#08x, skb->data = %#08x, dataptr = %#08x", (unsigned int)skb, (unsigned int)skb->data, dataptr);
+
+ return skb;
+}
+
+static INLINE int get_tx_desc(unsigned int itf, unsigned int *f_full)
+{
+ int desc_base = -1;
+ struct ptm_itf *p_itf = &g_ptm_priv_data.itf[itf];
+
+ // assume TX is serial operation
+ // no protection provided
+
+ *f_full = 1;
+
+ if ( p_itf->tx_desc[p_itf->tx_desc_pos].own == 0 ) {
+ desc_base = p_itf->tx_desc_pos;
+ if ( ++(p_itf->tx_desc_pos) == dma_tx_descriptor_length )
+ p_itf->tx_desc_pos = 0;
+ if ( p_itf->tx_desc[p_itf->tx_desc_pos].own == 0 )
+ *f_full = 0;
+ }
+
+ return desc_base;
+}
+
+static INLINE int mailbox_rx_irq_handler(unsigned int ch) // return: < 0 - descriptor not available, 0 - received one packet
+{
+ unsigned int ndev = ch;
+ struct sk_buff *skb;
+ struct sk_buff *new_skb;
+ volatile struct rx_descriptor *desc;
+ struct rx_descriptor reg_desc;
+ int netif_rx_ret;
+
+ desc = &g_ptm_priv_data.itf[ndev].rx_desc[g_ptm_priv_data.itf[ndev].rx_desc_pos];
+ if ( desc->own || !desc->c ) // if PP32 hold descriptor or descriptor not completed
+ return -EAGAIN;
+ if ( ++g_ptm_priv_data.itf[ndev].rx_desc_pos == dma_rx_descriptor_length )
+ g_ptm_priv_data.itf[ndev].rx_desc_pos = 0;
+
+ reg_desc = *desc;
+ skb = get_skb_rx_pointer(reg_desc.dataptr);
+
+ if ( !reg_desc.err ) {
+ new_skb = alloc_skb_rx();
+ if ( new_skb != NULL ) {
+ skb_reserve(skb, reg_desc.byteoff);
+ skb_put(skb, reg_desc.datalen);
+
+ dump_skb(skb, DUMP_SKB_LEN, (char *)__func__, ndev, ndev, 0);
+
+ // parse protocol header
+ skb->dev = g_net_dev[ndev];
+ skb->protocol = eth_type_trans(skb, skb->dev);
+
+ g_net_dev[ndev]->last_rx = jiffies;
+
+ netif_rx_ret = netif_receive_skb(skb);
+
+ if ( netif_rx_ret != NET_RX_DROP ) {
+ g_ptm_priv_data.itf[ndev].stats.rx_packets++;
+ g_ptm_priv_data.itf[ndev].stats.rx_bytes += reg_desc.datalen;
+ }
+
+ reg_desc.dataptr = ((unsigned int)new_skb->data >> 2) & 0x0FFFFFFF;
+ reg_desc.byteoff = RX_HEAD_MAC_ADDR_ALIGNMENT;
+ }
+ }
+ else
+ reg_desc.err = 0;
+
+ reg_desc.datalen = rx_max_packet_size;
+ reg_desc.own = 1;
+ reg_desc.c = 0;
+
+ // update descriptor
+ *desc = reg_desc;
+ wmb();
+
+ mailbox_signal(ndev, 0);
+
+ adsl_led_flash();
+
+ return 0;
+}
+
+static irqreturn_t mailbox_irq_handler(int irq, void *dev_id)
+{
+ unsigned int isr;
+ int i;
+
+ isr = IFX_REG_R32(MBOX_IGU1_ISR);
+ IFX_REG_W32(isr, MBOX_IGU1_ISRC);
+ isr &= IFX_REG_R32(MBOX_IGU1_IER);
+
+ while ( (i = __fls(isr)) >= 0 ) {
+ isr ^= 1 << i;
+
+ if ( i >= 16 ) {
+ // TX
+ IFX_REG_W32_MASK(1 << i, 0, MBOX_IGU1_IER);
+ i -= 16;
+ if ( i < MAX_ITF_NUMBER )
+ netif_wake_queue(g_net_dev[i]);
+ }
+ else {
+ // RX
+#ifdef CONFIG_IFX_PTM_RX_INTERRUPT
+ while ( WRX_DMA_CHANNEL_CONFIG(i)->vlddes > 0 )
+ mailbox_rx_irq_handler(i);
+#else
+ IFX_REG_W32_MASK(1 << i, 0, MBOX_IGU1_IER);
+ napi_schedule(&g_ptm_priv_data.itf[i].napi);
+#endif
+ }
+ }
+
+ return IRQ_HANDLED;
+}
+
+static INLINE void mailbox_signal(unsigned int itf, int is_tx)
+{
+ int count = 1000;
+
+ if ( is_tx ) {
+ while ( MBOX_IGU3_ISR_ISR(itf + 16) && count > 0 )
+ count--;
+ IFX_REG_W32(MBOX_IGU3_ISRS_SET(itf + 16), MBOX_IGU3_ISRS);
+ }
+ else {
+ while ( MBOX_IGU3_ISR_ISR(itf) && count > 0 )
+ count--;
+ IFX_REG_W32(MBOX_IGU3_ISRS_SET(itf), MBOX_IGU3_ISRS);
+ }
+
+ ASSERT(count != 0, "MBOX_IGU3_ISR = 0x%08x", IFX_REG_R32(MBOX_IGU3_ISR));
+}
+
+#ifdef CONFIG_IFX_PTM_RX_TASKLET
+static void do_ptm_tasklet(unsigned long arg)
+{
+ unsigned int work_to_do = 25;
+ unsigned int work_done = 0;
+
+ ASSERT(arg >= 0 && arg < ARRAY_SIZE(g_net_dev), "arg = %lu (wrong value)", arg);
+
+ while ( work_done < work_to_do && WRX_DMA_CHANNEL_CONFIG(arg)->vlddes > 0 ) {
+ if ( mailbox_rx_irq_handler(arg) < 0 )
+ break;
+
+ work_done++;
+ }
+
+ // interface down
+ if ( !netif_running(g_net_dev[arg]) )
+ return;
+
+ // no more traffic
+ if ( WRX_DMA_CHANNEL_CONFIG(arg)->vlddes == 0 ) {
+ // clear interrupt
+ IFX_REG_W32_MASK(0, 1 << arg, MBOX_IGU1_ISRC);
+ // double check
+ if ( WRX_DMA_CHANNEL_CONFIG(arg)->vlddes == 0 ) {
+ IFX_REG_W32_MASK(0, 1 << arg, MBOX_IGU1_IER);
+ return;
+ }
+ }
+
+ // next round
+ tasklet_schedule(&g_ptm_tasklet[arg]);
+}
+#endif
+
+#if defined(DEBUG_DUMP_SKB) && DEBUG_DUMP_SKB
+static void dump_skb(struct sk_buff *skb, u32 len, char *title, int port, int ch, int is_tx)
+{
+ int i;
+
+ if ( !(ifx_ptm_dbg_enable & (is_tx ? DBG_ENABLE_MASK_DUMP_SKB_TX : DBG_ENABLE_MASK_DUMP_SKB_RX)) )
+ return;
+
+ if ( skb->len < len )
+ len = skb->len;
+
+ if ( len > rx_max_packet_size ) {
+ printk("too big data length: skb = %08x, skb->data = %08x, skb->len = %d\n", (u32)skb, (u32)skb->data, skb->len);
+ return;
+ }
+
+ if ( ch >= 0 )
+ printk("%s (port %d, ch %d)\n", title, port, ch);
+ else
+ printk("%s\n", title);
+ printk(" skb->data = %08X, skb->tail = %08X, skb->len = %d\n", (u32)skb->data, (u32)skb->tail, (int)skb->len);
+ for ( i = 1; i <= len; i++ ) {
+ if ( i % 16 == 1 )
+ printk(" %4d:", i - 1);
+ printk(" %02X", (int)(*((char*)skb->data + i - 1) & 0xFF));
+ if ( i % 16 == 0 )
+ printk("\n");
+ }
+ if ( (i - 1) % 16 != 0 )
+ printk("\n");
+}
+#endif
+
+#if defined(ENABLE_DBG_PROC) && ENABLE_DBG_PROC
+static void skb_swap(struct sk_buff *skb)
+{
+ unsigned char tmp[8];
+ unsigned char *p = skb->data;
+
+ if ( !(p[0] & 0x01) ) { // bypass broadcast/multicast
+ // swap MAC
+ memcpy(tmp, p, 6);
+ memcpy(p, p + 6, 6);
+ memcpy(p + 6, tmp, 6);
+ p += 12;
+
+ // bypass VLAN
+ while ( p[0] == 0x81 && p[1] == 0x00 )
+ p += 4;
+
+ // IP
+ if ( p[0] == 0x08 && p[1] == 0x00 ) {
+ p += 14;
+ memcpy(tmp, p, 4);
+ memcpy(p, p + 4, 4);
+ memcpy(p + 4, tmp, 4);
+ p += 8;
+ }
+
+ dma_cache_wback((unsigned long)skb->data, (unsigned long)p - (unsigned long)skb->data);
+ }
+}
+#endif
+
+static INLINE void proc_file_create(void)
+{
+ struct proc_dir_entry *res;
+
+ g_ptm_dir = proc_mkdir("driver/ifx_ptm", NULL);
+
+ create_proc_read_entry("version",
+ 0,
+ g_ptm_dir,
+ proc_read_version,
+ NULL);
+
+ res = create_proc_entry("wanmib",
+ 0,
+ g_ptm_dir);
+ if ( res != NULL ) {
+ res->read_proc = proc_read_wanmib;
+ res->write_proc = proc_write_wanmib;
+ }
+
+#if defined(ENABLE_FW_PROC) && ENABLE_FW_PROC
+ create_proc_read_entry("genconf",
+ 0,
+ g_ptm_dir,
+ proc_read_genconf,
+ NULL);
+
+ #ifdef CONFIG_AR9
+ create_proc_read_entry("regs",
+ 0,
+ g_ptm_dir,
+ ifx_ptm_proc_read_regs,
+ NULL);
+ #endif
+#endif
+
+#if defined(ENABLE_DBG_PROC) && ENABLE_DBG_PROC
+ res = create_proc_entry("dbg",
+ 0,
+ g_ptm_dir);
+ if ( res != NULL ) {
+ res->read_proc = proc_read_dbg;
+ res->write_proc = proc_write_dbg;
+ }
+#endif
+}
+
+static INLINE void proc_file_delete(void)
+{
+#if defined(ENABLE_DBG_PROC) && ENABLE_DBG_PROC
+ remove_proc_entry("dbg", g_ptm_dir);
+#endif
+
+#if defined(ENABLE_FW_PROC) && ENABLE_FW_PROC
+ #ifdef CONFIG_AR9
+ remove_proc_entry("regs", g_ptm_dir);
+ #endif
+
+ remove_proc_entry("genconf", g_ptm_dir);
+#endif
+
+ remove_proc_entry("wanmib", g_ptm_dir);
+
+ remove_proc_entry("version", g_ptm_dir);
+
+ remove_proc_entry("driver/ifx_ptm", NULL);
+}
+
+static int proc_read_version(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+{
+ int len = 0;
+
+ len += ifx_ptm_version(buf + len);
+
+ if ( offset >= len ) {
+ *start = buf;
+ *eof = 1;
+ return 0;
+ }
+ *start = buf + offset;
+ if ( (len -= offset) > count )
+ return count;
+ *eof = 1;
+ return len;
+}
+
+static int proc_read_wanmib(char *page, char **start, off_t off, int count, int *eof, void *data)
+{
+ int len = 0;
+ int i;
+ char *title[] = {
+ "ptm0\n",
+ "ptmfast0\n"
+ };
+
+ for ( i = 0; i < ARRAY_SIZE(title); i++ ) {
+ len += sprintf(page + off + len, title[i]);
+ len += sprintf(page + off + len, " wrx_correct_pdu = %d\n", WAN_MIB_TABLE[i].wrx_correct_pdu);
+ len += sprintf(page + off + len, " wrx_correct_pdu_bytes = %d\n", WAN_MIB_TABLE[i].wrx_correct_pdu_bytes);
+ len += sprintf(page + off + len, " wrx_tccrc_err_pdu = %d\n", WAN_MIB_TABLE[i].wrx_tccrc_err_pdu);
+ len += sprintf(page + off + len, " wrx_tccrc_err_pdu_bytes = %d\n", WAN_MIB_TABLE[i].wrx_tccrc_err_pdu_bytes);
+ len += sprintf(page + off + len, " wrx_ethcrc_err_pdu = %d\n", WAN_MIB_TABLE[i].wrx_ethcrc_err_pdu);
+ len += sprintf(page + off + len, " wrx_ethcrc_err_pdu_bytes = %d\n", WAN_MIB_TABLE[i].wrx_ethcrc_err_pdu_bytes);
+ len += sprintf(page + off + len, " wrx_nodesc_drop_pdu = %d\n", WAN_MIB_TABLE[i].wrx_nodesc_drop_pdu);
+ len += sprintf(page + off + len, " wrx_len_violation_drop_pdu = %d\n", WAN_MIB_TABLE[i].wrx_len_violation_drop_pdu);
+ len += sprintf(page + off + len, " wrx_idle_bytes = %d\n", WAN_MIB_TABLE[i].wrx_idle_bytes);
+ len += sprintf(page + off + len, " wrx_nonidle_cw = %d\n", WAN_MIB_TABLE[i].wrx_nonidle_cw);
+ len += sprintf(page + off + len, " wrx_idle_cw = %d\n", WAN_MIB_TABLE[i].wrx_idle_cw);
+ len += sprintf(page + off + len, " wrx_err_cw = %d\n", WAN_MIB_TABLE[i].wrx_err_cw);
+ len += sprintf(page + off + len, " wtx_total_pdu = %d\n", WAN_MIB_TABLE[i].wtx_total_pdu);
+ len += sprintf(page + off + len, " wtx_total_bytes = %d\n", WAN_MIB_TABLE[i].wtx_total_bytes);
+ }
+
+ *eof = 1;
+
+ return len;
+}
+
+static int proc_write_wanmib(struct file *file, const char *buf, unsigned long count, void *data)
+{
+ char str[2048];
+ char *p;
+ int len, rlen;
+
+ int i;
+
+ len = count < sizeof(str) ? count : sizeof(str) - 1;
+ rlen = len - copy_from_user(str, buf, len);
+ while ( rlen && str[rlen - 1] <= ' ' )
+ rlen--;
+ str[rlen] = 0;
+ for ( p = str; *p && *p <= ' '; p++, rlen-- );
+ if ( !*p )
+ return count;
+
+ if ( stricmp(p, "clear") == 0 || stricmp(p, "clean") == 0 ) {
+ for ( i = 0; i < 2; i++ )
+ memset((void*)&WAN_MIB_TABLE[i], 0, sizeof(WAN_MIB_TABLE[i]));
+ }
+
+ return count;
+}
+
+#if defined(ENABLE_FW_PROC) && ENABLE_FW_PROC
+
+static int proc_read_genconf(char *page, char **start, off_t off, int count, int *eof, void *data)
+{
+ int len = 0;
+ int len_max = off + count;
+ char *pstr;
+ char str[2048];
+ int llen = 0;
+ int i;
+ unsigned long bit;
+
+ pstr = *start = page;
+
+ __sync();
+
+ llen += sprintf(str + llen, "CFG_WAN_WRDES_DELAY (0x%08X): %d\n", (unsigned int)CFG_WAN_WRDES_DELAY, IFX_REG_R32(CFG_WAN_WRDES_DELAY));
+ llen += sprintf(str + llen, "CFG_WRX_DMACH_ON (0x%08X):", (unsigned int)CFG_WRX_DMACH_ON);
+ for ( i = 0, bit = 1; i < MAX_RX_DMA_CHANNEL_NUMBER; i++, bit <<= 1 )
+ llen += sprintf(str + llen, " %d - %s", i, (IFX_REG_R32(CFG_WRX_DMACH_ON) & bit) ? "on " : "off");
+ llen += sprintf(str + llen, "\n");
+ llen += sprintf(str + llen, "CFG_WTX_DMACH_ON (0x%08X):", (unsigned int)CFG_WTX_DMACH_ON);
+ for ( i = 0, bit = 1; i < MAX_TX_DMA_CHANNEL_NUMBER; i++, bit <<= 1 )
+ llen += sprintf(str + llen, " %d - %s", i, (IFX_REG_R32(CFG_WTX_DMACH_ON) & bit) ? "on " : "off");
+ llen += sprintf(str + llen, "\n");
+ llen += sprintf(str + llen, "CFG_WRX_LOOK_BITTH (0x%08X): %d\n", (unsigned int)CFG_WRX_LOOK_BITTH, IFX_REG_R32(CFG_WRX_LOOK_BITTH));
+ llen += sprintf(str + llen, "CFG_ETH_EFMTC_CRC (0x%08X): rx_tc_crc_len - %2d, rx_tc_crc_check - %s\n", (unsigned int)CFG_ETH_EFMTC_CRC, CFG_ETH_EFMTC_CRC->rx_tc_crc_len, CFG_ETH_EFMTC_CRC->rx_tc_crc_check ? " on" : "off");
+ llen += sprintf(str + llen, " rx_eth_crc_check - %s, rx_eth_crc_present - %s\n", CFG_ETH_EFMTC_CRC->rx_eth_crc_check ? " on" : "off", CFG_ETH_EFMTC_CRC->rx_eth_crc_present ? " on" : "off");
+ llen += sprintf(str + llen, " tx_tc_crc_len - %2d, tx_tc_crc_gen - %s\n", CFG_ETH_EFMTC_CRC->tx_tc_crc_len, CFG_ETH_EFMTC_CRC->tx_tc_crc_gen ? " on" : "off");
+ llen += sprintf(str + llen, " tx_eth_crc_gen - %s\n", CFG_ETH_EFMTC_CRC->tx_eth_crc_gen ? " on" : "off");
+
+ llen += sprintf(str + llen, "RX Port:\n");
+ for ( i = 0; i < MAX_RX_DMA_CHANNEL_NUMBER; i++ )
+ llen += sprintf(str + llen, " %d (0x%08X). mfs - %5d, dmach - %d, local_state - %d, partner_state - %d\n", i, (unsigned int)WRX_PORT_CONFIG(i), WRX_PORT_CONFIG(i)->mfs, WRX_PORT_CONFIG(i)->dmach, WRX_PORT_CONFIG(i)->local_state, WRX_PORT_CONFIG(i)->partner_state);
+ llen += sprintf(str + llen, "RX DMA Channel:\n");
+ for ( i = 0; i < MAX_RX_DMA_CHANNEL_NUMBER; i++ )
+ llen += sprintf(str + llen, " %d (0x%08X). desba - 0x%08X (0x%08X), deslen - %d, vlddes - %d\n", i, (unsigned int)WRX_DMA_CHANNEL_CONFIG(i), WRX_DMA_CHANNEL_CONFIG(i)->desba, ((unsigned int)WRX_DMA_CHANNEL_CONFIG(i)->desba << 2) | KSEG1, WRX_DMA_CHANNEL_CONFIG(i)->deslen, WRX_DMA_CHANNEL_CONFIG(i)->vlddes);
+
+ llen += sprintf(str + llen, "TX Port:\n");
+ for ( i = 0; i < MAX_TX_DMA_CHANNEL_NUMBER; i++ )
+ llen += sprintf(str + llen, " %d (0x%08X). tx_cwth2 - %d, tx_cwth1 - %d\n", i, (unsigned int)WTX_PORT_CONFIG(i), WTX_PORT_CONFIG(i)->tx_cwth2, WTX_PORT_CONFIG(i)->tx_cwth1);
+ llen += sprintf(str + llen, "TX DMA Channel:\n");
+ for ( i = 0; i < MAX_TX_DMA_CHANNEL_NUMBER; i++ )
+ llen += sprintf(str + llen, " %d (0x%08X). desba - 0x%08X (0x%08X), deslen - %d, vlddes - %d\n", i, (unsigned int)WTX_DMA_CHANNEL_CONFIG(i), WTX_DMA_CHANNEL_CONFIG(i)->desba, ((unsigned int)WTX_DMA_CHANNEL_CONFIG(i)->desba << 2) | KSEG1, WTX_DMA_CHANNEL_CONFIG(i)->deslen, WTX_DMA_CHANNEL_CONFIG(i)->vlddes);
+
+ if ( len <= off && len + llen > off )
+ {
+ memcpy(pstr, str + off - len, len + llen - off);
+ pstr += len + llen - off;
+ }
+ else if ( len > off )
+ {
+ memcpy(pstr, str, llen);
+ pstr += llen;
+ }
+ len += llen;
+ if ( len >= len_max )
+ goto PROC_READ_GENCONF_OVERRUN_END;
+
+ *eof = 1;
+
+ return len - off;
+
+PROC_READ_GENCONF_OVERRUN_END:
+ return len - llen - off;
+}
+
+#endif // defined(ENABLE_FW_PROC) && ENABLE_FW_PROC
+
+#if defined(ENABLE_DBG_PROC) && ENABLE_DBG_PROC
+
+static int proc_read_dbg(char *page, char **start, off_t off, int count, int *eof, void *data)
+{
+ int len = 0;
+
+ len += sprintf(page + off + len, "error print - %s\n", (ifx_ptm_dbg_enable & DBG_ENABLE_MASK_ERR) ? "enabled" : "disabled");
+ len += sprintf(page + off + len, "debug print - %s\n", (ifx_ptm_dbg_enable & DBG_ENABLE_MASK_DEBUG_PRINT) ? "enabled" : "disabled");
+ len += sprintf(page + off + len, "assert - %s\n", (ifx_ptm_dbg_enable & DBG_ENABLE_MASK_ASSERT) ? "enabled" : "disabled");
+ len += sprintf(page + off + len, "dump rx skb - %s\n", (ifx_ptm_dbg_enable & DBG_ENABLE_MASK_DUMP_SKB_RX) ? "enabled" : "disabled");
+ len += sprintf(page + off + len, "dump tx skb - %s\n", (ifx_ptm_dbg_enable & DBG_ENABLE_MASK_DUMP_SKB_TX) ? "enabled" : "disabled");
+ len += sprintf(page + off + len, "mac swap - %s\n", (ifx_ptm_dbg_enable & DBG_ENABLE_MASK_MAC_SWAP) ? "enabled" : "disabled");
+
+ *eof = 1;
+
+ return len;
+}
+
+static int proc_write_dbg(struct file *file, const char *buf, unsigned long count, void *data)
+{
+ static const char *dbg_enable_mask_str[] = {
+ " error print",
+ " err",
+ " debug print",
+ " dbg",
+ " assert",
+ " assert",
+ " dump rx skb",
+ " rx",
+ " dump tx skb",
+ " tx",
+ " dump init",
+ " init",
+ " dump qos",
+ " qos",
+ " mac swap",
+ " swap",
+ " all"
+ };
+ static const int dbg_enable_mask_str_len[] = {
+ 12, 4,
+ 12, 4,
+ 7, 7,
+ 12, 3,
+ 12, 3,
+ 10, 5,
+ 9, 4,
+ 9, 5,
+ 4
+ };
+ unsigned int dbg_enable_mask[] = {
+ DBG_ENABLE_MASK_ERR,
+ DBG_ENABLE_MASK_DEBUG_PRINT,
+ DBG_ENABLE_MASK_ASSERT,
+ DBG_ENABLE_MASK_DUMP_SKB_RX,
+ DBG_ENABLE_MASK_DUMP_SKB_TX,
+ DBG_ENABLE_MASK_DUMP_INIT,
+ DBG_ENABLE_MASK_DUMP_QOS,
+ DBG_ENABLE_MASK_MAC_SWAP,
+ DBG_ENABLE_MASK_ALL
+ };
+
+ char str[2048];
+ char *p;
+
+ int len, rlen;
+
+ int f_enable = 0;
+ int i;
+
+ len = count < sizeof(str) ? count : sizeof(str) - 1;
+ rlen = len - copy_from_user(str, buf, len);
+ while ( rlen && str[rlen - 1] <= ' ' )
+ rlen--;
+ str[rlen] = 0;
+ for ( p = str; *p && *p <= ' '; p++, rlen-- );
+ if ( !*p )
+ return 0;
+
+ // debugging feature for enter/leave showtime
+ if ( strincmp(p, "enter", 5) == 0 && ifx_mei_atm_showtime_enter != NULL )
+ ifx_mei_atm_showtime_enter(NULL, NULL);
+ else if ( strincmp(p, "leave", 5) == 0 && ifx_mei_atm_showtime_exit != NULL )
+ ifx_mei_atm_showtime_exit();
+
+ if ( strincmp(p, "enable", 6) == 0 ) {
+ p += 6;
+ f_enable = 1;
+ }
+ else if ( strincmp(p, "disable", 7) == 0 ) {
+ p += 7;
+ f_enable = -1;
+ }
+ else if ( strincmp(p, "help", 4) == 0 || *p == '?' ) {
+ printk("echo <enable/disable> [err/dbg/assert/rx/tx/init/qos/swap/all] > /proc/driver/ifx_ptm/dbg\n");
+ }
+
+ if ( f_enable ) {
+ if ( *p == 0 ) {
+ if ( f_enable > 0 )
+ ifx_ptm_dbg_enable |= DBG_ENABLE_MASK_ALL & ~DBG_ENABLE_MASK_MAC_SWAP;
+ else
+ ifx_ptm_dbg_enable &= ~DBG_ENABLE_MASK_ALL | DBG_ENABLE_MASK_MAC_SWAP;
+ }
+ else {
+ do {
+ for ( i = 0; i < ARRAY_SIZE(dbg_enable_mask_str); i++ )
+ if ( strincmp(p, dbg_enable_mask_str[i], dbg_enable_mask_str_len[i]) == 0 ) {
+ if ( f_enable > 0 )
+ ifx_ptm_dbg_enable |= dbg_enable_mask[i >> 1];
+ else
+ ifx_ptm_dbg_enable &= ~dbg_enable_mask[i >> 1];
+ p += dbg_enable_mask_str_len[i];
+ break;
+ }
+ } while ( i < ARRAY_SIZE(dbg_enable_mask_str) );
+ }
+ }
+
+ return count;
+}
+
+#endif // defined(ENABLE_DBG_PROC) && ENABLE_DBG_PROC
+
+static INLINE int stricmp(const char *p1, const char *p2)
+{
+ int c1, c2;
+
+ while ( *p1 && *p2 )
+ {
+ c1 = *p1 >= 'A' && *p1 <= 'Z' ? *p1 + 'a' - 'A' : *p1;
+ c2 = *p2 >= 'A' && *p2 <= 'Z' ? *p2 + 'a' - 'A' : *p2;
+ if ( (c1 -= c2) )
+ return c1;
+ p1++;
+ p2++;
+ }
+
+ return *p1 - *p2;
+}
+
+#if defined(ENABLE_DBG_PROC) && ENABLE_DBG_PROC
+static INLINE int strincmp(const char *p1, const char *p2, int n)
+{
+ int c1 = 0, c2;
+
+ while ( n && *p1 && *p2 )
+ {
+ c1 = *p1 >= 'A' && *p1 <= 'Z' ? *p1 + 'a' - 'A' : *p1;
+ c2 = *p2 >= 'A' && *p2 <= 'Z' ? *p2 + 'a' - 'A' : *p2;
+ if ( (c1 -= c2) )
+ return c1;
+ p1++;
+ p2++;
+ n--;
+ }
+
+ return n ? *p1 - *p2 : c1;
+}
+#endif
+
+static INLINE int ifx_ptm_version(char *buf)
+{
+ int len = 0;
+ unsigned int major, minor;
+
+ ifx_ptm_get_fw_ver(&major, &minor);
+
+ len += sprintf(buf + len, "PTM %d.%d.%d", IFX_PTM_VER_MAJOR, IFX_PTM_VER_MID, IFX_PTM_VER_MINOR);
+ len += sprintf(buf + len, " PTM (E1) firmware version %d.%d\n", major, minor);
+
+ return len;
+}
+
+static INLINE void check_parameters(void)
+{
+ /* There is a delay between PPE write descriptor and descriptor is */
+ /* really stored in memory. Host also has this delay when writing */
+ /* descriptor. So PPE will use this value to determine if the write */
+ /* operation makes effect. */
+ if ( write_desc_delay < 0 )
+ write_desc_delay = 0;
+
+ /* Because of the limitation of length field in descriptors, the packet */
+ /* size could not be larger than 64K minus overhead size. */
+ if ( rx_max_packet_size < ETH_MIN_FRAME_LENGTH )
+ rx_max_packet_size = ETH_MIN_FRAME_LENGTH;
+ else if ( rx_max_packet_size > 65536 - 1 )
+ rx_max_packet_size = 65536 - 1;
+
+ if ( dma_rx_descriptor_length < 2 )
+ dma_rx_descriptor_length = 2;
+ if ( dma_tx_descriptor_length < 2 )
+ dma_tx_descriptor_length = 2;
+}
+
+static INLINE int init_priv_data(void)
+{
+ void *p;
+ int i;
+ struct rx_descriptor rx_desc = {0};
+ struct sk_buff *skb;
+ volatile struct rx_descriptor *p_rx_desc;
+ volatile struct tx_descriptor *p_tx_desc;
+ struct sk_buff **ppskb;
+
+ // clear ptm private data structure
+ memset(&g_ptm_priv_data, 0, sizeof(g_ptm_priv_data));
+
+ // allocate memory for RX descriptors
+ p = kzalloc(MAX_ITF_NUMBER * dma_rx_descriptor_length * sizeof(struct rx_descriptor) + DESC_ALIGNMENT, GFP_KERNEL);
+ if ( p == NULL )
+ return -1;
+ dma_cache_inv((unsigned long)p, MAX_ITF_NUMBER * dma_rx_descriptor_length * sizeof(struct rx_descriptor) + DESC_ALIGNMENT);
+ g_ptm_priv_data.rx_desc_base = p;
+ //p = (void *)((((unsigned int)p + DESC_ALIGNMENT - 1) & ~(DESC_ALIGNMENT - 1)) | KSEG1);
+
+ // allocate memory for TX descriptors
+ p = kzalloc(MAX_ITF_NUMBER * dma_tx_descriptor_length * sizeof(struct tx_descriptor) + DESC_ALIGNMENT, GFP_KERNEL);
+ if ( p == NULL )
+ return -1;
+ dma_cache_inv((unsigned long)p, MAX_ITF_NUMBER * dma_tx_descriptor_length * sizeof(struct tx_descriptor) + DESC_ALIGNMENT);
+ g_ptm_priv_data.tx_desc_base = p;
+
+ // allocate memroy for TX skb pointers
+ p = kzalloc(MAX_ITF_NUMBER * dma_tx_descriptor_length * sizeof(struct sk_buff *) + 4, GFP_KERNEL);
+ if ( p == NULL )
+ return -1;
+ dma_cache_wback_inv((unsigned long)p, MAX_ITF_NUMBER * dma_tx_descriptor_length * sizeof(struct sk_buff *) + 4);
+ g_ptm_priv_data.tx_skb_base = p;
+
+ p_rx_desc = (volatile struct rx_descriptor *)((((unsigned int)g_ptm_priv_data.rx_desc_base + DESC_ALIGNMENT - 1) & ~(DESC_ALIGNMENT - 1)) | KSEG1);
+ p_tx_desc = (volatile struct tx_descriptor *)((((unsigned int)g_ptm_priv_data.tx_desc_base + DESC_ALIGNMENT - 1) & ~(DESC_ALIGNMENT - 1)) | KSEG1);
+ ppskb = (struct sk_buff **)(((unsigned int)g_ptm_priv_data.tx_skb_base + 3) & ~3);
+ for ( i = 0; i < MAX_ITF_NUMBER; i++ ) {
+ g_ptm_priv_data.itf[i].rx_desc = &p_rx_desc[i * dma_rx_descriptor_length];
+ g_ptm_priv_data.itf[i].tx_desc = &p_tx_desc[i * dma_tx_descriptor_length];
+ g_ptm_priv_data.itf[i].tx_skb = &ppskb[i * dma_tx_descriptor_length];
+ }
+
+ rx_desc.own = 1;
+ rx_desc.c = 0;
+ rx_desc.sop = 1;
+ rx_desc.eop = 1;
+ rx_desc.byteoff = RX_HEAD_MAC_ADDR_ALIGNMENT;
+ rx_desc.id = 0;
+ rx_desc.err = 0;
+ rx_desc.datalen = rx_max_packet_size;
+ for ( i = 0; i < MAX_ITF_NUMBER * dma_rx_descriptor_length; i++ ) {
+ skb = alloc_skb_rx();
+ if ( skb == NULL )
+ return -1;
+ rx_desc.dataptr = ((unsigned int)skb->data >> 2) & 0x0FFFFFFF;
+ p_rx_desc[i] = rx_desc;
+ }
+
+ return 0;
+}
+
+static INLINE void clear_priv_data(void)
+{
+ int i, j;
+ struct sk_buff *skb;
+
+ for ( i = 0; i < MAX_ITF_NUMBER; i++ ) {
+ if ( g_ptm_priv_data.itf[i].tx_skb != NULL ) {
+ for ( j = 0; j < dma_tx_descriptor_length; j++ )
+ if ( g_ptm_priv_data.itf[i].tx_skb[j] != NULL )
+ dev_kfree_skb_any(g_ptm_priv_data.itf[i].tx_skb[j]);
+ }
+ if ( g_ptm_priv_data.itf[i].rx_desc != NULL ) {
+ for ( j = 0; j < dma_rx_descriptor_length; j++ ) {
+ if ( g_ptm_priv_data.itf[i].rx_desc[j].sop || g_ptm_priv_data.itf[i].rx_desc[j].eop ) { // descriptor initialized
+ skb = get_skb_rx_pointer(g_ptm_priv_data.itf[i].rx_desc[j].dataptr);
+ dev_kfree_skb_any(skb);
+ }
+ }
+ }
+ }
+
+ if ( g_ptm_priv_data.rx_desc_base != NULL )
+ kfree(g_ptm_priv_data.rx_desc_base);
+
+ if ( g_ptm_priv_data.tx_desc_base != NULL )
+ kfree(g_ptm_priv_data.tx_desc_base);
+
+ if ( g_ptm_priv_data.tx_skb_base != NULL )
+ kfree(g_ptm_priv_data.tx_skb_base);
+}
+
+static INLINE void init_tables(void)
+{
+ int i;
+ volatile unsigned int *p;
+ struct wrx_dma_channel_config rx_config = {0};
+ struct wtx_dma_channel_config tx_config = {0};
+ struct wrx_port_cfg_status rx_port_cfg = { 0 };
+ struct wtx_port_cfg tx_port_cfg = { 0 };
+
+ /*
+ * CDM Block 1
+ */
+ IFX_REG_W32(CDM_CFG_RAM1_SET(0x00) | CDM_CFG_RAM0_SET(0x00), CDM_CFG); // CDM block 1 must be data memory and mapped to 0x5000 (dword addr)
+ p = CDM_DATA_MEMORY(0, 0); // Clear CDM block 1
+ for ( i = 0; i < CDM_DATA_MEMORY_DWLEN; i++, p++ )
+ IFX_REG_W32(0, p);
+
+ /*
+ * General Registers
+ */
+ IFX_REG_W32(write_desc_delay, CFG_WAN_WRDES_DELAY);
+ IFX_REG_W32((1 << MAX_RX_DMA_CHANNEL_NUMBER) - 1, CFG_WRX_DMACH_ON);
+ IFX_REG_W32((1 << MAX_TX_DMA_CHANNEL_NUMBER) - 1, CFG_WTX_DMACH_ON);
+
+ IFX_REG_W32(8, CFG_WRX_LOOK_BITTH); // WAN RX EFM-TC Looking Threshold
+
+ IFX_REG_W32(eth_efmtc_crc_cfg, CFG_ETH_EFMTC_CRC);
+
+ /*
+ * WRX DMA Channel Configuration Table
+ */
+ rx_config.deslen = dma_rx_descriptor_length;
+ rx_port_cfg.mfs = ETH_MAX_FRAME_LENGTH;
+ rx_port_cfg.local_state = 0; // looking for sync
+ rx_port_cfg.partner_state = 0; // parter receiver is out of sync
+
+ for ( i = 0; i < MAX_RX_DMA_CHANNEL_NUMBER; i++ ) {
+ rx_config.desba = ((unsigned int)g_ptm_priv_data.itf[i].rx_desc >> 2) & 0x0FFFFFFF;
+ *WRX_DMA_CHANNEL_CONFIG(i) = rx_config;
+
+ rx_port_cfg.dmach = i;
+ *WRX_PORT_CONFIG(i) = rx_port_cfg;
+ }
+
+ /*
+ * WTX DMA Channel Configuration Table
+ */
+ tx_config.deslen = dma_tx_descriptor_length;
+ tx_port_cfg.tx_cwth1 = 5;
+ tx_port_cfg.tx_cwth2 = 4;
+
+ for ( i = 0; i < MAX_TX_DMA_CHANNEL_NUMBER; i++ ) {
+ tx_config.desba = ((unsigned int)g_ptm_priv_data.itf[i].tx_desc >> 2) & 0x0FFFFFFF;
+ *WTX_DMA_CHANNEL_CONFIG(i) = tx_config;
+
+ *WTX_PORT_CONFIG(i) = tx_port_cfg;
+ }
+}
+
+
+
+/*
+ * ####################################
+ * Global Function
+ * ####################################
+ */
+
+static int ptm_showtime_enter(struct port_cell_info *port_cell, void *xdata_addr)
+{
+
+ g_showtime = 1;
+
+ printk("enter showtime\n");
+
+ return 0;
+}
+
+static int ptm_showtime_exit(void)
+{
+ if ( !g_showtime )
+ return -1;
+
+ g_showtime = 0;
+
+ printk("leave showtime\n");
+
+ return 0;
+}
+
+
+
+/*
+ * ####################################
+ * Init/Cleanup API
+ * ####################################
+ */
+
+/*
+ * Description:
+ * Initialize global variables, PP32, comunication structures, register IRQ
+ * and register device.
+ * Input:
+ * none
+ * Output:
+ * 0 --- successful
+ * else --- failure, usually it is negative value of error code
+ */
+static int ifx_ptm_init(void)
+{
+ int ret;
+ struct port_cell_info port_cell = {0};
+ void *xdata_addr = NULL;
+ int i;
+ char ver_str[256];
+
+ check_parameters();
+
+ ret = init_priv_data();
+ if ( ret != 0 ) {
+ err("INIT_PRIV_DATA_FAIL");
+ goto INIT_PRIV_DATA_FAIL;
+ }
+
+ ifx_ptm_init_chip();
+ init_tables();
+
+ for ( i = 0; i < ARRAY_SIZE(g_net_dev); i++ ) {
+ g_net_dev[i] = alloc_netdev(0, g_net_dev_name[i], ether_setup);
+ if ( g_net_dev[i] == NULL )
+ goto ALLOC_NETDEV_FAIL;
+ ptm_setup(g_net_dev[i], i);
+ }
+
+ for ( i = 0; i < ARRAY_SIZE(g_net_dev); i++ ) {
+ ret = register_netdev(g_net_dev[i]);
+ if ( ret != 0 )
+ goto REGISTER_NETDEV_FAIL;
+ }
+
+ /* register interrupt handler */
+ ret = request_irq(PPE_MAILBOX_IGU1_INT, mailbox_irq_handler, IRQF_DISABLED, "ptm_mailbox_isr", &g_ptm_priv_data);
+ if ( ret ) {
+ if ( ret == -EBUSY ) {
+ err("IRQ may be occupied by other driver, please reconfig to disable it.");
+ }
+ else {
+ err("request_irq fail");
+ }
+ goto REQUEST_IRQ_PPE_MAILBOX_IGU1_INT_FAIL;
+ }
+ disable_irq(PPE_MAILBOX_IGU1_INT);
+
+ ret = ifx_pp32_start(0);
+ if ( ret ) {
+ err("ifx_pp32_start fail!");
+ goto PP32_START_FAIL;
+ }
+ IFX_REG_W32(0, MBOX_IGU1_IER);
+ IFX_REG_W32(~0, MBOX_IGU1_ISRC);
+
+ enable_irq(PPE_MAILBOX_IGU1_INT);
+
+
+ proc_file_create();
+
+ port_cell.port_num = 1;
+ ifx_mei_atm_showtime_check(&g_showtime, &port_cell, &xdata_addr);
+
+ ifx_mei_atm_showtime_enter = ptm_showtime_enter;
+ ifx_mei_atm_showtime_exit = ptm_showtime_exit;
+
+ ifx_ptm_version(ver_str);
+ printk(KERN_INFO "%s", ver_str);
+
+ printk("ifxmips_ptm: PTM init succeed\n");
+
+ return 0;
+
+PP32_START_FAIL:
+ free_irq(PPE_MAILBOX_IGU1_INT, &g_ptm_priv_data);
+REQUEST_IRQ_PPE_MAILBOX_IGU1_INT_FAIL:
+ i = ARRAY_SIZE(g_net_dev);
+REGISTER_NETDEV_FAIL:
+ while ( i-- )
+ unregister_netdev(g_net_dev[i]);
+ i = ARRAY_SIZE(g_net_dev);
+ALLOC_NETDEV_FAIL:
+ while ( i-- ) {
+ free_netdev(g_net_dev[i]);
+ g_net_dev[i] = NULL;
+ }
+INIT_PRIV_DATA_FAIL:
+ clear_priv_data();
+ printk("ifxmips_ptm: PTM init failed\n");
+ return ret;
+}
+
+/*
+ * Description:
+ * Release memory, free IRQ, and deregister device.
+ * Input:
+ * none
+ * Output:
+ * none
+ */
+static void __exit ifx_ptm_exit(void)
+{
+ int i;
+
+ ifx_mei_atm_showtime_enter = NULL;
+ ifx_mei_atm_showtime_exit = NULL;
+
+ proc_file_delete();
+
+
+ ifx_pp32_stop(0);
+
+ free_irq(PPE_MAILBOX_IGU1_INT, &g_ptm_priv_data);
+
+ for ( i = 0; i < ARRAY_SIZE(g_net_dev); i++ )
+ unregister_netdev(g_net_dev[i]);
+
+ for ( i = 0; i < ARRAY_SIZE(g_net_dev); i++ ) {
+ free_netdev(g_net_dev[i]);
+ g_net_dev[i] = NULL;
+ }
+
+ ifx_ptm_uninit_chip();
+
+ clear_priv_data();
+}
+
+module_init(ifx_ptm_init);
+module_exit(ifx_ptm_exit);
diff --git a/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_adsl.h b/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_adsl.h
new file mode 100644
index 0000000..de307bf
--- /dev/null
+++ b/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_adsl.h
@@ -0,0 +1,137 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_ptm_adsl.h
+** PROJECT : UEIP
+** MODULES : PTM
+**
+** DATE : 7 Jul 2009
+** AUTHOR : Xu Liang
+** DESCRIPTION : PTM driver header file (core functions for Danube/Amazon-SE/
+** AR9)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 17 JUN 2009 Xu Liang Init Version
+*******************************************************************************/
+
+#ifndef IFXMIPS_PTM_ADSL_H
+#define IFXMIPS_PTM_ADSL_H
+
+
+
+#include <linux/version.h>
+#include <linux/netdevice.h>
+#include <lantiq_ptm.h>
+#include "ifxmips_ptm_common.h"
+#include "ifxmips_ptm_ppe_common.h"
+#include "ifxmips_ptm_fw_regs_adsl.h"
+
+#define CONFIG_IFXMIPS_DSL_CPE_MEI
+#define INT_NUM_IM2_IRL24 (INT_NUM_IM2_IRL0 + 24)
+
+#define IFX_REG_W32(_v, _r) __raw_writel((_v), (volatile unsigned int *)(_r))
+#define IFX_REG_R32(_r) __raw_readl((volatile unsigned int *)(_r))
+#define IFX_REG_W32_MASK(_clr, _set, _r) IFX_REG_W32((IFX_REG_R32((_r)) & ~(_clr)) | (_set), (_r))
+#define SET_BITS(x, msb, lsb, value) (((x) & ~(((1 << ((msb) + 1)) - 1) ^ ((1 << (lsb)) - 1))) | (((value) & ((1 << (1 + (msb) - (lsb))) - 1)) << (lsb)))
+
+
+
+
+/*
+ * ####################################
+ * Definition
+ * ####################################
+ */
+
+/*
+ * Constant Definition
+ */
+#define ETH_WATCHDOG_TIMEOUT (2 * HZ)
+
+/*
+ * DMA RX/TX Channel Parameters
+ */
+#define MAX_ITF_NUMBER 2
+#define MAX_RX_DMA_CHANNEL_NUMBER MAX_ITF_NUMBER
+#define MAX_TX_DMA_CHANNEL_NUMBER MAX_ITF_NUMBER
+#define DATA_BUFFER_ALIGNMENT EMA_ALIGNMENT
+#define DESC_ALIGNMENT 8
+
+/*
+ * Ethernet Frame Definitions
+ */
+#define ETH_MAC_HEADER_LENGTH 14
+#define ETH_CRC_LENGTH 4
+#define ETH_MIN_FRAME_LENGTH 64
+#define ETH_MAX_FRAME_LENGTH (1518 + 4 * 2)
+
+/*
+ * RX Frame Definitions
+ */
+#define RX_HEAD_MAC_ADDR_ALIGNMENT 2
+#define RX_TAIL_CRC_LENGTH 0 // PTM firmware does not have ethernet frame CRC
+ // The len in descriptor doesn't include ETH_CRC
+ // because ETH_CRC may not present in some configuration
+
+
+
+/*
+ * ####################################
+ * Data Type
+ * ####################################
+ */
+
+struct ptm_itf {
+ volatile struct rx_descriptor *rx_desc;
+ unsigned int rx_desc_pos;
+
+ volatile struct tx_descriptor *tx_desc;
+ unsigned int tx_desc_pos;
+ struct sk_buff **tx_skb;
+
+ struct net_device_stats stats;
+
+ struct napi_struct napi;
+};
+
+struct ptm_priv_data {
+ struct ptm_itf itf[MAX_ITF_NUMBER];
+
+ void *rx_desc_base;
+ void *tx_desc_base;
+ void *tx_skb_base;
+};
+
+
+
+/*
+ * ####################################
+ * Declaration
+ * ####################################
+ */
+
+extern unsigned int ifx_ptm_dbg_enable;
+
+extern void ifx_ptm_get_fw_ver(unsigned int *major, unsigned int *minor);
+
+extern void ifx_ptm_init_chip(void);
+extern void ifx_ptm_uninit_chip(void);
+
+extern int ifx_pp32_start(int pp32);
+extern void ifx_pp32_stop(int pp32);
+
+extern void ifx_reset_ppe(void);
+
+extern int ifx_ptm_proc_read_regs(char *page, char **start, off_t off, int count, int *eof, void *data);
+
+
+
+#endif // IFXMIPS_PTM_ADSL_H
diff --git a/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_amazon_se.c b/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_amazon_se.c
new file mode 100644
index 0000000..077c900
--- /dev/null
+++ b/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_amazon_se.c
@@ -0,0 +1,322 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_ptm_amazon_se.c
+** PROJECT : UEIP
+** MODULES : PTM
+**
+** DATE : 7 Jul 2009
+** AUTHOR : Xu Liang
+** DESCRIPTION : PTM driver common source file (core functions)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 07 JUL 2009 Xu Liang Init Version
+*******************************************************************************/
+
+
+
+/*
+ * ####################################
+ * Head File
+ * ####################################
+ */
+
+/*
+ * Common Head File
+ */
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/version.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/proc_fs.h>
+#include <linux/init.h>
+#include <linux/ioctl.h>
+#include <asm/delay.h>
+
+/*
+ * Chip Specific Head File
+ */
+#include <asm/ifx/ifx_types.h>
+#include <asm/ifx/ifx_regs.h>
+#include <asm/ifx/common_routines.h>
+#include <asm/ifx/ifx_pmu.h>
+#include <asm/ifx/ifx_rcu.h>
+#include "ifxmips_ptm_adsl.h"
+#include "ifxmips_ptm_fw_amazon_se.h"
+
+
+
+/*
+ * ####################################
+ * Definition
+ * ####################################
+ */
+
+/*
+ * EMA Settings
+ */
+#define EMA_CMD_BUF_LEN 0x0040
+#define EMA_CMD_BASE_ADDR (0x00001580 << 2)
+#define EMA_DATA_BUF_LEN 0x0100
+#define EMA_DATA_BASE_ADDR (0x00000B00 << 2)
+#define EMA_WRITE_BURST 0x2
+#define EMA_READ_BURST 0x2
+
+
+
+/*
+ * ####################################
+ * Declaration
+ * ####################################
+ */
+
+/*
+ * Hardware Init/Uninit Functions
+ */
+static inline void init_pmu(void);
+static inline void uninit_pmu(void);
+static inline void reset_ppe(void);
+static inline void init_ema(void);
+static inline void init_mailbox(void);
+static inline void init_atm_tc(void);
+static inline void clear_share_buffer(void);
+
+
+
+/*
+ * ####################################
+ * Local Variable
+ * ####################################
+ */
+
+
+
+/*
+ * ####################################
+ * Local Function
+ * ####################################
+ */
+
+static inline void init_pmu(void)
+{
+ //*(unsigned long *)0xBF10201C &= ~((1 << 15) | (1 << 13) | (1 << 9));
+ //PPE_TOP_PMU_SETUP(IFX_PMU_ENABLE);
+ PPE_SLL01_PMU_SETUP(IFX_PMU_ENABLE);
+ PPE_TC_PMU_SETUP(IFX_PMU_ENABLE);
+ PPE_EMA_PMU_SETUP(IFX_PMU_ENABLE);
+ //PPE_QSB_PMU_SETUP(IFX_PMU_ENABLE);
+ PPE_TPE_PMU_SETUP(IFX_PMU_ENABLE);
+ DSL_DFE_PMU_SETUP(IFX_PMU_ENABLE);
+}
+
+static inline void uninit_pmu(void)
+{
+ PPE_SLL01_PMU_SETUP(IFX_PMU_DISABLE);
+ PPE_TC_PMU_SETUP(IFX_PMU_DISABLE);
+ PPE_EMA_PMU_SETUP(IFX_PMU_DISABLE);
+ //PPE_QSB_PMU_SETUP(IFX_PMU_DISABLE);
+ PPE_TPE_PMU_SETUP(IFX_PMU_DISABLE);
+ DSL_DFE_PMU_SETUP(IFX_PMU_DISABLE);
+ //PPE_TOP_PMU_SETUP(IFX_PMU_DISABLE);
+}
+
+static inline void reset_ppe(void)
+{
+#ifdef MODULE
+ unsigned int etop_cfg;
+ unsigned int etop_mdio_cfg;
+ unsigned int etop_ig_plen_ctrl;
+ unsigned int enet_mac_cfg;
+
+ etop_cfg = *IFX_PP32_ETOP_CFG;
+ etop_mdio_cfg = *IFX_PP32_ETOP_MDIO_CFG;
+ etop_ig_plen_ctrl = *IFX_PP32_ETOP_IG_PLEN_CTRL;
+ enet_mac_cfg = *IFX_PP32_ENET_MAC_CFG;
+
+ *IFX_PP32_ETOP_CFG = (*IFX_PP32_ETOP_CFG & ~0x03C0) | 0x0001;
+
+ // reset PPE
+ ifx_rcu_rst(IFX_RCU_DOMAIN_PPE, IFX_RCU_MODULE_PTM);
+
+ *IFX_PP32_ETOP_MDIO_CFG = etop_mdio_cfg;
+ *IFX_PP32_ETOP_IG_PLEN_CTRL = etop_ig_plen_ctrl;
+ *IFX_PP32_ENET_MAC_CFG = enet_mac_cfg;
+ *IFX_PP32_ETOP_CFG = etop_cfg;
+#endif
+}
+
+static inline void init_ema(void)
+{
+ // Configure share buffer master selection
+ *SB_MST_PRI0 = 1;
+ *SB_MST_PRI1 = 1;
+
+ // EMA Settings
+ IFX_REG_W32((EMA_CMD_BUF_LEN << 16) | (EMA_CMD_BASE_ADDR >> 2), EMA_CMDCFG);
+ IFX_REG_W32((EMA_DATA_BUF_LEN << 16) | (EMA_DATA_BASE_ADDR >> 2), EMA_DATACFG);
+ IFX_REG_W32(0x000000FF, EMA_IER);
+ IFX_REG_W32(EMA_READ_BURST | (EMA_WRITE_BURST << 2), EMA_CFG);
+}
+
+static inline void init_mailbox(void)
+{
+ IFX_REG_W32(0xFFFFFFFF, MBOX_IGU1_ISRC);
+ IFX_REG_W32(0x00000000, MBOX_IGU1_IER);
+ IFX_REG_W32(0xFFFFFFFF, MBOX_IGU3_ISRC);
+ IFX_REG_W32(0x00000000, MBOX_IGU3_IER);
+}
+
+static inline void init_atm_tc(void)
+{
+ IFX_REG_W32(0x0F00, DREG_AT_CTRL);
+ IFX_REG_W32(0x3C00, DREG_AR_CTRL);
+ IFX_REG_W32(0x0, DREG_AT_IDLE0);
+ IFX_REG_W32(0x0, DREG_AT_IDLE1);
+ IFX_REG_W32(0x0, DREG_AR_IDLE0);
+ IFX_REG_W32(0x0, DREG_AR_IDLE1);
+ IFX_REG_W32(0x0, RFBI_CFG);
+ IFX_REG_W32(0x0200, SFSM_DBA0);
+ IFX_REG_W32(0x0800, SFSM_DBA1);
+ IFX_REG_W32(0x0321, SFSM_CBA0);
+ IFX_REG_W32(0x0921, SFSM_CBA1);
+ IFX_REG_W32(0x14011, SFSM_CFG0);
+ IFX_REG_W32(0x14011, SFSM_CFG1);
+ IFX_REG_W32(0x0332, FFSM_DBA0);
+ IFX_REG_W32(0x0932, FFSM_DBA1);
+ IFX_REG_W32(0x3000C, FFSM_CFG0);
+ IFX_REG_W32(0x3000C, FFSM_CFG1);
+ IFX_REG_W32(0xF0D10000, FFSM_IDLE_HEAD_BC0);
+ IFX_REG_W32(0xF0D10000, FFSM_IDLE_HEAD_BC1);
+}
+
+static inline void clear_share_buffer(void)
+{
+ volatile u32 *p = SB_RAM0_ADDR(0);
+ unsigned int i;
+
+ for ( i = 0; i < SB_RAM0_DWLEN + SB_RAM1_DWLEN; i++ )
+ IFX_REG_W32(0, p++);
+}
+
+/*
+ * Description:
+ * Download PPE firmware binary code.
+ * Input:
+ * src --- u32 *, binary code buffer
+ * dword_len --- unsigned int, binary code length in DWORD (32-bit)
+ * Output:
+ * int --- 0: Success
+ * else: Error Code
+ */
+static inline int pp32_download_code(u32 *code_src, unsigned int code_dword_len, u32 *data_src, unsigned int data_dword_len)
+{
+ volatile u32 *dest;
+
+ if ( code_src == 0 || ((unsigned long)code_src & 0x03) != 0
+ || data_src == 0 || ((unsigned long)data_src & 0x03) != 0 )
+ return -1;
+
+ if ( code_dword_len <= CDM_CODE_MEMORYn_DWLEN(0) )
+ IFX_REG_W32(0x00, CDM_CFG);
+ else
+ IFX_REG_W32(0x04, CDM_CFG);
+
+ /* copy code */
+ dest = CDM_CODE_MEMORY(0, 0);
+ while ( code_dword_len-- > 0 )
+ IFX_REG_W32(*code_src++, dest++);
+
+ /* copy data */
+ dest = CDM_DATA_MEMORY(0, 0);
+ while ( data_dword_len-- > 0 )
+ IFX_REG_W32(*data_src++, dest++);
+
+ return 0;
+}
+
+
+
+/*
+ * ####################################
+ * Global Function
+ * ####################################
+ */
+
+extern void ifx_ptm_get_fw_ver(unsigned int *major, unsigned int *minor)
+{
+ ASSERT(major != NULL, "pointer is NULL");
+ ASSERT(minor != NULL, "pointer is NULL");
+
+ *major = FW_VER_ID->major;
+ *minor = FW_VER_ID->minor;
+}
+
+void ifx_ptm_init_chip(void)
+{
+ init_pmu();
+
+ reset_ppe();
+
+ init_ema();
+
+ init_mailbox();
+
+ init_atm_tc();
+
+ clear_share_buffer();
+}
+
+void ifx_ptm_uninit_chip(void)
+{
+ uninit_pmu();
+}
+
+/*
+ * Description:
+ * Initialize and start up PP32.
+ * Input:
+ * none
+ * Output:
+ * int --- 0: Success
+ * else: Error Code
+ */
+int ifx_pp32_start(int pp32)
+{
+ int ret;
+
+ /* download firmware */
+ ret = pp32_download_code(firmware_binary_code, sizeof(firmware_binary_code) / sizeof(*firmware_binary_code), firmware_binary_data, sizeof(firmware_binary_data) / sizeof(*firmware_binary_data));
+ if ( ret != 0 )
+ return ret;
+
+ /* run PP32 */
+ IFX_REG_W32(DBG_CTRL_RESTART, PP32_DBG_CTRL(pp32));
+
+ /* idle for a while to let PP32 init itself */
+ udelay(10);
+
+ return 0;
+}
+
+/*
+ * Description:
+ * Halt PP32.
+ * Input:
+ * none
+ * Output:
+ * none
+ */
+void ifx_pp32_stop(int pp32)
+{
+ /* halt PP32 */
+ IFX_REG_W32(DBG_CTRL_STOP, PP32_DBG_CTRL(pp32));
+}
diff --git a/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_ar9.c b/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_ar9.c
new file mode 100644
index 0000000..777d5cf
--- /dev/null
+++ b/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_ar9.c
@@ -0,0 +1,376 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_ptm_ar9.c
+** PROJECT : UEIP
+** MODULES : PTM
+**
+** DATE : 7 Jul 2009
+** AUTHOR : Xu Liang
+** DESCRIPTION : PTM driver common source file (core functions)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 07 JUL 2009 Xu Liang Init Version
+*******************************************************************************/
+
+
+
+/*
+ * ####################################
+ * Head File
+ * ####################################
+ */
+
+/*
+ * Common Head File
+ */
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/version.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/proc_fs.h>
+#include <linux/init.h>
+#include <linux/ioctl.h>
+#include <asm/delay.h>
+
+/*
+ * Chip Specific Head File
+ */
+#include "ifxmips_ptm_adsl.h"
+#include "ifxmips_ptm_fw_ar9.h"
+
+#include <lantiq_soc.h>
+
+
+/*
+ * ####################################
+ * Definition
+ * ####################################
+ */
+
+/*
+ * EMA Settings
+ */
+#define EMA_CMD_BUF_LEN 0x0040
+#define EMA_CMD_BASE_ADDR (0x00001B80 << 2)
+#define EMA_DATA_BUF_LEN 0x0100
+#define EMA_DATA_BASE_ADDR (0x00001C00 << 2)
+#define EMA_WRITE_BURST 0x2
+#define EMA_READ_BURST 0x2
+
+
+
+/*
+ * ####################################
+ * Declaration
+ * ####################################
+ */
+
+/*
+ * Hardware Init/Uninit Functions
+ */
+static inline void init_pmu(void);
+static inline void uninit_pmu(void);
+static inline void reset_ppe(void);
+static inline void init_ema(void);
+static inline void init_mailbox(void);
+static inline void init_atm_tc(void);
+static inline void clear_share_buffer(void);
+
+
+
+/*
+ * ####################################
+ * Local Variable
+ * ####################################
+ */
+
+
+
+/*
+ * ####################################
+ * Local Function
+ * ####################################
+ */
+
+#define IFX_PMU_MODULE_PPE_SLL01 BIT(19)
+#define IFX_PMU_MODULE_PPE_TC BIT(21)
+#define IFX_PMU_MODULE_PPE_EMA BIT(22)
+#define IFX_PMU_MODULE_PPE_QSB BIT(18)
+#define IFX_PMU_MODULE_TPE BIT(13)
+#define IFX_PMU_MODULE_DSL_DFE BIT(9)
+
+
+static inline void init_pmu(void)
+{
+ ltq_pmu_enable(IFX_PMU_MODULE_PPE_SLL01 |
+ IFX_PMU_MODULE_PPE_TC |
+ IFX_PMU_MODULE_PPE_EMA |
+ IFX_PMU_MODULE_TPE |
+ IFX_PMU_MODULE_DSL_DFE);
+
+}
+
+static inline void uninit_pmu(void)
+{
+ ltq_pmu_disable(IFX_PMU_MODULE_PPE_SLL01 |
+ IFX_PMU_MODULE_PPE_TC |
+ IFX_PMU_MODULE_PPE_EMA |
+ IFX_PMU_MODULE_TPE |
+ IFX_PMU_MODULE_DSL_DFE);
+
+}
+
+static inline void reset_ppe(void)
+{
+#ifdef MODULE
+ // reset PPE
+// ifx_rcu_rst(IFX_RCU_DOMAIN_PPE, IFX_RCU_MODULE_PTM);
+#endif
+}
+
+static inline void init_ema(void)
+{
+ // Configure share buffer master selection
+ IFX_REG_W32(1, SB_MST_PRI0);
+ IFX_REG_W32(1, SB_MST_PRI1);
+
+ // EMA Settings
+ IFX_REG_W32((EMA_CMD_BUF_LEN << 16) | (EMA_CMD_BASE_ADDR >> 2), EMA_CMDCFG);
+ IFX_REG_W32((EMA_DATA_BUF_LEN << 16) | (EMA_DATA_BASE_ADDR >> 2), EMA_DATACFG);
+ IFX_REG_W32(0x000000FF, EMA_IER);
+ IFX_REG_W32(EMA_READ_BURST | (EMA_WRITE_BURST << 2), EMA_CFG);
+}
+
+static inline void init_mailbox(void)
+{
+ IFX_REG_W32(0xFFFFFFFF, MBOX_IGU1_ISRC);
+ IFX_REG_W32(0x00000000, MBOX_IGU1_IER);
+ IFX_REG_W32(0xFFFFFFFF, MBOX_IGU3_ISRC);
+ IFX_REG_W32(0x00000000, MBOX_IGU3_IER);
+}
+
+static inline void init_atm_tc(void)
+{
+ IFX_REG_W32(0x0, RFBI_CFG);
+ IFX_REG_W32(0x1800, SFSM_DBA0);
+ IFX_REG_W32(0x1921, SFSM_DBA1);
+ IFX_REG_W32(0x1A42, SFSM_CBA0);
+ IFX_REG_W32(0x1A53, SFSM_CBA1);
+ IFX_REG_W32(0x14011, SFSM_CFG0);
+ IFX_REG_W32(0x14011, SFSM_CFG1);
+ IFX_REG_W32(0x1000, FFSM_DBA0);
+ IFX_REG_W32(0x1700, FFSM_DBA1);
+ IFX_REG_W32(0x3000C, FFSM_CFG0);
+ IFX_REG_W32(0x3000C, FFSM_CFG1);
+ IFX_REG_W32(0xF0D10000, FFSM_IDLE_HEAD_BC0);
+ IFX_REG_W32(0xF0D10000, FFSM_IDLE_HEAD_BC1);
+
+ /*
+ * 0. Backup port2 value to temp
+ * 1. Disable CPU port2 in switch (link and learning)
+ * 2. wait for a while
+ * 3. Configure DM register and counter
+ * 4. restore temp to CPU port2 in switch
+ * This code will cause network to stop working if there are heavy
+ * traffic during bootup. This part should be moved to switch and use
+ * the same code as ATM
+ */
+ {
+ int i;
+ u32 temp;
+
+ temp = IFX_REG_R32(SW_P2_CTL);
+
+ IFX_REG_W32(0x40020000, SW_P2_CTL);
+ for (i = 0; i < 200; i++)
+ udelay(2000);
+
+ IFX_REG_W32(0x00007028, DM_RXCFG);
+ IFX_REG_W32(0x00007028, DS_RXCFG);
+
+ IFX_REG_W32(0x00001100, DM_RXDB);
+ IFX_REG_W32(0x00001100, DS_RXDB);
+
+ IFX_REG_W32(0x00001600, DM_RXCB);
+ IFX_REG_W32(0x00001600, DS_RXCB);
+
+ /*
+ * For dynamic, must reset these counters,
+ * For once initialization, don't need to reset these counters
+ */
+ IFX_REG_W32(0x0, DM_RXPGCNT);
+ IFX_REG_W32(0x0, DS_RXPGCNT);
+ IFX_REG_W32(0x0, DM_RXPKTCNT);
+
+ IFX_REG_W32_MASK(0, 0x80000000, DM_RXCFG);
+ IFX_REG_W32_MASK(0, 0x8000, DS_RXCFG);
+
+ udelay(2000);
+ IFX_REG_W32(temp, SW_P2_CTL);
+ udelay(2000);
+ }
+}
+
+static inline void clear_share_buffer(void)
+{
+ volatile u32 *p = SB_RAM0_ADDR(0);
+ unsigned int i;
+
+ for ( i = 0; i < SB_RAM0_DWLEN + SB_RAM1_DWLEN + SB_RAM2_DWLEN + SB_RAM3_DWLEN + SB_RAM4_DWLEN; i++ )
+ IFX_REG_W32(0, p++);
+}
+
+/*
+ * Description:
+ * Download PPE firmware binary code.
+ * Input:
+ * src --- u32 *, binary code buffer
+ * dword_len --- unsigned int, binary code length in DWORD (32-bit)
+ * Output:
+ * int --- 0: Success
+ * else: Error Code
+ */
+static inline int pp32_download_code(u32 *code_src, unsigned int code_dword_len, u32 *data_src, unsigned int data_dword_len)
+{
+ volatile u32 *dest;
+
+ if ( code_src == 0 || ((unsigned long)code_src & 0x03) != 0
+ || data_src == 0 || ((unsigned long)data_src & 0x03) != 0 )
+ return -1;
+
+ if ( code_dword_len <= CDM_CODE_MEMORYn_DWLEN(0) )
+ IFX_REG_W32(0x00, CDM_CFG);
+ else
+ IFX_REG_W32(0x04, CDM_CFG);
+
+ /* copy code */
+ dest = CDM_CODE_MEMORY(0, 0);
+ while ( code_dword_len-- > 0 )
+ IFX_REG_W32(*code_src++, dest++);
+
+ /* copy data */
+ dest = CDM_DATA_MEMORY(0, 0);
+ while ( data_dword_len-- > 0 )
+ IFX_REG_W32(*data_src++, dest++);
+
+ return 0;
+}
+
+
+
+/*
+ * ####################################
+ * Global Function
+ * ####################################
+ */
+
+void ifx_ptm_get_fw_ver(unsigned int *major, unsigned int *minor)
+{
+ ASSERT(major != NULL, "pointer is NULL");
+ ASSERT(minor != NULL, "pointer is NULL");
+
+ *major = FW_VER_ID->major;
+ *minor = FW_VER_ID->minor;
+}
+
+void ifx_ptm_init_chip(void)
+{
+ init_pmu();
+
+ reset_ppe();
+
+ init_ema();
+
+ init_mailbox();
+
+ init_atm_tc();
+
+ clear_share_buffer();
+}
+
+void ifx_ptm_uninit_chip(void)
+{
+ uninit_pmu();
+}
+
+/*
+ * Description:
+ * Initialize and start up PP32.
+ * Input:
+ * none
+ * Output:
+ * int --- 0: Success
+ * else: Error Code
+ */
+int ifx_pp32_start(int pp32)
+{
+ int ret;
+
+ /* download firmware */
+ ret = pp32_download_code(firmware_binary_code, sizeof(firmware_binary_code) / sizeof(*firmware_binary_code), firmware_binary_data, sizeof(firmware_binary_data) / sizeof(*firmware_binary_data));
+ if ( ret != 0 )
+ return ret;
+
+ /* run PP32 */
+ IFX_REG_W32(DBG_CTRL_RESTART, PP32_DBG_CTRL(0));
+
+ /* idle for a while to let PP32 init itself */
+ udelay(10);
+
+ return 0;
+}
+
+/*
+ * Description:
+ * Halt PP32.
+ * Input:
+ * none
+ * Output:
+ * none
+ */
+void ifx_pp32_stop(int pp32)
+{
+ /* halt PP32 */
+ IFX_REG_W32(DBG_CTRL_STOP, PP32_DBG_CTRL(0));
+}
+
+int ifx_ptm_proc_read_regs(char *page, char **start, off_t off, int count, int *eof, void *data)
+{
+ int len = 0;
+
+ len += sprintf(page + off + len, "EMA:\n");
+ len += sprintf(page + off + len, " SB_MST_PRI0 - 0x%08X, SB_MST_PRI1 - 0x%08X\n", IFX_REG_R32(SB_MST_PRI0), IFX_REG_R32(SB_MST_PRI1));
+ len += sprintf(page + off + len, " EMA_CMDCFG - 0x%08X, EMA_DATACFG - 0x%08X\n", IFX_REG_R32(EMA_CMDCFG), IFX_REG_R32(EMA_DATACFG));
+ len += sprintf(page + off + len, " EMA_IER - 0x%08X, EMA_CFG - 0x%08X\n", IFX_REG_R32(EMA_IER), IFX_REG_R32(EMA_CFG));
+
+ len += sprintf(page + off + len, "Mailbox:\n");
+ len += sprintf(page + off + len, " MBOX_IGU1_IER - 0x%08X, MBOX_IGU1_ISR - 0x%08X\n", IFX_REG_R32(MBOX_IGU1_IER), IFX_REG_R32(MBOX_IGU1_ISR));
+ len += sprintf(page + off + len, " MBOX_IGU3_IER - 0x%08X, MBOX_IGU3_ISR - 0x%08X\n", IFX_REG_R32(MBOX_IGU3_IER), IFX_REG_R32(MBOX_IGU3_ISR));
+
+ len += sprintf(page + off + len, "TC:\n");
+ len += sprintf(page + off + len, " RFBI_CFG - 0x%08X\n", IFX_REG_R32(RFBI_CFG));
+ len += sprintf(page + off + len, " SFSM_DBA0 - 0x%08X, SFSM_CBA0 - 0x%08X, SFSM_CFG0 - 0x%08X\n", IFX_REG_R32(SFSM_DBA0), IFX_REG_R32(SFSM_CBA0), IFX_REG_R32(SFSM_CFG0));
+ len += sprintf(page + off + len, " SFSM_DBA1 - 0x%08X, SFSM_CBA1 - 0x%08X, SFSM_CFG1 - 0x%08X\n", IFX_REG_R32(SFSM_DBA1), IFX_REG_R32(SFSM_CBA1), IFX_REG_R32(SFSM_CFG1));
+ len += sprintf(page + off + len, " FFSM_DBA0 - 0x%08X, FFSM_CFG0 - 0x%08X, IDLE_HEAD - 0x%08X\n", IFX_REG_R32(FFSM_DBA0), IFX_REG_R32(FFSM_CFG0), IFX_REG_R32(FFSM_IDLE_HEAD_BC0));
+ len += sprintf(page + off + len, " FFSM_DBA1 - 0x%08X, FFSM_CFG1 - 0x%08X, IDLE_HEAD - 0x%08X\n", IFX_REG_R32(FFSM_DBA1), IFX_REG_R32(FFSM_CFG1), IFX_REG_R32(FFSM_IDLE_HEAD_BC1));
+
+ len += sprintf(page + off + len, "DPlus:\n");
+ len += sprintf(page + off + len, " DM_RXDB - 0x%08X, DM_RXCB - 0x%08X, DM_RXCFG - 0x%08X\n", IFX_REG_R32(DM_RXDB), IFX_REG_R32(DM_RXCB), IFX_REG_R32(DM_RXCFG));
+ len += sprintf(page + off + len, " DM_RXPGCNT - 0x%08X, DM_RXPKTCNT - 0x%08X\n", IFX_REG_R32(DM_RXPGCNT), IFX_REG_R32(DM_RXPKTCNT));
+ len += sprintf(page + off + len, " DS_RXDB - 0x%08X, DS_RXCB - 0x%08X, DS_RXCFG - 0x%08X\n", IFX_REG_R32(DS_RXDB), IFX_REG_R32(DS_RXCB), IFX_REG_R32(DS_RXCFG));
+ len += sprintf(page + off + len, " DS_RXPGCNT - 0x%08X\n", IFX_REG_R32(DS_RXPGCNT));
+
+ *eof = 1;
+
+ return len;
+}
diff --git a/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_common.h b/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_common.h
new file mode 100644
index 0000000..ccd19b1
--- /dev/null
+++ b/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_common.h
@@ -0,0 +1,102 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_ptm_common.h
+** PROJECT : UEIP
+** MODULES : PTM
+**
+** DATE : 7 Jul 2009
+** AUTHOR : Xu Liang
+** DESCRIPTION : PTM driver header file (common definitions)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 17 JUN 2009 Xu Liang Init Version
+*******************************************************************************/
+
+#ifndef IFXMIPS_PTM_COMMON_H
+#define IFXMIPS_PTM_COMMON_H
+
+
+
+/*
+ * ####################################
+ * Version No.
+ * ####################################
+ */
+
+#define IFX_PTM_VER_MAJOR 1
+#define IFX_PTM_VER_MID 0
+#define IFX_PTM_VER_MINOR 27
+
+
+
+/*
+ * ####################################
+ * Definition
+ * ####################################
+ */
+
+/*
+ * Compile Options
+ */
+
+#define ENABLE_DEBUG 1
+
+#define ENABLE_ASSERT 1
+
+#define INLINE
+
+#define DEBUG_DUMP_SKB 1
+
+#define DEBUG_QOS 1
+
+#define ENABLE_DBG_PROC 1
+
+#define ENABLE_FW_PROC 1
+
+#if defined(CONFIG_DSL_MEI_CPE_DRV) && !defined(CONFIG_IFXMIPS_DSL_CPE_MEI)
+ #define CONFIG_IFXMIPS_DSL_CPE_MEI 1
+#endif
+
+/*
+ * Debug/Assert/Error Message
+ */
+
+#define DBG_ENABLE_MASK_ERR (1 << 0)
+#define DBG_ENABLE_MASK_DEBUG_PRINT (1 << 1)
+#define DBG_ENABLE_MASK_ASSERT (1 << 2)
+#define DBG_ENABLE_MASK_DUMP_SKB_RX (1 << 8)
+#define DBG_ENABLE_MASK_DUMP_SKB_TX (1 << 9)
+#define DBG_ENABLE_MASK_DUMP_QOS (1 << 10)
+#define DBG_ENABLE_MASK_DUMP_INIT (1 << 11)
+#define DBG_ENABLE_MASK_MAC_SWAP (1 << 12)
+#define DBG_ENABLE_MASK_ALL (DBG_ENABLE_MASK_ERR | DBG_ENABLE_MASK_DEBUG_PRINT | DBG_ENABLE_MASK_ASSERT | DBG_ENABLE_MASK_DUMP_SKB_RX | DBG_ENABLE_MASK_DUMP_SKB_TX | DBG_ENABLE_MASK_DUMP_QOS | DBG_ENABLE_MASK_DUMP_INIT | DBG_ENABLE_MASK_MAC_SWAP)
+
+#define err(format, arg...) do { if ( (ifx_ptm_dbg_enable & DBG_ENABLE_MASK_ERR) ) printk(KERN_ERR __FILE__ ":%d:%s: " format "\n", __LINE__, __FUNCTION__, ##arg); } while ( 0 )
+
+#if defined(ENABLE_DEBUG) && ENABLE_DEBUG
+ #undef dbg
+ #define dbg(format, arg...) do { if ( (ifx_ptm_dbg_enable & DBG_ENABLE_MASK_DEBUG_PRINT) ) printk(KERN_WARNING __FILE__ ":%d:%s: " format "\n", __LINE__, __FUNCTION__, ##arg); } while ( 0 )
+#else
+ #if !defined(dbg)
+ #define dbg(format, arg...)
+ #endif
+#endif
+
+#if defined(ENABLE_ASSERT) && ENABLE_ASSERT
+ #define ASSERT(cond, format, arg...) do { if ( (ifx_ptm_dbg_enable & DBG_ENABLE_MASK_ASSERT) && !(cond) ) printk(KERN_ERR __FILE__ ":%d:%s: " format "\n", __LINE__, __FUNCTION__, ##arg); } while ( 0 )
+#else
+ #define ASSERT(cond, format, arg...)
+#endif
+
+
+
+#endif // IFXMIPS_PTM_COMMON_H
diff --git a/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_danube.c b/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_danube.c
new file mode 100644
index 0000000..279b03b
--- /dev/null
+++ b/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_danube.c
@@ -0,0 +1,317 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_ptm_danube.c
+** PROJECT : UEIP
+** MODULES : PTM
+**
+** DATE : 7 Jul 2009
+** AUTHOR : Xu Liang
+** DESCRIPTION : PTM driver common source file (core functions)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 07 JUL 2009 Xu Liang Init Version
+*******************************************************************************/
+
+
+
+/*
+ * ####################################
+ * Head File
+ * ####################################
+ */
+
+/*
+ * Common Head File
+ */
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/version.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/proc_fs.h>
+#include <linux/init.h>
+#include <linux/ioctl.h>
+#include <linux/delay.h>
+
+/*
+ * Chip Specific Head File
+ */
+#include "ifxmips_ptm_adsl.h"
+#include "ifxmips_ptm_fw_danube.h"
+
+#include <lantiq_soc.h>
+
+/*
+ * ####################################
+ * Definition
+ * ####################################
+ */
+
+/*
+ * EMA Settings
+ */
+#define EMA_CMD_BUF_LEN 0x0040
+#define EMA_CMD_BASE_ADDR (0x00001580 << 2)
+#define EMA_DATA_BUF_LEN 0x0100
+#define EMA_DATA_BASE_ADDR (0x00000B00 << 2)
+#define EMA_WRITE_BURST 0x2
+#define EMA_READ_BURST 0x2
+
+
+
+/*
+ * ####################################
+ * Declaration
+ * ####################################
+ */
+
+/*
+ * Hardware Init/Uninit Functions
+ */
+static inline void init_pmu(void);
+static inline void uninit_pmu(void);
+static inline void reset_ppe(void);
+static inline void init_ema(void);
+static inline void init_mailbox(void);
+static inline void init_atm_tc(void);
+static inline void clear_share_buffer(void);
+
+
+
+/*
+ * ####################################
+ * Local Variable
+ * ####################################
+ */
+
+
+#define IFX_PMU_MODULE_PPE_SLL01 BIT(19)
+#define IFX_PMU_MODULE_PPE_TC BIT(21)
+#define IFX_PMU_MODULE_PPE_EMA BIT(22)
+#define IFX_PMU_MODULE_PPE_QSB BIT(18)
+#define IFX_PMU_MODULE_TPE BIT(13)
+#define IFX_PMU_MODULE_DSL_DFE BIT(9)
+
+/*
+ * ####################################
+ * Local Function
+ * ####################################
+ */
+
+static inline void init_pmu(void)
+{
+ ltq_pmu_enable(IFX_PMU_MODULE_PPE_SLL01 |
+ IFX_PMU_MODULE_PPE_TC |
+ IFX_PMU_MODULE_PPE_EMA |
+ IFX_PMU_MODULE_TPE |
+ IFX_PMU_MODULE_DSL_DFE);
+}
+
+static inline void uninit_pmu(void)
+{
+ ltq_pmu_disable(IFX_PMU_MODULE_PPE_SLL01 |
+ IFX_PMU_MODULE_PPE_TC |
+ IFX_PMU_MODULE_PPE_EMA |
+ IFX_PMU_MODULE_TPE |
+ IFX_PMU_MODULE_DSL_DFE);
+}
+
+static inline void reset_ppe(void)
+{
+#ifdef MODULE
+ /*unsigned int etop_cfg;
+ unsigned int etop_mdio_cfg;
+ unsigned int etop_ig_plen_ctrl;
+ unsigned int enet_mac_cfg;
+
+ etop_cfg = *IFX_PP32_ETOP_CFG;
+ etop_mdio_cfg = *IFX_PP32_ETOP_MDIO_CFG;
+ etop_ig_plen_ctrl = *IFX_PP32_ETOP_IG_PLEN_CTRL;
+ enet_mac_cfg = *IFX_PP32_ENET_MAC_CFG;
+
+ *IFX_PP32_ETOP_CFG &= ~0x03C0;
+
+ // reset PPE
+ ifx_rcu_rst(IFX_RCU_DOMAIN_PPE, IFX_RCU_MODULE_PTM);
+
+ *IFX_PP32_ETOP_MDIO_CFG = etop_mdio_cfg;
+ *IFX_PP32_ETOP_IG_PLEN_CTRL = etop_ig_plen_ctrl;
+ *IFX_PP32_ENET_MAC_CFG = enet_mac_cfg;
+ *IFX_PP32_ETOP_CFG = etop_cfg;*/
+#endif
+}
+
+static inline void init_ema(void)
+{
+ // Configure share buffer master selection
+ *SB_MST_SEL |= 0x03;
+
+ // EMA Settings
+ IFX_REG_W32((EMA_CMD_BUF_LEN << 16) | (EMA_CMD_BASE_ADDR >> 2), EMA_CMDCFG);
+ IFX_REG_W32((EMA_DATA_BUF_LEN << 16) | (EMA_DATA_BASE_ADDR >> 2), EMA_DATACFG);
+ IFX_REG_W32(0x000000FF, EMA_IER);
+ IFX_REG_W32(EMA_READ_BURST | (EMA_WRITE_BURST << 2), EMA_CFG);
+}
+
+static inline void init_mailbox(void)
+{
+ IFX_REG_W32(0xFFFFFFFF, MBOX_IGU1_ISRC);
+ IFX_REG_W32(0x00000000, MBOX_IGU1_IER);
+ IFX_REG_W32(0xFFFFFFFF, MBOX_IGU3_ISRC);
+ IFX_REG_W32(0x00000000, MBOX_IGU3_IER);
+}
+
+static inline void init_atm_tc(void)
+{
+ IFX_REG_W32(0x0F00, DREG_AT_CTRL);
+ IFX_REG_W32(0x3C00, DREG_AR_CTRL);
+ IFX_REG_W32(0x0, DREG_AT_IDLE0);
+ IFX_REG_W32(0x0, DREG_AT_IDLE1);
+ IFX_REG_W32(0x0, DREG_AR_IDLE0);
+ IFX_REG_W32(0x0, DREG_AR_IDLE1);
+ IFX_REG_W32(0x0, RFBI_CFG);
+ IFX_REG_W32(0x1600, SFSM_DBA0);
+ IFX_REG_W32(0x1721, SFSM_DBA1);
+ IFX_REG_W32(0x1842, SFSM_CBA0);
+ IFX_REG_W32(0x1853, SFSM_CBA1);
+ IFX_REG_W32(0x14011, SFSM_CFG0);
+ IFX_REG_W32(0x14011, SFSM_CFG1);
+ IFX_REG_W32(0x1864, FFSM_DBA0);
+ IFX_REG_W32(0x1930, FFSM_DBA1);
+ IFX_REG_W32(0x3000C, FFSM_CFG0);
+ IFX_REG_W32(0x3000C, FFSM_CFG1);
+ IFX_REG_W32(0xF0D10000, FFSM_IDLE_HEAD_BC0);
+ IFX_REG_W32(0xF0D10000, FFSM_IDLE_HEAD_BC1);
+}
+
+static inline void clear_share_buffer(void)
+{
+ volatile u32 *p = SB_RAM0_ADDR(0);
+ unsigned int i;
+
+ for ( i = 0; i < SB_RAM0_DWLEN + SB_RAM1_DWLEN + SB_RAM2_DWLEN + SB_RAM3_DWLEN; i++ )
+ IFX_REG_W32(0, p++);
+}
+
+/*
+ * Description:
+ * Download PPE firmware binary code.
+ * Input:
+ * src --- u32 *, binary code buffer
+ * dword_len --- unsigned int, binary code length in DWORD (32-bit)
+ * Output:
+ * int --- 0: Success
+ * else: Error Code
+ */
+static inline int pp32_download_code(u32 *code_src, unsigned int code_dword_len, u32 *data_src, unsigned int data_dword_len)
+{
+ volatile u32 *dest;
+
+ if ( code_src == 0 || ((unsigned long)code_src & 0x03) != 0
+ || data_src == 0 || ((unsigned long)data_src & 0x03) != 0 )
+ return -1;
+
+ if ( code_dword_len <= CDM_CODE_MEMORYn_DWLEN(0) )
+ IFX_REG_W32(0x00, CDM_CFG);
+ else
+ IFX_REG_W32(0x04, CDM_CFG);
+
+ /* copy code */
+ dest = CDM_CODE_MEMORY(0, 0);
+ while ( code_dword_len-- > 0 )
+ IFX_REG_W32(*code_src++, dest++);
+
+ /* copy data */
+ dest = CDM_DATA_MEMORY(0, 0);
+ while ( data_dword_len-- > 0 )
+ IFX_REG_W32(*data_src++, dest++);
+
+ return 0;
+}
+
+
+
+/*
+ * ####################################
+ * Global Function
+ * ####################################
+ */
+
+extern void ifx_ptm_get_fw_ver(unsigned int *major, unsigned int *minor)
+{
+ ASSERT(major != NULL, "pointer is NULL");
+ ASSERT(minor != NULL, "pointer is NULL");
+
+ *major = FW_VER_ID->major;
+ *minor = FW_VER_ID->minor;
+}
+
+void ifx_ptm_init_chip(void)
+{
+ init_pmu();
+
+ reset_ppe();
+
+ init_ema();
+
+ init_mailbox();
+
+ init_atm_tc();
+
+ clear_share_buffer();
+}
+
+void ifx_ptm_uninit_chip(void)
+{
+ uninit_pmu();
+}
+
+/*
+ * Description:
+ * Initialize and start up PP32.
+ * Input:
+ * none
+ * Output:
+ * int --- 0: Success
+ * else: Error Code
+ */
+int ifx_pp32_start(int pp32)
+{
+ int ret;
+
+ /* download firmware */
+ ret = pp32_download_code(firmware_binary_code, sizeof(firmware_binary_code) / sizeof(*firmware_binary_code), firmware_binary_data, sizeof(firmware_binary_data) / sizeof(*firmware_binary_data));
+ if ( ret != 0 )
+ return ret;
+
+ /* run PP32 */
+ IFX_REG_W32(DBG_CTRL_START_SET(1), PP32_DBG_CTRL);
+
+ /* idle for a while to let PP32 init itself */
+ udelay(10);
+
+ return 0;
+}
+
+/*
+ * Description:
+ * Halt PP32.
+ * Input:
+ * none
+ * Output:
+ * none
+ */
+void ifx_pp32_stop(int pp32)
+{
+ /* halt PP32 */
+ IFX_REG_W32(DBG_CTRL_STOP_SET(1), PP32_DBG_CTRL);
+}
diff --git a/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_fw_amazon_se.h b/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_fw_amazon_se.h
new file mode 100644
index 0000000..ae33bcc
--- /dev/null
+++ b/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_fw_amazon_se.h
@@ -0,0 +1,493 @@
+#ifndef IFXMIPS_PTM_FW_AMAZON_SE_H
+#define IFXMIPS_PTM_FW_AMAZON_SE_H
+
+
+/******************************************************************************
+**
+** FILE NAME : ifxmips_ptm_fw_amazon_se.h
+** PROJECT : UEIP
+** MODULES : PTM (ADSL)
+**
+** DATE : 1 AUG 2005
+** AUTHOR : Xu Liang
+** DESCRIPTION : PTM Driver (PP32 Firmware)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 4 AUG 2005 Xu Liang Initiate Version
+** 23 OCT 2006 Xu Liang Add GPL header.
+** 9 JAN 2007 Xu Liang First version got from Anand (IC designer)
+*******************************************************************************/
+
+
+#define PTM_FW_VER_MAJOR 0
+#define PTM_FW_VER_MINOR 17
+
+
+static unsigned int firmware_binary_code[] = {
+ 0x800004b8, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8000ffe0, 0x00000000, 0x00000000, 0x00000000,
+ 0xc1000002, 0xd90c00f8, 0xc2000002, 0xda0800f9, 0x800055e0, 0xc2000000, 0xda0800f9, 0x80005580,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x80005e58, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xc10e0002, 0xd90c00f8, 0xc0004808, 0xc84000f8, 0x80005250, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xc3e1fffe, 0x597dfffe, 0x593dfef4, 0x900004d9, 0x00000000, 0x00000000, 0x00000000, 0x90cc0481,
+ 0x00000000, 0x00000000, 0x00000000, 0xc3e06262, 0x5bfc0022, 0xc0004802, 0xcfc000f8, 0xc0004810,
+ 0xcbc000f8, 0x00000000, 0xc3800000, 0xc7f80038, 0x5fb80000, 0xc7fa0038, 0xc7bfe802, 0x5fb80000,
+ 0x00000000, 0xc7bff802, 0xdbd400f9, 0xc00049a0, 0xc3800002, 0xa7ca006a, 0xc1200000, 0x5911fffe,
+ 0xcd0000f9, 0xc1200000, 0x59102042, 0xcd0000f9, 0xc1000004, 0xcd0000f9, 0xc1200000, 0x59103a1e,
+ 0xcd0000f9, 0x80000060, 0xc121fffe, 0x5911fffe, 0xcd0000f9, 0xc1203db8, 0x5910de82, 0xcd0000f9,
+ 0xc1000006, 0xcd0000f9, 0xc120385a, 0x591033da, 0xcd0000f9, 0x5fb80002, 0x8800001a, 0x6ffe0010,
+ 0x8000ff28, 0xdd7c00f9, 0xc3800000, 0xc7f86010, 0x5bb80008, 0xc3540002, 0x777da000, 0xc1000008,
+ 0x4791c002, 0xcf8000f9, 0xdb900038, 0xc3800008, 0xc3720002, 0x777da000, 0xa7f00028, 0x47b9c002,
+ 0xc1000000, 0xc7d26010, 0x4391c000, 0xcf8000f8, 0xdb900838, 0xc3c00000, 0xdbc800f9, 0xc0400000,
+ 0xc11c0000, 0xc000082c, 0xcd05ce00, 0xc11c0002, 0xc000082c, 0xcd05ce00, 0xc0400002, 0xc11c0000,
+ 0xc000082c, 0xcd05ce00, 0xc11c0002, 0xc000082c, 0xcd05ce00, 0xc0000824, 0x00000000, 0xcbc000f9,
+ 0xcb8000f9, 0xcb4000f9, 0xcb0000f8, 0xc0004878, 0x5bfc4000, 0xcfc000f9, 0x5bb84000, 0xcf8000f9,
+ 0x5b744000, 0xcf4000f9, 0x5b304000, 0xcf0000f8, 0xc0000a10, 0x00000000, 0xcbc000f9, 0xcb8000f8,
+ 0xc0004874, 0x5bfc4000, 0xcfc000f9, 0x5bb84000, 0xcf8000f8, 0xc30001fe, 0xc000140a, 0xcf0000f8,
+ 0xc3000000, 0x7f018000, 0xc000042e, 0xcf0000f8, 0xc000040e, 0xcf0000f8, 0xc3c1fffe, 0xc000490e,
+ 0xcfc00078, 0xc000492c, 0xcfc00078, 0xc0004924, 0xcfc00038, 0xc0004912, 0xcfc00038, 0xc000498c,
+ 0xcfc00038, 0xc000498e, 0xcfc00078, 0xc0004990, 0xcfc00078, 0xc3c00000, 0xc2800004, 0xc3000000,
+ 0x7f018000, 0x6ff88000, 0x6fd44000, 0x4395c000, 0x5bb84a00, 0xc00049a0, 0xcb0000f8, 0x00000000,
+ 0x58380006, 0xcf0000f8, 0xc321fffe, 0x5b31fffe, 0x58380024, 0xcf0000f8, 0x5bfc0002, 0xb7e8ff90,
+ 0x00000000, 0xc3c00000, 0xc2800010, 0x6ff86000, 0x47bdc000, 0x5bb84c80, 0xc3400000, 0x58380004,
+ 0xcb420078, 0x00000000, 0x58380008, 0xcf400078, 0x5bfc0002, 0xb7e8ffb0, 0x00000000, 0xc3c00000,
+ 0xc2800004, 0xc3400022, 0xc3000000, 0x7f018000, 0xc2c00016, 0x6ff8a000, 0x47bdc000, 0x5bb84e20,
+ 0x58380008, 0xcf400038, 0xc00049a8, 0xcb0000f8, 0x00000000, 0x5838000a, 0xcf0000f8, 0xc321fffe,
+ 0x5b31fffe, 0x5838000c, 0xcf0000f8, 0x58380034, 0xcec00038, 0x5bfc0002, 0xb7e8ff78, 0x00000000,
+ 0x00000000, 0xc0004840, 0xc3e12624, 0x5bfc2320, 0xcfc000f9, 0xc3e02f2c, 0x5bfd2a28, 0xcfc000f9,
+ 0xc3e03734, 0x5bfd3230, 0xcfc000f9, 0xc3e13e3c, 0x5bfc3b38, 0xcfc000f9, 0xc3e14644, 0x5bfc4340,
+ 0xcfc000f9, 0xc3e04f4c, 0x5bfd4a48, 0xcfc000f9, 0xc3e05754, 0x5bfd5250, 0xcfc000f9, 0xc3e15e5c,
+ 0x5bfc5b58, 0xcfc000f9, 0xc3e06764, 0x5bfd6260, 0xcfc000f9, 0xc3e16e6c, 0x5bfc6b68, 0xcfc000f9,
+ 0xc3e17674, 0x5bfc7370, 0xcfc000f9, 0xc3e07f7c, 0x5bfd7a78, 0xcfc000f9, 0xc3e18684, 0x5bfc8380,
+ 0xcfc000f9, 0xc3e08f8c, 0x5bfd8a88, 0xcfc000f9, 0xc3e09794, 0x5bfd9290, 0xcfc000f9, 0xc3e19e9c,
+ 0x5bfc9b98, 0xcfc000f9, 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0xc1000000, 0xd91c00f8, 0xc3e01002, 0x5bfd88c0, 0xc3a00f88,
+ 0x5bb839a2, 0x990068d8, 0xdbd800f8, 0xdb9800f9, 0x00000000, 0xc3c00000, 0xdf7f0038, 0xa7ccfff0,
+ 0xc3800000, 0xc00048c0, 0xcb818078, 0xc0001408, 0xcfc000f8, 0xc10e0002, 0xd90c00f8, 0x5d3802a6,
+ 0xc1000002, 0xd91c1f02, 0xc121fffe, 0x5911fef4, 0x14100000, 0xa9fe0270, 0xc3c00000, 0xddfc00f0,
+ 0x5d3c0000, 0x84000100, 0xc0000c04, 0xcb8000f8, 0xc11c0002, 0x00000000, 0x7391c000, 0xcf8000f8,
+ 0xc3800000, 0xc3400080, 0xdf780038, 0xb7b4ffea, 0xc3203002, 0x5b3188c4, 0xc2e00f88, 0x5aec100e,
+ 0x990068d8, 0xdb1800f8, 0xdad800f9, 0x00000000, 0xc3800000, 0xc3400080, 0xdf780038, 0xb7b4ffea,
+ 0xc3205002, 0x5b3188c8, 0xc2e00f90, 0x5aec180c, 0x990068d8, 0xdb1800f8, 0xdad800f9, 0x00000000,
+ 0x80000128, 0xc00048cc, 0xca8000f8, 0x00000000, 0xc1000006, 0x76914000, 0x840000fa, 0x00000000,
+ 0xa6800070, 0xc3800000, 0xc3400080, 0xdf780038, 0xb7b4ffea, 0xc3202002, 0x5b31c8c6, 0xc2e00f88,
+ 0x5aec100e, 0x990068d8, 0xdb1800f8, 0xdad800f9, 0x00000000, 0xa6820068, 0xc3800000, 0xc3400080,
+ 0xdf780038, 0xb7b4ffea, 0xc3204002, 0x5b31c8ca, 0xc2e00f90, 0x5aec180c, 0x990068d8, 0xdb1800f8,
+ 0xdad800f9, 0x00000000, 0xc00048cc, 0xc2800000, 0xce8000f8, 0xc3a00140, 0x5bfc0002, 0x47bc8000,
+ 0xc1000000, 0xc53c00fe, 0xdbdc00f0, 0x80000028, 0x00000000, 0x800004e8, 0x00000000, 0x8000fd70,
+ 0xc0004918, 0xd28000f8, 0xc2000000, 0xdf600038, 0x5e600080, 0x840002b2, 0x00000000, 0xc161fffe,
+ 0x5955fffe, 0x14140000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xc000480a, 0xca0000f8, 0xc0004912, 0xca4000f8, 0xc0004924, 0xca8000f8, 0xc000498c, 0xcac000f8,
+ 0xc121fffe, 0x5911fef4, 0x14100000, 0x76250000, 0x76290000, 0x762d0000, 0x840001ea, 0xc0004918,
+ 0xca4000f8, 0xc28001fe, 0x76290000, 0x5a640002, 0x6a254010, 0x5ee80000, 0x8400001a, 0x6aa54000,
+ 0x80000010, 0xc62800f8, 0x62818008, 0xc0004918, 0xcf0000f8, 0xc161fffe, 0x5955fffe, 0x14140000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xc000498c, 0xca4000f8,
+ 0xc2000002, 0x6a310000, 0x7e010000, 0x76612000, 0xce4000f8, 0xc121fffe, 0x5911fef4, 0x14100000,
+ 0x6f346000, 0x4771a000, 0x5b744c80, 0xc2800000, 0x58340006, 0xca800078, 0xc2c00000, 0x58340000,
+ 0xcac000d8, 0xc2400000, 0x5834000a, 0xca420078, 0x6ea82000, 0x42e9e000, 0x6f2ca000, 0x42e56000,
+ 0x5aec1400, 0xc3990040, 0xc7381c18, 0xc6f80060, 0x990068d8, 0xdb9800f8, 0xdbd800f9, 0x00000000,
+ 0xdea000f8, 0x46310000, 0x8400fd40, 0xc000495a, 0xc84000f8, 0x00000000, 0xc3c00002, 0x787c2000,
+ 0xcc4000f8, 0xc0000838, 0xc3800000, 0xcb840028, 0x6c748000, 0x6c544000, 0x4355a000, 0x5b744a00,
+ 0x5ef80000, 0x8400fca2, 0x58340004, 0xcb0000f8, 0x00000000, 0x00000000, 0xa7060020, 0x00000000,
+ 0x5ef80002, 0x8400fc62, 0x5834000c, 0xc8800038, 0xc2000000, 0xc000082c, 0xca040028, 0x5a880002,
+ 0xc2400000, 0xc0004958, 0xce4000f8, 0xb6280018, 0x00000000, 0xc2800000, 0x58340002, 0xc2000000,
+ 0xca020008, 0xc0004956, 0xce8000f8, 0x5e600000, 0x84001ca2, 0x5e600002, 0x84004062, 0x00000000,
+ 0x800021d0, 0xc0004958, 0xca0000f8, 0xc0004956, 0xca8000f8, 0x5e200000, 0x84000020, 0xc2500002,
+ 0xc0000838, 0xce450800, 0x6c748000, 0x6c544000, 0x4355a000, 0x5b744a00, 0x5834000c, 0xc6900038,
+ 0xcd000038, 0x8000fb38, 0xc2000000, 0xdf600038, 0x5e200080, 0x8400028a, 0x00000000, 0xc161fffe,
+ 0x5955fffe, 0x14140000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xc000480c, 0xca0000f8, 0xc0004910, 0xca4000f8, 0xc000492c, 0xca8000f8, 0xc000498e, 0xcac000f8,
+ 0xc121fffe, 0x5911fef4, 0x14100000, 0x76250000, 0x76290000, 0x76e16000, 0x840001c2, 0xc0004926,
+ 0xca4000f8, 0xc201fffe, 0x76e16000, 0x5a640002, 0x6ae50010, 0x5f200000, 0x8400001a, 0x6a250000,
+ 0x80000010, 0xc6e000f8, 0x62014008, 0xc0004926, 0xce8000f8, 0xc161fffe, 0x5955fffe, 0x14140000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xc000498e, 0xca4000f8,
+ 0xc2000002, 0x6a290000, 0x7e010000, 0x76612000, 0xce4000f8, 0xc121fffe, 0x5911fef4, 0x14100000,
+ 0x6eb4a000, 0x4769a000, 0x5b744e20, 0x58340002, 0xc2000000, 0xca0000d8, 0x58340036, 0xc2400000,
+ 0xca400078, 0x6eb0a000, 0x47298000, 0x5b300e56, 0x5b300004, 0x6e642000, 0x4225e000, 0xc39a8024,
+ 0xc7380060, 0xc6b81c18, 0x990068d8, 0xdb9800f8, 0xdbd800f9, 0x00000000, 0xc2000000, 0xdf600038,
+ 0x5e200080, 0x840002da, 0x00000000, 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xc000490e, 0xca0000f8, 0xc000492a, 0xca4000f8,
+ 0xc0004990, 0xcb0000f8, 0xc000498a, 0xcac000f8, 0xc121fffe, 0x5911fef4, 0x14100000, 0x77218000,
+ 0x77258000, 0x8400021a, 0xc201fffe, 0x77218000, 0x5aec0002, 0x6b2d0010, 0x5ea00000, 0x8400001a,
+ 0x6a2d0000, 0x80000010, 0xc72000f8, 0x62016008, 0xc000498a, 0xcec000f8, 0xc161fffe, 0x5955fffe,
+ 0x14140000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xc0004990,
+ 0xca4000f8, 0xc2000002, 0x6a2d0000, 0x7e010000, 0x76612000, 0xce4000f8, 0xc121fffe, 0x5911fef4,
+ 0x14100000, 0x6ef4a000, 0x476da000, 0x5b744e20, 0x58340010, 0xc2000000, 0xca0000d8, 0x58340008,
+ 0xc2400000, 0xca420078, 0x5834000e, 0xc2800000, 0xca832010, 0xc3c00000, 0x47e48000, 0x6e644010,
+ 0xc7e800fc, 0x42250000, 0x4229e000, 0xc39a8008, 0x58340008, 0xcb801038, 0x58340008, 0xc2800000,
+ 0xca810010, 0x6ee0a000, 0x462d0000, 0x5a20000a, 0x5a200e28, 0x42290000, 0xc6380060, 0xc6f81c18,
+ 0x990068d8, 0xdb9800f8, 0xdbd800f9, 0x00000000, 0xc000495c, 0xc84000f8, 0xc3400000, 0xc3c00002,
+ 0x787c2000, 0xcc4000f8, 0x6c78a000, 0x4785c000, 0x5bb84e20, 0x58380034, 0xcb410038, 0xc0000a28,
+ 0xc3000000, 0xcb040028, 0xc0000a14, 0xc2c00000, 0x43358000, 0xcac40028, 0xc000490e, 0xca8000f8,
+ 0x5eec0002, 0x472d8000, 0x8800f258, 0x6bc5e000, 0x76bd4000, 0x8400f240, 0x6c7ca000, 0x47c5e000,
+ 0x5bfc4e20, 0x583c0008, 0xc2000000, 0xca020078, 0xc00049aa, 0x00000000, 0xca8000f9, 0xca4000f8,
+ 0xc0001008, 0xce8000f8, 0xc0001006, 0xce4000f8, 0x583c000a, 0xca4000f8, 0x00000000, 0xc000100a,
+ 0xce4000f8, 0xc2400006, 0xc0001000, 0xce4000f8, 0xc2600982, 0x5a643b6e, 0xc0001002, 0xce4000f8,
+ 0x583c000c, 0xca4000f8, 0x00000000, 0xc0001004, 0xce4000f8, 0x583c000e, 0xcb8000f8, 0x00000000,
+ 0xc2400000, 0xc7a40078, 0xc2800000, 0xc7aae020, 0xdaa000f9, 0x583c0034, 0xcb8000f8, 0x00000000,
+ 0xc2c00000, 0xc7ad0038, 0xc0004978, 0xcec000f8, 0xc0800000, 0xc7880038, 0xc3400000, 0xc7b60038,
+ 0xc0004980, 0xcf4000f8, 0x4661c000, 0x43a9c000, 0xc2400000, 0xc000497c, 0xce4000f8, 0xad2c0001,
+ 0xc2800000, 0x00000000, 0x80000010, 0xc2800002, 0xc0004976, 0xce8000f8, 0xc2c00000, 0xc34000a0,
+ 0xdb5c00f9, 0xc3400002, 0xc000497a, 0xcf4000f8, 0x5f600000, 0x84000180, 0xde2800f9, 0xc6a000f8,
+ 0x47a9c000, 0x583c0000, 0xc2800000, 0xca830038, 0xc0000a28, 0xc3000000, 0xcb040028, 0xc3400000,
+ 0xc0004976, 0x46b18000, 0x8800006a, 0xcf4000f8, 0x58880002, 0xc3000000, 0xc0000a14, 0xcb040028,
+ 0x00000000, 0x00000000, 0xb4b001a8, 0x00000000, 0xc0800000, 0x00000000, 0x80000188, 0xc0004980,
+ 0xcb4000f8, 0x00000000, 0x00000000, 0x5af40002, 0xacec0080, 0x00000000, 0xc2c00000, 0xc000497a,
+ 0xadec0001, 0x00000000, 0x00000000, 0xad2c007f, 0xc2800000, 0xce8000f8, 0x80000018, 0xc2800002,
+ 0xce8000f8, 0x5f6c0000, 0x840000e8, 0x00000000, 0x8000ff00, 0x5f780082, 0x88000258, 0xc3000002,
+ 0xc000497c, 0xcf0000f8, 0xc2800080, 0xc1000000, 0xdd110038, 0x46914000, 0x47a94000, 0x880001d8,
+ 0x4391a000, 0xc0004980, 0xcf4000f8, 0x6f684010, 0x6f77c000, 0x6f77c010, 0xc0004840, 0x40280000,
+ 0xca8000f8, 0xc3000000, 0x6f506000, 0x6a908010, 0xc5300038, 0xdb1c00f9, 0x8000fe30, 0xc3400000,
+ 0xc0000a10, 0xcb440060, 0x6cb04000, 0x6f288000, 0x6f744000, 0x42b14000, 0x43694000, 0xc3400000,
+ 0xc6b44060, 0xc0004000, 0x40340000, 0xc321e000, 0xcf0000f8, 0x5aa80008, 0x42ad4000, 0xc3400000,
+ 0xc6b44060, 0xc0004000, 0x40340000, 0xca4000f8, 0xc3000000, 0xc6f00008, 0xc1400000, 0xddd40039,
+ 0x6f306000, 0xc13001fe, 0x69308010, 0x7d008000, 0x76512000, 0x6d570000, 0x6970a010, 0x42552000,
+ 0xce4000f8, 0x5aa80002, 0x5aec0002, 0xacec0080, 0x00000000, 0xc2c00000, 0x5f6c0000, 0x84000118,
+ 0x00000000, 0x80000040, 0x4391a000, 0x5f740080, 0xc0004980, 0xcf4000f8, 0xc3000004, 0xc000497a,
+ 0xcf0000f8, 0x58880002, 0xc3400000, 0xc0000a14, 0xcb440028, 0x00000000, 0x00000000, 0xb4b40018,
+ 0x00000000, 0xc0800000, 0xc3400000, 0xc0000a10, 0xcb440060, 0x6cb04000, 0x6f248000, 0x6f744000,
+ 0x42712000, 0x43654000, 0xc3400000, 0xc6b44060, 0xc0004000, 0x40340000, 0xc3201e00, 0xcf0000f8,
+ 0x5aa80008, 0x42ad4000, 0xc000100c, 0xcb4000f8, 0xc3000000, 0x00000000, 0xc7340060, 0xc300fffe,
+ 0xc7341070, 0xcf4000f8, 0xc000100e, 0xcb4000f8, 0xc3000e28, 0x00000000, 0xc7340060, 0xc300fffe,
+ 0xc7341070, 0xcf4000f8, 0xc0001010, 0xcb4000f8, 0xc3000002, 0x00000000, 0xc7341a00, 0xc7341800,
+ 0xc3000000, 0xc7341900, 0xc6b40070, 0xcf4000f8, 0xc0004982, 0xce8000f8, 0x6c64a000, 0x46452000,
+ 0x5a64000a, 0xc0001012, 0xcb4000f8, 0xc2800002, 0x00000000, 0xc6740260, 0xc6340008, 0xc000497c,
+ 0xcb0000f8, 0xc6b41800, 0xc6b41b00, 0xc6b41c00, 0xc6b41d00, 0xc7341e00, 0xdd6800f9, 0x7e814000,
+ 0x6eab2010, 0x76b14000, 0xc6b41f00, 0xc2800000, 0xc6b41900, 0xc3000080, 0x472d8000, 0xc0004982,
+ 0xc90000f8, 0x47394000, 0x88000102, 0x41388000, 0xcd0000f8, 0xc7b41038, 0xc0004994, 0xce8000f8,
+ 0xde1000f9, 0x45208000, 0x840000b0, 0xc1000000, 0xdd110038, 0x41388000, 0x412c8000, 0x5d100080,
+ 0xc0004980, 0xcd0000f8, 0xc1000002, 0xc000497c, 0xcd0000f8, 0xc5341e00, 0xdd5000f9, 0x7d008000,
+ 0xc5373f00, 0xc000497a, 0xc90000f8, 0x42390000, 0x43adc000, 0x59100002, 0xcd0000f8, 0x80000050,
+ 0x42390000, 0x80000040, 0xc7341038, 0x41308000, 0xcd0000f8, 0x42310000, 0xc1000000, 0xc0004994,
+ 0xcd0000f8, 0xc0001012, 0xcf4000f8, 0xc000493c, 0xce0000f8, 0xc0004984, 0xcf8000f8, 0xc000497a,
+ 0xca4000f8, 0xc000497c, 0xca8000f8, 0x6c7ca000, 0x47c5e000, 0x5bfc4e20, 0xc0004976, 0xcac000f8,
+ 0xc0004978, 0xca0000f8, 0x5eec0002, 0x8400008a, 0x42250000, 0xc2400000, 0xc000497a, 0xce4000f8,
+ 0x583c0000, 0xc2c00000, 0xcac30038, 0x00000000, 0x00000000, 0x46e16000, 0x8800001a, 0x00000000,
+ 0xad280002, 0xc000497a, 0xce0000f8, 0xc2000000, 0x5fa80000, 0x840001da, 0x00000000, 0x6c508000,
+ 0xc0004880, 0x40100000, 0x58000018, 0xc90000f8, 0x00000000, 0x00000000, 0x59100002, 0xcd0000f8,
+ 0x583c000e, 0xc2c00000, 0xcac00078, 0xc1000000, 0xdd532201, 0x42d16000, 0x6c508000, 0xc0004880,
+ 0x40100000, 0x5800001a, 0xc90000f8, 0x00000000, 0x00000000, 0x412c8000, 0xcd0000f8, 0x99006968,
+ 0xd85800f8, 0xdbd800f9, 0x00000000, 0x990066b0, 0xc000491c, 0xc1400000, 0xc9420048, 0xc000491c,
+ 0x99006b68, 0xc94000f9, 0xc98000f8, 0x00000000, 0x990068d8, 0xd95800f8, 0xd99800f9, 0x00000000,
+ 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x98c06528, 0xd85800f8, 0xdbd800f9, 0xc45800f8, 0xc121fffe, 0x5911fef4, 0x14100000,
+ 0xade80003, 0xc000493c, 0xcb4000f8, 0x00000000, 0xc3000000, 0xc7701078, 0x80000010, 0xc3000000,
+ 0x583c0008, 0xcf021078, 0x6e210000, 0x583c0034, 0xce010838, 0xc0004980, 0xcb8000f8, 0x583c0034,
+ 0x00000000, 0x6fba0000, 0xcf821038, 0xc000490e, 0xca0000f8, 0xc2c00002, 0x6ac56000, 0x722d0000,
+ 0xce0000f8, 0x00000000, 0x00000000, 0x00000000, 0xa8e2ffe8, 0x00000000, 0xc1220002, 0xd90c00f8,
+ 0x5fa80000, 0x84000712, 0xc00049a8, 0xca0000f8, 0x583c000a, 0x00000000, 0xce0000f8, 0xc221fffe,
+ 0x5a21fffe, 0x583c000c, 0xce0000f8, 0xc0001004, 0xca0000f8, 0x00000000, 0x583c0012, 0x7e010000,
+ 0xce0000f8, 0xa97000e1, 0x00000000, 0x00000000, 0xa97200c9, 0xc0001010, 0xc2740000, 0xce435a00,
+ 0x6c64a000, 0x46452000, 0x5a64000a, 0x6e644000, 0xc0001012, 0xce400070, 0xc2600008, 0xce421038,
+ 0xc27e0002, 0xce43ff00, 0xc2760002, 0xce437b00, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0xa8e2ffe8, 0x00000000, 0xc1220002, 0xd90c00f8, 0xc1000000, 0xdd110038, 0x5d100000,
+ 0x84000412, 0xc0004982, 0xca0000f8, 0xc0004984, 0xca4000f8, 0xc2800000, 0xc361fffe, 0x5b75fffe,
+ 0xa96a001b, 0xdfec00f8, 0xc6ec1078, 0x7af56000, 0x6c40a000, 0x44040000, 0x58004e20, 0x58000014,
+ 0xcec000f8, 0xa972001b, 0x5c000002, 0xcec000f8, 0xc0001010, 0xc2f40002, 0xcec35a00, 0x6c6ca000,
+ 0x46c56000, 0x5aec000a, 0x6eec4000, 0xc0001012, 0xcec00070, 0xc0004994, 0xc98000f8, 0xc1400000,
+ 0xdd150038, 0xc55c00f8, 0x45948000, 0x00000000, 0xc59c00fc, 0x5d1c0000, 0x840000d2, 0xc0001012,
+ 0xc5d01038, 0xcd021038, 0xc2f60002, 0xcec37b00, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0xa8e2ffe8, 0x00000000, 0xc1220002, 0xd90c00f8, 0x45948000, 0x88000052, 0xc0004994,
+ 0xcd0000f8, 0xc0004980, 0xcbc000f8, 0x42150000, 0xc0004982, 0xce0000f8, 0x5ffc0000, 0x84000218,
+ 0x58880002, 0xc3800000, 0xc0000a14, 0xcb840028, 0xc3c00000, 0xc0000a10, 0xb4b80018, 0x00000000,
+ 0xc0800000, 0xcbc40060, 0x6cb84000, 0x6fac8000, 0x6ffc4000, 0x42f96000, 0x43ed0000, 0xc3400000,
+ 0xc6344060, 0xc0004000, 0x40340000, 0xc2a1e000, 0xce8000f8, 0x5a200008, 0xc0004980, 0xcbc000f8,
+ 0xc3400000, 0xc0004840, 0x6ff84010, 0xc7f40008, 0x40380000, 0xcb8000f8, 0xc2800000, 0x6f506000,
+ 0x6b908010, 0xc52c1838, 0xc3400000, 0xc6344060, 0xc0004000, 0x40340000, 0xcec000f8, 0x5a200002,
+ 0x5ffc0000, 0x84000092, 0xc0001010, 0xc62c0070, 0xcec00070, 0xc0001012, 0xc7ec1038, 0xcec21038,
+ 0xc2f60002, 0xcec37b00, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xa8e2ffe8,
+ 0x00000000, 0xc1220002, 0xd90c00f8, 0xc0004994, 0xc100007e, 0x453c8000, 0xcd0000f8, 0x423d0000,
+ 0xc0004982, 0xce0000f8, 0xc0004994, 0xca0000f8, 0xc0004980, 0xca4000f8, 0x5e200000, 0x8400015a,
+ 0xc2000000, 0xc2800000, 0x5a640002, 0xc6684028, 0xc0004982, 0xcb0000f8, 0xc0004000, 0xc2c00000,
+ 0xc72c4060, 0x402c0000, 0x6e67c000, 0x6e67c010, 0x5ee40002, 0x8400003a, 0x5ee40004, 0x8400004a,
+ 0x5ee40006, 0x8400005a, 0x00000000, 0x80000060, 0xce0000b8, 0x5aa80002, 0x5b300006, 0x80000040,
+ 0xce000078, 0x5aa80002, 0x5b300004, 0x80000020, 0xce000038, 0x5aa80002, 0x5b300002, 0x5ee80020,
+ 0x84000052, 0xc0004000, 0xc2c00000, 0xc72c4060, 0x402c0000, 0xce0000f8, 0x5aa80002, 0x5b300008,
+ 0x8000ffb8, 0x00000000, 0x80000040, 0x583c000a, 0xd7c000f8, 0xc0001004, 0xca4000f8, 0x00000000,
+ 0x583c000c, 0xce4000f8, 0xc000497a, 0xca4000f8, 0xc2800002, 0xc0000a28, 0xc6780928, 0xc6b80800,
+ 0xcf850830, 0x6c7ca000, 0x47c5e000, 0x5bfc4e20, 0x583c0034, 0xc4900038, 0xcd000038, 0x8000e418,
+ 0x6c6c8000, 0x6c544000, 0x42d56000, 0x5aec4a00, 0xc0000824, 0xca0400f8, 0x6ca48000, 0x42492000,
+ 0xc3000000, 0xc3400000, 0x42250000, 0x58204000, 0xca4000f8, 0x5a200002, 0xda2400f9, 0xc2800000,
+ 0xc000495e, 0xce8000f8, 0xda6000f8, 0xc2800000, 0xc66b0038, 0xdaa800f8, 0x582c0010, 0x6f206010,
+ 0x40200000, 0xd82800f9, 0xca0000f8, 0xc2400000, 0xc7240010, 0x6e644000, 0xda6400f8, 0x6a254010,
+ 0xc3c00000, 0xc6bc0018, 0xc3800000, 0xdea000f8, 0x5e60001e, 0x8400002a, 0x5e6001e0, 0x8400001a,
+ 0x00000000, 0x80000080, 0xc7f800f8, 0x5e7c0008, 0x8400006a, 0x5bbc0002, 0x5e780008, 0x84000028,
+ 0x5b740002, 0xc0004960, 0xcf0000f8, 0x80000030, 0x5e780006, 0x88000022, 0xc2800002, 0xc000495e,
+ 0xce8000f8, 0xde8000f9, 0xca8000f8, 0xde6000f8, 0xc240001e, 0x6a612000, 0x7e412000, 0x76a54000,
+ 0x6ba12000, 0x72a54000, 0xce8000f8, 0x5e300080, 0x840000ba, 0xc2000000, 0xc7200008, 0x5e600000,
+ 0x84000058, 0xde6000f9, 0x58204000, 0xca4000f8, 0x5a200002, 0xda2400f9, 0xc2800000, 0xc66b0038,
+ 0xdaa800f8, 0xda6000f8, 0x80000038, 0xc2800000, 0x6e206000, 0xde2400f8, 0x6a610000, 0xc62b0038,
+ 0xdaa800f8, 0x5b300002, 0x8000fde0, 0xc2000000, 0x582c0020, 0xca020078, 0x00000000, 0xc2400000,
+ 0x5a200002, 0xc6241078, 0xce421078, 0xc000480e, 0xca8000f8, 0x5e740000, 0x84000160, 0x46a12000,
+ 0x8800e048, 0xc2400000, 0xc0000808, 0xca440010, 0x582c0010, 0xc1400000, 0xcd4000f9, 0xcd4000f9,
+ 0xcd4000f9, 0xcd4000f9, 0xcd4000f9, 0xcd4000f9, 0xcd4000f9, 0xcd4000f9, 0xcd400018, 0x582c0020,
+ 0xce021078, 0xc2000010, 0x5a640002, 0xb6240018, 0x00000000, 0xc2400000, 0xc6600010, 0xc0000808,
+ 0xce040010, 0xc0004956, 0xca4000f8, 0xc11c0000, 0xc000082c, 0xcd05ce00, 0xc6600928, 0xc2400000,
+ 0xc6600028, 0xc0000838, 0xce0400f8, 0xc2400002, 0xc0004958, 0xce4000f8, 0xc11c0002, 0xc000082c,
+ 0xcd05ce00, 0x8000df00, 0xc000495e, 0xca0000f8, 0x5e740002, 0x8400dee0, 0x5e200000, 0x8400ded0,
+ 0xc0004960, 0xca4000f8, 0xc2200004, 0x582c0002, 0xce021008, 0xc2000082, 0x46250000, 0xc6280030,
+ 0xc0000810, 0xce840030, 0x99007000, 0x582c0002, 0xc94000f8, 0xc1a20000, 0x5e640000, 0x8400fed0,
+ 0x00000000, 0x8000de40, 0x6c6c8000, 0x6c544000, 0x42d56000, 0x5aec4a00, 0xc000487c, 0xc80400f8,
+ 0x00000000, 0x00000000, 0x40080000, 0xcb8000f8, 0xc42400f8, 0x00000000, 0xa78601a0, 0xc3c00000,
+ 0xc2000000, 0x582c000c, 0xca010038, 0x6c508000, 0xc0004880, 0x40100000, 0x58000016, 0xc90000f8,
+ 0x00000000, 0x00000000, 0x59100002, 0xcd0000f8, 0x5a200002, 0x582c000c, 0xc6100838, 0xcd010838,
+ 0x5e600002, 0x84000020, 0xc2200004, 0x582c0002, 0xce021008, 0x5e600008, 0x84000060, 0xc2200002,
+ 0x582c0002, 0xce021008, 0x582c000c, 0xcfc10838, 0xc2220002, 0xc0000a14, 0xce063100, 0xc22001a2,
+ 0xc0000a1c, 0xce061038, 0x6c6c8000, 0x6c544000, 0x42d56000, 0x5aec4a00, 0x582c0004, 0xcb0000f8,
+ 0xc3400000, 0x00000000, 0xa7060028, 0xcf406300, 0xc3100002, 0xc0000838, 0xcf050800, 0x582c000c,
+ 0xcf421000, 0x8000dc40, 0x582c000c, 0xcfc10838, 0xc2000000, 0xc7a06010, 0x5e200000, 0x84001c08,
+ 0x6c6c8000, 0x6c544000, 0x42d56000, 0x5aec4a00, 0xc000487c, 0xc80400f8, 0x00000000, 0x00000000,
+ 0x40080000, 0xcb8000f8, 0xc42400f8, 0x00000000, 0xc2800000, 0xc3400000, 0xc7b5c030, 0xc0004970,
+ 0xcf4000f8, 0xc2400000, 0xc7a4e030, 0xc000496c, 0xce4000f8, 0xc3000000, 0xc7b00010, 0xc3c00004,
+ 0xc000496e, 0xcfc000f8, 0x582c000c, 0xca0000f8, 0xc2400002, 0xc0004964, 0xce4000f8, 0xa6200372,
+ 0x00000000, 0x5e700004, 0x840000ea, 0x5e700006, 0x84000080, 0xc2000002, 0x582c0002, 0xce000000,
+ 0xc0000a14, 0xce863100, 0x6c508000, 0xc0004880, 0x40100000, 0x58000014, 0xc90000f8, 0x00000000,
+ 0x00000000, 0x59100002, 0xcd0000f8, 0x80001a58, 0x5e70000a, 0x84000040, 0xc2000000, 0x582c0002,
+ 0xce000000, 0xc2220002, 0xc0000a14, 0xce063100, 0x8000ff70, 0x5e700008, 0x84000228, 0xc2200002,
+ 0x582c000c, 0xce021000, 0x6c508000, 0xc0004880, 0x40100000, 0x58000012, 0xc90000f8, 0x00000000,
+ 0x00000000, 0x59100002, 0xcd0000f8, 0x5e340002, 0x6c508000, 0xc0004880, 0x40100000, 0x58000010,
+ 0xc90000f8, 0x00000000, 0x00000000, 0x41208000, 0xcd0000f8, 0xc0000a14, 0xce863100, 0xc0004970,
+ 0xcb4000f8, 0x6c6c8000, 0x6c544000, 0x42d56000, 0x5aec4a00, 0x582c000e, 0xc4900038, 0xcd000038,
+ 0x582c000e, 0xc7500838, 0xcd010838, 0xc2800000, 0x582c0004, 0xce821078, 0x582c0004, 0xce800000,
+ 0xc00049a0, 0xca4000f8, 0x00000000, 0x582c0006, 0xce4000f8, 0xc261fffe, 0x5a65fffe, 0x582c0024,
+ 0xce4000f8, 0xc2060002, 0x582c0004, 0xce006300, 0xc2400002, 0xc0004958, 0xce4000f8, 0xc0004878,
+ 0xc80400f8, 0x6c908000, 0x41088000, 0x40100000, 0x58000020, 0xc90000f8, 0x582c0026, 0x00000000,
+ 0xcd0000f8, 0x800017e8, 0x00000000, 0x6c508000, 0xc0004880, 0x40100000, 0x58000016, 0xc90000f8,
+ 0x00000000, 0x00000000, 0x59100002, 0xcd0000f8, 0x8000faf0, 0x5e700000, 0x840000c0, 0xc3400082,
+ 0xc0004970, 0xcf4000f8, 0xc2400080, 0xc000496c, 0xce4000f8, 0xc3c00002, 0xc000496e, 0xcfc000f8,
+ 0xc2400000, 0xc0004964, 0xce4000f8, 0xc0004878, 0xc80400f8, 0x6c908000, 0x41088000, 0x40100000,
+ 0x58000020, 0xc90000f8, 0x582c0026, 0x00000000, 0xcd0000f8, 0x80000078, 0x5e700002, 0x84000058,
+ 0xc3400082, 0xc0004970, 0xcf4000f8, 0xc3c00004, 0xc000496e, 0xcfc000f8, 0xc2200000, 0x582c000c,
+ 0xce021000, 0x80000030, 0x5e700004, 0x8400fe80, 0xc2600002, 0x582c000c, 0xce421000, 0xc0000a14,
+ 0xce863100, 0xc000496c, 0xca4000f8, 0x6c508000, 0xc0004880, 0x40100000, 0x58000012, 0xc90000f8,
+ 0x00000000, 0x00000000, 0x59100002, 0xcd0000f8, 0xc000496e, 0xcbc000f8, 0x00000000, 0x00000000,
+ 0x477d0000, 0x46250000, 0x6c508000, 0xc0004880, 0x40100000, 0x58000010, 0xc90000f8, 0x00000000,
+ 0x00000000, 0x41208000, 0xcd0000f8, 0x6c6c8000, 0x6c544000, 0x42d56000, 0x5aec4a00, 0x582c0004,
+ 0xca0000f8, 0x00000000, 0x00000000, 0xa60014e2, 0x00000000, 0x6c6c8000, 0x6c544000, 0x42d56000,
+ 0x5aec4a00, 0xc3000000, 0x582c0004, 0xcf006300, 0x582c0000, 0xcb002010, 0xc3c00000, 0x582c0004,
+ 0xcbc20078, 0xc000491a, 0xcf0000f8, 0xc000493c, 0xcfc000f8, 0x582c0008, 0xcb8000f8, 0x582c000a,
+ 0xca4000f8, 0xc0004930, 0xcf8000f8, 0xc0004932, 0xce4000f8, 0x5ffc0000, 0x840001f0, 0x00000000,
+ 0xa7be0102, 0xc2800000, 0x6f206000, 0x46310000, 0x5a204c80, 0x5820000c, 0xca800020, 0x00000000,
+ 0x00000000, 0x5ea80000, 0x84000112, 0x00000000, 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x990063c8, 0xc000491a, 0xc94000f8,
+ 0x00000000, 0xc121fffe, 0x5911fef4, 0x14100000, 0xc0004930, 0xcb8000f8, 0xc0004932, 0xca4000f8,
+ 0xc4781108, 0xc0004930, 0xcf8000f8, 0x582c0008, 0xcf8000f8, 0x582c000a, 0xce4000f8, 0xc7b6e108,
+ 0x582c0004, 0xcf402108, 0x80000090, 0x00000000, 0x6c508000, 0xc0004880, 0x40100000, 0x5800000c,
+ 0xc90000f8, 0x00000000, 0x00000000, 0x59100002, 0xcd0000f8, 0xc2000002, 0x582c0004, 0xce000000,
+ 0xc0000838, 0xc2500002, 0xce450800, 0x80001220, 0x6c7c8000, 0x6c544000, 0x43d5e000, 0x5bfc4a00,
+ 0x583c0006, 0xca0000f8, 0xc00049a2, 0x00000000, 0xca8000f9, 0xca4000f8, 0xc0001008, 0xce8000f8,
+ 0xc0001006, 0xce4000f8, 0xc000100a, 0xce0000f8, 0xc2400006, 0xc0001000, 0xce4000f8, 0xc2600982,
+ 0x5a643b6e, 0xc0001002, 0xce4000f8, 0x583c0024, 0xca4000f8, 0x00000000, 0xc0001004, 0xce4000f8,
+ 0xc0004862, 0xc2000000, 0xca000078, 0xc360fffe, 0xc0004862, 0xce0000f8, 0xc0000824, 0xcb440060,
+ 0x00000000, 0xc000100e, 0xcf4000f8, 0xc3801600, 0xc2400200, 0x6e644000, 0xc6781070, 0xc000100c,
+ 0xcf8000f8, 0xc3200a00, 0xc0001010, 0xcf031810, 0xc2e06200, 0xc0001012, 0xcec31838, 0xc2000000,
+ 0x583c0004, 0xca002008, 0xc2800000, 0xc0004966, 0xce0000f8, 0xc62400f8, 0xc3000000, 0xc000496a,
+ 0xcf0000f8, 0xc0004974, 0xcf0000f8, 0xc000493c, 0xcb4000f8, 0x583c000e, 0x00000000, 0x5f740000,
+ 0x84000180, 0xc3400000, 0xcb410038, 0xc3000002, 0xc000496a, 0x5fb40080, 0x84000152, 0xcf0000f8,
+ 0x583c000e, 0xc2c00000, 0xcac00038, 0xc3800080, 0x47b5c000, 0xc0004974, 0xcf8000f8, 0xc0001012,
+ 0x6fba0000, 0xcf821038, 0x6fba0010, 0x43a5c000, 0x5b380006, 0x6f284010, 0xc7a40008, 0x6eec4000,
+ 0x6ef08000, 0x432d8000, 0x43358000, 0x5b300008, 0xc0001012, 0xc7100070, 0xcd000070, 0xc2000200,
+ 0xc2c00000, 0xdf6d0048, 0x462d6000, 0x46e96000, 0x8800ffe2, 0xc2000000, 0xc0004862, 0xca000260,
+ 0x00000000, 0x583c0004, 0xca002008, 0xc3360002, 0xc0001010, 0xce000070, 0xc0001012, 0xcf037b00,
+ 0xc0004974, 0xcb8000f8, 0x00000000, 0x00000000, 0x5fb80000, 0x84000042, 0x00000000, 0x00000000,
+ 0x00000000, 0xa8e2ffe8, 0x00000000, 0xc1220002, 0xd90c00f8, 0xc000496c, 0xcac000f8, 0x00000000,
+ 0x00000000, 0x426dc000, 0x5b380006, 0x6f304010, 0xc7a40008, 0xc0004968, 0xce4000f8, 0xc000496e,
+ 0xcb4000f8, 0x6ca44000, 0x6e608000, 0x42250000, 0x5a200006, 0x42350000, 0xc0001012, 0xc6100070,
+ 0xcd000070, 0x6eee0000, 0xcec21038, 0xc2000200, 0xc2c00000, 0xdf6d0048, 0x462d6000, 0x42b14000,
+ 0x46e96000, 0x8800ffda, 0xc000493c, 0xcb4000f8, 0xc0000838, 0xc3100002, 0x5f740000, 0x84000060,
+ 0xcf050800, 0xc0004974, 0xcb8000f8, 0x00000000, 0x00000000, 0x5fb80000, 0x8400006a, 0xc0001012,
+ 0xc3360002, 0xcf037b00, 0x800000a0, 0x583c0022, 0xcb4000f8, 0xc0004862, 0xca0000f8, 0x00000000,
+ 0xc0005600, 0x40200000, 0xcf4000f8, 0xc2000000, 0xc0004862, 0xca000260, 0x00000000, 0x583c0004,
+ 0xca002008, 0xc3360002, 0xc0001010, 0xce000070, 0xc0001012, 0xcf037b00, 0xc0004968, 0xcbc000f8,
+ 0xc0004964, 0xca4000f8, 0xc7e000f8, 0x00000000, 0x5e640000, 0x84000012, 0xc2000000, 0xc0004974,
+ 0xca4000f8, 0xc000496c, 0xca8000f8, 0xc000493c, 0xcb8000f8, 0x42698000, 0x00000000, 0x43b1a000,
+ 0x5ef40080, 0x8800019a, 0xc0004966, 0xcac000f8, 0x6c648000, 0x6c544000, 0x42552000, 0x5a644a00,
+ 0x58240000, 0x436da000, 0x4761a000, 0xc2400000, 0xca420078, 0x00000000, 0x00000000, 0x46752000,
+ 0x88000122, 0x432d8000, 0x47218000, 0x88000010, 0xc3000000, 0x5b300006, 0x6f304010, 0xc000493a,
+ 0xcf0000f8, 0xc0004932, 0xc2400000, 0xca4000d8, 0x00000000, 0x6fb84010, 0x42792000, 0xc000491e,
+ 0xce4000f8, 0xc0004862, 0xca8000f8, 0x00000000, 0xc2c0000a, 0xc6e80d70, 0xc7281048, 0xc000491c,
+ 0xce8000f8, 0x6c708000, 0x6c544000, 0x43158000, 0x5b304a00, 0x6f760000, 0x58300004, 0xcf421078,
+ 0x6ffc2000, 0x58300004, 0xcfc02108, 0x800000d0, 0x6c708000, 0x6c544000, 0x43158000, 0x5b304a00,
+ 0xc2800002, 0x58300004, 0xce800000, 0x6c508000, 0xc0004880, 0x40100000, 0x5800000e, 0xc90000f8,
+ 0x00000000, 0x00000000, 0x59100002, 0xcd0000f8, 0x00000000, 0x00000000, 0x00000000, 0xa8e2ffe8,
+ 0x00000000, 0xc1220002, 0xd90c00f8, 0x80000920, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xa8e2ffe8, 0x00000000, 0xc1220002, 0xd90c00f8, 0xc0004964, 0xca0000f8, 0x6c7c8000, 0x6c544000,
+ 0x43d5e000, 0x5bfc4a00, 0xdfe400f8, 0x5e200002, 0x84000608, 0x00000000, 0x583c0004, 0xc2800000,
+ 0xca820078, 0xc0004930, 0xcac000f8, 0x00000000, 0x00000000, 0x6eece000, 0x6eefc010, 0x46aca000,
+ 0xc1000000, 0xdd500039, 0x6d106010, 0x4550a000, 0xc1000000, 0xdd514201, 0x4550c000, 0xa95000f1,
+ 0xc00049a6, 0xca0000f8, 0xa94a0023, 0x00000000, 0x6e660000, 0x6e660010, 0x46612000, 0x840000b2,
+ 0x00000000, 0x6c508000, 0xc0004880, 0x40100000, 0x58000004, 0xc90000f8, 0x00000000, 0x00000000,
+ 0x59100002, 0xcd0000f8, 0x6c508000, 0xc0004880, 0x40100000, 0x58000006, 0xc90000f8, 0x00000000,
+ 0x00000000, 0x41148000, 0xcd0000f8, 0x80000720, 0x00000000, 0xa95203c1, 0xc0001004, 0xcb8000f8,
+ 0xc3400000, 0xdd740039, 0x5f740000, 0x840000d0, 0xc1218e08, 0x5911baf6, 0x45388000, 0x84000372,
+ 0x00000000, 0x6c508000, 0xc0004880, 0x40100000, 0x58000008, 0xc90000f8, 0x00000000, 0x00000000,
+ 0x59100002, 0xcd0000f8, 0x6c508000, 0xc0004880, 0x40100000, 0x5800000a, 0xc90000f8, 0x00000000,
+ 0x00000000, 0x41148000, 0xcd0000f8, 0x80000620, 0x00000000, 0xc000496c, 0xcb0000f8, 0x583c0026,
+ 0xcac000f8, 0xc0004878, 0xc80400f8, 0x6c908000, 0x41088000, 0x40100000, 0x58000002, 0xca8000f8,
+ 0x00000000, 0x00000000, 0x6ea90000, 0x5d300008, 0x8800004a, 0x59300002, 0xc3000000, 0xc5300008,
+ 0x6d104010, 0x40100000, 0xca8000f8, 0x5c000002, 0xcac000f8, 0x5d300000, 0x8400003a, 0x6f246000,
+ 0x6ae56000, 0xc1000040, 0x45252000, 0x6aa54010, 0x42e96000, 0x583c0026, 0xcec000f8, 0xc1218e08,
+ 0x5911baf6, 0xc0001004, 0xcd0000f8, 0x593c0026, 0xc000100e, 0xcd000060, 0xc1340000, 0xc0001010,
+ 0xcd035a00, 0xc1200008, 0xa94a0023, 0xc0001012, 0xc1200004, 0x59100004, 0xcd0000b8, 0xc1360002,
+ 0xcd037b00, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xa8e2ffe8, 0x00000000,
+ 0xc1220002, 0xd90c00f8, 0xc0001004, 0xc90000f8, 0x00000000, 0x00000000, 0x45388000, 0x840000b2,
+ 0x00000000, 0x6c508000, 0xc0004880, 0x40100000, 0x58000008, 0xc90000f8, 0x00000000, 0x00000000,
+ 0x59100002, 0xcd0000f8, 0x6c508000, 0xc0004880, 0x40100000, 0x5800000a, 0xc90000f8, 0x00000000,
+ 0x00000000, 0x41148000, 0xcd0000f8, 0x80000360, 0x00000000, 0x6c508000, 0xc0004880, 0x40100000,
+ 0x58000000, 0xc90000f8, 0x00000000, 0x00000000, 0x59100002, 0xcd0000f8, 0x6c508000, 0xc0004880,
+ 0x40100000, 0x58000002, 0xc90000f8, 0x00000000, 0x00000000, 0x41148000, 0xcd0000f8, 0xc0004930,
+ 0xcd800078, 0xc3000000, 0x583c0008, 0xcf0000f8, 0x80000038, 0xc0001004, 0xca0000f8, 0x583c0006,
+ 0xce4000f8, 0x583c0024, 0xce0000f8, 0xc0004862, 0xc2000000, 0xca000078, 0xc000493a, 0xca4000f8,
+ 0x00000000, 0x00000000, 0x42254000, 0x5ee80200, 0x88000012, 0xc6e800f8, 0xc0004000, 0x58001600,
+ 0x40280000, 0xcb8000f8, 0x00000000, 0x583c0022, 0xcf8000f8, 0xc0004862, 0xce800078, 0xc0001406,
+ 0xcac000f8, 0xc2800002, 0x00000000, 0xc66c1048, 0xc6ac0a00, 0xcec000f8, 0xc2000000, 0xdf600038,
+ 0x5e600080, 0x8400ffea, 0xc000491c, 0xca4000f8, 0xc000491e, 0xca8000f8, 0x990068d8, 0xda5800f8,
+ 0xda9800f9, 0x00000000, 0xc0004964, 0xcbc000f8, 0x00000000, 0x00000000, 0x5ffc0000, 0x84000102,
+ 0xc2000000, 0xdf610048, 0x5e6001fe, 0x8800ffe8, 0xc000491a, 0xc98000f8, 0xc0004862, 0xc94000f8,
+ 0x6d9c6000, 0x45d8e000, 0x59dc4c80, 0x99006738, 0xd95800f8, 0xd99800f9, 0xd9d400f8, 0x990066b0,
+ 0xc000491c, 0xc1400000, 0xc9420048, 0xc2000000, 0xdf600038, 0x5e600080, 0x8400ffea, 0xc000491c,
+ 0xca4000f8, 0xc000491e, 0xca8000f8, 0x990068d8, 0xda5800f8, 0xda9800f9, 0x00000000, 0xc0004970,
+ 0xcb4000f8, 0x00000000, 0x00000000, 0x5e740082, 0x8400e6d8, 0x00000000, 0x8000c018, 0x00000000,
+ 0x6c508000, 0xc0004880, 0x40100000, 0x58000016, 0xc90000f8, 0x00000000, 0x00000000, 0x59100002,
+ 0xcd0000f8, 0x8000e308, 0x6c6c8000, 0x6c544000, 0x42d56000, 0x5aec4a00, 0xc000487c, 0xc80400f8,
+ 0x00000000, 0x00000000, 0x40080000, 0xca0000f8, 0xc42400f8, 0x00000000, 0xa60600f8, 0xc3c00000,
+ 0xc2000000, 0x582c000c, 0xca010038, 0x00000000, 0x00000000, 0x5a200002, 0xc6100838, 0xcd010838,
+ 0x5e60000e, 0x8400bf00, 0xc2200000, 0x582c0002, 0xce021008, 0x582c000c, 0xcfc10838, 0x582c0020,
+ 0xcfc21078, 0x582c0010, 0xc1400000, 0xcd4000f9, 0xcd4000f9, 0xcd4000f9, 0xcd4000f9, 0xcd4000f9,
+ 0xcd4000f9, 0xcd4000f9, 0xcd4000f9, 0xcd400018, 0x8000be68, 0xc2200004, 0x582c0002, 0xce021008,
+ 0x582c000c, 0xcfc10838, 0x99007000, 0x582c0002, 0xc94000f8, 0xc1a20000, 0x8000be18, 0xc3e1fffe,
+ 0x597dfffe, 0x593dfef4, 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0xc0800000, 0xdf4b0038,
+ 0xc0004900, 0xcb8000f8, 0xc2000000, 0xc000490a, 0xa78000d0, 0xcbc000f8, 0xc1000000, 0xd90000f9,
+ 0xc1000002, 0xd90c00f8, 0x6ff46000, 0x477da000, 0x5b744c80, 0xc2400000, 0x58340004, 0xca400078,
+ 0xc0004900, 0xce000000, 0x5a640002, 0x58340004, 0xc6500078, 0xcd000078, 0xc0004914, 0xca4000f8,
+ 0xc2000002, 0x6a3d0000, 0x72612000, 0xce4000f8, 0xc0000408, 0xce0000f8, 0xa78200c8, 0xc0004908,
+ 0xcbc000f8, 0xc1000000, 0xd90000f9, 0xc1000002, 0xd90c00f8, 0x6ff4a000, 0x477da000, 0x5b744e20,
+ 0xc2800000, 0x58340006, 0xca800078, 0xc2000000, 0xc0004900, 0xce002100, 0x5ea80002, 0x58340006,
+ 0xc6900078, 0xcd000078, 0x5a7c0020, 0xc2000002, 0x6a250000, 0xc0000408, 0xce0000f8, 0xdca800f9,
+ 0x5ea80000, 0x8400a860, 0x00000000, 0xa4800230, 0x00000000, 0xc3c00000, 0xc000140e, 0xcbc00018,
+ 0xc3400000, 0xc2400000, 0x6ff86000, 0x47bdc000, 0x5bb84c80, 0x58380008, 0xcb400078, 0x58380006,
+ 0xca400078, 0x5f740002, 0x58380008, 0xc7500078, 0xcd000078, 0xc2000000, 0x58380004, 0xca020078,
+ 0xc3000000, 0x5838000c, 0xcb000020, 0x5a640002, 0x46610000, 0x84000010, 0xc2400000, 0x58380006,
+ 0xc6500078, 0xcd000078, 0xc2000000, 0x5838000a, 0xca020078, 0x5b300002, 0x5838000c, 0xc7100020,
+ 0xcd000020, 0xc2420020, 0x5a200004, 0x46252000, 0x84000010, 0xc2000000, 0x5838000a, 0xc6101078,
+ 0xcd021078, 0xc000498c, 0xca4000f8, 0xc2000002, 0x6a3d0000, 0x72612000, 0xce4000f8, 0x5f740000,
+ 0x84000040, 0xc0004912, 0xca0000f8, 0xc2c00002, 0x6afd6000, 0x7ec16000, 0x762d0000, 0xce0000f8,
+ 0x5f300020, 0x84000040, 0xc0004924, 0xca0000f8, 0xc2c00002, 0x6afd6000, 0x7ec16000, 0x762d0000,
+ 0xce0000f8, 0xa4820070, 0xc2400000, 0xc000140e, 0xca408018, 0xc2000002, 0xc0004900, 0xce000000,
+ 0xc000490a, 0xce4000f8, 0xc1000000, 0xd90000f9, 0xd8400078, 0xc1000004, 0xd90000f9, 0xa48402d8,
+ 0x00000000, 0xc3c00000, 0xc000140e, 0xcbc10018, 0xc2800000, 0xc2000000, 0x6ff8a000, 0x47bdc000,
+ 0x5bb84e20, 0x58380036, 0xca800078, 0x58380006, 0xca020078, 0xc3400000, 0x58380036, 0xcb420078,
+ 0x5aa80002, 0x46a10000, 0x84000010, 0xc2800000, 0x58380036, 0xc6900078, 0xcd000078, 0x5f740002,
+ 0x58380036, 0xc7501078, 0xcd021078, 0xc000498e, 0xca4000f8, 0xc2000002, 0x6a3d0000, 0x72612000,
+ 0xce4000f8, 0xc000492a, 0xca8000f8, 0x5e740000, 0x84000040, 0xc0004910, 0xca0000f8, 0xc2c00002,
+ 0x6afd6000, 0x7ec16000, 0x762d0000, 0xce0000f8, 0x6abd4010, 0xa6800132, 0x00000000, 0x5838003a,
+ 0xca0000f8, 0x58000002, 0xca4000f8, 0x5838000e, 0x00000000, 0xce0000f9, 0xce4000f8, 0xc2400000,
+ 0xdd250038, 0xc1000080, 0x45248000, 0xc2400000, 0xc6240078, 0x46510000, 0x00000000, 0xc52400fc,
+ 0x5d240078, 0xc1000078, 0xc52400fc, 0xc6600078, 0x5c000002, 0xce000078, 0xc000492a, 0xca0000f8,
+ 0xc2c00002, 0x6afd6000, 0x722d0000, 0xce0000f8, 0xc000492c, 0xca0000f8, 0xc2c00002, 0x6afd6000,
+ 0x722d0000, 0xce0000f8, 0x80000040, 0xc000492c, 0xca0000f8, 0xc2c00002, 0x6afd6000, 0x7ec16000,
+ 0x762d0000, 0xce0000f8, 0xa4880088, 0xc2c00000, 0xc000140e, 0xcac20018, 0xc000490e, 0xca4000f8,
+ 0xc2000002, 0x6a2d0000, 0x7e010000, 0x76612000, 0xce4000f8, 0xc0004990, 0xca4000f8, 0xc2000002,
+ 0x6a2d0000, 0x72612000, 0xce4000f8, 0xa4860070, 0xc2400000, 0xc000140e, 0xca418018, 0xc2020002,
+ 0xc0004900, 0xce002100, 0xc0004908, 0xce4000f8, 0xc1000000, 0xd90000f9, 0xd8400078, 0xc1000004,
+ 0xd90000f9, 0xa48c00e8, 0xc2400000, 0xc000140e, 0xca430018, 0x00000000, 0x00000000, 0x5d240002,
+ 0x84000058, 0xc00048c4, 0xca0000f8, 0xc00048c6, 0xc1040002, 0x72110000, 0xce0000f8, 0xc1000002,
+ 0xc00048cc, 0xcd000000, 0x80000060, 0x5d240004, 0x84000050, 0xc00048c8, 0xca0000f8, 0xc00048ca,
+ 0xc1160002, 0x72110000, 0xce0000f8, 0xc1020002, 0xc00048cc, 0xcd002100, 0xc0001408, 0xcc8000f8,
+ 0xc10e0002, 0xd90c00f8, 0x8000f668, 0xdfbc00f9, 0xc0004992, 0x99007040, 0xc94000f8, 0xc7d800f8,
+ 0x00000000, 0xc57000f8, 0x5ef00020, 0x88000158, 0x6f346000, 0x4771a000, 0x5b744c80, 0x58340008,
+ 0xc2400000, 0xca400078, 0x00000000, 0xc2000000, 0x5a640002, 0xc6500078, 0xcd000078, 0x58340004,
+ 0xca000078, 0x00000000, 0x00000000, 0x5e200002, 0xc6100078, 0xcd000078, 0xc0004912, 0xca8000f8,
+ 0xc2400002, 0x6a712000, 0x72a54000, 0xce8000f8, 0x5e200000, 0x84000052, 0xc000480a, 0xca0000f8,
+ 0xc0000408, 0xca8000f8, 0x76250000, 0x00000000, 0x72a14000, 0xce8000f8, 0x80000038, 0xc0004914,
+ 0xca0000f8, 0x7e412000, 0x00000000, 0x76250000, 0xce0000f8, 0x800000c8, 0x6ef4a000, 0x476da000,
+ 0x5b744e20, 0x58340036, 0xc2400000, 0xca420078, 0x00000000, 0xc2000000, 0x5a640002, 0xc6501078,
+ 0xcd021078, 0x58340006, 0xca000078, 0x00000000, 0x00000000, 0x5a200002, 0xc6100078, 0xcd000078,
+ 0xc0004910, 0xca4000f8, 0xc2000002, 0x6a2d0000, 0x72612000, 0xce4000f8, 0xc2000002, 0x6a310000,
+ 0xc000042a, 0xce0000f8, 0xc1040002, 0xd90c00f8, 0x00000000, 0x8000f3d0, 0x00000000, 0xc4980928,
+ 0x9d000000, 0xc5580028, 0xc0000838, 0xcd8400f8, 0xc1440200, 0xc1c01600, 0xc55c1070, 0xc000100e,
+ 0x9d000000, 0xcd8000f8, 0xc000100c, 0xcdc000f8, 0xc0004862, 0xc9c000f8, 0x00000000, 0x00000000,
+ 0xd9d800f9, 0xc0005600, 0x401c0000, 0x5dc05800, 0x88000012, 0x5c000200, 0xcd8000f8, 0xc1f0000a,
+ 0x715ca000, 0xdd9800f8, 0xdd9c00f9, 0x41d8e000, 0xc5d40260, 0xc0001010, 0xcd4000f8, 0x6c9c8000,
+ 0x45c8e000, 0x45c8e000, 0x59dc0004, 0xc1601260, 0xc5d40260, 0x9d000000, 0xc0001012, 0xcd4000f8,
+ 0x00000000, 0x00000000, 0xd95800f8, 0x6d586000, 0x4594c000, 0x59984c80, 0xd99800f9, 0x5818000a,
+ 0xc1800000, 0xc9800078, 0xc0005400, 0x6d5ca000, 0x401c0000, 0x40180000, 0xc94000f8, 0x58000002,
+ 0x00000000, 0xc9c000f8, 0xc0004930, 0xcd4000f8, 0xc0004932, 0xcdc000f8, 0x59980004, 0xc1c20020,
+ 0xb59c0018, 0x00000000, 0xc1800000, 0xdd9c00f9, 0x581c000a, 0xcd800078, 0x581c000c, 0xc1800000,
+ 0xc9800020, 0xc1c00002, 0xdd9400f8, 0x69d4e000, 0x5d980002, 0xcd800020, 0xc0004924, 0xc98000f8,
+ 0x00000000, 0x9d000000, 0x00000000, 0x719cc000, 0xcd8000f8, 0xc000492a, 0xc94000f8, 0xc1c00002,
+ 0x69d8e000, 0x7dc0c000, 0x7558a000, 0xcd4000f8, 0xc000492c, 0xc94000f8, 0xdd8000f9, 0x5800003a,
+ 0x755ca000, 0x84000108, 0xc94000f9, 0xc98000f8, 0xdd8000f9, 0x5800000e, 0x00000000, 0xcd4000f9,
+ 0xcd8000f8, 0xc1800000, 0xdd190038, 0xc1000080, 0x45188000, 0xc1800000, 0xc5580078, 0x4590a000,
+ 0x00000000, 0xc51800fc, 0x5d180078, 0xc1000078, 0xc51800fc, 0xc5940078, 0x5c000002, 0xcd400078,
+ 0xc000492c, 0xc94000f8, 0xc000492a, 0xc98000f8, 0x715ca000, 0xc000492c, 0xcd4000f8, 0x719cc000,
+ 0xc000492a, 0xcd8000f8, 0x9cc00000, 0x00000000, 0x00000000, 0x00000000, 0xc0004862, 0xc98000f8,
+ 0x00000000, 0xc1c00200, 0x4194c000, 0x459ce000, 0x88000012, 0xc5d800f8, 0xc0004862, 0xcd8000f8,
+ 0xc0001406, 0xc98000f8, 0xc1c00002, 0x9d000000, 0xc5d80a00, 0xc5581048, 0xcd8000f8, 0xc0004930,
+ 0xc98000f8, 0xc0004932, 0xc9c000f8, 0xc140000e, 0xc5581c18, 0xdd9400f8, 0xc0005600, 0x40140000,
+ 0x5d405800, 0x88000012, 0x5c000200, 0xcd8000f8, 0x58000002, 0x5d405800, 0x88000012, 0x5c000200,
+ 0xcdc000f8, 0xdd5400f8, 0xc1c00000, 0x58140006, 0xc9c20078, 0xc1800000, 0x58140000, 0xc98000d8,
+ 0x6ddc2000, 0xc000491e, 0x41d8e000, 0xcdc000f8, 0xdd9800f8, 0xc1c00022, 0xc5d80d70, 0xdd9400f9,
+ 0xc5581c18, 0xc000491c, 0xcd8000f8, 0xdd5400f8, 0xc1c00000, 0x58140006, 0xc9c20078, 0xc1800000,
+ 0x58140004, 0xc9820078, 0x00000000, 0x59dc0002, 0x45d8c000, 0x84000010, 0xc1c00000, 0x9d000000,
+ 0x58140006, 0xc5d81078, 0xcd821078, 0xc0004860, 0xc94000f8, 0xc1820080, 0xc1d00002, 0x58146b00,
+ 0xd58000f8, 0x58000002, 0xd58000f9, 0x59540004, 0xb5580018, 0xc0004860, 0xc1400000, 0xcd4000f8,
+ 0xdd9800f9, 0x9d000000, 0xdd9400f8, 0xc0001404, 0xcdc10800, 0xc1c00000, 0xc1800200, 0x5d980004,
+ 0xdf5d0048, 0x459ca000, 0x8800fff2, 0xdd8000f9, 0x5800000e, 0x00000000, 0xc94000f9, 0xc98000f8,
+ 0xc1c00002, 0xc5d43f00, 0xc5d81e00, 0xc0004862, 0xc9c000f8, 0x00000000, 0x00000000, 0x581c5600,
+ 0x5dc05800, 0x88000012, 0x5c000200, 0xcd4000f8, 0x58000002, 0x5dc05800, 0x88000012, 0x5c000200,
+ 0xcd8000f8, 0xc0004862, 0xc9c000f8, 0x00000000, 0xc15004c0, 0xc5d40060, 0xdd9c00f8, 0xc5d41c18,
+ 0xc1c00000, 0xdd8000f9, 0x58000038, 0xc9c00078, 0xdd8000f9, 0xc1800000, 0x58000002, 0xc98000d8,
+ 0x6ddc2000, 0xc000491c, 0x41d8e000, 0xcd4000f9, 0xcdc000f8, 0xdd9400f9, 0xc1c00000, 0x58140038,
+ 0xc9c00078, 0xc1800000, 0x58140006, 0xc9820078, 0x00000000, 0x59dc0002, 0x45d8c000, 0x84000010,
+ 0xc1c00000, 0x9d000000, 0x58140038, 0xc5d80078, 0xcd800078, 0xc1c00000, 0xdf5c0038, 0x5ddc0080,
+ 0x8400ffea, 0x00000000, 0x9d000000, 0x00000000, 0x00000000, 0x00000000, 0xc160fffe, 0xc0000a10,
+ 0xc9440060, 0xc1a0fffe, 0x59980e28, 0xc000100c, 0xcd4000f8, 0xc000100e, 0xcd8000f8, 0xc0004962,
+ 0xc98000f8, 0x00000000, 0xc170000a, 0x7158a000, 0x6c988000, 0x4588c000, 0x4588c000, 0x59980004,
+ 0xc5940270, 0xc0001010, 0xcd4000f8, 0xc0004946, 0xc94000f8, 0x00000000, 0x00000000, 0x6d58a000,
+ 0x6d5c4000, 0x459cc000, 0x4594c000, 0xc000494a, 0xc94000f8, 0xc0004948, 0xc9c000f8, 0x4194c000,
+ 0xc1400012, 0xc55c1818, 0x9d000000, 0xc59c0268, 0xc0001012, 0xcdc000f8, 0xc1400000, 0x58000014,
+ 0xc9410038, 0xc0004950, 0xc9c000f8, 0xc55800f8, 0xc5940838, 0xc5581078, 0xd99400f8, 0xc000493c,
+ 0xc94000f8, 0xc0004954, 0xc98000f8, 0x59dc00a8, 0x45d4e000, 0x41d8e000, 0x5d5c0030, 0x88000010,
+ 0xc1c00030, 0xc1800000, 0xc5d84028, 0xc1400000, 0xc5d40008, 0x5dd40002, 0x84000072, 0x5dd40004,
+ 0x8400009a, 0x5dd40006, 0x840000c2, 0x5dd80026, 0x840000ea, 0xdd5400f8, 0xdd8000f9, 0x58000008,
+ 0x40180000, 0xcd4000f8, 0x59980002, 0x8000ffc0, 0xdd5400f8, 0xdd8000f9, 0x58000008, 0x40180000,
+ 0xcd4000b8, 0x59980002, 0x8000ff88, 0xdd5400f8, 0xdd8000f9, 0x58000008, 0x40180000, 0xcd400078,
+ 0x59980002, 0x8000ff50, 0xdd5400f8, 0xdd8000f9, 0x58000008, 0x40180000, 0xcd400038, 0x59980002,
+ 0x8000ff18, 0x00000000, 0x9d000000, 0x00000000, 0x00000000, 0x00000000, 0x58000014, 0xc94000f8,
+ 0xc0004954, 0xc9c000f8, 0xc0004950, 0xc9400078, 0xdd8000f9, 0x5800002a, 0x5d9c0000, 0x84000052,
+ 0x5d9c0002, 0x84000052, 0x5d9c0004, 0x8400006a, 0xc55b0038, 0xc55c08b8, 0xcd800039, 0xcdc108b8,
+ 0x80000060, 0xcd4000f8, 0x80000050, 0xc55900b8, 0xc55c1838, 0xcd8000b9, 0xcdc31838, 0x80000028,
+ 0xc55a0078, 0xc55c1078, 0xcd800079, 0xcdc21078, 0x9d000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xc1e00000, 0xa540001a, 0xc0000a14, 0xc1a20002, 0x9d000000, 0xcd863100, 0xc0000a1c, 0xcdc61038,
+ 0x59540002, 0x6994e018, 0x61c0c008, 0x4194a000, 0x5d940040, 0x88000012, 0xc59400f8, 0x9d000000,
+ 0xcd4000f8, 0x00000000, 0x00000000,
+};
+
+static unsigned int firmware_binary_data[] = {
+};
+
+
+#endif // IFXMIPS_PTM_FW_AMAZON_SE_H
diff --git a/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_fw_ar9.h b/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_fw_ar9.h
new file mode 100644
index 0000000..a61d313
--- /dev/null
+++ b/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_fw_ar9.h
@@ -0,0 +1,473 @@
+#ifndef IFXMIPS_PTM_FW_AR9_H
+#define IFXMIPS_PTM_FW_AR9_H
+
+
+/******************************************************************************
+**
+** FILE NAME : ifxmips_ptm_fw_ar9.h
+** PROJECT : UEIP
+** MODULES : PTM (ADSL)
+**
+** DATE : 22 OCT 2007
+** AUTHOR : Xu Liang
+** DESCRIPTION : PTM Driver (PP32 Firmware)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 22 OCT 2007 Xu Liang Initiate Version, v00.01
+*******************************************************************************/
+
+
+#define PTM_FW_VER_MAJOR 0
+#define PTM_FW_VER_MINOR 17
+
+
+static unsigned int firmware_binary_code[] = {
+ 0x800004b8, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8000ffe0, 0x00000000, 0x00000000, 0x00000000,
+ 0xc1000002, 0xd90c00f8, 0xc2000002, 0xda0800f9, 0x80005270, 0xc2000000, 0xda0800f9, 0x80005210,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x80005a00, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xc10e0002, 0xd90c00f8, 0xc0004808, 0xc84000f8, 0x80004ee0, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xc3e1fffe, 0x597dfffe, 0x593dfef4, 0x900004d9, 0x00000000, 0x00000000, 0x00000000, 0x90cc0481,
+ 0x00000000, 0x00000000, 0x00000000, 0xc3e0a262, 0x5bfc0022, 0xc0004002, 0xcfc000f8, 0xc0004810,
+ 0xcbc000f8, 0x00000000, 0xc3800000, 0xc7f80038, 0x5fb80000, 0xc7fa0038, 0xc7bfe802, 0x5fb80000,
+ 0x00000000, 0xc7bff802, 0xdbd400f9, 0xc00049a0, 0xc3800002, 0xa7ca006a, 0xc1200000, 0x5911fffe,
+ 0xcd0000f9, 0xc1200000, 0x59102042, 0xcd0000f9, 0xc1000004, 0xcd0000f9, 0xc1200000, 0x59103a1e,
+ 0xcd0000f9, 0x80000060, 0xc121fffe, 0x5911fffe, 0xcd0000f9, 0xc1203db8, 0x5910de82, 0xcd0000f9,
+ 0xc1000006, 0xcd0000f9, 0xc120385a, 0x591033da, 0xcd0000f9, 0x5fb80002, 0x8800001a, 0x6ffe0010,
+ 0x8000ff28, 0xdd7c00f9, 0xc3800000, 0xc7f86010, 0x5bb80008, 0xc3540002, 0x777da000, 0xc1000008,
+ 0x4791c002, 0xcf8000f9, 0xdb900038, 0xc3800008, 0xc3720002, 0x777da000, 0xa7f00028, 0x47b9c002,
+ 0xc1000000, 0xc7d26010, 0x4391c000, 0xcf8000f8, 0xdb900838, 0xc3c00000, 0xdbc800f9, 0xc0400000,
+ 0xc11c0000, 0xc000082c, 0xcd05ce00, 0xc11c0002, 0xc000082c, 0xcd05ce00, 0xc0400002, 0xc11c0000,
+ 0xc000082c, 0xcd05ce00, 0xc11c0002, 0xc000082c, 0xcd05ce00, 0xc0000824, 0x00000000, 0xcbc000f9,
+ 0xcb8000f9, 0xcb4000f9, 0xcb0000f8, 0xc0004878, 0x5bfc4000, 0xcfc000f9, 0x5bb84000, 0xcf8000f9,
+ 0x5b744000, 0xcf4000f9, 0x5b304000, 0xcf0000f8, 0xc0000a10, 0x00000000, 0xcbc000f9, 0xcb8000f8,
+ 0xc0004874, 0x5bfc4000, 0xcfc000f9, 0x5bb84000, 0xcf8000f8, 0xc30001fe, 0xc000140a, 0xcf0000f8,
+ 0xc3000000, 0x7f018000, 0xc000042e, 0xcf0000f8, 0xc000040e, 0xcf0000f8, 0xc3c1fffe, 0xc000490e,
+ 0xcfc00078, 0xc000492c, 0xcfc00078, 0xc0004924, 0xcfc00038, 0xc0004912, 0xcfc00038, 0xc000498c,
+ 0xcfc00038, 0xc000498e, 0xcfc00078, 0xc0004990, 0xcfc00078, 0xc3c00000, 0xc2800004, 0xc3000000,
+ 0x7f018000, 0x6ff88000, 0x6fd44000, 0x4395c000, 0x5bb87e00, 0xc00049a0, 0xcb0000f8, 0x00000000,
+ 0x58380006, 0xcf0000f8, 0xc321fffe, 0x5b31fffe, 0x58380024, 0xcf0000f8, 0x5bfc0002, 0xb7e8ff90,
+ 0x00000000, 0xc3c00000, 0xc2800010, 0x6ff86000, 0x47bdc000, 0x5bb84c80, 0xc3400000, 0x58380004,
+ 0xcb420078, 0x00000000, 0x58380008, 0xcf400078, 0x5bfc0002, 0xb7e8ffb0, 0x00000000, 0xc3c00000,
+ 0xc2800004, 0xc3400022, 0xc3000000, 0x7f018000, 0xc2c00016, 0x6ff8a000, 0x47bdc000, 0x5bb87600,
+ 0x58380008, 0xcf400038, 0xc00049a8, 0xcb0000f8, 0x00000000, 0x5838000a, 0xcf0000f8, 0xc321fffe,
+ 0x5b31fffe, 0x5838000c, 0xcf0000f8, 0x58380034, 0xcec00038, 0x5bfc0002, 0xb7e8ff78, 0x00000000,
+ 0x00000000, 0xc0004840, 0xc3e12624, 0x5bfc2320, 0xcfc000f9, 0xc3e02f2c, 0x5bfd2a28, 0xcfc000f9,
+ 0xc3e03734, 0x5bfd3230, 0xcfc000f9, 0xc3e13e3c, 0x5bfc3b38, 0xcfc000f9, 0xc3e14644, 0x5bfc4340,
+ 0xcfc000f9, 0xc3e04f4c, 0x5bfd4a48, 0xcfc000f9, 0xc3e05754, 0x5bfd5250, 0xcfc000f9, 0xc3e15e5c,
+ 0x5bfc5b58, 0xcfc000f9, 0xc3e06764, 0x5bfd6260, 0xcfc000f9, 0xc3e16e6c, 0x5bfc6b68, 0xcfc000f9,
+ 0xc3e17674, 0x5bfc7370, 0xcfc000f9, 0xc3e07f7c, 0x5bfd7a78, 0xcfc000f9, 0xc3e18684, 0x5bfc8380,
+ 0xcfc000f9, 0xc3e08f8c, 0x5bfd8a88, 0xcfc000f9, 0xc3e09794, 0x5bfd9290, 0xcfc000f9, 0xc3e19e9c,
+ 0x5bfc9b98, 0xcfc000f9, 0xc121fffe, 0x5911fef4, 0x14100000, 0x80000028, 0x00000000, 0x800004e8,
+ 0x00000000, 0x8000ffe0, 0xc0004918, 0xd28000f8, 0xc2000000, 0xdf600038, 0x5e600080, 0x840002b2,
+ 0x00000000, 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0xc000480a, 0xca0000f8, 0xc0004912, 0xca4000f8, 0xc0004924, 0xca8000f8,
+ 0xc000498c, 0xcac000f8, 0xc121fffe, 0x5911fef4, 0x14100000, 0x76250000, 0x76290000, 0x762d0000,
+ 0x840001ea, 0xc0004918, 0xca4000f8, 0xc28001fe, 0x76290000, 0x5a640002, 0x6a254010, 0x5ee80000,
+ 0x8400001a, 0x6aa54000, 0x80000010, 0xc62800f8, 0x62818008, 0xc0004918, 0xcf0000f8, 0xc161fffe,
+ 0x5955fffe, 0x14140000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xc000498c, 0xca4000f8, 0xc2000002, 0x6a310000, 0x7e010000, 0x76612000, 0xce4000f8, 0xc121fffe,
+ 0x5911fef4, 0x14100000, 0x6f346000, 0x4771a000, 0x5b744c80, 0xc2800000, 0x58340006, 0xca800078,
+ 0xc2c00000, 0x58340000, 0xcac000d8, 0xc2400000, 0x5834000a, 0xca420078, 0x6ea82000, 0x42e9e000,
+ 0x6f2ca000, 0x42e56000, 0x5aec3680, 0xc3990040, 0xc7381c18, 0xc6f80060, 0x99006480, 0xdb9800f8,
+ 0xdbd800f9, 0x00000000, 0xdea000f8, 0x46310000, 0x8400fd40, 0xc000495a, 0xc84000f8, 0x00000000,
+ 0xc3c00002, 0x787c2000, 0xcc4000f8, 0xc0000838, 0xc3800000, 0xcb840028, 0x6c748000, 0x6c544000,
+ 0x4355a000, 0x5b747e00, 0x5ef80000, 0x8400fca2, 0x58340004, 0xcb0000f8, 0x00000000, 0x00000000,
+ 0xa7060020, 0x00000000, 0x5ef80002, 0x8400fc62, 0x5834000c, 0xc8800038, 0xc2000000, 0xc000082c,
+ 0xca040028, 0x5a880002, 0xc2400000, 0xc0004958, 0xce4000f8, 0xb6280018, 0x00000000, 0xc2800000,
+ 0x58340002, 0xc2000000, 0xca020008, 0xc0004956, 0xce8000f8, 0x5e600000, 0x84001ca2, 0x5e600002,
+ 0x84004062, 0x00000000, 0x800021d0, 0xc0004958, 0xca0000f8, 0xc0004956, 0xca8000f8, 0x5e200000,
+ 0x84000020, 0xc2500002, 0xc0000838, 0xce450800, 0x6c748000, 0x6c544000, 0x4355a000, 0x5b747e00,
+ 0x5834000c, 0xc6900038, 0xcd000038, 0x8000fb38, 0xc2000000, 0xdf600038, 0x5e200080, 0x8400028a,
+ 0x00000000, 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0xc000480c, 0xca0000f8, 0xc0004910, 0xca4000f8, 0xc000492c, 0xca8000f8,
+ 0xc000498e, 0xcac000f8, 0xc121fffe, 0x5911fef4, 0x14100000, 0x76250000, 0x76290000, 0x76e16000,
+ 0x840001c2, 0xc0004926, 0xca4000f8, 0xc201fffe, 0x76e16000, 0x5a640002, 0x6ae50010, 0x5f200000,
+ 0x8400001a, 0x6a250000, 0x80000010, 0xc6e000f8, 0x62014008, 0xc0004926, 0xce8000f8, 0xc161fffe,
+ 0x5955fffe, 0x14140000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xc000498e, 0xca4000f8, 0xc2000002, 0x6a290000, 0x7e010000, 0x76612000, 0xce4000f8, 0xc121fffe,
+ 0x5911fef4, 0x14100000, 0x6eb4a000, 0x4769a000, 0x5b747600, 0x58340002, 0xc2000000, 0xca0000d8,
+ 0x58340036, 0xc2400000, 0xca400078, 0x6eb0a000, 0x47298000, 0x5b303636, 0x5b300004, 0x6e642000,
+ 0x4225e000, 0xc39a8024, 0xc7380060, 0xc6b81c18, 0x99006480, 0xdb9800f8, 0xdbd800f9, 0x00000000,
+ 0xc2000000, 0xdf600038, 0x5e200080, 0x840002da, 0x00000000, 0xc161fffe, 0x5955fffe, 0x14140000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xc000490e, 0xca0000f8,
+ 0xc000492a, 0xca4000f8, 0xc0004990, 0xcb0000f8, 0xc000498a, 0xcac000f8, 0xc121fffe, 0x5911fef4,
+ 0x14100000, 0x77218000, 0x77258000, 0x8400021a, 0xc201fffe, 0x77218000, 0x5aec0002, 0x6b2d0010,
+ 0x5ea00000, 0x8400001a, 0x6a2d0000, 0x80000010, 0xc72000f8, 0x62016008, 0xc000498a, 0xcec000f8,
+ 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0xc0004990, 0xca4000f8, 0xc2000002, 0x6a2d0000, 0x7e010000, 0x76612000, 0xce4000f8,
+ 0xc121fffe, 0x5911fef4, 0x14100000, 0x6ef4a000, 0x476da000, 0x5b747600, 0x58340010, 0xc2000000,
+ 0xca0000d8, 0x58340008, 0xc2400000, 0xca420078, 0x5834000e, 0xc2800000, 0xca832010, 0xc3c00000,
+ 0x47e48000, 0x6e644010, 0xc7e800fc, 0x42250000, 0x4229e000, 0xc39a8008, 0x58340008, 0xcb801038,
+ 0x58340008, 0xc2800000, 0xca810010, 0x6ee0a000, 0x462d0000, 0x5a20000a, 0x5a203608, 0x42290000,
+ 0xc6380060, 0xc6f81c18, 0x99006480, 0xdb9800f8, 0xdbd800f9, 0x00000000, 0xc000495c, 0xc84000f8,
+ 0xc3400000, 0xc3c00002, 0x787c2000, 0xcc4000f8, 0x6c78a000, 0x4785c000, 0x5bb87600, 0x58380034,
+ 0xcb410038, 0xc0000a28, 0xc3000000, 0xcb040028, 0xc0000a14, 0xc2c00000, 0x43358000, 0xcac40028,
+ 0xc000490e, 0xca8000f8, 0x5eec0002, 0x472d8000, 0x8800f4c8, 0x6bc5e000, 0x76bd4000, 0x8400f4b0,
+ 0x6c7ca000, 0x47c5e000, 0x5bfc7600, 0x583c0008, 0xc2000000, 0xca020078, 0xc00049aa, 0x00000000,
+ 0xca8000f9, 0xca4000f8, 0xc0001008, 0xce8000f8, 0xc0001006, 0xce4000f8, 0x583c000a, 0xca4000f8,
+ 0x00000000, 0xc000100a, 0xce4000f8, 0xc2400006, 0xc0001000, 0xce4000f8, 0xc2600982, 0x5a643b6e,
+ 0xc0001002, 0xce4000f8, 0x583c000c, 0xca4000f8, 0x00000000, 0xc0001004, 0xce4000f8, 0x583c000e,
+ 0xcb8000f8, 0x00000000, 0xc2400000, 0xc7a40078, 0xc2800000, 0xc7aae020, 0xdaa000f9, 0x583c0034,
+ 0xcb8000f8, 0x00000000, 0xc2c00000, 0xc7ad0038, 0xc0004978, 0xcec000f8, 0xc0800000, 0xc7880038,
+ 0xc3400000, 0xc7b60038, 0xc0004980, 0xcf4000f8, 0x4661c000, 0x43a9c000, 0xc2400000, 0xc000497c,
+ 0xce4000f8, 0xad2c0001, 0xc2800000, 0x00000000, 0x80000010, 0xc2800002, 0xc0004976, 0xce8000f8,
+ 0xc2c00000, 0xc34000a0, 0xdb5c00f9, 0xc3400002, 0xc000497a, 0xcf4000f8, 0x5f600000, 0x84000180,
+ 0xde2800f9, 0xc6a000f8, 0x47a9c000, 0x583c0000, 0xc2800000, 0xca830038, 0xc0000a28, 0xc3000000,
+ 0xcb040028, 0xc3400000, 0xc0004976, 0x46b18000, 0x8800006a, 0xcf4000f8, 0x58880002, 0xc3000000,
+ 0xc0000a14, 0xcb040028, 0x00000000, 0x00000000, 0xb4b001a8, 0x00000000, 0xc0800000, 0x00000000,
+ 0x80000188, 0xc0004980, 0xcb4000f8, 0x00000000, 0x00000000, 0x5af40002, 0xacec0080, 0x00000000,
+ 0xc2c00000, 0xc000497a, 0xadec0001, 0x00000000, 0x00000000, 0xad2c007f, 0xc2800000, 0xce8000f8,
+ 0x80000018, 0xc2800002, 0xce8000f8, 0x5f6c0000, 0x840000e8, 0x00000000, 0x8000ff00, 0x5f780082,
+ 0x88000258, 0xc3000002, 0xc000497c, 0xcf0000f8, 0xc2800080, 0xc1000000, 0xdd110038, 0x46914000,
+ 0x47a94000, 0x880001d8, 0x4391a000, 0xc0004980, 0xcf4000f8, 0x6f684010, 0x6f77c000, 0x6f77c010,
+ 0xc0004840, 0x40280000, 0xca8000f8, 0xc3000000, 0x6f506000, 0x6a908010, 0xc5300038, 0xdb1c00f9,
+ 0x8000fe30, 0xc3400000, 0xc0000a10, 0xcb440060, 0x6cb04000, 0x6f288000, 0x6f744000, 0x42b14000,
+ 0x43694000, 0xc3400000, 0xc6b44060, 0xc0004000, 0x40340000, 0xc321e000, 0xcf0000f8, 0x5aa80008,
+ 0x42ad4000, 0xc3400000, 0xc6b44060, 0xc0004000, 0x40340000, 0xca4000f8, 0xc3000000, 0xc6f00008,
+ 0xc1400000, 0xddd40039, 0x6f306000, 0xc13001fe, 0x69308010, 0x7d008000, 0x76512000, 0x6d570000,
+ 0x6970a010, 0x42552000, 0xce4000f8, 0x5aa80002, 0x5aec0002, 0xacec0080, 0x00000000, 0xc2c00000,
+ 0x5f6c0000, 0x84000118, 0x00000000, 0x80000040, 0x4391a000, 0x5f740080, 0xc0004980, 0xcf4000f8,
+ 0xc3000004, 0xc000497a, 0xcf0000f8, 0x58880002, 0xc3400000, 0xc0000a14, 0xcb440028, 0x00000000,
+ 0x00000000, 0xb4b40018, 0x00000000, 0xc0800000, 0xc3400000, 0xc0000a10, 0xcb440060, 0x6cb04000,
+ 0x6f248000, 0x6f744000, 0x42712000, 0x43654000, 0xc3400000, 0xc6b44060, 0xc0004000, 0x40340000,
+ 0xc3201e00, 0xcf0000f8, 0x5aa80008, 0x42ad4000, 0xc000100c, 0xcb4000f8, 0xc3000000, 0x00000000,
+ 0xc7340060, 0xc300fffe, 0xc7341070, 0xcf4000f8, 0xc000100e, 0xcb4000f8, 0xc3003608, 0x00000000,
+ 0xc7340060, 0xc300fffe, 0xc7341070, 0xcf4000f8, 0xc0001010, 0xcb4000f8, 0xc3000002, 0x00000000,
+ 0xc7341a00, 0xc7341800, 0xc3000000, 0xc7341900, 0xc6b40070, 0xcf4000f8, 0xc0004982, 0xce8000f8,
+ 0x6c64a000, 0x46452000, 0x5a64000a, 0xc0001012, 0xcb4000f8, 0xc2800002, 0x00000000, 0xc6740260,
+ 0xc6340008, 0xc000497c, 0xcb0000f8, 0xc6b41800, 0xc6b41b00, 0xc6b41c00, 0xc6b41d00, 0xc7341e00,
+ 0xdd6800f9, 0x7e814000, 0x6eab2010, 0x76b14000, 0xc6b41f00, 0xc2800000, 0xc6b41900, 0xc3000080,
+ 0x472d8000, 0xc0004982, 0xc90000f8, 0x47394000, 0x88000102, 0x41388000, 0xcd0000f8, 0xc7b41038,
+ 0xc0004994, 0xce8000f8, 0xde1000f9, 0x45208000, 0x840000b0, 0xc1000000, 0xdd110038, 0x41388000,
+ 0x412c8000, 0x5d100080, 0xc0004980, 0xcd0000f8, 0xc1000002, 0xc000497c, 0xcd0000f8, 0xc5341e00,
+ 0xdd5000f9, 0x7d008000, 0xc5373f00, 0xc000497a, 0xc90000f8, 0x42390000, 0x43adc000, 0x59100002,
+ 0xcd0000f8, 0x80000050, 0x42390000, 0x80000040, 0xc7341038, 0x41308000, 0xcd0000f8, 0x42310000,
+ 0xc1000000, 0xc0004994, 0xcd0000f8, 0xc0001012, 0xcf4000f8, 0xc000493c, 0xce0000f8, 0xc0004984,
+ 0xcf8000f8, 0xc000497a, 0xca4000f8, 0xc000497c, 0xca8000f8, 0x6c7ca000, 0x47c5e000, 0x5bfc7600,
+ 0xc0004976, 0xcac000f8, 0xc0004978, 0xca0000f8, 0x5eec0002, 0x8400008a, 0x42250000, 0xc2400000,
+ 0xc000497a, 0xce4000f8, 0x583c0000, 0xc2c00000, 0xcac30038, 0x00000000, 0x00000000, 0x46e16000,
+ 0x8800001a, 0x00000000, 0xad280002, 0xc000497a, 0xce0000f8, 0xc2000000, 0x5fa80000, 0x840001da,
+ 0x00000000, 0x6c508000, 0xc0004880, 0x40100000, 0x58000018, 0xc90000f8, 0x00000000, 0x00000000,
+ 0x59100002, 0xcd0000f8, 0x583c000e, 0xc2c00000, 0xcac00078, 0xc1000000, 0xdd532201, 0x42d16000,
+ 0x6c508000, 0xc0004880, 0x40100000, 0x5800001a, 0xc90000f8, 0x00000000, 0x00000000, 0x412c8000,
+ 0xcd0000f8, 0x99006510, 0xd85800f8, 0xdbd800f9, 0x00000000, 0x99006258, 0xc000491c, 0xc1400000,
+ 0xc9420048, 0xc000491c, 0x99006710, 0xc94000f9, 0xc98000f8, 0x00000000, 0x99006480, 0xd95800f8,
+ 0xd99800f9, 0x00000000, 0xc161fffe, 0x5955fffe, 0x14140000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x98c060d0, 0xd85800f8, 0xdbd800f9, 0xc45800f8, 0xc121fffe,
+ 0x5911fef4, 0x14100000, 0xade80003, 0xc000493c, 0xcb4000f8, 0x00000000, 0xc3000000, 0xc7701078,
+ 0x80000010, 0xc3000000, 0x583c0008, 0xcf021078, 0x6e210000, 0x583c0034, 0xce010838, 0xc0004980,
+ 0xcb8000f8, 0x583c0034, 0x00000000, 0x6fba0000, 0xcf821038, 0xc000490e, 0xca0000f8, 0xc2c00002,
+ 0x6ac56000, 0x722d0000, 0xce0000f8, 0x00000000, 0x00000000, 0x00000000, 0xa8e2ffe8, 0x00000000,
+ 0xc1220002, 0xd90c00f8, 0x5fa80000, 0x84000712, 0xc00049a8, 0xca0000f8, 0x583c000a, 0x00000000,
+ 0xce0000f8, 0xc221fffe, 0x5a21fffe, 0x583c000c, 0xce0000f8, 0xc0001004, 0xca0000f8, 0x00000000,
+ 0x583c0012, 0x7e010000, 0xce0000f8, 0xa97000e1, 0x00000000, 0x00000000, 0xa97200c9, 0xc0001010,
+ 0xc2740000, 0xce435a00, 0x6c64a000, 0x46452000, 0x5a64000a, 0x6e644000, 0xc0001012, 0xce400070,
+ 0xc2600008, 0xce421038, 0xc27e0002, 0xce43ff00, 0xc2760002, 0xce437b00, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0xa8e2ffe8, 0x00000000, 0xc1220002, 0xd90c00f8, 0xc1000000,
+ 0xdd110038, 0x5d100000, 0x84000412, 0xc0004982, 0xca0000f8, 0xc0004984, 0xca4000f8, 0xc2800000,
+ 0xc361fffe, 0x5b75fffe, 0xa96a001b, 0xdfec00f8, 0xc6ec1078, 0x7af56000, 0x6c40a000, 0x44040000,
+ 0x58007600, 0x58000014, 0xcec000f8, 0xa972001b, 0x5c000002, 0xcec000f8, 0xc0001010, 0xc2f40002,
+ 0xcec35a00, 0x6c6ca000, 0x46c56000, 0x5aec000a, 0x6eec4000, 0xc0001012, 0xcec00070, 0xc0004994,
+ 0xc98000f8, 0xc1400000, 0xdd150038, 0xc55c00f8, 0x45948000, 0x00000000, 0xc59c00fc, 0x5d1c0000,
+ 0x840000d2, 0xc0001012, 0xc5d01038, 0xcd021038, 0xc2f60002, 0xcec37b00, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0xa8e2ffe8, 0x00000000, 0xc1220002, 0xd90c00f8, 0x45948000,
+ 0x88000052, 0xc0004994, 0xcd0000f8, 0xc0004980, 0xcbc000f8, 0x42150000, 0xc0004982, 0xce0000f8,
+ 0x5ffc0000, 0x84000218, 0x58880002, 0xc3800000, 0xc0000a14, 0xcb840028, 0xc3c00000, 0xc0000a10,
+ 0xb4b80018, 0x00000000, 0xc0800000, 0xcbc40060, 0x6cb84000, 0x6fac8000, 0x6ffc4000, 0x42f96000,
+ 0x43ed0000, 0xc3400000, 0xc6344060, 0xc0004000, 0x40340000, 0xc2a1e000, 0xce8000f8, 0x5a200008,
+ 0xc0004980, 0xcbc000f8, 0xc3400000, 0xc0004840, 0x6ff84010, 0xc7f40008, 0x40380000, 0xcb8000f8,
+ 0xc2800000, 0x6f506000, 0x6b908010, 0xc52c1838, 0xc3400000, 0xc6344060, 0xc0004000, 0x40340000,
+ 0xcec000f8, 0x5a200002, 0x5ffc0000, 0x84000092, 0xc0001010, 0xc62c0070, 0xcec00070, 0xc0001012,
+ 0xc7ec1038, 0xcec21038, 0xc2f60002, 0xcec37b00, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0xa8e2ffe8, 0x00000000, 0xc1220002, 0xd90c00f8, 0xc0004994, 0xc100007e, 0x453c8000,
+ 0xcd0000f8, 0x423d0000, 0xc0004982, 0xce0000f8, 0xc0004994, 0xca0000f8, 0xc0004980, 0xca4000f8,
+ 0x5e200000, 0x8400015a, 0xc2000000, 0xc2800000, 0x5a640002, 0xc6684028, 0xc0004982, 0xcb0000f8,
+ 0xc0004000, 0xc2c00000, 0xc72c4060, 0x402c0000, 0x6e67c000, 0x6e67c010, 0x5ee40002, 0x8400003a,
+ 0x5ee40004, 0x8400004a, 0x5ee40006, 0x8400005a, 0x00000000, 0x80000060, 0xce0000b8, 0x5aa80002,
+ 0x5b300006, 0x80000040, 0xce000078, 0x5aa80002, 0x5b300004, 0x80000020, 0xce000038, 0x5aa80002,
+ 0x5b300002, 0x5ee80020, 0x84000052, 0xc0004000, 0xc2c00000, 0xc72c4060, 0x402c0000, 0xce0000f8,
+ 0x5aa80002, 0x5b300008, 0x8000ffb8, 0x00000000, 0x80000040, 0x583c000a, 0xd7c000f8, 0xc0001004,
+ 0xca4000f8, 0x00000000, 0x583c000c, 0xce4000f8, 0xc000497a, 0xca4000f8, 0xc2800002, 0xc0000a28,
+ 0xc6780928, 0xc6b80800, 0xcf850830, 0x6c7ca000, 0x47c5e000, 0x5bfc7600, 0x583c0034, 0xc4900038,
+ 0xcd000038, 0x8000e418, 0x6c6c8000, 0x6c544000, 0x42d56000, 0x5aec7e00, 0xc0000824, 0xca0400f8,
+ 0x6ca48000, 0x42492000, 0xc3000000, 0xc3400000, 0x42250000, 0x58204000, 0xca4000f8, 0x5a200002,
+ 0xda2400f9, 0xc2800000, 0xc000495e, 0xce8000f8, 0xda6000f8, 0xc2800000, 0xc66b0038, 0xdaa800f8,
+ 0x582c0010, 0x6f206010, 0x40200000, 0xd82800f9, 0xca0000f8, 0xc2400000, 0xc7240010, 0x6e644000,
+ 0xda6400f8, 0x6a254010, 0xc3c00000, 0xc6bc0018, 0xc3800000, 0xdea000f8, 0x5e60001e, 0x8400002a,
+ 0x5e6001e0, 0x8400001a, 0x00000000, 0x80000080, 0xc7f800f8, 0x5e7c0008, 0x8400006a, 0x5bbc0002,
+ 0x5e780008, 0x84000028, 0x5b740002, 0xc0004960, 0xcf0000f8, 0x80000030, 0x5e780006, 0x88000022,
+ 0xc2800002, 0xc000495e, 0xce8000f8, 0xde8000f9, 0xca8000f8, 0xde6000f8, 0xc240001e, 0x6a612000,
+ 0x7e412000, 0x76a54000, 0x6ba12000, 0x72a54000, 0xce8000f8, 0x5e300080, 0x840000ba, 0xc2000000,
+ 0xc7200008, 0x5e600000, 0x84000058, 0xde6000f9, 0x58204000, 0xca4000f8, 0x5a200002, 0xda2400f9,
+ 0xc2800000, 0xc66b0038, 0xdaa800f8, 0xda6000f8, 0x80000038, 0xc2800000, 0x6e206000, 0xde2400f8,
+ 0x6a610000, 0xc62b0038, 0xdaa800f8, 0x5b300002, 0x8000fde0, 0xc2000000, 0x582c0020, 0xca020078,
+ 0x00000000, 0xc2400000, 0x5a200002, 0xc6241078, 0xce421078, 0xc000480e, 0xca8000f8, 0x5e740000,
+ 0x84000160, 0x46a12000, 0x8800e048, 0xc2400000, 0xc0000808, 0xca440010, 0x582c0010, 0xc1400000,
+ 0xcd4000f9, 0xcd4000f9, 0xcd4000f9, 0xcd4000f9, 0xcd4000f9, 0xcd4000f9, 0xcd4000f9, 0xcd4000f9,
+ 0xcd400018, 0x582c0020, 0xce021078, 0xc2000010, 0x5a640002, 0xb6240018, 0x00000000, 0xc2400000,
+ 0xc6600010, 0xc0000808, 0xce040010, 0xc0004956, 0xca4000f8, 0xc11c0000, 0xc000082c, 0xcd05ce00,
+ 0xc6600928, 0xc2400000, 0xc6600028, 0xc0000838, 0xce0400f8, 0xc2400002, 0xc0004958, 0xce4000f8,
+ 0xc11c0002, 0xc000082c, 0xcd05ce00, 0x8000df00, 0xc000495e, 0xca0000f8, 0x5e740002, 0x8400dee0,
+ 0x5e200000, 0x8400ded0, 0xc0004960, 0xca4000f8, 0xc2200004, 0x582c0002, 0xce021008, 0xc2000082,
+ 0x46250000, 0xc6280030, 0xc0000810, 0xce840030, 0x99006ba8, 0x582c0002, 0xc94000f8, 0xc1a20000,
+ 0x5e640000, 0x8400fed0, 0x00000000, 0x8000de40, 0x6c6c8000, 0x6c544000, 0x42d56000, 0x5aec7e00,
+ 0xc000487c, 0xc80400f8, 0x00000000, 0x00000000, 0x40080000, 0xcb8000f8, 0xc42400f8, 0x00000000,
+ 0xa78601a0, 0xc3c00000, 0xc2000000, 0x582c000c, 0xca010038, 0x6c508000, 0xc0004880, 0x40100000,
+ 0x58000016, 0xc90000f8, 0x00000000, 0x00000000, 0x59100002, 0xcd0000f8, 0x5a200002, 0x582c000c,
+ 0xc6100838, 0xcd010838, 0x5e600002, 0x84000020, 0xc2200004, 0x582c0002, 0xce021008, 0x5e600008,
+ 0x84000060, 0xc2200002, 0x582c0002, 0xce021008, 0x582c000c, 0xcfc10838, 0xc2220002, 0xc0000a14,
+ 0xce063100, 0xc22001a2, 0xc0000a1c, 0xce061038, 0x6c6c8000, 0x6c544000, 0x42d56000, 0x5aec7e00,
+ 0x582c0004, 0xcb0000f8, 0xc3400000, 0x00000000, 0xa7060028, 0xcf406300, 0xc3100002, 0xc0000838,
+ 0xcf050800, 0x582c000c, 0xcf421000, 0x8000dc40, 0x582c000c, 0xcfc10838, 0xc2000000, 0xc7a06010,
+ 0x5e200000, 0x84001c08, 0x6c6c8000, 0x6c544000, 0x42d56000, 0x5aec7e00, 0xc000487c, 0xc80400f8,
+ 0x00000000, 0x00000000, 0x40080000, 0xcb8000f8, 0xc42400f8, 0x00000000, 0xc2800000, 0xc3400000,
+ 0xc7b5c030, 0xc0004970, 0xcf4000f8, 0xc2400000, 0xc7a4e030, 0xc000496c, 0xce4000f8, 0xc3000000,
+ 0xc7b00010, 0xc3c00004, 0xc000496e, 0xcfc000f8, 0x582c000c, 0xca0000f8, 0xc2400002, 0xc0004964,
+ 0xce4000f8, 0xa6200372, 0x00000000, 0x5e700004, 0x840000ea, 0x5e700006, 0x84000080, 0xc2000002,
+ 0x582c0002, 0xce000000, 0xc0000a14, 0xce863100, 0x6c508000, 0xc0004880, 0x40100000, 0x58000014,
+ 0xc90000f8, 0x00000000, 0x00000000, 0x59100002, 0xcd0000f8, 0x80001a58, 0x5e70000a, 0x84000040,
+ 0xc2000000, 0x582c0002, 0xce000000, 0xc2220002, 0xc0000a14, 0xce063100, 0x8000ff70, 0x5e700008,
+ 0x84000228, 0xc2200002, 0x582c000c, 0xce021000, 0x6c508000, 0xc0004880, 0x40100000, 0x58000012,
+ 0xc90000f8, 0x00000000, 0x00000000, 0x59100002, 0xcd0000f8, 0x5e340002, 0x6c508000, 0xc0004880,
+ 0x40100000, 0x58000010, 0xc90000f8, 0x00000000, 0x00000000, 0x41208000, 0xcd0000f8, 0xc0000a14,
+ 0xce863100, 0xc0004970, 0xcb4000f8, 0x6c6c8000, 0x6c544000, 0x42d56000, 0x5aec7e00, 0x582c000e,
+ 0xc4900038, 0xcd000038, 0x582c000e, 0xc7500838, 0xcd010838, 0xc2800000, 0x582c0004, 0xce821078,
+ 0x582c0004, 0xce800000, 0xc00049a0, 0xca4000f8, 0x00000000, 0x582c0006, 0xce4000f8, 0xc261fffe,
+ 0x5a65fffe, 0x582c0024, 0xce4000f8, 0xc2060002, 0x582c0004, 0xce006300, 0xc2400002, 0xc0004958,
+ 0xce4000f8, 0xc0004878, 0xc80400f8, 0x6c908000, 0x41088000, 0x40100000, 0x58000020, 0xc90000f8,
+ 0x582c0026, 0x00000000, 0xcd0000f8, 0x800017e8, 0x00000000, 0x6c508000, 0xc0004880, 0x40100000,
+ 0x58000016, 0xc90000f8, 0x00000000, 0x00000000, 0x59100002, 0xcd0000f8, 0x8000faf0, 0x5e700000,
+ 0x840000c0, 0xc3400082, 0xc0004970, 0xcf4000f8, 0xc2400080, 0xc000496c, 0xce4000f8, 0xc3c00002,
+ 0xc000496e, 0xcfc000f8, 0xc2400000, 0xc0004964, 0xce4000f8, 0xc0004878, 0xc80400f8, 0x6c908000,
+ 0x41088000, 0x40100000, 0x58000020, 0xc90000f8, 0x582c0026, 0x00000000, 0xcd0000f8, 0x80000078,
+ 0x5e700002, 0x84000058, 0xc3400082, 0xc0004970, 0xcf4000f8, 0xc3c00004, 0xc000496e, 0xcfc000f8,
+ 0xc2200000, 0x582c000c, 0xce021000, 0x80000030, 0x5e700004, 0x8400fe80, 0xc2600002, 0x582c000c,
+ 0xce421000, 0xc0000a14, 0xce863100, 0xc000496c, 0xca4000f8, 0x6c508000, 0xc0004880, 0x40100000,
+ 0x58000012, 0xc90000f8, 0x00000000, 0x00000000, 0x59100002, 0xcd0000f8, 0xc000496e, 0xcbc000f8,
+ 0x00000000, 0x00000000, 0x477d0000, 0x46250000, 0x6c508000, 0xc0004880, 0x40100000, 0x58000010,
+ 0xc90000f8, 0x00000000, 0x00000000, 0x41208000, 0xcd0000f8, 0x6c6c8000, 0x6c544000, 0x42d56000,
+ 0x5aec7e00, 0x582c0004, 0xca0000f8, 0x00000000, 0x00000000, 0xa60014e2, 0x00000000, 0x6c6c8000,
+ 0x6c544000, 0x42d56000, 0x5aec7e00, 0xc3000000, 0x582c0004, 0xcf006300, 0x582c0000, 0xcb002010,
+ 0xc3c00000, 0x582c0004, 0xcbc20078, 0xc000491a, 0xcf0000f8, 0xc000493c, 0xcfc000f8, 0x582c0008,
+ 0xcb8000f8, 0x582c000a, 0xca4000f8, 0xc0004930, 0xcf8000f8, 0xc0004932, 0xce4000f8, 0x5ffc0000,
+ 0x840001f0, 0x00000000, 0xa7be0102, 0xc2800000, 0x6f206000, 0x46310000, 0x5a204c80, 0x5820000c,
+ 0xca800020, 0x00000000, 0x00000000, 0x5ea80000, 0x84000112, 0x00000000, 0xc161fffe, 0x5955fffe,
+ 0x14140000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x99005f70,
+ 0xc000491a, 0xc94000f8, 0x00000000, 0xc121fffe, 0x5911fef4, 0x14100000, 0xc0004930, 0xcb8000f8,
+ 0xc0004932, 0xca4000f8, 0xc4781108, 0xc0004930, 0xcf8000f8, 0x582c0008, 0xcf8000f8, 0x582c000a,
+ 0xce4000f8, 0xc7b6e108, 0x582c0004, 0xcf402108, 0x80000090, 0x00000000, 0x6c508000, 0xc0004880,
+ 0x40100000, 0x5800000c, 0xc90000f8, 0x00000000, 0x00000000, 0x59100002, 0xcd0000f8, 0xc2000002,
+ 0x582c0004, 0xce000000, 0xc0000838, 0xc2500002, 0xce450800, 0x80001220, 0x6c7c8000, 0x6c544000,
+ 0x43d5e000, 0x5bfc7e00, 0x583c0006, 0xca0000f8, 0xc00049a2, 0x00000000, 0xca8000f9, 0xca4000f8,
+ 0xc0001008, 0xce8000f8, 0xc0001006, 0xce4000f8, 0xc000100a, 0xce0000f8, 0xc2400006, 0xc0001000,
+ 0xce4000f8, 0xc2600982, 0x5a643b6e, 0xc0001002, 0xce4000f8, 0x583c0024, 0xca4000f8, 0x00000000,
+ 0xc0001004, 0xce4000f8, 0xc0004862, 0xc2000000, 0xca000078, 0xc360fffe, 0xc0004862, 0xce0000f8,
+ 0xc0000824, 0xcb440060, 0x00000000, 0xc000100e, 0xcf4000f8, 0xc3803800, 0xc2400200, 0x6e644000,
+ 0xc6781070, 0xc000100c, 0xcf8000f8, 0xc3200a00, 0xc0001010, 0xcf031810, 0xc2e06200, 0xc0001012,
+ 0xcec31838, 0xc2000000, 0x583c0004, 0xca002008, 0xc2800000, 0xc0004966, 0xce0000f8, 0xc62400f8,
+ 0xc3000000, 0xc000496a, 0xcf0000f8, 0xc0004974, 0xcf0000f8, 0xc000493c, 0xcb4000f8, 0x583c000e,
+ 0x00000000, 0x5f740000, 0x84000180, 0xc3400000, 0xcb410038, 0xc3000002, 0xc000496a, 0x5fb40080,
+ 0x84000152, 0xcf0000f8, 0x583c000e, 0xc2c00000, 0xcac00038, 0xc3800080, 0x47b5c000, 0xc0004974,
+ 0xcf8000f8, 0xc0001012, 0x6fba0000, 0xcf821038, 0x6fba0010, 0x43a5c000, 0x5b380006, 0x6f284010,
+ 0xc7a40008, 0x6eec4000, 0x6ef08000, 0x432d8000, 0x43358000, 0x5b300008, 0xc0001012, 0xc7100070,
+ 0xcd000070, 0xc2000200, 0xc2c00000, 0xdf6d0048, 0x462d6000, 0x46e96000, 0x8800ffe2, 0xc2000000,
+ 0xc0004862, 0xca000260, 0x00000000, 0x583c0004, 0xca002008, 0xc3360002, 0xc0001010, 0xce000070,
+ 0xc0001012, 0xcf037b00, 0xc0004974, 0xcb8000f8, 0x00000000, 0x00000000, 0x5fb80000, 0x84000042,
+ 0x00000000, 0x00000000, 0x00000000, 0xa8e2ffe8, 0x00000000, 0xc1220002, 0xd90c00f8, 0xc000496c,
+ 0xcac000f8, 0x00000000, 0x00000000, 0x426dc000, 0x5b380006, 0x6f304010, 0xc7a40008, 0xc0004968,
+ 0xce4000f8, 0xc000496e, 0xcb4000f8, 0x6ca44000, 0x6e608000, 0x42250000, 0x5a200006, 0x42350000,
+ 0xc0001012, 0xc6100070, 0xcd000070, 0x6eee0000, 0xcec21038, 0xc2000200, 0xc2c00000, 0xdf6d0048,
+ 0x462d6000, 0x42b14000, 0x46e96000, 0x8800ffda, 0xc000493c, 0xcb4000f8, 0xc0000838, 0xc3100002,
+ 0x5f740000, 0x84000060, 0xcf050800, 0xc0004974, 0xcb8000f8, 0x00000000, 0x00000000, 0x5fb80000,
+ 0x8400006a, 0xc0001012, 0xc3360002, 0xcf037b00, 0x800000a0, 0x583c0022, 0xcb4000f8, 0xc0004862,
+ 0xca0000f8, 0x00000000, 0xc0007800, 0x40200000, 0xcf4000f8, 0xc2000000, 0xc0004862, 0xca000260,
+ 0x00000000, 0x583c0004, 0xca002008, 0xc3360002, 0xc0001010, 0xce000070, 0xc0001012, 0xcf037b00,
+ 0xc0004968, 0xcbc000f8, 0xc0004964, 0xca4000f8, 0xc7e000f8, 0x00000000, 0x5e640000, 0x84000012,
+ 0xc2000000, 0xc0004974, 0xca4000f8, 0xc000496c, 0xca8000f8, 0xc000493c, 0xcb8000f8, 0x42698000,
+ 0x00000000, 0x43b1a000, 0x5ef40080, 0x8800019a, 0xc0004966, 0xcac000f8, 0x6c648000, 0x6c544000,
+ 0x42552000, 0x5a647e00, 0x58240000, 0x436da000, 0x4761a000, 0xc2400000, 0xca420078, 0x00000000,
+ 0x00000000, 0x46752000, 0x88000122, 0x432d8000, 0x47218000, 0x88000010, 0xc3000000, 0x5b300006,
+ 0x6f304010, 0xc000493a, 0xcf0000f8, 0xc0004932, 0xc2400000, 0xca4000d8, 0x00000000, 0x6fb84010,
+ 0x42792000, 0xc000491e, 0xce4000f8, 0xc0004862, 0xca8000f8, 0x00000000, 0xc2c0000a, 0xc6e80d70,
+ 0xc7281048, 0xc000491c, 0xce8000f8, 0x6c708000, 0x6c544000, 0x43158000, 0x5b307e00, 0x6f760000,
+ 0x58300004, 0xcf421078, 0x6ffc2000, 0x58300004, 0xcfc02108, 0x800000d0, 0x6c708000, 0x6c544000,
+ 0x43158000, 0x5b307e00, 0xc2800002, 0x58300004, 0xce800000, 0x6c508000, 0xc0004880, 0x40100000,
+ 0x5800000e, 0xc90000f8, 0x00000000, 0x00000000, 0x59100002, 0xcd0000f8, 0x00000000, 0x00000000,
+ 0x00000000, 0xa8e2ffe8, 0x00000000, 0xc1220002, 0xd90c00f8, 0x80000920, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0xa8e2ffe8, 0x00000000, 0xc1220002, 0xd90c00f8, 0xc0004964, 0xca0000f8,
+ 0x6c7c8000, 0x6c544000, 0x43d5e000, 0x5bfc7e00, 0xdfe400f8, 0x5e200002, 0x84000608, 0x00000000,
+ 0x583c0004, 0xc2800000, 0xca820078, 0xc0004930, 0xcac000f8, 0x00000000, 0x00000000, 0x6eece000,
+ 0x6eefc010, 0x46aca000, 0xc1000000, 0xdd500039, 0x6d106010, 0x4550a000, 0xc1000000, 0xdd514201,
+ 0x4550c000, 0xa95000f1, 0xc00049a6, 0xca0000f8, 0xa94a0023, 0x00000000, 0x6e660000, 0x6e660010,
+ 0x46612000, 0x840000b2, 0x00000000, 0x6c508000, 0xc0004880, 0x40100000, 0x58000004, 0xc90000f8,
+ 0x00000000, 0x00000000, 0x59100002, 0xcd0000f8, 0x6c508000, 0xc0004880, 0x40100000, 0x58000006,
+ 0xc90000f8, 0x00000000, 0x00000000, 0x41148000, 0xcd0000f8, 0x80000720, 0x00000000, 0xa95203c1,
+ 0xc0001004, 0xcb8000f8, 0xc3400000, 0xdd740039, 0x5f740000, 0x840000d0, 0xc1218e08, 0x5911baf6,
+ 0x45388000, 0x84000372, 0x00000000, 0x6c508000, 0xc0004880, 0x40100000, 0x58000008, 0xc90000f8,
+ 0x00000000, 0x00000000, 0x59100002, 0xcd0000f8, 0x6c508000, 0xc0004880, 0x40100000, 0x5800000a,
+ 0xc90000f8, 0x00000000, 0x00000000, 0x41148000, 0xcd0000f8, 0x80000620, 0x00000000, 0xc000496c,
+ 0xcb0000f8, 0x583c0026, 0xcac000f8, 0xc0004878, 0xc80400f8, 0x6c908000, 0x41088000, 0x40100000,
+ 0x58000002, 0xca8000f8, 0x00000000, 0x00000000, 0x6ea90000, 0x5d300008, 0x8800004a, 0x59300002,
+ 0xc3000000, 0xc5300008, 0x6d104010, 0x40100000, 0xca8000f8, 0x5c000002, 0xcac000f8, 0x5d300000,
+ 0x8400003a, 0x6f246000, 0x6ae56000, 0xc1000040, 0x45252000, 0x6aa54010, 0x42e96000, 0x583c0026,
+ 0xcec000f8, 0xc1218e08, 0x5911baf6, 0xc0001004, 0xcd0000f8, 0x593c0026, 0xc000100e, 0xcd000060,
+ 0xc1340000, 0xc0001010, 0xcd035a00, 0xc1200008, 0xa94a0023, 0xc0001012, 0xc1200004, 0x59100004,
+ 0xcd0000b8, 0xc1360002, 0xcd037b00, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xa8e2ffe8, 0x00000000, 0xc1220002, 0xd90c00f8, 0xc0001004, 0xc90000f8, 0x00000000, 0x00000000,
+ 0x45388000, 0x840000b2, 0x00000000, 0x6c508000, 0xc0004880, 0x40100000, 0x58000008, 0xc90000f8,
+ 0x00000000, 0x00000000, 0x59100002, 0xcd0000f8, 0x6c508000, 0xc0004880, 0x40100000, 0x5800000a,
+ 0xc90000f8, 0x00000000, 0x00000000, 0x41148000, 0xcd0000f8, 0x80000360, 0x00000000, 0x6c508000,
+ 0xc0004880, 0x40100000, 0x58000000, 0xc90000f8, 0x00000000, 0x00000000, 0x59100002, 0xcd0000f8,
+ 0x6c508000, 0xc0004880, 0x40100000, 0x58000002, 0xc90000f8, 0x00000000, 0x00000000, 0x41148000,
+ 0xcd0000f8, 0xc0004930, 0xcd800078, 0xc3000000, 0x583c0008, 0xcf0000f8, 0x80000038, 0xc0001004,
+ 0xca0000f8, 0x583c0006, 0xce4000f8, 0x583c0024, 0xce0000f8, 0xc0004862, 0xc2000000, 0xca000078,
+ 0xc000493a, 0xca4000f8, 0x00000000, 0x00000000, 0x42254000, 0x5ee80200, 0x88000012, 0xc6e800f8,
+ 0xc0004000, 0x58003800, 0x40280000, 0xcb8000f8, 0x00000000, 0x583c0022, 0xcf8000f8, 0xc0004862,
+ 0xce800078, 0xc0001406, 0xcac000f8, 0xc2800002, 0x00000000, 0xc66c1048, 0xc6ac0a00, 0xcec000f8,
+ 0xc2000000, 0xdf600038, 0x5e600080, 0x8400ffea, 0xc000491c, 0xca4000f8, 0xc000491e, 0xca8000f8,
+ 0x99006480, 0xda5800f8, 0xda9800f9, 0x00000000, 0xc0004964, 0xcbc000f8, 0x00000000, 0x00000000,
+ 0x5ffc0000, 0x84000102, 0xc2000000, 0xdf610048, 0x5e6001fe, 0x8800ffe8, 0xc000491a, 0xc98000f8,
+ 0xc0004862, 0xc94000f8, 0x6d9c6000, 0x45d8e000, 0x59dc4c80, 0x990062e0, 0xd95800f8, 0xd99800f9,
+ 0xd9d400f8, 0x99006258, 0xc000491c, 0xc1400000, 0xc9420048, 0xc2000000, 0xdf600038, 0x5e600080,
+ 0x8400ffea, 0xc000491c, 0xca4000f8, 0xc000491e, 0xca8000f8, 0x99006480, 0xda5800f8, 0xda9800f9,
+ 0x00000000, 0xc0004970, 0xcb4000f8, 0x00000000, 0x00000000, 0x5e740082, 0x8400e6d8, 0x00000000,
+ 0x8000c018, 0x00000000, 0x6c508000, 0xc0004880, 0x40100000, 0x58000016, 0xc90000f8, 0x00000000,
+ 0x00000000, 0x59100002, 0xcd0000f8, 0x8000e308, 0x6c6c8000, 0x6c544000, 0x42d56000, 0x5aec7e00,
+ 0xc000487c, 0xc80400f8, 0x00000000, 0x00000000, 0x40080000, 0xca0000f8, 0xc42400f8, 0x00000000,
+ 0xa60600f8, 0xc3c00000, 0xc2000000, 0x582c000c, 0xca010038, 0x00000000, 0x00000000, 0x5a200002,
+ 0xc6100838, 0xcd010838, 0x5e60000e, 0x8400bf00, 0xc2200000, 0x582c0002, 0xce021008, 0x582c000c,
+ 0xcfc10838, 0x582c0020, 0xcfc21078, 0x582c0010, 0xc1400000, 0xcd4000f9, 0xcd4000f9, 0xcd4000f9,
+ 0xcd4000f9, 0xcd4000f9, 0xcd4000f9, 0xcd4000f9, 0xcd4000f9, 0xcd400018, 0x8000be68, 0xc2200004,
+ 0x582c0002, 0xce021008, 0x582c000c, 0xcfc10838, 0x99006ba8, 0x582c0002, 0xc94000f8, 0xc1a20000,
+ 0x8000be18, 0xc3e1fffe, 0x597dfffe, 0x593dfef4, 0x94000001, 0x00000000, 0x00000000, 0x00000000,
+ 0xc0800000, 0xdf4b0038, 0xc0004900, 0xcb8000f8, 0xc2000000, 0xc000490a, 0xa78000d0, 0xcbc000f8,
+ 0xc1000000, 0xd90000f9, 0xc1000002, 0xd90c00f8, 0x6ff46000, 0x477da000, 0x5b744c80, 0xc2400000,
+ 0x58340004, 0xca400078, 0xc0004900, 0xce000000, 0x5a640002, 0x58340004, 0xc6500078, 0xcd000078,
+ 0xc0004914, 0xca4000f8, 0xc2000002, 0x6a3d0000, 0x72612000, 0xce4000f8, 0xc0000408, 0xce0000f8,
+ 0xa78200c8, 0xc0004908, 0xcbc000f8, 0xc1000000, 0xd90000f9, 0xc1000002, 0xd90c00f8, 0x6ff4a000,
+ 0x477da000, 0x5b747600, 0xc2800000, 0x58340006, 0xca800078, 0xc2000000, 0xc0004900, 0xce002100,
+ 0x5ea80002, 0x58340006, 0xc6900078, 0xcd000078, 0x5a7c0020, 0xc2000002, 0x6a250000, 0xc0000408,
+ 0xce0000f8, 0xdca800f9, 0x5ea80000, 0x8400abd0, 0x00000000, 0xa4800230, 0x00000000, 0xc3c00000,
+ 0xc000140e, 0xcbc00018, 0xc3400000, 0xc2400000, 0x6ff86000, 0x47bdc000, 0x5bb84c80, 0x58380008,
+ 0xcb400078, 0x58380006, 0xca400078, 0x5f740002, 0x58380008, 0xc7500078, 0xcd000078, 0xc2000000,
+ 0x58380004, 0xca020078, 0xc3000000, 0x5838000c, 0xcb000020, 0x5a640002, 0x46610000, 0x84000010,
+ 0xc2400000, 0x58380006, 0xc6500078, 0xcd000078, 0xc2000000, 0x5838000a, 0xca020078, 0x5b300002,
+ 0x5838000c, 0xc7100020, 0xcd000020, 0xc2420020, 0x5a200004, 0x46252000, 0x84000010, 0xc2000000,
+ 0x5838000a, 0xc6101078, 0xcd021078, 0xc000498c, 0xca4000f8, 0xc2000002, 0x6a3d0000, 0x72612000,
+ 0xce4000f8, 0x5f740000, 0x84000040, 0xc0004912, 0xca0000f8, 0xc2c00002, 0x6afd6000, 0x7ec16000,
+ 0x762d0000, 0xce0000f8, 0x5f300020, 0x84000040, 0xc0004924, 0xca0000f8, 0xc2c00002, 0x6afd6000,
+ 0x7ec16000, 0x762d0000, 0xce0000f8, 0xa4820070, 0xc2400000, 0xc000140e, 0xca408018, 0xc2000002,
+ 0xc0004900, 0xce000000, 0xc000490a, 0xce4000f8, 0xc1000000, 0xd90000f9, 0xd8400078, 0xc1000004,
+ 0xd90000f9, 0xa48402d8, 0x00000000, 0xc3c00000, 0xc000140e, 0xcbc10018, 0xc2800000, 0xc2000000,
+ 0x6ff8a000, 0x47bdc000, 0x5bb87600, 0x58380036, 0xca800078, 0x58380006, 0xca020078, 0xc3400000,
+ 0x58380036, 0xcb420078, 0x5aa80002, 0x46a10000, 0x84000010, 0xc2800000, 0x58380036, 0xc6900078,
+ 0xcd000078, 0x5f740002, 0x58380036, 0xc7501078, 0xcd021078, 0xc000498e, 0xca4000f8, 0xc2000002,
+ 0x6a3d0000, 0x72612000, 0xce4000f8, 0xc000492a, 0xca8000f8, 0x5e740000, 0x84000040, 0xc0004910,
+ 0xca0000f8, 0xc2c00002, 0x6afd6000, 0x7ec16000, 0x762d0000, 0xce0000f8, 0x6abd4010, 0xa6800132,
+ 0x00000000, 0x5838003a, 0xca0000f8, 0x58000002, 0xca4000f8, 0x5838000e, 0x00000000, 0xce0000f9,
+ 0xce4000f8, 0xc2400000, 0xdd250038, 0xc1000080, 0x45248000, 0xc2400000, 0xc6240078, 0x46510000,
+ 0x00000000, 0xc52400fc, 0x5d240078, 0xc1000078, 0xc52400fc, 0xc6600078, 0x5c000002, 0xce000078,
+ 0xc000492a, 0xca0000f8, 0xc2c00002, 0x6afd6000, 0x722d0000, 0xce0000f8, 0xc000492c, 0xca0000f8,
+ 0xc2c00002, 0x6afd6000, 0x722d0000, 0xce0000f8, 0x80000040, 0xc000492c, 0xca0000f8, 0xc2c00002,
+ 0x6afd6000, 0x7ec16000, 0x762d0000, 0xce0000f8, 0xa4880088, 0xc2c00000, 0xc000140e, 0xcac20018,
+ 0xc000490e, 0xca4000f8, 0xc2000002, 0x6a2d0000, 0x7e010000, 0x76612000, 0xce4000f8, 0xc0004990,
+ 0xca4000f8, 0xc2000002, 0x6a2d0000, 0x72612000, 0xce4000f8, 0xa4860070, 0xc2400000, 0xc000140e,
+ 0xca418018, 0xc2020002, 0xc0004900, 0xce002100, 0xc0004908, 0xce4000f8, 0xc1000000, 0xd90000f9,
+ 0xd8400078, 0xc1000004, 0xd90000f9, 0xc0001408, 0xcc8000f8, 0xc10e0002, 0xd90c00f8, 0x8000f750,
+ 0xdfbc00f9, 0xc0004992, 0x99006be8, 0xc94000f8, 0xc7d800f8, 0x00000000, 0xc57000f8, 0x5ef00020,
+ 0x88000158, 0x6f346000, 0x4771a000, 0x5b744c80, 0x58340008, 0xc2400000, 0xca400078, 0x00000000,
+ 0xc2000000, 0x5a640002, 0xc6500078, 0xcd000078, 0x58340004, 0xca000078, 0x00000000, 0x00000000,
+ 0x5e200002, 0xc6100078, 0xcd000078, 0xc0004912, 0xca8000f8, 0xc2400002, 0x6a712000, 0x72a54000,
+ 0xce8000f8, 0x5e200000, 0x84000052, 0xc000480a, 0xca0000f8, 0xc0000408, 0xca8000f8, 0x76250000,
+ 0x00000000, 0x72a14000, 0xce8000f8, 0x80000038, 0xc0004914, 0xca0000f8, 0x7e412000, 0x00000000,
+ 0x76250000, 0xce0000f8, 0x800000c8, 0x6ef4a000, 0x476da000, 0x5b747600, 0x58340036, 0xc2400000,
+ 0xca420078, 0x00000000, 0xc2000000, 0x5a640002, 0xc6501078, 0xcd021078, 0x58340006, 0xca000078,
+ 0x00000000, 0x00000000, 0x5a200002, 0xc6100078, 0xcd000078, 0xc0004910, 0xca4000f8, 0xc2000002,
+ 0x6a2d0000, 0x72612000, 0xce4000f8, 0xc2000002, 0x6a310000, 0xc000042a, 0xce0000f8, 0xc1040002,
+ 0xd90c00f8, 0x00000000, 0x8000f4b8, 0x00000000, 0xc4980928, 0x9d000000, 0xc5580028, 0xc0000838,
+ 0xcd8400f8, 0xc1440200, 0xc1c03800, 0xc55c1070, 0xc000100e, 0x9d000000, 0xcd8000f8, 0xc000100c,
+ 0xcdc000f8, 0xc0004862, 0xc9c000f8, 0x00000000, 0x00000000, 0xd9d800f9, 0xc0007800, 0x401c0000,
+ 0x5dc07a00, 0x88000012, 0x5c000200, 0xcd8000f8, 0xc1f0000a, 0x715ca000, 0xdd9800f8, 0xdd9c00f9,
+ 0x41d8e000, 0xc5d40260, 0xc0001010, 0xcd4000f8, 0x6c9c8000, 0x45c8e000, 0x45c8e000, 0x59dc0004,
+ 0xc1601260, 0xc5d40260, 0x9d000000, 0xc0001012, 0xcd4000f8, 0x00000000, 0x00000000, 0xd95800f8,
+ 0x6d586000, 0x4594c000, 0x59984c80, 0xd99800f9, 0x5818000a, 0xc1800000, 0xc9800078, 0xc0007680,
+ 0x6d5ca000, 0x401c0000, 0x40180000, 0xc94000f8, 0x58000002, 0x00000000, 0xc9c000f8, 0xc0004930,
+ 0xcd4000f8, 0xc0004932, 0xcdc000f8, 0x59980004, 0xc1c20020, 0xb59c0018, 0x00000000, 0xc1800000,
+ 0xdd9c00f9, 0x581c000a, 0xcd800078, 0x581c000c, 0xc1800000, 0xc9800020, 0xc1c00002, 0xdd9400f8,
+ 0x69d4e000, 0x5d980002, 0xcd800020, 0xc0004924, 0xc98000f8, 0x00000000, 0x9d000000, 0x00000000,
+ 0x719cc000, 0xcd8000f8, 0xc000492a, 0xc94000f8, 0xc1c00002, 0x69d8e000, 0x7dc0c000, 0x7558a000,
+ 0xcd4000f8, 0xc000492c, 0xc94000f8, 0xdd8000f9, 0x5800003a, 0x755ca000, 0x84000108, 0xc94000f9,
+ 0xc98000f8, 0xdd8000f9, 0x5800000e, 0x00000000, 0xcd4000f9, 0xcd8000f8, 0xc1800000, 0xdd190038,
+ 0xc1000080, 0x45188000, 0xc1800000, 0xc5580078, 0x4590a000, 0x00000000, 0xc51800fc, 0x5d180078,
+ 0xc1000078, 0xc51800fc, 0xc5940078, 0x5c000002, 0xcd400078, 0xc000492c, 0xc94000f8, 0xc000492a,
+ 0xc98000f8, 0x715ca000, 0xc000492c, 0xcd4000f8, 0x719cc000, 0xc000492a, 0xcd8000f8, 0x9cc00000,
+ 0x00000000, 0x00000000, 0x00000000, 0xc0004862, 0xc98000f8, 0x00000000, 0xc1c00200, 0x4194c000,
+ 0x459ce000, 0x88000012, 0xc5d800f8, 0xc0004862, 0xcd8000f8, 0xc0001406, 0xc98000f8, 0xc1c00002,
+ 0x9d000000, 0xc5d80a00, 0xc5581048, 0xcd8000f8, 0xc0004930, 0xc98000f8, 0xc0004932, 0xc9c000f8,
+ 0xc140000e, 0xc5581c18, 0xdd9400f8, 0xc0007800, 0x40140000, 0x5d407a00, 0x88000012, 0x5c000200,
+ 0xcd8000f8, 0x58000002, 0x5d407a00, 0x88000012, 0x5c000200, 0xcdc000f8, 0xdd5400f8, 0xc1c00000,
+ 0x58140006, 0xc9c20078, 0xc1800000, 0x58140000, 0xc98000d8, 0x6ddc2000, 0xc000491e, 0x41d8e000,
+ 0xcdc000f8, 0xdd9800f8, 0xc1c00022, 0xc5d80d70, 0xdd9400f9, 0xc5581c18, 0xc000491c, 0xcd8000f8,
+ 0xdd5400f8, 0xc1c00000, 0x58140006, 0xc9c20078, 0xc1800000, 0x58140004, 0xc9820078, 0x00000000,
+ 0x59dc0002, 0x45d8c000, 0x84000010, 0xc1c00000, 0x9d000000, 0x58140006, 0xc5d81078, 0xcd821078,
+ 0xc0004860, 0xc94000f8, 0xc1820080, 0xc1d00002, 0x58147700, 0xd58000f8, 0x58000002, 0xd58000f9,
+ 0x59540004, 0xb5580018, 0xc0004860, 0xc1400000, 0xcd4000f8, 0xdd9800f9, 0x9d000000, 0xdd9400f8,
+ 0xc0001404, 0xcdc10800, 0xc1c00000, 0xc1800200, 0x5d980004, 0xdf5d0048, 0x459ca000, 0x8800fff2,
+ 0xdd8000f9, 0x5800000e, 0x00000000, 0xc94000f9, 0xc98000f8, 0xc1c00002, 0xc5d43f00, 0xc5d81e00,
+ 0xc0004862, 0xc9c000f8, 0x00000000, 0x00000000, 0x581c7800, 0x5dc07a00, 0x88000012, 0x5c000200,
+ 0xcd4000f8, 0x58000002, 0x5dc07a00, 0x88000012, 0x5c000200, 0xcd8000f8, 0xc0004862, 0xc9c000f8,
+ 0x00000000, 0xc15004c0, 0xc5d40060, 0xdd9c00f8, 0xc5d41c18, 0xc1c00000, 0xdd8000f9, 0x58000038,
+ 0xc9c00078, 0xdd8000f9, 0xc1800000, 0x58000002, 0xc98000d8, 0x6ddc2000, 0xc000491c, 0x41d8e000,
+ 0xcd4000f9, 0xcdc000f8, 0xdd9400f9, 0xc1c00000, 0x58140038, 0xc9c00078, 0xc1800000, 0x58140006,
+ 0xc9820078, 0x00000000, 0x59dc0002, 0x45d8c000, 0x84000010, 0xc1c00000, 0x9d000000, 0x58140038,
+ 0xc5d80078, 0xcd800078, 0xc1c00000, 0xdf5c0038, 0x5ddc0080, 0x8400ffea, 0x00000000, 0x9d000000,
+ 0x00000000, 0x00000000, 0x00000000, 0xc160fffe, 0xc0000a10, 0xc9440060, 0xc1a0fffe, 0x59983608,
+ 0xc000100c, 0xcd4000f8, 0xc000100e, 0xcd8000f8, 0xc0004962, 0xc98000f8, 0x00000000, 0xc170000a,
+ 0x7158a000, 0x6c988000, 0x4588c000, 0x4588c000, 0x59980004, 0xc5940270, 0xc0001010, 0xcd4000f8,
+ 0xc0004946, 0xc94000f8, 0x00000000, 0x00000000, 0x6d58a000, 0x6d5c4000, 0x459cc000, 0x4594c000,
+ 0xc000494a, 0xc94000f8, 0xc0004948, 0xc9c000f8, 0x4194c000, 0xc1400012, 0xc55c1818, 0x9d000000,
+ 0xc59c0268, 0xc0001012, 0xcdc000f8, 0xc1400000, 0x58000014, 0xc9410038, 0xc0004950, 0xc9c000f8,
+ 0xc55800f8, 0xc5940838, 0xc5581078, 0xd99400f8, 0xc000493c, 0xc94000f8, 0xc0004954, 0xc98000f8,
+ 0x59dc00a8, 0x45d4e000, 0x41d8e000, 0x5d5c0030, 0x88000010, 0xc1c00030, 0xc1800000, 0xc5d84028,
+ 0xc1400000, 0xc5d40008, 0x5dd40002, 0x84000072, 0x5dd40004, 0x8400009a, 0x5dd40006, 0x840000c2,
+ 0x5dd80026, 0x840000ea, 0xdd5400f8, 0xdd8000f9, 0x58000008, 0x40180000, 0xcd4000f8, 0x59980002,
+ 0x8000ffc0, 0xdd5400f8, 0xdd8000f9, 0x58000008, 0x40180000, 0xcd4000b8, 0x59980002, 0x8000ff88,
+ 0xdd5400f8, 0xdd8000f9, 0x58000008, 0x40180000, 0xcd400078, 0x59980002, 0x8000ff50, 0xdd5400f8,
+ 0xdd8000f9, 0x58000008, 0x40180000, 0xcd400038, 0x59980002, 0x8000ff18, 0x00000000, 0x9d000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x58000014, 0xc94000f8, 0xc0004954, 0xc9c000f8, 0xc0004950,
+ 0xc9400078, 0xdd8000f9, 0x5800002a, 0x5d9c0000, 0x84000052, 0x5d9c0002, 0x84000052, 0x5d9c0004,
+ 0x8400006a, 0xc55b0038, 0xc55c08b8, 0xcd800039, 0xcdc108b8, 0x80000060, 0xcd4000f8, 0x80000050,
+ 0xc55900b8, 0xc55c1838, 0xcd8000b9, 0xcdc31838, 0x80000028, 0xc55a0078, 0xc55c1078, 0xcd800079,
+ 0xcdc21078, 0x9d000000, 0x00000000, 0x00000000, 0x00000000, 0xc1e00000, 0xa540001a, 0xc0000a14,
+ 0xc1a20002, 0x9d000000, 0xcd863100, 0xc0000a1c, 0xcdc61038, 0x59540002, 0x6994e018, 0x61c0c008,
+ 0x4194a000, 0x5d940040, 0x88000012, 0xc59400f8, 0x9d000000, 0xcd4000f8, 0x00000000, 0x00000000,
+};
+
+static unsigned int firmware_binary_data[] = {
+};
+
+
+#endif // IFXMIPS_PTM_FW_AR9_H
diff --git a/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_fw_danube.h b/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_fw_danube.h
new file mode 100644
index 0000000..3451682
--- /dev/null
+++ b/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_fw_danube.h
@@ -0,0 +1,489 @@
+#ifndef IFXMIPS_PTM_FW_DANUBE_H
+#define IFXMIPS_PTM_FW_DANUBE_H
+
+
+/******************************************************************************
+**
+** FILE NAME : ifxmips_ptm_fw_danube.h
+** PROJECT : Danube
+** MODULES : PTM (ADSL)
+**
+** DATE : 1 AUG 2005
+** AUTHOR : Xu Liang
+** DESCRIPTION : PTM Driver (PP32 Firmware)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 4 AUG 2005 Xu Liang Initiate Version
+** 23 OCT 2006 Xu Liang Add GPL header.
+*******************************************************************************/
+
+
+#define PTM_FW_VER_MAJOR 0
+#define PTM_FW_VER_MINOR 17
+
+
+static unsigned int firmware_binary_code[] = {
+ 0x800004a0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8000ffc8, 0x00000000, 0x00000000, 0x00000000,
+ 0xc1000002, 0xd90c0000, 0xc2000002, 0xda080001, 0x80005618, 0xc2000000, 0xda080001, 0x800055b8,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x80005da8, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xc10e0002, 0xd90c0000, 0xc0004808, 0xc8400000, 0x80005288, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xc3e1fffe, 0x597dfffe, 0x593dfef4, 0x900004d9, 0x00000000, 0x00000000, 0x00000000, 0x90cc0481,
+ 0x00000000, 0x00000000, 0x00000000, 0xc3e02262, 0x5bfc0022, 0xc0004002, 0xcfc00000, 0xc0004810,
+ 0xcbc00000, 0x00000000, 0xc3800000, 0xc7f80040, 0x5fb80000, 0xc7fa0040, 0xc7bfe80a, 0x5fb80000,
+ 0x00000000, 0xc7bff80a, 0xdbd40001, 0xc00049a0, 0xc3800002, 0xa7ca004a, 0xc1200000, 0x5911fffe,
+ 0xcd000001, 0xc1200000, 0x59102042, 0xcd000001, 0xc1000004, 0xcd000001, 0xc1200000, 0x59103a1e,
+ 0xcd000001, 0x80000048, 0xc121fffe, 0x5911fffe, 0xcd000001, 0xc1203db8, 0x5910de82, 0xcd000001,
+ 0xc1000006, 0xcd000001, 0xc120385a, 0x591033da, 0xcd000001, 0x5fb80002, 0x88000002, 0x6ffe0010,
+ 0x8000ff10, 0xdd7c0001, 0xc3800000, 0xc7f86018, 0x5bb80008, 0xc3540002, 0x77f5a000, 0xc1000008,
+ 0x4539c002, 0xcf800001, 0xdb900040, 0xc3800008, 0xc3720002, 0x77f5a000, 0xa7f00008, 0x47b9c002,
+ 0xc1000000, 0xc7d26018, 0x4391c000, 0xcf800000, 0xdb900840, 0xc3c00000, 0xdbc80001, 0xc0400000,
+ 0xc11c0000, 0xc000082c, 0xcd040e08, 0xc11c0002, 0xc000082c, 0xcd040e08, 0xc0400002, 0xc11c0000,
+ 0xc000082c, 0xcd040e08, 0xc11c0002, 0xc000082c, 0xcd040e08, 0xc0000824, 0x00000000, 0xcbc00001,
+ 0xcb800001, 0xcb400001, 0xcb000000, 0xc0004878, 0x5bfc4000, 0xcfc00001, 0x5bb84000, 0xcf800001,
+ 0x5b744000, 0xcf400001, 0x5b304000, 0xcf000000, 0xc0000a10, 0x00000000, 0xcbc00001, 0xcb800000,
+ 0xc0004874, 0x5bfc4000, 0xcfc00001, 0x5bb84000, 0xcf800000, 0xc30001fe, 0xc000140a, 0xcf000000,
+ 0xc3000000, 0x7f018000, 0xc000042e, 0xcf000000, 0xc000040e, 0xcf000000, 0xc3c1fffe, 0xc000490e,
+ 0xcfc00080, 0xc000492c, 0xcfc00080, 0xc0004924, 0xcfc00040, 0xc0004912, 0xcfc00040, 0xc000498c,
+ 0xcfc00040, 0xc000498e, 0xcfc00080, 0xc0004990, 0xcfc00080, 0xc3c00000, 0xc2800004, 0xc3000000,
+ 0x7f018000, 0x6ff88000, 0x6fd44000, 0x4395c000, 0x5bb84a00, 0xc00049a0, 0xcb000000, 0x00000000,
+ 0x58380006, 0xcf000000, 0xc321fffe, 0x5b31fffe, 0x58380024, 0xcf000000, 0x5bfc0002, 0xb7e8ff70,
+ 0x00000000, 0xc3c00000, 0xc2800010, 0x6ff86000, 0x47f9c000, 0x5bb84c80, 0xc3400000, 0x58380004,
+ 0xcb420080, 0x00000000, 0x58380008, 0xcf400080, 0x5bfc0002, 0xb7e8ff90, 0x00000000, 0xc3c00000,
+ 0xc2800004, 0xc3400022, 0xc3000000, 0x7f018000, 0xc2c00016, 0x6ff8a000, 0x47f9c000, 0x5bb84e20,
+ 0x58380008, 0xcf400040, 0xc00049a8, 0xcb000000, 0x00000000, 0x5838000a, 0xcf000000, 0xc321fffe,
+ 0x5b31fffe, 0x5838000c, 0xcf000000, 0x58380034, 0xcec00040, 0x5bfc0002, 0xb7e8ff58, 0x00000000,
+ 0x00000000, 0xc0004840, 0xc3e12624, 0x5bfc2320, 0xcfc00001, 0xc3e02f2c, 0x5bfd2a28, 0xcfc00001,
+ 0xc3e03734, 0x5bfd3230, 0xcfc00001, 0xc3e13e3c, 0x5bfc3b38, 0xcfc00001, 0xc3e14644, 0x5bfc4340,
+ 0xcfc00001, 0xc3e04f4c, 0x5bfd4a48, 0xcfc00001, 0xc3e05754, 0x5bfd5250, 0xcfc00001, 0xc3e15e5c,
+ 0x5bfc5b58, 0xcfc00001, 0xc3e06764, 0x5bfd6260, 0xcfc00001, 0xc3e16e6c, 0x5bfc6b68, 0xcfc00001,
+ 0xc3e17674, 0x5bfc7370, 0xcfc00001, 0xc3e07f7c, 0x5bfd7a78, 0xcfc00001, 0xc3e18684, 0x5bfc8380,
+ 0xcfc00001, 0xc3e08f8c, 0x5bfd8a88, 0xcfc00001, 0xc3e09794, 0x5bfd9290, 0xcfc00001, 0xc3e19e9c,
+ 0x5bfc9b98, 0xcfc00001, 0xc121fffe, 0x5911fef4, 0x15000000, 0x80000010, 0x00000000, 0x80000638,
+ 0x00000000, 0x8000ffc8, 0xc0004918, 0xd2800000, 0xc2000000, 0xdf600040, 0x5e600080, 0x8400029a,
+ 0x00000000, 0xc161fffe, 0x5955fffe, 0x15400000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0xc000480a, 0xca000000, 0xc0004912, 0xca400000, 0xc0004924, 0xca800000,
+ 0xc000498c, 0xcac00000, 0xc121fffe, 0x5911fef4, 0x15000000, 0x76610000, 0x76a10000, 0x76e10000,
+ 0x840001d2, 0xc0004918, 0xca400000, 0xc28001fe, 0x76a10000, 0x5a640002, 0x6a254010, 0x5ee80000,
+ 0x84000002, 0x6aa54000, 0x8000fff8, 0xc6280000, 0x62818008, 0xc0004918, 0xcf000000, 0xc161fffe,
+ 0x5955fffe, 0x15400000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xc000498c, 0xca400000, 0xc2000002, 0x6a310000, 0x7e010000, 0x76252000, 0xce400000, 0xc121fffe,
+ 0x5911fef4, 0x15000000, 0x6f346000, 0x4735a000, 0x5b744c80, 0xc2800000, 0x58340006, 0xca800080,
+ 0xc2c00000, 0x58340000, 0xcac000e0, 0xc2400000, 0x5834000a, 0xca420080, 0x6ea82000, 0x42e9e000,
+ 0x6f2ca000, 0x42e56000, 0x5aec1400, 0xc3990040, 0xc7381c20, 0xc6f80068, 0x99006840, 0xdb980000,
+ 0xdbd80001, 0x00000000, 0xdea00000, 0x47210000, 0x8400fd28, 0xc000495a, 0xc8400000, 0x00000000,
+ 0xc3c00002, 0x7bc42000, 0xcc400000, 0xc0000838, 0xc3800000, 0xcb840030, 0x6c748000, 0x6c544000,
+ 0x4355a000, 0x5b744a00, 0x5ef80000, 0x8400fc8a, 0x58340004, 0xcb000000, 0x00000000, 0x00000000,
+ 0xa7060000, 0x00000000, 0x5ef80002, 0x8400fc4a, 0x5834000c, 0xc8800040, 0xc2000000, 0xc000082c,
+ 0xca040030, 0x5a880002, 0xc2400000, 0xc0004958, 0xce400000, 0xb628fff8, 0x00000000, 0xc2800000,
+ 0x58340002, 0xc2000000, 0xca020010, 0xc0004956, 0xce800000, 0x5e600000, 0x84001df2, 0x5e600002,
+ 0x840043da, 0x00000000, 0x80002320, 0xc0004958, 0xca000000, 0xc0004956, 0xca800000, 0x5e200000,
+ 0x84000008, 0xc2500002, 0xc0000838, 0xce440808, 0x6c748000, 0x6c544000, 0x4355a000, 0x5b744a00,
+ 0x5834000c, 0xc6900040, 0xcd000040, 0x58340002, 0xc2000000, 0xca020010, 0x00000000, 0x00000000,
+ 0x5f600000, 0x84000122, 0xc0004818, 0xc8000000, 0x00000000, 0x00000000, 0x5c000000, 0x840000f2,
+ 0xc11c0000, 0xc000082c, 0xcd040e08, 0xc0000838, 0xc3800000, 0xc2400000, 0xcb840030, 0xca452030,
+ 0x00000000, 0x42b9a000, 0x5e340022, 0x88000012, 0xc200001e, 0x7635a000, 0x5f740002, 0x8000fff0,
+ 0x6e642010, 0x4675a000, 0x84000042, 0xc0004818, 0xc8000000, 0x00000000, 0x00000000, 0x5c000000,
+ 0x84000012, 0x00000000, 0x00000000, 0x00000000, 0x8000ffa0, 0xc11c0002, 0xc000082c, 0xcd040e08,
+ 0x8000f9b8, 0xc2000000, 0xdf600040, 0x5e200080, 0x84000272, 0x00000000, 0xc161fffe, 0x5955fffe,
+ 0x15400000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xc000480c,
+ 0xca000000, 0xc0004910, 0xca400000, 0xc000492c, 0xca800000, 0xc000498e, 0xcac00000, 0xc121fffe,
+ 0x5911fef4, 0x15000000, 0x76610000, 0x76a10000, 0x762d6000, 0x840001aa, 0xc0004926, 0xca400000,
+ 0xc201fffe, 0x762d6000, 0x5a640002, 0x6ae50010, 0x5f200000, 0x84000002, 0x6a250000, 0x8000fff8,
+ 0xc6e00000, 0x62014008, 0xc0004926, 0xce800000, 0xc161fffe, 0x5955fffe, 0x15400000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xc000498e, 0xca400000, 0xc2000002,
+ 0x6a290000, 0x7e010000, 0x76252000, 0xce400000, 0xc121fffe, 0x5911fef4, 0x15000000, 0x6eb4a000,
+ 0x46b5a000, 0x5b744e20, 0x58340002, 0xc2000000, 0xca0000e0, 0x58340036, 0xc2400000, 0xca400080,
+ 0x6eb0a000, 0x46b18000, 0x5b300e56, 0x5b300004, 0x6e642000, 0x4225e000, 0xc39a8024, 0xc7380068,
+ 0xc6b81c20, 0x99006840, 0xdb980000, 0xdbd80001, 0x00000000, 0xc2000000, 0xdf600040, 0x5e200080,
+ 0x840002c2, 0x00000000, 0xc161fffe, 0x5955fffe, 0x15400000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0xc000490e, 0xca000000, 0xc000492a, 0xca400000, 0xc0004990,
+ 0xcb000000, 0xc000498a, 0xcac00000, 0xc121fffe, 0x5911fef4, 0x15000000, 0x76318000, 0x76718000,
+ 0x84000202, 0xc201fffe, 0x76318000, 0x5aec0002, 0x6b2d0010, 0x5ea00000, 0x84000002, 0x6a2d0000,
+ 0x8000fff8, 0xc7200000, 0x62016008, 0xc000498a, 0xcec00000, 0xc161fffe, 0x5955fffe, 0x15400000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xc0004990, 0xca400000,
+ 0xc2000002, 0x6a2d0000, 0x7e010000, 0x76252000, 0xce400000, 0xc121fffe, 0x5911fef4, 0x15000000,
+ 0x6ef4a000, 0x46f5a000, 0x5b744e20, 0x58340010, 0xc2000000, 0xca0000e0, 0x58340008, 0xc2400000,
+ 0xca420080, 0x5834000e, 0xc2800000, 0xca832018, 0xc3c00000, 0x467c8000, 0x6e644010, 0xc7e80004,
+ 0x42250000, 0x4229e000, 0xc39a8008, 0x58340008, 0xcb801040, 0x58340008, 0xc2800000, 0xca810018,
+ 0x6ee0a000, 0x46e10000, 0x5a20000a, 0x5a200e28, 0x42290000, 0xc6380068, 0xc6f81c20, 0x99006840,
+ 0xdb980000, 0xdbd80001, 0x00000000, 0xc000495c, 0xc8400000, 0xc3400000, 0xc3c00002, 0x7bc42000,
+ 0xcc400000, 0x6c78a000, 0x4479c000, 0x5bb84e20, 0x58380034, 0xcb410040, 0xc0000a28, 0xc3000000,
+ 0xcb040030, 0xc0000a14, 0xc2c00000, 0x43358000, 0xcac40030, 0xc000490e, 0xca800000, 0x5eec0002,
+ 0x46f18000, 0x8800f348, 0x6bc5e000, 0x77e94000, 0x8400f330, 0x6c7ca000, 0x447de000, 0x5bfc4e20,
+ 0x583c0008, 0xc2000000, 0xca020080, 0xc00049aa, 0x00000000, 0xca800001, 0xca400000, 0xc0001008,
+ 0xce800000, 0xc0001006, 0xce400000, 0x583c000a, 0xca400000, 0x00000000, 0xc000100a, 0xce400000,
+ 0xc2400006, 0xc0001000, 0xce400000, 0xc2600982, 0x5a643b6e, 0xc0001002, 0xce400000, 0x583c000c,
+ 0xca400000, 0x00000000, 0xc0001004, 0xce400000, 0x583c000e, 0xcb800000, 0x00000000, 0xc2400000,
+ 0xc7a40080, 0xc2800000, 0xc7aae028, 0xdaa00001, 0x583c0034, 0xcb800000, 0x00000000, 0xc2c00000,
+ 0xc7ad0040, 0xc0004978, 0xcec00000, 0xc0800000, 0xc7880040, 0xc3400000, 0xc7b60040, 0xc0004980,
+ 0xcf400000, 0x4625c000, 0x43a9c000, 0xc2400000, 0xc000497c, 0xce400000, 0xac2c0001, 0xc2800000,
+ 0x00000000, 0x8000fff8, 0xc2800002, 0xc0004976, 0xce800000, 0xc2c00000, 0xc34000a0, 0xdb5c0001,
+ 0xc3400002, 0xc000497a, 0xcf400000, 0x5f600000, 0x84000168, 0xde280001, 0xc6a00000, 0x46b9c000,
+ 0x583c0000, 0xc2800000, 0xca830040, 0xc0000a28, 0xc3000000, 0xcb040030, 0xc3400000, 0xc0004976,
+ 0x47298000, 0x88000052, 0xcf400000, 0x58880002, 0xc3000000, 0xc0000a14, 0xcb040030, 0x00000000,
+ 0x00000000, 0xb4b00188, 0x00000000, 0xc0800000, 0x00000000, 0x80000170, 0xc0004980, 0xcb400000,
+ 0x00000000, 0x00000000, 0x5af40002, 0xafec0080, 0x00000000, 0xc2c00000, 0xc000497a, 0xacec0001,
+ 0x00000000, 0x00000000, 0xac2c007f, 0xc2800000, 0xce800000, 0x80000000, 0xc2800002, 0xce800000,
+ 0x5f6c0000, 0x840000d0, 0x00000000, 0x8000fee8, 0x5f780082, 0x88000240, 0xc3000002, 0xc000497c,
+ 0xcf000000, 0xc2800080, 0xc1000000, 0xdd110040, 0x45294000, 0x46b94000, 0x880001c0, 0x4391a000,
+ 0xc0004980, 0xcf400000, 0x6f684010, 0x6f77c000, 0x6f77c010, 0xc0004840, 0x40280000, 0xca800000,
+ 0xc3000000, 0x6f506000, 0x6a908010, 0xc5300040, 0xdb1c0001, 0x8000fe18, 0xc3400000, 0xc0000a10,
+ 0xcb440068, 0x6cb04000, 0x6f288000, 0x6f744000, 0x42b14000, 0x43694000, 0xc3400000, 0xc6b44068,
+ 0xc0004000, 0x40340000, 0xc321e000, 0xcf000000, 0x5aa80008, 0x42ad4000, 0xc3400000, 0xc6b44068,
+ 0xc0004000, 0x40340000, 0xca400000, 0xc3000000, 0xc6f00010, 0xc1400000, 0xddd40041, 0x6f306000,
+ 0xc13001fe, 0x69308010, 0x7d008000, 0x75252000, 0x6d570000, 0x6970a010, 0x42552000, 0xce400000,
+ 0x5aa80002, 0x5aec0002, 0xafec0080, 0x00000000, 0xc2c00000, 0x5f6c0000, 0x84000100, 0x00000000,
+ 0x80000028, 0x4391a000, 0x5f740080, 0xc0004980, 0xcf400000, 0xc3000004, 0xc000497a, 0xcf000000,
+ 0x58880002, 0xc3400000, 0xc0000a14, 0xcb440030, 0x00000000, 0x00000000, 0xb4b4fff8, 0x00000000,
+ 0xc0800000, 0xc3400000, 0xc0000a10, 0xcb440068, 0x6cb04000, 0x6f248000, 0x6f744000, 0x42712000,
+ 0x43654000, 0xc3400000, 0xc6b44068, 0xc0004000, 0x40340000, 0xc3201e00, 0xcf000000, 0x5aa80008,
+ 0x42ad4000, 0xc000100c, 0xcb400000, 0xc3000000, 0x00000000, 0xc7340068, 0xc300fffe, 0xc7341078,
+ 0xcf400000, 0xc000100e, 0xcb400000, 0xc3000e28, 0x00000000, 0xc7340068, 0xc300fffe, 0xc7341078,
+ 0xcf400000, 0xc0001010, 0xcb400000, 0xc3000002, 0x00000000, 0xc7341a08, 0xc7341808, 0xc3000000,
+ 0xc7341908, 0xc6b40078, 0xcf400000, 0xc0004982, 0xce800000, 0x6c64a000, 0x44652000, 0x5a64000a,
+ 0xc0001012, 0xcb400000, 0xc2800002, 0x00000000, 0xc6740268, 0xc6340010, 0xc000497c, 0xcb000000,
+ 0xc6b41808, 0xc6b41b08, 0xc6b41c08, 0xc6b41d08, 0xc7341e08, 0xdd680001, 0x7e814000, 0x6eab2010,
+ 0x77294000, 0xc6b41f08, 0xc2800000, 0xc6b41908, 0xc3000080, 0x46f18000, 0xc0004982, 0xc9000000,
+ 0x47b14000, 0x880000ea, 0x41388000, 0xcd000000, 0xc7b41040, 0xc0004994, 0xce800000, 0xde100001,
+ 0x46108000, 0x84000098, 0xc1000000, 0xdd110040, 0x41388000, 0x412c8000, 0x5d100080, 0xc0004980,
+ 0xcd000000, 0xc1000002, 0xc000497c, 0xcd000000, 0xc5341e08, 0xdd500001, 0x7d008000, 0xc5373f08,
+ 0xc000497a, 0xc9000000, 0x42390000, 0x43adc000, 0x59100002, 0xcd000000, 0x80000038, 0x42390000,
+ 0x80000028, 0xc7341040, 0x41308000, 0xcd000000, 0x42310000, 0xc1000000, 0xc0004994, 0xcd000000,
+ 0xc0001012, 0xcf400000, 0xc000493c, 0xce000000, 0xc0004984, 0xcf800000, 0xc000497a, 0xca400000,
+ 0xc000497c, 0xca800000, 0x6c7ca000, 0x447de000, 0x5bfc4e20, 0xc0004976, 0xcac00000, 0xc0004978,
+ 0xca000000, 0x5eec0002, 0x84000072, 0x42250000, 0xc2400000, 0xc000497a, 0xce400000, 0x583c0000,
+ 0xc2c00000, 0xcac30040, 0x00000000, 0x00000000, 0x462d6000, 0x88000002, 0x00000000, 0xac280002,
+ 0xc000497a, 0xce000000, 0xc2000000, 0x5fa80000, 0x840001c2, 0x00000000, 0x6c508000, 0xc0004880,
+ 0x40100000, 0x58000018, 0xc9000000, 0x00000000, 0x00000000, 0x59100002, 0xcd000000, 0x583c000e,
+ 0xc2c00000, 0xcac00080, 0xc1000000, 0xdd532209, 0x42d16000, 0x6c508000, 0xc0004880, 0x40100000,
+ 0x5800001a, 0xc9000000, 0x00000000, 0x00000000, 0x412c8000, 0xcd000000, 0x990068d0, 0xd8580000,
+ 0xdbd80001, 0x00000000, 0x99006618, 0xc000491c, 0xc1400000, 0xc9420050, 0xc000491c, 0x99006ad0,
+ 0xc9400001, 0xc9800000, 0x00000000, 0x99006840, 0xd9580000, 0xd9980001, 0x00000000, 0xc161fffe,
+ 0x5955fffe, 0x15400000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x98c06490, 0xd8580000, 0xdbd80001, 0xc4580000, 0xc121fffe, 0x5911fef4, 0x15000000, 0xace80003,
+ 0xc000493c, 0xcb400000, 0x00000000, 0xc3000000, 0xc7701080, 0x8000fff8, 0xc3000000, 0x583c0008,
+ 0xcf001080, 0x6e210000, 0x583c0034, 0xce000840, 0xc0004980, 0xcb800000, 0x583c0034, 0x00000000,
+ 0x6fba0000, 0xcf801040, 0xc000490e, 0xca000000, 0xc2c00002, 0x6ac56000, 0x72e10000, 0xce000000,
+ 0x00000000, 0x00000000, 0x00000000, 0xa8e2ffc8, 0x00000000, 0xc1220002, 0xd90c0000, 0x5fa80000,
+ 0x840006fa, 0xc00049a8, 0xca000000, 0x583c000a, 0x00000000, 0xce000000, 0xc221fffe, 0x5a21fffe,
+ 0x583c000c, 0xce000000, 0xc0001004, 0xca000000, 0x00000000, 0x583c0012, 0x7e010000, 0xce000000,
+ 0xa97000c1, 0x00000000, 0x00000000, 0xa97200a9, 0xc0001010, 0xc2740000, 0xce401a08, 0x6c64a000,
+ 0x44652000, 0x5a64000a, 0x6e644000, 0xc0001012, 0xce400078, 0xc2600008, 0xce401040, 0xc27e0002,
+ 0xce401f08, 0xc2760002, 0xce401b08, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xa8e2ffc8, 0x00000000, 0xc1220002, 0xd90c0000, 0xc1000000, 0xdd110040, 0x5d100000, 0x840003fa,
+ 0xc0004982, 0xca000000, 0xc0004984, 0xca400000, 0xc2800000, 0xc361fffe, 0x5b75fffe, 0xa96afffb,
+ 0xdfec0000, 0xc6ec1080, 0x7b6d6000, 0x6c40a000, 0x44400000, 0x58004e20, 0x58000014, 0xcec00000,
+ 0xa972fffb, 0x5c000002, 0xcec00000, 0xc0001010, 0xc2f40002, 0xcec01a08, 0x6c6ca000, 0x446d6000,
+ 0x5aec000a, 0x6eec4000, 0xc0001012, 0xcec00078, 0xc0004994, 0xc9800000, 0xc1400000, 0xdd150040,
+ 0xc55c0000, 0x45588000, 0x00000000, 0xc59c0004, 0x5d1c0000, 0x840000ba, 0xc0001012, 0xc5d01040,
+ 0xcd001040, 0xc2f60002, 0xcec01b08, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xa8e2ffc8, 0x00000000, 0xc1220002, 0xd90c0000, 0x45588000, 0x8800003a, 0xc0004994, 0xcd000000,
+ 0xc0004980, 0xcbc00000, 0x42150000, 0xc0004982, 0xce000000, 0x5ffc0000, 0x84000200, 0x58880002,
+ 0xc3800000, 0xc0000a14, 0xcb840030, 0xc3c00000, 0xc0000a10, 0xb4b8fff8, 0x00000000, 0xc0800000,
+ 0xcbc40068, 0x6cb84000, 0x6fac8000, 0x6ffc4000, 0x42f96000, 0x43ed0000, 0xc3400000, 0xc6344068,
+ 0xc0004000, 0x40340000, 0xc2a1e000, 0xce800000, 0x5a200008, 0xc0004980, 0xcbc00000, 0xc3400000,
+ 0xc0004840, 0x6ff84010, 0xc7f40010, 0x40380000, 0xcb800000, 0xc2800000, 0x6f506000, 0x6b908010,
+ 0xc52c1840, 0xc3400000, 0xc6344068, 0xc0004000, 0x40340000, 0xcec00000, 0x5a200002, 0x5ffc0000,
+ 0x8400007a, 0xc0001010, 0xc62c0078, 0xcec00078, 0xc0001012, 0xc7ec1040, 0xcec01040, 0xc2f60002,
+ 0xcec01b08, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xa8e2ffc8, 0x00000000,
+ 0xc1220002, 0xd90c0000, 0xc0004994, 0xc100007e, 0x47d08000, 0xcd000000, 0x423d0000, 0xc0004982,
+ 0xce000000, 0xc0004994, 0xca000000, 0xc0004980, 0xca400000, 0x5e200000, 0x84000142, 0xc2000000,
+ 0xc2800000, 0x5a640002, 0xc6684030, 0xc0004982, 0xcb000000, 0xc0004000, 0xc2c00000, 0xc72c4068,
+ 0x402c0000, 0x6e67c000, 0x6e67c010, 0x5ee40002, 0x84000022, 0x5ee40004, 0x84000032, 0x5ee40006,
+ 0x84000042, 0x00000000, 0x80000048, 0xce0000c0, 0x5aa80002, 0x5b300006, 0x80000028, 0xce000080,
+ 0x5aa80002, 0x5b300004, 0x80000008, 0xce000040, 0x5aa80002, 0x5b300002, 0x5ee80020, 0x8400003a,
+ 0xc0004000, 0xc2c00000, 0xc72c4068, 0x402c0000, 0xce000000, 0x5aa80002, 0x5b300008, 0x8000ffa0,
+ 0x00000000, 0x80000028, 0x583c000a, 0xd7c00000, 0xc0001004, 0xca400000, 0x00000000, 0x583c000c,
+ 0xce400000, 0xc000497a, 0xca400000, 0xc2800002, 0xc0000a28, 0xc6780930, 0xc6b80808, 0xcf840838,
+ 0x6c7ca000, 0x447de000, 0x5bfc4e20, 0x583c0034, 0xc4900040, 0xcd000040, 0x8000e400, 0x6c6c8000,
+ 0x6c544000, 0x42d56000, 0x5aec4a00, 0xc0000824, 0xca040000, 0x6ca48000, 0x42492000, 0xc3000000,
+ 0xc3400000, 0x42250000, 0x58204000, 0xca400000, 0x5a200002, 0xda240001, 0xc2800000, 0xc000495e,
+ 0xce800000, 0xda600000, 0xc2800000, 0xc66b0040, 0xdaa80000, 0x582c0010, 0x6f206010, 0x40200000,
+ 0xd8280001, 0xca000000, 0xc2400000, 0xc7240018, 0x6e644000, 0xda640000, 0x6a254010, 0xc3c00000,
+ 0xc6bc0020, 0xc3800000, 0xdea00000, 0x5e60001e, 0x84000012, 0x5e6001e0, 0x84000002, 0x00000000,
+ 0x80000068, 0xc7f80000, 0x5e7c0008, 0x84000052, 0x5bbc0002, 0x5e780008, 0x84000010, 0x5b740002,
+ 0xc0004960, 0xcf000000, 0x80000018, 0x5e780006, 0x8800000a, 0xc2800002, 0xc000495e, 0xce800000,
+ 0xde800001, 0xca800000, 0xde600000, 0xc240001e, 0x6a612000, 0x7e412000, 0x76694000, 0x6ba12000,
+ 0x72694000, 0xce800000, 0x5e300080, 0x840000a2, 0xc2000000, 0xc7200010, 0x5e600000, 0x84000040,
+ 0xde600001, 0x58204000, 0xca400000, 0x5a200002, 0xda240001, 0xc2800000, 0xc66b0040, 0xdaa80000,
+ 0xda600000, 0x80000020, 0xc2800000, 0x6e206000, 0xde240000, 0x6a610000, 0xc62b0040, 0xdaa80000,
+ 0x5b300002, 0x8000fdc8, 0xc2000000, 0x582c0020, 0xca020080, 0x00000000, 0xc2400000, 0x5a200002,
+ 0xc6241080, 0xce401080, 0xc000480e, 0xca800000, 0x5e740000, 0x84000148, 0x46292000, 0x8800dec8,
+ 0xc2400000, 0xc0000808, 0xca440018, 0x582c0010, 0xc1400000, 0xcd400001, 0xcd400001, 0xcd400001,
+ 0xcd400001, 0xcd400001, 0xcd400001, 0xcd400001, 0xcd400001, 0xcd400020, 0x582c0020, 0xce001080,
+ 0xc2000010, 0x5a640002, 0xb624fff8, 0x00000000, 0xc2400000, 0xc6600018, 0xc0000808, 0xce040018,
+ 0xc0004956, 0xca400000, 0xc11c0000, 0xc000082c, 0xcd040e08, 0xc6600930, 0xc2400000, 0xc6600030,
+ 0xc0000838, 0xce040000, 0xc2400002, 0xc0004958, 0xce400000, 0xc11c0002, 0xc000082c, 0xcd040e08,
+ 0x8000dd80, 0xc000495e, 0xca000000, 0x5e740002, 0x8400dd60, 0x5e200000, 0x8400dd50, 0xc0004960,
+ 0xca400000, 0xc2200004, 0x582c0002, 0xce001010, 0xc2000082, 0x46610000, 0xc6280038, 0xc0000810,
+ 0xce840038, 0x99006f68, 0x582c0002, 0xc9400000, 0xc1a20000, 0x5e640000, 0x8400feb8, 0x00000000,
+ 0x8000dcc0, 0x6c6c8000, 0x6c544000, 0x42d56000, 0x5aec4a00, 0xc000487c, 0xc8040000, 0x00000000,
+ 0x00000000, 0x40080000, 0xcb800000, 0xc4240000, 0x00000000, 0xa7860180, 0xc3c00000, 0xc2000000,
+ 0x582c000c, 0xca010040, 0x6c508000, 0xc0004880, 0x40100000, 0x58000016, 0xc9000000, 0x00000000,
+ 0x00000000, 0x59100002, 0xcd000000, 0x5a200002, 0x582c000c, 0xc6100840, 0xcd000840, 0x5e600002,
+ 0x84000008, 0xc2200004, 0x582c0002, 0xce001010, 0x5e600008, 0x84000048, 0xc2200002, 0x582c0002,
+ 0xce001010, 0x582c000c, 0xcfc00840, 0xc2220002, 0xc0000a14, 0xce041108, 0xc22001a2, 0xc0000a1c,
+ 0xce041040, 0x6c6c8000, 0x6c544000, 0x42d56000, 0x5aec4a00, 0x582c0004, 0xcb000000, 0xc3400000,
+ 0x00000000, 0xa7060008, 0xcf400308, 0xc3100002, 0xc0000838, 0xcf040808, 0x582c000c, 0xcf401008,
+ 0x8000dac0, 0x582c000c, 0xcfc00840, 0xc2000000, 0xc7a06018, 0x5e200000, 0x84001e18, 0x6c6c8000,
+ 0x6c544000, 0x42d56000, 0x5aec4a00, 0xc000487c, 0xc8040000, 0x00000000, 0x00000000, 0x40080000,
+ 0xcb800000, 0xc4240000, 0x00000000, 0xc2800000, 0xc3400000, 0xc7b5c038, 0xc0004970, 0xcf400000,
+ 0xc2400000, 0xc7a4e038, 0xc000496c, 0xce400000, 0xc3000000, 0xc7b00018, 0xc3c00004, 0xc000496e,
+ 0xcfc00000, 0x582c000c, 0xca000000, 0xc2400002, 0xc0004964, 0xce400000, 0xa6200352, 0x00000000,
+ 0x5e700004, 0x840000d2, 0x5e700006, 0x84000068, 0xc2000002, 0x582c0002, 0xce000008, 0xc0000a14,
+ 0xce841108, 0x6c508000, 0xc0004880, 0x40100000, 0x58000014, 0xc9000000, 0x00000000, 0x00000000,
+ 0x59100002, 0xcd000000, 0x80001c68, 0x5e70000a, 0x84000028, 0xc2000000, 0x582c0002, 0xce000008,
+ 0xc2220002, 0xc0000a14, 0xce041108, 0x8000ff58, 0x5e700008, 0x84000210, 0xc2200002, 0x582c000c,
+ 0xce001008, 0x6c508000, 0xc0004880, 0x40100000, 0x58000012, 0xc9000000, 0x00000000, 0x00000000,
+ 0x59100002, 0xcd000000, 0x5e340002, 0x6c508000, 0xc0004880, 0x40100000, 0x58000010, 0xc9000000,
+ 0x00000000, 0x00000000, 0x41208000, 0xcd000000, 0xc0000a14, 0xce841108, 0xc0004970, 0xcb400000,
+ 0x6c6c8000, 0x6c544000, 0x42d56000, 0x5aec4a00, 0x582c000e, 0xc4900040, 0xcd000040, 0x582c000e,
+ 0xc7500840, 0xcd000840, 0xc2800000, 0x582c0004, 0xce801080, 0x582c0004, 0xce800008, 0xc00049a0,
+ 0xca400000, 0x00000000, 0x582c0006, 0xce400000, 0xc261fffe, 0x5a65fffe, 0x582c0024, 0xce400000,
+ 0xc2060002, 0x582c0004, 0xce000308, 0xc2400002, 0xc0004958, 0xce400000, 0xc0004878, 0xc8040000,
+ 0x6c908000, 0x41088000, 0x40100000, 0x58000020, 0xc9000000, 0x582c0026, 0x00000000, 0xcd000000,
+ 0x800019f8, 0x00000000, 0x6c508000, 0xc0004880, 0x40100000, 0x58000016, 0xc9000000, 0x00000000,
+ 0x00000000, 0x59100002, 0xcd000000, 0x8000fad8, 0x5e700000, 0x840000a8, 0xc3400082, 0xc0004970,
+ 0xcf400000, 0xc2400080, 0xc000496c, 0xce400000, 0xc3c00002, 0xc000496e, 0xcfc00000, 0xc2400000,
+ 0xc0004964, 0xce400000, 0xc0004878, 0xc8040000, 0x6c908000, 0x41088000, 0x40100000, 0x58000020,
+ 0xc9000000, 0x582c0026, 0x00000000, 0xcd000000, 0x80000060, 0x5e700002, 0x84000040, 0xc3400082,
+ 0xc0004970, 0xcf400000, 0xc3c00004, 0xc000496e, 0xcfc00000, 0xc2200000, 0x582c000c, 0xce001008,
+ 0x80000018, 0x5e700004, 0x8400fe68, 0xc2600002, 0x582c000c, 0xce401008, 0xc0000a14, 0xce841108,
+ 0xc000496c, 0xca400000, 0x6c508000, 0xc0004880, 0x40100000, 0x58000012, 0xc9000000, 0x00000000,
+ 0x00000000, 0x59100002, 0xcd000000, 0xc000496e, 0xcbc00000, 0x00000000, 0x00000000, 0x47f50000,
+ 0x46610000, 0x6c508000, 0xc0004880, 0x40100000, 0x58000010, 0xc9000000, 0x00000000, 0x00000000,
+ 0x41208000, 0xcd000000, 0x6c6c8000, 0x6c544000, 0x42d56000, 0x5aec4a00, 0x582c0004, 0xca000000,
+ 0x00000000, 0x00000000, 0xa60016ea, 0x00000000, 0x6c6c8000, 0x6c544000, 0x42d56000, 0x5aec4a00,
+ 0xc3000000, 0x582c0004, 0xcf000308, 0x582c0000, 0xcb002018, 0xc3c00000, 0x582c0004, 0xcbc20080,
+ 0xc000491a, 0xcf000000, 0xc000493c, 0xcfc00000, 0x582c0008, 0xcb800000, 0x582c000a, 0xca400000,
+ 0xc0004930, 0xcf800000, 0xc0004932, 0xce400000, 0x5ffc0000, 0x840001d8, 0x00000000, 0xa7be00e2,
+ 0xc2800000, 0x6f206000, 0x47210000, 0x5a204c80, 0x5820000c, 0xca800028, 0x00000000, 0x00000000,
+ 0x5ea80000, 0x840000fa, 0x00000000, 0xc161fffe, 0x5955fffe, 0x15400000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x99006330, 0xc000491a, 0xc9400000, 0x00000000,
+ 0xc121fffe, 0x5911fef4, 0x15000000, 0xc0004930, 0xcb800000, 0xc0004932, 0xca400000, 0xc4781110,
+ 0xc0004930, 0xcf800000, 0x582c0008, 0xcf800000, 0x582c000a, 0xce400000, 0xc7b6e110, 0x582c0004,
+ 0xcf400110, 0x80000078, 0x00000000, 0x6c508000, 0xc0004880, 0x40100000, 0x5800000c, 0xc9000000,
+ 0x00000000, 0x00000000, 0x59100002, 0xcd000000, 0xc2000002, 0x582c0004, 0xce000008, 0xc0000838,
+ 0xc2500002, 0xce440808, 0x80001430, 0x6c7c8000, 0x6c544000, 0x43d5e000, 0x5bfc4a00, 0x583c0006,
+ 0xca000000, 0xc00049a2, 0x00000000, 0xca800001, 0xca400000, 0xc0001008, 0xce800000, 0xc0001006,
+ 0xce400000, 0xc000100a, 0xce000000, 0xc2400006, 0xc0001000, 0xce400000, 0xc2600982, 0x5a643b6e,
+ 0xc0001002, 0xce400000, 0x583c0024, 0xca400000, 0x00000000, 0xc0001004, 0xce400000, 0xc0004862,
+ 0xc2000000, 0xca000080, 0xc360fffe, 0xc0004862, 0xce000000, 0xc0000824, 0xcb440068, 0x00000000,
+ 0xc000100e, 0xcf400000, 0xc3801600, 0xc2400200, 0x6e644000, 0xc6781078, 0xc000100c, 0xcf800000,
+ 0xc3200a00, 0xc0001010, 0xcf001818, 0xc2e06200, 0xc0001012, 0xcec01840, 0xc2000000, 0x583c0004,
+ 0xca002010, 0xc2800000, 0xc0004966, 0xce000000, 0xc6240000, 0xc3000000, 0xc000496a, 0xcf000000,
+ 0xc0004974, 0xcf000000, 0xc000493c, 0xcb400000, 0x583c000e, 0x00000000, 0x5f740000, 0x84000168,
+ 0xc3400000, 0xcb410040, 0xc3000002, 0xc000496a, 0x5fb40080, 0x8400013a, 0xcf000000, 0x583c000e,
+ 0xc2c00000, 0xcac00040, 0xc3800080, 0x4779c000, 0xc0004974, 0xcf800000, 0xc0001012, 0x6fba0000,
+ 0xcf801040, 0x6fba0010, 0x43a5c000, 0x5b380006, 0x6f284010, 0xc7a40010, 0x6eec4000, 0x6ef08000,
+ 0x432d8000, 0x43358000, 0x5b300008, 0xc0001012, 0xc7100078, 0xcd000078, 0xc2000200, 0xc2c00000,
+ 0xdf6d0050, 0x46e16000, 0x46ad6000, 0x8800ffca, 0xc2000000, 0xc0004862, 0xca000268, 0x00000000,
+ 0x583c0004, 0xca002010, 0xc3360002, 0xc0001010, 0xce000078, 0xc0001012, 0xcf001b08, 0xc0004974,
+ 0xcb800000, 0x00000000, 0x00000000, 0x5fb80000, 0x8400002a, 0x00000000, 0x00000000, 0x00000000,
+ 0xa8e2ffc8, 0x00000000, 0xc1220002, 0xd90c0000, 0xc000496c, 0xcac00000, 0x00000000, 0x00000000,
+ 0x426dc000, 0x5b380006, 0x6f304010, 0xc7a40010, 0xc0004968, 0xce400000, 0xc000496e, 0xcb400000,
+ 0x6ca44000, 0x6e608000, 0x42250000, 0x5a200006, 0x42350000, 0xc0001012, 0xc6100078, 0xcd000078,
+ 0x6eee0000, 0xcec01040, 0xc2000200, 0xc2c00000, 0xdf6d0050, 0x46e16000, 0x42b14000, 0x46ad6000,
+ 0x8800ffc2, 0xc000493c, 0xcb400000, 0xc0000838, 0xc3100002, 0x5f740000, 0x84000048, 0xcf040808,
+ 0xc0004974, 0xcb800000, 0x00000000, 0x00000000, 0x5fb80000, 0x84000052, 0xc0001012, 0xc3360002,
+ 0xcf001b08, 0x80000088, 0x583c0022, 0xcb400000, 0xc0004862, 0xca000000, 0x00000000, 0xc0005600,
+ 0x40200000, 0xcf400000, 0xc2000000, 0xc0004862, 0xca000268, 0x00000000, 0x583c0004, 0xca002010,
+ 0xc3360002, 0xc0001010, 0xce000078, 0xc0001012, 0xcf001b08, 0xc0004968, 0xcbc00000, 0xc0004964,
+ 0xca400000, 0xc7e00000, 0x00000000, 0x5e640000, 0x8400fffa, 0xc2000000, 0xc0004974, 0xca400000,
+ 0xc000496c, 0xca800000, 0xc000493c, 0xcb800000, 0x42698000, 0x00000000, 0x43b1a000, 0x5ef40080,
+ 0x88000182, 0xc0004966, 0xcac00000, 0x6c648000, 0x6c544000, 0x42552000, 0x5a644a00, 0x58240000,
+ 0x436da000, 0x4635a000, 0xc2400000, 0xca420080, 0x00000000, 0x00000000, 0x47652000, 0x8800010a,
+ 0x432d8000, 0x46318000, 0x8800fff8, 0xc3000000, 0x5b300006, 0x6f304010, 0xc000493a, 0xcf000000,
+ 0xc0004932, 0xc2400000, 0xca4000e0, 0x00000000, 0x6fb84010, 0x42792000, 0xc000491e, 0xce400000,
+ 0xc0004862, 0xca800000, 0x00000000, 0xc2c0000a, 0xc6e80d78, 0xc7281050, 0xc000491c, 0xce800000,
+ 0x6c708000, 0x6c544000, 0x43158000, 0x5b304a00, 0x6f760000, 0x58300004, 0xcf401080, 0x6ffc2000,
+ 0x58300004, 0xcfc00110, 0x80000168, 0x6c708000, 0x6c544000, 0x43158000, 0x5b304a00, 0xc2800002,
+ 0x58300004, 0xce800008, 0x6c508000, 0xc0004880, 0x40100000, 0x5800000e, 0xc9000000, 0x00000000,
+ 0x00000000, 0x59100002, 0xcd000000, 0xc0004816, 0xc8000000, 0x00000000, 0x00000000, 0x5c000000,
+ 0x84000072, 0xc11c0000, 0xc000082c, 0xcd040e08, 0xc0004816, 0xc8000000, 0x00000000, 0x00000000,
+ 0x5c000000, 0x84000012, 0x00000000, 0x00000000, 0x00000000, 0x8000ffa0, 0xc11c0002, 0xc000082c,
+ 0xcd040e08, 0x00000000, 0x00000000, 0x00000000, 0xa8e2ffc8, 0x00000000, 0xc1220002, 0xd90c0000,
+ 0x80000a80, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xa8e2ffc8, 0x00000000, 0xc1220002,
+ 0xd90c0000, 0xc0004964, 0xca000000, 0x6c7c8000, 0x6c544000, 0x43d5e000, 0x5bfc4a00, 0xdfe40000,
+ 0x5e200002, 0x840006a0, 0x00000000, 0x583c0004, 0xc2800000, 0xca820080, 0xc0004930, 0xcac00000,
+ 0x00000000, 0x00000000, 0x6eece000, 0x6eefc010, 0x46e8a000, 0xc1000000, 0xdd500041, 0x6d106010,
+ 0x4514a000, 0xc1000000, 0xdd514209, 0x4514c000, 0xa9500181, 0xc00049a6, 0xca000000, 0xa94a0003,
+ 0x00000000, 0x6e660000, 0x6e660010, 0x46252000, 0x8400014a, 0x00000000, 0xc0004812, 0xc8000000,
+ 0x00000000, 0x00000000, 0x5c000000, 0x84000072, 0xc11c0000, 0xc000082c, 0xcd040e08, 0xc0004812,
+ 0xc8000000, 0x00000000, 0x00000000, 0x5c000000, 0x84000012, 0x00000000, 0x00000000, 0x00000000,
+ 0x8000ffa0, 0xc11c0002, 0xc000082c, 0xcd040e08, 0x6c508000, 0xc0004880, 0x40100000, 0x58000004,
+ 0xc9000000, 0x00000000, 0x00000000, 0x59100002, 0xcd000000, 0x6c508000, 0xc0004880, 0x40100000,
+ 0x58000006, 0xc9000000, 0x00000000, 0x00000000, 0x41148000, 0xcd000000, 0x800007d0, 0x00000000,
+ 0xa95203a1, 0xc0001004, 0xcb800000, 0xc3400000, 0xdd740041, 0x5f740000, 0x840000b8, 0xc1218e08,
+ 0x5911baf6, 0x47908000, 0x8400035a, 0x00000000, 0x6c508000, 0xc0004880, 0x40100000, 0x58000008,
+ 0xc9000000, 0x00000000, 0x00000000, 0x59100002, 0xcd000000, 0x6c508000, 0xc0004880, 0x40100000,
+ 0x5800000a, 0xc9000000, 0x00000000, 0x00000000, 0x41148000, 0xcd000000, 0x800006d0, 0x00000000,
+ 0xc000496c, 0xcb000000, 0x583c0026, 0xcac00000, 0xc0004878, 0xc8040000, 0x6c908000, 0x41088000,
+ 0x40100000, 0x58000002, 0xca800000, 0x00000000, 0x00000000, 0x6ea90000, 0x5d300008, 0x88000032,
+ 0x59300002, 0xc3000000, 0xc5300010, 0x6d104010, 0x40100000, 0xca800000, 0x5c000002, 0xcac00000,
+ 0x5d300000, 0x84000022, 0x6f246000, 0x6ae56000, 0xc1000040, 0x46512000, 0x6aa54010, 0x42e96000,
+ 0x583c0026, 0xcec00000, 0xc1218e08, 0x5911baf6, 0xc0001004, 0xcd000000, 0x593c0026, 0xc000100e,
+ 0xcd000068, 0xc1340000, 0xc0001010, 0xcd001a08, 0xc1200008, 0xa94a0003, 0xc0001012, 0xc1200004,
+ 0x59100004, 0xcd0000c0, 0xc1360002, 0xcd001b08, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0xa8e2ffc8, 0x00000000, 0xc1220002, 0xd90c0000, 0xc0001004, 0xc9000000, 0x00000000,
+ 0x00000000, 0x47908000, 0x8400009a, 0x00000000, 0x6c508000, 0xc0004880, 0x40100000, 0x58000008,
+ 0xc9000000, 0x00000000, 0x00000000, 0x59100002, 0xcd000000, 0x6c508000, 0xc0004880, 0x40100000,
+ 0x5800000a, 0xc9000000, 0x00000000, 0x00000000, 0x41148000, 0xcd000000, 0x80000410, 0x00000000,
+ 0x6c508000, 0xc0004880, 0x40100000, 0x58000000, 0xc9000000, 0x00000000, 0x00000000, 0x59100002,
+ 0xcd000000, 0x6c508000, 0xc0004880, 0x40100000, 0x58000002, 0xc9000000, 0x00000000, 0x00000000,
+ 0x41148000, 0xcd000000, 0xc0004930, 0xcd800080, 0xc3000000, 0x583c0008, 0xcf000000, 0x800000e8,
+ 0xc0001004, 0xca000000, 0x583c0006, 0xce400000, 0x583c0024, 0xce000000, 0xc0004814, 0xc8000000,
+ 0x00000000, 0x00000000, 0x5c000000, 0x8400008a, 0xc001fffe, 0x46400000, 0x84000070, 0xc11c0000,
+ 0xc000082c, 0xcd040e08, 0xc0004814, 0xc8000000, 0x00000000, 0x00000000, 0x5c000000, 0x84000012,
+ 0x00000000, 0x00000000, 0x00000000, 0x8000ffa0, 0xc11c0002, 0xc000082c, 0xcd040e08, 0xc0004862,
+ 0xc2000000, 0xca000080, 0xc000493a, 0xca400000, 0x00000000, 0x00000000, 0x42254000, 0x5ee80200,
+ 0x8800fffa, 0xc6e80000, 0xc0004000, 0x58001600, 0x40280000, 0xcb800000, 0x00000000, 0x583c0022,
+ 0xcf800000, 0xc0004862, 0xce800080, 0xc0001406, 0xcac00000, 0xc2800002, 0x00000000, 0xc66c1050,
+ 0xc6ac0a08, 0xcec00000, 0xc2000000, 0xdf600040, 0x5e600080, 0x8400ffd2, 0xc000491c, 0xca400000,
+ 0xc000491e, 0xca800000, 0x99006840, 0xda580000, 0xda980001, 0x00000000, 0xc0004964, 0xcbc00000,
+ 0x00000000, 0x00000000, 0x5ffc0000, 0x840000ea, 0xc2000000, 0xdf610050, 0x5e6001fe, 0x8800ffd0,
+ 0xc000491a, 0xc9800000, 0xc0004862, 0xc9400000, 0x6d9c6000, 0x459ce000, 0x59dc4c80, 0x990066a0,
+ 0xd9580000, 0xd9980001, 0xd9d40000, 0x99006618, 0xc000491c, 0xc1400000, 0xc9420050, 0xc2000000,
+ 0xdf600040, 0x5e600080, 0x8400ffd2, 0xc000491c, 0xca400000, 0xc000491e, 0xca800000, 0x99006840,
+ 0xda580000, 0xda980001, 0x00000000, 0xc0004970, 0xcb400000, 0x00000000, 0x00000000, 0x5e740082,
+ 0x8400e498, 0x00000000, 0x8000bc70, 0x00000000, 0x6c508000, 0xc0004880, 0x40100000, 0x58000016,
+ 0xc9000000, 0x00000000, 0x00000000, 0x59100002, 0xcd000000, 0x8000e0c8, 0x6c6c8000, 0x6c544000,
+ 0x42d56000, 0x5aec4a00, 0xc000487c, 0xc8040000, 0x00000000, 0x00000000, 0x40080000, 0xca000000,
+ 0xc4240000, 0x00000000, 0xa6060108, 0xc3c00000, 0xc2000000, 0x582c000c, 0xca010040, 0x00000000,
+ 0x00000000, 0x5a200002, 0xc6100840, 0xcd000840, 0x5e60000e, 0x8400bb58, 0xc2200000, 0x582c0002,
+ 0xce001010, 0x582c000c, 0xcfc00840, 0x582c0020, 0xcfc01080, 0x582c0010, 0xc1400000, 0xcd400001,
+ 0xcd400001, 0xcd400001, 0xcd400001, 0xcd400001, 0xcd400001, 0xcd400001, 0xcd400001, 0xcd400020,
+ 0xc000481a, 0xca000000, 0x00000000, 0x00000000, 0x5a200002, 0xce000000, 0x8000ba90, 0xc2200004,
+ 0x582c0002, 0xce001010, 0x582c000c, 0xcfc00840, 0x99006f68, 0x582c0002, 0xc9400000, 0xc1a20000,
+ 0x8000ba40, 0xc3e1fffe, 0x597dfffe, 0x593dfef4, 0x94000001, 0x00000000, 0x00000000, 0x00000000,
+ 0xc0800000, 0xdf4b0040, 0xc0004900, 0xcb800000, 0xc2000000, 0xc000490a, 0xa78000b0, 0xcbc00000,
+ 0xc1000000, 0xd9000001, 0xc1000002, 0xd90c0000, 0x6ff46000, 0x47f5a000, 0x5b744c80, 0xc2400000,
+ 0x58340004, 0xca400080, 0xc0004900, 0xce000008, 0x5a640002, 0x58340004, 0xc6500080, 0xcd000080,
+ 0xc0004914, 0xca400000, 0xc2000002, 0x6a3d0000, 0x72252000, 0xce400000, 0xc0000408, 0xce000000,
+ 0xa78200a8, 0xc0004908, 0xcbc00000, 0xc1000000, 0xd9000001, 0xc1000002, 0xd90c0000, 0x6ff4a000,
+ 0x47f5a000, 0x5b744e20, 0xc2800000, 0x58340006, 0xca800080, 0xc2000000, 0xc0004900, 0xce000108,
+ 0x5ea80002, 0x58340006, 0xc6900080, 0xcd000080, 0x5a7c0020, 0xc2000002, 0x6a250000, 0xc0000408,
+ 0xce000000, 0xdca80001, 0x5ea80000, 0x8400a7f8, 0x00000000, 0xa4800210, 0x00000000, 0xc3c00000,
+ 0xc000140e, 0xcbc00020, 0xc3400000, 0xc2400000, 0x6ff86000, 0x47f9c000, 0x5bb84c80, 0x58380008,
+ 0xcb400080, 0x58380006, 0xca400080, 0x5f740002, 0x58380008, 0xc7500080, 0xcd000080, 0xc2000000,
+ 0x58380004, 0xca020080, 0xc3000000, 0x5838000c, 0xcb000028, 0x5a640002, 0x46250000, 0x8400fff8,
+ 0xc2400000, 0x58380006, 0xc6500080, 0xcd000080, 0xc2000000, 0x5838000a, 0xca020080, 0x5b300002,
+ 0x5838000c, 0xc7100028, 0xcd000028, 0xc2420020, 0x5a200004, 0x46612000, 0x8400fff8, 0xc2000000,
+ 0x5838000a, 0xc6101080, 0xcd001080, 0xc000498c, 0xca400000, 0xc2000002, 0x6a3d0000, 0x72252000,
+ 0xce400000, 0x5f740000, 0x84000028, 0xc0004912, 0xca000000, 0xc2c00002, 0x6afd6000, 0x7ec16000,
+ 0x76e10000, 0xce000000, 0x5f300020, 0x84000028, 0xc0004924, 0xca000000, 0xc2c00002, 0x6afd6000,
+ 0x7ec16000, 0x76e10000, 0xce000000, 0xa4820050, 0xc2400000, 0xc000140e, 0xca408020, 0xc2000002,
+ 0xc0004900, 0xce000008, 0xc000490a, 0xce400000, 0xc1000000, 0xd9000001, 0xd8400080, 0xc1000004,
+ 0xd9000001, 0xa48402b8, 0x00000000, 0xc3c00000, 0xc000140e, 0xcbc10020, 0xc2800000, 0xc2000000,
+ 0x6ff8a000, 0x47f9c000, 0x5bb84e20, 0x58380036, 0xca800080, 0x58380006, 0xca020080, 0xc3400000,
+ 0x58380036, 0xcb420080, 0x5aa80002, 0x46290000, 0x8400fff8, 0xc2800000, 0x58380036, 0xc6900080,
+ 0xcd000080, 0x5f740002, 0x58380036, 0xc7501080, 0xcd001080, 0xc000498e, 0xca400000, 0xc2000002,
+ 0x6a3d0000, 0x72252000, 0xce400000, 0xc000492a, 0xca800000, 0x5e740000, 0x84000028, 0xc0004910,
+ 0xca000000, 0xc2c00002, 0x6afd6000, 0x7ec16000, 0x76e10000, 0xce000000, 0x6abd4010, 0xa6800112,
+ 0x00000000, 0x5838003a, 0xca000000, 0x58000002, 0xca400000, 0x5838000e, 0x00000000, 0xce000001,
+ 0xce400000, 0xc2400000, 0xdd250040, 0xc1000080, 0x46508000, 0xc2400000, 0xc6240080, 0x45250000,
+ 0x00000000, 0xc5240004, 0x5d240078, 0xc1000078, 0xc5240004, 0xc6600080, 0x5c000002, 0xce000080,
+ 0xc000492a, 0xca000000, 0xc2c00002, 0x6afd6000, 0x72e10000, 0xce000000, 0xc000492c, 0xca000000,
+ 0xc2c00002, 0x6afd6000, 0x72e10000, 0xce000000, 0x80000028, 0xc000492c, 0xca000000, 0xc2c00002,
+ 0x6afd6000, 0x7ec16000, 0x76e10000, 0xce000000, 0xa4880068, 0xc2c00000, 0xc000140e, 0xcac20020,
+ 0xc000490e, 0xca400000, 0xc2000002, 0x6a2d0000, 0x7e010000, 0x76252000, 0xce400000, 0xc0004990,
+ 0xca400000, 0xc2000002, 0x6a2d0000, 0x72252000, 0xce400000, 0xa4860050, 0xc2400000, 0xc000140e,
+ 0xca418020, 0xc2020002, 0xc0004900, 0xce000108, 0xc0004908, 0xce400000, 0xc1000000, 0xd9000001,
+ 0xd8400080, 0xc1000004, 0xd9000001, 0xc0001408, 0xcc800000, 0xc10e0002, 0xd90c0000, 0x8000f738,
+ 0xdfbc0001, 0xc0004992, 0x99006fa8, 0xc9400000, 0xc7d80000, 0x00000000, 0xc5700000, 0x5ef00020,
+ 0x88000140, 0x6f346000, 0x4735a000, 0x5b744c80, 0x58340008, 0xc2400000, 0xca400080, 0x00000000,
+ 0xc2000000, 0x5a640002, 0xc6500080, 0xcd000080, 0x58340004, 0xca000080, 0x00000000, 0x00000000,
+ 0x5e200002, 0xc6100080, 0xcd000080, 0xc0004912, 0xca800000, 0xc2400002, 0x6a712000, 0x72694000,
+ 0xce800000, 0x5e200000, 0x8400003a, 0xc000480a, 0xca000000, 0xc0000408, 0xca800000, 0x76610000,
+ 0x00000000, 0x72294000, 0xce800000, 0x80000020, 0xc0004914, 0xca000000, 0x7e412000, 0x00000000,
+ 0x76610000, 0xce000000, 0x800000b0, 0x6ef4a000, 0x46f5a000, 0x5b744e20, 0x58340036, 0xc2400000,
+ 0xca420080, 0x00000000, 0xc2000000, 0x5a640002, 0xc6501080, 0xcd001080, 0x58340006, 0xca000080,
+ 0x00000000, 0x00000000, 0x5a200002, 0xc6100080, 0xcd000080, 0xc0004910, 0xca400000, 0xc2000002,
+ 0x6a2d0000, 0x72252000, 0xce400000, 0xc2000002, 0x6a310000, 0xc000042a, 0xce000000, 0xc1040002,
+ 0xd90c0000, 0x00000000, 0x8000f4a0, 0x00000000, 0xc4980930, 0x9d000000, 0xc5580030, 0xc0000838,
+ 0xcd840000, 0xc1440200, 0xc1c01600, 0xc55c1078, 0xc000100e, 0x9d000000, 0xcd800000, 0xc000100c,
+ 0xcdc00000, 0xc0004862, 0xc9c00000, 0x00000000, 0x00000000, 0xd9d80001, 0xc0005600, 0x401c0000,
+ 0x5dc05800, 0x8800fffa, 0x5c000200, 0xcd800000, 0xc1f0000a, 0x71d4a000, 0xdd980000, 0xdd9c0001,
+ 0x41d8e000, 0xc5d40268, 0xc0001010, 0xcd400000, 0x6c9c8000, 0x449ce000, 0x449ce000, 0x59dc0004,
+ 0xc1601260, 0xc5d40268, 0x9d000000, 0xc0001012, 0xcd400000, 0x00000000, 0x00000000, 0xd9580000,
+ 0x6d586000, 0x4558c000, 0x59984c80, 0xd9980001, 0x5818000a, 0xc1800000, 0xc9800080, 0xc0005400,
+ 0x6d5ca000, 0x401c0000, 0x40180000, 0xc9400000, 0x58000002, 0x00000000, 0xc9c00000, 0xc0004930,
+ 0xcd400000, 0xc0004932, 0xcdc00000, 0x59980004, 0xc1c20020, 0xb59cfff8, 0x00000000, 0xc1800000,
+ 0xdd9c0001, 0x581c000a, 0xcd800080, 0x581c000c, 0xc1800000, 0xc9800028, 0xc1c00002, 0xdd940000,
+ 0x69d4e000, 0x5d980002, 0xcd800028, 0xc0004924, 0xc9800000, 0x00000000, 0x9d000000, 0x00000000,
+ 0x71d8c000, 0xcd800000, 0xc000492a, 0xc9400000, 0xc1c00002, 0x69d8e000, 0x7dc0c000, 0x7594a000,
+ 0xcd400000, 0xc000492c, 0xc9400000, 0xdd800001, 0x5800003a, 0x75d4a000, 0x840000f0, 0xc9400001,
+ 0xc9800000, 0xdd800001, 0x5800000e, 0x00000000, 0xcd400001, 0xcd800000, 0xc1800000, 0xdd190040,
+ 0xc1000080, 0x45908000, 0xc1800000, 0xc5580080, 0x4518a000, 0x00000000, 0xc5180004, 0x5d180078,
+ 0xc1000078, 0xc5180004, 0xc5940080, 0x5c000002, 0xcd400080, 0xc000492c, 0xc9400000, 0xc000492a,
+ 0xc9800000, 0x71d4a000, 0xc000492c, 0xcd400000, 0x71d8c000, 0xc000492a, 0xcd800000, 0x9cc00000,
+ 0x00000000, 0x00000000, 0x00000000, 0xc0004862, 0xc9800000, 0x00000000, 0xc1c00200, 0x4194c000,
+ 0x45d8e000, 0x8800fffa, 0xc5d80000, 0xc0004862, 0xcd800000, 0xc0001406, 0xc9800000, 0xc1c00002,
+ 0x9d000000, 0xc5d80a08, 0xc5581050, 0xcd800000, 0xc0004930, 0xc9800000, 0xc0004932, 0xc9c00000,
+ 0xc140000e, 0xc5581c20, 0xdd940000, 0xc0005600, 0x40140000, 0x5d405800, 0x8800fffa, 0x5c000200,
+ 0xcd800000, 0x58000002, 0x5d405800, 0x8800fffa, 0x5c000200, 0xcdc00000, 0xdd540000, 0xc1c00000,
+ 0x58140006, 0xc9c20080, 0xc1800000, 0x58140000, 0xc98000e0, 0x6ddc2000, 0xc000491e, 0x41d8e000,
+ 0xcdc00000, 0xdd980000, 0xc1c00022, 0xc5d80d78, 0xdd940001, 0xc5581c20, 0xc000491c, 0xcd800000,
+ 0xdd540000, 0xc1c00000, 0x58140006, 0xc9c20080, 0xc1800000, 0x58140004, 0xc9820080, 0x00000000,
+ 0x59dc0002, 0x459cc000, 0x8400fff8, 0xc1c00000, 0x9d000000, 0x58140006, 0xc5d81080, 0xcd801080,
+ 0xc0004860, 0xc9400000, 0xc1820080, 0xc1d00002, 0x58146b00, 0xd5800000, 0x58000002, 0xd5800001,
+ 0x59540004, 0xb558fff8, 0xc0004860, 0xc1400000, 0xcd400000, 0xdd980001, 0x9d000000, 0xdd940000,
+ 0xc0001404, 0xcdc00808, 0xc1c00000, 0xc1800200, 0x5d980004, 0xdf5d0050, 0x45d8a000, 0x8800ffda,
+ 0xdd800001, 0x5800000e, 0x00000000, 0xc9400001, 0xc9800000, 0xc1c00002, 0xc5d43f08, 0xc5d81e08,
+ 0xc0004862, 0xc9c00000, 0x00000000, 0x00000000, 0x581c5600, 0x5dc05800, 0x8800fffa, 0x5c000200,
+ 0xcd400000, 0x58000002, 0x5dc05800, 0x8800fffa, 0x5c000200, 0xcd800000, 0xc0004862, 0xc9c00000,
+ 0x00000000, 0xc15004c0, 0xc5d40068, 0xdd9c0000, 0xc5d41c20, 0xc1c00000, 0xdd800001, 0x58000038,
+ 0xc9c00080, 0xdd800001, 0xc1800000, 0x58000002, 0xc98000e0, 0x6ddc2000, 0xc000491c, 0x41d8e000,
+ 0xcd400001, 0xcdc00000, 0xdd940001, 0xc1c00000, 0x58140038, 0xc9c00080, 0xc1800000, 0x58140006,
+ 0xc9820080, 0x00000000, 0x59dc0002, 0x459cc000, 0x8400fff8, 0xc1c00000, 0x9d000000, 0x58140038,
+ 0xc5d80080, 0xcd800080, 0xc1c00000, 0xdf5c0040, 0x5ddc0080, 0x8400ffd2, 0x00000000, 0x9d000000,
+ 0x00000000, 0x00000000, 0x00000000, 0xc160fffe, 0xc0000a10, 0xc9440068, 0xc1a0fffe, 0x59980e28,
+ 0xc000100c, 0xcd400000, 0xc000100e, 0xcd800000, 0xc0004962, 0xc9800000, 0x00000000, 0xc170000a,
+ 0x7194a000, 0x6c988000, 0x4498c000, 0x4498c000, 0x59980004, 0xc5940278, 0xc0001010, 0xcd400000,
+ 0xc0004946, 0xc9400000, 0x00000000, 0x00000000, 0x6d58a000, 0x6d5c4000, 0x45d8c000, 0x4558c000,
+ 0xc000494a, 0xc9400000, 0xc0004948, 0xc9c00000, 0x4194c000, 0xc1400012, 0xc55c1820, 0x9d000000,
+ 0xc59c0270, 0xc0001012, 0xcdc00000, 0xc1400000, 0x58000014, 0xc9410040, 0xc0004950, 0xc9c00000,
+ 0xc5580000, 0xc5940840, 0xc5581080, 0xd9940000, 0xc000493c, 0xc9400000, 0xc0004954, 0xc9800000,
+ 0x59dc00a8, 0x455ce000, 0x41d8e000, 0x5d5c0030, 0x8800fff8, 0xc1c00030, 0xc1800000, 0xc5d84030,
+ 0xc1400000, 0xc5d40010, 0x5dd40002, 0x8400005a, 0x5dd40004, 0x84000082, 0x5dd40006, 0x840000aa,
+ 0x5dd80026, 0x840000d2, 0xdd540000, 0xdd800001, 0x58000008, 0x40180000, 0xcd400000, 0x59980002,
+ 0x8000ffa8, 0xdd540000, 0xdd800001, 0x58000008, 0x40180000, 0xcd4000c0, 0x59980002, 0x8000ff70,
+ 0xdd540000, 0xdd800001, 0x58000008, 0x40180000, 0xcd400080, 0x59980002, 0x8000ff38, 0xdd540000,
+ 0xdd800001, 0x58000008, 0x40180000, 0xcd400040, 0x59980002, 0x8000ff00, 0x00000000, 0x9d000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x58000014, 0xc9400000, 0xc0004954, 0xc9c00000, 0xc0004950,
+ 0xc9400080, 0xdd800001, 0x5800002a, 0x5d9c0000, 0x8400003a, 0x5d9c0002, 0x8400003a, 0x5d9c0004,
+ 0x84000052, 0xc55b0040, 0xc55c08c0, 0xcd800041, 0xcdc008c0, 0x80000048, 0xcd400000, 0x80000038,
+ 0xc55900c0, 0xc55c1840, 0xcd8000c1, 0xcdc01840, 0x80000010, 0xc55a0080, 0xc55c1080, 0xcd800081,
+ 0xcdc01080, 0x9d000000, 0x00000000, 0x00000000, 0x00000000, 0xc1e00000, 0xa540fffa, 0xc0000a14,
+ 0xc1a20002, 0x9d000000, 0xcd841108, 0xc0000a1c, 0xcdc41040, 0x59540002, 0x6994e018, 0x61c0c008,
+ 0x4194a000, 0x5d940040, 0x8800fffa, 0xc5940000, 0x9d000000, 0xcd400000, 0x00000000, 0x00000000,
+};
+
+static unsigned int firmware_binary_data[] = {
+};
+
+
+#endif // IFXMIPS_PTM_FW_DANUBE_H
diff --git a/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_fw_regs_adsl.h b/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_fw_regs_adsl.h
new file mode 100644
index 0000000..d6bdfd9
--- /dev/null
+++ b/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_fw_regs_adsl.h
@@ -0,0 +1,284 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_ptm_fw_regs_adsl.h
+** PROJECT : UEIP
+** MODULES : PTM
+**
+** DATE : 7 Jul 2009
+** AUTHOR : Xu Liang
+** DESCRIPTION : PTM driver header file (firmware register for ADSL)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 07 JUL 2009 Xu Liang Init Version
+*******************************************************************************/
+
+
+
+#ifndef IFXMIPS_PTM_FW_REGS_ADSL_H
+#define IFXMIPS_PTM_FW_REGS_ADSL_H
+
+
+
+#if defined(CONFIG_DANUBE)
+ #include "ifxmips_ptm_fw_regs_danube.h"
+#elif defined(CONFIG_AMAZON_SE)
+ #include "ifxmips_ptm_fw_regs_amazon_se.h"
+#elif defined(CONFIG_AR9)
+ #include "ifxmips_ptm_fw_regs_ar9.h"
+#elif defined(CONFIG_VR9)
+ #error VR9 is not ADSL PTM mode!
+#else
+ #error Platform is not specified!
+#endif
+
+
+
+/*
+ * MIB Table Maintained by Firmware
+ */
+
+struct wan_mib_table {
+ unsigned int wrx_correct_pdu; /* 0 */
+ unsigned int wrx_correct_pdu_bytes; /* 1 */
+ unsigned int wrx_tccrc_err_pdu; /* 2 */
+ unsigned int wrx_tccrc_err_pdu_bytes; /* 3 */
+ unsigned int wrx_ethcrc_err_pdu; /* 4 */
+ unsigned int wrx_ethcrc_err_pdu_bytes; /* 5 */
+ unsigned int wrx_nodesc_drop_pdu; /* 6 */
+ unsigned int wrx_len_violation_drop_pdu; /* 7 */
+ unsigned int wrx_idle_bytes; /* 8 */
+ unsigned int wrx_nonidle_cw; /* 9 */
+ unsigned int wrx_idle_cw; /* A */
+ unsigned int wrx_err_cw; /* B */
+ unsigned int wtx_total_pdu; /* C */
+ unsigned int wtx_total_bytes; /* D */
+ unsigned int res0; /* E */
+ unsigned int res1; /* F */
+};
+
+
+/*
+ * Host-PPE Communication Data Structure
+ */
+
+#if defined(__BIG_ENDIAN)
+
+ struct fw_ver_id {
+ unsigned int family :4;
+ unsigned int fwtype :4;
+ unsigned int interface :4;
+ unsigned int fwmode :4;
+ unsigned int major :8;
+ unsigned int minor :8;
+ };
+
+ struct wrx_port_cfg_status {
+ /* 0h */
+ unsigned int mfs :16;
+ unsigned int res0 :12;
+ unsigned int dmach :3;
+ unsigned int res1 :1;
+
+ /* 1h */
+ unsigned int res2 :14;
+ unsigned int local_state :2; // init with 0, written by firmware only
+ unsigned int res3 :15;
+ unsigned int partner_state :1; // init with 0, written by firmware only
+
+ };
+
+ struct wrx_dma_channel_config {
+ /* 0h */
+ unsigned int res3 :1;
+ unsigned int res4 :2;
+ unsigned int res5 :1;
+ unsigned int desba :28;
+ /* 1h */
+ unsigned int res1 :16;
+ unsigned int res2 :16;
+ /* 2h */
+ unsigned int deslen :16;
+ unsigned int vlddes :16;
+ };
+
+ struct wtx_port_cfg {
+ /* 0h */
+ unsigned int tx_cwth2 :8;
+ unsigned int tx_cwth1 :8;
+ unsigned int res0 :16;
+ };
+
+ struct wtx_dma_channel_config {
+ /* 0h */
+ unsigned int res3 :1;
+ unsigned int res4 :2;
+ unsigned int res5 :1;
+ unsigned int desba :28;
+
+ /* 1h */
+ unsigned int res1 :16;
+ unsigned int res2 :16;
+
+ /* 2h */
+ unsigned int deslen :16;
+ unsigned int vlddes :16;
+ };
+
+ struct eth_efmtc_crc_cfg {
+ /* 0h */
+ unsigned int res0 :6;
+ unsigned int tx_eth_crc_gen :1;
+ unsigned int tx_tc_crc_gen :1;
+ unsigned int tx_tc_crc_len :8;
+ unsigned int res1 :5;
+ unsigned int rx_eth_crc_present :1;
+ unsigned int rx_eth_crc_check :1;
+ unsigned int rx_tc_crc_check :1;
+ unsigned int rx_tc_crc_len :8;
+ };
+
+ /* DMA descriptor */
+ struct rx_descriptor {
+ /* 0 - 3h */
+ unsigned int own :1;
+ unsigned int c :1;
+ unsigned int sop :1;
+ unsigned int eop :1;
+ unsigned int res1 :3;
+ unsigned int byteoff :2;
+ unsigned int res2 :2;
+ unsigned int id :4;
+ unsigned int err :1;
+ unsigned int datalen :16;
+ /* 4 - 7h */
+ unsigned int res3 :4;
+ unsigned int dataptr :28;
+ };
+
+ struct tx_descriptor {
+ /* 0 - 3h */
+ unsigned int own :1;
+ unsigned int c :1;
+ unsigned int sop :1;
+ unsigned int eop :1;
+ unsigned int byteoff :5;
+ unsigned int res1 :5;
+ unsigned int iscell :1;
+ unsigned int clp :1;
+ unsigned int datalen :16;
+ /* 4 - 7h */
+ unsigned int res2 :4;
+ unsigned int dataptr :28;
+ };
+
+#else /* defined(__BIG_ENDIAN) */
+
+ struct wrx_port_cfg_status {
+ /* 0h */
+ unsigned int res1 :1;
+ unsigned int dmach :3;
+ unsigned int res0 :12;
+ unsigned int mfs :16;
+
+ /* 1h */
+ unsigned int partner_state :1;
+ unsigned int res3 :15;
+ unsigned int local_state :2;
+ unsigned int res2 :14;
+ };
+
+ struct wrx_dma_channel_config {
+ /* 0h */
+ unsigned int desba :28;
+ unsigned int res5 :1;
+ unsigned int res4 :2;
+ unsigned int res3 :1;
+ /* 1h */
+ unsigned int res2 :16;
+ unsigned int res1 :16;
+ /* 2h */
+ unsigned int vlddes :16;
+ unsigned int deslen :16;
+ };
+
+ struct wtx_port_cfg {
+ /* 0h */
+ unsigned int res0 :16;
+ unsigned int tx_cwth1 :8;
+ unsigned int tx_cwth2 :8;
+ };
+
+ struct wtx_dma_channel_config {
+ /* 0h */
+ unsigned int desba :28;
+ unsigned int res5 :1;
+ unsigned int res4 :2;
+ unsigned int res3 :1;
+ /* 1h */
+ unsigned int res2 :16;
+ unsigned int res1 :16;
+ /* 2h */
+ unsigned int vlddes :16;
+ unsigned int deslen :16;
+ };
+
+ struct eth_efmtc_crc_cfg {
+ /* 0h */
+ unsigned int rx_tc_crc_len :8;
+ unsigned int rx_tc_crc_check :1;
+ unsigned int rx_eth_crc_check :1;
+ unsigned int rx_eth_crc_present :1;
+ unsigned int res1 :5;
+ unsigned int tx_tc_crc_len :8;
+ unsigned int tx_tc_crc_gen :1;
+ unsigned int tx_eth_crc_gen :1;
+ unsigned int res0 :6;
+ };
+
+ /* DMA descriptor */
+ struct rx_descriptor {
+ /* 4 - 7h */
+ unsigned int dataptr :28;
+ unsigned int res3 :4;
+ /* 0 - 3h */
+ unsigned int datalen :16;
+ unsigned int err :1;
+ unsigned int id :4;
+ unsigned int res2 :2;
+ unsigned int byteoff :2;
+ unsigned int res1 :3;
+ unsigned int eop :1;
+ unsigned int sop :1;
+ unsigned int c :1;
+ unsigned int own :1;
+ };
+
+ struct tx_descriptor {
+ /* 4 - 7h */
+ unsigned int dataptr :28;
+ unsigned int res2 :4;
+ /* 0 - 3h */
+ unsigned int datalen :16;
+ unsigned int clp :1;
+ unsigned int iscell :1;
+ unsigned int res1 :5;
+ unsigned int byteoff :5;
+ unsigned int eop :1;
+ unsigned int sop :1;
+ unsigned int c :1;
+ unsigned int own :1;
+ };
+#endif /* defined(__BIG_ENDIAN) */
+
+
+
+#endif // IFXMIPS_PTM_FW_REGS_ADSL_H
diff --git a/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_fw_regs_amazon_se.h b/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_fw_regs_amazon_se.h
new file mode 100644
index 0000000..1219b6b
--- /dev/null
+++ b/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_fw_regs_amazon_se.h
@@ -0,0 +1,48 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_ptm_fw_regs_amazon_se.h
+** PROJECT : UEIP
+** MODULES : PTM
+**
+** DATE : 7 Jul 2009
+** AUTHOR : Xu Liang
+** DESCRIPTION : PTM driver header file (firmware register for Amazon-SE)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 07 JUL 2009 Xu Liang Init Version
+*******************************************************************************/
+
+
+
+#ifndef IFXMIPS_PTM_FW_REGS_AMAZON_SE_H
+#define IFXMIPS_PTM_FW_REGS_AMAZON_SE_H
+
+
+
+/*
+ * Host-PPE Communication Data Address Mapping
+ */
+#define FW_VER_ID ((volatile struct fw_ver_id *) SB_BUFFER(0x2401))
+#define CFG_WAN_WRDES_DELAY SB_BUFFER(0x2404)
+#define CFG_WRX_DMACH_ON SB_BUFFER(0x2405)
+#define CFG_WTX_DMACH_ON SB_BUFFER(0x2406)
+#define CFG_WRX_LOOK_BITTH SB_BUFFER(0x2407)
+#define CFG_ETH_EFMTC_CRC ((volatile struct eth_efmtc_crc_cfg *) SB_BUFFER(0x2408))
+#define WAN_MIB_TABLE ((volatile struct wan_mib_table*) SB_BUFFER(0x2440))
+#define WRX_PORT_CONFIG(i) ((volatile struct wrx_port_cfg_status*) SB_BUFFER(0x2500 + (i) * 20))
+#define WRX_DMA_CHANNEL_CONFIG(i) ((volatile struct wrx_dma_channel_config*) SB_BUFFER(0x2640 + (i) * 7))
+#define WTX_PORT_CONFIG(i) ((volatile struct wtx_port_cfg*) SB_BUFFER(0x2710 + (i) * 31))
+#define WTX_DMA_CHANNEL_CONFIG(i) ((volatile struct wtx_dma_channel_config*) SB_BUFFER(0x2711 + (i) * 31))
+
+
+
+#endif // IFXMIPS_PTM_FW_REGS_AMAZON_SE_H
diff --git a/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_fw_regs_ar9.h b/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_fw_regs_ar9.h
new file mode 100644
index 0000000..43f4da9
--- /dev/null
+++ b/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_fw_regs_ar9.h
@@ -0,0 +1,48 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_ptm_fw_regs_ar9.h
+** PROJECT : UEIP
+** MODULES : PTM
+**
+** DATE : 7 Jul 2009
+** AUTHOR : Xu Liang
+** DESCRIPTION : PTM driver header file (firmware register for AR9)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 07 JUL 2009 Xu Liang Init Version
+*******************************************************************************/
+
+
+
+#ifndef IFXMIPS_PTM_FW_REGS_AR9_H
+#define IFXMIPS_PTM_FW_REGS_AR9_H
+
+
+
+/*
+ * Host-PPE Communication Data Address Mapping
+ */
+#define FW_VER_ID ((volatile struct fw_ver_id *) SB_BUFFER(0x2001))
+#define CFG_WAN_WRDES_DELAY SB_BUFFER(0x2404)
+#define CFG_WRX_DMACH_ON SB_BUFFER(0x2405)
+#define CFG_WTX_DMACH_ON SB_BUFFER(0x2406)
+#define CFG_WRX_LOOK_BITTH SB_BUFFER(0x2407)
+#define CFG_ETH_EFMTC_CRC ((volatile struct eth_efmtc_crc_cfg *) SB_BUFFER(0x2408))
+#define WAN_MIB_TABLE ((volatile struct wan_mib_table*) SB_BUFFER(0x2440))
+#define WRX_PORT_CONFIG(i) ((volatile struct wrx_port_cfg_status*) SB_BUFFER(0x3F00 + (i) * 20))
+#define WRX_DMA_CHANNEL_CONFIG(i) ((volatile struct wrx_dma_channel_config*) SB_BUFFER(0x2640 + (i) * 7))
+#define WTX_PORT_CONFIG(i) ((volatile struct wtx_port_cfg*) SB_BUFFER(0x3B00 + (i) * 31))
+#define WTX_DMA_CHANNEL_CONFIG(i) ((volatile struct wtx_dma_channel_config*) SB_BUFFER(0x3B01 + (i) * 31))
+
+
+
+#endif // IFXMIPS_PTM_FW_REGS_AR9_H
diff --git a/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_fw_regs_danube.h b/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_fw_regs_danube.h
new file mode 100644
index 0000000..d8685f3
--- /dev/null
+++ b/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_fw_regs_danube.h
@@ -0,0 +1,48 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_ptm_fw_regs_danube.h
+** PROJECT : UEIP
+** MODULES : PTM
+**
+** DATE : 7 Jul 2009
+** AUTHOR : Xu Liang
+** DESCRIPTION : PTM driver header file (firmware register for Danube)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 07 JUL 2009 Xu Liang Init Version
+*******************************************************************************/
+
+
+
+#ifndef IFXMIPS_PTM_FW_REGS_DANUBE_H
+#define IFXMIPS_PTM_FW_REGS_DANUBE_H
+
+
+
+/*
+ * Host-PPE Communication Data Address Mapping
+ */
+#define FW_VER_ID ((volatile struct fw_ver_id *) SB_BUFFER(0x2001))
+#define CFG_WAN_WRDES_DELAY SB_BUFFER(0x2404)
+#define CFG_WRX_DMACH_ON SB_BUFFER(0x2405)
+#define CFG_WTX_DMACH_ON SB_BUFFER(0x2406)
+#define CFG_WRX_LOOK_BITTH SB_BUFFER(0x2407)
+#define CFG_ETH_EFMTC_CRC ((volatile struct eth_efmtc_crc_cfg *) SB_BUFFER(0x2408))
+#define WAN_MIB_TABLE ((volatile struct wan_mib_table*) SB_BUFFER(0x2440))
+#define WRX_PORT_CONFIG(i) ((volatile struct wrx_port_cfg_status*) SB_BUFFER(0x2500 + (i) * 20))
+#define WRX_DMA_CHANNEL_CONFIG(i) ((volatile struct wrx_dma_channel_config*) SB_BUFFER(0x2640 + (i) * 7))
+#define WTX_PORT_CONFIG(i) ((volatile struct wtx_port_cfg*) SB_BUFFER(0x2710 + (i) * 31))
+#define WTX_DMA_CHANNEL_CONFIG(i) ((volatile struct wtx_dma_channel_config*) SB_BUFFER(0x2711 + (i) * 31))
+
+
+
+#endif // IFXMIPS_PTM_FW_REGS_DANUBE_H
diff --git a/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_fw_regs_vdsl.h b/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_fw_regs_vdsl.h
new file mode 100644
index 0000000..e357197
--- /dev/null
+++ b/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_fw_regs_vdsl.h
@@ -0,0 +1,278 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_ptm_fw_regs_vdsl.h
+** PROJECT : UEIP
+** MODULES : PTM
+**
+** DATE : 7 Jul 2009
+** AUTHOR : Xu Liang
+** DESCRIPTION : PTM driver header file (firmware register for VDSL)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 07 JUL 2009 Xu Liang Init Version
+*******************************************************************************/
+
+
+
+#ifndef IFXMIPS_PTM_FW_REGS_VDSL_H
+#define IFXMIPS_PTM_FW_REGS_VDSL_H
+
+
+
+#if defined(CONFIG_DANUBE)
+ #error Danube is not VDSL PTM mode!
+#elif defined(CONFIG_AMAZON_SE)
+ #error Amazon-SE is not VDSL PTM mode!
+#elif defined(CONFIG_AR9)
+ #error AR9 is not VDSL PTM mode!
+#elif defined(CONFIG_VR9)
+ #include "ifxmips_ptm_fw_regs_vr9.h"
+#else
+ #error Platform is not specified!
+#endif
+
+
+
+/*
+ * MIB Table Maintained by Firmware
+ */
+
+struct wan_rx_mib_table {
+ unsigned int res1[2];
+ unsigned int wrx_dropdes_pdu;
+ unsigned int wrx_total_bytes;
+ unsigned int res2[4];
+ // wrx_total_pdu is implemented with hardware counter (not used by PTM TC)
+ // check register "TC_RX_MIB_CMD"
+ // "HEC_INC" used to increase preemption Gamma interface (wrx_total_pdu)
+ // "AIIDLE_INC" used to increase normal Gamma interface (wrx_total_pdu)
+};
+
+struct wan_tx_mib_table {
+ //unsigned int wtx_total_pdu; // version before 0.26
+ //unsigned int small_pkt_drop_cnt;
+ //unsigned int total_pkt_drop_cnt;
+ unsigned int wrx_total_pdu; // version 0.26 and onwards
+ unsigned int wrx_total_bytes;
+ unsigned int wtx_total_pdu;
+ unsigned int wtx_total_bytes;
+
+ unsigned int wtx_cpu_dropsmall_pdu;
+ unsigned int wtx_cpu_dropdes_pdu;
+ unsigned int wtx_fast_dropsmall_pdu;
+ unsigned int wtx_fast_dropdes_pdu;
+};
+
+
+/*
+ * Host-PPE Communication Data Structure
+ */
+
+#if defined(__BIG_ENDIAN)
+
+ struct fw_ver_id {
+ unsigned int family :4;
+ unsigned int fwtype :4;
+ unsigned int interface :4;
+ unsigned int fwmode :4;
+ unsigned int major :8;
+ unsigned int minor :8;
+ };
+
+ struct cfg_std_data_len {
+ unsigned int res1 :14;
+ unsigned int byte_off :2; // byte offset in RX DMA channel
+ unsigned int data_len :16; // data length for standard size packet buffer
+ };
+
+ struct tx_qos_cfg {
+ unsigned int time_tick :16; // number of PP32 cycles per basic time tick
+ unsigned int overhd_bytes :8; // number of overhead bytes per packet in rate shaping
+ unsigned int eth1_eg_qnum :4; // number of egress QoS queues (< 8);
+ unsigned int eth1_burst_chk :1; // always 1, more accurate WFQ
+ unsigned int eth1_qss :1; // 1: FW QoS, 0: HW QoS
+ unsigned int shape_en :1; // 1: enable rate shaping, 0: disable
+ unsigned int wfq_en :1; // 1: WFQ enabled, 0: strict priority enabled
+ };
+
+ struct psave_cfg {
+ unsigned int res1 :15;
+ unsigned int start_state :1; // 1: start from partial PPE reset, 0: start from full PPE reset
+ unsigned int res2 :15;
+ unsigned int sleep_en :1; // 1: enable sleep mode, 0: disable sleep mode
+ };
+
+ struct eg_bwctrl_cfg {
+ unsigned int fdesc_wm :16; // if free descriptors in QoS/Swap channel is less than this watermark, large size packets are discarded
+ unsigned int class_len :16; // if packet length is not less than this value, the packet is recognized as large packet
+ };
+
+ struct test_mode {
+ unsigned int res1 :30;
+ unsigned int mib_clear_mode :1; // 1: MIB counter is cleared with TPS-TC software reset, 0: MIB counter not cleared
+ unsigned int test_mode :1; // 1: test mode, 0: normal mode
+ };
+
+ struct gpio_mode {
+ unsigned int res1 :3;
+ unsigned int gpio_bit_bc1 :5;
+ unsigned int res2 :3;
+ unsigned int gpio_bit_bc0 :5;
+
+ unsigned int res3 :7;
+ unsigned int gpio_bc1_en :1;
+
+ unsigned int res4 :7;
+ unsigned int gpio_bc0_en :1;
+ };
+
+ struct gpio_wm_cfg {
+ unsigned int stop_wm_bc1 :8;
+ unsigned int start_wm_bc1 :8;
+ unsigned int stop_wm_bc0 :8;
+ unsigned int start_wm_bc0 :8;
+ };
+
+ struct rx_bc_cfg {
+ unsigned int res1 :14;
+ unsigned int local_state :2; // 0: local receiver is "Looking", 1: local receiver is "Freewheel Sync False", 2: local receiver is "Synced", 3: local receiver is "Freewheel Sync Truee"
+ unsigned int res2 :15;
+ unsigned int remote_state :1; // 0: remote receiver is "Out-of-Sync", 1: remote receiver is "Synced"
+ unsigned int to_false_th :16; // the number of consecutive "Miss Sync" for leaving "Freewheel Sync False" to "Looking" (default 3)
+ unsigned int to_looking_th :16; // the number of consecutive "Miss Sync" for leaving "Freewheel Sync True" to "Freewheel Sync False" (default 7)
+ unsigned int res_word[30];
+ };
+
+ struct rx_gamma_itf_cfg {
+ unsigned int res1 :31;
+ unsigned int receive_state :1; // 0: "Out-of-Fragment", 1: "In-Fragment"
+ unsigned int res2 :16;
+ unsigned int rx_min_len :8; // min length of packet, padding if packet length is smaller than this value
+ unsigned int rx_pad_en :1; // 0: padding disabled, 1: padding enabled
+ unsigned int res3 :2;
+ unsigned int rx_eth_fcs_ver_dis :1; // 0: ETH FCS verification is enabled, 1: disabled
+ unsigned int rx_rm_eth_fcs :1; // 0: ETH FCS field is not removed, 1: ETH FCS field is removed
+ unsigned int rx_tc_crc_ver_dis :1; // 0: TC CRC verification enabled, 1: disabled
+ unsigned int rx_tc_crc_size :2; // 0: 0-bit, 1: 16-bit, 2: 32-bit
+ unsigned int rx_eth_fcs_result; // if the ETH FCS result matches this magic number, then the packet is valid packet
+ unsigned int rx_tc_crc_result; // if the TC CRC result matches this magic number, then the packet is valid packet
+ unsigned int rx_crc_cfg :16; // TC CRC config, please check the description of SAR context data structure in the hardware spec
+ unsigned int res4 :16;
+ unsigned int rx_eth_fcs_init_value; // ETH FCS initialization value
+ unsigned int rx_tc_crc_init_value; // TC CRC initialization value
+ unsigned int res_word1;
+ unsigned int rx_max_len_sel :1; // 0: normal, the max length is given by MAX_LEN_NORMAL, 1: fragment, the max length is given by MAX_LEN_FRAG
+ unsigned int res5 :2;
+ unsigned int rx_edit_num2 :4; // number of bytes to be inserted/removed
+ unsigned int rx_edit_pos2 :7; // first byte position to be edited
+ unsigned int rx_edit_type2 :1; // 0: remove, 1: insert
+ unsigned int rx_edit_en2 :1; // 0: disable insertion or removal of data, 1: enable
+ unsigned int res6 :3;
+ unsigned int rx_edit_num1 :4; // number of bytes to be inserted/removed
+ unsigned int rx_edit_pos1 :7; // first byte position to be edited
+ unsigned int rx_edit_type1 :1; // 0: remove, 1: insert
+ unsigned int rx_edit_en1 :1; // 0: disable insertion or removal of data, 1: enable
+ unsigned int res_word2[2];
+ unsigned int rx_inserted_bytes_1l;
+ unsigned int rx_inserted_bytes_1h;
+ unsigned int rx_inserted_bytes_2l;
+ unsigned int rx_inserted_bytes_2h;
+ int rx_len_adj; // the packet length adjustment, it is sign integer
+ unsigned int res_word3[16];
+ };
+
+ struct tx_bc_cfg {
+ unsigned int fill_wm :16; // default 2
+ unsigned int uflw_wm :16; // default 2
+ unsigned int res_word[31];
+ };
+
+ struct tx_gamma_itf_cfg {
+ unsigned int res_word1;
+ unsigned int res1 :8;
+ unsigned int tx_len_adj :4; // 4 * (not TX_ETH_FCS_GEN_DIS) + TX_TC_CRC_SIZE
+ unsigned int tx_crc_off_adj :4; // 4 + TX_TC_CRC_SIZE
+ unsigned int tx_min_len :8; // min length of packet, if length is less than this value, packet is padded
+ unsigned int res2 :3;
+ unsigned int tx_eth_fcs_gen_dis :1; // 0: ETH FCS generation enabled, 1: disabled
+ unsigned int res3 :2;
+ unsigned int tx_tc_crc_size :2; // 0: 0-bit, 1: 16-bit, 2: 32-bit
+ unsigned int res4 :24;
+ unsigned int queue_mapping :8; // TX queue attached to this Gamma interface
+ unsigned int res_word2;
+ unsigned int tx_crc_cfg :16; // TC CRC config, please check the description of SAR context data structure in the hardware spec
+ unsigned int res5 :16;
+ unsigned int tx_eth_fcs_init_value; // ETH FCS initialization value
+ unsigned int tx_tc_crc_init_value; // TC CRC initialization value
+ unsigned int res_word3[25];
+ };
+
+ struct wtx_qos_q_desc_cfg {
+ unsigned int threshold :8;
+ unsigned int length :8;
+ unsigned int addr :16;
+ unsigned int rd_ptr :16;
+ unsigned int wr_ptr :16;
+ };
+
+ struct wtx_eg_q_shaping_cfg {
+ unsigned int t :8;
+ unsigned int w :24;
+ unsigned int s :16;
+ unsigned int r :16;
+ unsigned int res1 :8;
+ unsigned int d :24; // ppe internal variable
+ unsigned int res2 :8;
+ unsigned int tick_cnt :8; // ppe internal variable
+ unsigned int b :16; // ppe internal variable
+ };
+
+ /* DMA descriptor */
+ struct rx_descriptor {
+ /* 0 - 3h */
+ unsigned int own :1; // 0: Central DMA TX or MIPS, 1: PPE
+ unsigned int c :1; // PPE tells current descriptor is complete
+ unsigned int sop :1;
+ unsigned int eop :1;
+ unsigned int res1 :3;
+ unsigned int byteoff :2;
+ unsigned int res2 :7;
+ unsigned int datalen :16;
+ /* 4 - 7h */
+ unsigned int res3 :4;
+ unsigned int dataptr :28; // byte address
+ };
+
+ struct tx_descriptor {
+ /* 0 - 3h */
+ unsigned int own :1; // CPU path - 0: MIPS, 1: PPE Dispatcher, Fastpath - 0: PPE Dispatcher, 1: Central DMA, QoS Queue - 0: PPE Dispatcher, 1: PPE DMA, SWAP Channel - 0: MIPS, 1: PPE Dispatcher
+ unsigned int c :1; // MIPS or central DMA tells PPE the current descriptor is complete
+ unsigned int sop :1;
+ unsigned int eop :1;
+ unsigned int byteoff :5;
+ unsigned int qid :4; // TX Queue ID, bit 3 is reserved
+ unsigned int res1 :3;
+ unsigned int datalen :16;
+ /* 4 - 7h */
+ unsigned int small :1; // 0: standard size, 1: less than standard size
+ unsigned int res2 :3;
+ unsigned int dataptr :28; // byte address
+ };
+
+#else /* defined(__BIG_ENDIAN) */
+ #error structures are defined in big endian
+#endif /* defined(__BIG_ENDIAN) */
+
+
+
+#endif // IFXMIPS_PTM_FW_REGS_VDSL_H
+
diff --git a/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_fw_regs_vr9.h b/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_fw_regs_vr9.h
new file mode 100644
index 0000000..a640cfb
--- /dev/null
+++ b/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_fw_regs_vr9.h
@@ -0,0 +1,90 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_ptm_fw_regs_vr9.h
+** PROJECT : UEIP
+** MODULES : PTM
+**
+** DATE : 7 Jul 2009
+** AUTHOR : Xu Liang
+** DESCRIPTION : PTM driver header file (firmware register for VR9)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 07 JUL 2009 Xu Liang Init Version
+*******************************************************************************/
+
+
+
+#ifndef IFXMIPS_PTM_FW_REGS_VR9_H
+#define IFXMIPS_PTM_FW_REGS_VR9_H
+
+
+
+/*
+ * Host-PPE Communication Data Address Mapping
+ */
+#define FW_VER_ID ((volatile struct fw_ver_id *) SB_BUFFER(0x2001))
+#define CFG_STD_DATA_LEN ((volatile struct cfg_std_data_len *) SB_BUFFER(0x2011))
+#define TX_QOS_CFG ((volatile struct tx_qos_cfg *) SB_BUFFER(0x2012))
+#define EG_BWCTRL_CFG ((volatile struct eg_bwctrl_cfg *) SB_BUFFER(0x2013))
+#define PSAVE_CFG ((volatile struct psave_cfg *) SB_BUFFER(0x2014))
+#define GPIO_ADDR SB_BUFFER(0x2019)
+#define GPIO_MODE ((volatile struct gpio_mode *) SB_BUFFER(0x201C))
+#define GPIO_WM_CFG ((volatile struct gpio_wm_cfg *) SB_BUFFER(0x201D))
+#define TEST_MODE ((volatile struct test_mode *) SB_BUFFER(0x201F))
+#define WTX_QOS_Q_DESC_CFG(i) ((volatile struct wtx_qos_q_desc_cfg *) SB_BUFFER(0x2FF0 + (i) * 2)) /* i < 8 */
+#define WTX_EG_Q_PORT_SHAPING_CFG(i) ((volatile struct wtx_eg_q_shaping_cfg *) SB_BUFFER(0x2680 + (i) * 4)) /* i < 1 */
+#define WTX_EG_Q_SHAPING_CFG(i) ((volatile struct wtx_eg_q_shaping_cfg *) SB_BUFFER(0x2684 + (i) * 4)) /* i < 8 */
+#define TX_QUEUE_CFG(i) WTX_EG_Q_PORT_SHAPING_CFG(i) // i < 9
+#define RX_BC_CFG(i) ((volatile struct rx_bc_cfg *) SB_BUFFER(0x3E80 + (i) * 0x20)) // i < 2
+#define TX_BC_CFG(i) ((volatile struct tx_bc_cfg *) SB_BUFFER(0x3EC0 + (i) * 0x20)) // i < 2
+#define RX_GAMMA_ITF_CFG(i) ((volatile struct rx_gamma_itf_cfg *) SB_BUFFER(0x3D80 + (i) * 0x20)) // i < 4
+#define TX_GAMMA_ITF_CFG(i) ((volatile struct tx_gamma_itf_cfg *) SB_BUFFER(0x3E00 + (i) * 0x20)) // i < 4
+#define WAN_RX_MIB_TABLE(i) ((volatile struct wan_rx_mib_table *) SB_BUFFER(0x5B00 + (i) * 8)) // i < 4
+#define WAN_TX_MIB_TABLE(i) ((volatile struct wan_tx_mib_table *) SB_BUFFER(0x5B20 + (i) * 8)) // i < 8
+#define TX_CTRL_K_TABLE(i) SB_BUFFER(0x47F0 + (i)) // i < 16
+// following MIB for debugging purpose
+#define RECEIVE_NON_IDLE_CELL_CNT(i) SB_BUFFER(5020 + (i))
+#define RECEIVE_IDLE_CELL_CNT(i) SB_BUFFER(5022 + (i))
+#define TRANSMIT_CELL_CNT(i) SB_BUFFER(5024 + (i))
+#define FP_RECEIVE_PKT_CNT SB_BUFFER(5026)
+
+#define UTP_CFG SB_BUFFER(0x2018) // bit 0~3 - 0x0F: in showtime, 0x00: not in showtime
+
+/*
+ * Descriptor Base Address
+ */
+#define CPU_TO_WAN_TX_DESC_BASE ((volatile struct tx_descriptor *)SB_BUFFER(0x3D00))
+#define __ETH_WAN_TX_QUEUE_NUM g_wanqos_en
+#define __ETH_WAN_TX_QUEUE_LEN ((WAN_TX_DESC_NUM_TOTAL / __ETH_WAN_TX_QUEUE_NUM) < 256 ? (WAN_TX_DESC_NUM_TOTAL / __ETH_WAN_TX_QUEUE_NUM) : 255)
+#define __ETH_WAN_TX_DESC_BASE(i) (0x5C00 + (i) * 2 * __ETH_WAN_TX_QUEUE_LEN)
+#define WAN_TX_DESC_BASE(i) ((volatile struct tx_descriptor *)SB_BUFFER(__ETH_WAN_TX_DESC_BASE(i))) // i < __ETH_WAN_TX_QUEUE_NUM, __ETH_WAN_TX_QUEUE_LEN each queue
+#define WAN_SWAP_DESC_BASE ((volatile struct tx_descriptor *)SB_BUFFER(0x2E80))
+#define FASTPATH_TO_WAN_TX_DESC_BASE ((volatile struct tx_descriptor *)SB_BUFFER(0x2580))
+#define DMA_RX_CH1_DESC_BASE FASTPATH_TO_WAN_TX_DESC_BASE
+#define WAN_RX_DESC_BASE ((volatile struct rx_descriptor *)SB_BUFFER(0x2600))
+#define DMA_TX_CH1_DESC_BASE WAN_RX_DESC_BASE
+
+/*
+ * Descriptor Number
+ */
+#define CPU_TO_WAN_TX_DESC_NUM 64
+#define WAN_TX_DESC_NUM __ETH_WAN_TX_QUEUE_LEN
+#define WAN_SWAP_DESC_NUM 64
+#define WAN_TX_DESC_NUM_TOTAL 512
+#define FASTPATH_TO_WAN_TX_DESC_NUM 64
+#define DMA_RX_CH1_DESC_NUM FASTPATH_TO_WAN_TX_DESC_NUM
+#define WAN_RX_DESC_NUM 64
+#define DMA_TX_CH1_DESC_NUM WAN_RX_DESC_NUM
+
+
+
+#endif // IFXMIPS_PTM_FW_REGS_VR9_H
diff --git a/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_fw_vr9.h b/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_fw_vr9.h
new file mode 100644
index 0000000..c9f0893
--- /dev/null
+++ b/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_fw_vr9.h
@@ -0,0 +1,380 @@
+#ifndef IFXMIPS_PTM_FW_VR9_H
+#define IFXMIPS_PTM_FW_VR9_H
+
+
+/******************************************************************************
+**
+** FILE NAME : ifxmips_ptm_fw_vr9.h
+** PROJECT : UEIP
+** MODULES : PTM (VDSL)
+**
+** DATE : 22 OCT 2007
+** AUTHOR : Xu Liang
+** DESCRIPTION : PTM Driver (PP32 Firmware)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 22 OCT 2007 Xu Liang Initiate Version, v00.01
+*******************************************************************************/
+
+
+#define PTM_FW_VER_MAJOR 0
+#define PTM_FW_VER_MINOR 30
+
+
+static unsigned int firmware_binary_code[] = {
+ 0x80000980, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8000ffe0, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xc1c20002, 0xd9cc00f8, 0xc0006950, 0xcbc000f8, 0xc0004024, 0xc8c000f8, 0xc0006950, 0x5bfc0002,
+ 0xcfc000f8, 0xa4c252a2, 0x00000000, 0x00000000, 0x800007a0, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x94000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xc0e1fffe, 0x58cdfffe, 0xc1e1fffa, 0x59ddfffe, 0x94000001, 0x00000000, 0x00000000, 0x00000000,
+ 0xc0e1fffe, 0x58cdfffe, 0xc1e1fffa, 0x59ddfffe, 0x900009a1, 0x00000000, 0x00000000, 0x00000000,
+ 0x90cc0941, 0x00000000, 0x00000000, 0x00000000, 0xc3e0e2a2, 0x5bfc003c, 0xc0004002, 0xcfc000f8,
+ 0xc3c00000, 0xc0004024, 0xcbc20078, 0x00000000, 0x00000000, 0xc1c00000, 0xd9c400f9, 0xdbc40078,
+ 0xc1c00006, 0xd9c400f9, 0xc3c0fc10, 0xc0006952, 0xcfc000f8, 0xc3c00000, 0xc3400000, 0xc3000040,
+ 0xc2c00080, 0x6ff8a000, 0x5bb87d00, 0x5838001c, 0xcf4000f8, 0x5838001e, 0xcec000f8, 0x58380020,
+ 0xcf4000f8, 0x58380022, 0xcf0000f8, 0x5bfc0002, 0x5ebc0004, 0x8400ffa0, 0x00000000, 0xc1e1fffe,
+ 0x59ddfffa, 0x141c0000, 0xc1c00000, 0xc000691c, 0xcdc000f8, 0xab64002a, 0xc3c00000, 0xab66001a,
+ 0xc3c00002, 0x80001130, 0xc1c00002, 0xc000691c, 0xcdc000f8, 0x6ff8a000, 0x5bb87d00, 0x58380004,
+ 0xcb4000f8, 0xc2800000, 0x58380000, 0xca820008, 0xc000e824, 0xc3000000, 0xcb3c0070, 0x6f5c8000,
+ 0x41f4e000, 0x431d8000, 0x5b304000, 0xc000e828, 0xc1c00000, 0xc9fc0070, 0x00000000, 0xc0004000,
+ 0x41f4e000, 0x401c0000, 0xcac000f8, 0x5de80004, 0x84000880, 0xa6c607ea, 0x00000000, 0x6fe42000,
+ 0xc6e4a000, 0x6e60a000, 0x5a207b00, 0xc1800000, 0x58200000, 0xc9800000, 0xc2800000, 0xc6e80010,
+ 0x5dd80000, 0x8400003a, 0x5de80008, 0xc6a82012, 0xc1c00004, 0x45e8e000, 0x88000030, 0x80000558,
+ 0x5de80004, 0xc6a8010a, 0x5de80008, 0x84000538, 0x58380000, 0xc1c00002, 0xcdc00000, 0x58200000,
+ 0xc1c00002, 0xcdc00000, 0x5de80002, 0xcdc00002, 0xc000ea14, 0xc1e20000, 0xcdfe3100, 0xc000fb60,
+ 0xc1c00002, 0xcdfc0000, 0xc0006940, 0xc9c000f8, 0x403c0000, 0x00000000, 0x59dc0002, 0xcdc000f8,
+ 0xc1c00004, 0x45e8e000, 0x880000fa, 0x58200020, 0xc9c000f8, 0xc0c00018, 0xc1000000, 0xa5c0002a,
+ 0xc1400080, 0x5de80000, 0xc6ccf930, 0xc54c1932, 0x5de80000, 0xc1c0000a, 0xc5cc1230, 0xc5cc3202,
+ 0x58200022, 0xc9c000f8, 0xc74c0b30, 0xc7cc0008, 0xc5cc0528, 0xc1800000, 0xc6982000, 0xc1c00000,
+ 0xc69c0000, 0x71d8e000, 0xc5cc0400, 0x98404c78, 0xc5d00000, 0x7d80e000, 0xc5d00100, 0x5dd80002,
+ 0x84000388, 0xc1c00000, 0xc6ddc030, 0x59dc0006, 0xc5ec0e30, 0xc0c00018, 0xc1000004, 0x59dc0002,
+ 0xc5cc1230, 0xc74c0b30, 0xc7cc0008, 0xc0000088, 0x441ce000, 0xc5cc1930, 0xa6cc02b0, 0xc1c80002,
+ 0x70dc6000, 0xc1400000, 0xc6d5c030, 0x5d540002, 0x6d5c4010, 0x431c0000, 0xc88000f8, 0xc1c00000,
+ 0xc55c0008, 0xc0000006, 0x441ce000, 0x6ddc6000, 0x689c4010, 0xc1c001fe, 0x749c4000, 0x59540002,
+ 0xc1c000fe, 0x749c4000, 0x5c880020, 0xc48c1930, 0x4148c000, 0x59980002, 0x5dd80088, 0x8800002a,
+ 0x58200000, 0xc1c00000, 0xcdc00000, 0x800000c8, 0xc1400000, 0x6d9c4010, 0x431c0000, 0xc94000f8,
+ 0xc1c00000, 0xc59c0008, 0xc0000006, 0x441ce000, 0x6ddc6000, 0x695ca010, 0xc1c001fe, 0x755ca000,
+ 0x00000000, 0x00000000, 0x5dd40000, 0x84000018, 0x59980002, 0x8000ff48, 0x59980002, 0xc0800002,
+ 0x5dd400a0, 0xc4902100, 0xc4ac2602, 0x4588c002, 0xdbc800f9, 0xda4800f8, 0xda1000f9, 0x90404391,
+ 0x58200020, 0xc9c000f8, 0x58200022, 0xc94000f8, 0x5ddc0002, 0xc1c00000, 0xc5cc1932, 0xc6ddc030,
+ 0x59dc0002, 0x98404c78, 0xc5cc1230, 0xc54c0528, 0xc4d08000, 0xa5020072, 0xc1c00002, 0xc5d00100,
+ 0xc5ac0e30, 0xa6ccfdc2, 0xc1c00000, 0xc5cc0400, 0xc1c00086, 0x45d8e000, 0xc5cc1930, 0x8000ff28,
+ 0x00000000, 0x00000000, 0x00000000, 0x80000070, 0xdbc800f9, 0xda4800f8, 0xda1000f9, 0x90404391,
+ 0x58200022, 0xc98000f8, 0x58200020, 0xc9c000f8, 0x00000000, 0x98404c78, 0x5ddc0002, 0xc58c0528,
+ 0xc5cc1932, 0x80000200, 0xc1400000, 0xc000403e, 0xc9400000, 0xc1800000, 0x58200000, 0xc9800000,
+ 0x5dd40002, 0x84000020, 0x5dd80002, 0x84000010, 0x80000110, 0x5de80006, 0x84000088, 0x58380000,
+ 0xc1c00002, 0xcdc00000, 0xc000ea14, 0xc1e20000, 0xcdfe3100, 0xc000fb60, 0xc1c20002, 0xcdfc2100,
+ 0xc0006944, 0xc9c000f8, 0x403c0000, 0x00000000, 0x59dc0002, 0xcdc000f8, 0x800000f0, 0x5de8000a,
+ 0x84000070, 0x58380000, 0xc1c00000, 0xcdc00000, 0xc000ea14, 0xc1e20002, 0xcdfe3100, 0xc000fb60,
+ 0xc1c20002, 0xcdfc2100, 0xc000facc, 0xc1c00002, 0xcdfc0000, 0x80000078, 0xa6ca0040, 0xc000facc,
+ 0xc1ca0002, 0xcdfca500, 0xc000fb64, 0xc1c60002, 0xcdfc6300, 0x80000038, 0xc000facc, 0xc1c80002,
+ 0xcdfc8400, 0xc000fb64, 0xc1c40002, 0xcdfc4200, 0xc0c00010, 0x98404c78, 0xc7cc0008, 0xc74c0b30,
+ 0xc1000004, 0x80000808, 0xc1c00002, 0x58380008, 0xcdc000f8, 0x58380000, 0xc1e00006, 0xcdc21008,
+ 0xc000facc, 0xc1c80002, 0xcdfc8400, 0xc000fb64, 0xc1c40002, 0xcdfc4200, 0xc0c00010, 0x98404c78,
+ 0xc7cc0008, 0xc74c0b30, 0xc1000004, 0x80000778, 0x5de80006, 0x84000170, 0xa6c60032, 0x00000000,
+ 0x58380000, 0xc1e00004, 0xcdc21008, 0x8000f760, 0x58380008, 0xca8000f8, 0xc2400000, 0x58380002,
+ 0xca420078, 0x00000000, 0x5aa80002, 0x58380008, 0xce8000f8, 0x46a4e000, 0x8800008a, 0x58380000,
+ 0xc1e00002, 0xcdc21008, 0x58380000, 0xc1c00000, 0xcdc00000, 0xc000facc, 0xc1c20002, 0xcdfc2100,
+ 0xc1e1e1a2, 0xc000ea1c, 0xcdfc00f8, 0xc000ea14, 0xc1e20002, 0xcdfe3100, 0x80000038, 0xc000facc,
+ 0xc1c80002, 0xcdfc8400, 0xc000fb64, 0xc1c40002, 0xcdfc4200, 0xc0c00010, 0x98404c78, 0xc7cc0008,
+ 0xc74c0b30, 0xc1000004, 0x80000600, 0x5de80002, 0x84000150, 0xa6c6004a, 0x00000000, 0x58380000,
+ 0xc1e00004, 0xcdc21008, 0xc1f8001e, 0xc000ea1c, 0xcdfc00f8, 0x8000f5d0, 0x58380008, 0xca8000f8,
+ 0xc2400000, 0x58380002, 0xca400078, 0xc000facc, 0xc1c20002, 0xcdfc2100, 0x5aa80002, 0x58380008,
+ 0xce8000f8, 0x46a4e000, 0x88000072, 0x58380000, 0xc1e00000, 0xcdc21008, 0xc1c00000, 0x58380006,
+ 0xcdc000f8, 0xc000e82c, 0xc1c00000, 0xcdfdce00, 0xc000e820, 0xc1c00000, 0xcdfc0000, 0x80000300,
+ 0xc0c00010, 0x98404c78, 0xc7cc0008, 0xc74c0b30, 0xc1000004, 0x800004a8, 0x5838001c, 0xca8000f8,
+ 0x5838001e, 0xca4000f8, 0x5aa80002, 0x5838001c, 0xce8000f8, 0x4668e000, 0x88000098, 0x58380022,
+ 0xca4000f8, 0x58380020, 0xca0000f8, 0xc000e82c, 0xc1c00000, 0xcdfdce00, 0xc000e810, 0xce7c0030,
+ 0xc2800000, 0x5838001c, 0xce8000f8, 0x5a200002, 0x58380020, 0xce0000f8, 0xc000e82c, 0xc1dc0002,
+ 0xcdfdce00, 0x58380006, 0xc8c000f8, 0x5830001c, 0xca8000f9, 0xca4000f9, 0xc2000000, 0xca000001,
+ 0x5dcc0006, 0x88000028, 0x58cc0002, 0x58380006, 0xccc000f8, 0x80000250, 0x5838000a, 0xc8c000f9,
+ 0xc90000f9, 0xc1400000, 0xc9400001, 0x74e86000, 0x75248000, 0x7560a000, 0x58380010, 0xca8000f9,
+ 0xca4000f9, 0xc2000000, 0xca000001, 0x98404de8, 0x74e86000, 0x75248000, 0x7560a000, 0x5dc800a0,
+ 0x840001ba, 0x58380016, 0xca8000f9, 0xca4000f9, 0xc2000000, 0xca000001, 0x98404de8, 0x74e86000,
+ 0x75248000, 0x7560a000, 0x5dc800a0, 0x84000162, 0x58380000, 0xc1e00004, 0xcdc21008, 0x5838001c,
+ 0xc1c00000, 0xcdc000f8, 0xc000e82c, 0xc1c00000, 0xcdfdce00, 0xc1f8001e, 0xc000ea1c, 0xcdfc00f8,
+ 0xc000e820, 0xc1c00002, 0xcdfc0000, 0xc1c00082, 0x45c8e000, 0xc000e810, 0xcdfc0030, 0xc2400000,
+ 0xc000e82c, 0xca7c0038, 0xc000e83c, 0xc2800000, 0xcabc0038, 0xc0c00010, 0x98404c78, 0xc7cc0008,
+ 0xc74c0b30, 0xc1000004, 0x5b740002, 0x4674e000, 0xc1c00000, 0xc5f400fe, 0x5ea80002, 0x8400ffb0,
+ 0xc000e83c, 0xc1c00000, 0xcdfc0038, 0xc000e82c, 0xc1dc0002, 0xcdfdce00, 0x80000178, 0x58380010,
+ 0xca8000f9, 0xca4000f9, 0xc2000000, 0xca000001, 0x58380016, 0xce8000f9, 0xce4000f9, 0xce000001,
+ 0x5838000a, 0xca8000f9, 0xca4000f9, 0xc2000000, 0xca000001, 0x58380010, 0xce8000f9, 0xce4000f9,
+ 0xce000001, 0x5830001c, 0xca8000f9, 0xca4000f9, 0xc2000000, 0xca000001, 0x5838000a, 0xce8000f9,
+ 0xce4000f9, 0xce000001, 0xc000facc, 0xc1c20002, 0xcdfc2100, 0xc0c00010, 0x98404c78, 0xc7cc0008,
+ 0xc74c0b30, 0xc1000004, 0xc000e83c, 0xc1d00002, 0xcdfd0800, 0xc0c00000, 0xc000e82c, 0xc8fc0038,
+ 0x5b740002, 0x00000000, 0x44f4e000, 0xc1c00000, 0xc5f400fe, 0x58380004, 0xcf4000f8, 0x98404ec0,
+ 0x00000000, 0x00000000, 0x00000000, 0xc0006914, 0xcbc000f8, 0xc2800000, 0xc2400000, 0x5bfc4b00,
+ 0xc7c000f8, 0xcb0000f8, 0x58000002, 0xcac000f8, 0xc0004026, 0xca800078, 0xc0004026, 0xca420078,
+ 0xc3400000, 0xc7366018, 0xa73e0172, 0x00000000, 0xc777e300, 0xc000694c, 0xc9c000f8, 0x00000000,
+ 0x00000000, 0x59dc0002, 0xcdc000f8, 0x6f5c6000, 0x58dcb640, 0x580c0000, 0xc90000f8, 0x580c0002,
+ 0xc94000f8, 0x59100002, 0x580c0000, 0xcd0000f8, 0xc1c00000, 0xc71c0078, 0x415ca000, 0x580c0002,
+ 0xcd4000f8, 0x98402008, 0x5834fc10, 0xc8c000f8, 0xc1000000, 0x5dc80000, 0x84000070, 0x6f402000,
+ 0x58005fe0, 0xc3800000, 0x58000000, 0xcb800078, 0xc1c00000, 0x58000002, 0xc9c00078, 0x984022c0,
+ 0x00000000, 0x439dc000, 0x00000000, 0x80000028, 0x98402098, 0xc48c00f8, 0x00000000, 0x00000000,
+ 0xc0006916, 0xcbc000f8, 0xc3400000, 0x00000000, 0x5bfc7a00, 0xc7c000f8, 0xcb0000f8, 0x58000002,
+ 0xcac000f8, 0xc7366018, 0xa73e0900, 0x00000000, 0xc777e300, 0xc000694e, 0xc9c000f8, 0x00000000,
+ 0x00000000, 0x59dc0002, 0xcdc000f8, 0x6f5c6000, 0x58dcb640, 0x580c0000, 0xc90000f8, 0x580c0002,
+ 0xc94000f8, 0x59100002, 0x580c0000, 0xcd0000f8, 0xc1c00000, 0xc71c0078, 0x415ca000, 0x580c0002,
+ 0xcd4000f8, 0x98402008, 0x5834fc10, 0xc8c000f8, 0xc1000000, 0x5dc80000, 0x84000070, 0x6f402000,
+ 0x58005fe0, 0xc3800000, 0x58000000, 0xcb800078, 0xc1c00000, 0x58000002, 0xc9c00078, 0x984025d0,
+ 0x00000000, 0x439dc000, 0x00000000, 0x800007b8, 0x984021c0, 0xc48c00f8, 0x00000000, 0x00000000,
+ 0x80000790, 0xc7100078, 0xc0800000, 0x6f402000, 0x58005fe0, 0xc1400000, 0x58000000, 0xc9420038,
+ 0x4690e000, 0x88000030, 0x454ca000, 0x9c400000, 0x4564e000, 0xc1c00004, 0xc5c800fe, 0x9c400000,
+ 0x454ce000, 0xc1c00002, 0xc5c800fe, 0xc0006914, 0xc90000f8, 0xc1400000, 0xc0004022, 0xc9400078,
+ 0x583c0000, 0xc1fc0000, 0xcdc3de00, 0x583c0000, 0xcd400078, 0x583c0000, 0xc1fe0002, 0xcdc3ff00,
+ 0x59100004, 0xc1c00100, 0x45d0e000, 0xc1c00000, 0xc5d000fe, 0xc0006914, 0xcd0000f8, 0x6f546000,
+ 0x5954b640, 0x5dcc0002, 0x84000038, 0x5814000c, 0xc9c000f8, 0x00000000, 0x00000000, 0x59dc0002,
+ 0xcdc000f8, 0x5814000e, 0xc9c000f8, 0x00000000, 0x9c400000, 0x59dc0002, 0xcdc000f8, 0x00000000,
+ 0xc0006916, 0xc90000f8, 0x583c0000, 0xc1fc0000, 0xcdc3de00, 0x583c0000, 0xc1fe0000, 0xcdc3ff00,
+ 0x59100004, 0xc1c00100, 0x45d0e000, 0xc1c00000, 0xc5d000fe, 0xc0006916, 0xcd0000f8, 0x6f546000,
+ 0x5954b640, 0x5dcc0002, 0x84000038, 0x58140008, 0xc9c000f8, 0x00000000, 0x00000000, 0x59dc0002,
+ 0xcdc000f8, 0x5814000a, 0xc9c000f8, 0x00000000, 0x9c400000, 0x59dc0002, 0xcdc000f8, 0x00000000,
+ 0x58380002, 0xc90000f8, 0x5c000002, 0xc8c000f8, 0xa53e0178, 0xc0006918, 0xca0000f8, 0x00000000,
+ 0x00000000, 0x5a205d00, 0xc60000f8, 0xc94000f8, 0x58000002, 0xc98000f8, 0xa57e006a, 0xc1c00000,
+ 0xc0c00004, 0xc71c0078, 0xc46000f8, 0x98402098, 0x45e8e000, 0xc1c00002, 0xc5cc00fe, 0x9e000000,
+ 0xc1e00002, 0xc000e408, 0xcdc21000, 0xc55c00f8, 0xc4d400f8, 0xc5cc00f8, 0xc59c00f8, 0xc51800f8,
+ 0xc5d000f8, 0xc1c00000, 0xc5d41f00, 0xc5d3ff00, 0x58200002, 0xcd8000f8, 0x5c000002, 0xcd4000f8,
+ 0x5e205d00, 0x5a200004, 0xc1c00100, 0x45e0e000, 0xc1c00000, 0xc5e000fe, 0xc0006918, 0xce0000f8,
+ 0xc1e00002, 0xc000e408, 0xcdc21000, 0xc6dc00f8, 0xc52c00f8, 0xc5d000f8, 0xc71c00f8, 0xc4f000f8,
+ 0xc5cc00f8, 0xc0004022, 0xcb000078, 0xc1c00002, 0xc5cc1f00, 0xc5f01f00, 0xc5f3fe00, 0x58380002,
+ 0xcd0000f8, 0x5c000002, 0xccc000f8, 0x6f402000, 0x58005fe0, 0xc1c00000, 0xc9c20138, 0xc2000000,
+ 0x58000002, 0xca000078, 0x00000000, 0x00000000, 0x5a200004, 0x45e0e000, 0xc1c00000, 0xc5e000fe,
+ 0xce000078, 0x5e3c4b00, 0x5a200004, 0xc1c00100, 0x45e0e000, 0xc1c00000, 0xc5e000fe, 0xc0006914,
+ 0xce0000f8, 0xc1c00002, 0x69f4e000, 0xc5dc0838, 0xd9f000f8, 0x583c0002, 0xcec000f8, 0x5c000002,
+ 0xcf0000f8, 0x9c400000, 0x58380002, 0xc90000f8, 0x5c000002, 0xc8c000f8, 0xc6dc00f8, 0xc52c00f8,
+ 0xc5d000f8, 0xc71c00f8, 0xc4f000f8, 0xc5cc00f8, 0xc1c00002, 0xc5cc1f00, 0xc1c00000, 0xc5f01f00,
+ 0xc5f3fe00, 0x58380002, 0xcd0000f8, 0x5c000002, 0xccc000f8, 0x6f402000, 0x58005fe0, 0xc1c00000,
+ 0xc9c20138, 0xc2000000, 0x58000002, 0xca000078, 0x00000000, 0x00000000, 0x5a200004, 0x45e0e000,
+ 0xc1c00000, 0xc5e000fe, 0xce000078, 0x5e3c7a00, 0x5a200004, 0xc1c00100, 0x45e0e000, 0xc1c00000,
+ 0xc5e000fe, 0xc0006916, 0xce0000f8, 0xc1c00002, 0x69f4e000, 0xc5dc0838, 0xd9f000f8, 0x583c0002,
+ 0xcec000f8, 0x5c000002, 0xcf0000f8, 0xc1e20002, 0xc000e408, 0xcdc23100, 0x9c400000, 0x00000000,
+ 0x00000000, 0x00000000, 0xc3c00000, 0x6ff8a000, 0x5bb87d80, 0x583cfb50, 0xc2800000, 0xca80c030,
+ 0xc2400000, 0x58380000, 0xca400078, 0x58380006, 0xca0000f8, 0x583cea28, 0xc9c000f8, 0xc0c00000,
+ 0x00000000, 0xc5cc0038, 0x420c8000, 0x4268a000, 0x4514e000, 0x880000aa, 0x58380004, 0xca4000f8,
+ 0xc000ea28, 0x6e1d2000, 0xcdfd2928, 0xc000ea28, 0xc1d00002, 0xcdfd0800, 0xc0006948, 0xc9c000f8,
+ 0x403c0000, 0x00000000, 0x41e0e000, 0xcdc000f8, 0x46612000, 0x58380004, 0xce4000f8, 0x58380006,
+ 0xc1c00000, 0xcdc000f8, 0x58380004, 0xca4000f8, 0x583cea28, 0xc9c000f8, 0xc0c00000, 0x00000000,
+ 0xc5cc0038, 0xc1400000, 0x58380000, 0xc9420078, 0x424d0000, 0x00000000, 0x42948000, 0x4520e000,
+ 0x8800163a, 0xc000fa40, 0xc9bc00f8, 0x6ff42000, 0xc3000000, 0xc5b4e000, 0xc2c07c00, 0x6f5ca000,
+ 0x42dd6000, 0x582c0022, 0xc98000f8, 0x00000000, 0x00000000, 0x5dd80000, 0x840003c2, 0x582c0026,
+ 0xca8000f8, 0x5838000a, 0xc98000f8, 0xc000ea10, 0xc2400000, 0xca7c0070, 0x6d9c8000, 0x41d8e000,
+ 0x425d2000, 0x5a644000, 0x582c002e, 0xc98000f8, 0x582c0030, 0xc94000f8, 0x00000000, 0x00000000,
+ 0x4194e000, 0xd9f800f8, 0x5ddc0080, 0x880000a2, 0x00000000, 0xa7400018, 0xc180001e, 0xc180015e,
+ 0xc1400000, 0x6d5c4010, 0x425c0000, 0xc1c00006, 0x755c8000, 0x5dd00000, 0xcd80183a, 0x5dd00002,
+ 0xcd80103a, 0x5dd00004, 0xcd80083a, 0x5dd00006, 0xcd80003a, 0x5b300008, 0x80000278, 0x58240002,
+ 0xc1800000, 0xcd8000f9, 0xcd8000f9, 0xcd8000f9, 0xcd8000f9, 0xcd8000f9, 0xcd8000f9, 0xcd8000f9,
+ 0xcd8000f9, 0xcd8000f9, 0xcd8000f9, 0xcd8000f9, 0xcd8000f9, 0xcd8000f9, 0xcd8000f9, 0xcd8000f9,
+ 0xcd8000f9, 0xa7400018, 0xc18001e0, 0xc18001ea, 0xc1400000, 0x6d5c4010, 0x425c0000, 0xc90000f8,
+ 0xc1c00000, 0xc55c0308, 0x691c8008, 0xc5901838, 0x691c8018, 0xcd0000f8, 0x6d5c4010, 0x425c0000,
+ 0xc1c00006, 0x755c8000, 0x5dd00000, 0xcd80183a, 0x5dd00002, 0xcd80103a, 0x5dd00004, 0xcd80083a,
+ 0x5dd00006, 0xcd80003a, 0x5b300008, 0xdf9400f8, 0xc1008fe0, 0x6d5c4010, 0x411c0000, 0xc98000f8,
+ 0xc1c00000, 0xc55c0308, 0x699cc000, 0x6d9b0010, 0x6f1c4010, 0x425c0000, 0xc94000f8, 0xc1c00000,
+ 0xc71c0308, 0x695ca008, 0xc5941838, 0x695ca018, 0xcd4000f8, 0x6f1c4010, 0x425c0000, 0xc1c00006,
+ 0x771ca000, 0x5dd40000, 0xcd80183a, 0x5dd40002, 0xcd80103a, 0x5dd40004, 0xcd80083a, 0x5dd40006,
+ 0xcd80003a, 0x5b300002, 0x582c0022, 0xc1c00000, 0xcdc000f8, 0x80000e18, 0xdb8800f9, 0xdb4800f8,
+ 0xc2400000, 0xdf240038, 0xc0004024, 0xcb8000f8, 0x00000000, 0xc3400000, 0xc7b50038, 0xc2800000,
+ 0xc7a88018, 0xc000fa40, 0xc8fc00f8, 0xc2800000, 0x582c0004, 0xca800038, 0xa4ce0042, 0x58ec0040,
+ 0xc1c00000, 0x580c0004, 0xc9c00038, 0x00000000, 0x00000000, 0x729d4000, 0x7e412000, 0x76692000,
+ 0xc0400000, 0xc7840008, 0xc000a0ae, 0x5de40000, 0x84000070, 0xc0c00000, 0xc8c000f8, 0x5dc40000,
+ 0xdcb800fb, 0xdcb400fa, 0x84000ffa, 0x5dcc0000, 0xdcb800fb, 0xdcb400fa, 0x84000fda, 0xc0c00000,
+ 0xccc000f8, 0x800001b8, 0xc0c00002, 0xccc000f8, 0xc65000f8, 0x61010028, 0x5dc40000, 0x84000018,
+ 0x62410008, 0x800002e8, 0x6e144000, 0x59544d08, 0xc0400000, 0x58140004, 0xc84000b8, 0xa78200d0,
+ 0xc0800000, 0xc1c00000, 0x6e1c2000, 0x59dc5fe0, 0x581c0002, 0xc8820078, 0x581c0000, 0xc9c00078,
+ 0xc1800000, 0x58140006, 0xc9800078, 0x409ce000, 0xc0800000, 0x581c0000, 0xc8800078, 0x00000000,
+ 0x00000000, 0x40b44000, 0x4588e000, 0x88000030, 0xc1c00002, 0x69e0e000, 0x7dc0e000, 0x765d2000,
+ 0x80000038, 0xa7800030, 0x5dc40000, 0x84000022, 0xc1ee0002, 0x75c4e000, 0xc4cc2002, 0x61010028,
+ 0xa60afed0, 0x00000000, 0x5de40000, 0xdcb800fb, 0xdcb400fa, 0x84000e22, 0x5dcc0000, 0x840000ba,
+ 0xa78000b0, 0x62810028, 0x840000a2, 0x6e0c4000, 0x58cc4d08, 0xc1000000, 0x580c0004, 0xc90000b8,
+ 0x580c0000, 0xc98000b8, 0x7d00a000, 0xc1f00002, 0x5ddc0002, 0x755ca000, 0x59540002, 0xc1ee0002,
+ 0x75d0e000, 0xc5d400fa, 0x45948000, 0x580c0004, 0xcd0000b8, 0x8000ff60, 0x5de40000, 0xdcb800fb,
+ 0xdcb400fa, 0x84000d42, 0x62410008, 0xa7800098, 0x00000000, 0xc0c00000, 0xc65000f8, 0x6100a028,
+ 0x6d584000, 0x59984d08, 0xc0400000, 0x58180004, 0xc84000b8, 0x00000000, 0x00000000, 0xa46e002a,
+ 0x44c4e000, 0x88000018, 0xc56000f8, 0xc44c00f8, 0x6100a028, 0xa54aff98, 0x6e184000, 0x59984d08,
+ 0xc0400000, 0xc0800000, 0x6e1c2000, 0x59dc5fe0, 0x581c0002, 0xc8420078, 0x581c0000, 0xc8800078,
+ 0xc1400000, 0x58180006, 0xc9400078, 0x40484000, 0xc0c00000, 0x58080000, 0xc8c00078, 0x00000000,
+ 0xa7820038, 0x40f42000, 0x5dd5fffe, 0x84000022, 0x4544a000, 0x58180006, 0xcd400078, 0xa7800088,
+ 0xc0400000, 0x58180000, 0xc84000b8, 0xc1000000, 0x58180004, 0xc90000b8, 0x5dc40000, 0x8400004a,
+ 0xc1ee0002, 0x5ddc0002, 0x445ce000, 0x8400002a, 0x450c8000, 0x45348000, 0x58180004, 0xcd0000b8,
+ 0x6e106000, 0x5910b640, 0x58100006, 0xc98000f8, 0x58100004, 0xc94000f8, 0x418cc000, 0x58100006,
+ 0xcd8000f8, 0x59540002, 0x58100004, 0xcd4000f8, 0x6e242000, 0x5a645fe0, 0xc0c00000, 0x58240002,
+ 0xc8c20078, 0xc1000000, 0x58240000, 0xc9020038, 0x582c002a, 0xcc8000f8, 0x582c002c, 0xce0000f8,
+ 0x6d102000, 0x58cc0004, 0x450ce000, 0xc1c00000, 0xc5cc00fe, 0x58240002, 0x6cde0000, 0xcdc21078,
+ 0xc0e00002, 0x68e06000, 0xd8f000f8, 0xdcb800f9, 0xdcb400f8, 0xc0006910, 0xc8c000f9, 0xc90000f8,
+ 0xc1c00000, 0xc1400040, 0x60c04000, 0x7494e000, 0x8400007a, 0xc1400080, 0x61004000, 0x58880040,
+ 0x7494e000, 0x84000052, 0x00000000, 0xab6c0002, 0x00000000, 0x00000000, 0x984047e8, 0xc0006902,
+ 0xc8c000f8, 0xc3c00000, 0x8000ff58, 0xc0006910, 0xc1c00000, 0xc49ca000, 0x401c0000, 0xc8c000f8,
+ 0xc1000002, 0xc1400000, 0xc4940020, 0x6914e000, 0x70dc6000, 0xccc000f8, 0x582c0020, 0xcc8000f8,
+ 0xc1c00002, 0x582c0022, 0xcdc000f8, 0xc2409c00, 0x6c9c6000, 0x425d2000, 0xc2807600, 0x6c9c6000,
+ 0x429d4000, 0x582c002c, 0xc98000f8, 0x582c0026, 0xce8000f8, 0x582c0028, 0xce4000f8, 0x58240008,
+ 0xcd8000f8, 0x5838000a, 0xc98000f8, 0xc000ea10, 0xc2000000, 0xca3c0070, 0x6d9c8000, 0x41d8e000,
+ 0x421d0000, 0x5a204000, 0x582c002a, 0xc98000f8, 0xc1400000, 0xc1000000, 0x58180000, 0xc942e020,
+ 0x58180002, 0xc90000e0, 0x5828000e, 0xcd8000f8, 0x58280002, 0xc1c00000, 0xcdc00078, 0x41148000,
+ 0x58280004, 0xcd0000e0, 0x58a40000, 0x586c0008, 0xc44000f8, 0xc8c000f9, 0xc90000f9, 0xc94000f8,
+ 0xc48000f8, 0xccc000f9, 0xcd0000f9, 0xcd4000f9, 0x5df00000, 0x84000138, 0x58200000, 0xc1800000,
+ 0xcd8000f9, 0xcd8000f9, 0xcd8000f9, 0xcd8000f9, 0xcd8000f9, 0xcd8000f9, 0xcd8000f9, 0xcd8000f9,
+ 0xcd8000f9, 0xcd8000f9, 0xcd8000f9, 0xcd8000f9, 0xcd8000f9, 0xcd8000f9, 0xcd8000f9, 0xcd8000f9,
+ 0xcd8000f9, 0xc18001ea, 0xc1c00002, 0x75f4e000, 0xc1c001e0, 0xc5d800fa, 0xc1400000, 0x6d5c4010,
+ 0x421c0000, 0xc1c00006, 0x755c8000, 0x5dd00000, 0xcd80183a, 0x5dd00002, 0xcd80103a, 0x5dd00004,
+ 0xcd80083a, 0x5dd00006, 0xcd80003a, 0x5b300008, 0xc000fa40, 0xc93c00f8, 0xc1400000, 0x582c0002,
+ 0xc9428018, 0xc0400000, 0xc0800080, 0x44944000, 0xc45800f8, 0xc1c00200, 0x75d0e000, 0xc49c00f8,
+ 0xc5d800fa, 0x582c0030, 0xcd4000f8, 0xd97800f8, 0x5828000e, 0xc9c000f8, 0xc0c00000, 0x582c0002,
+ 0xc8c10038, 0xc1000000, 0x581c0000, 0xc9000078, 0x00000000, 0x00000000, 0xc50800f8, 0x4518e000,
+ 0xc59c00f8, 0xc5c800fc, 0xc4d400f8, 0x44c8e000, 0xc49c00f8, 0xc5d400fc, 0x582c002e, 0xcd4000f8,
+ 0xdf9000f8, 0x4150e000, 0xd9f800f8, 0x41f0e000, 0x5ddc0086, 0x88000082, 0xc18000a0, 0x6f1c4010,
+ 0x421c0000, 0xc1c00006, 0x771ca000, 0x5dd40000, 0xcd80183a, 0x5dd40002, 0xcd80103a, 0x5dd40004,
+ 0xcd80083a, 0x5dd40006, 0xcd80003a, 0x5b300002, 0x80000158, 0x00000000, 0x00000000, 0x00000000,
+ 0xdf9400f8, 0xc1008fe0, 0x6d5c4010, 0x411c0000, 0xc98000f8, 0xc1c00000, 0xc55c0308, 0x699cc000,
+ 0x6d9b0010, 0x6f1c4010, 0x421c0000, 0xc1c00006, 0x771c6000, 0x5dcc0000, 0xcd80183a, 0x5dcc0002,
+ 0xcd80103a, 0x5dcc0004, 0xcd80083a, 0x5dcc0006, 0xcd80003a, 0x5b300002, 0xc18000a0, 0x6f1c4010,
+ 0x421c0000, 0xc1c00006, 0x771ca000, 0x5dd40000, 0xcd80183a, 0x5dd40002, 0xcd80103a, 0x5dd40004,
+ 0xcd80083a, 0x5dd40006, 0xcd80003a, 0x5b300002, 0x582c0022, 0xc1c00000, 0xcdc000f8, 0x00000000,
+ 0x00000000, 0x5df00088, 0x880002f8, 0x582c0020, 0xc98000f8, 0xc2800000, 0xc2400000, 0xc5a80528,
+ 0x582c002e, 0xc98000f8, 0xc1000088, 0x45308000, 0xc51400f8, 0x4590e000, 0xc59c00f8, 0xc5d400fc,
+ 0xc5681930, 0x5838000a, 0xc90000f8, 0xc7281230, 0xc7e80008, 0xc5280b30, 0xd93800f8, 0xc1c00002,
+ 0xc5e80400, 0x4594e000, 0x8400001a, 0xc1c00000, 0xc5e80400, 0x5dd80000, 0x8400002a, 0xc1c00002,
+ 0xc5e80300, 0xc1c00002, 0xc5e80200, 0x582c0022, 0xc94000f8, 0xc7640e08, 0x00000000, 0x5d540002,
+ 0x8400001a, 0xc1c00002, 0xc5e40d00, 0xc0c00000, 0xc68f2030, 0x430c8000, 0xc5241838, 0xc0800088,
+ 0x44904000, 0xc1c00000, 0xc5c800fc, 0x582c0030, 0xc94000f8, 0xc0400000, 0x582c0002, 0xc8420018,
+ 0xc49000f8, 0x4548e000, 0xc55c00f8, 0xc5d000fc, 0xc5241418, 0x44546000, 0xc4e41018, 0x4550a000,
+ 0x582c0030, 0xcd4000f8, 0xc0c00000, 0xc68f2030, 0x458cc000, 0x582c002e, 0xcd8000f8, 0x43118000,
+ 0x430d8000, 0xdf9800f8, 0xc000ea10, 0xc1400000, 0xc97c0070, 0x6d9c8000, 0x41d8e000, 0x415ca000,
+ 0x59544000, 0x00000000, 0xc1000000, 0xc0000000, 0xc9140038, 0x00000000, 0x00000000, 0x59100002,
+ 0xcd140038, 0x98404d30, 0xc68c00f8, 0xc65000f8, 0x00000000, 0x5df00088, 0x8800ef02, 0x00000000,
+ 0x80000008, 0x5df00000, 0x840000ba, 0xc1c00002, 0xc000691c, 0xcdc000f8, 0x5838000a, 0xc94000f8,
+ 0xc1000000, 0xc000ea14, 0xc93c0038, 0x59540002, 0x00000000, 0x4514e000, 0xc1c00000, 0xc5d400fe,
+ 0x5838000a, 0xcd4000f8, 0x58380004, 0xc94000f8, 0x00000000, 0x00000000, 0x59540002, 0x58380004,
+ 0xcd4000f8, 0x5df00000, 0x84000058, 0xa7400020, 0x00000000, 0x6ff42000, 0x8000ea00, 0x5bfc0002,
+ 0x5dfc0002, 0x8400e812, 0x00000000, 0x00000000, 0x00000000, 0xab6c0052, 0x984047e8, 0xc0006902,
+ 0xc8c000f8, 0xc3c00000, 0xab6c002a, 0x984047e8, 0xc0006902, 0xc8c000f8, 0xc3c00000, 0xc0004032,
+ 0xcbc000f8, 0xc0004038, 0xcb8000f8, 0xc000691a, 0xcb0000f8, 0xc000403a, 0xcb4000f8, 0xc72c00f8,
+ 0xa7800058, 0xc2800000, 0x00000000, 0x984041b8, 0xc0c07c80, 0xc0007c00, 0x00000000, 0x98404220,
+ 0xc0006952, 0xc80000f8, 0xc1000000, 0xa7900058, 0xc2800002, 0x00000000, 0x984041b8, 0xc0c07c80,
+ 0xc0007c00, 0x00000000, 0x98404220, 0xc0006952, 0xc80000f8, 0xc1000000, 0x472ce000, 0x8400023a,
+ 0xc0c00000, 0xc78e0020, 0xc1c00002, 0x69cc8000, 0xc78f0020, 0x69cce000, 0x711c8000, 0xc000f41a,
+ 0xcfc000f8, 0xc1c00000, 0xc7dc4050, 0x581cc000, 0xcb0000f8, 0x00000000, 0x00000000, 0x76d16000,
+ 0x7d008000, 0x77118000, 0x732d8000, 0xcf0000f8, 0xc000691a, 0xcec000f8, 0x80000180, 0x5ea80000,
+ 0xc40c00fa, 0xc2400000, 0x580c0004, 0xca400038, 0x58cc0040, 0xc1c00000, 0x580c0004, 0xc9c00038,
+ 0x9c400000, 0x00000000, 0x00000000, 0x725d2000, 0x62406028, 0x84000032, 0xc9cc00f8, 0x00000000,
+ 0x00000000, 0x411c8000, 0x8000ffd0, 0xc1400000, 0xc7970020, 0x6f4e0010, 0x5de80000, 0xc74c00fa,
+ 0xc7960022, 0xc1c00000, 0xc4dd0038, 0x45d0e000, 0x88000048, 0xc1c00000, 0xc4dc0038, 0x451ce000,
+ 0x88000050, 0x9c400000, 0x00000000, 0x00000000, 0x00000000, 0xc1c00002, 0x9c400000, 0x69d4e000,
+ 0x7dc0e000, 0x76dd6000, 0x9c400000, 0xc1c00002, 0x69d4e000, 0x72dd6000, 0xc0004028, 0xcbc000f8,
+ 0xc000691c, 0xcb8000f8, 0xa7c0c780, 0x00000000, 0x5df80000, 0x8400c768, 0xc1c00002, 0xc000e070,
+ 0xcdc00000, 0x8000c748, 0xdcbc00f9, 0xdcb800f8, 0xdd3400f9, 0xc2400040, 0xc000690c, 0xc8c000f9,
+ 0xc90000f8, 0xc1c00000, 0x60c18000, 0x7724e000, 0x84000052, 0x61018000, 0x7724e000, 0x84000032,
+ 0x98404ec0, 0x00000000, 0x00000000, 0x00000000, 0x8000ff90, 0x5b300040, 0xc2c09400, 0x6f1c6000,
+ 0x42dd6000, 0xc2809800, 0x429d4000, 0x58340022, 0xcf0000f8, 0x582c0008, 0xcf8000f8, 0xc000690c,
+ 0xc1c00000, 0xc71ca000, 0x401c0000, 0xc8c000f8, 0xc2000002, 0x6a30e000, 0x70dc6000, 0xccc000f8,
+ 0x58340008, 0xc8c000f9, 0xc90000f9, 0xc94000f9, 0x582c0000, 0xccc000f9, 0xcd0000f9, 0xcd4000f9,
+ 0x58340010, 0xc9c000f9, 0xc8c000f9, 0xc90000f9, 0xc94000f9, 0xc98000f9, 0xc84000f9, 0xc88000f9,
+ 0x58280000, 0xcdc000f9, 0xccc000f9, 0xcd0000f9, 0xcd4000f9, 0xcd8000f9, 0xcc4000f9, 0xcc8000f9,
+ 0xc1c00000, 0x5828000e, 0xc9c3e000, 0x00000000, 0x00000000, 0x5ddc0002, 0x840001ba, 0xc0006908,
+ 0xc8c000f8, 0xc0004c00, 0xc1000000, 0x400c0000, 0x58000000, 0xc903e000, 0x00000000, 0x00000000,
+ 0x5dd00002, 0x840000e8, 0xc1000000, 0x58000002, 0xc90000e0, 0xc1c00000, 0xc0004022, 0xc9c20008,
+ 0x5828000e, 0xcd0000e0, 0x411ce000, 0x58280004, 0xcdc000e0, 0x5828000e, 0xc1fe0002, 0xcdc3ff00,
+ 0x5828000e, 0xc1fc0000, 0xcdc3de00, 0x58340020, 0xc1c00000, 0xcdc000f8, 0x58cc0004, 0xc1c00100,
+ 0x45cce000, 0xc1c00000, 0xc5cc00fe, 0xc0006908, 0xccc000f8, 0x800000f8, 0xc0c0b600, 0x6f9c6000,
+ 0x40dc6000, 0x580c0004, 0xc90000f8, 0x5828000e, 0xc1fc0002, 0xcdc3de00, 0x58340020, 0xc1c00002,
+ 0xcdc000f8, 0x59100002, 0x580c0004, 0xcd0000f8, 0x80000080, 0xc0c00000, 0xc0004022, 0xc8c20008,
+ 0xc1000000, 0x5828000e, 0xc90000e0, 0x5828000e, 0xc1fc0000, 0xcdc3de00, 0x58340020, 0xc1c00000,
+ 0xcdc000f8, 0x410ce000, 0x58280004, 0xcdc000e0, 0x94000000, 0xc1c00002, 0xc000691c, 0xcdc000f8,
+ 0xd87800f8, 0xc3800000, 0x580c7400, 0xca4000f9, 0xca0000f8, 0xc3400000, 0xc67c0008, 0xc639c008,
+ 0xc674a028, 0xc0c00000, 0xc64d6030, 0xc000ea10, 0xc3000000, 0xcb3c0070, 0x6cdc8000, 0x41cce000,
+ 0x431d8000, 0x5b304000, 0x6faca000, 0x5aec7c00, 0xc0c00000, 0xc0000000, 0xc8f00038, 0x6f686000,
+ 0x5aa89c00, 0x5ccc0002, 0xccf00038, 0xc1000000, 0xc6128018, 0x5dd00000, 0x840000f2, 0xc1800000,
+ 0xc0800000, 0xc61a0018, 0xc60b0038, 0xc1c40002, 0x419cc000, 0x6d9c4010, 0x429c0000, 0xc94000f8,
+ 0xc1c00000, 0xc59c0308, 0x695ca000, 0x6d570010, 0x59980002, 0x6c9c4010, 0x431c0000, 0xc1c00006,
+ 0x749c2000, 0x5dc40000, 0xcd40183a, 0x5dc40002, 0xcd40103a, 0x5dc40004, 0xcd40083a, 0x5dc40006,
+ 0xcd40003a, 0x58880002, 0x5d100002, 0x8400ff50, 0xa61a00a0, 0x582c002a, 0xc90000f8, 0xc0000000,
+ 0xc1c00000, 0xcdd3ff00, 0xc1000002, 0x58280008, 0xc94000f8, 0x5df40040, 0xc0006912, 0x44100004,
+ 0xc98000f8, 0x6934e000, 0x7dc0e000, 0x759cc000, 0xcd8000f8, 0xc1b00002, 0x6994c000, 0xd9b000f8,
+ 0x5ccc0000, 0x84000160, 0x6fcca000, 0x58cc7d80, 0x580c0006, 0xc90000f8, 0xc1400000, 0xc615a000,
+ 0x59100002, 0x580c0006, 0xcd0000f8, 0xc1c00000, 0x7d40a000, 0xc55c0000, 0x582c0024, 0xcdc000f8,
+ 0xa61a00e8, 0x7f80e000, 0xc5f80000, 0x6faca000, 0x5aec7c00, 0x582c0024, 0xc94000f8, 0x580c0004,
+ 0xc98000f8, 0x5dd40002, 0x8400009a, 0xc000ea28, 0x6d1d2000, 0xcdfd2928, 0xc000ea28, 0xc1d00002,
+ 0xcdfd0800, 0xc0006948, 0xc9c000f8, 0x403c0000, 0x00000000, 0x41d0e000, 0xcdc000f8, 0x4590c000,
+ 0x580c0004, 0xcd8000f8, 0x580c0006, 0xc1c00000, 0xcdc000f8, 0xc0006902, 0xc8c000f8, 0x00000000,
+ 0x00000000, 0x58cc0004, 0xc1c00200, 0x45cce000, 0xc1c00000, 0xc5cc00fe, 0xccc000f8, 0xc000f01e,
+ 0xc1d00002, 0xcdc10800, 0xdf8400f8, 0x9c400000, 0x00000000, 0x00000000, 0x00000000, 0xc0006904,
+ 0xc94000f8, 0xab68008a, 0x00000000, 0x58147200, 0xccc000f9, 0xcd0000f9, 0xc000f016, 0xc1d00002,
+ 0xcdc10800, 0x59540004, 0xc1c00200, 0x45d4e000, 0xc1c00000, 0xc5d400fe, 0x9c400000, 0xc0006904,
+ 0xcd4000f8, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8000ff60, 0xc0006906, 0xc94000f8,
+ 0xab6a008a, 0x00000000, 0x58147400, 0xccc000f9, 0xcd0000f9, 0xc000f404, 0xc1d00002, 0xcdc10800,
+ 0x59540004, 0xc1c00200, 0x45d4e000, 0xc1c00000, 0xc5d400fe, 0x9c400000, 0xc0006906, 0xcd4000f8,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8000ff60, 0xc08000a0, 0x74d0c000, 0x84000090,
+ 0x78d0c000, 0x8400006a, 0x61800018, 0x6180e008, 0x441cc000, 0x84000060, 0x5d940000, 0x84000050,
+ 0x60c04008, 0xa48a0040, 0x9c400000, 0x61004008, 0x58880040, 0x00000000, 0xa5400018, 0x00000000,
+ 0xc0800080, 0x9c400000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xc000f412, 0xc9c000f8, 0xc1800000, 0xc0800000, 0xa5c004e8, 0xc5d82028, 0x6d886000, 0x59089800,
+ 0x5810000e, 0xc9c3c000, 0x59489400, 0xd9b800f8, 0xa5c0044a, 0x58140008, 0xc98000f8, 0xc0c07b00,
+ 0xc0800000, 0x6d9ca000, 0x40dc6000, 0xd9b800f8, 0x580c0002, 0xc8808000, 0x00000000, 0x00000000,
+ 0xa480004a, 0x580c0004, 0xc98000f8, 0x58140002, 0xc88000f8, 0x00000000, 0x00000000, 0x4498e000,
+ 0x84000110, 0xc1c00000, 0x580c0002, 0xc9c04000, 0x00000000, 0x00000000, 0xa5c0004a, 0x580c0006,
+ 0xc98000f8, 0x58140004, 0xc88000f8, 0x00000000, 0x00000000, 0x4498e000, 0x840000a0, 0xc0800000,
+ 0x58100002, 0xc8800078, 0x580c001e, 0xc94000f8, 0xc1800000, 0x580c0002, 0xc9810038, 0x40944000,
+ 0xa4be0052, 0xc1400000, 0x4498e000, 0x88000118, 0x580c0002, 0xc940e000, 0x00000000, 0x00000000,
+ 0xa54000ca, 0xc1c00000, 0x00000000, 0x00000000, 0x00000000, 0xdf9400f8, 0x00000000, 0x00000000,
+ 0xc1800000, 0xc5582000, 0xa5400042, 0xc000fb64, 0xc1c00002, 0xcdd80000, 0xc000facc, 0xc1c40002,
+ 0xcdd84200, 0x80000220, 0xc000fb64, 0xc1c20002, 0xcdd82100, 0xc000facc, 0xc1c60002, 0xcdd86300,
+ 0x800001e8, 0x580c0002, 0xc9c10038, 0x00000000, 0x00000000, 0x589c0000, 0xc000690a, 0xc94000f8,
+ 0xc1c00000, 0x5810000e, 0xc9c000e0, 0x59944c00, 0x58180000, 0xcc800078, 0x58180002, 0xcdc000e0,
+ 0x58180000, 0xc1fa0002, 0xcdc3bd00, 0x58180000, 0xc1f80002, 0xcdc39c00, 0x58180000, 0xc1fe0000,
+ 0xcdc3ff00, 0x59540004, 0xc1c00100, 0x45d4e000, 0xc1c00000, 0xc5d400fe, 0xc000690a, 0xcd4000f8,
+ 0xc000e408, 0xc1c00002, 0xcdc000f8, 0x5810000e, 0xc1fe0000, 0xcdc3ff00, 0xdf9400f8, 0xc1800000,
+ 0x58100002, 0xc9800078, 0x6d486000, 0x5888b600, 0x58080006, 0xc9c000f8, 0x00000000, 0x00000000,
+ 0x419cc000, 0x58080006, 0xcd8000f8, 0xc1800000, 0xc5582000, 0xa540002a, 0xc000fb60, 0xc1c40002,
+ 0xcdd84200, 0x80000020, 0xc000fb60, 0xc1c60002, 0xcdd86300, 0xdf9400f8, 0xc1800002, 0x00000000,
+ 0x00000000, 0x5dd40040, 0xc000690e, 0x44180004, 0xc88000f8, 0x6994e000, 0x7dc0e000, 0x749c4000,
+ 0xcc8000f8, 0x9c400000, 0x00000000, 0x00000000, 0x00000000, 0xc3c00000, 0xc4fc8018, 0xc3800000,
+ 0x6fb44000, 0x5b744d08, 0xc3000000, 0x58340006, 0xcb020038, 0xc2c00000, 0xc2800000, 0x5f300002,
+ 0x84000080, 0x58340006, 0xcac00078, 0x58340002, 0xca800078, 0xc2000000, 0x58340002, 0xca020078,
+ 0x42e92000, 0x00000000, 0x4624e000, 0xc62400fc, 0x58340000, 0xcb030038, 0x58340006, 0xce400078,
+ 0x58340006, 0x6f1e0000, 0xcdc21038, 0x5bb80002, 0x47bce000, 0x8800ff1a, 0x8000b410, 0x00000000,
+ 0x00000000, 0x00000000,};
+
+static unsigned int firmware_binary_data[] = {
+};
+
+
+#endif // IFXMIPS_PTM_FW_VR9_H
diff --git a/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_ppe_amazon_se.h b/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_ppe_amazon_se.h
new file mode 100644
index 0000000..f912039
--- /dev/null
+++ b/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_ppe_amazon_se.h
@@ -0,0 +1,186 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_ptm_ppe_amazon_se.h
+** PROJECT : UEIP
+** MODULES : PTM
+**
+** DATE : 7 Jul 2009
+** AUTHOR : Xu Liang
+** DESCRIPTION : PTM driver header file (PPE register for Amazon-SE)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 07 JUL 2009 Xu Liang Init Version
+*******************************************************************************/
+
+
+
+#ifndef IFXMIPS_PTM_PPE_AMAZON_SE_H
+#define IFXMIPS_PTM_PPE_AMAZON_SE_H
+
+
+
+/*
+ * FPI Configuration Bus Register and Memory Address Mapping
+ */
+#define IFX_PPE (KSEG1 | 0x1E180000)
+#define PP32_DEBUG_REG_ADDR(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x0000) << 2)))
+#define PPM_INT_REG_ADDR(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x0030) << 2)))
+#define PP32_INTERNAL_RES_ADDR(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x0040) << 2)))
+#define CDM_CODE_MEMORY(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x1000) << 2)))
+#define PPE_REG_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x4000) << 2)))
+#define CDM_DATA_MEMORY(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x5000) << 2)))
+#define PPM_INT_UNIT_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6000) << 2)))
+#define PPM_TIMER0_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6100) << 2)))
+#define PPM_TASK_IND_REG_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6200) << 2)))
+#define PPS_BRK_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6300) << 2)))
+#define PPM_TIMER1_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6400) << 2)))
+#define SB_RAM0_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x8200) << 2)))
+#define SB_RAM1_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x8C00) << 2)))
+#define QSB_CONF_REG_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0xC000) << 2)))
+
+/*
+ * DWORD-Length of Memory Blocks
+ */
+#define PP32_DEBUG_REG_DWLEN 0x0030
+#define PPM_INT_REG_DWLEN 0x0010
+#define PP32_INTERNAL_RES_DWLEN 0x00C0
+#define CDM_CODE_MEMORYn_DWLEN(n) ((n) == 0 ? 0x1000 : 0x0800)
+#define PPE_REG_DWLEN 0x1000
+#define CDM_DATA_MEMORY_DWLEN CDM_CODE_MEMORYn_DWLEN(1)
+#define PPM_INT_UNIT_DWLEN 0x0100
+#define PPM_TIMER0_DWLEN 0x0100
+#define PPM_TASK_IND_REG_DWLEN 0x0100
+#define PPS_BRK_DWLEN 0x0100
+#define PPM_TIMER1_DWLEN 0x0100
+#define SB_RAM0_DWLEN 0x0A00
+#define SB_RAM1_DWLEN 0x0A00
+#define QSB_CONF_REG_DWLEN 0x0100
+
+/*
+ * PP32 to FPI Address Mapping
+ */
+#define SB_BUFFER(__sb_addr) ((volatile unsigned int *)((((__sb_addr) >= 0x0000) && ((__sb_addr) <= 0x0FFF)) ? PPE_REG_ADDR((__sb_addr) - 0x0000) : \
+ (((__sb_addr) >= 0x2200) && ((__sb_addr) <= 0x2BFF)) ? SB_RAM0_ADDR((__sb_addr) - 0x2200) : \
+ (((__sb_addr) >= 0x2C00) && ((__sb_addr) <= 0x35FF)) ? SB_RAM1_ADDR((__sb_addr) - 0x2C00) : \
+ 0))
+
+/*
+ * PP32 Debug Control Register
+ */
+#define NUM_OF_PP32 1
+
+#define PP32_DBG_CTRL(n) PP32_DEBUG_REG_ADDR(n, 0x0000)
+
+#define DBG_CTRL_RESTART 0
+#define DBG_CTRL_STOP 1
+
+#define PP32_CTRL_CMD(n) PP32_DEBUG_REG_ADDR(n, 0x0B00)
+ #define PP32_CTRL_CMD_RESTART (1 << 0)
+ #define PP32_CTRL_CMD_STOP (1 << 1)
+ #define PP32_CTRL_CMD_STEP (1 << 2)
+ #define PP32_CTRL_CMD_BREAKOUT (1 << 3)
+
+#define PP32_CTRL_OPT(n) PP32_DEBUG_REG_ADDR(n, 0x0C00)
+ #define PP32_CTRL_OPT_BREAKOUT_ON_STOP_ON (3 << 0)
+ #define PP32_CTRL_OPT_BREAKOUT_ON_STOP_OFF (2 << 0)
+ #define PP32_CTRL_OPT_BREAKOUT_ON_BREAKIN_ON (3 << 2)
+ #define PP32_CTRL_OPT_BREAKOUT_ON_BREAKIN_OFF (2 << 2)
+ #define PP32_CTRL_OPT_STOP_ON_BREAKIN_ON (3 << 4)
+ #define PP32_CTRL_OPT_STOP_ON_BREAKIN_OFF (2 << 4)
+ #define PP32_CTRL_OPT_STOP_ON_BREAKPOINT_ON (3 << 6)
+ #define PP32_CTRL_OPT_STOP_ON_BREAKPOINT_OFF (2 << 6)
+ #define PP32_CTRL_OPT_BREAKOUT_ON_STOP(n) (*PP32_CTRL_OPT(n) & (1 << 0))
+ #define PP32_CTRL_OPT_BREAKOUT_ON_BREAKIN(n) (*PP32_CTRL_OPT(n) & (1 << 2))
+ #define PP32_CTRL_OPT_STOP_ON_BREAKIN(n) (*PP32_CTRL_OPT(n) & (1 << 4))
+ #define PP32_CTRL_OPT_STOP_ON_BREAKPOINT(n) (*PP32_CTRL_OPT(n) & (1 << 6))
+
+#define PP32_BRK_PC(n, i) PP32_DEBUG_REG_ADDR(n, 0x0900 + (i) * 2)
+#define PP32_BRK_PC_MASK(n, i) PP32_DEBUG_REG_ADDR(n, 0x0901 + (i) * 2)
+#define PP32_BRK_DATA_ADDR(n, i) PP32_DEBUG_REG_ADDR(n, 0x0904 + (i) * 2)
+#define PP32_BRK_DATA_ADDR_MASK(n, i) PP32_DEBUG_REG_ADDR(n, 0x0905 + (i) * 2)
+#define PP32_BRK_DATA_VALUE_RD(n, i) PP32_DEBUG_REG_ADDR(n, 0x0908 + (i) * 2)
+#define PP32_BRK_DATA_VALUE_RD_MASK(n, i) PP32_DEBUG_REG_ADDR(n, 0x0909 + (i) * 2)
+#define PP32_BRK_DATA_VALUE_WR(n, i) PP32_DEBUG_REG_ADDR(n, 0x090C + (i) * 2)
+#define PP32_BRK_DATA_VALUE_WR_MASK(n, i) PP32_DEBUG_REG_ADDR(n, 0x090D + (i) * 2)
+ #define PP32_BRK_CONTEXT_MASK(i) (1 << (i))
+ #define PP32_BRK_CONTEXT_MASK_EN (1 << 4)
+ #define PP32_BRK_COMPARE_GREATER_EQUAL (1 << 5) // valid for break data value rd/wr only
+ #define PP32_BRK_COMPARE_LOWER_EQUAL (1 << 6)
+ #define PP32_BRK_COMPARE_EN (1 << 7)
+
+#define PP32_BRK_SRC(n) PP32_DEBUG_REG_ADDR(n, 0x0F00)
+#define PP32_BRK_TRIG(n) PP32_BRK_SRC(n)
+ #define PP32_BRK_GRPi_PCn_ON(i, n) ((3 << ((n) * 2)) << ((i) * 16))
+ #define PP32_BRK_GRPi_PCn_OFF(i, n) ((2 << ((n) * 2)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_ADDRn_ON(i, n) ((3 << ((n) * 2 + 4)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_ADDRn_OFF(i, n) ((2 << ((n) * 2 + 4)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_VALUE_RDn_ON(i, n) ((3 << ((n) * 2 + 8)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_VALUE_RDn_OFF(i, n)((2 << ((n) * 2 + 8)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_VALUE_WRn_ON(i, n) ((3 << ((n) * 2 + 12)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_VALUE_WRn_OFF(i, n)((2 << ((n) * 2 + 12)) << ((i) * 16))
+ #define PP32_BRK_GRPi_PCn(k, i, n) (*PP32_BRK_TRIG(k) & ((1 << ((n))) << ((i) * 8)))
+ #define PP32_BRK_GRPi_DATA_ADDRn(k, i, n) (*PP32_BRK_TRIG(k) & ((1 << ((n) + 2)) << ((i) * 8)))
+ #define PP32_BRK_GRPi_DATA_VALUE_RDn(k, i, n) (*PP32_BRK_TRIG(k) & ((1 << ((n) + 4)) << ((i) * 8)))
+ #define PP32_BRK_GRPi_DATA_VALUE_WRn(k, i, n) (*PP32_BRK_TRIG(k) & ((1 << ((n) + 6)) << ((i) * 8)))
+
+#define PP32_CPU_STATUS(n) PP32_DEBUG_REG_ADDR(n, 0x0D00)
+#define PP32_HALT_STAT(n) PP32_CPU_STATUS(n)
+#define PP32_DBG_CUR_PC(n) PP32_DEBUG_REG_ADDR(n, 0x0F80)
+ #define PP32_CPU_USER_STOPPED(n) (*PP32_CPU_STATUS(n) & (1 << 0))
+ #define PP32_CPU_USER_BREAKIN_RCV(n) (*PP32_CPU_STATUS(n) & (1 << 1))
+ #define PP32_CPU_USER_BREAKPOINT_MET(n) (*PP32_CPU_STATUS(n) & (1 << 2))
+ #define PP32_CPU_CUR_PC(n) (*PP32_DBG_CUR_PC(n) & 0xFFFF)
+
+#define PP32_BREAKPOINT_REASONS(n) PP32_DEBUG_REG_ADDR(n, 0x0A00)
+ #define PP32_BRK_PC_MET(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << (i)))
+ #define PP32_BRK_DATA_ADDR_MET(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) + 2)))
+ #define PP32_BRK_DATA_VALUE_RD_MET(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) + 4)))
+ #define PP32_BRK_DATA_VALUE_WR_MET(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) + 6)))
+ #define PP32_BRK_DATA_VALUE_RD_LO_EQ(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) * 2 + 8)))
+ #define PP32_BRK_DATA_VALUE_RD_GT_EQ(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) * 2 + 9)))
+ #define PP32_BRK_DATA_VALUE_WR_LO_EQ(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) * 2 + 12)))
+ #define PP32_BRK_DATA_VALUE_WR_GT_EQ(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) * 2 + 13)))
+// #define PP32_BRK_CUR_CONTEXT(n) ((*PP32_BREAKPOINT_REASONS(n) >> 16) & 0x03)
+#define PP32_DBG_TASK_NO(n) PP32_DEBUG_REG_ADDR(n, 0x0F81)
+ #define PP32_BRK_CUR_CONTEXT(n) (*PP32_DBG_TASK_NO(n) & 0x03)
+
+#define PP32_GP_REG_BASE(n) PP32_DEBUG_REG_ADDR(n, 0x0E00)
+#define PP32_GP_CONTEXTi_REGn(n, i, j) PP32_DEBUG_REG_ADDR(n, 0x0E00 + (i) * 16 + (j))
+
+/*
+ * Share Buffer
+ */
+#define SB_MST_PRI0 PPE_REG_ADDR(0x0300)
+#define SB_MST_PRI1 PPE_REG_ADDR(0x0301)
+
+/*
+ * EMA Registers
+ */
+#define EMA_CMDCFG PPE_REG_ADDR(0x0A00)
+#define EMA_DATACFG PPE_REG_ADDR(0x0A01)
+#define EMA_CMDCNT PPE_REG_ADDR(0x0A02)
+#define EMA_DATACNT PPE_REG_ADDR(0x0A03)
+#define EMA_ISR PPE_REG_ADDR(0x0A04)
+#define EMA_IER PPE_REG_ADDR(0x0A05)
+#define EMA_CFG PPE_REG_ADDR(0x0A06)
+#define EMA_SUBID PPE_REG_ADDR(0x0A07)
+
+#define EMA_ALIGNMENT 4
+
+/*
+ * Mailbox IGU1 Interrupt
+ */
+#define PPE_MAILBOX_IGU1_INT INT_NUM_IM2_IRL13
+
+
+
+#endif // IFXMIPS_PTM_PPE_AMAZON_SE_H
diff --git a/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_ppe_ar9.h b/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_ppe_ar9.h
new file mode 100644
index 0000000..9355747
--- /dev/null
+++ b/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_ppe_ar9.h
@@ -0,0 +1,213 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_ptm_ppe_ar9.h
+** PROJECT : UEIP
+** MODULES : PTM
+**
+** DATE : 7 Jul 2009
+** AUTHOR : Xu Liang
+** DESCRIPTION : PTM driver header file (PPE register for AR9)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 07 JUL 2009 Xu Liang Init Version
+*******************************************************************************/
+
+
+
+#ifndef IFXMIPS_PTM_PPE_AR9_H
+#define IFXMIPS_PTM_PPE_AR9_H
+
+
+
+/*
+ * FPI Configuration Bus Register and Memory Address Mapping
+ */
+#define IFX_PPE (KSEG1 | 0x1E180000)
+#define PP32_DEBUG_REG_ADDR(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x0000) << 2)))
+#define PPM_INT_REG_ADDR(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x0030) << 2)))
+#define PP32_INTERNAL_RES_ADDR(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x0040) << 2)))
+#define CDM_CODE_MEMORY(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x1000) << 2)))
+#define PPE_REG_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x4000) << 2)))
+#define CDM_DATA_MEMORY(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x5000) << 2)))
+#define PPM_INT_UNIT_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6000) << 2)))
+#define PPM_TIMER0_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6100) << 2)))
+#define PPM_TASK_IND_REG_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6200) << 2)))
+#define PPS_BRK_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6300) << 2)))
+#define PPM_TIMER1_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6400) << 2)))
+#define SB_RAM0_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x8000) << 2)))
+#define SB_RAM1_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x8800) << 2)))
+#define SB_RAM2_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x9000) << 2)))
+#define SB_RAM3_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x9800) << 2)))
+#define SB_RAM4_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0xA000) << 2)))
+#define QSB_CONF_REG_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0xC000) << 2)))
+
+/*
+ * DWORD-Length of Memory Blocks
+ */
+#define PP32_DEBUG_REG_DWLEN 0x0030
+#define PPM_INT_REG_DWLEN 0x0010
+#define PP32_INTERNAL_RES_DWLEN 0x00C0
+#define CDM_CODE_MEMORYn_DWLEN(n) 0x1000
+#define PPE_REG_DWLEN 0x1000
+#define CDM_DATA_MEMORY_DWLEN CDM_CODE_MEMORYn_DWLEN(1)
+#define PPM_INT_UNIT_DWLEN 0x0100
+#define PPM_TIMER0_DWLEN 0x0100
+#define PPM_TASK_IND_REG_DWLEN 0x0100
+#define PPS_BRK_DWLEN 0x0100
+#define PPM_TIMER1_DWLEN 0x0100
+#define SB_RAM0_DWLEN 0x0800
+#define SB_RAM1_DWLEN 0x0800
+#define SB_RAM2_DWLEN 0x0800
+#define SB_RAM3_DWLEN 0x0800
+#define SB_RAM4_DWLEN 0x0C00
+#define QSB_CONF_REG_DWLEN 0x0100
+
+/*
+ * PP32 to FPI Address Mapping
+ */
+#define SB_BUFFER(__sb_addr) ((volatile unsigned int *)((((__sb_addr) >= 0x0000) && ((__sb_addr) <= 0x0FFF)) ? PP32_DEBUG_REG_ADDR(0, (__sb_addr)): \
+ (((__sb_addr) >= 0x2000) && ((__sb_addr) <= 0x27FF)) ? SB_RAM0_ADDR((__sb_addr) - 0x2000) : \
+ (((__sb_addr) >= 0x2800) && ((__sb_addr) <= 0x2FFF)) ? SB_RAM1_ADDR((__sb_addr) - 0x2800) : \
+ (((__sb_addr) >= 0x3000) && ((__sb_addr) <= 0x37FF)) ? SB_RAM2_ADDR((__sb_addr) - 0x3000) : \
+ (((__sb_addr) >= 0x3800) && ((__sb_addr) <= 0x3FFF)) ? SB_RAM3_ADDR((__sb_addr) - 0x3800) : \
+ (((__sb_addr) >= 0x4000) && ((__sb_addr) <= 0x4BFF)) ? SB_RAM4_ADDR((__sb_addr) - 0x4000) : \
+ 0))
+
+/*
+ * PP32 Debug Control Register
+ */
+#define NUM_OF_PP32 1
+
+#define PP32_DBG_CTRL(n) PP32_DEBUG_REG_ADDR(n, 0x0000)
+
+#define DBG_CTRL_RESTART 0
+#define DBG_CTRL_STOP 1
+
+#define PP32_CTRL_CMD(n) PP32_DEBUG_REG_ADDR(n, 0x0B00)
+ #define PP32_CTRL_CMD_RESTART (1 << 0)
+ #define PP32_CTRL_CMD_STOP (1 << 1)
+ #define PP32_CTRL_CMD_STEP (1 << 2)
+ #define PP32_CTRL_CMD_BREAKOUT (1 << 3)
+
+#define PP32_CTRL_OPT(n) PP32_DEBUG_REG_ADDR(n, 0x0C00)
+ #define PP32_CTRL_OPT_BREAKOUT_ON_STOP_ON (3 << 0)
+ #define PP32_CTRL_OPT_BREAKOUT_ON_STOP_OFF (2 << 0)
+ #define PP32_CTRL_OPT_BREAKOUT_ON_BREAKIN_ON (3 << 2)
+ #define PP32_CTRL_OPT_BREAKOUT_ON_BREAKIN_OFF (2 << 2)
+ #define PP32_CTRL_OPT_STOP_ON_BREAKIN_ON (3 << 4)
+ #define PP32_CTRL_OPT_STOP_ON_BREAKIN_OFF (2 << 4)
+ #define PP32_CTRL_OPT_STOP_ON_BREAKPOINT_ON (3 << 6)
+ #define PP32_CTRL_OPT_STOP_ON_BREAKPOINT_OFF (2 << 6)
+ #define PP32_CTRL_OPT_BREAKOUT_ON_STOP(n) (*PP32_CTRL_OPT(n) & (1 << 0))
+ #define PP32_CTRL_OPT_BREAKOUT_ON_BREAKIN(n) (*PP32_CTRL_OPT(n) & (1 << 2))
+ #define PP32_CTRL_OPT_STOP_ON_BREAKIN(n) (*PP32_CTRL_OPT(n) & (1 << 4))
+ #define PP32_CTRL_OPT_STOP_ON_BREAKPOINT(n) (*PP32_CTRL_OPT(n) & (1 << 6))
+
+#define PP32_BRK_PC(n, i) PP32_DEBUG_REG_ADDR(n, 0x0900 + (i) * 2)
+#define PP32_BRK_PC_MASK(n, i) PP32_DEBUG_REG_ADDR(n, 0x0901 + (i) * 2)
+#define PP32_BRK_DATA_ADDR(n, i) PP32_DEBUG_REG_ADDR(n, 0x0904 + (i) * 2)
+#define PP32_BRK_DATA_ADDR_MASK(n, i) PP32_DEBUG_REG_ADDR(n, 0x0905 + (i) * 2)
+#define PP32_BRK_DATA_VALUE_RD(n, i) PP32_DEBUG_REG_ADDR(n, 0x0908 + (i) * 2)
+#define PP32_BRK_DATA_VALUE_RD_MASK(n, i) PP32_DEBUG_REG_ADDR(n, 0x0909 + (i) * 2)
+#define PP32_BRK_DATA_VALUE_WR(n, i) PP32_DEBUG_REG_ADDR(n, 0x090C + (i) * 2)
+#define PP32_BRK_DATA_VALUE_WR_MASK(n, i) PP32_DEBUG_REG_ADDR(n, 0x090D + (i) * 2)
+ #define PP32_BRK_CONTEXT_MASK(i) (1 << (i))
+ #define PP32_BRK_CONTEXT_MASK_EN (1 << 4)
+ #define PP32_BRK_COMPARE_GREATER_EQUAL (1 << 5) // valid for break data value rd/wr only
+ #define PP32_BRK_COMPARE_LOWER_EQUAL (1 << 6)
+ #define PP32_BRK_COMPARE_EN (1 << 7)
+
+#define PP32_BRK_TRIG(n) PP32_DEBUG_REG_ADDR(n, 0x0F00)
+ #define PP32_BRK_GRPi_PCn_ON(i, n) ((3 << ((n) * 2)) << ((i) * 16))
+ #define PP32_BRK_GRPi_PCn_OFF(i, n) ((2 << ((n) * 2)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_ADDRn_ON(i, n) ((3 << ((n) * 2 + 4)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_ADDRn_OFF(i, n) ((2 << ((n) * 2 + 4)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_VALUE_RDn_ON(i, n) ((3 << ((n) * 2 + 8)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_VALUE_RDn_OFF(i, n)((2 << ((n) * 2 + 8)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_VALUE_WRn_ON(i, n) ((3 << ((n) * 2 + 12)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_VALUE_WRn_OFF(i, n)((2 << ((n) * 2 + 12)) << ((i) * 16))
+ #define PP32_BRK_GRPi_PCn(k, i, n) (*PP32_BRK_TRIG(k) & ((1 << ((n))) << ((i) * 8)))
+ #define PP32_BRK_GRPi_DATA_ADDRn(k, i, n) (*PP32_BRK_TRIG(k) & ((1 << ((n) + 2)) << ((i) * 8)))
+ #define PP32_BRK_GRPi_DATA_VALUE_RDn(k, i, n) (*PP32_BRK_TRIG(k) & ((1 << ((n) + 4)) << ((i) * 8)))
+ #define PP32_BRK_GRPi_DATA_VALUE_WRn(k, i, n) (*PP32_BRK_TRIG(k) & ((1 << ((n) + 6)) << ((i) * 8)))
+
+#define PP32_CPU_STATUS(n) PP32_DEBUG_REG_ADDR(n, 0x0D00)
+#define PP32_HALT_STAT(n) PP32_CPU_STATUS(n)
+#define PP32_DBG_CUR_PC(n) PP32_CPU_STATUS(n)
+ #define PP32_CPU_USER_STOPPED(n) (*PP32_CPU_STATUS(n) & (1 << 0))
+ #define PP32_CPU_USER_BREAKIN_RCV(n) (*PP32_CPU_STATUS(n) & (1 << 1))
+ #define PP32_CPU_USER_BREAKPOINT_MET(n) (*PP32_CPU_STATUS(n) & (1 << 2))
+ #define PP32_CPU_CUR_PC(n) (*PP32_CPU_STATUS(n) >> 16)
+
+#define PP32_BREAKPOINT_REASONS(n) PP32_DEBUG_REG_ADDR(n, 0x0A00)
+ #define PP32_BRK_PC_MET(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << (i)))
+ #define PP32_BRK_DATA_ADDR_MET(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) + 2)))
+ #define PP32_BRK_DATA_VALUE_RD_MET(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) + 4)))
+ #define PP32_BRK_DATA_VALUE_WR_MET(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) + 6)))
+ #define PP32_BRK_DATA_VALUE_RD_LO_EQ(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) * 2 + 8)))
+ #define PP32_BRK_DATA_VALUE_RD_GT_EQ(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) * 2 + 9)))
+ #define PP32_BRK_DATA_VALUE_WR_LO_EQ(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) * 2 + 12)))
+ #define PP32_BRK_DATA_VALUE_WR_GT_EQ(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) * 2 + 13)))
+ #define PP32_BRK_CUR_CONTEXT(n) ((*PP32_BREAKPOINT_REASONS(n) >> 16) & 0x03)
+
+#define PP32_GP_REG_BASE(n) PP32_DEBUG_REG_ADDR(n, 0x0E00)
+#define PP32_GP_CONTEXTi_REGn(n, i, j) PP32_DEBUG_REG_ADDR(n, 0x0E00 + (i) * 16 + (j))
+
+/*
+ * Share Buffer Registers
+ */
+#define SB_MST_PRI0 PPE_REG_ADDR(0x0300)
+#define SB_MST_PRI1 PPE_REG_ADDR(0x0301)
+
+/*
+ * EMA Registers
+ */
+#define EMA_CMDCFG PPE_REG_ADDR(0x0A00)
+#define EMA_DATACFG PPE_REG_ADDR(0x0A01)
+#define EMA_CMDCNT PPE_REG_ADDR(0x0A02)
+#define EMA_DATACNT PPE_REG_ADDR(0x0A03)
+#define EMA_ISR PPE_REG_ADDR(0x0A04)
+#define EMA_IER PPE_REG_ADDR(0x0A05)
+#define EMA_CFG PPE_REG_ADDR(0x0A06)
+#define EMA_SUBID PPE_REG_ADDR(0x0A07)
+
+#define EMA_ALIGNMENT 4
+
+/*
+ * DPlus Registers
+ */
+#define DM_RXDB PPE_REG_ADDR(0x0612)
+#define DM_RXCB PPE_REG_ADDR(0x0613)
+#define DM_RXCFG PPE_REG_ADDR(0x0614)
+#define DM_RXPGCNT PPE_REG_ADDR(0x0615)
+#define DM_RXPKTCNT PPE_REG_ADDR(0x0616)
+#define DS_RXDB PPE_REG_ADDR(0x0710)
+#define DS_RXCB PPE_REG_ADDR(0x0711)
+#define DS_RXCFG PPE_REG_ADDR(0x0712)
+#define DS_RXPGCNT PPE_REG_ADDR(0x0713)
+
+/*
+ * 3-Port Switch Registers (partial)
+ */
+#define IFX_SW (KSEG1 | 0x1E108000)
+#define SW_REG(off) ((volatile unsigned int*)(IFX_SW + (off)))
+#define SW_P2_CTL SW_REG(0x00C)
+
+
+/*
+ * Mailbox IGU1 Interrupt
+ */
+#define PPE_MAILBOX_IGU1_INT INT_NUM_IM2_IRL24
+
+
+
+#endif // IFXMIPS_PTM_PPE_AR9_H
diff --git a/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_ppe_common.h b/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_ppe_common.h
new file mode 100644
index 0000000..63a5a37
--- /dev/null
+++ b/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_ppe_common.h
@@ -0,0 +1,311 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_ptm_ppe_common.h
+** PROJECT : UEIP
+** MODULES : PTM
+**
+** DATE : 7 Jul 2009
+** AUTHOR : Xu Liang
+** DESCRIPTION : PTM driver header file (PPE register for all platform)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 07 JUL 2009 Xu Liang Init Version
+*******************************************************************************/
+
+
+
+#ifndef IFXMIPS_PTM_PPE_COMMON_H
+#define IFXMIPS_PTM_PPE_COMMON_H
+
+
+
+#if defined(CONFIG_DANUBE)
+ #include "ifxmips_ptm_ppe_danube.h"
+#elif defined(CONFIG_AMAZON_SE)
+ #include "ifxmips_ptm_ppe_amazon_se.h"
+#elif defined(CONFIG_AR9)
+ #include "ifxmips_ptm_ppe_ar9.h"
+#elif defined(CONFIG_VR9)
+ #include "ifxmips_ptm_ppe_vr9.h"
+#else
+ #error Platform is not specified!
+#endif
+
+
+
+/*
+ * Code/Data Memory (CDM) Interface Configuration Register
+ */
+#define CDM_CFG PPE_REG_ADDR(0x0100)
+
+#define CDM_CFG_RAM1 GET_BITS(*CDM_CFG, 3, 2)
+#define CDM_CFG_RAM0 (*CDM_CFG & (1 << 1))
+
+#define CDM_CFG_RAM1_SET(value) SET_BITS(0, 3, 2, value)
+#define CDM_CFG_RAM0_SET(value) ((value) ? (1 << 1) : 0)
+
+/*
+ * QSB Internal Cell Delay Variation Register
+ */
+#define QSB_ICDV QSB_CONF_REG_ADDR(0x0007)
+
+#define QSB_ICDV_TAU GET_BITS(*QSB_ICDV, 5, 0)
+
+#define QSB_ICDV_TAU_SET(value) SET_BITS(0, 5, 0, value)
+
+/*
+ * QSB Scheduler Burst Limit Register
+ */
+#define QSB_SBL QSB_CONF_REG_ADDR(0x0009)
+
+#define QSB_SBL_SBL GET_BITS(*QSB_SBL, 3, 0)
+
+#define QSB_SBL_SBL_SET(value) SET_BITS(0, 3, 0, value)
+
+/*
+ * QSB Configuration Register
+ */
+#define QSB_CFG QSB_CONF_REG_ADDR(0x000A)
+
+#define QSB_CFG_TSTEPC GET_BITS(*QSB_CFG, 1, 0)
+
+#define QSB_CFG_TSTEPC_SET(value) SET_BITS(0, 1, 0, value)
+
+/*
+ * QSB RAM Transfer Table Register
+ */
+#define QSB_RTM QSB_CONF_REG_ADDR(0x000B)
+
+#define QSB_RTM_DM (*QSB_RTM)
+
+#define QSB_RTM_DM_SET(value) ((value) & 0xFFFFFFFF)
+
+/*
+ * QSB RAM Transfer Data Register
+ */
+#define QSB_RTD QSB_CONF_REG_ADDR(0x000C)
+
+#define QSB_RTD_TTV (*QSB_RTD)
+
+#define QSB_RTD_TTV_SET(value) ((value) & 0xFFFFFFFF)
+
+/*
+ * QSB RAM Access Register
+ */
+#define QSB_RAMAC QSB_CONF_REG_ADDR(0x000D)
+
+#define QSB_RAMAC_RW (*QSB_RAMAC & (1 << 31))
+#define QSB_RAMAC_TSEL GET_BITS(*QSB_RAMAC, 27, 24)
+#define QSB_RAMAC_LH (*QSB_RAMAC & (1 << 16))
+#define QSB_RAMAC_TESEL GET_BITS(*QSB_RAMAC, 9, 0)
+
+#define QSB_RAMAC_RW_SET(value) ((value) ? (1 << 31) : 0)
+#define QSB_RAMAC_TSEL_SET(value) SET_BITS(0, 27, 24, value)
+#define QSB_RAMAC_LH_SET(value) ((value) ? (1 << 16) : 0)
+#define QSB_RAMAC_TESEL_SET(value) SET_BITS(0, 9, 0, value)
+
+/*
+ * QSB Queue Scheduling and Shaping Definitions
+ */
+#define QSB_WFQ_NONUBR_MAX 0x3f00
+#define QSB_WFQ_UBR_BYPASS 0x3fff
+#define QSB_TP_TS_MAX 65472
+#define QSB_TAUS_MAX 64512
+#define QSB_GCR_MIN 18
+
+/*
+ * QSB Constant
+ */
+#define QSB_RAMAC_RW_READ 0
+#define QSB_RAMAC_RW_WRITE 1
+
+#define QSB_RAMAC_TSEL_QPT 0x01
+#define QSB_RAMAC_TSEL_SCT 0x02
+#define QSB_RAMAC_TSEL_SPT 0x03
+#define QSB_RAMAC_TSEL_VBR 0x08
+
+#define QSB_RAMAC_LH_LOW 0
+#define QSB_RAMAC_LH_HIGH 1
+
+#define QSB_QPT_SET_MASK 0x0
+#define QSB_QVPT_SET_MASK 0x0
+#define QSB_SET_SCT_MASK 0x0
+#define QSB_SET_SPT_MASK 0x0
+#define QSB_SET_SPT_SBVALID_MASK 0x7FFFFFFF
+
+#define QSB_SPT_SBV_VALID (1 << 31)
+#define QSB_SPT_PN_SET(value) (((value) & 0x01) ? (1 << 16) : 0)
+#define QSB_SPT_INTRATE_SET(value) SET_BITS(0, 13, 0, value)
+
+/*
+ * QSB Queue Parameter Table Entry and Queue VBR Parameter Table Entry
+ */
+#if defined(__BIG_ENDIAN)
+ union qsb_queue_parameter_table {
+ struct {
+ unsigned int res1 :1;
+ unsigned int vbr :1;
+ unsigned int wfqf :14;
+ unsigned int tp :16;
+ } bit;
+ u32 dword;
+ };
+
+ union qsb_queue_vbr_parameter_table {
+ struct {
+ unsigned int taus :16;
+ unsigned int ts :16;
+ } bit;
+ u32 dword;
+ };
+#else
+ union qsb_queue_parameter_table {
+ struct {
+ unsigned int tp :16;
+ unsigned int wfqf :14;
+ unsigned int vbr :1;
+ unsigned int res1 :1;
+ } bit;
+ u32 dword;
+ };
+
+ union qsb_queue_vbr_parameter_table {
+ struct {
+ unsigned int ts :16;
+ unsigned int taus :16;
+ } bit;
+ u32 dword;
+ };
+#endif // defined(__BIG_ENDIAN)
+
+/*
+ * Mailbox IGU0 Registers
+ */
+#define MBOX_IGU0_ISRS PPE_REG_ADDR(0x0200)
+#define MBOX_IGU0_ISRC PPE_REG_ADDR(0x0201)
+#define MBOX_IGU0_ISR PPE_REG_ADDR(0x0202)
+#define MBOX_IGU0_IER PPE_REG_ADDR(0x0203)
+
+#define MBOX_IGU0_ISRS_SET(n) (1 << (n))
+#define MBOX_IGU0_ISRC_CLEAR(n) (1 << (n))
+#define MBOX_IGU0_ISR_ISR(n) (*MBOX_IGU0_ISR & (1 << (n)))
+#define MBOX_IGU0_IER_EN(n) (*MBOX_IGU0_IER & (1 << (n)))
+#define MBOX_IGU0_IER_EN_SET(n) (1 << (n))
+
+/*
+ * Mailbox IGU1 Registers
+ */
+#define MBOX_IGU1_ISRS PPE_REG_ADDR(0x0204)
+#define MBOX_IGU1_ISRC PPE_REG_ADDR(0x0205)
+#define MBOX_IGU1_ISR PPE_REG_ADDR(0x0206)
+#define MBOX_IGU1_IER PPE_REG_ADDR(0x0207)
+
+#define MBOX_IGU1_ISRS_SET(n) (1 << (n))
+#define MBOX_IGU1_ISRC_CLEAR(n) (1 << (n))
+#define MBOX_IGU1_ISR_ISR(n) (*MBOX_IGU1_ISR & (1 << (n)))
+#define MBOX_IGU1_IER_EN(n) (*MBOX_IGU1_IER & (1 << (n)))
+#define MBOX_IGU1_IER_EN_SET(n) (1 << (n))
+
+/*
+ * Mailbox IGU3 Registers
+ */
+#define MBOX_IGU3_ISRS PPE_REG_ADDR(0x0214)
+#define MBOX_IGU3_ISRC PPE_REG_ADDR(0x0215)
+#define MBOX_IGU3_ISR PPE_REG_ADDR(0x0216)
+#define MBOX_IGU3_IER PPE_REG_ADDR(0x0217)
+
+#define MBOX_IGU3_ISRS_SET(n) (1 << (n))
+#define MBOX_IGU3_ISRC_CLEAR(n) (1 << (n))
+#define MBOX_IGU3_ISR_ISR(n) (*MBOX_IGU3_ISR & (1 << (n)))
+#define MBOX_IGU3_IER_EN(n) (*MBOX_IGU3_IER & (1 << (n)))
+#define MBOX_IGU3_IER_EN_SET(n) (1 << (n))
+
+/*
+ * RTHA/TTHA Registers
+ */
+#define RFBI_CFG PPE_REG_ADDR(0x0400)
+#define RBA_CFG0 PPE_REG_ADDR(0x0404)
+#define RBA_CFG1 PPE_REG_ADDR(0x0405)
+#define RCA_CFG0 PPE_REG_ADDR(0x0408)
+#define RCA_CFG1 PPE_REG_ADDR(0x0409)
+#define RDES_CFG0 PPE_REG_ADDR(0x040C)
+#define RDES_CFG1 PPE_REG_ADDR(0x040D)
+#define SFSM_STATE0 PPE_REG_ADDR(0x0410)
+#define SFSM_STATE1 PPE_REG_ADDR(0x0411)
+#define SFSM_DBA0 PPE_REG_ADDR(0x0412)
+#define SFSM_DBA1 PPE_REG_ADDR(0x0413)
+#define SFSM_CBA0 PPE_REG_ADDR(0x0414)
+#define SFSM_CBA1 PPE_REG_ADDR(0x0415)
+#define SFSM_CFG0 PPE_REG_ADDR(0x0416)
+#define SFSM_CFG1 PPE_REG_ADDR(0x0417)
+#define SFSM_PGCNT0 PPE_REG_ADDR(0x041C)
+#define SFSM_PGCNT1 PPE_REG_ADDR(0x041D)
+#define FFSM_DBA0 PPE_REG_ADDR(0x0508)
+#define FFSM_DBA1 PPE_REG_ADDR(0x0509)
+#define FFSM_CFG0 PPE_REG_ADDR(0x050A)
+#define FFSM_CFG1 PPE_REG_ADDR(0x050B)
+#define FFSM_IDLE_HEAD_BC0 PPE_REG_ADDR(0x050E)
+#define FFSM_IDLE_HEAD_BC1 PPE_REG_ADDR(0x050F)
+#define FFSM_PGCNT0 PPE_REG_ADDR(0x0514)
+#define FFSM_PGCNT1 PPE_REG_ADDR(0x0515)
+
+/*
+ * PPE TC Logic Registers (partial)
+ */
+#define DREG_A_VERSION PPE_REG_ADDR(0x0D00)
+#define DREG_A_CFG PPE_REG_ADDR(0x0D01)
+#define DREG_AT_CTRL PPE_REG_ADDR(0x0D02)
+#define DREG_AT_CB_CFG0 PPE_REG_ADDR(0x0D03)
+#define DREG_AT_CB_CFG1 PPE_REG_ADDR(0x0D04)
+#define DREG_AR_CTRL PPE_REG_ADDR(0x0D08)
+#define DREG_AR_CB_CFG0 PPE_REG_ADDR(0x0D09)
+#define DREG_AR_CB_CFG1 PPE_REG_ADDR(0x0D0A)
+#define DREG_A_UTPCFG PPE_REG_ADDR(0x0D0E)
+#define DREG_A_STATUS PPE_REG_ADDR(0x0D0F)
+#define DREG_AT_CFG0 PPE_REG_ADDR(0x0D20)
+#define DREG_AT_CFG1 PPE_REG_ADDR(0x0D21)
+#define DREG_AT_FB_SIZE0 PPE_REG_ADDR(0x0D22)
+#define DREG_AT_FB_SIZE1 PPE_REG_ADDR(0x0D23)
+#define DREG_AT_CELL0 PPE_REG_ADDR(0x0D24)
+#define DREG_AT_CELL1 PPE_REG_ADDR(0x0D25)
+#define DREG_AT_IDLE_CNT0 PPE_REG_ADDR(0x0D26)
+#define DREG_AT_IDLE_CNT1 PPE_REG_ADDR(0x0D27)
+#define DREG_AT_IDLE0 PPE_REG_ADDR(0x0D28)
+#define DREG_AT_IDLE1 PPE_REG_ADDR(0x0D29)
+#define DREG_AR_CFG0 PPE_REG_ADDR(0x0D60)
+#define DREG_AR_CFG1 PPE_REG_ADDR(0x0D61)
+#define DREG_AR_CELL0 PPE_REG_ADDR(0x0D68)
+#define DREG_AR_CELL1 PPE_REG_ADDR(0x0D69)
+#define DREG_AR_IDLE_CNT0 PPE_REG_ADDR(0x0D6A)
+#define DREG_AR_IDLE_CNT1 PPE_REG_ADDR(0x0D6B)
+#define DREG_AR_AIIDLE_CNT0 PPE_REG_ADDR(0x0D6C)
+#define DREG_AR_AIIDLE_CNT1 PPE_REG_ADDR(0x0D6D)
+#define DREG_AR_BE_CNT0 PPE_REG_ADDR(0x0D6E)
+#define DREG_AR_BE_CNT1 PPE_REG_ADDR(0x0D6F)
+#define DREG_AR_HEC_CNT0 PPE_REG_ADDR(0x0D70)
+#define DREG_AR_HEC_CNT1 PPE_REG_ADDR(0x0D71)
+#define DREG_AR_IDLE0 PPE_REG_ADDR(0x0D74)
+#define DREG_AR_IDLE1 PPE_REG_ADDR(0x0D75)
+#define DREG_AR_CERRN_CNT0 PPE_REG_ADDR(0x0DA0)
+#define DREG_AR_CERRN_CNT1 PPE_REG_ADDR(0x0DA1)
+#define DREG_AR_CERRNP_CNT0 PPE_REG_ADDR(0x0DA2)
+#define DREG_AR_CERRNP_CNT1 PPE_REG_ADDR(0x0DA3)
+#define DREG_AR_CVN_CNT0 PPE_REG_ADDR(0x0DA4)
+#define DREG_AR_CVN_CNT1 PPE_REG_ADDR(0x0DA5)
+#define DREG_AR_CVNP_CNT0 PPE_REG_ADDR(0x0DA6)
+#define DREG_AR_CVNP_CNT1 PPE_REG_ADDR(0x0DA7)
+#define DREG_B0_LADR PPE_REG_ADDR(0x0DA8)
+#define DREG_B1_LADR PPE_REG_ADDR(0x0DA9)
+
+
+
+#endif // IFXMIPS_PTM_PPE_COMMON_H
diff --git a/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_ppe_danube.h b/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_ppe_danube.h
new file mode 100644
index 0000000..5f896e6
--- /dev/null
+++ b/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_ppe_danube.h
@@ -0,0 +1,135 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_ptm_ppe_danube.h
+** PROJECT : UEIP
+** MODULES : PTM
+**
+** DATE : 7 Jul 2009
+** AUTHOR : Xu Liang
+** DESCRIPTION : PTM driver header file (PPE register for Danube)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 07 JUL 2009 Xu Liang Init Version
+*******************************************************************************/
+
+
+
+#ifndef IFXMIPS_PTM_PPE_DANUBE_H
+#define IFXMIPS_PTM_PPE_DANUBE_H
+
+
+
+/*
+ * FPI Configuration Bus Register and Memory Address Mapping
+ */
+#define IFX_PPE (KSEG1 | 0x1E180000)
+#define PP32_DEBUG_REG_ADDR(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x0000) << 2)))
+#define PPM_INT_REG_ADDR(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x0030) << 2)))
+#define PP32_INTERNAL_RES_ADDR(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x0040) << 2)))
+#define CDM_CODE_MEMORY(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x1000) << 2)))
+#define PPE_REG_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x4000) << 2)))
+#define CDM_DATA_MEMORY(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x5000) << 2)))
+#define PPM_INT_UNIT_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6000) << 2)))
+#define PPM_TIMER0_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6100) << 2)))
+#define PPM_TASK_IND_REG_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6200) << 2)))
+#define PPS_BRK_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6300) << 2)))
+#define PPM_TIMER1_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x6400) << 2)))
+#define SB_RAM0_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x8000) << 2)))
+#define SB_RAM1_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x8400) << 2)))
+#define SB_RAM2_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x8C00) << 2)))
+#define SB_RAM3_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x9600) << 2)))
+#define QSB_CONF_REG_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0xC000) << 2)))
+
+/*
+ * DWORD-Length of Memory Blocks
+ */
+#define PP32_DEBUG_REG_DWLEN 0x0030
+#define PPM_INT_REG_DWLEN 0x0010
+#define PP32_INTERNAL_RES_DWLEN 0x00C0
+#define CDM_CODE_MEMORYn_DWLEN(n) ((n) == 0 ? 0x1000 : 0x0800)
+#define PPE_REG_DWLEN 0x1000
+#define CDM_DATA_MEMORY_DWLEN CDM_CODE_MEMORYn_DWLEN(1)
+#define PPM_INT_UNIT_DWLEN 0x0100
+#define PPM_TIMER0_DWLEN 0x0100
+#define PPM_TASK_IND_REG_DWLEN 0x0100
+#define PPS_BRK_DWLEN 0x0100
+#define PPM_TIMER1_DWLEN 0x0100
+#define SB_RAM0_DWLEN 0x0400
+#define SB_RAM1_DWLEN 0x0800
+#define SB_RAM2_DWLEN 0x0A00
+#define SB_RAM3_DWLEN 0x0400
+#define QSB_CONF_REG_DWLEN 0x0100
+
+/*
+ * PP32 to FPI Address Mapping
+ */
+#define SB_BUFFER(__sb_addr) ((volatile unsigned int *)((((__sb_addr) >= 0x2000) && ((__sb_addr) <= 0x23FF)) ? SB_RAM0_ADDR((__sb_addr) - 0x2000) : \
+ (((__sb_addr) >= 0x2400) && ((__sb_addr) <= 0x2BFF)) ? SB_RAM1_ADDR((__sb_addr) - 0x2400) : \
+ (((__sb_addr) >= 0x2C00) && ((__sb_addr) <= 0x35FF)) ? SB_RAM2_ADDR((__sb_addr) - 0x2C00) : \
+ (((__sb_addr) >= 0x3600) && ((__sb_addr) <= 0x39FF)) ? SB_RAM3_ADDR((__sb_addr) - 0x3600) : \
+ 0))
+
+/*
+ * PP32 Debug Control Register
+ */
+#define PP32_DBG_CTRL PP32_DEBUG_REG_ADDR(0, 0x0000)
+
+#define DBG_CTRL_START_SET(value) ((value) ? (1 << 0) : 0)
+#define DBG_CTRL_STOP_SET(value) ((value) ? (1 << 1) : 0)
+#define DBG_CTRL_STEP_SET(value) ((value) ? (1 << 2) : 0)
+
+#define PP32_HALT_STAT PP32_DEBUG_REG_ADDR(0, 0x0001)
+
+#define PP32_BRK_SRC PP32_DEBUG_REG_ADDR(0, 0x0002)
+ #define PP32_BRK_SRC_PC(i) (1 << (i))
+ #define PP32_BRK_SRC_DATA(i, cmd) ((cmd) << ((i) * 3 + 8))
+
+#define PP32_DBG_PC_MIN(i) PP32_DEBUG_REG_ADDR(0, 0x0010 + (i))
+#define PP32_DBG_PC_MAX(i) PP32_DEBUG_REG_ADDR(0, 0x0014 + (i))
+#define PP32_DBG_DATA_MIN(i) PP32_DEBUG_REG_ADDR(0, 0x0018 + (i))
+#define PP32_DBG_DATA_MAX(i) PP32_DEBUG_REG_ADDR(0, 0x001A + (i))
+#define PP32_DBG_DATA_VAL(i) PP32_DEBUG_REG_ADDR(0, 0x001C + (i))
+
+#define PP32_DBG_TASK_GPR(task, i) PP32_DEBUG_REG_ADDR(0, 0x0040 + (task) * 0x0010 + (i))
+
+#define PP32_DBG_CUR_PC PP32_DEBUG_REG_ADDR(0, 0x0080)
+#define PP32_DBG_TASK_NO PP32_DEBUG_REG_ADDR(0, 0x0081)
+#define PP32_DBG_TASK_PRIO PP32_DEBUG_REG_ADDR(0, 0x0086)
+#define PP32_DBG_PC_OF_TASK(i) PP32_DEBUG_REG_ADDR(0, 0x0087 + (i))
+
+/*
+ * Share Buffer Registers
+ */
+#define SB_MST_SEL PPE_REG_ADDR(0x0304)
+
+/*
+ * EMA Registers
+ */
+#define EMA_CMDCFG PPE_REG_ADDR(0x0A00)
+#define EMA_DATACFG PPE_REG_ADDR(0x0A01)
+#define EMA_CMDCNT PPE_REG_ADDR(0x0A02)
+#define EMA_DATACNT PPE_REG_ADDR(0x0A03)
+#define EMA_ISR PPE_REG_ADDR(0x0A04)
+#define EMA_IER PPE_REG_ADDR(0x0A05)
+#define EMA_CFG PPE_REG_ADDR(0x0A06)
+#define EMA_SUBID PPE_REG_ADDR(0x0A07)
+
+#define EMA_ALIGNMENT 4
+
+/*
+ * Mailbox IGU1 Interrupt
+ */
+#define PPE_MAILBOX_IGU1_INT INT_NUM_IM2_IRL24
+
+
+
+#endif // IFXMIPS_PTM_PPE_DANUBE_H
diff --git a/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_ppe_vr9.h b/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_ppe_vr9.h
new file mode 100644
index 0000000..4a8c2f7
--- /dev/null
+++ b/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_ppe_vr9.h
@@ -0,0 +1,205 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_ptm_ppe_vr9.h
+** PROJECT : UEIP
+** MODULES : PTM
+**
+** DATE : 7 Jul 2009
+** AUTHOR : Xu Liang
+** DESCRIPTION : PTM driver header file (PPE register for VR9)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 07 JUL 2009 Xu Liang Init Version
+*******************************************************************************/
+
+
+
+#ifndef IFXMIPS_PTM_PPE_VR9_H
+#define IFXMIPS_PTM_PPE_VR9_H
+
+
+
+/*
+ * FPI Configuration Bus Register and Memory Address Mapping
+ */
+#define IFX_PPE (KSEG1 | 0x1E200000)
+#define PP32_DEBUG_REG_ADDR(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x000000 + (i) * 0x00010000) << 2)))
+#define CDM_CODE_MEMORY(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x001000 + (i) * 0x00010000) << 2)))
+#define CDM_DATA_MEMORY(i, x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x004000 + (i) * 0x00010000) << 2)))
+#define SB_RAM0_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x008000) << 2)))
+#define SB_RAM1_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x009000) << 2)))
+#define SB_RAM2_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x00A000) << 2)))
+#define SB_RAM3_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x00B000) << 2)))
+#define PPE_REG_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x00D000) << 2)))
+#define QSB_CONF_REG_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x00E000) << 2)))
+#define SB_RAM6_ADDR(x) ((volatile unsigned int*)(IFX_PPE + (((x) + 0x018000) << 2)))
+
+/*
+ * DWORD-Length of Memory Blocks
+ */
+#define PP32_DEBUG_REG_DWLEN 0x0030
+#define CDM_CODE_MEMORYn_DWLEN(n) ((n) == 0 ? 0x1000 : 0x0800)
+#define CDM_DATA_MEMORY_DWLEN CDM_CODE_MEMORYn_DWLEN(1)
+#define SB_RAM0_DWLEN 0x1000
+#define SB_RAM1_DWLEN 0x1000
+#define SB_RAM2_DWLEN 0x1000
+#define SB_RAM3_DWLEN 0x1000
+#define SB_RAM6_DWLEN 0x8000
+#define QSB_CONF_REG_DWLEN 0x0100
+
+/*
+ * PP32 to FPI Address Mapping
+ */
+#define SB_BUFFER(__sb_addr) ((volatile unsigned int *)((((__sb_addr) >= 0x0000) && ((__sb_addr) <= 0x1FFF)) ? PPE_REG_ADDR((__sb_addr)) : \
+ (((__sb_addr) >= 0x2000) && ((__sb_addr) <= 0x2FFF)) ? SB_RAM0_ADDR((__sb_addr) - 0x2000) : \
+ (((__sb_addr) >= 0x3000) && ((__sb_addr) <= 0x3FFF)) ? SB_RAM1_ADDR((__sb_addr) - 0x3000) : \
+ (((__sb_addr) >= 0x4000) && ((__sb_addr) <= 0x4FFF)) ? SB_RAM2_ADDR((__sb_addr) - 0x4000) : \
+ (((__sb_addr) >= 0x5000) && ((__sb_addr) <= 0x5FFF)) ? SB_RAM3_ADDR((__sb_addr) - 0x5000) : \
+ (((__sb_addr) >= 0x7000) && ((__sb_addr) <= 0x7FFF)) ? PPE_REG_ADDR((__sb_addr) - 0x7000) : \
+ (((__sb_addr) >= 0x8000) && ((__sb_addr) <= 0xFFFF)) ? SB_RAM6_ADDR((__sb_addr) - 0x8000) : \
+ 0))
+
+/*
+ * PP32 Debug Control Register
+ */
+#define NUM_OF_PP32 2
+
+#define PP32_FREEZE PPE_REG_ADDR(0x0000)
+#define PP32_SRST PPE_REG_ADDR(0x0020)
+
+#define PP32_DBG_CTRL(n) PP32_DEBUG_REG_ADDR(n, 0x0000)
+
+#define DBG_CTRL_RESTART 0
+#define DBG_CTRL_STOP 1
+
+#define PP32_CTRL_CMD(n) PP32_DEBUG_REG_ADDR(n, 0x0B00)
+ #define PP32_CTRL_CMD_RESTART (1 << 0)
+ #define PP32_CTRL_CMD_STOP (1 << 1)
+ #define PP32_CTRL_CMD_STEP (1 << 2)
+ #define PP32_CTRL_CMD_BREAKOUT (1 << 3)
+
+#define PP32_CTRL_OPT(n) PP32_DEBUG_REG_ADDR(n, 0x0C00)
+ #define PP32_CTRL_OPT_BREAKOUT_ON_STOP_ON (3 << 0)
+ #define PP32_CTRL_OPT_BREAKOUT_ON_STOP_OFF (2 << 0)
+ #define PP32_CTRL_OPT_BREAKOUT_ON_BREAKIN_ON (3 << 2)
+ #define PP32_CTRL_OPT_BREAKOUT_ON_BREAKIN_OFF (2 << 2)
+ #define PP32_CTRL_OPT_STOP_ON_BREAKIN_ON (3 << 4)
+ #define PP32_CTRL_OPT_STOP_ON_BREAKIN_OFF (2 << 4)
+ #define PP32_CTRL_OPT_STOP_ON_BREAKPOINT_ON (3 << 6)
+ #define PP32_CTRL_OPT_STOP_ON_BREAKPOINT_OFF (2 << 6)
+ #define PP32_CTRL_OPT_BREAKOUT_ON_STOP(n) (*PP32_CTRL_OPT(n) & (1 << 0))
+ #define PP32_CTRL_OPT_BREAKOUT_ON_BREAKIN(n) (*PP32_CTRL_OPT(n) & (1 << 2))
+ #define PP32_CTRL_OPT_STOP_ON_BREAKIN(n) (*PP32_CTRL_OPT(n) & (1 << 4))
+ #define PP32_CTRL_OPT_STOP_ON_BREAKPOINT(n) (*PP32_CTRL_OPT(n) & (1 << 6))
+
+#define PP32_BRK_PC(n, i) PP32_DEBUG_REG_ADDR(n, 0x0900 + (i) * 2)
+#define PP32_BRK_PC_MASK(n, i) PP32_DEBUG_REG_ADDR(n, 0x0901 + (i) * 2)
+#define PP32_BRK_DATA_ADDR(n, i) PP32_DEBUG_REG_ADDR(n, 0x0904 + (i) * 2)
+#define PP32_BRK_DATA_ADDR_MASK(n, i) PP32_DEBUG_REG_ADDR(n, 0x0905 + (i) * 2)
+#define PP32_BRK_DATA_VALUE_RD(n, i) PP32_DEBUG_REG_ADDR(n, 0x0908 + (i) * 2)
+#define PP32_BRK_DATA_VALUE_RD_MASK(n, i) PP32_DEBUG_REG_ADDR(n, 0x0909 + (i) * 2)
+#define PP32_BRK_DATA_VALUE_WR(n, i) PP32_DEBUG_REG_ADDR(n, 0x090C + (i) * 2)
+#define PP32_BRK_DATA_VALUE_WR_MASK(n, i) PP32_DEBUG_REG_ADDR(n, 0x090D + (i) * 2)
+ #define PP32_BRK_CONTEXT_MASK(i) (1 << (i))
+ #define PP32_BRK_CONTEXT_MASK_EN (1 << 4)
+ #define PP32_BRK_COMPARE_GREATER_EQUAL (1 << 5) // valid for break data value rd/wr only
+ #define PP32_BRK_COMPARE_LOWER_EQUAL (1 << 6)
+ #define PP32_BRK_COMPARE_EN (1 << 7)
+
+#define PP32_BRK_TRIG(n) PP32_DEBUG_REG_ADDR(n, 0x0F00)
+ #define PP32_BRK_GRPi_PCn_ON(i, n) ((3 << ((n) * 2)) << ((i) * 16))
+ #define PP32_BRK_GRPi_PCn_OFF(i, n) ((2 << ((n) * 2)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_ADDRn_ON(i, n) ((3 << ((n) * 2 + 4)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_ADDRn_OFF(i, n) ((2 << ((n) * 2 + 4)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_VALUE_RDn_ON(i, n) ((3 << ((n) * 2 + 8)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_VALUE_RDn_OFF(i, n)((2 << ((n) * 2 + 8)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_VALUE_WRn_ON(i, n) ((3 << ((n) * 2 + 12)) << ((i) * 16))
+ #define PP32_BRK_GRPi_DATA_VALUE_WRn_OFF(i, n)((2 << ((n) * 2 + 12)) << ((i) * 16))
+ #define PP32_BRK_GRPi_PCn(k, i, n) (*PP32_BRK_TRIG(k) & ((1 << ((n))) << ((i) * 8)))
+ #define PP32_BRK_GRPi_DATA_ADDRn(k, i, n) (*PP32_BRK_TRIG(k) & ((1 << ((n) + 2)) << ((i) * 8)))
+ #define PP32_BRK_GRPi_DATA_VALUE_RDn(k, i, n) (*PP32_BRK_TRIG(k) & ((1 << ((n) + 4)) << ((i) * 8)))
+ #define PP32_BRK_GRPi_DATA_VALUE_WRn(k, i, n) (*PP32_BRK_TRIG(k) & ((1 << ((n) + 6)) << ((i) * 8)))
+
+#define PP32_CPU_STATUS(n) PP32_DEBUG_REG_ADDR(n, 0x0D00)
+#define PP32_HALT_STAT(n) PP32_CPU_STATUS(n)
+#define PP32_DBG_CUR_PC(n) PP32_CPU_STATUS(n)
+ #define PP32_CPU_USER_STOPPED(n) (*PP32_CPU_STATUS(n) & (1 << 0))
+ #define PP32_CPU_USER_BREAKIN_RCV(n) (*PP32_CPU_STATUS(n) & (1 << 1))
+ #define PP32_CPU_USER_BREAKPOINT_MET(n) (*PP32_CPU_STATUS(n) & (1 << 2))
+ #define PP32_CPU_CUR_PC(n) (*PP32_CPU_STATUS(n) >> 16)
+
+#define PP32_BREAKPOINT_REASONS(n) PP32_DEBUG_REG_ADDR(n, 0x0A00)
+ #define PP32_BRK_PC_MET(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << (i)))
+ #define PP32_BRK_DATA_ADDR_MET(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) + 2)))
+ #define PP32_BRK_DATA_VALUE_RD_MET(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) + 4)))
+ #define PP32_BRK_DATA_VALUE_WR_MET(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) + 6)))
+ #define PP32_BRK_DATA_VALUE_RD_LO_EQ(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) * 2 + 8)))
+ #define PP32_BRK_DATA_VALUE_RD_GT_EQ(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) * 2 + 9)))
+ #define PP32_BRK_DATA_VALUE_WR_LO_EQ(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) * 2 + 12)))
+ #define PP32_BRK_DATA_VALUE_WR_GT_EQ(n, i) (*PP32_BREAKPOINT_REASONS(n) & (1 << ((i) * 2 + 13)))
+ #define PP32_BRK_CUR_CONTEXT(n) ((*PP32_BREAKPOINT_REASONS(n) >> 16) & 0x03)
+
+#define PP32_GP_REG_BASE(n) PP32_DEBUG_REG_ADDR(n, 0x0E00)
+#define PP32_GP_CONTEXTi_REGn(n, i, j) PP32_DEBUG_REG_ADDR(n, 0x0E00 + (i) * 16 + (j))
+
+/*
+ * SAR Registers
+ */
+#define SAR_MODE_CFG PPE_REG_ADDR(0x080A)
+#define SAR_RX_CMD_CNT PPE_REG_ADDR(0x080B)
+#define SAR_TX_CMD_CNT PPE_REG_ADDR(0x080C)
+#define SAR_RX_CTX_CFG PPE_REG_ADDR(0x080D)
+#define SAR_TX_CTX_CFG PPE_REG_ADDR(0x080E)
+#define SAR_TX_CMD_DONE_CNT PPE_REG_ADDR(0x080F)
+#define SAR_POLY_CFG_SET0 PPE_REG_ADDR(0x0812)
+#define SAR_POLY_CFG_SET1 PPE_REG_ADDR(0x0813)
+#define SAR_POLY_CFG_SET2 PPE_REG_ADDR(0x0814)
+#define SAR_POLY_CFG_SET3 PPE_REG_ADDR(0x0815)
+#define SAR_CRC_SIZE_CFG PPE_REG_ADDR(0x0816)
+
+/*
+ * PDMA/EMA Registers
+ */
+#define PDMA_CFG PPE_REG_ADDR(0x0A00)
+#define PDMA_RX_CMDCNT PPE_REG_ADDR(0x0A01)
+#define PDMA_TX_CMDCNT PPE_REG_ADDR(0x0A02)
+#define PDMA_RX_FWDATACNT PPE_REG_ADDR(0x0A03)
+#define PDMA_TX_FWDATACNT PPE_REG_ADDR(0x0A04)
+#define PDMA_RX_CTX_CFG PPE_REG_ADDR(0x0A05)
+#define PDMA_TX_CTX_CFG PPE_REG_ADDR(0x0A06)
+#define PDMA_RX_MAX_LEN_REG PPE_REG_ADDR(0x0A07)
+#define PDMA_RX_DELAY_CFG PPE_REG_ADDR(0x0A08)
+#define PDMA_INT_FIFO_RD PPE_REG_ADDR(0x0A09)
+#define PDMA_ISR PPE_REG_ADDR(0x0A0A)
+#define PDMA_IER PPE_REG_ADDR(0x0A0B)
+#define PDMA_SUBID PPE_REG_ADDR(0x0A0C)
+#define PDMA_BAR0 PPE_REG_ADDR(0x0A0D)
+#define PDMA_BAR1 PPE_REG_ADDR(0x0A0E)
+
+#define SAR_PDMA_RX_CMDBUF_CFG PPE_REG_ADDR(0x0F00)
+#define SAR_PDMA_TX_CMDBUF_CFG PPE_REG_ADDR(0x0F01)
+#define SAR_PDMA_RX_FW_CMDBUF_CFG PPE_REG_ADDR(0x0F02)
+#define SAR_PDMA_TX_FW_CMDBUF_CFG PPE_REG_ADDR(0x0F03)
+#define SAR_PDMA_RX_CMDBUF_STATUS PPE_REG_ADDR(0x0F04)
+#define SAR_PDMA_TX_CMDBUF_STATUS PPE_REG_ADDR(0x0F05)
+
+#define PDMA_ALIGNMENT 32 // same as Central DMA because of descriptor swap
+#define EMA_ALIGNMENT PDMA_ALIGNMENT
+
+/*
+ * Mailbox IGU1 Interrupt
+ */
+#define PPE_MAILBOX_IGU1_INT INT_NUM_IM2_IRL24
+
+
+
+#endif // IFXMIPS_PTM_PPE_VR9_H
diff --git a/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_test.c b/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_test.c
new file mode 100644
index 0000000..15d8352
--- /dev/null
+++ b/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_test.c
@@ -0,0 +1,943 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_ptm_vdsl.c
+** PROJECT : UEIP
+** MODULES : PTM
+**
+** DATE : 7 Jul 2009
+** AUTHOR : Xu Liang
+** DESCRIPTION : PTM driver common source file (core functions for VR9)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 07 JUL 2009 Xu Liang Init Version
+*******************************************************************************/
+
+
+
+#ifdef CONFIG_IFX_PTM_TEST_PROC
+
+/*
+ * ####################################
+ * Head File
+ * ####################################
+ */
+
+/*
+ * Common Head File
+ */
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/version.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/proc_fs.h>
+#include <linux/init.h>
+#include <linux/ioctl.h>
+#include <linux/etherdevice.h>
+
+/*
+ * Chip Specific Head File
+ */
+#include <asm/ifx/ifx_types.h>
+#include <asm/ifx/ifx_regs.h>
+#include <asm/ifx/common_routines.h>
+#include "ifxmips_ptm_common.h"
+#include "ifxmips_ptm_ppe_common.h"
+
+
+
+/*
+ * ####################################
+ * Definition
+ * ####################################
+ */
+
+
+
+/*
+ * ####################################
+ * Declaration
+ * ####################################
+ */
+
+/*
+ * Proc File Functions
+ */
+static inline void proc_file_create(void);
+static inline void proc_file_delete(void);
+
+/*
+ * Proc Help Functions
+ */
+static int proc_write_mem(struct file *, const char *, unsigned long, void *);
+static int proc_read_pp32(char *, char **, off_t, int, int *, void *);
+static int proc_write_pp32(struct file *, const char *, unsigned long, void *);
+static int stricmp(const char *, const char *);
+static int strincmp(const char *, const char *, int);
+static int get_token(char **, char **, int *, int *);
+static int get_number(char **, int *, int);
+static inline void ignore_space(char **, int *);
+
+
+
+/*
+ * ####################################
+ * Local Variable
+ * ####################################
+ */
+
+
+
+/*
+ * ####################################
+ * Local Function
+ * ####################################
+ */
+
+static inline void proc_file_create(void)
+{
+ struct proc_dir_entry *res;
+
+ res = create_proc_entry("driver/ifx_ptm/mem",
+ 0,
+ NULL);
+ if ( res != NULL )
+ res->write_proc = proc_write_mem;
+ else
+ printk("%s:%s:%d: failed to create proc mem!", __FILE__, __func__, __LINE__);
+
+ res = create_proc_entry("driver/ifx_ptm/pp32",
+ 0,
+ NULL);
+ if ( res != NULL ) {
+ res->read_proc = proc_read_pp32;
+ res->write_proc = proc_write_pp32;
+ }
+ else
+ printk("%s:%s:%d: failed to create proc pp32!", __FILE__, __func__, __LINE__);
+}
+
+static inline void proc_file_delete(void)
+{
+ remove_proc_entry("driver/ifx_ptm/pp32", NULL);
+
+ remove_proc_entry("driver/ifx_ptm/mem", NULL);
+}
+
+static inline unsigned long sb_addr_to_fpi_addr_convert(unsigned long sb_addr)
+{
+#define PP32_SB_ADDR_END 0xFFFF
+
+ if ( sb_addr < PP32_SB_ADDR_END) {
+ return (unsigned long ) SB_BUFFER(sb_addr);
+ }
+ else {
+ return sb_addr;
+ }
+}
+
+static int proc_write_mem(struct file *file, const char *buf, unsigned long count, void *data)
+{
+ char *p1, *p2;
+ int len;
+ int colon;
+ unsigned long *p;
+ char local_buf[1024];
+ int i, n, l;
+
+ len = sizeof(local_buf) < count ? sizeof(local_buf) - 1 : count;
+ len = len - copy_from_user(local_buf, buf, len);
+ local_buf[len] = 0;
+
+ p1 = local_buf;
+ colon = 1;
+ while ( get_token(&p1, &p2, &len, &colon) )
+ {
+ if ( stricmp(p1, "w") == 0 || stricmp(p1, "write") == 0 || stricmp(p1, "r") == 0 || stricmp(p1, "read") == 0 )
+ break;
+
+ p1 = p2;
+ colon = 1;
+ }
+
+ if ( *p1 == 'w' )
+ {
+ ignore_space(&p2, &len);
+ p = (unsigned long *)get_number(&p2, &len, 1);
+ p = (unsigned long *)sb_addr_to_fpi_addr_convert( (unsigned long) p);
+
+ if ( (u32)p >= KSEG0 )
+ while ( 1 )
+ {
+ ignore_space(&p2, &len);
+ if ( !len || !((*p2 >= '0' && *p2 <= '9') || (*p2 >= 'a' && *p2 <= 'f') || (*p2 >= 'A' && *p2 <= 'F')) )
+ break;
+
+ *p++ = (u32)get_number(&p2, &len, 1);
+ }
+ }
+ else if ( *p1 == 'r' )
+ {
+ ignore_space(&p2, &len);
+ p = (unsigned long *)get_number(&p2, &len, 1);
+ p = (unsigned long *)sb_addr_to_fpi_addr_convert( (unsigned long) p);
+
+ if ( (u32)p >= KSEG0 )
+ {
+ ignore_space(&p2, &len);
+ n = (int)get_number(&p2, &len, 0);
+ if ( n )
+ {
+ char str[32] = {0};
+ char *pch = str;
+ int k;
+ u32 data;
+ char c;
+
+ n += (l = ((int)p >> 2) & 0x03);
+ p = (unsigned long *)((u32)p & ~0x0F);
+ for ( i = 0; i < n; i++ )
+ {
+ if ( (i & 0x03) == 0 )
+ {
+ printk("%08X:", (u32)p);
+ pch = str;
+ }
+ if ( i < l )
+ {
+ printk(" ");
+ sprintf(pch, " ");
+ }
+ else
+ {
+ data = (u32)*p;
+ printk(" %08X", data);
+ for ( k = 0; k < 4; k++ )
+ {
+ c = ((char*)&data)[k];
+ pch[k] = c < ' ' ? '.' : c;
+ }
+ }
+ p++;
+ pch += 4;
+ if ( (i & 0x03) == 0x03 )
+ {
+ pch[0] = 0;
+ printk(" ; %s\n", str);
+ }
+ }
+ if ( (n & 0x03) != 0x00 )
+ {
+ for ( k = 4 - (n & 0x03); k > 0; k-- )
+ printk(" ");
+ pch[0] = 0;
+ printk(" ; %s\n", str);
+ }
+ }
+ }
+ }
+
+ return count;
+}
+
+#ifdef CONFIG_DANUBE
+
+static int proc_read_pp32(char *page, char **start, off_t off, int count, int *eof, void *data)
+{
+ static const char *halt_stat[] = {
+ "reset",
+ "break in line",
+ "stop",
+ "step",
+ "code",
+ "data0",
+ "data1"
+ };
+ static const char *brk_src_data[] = {
+ "off",
+ "read",
+ "write",
+ "read/write",
+ "write_equal",
+ "N/A",
+ "N/A",
+ "N/A"
+ };
+ static const char *brk_src_code[] = {
+ "off",
+ "on"
+ };
+
+ int len = 0;
+ int cur_task;
+ int i, j;
+ int k;
+ unsigned long bit;
+
+ len += sprintf(page + off + len, "Task No %d, PC %04x\n", *PP32_DBG_TASK_NO & 0x03, *PP32_DBG_CUR_PC & 0xFFFF);
+
+ if ( !(*PP32_HALT_STAT & 0x01) )
+ len += sprintf(page + off + len, " Halt State: Running\n");
+ else
+ {
+ len += sprintf(page + off + len, " Halt State: Stopped");
+ k = 0;
+ for ( bit = 2, i = 0; bit <= (1 << 7); bit <<= 1, i++ )
+ if ( (*PP32_HALT_STAT & bit) )
+ {
+ if ( !k )
+ {
+ len += sprintf(page + off + len, ", ");
+ k++;
+ }
+ else
+ len += sprintf(page + off + len, " | ");
+ len += sprintf(page + off + len, halt_stat[i]);
+ }
+
+ len += sprintf(page + off + len, "\n");
+
+ cur_task = *PP32_DBG_TASK_NO & 0x03;
+ len += sprintf(page + off + len, "General Purpose Register (Task %d):\n", cur_task);
+ for ( i = 0; i < 4; i++ )
+ {
+ for ( j = 0; j < 4; j++ )
+ len += sprintf(page + off + len, " %2d: %08x", i + j * 4, *PP32_DBG_TASK_GPR(cur_task, i + j * 4));
+ len += sprintf(page + off + len, "\n");
+ }
+ }
+
+ len += sprintf(page + off + len, " Break Src: data1 - %s, data0 - %s, pc3 - %s, pc2 - %s, pc1 - %s, pc0 - %s\n",
+ brk_src_data[(*PP32_BRK_SRC >> 11) & 0x07], brk_src_data[(*PP32_BRK_SRC >> 8) & 0x07], brk_src_code[(*PP32_BRK_SRC >> 3) & 0x01], brk_src_code[(*PP32_BRK_SRC >> 2) & 0x01], brk_src_code[(*PP32_BRK_SRC >> 1) & 0x01], brk_src_code[*PP32_BRK_SRC & 0x01]);
+
+ for ( i = 0; i < 4; i++ )
+ len += sprintf(page + off + len, " pc%d: %04x - %04x\n", i, *PP32_DBG_PC_MIN(i), *PP32_DBG_PC_MAX(i));
+
+ for ( i = 0; i < 2; i++ )
+ len += sprintf(page + off + len, " data%d: %04x - %04x (%08x)\n", i, *PP32_DBG_DATA_MIN(i), *PP32_DBG_DATA_MAX(i), *PP32_DBG_DATA_VAL(i));
+
+ *eof = 1;
+
+ return len;
+}
+
+static int proc_write_pp32(struct file *file, const char *buf, unsigned long count, void *data)
+{
+ char str[2048];
+ char *p;
+ int len, rlen;
+
+ int id;
+ u32 addr;
+ u32 cmd;
+
+ len = count < sizeof(str) ? count : sizeof(str) - 1;
+ rlen = len - copy_from_user(str, buf, len);
+ while ( rlen && str[rlen - 1] <= ' ' )
+ rlen--;
+ str[rlen] = 0;
+ for ( p = str; *p && *p <= ' '; p++, rlen-- );
+ if ( !*p )
+ {
+ return 0;
+ }
+
+ if ( stricmp(str, "start") == 0 )
+ *PP32_DBG_CTRL = DBG_CTRL_START_SET(1);
+ else if ( stricmp(str, "stop") == 0 )
+ *PP32_DBG_CTRL = DBG_CTRL_STOP_SET(1);
+ else if ( stricmp(str, "step") == 0 )
+ *PP32_DBG_CTRL = DBG_CTRL_STEP_SET(1);
+ else if ( strincmp(p, "pc", 2) == 0 && p[2] >= '0' && p[2] <= '3' && p[3] == ' ' )
+ {
+ id = (int)(p[2] - '0');
+ p += 4;
+ rlen -= 4;
+ *PP32_BRK_SRC &= ~PP32_BRK_SRC_PC(id);
+ if ( stricmp(p, "off") != 0 )
+ {
+ ignore_space(&p, &rlen);
+ *PP32_DBG_PC_MIN(id) = *PP32_DBG_PC_MAX(id) = get_number(&p, &rlen, 1);
+ ignore_space(&p, &rlen);
+ if ( rlen > 0 )
+ {
+ addr = get_number(&p, &rlen, 1);
+ if ( addr >= *PP32_DBG_PC_MIN(id) )
+ *PP32_DBG_PC_MAX(id) = addr;
+ else
+ *PP32_DBG_PC_MIN(id) = addr;
+ }
+ *PP32_BRK_SRC |= PP32_BRK_SRC_PC(id);
+ }
+ }
+ else if ( strincmp(p, "daddr", 5) == 0 && p[5] >= '0' && p[5] <= '1' && p[6] == ' ' )
+ {
+ id = (int)(p[5] - '0');
+ p += 7;
+ rlen -= 7;
+ *PP32_BRK_SRC &= ~PP32_BRK_SRC_DATA(id, 7);
+ if ( stricmp(p, "off") != 0 )
+ {
+ ignore_space(&p, &rlen);
+ *PP32_DBG_DATA_MIN(id) = *PP32_DBG_DATA_MAX(id) = get_number(&p, &rlen, 1);
+ cmd = 1;
+ ignore_space(&p, &rlen);
+ if ( rlen > 0 && ((*p >= '0' && *p <= '9') || (*p >= 'a' && *p <= 'f') || (*p >= 'A' && *p <= 'F')) )
+ {
+ addr = get_number(&p, &rlen, 1);
+ if ( addr >= *PP32_DBG_PC_MIN(id) )
+ *PP32_DBG_DATA_MAX(id) = addr;
+ else
+ *PP32_DBG_DATA_MIN(id) = addr;
+ ignore_space(&p, &rlen);
+ }
+ if ( *p == 'w' )
+ cmd = 2;
+ else if ( *p == 'r' && p[1] == 'w' )
+ {
+ cmd = 3;
+ p++;
+ rlen--;
+ }
+ p++;
+ rlen--;
+ if ( rlen > 0 )
+ {
+ ignore_space(&p, &rlen);
+ if ( (*p >= '0' && *p <= '9') || (*p >= 'a' && *p <= 'f') || (*p >= 'A' && *p <= 'F'))
+ {
+ *PP32_DBG_DATA_VAL(id) = get_number(&p, &rlen, 1);
+ cmd = 4;
+ }
+ }
+ *PP32_BRK_SRC |= PP32_BRK_SRC_DATA(id, cmd);
+ }
+ }
+ else
+ {
+ printk("echo \"<command>\" > /proc/driver/ifx_ptm/pp32\n");
+ printk(" command:\n");
+ printk(" start - run pp32\n");
+ printk(" stop - stop pp32\n");
+ printk(" step - run pp32 with one step only\n");
+ printk(" pc0 - pc0 <addr_min [addr_max]>/off, set break point PC0\n");
+ printk(" pc1 - pc1 <addr_min [addr_max]>/off, set break point PC1\n");
+ printk(" pc2 - pc2 <addr_min [addr_max]>/off, set break point PC2\n");
+ printk(" pc3 - pc3 <addr_min [addr_max]>/off, set break point PC3\n");
+ printk(" daddr0 - daddr0 <addr_min [addr_max] r/w/rw [value]>/off, set break point data address 0\n");
+ printk(" daddr1 - daddr1 <addr_min [addr_max] r/w/rw [value]>/off, set break point data address 1\n");
+ printk(" help - print this screen\n");
+ }
+
+ return count;
+}
+
+#else
+
+static int proc_read_pp32(char *page, char **start, off_t off, int count, int *eof, void *data)
+{
+ static const char *stron = " on";
+ static const char *stroff = "off";
+
+ int len = 0;
+ int cur_context;
+ int f_stopped;
+ char str[256];
+ char strlength;
+ int i, j;
+
+ int pp32;
+
+ for ( pp32 = 0; pp32 < NUM_OF_PP32; pp32++ )
+ {
+ f_stopped = 0;
+
+ len += sprintf(page + off + len, "===== pp32 core %d =====\n", pp32);
+
+ #ifdef CONFIG_VR9
+ if ( (*PP32_FREEZE & (1 << (pp32 << 4))) != 0 )
+ {
+ sprintf(str, "freezed");
+ f_stopped = 1;
+ }
+ #else
+ if ( 0 )
+ {
+ }
+ #endif
+ else if ( PP32_CPU_USER_STOPPED(pp32) || PP32_CPU_USER_BREAKIN_RCV(pp32) || PP32_CPU_USER_BREAKPOINT_MET(pp32) )
+ {
+ strlength = 0;
+ if ( PP32_CPU_USER_STOPPED(pp32) )
+ strlength += sprintf(str + strlength, "stopped");
+ if ( PP32_CPU_USER_BREAKPOINT_MET(pp32) )
+ strlength += sprintf(str + strlength, strlength ? " | breakpoint" : "breakpoint");
+ if ( PP32_CPU_USER_BREAKIN_RCV(pp32) )
+ strlength += sprintf(str + strlength, strlength ? " | breakin" : "breakin");
+ f_stopped = 1;
+ }
+ else if ( PP32_CPU_CUR_PC(pp32) == PP32_CPU_CUR_PC(pp32) )
+ {
+ unsigned int pc_value[64] = {0};
+
+ f_stopped = 1;
+ for ( i = 0; f_stopped && i < NUM_ENTITY(pc_value); i++ )
+ {
+ pc_value[i] = PP32_CPU_CUR_PC(pp32);
+ for ( j = 0; j < i; j++ )
+ if ( pc_value[j] != pc_value[i] )
+ {
+ f_stopped = 0;
+ break;
+ }
+ }
+ if ( f_stopped )
+ sprintf(str, "hang");
+ }
+ if ( !f_stopped )
+ sprintf(str, "running");
+ cur_context = PP32_BRK_CUR_CONTEXT(pp32);
+ len += sprintf(page + off + len, "Context: %d, PC: 0x%04x, %s\n", cur_context, PP32_CPU_CUR_PC(pp32), str);
+
+ if ( PP32_CPU_USER_BREAKPOINT_MET(pp32) )
+ {
+ strlength = 0;
+ if ( PP32_BRK_PC_MET(pp32, 0) )
+ strlength += sprintf(str + strlength, "pc0");
+ if ( PP32_BRK_PC_MET(pp32, 1) )
+ strlength += sprintf(str + strlength, strlength ? " | pc1" : "pc1");
+ if ( PP32_BRK_DATA_ADDR_MET(pp32, 0) )
+ strlength += sprintf(str + strlength, strlength ? " | daddr0" : "daddr0");
+ if ( PP32_BRK_DATA_ADDR_MET(pp32, 1) )
+ strlength += sprintf(str + strlength, strlength ? " | daddr1" : "daddr1");
+ if ( PP32_BRK_DATA_VALUE_RD_MET(pp32, 0) )
+ {
+ strlength += sprintf(str + strlength, strlength ? " | rdval0" : "rdval0");
+ if ( PP32_BRK_DATA_VALUE_RD_LO_EQ(pp32, 0) )
+ {
+ if ( PP32_BRK_DATA_VALUE_RD_GT_EQ(pp32, 0) )
+ strlength += sprintf(str + strlength, " ==");
+ else
+ strlength += sprintf(str + strlength, " <=");
+ }
+ else if ( PP32_BRK_DATA_VALUE_RD_GT_EQ(pp32, 0) )
+ strlength += sprintf(str + strlength, " >=");
+ }
+ if ( PP32_BRK_DATA_VALUE_RD_MET(pp32, 1) )
+ {
+ strlength += sprintf(str + strlength, strlength ? " | rdval1" : "rdval1");
+ if ( PP32_BRK_DATA_VALUE_RD_LO_EQ(pp32, 1) )
+ {
+ if ( PP32_BRK_DATA_VALUE_RD_GT_EQ(pp32, 1) )
+ strlength += sprintf(str + strlength, " ==");
+ else
+ strlength += sprintf(str + strlength, " <=");
+ }
+ else if ( PP32_BRK_DATA_VALUE_RD_GT_EQ(pp32, 1) )
+ strlength += sprintf(str + strlength, " >=");
+ }
+ if ( PP32_BRK_DATA_VALUE_WR_MET(pp32, 0) )
+ {
+ strlength += sprintf(str + strlength, strlength ? " | wtval0" : "wtval0");
+ if ( PP32_BRK_DATA_VALUE_WR_LO_EQ(pp32, 0) )
+ {
+ if ( PP32_BRK_DATA_VALUE_WR_GT_EQ(pp32, 0) )
+ strlength += sprintf(str + strlength, " ==");
+ else
+ strlength += sprintf(str + strlength, " <=");
+ }
+ else if ( PP32_BRK_DATA_VALUE_WR_GT_EQ(pp32, 0) )
+ strlength += sprintf(str + strlength, " >=");
+ }
+ if ( PP32_BRK_DATA_VALUE_WR_MET(pp32, 1) )
+ {
+ strlength += sprintf(str + strlength, strlength ? " | wtval1" : "wtval1");
+ if ( PP32_BRK_DATA_VALUE_WR_LO_EQ(pp32, 1) )
+ {
+ if ( PP32_BRK_DATA_VALUE_WR_GT_EQ(pp32, 1) )
+ strlength += sprintf(str + strlength, " ==");
+ else
+ strlength += sprintf(str + strlength, " <=");
+ }
+ else if ( PP32_BRK_DATA_VALUE_WR_GT_EQ(pp32, 1) )
+ strlength += sprintf(str + strlength, " >=");
+ }
+ len += sprintf(page + off + len, "break reason: %s\n", str);
+ }
+
+ if ( f_stopped )
+ {
+ len += sprintf(page + off + len, "General Purpose Register (Context %d):\n", cur_context);
+ for ( i = 0; i < 4; i++ )
+ {
+ for ( j = 0; j < 4; j++ )
+ len += sprintf(page + off + len, " %2d: %08x", i + j * 4, *PP32_GP_CONTEXTi_REGn(pp32, cur_context, i + j * 4));
+ len += sprintf(page + off + len, "\n");
+ }
+ }
+
+ len += sprintf(page + off + len, "break out on: break in - %s, stop - %s\n",
+ PP32_CTRL_OPT_BREAKOUT_ON_BREAKIN(pp32) ? stron : stroff,
+ PP32_CTRL_OPT_BREAKOUT_ON_STOP(pp32) ? stron : stroff);
+ len += sprintf(page + off + len, " stop on: break in - %s, break point - %s\n",
+ PP32_CTRL_OPT_STOP_ON_BREAKIN(pp32) ? stron : stroff,
+ PP32_CTRL_OPT_STOP_ON_BREAKPOINT(pp32) ? stron : stroff);
+ len += sprintf(page + off + len, "breakpoint:\n");
+ len += sprintf(page + off + len, " pc0: 0x%08x, %s\n", *PP32_BRK_PC(pp32, 0), PP32_BRK_GRPi_PCn(pp32, 0, 0) ? "group 0" : "off");
+ len += sprintf(page + off + len, " pc1: 0x%08x, %s\n", *PP32_BRK_PC(pp32, 1), PP32_BRK_GRPi_PCn(pp32, 1, 1) ? "group 1" : "off");
+ len += sprintf(page + off + len, " daddr0: 0x%08x, %s\n", *PP32_BRK_DATA_ADDR(pp32, 0), PP32_BRK_GRPi_DATA_ADDRn(pp32, 0, 0) ? "group 0" : "off");
+ len += sprintf(page + off + len, " daddr1: 0x%08x, %s\n", *PP32_BRK_DATA_ADDR(pp32, 1), PP32_BRK_GRPi_DATA_ADDRn(pp32, 1, 1) ? "group 1" : "off");
+ len += sprintf(page + off + len, " rdval0: 0x%08x\n", *PP32_BRK_DATA_VALUE_RD(pp32, 0));
+ len += sprintf(page + off + len, " rdval1: 0x%08x\n", *PP32_BRK_DATA_VALUE_RD(pp32, 1));
+ len += sprintf(page + off + len, " wrval0: 0x%08x\n", *PP32_BRK_DATA_VALUE_WR(pp32, 0));
+ len += sprintf(page + off + len, " wrval1: 0x%08x\n", *PP32_BRK_DATA_VALUE_WR(pp32, 1));
+ }
+
+ *eof = 1;
+
+ return len;
+}
+
+static int proc_write_pp32(struct file *file, const char *buf, unsigned long count, void *data)
+{
+ char str[2048];
+ char *p;
+ int len, rlen;
+
+ int pp32 = 0;
+ u32 addr;
+
+ len = count < sizeof(str) ? count : sizeof(str) - 1;
+ rlen = len - copy_from_user(str, buf, len);
+ while ( rlen && str[rlen - 1] <= ' ' )
+ rlen--;
+ str[rlen] = 0;
+ for ( p = str; *p && *p <= ' '; p++, rlen-- );
+ if ( !*p )
+ return 0;
+
+ if ( strincmp(p, "pp32 ", 5) == 0 )
+ {
+ p += 5;
+ rlen -= 5;
+
+ while ( rlen > 0 && *p >= '0' && *p <= '9' )
+ {
+ pp32 += *p - '0';
+ p++;
+ rlen--;
+ }
+ while ( rlen > 0 && *p && *p <= ' ' )
+ {
+ p++;
+ rlen--;
+ }
+
+ if ( pp32 >= NUM_OF_PP32 )
+ {
+ printk(KERN_ERR __FILE__ ":%d:%s: incorrect pp32 index - %d\n", __LINE__, __FUNCTION__, pp32);
+ return count;
+ }
+ }
+
+ if ( stricmp(p, "start") == 0 )
+ {
+ #ifdef CONFIG_AMAZON_SE
+ *PP32_CTRL_CMD(pp32) = 0;
+ #endif
+ *PP32_CTRL_CMD(pp32) = PP32_CTRL_CMD_RESTART;
+ }
+ else if ( stricmp(p, "stop") == 0 )
+ {
+ #ifdef CONFIG_AMAZON_SE
+ *PP32_CTRL_CMD(pp32) = 0;
+ #endif
+ *PP32_CTRL_CMD(pp32) = PP32_CTRL_CMD_STOP;
+ }
+ else if ( stricmp(p, "step") == 0 )
+ {
+ #ifdef CONFIG_AMAZON_SE
+ *PP32_CTRL_CMD(pp32) = 0;
+ #endif
+ *PP32_CTRL_CMD(pp32) = PP32_CTRL_CMD_STEP;
+ }
+ #ifdef CONFIG_VR9
+ else if ( stricmp(p, "unfreeze") == 0 )
+ *PP32_FREEZE &= ~(1 << (pp32 << 4));
+ else if ( stricmp(p, "freeze") == 0 )
+ *PP32_FREEZE |= 1 << (pp32 << 4);
+ #else
+ else if ( stricmp(p, "unfreeze") == 0 )
+ *PP32_DBG_CTRL(pp32) = DBG_CTRL_RESTART;
+ else if ( stricmp(p, "freeze") == 0 )
+ *PP32_DBG_CTRL(pp32) = DBG_CTRL_STOP;
+ #endif
+ else if ( strincmp(p, "pc0 ", 4) == 0 )
+ {
+ p += 4;
+ rlen -= 4;
+ if ( stricmp(p, "off") == 0 )
+ {
+ *PP32_BRK_TRIG(pp32) = PP32_BRK_GRPi_PCn_OFF(0, 0);
+ *PP32_BRK_PC_MASK(pp32, 0) = PP32_BRK_CONTEXT_MASK_EN;
+ *PP32_BRK_PC(pp32, 0) = 0;
+ }
+ else
+ {
+ addr = get_number(&p, &rlen, 1);
+ *PP32_BRK_PC(pp32, 0) = addr;
+ *PP32_BRK_PC_MASK(pp32, 0) = PP32_BRK_CONTEXT_MASK_EN | PP32_BRK_CONTEXT_MASK(0) | PP32_BRK_CONTEXT_MASK(1) | PP32_BRK_CONTEXT_MASK(2) | PP32_BRK_CONTEXT_MASK(3);
+ *PP32_BRK_TRIG(pp32) = PP32_BRK_GRPi_PCn_ON(0, 0);
+ }
+ }
+ else if ( strincmp(p, "pc1 ", 4) == 0 )
+ {
+ p += 4;
+ rlen -= 4;
+ if ( stricmp(p, "off") == 0 )
+ {
+ *PP32_BRK_TRIG(pp32) = PP32_BRK_GRPi_PCn_OFF(1, 1);
+ *PP32_BRK_PC_MASK(pp32, 1) = PP32_BRK_CONTEXT_MASK_EN;
+ *PP32_BRK_PC(pp32, 1) = 0;
+ }
+ else
+ {
+ addr = get_number(&p, &rlen, 1);
+ *PP32_BRK_PC(pp32, 1) = addr;
+ *PP32_BRK_PC_MASK(pp32, 1) = PP32_BRK_CONTEXT_MASK_EN | PP32_BRK_CONTEXT_MASK(0) | PP32_BRK_CONTEXT_MASK(1) | PP32_BRK_CONTEXT_MASK(2) | PP32_BRK_CONTEXT_MASK(3);
+ *PP32_BRK_TRIG(pp32) = PP32_BRK_GRPi_PCn_ON(1, 1);
+ }
+ }
+ else if ( strincmp(p, "daddr0 ", 7) == 0 )
+ {
+ p += 7;
+ rlen -= 7;
+ if ( stricmp(p, "off") == 0 )
+ {
+ *PP32_BRK_TRIG(pp32) = PP32_BRK_GRPi_DATA_ADDRn_OFF(0, 0);
+ *PP32_BRK_DATA_ADDR_MASK(pp32, 0) = PP32_BRK_CONTEXT_MASK_EN;
+ *PP32_BRK_DATA_ADDR(pp32, 0) = 0;
+ }
+ else
+ {
+ addr = get_number(&p, &rlen, 1);
+ *PP32_BRK_DATA_ADDR(pp32, 0) = addr;
+ *PP32_BRK_DATA_ADDR_MASK(pp32, 0) = PP32_BRK_CONTEXT_MASK_EN | PP32_BRK_CONTEXT_MASK(0) | PP32_BRK_CONTEXT_MASK(1) | PP32_BRK_CONTEXT_MASK(2) | PP32_BRK_CONTEXT_MASK(3);
+ *PP32_BRK_TRIG(pp32) = PP32_BRK_GRPi_DATA_ADDRn_ON(0, 0);
+ }
+ }
+ else if ( strincmp(p, "daddr1 ", 7) == 0 )
+ {
+ p += 7;
+ rlen -= 7;
+ if ( stricmp(p, "off") == 0 )
+ {
+ *PP32_BRK_TRIG(pp32) = PP32_BRK_GRPi_DATA_ADDRn_OFF(1, 1);
+ *PP32_BRK_DATA_ADDR_MASK(pp32, 1) = PP32_BRK_CONTEXT_MASK_EN;
+ *PP32_BRK_DATA_ADDR(pp32, 1) = 0;
+ }
+ else
+ {
+ addr = get_number(&p, &rlen, 1);
+ *PP32_BRK_DATA_ADDR(pp32, 1) = addr;
+ *PP32_BRK_DATA_ADDR_MASK(pp32, 1) = PP32_BRK_CONTEXT_MASK_EN | PP32_BRK_CONTEXT_MASK(0) | PP32_BRK_CONTEXT_MASK(1) | PP32_BRK_CONTEXT_MASK(2) | PP32_BRK_CONTEXT_MASK(3);
+ *PP32_BRK_TRIG(pp32) = PP32_BRK_GRPi_DATA_ADDRn_ON(1, 1);
+ }
+ }
+ else
+ {
+
+ printk("echo \"<command>\" > /proc/driver/ifx_ptm/pp32\n");
+ printk(" command:\n");
+ printk(" unfreeze - unfreeze pp32\n");
+ printk(" freeze - freeze pp32\n");
+ printk(" start - run pp32\n");
+ printk(" stop - stop pp32\n");
+ printk(" step - run pp32 with one step only\n");
+ printk(" pc0 - pc0 <addr>/off, set break point PC0\n");
+ printk(" pc1 - pc1 <addr>/off, set break point PC1\n");
+ printk(" daddr0 - daddr0 <addr>/off, set break point data address 0\n");
+ printk(" daddr1 - daddr1 <addr>/off, set break point data address 1\n");
+ printk(" help - print this screen\n");
+ }
+
+ if ( *PP32_BRK_TRIG(pp32) )
+ *PP32_CTRL_OPT(pp32) = PP32_CTRL_OPT_STOP_ON_BREAKPOINT_ON;
+ else
+ *PP32_CTRL_OPT(pp32) = PP32_CTRL_OPT_STOP_ON_BREAKPOINT_OFF;
+
+ return count;
+}
+
+#endif
+
+static int stricmp(const char *p1, const char *p2)
+{
+ int c1, c2;
+
+ while ( *p1 && *p2 )
+ {
+ c1 = *p1 >= 'A' && *p1 <= 'Z' ? *p1 + 'a' - 'A' : *p1;
+ c2 = *p2 >= 'A' && *p2 <= 'Z' ? *p2 + 'a' - 'A' : *p2;
+ if ( (c1 -= c2) )
+ return c1;
+ p1++;
+ p2++;
+ }
+
+ return *p1 - *p2;
+}
+
+static int strincmp(const char *p1, const char *p2, int n)
+{
+ int c1 = 0, c2;
+
+ while ( n && *p1 && *p2 )
+ {
+ c1 = *p1 >= 'A' && *p1 <= 'Z' ? *p1 + 'a' - 'A' : *p1;
+ c2 = *p2 >= 'A' && *p2 <= 'Z' ? *p2 + 'a' - 'A' : *p2;
+ if ( (c1 -= c2) )
+ return c1;
+ p1++;
+ p2++;
+ n--;
+ }
+
+ return n ? *p1 - *p2 : c1;
+}
+
+static int get_token(char **p1, char **p2, int *len, int *colon)
+{
+ int tlen = 0;
+
+ while ( *len && !((**p1 >= 'A' && **p1 <= 'Z') || (**p1 >= 'a' && **p1<= 'z')) )
+ {
+ (*p1)++;
+ (*len)--;
+ }
+ if ( !*len )
+ return 0;
+
+ if ( *colon )
+ {
+ *colon = 0;
+ *p2 = *p1;
+ while ( *len && **p2 > ' ' && **p2 != ',' )
+ {
+ if ( **p2 == ':' )
+ {
+ *colon = 1;
+ break;
+ }
+ (*p2)++;
+ (*len)--;
+ tlen++;
+ }
+ **p2 = 0;
+ }
+ else
+ {
+ *p2 = *p1;
+ while ( *len && **p2 > ' ' && **p2 != ',' )
+ {
+ (*p2)++;
+ (*len)--;
+ tlen++;
+ }
+ **p2 = 0;
+ }
+
+ return tlen;
+}
+
+static int get_number(char **p, int *len, int is_hex)
+{
+ int ret = 0;
+ int n = 0;
+
+ if ( (*p)[0] == '0' && (*p)[1] == 'x' )
+ {
+ is_hex = 1;
+ (*p) += 2;
+ (*len) -= 2;
+ }
+
+ if ( is_hex )
+ {
+ while ( *len && ((**p >= '0' && **p <= '9') || (**p >= 'a' && **p <= 'f') || (**p >= 'A' && **p <= 'F')) )
+ {
+ if ( **p >= '0' && **p <= '9' )
+ n = **p - '0';
+ else if ( **p >= 'a' && **p <= 'f' )
+ n = **p - 'a' + 10;
+ else if ( **p >= 'A' && **p <= 'F' )
+ n = **p - 'A' + 10;
+ ret = (ret << 4) | n;
+ (*p)++;
+ (*len)--;
+ }
+ }
+ else
+ {
+ while ( *len && **p >= '0' && **p <= '9' )
+ {
+ n = **p - '0';
+ ret = ret * 10 + n;
+ (*p)++;
+ (*len)--;
+ }
+ }
+
+ return ret;
+}
+
+static inline void ignore_space(char **p, int *len)
+{
+ while ( *len && (**p <= ' ' || **p == ':' || **p == '.' || **p == ',') )
+ {
+ (*p)++;
+ (*len)--;
+ }
+}
+
+
+
+/*
+ * ####################################
+ * Global Function
+ * ####################################
+ */
+
+
+
+/*
+ * ####################################
+ * Init/Cleanup API
+ * ####################################
+ */
+
+static int __init ifx_ptm_test_init(void)
+{
+ proc_file_create();
+
+ return 0;
+}
+
+static void __exit ifx_ptm_test_exit(void)
+{
+ proc_file_delete();
+}
+
+module_init(ifx_ptm_test_init);
+module_exit(ifx_ptm_test_exit);
+
+#endif
diff --git a/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_vdsl.c b/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_vdsl.c
new file mode 100644
index 0000000..745eb03
--- /dev/null
+++ b/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_vdsl.c
@@ -0,0 +1,1080 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_ptm_vdsl.c
+** PROJECT : UEIP
+** MODULES : PTM
+**
+** DATE : 7 Jul 2009
+** AUTHOR : Xu Liang
+** DESCRIPTION : PTM driver common source file (core functions for VR9)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 07 JUL 2009 Xu Liang Init Version
+*******************************************************************************/
+
+#include <linux/version.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/ctype.h>
+#include <linux/errno.h>
+#include <linux/proc_fs.h>
+#include <linux/init.h>
+#include <linux/ioctl.h>
+#include <linux/etherdevice.h>
+#include <linux/interrupt.h>
+
+#include "ifxmips_ptm_vdsl.h"
+#include <lantiq_soc.h>
+
+#define MODULE_PARM_ARRAY(a, b) module_param_array(a, int, NULL, 0)
+#define MODULE_PARM(a, b) module_param(a, int, 0)
+
+static int wanqos_en = 0;
+static int queue_gamma_map[4] = {0xFE, 0x01, 0x00, 0x00};
+
+MODULE_PARM(wanqos_en, "i");
+MODULE_PARM_DESC(wanqos_en, "WAN QoS support, 1 - enabled, 0 - disabled.");
+
+MODULE_PARM_ARRAY(queue_gamma_map, "4-4i");
+MODULE_PARM_DESC(queue_gamma_map, "TX QoS queues mapping to 4 TX Gamma interfaces.");
+
+extern int (*ifx_mei_atm_showtime_enter)(struct port_cell_info *, void *);
+extern int (*ifx_mei_atm_showtime_exit)(void);
+extern int ifx_mei_atm_showtime_check(int *is_showtime, struct port_cell_info *port_cell, void **xdata_addr);
+
+static int g_showtime = 0;
+static void *g_xdata_addr = NULL;
+
+
+#define ENABLE_TMP_DBG 0
+
+unsigned long cgu_get_pp32_clock(void)
+{
+ struct clk *c = clk_get_ppe();
+ unsigned long rate = clk_get_rate(c);
+ clk_put(c);
+ return rate;
+}
+
+static void ptm_setup(struct net_device *, int);
+static struct net_device_stats *ptm_get_stats(struct net_device *);
+static int ptm_open(struct net_device *);
+static int ptm_stop(struct net_device *);
+ static unsigned int ptm_poll(int, unsigned int);
+ static int ptm_napi_poll(struct napi_struct *, int);
+static int ptm_hard_start_xmit(struct sk_buff *, struct net_device *);
+static int ptm_ioctl(struct net_device *, struct ifreq *, int);
+static void ptm_tx_timeout(struct net_device *);
+
+static inline struct sk_buff* alloc_skb_rx(void);
+static inline struct sk_buff* alloc_skb_tx(unsigned int);
+static inline struct sk_buff *get_skb_pointer(unsigned int);
+static inline int get_tx_desc(unsigned int, unsigned int *);
+
+/*
+ * Mailbox handler and signal function
+ */
+static irqreturn_t mailbox_irq_handler(int, void *);
+
+/*
+ * Tasklet to Handle Swap Descriptors
+ */
+static void do_swap_desc_tasklet(unsigned long);
+
+
+/*
+ * Init & clean-up functions
+ */
+static inline int init_priv_data(void);
+static inline void clear_priv_data(void);
+static inline int init_tables(void);
+static inline void clear_tables(void);
+
+static int g_wanqos_en = 0;
+
+static int g_queue_gamma_map[4];
+
+static struct ptm_priv_data g_ptm_priv_data;
+
+static struct net_device_ops g_ptm_netdev_ops = {
+ .ndo_get_stats = ptm_get_stats,
+ .ndo_open = ptm_open,
+ .ndo_stop = ptm_stop,
+ .ndo_start_xmit = ptm_hard_start_xmit,
+ .ndo_validate_addr = eth_validate_addr,
+ .ndo_set_mac_address = eth_mac_addr,
+ .ndo_change_mtu = eth_change_mtu,
+ .ndo_do_ioctl = ptm_ioctl,
+ .ndo_tx_timeout = ptm_tx_timeout,
+};
+
+static struct net_device *g_net_dev[1] = {0};
+static char *g_net_dev_name[1] = {"ptm0"};
+
+static int g_ptm_prio_queue_map[8];
+
+static DECLARE_TASKLET(g_swap_desc_tasklet, do_swap_desc_tasklet, 0);
+
+
+unsigned int ifx_ptm_dbg_enable = DBG_ENABLE_MASK_ERR;
+
+/*
+ * ####################################
+ * Local Function
+ * ####################################
+ */
+
+static void ptm_setup(struct net_device *dev, int ndev)
+{
+ dev->netdev_ops = &g_ptm_netdev_ops;
+ netif_napi_add(dev, &g_ptm_priv_data.itf[ndev].napi, ptm_napi_poll, 16);
+ dev->watchdog_timeo = ETH_WATCHDOG_TIMEOUT;
+
+ dev->dev_addr[0] = 0x00;
+ dev->dev_addr[1] = 0x20;
+ dev->dev_addr[2] = 0xda;
+ dev->dev_addr[3] = 0x86;
+ dev->dev_addr[4] = 0x23;
+ dev->dev_addr[5] = 0x75 + ndev;
+}
+
+static struct net_device_stats *ptm_get_stats(struct net_device *dev)
+{
+ struct net_device_stats *s;
+
+ if ( dev != g_net_dev[0] )
+ return NULL;
+s = &g_ptm_priv_data.itf[0].stats;
+
+ return s;
+}
+
+static int ptm_open(struct net_device *dev)
+{
+ ASSERT(dev == g_net_dev[0], "incorrect device");
+
+ napi_enable(&g_ptm_priv_data.itf[0].napi);
+
+ IFX_REG_W32_MASK(0, 1, MBOX_IGU1_IER);
+
+ netif_start_queue(dev);
+
+ return 0;
+}
+
+static int ptm_stop(struct net_device *dev)
+{
+ ASSERT(dev == g_net_dev[0], "incorrect device");
+
+ IFX_REG_W32_MASK(1 | (1 << 17), 0, MBOX_IGU1_IER);
+
+ napi_disable(&g_ptm_priv_data.itf[0].napi);
+
+ netif_stop_queue(dev);
+
+ return 0;
+}
+
+static unsigned int ptm_poll(int ndev, unsigned int work_to_do)
+{
+ unsigned int work_done = 0;
+ volatile struct rx_descriptor *desc;
+ struct rx_descriptor reg_desc;
+ struct sk_buff *skb, *new_skb;
+
+ ASSERT(ndev >= 0 && ndev < ARRAY_SIZE(g_net_dev), "ndev = %d (wrong value)", ndev);
+
+ while ( work_done < work_to_do ) {
+ desc = &WAN_RX_DESC_BASE[g_ptm_priv_data.itf[0].rx_desc_pos];
+ if ( desc->own /* || !desc->c */ ) // if PP32 hold descriptor or descriptor not completed
+ break;
+ if ( ++g_ptm_priv_data.itf[0].rx_desc_pos == WAN_RX_DESC_NUM )
+ g_ptm_priv_data.itf[0].rx_desc_pos = 0;
+
+ reg_desc = *desc;
+ skb = get_skb_pointer(reg_desc.dataptr);
+ ASSERT(skb != NULL, "invalid pointer skb == NULL");
+
+ new_skb = alloc_skb_rx();
+ if ( new_skb != NULL ) {
+ skb_reserve(skb, reg_desc.byteoff);
+ skb_put(skb, reg_desc.datalen);
+
+ // parse protocol header
+ skb->dev = g_net_dev[0];
+ skb->protocol = eth_type_trans(skb, skb->dev);
+
+ g_net_dev[0]->last_rx = jiffies;
+
+ netif_receive_skb(skb);
+
+ g_ptm_priv_data.itf[0].stats.rx_packets++;
+ g_ptm_priv_data.itf[0].stats.rx_bytes += reg_desc.datalen;
+
+ reg_desc.dataptr = (unsigned int)new_skb->data & 0x0FFFFFFF;
+ reg_desc.byteoff = RX_HEAD_MAC_ADDR_ALIGNMENT;
+ }
+
+ reg_desc.datalen = RX_MAX_BUFFER_SIZE - RX_HEAD_MAC_ADDR_ALIGNMENT;
+ reg_desc.own = 1;
+ reg_desc.c = 0;
+
+ /* write discriptor to memory */
+ *((volatile unsigned int *)desc + 1) = *((unsigned int *)&reg_desc + 1);
+ wmb();
+ *(volatile unsigned int *)desc = *(unsigned int *)&reg_desc;
+
+ work_done++;
+ }
+
+ return work_done;
+}
+
+static int ptm_napi_poll(struct napi_struct *napi, int budget)
+{
+ int ndev = 0;
+ unsigned int work_done;
+
+ work_done = ptm_poll(ndev, budget);
+
+ // interface down
+ if ( !netif_running(napi->dev) ) {
+ napi_complete(napi);
+ return work_done;
+ }
+
+ // clear interrupt
+ IFX_REG_W32_MASK(0, 1, MBOX_IGU1_ISRC);
+ // no more traffic
+ if ( WAN_RX_DESC_BASE[g_ptm_priv_data.itf[0].rx_desc_pos].own ) { // if PP32 hold descriptor
+ napi_complete(napi);
+ IFX_REG_W32_MASK(0, 1, MBOX_IGU1_IER);
+ return work_done;
+ }
+
+ // next round
+ return work_done;
+}
+
+static int ptm_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
+{
+ unsigned int f_full;
+ int desc_base;
+ volatile struct tx_descriptor *desc;
+ struct tx_descriptor reg_desc = {0};
+ struct sk_buff *skb_to_free;
+ unsigned int byteoff;
+
+ ASSERT(dev == g_net_dev[0], "incorrect device");
+
+ if ( !g_showtime ) {
+ err("not in showtime");
+ goto PTM_HARD_START_XMIT_FAIL;
+ }
+
+ /* allocate descriptor */
+ desc_base = get_tx_desc(0, &f_full);
+ if ( f_full ) {
+ dev->trans_start = jiffies;
+ netif_stop_queue(dev);
+
+ IFX_REG_W32_MASK(0, 1 << 17, MBOX_IGU1_ISRC);
+ IFX_REG_W32_MASK(0, 1 << 17, MBOX_IGU1_IER);
+ }
+ if ( desc_base < 0 )
+ goto PTM_HARD_START_XMIT_FAIL;
+ desc = &CPU_TO_WAN_TX_DESC_BASE[desc_base];
+
+ byteoff = (unsigned int)skb->data & (DATA_BUFFER_ALIGNMENT - 1);
+ if ( skb_headroom(skb) < sizeof(struct sk_buff *) + byteoff || skb_cloned(skb) ) {
+ struct sk_buff *new_skb;
+
+ ASSERT(skb_headroom(skb) >= sizeof(struct sk_buff *) + byteoff, "skb_headroom(skb) < sizeof(struct sk_buff *) + byteoff");
+ ASSERT(!skb_cloned(skb), "skb is cloned");
+
+ new_skb = alloc_skb_tx(skb->len);
+ if ( new_skb == NULL ) {
+ dbg("no memory");
+ goto ALLOC_SKB_TX_FAIL;
+ }
+ skb_put(new_skb, skb->len);
+ memcpy(new_skb->data, skb->data, skb->len);
+ dev_kfree_skb_any(skb);
+ skb = new_skb;
+ byteoff = (unsigned int)skb->data & (DATA_BUFFER_ALIGNMENT - 1);
+ /* write back to physical memory */
+ dma_cache_wback((unsigned long)skb->data, skb->len);
+ }
+
+ *(struct sk_buff **)((unsigned int)skb->data - byteoff - sizeof(struct sk_buff *)) = skb;
+ /* write back to physical memory */
+ dma_cache_wback((unsigned long)skb->data - byteoff - sizeof(struct sk_buff *), skb->len + byteoff + sizeof(struct sk_buff *));
+
+ /* free previous skb */
+ skb_to_free = get_skb_pointer(desc->dataptr);
+ if ( skb_to_free != NULL )
+ dev_kfree_skb_any(skb_to_free);
+
+ /* update descriptor */
+ reg_desc.small = 0;
+ reg_desc.dataptr = (unsigned int)skb->data & (0x0FFFFFFF ^ (DATA_BUFFER_ALIGNMENT - 1));
+ reg_desc.datalen = skb->len < ETH_ZLEN ? ETH_ZLEN : skb->len;
+ reg_desc.qid = g_ptm_prio_queue_map[skb->priority > 7 ? 7 : skb->priority];
+ reg_desc.byteoff = byteoff;
+ reg_desc.own = 1;
+ reg_desc.c = 1;
+ reg_desc.sop = reg_desc.eop = 1;
+
+ /* update MIB */
+ g_ptm_priv_data.itf[0].stats.tx_packets++;
+ g_ptm_priv_data.itf[0].stats.tx_bytes += reg_desc.datalen;
+
+ /* write discriptor to memory */
+ *((volatile unsigned int *)desc + 1) = *((unsigned int *)&reg_desc + 1);
+ wmb();
+ *(volatile unsigned int *)desc = *(unsigned int *)&reg_desc;
+
+ dev->trans_start = jiffies;
+
+ return 0;
+
+ALLOC_SKB_TX_FAIL:
+PTM_HARD_START_XMIT_FAIL:
+ dev_kfree_skb_any(skb);
+ g_ptm_priv_data.itf[0].stats.tx_dropped++;
+ return 0;
+}
+
+static int ptm_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
+{
+ ASSERT(dev == g_net_dev[0], "incorrect device");
+
+ switch ( cmd )
+ {
+ case IFX_PTM_MIB_CW_GET:
+ ((PTM_CW_IF_ENTRY_T *)ifr->ifr_data)->ifRxNoIdleCodewords = IFX_REG_R32(DREG_AR_CELL0) + IFX_REG_R32(DREG_AR_CELL1);
+ ((PTM_CW_IF_ENTRY_T *)ifr->ifr_data)->ifRxIdleCodewords = IFX_REG_R32(DREG_AR_IDLE_CNT0) + IFX_REG_R32(DREG_AR_IDLE_CNT1);
+ ((PTM_CW_IF_ENTRY_T *)ifr->ifr_data)->ifRxCodingViolation = IFX_REG_R32(DREG_AR_CVN_CNT0) + IFX_REG_R32(DREG_AR_CVN_CNT1) + IFX_REG_R32(DREG_AR_CVNP_CNT0) + IFX_REG_R32(DREG_AR_CVNP_CNT1);
+ ((PTM_CW_IF_ENTRY_T *)ifr->ifr_data)->ifTxNoIdleCodewords = IFX_REG_R32(DREG_AT_CELL0) + IFX_REG_R32(DREG_AT_CELL1);
+ ((PTM_CW_IF_ENTRY_T *)ifr->ifr_data)->ifTxIdleCodewords = IFX_REG_R32(DREG_AT_IDLE_CNT0) + IFX_REG_R32(DREG_AT_IDLE_CNT1);
+ break;
+ case IFX_PTM_MIB_FRAME_GET:
+ {
+ PTM_FRAME_MIB_T data = {0};
+ int i;
+
+ data.RxCorrect = IFX_REG_R32(DREG_AR_HEC_CNT0) + IFX_REG_R32(DREG_AR_HEC_CNT1) + IFX_REG_R32(DREG_AR_AIIDLE_CNT0) + IFX_REG_R32(DREG_AR_AIIDLE_CNT1);
+ for ( i = 0; i < 4; i++ )
+ data.RxDropped += WAN_RX_MIB_TABLE(i)->wrx_dropdes_pdu;
+ for ( i = 0; i < 8; i++ )
+ data.TxSend += WAN_TX_MIB_TABLE(i)->wtx_total_pdu;
+
+ *((PTM_FRAME_MIB_T *)ifr->ifr_data) = data;
+ }
+ break;
+ case IFX_PTM_CFG_GET:
+ // use bear channel 0 preemption gamma interface settings
+ ((IFX_PTM_CFG_T *)ifr->ifr_data)->RxEthCrcPresent = 1;
+ ((IFX_PTM_CFG_T *)ifr->ifr_data)->RxEthCrcCheck = RX_GAMMA_ITF_CFG(0)->rx_eth_fcs_ver_dis == 0 ? 1 : 0;
+ ((IFX_PTM_CFG_T *)ifr->ifr_data)->RxTcCrcCheck = RX_GAMMA_ITF_CFG(0)->rx_tc_crc_ver_dis == 0 ? 1 : 0;;
+ ((IFX_PTM_CFG_T *)ifr->ifr_data)->RxTcCrcLen = RX_GAMMA_ITF_CFG(0)->rx_tc_crc_size == 0 ? 0 : (RX_GAMMA_ITF_CFG(0)->rx_tc_crc_size * 16);
+ ((IFX_PTM_CFG_T *)ifr->ifr_data)->TxEthCrcGen = TX_GAMMA_ITF_CFG(0)->tx_eth_fcs_gen_dis == 0 ? 1 : 0;
+ ((IFX_PTM_CFG_T *)ifr->ifr_data)->TxTcCrcGen = TX_GAMMA_ITF_CFG(0)->tx_tc_crc_size == 0 ? 0 : 1;
+ ((IFX_PTM_CFG_T *)ifr->ifr_data)->TxTcCrcLen = TX_GAMMA_ITF_CFG(0)->tx_tc_crc_size == 0 ? 0 : (TX_GAMMA_ITF_CFG(0)->tx_tc_crc_size * 16);
+ break;
+ case IFX_PTM_CFG_SET:
+ {
+ int i;
+
+ for ( i = 0; i < 4; i++ ) {
+ RX_GAMMA_ITF_CFG(i)->rx_eth_fcs_ver_dis = ((IFX_PTM_CFG_T *)ifr->ifr_data)->RxEthCrcCheck ? 0 : 1;
+
+ RX_GAMMA_ITF_CFG(0)->rx_tc_crc_ver_dis = ((IFX_PTM_CFG_T *)ifr->ifr_data)->RxTcCrcCheck ? 0 : 1;
+
+ switch ( ((IFX_PTM_CFG_T *)ifr->ifr_data)->RxTcCrcLen ) {
+ case 16: RX_GAMMA_ITF_CFG(0)->rx_tc_crc_size = 1; break;
+ case 32: RX_GAMMA_ITF_CFG(0)->rx_tc_crc_size = 2; break;
+ default: RX_GAMMA_ITF_CFG(0)->rx_tc_crc_size = 0;
+ }
+
+ TX_GAMMA_ITF_CFG(0)->tx_eth_fcs_gen_dis = ((IFX_PTM_CFG_T *)ifr->ifr_data)->TxEthCrcGen ? 0 : 1;
+
+ if ( ((IFX_PTM_CFG_T *)ifr->ifr_data)->TxTcCrcGen ) {
+ switch ( ((IFX_PTM_CFG_T *)ifr->ifr_data)->TxTcCrcLen ) {
+ case 16: TX_GAMMA_ITF_CFG(0)->tx_tc_crc_size = 1; break;
+ case 32: TX_GAMMA_ITF_CFG(0)->tx_tc_crc_size = 2; break;
+ default: TX_GAMMA_ITF_CFG(0)->tx_tc_crc_size = 0;
+ }
+ }
+ else
+ TX_GAMMA_ITF_CFG(0)->tx_tc_crc_size = 0;
+ }
+ }
+ break;
+ case IFX_PTM_MAP_PKT_PRIO_TO_Q:
+ {
+ struct ppe_prio_q_map cmd;
+
+ if ( copy_from_user(&cmd, ifr->ifr_data, sizeof(cmd)) )
+ return -EFAULT;
+
+ if ( cmd.pkt_prio < 0 || cmd.pkt_prio >= ARRAY_SIZE(g_ptm_prio_queue_map) )
+ return -EINVAL;
+
+ if ( cmd.qid < 0 || cmd.qid >= g_wanqos_en )
+ return -EINVAL;
+
+ g_ptm_prio_queue_map[cmd.pkt_prio] = cmd.qid;
+ }
+ break;
+ default:
+ return -EOPNOTSUPP;
+ }
+
+ return 0;
+}
+
+static void ptm_tx_timeout(struct net_device *dev)
+{
+ ASSERT(dev == g_net_dev[0], "incorrect device");
+
+ /* disable TX irq, release skb when sending new packet */
+ IFX_REG_W32_MASK(1 << 17, 0, MBOX_IGU1_IER);
+
+ /* wake up TX queue */
+ netif_wake_queue(dev);
+
+ return;
+}
+
+static inline struct sk_buff* alloc_skb_rx(void)
+{
+ struct sk_buff *skb;
+
+ /* allocate memroy including trailer and padding */
+ skb = dev_alloc_skb(RX_MAX_BUFFER_SIZE + DATA_BUFFER_ALIGNMENT);
+ if ( skb != NULL ) {
+ /* must be burst length alignment and reserve two more bytes for MAC address alignment */
+ if ( ((unsigned int)skb->data & (DATA_BUFFER_ALIGNMENT - 1)) != 0 )
+ skb_reserve(skb, ~((unsigned int)skb->data + (DATA_BUFFER_ALIGNMENT - 1)) & (DATA_BUFFER_ALIGNMENT - 1));
+ /* pub skb in reserved area "skb->data - 4" */
+ *((struct sk_buff **)skb->data - 1) = skb;
+ wmb();
+ /* write back and invalidate cache */
+ dma_cache_wback_inv((unsigned long)skb->data - sizeof(skb), sizeof(skb));
+ /* invalidate cache */
+ dma_cache_inv((unsigned long)skb->data, (unsigned int)skb->end - (unsigned int)skb->data);
+ }
+
+ return skb;
+}
+
+static inline struct sk_buff* alloc_skb_tx(unsigned int size)
+{
+ struct sk_buff *skb;
+
+ /* allocate memory including padding */
+ size = RX_MAX_BUFFER_SIZE;
+ size = (size + DATA_BUFFER_ALIGNMENT - 1) & ~(DATA_BUFFER_ALIGNMENT - 1);
+ skb = dev_alloc_skb(size + DATA_BUFFER_ALIGNMENT);
+ /* must be burst length alignment */
+ if ( skb != NULL )
+ skb_reserve(skb, ~((unsigned int)skb->data + (DATA_BUFFER_ALIGNMENT - 1)) & (DATA_BUFFER_ALIGNMENT - 1));
+ return skb;
+}
+
+static inline struct sk_buff *get_skb_pointer(unsigned int dataptr)
+{
+ unsigned int skb_dataptr;
+ struct sk_buff *skb;
+
+ // usually, CPE memory is less than 256M bytes
+ // so NULL means invalid pointer
+ if ( dataptr == 0 ) {
+ dbg("dataptr is 0, it's supposed to be invalid pointer");
+ return NULL;
+ }
+
+ skb_dataptr = (dataptr - 4) | KSEG1;
+ skb = *(struct sk_buff **)skb_dataptr;
+
+ ASSERT((unsigned int)skb >= KSEG0, "invalid skb - skb = %#08x, dataptr = %#08x", (unsigned int)skb, dataptr);
+ ASSERT((((unsigned int)skb->data & (0x0FFFFFFF ^ (DATA_BUFFER_ALIGNMENT - 1))) | KSEG1) == (dataptr | KSEG1), "invalid skb - skb = %#08x, skb->data = %#08x, dataptr = %#08x", (unsigned int)skb, (unsigned int)skb->data, dataptr);
+
+ return skb;
+}
+
+static inline int get_tx_desc(unsigned int itf, unsigned int *f_full)
+{
+ int desc_base = -1;
+ struct ptm_itf *p_itf = &g_ptm_priv_data.itf[0];
+
+ // assume TX is serial operation
+ // no protection provided
+
+ *f_full = 1;
+
+ if ( CPU_TO_WAN_TX_DESC_BASE[p_itf->tx_desc_pos].own == 0 ) {
+ desc_base = p_itf->tx_desc_pos;
+ if ( ++(p_itf->tx_desc_pos) == CPU_TO_WAN_TX_DESC_NUM )
+ p_itf->tx_desc_pos = 0;
+ if ( CPU_TO_WAN_TX_DESC_BASE[p_itf->tx_desc_pos].own == 0 )
+ *f_full = 0;
+ }
+
+ return desc_base;
+}
+
+static irqreturn_t mailbox_irq_handler(int irq, void *dev_id)
+{
+ unsigned int isr;
+ int i;
+
+ isr = IFX_REG_R32(MBOX_IGU1_ISR);
+ IFX_REG_W32(isr, MBOX_IGU1_ISRC);
+ isr &= IFX_REG_R32(MBOX_IGU1_IER);
+
+ if (isr & BIT(0)) {
+ IFX_REG_W32_MASK(1, 0, MBOX_IGU1_IER);
+ napi_schedule(&g_ptm_priv_data.itf[0].napi);
+#if defined(ENABLE_TMP_DBG) && ENABLE_TMP_DBG
+ {
+ volatile struct rx_descriptor *desc = &WAN_RX_DESC_BASE[g_ptm_priv_data.itf[0].rx_desc_pos];
+
+ if ( desc->own ) { // PP32 hold
+ err("invalid interrupt");
+ }
+ }
+#endif
+ }
+ if (isr & BIT(16)) {
+ IFX_REG_W32_MASK(1 << 16, 0, MBOX_IGU1_IER);
+ tasklet_hi_schedule(&g_swap_desc_tasklet);
+ }
+ if (isr & BIT(17)) {
+ IFX_REG_W32_MASK(1 << 17, 0, MBOX_IGU1_IER);
+ netif_wake_queue(g_net_dev[0]);
+ }
+
+ return IRQ_HANDLED;
+}
+
+static void do_swap_desc_tasklet(unsigned long arg)
+{
+ int budget = 32;
+ volatile struct tx_descriptor *desc;
+ struct sk_buff *skb;
+ unsigned int byteoff;
+
+ while ( budget-- > 0 ) {
+ if ( WAN_SWAP_DESC_BASE[g_ptm_priv_data.itf[0].tx_swap_desc_pos].own ) // if PP32 hold descriptor
+ break;
+
+ desc = &WAN_SWAP_DESC_BASE[g_ptm_priv_data.itf[0].tx_swap_desc_pos];
+ if ( ++g_ptm_priv_data.itf[0].tx_swap_desc_pos == WAN_SWAP_DESC_NUM )
+ g_ptm_priv_data.itf[0].tx_swap_desc_pos = 0;
+
+ skb = get_skb_pointer(desc->dataptr);
+ if ( skb != NULL )
+ dev_kfree_skb_any(skb);
+
+ skb = alloc_skb_tx(RX_MAX_BUFFER_SIZE);
+ if ( skb == NULL )
+ panic("can't allocate swap buffer for PPE firmware use\n");
+ byteoff = (unsigned int)skb->data & (DATA_BUFFER_ALIGNMENT - 1);
+ *(struct sk_buff **)((unsigned int)skb->data - byteoff - sizeof(struct sk_buff *)) = skb;
+
+ desc->dataptr = (unsigned int)skb->data & 0x0FFFFFFF;
+ desc->own = 1;
+ }
+
+ // clear interrupt
+ IFX_REG_W32_MASK(0, 16, MBOX_IGU1_ISRC);
+ // no more skb to be replaced
+ if ( WAN_SWAP_DESC_BASE[g_ptm_priv_data.itf[0].tx_swap_desc_pos].own ) { // if PP32 hold descriptor
+ IFX_REG_W32_MASK(0, 1 << 16, MBOX_IGU1_IER);
+ return;
+ }
+
+ tasklet_hi_schedule(&g_swap_desc_tasklet);
+ return;
+}
+
+
+static inline int ifx_ptm_version(char *buf)
+{
+ int len = 0;
+ unsigned int major, minor;
+
+ ifx_ptm_get_fw_ver(&major, &minor);
+
+ len += sprintf(buf + len, "PTM %d.%d.%d", IFX_PTM_VER_MAJOR, IFX_PTM_VER_MID, IFX_PTM_VER_MINOR);
+ len += sprintf(buf + len, " PTM (E1) firmware version %d.%d\n", major, minor);
+
+ return len;
+}
+
+static inline int init_priv_data(void)
+{
+ int i, j;
+
+ g_wanqos_en = wanqos_en ? wanqos_en : 8;
+ if ( g_wanqos_en > 8 )
+ g_wanqos_en = 8;
+
+ for ( i = 0; i < ARRAY_SIZE(g_queue_gamma_map); i++ )
+ {
+ g_queue_gamma_map[i] = queue_gamma_map[i] & ((1 << g_wanqos_en) - 1);
+ for ( j = 0; j < i; j++ )
+ g_queue_gamma_map[i] &= ~g_queue_gamma_map[j];
+ }
+
+ memset(&g_ptm_priv_data, 0, sizeof(g_ptm_priv_data));
+
+ {
+ int max_packet_priority = ARRAY_SIZE(g_ptm_prio_queue_map);
+ int tx_num_q;
+ int q_step, q_accum, p_step;
+
+ tx_num_q = __ETH_WAN_TX_QUEUE_NUM;
+ q_step = tx_num_q - 1;
+ p_step = max_packet_priority - 1;
+ for ( j = 0, q_accum = 0; j < max_packet_priority; j++, q_accum += q_step )
+ g_ptm_prio_queue_map[j] = q_step - (q_accum + (p_step >> 1)) / p_step;
+ }
+
+ return 0;
+}
+
+static inline void clear_priv_data(void)
+{
+}
+
+static inline int init_tables(void)
+{
+ struct sk_buff *skb_pool[WAN_RX_DESC_NUM] = {0};
+ struct cfg_std_data_len cfg_std_data_len = {0};
+ struct tx_qos_cfg tx_qos_cfg = {0};
+ struct psave_cfg psave_cfg = {0};
+ struct eg_bwctrl_cfg eg_bwctrl_cfg = {0};
+ struct test_mode test_mode = {0};
+ struct rx_bc_cfg rx_bc_cfg = {0};
+ struct tx_bc_cfg tx_bc_cfg = {0};
+ struct gpio_mode gpio_mode = {0};
+ struct gpio_wm_cfg gpio_wm_cfg = {0};
+ struct rx_gamma_itf_cfg rx_gamma_itf_cfg = {0};
+ struct tx_gamma_itf_cfg tx_gamma_itf_cfg = {0};
+ struct wtx_qos_q_desc_cfg wtx_qos_q_desc_cfg = {0};
+ struct rx_descriptor rx_desc = {0};
+ struct tx_descriptor tx_desc = {0};
+ int i;
+
+ for ( i = 0; i < WAN_RX_DESC_NUM; i++ ) {
+ skb_pool[i] = alloc_skb_rx();
+ if ( skb_pool[i] == NULL )
+ goto ALLOC_SKB_RX_FAIL;
+ }
+
+ cfg_std_data_len.byte_off = RX_HEAD_MAC_ADDR_ALIGNMENT; // this field replaces byte_off in rx descriptor of VDSL ingress
+ cfg_std_data_len.data_len = 1600;
+ *CFG_STD_DATA_LEN = cfg_std_data_len;
+
+ tx_qos_cfg.time_tick = cgu_get_pp32_clock() / 62500; // 16 * (cgu_get_pp32_clock() / 1000000)
+ tx_qos_cfg.overhd_bytes = 0;
+ tx_qos_cfg.eth1_eg_qnum = __ETH_WAN_TX_QUEUE_NUM;
+ tx_qos_cfg.eth1_burst_chk = 1;
+ tx_qos_cfg.eth1_qss = 0;
+ tx_qos_cfg.shape_en = 0; // disable
+ tx_qos_cfg.wfq_en = 0; // strict priority
+ *TX_QOS_CFG = tx_qos_cfg;
+
+ psave_cfg.start_state = 0;
+ psave_cfg.sleep_en = 1; // enable sleep mode
+ *PSAVE_CFG = psave_cfg;
+
+ eg_bwctrl_cfg.fdesc_wm = 16;
+ eg_bwctrl_cfg.class_len = 128;
+ *EG_BWCTRL_CFG = eg_bwctrl_cfg;
+
+ //*GPIO_ADDR = (unsigned int)IFX_GPIO_P0_OUT;
+ *GPIO_ADDR = (unsigned int)0x00000000; // disabled by default
+
+ gpio_mode.gpio_bit_bc1 = 2;
+ gpio_mode.gpio_bit_bc0 = 1;
+ gpio_mode.gpio_bc1_en = 0;
+ gpio_mode.gpio_bc0_en = 0;
+ *GPIO_MODE = gpio_mode;
+
+ gpio_wm_cfg.stop_wm_bc1 = 2;
+ gpio_wm_cfg.start_wm_bc1 = 4;
+ gpio_wm_cfg.stop_wm_bc0 = 2;
+ gpio_wm_cfg.start_wm_bc0 = 4;
+ *GPIO_WM_CFG = gpio_wm_cfg;
+
+ test_mode.mib_clear_mode = 0;
+ test_mode.test_mode = 0;
+ *TEST_MODE = test_mode;
+
+ rx_bc_cfg.local_state = 0;
+ rx_bc_cfg.remote_state = 0;
+ rx_bc_cfg.to_false_th = 7;
+ rx_bc_cfg.to_looking_th = 3;
+ *RX_BC_CFG(0) = rx_bc_cfg;
+ *RX_BC_CFG(1) = rx_bc_cfg;
+
+ tx_bc_cfg.fill_wm = 2;
+ tx_bc_cfg.uflw_wm = 2;
+ *TX_BC_CFG(0) = tx_bc_cfg;
+ *TX_BC_CFG(1) = tx_bc_cfg;
+
+ rx_gamma_itf_cfg.receive_state = 0;
+ rx_gamma_itf_cfg.rx_min_len = 60;
+ rx_gamma_itf_cfg.rx_pad_en = 1;
+ rx_gamma_itf_cfg.rx_eth_fcs_ver_dis = 0;
+ rx_gamma_itf_cfg.rx_rm_eth_fcs = 1;
+ rx_gamma_itf_cfg.rx_tc_crc_ver_dis = 0;
+ rx_gamma_itf_cfg.rx_tc_crc_size = 1;
+ rx_gamma_itf_cfg.rx_eth_fcs_result = 0xC704DD7B;
+ rx_gamma_itf_cfg.rx_tc_crc_result = 0x1D0F1D0F;
+ rx_gamma_itf_cfg.rx_crc_cfg = 0x2500;
+ rx_gamma_itf_cfg.rx_eth_fcs_init_value = 0xFFFFFFFF;
+ rx_gamma_itf_cfg.rx_tc_crc_init_value = 0x0000FFFF;
+ rx_gamma_itf_cfg.rx_max_len_sel = 0;
+ rx_gamma_itf_cfg.rx_edit_num2 = 0;
+ rx_gamma_itf_cfg.rx_edit_pos2 = 0;
+ rx_gamma_itf_cfg.rx_edit_type2 = 0;
+ rx_gamma_itf_cfg.rx_edit_en2 = 0;
+ rx_gamma_itf_cfg.rx_edit_num1 = 0;
+ rx_gamma_itf_cfg.rx_edit_pos1 = 0;
+ rx_gamma_itf_cfg.rx_edit_type1 = 0;
+ rx_gamma_itf_cfg.rx_edit_en1 = 0;
+ rx_gamma_itf_cfg.rx_inserted_bytes_1l = 0;
+ rx_gamma_itf_cfg.rx_inserted_bytes_1h = 0;
+ rx_gamma_itf_cfg.rx_inserted_bytes_2l = 0;
+ rx_gamma_itf_cfg.rx_inserted_bytes_2h = 0;
+ rx_gamma_itf_cfg.rx_len_adj = -6;
+ for ( i = 0; i < 4; i++ )
+ *RX_GAMMA_ITF_CFG(i) = rx_gamma_itf_cfg;
+
+ tx_gamma_itf_cfg.tx_len_adj = 6;
+ tx_gamma_itf_cfg.tx_crc_off_adj = 6;
+ tx_gamma_itf_cfg.tx_min_len = 0;
+ tx_gamma_itf_cfg.tx_eth_fcs_gen_dis = 0;
+ tx_gamma_itf_cfg.tx_tc_crc_size = 1;
+ tx_gamma_itf_cfg.tx_crc_cfg = 0x2F00;
+ tx_gamma_itf_cfg.tx_eth_fcs_init_value = 0xFFFFFFFF;
+ tx_gamma_itf_cfg.tx_tc_crc_init_value = 0x0000FFFF;
+ for ( i = 0; i < ARRAY_SIZE(g_queue_gamma_map); i++ ) {
+ tx_gamma_itf_cfg.queue_mapping = g_queue_gamma_map[i];
+ *TX_GAMMA_ITF_CFG(i) = tx_gamma_itf_cfg;
+ }
+
+ for ( i = 0; i < __ETH_WAN_TX_QUEUE_NUM; i++ ) {
+ wtx_qos_q_desc_cfg.length = WAN_TX_DESC_NUM;
+ wtx_qos_q_desc_cfg.addr = __ETH_WAN_TX_DESC_BASE(i);
+ *WTX_QOS_Q_DESC_CFG(i) = wtx_qos_q_desc_cfg;
+ }
+
+ // default TX queue QoS config is all ZERO
+
+ // TX Ctrl K Table
+ IFX_REG_W32(0x90111293, TX_CTRL_K_TABLE(0));
+ IFX_REG_W32(0x14959617, TX_CTRL_K_TABLE(1));
+ IFX_REG_W32(0x18999A1B, TX_CTRL_K_TABLE(2));
+ IFX_REG_W32(0x9C1D1E9F, TX_CTRL_K_TABLE(3));
+ IFX_REG_W32(0xA02122A3, TX_CTRL_K_TABLE(4));
+ IFX_REG_W32(0x24A5A627, TX_CTRL_K_TABLE(5));
+ IFX_REG_W32(0x28A9AA2B, TX_CTRL_K_TABLE(6));
+ IFX_REG_W32(0xAC2D2EAF, TX_CTRL_K_TABLE(7));
+ IFX_REG_W32(0x30B1B233, TX_CTRL_K_TABLE(8));
+ IFX_REG_W32(0xB43536B7, TX_CTRL_K_TABLE(9));
+ IFX_REG_W32(0xB8393ABB, TX_CTRL_K_TABLE(10));
+ IFX_REG_W32(0x3CBDBE3F, TX_CTRL_K_TABLE(11));
+ IFX_REG_W32(0xC04142C3, TX_CTRL_K_TABLE(12));
+ IFX_REG_W32(0x44C5C647, TX_CTRL_K_TABLE(13));
+ IFX_REG_W32(0x48C9CA4B, TX_CTRL_K_TABLE(14));
+ IFX_REG_W32(0xCC4D4ECF, TX_CTRL_K_TABLE(15));
+
+ // init RX descriptor
+ rx_desc.own = 1;
+ rx_desc.c = 0;
+ rx_desc.sop = 1;
+ rx_desc.eop = 1;
+ rx_desc.byteoff = RX_HEAD_MAC_ADDR_ALIGNMENT;
+ rx_desc.datalen = RX_MAX_BUFFER_SIZE - RX_HEAD_MAC_ADDR_ALIGNMENT;
+ for ( i = 0; i < WAN_RX_DESC_NUM; i++ ) {
+ rx_desc.dataptr = (unsigned int)skb_pool[i]->data & 0x0FFFFFFF;
+ WAN_RX_DESC_BASE[i] = rx_desc;
+ }
+
+ // init TX descriptor
+ tx_desc.own = 0;
+ tx_desc.c = 0;
+ tx_desc.sop = 1;
+ tx_desc.eop = 1;
+ tx_desc.byteoff = 0;
+ tx_desc.qid = 0;
+ tx_desc.datalen = 0;
+ tx_desc.small = 0;
+ tx_desc.dataptr = 0;
+ for ( i = 0; i < CPU_TO_WAN_TX_DESC_NUM; i++ )
+ CPU_TO_WAN_TX_DESC_BASE[i] = tx_desc;
+ for ( i = 0; i < WAN_TX_DESC_NUM_TOTAL; i++ )
+ WAN_TX_DESC_BASE(0)[i] = tx_desc;
+
+ // init Swap descriptor
+ for ( i = 0; i < WAN_SWAP_DESC_NUM; i++ )
+ WAN_SWAP_DESC_BASE[i] = tx_desc;
+
+ // init fastpath TX descriptor
+ tx_desc.own = 1;
+ for ( i = 0; i < FASTPATH_TO_WAN_TX_DESC_NUM; i++ )
+ FASTPATH_TO_WAN_TX_DESC_BASE[i] = tx_desc;
+
+ return 0;
+
+ALLOC_SKB_RX_FAIL:
+ while ( i-- > 0 )
+ dev_kfree_skb_any(skb_pool[i]);
+ return -1;
+}
+
+static inline void clear_tables(void)
+{
+ struct sk_buff *skb;
+ int i, j;
+
+ for ( i = 0; i < WAN_RX_DESC_NUM; i++ ) {
+ skb = get_skb_pointer(WAN_RX_DESC_BASE[i].dataptr);
+ if ( skb != NULL )
+ dev_kfree_skb_any(skb);
+ }
+
+ for ( i = 0; i < CPU_TO_WAN_TX_DESC_NUM; i++ ) {
+ skb = get_skb_pointer(CPU_TO_WAN_TX_DESC_BASE[i].dataptr);
+ if ( skb != NULL )
+ dev_kfree_skb_any(skb);
+ }
+
+ for ( j = 0; j < 8; j++ )
+ for ( i = 0; i < WAN_TX_DESC_NUM; i++ ) {
+ skb = get_skb_pointer(WAN_TX_DESC_BASE(j)[i].dataptr);
+ if ( skb != NULL )
+ dev_kfree_skb_any(skb);
+ }
+
+ for ( i = 0; i < WAN_SWAP_DESC_NUM; i++ ) {
+ skb = get_skb_pointer(WAN_SWAP_DESC_BASE[i].dataptr);
+ if ( skb != NULL )
+ dev_kfree_skb_any(skb);
+ }
+
+ for ( i = 0; i < FASTPATH_TO_WAN_TX_DESC_NUM; i++ ) {
+ skb = get_skb_pointer(FASTPATH_TO_WAN_TX_DESC_BASE[i].dataptr);
+ if ( skb != NULL )
+ dev_kfree_skb_any(skb);
+ }
+}
+
+static int ptm_showtime_enter(struct port_cell_info *port_cell, void *xdata_addr)
+{
+ ASSERT(port_cell != NULL, "port_cell is NULL");
+ ASSERT(xdata_addr != NULL, "xdata_addr is NULL");
+
+ // TODO: ReTX set xdata_addr
+ g_xdata_addr = xdata_addr;
+
+ g_showtime = 1;
+
+ IFX_REG_W32(0x0F, UTP_CFG);
+
+ //#ifdef CONFIG_VR9
+ // IFX_REG_W32_MASK(1 << 17, 0, FFSM_CFG0);
+ //#endif
+
+ printk("enter showtime\n");
+
+ return 0;
+}
+
+static int ptm_showtime_exit(void)
+{
+ if ( !g_showtime )
+ return -1;
+
+ //#ifdef CONFIG_VR9
+ // IFX_REG_W32_MASK(0, 1 << 17, FFSM_CFG0);
+ //#endif
+
+ IFX_REG_W32(0x00, UTP_CFG);
+
+ g_showtime = 0;
+
+ // TODO: ReTX clean state
+ g_xdata_addr = NULL;
+
+ printk("leave showtime\n");
+
+ return 0;
+}
+
+
+
+static int ifx_ptm_init(void)
+{
+ int ret;
+ int i;
+ char ver_str[128];
+ struct port_cell_info port_cell = {0};
+
+ ret = init_priv_data();
+ if ( ret != 0 ) {
+ err("INIT_PRIV_DATA_FAIL");
+ goto INIT_PRIV_DATA_FAIL;
+ }
+
+ ifx_ptm_init_chip();
+ ret = init_tables();
+ if ( ret != 0 ) {
+ err("INIT_TABLES_FAIL");
+ goto INIT_TABLES_FAIL;
+ }
+
+ for ( i = 0; i < ARRAY_SIZE(g_net_dev); i++ ) {
+ g_net_dev[i] = alloc_netdev(0, g_net_dev_name[i], ether_setup);
+ if ( g_net_dev[i] == NULL )
+ goto ALLOC_NETDEV_FAIL;
+ ptm_setup(g_net_dev[i], i);
+ }
+
+ for ( i = 0; i < ARRAY_SIZE(g_net_dev); i++ ) {
+ ret = register_netdev(g_net_dev[i]);
+ if ( ret != 0 )
+ goto REGISTER_NETDEV_FAIL;
+ }
+
+ /* register interrupt handler */
+ ret = request_irq(PPE_MAILBOX_IGU1_INT, mailbox_irq_handler, IRQF_DISABLED, "ptm_mailbox_isr", &g_ptm_priv_data);
+ if ( ret ) {
+ if ( ret == -EBUSY ) {
+ err("IRQ may be occupied by other driver, please reconfig to disable it.");
+ }
+ else {
+ err("request_irq fail");
+ }
+ goto REQUEST_IRQ_PPE_MAILBOX_IGU1_INT_FAIL;
+ }
+ disable_irq(PPE_MAILBOX_IGU1_INT);
+
+ ret = ifx_pp32_start(0);
+ if ( ret ) {
+ err("ifx_pp32_start fail!");
+ goto PP32_START_FAIL;
+ }
+ IFX_REG_W32(1 << 16, MBOX_IGU1_IER); // enable SWAP interrupt
+ IFX_REG_W32(~0, MBOX_IGU1_ISRC);
+
+ enable_irq(PPE_MAILBOX_IGU1_INT);
+
+ ifx_mei_atm_showtime_check(&g_showtime, &port_cell, &g_xdata_addr);
+
+ ifx_mei_atm_showtime_enter = ptm_showtime_enter;
+ ifx_mei_atm_showtime_exit = ptm_showtime_exit;
+
+ ifx_ptm_version(ver_str);
+ printk(KERN_INFO "%s", ver_str);
+
+ printk("ifxmips_ptm: PTM init succeed\n");
+
+ return 0;
+
+PP32_START_FAIL:
+ free_irq(PPE_MAILBOX_IGU1_INT, &g_ptm_priv_data);
+REQUEST_IRQ_PPE_MAILBOX_IGU1_INT_FAIL:
+ i = ARRAY_SIZE(g_net_dev);
+REGISTER_NETDEV_FAIL:
+ while ( i-- )
+ unregister_netdev(g_net_dev[i]);
+ i = ARRAY_SIZE(g_net_dev);
+ALLOC_NETDEV_FAIL:
+ while ( i-- ) {
+ free_netdev(g_net_dev[i]);
+ g_net_dev[i] = NULL;
+ }
+INIT_TABLES_FAIL:
+INIT_PRIV_DATA_FAIL:
+ clear_priv_data();
+ printk("ifxmips_ptm: PTM init failed\n");
+ return ret;
+}
+
+static void __exit ifx_ptm_exit(void)
+{
+ int i;
+ ifx_mei_atm_showtime_enter = NULL;
+ ifx_mei_atm_showtime_exit = NULL;
+
+
+ ifx_pp32_stop(0);
+
+ free_irq(PPE_MAILBOX_IGU1_INT, &g_ptm_priv_data);
+
+ for ( i = 0; i < ARRAY_SIZE(g_net_dev); i++ )
+ unregister_netdev(g_net_dev[i]);
+
+ for ( i = 0; i < ARRAY_SIZE(g_net_dev); i++ ) {
+ free_netdev(g_net_dev[i]);
+ g_net_dev[i] = NULL;
+ }
+
+ clear_tables();
+
+ ifx_ptm_uninit_chip();
+
+ clear_priv_data();
+}
+
+#ifndef MODULE
+static int __init wanqos_en_setup(char *line)
+{
+ wanqos_en = simple_strtoul(line, NULL, 0);
+
+ if ( wanqos_en < 1 || wanqos_en > 8 )
+ wanqos_en = 0;
+
+ return 0;
+}
+
+static int __init queue_gamma_map_setup(char *line)
+{
+ char *p;
+ int i;
+
+ for ( i = 0, p = line; i < ARRAY_SIZE(queue_gamma_map) && isxdigit(*p); i++ )
+ {
+ queue_gamma_map[i] = simple_strtoul(p, &p, 0);
+ if ( *p == ',' || *p == ';' || *p == ':' )
+ p++;
+ }
+
+ return 0;
+}
+#endif
+module_init(ifx_ptm_init);
+module_exit(ifx_ptm_exit);
+#ifndef MODULE
+ __setup("wanqos_en=", wanqos_en_setup);
+ __setup("queue_gamma_map=", queue_gamma_map_setup);
+#endif
+
+MODULE_LICENSE("GPL");
diff --git a/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_vdsl.h b/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_vdsl.h
new file mode 100644
index 0000000..b06232d
--- /dev/null
+++ b/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_vdsl.h
@@ -0,0 +1,126 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_ptm_vdsl.h
+** PROJECT : UEIP
+** MODULES : PTM
+**
+** DATE : 7 Jul 2009
+** AUTHOR : Xu Liang
+** DESCRIPTION : PTM driver header file (core functions for VR9)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 07 JUL 2009 Xu Liang Init Version
+*******************************************************************************/
+
+#ifndef IFXMIPS_PTM_VDSL_H
+#define IFXMIPS_PTM_VDSL_H
+
+#include <linux/version.h>
+#include <linux/netdevice.h>
+#include <lantiq_ptm.h>
+#include "ifxmips_ptm_common.h"
+#include "ifxmips_ptm_ppe_common.h"
+#include "ifxmips_ptm_fw_regs_vdsl.h"
+
+#define INT_NUM_IM2_IRL24 (INT_NUM_IM2_IRL0 + 24)
+
+#define IFX_REG_W32(_v, _r) __raw_writel((_v), (volatile unsigned int *)(_r))
+#define IFX_REG_R32(_r) __raw_readl((volatile unsigned int *)(_r))
+#define IFX_REG_W32_MASK(_clr, _set, _r) IFX_REG_W32((IFX_REG_R32((_r)) & ~(_clr)) | (_set), (_r))
+#define SET_BITS(x, msb, lsb, value) (((x) & ~(((1 << ((msb) + 1)) - 1) ^ ((1 << (lsb)) - 1))) | (((value) & ((1 << (1 + (msb) - (lsb))) - 1)) << (lsb)))
+
+
+
+/*
+ * ####################################
+ * Definition
+ * ####################################
+ */
+
+/*
+ * Constant Definition
+ */
+#define ETH_WATCHDOG_TIMEOUT (10 * HZ)
+
+/*
+ * DMA RX/TX Channel Parameters
+ */
+#define MAX_ITF_NUMBER 1
+#define MAX_RX_DMA_CHANNEL_NUMBER 1
+#define MAX_TX_DMA_CHANNEL_NUMBER 1
+#define DATA_BUFFER_ALIGNMENT EMA_ALIGNMENT
+#define DESC_ALIGNMENT 8
+
+/*
+ * Ethernet Frame Definitions
+ */
+#define ETH_MAC_HEADER_LENGTH 14
+#define ETH_CRC_LENGTH 4
+#define ETH_MIN_FRAME_LENGTH 64
+#define ETH_MAX_FRAME_LENGTH (1518 + 4 * 2)
+
+/*
+ * RX Frame Definitions
+ */
+#define RX_MAX_BUFFER_SIZE (1600 + RX_HEAD_MAC_ADDR_ALIGNMENT)
+#define RX_HEAD_MAC_ADDR_ALIGNMENT 2
+#define RX_TAIL_CRC_LENGTH 0 // PTM firmware does not have ethernet frame CRC
+ // The len in descriptor doesn't include ETH_CRC
+ // because ETH_CRC may not present in some configuration
+
+
+
+/*
+ * ####################################
+ * Data Type
+ * ####################################
+ */
+
+struct ptm_itf {
+ unsigned int rx_desc_pos;
+
+ unsigned int tx_desc_pos;
+
+ unsigned int tx_swap_desc_pos;
+
+ struct net_device_stats stats;
+
+ struct napi_struct napi;
+};
+
+struct ptm_priv_data {
+ struct ptm_itf itf[MAX_ITF_NUMBER];
+};
+
+
+
+/*
+ * ####################################
+ * Declaration
+ * ####################################
+ */
+
+extern unsigned int ifx_ptm_dbg_enable;
+
+extern void ifx_ptm_get_fw_ver(unsigned int *major, unsigned int *minor);
+
+extern void ifx_ptm_init_chip(void);
+extern void ifx_ptm_uninit_chip(void);
+
+extern int ifx_pp32_start(int pp32);
+extern void ifx_pp32_stop(int pp32);
+
+extern void ifx_reset_ppe(void);
+
+
+
+#endif // IFXMIPS_PTM_VDSL_H
diff --git a/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_vr9.c b/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_vr9.c
new file mode 100644
index 0000000..0a02569
--- /dev/null
+++ b/package/platform/lantiq/ltq-ptm/src/ifxmips_ptm_vr9.c
@@ -0,0 +1,295 @@
+/******************************************************************************
+**
+** FILE NAME : ifxmips_ptm_vr9.c
+** PROJECT : UEIP
+** MODULES : PTM
+**
+** DATE : 7 Jul 2009
+** AUTHOR : Xu Liang
+** DESCRIPTION : PTM driver common source file (core functions)
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 07 JUL 2009 Xu Liang Init Version
+*******************************************************************************/
+
+
+
+/*
+ * ####################################
+ * Head File
+ * ####################################
+ */
+
+/*
+ * Common Head File
+ */
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/version.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/proc_fs.h>
+#include <linux/init.h>
+#include <linux/ioctl.h>
+#include <asm/delay.h>
+
+/*
+ * Chip Specific Head File
+ */
+#include "ifxmips_ptm_vdsl.h"
+#include "ifxmips_ptm_fw_vr9.h"
+
+#include <lantiq_soc.h>
+
+static inline void init_pmu(void);
+static inline void uninit_pmu(void);
+static inline void reset_ppe(void);
+static inline void init_pdma(void);
+static inline void init_mailbox(void);
+static inline void init_atm_tc(void);
+static inline void clear_share_buffer(void);
+
+#define IFX_PMU_MODULE_PPE_SLL01 BIT(19)
+#define IFX_PMU_MODULE_PPE_TC BIT(21)
+#define IFX_PMU_MODULE_PPE_EMA BIT(22)
+#define IFX_PMU_MODULE_PPE_QSB BIT(18)
+#define IFX_PMU_MODULE_AHBS BIT(13)
+#define IFX_PMU_MODULE_DSL_DFE BIT(9)
+
+
+static inline void init_pmu(void)
+{
+ ltq_pmu_enable(IFX_PMU_MODULE_PPE_SLL01 |
+ IFX_PMU_MODULE_PPE_TC |
+ IFX_PMU_MODULE_PPE_EMA |
+ IFX_PMU_MODULE_AHBS |
+ IFX_PMU_MODULE_DSL_DFE);
+
+}
+
+static inline void uninit_pmu(void)
+{
+}
+
+static inline void reset_ppe(void)
+{
+/*#ifdef MODULE
+ // reset PPE
+ ifx_rcu_rst(IFX_RCU_DOMAIN_DSLDFE, IFX_RCU_MODULE_PTM);
+ udelay(1000);
+ ifx_rcu_rst(IFX_RCU_DOMAIN_DSLTC, IFX_RCU_MODULE_PTM);
+ udelay(1000);
+ ifx_rcu_rst(IFX_RCU_DOMAIN_PPE, IFX_RCU_MODULE_PTM);
+ udelay(1000);
+ *PP32_SRST &= ~0x000303CF;
+ udelay(1000);
+ *PP32_SRST |= 0x000303CF;
+ udelay(1000);
+#endif*/
+}
+
+static inline void init_pdma(void)
+{
+ IFX_REG_W32(0x00000001, PDMA_CFG);
+ IFX_REG_W32(0x00082C00, PDMA_RX_CTX_CFG);
+ IFX_REG_W32(0x00081B00, PDMA_TX_CTX_CFG);
+ IFX_REG_W32(0x02040604, PDMA_RX_MAX_LEN_REG);
+ IFX_REG_W32(0x000F003F, PDMA_RX_DELAY_CFG);
+
+ IFX_REG_W32(0x00000011, SAR_MODE_CFG);
+ IFX_REG_W32(0x00082A00, SAR_RX_CTX_CFG);
+ IFX_REG_W32(0x00082E00, SAR_TX_CTX_CFG);
+ IFX_REG_W32(0x00001021, SAR_POLY_CFG_SET0);
+ IFX_REG_W32(0x1EDC6F41, SAR_POLY_CFG_SET1);
+ IFX_REG_W32(0x04C11DB7, SAR_POLY_CFG_SET2);
+ IFX_REG_W32(0x00000F3E, SAR_CRC_SIZE_CFG);
+
+ IFX_REG_W32(0x01001900, SAR_PDMA_RX_CMDBUF_CFG);
+ IFX_REG_W32(0x01001A00, SAR_PDMA_TX_CMDBUF_CFG);
+}
+
+static inline void init_mailbox(void)
+{
+ IFX_REG_W32(0xFFFFFFFF, MBOX_IGU1_ISRC);
+ IFX_REG_W32(0x00000000, MBOX_IGU1_IER);
+ IFX_REG_W32(0xFFFFFFFF, MBOX_IGU3_ISRC);
+ IFX_REG_W32(0x00000000, MBOX_IGU3_IER);
+}
+
+static inline void init_atm_tc(void)
+{
+ IFX_REG_W32(0x00010040, SFSM_CFG0);
+ IFX_REG_W32(0x00010040, SFSM_CFG1);
+ IFX_REG_W32(0x00020000, SFSM_PGCNT0);
+ IFX_REG_W32(0x00020000, SFSM_PGCNT1);
+ IFX_REG_W32(0x00000000, DREG_AT_IDLE0);
+ IFX_REG_W32(0x00000000, DREG_AT_IDLE1);
+ IFX_REG_W32(0x00000000, DREG_AR_IDLE0);
+ IFX_REG_W32(0x00000000, DREG_AR_IDLE1);
+ IFX_REG_W32(0x0000080C, DREG_B0_LADR);
+ IFX_REG_W32(0x0000080C, DREG_B1_LADR);
+
+ IFX_REG_W32(0x000001F0, DREG_AR_CFG0);
+ IFX_REG_W32(0x000001F0, DREG_AR_CFG1);
+ IFX_REG_W32(0x000001E0, DREG_AT_CFG0);
+ IFX_REG_W32(0x000001E0, DREG_AT_CFG1);
+
+ /* clear sync state */
+ //IFX_REG_W32(0, SFSM_STATE0);
+ //IFX_REG_W32(0, SFSM_STATE1);
+
+ IFX_REG_W32_MASK(0, 1 << 14, SFSM_CFG0); // enable SFSM storing
+ IFX_REG_W32_MASK(0, 1 << 14, SFSM_CFG1);
+
+ IFX_REG_W32_MASK(0, 1 << 15, SFSM_CFG0); // HW keep the IDLE cells in RTHA buffer
+ IFX_REG_W32_MASK(0, 1 << 15, SFSM_CFG1);
+
+ IFX_REG_W32(0xF0D10000, FFSM_IDLE_HEAD_BC0);
+ IFX_REG_W32(0xF0D10000, FFSM_IDLE_HEAD_BC1);
+ IFX_REG_W32(0x00030028, FFSM_CFG0); // Force_idle
+ IFX_REG_W32(0x00030028, FFSM_CFG1);
+}
+
+static inline void clear_share_buffer(void)
+{
+ volatile u32 *p;
+ unsigned int i;
+
+ p = SB_RAM0_ADDR(0);
+ for ( i = 0; i < SB_RAM0_DWLEN + SB_RAM1_DWLEN + SB_RAM2_DWLEN + SB_RAM3_DWLEN; i++ )
+ IFX_REG_W32(0, p++);
+
+ p = SB_RAM6_ADDR(0);
+ for ( i = 0; i < SB_RAM6_DWLEN; i++ )
+ IFX_REG_W32(0, p++);
+}
+
+/*
+ * Description:
+ * Download PPE firmware binary code.
+ * Input:
+ * pp32 --- int, which pp32 core
+ * src --- u32 *, binary code buffer
+ * dword_len --- unsigned int, binary code length in DWORD (32-bit)
+ * Output:
+ * int --- 0: Success
+ * else: Error Code
+ */
+static inline int pp32_download_code(int pp32, u32 *code_src, unsigned int code_dword_len, u32 *data_src, unsigned int data_dword_len)
+{
+ unsigned int clr, set;
+ volatile u32 *dest;
+
+ if ( code_src == 0 || ((unsigned long)code_src & 0x03) != 0
+ || data_src == 0 || ((unsigned long)data_src & 0x03) != 0 )
+ return -1;
+
+ clr = pp32 ? 0xF0 : 0x0F;
+ if ( code_dword_len <= CDM_CODE_MEMORYn_DWLEN(0) )
+ set = pp32 ? (3 << 6): (2 << 2);
+ else
+ set = 0x00;
+ IFX_REG_W32_MASK(clr, set, CDM_CFG);
+
+ /* copy code */
+ dest = CDM_CODE_MEMORY(pp32, 0);
+ while ( code_dword_len-- > 0 )
+ IFX_REG_W32(*code_src++, dest++);
+
+ /* copy data */
+ dest = CDM_DATA_MEMORY(pp32, 0);
+ while ( data_dword_len-- > 0 )
+ IFX_REG_W32(*data_src++, dest++);
+
+ return 0;
+}
+
+
+
+/*
+ * ####################################
+ * Global Function
+ * ####################################
+ */
+
+extern void ifx_ptm_get_fw_ver(unsigned int *major, unsigned int *minor)
+{
+ ASSERT(major != NULL, "pointer is NULL");
+ ASSERT(minor != NULL, "pointer is NULL");
+
+ *major = FW_VER_ID->major;
+ *minor = FW_VER_ID->minor;
+}
+
+void ifx_ptm_init_chip(void)
+{
+ init_pmu();
+
+ reset_ppe();
+
+ init_pdma();
+
+ init_mailbox();
+
+ init_atm_tc();
+
+ clear_share_buffer();
+}
+
+void ifx_ptm_uninit_chip(void)
+{
+ uninit_pmu();
+}
+
+/*
+ * Description:
+ * Initialize and start up PP32.
+ * Input:
+ * none
+ * Output:
+ * int --- 0: Success
+ * else: Error Code
+ */
+int ifx_pp32_start(int pp32)
+{
+ unsigned int mask = 1 << (pp32 << 4);
+ int ret;
+
+ /* download firmware */
+ ret = pp32_download_code(pp32, firmware_binary_code, sizeof(firmware_binary_code) / sizeof(*firmware_binary_code), firmware_binary_data, sizeof(firmware_binary_data) / sizeof(*firmware_binary_data));
+ if ( ret != 0 )
+ return ret;
+
+ /* run PP32 */
+ IFX_REG_W32_MASK(mask, 0, PP32_FREEZE);
+
+ /* idle for a while to let PP32 init itself */
+ udelay(10);
+
+ return 0;
+}
+
+/*
+ * Description:
+ * Halt PP32.
+ * Input:
+ * none
+ * Output:
+ * none
+ */
+void ifx_pp32_stop(int pp32)
+{
+ unsigned int mask = 1 << (pp32 << 4);
+
+ /* halt PP32 */
+ IFX_REG_W32_MASK(0, mask, PP32_FREEZE);
+}
diff --git a/package/platform/lantiq/ltq-tapi/.svn/entries b/package/platform/lantiq/ltq-tapi/.svn/entries
new file mode 100644
index 0000000..ea5f8a8
--- /dev/null
+++ b/package/platform/lantiq/ltq-tapi/.svn/entries
@@ -0,0 +1,99 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/platform/lantiq/ltq-tapi
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-12-15T02:00:45.545494Z
+34695
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+patches
+dir
+
+Config.in
+file
+
+
+
+
+2013-03-17T12:13:11.000000Z
+d2ece8c67087080f79faabb1cd4d54f9
+2012-12-15T02:00:45.545494Z
+34695
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2493
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:11.000000Z
+9f1728eb931eb7a3d09d2758d174bc1b
+2012-12-15T02:00:45.545494Z
+34695
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2269
+
diff --git a/package/platform/lantiq/ltq-tapi/.svn/text-base/Config.in.svn-base b/package/platform/lantiq/ltq-tapi/.svn/text-base/Config.in.svn-base
new file mode 100644
index 0000000..84dbef2
--- /dev/null
+++ b/package/platform/lantiq/ltq-tapi/.svn/text-base/Config.in.svn-base
@@ -0,0 +1,88 @@
+config VOICE_CPE_TAPI_FAX
+ bool "fax relay and modem support"
+ depends on PACKAGE_kmod-ltq-tapi
+ default n
+ help
+ Option to enable fax/modem support in TAPI.
+ Note: Newer platforms as AR9 and VR9 support a T.38 fax relay stack
+ in FW while older platforms like Danube or VINETIC-CPE require a
+ separate SW stack executed as an application.
+
+config VOICE_CPE_TAPI_CID
+ bool "CID support"
+ depends on PACKAGE_kmod-ltq-tapi
+ default y
+ help
+ Option to enable Caller ID support.
+
+config VOICE_CPE_TAPI_LT_GR909
+ bool "Linetesting GR-909 support"
+ depends on PACKAGE_kmod-ltq-tapi
+ default y
+ help
+ Option to enable linetesting GR-909.
+
+config VOICE_CPE_TAPI_DECT
+ bool "DECT encoding for COSIC modem"
+ depends on PACKAGE_kmod-ltq-tapi
+ default n
+ help
+ Option to enable DECT encoding for COSIC modem.
+
+config VOICE_CPE_TAPI_KPI
+ bool "KPI (Kernel Packet Interface)"
+ depends on PACKAGE_kmod-ltq-tapi
+ default y
+ help
+ Option to enable the generic kernel level packet interface
+ which allows accelerated packet transfer for various purposes.
+ The most important example is the QOS option, which allows
+ to redirect RTP packets directly into the IP stack.
+ Other options relying on KPI are DECT and HDLC.
+
+config VOICE_CPE_TAPI_QOS
+ bool "QOS for accelerated RTP packet handling"
+ depends on PACKAGE_kmod-ltq-tapi
+ default y
+ help
+ Option to enable an accelerated RTP packet transfer inside
+ the LINUX kernel space. This option requires the KPI2UDP
+ packet, which actually provides the OS specific hooks in
+ the IP stack.
+
+config VOICE_CPE_TAPI_STATISTICS
+ bool "TAPI statistics via /proc fs"
+ depends on PACKAGE_kmod-ltq-tapi
+ default y
+ help
+ Option to enable /proc fs statistics for packet counts etc.
+
+config VOICE_CPE_TAPI_METERING
+ bool "Metering (TTX) support"
+ depends on PACKAGE_kmod-ltq-tapi
+ default n
+ help
+ Option to enable metering (TTX) support.
+
+config VOICE_CPE_TAPI_HDLC
+ bool "PCM HDLC support, evaluation"
+ depends on PACKAGE_kmod-ltq-tapi
+ default n
+ help
+ Option to enable PCM HDLC framing inside the firmware, e.g. for
+ ISDN D-Channel access.
+
+config VOICE_CPE_TAPI_TRACES
+ bool "enable driver traces"
+ depends on PACKAGE_kmod-ltq-tapi
+ default y
+ help
+ enable driver traces with different trace levels to be
+ configured dynamically from the application or during insmod
+
+config VOICE_CPE_TAPI_LINUX_HOTPLUG
+ bool "enable driver Linux hotplug events"
+ depends on PACKAGE_kmod-ltq-tapi
+ default y
+ help
+ enable driver Linux hotplug events generation
diff --git a/package/platform/lantiq/ltq-tapi/.svn/text-base/Makefile.svn-base b/package/platform/lantiq/ltq-tapi/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..2582235
--- /dev/null
+++ b/package/platform/lantiq/ltq-tapi/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,70 @@
+#
+# Copyright (C) 2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=drv_tapi
+PKG_VERSION:=3.13.0
+PKG_RELEASE:=3
+
+PKG_SOURCE:=drv_tapi-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=http://mirror2.openwrt.org/sources
+PKG_MD5SUM:=edb43b494832c540cc035493d18db58f
+PKG_MAINTAINER:=John Crispin <blogic@openwrt.org>
+
+include $(INCLUDE_DIR)/ltqtapi.mk
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/ltq-tapi
+ SUBMENU:=Voice over IP
+ TITLE:=Lantiq TAPI subsystem
+ URL:=http://www.lantiq.com/
+ DEPENDS:=$(LTQ_TAPI_TARGET) +kmod-ltq-ifxos
+ FILES:=$(PKG_BUILD_DIR)/src/drv_tapi.ko
+ AUTOLOAD:=$(call AutoLoad,20,drv_tapi)
+endef
+
+define KernelPackage/ltq-tapi/description
+ Voice Subsystem Telephony API High Level Driver
+endef
+
+define KernelPackage/ltq-tapi/config
+ source "$(SOURCE)/Config.in"
+endef
+
+CONFIGURE_ARGS += \
+ ARCH=$(LINUX_KARCH) \
+ --enable-linux-26 \
+ --enable-kernelbuild="$(LINUX_DIR)" \
+ --enable-kernelincl="$(LINUX_DIR)/include" \
+ --with-ifxos-incl=$(STAGING_DIR)/usr/include/ifxos \
+ $(call autoconf_bool,CONFIG_IFX_DRV_TAPI_EVENT_LOGGER,el-debug) \
+ $(call autoconf_bool,CONFIG_VOICE_CPE_TAPI_FAX,fax t38) \
+ $(call autoconf_bool,CONFIG_VOICE_CPE_TAPI_CID,cid) \
+ $(call autoconf_bool,CONFIG_VOICE_CPE_TAPI_DECT,dect) \
+ $(call autoconf_bool,CONFIG_VOICE_CPE_TAPI_KPI,kpi) \
+ $(call autoconf_bool,CONFIG_VOICE_CPE_TAPI_QOS,qos) \
+ $(call autoconf_bool,CONFIG_VOICE_CPE_TAPI_LT_GR909,lt) \
+ $(call autoconf_bool,CONFIG_VOICE_CPE_TAPI_STATISTICS,statistics) \
+ $(call autoconf_bool,CONFIG_VOICE_CPE_TAPI_METERING,metering) \
+ $(call autoconf_bool,CONFIG_VOICE_CPE_TAPI_HDLC,hdlc) \
+ $(call autoconf_bool,CONFIG_VOICE_CPE_TAPI_TRACES,trace) \
+ $(call autoconf_bool,CONFIG_VOICE_CPE_TAPI_LINUX_HOTPLUG,hotplug)
+
+define Build/Configure
+ (cd $(PKG_BUILD_DIR); aclocal && autoconf && automake)
+ $(call Build/Configure/Default)
+endef
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include/drv_tapi
+ $(CP) --dereference $(PKG_BUILD_DIR)/include/* $(1)/usr/include/drv_tapi
+ (cd $(1)/usr/include/drv_tapi && ln -s . include && ln -s ../ifxos/ifx_types.h .)
+endef
+
+$(eval $(call KernelPackage,ltq-tapi))
diff --git a/package/platform/lantiq/ltq-tapi/Config.in b/package/platform/lantiq/ltq-tapi/Config.in
new file mode 100644
index 0000000..84dbef2
--- /dev/null
+++ b/package/platform/lantiq/ltq-tapi/Config.in
@@ -0,0 +1,88 @@
+config VOICE_CPE_TAPI_FAX
+ bool "fax relay and modem support"
+ depends on PACKAGE_kmod-ltq-tapi
+ default n
+ help
+ Option to enable fax/modem support in TAPI.
+ Note: Newer platforms as AR9 and VR9 support a T.38 fax relay stack
+ in FW while older platforms like Danube or VINETIC-CPE require a
+ separate SW stack executed as an application.
+
+config VOICE_CPE_TAPI_CID
+ bool "CID support"
+ depends on PACKAGE_kmod-ltq-tapi
+ default y
+ help
+ Option to enable Caller ID support.
+
+config VOICE_CPE_TAPI_LT_GR909
+ bool "Linetesting GR-909 support"
+ depends on PACKAGE_kmod-ltq-tapi
+ default y
+ help
+ Option to enable linetesting GR-909.
+
+config VOICE_CPE_TAPI_DECT
+ bool "DECT encoding for COSIC modem"
+ depends on PACKAGE_kmod-ltq-tapi
+ default n
+ help
+ Option to enable DECT encoding for COSIC modem.
+
+config VOICE_CPE_TAPI_KPI
+ bool "KPI (Kernel Packet Interface)"
+ depends on PACKAGE_kmod-ltq-tapi
+ default y
+ help
+ Option to enable the generic kernel level packet interface
+ which allows accelerated packet transfer for various purposes.
+ The most important example is the QOS option, which allows
+ to redirect RTP packets directly into the IP stack.
+ Other options relying on KPI are DECT and HDLC.
+
+config VOICE_CPE_TAPI_QOS
+ bool "QOS for accelerated RTP packet handling"
+ depends on PACKAGE_kmod-ltq-tapi
+ default y
+ help
+ Option to enable an accelerated RTP packet transfer inside
+ the LINUX kernel space. This option requires the KPI2UDP
+ packet, which actually provides the OS specific hooks in
+ the IP stack.
+
+config VOICE_CPE_TAPI_STATISTICS
+ bool "TAPI statistics via /proc fs"
+ depends on PACKAGE_kmod-ltq-tapi
+ default y
+ help
+ Option to enable /proc fs statistics for packet counts etc.
+
+config VOICE_CPE_TAPI_METERING
+ bool "Metering (TTX) support"
+ depends on PACKAGE_kmod-ltq-tapi
+ default n
+ help
+ Option to enable metering (TTX) support.
+
+config VOICE_CPE_TAPI_HDLC
+ bool "PCM HDLC support, evaluation"
+ depends on PACKAGE_kmod-ltq-tapi
+ default n
+ help
+ Option to enable PCM HDLC framing inside the firmware, e.g. for
+ ISDN D-Channel access.
+
+config VOICE_CPE_TAPI_TRACES
+ bool "enable driver traces"
+ depends on PACKAGE_kmod-ltq-tapi
+ default y
+ help
+ enable driver traces with different trace levels to be
+ configured dynamically from the application or during insmod
+
+config VOICE_CPE_TAPI_LINUX_HOTPLUG
+ bool "enable driver Linux hotplug events"
+ depends on PACKAGE_kmod-ltq-tapi
+ default y
+ help
+ enable driver Linux hotplug events generation
diff --git a/package/platform/lantiq/ltq-tapi/Makefile b/package/platform/lantiq/ltq-tapi/Makefile
new file mode 100644
index 0000000..2582235
--- /dev/null
+++ b/package/platform/lantiq/ltq-tapi/Makefile
@@ -0,0 +1,70 @@
+#
+# Copyright (C) 2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=drv_tapi
+PKG_VERSION:=3.13.0
+PKG_RELEASE:=3
+
+PKG_SOURCE:=drv_tapi-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=http://mirror2.openwrt.org/sources
+PKG_MD5SUM:=edb43b494832c540cc035493d18db58f
+PKG_MAINTAINER:=John Crispin <blogic@openwrt.org>
+
+include $(INCLUDE_DIR)/ltqtapi.mk
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/ltq-tapi
+ SUBMENU:=Voice over IP
+ TITLE:=Lantiq TAPI subsystem
+ URL:=http://www.lantiq.com/
+ DEPENDS:=$(LTQ_TAPI_TARGET) +kmod-ltq-ifxos
+ FILES:=$(PKG_BUILD_DIR)/src/drv_tapi.ko
+ AUTOLOAD:=$(call AutoLoad,20,drv_tapi)
+endef
+
+define KernelPackage/ltq-tapi/description
+ Voice Subsystem Telephony API High Level Driver
+endef
+
+define KernelPackage/ltq-tapi/config
+ source "$(SOURCE)/Config.in"
+endef
+
+CONFIGURE_ARGS += \
+ ARCH=$(LINUX_KARCH) \
+ --enable-linux-26 \
+ --enable-kernelbuild="$(LINUX_DIR)" \
+ --enable-kernelincl="$(LINUX_DIR)/include" \
+ --with-ifxos-incl=$(STAGING_DIR)/usr/include/ifxos \
+ $(call autoconf_bool,CONFIG_IFX_DRV_TAPI_EVENT_LOGGER,el-debug) \
+ $(call autoconf_bool,CONFIG_VOICE_CPE_TAPI_FAX,fax t38) \
+ $(call autoconf_bool,CONFIG_VOICE_CPE_TAPI_CID,cid) \
+ $(call autoconf_bool,CONFIG_VOICE_CPE_TAPI_DECT,dect) \
+ $(call autoconf_bool,CONFIG_VOICE_CPE_TAPI_KPI,kpi) \
+ $(call autoconf_bool,CONFIG_VOICE_CPE_TAPI_QOS,qos) \
+ $(call autoconf_bool,CONFIG_VOICE_CPE_TAPI_LT_GR909,lt) \
+ $(call autoconf_bool,CONFIG_VOICE_CPE_TAPI_STATISTICS,statistics) \
+ $(call autoconf_bool,CONFIG_VOICE_CPE_TAPI_METERING,metering) \
+ $(call autoconf_bool,CONFIG_VOICE_CPE_TAPI_HDLC,hdlc) \
+ $(call autoconf_bool,CONFIG_VOICE_CPE_TAPI_TRACES,trace) \
+ $(call autoconf_bool,CONFIG_VOICE_CPE_TAPI_LINUX_HOTPLUG,hotplug)
+
+define Build/Configure
+ (cd $(PKG_BUILD_DIR); aclocal && autoconf && automake)
+ $(call Build/Configure/Default)
+endef
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include/drv_tapi
+ $(CP) --dereference $(PKG_BUILD_DIR)/include/* $(1)/usr/include/drv_tapi
+ (cd $(1)/usr/include/drv_tapi && ln -s . include && ln -s ../ifxos/ifx_types.h .)
+endef
+
+$(eval $(call KernelPackage,ltq-tapi))
diff --git a/package/platform/lantiq/ltq-tapi/patches/.svn/entries b/package/platform/lantiq/ltq-tapi/patches/.svn/entries
new file mode 100644
index 0000000..df810ef
--- /dev/null
+++ b/package/platform/lantiq/ltq-tapi/patches/.svn/entries
@@ -0,0 +1,130 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/platform/lantiq/ltq-tapi/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-12-15T02:00:45.545494Z
+34695
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+200-linux-37.patch
+file
+
+
+
+
+2013-03-17T12:13:11.000000Z
+0775b777b17612cd12fc195e3353f644
+2012-12-15T02:00:45.545494Z
+34695
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3561
+
+100-ifxmips.patch
+file
+
+
+
+
+2013-03-17T12:13:11.000000Z
+4047484ef482235d207a792f5dafe127
+2012-12-15T02:00:45.545494Z
+34695
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3244
+
+000-portability.patch
+file
+
+
+
+
+2013-03-17T12:13:11.000000Z
+f41cd79f61b2c582d5f4c84bcfd70eb1
+2012-12-15T02:00:45.545494Z
+34695
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3323
+
diff --git a/package/platform/lantiq/ltq-tapi/patches/.svn/text-base/000-portability.patch.svn-base b/package/platform/lantiq/ltq-tapi/patches/.svn/text-base/000-portability.patch.svn-base
new file mode 100644
index 0000000..78fcbad
--- /dev/null
+++ b/package/platform/lantiq/ltq-tapi/patches/.svn/text-base/000-portability.patch.svn-base
@@ -0,0 +1,82 @@
+--- a/src/Makefile.am
++++ b/src/Makefile.am
+@@ -154,7 +154,7 @@ if KERNEL_2_6
+ drv_tapi_OBJS = "$(subst .c,.o, $(drv_tapi_SOURCES))"
+
+ drv_tapi.ko: $(drv_tapi_SOURCES) $(EXTRA_DIST)
+- @echo -e "Making Linux 2.6.x kernel object"
++ @echo "Making Linux 2.6.x kernel object"
+ @for f in $(drv_tapi_SOURCES) ; do \
+ if test ! -e $(PWD)/$$f; then \
+ echo " LN $$f" ; \
+@@ -162,10 +162,10 @@ drv_tapi.ko: $(drv_tapi_SOURCES) $(EXTRA
+ ln -s @abs_srcdir@/$$f $(PWD)/$$f; \
+ fi; \
+ done;
+- @echo -e "# drv_tapi: Generated to build Linux 2.6.x kernel object" > $(PWD)/Kbuild
+- @echo -e "obj-m := $(subst .ko,.o,$@)" >> $(PWD)/Kbuild
+- @echo -e "$(subst .ko,,$@)-y := $(drv_tapi_OBJS)" >> $(PWD)/Kbuild
+- @echo -e "EXTRA_CFLAGS := -DHAVE_CONFIG_H $(CFLAGS) $(drv_tapi_CFLAGS) $(INCLUDES)" >> $(PWD)/Kbuild
++ @echo "# drv_tapi: Generated to build Linux 2.6.x kernel object" > $(PWD)/Kbuild
++ @echo "obj-m := $(subst .ko,.o,$@)" >> $(PWD)/Kbuild
++ @echo "$(subst .ko,,$@)-y := $(drv_tapi_OBJS)" >> $(PWD)/Kbuild
++ @echo "EXTRA_CFLAGS := -DHAVE_CONFIG_H $(CFLAGS) $(drv_tapi_CFLAGS) $(INCLUDES)" >> $(PWD)/Kbuild
+ $(MAKE) ARCH=@KERNEL_ARCH@ -C @KERNEL_BUILD_PATH@ O=@KERNEL_BUILD_PATH@ M=$(PWD) modules
+
+ clean-generic:
+--- a/configure.in
++++ b/configure.in
+@@ -128,7 +128,7 @@ dnl Set kernel build path
+ AC_ARG_ENABLE(kernelbuild,
+ AS_HELP_STRING(--enable-kernelbuild=x,Set the target kernel build path),
+ [
+- if test -r $enableval/include/linux/autoconf.h; then
++ if test -e $enableval/include/linux/autoconf.h -o -e $enableval/include/generated/autoconf.h; then
+ AC_SUBST([KERNEL_BUILD_PATH],[$enableval])
+ else
+ AC_MSG_ERROR([The kernel build directory is not valid or not configured!])
+--- a/src/drv_tapi_linux.h
++++ b/src/drv_tapi_linux.h
+@@ -24,6 +24,7 @@
+ #include <linux/version.h>
+ #include <linux/interrupt.h> /* in_interrupt() */
+ #include <linux/delay.h> /* mdelay - udelay */
++#include <linux/workqueue.h> /* work_struct */
+ #include <asm/poll.h> /* POLLIN, POLLOUT */
+
+ #include "ifx_types.h" /* ifx type definitions */
+--- a/src/drv_tapi_linux.c
++++ b/src/drv_tapi_linux.c
+@@ -47,6 +47,7 @@
+ #include <linux/errno.h>
+ #include <asm/uaccess.h> /* copy_from_user(), ... */
+ #include <asm/byteorder.h>
++#include <linux/smp_lock.h> /* lock_kernel() */
+ #include <asm/io.h>
+
+ #ifdef LINUX_2_6
+@@ -55,7 +56,11 @@
+ #include <linux/sched.h>
+ #undef CONFIG_DEVFS_FS
+ #ifndef UTS_RELEASE
+- #include "linux/utsrelease.h"
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33))
++# include <linux/utsrelease.h>
++#else
++# include <generated/utsrelease.h>
++#endif
+ #endif /* UTC_RELEASE */
+ #else
+ #include <linux/tqueue.h>
+@@ -3718,7 +3723,11 @@ IFX_void_t TAPI_OS_ThreadKill(IFXOS_Thre
+ flag and released after the down() call. */
+ lock_kernel();
+ mb();
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)
+ kill_proc(pThrCntrl->tid, SIGKILL, 1);
++#else
++ kill_pid(find_vpid(pThrCntrl->tid), SIGKILL, 1);
++#endif
+ /* release the big kernel lock */
+ unlock_kernel();
+ wait_for_completion (&pThrCntrl->thrCompletion);
diff --git a/package/platform/lantiq/ltq-tapi/patches/.svn/text-base/100-ifxmips.patch.svn-base b/package/platform/lantiq/ltq-tapi/patches/.svn/text-base/100-ifxmips.patch.svn-base
new file mode 100644
index 0000000..a9c0d81
--- /dev/null
+++ b/package/platform/lantiq/ltq-tapi/patches/.svn/text-base/100-ifxmips.patch.svn-base
@@ -0,0 +1,96 @@
+--- a/src/drv_tapi_linux.c
++++ b/src/drv_tapi_linux.c
+@@ -552,7 +552,7 @@ static ssize_t ifx_tapi_write (struct fi
+ IFX_uint8_t *pData;
+ IFX_size_t buf_size;
+ #endif /* TAPI_PACKET */
+- IFX_ssize_t size = 0;
++ ssize_t size = 0;
+
+ #ifdef TAPI_PACKET
+ if (pTapiDev->bInitialized == IFX_FALSE)
+--- a/src/drv_tapi_osmap.h
++++ b/src/drv_tapi_osmap.h
+@@ -17,39 +17,6 @@
+ */
+
+ #include "ifx_types.h" /* ifx type definitions */
+-
+-#ifndef HAVE_IFX_ULONG_T
+- #warning please update your ifx_types.h, using local definition of IFX_ulong_t
+- /* unsigned long type - valid for 32bit systems only */
+- typedef unsigned long IFX_ulong_t;
+- #define HAVE_IFX_ULONG_T
+-#endif /* HAVE_IFX_ULONG_T */
+-
+-#ifndef HAVE_IFX_LONG_T
+- #warning please update your ifx_types.h, using local definition of IFX_long_t
+- /* long type - valid for 32bit systems only */
+- typedef long IFX_long_t;
+- #define HAVE_IFX_LONG_T
+-#endif /* HAVE_IFX_LONG_T */
+-
+-#ifndef HAVE_IFX_INTPTR_T
+- #warning please update your ifx_types.h, using local definition of IFX_intptr_t
+- typedef IFX_long_t IFX_intptr_t;
+- #define HAVE_IFX_INTPTR_T
+-#endif /* HAVE_IFX_INTPTR_T */
+-
+-#ifndef HAVE_IFX_SIZE_T
+- #warning please update your ifx_types.h, using local definition of IFX_size_t
+- typedef IFX_ulong_t IFX_size_t;
+- #define HAVE_IFX_SIZE_T
+-#endif /* HAVE_IFX_SIZE_T */
+-
+-#ifndef HAVE_IFX_SSIZE_T
+- #warning please update your ifx_types.h, using local definition of IFX_ssize_t
+- typedef IFX_long_t IFX_ssize_t;
+- #define HAVE_IFX_SSIZE_T
+-#endif /* HAVE_IFX_SSIZE_T */
+-
+ #include "ifxos_interrupt.h"
+ #include "ifxos_memory_alloc.h"
+ #include "ifxos_copy_user_space.h"
+--- a/include/drv_tapi_ll_interface.h
++++ b/include/drv_tapi_ll_interface.h
+@@ -40,13 +40,6 @@
+ #include "ifxos_select.h"
+ #endif /* TAPI_PACKET */
+
+-#ifndef HAVE_IFX_ULONG_T
+- #warning please update your ifx_types.h, using local definition of IFX_ulong_t
+- /* unsigned long type - valid for 32bit systems only */
+- typedef unsigned long IFX_ulong_t;
+- #define HAVE_IFX_ULONG_T
+-#endif /* HAVE_IFX_ULONG_T */
+-
+ /* ============================= */
+ /* Local Macros Definitions */
+ /* ============================= */
+--- a/src/lib/lib_bufferpool/lib_bufferpool.c
++++ b/src/lib/lib_bufferpool/lib_bufferpool.c
+@@ -85,24 +85,6 @@
+ #include <stdlib.h>
+ #endif /*VXWORKS*/
+
+-
+-/* ============================= */
+-/* Extra type definitions */
+-/* ============================= */
+-#ifndef HAVE_IFX_ULONG_T
+- #warning please update your ifx_types.h, using local definition of IFX_ulong_t
+- /* unsigned long type - valid for 32bit systems only */
+- typedef unsigned long IFX_ulong_t;
+- #define HAVE_IFX_ULONG_T
+-#endif /* HAVE_IFX_ULONG_T */
+-
+-#ifndef HAVE_IFX_UINTPTR_T
+- #warning please update your ifx_types.h, using local definition of IFX_uintptr_t
+- typedef IFX_ulong_t IFX_uintptr_t;
+- #define HAVE_IFX_UINTPTR_T
+-#endif /* HAVE_IFX_UINTPTR_T */
+-
+-
+ /* ============================= */
+ /* Local Macros & Definitions */
+ /* ============================= */
diff --git a/package/platform/lantiq/ltq-tapi/patches/.svn/text-base/200-linux-37.patch.svn-base b/package/platform/lantiq/ltq-tapi/patches/.svn/text-base/200-linux-37.patch.svn-base
new file mode 100644
index 0000000..9d7428d
--- /dev/null
+++ b/package/platform/lantiq/ltq-tapi/patches/.svn/text-base/200-linux-37.patch.svn-base
@@ -0,0 +1,108 @@
+--- a/src/drv_tapi_linux.c
++++ b/src/drv_tapi_linux.c
+@@ -47,7 +47,9 @@
+ #include <linux/errno.h>
+ #include <asm/uaccess.h> /* copy_from_user(), ... */
+ #include <asm/byteorder.h>
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33))
+ #include <linux/smp_lock.h> /* lock_kernel() */
++#endif
+ #include <asm/io.h>
+
+ #ifdef LINUX_2_6
+@@ -65,7 +67,9 @@
+ #else
+ #include <linux/tqueue.h>
+ #include <linux/sched.h>
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33))
+ #include <linux/smp_lock.h> /* lock_kernel() */
++#endif
+ #endif /* LINUX_2_6 */
+
+ #include "drv_tapi.h"
+@@ -133,8 +137,13 @@
+ size_t count, loff_t * ppos);
+ static ssize_t ifx_tapi_read(struct file * filp, char *buf,
+ size_t length, loff_t * ppos);
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36))
+ static int ifx_tapi_ioctl(struct inode *inode, struct file *filp,
+ unsigned int nCmd, unsigned long nArgument);
++#else
++static long ifx_tapi_ioctl(struct file *filp,
++ unsigned int nCmd, unsigned long nArgument);
++#endif
+ static unsigned int ifx_tapi_poll (struct file *filp, poll_table *table);
+
+ #ifdef CONFIG_PROC_FS
+@@ -218,7 +227,11 @@
+ IFX_char_t *pRegDrvName = IFX_NULL;
+ IFX_int32_t ret = 0;
+
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36))
+ if (tapi_fops.ioctl == IFX_NULL)
++#else
++ if (tapi_fops.unlocked_ioctl == IFX_NULL)
++#endif
+ {
+ #ifdef MODULE
+ tapi_fops.owner = THIS_MODULE;
+@@ -226,7 +239,11 @@
+ tapi_fops.read = ifx_tapi_read;
+ tapi_fops.write = ifx_tapi_write;
+ tapi_fops.poll = ifx_tapi_poll;
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36))
+ tapi_fops.ioctl = ifx_tapi_ioctl;
++#else
++ tapi_fops.unlocked_ioctl = ifx_tapi_ioctl;
++#endif
+ tapi_fops.open = ifx_tapi_open;
+ tapi_fops.release = ifx_tapi_release;
+ }
+@@ -881,8 +898,13 @@
+ - 0 and positive values - success
+ - negative value - ioctl failed
+ */
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36))
+ static int ifx_tapi_ioctl(struct inode *inode, struct file *filp,
+ unsigned int nCmd, unsigned long nArg)
++#else
++static long ifx_tapi_ioctl(struct file *filp,
++ unsigned int nCmd, unsigned long nArg)
++#endif
+ {
+ TAPI_FD_PRIV_DATA_t *pTapiPriv;
+ IFX_TAPI_ioctlCtx_t ctx;
+@@ -3721,7 +3743,9 @@
+ kernel lock (lock_kernel()). The lock must be
+ grabbed before changing the terminate
+ flag and released after the down() call. */
+- lock_kernel();
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
++ lock_kernel();
++#endif
+ mb();
+ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)
+ kill_proc(pThrCntrl->tid, SIGKILL, 1);
+@@ -3729,8 +3753,10 @@
+ kill_pid(find_vpid(pThrCntrl->tid), SIGKILL, 1);
+ #endif
+ /* release the big kernel lock */
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
+ unlock_kernel();
+- wait_for_completion (&pThrCntrl->thrCompletion);
++#endif
++ wait_for_completion (&pThrCntrl->thrCompletion);
+
+ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
+ /* Now we are sure the thread is in zombie state.
+--- a/src/lib/lib_fifo/lib_fifo.c
++++ b/src/lib/lib_fifo/lib_fifo.c
+@@ -41,7 +41,7 @@
+ #ifdef LINUX
+ /* if linux/slab.h is not available, use the precessor linux/malloc.h */
+ #include <linux/slab.h>
+-#elif VXWORKS
++#elif defined(VXWORKS)
+ #include <sys_drv_debug.h>
+ #endif /* LINUX */
+
diff --git a/package/platform/lantiq/ltq-tapi/patches/000-portability.patch b/package/platform/lantiq/ltq-tapi/patches/000-portability.patch
new file mode 100644
index 0000000..78fcbad
--- /dev/null
+++ b/package/platform/lantiq/ltq-tapi/patches/000-portability.patch
@@ -0,0 +1,82 @@
+--- a/src/Makefile.am
++++ b/src/Makefile.am
+@@ -154,7 +154,7 @@ if KERNEL_2_6
+ drv_tapi_OBJS = "$(subst .c,.o, $(drv_tapi_SOURCES))"
+
+ drv_tapi.ko: $(drv_tapi_SOURCES) $(EXTRA_DIST)
+- @echo -e "Making Linux 2.6.x kernel object"
++ @echo "Making Linux 2.6.x kernel object"
+ @for f in $(drv_tapi_SOURCES) ; do \
+ if test ! -e $(PWD)/$$f; then \
+ echo " LN $$f" ; \
+@@ -162,10 +162,10 @@ drv_tapi.ko: $(drv_tapi_SOURCES) $(EXTRA
+ ln -s @abs_srcdir@/$$f $(PWD)/$$f; \
+ fi; \
+ done;
+- @echo -e "# drv_tapi: Generated to build Linux 2.6.x kernel object" > $(PWD)/Kbuild
+- @echo -e "obj-m := $(subst .ko,.o,$@)" >> $(PWD)/Kbuild
+- @echo -e "$(subst .ko,,$@)-y := $(drv_tapi_OBJS)" >> $(PWD)/Kbuild
+- @echo -e "EXTRA_CFLAGS := -DHAVE_CONFIG_H $(CFLAGS) $(drv_tapi_CFLAGS) $(INCLUDES)" >> $(PWD)/Kbuild
++ @echo "# drv_tapi: Generated to build Linux 2.6.x kernel object" > $(PWD)/Kbuild
++ @echo "obj-m := $(subst .ko,.o,$@)" >> $(PWD)/Kbuild
++ @echo "$(subst .ko,,$@)-y := $(drv_tapi_OBJS)" >> $(PWD)/Kbuild
++ @echo "EXTRA_CFLAGS := -DHAVE_CONFIG_H $(CFLAGS) $(drv_tapi_CFLAGS) $(INCLUDES)" >> $(PWD)/Kbuild
+ $(MAKE) ARCH=@KERNEL_ARCH@ -C @KERNEL_BUILD_PATH@ O=@KERNEL_BUILD_PATH@ M=$(PWD) modules
+
+ clean-generic:
+--- a/configure.in
++++ b/configure.in
+@@ -128,7 +128,7 @@ dnl Set kernel build path
+ AC_ARG_ENABLE(kernelbuild,
+ AS_HELP_STRING(--enable-kernelbuild=x,Set the target kernel build path),
+ [
+- if test -r $enableval/include/linux/autoconf.h; then
++ if test -e $enableval/include/linux/autoconf.h -o -e $enableval/include/generated/autoconf.h; then
+ AC_SUBST([KERNEL_BUILD_PATH],[$enableval])
+ else
+ AC_MSG_ERROR([The kernel build directory is not valid or not configured!])
+--- a/src/drv_tapi_linux.h
++++ b/src/drv_tapi_linux.h
+@@ -24,6 +24,7 @@
+ #include <linux/version.h>
+ #include <linux/interrupt.h> /* in_interrupt() */
+ #include <linux/delay.h> /* mdelay - udelay */
++#include <linux/workqueue.h> /* work_struct */
+ #include <asm/poll.h> /* POLLIN, POLLOUT */
+
+ #include "ifx_types.h" /* ifx type definitions */
+--- a/src/drv_tapi_linux.c
++++ b/src/drv_tapi_linux.c
+@@ -47,6 +47,7 @@
+ #include <linux/errno.h>
+ #include <asm/uaccess.h> /* copy_from_user(), ... */
+ #include <asm/byteorder.h>
++#include <linux/smp_lock.h> /* lock_kernel() */
+ #include <asm/io.h>
+
+ #ifdef LINUX_2_6
+@@ -55,7 +56,11 @@
+ #include <linux/sched.h>
+ #undef CONFIG_DEVFS_FS
+ #ifndef UTS_RELEASE
+- #include "linux/utsrelease.h"
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33))
++# include <linux/utsrelease.h>
++#else
++# include <generated/utsrelease.h>
++#endif
+ #endif /* UTC_RELEASE */
+ #else
+ #include <linux/tqueue.h>
+@@ -3718,7 +3723,11 @@ IFX_void_t TAPI_OS_ThreadKill(IFXOS_Thre
+ flag and released after the down() call. */
+ lock_kernel();
+ mb();
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)
+ kill_proc(pThrCntrl->tid, SIGKILL, 1);
++#else
++ kill_pid(find_vpid(pThrCntrl->tid), SIGKILL, 1);
++#endif
+ /* release the big kernel lock */
+ unlock_kernel();
+ wait_for_completion (&pThrCntrl->thrCompletion);
diff --git a/package/platform/lantiq/ltq-tapi/patches/100-ifxmips.patch b/package/platform/lantiq/ltq-tapi/patches/100-ifxmips.patch
new file mode 100644
index 0000000..a9c0d81
--- /dev/null
+++ b/package/platform/lantiq/ltq-tapi/patches/100-ifxmips.patch
@@ -0,0 +1,96 @@
+--- a/src/drv_tapi_linux.c
++++ b/src/drv_tapi_linux.c
+@@ -552,7 +552,7 @@ static ssize_t ifx_tapi_write (struct fi
+ IFX_uint8_t *pData;
+ IFX_size_t buf_size;
+ #endif /* TAPI_PACKET */
+- IFX_ssize_t size = 0;
++ ssize_t size = 0;
+
+ #ifdef TAPI_PACKET
+ if (pTapiDev->bInitialized == IFX_FALSE)
+--- a/src/drv_tapi_osmap.h
++++ b/src/drv_tapi_osmap.h
+@@ -17,39 +17,6 @@
+ */
+
+ #include "ifx_types.h" /* ifx type definitions */
+-
+-#ifndef HAVE_IFX_ULONG_T
+- #warning please update your ifx_types.h, using local definition of IFX_ulong_t
+- /* unsigned long type - valid for 32bit systems only */
+- typedef unsigned long IFX_ulong_t;
+- #define HAVE_IFX_ULONG_T
+-#endif /* HAVE_IFX_ULONG_T */
+-
+-#ifndef HAVE_IFX_LONG_T
+- #warning please update your ifx_types.h, using local definition of IFX_long_t
+- /* long type - valid for 32bit systems only */
+- typedef long IFX_long_t;
+- #define HAVE_IFX_LONG_T
+-#endif /* HAVE_IFX_LONG_T */
+-
+-#ifndef HAVE_IFX_INTPTR_T
+- #warning please update your ifx_types.h, using local definition of IFX_intptr_t
+- typedef IFX_long_t IFX_intptr_t;
+- #define HAVE_IFX_INTPTR_T
+-#endif /* HAVE_IFX_INTPTR_T */
+-
+-#ifndef HAVE_IFX_SIZE_T
+- #warning please update your ifx_types.h, using local definition of IFX_size_t
+- typedef IFX_ulong_t IFX_size_t;
+- #define HAVE_IFX_SIZE_T
+-#endif /* HAVE_IFX_SIZE_T */
+-
+-#ifndef HAVE_IFX_SSIZE_T
+- #warning please update your ifx_types.h, using local definition of IFX_ssize_t
+- typedef IFX_long_t IFX_ssize_t;
+- #define HAVE_IFX_SSIZE_T
+-#endif /* HAVE_IFX_SSIZE_T */
+-
+ #include "ifxos_interrupt.h"
+ #include "ifxos_memory_alloc.h"
+ #include "ifxos_copy_user_space.h"
+--- a/include/drv_tapi_ll_interface.h
++++ b/include/drv_tapi_ll_interface.h
+@@ -40,13 +40,6 @@
+ #include "ifxos_select.h"
+ #endif /* TAPI_PACKET */
+
+-#ifndef HAVE_IFX_ULONG_T
+- #warning please update your ifx_types.h, using local definition of IFX_ulong_t
+- /* unsigned long type - valid for 32bit systems only */
+- typedef unsigned long IFX_ulong_t;
+- #define HAVE_IFX_ULONG_T
+-#endif /* HAVE_IFX_ULONG_T */
+-
+ /* ============================= */
+ /* Local Macros Definitions */
+ /* ============================= */
+--- a/src/lib/lib_bufferpool/lib_bufferpool.c
++++ b/src/lib/lib_bufferpool/lib_bufferpool.c
+@@ -85,24 +85,6 @@
+ #include <stdlib.h>
+ #endif /*VXWORKS*/
+
+-
+-/* ============================= */
+-/* Extra type definitions */
+-/* ============================= */
+-#ifndef HAVE_IFX_ULONG_T
+- #warning please update your ifx_types.h, using local definition of IFX_ulong_t
+- /* unsigned long type - valid for 32bit systems only */
+- typedef unsigned long IFX_ulong_t;
+- #define HAVE_IFX_ULONG_T
+-#endif /* HAVE_IFX_ULONG_T */
+-
+-#ifndef HAVE_IFX_UINTPTR_T
+- #warning please update your ifx_types.h, using local definition of IFX_uintptr_t
+- typedef IFX_ulong_t IFX_uintptr_t;
+- #define HAVE_IFX_UINTPTR_T
+-#endif /* HAVE_IFX_UINTPTR_T */
+-
+-
+ /* ============================= */
+ /* Local Macros & Definitions */
+ /* ============================= */
diff --git a/package/platform/lantiq/ltq-tapi/patches/200-linux-37.patch b/package/platform/lantiq/ltq-tapi/patches/200-linux-37.patch
new file mode 100644
index 0000000..9d7428d
--- /dev/null
+++ b/package/platform/lantiq/ltq-tapi/patches/200-linux-37.patch
@@ -0,0 +1,108 @@
+--- a/src/drv_tapi_linux.c
++++ b/src/drv_tapi_linux.c
+@@ -47,7 +47,9 @@
+ #include <linux/errno.h>
+ #include <asm/uaccess.h> /* copy_from_user(), ... */
+ #include <asm/byteorder.h>
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33))
+ #include <linux/smp_lock.h> /* lock_kernel() */
++#endif
+ #include <asm/io.h>
+
+ #ifdef LINUX_2_6
+@@ -65,7 +67,9 @@
+ #else
+ #include <linux/tqueue.h>
+ #include <linux/sched.h>
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33))
+ #include <linux/smp_lock.h> /* lock_kernel() */
++#endif
+ #endif /* LINUX_2_6 */
+
+ #include "drv_tapi.h"
+@@ -133,8 +137,13 @@
+ size_t count, loff_t * ppos);
+ static ssize_t ifx_tapi_read(struct file * filp, char *buf,
+ size_t length, loff_t * ppos);
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36))
+ static int ifx_tapi_ioctl(struct inode *inode, struct file *filp,
+ unsigned int nCmd, unsigned long nArgument);
++#else
++static long ifx_tapi_ioctl(struct file *filp,
++ unsigned int nCmd, unsigned long nArgument);
++#endif
+ static unsigned int ifx_tapi_poll (struct file *filp, poll_table *table);
+
+ #ifdef CONFIG_PROC_FS
+@@ -218,7 +227,11 @@
+ IFX_char_t *pRegDrvName = IFX_NULL;
+ IFX_int32_t ret = 0;
+
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36))
+ if (tapi_fops.ioctl == IFX_NULL)
++#else
++ if (tapi_fops.unlocked_ioctl == IFX_NULL)
++#endif
+ {
+ #ifdef MODULE
+ tapi_fops.owner = THIS_MODULE;
+@@ -226,7 +239,11 @@
+ tapi_fops.read = ifx_tapi_read;
+ tapi_fops.write = ifx_tapi_write;
+ tapi_fops.poll = ifx_tapi_poll;
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36))
+ tapi_fops.ioctl = ifx_tapi_ioctl;
++#else
++ tapi_fops.unlocked_ioctl = ifx_tapi_ioctl;
++#endif
+ tapi_fops.open = ifx_tapi_open;
+ tapi_fops.release = ifx_tapi_release;
+ }
+@@ -881,8 +898,13 @@
+ - 0 and positive values - success
+ - negative value - ioctl failed
+ */
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36))
+ static int ifx_tapi_ioctl(struct inode *inode, struct file *filp,
+ unsigned int nCmd, unsigned long nArg)
++#else
++static long ifx_tapi_ioctl(struct file *filp,
++ unsigned int nCmd, unsigned long nArg)
++#endif
+ {
+ TAPI_FD_PRIV_DATA_t *pTapiPriv;
+ IFX_TAPI_ioctlCtx_t ctx;
+@@ -3721,7 +3743,9 @@
+ kernel lock (lock_kernel()). The lock must be
+ grabbed before changing the terminate
+ flag and released after the down() call. */
+- lock_kernel();
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
++ lock_kernel();
++#endif
+ mb();
+ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)
+ kill_proc(pThrCntrl->tid, SIGKILL, 1);
+@@ -3729,8 +3753,10 @@
+ kill_pid(find_vpid(pThrCntrl->tid), SIGKILL, 1);
+ #endif
+ /* release the big kernel lock */
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
+ unlock_kernel();
+- wait_for_completion (&pThrCntrl->thrCompletion);
++#endif
++ wait_for_completion (&pThrCntrl->thrCompletion);
+
+ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
+ /* Now we are sure the thread is in zombie state.
+--- a/src/lib/lib_fifo/lib_fifo.c
++++ b/src/lib/lib_fifo/lib_fifo.c
+@@ -41,7 +41,7 @@
+ #ifdef LINUX
+ /* if linux/slab.h is not available, use the precessor linux/malloc.h */
+ #include <linux/slab.h>
+-#elif VXWORKS
++#elif defined(VXWORKS)
+ #include <sys_drv_debug.h>
+ #endif /* LINUX */
+
diff --git a/package/platform/lantiq/ltq-vdsl-app/.svn/entries b/package/platform/lantiq/ltq-vdsl-app/.svn/entries
new file mode 100644
index 0000000..f540d14
--- /dev/null
+++ b/package/platform/lantiq/ltq-vdsl-app/.svn/entries
@@ -0,0 +1,68 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/platform/lantiq/ltq-vdsl-app
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-14T18:43:13.075515Z
+36022
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+files
+dir
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+a0aa727c49f0bdf176743f20e8f1d4fa
+2013-03-14T18:43:13.075515Z
+36022
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2147
+
diff --git a/package/platform/lantiq/ltq-vdsl-app/.svn/text-base/Makefile.svn-base b/package/platform/lantiq/ltq-vdsl-app/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..3de29d5
--- /dev/null
+++ b/package/platform/lantiq/ltq-vdsl-app/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,75 @@
+# Copyright (C) 2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=ltq-vdsl-app
+PKG_VERSION:=4.11.4
+PKG_RELEASE:=1
+PKG_BASE_NAME:=dsl_cpe_control_vrx
+PKG_SOURCE:=$(PKG_BASE_NAME)-$(PKG_VERSION).tar.gz
+PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/dsl_cpe_control-$(PKG_VERSION)
+
+PKG_BUILD_DEPENDS:=kmod-ltq-vdsl-vr9
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/ltq-vdsl-app
+ SECTION:=net
+ CATEGORY:=Network
+ TITLE:=Lantiq VDSL userland tool
+ URL:=http://www.lantiq.com/
+ DEPENDS:=@TARGET_lantiq_xway +libpthread
+endef
+
+define Package/ltq-vdsl-app/description
+ Userland tool needed to control Lantiq VDSL CPE
+endef
+
+CONFIGURE_ARGS += \
+ --with-max-device="1" \
+ --with-lines-per-device="1" \
+ --with-channels-per-line="1" \
+ --enable-vrx \
+ --enable-driver-include="-I$(STAGING_DIR)/usr/include/drv_vdsl_cpe_api" \
+ --enable-device-driver-include="-I$(STAGING_DIR)/usr/include/vdsl/" \
+ --enable-add-appl-cflags="-DMAX_CLI_PIPES=2" \
+ --enable-ifxos \
+ --enable-ifxos-include="-I$(STAGING_DIR)/usr/include/ifxos" \
+ --enable-ifxos-library="-I$(STAGING_DIR)/usr/lib" \
+ --enable-dsl-ceoc \
+ --enable-dsl-pm-total \
+ --enable-dsl-pm-showtime \
+ --enable-dsl-pm-line-counters \
+ --enable-dsl-pm-line-failure-counters \
+ --enable-dsl-pm-datapath-counters \
+ --enable-dsl-pm-datapath-failure-counters \
+ --enable-deprecated \
+ --disable-soap-support \
+ --enable-dsl-bonding=no \
+ --disable-dti
+
+ifeq ($(CONFIG_IFX_CLI),y)
+CONFIGURE_ARGS += \
+ --enable-cli-support
+endif
+
+CONFIGURE_ARGS += --enable-model=full
+#CONFIGURE_ARGS += --enable-model=lite
+#CONFIGURE_ARGS += --enable-model=footprint
+#CONFIGURE_ARGS += --enable-model=typical
+#CONFIGURE_ARGS += --enable-model=debug
+
+define Package/ltq-vdsl-app/install
+ $(INSTALL_DIR) $(1)/etc/init.d
+ $(INSTALL_BIN) ./files/dsl_control $(1)/etc/init.d/
+
+ $(INSTALL_DIR) $(1)/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/dsl_cpe_control $(1)/sbin/vdsl_cpe_control
+ $(INSTALL_BIN) ./files/dsl_notify.sh $(1)/sbin
+endef
+
+$(eval $(call BuildPackage,ltq-vdsl-app))
diff --git a/package/platform/lantiq/ltq-vdsl-app/Makefile b/package/platform/lantiq/ltq-vdsl-app/Makefile
new file mode 100644
index 0000000..3de29d5
--- /dev/null
+++ b/package/platform/lantiq/ltq-vdsl-app/Makefile
@@ -0,0 +1,75 @@
+# Copyright (C) 2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=ltq-vdsl-app
+PKG_VERSION:=4.11.4
+PKG_RELEASE:=1
+PKG_BASE_NAME:=dsl_cpe_control_vrx
+PKG_SOURCE:=$(PKG_BASE_NAME)-$(PKG_VERSION).tar.gz
+PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/dsl_cpe_control-$(PKG_VERSION)
+
+PKG_BUILD_DEPENDS:=kmod-ltq-vdsl-vr9
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/ltq-vdsl-app
+ SECTION:=net
+ CATEGORY:=Network
+ TITLE:=Lantiq VDSL userland tool
+ URL:=http://www.lantiq.com/
+ DEPENDS:=@TARGET_lantiq_xway +libpthread
+endef
+
+define Package/ltq-vdsl-app/description
+ Userland tool needed to control Lantiq VDSL CPE
+endef
+
+CONFIGURE_ARGS += \
+ --with-max-device="1" \
+ --with-lines-per-device="1" \
+ --with-channels-per-line="1" \
+ --enable-vrx \
+ --enable-driver-include="-I$(STAGING_DIR)/usr/include/drv_vdsl_cpe_api" \
+ --enable-device-driver-include="-I$(STAGING_DIR)/usr/include/vdsl/" \
+ --enable-add-appl-cflags="-DMAX_CLI_PIPES=2" \
+ --enable-ifxos \
+ --enable-ifxos-include="-I$(STAGING_DIR)/usr/include/ifxos" \
+ --enable-ifxos-library="-I$(STAGING_DIR)/usr/lib" \
+ --enable-dsl-ceoc \
+ --enable-dsl-pm-total \
+ --enable-dsl-pm-showtime \
+ --enable-dsl-pm-line-counters \
+ --enable-dsl-pm-line-failure-counters \
+ --enable-dsl-pm-datapath-counters \
+ --enable-dsl-pm-datapath-failure-counters \
+ --enable-deprecated \
+ --disable-soap-support \
+ --enable-dsl-bonding=no \
+ --disable-dti
+
+ifeq ($(CONFIG_IFX_CLI),y)
+CONFIGURE_ARGS += \
+ --enable-cli-support
+endif
+
+CONFIGURE_ARGS += --enable-model=full
+#CONFIGURE_ARGS += --enable-model=lite
+#CONFIGURE_ARGS += --enable-model=footprint
+#CONFIGURE_ARGS += --enable-model=typical
+#CONFIGURE_ARGS += --enable-model=debug
+
+define Package/ltq-vdsl-app/install
+ $(INSTALL_DIR) $(1)/etc/init.d
+ $(INSTALL_BIN) ./files/dsl_control $(1)/etc/init.d/
+
+ $(INSTALL_DIR) $(1)/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/dsl_cpe_control $(1)/sbin/vdsl_cpe_control
+ $(INSTALL_BIN) ./files/dsl_notify.sh $(1)/sbin
+endef
+
+$(eval $(call BuildPackage,ltq-vdsl-app))
diff --git a/package/platform/lantiq/ltq-vdsl-app/files/.svn/entries b/package/platform/lantiq/ltq-vdsl-app/files/.svn/entries
new file mode 100644
index 0000000..2b06a00
--- /dev/null
+++ b/package/platform/lantiq/ltq-vdsl-app/files/.svn/entries
@@ -0,0 +1,96 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/platform/lantiq/ltq-vdsl-app/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-14T18:43:13.075515Z
+36022
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+dsl_control
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+6ae669bc261b598219108384e787450d
+2013-03-14T18:43:13.075515Z
+36022
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+6042
+
+dsl_notify.sh
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+40eca6e336903e2776949907def9a02c
+2013-03-14T18:43:13.075515Z
+36022
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1004
+
diff --git a/package/platform/lantiq/ltq-vdsl-app/files/.svn/text-base/dsl_control.svn-base b/package/platform/lantiq/ltq-vdsl-app/files/.svn/text-base/dsl_control.svn-base
new file mode 100644
index 0000000..0d7d32c
--- /dev/null
+++ b/package/platform/lantiq/ltq-vdsl-app/files/.svn/text-base/dsl_control.svn-base
@@ -0,0 +1,311 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2012 OpenWrt.org
+
+START=99
+
+EXTRA_COMMANDS="status lucistat"
+EXTRA_HELP=" status Get DSL status information
+ lucistat Get status information if lua friendly format"
+
+SERVICE_DAEMONIZE=1
+SERVICE_WRITE_PID=1
+
+#
+# Basic functions to send CLI commands to the vdsl_cpe_control daemon
+#
+dsl_cmd() {
+ killall -0 vdsl_cpe_control && (
+ echo "$@" > /tmp/pipe/dsl_cpe0_cmd
+ cat /tmp/pipe/dsl_cpe0_ack
+ )
+}
+dsl_val() {
+ echo $(expr "$1" : '.*'$2'=\([-\.[:alnum:]]*\).*')
+}
+
+#
+# Simple divide by 10 routine to cope with one decimal place
+#
+dbt() {
+ local a=$(expr $1 / 10)
+ local b=$(expr $1 % 10)
+ echo "${a}.${b}"
+}
+#
+# Take a number and convert to k or meg
+#
+scale() {
+ local val=$1
+ local a
+ local b
+
+ if [ "$val" -gt 1000000 ]; then
+ a=$(expr $val / 1000)
+ b=$(expr $a % 1000)
+ a=$(expr $a / 1000)
+ printf "%d.%03d Mb" ${a} ${b}
+ elif [ "$val" -gt 1000 ]; then
+ a=$(expr $val / 1000)
+ printf "%d Kb" ${a}
+ else
+ echo "${val} b"
+ fi
+}
+
+#
+# Read the data rates for both directions
+#
+data_rates() {
+ local csg
+ local dru
+ local drd
+ local sdru
+ local sdrd
+
+ csg=$(dsl_cmd g997csg 0 1)
+ drd=$(dsl_val "$csg" ActualDataRate)
+
+ csg=$(dsl_cmd g997csg 0 0)
+ dru=$(dsl_val "$csg" ActualDataRate)
+
+ [ -z "$drd" ] && drd=0
+ [ -z "$dru" ] && dru=0
+
+ sdrd=$(scale $drd)
+ sdru=$(scale $dru)
+
+ if [ "$action" = "lucistat" ]; then
+ echo "dsl.data_rate_down=$drd"
+ echo "dsl.data_rate_up=$dru"
+ echo "dsl.data_rate_down_s=\"$sdrd\""
+ echo "dsl.data_rate_up_s=\"$sdru\""
+ else
+ echo "Data Rate: ${sdrd}/s / ${sdru}/s"
+ fi
+}
+
+#
+# Chipset
+#
+chipset() {
+ local vig
+ local cs
+ local csv
+
+ vig=$(dsl_cmd vig)
+ cs=$(dsl_val "$vig" DSL_ChipSetType)
+ csv=$(dsl_val "$vig" DSL_ChipSetHWVersion)
+
+ if [ "$action" = "lucistat" ]; then
+ echo "dsl.chipset=\"${cs} ${csv}\""
+ else
+ echo "Chipset: ${cs} ${csv}"
+ fi
+}
+
+#
+# Work out how long the line has been up
+#
+line_uptime() {
+ local ccsg
+ local et
+ local etr
+ local d
+ local h
+ local m
+ local s
+ local rc=""
+
+ ccsg=$(dsl_cmd pmccsg 0 0 0)
+ et=$(dsl_val "$ccsg" nElapsedTime)
+
+ [ -z "$et" ] && et=0
+
+ if [ "$action" = "lucistat" ]; then
+ echo "dsl.line_uptime=${et}"
+ return
+ fi
+
+ d=$(expr $et / 86400)
+ etr=$(expr $et % 86400)
+ h=$(expr $etr / 3600)
+ etr=$(expr $etr % 3600)
+ m=$(expr $etr / 60)
+ s=$(expr $etr % 60)
+
+
+ [ "${d}${h}${m}${s}" -ne 0 ] && rc="${s}s"
+ [ "${d}${h}${m}" -ne 0 ] && rc="${m}m ${rc}"
+ [ "${d}${h}" -ne 0 ] && rc="${h}h ${rc}"
+ [ "${d}" -ne 0 ] && rc="${d}d ${rc}"
+
+ [ -z "$rc" ] && rc="down"
+ echo "Line Uptime: ${rc}"
+}
+
+#
+# Get noise and attenuation figures
+#
+line_data() {
+ local lsg
+ local latnu
+ local latnd
+ local snru
+ local snrd
+
+ lsg=$(dsl_cmd g997lsg 1 1)
+ latnd=$(dsl_val "$lsg" LATN)
+ snrd=$(dsl_val "$lsg" SNR)
+
+ lsg=$(dsl_cmd g997lsg 0 1)
+ latnu=$(dsl_val "$lsg" LATN)
+ snru=$(dsl_val "$lsg" SNR)
+
+ [ -z "$latnd" ] && latnd=0
+ [ -z "$latnu" ] && latnu=0
+ [ -z "$snrd" ] && snrd=0
+ [ -z "$snru" ] && snru=0
+
+ latnd=$(dbt $latnd)
+ latnu=$(dbt $latnu)
+ snrd=$(dbt $snrd)
+ snru=$(dbt $snru)
+
+ if [ "$action" = "lucistat" ]; then
+ echo "dsl.line_attenuation_down=$latnd"
+ echo "dsl.line_attenuation_up=$latnu"
+ echo "dsl.noise_margin_down=$snrd"
+ echo "dsl.noise_margin_up=$snru"
+ else
+ echo "Line Attenuation: ${latnd}dB / ${latnu}dB"
+ echo "Noise Margin: ${snrd}dB / ${snru}dB"
+ fi
+}
+
+#
+# Is the line up? Or what state is it in?
+#
+line_state() {
+ local lsg=$(dsl_cmd lsg)
+ local ls=$(dsl_val "$lsg" nLineState);
+ local s;
+
+ case "$ls" in
+ "0x0") s="not initialized" ;;
+ "0x1") s="exception" ;;
+ "0x10") s="not updated" ;;
+ "0xff") s="idle request" ;;
+ "0x100") s="idle" ;;
+ "0x1ff") s="silent request" ;;
+ "0x200") s="silent" ;;
+ "0x300") s="handshake" ;;
+ "0x380") s="full_init" ;;
+ "0x400") s="discovery" ;;
+ "0x500") s="training" ;;
+ "0x600") s="analysis" ;;
+ "0x700") s="exchange" ;;
+ "0x800") s="showtime_no_sync" ;;
+ "0x801") s="showtime_tc_sync" ;;
+ "0x900") s="fastretrain" ;;
+ "0xa00") s="lowpower_l2" ;;
+ "0xb00") s="loopdiagnostic active" ;;
+ "0xb10") s="loopdiagnostic data exchange" ;;
+ "0xb20") s="loopdiagnostic data request" ;;
+ "0xc00") s="loopdiagnostic complete" ;;
+ "0x1000000") s="test" ;;
+ "0xd00") s="resync" ;;
+ "0x3c0") s="short init entry" ;;
+ "") s="not running daemon"; ls="0xfff" ;;
+ *) s="unknown" ;;
+ esac
+
+ if [ $action = "lucistat" ]; then
+ echo "dsl.line_state_num=$ls"
+ echo "dsl.line_state_detail=\"$s\""
+ if [ "$ls" = "0x801" ]; then
+ echo "dsl.line_state=\"UP\""
+ else
+ echo "dsl.line_state=\"DOWN\""
+ fi
+ else
+ if [ "$ls" = "0x801" ]; then
+ echo "Line State: UP [$ls: $s]"
+ else
+ echo "Line State: DOWN [$ls: $s]"
+ fi
+ fi
+}
+
+#
+# Main status routine
+#
+status() {
+ chipset
+ line_state
+ data_rates
+ line_data
+ line_uptime
+}
+
+#
+# Luci (lua) compatible version that's easy to parse
+#
+lucistat() {
+ echo "local dsl={}"
+ status
+ echo "return dsl"
+}
+
+
+annex_b=10_00_10_00_00_04_00_00
+annex_bdmt=10_00_00_00_00_00_00_00
+annex_b2=00_00_10_00_00_00_00_00
+annex_b2p=00_00_00_00_00_04_00_00
+annex_a=04_01_04_00_00_01_00_00
+annex_at1=01_00_00_00_00_00_00_00
+annex_alite=00_01_00_00_00_00_00_00
+annex_admt=04_00_00_00_00_00_00_00
+annex_a2=00_00_04_00_00_00_00_00
+annex_a2p=00_00_00_00_00_01_00_00
+annex_l=00_00_00_00_04_00_00_00
+annex_m=00_00_00_00_40_00_04_00
+annex_m2=00_00_00_00_40_00_00_00
+annex_m2p=00_00_00_00_00_00_04_00
+
+#
+# Simple start routine
+#
+start() {
+ local annex
+ local firmware
+ local xtu
+ config_load network
+ config_get annex wan annex
+ config_get firmware wan firmware
+
+ # get xtu
+ eval "xtu=\"\${annex_$annex}\""
+
+ # check for firmware
+ [ -z "${firmware}" ] &&
+ firmware=vdsl.bin
+
+ # start CPE dsl daemon in the background
+ service_start /sbin/vdsl_cpe_control -i${xtu} \
+ -n /sbin/dsl_notify.sh \
+ -f /lib/firmware/${firmware}
+}
+
+#
+# For stop we want to simulate the notification call for when
+# the line goes down, so that we can stop the ppp link before
+# we die.
+#
+stop() {
+ DSL_NOTIFICATION_TYPE="DSL_INTERFACE_STATUS" \
+ DSL_INTERFACE_STATUS="DOWN" \
+ /sbin/dsl_notify.sh
+
+ service_stop /sbin/vdsl_cpe_control
+}
+
diff --git a/package/platform/lantiq/ltq-vdsl-app/files/.svn/text-base/dsl_notify.sh.svn-base b/package/platform/lantiq/ltq-vdsl-app/files/.svn/text-base/dsl_notify.sh.svn-base
new file mode 100644
index 0000000..5e9f396
--- /dev/null
+++ b/package/platform/lantiq/ltq-vdsl-app/files/.svn/text-base/dsl_notify.sh.svn-base
@@ -0,0 +1,44 @@
+#!/bin/sh
+#
+# This script is called by dsl_cpe_control whenever there is a DSL event,
+# we only actually care about the DSL_INTERFACE_STATUS events as these
+# tell us the line has either come up or gone down.
+#
+# The rest of the code is basically the same at the atm hotplug code
+#
+
+[ "$DSL_NOTIFICATION_TYPE" = "DSL_INTERFACE_STATUS" ] || exit 0
+
+. /lib/functions.sh
+
+include /lib/network
+scan_interfaces
+
+local found=0
+local ifc
+for ifc in $interfaces; do
+ local up
+ config_get_bool up "$ifc" up 0
+
+ local auto
+ config_get_bool auto "$ifc" auto 1
+
+ local proto
+ config_get proto "$ifc" proto
+
+ if [ "$DSL_INTERFACE_STATUS" = "UP" ]; then
+ if [ "$proto" = "pppoa" ] && [ "$up" != 1 ] && [ "$auto" = 1 ]; then
+ found=1
+ ( sleep 1; ifup "$ifc" ) &
+ fi
+ else
+ if [ "$proto" = "pppoa" ] && [ "$up" = 1 ] && [ "$auto" = 1 ]; then
+ found=1
+ ( sleep 1; ifdown "$ifc" ) &
+ fi
+ fi
+done
+
+if [ "$found" != 1 ]; then
+ logger "Found no matching interface for DSL notification ($DSL_INTERFACE_STATUS)"
+fi
diff --git a/package/platform/lantiq/ltq-vdsl-app/files/dsl_control b/package/platform/lantiq/ltq-vdsl-app/files/dsl_control
new file mode 100644
index 0000000..0d7d32c
--- /dev/null
+++ b/package/platform/lantiq/ltq-vdsl-app/files/dsl_control
@@ -0,0 +1,311 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2012 OpenWrt.org
+
+START=99
+
+EXTRA_COMMANDS="status lucistat"
+EXTRA_HELP=" status Get DSL status information
+ lucistat Get status information if lua friendly format"
+
+SERVICE_DAEMONIZE=1
+SERVICE_WRITE_PID=1
+
+#
+# Basic functions to send CLI commands to the vdsl_cpe_control daemon
+#
+dsl_cmd() {
+ killall -0 vdsl_cpe_control && (
+ echo "$@" > /tmp/pipe/dsl_cpe0_cmd
+ cat /tmp/pipe/dsl_cpe0_ack
+ )
+}
+dsl_val() {
+ echo $(expr "$1" : '.*'$2'=\([-\.[:alnum:]]*\).*')
+}
+
+#
+# Simple divide by 10 routine to cope with one decimal place
+#
+dbt() {
+ local a=$(expr $1 / 10)
+ local b=$(expr $1 % 10)
+ echo "${a}.${b}"
+}
+#
+# Take a number and convert to k or meg
+#
+scale() {
+ local val=$1
+ local a
+ local b
+
+ if [ "$val" -gt 1000000 ]; then
+ a=$(expr $val / 1000)
+ b=$(expr $a % 1000)
+ a=$(expr $a / 1000)
+ printf "%d.%03d Mb" ${a} ${b}
+ elif [ "$val" -gt 1000 ]; then
+ a=$(expr $val / 1000)
+ printf "%d Kb" ${a}
+ else
+ echo "${val} b"
+ fi
+}
+
+#
+# Read the data rates for both directions
+#
+data_rates() {
+ local csg
+ local dru
+ local drd
+ local sdru
+ local sdrd
+
+ csg=$(dsl_cmd g997csg 0 1)
+ drd=$(dsl_val "$csg" ActualDataRate)
+
+ csg=$(dsl_cmd g997csg 0 0)
+ dru=$(dsl_val "$csg" ActualDataRate)
+
+ [ -z "$drd" ] && drd=0
+ [ -z "$dru" ] && dru=0
+
+ sdrd=$(scale $drd)
+ sdru=$(scale $dru)
+
+ if [ "$action" = "lucistat" ]; then
+ echo "dsl.data_rate_down=$drd"
+ echo "dsl.data_rate_up=$dru"
+ echo "dsl.data_rate_down_s=\"$sdrd\""
+ echo "dsl.data_rate_up_s=\"$sdru\""
+ else
+ echo "Data Rate: ${sdrd}/s / ${sdru}/s"
+ fi
+}
+
+#
+# Chipset
+#
+chipset() {
+ local vig
+ local cs
+ local csv
+
+ vig=$(dsl_cmd vig)
+ cs=$(dsl_val "$vig" DSL_ChipSetType)
+ csv=$(dsl_val "$vig" DSL_ChipSetHWVersion)
+
+ if [ "$action" = "lucistat" ]; then
+ echo "dsl.chipset=\"${cs} ${csv}\""
+ else
+ echo "Chipset: ${cs} ${csv}"
+ fi
+}
+
+#
+# Work out how long the line has been up
+#
+line_uptime() {
+ local ccsg
+ local et
+ local etr
+ local d
+ local h
+ local m
+ local s
+ local rc=""
+
+ ccsg=$(dsl_cmd pmccsg 0 0 0)
+ et=$(dsl_val "$ccsg" nElapsedTime)
+
+ [ -z "$et" ] && et=0
+
+ if [ "$action" = "lucistat" ]; then
+ echo "dsl.line_uptime=${et}"
+ return
+ fi
+
+ d=$(expr $et / 86400)
+ etr=$(expr $et % 86400)
+ h=$(expr $etr / 3600)
+ etr=$(expr $etr % 3600)
+ m=$(expr $etr / 60)
+ s=$(expr $etr % 60)
+
+
+ [ "${d}${h}${m}${s}" -ne 0 ] && rc="${s}s"
+ [ "${d}${h}${m}" -ne 0 ] && rc="${m}m ${rc}"
+ [ "${d}${h}" -ne 0 ] && rc="${h}h ${rc}"
+ [ "${d}" -ne 0 ] && rc="${d}d ${rc}"
+
+ [ -z "$rc" ] && rc="down"
+ echo "Line Uptime: ${rc}"
+}
+
+#
+# Get noise and attenuation figures
+#
+line_data() {
+ local lsg
+ local latnu
+ local latnd
+ local snru
+ local snrd
+
+ lsg=$(dsl_cmd g997lsg 1 1)
+ latnd=$(dsl_val "$lsg" LATN)
+ snrd=$(dsl_val "$lsg" SNR)
+
+ lsg=$(dsl_cmd g997lsg 0 1)
+ latnu=$(dsl_val "$lsg" LATN)
+ snru=$(dsl_val "$lsg" SNR)
+
+ [ -z "$latnd" ] && latnd=0
+ [ -z "$latnu" ] && latnu=0
+ [ -z "$snrd" ] && snrd=0
+ [ -z "$snru" ] && snru=0
+
+ latnd=$(dbt $latnd)
+ latnu=$(dbt $latnu)
+ snrd=$(dbt $snrd)
+ snru=$(dbt $snru)
+
+ if [ "$action" = "lucistat" ]; then
+ echo "dsl.line_attenuation_down=$latnd"
+ echo "dsl.line_attenuation_up=$latnu"
+ echo "dsl.noise_margin_down=$snrd"
+ echo "dsl.noise_margin_up=$snru"
+ else
+ echo "Line Attenuation: ${latnd}dB / ${latnu}dB"
+ echo "Noise Margin: ${snrd}dB / ${snru}dB"
+ fi
+}
+
+#
+# Is the line up? Or what state is it in?
+#
+line_state() {
+ local lsg=$(dsl_cmd lsg)
+ local ls=$(dsl_val "$lsg" nLineState);
+ local s;
+
+ case "$ls" in
+ "0x0") s="not initialized" ;;
+ "0x1") s="exception" ;;
+ "0x10") s="not updated" ;;
+ "0xff") s="idle request" ;;
+ "0x100") s="idle" ;;
+ "0x1ff") s="silent request" ;;
+ "0x200") s="silent" ;;
+ "0x300") s="handshake" ;;
+ "0x380") s="full_init" ;;
+ "0x400") s="discovery" ;;
+ "0x500") s="training" ;;
+ "0x600") s="analysis" ;;
+ "0x700") s="exchange" ;;
+ "0x800") s="showtime_no_sync" ;;
+ "0x801") s="showtime_tc_sync" ;;
+ "0x900") s="fastretrain" ;;
+ "0xa00") s="lowpower_l2" ;;
+ "0xb00") s="loopdiagnostic active" ;;
+ "0xb10") s="loopdiagnostic data exchange" ;;
+ "0xb20") s="loopdiagnostic data request" ;;
+ "0xc00") s="loopdiagnostic complete" ;;
+ "0x1000000") s="test" ;;
+ "0xd00") s="resync" ;;
+ "0x3c0") s="short init entry" ;;
+ "") s="not running daemon"; ls="0xfff" ;;
+ *) s="unknown" ;;
+ esac
+
+ if [ $action = "lucistat" ]; then
+ echo "dsl.line_state_num=$ls"
+ echo "dsl.line_state_detail=\"$s\""
+ if [ "$ls" = "0x801" ]; then
+ echo "dsl.line_state=\"UP\""
+ else
+ echo "dsl.line_state=\"DOWN\""
+ fi
+ else
+ if [ "$ls" = "0x801" ]; then
+ echo "Line State: UP [$ls: $s]"
+ else
+ echo "Line State: DOWN [$ls: $s]"
+ fi
+ fi
+}
+
+#
+# Main status routine
+#
+status() {
+ chipset
+ line_state
+ data_rates
+ line_data
+ line_uptime
+}
+
+#
+# Luci (lua) compatible version that's easy to parse
+#
+lucistat() {
+ echo "local dsl={}"
+ status
+ echo "return dsl"
+}
+
+
+annex_b=10_00_10_00_00_04_00_00
+annex_bdmt=10_00_00_00_00_00_00_00
+annex_b2=00_00_10_00_00_00_00_00
+annex_b2p=00_00_00_00_00_04_00_00
+annex_a=04_01_04_00_00_01_00_00
+annex_at1=01_00_00_00_00_00_00_00
+annex_alite=00_01_00_00_00_00_00_00
+annex_admt=04_00_00_00_00_00_00_00
+annex_a2=00_00_04_00_00_00_00_00
+annex_a2p=00_00_00_00_00_01_00_00
+annex_l=00_00_00_00_04_00_00_00
+annex_m=00_00_00_00_40_00_04_00
+annex_m2=00_00_00_00_40_00_00_00
+annex_m2p=00_00_00_00_00_00_04_00
+
+#
+# Simple start routine
+#
+start() {
+ local annex
+ local firmware
+ local xtu
+ config_load network
+ config_get annex wan annex
+ config_get firmware wan firmware
+
+ # get xtu
+ eval "xtu=\"\${annex_$annex}\""
+
+ # check for firmware
+ [ -z "${firmware}" ] &&
+ firmware=vdsl.bin
+
+ # start CPE dsl daemon in the background
+ service_start /sbin/vdsl_cpe_control -i${xtu} \
+ -n /sbin/dsl_notify.sh \
+ -f /lib/firmware/${firmware}
+}
+
+#
+# For stop we want to simulate the notification call for when
+# the line goes down, so that we can stop the ppp link before
+# we die.
+#
+stop() {
+ DSL_NOTIFICATION_TYPE="DSL_INTERFACE_STATUS" \
+ DSL_INTERFACE_STATUS="DOWN" \
+ /sbin/dsl_notify.sh
+
+ service_stop /sbin/vdsl_cpe_control
+}
+
diff --git a/package/platform/lantiq/ltq-vdsl-app/files/dsl_notify.sh b/package/platform/lantiq/ltq-vdsl-app/files/dsl_notify.sh
new file mode 100644
index 0000000..5e9f396
--- /dev/null
+++ b/package/platform/lantiq/ltq-vdsl-app/files/dsl_notify.sh
@@ -0,0 +1,44 @@
+#!/bin/sh
+#
+# This script is called by dsl_cpe_control whenever there is a DSL event,
+# we only actually care about the DSL_INTERFACE_STATUS events as these
+# tell us the line has either come up or gone down.
+#
+# The rest of the code is basically the same at the atm hotplug code
+#
+
+[ "$DSL_NOTIFICATION_TYPE" = "DSL_INTERFACE_STATUS" ] || exit 0
+
+. /lib/functions.sh
+
+include /lib/network
+scan_interfaces
+
+local found=0
+local ifc
+for ifc in $interfaces; do
+ local up
+ config_get_bool up "$ifc" up 0
+
+ local auto
+ config_get_bool auto "$ifc" auto 1
+
+ local proto
+ config_get proto "$ifc" proto
+
+ if [ "$DSL_INTERFACE_STATUS" = "UP" ]; then
+ if [ "$proto" = "pppoa" ] && [ "$up" != 1 ] && [ "$auto" = 1 ]; then
+ found=1
+ ( sleep 1; ifup "$ifc" ) &
+ fi
+ else
+ if [ "$proto" = "pppoa" ] && [ "$up" = 1 ] && [ "$auto" = 1 ]; then
+ found=1
+ ( sleep 1; ifdown "$ifc" ) &
+ fi
+ fi
+done
+
+if [ "$found" != 1 ]; then
+ logger "Found no matching interface for DSL notification ($DSL_INTERFACE_STATUS)"
+fi
diff --git a/package/platform/lantiq/ltq-vdsl-app/patches/.svn/entries b/package/platform/lantiq/ltq-vdsl-app/patches/.svn/entries
new file mode 100644
index 0000000..1578c00
--- /dev/null
+++ b/package/platform/lantiq/ltq-vdsl-app/patches/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/platform/lantiq/ltq-vdsl-app/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-14T18:43:13.075515Z
+36022
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+100-compat.patch
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+4c05cd919699927088a39066334284cf
+2013-03-14T18:43:13.075515Z
+36022
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1312
+
diff --git a/package/platform/lantiq/ltq-vdsl-app/patches/.svn/text-base/100-compat.patch.svn-base b/package/platform/lantiq/ltq-vdsl-app/patches/.svn/text-base/100-compat.patch.svn-base
new file mode 100644
index 0000000..da56232
--- /dev/null
+++ b/package/platform/lantiq/ltq-vdsl-app/patches/.svn/text-base/100-compat.patch.svn-base
@@ -0,0 +1,26 @@
+Index: dsl_cpe_control-4.11.4/src/dsl_cpe_init_cfg.c
+===================================================================
+--- dsl_cpe_control-4.11.4.orig/src/dsl_cpe_init_cfg.c 2011-10-26 00:35:26.000000000 +0200
++++ dsl_cpe_control-4.11.4/src/dsl_cpe_init_cfg.c 2012-11-28 15:53:10.857692092 +0100
+@@ -43,7 +43,7 @@
+ {
+ DSL_CPE_LL_CFG_SET(-1, -1, DSL_DEV_HS_TONE_GROUP_VDSL2_B43, \
+ DSL_DEV_HS_TONE_GROUP_VDSL2_B43, DSL_DEV_HS_TONE_GROUP_VDSL2_B43, \
+- 0x1E116000, 0x37, -1),
++ 0x1E116000, 0x3f, -1),
+ #endif
+
+ #if defined(INCLUDE_DSL_CPE_API_VINAX)
+Index: dsl_cpe_control-4.11.4/src/dsl_cpe_control.c
+===================================================================
+--- dsl_cpe_control-4.11.4.orig/src/dsl_cpe_control.c 2012-01-13 15:15:34.000000000 +0100
++++ dsl_cpe_control-4.11.4/src/dsl_cpe_control.c 2012-11-28 15:53:23.465692408 +0100
+@@ -6432,7 +6432,7 @@
+ for (nDevice = 0; nDevice < DSL_CPE_MAX_DEVICE_NUMBER; nDevice++)
+ {
+ #if defined(INCLUDE_DSL_CPE_API_VINAX) || defined(INCLUDE_DSL_CPE_API_VRX)
+- sprintf (device, "%s/%d", DSL_CPE_DEVICE_NAME, nDevice);
++ sprintf (device, "%s%d", DSL_CPE_DEVICE_NAME, nDevice);
+ #else
+ sprintf (device, "%s", DSL_CPE_DEVICE_NAME);
+ #endif /* defined(INCLUDE_DSL_CPE_API_VINAX) || defined(INCLUDE_DSL_CPE_API_VRX)*/
diff --git a/package/platform/lantiq/ltq-vdsl-app/patches/100-compat.patch b/package/platform/lantiq/ltq-vdsl-app/patches/100-compat.patch
new file mode 100644
index 0000000..da56232
--- /dev/null
+++ b/package/platform/lantiq/ltq-vdsl-app/patches/100-compat.patch
@@ -0,0 +1,26 @@
+Index: dsl_cpe_control-4.11.4/src/dsl_cpe_init_cfg.c
+===================================================================
+--- dsl_cpe_control-4.11.4.orig/src/dsl_cpe_init_cfg.c 2011-10-26 00:35:26.000000000 +0200
++++ dsl_cpe_control-4.11.4/src/dsl_cpe_init_cfg.c 2012-11-28 15:53:10.857692092 +0100
+@@ -43,7 +43,7 @@
+ {
+ DSL_CPE_LL_CFG_SET(-1, -1, DSL_DEV_HS_TONE_GROUP_VDSL2_B43, \
+ DSL_DEV_HS_TONE_GROUP_VDSL2_B43, DSL_DEV_HS_TONE_GROUP_VDSL2_B43, \
+- 0x1E116000, 0x37, -1),
++ 0x1E116000, 0x3f, -1),
+ #endif
+
+ #if defined(INCLUDE_DSL_CPE_API_VINAX)
+Index: dsl_cpe_control-4.11.4/src/dsl_cpe_control.c
+===================================================================
+--- dsl_cpe_control-4.11.4.orig/src/dsl_cpe_control.c 2012-01-13 15:15:34.000000000 +0100
++++ dsl_cpe_control-4.11.4/src/dsl_cpe_control.c 2012-11-28 15:53:23.465692408 +0100
+@@ -6432,7 +6432,7 @@
+ for (nDevice = 0; nDevice < DSL_CPE_MAX_DEVICE_NUMBER; nDevice++)
+ {
+ #if defined(INCLUDE_DSL_CPE_API_VINAX) || defined(INCLUDE_DSL_CPE_API_VRX)
+- sprintf (device, "%s/%d", DSL_CPE_DEVICE_NAME, nDevice);
++ sprintf (device, "%s%d", DSL_CPE_DEVICE_NAME, nDevice);
+ #else
+ sprintf (device, "%s", DSL_CPE_DEVICE_NAME);
+ #endif /* defined(INCLUDE_DSL_CPE_API_VINAX) || defined(INCLUDE_DSL_CPE_API_VRX)*/
diff --git a/package/platform/lantiq/ltq-vdsl-fw/.svn/entries b/package/platform/lantiq/ltq-vdsl-fw/.svn/entries
new file mode 100644
index 0000000..b8dd8b3
--- /dev/null
+++ b/package/platform/lantiq/ltq-vdsl-fw/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/platform/lantiq/ltq-vdsl-fw
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-14T18:43:29.116646Z
+36025
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+src
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+45ae85edeb12101010c6b08af2bdf460
+2013-03-14T18:43:29.116646Z
+36025
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+941
+
diff --git a/package/platform/lantiq/ltq-vdsl-fw/.svn/text-base/Makefile.svn-base b/package/platform/lantiq/ltq-vdsl-fw/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..d4e0023
--- /dev/null
+++ b/package/platform/lantiq/ltq-vdsl-fw/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,40 @@
+# Copyright (C) 2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=ltq-vdsl-fw
+PKG_VERSION:=1
+PKG_RELEASE:=1
+
+PKG_MAINTAINER:=John Crispin <blogic@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/ltq-vdsl-vr9-fw-installer
+ TITLE:=Firmware installer
+ SECTION:=net
+ CATEGORY:=Network
+ DEPENDS:=@TARGET_lantiq_xway +kmod-ltq-vdsl-vr9
+endef
+
+define Build/Prepare
+ $(INSTALL_DIR) $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)
+endef
+
+define Build/Compile
+ $(TARGET_CONFIGURE_OPTS) \
+ CFLAGS="$(TARGET_CFLAGS)" \
+ LDFLAGS="$(TARGET_LDFLAGS)" \
+ $(MAKE) -C $(PKG_BUILD_DIR)
+endef
+
+define Package/ltq-vdsl-vr9-fw-installer/install
+ $(INSTALL_DIR) $(1)/sbin
+ $(CP) $(PKG_BUILD_DIR)/w921v_fw_cutter $(PKG_BUILD_DIR)/vdsl_fw_install.sh $(1)/sbin/
+endef
+
+$(eval $(call BuildPackage,ltq-vdsl-vr9-fw-installer))
diff --git a/package/platform/lantiq/ltq-vdsl-fw/Makefile b/package/platform/lantiq/ltq-vdsl-fw/Makefile
new file mode 100644
index 0000000..d4e0023
--- /dev/null
+++ b/package/platform/lantiq/ltq-vdsl-fw/Makefile
@@ -0,0 +1,40 @@
+# Copyright (C) 2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=ltq-vdsl-fw
+PKG_VERSION:=1
+PKG_RELEASE:=1
+
+PKG_MAINTAINER:=John Crispin <blogic@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/ltq-vdsl-vr9-fw-installer
+ TITLE:=Firmware installer
+ SECTION:=net
+ CATEGORY:=Network
+ DEPENDS:=@TARGET_lantiq_xway +kmod-ltq-vdsl-vr9
+endef
+
+define Build/Prepare
+ $(INSTALL_DIR) $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)
+endef
+
+define Build/Compile
+ $(TARGET_CONFIGURE_OPTS) \
+ CFLAGS="$(TARGET_CFLAGS)" \
+ LDFLAGS="$(TARGET_LDFLAGS)" \
+ $(MAKE) -C $(PKG_BUILD_DIR)
+endef
+
+define Package/ltq-vdsl-vr9-fw-installer/install
+ $(INSTALL_DIR) $(1)/sbin
+ $(CP) $(PKG_BUILD_DIR)/w921v_fw_cutter $(PKG_BUILD_DIR)/vdsl_fw_install.sh $(1)/sbin/
+endef
+
+$(eval $(call BuildPackage,ltq-vdsl-vr9-fw-installer))
diff --git a/package/platform/lantiq/ltq-vdsl-fw/src/.svn/entries b/package/platform/lantiq/ltq-vdsl-fw/src/.svn/entries
new file mode 100644
index 0000000..31c86d8
--- /dev/null
+++ b/package/platform/lantiq/ltq-vdsl-fw/src/.svn/entries
@@ -0,0 +1,300 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/platform/lantiq/ltq-vdsl-fw/src
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-14T18:43:29.116646Z
+36025
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+vdsl_fw_install.sh
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+66a64823a2d3f209af9342d07d7e267a
+2013-03-14T18:43:29.116646Z
+36025
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1256
+
+LzmaWrapper.c
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+a89cd832fe06c5482096247986b9622d
+2013-03-14T18:43:29.116646Z
+36025
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5735
+
+LzmaDecode.c
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+4946fb50ec2dd24d326317a9d1be4067
+2013-03-14T18:43:29.116646Z
+36025
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+15775
+
+LzmaWrapper.h
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+7efb7ca9dade63a42b1081a2a9f4cff6
+2013-03-14T18:43:29.116646Z
+36025
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1279
+
+w921v_fw_cutter.c
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+96ea45f7bd5e299559e7d8f413c25272
+2013-03-14T18:43:29.116646Z
+36025
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4238
+
+LzmaDecode.h
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+0b1473f18367a01e3a9a0617529dd25a
+2013-03-14T18:43:29.116646Z
+36025
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2694
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+59ba40f45adad7bf12bb8467fce12f25
+2013-03-14T18:43:29.116646Z
+36025
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+204
+
+LzmaTypes.h
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+4998778b751b993afecb0530049aa95f
+2013-03-14T18:43:29.116646Z
+36025
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+830
+
diff --git a/package/platform/lantiq/ltq-vdsl-fw/src/.svn/prop-base/LzmaDecode.c.svn-base b/package/platform/lantiq/ltq-vdsl-fw/src/.svn/prop-base/LzmaDecode.c.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/platform/lantiq/ltq-vdsl-fw/src/.svn/prop-base/LzmaDecode.c.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/platform/lantiq/ltq-vdsl-fw/src/.svn/prop-base/LzmaDecode.h.svn-base b/package/platform/lantiq/ltq-vdsl-fw/src/.svn/prop-base/LzmaDecode.h.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/platform/lantiq/ltq-vdsl-fw/src/.svn/prop-base/LzmaDecode.h.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/platform/lantiq/ltq-vdsl-fw/src/.svn/prop-base/LzmaTypes.h.svn-base b/package/platform/lantiq/ltq-vdsl-fw/src/.svn/prop-base/LzmaTypes.h.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/platform/lantiq/ltq-vdsl-fw/src/.svn/prop-base/LzmaTypes.h.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/platform/lantiq/ltq-vdsl-fw/src/.svn/prop-base/vdsl_fw_install.sh.svn-base b/package/platform/lantiq/ltq-vdsl-fw/src/.svn/prop-base/vdsl_fw_install.sh.svn-base
new file mode 100644
index 0000000..869ac71
--- /dev/null
+++ b/package/platform/lantiq/ltq-vdsl-fw/src/.svn/prop-base/vdsl_fw_install.sh.svn-base
@@ -0,0 +1,5 @@
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/platform/lantiq/ltq-vdsl-fw/src/.svn/text-base/LzmaDecode.c.svn-base b/package/platform/lantiq/ltq-vdsl-fw/src/.svn/text-base/LzmaDecode.c.svn-base
new file mode 100644
index 0000000..cb83453
--- /dev/null
+++ b/package/platform/lantiq/ltq-vdsl-fw/src/.svn/text-base/LzmaDecode.c.svn-base
@@ -0,0 +1,584 @@
+/*
+ LzmaDecode.c
+ LZMA Decoder (optimized for Speed version)
+
+ LZMA SDK 4.40 Copyright (c) 1999-2006 Igor Pavlov (2006-05-01)
+ http://www.7-zip.org/
+
+ LZMA SDK is licensed under two licenses:
+ 1) GNU Lesser General Public License (GNU LGPL)
+ 2) Common Public License (CPL)
+ It means that you can select one of these two licenses and
+ follow rules of that license.
+
+ SPECIAL EXCEPTION:
+ Igor Pavlov, as the author of this Code, expressly permits you to
+ statically or dynamically link your Code (or bind by name) to the
+ interfaces of this file without subjecting your linked Code to the
+ terms of the CPL or GNU LGPL. Any modifications or additions
+ to this file, however, are subject to the LGPL or CPL terms.
+*/
+
+#include "LzmaDecode.h"
+
+#define kNumTopBits 24
+#define kTopValue ((UInt32)1 << kNumTopBits)
+
+#define kNumBitModelTotalBits 11
+#define kBitModelTotal (1 << kNumBitModelTotalBits)
+#define kNumMoveBits 5
+
+#define RC_READ_BYTE (*Buffer++)
+
+#define RC_INIT2 Code = 0; Range = 0xFFFFFFFF; \
+ { int i; for(i = 0; i < 5; i++) { RC_TEST; Code = (Code << 8) | RC_READ_BYTE; }}
+
+#ifdef _LZMA_IN_CB
+
+#define RC_TEST { if (Buffer == BufferLim) \
+ { SizeT size; int result = InCallback->Read(InCallback, &Buffer, &size); if (result != LZMA_RESULT_OK) return result; \
+ BufferLim = Buffer + size; if (size == 0) return LZMA_RESULT_DATA_ERROR; }}
+
+#define RC_INIT Buffer = BufferLim = 0; RC_INIT2
+
+#else
+
+#define RC_TEST { if (Buffer == BufferLim) return LZMA_RESULT_DATA_ERROR; }
+
+#define RC_INIT(buffer, bufferSize) Buffer = buffer; BufferLim = buffer + bufferSize; RC_INIT2
+
+#endif
+
+#define RC_NORMALIZE if (Range < kTopValue) { RC_TEST; Range <<= 8; Code = (Code << 8) | RC_READ_BYTE; }
+
+#define IfBit0(p) RC_NORMALIZE; bound = (Range >> kNumBitModelTotalBits) * *(p); if (Code < bound)
+#define UpdateBit0(p) Range = bound; *(p) += (kBitModelTotal - *(p)) >> kNumMoveBits;
+#define UpdateBit1(p) Range -= bound; Code -= bound; *(p) -= (*(p)) >> kNumMoveBits;
+
+#define RC_GET_BIT2(p, mi, A0, A1) IfBit0(p) \
+ { UpdateBit0(p); mi <<= 1; A0; } else \
+ { UpdateBit1(p); mi = (mi + mi) + 1; A1; }
+
+#define RC_GET_BIT(p, mi) RC_GET_BIT2(p, mi, ; , ;)
+
+#define RangeDecoderBitTreeDecode(probs, numLevels, res) \
+ { int i = numLevels; res = 1; \
+ do { CProb *p = probs + res; RC_GET_BIT(p, res) } while(--i != 0); \
+ res -= (1 << numLevels); }
+
+
+#define kNumPosBitsMax 4
+#define kNumPosStatesMax (1 << kNumPosBitsMax)
+
+#define kLenNumLowBits 3
+#define kLenNumLowSymbols (1 << kLenNumLowBits)
+#define kLenNumMidBits 3
+#define kLenNumMidSymbols (1 << kLenNumMidBits)
+#define kLenNumHighBits 8
+#define kLenNumHighSymbols (1 << kLenNumHighBits)
+
+#define LenChoice 0
+#define LenChoice2 (LenChoice + 1)
+#define LenLow (LenChoice2 + 1)
+#define LenMid (LenLow + (kNumPosStatesMax << kLenNumLowBits))
+#define LenHigh (LenMid + (kNumPosStatesMax << kLenNumMidBits))
+#define kNumLenProbs (LenHigh + kLenNumHighSymbols)
+
+
+#define kNumStates 12
+#define kNumLitStates 7
+
+#define kStartPosModelIndex 4
+#define kEndPosModelIndex 14
+#define kNumFullDistances (1 << (kEndPosModelIndex >> 1))
+
+#define kNumPosSlotBits 6
+#define kNumLenToPosStates 4
+
+#define kNumAlignBits 4
+#define kAlignTableSize (1 << kNumAlignBits)
+
+#define kMatchMinLen 2
+
+#define IsMatch 0
+#define IsRep (IsMatch + (kNumStates << kNumPosBitsMax))
+#define IsRepG0 (IsRep + kNumStates)
+#define IsRepG1 (IsRepG0 + kNumStates)
+#define IsRepG2 (IsRepG1 + kNumStates)
+#define IsRep0Long (IsRepG2 + kNumStates)
+#define PosSlot (IsRep0Long + (kNumStates << kNumPosBitsMax))
+#define SpecPos (PosSlot + (kNumLenToPosStates << kNumPosSlotBits))
+#define Align (SpecPos + kNumFullDistances - kEndPosModelIndex)
+#define LenCoder (Align + kAlignTableSize)
+#define RepLenCoder (LenCoder + kNumLenProbs)
+#define Literal (RepLenCoder + kNumLenProbs)
+
+#if Literal != LZMA_BASE_SIZE
+StopCompilingDueBUG
+#endif
+
+int LzmaDecodeProperties(CLzmaProperties *propsRes, const unsigned char *propsData, int size)
+{
+ unsigned char prop0;
+ if (size < LZMA_PROPERTIES_SIZE)
+ return LZMA_RESULT_DATA_ERROR;
+ prop0 = propsData[0];
+ if (prop0 >= (9 * 5 * 5))
+ return LZMA_RESULT_DATA_ERROR;
+ {
+ for (propsRes->pb = 0; prop0 >= (9 * 5); propsRes->pb++, prop0 -= (9 * 5));
+ for (propsRes->lp = 0; prop0 >= 9; propsRes->lp++, prop0 -= 9);
+ propsRes->lc = prop0;
+ /*
+ unsigned char remainder = (unsigned char)(prop0 / 9);
+ propsRes->lc = prop0 % 9;
+ propsRes->pb = remainder / 5;
+ propsRes->lp = remainder % 5;
+ */
+ }
+
+ #ifdef _LZMA_OUT_READ
+ {
+ int i;
+ propsRes->DictionarySize = 0;
+ for (i = 0; i < 4; i++)
+ propsRes->DictionarySize += (UInt32)(propsData[1 + i]) << (i * 8);
+ if (propsRes->DictionarySize == 0)
+ propsRes->DictionarySize = 1;
+ }
+ #endif
+ return LZMA_RESULT_OK;
+}
+
+#define kLzmaStreamWasFinishedId (-1)
+
+int LzmaDecode(CLzmaDecoderState *vs,
+ #ifdef _LZMA_IN_CB
+ ILzmaInCallback *InCallback,
+ #else
+ const unsigned char *inStream, SizeT inSize, SizeT *inSizeProcessed,
+ #endif
+ unsigned char *outStream, SizeT outSize, SizeT *outSizeProcessed)
+{
+ CProb *p = vs->Probs;
+ SizeT nowPos = 0;
+ Byte previousByte = 0;
+ UInt32 posStateMask = (1 << (vs->Properties.pb)) - 1;
+ UInt32 literalPosMask = (1 << (vs->Properties.lp)) - 1;
+ int lc = vs->Properties.lc;
+
+ #ifdef _LZMA_OUT_READ
+
+ UInt32 Range = vs->Range;
+ UInt32 Code = vs->Code;
+ #ifdef _LZMA_IN_CB
+ const Byte *Buffer = vs->Buffer;
+ const Byte *BufferLim = vs->BufferLim;
+ #else
+ const Byte *Buffer = inStream;
+ const Byte *BufferLim = inStream + inSize;
+ #endif
+ int state = vs->State;
+ UInt32 rep0 = vs->Reps[0], rep1 = vs->Reps[1], rep2 = vs->Reps[2], rep3 = vs->Reps[3];
+ int len = vs->RemainLen;
+ UInt32 globalPos = vs->GlobalPos;
+ UInt32 distanceLimit = vs->DistanceLimit;
+
+ Byte *dictionary = vs->Dictionary;
+ UInt32 dictionarySize = vs->Properties.DictionarySize;
+ UInt32 dictionaryPos = vs->DictionaryPos;
+
+ Byte tempDictionary[4];
+
+ #ifndef _LZMA_IN_CB
+ *inSizeProcessed = 0;
+ #endif
+ *outSizeProcessed = 0;
+ if (len == kLzmaStreamWasFinishedId)
+ return LZMA_RESULT_OK;
+
+ if (dictionarySize == 0)
+ {
+ dictionary = tempDictionary;
+ dictionarySize = 1;
+ tempDictionary[0] = vs->TempDictionary[0];
+ }
+
+ if (len == kLzmaNeedInitId)
+ {
+ {
+ UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (lc + vs->Properties.lp));
+ UInt32 i;
+ for (i = 0; i < numProbs; i++)
+ p[i] = kBitModelTotal >> 1;
+ rep0 = rep1 = rep2 = rep3 = 1;
+ state = 0;
+ globalPos = 0;
+ distanceLimit = 0;
+ dictionaryPos = 0;
+ dictionary[dictionarySize - 1] = 0;
+ #ifdef _LZMA_IN_CB
+ RC_INIT;
+ #else
+ RC_INIT(inStream, inSize);
+ #endif
+ }
+ len = 0;
+ }
+ while(len != 0 && nowPos < outSize)
+ {
+ UInt32 pos = dictionaryPos - rep0;
+ if (pos >= dictionarySize)
+ pos += dictionarySize;
+ outStream[nowPos++] = dictionary[dictionaryPos] = dictionary[pos];
+ if (++dictionaryPos == dictionarySize)
+ dictionaryPos = 0;
+ len--;
+ }
+ if (dictionaryPos == 0)
+ previousByte = dictionary[dictionarySize - 1];
+ else
+ previousByte = dictionary[dictionaryPos - 1];
+
+ #else /* if !_LZMA_OUT_READ */
+
+ int state = 0;
+ UInt32 rep0 = 1, rep1 = 1, rep2 = 1, rep3 = 1;
+ int len = 0;
+ const Byte *Buffer;
+ const Byte *BufferLim;
+ UInt32 Range;
+ UInt32 Code;
+
+ #ifndef _LZMA_IN_CB
+ *inSizeProcessed = 0;
+ #endif
+ *outSizeProcessed = 0;
+
+ {
+ UInt32 i;
+ UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (lc + vs->Properties.lp));
+ for (i = 0; i < numProbs; i++)
+ p[i] = kBitModelTotal >> 1;
+ }
+
+ #ifdef _LZMA_IN_CB
+ RC_INIT;
+ #else
+ RC_INIT(inStream, inSize);
+ #endif
+
+ #endif /* _LZMA_OUT_READ */
+
+ while(nowPos < outSize)
+ {
+ CProb *prob;
+ UInt32 bound;
+ int posState = (int)(
+ (nowPos
+ #ifdef _LZMA_OUT_READ
+ + globalPos
+ #endif
+ )
+ & posStateMask);
+
+ prob = p + IsMatch + (state << kNumPosBitsMax) + posState;
+ IfBit0(prob)
+ {
+ int symbol = 1;
+ UpdateBit0(prob)
+ prob = p + Literal + (LZMA_LIT_SIZE *
+ (((
+ (nowPos
+ #ifdef _LZMA_OUT_READ
+ + globalPos
+ #endif
+ )
+ & literalPosMask) << lc) + (previousByte >> (8 - lc))));
+
+ if (state >= kNumLitStates)
+ {
+ int matchByte;
+ #ifdef _LZMA_OUT_READ
+ UInt32 pos = dictionaryPos - rep0;
+ if (pos >= dictionarySize)
+ pos += dictionarySize;
+ matchByte = dictionary[pos];
+ #else
+ matchByte = outStream[nowPos - rep0];
+ #endif
+ do
+ {
+ int bit;
+ CProb *probLit;
+ matchByte <<= 1;
+ bit = (matchByte & 0x100);
+ probLit = prob + 0x100 + bit + symbol;
+ RC_GET_BIT2(probLit, symbol, if (bit != 0) break, if (bit == 0) break)
+ }
+ while (symbol < 0x100);
+ }
+ while (symbol < 0x100)
+ {
+ CProb *probLit = prob + symbol;
+ RC_GET_BIT(probLit, symbol)
+ }
+ previousByte = (Byte)symbol;
+
+ outStream[nowPos++] = previousByte;
+ #ifdef _LZMA_OUT_READ
+ if (distanceLimit < dictionarySize)
+ distanceLimit++;
+
+ dictionary[dictionaryPos] = previousByte;
+ if (++dictionaryPos == dictionarySize)
+ dictionaryPos = 0;
+ #endif
+ if (state < 4) state = 0;
+ else if (state < 10) state -= 3;
+ else state -= 6;
+ }
+ else
+ {
+ UpdateBit1(prob);
+ prob = p + IsRep + state;
+ IfBit0(prob)
+ {
+ UpdateBit0(prob);
+ rep3 = rep2;
+ rep2 = rep1;
+ rep1 = rep0;
+ state = state < kNumLitStates ? 0 : 3;
+ prob = p + LenCoder;
+ }
+ else
+ {
+ UpdateBit1(prob);
+ prob = p + IsRepG0 + state;
+ IfBit0(prob)
+ {
+ UpdateBit0(prob);
+ prob = p + IsRep0Long + (state << kNumPosBitsMax) + posState;
+ IfBit0(prob)
+ {
+ #ifdef _LZMA_OUT_READ
+ UInt32 pos;
+ #endif
+ UpdateBit0(prob);
+
+ #ifdef _LZMA_OUT_READ
+ if (distanceLimit == 0)
+ #else
+ if (nowPos == 0)
+ #endif
+ return LZMA_RESULT_DATA_ERROR;
+
+ state = state < kNumLitStates ? 9 : 11;
+ #ifdef _LZMA_OUT_READ
+ pos = dictionaryPos - rep0;
+ if (pos >= dictionarySize)
+ pos += dictionarySize;
+ previousByte = dictionary[pos];
+ dictionary[dictionaryPos] = previousByte;
+ if (++dictionaryPos == dictionarySize)
+ dictionaryPos = 0;
+ #else
+ previousByte = outStream[nowPos - rep0];
+ #endif
+ outStream[nowPos++] = previousByte;
+ #ifdef _LZMA_OUT_READ
+ if (distanceLimit < dictionarySize)
+ distanceLimit++;
+ #endif
+
+ continue;
+ }
+ else
+ {
+ UpdateBit1(prob);
+ }
+ }
+ else
+ {
+ UInt32 distance;
+ UpdateBit1(prob);
+ prob = p + IsRepG1 + state;
+ IfBit0(prob)
+ {
+ UpdateBit0(prob);
+ distance = rep1;
+ }
+ else
+ {
+ UpdateBit1(prob);
+ prob = p + IsRepG2 + state;
+ IfBit0(prob)
+ {
+ UpdateBit0(prob);
+ distance = rep2;
+ }
+ else
+ {
+ UpdateBit1(prob);
+ distance = rep3;
+ rep3 = rep2;
+ }
+ rep2 = rep1;
+ }
+ rep1 = rep0;
+ rep0 = distance;
+ }
+ state = state < kNumLitStates ? 8 : 11;
+ prob = p + RepLenCoder;
+ }
+ {
+ int numBits, offset;
+ CProb *probLen = prob + LenChoice;
+ IfBit0(probLen)
+ {
+ UpdateBit0(probLen);
+ probLen = prob + LenLow + (posState << kLenNumLowBits);
+ offset = 0;
+ numBits = kLenNumLowBits;
+ }
+ else
+ {
+ UpdateBit1(probLen);
+ probLen = prob + LenChoice2;
+ IfBit0(probLen)
+ {
+ UpdateBit0(probLen);
+ probLen = prob + LenMid + (posState << kLenNumMidBits);
+ offset = kLenNumLowSymbols;
+ numBits = kLenNumMidBits;
+ }
+ else
+ {
+ UpdateBit1(probLen);
+ probLen = prob + LenHigh;
+ offset = kLenNumLowSymbols + kLenNumMidSymbols;
+ numBits = kLenNumHighBits;
+ }
+ }
+ RangeDecoderBitTreeDecode(probLen, numBits, len);
+ len += offset;
+ }
+
+ if (state < 4)
+ {
+ int posSlot;
+ state += kNumLitStates;
+ prob = p + PosSlot +
+ ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) <<
+ kNumPosSlotBits);
+ RangeDecoderBitTreeDecode(prob, kNumPosSlotBits, posSlot);
+ if (posSlot >= kStartPosModelIndex)
+ {
+ int numDirectBits = ((posSlot >> 1) - 1);
+ rep0 = (2 | ((UInt32)posSlot & 1));
+ if (posSlot < kEndPosModelIndex)
+ {
+ rep0 <<= numDirectBits;
+ prob = p + SpecPos + rep0 - posSlot - 1;
+ }
+ else
+ {
+ numDirectBits -= kNumAlignBits;
+ do
+ {
+ RC_NORMALIZE
+ Range >>= 1;
+ rep0 <<= 1;
+ if (Code >= Range)
+ {
+ Code -= Range;
+ rep0 |= 1;
+ }
+ }
+ while (--numDirectBits != 0);
+ prob = p + Align;
+ rep0 <<= kNumAlignBits;
+ numDirectBits = kNumAlignBits;
+ }
+ {
+ int i = 1;
+ int mi = 1;
+ do
+ {
+ CProb *prob3 = prob + mi;
+ RC_GET_BIT2(prob3, mi, ; , rep0 |= i);
+ i <<= 1;
+ }
+ while(--numDirectBits != 0);
+ }
+ }
+ else
+ rep0 = posSlot;
+ if (++rep0 == (UInt32)(0))
+ {
+ /* it's for stream version */
+ len = kLzmaStreamWasFinishedId;
+ break;
+ }
+ }
+
+ len += kMatchMinLen;
+ #ifdef _LZMA_OUT_READ
+ if (rep0 > distanceLimit)
+ #else
+ if (rep0 > nowPos)
+ #endif
+ return LZMA_RESULT_DATA_ERROR;
+
+ #ifdef _LZMA_OUT_READ
+ if (dictionarySize - distanceLimit > (UInt32)len)
+ distanceLimit += len;
+ else
+ distanceLimit = dictionarySize;
+ #endif
+
+ do
+ {
+ #ifdef _LZMA_OUT_READ
+ UInt32 pos = dictionaryPos - rep0;
+ if (pos >= dictionarySize)
+ pos += dictionarySize;
+ previousByte = dictionary[pos];
+ dictionary[dictionaryPos] = previousByte;
+ if (++dictionaryPos == dictionarySize)
+ dictionaryPos = 0;
+ #else
+ previousByte = outStream[nowPos - rep0];
+ #endif
+ len--;
+ outStream[nowPos++] = previousByte;
+ }
+ while(len != 0 && nowPos < outSize);
+ }
+ }
+ RC_NORMALIZE;
+
+ #ifdef _LZMA_OUT_READ
+ vs->Range = Range;
+ vs->Code = Code;
+ vs->DictionaryPos = dictionaryPos;
+ vs->GlobalPos = globalPos + (UInt32)nowPos;
+ vs->DistanceLimit = distanceLimit;
+ vs->Reps[0] = rep0;
+ vs->Reps[1] = rep1;
+ vs->Reps[2] = rep2;
+ vs->Reps[3] = rep3;
+ vs->State = state;
+ vs->RemainLen = len;
+ vs->TempDictionary[0] = tempDictionary[0];
+ #endif
+
+ #ifdef _LZMA_IN_CB
+ vs->Buffer = Buffer;
+ vs->BufferLim = BufferLim;
+ #else
+ *inSizeProcessed = (SizeT)(Buffer - inStream);
+ #endif
+ *outSizeProcessed = nowPos;
+ return LZMA_RESULT_OK;
+}
diff --git a/package/platform/lantiq/ltq-vdsl-fw/src/.svn/text-base/LzmaDecode.h.svn-base b/package/platform/lantiq/ltq-vdsl-fw/src/.svn/text-base/LzmaDecode.h.svn-base
new file mode 100644
index 0000000..2870eeb
--- /dev/null
+++ b/package/platform/lantiq/ltq-vdsl-fw/src/.svn/text-base/LzmaDecode.h.svn-base
@@ -0,0 +1,113 @@
+/*
+ LzmaDecode.h
+ LZMA Decoder interface
+
+ LZMA SDK 4.40 Copyright (c) 1999-2006 Igor Pavlov (2006-05-01)
+ http://www.7-zip.org/
+
+ LZMA SDK is licensed under two licenses:
+ 1) GNU Lesser General Public License (GNU LGPL)
+ 2) Common Public License (CPL)
+ It means that you can select one of these two licenses and
+ follow rules of that license.
+
+ SPECIAL EXCEPTION:
+ Igor Pavlov, as the author of this code, expressly permits you to
+ statically or dynamically link your code (or bind by name) to the
+ interfaces of this file without subjecting your linked code to the
+ terms of the CPL or GNU LGPL. Any modifications or additions
+ to this file, however, are subject to the LGPL or CPL terms.
+*/
+
+#ifndef __LZMADECODE_H
+#define __LZMADECODE_H
+
+#include "LzmaTypes.h"
+
+/* #define _LZMA_IN_CB */
+/* Use callback for input data */
+
+/* #define _LZMA_OUT_READ */
+/* Use read function for output data */
+
+/* #define _LZMA_PROB32 */
+/* It can increase speed on some 32-bit CPUs,
+ but memory usage will be doubled in that case */
+
+/* #define _LZMA_LOC_OPT */
+/* Enable local speed optimizations inside code */
+
+#ifdef _LZMA_PROB32
+#define CProb UInt32
+#else
+#define CProb UInt16
+#endif
+
+#define LZMA_RESULT_OK 0
+#define LZMA_RESULT_DATA_ERROR 1
+
+#ifdef _LZMA_IN_CB
+typedef struct _ILzmaInCallback
+{
+ int (*Read)(void *object, const unsigned char **buffer, SizeT *bufferSize);
+} ILzmaInCallback;
+#endif
+
+#define LZMA_BASE_SIZE 1846
+#define LZMA_LIT_SIZE 768
+
+#define LZMA_PROPERTIES_SIZE 5
+
+typedef struct _CLzmaProperties
+{
+ int lc;
+ int lp;
+ int pb;
+ #ifdef _LZMA_OUT_READ
+ UInt32 DictionarySize;
+ #endif
+}CLzmaProperties;
+
+int LzmaDecodeProperties(CLzmaProperties *propsRes, const unsigned char *propsData, int size);
+
+#define LzmaGetNumProbs(Properties) (LZMA_BASE_SIZE + (LZMA_LIT_SIZE << ((Properties)->lc + (Properties)->lp)))
+
+#define kLzmaNeedInitId (-2)
+
+typedef struct _CLzmaDecoderState
+{
+ CLzmaProperties Properties;
+ CProb *Probs;
+
+ #ifdef _LZMA_IN_CB
+ const unsigned char *Buffer;
+ const unsigned char *BufferLim;
+ #endif
+
+ #ifdef _LZMA_OUT_READ
+ unsigned char *Dictionary;
+ UInt32 Range;
+ UInt32 Code;
+ UInt32 DictionaryPos;
+ UInt32 GlobalPos;
+ UInt32 DistanceLimit;
+ UInt32 Reps[4];
+ int State;
+ int RemainLen;
+ unsigned char TempDictionary[4];
+ #endif
+} CLzmaDecoderState;
+
+#ifdef _LZMA_OUT_READ
+#define LzmaDecoderInit(vs) { (vs)->RemainLen = kLzmaNeedInitId; }
+#endif
+
+int LzmaDecode(CLzmaDecoderState *vs,
+ #ifdef _LZMA_IN_CB
+ ILzmaInCallback *inCallback,
+ #else
+ const unsigned char *inStream, SizeT inSize, SizeT *inSizeProcessed,
+ #endif
+ unsigned char *outStream, SizeT outSize, SizeT *outSizeProcessed);
+
+#endif
diff --git a/package/platform/lantiq/ltq-vdsl-fw/src/.svn/text-base/LzmaTypes.h.svn-base b/package/platform/lantiq/ltq-vdsl-fw/src/.svn/text-base/LzmaTypes.h.svn-base
new file mode 100644
index 0000000..9c27290
--- /dev/null
+++ b/package/platform/lantiq/ltq-vdsl-fw/src/.svn/text-base/LzmaTypes.h.svn-base
@@ -0,0 +1,45 @@
+/*
+LzmaTypes.h
+
+Types for LZMA Decoder
+
+This file written and distributed to public domain by Igor Pavlov.
+This file is part of LZMA SDK 4.40 (2006-05-01)
+*/
+
+#ifndef __LZMATYPES_H
+#define __LZMATYPES_H
+
+#ifndef _7ZIP_BYTE_DEFINED
+#define _7ZIP_BYTE_DEFINED
+typedef unsigned char Byte;
+#endif
+
+#ifndef _7ZIP_UINT16_DEFINED
+#define _7ZIP_UINT16_DEFINED
+typedef unsigned short UInt16;
+#endif
+
+#ifndef _7ZIP_UINT32_DEFINED
+#define _7ZIP_UINT32_DEFINED
+#ifdef _LZMA_UINT32_IS_ULONG
+typedef unsigned long UInt32;
+#else
+typedef unsigned int UInt32;
+#endif
+#endif
+
+/* #define _LZMA_NO_SYSTEM_SIZE_T */
+/* You can use it, if you don't want <stddef.h> */
+
+#ifndef _7ZIP_SIZET_DEFINED
+#define _7ZIP_SIZET_DEFINED
+#ifdef _LZMA_NO_SYSTEM_SIZE_T
+typedef UInt32 SizeT;
+#else
+#include <stddef.h>
+typedef size_t SizeT;
+#endif
+#endif
+
+#endif
diff --git a/package/platform/lantiq/ltq-vdsl-fw/src/.svn/text-base/LzmaWrapper.c.svn-base b/package/platform/lantiq/ltq-vdsl-fw/src/.svn/text-base/LzmaWrapper.c.svn-base
new file mode 100644
index 0000000..7dce056
--- /dev/null
+++ b/package/platform/lantiq/ltq-vdsl-fw/src/.svn/text-base/LzmaWrapper.c.svn-base
@@ -0,0 +1,206 @@
+/******************************************************************************
+**
+** FILE NAME : LzmaWrapper.c
+** PROJECT : bootloader
+** MODULES : U-boot
+**
+** DATE : 2 Nov 2006
+** AUTHOR : Lin Mars
+** DESCRIPTION : LZMA decoder support for U-boot 1.1.5
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 2 Nov 2006 Lin Mars init version which derived from LzmaTest.c from
+** LZMA v4.43 SDK
+** 24 May 2007 Lin Mars Fix issue for multiple lzma_inflate involved
+*******************************************************************************/
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "LzmaDecode.h"
+#include "LzmaWrapper.h"
+
+#if defined(DEBUG_ENABLE_BOOTSTRAP_PRINTF) || !defined(CFG_BOOTSTRAP_CODE)
+static const char *kCantReadMessage = "Can not read from source buffer";
+static const char *kCantAllocateMessage = "Not enough buffer for decompression";
+#endif
+
+static size_t rpos=0, dpos=0;
+
+static int MyReadFileAndCheck(unsigned char *src, void *dest, size_t size)
+{
+ if (size == 0)
+ return 0;
+ memcpy(dest, src + rpos, size);
+ rpos += size;
+ return 1;
+}
+
+int lzma_inflate(unsigned char *source, int s_len, unsigned char *dest, int *d_len)
+{
+ /* We use two 32-bit integers to construct 64-bit integer for file size.
+ You can remove outSizeHigh, if you don't need >= 4GB supporting,
+ or you can use UInt64 outSize, if your compiler supports 64-bit integers*/
+ UInt32 outSize = 0;
+ UInt32 outSizeHigh = 0;
+ SizeT outSizeFull;
+ unsigned char *outStream;
+
+ int waitEOS = 1;
+ /* waitEOS = 1, if there is no uncompressed size in headers,
+ so decoder will wait EOS (End of Stream Marker) in compressed stream */
+
+ SizeT compressedSize;
+ unsigned char *inStream;
+
+ CLzmaDecoderState state; /* it's about 24-80 bytes structure, if int is 32-bit */
+ unsigned char properties[LZMA_PROPERTIES_SIZE];
+
+ int res;
+
+ rpos=0; dpos=0;
+
+ if (sizeof(UInt32) < 4)
+ {
+#if defined(DEBUG_ENABLE_BOOTSTRAP_PRINTF) || !defined(CFG_BOOTSTRAP_CODE)
+ printf("LZMA decoder needs correct UInt32\n");
+#endif
+ return LZMA_RESULT_DATA_ERROR;
+ }
+
+ {
+ long length=s_len;
+ if ((long)(SizeT)length != length)
+ {
+#if defined(DEBUG_ENABLE_BOOTSTRAP_PRINTF) || !defined(CFG_BOOTSTRAP_CODE)
+ printf("Too big compressed stream\n");
+#endif
+ return LZMA_RESULT_DATA_ERROR;
+ }
+ compressedSize = (SizeT)(length - (LZMA_PROPERTIES_SIZE + 8));
+ }
+
+ /* Read LZMA properties for compressed stream */
+
+ if (!MyReadFileAndCheck(source, properties, sizeof(properties)))
+ {
+#if defined(DEBUG_ENABLE_BOOTSTRAP_PRINTF) || !defined(CFG_BOOTSTRAP_CODE)
+ printf("%s\n", kCantReadMessage);
+#endif
+ return LZMA_RESULT_DATA_ERROR;
+ }
+
+ /* Read uncompressed size */
+ {
+ int i;
+ for (i = 0; i < 8; i++)
+ {
+ unsigned char b;
+ if (!MyReadFileAndCheck(source, &b, 1))
+ {
+#if defined(DEBUG_ENABLE_BOOTSTRAP_PRINTF) || !defined(CFG_BOOTSTRAP_CODE)
+ printf("%s\n", kCantReadMessage);
+#endif
+ return LZMA_RESULT_DATA_ERROR;
+ }
+ if (b != 0xFF)
+ waitEOS = 0;
+ if (i < 4)
+ outSize += (UInt32)(b) << (i * 8);
+ else
+ outSizeHigh += (UInt32)(b) << ((i - 4) * 8);
+ }
+
+ if (waitEOS)
+ {
+#if defined(DEBUG_ENABLE_BOOTSTRAP_PRINTF) || !defined(CFG_BOOTSTRAP_CODE)
+ printf("Stream with EOS marker is not supported");
+#endif
+ return LZMA_RESULT_DATA_ERROR;
+ }
+ outSizeFull = (SizeT)outSize;
+ if (sizeof(SizeT) >= 8)
+ outSizeFull |= (((SizeT)outSizeHigh << 16) << 16);
+ else if (outSizeHigh != 0 || (UInt32)(SizeT)outSize != outSize)
+ {
+#if defined(DEBUG_ENABLE_BOOTSTRAP_PRINTF) || !defined(CFG_BOOTSTRAP_CODE)
+ printf("Too big uncompressed stream");
+#endif
+ return LZMA_RESULT_DATA_ERROR;
+ }
+ }
+
+ /* Decode LZMA properties and allocate memory */
+ if (LzmaDecodeProperties(&state.Properties, properties, LZMA_PROPERTIES_SIZE) != LZMA_RESULT_OK)
+ {
+#if defined(DEBUG_ENABLE_BOOTSTRAP_PRINTF) || !defined(CFG_BOOTSTRAP_CODE)
+ printf("Incorrect stream properties");
+#endif
+ return LZMA_RESULT_DATA_ERROR;
+ }
+ state.Probs = (CProb *)malloc(LzmaGetNumProbs(&state.Properties) * sizeof(CProb));
+
+ if (outSizeFull == 0)
+ outStream = 0;
+ else
+ {
+ if (outSizeFull > d_len)
+ outStream = 0;
+ else
+ outStream = dest;
+ }
+
+ if (compressedSize == 0)
+ inStream = 0;
+ else
+ {
+ if ((compressedSize+rpos) > s_len )
+ inStream = 0;
+ else
+ inStream = source + rpos;
+ }
+
+ if (state.Probs == 0
+ || (outStream == 0 && outSizeFull != 0)
+ || (inStream == 0 && compressedSize != 0)
+ )
+ {
+ free(state.Probs);
+#if defined(DEBUG_ENABLE_BOOTSTRAP_PRINTF) || !defined(CFG_BOOTSTRAP_CODE)
+ printf("%s\n", kCantAllocateMessage);
+#endif
+ return LZMA_RESULT_DATA_ERROR;
+ }
+
+ /* Decompress */
+ {
+ SizeT inProcessed;
+ SizeT outProcessed;
+ res = LzmaDecode(&state,
+ inStream, compressedSize, &inProcessed,
+ outStream, outSizeFull, &outProcessed);
+ if (res != 0)
+ {
+#if defined(DEBUG_ENABLE_BOOTSTRAP_PRINTF) || !defined(CFG_BOOTSTRAP_CODE)
+ printf("\nDecoding error = %d\n", res);
+#endif
+ res = 1;
+ }
+ else
+ {
+ *d_len = outProcessed;
+ }
+ }
+
+ free(state.Probs);
+ return res;
+}
diff --git a/package/platform/lantiq/ltq-vdsl-fw/src/.svn/text-base/LzmaWrapper.h.svn-base b/package/platform/lantiq/ltq-vdsl-fw/src/.svn/text-base/LzmaWrapper.h.svn-base
new file mode 100644
index 0000000..2f9a3ff
--- /dev/null
+++ b/package/platform/lantiq/ltq-vdsl-fw/src/.svn/text-base/LzmaWrapper.h.svn-base
@@ -0,0 +1,36 @@
+/******************************************************************************
+**
+** FILE NAME : LzmaWrapper.h
+** PROJECT : bootloader
+** MODULES : U-boot
+**
+** DATE : 2 Nov 2006
+** AUTHOR : Lin Mars
+** DESCRIPTION : LZMA decoder support for U-boot 1.1.5
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 2 Nov 2006 Lin Mars init version which derived from LzmaTest.c from
+** LZMA v4.43 SDK
+*******************************************************************************/
+#ifndef __LZMA_WRAPPER_H__
+#define __LZMA_WRAPPER_H__
+
+#ifndef LZMA_RESULT_OK
+#define LZMA_RESULT_OK 0
+#endif
+#ifndef LZMA_RESULT_DATA_ERROR
+#define LZMA_RESULT_DATA_ERROR 1
+#endif
+
+extern int lzma_inflate(unsigned char *source, int s_len, unsigned char *dest, int *d_len);
+
+#endif /*__LZMA_WRAPPER_H__*/
diff --git a/package/platform/lantiq/ltq-vdsl-fw/src/.svn/text-base/Makefile.svn-base b/package/platform/lantiq/ltq-vdsl-fw/src/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..2d50aaf
--- /dev/null
+++ b/package/platform/lantiq/ltq-vdsl-fw/src/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,13 @@
+PROG=w921v_fw_cutter
+OBJS=w921v_fw_cutter.c LzmaDecode.c LzmaWrapper.c
+
+all: $(PROG)
+
+$(PROG): $(OBJS)
+ $(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@
+
+clean:
+ rm *.o $(PROG)
+
+%.o: %.c
+ $(CC) $(CFLAGS) -c $^ -o $@
diff --git a/package/platform/lantiq/ltq-vdsl-fw/src/.svn/text-base/vdsl_fw_install.sh.svn-base b/package/platform/lantiq/ltq-vdsl-fw/src/.svn/text-base/vdsl_fw_install.sh.svn-base
new file mode 100644
index 0000000..4d40756
--- /dev/null
+++ b/package/platform/lantiq/ltq-vdsl-fw/src/.svn/text-base/vdsl_fw_install.sh.svn-base
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+FW="/tmp/Firmware_Speedport_W921V_1.20.000.bin"
+URL="http://hilfe.telekom.de/dlp/eki/downloads/Speedport/Speedport%20W%20921V/Firmware_Speedport_W921V_1.20.000.bin"
+FW_TAPI="/tmp/vr9_tapi_fw.bin"
+FW_DSL="/tmp/vr9_dsl_fw_annex_b.bin"
+FW_TGZ="/tmp/vr9_fw.tgz"
+MD5_FW="4d812f2c3476dadd738b022c4767c491"
+MD5_TAPI="06b6ab3481b8d3eb7e8bf6131f7f6b7f"
+MD5_DSL="59dd9dc81195c6854433c691b163f757"
+
+[ -f /lib/firmware/vdsl.bin] && exit 0
+
+[ -z "$1" ] || URL=$1
+
+[ -f "${FW}" ] || {
+ echo "${FW} does not exist. Try to Download it ? (y/N)"
+ read -n 1 R
+ echo ""
+ [ "$R" = "y" ] || {
+ echo "Please manually download the firmware from ${URL} and copy the file to ${FW}"
+ exit 1
+ }
+ echo "Download w921v Firmware"
+ wget "${URL}" -O "${FW}"
+ [ $? -eq 0 -a -f "${FW}" ] || exit 1
+}
+
+F=`md5sum -b ${FW} | cut -d" " -f1`
+[ "$F" = "${MD5_FW}" ] || {
+ echo "Failed to verify Firmware MD5"
+ exit 1
+}
+
+echo "Unpack and decompress w921v Firmware"
+w921v_fw_cutter
+[ $? -eq 0 ] || exit 1
+
+T=`md5sum -b ${FW_TAPI} | cut -d" " -f1`
+D=`md5sum -b ${FW_DSL} | cut -d" " -f1`
+
+[ "$T" = "${MD5_TAPI}" -a "$D" = "${MD5_DSL}" ] || {
+ echo "Failed to verify MD5"
+ exit 1
+}
+
+cp ${FW_TAPI} ${FW_DSL} /lib/firmware/
+ln -s /lib/firmware/vr9_dsl_fw_annex_b.bin /lib/firmware/vdsl.bin
diff --git a/package/platform/lantiq/ltq-vdsl-fw/src/.svn/text-base/w921v_fw_cutter.c.svn-base b/package/platform/lantiq/ltq-vdsl-fw/src/.svn/text-base/w921v_fw_cutter.c.svn-base
new file mode 100644
index 0000000..b26c91e
--- /dev/null
+++ b/package/platform/lantiq/ltq-vdsl-fw/src/.svn/text-base/w921v_fw_cutter.c.svn-base
@@ -0,0 +1,164 @@
+/*
+ * 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; version 2 of the License
+ *
+ * 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Copyright (C) 2012 John Crispin <blogic@openwrt.org>
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <fcntl.h>
+
+#include "LzmaWrapper.h"
+
+#define FW_NAME "/tmp/Firmware_Speedport_W921V_1.20.000.bin"
+
+#define MAGIC 0x50
+#define MAGIC_SZ 0x3FFC00
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+#define MAGIC_PART 0x12345678
+#define MAGIC_LZMA 0x8000005D
+#define MAGIC_ANNEX_B 0x3C
+#define MAGIC_TAPI 0x5A
+#else
+#define MAGIC_PART 0x78563412
+#define MAGIC_LZMA 0x5D000080
+#define MAGIC_ANNEX_B 0x3C000000
+#define MAGIC_TAPI 0x5A000000
+#endif
+
+
+const char* part_type(u_int32_t id)
+{
+ switch(id) {
+ case MAGIC_ANNEX_B:
+ return "/tmp/vr9_dsl_fw_annex_b.bin";
+ case MAGIC_TAPI:
+ return "/tmp/vr9_tapi_fw.bin";
+ }
+ printf("\tUnknown lzma type 0x%02X\n", id);
+ return "/tmp/unknown.lzma";
+}
+
+int main(int argc, char **argv)
+{
+ struct stat s;
+ u_int8_t *buf_orig;
+ u_int32_t *buf;
+ int buflen;
+ int fd;
+ int i;
+ int err;
+ int start = 0, end = 0;
+
+ printf("Arcadyan Firmware cutter v0.1\n");
+ printf("-----------------------------\n");
+ printf("This tool extracts the different parts of an arcadyan firmware update file\n");
+ printf("This tool is for private use only. The Firmware that gets extracted has a license that forbids redistribution\n");
+ printf("Please only run this if you understand the risks\n\n");
+ printf("I understand the risks ? (y/N)\n");
+
+ if (getchar() != 'y')
+ return -1;
+
+ if (stat(FW_NAME, &s) != 0) {
+ printf("Failed to find %s\n", FW_NAME);
+ printf("Ask Google or try http://hilfe.telekom.de/dlp/eki/downloads/Speedport/Speedport%20W%20921V/Firmware_Speedport_W921V_1.20.000.bin\n");
+ return -1;
+ }
+
+ buf_orig = malloc(s.st_size);
+ if (!buf_orig) {
+ printf("Failed to alloc %d bytes\n", s.st_size);
+ return -1;
+ }
+
+ fd = open(FW_NAME, O_RDONLY);
+ if (fd < 0) {
+ printf("Unable to open %s\n", FW_NAME);
+ return -1;
+ }
+
+ buflen = read(fd, buf_orig, s.st_size);
+ close(fd);
+ if (buflen != s.st_size) {
+ printf("Loaded %d instead of %d bytes inside %s\n", buflen, s.st_size, FW_NAME);
+ return -1;
+ }
+
+ /* <magic> */
+ buf_orig++;
+ buflen -= 1;
+ for (i = 0; i < MAGIC_SZ; i++) {
+ if ((i % 16) < 3)
+ buf_orig[i] = buf_orig[i + 16] ^ MAGIC;
+ else
+ buf_orig[i] = buf_orig[i] ^ MAGIC;
+ }
+ buflen -= 3;
+ memmove(&buf_orig[MAGIC_SZ], &buf_orig[MAGIC_SZ + 3], buflen - MAGIC_SZ);
+ /* </magic> */
+
+ buf = (u_int32_t*) buf_orig;
+
+ do {
+ if (buf[end] == MAGIC_PART) {
+ end += 2;
+ printf("Found partition at 0x%08X with size %d\n",
+ start * sizeof(u_int32_t),
+ (end - start) * sizeof(u_int32_t));
+ if (buf[start] == MAGIC_LZMA) {
+ int dest_len = 1024 * 1024;
+ int len = buf[end - 3];
+ u_int32_t id = buf[end - 6];
+ const char *type = part_type(id);
+ u_int8_t *dest;
+
+ dest = malloc(dest_len);
+ if (!dest) {
+ printf("Failed to alloc dest buffer\n");
+ return -1;
+ }
+
+ if (lzma_inflate((u_int8_t*)&buf[start], len, dest, &dest_len)) {
+ printf("Failed to decompress data\n");
+ return -1;
+ }
+
+ fd = creat(type, S_IRUSR | S_IWUSR);
+ if (fd != -1) {
+ if (write(fd, dest, dest_len) != dest_len)
+ printf("\tFailed to write %d bytes\n", dest_len);
+ else
+ printf("\tWrote %d bytes to %s\n", dest_len, type);
+ close(fd);
+ } else {
+ printf("\tFailed to open %s\n", type);
+ }
+ free(dest);
+ } else {
+ printf("\tThis is not lzma\n");
+ }
+ start = end;
+ } else {
+ end++;
+ }
+ } while(end < buflen / sizeof(u_int32_t));
+
+ return 0;
+}
diff --git a/package/platform/lantiq/ltq-vdsl-fw/src/LzmaDecode.c b/package/platform/lantiq/ltq-vdsl-fw/src/LzmaDecode.c
new file mode 100644
index 0000000..cb83453
--- /dev/null
+++ b/package/platform/lantiq/ltq-vdsl-fw/src/LzmaDecode.c
@@ -0,0 +1,584 @@
+/*
+ LzmaDecode.c
+ LZMA Decoder (optimized for Speed version)
+
+ LZMA SDK 4.40 Copyright (c) 1999-2006 Igor Pavlov (2006-05-01)
+ http://www.7-zip.org/
+
+ LZMA SDK is licensed under two licenses:
+ 1) GNU Lesser General Public License (GNU LGPL)
+ 2) Common Public License (CPL)
+ It means that you can select one of these two licenses and
+ follow rules of that license.
+
+ SPECIAL EXCEPTION:
+ Igor Pavlov, as the author of this Code, expressly permits you to
+ statically or dynamically link your Code (or bind by name) to the
+ interfaces of this file without subjecting your linked Code to the
+ terms of the CPL or GNU LGPL. Any modifications or additions
+ to this file, however, are subject to the LGPL or CPL terms.
+*/
+
+#include "LzmaDecode.h"
+
+#define kNumTopBits 24
+#define kTopValue ((UInt32)1 << kNumTopBits)
+
+#define kNumBitModelTotalBits 11
+#define kBitModelTotal (1 << kNumBitModelTotalBits)
+#define kNumMoveBits 5
+
+#define RC_READ_BYTE (*Buffer++)
+
+#define RC_INIT2 Code = 0; Range = 0xFFFFFFFF; \
+ { int i; for(i = 0; i < 5; i++) { RC_TEST; Code = (Code << 8) | RC_READ_BYTE; }}
+
+#ifdef _LZMA_IN_CB
+
+#define RC_TEST { if (Buffer == BufferLim) \
+ { SizeT size; int result = InCallback->Read(InCallback, &Buffer, &size); if (result != LZMA_RESULT_OK) return result; \
+ BufferLim = Buffer + size; if (size == 0) return LZMA_RESULT_DATA_ERROR; }}
+
+#define RC_INIT Buffer = BufferLim = 0; RC_INIT2
+
+#else
+
+#define RC_TEST { if (Buffer == BufferLim) return LZMA_RESULT_DATA_ERROR; }
+
+#define RC_INIT(buffer, bufferSize) Buffer = buffer; BufferLim = buffer + bufferSize; RC_INIT2
+
+#endif
+
+#define RC_NORMALIZE if (Range < kTopValue) { RC_TEST; Range <<= 8; Code = (Code << 8) | RC_READ_BYTE; }
+
+#define IfBit0(p) RC_NORMALIZE; bound = (Range >> kNumBitModelTotalBits) * *(p); if (Code < bound)
+#define UpdateBit0(p) Range = bound; *(p) += (kBitModelTotal - *(p)) >> kNumMoveBits;
+#define UpdateBit1(p) Range -= bound; Code -= bound; *(p) -= (*(p)) >> kNumMoveBits;
+
+#define RC_GET_BIT2(p, mi, A0, A1) IfBit0(p) \
+ { UpdateBit0(p); mi <<= 1; A0; } else \
+ { UpdateBit1(p); mi = (mi + mi) + 1; A1; }
+
+#define RC_GET_BIT(p, mi) RC_GET_BIT2(p, mi, ; , ;)
+
+#define RangeDecoderBitTreeDecode(probs, numLevels, res) \
+ { int i = numLevels; res = 1; \
+ do { CProb *p = probs + res; RC_GET_BIT(p, res) } while(--i != 0); \
+ res -= (1 << numLevels); }
+
+
+#define kNumPosBitsMax 4
+#define kNumPosStatesMax (1 << kNumPosBitsMax)
+
+#define kLenNumLowBits 3
+#define kLenNumLowSymbols (1 << kLenNumLowBits)
+#define kLenNumMidBits 3
+#define kLenNumMidSymbols (1 << kLenNumMidBits)
+#define kLenNumHighBits 8
+#define kLenNumHighSymbols (1 << kLenNumHighBits)
+
+#define LenChoice 0
+#define LenChoice2 (LenChoice + 1)
+#define LenLow (LenChoice2 + 1)
+#define LenMid (LenLow + (kNumPosStatesMax << kLenNumLowBits))
+#define LenHigh (LenMid + (kNumPosStatesMax << kLenNumMidBits))
+#define kNumLenProbs (LenHigh + kLenNumHighSymbols)
+
+
+#define kNumStates 12
+#define kNumLitStates 7
+
+#define kStartPosModelIndex 4
+#define kEndPosModelIndex 14
+#define kNumFullDistances (1 << (kEndPosModelIndex >> 1))
+
+#define kNumPosSlotBits 6
+#define kNumLenToPosStates 4
+
+#define kNumAlignBits 4
+#define kAlignTableSize (1 << kNumAlignBits)
+
+#define kMatchMinLen 2
+
+#define IsMatch 0
+#define IsRep (IsMatch + (kNumStates << kNumPosBitsMax))
+#define IsRepG0 (IsRep + kNumStates)
+#define IsRepG1 (IsRepG0 + kNumStates)
+#define IsRepG2 (IsRepG1 + kNumStates)
+#define IsRep0Long (IsRepG2 + kNumStates)
+#define PosSlot (IsRep0Long + (kNumStates << kNumPosBitsMax))
+#define SpecPos (PosSlot + (kNumLenToPosStates << kNumPosSlotBits))
+#define Align (SpecPos + kNumFullDistances - kEndPosModelIndex)
+#define LenCoder (Align + kAlignTableSize)
+#define RepLenCoder (LenCoder + kNumLenProbs)
+#define Literal (RepLenCoder + kNumLenProbs)
+
+#if Literal != LZMA_BASE_SIZE
+StopCompilingDueBUG
+#endif
+
+int LzmaDecodeProperties(CLzmaProperties *propsRes, const unsigned char *propsData, int size)
+{
+ unsigned char prop0;
+ if (size < LZMA_PROPERTIES_SIZE)
+ return LZMA_RESULT_DATA_ERROR;
+ prop0 = propsData[0];
+ if (prop0 >= (9 * 5 * 5))
+ return LZMA_RESULT_DATA_ERROR;
+ {
+ for (propsRes->pb = 0; prop0 >= (9 * 5); propsRes->pb++, prop0 -= (9 * 5));
+ for (propsRes->lp = 0; prop0 >= 9; propsRes->lp++, prop0 -= 9);
+ propsRes->lc = prop0;
+ /*
+ unsigned char remainder = (unsigned char)(prop0 / 9);
+ propsRes->lc = prop0 % 9;
+ propsRes->pb = remainder / 5;
+ propsRes->lp = remainder % 5;
+ */
+ }
+
+ #ifdef _LZMA_OUT_READ
+ {
+ int i;
+ propsRes->DictionarySize = 0;
+ for (i = 0; i < 4; i++)
+ propsRes->DictionarySize += (UInt32)(propsData[1 + i]) << (i * 8);
+ if (propsRes->DictionarySize == 0)
+ propsRes->DictionarySize = 1;
+ }
+ #endif
+ return LZMA_RESULT_OK;
+}
+
+#define kLzmaStreamWasFinishedId (-1)
+
+int LzmaDecode(CLzmaDecoderState *vs,
+ #ifdef _LZMA_IN_CB
+ ILzmaInCallback *InCallback,
+ #else
+ const unsigned char *inStream, SizeT inSize, SizeT *inSizeProcessed,
+ #endif
+ unsigned char *outStream, SizeT outSize, SizeT *outSizeProcessed)
+{
+ CProb *p = vs->Probs;
+ SizeT nowPos = 0;
+ Byte previousByte = 0;
+ UInt32 posStateMask = (1 << (vs->Properties.pb)) - 1;
+ UInt32 literalPosMask = (1 << (vs->Properties.lp)) - 1;
+ int lc = vs->Properties.lc;
+
+ #ifdef _LZMA_OUT_READ
+
+ UInt32 Range = vs->Range;
+ UInt32 Code = vs->Code;
+ #ifdef _LZMA_IN_CB
+ const Byte *Buffer = vs->Buffer;
+ const Byte *BufferLim = vs->BufferLim;
+ #else
+ const Byte *Buffer = inStream;
+ const Byte *BufferLim = inStream + inSize;
+ #endif
+ int state = vs->State;
+ UInt32 rep0 = vs->Reps[0], rep1 = vs->Reps[1], rep2 = vs->Reps[2], rep3 = vs->Reps[3];
+ int len = vs->RemainLen;
+ UInt32 globalPos = vs->GlobalPos;
+ UInt32 distanceLimit = vs->DistanceLimit;
+
+ Byte *dictionary = vs->Dictionary;
+ UInt32 dictionarySize = vs->Properties.DictionarySize;
+ UInt32 dictionaryPos = vs->DictionaryPos;
+
+ Byte tempDictionary[4];
+
+ #ifndef _LZMA_IN_CB
+ *inSizeProcessed = 0;
+ #endif
+ *outSizeProcessed = 0;
+ if (len == kLzmaStreamWasFinishedId)
+ return LZMA_RESULT_OK;
+
+ if (dictionarySize == 0)
+ {
+ dictionary = tempDictionary;
+ dictionarySize = 1;
+ tempDictionary[0] = vs->TempDictionary[0];
+ }
+
+ if (len == kLzmaNeedInitId)
+ {
+ {
+ UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (lc + vs->Properties.lp));
+ UInt32 i;
+ for (i = 0; i < numProbs; i++)
+ p[i] = kBitModelTotal >> 1;
+ rep0 = rep1 = rep2 = rep3 = 1;
+ state = 0;
+ globalPos = 0;
+ distanceLimit = 0;
+ dictionaryPos = 0;
+ dictionary[dictionarySize - 1] = 0;
+ #ifdef _LZMA_IN_CB
+ RC_INIT;
+ #else
+ RC_INIT(inStream, inSize);
+ #endif
+ }
+ len = 0;
+ }
+ while(len != 0 && nowPos < outSize)
+ {
+ UInt32 pos = dictionaryPos - rep0;
+ if (pos >= dictionarySize)
+ pos += dictionarySize;
+ outStream[nowPos++] = dictionary[dictionaryPos] = dictionary[pos];
+ if (++dictionaryPos == dictionarySize)
+ dictionaryPos = 0;
+ len--;
+ }
+ if (dictionaryPos == 0)
+ previousByte = dictionary[dictionarySize - 1];
+ else
+ previousByte = dictionary[dictionaryPos - 1];
+
+ #else /* if !_LZMA_OUT_READ */
+
+ int state = 0;
+ UInt32 rep0 = 1, rep1 = 1, rep2 = 1, rep3 = 1;
+ int len = 0;
+ const Byte *Buffer;
+ const Byte *BufferLim;
+ UInt32 Range;
+ UInt32 Code;
+
+ #ifndef _LZMA_IN_CB
+ *inSizeProcessed = 0;
+ #endif
+ *outSizeProcessed = 0;
+
+ {
+ UInt32 i;
+ UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (lc + vs->Properties.lp));
+ for (i = 0; i < numProbs; i++)
+ p[i] = kBitModelTotal >> 1;
+ }
+
+ #ifdef _LZMA_IN_CB
+ RC_INIT;
+ #else
+ RC_INIT(inStream, inSize);
+ #endif
+
+ #endif /* _LZMA_OUT_READ */
+
+ while(nowPos < outSize)
+ {
+ CProb *prob;
+ UInt32 bound;
+ int posState = (int)(
+ (nowPos
+ #ifdef _LZMA_OUT_READ
+ + globalPos
+ #endif
+ )
+ & posStateMask);
+
+ prob = p + IsMatch + (state << kNumPosBitsMax) + posState;
+ IfBit0(prob)
+ {
+ int symbol = 1;
+ UpdateBit0(prob)
+ prob = p + Literal + (LZMA_LIT_SIZE *
+ (((
+ (nowPos
+ #ifdef _LZMA_OUT_READ
+ + globalPos
+ #endif
+ )
+ & literalPosMask) << lc) + (previousByte >> (8 - lc))));
+
+ if (state >= kNumLitStates)
+ {
+ int matchByte;
+ #ifdef _LZMA_OUT_READ
+ UInt32 pos = dictionaryPos - rep0;
+ if (pos >= dictionarySize)
+ pos += dictionarySize;
+ matchByte = dictionary[pos];
+ #else
+ matchByte = outStream[nowPos - rep0];
+ #endif
+ do
+ {
+ int bit;
+ CProb *probLit;
+ matchByte <<= 1;
+ bit = (matchByte & 0x100);
+ probLit = prob + 0x100 + bit + symbol;
+ RC_GET_BIT2(probLit, symbol, if (bit != 0) break, if (bit == 0) break)
+ }
+ while (symbol < 0x100);
+ }
+ while (symbol < 0x100)
+ {
+ CProb *probLit = prob + symbol;
+ RC_GET_BIT(probLit, symbol)
+ }
+ previousByte = (Byte)symbol;
+
+ outStream[nowPos++] = previousByte;
+ #ifdef _LZMA_OUT_READ
+ if (distanceLimit < dictionarySize)
+ distanceLimit++;
+
+ dictionary[dictionaryPos] = previousByte;
+ if (++dictionaryPos == dictionarySize)
+ dictionaryPos = 0;
+ #endif
+ if (state < 4) state = 0;
+ else if (state < 10) state -= 3;
+ else state -= 6;
+ }
+ else
+ {
+ UpdateBit1(prob);
+ prob = p + IsRep + state;
+ IfBit0(prob)
+ {
+ UpdateBit0(prob);
+ rep3 = rep2;
+ rep2 = rep1;
+ rep1 = rep0;
+ state = state < kNumLitStates ? 0 : 3;
+ prob = p + LenCoder;
+ }
+ else
+ {
+ UpdateBit1(prob);
+ prob = p + IsRepG0 + state;
+ IfBit0(prob)
+ {
+ UpdateBit0(prob);
+ prob = p + IsRep0Long + (state << kNumPosBitsMax) + posState;
+ IfBit0(prob)
+ {
+ #ifdef _LZMA_OUT_READ
+ UInt32 pos;
+ #endif
+ UpdateBit0(prob);
+
+ #ifdef _LZMA_OUT_READ
+ if (distanceLimit == 0)
+ #else
+ if (nowPos == 0)
+ #endif
+ return LZMA_RESULT_DATA_ERROR;
+
+ state = state < kNumLitStates ? 9 : 11;
+ #ifdef _LZMA_OUT_READ
+ pos = dictionaryPos - rep0;
+ if (pos >= dictionarySize)
+ pos += dictionarySize;
+ previousByte = dictionary[pos];
+ dictionary[dictionaryPos] = previousByte;
+ if (++dictionaryPos == dictionarySize)
+ dictionaryPos = 0;
+ #else
+ previousByte = outStream[nowPos - rep0];
+ #endif
+ outStream[nowPos++] = previousByte;
+ #ifdef _LZMA_OUT_READ
+ if (distanceLimit < dictionarySize)
+ distanceLimit++;
+ #endif
+
+ continue;
+ }
+ else
+ {
+ UpdateBit1(prob);
+ }
+ }
+ else
+ {
+ UInt32 distance;
+ UpdateBit1(prob);
+ prob = p + IsRepG1 + state;
+ IfBit0(prob)
+ {
+ UpdateBit0(prob);
+ distance = rep1;
+ }
+ else
+ {
+ UpdateBit1(prob);
+ prob = p + IsRepG2 + state;
+ IfBit0(prob)
+ {
+ UpdateBit0(prob);
+ distance = rep2;
+ }
+ else
+ {
+ UpdateBit1(prob);
+ distance = rep3;
+ rep3 = rep2;
+ }
+ rep2 = rep1;
+ }
+ rep1 = rep0;
+ rep0 = distance;
+ }
+ state = state < kNumLitStates ? 8 : 11;
+ prob = p + RepLenCoder;
+ }
+ {
+ int numBits, offset;
+ CProb *probLen = prob + LenChoice;
+ IfBit0(probLen)
+ {
+ UpdateBit0(probLen);
+ probLen = prob + LenLow + (posState << kLenNumLowBits);
+ offset = 0;
+ numBits = kLenNumLowBits;
+ }
+ else
+ {
+ UpdateBit1(probLen);
+ probLen = prob + LenChoice2;
+ IfBit0(probLen)
+ {
+ UpdateBit0(probLen);
+ probLen = prob + LenMid + (posState << kLenNumMidBits);
+ offset = kLenNumLowSymbols;
+ numBits = kLenNumMidBits;
+ }
+ else
+ {
+ UpdateBit1(probLen);
+ probLen = prob + LenHigh;
+ offset = kLenNumLowSymbols + kLenNumMidSymbols;
+ numBits = kLenNumHighBits;
+ }
+ }
+ RangeDecoderBitTreeDecode(probLen, numBits, len);
+ len += offset;
+ }
+
+ if (state < 4)
+ {
+ int posSlot;
+ state += kNumLitStates;
+ prob = p + PosSlot +
+ ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) <<
+ kNumPosSlotBits);
+ RangeDecoderBitTreeDecode(prob, kNumPosSlotBits, posSlot);
+ if (posSlot >= kStartPosModelIndex)
+ {
+ int numDirectBits = ((posSlot >> 1) - 1);
+ rep0 = (2 | ((UInt32)posSlot & 1));
+ if (posSlot < kEndPosModelIndex)
+ {
+ rep0 <<= numDirectBits;
+ prob = p + SpecPos + rep0 - posSlot - 1;
+ }
+ else
+ {
+ numDirectBits -= kNumAlignBits;
+ do
+ {
+ RC_NORMALIZE
+ Range >>= 1;
+ rep0 <<= 1;
+ if (Code >= Range)
+ {
+ Code -= Range;
+ rep0 |= 1;
+ }
+ }
+ while (--numDirectBits != 0);
+ prob = p + Align;
+ rep0 <<= kNumAlignBits;
+ numDirectBits = kNumAlignBits;
+ }
+ {
+ int i = 1;
+ int mi = 1;
+ do
+ {
+ CProb *prob3 = prob + mi;
+ RC_GET_BIT2(prob3, mi, ; , rep0 |= i);
+ i <<= 1;
+ }
+ while(--numDirectBits != 0);
+ }
+ }
+ else
+ rep0 = posSlot;
+ if (++rep0 == (UInt32)(0))
+ {
+ /* it's for stream version */
+ len = kLzmaStreamWasFinishedId;
+ break;
+ }
+ }
+
+ len += kMatchMinLen;
+ #ifdef _LZMA_OUT_READ
+ if (rep0 > distanceLimit)
+ #else
+ if (rep0 > nowPos)
+ #endif
+ return LZMA_RESULT_DATA_ERROR;
+
+ #ifdef _LZMA_OUT_READ
+ if (dictionarySize - distanceLimit > (UInt32)len)
+ distanceLimit += len;
+ else
+ distanceLimit = dictionarySize;
+ #endif
+
+ do
+ {
+ #ifdef _LZMA_OUT_READ
+ UInt32 pos = dictionaryPos - rep0;
+ if (pos >= dictionarySize)
+ pos += dictionarySize;
+ previousByte = dictionary[pos];
+ dictionary[dictionaryPos] = previousByte;
+ if (++dictionaryPos == dictionarySize)
+ dictionaryPos = 0;
+ #else
+ previousByte = outStream[nowPos - rep0];
+ #endif
+ len--;
+ outStream[nowPos++] = previousByte;
+ }
+ while(len != 0 && nowPos < outSize);
+ }
+ }
+ RC_NORMALIZE;
+
+ #ifdef _LZMA_OUT_READ
+ vs->Range = Range;
+ vs->Code = Code;
+ vs->DictionaryPos = dictionaryPos;
+ vs->GlobalPos = globalPos + (UInt32)nowPos;
+ vs->DistanceLimit = distanceLimit;
+ vs->Reps[0] = rep0;
+ vs->Reps[1] = rep1;
+ vs->Reps[2] = rep2;
+ vs->Reps[3] = rep3;
+ vs->State = state;
+ vs->RemainLen = len;
+ vs->TempDictionary[0] = tempDictionary[0];
+ #endif
+
+ #ifdef _LZMA_IN_CB
+ vs->Buffer = Buffer;
+ vs->BufferLim = BufferLim;
+ #else
+ *inSizeProcessed = (SizeT)(Buffer - inStream);
+ #endif
+ *outSizeProcessed = nowPos;
+ return LZMA_RESULT_OK;
+}
diff --git a/package/platform/lantiq/ltq-vdsl-fw/src/LzmaDecode.h b/package/platform/lantiq/ltq-vdsl-fw/src/LzmaDecode.h
new file mode 100644
index 0000000..2870eeb
--- /dev/null
+++ b/package/platform/lantiq/ltq-vdsl-fw/src/LzmaDecode.h
@@ -0,0 +1,113 @@
+/*
+ LzmaDecode.h
+ LZMA Decoder interface
+
+ LZMA SDK 4.40 Copyright (c) 1999-2006 Igor Pavlov (2006-05-01)
+ http://www.7-zip.org/
+
+ LZMA SDK is licensed under two licenses:
+ 1) GNU Lesser General Public License (GNU LGPL)
+ 2) Common Public License (CPL)
+ It means that you can select one of these two licenses and
+ follow rules of that license.
+
+ SPECIAL EXCEPTION:
+ Igor Pavlov, as the author of this code, expressly permits you to
+ statically or dynamically link your code (or bind by name) to the
+ interfaces of this file without subjecting your linked code to the
+ terms of the CPL or GNU LGPL. Any modifications or additions
+ to this file, however, are subject to the LGPL or CPL terms.
+*/
+
+#ifndef __LZMADECODE_H
+#define __LZMADECODE_H
+
+#include "LzmaTypes.h"
+
+/* #define _LZMA_IN_CB */
+/* Use callback for input data */
+
+/* #define _LZMA_OUT_READ */
+/* Use read function for output data */
+
+/* #define _LZMA_PROB32 */
+/* It can increase speed on some 32-bit CPUs,
+ but memory usage will be doubled in that case */
+
+/* #define _LZMA_LOC_OPT */
+/* Enable local speed optimizations inside code */
+
+#ifdef _LZMA_PROB32
+#define CProb UInt32
+#else
+#define CProb UInt16
+#endif
+
+#define LZMA_RESULT_OK 0
+#define LZMA_RESULT_DATA_ERROR 1
+
+#ifdef _LZMA_IN_CB
+typedef struct _ILzmaInCallback
+{
+ int (*Read)(void *object, const unsigned char **buffer, SizeT *bufferSize);
+} ILzmaInCallback;
+#endif
+
+#define LZMA_BASE_SIZE 1846
+#define LZMA_LIT_SIZE 768
+
+#define LZMA_PROPERTIES_SIZE 5
+
+typedef struct _CLzmaProperties
+{
+ int lc;
+ int lp;
+ int pb;
+ #ifdef _LZMA_OUT_READ
+ UInt32 DictionarySize;
+ #endif
+}CLzmaProperties;
+
+int LzmaDecodeProperties(CLzmaProperties *propsRes, const unsigned char *propsData, int size);
+
+#define LzmaGetNumProbs(Properties) (LZMA_BASE_SIZE + (LZMA_LIT_SIZE << ((Properties)->lc + (Properties)->lp)))
+
+#define kLzmaNeedInitId (-2)
+
+typedef struct _CLzmaDecoderState
+{
+ CLzmaProperties Properties;
+ CProb *Probs;
+
+ #ifdef _LZMA_IN_CB
+ const unsigned char *Buffer;
+ const unsigned char *BufferLim;
+ #endif
+
+ #ifdef _LZMA_OUT_READ
+ unsigned char *Dictionary;
+ UInt32 Range;
+ UInt32 Code;
+ UInt32 DictionaryPos;
+ UInt32 GlobalPos;
+ UInt32 DistanceLimit;
+ UInt32 Reps[4];
+ int State;
+ int RemainLen;
+ unsigned char TempDictionary[4];
+ #endif
+} CLzmaDecoderState;
+
+#ifdef _LZMA_OUT_READ
+#define LzmaDecoderInit(vs) { (vs)->RemainLen = kLzmaNeedInitId; }
+#endif
+
+int LzmaDecode(CLzmaDecoderState *vs,
+ #ifdef _LZMA_IN_CB
+ ILzmaInCallback *inCallback,
+ #else
+ const unsigned char *inStream, SizeT inSize, SizeT *inSizeProcessed,
+ #endif
+ unsigned char *outStream, SizeT outSize, SizeT *outSizeProcessed);
+
+#endif
diff --git a/package/platform/lantiq/ltq-vdsl-fw/src/LzmaTypes.h b/package/platform/lantiq/ltq-vdsl-fw/src/LzmaTypes.h
new file mode 100644
index 0000000..9c27290
--- /dev/null
+++ b/package/platform/lantiq/ltq-vdsl-fw/src/LzmaTypes.h
@@ -0,0 +1,45 @@
+/*
+LzmaTypes.h
+
+Types for LZMA Decoder
+
+This file written and distributed to public domain by Igor Pavlov.
+This file is part of LZMA SDK 4.40 (2006-05-01)
+*/
+
+#ifndef __LZMATYPES_H
+#define __LZMATYPES_H
+
+#ifndef _7ZIP_BYTE_DEFINED
+#define _7ZIP_BYTE_DEFINED
+typedef unsigned char Byte;
+#endif
+
+#ifndef _7ZIP_UINT16_DEFINED
+#define _7ZIP_UINT16_DEFINED
+typedef unsigned short UInt16;
+#endif
+
+#ifndef _7ZIP_UINT32_DEFINED
+#define _7ZIP_UINT32_DEFINED
+#ifdef _LZMA_UINT32_IS_ULONG
+typedef unsigned long UInt32;
+#else
+typedef unsigned int UInt32;
+#endif
+#endif
+
+/* #define _LZMA_NO_SYSTEM_SIZE_T */
+/* You can use it, if you don't want <stddef.h> */
+
+#ifndef _7ZIP_SIZET_DEFINED
+#define _7ZIP_SIZET_DEFINED
+#ifdef _LZMA_NO_SYSTEM_SIZE_T
+typedef UInt32 SizeT;
+#else
+#include <stddef.h>
+typedef size_t SizeT;
+#endif
+#endif
+
+#endif
diff --git a/package/platform/lantiq/ltq-vdsl-fw/src/LzmaWrapper.c b/package/platform/lantiq/ltq-vdsl-fw/src/LzmaWrapper.c
new file mode 100644
index 0000000..7dce056
--- /dev/null
+++ b/package/platform/lantiq/ltq-vdsl-fw/src/LzmaWrapper.c
@@ -0,0 +1,206 @@
+/******************************************************************************
+**
+** FILE NAME : LzmaWrapper.c
+** PROJECT : bootloader
+** MODULES : U-boot
+**
+** DATE : 2 Nov 2006
+** AUTHOR : Lin Mars
+** DESCRIPTION : LZMA decoder support for U-boot 1.1.5
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 2 Nov 2006 Lin Mars init version which derived from LzmaTest.c from
+** LZMA v4.43 SDK
+** 24 May 2007 Lin Mars Fix issue for multiple lzma_inflate involved
+*******************************************************************************/
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "LzmaDecode.h"
+#include "LzmaWrapper.h"
+
+#if defined(DEBUG_ENABLE_BOOTSTRAP_PRINTF) || !defined(CFG_BOOTSTRAP_CODE)
+static const char *kCantReadMessage = "Can not read from source buffer";
+static const char *kCantAllocateMessage = "Not enough buffer for decompression";
+#endif
+
+static size_t rpos=0, dpos=0;
+
+static int MyReadFileAndCheck(unsigned char *src, void *dest, size_t size)
+{
+ if (size == 0)
+ return 0;
+ memcpy(dest, src + rpos, size);
+ rpos += size;
+ return 1;
+}
+
+int lzma_inflate(unsigned char *source, int s_len, unsigned char *dest, int *d_len)
+{
+ /* We use two 32-bit integers to construct 64-bit integer for file size.
+ You can remove outSizeHigh, if you don't need >= 4GB supporting,
+ or you can use UInt64 outSize, if your compiler supports 64-bit integers*/
+ UInt32 outSize = 0;
+ UInt32 outSizeHigh = 0;
+ SizeT outSizeFull;
+ unsigned char *outStream;
+
+ int waitEOS = 1;
+ /* waitEOS = 1, if there is no uncompressed size in headers,
+ so decoder will wait EOS (End of Stream Marker) in compressed stream */
+
+ SizeT compressedSize;
+ unsigned char *inStream;
+
+ CLzmaDecoderState state; /* it's about 24-80 bytes structure, if int is 32-bit */
+ unsigned char properties[LZMA_PROPERTIES_SIZE];
+
+ int res;
+
+ rpos=0; dpos=0;
+
+ if (sizeof(UInt32) < 4)
+ {
+#if defined(DEBUG_ENABLE_BOOTSTRAP_PRINTF) || !defined(CFG_BOOTSTRAP_CODE)
+ printf("LZMA decoder needs correct UInt32\n");
+#endif
+ return LZMA_RESULT_DATA_ERROR;
+ }
+
+ {
+ long length=s_len;
+ if ((long)(SizeT)length != length)
+ {
+#if defined(DEBUG_ENABLE_BOOTSTRAP_PRINTF) || !defined(CFG_BOOTSTRAP_CODE)
+ printf("Too big compressed stream\n");
+#endif
+ return LZMA_RESULT_DATA_ERROR;
+ }
+ compressedSize = (SizeT)(length - (LZMA_PROPERTIES_SIZE + 8));
+ }
+
+ /* Read LZMA properties for compressed stream */
+
+ if (!MyReadFileAndCheck(source, properties, sizeof(properties)))
+ {
+#if defined(DEBUG_ENABLE_BOOTSTRAP_PRINTF) || !defined(CFG_BOOTSTRAP_CODE)
+ printf("%s\n", kCantReadMessage);
+#endif
+ return LZMA_RESULT_DATA_ERROR;
+ }
+
+ /* Read uncompressed size */
+ {
+ int i;
+ for (i = 0; i < 8; i++)
+ {
+ unsigned char b;
+ if (!MyReadFileAndCheck(source, &b, 1))
+ {
+#if defined(DEBUG_ENABLE_BOOTSTRAP_PRINTF) || !defined(CFG_BOOTSTRAP_CODE)
+ printf("%s\n", kCantReadMessage);
+#endif
+ return LZMA_RESULT_DATA_ERROR;
+ }
+ if (b != 0xFF)
+ waitEOS = 0;
+ if (i < 4)
+ outSize += (UInt32)(b) << (i * 8);
+ else
+ outSizeHigh += (UInt32)(b) << ((i - 4) * 8);
+ }
+
+ if (waitEOS)
+ {
+#if defined(DEBUG_ENABLE_BOOTSTRAP_PRINTF) || !defined(CFG_BOOTSTRAP_CODE)
+ printf("Stream with EOS marker is not supported");
+#endif
+ return LZMA_RESULT_DATA_ERROR;
+ }
+ outSizeFull = (SizeT)outSize;
+ if (sizeof(SizeT) >= 8)
+ outSizeFull |= (((SizeT)outSizeHigh << 16) << 16);
+ else if (outSizeHigh != 0 || (UInt32)(SizeT)outSize != outSize)
+ {
+#if defined(DEBUG_ENABLE_BOOTSTRAP_PRINTF) || !defined(CFG_BOOTSTRAP_CODE)
+ printf("Too big uncompressed stream");
+#endif
+ return LZMA_RESULT_DATA_ERROR;
+ }
+ }
+
+ /* Decode LZMA properties and allocate memory */
+ if (LzmaDecodeProperties(&state.Properties, properties, LZMA_PROPERTIES_SIZE) != LZMA_RESULT_OK)
+ {
+#if defined(DEBUG_ENABLE_BOOTSTRAP_PRINTF) || !defined(CFG_BOOTSTRAP_CODE)
+ printf("Incorrect stream properties");
+#endif
+ return LZMA_RESULT_DATA_ERROR;
+ }
+ state.Probs = (CProb *)malloc(LzmaGetNumProbs(&state.Properties) * sizeof(CProb));
+
+ if (outSizeFull == 0)
+ outStream = 0;
+ else
+ {
+ if (outSizeFull > d_len)
+ outStream = 0;
+ else
+ outStream = dest;
+ }
+
+ if (compressedSize == 0)
+ inStream = 0;
+ else
+ {
+ if ((compressedSize+rpos) > s_len )
+ inStream = 0;
+ else
+ inStream = source + rpos;
+ }
+
+ if (state.Probs == 0
+ || (outStream == 0 && outSizeFull != 0)
+ || (inStream == 0 && compressedSize != 0)
+ )
+ {
+ free(state.Probs);
+#if defined(DEBUG_ENABLE_BOOTSTRAP_PRINTF) || !defined(CFG_BOOTSTRAP_CODE)
+ printf("%s\n", kCantAllocateMessage);
+#endif
+ return LZMA_RESULT_DATA_ERROR;
+ }
+
+ /* Decompress */
+ {
+ SizeT inProcessed;
+ SizeT outProcessed;
+ res = LzmaDecode(&state,
+ inStream, compressedSize, &inProcessed,
+ outStream, outSizeFull, &outProcessed);
+ if (res != 0)
+ {
+#if defined(DEBUG_ENABLE_BOOTSTRAP_PRINTF) || !defined(CFG_BOOTSTRAP_CODE)
+ printf("\nDecoding error = %d\n", res);
+#endif
+ res = 1;
+ }
+ else
+ {
+ *d_len = outProcessed;
+ }
+ }
+
+ free(state.Probs);
+ return res;
+}
diff --git a/package/platform/lantiq/ltq-vdsl-fw/src/LzmaWrapper.h b/package/platform/lantiq/ltq-vdsl-fw/src/LzmaWrapper.h
new file mode 100644
index 0000000..2f9a3ff
--- /dev/null
+++ b/package/platform/lantiq/ltq-vdsl-fw/src/LzmaWrapper.h
@@ -0,0 +1,36 @@
+/******************************************************************************
+**
+** FILE NAME : LzmaWrapper.h
+** PROJECT : bootloader
+** MODULES : U-boot
+**
+** DATE : 2 Nov 2006
+** AUTHOR : Lin Mars
+** DESCRIPTION : LZMA decoder support for U-boot 1.1.5
+** COPYRIGHT : Copyright (c) 2006
+** Infineon Technologies AG
+** Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+** 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 of the License, or
+** (at your option) any later version.
+**
+** HISTORY
+** $Date $Author $Comment
+** 2 Nov 2006 Lin Mars init version which derived from LzmaTest.c from
+** LZMA v4.43 SDK
+*******************************************************************************/
+#ifndef __LZMA_WRAPPER_H__
+#define __LZMA_WRAPPER_H__
+
+#ifndef LZMA_RESULT_OK
+#define LZMA_RESULT_OK 0
+#endif
+#ifndef LZMA_RESULT_DATA_ERROR
+#define LZMA_RESULT_DATA_ERROR 1
+#endif
+
+extern int lzma_inflate(unsigned char *source, int s_len, unsigned char *dest, int *d_len);
+
+#endif /*__LZMA_WRAPPER_H__*/
diff --git a/package/platform/lantiq/ltq-vdsl-fw/src/Makefile b/package/platform/lantiq/ltq-vdsl-fw/src/Makefile
new file mode 100644
index 0000000..2d50aaf
--- /dev/null
+++ b/package/platform/lantiq/ltq-vdsl-fw/src/Makefile
@@ -0,0 +1,13 @@
+PROG=w921v_fw_cutter
+OBJS=w921v_fw_cutter.c LzmaDecode.c LzmaWrapper.c
+
+all: $(PROG)
+
+$(PROG): $(OBJS)
+ $(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@
+
+clean:
+ rm *.o $(PROG)
+
+%.o: %.c
+ $(CC) $(CFLAGS) -c $^ -o $@
diff --git a/package/platform/lantiq/ltq-vdsl-fw/src/vdsl_fw_install.sh b/package/platform/lantiq/ltq-vdsl-fw/src/vdsl_fw_install.sh
new file mode 100755
index 0000000..4d40756
--- /dev/null
+++ b/package/platform/lantiq/ltq-vdsl-fw/src/vdsl_fw_install.sh
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+FW="/tmp/Firmware_Speedport_W921V_1.20.000.bin"
+URL="http://hilfe.telekom.de/dlp/eki/downloads/Speedport/Speedport%20W%20921V/Firmware_Speedport_W921V_1.20.000.bin"
+FW_TAPI="/tmp/vr9_tapi_fw.bin"
+FW_DSL="/tmp/vr9_dsl_fw_annex_b.bin"
+FW_TGZ="/tmp/vr9_fw.tgz"
+MD5_FW="4d812f2c3476dadd738b022c4767c491"
+MD5_TAPI="06b6ab3481b8d3eb7e8bf6131f7f6b7f"
+MD5_DSL="59dd9dc81195c6854433c691b163f757"
+
+[ -f /lib/firmware/vdsl.bin] && exit 0
+
+[ -z "$1" ] || URL=$1
+
+[ -f "${FW}" ] || {
+ echo "${FW} does not exist. Try to Download it ? (y/N)"
+ read -n 1 R
+ echo ""
+ [ "$R" = "y" ] || {
+ echo "Please manually download the firmware from ${URL} and copy the file to ${FW}"
+ exit 1
+ }
+ echo "Download w921v Firmware"
+ wget "${URL}" -O "${FW}"
+ [ $? -eq 0 -a -f "${FW}" ] || exit 1
+}
+
+F=`md5sum -b ${FW} | cut -d" " -f1`
+[ "$F" = "${MD5_FW}" ] || {
+ echo "Failed to verify Firmware MD5"
+ exit 1
+}
+
+echo "Unpack and decompress w921v Firmware"
+w921v_fw_cutter
+[ $? -eq 0 ] || exit 1
+
+T=`md5sum -b ${FW_TAPI} | cut -d" " -f1`
+D=`md5sum -b ${FW_DSL} | cut -d" " -f1`
+
+[ "$T" = "${MD5_TAPI}" -a "$D" = "${MD5_DSL}" ] || {
+ echo "Failed to verify MD5"
+ exit 1
+}
+
+cp ${FW_TAPI} ${FW_DSL} /lib/firmware/
+ln -s /lib/firmware/vr9_dsl_fw_annex_b.bin /lib/firmware/vdsl.bin
diff --git a/package/platform/lantiq/ltq-vdsl-fw/src/w921v_fw_cutter.c b/package/platform/lantiq/ltq-vdsl-fw/src/w921v_fw_cutter.c
new file mode 100644
index 0000000..b26c91e
--- /dev/null
+++ b/package/platform/lantiq/ltq-vdsl-fw/src/w921v_fw_cutter.c
@@ -0,0 +1,164 @@
+/*
+ * 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; version 2 of the License
+ *
+ * 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Copyright (C) 2012 John Crispin <blogic@openwrt.org>
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <fcntl.h>
+
+#include "LzmaWrapper.h"
+
+#define FW_NAME "/tmp/Firmware_Speedport_W921V_1.20.000.bin"
+
+#define MAGIC 0x50
+#define MAGIC_SZ 0x3FFC00
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+#define MAGIC_PART 0x12345678
+#define MAGIC_LZMA 0x8000005D
+#define MAGIC_ANNEX_B 0x3C
+#define MAGIC_TAPI 0x5A
+#else
+#define MAGIC_PART 0x78563412
+#define MAGIC_LZMA 0x5D000080
+#define MAGIC_ANNEX_B 0x3C000000
+#define MAGIC_TAPI 0x5A000000
+#endif
+
+
+const char* part_type(u_int32_t id)
+{
+ switch(id) {
+ case MAGIC_ANNEX_B:
+ return "/tmp/vr9_dsl_fw_annex_b.bin";
+ case MAGIC_TAPI:
+ return "/tmp/vr9_tapi_fw.bin";
+ }
+ printf("\tUnknown lzma type 0x%02X\n", id);
+ return "/tmp/unknown.lzma";
+}
+
+int main(int argc, char **argv)
+{
+ struct stat s;
+ u_int8_t *buf_orig;
+ u_int32_t *buf;
+ int buflen;
+ int fd;
+ int i;
+ int err;
+ int start = 0, end = 0;
+
+ printf("Arcadyan Firmware cutter v0.1\n");
+ printf("-----------------------------\n");
+ printf("This tool extracts the different parts of an arcadyan firmware update file\n");
+ printf("This tool is for private use only. The Firmware that gets extracted has a license that forbids redistribution\n");
+ printf("Please only run this if you understand the risks\n\n");
+ printf("I understand the risks ? (y/N)\n");
+
+ if (getchar() != 'y')
+ return -1;
+
+ if (stat(FW_NAME, &s) != 0) {
+ printf("Failed to find %s\n", FW_NAME);
+ printf("Ask Google or try http://hilfe.telekom.de/dlp/eki/downloads/Speedport/Speedport%20W%20921V/Firmware_Speedport_W921V_1.20.000.bin\n");
+ return -1;
+ }
+
+ buf_orig = malloc(s.st_size);
+ if (!buf_orig) {
+ printf("Failed to alloc %d bytes\n", s.st_size);
+ return -1;
+ }
+
+ fd = open(FW_NAME, O_RDONLY);
+ if (fd < 0) {
+ printf("Unable to open %s\n", FW_NAME);
+ return -1;
+ }
+
+ buflen = read(fd, buf_orig, s.st_size);
+ close(fd);
+ if (buflen != s.st_size) {
+ printf("Loaded %d instead of %d bytes inside %s\n", buflen, s.st_size, FW_NAME);
+ return -1;
+ }
+
+ /* <magic> */
+ buf_orig++;
+ buflen -= 1;
+ for (i = 0; i < MAGIC_SZ; i++) {
+ if ((i % 16) < 3)
+ buf_orig[i] = buf_orig[i + 16] ^ MAGIC;
+ else
+ buf_orig[i] = buf_orig[i] ^ MAGIC;
+ }
+ buflen -= 3;
+ memmove(&buf_orig[MAGIC_SZ], &buf_orig[MAGIC_SZ + 3], buflen - MAGIC_SZ);
+ /* </magic> */
+
+ buf = (u_int32_t*) buf_orig;
+
+ do {
+ if (buf[end] == MAGIC_PART) {
+ end += 2;
+ printf("Found partition at 0x%08X with size %d\n",
+ start * sizeof(u_int32_t),
+ (end - start) * sizeof(u_int32_t));
+ if (buf[start] == MAGIC_LZMA) {
+ int dest_len = 1024 * 1024;
+ int len = buf[end - 3];
+ u_int32_t id = buf[end - 6];
+ const char *type = part_type(id);
+ u_int8_t *dest;
+
+ dest = malloc(dest_len);
+ if (!dest) {
+ printf("Failed to alloc dest buffer\n");
+ return -1;
+ }
+
+ if (lzma_inflate((u_int8_t*)&buf[start], len, dest, &dest_len)) {
+ printf("Failed to decompress data\n");
+ return -1;
+ }
+
+ fd = creat(type, S_IRUSR | S_IWUSR);
+ if (fd != -1) {
+ if (write(fd, dest, dest_len) != dest_len)
+ printf("\tFailed to write %d bytes\n", dest_len);
+ else
+ printf("\tWrote %d bytes to %s\n", dest_len, type);
+ close(fd);
+ } else {
+ printf("\tFailed to open %s\n", type);
+ }
+ free(dest);
+ } else {
+ printf("\tThis is not lzma\n");
+ }
+ start = end;
+ } else {
+ end++;
+ }
+ } while(end < buflen / sizeof(u_int32_t));
+
+ return 0;
+}
diff --git a/package/platform/lantiq/ltq-vdsl-mei/.svn/entries b/package/platform/lantiq/ltq-vdsl-mei/.svn/entries
new file mode 100644
index 0000000..aa9f623
--- /dev/null
+++ b/package/platform/lantiq/ltq-vdsl-mei/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/platform/lantiq/ltq-vdsl-mei
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-14T18:43:23.358748Z
+36024
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+578b50d526098ae35a1fdebc058dd0b8
+2013-03-14T18:43:23.358748Z
+36024
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1934
+
diff --git a/package/platform/lantiq/ltq-vdsl-mei/.svn/text-base/Makefile.svn-base b/package/platform/lantiq/ltq-vdsl-mei/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..8561573
--- /dev/null
+++ b/package/platform/lantiq/ltq-vdsl-mei/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,60 @@
+# Copyright (C) 2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=ltq-vdsl-vr9-mei
+PKG_VERSION:=1.2.0
+PKG_RELEASE:=1
+
+PKG_BASE_NAME:=drv_mei_cpe
+PKG_SOURCE:=$(PKG_BASE_NAME)-$(PKG_VERSION).tar.gz
+PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_BASE_NAME)-$(PKG_VERSION)
+PKG_MD5SUM:=cf2fccc1bc72390b2aec46650abf2f20
+PKG_FIXUP:=autoreconf
+PKG_MAINTAINER:=John Crispin <blogic@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/ltq-vdsl-vr9-mei
+ TITLE:=mei driver for vdsl
+ SECTION:=sys
+ SUBMENU:=Network Devices
+ DEPENDS:=@TARGET_lantiq_xway +kmod-ltq-ifxos
+ FILES:=$(PKG_BUILD_DIR)/src/drv_mei_cpe.ko
+ AUTOLOAD:=$(call AutoLoad,50,drv_mei_cpe)
+endef
+
+define KernelPackage/ltq-vdsl-vr9-mei/description
+ Lantiq MEI CPE Kernel Module Driver
+endef
+
+#DEBUG=-DDEBUG_PRINT=1
+
+CONFIGURE_ARGS += \
+ --enable-kernelincl="$(LINUX_DIR)/include" \
+ --enable-device=vr9 \
+ --with-max-device=1 \
+ --with-lines-per-device=1 \
+ --enable-debug \
+ --enable-error_print \
+ --enable-ifxos-include="-I$(STAGING_DIR)/usr/include/ifxos/" \
+ --enable-ifxos-library="-L$(STAGING_DIR)/usr/lib" \
+ --enable-add_drv_cflags="$(DEBUG) -DMEI_DRV_ATM_PTM_INTERFACE_ENABLE=1 -fno-pic -mno-abicalls -mlong-calls -O2 -g0" \
+ --enable-linux-26 \
+ --enable-kernelbuild="$(LINUX_DIR)" \
+ ARCH=$(LINUX_KARCH)
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include/vdsl
+ $(CP) $(PKG_BUILD_DIR)/src/drv_mei_cpe_api_intern.h $(1)/usr/include/vdsl/
+ $(CP) $(PKG_BUILD_DIR)/src/drv_mei_cpe_api_atm_ptm_intern.h $(1)/usr/include/vdsl/
+ $(CP) $(PKG_BUILD_DIR)/src/drv_mei_cpe_interface.h $(1)/usr/include/vdsl
+ $(CP) $(PKG_BUILD_DIR)/src/drv_mei_cpe_config.h $(1)/usr/include/vdsl/
+ $(CP) $(PKG_BUILD_DIR)/src/cmv_message_format.h $(1)/usr/include/vdsl/
+endef
+
+$(eval $(call KernelPackage,ltq-vdsl-vr9-mei))
diff --git a/package/platform/lantiq/ltq-vdsl-mei/Makefile b/package/platform/lantiq/ltq-vdsl-mei/Makefile
new file mode 100644
index 0000000..8561573
--- /dev/null
+++ b/package/platform/lantiq/ltq-vdsl-mei/Makefile
@@ -0,0 +1,60 @@
+# Copyright (C) 2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=ltq-vdsl-vr9-mei
+PKG_VERSION:=1.2.0
+PKG_RELEASE:=1
+
+PKG_BASE_NAME:=drv_mei_cpe
+PKG_SOURCE:=$(PKG_BASE_NAME)-$(PKG_VERSION).tar.gz
+PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_BASE_NAME)-$(PKG_VERSION)
+PKG_MD5SUM:=cf2fccc1bc72390b2aec46650abf2f20
+PKG_FIXUP:=autoreconf
+PKG_MAINTAINER:=John Crispin <blogic@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/ltq-vdsl-vr9-mei
+ TITLE:=mei driver for vdsl
+ SECTION:=sys
+ SUBMENU:=Network Devices
+ DEPENDS:=@TARGET_lantiq_xway +kmod-ltq-ifxos
+ FILES:=$(PKG_BUILD_DIR)/src/drv_mei_cpe.ko
+ AUTOLOAD:=$(call AutoLoad,50,drv_mei_cpe)
+endef
+
+define KernelPackage/ltq-vdsl-vr9-mei/description
+ Lantiq MEI CPE Kernel Module Driver
+endef
+
+#DEBUG=-DDEBUG_PRINT=1
+
+CONFIGURE_ARGS += \
+ --enable-kernelincl="$(LINUX_DIR)/include" \
+ --enable-device=vr9 \
+ --with-max-device=1 \
+ --with-lines-per-device=1 \
+ --enable-debug \
+ --enable-error_print \
+ --enable-ifxos-include="-I$(STAGING_DIR)/usr/include/ifxos/" \
+ --enable-ifxos-library="-L$(STAGING_DIR)/usr/lib" \
+ --enable-add_drv_cflags="$(DEBUG) -DMEI_DRV_ATM_PTM_INTERFACE_ENABLE=1 -fno-pic -mno-abicalls -mlong-calls -O2 -g0" \
+ --enable-linux-26 \
+ --enable-kernelbuild="$(LINUX_DIR)" \
+ ARCH=$(LINUX_KARCH)
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include/vdsl
+ $(CP) $(PKG_BUILD_DIR)/src/drv_mei_cpe_api_intern.h $(1)/usr/include/vdsl/
+ $(CP) $(PKG_BUILD_DIR)/src/drv_mei_cpe_api_atm_ptm_intern.h $(1)/usr/include/vdsl/
+ $(CP) $(PKG_BUILD_DIR)/src/drv_mei_cpe_interface.h $(1)/usr/include/vdsl
+ $(CP) $(PKG_BUILD_DIR)/src/drv_mei_cpe_config.h $(1)/usr/include/vdsl/
+ $(CP) $(PKG_BUILD_DIR)/src/cmv_message_format.h $(1)/usr/include/vdsl/
+endef
+
+$(eval $(call KernelPackage,ltq-vdsl-vr9-mei))
diff --git a/package/platform/lantiq/ltq-vdsl-mei/patches/.svn/entries b/package/platform/lantiq/ltq-vdsl-mei/patches/.svn/entries
new file mode 100644
index 0000000..768cde0
--- /dev/null
+++ b/package/platform/lantiq/ltq-vdsl-mei/patches/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/platform/lantiq/ltq-vdsl-mei/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-14T18:43:23.358748Z
+36024
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+100-compat.patch
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+24330a930611dda58eac0db7ebd94b1a
+2013-03-14T18:43:23.358748Z
+36024
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+9818
+
diff --git a/package/platform/lantiq/ltq-vdsl-mei/patches/.svn/text-base/100-compat.patch.svn-base b/package/platform/lantiq/ltq-vdsl-mei/patches/.svn/text-base/100-compat.patch.svn-base
new file mode 100644
index 0000000..5822e74
--- /dev/null
+++ b/package/platform/lantiq/ltq-vdsl-mei/patches/.svn/text-base/100-compat.patch.svn-base
@@ -0,0 +1,298 @@
+Index: drv_mei_cpe-1.2.0/src/drv_mei_cpe_common.c
+===================================================================
+--- drv_mei_cpe-1.2.0.orig/src/drv_mei_cpe_common.c 2011-10-26 00:49:51.000000000 +0200
++++ drv_mei_cpe-1.2.0/src/drv_mei_cpe_common.c 2012-11-28 15:14:10.421633418 +0100
+@@ -20,7 +20,6 @@
+ /* get at first the driver configuration */
+ #include "drv_mei_cpe_config.h"
+
+-#include "ifx_types.h"
+ #include "drv_mei_cpe_os.h"
+ #include "drv_mei_cpe_dbg.h"
+
+Index: drv_mei_cpe-1.2.0/configure.in
+===================================================================
+--- drv_mei_cpe-1.2.0.orig/configure.in 2012-01-20 17:41:07.000000000 +0100
++++ drv_mei_cpe-1.2.0/configure.in 2012-11-28 15:14:10.421633418 +0100
+@@ -140,7 +140,7 @@
+ AC_ARG_ENABLE(kernelbuild,
+ AC_HELP_STRING([--enable-kernelbuild=x],[Set the target kernel build path]),
+ [
+- if test -e $enableval/include/linux/autoconf.h; then
++ if test -e $enableval/include/generated/autoconf.h; then
+ AC_SUBST([KERNEL_BUILD_PATH],[$enableval])
+ else
+ AC_MSG_ERROR([The kernel build directory is not valid or not configured!])
+Index: drv_mei_cpe-1.2.0/configure
+===================================================================
+--- drv_mei_cpe-1.2.0.orig/configure 2012-01-20 17:50:02.000000000 +0100
++++ drv_mei_cpe-1.2.0/configure 2012-11-28 15:14:56.637634577 +0100
+@@ -617,6 +617,7 @@
+ am__fastdepCC_FALSE
+ am__fastdepCC_TRUE
+ CCDEPMODE
++am__nodep
+ AMDEPBACKSLASH
+ AMDEP_FALSE
+ AMDEP_TRUE
+@@ -2367,11 +2368,11 @@
+
+ # We need awk for the "check" target. The system "awk" is bad on
+ # some platforms.
+-# Always define AMTAR for backward compatibility.
++# Always define AMTAR for backward compatibility. Yes, it's still used
++# in the wild :-( We should find a proper way to deprecate it ...
++AMTAR='$${TAR-tar}'
+
+-AMTAR=${AMTAR-"${am_missing_run}tar"}
+-
+-am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'
++am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'
+
+
+
+@@ -3219,6 +3220,7 @@
+ if test "x$enable_dependency_tracking" != xno; then
+ am_depcomp="$ac_aux_dir/depcomp"
+ AMDEPBACKSLASH='\'
++ am__nodep='_no'
+ fi
+ if test "x$enable_dependency_tracking" != xno; then
+ AMDEP_TRUE=
+@@ -3243,6 +3245,7 @@
+ # instance it was reported that on HP-UX the gcc test will end up
+ # making a dummy file named `D' -- because `-MD' means `put the output
+ # in D'.
++ rm -rf conftest.dir
+ mkdir conftest.dir
+ # Copy depcomp to subdir because otherwise we won't find it if we're
+ # using a relative directory.
+@@ -3302,7 +3305,7 @@
+ break
+ fi
+ ;;
+- msvisualcpp | msvcmsys)
++ msvc7 | msvc7msys | msvisualcpp | msvcmsys)
+ # This compiler won't grok `-c -o', but also, the minuso test has
+ # not run yet. These depmodes are late enough in the game, and
+ # so weak that their functioning should not be impacted.
+@@ -3656,7 +3659,7 @@
+ # Check whether --enable-kernelbuild was given.
+ if test "${enable_kernelbuild+set}" = set; then :
+ enableval=$enable_kernelbuild;
+- if test -e $enableval/include/linux/autoconf.h; then
++ if test -e $enableval/include/generated/autoconf.h; then
+ KERNEL_BUILD_PATH=$enableval
+
+ else
+Index: drv_mei_cpe-1.2.0/src/drv_mei_cpe_linux.h
+===================================================================
+--- drv_mei_cpe-1.2.0.orig/src/drv_mei_cpe_linux.h 2011-07-25 20:41:02.000000000 +0200
++++ drv_mei_cpe-1.2.0/src/drv_mei_cpe_linux.h 2012-11-28 15:14:10.429633419 +0100
+@@ -34,8 +34,6 @@
+ #include <linux/sched.h>
+ #include <linux/interrupt.h>
+
+-#include <asm/ifx/irq.h>
+-
+ #if (MEI_DRV_IFXOS_ENABLE == 0)
+
+ #include <linux/version.h>
+@@ -44,8 +42,6 @@
+ #include <linux/poll.h>
+ #include <linux/types.h>
+
+-#include <asm/ifx/ifx_types.h>
+-
+ #endif /* #if (MEI_DRV_IFXOS_ENABLE == 0)*/
+
+ /* ============================================================================
+Index: drv_mei_cpe-1.2.0/src/drv_mei_cpe_mei_vr9.h
+===================================================================
+--- drv_mei_cpe-1.2.0.orig/src/drv_mei_cpe_mei_vr9.h 2011-07-25 20:41:02.000000000 +0200
++++ drv_mei_cpe-1.2.0/src/drv_mei_cpe_mei_vr9.h 2012-11-28 15:14:10.429633419 +0100
+@@ -40,12 +40,6 @@
+ #endif
+ #endif
+
+-#ifdef LINUX
+- #include <asm/ifx/ifx_pmu.h>
+-#else
+- #error "Please check PMU driver path!"
+-#endif
+-
+ /* ============================================================================
+ Module : RCU register address and bits
+ ========================================================================= */
+Index: drv_mei_cpe-1.2.0/src/drv_mei_cpe_api_atm_ptm_intern.c
+===================================================================
+--- drv_mei_cpe-1.2.0.orig/src/drv_mei_cpe_api_atm_ptm_intern.c 2011-07-25 20:41:02.000000000 +0200
++++ drv_mei_cpe-1.2.0/src/drv_mei_cpe_api_atm_ptm_intern.c 2012-11-28 15:14:10.429633419 +0100
+@@ -25,11 +25,7 @@
+ #include "ifx_types.h"
+ #include "drv_mei_cpe_os.h"
+
+-#ifdef LINUX
+- #include <asm/ifx/ifx_atm.h>
+-#else
+- #error "ATM/PTM internal interface is only supported for Linux!"
+-#endif
++#include <lantiq_atm.h>
+
+ /** get interface and configuration */
+ #include "drv_mei_cpe_interface.h"
+Index: drv_mei_cpe-1.2.0/src/drv_mei_cpe_linux.c
+===================================================================
+--- drv_mei_cpe-1.2.0.orig/src/drv_mei_cpe_linux.c 2011-07-25 20:41:02.000000000 +0200
++++ drv_mei_cpe-1.2.0/src/drv_mei_cpe_linux.c 2012-11-28 15:24:56.269649609 +0100
+@@ -32,11 +32,9 @@
+ #include <linux/module.h>
+ #include <linux/version.h>
+
+-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17))
+-#include <linux/utsrelease.h>
+-#endif
+-#include <linux/init.h>
++#include <generated/utsrelease.h>
+
++#include <linux/device.h>
+ #include <linux/ioport.h>
+ #include <linux/irq.h>
+ #include <asm/io.h>
+@@ -87,6 +85,8 @@
+ #include "drv_mei_cpe_device_cntrl.h"
+ #endif
+
++#define INT_NUM_IM4_IRL30 (INT_NUM_IM4_IRL0 + 30)
++
+ /* ===================================
+ extern function declarations
+ =================================== */
+@@ -122,7 +122,7 @@
+ size_t length,
+ loff_t * ppos);
+
+-static int MEI_Ioctl( struct inode *inode, struct file *filp,
++static long MEI_Ioctl(struct file *filp,
+ unsigned int nCmd, unsigned long nArgument);
+
+ static unsigned int MEI_Poll (struct file *filp, poll_table *table);
+@@ -137,7 +137,7 @@
+
+ static void MEI_IfxFreeIrq(unsigned int usedIrq, void *pUsedDevId);
+
+-static irqreturn_t MEI_InterruptLinux(int irq, void *dev_id, struct pt_regs *regs);
++static irqreturn_t MEI_InterruptLinux(int irq, void *dev_id);
+ #endif
+
+ #if CONFIG_PROC_FS
+@@ -194,7 +194,9 @@
+ /* =================================== */
+ /* Local variables (LINUX) */
+ /* =================================== */
+-static IFX_uint8_t major_number = 0;
++#define MEI_MAJOR 105
++
++static IFX_uint8_t major_number = MEI_MAJOR;
+ #ifdef MODULE
+ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
+ MODULE_PARM(major_number, "b");
+@@ -242,7 +244,7 @@
+ MEI_Write,
+ poll:
+ MEI_Poll,
+- ioctl:
++ unlocked_ioctl:
+ MEI_Ioctl,
+ open:
+ MEI_OpenOS,
+@@ -457,7 +459,7 @@
+ 0 and positive values - success,
+ negative value - ioctl failed
+ */
+-static int MEI_Ioctl( struct inode *inode, struct file *filp,
++static long MEI_Ioctl(struct file *filp,
+ unsigned int nCmd, unsigned long nArgument)
+ {
+ int ret = 0, retSize = sizeof(IOCTL_MEI_ioctl_t);
+@@ -1242,7 +1246,7 @@
+ \remark
+ None.
+ */
+-static irqreturn_t MEI_InterruptLinux(int irq, void *dev_id, struct pt_regs *regs)
++static irqreturn_t MEI_InterruptLinux(int irq, void *dev_id)
+ {
+ IFX_int32_t meiIntCnt = 0;
+ MEIX_CNTRL_T *pMeiXCntrlList = (MEIX_CNTRL_T*)dev_id;
+@@ -1691,6 +1695,7 @@
+ static int __init MEI_module_init (void)
+ {
+ int result;
++ static struct class *dsl_class;
+
+ printk(KERN_INFO "%s" MEI_DRV_CRLF, &MEI_WHATVERSION[4]);
+ printk(KERN_INFO "(c) Copyright 2009, Infineon Technologies AG" MEI_DRV_CRLF);
+@@ -1730,6 +1735,8 @@
+ return (result);
+ }
+
++ dsl_class = class_create(THIS_MODULE, "ifx_mei");
++ device_create(dsl_class, NULL, MKDEV(MEI_MAJOR, 0), NULL, "ifx_mei");
+ return 0;
+ }
+
+Index: drv_mei_cpe-1.2.0/src/drv_mei_cpe_mei_access_vr9.c
+===================================================================
+--- drv_mei_cpe-1.2.0.orig/src/drv_mei_cpe_mei_access_vr9.c 2011-07-25 20:41:02.000000000 +0200
++++ drv_mei_cpe-1.2.0/src/drv_mei_cpe_mei_access_vr9.c 2012-11-28 15:14:10.433633419 +0100
+@@ -37,6 +37,7 @@
+
+ #include "cmv_message_format.h"
+
++#include <lantiq_soc.h>
+
+ /* ============================================================================
+ Local macro definition
+@@ -1527,32 +1528,35 @@
+ return IFX_ERROR;
+ }
+
++#define PMU_DFE BIT(9)
++
+ IFX_int32_t MEI_BasicChipInit(IFX_void_t)
+ {
+ /* Power up MEI */
+- DSL_DFE_PMU_SETUP(IFX_PMU_ENABLE);
+-
+- if (ifx_pmu_pg_dsl_dfe_enable() != 0)
++// DSL_DFE_PMU_SETUP(IFX_PMU_ENABLE);
++ltq_pmu_enable(PMU_DFE);
++ /* if (ifx_pmu_pg_dsl_dfe_enable() != 0)
+ {
+ PRN_ERR_USR_NL( MEI_MEI_ACCESS, MEI_DRV_PRN_LEVEL_ERR,
+ ("MEI: ERROR - DSL DFE PG enable failed!" MEI_DRV_CRLF));
+ return IFX_ERROR;
+- }
++ }*/
+
+ return IFX_SUCCESS;
+ }
+
+ IFX_int32_t MEI_BasicChipExit(IFX_void_t)
+ {
+- if (ifx_pmu_pg_dsl_dfe_disable() != 0)
++/* if (ifx_pmu_pg_dsl_dfe_disable() != 0)
+ {
+ PRN_ERR_USR_NL( MEI_MEI_ACCESS, MEI_DRV_PRN_LEVEL_ERR,
+ ("MEI: ERROR - DSL DFE PG disable failed!" MEI_DRV_CRLF));
+ return IFX_ERROR;
+ }
+-
++*/
+ /* Power down MEI */
+- DSL_DFE_PMU_SETUP(IFX_PMU_DISABLE);
++// DSL_DFE_PMU_SETUP(IFX_PMU_DISABLE);
++ltq_pmu_disable(PMU_DFE);
+
+ return IFX_SUCCESS;
+ }
diff --git a/package/platform/lantiq/ltq-vdsl-mei/patches/100-compat.patch b/package/platform/lantiq/ltq-vdsl-mei/patches/100-compat.patch
new file mode 100644
index 0000000..5822e74
--- /dev/null
+++ b/package/platform/lantiq/ltq-vdsl-mei/patches/100-compat.patch
@@ -0,0 +1,298 @@
+Index: drv_mei_cpe-1.2.0/src/drv_mei_cpe_common.c
+===================================================================
+--- drv_mei_cpe-1.2.0.orig/src/drv_mei_cpe_common.c 2011-10-26 00:49:51.000000000 +0200
++++ drv_mei_cpe-1.2.0/src/drv_mei_cpe_common.c 2012-11-28 15:14:10.421633418 +0100
+@@ -20,7 +20,6 @@
+ /* get at first the driver configuration */
+ #include "drv_mei_cpe_config.h"
+
+-#include "ifx_types.h"
+ #include "drv_mei_cpe_os.h"
+ #include "drv_mei_cpe_dbg.h"
+
+Index: drv_mei_cpe-1.2.0/configure.in
+===================================================================
+--- drv_mei_cpe-1.2.0.orig/configure.in 2012-01-20 17:41:07.000000000 +0100
++++ drv_mei_cpe-1.2.0/configure.in 2012-11-28 15:14:10.421633418 +0100
+@@ -140,7 +140,7 @@
+ AC_ARG_ENABLE(kernelbuild,
+ AC_HELP_STRING([--enable-kernelbuild=x],[Set the target kernel build path]),
+ [
+- if test -e $enableval/include/linux/autoconf.h; then
++ if test -e $enableval/include/generated/autoconf.h; then
+ AC_SUBST([KERNEL_BUILD_PATH],[$enableval])
+ else
+ AC_MSG_ERROR([The kernel build directory is not valid or not configured!])
+Index: drv_mei_cpe-1.2.0/configure
+===================================================================
+--- drv_mei_cpe-1.2.0.orig/configure 2012-01-20 17:50:02.000000000 +0100
++++ drv_mei_cpe-1.2.0/configure 2012-11-28 15:14:56.637634577 +0100
+@@ -617,6 +617,7 @@
+ am__fastdepCC_FALSE
+ am__fastdepCC_TRUE
+ CCDEPMODE
++am__nodep
+ AMDEPBACKSLASH
+ AMDEP_FALSE
+ AMDEP_TRUE
+@@ -2367,11 +2368,11 @@
+
+ # We need awk for the "check" target. The system "awk" is bad on
+ # some platforms.
+-# Always define AMTAR for backward compatibility.
++# Always define AMTAR for backward compatibility. Yes, it's still used
++# in the wild :-( We should find a proper way to deprecate it ...
++AMTAR='$${TAR-tar}'
+
+-AMTAR=${AMTAR-"${am_missing_run}tar"}
+-
+-am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'
++am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'
+
+
+
+@@ -3219,6 +3220,7 @@
+ if test "x$enable_dependency_tracking" != xno; then
+ am_depcomp="$ac_aux_dir/depcomp"
+ AMDEPBACKSLASH='\'
++ am__nodep='_no'
+ fi
+ if test "x$enable_dependency_tracking" != xno; then
+ AMDEP_TRUE=
+@@ -3243,6 +3245,7 @@
+ # instance it was reported that on HP-UX the gcc test will end up
+ # making a dummy file named `D' -- because `-MD' means `put the output
+ # in D'.
++ rm -rf conftest.dir
+ mkdir conftest.dir
+ # Copy depcomp to subdir because otherwise we won't find it if we're
+ # using a relative directory.
+@@ -3302,7 +3305,7 @@
+ break
+ fi
+ ;;
+- msvisualcpp | msvcmsys)
++ msvc7 | msvc7msys | msvisualcpp | msvcmsys)
+ # This compiler won't grok `-c -o', but also, the minuso test has
+ # not run yet. These depmodes are late enough in the game, and
+ # so weak that their functioning should not be impacted.
+@@ -3656,7 +3659,7 @@
+ # Check whether --enable-kernelbuild was given.
+ if test "${enable_kernelbuild+set}" = set; then :
+ enableval=$enable_kernelbuild;
+- if test -e $enableval/include/linux/autoconf.h; then
++ if test -e $enableval/include/generated/autoconf.h; then
+ KERNEL_BUILD_PATH=$enableval
+
+ else
+Index: drv_mei_cpe-1.2.0/src/drv_mei_cpe_linux.h
+===================================================================
+--- drv_mei_cpe-1.2.0.orig/src/drv_mei_cpe_linux.h 2011-07-25 20:41:02.000000000 +0200
++++ drv_mei_cpe-1.2.0/src/drv_mei_cpe_linux.h 2012-11-28 15:14:10.429633419 +0100
+@@ -34,8 +34,6 @@
+ #include <linux/sched.h>
+ #include <linux/interrupt.h>
+
+-#include <asm/ifx/irq.h>
+-
+ #if (MEI_DRV_IFXOS_ENABLE == 0)
+
+ #include <linux/version.h>
+@@ -44,8 +42,6 @@
+ #include <linux/poll.h>
+ #include <linux/types.h>
+
+-#include <asm/ifx/ifx_types.h>
+-
+ #endif /* #if (MEI_DRV_IFXOS_ENABLE == 0)*/
+
+ /* ============================================================================
+Index: drv_mei_cpe-1.2.0/src/drv_mei_cpe_mei_vr9.h
+===================================================================
+--- drv_mei_cpe-1.2.0.orig/src/drv_mei_cpe_mei_vr9.h 2011-07-25 20:41:02.000000000 +0200
++++ drv_mei_cpe-1.2.0/src/drv_mei_cpe_mei_vr9.h 2012-11-28 15:14:10.429633419 +0100
+@@ -40,12 +40,6 @@
+ #endif
+ #endif
+
+-#ifdef LINUX
+- #include <asm/ifx/ifx_pmu.h>
+-#else
+- #error "Please check PMU driver path!"
+-#endif
+-
+ /* ============================================================================
+ Module : RCU register address and bits
+ ========================================================================= */
+Index: drv_mei_cpe-1.2.0/src/drv_mei_cpe_api_atm_ptm_intern.c
+===================================================================
+--- drv_mei_cpe-1.2.0.orig/src/drv_mei_cpe_api_atm_ptm_intern.c 2011-07-25 20:41:02.000000000 +0200
++++ drv_mei_cpe-1.2.0/src/drv_mei_cpe_api_atm_ptm_intern.c 2012-11-28 15:14:10.429633419 +0100
+@@ -25,11 +25,7 @@
+ #include "ifx_types.h"
+ #include "drv_mei_cpe_os.h"
+
+-#ifdef LINUX
+- #include <asm/ifx/ifx_atm.h>
+-#else
+- #error "ATM/PTM internal interface is only supported for Linux!"
+-#endif
++#include <lantiq_atm.h>
+
+ /** get interface and configuration */
+ #include "drv_mei_cpe_interface.h"
+Index: drv_mei_cpe-1.2.0/src/drv_mei_cpe_linux.c
+===================================================================
+--- drv_mei_cpe-1.2.0.orig/src/drv_mei_cpe_linux.c 2011-07-25 20:41:02.000000000 +0200
++++ drv_mei_cpe-1.2.0/src/drv_mei_cpe_linux.c 2012-11-28 15:24:56.269649609 +0100
+@@ -32,11 +32,9 @@
+ #include <linux/module.h>
+ #include <linux/version.h>
+
+-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17))
+-#include <linux/utsrelease.h>
+-#endif
+-#include <linux/init.h>
++#include <generated/utsrelease.h>
+
++#include <linux/device.h>
+ #include <linux/ioport.h>
+ #include <linux/irq.h>
+ #include <asm/io.h>
+@@ -87,6 +85,8 @@
+ #include "drv_mei_cpe_device_cntrl.h"
+ #endif
+
++#define INT_NUM_IM4_IRL30 (INT_NUM_IM4_IRL0 + 30)
++
+ /* ===================================
+ extern function declarations
+ =================================== */
+@@ -122,7 +122,7 @@
+ size_t length,
+ loff_t * ppos);
+
+-static int MEI_Ioctl( struct inode *inode, struct file *filp,
++static long MEI_Ioctl(struct file *filp,
+ unsigned int nCmd, unsigned long nArgument);
+
+ static unsigned int MEI_Poll (struct file *filp, poll_table *table);
+@@ -137,7 +137,7 @@
+
+ static void MEI_IfxFreeIrq(unsigned int usedIrq, void *pUsedDevId);
+
+-static irqreturn_t MEI_InterruptLinux(int irq, void *dev_id, struct pt_regs *regs);
++static irqreturn_t MEI_InterruptLinux(int irq, void *dev_id);
+ #endif
+
+ #if CONFIG_PROC_FS
+@@ -194,7 +194,9 @@
+ /* =================================== */
+ /* Local variables (LINUX) */
+ /* =================================== */
+-static IFX_uint8_t major_number = 0;
++#define MEI_MAJOR 105
++
++static IFX_uint8_t major_number = MEI_MAJOR;
+ #ifdef MODULE
+ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
+ MODULE_PARM(major_number, "b");
+@@ -242,7 +244,7 @@
+ MEI_Write,
+ poll:
+ MEI_Poll,
+- ioctl:
++ unlocked_ioctl:
+ MEI_Ioctl,
+ open:
+ MEI_OpenOS,
+@@ -457,7 +459,7 @@
+ 0 and positive values - success,
+ negative value - ioctl failed
+ */
+-static int MEI_Ioctl( struct inode *inode, struct file *filp,
++static long MEI_Ioctl(struct file *filp,
+ unsigned int nCmd, unsigned long nArgument)
+ {
+ int ret = 0, retSize = sizeof(IOCTL_MEI_ioctl_t);
+@@ -1242,7 +1246,7 @@
+ \remark
+ None.
+ */
+-static irqreturn_t MEI_InterruptLinux(int irq, void *dev_id, struct pt_regs *regs)
++static irqreturn_t MEI_InterruptLinux(int irq, void *dev_id)
+ {
+ IFX_int32_t meiIntCnt = 0;
+ MEIX_CNTRL_T *pMeiXCntrlList = (MEIX_CNTRL_T*)dev_id;
+@@ -1691,6 +1695,7 @@
+ static int __init MEI_module_init (void)
+ {
+ int result;
++ static struct class *dsl_class;
+
+ printk(KERN_INFO "%s" MEI_DRV_CRLF, &MEI_WHATVERSION[4]);
+ printk(KERN_INFO "(c) Copyright 2009, Infineon Technologies AG" MEI_DRV_CRLF);
+@@ -1730,6 +1735,8 @@
+ return (result);
+ }
+
++ dsl_class = class_create(THIS_MODULE, "ifx_mei");
++ device_create(dsl_class, NULL, MKDEV(MEI_MAJOR, 0), NULL, "ifx_mei");
+ return 0;
+ }
+
+Index: drv_mei_cpe-1.2.0/src/drv_mei_cpe_mei_access_vr9.c
+===================================================================
+--- drv_mei_cpe-1.2.0.orig/src/drv_mei_cpe_mei_access_vr9.c 2011-07-25 20:41:02.000000000 +0200
++++ drv_mei_cpe-1.2.0/src/drv_mei_cpe_mei_access_vr9.c 2012-11-28 15:14:10.433633419 +0100
+@@ -37,6 +37,7 @@
+
+ #include "cmv_message_format.h"
+
++#include <lantiq_soc.h>
+
+ /* ============================================================================
+ Local macro definition
+@@ -1527,32 +1528,35 @@
+ return IFX_ERROR;
+ }
+
++#define PMU_DFE BIT(9)
++
+ IFX_int32_t MEI_BasicChipInit(IFX_void_t)
+ {
+ /* Power up MEI */
+- DSL_DFE_PMU_SETUP(IFX_PMU_ENABLE);
+-
+- if (ifx_pmu_pg_dsl_dfe_enable() != 0)
++// DSL_DFE_PMU_SETUP(IFX_PMU_ENABLE);
++ltq_pmu_enable(PMU_DFE);
++ /* if (ifx_pmu_pg_dsl_dfe_enable() != 0)
+ {
+ PRN_ERR_USR_NL( MEI_MEI_ACCESS, MEI_DRV_PRN_LEVEL_ERR,
+ ("MEI: ERROR - DSL DFE PG enable failed!" MEI_DRV_CRLF));
+ return IFX_ERROR;
+- }
++ }*/
+
+ return IFX_SUCCESS;
+ }
+
+ IFX_int32_t MEI_BasicChipExit(IFX_void_t)
+ {
+- if (ifx_pmu_pg_dsl_dfe_disable() != 0)
++/* if (ifx_pmu_pg_dsl_dfe_disable() != 0)
+ {
+ PRN_ERR_USR_NL( MEI_MEI_ACCESS, MEI_DRV_PRN_LEVEL_ERR,
+ ("MEI: ERROR - DSL DFE PG disable failed!" MEI_DRV_CRLF));
+ return IFX_ERROR;
+ }
+-
++*/
+ /* Power down MEI */
+- DSL_DFE_PMU_SETUP(IFX_PMU_DISABLE);
++// DSL_DFE_PMU_SETUP(IFX_PMU_DISABLE);
++ltq_pmu_disable(PMU_DFE);
+
+ return IFX_SUCCESS;
+ }
diff --git a/package/platform/lantiq/ltq-vdsl/.svn/entries b/package/platform/lantiq/ltq-vdsl/.svn/entries
new file mode 100644
index 0000000..c2dbfda
--- /dev/null
+++ b/package/platform/lantiq/ltq-vdsl/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/platform/lantiq/ltq-vdsl
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-14T18:43:18.200776Z
+36023
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+19effd8455837b3a7ba1f5825657f938
+2013-03-14T18:43:18.200776Z
+36023
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2061
+
diff --git a/package/platform/lantiq/ltq-vdsl/.svn/text-base/Makefile.svn-base b/package/platform/lantiq/ltq-vdsl/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..9f1e268
--- /dev/null
+++ b/package/platform/lantiq/ltq-vdsl/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,69 @@
+# Copyright (C) 2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=ltq-vdsl-vr9
+PKG_VERSION:=4.11.4
+PKG_RELEASE:=1
+
+PKG_BASE_NAME:=drv_dsl_cpe_api_vrx
+PKG_SOURCE:=$(PKG_BASE_NAME)-$(PKG_VERSION).tar.gz
+PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/drv_dsl_cpe_api-$(PKG_VERSION)
+PKG_SOURCE_URL:=http://mirror2.openwrt.org/sources/
+PKG_MD5SUM:=b6d9c1e3c5db1bfcd6e81bb2f582cadb
+
+PKG_MAINTAINER:=John Crispin <blogic@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/ltq-vdsl-vr9
+ TITLE:=vdsl driver
+ SECTION:=sys
+ SUBMENU:=Network Devices
+ DEPENDS:=@TARGET_lantiq_xway +kmod-ltq-vdsl-vr9-mei
+ FILES:=$(PKG_BUILD_DIR)/src/drv_dsl_cpe_api.ko
+ AUTOLOAD:=$(call AutoLoad,51,drv_dsl_cpe_api)
+endef
+
+define Package/ltq-vdsl-vr9/description
+ This package contains the Lantiq DSL CPE API driver.
+
+ Supported Devices:
+ - VRX200 Family
+endef
+
+EXTRA_CFLAGS = -fno-pic -mno-abicalls -mlong-calls -G 0
+
+CONFIGURE_ARGS += --enable-kernel-include="$(LINUX_DIR)/include" \
+ --with-max-device="1" \
+ --with-lines-per-device="1" \
+ --with-channels-per-line="1" \
+ --enable-vrx \
+ --enable-ifxos \
+ --enable-ifxos-include="-I$(STAGING_DIR)/usr/include/ifxos" \
+ --enable-driver-include="-I$(STAGING_DIR)/usr/include/vdsl" \
+ --enable-add-drv-cflags="-DMODULE -DINCLUDE_DSL_ATM_PTM_INTERFACE_SUPPORT -DDSL_DEBUG_DISABLE" \
+ --enable-adsl-led=no \
+ --enable-adsl-mib=no \
+ --enable-dsl-ceoc=no \
+ --enable-dsl-bonding=no \
+ --enable-linux-26 \
+ --enable-kernelbuild="$(LINUX_DIR)" \
+ KERNEL_ARCH=mips
+
+CONFIGURE_ARGS += --enable-model=full
+#CONFIGURE_ARGS += --enable-model=lite
+#CONFIGURE_ARGS += --enable-model=footprint
+#CONFIGURE_ARGS += --enable-model=typical
+#CONFIGURE_ARGS += --enable-model=debug
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include/drv_vdsl_cpe_api
+ $(CP) $(PKG_BUILD_DIR)/src/include/drv_dsl_cpe*.h $(1)/usr/include/drv_vdsl_cpe_api/
+endef
+
+$(eval $(call KernelPackage,ltq-vdsl-vr9))
diff --git a/package/platform/lantiq/ltq-vdsl/Makefile b/package/platform/lantiq/ltq-vdsl/Makefile
new file mode 100644
index 0000000..9f1e268
--- /dev/null
+++ b/package/platform/lantiq/ltq-vdsl/Makefile
@@ -0,0 +1,69 @@
+# Copyright (C) 2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=ltq-vdsl-vr9
+PKG_VERSION:=4.11.4
+PKG_RELEASE:=1
+
+PKG_BASE_NAME:=drv_dsl_cpe_api_vrx
+PKG_SOURCE:=$(PKG_BASE_NAME)-$(PKG_VERSION).tar.gz
+PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/drv_dsl_cpe_api-$(PKG_VERSION)
+PKG_SOURCE_URL:=http://mirror2.openwrt.org/sources/
+PKG_MD5SUM:=b6d9c1e3c5db1bfcd6e81bb2f582cadb
+
+PKG_MAINTAINER:=John Crispin <blogic@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/ltq-vdsl-vr9
+ TITLE:=vdsl driver
+ SECTION:=sys
+ SUBMENU:=Network Devices
+ DEPENDS:=@TARGET_lantiq_xway +kmod-ltq-vdsl-vr9-mei
+ FILES:=$(PKG_BUILD_DIR)/src/drv_dsl_cpe_api.ko
+ AUTOLOAD:=$(call AutoLoad,51,drv_dsl_cpe_api)
+endef
+
+define Package/ltq-vdsl-vr9/description
+ This package contains the Lantiq DSL CPE API driver.
+
+ Supported Devices:
+ - VRX200 Family
+endef
+
+EXTRA_CFLAGS = -fno-pic -mno-abicalls -mlong-calls -G 0
+
+CONFIGURE_ARGS += --enable-kernel-include="$(LINUX_DIR)/include" \
+ --with-max-device="1" \
+ --with-lines-per-device="1" \
+ --with-channels-per-line="1" \
+ --enable-vrx \
+ --enable-ifxos \
+ --enable-ifxos-include="-I$(STAGING_DIR)/usr/include/ifxos" \
+ --enable-driver-include="-I$(STAGING_DIR)/usr/include/vdsl" \
+ --enable-add-drv-cflags="-DMODULE -DINCLUDE_DSL_ATM_PTM_INTERFACE_SUPPORT -DDSL_DEBUG_DISABLE" \
+ --enable-adsl-led=no \
+ --enable-adsl-mib=no \
+ --enable-dsl-ceoc=no \
+ --enable-dsl-bonding=no \
+ --enable-linux-26 \
+ --enable-kernelbuild="$(LINUX_DIR)" \
+ KERNEL_ARCH=mips
+
+CONFIGURE_ARGS += --enable-model=full
+#CONFIGURE_ARGS += --enable-model=lite
+#CONFIGURE_ARGS += --enable-model=footprint
+#CONFIGURE_ARGS += --enable-model=typical
+#CONFIGURE_ARGS += --enable-model=debug
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include/drv_vdsl_cpe_api
+ $(CP) $(PKG_BUILD_DIR)/src/include/drv_dsl_cpe*.h $(1)/usr/include/drv_vdsl_cpe_api/
+endef
+
+$(eval $(call KernelPackage,ltq-vdsl-vr9))
diff --git a/package/platform/lantiq/ltq-vdsl/patches/.svn/entries b/package/platform/lantiq/ltq-vdsl/patches/.svn/entries
new file mode 100644
index 0000000..78cb904
--- /dev/null
+++ b/package/platform/lantiq/ltq-vdsl/patches/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/platform/lantiq/ltq-vdsl/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-14T18:43:18.200776Z
+36023
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+100-compat.patch
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+de283425f8ee6a54a1e959b2b342faae
+2013-03-14T18:43:18.200776Z
+36023
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4851
+
diff --git a/package/platform/lantiq/ltq-vdsl/patches/.svn/text-base/100-compat.patch.svn-base b/package/platform/lantiq/ltq-vdsl/patches/.svn/text-base/100-compat.patch.svn-base
new file mode 100644
index 0000000..5abe4b2
--- /dev/null
+++ b/package/platform/lantiq/ltq-vdsl/patches/.svn/text-base/100-compat.patch.svn-base
@@ -0,0 +1,148 @@
+Index: drv_dsl_cpe_api-4.11.4/src/include/drv_dsl_cpe_os_linux.h
+===================================================================
+--- drv_dsl_cpe_api-4.11.4.orig/src/include/drv_dsl_cpe_os_linux.h 2011-10-26 00:35:29.000000000 +0200
++++ drv_dsl_cpe_api-4.11.4/src/include/drv_dsl_cpe_os_linux.h 2012-11-28 23:05:38.766342592 +0100
+@@ -17,7 +17,7 @@
+ #endif
+
+ #include <asm/ioctl.h>
+-#include <linux/autoconf.h>
++#include <generated/autoconf.h>
+ #include <linux/module.h>
+ #include <linux/kernel.h>
+ #include <linux/init.h>
+@@ -28,7 +28,7 @@
+ #include <linux/sched.h>
+
+ #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17))
+- #include <linux/utsrelease.h>
++ #include <generated/utsrelease.h>
+ #endif
+
+ #include <linux/types.h>
+@@ -40,7 +40,6 @@
+ #include <linux/delay.h>
+ #include <linux/poll.h>
+ #include <asm/uaccess.h>
+-#include <linux/smp_lock.h>
+
+ #ifdef INCLUDE_DSL_CPE_API_IFXOS_SUPPORT
+ /** IFXOS includes*/
+Index: drv_dsl_cpe_api-4.11.4/src/Makefile.in
+===================================================================
+--- drv_dsl_cpe_api-4.11.4.orig/src/Makefile.in 2012-03-05 15:24:31.000000000 +0100
++++ drv_dsl_cpe_api-4.11.4/src/Makefile.in 2012-11-28 23:05:38.770342592 +0100
+@@ -72,7 +72,7 @@
+
+ # the headerfile of linux kernels 2.6.x contain to much arithmetic
+ # with void pointers (which is allowed for gcc!)
+-@KERNEL_2_6_FALSE@am__append_8 = -Wpointer-arith
++@KERNEL_2_6_FALSE@am__append_8 =
+ subdir = src
+ DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+Index: drv_dsl_cpe_api-4.11.4/src/common/drv_dsl_cpe_os_linux.c
+===================================================================
+--- drv_dsl_cpe_api-4.11.4.orig/src/common/drv_dsl_cpe_os_linux.c 2011-10-26 00:35:28.000000000 +0200
++++ drv_dsl_cpe_api-4.11.4/src/common/drv_dsl_cpe_os_linux.c 2012-11-28 23:05:38.770342592 +0100
+@@ -12,6 +12,7 @@
+
+ #define DSL_INTERN
+
++#include <linux/device.h>
+ #include "drv_dsl_cpe_api.h"
+ #include "drv_dsl_cpe_api_ioctl.h"
+
+@@ -34,7 +35,7 @@
+ static DSL_ssize_t DSL_DRV_Write(DSL_DRV_file_t *pFile, const DSL_char_t * pBuf,
+ DSL_DRV_size_t nSize, DSL_DRV_offset_t * pLoff);
+
+-static DSL_int_t DSL_DRV_Ioctls(DSL_DRV_inode_t * pINode, DSL_DRV_file_t * pFile,
++static long DSL_DRV_Ioctls(DSL_DRV_file_t * pFile,
+ DSL_uint_t nCommand, unsigned long nArg);
+
+ static int DSL_DRV_Open(DSL_DRV_inode_t * ino, DSL_DRV_file_t * fil);
+@@ -71,7 +72,7 @@
+ open: DSL_DRV_Open,
+ release: DSL_DRV_Release,
+ write: DSL_DRV_Write,
+- ioctl: DSL_DRV_Ioctls,
++ unlocked_ioctl: DSL_DRV_Ioctls,
+ poll: DSL_DRV_Poll
+ };
+ #else
+@@ -172,7 +173,7 @@
+ \return Success or failure.
+ \ingroup Internal
+ */
+-static DSL_int_t DSL_DRV_Ioctls(DSL_DRV_inode_t * pINode,
++static long DSL_DRV_Ioctls(
+ DSL_DRV_file_t * pFile,
+ DSL_uint_t nCommand,
+ unsigned long nArg)
+@@ -222,14 +223,7 @@
+ }
+ }
+
+- if (pINode == DSL_NULL)
+- {
+- bIsInKernel = DSL_TRUE;
+- }
+- else
+- {
+ bIsInKernel = DSL_FALSE;
+- }
+
+ if ( (_IOC_TYPE(nCommand) == DSL_IOC_MAGIC_CPE_API) ||
+ (_IOC_TYPE(nCommand) == DSL_IOC_MAGIC_CPE_API_G997) ||
+@@ -1082,6 +1076,7 @@
+ int __init DSL_ModuleInit(void)
+ {
+ DSL_int_t i;
++ static struct class *dsl_class;
+
+ printk(DSL_DRV_CRLF DSL_DRV_CRLF "Lantiq CPE API Driver version: %s" DSL_DRV_CRLF,
+ &(dsl_cpe_api_version[4]));
+@@ -1127,6 +1122,10 @@
+
+ DSL_DRV_DevNodeInit();
+
++ dsl_class = class_create(THIS_MODULE, "dsl_cpe_api0");
++ device_create(dsl_class, NULL, MKDEV(DRV_DSL_CPE_API_DEV_MAJOR, 0), NULL, "dsl_cpe_api0");
++
++
+ return 0;
+ }
+
+Index: drv_dsl_cpe_api-4.11.4/src/device/drv_dsl_cpe_msg_vrx.c
+===================================================================
+--- drv_dsl_cpe_api-4.11.4.orig/src/device/drv_dsl_cpe_msg_vrx.c 2012-03-05 11:25:21.000000000 +0100
++++ drv_dsl_cpe_api-4.11.4/src/device/drv_dsl_cpe_msg_vrx.c 2012-11-28 23:06:46.418344288 +0100
+@@ -685,6 +685,7 @@
+ DSL_ProfileType_t nProfile = DSL_PROFILE_LAST;
+ DSL_G997_XTUSystemEnablingData_t data = {{0,0,0,0,0,0,0,0}};
+
++ //printk("%s:%s[%d]\n", __FILE__, __func__, __LINE__);
+ DSL_DEBUG( DSL_DBG_MSG,
+ (pContext, SYS_DBG_MSG"DSL[%02d]: IN - DSL_DRV_VXX_SendMsgSelectedProfileVdsl2Get"
+ DSL_DRV_CRLF, DSL_DEV_NUM(pContext)));
+@@ -985,8 +988,10 @@
+
+ /* Check consistency of XTSE status setting - Only one bit should be set at
+ a time */
++ //printk("XTSE (%d) - ", DSL_G997_NUM_XTSE_OCTETS);
+ for (i = 0, nBitCount = 0; i < DSL_G997_NUM_XTSE_OCTETS; i++)
+ {
++ //printk("%02X ", data.XTSE[i]);
+ for (j = 0; j < 8; j++)
+ {
+ if ( ((data.XTSE[i] >> j) & 0x01) != 0)
+@@ -996,6 +1001,8 @@
+ }
+ }
+
++ //printk("\n");
++
+ if (nBitCount > 1)
+ {
+ DSL_DEBUG( DSL_DBG_ERR,
diff --git a/package/platform/lantiq/ltq-vdsl/patches/100-compat.patch b/package/platform/lantiq/ltq-vdsl/patches/100-compat.patch
new file mode 100644
index 0000000..5abe4b2
--- /dev/null
+++ b/package/platform/lantiq/ltq-vdsl/patches/100-compat.patch
@@ -0,0 +1,148 @@
+Index: drv_dsl_cpe_api-4.11.4/src/include/drv_dsl_cpe_os_linux.h
+===================================================================
+--- drv_dsl_cpe_api-4.11.4.orig/src/include/drv_dsl_cpe_os_linux.h 2011-10-26 00:35:29.000000000 +0200
++++ drv_dsl_cpe_api-4.11.4/src/include/drv_dsl_cpe_os_linux.h 2012-11-28 23:05:38.766342592 +0100
+@@ -17,7 +17,7 @@
+ #endif
+
+ #include <asm/ioctl.h>
+-#include <linux/autoconf.h>
++#include <generated/autoconf.h>
+ #include <linux/module.h>
+ #include <linux/kernel.h>
+ #include <linux/init.h>
+@@ -28,7 +28,7 @@
+ #include <linux/sched.h>
+
+ #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17))
+- #include <linux/utsrelease.h>
++ #include <generated/utsrelease.h>
+ #endif
+
+ #include <linux/types.h>
+@@ -40,7 +40,6 @@
+ #include <linux/delay.h>
+ #include <linux/poll.h>
+ #include <asm/uaccess.h>
+-#include <linux/smp_lock.h>
+
+ #ifdef INCLUDE_DSL_CPE_API_IFXOS_SUPPORT
+ /** IFXOS includes*/
+Index: drv_dsl_cpe_api-4.11.4/src/Makefile.in
+===================================================================
+--- drv_dsl_cpe_api-4.11.4.orig/src/Makefile.in 2012-03-05 15:24:31.000000000 +0100
++++ drv_dsl_cpe_api-4.11.4/src/Makefile.in 2012-11-28 23:05:38.770342592 +0100
+@@ -72,7 +72,7 @@
+
+ # the headerfile of linux kernels 2.6.x contain to much arithmetic
+ # with void pointers (which is allowed for gcc!)
+-@KERNEL_2_6_FALSE@am__append_8 = -Wpointer-arith
++@KERNEL_2_6_FALSE@am__append_8 =
+ subdir = src
+ DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+Index: drv_dsl_cpe_api-4.11.4/src/common/drv_dsl_cpe_os_linux.c
+===================================================================
+--- drv_dsl_cpe_api-4.11.4.orig/src/common/drv_dsl_cpe_os_linux.c 2011-10-26 00:35:28.000000000 +0200
++++ drv_dsl_cpe_api-4.11.4/src/common/drv_dsl_cpe_os_linux.c 2012-11-28 23:05:38.770342592 +0100
+@@ -12,6 +12,7 @@
+
+ #define DSL_INTERN
+
++#include <linux/device.h>
+ #include "drv_dsl_cpe_api.h"
+ #include "drv_dsl_cpe_api_ioctl.h"
+
+@@ -34,7 +35,7 @@
+ static DSL_ssize_t DSL_DRV_Write(DSL_DRV_file_t *pFile, const DSL_char_t * pBuf,
+ DSL_DRV_size_t nSize, DSL_DRV_offset_t * pLoff);
+
+-static DSL_int_t DSL_DRV_Ioctls(DSL_DRV_inode_t * pINode, DSL_DRV_file_t * pFile,
++static long DSL_DRV_Ioctls(DSL_DRV_file_t * pFile,
+ DSL_uint_t nCommand, unsigned long nArg);
+
+ static int DSL_DRV_Open(DSL_DRV_inode_t * ino, DSL_DRV_file_t * fil);
+@@ -71,7 +72,7 @@
+ open: DSL_DRV_Open,
+ release: DSL_DRV_Release,
+ write: DSL_DRV_Write,
+- ioctl: DSL_DRV_Ioctls,
++ unlocked_ioctl: DSL_DRV_Ioctls,
+ poll: DSL_DRV_Poll
+ };
+ #else
+@@ -172,7 +173,7 @@
+ \return Success or failure.
+ \ingroup Internal
+ */
+-static DSL_int_t DSL_DRV_Ioctls(DSL_DRV_inode_t * pINode,
++static long DSL_DRV_Ioctls(
+ DSL_DRV_file_t * pFile,
+ DSL_uint_t nCommand,
+ unsigned long nArg)
+@@ -222,14 +223,7 @@
+ }
+ }
+
+- if (pINode == DSL_NULL)
+- {
+- bIsInKernel = DSL_TRUE;
+- }
+- else
+- {
+ bIsInKernel = DSL_FALSE;
+- }
+
+ if ( (_IOC_TYPE(nCommand) == DSL_IOC_MAGIC_CPE_API) ||
+ (_IOC_TYPE(nCommand) == DSL_IOC_MAGIC_CPE_API_G997) ||
+@@ -1082,6 +1076,7 @@
+ int __init DSL_ModuleInit(void)
+ {
+ DSL_int_t i;
++ static struct class *dsl_class;
+
+ printk(DSL_DRV_CRLF DSL_DRV_CRLF "Lantiq CPE API Driver version: %s" DSL_DRV_CRLF,
+ &(dsl_cpe_api_version[4]));
+@@ -1127,6 +1122,10 @@
+
+ DSL_DRV_DevNodeInit();
+
++ dsl_class = class_create(THIS_MODULE, "dsl_cpe_api0");
++ device_create(dsl_class, NULL, MKDEV(DRV_DSL_CPE_API_DEV_MAJOR, 0), NULL, "dsl_cpe_api0");
++
++
+ return 0;
+ }
+
+Index: drv_dsl_cpe_api-4.11.4/src/device/drv_dsl_cpe_msg_vrx.c
+===================================================================
+--- drv_dsl_cpe_api-4.11.4.orig/src/device/drv_dsl_cpe_msg_vrx.c 2012-03-05 11:25:21.000000000 +0100
++++ drv_dsl_cpe_api-4.11.4/src/device/drv_dsl_cpe_msg_vrx.c 2012-11-28 23:06:46.418344288 +0100
+@@ -685,6 +685,7 @@
+ DSL_ProfileType_t nProfile = DSL_PROFILE_LAST;
+ DSL_G997_XTUSystemEnablingData_t data = {{0,0,0,0,0,0,0,0}};
+
++ //printk("%s:%s[%d]\n", __FILE__, __func__, __LINE__);
+ DSL_DEBUG( DSL_DBG_MSG,
+ (pContext, SYS_DBG_MSG"DSL[%02d]: IN - DSL_DRV_VXX_SendMsgSelectedProfileVdsl2Get"
+ DSL_DRV_CRLF, DSL_DEV_NUM(pContext)));
+@@ -985,8 +988,10 @@
+
+ /* Check consistency of XTSE status setting - Only one bit should be set at
+ a time */
++ //printk("XTSE (%d) - ", DSL_G997_NUM_XTSE_OCTETS);
+ for (i = 0, nBitCount = 0; i < DSL_G997_NUM_XTSE_OCTETS; i++)
+ {
++ //printk("%02X ", data.XTSE[i]);
+ for (j = 0; j < 8; j++)
+ {
+ if ( ((data.XTSE[i] >> j) & 0x01) != 0)
+@@ -996,6 +1001,8 @@
+ }
+ }
+
++ //printk("\n");
++
+ if (nBitCount > 1)
+ {
+ DSL_DEBUG( DSL_DBG_ERR,
diff --git a/package/platform/lantiq/ltq-vmmc/.svn/entries b/package/platform/lantiq/ltq-vmmc/.svn/entries
new file mode 100644
index 0000000..285f17e
--- /dev/null
+++ b/package/platform/lantiq/ltq-vmmc/.svn/entries
@@ -0,0 +1,102 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/platform/lantiq/ltq-vmmc
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-12-15T02:00:45.545494Z
+34695
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+files
+dir
+
+patches
+dir
+
+Config.in
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+7b9fa0d4f09904dfbb5a1a4ce9db833d
+2012-12-15T02:00:45.545494Z
+34695
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2865
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+3294de36a2d1b8df9c59f56c7b534e7f
+2012-12-15T02:00:45.545494Z
+34695
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5112
+
diff --git a/package/platform/lantiq/ltq-vmmc/.svn/text-base/Config.in.svn-base b/package/platform/lantiq/ltq-vmmc/.svn/text-base/Config.in.svn-base
new file mode 100644
index 0000000..89e1bc5
--- /dev/null
+++ b/package/platform/lantiq/ltq-vmmc/.svn/text-base/Config.in.svn-base
@@ -0,0 +1,95 @@
+choice
+ prompt "device selection"
+ depends on PACKAGE_kmod-ltq-vmmc
+ default VOICE_CPE_VMMC_WITH_DEVICE_DANUBE
+ help
+ Select the target device.
+
+ config VOICE_CPE_VMMC_WITH_DEVICE_DANUBE
+ bool "Danube, Twinpass, Vinax"
+ depends on TARGET_lantiq_xway
+
+# config VOICE_CPE_VMMC_WITH_DEVICE_AR9
+# bool "AR9 family"
+# depends on TARGET_lantiq_ar9
+
+# config VOICE_CPE_VMMC_WITH_DEVICE_VR9
+# bool "VR9 family"
+# depends on TARGET_lantiq_vr9
+#
+ config VOICE_VMMC_WITH_DEVICE_FALCON
+ bool "FALC-ON"
+ depends on (TARGET_lantiq_falcon||TARGET_lantiq_falcon_stable)
+
+endchoice
+
+choice
+ depends on PACKAGE_kmod-ltq-vmmc
+ prompt "FXS coefficients"
+ default LTQ_VOICE_CPE_VMMC_COEF_FALCON_ETSI
+ help
+ Select country specific FXS coefficient file.
+
+ config LTQ_VOICE_CPE_VMMC_COEF_FALCON_ETSI
+ bool "ETSI_T3R10: Vl:40V, Ic:25mA, Vid:25V, Vri:45Vrms, f:25Hz"
+ help
+ These coefficents contains a parameter set with line impedance Zr according to ETSI.
+
+ T: gain in transmit direction (attenuation 3dBr) [dBr]
+ R: gain in receive direction (attenuation 10dBr) [dBr]
+ Vl: on-hook voltage limit [V]
+ Ic: off-hook loop current [mA]
+ Vid: low-power-standby voltage [V]
+ Vri: ring voltage [v]
+ f: ring frequency [V]
+
+ config LTQ_VOICE_CPE_VMMC_COEF_FALCON_US600R
+ bool "USA_600R_T3R10: Vl:40V, Ic:25mA, Vid:25V, Vri:45V, f:20Hz"
+ help
+ These coefficents contains a parameter set with line impedance e.g. for USA.
+
+ T: gain in transmit direction (attenuation 3dBr) [dBr]
+ R: gain in receive direction (attenuation 10dBr) [dBr]
+ Vl: on-hook voltage limit [V]
+ Ic: off-hook loop current [mA]
+ Vid: low-power-standby voltage [V]
+ Vri: ring voltage [v]
+ f: ring frequency [V]
+
+ config LTQ_VOICE_CPE_VMMC_COEF_FALCON_USE_CUSTOM_FILE
+ bool "Select own FXS coefficient file"
+endchoice
+
+config VOICE_CPE_VMMC_PMC
+ depends on (VOICE_CPE_VMMC_WITH_DEVICE_AR9 || VOICE_CPE_VMMC_WITH_DEVICE_VR9)
+ bool "Power Management Control support"
+ default n
+ help
+ Option to enable Power Management Control on AR9, VR9. Not supported for Danube.
+
+config VOICE_CPE_VMMC_DISABLE_DECT_NIBBLE_SWAP
+ bool "Disable DECT nibble swap"
+ depends on PACKAGE_kmod-ltq-vmmc
+ default n
+ help
+ Option to disable DECT nibble swap for COSIC modem (for backward compatibility only).
+
+config VOICE_CPE_VMMC_EVENT_LOGGER
+ depends on BROKEN
+ bool "Event logger support"
+ depends on PACKAGE_kmod-ltq-vmmc
+ default n
+ help
+ Option to enable details traces between drv_vmmc and the voice FW
+ - for debugging only
+ - requires package ifx-evtlog
+
+config VOICE_CPE_VMMC_MPS_HISTORY_SIZE
+ int "MPS history buffer in words (0<=size<=512)"
+ depends on PACKAGE_kmod-ltq-vmmc
+ default "128"
+ help
+ MPS history buffer (default=128 words, maximum=512 words, 0=disable)
+ To opimize the memory footprint in RAM, you might want to set the
+ buffer size to 0.
+
diff --git a/package/platform/lantiq/ltq-vmmc/.svn/text-base/Makefile.svn-base b/package/platform/lantiq/ltq-vmmc/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..98355b1
--- /dev/null
+++ b/package/platform/lantiq/ltq-vmmc/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,166 @@
+#
+# Copyright (C) 2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=drv_vmmc
+PKG_VERSION:=1.9.0
+PKG_RELEASE:=2
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_MD5SUM:=d8eee8cba0edb28974cc1f8532e3bd18
+PKG_SOURCE_URL:=http://mirror2.openwrt.org/sources
+PKG_MAINTAINER:=John Crispin <blogic@openwrt.org>
+
+include $(INCLUDE_DIR)/ltqtapi.mk
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/ltq-vmmc
+ SUBMENU:=Voice over IP
+ TITLE:=TAPI LL driver for Voice Macro
+ URL:=http://www.lantiq.com/
+ DEPENDS:=$(LTQ_TAPI_TARGET) +kmod-ltq-tapi
+ FILES:=$(PKG_BUILD_DIR)/src/drv_vmmc.ko
+ AUTOLOAD:=$(call AutoLoad,25,drv_vmmc)
+endef
+
+define KernelPackage/ltq-vmmc/description
+ Voice Subsystem Low Level Driver for Danube, AR9, VR9 device families
+endef
+
+define KernelPackage/ltq-vmmc/config
+ source "$(SOURCE)/Config.in"
+endef
+
+CONFIGURE_ARGS += \
+ ARCH=$(LINUX_KARCH) \
+ --enable-linux-26 \
+ --enable-kernelbuild="$(LINUX_DIR)" \
+ --enable-kernelincl="$(LINUX_DIR)/include" \
+ --enable-tapiincl="$(STAGING_DIR)/usr/include/drv_tapi" \
+ --with-ifxos-incl=$(STAGING_DIR)/usr/include/ifxos \
+ $(call autoconf_bool,CONFIG_VOICE_CPE_VMMC_EVENT_LOGGER,el-debug) \
+ $(call autoconf_bool,CONFIG_VOICE_CPE_VMMC_PMC,pmc) \
+ $(call autoconf_bool,CONFIG_VOICE_CPE_VMMC_DISABLE_DECT_NIBBLE_SWAP,dect-nibble-swap) \
+ $(call autoconf_bool,CONFIG_VOICE_CPE_TAPI_FAX,fax t38) \
+ $(call autoconf_bool,CONFIG_VOICE_CPE_TAPI_CID,cid) \
+ $(call autoconf_bool,CONFIG_VOICE_CPE_TAPI_DECT,dect) \
+ $(call autoconf_bool,CONFIG_VOICE_CPE_TAPI_KPI,kpi) \
+ $(call autoconf_bool,CONFIG_VOICE_CPE_TAPI_LT_GR909,lt calibration) \
+ $(call autoconf_bool,CONFIG_VOICE_CPE_TAPI_HDLC,hdlc) \
+ $(call autoconf_bool,CONFIG_VOICE_CPE_TAPI_TRACES,trace)
+
+ifneq ($(CONFIG_VOICE_CPE_VMMC_MPS_HISTORY_SIZE),128)
+ CONFIGURE_ARGS += --enable-history-buf=$(CONFIG_VOICE_CPE_VMMC_MPS_HISTORY_SIZE)
+endif
+
+#defaults
+FW_URL:=http://localhost/
+FW_TARGET:=ifx_firmware.bin
+FW_FILE:=fw_voip_ifx.tar.gz
+COEF_TARGET:=ifx_bbd_fxs.bin
+COEF_FILE:=coef_voip_ifx.tar.gz
+
+FW_DIR:=lib/firmware
+
+FW_TARGET_GENERIC:=$(FW_TARGET)
+COEF_TARGET_GENERIC:=$(COEF_TARGET)
+
+ifeq ($(CONFIG_VOICE_CPE_VMMC_WITH_DEVICE_DANUBE)$(CONFIG_LTQ_VOICE_CPE_VMMC_WITH_DEVICE_DANUBE),y)
+ CONFIGURE_ARGS += --with-device=DANUBE
+ FW_SOURCE:=voip_R12.1.0.1.0-enc.bin
+ FW_TARGET:=danube_firmware.bin
+ FW_FILE=fw_voip_danube-12.1.0.1.0.tar.gz
+ FW_MD5SUM:=51868b88dee9dbc65d3dbba355ded91c
+ FW_DOWNLOAD:=1
+ COEF_SRC:=danube_bbd_fxs.bin
+ COEF_TARGET:=danube_bbd_fxs.bin
+ COEF_FILE:=coef_voip_danube-0.9.0.tar.gz
+ COEF_MD5SUM:=c8ac6592b304b03829a8123560e15710
+ COEF_DOWNLOAD:=1
+endif
+
+ifeq ($(CONFIG_VOICE_CPE_VMMC_WITH_DEVICE_AR9),y)
+ CONFIGURE_ARGS += --with-device=AR9
+ # TODO: add fw/coef
+endif
+
+COEF_SRC:=$(COEF_TARGET)
+
+ifeq ($(CONFIG_VOICE_VMMC_WITH_DEVICE_FALCON),y)
+ CONFIGURE_ARGS += --with-device=FALCON
+ FW_SOURCE:=voip_R1.1.0.6.0-enc.bin
+ FW_MD5SUM:=cd4366a52a8010b76793e3810a4f14b3
+ FW_TARGET:=falcon_voip_fw.bin
+ FW_FILE=fw_voip_falcon-1.1.0.6.0.tar.gz
+ FW_DOWNLOAD:=1
+ COEF_TARGET:=falcon_bbd.bin
+# FXS part
+ifeq ($(CONFIG_LTQ_VOICE_CPE_VMMC_COEF_FALCON_ETSI),y)
+ COEF_SRC:=ETSI_3_10.BIN
+endif
+ifeq ($(CONFIG_LTQ_VOICE_CPE_VMMC_COEF_FALCON_US600R),y)
+ COEF_SRC:=R600_3_10.BIN
+endif
+ifeq ($(CONFIG_LTQ_VOICE_CPE_VMMC_COEF_FALCON_USE_CUSTOM_FILE),y)
+ COEF_SRC:=$(CONFIG_LTQ_VOICE_CPE_VMMC_COEF_FALCON_CUSTOM_FILE)
+endif
+ COEF_FILE:=coef_voip_falcon.tar.gz
+ COEF_MD5SUM:=56c5a838f2bb9bd87d0e8dce271f810b
+ COEF_DOWNLOAD:=1
+endif
+
+ifeq ($(CONFIG_VOICE_CPE_VMMC_WITH_DEVICE_VR9),y)
+ CONFIGURE_ARGS += --with-device=VR9
+ # TODO: add fw/coef
+endif
+
+define Download/firmware
+ FILE:=$(FW_FILE)
+ URL:=$(FW_URL)
+ MD5SUM:=$(FW_MD5SUM)
+endef
+$(eval $(if $(FW_DOWNLOAD),$(call Download,firmware)))
+
+define Download/coef
+ FILE:=$(COEF_FILE)
+ URL:=$(FW_URL)
+ MD5SUM:=$(COEF_MD5SUM)
+endef
+$(eval $(if $(COEF_DOWNLOAD),$(call Download,coef)))
+
+define Build/Configure
+ rm -rf \
+ $(PKG_BUILD_DIR)/coef \
+ $(PKG_BUILD_DIR)/firmware
+ mkdir -p \
+ $(PKG_BUILD_DIR)/coef \
+ $(PKG_BUILD_DIR)/firmware
+ $(TAR) -C $(PKG_BUILD_DIR)/firmware -xvzf $(DL_DIR)/$(FW_FILE)
+ $(TAR) -C $(PKG_BUILD_DIR)/coef -xvzf $(DL_DIR)/$(COEF_FILE)
+ (cd $(PKG_BUILD_DIR); aclocal && autoconf && automake)
+ $(call Build/Configure/Default)
+endef
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include
+ mkdir -p $(1)/usr/include/drv_vmmc
+ $(CP) -v --dereference $(PKG_BUILD_DIR)/include/* $(1)/usr/include/drv_vmmc
+ (cd $(1)/usr/include/drv_vmmc && ln -snf . include)
+endef
+
+define KernelPackage/ltq-vmmc/install
+ $(INSTALL_DIR) $(1)/etc/init.d $(1)/$(FW_DIR)
+ $(INSTALL_BIN) ./files/vmmc.init $(1)/etc/init.d/vmmc
+ $(CP) $(PKG_BUILD_DIR)/firmware/$(FW_SOURCE) $(1)/$(FW_DIR)/$(FW_TARGET)
+ ln -s /$(FW_DIR)/$(FW_TARGET) $(1)/$(FW_DIR)/$(FW_TARGET_GENERIC)
+ $(CP) $(PKG_BUILD_DIR)/coef/$(COEF_SRC) $(1)/$(FW_DIR)/$(COEF_TARGET)
+ ln -s /$(FW_DIR)/$(COEF_TARGET) $(1)/$(FW_DIR)/$(COEF_TARGET_GENERIC)
+endef
+
+$(eval $(call KernelPackage,ltq-vmmc))
diff --git a/package/platform/lantiq/ltq-vmmc/Config.in b/package/platform/lantiq/ltq-vmmc/Config.in
new file mode 100644
index 0000000..89e1bc5
--- /dev/null
+++ b/package/platform/lantiq/ltq-vmmc/Config.in
@@ -0,0 +1,95 @@
+choice
+ prompt "device selection"
+ depends on PACKAGE_kmod-ltq-vmmc
+ default VOICE_CPE_VMMC_WITH_DEVICE_DANUBE
+ help
+ Select the target device.
+
+ config VOICE_CPE_VMMC_WITH_DEVICE_DANUBE
+ bool "Danube, Twinpass, Vinax"
+ depends on TARGET_lantiq_xway
+
+# config VOICE_CPE_VMMC_WITH_DEVICE_AR9
+# bool "AR9 family"
+# depends on TARGET_lantiq_ar9
+
+# config VOICE_CPE_VMMC_WITH_DEVICE_VR9
+# bool "VR9 family"
+# depends on TARGET_lantiq_vr9
+#
+ config VOICE_VMMC_WITH_DEVICE_FALCON
+ bool "FALC-ON"
+ depends on (TARGET_lantiq_falcon||TARGET_lantiq_falcon_stable)
+
+endchoice
+
+choice
+ depends on PACKAGE_kmod-ltq-vmmc
+ prompt "FXS coefficients"
+ default LTQ_VOICE_CPE_VMMC_COEF_FALCON_ETSI
+ help
+ Select country specific FXS coefficient file.
+
+ config LTQ_VOICE_CPE_VMMC_COEF_FALCON_ETSI
+ bool "ETSI_T3R10: Vl:40V, Ic:25mA, Vid:25V, Vri:45Vrms, f:25Hz"
+ help
+ These coefficents contains a parameter set with line impedance Zr according to ETSI.
+
+ T: gain in transmit direction (attenuation 3dBr) [dBr]
+ R: gain in receive direction (attenuation 10dBr) [dBr]
+ Vl: on-hook voltage limit [V]
+ Ic: off-hook loop current [mA]
+ Vid: low-power-standby voltage [V]
+ Vri: ring voltage [v]
+ f: ring frequency [V]
+
+ config LTQ_VOICE_CPE_VMMC_COEF_FALCON_US600R
+ bool "USA_600R_T3R10: Vl:40V, Ic:25mA, Vid:25V, Vri:45V, f:20Hz"
+ help
+ These coefficents contains a parameter set with line impedance e.g. for USA.
+
+ T: gain in transmit direction (attenuation 3dBr) [dBr]
+ R: gain in receive direction (attenuation 10dBr) [dBr]
+ Vl: on-hook voltage limit [V]
+ Ic: off-hook loop current [mA]
+ Vid: low-power-standby voltage [V]
+ Vri: ring voltage [v]
+ f: ring frequency [V]
+
+ config LTQ_VOICE_CPE_VMMC_COEF_FALCON_USE_CUSTOM_FILE
+ bool "Select own FXS coefficient file"
+endchoice
+
+config VOICE_CPE_VMMC_PMC
+ depends on (VOICE_CPE_VMMC_WITH_DEVICE_AR9 || VOICE_CPE_VMMC_WITH_DEVICE_VR9)
+ bool "Power Management Control support"
+ default n
+ help
+ Option to enable Power Management Control on AR9, VR9. Not supported for Danube.
+
+config VOICE_CPE_VMMC_DISABLE_DECT_NIBBLE_SWAP
+ bool "Disable DECT nibble swap"
+ depends on PACKAGE_kmod-ltq-vmmc
+ default n
+ help
+ Option to disable DECT nibble swap for COSIC modem (for backward compatibility only).
+
+config VOICE_CPE_VMMC_EVENT_LOGGER
+ depends on BROKEN
+ bool "Event logger support"
+ depends on PACKAGE_kmod-ltq-vmmc
+ default n
+ help
+ Option to enable details traces between drv_vmmc and the voice FW
+ - for debugging only
+ - requires package ifx-evtlog
+
+config VOICE_CPE_VMMC_MPS_HISTORY_SIZE
+ int "MPS history buffer in words (0<=size<=512)"
+ depends on PACKAGE_kmod-ltq-vmmc
+ default "128"
+ help
+ MPS history buffer (default=128 words, maximum=512 words, 0=disable)
+ To opimize the memory footprint in RAM, you might want to set the
+ buffer size to 0.
+
diff --git a/package/platform/lantiq/ltq-vmmc/Makefile b/package/platform/lantiq/ltq-vmmc/Makefile
new file mode 100644
index 0000000..98355b1
--- /dev/null
+++ b/package/platform/lantiq/ltq-vmmc/Makefile
@@ -0,0 +1,166 @@
+#
+# Copyright (C) 2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=drv_vmmc
+PKG_VERSION:=1.9.0
+PKG_RELEASE:=2
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_MD5SUM:=d8eee8cba0edb28974cc1f8532e3bd18
+PKG_SOURCE_URL:=http://mirror2.openwrt.org/sources
+PKG_MAINTAINER:=John Crispin <blogic@openwrt.org>
+
+include $(INCLUDE_DIR)/ltqtapi.mk
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/ltq-vmmc
+ SUBMENU:=Voice over IP
+ TITLE:=TAPI LL driver for Voice Macro
+ URL:=http://www.lantiq.com/
+ DEPENDS:=$(LTQ_TAPI_TARGET) +kmod-ltq-tapi
+ FILES:=$(PKG_BUILD_DIR)/src/drv_vmmc.ko
+ AUTOLOAD:=$(call AutoLoad,25,drv_vmmc)
+endef
+
+define KernelPackage/ltq-vmmc/description
+ Voice Subsystem Low Level Driver for Danube, AR9, VR9 device families
+endef
+
+define KernelPackage/ltq-vmmc/config
+ source "$(SOURCE)/Config.in"
+endef
+
+CONFIGURE_ARGS += \
+ ARCH=$(LINUX_KARCH) \
+ --enable-linux-26 \
+ --enable-kernelbuild="$(LINUX_DIR)" \
+ --enable-kernelincl="$(LINUX_DIR)/include" \
+ --enable-tapiincl="$(STAGING_DIR)/usr/include/drv_tapi" \
+ --with-ifxos-incl=$(STAGING_DIR)/usr/include/ifxos \
+ $(call autoconf_bool,CONFIG_VOICE_CPE_VMMC_EVENT_LOGGER,el-debug) \
+ $(call autoconf_bool,CONFIG_VOICE_CPE_VMMC_PMC,pmc) \
+ $(call autoconf_bool,CONFIG_VOICE_CPE_VMMC_DISABLE_DECT_NIBBLE_SWAP,dect-nibble-swap) \
+ $(call autoconf_bool,CONFIG_VOICE_CPE_TAPI_FAX,fax t38) \
+ $(call autoconf_bool,CONFIG_VOICE_CPE_TAPI_CID,cid) \
+ $(call autoconf_bool,CONFIG_VOICE_CPE_TAPI_DECT,dect) \
+ $(call autoconf_bool,CONFIG_VOICE_CPE_TAPI_KPI,kpi) \
+ $(call autoconf_bool,CONFIG_VOICE_CPE_TAPI_LT_GR909,lt calibration) \
+ $(call autoconf_bool,CONFIG_VOICE_CPE_TAPI_HDLC,hdlc) \
+ $(call autoconf_bool,CONFIG_VOICE_CPE_TAPI_TRACES,trace)
+
+ifneq ($(CONFIG_VOICE_CPE_VMMC_MPS_HISTORY_SIZE),128)
+ CONFIGURE_ARGS += --enable-history-buf=$(CONFIG_VOICE_CPE_VMMC_MPS_HISTORY_SIZE)
+endif
+
+#defaults
+FW_URL:=http://localhost/
+FW_TARGET:=ifx_firmware.bin
+FW_FILE:=fw_voip_ifx.tar.gz
+COEF_TARGET:=ifx_bbd_fxs.bin
+COEF_FILE:=coef_voip_ifx.tar.gz
+
+FW_DIR:=lib/firmware
+
+FW_TARGET_GENERIC:=$(FW_TARGET)
+COEF_TARGET_GENERIC:=$(COEF_TARGET)
+
+ifeq ($(CONFIG_VOICE_CPE_VMMC_WITH_DEVICE_DANUBE)$(CONFIG_LTQ_VOICE_CPE_VMMC_WITH_DEVICE_DANUBE),y)
+ CONFIGURE_ARGS += --with-device=DANUBE
+ FW_SOURCE:=voip_R12.1.0.1.0-enc.bin
+ FW_TARGET:=danube_firmware.bin
+ FW_FILE=fw_voip_danube-12.1.0.1.0.tar.gz
+ FW_MD5SUM:=51868b88dee9dbc65d3dbba355ded91c
+ FW_DOWNLOAD:=1
+ COEF_SRC:=danube_bbd_fxs.bin
+ COEF_TARGET:=danube_bbd_fxs.bin
+ COEF_FILE:=coef_voip_danube-0.9.0.tar.gz
+ COEF_MD5SUM:=c8ac6592b304b03829a8123560e15710
+ COEF_DOWNLOAD:=1
+endif
+
+ifeq ($(CONFIG_VOICE_CPE_VMMC_WITH_DEVICE_AR9),y)
+ CONFIGURE_ARGS += --with-device=AR9
+ # TODO: add fw/coef
+endif
+
+COEF_SRC:=$(COEF_TARGET)
+
+ifeq ($(CONFIG_VOICE_VMMC_WITH_DEVICE_FALCON),y)
+ CONFIGURE_ARGS += --with-device=FALCON
+ FW_SOURCE:=voip_R1.1.0.6.0-enc.bin
+ FW_MD5SUM:=cd4366a52a8010b76793e3810a4f14b3
+ FW_TARGET:=falcon_voip_fw.bin
+ FW_FILE=fw_voip_falcon-1.1.0.6.0.tar.gz
+ FW_DOWNLOAD:=1
+ COEF_TARGET:=falcon_bbd.bin
+# FXS part
+ifeq ($(CONFIG_LTQ_VOICE_CPE_VMMC_COEF_FALCON_ETSI),y)
+ COEF_SRC:=ETSI_3_10.BIN
+endif
+ifeq ($(CONFIG_LTQ_VOICE_CPE_VMMC_COEF_FALCON_US600R),y)
+ COEF_SRC:=R600_3_10.BIN
+endif
+ifeq ($(CONFIG_LTQ_VOICE_CPE_VMMC_COEF_FALCON_USE_CUSTOM_FILE),y)
+ COEF_SRC:=$(CONFIG_LTQ_VOICE_CPE_VMMC_COEF_FALCON_CUSTOM_FILE)
+endif
+ COEF_FILE:=coef_voip_falcon.tar.gz
+ COEF_MD5SUM:=56c5a838f2bb9bd87d0e8dce271f810b
+ COEF_DOWNLOAD:=1
+endif
+
+ifeq ($(CONFIG_VOICE_CPE_VMMC_WITH_DEVICE_VR9),y)
+ CONFIGURE_ARGS += --with-device=VR9
+ # TODO: add fw/coef
+endif
+
+define Download/firmware
+ FILE:=$(FW_FILE)
+ URL:=$(FW_URL)
+ MD5SUM:=$(FW_MD5SUM)
+endef
+$(eval $(if $(FW_DOWNLOAD),$(call Download,firmware)))
+
+define Download/coef
+ FILE:=$(COEF_FILE)
+ URL:=$(FW_URL)
+ MD5SUM:=$(COEF_MD5SUM)
+endef
+$(eval $(if $(COEF_DOWNLOAD),$(call Download,coef)))
+
+define Build/Configure
+ rm -rf \
+ $(PKG_BUILD_DIR)/coef \
+ $(PKG_BUILD_DIR)/firmware
+ mkdir -p \
+ $(PKG_BUILD_DIR)/coef \
+ $(PKG_BUILD_DIR)/firmware
+ $(TAR) -C $(PKG_BUILD_DIR)/firmware -xvzf $(DL_DIR)/$(FW_FILE)
+ $(TAR) -C $(PKG_BUILD_DIR)/coef -xvzf $(DL_DIR)/$(COEF_FILE)
+ (cd $(PKG_BUILD_DIR); aclocal && autoconf && automake)
+ $(call Build/Configure/Default)
+endef
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include
+ mkdir -p $(1)/usr/include/drv_vmmc
+ $(CP) -v --dereference $(PKG_BUILD_DIR)/include/* $(1)/usr/include/drv_vmmc
+ (cd $(1)/usr/include/drv_vmmc && ln -snf . include)
+endef
+
+define KernelPackage/ltq-vmmc/install
+ $(INSTALL_DIR) $(1)/etc/init.d $(1)/$(FW_DIR)
+ $(INSTALL_BIN) ./files/vmmc.init $(1)/etc/init.d/vmmc
+ $(CP) $(PKG_BUILD_DIR)/firmware/$(FW_SOURCE) $(1)/$(FW_DIR)/$(FW_TARGET)
+ ln -s /$(FW_DIR)/$(FW_TARGET) $(1)/$(FW_DIR)/$(FW_TARGET_GENERIC)
+ $(CP) $(PKG_BUILD_DIR)/coef/$(COEF_SRC) $(1)/$(FW_DIR)/$(COEF_TARGET)
+ ln -s /$(FW_DIR)/$(COEF_TARGET) $(1)/$(FW_DIR)/$(COEF_TARGET_GENERIC)
+endef
+
+$(eval $(call KernelPackage,ltq-vmmc))
diff --git a/package/platform/lantiq/ltq-vmmc/files/.svn/entries b/package/platform/lantiq/ltq-vmmc/files/.svn/entries
new file mode 100644
index 0000000..259681d
--- /dev/null
+++ b/package/platform/lantiq/ltq-vmmc/files/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/platform/lantiq/ltq-vmmc/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-12-15T02:00:45.545494Z
+34695
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+vmmc.init
+file
+
+
+
+
+2013-03-17T12:13:13.000000Z
+7939993afb6d4d936a2d911761b0eb78
+2012-12-15T02:00:45.545494Z
+34695
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+396
+
diff --git a/package/platform/lantiq/ltq-vmmc/files/.svn/text-base/vmmc.init.svn-base b/package/platform/lantiq/ltq-vmmc/files/.svn/text-base/vmmc.init.svn-base
new file mode 100644
index 0000000..100a97d
--- /dev/null
+++ b/package/platform/lantiq/ltq-vmmc/files/.svn/text-base/vmmc.init.svn-base
@@ -0,0 +1,19 @@
+#!/bin/sh /etc/rc.common
+#
+# Activate Voice CPE TAPI subsystem LL driver for VMMC
+
+START=31
+
+start() {
+ [ ! -c /dev/vmmc10 ] && {
+ mknod /dev/vmmc10 c 122 10
+ mknod /dev/vmmc11 c 122 11
+ mknod /dev/vmmc12 c 122 12
+ mknod /dev/vmmc13 c 122 13
+ mknod /dev/vmmc14 c 122 14
+ mknod /dev/vmmc15 c 122 15
+ mknod /dev/vmmc16 c 122 16
+ mknod /dev/vmmc17 c 122 17
+ mknod /dev/vmmc18 c 122 18
+ }
+}
diff --git a/package/platform/lantiq/ltq-vmmc/files/vmmc.init b/package/platform/lantiq/ltq-vmmc/files/vmmc.init
new file mode 100644
index 0000000..100a97d
--- /dev/null
+++ b/package/platform/lantiq/ltq-vmmc/files/vmmc.init
@@ -0,0 +1,19 @@
+#!/bin/sh /etc/rc.common
+#
+# Activate Voice CPE TAPI subsystem LL driver for VMMC
+
+START=31
+
+start() {
+ [ ! -c /dev/vmmc10 ] && {
+ mknod /dev/vmmc10 c 122 10
+ mknod /dev/vmmc11 c 122 11
+ mknod /dev/vmmc12 c 122 12
+ mknod /dev/vmmc13 c 122 13
+ mknod /dev/vmmc14 c 122 14
+ mknod /dev/vmmc15 c 122 15
+ mknod /dev/vmmc16 c 122 16
+ mknod /dev/vmmc17 c 122 17
+ mknod /dev/vmmc18 c 122 18
+ }
+}
diff --git a/package/platform/lantiq/ltq-vmmc/patches/.svn/entries b/package/platform/lantiq/ltq-vmmc/patches/.svn/entries
new file mode 100644
index 0000000..206bbfa
--- /dev/null
+++ b/package/platform/lantiq/ltq-vmmc/patches/.svn/entries
@@ -0,0 +1,130 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/platform/lantiq/ltq-vmmc/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-12-15T02:00:45.545494Z
+34695
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+400-falcon.patch
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+f8a7e8540cc1699e728b5b8b4072cc79
+2012-12-15T02:00:45.545494Z
+34695
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+32126
+
+100-target.patch
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+fa2f5950935c964d0c341539b240ffa6
+2012-12-15T02:00:45.545494Z
+34695
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+25238
+
+000-portability.patch
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+8a157275f26e92e807d4c4f3bf4ecb7a
+2012-12-15T02:00:45.545494Z
+34695
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+10009
+
diff --git a/package/platform/lantiq/ltq-vmmc/patches/.svn/text-base/000-portability.patch.svn-base b/package/platform/lantiq/ltq-vmmc/patches/.svn/text-base/000-portability.patch.svn-base
new file mode 100644
index 0000000..4860247
--- /dev/null
+++ b/package/platform/lantiq/ltq-vmmc/patches/.svn/text-base/000-portability.patch.svn-base
@@ -0,0 +1,287 @@
+--- a/src/Makefile.am
++++ b/src/Makefile.am
+@@ -228,7 +228,7 @@ drv_vmmc_CFLAGS += -fno-common
+ drv_vmmc_OBJS = "$(subst .c,.o, $(drv_vmmc_SOURCES) $(nodist_drv_vmmc_SOURCES))"
+
+ drv_vmmc.ko: $(drv_vmmc_SOURCES) $(EXTRA_DIST)
+- @echo -e "Making Linux 2.6.x kernel object"
++ @echo "Making Linux 2.6.x kernel object"
+ @for f in $(drv_vmmc_SOURCES) $(nodist_drv_vmmc_SOURCES) ; do \
+ if test ! -e $(PWD)/$$f; then \
+ echo " LN $$f" ; \
+@@ -236,10 +236,10 @@ drv_vmmc.ko: $(drv_vmmc_SOURCES) $(EXTRA
+ ln -s @abs_srcdir@/$$f $(PWD)/$$f; \
+ fi; \
+ done;
+- @echo -e "# drv_vmmc: Generated to build Linux 2.6.x kernel object" > $(PWD)/Kbuild
+- @echo -e "obj-m := $(subst .ko,.o,$@)" >> $(PWD)/Kbuild
+- @echo -e "$(subst .ko,,$@)-y := $(drv_vmmc_OBJS)" >> $(PWD)/Kbuild
+- @echo -e "EXTRA_CFLAGS := -DHAVE_CONFIG_H $(CFLAGS) $(drv_vmmc_CFLAGS) $(INCLUDES)" >> $(PWD)/Kbuild
++ @echo "# drv_vmmc: Generated to build Linux 2.6.x kernel object" > $(PWD)/Kbuild
++ @echo "obj-m := $(subst .ko,.o,$@)" >> $(PWD)/Kbuild
++ @echo "$(subst .ko,,$@)-y := $(drv_vmmc_OBJS)" >> $(PWD)/Kbuild
++ @echo "EXTRA_CFLAGS := -DHAVE_CONFIG_H $(CFLAGS) $(drv_vmmc_CFLAGS) $(INCLUDES)" >> $(PWD)/Kbuild
+ $(MAKE) ARCH=@KERNEL_ARCH@ -C @KERNEL_BUILD_PATH@ O=@KERNEL_BUILD_PATH@ M=$(PWD) modules
+
+ clean-generic:
+--- a/src/drv_vmmc_linux.c
++++ b/src/drv_vmmc_linux.c
+@@ -27,11 +27,18 @@
+ #include <linux/proc_fs.h>
+ #include <linux/wait.h>
+ #include <linux/vmalloc.h>
++#include <linux/sched.h>
+
+ #ifdef LINUX_2_6
+ #include <linux/version.h>
+ #ifndef UTS_RELEASE
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33))
++#include <linux/autoconf.h>
+ #include <linux/utsrelease.h>
++#else
++#include <generated/autoconf.h>
++#include <generated/utsrelease.h>
++#endif
+ #endif /* UTC_RELEASE */
+ #undef CONFIG_DEVFS_FS
+ #endif /* LINUX_2_6 */
+--- a/src/mps/drv_mps_vmmc_linux.c
++++ b/src/mps/drv_mps_vmmc_linux.c
+@@ -19,11 +19,22 @@
+ #include "drv_config.h"
+
+ #include "drv_mps_version.h"
++#include <linux/version.h>
+
+ #ifdef CONFIG_DEBUG_MINI_BOOT
+ #define IKOS_MINI_BOOT
+ #endif /* */
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33))
+ #include <linux/autoconf.h>
++#ifndef UTS_RELEASE
++#include <linux/utsrelease.h>
++#endif
++#else
++#include <generated/autoconf.h>
++#ifndef UTS_RELEASE
++#include <generated/utsrelease.h>
++#endif
++#endif
+ #include <linux/module.h>
+ #include <linux/init.h>
+ #include <linux/poll.h>
+@@ -34,7 +45,13 @@
+ #include <linux/delay.h>
+ #include <linux/interrupt.h>
+ #ifdef LINUX_2_6
++#ifndef UTS_RELEASE
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 33)
+ #include <linux/utsrelease.h>
++#else
++#include <generated/utsrelease.h>
++#endif
++#endif /* UTC_RELEASE */
+ #else /* */
+ #include <linux/uts.h>
+ #include <linux/moduleparam.h>
+@@ -94,8 +111,13 @@ IFX_int32_t ifx_mps_get_status_proc (IFX
+ #ifndef __KERNEL__
+ IFX_int32_t ifx_mps_open (struct inode *inode, struct file *file_p);
+ IFX_int32_t ifx_mps_close (struct inode *inode, struct file *file_p);
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37)
+ IFX_int32_t ifx_mps_ioctl (struct inode *inode, struct file *file_p,
+ IFX_uint32_t nCmd, IFX_ulong_t arg);
++#else
++long ifx_mps_ioctl (struct file *file_p,
++ IFX_uint32_t nCmd, IFX_ulong_t arg);
++#endif
+ IFX_int32_t ifx_mps_read_mailbox (mps_devices type, mps_message * rw);
+ IFX_int32_t ifx_mps_write_mailbox (mps_devices type, mps_message * rw);
+ IFX_int32_t ifx_mps_register_data_callback (mps_devices type, IFX_uint32_t dir,
+@@ -155,7 +177,11 @@ IFX_char_t voice_channel_int_name[NUM_VO
+ static struct file_operations ifx_mps_fops = {
+ owner:THIS_MODULE,
+ poll:ifx_mps_poll,
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37)
+ ioctl:ifx_mps_ioctl,
++#else
++ unlocked_ioctl:ifx_mps_ioctl,
++#endif
+ open:ifx_mps_open,
+ release:ifx_mps_close
+ };
+@@ -598,8 +624,13 @@ static IFX_uint32_t ifx_mps_poll (struct
+ * \return -ENOIOCTLCMD Invalid command
+ * \ingroup API
+ */
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37)
+ IFX_int32_t ifx_mps_ioctl (struct inode * inode, struct file * file_p,
+ IFX_uint32_t nCmd, IFX_ulong_t arg)
++#else
++long ifx_mps_ioctl (struct file *file_p,
++ IFX_uint32_t nCmd, IFX_ulong_t arg)
++#endif
+ {
+ IFX_int32_t retvalue = -EINVAL;
+ mps_message rw_struct;
+@@ -613,17 +644,30 @@ IFX_int32_t ifx_mps_ioctl (struct inode
+ 'mps_devices' enum type, which in fact is [0..8]; So, if inode value is
+ [0..NUM_VOICE_CHANNEL+1], then we make sure that we are calling from
+ kernel space. */
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37)
+ if (((IFX_int32_t) inode >= 0) &&
+ ((IFX_int32_t) inode < NUM_VOICE_CHANNEL + 1))
++#else
++ if (((IFX_int32_t) file_p >= 0) &&
++ ((IFX_int32_t) file_p < NUM_VOICE_CHANNEL + 1))
++#endif
+ {
+ from_kernel = 1;
+
+ /* Get corresponding mailbox device structure */
+ if ((pMBDev =
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37)
+ ifx_mps_get_device ((mps_devices) ((IFX_int32_t) inode))) == 0)
++#else
++ ifx_mps_get_device ((mps_devices) ((IFX_int32_t) file_p))) == 0)
++#endif
+ {
+ return (-EINVAL);
+ }
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37)
++#else
++ file_p = NULL;
++#endif
+ }
+ else
+ {
+--- a/src/mps/drv_mps_vmmc_common.c
++++ b/src/mps/drv_mps_vmmc_common.c
+@@ -21,7 +21,11 @@
+ #undef USE_PLAIN_VOICE_FIRMWARE
+ #undef PRINT_ON_ERR_INTERRUPT
+ #undef FAIL_ON_ERR_INTERRUPT
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33))
+ #include <linux/autoconf.h>
++#else
++#include <generated/autoconf.h>
++#endif
+ #include <linux/interrupt.h>
+ #include <linux/delay.h>
+
+@@ -92,7 +96,9 @@ extern IFX_uint32_t danube_get_cpu_ver (
+ extern mps_mbx_dev *ifx_mps_get_device (mps_devices type);
+
+ #ifdef LINUX_2_6
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39))
+ extern IFX_void_t bsp_mask_and_ack_irq (IFX_uint32_t irq_nr);
++#endif
+
+ #else /* */
+ extern IFX_void_t mask_and_ack_danube_irq (IFX_uint32_t irq_nr);
+--- a/src/mps/drv_mps_vmmc_danube.c
++++ b/src/mps/drv_mps_vmmc_danube.c
+@@ -20,7 +20,11 @@
+
+ #ifdef SYSTEM_DANUBE /* defined in drv_mps_vmmc_config.h */
+
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33))
+ #include <linux/autoconf.h>
++#else
++#include <generated/autoconf.h>
++#endif
+
+ /* lib_ifxos headers */
+ #include "ifx_types.h"
+--- a/configure.in
++++ b/configure.in
+@@ -112,7 +112,7 @@ dnl Set kernel build path
+ AC_ARG_ENABLE(kernelbuild,
+ AS_HELP_STRING(--enable-kernelbuild=x,Set the target kernel build path),
+ [
+- if test -r $enableval/include/linux/autoconf.h; then
++ if test -e $enableval/include/linux/autoconf.h -o -e $enableval/include/generated/autoconf.h; then
+ AC_SUBST([KERNEL_BUILD_PATH],[$enableval])
+ else
+ AC_MSG_ERROR([The kernel build directory is not valid or not configured!])
+--- a/src/drv_vmmc_bbd.c
++++ b/src/drv_vmmc_bbd.c
+@@ -1072,7 +1072,11 @@ static IFX_int32_t vmmc_BBD_DownloadChCr
+ IFX_uint8_t padBytes = 0;
+ #endif
+ IFX_uint16_t cram_offset, cram_crc,
+- pCmd [MAX_CMD_WORD] = {0};
++ pCmd [MAX_CMD_WORD]
++#if defined (__GNUC__) || defined (__GNUG__)
++ __attribute__ ((aligned(4)))
++#endif
++ = {0};
+
+ /* read offset */
+ cpb2w (&cram_offset, &bbd_cram->pData[0], sizeof (IFX_uint16_t));
+--- a/src/drv_vmmc_init.c
++++ b/src/drv_vmmc_init.c
+@@ -776,8 +776,13 @@ IFX_int32_t VMMC_TAPI_LL_FW_Start(IFX_TA
+ dwld.fwDwld.length = IoInit.pram_size;
+
+ /* download firmware */
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37)
+ ret = ifx_mps_ioctl((IFX_void_t *) command, IFX_NULL, FIO_MPS_DOWNLOAD,
+ (IFX_uint32_t) &dwld.fwDwld);
++#else
++ ret = ifx_mps_ioctl((IFX_void_t *) command, FIO_MPS_DOWNLOAD,
++ (IFX_uint32_t) &dwld.fwDwld);
++#endif
+ }
+
+ if (VMMC_SUCCESS(ret))
+--- a/src/drv_vmmc_ioctl.c
++++ b/src/drv_vmmc_ioctl.c
+@@ -426,18 +426,31 @@ IFX_int32_t VMMC_Dev_Spec_Ioctl (IFX_TAP
+ /* MPS driver will do the USR2KERN so just pass on the pointer. */
+ dwnld_struct.data = (IFX_void_t *)IoInit.pPRAMfw;
+
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37)
+ ret = ifx_mps_ioctl((IFX_void_t *)command, IFX_NULL,
+ FIO_MPS_DOWNLOAD, (IFX_uint32_t) &dwnld_struct);
++#else
++ ret = ifx_mps_ioctl((IFX_void_t *)command,
++ FIO_MPS_DOWNLOAD, (IFX_uint32_t) &dwnld_struct);
++#endif
+ break;
+ }
+ case FIO_DEV_RESET:
+ {
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37)
+ ret = ifx_mps_ioctl((IFX_void_t *)command, IFX_NULL, FIO_MPS_RESET, 0);
++#else
++ ret = ifx_mps_ioctl((IFX_void_t *)command, FIO_MPS_RESET, 0);
++#endif
+ break;
+ }
+ case FIO_DEV_RESTART:
+ {
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37)
+ ret = ifx_mps_ioctl((IFX_void_t *)command, IFX_NULL, FIO_MPS_RESTART, 0);
++#else
++ ret = ifx_mps_ioctl((IFX_void_t *)command, FIO_MPS_RESTART, 0);
++#endif
+ break;
+ }
+ case FIO_LASTERR:
+--- a/src/mps/drv_mps_vmmc.h
++++ b/src/mps/drv_mps_vmmc.h
+@@ -279,8 +279,13 @@ typedef struct
+ #include <linux/fs.h>
+ IFX_int32_t ifx_mps_open (struct inode *inode, struct file *file_p);
+ IFX_int32_t ifx_mps_close (struct inode *inode, struct file *filp);
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37)
+ IFX_int32_t ifx_mps_ioctl (struct inode *inode, struct file *file_p,
+ IFX_uint32_t nCmd, unsigned long arg);
++#else
++long ifx_mps_ioctl (struct file *filp,
++ IFX_uint32_t nCmd, unsigned long arg);
++#endif
+ IFX_int32_t ifx_mps_register_data_callback (mps_devices type, IFX_uint32_t dir,
+ IFX_void_t (*callback) (mps_devices
+ type));
diff --git a/package/platform/lantiq/ltq-vmmc/patches/.svn/text-base/100-target.patch.svn-base b/package/platform/lantiq/ltq-vmmc/patches/.svn/text-base/100-target.patch.svn-base
new file mode 100644
index 0000000..cabd2d1
--- /dev/null
+++ b/package/platform/lantiq/ltq-vmmc/patches/.svn/text-base/100-target.patch.svn-base
@@ -0,0 +1,751 @@
+--- a/src/drv_vmmc_access.h
++++ b/src/drv_vmmc_access.h
+@@ -24,6 +24,10 @@
+ #include "drv_mps_vmmc.h"
+ #endif
+
++#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,28))
++# define IFX_MPS IFXMIPS_MPS_BASE_ADDR
++#endif
++
+ /* ============================= */
+ /* Global Defines */
+ /* ============================= */
+--- a/src/drv_vmmc_danube.h
++++ b/src/drv_vmmc_danube.h
+@@ -15,56 +15,18 @@
+ */
+
+ #if defined SYSTEM_DANUBE
+-#include <asm/ifx/ifx_gpio.h>
++#include <lantiq_soc.h>
++
+ #else
+ #error no system selected
+ #endif
+
+-#define VMMC_TAPI_GPIO_MODULE_ID IFX_GPIO_MODULE_TAPI_VMMC
++#define VMMC_TAPI_GPIO_MODULE_ID IFX_GPIO_MODULE_TAPI_VMMC
+ /**
+
+ */
+ #define VMMC_PCM_IF_CFG_HOOK(mode, GPIOreserved, ret) \
+ do { \
+- ret = VMMC_statusOk; \
+- /* Reserve P0.0 as TDM/FSC */ \
+- if (!GPIOreserved) \
+- ret |= ifx_gpio_pin_reserve(IFX_GPIO_PIN_ID(0, 0), VMMC_TAPI_GPIO_MODULE_ID); \
+- ret |= ifx_gpio_altsel0_set(IFX_GPIO_PIN_ID(0, 0), VMMC_TAPI_GPIO_MODULE_ID); \
+- ret |= ifx_gpio_altsel1_set(IFX_GPIO_PIN_ID(0, 0), VMMC_TAPI_GPIO_MODULE_ID); \
+- ret |= ifx_gpio_open_drain_set(IFX_GPIO_PIN_ID(0, 0), VMMC_TAPI_GPIO_MODULE_ID);\
+- \
+- /* Reserve P1.9 as TDM/DO */ \
+- if (!GPIOreserved) \
+- ret |= ifx_gpio_pin_reserve(IFX_GPIO_PIN_ID(1, 9), VMMC_TAPI_GPIO_MODULE_ID); \
+- ret |= ifx_gpio_altsel0_set(IFX_GPIO_PIN_ID(1, 9), VMMC_TAPI_GPIO_MODULE_ID); \
+- ret |= ifx_gpio_altsel1_clear(IFX_GPIO_PIN_ID(1, 9), VMMC_TAPI_GPIO_MODULE_ID); \
+- ret |= ifx_gpio_dir_out_set(IFX_GPIO_PIN_ID(1, 9), VMMC_TAPI_GPIO_MODULE_ID); \
+- ret |= ifx_gpio_open_drain_set(IFX_GPIO_PIN_ID(1, 9), VMMC_TAPI_GPIO_MODULE_ID); \
+- \
+- /* Reserve P1.10 as TDM/DI */ \
+- if (!GPIOreserved) \
+- ret |= ifx_gpio_pin_reserve(IFX_GPIO_PIN_ID(1,10), VMMC_TAPI_GPIO_MODULE_ID); \
+- ret |= ifx_gpio_altsel0_clear(IFX_GPIO_PIN_ID(1,10), VMMC_TAPI_GPIO_MODULE_ID); \
+- ret |= ifx_gpio_altsel1_set(IFX_GPIO_PIN_ID(1,10), VMMC_TAPI_GPIO_MODULE_ID);\
+- ret |= ifx_gpio_dir_in_set(IFX_GPIO_PIN_ID(1,10), VMMC_TAPI_GPIO_MODULE_ID); \
+- \
+- /* Reserve P1.11 as TDM/DCL */ \
+- if (!GPIOreserved) \
+- ret |= ifx_gpio_pin_reserve(IFX_GPIO_PIN_ID(1,11), VMMC_TAPI_GPIO_MODULE_ID); \
+- ret |= ifx_gpio_altsel0_set(IFX_GPIO_PIN_ID(1,11), VMMC_TAPI_GPIO_MODULE_ID); \
+- ret |= ifx_gpio_altsel1_clear(IFX_GPIO_PIN_ID(1,11), VMMC_TAPI_GPIO_MODULE_ID); \
+- ret |= ifx_gpio_open_drain_set(IFX_GPIO_PIN_ID(1,11), VMMC_TAPI_GPIO_MODULE_ID); \
+- \
+- if (mode == 2) { \
+- /* TDM/FSC+DCL Master */ \
+- ret |= ifx_gpio_dir_out_set(IFX_GPIO_PIN_ID(0, 0), VMMC_TAPI_GPIO_MODULE_ID); \
+- ret |= ifx_gpio_dir_out_set(IFX_GPIO_PIN_ID(1,11), VMMC_TAPI_GPIO_MODULE_ID); \
+- } else { \
+- /* TDM/FSC+DCL Slave */ \
+- ret |= ifx_gpio_dir_in_set(IFX_GPIO_PIN_ID(0, 0), VMMC_TAPI_GPIO_MODULE_ID); \
+- ret |= ifx_gpio_dir_in_set(IFX_GPIO_PIN_ID(1,11), VMMC_TAPI_GPIO_MODULE_ID); \
+- } \
+ } while(0);
+
+ /**
+@@ -72,11 +34,6 @@
+ */
+ #define VMMC_DRIVER_UNLOAD_HOOK(ret) \
+ do { \
+- ret = VMMC_statusOk; \
+- ret |= ifx_gpio_pin_free(IFX_GPIO_PIN_ID(0, 0), VMMC_TAPI_GPIO_MODULE_ID); \
+- ret |= ifx_gpio_pin_free(IFX_GPIO_PIN_ID(1, 9), VMMC_TAPI_GPIO_MODULE_ID); \
+- ret |= ifx_gpio_pin_free(IFX_GPIO_PIN_ID(1,10), VMMC_TAPI_GPIO_MODULE_ID); \
+- ret |= ifx_gpio_pin_free(IFX_GPIO_PIN_ID(1,11), VMMC_TAPI_GPIO_MODULE_ID); \
+ } while (0)
+
+ #endif /* _DRV_VMMC_AMAZON_S_H */
+--- a/src/drv_vmmc_init.c
++++ b/src/drv_vmmc_init.c
+@@ -52,6 +52,14 @@
+ #include "ifx_pmu.h"
+ #endif /* PMU_SUPPORTED */
+
++#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,28))
++# define IFX_MPS_CAD0SR IFXMIPS_MPS_CAD0SR
++# define IFX_MPS_CAD1SR IFXMIPS_MPS_CAD1SR
++# define IFX_MPS_CVC0SR IFXMIPS_MPS_CVC0SR
++# define IFX_MPS_CVC1SR IFXMIPS_MPS_CVC1SR
++# define IFX_MPS_CVC2SR IFXMIPS_MPS_CVC2SR
++# define IFX_MPS_CVC3SR IFXMIPS_MPS_CVC3SR
++#endif
+
+ /* ============================= */
+ /* Local Macros & Definitions */
+@@ -1591,7 +1599,7 @@
+ #ifdef VMMC_DRIVER_UNLOAD_HOOK
+ if (VDevices[0].nDevState & DS_GPIO_RESERVED)
+ {
+- IFX_int32_t ret;
++ IFX_int32_t ret = 0;
+ VMMC_DRIVER_UNLOAD_HOOK(ret);
+ if (!VMMC_SUCCESS(ret))
+ {
+--- a/src/drv_vmmc_init_cap.c
++++ b/src/drv_vmmc_init_cap.c
+@@ -22,6 +22,11 @@
+ #include "drv_mps_vmmc.h"
+ #include "drv_mps_vmmc_device.h"
+
++#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,28))
++# define IFX_MPS_CHIPID_VERSION_GET IFXMIPS_MPS_CHIPID_VERSION_GET
++# define IFX_MPS_CHIPID IFXMIPS_MPS_CHIPID
++#endif
++
+ /* ============================= */
+ /* Configuration defintions */
+ /* ============================= */
+--- a/src/mps/drv_mps_vmmc_common.c
++++ b/src/mps/drv_mps_vmmc_common.c
+@@ -17,6 +17,7 @@
+ /* Includes */
+ /* ============================= */
+ #include "drv_config.h"
++#include "drv_vmmc_init.h"
+
+ #undef USE_PLAIN_VOICE_FIRMWARE
+ #undef PRINT_ON_ERR_INTERRUPT
+@@ -39,8 +40,32 @@
+ #include "ifxos_interrupt.h"
+ #include "ifxos_time.h"
+
+-#include <asm/ifx/ifx_regs.h>
+-#include <asm/ifx/ifx_gptu.h>
++#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,28))
++# include <lantiq.h>
++# include <irq.h>
++# include <lantiq_timer.h>
++
++# define ifx_gptu_timer_request lq_request_timer
++# define ifx_gptu_timer_start lq_start_timer
++# define ifx_gptu_countvalue_get lq_get_count_value
++# define ifx_gptu_timer_free lq_free_timer
++
++
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39))
++# define bsp_mask_and_ack_irq ltq_mask_and_ack_irq
++#else
++extern void ltq_mask_and_ack_irq(struct irq_data *d);
++static void inline bsp_mask_and_ack_irq(int x)
++{
++ struct irq_data d;
++ d.hwirq = x;
++ ltq_mask_and_ack_irq(&d);
++}
++#endif
++#else
++# include <asm/ifx/ifx_regs.h>
++# include <asm/ifx/ifx_gptu.h>
++#endif
+
+ #include "drv_mps_vmmc.h"
+ #include "drv_mps_vmmc_dbg.h"
+@@ -104,6 +129,9 @@
+ extern IFX_void_t mask_and_ack_danube_irq (IFX_uint32_t irq_nr);
+
+ #endif /* */
++
++extern void sys_hw_setup (void);
++
+ extern IFXOS_event_t fw_ready_evt;
+ /* callback function to free all data buffers currently used by voice FW */
+ IFX_void_t (*ifx_mps_bufman_freeall)(IFX_void_t) = IFX_NULL;
+@@ -207,7 +235,8 @@
+ */
+ IFX_void_t *ifx_mps_fastbuf_malloc (IFX_size_t size, IFX_int32_t priority)
+ {
+- IFX_uint32_t ptr, flags;
++ IFXOS_INTSTAT flags;
++ IFX_uint32_t ptr;
+ IFX_int32_t index = fastbuf_index;
+
+ if (fastbuf_initialized == 0)
+@@ -261,7 +290,7 @@
+ */
+ IFX_void_t ifx_mps_fastbuf_free (const IFX_void_t * ptr)
+ {
+- IFX_uint32_t flags;
++ IFXOS_INTSTAT flags;
+ IFX_int32_t index = fastbuf_index;
+
+ IFXOS_LOCKINT (flags);
+@@ -457,7 +486,7 @@
+ */
+ static IFX_int32_t ifx_mps_bufman_inc_level (IFX_uint32_t value)
+ {
+- IFX_uint32_t flags;
++ IFXOS_INTSTAT flags;
+
+ if (mps_buffer.buf_level + value > MPS_BUFFER_MAX_LEVEL)
+ {
+@@ -484,7 +513,7 @@
+ */
+ static IFX_int32_t ifx_mps_bufman_dec_level (IFX_uint32_t value)
+ {
+- IFX_uint32_t flags;
++ IFXOS_INTSTAT flags;
+
+ if (mps_buffer.buf_level < value)
+ {
+@@ -636,7 +665,7 @@
+ mem_seg_ptr[i] =
+ (IFX_uint32_t *) CPHYSADDR ((IFX_uint32_t) mps_buffer.
+ malloc (segment_size, FASTBUF_FW_OWNED));
+- if (mem_seg_ptr[i] == CPHYSADDR (IFX_NULL))
++ if (mem_seg_ptr[i] == (IFX_uint32_t *)CPHYSADDR (IFX_NULL))
+ {
+ TRACE (MPS, DBG_LEVEL_HIGH,
+ ("%s(): cannot allocate buffer\n", __FUNCTION__));
+@@ -952,7 +981,7 @@
+ mps_mbx_dev * pMBDev, IFX_int32_t bcommand,
+ IFX_boolean_t from_kernel)
+ {
+- IFX_uint32_t flags;
++ IFXOS_INTSTAT flags;
+
+ IFXOS_LOCKINT (flags);
+
+@@ -1068,7 +1097,7 @@
+ IFX_void_t ifx_mps_release_structures (mps_comm_dev * pDev)
+ {
+ IFX_int32_t count;
+- IFX_uint32_t flags;
++ IFXOS_INTSTAT flags;
+
+ IFXOS_LOCKINT (flags);
+ IFXOS_BlockFree (pFW_img_data);
+@@ -1117,7 +1146,7 @@
+
+ /* Initialize MPS main structure */
+ memset ((IFX_void_t *) pDev, 0, sizeof (mps_comm_dev));
+- pDev->base_global = (mps_mbx_reg *) IFX_MPS_SRAM;
++ pDev->base_global = (mps_mbx_reg *) IFXMIPS_MPS_SRAM;
+ pDev->flags = 0x00000000;
+ MBX_Memory = pDev->base_global;
+
+@@ -1125,9 +1154,11 @@
+ for MBX communication. These are: mailbox base address, mailbox size, *
+ mailbox read index and mailbox write index. for command and voice
+ mailbox, * upstream and downstream direction. */
+- memset ((IFX_void_t *) MBX_Memory, /* avoid to overwrite CPU boot
+- registers */
+- 0, sizeof (mps_mbx_reg) - 2 * sizeof (mps_boot_cfg_reg));
++ memset (
++ /* avoid to overwrite CPU boot registers */
++ (IFX_void_t *) MBX_Memory,
++ 0,
++ sizeof (mps_mbx_reg) - 2 * sizeof (mps_boot_cfg_reg));
+ MBX_Memory->MBX_UPSTR_CMD_BASE =
+ (IFX_uint32_t *) CPHYSADDR ((IFX_uint32_t) MBX_UPSTRM_CMD_FIFO_BASE);
+ MBX_Memory->MBX_UPSTR_CMD_SIZE = MBX_CMD_FIFO_SIZE;
+@@ -1564,7 +1595,7 @@
+ IFX_uint32_t * bytes)
+ {
+ IFX_int32_t i, ret;
+- IFX_uint32_t flags;
++ IFXOS_INTSTAT flags;
+
+ IFXOS_LOCKINT (flags);
+
+@@ -1774,7 +1805,7 @@
+ {
+ mps_fifo *mbx;
+ IFX_uint32_t i;
+- IFX_uint32_t flags;
++ IFXOS_INTSTAT flags;
+ IFX_int32_t retval = -EAGAIN;
+ IFX_int32_t retries = 0;
+ IFX_uint32_t word = 0;
+@@ -2169,6 +2200,7 @@
+ TRACE (MPS, DBG_LEVEL_HIGH,
+ ("%s(): Invalid device ID %d !\n", __FUNCTION__, pMBDev->devID));
+ }
++
+ return retval;
+ }
+
+@@ -2192,7 +2224,7 @@
+ mps_mbx_dev *mbx_dev;
+ MbxMsg_s msg;
+ IFX_uint32_t bytes_read = 0;
+- IFX_uint32_t flags;
++ IFXOS_INTSTAT flags;
+ IFX_int32_t ret;
+
+ /* set pointer to data upstream mailbox, no matter if 0,1,2 or 3 because
+@@ -2283,7 +2315,7 @@
+ {
+ ifx_mps_bufman_dec_level (1);
+ if ((ifx_mps_bufman_get_level () <= mps_buffer.buf_threshold) &&
+- (atomic_read (&pMPSDev->provide_buffer->object.count) == 0))
++ ((volatile unsigned int)pMPSDev->provide_buffer->object.count == 0))
+ {
+ IFXOS_LockRelease (pMPSDev->provide_buffer);
+ }
+@@ -2326,7 +2358,7 @@
+ #endif /* CONFIG_PROC_FS */
+ ifx_mps_bufman_dec_level (1);
+ if ((ifx_mps_bufman_get_level () <= mps_buffer.buf_threshold) &&
+- (atomic_read (&pMPSDev->provide_buffer->object.count) == 0))
++ ((volatile unsigned int)pMPSDev->provide_buffer->object.count == 0))
+ {
+ IFXOS_LockRelease (pMPSDev->provide_buffer);
+ }
+@@ -2356,7 +2388,7 @@
+ IFX_void_t ifx_mps_mbx_cmd_upstream (IFX_ulong_t dummy)
+ {
+ mps_fifo *mbx;
+- IFX_uint32_t flags;
++ IFXOS_INTSTAT flags;
+
+ /* set pointer to upstream command mailbox */
+ mbx = &(pMPSDev->cmd_upstrm_fifo);
+@@ -2404,7 +2436,7 @@
+ mps_event_msg msg;
+ IFX_int32_t length = 0;
+ IFX_int32_t read_length = 0;
+- IFX_uint32_t flags;
++ IFXOS_INTSTAT flags;
+
+ /* set pointer to upstream event mailbox */
+ mbx = &(pMPSDev->event_upstrm_fifo);
+@@ -2619,6 +2651,7 @@
+ #endif
+
+ *IFX_MPS_AD0ENR = Ad0Reg.val;
++
+ }
+
+ /**
+@@ -2647,7 +2680,7 @@
+ */
+ IFX_void_t ifx_mps_dd_mbx_int_enable (IFX_void_t)
+ {
+- IFX_uint32_t flags;
++ IFXOS_INTSTAT flags;
+ MPS_Ad0Reg_u Ad0Reg;
+
+ IFXOS_LOCKINT (flags);
+@@ -2673,7 +2706,7 @@
+ */
+ IFX_void_t ifx_mps_dd_mbx_int_disable (IFX_void_t)
+ {
+- IFX_uint32_t flags;
++ IFXOS_INTSTAT flags;
+ MPS_Ad0Reg_u Ad0Reg;
+
+ IFXOS_LOCKINT (flags);
+@@ -2738,7 +2771,6 @@
+ #else /* */
+ mask_and_ack_danube_irq (irq);
+ #endif /* */
+-
+ /* FW is up and ready to process commands */
+ if (MPS_Ad0StatusReg.fld.dl_end)
+ {
+@@ -2800,6 +2832,7 @@
+ }
+ }
+
++
+ if (MPS_Ad0StatusReg.fld.du_mbx)
+ {
+ #ifdef CONFIG_PROC_FS
+@@ -2944,12 +2977,12 @@
+ IFX_MPS_CVC0SR[chan] = MPS_VCStatusReg.val;
+ /* handle only enabled interrupts */
+ MPS_VCStatusReg.val &= IFX_MPS_VC0ENR[chan];
+-
+ #ifdef LINUX_2_6
+ bsp_mask_and_ack_irq (irq);
+ #else /* */
+ mask_and_ack_danube_irq (irq);
+ #endif /* */
++
+ pMPSDev->event.MPS_VCStatReg[chan].val = MPS_VCStatusReg.val;
+ #ifdef PRINT_ON_ERR_INTERRUPT
+ if (MPS_VCStatusReg.fld.rcv_ov)
+@@ -3093,7 +3126,8 @@
+ */
+ IFX_return_t ifx_mps_init_gpt ()
+ {
+- IFX_uint32_t flags, timer_flags, timer, loops = 0;
++ unsigned long flags;
++ IFX_uint32_t timer_flags, timer, loops = 0;
+ IFX_ulong_t count;
+ #if defined(SYSTEM_AR9) || defined(SYSTEM_VR9)
+ timer = TIMER1A;
+@@ -3166,6 +3200,7 @@
+ #else /* Danube */
+ timer = TIMER1B;
+ #endif /* SYSTEM_AR9 || SYSTEM_VR9 */
++
+ ifx_gptu_timer_free (timer);
+ }
+
+--- a/src/mps/drv_mps_vmmc_danube.c
++++ b/src/mps/drv_mps_vmmc_danube.c
+@@ -16,6 +16,7 @@
+ /* ============================= */
+ /* Includes */
+ /* ============================= */
++#include "linux/version.h"
+ #include "drv_config.h"
+
+ #ifdef SYSTEM_DANUBE /* defined in drv_mps_vmmc_config.h */
+@@ -36,9 +37,22 @@
+ #include "ifxos_select.h"
+ #include "ifxos_interrupt.h"
+
+-#include <asm/ifx/ifx_regs.h>
+-#include <asm/ifx/ifx_gpio.h>
+-#include <asm/ifx/common_routines.h>
++#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,28))
++# include <lantiq.h>
++# include <irq.h>
++# include <lantiq_timer.h>
++# include <linux/dma-mapping.h>
++
++
++#define LQ_RCU_BASE_ADDR (KSEG1 + LTQ_RCU_BASE_ADDR)
++# define LQ_RCU_RST ((u32 *)(LQ_RCU_BASE_ADDR + 0x0010))
++#define IFX_RCU_RST_REQ_CPU1 (1 << 3)
++# define IFX_RCU_RST_REQ LQ_RCU_RST
++#else
++# include <asm/ifx/ifx_regs.h>
++# include <asm/ifx_vpe.h>
++# include <asm/ifx/ifx_gpio.h>
++#endif
+
+ #include "drv_mps_vmmc.h"
+ #include "drv_mps_vmmc_dbg.h"
+@@ -75,6 +89,20 @@
+ /* Local function definition */
+ /* ============================= */
+
++#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,28))
++IFX_uint32_t ifx_get_cp1_size(IFX_void_t)
++{
++ return 1;
++}
++
++unsigned int *ltq_get_cp1_base(void);
++
++IFX_uint32_t *ifx_get_cp1_base(IFX_void_t)
++{
++ return ltq_get_cp1_base();
++}
++#endif
++
+ /******************************************************************************
+ * DANUBE Specific Routines
+ ******************************************************************************/
+@@ -134,6 +162,15 @@
+ }
+
+ /* check if FW image fits in available memory space */
++#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,28))
++ if (mem > ifx_get_cp1_size()<<20)
++ {
++ TRACE (MPS, DBG_LEVEL_HIGH,
++ ("[%s %s %d]: error, firmware memory exceeds reserved space (%i > %i)!\n",
++ __FILE__, __func__, __LINE__, mem, ifx_get_cp1_size()<<20));
++ return IFX_ERROR;
++ }
++#else
+ if (mem > ifx_get_cp1_size())
+ {
+ TRACE (MPS, DBG_LEVEL_HIGH,
+@@ -141,6 +178,7 @@
+ __FILE__, __func__, __LINE__, mem, ifx_get_cp1_size()));
+ return IFX_ERROR;
+ }
++#endif
+
+ /* reset the driver */
+ ifx_mps_reset ();
+@@ -361,7 +399,7 @@
+ */
+ IFX_void_t ifx_mps_wdog_expiry()
+ {
+- IFX_uint32_t flags;
++ unsigned long flags;
+
+ IFXOS_LOCKINT (flags);
+ /* recalculate and compare the firmware checksum */
+--- a/src/mps/drv_mps_vmmc_device.h
++++ b/src/mps/drv_mps_vmmc_device.h
+@@ -16,8 +16,58 @@
+ declarations.
+ *******************************************************************************/
+
+-#include <asm/ifx/ifx_regs.h>
+-#include <asm/ifx_vpe.h>
++#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,28))
++# include <lantiq.h>
++# include <irq.h>
++# include <lantiq_soc.h>
++# include <gpio.h>
++#define IFXMIPS_MPS_SRAM ((u32 *)(KSEG1 + 0x1F200000))
++#define IFXMIPS_MPS_BASE_ADDR (KSEG1 + 0x1F107000)
++#define IFXMIPS_MPS_CHIPID ((u32 *)(IFXMIPS_MPS_BASE_ADDR + 0x0344))
++#define IFXMIPS_MPS_VC0ENR ((u32 *)(IFXMIPS_MPS_BASE_ADDR + 0x0000))
++#define IFXMIPS_MPS_RVC0SR ((u32 *)(IFXMIPS_MPS_BASE_ADDR + 0x0010))
++#define IFXMIPS_MPS_CVC0SR ((u32 *)(IFXMIPS_MPS_BASE_ADDR + 0x0030))
++#define IFXMIPS_MPS_CVC1SR ((u32 *)(IFXMIPS_MPS_BASE_ADDR + 0x0034))
++#define IFXMIPS_MPS_CVC2SR ((u32 *)(IFXMIPS_MPS_BASE_ADDR + 0x0038))
++#define IFXMIPS_MPS_CVC3SR ((u32 *)(IFXMIPS_MPS_BASE_ADDR + 0x003C))
++#define IFXMIPS_MPS_RAD0SR ((u32 *)(IFXMIPS_MPS_BASE_ADDR + 0x0040))
++#define IFXMIPS_MPS_RAD1SR ((u32 *)(IFXMIPS_MPS_BASE_ADDR + 0x0044))
++#define IFXMIPS_MPS_SAD0SR ((u32 *)(IFXMIPS_MPS_BASE_ADDR + 0x0048))
++#define IFXMIPS_MPS_SAD1SR ((u32 *)(IFXMIPS_MPS_BASE_ADDR + 0x004C))
++#define IFXMIPS_MPS_CAD0SR ((u32 *)(IFXMIPS_MPS_BASE_ADDR + 0x0050))
++#define IFXMIPS_MPS_CAD1SR ((u32 *)(IFXMIPS_MPS_BASE_ADDR + 0x0054))
++#define IFXMIPS_MPS_AD0ENR ((u32 *)(IFXMIPS_MPS_BASE_ADDR + 0x0058))
++#define IFXMIPS_MPS_AD1ENR ((u32 *)(IFXMIPS_MPS_BASE_ADDR + 0x005C))
++
++#define IFXMIPS_MPS_CHIPID_VERSION_GET(value) (((value) >> 28) & ((1 << 4) - 1))
++#define IFXMIPS_MPS_CHIPID_VERSION_SET(value) ((((1 << 4) - 1) & (value)) << 28)
++#define IFXMIPS_MPS_CHIPID_PARTNUM_GET(value) (((value) >> 12) & ((1 << 16) - 1))
++#define IFXMIPS_MPS_CHIPID_PARTNUM_SET(value) ((((1 << 16) - 1) & (value)) << 12)
++#define IFXMIPS_MPS_CHIPID_MANID_GET(value) (((value) >> 1) & ((1 << 10) - 1))
++#define IFXMIPS_MPS_CHIPID_MANID_SET(value) ((((1 << 10) - 1) & (value)) << 1)
++#else
++# include <asm/ifx/ifx_regs.h>
++# include <asm/ifx_vpe.h>
++#endif
++/* MPS register */
++# define IFX_MPS_AD0ENR IFXMIPS_MPS_AD0ENR
++# define IFX_MPS_AD1ENR IFXMIPS_MPS_AD1ENR
++# define IFX_MPS_RAD0SR IFXMIPS_MPS_RAD0SR
++# define IFX_MPS_RAD1SR IFXMIPS_MPS_RAD1SR
++# define IFX_MPS_VC0ENR IFXMIPS_MPS_VC0ENR
++# define IFX_MPS_RVC0SR IFXMIPS_MPS_RVC0SR
++# define IFX_MPS_CVC0SR IFXMIPS_MPS_CVC0SR
++# define IFX_MPS_CAD0SR IFXMIPS_MPS_CAD0SR
++# define IFX_MPS_CAD1SR IFXMIPS_MPS_CAD1SR
++# define IFX_MPS_CVC1SR IFXMIPS_MPS_CVC1SR
++# define IFX_MPS_CVC2SR IFXMIPS_MPS_CVC2SR
++# define IFX_MPS_CVC3SR IFXMIPS_MPS_CVC3SR
++# define IFX_MPS_SAD0SR IFXMIPS_MPS_SAD0SR
++/* interrupt vectors */
++# define INT_NUM_IM4_IRL14 (INT_NUM_IM4_IRL0 + 14)
++# define INT_NUM_IM4_IRL18 (INT_NUM_IM4_IRL0 + 18)
++# define INT_NUM_IM4_IRL19 (INT_NUM_IM4_IRL0 + 19)
++# define IFX_ICU_IM4_IER IFXMIPS_ICU_IM4_IER
+
+ /* ============================= */
+ /* MPS Common defines */
+@@ -26,32 +76,28 @@
+ #define MPS_BASEADDRESS 0xBF107000
+ #define MPS_RAD0SR MPS_BASEADDRESS + 0x0004
+
+-#define MPS_RAD0SR_DU (1<<0)
+-#define MPS_RAD0SR_CU (1<<1)
+-
+ #define MBX_BASEADDRESS 0xBF200000
+ #define VCPU_BASEADDRESS 0xBF208000 /* 0xBF108000 */
+ /*---------------------------------------------------------------------------*/
++#if !defined(CONFIG_LANTIQ)
++/* enabling interrupts is done with request_irq by the BSP
++ The related code should not be needed anymore */
+ #if defined(SYSTEM_AR9) || defined(SYSTEM_VR9)
+ /* TODO: doublecheck - IM4 or different! */
+ #define MPS_INTERRUPTS_ENABLE(X) *((volatile IFX_uint32_t*) IFX_ICU_IM4_IER) |= X;
+ #define MPS_INTERRUPTS_DISABLE(X) *((volatile IFX_uint32_t*) IFX_ICU_IM4_IER) &= ~X;
+-#define MPS_INTERRUPTS_CLEAR(X) *((volatile IFX_uint32_t*) IFX_ICU_IM4_ISR) = X;
+-#define MPS_INTERRUPTS_SET(X) *((volatile IFX_uint32_t*) IFX_ICU_IM4_IRSR) = X;/* |= ? */
+ #else /* Danube */
+ /* TODO: possibly needs to be changed to IM4 !!!!!! */
+ #ifdef LINUX_2_6
+ #define MPS_INTERRUPTS_ENABLE(X) *((volatile IFX_uint32_t*) IFX_ICU_IM4_IER) |= X;
+ #define MPS_INTERRUPTS_DISABLE(X) *((volatile IFX_uint32_t*) IFX_ICU_IM4_IER) &= ~X;
+-#define MPS_INTERRUPTS_CLEAR(X) *((volatile IFX_uint32_t*) IFX_ICU_IM4_ISR) = X;
+-#define MPS_INTERRUPTS_SET(X) *((volatile IFX_uint32_t*) IFX_ICU_IM4_IRSR) = X;/* |= ? */
+ #else /* */
+ #define MPS_INTERRUPTS_ENABLE(X) *((volatile IFX_uint32_t*) DANUBE_ICU_IM5_IER) |= X;
+ #define MPS_INTERRUPTS_DISABLE(X) *((volatile IFX_uint32_t*) DANUBE_ICU_IM5_IER) &= ~X;
+-#define MPS_INTERRUPTS_CLEAR(X) *((volatile IFX_uint32_t*) DANUBE_ICU_IM5_ISR) = X;
+-#define MPS_INTERRUPTS_SET(X) *((volatile IFX_uint32_t*) DANUBE_ICU_IM5_IRSR) = X;/* |= ? */
+ #endif /* LINUX_2_6 */
+ #endif /* SYSTEM_AR9 || SYSTEM_VR9 */
++#endif /* !defined(CONFIG_LANTIQ) */
++
+ /*---------------------------------------------------------------------------*/
+
+ /*---------------------------------------------------------------------------*/
+@@ -142,53 +188,9 @@
+ #if defined(SYSTEM_AR9) || defined(SYSTEM_VR9)
+ /* ***** Amazon-S specific defines ***** */
+ #define IFX_MPS_Base AMAZON_S_MPS
+-
+-//#define IFX_MPS_CHIPID AMAZON_S_MPS_CHIPID
+-//#define IFX_MPS_CHIPID_VERSION_GET AMAZON_S_MPS_CHIPID_VERSION_GET
+-
+-//#define IFX_MPS_AD0ENR AMAZON_S_MPS_AD0ENR
+-//#define IFX_MPS_AD1ENR AMAZON_S_MPS_AD1ENR
+-//#define IFX_MPS_VC0ENR AMAZON_S_MPS_VC0ENR
+-//#define IFX_MPS_SAD0SR AMAZON_S_MPS_SAD0SR
+-//#define IFX_MPS_RAD0SR AMAZON_S_MPS_RAD0SR
+-//#define IFX_MPS_CAD0SR AMAZON_S_MPS_CAD0SR
+-//#define IFX_MPS_RAD1SR AMAZON_S_MPS_RAD1SR
+-//#define IFX_MPS_CAD1SR AMAZON_S_MPS_CAD1SR
+-//#define IFX_MPS_RVC0SR AMAZON_S_MPS_RVC0SR
+-//#define IFX_MPS_CVC0SR AMAZON_S_MPS_CVC0SR
+-//#define IFX_MPS_CVC1SR AMAZON_S_MPS_CVC1SR
+-//#define IFX_MPS_CVC2SR AMAZON_S_MPS_CVC2SR
+-//#define IFX_MPS_CVC3SR AMAZON_S_MPS_CVC3SR
+-
+-//#define IFX_MPS_SRAM AMAZON_S_MPS_SRAM
+ #else /* */
+ /* ***** DANUBE specific defines ***** */
+ #define IFX_MPS_Base DANUBE_MPS
+-
+-//#define IFX_MPS_CHIPID DANUBE_MPS_CHIPID
+-//#define IFX_MPS_CHIPID_VERSION_GET DANUBE_MPS_CHIPID_VERSION_GET
+-//#define IFX_MPS_CHIPID_VERSION_SET DANUBE_MPS_CHIPID_VERSION_SET
+-//#define IFX_MPS_CHIPID_PARTNUM_GET DANUBE_MPS_CHIPID_PARTNUM_GET
+-//#define IFX_MPS_CHIPID_PARTNUM_SET DANUBE_MPS_CHIPID_PARTNUM_SET
+-//#define IFX_MPS_CHIPID_MANID_GET DANUBE_MPS_CHIPID_MANID_GET
+-//#define IFX_MPS_CHIPID_MANID_SET DANUBE_MPS_CHIPID_MANID_SET
+-//#define IFX_MPS_SUBVER DANUBE_MPS_SUBVER
+-
+-//#define IFX_MPS_AD0ENR DANUBE_MPS_AD0ENR
+-//#define IFX_MPS_AD1ENR DANUBE_MPS_AD1ENR
+-//#define IFX_MPS_VC0ENR DANUBE_MPS_VC0ENR
+-//#define IFX_MPS_SAD0SR DANUBE_MPS_SAD0SR
+-//#define IFX_MPS_RAD0SR DANUBE_MPS_RAD0SR
+-//#define IFX_MPS_CAD0SR DANUBE_MPS_CAD0SR
+-//#define IFX_MPS_RAD1SR DANUBE_MPS_RAD1SR
+-//#define IFX_MPS_CAD1SR DANUBE_MPS_CAD1SR
+-//#define IFX_MPS_RVC0SR DANUBE_MPS_RVC0SR
+-//#define IFX_MPS_CVC0SR DANUBE_MPS_CVC0SR
+-//#define IFX_MPS_CVC1SR DANUBE_MPS_CVC1SR
+-//#define IFX_MPS_CVC2SR DANUBE_MPS_CVC2SR
+-//#define IFX_MPS_CVC3SR DANUBE_MPS_CVC3SR
+-
+-//#define IFX_MPS_SRAM DANUBE_MPS_SRAM
+ #endif /* SYSTEM_AR9 || SYSTEM_VR9 */
+ typedef enum
+ {
+--- a/src/mps/drv_mps_vmmc_linux.c
++++ b/src/mps/drv_mps_vmmc_linux.c
+@@ -57,10 +57,11 @@
+ #include <linux/moduleparam.h>
+ #endif /* */
+
+-
++#if !defined CONFIG_LANTIQ
+ #include <asm/ifx/irq.h>
+ #include <asm/ifx/ifx_regs.h>
+ #include <asm/ifx_vpe.h>
++#endif
+
+ /* lib_ifxos headers */
+ #include "ifx_types.h"
+@@ -959,7 +960,7 @@
+ #endif /* MPS_FIFO_BLOCKING_WRITE */
+ case FIO_MPS_GET_STATUS:
+ {
+- IFX_uint32_t flags;
++ unsigned long flags;
+
+ /* get the status of the channel */
+ if (!from_kernel)
+@@ -993,7 +994,7 @@
+ #if CONFIG_MPS_HISTORY_SIZE > 0
+ case FIO_MPS_GET_CMD_HISTORY:
+ {
+- IFX_uint32_t flags;
++ unsigned long flags;
+
+ if (from_kernel)
+ {
+@@ -1685,6 +1686,7 @@
+ sprintf (buf + len, " minLv: \t %8d\n",
+ ifx_mps_dev.voice_mb[i].upstrm_fifo->min_space);
+ }
++
+ return len;
+ }
+
+@@ -2291,9 +2293,11 @@
+ return result;
+ }
+
++#if !defined(CONFIG_LANTIQ)
++ /** \todo This is handled already with request_irq, remove */
+ /* Enable all MPS Interrupts at ICU0 */
+ MPS_INTERRUPTS_ENABLE (0x0000FF80);
+-
++#endif
+ /* enable mailbox interrupts */
+ ifx_mps_enable_mailbox_int ();
+ /* init FW ready event */
+@@ -2421,9 +2425,11 @@
+ /* disable mailbox interrupts */
+ ifx_mps_disable_mailbox_int ();
+
++#if !defined(CONFIG_LANTIQ)
+ /* disable Interrupts at ICU0 */
+- MPS_INTERRUPTS_DISABLE (DANUBE_MPS_AD0_IR4); /* Disable DFE/AFE 0 Interrupts
+- */
++ /* Disable DFE/AFE 0 Interrupts*/
++ MPS_INTERRUPTS_DISABLE (DANUBE_MPS_AD0_IR4);
++#endif
+
+ /* disable all MPS interrupts */
+ ifx_mps_disable_all_int ();
+--- a/src/drv_vmmc_ioctl.c
++++ b/src/drv_vmmc_ioctl.c
+@@ -18,6 +18,7 @@
+ /* Includes */
+ /* ============================= */
+ #include "drv_api.h"
++#include "drv_vmmc_init.h"
+ #include "drv_vmmc_api.h"
+ #include "drv_vmmc_bbd.h"
+
+Index: drv_vmmc-1.9.0/src/mps/drv_mps_vmmc_danube.c
+===================================================================
+--- drv_vmmc-1.9.0.orig/src/mps/drv_mps_vmmc_danube.c 2012-12-13 08:43:16.080109377 +0100
++++ drv_vmmc-1.9.0/src/mps/drv_mps_vmmc_danube.c 2012-12-13 08:43:48.584110192 +0100
+@@ -44,7 +44,7 @@
+ # include <linux/dma-mapping.h>
+
+
+-#define LQ_RCU_BASE_ADDR (KSEG1 + LTQ_RCU_BASE_ADDR)
++#define LQ_RCU_BASE_ADDR (KSEG1 + 0x1F203000)
+ # define LQ_RCU_RST ((u32 *)(LQ_RCU_BASE_ADDR + 0x0010))
+ #define IFX_RCU_RST_REQ_CPU1 (1 << 3)
+ # define IFX_RCU_RST_REQ LQ_RCU_RST
diff --git a/package/platform/lantiq/ltq-vmmc/patches/.svn/text-base/400-falcon.patch.svn-base b/package/platform/lantiq/ltq-vmmc/patches/.svn/text-base/400-falcon.patch.svn-base
new file mode 100644
index 0000000..490d6e5
--- /dev/null
+++ b/package/platform/lantiq/ltq-vmmc/patches/.svn/text-base/400-falcon.patch.svn-base
@@ -0,0 +1,968 @@
+--- a/configure.in
++++ b/configure.in
+@@ -956,14 +956,15 @@ AC_DEFINE([VMMC],[1],[enable VMMC suppor
+ AM_CONDITIONAL(DANUBE, false)
+ AM_CONDITIONAL(AR9, false)
+ AM_CONDITIONAL(VR9, false)
++AM_CONDITIONAL(FALCON, false)
+ AC_ARG_WITH(device,
+ AC_HELP_STRING(
+- [--with-device=DANUBE|TWINPASS|AR9|VR9],
++ [--with-device=DANUBE|TWINPASS|AR9|VR9|FALCON],
+ [Set device type, default is DANUBE]
+ ),
+ [
+ if test "$withval" = yes; then
+- AC_MSG_ERROR([Set device type! Valid choices are DANUBE|TWINPASS|AR9|VR9]);
++ AC_MSG_ERROR([Set device type! Valid choices are DANUBE|TWINPASS|AR9|VR9|FALCON]);
+ else
+ case $withval in
+ DANUBE)
+@@ -986,8 +987,13 @@ AC_ARG_WITH(device,
+ AC_DEFINE([SYSTEM_VR9],[1],[enable VR9 specific code])
+ AM_CONDITIONAL(VR9, true)
+ ;;
++ FALCON)
++ AC_MSG_RESULT(FALCON device is used);
++ AC_DEFINE([SYSTEM_FALCON],[1],[enable FALCON specific code])
++ AM_CONDITIONAL(FALCON, true)
++ ;;
+ *)
+- AC_MSG_ERROR([Set device type! Valid choices are DANUBE|TWINPASS|AR9|VR9]);
++ AC_MSG_ERROR([Set device type! Valid choices are DANUBE|TWINPASS|AR9|VR9|FALCON]);
+ ;;
+ esac
+ fi
+--- a/src/Makefile.am
++++ b/src/Makefile.am
+@@ -70,6 +70,11 @@ drv_vmmc_SOURCES +=\
+ mps/drv_mps_vmmc_ar9.c
+ endif
+
++if FALCON
++drv_vmmc_SOURCES +=\
++ mps/drv_mps_vmmc_falcon.c
++endif
++
+ endif
+
+ if PMC_SUPPORT
+--- a/drv_version.h
++++ b/drv_version.h
+@@ -36,6 +36,10 @@
+ #define MIN_FW_MAJORSTEP 2
+ #define MIN_FW_MINORSTEP 1
+ #define MIN_FW_HOTFIXSTEP 0
++#elif defined(SYSTEM_FALCON)
++#define MIN_FW_MAJORSTEP 0
++#define MIN_FW_MINORSTEP 1
++#define MIN_FW_HOTFIXSTEP 0
+ #else
+ #error unknown system
+ #endif
+--- a/src/drv_vmmc_bbd.c
++++ b/src/drv_vmmc_bbd.c
+@@ -34,6 +34,7 @@
+ #define VMMC_WL_SDD_BASIC_CFG 0x04000400
+ #define VMMC_WL_SDD_RING_CFG 0x04000500
+ #define VMMC_WL_SDD_DCDC_CFG 0x04000C00
++#define VMMC_WL_SDD_MWI_CFG 0x04000600
+
+ #define IDLE_EXT_TOGGLE_SLEEP_MS 5
+
+@@ -52,6 +53,8 @@
+ #define BBD_VMMC_MAGIC 0x41523921 /* "AR9" */
+ #elif defined(SYSTEM_VR9)
+ #define BBD_VMMC_MAGIC 0x56523921 /* "VR9" */
++#elif defined(SYSTEM_FALCON)
++#define BBD_VMMC_MAGIC 0x46414C43 /* "FALC" */
+ #else
+ #error system undefined
+ #endif
+@@ -525,9 +528,6 @@ static IFX_int32_t VMMC_BBD_BlockHandler
+ IFX_uint16_t slic_val;
+ IFX_int32_t ret = IFX_SUCCESS;
+
+- TRACE(VMMC, DBG_LEVEL_LOW,
+- ("bbd block with tag 0x%04X passed\n", pBBDblock->tag));
+-
+ /* for FXO line allowed blocks are FXO_CRAM and TRANSPARENT */
+ if (pCh->pALM->line_type_fxs != IFX_TRUE)
+ {
+@@ -686,6 +686,7 @@ static IFX_int32_t VMMC_BBD_BlockHandler
+ break;
+ }
+ } /* if */
++
+ return ret;
+ }
+
+@@ -1026,6 +1027,7 @@ static IFX_int32_t vmmc_BBD_WhiteListedC
+ }
+ case VMMC_WL_SDD_RING_CFG:
+ case VMMC_WL_SDD_DCDC_CFG:
++ case VMMC_WL_SDD_MWI_CFG:
+ ret = CmdWrite (pCh->pParent, Msg.val, Msg.cmd.LENGTH);
+ break;
+
+@@ -1068,7 +1070,7 @@ static IFX_int32_t vmmc_BBD_DownloadChCr
+ IFX_uint32_t countWords;
+ IFX_uint32_t posBytes = 0;
+ IFX_uint8_t lenBytes, *pByte;
+-#if defined(SYSTEM_AR9) || defined(SYSTEM_VR9)
++#if defined(SYSTEM_AR9) || defined(SYSTEM_VR9) || defined(SYSTEM_FALCON)
+ IFX_uint8_t padBytes = 0;
+ #endif
+ IFX_uint16_t cram_offset, cram_crc,
+@@ -1088,7 +1090,7 @@ static IFX_int32_t vmmc_BBD_DownloadChCr
+ #ifdef SYSTEM_DANUBE
+ /* CMD1 is a COP command */
+ pCmd[0] = (0x0200) | (pCh->nChannel - 1);
+-#elif defined(SYSTEM_AR9) || defined(SYSTEM_VR9)
++#elif defined(SYSTEM_AR9) || defined(SYSTEM_VR9) || defined(SYSTEM_FALCON)
+ /* SDD_Coef command */
+ pCmd[0] = (0x0400) | (pCh->nChannel - 1);
+ pCmd[1] = (0x0D00);
+@@ -1111,7 +1113,7 @@ static IFX_int32_t vmmc_BBD_DownloadChCr
+ pCmd[1] = ((cram_offset + (posBytes >> 1)) << 8);
+ /* set CRAM data while taking care of endianess */
+ cpb2w (&pCmd[2], &pByte[posBytes], lenBytes);
+-#elif defined(SYSTEM_AR9) || defined(SYSTEM_VR9)
++#elif defined(SYSTEM_AR9) || defined(SYSTEM_VR9) || defined(SYSTEM_FALCON)
+ /* calculate length to download (in words = 16bit),
+ maximum allowed length for this message is 56 Bytes = 28 Words */
+ if (countWords > ((MAX_CMD_WORD - CMD_HDR_CNT - 1)))
+@@ -1140,7 +1142,7 @@ static IFX_int32_t vmmc_BBD_DownloadChCr
+ /* write Data */
+ #if defined SYSTEM_DANUBE
+ ret = CmdWrite (pCh->pParent, (IFX_uint32_t *) pCmd, lenBytes);
+-#elif defined(SYSTEM_AR9) || defined(SYSTEM_VR9)
++#elif defined(SYSTEM_AR9) || defined(SYSTEM_VR9) || defined(SYSTEM_FALCON)
+ #if 1
+ /* lenBytes + 2 bytes for block offset/length which are not calculated
+ in the download progress */
+--- a/src/mps/drv_mps_version.h
++++ b/src/mps/drv_mps_version.h
+@@ -17,7 +17,7 @@
+ #define VERSIONSTEP 2
+ #define VERS_TYPE 5
+
+-#if defined(SYSTEM_AR9) || defined(SYSTEM_VR9)
++#if defined(SYSTEM_AR9) || defined(SYSTEM_VR9) || defined(SYSTEM_FALCON)
+ #define IFX_MPS_PLATFORM_NAME "MIPS34KEc"
+ #elif defined(SYSTEM_DANUBE)
+ #define IFX_MPS_PLATFORM_NAME "MIPS24KEc"
+--- a/src/mps/drv_mps_vmmc_linux.c
++++ b/src/mps/drv_mps_vmmc_linux.c
+@@ -2225,7 +2225,7 @@ IFX_int32_t __init ifx_mps_init_module (
+ #if defined(CONFIG_MIPS) && !defined(CONFIG_MIPS_UNCACHED)
+ #if defined(SYSTEM_DANUBE)
+ bDoCacheOps = IFX_TRUE; /* on Danube always perform cache ops */
+-#elif defined(SYSTEM_AR9) || defined(SYSTEM_VR9)
++#elif defined(SYSTEM_AR9) || defined(SYSTEM_VR9) || defined(SYSTEM_FALCON)
+ /* on AR9/VR9 cache is configured by BSP;
+ here we check whether the D-cache is shared or partitioned;
+ 1) in case of shared D-cache all cache operations are omitted;
+@@ -2255,7 +2255,8 @@ IFX_int32_t __init ifx_mps_init_module (
+
+ /* reset the device before initializing the device driver */
+ ifx_mps_reset ();
+- result = request_irq (INT_NUM_IM4_IRL18,
++
++ result = request_irq (INT_NUM_IM4_IRL18,
+ #ifdef LINUX_2_6
+ ifx_mps_ad0_irq, IRQF_DISABLED
+ #else /* */
+@@ -2396,7 +2397,7 @@ IFX_int32_t __init ifx_mps_init_module (
+ if (result = ifx_mps_init_gpt_danube ())
+ return result;
+ #endif /*DANUBE*/
+- TRACE (MPS, DBG_LEVEL_HIGH, ("Downloading Firmware...\n"));
++ TRACE (MPS, DBG_LEVEL_HIGH, ("Downloading Firmware...\n"));
+ ifx_mps_download_firmware (IFX_NULL, (mps_fw *) 0xa0a00000);
+ udelay (500);
+ TRACE (MPS, DBG_LEVEL_HIGH, ("Providing Buffers...\n"));
+--- /dev/null
++++ b/src/mps/drv_mps_vmmc_falcon.c
+@@ -0,0 +1,463 @@
++/******************************************************************************
++
++ Copyright (c) 2009
++ Lantiq Deutschland GmbH
++ Am Campeon 3; 85579 Neubiberg, Germany
++
++ For licensing information, see the file 'LICENSE' in the root folder of
++ this software module.
++
++****************************************************************************
++ Module : drv_mps_vmmc_falcon.c
++ Description : This file contains the implementation of the FALC-ON specific
++ driver functions.
++*******************************************************************************/
++
++/* ============================= */
++/* Includes */
++/* ============================= */
++#include "drv_config.h"
++
++#if defined(SYSTEM_FALCON) /* defined in drv_config.h */
++
++/* lib_ifxos headers */
++#include "ifx_types.h"
++#include "ifxos_linux_drv.h"
++#include "ifxos_copy_user_space.h"
++#include "ifxos_event.h"
++#include "ifxos_lock.h"
++#include "ifxos_select.h"
++#include "ifxos_interrupt.h"
++#include <linux/gpio.h>
++#include <sys1_reg.h>
++#include <falcon.h>
++#include <falcon_irq.h>
++#include <vpe.h>
++#include <sysctrl.h>
++void (*ifx_bsp_basic_mps_decrypt)(unsigned int addr, int n) = (void (*)(unsigned int, int))0xbf000290;
++
++#define IFX_MPS_SRAM IFXMIPS_MPS_SRAM
++
++/*#define USE_PLAIN_VOICE_FIRMWARE*/
++/* board specific headers */
++
++/* device specific headers */
++#include "drv_mps_vmmc.h"
++#include "drv_mps_vmmc_dbg.h"
++#include "drv_mps_vmmc_device.h"
++
++/* ============================= */
++/* Local Macros & Definitions */
++/* ============================= */
++/* Firmware watchdog timer counter address */
++#define VPE1_WDOG_CTR_ADDR ((IFX_uint32_t)((IFX_uint8_t* )IFX_MPS_SRAM + 432))
++
++/* Firmware watchdog timeout range, values in ms */
++#define VPE1_WDOG_TMOUT_MIN 20
++#define VPE1_WDOG_TMOUT_MAX 5000
++
++/* ============================= */
++/* Global variable definition */
++/* ============================= */
++extern mps_comm_dev *pMPSDev;
++
++/* ============================= */
++/* Global function declaration */
++/* ============================= */
++IFX_void_t ifx_mps_release (IFX_void_t);
++extern IFX_uint32_t ifx_mps_reset_structures (mps_comm_dev * pMPSDev);
++extern IFX_int32_t ifx_mps_bufman_close (IFX_void_t);
++IFX_int32_t ifx_mps_wdog_callback (IFX_uint32_t wdog_cleared_ok_count);
++extern IFXOS_event_t fw_ready_evt;
++/* ============================= */
++/* Local function declaration */
++/* ============================= */
++static IFX_int32_t ifx_mps_fw_wdog_start_ar9(IFX_void_t);
++
++/* ============================= */
++/* Local variable definition */
++/* ============================= */
++static IFX_int32_t vpe1_started = 0;
++/* VMMC watchdog timer callback */
++IFX_int32_t (*ifx_wdog_callback) (IFX_uint32_t flags) = IFX_NULL;
++
++/* ============================= */
++/* Local function definition */
++/* ============================= */
++
++/******************************************************************************
++ * AR9 Specific Routines
++ ******************************************************************************/
++
++/**
++ * Start AR9 EDSP firmware watchdog mechanism.
++ * Called after download and startup of VPE1.
++ *
++ * \param none
++ * \return 0 IFX_SUCCESS
++ * \return -1 IFX_ERROR
++ * \ingroup Internal
++ */
++IFX_int32_t ifx_mps_fw_wdog_start_ar9()
++{
++ return IFX_SUCCESS;
++}
++
++/**
++ * Firmware download to Voice CPU
++ * This function performs a firmware download to the coprocessor.
++ *
++ * \param pMBDev Pointer to mailbox device structure
++ * \param pFWDwnld Pointer to firmware structure
++ * \return 0 IFX_SUCCESS, firmware ready
++ * \return -1 IFX_ERROR, firmware not downloaded.
++ * \ingroup Internal
++ */
++IFX_int32_t ifx_mps_download_firmware (mps_mbx_dev *pMBDev, mps_fw *pFWDwnld)
++{
++ IFX_uint32_t mem, cksum;
++ IFX_uint8_t crc;
++ IFX_boolean_t bMemReqNotPresent = IFX_FALSE;
++
++ /* VCC register */
++ /* dummy accesss on GTC for GPONC-55, otherwise upper bits are random on read */
++ ltq_r32 ((u32 *)((KSEG1 | 0x1DC000B0)));
++ /* NTR Frequency Select 1536 kHz per default or take existing,
++ NTR Output Enable and NTR8K Output Enable */
++ if ((ltq_r32 ((u32 *)(GPON_SYS_BASE + 0xBC)) & 7) == 0)
++ ltq_w32_mask (0x10187, 0x183, (u32 *)(GPON_SYS_BASE + 0xBC));
++ else
++ ltq_w32_mask (0x10180, 0x180, (u32 *)(GPON_SYS_BASE + 0xBC));
++#if 0
++ /* BIU-ICU1-IM1_ISR - IM1:FSCT_CMP1=1 and FSC_ROOT=1
++ (0x1f880328 = 0x00002800) */
++ ltq_w32 (0x00002800, (u32 *)(GPON_ICU1_BASE + 0x30));
++#endif
++ /* copy FW footer from user space */
++ if (IFX_NULL == IFXOS_CpyFromUser(pFW_img_data,
++ pFWDwnld->data+pFWDwnld->length/4-sizeof(*pFW_img_data)/4,
++ sizeof(*pFW_img_data)))
++ {
++ TRACE (MPS, DBG_LEVEL_HIGH,
++ (KERN_ERR "[%s %s %d]: copy_from_user error\r\n",
++ __FILE__, __func__, __LINE__));
++ return IFX_ERROR;
++ }
++
++ mem = pFW_img_data->mem;
++
++ /* memory requirement sanity check */
++ if ((crc = ~((mem >> 16) + (mem >> 8) + mem)) != (mem >> 24))
++ {
++ TRACE (MPS, DBG_LEVEL_HIGH,
++ ("[%s %s %d]: warning, image does not contain size - assuming 1MB!\n",
++ __FILE__, __func__, __LINE__));
++ mem = 1 * 1024 * 1024;
++ bMemReqNotPresent = IFX_TRUE;
++ }
++ else
++ {
++ mem &= 0x00FFFFFF;
++ }
++
++ /* check if FW image fits in available memory space */
++ if (mem > vpe1_get_max_mem(0))
++ {
++ TRACE (MPS, DBG_LEVEL_HIGH,
++ ("[%s %s %d]: error, firmware memory exceeds reserved space (%i > %i)!\n",
++ __FILE__, __func__, __LINE__, mem, vpe1_get_max_mem(0)));
++ return IFX_ERROR;
++ }
++
++ /* reset the driver */
++ ifx_mps_reset ();
++
++ /* call BSP to get cpu1 base address */
++ cpu1_base_addr = (IFX_uint32_t *)vpe1_get_load_addr(0);
++
++ /* check if CPU1 base address is sane
++ \todo: check if address is 1MB aligned,
++ also make it visible in a /proc fs */
++ if (!cpu1_base_addr)
++ {
++ TRACE (MPS, DBG_LEVEL_HIGH,
++ (KERN_ERR "IFX_MPS: CPU1 base address is invalid!\r\n"));
++ return IFX_ERROR;
++ }
++ /* further use uncached value */
++ cpu1_base_addr = (IFX_uint32_t *)KSEG1ADDR(cpu1_base_addr);
++
++ /* free all data buffers that might be currently used by FW */
++ if (IFX_NULL != ifx_mps_bufman_freeall)
++ {
++ ifx_mps_bufman_freeall();
++ }
++
++ if(FW_FORMAT_NEW)
++ {
++ /* adjust download length */
++ pFWDwnld->length -= (sizeof(*pFW_img_data)-sizeof(IFX_uint32_t));
++ }
++ else
++ {
++ pFWDwnld->length -= sizeof(IFX_uint32_t);
++
++ /* handle unlikely case if FW image does not contain memory requirement -
++ assumed for old format only */
++ if (IFX_TRUE == bMemReqNotPresent)
++ pFWDwnld->length += sizeof(IFX_uint32_t);
++
++ /* in case of old FW format always assume that FW is encrypted;
++ use compile switch USE_PLAIN_VOICE_FIRMWARE for plain FW */
++#ifndef USE_PLAIN_VOICE_FIRMWARE
++ pFW_img_data->enc = 1;
++#else
++#warning Using unencrypted firmware!
++ pFW_img_data->enc = 0;
++#endif /* USE_PLAIN_VOICE_FIRMWARE */
++ /* initializations for the old format */
++ pFW_img_data->st_addr_crc = 2*sizeof(IFX_uint32_t) +
++ FW_AR9_OLD_FMT_XCPT_AREA_SZ;
++ pFW_img_data->en_addr_crc = pFWDwnld->length;
++ pFW_img_data->fw_vers = 0;
++ pFW_img_data->magic = 0;
++ }
++
++ /* copy FW image to base address of CPU1 */
++ if (IFX_NULL ==
++ IFXOS_CpyFromUser ((IFX_void_t *)cpu1_base_addr,
++ (IFX_void_t *)pFWDwnld->data, pFWDwnld->length))
++ {
++ TRACE (MPS, DBG_LEVEL_HIGH,
++ (KERN_ERR "[%s %s %d]: copy_from_user error\r\n", __FILE__,
++ __func__, __LINE__));
++ return IFX_ERROR;
++ }
++
++ /* process firmware decryption */
++ if (pFW_img_data->enc == 1)
++ {
++ if(FW_FORMAT_NEW)
++ {
++ /* adjust decryption length (avoid decrypting CRC32 checksum) */
++ pFWDwnld->length -= sizeof(IFX_uint32_t);
++ }
++ /* BootROM actually decrypts n+4 bytes if n bytes were passed for
++ decryption. Subtract sizeof(u32) from length to avoid decryption
++ of data beyond the FW image code */
++ pFWDwnld->length -= sizeof(IFX_uint32_t);
++ ifx_bsp_basic_mps_decrypt((unsigned int)cpu1_base_addr, pFWDwnld->length);
++ }
++
++ /* calculate CRC32 checksum over downloaded image */
++ cksum = ifx_mps_fw_crc32(cpu1_base_addr, pFW_img_data);
++
++ /* verify the checksum */
++ if(FW_FORMAT_NEW)
++ {
++ if (cksum != pFW_img_data->crc32)
++ {
++ TRACE (MPS, DBG_LEVEL_HIGH,
++ ("MPS: FW checksum error: img=0x%08x calc=0x%08x\r\n",
++ pFW_img_data->crc32, cksum));
++ /*return IFX_ERROR;*/
++ }
++ }
++ else
++ {
++ /* just store self-calculated checksum */
++ pFW_img_data->crc32 = cksum;
++ }
++
++ /* start VPE1 */
++ ifx_mps_release ();
++#if 0
++ /* start FW watchdog mechanism */
++ ifx_mps_fw_wdog_start_ar9();
++#endif
++ /* get FW version */
++ return ifx_mps_get_fw_version (0);
++}
++
++
++/**
++ * Restart CPU1
++ * This function restarts CPU1 by accessing the reset request register and
++ * reinitializes the mailbox.
++ *
++ * \return 0 IFX_SUCCESS, successful restart
++ * \return -1 IFX_ERROR, if reset failed
++ * \ingroup Internal
++ */
++IFX_int32_t ifx_mps_restart (IFX_void_t)
++{
++ /* raise reset request for CPU1 and reset driver structures */
++ ifx_mps_reset ();
++ /* Disable GPTC Interrupt to CPU1 */
++ ifx_mps_shutdown_gpt ();
++ /* re-configure GPTC */
++ ifx_mps_init_gpt ();
++ /* let CPU1 run */
++ ifx_mps_release ();
++ /* start FW watchdog mechanism */
++ ifx_mps_fw_wdog_start_ar9();
++ TRACE (MPS, DBG_LEVEL_HIGH, ("IFX_MPS: Restarting firmware..."));
++ return ifx_mps_get_fw_version (0);
++}
++
++/**
++ * Shutdown MPS - stop VPE1
++ * This function stops VPE1
++ *
++ * \ingroup Internal
++ */
++IFX_void_t ifx_mps_shutdown (IFX_void_t)
++{
++ if (vpe1_started)
++ {
++ /* stop software watchdog timer */
++ vpe1_sw_wdog_stop (0);
++ /* clean up the BSP callback function */
++ vpe1_sw_wdog_register_reset_handler (IFX_NULL);
++ /* stop VPE1 */
++ vpe1_sw_stop (0);
++ vpe1_started = 0;
++ }
++ /* free GPTC */
++ ifx_mps_shutdown_gpt ();
++}
++
++/**
++ * Reset CPU1
++ * This function causes a reset of CPU1 by clearing the CPU0 boot ready bit
++ * in the reset request register RCU_RST_REQ.
++ * It does not change the boot configuration registers for CPU0 or CPU1.
++ *
++ * \return 0 IFX_SUCCESS, cannot fail
++ * \ingroup Internal
++ */
++IFX_void_t ifx_mps_reset (IFX_void_t)
++{
++ /* if VPE1 is already started, stop it */
++ if (vpe1_started)
++ {
++ /* stop software watchdog timer first */
++ vpe1_sw_wdog_stop (0);
++ vpe1_sw_stop (0);
++ vpe1_started = 0;
++ }
++
++ /* reset driver */
++ ifx_mps_reset_structures (pMPSDev);
++ ifx_mps_bufman_close ();
++ return;
++}
++
++/**
++ * Let CPU1 run
++ * This function starts VPE1
++ *
++ * \return none
++ * \ingroup Internal
++ */
++IFX_void_t ifx_mps_release (IFX_void_t)
++{
++ IFX_int_t ret;
++ IFX_int32_t RetCode = 0;
++
++ /* Start VPE1 */
++ if (IFX_SUCCESS !=
++ vpe1_sw_start ((IFX_void_t *)cpu1_base_addr, 0, 0))
++ {
++ TRACE (MPS, DBG_LEVEL_HIGH, (KERN_ERR "Error starting VPE1\r\n"));
++ return;
++ }
++ vpe1_started = 1;
++
++ /* sleep 3 seconds until FW is ready */
++ ret = IFXOS_EventWait (&fw_ready_evt, 3000, &RetCode);
++ if ((ret == IFX_ERROR) && (RetCode == 1))
++ {
++ /* timeout */
++ TRACE (MPS, DBG_LEVEL_HIGH,
++ (KERN_ERR "[%s %s %d]: Timeout waiting for firmware ready.\r\n",
++ __FILE__, __func__, __LINE__));
++ /* recalculate and compare the firmware checksum */
++ ifx_mps_fw_crc_compare(cpu1_base_addr, pFW_img_data);
++ /* dump exception area on a console */
++ ifx_mps_dump_fw_xcpt(cpu1_base_addr, pFW_img_data);
++ }
++}
++
++/**
++ * WDT callback.
++ * This function is called by BSP (module softdog_vpe) in case if software
++ * watchdog timer expiration is detected by BSP.
++ * This function needs to be registered at BSP as WDT callback using
++ * vpe1_sw_wdog_register_reset_handler() API.
++ *
++ * \return 0 IFX_SUCCESS, cannot fail
++ * \ingroup Internal
++ */
++IFX_int32_t ifx_mps_wdog_callback (IFX_uint32_t wdog_cleared_ok_count)
++{
++#ifdef DEBUG
++ TRACE (MPS, DBG_LEVEL_HIGH,
++ ("MPS: watchdog callback! arg=0x%08x\r\n", wdog_cleared_ok_count));
++#endif /* DEBUG */
++
++ /* reset SmartSLIC is done by FW */
++ /* recalculate and compare the firmware checksum */
++ ifx_mps_fw_crc_compare(cpu1_base_addr, pFW_img_data);
++
++ /* dump exception area on a console */
++ ifx_mps_dump_fw_xcpt(cpu1_base_addr, pFW_img_data);
++
++ if (IFX_NULL != ifx_wdog_callback)
++ {
++ /* call VMMC driver */
++ ifx_wdog_callback (wdog_cleared_ok_count);
++ }
++ else
++ {
++ TRACE (MPS, DBG_LEVEL_HIGH,
++ (KERN_WARNING "MPS: VMMC watchdog timer callback is NULL.\r\n"));
++ }
++ return 0;
++}
++
++/**
++ * Register WDT callback.
++ * This function is called by VMMC driver to register its callback in
++ * the MPS driver.
++ *
++ * \return 0 IFX_SUCCESS, cannot fail
++ * \ingroup Internal
++ */
++IFX_int32_t
++ifx_mps_register_wdog_callback (IFX_int32_t (*pfn) (IFX_uint32_t flags))
++{
++ ifx_wdog_callback = pfn;
++ return 0;
++}
++
++/**
++ Hardware setup on FALC ON
++*/
++void sys_hw_setup (void)
++{
++ /* Set INFRAC register bit 1: clock enable of the GPE primary clock. */
++ sys_gpe_hw_activate (0);
++ /* enable 1.5 V */
++ ltq_w32_mask (0xf, 0x0b, (u32 *)(GPON_SYS1_BASE | 0xbc));
++ /* SYS1-CLKEN:GPTC = 1 and MPS, no longer FSCT = 1 */
++ sys1_hw_activate (ACTS_MPS | ACTS_GPTC);
++ /* GPTC:CLC:RMC = 1 */
++ ltq_w32 (0x00000100, (u32 *)(KSEG1 | 0x1E100E00));
++}
++
++#ifndef VMMC_WITH_MPS
++EXPORT_SYMBOL (ifx_mps_register_wdog_callback);
++#endif /* !VMMC_WITH_MPS */
++
++#endif /* SYSTEM_FALCON */
+--- a/src/mps/drv_mps_vmmc_common.c
++++ b/src/mps/drv_mps_vmmc_common.c
+@@ -66,6 +66,10 @@ static void inline bsp_mask_and_ack_irq(
+ # include <asm/ifx/ifx_regs.h>
+ # include <asm/ifx/ifx_gptu.h>
+ #endif
++#if defined(SYSTEM_FALCON)
++#include <sys1_reg.h>
++#include <sysctrl.h>
++#endif
+
+ #include "drv_mps_vmmc.h"
+ #include "drv_mps_vmmc_dbg.h"
+@@ -1156,7 +1160,12 @@ IFX_uint32_t ifx_mps_init_structures (mp
+ mailbox, * upstream and downstream direction. */
+ memset (
+ /* avoid to overwrite CPU boot registers */
++#if defined(SYSTEM_FALCON)
++ (IFX_void_t *) MBX_Memory +
++ 2 * sizeof (mps_boot_cfg_reg),
++#else
+ (IFX_void_t *) MBX_Memory,
++#endif
+ 0,
+ sizeof (mps_mbx_reg) - 2 * sizeof (mps_boot_cfg_reg));
+ MBX_Memory->MBX_UPSTR_CMD_BASE =
+@@ -2651,7 +2660,6 @@ IFX_void_t ifx_mps_enable_mailbox_int ()
+ #endif
+
+ *IFX_MPS_AD0ENR = Ad0Reg.val;
+-
+ }
+
+ /**
+@@ -2669,6 +2677,7 @@ IFX_void_t ifx_mps_disable_mailbox_int (
+ Ad0Reg.fld.cu_mbx = 0;
+ Ad0Reg.fld.du_mbx = 0;
+ *IFX_MPS_AD0ENR = Ad0Reg.val;
++
+ }
+
+ /**
+@@ -2766,11 +2775,13 @@ irqreturn_t ifx_mps_ad0_irq (IFX_int32_t
+ /* handle only enabled interrupts */
+ MPS_Ad0StatusReg.val &= *IFX_MPS_AD0ENR;
+
++#if !defined(SYSTEM_FALCON)
+ #ifdef LINUX_2_6
+ bsp_mask_and_ack_irq (irq);
+ #else /* */
+ mask_and_ack_danube_irq (irq);
+ #endif /* */
++#endif /* !defined(SYSTEM_FALCON) */
+ /* FW is up and ready to process commands */
+ if (MPS_Ad0StatusReg.fld.dl_end)
+ {
+@@ -2919,11 +2930,13 @@ irqreturn_t ifx_mps_ad1_irq (IFX_int32_t
+ /* handle only enabled interrupts */
+ MPS_Ad1StatusReg.val &= *IFX_MPS_AD1ENR;
+
++#if !defined(SYSTEM_FALCON)
+ #ifdef LINUX_2_6
+ bsp_mask_and_ack_irq (irq);
+ #else /* */
+ mask_and_ack_danube_irq (irq);
+ #endif /* */
++#endif /* !defined(SYSTEM_FALCON) */
+ pMPSDev->event.MPS_Ad1Reg.val = MPS_Ad1StatusReg.val;
+
+ /* use callback function or queue wake up to notify about data reception */
+@@ -2977,11 +2990,13 @@ irqreturn_t ifx_mps_vc_irq (IFX_int32_t
+ IFX_MPS_CVC0SR[chan] = MPS_VCStatusReg.val;
+ /* handle only enabled interrupts */
+ MPS_VCStatusReg.val &= IFX_MPS_VC0ENR[chan];
++#if !defined(SYSTEM_FALCON)
+ #ifdef LINUX_2_6
+ bsp_mask_and_ack_irq (irq);
+ #else /* */
+ mask_and_ack_danube_irq (irq);
+ #endif /* */
++#endif /* !defined(SYSTEM_FALCON) */
+
+ pMPSDev->event.MPS_VCStatReg[chan].val = MPS_VCStatusReg.val;
+ #ifdef PRINT_ON_ERR_INTERRUPT
+@@ -3126,6 +3141,7 @@ IFX_int32_t ifx_mps_get_fw_version (IFX_
+ */
+ IFX_return_t ifx_mps_init_gpt ()
+ {
++#if !defined(SYSTEM_FALCON)
+ unsigned long flags;
+ IFX_uint32_t timer_flags, timer, loops = 0;
+ IFX_ulong_t count;
+@@ -3134,7 +3150,11 @@ IFX_return_t ifx_mps_init_gpt ()
+ #else /* Danube */
+ timer = TIMER1B;
+ #endif /* SYSTEM_AR9 || SYSTEM_VR9 */
++#endif
+
++#if defined(SYSTEM_FALCON)
++ sys_hw_setup ();
++#else
+ /* calibration loop - required to syncronize GPTC interrupt with falling
+ edge of FSC clock */
+ timer_flags =
+@@ -3179,7 +3199,7 @@ Probably already in use.\r\n", __FILE__,
+ #endif /* DEBUG */
+
+ IFXOS_UNLOCKINT (flags);
+-
++#endif
+ return IFX_SUCCESS;
+ }
+
+@@ -3194,6 +3214,9 @@ Probably already in use.\r\n", __FILE__,
+ */
+ IFX_void_t ifx_mps_shutdown_gpt (IFX_void_t)
+ {
++#if defined(SYSTEM_FALCON)
++ sys1_hw_deactivate (ACTS_MPS);
++#else
+ IFX_uint32_t timer;
+ #if defined(SYSTEM_AR9) || defined(SYSTEM_VR9)
+ timer = TIMER1A;
+@@ -3202,6 +3225,7 @@ IFX_void_t ifx_mps_shutdown_gpt (IFX_voi
+ #endif /* SYSTEM_AR9 || SYSTEM_VR9 */
+
+ ifx_gptu_timer_free (timer);
++#endif
+ }
+
+ /**
+--- a/src/mps/drv_mps_vmmc_device.h
++++ b/src/mps/drv_mps_vmmc_device.h
+@@ -22,7 +22,12 @@
+ # include <lantiq_soc.h>
+ # include <gpio.h>
+ #define IFXMIPS_MPS_SRAM ((u32 *)(KSEG1 + 0x1F200000))
++#if defined(SYSTEM_FALCON)
++#define IFXMIPS_MPS_BASE_ADDR (KSEG1 + 0x1D004000)
++#else
+ #define IFXMIPS_MPS_BASE_ADDR (KSEG1 + 0x1F107000)
++#endif
++
+ #define IFXMIPS_MPS_CHIPID ((u32 *)(IFXMIPS_MPS_BASE_ADDR + 0x0344))
+ #define IFXMIPS_MPS_VC0ENR ((u32 *)(IFXMIPS_MPS_BASE_ADDR + 0x0000))
+ #define IFXMIPS_MPS_RVC0SR ((u32 *)(IFXMIPS_MPS_BASE_ADDR + 0x0010))
+@@ -73,10 +78,11 @@
+ /* MPS Common defines */
+ /* ============================= */
+
+-#define MPS_BASEADDRESS 0xBF107000
+-#define MPS_RAD0SR MPS_BASEADDRESS + 0x0004
+-
++#if defined(SYSTEM_FALCON)
++#define MBX_BASEADDRESS 0xBF200040
++#else
+ #define MBX_BASEADDRESS 0xBF200000
++#endif
+ #define VCPU_BASEADDRESS 0xBF208000 /* 0xBF108000 */
+ /*---------------------------------------------------------------------------*/
+ #if !defined(CONFIG_LANTIQ)
+@@ -118,7 +124,6 @@
+ /*---------------------------------------------------------------------------*/
+
+ #ifdef CONFIG_MPS_EVENT_MBX
+-
+ #define MBX_CMD_FIFO_SIZE 64 /**< Size of command FIFO in bytes */
+ #define MBX_DATA_UPSTRM_FIFO_SIZE 64
+ #define MBX_DATA_DNSTRM_FIFO_SIZE 128
+@@ -294,6 +299,10 @@ typedef struct
+ #ifdef CONFIG_MPS_EVENT_MBX
+ typedef struct
+ {
++#if defined(SYSTEM_FALCON)
++ mps_boot_cfg_reg MBX_CPU0_BOOT_CFG; /**< CPU0 Boot Configuration */
++ mps_boot_cfg_reg MBX_CPU1_BOOT_CFG; /**< CPU1 Boot Configuration */
++#endif
+ volatile IFX_uint32_t *MBX_UPSTR_CMD_BASE; /**< Upstream Command FIFO Base Address */
+ volatile IFX_uint32_t MBX_UPSTR_CMD_SIZE; /**< Upstream Command FIFO size in byte */
+ volatile IFX_uint32_t *MBX_DNSTR_CMD_BASE; /**< Downstream Command FIFO Base Address */
+@@ -317,13 +326,19 @@ typedef struct
+ volatile IFX_uint32_t MBX_UPSTR_EVENT_WRITE; /**< Upstream Event FIFO Write Index */
+ volatile IFX_uint32_t MBX_EVENT[MBX_EVENT_DATA_WORDS];
+ volatile IFX_uint32_t reserved[4];
++#if !defined(SYSTEM_FALCON)
+ mps_boot_cfg_reg MBX_CPU0_BOOT_CFG; /**< CPU0 Boot Configuration */
+ mps_boot_cfg_reg MBX_CPU1_BOOT_CFG; /**< CPU1 Boot Configuration */
++#endif
+ } mps_mbx_reg;
+
+ #else /* */
+ typedef struct
+ {
++#if defined(SYSTEM_FALCON)
++ mps_boot_cfg_reg MBX_CPU0_BOOT_CFG; /**< CPU0 Boot Configuration */
++ mps_boot_cfg_reg MBX_CPU1_BOOT_CFG; /**< CPU1 Boot Configuration */
++#endif
+ volatile IFX_uint32_t *MBX_UPSTR_CMD_BASE; /**< Upstream Command FIFO Base Address */
+ volatile IFX_uint32_t MBX_UPSTR_CMD_SIZE; /**< Upstream Command FIFO size in byte */
+ volatile IFX_uint32_t *MBX_DNSTR_CMD_BASE; /**< Downstream Command FIFO Base Address */
+@@ -341,8 +356,10 @@ typedef struct
+ volatile IFX_uint32_t MBX_DNSTR_DATA_READ; /**< Downstream Data FIFO Read Index */
+ volatile IFX_uint32_t MBX_DNSTR_DATA_WRITE; /**< Downstream Data FIFO Write Index */
+ volatile IFX_uint32_t MBX_DATA[MBX_DATA_WORDS];
++#if !defined(SYSTEM_FALCON)
+ mps_boot_cfg_reg MBX_CPU0_BOOT_CFG; /**< CPU0 Boot Configuration */
+ mps_boot_cfg_reg MBX_CPU1_BOOT_CFG; /**< CPU1 Boot Configuration */
++#endif
+ } mps_mbx_reg;
+ #endif /* CONFIG_MPS_EVENT_MBX */
+
+--- a/src/drv_api.h
++++ b/src/drv_api.h
+@@ -183,7 +183,7 @@
+ #endif
+
+ /* TAPI FXS Phone Detection feature is not available for Danube platform */
+-#if defined(TAPI_PHONE_DETECTION) && (defined(SYSTEM_AR9) || defined(SYSTEM_VR9))
++#if defined(TAPI_PHONE_DETECTION) && (defined(SYSTEM_AR9) || defined(SYSTEM_VR9) || defined(SYSTEM_FALCON))
+ #define VMMC_CFG_ADD_FEAT_PHONE_DETECTION VMMC_FEAT_PHONE_DETECTION
+ #else
+ #define VMMC_CFG_ADD_FEAT_PHONE_DETECTION 0
+--- a/src/drv_vmmc_alm.c
++++ b/src/drv_vmmc_alm.c
+@@ -800,7 +800,7 @@ IFX_void_t VMMC_ALM_Free_Ch_Structures (
+ }
+
+
+-#if defined(SYSTEM_AR9) || defined(SYSTEM_VR9)
++#if defined(SYSTEM_AR9) || defined(SYSTEM_VR9) || defined(SYSTEM_FALCON)
+ /**
+ Check whether SmartSLIC is connected
+
+@@ -836,7 +836,7 @@ IFX_boolean_t VMMC_ALM_SmartSLIC_IsConne
+ #endif /*SYSTEM_AR9 || SYSTEM_VR9*/
+
+
+-#if defined(SYSTEM_AR9) || defined(SYSTEM_VR9)
++#if defined(SYSTEM_AR9) || defined(SYSTEM_VR9) || defined(SYSTEM_FALCON)
+ /**
+ Read the number of channels on the SmartSLIC.
+
+@@ -1876,7 +1876,7 @@ IFX_int32_t VMMC_TAPI_LL_ALM_VMMC_Test_L
+ /* write updated message contents */
+ ret = CmdWrite (pDev, (IFX_uint32_t *)((IFX_void_t *)&debugCfg),
+ DCCTL_CMD_LEN);
+-#elif defined(SYSTEM_AR9) || defined(SYSTEM_VR9)
++#elif defined(SYSTEM_AR9) || defined(SYSTEM_VR9) || defined(SYSTEM_FALCON)
+ IFX_uint32_t dcctrlLoop[2];
+ IFX_uint32_t ch = (IFX_uint32_t)(pCh->nChannel - 1);
+
+--- a/src/drv_vmmc_alm.h
++++ b/src/drv_vmmc_alm.h
+@@ -65,7 +65,7 @@ extern IFX_void_t irq_VMMC_ALM_LineDisab
+ extern IFX_void_t VMMC_ALM_CorrectLinemodeCache (VMMC_CHANNEL *pCh,
+ IFX_uint16_t lm);
+
+-#if defined(SYSTEM_AR9) || defined(SYSTEM_VR9)
++#if defined(SYSTEM_AR9) || defined(SYSTEM_VR9) || defined(SYSTEM_FALCON)
+ extern IFX_boolean_t VMMC_ALM_SmartSLIC_IsConnected (
+ VMMC_DEVICE *pDev);
+
+--- a/src/drv_vmmc_init.c
++++ b/src/drv_vmmc_init.c
+@@ -52,15 +52,6 @@
+ #include "ifx_pmu.h"
+ #endif /* PMU_SUPPORTED */
+
+-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,28))
+-# define IFX_MPS_CAD0SR IFXMIPS_MPS_CAD0SR
+-# define IFX_MPS_CAD1SR IFXMIPS_MPS_CAD1SR
+-# define IFX_MPS_CVC0SR IFXMIPS_MPS_CVC0SR
+-# define IFX_MPS_CVC1SR IFXMIPS_MPS_CVC1SR
+-# define IFX_MPS_CVC2SR IFXMIPS_MPS_CVC2SR
+-# define IFX_MPS_CVC3SR IFXMIPS_MPS_CVC3SR
+-#endif
+-
+ /* ============================= */
+ /* Local Macros & Definitions */
+ /* ============================= */
+@@ -820,7 +811,7 @@ static IFX_int32_t VMMC_TAPI_LL_FW_Init(
+ MIN_FW_HOTFIXSTEP};
+ IFX_uint8_t tmp1, tmp2;
+ IFX_TAPI_RESOURCE nResource;
+-#if defined(SYSTEM_AR9) || defined(SYSTEM_VR9)
++#if defined(SYSTEM_AR9) || defined(SYSTEM_VR9) || defined(SYSTEM_FALCON)
+ IFX_uint8_t nChannels, nFXOChannels;
+ #endif /*SYSTEM_AR9 || SYSTEM_VR9*/
+ IFX_int32_t ret = VMMC_statusOk;
+@@ -874,7 +865,7 @@ static IFX_int32_t VMMC_TAPI_LL_FW_Init(
+ pDev->bSmartSlic = IFX_FALSE;
+ pDev->bSlicSupportsIdleMode = IFX_FALSE;
+
+-#if defined(SYSTEM_AR9) || defined(SYSTEM_VR9)
++#if defined(SYSTEM_AR9) || defined(SYSTEM_VR9) || defined(SYSTEM_FALCON)
+ if (VMMC_SUCCESS(ret))
+ {
+ /* Reduce the number of ALM channels in the capabilities if the SLIC
+--- a/src/drv_vmmc_ioctl.c
++++ b/src/drv_vmmc_ioctl.c
+@@ -273,7 +273,7 @@ IFX_int32_t VMMC_Dev_Spec_Ioctl (IFX_TAP
+ case FIO_GET_VERS:
+ {
+ VMMC_IO_VERSION *pVers;
+-#if defined(SYSTEM_AR9) || defined(SYSTEM_VR9)
++#if defined(SYSTEM_AR9) || defined(SYSTEM_VR9) || defined(SYSTEM_FALCON)
+ VMMC_SDD_REVISION_READ_t *pSDDVersCmd = IFX_NULL;
+ #endif /*SYSTEM_AR9 || SYSTEM_VR9*/
+ SYS_VER_t *pCmd;
+@@ -322,7 +322,7 @@ IFX_int32_t VMMC_Dev_Spec_Ioctl (IFX_TAP
+ pVers->nTapiVers = 3;
+ pVers->nDrvVers = MAJORSTEP << 24 | MINORSTEP << 16 |
+ VERSIONSTEP << 8 | VERS_TYPE;
+-#if defined(SYSTEM_AR9) || defined(SYSTEM_VR9)
++#if defined(SYSTEM_AR9) || defined(SYSTEM_VR9) || defined(SYSTEM_FALCON)
+ /* in case of SmartSLIC based systems, we can give some more
+ versions.*/
+ if (VMMC_ALM_SmartSLIC_IsConnected(pDev))
diff --git a/package/platform/lantiq/ltq-vmmc/patches/000-portability.patch b/package/platform/lantiq/ltq-vmmc/patches/000-portability.patch
new file mode 100644
index 0000000..4860247
--- /dev/null
+++ b/package/platform/lantiq/ltq-vmmc/patches/000-portability.patch
@@ -0,0 +1,287 @@
+--- a/src/Makefile.am
++++ b/src/Makefile.am
+@@ -228,7 +228,7 @@ drv_vmmc_CFLAGS += -fno-common
+ drv_vmmc_OBJS = "$(subst .c,.o, $(drv_vmmc_SOURCES) $(nodist_drv_vmmc_SOURCES))"
+
+ drv_vmmc.ko: $(drv_vmmc_SOURCES) $(EXTRA_DIST)
+- @echo -e "Making Linux 2.6.x kernel object"
++ @echo "Making Linux 2.6.x kernel object"
+ @for f in $(drv_vmmc_SOURCES) $(nodist_drv_vmmc_SOURCES) ; do \
+ if test ! -e $(PWD)/$$f; then \
+ echo " LN $$f" ; \
+@@ -236,10 +236,10 @@ drv_vmmc.ko: $(drv_vmmc_SOURCES) $(EXTRA
+ ln -s @abs_srcdir@/$$f $(PWD)/$$f; \
+ fi; \
+ done;
+- @echo -e "# drv_vmmc: Generated to build Linux 2.6.x kernel object" > $(PWD)/Kbuild
+- @echo -e "obj-m := $(subst .ko,.o,$@)" >> $(PWD)/Kbuild
+- @echo -e "$(subst .ko,,$@)-y := $(drv_vmmc_OBJS)" >> $(PWD)/Kbuild
+- @echo -e "EXTRA_CFLAGS := -DHAVE_CONFIG_H $(CFLAGS) $(drv_vmmc_CFLAGS) $(INCLUDES)" >> $(PWD)/Kbuild
++ @echo "# drv_vmmc: Generated to build Linux 2.6.x kernel object" > $(PWD)/Kbuild
++ @echo "obj-m := $(subst .ko,.o,$@)" >> $(PWD)/Kbuild
++ @echo "$(subst .ko,,$@)-y := $(drv_vmmc_OBJS)" >> $(PWD)/Kbuild
++ @echo "EXTRA_CFLAGS := -DHAVE_CONFIG_H $(CFLAGS) $(drv_vmmc_CFLAGS) $(INCLUDES)" >> $(PWD)/Kbuild
+ $(MAKE) ARCH=@KERNEL_ARCH@ -C @KERNEL_BUILD_PATH@ O=@KERNEL_BUILD_PATH@ M=$(PWD) modules
+
+ clean-generic:
+--- a/src/drv_vmmc_linux.c
++++ b/src/drv_vmmc_linux.c
+@@ -27,11 +27,18 @@
+ #include <linux/proc_fs.h>
+ #include <linux/wait.h>
+ #include <linux/vmalloc.h>
++#include <linux/sched.h>
+
+ #ifdef LINUX_2_6
+ #include <linux/version.h>
+ #ifndef UTS_RELEASE
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33))
++#include <linux/autoconf.h>
+ #include <linux/utsrelease.h>
++#else
++#include <generated/autoconf.h>
++#include <generated/utsrelease.h>
++#endif
+ #endif /* UTC_RELEASE */
+ #undef CONFIG_DEVFS_FS
+ #endif /* LINUX_2_6 */
+--- a/src/mps/drv_mps_vmmc_linux.c
++++ b/src/mps/drv_mps_vmmc_linux.c
+@@ -19,11 +19,22 @@
+ #include "drv_config.h"
+
+ #include "drv_mps_version.h"
++#include <linux/version.h>
+
+ #ifdef CONFIG_DEBUG_MINI_BOOT
+ #define IKOS_MINI_BOOT
+ #endif /* */
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33))
+ #include <linux/autoconf.h>
++#ifndef UTS_RELEASE
++#include <linux/utsrelease.h>
++#endif
++#else
++#include <generated/autoconf.h>
++#ifndef UTS_RELEASE
++#include <generated/utsrelease.h>
++#endif
++#endif
+ #include <linux/module.h>
+ #include <linux/init.h>
+ #include <linux/poll.h>
+@@ -34,7 +45,13 @@
+ #include <linux/delay.h>
+ #include <linux/interrupt.h>
+ #ifdef LINUX_2_6
++#ifndef UTS_RELEASE
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 33)
+ #include <linux/utsrelease.h>
++#else
++#include <generated/utsrelease.h>
++#endif
++#endif /* UTC_RELEASE */
+ #else /* */
+ #include <linux/uts.h>
+ #include <linux/moduleparam.h>
+@@ -94,8 +111,13 @@ IFX_int32_t ifx_mps_get_status_proc (IFX
+ #ifndef __KERNEL__
+ IFX_int32_t ifx_mps_open (struct inode *inode, struct file *file_p);
+ IFX_int32_t ifx_mps_close (struct inode *inode, struct file *file_p);
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37)
+ IFX_int32_t ifx_mps_ioctl (struct inode *inode, struct file *file_p,
+ IFX_uint32_t nCmd, IFX_ulong_t arg);
++#else
++long ifx_mps_ioctl (struct file *file_p,
++ IFX_uint32_t nCmd, IFX_ulong_t arg);
++#endif
+ IFX_int32_t ifx_mps_read_mailbox (mps_devices type, mps_message * rw);
+ IFX_int32_t ifx_mps_write_mailbox (mps_devices type, mps_message * rw);
+ IFX_int32_t ifx_mps_register_data_callback (mps_devices type, IFX_uint32_t dir,
+@@ -155,7 +177,11 @@ IFX_char_t voice_channel_int_name[NUM_VO
+ static struct file_operations ifx_mps_fops = {
+ owner:THIS_MODULE,
+ poll:ifx_mps_poll,
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37)
+ ioctl:ifx_mps_ioctl,
++#else
++ unlocked_ioctl:ifx_mps_ioctl,
++#endif
+ open:ifx_mps_open,
+ release:ifx_mps_close
+ };
+@@ -598,8 +624,13 @@ static IFX_uint32_t ifx_mps_poll (struct
+ * \return -ENOIOCTLCMD Invalid command
+ * \ingroup API
+ */
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37)
+ IFX_int32_t ifx_mps_ioctl (struct inode * inode, struct file * file_p,
+ IFX_uint32_t nCmd, IFX_ulong_t arg)
++#else
++long ifx_mps_ioctl (struct file *file_p,
++ IFX_uint32_t nCmd, IFX_ulong_t arg)
++#endif
+ {
+ IFX_int32_t retvalue = -EINVAL;
+ mps_message rw_struct;
+@@ -613,17 +644,30 @@ IFX_int32_t ifx_mps_ioctl (struct inode
+ 'mps_devices' enum type, which in fact is [0..8]; So, if inode value is
+ [0..NUM_VOICE_CHANNEL+1], then we make sure that we are calling from
+ kernel space. */
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37)
+ if (((IFX_int32_t) inode >= 0) &&
+ ((IFX_int32_t) inode < NUM_VOICE_CHANNEL + 1))
++#else
++ if (((IFX_int32_t) file_p >= 0) &&
++ ((IFX_int32_t) file_p < NUM_VOICE_CHANNEL + 1))
++#endif
+ {
+ from_kernel = 1;
+
+ /* Get corresponding mailbox device structure */
+ if ((pMBDev =
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37)
+ ifx_mps_get_device ((mps_devices) ((IFX_int32_t) inode))) == 0)
++#else
++ ifx_mps_get_device ((mps_devices) ((IFX_int32_t) file_p))) == 0)
++#endif
+ {
+ return (-EINVAL);
+ }
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37)
++#else
++ file_p = NULL;
++#endif
+ }
+ else
+ {
+--- a/src/mps/drv_mps_vmmc_common.c
++++ b/src/mps/drv_mps_vmmc_common.c
+@@ -21,7 +21,11 @@
+ #undef USE_PLAIN_VOICE_FIRMWARE
+ #undef PRINT_ON_ERR_INTERRUPT
+ #undef FAIL_ON_ERR_INTERRUPT
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33))
+ #include <linux/autoconf.h>
++#else
++#include <generated/autoconf.h>
++#endif
+ #include <linux/interrupt.h>
+ #include <linux/delay.h>
+
+@@ -92,7 +96,9 @@ extern IFX_uint32_t danube_get_cpu_ver (
+ extern mps_mbx_dev *ifx_mps_get_device (mps_devices type);
+
+ #ifdef LINUX_2_6
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39))
+ extern IFX_void_t bsp_mask_and_ack_irq (IFX_uint32_t irq_nr);
++#endif
+
+ #else /* */
+ extern IFX_void_t mask_and_ack_danube_irq (IFX_uint32_t irq_nr);
+--- a/src/mps/drv_mps_vmmc_danube.c
++++ b/src/mps/drv_mps_vmmc_danube.c
+@@ -20,7 +20,11 @@
+
+ #ifdef SYSTEM_DANUBE /* defined in drv_mps_vmmc_config.h */
+
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33))
+ #include <linux/autoconf.h>
++#else
++#include <generated/autoconf.h>
++#endif
+
+ /* lib_ifxos headers */
+ #include "ifx_types.h"
+--- a/configure.in
++++ b/configure.in
+@@ -112,7 +112,7 @@ dnl Set kernel build path
+ AC_ARG_ENABLE(kernelbuild,
+ AS_HELP_STRING(--enable-kernelbuild=x,Set the target kernel build path),
+ [
+- if test -r $enableval/include/linux/autoconf.h; then
++ if test -e $enableval/include/linux/autoconf.h -o -e $enableval/include/generated/autoconf.h; then
+ AC_SUBST([KERNEL_BUILD_PATH],[$enableval])
+ else
+ AC_MSG_ERROR([The kernel build directory is not valid or not configured!])
+--- a/src/drv_vmmc_bbd.c
++++ b/src/drv_vmmc_bbd.c
+@@ -1072,7 +1072,11 @@ static IFX_int32_t vmmc_BBD_DownloadChCr
+ IFX_uint8_t padBytes = 0;
+ #endif
+ IFX_uint16_t cram_offset, cram_crc,
+- pCmd [MAX_CMD_WORD] = {0};
++ pCmd [MAX_CMD_WORD]
++#if defined (__GNUC__) || defined (__GNUG__)
++ __attribute__ ((aligned(4)))
++#endif
++ = {0};
+
+ /* read offset */
+ cpb2w (&cram_offset, &bbd_cram->pData[0], sizeof (IFX_uint16_t));
+--- a/src/drv_vmmc_init.c
++++ b/src/drv_vmmc_init.c
+@@ -776,8 +776,13 @@ IFX_int32_t VMMC_TAPI_LL_FW_Start(IFX_TA
+ dwld.fwDwld.length = IoInit.pram_size;
+
+ /* download firmware */
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37)
+ ret = ifx_mps_ioctl((IFX_void_t *) command, IFX_NULL, FIO_MPS_DOWNLOAD,
+ (IFX_uint32_t) &dwld.fwDwld);
++#else
++ ret = ifx_mps_ioctl((IFX_void_t *) command, FIO_MPS_DOWNLOAD,
++ (IFX_uint32_t) &dwld.fwDwld);
++#endif
+ }
+
+ if (VMMC_SUCCESS(ret))
+--- a/src/drv_vmmc_ioctl.c
++++ b/src/drv_vmmc_ioctl.c
+@@ -426,18 +426,31 @@ IFX_int32_t VMMC_Dev_Spec_Ioctl (IFX_TAP
+ /* MPS driver will do the USR2KERN so just pass on the pointer. */
+ dwnld_struct.data = (IFX_void_t *)IoInit.pPRAMfw;
+
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37)
+ ret = ifx_mps_ioctl((IFX_void_t *)command, IFX_NULL,
+ FIO_MPS_DOWNLOAD, (IFX_uint32_t) &dwnld_struct);
++#else
++ ret = ifx_mps_ioctl((IFX_void_t *)command,
++ FIO_MPS_DOWNLOAD, (IFX_uint32_t) &dwnld_struct);
++#endif
+ break;
+ }
+ case FIO_DEV_RESET:
+ {
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37)
+ ret = ifx_mps_ioctl((IFX_void_t *)command, IFX_NULL, FIO_MPS_RESET, 0);
++#else
++ ret = ifx_mps_ioctl((IFX_void_t *)command, FIO_MPS_RESET, 0);
++#endif
+ break;
+ }
+ case FIO_DEV_RESTART:
+ {
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37)
+ ret = ifx_mps_ioctl((IFX_void_t *)command, IFX_NULL, FIO_MPS_RESTART, 0);
++#else
++ ret = ifx_mps_ioctl((IFX_void_t *)command, FIO_MPS_RESTART, 0);
++#endif
+ break;
+ }
+ case FIO_LASTERR:
+--- a/src/mps/drv_mps_vmmc.h
++++ b/src/mps/drv_mps_vmmc.h
+@@ -279,8 +279,13 @@ typedef struct
+ #include <linux/fs.h>
+ IFX_int32_t ifx_mps_open (struct inode *inode, struct file *file_p);
+ IFX_int32_t ifx_mps_close (struct inode *inode, struct file *filp);
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37)
+ IFX_int32_t ifx_mps_ioctl (struct inode *inode, struct file *file_p,
+ IFX_uint32_t nCmd, unsigned long arg);
++#else
++long ifx_mps_ioctl (struct file *filp,
++ IFX_uint32_t nCmd, unsigned long arg);
++#endif
+ IFX_int32_t ifx_mps_register_data_callback (mps_devices type, IFX_uint32_t dir,
+ IFX_void_t (*callback) (mps_devices
+ type));
diff --git a/package/platform/lantiq/ltq-vmmc/patches/100-target.patch b/package/platform/lantiq/ltq-vmmc/patches/100-target.patch
new file mode 100644
index 0000000..cabd2d1
--- /dev/null
+++ b/package/platform/lantiq/ltq-vmmc/patches/100-target.patch
@@ -0,0 +1,751 @@
+--- a/src/drv_vmmc_access.h
++++ b/src/drv_vmmc_access.h
+@@ -24,6 +24,10 @@
+ #include "drv_mps_vmmc.h"
+ #endif
+
++#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,28))
++# define IFX_MPS IFXMIPS_MPS_BASE_ADDR
++#endif
++
+ /* ============================= */
+ /* Global Defines */
+ /* ============================= */
+--- a/src/drv_vmmc_danube.h
++++ b/src/drv_vmmc_danube.h
+@@ -15,56 +15,18 @@
+ */
+
+ #if defined SYSTEM_DANUBE
+-#include <asm/ifx/ifx_gpio.h>
++#include <lantiq_soc.h>
++
+ #else
+ #error no system selected
+ #endif
+
+-#define VMMC_TAPI_GPIO_MODULE_ID IFX_GPIO_MODULE_TAPI_VMMC
++#define VMMC_TAPI_GPIO_MODULE_ID IFX_GPIO_MODULE_TAPI_VMMC
+ /**
+
+ */
+ #define VMMC_PCM_IF_CFG_HOOK(mode, GPIOreserved, ret) \
+ do { \
+- ret = VMMC_statusOk; \
+- /* Reserve P0.0 as TDM/FSC */ \
+- if (!GPIOreserved) \
+- ret |= ifx_gpio_pin_reserve(IFX_GPIO_PIN_ID(0, 0), VMMC_TAPI_GPIO_MODULE_ID); \
+- ret |= ifx_gpio_altsel0_set(IFX_GPIO_PIN_ID(0, 0), VMMC_TAPI_GPIO_MODULE_ID); \
+- ret |= ifx_gpio_altsel1_set(IFX_GPIO_PIN_ID(0, 0), VMMC_TAPI_GPIO_MODULE_ID); \
+- ret |= ifx_gpio_open_drain_set(IFX_GPIO_PIN_ID(0, 0), VMMC_TAPI_GPIO_MODULE_ID);\
+- \
+- /* Reserve P1.9 as TDM/DO */ \
+- if (!GPIOreserved) \
+- ret |= ifx_gpio_pin_reserve(IFX_GPIO_PIN_ID(1, 9), VMMC_TAPI_GPIO_MODULE_ID); \
+- ret |= ifx_gpio_altsel0_set(IFX_GPIO_PIN_ID(1, 9), VMMC_TAPI_GPIO_MODULE_ID); \
+- ret |= ifx_gpio_altsel1_clear(IFX_GPIO_PIN_ID(1, 9), VMMC_TAPI_GPIO_MODULE_ID); \
+- ret |= ifx_gpio_dir_out_set(IFX_GPIO_PIN_ID(1, 9), VMMC_TAPI_GPIO_MODULE_ID); \
+- ret |= ifx_gpio_open_drain_set(IFX_GPIO_PIN_ID(1, 9), VMMC_TAPI_GPIO_MODULE_ID); \
+- \
+- /* Reserve P1.10 as TDM/DI */ \
+- if (!GPIOreserved) \
+- ret |= ifx_gpio_pin_reserve(IFX_GPIO_PIN_ID(1,10), VMMC_TAPI_GPIO_MODULE_ID); \
+- ret |= ifx_gpio_altsel0_clear(IFX_GPIO_PIN_ID(1,10), VMMC_TAPI_GPIO_MODULE_ID); \
+- ret |= ifx_gpio_altsel1_set(IFX_GPIO_PIN_ID(1,10), VMMC_TAPI_GPIO_MODULE_ID);\
+- ret |= ifx_gpio_dir_in_set(IFX_GPIO_PIN_ID(1,10), VMMC_TAPI_GPIO_MODULE_ID); \
+- \
+- /* Reserve P1.11 as TDM/DCL */ \
+- if (!GPIOreserved) \
+- ret |= ifx_gpio_pin_reserve(IFX_GPIO_PIN_ID(1,11), VMMC_TAPI_GPIO_MODULE_ID); \
+- ret |= ifx_gpio_altsel0_set(IFX_GPIO_PIN_ID(1,11), VMMC_TAPI_GPIO_MODULE_ID); \
+- ret |= ifx_gpio_altsel1_clear(IFX_GPIO_PIN_ID(1,11), VMMC_TAPI_GPIO_MODULE_ID); \
+- ret |= ifx_gpio_open_drain_set(IFX_GPIO_PIN_ID(1,11), VMMC_TAPI_GPIO_MODULE_ID); \
+- \
+- if (mode == 2) { \
+- /* TDM/FSC+DCL Master */ \
+- ret |= ifx_gpio_dir_out_set(IFX_GPIO_PIN_ID(0, 0), VMMC_TAPI_GPIO_MODULE_ID); \
+- ret |= ifx_gpio_dir_out_set(IFX_GPIO_PIN_ID(1,11), VMMC_TAPI_GPIO_MODULE_ID); \
+- } else { \
+- /* TDM/FSC+DCL Slave */ \
+- ret |= ifx_gpio_dir_in_set(IFX_GPIO_PIN_ID(0, 0), VMMC_TAPI_GPIO_MODULE_ID); \
+- ret |= ifx_gpio_dir_in_set(IFX_GPIO_PIN_ID(1,11), VMMC_TAPI_GPIO_MODULE_ID); \
+- } \
+ } while(0);
+
+ /**
+@@ -72,11 +34,6 @@
+ */
+ #define VMMC_DRIVER_UNLOAD_HOOK(ret) \
+ do { \
+- ret = VMMC_statusOk; \
+- ret |= ifx_gpio_pin_free(IFX_GPIO_PIN_ID(0, 0), VMMC_TAPI_GPIO_MODULE_ID); \
+- ret |= ifx_gpio_pin_free(IFX_GPIO_PIN_ID(1, 9), VMMC_TAPI_GPIO_MODULE_ID); \
+- ret |= ifx_gpio_pin_free(IFX_GPIO_PIN_ID(1,10), VMMC_TAPI_GPIO_MODULE_ID); \
+- ret |= ifx_gpio_pin_free(IFX_GPIO_PIN_ID(1,11), VMMC_TAPI_GPIO_MODULE_ID); \
+ } while (0)
+
+ #endif /* _DRV_VMMC_AMAZON_S_H */
+--- a/src/drv_vmmc_init.c
++++ b/src/drv_vmmc_init.c
+@@ -52,6 +52,14 @@
+ #include "ifx_pmu.h"
+ #endif /* PMU_SUPPORTED */
+
++#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,28))
++# define IFX_MPS_CAD0SR IFXMIPS_MPS_CAD0SR
++# define IFX_MPS_CAD1SR IFXMIPS_MPS_CAD1SR
++# define IFX_MPS_CVC0SR IFXMIPS_MPS_CVC0SR
++# define IFX_MPS_CVC1SR IFXMIPS_MPS_CVC1SR
++# define IFX_MPS_CVC2SR IFXMIPS_MPS_CVC2SR
++# define IFX_MPS_CVC3SR IFXMIPS_MPS_CVC3SR
++#endif
+
+ /* ============================= */
+ /* Local Macros & Definitions */
+@@ -1591,7 +1599,7 @@
+ #ifdef VMMC_DRIVER_UNLOAD_HOOK
+ if (VDevices[0].nDevState & DS_GPIO_RESERVED)
+ {
+- IFX_int32_t ret;
++ IFX_int32_t ret = 0;
+ VMMC_DRIVER_UNLOAD_HOOK(ret);
+ if (!VMMC_SUCCESS(ret))
+ {
+--- a/src/drv_vmmc_init_cap.c
++++ b/src/drv_vmmc_init_cap.c
+@@ -22,6 +22,11 @@
+ #include "drv_mps_vmmc.h"
+ #include "drv_mps_vmmc_device.h"
+
++#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,28))
++# define IFX_MPS_CHIPID_VERSION_GET IFXMIPS_MPS_CHIPID_VERSION_GET
++# define IFX_MPS_CHIPID IFXMIPS_MPS_CHIPID
++#endif
++
+ /* ============================= */
+ /* Configuration defintions */
+ /* ============================= */
+--- a/src/mps/drv_mps_vmmc_common.c
++++ b/src/mps/drv_mps_vmmc_common.c
+@@ -17,6 +17,7 @@
+ /* Includes */
+ /* ============================= */
+ #include "drv_config.h"
++#include "drv_vmmc_init.h"
+
+ #undef USE_PLAIN_VOICE_FIRMWARE
+ #undef PRINT_ON_ERR_INTERRUPT
+@@ -39,8 +40,32 @@
+ #include "ifxos_interrupt.h"
+ #include "ifxos_time.h"
+
+-#include <asm/ifx/ifx_regs.h>
+-#include <asm/ifx/ifx_gptu.h>
++#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,28))
++# include <lantiq.h>
++# include <irq.h>
++# include <lantiq_timer.h>
++
++# define ifx_gptu_timer_request lq_request_timer
++# define ifx_gptu_timer_start lq_start_timer
++# define ifx_gptu_countvalue_get lq_get_count_value
++# define ifx_gptu_timer_free lq_free_timer
++
++
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39))
++# define bsp_mask_and_ack_irq ltq_mask_and_ack_irq
++#else
++extern void ltq_mask_and_ack_irq(struct irq_data *d);
++static void inline bsp_mask_and_ack_irq(int x)
++{
++ struct irq_data d;
++ d.hwirq = x;
++ ltq_mask_and_ack_irq(&d);
++}
++#endif
++#else
++# include <asm/ifx/ifx_regs.h>
++# include <asm/ifx/ifx_gptu.h>
++#endif
+
+ #include "drv_mps_vmmc.h"
+ #include "drv_mps_vmmc_dbg.h"
+@@ -104,6 +129,9 @@
+ extern IFX_void_t mask_and_ack_danube_irq (IFX_uint32_t irq_nr);
+
+ #endif /* */
++
++extern void sys_hw_setup (void);
++
+ extern IFXOS_event_t fw_ready_evt;
+ /* callback function to free all data buffers currently used by voice FW */
+ IFX_void_t (*ifx_mps_bufman_freeall)(IFX_void_t) = IFX_NULL;
+@@ -207,7 +235,8 @@
+ */
+ IFX_void_t *ifx_mps_fastbuf_malloc (IFX_size_t size, IFX_int32_t priority)
+ {
+- IFX_uint32_t ptr, flags;
++ IFXOS_INTSTAT flags;
++ IFX_uint32_t ptr;
+ IFX_int32_t index = fastbuf_index;
+
+ if (fastbuf_initialized == 0)
+@@ -261,7 +290,7 @@
+ */
+ IFX_void_t ifx_mps_fastbuf_free (const IFX_void_t * ptr)
+ {
+- IFX_uint32_t flags;
++ IFXOS_INTSTAT flags;
+ IFX_int32_t index = fastbuf_index;
+
+ IFXOS_LOCKINT (flags);
+@@ -457,7 +486,7 @@
+ */
+ static IFX_int32_t ifx_mps_bufman_inc_level (IFX_uint32_t value)
+ {
+- IFX_uint32_t flags;
++ IFXOS_INTSTAT flags;
+
+ if (mps_buffer.buf_level + value > MPS_BUFFER_MAX_LEVEL)
+ {
+@@ -484,7 +513,7 @@
+ */
+ static IFX_int32_t ifx_mps_bufman_dec_level (IFX_uint32_t value)
+ {
+- IFX_uint32_t flags;
++ IFXOS_INTSTAT flags;
+
+ if (mps_buffer.buf_level < value)
+ {
+@@ -636,7 +665,7 @@
+ mem_seg_ptr[i] =
+ (IFX_uint32_t *) CPHYSADDR ((IFX_uint32_t) mps_buffer.
+ malloc (segment_size, FASTBUF_FW_OWNED));
+- if (mem_seg_ptr[i] == CPHYSADDR (IFX_NULL))
++ if (mem_seg_ptr[i] == (IFX_uint32_t *)CPHYSADDR (IFX_NULL))
+ {
+ TRACE (MPS, DBG_LEVEL_HIGH,
+ ("%s(): cannot allocate buffer\n", __FUNCTION__));
+@@ -952,7 +981,7 @@
+ mps_mbx_dev * pMBDev, IFX_int32_t bcommand,
+ IFX_boolean_t from_kernel)
+ {
+- IFX_uint32_t flags;
++ IFXOS_INTSTAT flags;
+
+ IFXOS_LOCKINT (flags);
+
+@@ -1068,7 +1097,7 @@
+ IFX_void_t ifx_mps_release_structures (mps_comm_dev * pDev)
+ {
+ IFX_int32_t count;
+- IFX_uint32_t flags;
++ IFXOS_INTSTAT flags;
+
+ IFXOS_LOCKINT (flags);
+ IFXOS_BlockFree (pFW_img_data);
+@@ -1117,7 +1146,7 @@
+
+ /* Initialize MPS main structure */
+ memset ((IFX_void_t *) pDev, 0, sizeof (mps_comm_dev));
+- pDev->base_global = (mps_mbx_reg *) IFX_MPS_SRAM;
++ pDev->base_global = (mps_mbx_reg *) IFXMIPS_MPS_SRAM;
+ pDev->flags = 0x00000000;
+ MBX_Memory = pDev->base_global;
+
+@@ -1125,9 +1154,11 @@
+ for MBX communication. These are: mailbox base address, mailbox size, *
+ mailbox read index and mailbox write index. for command and voice
+ mailbox, * upstream and downstream direction. */
+- memset ((IFX_void_t *) MBX_Memory, /* avoid to overwrite CPU boot
+- registers */
+- 0, sizeof (mps_mbx_reg) - 2 * sizeof (mps_boot_cfg_reg));
++ memset (
++ /* avoid to overwrite CPU boot registers */
++ (IFX_void_t *) MBX_Memory,
++ 0,
++ sizeof (mps_mbx_reg) - 2 * sizeof (mps_boot_cfg_reg));
+ MBX_Memory->MBX_UPSTR_CMD_BASE =
+ (IFX_uint32_t *) CPHYSADDR ((IFX_uint32_t) MBX_UPSTRM_CMD_FIFO_BASE);
+ MBX_Memory->MBX_UPSTR_CMD_SIZE = MBX_CMD_FIFO_SIZE;
+@@ -1564,7 +1595,7 @@
+ IFX_uint32_t * bytes)
+ {
+ IFX_int32_t i, ret;
+- IFX_uint32_t flags;
++ IFXOS_INTSTAT flags;
+
+ IFXOS_LOCKINT (flags);
+
+@@ -1774,7 +1805,7 @@
+ {
+ mps_fifo *mbx;
+ IFX_uint32_t i;
+- IFX_uint32_t flags;
++ IFXOS_INTSTAT flags;
+ IFX_int32_t retval = -EAGAIN;
+ IFX_int32_t retries = 0;
+ IFX_uint32_t word = 0;
+@@ -2169,6 +2200,7 @@
+ TRACE (MPS, DBG_LEVEL_HIGH,
+ ("%s(): Invalid device ID %d !\n", __FUNCTION__, pMBDev->devID));
+ }
++
+ return retval;
+ }
+
+@@ -2192,7 +2224,7 @@
+ mps_mbx_dev *mbx_dev;
+ MbxMsg_s msg;
+ IFX_uint32_t bytes_read = 0;
+- IFX_uint32_t flags;
++ IFXOS_INTSTAT flags;
+ IFX_int32_t ret;
+
+ /* set pointer to data upstream mailbox, no matter if 0,1,2 or 3 because
+@@ -2283,7 +2315,7 @@
+ {
+ ifx_mps_bufman_dec_level (1);
+ if ((ifx_mps_bufman_get_level () <= mps_buffer.buf_threshold) &&
+- (atomic_read (&pMPSDev->provide_buffer->object.count) == 0))
++ ((volatile unsigned int)pMPSDev->provide_buffer->object.count == 0))
+ {
+ IFXOS_LockRelease (pMPSDev->provide_buffer);
+ }
+@@ -2326,7 +2358,7 @@
+ #endif /* CONFIG_PROC_FS */
+ ifx_mps_bufman_dec_level (1);
+ if ((ifx_mps_bufman_get_level () <= mps_buffer.buf_threshold) &&
+- (atomic_read (&pMPSDev->provide_buffer->object.count) == 0))
++ ((volatile unsigned int)pMPSDev->provide_buffer->object.count == 0))
+ {
+ IFXOS_LockRelease (pMPSDev->provide_buffer);
+ }
+@@ -2356,7 +2388,7 @@
+ IFX_void_t ifx_mps_mbx_cmd_upstream (IFX_ulong_t dummy)
+ {
+ mps_fifo *mbx;
+- IFX_uint32_t flags;
++ IFXOS_INTSTAT flags;
+
+ /* set pointer to upstream command mailbox */
+ mbx = &(pMPSDev->cmd_upstrm_fifo);
+@@ -2404,7 +2436,7 @@
+ mps_event_msg msg;
+ IFX_int32_t length = 0;
+ IFX_int32_t read_length = 0;
+- IFX_uint32_t flags;
++ IFXOS_INTSTAT flags;
+
+ /* set pointer to upstream event mailbox */
+ mbx = &(pMPSDev->event_upstrm_fifo);
+@@ -2619,6 +2651,7 @@
+ #endif
+
+ *IFX_MPS_AD0ENR = Ad0Reg.val;
++
+ }
+
+ /**
+@@ -2647,7 +2680,7 @@
+ */
+ IFX_void_t ifx_mps_dd_mbx_int_enable (IFX_void_t)
+ {
+- IFX_uint32_t flags;
++ IFXOS_INTSTAT flags;
+ MPS_Ad0Reg_u Ad0Reg;
+
+ IFXOS_LOCKINT (flags);
+@@ -2673,7 +2706,7 @@
+ */
+ IFX_void_t ifx_mps_dd_mbx_int_disable (IFX_void_t)
+ {
+- IFX_uint32_t flags;
++ IFXOS_INTSTAT flags;
+ MPS_Ad0Reg_u Ad0Reg;
+
+ IFXOS_LOCKINT (flags);
+@@ -2738,7 +2771,6 @@
+ #else /* */
+ mask_and_ack_danube_irq (irq);
+ #endif /* */
+-
+ /* FW is up and ready to process commands */
+ if (MPS_Ad0StatusReg.fld.dl_end)
+ {
+@@ -2800,6 +2832,7 @@
+ }
+ }
+
++
+ if (MPS_Ad0StatusReg.fld.du_mbx)
+ {
+ #ifdef CONFIG_PROC_FS
+@@ -2944,12 +2977,12 @@
+ IFX_MPS_CVC0SR[chan] = MPS_VCStatusReg.val;
+ /* handle only enabled interrupts */
+ MPS_VCStatusReg.val &= IFX_MPS_VC0ENR[chan];
+-
+ #ifdef LINUX_2_6
+ bsp_mask_and_ack_irq (irq);
+ #else /* */
+ mask_and_ack_danube_irq (irq);
+ #endif /* */
++
+ pMPSDev->event.MPS_VCStatReg[chan].val = MPS_VCStatusReg.val;
+ #ifdef PRINT_ON_ERR_INTERRUPT
+ if (MPS_VCStatusReg.fld.rcv_ov)
+@@ -3093,7 +3126,8 @@
+ */
+ IFX_return_t ifx_mps_init_gpt ()
+ {
+- IFX_uint32_t flags, timer_flags, timer, loops = 0;
++ unsigned long flags;
++ IFX_uint32_t timer_flags, timer, loops = 0;
+ IFX_ulong_t count;
+ #if defined(SYSTEM_AR9) || defined(SYSTEM_VR9)
+ timer = TIMER1A;
+@@ -3166,6 +3200,7 @@
+ #else /* Danube */
+ timer = TIMER1B;
+ #endif /* SYSTEM_AR9 || SYSTEM_VR9 */
++
+ ifx_gptu_timer_free (timer);
+ }
+
+--- a/src/mps/drv_mps_vmmc_danube.c
++++ b/src/mps/drv_mps_vmmc_danube.c
+@@ -16,6 +16,7 @@
+ /* ============================= */
+ /* Includes */
+ /* ============================= */
++#include "linux/version.h"
+ #include "drv_config.h"
+
+ #ifdef SYSTEM_DANUBE /* defined in drv_mps_vmmc_config.h */
+@@ -36,9 +37,22 @@
+ #include "ifxos_select.h"
+ #include "ifxos_interrupt.h"
+
+-#include <asm/ifx/ifx_regs.h>
+-#include <asm/ifx/ifx_gpio.h>
+-#include <asm/ifx/common_routines.h>
++#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,28))
++# include <lantiq.h>
++# include <irq.h>
++# include <lantiq_timer.h>
++# include <linux/dma-mapping.h>
++
++
++#define LQ_RCU_BASE_ADDR (KSEG1 + LTQ_RCU_BASE_ADDR)
++# define LQ_RCU_RST ((u32 *)(LQ_RCU_BASE_ADDR + 0x0010))
++#define IFX_RCU_RST_REQ_CPU1 (1 << 3)
++# define IFX_RCU_RST_REQ LQ_RCU_RST
++#else
++# include <asm/ifx/ifx_regs.h>
++# include <asm/ifx_vpe.h>
++# include <asm/ifx/ifx_gpio.h>
++#endif
+
+ #include "drv_mps_vmmc.h"
+ #include "drv_mps_vmmc_dbg.h"
+@@ -75,6 +89,20 @@
+ /* Local function definition */
+ /* ============================= */
+
++#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,28))
++IFX_uint32_t ifx_get_cp1_size(IFX_void_t)
++{
++ return 1;
++}
++
++unsigned int *ltq_get_cp1_base(void);
++
++IFX_uint32_t *ifx_get_cp1_base(IFX_void_t)
++{
++ return ltq_get_cp1_base();
++}
++#endif
++
+ /******************************************************************************
+ * DANUBE Specific Routines
+ ******************************************************************************/
+@@ -134,6 +162,15 @@
+ }
+
+ /* check if FW image fits in available memory space */
++#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,28))
++ if (mem > ifx_get_cp1_size()<<20)
++ {
++ TRACE (MPS, DBG_LEVEL_HIGH,
++ ("[%s %s %d]: error, firmware memory exceeds reserved space (%i > %i)!\n",
++ __FILE__, __func__, __LINE__, mem, ifx_get_cp1_size()<<20));
++ return IFX_ERROR;
++ }
++#else
+ if (mem > ifx_get_cp1_size())
+ {
+ TRACE (MPS, DBG_LEVEL_HIGH,
+@@ -141,6 +178,7 @@
+ __FILE__, __func__, __LINE__, mem, ifx_get_cp1_size()));
+ return IFX_ERROR;
+ }
++#endif
+
+ /* reset the driver */
+ ifx_mps_reset ();
+@@ -361,7 +399,7 @@
+ */
+ IFX_void_t ifx_mps_wdog_expiry()
+ {
+- IFX_uint32_t flags;
++ unsigned long flags;
+
+ IFXOS_LOCKINT (flags);
+ /* recalculate and compare the firmware checksum */
+--- a/src/mps/drv_mps_vmmc_device.h
++++ b/src/mps/drv_mps_vmmc_device.h
+@@ -16,8 +16,58 @@
+ declarations.
+ *******************************************************************************/
+
+-#include <asm/ifx/ifx_regs.h>
+-#include <asm/ifx_vpe.h>
++#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,28))
++# include <lantiq.h>
++# include <irq.h>
++# include <lantiq_soc.h>
++# include <gpio.h>
++#define IFXMIPS_MPS_SRAM ((u32 *)(KSEG1 + 0x1F200000))
++#define IFXMIPS_MPS_BASE_ADDR (KSEG1 + 0x1F107000)
++#define IFXMIPS_MPS_CHIPID ((u32 *)(IFXMIPS_MPS_BASE_ADDR + 0x0344))
++#define IFXMIPS_MPS_VC0ENR ((u32 *)(IFXMIPS_MPS_BASE_ADDR + 0x0000))
++#define IFXMIPS_MPS_RVC0SR ((u32 *)(IFXMIPS_MPS_BASE_ADDR + 0x0010))
++#define IFXMIPS_MPS_CVC0SR ((u32 *)(IFXMIPS_MPS_BASE_ADDR + 0x0030))
++#define IFXMIPS_MPS_CVC1SR ((u32 *)(IFXMIPS_MPS_BASE_ADDR + 0x0034))
++#define IFXMIPS_MPS_CVC2SR ((u32 *)(IFXMIPS_MPS_BASE_ADDR + 0x0038))
++#define IFXMIPS_MPS_CVC3SR ((u32 *)(IFXMIPS_MPS_BASE_ADDR + 0x003C))
++#define IFXMIPS_MPS_RAD0SR ((u32 *)(IFXMIPS_MPS_BASE_ADDR + 0x0040))
++#define IFXMIPS_MPS_RAD1SR ((u32 *)(IFXMIPS_MPS_BASE_ADDR + 0x0044))
++#define IFXMIPS_MPS_SAD0SR ((u32 *)(IFXMIPS_MPS_BASE_ADDR + 0x0048))
++#define IFXMIPS_MPS_SAD1SR ((u32 *)(IFXMIPS_MPS_BASE_ADDR + 0x004C))
++#define IFXMIPS_MPS_CAD0SR ((u32 *)(IFXMIPS_MPS_BASE_ADDR + 0x0050))
++#define IFXMIPS_MPS_CAD1SR ((u32 *)(IFXMIPS_MPS_BASE_ADDR + 0x0054))
++#define IFXMIPS_MPS_AD0ENR ((u32 *)(IFXMIPS_MPS_BASE_ADDR + 0x0058))
++#define IFXMIPS_MPS_AD1ENR ((u32 *)(IFXMIPS_MPS_BASE_ADDR + 0x005C))
++
++#define IFXMIPS_MPS_CHIPID_VERSION_GET(value) (((value) >> 28) & ((1 << 4) - 1))
++#define IFXMIPS_MPS_CHIPID_VERSION_SET(value) ((((1 << 4) - 1) & (value)) << 28)
++#define IFXMIPS_MPS_CHIPID_PARTNUM_GET(value) (((value) >> 12) & ((1 << 16) - 1))
++#define IFXMIPS_MPS_CHIPID_PARTNUM_SET(value) ((((1 << 16) - 1) & (value)) << 12)
++#define IFXMIPS_MPS_CHIPID_MANID_GET(value) (((value) >> 1) & ((1 << 10) - 1))
++#define IFXMIPS_MPS_CHIPID_MANID_SET(value) ((((1 << 10) - 1) & (value)) << 1)
++#else
++# include <asm/ifx/ifx_regs.h>
++# include <asm/ifx_vpe.h>
++#endif
++/* MPS register */
++# define IFX_MPS_AD0ENR IFXMIPS_MPS_AD0ENR
++# define IFX_MPS_AD1ENR IFXMIPS_MPS_AD1ENR
++# define IFX_MPS_RAD0SR IFXMIPS_MPS_RAD0SR
++# define IFX_MPS_RAD1SR IFXMIPS_MPS_RAD1SR
++# define IFX_MPS_VC0ENR IFXMIPS_MPS_VC0ENR
++# define IFX_MPS_RVC0SR IFXMIPS_MPS_RVC0SR
++# define IFX_MPS_CVC0SR IFXMIPS_MPS_CVC0SR
++# define IFX_MPS_CAD0SR IFXMIPS_MPS_CAD0SR
++# define IFX_MPS_CAD1SR IFXMIPS_MPS_CAD1SR
++# define IFX_MPS_CVC1SR IFXMIPS_MPS_CVC1SR
++# define IFX_MPS_CVC2SR IFXMIPS_MPS_CVC2SR
++# define IFX_MPS_CVC3SR IFXMIPS_MPS_CVC3SR
++# define IFX_MPS_SAD0SR IFXMIPS_MPS_SAD0SR
++/* interrupt vectors */
++# define INT_NUM_IM4_IRL14 (INT_NUM_IM4_IRL0 + 14)
++# define INT_NUM_IM4_IRL18 (INT_NUM_IM4_IRL0 + 18)
++# define INT_NUM_IM4_IRL19 (INT_NUM_IM4_IRL0 + 19)
++# define IFX_ICU_IM4_IER IFXMIPS_ICU_IM4_IER
+
+ /* ============================= */
+ /* MPS Common defines */
+@@ -26,32 +76,28 @@
+ #define MPS_BASEADDRESS 0xBF107000
+ #define MPS_RAD0SR MPS_BASEADDRESS + 0x0004
+
+-#define MPS_RAD0SR_DU (1<<0)
+-#define MPS_RAD0SR_CU (1<<1)
+-
+ #define MBX_BASEADDRESS 0xBF200000
+ #define VCPU_BASEADDRESS 0xBF208000 /* 0xBF108000 */
+ /*---------------------------------------------------------------------------*/
++#if !defined(CONFIG_LANTIQ)
++/* enabling interrupts is done with request_irq by the BSP
++ The related code should not be needed anymore */
+ #if defined(SYSTEM_AR9) || defined(SYSTEM_VR9)
+ /* TODO: doublecheck - IM4 or different! */
+ #define MPS_INTERRUPTS_ENABLE(X) *((volatile IFX_uint32_t*) IFX_ICU_IM4_IER) |= X;
+ #define MPS_INTERRUPTS_DISABLE(X) *((volatile IFX_uint32_t*) IFX_ICU_IM4_IER) &= ~X;
+-#define MPS_INTERRUPTS_CLEAR(X) *((volatile IFX_uint32_t*) IFX_ICU_IM4_ISR) = X;
+-#define MPS_INTERRUPTS_SET(X) *((volatile IFX_uint32_t*) IFX_ICU_IM4_IRSR) = X;/* |= ? */
+ #else /* Danube */
+ /* TODO: possibly needs to be changed to IM4 !!!!!! */
+ #ifdef LINUX_2_6
+ #define MPS_INTERRUPTS_ENABLE(X) *((volatile IFX_uint32_t*) IFX_ICU_IM4_IER) |= X;
+ #define MPS_INTERRUPTS_DISABLE(X) *((volatile IFX_uint32_t*) IFX_ICU_IM4_IER) &= ~X;
+-#define MPS_INTERRUPTS_CLEAR(X) *((volatile IFX_uint32_t*) IFX_ICU_IM4_ISR) = X;
+-#define MPS_INTERRUPTS_SET(X) *((volatile IFX_uint32_t*) IFX_ICU_IM4_IRSR) = X;/* |= ? */
+ #else /* */
+ #define MPS_INTERRUPTS_ENABLE(X) *((volatile IFX_uint32_t*) DANUBE_ICU_IM5_IER) |= X;
+ #define MPS_INTERRUPTS_DISABLE(X) *((volatile IFX_uint32_t*) DANUBE_ICU_IM5_IER) &= ~X;
+-#define MPS_INTERRUPTS_CLEAR(X) *((volatile IFX_uint32_t*) DANUBE_ICU_IM5_ISR) = X;
+-#define MPS_INTERRUPTS_SET(X) *((volatile IFX_uint32_t*) DANUBE_ICU_IM5_IRSR) = X;/* |= ? */
+ #endif /* LINUX_2_6 */
+ #endif /* SYSTEM_AR9 || SYSTEM_VR9 */
++#endif /* !defined(CONFIG_LANTIQ) */
++
+ /*---------------------------------------------------------------------------*/
+
+ /*---------------------------------------------------------------------------*/
+@@ -142,53 +188,9 @@
+ #if defined(SYSTEM_AR9) || defined(SYSTEM_VR9)
+ /* ***** Amazon-S specific defines ***** */
+ #define IFX_MPS_Base AMAZON_S_MPS
+-
+-//#define IFX_MPS_CHIPID AMAZON_S_MPS_CHIPID
+-//#define IFX_MPS_CHIPID_VERSION_GET AMAZON_S_MPS_CHIPID_VERSION_GET
+-
+-//#define IFX_MPS_AD0ENR AMAZON_S_MPS_AD0ENR
+-//#define IFX_MPS_AD1ENR AMAZON_S_MPS_AD1ENR
+-//#define IFX_MPS_VC0ENR AMAZON_S_MPS_VC0ENR
+-//#define IFX_MPS_SAD0SR AMAZON_S_MPS_SAD0SR
+-//#define IFX_MPS_RAD0SR AMAZON_S_MPS_RAD0SR
+-//#define IFX_MPS_CAD0SR AMAZON_S_MPS_CAD0SR
+-//#define IFX_MPS_RAD1SR AMAZON_S_MPS_RAD1SR
+-//#define IFX_MPS_CAD1SR AMAZON_S_MPS_CAD1SR
+-//#define IFX_MPS_RVC0SR AMAZON_S_MPS_RVC0SR
+-//#define IFX_MPS_CVC0SR AMAZON_S_MPS_CVC0SR
+-//#define IFX_MPS_CVC1SR AMAZON_S_MPS_CVC1SR
+-//#define IFX_MPS_CVC2SR AMAZON_S_MPS_CVC2SR
+-//#define IFX_MPS_CVC3SR AMAZON_S_MPS_CVC3SR
+-
+-//#define IFX_MPS_SRAM AMAZON_S_MPS_SRAM
+ #else /* */
+ /* ***** DANUBE specific defines ***** */
+ #define IFX_MPS_Base DANUBE_MPS
+-
+-//#define IFX_MPS_CHIPID DANUBE_MPS_CHIPID
+-//#define IFX_MPS_CHIPID_VERSION_GET DANUBE_MPS_CHIPID_VERSION_GET
+-//#define IFX_MPS_CHIPID_VERSION_SET DANUBE_MPS_CHIPID_VERSION_SET
+-//#define IFX_MPS_CHIPID_PARTNUM_GET DANUBE_MPS_CHIPID_PARTNUM_GET
+-//#define IFX_MPS_CHIPID_PARTNUM_SET DANUBE_MPS_CHIPID_PARTNUM_SET
+-//#define IFX_MPS_CHIPID_MANID_GET DANUBE_MPS_CHIPID_MANID_GET
+-//#define IFX_MPS_CHIPID_MANID_SET DANUBE_MPS_CHIPID_MANID_SET
+-//#define IFX_MPS_SUBVER DANUBE_MPS_SUBVER
+-
+-//#define IFX_MPS_AD0ENR DANUBE_MPS_AD0ENR
+-//#define IFX_MPS_AD1ENR DANUBE_MPS_AD1ENR
+-//#define IFX_MPS_VC0ENR DANUBE_MPS_VC0ENR
+-//#define IFX_MPS_SAD0SR DANUBE_MPS_SAD0SR
+-//#define IFX_MPS_RAD0SR DANUBE_MPS_RAD0SR
+-//#define IFX_MPS_CAD0SR DANUBE_MPS_CAD0SR
+-//#define IFX_MPS_RAD1SR DANUBE_MPS_RAD1SR
+-//#define IFX_MPS_CAD1SR DANUBE_MPS_CAD1SR
+-//#define IFX_MPS_RVC0SR DANUBE_MPS_RVC0SR
+-//#define IFX_MPS_CVC0SR DANUBE_MPS_CVC0SR
+-//#define IFX_MPS_CVC1SR DANUBE_MPS_CVC1SR
+-//#define IFX_MPS_CVC2SR DANUBE_MPS_CVC2SR
+-//#define IFX_MPS_CVC3SR DANUBE_MPS_CVC3SR
+-
+-//#define IFX_MPS_SRAM DANUBE_MPS_SRAM
+ #endif /* SYSTEM_AR9 || SYSTEM_VR9 */
+ typedef enum
+ {
+--- a/src/mps/drv_mps_vmmc_linux.c
++++ b/src/mps/drv_mps_vmmc_linux.c
+@@ -57,10 +57,11 @@
+ #include <linux/moduleparam.h>
+ #endif /* */
+
+-
++#if !defined CONFIG_LANTIQ
+ #include <asm/ifx/irq.h>
+ #include <asm/ifx/ifx_regs.h>
+ #include <asm/ifx_vpe.h>
++#endif
+
+ /* lib_ifxos headers */
+ #include "ifx_types.h"
+@@ -959,7 +960,7 @@
+ #endif /* MPS_FIFO_BLOCKING_WRITE */
+ case FIO_MPS_GET_STATUS:
+ {
+- IFX_uint32_t flags;
++ unsigned long flags;
+
+ /* get the status of the channel */
+ if (!from_kernel)
+@@ -993,7 +994,7 @@
+ #if CONFIG_MPS_HISTORY_SIZE > 0
+ case FIO_MPS_GET_CMD_HISTORY:
+ {
+- IFX_uint32_t flags;
++ unsigned long flags;
+
+ if (from_kernel)
+ {
+@@ -1685,6 +1686,7 @@
+ sprintf (buf + len, " minLv: \t %8d\n",
+ ifx_mps_dev.voice_mb[i].upstrm_fifo->min_space);
+ }
++
+ return len;
+ }
+
+@@ -2291,9 +2293,11 @@
+ return result;
+ }
+
++#if !defined(CONFIG_LANTIQ)
++ /** \todo This is handled already with request_irq, remove */
+ /* Enable all MPS Interrupts at ICU0 */
+ MPS_INTERRUPTS_ENABLE (0x0000FF80);
+-
++#endif
+ /* enable mailbox interrupts */
+ ifx_mps_enable_mailbox_int ();
+ /* init FW ready event */
+@@ -2421,9 +2425,11 @@
+ /* disable mailbox interrupts */
+ ifx_mps_disable_mailbox_int ();
+
++#if !defined(CONFIG_LANTIQ)
+ /* disable Interrupts at ICU0 */
+- MPS_INTERRUPTS_DISABLE (DANUBE_MPS_AD0_IR4); /* Disable DFE/AFE 0 Interrupts
+- */
++ /* Disable DFE/AFE 0 Interrupts*/
++ MPS_INTERRUPTS_DISABLE (DANUBE_MPS_AD0_IR4);
++#endif
+
+ /* disable all MPS interrupts */
+ ifx_mps_disable_all_int ();
+--- a/src/drv_vmmc_ioctl.c
++++ b/src/drv_vmmc_ioctl.c
+@@ -18,6 +18,7 @@
+ /* Includes */
+ /* ============================= */
+ #include "drv_api.h"
++#include "drv_vmmc_init.h"
+ #include "drv_vmmc_api.h"
+ #include "drv_vmmc_bbd.h"
+
+Index: drv_vmmc-1.9.0/src/mps/drv_mps_vmmc_danube.c
+===================================================================
+--- drv_vmmc-1.9.0.orig/src/mps/drv_mps_vmmc_danube.c 2012-12-13 08:43:16.080109377 +0100
++++ drv_vmmc-1.9.0/src/mps/drv_mps_vmmc_danube.c 2012-12-13 08:43:48.584110192 +0100
+@@ -44,7 +44,7 @@
+ # include <linux/dma-mapping.h>
+
+
+-#define LQ_RCU_BASE_ADDR (KSEG1 + LTQ_RCU_BASE_ADDR)
++#define LQ_RCU_BASE_ADDR (KSEG1 + 0x1F203000)
+ # define LQ_RCU_RST ((u32 *)(LQ_RCU_BASE_ADDR + 0x0010))
+ #define IFX_RCU_RST_REQ_CPU1 (1 << 3)
+ # define IFX_RCU_RST_REQ LQ_RCU_RST
diff --git a/package/platform/lantiq/ltq-vmmc/patches/400-falcon.patch b/package/platform/lantiq/ltq-vmmc/patches/400-falcon.patch
new file mode 100644
index 0000000..490d6e5
--- /dev/null
+++ b/package/platform/lantiq/ltq-vmmc/patches/400-falcon.patch
@@ -0,0 +1,968 @@
+--- a/configure.in
++++ b/configure.in
+@@ -956,14 +956,15 @@ AC_DEFINE([VMMC],[1],[enable VMMC suppor
+ AM_CONDITIONAL(DANUBE, false)
+ AM_CONDITIONAL(AR9, false)
+ AM_CONDITIONAL(VR9, false)
++AM_CONDITIONAL(FALCON, false)
+ AC_ARG_WITH(device,
+ AC_HELP_STRING(
+- [--with-device=DANUBE|TWINPASS|AR9|VR9],
++ [--with-device=DANUBE|TWINPASS|AR9|VR9|FALCON],
+ [Set device type, default is DANUBE]
+ ),
+ [
+ if test "$withval" = yes; then
+- AC_MSG_ERROR([Set device type! Valid choices are DANUBE|TWINPASS|AR9|VR9]);
++ AC_MSG_ERROR([Set device type! Valid choices are DANUBE|TWINPASS|AR9|VR9|FALCON]);
+ else
+ case $withval in
+ DANUBE)
+@@ -986,8 +987,13 @@ AC_ARG_WITH(device,
+ AC_DEFINE([SYSTEM_VR9],[1],[enable VR9 specific code])
+ AM_CONDITIONAL(VR9, true)
+ ;;
++ FALCON)
++ AC_MSG_RESULT(FALCON device is used);
++ AC_DEFINE([SYSTEM_FALCON],[1],[enable FALCON specific code])
++ AM_CONDITIONAL(FALCON, true)
++ ;;
+ *)
+- AC_MSG_ERROR([Set device type! Valid choices are DANUBE|TWINPASS|AR9|VR9]);
++ AC_MSG_ERROR([Set device type! Valid choices are DANUBE|TWINPASS|AR9|VR9|FALCON]);
+ ;;
+ esac
+ fi
+--- a/src/Makefile.am
++++ b/src/Makefile.am
+@@ -70,6 +70,11 @@ drv_vmmc_SOURCES +=\
+ mps/drv_mps_vmmc_ar9.c
+ endif
+
++if FALCON
++drv_vmmc_SOURCES +=\
++ mps/drv_mps_vmmc_falcon.c
++endif
++
+ endif
+
+ if PMC_SUPPORT
+--- a/drv_version.h
++++ b/drv_version.h
+@@ -36,6 +36,10 @@
+ #define MIN_FW_MAJORSTEP 2
+ #define MIN_FW_MINORSTEP 1
+ #define MIN_FW_HOTFIXSTEP 0
++#elif defined(SYSTEM_FALCON)
++#define MIN_FW_MAJORSTEP 0
++#define MIN_FW_MINORSTEP 1
++#define MIN_FW_HOTFIXSTEP 0
+ #else
+ #error unknown system
+ #endif
+--- a/src/drv_vmmc_bbd.c
++++ b/src/drv_vmmc_bbd.c
+@@ -34,6 +34,7 @@
+ #define VMMC_WL_SDD_BASIC_CFG 0x04000400
+ #define VMMC_WL_SDD_RING_CFG 0x04000500
+ #define VMMC_WL_SDD_DCDC_CFG 0x04000C00
++#define VMMC_WL_SDD_MWI_CFG 0x04000600
+
+ #define IDLE_EXT_TOGGLE_SLEEP_MS 5
+
+@@ -52,6 +53,8 @@
+ #define BBD_VMMC_MAGIC 0x41523921 /* "AR9" */
+ #elif defined(SYSTEM_VR9)
+ #define BBD_VMMC_MAGIC 0x56523921 /* "VR9" */
++#elif defined(SYSTEM_FALCON)
++#define BBD_VMMC_MAGIC 0x46414C43 /* "FALC" */
+ #else
+ #error system undefined
+ #endif
+@@ -525,9 +528,6 @@ static IFX_int32_t VMMC_BBD_BlockHandler
+ IFX_uint16_t slic_val;
+ IFX_int32_t ret = IFX_SUCCESS;
+
+- TRACE(VMMC, DBG_LEVEL_LOW,
+- ("bbd block with tag 0x%04X passed\n", pBBDblock->tag));
+-
+ /* for FXO line allowed blocks are FXO_CRAM and TRANSPARENT */
+ if (pCh->pALM->line_type_fxs != IFX_TRUE)
+ {
+@@ -686,6 +686,7 @@ static IFX_int32_t VMMC_BBD_BlockHandler
+ break;
+ }
+ } /* if */
++
+ return ret;
+ }
+
+@@ -1026,6 +1027,7 @@ static IFX_int32_t vmmc_BBD_WhiteListedC
+ }
+ case VMMC_WL_SDD_RING_CFG:
+ case VMMC_WL_SDD_DCDC_CFG:
++ case VMMC_WL_SDD_MWI_CFG:
+ ret = CmdWrite (pCh->pParent, Msg.val, Msg.cmd.LENGTH);
+ break;
+
+@@ -1068,7 +1070,7 @@ static IFX_int32_t vmmc_BBD_DownloadChCr
+ IFX_uint32_t countWords;
+ IFX_uint32_t posBytes = 0;
+ IFX_uint8_t lenBytes, *pByte;
+-#if defined(SYSTEM_AR9) || defined(SYSTEM_VR9)
++#if defined(SYSTEM_AR9) || defined(SYSTEM_VR9) || defined(SYSTEM_FALCON)
+ IFX_uint8_t padBytes = 0;
+ #endif
+ IFX_uint16_t cram_offset, cram_crc,
+@@ -1088,7 +1090,7 @@ static IFX_int32_t vmmc_BBD_DownloadChCr
+ #ifdef SYSTEM_DANUBE
+ /* CMD1 is a COP command */
+ pCmd[0] = (0x0200) | (pCh->nChannel - 1);
+-#elif defined(SYSTEM_AR9) || defined(SYSTEM_VR9)
++#elif defined(SYSTEM_AR9) || defined(SYSTEM_VR9) || defined(SYSTEM_FALCON)
+ /* SDD_Coef command */
+ pCmd[0] = (0x0400) | (pCh->nChannel - 1);
+ pCmd[1] = (0x0D00);
+@@ -1111,7 +1113,7 @@ static IFX_int32_t vmmc_BBD_DownloadChCr
+ pCmd[1] = ((cram_offset + (posBytes >> 1)) << 8);
+ /* set CRAM data while taking care of endianess */
+ cpb2w (&pCmd[2], &pByte[posBytes], lenBytes);
+-#elif defined(SYSTEM_AR9) || defined(SYSTEM_VR9)
++#elif defined(SYSTEM_AR9) || defined(SYSTEM_VR9) || defined(SYSTEM_FALCON)
+ /* calculate length to download (in words = 16bit),
+ maximum allowed length for this message is 56 Bytes = 28 Words */
+ if (countWords > ((MAX_CMD_WORD - CMD_HDR_CNT - 1)))
+@@ -1140,7 +1142,7 @@ static IFX_int32_t vmmc_BBD_DownloadChCr
+ /* write Data */
+ #if defined SYSTEM_DANUBE
+ ret = CmdWrite (pCh->pParent, (IFX_uint32_t *) pCmd, lenBytes);
+-#elif defined(SYSTEM_AR9) || defined(SYSTEM_VR9)
++#elif defined(SYSTEM_AR9) || defined(SYSTEM_VR9) || defined(SYSTEM_FALCON)
+ #if 1
+ /* lenBytes + 2 bytes for block offset/length which are not calculated
+ in the download progress */
+--- a/src/mps/drv_mps_version.h
++++ b/src/mps/drv_mps_version.h
+@@ -17,7 +17,7 @@
+ #define VERSIONSTEP 2
+ #define VERS_TYPE 5
+
+-#if defined(SYSTEM_AR9) || defined(SYSTEM_VR9)
++#if defined(SYSTEM_AR9) || defined(SYSTEM_VR9) || defined(SYSTEM_FALCON)
+ #define IFX_MPS_PLATFORM_NAME "MIPS34KEc"
+ #elif defined(SYSTEM_DANUBE)
+ #define IFX_MPS_PLATFORM_NAME "MIPS24KEc"
+--- a/src/mps/drv_mps_vmmc_linux.c
++++ b/src/mps/drv_mps_vmmc_linux.c
+@@ -2225,7 +2225,7 @@ IFX_int32_t __init ifx_mps_init_module (
+ #if defined(CONFIG_MIPS) && !defined(CONFIG_MIPS_UNCACHED)
+ #if defined(SYSTEM_DANUBE)
+ bDoCacheOps = IFX_TRUE; /* on Danube always perform cache ops */
+-#elif defined(SYSTEM_AR9) || defined(SYSTEM_VR9)
++#elif defined(SYSTEM_AR9) || defined(SYSTEM_VR9) || defined(SYSTEM_FALCON)
+ /* on AR9/VR9 cache is configured by BSP;
+ here we check whether the D-cache is shared or partitioned;
+ 1) in case of shared D-cache all cache operations are omitted;
+@@ -2255,7 +2255,8 @@ IFX_int32_t __init ifx_mps_init_module (
+
+ /* reset the device before initializing the device driver */
+ ifx_mps_reset ();
+- result = request_irq (INT_NUM_IM4_IRL18,
++
++ result = request_irq (INT_NUM_IM4_IRL18,
+ #ifdef LINUX_2_6
+ ifx_mps_ad0_irq, IRQF_DISABLED
+ #else /* */
+@@ -2396,7 +2397,7 @@ IFX_int32_t __init ifx_mps_init_module (
+ if (result = ifx_mps_init_gpt_danube ())
+ return result;
+ #endif /*DANUBE*/
+- TRACE (MPS, DBG_LEVEL_HIGH, ("Downloading Firmware...\n"));
++ TRACE (MPS, DBG_LEVEL_HIGH, ("Downloading Firmware...\n"));
+ ifx_mps_download_firmware (IFX_NULL, (mps_fw *) 0xa0a00000);
+ udelay (500);
+ TRACE (MPS, DBG_LEVEL_HIGH, ("Providing Buffers...\n"));
+--- /dev/null
++++ b/src/mps/drv_mps_vmmc_falcon.c
+@@ -0,0 +1,463 @@
++/******************************************************************************
++
++ Copyright (c) 2009
++ Lantiq Deutschland GmbH
++ Am Campeon 3; 85579 Neubiberg, Germany
++
++ For licensing information, see the file 'LICENSE' in the root folder of
++ this software module.
++
++****************************************************************************
++ Module : drv_mps_vmmc_falcon.c
++ Description : This file contains the implementation of the FALC-ON specific
++ driver functions.
++*******************************************************************************/
++
++/* ============================= */
++/* Includes */
++/* ============================= */
++#include "drv_config.h"
++
++#if defined(SYSTEM_FALCON) /* defined in drv_config.h */
++
++/* lib_ifxos headers */
++#include "ifx_types.h"
++#include "ifxos_linux_drv.h"
++#include "ifxos_copy_user_space.h"
++#include "ifxos_event.h"
++#include "ifxos_lock.h"
++#include "ifxos_select.h"
++#include "ifxos_interrupt.h"
++#include <linux/gpio.h>
++#include <sys1_reg.h>
++#include <falcon.h>
++#include <falcon_irq.h>
++#include <vpe.h>
++#include <sysctrl.h>
++void (*ifx_bsp_basic_mps_decrypt)(unsigned int addr, int n) = (void (*)(unsigned int, int))0xbf000290;
++
++#define IFX_MPS_SRAM IFXMIPS_MPS_SRAM
++
++/*#define USE_PLAIN_VOICE_FIRMWARE*/
++/* board specific headers */
++
++/* device specific headers */
++#include "drv_mps_vmmc.h"
++#include "drv_mps_vmmc_dbg.h"
++#include "drv_mps_vmmc_device.h"
++
++/* ============================= */
++/* Local Macros & Definitions */
++/* ============================= */
++/* Firmware watchdog timer counter address */
++#define VPE1_WDOG_CTR_ADDR ((IFX_uint32_t)((IFX_uint8_t* )IFX_MPS_SRAM + 432))
++
++/* Firmware watchdog timeout range, values in ms */
++#define VPE1_WDOG_TMOUT_MIN 20
++#define VPE1_WDOG_TMOUT_MAX 5000
++
++/* ============================= */
++/* Global variable definition */
++/* ============================= */
++extern mps_comm_dev *pMPSDev;
++
++/* ============================= */
++/* Global function declaration */
++/* ============================= */
++IFX_void_t ifx_mps_release (IFX_void_t);
++extern IFX_uint32_t ifx_mps_reset_structures (mps_comm_dev * pMPSDev);
++extern IFX_int32_t ifx_mps_bufman_close (IFX_void_t);
++IFX_int32_t ifx_mps_wdog_callback (IFX_uint32_t wdog_cleared_ok_count);
++extern IFXOS_event_t fw_ready_evt;
++/* ============================= */
++/* Local function declaration */
++/* ============================= */
++static IFX_int32_t ifx_mps_fw_wdog_start_ar9(IFX_void_t);
++
++/* ============================= */
++/* Local variable definition */
++/* ============================= */
++static IFX_int32_t vpe1_started = 0;
++/* VMMC watchdog timer callback */
++IFX_int32_t (*ifx_wdog_callback) (IFX_uint32_t flags) = IFX_NULL;
++
++/* ============================= */
++/* Local function definition */
++/* ============================= */
++
++/******************************************************************************
++ * AR9 Specific Routines
++ ******************************************************************************/
++
++/**
++ * Start AR9 EDSP firmware watchdog mechanism.
++ * Called after download and startup of VPE1.
++ *
++ * \param none
++ * \return 0 IFX_SUCCESS
++ * \return -1 IFX_ERROR
++ * \ingroup Internal
++ */
++IFX_int32_t ifx_mps_fw_wdog_start_ar9()
++{
++ return IFX_SUCCESS;
++}
++
++/**
++ * Firmware download to Voice CPU
++ * This function performs a firmware download to the coprocessor.
++ *
++ * \param pMBDev Pointer to mailbox device structure
++ * \param pFWDwnld Pointer to firmware structure
++ * \return 0 IFX_SUCCESS, firmware ready
++ * \return -1 IFX_ERROR, firmware not downloaded.
++ * \ingroup Internal
++ */
++IFX_int32_t ifx_mps_download_firmware (mps_mbx_dev *pMBDev, mps_fw *pFWDwnld)
++{
++ IFX_uint32_t mem, cksum;
++ IFX_uint8_t crc;
++ IFX_boolean_t bMemReqNotPresent = IFX_FALSE;
++
++ /* VCC register */
++ /* dummy accesss on GTC for GPONC-55, otherwise upper bits are random on read */
++ ltq_r32 ((u32 *)((KSEG1 | 0x1DC000B0)));
++ /* NTR Frequency Select 1536 kHz per default or take existing,
++ NTR Output Enable and NTR8K Output Enable */
++ if ((ltq_r32 ((u32 *)(GPON_SYS_BASE + 0xBC)) & 7) == 0)
++ ltq_w32_mask (0x10187, 0x183, (u32 *)(GPON_SYS_BASE + 0xBC));
++ else
++ ltq_w32_mask (0x10180, 0x180, (u32 *)(GPON_SYS_BASE + 0xBC));
++#if 0
++ /* BIU-ICU1-IM1_ISR - IM1:FSCT_CMP1=1 and FSC_ROOT=1
++ (0x1f880328 = 0x00002800) */
++ ltq_w32 (0x00002800, (u32 *)(GPON_ICU1_BASE + 0x30));
++#endif
++ /* copy FW footer from user space */
++ if (IFX_NULL == IFXOS_CpyFromUser(pFW_img_data,
++ pFWDwnld->data+pFWDwnld->length/4-sizeof(*pFW_img_data)/4,
++ sizeof(*pFW_img_data)))
++ {
++ TRACE (MPS, DBG_LEVEL_HIGH,
++ (KERN_ERR "[%s %s %d]: copy_from_user error\r\n",
++ __FILE__, __func__, __LINE__));
++ return IFX_ERROR;
++ }
++
++ mem = pFW_img_data->mem;
++
++ /* memory requirement sanity check */
++ if ((crc = ~((mem >> 16) + (mem >> 8) + mem)) != (mem >> 24))
++ {
++ TRACE (MPS, DBG_LEVEL_HIGH,
++ ("[%s %s %d]: warning, image does not contain size - assuming 1MB!\n",
++ __FILE__, __func__, __LINE__));
++ mem = 1 * 1024 * 1024;
++ bMemReqNotPresent = IFX_TRUE;
++ }
++ else
++ {
++ mem &= 0x00FFFFFF;
++ }
++
++ /* check if FW image fits in available memory space */
++ if (mem > vpe1_get_max_mem(0))
++ {
++ TRACE (MPS, DBG_LEVEL_HIGH,
++ ("[%s %s %d]: error, firmware memory exceeds reserved space (%i > %i)!\n",
++ __FILE__, __func__, __LINE__, mem, vpe1_get_max_mem(0)));
++ return IFX_ERROR;
++ }
++
++ /* reset the driver */
++ ifx_mps_reset ();
++
++ /* call BSP to get cpu1 base address */
++ cpu1_base_addr = (IFX_uint32_t *)vpe1_get_load_addr(0);
++
++ /* check if CPU1 base address is sane
++ \todo: check if address is 1MB aligned,
++ also make it visible in a /proc fs */
++ if (!cpu1_base_addr)
++ {
++ TRACE (MPS, DBG_LEVEL_HIGH,
++ (KERN_ERR "IFX_MPS: CPU1 base address is invalid!\r\n"));
++ return IFX_ERROR;
++ }
++ /* further use uncached value */
++ cpu1_base_addr = (IFX_uint32_t *)KSEG1ADDR(cpu1_base_addr);
++
++ /* free all data buffers that might be currently used by FW */
++ if (IFX_NULL != ifx_mps_bufman_freeall)
++ {
++ ifx_mps_bufman_freeall();
++ }
++
++ if(FW_FORMAT_NEW)
++ {
++ /* adjust download length */
++ pFWDwnld->length -= (sizeof(*pFW_img_data)-sizeof(IFX_uint32_t));
++ }
++ else
++ {
++ pFWDwnld->length -= sizeof(IFX_uint32_t);
++
++ /* handle unlikely case if FW image does not contain memory requirement -
++ assumed for old format only */
++ if (IFX_TRUE == bMemReqNotPresent)
++ pFWDwnld->length += sizeof(IFX_uint32_t);
++
++ /* in case of old FW format always assume that FW is encrypted;
++ use compile switch USE_PLAIN_VOICE_FIRMWARE for plain FW */
++#ifndef USE_PLAIN_VOICE_FIRMWARE
++ pFW_img_data->enc = 1;
++#else
++#warning Using unencrypted firmware!
++ pFW_img_data->enc = 0;
++#endif /* USE_PLAIN_VOICE_FIRMWARE */
++ /* initializations for the old format */
++ pFW_img_data->st_addr_crc = 2*sizeof(IFX_uint32_t) +
++ FW_AR9_OLD_FMT_XCPT_AREA_SZ;
++ pFW_img_data->en_addr_crc = pFWDwnld->length;
++ pFW_img_data->fw_vers = 0;
++ pFW_img_data->magic = 0;
++ }
++
++ /* copy FW image to base address of CPU1 */
++ if (IFX_NULL ==
++ IFXOS_CpyFromUser ((IFX_void_t *)cpu1_base_addr,
++ (IFX_void_t *)pFWDwnld->data, pFWDwnld->length))
++ {
++ TRACE (MPS, DBG_LEVEL_HIGH,
++ (KERN_ERR "[%s %s %d]: copy_from_user error\r\n", __FILE__,
++ __func__, __LINE__));
++ return IFX_ERROR;
++ }
++
++ /* process firmware decryption */
++ if (pFW_img_data->enc == 1)
++ {
++ if(FW_FORMAT_NEW)
++ {
++ /* adjust decryption length (avoid decrypting CRC32 checksum) */
++ pFWDwnld->length -= sizeof(IFX_uint32_t);
++ }
++ /* BootROM actually decrypts n+4 bytes if n bytes were passed for
++ decryption. Subtract sizeof(u32) from length to avoid decryption
++ of data beyond the FW image code */
++ pFWDwnld->length -= sizeof(IFX_uint32_t);
++ ifx_bsp_basic_mps_decrypt((unsigned int)cpu1_base_addr, pFWDwnld->length);
++ }
++
++ /* calculate CRC32 checksum over downloaded image */
++ cksum = ifx_mps_fw_crc32(cpu1_base_addr, pFW_img_data);
++
++ /* verify the checksum */
++ if(FW_FORMAT_NEW)
++ {
++ if (cksum != pFW_img_data->crc32)
++ {
++ TRACE (MPS, DBG_LEVEL_HIGH,
++ ("MPS: FW checksum error: img=0x%08x calc=0x%08x\r\n",
++ pFW_img_data->crc32, cksum));
++ /*return IFX_ERROR;*/
++ }
++ }
++ else
++ {
++ /* just store self-calculated checksum */
++ pFW_img_data->crc32 = cksum;
++ }
++
++ /* start VPE1 */
++ ifx_mps_release ();
++#if 0
++ /* start FW watchdog mechanism */
++ ifx_mps_fw_wdog_start_ar9();
++#endif
++ /* get FW version */
++ return ifx_mps_get_fw_version (0);
++}
++
++
++/**
++ * Restart CPU1
++ * This function restarts CPU1 by accessing the reset request register and
++ * reinitializes the mailbox.
++ *
++ * \return 0 IFX_SUCCESS, successful restart
++ * \return -1 IFX_ERROR, if reset failed
++ * \ingroup Internal
++ */
++IFX_int32_t ifx_mps_restart (IFX_void_t)
++{
++ /* raise reset request for CPU1 and reset driver structures */
++ ifx_mps_reset ();
++ /* Disable GPTC Interrupt to CPU1 */
++ ifx_mps_shutdown_gpt ();
++ /* re-configure GPTC */
++ ifx_mps_init_gpt ();
++ /* let CPU1 run */
++ ifx_mps_release ();
++ /* start FW watchdog mechanism */
++ ifx_mps_fw_wdog_start_ar9();
++ TRACE (MPS, DBG_LEVEL_HIGH, ("IFX_MPS: Restarting firmware..."));
++ return ifx_mps_get_fw_version (0);
++}
++
++/**
++ * Shutdown MPS - stop VPE1
++ * This function stops VPE1
++ *
++ * \ingroup Internal
++ */
++IFX_void_t ifx_mps_shutdown (IFX_void_t)
++{
++ if (vpe1_started)
++ {
++ /* stop software watchdog timer */
++ vpe1_sw_wdog_stop (0);
++ /* clean up the BSP callback function */
++ vpe1_sw_wdog_register_reset_handler (IFX_NULL);
++ /* stop VPE1 */
++ vpe1_sw_stop (0);
++ vpe1_started = 0;
++ }
++ /* free GPTC */
++ ifx_mps_shutdown_gpt ();
++}
++
++/**
++ * Reset CPU1
++ * This function causes a reset of CPU1 by clearing the CPU0 boot ready bit
++ * in the reset request register RCU_RST_REQ.
++ * It does not change the boot configuration registers for CPU0 or CPU1.
++ *
++ * \return 0 IFX_SUCCESS, cannot fail
++ * \ingroup Internal
++ */
++IFX_void_t ifx_mps_reset (IFX_void_t)
++{
++ /* if VPE1 is already started, stop it */
++ if (vpe1_started)
++ {
++ /* stop software watchdog timer first */
++ vpe1_sw_wdog_stop (0);
++ vpe1_sw_stop (0);
++ vpe1_started = 0;
++ }
++
++ /* reset driver */
++ ifx_mps_reset_structures (pMPSDev);
++ ifx_mps_bufman_close ();
++ return;
++}
++
++/**
++ * Let CPU1 run
++ * This function starts VPE1
++ *
++ * \return none
++ * \ingroup Internal
++ */
++IFX_void_t ifx_mps_release (IFX_void_t)
++{
++ IFX_int_t ret;
++ IFX_int32_t RetCode = 0;
++
++ /* Start VPE1 */
++ if (IFX_SUCCESS !=
++ vpe1_sw_start ((IFX_void_t *)cpu1_base_addr, 0, 0))
++ {
++ TRACE (MPS, DBG_LEVEL_HIGH, (KERN_ERR "Error starting VPE1\r\n"));
++ return;
++ }
++ vpe1_started = 1;
++
++ /* sleep 3 seconds until FW is ready */
++ ret = IFXOS_EventWait (&fw_ready_evt, 3000, &RetCode);
++ if ((ret == IFX_ERROR) && (RetCode == 1))
++ {
++ /* timeout */
++ TRACE (MPS, DBG_LEVEL_HIGH,
++ (KERN_ERR "[%s %s %d]: Timeout waiting for firmware ready.\r\n",
++ __FILE__, __func__, __LINE__));
++ /* recalculate and compare the firmware checksum */
++ ifx_mps_fw_crc_compare(cpu1_base_addr, pFW_img_data);
++ /* dump exception area on a console */
++ ifx_mps_dump_fw_xcpt(cpu1_base_addr, pFW_img_data);
++ }
++}
++
++/**
++ * WDT callback.
++ * This function is called by BSP (module softdog_vpe) in case if software
++ * watchdog timer expiration is detected by BSP.
++ * This function needs to be registered at BSP as WDT callback using
++ * vpe1_sw_wdog_register_reset_handler() API.
++ *
++ * \return 0 IFX_SUCCESS, cannot fail
++ * \ingroup Internal
++ */
++IFX_int32_t ifx_mps_wdog_callback (IFX_uint32_t wdog_cleared_ok_count)
++{
++#ifdef DEBUG
++ TRACE (MPS, DBG_LEVEL_HIGH,
++ ("MPS: watchdog callback! arg=0x%08x\r\n", wdog_cleared_ok_count));
++#endif /* DEBUG */
++
++ /* reset SmartSLIC is done by FW */
++ /* recalculate and compare the firmware checksum */
++ ifx_mps_fw_crc_compare(cpu1_base_addr, pFW_img_data);
++
++ /* dump exception area on a console */
++ ifx_mps_dump_fw_xcpt(cpu1_base_addr, pFW_img_data);
++
++ if (IFX_NULL != ifx_wdog_callback)
++ {
++ /* call VMMC driver */
++ ifx_wdog_callback (wdog_cleared_ok_count);
++ }
++ else
++ {
++ TRACE (MPS, DBG_LEVEL_HIGH,
++ (KERN_WARNING "MPS: VMMC watchdog timer callback is NULL.\r\n"));
++ }
++ return 0;
++}
++
++/**
++ * Register WDT callback.
++ * This function is called by VMMC driver to register its callback in
++ * the MPS driver.
++ *
++ * \return 0 IFX_SUCCESS, cannot fail
++ * \ingroup Internal
++ */
++IFX_int32_t
++ifx_mps_register_wdog_callback (IFX_int32_t (*pfn) (IFX_uint32_t flags))
++{
++ ifx_wdog_callback = pfn;
++ return 0;
++}
++
++/**
++ Hardware setup on FALC ON
++*/
++void sys_hw_setup (void)
++{
++ /* Set INFRAC register bit 1: clock enable of the GPE primary clock. */
++ sys_gpe_hw_activate (0);
++ /* enable 1.5 V */
++ ltq_w32_mask (0xf, 0x0b, (u32 *)(GPON_SYS1_BASE | 0xbc));
++ /* SYS1-CLKEN:GPTC = 1 and MPS, no longer FSCT = 1 */
++ sys1_hw_activate (ACTS_MPS | ACTS_GPTC);
++ /* GPTC:CLC:RMC = 1 */
++ ltq_w32 (0x00000100, (u32 *)(KSEG1 | 0x1E100E00));
++}
++
++#ifndef VMMC_WITH_MPS
++EXPORT_SYMBOL (ifx_mps_register_wdog_callback);
++#endif /* !VMMC_WITH_MPS */
++
++#endif /* SYSTEM_FALCON */
+--- a/src/mps/drv_mps_vmmc_common.c
++++ b/src/mps/drv_mps_vmmc_common.c
+@@ -66,6 +66,10 @@ static void inline bsp_mask_and_ack_irq(
+ # include <asm/ifx/ifx_regs.h>
+ # include <asm/ifx/ifx_gptu.h>
+ #endif
++#if defined(SYSTEM_FALCON)
++#include <sys1_reg.h>
++#include <sysctrl.h>
++#endif
+
+ #include "drv_mps_vmmc.h"
+ #include "drv_mps_vmmc_dbg.h"
+@@ -1156,7 +1160,12 @@ IFX_uint32_t ifx_mps_init_structures (mp
+ mailbox, * upstream and downstream direction. */
+ memset (
+ /* avoid to overwrite CPU boot registers */
++#if defined(SYSTEM_FALCON)
++ (IFX_void_t *) MBX_Memory +
++ 2 * sizeof (mps_boot_cfg_reg),
++#else
+ (IFX_void_t *) MBX_Memory,
++#endif
+ 0,
+ sizeof (mps_mbx_reg) - 2 * sizeof (mps_boot_cfg_reg));
+ MBX_Memory->MBX_UPSTR_CMD_BASE =
+@@ -2651,7 +2660,6 @@ IFX_void_t ifx_mps_enable_mailbox_int ()
+ #endif
+
+ *IFX_MPS_AD0ENR = Ad0Reg.val;
+-
+ }
+
+ /**
+@@ -2669,6 +2677,7 @@ IFX_void_t ifx_mps_disable_mailbox_int (
+ Ad0Reg.fld.cu_mbx = 0;
+ Ad0Reg.fld.du_mbx = 0;
+ *IFX_MPS_AD0ENR = Ad0Reg.val;
++
+ }
+
+ /**
+@@ -2766,11 +2775,13 @@ irqreturn_t ifx_mps_ad0_irq (IFX_int32_t
+ /* handle only enabled interrupts */
+ MPS_Ad0StatusReg.val &= *IFX_MPS_AD0ENR;
+
++#if !defined(SYSTEM_FALCON)
+ #ifdef LINUX_2_6
+ bsp_mask_and_ack_irq (irq);
+ #else /* */
+ mask_and_ack_danube_irq (irq);
+ #endif /* */
++#endif /* !defined(SYSTEM_FALCON) */
+ /* FW is up and ready to process commands */
+ if (MPS_Ad0StatusReg.fld.dl_end)
+ {
+@@ -2919,11 +2930,13 @@ irqreturn_t ifx_mps_ad1_irq (IFX_int32_t
+ /* handle only enabled interrupts */
+ MPS_Ad1StatusReg.val &= *IFX_MPS_AD1ENR;
+
++#if !defined(SYSTEM_FALCON)
+ #ifdef LINUX_2_6
+ bsp_mask_and_ack_irq (irq);
+ #else /* */
+ mask_and_ack_danube_irq (irq);
+ #endif /* */
++#endif /* !defined(SYSTEM_FALCON) */
+ pMPSDev->event.MPS_Ad1Reg.val = MPS_Ad1StatusReg.val;
+
+ /* use callback function or queue wake up to notify about data reception */
+@@ -2977,11 +2990,13 @@ irqreturn_t ifx_mps_vc_irq (IFX_int32_t
+ IFX_MPS_CVC0SR[chan] = MPS_VCStatusReg.val;
+ /* handle only enabled interrupts */
+ MPS_VCStatusReg.val &= IFX_MPS_VC0ENR[chan];
++#if !defined(SYSTEM_FALCON)
+ #ifdef LINUX_2_6
+ bsp_mask_and_ack_irq (irq);
+ #else /* */
+ mask_and_ack_danube_irq (irq);
+ #endif /* */
++#endif /* !defined(SYSTEM_FALCON) */
+
+ pMPSDev->event.MPS_VCStatReg[chan].val = MPS_VCStatusReg.val;
+ #ifdef PRINT_ON_ERR_INTERRUPT
+@@ -3126,6 +3141,7 @@ IFX_int32_t ifx_mps_get_fw_version (IFX_
+ */
+ IFX_return_t ifx_mps_init_gpt ()
+ {
++#if !defined(SYSTEM_FALCON)
+ unsigned long flags;
+ IFX_uint32_t timer_flags, timer, loops = 0;
+ IFX_ulong_t count;
+@@ -3134,7 +3150,11 @@ IFX_return_t ifx_mps_init_gpt ()
+ #else /* Danube */
+ timer = TIMER1B;
+ #endif /* SYSTEM_AR9 || SYSTEM_VR9 */
++#endif
+
++#if defined(SYSTEM_FALCON)
++ sys_hw_setup ();
++#else
+ /* calibration loop - required to syncronize GPTC interrupt with falling
+ edge of FSC clock */
+ timer_flags =
+@@ -3179,7 +3199,7 @@ Probably already in use.\r\n", __FILE__,
+ #endif /* DEBUG */
+
+ IFXOS_UNLOCKINT (flags);
+-
++#endif
+ return IFX_SUCCESS;
+ }
+
+@@ -3194,6 +3214,9 @@ Probably already in use.\r\n", __FILE__,
+ */
+ IFX_void_t ifx_mps_shutdown_gpt (IFX_void_t)
+ {
++#if defined(SYSTEM_FALCON)
++ sys1_hw_deactivate (ACTS_MPS);
++#else
+ IFX_uint32_t timer;
+ #if defined(SYSTEM_AR9) || defined(SYSTEM_VR9)
+ timer = TIMER1A;
+@@ -3202,6 +3225,7 @@ IFX_void_t ifx_mps_shutdown_gpt (IFX_voi
+ #endif /* SYSTEM_AR9 || SYSTEM_VR9 */
+
+ ifx_gptu_timer_free (timer);
++#endif
+ }
+
+ /**
+--- a/src/mps/drv_mps_vmmc_device.h
++++ b/src/mps/drv_mps_vmmc_device.h
+@@ -22,7 +22,12 @@
+ # include <lantiq_soc.h>
+ # include <gpio.h>
+ #define IFXMIPS_MPS_SRAM ((u32 *)(KSEG1 + 0x1F200000))
++#if defined(SYSTEM_FALCON)
++#define IFXMIPS_MPS_BASE_ADDR (KSEG1 + 0x1D004000)
++#else
+ #define IFXMIPS_MPS_BASE_ADDR (KSEG1 + 0x1F107000)
++#endif
++
+ #define IFXMIPS_MPS_CHIPID ((u32 *)(IFXMIPS_MPS_BASE_ADDR + 0x0344))
+ #define IFXMIPS_MPS_VC0ENR ((u32 *)(IFXMIPS_MPS_BASE_ADDR + 0x0000))
+ #define IFXMIPS_MPS_RVC0SR ((u32 *)(IFXMIPS_MPS_BASE_ADDR + 0x0010))
+@@ -73,10 +78,11 @@
+ /* MPS Common defines */
+ /* ============================= */
+
+-#define MPS_BASEADDRESS 0xBF107000
+-#define MPS_RAD0SR MPS_BASEADDRESS + 0x0004
+-
++#if defined(SYSTEM_FALCON)
++#define MBX_BASEADDRESS 0xBF200040
++#else
+ #define MBX_BASEADDRESS 0xBF200000
++#endif
+ #define VCPU_BASEADDRESS 0xBF208000 /* 0xBF108000 */
+ /*---------------------------------------------------------------------------*/
+ #if !defined(CONFIG_LANTIQ)
+@@ -118,7 +124,6 @@
+ /*---------------------------------------------------------------------------*/
+
+ #ifdef CONFIG_MPS_EVENT_MBX
+-
+ #define MBX_CMD_FIFO_SIZE 64 /**< Size of command FIFO in bytes */
+ #define MBX_DATA_UPSTRM_FIFO_SIZE 64
+ #define MBX_DATA_DNSTRM_FIFO_SIZE 128
+@@ -294,6 +299,10 @@ typedef struct
+ #ifdef CONFIG_MPS_EVENT_MBX
+ typedef struct
+ {
++#if defined(SYSTEM_FALCON)
++ mps_boot_cfg_reg MBX_CPU0_BOOT_CFG; /**< CPU0 Boot Configuration */
++ mps_boot_cfg_reg MBX_CPU1_BOOT_CFG; /**< CPU1 Boot Configuration */
++#endif
+ volatile IFX_uint32_t *MBX_UPSTR_CMD_BASE; /**< Upstream Command FIFO Base Address */
+ volatile IFX_uint32_t MBX_UPSTR_CMD_SIZE; /**< Upstream Command FIFO size in byte */
+ volatile IFX_uint32_t *MBX_DNSTR_CMD_BASE; /**< Downstream Command FIFO Base Address */
+@@ -317,13 +326,19 @@ typedef struct
+ volatile IFX_uint32_t MBX_UPSTR_EVENT_WRITE; /**< Upstream Event FIFO Write Index */
+ volatile IFX_uint32_t MBX_EVENT[MBX_EVENT_DATA_WORDS];
+ volatile IFX_uint32_t reserved[4];
++#if !defined(SYSTEM_FALCON)
+ mps_boot_cfg_reg MBX_CPU0_BOOT_CFG; /**< CPU0 Boot Configuration */
+ mps_boot_cfg_reg MBX_CPU1_BOOT_CFG; /**< CPU1 Boot Configuration */
++#endif
+ } mps_mbx_reg;
+
+ #else /* */
+ typedef struct
+ {
++#if defined(SYSTEM_FALCON)
++ mps_boot_cfg_reg MBX_CPU0_BOOT_CFG; /**< CPU0 Boot Configuration */
++ mps_boot_cfg_reg MBX_CPU1_BOOT_CFG; /**< CPU1 Boot Configuration */
++#endif
+ volatile IFX_uint32_t *MBX_UPSTR_CMD_BASE; /**< Upstream Command FIFO Base Address */
+ volatile IFX_uint32_t MBX_UPSTR_CMD_SIZE; /**< Upstream Command FIFO size in byte */
+ volatile IFX_uint32_t *MBX_DNSTR_CMD_BASE; /**< Downstream Command FIFO Base Address */
+@@ -341,8 +356,10 @@ typedef struct
+ volatile IFX_uint32_t MBX_DNSTR_DATA_READ; /**< Downstream Data FIFO Read Index */
+ volatile IFX_uint32_t MBX_DNSTR_DATA_WRITE; /**< Downstream Data FIFO Write Index */
+ volatile IFX_uint32_t MBX_DATA[MBX_DATA_WORDS];
++#if !defined(SYSTEM_FALCON)
+ mps_boot_cfg_reg MBX_CPU0_BOOT_CFG; /**< CPU0 Boot Configuration */
+ mps_boot_cfg_reg MBX_CPU1_BOOT_CFG; /**< CPU1 Boot Configuration */
++#endif
+ } mps_mbx_reg;
+ #endif /* CONFIG_MPS_EVENT_MBX */
+
+--- a/src/drv_api.h
++++ b/src/drv_api.h
+@@ -183,7 +183,7 @@
+ #endif
+
+ /* TAPI FXS Phone Detection feature is not available for Danube platform */
+-#if defined(TAPI_PHONE_DETECTION) && (defined(SYSTEM_AR9) || defined(SYSTEM_VR9))
++#if defined(TAPI_PHONE_DETECTION) && (defined(SYSTEM_AR9) || defined(SYSTEM_VR9) || defined(SYSTEM_FALCON))
+ #define VMMC_CFG_ADD_FEAT_PHONE_DETECTION VMMC_FEAT_PHONE_DETECTION
+ #else
+ #define VMMC_CFG_ADD_FEAT_PHONE_DETECTION 0
+--- a/src/drv_vmmc_alm.c
++++ b/src/drv_vmmc_alm.c
+@@ -800,7 +800,7 @@ IFX_void_t VMMC_ALM_Free_Ch_Structures (
+ }
+
+
+-#if defined(SYSTEM_AR9) || defined(SYSTEM_VR9)
++#if defined(SYSTEM_AR9) || defined(SYSTEM_VR9) || defined(SYSTEM_FALCON)
+ /**
+ Check whether SmartSLIC is connected
+
+@@ -836,7 +836,7 @@ IFX_boolean_t VMMC_ALM_SmartSLIC_IsConne
+ #endif /*SYSTEM_AR9 || SYSTEM_VR9*/
+
+
+-#if defined(SYSTEM_AR9) || defined(SYSTEM_VR9)
++#if defined(SYSTEM_AR9) || defined(SYSTEM_VR9) || defined(SYSTEM_FALCON)
+ /**
+ Read the number of channels on the SmartSLIC.
+
+@@ -1876,7 +1876,7 @@ IFX_int32_t VMMC_TAPI_LL_ALM_VMMC_Test_L
+ /* write updated message contents */
+ ret = CmdWrite (pDev, (IFX_uint32_t *)((IFX_void_t *)&debugCfg),
+ DCCTL_CMD_LEN);
+-#elif defined(SYSTEM_AR9) || defined(SYSTEM_VR9)
++#elif defined(SYSTEM_AR9) || defined(SYSTEM_VR9) || defined(SYSTEM_FALCON)
+ IFX_uint32_t dcctrlLoop[2];
+ IFX_uint32_t ch = (IFX_uint32_t)(pCh->nChannel - 1);
+
+--- a/src/drv_vmmc_alm.h
++++ b/src/drv_vmmc_alm.h
+@@ -65,7 +65,7 @@ extern IFX_void_t irq_VMMC_ALM_LineDisab
+ extern IFX_void_t VMMC_ALM_CorrectLinemodeCache (VMMC_CHANNEL *pCh,
+ IFX_uint16_t lm);
+
+-#if defined(SYSTEM_AR9) || defined(SYSTEM_VR9)
++#if defined(SYSTEM_AR9) || defined(SYSTEM_VR9) || defined(SYSTEM_FALCON)
+ extern IFX_boolean_t VMMC_ALM_SmartSLIC_IsConnected (
+ VMMC_DEVICE *pDev);
+
+--- a/src/drv_vmmc_init.c
++++ b/src/drv_vmmc_init.c
+@@ -52,15 +52,6 @@
+ #include "ifx_pmu.h"
+ #endif /* PMU_SUPPORTED */
+
+-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,28))
+-# define IFX_MPS_CAD0SR IFXMIPS_MPS_CAD0SR
+-# define IFX_MPS_CAD1SR IFXMIPS_MPS_CAD1SR
+-# define IFX_MPS_CVC0SR IFXMIPS_MPS_CVC0SR
+-# define IFX_MPS_CVC1SR IFXMIPS_MPS_CVC1SR
+-# define IFX_MPS_CVC2SR IFXMIPS_MPS_CVC2SR
+-# define IFX_MPS_CVC3SR IFXMIPS_MPS_CVC3SR
+-#endif
+-
+ /* ============================= */
+ /* Local Macros & Definitions */
+ /* ============================= */
+@@ -820,7 +811,7 @@ static IFX_int32_t VMMC_TAPI_LL_FW_Init(
+ MIN_FW_HOTFIXSTEP};
+ IFX_uint8_t tmp1, tmp2;
+ IFX_TAPI_RESOURCE nResource;
+-#if defined(SYSTEM_AR9) || defined(SYSTEM_VR9)
++#if defined(SYSTEM_AR9) || defined(SYSTEM_VR9) || defined(SYSTEM_FALCON)
+ IFX_uint8_t nChannels, nFXOChannels;
+ #endif /*SYSTEM_AR9 || SYSTEM_VR9*/
+ IFX_int32_t ret = VMMC_statusOk;
+@@ -874,7 +865,7 @@ static IFX_int32_t VMMC_TAPI_LL_FW_Init(
+ pDev->bSmartSlic = IFX_FALSE;
+ pDev->bSlicSupportsIdleMode = IFX_FALSE;
+
+-#if defined(SYSTEM_AR9) || defined(SYSTEM_VR9)
++#if defined(SYSTEM_AR9) || defined(SYSTEM_VR9) || defined(SYSTEM_FALCON)
+ if (VMMC_SUCCESS(ret))
+ {
+ /* Reduce the number of ALM channels in the capabilities if the SLIC
+--- a/src/drv_vmmc_ioctl.c
++++ b/src/drv_vmmc_ioctl.c
+@@ -273,7 +273,7 @@ IFX_int32_t VMMC_Dev_Spec_Ioctl (IFX_TAP
+ case FIO_GET_VERS:
+ {
+ VMMC_IO_VERSION *pVers;
+-#if defined(SYSTEM_AR9) || defined(SYSTEM_VR9)
++#if defined(SYSTEM_AR9) || defined(SYSTEM_VR9) || defined(SYSTEM_FALCON)
+ VMMC_SDD_REVISION_READ_t *pSDDVersCmd = IFX_NULL;
+ #endif /*SYSTEM_AR9 || SYSTEM_VR9*/
+ SYS_VER_t *pCmd;
+@@ -322,7 +322,7 @@ IFX_int32_t VMMC_Dev_Spec_Ioctl (IFX_TAP
+ pVers->nTapiVers = 3;
+ pVers->nDrvVers = MAJORSTEP << 24 | MINORSTEP << 16 |
+ VERSIONSTEP << 8 | VERS_TYPE;
+-#if defined(SYSTEM_AR9) || defined(SYSTEM_VR9)
++#if defined(SYSTEM_AR9) || defined(SYSTEM_VR9) || defined(SYSTEM_FALCON)
+ /* in case of SmartSLIC based systems, we can give some more
+ versions.*/
+ if (VMMC_ALM_SmartSLIC_IsConnected(pDev))
diff --git a/package/procd/.svn/entries b/package/procd/.svn/entries
new file mode 100644
index 0000000..9eea338
--- /dev/null
+++ b/package/procd/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/procd
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-14T18:44:03.692388Z
+36032
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+files
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+b3ce8463bcac4a73c7b1d9799bc7da79
+2013-03-14T18:44:03.692388Z
+36032
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1355
+
diff --git a/package/procd/.svn/text-base/Makefile.svn-base b/package/procd/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..762fb5f
--- /dev/null
+++ b/package/procd/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,50 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=procd
+PKG_VERSION:=2013-03-14
+PKG_RELEASE=$(PKG_SOURCE_VERSION)
+
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL:=git://nbd.name/luci2/procd.git
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE_VERSION:=9fcc900e301e0c304488b6b83f10c8db5b8f4ce0
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
+CMAKE_INSTALL:=1
+
+PKG_LICENSE:=GPLv2
+PKG_LICENSE_FILES:=
+
+PKG_CONFIG_DEPENDS:=CONFIG_PROCD_INIT
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/cmake.mk
+
+define Package/procd
+ SECTION:=base
+ CATEGORY:=Base system
+ DEPENDS:=+ubusd +ubus +libjson-script
+ TITLE:=OpenWrt system process manager
+endef
+
+ifneq ($(CONFIG_PROCD_INIT),)
+define Package/procd/install
+ $(INSTALL_DIR) $(1)/sbin $(1)/lib/functions $(1)/etc
+
+ $(CP) $(PKG_INSTALL_DIR)/usr/sbin/{procd,askfirst,udevtrigger,logread} $(1)/sbin/
+ $(INSTALL_DATA) ./files/hotplug*.json $(1)/etc/
+ $(INSTALL_DATA) ./files/procd.sh $(1)/lib/functions/
+ ln -s /sbin/procd $(1)/sbin/init
+endef
+else
+define Package/procd/install
+ $(INSTALL_DIR) $(1)/sbin $(1)/lib/functions $(1)/etc/init.d
+
+ $(CP) $(PKG_INSTALL_DIR)/usr/sbin/procd $(1)/sbin/
+ $(INSTALL_BIN) ./files/procd.init $(1)/etc/init.d/procd
+ $(INSTALL_DATA) ./files/procd.sh $(1)/lib/functions/
+endef
+endif
+
+$(eval $(call BuildPackage,procd))
diff --git a/package/procd/Makefile b/package/procd/Makefile
new file mode 100644
index 0000000..762fb5f
--- /dev/null
+++ b/package/procd/Makefile
@@ -0,0 +1,50 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=procd
+PKG_VERSION:=2013-03-14
+PKG_RELEASE=$(PKG_SOURCE_VERSION)
+
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL:=git://nbd.name/luci2/procd.git
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE_VERSION:=9fcc900e301e0c304488b6b83f10c8db5b8f4ce0
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
+CMAKE_INSTALL:=1
+
+PKG_LICENSE:=GPLv2
+PKG_LICENSE_FILES:=
+
+PKG_CONFIG_DEPENDS:=CONFIG_PROCD_INIT
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/cmake.mk
+
+define Package/procd
+ SECTION:=base
+ CATEGORY:=Base system
+ DEPENDS:=+ubusd +ubus +libjson-script
+ TITLE:=OpenWrt system process manager
+endef
+
+ifneq ($(CONFIG_PROCD_INIT),)
+define Package/procd/install
+ $(INSTALL_DIR) $(1)/sbin $(1)/lib/functions $(1)/etc
+
+ $(CP) $(PKG_INSTALL_DIR)/usr/sbin/{procd,askfirst,udevtrigger,logread} $(1)/sbin/
+ $(INSTALL_DATA) ./files/hotplug*.json $(1)/etc/
+ $(INSTALL_DATA) ./files/procd.sh $(1)/lib/functions/
+ ln -s /sbin/procd $(1)/sbin/init
+endef
+else
+define Package/procd/install
+ $(INSTALL_DIR) $(1)/sbin $(1)/lib/functions $(1)/etc/init.d
+
+ $(CP) $(PKG_INSTALL_DIR)/usr/sbin/procd $(1)/sbin/
+ $(INSTALL_BIN) ./files/procd.init $(1)/etc/init.d/procd
+ $(INSTALL_DATA) ./files/procd.sh $(1)/lib/functions/
+endef
+endif
+
+$(eval $(call BuildPackage,procd))
diff --git a/package/procd/files/.svn/entries b/package/procd/files/.svn/entries
new file mode 100644
index 0000000..3fc54f5
--- /dev/null
+++ b/package/procd/files/.svn/entries
@@ -0,0 +1,164 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/procd/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-13T18:11:07.862775Z
+36001
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+procd.sh
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+005e731331cb253b6cb861c0a52cbbf8
+2012-12-22T18:56:06.049092Z
+34865
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3213
+
+hotplug-preinit.json
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+6a4f2c3a950ab8bf89e29b096167d29b
+2013-03-13T18:11:07.862775Z
+36001
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+358
+
+procd.init
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+d995bcc944cca803ac7c18467fd1db47
+2012-12-22T18:56:06.049092Z
+34865
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+195
+
+hotplug.json
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+39aba6959706732425e016853dde5552
+2013-03-13T18:11:07.862775Z
+36001
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1512
+
diff --git a/package/procd/files/.svn/text-base/hotplug-preinit.json.svn-base b/package/procd/files/.svn/text-base/hotplug-preinit.json.svn-base
new file mode 100644
index 0000000..d212b22
--- /dev/null
+++ b/package/procd/files/.svn/text-base/hotplug-preinit.json.svn-base
@@ -0,0 +1,21 @@
+[
+ [ "case", "ACTION", {
+ "add": [
+ [ "if",
+ [ "has", "FIRMWARE" ],
+ [
+ [ "exec", "/sbin/hotplug-call", "%SUBSYSTEM%" ],
+ [ "load-firmware", "/lib/firmware" ],
+ [ "return" ]
+ ]
+ ],
+ ],
+ }, ],
+ [ "if",
+ [ "and",
+ [ "eq", "SUBSYSTEM", "button" ],
+ [ "eq", "BUTTON", "reset" ],
+ ],
+ [ "exec", "/etc/rc.button/failsafe" ]
+ ],
+]
diff --git a/package/procd/files/.svn/text-base/hotplug.json.svn-base b/package/procd/files/.svn/text-base/hotplug.json.svn-base
new file mode 100644
index 0000000..43fec0c
--- /dev/null
+++ b/package/procd/files/.svn/text-base/hotplug.json.svn-base
@@ -0,0 +1,80 @@
+[
+ [ "case", "ACTION", {
+ "add": [
+ [ "if",
+ [ "and",
+ [ "has", "MAJOR" ],
+ [ "has", "MINOR" ],
+ ],
+ [
+ [ "if",
+ [ "or",
+ [ "eq", "DEVNAME",
+ [ "null", "full", "ptmx", "zero" ],
+ ],
+ [ "regex", "DEVNAME",
+ [ "^gpio", "^hvc", "^tty" ],
+ ],
+ ],
+ [
+ [ "makedev", "/dev/%DEVNAME%", "0666" ],
+ [ "return" ],
+ ]
+ ],
+ [ "if",
+ [ "or",
+ [ "eq", "DEVNAME", "mapper/control" ],
+ [ "regex", "DEVPATH", "^ppp" ],
+ ],
+ [
+ [ "makedev", "/dev/%DEVNAME%", "0600" ],
+ [ "return" ],
+ ],
+ ],
+ [ "if",
+ [ "has", "DEVNAME" ],
+ [
+ [ "makedev", "/dev/%DEVNAME%", "0644" ],
+ [ "return" ],
+ ],
+ ],
+ ],
+ ],
+ [ "if",
+ [ "has", "FIRMWARE" ],
+ [
+ [ "exec", "/sbin/hotplug-call", "%SUBSYSTEM%" ],
+ [ "load-firmware", "/lib/firmware" ],
+ [ "return" ]
+ ]
+ ],
+ ],
+ "remove" : [
+ [ "if",
+ [ "and",
+ [ "has", "DEVNAME" ],
+ [ "has", "MAJOR" ],
+ [ "has", "MINOR" ],
+ ],
+ [ "rm", "/dev/%DEVNAME%" ]
+ ]
+ ]
+ } ],
+ [ "if",
+ [ "eq", "SUBSYSTEM", "platform" ],
+ [ "exec", "/sbin/hotplug-call", "%SUBSYSTEM%" ]
+ ],
+ [ "if",
+ [ "and",
+ [ "has", "BUTTON" ],
+ [ "eq", "SUBSYSTEM", "button" ],
+ ],
+ [ "exec", "/etc/rc.button/%BUTTON%" ]
+ ],
+ [ "if",
+ [ "eq", "SUBSYSTEM",
+ [ "net", "input", "usb", "ieee1394", "block", "atm", "zaptel", "tty" ]
+ ],
+ [ "exec", "/sbin/hotplug-call", "%SUBSYSTEM%" ]
+ ],
+]
diff --git a/package/procd/files/.svn/text-base/procd.init.svn-base b/package/procd/files/.svn/text-base/procd.init.svn-base
new file mode 100644
index 0000000..3df5f48
--- /dev/null
+++ b/package/procd/files/.svn/text-base/procd.init.svn-base
@@ -0,0 +1,19 @@
+#!/bin/sh /etc/rc.common
+
+START=11
+
+start_stop() {
+ start-stop-daemon $1 -b -m -p /var/run/procd.pid -x /sbin/procd
+}
+
+start() {
+ start_stop -S
+}
+
+reload() {
+ return
+}
+
+stop() {
+ start_stop -K
+}
diff --git a/package/procd/files/.svn/text-base/procd.sh.svn-base b/package/procd/files/.svn/text-base/procd.sh.svn-base
new file mode 100644
index 0000000..e771e0c
--- /dev/null
+++ b/package/procd/files/.svn/text-base/procd.sh.svn-base
@@ -0,0 +1,171 @@
+# procd API:
+#
+# procd_open_service(name, [script]):
+# Initialize a new procd command message containing a service with one or more instances
+#
+# procd_close_service()
+# Send the command message for the service
+#
+# procd_open_instance([name]):
+# Add an instance to the service described by the previous procd_open_service call
+#
+# procd_set_param(type, [value...])
+# Available types:
+# command: command line (array).
+# env: environment variable (passed to the process)
+# data: arbitrary name/value pairs for detecting config changes (table)
+# file: configuration files (array)
+# netdev: bound network device (detects ifindex changes)
+#
+# No space separation is done for arrays/tables - use one function argument per command line argument
+#
+# procd_close_instance():
+# Complete the instance being prepared
+#
+# procd_kill(service, [instance]):
+# Kill a service instance (or all instances)
+#
+
+. $IPKG_INSTROOT/usr/share/libubox/jshn.sh
+
+_PROCD_SERVICE=
+
+_procd_call() {
+ local old_cb
+
+ json_set_namespace procd old_cb
+ "$@"
+ json_set_namespace $old_cb
+}
+
+_procd_wrapper() {
+ while [ -n "$1" ]; do
+ eval "$1() { _procd_call _$1 \"\$@\"; }"
+ shift
+ done
+}
+
+_procd_ubus_call() {
+ local cmd="$1"
+
+ ubus call service "$cmd" "$(json_dump)"
+ json_cleanup
+}
+
+_procd_open_service() {
+ local name="$1"
+ local script="$2"
+
+ _PROCD_SERVICE="$name"
+ _PROCD_INSTANCE_SEQ=0
+
+ json_init
+ json_add_string name "$name"
+ [ -n "$script" ] && json_add_string script "$script"
+ json_add_object instances
+}
+
+_procd_close_service() {
+ json_close_object
+ _procd_ubus_call set
+}
+
+_procd_add_array_data() {
+ while [ -n "$1" ]; do
+ json_add_string "" "$1"
+ shift
+ done
+}
+
+_procd_add_array() {
+ json_add_array "$1"
+ shift
+ _procd_add_array_data "$@"
+ json_close_array
+}
+
+_procd_add_table_data() {
+ while [ -n "$1" ]; do
+ local var="${1%%=*}"
+ local val="${1#*=}"
+ [[ "$1" == "$val" ]] && val=
+ json_add_string "$var" "$val"
+ shift
+ done
+}
+
+_procd_add_table() {
+ json_add_object "$1"
+ shift
+ _procd_add_table_data "$@"
+ json_close_object
+}
+
+_procd_open_instance() {
+ local name="$1"; shift
+
+ _PROCD_INSTANCE_SEQ="$(($_PROCD_INSTANCE_SEQ + 1))"
+ name="${name:-instance$_PROCD_INSTANCE_SEQ}"
+ json_add_object "$name"
+}
+
+_procd_set_param() {
+ local type="$1"; shift
+
+ case "$type" in
+ env|data)
+ _procd_add_table "$type" "$@"
+ ;;
+ command|netdev|file)
+ _procd_add_array "$type" "$@"
+ ;;
+ nice)
+ json_add_int "$type" "$1"
+ ;;
+ esac
+}
+
+_procd_append_param() {
+ local type="$1"; shift
+
+ json_select "$type"
+ case "$type" in
+ env|data)
+ _procd_add_table_data "$@"
+ ;;
+ command|netdev|file)
+ _procd_add_array_data "$@"
+ ;;
+ esac
+ json_select ..
+}
+
+_procd_close_instance() {
+ json_close_object
+}
+
+_procd_add_instance() {
+ _procd_open_instance
+ _procd_set_command "$@"
+ _procd_close_instance
+}
+
+_procd_kill() {
+ local service="$1"
+ local instance="$2"
+
+ json_init
+ [ -n "$service" ] && json_add_string service "$service"
+ [ -n "$instance" ] && json_add_string instance "$instance"
+ _procd_ubus_call delete
+}
+
+_procd_wrapper \
+ procd_open_service \
+ procd_close_service \
+ procd_add_instance \
+ procd_open_instance \
+ procd_close_instance \
+ procd_set_param \
+ procd_append_param \
+ procd_kill
diff --git a/package/procd/files/hotplug-preinit.json b/package/procd/files/hotplug-preinit.json
new file mode 100644
index 0000000..d212b22
--- /dev/null
+++ b/package/procd/files/hotplug-preinit.json
@@ -0,0 +1,21 @@
+[
+ [ "case", "ACTION", {
+ "add": [
+ [ "if",
+ [ "has", "FIRMWARE" ],
+ [
+ [ "exec", "/sbin/hotplug-call", "%SUBSYSTEM%" ],
+ [ "load-firmware", "/lib/firmware" ],
+ [ "return" ]
+ ]
+ ],
+ ],
+ }, ],
+ [ "if",
+ [ "and",
+ [ "eq", "SUBSYSTEM", "button" ],
+ [ "eq", "BUTTON", "reset" ],
+ ],
+ [ "exec", "/etc/rc.button/failsafe" ]
+ ],
+]
diff --git a/package/procd/files/hotplug.json b/package/procd/files/hotplug.json
new file mode 100644
index 0000000..43fec0c
--- /dev/null
+++ b/package/procd/files/hotplug.json
@@ -0,0 +1,80 @@
+[
+ [ "case", "ACTION", {
+ "add": [
+ [ "if",
+ [ "and",
+ [ "has", "MAJOR" ],
+ [ "has", "MINOR" ],
+ ],
+ [
+ [ "if",
+ [ "or",
+ [ "eq", "DEVNAME",
+ [ "null", "full", "ptmx", "zero" ],
+ ],
+ [ "regex", "DEVNAME",
+ [ "^gpio", "^hvc", "^tty" ],
+ ],
+ ],
+ [
+ [ "makedev", "/dev/%DEVNAME%", "0666" ],
+ [ "return" ],
+ ]
+ ],
+ [ "if",
+ [ "or",
+ [ "eq", "DEVNAME", "mapper/control" ],
+ [ "regex", "DEVPATH", "^ppp" ],
+ ],
+ [
+ [ "makedev", "/dev/%DEVNAME%", "0600" ],
+ [ "return" ],
+ ],
+ ],
+ [ "if",
+ [ "has", "DEVNAME" ],
+ [
+ [ "makedev", "/dev/%DEVNAME%", "0644" ],
+ [ "return" ],
+ ],
+ ],
+ ],
+ ],
+ [ "if",
+ [ "has", "FIRMWARE" ],
+ [
+ [ "exec", "/sbin/hotplug-call", "%SUBSYSTEM%" ],
+ [ "load-firmware", "/lib/firmware" ],
+ [ "return" ]
+ ]
+ ],
+ ],
+ "remove" : [
+ [ "if",
+ [ "and",
+ [ "has", "DEVNAME" ],
+ [ "has", "MAJOR" ],
+ [ "has", "MINOR" ],
+ ],
+ [ "rm", "/dev/%DEVNAME%" ]
+ ]
+ ]
+ } ],
+ [ "if",
+ [ "eq", "SUBSYSTEM", "platform" ],
+ [ "exec", "/sbin/hotplug-call", "%SUBSYSTEM%" ]
+ ],
+ [ "if",
+ [ "and",
+ [ "has", "BUTTON" ],
+ [ "eq", "SUBSYSTEM", "button" ],
+ ],
+ [ "exec", "/etc/rc.button/%BUTTON%" ]
+ ],
+ [ "if",
+ [ "eq", "SUBSYSTEM",
+ [ "net", "input", "usb", "ieee1394", "block", "atm", "zaptel", "tty" ]
+ ],
+ [ "exec", "/sbin/hotplug-call", "%SUBSYSTEM%" ]
+ ],
+]
diff --git a/package/procd/files/procd.init b/package/procd/files/procd.init
new file mode 100644
index 0000000..3df5f48
--- /dev/null
+++ b/package/procd/files/procd.init
@@ -0,0 +1,19 @@
+#!/bin/sh /etc/rc.common
+
+START=11
+
+start_stop() {
+ start-stop-daemon $1 -b -m -p /var/run/procd.pid -x /sbin/procd
+}
+
+start() {
+ start_stop -S
+}
+
+reload() {
+ return
+}
+
+stop() {
+ start_stop -K
+}
diff --git a/package/procd/files/procd.sh b/package/procd/files/procd.sh
new file mode 100644
index 0000000..e771e0c
--- /dev/null
+++ b/package/procd/files/procd.sh
@@ -0,0 +1,171 @@
+# procd API:
+#
+# procd_open_service(name, [script]):
+# Initialize a new procd command message containing a service with one or more instances
+#
+# procd_close_service()
+# Send the command message for the service
+#
+# procd_open_instance([name]):
+# Add an instance to the service described by the previous procd_open_service call
+#
+# procd_set_param(type, [value...])
+# Available types:
+# command: command line (array).
+# env: environment variable (passed to the process)
+# data: arbitrary name/value pairs for detecting config changes (table)
+# file: configuration files (array)
+# netdev: bound network device (detects ifindex changes)
+#
+# No space separation is done for arrays/tables - use one function argument per command line argument
+#
+# procd_close_instance():
+# Complete the instance being prepared
+#
+# procd_kill(service, [instance]):
+# Kill a service instance (or all instances)
+#
+
+. $IPKG_INSTROOT/usr/share/libubox/jshn.sh
+
+_PROCD_SERVICE=
+
+_procd_call() {
+ local old_cb
+
+ json_set_namespace procd old_cb
+ "$@"
+ json_set_namespace $old_cb
+}
+
+_procd_wrapper() {
+ while [ -n "$1" ]; do
+ eval "$1() { _procd_call _$1 \"\$@\"; }"
+ shift
+ done
+}
+
+_procd_ubus_call() {
+ local cmd="$1"
+
+ ubus call service "$cmd" "$(json_dump)"
+ json_cleanup
+}
+
+_procd_open_service() {
+ local name="$1"
+ local script="$2"
+
+ _PROCD_SERVICE="$name"
+ _PROCD_INSTANCE_SEQ=0
+
+ json_init
+ json_add_string name "$name"
+ [ -n "$script" ] && json_add_string script "$script"
+ json_add_object instances
+}
+
+_procd_close_service() {
+ json_close_object
+ _procd_ubus_call set
+}
+
+_procd_add_array_data() {
+ while [ -n "$1" ]; do
+ json_add_string "" "$1"
+ shift
+ done
+}
+
+_procd_add_array() {
+ json_add_array "$1"
+ shift
+ _procd_add_array_data "$@"
+ json_close_array
+}
+
+_procd_add_table_data() {
+ while [ -n "$1" ]; do
+ local var="${1%%=*}"
+ local val="${1#*=}"
+ [[ "$1" == "$val" ]] && val=
+ json_add_string "$var" "$val"
+ shift
+ done
+}
+
+_procd_add_table() {
+ json_add_object "$1"
+ shift
+ _procd_add_table_data "$@"
+ json_close_object
+}
+
+_procd_open_instance() {
+ local name="$1"; shift
+
+ _PROCD_INSTANCE_SEQ="$(($_PROCD_INSTANCE_SEQ + 1))"
+ name="${name:-instance$_PROCD_INSTANCE_SEQ}"
+ json_add_object "$name"
+}
+
+_procd_set_param() {
+ local type="$1"; shift
+
+ case "$type" in
+ env|data)
+ _procd_add_table "$type" "$@"
+ ;;
+ command|netdev|file)
+ _procd_add_array "$type" "$@"
+ ;;
+ nice)
+ json_add_int "$type" "$1"
+ ;;
+ esac
+}
+
+_procd_append_param() {
+ local type="$1"; shift
+
+ json_select "$type"
+ case "$type" in
+ env|data)
+ _procd_add_table_data "$@"
+ ;;
+ command|netdev|file)
+ _procd_add_array_data "$@"
+ ;;
+ esac
+ json_select ..
+}
+
+_procd_close_instance() {
+ json_close_object
+}
+
+_procd_add_instance() {
+ _procd_open_instance
+ _procd_set_command "$@"
+ _procd_close_instance
+}
+
+_procd_kill() {
+ local service="$1"
+ local instance="$2"
+
+ json_init
+ [ -n "$service" ] && json_add_string service "$service"
+ [ -n "$instance" ] && json_add_string instance "$instance"
+ _procd_ubus_call delete
+}
+
+_procd_wrapper \
+ procd_open_service \
+ procd_close_service \
+ procd_add_instance \
+ procd_open_instance \
+ procd_close_instance \
+ procd_set_param \
+ procd_append_param \
+ procd_kill
diff --git a/package/px5g/.svn/entries b/package/px5g/.svn/entries
new file mode 100644
index 0000000..996f39a
--- /dev/null
+++ b/package/px5g/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/px5g
+svn://svn.openwrt.org/openwrt
+
+
+
+2010-09-30T10:48:37.964618Z
+23159
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+src
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+27a35f2227dd4baa14dd0f05c52a527c
+2010-09-30T10:48:37.964618Z
+23159
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+928
+
diff --git a/package/px5g/.svn/text-base/Makefile.svn-base b/package/px5g/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..ad4ec40
--- /dev/null
+++ b/package/px5g/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,40 @@
+#
+# Copyright (C) 2010 Jo-Philipp Wich <xm@subsignal.org>
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=px5g
+PKG_RELEASE:=1
+
+PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/px5g
+ SECTION:=utils
+ CATEGORY:=Utilities
+ TITLE:=Standalone X.509 certificate generator
+ MAINTAINER:=Jo-Philipp Wich <xm@subsignal.org>
+endef
+
+define Package/px5g/description
+ Px5g is a tiny standalone X.509 certificate generator.
+ It suitable to create key files and certificates in DER
+ and PEM format for use with stunnel, uhttpd and others.
+endef
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+define Package/px5g/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/px5g $(1)/usr/sbin/px5g
+endef
+
+$(eval $(call BuildPackage,px5g))
diff --git a/package/px5g/Makefile b/package/px5g/Makefile
new file mode 100644
index 0000000..ad4ec40
--- /dev/null
+++ b/package/px5g/Makefile
@@ -0,0 +1,40 @@
+#
+# Copyright (C) 2010 Jo-Philipp Wich <xm@subsignal.org>
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=px5g
+PKG_RELEASE:=1
+
+PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/px5g
+ SECTION:=utils
+ CATEGORY:=Utilities
+ TITLE:=Standalone X.509 certificate generator
+ MAINTAINER:=Jo-Philipp Wich <xm@subsignal.org>
+endef
+
+define Package/px5g/description
+ Px5g is a tiny standalone X.509 certificate generator.
+ It suitable to create key files and certificates in DER
+ and PEM format for use with stunnel, uhttpd and others.
+endef
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+define Package/px5g/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/px5g $(1)/usr/sbin/px5g
+endef
+
+$(eval $(call BuildPackage,px5g))
diff --git a/package/px5g/src/.svn/entries b/package/px5g/src/.svn/entries
new file mode 100644
index 0000000..8b200b4
--- /dev/null
+++ b/package/px5g/src/.svn/entries
@@ -0,0 +1,102 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/px5g/src
+svn://svn.openwrt.org/openwrt
+
+
+
+2010-03-25T15:46:39.389627Z
+20429
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+polarssl
+dir
+
+library
+dir
+
+px5g.c
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+31953bc6a8a8c503b901e44132852617
+2010-03-25T15:46:39.389627Z
+20429
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5306
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+930711c1f3981f7a05d746e0c7199662
+2010-03-25T15:46:39.389627Z
+20429
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+226
+
diff --git a/package/px5g/src/.svn/text-base/Makefile.svn-base b/package/px5g/src/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..2bd9573
--- /dev/null
+++ b/package/px5g/src/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,14 @@
+CFLAGS?=-O2
+CFLAGS+=
+SFLAGS:=--std=gnu99
+WFLAGS:=-Wall -Werror -pedantic
+LDFLAGS?=
+BINARY:=px5g
+
+all: $(BINARY)
+
+$(BINARY): *.c library/*.c
+ $(CC) -I. $(CFLAGS) $(SFLAGS) $(WFLAGS) $(LDFLAGS) -o $@ $+
+
+clean:
+ rm -f $(BINARY)
diff --git a/package/px5g/src/.svn/text-base/px5g.c.svn-base b/package/px5g/src/.svn/text-base/px5g.c.svn-base
new file mode 100644
index 0000000..2b3e785
--- /dev/null
+++ b/package/px5g/src/.svn/text-base/px5g.c.svn-base
@@ -0,0 +1,197 @@
+/*
+ * px5g - Embedded x509 key and certificate generator based on PolarSSL
+ *
+ * Copyright (C) 2009 Steven Barth <steven@midlink.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License, version 2.1 as published by the Free Software Foundation.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include "polarssl/havege.h"
+#include "polarssl/bignum.h"
+#include "polarssl/x509.h"
+#include "polarssl/rsa.h"
+
+#define PX5G_VERSION "0.1"
+#define PX5G_COPY "Copyright (c) 2009 Steven Barth <steven@midlink.org>"
+#define PX5G_LICENSE "Licensed under the GNU Lesser General Public License v2.1"
+
+int rsakey(char **arg) {
+ havege_state hs;
+ rsa_context rsa;
+
+ unsigned int ksize = 512;
+ int exp = 65537;
+ char *path = NULL;
+ int flag = X509_OUTPUT_PEM;
+
+ while (*arg && **arg == '-') {
+ if (!strcmp(*arg, "-out") && arg[1]) {
+ path = arg[1];
+ arg++;
+ } else if (!strcmp(*arg, "-3")) {
+ exp = 3;
+ } else if (!strcmp(*arg, "-der")) {
+ flag = X509_OUTPUT_DER;
+ }
+ arg++;
+ }
+
+ if (*arg) {
+ ksize = (unsigned int)atoi(*arg);
+ }
+
+ havege_init(&hs);
+ rsa_init(&rsa, RSA_PKCS_V15, 0, havege_rand, &hs);
+
+ fprintf(stderr, "Generating RSA private key, %i bit long modulus\n", ksize);
+ if (rsa_gen_key(&rsa, ksize, exp)) {
+ fprintf(stderr, "error: key generation failed\n");
+ return 1;
+ }
+
+ if (x509write_keyfile(&rsa, path, flag)) {
+ fprintf(stderr, "error: I/O error\n");
+ return 1;
+ }
+
+ rsa_free(&rsa);
+ return 0;
+}
+
+int selfsigned(char **arg) {
+ havege_state hs;
+ rsa_context rsa;
+ x509_node node;
+
+ char *subject = "";
+ unsigned int ksize = 512;
+ int exp = 65537;
+ unsigned int days = 30;
+ char *keypath = NULL, *certpath = NULL;
+ int flag = X509_OUTPUT_PEM;
+ time_t from = time(NULL), to;
+ char fstr[20], tstr[20];
+
+ while (*arg && **arg == '-') {
+ if (!strcmp(*arg, "-der")) {
+ flag = X509_OUTPUT_DER;
+ } else if (!strcmp(*arg, "-newkey") && arg[1]) {
+ if (strncmp(arg[1], "rsa:", 4)) {
+ fprintf(stderr, "error: invalid algorithm");
+ return 1;
+ }
+ ksize = (unsigned int)atoi(arg[1] + 4);
+ arg++;
+ } else if (!strcmp(*arg, "-days") && arg[1]) {
+ days = (unsigned int)atoi(arg[1]);
+ arg++;
+ } else if (!strcmp(*arg, "-keyout") && arg[1]) {
+ keypath = arg[1];
+ arg++;
+ } else if (!strcmp(*arg, "-out") && arg[1]) {
+ certpath = arg[1];
+ arg++;
+ } else if (!strcmp(*arg, "-subj") && arg[1]) {
+ if (arg[1][0] != '/' || strchr(arg[1], ';')) {
+ fprintf(stderr, "error: invalid subject");
+ return 1;
+ }
+ subject = calloc(strlen(arg[1]) + 1, 1);
+ char *oldc = arg[1] + 1, *newc = subject, *delim;
+ do {
+ delim = strchr(oldc, '=');
+ if (!delim) {
+ fprintf(stderr, "error: invalid subject");
+ return 1;
+ }
+ memcpy(newc, oldc, delim - oldc + 1);
+ newc += delim - oldc + 1;
+ oldc = delim + 1;
+
+ delim = strchr(oldc, '/');
+ if (!delim) {
+ delim = arg[1] + strlen(arg[1]);
+ }
+ memcpy(newc, oldc, delim - oldc);
+ newc += delim - oldc;
+ *newc++ = ';';
+ oldc = delim + 1;
+ } while(*delim);
+ arg++;
+ }
+ arg++;
+ }
+
+ havege_init(&hs);
+ rsa_init(&rsa, RSA_PKCS_V15, 0, havege_rand, &hs);
+ x509write_init_node(&node);
+ fprintf(stderr, "Generating RSA private key, %i bit long modulus\n", ksize);
+ if (rsa_gen_key(&rsa, ksize, exp)) {
+ fprintf(stderr, "error: key generation failed\n");
+ return 1;
+ }
+
+ if (keypath) {
+ if (x509write_keyfile(&rsa, keypath, flag)) {
+ fprintf(stderr, "error: I/O error\n");
+ return 1;
+ }
+ }
+
+ from = (from < 1000000000) ? 1000000000 : from;
+ strftime(fstr, sizeof(fstr), "%F %H:%M:%S", gmtime(&from));
+ to = from + 60 * 60 * 24 * days;
+ strftime(tstr, sizeof(tstr), "%F %H:%M:%S", gmtime(&to));
+
+ x509_raw cert;
+ x509write_init_raw(&cert);
+ x509write_add_pubkey(&cert, &rsa);
+ x509write_add_subject(&cert, (unsigned char*)subject);
+ x509write_add_validity(&cert, (unsigned char*)fstr, (unsigned char*)tstr);
+ fprintf(stderr, "Generating selfsigned certificate with subject '%s'"
+ " and validity %s-%s\n", subject, fstr, tstr);
+ if (x509write_create_selfsign(&cert, &rsa)) {
+ fprintf(stderr, "error: certificate generation failed\n");
+ }
+
+ if (x509write_crtfile(&cert, (unsigned char*)certpath, flag)) {
+ fprintf(stderr, "error: I/O error\n");
+ return 1;
+ }
+
+ x509write_free_raw(&cert);
+ rsa_free(&rsa);
+ return 0;
+}
+
+int main(int argc, char *argv[]) {
+ if (!argv[1]) {
+ //Usage
+ } else if (!strcmp(argv[1], "rsakey")) {
+ return rsakey(argv+2);
+ } else if (!strcmp(argv[1], "selfsigned")) {
+ return selfsigned(argv+2);
+ }
+
+ fprintf(stderr,
+ "PX5G X.509 Certificate Generator Utility v" PX5G_VERSION "\n" PX5G_COPY
+ "\nbased on PolarSSL by Christophe Devine and Paul Bakker\n\n");
+ fprintf(stderr, "Usage: %s [rsakey|selfsigned]\n", *argv);
+ return 1;
+}
diff --git a/package/px5g/src/Makefile b/package/px5g/src/Makefile
new file mode 100644
index 0000000..2bd9573
--- /dev/null
+++ b/package/px5g/src/Makefile
@@ -0,0 +1,14 @@
+CFLAGS?=-O2
+CFLAGS+=
+SFLAGS:=--std=gnu99
+WFLAGS:=-Wall -Werror -pedantic
+LDFLAGS?=
+BINARY:=px5g
+
+all: $(BINARY)
+
+$(BINARY): *.c library/*.c
+ $(CC) -I. $(CFLAGS) $(SFLAGS) $(WFLAGS) $(LDFLAGS) -o $@ $+
+
+clean:
+ rm -f $(BINARY)
diff --git a/package/px5g/src/library/.svn/entries b/package/px5g/src/library/.svn/entries
new file mode 100644
index 0000000..146082b
--- /dev/null
+++ b/package/px5g/src/library/.svn/entries
@@ -0,0 +1,266 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/px5g/src/library
+svn://svn.openwrt.org/openwrt
+
+
+
+2010-03-25T15:46:39.389627Z
+20429
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+havege.c
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+cc2e93a0f39f8751ed125aca0b187881
+2010-03-25T15:46:39.389627Z
+20429
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+10228
+
+x509write.c
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+6ebf62f83d1d2e39ccf1f3fdc2c5e2f4
+2010-03-25T15:46:39.389627Z
+20429
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+28518
+
+bignum.c
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+74b042512de171aca695f9c21d1a6005
+2010-03-25T15:46:39.389627Z
+20429
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+41605
+
+base64.c
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+44ba8e1140ac3d9f0c11a58556925b62
+2010-03-25T15:46:39.389627Z
+20429
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+7381
+
+rsa.c
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+de371923bcfca74c6c04568da5a5bba3
+2010-03-25T15:46:39.389627Z
+20429
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+19286
+
+timing.c
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+0ca59560e34d117c846beddf72436a7f
+2010-03-25T15:46:39.389627Z
+20429
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5862
+
+sha1.c
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+719ec4f927bdd88e796bea0c58b6a2b8
+2010-03-25T15:46:39.389627Z
+20429
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+16757
+
diff --git a/package/px5g/src/library/.svn/text-base/base64.c.svn-base b/package/px5g/src/library/.svn/text-base/base64.c.svn-base
new file mode 100644
index 0000000..b7cc5b8
--- /dev/null
+++ b/package/px5g/src/library/.svn/text-base/base64.c.svn-base
@@ -0,0 +1,264 @@
+/*
+ * RFC 1521 base64 encoding/decoding
+ *
+ * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
+ *
+ * Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the names of PolarSSL or XySSL nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "polarssl/config.h"
+
+#if defined(POLARSSL_BASE64_C)
+
+#include "polarssl/base64.h"
+
+static const unsigned char base64_enc_map[64] =
+{
+ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
+ 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
+ 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd',
+ 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
+ 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x',
+ 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7',
+ '8', '9', '+', '/'
+};
+
+static const unsigned char base64_dec_map[128] =
+{
+ 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
+ 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
+ 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
+ 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
+ 127, 127, 127, 62, 127, 127, 127, 63, 52, 53,
+ 54, 55, 56, 57, 58, 59, 60, 61, 127, 127,
+ 127, 64, 127, 127, 127, 0, 1, 2, 3, 4,
+ 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
+ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
+ 25, 127, 127, 127, 127, 127, 127, 26, 27, 28,
+ 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
+ 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
+ 49, 50, 51, 127, 127, 127, 127, 127
+};
+
+/*
+ * Encode a buffer into base64 format
+ */
+int base64_encode( unsigned char *dst, int *dlen,
+ unsigned char *src, int slen )
+{
+ int i, n;
+ int C1, C2, C3;
+ unsigned char *p;
+
+ if( slen == 0 )
+ return( 0 );
+
+ n = (slen << 3) / 6;
+
+ switch( (slen << 3) - (n * 6) )
+ {
+ case 2: n += 3; break;
+ case 4: n += 2; break;
+ default: break;
+ }
+
+ if( *dlen < n + 1 )
+ {
+ *dlen = n + 1;
+ return( POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL );
+ }
+
+ n = (slen / 3) * 3;
+
+ for( i = 0, p = dst; i < n; i += 3 )
+ {
+ C1 = *src++;
+ C2 = *src++;
+ C3 = *src++;
+
+ *p++ = base64_enc_map[(C1 >> 2) & 0x3F];
+ *p++ = base64_enc_map[(((C1 & 3) << 4) + (C2 >> 4)) & 0x3F];
+ *p++ = base64_enc_map[(((C2 & 15) << 2) + (C3 >> 6)) & 0x3F];
+ *p++ = base64_enc_map[C3 & 0x3F];
+ }
+
+ if( i < slen )
+ {
+ C1 = *src++;
+ C2 = ((i + 1) < slen) ? *src++ : 0;
+
+ *p++ = base64_enc_map[(C1 >> 2) & 0x3F];
+ *p++ = base64_enc_map[(((C1 & 3) << 4) + (C2 >> 4)) & 0x3F];
+
+ if( (i + 1) < slen )
+ *p++ = base64_enc_map[((C2 & 15) << 2) & 0x3F];
+ else *p++ = '=';
+
+ *p++ = '=';
+ }
+
+ *dlen = p - dst;
+ *p = 0;
+
+ return( 0 );
+}
+
+/*
+ * Decode a base64-formatted buffer
+ */
+int base64_decode( unsigned char *dst, int *dlen,
+ unsigned char *src, int slen )
+{
+ int i, j, n;
+ unsigned long x;
+ unsigned char *p;
+
+ for( i = j = n = 0; i < slen; i++ )
+ {
+ if( ( slen - i ) >= 2 &&
+ src[i] == '\r' && src[i + 1] == '\n' )
+ continue;
+
+ if( src[i] == '\n' )
+ continue;
+
+ if( src[i] == '=' && ++j > 2 )
+ return( POLARSSL_ERR_BASE64_INVALID_CHARACTER );
+
+ if( src[i] > 127 || base64_dec_map[src[i]] == 127 )
+ return( POLARSSL_ERR_BASE64_INVALID_CHARACTER );
+
+ if( base64_dec_map[src[i]] < 64 && j != 0 )
+ return( POLARSSL_ERR_BASE64_INVALID_CHARACTER );
+
+ n++;
+ }
+
+ if( n == 0 )
+ return( 0 );
+
+ n = ((n * 6) + 7) >> 3;
+
+ if( *dlen < n )
+ {
+ *dlen = n;
+ return( POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL );
+ }
+
+ for( j = 3, n = x = 0, p = dst; i > 0; i--, src++ )
+ {
+ if( *src == '\r' || *src == '\n' )
+ continue;
+
+ j -= ( base64_dec_map[*src] == 64 );
+ x = (x << 6) | ( base64_dec_map[*src] & 0x3F );
+
+ if( ++n == 4 )
+ {
+ n = 0;
+ if( j > 0 ) *p++ = (unsigned char)( x >> 16 );
+ if( j > 1 ) *p++ = (unsigned char)( x >> 8 );
+ if( j > 2 ) *p++ = (unsigned char)( x );
+ }
+ }
+
+ *dlen = p - dst;
+
+ return( 0 );
+}
+
+#if defined(POLARSSL_SELF_TEST)
+
+#include <string.h>
+#include <stdio.h>
+
+static const unsigned char base64_test_dec[64] =
+{
+ 0x24, 0x48, 0x6E, 0x56, 0x87, 0x62, 0x5A, 0xBD,
+ 0xBF, 0x17, 0xD9, 0xA2, 0xC4, 0x17, 0x1A, 0x01,
+ 0x94, 0xED, 0x8F, 0x1E, 0x11, 0xB3, 0xD7, 0x09,
+ 0x0C, 0xB6, 0xE9, 0x10, 0x6F, 0x22, 0xEE, 0x13,
+ 0xCA, 0xB3, 0x07, 0x05, 0x76, 0xC9, 0xFA, 0x31,
+ 0x6C, 0x08, 0x34, 0xFF, 0x8D, 0xC2, 0x6C, 0x38,
+ 0x00, 0x43, 0xE9, 0x54, 0x97, 0xAF, 0x50, 0x4B,
+ 0xD1, 0x41, 0xBA, 0x95, 0x31, 0x5A, 0x0B, 0x97
+};
+
+static const unsigned char base64_test_enc[] =
+ "JEhuVodiWr2/F9mixBcaAZTtjx4Rs9cJDLbpEG8i7hPK"
+ "swcFdsn6MWwINP+Nwmw4AEPpVJevUEvRQbqVMVoLlw==";
+
+/*
+ * Checkup routine
+ */
+int base64_self_test( int verbose )
+{
+ int len;
+ unsigned char *src, buffer[128];
+
+ if( verbose != 0 )
+ printf( " Base64 encoding test: " );
+
+ len = sizeof( buffer );
+ src = (unsigned char *) base64_test_dec;
+
+ if( base64_encode( buffer, &len, src, 64 ) != 0 ||
+ memcmp( base64_test_enc, buffer, 88 ) != 0 )
+ {
+ if( verbose != 0 )
+ printf( "failed\n" );
+
+ return( 1 );
+ }
+
+ if( verbose != 0 )
+ printf( "passed\n Base64 decoding test: " );
+
+ len = sizeof( buffer );
+ src = (unsigned char *) base64_test_enc;
+
+ if( base64_decode( buffer, &len, src, 88 ) != 0 ||
+ memcmp( base64_test_dec, buffer, 64 ) != 0 )
+ {
+ if( verbose != 0 )
+ printf( "failed\n" );
+
+ return( 1 );
+ }
+
+ if( verbose != 0 )
+ printf( "passed\n\n" );
+
+ return( 0 );
+}
+
+#endif
+
+#endif
diff --git a/package/px5g/src/library/.svn/text-base/bignum.c.svn-base b/package/px5g/src/library/.svn/text-base/bignum.c.svn-base
new file mode 100644
index 0000000..8b7c12f
--- /dev/null
+++ b/package/px5g/src/library/.svn/text-base/bignum.c.svn-base
@@ -0,0 +1,2010 @@
+/*
+ * Multi-precision integer library
+ *
+ * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
+ *
+ * Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the names of PolarSSL or XySSL nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+/*
+ * This MPI implementation is based on:
+ *
+ * http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf
+ * http://www.stillhq.com/extracted/gnupg-api/mpi/
+ * http://math.libtomcrypt.com/files/tommath.pdf
+ */
+
+#include "polarssl/config.h"
+
+#if defined(POLARSSL_BIGNUM_C)
+
+#include "polarssl/bignum.h"
+#include "polarssl/bn_mul.h"
+
+#include <string.h>
+#include <stdlib.h>
+#include <stdarg.h>
+
+#define ciL ((int) sizeof(t_int)) /* chars in limb */
+#define biL (ciL << 3) /* bits in limb */
+#define biH (ciL << 2) /* half limb size */
+
+/*
+ * Convert between bits/chars and number of limbs
+ */
+#define BITS_TO_LIMBS(i) (((i) + biL - 1) / biL)
+#define CHARS_TO_LIMBS(i) (((i) + ciL - 1) / ciL)
+
+/*
+ * Initialize one or more mpi
+ */
+void mpi_init( mpi *X, ... )
+{
+ va_list args;
+
+ va_start( args, X );
+
+ while( X != NULL )
+ {
+ X->s = 1;
+ X->n = 0;
+ X->p = NULL;
+
+ X = va_arg( args, mpi* );
+ }
+
+ va_end( args );
+}
+
+/*
+ * Unallocate one or more mpi
+ */
+void mpi_free( mpi *X, ... )
+{
+ va_list args;
+
+ va_start( args, X );
+
+ while( X != NULL )
+ {
+ if( X->p != NULL )
+ {
+ memset( X->p, 0, X->n * ciL );
+ free( X->p );
+ }
+
+ X->s = 1;
+ X->n = 0;
+ X->p = NULL;
+
+ X = va_arg( args, mpi* );
+ }
+
+ va_end( args );
+}
+
+/*
+ * Enlarge to the specified number of limbs
+ */
+int mpi_grow( mpi *X, int nblimbs )
+{
+ t_int *p;
+
+ if( X->n < nblimbs )
+ {
+ if( ( p = (t_int *) malloc( nblimbs * ciL ) ) == NULL )
+ return( 1 );
+
+ memset( p, 0, nblimbs * ciL );
+
+ if( X->p != NULL )
+ {
+ memcpy( p, X->p, X->n * ciL );
+ memset( X->p, 0, X->n * ciL );
+ free( X->p );
+ }
+
+ X->n = nblimbs;
+ X->p = p;
+ }
+
+ return( 0 );
+}
+
+/*
+ * Copy the contents of Y into X
+ */
+int mpi_copy( mpi *X, mpi *Y )
+{
+ int ret, i;
+
+ if( X == Y )
+ return( 0 );
+
+ for( i = Y->n - 1; i > 0; i-- )
+ if( Y->p[i] != 0 )
+ break;
+ i++;
+
+ X->s = Y->s;
+
+ MPI_CHK( mpi_grow( X, i ) );
+
+ memset( X->p, 0, X->n * ciL );
+ memcpy( X->p, Y->p, i * ciL );
+
+cleanup:
+
+ return( ret );
+}
+
+/*
+ * Swap the contents of X and Y
+ */
+void mpi_swap( mpi *X, mpi *Y )
+{
+ mpi T;
+
+ memcpy( &T, X, sizeof( mpi ) );
+ memcpy( X, Y, sizeof( mpi ) );
+ memcpy( Y, &T, sizeof( mpi ) );
+}
+
+/*
+ * Set value from integer
+ */
+int mpi_lset( mpi *X, int z )
+{
+ int ret;
+
+ MPI_CHK( mpi_grow( X, 1 ) );
+ memset( X->p, 0, X->n * ciL );
+
+ X->p[0] = ( z < 0 ) ? -z : z;
+ X->s = ( z < 0 ) ? -1 : 1;
+
+cleanup:
+
+ return( ret );
+}
+
+/*
+ * Return the number of least significant bits
+ */
+int mpi_lsb( mpi *X )
+{
+ int i, j, count = 0;
+
+ for( i = 0; i < X->n; i++ )
+ for( j = 0; j < (int) biL; j++, count++ )
+ if( ( ( X->p[i] >> j ) & 1 ) != 0 )
+ return( count );
+
+ return( 0 );
+}
+
+/*
+ * Return the number of most significant bits
+ */
+int mpi_msb( mpi *X )
+{
+ int i, j;
+
+ for( i = X->n - 1; i > 0; i-- )
+ if( X->p[i] != 0 )
+ break;
+
+ for( j = biL - 1; j >= 0; j-- )
+ if( ( ( X->p[i] >> j ) & 1 ) != 0 )
+ break;
+
+ return( ( i * biL ) + j + 1 );
+}
+
+/*
+ * Return the total size in bytes
+ */
+int mpi_size( mpi *X )
+{
+ return( ( mpi_msb( X ) + 7 ) >> 3 );
+}
+
+/*
+ * Convert an ASCII character to digit value
+ */
+static int mpi_get_digit( t_int *d, int radix, char c )
+{
+ *d = 255;
+
+ if( c >= 0x30 && c <= 0x39 ) *d = c - 0x30;
+ if( c >= 0x41 && c <= 0x46 ) *d = c - 0x37;
+ if( c >= 0x61 && c <= 0x66 ) *d = c - 0x57;
+
+ if( *d >= (t_int) radix )
+ return( POLARSSL_ERR_MPI_INVALID_CHARACTER );
+
+ return( 0 );
+}
+
+/*
+ * Import from an ASCII string
+ */
+int mpi_read_string( mpi *X, int radix, char *s )
+{
+ int ret, i, j, n;
+ t_int d;
+ mpi T;
+
+ if( radix < 2 || radix > 16 )
+ return( POLARSSL_ERR_MPI_BAD_INPUT_DATA );
+
+ mpi_init( &T, NULL );
+
+ if( radix == 16 )
+ {
+ n = BITS_TO_LIMBS( strlen( s ) << 2 );
+
+ MPI_CHK( mpi_grow( X, n ) );
+ MPI_CHK( mpi_lset( X, 0 ) );
+
+ for( i = strlen( s ) - 1, j = 0; i >= 0; i--, j++ )
+ {
+ if( i == 0 && s[i] == '-' )
+ {
+ X->s = -1;
+ break;
+ }
+
+ MPI_CHK( mpi_get_digit( &d, radix, s[i] ) );
+ X->p[j / (2 * ciL)] |= d << ( (j % (2 * ciL)) << 2 );
+ }
+ }
+ else
+ {
+ MPI_CHK( mpi_lset( X, 0 ) );
+
+ for( i = 0; i < (int) strlen( s ); i++ )
+ {
+ if( i == 0 && s[i] == '-' )
+ {
+ X->s = -1;
+ continue;
+ }
+
+ MPI_CHK( mpi_get_digit( &d, radix, s[i] ) );
+ MPI_CHK( mpi_mul_int( &T, X, radix ) );
+ MPI_CHK( mpi_add_int( X, &T, d ) );
+ }
+ }
+
+cleanup:
+
+ mpi_free( &T, NULL );
+
+ return( ret );
+}
+
+/*
+ * Helper to write the digits high-order first
+ */
+static int mpi_write_hlp( mpi *X, int radix, char **p )
+{
+ int ret;
+ t_int r;
+
+ if( radix < 2 || radix > 16 )
+ return( POLARSSL_ERR_MPI_BAD_INPUT_DATA );
+
+ MPI_CHK( mpi_mod_int( &r, X, radix ) );
+ MPI_CHK( mpi_div_int( X, NULL, X, radix ) );
+
+ if( mpi_cmp_int( X, 0 ) != 0 )
+ MPI_CHK( mpi_write_hlp( X, radix, p ) );
+
+ if( r < 10 )
+ *(*p)++ = (char)( r + 0x30 );
+ else
+ *(*p)++ = (char)( r + 0x37 );
+
+cleanup:
+
+ return( ret );
+}
+
+/*
+ * Export into an ASCII string
+ */
+int mpi_write_string( mpi *X, int radix, char *s, int *slen )
+{
+ int ret = 0, n;
+ char *p;
+ mpi T;
+
+ if( radix < 2 || radix > 16 )
+ return( POLARSSL_ERR_MPI_BAD_INPUT_DATA );
+
+ n = mpi_msb( X );
+ if( radix >= 4 ) n >>= 1;
+ if( radix >= 16 ) n >>= 1;
+ n += 3;
+
+ if( *slen < n )
+ {
+ *slen = n;
+ return( POLARSSL_ERR_MPI_BUFFER_TOO_SMALL );
+ }
+
+ p = s;
+ mpi_init( &T, NULL );
+
+ if( X->s == -1 )
+ *p++ = '-';
+
+ if( radix == 16 )
+ {
+ int c, i, j, k;
+
+ for( i = X->n - 1, k = 0; i >= 0; i-- )
+ {
+ for( j = ciL - 1; j >= 0; j-- )
+ {
+ c = ( X->p[i] >> (j << 3) ) & 0xFF;
+
+ if( c == 0 && k == 0 && (i + j) != 0 )
+ continue;
+
+ p += sprintf( p, "%02X", c );
+ k = 1;
+ }
+ }
+ }
+ else
+ {
+ MPI_CHK( mpi_copy( &T, X ) );
+ MPI_CHK( mpi_write_hlp( &T, radix, &p ) );
+ }
+
+ *p++ = '\0';
+ *slen = p - s;
+
+cleanup:
+
+ mpi_free( &T, NULL );
+
+ return( ret );
+}
+
+/*
+ * Read X from an opened file
+ */
+int mpi_read_file( mpi *X, int radix, FILE *fin )
+{
+ t_int d;
+ int slen;
+ char *p;
+ char s[1024];
+
+ memset( s, 0, sizeof( s ) );
+ if( fgets( s, sizeof( s ) - 1, fin ) == NULL )
+ return( POLARSSL_ERR_MPI_FILE_IO_ERROR );
+
+ slen = strlen( s );
+ if( s[slen - 1] == '\n' ) { slen--; s[slen] = '\0'; }
+ if( s[slen - 1] == '\r' ) { slen--; s[slen] = '\0'; }
+
+ p = s + slen;
+ while( --p >= s )
+ if( mpi_get_digit( &d, radix, *p ) != 0 )
+ break;
+
+ return( mpi_read_string( X, radix, p + 1 ) );
+}
+
+/*
+ * Write X into an opened file (or stdout if fout == NULL)
+ */
+int mpi_write_file( char *p, mpi *X, int radix, FILE *fout )
+{
+ int n, ret;
+ size_t slen;
+ size_t plen;
+ char s[1024];
+
+ n = sizeof( s );
+ memset( s, 0, n );
+ n -= 2;
+
+ MPI_CHK( mpi_write_string( X, radix, s, (int *) &n ) );
+
+ if( p == NULL ) p = "";
+
+ plen = strlen( p );
+ slen = strlen( s );
+ s[slen++] = '\r';
+ s[slen++] = '\n';
+
+ if( fout != NULL )
+ {
+ if( fwrite( p, 1, plen, fout ) != plen ||
+ fwrite( s, 1, slen, fout ) != slen )
+ return( POLARSSL_ERR_MPI_FILE_IO_ERROR );
+ }
+ else
+ printf( "%s%s", p, s );
+
+cleanup:
+
+ return( ret );
+}
+
+/*
+ * Import X from unsigned binary data, big endian
+ */
+int mpi_read_binary( mpi *X, unsigned char *buf, int buflen )
+{
+ int ret, i, j, n;
+
+ for( n = 0; n < buflen; n++ )
+ if( buf[n] != 0 )
+ break;
+
+ MPI_CHK( mpi_grow( X, CHARS_TO_LIMBS( buflen - n ) ) );
+ MPI_CHK( mpi_lset( X, 0 ) );
+
+ for( i = buflen - 1, j = 0; i >= n; i--, j++ )
+ X->p[j / ciL] |= ((t_int) buf[i]) << ((j % ciL) << 3);
+
+cleanup:
+
+ return( ret );
+}
+
+/*
+ * Export X into unsigned binary data, big endian
+ */
+int mpi_write_binary( mpi *X, unsigned char *buf, int buflen )
+{
+ int i, j, n;
+
+ n = mpi_size( X );
+
+ if( buflen < n )
+ return( POLARSSL_ERR_MPI_BUFFER_TOO_SMALL );
+
+ memset( buf, 0, buflen );
+
+ for( i = buflen - 1, j = 0; n > 0; i--, j++, n-- )
+ buf[i] = (unsigned char)( X->p[j / ciL] >> ((j % ciL) << 3) );
+
+ return( 0 );
+}
+
+/*
+ * Left-shift: X <<= count
+ */
+int mpi_shift_l( mpi *X, int count )
+{
+ int ret, i, v0, t1;
+ t_int r0 = 0, r1;
+
+ v0 = count / (biL );
+ t1 = count & (biL - 1);
+
+ i = mpi_msb( X ) + count;
+
+ if( X->n * (int) biL < i )
+ MPI_CHK( mpi_grow( X, BITS_TO_LIMBS( i ) ) );
+
+ ret = 0;
+
+ /*
+ * shift by count / limb_size
+ */
+ if( v0 > 0 )
+ {
+ for( i = X->n - 1; i >= v0; i-- )
+ X->p[i] = X->p[i - v0];
+
+ for( ; i >= 0; i-- )
+ X->p[i] = 0;
+ }
+
+ /*
+ * shift by count % limb_size
+ */
+ if( t1 > 0 )
+ {
+ for( i = v0; i < X->n; i++ )
+ {
+ r1 = X->p[i] >> (biL - t1);
+ X->p[i] <<= t1;
+ X->p[i] |= r0;
+ r0 = r1;
+ }
+ }
+
+cleanup:
+
+ return( ret );
+}
+
+/*
+ * Right-shift: X >>= count
+ */
+int mpi_shift_r( mpi *X, int count )
+{
+ int i, v0, v1;
+ t_int r0 = 0, r1;
+
+ v0 = count / biL;
+ v1 = count & (biL - 1);
+
+ /*
+ * shift by count / limb_size
+ */
+ if( v0 > 0 )
+ {
+ for( i = 0; i < X->n - v0; i++ )
+ X->p[i] = X->p[i + v0];
+
+ for( ; i < X->n; i++ )
+ X->p[i] = 0;
+ }
+
+ /*
+ * shift by count % limb_size
+ */
+ if( v1 > 0 )
+ {
+ for( i = X->n - 1; i >= 0; i-- )
+ {
+ r1 = X->p[i] << (biL - v1);
+ X->p[i] >>= v1;
+ X->p[i] |= r0;
+ r0 = r1;
+ }
+ }
+
+ return( 0 );
+}
+
+/*
+ * Compare unsigned values
+ */
+int mpi_cmp_abs( mpi *X, mpi *Y )
+{
+ int i, j;
+
+ for( i = X->n - 1; i >= 0; i-- )
+ if( X->p[i] != 0 )
+ break;
+
+ for( j = Y->n - 1; j >= 0; j-- )
+ if( Y->p[j] != 0 )
+ break;
+
+ if( i < 0 && j < 0 )
+ return( 0 );
+
+ if( i > j ) return( 1 );
+ if( j > i ) return( -1 );
+
+ for( ; i >= 0; i-- )
+ {
+ if( X->p[i] > Y->p[i] ) return( 1 );
+ if( X->p[i] < Y->p[i] ) return( -1 );
+ }
+
+ return( 0 );
+}
+
+/*
+ * Compare signed values
+ */
+int mpi_cmp_mpi( mpi *X, mpi *Y )
+{
+ int i, j;
+
+ for( i = X->n - 1; i >= 0; i-- )
+ if( X->p[i] != 0 )
+ break;
+
+ for( j = Y->n - 1; j >= 0; j-- )
+ if( Y->p[j] != 0 )
+ break;
+
+ if( i < 0 && j < 0 )
+ return( 0 );
+
+ if( i > j ) return( X->s );
+ if( j > i ) return( -X->s );
+
+ if( X->s > 0 && Y->s < 0 ) return( 1 );
+ if( Y->s > 0 && X->s < 0 ) return( -1 );
+
+ for( ; i >= 0; i-- )
+ {
+ if( X->p[i] > Y->p[i] ) return( X->s );
+ if( X->p[i] < Y->p[i] ) return( -X->s );
+ }
+
+ return( 0 );
+}
+
+/*
+ * Compare signed values
+ */
+int mpi_cmp_int( mpi *X, int z )
+{
+ mpi Y;
+ t_int p[1];
+
+ *p = ( z < 0 ) ? -z : z;
+ Y.s = ( z < 0 ) ? -1 : 1;
+ Y.n = 1;
+ Y.p = p;
+
+ return( mpi_cmp_mpi( X, &Y ) );
+}
+
+/*
+ * Unsigned addition: X = |A| + |B| (HAC 14.7)
+ */
+int mpi_add_abs( mpi *X, mpi *A, mpi *B )
+{
+ int ret, i, j;
+ t_int *o, *p, c;
+
+ if( X == B )
+ {
+ mpi *T = A; A = X; B = T;
+ }
+
+ if( X != A )
+ MPI_CHK( mpi_copy( X, A ) );
+
+ for( j = B->n - 1; j >= 0; j-- )
+ if( B->p[j] != 0 )
+ break;
+
+ MPI_CHK( mpi_grow( X, j + 1 ) );
+
+ o = B->p; p = X->p; c = 0;
+
+ for( i = 0; i <= j; i++, o++, p++ )
+ {
+ *p += c; c = ( *p < c );
+ *p += *o; c += ( *p < *o );
+ }
+
+ while( c != 0 )
+ {
+ if( i >= X->n )
+ {
+ MPI_CHK( mpi_grow( X, i + 1 ) );
+ p = X->p + i;
+ }
+
+ *p += c; c = ( *p < c ); i++;
+ }
+
+cleanup:
+
+ return( ret );
+}
+
+/*
+ * Helper for mpi substraction
+ */
+static void mpi_sub_hlp( int n, t_int *s, t_int *d )
+{
+ int i;
+ t_int c, z;
+
+ for( i = c = 0; i < n; i++, s++, d++ )
+ {
+ z = ( *d < c ); *d -= c;
+ c = ( *d < *s ) + z; *d -= *s;
+ }
+
+ while( c != 0 )
+ {
+ z = ( *d < c ); *d -= c;
+ c = z; i++; d++;
+ }
+}
+
+/*
+ * Unsigned substraction: X = |A| - |B| (HAC 14.9)
+ */
+int mpi_sub_abs( mpi *X, mpi *A, mpi *B )
+{
+ mpi TB;
+ int ret, n;
+
+ if( mpi_cmp_abs( A, B ) < 0 )
+ return( POLARSSL_ERR_MPI_NEGATIVE_VALUE );
+
+ mpi_init( &TB, NULL );
+
+ if( X == B )
+ {
+ MPI_CHK( mpi_copy( &TB, B ) );
+ B = &TB;
+ }
+
+ if( X != A )
+ MPI_CHK( mpi_copy( X, A ) );
+
+ ret = 0;
+
+ for( n = B->n - 1; n >= 0; n-- )
+ if( B->p[n] != 0 )
+ break;
+
+ mpi_sub_hlp( n + 1, B->p, X->p );
+
+cleanup:
+
+ mpi_free( &TB, NULL );
+
+ return( ret );
+}
+
+/*
+ * Signed addition: X = A + B
+ */
+int mpi_add_mpi( mpi *X, mpi *A, mpi *B )
+{
+ int ret, s = A->s;
+
+ if( A->s * B->s < 0 )
+ {
+ if( mpi_cmp_abs( A, B ) >= 0 )
+ {
+ MPI_CHK( mpi_sub_abs( X, A, B ) );
+ X->s = s;
+ }
+ else
+ {
+ MPI_CHK( mpi_sub_abs( X, B, A ) );
+ X->s = -s;
+ }
+ }
+ else
+ {
+ MPI_CHK( mpi_add_abs( X, A, B ) );
+ X->s = s;
+ }
+
+cleanup:
+
+ return( ret );
+}
+
+/*
+ * Signed substraction: X = A - B
+ */
+int mpi_sub_mpi( mpi *X, mpi *A, mpi *B )
+{
+ int ret, s = A->s;
+
+ if( A->s * B->s > 0 )
+ {
+ if( mpi_cmp_abs( A, B ) >= 0 )
+ {
+ MPI_CHK( mpi_sub_abs( X, A, B ) );
+ X->s = s;
+ }
+ else
+ {
+ MPI_CHK( mpi_sub_abs( X, B, A ) );
+ X->s = -s;
+ }
+ }
+ else
+ {
+ MPI_CHK( mpi_add_abs( X, A, B ) );
+ X->s = s;
+ }
+
+cleanup:
+
+ return( ret );
+}
+
+/*
+ * Signed addition: X = A + b
+ */
+int mpi_add_int( mpi *X, mpi *A, int b )
+{
+ mpi _B;
+ t_int p[1];
+
+ p[0] = ( b < 0 ) ? -b : b;
+ _B.s = ( b < 0 ) ? -1 : 1;
+ _B.n = 1;
+ _B.p = p;
+
+ return( mpi_add_mpi( X, A, &_B ) );
+}
+
+/*
+ * Signed substraction: X = A - b
+ */
+int mpi_sub_int( mpi *X, mpi *A, int b )
+{
+ mpi _B;
+ t_int p[1];
+
+ p[0] = ( b < 0 ) ? -b : b;
+ _B.s = ( b < 0 ) ? -1 : 1;
+ _B.n = 1;
+ _B.p = p;
+
+ return( mpi_sub_mpi( X, A, &_B ) );
+}
+
+/*
+ * Helper for mpi multiplication
+ */
+static void mpi_mul_hlp( int i, t_int *s, t_int *d, t_int b )
+{
+ t_int c = 0, t = 0;
+
+#if defined(MULADDC_HUIT)
+ for( ; i >= 8; i -= 8 )
+ {
+ MULADDC_INIT
+ MULADDC_HUIT
+ MULADDC_STOP
+ }
+
+ for( ; i > 0; i-- )
+ {
+ MULADDC_INIT
+ MULADDC_CORE
+ MULADDC_STOP
+ }
+#else
+ for( ; i >= 16; i -= 16 )
+ {
+ MULADDC_INIT
+ MULADDC_CORE MULADDC_CORE
+ MULADDC_CORE MULADDC_CORE
+ MULADDC_CORE MULADDC_CORE
+ MULADDC_CORE MULADDC_CORE
+
+ MULADDC_CORE MULADDC_CORE
+ MULADDC_CORE MULADDC_CORE
+ MULADDC_CORE MULADDC_CORE
+ MULADDC_CORE MULADDC_CORE
+ MULADDC_STOP
+ }
+
+ for( ; i >= 8; i -= 8 )
+ {
+ MULADDC_INIT
+ MULADDC_CORE MULADDC_CORE
+ MULADDC_CORE MULADDC_CORE
+
+ MULADDC_CORE MULADDC_CORE
+ MULADDC_CORE MULADDC_CORE
+ MULADDC_STOP
+ }
+
+ for( ; i > 0; i-- )
+ {
+ MULADDC_INIT
+ MULADDC_CORE
+ MULADDC_STOP
+ }
+#endif
+
+ t++;
+
+ do {
+ *d += c; c = ( *d < c ); d++;
+ }
+ while( c != 0 );
+}
+
+/*
+ * Baseline multiplication: X = A * B (HAC 14.12)
+ */
+int mpi_mul_mpi( mpi *X, mpi *A, mpi *B )
+{
+ int ret, i, j;
+ mpi TA, TB;
+
+ mpi_init( &TA, &TB, NULL );
+
+ if( X == A ) { MPI_CHK( mpi_copy( &TA, A ) ); A = &TA; }
+ if( X == B ) { MPI_CHK( mpi_copy( &TB, B ) ); B = &TB; }
+
+ for( i = A->n - 1; i >= 0; i-- )
+ if( A->p[i] != 0 )
+ break;
+
+ for( j = B->n - 1; j >= 0; j-- )
+ if( B->p[j] != 0 )
+ break;
+
+ MPI_CHK( mpi_grow( X, i + j + 2 ) );
+ MPI_CHK( mpi_lset( X, 0 ) );
+
+ for( i++; j >= 0; j-- )
+ mpi_mul_hlp( i, A->p, X->p + j, B->p[j] );
+
+ X->s = A->s * B->s;
+
+cleanup:
+
+ mpi_free( &TB, &TA, NULL );
+
+ return( ret );
+}
+
+/*
+ * Baseline multiplication: X = A * b
+ */
+int mpi_mul_int( mpi *X, mpi *A, t_int b )
+{
+ mpi _B;
+ t_int p[1];
+
+ _B.s = 1;
+ _B.n = 1;
+ _B.p = p;
+ p[0] = b;
+
+ return( mpi_mul_mpi( X, A, &_B ) );
+}
+
+/*
+ * Division by mpi: A = Q * B + R (HAC 14.20)
+ */
+int mpi_div_mpi( mpi *Q, mpi *R, mpi *A, mpi *B )
+{
+ int ret, i, n, t, k;
+ mpi X, Y, Z, T1, T2;
+
+ if( mpi_cmp_int( B, 0 ) == 0 )
+ return( POLARSSL_ERR_MPI_DIVISION_BY_ZERO );
+
+ mpi_init( &X, &Y, &Z, &T1, &T2, NULL );
+
+ if( mpi_cmp_abs( A, B ) < 0 )
+ {
+ if( Q != NULL ) MPI_CHK( mpi_lset( Q, 0 ) );
+ if( R != NULL ) MPI_CHK( mpi_copy( R, A ) );
+ return( 0 );
+ }
+
+ MPI_CHK( mpi_copy( &X, A ) );
+ MPI_CHK( mpi_copy( &Y, B ) );
+ X.s = Y.s = 1;
+
+ MPI_CHK( mpi_grow( &Z, A->n + 2 ) );
+ MPI_CHK( mpi_lset( &Z, 0 ) );
+ MPI_CHK( mpi_grow( &T1, 2 ) );
+ MPI_CHK( mpi_grow( &T2, 3 ) );
+
+ k = mpi_msb( &Y ) % biL;
+ if( k < (int) biL - 1 )
+ {
+ k = biL - 1 - k;
+ MPI_CHK( mpi_shift_l( &X, k ) );
+ MPI_CHK( mpi_shift_l( &Y, k ) );
+ }
+ else k = 0;
+
+ n = X.n - 1;
+ t = Y.n - 1;
+ mpi_shift_l( &Y, biL * (n - t) );
+
+ while( mpi_cmp_mpi( &X, &Y ) >= 0 )
+ {
+ Z.p[n - t]++;
+ mpi_sub_mpi( &X, &X, &Y );
+ }
+ mpi_shift_r( &Y, biL * (n - t) );
+
+ for( i = n; i > t ; i-- )
+ {
+ if( X.p[i] >= Y.p[t] )
+ Z.p[i - t - 1] = ~0;
+ else
+ {
+#if defined(POLARSSL_HAVE_LONGLONG)
+ t_dbl r;
+
+ r = (t_dbl) X.p[i] << biL;
+ r |= (t_dbl) X.p[i - 1];
+ r /= Y.p[t];
+ if( r > ((t_dbl) 1 << biL) - 1)
+ r = ((t_dbl) 1 << biL) - 1;
+
+ Z.p[i - t - 1] = (t_int) r;
+#else
+ /*
+ * __udiv_qrnnd_c, from gmp/longlong.h
+ */
+ t_int q0, q1, r0, r1;
+ t_int d0, d1, d, m;
+
+ d = Y.p[t];
+ d0 = ( d << biH ) >> biH;
+ d1 = ( d >> biH );
+
+ q1 = X.p[i] / d1;
+ r1 = X.p[i] - d1 * q1;
+ r1 <<= biH;
+ r1 |= ( X.p[i - 1] >> biH );
+
+ m = q1 * d0;
+ if( r1 < m )
+ {
+ q1--, r1 += d;
+ while( r1 >= d && r1 < m )
+ q1--, r1 += d;
+ }
+ r1 -= m;
+
+ q0 = r1 / d1;
+ r0 = r1 - d1 * q0;
+ r0 <<= biH;
+ r0 |= ( X.p[i - 1] << biH ) >> biH;
+
+ m = q0 * d0;
+ if( r0 < m )
+ {
+ q0--, r0 += d;
+ while( r0 >= d && r0 < m )
+ q0--, r0 += d;
+ }
+ r0 -= m;
+
+ Z.p[i - t - 1] = ( q1 << biH ) | q0;
+#endif
+ }
+
+ Z.p[i - t - 1]++;
+ do
+ {
+ Z.p[i - t - 1]--;
+
+ MPI_CHK( mpi_lset( &T1, 0 ) );
+ T1.p[0] = (t < 1) ? 0 : Y.p[t - 1];
+ T1.p[1] = Y.p[t];
+ MPI_CHK( mpi_mul_int( &T1, &T1, Z.p[i - t - 1] ) );
+
+ MPI_CHK( mpi_lset( &T2, 0 ) );
+ T2.p[0] = (i < 2) ? 0 : X.p[i - 2];
+ T2.p[1] = (i < 1) ? 0 : X.p[i - 1];
+ T2.p[2] = X.p[i];
+ }
+ while( mpi_cmp_mpi( &T1, &T2 ) > 0 );
+
+ MPI_CHK( mpi_mul_int( &T1, &Y, Z.p[i - t - 1] ) );
+ MPI_CHK( mpi_shift_l( &T1, biL * (i - t - 1) ) );
+ MPI_CHK( mpi_sub_mpi( &X, &X, &T1 ) );
+
+ if( mpi_cmp_int( &X, 0 ) < 0 )
+ {
+ MPI_CHK( mpi_copy( &T1, &Y ) );
+ MPI_CHK( mpi_shift_l( &T1, biL * (i - t - 1) ) );
+ MPI_CHK( mpi_add_mpi( &X, &X, &T1 ) );
+ Z.p[i - t - 1]--;
+ }
+ }
+
+ if( Q != NULL )
+ {
+ mpi_copy( Q, &Z );
+ Q->s = A->s * B->s;
+ }
+
+ if( R != NULL )
+ {
+ mpi_shift_r( &X, k );
+ mpi_copy( R, &X );
+
+ R->s = A->s;
+ if( mpi_cmp_int( R, 0 ) == 0 )
+ R->s = 1;
+ }
+
+cleanup:
+
+ mpi_free( &X, &Y, &Z, &T1, &T2, NULL );
+
+ return( ret );
+}
+
+/*
+ * Division by int: A = Q * b + R
+ *
+ * Returns 0 if successful
+ * 1 if memory allocation failed
+ * POLARSSL_ERR_MPI_DIVISION_BY_ZERO if b == 0
+ */
+int mpi_div_int( mpi *Q, mpi *R, mpi *A, int b )
+{
+ mpi _B;
+ t_int p[1];
+
+ p[0] = ( b < 0 ) ? -b : b;
+ _B.s = ( b < 0 ) ? -1 : 1;
+ _B.n = 1;
+ _B.p = p;
+
+ return( mpi_div_mpi( Q, R, A, &_B ) );
+}
+
+/*
+ * Modulo: R = A mod B
+ */
+int mpi_mod_mpi( mpi *R, mpi *A, mpi *B )
+{
+ int ret;
+
+ MPI_CHK( mpi_div_mpi( NULL, R, A, B ) );
+
+ while( mpi_cmp_int( R, 0 ) < 0 )
+ MPI_CHK( mpi_add_mpi( R, R, B ) );
+
+ while( mpi_cmp_mpi( R, B ) >= 0 )
+ MPI_CHK( mpi_sub_mpi( R, R, B ) );
+
+cleanup:
+
+ return( ret );
+}
+
+/*
+ * Modulo: r = A mod b
+ */
+int mpi_mod_int( t_int *r, mpi *A, int b )
+{
+ int i;
+ t_int x, y, z;
+
+ if( b == 0 )
+ return( POLARSSL_ERR_MPI_DIVISION_BY_ZERO );
+
+ if( b < 0 )
+ b = -b;
+
+ /*
+ * handle trivial cases
+ */
+ if( b == 1 )
+ {
+ *r = 0;
+ return( 0 );
+ }
+
+ if( b == 2 )
+ {
+ *r = A->p[0] & 1;
+ return( 0 );
+ }
+
+ /*
+ * general case
+ */
+ for( i = A->n - 1, y = 0; i >= 0; i-- )
+ {
+ x = A->p[i];
+ y = ( y << biH ) | ( x >> biH );
+ z = y / b;
+ y -= z * b;
+
+ x <<= biH;
+ y = ( y << biH ) | ( x >> biH );
+ z = y / b;
+ y -= z * b;
+ }
+
+ *r = y;
+
+ return( 0 );
+}
+
+/*
+ * Fast Montgomery initialization (thanks to Tom St Denis)
+ */
+static void mpi_montg_init( t_int *mm, mpi *N )
+{
+ t_int x, m0 = N->p[0];
+
+ x = m0;
+ x += ( ( m0 + 2 ) & 4 ) << 1;
+ x *= ( 2 - ( m0 * x ) );
+
+ if( biL >= 16 ) x *= ( 2 - ( m0 * x ) );
+ if( biL >= 32 ) x *= ( 2 - ( m0 * x ) );
+ if( biL >= 64 ) x *= ( 2 - ( m0 * x ) );
+
+ *mm = ~x + 1;
+}
+
+/*
+ * Montgomery multiplication: A = A * B * R^-1 mod N (HAC 14.36)
+ */
+static void mpi_montmul( mpi *A, mpi *B, mpi *N, t_int mm, mpi *T )
+{
+ int i, n, m;
+ t_int u0, u1, *d;
+
+ memset( T->p, 0, T->n * ciL );
+
+ d = T->p;
+ n = N->n;
+ m = ( B->n < n ) ? B->n : n;
+
+ for( i = 0; i < n; i++ )
+ {
+ /*
+ * T = (T + u0*B + u1*N) / 2^biL
+ */
+ u0 = A->p[i];
+ u1 = ( d[0] + u0 * B->p[0] ) * mm;
+
+ mpi_mul_hlp( m, B->p, d, u0 );
+ mpi_mul_hlp( n, N->p, d, u1 );
+
+ *d++ = u0; d[n + 1] = 0;
+ }
+
+ memcpy( A->p, d, (n + 1) * ciL );
+
+ if( mpi_cmp_abs( A, N ) >= 0 )
+ mpi_sub_hlp( n, N->p, A->p );
+ else
+ /* prevent timing attacks */
+ mpi_sub_hlp( n, A->p, T->p );
+}
+
+/*
+ * Montgomery reduction: A = A * R^-1 mod N
+ */
+static void mpi_montred( mpi *A, mpi *N, t_int mm, mpi *T )
+{
+ t_int z = 1;
+ mpi U;
+
+ U.n = U.s = z;
+ U.p = &z;
+
+ mpi_montmul( A, &U, N, mm, T );
+}
+
+/*
+ * Sliding-window exponentiation: X = A^E mod N (HAC 14.85)
+ */
+int mpi_exp_mod( mpi *X, mpi *A, mpi *E, mpi *N, mpi *_RR )
+{
+ int ret, i, j, wsize, wbits;
+ int bufsize, nblimbs, nbits;
+ t_int ei, mm, state;
+ mpi RR, T, W[64];
+
+ if( mpi_cmp_int( N, 0 ) < 0 || ( N->p[0] & 1 ) == 0 )
+ return( POLARSSL_ERR_MPI_BAD_INPUT_DATA );
+
+ /*
+ * Init temps and window size
+ */
+ mpi_montg_init( &mm, N );
+ mpi_init( &RR, &T, NULL );
+ memset( W, 0, sizeof( W ) );
+
+ i = mpi_msb( E );
+
+ wsize = ( i > 671 ) ? 6 : ( i > 239 ) ? 5 :
+ ( i > 79 ) ? 4 : ( i > 23 ) ? 3 : 1;
+
+ j = N->n + 1;
+ MPI_CHK( mpi_grow( X, j ) );
+ MPI_CHK( mpi_grow( &W[1], j ) );
+ MPI_CHK( mpi_grow( &T, j * 2 ) );
+
+ /*
+ * If 1st call, pre-compute R^2 mod N
+ */
+ if( _RR == NULL || _RR->p == NULL )
+ {
+ MPI_CHK( mpi_lset( &RR, 1 ) );
+ MPI_CHK( mpi_shift_l( &RR, N->n * 2 * biL ) );
+ MPI_CHK( mpi_mod_mpi( &RR, &RR, N ) );
+
+ if( _RR != NULL )
+ memcpy( _RR, &RR, sizeof( mpi ) );
+ }
+ else
+ memcpy( &RR, _RR, sizeof( mpi ) );
+
+ /*
+ * W[1] = A * R^2 * R^-1 mod N = A * R mod N
+ */
+ if( mpi_cmp_mpi( A, N ) >= 0 )
+ mpi_mod_mpi( &W[1], A, N );
+ else mpi_copy( &W[1], A );
+
+ mpi_montmul( &W[1], &RR, N, mm, &T );
+
+ /*
+ * X = R^2 * R^-1 mod N = R mod N
+ */
+ MPI_CHK( mpi_copy( X, &RR ) );
+ mpi_montred( X, N, mm, &T );
+
+ if( wsize > 1 )
+ {
+ /*
+ * W[1 << (wsize - 1)] = W[1] ^ (wsize - 1)
+ */
+ j = 1 << (wsize - 1);
+
+ MPI_CHK( mpi_grow( &W[j], N->n + 1 ) );
+ MPI_CHK( mpi_copy( &W[j], &W[1] ) );
+
+ for( i = 0; i < wsize - 1; i++ )
+ mpi_montmul( &W[j], &W[j], N, mm, &T );
+
+ /*
+ * W[i] = W[i - 1] * W[1]
+ */
+ for( i = j + 1; i < (1 << wsize); i++ )
+ {
+ MPI_CHK( mpi_grow( &W[i], N->n + 1 ) );
+ MPI_CHK( mpi_copy( &W[i], &W[i - 1] ) );
+
+ mpi_montmul( &W[i], &W[1], N, mm, &T );
+ }
+ }
+
+ nblimbs = E->n;
+ bufsize = 0;
+ nbits = 0;
+ wbits = 0;
+ state = 0;
+
+ while( 1 )
+ {
+ if( bufsize == 0 )
+ {
+ if( nblimbs-- == 0 )
+ break;
+
+ bufsize = sizeof( t_int ) << 3;
+ }
+
+ bufsize--;
+
+ ei = (E->p[nblimbs] >> bufsize) & 1;
+
+ /*
+ * skip leading 0s
+ */
+ if( ei == 0 && state == 0 )
+ continue;
+
+ if( ei == 0 && state == 1 )
+ {
+ /*
+ * out of window, square X
+ */
+ mpi_montmul( X, X, N, mm, &T );
+ continue;
+ }
+
+ /*
+ * add ei to current window
+ */
+ state = 2;
+
+ nbits++;
+ wbits |= (ei << (wsize - nbits));
+
+ if( nbits == wsize )
+ {
+ /*
+ * X = X^wsize R^-1 mod N
+ */
+ for( i = 0; i < wsize; i++ )
+ mpi_montmul( X, X, N, mm, &T );
+
+ /*
+ * X = X * W[wbits] R^-1 mod N
+ */
+ mpi_montmul( X, &W[wbits], N, mm, &T );
+
+ state--;
+ nbits = 0;
+ wbits = 0;
+ }
+ }
+
+ /*
+ * process the remaining bits
+ */
+ for( i = 0; i < nbits; i++ )
+ {
+ mpi_montmul( X, X, N, mm, &T );
+
+ wbits <<= 1;
+
+ if( (wbits & (1 << wsize)) != 0 )
+ mpi_montmul( X, &W[1], N, mm, &T );
+ }
+
+ /*
+ * X = A^E * R * R^-1 mod N = A^E mod N
+ */
+ mpi_montred( X, N, mm, &T );
+
+cleanup:
+
+ for( i = (1 << (wsize - 1)); i < (1 << wsize); i++ )
+ mpi_free( &W[i], NULL );
+
+ if( _RR != NULL )
+ mpi_free( &W[1], &T, NULL );
+ else mpi_free( &W[1], &T, &RR, NULL );
+
+ return( ret );
+}
+
+/*
+ * Greatest common divisor: G = gcd(A, B) (HAC 14.54)
+ */
+int mpi_gcd( mpi *G, mpi *A, mpi *B )
+{
+ int ret, lz, lzt;
+ mpi TG, TA, TB;
+
+ mpi_init( &TG, &TA, &TB, NULL );
+
+ MPI_CHK( mpi_copy( &TA, A ) );
+ MPI_CHK( mpi_copy( &TB, B ) );
+
+ lz = mpi_lsb( &TA );
+ lzt = mpi_lsb( &TB );
+
+ if ( lzt < lz )
+ lz = lzt;
+
+ MPI_CHK( mpi_shift_r( &TA, lz ) );
+ MPI_CHK( mpi_shift_r( &TB, lz ) );
+
+ TA.s = TB.s = 1;
+
+ while( mpi_cmp_int( &TA, 0 ) != 0 )
+ {
+ MPI_CHK( mpi_shift_r( &TA, mpi_lsb( &TA ) ) );
+ MPI_CHK( mpi_shift_r( &TB, mpi_lsb( &TB ) ) );
+
+ if( mpi_cmp_mpi( &TA, &TB ) >= 0 )
+ {
+ MPI_CHK( mpi_sub_abs( &TA, &TA, &TB ) );
+ MPI_CHK( mpi_shift_r( &TA, 1 ) );
+ }
+ else
+ {
+ MPI_CHK( mpi_sub_abs( &TB, &TB, &TA ) );
+ MPI_CHK( mpi_shift_r( &TB, 1 ) );
+ }
+ }
+
+ MPI_CHK( mpi_shift_l( &TB, lz ) );
+ MPI_CHK( mpi_copy( G, &TB ) );
+
+cleanup:
+
+ mpi_free( &TB, &TA, &TG, NULL );
+
+ return( ret );
+}
+
+#if defined(POLARSSL_GENPRIME)
+
+/*
+ * Modular inverse: X = A^-1 mod N (HAC 14.61 / 14.64)
+ */
+int mpi_inv_mod( mpi *X, mpi *A, mpi *N )
+{
+ int ret;
+ mpi G, TA, TU, U1, U2, TB, TV, V1, V2;
+
+ if( mpi_cmp_int( N, 0 ) <= 0 )
+ return( POLARSSL_ERR_MPI_BAD_INPUT_DATA );
+
+ mpi_init( &TA, &TU, &U1, &U2, &G,
+ &TB, &TV, &V1, &V2, NULL );
+
+ MPI_CHK( mpi_gcd( &G, A, N ) );
+
+ if( mpi_cmp_int( &G, 1 ) != 0 )
+ {
+ ret = POLARSSL_ERR_MPI_NOT_ACCEPTABLE;
+ goto cleanup;
+ }
+
+ MPI_CHK( mpi_mod_mpi( &TA, A, N ) );
+ MPI_CHK( mpi_copy( &TU, &TA ) );
+ MPI_CHK( mpi_copy( &TB, N ) );
+ MPI_CHK( mpi_copy( &TV, N ) );
+
+ MPI_CHK( mpi_lset( &U1, 1 ) );
+ MPI_CHK( mpi_lset( &U2, 0 ) );
+ MPI_CHK( mpi_lset( &V1, 0 ) );
+ MPI_CHK( mpi_lset( &V2, 1 ) );
+
+ do
+ {
+ while( ( TU.p[0] & 1 ) == 0 )
+ {
+ MPI_CHK( mpi_shift_r( &TU, 1 ) );
+
+ if( ( U1.p[0] & 1 ) != 0 || ( U2.p[0] & 1 ) != 0 )
+ {
+ MPI_CHK( mpi_add_mpi( &U1, &U1, &TB ) );
+ MPI_CHK( mpi_sub_mpi( &U2, &U2, &TA ) );
+ }
+
+ MPI_CHK( mpi_shift_r( &U1, 1 ) );
+ MPI_CHK( mpi_shift_r( &U2, 1 ) );
+ }
+
+ while( ( TV.p[0] & 1 ) == 0 )
+ {
+ MPI_CHK( mpi_shift_r( &TV, 1 ) );
+
+ if( ( V1.p[0] & 1 ) != 0 || ( V2.p[0] & 1 ) != 0 )
+ {
+ MPI_CHK( mpi_add_mpi( &V1, &V1, &TB ) );
+ MPI_CHK( mpi_sub_mpi( &V2, &V2, &TA ) );
+ }
+
+ MPI_CHK( mpi_shift_r( &V1, 1 ) );
+ MPI_CHK( mpi_shift_r( &V2, 1 ) );
+ }
+
+ if( mpi_cmp_mpi( &TU, &TV ) >= 0 )
+ {
+ MPI_CHK( mpi_sub_mpi( &TU, &TU, &TV ) );
+ MPI_CHK( mpi_sub_mpi( &U1, &U1, &V1 ) );
+ MPI_CHK( mpi_sub_mpi( &U2, &U2, &V2 ) );
+ }
+ else
+ {
+ MPI_CHK( mpi_sub_mpi( &TV, &TV, &TU ) );
+ MPI_CHK( mpi_sub_mpi( &V1, &V1, &U1 ) );
+ MPI_CHK( mpi_sub_mpi( &V2, &V2, &U2 ) );
+ }
+ }
+ while( mpi_cmp_int( &TU, 0 ) != 0 );
+
+ while( mpi_cmp_int( &V1, 0 ) < 0 )
+ MPI_CHK( mpi_add_mpi( &V1, &V1, N ) );
+
+ while( mpi_cmp_mpi( &V1, N ) >= 0 )
+ MPI_CHK( mpi_sub_mpi( &V1, &V1, N ) );
+
+ MPI_CHK( mpi_copy( X, &V1 ) );
+
+cleanup:
+
+ mpi_free( &V2, &V1, &TV, &TB, &G,
+ &U2, &U1, &TU, &TA, NULL );
+
+ return( ret );
+}
+
+static const int small_prime[] =
+{
+ 3, 5, 7, 11, 13, 17, 19, 23,
+ 29, 31, 37, 41, 43, 47, 53, 59,
+ 61, 67, 71, 73, 79, 83, 89, 97,
+ 101, 103, 107, 109, 113, 127, 131, 137,
+ 139, 149, 151, 157, 163, 167, 173, 179,
+ 181, 191, 193, 197, 199, 211, 223, 227,
+ 229, 233, 239, 241, 251, 257, 263, 269,
+ 271, 277, 281, 283, 293, 307, 311, 313,
+ 317, 331, 337, 347, 349, 353, 359, 367,
+ 373, 379, 383, 389, 397, 401, 409, 419,
+ 421, 431, 433, 439, 443, 449, 457, 461,
+ 463, 467, 479, 487, 491, 499, 503, 509,
+ 521, 523, 541, 547, 557, 563, 569, 571,
+ 577, 587, 593, 599, 601, 607, 613, 617,
+ 619, 631, 641, 643, 647, 653, 659, 661,
+ 673, 677, 683, 691, 701, 709, 719, 727,
+ 733, 739, 743, 751, 757, 761, 769, 773,
+ 787, 797, 809, 811, 821, 823, 827, 829,
+ 839, 853, 857, 859, 863, 877, 881, 883,
+ 887, 907, 911, 919, 929, 937, 941, 947,
+ 953, 967, 971, 977, 983, 991, 997, -103
+};
+
+/*
+ * Miller-Rabin primality test (HAC 4.24)
+ */
+int mpi_is_prime( mpi *X, int (*f_rng)(void *), void *p_rng )
+{
+ int ret, i, j, n, s, xs;
+ mpi W, R, T, A, RR;
+ unsigned char *p;
+
+ if( mpi_cmp_int( X, 0 ) == 0 )
+ return( 0 );
+
+ mpi_init( &W, &R, &T, &A, &RR, NULL );
+
+ xs = X->s; X->s = 1;
+
+ /*
+ * test trivial factors first
+ */
+ if( ( X->p[0] & 1 ) == 0 )
+ return( POLARSSL_ERR_MPI_NOT_ACCEPTABLE );
+
+ for( i = 0; small_prime[i] > 0; i++ )
+ {
+ t_int r;
+
+ if( mpi_cmp_int( X, small_prime[i] ) <= 0 )
+ return( 0 );
+
+ MPI_CHK( mpi_mod_int( &r, X, small_prime[i] ) );
+
+ if( r == 0 )
+ return( POLARSSL_ERR_MPI_NOT_ACCEPTABLE );
+ }
+
+ /*
+ * W = |X| - 1
+ * R = W >> lsb( W )
+ */
+ s = mpi_lsb( &W );
+ MPI_CHK( mpi_sub_int( &W, X, 1 ) );
+ MPI_CHK( mpi_copy( &R, &W ) );
+ MPI_CHK( mpi_shift_r( &R, s ) );
+
+ i = mpi_msb( X );
+ /*
+ * HAC, table 4.4
+ */
+ n = ( ( i >= 1300 ) ? 2 : ( i >= 850 ) ? 3 :
+ ( i >= 650 ) ? 4 : ( i >= 350 ) ? 8 :
+ ( i >= 250 ) ? 12 : ( i >= 150 ) ? 18 : 27 );
+
+ for( i = 0; i < n; i++ )
+ {
+ /*
+ * pick a random A, 1 < A < |X| - 1
+ */
+ MPI_CHK( mpi_grow( &A, X->n ) );
+
+ p = (unsigned char *) A.p;
+ for( j = 0; j < A.n * ciL; j++ )
+ *p++ = (unsigned char) f_rng( p_rng );
+
+ j = mpi_msb( &A ) - mpi_msb( &W );
+ MPI_CHK( mpi_shift_r( &A, j + 1 ) );
+ A.p[0] |= 3;
+
+ /*
+ * A = A^R mod |X|
+ */
+ MPI_CHK( mpi_exp_mod( &A, &A, &R, X, &RR ) );
+
+ if( mpi_cmp_mpi( &A, &W ) == 0 ||
+ mpi_cmp_int( &A, 1 ) == 0 )
+ continue;
+
+ j = 1;
+ while( j < s && mpi_cmp_mpi( &A, &W ) != 0 )
+ {
+ /*
+ * A = A * A mod |X|
+ */
+ MPI_CHK( mpi_mul_mpi( &T, &A, &A ) );
+ MPI_CHK( mpi_mod_mpi( &A, &T, X ) );
+
+ if( mpi_cmp_int( &A, 1 ) == 0 )
+ break;
+
+ j++;
+ }
+
+ /*
+ * not prime if A != |X| - 1 or A == 1
+ */
+ if( mpi_cmp_mpi( &A, &W ) != 0 ||
+ mpi_cmp_int( &A, 1 ) == 0 )
+ {
+ ret = POLARSSL_ERR_MPI_NOT_ACCEPTABLE;
+ break;
+ }
+ }
+
+cleanup:
+
+ X->s = xs;
+
+ mpi_free( &RR, &A, &T, &R, &W, NULL );
+
+ return( ret );
+}
+
+/*
+ * Prime number generation
+ */
+int mpi_gen_prime( mpi *X, int nbits, int dh_flag,
+ int (*f_rng)(void *), void *p_rng )
+{
+ int ret, k, n;
+ unsigned char *p;
+ mpi Y;
+
+ if( nbits < 3 )
+ return( POLARSSL_ERR_MPI_BAD_INPUT_DATA );
+
+ mpi_init( &Y, NULL );
+
+ n = BITS_TO_LIMBS( nbits );
+
+ MPI_CHK( mpi_grow( X, n ) );
+ MPI_CHK( mpi_lset( X, 0 ) );
+
+ p = (unsigned char *) X->p;
+ for( k = 0; k < X->n * ciL; k++ )
+ *p++ = (unsigned char) f_rng( p_rng );
+
+ k = mpi_msb( X );
+ if( k < nbits ) MPI_CHK( mpi_shift_l( X, nbits - k ) );
+ if( k > nbits ) MPI_CHK( mpi_shift_r( X, k - nbits ) );
+
+ X->p[0] |= 3;
+
+ if( dh_flag == 0 )
+ {
+ while( ( ret = mpi_is_prime( X, f_rng, p_rng ) ) != 0 )
+ {
+ if( ret != POLARSSL_ERR_MPI_NOT_ACCEPTABLE )
+ goto cleanup;
+
+ MPI_CHK( mpi_add_int( X, X, 2 ) );
+ }
+ }
+ else
+ {
+ MPI_CHK( mpi_sub_int( &Y, X, 1 ) );
+ MPI_CHK( mpi_shift_r( &Y, 1 ) );
+
+ while( 1 )
+ {
+ if( ( ret = mpi_is_prime( X, f_rng, p_rng ) ) == 0 )
+ {
+ if( ( ret = mpi_is_prime( &Y, f_rng, p_rng ) ) == 0 )
+ break;
+
+ if( ret != POLARSSL_ERR_MPI_NOT_ACCEPTABLE )
+ goto cleanup;
+ }
+
+ if( ret != POLARSSL_ERR_MPI_NOT_ACCEPTABLE )
+ goto cleanup;
+
+ MPI_CHK( mpi_add_int( &Y, X, 1 ) );
+ MPI_CHK( mpi_add_int( X, X, 2 ) );
+ MPI_CHK( mpi_shift_r( &Y, 1 ) );
+ }
+ }
+
+cleanup:
+
+ mpi_free( &Y, NULL );
+
+ return( ret );
+}
+
+#endif
+
+#if defined(POLARSSL_SELF_TEST)
+
+#define GCD_PAIR_COUNT 3
+
+static const int gcd_pairs[GCD_PAIR_COUNT][3] =
+{
+ { 693, 609, 21 },
+ { 1764, 868, 28 },
+ { 768454923, 542167814, 1 }
+};
+
+/*
+ * Checkup routine
+ */
+int mpi_self_test( int verbose )
+{
+ int ret, i;
+ mpi A, E, N, X, Y, U, V;
+
+ mpi_init( &A, &E, &N, &X, &Y, &U, &V, NULL );
+
+ MPI_CHK( mpi_read_string( &A, 16,
+ "EFE021C2645FD1DC586E69184AF4A31E" \
+ "D5F53E93B5F123FA41680867BA110131" \
+ "944FE7952E2517337780CB0DB80E61AA" \
+ "E7C8DDC6C5C6AADEB34EB38A2F40D5E6" ) );
+
+ MPI_CHK( mpi_read_string( &E, 16,
+ "B2E7EFD37075B9F03FF989C7C5051C20" \
+ "34D2A323810251127E7BF8625A4F49A5" \
+ "F3E27F4DA8BD59C47D6DAABA4C8127BD" \
+ "5B5C25763222FEFCCFC38B832366C29E" ) );
+
+ MPI_CHK( mpi_read_string( &N, 16,
+ "0066A198186C18C10B2F5ED9B522752A" \
+ "9830B69916E535C8F047518A889A43A5" \
+ "94B6BED27A168D31D4A52F88925AA8F5" ) );
+
+ MPI_CHK( mpi_mul_mpi( &X, &A, &N ) );
+
+ MPI_CHK( mpi_read_string( &U, 16,
+ "602AB7ECA597A3D6B56FF9829A5E8B85" \
+ "9E857EA95A03512E2BAE7391688D264A" \
+ "A5663B0341DB9CCFD2C4C5F421FEC814" \
+ "8001B72E848A38CAE1C65F78E56ABDEF" \
+ "E12D3C039B8A02D6BE593F0BBBDA56F1" \
+ "ECF677152EF804370C1A305CAF3B5BF1" \
+ "30879B56C61DE584A0F53A2447A51E" ) );
+
+ if( verbose != 0 )
+ printf( " MPI test #1 (mul_mpi): " );
+
+ if( mpi_cmp_mpi( &X, &U ) != 0 )
+ {
+ if( verbose != 0 )
+ printf( "failed\n" );
+
+ return( 1 );
+ }
+
+ if( verbose != 0 )
+ printf( "passed\n" );
+
+ MPI_CHK( mpi_div_mpi( &X, &Y, &A, &N ) );
+
+ MPI_CHK( mpi_read_string( &U, 16,
+ "256567336059E52CAE22925474705F39A94" ) );
+
+ MPI_CHK( mpi_read_string( &V, 16,
+ "6613F26162223DF488E9CD48CC132C7A" \
+ "0AC93C701B001B092E4E5B9F73BCD27B" \
+ "9EE50D0657C77F374E903CDFA4C642" ) );
+
+ if( verbose != 0 )
+ printf( " MPI test #2 (div_mpi): " );
+
+ if( mpi_cmp_mpi( &X, &U ) != 0 ||
+ mpi_cmp_mpi( &Y, &V ) != 0 )
+ {
+ if( verbose != 0 )
+ printf( "failed\n" );
+
+ return( 1 );
+ }
+
+ if( verbose != 0 )
+ printf( "passed\n" );
+
+ MPI_CHK( mpi_exp_mod( &X, &A, &E, &N, NULL ) );
+
+ MPI_CHK( mpi_read_string( &U, 16,
+ "36E139AEA55215609D2816998ED020BB" \
+ "BD96C37890F65171D948E9BC7CBAA4D9" \
+ "325D24D6A3C12710F10A09FA08AB87" ) );
+
+ if( verbose != 0 )
+ printf( " MPI test #3 (exp_mod): " );
+
+ if( mpi_cmp_mpi( &X, &U ) != 0 )
+ {
+ if( verbose != 0 )
+ printf( "failed\n" );
+
+ return( 1 );
+ }
+
+ if( verbose != 0 )
+ printf( "passed\n" );
+
+ MPI_CHK( mpi_inv_mod( &X, &A, &N ) );
+
+ MPI_CHK( mpi_read_string( &U, 16,
+ "003A0AAEDD7E784FC07D8F9EC6E3BFD5" \
+ "C3DBA76456363A10869622EAC2DD84EC" \
+ "C5B8A74DAC4D09E03B5E0BE779F2DF61" ) );
+
+ if( verbose != 0 )
+ printf( " MPI test #4 (inv_mod): " );
+
+ if( mpi_cmp_mpi( &X, &U ) != 0 )
+ {
+ if( verbose != 0 )
+ printf( "failed\n" );
+
+ return( 1 );
+ }
+
+ if( verbose != 0 )
+ printf( "passed\n" );
+
+ if( verbose != 0 )
+ printf( " MPI test #5 (simple gcd): " );
+
+ for ( i = 0; i < GCD_PAIR_COUNT; i++)
+ {
+ MPI_CHK( mpi_lset( &X, gcd_pairs[i][0] ) );
+ MPI_CHK( mpi_lset( &Y, gcd_pairs[i][1] ) );
+
+ MPI_CHK( mpi_gcd( &A, &X, &Y ) );
+
+ if( mpi_cmp_int( &A, gcd_pairs[i][2] ) != 0 )
+ {
+ if( verbose != 0 )
+ printf( "failed at %d\n", i );
+
+ return( 1 );
+ }
+ }
+
+ if( verbose != 0 )
+ printf( "passed\n" );
+
+cleanup:
+
+ if( ret != 0 && verbose != 0 )
+ printf( "Unexpected error, return code = %08X\n", ret );
+
+ mpi_free( &V, &U, &Y, &X, &N, &E, &A, NULL );
+
+ if( verbose != 0 )
+ printf( "\n" );
+
+ return( ret );
+}
+
+#endif
+
+#endif
diff --git a/package/px5g/src/library/.svn/text-base/havege.c.svn-base b/package/px5g/src/library/.svn/text-base/havege.c.svn-base
new file mode 100644
index 0000000..266299d
--- /dev/null
+++ b/package/px5g/src/library/.svn/text-base/havege.c.svn-base
@@ -0,0 +1,276 @@
+/*
+ * HAVEGE: HArdware Volatile Entropy Gathering and Expansion
+ *
+ * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
+ *
+ * Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the names of PolarSSL or XySSL nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+/*
+ * The HAVEGE RNG was designed by Andre Seznec in 2002.
+ *
+ * http://www.irisa.fr/caps/projects/hipsor/publi.php
+ *
+ * Contact: seznec(at)irisa_dot_fr - orocheco(at)irisa_dot_fr
+ */
+
+#include <string.h>
+#include <time.h>
+
+#include "polarssl/config.h"
+
+#if defined(POLARSSL_HAVEGE_C)
+
+#include "polarssl/havege.h"
+#include "polarssl/timing.h"
+
+/* ------------------------------------------------------------------------
+ * On average, one iteration accesses two 8-word blocks in the havege WALK
+ * table, and generates 16 words in the RES array.
+ *
+ * The data read in the WALK table is updated and permuted after each use.
+ * The result of the hardware clock counter read is used for this update.
+ *
+ * 25 conditional tests are present. The conditional tests are grouped in
+ * two nested groups of 12 conditional tests and 1 test that controls the
+ * permutation; on average, there should be 6 tests executed and 3 of them
+ * should be mispredicted.
+ * ------------------------------------------------------------------------
+ */
+
+#define SWAP(X,Y) { int *T = X; X = Y; Y = T; }
+
+#define TST1_ENTER if( PTEST & 1 ) { PTEST ^= 3; PTEST >>= 1;
+#define TST2_ENTER if( PTEST & 1 ) { PTEST ^= 3; PTEST >>= 1;
+
+#define TST1_LEAVE U1++; }
+#define TST2_LEAVE U2++; }
+
+#define ONE_ITERATION \
+ \
+ PTEST = PT1 >> 20; \
+ \
+ TST1_ENTER TST1_ENTER TST1_ENTER TST1_ENTER \
+ TST1_ENTER TST1_ENTER TST1_ENTER TST1_ENTER \
+ TST1_ENTER TST1_ENTER TST1_ENTER TST1_ENTER \
+ \
+ TST1_LEAVE TST1_LEAVE TST1_LEAVE TST1_LEAVE \
+ TST1_LEAVE TST1_LEAVE TST1_LEAVE TST1_LEAVE \
+ TST1_LEAVE TST1_LEAVE TST1_LEAVE TST1_LEAVE \
+ \
+ PTX = (PT1 >> 18) & 7; \
+ PT1 &= 0x1FFF; \
+ PT2 &= 0x1FFF; \
+ CLK = (int) hardclock(); \
+ \
+ i = 0; \
+ A = &WALK[PT1 ]; RES[i++] ^= *A; \
+ B = &WALK[PT2 ]; RES[i++] ^= *B; \
+ C = &WALK[PT1 ^ 1]; RES[i++] ^= *C; \
+ D = &WALK[PT2 ^ 4]; RES[i++] ^= *D; \
+ \
+ IN = (*A >> (1)) ^ (*A << (31)) ^ CLK; \
+ *A = (*B >> (2)) ^ (*B << (30)) ^ CLK; \
+ *B = IN ^ U1; \
+ *C = (*C >> (3)) ^ (*C << (29)) ^ CLK; \
+ *D = (*D >> (4)) ^ (*D << (28)) ^ CLK; \
+ \
+ A = &WALK[PT1 ^ 2]; RES[i++] ^= *A; \
+ B = &WALK[PT2 ^ 2]; RES[i++] ^= *B; \
+ C = &WALK[PT1 ^ 3]; RES[i++] ^= *C; \
+ D = &WALK[PT2 ^ 6]; RES[i++] ^= *D; \
+ \
+ if( PTEST & 1 ) SWAP( A, C ); \
+ \
+ IN = (*A >> (5)) ^ (*A << (27)) ^ CLK; \
+ *A = (*B >> (6)) ^ (*B << (26)) ^ CLK; \
+ *B = IN; CLK = (int) hardclock(); \
+ *C = (*C >> (7)) ^ (*C << (25)) ^ CLK; \
+ *D = (*D >> (8)) ^ (*D << (24)) ^ CLK; \
+ \
+ A = &WALK[PT1 ^ 4]; \
+ B = &WALK[PT2 ^ 1]; \
+ \
+ PTEST = PT2 >> 1; \
+ \
+ PT2 = (RES[(i - 8) ^ PTY] ^ WALK[PT2 ^ PTY ^ 7]); \
+ PT2 = ((PT2 & 0x1FFF) & (~8)) ^ ((PT1 ^ 8) & 0x8); \
+ PTY = (PT2 >> 10) & 7; \
+ \
+ TST2_ENTER TST2_ENTER TST2_ENTER TST2_ENTER \
+ TST2_ENTER TST2_ENTER TST2_ENTER TST2_ENTER \
+ TST2_ENTER TST2_ENTER TST2_ENTER TST2_ENTER \
+ \
+ TST2_LEAVE TST2_LEAVE TST2_LEAVE TST2_LEAVE \
+ TST2_LEAVE TST2_LEAVE TST2_LEAVE TST2_LEAVE \
+ TST2_LEAVE TST2_LEAVE TST2_LEAVE TST2_LEAVE \
+ \
+ C = &WALK[PT1 ^ 5]; \
+ D = &WALK[PT2 ^ 5]; \
+ \
+ RES[i++] ^= *A; \
+ RES[i++] ^= *B; \
+ RES[i++] ^= *C; \
+ RES[i++] ^= *D; \
+ \
+ IN = (*A >> ( 9)) ^ (*A << (23)) ^ CLK; \
+ *A = (*B >> (10)) ^ (*B << (22)) ^ CLK; \
+ *B = IN ^ U2; \
+ *C = (*C >> (11)) ^ (*C << (21)) ^ CLK; \
+ *D = (*D >> (12)) ^ (*D << (20)) ^ CLK; \
+ \
+ A = &WALK[PT1 ^ 6]; RES[i++] ^= *A; \
+ B = &WALK[PT2 ^ 3]; RES[i++] ^= *B; \
+ C = &WALK[PT1 ^ 7]; RES[i++] ^= *C; \
+ D = &WALK[PT2 ^ 7]; RES[i++] ^= *D; \
+ \
+ IN = (*A >> (13)) ^ (*A << (19)) ^ CLK; \
+ *A = (*B >> (14)) ^ (*B << (18)) ^ CLK; \
+ *B = IN; \
+ *C = (*C >> (15)) ^ (*C << (17)) ^ CLK; \
+ *D = (*D >> (16)) ^ (*D << (16)) ^ CLK; \
+ \
+ PT1 = ( RES[(i - 8) ^ PTX] ^ \
+ WALK[PT1 ^ PTX ^ 7] ) & (~1); \
+ PT1 ^= (PT2 ^ 0x10) & 0x10; \
+ \
+ for( n++, i = 0; i < 16; i++ ) \
+ hs->pool[n % COLLECT_SIZE] ^= RES[i];
+
+/*
+ * Entropy gathering function
+ */
+static void havege_fill( havege_state *hs )
+{
+ int i, n = 0;
+ int U1, U2, *A, *B, *C, *D;
+ int PT1, PT2, *WALK, RES[16];
+ int PTX, PTY, CLK, PTEST, IN;
+
+ WALK = hs->WALK;
+ PT1 = hs->PT1;
+ PT2 = hs->PT2;
+
+ PTX = U1 = 0;
+ PTY = U2 = 0;
+
+ memset( RES, 0, sizeof( RES ) );
+
+ while( n < COLLECT_SIZE * 4 )
+ {
+ ONE_ITERATION
+ ONE_ITERATION
+ ONE_ITERATION
+ ONE_ITERATION
+ }
+
+ hs->PT1 = PT1;
+ hs->PT2 = PT2;
+
+ hs->offset[0] = 0;
+ hs->offset[1] = COLLECT_SIZE / 2;
+}
+
+/*
+ * HAVEGE initialization
+ */
+void havege_init( havege_state *hs )
+{
+ memset( hs, 0, sizeof( havege_state ) );
+
+ havege_fill( hs );
+}
+
+/*
+ * HAVEGE rand function
+ */
+int havege_rand( void *p_rng )
+{
+ int ret;
+ havege_state *hs = (havege_state *) p_rng;
+
+ if( hs->offset[1] >= COLLECT_SIZE )
+ havege_fill( hs );
+
+ ret = hs->pool[hs->offset[0]++];
+ ret ^= hs->pool[hs->offset[1]++];
+
+ return( ret );
+}
+
+#if defined(POLARSSL_RAND_TEST)
+
+#include <stdio.h>
+
+int main( int argc, char *argv[] )
+{
+ FILE *f;
+ time_t t;
+ int i, j, k;
+ havege_state hs;
+ unsigned char buf[1024];
+
+ if( argc < 2 )
+ {
+ fprintf( stderr, "usage: %s <output filename>\n", argv[0] );
+ return( 1 );
+ }
+
+ if( ( f = fopen( argv[1], "wb+" ) ) == NULL )
+ {
+ printf( "failed to open '%s' for writing.\n", argv[0] );
+ return( 1 );
+ }
+
+ havege_init( &hs );
+
+ t = time( NULL );
+
+ for( i = 0, k = 32768; i < k; i++ )
+ {
+ for( j = 0; j < sizeof( buf ); j++ )
+ buf[j] = havege_rand( &hs );
+
+ fwrite( buf, sizeof( buf ), 1, f );
+
+ printf( "Generating 32Mb of data in file '%s'... %04.1f" \
+ "%% done\r", argv[1], (100 * (float) (i + 1)) / k );
+ fflush( stdout );
+ }
+
+ if( t == time( NULL ) )
+ t--;
+
+ fclose( f );
+ return( 0 );
+}
+
+#endif
+
+#endif
diff --git a/package/px5g/src/library/.svn/text-base/rsa.c.svn-base b/package/px5g/src/library/.svn/text-base/rsa.c.svn-base
new file mode 100644
index 0000000..131b6c6
--- /dev/null
+++ b/package/px5g/src/library/.svn/text-base/rsa.c.svn-base
@@ -0,0 +1,750 @@
+/*
+ * The RSA public-key cryptosystem
+ *
+ * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
+ *
+ * Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the names of PolarSSL or XySSL nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+/*
+ * RSA was designed by Ron Rivest, Adi Shamir and Len Adleman.
+ *
+ * http://theory.lcs.mit.edu/~rivest/rsapaper.pdf
+ * http://www.cacr.math.uwaterloo.ca/hac/about/chap8.pdf
+ */
+
+#include "polarssl/config.h"
+
+#if defined(POLARSSL_RSA_C)
+
+#include "polarssl/rsa.h"
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+/*
+ * Initialize an RSA context
+ */
+void rsa_init( rsa_context *ctx,
+ int padding,
+ int hash_id,
+ int (*f_rng)(void *),
+ void *p_rng )
+{
+ memset( ctx, 0, sizeof( rsa_context ) );
+
+ ctx->padding = padding;
+ ctx->hash_id = hash_id;
+
+ ctx->f_rng = f_rng;
+ ctx->p_rng = p_rng;
+}
+
+#if defined(POLARSSL_GENPRIME)
+
+/*
+ * Generate an RSA keypair
+ */
+int rsa_gen_key( rsa_context *ctx, int nbits, int exponent )
+{
+ int ret;
+ mpi P1, Q1, H, G;
+
+ if( ctx->f_rng == NULL || nbits < 128 || exponent < 3 )
+ return( POLARSSL_ERR_RSA_BAD_INPUT_DATA );
+
+ mpi_init( &P1, &Q1, &H, &G, NULL );
+
+ /*
+ * find primes P and Q with Q < P so that:
+ * GCD( E, (P-1)*(Q-1) ) == 1
+ */
+ MPI_CHK( mpi_lset( &ctx->E, exponent ) );
+
+ do
+ {
+ MPI_CHK( mpi_gen_prime( &ctx->P, ( nbits + 1 ) >> 1, 0,
+ ctx->f_rng, ctx->p_rng ) );
+
+ MPI_CHK( mpi_gen_prime( &ctx->Q, ( nbits + 1 ) >> 1, 0,
+ ctx->f_rng, ctx->p_rng ) );
+
+ if( mpi_cmp_mpi( &ctx->P, &ctx->Q ) < 0 )
+ mpi_swap( &ctx->P, &ctx->Q );
+
+ if( mpi_cmp_mpi( &ctx->P, &ctx->Q ) == 0 )
+ continue;
+
+ MPI_CHK( mpi_mul_mpi( &ctx->N, &ctx->P, &ctx->Q ) );
+ if( mpi_msb( &ctx->N ) != nbits )
+ continue;
+
+ MPI_CHK( mpi_sub_int( &P1, &ctx->P, 1 ) );
+ MPI_CHK( mpi_sub_int( &Q1, &ctx->Q, 1 ) );
+ MPI_CHK( mpi_mul_mpi( &H, &P1, &Q1 ) );
+ MPI_CHK( mpi_gcd( &G, &ctx->E, &H ) );
+ }
+ while( mpi_cmp_int( &G, 1 ) != 0 );
+
+ /*
+ * D = E^-1 mod ((P-1)*(Q-1))
+ * DP = D mod (P - 1)
+ * DQ = D mod (Q - 1)
+ * QP = Q^-1 mod P
+ */
+ MPI_CHK( mpi_inv_mod( &ctx->D , &ctx->E, &H ) );
+ MPI_CHK( mpi_mod_mpi( &ctx->DP, &ctx->D, &P1 ) );
+ MPI_CHK( mpi_mod_mpi( &ctx->DQ, &ctx->D, &Q1 ) );
+ MPI_CHK( mpi_inv_mod( &ctx->QP, &ctx->Q, &ctx->P ) );
+
+ ctx->len = ( mpi_msb( &ctx->N ) + 7 ) >> 3;
+
+cleanup:
+
+ mpi_free( &G, &H, &Q1, &P1, NULL );
+
+ if( ret != 0 )
+ {
+ rsa_free( ctx );
+ return( POLARSSL_ERR_RSA_KEY_GEN_FAILED | ret );
+ }
+
+ return( 0 );
+}
+
+#endif
+
+/*
+ * Check a public RSA key
+ */
+int rsa_check_pubkey( rsa_context *ctx )
+{
+ if( ( ctx->N.p[0] & 1 ) == 0 ||
+ ( ctx->E.p[0] & 1 ) == 0 )
+ return( POLARSSL_ERR_RSA_KEY_CHECK_FAILED );
+
+ if( mpi_msb( &ctx->N ) < 128 ||
+ mpi_msb( &ctx->N ) > 4096 )
+ return( POLARSSL_ERR_RSA_KEY_CHECK_FAILED );
+
+ if( mpi_msb( &ctx->E ) < 2 ||
+ mpi_msb( &ctx->E ) > 64 )
+ return( POLARSSL_ERR_RSA_KEY_CHECK_FAILED );
+
+ return( 0 );
+}
+
+/*
+ * Check a private RSA key
+ */
+int rsa_check_privkey( rsa_context *ctx )
+{
+ int ret;
+ mpi PQ, DE, P1, Q1, H, I, G;
+
+ if( ( ret = rsa_check_pubkey( ctx ) ) != 0 )
+ return( ret );
+
+ mpi_init( &PQ, &DE, &P1, &Q1, &H, &I, &G, NULL );
+
+ MPI_CHK( mpi_mul_mpi( &PQ, &ctx->P, &ctx->Q ) );
+ MPI_CHK( mpi_mul_mpi( &DE, &ctx->D, &ctx->E ) );
+ MPI_CHK( mpi_sub_int( &P1, &ctx->P, 1 ) );
+ MPI_CHK( mpi_sub_int( &Q1, &ctx->Q, 1 ) );
+ MPI_CHK( mpi_mul_mpi( &H, &P1, &Q1 ) );
+ MPI_CHK( mpi_mod_mpi( &I, &DE, &H ) );
+ MPI_CHK( mpi_gcd( &G, &ctx->E, &H ) );
+
+ if( mpi_cmp_mpi( &PQ, &ctx->N ) == 0 &&
+ mpi_cmp_int( &I, 1 ) == 0 &&
+ mpi_cmp_int( &G, 1 ) == 0 )
+ {
+ mpi_free( &G, &I, &H, &Q1, &P1, &DE, &PQ, NULL );
+ return( 0 );
+ }
+
+cleanup:
+
+ mpi_free( &G, &I, &H, &Q1, &P1, &DE, &PQ, NULL );
+ return( POLARSSL_ERR_RSA_KEY_CHECK_FAILED | ret );
+}
+
+/*
+ * Do an RSA public key operation
+ */
+int rsa_public( rsa_context *ctx,
+ unsigned char *input,
+ unsigned char *output )
+{
+ int ret, olen;
+ mpi T;
+
+ mpi_init( &T, NULL );
+
+ MPI_CHK( mpi_read_binary( &T, input, ctx->len ) );
+
+ if( mpi_cmp_mpi( &T, &ctx->N ) >= 0 )
+ {
+ mpi_free( &T, NULL );
+ return( POLARSSL_ERR_RSA_BAD_INPUT_DATA );
+ }
+
+ olen = ctx->len;
+ MPI_CHK( mpi_exp_mod( &T, &T, &ctx->E, &ctx->N, &ctx->RN ) );
+ MPI_CHK( mpi_write_binary( &T, output, olen ) );
+
+cleanup:
+
+ mpi_free( &T, NULL );
+
+ if( ret != 0 )
+ return( POLARSSL_ERR_RSA_PUBLIC_FAILED | ret );
+
+ return( 0 );
+}
+
+/*
+ * Do an RSA private key operation
+ */
+int rsa_private( rsa_context *ctx,
+ unsigned char *input,
+ unsigned char *output )
+{
+ int ret, olen;
+ mpi T, T1, T2;
+
+ mpi_init( &T, &T1, &T2, NULL );
+
+ MPI_CHK( mpi_read_binary( &T, input, ctx->len ) );
+
+ if( mpi_cmp_mpi( &T, &ctx->N ) >= 0 )
+ {
+ mpi_free( &T, NULL );
+ return( POLARSSL_ERR_RSA_BAD_INPUT_DATA );
+ }
+
+#if 0
+ MPI_CHK( mpi_exp_mod( &T, &T, &ctx->D, &ctx->N, &ctx->RN ) );
+#else
+ /*
+ * faster decryption using the CRT
+ *
+ * T1 = input ^ dP mod P
+ * T2 = input ^ dQ mod Q
+ */
+ MPI_CHK( mpi_exp_mod( &T1, &T, &ctx->DP, &ctx->P, &ctx->RP ) );
+ MPI_CHK( mpi_exp_mod( &T2, &T, &ctx->DQ, &ctx->Q, &ctx->RQ ) );
+
+ /*
+ * T = (T1 - T2) * (Q^-1 mod P) mod P
+ */
+ MPI_CHK( mpi_sub_mpi( &T, &T1, &T2 ) );
+ MPI_CHK( mpi_mul_mpi( &T1, &T, &ctx->QP ) );
+ MPI_CHK( mpi_mod_mpi( &T, &T1, &ctx->P ) );
+
+ /*
+ * output = T2 + T * Q
+ */
+ MPI_CHK( mpi_mul_mpi( &T1, &T, &ctx->Q ) );
+ MPI_CHK( mpi_add_mpi( &T, &T2, &T1 ) );
+#endif
+
+ olen = ctx->len;
+ MPI_CHK( mpi_write_binary( &T, output, olen ) );
+
+cleanup:
+
+ mpi_free( &T, &T1, &T2, NULL );
+
+ if( ret != 0 )
+ return( POLARSSL_ERR_RSA_PRIVATE_FAILED | ret );
+
+ return( 0 );
+}
+
+/*
+ * Add the message padding, then do an RSA operation
+ */
+int rsa_pkcs1_encrypt( rsa_context *ctx,
+ int mode, int ilen,
+ unsigned char *input,
+ unsigned char *output )
+{
+ int nb_pad, olen;
+ unsigned char *p = output;
+
+ olen = ctx->len;
+
+ switch( ctx->padding )
+ {
+ case RSA_PKCS_V15:
+
+ if( ilen < 0 || olen < ilen + 11 )
+ return( POLARSSL_ERR_RSA_BAD_INPUT_DATA );
+
+ nb_pad = olen - 3 - ilen;
+
+ *p++ = 0;
+ *p++ = RSA_CRYPT;
+
+ while( nb_pad-- > 0 )
+ {
+ do {
+ *p = (unsigned char) rand();
+ } while( *p == 0 );
+ p++;
+ }
+ *p++ = 0;
+ memcpy( p, input, ilen );
+ break;
+
+ default:
+
+ return( POLARSSL_ERR_RSA_INVALID_PADDING );
+ }
+
+ return( ( mode == RSA_PUBLIC )
+ ? rsa_public( ctx, output, output )
+ : rsa_private( ctx, output, output ) );
+}
+
+/*
+ * Do an RSA operation, then remove the message padding
+ */
+int rsa_pkcs1_decrypt( rsa_context *ctx,
+ int mode, int *olen,
+ unsigned char *input,
+ unsigned char *output,
+ int output_max_len)
+{
+ int ret, ilen;
+ unsigned char *p;
+ unsigned char buf[512];
+
+ ilen = ctx->len;
+
+ if( ilen < 16 || ilen > (int) sizeof( buf ) )
+ return( POLARSSL_ERR_RSA_BAD_INPUT_DATA );
+
+ ret = ( mode == RSA_PUBLIC )
+ ? rsa_public( ctx, input, buf )
+ : rsa_private( ctx, input, buf );
+
+ if( ret != 0 )
+ return( ret );
+
+ p = buf;
+
+ switch( ctx->padding )
+ {
+ case RSA_PKCS_V15:
+
+ if( *p++ != 0 || *p++ != RSA_CRYPT )
+ return( POLARSSL_ERR_RSA_INVALID_PADDING );
+
+ while( *p != 0 )
+ {
+ if( p >= buf + ilen - 1 )
+ return( POLARSSL_ERR_RSA_INVALID_PADDING );
+ p++;
+ }
+ p++;
+ break;
+
+ default:
+
+ return( POLARSSL_ERR_RSA_INVALID_PADDING );
+ }
+
+ if (ilen - (int)(p - buf) > output_max_len)
+ return( POLARSSL_ERR_RSA_OUTPUT_TO_LARGE );
+
+ *olen = ilen - (int)(p - buf);
+ memcpy( output, p, *olen );
+
+ return( 0 );
+}
+
+/*
+ * Do an RSA operation to sign the message digest
+ */
+int rsa_pkcs1_sign( rsa_context *ctx,
+ int mode,
+ int hash_id,
+ int hashlen,
+ unsigned char *hash,
+ unsigned char *sig )
+{
+ int nb_pad, olen;
+ unsigned char *p = sig;
+
+ olen = ctx->len;
+
+ switch( ctx->padding )
+ {
+ case RSA_PKCS_V15:
+
+ switch( hash_id )
+ {
+ case RSA_RAW:
+ nb_pad = olen - 3 - hashlen;
+ break;
+
+ case RSA_MD2:
+ case RSA_MD4:
+ case RSA_MD5:
+ nb_pad = olen - 3 - 34;
+ break;
+
+ case RSA_SHA1:
+ nb_pad = olen - 3 - 35;
+ break;
+
+ default:
+ return( POLARSSL_ERR_RSA_BAD_INPUT_DATA );
+ }
+
+ if( nb_pad < 8 )
+ return( POLARSSL_ERR_RSA_BAD_INPUT_DATA );
+
+ *p++ = 0;
+ *p++ = RSA_SIGN;
+ memset( p, 0xFF, nb_pad );
+ p += nb_pad;
+ *p++ = 0;
+ break;
+
+ default:
+
+ return( POLARSSL_ERR_RSA_INVALID_PADDING );
+ }
+
+ switch( hash_id )
+ {
+ case RSA_RAW:
+ memcpy( p, hash, hashlen );
+ break;
+
+ case RSA_MD2:
+ memcpy( p, ASN1_HASH_MDX, 18 );
+ memcpy( p + 18, hash, 16 );
+ p[13] = 2; break;
+
+ case RSA_MD4:
+ memcpy( p, ASN1_HASH_MDX, 18 );
+ memcpy( p + 18, hash, 16 );
+ p[13] = 4; break;
+
+ case RSA_MD5:
+ memcpy( p, ASN1_HASH_MDX, 18 );
+ memcpy( p + 18, hash, 16 );
+ p[13] = 5; break;
+
+ case RSA_SHA1:
+ memcpy( p, ASN1_HASH_SHA1, 15 );
+ memcpy( p + 15, hash, 20 );
+ break;
+
+ default:
+ return( POLARSSL_ERR_RSA_BAD_INPUT_DATA );
+ }
+
+ return( ( mode == RSA_PUBLIC )
+ ? rsa_public( ctx, sig, sig )
+ : rsa_private( ctx, sig, sig ) );
+}
+
+/*
+ * Do an RSA operation and check the message digest
+ */
+int rsa_pkcs1_verify( rsa_context *ctx,
+ int mode,
+ int hash_id,
+ int hashlen,
+ unsigned char *hash,
+ unsigned char *sig )
+{
+ int ret, len, siglen;
+ unsigned char *p, c;
+ unsigned char buf[512];
+
+ siglen = ctx->len;
+
+ if( siglen < 16 || siglen > (int) sizeof( buf ) )
+ return( POLARSSL_ERR_RSA_BAD_INPUT_DATA );
+
+ ret = ( mode == RSA_PUBLIC )
+ ? rsa_public( ctx, sig, buf )
+ : rsa_private( ctx, sig, buf );
+
+ if( ret != 0 )
+ return( ret );
+
+ p = buf;
+
+ switch( ctx->padding )
+ {
+ case RSA_PKCS_V15:
+
+ if( *p++ != 0 || *p++ != RSA_SIGN )
+ return( POLARSSL_ERR_RSA_INVALID_PADDING );
+
+ while( *p != 0 )
+ {
+ if( p >= buf + siglen - 1 || *p != 0xFF )
+ return( POLARSSL_ERR_RSA_INVALID_PADDING );
+ p++;
+ }
+ p++;
+ break;
+
+ default:
+
+ return( POLARSSL_ERR_RSA_INVALID_PADDING );
+ }
+
+ len = siglen - (int)( p - buf );
+
+ if( len == 34 )
+ {
+ c = p[13];
+ p[13] = 0;
+
+ if( memcmp( p, ASN1_HASH_MDX, 18 ) != 0 )
+ return( POLARSSL_ERR_RSA_VERIFY_FAILED );
+
+ if( ( c == 2 && hash_id == RSA_MD2 ) ||
+ ( c == 4 && hash_id == RSA_MD4 ) ||
+ ( c == 5 && hash_id == RSA_MD5 ) )
+ {
+ if( memcmp( p + 18, hash, 16 ) == 0 )
+ return( 0 );
+ else
+ return( POLARSSL_ERR_RSA_VERIFY_FAILED );
+ }
+ }
+
+ if( len == 35 && hash_id == RSA_SHA1 )
+ {
+ if( memcmp( p, ASN1_HASH_SHA1, 15 ) == 0 &&
+ memcmp( p + 15, hash, 20 ) == 0 )
+ return( 0 );
+ else
+ return( POLARSSL_ERR_RSA_VERIFY_FAILED );
+ }
+
+ if( len == hashlen && hash_id == RSA_RAW )
+ {
+ if( memcmp( p, hash, hashlen ) == 0 )
+ return( 0 );
+ else
+ return( POLARSSL_ERR_RSA_VERIFY_FAILED );
+ }
+
+ return( POLARSSL_ERR_RSA_INVALID_PADDING );
+}
+
+/*
+ * Free the components of an RSA key
+ */
+void rsa_free( rsa_context *ctx )
+{
+ mpi_free( &ctx->RQ, &ctx->RP, &ctx->RN,
+ &ctx->QP, &ctx->DQ, &ctx->DP,
+ &ctx->Q, &ctx->P, &ctx->D,
+ &ctx->E, &ctx->N, NULL );
+}
+
+#if defined(POLARSSL_SELF_TEST)
+
+#include "polarssl/sha1.h"
+
+/*
+ * Example RSA-1024 keypair, for test purposes
+ */
+#define KEY_LEN 128
+
+#define RSA_N "9292758453063D803DD603D5E777D788" \
+ "8ED1D5BF35786190FA2F23EBC0848AEA" \
+ "DDA92CA6C3D80B32C4D109BE0F36D6AE" \
+ "7130B9CED7ACDF54CFC7555AC14EEBAB" \
+ "93A89813FBF3C4F8066D2D800F7C38A8" \
+ "1AE31942917403FF4946B0A83D3D3E05" \
+ "EE57C6F5F5606FB5D4BC6CD34EE0801A" \
+ "5E94BB77B07507233A0BC7BAC8F90F79"
+
+#define RSA_E "10001"
+
+#define RSA_D "24BF6185468786FDD303083D25E64EFC" \
+ "66CA472BC44D253102F8B4A9D3BFA750" \
+ "91386C0077937FE33FA3252D28855837" \
+ "AE1B484A8A9A45F7EE8C0C634F99E8CD" \
+ "DF79C5CE07EE72C7F123142198164234" \
+ "CABB724CF78B8173B9F880FC86322407" \
+ "AF1FEDFDDE2BEB674CA15F3E81A1521E" \
+ "071513A1E85B5DFA031F21ECAE91A34D"
+
+#define RSA_P "C36D0EB7FCD285223CFB5AABA5BDA3D8" \
+ "2C01CAD19EA484A87EA4377637E75500" \
+ "FCB2005C5C7DD6EC4AC023CDA285D796" \
+ "C3D9E75E1EFC42488BB4F1D13AC30A57"
+
+#define RSA_Q "C000DF51A7C77AE8D7C7370C1FF55B69" \
+ "E211C2B9E5DB1ED0BF61D0D9899620F4" \
+ "910E4168387E3C30AA1E00C339A79508" \
+ "8452DD96A9A5EA5D9DCA68DA636032AF"
+
+#define RSA_DP "C1ACF567564274FB07A0BBAD5D26E298" \
+ "3C94D22288ACD763FD8E5600ED4A702D" \
+ "F84198A5F06C2E72236AE490C93F07F8" \
+ "3CC559CD27BC2D1CA488811730BB5725"
+
+#define RSA_DQ "4959CBF6F8FEF750AEE6977C155579C7" \
+ "D8AAEA56749EA28623272E4F7D0592AF" \
+ "7C1F1313CAC9471B5C523BFE592F517B" \
+ "407A1BD76C164B93DA2D32A383E58357"
+
+#define RSA_QP "9AE7FBC99546432DF71896FC239EADAE" \
+ "F38D18D2B2F0E2DD275AA977E2BF4411" \
+ "F5A3B2A5D33605AEBBCCBA7FEB9F2D2F" \
+ "A74206CEC169D74BF5A8C50D6F48EA08"
+
+#define PT_LEN 24
+#define RSA_PT "\xAA\xBB\xCC\x03\x02\x01\x00\xFF\xFF\xFF\xFF\xFF" \
+ "\x11\x22\x33\x0A\x0B\x0C\xCC\xDD\xDD\xDD\xDD\xDD"
+
+/*
+ * Checkup routine
+ */
+int rsa_self_test( int verbose )
+{
+ int len;
+ rsa_context rsa;
+ unsigned char sha1sum[20];
+ unsigned char rsa_plaintext[PT_LEN];
+ unsigned char rsa_decrypted[PT_LEN];
+ unsigned char rsa_ciphertext[KEY_LEN];
+
+ memset( &rsa, 0, sizeof( rsa_context ) );
+
+ rsa.len = KEY_LEN;
+ mpi_read_string( &rsa.N , 16, RSA_N );
+ mpi_read_string( &rsa.E , 16, RSA_E );
+ mpi_read_string( &rsa.D , 16, RSA_D );
+ mpi_read_string( &rsa.P , 16, RSA_P );
+ mpi_read_string( &rsa.Q , 16, RSA_Q );
+ mpi_read_string( &rsa.DP, 16, RSA_DP );
+ mpi_read_string( &rsa.DQ, 16, RSA_DQ );
+ mpi_read_string( &rsa.QP, 16, RSA_QP );
+
+ if( verbose != 0 )
+ printf( " RSA key validation: " );
+
+ if( rsa_check_pubkey( &rsa ) != 0 ||
+ rsa_check_privkey( &rsa ) != 0 )
+ {
+ if( verbose != 0 )
+ printf( "failed\n" );
+
+ return( 1 );
+ }
+
+ if( verbose != 0 )
+ printf( "passed\n PKCS#1 encryption : " );
+
+ memcpy( rsa_plaintext, RSA_PT, PT_LEN );
+
+ if( rsa_pkcs1_encrypt( &rsa, RSA_PUBLIC, PT_LEN,
+ rsa_plaintext, rsa_ciphertext ) != 0 )
+ {
+ if( verbose != 0 )
+ printf( "failed\n" );
+
+ return( 1 );
+ }
+
+ if( verbose != 0 )
+ printf( "passed\n PKCS#1 decryption : " );
+
+ if( rsa_pkcs1_decrypt( &rsa, RSA_PRIVATE, &len,
+ rsa_ciphertext, rsa_decrypted,
+ sizeof(rsa_decrypted) ) != 0 )
+ {
+ if( verbose != 0 )
+ printf( "failed\n" );
+
+ return( 1 );
+ }
+
+ if( memcmp( rsa_decrypted, rsa_plaintext, len ) != 0 )
+ {
+ if( verbose != 0 )
+ printf( "failed\n" );
+
+ return( 1 );
+ }
+
+ if( verbose != 0 )
+ printf( "passed\n PKCS#1 data sign : " );
+
+ sha1( rsa_plaintext, PT_LEN, sha1sum );
+
+ if( rsa_pkcs1_sign( &rsa, RSA_PRIVATE, RSA_SHA1, 20,
+ sha1sum, rsa_ciphertext ) != 0 )
+ {
+ if( verbose != 0 )
+ printf( "failed\n" );
+
+ return( 1 );
+ }
+
+ if( verbose != 0 )
+ printf( "passed\n PKCS#1 sig. verify: " );
+
+ if( rsa_pkcs1_verify( &rsa, RSA_PUBLIC, RSA_SHA1, 20,
+ sha1sum, rsa_ciphertext ) != 0 )
+ {
+ if( verbose != 0 )
+ printf( "failed\n" );
+
+ return( 1 );
+ }
+
+ if( verbose != 0 )
+ printf( "passed\n\n" );
+
+ rsa_free( &rsa );
+
+ return( 0 );
+}
+
+#endif
+
+#endif
diff --git a/package/px5g/src/library/.svn/text-base/sha1.c.svn-base b/package/px5g/src/library/.svn/text-base/sha1.c.svn-base
new file mode 100644
index 0000000..54a4416
--- /dev/null
+++ b/package/px5g/src/library/.svn/text-base/sha1.c.svn-base
@@ -0,0 +1,622 @@
+/*
+ * FIPS-180-1 compliant SHA-1 implementation
+ *
+ * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
+ *
+ * Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the names of PolarSSL or XySSL nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+/*
+ * The SHA-1 standard was published by NIST in 1993.
+ *
+ * http://www.itl.nist.gov/fipspubs/fip180-1.htm
+ */
+
+#include "polarssl/config.h"
+
+#if defined(POLARSSL_SHA1_C)
+
+#include "polarssl/sha1.h"
+
+#include <string.h>
+#include <stdio.h>
+
+/*
+ * 32-bit integer manipulation macros (big endian)
+ */
+#ifndef GET_ULONG_BE
+#define GET_ULONG_BE(n,b,i) \
+{ \
+ (n) = ( (unsigned long) (b)[(i) ] << 24 ) \
+ | ( (unsigned long) (b)[(i) + 1] << 16 ) \
+ | ( (unsigned long) (b)[(i) + 2] << 8 ) \
+ | ( (unsigned long) (b)[(i) + 3] ); \
+}
+#endif
+
+#ifndef PUT_ULONG_BE
+#define PUT_ULONG_BE(n,b,i) \
+{ \
+ (b)[(i) ] = (unsigned char) ( (n) >> 24 ); \
+ (b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \
+ (b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \
+ (b)[(i) + 3] = (unsigned char) ( (n) ); \
+}
+#endif
+
+/*
+ * SHA-1 context setup
+ */
+void sha1_starts( sha1_context *ctx )
+{
+ ctx->total[0] = 0;
+ ctx->total[1] = 0;
+
+ ctx->state[0] = 0x67452301;
+ ctx->state[1] = 0xEFCDAB89;
+ ctx->state[2] = 0x98BADCFE;
+ ctx->state[3] = 0x10325476;
+ ctx->state[4] = 0xC3D2E1F0;
+}
+
+static void sha1_process( sha1_context *ctx, unsigned char data[64] )
+{
+ unsigned long temp, W[16], A, B, C, D, E;
+
+ GET_ULONG_BE( W[ 0], data, 0 );
+ GET_ULONG_BE( W[ 1], data, 4 );
+ GET_ULONG_BE( W[ 2], data, 8 );
+ GET_ULONG_BE( W[ 3], data, 12 );
+ GET_ULONG_BE( W[ 4], data, 16 );
+ GET_ULONG_BE( W[ 5], data, 20 );
+ GET_ULONG_BE( W[ 6], data, 24 );
+ GET_ULONG_BE( W[ 7], data, 28 );
+ GET_ULONG_BE( W[ 8], data, 32 );
+ GET_ULONG_BE( W[ 9], data, 36 );
+ GET_ULONG_BE( W[10], data, 40 );
+ GET_ULONG_BE( W[11], data, 44 );
+ GET_ULONG_BE( W[12], data, 48 );
+ GET_ULONG_BE( W[13], data, 52 );
+ GET_ULONG_BE( W[14], data, 56 );
+ GET_ULONG_BE( W[15], data, 60 );
+
+#define S(x,n) ((x << n) | ((x & 0xFFFFFFFF) >> (32 - n)))
+
+#define R(t) \
+( \
+ temp = W[(t - 3) & 0x0F] ^ W[(t - 8) & 0x0F] ^ \
+ W[(t - 14) & 0x0F] ^ W[ t & 0x0F], \
+ ( W[t & 0x0F] = S(temp,1) ) \
+)
+
+#define P(a,b,c,d,e,x) \
+{ \
+ e += S(a,5) + F(b,c,d) + K + x; b = S(b,30); \
+}
+
+ A = ctx->state[0];
+ B = ctx->state[1];
+ C = ctx->state[2];
+ D = ctx->state[3];
+ E = ctx->state[4];
+
+#define F(x,y,z) (z ^ (x & (y ^ z)))
+#define K 0x5A827999
+
+ P( A, B, C, D, E, W[0] );
+ P( E, A, B, C, D, W[1] );
+ P( D, E, A, B, C, W[2] );
+ P( C, D, E, A, B, W[3] );
+ P( B, C, D, E, A, W[4] );
+ P( A, B, C, D, E, W[5] );
+ P( E, A, B, C, D, W[6] );
+ P( D, E, A, B, C, W[7] );
+ P( C, D, E, A, B, W[8] );
+ P( B, C, D, E, A, W[9] );
+ P( A, B, C, D, E, W[10] );
+ P( E, A, B, C, D, W[11] );
+ P( D, E, A, B, C, W[12] );
+ P( C, D, E, A, B, W[13] );
+ P( B, C, D, E, A, W[14] );
+ P( A, B, C, D, E, W[15] );
+ P( E, A, B, C, D, R(16) );
+ P( D, E, A, B, C, R(17) );
+ P( C, D, E, A, B, R(18) );
+ P( B, C, D, E, A, R(19) );
+
+#undef K
+#undef F
+
+#define F(x,y,z) (x ^ y ^ z)
+#define K 0x6ED9EBA1
+
+ P( A, B, C, D, E, R(20) );
+ P( E, A, B, C, D, R(21) );
+ P( D, E, A, B, C, R(22) );
+ P( C, D, E, A, B, R(23) );
+ P( B, C, D, E, A, R(24) );
+ P( A, B, C, D, E, R(25) );
+ P( E, A, B, C, D, R(26) );
+ P( D, E, A, B, C, R(27) );
+ P( C, D, E, A, B, R(28) );
+ P( B, C, D, E, A, R(29) );
+ P( A, B, C, D, E, R(30) );
+ P( E, A, B, C, D, R(31) );
+ P( D, E, A, B, C, R(32) );
+ P( C, D, E, A, B, R(33) );
+ P( B, C, D, E, A, R(34) );
+ P( A, B, C, D, E, R(35) );
+ P( E, A, B, C, D, R(36) );
+ P( D, E, A, B, C, R(37) );
+ P( C, D, E, A, B, R(38) );
+ P( B, C, D, E, A, R(39) );
+
+#undef K
+#undef F
+
+#define F(x,y,z) ((x & y) | (z & (x | y)))
+#define K 0x8F1BBCDC
+
+ P( A, B, C, D, E, R(40) );
+ P( E, A, B, C, D, R(41) );
+ P( D, E, A, B, C, R(42) );
+ P( C, D, E, A, B, R(43) );
+ P( B, C, D, E, A, R(44) );
+ P( A, B, C, D, E, R(45) );
+ P( E, A, B, C, D, R(46) );
+ P( D, E, A, B, C, R(47) );
+ P( C, D, E, A, B, R(48) );
+ P( B, C, D, E, A, R(49) );
+ P( A, B, C, D, E, R(50) );
+ P( E, A, B, C, D, R(51) );
+ P( D, E, A, B, C, R(52) );
+ P( C, D, E, A, B, R(53) );
+ P( B, C, D, E, A, R(54) );
+ P( A, B, C, D, E, R(55) );
+ P( E, A, B, C, D, R(56) );
+ P( D, E, A, B, C, R(57) );
+ P( C, D, E, A, B, R(58) );
+ P( B, C, D, E, A, R(59) );
+
+#undef K
+#undef F
+
+#define F(x,y,z) (x ^ y ^ z)
+#define K 0xCA62C1D6
+
+ P( A, B, C, D, E, R(60) );
+ P( E, A, B, C, D, R(61) );
+ P( D, E, A, B, C, R(62) );
+ P( C, D, E, A, B, R(63) );
+ P( B, C, D, E, A, R(64) );
+ P( A, B, C, D, E, R(65) );
+ P( E, A, B, C, D, R(66) );
+ P( D, E, A, B, C, R(67) );
+ P( C, D, E, A, B, R(68) );
+ P( B, C, D, E, A, R(69) );
+ P( A, B, C, D, E, R(70) );
+ P( E, A, B, C, D, R(71) );
+ P( D, E, A, B, C, R(72) );
+ P( C, D, E, A, B, R(73) );
+ P( B, C, D, E, A, R(74) );
+ P( A, B, C, D, E, R(75) );
+ P( E, A, B, C, D, R(76) );
+ P( D, E, A, B, C, R(77) );
+ P( C, D, E, A, B, R(78) );
+ P( B, C, D, E, A, R(79) );
+
+#undef K
+#undef F
+
+ ctx->state[0] += A;
+ ctx->state[1] += B;
+ ctx->state[2] += C;
+ ctx->state[3] += D;
+ ctx->state[4] += E;
+}
+
+/*
+ * SHA-1 process buffer
+ */
+void sha1_update( sha1_context *ctx, unsigned char *input, int ilen )
+{
+ int fill;
+ unsigned long left;
+
+ if( ilen <= 0 )
+ return;
+
+ left = ctx->total[0] & 0x3F;
+ fill = 64 - left;
+
+ ctx->total[0] += ilen;
+ ctx->total[0] &= 0xFFFFFFFF;
+
+ if( ctx->total[0] < (unsigned long) ilen )
+ ctx->total[1]++;
+
+ if( left && ilen >= fill )
+ {
+ memcpy( (void *) (ctx->buffer + left),
+ (void *) input, fill );
+ sha1_process( ctx, ctx->buffer );
+ input += fill;
+ ilen -= fill;
+ left = 0;
+ }
+
+ while( ilen >= 64 )
+ {
+ sha1_process( ctx, input );
+ input += 64;
+ ilen -= 64;
+ }
+
+ if( ilen > 0 )
+ {
+ memcpy( (void *) (ctx->buffer + left),
+ (void *) input, ilen );
+ }
+}
+
+static const unsigned char sha1_padding[64] =
+{
+ 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+/*
+ * SHA-1 final digest
+ */
+void sha1_finish( sha1_context *ctx, unsigned char output[20] )
+{
+ unsigned long last, padn;
+ unsigned long high, low;
+ unsigned char msglen[8];
+
+ high = ( ctx->total[0] >> 29 )
+ | ( ctx->total[1] << 3 );
+ low = ( ctx->total[0] << 3 );
+
+ PUT_ULONG_BE( high, msglen, 0 );
+ PUT_ULONG_BE( low, msglen, 4 );
+
+ last = ctx->total[0] & 0x3F;
+ padn = ( last < 56 ) ? ( 56 - last ) : ( 120 - last );
+
+ sha1_update( ctx, (unsigned char *) sha1_padding, padn );
+ sha1_update( ctx, msglen, 8 );
+
+ PUT_ULONG_BE( ctx->state[0], output, 0 );
+ PUT_ULONG_BE( ctx->state[1], output, 4 );
+ PUT_ULONG_BE( ctx->state[2], output, 8 );
+ PUT_ULONG_BE( ctx->state[3], output, 12 );
+ PUT_ULONG_BE( ctx->state[4], output, 16 );
+}
+
+/*
+ * output = SHA-1( input buffer )
+ */
+void sha1( unsigned char *input, int ilen, unsigned char output[20] )
+{
+ sha1_context ctx;
+
+ sha1_starts( &ctx );
+ sha1_update( &ctx, input, ilen );
+ sha1_finish( &ctx, output );
+
+ memset( &ctx, 0, sizeof( sha1_context ) );
+}
+
+/*
+ * output = SHA-1( file contents )
+ */
+int sha1_file( char *path, unsigned char output[20] )
+{
+ FILE *f;
+ size_t n;
+ sha1_context ctx;
+ unsigned char buf[1024];
+
+ if( ( f = fopen( path, "rb" ) ) == NULL )
+ return( 1 );
+
+ sha1_starts( &ctx );
+
+ while( ( n = fread( buf, 1, sizeof( buf ), f ) ) > 0 )
+ sha1_update( &ctx, buf, (int) n );
+
+ sha1_finish( &ctx, output );
+
+ memset( &ctx, 0, sizeof( sha1_context ) );
+
+ if( ferror( f ) != 0 )
+ {
+ fclose( f );
+ return( 2 );
+ }
+
+ fclose( f );
+ return( 0 );
+}
+
+/*
+ * SHA-1 HMAC context setup
+ */
+void sha1_hmac_starts( sha1_context *ctx, unsigned char *key, int keylen )
+{
+ int i;
+ unsigned char sum[20];
+
+ if( keylen > 64 )
+ {
+ sha1( key, keylen, sum );
+ keylen = 20;
+ key = sum;
+ }
+
+ memset( ctx->ipad, 0x36, 64 );
+ memset( ctx->opad, 0x5C, 64 );
+
+ for( i = 0; i < keylen; i++ )
+ {
+ ctx->ipad[i] = (unsigned char)( ctx->ipad[i] ^ key[i] );
+ ctx->opad[i] = (unsigned char)( ctx->opad[i] ^ key[i] );
+ }
+
+ sha1_starts( ctx );
+ sha1_update( ctx, ctx->ipad, 64 );
+
+ memset( sum, 0, sizeof( sum ) );
+}
+
+/*
+ * SHA-1 HMAC process buffer
+ */
+void sha1_hmac_update( sha1_context *ctx, unsigned char *input, int ilen )
+{
+ sha1_update( ctx, input, ilen );
+}
+
+/*
+ * SHA-1 HMAC final digest
+ */
+void sha1_hmac_finish( sha1_context *ctx, unsigned char output[20] )
+{
+ unsigned char tmpbuf[20];
+
+ sha1_finish( ctx, tmpbuf );
+ sha1_starts( ctx );
+ sha1_update( ctx, ctx->opad, 64 );
+ sha1_update( ctx, tmpbuf, 20 );
+ sha1_finish( ctx, output );
+
+ memset( tmpbuf, 0, sizeof( tmpbuf ) );
+}
+
+/*
+ * output = HMAC-SHA-1( hmac key, input buffer )
+ */
+void sha1_hmac( unsigned char *key, int keylen,
+ unsigned char *input, int ilen,
+ unsigned char output[20] )
+{
+ sha1_context ctx;
+
+ sha1_hmac_starts( &ctx, key, keylen );
+ sha1_hmac_update( &ctx, input, ilen );
+ sha1_hmac_finish( &ctx, output );
+
+ memset( &ctx, 0, sizeof( sha1_context ) );
+}
+
+#if defined(POLARSSL_SELF_TEST)
+/*
+ * FIPS-180-1 test vectors
+ */
+static unsigned char sha1_test_buf[3][57] =
+{
+ { "abc" },
+ { "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" },
+ { "" }
+};
+
+static const int sha1_test_buflen[3] =
+{
+ 3, 56, 1000
+};
+
+static const unsigned char sha1_test_sum[3][20] =
+{
+ { 0xA9, 0x99, 0x3E, 0x36, 0x47, 0x06, 0x81, 0x6A, 0xBA, 0x3E,
+ 0x25, 0x71, 0x78, 0x50, 0xC2, 0x6C, 0x9C, 0xD0, 0xD8, 0x9D },
+ { 0x84, 0x98, 0x3E, 0x44, 0x1C, 0x3B, 0xD2, 0x6E, 0xBA, 0xAE,
+ 0x4A, 0xA1, 0xF9, 0x51, 0x29, 0xE5, 0xE5, 0x46, 0x70, 0xF1 },
+ { 0x34, 0xAA, 0x97, 0x3C, 0xD4, 0xC4, 0xDA, 0xA4, 0xF6, 0x1E,
+ 0xEB, 0x2B, 0xDB, 0xAD, 0x27, 0x31, 0x65, 0x34, 0x01, 0x6F }
+};
+
+/*
+ * RFC 2202 test vectors
+ */
+static unsigned char sha1_hmac_test_key[7][26] =
+{
+ { "\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B"
+ "\x0B\x0B\x0B\x0B" },
+ { "Jefe" },
+ { "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA"
+ "\xAA\xAA\xAA\xAA" },
+ { "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10"
+ "\x11\x12\x13\x14\x15\x16\x17\x18\x19" },
+ { "\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C"
+ "\x0C\x0C\x0C\x0C" },
+ { "" }, /* 0xAA 80 times */
+ { "" }
+};
+
+static const int sha1_hmac_test_keylen[7] =
+{
+ 20, 4, 20, 25, 20, 80, 80
+};
+
+static unsigned char sha1_hmac_test_buf[7][74] =
+{
+ { "Hi There" },
+ { "what do ya want for nothing?" },
+ { "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD"
+ "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD"
+ "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD"
+ "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD"
+ "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD" },
+ { "\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD"
+ "\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD"
+ "\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD"
+ "\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD"
+ "\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD" },
+ { "Test With Truncation" },
+ { "Test Using Larger Than Block-Size Key - Hash Key First" },
+ { "Test Using Larger Than Block-Size Key and Larger"
+ " Than One Block-Size Data" }
+};
+
+static const int sha1_hmac_test_buflen[7] =
+{
+ 8, 28, 50, 50, 20, 54, 73
+};
+
+static const unsigned char sha1_hmac_test_sum[7][20] =
+{
+ { 0xB6, 0x17, 0x31, 0x86, 0x55, 0x05, 0x72, 0x64, 0xE2, 0x8B,
+ 0xC0, 0xB6, 0xFB, 0x37, 0x8C, 0x8E, 0xF1, 0x46, 0xBE, 0x00 },
+ { 0xEF, 0xFC, 0xDF, 0x6A, 0xE5, 0xEB, 0x2F, 0xA2, 0xD2, 0x74,
+ 0x16, 0xD5, 0xF1, 0x84, 0xDF, 0x9C, 0x25, 0x9A, 0x7C, 0x79 },
+ { 0x12, 0x5D, 0x73, 0x42, 0xB9, 0xAC, 0x11, 0xCD, 0x91, 0xA3,
+ 0x9A, 0xF4, 0x8A, 0xA1, 0x7B, 0x4F, 0x63, 0xF1, 0x75, 0xD3 },
+ { 0x4C, 0x90, 0x07, 0xF4, 0x02, 0x62, 0x50, 0xC6, 0xBC, 0x84,
+ 0x14, 0xF9, 0xBF, 0x50, 0xC8, 0x6C, 0x2D, 0x72, 0x35, 0xDA },
+ { 0x4C, 0x1A, 0x03, 0x42, 0x4B, 0x55, 0xE0, 0x7F, 0xE7, 0xF2,
+ 0x7B, 0xE1 },
+ { 0xAA, 0x4A, 0xE5, 0xE1, 0x52, 0x72, 0xD0, 0x0E, 0x95, 0x70,
+ 0x56, 0x37, 0xCE, 0x8A, 0x3B, 0x55, 0xED, 0x40, 0x21, 0x12 },
+ { 0xE8, 0xE9, 0x9D, 0x0F, 0x45, 0x23, 0x7D, 0x78, 0x6D, 0x6B,
+ 0xBA, 0xA7, 0x96, 0x5C, 0x78, 0x08, 0xBB, 0xFF, 0x1A, 0x91 }
+};
+
+/*
+ * Checkup routine
+ */
+int sha1_self_test( int verbose )
+{
+ int i, j, buflen;
+ unsigned char buf[1024];
+ unsigned char sha1sum[20];
+ sha1_context ctx;
+
+ /*
+ * SHA-1
+ */
+ for( i = 0; i < 3; i++ )
+ {
+ if( verbose != 0 )
+ printf( " SHA-1 test #%d: ", i + 1 );
+
+ sha1_starts( &ctx );
+
+ if( i == 2 )
+ {
+ memset( buf, 'a', buflen = 1000 );
+
+ for( j = 0; j < 1000; j++ )
+ sha1_update( &ctx, buf, buflen );
+ }
+ else
+ sha1_update( &ctx, sha1_test_buf[i],
+ sha1_test_buflen[i] );
+
+ sha1_finish( &ctx, sha1sum );
+
+ if( memcmp( sha1sum, sha1_test_sum[i], 20 ) != 0 )
+ {
+ if( verbose != 0 )
+ printf( "failed\n" );
+
+ return( 1 );
+ }
+
+ if( verbose != 0 )
+ printf( "passed\n" );
+ }
+
+ if( verbose != 0 )
+ printf( "\n" );
+
+ for( i = 0; i < 7; i++ )
+ {
+ if( verbose != 0 )
+ printf( " HMAC-SHA-1 test #%d: ", i + 1 );
+
+ if( i == 5 || i == 6 )
+ {
+ memset( buf, '\xAA', buflen = 80 );
+ sha1_hmac_starts( &ctx, buf, buflen );
+ }
+ else
+ sha1_hmac_starts( &ctx, sha1_hmac_test_key[i],
+ sha1_hmac_test_keylen[i] );
+
+ sha1_hmac_update( &ctx, sha1_hmac_test_buf[i],
+ sha1_hmac_test_buflen[i] );
+
+ sha1_hmac_finish( &ctx, sha1sum );
+
+ buflen = ( i == 4 ) ? 12 : 20;
+
+ if( memcmp( sha1sum, sha1_hmac_test_sum[i], buflen ) != 0 )
+ {
+ if( verbose != 0 )
+ printf( "failed\n" );
+
+ return( 1 );
+ }
+
+ if( verbose != 0 )
+ printf( "passed\n" );
+ }
+
+ if( verbose != 0 )
+ printf( "\n" );
+
+ return( 0 );
+}
+
+#endif
+
+#endif
diff --git a/package/px5g/src/library/.svn/text-base/timing.c.svn-base b/package/px5g/src/library/.svn/text-base/timing.c.svn-base
new file mode 100644
index 0000000..6b7ab74
--- /dev/null
+++ b/package/px5g/src/library/.svn/text-base/timing.c.svn-base
@@ -0,0 +1,265 @@
+/*
+ * Portable interface to the CPU cycle counter
+ *
+ * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
+ *
+ * Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the names of PolarSSL or XySSL nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "polarssl/config.h"
+
+#if defined(POLARSSL_TIMING_C)
+
+#include "polarssl/timing.h"
+
+#if defined(WIN32)
+
+#include <windows.h>
+#include <winbase.h>
+
+struct _hr_time
+{
+ LARGE_INTEGER start;
+};
+
+#else
+
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <signal.h>
+#include <time.h>
+
+struct _hr_time
+{
+ struct timeval start;
+};
+
+#endif
+
+#if (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)
+
+unsigned long hardclock( void )
+{
+ unsigned long tsc;
+ __asm rdtsc
+ __asm mov [tsc], eax
+ return( tsc );
+}
+
+#else
+#if defined(__GNUC__) && defined(__i386__)
+
+unsigned long hardclock( void )
+{
+ unsigned long tsc;
+ asm( "rdtsc" : "=a" (tsc) );
+ return( tsc );
+}
+
+#else
+#if defined(__GNUC__) && (defined(__amd64__) || defined(__x86_64__))
+
+unsigned long hardclock( void )
+{
+ unsigned long lo, hi;
+ asm( "rdtsc" : "=a" (lo), "=d" (hi) );
+ return( lo | (hi << 32) );
+}
+
+#else
+#if defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__))
+
+unsigned long hardclock( void )
+{
+ unsigned long tbl, tbu0, tbu1;
+
+ do
+ {
+ asm( "mftbu %0" : "=r" (tbu0) );
+ asm( "mftb %0" : "=r" (tbl ) );
+ asm( "mftbu %0" : "=r" (tbu1) );
+ }
+ while( tbu0 != tbu1 );
+
+ return( tbl );
+}
+
+#else
+#if defined(__GNUC__) && defined(__sparc__)
+
+unsigned long hardclock( void )
+{
+ unsigned long tick;
+ asm( ".byte 0x83, 0x41, 0x00, 0x00" );
+ asm( "mov %%g1, %0" : "=r" (tick) );
+ return( tick );
+}
+
+#else
+#if defined(__GNUC__) && defined(__alpha__)
+
+unsigned long hardclock( void )
+{
+ unsigned long cc;
+ asm( "rpcc %0" : "=r" (cc) );
+ return( cc & 0xFFFFFFFF );
+}
+
+#else
+#if defined(__GNUC__) && defined(__ia64__)
+
+unsigned long hardclock( void )
+{
+ unsigned long itc;
+ asm( "mov %0 = ar.itc" : "=r" (itc) );
+ return( itc );
+}
+
+#else
+
+static int hardclock_init = 0;
+static struct timeval tv_init;
+
+unsigned long hardclock( void )
+{
+ struct timeval tv_cur;
+
+ if( hardclock_init == 0 )
+ {
+ gettimeofday( &tv_init, NULL );
+ hardclock_init = 1;
+ }
+
+ gettimeofday( &tv_cur, NULL );
+ return( ( tv_cur.tv_sec - tv_init.tv_sec ) * 1000000
+ + ( tv_cur.tv_usec - tv_init.tv_usec ) );
+}
+
+#endif /* generic */
+#endif /* IA-64 */
+#endif /* Alpha */
+#endif /* SPARC8 */
+#endif /* PowerPC */
+#endif /* AMD64 */
+#endif /* i586+ */
+
+int alarmed = 0;
+
+#if defined(WIN32)
+
+unsigned long get_timer( struct hr_time *val, int reset )
+{
+ unsigned long delta;
+ LARGE_INTEGER offset, hfreq;
+ struct _hr_time *t = (struct _hr_time *) val;
+
+ QueryPerformanceCounter( &offset );
+ QueryPerformanceFrequency( &hfreq );
+
+ delta = (unsigned long)( ( 1000 *
+ ( offset.QuadPart - t->start.QuadPart ) ) /
+ hfreq.QuadPart );
+
+ if( reset )
+ QueryPerformanceCounter( &t->start );
+
+ return( delta );
+}
+
+DWORD WINAPI TimerProc( LPVOID uElapse )
+{
+ Sleep( (DWORD) uElapse );
+ alarmed = 1;
+ return( TRUE );
+}
+
+void set_alarm( int seconds )
+{
+ DWORD ThreadId;
+
+ alarmed = 0;
+ CloseHandle( CreateThread( NULL, 0, TimerProc,
+ (LPVOID) ( seconds * 1000 ), 0, &ThreadId ) );
+}
+
+void m_sleep( int milliseconds )
+{
+ Sleep( milliseconds );
+}
+
+#else
+
+unsigned long get_timer( struct hr_time *val, int reset )
+{
+ unsigned long delta;
+ struct timeval offset;
+ struct _hr_time *t = (struct _hr_time *) val;
+
+ gettimeofday( &offset, NULL );
+
+ delta = ( offset.tv_sec - t->start.tv_sec ) * 1000
+ + ( offset.tv_usec - t->start.tv_usec ) / 1000;
+
+ if( reset )
+ {
+ t->start.tv_sec = offset.tv_sec;
+ t->start.tv_usec = offset.tv_usec;
+ }
+
+ return( delta );
+}
+
+static void sighandler( int signum )
+{
+ alarmed = 1;
+ signal( signum, sighandler );
+}
+
+void set_alarm( int seconds )
+{
+ alarmed = 0;
+ signal( SIGALRM, sighandler );
+ alarm( seconds );
+}
+
+void m_sleep( int milliseconds )
+{
+ struct timeval tv;
+
+ tv.tv_sec = milliseconds / 1000;
+ tv.tv_usec = milliseconds * 1000;
+
+ select( 0, NULL, NULL, NULL, &tv );
+}
+
+#endif
+
+#endif
diff --git a/package/px5g/src/library/.svn/text-base/x509write.c.svn-base b/package/px5g/src/library/.svn/text-base/x509write.c.svn-base
new file mode 100644
index 0000000..fabee20
--- /dev/null
+++ b/package/px5g/src/library/.svn/text-base/x509write.c.svn-base
@@ -0,0 +1,1139 @@
+/*
+ * X.509 certificate and private key writing
+ *
+ * Copyright (C) 2006-2007 Pascal Vizeli <pvizeli@yahoo.de>
+ * Modifications (C) 2009 Steven Barth <steven@midlink.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License, version 2.1 as published by the Free Software Foundation.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+/*
+ * The ITU-T X.509 standard defines a certificat format for PKI.
+ *
+ * http://www.ietf.org/rfc/rfc2459.txt
+ * http://www.ietf.org/rfc/rfc3279.txt
+ *
+ * ftp://ftp.rsasecurity.com/pub/pkcs/ascii/pkcs-1v2.asc
+ *
+ * http://www.itu.int/ITU-T/studygroups/com17/languages/X.680-0207.pdf
+ * http://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf
+ *
+ * For CRS:
+ * http://www.faqs.org/rfcs/rfc2314.html
+ */
+#include "polarssl/config.h"
+#include "polarssl/x509.h"
+#include "polarssl/base64.h"
+#include "polarssl/sha1.h"
+
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <time.h>
+
+#define and &&
+#define or ||
+
+#if defined _MSC_VER && !defined snprintf
+#define snprintf _snprintf
+#endif
+
+static int x509write_realloc_node(x509_node *node, size_t larger);
+static int x509write_file(x509_node *node, char *path, int format, const char* pem_prolog, const char* pem_epilog);
+
+/*
+ * evaluate how mani octet have this integer
+ */
+static int asn1_eval_octet(unsigned int digit)
+{
+ int i, byte;
+
+ for (byte = 4, i = 24; i >= 0; i -= 8, --byte)
+ if (((digit >> i) & 0xFF) != 0)
+ return byte;
+
+ return 0;
+}
+
+/*
+ * write the asn.1 lenght form into p
+ */
+static int asn1_add_len(unsigned int size, x509_node *node)
+{
+ if (size > 127) {
+
+ /* long size */
+ int byte = asn1_eval_octet(size);
+ int i = 0;
+
+ *(node->p) = (0x80 | byte) & 0xFF;
+ ++node->p;
+
+ for (i = byte; i > 0; --i) {
+
+ *(node->p) = (size >> ((i - 1) * 8)) & 0xFF;
+ ++node->p;
+ }
+
+ } else {
+
+ /* short size */
+ *(node->p) = size & 0xFF;
+ if (size != 0)
+ ++node->p;
+ }
+
+ return 0;
+}
+
+/*
+ * write a ans.1 object into p
+ */
+static int asn1_add_obj(unsigned char *value, unsigned int size, int tag,
+ x509_node *node)
+{
+ int tl = 2;
+
+ if (tag == ASN1_BIT_STRING)
+ ++tl;
+
+ if (size > 127)
+ x509write_realloc_node(node, (size_t) size + tl +
+ asn1_eval_octet(size));
+ else
+ x509write_realloc_node(node, (size_t) size + tl);
+
+ if (node->data == NULL)
+ return 1;
+
+ /* tag */
+ *(node->p) = tag & 0xFF;
+ ++node->p;
+
+ /* len */
+ if (tag == ASN1_BIT_STRING) {
+ asn1_add_len((unsigned int) size + 1, node);
+ *(node->p) = 0x00;
+ ++node->p;
+ } else {
+ asn1_add_len((unsigned int) size, node);
+ }
+
+ /* value */
+ if (size > 0) {
+
+ memcpy(node->p, value, (size_t) size);
+ if ((node->p += size -1) != node->end)
+ return POLARSSL_ERR_X509_POINT_ERROR;
+ } else {
+ /* make nothing -> NULL */
+ }
+
+ return 0;
+}
+
+/*
+ * write a asn.1 conform integer object
+ */
+static int asn1_add_int(signed int value, x509_node *node)
+{
+ signed int i = 0, neg = 1;
+ unsigned int byte, u_val = 0, tmp_val = 0;
+
+ /* if negate? */
+ if (value < 0) {
+ neg = -1;
+ u_val = ~value;
+ } else {
+ u_val = value;
+ }
+
+ byte = asn1_eval_octet(u_val);
+ /* 0 isn't NULL */
+ if (byte == 0)
+ byte = 1;
+
+ /* ASN.1 integer is signed! */
+ if (byte < 4 and ((u_val >> ((byte -1) * 8)) & 0xFF) == 0x80)
+ byte += 1;
+
+ if (x509write_realloc_node(node, (size_t) byte + 2) != 0)
+ return 1;
+
+ /* tag */
+ *(node->p) = ASN1_INTEGER;
+ ++node->p;
+
+ /* len */
+ asn1_add_len(byte, node);
+
+ /* value */
+ for (i = byte; i > 0; --i) {
+
+ tmp_val = (u_val >> ((i - 1) * 8)) & 0xFF;
+ if (neg == 1)
+ *(node->p) = tmp_val;
+ else
+ *(node->p) = ~tmp_val;
+
+ if (i > 1)
+ ++node->p;
+ }
+
+ if (node->p != node->end)
+ return POLARSSL_ERR_X509_POINT_ERROR;
+
+ return 0;
+}
+
+/*
+ * write a asn.1 conform mpi object
+ */
+static int asn1_add_mpi(mpi *value, int tag, x509_node *node)
+{
+ size_t size = (mpi_msb(value) / 8) + 1;
+ unsigned char *buf;
+ int buf_len = (int) size, tl = 2;
+
+ if (tag == ASN1_BIT_STRING)
+ ++tl;
+
+ if (size > 127)
+ x509write_realloc_node(node, size + (size_t) tl +
+ asn1_eval_octet((unsigned int)size));
+ else
+ x509write_realloc_node(node, size + (size_t) tl);
+
+ if (node->data == NULL)
+ return 1;
+
+ buf = (unsigned char*) malloc(size);
+ if (mpi_write_binary(value, buf, buf_len) != 0)
+ return POLARSSL_ERR_MPI_BUFFER_TOO_SMALL;
+
+ /* tag */
+ *(node->p) = tag & 0xFF;
+ ++node->p;
+
+ /* len */
+ if (tag == ASN1_BIT_STRING) {
+ asn1_add_len((unsigned int) size + 1, node);
+ *(node->p) = 0x00;
+ ++node->p;
+ } else {
+ asn1_add_len((unsigned int) size, node);
+ }
+
+ /* value */
+ memcpy(node->p, buf, size);
+ free(buf);
+
+ if ((node->p += (int) size -1) != node->end)
+ return POLARSSL_ERR_X509_POINT_ERROR;
+
+ return 0;
+}
+
+/*
+ * write a node into asn.1 conform object
+ */
+static int asn1_append_tag(x509_node *node, int tag)
+{
+ int tl = 2;
+
+ x509_node tmp;
+ x509write_init_node(&tmp);
+
+ if (tag == ASN1_BIT_STRING)
+ ++tl;
+
+ if (node->len > 127)
+ x509write_realloc_node(&tmp, node->len + (size_t) tl +
+ asn1_eval_octet((unsigned int)node->len));
+ else
+ x509write_realloc_node(&tmp, node->len + (size_t) tl);
+
+ if (tmp.data == NULL) {
+ x509write_free_node(&tmp);
+ return 1;
+ }
+
+ /* tag */
+ *(tmp.p) = tag & 0xFF;
+ ++tmp.p;
+
+ /* len */
+ if (tag == ASN1_BIT_STRING) {
+ asn1_add_len((unsigned int) node->len + 1, &tmp);
+ *(tmp.p) = 0x00;
+ ++tmp.p;
+ } else {
+ asn1_add_len((unsigned int) node->len, &tmp);
+ }
+
+ /* value */
+ memcpy(tmp.p, node->data, node->len);
+
+ /* good? */
+ if ((tmp.p += (int) node->len -1) != tmp.end) {
+ x509write_free_node(&tmp);
+ return POLARSSL_ERR_X509_POINT_ERROR;
+ }
+
+ free(node->data);
+ node->data = tmp.data;
+ node->p = tmp.p;
+ node->end = tmp.end;
+ node->len = tmp.len;
+
+ return 0;
+}
+
+/*
+ * write nodes into a asn.1 object
+ */
+static int asn1_append_nodes(x509_node *node, int tag, int anz, ...)
+{
+ va_list ap;
+ size_t size = 0;
+ x509_node *tmp;
+ int count;
+
+ va_start(ap, anz);
+ count = anz;
+
+ while (count--) {
+
+ tmp = va_arg(ap, x509_node*);
+ if (tmp->data != NULL)
+ size += tmp->len;
+ }
+
+ if ( size > 127) {
+ if (x509write_realloc_node(node, size + (size_t) 2 +
+ asn1_eval_octet(size)) != 0)
+ return 1;
+ } else {
+ if (x509write_realloc_node(node, size + (size_t) 2) != 0)
+ return 1;
+ }
+
+ /* tag */
+ *(node->p) = tag & 0xFF;
+ ++node->p;
+
+ /* len */
+ asn1_add_len(size, node);
+
+ /* value */
+ va_start(ap, anz);
+ count = anz;
+
+ while (count--) {
+
+ tmp = va_arg(ap, x509_node*);
+ if (tmp->data != NULL) {
+
+ memcpy(node->p, tmp->data, tmp->len);
+ if ((node->p += (int) tmp->len -1) != node->end)
+ ++node->p;
+ }
+ }
+
+ va_end(ap);
+ return 0;
+}
+
+/*
+ * write a ASN.1 conform object identifiere include a "tag"
+ */
+static int asn1_add_oid(x509_node *node, unsigned char *oid, size_t len,
+ int tag, int tag_val, unsigned char *value, size_t val_len)
+{
+ int ret;
+ x509_node tmp;
+
+ x509write_init_node(&tmp);
+
+ /* OBJECT IDENTIFIER */
+ if ((ret = asn1_add_obj(oid, len, ASN1_OID, &tmp)) != 0) {
+ x509write_free_node(&tmp);
+ return ret;
+ }
+
+ /* value */
+ if ((ret = asn1_add_obj(value, val_len, tag_val, &tmp)) != 0) {
+ x509write_free_node(&tmp);
+ return ret;
+ }
+
+ /* SET/SEQUENCE */
+ if ((ret = asn1_append_nodes(node, tag, 1, &tmp)) != 0) {
+ x509write_free_node(&tmp);
+ return ret;
+ }
+
+ x509write_free_node(&tmp);
+ return 0;
+}
+
+/*
+ * utcTime UTCTime
+ */
+static int asn1_add_date_utc(unsigned char *time, x509_node *node)
+{
+ unsigned char date[13], *sp;
+ x509_time xtime;
+ int ret;
+
+ sscanf((char*)time, "%d-%d-%d %d:%d:%d", &xtime.year, &xtime.mon,
+ &xtime.day, &xtime.hour, &xtime.min, &xtime.sec);
+
+ /* convert to YY */
+ if (xtime.year > 2000)
+ xtime.year -= 2000;
+ else
+ xtime.year -= 1900;
+
+ snprintf((char*)date, 13, "%2d%2d%2d%2d%2d%2d", xtime.year, xtime.mon, xtime.day,
+ xtime.hour, xtime.min, xtime.sec);
+
+ /* replace ' ' to '0' */
+ for (sp = date; *sp != '\0'; ++sp)
+ if (*sp == '\x20')
+ *sp = '\x30';
+
+ date[12] = 'Z';
+
+ if ((ret = asn1_add_obj(date, 13, ASN1_UTC_TIME, node)) != 0)
+ return ret;
+
+ return 0;
+}
+
+/*
+ * serialize an rsa key into DER
+ */
+
+int x509write_serialize_key(rsa_context *rsa, x509_node *node)
+{
+ int ret = 0;
+ x509write_init_node(node);
+
+ /* vers, n, e, d, p, q, dp, dq, pq */
+ if ((ret = asn1_add_int(rsa->ver, node)) != 0)
+ return ret;
+ if ((ret = asn1_add_mpi(&rsa->N, ASN1_INTEGER, node)) != 0)
+ return ret;
+ if ((ret = asn1_add_mpi(&rsa->E, ASN1_INTEGER, node)) != 0)
+ return ret;
+ if ((ret = asn1_add_mpi(&rsa->D, ASN1_INTEGER, node)) != 0)
+ return ret;
+ if ((ret = asn1_add_mpi(&rsa->P, ASN1_INTEGER, node)) != 0)
+ return ret;
+ if ((ret = asn1_add_mpi(&rsa->Q, ASN1_INTEGER, node)) != 0)
+ return ret;
+ if ((ret = asn1_add_mpi(&rsa->DP, ASN1_INTEGER, node)) != 0)
+ return ret;
+ if ((ret = asn1_add_mpi(&rsa->DQ, ASN1_INTEGER, node)) != 0)
+ return ret;
+ if ((ret = asn1_add_mpi(&rsa->QP, ASN1_INTEGER, node)) != 0)
+ return ret;
+ if ((ret = asn1_append_tag(node, ASN1_CONSTRUCTED | ASN1_SEQUENCE)) != 0)
+ return ret;
+
+ return 0;
+}
+
+/*
+ * write a der/pem encoded rsa private key into a file
+ */
+int x509write_keyfile(rsa_context *rsa, char *path, int out_flag)
+{
+ int ret = 0;
+ const char key_beg[] = "-----BEGIN RSA PRIVATE KEY-----\n",
+ key_end[] = "-----END RSA PRIVATE KEY-----\n";
+ x509_node node;
+
+ x509write_init_node(&node);
+ if ((ret = x509write_serialize_key(rsa,&node)) != 0) {
+ x509write_free_node(&node);
+ return ret;
+ }
+
+ ret = x509write_file(&node,path,out_flag,key_beg,key_end);
+ x509write_free_node(&node);
+
+ return ret;
+}
+
+
+/*
+ * reasize the memory for node
+ */
+static int x509write_realloc_node(x509_node *node, size_t larger)
+{
+ /* init len */
+ if (node->data == NULL) {
+ node->len = 0;
+ node->data = malloc(larger);
+ if(node->data == NULL)
+ return 1;
+ } else {
+ /* realloc memory */
+ if ((node->data = realloc(node->data, node->len + larger)) == NULL)
+ return 1;
+ }
+
+ /* init pointer */
+ node->p = &node->data[node->len];
+ node->len += larger;
+ node->end = &node->data[node->len -1];
+
+ return 0;
+}
+
+/*
+ * init node
+ */
+void x509write_init_node(x509_node *node)
+{
+ memset(node, 0, sizeof(x509_node));
+}
+
+/*
+ * clean memory
+ */
+void x509write_free_node(x509_node *node)
+{
+ if (node->data != NULL)
+ free(node->data);
+ node->p = NULL;
+ node->end = NULL;
+ node->len = 0;
+}
+
+/*
+ * write a x509 certificate into file
+ */
+int x509write_crtfile(x509_raw *chain, unsigned char *path, int out_flag)
+{
+ const char cer_beg[] = "-----BEGIN CERTIFICATE-----\n",
+ cer_end[] = "-----END CERTIFICATE-----\n";
+
+ return x509write_file(&chain->raw, (char*)path, out_flag, cer_beg, cer_end);
+}
+
+/*
+ * write a x509 certificate into file
+ */
+int x509write_csrfile(x509_raw *chain, unsigned char *path, int out_flag)
+{
+ const char cer_beg[] = "-----BEGIN CERTIFICATE REQUEST-----\n",
+ cer_end[] = "-----END CERTIFICATE REQUEST-----\n";
+
+ return x509write_file(&chain->raw, (char*)path, out_flag, cer_beg, cer_end);
+}
+
+/*
+ * write an x509 file
+ */
+static int x509write_file(x509_node *node, char *path, int format,
+ const char* pem_prolog, const char* pem_epilog)
+{
+ FILE *ofstream = stdout;
+ int is_err = 1, buf_len, i, n;
+ unsigned char* base_buf;
+
+ if (path) {
+ if ((ofstream = fopen(path, "wb")) == NULL)
+ return 1;
+ }
+
+ switch (format) {
+ case X509_OUTPUT_DER:
+ if (fwrite(node->data, 1, node->len, ofstream)
+ != node->len)
+ is_err = -1;
+ break;
+
+ case X509_OUTPUT_PEM:
+ if (fprintf(ofstream,pem_prolog)<0) {
+ is_err = -1;
+ break;
+ }
+
+ buf_len = node->len << 1;
+ base_buf = (unsigned char*) malloc((size_t)buf_len);
+ memset(base_buf,0,buf_len);
+ if (base64_encode(base_buf, &buf_len, node->data,
+ (int) node->len) != 0) {
+ is_err = -1;
+ break;
+ }
+
+ n=strlen((char*)base_buf);
+ for(i=0;i<n;i+=64) {
+ fprintf(ofstream,"%.64s\n",&base_buf[i]);
+ }
+
+ if (fprintf(ofstream, pem_epilog)<0) {
+ is_err = -1;
+ break;
+ }
+
+ free(base_buf);
+ }
+
+ fclose(ofstream);
+
+ if (is_err == -1)
+ return 1;
+
+ return 0;
+}
+
+
+/*
+ * add the owner public key to x509 certificate
+ */
+int x509write_add_pubkey(x509_raw *chain, rsa_context *pubkey)
+{
+ x509_node n_tmp, n_tmp2, *node;
+ int ret;
+
+ node = &chain->subpubkey;
+
+ x509write_init_node(&n_tmp);
+ x509write_init_node(&n_tmp2);
+
+ /*
+ * RSAPublicKey ::= SEQUENCE {
+ * modulus INTEGER, -- n
+ * publicExponent INTEGER -- e
+ * }
+ */
+ if ((ret = asn1_add_mpi(&pubkey->N, ASN1_INTEGER, &n_tmp)) != 0) {
+ x509write_free_node(&n_tmp);
+ x509write_free_node(&n_tmp2);
+ return ret;
+ }
+ if ((ret = asn1_add_mpi(&pubkey->E, ASN1_INTEGER, &n_tmp)) != 0) {
+ x509write_free_node(&n_tmp);
+ x509write_free_node(&n_tmp2);
+ return ret;
+ }
+ if ((ret = asn1_append_tag(&n_tmp, ASN1_CONSTRUCTED | ASN1_SEQUENCE))
+ != 0) {
+ x509write_free_node(&n_tmp);
+ x509write_free_node(&n_tmp2);
+ return ret;
+ }
+
+ /*
+ * SubjectPublicKeyInfo ::= SEQUENCE {
+ * algorithm AlgorithmIdentifier,
+ * subjectPublicKey BIT STRING }
+ */
+ if ((ret = asn1_append_tag(&n_tmp, ASN1_BIT_STRING)) != 0) {
+ x509write_free_node(&n_tmp);
+ x509write_free_node(&n_tmp2);
+ return ret;
+ }
+ if ((ret = asn1_add_oid(&n_tmp2, (unsigned char*)OID_PKCS1_RSA, 9,
+ ASN1_CONSTRUCTED | ASN1_SEQUENCE, ASN1_NULL,
+ (unsigned char *)"", 0)) != 0) {
+ x509write_free_node(&n_tmp);
+ x509write_free_node(&n_tmp2);
+ return ret;
+ }
+
+ if ((ret = asn1_append_nodes(node, ASN1_CONSTRUCTED | ASN1_SEQUENCE, 2,
+ &n_tmp2, &n_tmp))) {
+ x509write_free_node(&n_tmp);
+ x509write_free_node(&n_tmp2);
+ return ret;
+ }
+
+ x509write_free_node(&n_tmp);
+ x509write_free_node(&n_tmp2);
+ return 0;
+}
+
+/*
+ * RelativeDistinguishedName ::=
+ * SET OF AttributeTypeAndValue
+ *
+ * AttributeTypeAndValue ::= SEQUENCE {
+ * type AttributeType,
+ * value AttributeValue }
+ */
+static int x509write_add_name(x509_node *node, unsigned char *oid,
+ unsigned int oid_len, unsigned char *value, int len, int value_tag)
+{
+ int ret;
+ x509_node n_tmp;
+
+ x509write_init_node(&n_tmp);
+
+ if ((ret = asn1_add_oid(&n_tmp, oid, oid_len,
+ ASN1_CONSTRUCTED | ASN1_SEQUENCE, value_tag,
+ value, len))) {
+ x509write_free_node(&n_tmp);
+ return ret;
+ }
+
+ if ((asn1_append_nodes(node, ASN1_CONSTRUCTED | ASN1_SET, 1, &n_tmp))
+ != 0) {
+ x509write_free_node(&n_tmp);
+ return ret;
+ }
+
+ x509write_free_node(&n_tmp);
+ return 0;
+}
+
+/*
+ * Parse the name string and add to node
+ */
+static int x509write_parse_names(x509_node *node, unsigned char *names)
+{
+ unsigned char *sp, *begin = NULL;
+ unsigned char oid[3] = OID_X520, tag[4], *tag_sp = tag;
+ unsigned char *C = NULL, *CN = NULL, *O = NULL, *OU = NULL,
+ *ST = NULL, *L = NULL, *R = NULL;
+ int C_len = 0, CN_len = 0, O_len = 0, OU_len = 0, ST_len = 0,
+ L_len = 0, R_len = 0;
+ int ret = 0, is_tag = 1, is_begin = -1, len = 0;
+
+
+ for (sp = names; ; ++sp) {
+
+ /* filter tag */
+ if (is_tag == 1) {
+
+ if (tag_sp == &tag[3])
+ return POLARSSL_ERR_X509_VALUE_TO_LENGTH;
+
+ /* is tag end? */
+ if (*sp == '=') {
+ is_tag = -1;
+ *tag_sp = '\0';
+ is_begin = 1;
+ /* set len 0 (reset) */
+ len = 0;
+ } else {
+ /* tag hasn't ' '! */
+ if (*sp != ' ') {
+ *tag_sp = *sp;
+ ++tag_sp;
+ }
+ }
+ /* filter value */
+ } else {
+
+ /* set pointer of value begin */
+ if (is_begin == 1) {
+ begin = sp;
+ is_begin = -1;
+ }
+
+ /* is value at end? */
+ if (*sp == ';' or *sp == '\0') {
+ is_tag = 1;
+
+ /* common name */
+ if (tag[0] == 'C' and tag[1] == 'N') {
+ CN = begin;
+ CN_len = len;
+
+ /* organization */
+ } else if (tag[0] == 'O' and tag[1] == '\0') {
+ O = begin;
+ O_len = len;
+
+ /* country */
+ } else if (tag[0] == 'C' and tag[1] == '\0') {
+ C = begin;
+ C_len = len;
+
+ /* organisation unit */
+ } else if (tag[0] == 'O' and tag[1] == 'U') {
+ OU = begin;
+ OU_len = len;
+
+ /* state */
+ } else if (tag[0] == 'S' and tag[1] == 'T') {
+ ST = begin;
+ ST_len = len;
+
+ /* locality */
+ } else if (tag[0] == 'L' and tag[1] == '\0') {
+ L = begin;
+ L_len = len;
+
+ /* email */
+ } else if (tag[0] == 'R' and tag[1] == '\0') {
+ R = begin;
+ R_len = len;
+ }
+
+ /* set tag poiner to begin */
+ tag_sp = tag;
+
+ /* is at end? */
+ if (*sp == '\0' or *(sp +1) == '\0')
+ break;
+ } else {
+ ++len;
+ }
+ }
+
+ /* make saver */
+ if (*sp == '\0')
+ break;
+ } /* end for */
+
+ /* country */
+ if (C != NULL) {
+ oid[2] = X520_COUNTRY;
+ if ((ret = x509write_add_name(node, oid, 3, C, C_len,
+ ASN1_PRINTABLE_STRING)) != 0)
+ return ret;
+ }
+
+ /* state */
+ if (ST != NULL) {
+ oid[2] = X520_STATE;
+ if ((ret = x509write_add_name(node, oid, 3, ST, ST_len,
+ ASN1_PRINTABLE_STRING)) != 0)
+ return ret;
+ }
+
+ /* locality */
+ if (L != NULL) {
+ oid[2] = X520_LOCALITY;
+ if ((ret = x509write_add_name(node, oid, 3, L, L_len,
+ ASN1_PRINTABLE_STRING)) != 0)
+ return ret;
+ }
+
+ /* organization */
+ if (O != NULL) {
+ oid[2] = X520_ORGANIZATION;
+ if ((ret = x509write_add_name(node, oid, 3, O, O_len,
+ ASN1_PRINTABLE_STRING)) != 0)
+ return ret;
+ }
+
+ /* organisation unit */
+ if (OU != NULL) {
+ oid[2] = X520_ORG_UNIT;
+ if ((ret = x509write_add_name(node, oid, 3, OU, OU_len,
+ ASN1_PRINTABLE_STRING)) != 0)
+ return ret;
+ }
+
+ /* common name */
+ if (CN != NULL) {
+ oid[2] = X520_COMMON_NAME;
+ if ((ret = x509write_add_name(node, oid, 3, CN, CN_len,
+ ASN1_PRINTABLE_STRING)) != 0)
+ return ret;
+ }
+
+ /* email */
+ if (R != NULL) {
+ if ((ret = x509write_add_name(node, (unsigned char*)OID_PKCS9_EMAIL,
+ 9, R, R_len, ASN1_IA5_STRING)) != 0)
+ return ret;
+ }
+
+ if ((asn1_append_tag(node, ASN1_CONSTRUCTED | ASN1_SEQUENCE)) != 0)
+ return ret;
+
+ return 0;
+}
+
+/*
+ * Copy raw data from orginal ca to node
+ */
+static int x509write_copy_from_raw(x509_node *node, x509_buf *raw)
+{
+ if (x509write_realloc_node(node, raw->len) != 0)
+ return 1;
+
+ memcpy(node->p, raw->p, (size_t)raw->len);
+ if ((node->p += raw->len -1) != node->end)
+ return POLARSSL_ERR_X509_POINT_ERROR;
+
+ return 0;
+}
+
+/*
+ * Add the issuer
+ */
+
+int x509write_add_issuer(x509_raw *crt, unsigned char *issuer)
+{
+ return x509write_parse_names(&crt->issuer, issuer);
+}
+
+/*
+ * Add the subject
+ */
+int x509write_add_subject(x509_raw *crt, unsigned char *subject)
+{
+ return x509write_parse_names(&crt->subject, subject);
+}
+
+/*
+ * Copy issuer line from another cert to issuer
+ */
+int x509write_copy_issuer(x509_raw *crt, x509_cert *from_crt)
+{
+ return x509write_copy_from_raw(&crt->issuer, &from_crt->issuer_raw);
+}
+
+/*
+ * Copy subject line from another cert
+ */
+int x509write_copy_subject(x509_raw *crt, x509_cert *from_crt)
+{
+ return x509write_copy_from_raw(&crt->subject, &from_crt->subject_raw);
+}
+
+/*
+ * Copy subject line form antoher cert into issuer
+ */
+int x509write_copy_issuer_form_subject(x509_raw *crt,
+ x509_cert *from_crt)
+{
+ return x509write_copy_from_raw(&crt->issuer, &from_crt->subject_raw);
+}
+
+/*
+ * Copy issuer line from another cert into subject
+ */
+int x509write_copy_subject_from_issuer(x509_raw *crt,
+ x509_cert * from_crt)
+{
+ return x509write_copy_from_raw(&crt->subject, &from_crt->issuer_raw);
+}
+
+/*
+ * Validity ::= SEQUENCE {
+ * notBefore Time,
+ * notAfter Time }
+ *
+ * Time ::= CHOICE {
+ * utcTime UTCTime,
+ * generalTime GeneralizedTime }
+ */
+/* TODO: No handle GeneralizedTime! */
+int x509write_add_validity(x509_raw *chain, unsigned char *befor,
+ unsigned char *after)
+{
+ int ret;
+
+ x509_node *node = &chain->validity;
+
+ /* notBefore */
+ if ((ret = asn1_add_date_utc(befor, node)) != 0)
+ return ret;
+
+ /* notAfter */
+ if ((ret = asn1_add_date_utc(after, node)) != 0)
+ return ret;
+
+ if ((ret = asn1_append_tag(node, ASN1_CONSTRUCTED | ASN1_SEQUENCE)) != 0)
+ return ret;
+
+ return 0;
+}
+
+/*
+ * make hash from tbs and sign that with private key
+ */
+static int x509write_make_sign(x509_raw *chain, rsa_context *privkey)
+{
+ int ret;
+ unsigned char hash[20], *sign;
+ size_t sign_len = (size_t) mpi_size(&privkey->N);
+
+ /* make hash */
+ sha1(chain->tbs.data, chain->tbs.len, hash);
+
+ /* create sign */
+ sign = (unsigned char *) malloc(sign_len);
+ if (sign == NULL)
+ return 1;
+
+ if ((ret = rsa_pkcs1_sign(privkey, RSA_PRIVATE, RSA_SHA1, 20, hash,
+ sign)) != 0)
+ return ret;
+
+ if ((ret = asn1_add_obj(sign, sign_len, ASN1_BIT_STRING,
+ &chain->sign)) != 0)
+ return ret;
+
+ /*
+ * AlgorithmIdentifier ::= SEQUENCE {
+ * algorithm OBJECT IDENTIFIER,
+ * parameters ANY DEFINED BY algorithm OPTIONAL }
+ */
+ return asn1_add_oid(&chain->signalg, (unsigned char*)OID_PKCS1_RSA_SHA, 9,
+ ASN1_CONSTRUCTED | ASN1_SEQUENCE, ASN1_NULL,
+ (unsigned char*)"", 0);
+}
+
+/*
+ * Create a self signed certificate
+ */
+int x509write_create_sign(x509_raw *chain, rsa_context *privkey)
+{
+ int ret, serial;
+
+ /*
+ * Version ::= INTEGER { v1(0), v2(1), v3(2) }
+ */
+ if ((ret = asn1_add_int(2, &chain->version)) != 0)
+ return ret;
+
+ if ((ret = asn1_append_tag(&chain->version, ASN1_CONTEXT_SPECIFIC |
+ ASN1_CONSTRUCTED)) != 0)
+ return ret;
+
+
+ /*
+ * CertificateSerialNumber ::= INTEGER
+ */
+ srand((unsigned int) time(NULL));
+ serial = rand();
+ if ((ret = asn1_add_int(serial, &chain->serial)) != 0)
+ return ret;
+
+ /*
+ * AlgorithmIdentifier ::= SEQUENCE {
+ * algorithm OBJECT IDENTIFIER,
+ * parameters ANY DEFINED BY algorithm OPTIONAL }
+ */
+ if ((ret = asn1_add_oid(&chain->tbs_signalg,
+ (unsigned char*)OID_PKCS1_RSA_SHA, 9, ASN1_CONSTRUCTED |
+ ASN1_SEQUENCE, ASN1_NULL, (unsigned char*)"", 0)) != 0)
+ return ret;
+
+ /*
+ * Create the tbs
+ */
+ if ((ret = asn1_append_nodes(&chain->tbs, ASN1_CONSTRUCTED |
+ ASN1_SEQUENCE, 7, &chain->version, &chain->serial,
+ &chain->tbs_signalg, &chain->issuer, &chain->validity,
+ &chain->subject, &chain->subpubkey)) != 0)
+ return ret;
+
+ /* make signing */
+ if ((ret = x509write_make_sign(chain, privkey)) != 0)
+ return ret;
+
+ /* finishing */
+ if ((ret = asn1_append_nodes(&chain->raw, ASN1_CONSTRUCTED |
+ ASN1_SEQUENCE, 3, &chain->tbs, &chain->signalg,
+ &chain->sign)) != 0)
+ return ret;
+
+ return 0;
+}
+
+int x509write_create_selfsign(x509_raw *chain, rsa_context *privkey)
+{
+ /*
+ * On self signed certificate are subject and issuer the same
+ */
+ x509write_free_node(&chain->issuer);
+ chain->issuer = chain->subject;
+ return x509write_create_sign(chain, privkey);
+}
+
+/*
+ * CertificationRequestInfo ::= SEQUENCE {
+ * version Version,
+ * subject Name,
+ * subjectPublicKeyInfo SubjectPublicKeyInfo,
+ * attributes [0] IMPLICIT Attributes }
+ *
+ * CertificationRequest ::= SEQUENCE {
+ * certificationRequestInfo CertificationRequestInfo,
+ * signatureAlgorithm SignatureAlgorithmIdentifier,
+ * signature Signature }
+ *
+ * It use chain.serail for attributes!
+ *
+ */
+int x509write_create_csr(x509_raw *chain, rsa_context *privkey)
+{
+ int ret;
+
+ /* version ::= INTEGER */
+ if ((ret = asn1_add_int(0, &chain->version)) != 0)
+ return ret;
+
+ /* write attributes */
+ if ((ret = asn1_add_obj((unsigned char*)"", 0, ASN1_CONTEXT_SPECIFIC |
+ ASN1_CONSTRUCTED, &chain->serial)) != 0)
+ return ret;
+
+ /* create CertificationRequestInfo */
+ if ((ret = asn1_append_nodes(&chain->tbs, ASN1_CONSTRUCTED |
+ ASN1_SEQUENCE, 4, &chain->version, &chain->subject,
+ &chain->subpubkey, &chain->serial)) != 0)
+ return ret;
+
+ /* make signing */
+ if ((ret = x509write_make_sign(chain, privkey)) != 0)
+ return ret;
+
+ /* finish */
+ if ((ret = asn1_append_nodes(&chain->raw, ASN1_CONSTRUCTED | ASN1_SEQUENCE,
+ 3, &chain->tbs, &chain->signalg, &chain->sign)) != 0)
+ return ret;
+
+ return ret;
+}
+
+/*
+ * Free memory
+ */
+void x509write_free_raw(x509_raw *chain)
+{
+ x509write_free_node(&chain->raw);
+ x509write_free_node(&chain->tbs);
+ x509write_free_node(&chain->version);
+ x509write_free_node(&chain->serial);
+ x509write_free_node(&chain->tbs_signalg);
+ x509write_free_node(&chain->issuer);
+ x509write_free_node(&chain->validity);
+ if (chain->subject.data != chain->issuer.data)
+ x509write_free_node(&chain->subject);
+ x509write_free_node(&chain->subpubkey);
+ x509write_free_node(&chain->signalg);
+ x509write_free_node(&chain->sign);
+}
+
+void x509write_init_raw(x509_raw *chain)
+{
+ memset((void *) chain, 0, sizeof(x509_raw));
+}
+
diff --git a/package/px5g/src/library/base64.c b/package/px5g/src/library/base64.c
new file mode 100644
index 0000000..b7cc5b8
--- /dev/null
+++ b/package/px5g/src/library/base64.c
@@ -0,0 +1,264 @@
+/*
+ * RFC 1521 base64 encoding/decoding
+ *
+ * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
+ *
+ * Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the names of PolarSSL or XySSL nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "polarssl/config.h"
+
+#if defined(POLARSSL_BASE64_C)
+
+#include "polarssl/base64.h"
+
+static const unsigned char base64_enc_map[64] =
+{
+ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
+ 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
+ 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd',
+ 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
+ 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x',
+ 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7',
+ '8', '9', '+', '/'
+};
+
+static const unsigned char base64_dec_map[128] =
+{
+ 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
+ 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
+ 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
+ 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
+ 127, 127, 127, 62, 127, 127, 127, 63, 52, 53,
+ 54, 55, 56, 57, 58, 59, 60, 61, 127, 127,
+ 127, 64, 127, 127, 127, 0, 1, 2, 3, 4,
+ 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
+ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
+ 25, 127, 127, 127, 127, 127, 127, 26, 27, 28,
+ 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
+ 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
+ 49, 50, 51, 127, 127, 127, 127, 127
+};
+
+/*
+ * Encode a buffer into base64 format
+ */
+int base64_encode( unsigned char *dst, int *dlen,
+ unsigned char *src, int slen )
+{
+ int i, n;
+ int C1, C2, C3;
+ unsigned char *p;
+
+ if( slen == 0 )
+ return( 0 );
+
+ n = (slen << 3) / 6;
+
+ switch( (slen << 3) - (n * 6) )
+ {
+ case 2: n += 3; break;
+ case 4: n += 2; break;
+ default: break;
+ }
+
+ if( *dlen < n + 1 )
+ {
+ *dlen = n + 1;
+ return( POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL );
+ }
+
+ n = (slen / 3) * 3;
+
+ for( i = 0, p = dst; i < n; i += 3 )
+ {
+ C1 = *src++;
+ C2 = *src++;
+ C3 = *src++;
+
+ *p++ = base64_enc_map[(C1 >> 2) & 0x3F];
+ *p++ = base64_enc_map[(((C1 & 3) << 4) + (C2 >> 4)) & 0x3F];
+ *p++ = base64_enc_map[(((C2 & 15) << 2) + (C3 >> 6)) & 0x3F];
+ *p++ = base64_enc_map[C3 & 0x3F];
+ }
+
+ if( i < slen )
+ {
+ C1 = *src++;
+ C2 = ((i + 1) < slen) ? *src++ : 0;
+
+ *p++ = base64_enc_map[(C1 >> 2) & 0x3F];
+ *p++ = base64_enc_map[(((C1 & 3) << 4) + (C2 >> 4)) & 0x3F];
+
+ if( (i + 1) < slen )
+ *p++ = base64_enc_map[((C2 & 15) << 2) & 0x3F];
+ else *p++ = '=';
+
+ *p++ = '=';
+ }
+
+ *dlen = p - dst;
+ *p = 0;
+
+ return( 0 );
+}
+
+/*
+ * Decode a base64-formatted buffer
+ */
+int base64_decode( unsigned char *dst, int *dlen,
+ unsigned char *src, int slen )
+{
+ int i, j, n;
+ unsigned long x;
+ unsigned char *p;
+
+ for( i = j = n = 0; i < slen; i++ )
+ {
+ if( ( slen - i ) >= 2 &&
+ src[i] == '\r' && src[i + 1] == '\n' )
+ continue;
+
+ if( src[i] == '\n' )
+ continue;
+
+ if( src[i] == '=' && ++j > 2 )
+ return( POLARSSL_ERR_BASE64_INVALID_CHARACTER );
+
+ if( src[i] > 127 || base64_dec_map[src[i]] == 127 )
+ return( POLARSSL_ERR_BASE64_INVALID_CHARACTER );
+
+ if( base64_dec_map[src[i]] < 64 && j != 0 )
+ return( POLARSSL_ERR_BASE64_INVALID_CHARACTER );
+
+ n++;
+ }
+
+ if( n == 0 )
+ return( 0 );
+
+ n = ((n * 6) + 7) >> 3;
+
+ if( *dlen < n )
+ {
+ *dlen = n;
+ return( POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL );
+ }
+
+ for( j = 3, n = x = 0, p = dst; i > 0; i--, src++ )
+ {
+ if( *src == '\r' || *src == '\n' )
+ continue;
+
+ j -= ( base64_dec_map[*src] == 64 );
+ x = (x << 6) | ( base64_dec_map[*src] & 0x3F );
+
+ if( ++n == 4 )
+ {
+ n = 0;
+ if( j > 0 ) *p++ = (unsigned char)( x >> 16 );
+ if( j > 1 ) *p++ = (unsigned char)( x >> 8 );
+ if( j > 2 ) *p++ = (unsigned char)( x );
+ }
+ }
+
+ *dlen = p - dst;
+
+ return( 0 );
+}
+
+#if defined(POLARSSL_SELF_TEST)
+
+#include <string.h>
+#include <stdio.h>
+
+static const unsigned char base64_test_dec[64] =
+{
+ 0x24, 0x48, 0x6E, 0x56, 0x87, 0x62, 0x5A, 0xBD,
+ 0xBF, 0x17, 0xD9, 0xA2, 0xC4, 0x17, 0x1A, 0x01,
+ 0x94, 0xED, 0x8F, 0x1E, 0x11, 0xB3, 0xD7, 0x09,
+ 0x0C, 0xB6, 0xE9, 0x10, 0x6F, 0x22, 0xEE, 0x13,
+ 0xCA, 0xB3, 0x07, 0x05, 0x76, 0xC9, 0xFA, 0x31,
+ 0x6C, 0x08, 0x34, 0xFF, 0x8D, 0xC2, 0x6C, 0x38,
+ 0x00, 0x43, 0xE9, 0x54, 0x97, 0xAF, 0x50, 0x4B,
+ 0xD1, 0x41, 0xBA, 0x95, 0x31, 0x5A, 0x0B, 0x97
+};
+
+static const unsigned char base64_test_enc[] =
+ "JEhuVodiWr2/F9mixBcaAZTtjx4Rs9cJDLbpEG8i7hPK"
+ "swcFdsn6MWwINP+Nwmw4AEPpVJevUEvRQbqVMVoLlw==";
+
+/*
+ * Checkup routine
+ */
+int base64_self_test( int verbose )
+{
+ int len;
+ unsigned char *src, buffer[128];
+
+ if( verbose != 0 )
+ printf( " Base64 encoding test: " );
+
+ len = sizeof( buffer );
+ src = (unsigned char *) base64_test_dec;
+
+ if( base64_encode( buffer, &len, src, 64 ) != 0 ||
+ memcmp( base64_test_enc, buffer, 88 ) != 0 )
+ {
+ if( verbose != 0 )
+ printf( "failed\n" );
+
+ return( 1 );
+ }
+
+ if( verbose != 0 )
+ printf( "passed\n Base64 decoding test: " );
+
+ len = sizeof( buffer );
+ src = (unsigned char *) base64_test_enc;
+
+ if( base64_decode( buffer, &len, src, 88 ) != 0 ||
+ memcmp( base64_test_dec, buffer, 64 ) != 0 )
+ {
+ if( verbose != 0 )
+ printf( "failed\n" );
+
+ return( 1 );
+ }
+
+ if( verbose != 0 )
+ printf( "passed\n\n" );
+
+ return( 0 );
+}
+
+#endif
+
+#endif
diff --git a/package/px5g/src/library/bignum.c b/package/px5g/src/library/bignum.c
new file mode 100644
index 0000000..8b7c12f
--- /dev/null
+++ b/package/px5g/src/library/bignum.c
@@ -0,0 +1,2010 @@
+/*
+ * Multi-precision integer library
+ *
+ * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
+ *
+ * Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the names of PolarSSL or XySSL nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+/*
+ * This MPI implementation is based on:
+ *
+ * http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf
+ * http://www.stillhq.com/extracted/gnupg-api/mpi/
+ * http://math.libtomcrypt.com/files/tommath.pdf
+ */
+
+#include "polarssl/config.h"
+
+#if defined(POLARSSL_BIGNUM_C)
+
+#include "polarssl/bignum.h"
+#include "polarssl/bn_mul.h"
+
+#include <string.h>
+#include <stdlib.h>
+#include <stdarg.h>
+
+#define ciL ((int) sizeof(t_int)) /* chars in limb */
+#define biL (ciL << 3) /* bits in limb */
+#define biH (ciL << 2) /* half limb size */
+
+/*
+ * Convert between bits/chars and number of limbs
+ */
+#define BITS_TO_LIMBS(i) (((i) + biL - 1) / biL)
+#define CHARS_TO_LIMBS(i) (((i) + ciL - 1) / ciL)
+
+/*
+ * Initialize one or more mpi
+ */
+void mpi_init( mpi *X, ... )
+{
+ va_list args;
+
+ va_start( args, X );
+
+ while( X != NULL )
+ {
+ X->s = 1;
+ X->n = 0;
+ X->p = NULL;
+
+ X = va_arg( args, mpi* );
+ }
+
+ va_end( args );
+}
+
+/*
+ * Unallocate one or more mpi
+ */
+void mpi_free( mpi *X, ... )
+{
+ va_list args;
+
+ va_start( args, X );
+
+ while( X != NULL )
+ {
+ if( X->p != NULL )
+ {
+ memset( X->p, 0, X->n * ciL );
+ free( X->p );
+ }
+
+ X->s = 1;
+ X->n = 0;
+ X->p = NULL;
+
+ X = va_arg( args, mpi* );
+ }
+
+ va_end( args );
+}
+
+/*
+ * Enlarge to the specified number of limbs
+ */
+int mpi_grow( mpi *X, int nblimbs )
+{
+ t_int *p;
+
+ if( X->n < nblimbs )
+ {
+ if( ( p = (t_int *) malloc( nblimbs * ciL ) ) == NULL )
+ return( 1 );
+
+ memset( p, 0, nblimbs * ciL );
+
+ if( X->p != NULL )
+ {
+ memcpy( p, X->p, X->n * ciL );
+ memset( X->p, 0, X->n * ciL );
+ free( X->p );
+ }
+
+ X->n = nblimbs;
+ X->p = p;
+ }
+
+ return( 0 );
+}
+
+/*
+ * Copy the contents of Y into X
+ */
+int mpi_copy( mpi *X, mpi *Y )
+{
+ int ret, i;
+
+ if( X == Y )
+ return( 0 );
+
+ for( i = Y->n - 1; i > 0; i-- )
+ if( Y->p[i] != 0 )
+ break;
+ i++;
+
+ X->s = Y->s;
+
+ MPI_CHK( mpi_grow( X, i ) );
+
+ memset( X->p, 0, X->n * ciL );
+ memcpy( X->p, Y->p, i * ciL );
+
+cleanup:
+
+ return( ret );
+}
+
+/*
+ * Swap the contents of X and Y
+ */
+void mpi_swap( mpi *X, mpi *Y )
+{
+ mpi T;
+
+ memcpy( &T, X, sizeof( mpi ) );
+ memcpy( X, Y, sizeof( mpi ) );
+ memcpy( Y, &T, sizeof( mpi ) );
+}
+
+/*
+ * Set value from integer
+ */
+int mpi_lset( mpi *X, int z )
+{
+ int ret;
+
+ MPI_CHK( mpi_grow( X, 1 ) );
+ memset( X->p, 0, X->n * ciL );
+
+ X->p[0] = ( z < 0 ) ? -z : z;
+ X->s = ( z < 0 ) ? -1 : 1;
+
+cleanup:
+
+ return( ret );
+}
+
+/*
+ * Return the number of least significant bits
+ */
+int mpi_lsb( mpi *X )
+{
+ int i, j, count = 0;
+
+ for( i = 0; i < X->n; i++ )
+ for( j = 0; j < (int) biL; j++, count++ )
+ if( ( ( X->p[i] >> j ) & 1 ) != 0 )
+ return( count );
+
+ return( 0 );
+}
+
+/*
+ * Return the number of most significant bits
+ */
+int mpi_msb( mpi *X )
+{
+ int i, j;
+
+ for( i = X->n - 1; i > 0; i-- )
+ if( X->p[i] != 0 )
+ break;
+
+ for( j = biL - 1; j >= 0; j-- )
+ if( ( ( X->p[i] >> j ) & 1 ) != 0 )
+ break;
+
+ return( ( i * biL ) + j + 1 );
+}
+
+/*
+ * Return the total size in bytes
+ */
+int mpi_size( mpi *X )
+{
+ return( ( mpi_msb( X ) + 7 ) >> 3 );
+}
+
+/*
+ * Convert an ASCII character to digit value
+ */
+static int mpi_get_digit( t_int *d, int radix, char c )
+{
+ *d = 255;
+
+ if( c >= 0x30 && c <= 0x39 ) *d = c - 0x30;
+ if( c >= 0x41 && c <= 0x46 ) *d = c - 0x37;
+ if( c >= 0x61 && c <= 0x66 ) *d = c - 0x57;
+
+ if( *d >= (t_int) radix )
+ return( POLARSSL_ERR_MPI_INVALID_CHARACTER );
+
+ return( 0 );
+}
+
+/*
+ * Import from an ASCII string
+ */
+int mpi_read_string( mpi *X, int radix, char *s )
+{
+ int ret, i, j, n;
+ t_int d;
+ mpi T;
+
+ if( radix < 2 || radix > 16 )
+ return( POLARSSL_ERR_MPI_BAD_INPUT_DATA );
+
+ mpi_init( &T, NULL );
+
+ if( radix == 16 )
+ {
+ n = BITS_TO_LIMBS( strlen( s ) << 2 );
+
+ MPI_CHK( mpi_grow( X, n ) );
+ MPI_CHK( mpi_lset( X, 0 ) );
+
+ for( i = strlen( s ) - 1, j = 0; i >= 0; i--, j++ )
+ {
+ if( i == 0 && s[i] == '-' )
+ {
+ X->s = -1;
+ break;
+ }
+
+ MPI_CHK( mpi_get_digit( &d, radix, s[i] ) );
+ X->p[j / (2 * ciL)] |= d << ( (j % (2 * ciL)) << 2 );
+ }
+ }
+ else
+ {
+ MPI_CHK( mpi_lset( X, 0 ) );
+
+ for( i = 0; i < (int) strlen( s ); i++ )
+ {
+ if( i == 0 && s[i] == '-' )
+ {
+ X->s = -1;
+ continue;
+ }
+
+ MPI_CHK( mpi_get_digit( &d, radix, s[i] ) );
+ MPI_CHK( mpi_mul_int( &T, X, radix ) );
+ MPI_CHK( mpi_add_int( X, &T, d ) );
+ }
+ }
+
+cleanup:
+
+ mpi_free( &T, NULL );
+
+ return( ret );
+}
+
+/*
+ * Helper to write the digits high-order first
+ */
+static int mpi_write_hlp( mpi *X, int radix, char **p )
+{
+ int ret;
+ t_int r;
+
+ if( radix < 2 || radix > 16 )
+ return( POLARSSL_ERR_MPI_BAD_INPUT_DATA );
+
+ MPI_CHK( mpi_mod_int( &r, X, radix ) );
+ MPI_CHK( mpi_div_int( X, NULL, X, radix ) );
+
+ if( mpi_cmp_int( X, 0 ) != 0 )
+ MPI_CHK( mpi_write_hlp( X, radix, p ) );
+
+ if( r < 10 )
+ *(*p)++ = (char)( r + 0x30 );
+ else
+ *(*p)++ = (char)( r + 0x37 );
+
+cleanup:
+
+ return( ret );
+}
+
+/*
+ * Export into an ASCII string
+ */
+int mpi_write_string( mpi *X, int radix, char *s, int *slen )
+{
+ int ret = 0, n;
+ char *p;
+ mpi T;
+
+ if( radix < 2 || radix > 16 )
+ return( POLARSSL_ERR_MPI_BAD_INPUT_DATA );
+
+ n = mpi_msb( X );
+ if( radix >= 4 ) n >>= 1;
+ if( radix >= 16 ) n >>= 1;
+ n += 3;
+
+ if( *slen < n )
+ {
+ *slen = n;
+ return( POLARSSL_ERR_MPI_BUFFER_TOO_SMALL );
+ }
+
+ p = s;
+ mpi_init( &T, NULL );
+
+ if( X->s == -1 )
+ *p++ = '-';
+
+ if( radix == 16 )
+ {
+ int c, i, j, k;
+
+ for( i = X->n - 1, k = 0; i >= 0; i-- )
+ {
+ for( j = ciL - 1; j >= 0; j-- )
+ {
+ c = ( X->p[i] >> (j << 3) ) & 0xFF;
+
+ if( c == 0 && k == 0 && (i + j) != 0 )
+ continue;
+
+ p += sprintf( p, "%02X", c );
+ k = 1;
+ }
+ }
+ }
+ else
+ {
+ MPI_CHK( mpi_copy( &T, X ) );
+ MPI_CHK( mpi_write_hlp( &T, radix, &p ) );
+ }
+
+ *p++ = '\0';
+ *slen = p - s;
+
+cleanup:
+
+ mpi_free( &T, NULL );
+
+ return( ret );
+}
+
+/*
+ * Read X from an opened file
+ */
+int mpi_read_file( mpi *X, int radix, FILE *fin )
+{
+ t_int d;
+ int slen;
+ char *p;
+ char s[1024];
+
+ memset( s, 0, sizeof( s ) );
+ if( fgets( s, sizeof( s ) - 1, fin ) == NULL )
+ return( POLARSSL_ERR_MPI_FILE_IO_ERROR );
+
+ slen = strlen( s );
+ if( s[slen - 1] == '\n' ) { slen--; s[slen] = '\0'; }
+ if( s[slen - 1] == '\r' ) { slen--; s[slen] = '\0'; }
+
+ p = s + slen;
+ while( --p >= s )
+ if( mpi_get_digit( &d, radix, *p ) != 0 )
+ break;
+
+ return( mpi_read_string( X, radix, p + 1 ) );
+}
+
+/*
+ * Write X into an opened file (or stdout if fout == NULL)
+ */
+int mpi_write_file( char *p, mpi *X, int radix, FILE *fout )
+{
+ int n, ret;
+ size_t slen;
+ size_t plen;
+ char s[1024];
+
+ n = sizeof( s );
+ memset( s, 0, n );
+ n -= 2;
+
+ MPI_CHK( mpi_write_string( X, radix, s, (int *) &n ) );
+
+ if( p == NULL ) p = "";
+
+ plen = strlen( p );
+ slen = strlen( s );
+ s[slen++] = '\r';
+ s[slen++] = '\n';
+
+ if( fout != NULL )
+ {
+ if( fwrite( p, 1, plen, fout ) != plen ||
+ fwrite( s, 1, slen, fout ) != slen )
+ return( POLARSSL_ERR_MPI_FILE_IO_ERROR );
+ }
+ else
+ printf( "%s%s", p, s );
+
+cleanup:
+
+ return( ret );
+}
+
+/*
+ * Import X from unsigned binary data, big endian
+ */
+int mpi_read_binary( mpi *X, unsigned char *buf, int buflen )
+{
+ int ret, i, j, n;
+
+ for( n = 0; n < buflen; n++ )
+ if( buf[n] != 0 )
+ break;
+
+ MPI_CHK( mpi_grow( X, CHARS_TO_LIMBS( buflen - n ) ) );
+ MPI_CHK( mpi_lset( X, 0 ) );
+
+ for( i = buflen - 1, j = 0; i >= n; i--, j++ )
+ X->p[j / ciL] |= ((t_int) buf[i]) << ((j % ciL) << 3);
+
+cleanup:
+
+ return( ret );
+}
+
+/*
+ * Export X into unsigned binary data, big endian
+ */
+int mpi_write_binary( mpi *X, unsigned char *buf, int buflen )
+{
+ int i, j, n;
+
+ n = mpi_size( X );
+
+ if( buflen < n )
+ return( POLARSSL_ERR_MPI_BUFFER_TOO_SMALL );
+
+ memset( buf, 0, buflen );
+
+ for( i = buflen - 1, j = 0; n > 0; i--, j++, n-- )
+ buf[i] = (unsigned char)( X->p[j / ciL] >> ((j % ciL) << 3) );
+
+ return( 0 );
+}
+
+/*
+ * Left-shift: X <<= count
+ */
+int mpi_shift_l( mpi *X, int count )
+{
+ int ret, i, v0, t1;
+ t_int r0 = 0, r1;
+
+ v0 = count / (biL );
+ t1 = count & (biL - 1);
+
+ i = mpi_msb( X ) + count;
+
+ if( X->n * (int) biL < i )
+ MPI_CHK( mpi_grow( X, BITS_TO_LIMBS( i ) ) );
+
+ ret = 0;
+
+ /*
+ * shift by count / limb_size
+ */
+ if( v0 > 0 )
+ {
+ for( i = X->n - 1; i >= v0; i-- )
+ X->p[i] = X->p[i - v0];
+
+ for( ; i >= 0; i-- )
+ X->p[i] = 0;
+ }
+
+ /*
+ * shift by count % limb_size
+ */
+ if( t1 > 0 )
+ {
+ for( i = v0; i < X->n; i++ )
+ {
+ r1 = X->p[i] >> (biL - t1);
+ X->p[i] <<= t1;
+ X->p[i] |= r0;
+ r0 = r1;
+ }
+ }
+
+cleanup:
+
+ return( ret );
+}
+
+/*
+ * Right-shift: X >>= count
+ */
+int mpi_shift_r( mpi *X, int count )
+{
+ int i, v0, v1;
+ t_int r0 = 0, r1;
+
+ v0 = count / biL;
+ v1 = count & (biL - 1);
+
+ /*
+ * shift by count / limb_size
+ */
+ if( v0 > 0 )
+ {
+ for( i = 0; i < X->n - v0; i++ )
+ X->p[i] = X->p[i + v0];
+
+ for( ; i < X->n; i++ )
+ X->p[i] = 0;
+ }
+
+ /*
+ * shift by count % limb_size
+ */
+ if( v1 > 0 )
+ {
+ for( i = X->n - 1; i >= 0; i-- )
+ {
+ r1 = X->p[i] << (biL - v1);
+ X->p[i] >>= v1;
+ X->p[i] |= r0;
+ r0 = r1;
+ }
+ }
+
+ return( 0 );
+}
+
+/*
+ * Compare unsigned values
+ */
+int mpi_cmp_abs( mpi *X, mpi *Y )
+{
+ int i, j;
+
+ for( i = X->n - 1; i >= 0; i-- )
+ if( X->p[i] != 0 )
+ break;
+
+ for( j = Y->n - 1; j >= 0; j-- )
+ if( Y->p[j] != 0 )
+ break;
+
+ if( i < 0 && j < 0 )
+ return( 0 );
+
+ if( i > j ) return( 1 );
+ if( j > i ) return( -1 );
+
+ for( ; i >= 0; i-- )
+ {
+ if( X->p[i] > Y->p[i] ) return( 1 );
+ if( X->p[i] < Y->p[i] ) return( -1 );
+ }
+
+ return( 0 );
+}
+
+/*
+ * Compare signed values
+ */
+int mpi_cmp_mpi( mpi *X, mpi *Y )
+{
+ int i, j;
+
+ for( i = X->n - 1; i >= 0; i-- )
+ if( X->p[i] != 0 )
+ break;
+
+ for( j = Y->n - 1; j >= 0; j-- )
+ if( Y->p[j] != 0 )
+ break;
+
+ if( i < 0 && j < 0 )
+ return( 0 );
+
+ if( i > j ) return( X->s );
+ if( j > i ) return( -X->s );
+
+ if( X->s > 0 && Y->s < 0 ) return( 1 );
+ if( Y->s > 0 && X->s < 0 ) return( -1 );
+
+ for( ; i >= 0; i-- )
+ {
+ if( X->p[i] > Y->p[i] ) return( X->s );
+ if( X->p[i] < Y->p[i] ) return( -X->s );
+ }
+
+ return( 0 );
+}
+
+/*
+ * Compare signed values
+ */
+int mpi_cmp_int( mpi *X, int z )
+{
+ mpi Y;
+ t_int p[1];
+
+ *p = ( z < 0 ) ? -z : z;
+ Y.s = ( z < 0 ) ? -1 : 1;
+ Y.n = 1;
+ Y.p = p;
+
+ return( mpi_cmp_mpi( X, &Y ) );
+}
+
+/*
+ * Unsigned addition: X = |A| + |B| (HAC 14.7)
+ */
+int mpi_add_abs( mpi *X, mpi *A, mpi *B )
+{
+ int ret, i, j;
+ t_int *o, *p, c;
+
+ if( X == B )
+ {
+ mpi *T = A; A = X; B = T;
+ }
+
+ if( X != A )
+ MPI_CHK( mpi_copy( X, A ) );
+
+ for( j = B->n - 1; j >= 0; j-- )
+ if( B->p[j] != 0 )
+ break;
+
+ MPI_CHK( mpi_grow( X, j + 1 ) );
+
+ o = B->p; p = X->p; c = 0;
+
+ for( i = 0; i <= j; i++, o++, p++ )
+ {
+ *p += c; c = ( *p < c );
+ *p += *o; c += ( *p < *o );
+ }
+
+ while( c != 0 )
+ {
+ if( i >= X->n )
+ {
+ MPI_CHK( mpi_grow( X, i + 1 ) );
+ p = X->p + i;
+ }
+
+ *p += c; c = ( *p < c ); i++;
+ }
+
+cleanup:
+
+ return( ret );
+}
+
+/*
+ * Helper for mpi substraction
+ */
+static void mpi_sub_hlp( int n, t_int *s, t_int *d )
+{
+ int i;
+ t_int c, z;
+
+ for( i = c = 0; i < n; i++, s++, d++ )
+ {
+ z = ( *d < c ); *d -= c;
+ c = ( *d < *s ) + z; *d -= *s;
+ }
+
+ while( c != 0 )
+ {
+ z = ( *d < c ); *d -= c;
+ c = z; i++; d++;
+ }
+}
+
+/*
+ * Unsigned substraction: X = |A| - |B| (HAC 14.9)
+ */
+int mpi_sub_abs( mpi *X, mpi *A, mpi *B )
+{
+ mpi TB;
+ int ret, n;
+
+ if( mpi_cmp_abs( A, B ) < 0 )
+ return( POLARSSL_ERR_MPI_NEGATIVE_VALUE );
+
+ mpi_init( &TB, NULL );
+
+ if( X == B )
+ {
+ MPI_CHK( mpi_copy( &TB, B ) );
+ B = &TB;
+ }
+
+ if( X != A )
+ MPI_CHK( mpi_copy( X, A ) );
+
+ ret = 0;
+
+ for( n = B->n - 1; n >= 0; n-- )
+ if( B->p[n] != 0 )
+ break;
+
+ mpi_sub_hlp( n + 1, B->p, X->p );
+
+cleanup:
+
+ mpi_free( &TB, NULL );
+
+ return( ret );
+}
+
+/*
+ * Signed addition: X = A + B
+ */
+int mpi_add_mpi( mpi *X, mpi *A, mpi *B )
+{
+ int ret, s = A->s;
+
+ if( A->s * B->s < 0 )
+ {
+ if( mpi_cmp_abs( A, B ) >= 0 )
+ {
+ MPI_CHK( mpi_sub_abs( X, A, B ) );
+ X->s = s;
+ }
+ else
+ {
+ MPI_CHK( mpi_sub_abs( X, B, A ) );
+ X->s = -s;
+ }
+ }
+ else
+ {
+ MPI_CHK( mpi_add_abs( X, A, B ) );
+ X->s = s;
+ }
+
+cleanup:
+
+ return( ret );
+}
+
+/*
+ * Signed substraction: X = A - B
+ */
+int mpi_sub_mpi( mpi *X, mpi *A, mpi *B )
+{
+ int ret, s = A->s;
+
+ if( A->s * B->s > 0 )
+ {
+ if( mpi_cmp_abs( A, B ) >= 0 )
+ {
+ MPI_CHK( mpi_sub_abs( X, A, B ) );
+ X->s = s;
+ }
+ else
+ {
+ MPI_CHK( mpi_sub_abs( X, B, A ) );
+ X->s = -s;
+ }
+ }
+ else
+ {
+ MPI_CHK( mpi_add_abs( X, A, B ) );
+ X->s = s;
+ }
+
+cleanup:
+
+ return( ret );
+}
+
+/*
+ * Signed addition: X = A + b
+ */
+int mpi_add_int( mpi *X, mpi *A, int b )
+{
+ mpi _B;
+ t_int p[1];
+
+ p[0] = ( b < 0 ) ? -b : b;
+ _B.s = ( b < 0 ) ? -1 : 1;
+ _B.n = 1;
+ _B.p = p;
+
+ return( mpi_add_mpi( X, A, &_B ) );
+}
+
+/*
+ * Signed substraction: X = A - b
+ */
+int mpi_sub_int( mpi *X, mpi *A, int b )
+{
+ mpi _B;
+ t_int p[1];
+
+ p[0] = ( b < 0 ) ? -b : b;
+ _B.s = ( b < 0 ) ? -1 : 1;
+ _B.n = 1;
+ _B.p = p;
+
+ return( mpi_sub_mpi( X, A, &_B ) );
+}
+
+/*
+ * Helper for mpi multiplication
+ */
+static void mpi_mul_hlp( int i, t_int *s, t_int *d, t_int b )
+{
+ t_int c = 0, t = 0;
+
+#if defined(MULADDC_HUIT)
+ for( ; i >= 8; i -= 8 )
+ {
+ MULADDC_INIT
+ MULADDC_HUIT
+ MULADDC_STOP
+ }
+
+ for( ; i > 0; i-- )
+ {
+ MULADDC_INIT
+ MULADDC_CORE
+ MULADDC_STOP
+ }
+#else
+ for( ; i >= 16; i -= 16 )
+ {
+ MULADDC_INIT
+ MULADDC_CORE MULADDC_CORE
+ MULADDC_CORE MULADDC_CORE
+ MULADDC_CORE MULADDC_CORE
+ MULADDC_CORE MULADDC_CORE
+
+ MULADDC_CORE MULADDC_CORE
+ MULADDC_CORE MULADDC_CORE
+ MULADDC_CORE MULADDC_CORE
+ MULADDC_CORE MULADDC_CORE
+ MULADDC_STOP
+ }
+
+ for( ; i >= 8; i -= 8 )
+ {
+ MULADDC_INIT
+ MULADDC_CORE MULADDC_CORE
+ MULADDC_CORE MULADDC_CORE
+
+ MULADDC_CORE MULADDC_CORE
+ MULADDC_CORE MULADDC_CORE
+ MULADDC_STOP
+ }
+
+ for( ; i > 0; i-- )
+ {
+ MULADDC_INIT
+ MULADDC_CORE
+ MULADDC_STOP
+ }
+#endif
+
+ t++;
+
+ do {
+ *d += c; c = ( *d < c ); d++;
+ }
+ while( c != 0 );
+}
+
+/*
+ * Baseline multiplication: X = A * B (HAC 14.12)
+ */
+int mpi_mul_mpi( mpi *X, mpi *A, mpi *B )
+{
+ int ret, i, j;
+ mpi TA, TB;
+
+ mpi_init( &TA, &TB, NULL );
+
+ if( X == A ) { MPI_CHK( mpi_copy( &TA, A ) ); A = &TA; }
+ if( X == B ) { MPI_CHK( mpi_copy( &TB, B ) ); B = &TB; }
+
+ for( i = A->n - 1; i >= 0; i-- )
+ if( A->p[i] != 0 )
+ break;
+
+ for( j = B->n - 1; j >= 0; j-- )
+ if( B->p[j] != 0 )
+ break;
+
+ MPI_CHK( mpi_grow( X, i + j + 2 ) );
+ MPI_CHK( mpi_lset( X, 0 ) );
+
+ for( i++; j >= 0; j-- )
+ mpi_mul_hlp( i, A->p, X->p + j, B->p[j] );
+
+ X->s = A->s * B->s;
+
+cleanup:
+
+ mpi_free( &TB, &TA, NULL );
+
+ return( ret );
+}
+
+/*
+ * Baseline multiplication: X = A * b
+ */
+int mpi_mul_int( mpi *X, mpi *A, t_int b )
+{
+ mpi _B;
+ t_int p[1];
+
+ _B.s = 1;
+ _B.n = 1;
+ _B.p = p;
+ p[0] = b;
+
+ return( mpi_mul_mpi( X, A, &_B ) );
+}
+
+/*
+ * Division by mpi: A = Q * B + R (HAC 14.20)
+ */
+int mpi_div_mpi( mpi *Q, mpi *R, mpi *A, mpi *B )
+{
+ int ret, i, n, t, k;
+ mpi X, Y, Z, T1, T2;
+
+ if( mpi_cmp_int( B, 0 ) == 0 )
+ return( POLARSSL_ERR_MPI_DIVISION_BY_ZERO );
+
+ mpi_init( &X, &Y, &Z, &T1, &T2, NULL );
+
+ if( mpi_cmp_abs( A, B ) < 0 )
+ {
+ if( Q != NULL ) MPI_CHK( mpi_lset( Q, 0 ) );
+ if( R != NULL ) MPI_CHK( mpi_copy( R, A ) );
+ return( 0 );
+ }
+
+ MPI_CHK( mpi_copy( &X, A ) );
+ MPI_CHK( mpi_copy( &Y, B ) );
+ X.s = Y.s = 1;
+
+ MPI_CHK( mpi_grow( &Z, A->n + 2 ) );
+ MPI_CHK( mpi_lset( &Z, 0 ) );
+ MPI_CHK( mpi_grow( &T1, 2 ) );
+ MPI_CHK( mpi_grow( &T2, 3 ) );
+
+ k = mpi_msb( &Y ) % biL;
+ if( k < (int) biL - 1 )
+ {
+ k = biL - 1 - k;
+ MPI_CHK( mpi_shift_l( &X, k ) );
+ MPI_CHK( mpi_shift_l( &Y, k ) );
+ }
+ else k = 0;
+
+ n = X.n - 1;
+ t = Y.n - 1;
+ mpi_shift_l( &Y, biL * (n - t) );
+
+ while( mpi_cmp_mpi( &X, &Y ) >= 0 )
+ {
+ Z.p[n - t]++;
+ mpi_sub_mpi( &X, &X, &Y );
+ }
+ mpi_shift_r( &Y, biL * (n - t) );
+
+ for( i = n; i > t ; i-- )
+ {
+ if( X.p[i] >= Y.p[t] )
+ Z.p[i - t - 1] = ~0;
+ else
+ {
+#if defined(POLARSSL_HAVE_LONGLONG)
+ t_dbl r;
+
+ r = (t_dbl) X.p[i] << biL;
+ r |= (t_dbl) X.p[i - 1];
+ r /= Y.p[t];
+ if( r > ((t_dbl) 1 << biL) - 1)
+ r = ((t_dbl) 1 << biL) - 1;
+
+ Z.p[i - t - 1] = (t_int) r;
+#else
+ /*
+ * __udiv_qrnnd_c, from gmp/longlong.h
+ */
+ t_int q0, q1, r0, r1;
+ t_int d0, d1, d, m;
+
+ d = Y.p[t];
+ d0 = ( d << biH ) >> biH;
+ d1 = ( d >> biH );
+
+ q1 = X.p[i] / d1;
+ r1 = X.p[i] - d1 * q1;
+ r1 <<= biH;
+ r1 |= ( X.p[i - 1] >> biH );
+
+ m = q1 * d0;
+ if( r1 < m )
+ {
+ q1--, r1 += d;
+ while( r1 >= d && r1 < m )
+ q1--, r1 += d;
+ }
+ r1 -= m;
+
+ q0 = r1 / d1;
+ r0 = r1 - d1 * q0;
+ r0 <<= biH;
+ r0 |= ( X.p[i - 1] << biH ) >> biH;
+
+ m = q0 * d0;
+ if( r0 < m )
+ {
+ q0--, r0 += d;
+ while( r0 >= d && r0 < m )
+ q0--, r0 += d;
+ }
+ r0 -= m;
+
+ Z.p[i - t - 1] = ( q1 << biH ) | q0;
+#endif
+ }
+
+ Z.p[i - t - 1]++;
+ do
+ {
+ Z.p[i - t - 1]--;
+
+ MPI_CHK( mpi_lset( &T1, 0 ) );
+ T1.p[0] = (t < 1) ? 0 : Y.p[t - 1];
+ T1.p[1] = Y.p[t];
+ MPI_CHK( mpi_mul_int( &T1, &T1, Z.p[i - t - 1] ) );
+
+ MPI_CHK( mpi_lset( &T2, 0 ) );
+ T2.p[0] = (i < 2) ? 0 : X.p[i - 2];
+ T2.p[1] = (i < 1) ? 0 : X.p[i - 1];
+ T2.p[2] = X.p[i];
+ }
+ while( mpi_cmp_mpi( &T1, &T2 ) > 0 );
+
+ MPI_CHK( mpi_mul_int( &T1, &Y, Z.p[i - t - 1] ) );
+ MPI_CHK( mpi_shift_l( &T1, biL * (i - t - 1) ) );
+ MPI_CHK( mpi_sub_mpi( &X, &X, &T1 ) );
+
+ if( mpi_cmp_int( &X, 0 ) < 0 )
+ {
+ MPI_CHK( mpi_copy( &T1, &Y ) );
+ MPI_CHK( mpi_shift_l( &T1, biL * (i - t - 1) ) );
+ MPI_CHK( mpi_add_mpi( &X, &X, &T1 ) );
+ Z.p[i - t - 1]--;
+ }
+ }
+
+ if( Q != NULL )
+ {
+ mpi_copy( Q, &Z );
+ Q->s = A->s * B->s;
+ }
+
+ if( R != NULL )
+ {
+ mpi_shift_r( &X, k );
+ mpi_copy( R, &X );
+
+ R->s = A->s;
+ if( mpi_cmp_int( R, 0 ) == 0 )
+ R->s = 1;
+ }
+
+cleanup:
+
+ mpi_free( &X, &Y, &Z, &T1, &T2, NULL );
+
+ return( ret );
+}
+
+/*
+ * Division by int: A = Q * b + R
+ *
+ * Returns 0 if successful
+ * 1 if memory allocation failed
+ * POLARSSL_ERR_MPI_DIVISION_BY_ZERO if b == 0
+ */
+int mpi_div_int( mpi *Q, mpi *R, mpi *A, int b )
+{
+ mpi _B;
+ t_int p[1];
+
+ p[0] = ( b < 0 ) ? -b : b;
+ _B.s = ( b < 0 ) ? -1 : 1;
+ _B.n = 1;
+ _B.p = p;
+
+ return( mpi_div_mpi( Q, R, A, &_B ) );
+}
+
+/*
+ * Modulo: R = A mod B
+ */
+int mpi_mod_mpi( mpi *R, mpi *A, mpi *B )
+{
+ int ret;
+
+ MPI_CHK( mpi_div_mpi( NULL, R, A, B ) );
+
+ while( mpi_cmp_int( R, 0 ) < 0 )
+ MPI_CHK( mpi_add_mpi( R, R, B ) );
+
+ while( mpi_cmp_mpi( R, B ) >= 0 )
+ MPI_CHK( mpi_sub_mpi( R, R, B ) );
+
+cleanup:
+
+ return( ret );
+}
+
+/*
+ * Modulo: r = A mod b
+ */
+int mpi_mod_int( t_int *r, mpi *A, int b )
+{
+ int i;
+ t_int x, y, z;
+
+ if( b == 0 )
+ return( POLARSSL_ERR_MPI_DIVISION_BY_ZERO );
+
+ if( b < 0 )
+ b = -b;
+
+ /*
+ * handle trivial cases
+ */
+ if( b == 1 )
+ {
+ *r = 0;
+ return( 0 );
+ }
+
+ if( b == 2 )
+ {
+ *r = A->p[0] & 1;
+ return( 0 );
+ }
+
+ /*
+ * general case
+ */
+ for( i = A->n - 1, y = 0; i >= 0; i-- )
+ {
+ x = A->p[i];
+ y = ( y << biH ) | ( x >> biH );
+ z = y / b;
+ y -= z * b;
+
+ x <<= biH;
+ y = ( y << biH ) | ( x >> biH );
+ z = y / b;
+ y -= z * b;
+ }
+
+ *r = y;
+
+ return( 0 );
+}
+
+/*
+ * Fast Montgomery initialization (thanks to Tom St Denis)
+ */
+static void mpi_montg_init( t_int *mm, mpi *N )
+{
+ t_int x, m0 = N->p[0];
+
+ x = m0;
+ x += ( ( m0 + 2 ) & 4 ) << 1;
+ x *= ( 2 - ( m0 * x ) );
+
+ if( biL >= 16 ) x *= ( 2 - ( m0 * x ) );
+ if( biL >= 32 ) x *= ( 2 - ( m0 * x ) );
+ if( biL >= 64 ) x *= ( 2 - ( m0 * x ) );
+
+ *mm = ~x + 1;
+}
+
+/*
+ * Montgomery multiplication: A = A * B * R^-1 mod N (HAC 14.36)
+ */
+static void mpi_montmul( mpi *A, mpi *B, mpi *N, t_int mm, mpi *T )
+{
+ int i, n, m;
+ t_int u0, u1, *d;
+
+ memset( T->p, 0, T->n * ciL );
+
+ d = T->p;
+ n = N->n;
+ m = ( B->n < n ) ? B->n : n;
+
+ for( i = 0; i < n; i++ )
+ {
+ /*
+ * T = (T + u0*B + u1*N) / 2^biL
+ */
+ u0 = A->p[i];
+ u1 = ( d[0] + u0 * B->p[0] ) * mm;
+
+ mpi_mul_hlp( m, B->p, d, u0 );
+ mpi_mul_hlp( n, N->p, d, u1 );
+
+ *d++ = u0; d[n + 1] = 0;
+ }
+
+ memcpy( A->p, d, (n + 1) * ciL );
+
+ if( mpi_cmp_abs( A, N ) >= 0 )
+ mpi_sub_hlp( n, N->p, A->p );
+ else
+ /* prevent timing attacks */
+ mpi_sub_hlp( n, A->p, T->p );
+}
+
+/*
+ * Montgomery reduction: A = A * R^-1 mod N
+ */
+static void mpi_montred( mpi *A, mpi *N, t_int mm, mpi *T )
+{
+ t_int z = 1;
+ mpi U;
+
+ U.n = U.s = z;
+ U.p = &z;
+
+ mpi_montmul( A, &U, N, mm, T );
+}
+
+/*
+ * Sliding-window exponentiation: X = A^E mod N (HAC 14.85)
+ */
+int mpi_exp_mod( mpi *X, mpi *A, mpi *E, mpi *N, mpi *_RR )
+{
+ int ret, i, j, wsize, wbits;
+ int bufsize, nblimbs, nbits;
+ t_int ei, mm, state;
+ mpi RR, T, W[64];
+
+ if( mpi_cmp_int( N, 0 ) < 0 || ( N->p[0] & 1 ) == 0 )
+ return( POLARSSL_ERR_MPI_BAD_INPUT_DATA );
+
+ /*
+ * Init temps and window size
+ */
+ mpi_montg_init( &mm, N );
+ mpi_init( &RR, &T, NULL );
+ memset( W, 0, sizeof( W ) );
+
+ i = mpi_msb( E );
+
+ wsize = ( i > 671 ) ? 6 : ( i > 239 ) ? 5 :
+ ( i > 79 ) ? 4 : ( i > 23 ) ? 3 : 1;
+
+ j = N->n + 1;
+ MPI_CHK( mpi_grow( X, j ) );
+ MPI_CHK( mpi_grow( &W[1], j ) );
+ MPI_CHK( mpi_grow( &T, j * 2 ) );
+
+ /*
+ * If 1st call, pre-compute R^2 mod N
+ */
+ if( _RR == NULL || _RR->p == NULL )
+ {
+ MPI_CHK( mpi_lset( &RR, 1 ) );
+ MPI_CHK( mpi_shift_l( &RR, N->n * 2 * biL ) );
+ MPI_CHK( mpi_mod_mpi( &RR, &RR, N ) );
+
+ if( _RR != NULL )
+ memcpy( _RR, &RR, sizeof( mpi ) );
+ }
+ else
+ memcpy( &RR, _RR, sizeof( mpi ) );
+
+ /*
+ * W[1] = A * R^2 * R^-1 mod N = A * R mod N
+ */
+ if( mpi_cmp_mpi( A, N ) >= 0 )
+ mpi_mod_mpi( &W[1], A, N );
+ else mpi_copy( &W[1], A );
+
+ mpi_montmul( &W[1], &RR, N, mm, &T );
+
+ /*
+ * X = R^2 * R^-1 mod N = R mod N
+ */
+ MPI_CHK( mpi_copy( X, &RR ) );
+ mpi_montred( X, N, mm, &T );
+
+ if( wsize > 1 )
+ {
+ /*
+ * W[1 << (wsize - 1)] = W[1] ^ (wsize - 1)
+ */
+ j = 1 << (wsize - 1);
+
+ MPI_CHK( mpi_grow( &W[j], N->n + 1 ) );
+ MPI_CHK( mpi_copy( &W[j], &W[1] ) );
+
+ for( i = 0; i < wsize - 1; i++ )
+ mpi_montmul( &W[j], &W[j], N, mm, &T );
+
+ /*
+ * W[i] = W[i - 1] * W[1]
+ */
+ for( i = j + 1; i < (1 << wsize); i++ )
+ {
+ MPI_CHK( mpi_grow( &W[i], N->n + 1 ) );
+ MPI_CHK( mpi_copy( &W[i], &W[i - 1] ) );
+
+ mpi_montmul( &W[i], &W[1], N, mm, &T );
+ }
+ }
+
+ nblimbs = E->n;
+ bufsize = 0;
+ nbits = 0;
+ wbits = 0;
+ state = 0;
+
+ while( 1 )
+ {
+ if( bufsize == 0 )
+ {
+ if( nblimbs-- == 0 )
+ break;
+
+ bufsize = sizeof( t_int ) << 3;
+ }
+
+ bufsize--;
+
+ ei = (E->p[nblimbs] >> bufsize) & 1;
+
+ /*
+ * skip leading 0s
+ */
+ if( ei == 0 && state == 0 )
+ continue;
+
+ if( ei == 0 && state == 1 )
+ {
+ /*
+ * out of window, square X
+ */
+ mpi_montmul( X, X, N, mm, &T );
+ continue;
+ }
+
+ /*
+ * add ei to current window
+ */
+ state = 2;
+
+ nbits++;
+ wbits |= (ei << (wsize - nbits));
+
+ if( nbits == wsize )
+ {
+ /*
+ * X = X^wsize R^-1 mod N
+ */
+ for( i = 0; i < wsize; i++ )
+ mpi_montmul( X, X, N, mm, &T );
+
+ /*
+ * X = X * W[wbits] R^-1 mod N
+ */
+ mpi_montmul( X, &W[wbits], N, mm, &T );
+
+ state--;
+ nbits = 0;
+ wbits = 0;
+ }
+ }
+
+ /*
+ * process the remaining bits
+ */
+ for( i = 0; i < nbits; i++ )
+ {
+ mpi_montmul( X, X, N, mm, &T );
+
+ wbits <<= 1;
+
+ if( (wbits & (1 << wsize)) != 0 )
+ mpi_montmul( X, &W[1], N, mm, &T );
+ }
+
+ /*
+ * X = A^E * R * R^-1 mod N = A^E mod N
+ */
+ mpi_montred( X, N, mm, &T );
+
+cleanup:
+
+ for( i = (1 << (wsize - 1)); i < (1 << wsize); i++ )
+ mpi_free( &W[i], NULL );
+
+ if( _RR != NULL )
+ mpi_free( &W[1], &T, NULL );
+ else mpi_free( &W[1], &T, &RR, NULL );
+
+ return( ret );
+}
+
+/*
+ * Greatest common divisor: G = gcd(A, B) (HAC 14.54)
+ */
+int mpi_gcd( mpi *G, mpi *A, mpi *B )
+{
+ int ret, lz, lzt;
+ mpi TG, TA, TB;
+
+ mpi_init( &TG, &TA, &TB, NULL );
+
+ MPI_CHK( mpi_copy( &TA, A ) );
+ MPI_CHK( mpi_copy( &TB, B ) );
+
+ lz = mpi_lsb( &TA );
+ lzt = mpi_lsb( &TB );
+
+ if ( lzt < lz )
+ lz = lzt;
+
+ MPI_CHK( mpi_shift_r( &TA, lz ) );
+ MPI_CHK( mpi_shift_r( &TB, lz ) );
+
+ TA.s = TB.s = 1;
+
+ while( mpi_cmp_int( &TA, 0 ) != 0 )
+ {
+ MPI_CHK( mpi_shift_r( &TA, mpi_lsb( &TA ) ) );
+ MPI_CHK( mpi_shift_r( &TB, mpi_lsb( &TB ) ) );
+
+ if( mpi_cmp_mpi( &TA, &TB ) >= 0 )
+ {
+ MPI_CHK( mpi_sub_abs( &TA, &TA, &TB ) );
+ MPI_CHK( mpi_shift_r( &TA, 1 ) );
+ }
+ else
+ {
+ MPI_CHK( mpi_sub_abs( &TB, &TB, &TA ) );
+ MPI_CHK( mpi_shift_r( &TB, 1 ) );
+ }
+ }
+
+ MPI_CHK( mpi_shift_l( &TB, lz ) );
+ MPI_CHK( mpi_copy( G, &TB ) );
+
+cleanup:
+
+ mpi_free( &TB, &TA, &TG, NULL );
+
+ return( ret );
+}
+
+#if defined(POLARSSL_GENPRIME)
+
+/*
+ * Modular inverse: X = A^-1 mod N (HAC 14.61 / 14.64)
+ */
+int mpi_inv_mod( mpi *X, mpi *A, mpi *N )
+{
+ int ret;
+ mpi G, TA, TU, U1, U2, TB, TV, V1, V2;
+
+ if( mpi_cmp_int( N, 0 ) <= 0 )
+ return( POLARSSL_ERR_MPI_BAD_INPUT_DATA );
+
+ mpi_init( &TA, &TU, &U1, &U2, &G,
+ &TB, &TV, &V1, &V2, NULL );
+
+ MPI_CHK( mpi_gcd( &G, A, N ) );
+
+ if( mpi_cmp_int( &G, 1 ) != 0 )
+ {
+ ret = POLARSSL_ERR_MPI_NOT_ACCEPTABLE;
+ goto cleanup;
+ }
+
+ MPI_CHK( mpi_mod_mpi( &TA, A, N ) );
+ MPI_CHK( mpi_copy( &TU, &TA ) );
+ MPI_CHK( mpi_copy( &TB, N ) );
+ MPI_CHK( mpi_copy( &TV, N ) );
+
+ MPI_CHK( mpi_lset( &U1, 1 ) );
+ MPI_CHK( mpi_lset( &U2, 0 ) );
+ MPI_CHK( mpi_lset( &V1, 0 ) );
+ MPI_CHK( mpi_lset( &V2, 1 ) );
+
+ do
+ {
+ while( ( TU.p[0] & 1 ) == 0 )
+ {
+ MPI_CHK( mpi_shift_r( &TU, 1 ) );
+
+ if( ( U1.p[0] & 1 ) != 0 || ( U2.p[0] & 1 ) != 0 )
+ {
+ MPI_CHK( mpi_add_mpi( &U1, &U1, &TB ) );
+ MPI_CHK( mpi_sub_mpi( &U2, &U2, &TA ) );
+ }
+
+ MPI_CHK( mpi_shift_r( &U1, 1 ) );
+ MPI_CHK( mpi_shift_r( &U2, 1 ) );
+ }
+
+ while( ( TV.p[0] & 1 ) == 0 )
+ {
+ MPI_CHK( mpi_shift_r( &TV, 1 ) );
+
+ if( ( V1.p[0] & 1 ) != 0 || ( V2.p[0] & 1 ) != 0 )
+ {
+ MPI_CHK( mpi_add_mpi( &V1, &V1, &TB ) );
+ MPI_CHK( mpi_sub_mpi( &V2, &V2, &TA ) );
+ }
+
+ MPI_CHK( mpi_shift_r( &V1, 1 ) );
+ MPI_CHK( mpi_shift_r( &V2, 1 ) );
+ }
+
+ if( mpi_cmp_mpi( &TU, &TV ) >= 0 )
+ {
+ MPI_CHK( mpi_sub_mpi( &TU, &TU, &TV ) );
+ MPI_CHK( mpi_sub_mpi( &U1, &U1, &V1 ) );
+ MPI_CHK( mpi_sub_mpi( &U2, &U2, &V2 ) );
+ }
+ else
+ {
+ MPI_CHK( mpi_sub_mpi( &TV, &TV, &TU ) );
+ MPI_CHK( mpi_sub_mpi( &V1, &V1, &U1 ) );
+ MPI_CHK( mpi_sub_mpi( &V2, &V2, &U2 ) );
+ }
+ }
+ while( mpi_cmp_int( &TU, 0 ) != 0 );
+
+ while( mpi_cmp_int( &V1, 0 ) < 0 )
+ MPI_CHK( mpi_add_mpi( &V1, &V1, N ) );
+
+ while( mpi_cmp_mpi( &V1, N ) >= 0 )
+ MPI_CHK( mpi_sub_mpi( &V1, &V1, N ) );
+
+ MPI_CHK( mpi_copy( X, &V1 ) );
+
+cleanup:
+
+ mpi_free( &V2, &V1, &TV, &TB, &G,
+ &U2, &U1, &TU, &TA, NULL );
+
+ return( ret );
+}
+
+static const int small_prime[] =
+{
+ 3, 5, 7, 11, 13, 17, 19, 23,
+ 29, 31, 37, 41, 43, 47, 53, 59,
+ 61, 67, 71, 73, 79, 83, 89, 97,
+ 101, 103, 107, 109, 113, 127, 131, 137,
+ 139, 149, 151, 157, 163, 167, 173, 179,
+ 181, 191, 193, 197, 199, 211, 223, 227,
+ 229, 233, 239, 241, 251, 257, 263, 269,
+ 271, 277, 281, 283, 293, 307, 311, 313,
+ 317, 331, 337, 347, 349, 353, 359, 367,
+ 373, 379, 383, 389, 397, 401, 409, 419,
+ 421, 431, 433, 439, 443, 449, 457, 461,
+ 463, 467, 479, 487, 491, 499, 503, 509,
+ 521, 523, 541, 547, 557, 563, 569, 571,
+ 577, 587, 593, 599, 601, 607, 613, 617,
+ 619, 631, 641, 643, 647, 653, 659, 661,
+ 673, 677, 683, 691, 701, 709, 719, 727,
+ 733, 739, 743, 751, 757, 761, 769, 773,
+ 787, 797, 809, 811, 821, 823, 827, 829,
+ 839, 853, 857, 859, 863, 877, 881, 883,
+ 887, 907, 911, 919, 929, 937, 941, 947,
+ 953, 967, 971, 977, 983, 991, 997, -103
+};
+
+/*
+ * Miller-Rabin primality test (HAC 4.24)
+ */
+int mpi_is_prime( mpi *X, int (*f_rng)(void *), void *p_rng )
+{
+ int ret, i, j, n, s, xs;
+ mpi W, R, T, A, RR;
+ unsigned char *p;
+
+ if( mpi_cmp_int( X, 0 ) == 0 )
+ return( 0 );
+
+ mpi_init( &W, &R, &T, &A, &RR, NULL );
+
+ xs = X->s; X->s = 1;
+
+ /*
+ * test trivial factors first
+ */
+ if( ( X->p[0] & 1 ) == 0 )
+ return( POLARSSL_ERR_MPI_NOT_ACCEPTABLE );
+
+ for( i = 0; small_prime[i] > 0; i++ )
+ {
+ t_int r;
+
+ if( mpi_cmp_int( X, small_prime[i] ) <= 0 )
+ return( 0 );
+
+ MPI_CHK( mpi_mod_int( &r, X, small_prime[i] ) );
+
+ if( r == 0 )
+ return( POLARSSL_ERR_MPI_NOT_ACCEPTABLE );
+ }
+
+ /*
+ * W = |X| - 1
+ * R = W >> lsb( W )
+ */
+ s = mpi_lsb( &W );
+ MPI_CHK( mpi_sub_int( &W, X, 1 ) );
+ MPI_CHK( mpi_copy( &R, &W ) );
+ MPI_CHK( mpi_shift_r( &R, s ) );
+
+ i = mpi_msb( X );
+ /*
+ * HAC, table 4.4
+ */
+ n = ( ( i >= 1300 ) ? 2 : ( i >= 850 ) ? 3 :
+ ( i >= 650 ) ? 4 : ( i >= 350 ) ? 8 :
+ ( i >= 250 ) ? 12 : ( i >= 150 ) ? 18 : 27 );
+
+ for( i = 0; i < n; i++ )
+ {
+ /*
+ * pick a random A, 1 < A < |X| - 1
+ */
+ MPI_CHK( mpi_grow( &A, X->n ) );
+
+ p = (unsigned char *) A.p;
+ for( j = 0; j < A.n * ciL; j++ )
+ *p++ = (unsigned char) f_rng( p_rng );
+
+ j = mpi_msb( &A ) - mpi_msb( &W );
+ MPI_CHK( mpi_shift_r( &A, j + 1 ) );
+ A.p[0] |= 3;
+
+ /*
+ * A = A^R mod |X|
+ */
+ MPI_CHK( mpi_exp_mod( &A, &A, &R, X, &RR ) );
+
+ if( mpi_cmp_mpi( &A, &W ) == 0 ||
+ mpi_cmp_int( &A, 1 ) == 0 )
+ continue;
+
+ j = 1;
+ while( j < s && mpi_cmp_mpi( &A, &W ) != 0 )
+ {
+ /*
+ * A = A * A mod |X|
+ */
+ MPI_CHK( mpi_mul_mpi( &T, &A, &A ) );
+ MPI_CHK( mpi_mod_mpi( &A, &T, X ) );
+
+ if( mpi_cmp_int( &A, 1 ) == 0 )
+ break;
+
+ j++;
+ }
+
+ /*
+ * not prime if A != |X| - 1 or A == 1
+ */
+ if( mpi_cmp_mpi( &A, &W ) != 0 ||
+ mpi_cmp_int( &A, 1 ) == 0 )
+ {
+ ret = POLARSSL_ERR_MPI_NOT_ACCEPTABLE;
+ break;
+ }
+ }
+
+cleanup:
+
+ X->s = xs;
+
+ mpi_free( &RR, &A, &T, &R, &W, NULL );
+
+ return( ret );
+}
+
+/*
+ * Prime number generation
+ */
+int mpi_gen_prime( mpi *X, int nbits, int dh_flag,
+ int (*f_rng)(void *), void *p_rng )
+{
+ int ret, k, n;
+ unsigned char *p;
+ mpi Y;
+
+ if( nbits < 3 )
+ return( POLARSSL_ERR_MPI_BAD_INPUT_DATA );
+
+ mpi_init( &Y, NULL );
+
+ n = BITS_TO_LIMBS( nbits );
+
+ MPI_CHK( mpi_grow( X, n ) );
+ MPI_CHK( mpi_lset( X, 0 ) );
+
+ p = (unsigned char *) X->p;
+ for( k = 0; k < X->n * ciL; k++ )
+ *p++ = (unsigned char) f_rng( p_rng );
+
+ k = mpi_msb( X );
+ if( k < nbits ) MPI_CHK( mpi_shift_l( X, nbits - k ) );
+ if( k > nbits ) MPI_CHK( mpi_shift_r( X, k - nbits ) );
+
+ X->p[0] |= 3;
+
+ if( dh_flag == 0 )
+ {
+ while( ( ret = mpi_is_prime( X, f_rng, p_rng ) ) != 0 )
+ {
+ if( ret != POLARSSL_ERR_MPI_NOT_ACCEPTABLE )
+ goto cleanup;
+
+ MPI_CHK( mpi_add_int( X, X, 2 ) );
+ }
+ }
+ else
+ {
+ MPI_CHK( mpi_sub_int( &Y, X, 1 ) );
+ MPI_CHK( mpi_shift_r( &Y, 1 ) );
+
+ while( 1 )
+ {
+ if( ( ret = mpi_is_prime( X, f_rng, p_rng ) ) == 0 )
+ {
+ if( ( ret = mpi_is_prime( &Y, f_rng, p_rng ) ) == 0 )
+ break;
+
+ if( ret != POLARSSL_ERR_MPI_NOT_ACCEPTABLE )
+ goto cleanup;
+ }
+
+ if( ret != POLARSSL_ERR_MPI_NOT_ACCEPTABLE )
+ goto cleanup;
+
+ MPI_CHK( mpi_add_int( &Y, X, 1 ) );
+ MPI_CHK( mpi_add_int( X, X, 2 ) );
+ MPI_CHK( mpi_shift_r( &Y, 1 ) );
+ }
+ }
+
+cleanup:
+
+ mpi_free( &Y, NULL );
+
+ return( ret );
+}
+
+#endif
+
+#if defined(POLARSSL_SELF_TEST)
+
+#define GCD_PAIR_COUNT 3
+
+static const int gcd_pairs[GCD_PAIR_COUNT][3] =
+{
+ { 693, 609, 21 },
+ { 1764, 868, 28 },
+ { 768454923, 542167814, 1 }
+};
+
+/*
+ * Checkup routine
+ */
+int mpi_self_test( int verbose )
+{
+ int ret, i;
+ mpi A, E, N, X, Y, U, V;
+
+ mpi_init( &A, &E, &N, &X, &Y, &U, &V, NULL );
+
+ MPI_CHK( mpi_read_string( &A, 16,
+ "EFE021C2645FD1DC586E69184AF4A31E" \
+ "D5F53E93B5F123FA41680867BA110131" \
+ "944FE7952E2517337780CB0DB80E61AA" \
+ "E7C8DDC6C5C6AADEB34EB38A2F40D5E6" ) );
+
+ MPI_CHK( mpi_read_string( &E, 16,
+ "B2E7EFD37075B9F03FF989C7C5051C20" \
+ "34D2A323810251127E7BF8625A4F49A5" \
+ "F3E27F4DA8BD59C47D6DAABA4C8127BD" \
+ "5B5C25763222FEFCCFC38B832366C29E" ) );
+
+ MPI_CHK( mpi_read_string( &N, 16,
+ "0066A198186C18C10B2F5ED9B522752A" \
+ "9830B69916E535C8F047518A889A43A5" \
+ "94B6BED27A168D31D4A52F88925AA8F5" ) );
+
+ MPI_CHK( mpi_mul_mpi( &X, &A, &N ) );
+
+ MPI_CHK( mpi_read_string( &U, 16,
+ "602AB7ECA597A3D6B56FF9829A5E8B85" \
+ "9E857EA95A03512E2BAE7391688D264A" \
+ "A5663B0341DB9CCFD2C4C5F421FEC814" \
+ "8001B72E848A38CAE1C65F78E56ABDEF" \
+ "E12D3C039B8A02D6BE593F0BBBDA56F1" \
+ "ECF677152EF804370C1A305CAF3B5BF1" \
+ "30879B56C61DE584A0F53A2447A51E" ) );
+
+ if( verbose != 0 )
+ printf( " MPI test #1 (mul_mpi): " );
+
+ if( mpi_cmp_mpi( &X, &U ) != 0 )
+ {
+ if( verbose != 0 )
+ printf( "failed\n" );
+
+ return( 1 );
+ }
+
+ if( verbose != 0 )
+ printf( "passed\n" );
+
+ MPI_CHK( mpi_div_mpi( &X, &Y, &A, &N ) );
+
+ MPI_CHK( mpi_read_string( &U, 16,
+ "256567336059E52CAE22925474705F39A94" ) );
+
+ MPI_CHK( mpi_read_string( &V, 16,
+ "6613F26162223DF488E9CD48CC132C7A" \
+ "0AC93C701B001B092E4E5B9F73BCD27B" \
+ "9EE50D0657C77F374E903CDFA4C642" ) );
+
+ if( verbose != 0 )
+ printf( " MPI test #2 (div_mpi): " );
+
+ if( mpi_cmp_mpi( &X, &U ) != 0 ||
+ mpi_cmp_mpi( &Y, &V ) != 0 )
+ {
+ if( verbose != 0 )
+ printf( "failed\n" );
+
+ return( 1 );
+ }
+
+ if( verbose != 0 )
+ printf( "passed\n" );
+
+ MPI_CHK( mpi_exp_mod( &X, &A, &E, &N, NULL ) );
+
+ MPI_CHK( mpi_read_string( &U, 16,
+ "36E139AEA55215609D2816998ED020BB" \
+ "BD96C37890F65171D948E9BC7CBAA4D9" \
+ "325D24D6A3C12710F10A09FA08AB87" ) );
+
+ if( verbose != 0 )
+ printf( " MPI test #3 (exp_mod): " );
+
+ if( mpi_cmp_mpi( &X, &U ) != 0 )
+ {
+ if( verbose != 0 )
+ printf( "failed\n" );
+
+ return( 1 );
+ }
+
+ if( verbose != 0 )
+ printf( "passed\n" );
+
+ MPI_CHK( mpi_inv_mod( &X, &A, &N ) );
+
+ MPI_CHK( mpi_read_string( &U, 16,
+ "003A0AAEDD7E784FC07D8F9EC6E3BFD5" \
+ "C3DBA76456363A10869622EAC2DD84EC" \
+ "C5B8A74DAC4D09E03B5E0BE779F2DF61" ) );
+
+ if( verbose != 0 )
+ printf( " MPI test #4 (inv_mod): " );
+
+ if( mpi_cmp_mpi( &X, &U ) != 0 )
+ {
+ if( verbose != 0 )
+ printf( "failed\n" );
+
+ return( 1 );
+ }
+
+ if( verbose != 0 )
+ printf( "passed\n" );
+
+ if( verbose != 0 )
+ printf( " MPI test #5 (simple gcd): " );
+
+ for ( i = 0; i < GCD_PAIR_COUNT; i++)
+ {
+ MPI_CHK( mpi_lset( &X, gcd_pairs[i][0] ) );
+ MPI_CHK( mpi_lset( &Y, gcd_pairs[i][1] ) );
+
+ MPI_CHK( mpi_gcd( &A, &X, &Y ) );
+
+ if( mpi_cmp_int( &A, gcd_pairs[i][2] ) != 0 )
+ {
+ if( verbose != 0 )
+ printf( "failed at %d\n", i );
+
+ return( 1 );
+ }
+ }
+
+ if( verbose != 0 )
+ printf( "passed\n" );
+
+cleanup:
+
+ if( ret != 0 && verbose != 0 )
+ printf( "Unexpected error, return code = %08X\n", ret );
+
+ mpi_free( &V, &U, &Y, &X, &N, &E, &A, NULL );
+
+ if( verbose != 0 )
+ printf( "\n" );
+
+ return( ret );
+}
+
+#endif
+
+#endif
diff --git a/package/px5g/src/library/havege.c b/package/px5g/src/library/havege.c
new file mode 100644
index 0000000..266299d
--- /dev/null
+++ b/package/px5g/src/library/havege.c
@@ -0,0 +1,276 @@
+/*
+ * HAVEGE: HArdware Volatile Entropy Gathering and Expansion
+ *
+ * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
+ *
+ * Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the names of PolarSSL or XySSL nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+/*
+ * The HAVEGE RNG was designed by Andre Seznec in 2002.
+ *
+ * http://www.irisa.fr/caps/projects/hipsor/publi.php
+ *
+ * Contact: seznec(at)irisa_dot_fr - orocheco(at)irisa_dot_fr
+ */
+
+#include <string.h>
+#include <time.h>
+
+#include "polarssl/config.h"
+
+#if defined(POLARSSL_HAVEGE_C)
+
+#include "polarssl/havege.h"
+#include "polarssl/timing.h"
+
+/* ------------------------------------------------------------------------
+ * On average, one iteration accesses two 8-word blocks in the havege WALK
+ * table, and generates 16 words in the RES array.
+ *
+ * The data read in the WALK table is updated and permuted after each use.
+ * The result of the hardware clock counter read is used for this update.
+ *
+ * 25 conditional tests are present. The conditional tests are grouped in
+ * two nested groups of 12 conditional tests and 1 test that controls the
+ * permutation; on average, there should be 6 tests executed and 3 of them
+ * should be mispredicted.
+ * ------------------------------------------------------------------------
+ */
+
+#define SWAP(X,Y) { int *T = X; X = Y; Y = T; }
+
+#define TST1_ENTER if( PTEST & 1 ) { PTEST ^= 3; PTEST >>= 1;
+#define TST2_ENTER if( PTEST & 1 ) { PTEST ^= 3; PTEST >>= 1;
+
+#define TST1_LEAVE U1++; }
+#define TST2_LEAVE U2++; }
+
+#define ONE_ITERATION \
+ \
+ PTEST = PT1 >> 20; \
+ \
+ TST1_ENTER TST1_ENTER TST1_ENTER TST1_ENTER \
+ TST1_ENTER TST1_ENTER TST1_ENTER TST1_ENTER \
+ TST1_ENTER TST1_ENTER TST1_ENTER TST1_ENTER \
+ \
+ TST1_LEAVE TST1_LEAVE TST1_LEAVE TST1_LEAVE \
+ TST1_LEAVE TST1_LEAVE TST1_LEAVE TST1_LEAVE \
+ TST1_LEAVE TST1_LEAVE TST1_LEAVE TST1_LEAVE \
+ \
+ PTX = (PT1 >> 18) & 7; \
+ PT1 &= 0x1FFF; \
+ PT2 &= 0x1FFF; \
+ CLK = (int) hardclock(); \
+ \
+ i = 0; \
+ A = &WALK[PT1 ]; RES[i++] ^= *A; \
+ B = &WALK[PT2 ]; RES[i++] ^= *B; \
+ C = &WALK[PT1 ^ 1]; RES[i++] ^= *C; \
+ D = &WALK[PT2 ^ 4]; RES[i++] ^= *D; \
+ \
+ IN = (*A >> (1)) ^ (*A << (31)) ^ CLK; \
+ *A = (*B >> (2)) ^ (*B << (30)) ^ CLK; \
+ *B = IN ^ U1; \
+ *C = (*C >> (3)) ^ (*C << (29)) ^ CLK; \
+ *D = (*D >> (4)) ^ (*D << (28)) ^ CLK; \
+ \
+ A = &WALK[PT1 ^ 2]; RES[i++] ^= *A; \
+ B = &WALK[PT2 ^ 2]; RES[i++] ^= *B; \
+ C = &WALK[PT1 ^ 3]; RES[i++] ^= *C; \
+ D = &WALK[PT2 ^ 6]; RES[i++] ^= *D; \
+ \
+ if( PTEST & 1 ) SWAP( A, C ); \
+ \
+ IN = (*A >> (5)) ^ (*A << (27)) ^ CLK; \
+ *A = (*B >> (6)) ^ (*B << (26)) ^ CLK; \
+ *B = IN; CLK = (int) hardclock(); \
+ *C = (*C >> (7)) ^ (*C << (25)) ^ CLK; \
+ *D = (*D >> (8)) ^ (*D << (24)) ^ CLK; \
+ \
+ A = &WALK[PT1 ^ 4]; \
+ B = &WALK[PT2 ^ 1]; \
+ \
+ PTEST = PT2 >> 1; \
+ \
+ PT2 = (RES[(i - 8) ^ PTY] ^ WALK[PT2 ^ PTY ^ 7]); \
+ PT2 = ((PT2 & 0x1FFF) & (~8)) ^ ((PT1 ^ 8) & 0x8); \
+ PTY = (PT2 >> 10) & 7; \
+ \
+ TST2_ENTER TST2_ENTER TST2_ENTER TST2_ENTER \
+ TST2_ENTER TST2_ENTER TST2_ENTER TST2_ENTER \
+ TST2_ENTER TST2_ENTER TST2_ENTER TST2_ENTER \
+ \
+ TST2_LEAVE TST2_LEAVE TST2_LEAVE TST2_LEAVE \
+ TST2_LEAVE TST2_LEAVE TST2_LEAVE TST2_LEAVE \
+ TST2_LEAVE TST2_LEAVE TST2_LEAVE TST2_LEAVE \
+ \
+ C = &WALK[PT1 ^ 5]; \
+ D = &WALK[PT2 ^ 5]; \
+ \
+ RES[i++] ^= *A; \
+ RES[i++] ^= *B; \
+ RES[i++] ^= *C; \
+ RES[i++] ^= *D; \
+ \
+ IN = (*A >> ( 9)) ^ (*A << (23)) ^ CLK; \
+ *A = (*B >> (10)) ^ (*B << (22)) ^ CLK; \
+ *B = IN ^ U2; \
+ *C = (*C >> (11)) ^ (*C << (21)) ^ CLK; \
+ *D = (*D >> (12)) ^ (*D << (20)) ^ CLK; \
+ \
+ A = &WALK[PT1 ^ 6]; RES[i++] ^= *A; \
+ B = &WALK[PT2 ^ 3]; RES[i++] ^= *B; \
+ C = &WALK[PT1 ^ 7]; RES[i++] ^= *C; \
+ D = &WALK[PT2 ^ 7]; RES[i++] ^= *D; \
+ \
+ IN = (*A >> (13)) ^ (*A << (19)) ^ CLK; \
+ *A = (*B >> (14)) ^ (*B << (18)) ^ CLK; \
+ *B = IN; \
+ *C = (*C >> (15)) ^ (*C << (17)) ^ CLK; \
+ *D = (*D >> (16)) ^ (*D << (16)) ^ CLK; \
+ \
+ PT1 = ( RES[(i - 8) ^ PTX] ^ \
+ WALK[PT1 ^ PTX ^ 7] ) & (~1); \
+ PT1 ^= (PT2 ^ 0x10) & 0x10; \
+ \
+ for( n++, i = 0; i < 16; i++ ) \
+ hs->pool[n % COLLECT_SIZE] ^= RES[i];
+
+/*
+ * Entropy gathering function
+ */
+static void havege_fill( havege_state *hs )
+{
+ int i, n = 0;
+ int U1, U2, *A, *B, *C, *D;
+ int PT1, PT2, *WALK, RES[16];
+ int PTX, PTY, CLK, PTEST, IN;
+
+ WALK = hs->WALK;
+ PT1 = hs->PT1;
+ PT2 = hs->PT2;
+
+ PTX = U1 = 0;
+ PTY = U2 = 0;
+
+ memset( RES, 0, sizeof( RES ) );
+
+ while( n < COLLECT_SIZE * 4 )
+ {
+ ONE_ITERATION
+ ONE_ITERATION
+ ONE_ITERATION
+ ONE_ITERATION
+ }
+
+ hs->PT1 = PT1;
+ hs->PT2 = PT2;
+
+ hs->offset[0] = 0;
+ hs->offset[1] = COLLECT_SIZE / 2;
+}
+
+/*
+ * HAVEGE initialization
+ */
+void havege_init( havege_state *hs )
+{
+ memset( hs, 0, sizeof( havege_state ) );
+
+ havege_fill( hs );
+}
+
+/*
+ * HAVEGE rand function
+ */
+int havege_rand( void *p_rng )
+{
+ int ret;
+ havege_state *hs = (havege_state *) p_rng;
+
+ if( hs->offset[1] >= COLLECT_SIZE )
+ havege_fill( hs );
+
+ ret = hs->pool[hs->offset[0]++];
+ ret ^= hs->pool[hs->offset[1]++];
+
+ return( ret );
+}
+
+#if defined(POLARSSL_RAND_TEST)
+
+#include <stdio.h>
+
+int main( int argc, char *argv[] )
+{
+ FILE *f;
+ time_t t;
+ int i, j, k;
+ havege_state hs;
+ unsigned char buf[1024];
+
+ if( argc < 2 )
+ {
+ fprintf( stderr, "usage: %s <output filename>\n", argv[0] );
+ return( 1 );
+ }
+
+ if( ( f = fopen( argv[1], "wb+" ) ) == NULL )
+ {
+ printf( "failed to open '%s' for writing.\n", argv[0] );
+ return( 1 );
+ }
+
+ havege_init( &hs );
+
+ t = time( NULL );
+
+ for( i = 0, k = 32768; i < k; i++ )
+ {
+ for( j = 0; j < sizeof( buf ); j++ )
+ buf[j] = havege_rand( &hs );
+
+ fwrite( buf, sizeof( buf ), 1, f );
+
+ printf( "Generating 32Mb of data in file '%s'... %04.1f" \
+ "%% done\r", argv[1], (100 * (float) (i + 1)) / k );
+ fflush( stdout );
+ }
+
+ if( t == time( NULL ) )
+ t--;
+
+ fclose( f );
+ return( 0 );
+}
+
+#endif
+
+#endif
diff --git a/package/px5g/src/library/rsa.c b/package/px5g/src/library/rsa.c
new file mode 100644
index 0000000..131b6c6
--- /dev/null
+++ b/package/px5g/src/library/rsa.c
@@ -0,0 +1,750 @@
+/*
+ * The RSA public-key cryptosystem
+ *
+ * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
+ *
+ * Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the names of PolarSSL or XySSL nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+/*
+ * RSA was designed by Ron Rivest, Adi Shamir and Len Adleman.
+ *
+ * http://theory.lcs.mit.edu/~rivest/rsapaper.pdf
+ * http://www.cacr.math.uwaterloo.ca/hac/about/chap8.pdf
+ */
+
+#include "polarssl/config.h"
+
+#if defined(POLARSSL_RSA_C)
+
+#include "polarssl/rsa.h"
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+/*
+ * Initialize an RSA context
+ */
+void rsa_init( rsa_context *ctx,
+ int padding,
+ int hash_id,
+ int (*f_rng)(void *),
+ void *p_rng )
+{
+ memset( ctx, 0, sizeof( rsa_context ) );
+
+ ctx->padding = padding;
+ ctx->hash_id = hash_id;
+
+ ctx->f_rng = f_rng;
+ ctx->p_rng = p_rng;
+}
+
+#if defined(POLARSSL_GENPRIME)
+
+/*
+ * Generate an RSA keypair
+ */
+int rsa_gen_key( rsa_context *ctx, int nbits, int exponent )
+{
+ int ret;
+ mpi P1, Q1, H, G;
+
+ if( ctx->f_rng == NULL || nbits < 128 || exponent < 3 )
+ return( POLARSSL_ERR_RSA_BAD_INPUT_DATA );
+
+ mpi_init( &P1, &Q1, &H, &G, NULL );
+
+ /*
+ * find primes P and Q with Q < P so that:
+ * GCD( E, (P-1)*(Q-1) ) == 1
+ */
+ MPI_CHK( mpi_lset( &ctx->E, exponent ) );
+
+ do
+ {
+ MPI_CHK( mpi_gen_prime( &ctx->P, ( nbits + 1 ) >> 1, 0,
+ ctx->f_rng, ctx->p_rng ) );
+
+ MPI_CHK( mpi_gen_prime( &ctx->Q, ( nbits + 1 ) >> 1, 0,
+ ctx->f_rng, ctx->p_rng ) );
+
+ if( mpi_cmp_mpi( &ctx->P, &ctx->Q ) < 0 )
+ mpi_swap( &ctx->P, &ctx->Q );
+
+ if( mpi_cmp_mpi( &ctx->P, &ctx->Q ) == 0 )
+ continue;
+
+ MPI_CHK( mpi_mul_mpi( &ctx->N, &ctx->P, &ctx->Q ) );
+ if( mpi_msb( &ctx->N ) != nbits )
+ continue;
+
+ MPI_CHK( mpi_sub_int( &P1, &ctx->P, 1 ) );
+ MPI_CHK( mpi_sub_int( &Q1, &ctx->Q, 1 ) );
+ MPI_CHK( mpi_mul_mpi( &H, &P1, &Q1 ) );
+ MPI_CHK( mpi_gcd( &G, &ctx->E, &H ) );
+ }
+ while( mpi_cmp_int( &G, 1 ) != 0 );
+
+ /*
+ * D = E^-1 mod ((P-1)*(Q-1))
+ * DP = D mod (P - 1)
+ * DQ = D mod (Q - 1)
+ * QP = Q^-1 mod P
+ */
+ MPI_CHK( mpi_inv_mod( &ctx->D , &ctx->E, &H ) );
+ MPI_CHK( mpi_mod_mpi( &ctx->DP, &ctx->D, &P1 ) );
+ MPI_CHK( mpi_mod_mpi( &ctx->DQ, &ctx->D, &Q1 ) );
+ MPI_CHK( mpi_inv_mod( &ctx->QP, &ctx->Q, &ctx->P ) );
+
+ ctx->len = ( mpi_msb( &ctx->N ) + 7 ) >> 3;
+
+cleanup:
+
+ mpi_free( &G, &H, &Q1, &P1, NULL );
+
+ if( ret != 0 )
+ {
+ rsa_free( ctx );
+ return( POLARSSL_ERR_RSA_KEY_GEN_FAILED | ret );
+ }
+
+ return( 0 );
+}
+
+#endif
+
+/*
+ * Check a public RSA key
+ */
+int rsa_check_pubkey( rsa_context *ctx )
+{
+ if( ( ctx->N.p[0] & 1 ) == 0 ||
+ ( ctx->E.p[0] & 1 ) == 0 )
+ return( POLARSSL_ERR_RSA_KEY_CHECK_FAILED );
+
+ if( mpi_msb( &ctx->N ) < 128 ||
+ mpi_msb( &ctx->N ) > 4096 )
+ return( POLARSSL_ERR_RSA_KEY_CHECK_FAILED );
+
+ if( mpi_msb( &ctx->E ) < 2 ||
+ mpi_msb( &ctx->E ) > 64 )
+ return( POLARSSL_ERR_RSA_KEY_CHECK_FAILED );
+
+ return( 0 );
+}
+
+/*
+ * Check a private RSA key
+ */
+int rsa_check_privkey( rsa_context *ctx )
+{
+ int ret;
+ mpi PQ, DE, P1, Q1, H, I, G;
+
+ if( ( ret = rsa_check_pubkey( ctx ) ) != 0 )
+ return( ret );
+
+ mpi_init( &PQ, &DE, &P1, &Q1, &H, &I, &G, NULL );
+
+ MPI_CHK( mpi_mul_mpi( &PQ, &ctx->P, &ctx->Q ) );
+ MPI_CHK( mpi_mul_mpi( &DE, &ctx->D, &ctx->E ) );
+ MPI_CHK( mpi_sub_int( &P1, &ctx->P, 1 ) );
+ MPI_CHK( mpi_sub_int( &Q1, &ctx->Q, 1 ) );
+ MPI_CHK( mpi_mul_mpi( &H, &P1, &Q1 ) );
+ MPI_CHK( mpi_mod_mpi( &I, &DE, &H ) );
+ MPI_CHK( mpi_gcd( &G, &ctx->E, &H ) );
+
+ if( mpi_cmp_mpi( &PQ, &ctx->N ) == 0 &&
+ mpi_cmp_int( &I, 1 ) == 0 &&
+ mpi_cmp_int( &G, 1 ) == 0 )
+ {
+ mpi_free( &G, &I, &H, &Q1, &P1, &DE, &PQ, NULL );
+ return( 0 );
+ }
+
+cleanup:
+
+ mpi_free( &G, &I, &H, &Q1, &P1, &DE, &PQ, NULL );
+ return( POLARSSL_ERR_RSA_KEY_CHECK_FAILED | ret );
+}
+
+/*
+ * Do an RSA public key operation
+ */
+int rsa_public( rsa_context *ctx,
+ unsigned char *input,
+ unsigned char *output )
+{
+ int ret, olen;
+ mpi T;
+
+ mpi_init( &T, NULL );
+
+ MPI_CHK( mpi_read_binary( &T, input, ctx->len ) );
+
+ if( mpi_cmp_mpi( &T, &ctx->N ) >= 0 )
+ {
+ mpi_free( &T, NULL );
+ return( POLARSSL_ERR_RSA_BAD_INPUT_DATA );
+ }
+
+ olen = ctx->len;
+ MPI_CHK( mpi_exp_mod( &T, &T, &ctx->E, &ctx->N, &ctx->RN ) );
+ MPI_CHK( mpi_write_binary( &T, output, olen ) );
+
+cleanup:
+
+ mpi_free( &T, NULL );
+
+ if( ret != 0 )
+ return( POLARSSL_ERR_RSA_PUBLIC_FAILED | ret );
+
+ return( 0 );
+}
+
+/*
+ * Do an RSA private key operation
+ */
+int rsa_private( rsa_context *ctx,
+ unsigned char *input,
+ unsigned char *output )
+{
+ int ret, olen;
+ mpi T, T1, T2;
+
+ mpi_init( &T, &T1, &T2, NULL );
+
+ MPI_CHK( mpi_read_binary( &T, input, ctx->len ) );
+
+ if( mpi_cmp_mpi( &T, &ctx->N ) >= 0 )
+ {
+ mpi_free( &T, NULL );
+ return( POLARSSL_ERR_RSA_BAD_INPUT_DATA );
+ }
+
+#if 0
+ MPI_CHK( mpi_exp_mod( &T, &T, &ctx->D, &ctx->N, &ctx->RN ) );
+#else
+ /*
+ * faster decryption using the CRT
+ *
+ * T1 = input ^ dP mod P
+ * T2 = input ^ dQ mod Q
+ */
+ MPI_CHK( mpi_exp_mod( &T1, &T, &ctx->DP, &ctx->P, &ctx->RP ) );
+ MPI_CHK( mpi_exp_mod( &T2, &T, &ctx->DQ, &ctx->Q, &ctx->RQ ) );
+
+ /*
+ * T = (T1 - T2) * (Q^-1 mod P) mod P
+ */
+ MPI_CHK( mpi_sub_mpi( &T, &T1, &T2 ) );
+ MPI_CHK( mpi_mul_mpi( &T1, &T, &ctx->QP ) );
+ MPI_CHK( mpi_mod_mpi( &T, &T1, &ctx->P ) );
+
+ /*
+ * output = T2 + T * Q
+ */
+ MPI_CHK( mpi_mul_mpi( &T1, &T, &ctx->Q ) );
+ MPI_CHK( mpi_add_mpi( &T, &T2, &T1 ) );
+#endif
+
+ olen = ctx->len;
+ MPI_CHK( mpi_write_binary( &T, output, olen ) );
+
+cleanup:
+
+ mpi_free( &T, &T1, &T2, NULL );
+
+ if( ret != 0 )
+ return( POLARSSL_ERR_RSA_PRIVATE_FAILED | ret );
+
+ return( 0 );
+}
+
+/*
+ * Add the message padding, then do an RSA operation
+ */
+int rsa_pkcs1_encrypt( rsa_context *ctx,
+ int mode, int ilen,
+ unsigned char *input,
+ unsigned char *output )
+{
+ int nb_pad, olen;
+ unsigned char *p = output;
+
+ olen = ctx->len;
+
+ switch( ctx->padding )
+ {
+ case RSA_PKCS_V15:
+
+ if( ilen < 0 || olen < ilen + 11 )
+ return( POLARSSL_ERR_RSA_BAD_INPUT_DATA );
+
+ nb_pad = olen - 3 - ilen;
+
+ *p++ = 0;
+ *p++ = RSA_CRYPT;
+
+ while( nb_pad-- > 0 )
+ {
+ do {
+ *p = (unsigned char) rand();
+ } while( *p == 0 );
+ p++;
+ }
+ *p++ = 0;
+ memcpy( p, input, ilen );
+ break;
+
+ default:
+
+ return( POLARSSL_ERR_RSA_INVALID_PADDING );
+ }
+
+ return( ( mode == RSA_PUBLIC )
+ ? rsa_public( ctx, output, output )
+ : rsa_private( ctx, output, output ) );
+}
+
+/*
+ * Do an RSA operation, then remove the message padding
+ */
+int rsa_pkcs1_decrypt( rsa_context *ctx,
+ int mode, int *olen,
+ unsigned char *input,
+ unsigned char *output,
+ int output_max_len)
+{
+ int ret, ilen;
+ unsigned char *p;
+ unsigned char buf[512];
+
+ ilen = ctx->len;
+
+ if( ilen < 16 || ilen > (int) sizeof( buf ) )
+ return( POLARSSL_ERR_RSA_BAD_INPUT_DATA );
+
+ ret = ( mode == RSA_PUBLIC )
+ ? rsa_public( ctx, input, buf )
+ : rsa_private( ctx, input, buf );
+
+ if( ret != 0 )
+ return( ret );
+
+ p = buf;
+
+ switch( ctx->padding )
+ {
+ case RSA_PKCS_V15:
+
+ if( *p++ != 0 || *p++ != RSA_CRYPT )
+ return( POLARSSL_ERR_RSA_INVALID_PADDING );
+
+ while( *p != 0 )
+ {
+ if( p >= buf + ilen - 1 )
+ return( POLARSSL_ERR_RSA_INVALID_PADDING );
+ p++;
+ }
+ p++;
+ break;
+
+ default:
+
+ return( POLARSSL_ERR_RSA_INVALID_PADDING );
+ }
+
+ if (ilen - (int)(p - buf) > output_max_len)
+ return( POLARSSL_ERR_RSA_OUTPUT_TO_LARGE );
+
+ *olen = ilen - (int)(p - buf);
+ memcpy( output, p, *olen );
+
+ return( 0 );
+}
+
+/*
+ * Do an RSA operation to sign the message digest
+ */
+int rsa_pkcs1_sign( rsa_context *ctx,
+ int mode,
+ int hash_id,
+ int hashlen,
+ unsigned char *hash,
+ unsigned char *sig )
+{
+ int nb_pad, olen;
+ unsigned char *p = sig;
+
+ olen = ctx->len;
+
+ switch( ctx->padding )
+ {
+ case RSA_PKCS_V15:
+
+ switch( hash_id )
+ {
+ case RSA_RAW:
+ nb_pad = olen - 3 - hashlen;
+ break;
+
+ case RSA_MD2:
+ case RSA_MD4:
+ case RSA_MD5:
+ nb_pad = olen - 3 - 34;
+ break;
+
+ case RSA_SHA1:
+ nb_pad = olen - 3 - 35;
+ break;
+
+ default:
+ return( POLARSSL_ERR_RSA_BAD_INPUT_DATA );
+ }
+
+ if( nb_pad < 8 )
+ return( POLARSSL_ERR_RSA_BAD_INPUT_DATA );
+
+ *p++ = 0;
+ *p++ = RSA_SIGN;
+ memset( p, 0xFF, nb_pad );
+ p += nb_pad;
+ *p++ = 0;
+ break;
+
+ default:
+
+ return( POLARSSL_ERR_RSA_INVALID_PADDING );
+ }
+
+ switch( hash_id )
+ {
+ case RSA_RAW:
+ memcpy( p, hash, hashlen );
+ break;
+
+ case RSA_MD2:
+ memcpy( p, ASN1_HASH_MDX, 18 );
+ memcpy( p + 18, hash, 16 );
+ p[13] = 2; break;
+
+ case RSA_MD4:
+ memcpy( p, ASN1_HASH_MDX, 18 );
+ memcpy( p + 18, hash, 16 );
+ p[13] = 4; break;
+
+ case RSA_MD5:
+ memcpy( p, ASN1_HASH_MDX, 18 );
+ memcpy( p + 18, hash, 16 );
+ p[13] = 5; break;
+
+ case RSA_SHA1:
+ memcpy( p, ASN1_HASH_SHA1, 15 );
+ memcpy( p + 15, hash, 20 );
+ break;
+
+ default:
+ return( POLARSSL_ERR_RSA_BAD_INPUT_DATA );
+ }
+
+ return( ( mode == RSA_PUBLIC )
+ ? rsa_public( ctx, sig, sig )
+ : rsa_private( ctx, sig, sig ) );
+}
+
+/*
+ * Do an RSA operation and check the message digest
+ */
+int rsa_pkcs1_verify( rsa_context *ctx,
+ int mode,
+ int hash_id,
+ int hashlen,
+ unsigned char *hash,
+ unsigned char *sig )
+{
+ int ret, len, siglen;
+ unsigned char *p, c;
+ unsigned char buf[512];
+
+ siglen = ctx->len;
+
+ if( siglen < 16 || siglen > (int) sizeof( buf ) )
+ return( POLARSSL_ERR_RSA_BAD_INPUT_DATA );
+
+ ret = ( mode == RSA_PUBLIC )
+ ? rsa_public( ctx, sig, buf )
+ : rsa_private( ctx, sig, buf );
+
+ if( ret != 0 )
+ return( ret );
+
+ p = buf;
+
+ switch( ctx->padding )
+ {
+ case RSA_PKCS_V15:
+
+ if( *p++ != 0 || *p++ != RSA_SIGN )
+ return( POLARSSL_ERR_RSA_INVALID_PADDING );
+
+ while( *p != 0 )
+ {
+ if( p >= buf + siglen - 1 || *p != 0xFF )
+ return( POLARSSL_ERR_RSA_INVALID_PADDING );
+ p++;
+ }
+ p++;
+ break;
+
+ default:
+
+ return( POLARSSL_ERR_RSA_INVALID_PADDING );
+ }
+
+ len = siglen - (int)( p - buf );
+
+ if( len == 34 )
+ {
+ c = p[13];
+ p[13] = 0;
+
+ if( memcmp( p, ASN1_HASH_MDX, 18 ) != 0 )
+ return( POLARSSL_ERR_RSA_VERIFY_FAILED );
+
+ if( ( c == 2 && hash_id == RSA_MD2 ) ||
+ ( c == 4 && hash_id == RSA_MD4 ) ||
+ ( c == 5 && hash_id == RSA_MD5 ) )
+ {
+ if( memcmp( p + 18, hash, 16 ) == 0 )
+ return( 0 );
+ else
+ return( POLARSSL_ERR_RSA_VERIFY_FAILED );
+ }
+ }
+
+ if( len == 35 && hash_id == RSA_SHA1 )
+ {
+ if( memcmp( p, ASN1_HASH_SHA1, 15 ) == 0 &&
+ memcmp( p + 15, hash, 20 ) == 0 )
+ return( 0 );
+ else
+ return( POLARSSL_ERR_RSA_VERIFY_FAILED );
+ }
+
+ if( len == hashlen && hash_id == RSA_RAW )
+ {
+ if( memcmp( p, hash, hashlen ) == 0 )
+ return( 0 );
+ else
+ return( POLARSSL_ERR_RSA_VERIFY_FAILED );
+ }
+
+ return( POLARSSL_ERR_RSA_INVALID_PADDING );
+}
+
+/*
+ * Free the components of an RSA key
+ */
+void rsa_free( rsa_context *ctx )
+{
+ mpi_free( &ctx->RQ, &ctx->RP, &ctx->RN,
+ &ctx->QP, &ctx->DQ, &ctx->DP,
+ &ctx->Q, &ctx->P, &ctx->D,
+ &ctx->E, &ctx->N, NULL );
+}
+
+#if defined(POLARSSL_SELF_TEST)
+
+#include "polarssl/sha1.h"
+
+/*
+ * Example RSA-1024 keypair, for test purposes
+ */
+#define KEY_LEN 128
+
+#define RSA_N "9292758453063D803DD603D5E777D788" \
+ "8ED1D5BF35786190FA2F23EBC0848AEA" \
+ "DDA92CA6C3D80B32C4D109BE0F36D6AE" \
+ "7130B9CED7ACDF54CFC7555AC14EEBAB" \
+ "93A89813FBF3C4F8066D2D800F7C38A8" \
+ "1AE31942917403FF4946B0A83D3D3E05" \
+ "EE57C6F5F5606FB5D4BC6CD34EE0801A" \
+ "5E94BB77B07507233A0BC7BAC8F90F79"
+
+#define RSA_E "10001"
+
+#define RSA_D "24BF6185468786FDD303083D25E64EFC" \
+ "66CA472BC44D253102F8B4A9D3BFA750" \
+ "91386C0077937FE33FA3252D28855837" \
+ "AE1B484A8A9A45F7EE8C0C634F99E8CD" \
+ "DF79C5CE07EE72C7F123142198164234" \
+ "CABB724CF78B8173B9F880FC86322407" \
+ "AF1FEDFDDE2BEB674CA15F3E81A1521E" \
+ "071513A1E85B5DFA031F21ECAE91A34D"
+
+#define RSA_P "C36D0EB7FCD285223CFB5AABA5BDA3D8" \
+ "2C01CAD19EA484A87EA4377637E75500" \
+ "FCB2005C5C7DD6EC4AC023CDA285D796" \
+ "C3D9E75E1EFC42488BB4F1D13AC30A57"
+
+#define RSA_Q "C000DF51A7C77AE8D7C7370C1FF55B69" \
+ "E211C2B9E5DB1ED0BF61D0D9899620F4" \
+ "910E4168387E3C30AA1E00C339A79508" \
+ "8452DD96A9A5EA5D9DCA68DA636032AF"
+
+#define RSA_DP "C1ACF567564274FB07A0BBAD5D26E298" \
+ "3C94D22288ACD763FD8E5600ED4A702D" \
+ "F84198A5F06C2E72236AE490C93F07F8" \
+ "3CC559CD27BC2D1CA488811730BB5725"
+
+#define RSA_DQ "4959CBF6F8FEF750AEE6977C155579C7" \
+ "D8AAEA56749EA28623272E4F7D0592AF" \
+ "7C1F1313CAC9471B5C523BFE592F517B" \
+ "407A1BD76C164B93DA2D32A383E58357"
+
+#define RSA_QP "9AE7FBC99546432DF71896FC239EADAE" \
+ "F38D18D2B2F0E2DD275AA977E2BF4411" \
+ "F5A3B2A5D33605AEBBCCBA7FEB9F2D2F" \
+ "A74206CEC169D74BF5A8C50D6F48EA08"
+
+#define PT_LEN 24
+#define RSA_PT "\xAA\xBB\xCC\x03\x02\x01\x00\xFF\xFF\xFF\xFF\xFF" \
+ "\x11\x22\x33\x0A\x0B\x0C\xCC\xDD\xDD\xDD\xDD\xDD"
+
+/*
+ * Checkup routine
+ */
+int rsa_self_test( int verbose )
+{
+ int len;
+ rsa_context rsa;
+ unsigned char sha1sum[20];
+ unsigned char rsa_plaintext[PT_LEN];
+ unsigned char rsa_decrypted[PT_LEN];
+ unsigned char rsa_ciphertext[KEY_LEN];
+
+ memset( &rsa, 0, sizeof( rsa_context ) );
+
+ rsa.len = KEY_LEN;
+ mpi_read_string( &rsa.N , 16, RSA_N );
+ mpi_read_string( &rsa.E , 16, RSA_E );
+ mpi_read_string( &rsa.D , 16, RSA_D );
+ mpi_read_string( &rsa.P , 16, RSA_P );
+ mpi_read_string( &rsa.Q , 16, RSA_Q );
+ mpi_read_string( &rsa.DP, 16, RSA_DP );
+ mpi_read_string( &rsa.DQ, 16, RSA_DQ );
+ mpi_read_string( &rsa.QP, 16, RSA_QP );
+
+ if( verbose != 0 )
+ printf( " RSA key validation: " );
+
+ if( rsa_check_pubkey( &rsa ) != 0 ||
+ rsa_check_privkey( &rsa ) != 0 )
+ {
+ if( verbose != 0 )
+ printf( "failed\n" );
+
+ return( 1 );
+ }
+
+ if( verbose != 0 )
+ printf( "passed\n PKCS#1 encryption : " );
+
+ memcpy( rsa_plaintext, RSA_PT, PT_LEN );
+
+ if( rsa_pkcs1_encrypt( &rsa, RSA_PUBLIC, PT_LEN,
+ rsa_plaintext, rsa_ciphertext ) != 0 )
+ {
+ if( verbose != 0 )
+ printf( "failed\n" );
+
+ return( 1 );
+ }
+
+ if( verbose != 0 )
+ printf( "passed\n PKCS#1 decryption : " );
+
+ if( rsa_pkcs1_decrypt( &rsa, RSA_PRIVATE, &len,
+ rsa_ciphertext, rsa_decrypted,
+ sizeof(rsa_decrypted) ) != 0 )
+ {
+ if( verbose != 0 )
+ printf( "failed\n" );
+
+ return( 1 );
+ }
+
+ if( memcmp( rsa_decrypted, rsa_plaintext, len ) != 0 )
+ {
+ if( verbose != 0 )
+ printf( "failed\n" );
+
+ return( 1 );
+ }
+
+ if( verbose != 0 )
+ printf( "passed\n PKCS#1 data sign : " );
+
+ sha1( rsa_plaintext, PT_LEN, sha1sum );
+
+ if( rsa_pkcs1_sign( &rsa, RSA_PRIVATE, RSA_SHA1, 20,
+ sha1sum, rsa_ciphertext ) != 0 )
+ {
+ if( verbose != 0 )
+ printf( "failed\n" );
+
+ return( 1 );
+ }
+
+ if( verbose != 0 )
+ printf( "passed\n PKCS#1 sig. verify: " );
+
+ if( rsa_pkcs1_verify( &rsa, RSA_PUBLIC, RSA_SHA1, 20,
+ sha1sum, rsa_ciphertext ) != 0 )
+ {
+ if( verbose != 0 )
+ printf( "failed\n" );
+
+ return( 1 );
+ }
+
+ if( verbose != 0 )
+ printf( "passed\n\n" );
+
+ rsa_free( &rsa );
+
+ return( 0 );
+}
+
+#endif
+
+#endif
diff --git a/package/px5g/src/library/sha1.c b/package/px5g/src/library/sha1.c
new file mode 100644
index 0000000..54a4416
--- /dev/null
+++ b/package/px5g/src/library/sha1.c
@@ -0,0 +1,622 @@
+/*
+ * FIPS-180-1 compliant SHA-1 implementation
+ *
+ * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
+ *
+ * Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the names of PolarSSL or XySSL nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+/*
+ * The SHA-1 standard was published by NIST in 1993.
+ *
+ * http://www.itl.nist.gov/fipspubs/fip180-1.htm
+ */
+
+#include "polarssl/config.h"
+
+#if defined(POLARSSL_SHA1_C)
+
+#include "polarssl/sha1.h"
+
+#include <string.h>
+#include <stdio.h>
+
+/*
+ * 32-bit integer manipulation macros (big endian)
+ */
+#ifndef GET_ULONG_BE
+#define GET_ULONG_BE(n,b,i) \
+{ \
+ (n) = ( (unsigned long) (b)[(i) ] << 24 ) \
+ | ( (unsigned long) (b)[(i) + 1] << 16 ) \
+ | ( (unsigned long) (b)[(i) + 2] << 8 ) \
+ | ( (unsigned long) (b)[(i) + 3] ); \
+}
+#endif
+
+#ifndef PUT_ULONG_BE
+#define PUT_ULONG_BE(n,b,i) \
+{ \
+ (b)[(i) ] = (unsigned char) ( (n) >> 24 ); \
+ (b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \
+ (b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \
+ (b)[(i) + 3] = (unsigned char) ( (n) ); \
+}
+#endif
+
+/*
+ * SHA-1 context setup
+ */
+void sha1_starts( sha1_context *ctx )
+{
+ ctx->total[0] = 0;
+ ctx->total[1] = 0;
+
+ ctx->state[0] = 0x67452301;
+ ctx->state[1] = 0xEFCDAB89;
+ ctx->state[2] = 0x98BADCFE;
+ ctx->state[3] = 0x10325476;
+ ctx->state[4] = 0xC3D2E1F0;
+}
+
+static void sha1_process( sha1_context *ctx, unsigned char data[64] )
+{
+ unsigned long temp, W[16], A, B, C, D, E;
+
+ GET_ULONG_BE( W[ 0], data, 0 );
+ GET_ULONG_BE( W[ 1], data, 4 );
+ GET_ULONG_BE( W[ 2], data, 8 );
+ GET_ULONG_BE( W[ 3], data, 12 );
+ GET_ULONG_BE( W[ 4], data, 16 );
+ GET_ULONG_BE( W[ 5], data, 20 );
+ GET_ULONG_BE( W[ 6], data, 24 );
+ GET_ULONG_BE( W[ 7], data, 28 );
+ GET_ULONG_BE( W[ 8], data, 32 );
+ GET_ULONG_BE( W[ 9], data, 36 );
+ GET_ULONG_BE( W[10], data, 40 );
+ GET_ULONG_BE( W[11], data, 44 );
+ GET_ULONG_BE( W[12], data, 48 );
+ GET_ULONG_BE( W[13], data, 52 );
+ GET_ULONG_BE( W[14], data, 56 );
+ GET_ULONG_BE( W[15], data, 60 );
+
+#define S(x,n) ((x << n) | ((x & 0xFFFFFFFF) >> (32 - n)))
+
+#define R(t) \
+( \
+ temp = W[(t - 3) & 0x0F] ^ W[(t - 8) & 0x0F] ^ \
+ W[(t - 14) & 0x0F] ^ W[ t & 0x0F], \
+ ( W[t & 0x0F] = S(temp,1) ) \
+)
+
+#define P(a,b,c,d,e,x) \
+{ \
+ e += S(a,5) + F(b,c,d) + K + x; b = S(b,30); \
+}
+
+ A = ctx->state[0];
+ B = ctx->state[1];
+ C = ctx->state[2];
+ D = ctx->state[3];
+ E = ctx->state[4];
+
+#define F(x,y,z) (z ^ (x & (y ^ z)))
+#define K 0x5A827999
+
+ P( A, B, C, D, E, W[0] );
+ P( E, A, B, C, D, W[1] );
+ P( D, E, A, B, C, W[2] );
+ P( C, D, E, A, B, W[3] );
+ P( B, C, D, E, A, W[4] );
+ P( A, B, C, D, E, W[5] );
+ P( E, A, B, C, D, W[6] );
+ P( D, E, A, B, C, W[7] );
+ P( C, D, E, A, B, W[8] );
+ P( B, C, D, E, A, W[9] );
+ P( A, B, C, D, E, W[10] );
+ P( E, A, B, C, D, W[11] );
+ P( D, E, A, B, C, W[12] );
+ P( C, D, E, A, B, W[13] );
+ P( B, C, D, E, A, W[14] );
+ P( A, B, C, D, E, W[15] );
+ P( E, A, B, C, D, R(16) );
+ P( D, E, A, B, C, R(17) );
+ P( C, D, E, A, B, R(18) );
+ P( B, C, D, E, A, R(19) );
+
+#undef K
+#undef F
+
+#define F(x,y,z) (x ^ y ^ z)
+#define K 0x6ED9EBA1
+
+ P( A, B, C, D, E, R(20) );
+ P( E, A, B, C, D, R(21) );
+ P( D, E, A, B, C, R(22) );
+ P( C, D, E, A, B, R(23) );
+ P( B, C, D, E, A, R(24) );
+ P( A, B, C, D, E, R(25) );
+ P( E, A, B, C, D, R(26) );
+ P( D, E, A, B, C, R(27) );
+ P( C, D, E, A, B, R(28) );
+ P( B, C, D, E, A, R(29) );
+ P( A, B, C, D, E, R(30) );
+ P( E, A, B, C, D, R(31) );
+ P( D, E, A, B, C, R(32) );
+ P( C, D, E, A, B, R(33) );
+ P( B, C, D, E, A, R(34) );
+ P( A, B, C, D, E, R(35) );
+ P( E, A, B, C, D, R(36) );
+ P( D, E, A, B, C, R(37) );
+ P( C, D, E, A, B, R(38) );
+ P( B, C, D, E, A, R(39) );
+
+#undef K
+#undef F
+
+#define F(x,y,z) ((x & y) | (z & (x | y)))
+#define K 0x8F1BBCDC
+
+ P( A, B, C, D, E, R(40) );
+ P( E, A, B, C, D, R(41) );
+ P( D, E, A, B, C, R(42) );
+ P( C, D, E, A, B, R(43) );
+ P( B, C, D, E, A, R(44) );
+ P( A, B, C, D, E, R(45) );
+ P( E, A, B, C, D, R(46) );
+ P( D, E, A, B, C, R(47) );
+ P( C, D, E, A, B, R(48) );
+ P( B, C, D, E, A, R(49) );
+ P( A, B, C, D, E, R(50) );
+ P( E, A, B, C, D, R(51) );
+ P( D, E, A, B, C, R(52) );
+ P( C, D, E, A, B, R(53) );
+ P( B, C, D, E, A, R(54) );
+ P( A, B, C, D, E, R(55) );
+ P( E, A, B, C, D, R(56) );
+ P( D, E, A, B, C, R(57) );
+ P( C, D, E, A, B, R(58) );
+ P( B, C, D, E, A, R(59) );
+
+#undef K
+#undef F
+
+#define F(x,y,z) (x ^ y ^ z)
+#define K 0xCA62C1D6
+
+ P( A, B, C, D, E, R(60) );
+ P( E, A, B, C, D, R(61) );
+ P( D, E, A, B, C, R(62) );
+ P( C, D, E, A, B, R(63) );
+ P( B, C, D, E, A, R(64) );
+ P( A, B, C, D, E, R(65) );
+ P( E, A, B, C, D, R(66) );
+ P( D, E, A, B, C, R(67) );
+ P( C, D, E, A, B, R(68) );
+ P( B, C, D, E, A, R(69) );
+ P( A, B, C, D, E, R(70) );
+ P( E, A, B, C, D, R(71) );
+ P( D, E, A, B, C, R(72) );
+ P( C, D, E, A, B, R(73) );
+ P( B, C, D, E, A, R(74) );
+ P( A, B, C, D, E, R(75) );
+ P( E, A, B, C, D, R(76) );
+ P( D, E, A, B, C, R(77) );
+ P( C, D, E, A, B, R(78) );
+ P( B, C, D, E, A, R(79) );
+
+#undef K
+#undef F
+
+ ctx->state[0] += A;
+ ctx->state[1] += B;
+ ctx->state[2] += C;
+ ctx->state[3] += D;
+ ctx->state[4] += E;
+}
+
+/*
+ * SHA-1 process buffer
+ */
+void sha1_update( sha1_context *ctx, unsigned char *input, int ilen )
+{
+ int fill;
+ unsigned long left;
+
+ if( ilen <= 0 )
+ return;
+
+ left = ctx->total[0] & 0x3F;
+ fill = 64 - left;
+
+ ctx->total[0] += ilen;
+ ctx->total[0] &= 0xFFFFFFFF;
+
+ if( ctx->total[0] < (unsigned long) ilen )
+ ctx->total[1]++;
+
+ if( left && ilen >= fill )
+ {
+ memcpy( (void *) (ctx->buffer + left),
+ (void *) input, fill );
+ sha1_process( ctx, ctx->buffer );
+ input += fill;
+ ilen -= fill;
+ left = 0;
+ }
+
+ while( ilen >= 64 )
+ {
+ sha1_process( ctx, input );
+ input += 64;
+ ilen -= 64;
+ }
+
+ if( ilen > 0 )
+ {
+ memcpy( (void *) (ctx->buffer + left),
+ (void *) input, ilen );
+ }
+}
+
+static const unsigned char sha1_padding[64] =
+{
+ 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+/*
+ * SHA-1 final digest
+ */
+void sha1_finish( sha1_context *ctx, unsigned char output[20] )
+{
+ unsigned long last, padn;
+ unsigned long high, low;
+ unsigned char msglen[8];
+
+ high = ( ctx->total[0] >> 29 )
+ | ( ctx->total[1] << 3 );
+ low = ( ctx->total[0] << 3 );
+
+ PUT_ULONG_BE( high, msglen, 0 );
+ PUT_ULONG_BE( low, msglen, 4 );
+
+ last = ctx->total[0] & 0x3F;
+ padn = ( last < 56 ) ? ( 56 - last ) : ( 120 - last );
+
+ sha1_update( ctx, (unsigned char *) sha1_padding, padn );
+ sha1_update( ctx, msglen, 8 );
+
+ PUT_ULONG_BE( ctx->state[0], output, 0 );
+ PUT_ULONG_BE( ctx->state[1], output, 4 );
+ PUT_ULONG_BE( ctx->state[2], output, 8 );
+ PUT_ULONG_BE( ctx->state[3], output, 12 );
+ PUT_ULONG_BE( ctx->state[4], output, 16 );
+}
+
+/*
+ * output = SHA-1( input buffer )
+ */
+void sha1( unsigned char *input, int ilen, unsigned char output[20] )
+{
+ sha1_context ctx;
+
+ sha1_starts( &ctx );
+ sha1_update( &ctx, input, ilen );
+ sha1_finish( &ctx, output );
+
+ memset( &ctx, 0, sizeof( sha1_context ) );
+}
+
+/*
+ * output = SHA-1( file contents )
+ */
+int sha1_file( char *path, unsigned char output[20] )
+{
+ FILE *f;
+ size_t n;
+ sha1_context ctx;
+ unsigned char buf[1024];
+
+ if( ( f = fopen( path, "rb" ) ) == NULL )
+ return( 1 );
+
+ sha1_starts( &ctx );
+
+ while( ( n = fread( buf, 1, sizeof( buf ), f ) ) > 0 )
+ sha1_update( &ctx, buf, (int) n );
+
+ sha1_finish( &ctx, output );
+
+ memset( &ctx, 0, sizeof( sha1_context ) );
+
+ if( ferror( f ) != 0 )
+ {
+ fclose( f );
+ return( 2 );
+ }
+
+ fclose( f );
+ return( 0 );
+}
+
+/*
+ * SHA-1 HMAC context setup
+ */
+void sha1_hmac_starts( sha1_context *ctx, unsigned char *key, int keylen )
+{
+ int i;
+ unsigned char sum[20];
+
+ if( keylen > 64 )
+ {
+ sha1( key, keylen, sum );
+ keylen = 20;
+ key = sum;
+ }
+
+ memset( ctx->ipad, 0x36, 64 );
+ memset( ctx->opad, 0x5C, 64 );
+
+ for( i = 0; i < keylen; i++ )
+ {
+ ctx->ipad[i] = (unsigned char)( ctx->ipad[i] ^ key[i] );
+ ctx->opad[i] = (unsigned char)( ctx->opad[i] ^ key[i] );
+ }
+
+ sha1_starts( ctx );
+ sha1_update( ctx, ctx->ipad, 64 );
+
+ memset( sum, 0, sizeof( sum ) );
+}
+
+/*
+ * SHA-1 HMAC process buffer
+ */
+void sha1_hmac_update( sha1_context *ctx, unsigned char *input, int ilen )
+{
+ sha1_update( ctx, input, ilen );
+}
+
+/*
+ * SHA-1 HMAC final digest
+ */
+void sha1_hmac_finish( sha1_context *ctx, unsigned char output[20] )
+{
+ unsigned char tmpbuf[20];
+
+ sha1_finish( ctx, tmpbuf );
+ sha1_starts( ctx );
+ sha1_update( ctx, ctx->opad, 64 );
+ sha1_update( ctx, tmpbuf, 20 );
+ sha1_finish( ctx, output );
+
+ memset( tmpbuf, 0, sizeof( tmpbuf ) );
+}
+
+/*
+ * output = HMAC-SHA-1( hmac key, input buffer )
+ */
+void sha1_hmac( unsigned char *key, int keylen,
+ unsigned char *input, int ilen,
+ unsigned char output[20] )
+{
+ sha1_context ctx;
+
+ sha1_hmac_starts( &ctx, key, keylen );
+ sha1_hmac_update( &ctx, input, ilen );
+ sha1_hmac_finish( &ctx, output );
+
+ memset( &ctx, 0, sizeof( sha1_context ) );
+}
+
+#if defined(POLARSSL_SELF_TEST)
+/*
+ * FIPS-180-1 test vectors
+ */
+static unsigned char sha1_test_buf[3][57] =
+{
+ { "abc" },
+ { "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" },
+ { "" }
+};
+
+static const int sha1_test_buflen[3] =
+{
+ 3, 56, 1000
+};
+
+static const unsigned char sha1_test_sum[3][20] =
+{
+ { 0xA9, 0x99, 0x3E, 0x36, 0x47, 0x06, 0x81, 0x6A, 0xBA, 0x3E,
+ 0x25, 0x71, 0x78, 0x50, 0xC2, 0x6C, 0x9C, 0xD0, 0xD8, 0x9D },
+ { 0x84, 0x98, 0x3E, 0x44, 0x1C, 0x3B, 0xD2, 0x6E, 0xBA, 0xAE,
+ 0x4A, 0xA1, 0xF9, 0x51, 0x29, 0xE5, 0xE5, 0x46, 0x70, 0xF1 },
+ { 0x34, 0xAA, 0x97, 0x3C, 0xD4, 0xC4, 0xDA, 0xA4, 0xF6, 0x1E,
+ 0xEB, 0x2B, 0xDB, 0xAD, 0x27, 0x31, 0x65, 0x34, 0x01, 0x6F }
+};
+
+/*
+ * RFC 2202 test vectors
+ */
+static unsigned char sha1_hmac_test_key[7][26] =
+{
+ { "\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B"
+ "\x0B\x0B\x0B\x0B" },
+ { "Jefe" },
+ { "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA"
+ "\xAA\xAA\xAA\xAA" },
+ { "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10"
+ "\x11\x12\x13\x14\x15\x16\x17\x18\x19" },
+ { "\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C"
+ "\x0C\x0C\x0C\x0C" },
+ { "" }, /* 0xAA 80 times */
+ { "" }
+};
+
+static const int sha1_hmac_test_keylen[7] =
+{
+ 20, 4, 20, 25, 20, 80, 80
+};
+
+static unsigned char sha1_hmac_test_buf[7][74] =
+{
+ { "Hi There" },
+ { "what do ya want for nothing?" },
+ { "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD"
+ "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD"
+ "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD"
+ "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD"
+ "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD" },
+ { "\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD"
+ "\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD"
+ "\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD"
+ "\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD"
+ "\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD" },
+ { "Test With Truncation" },
+ { "Test Using Larger Than Block-Size Key - Hash Key First" },
+ { "Test Using Larger Than Block-Size Key and Larger"
+ " Than One Block-Size Data" }
+};
+
+static const int sha1_hmac_test_buflen[7] =
+{
+ 8, 28, 50, 50, 20, 54, 73
+};
+
+static const unsigned char sha1_hmac_test_sum[7][20] =
+{
+ { 0xB6, 0x17, 0x31, 0x86, 0x55, 0x05, 0x72, 0x64, 0xE2, 0x8B,
+ 0xC0, 0xB6, 0xFB, 0x37, 0x8C, 0x8E, 0xF1, 0x46, 0xBE, 0x00 },
+ { 0xEF, 0xFC, 0xDF, 0x6A, 0xE5, 0xEB, 0x2F, 0xA2, 0xD2, 0x74,
+ 0x16, 0xD5, 0xF1, 0x84, 0xDF, 0x9C, 0x25, 0x9A, 0x7C, 0x79 },
+ { 0x12, 0x5D, 0x73, 0x42, 0xB9, 0xAC, 0x11, 0xCD, 0x91, 0xA3,
+ 0x9A, 0xF4, 0x8A, 0xA1, 0x7B, 0x4F, 0x63, 0xF1, 0x75, 0xD3 },
+ { 0x4C, 0x90, 0x07, 0xF4, 0x02, 0x62, 0x50, 0xC6, 0xBC, 0x84,
+ 0x14, 0xF9, 0xBF, 0x50, 0xC8, 0x6C, 0x2D, 0x72, 0x35, 0xDA },
+ { 0x4C, 0x1A, 0x03, 0x42, 0x4B, 0x55, 0xE0, 0x7F, 0xE7, 0xF2,
+ 0x7B, 0xE1 },
+ { 0xAA, 0x4A, 0xE5, 0xE1, 0x52, 0x72, 0xD0, 0x0E, 0x95, 0x70,
+ 0x56, 0x37, 0xCE, 0x8A, 0x3B, 0x55, 0xED, 0x40, 0x21, 0x12 },
+ { 0xE8, 0xE9, 0x9D, 0x0F, 0x45, 0x23, 0x7D, 0x78, 0x6D, 0x6B,
+ 0xBA, 0xA7, 0x96, 0x5C, 0x78, 0x08, 0xBB, 0xFF, 0x1A, 0x91 }
+};
+
+/*
+ * Checkup routine
+ */
+int sha1_self_test( int verbose )
+{
+ int i, j, buflen;
+ unsigned char buf[1024];
+ unsigned char sha1sum[20];
+ sha1_context ctx;
+
+ /*
+ * SHA-1
+ */
+ for( i = 0; i < 3; i++ )
+ {
+ if( verbose != 0 )
+ printf( " SHA-1 test #%d: ", i + 1 );
+
+ sha1_starts( &ctx );
+
+ if( i == 2 )
+ {
+ memset( buf, 'a', buflen = 1000 );
+
+ for( j = 0; j < 1000; j++ )
+ sha1_update( &ctx, buf, buflen );
+ }
+ else
+ sha1_update( &ctx, sha1_test_buf[i],
+ sha1_test_buflen[i] );
+
+ sha1_finish( &ctx, sha1sum );
+
+ if( memcmp( sha1sum, sha1_test_sum[i], 20 ) != 0 )
+ {
+ if( verbose != 0 )
+ printf( "failed\n" );
+
+ return( 1 );
+ }
+
+ if( verbose != 0 )
+ printf( "passed\n" );
+ }
+
+ if( verbose != 0 )
+ printf( "\n" );
+
+ for( i = 0; i < 7; i++ )
+ {
+ if( verbose != 0 )
+ printf( " HMAC-SHA-1 test #%d: ", i + 1 );
+
+ if( i == 5 || i == 6 )
+ {
+ memset( buf, '\xAA', buflen = 80 );
+ sha1_hmac_starts( &ctx, buf, buflen );
+ }
+ else
+ sha1_hmac_starts( &ctx, sha1_hmac_test_key[i],
+ sha1_hmac_test_keylen[i] );
+
+ sha1_hmac_update( &ctx, sha1_hmac_test_buf[i],
+ sha1_hmac_test_buflen[i] );
+
+ sha1_hmac_finish( &ctx, sha1sum );
+
+ buflen = ( i == 4 ) ? 12 : 20;
+
+ if( memcmp( sha1sum, sha1_hmac_test_sum[i], buflen ) != 0 )
+ {
+ if( verbose != 0 )
+ printf( "failed\n" );
+
+ return( 1 );
+ }
+
+ if( verbose != 0 )
+ printf( "passed\n" );
+ }
+
+ if( verbose != 0 )
+ printf( "\n" );
+
+ return( 0 );
+}
+
+#endif
+
+#endif
diff --git a/package/px5g/src/library/timing.c b/package/px5g/src/library/timing.c
new file mode 100644
index 0000000..6b7ab74
--- /dev/null
+++ b/package/px5g/src/library/timing.c
@@ -0,0 +1,265 @@
+/*
+ * Portable interface to the CPU cycle counter
+ *
+ * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
+ *
+ * Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the names of PolarSSL or XySSL nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "polarssl/config.h"
+
+#if defined(POLARSSL_TIMING_C)
+
+#include "polarssl/timing.h"
+
+#if defined(WIN32)
+
+#include <windows.h>
+#include <winbase.h>
+
+struct _hr_time
+{
+ LARGE_INTEGER start;
+};
+
+#else
+
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <signal.h>
+#include <time.h>
+
+struct _hr_time
+{
+ struct timeval start;
+};
+
+#endif
+
+#if (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)
+
+unsigned long hardclock( void )
+{
+ unsigned long tsc;
+ __asm rdtsc
+ __asm mov [tsc], eax
+ return( tsc );
+}
+
+#else
+#if defined(__GNUC__) && defined(__i386__)
+
+unsigned long hardclock( void )
+{
+ unsigned long tsc;
+ asm( "rdtsc" : "=a" (tsc) );
+ return( tsc );
+}
+
+#else
+#if defined(__GNUC__) && (defined(__amd64__) || defined(__x86_64__))
+
+unsigned long hardclock( void )
+{
+ unsigned long lo, hi;
+ asm( "rdtsc" : "=a" (lo), "=d" (hi) );
+ return( lo | (hi << 32) );
+}
+
+#else
+#if defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__))
+
+unsigned long hardclock( void )
+{
+ unsigned long tbl, tbu0, tbu1;
+
+ do
+ {
+ asm( "mftbu %0" : "=r" (tbu0) );
+ asm( "mftb %0" : "=r" (tbl ) );
+ asm( "mftbu %0" : "=r" (tbu1) );
+ }
+ while( tbu0 != tbu1 );
+
+ return( tbl );
+}
+
+#else
+#if defined(__GNUC__) && defined(__sparc__)
+
+unsigned long hardclock( void )
+{
+ unsigned long tick;
+ asm( ".byte 0x83, 0x41, 0x00, 0x00" );
+ asm( "mov %%g1, %0" : "=r" (tick) );
+ return( tick );
+}
+
+#else
+#if defined(__GNUC__) && defined(__alpha__)
+
+unsigned long hardclock( void )
+{
+ unsigned long cc;
+ asm( "rpcc %0" : "=r" (cc) );
+ return( cc & 0xFFFFFFFF );
+}
+
+#else
+#if defined(__GNUC__) && defined(__ia64__)
+
+unsigned long hardclock( void )
+{
+ unsigned long itc;
+ asm( "mov %0 = ar.itc" : "=r" (itc) );
+ return( itc );
+}
+
+#else
+
+static int hardclock_init = 0;
+static struct timeval tv_init;
+
+unsigned long hardclock( void )
+{
+ struct timeval tv_cur;
+
+ if( hardclock_init == 0 )
+ {
+ gettimeofday( &tv_init, NULL );
+ hardclock_init = 1;
+ }
+
+ gettimeofday( &tv_cur, NULL );
+ return( ( tv_cur.tv_sec - tv_init.tv_sec ) * 1000000
+ + ( tv_cur.tv_usec - tv_init.tv_usec ) );
+}
+
+#endif /* generic */
+#endif /* IA-64 */
+#endif /* Alpha */
+#endif /* SPARC8 */
+#endif /* PowerPC */
+#endif /* AMD64 */
+#endif /* i586+ */
+
+int alarmed = 0;
+
+#if defined(WIN32)
+
+unsigned long get_timer( struct hr_time *val, int reset )
+{
+ unsigned long delta;
+ LARGE_INTEGER offset, hfreq;
+ struct _hr_time *t = (struct _hr_time *) val;
+
+ QueryPerformanceCounter( &offset );
+ QueryPerformanceFrequency( &hfreq );
+
+ delta = (unsigned long)( ( 1000 *
+ ( offset.QuadPart - t->start.QuadPart ) ) /
+ hfreq.QuadPart );
+
+ if( reset )
+ QueryPerformanceCounter( &t->start );
+
+ return( delta );
+}
+
+DWORD WINAPI TimerProc( LPVOID uElapse )
+{
+ Sleep( (DWORD) uElapse );
+ alarmed = 1;
+ return( TRUE );
+}
+
+void set_alarm( int seconds )
+{
+ DWORD ThreadId;
+
+ alarmed = 0;
+ CloseHandle( CreateThread( NULL, 0, TimerProc,
+ (LPVOID) ( seconds * 1000 ), 0, &ThreadId ) );
+}
+
+void m_sleep( int milliseconds )
+{
+ Sleep( milliseconds );
+}
+
+#else
+
+unsigned long get_timer( struct hr_time *val, int reset )
+{
+ unsigned long delta;
+ struct timeval offset;
+ struct _hr_time *t = (struct _hr_time *) val;
+
+ gettimeofday( &offset, NULL );
+
+ delta = ( offset.tv_sec - t->start.tv_sec ) * 1000
+ + ( offset.tv_usec - t->start.tv_usec ) / 1000;
+
+ if( reset )
+ {
+ t->start.tv_sec = offset.tv_sec;
+ t->start.tv_usec = offset.tv_usec;
+ }
+
+ return( delta );
+}
+
+static void sighandler( int signum )
+{
+ alarmed = 1;
+ signal( signum, sighandler );
+}
+
+void set_alarm( int seconds )
+{
+ alarmed = 0;
+ signal( SIGALRM, sighandler );
+ alarm( seconds );
+}
+
+void m_sleep( int milliseconds )
+{
+ struct timeval tv;
+
+ tv.tv_sec = milliseconds / 1000;
+ tv.tv_usec = milliseconds * 1000;
+
+ select( 0, NULL, NULL, NULL, &tv );
+}
+
+#endif
+
+#endif
diff --git a/package/px5g/src/library/x509write.c b/package/px5g/src/library/x509write.c
new file mode 100644
index 0000000..fabee20
--- /dev/null
+++ b/package/px5g/src/library/x509write.c
@@ -0,0 +1,1139 @@
+/*
+ * X.509 certificate and private key writing
+ *
+ * Copyright (C) 2006-2007 Pascal Vizeli <pvizeli@yahoo.de>
+ * Modifications (C) 2009 Steven Barth <steven@midlink.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License, version 2.1 as published by the Free Software Foundation.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+/*
+ * The ITU-T X.509 standard defines a certificat format for PKI.
+ *
+ * http://www.ietf.org/rfc/rfc2459.txt
+ * http://www.ietf.org/rfc/rfc3279.txt
+ *
+ * ftp://ftp.rsasecurity.com/pub/pkcs/ascii/pkcs-1v2.asc
+ *
+ * http://www.itu.int/ITU-T/studygroups/com17/languages/X.680-0207.pdf
+ * http://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf
+ *
+ * For CRS:
+ * http://www.faqs.org/rfcs/rfc2314.html
+ */
+#include "polarssl/config.h"
+#include "polarssl/x509.h"
+#include "polarssl/base64.h"
+#include "polarssl/sha1.h"
+
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <time.h>
+
+#define and &&
+#define or ||
+
+#if defined _MSC_VER && !defined snprintf
+#define snprintf _snprintf
+#endif
+
+static int x509write_realloc_node(x509_node *node, size_t larger);
+static int x509write_file(x509_node *node, char *path, int format, const char* pem_prolog, const char* pem_epilog);
+
+/*
+ * evaluate how mani octet have this integer
+ */
+static int asn1_eval_octet(unsigned int digit)
+{
+ int i, byte;
+
+ for (byte = 4, i = 24; i >= 0; i -= 8, --byte)
+ if (((digit >> i) & 0xFF) != 0)
+ return byte;
+
+ return 0;
+}
+
+/*
+ * write the asn.1 lenght form into p
+ */
+static int asn1_add_len(unsigned int size, x509_node *node)
+{
+ if (size > 127) {
+
+ /* long size */
+ int byte = asn1_eval_octet(size);
+ int i = 0;
+
+ *(node->p) = (0x80 | byte) & 0xFF;
+ ++node->p;
+
+ for (i = byte; i > 0; --i) {
+
+ *(node->p) = (size >> ((i - 1) * 8)) & 0xFF;
+ ++node->p;
+ }
+
+ } else {
+
+ /* short size */
+ *(node->p) = size & 0xFF;
+ if (size != 0)
+ ++node->p;
+ }
+
+ return 0;
+}
+
+/*
+ * write a ans.1 object into p
+ */
+static int asn1_add_obj(unsigned char *value, unsigned int size, int tag,
+ x509_node *node)
+{
+ int tl = 2;
+
+ if (tag == ASN1_BIT_STRING)
+ ++tl;
+
+ if (size > 127)
+ x509write_realloc_node(node, (size_t) size + tl +
+ asn1_eval_octet(size));
+ else
+ x509write_realloc_node(node, (size_t) size + tl);
+
+ if (node->data == NULL)
+ return 1;
+
+ /* tag */
+ *(node->p) = tag & 0xFF;
+ ++node->p;
+
+ /* len */
+ if (tag == ASN1_BIT_STRING) {
+ asn1_add_len((unsigned int) size + 1, node);
+ *(node->p) = 0x00;
+ ++node->p;
+ } else {
+ asn1_add_len((unsigned int) size, node);
+ }
+
+ /* value */
+ if (size > 0) {
+
+ memcpy(node->p, value, (size_t) size);
+ if ((node->p += size -1) != node->end)
+ return POLARSSL_ERR_X509_POINT_ERROR;
+ } else {
+ /* make nothing -> NULL */
+ }
+
+ return 0;
+}
+
+/*
+ * write a asn.1 conform integer object
+ */
+static int asn1_add_int(signed int value, x509_node *node)
+{
+ signed int i = 0, neg = 1;
+ unsigned int byte, u_val = 0, tmp_val = 0;
+
+ /* if negate? */
+ if (value < 0) {
+ neg = -1;
+ u_val = ~value;
+ } else {
+ u_val = value;
+ }
+
+ byte = asn1_eval_octet(u_val);
+ /* 0 isn't NULL */
+ if (byte == 0)
+ byte = 1;
+
+ /* ASN.1 integer is signed! */
+ if (byte < 4 and ((u_val >> ((byte -1) * 8)) & 0xFF) == 0x80)
+ byte += 1;
+
+ if (x509write_realloc_node(node, (size_t) byte + 2) != 0)
+ return 1;
+
+ /* tag */
+ *(node->p) = ASN1_INTEGER;
+ ++node->p;
+
+ /* len */
+ asn1_add_len(byte, node);
+
+ /* value */
+ for (i = byte; i > 0; --i) {
+
+ tmp_val = (u_val >> ((i - 1) * 8)) & 0xFF;
+ if (neg == 1)
+ *(node->p) = tmp_val;
+ else
+ *(node->p) = ~tmp_val;
+
+ if (i > 1)
+ ++node->p;
+ }
+
+ if (node->p != node->end)
+ return POLARSSL_ERR_X509_POINT_ERROR;
+
+ return 0;
+}
+
+/*
+ * write a asn.1 conform mpi object
+ */
+static int asn1_add_mpi(mpi *value, int tag, x509_node *node)
+{
+ size_t size = (mpi_msb(value) / 8) + 1;
+ unsigned char *buf;
+ int buf_len = (int) size, tl = 2;
+
+ if (tag == ASN1_BIT_STRING)
+ ++tl;
+
+ if (size > 127)
+ x509write_realloc_node(node, size + (size_t) tl +
+ asn1_eval_octet((unsigned int)size));
+ else
+ x509write_realloc_node(node, size + (size_t) tl);
+
+ if (node->data == NULL)
+ return 1;
+
+ buf = (unsigned char*) malloc(size);
+ if (mpi_write_binary(value, buf, buf_len) != 0)
+ return POLARSSL_ERR_MPI_BUFFER_TOO_SMALL;
+
+ /* tag */
+ *(node->p) = tag & 0xFF;
+ ++node->p;
+
+ /* len */
+ if (tag == ASN1_BIT_STRING) {
+ asn1_add_len((unsigned int) size + 1, node);
+ *(node->p) = 0x00;
+ ++node->p;
+ } else {
+ asn1_add_len((unsigned int) size, node);
+ }
+
+ /* value */
+ memcpy(node->p, buf, size);
+ free(buf);
+
+ if ((node->p += (int) size -1) != node->end)
+ return POLARSSL_ERR_X509_POINT_ERROR;
+
+ return 0;
+}
+
+/*
+ * write a node into asn.1 conform object
+ */
+static int asn1_append_tag(x509_node *node, int tag)
+{
+ int tl = 2;
+
+ x509_node tmp;
+ x509write_init_node(&tmp);
+
+ if (tag == ASN1_BIT_STRING)
+ ++tl;
+
+ if (node->len > 127)
+ x509write_realloc_node(&tmp, node->len + (size_t) tl +
+ asn1_eval_octet((unsigned int)node->len));
+ else
+ x509write_realloc_node(&tmp, node->len + (size_t) tl);
+
+ if (tmp.data == NULL) {
+ x509write_free_node(&tmp);
+ return 1;
+ }
+
+ /* tag */
+ *(tmp.p) = tag & 0xFF;
+ ++tmp.p;
+
+ /* len */
+ if (tag == ASN1_BIT_STRING) {
+ asn1_add_len((unsigned int) node->len + 1, &tmp);
+ *(tmp.p) = 0x00;
+ ++tmp.p;
+ } else {
+ asn1_add_len((unsigned int) node->len, &tmp);
+ }
+
+ /* value */
+ memcpy(tmp.p, node->data, node->len);
+
+ /* good? */
+ if ((tmp.p += (int) node->len -1) != tmp.end) {
+ x509write_free_node(&tmp);
+ return POLARSSL_ERR_X509_POINT_ERROR;
+ }
+
+ free(node->data);
+ node->data = tmp.data;
+ node->p = tmp.p;
+ node->end = tmp.end;
+ node->len = tmp.len;
+
+ return 0;
+}
+
+/*
+ * write nodes into a asn.1 object
+ */
+static int asn1_append_nodes(x509_node *node, int tag, int anz, ...)
+{
+ va_list ap;
+ size_t size = 0;
+ x509_node *tmp;
+ int count;
+
+ va_start(ap, anz);
+ count = anz;
+
+ while (count--) {
+
+ tmp = va_arg(ap, x509_node*);
+ if (tmp->data != NULL)
+ size += tmp->len;
+ }
+
+ if ( size > 127) {
+ if (x509write_realloc_node(node, size + (size_t) 2 +
+ asn1_eval_octet(size)) != 0)
+ return 1;
+ } else {
+ if (x509write_realloc_node(node, size + (size_t) 2) != 0)
+ return 1;
+ }
+
+ /* tag */
+ *(node->p) = tag & 0xFF;
+ ++node->p;
+
+ /* len */
+ asn1_add_len(size, node);
+
+ /* value */
+ va_start(ap, anz);
+ count = anz;
+
+ while (count--) {
+
+ tmp = va_arg(ap, x509_node*);
+ if (tmp->data != NULL) {
+
+ memcpy(node->p, tmp->data, tmp->len);
+ if ((node->p += (int) tmp->len -1) != node->end)
+ ++node->p;
+ }
+ }
+
+ va_end(ap);
+ return 0;
+}
+
+/*
+ * write a ASN.1 conform object identifiere include a "tag"
+ */
+static int asn1_add_oid(x509_node *node, unsigned char *oid, size_t len,
+ int tag, int tag_val, unsigned char *value, size_t val_len)
+{
+ int ret;
+ x509_node tmp;
+
+ x509write_init_node(&tmp);
+
+ /* OBJECT IDENTIFIER */
+ if ((ret = asn1_add_obj(oid, len, ASN1_OID, &tmp)) != 0) {
+ x509write_free_node(&tmp);
+ return ret;
+ }
+
+ /* value */
+ if ((ret = asn1_add_obj(value, val_len, tag_val, &tmp)) != 0) {
+ x509write_free_node(&tmp);
+ return ret;
+ }
+
+ /* SET/SEQUENCE */
+ if ((ret = asn1_append_nodes(node, tag, 1, &tmp)) != 0) {
+ x509write_free_node(&tmp);
+ return ret;
+ }
+
+ x509write_free_node(&tmp);
+ return 0;
+}
+
+/*
+ * utcTime UTCTime
+ */
+static int asn1_add_date_utc(unsigned char *time, x509_node *node)
+{
+ unsigned char date[13], *sp;
+ x509_time xtime;
+ int ret;
+
+ sscanf((char*)time, "%d-%d-%d %d:%d:%d", &xtime.year, &xtime.mon,
+ &xtime.day, &xtime.hour, &xtime.min, &xtime.sec);
+
+ /* convert to YY */
+ if (xtime.year > 2000)
+ xtime.year -= 2000;
+ else
+ xtime.year -= 1900;
+
+ snprintf((char*)date, 13, "%2d%2d%2d%2d%2d%2d", xtime.year, xtime.mon, xtime.day,
+ xtime.hour, xtime.min, xtime.sec);
+
+ /* replace ' ' to '0' */
+ for (sp = date; *sp != '\0'; ++sp)
+ if (*sp == '\x20')
+ *sp = '\x30';
+
+ date[12] = 'Z';
+
+ if ((ret = asn1_add_obj(date, 13, ASN1_UTC_TIME, node)) != 0)
+ return ret;
+
+ return 0;
+}
+
+/*
+ * serialize an rsa key into DER
+ */
+
+int x509write_serialize_key(rsa_context *rsa, x509_node *node)
+{
+ int ret = 0;
+ x509write_init_node(node);
+
+ /* vers, n, e, d, p, q, dp, dq, pq */
+ if ((ret = asn1_add_int(rsa->ver, node)) != 0)
+ return ret;
+ if ((ret = asn1_add_mpi(&rsa->N, ASN1_INTEGER, node)) != 0)
+ return ret;
+ if ((ret = asn1_add_mpi(&rsa->E, ASN1_INTEGER, node)) != 0)
+ return ret;
+ if ((ret = asn1_add_mpi(&rsa->D, ASN1_INTEGER, node)) != 0)
+ return ret;
+ if ((ret = asn1_add_mpi(&rsa->P, ASN1_INTEGER, node)) != 0)
+ return ret;
+ if ((ret = asn1_add_mpi(&rsa->Q, ASN1_INTEGER, node)) != 0)
+ return ret;
+ if ((ret = asn1_add_mpi(&rsa->DP, ASN1_INTEGER, node)) != 0)
+ return ret;
+ if ((ret = asn1_add_mpi(&rsa->DQ, ASN1_INTEGER, node)) != 0)
+ return ret;
+ if ((ret = asn1_add_mpi(&rsa->QP, ASN1_INTEGER, node)) != 0)
+ return ret;
+ if ((ret = asn1_append_tag(node, ASN1_CONSTRUCTED | ASN1_SEQUENCE)) != 0)
+ return ret;
+
+ return 0;
+}
+
+/*
+ * write a der/pem encoded rsa private key into a file
+ */
+int x509write_keyfile(rsa_context *rsa, char *path, int out_flag)
+{
+ int ret = 0;
+ const char key_beg[] = "-----BEGIN RSA PRIVATE KEY-----\n",
+ key_end[] = "-----END RSA PRIVATE KEY-----\n";
+ x509_node node;
+
+ x509write_init_node(&node);
+ if ((ret = x509write_serialize_key(rsa,&node)) != 0) {
+ x509write_free_node(&node);
+ return ret;
+ }
+
+ ret = x509write_file(&node,path,out_flag,key_beg,key_end);
+ x509write_free_node(&node);
+
+ return ret;
+}
+
+
+/*
+ * reasize the memory for node
+ */
+static int x509write_realloc_node(x509_node *node, size_t larger)
+{
+ /* init len */
+ if (node->data == NULL) {
+ node->len = 0;
+ node->data = malloc(larger);
+ if(node->data == NULL)
+ return 1;
+ } else {
+ /* realloc memory */
+ if ((node->data = realloc(node->data, node->len + larger)) == NULL)
+ return 1;
+ }
+
+ /* init pointer */
+ node->p = &node->data[node->len];
+ node->len += larger;
+ node->end = &node->data[node->len -1];
+
+ return 0;
+}
+
+/*
+ * init node
+ */
+void x509write_init_node(x509_node *node)
+{
+ memset(node, 0, sizeof(x509_node));
+}
+
+/*
+ * clean memory
+ */
+void x509write_free_node(x509_node *node)
+{
+ if (node->data != NULL)
+ free(node->data);
+ node->p = NULL;
+ node->end = NULL;
+ node->len = 0;
+}
+
+/*
+ * write a x509 certificate into file
+ */
+int x509write_crtfile(x509_raw *chain, unsigned char *path, int out_flag)
+{
+ const char cer_beg[] = "-----BEGIN CERTIFICATE-----\n",
+ cer_end[] = "-----END CERTIFICATE-----\n";
+
+ return x509write_file(&chain->raw, (char*)path, out_flag, cer_beg, cer_end);
+}
+
+/*
+ * write a x509 certificate into file
+ */
+int x509write_csrfile(x509_raw *chain, unsigned char *path, int out_flag)
+{
+ const char cer_beg[] = "-----BEGIN CERTIFICATE REQUEST-----\n",
+ cer_end[] = "-----END CERTIFICATE REQUEST-----\n";
+
+ return x509write_file(&chain->raw, (char*)path, out_flag, cer_beg, cer_end);
+}
+
+/*
+ * write an x509 file
+ */
+static int x509write_file(x509_node *node, char *path, int format,
+ const char* pem_prolog, const char* pem_epilog)
+{
+ FILE *ofstream = stdout;
+ int is_err = 1, buf_len, i, n;
+ unsigned char* base_buf;
+
+ if (path) {
+ if ((ofstream = fopen(path, "wb")) == NULL)
+ return 1;
+ }
+
+ switch (format) {
+ case X509_OUTPUT_DER:
+ if (fwrite(node->data, 1, node->len, ofstream)
+ != node->len)
+ is_err = -1;
+ break;
+
+ case X509_OUTPUT_PEM:
+ if (fprintf(ofstream,pem_prolog)<0) {
+ is_err = -1;
+ break;
+ }
+
+ buf_len = node->len << 1;
+ base_buf = (unsigned char*) malloc((size_t)buf_len);
+ memset(base_buf,0,buf_len);
+ if (base64_encode(base_buf, &buf_len, node->data,
+ (int) node->len) != 0) {
+ is_err = -1;
+ break;
+ }
+
+ n=strlen((char*)base_buf);
+ for(i=0;i<n;i+=64) {
+ fprintf(ofstream,"%.64s\n",&base_buf[i]);
+ }
+
+ if (fprintf(ofstream, pem_epilog)<0) {
+ is_err = -1;
+ break;
+ }
+
+ free(base_buf);
+ }
+
+ fclose(ofstream);
+
+ if (is_err == -1)
+ return 1;
+
+ return 0;
+}
+
+
+/*
+ * add the owner public key to x509 certificate
+ */
+int x509write_add_pubkey(x509_raw *chain, rsa_context *pubkey)
+{
+ x509_node n_tmp, n_tmp2, *node;
+ int ret;
+
+ node = &chain->subpubkey;
+
+ x509write_init_node(&n_tmp);
+ x509write_init_node(&n_tmp2);
+
+ /*
+ * RSAPublicKey ::= SEQUENCE {
+ * modulus INTEGER, -- n
+ * publicExponent INTEGER -- e
+ * }
+ */
+ if ((ret = asn1_add_mpi(&pubkey->N, ASN1_INTEGER, &n_tmp)) != 0) {
+ x509write_free_node(&n_tmp);
+ x509write_free_node(&n_tmp2);
+ return ret;
+ }
+ if ((ret = asn1_add_mpi(&pubkey->E, ASN1_INTEGER, &n_tmp)) != 0) {
+ x509write_free_node(&n_tmp);
+ x509write_free_node(&n_tmp2);
+ return ret;
+ }
+ if ((ret = asn1_append_tag(&n_tmp, ASN1_CONSTRUCTED | ASN1_SEQUENCE))
+ != 0) {
+ x509write_free_node(&n_tmp);
+ x509write_free_node(&n_tmp2);
+ return ret;
+ }
+
+ /*
+ * SubjectPublicKeyInfo ::= SEQUENCE {
+ * algorithm AlgorithmIdentifier,
+ * subjectPublicKey BIT STRING }
+ */
+ if ((ret = asn1_append_tag(&n_tmp, ASN1_BIT_STRING)) != 0) {
+ x509write_free_node(&n_tmp);
+ x509write_free_node(&n_tmp2);
+ return ret;
+ }
+ if ((ret = asn1_add_oid(&n_tmp2, (unsigned char*)OID_PKCS1_RSA, 9,
+ ASN1_CONSTRUCTED | ASN1_SEQUENCE, ASN1_NULL,
+ (unsigned char *)"", 0)) != 0) {
+ x509write_free_node(&n_tmp);
+ x509write_free_node(&n_tmp2);
+ return ret;
+ }
+
+ if ((ret = asn1_append_nodes(node, ASN1_CONSTRUCTED | ASN1_SEQUENCE, 2,
+ &n_tmp2, &n_tmp))) {
+ x509write_free_node(&n_tmp);
+ x509write_free_node(&n_tmp2);
+ return ret;
+ }
+
+ x509write_free_node(&n_tmp);
+ x509write_free_node(&n_tmp2);
+ return 0;
+}
+
+/*
+ * RelativeDistinguishedName ::=
+ * SET OF AttributeTypeAndValue
+ *
+ * AttributeTypeAndValue ::= SEQUENCE {
+ * type AttributeType,
+ * value AttributeValue }
+ */
+static int x509write_add_name(x509_node *node, unsigned char *oid,
+ unsigned int oid_len, unsigned char *value, int len, int value_tag)
+{
+ int ret;
+ x509_node n_tmp;
+
+ x509write_init_node(&n_tmp);
+
+ if ((ret = asn1_add_oid(&n_tmp, oid, oid_len,
+ ASN1_CONSTRUCTED | ASN1_SEQUENCE, value_tag,
+ value, len))) {
+ x509write_free_node(&n_tmp);
+ return ret;
+ }
+
+ if ((asn1_append_nodes(node, ASN1_CONSTRUCTED | ASN1_SET, 1, &n_tmp))
+ != 0) {
+ x509write_free_node(&n_tmp);
+ return ret;
+ }
+
+ x509write_free_node(&n_tmp);
+ return 0;
+}
+
+/*
+ * Parse the name string and add to node
+ */
+static int x509write_parse_names(x509_node *node, unsigned char *names)
+{
+ unsigned char *sp, *begin = NULL;
+ unsigned char oid[3] = OID_X520, tag[4], *tag_sp = tag;
+ unsigned char *C = NULL, *CN = NULL, *O = NULL, *OU = NULL,
+ *ST = NULL, *L = NULL, *R = NULL;
+ int C_len = 0, CN_len = 0, O_len = 0, OU_len = 0, ST_len = 0,
+ L_len = 0, R_len = 0;
+ int ret = 0, is_tag = 1, is_begin = -1, len = 0;
+
+
+ for (sp = names; ; ++sp) {
+
+ /* filter tag */
+ if (is_tag == 1) {
+
+ if (tag_sp == &tag[3])
+ return POLARSSL_ERR_X509_VALUE_TO_LENGTH;
+
+ /* is tag end? */
+ if (*sp == '=') {
+ is_tag = -1;
+ *tag_sp = '\0';
+ is_begin = 1;
+ /* set len 0 (reset) */
+ len = 0;
+ } else {
+ /* tag hasn't ' '! */
+ if (*sp != ' ') {
+ *tag_sp = *sp;
+ ++tag_sp;
+ }
+ }
+ /* filter value */
+ } else {
+
+ /* set pointer of value begin */
+ if (is_begin == 1) {
+ begin = sp;
+ is_begin = -1;
+ }
+
+ /* is value at end? */
+ if (*sp == ';' or *sp == '\0') {
+ is_tag = 1;
+
+ /* common name */
+ if (tag[0] == 'C' and tag[1] == 'N') {
+ CN = begin;
+ CN_len = len;
+
+ /* organization */
+ } else if (tag[0] == 'O' and tag[1] == '\0') {
+ O = begin;
+ O_len = len;
+
+ /* country */
+ } else if (tag[0] == 'C' and tag[1] == '\0') {
+ C = begin;
+ C_len = len;
+
+ /* organisation unit */
+ } else if (tag[0] == 'O' and tag[1] == 'U') {
+ OU = begin;
+ OU_len = len;
+
+ /* state */
+ } else if (tag[0] == 'S' and tag[1] == 'T') {
+ ST = begin;
+ ST_len = len;
+
+ /* locality */
+ } else if (tag[0] == 'L' and tag[1] == '\0') {
+ L = begin;
+ L_len = len;
+
+ /* email */
+ } else if (tag[0] == 'R' and tag[1] == '\0') {
+ R = begin;
+ R_len = len;
+ }
+
+ /* set tag poiner to begin */
+ tag_sp = tag;
+
+ /* is at end? */
+ if (*sp == '\0' or *(sp +1) == '\0')
+ break;
+ } else {
+ ++len;
+ }
+ }
+
+ /* make saver */
+ if (*sp == '\0')
+ break;
+ } /* end for */
+
+ /* country */
+ if (C != NULL) {
+ oid[2] = X520_COUNTRY;
+ if ((ret = x509write_add_name(node, oid, 3, C, C_len,
+ ASN1_PRINTABLE_STRING)) != 0)
+ return ret;
+ }
+
+ /* state */
+ if (ST != NULL) {
+ oid[2] = X520_STATE;
+ if ((ret = x509write_add_name(node, oid, 3, ST, ST_len,
+ ASN1_PRINTABLE_STRING)) != 0)
+ return ret;
+ }
+
+ /* locality */
+ if (L != NULL) {
+ oid[2] = X520_LOCALITY;
+ if ((ret = x509write_add_name(node, oid, 3, L, L_len,
+ ASN1_PRINTABLE_STRING)) != 0)
+ return ret;
+ }
+
+ /* organization */
+ if (O != NULL) {
+ oid[2] = X520_ORGANIZATION;
+ if ((ret = x509write_add_name(node, oid, 3, O, O_len,
+ ASN1_PRINTABLE_STRING)) != 0)
+ return ret;
+ }
+
+ /* organisation unit */
+ if (OU != NULL) {
+ oid[2] = X520_ORG_UNIT;
+ if ((ret = x509write_add_name(node, oid, 3, OU, OU_len,
+ ASN1_PRINTABLE_STRING)) != 0)
+ return ret;
+ }
+
+ /* common name */
+ if (CN != NULL) {
+ oid[2] = X520_COMMON_NAME;
+ if ((ret = x509write_add_name(node, oid, 3, CN, CN_len,
+ ASN1_PRINTABLE_STRING)) != 0)
+ return ret;
+ }
+
+ /* email */
+ if (R != NULL) {
+ if ((ret = x509write_add_name(node, (unsigned char*)OID_PKCS9_EMAIL,
+ 9, R, R_len, ASN1_IA5_STRING)) != 0)
+ return ret;
+ }
+
+ if ((asn1_append_tag(node, ASN1_CONSTRUCTED | ASN1_SEQUENCE)) != 0)
+ return ret;
+
+ return 0;
+}
+
+/*
+ * Copy raw data from orginal ca to node
+ */
+static int x509write_copy_from_raw(x509_node *node, x509_buf *raw)
+{
+ if (x509write_realloc_node(node, raw->len) != 0)
+ return 1;
+
+ memcpy(node->p, raw->p, (size_t)raw->len);
+ if ((node->p += raw->len -1) != node->end)
+ return POLARSSL_ERR_X509_POINT_ERROR;
+
+ return 0;
+}
+
+/*
+ * Add the issuer
+ */
+
+int x509write_add_issuer(x509_raw *crt, unsigned char *issuer)
+{
+ return x509write_parse_names(&crt->issuer, issuer);
+}
+
+/*
+ * Add the subject
+ */
+int x509write_add_subject(x509_raw *crt, unsigned char *subject)
+{
+ return x509write_parse_names(&crt->subject, subject);
+}
+
+/*
+ * Copy issuer line from another cert to issuer
+ */
+int x509write_copy_issuer(x509_raw *crt, x509_cert *from_crt)
+{
+ return x509write_copy_from_raw(&crt->issuer, &from_crt->issuer_raw);
+}
+
+/*
+ * Copy subject line from another cert
+ */
+int x509write_copy_subject(x509_raw *crt, x509_cert *from_crt)
+{
+ return x509write_copy_from_raw(&crt->subject, &from_crt->subject_raw);
+}
+
+/*
+ * Copy subject line form antoher cert into issuer
+ */
+int x509write_copy_issuer_form_subject(x509_raw *crt,
+ x509_cert *from_crt)
+{
+ return x509write_copy_from_raw(&crt->issuer, &from_crt->subject_raw);
+}
+
+/*
+ * Copy issuer line from another cert into subject
+ */
+int x509write_copy_subject_from_issuer(x509_raw *crt,
+ x509_cert * from_crt)
+{
+ return x509write_copy_from_raw(&crt->subject, &from_crt->issuer_raw);
+}
+
+/*
+ * Validity ::= SEQUENCE {
+ * notBefore Time,
+ * notAfter Time }
+ *
+ * Time ::= CHOICE {
+ * utcTime UTCTime,
+ * generalTime GeneralizedTime }
+ */
+/* TODO: No handle GeneralizedTime! */
+int x509write_add_validity(x509_raw *chain, unsigned char *befor,
+ unsigned char *after)
+{
+ int ret;
+
+ x509_node *node = &chain->validity;
+
+ /* notBefore */
+ if ((ret = asn1_add_date_utc(befor, node)) != 0)
+ return ret;
+
+ /* notAfter */
+ if ((ret = asn1_add_date_utc(after, node)) != 0)
+ return ret;
+
+ if ((ret = asn1_append_tag(node, ASN1_CONSTRUCTED | ASN1_SEQUENCE)) != 0)
+ return ret;
+
+ return 0;
+}
+
+/*
+ * make hash from tbs and sign that with private key
+ */
+static int x509write_make_sign(x509_raw *chain, rsa_context *privkey)
+{
+ int ret;
+ unsigned char hash[20], *sign;
+ size_t sign_len = (size_t) mpi_size(&privkey->N);
+
+ /* make hash */
+ sha1(chain->tbs.data, chain->tbs.len, hash);
+
+ /* create sign */
+ sign = (unsigned char *) malloc(sign_len);
+ if (sign == NULL)
+ return 1;
+
+ if ((ret = rsa_pkcs1_sign(privkey, RSA_PRIVATE, RSA_SHA1, 20, hash,
+ sign)) != 0)
+ return ret;
+
+ if ((ret = asn1_add_obj(sign, sign_len, ASN1_BIT_STRING,
+ &chain->sign)) != 0)
+ return ret;
+
+ /*
+ * AlgorithmIdentifier ::= SEQUENCE {
+ * algorithm OBJECT IDENTIFIER,
+ * parameters ANY DEFINED BY algorithm OPTIONAL }
+ */
+ return asn1_add_oid(&chain->signalg, (unsigned char*)OID_PKCS1_RSA_SHA, 9,
+ ASN1_CONSTRUCTED | ASN1_SEQUENCE, ASN1_NULL,
+ (unsigned char*)"", 0);
+}
+
+/*
+ * Create a self signed certificate
+ */
+int x509write_create_sign(x509_raw *chain, rsa_context *privkey)
+{
+ int ret, serial;
+
+ /*
+ * Version ::= INTEGER { v1(0), v2(1), v3(2) }
+ */
+ if ((ret = asn1_add_int(2, &chain->version)) != 0)
+ return ret;
+
+ if ((ret = asn1_append_tag(&chain->version, ASN1_CONTEXT_SPECIFIC |
+ ASN1_CONSTRUCTED)) != 0)
+ return ret;
+
+
+ /*
+ * CertificateSerialNumber ::= INTEGER
+ */
+ srand((unsigned int) time(NULL));
+ serial = rand();
+ if ((ret = asn1_add_int(serial, &chain->serial)) != 0)
+ return ret;
+
+ /*
+ * AlgorithmIdentifier ::= SEQUENCE {
+ * algorithm OBJECT IDENTIFIER,
+ * parameters ANY DEFINED BY algorithm OPTIONAL }
+ */
+ if ((ret = asn1_add_oid(&chain->tbs_signalg,
+ (unsigned char*)OID_PKCS1_RSA_SHA, 9, ASN1_CONSTRUCTED |
+ ASN1_SEQUENCE, ASN1_NULL, (unsigned char*)"", 0)) != 0)
+ return ret;
+
+ /*
+ * Create the tbs
+ */
+ if ((ret = asn1_append_nodes(&chain->tbs, ASN1_CONSTRUCTED |
+ ASN1_SEQUENCE, 7, &chain->version, &chain->serial,
+ &chain->tbs_signalg, &chain->issuer, &chain->validity,
+ &chain->subject, &chain->subpubkey)) != 0)
+ return ret;
+
+ /* make signing */
+ if ((ret = x509write_make_sign(chain, privkey)) != 0)
+ return ret;
+
+ /* finishing */
+ if ((ret = asn1_append_nodes(&chain->raw, ASN1_CONSTRUCTED |
+ ASN1_SEQUENCE, 3, &chain->tbs, &chain->signalg,
+ &chain->sign)) != 0)
+ return ret;
+
+ return 0;
+}
+
+int x509write_create_selfsign(x509_raw *chain, rsa_context *privkey)
+{
+ /*
+ * On self signed certificate are subject and issuer the same
+ */
+ x509write_free_node(&chain->issuer);
+ chain->issuer = chain->subject;
+ return x509write_create_sign(chain, privkey);
+}
+
+/*
+ * CertificationRequestInfo ::= SEQUENCE {
+ * version Version,
+ * subject Name,
+ * subjectPublicKeyInfo SubjectPublicKeyInfo,
+ * attributes [0] IMPLICIT Attributes }
+ *
+ * CertificationRequest ::= SEQUENCE {
+ * certificationRequestInfo CertificationRequestInfo,
+ * signatureAlgorithm SignatureAlgorithmIdentifier,
+ * signature Signature }
+ *
+ * It use chain.serail for attributes!
+ *
+ */
+int x509write_create_csr(x509_raw *chain, rsa_context *privkey)
+{
+ int ret;
+
+ /* version ::= INTEGER */
+ if ((ret = asn1_add_int(0, &chain->version)) != 0)
+ return ret;
+
+ /* write attributes */
+ if ((ret = asn1_add_obj((unsigned char*)"", 0, ASN1_CONTEXT_SPECIFIC |
+ ASN1_CONSTRUCTED, &chain->serial)) != 0)
+ return ret;
+
+ /* create CertificationRequestInfo */
+ if ((ret = asn1_append_nodes(&chain->tbs, ASN1_CONSTRUCTED |
+ ASN1_SEQUENCE, 4, &chain->version, &chain->subject,
+ &chain->subpubkey, &chain->serial)) != 0)
+ return ret;
+
+ /* make signing */
+ if ((ret = x509write_make_sign(chain, privkey)) != 0)
+ return ret;
+
+ /* finish */
+ if ((ret = asn1_append_nodes(&chain->raw, ASN1_CONSTRUCTED | ASN1_SEQUENCE,
+ 3, &chain->tbs, &chain->signalg, &chain->sign)) != 0)
+ return ret;
+
+ return ret;
+}
+
+/*
+ * Free memory
+ */
+void x509write_free_raw(x509_raw *chain)
+{
+ x509write_free_node(&chain->raw);
+ x509write_free_node(&chain->tbs);
+ x509write_free_node(&chain->version);
+ x509write_free_node(&chain->serial);
+ x509write_free_node(&chain->tbs_signalg);
+ x509write_free_node(&chain->issuer);
+ x509write_free_node(&chain->validity);
+ if (chain->subject.data != chain->issuer.data)
+ x509write_free_node(&chain->subject);
+ x509write_free_node(&chain->subpubkey);
+ x509write_free_node(&chain->signalg);
+ x509write_free_node(&chain->sign);
+}
+
+void x509write_init_raw(x509_raw *chain)
+{
+ memset((void *) chain, 0, sizeof(x509_raw));
+}
+
diff --git a/package/px5g/src/polarssl/.svn/entries b/package/px5g/src/polarssl/.svn/entries
new file mode 100644
index 0000000..f6f1b63
--- /dev/null
+++ b/package/px5g/src/polarssl/.svn/entries
@@ -0,0 +1,334 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/px5g/src/polarssl
+svn://svn.openwrt.org/openwrt
+
+
+
+2010-03-25T15:46:39.389627Z
+20429
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+bn_mul.h
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+bf17f78c2ce71f3144c251dda7affbbe
+2010-03-25T15:46:39.389627Z
+20429
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+29700
+
+sha1.h
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+0e997ea55c71d1969caaaefd89bc24db
+2010-03-25T15:46:39.389627Z
+20429
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4701
+
+havege.h
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+5fe3ad3734ad53d726153fcc8ce0e44a
+2010-03-25T15:46:39.389627Z
+20429
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2383
+
+bignum.h
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+1942cc2eb34605dea3090b057cdf7b10
+2010-03-25T15:46:39.389627Z
+20429
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+12442
+
+base64.h
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+22ee76e109cd56a9c2fcd26bbdb368c1
+2010-03-25T15:46:39.389627Z
+20429
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3563
+
+config.h
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+54619859d712c9a0d1546e88adfa1686
+2010-03-25T15:46:39.389627Z
+20429
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+7197
+
+rsa.h
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+edbefc800a46bb1b59b1c775335b3b2f
+2010-03-25T15:46:39.389627Z
+20429
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+10499
+
+x509.h
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+c83c802941c1bec3bda96b8f519f76e4
+2010-03-25T15:46:39.389627Z
+20429
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+17875
+
+timing.h
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+089d7a76d0f7f8c1c56f9847ac206a26
+2010-03-25T15:46:39.389627Z
+20429
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2571
+
diff --git a/package/px5g/src/polarssl/.svn/text-base/base64.h.svn-base b/package/px5g/src/polarssl/.svn/text-base/base64.h.svn-base
new file mode 100644
index 0000000..c48267b
--- /dev/null
+++ b/package/px5g/src/polarssl/.svn/text-base/base64.h.svn-base
@@ -0,0 +1,93 @@
+/**
+ * \file base64.h
+ *
+ * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
+ *
+ * Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the names of PolarSSL or XySSL nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef POLARSSL_BASE64_H
+#define POLARSSL_BASE64_H
+
+#define POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL -0x0010
+#define POLARSSL_ERR_BASE64_INVALID_CHARACTER -0x0012
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \brief Encode a buffer into base64 format
+ *
+ * \param dst destination buffer
+ * \param dlen size of the buffer
+ * \param src source buffer
+ * \param slen amount of data to be encoded
+ *
+ * \return 0 if successful, or POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL.
+ * *dlen is always updated to reflect the amount
+ * of data that has (or would have) been written.
+ *
+ * \note Call this function with *dlen = 0 to obtain the
+ * required buffer size in *dlen
+ */
+int base64_encode( unsigned char *dst, int *dlen,
+ unsigned char *src, int slen );
+
+/**
+ * \brief Decode a base64-formatted buffer
+ *
+ * \param dst destination buffer
+ * \param dlen size of the buffer
+ * \param src source buffer
+ * \param slen amount of data to be decoded
+ *
+ * \return 0 if successful, POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL, or
+ * POLARSSL_ERR_BASE64_INVALID_DATA if the input data is not
+ * correct. *dlen is always updated to reflect the amount
+ * of data that has (or would have) been written.
+ *
+ * \note Call this function with *dlen = 0 to obtain the
+ * required buffer size in *dlen
+ */
+int base64_decode( unsigned char *dst, int *dlen,
+ unsigned char *src, int slen );
+
+/**
+ * \brief Checkup routine
+ *
+ * \return 0 if successful, or 1 if the test failed
+ */
+int base64_self_test( int verbose );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* base64.h */
diff --git a/package/px5g/src/polarssl/.svn/text-base/bignum.h.svn-base b/package/px5g/src/polarssl/.svn/text-base/bignum.h.svn-base
new file mode 100644
index 0000000..c667303
--- /dev/null
+++ b/package/px5g/src/polarssl/.svn/text-base/bignum.h.svn-base
@@ -0,0 +1,437 @@
+/**
+ * \file bignum.h
+ *
+ * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
+ *
+ * Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the names of PolarSSL or XySSL nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef POLARSSL_BIGNUM_H
+#define POLARSSL_BIGNUM_H
+
+#include <stdio.h>
+
+#define POLARSSL_ERR_MPI_FILE_IO_ERROR -0x0002
+#define POLARSSL_ERR_MPI_BAD_INPUT_DATA -0x0004
+#define POLARSSL_ERR_MPI_INVALID_CHARACTER -0x0006
+#define POLARSSL_ERR_MPI_BUFFER_TOO_SMALL -0x0008
+#define POLARSSL_ERR_MPI_NEGATIVE_VALUE -0x000A
+#define POLARSSL_ERR_MPI_DIVISION_BY_ZERO -0x000C
+#define POLARSSL_ERR_MPI_NOT_ACCEPTABLE -0x000E
+
+#define MPI_CHK(f) if( ( ret = f ) != 0 ) goto cleanup
+
+/*
+ * Define the base integer type, architecture-wise
+ */
+#if defined(POLARSSL_HAVE_INT8)
+typedef unsigned char t_int;
+typedef unsigned short t_dbl;
+#else
+#if defined(POLARSSL_HAVE_INT16)
+typedef unsigned short t_int;
+typedef unsigned long t_dbl;
+#else
+ typedef unsigned long t_int;
+ #if defined(_MSC_VER) && defined(_M_IX86)
+ typedef unsigned __int64 t_dbl;
+ #else
+ #if defined(__amd64__) || defined(__x86_64__) || \
+ defined(__ppc64__) || defined(__powerpc64__) || \
+ defined(__ia64__) || defined(__alpha__)
+ typedef unsigned int t_dbl __attribute__((mode(TI)));
+ #else
+ typedef unsigned long long t_dbl;
+ #endif
+ #endif
+#endif
+#endif
+
+/**
+ * \brief MPI structure
+ */
+typedef struct
+{
+ int s; /*!< integer sign */
+ int n; /*!< total # of limbs */
+ t_int *p; /*!< pointer to limbs */
+}
+mpi;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \brief Initialize one or more mpi
+ */
+void mpi_init( mpi *X, ... );
+
+/**
+ * \brief Unallocate one or more mpi
+ */
+void mpi_free( mpi *X, ... );
+
+/**
+ * \brief Enlarge to the specified number of limbs
+ *
+ * \return 0 if successful,
+ * 1 if memory allocation failed
+ */
+int mpi_grow( mpi *X, int nblimbs );
+
+/**
+ * \brief Copy the contents of Y into X
+ *
+ * \return 0 if successful,
+ * 1 if memory allocation failed
+ */
+int mpi_copy( mpi *X, mpi *Y );
+
+/**
+ * \brief Swap the contents of X and Y
+ */
+void mpi_swap( mpi *X, mpi *Y );
+
+/**
+ * \brief Set value from integer
+ *
+ * \return 0 if successful,
+ * 1 if memory allocation failed
+ */
+int mpi_lset( mpi *X, int z );
+
+/**
+ * \brief Return the number of least significant bits
+ */
+int mpi_lsb( mpi *X );
+
+/**
+ * \brief Return the number of most significant bits
+ */
+int mpi_msb( mpi *X );
+
+/**
+ * \brief Return the total size in bytes
+ */
+int mpi_size( mpi *X );
+
+/**
+ * \brief Import from an ASCII string
+ *
+ * \param X destination mpi
+ * \param radix input numeric base
+ * \param s null-terminated string buffer
+ *
+ * \return 0 if successful, or an POLARSSL_ERR_MPI_XXX error code
+ */
+int mpi_read_string( mpi *X, int radix, char *s );
+
+/**
+ * \brief Export into an ASCII string
+ *
+ * \param X source mpi
+ * \param radix output numeric base
+ * \param s string buffer
+ * \param slen string buffer size
+ *
+ * \return 0 if successful, or an POLARSSL_ERR_MPI_XXX error code
+ *
+ * \note Call this function with *slen = 0 to obtain the
+ * minimum required buffer size in *slen.
+ */
+int mpi_write_string( mpi *X, int radix, char *s, int *slen );
+
+/**
+ * \brief Read X from an opened file
+ *
+ * \param X destination mpi
+ * \param radix input numeric base
+ * \param fin input file handle
+ *
+ * \return 0 if successful, or an POLARSSL_ERR_MPI_XXX error code
+ */
+int mpi_read_file( mpi *X, int radix, FILE *fin );
+
+/**
+ * \brief Write X into an opened file, or stdout
+ *
+ * \param p prefix, can be NULL
+ * \param X source mpi
+ * \param radix output numeric base
+ * \param fout output file handle
+ *
+ * \return 0 if successful, or an POLARSSL_ERR_MPI_XXX error code
+ *
+ * \note Set fout == NULL to print X on the console.
+ */
+int mpi_write_file( char *p, mpi *X, int radix, FILE *fout );
+
+/**
+ * \brief Import X from unsigned binary data, big endian
+ *
+ * \param X destination mpi
+ * \param buf input buffer
+ * \param buflen input buffer size
+ *
+ * \return 0 if successful,
+ * 1 if memory allocation failed
+ */
+int mpi_read_binary( mpi *X, unsigned char *buf, int buflen );
+
+/**
+ * \brief Export X into unsigned binary data, big endian
+ *
+ * \param X source mpi
+ * \param buf output buffer
+ * \param buflen output buffer size
+ *
+ * \return 0 if successful,
+ * POLARSSL_ERR_MPI_BUFFER_TOO_SMALL if buf isn't large enough
+ *
+ * \note Call this function with *buflen = 0 to obtain the
+ * minimum required buffer size in *buflen.
+ */
+int mpi_write_binary( mpi *X, unsigned char *buf, int buflen );
+
+/**
+ * \brief Left-shift: X <<= count
+ *
+ * \return 0 if successful,
+ * 1 if memory allocation failed
+ */
+int mpi_shift_l( mpi *X, int count );
+
+/**
+ * \brief Right-shift: X >>= count
+ *
+ * \return 0 if successful,
+ * 1 if memory allocation failed
+ */
+int mpi_shift_r( mpi *X, int count );
+
+/**
+ * \brief Compare unsigned values
+ *
+ * \return 1 if |X| is greater than |Y|,
+ * -1 if |X| is lesser than |Y| or
+ * 0 if |X| is equal to |Y|
+ */
+int mpi_cmp_abs( mpi *X, mpi *Y );
+
+/**
+ * \brief Compare signed values
+ *
+ * \return 1 if X is greater than Y,
+ * -1 if X is lesser than Y or
+ * 0 if X is equal to Y
+ */
+int mpi_cmp_mpi( mpi *X, mpi *Y );
+
+/**
+ * \brief Compare signed values
+ *
+ * \return 1 if X is greater than z,
+ * -1 if X is lesser than z or
+ * 0 if X is equal to z
+ */
+int mpi_cmp_int( mpi *X, int z );
+
+/**
+ * \brief Unsigned addition: X = |A| + |B|
+ *
+ * \return 0 if successful,
+ * 1 if memory allocation failed
+ */
+int mpi_add_abs( mpi *X, mpi *A, mpi *B );
+
+/**
+ * \brief Unsigned substraction: X = |A| - |B|
+ *
+ * \return 0 if successful,
+ * POLARSSL_ERR_MPI_NEGATIVE_VALUE if B is greater than A
+ */
+int mpi_sub_abs( mpi *X, mpi *A, mpi *B );
+
+/**
+ * \brief Signed addition: X = A + B
+ *
+ * \return 0 if successful,
+ * 1 if memory allocation failed
+ */
+int mpi_add_mpi( mpi *X, mpi *A, mpi *B );
+
+/**
+ * \brief Signed substraction: X = A - B
+ *
+ * \return 0 if successful,
+ * 1 if memory allocation failed
+ */
+int mpi_sub_mpi( mpi *X, mpi *A, mpi *B );
+
+/**
+ * \brief Signed addition: X = A + b
+ *
+ * \return 0 if successful,
+ * 1 if memory allocation failed
+ */
+int mpi_add_int( mpi *X, mpi *A, int b );
+
+/**
+ * \brief Signed substraction: X = A - b
+ *
+ * \return 0 if successful,
+ * 1 if memory allocation failed
+ */
+int mpi_sub_int( mpi *X, mpi *A, int b );
+
+/**
+ * \brief Baseline multiplication: X = A * B
+ *
+ * \return 0 if successful,
+ * 1 if memory allocation failed
+ */
+int mpi_mul_mpi( mpi *X, mpi *A, mpi *B );
+
+/**
+ * \brief Baseline multiplication: X = A * b
+ *
+ * \return 0 if successful,
+ * 1 if memory allocation failed
+ */
+int mpi_mul_int( mpi *X, mpi *A, t_int b );
+
+/**
+ * \brief Division by mpi: A = Q * B + R
+ *
+ * \return 0 if successful,
+ * 1 if memory allocation failed,
+ * POLARSSL_ERR_MPI_DIVISION_BY_ZERO if B == 0
+ *
+ * \note Either Q or R can be NULL.
+ */
+int mpi_div_mpi( mpi *Q, mpi *R, mpi *A, mpi *B );
+
+/**
+ * \brief Division by int: A = Q * b + R
+ *
+ * \return 0 if successful,
+ * 1 if memory allocation failed,
+ * POLARSSL_ERR_MPI_DIVISION_BY_ZERO if b == 0
+ *
+ * \note Either Q or R can be NULL.
+ */
+int mpi_div_int( mpi *Q, mpi *R, mpi *A, int b );
+
+/**
+ * \brief Modulo: R = A mod B
+ *
+ * \return 0 if successful,
+ * 1 if memory allocation failed,
+ * POLARSSL_ERR_MPI_DIVISION_BY_ZERO if B == 0
+ */
+int mpi_mod_mpi( mpi *R, mpi *A, mpi *B );
+
+/**
+ * \brief Modulo: r = A mod b
+ *
+ * \return 0 if successful,
+ * 1 if memory allocation failed,
+ * POLARSSL_ERR_MPI_DIVISION_BY_ZERO if b == 0
+ */
+int mpi_mod_int( t_int *r, mpi *A, int b );
+
+/**
+ * \brief Sliding-window exponentiation: X = A^E mod N
+ *
+ * \return 0 if successful,
+ * 1 if memory allocation failed,
+ * POLARSSL_ERR_MPI_BAD_INPUT_DATA if N is negative or even
+ *
+ * \note _RR is used to avoid re-computing R*R mod N across
+ * multiple calls, which speeds up things a bit. It can
+ * be set to NULL if the extra performance is unneeded.
+ */
+int mpi_exp_mod( mpi *X, mpi *A, mpi *E, mpi *N, mpi *_RR );
+
+/**
+ * \brief Greatest common divisor: G = gcd(A, B)
+ *
+ * \return 0 if successful,
+ * 1 if memory allocation failed
+ */
+int mpi_gcd( mpi *G, mpi *A, mpi *B );
+
+/**
+ * \brief Modular inverse: X = A^-1 mod N
+ *
+ * \return 0 if successful,
+ * 1 if memory allocation failed,
+ * POLARSSL_ERR_MPI_BAD_INPUT_DATA if N is negative or nil
+ * POLARSSL_ERR_MPI_NOT_ACCEPTABLE if A has no inverse mod N
+ */
+int mpi_inv_mod( mpi *X, mpi *A, mpi *N );
+
+/**
+ * \brief Miller-Rabin primality test
+ *
+ * \return 0 if successful (probably prime),
+ * 1 if memory allocation failed,
+ * POLARSSL_ERR_MPI_NOT_ACCEPTABLE if X is not prime
+ */
+int mpi_is_prime( mpi *X, int (*f_rng)(void *), void *p_rng );
+
+/**
+ * \brief Prime number generation
+ *
+ * \param X destination mpi
+ * \param nbits required size of X in bits
+ * \param dh_flag if 1, then (X-1)/2 will be prime too
+ * \param f_rng RNG function
+ * \param p_rng RNG parameter
+ *
+ * \return 0 if successful (probably prime),
+ * 1 if memory allocation failed,
+ * POLARSSL_ERR_MPI_BAD_INPUT_DATA if nbits is < 3
+ */
+int mpi_gen_prime( mpi *X, int nbits, int dh_flag,
+ int (*f_rng)(void *), void *p_rng );
+
+/**
+ * \brief Checkup routine
+ *
+ * \return 0 if successful, or 1 if the test failed
+ */
+int mpi_self_test( int verbose );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* bignum.h */
diff --git a/package/px5g/src/polarssl/.svn/text-base/bn_mul.h.svn-base b/package/px5g/src/polarssl/.svn/text-base/bn_mul.h.svn-base
new file mode 100644
index 0000000..f6d34da
--- /dev/null
+++ b/package/px5g/src/polarssl/.svn/text-base/bn_mul.h.svn-base
@@ -0,0 +1,731 @@
+/**
+ * \file bn_mul.h
+ *
+ * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
+ *
+ * Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the names of PolarSSL or XySSL nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+/*
+ * Multiply source vector [s] with b, add result
+ * to destination vector [d] and set carry c.
+ *
+ * Currently supports:
+ *
+ * . IA-32 (386+) . AMD64 / EM64T
+ * . IA-32 (SSE2) . Motorola 68000
+ * . PowerPC, 32-bit . MicroBlaze
+ * . PowerPC, 64-bit . TriCore
+ * . SPARC v8 . ARM v3+
+ * . Alpha . MIPS32
+ * . C, longlong . C, generic
+ */
+#ifndef POLARSSL_BN_MUL_H
+#define POLARSSL_BN_MUL_H
+
+#include "polarssl/config.h"
+
+#if defined(POLARSSL_HAVE_ASM)
+
+#if defined(__GNUC__)
+#if defined(__i386__)
+
+#define MULADDC_INIT \
+ asm( "movl %%ebx, %0 " : "=m" (t)); \
+ asm( "movl %0, %%esi " :: "m" (s)); \
+ asm( "movl %0, %%edi " :: "m" (d)); \
+ asm( "movl %0, %%ecx " :: "m" (c)); \
+ asm( "movl %0, %%ebx " :: "m" (b));
+
+#define MULADDC_CORE \
+ asm( "lodsl " ); \
+ asm( "mull %ebx " ); \
+ asm( "addl %ecx, %eax " ); \
+ asm( "adcl $0, %edx " ); \
+ asm( "addl (%edi), %eax " ); \
+ asm( "adcl $0, %edx " ); \
+ asm( "movl %edx, %ecx " ); \
+ asm( "stosl " );
+
+#if defined(POLARSSL_HAVE_SSE2)
+
+#define MULADDC_HUIT \
+ asm( "movd %ecx, %mm1 " ); \
+ asm( "movd %ebx, %mm0 " ); \
+ asm( "movd (%edi), %mm3 " ); \
+ asm( "paddq %mm3, %mm1 " ); \
+ asm( "movd (%esi), %mm2 " ); \
+ asm( "pmuludq %mm0, %mm2 " ); \
+ asm( "movd 4(%esi), %mm4 " ); \
+ asm( "pmuludq %mm0, %mm4 " ); \
+ asm( "movd 8(%esi), %mm6 " ); \
+ asm( "pmuludq %mm0, %mm6 " ); \
+ asm( "movd 12(%esi), %mm7 " ); \
+ asm( "pmuludq %mm0, %mm7 " ); \
+ asm( "paddq %mm2, %mm1 " ); \
+ asm( "movd 4(%edi), %mm3 " ); \
+ asm( "paddq %mm4, %mm3 " ); \
+ asm( "movd 8(%edi), %mm5 " ); \
+ asm( "paddq %mm6, %mm5 " ); \
+ asm( "movd 12(%edi), %mm4 " ); \
+ asm( "paddq %mm4, %mm7 " ); \
+ asm( "movd %mm1, (%edi) " ); \
+ asm( "movd 16(%esi), %mm2 " ); \
+ asm( "pmuludq %mm0, %mm2 " ); \
+ asm( "psrlq $32, %mm1 " ); \
+ asm( "movd 20(%esi), %mm4 " ); \
+ asm( "pmuludq %mm0, %mm4 " ); \
+ asm( "paddq %mm3, %mm1 " ); \
+ asm( "movd 24(%esi), %mm6 " ); \
+ asm( "pmuludq %mm0, %mm6 " ); \
+ asm( "movd %mm1, 4(%edi) " ); \
+ asm( "psrlq $32, %mm1 " ); \
+ asm( "movd 28(%esi), %mm3 " ); \
+ asm( "pmuludq %mm0, %mm3 " ); \
+ asm( "paddq %mm5, %mm1 " ); \
+ asm( "movd 16(%edi), %mm5 " ); \
+ asm( "paddq %mm5, %mm2 " ); \
+ asm( "movd %mm1, 8(%edi) " ); \
+ asm( "psrlq $32, %mm1 " ); \
+ asm( "paddq %mm7, %mm1 " ); \
+ asm( "movd 20(%edi), %mm5 " ); \
+ asm( "paddq %mm5, %mm4 " ); \
+ asm( "movd %mm1, 12(%edi) " ); \
+ asm( "psrlq $32, %mm1 " ); \
+ asm( "paddq %mm2, %mm1 " ); \
+ asm( "movd 24(%edi), %mm5 " ); \
+ asm( "paddq %mm5, %mm6 " ); \
+ asm( "movd %mm1, 16(%edi) " ); \
+ asm( "psrlq $32, %mm1 " ); \
+ asm( "paddq %mm4, %mm1 " ); \
+ asm( "movd 28(%edi), %mm5 " ); \
+ asm( "paddq %mm5, %mm3 " ); \
+ asm( "movd %mm1, 20(%edi) " ); \
+ asm( "psrlq $32, %mm1 " ); \
+ asm( "paddq %mm6, %mm1 " ); \
+ asm( "movd %mm1, 24(%edi) " ); \
+ asm( "psrlq $32, %mm1 " ); \
+ asm( "paddq %mm3, %mm1 " ); \
+ asm( "movd %mm1, 28(%edi) " ); \
+ asm( "addl $32, %edi " ); \
+ asm( "addl $32, %esi " ); \
+ asm( "psrlq $32, %mm1 " ); \
+ asm( "movd %mm1, %ecx " );
+
+#define MULADDC_STOP \
+ asm( "emms " ); \
+ asm( "movl %0, %%ebx " :: "m" (t)); \
+ asm( "movl %%ecx, %0 " : "=m" (c)); \
+ asm( "movl %%edi, %0 " : "=m" (d)); \
+ asm( "movl %%esi, %0 " : "=m" (s) :: \
+ "eax", "ecx", "edx", "esi", "edi" );
+
+#else
+
+#define MULADDC_STOP \
+ asm( "movl %0, %%ebx " :: "m" (t)); \
+ asm( "movl %%ecx, %0 " : "=m" (c)); \
+ asm( "movl %%edi, %0 " : "=m" (d)); \
+ asm( "movl %%esi, %0 " : "=m" (s) :: \
+ "eax", "ecx", "edx", "esi", "edi" );
+
+#endif /* SSE2 */
+#endif /* i386 */
+
+#if defined(__amd64__) || defined (__x86_64__)
+
+#define MULADDC_INIT \
+ asm( "movq %0, %%rsi " :: "m" (s)); \
+ asm( "movq %0, %%rdi " :: "m" (d)); \
+ asm( "movq %0, %%rcx " :: "m" (c)); \
+ asm( "movq %0, %%rbx " :: "m" (b)); \
+ asm( "xorq %r8, %r8 " );
+
+#define MULADDC_CORE \
+ asm( "movq (%rsi),%rax " ); \
+ asm( "mulq %rbx " ); \
+ asm( "addq $8, %rsi " ); \
+ asm( "addq %rcx, %rax " ); \
+ asm( "movq %r8, %rcx " ); \
+ asm( "adcq $0, %rdx " ); \
+ asm( "nop " ); \
+ asm( "addq %rax, (%rdi) " ); \
+ asm( "adcq %rdx, %rcx " ); \
+ asm( "addq $8, %rdi " );
+
+#define MULADDC_STOP \
+ asm( "movq %%rcx, %0 " : "=m" (c)); \
+ asm( "movq %%rdi, %0 " : "=m" (d)); \
+ asm( "movq %%rsi, %0 " : "=m" (s) :: \
+ "rax", "rcx", "rdx", "rbx", "rsi", "rdi", "r8" );
+
+#endif /* AMD64 */
+
+#if defined(__mc68020__) || defined(__mcpu32__)
+
+#define MULADDC_INIT \
+ asm( "movl %0, %%a2 " :: "m" (s)); \
+ asm( "movl %0, %%a3 " :: "m" (d)); \
+ asm( "movl %0, %%d3 " :: "m" (c)); \
+ asm( "movl %0, %%d2 " :: "m" (b)); \
+ asm( "moveq #0, %d0 " );
+
+#define MULADDC_CORE \
+ asm( "movel %a2@+, %d1 " ); \
+ asm( "mulul %d2, %d4:%d1 " ); \
+ asm( "addl %d3, %d1 " ); \
+ asm( "addxl %d0, %d4 " ); \
+ asm( "moveq #0, %d3 " ); \
+ asm( "addl %d1, %a3@+ " ); \
+ asm( "addxl %d4, %d3 " );
+
+#define MULADDC_STOP \
+ asm( "movl %%d3, %0 " : "=m" (c)); \
+ asm( "movl %%a3, %0 " : "=m" (d)); \
+ asm( "movl %%a2, %0 " : "=m" (s) :: \
+ "d0", "d1", "d2", "d3", "d4", "a2", "a3" );
+
+#define MULADDC_HUIT \
+ asm( "movel %a2@+, %d1 " ); \
+ asm( "mulul %d2, %d4:%d1 " ); \
+ asm( "addxl %d3, %d1 " ); \
+ asm( "addxl %d0, %d4 " ); \
+ asm( "addl %d1, %a3@+ " ); \
+ asm( "movel %a2@+, %d1 " ); \
+ asm( "mulul %d2, %d3:%d1 " ); \
+ asm( "addxl %d4, %d1 " ); \
+ asm( "addxl %d0, %d3 " ); \
+ asm( "addl %d1, %a3@+ " ); \
+ asm( "movel %a2@+, %d1 " ); \
+ asm( "mulul %d2, %d4:%d1 " ); \
+ asm( "addxl %d3, %d1 " ); \
+ asm( "addxl %d0, %d4 " ); \
+ asm( "addl %d1, %a3@+ " ); \
+ asm( "movel %a2@+, %d1 " ); \
+ asm( "mulul %d2, %d3:%d1 " ); \
+ asm( "addxl %d4, %d1 " ); \
+ asm( "addxl %d0, %d3 " ); \
+ asm( "addl %d1, %a3@+ " ); \
+ asm( "movel %a2@+, %d1 " ); \
+ asm( "mulul %d2, %d4:%d1 " ); \
+ asm( "addxl %d3, %d1 " ); \
+ asm( "addxl %d0, %d4 " ); \
+ asm( "addl %d1, %a3@+ " ); \
+ asm( "movel %a2@+, %d1 " ); \
+ asm( "mulul %d2, %d3:%d1 " ); \
+ asm( "addxl %d4, %d1 " ); \
+ asm( "addxl %d0, %d3 " ); \
+ asm( "addl %d1, %a3@+ " ); \
+ asm( "movel %a2@+, %d1 " ); \
+ asm( "mulul %d2, %d4:%d1 " ); \
+ asm( "addxl %d3, %d1 " ); \
+ asm( "addxl %d0, %d4 " ); \
+ asm( "addl %d1, %a3@+ " ); \
+ asm( "movel %a2@+, %d1 " ); \
+ asm( "mulul %d2, %d3:%d1 " ); \
+ asm( "addxl %d4, %d1 " ); \
+ asm( "addxl %d0, %d3 " ); \
+ asm( "addl %d1, %a3@+ " ); \
+ asm( "addxl %d0, %d3 " );
+
+#endif /* MC68000 */
+
+#if defined(__powerpc__) || defined(__ppc__)
+#if defined(__powerpc64__) || defined(__ppc64__)
+
+#if defined(__MACH__) && defined(__APPLE__)
+
+#define MULADDC_INIT \
+ asm( "ld r3, %0 " :: "m" (s)); \
+ asm( "ld r4, %0 " :: "m" (d)); \
+ asm( "ld r5, %0 " :: "m" (c)); \
+ asm( "ld r6, %0 " :: "m" (b)); \
+ asm( "addi r3, r3, -8 " ); \
+ asm( "addi r4, r4, -8 " ); \
+ asm( "addic r5, r5, 0 " );
+
+#define MULADDC_CORE \
+ asm( "ldu r7, 8(r3) " ); \
+ asm( "mulld r8, r7, r6 " ); \
+ asm( "mulhdu r9, r7, r6 " ); \
+ asm( "adde r8, r8, r5 " ); \
+ asm( "ld r7, 8(r4) " ); \
+ asm( "addze r5, r9 " ); \
+ asm( "addc r8, r8, r7 " ); \
+ asm( "stdu r8, 8(r4) " );
+
+#define MULADDC_STOP \
+ asm( "addze r5, r5 " ); \
+ asm( "addi r4, r4, 8 " ); \
+ asm( "addi r3, r3, 8 " ); \
+ asm( "std r5, %0 " : "=m" (c)); \
+ asm( "std r4, %0 " : "=m" (d)); \
+ asm( "std r3, %0 " : "=m" (s) :: \
+ "r3", "r4", "r5", "r6", "r7", "r8", "r9" );
+
+#else
+
+#define MULADDC_INIT \
+ asm( "ld %%r3, %0 " :: "m" (s)); \
+ asm( "ld %%r4, %0 " :: "m" (d)); \
+ asm( "ld %%r5, %0 " :: "m" (c)); \
+ asm( "ld %%r6, %0 " :: "m" (b)); \
+ asm( "addi %r3, %r3, -8 " ); \
+ asm( "addi %r4, %r4, -8 " ); \
+ asm( "addic %r5, %r5, 0 " );
+
+#define MULADDC_CORE \
+ asm( "ldu %r7, 8(%r3) " ); \
+ asm( "mulld %r8, %r7, %r6 " ); \
+ asm( "mulhdu %r9, %r7, %r6 " ); \
+ asm( "adde %r8, %r8, %r5 " ); \
+ asm( "ld %r7, 8(%r4) " ); \
+ asm( "addze %r5, %r9 " ); \
+ asm( "addc %r8, %r8, %r7 " ); \
+ asm( "stdu %r8, 8(%r4) " );
+
+#define MULADDC_STOP \
+ asm( "addze %r5, %r5 " ); \
+ asm( "addi %r4, %r4, 8 " ); \
+ asm( "addi %r3, %r3, 8 " ); \
+ asm( "std %%r5, %0 " : "=m" (c)); \
+ asm( "std %%r4, %0 " : "=m" (d)); \
+ asm( "std %%r3, %0 " : "=m" (s) :: \
+ "r3", "r4", "r5", "r6", "r7", "r8", "r9" );
+
+#endif
+
+#else /* PPC32 */
+
+#if defined(__MACH__) && defined(__APPLE__)
+
+#define MULADDC_INIT \
+ asm( "lwz r3, %0 " :: "m" (s)); \
+ asm( "lwz r4, %0 " :: "m" (d)); \
+ asm( "lwz r5, %0 " :: "m" (c)); \
+ asm( "lwz r6, %0 " :: "m" (b)); \
+ asm( "addi r3, r3, -4 " ); \
+ asm( "addi r4, r4, -4 " ); \
+ asm( "addic r5, r5, 0 " );
+
+#define MULADDC_CORE \
+ asm( "lwzu r7, 4(r3) " ); \
+ asm( "mullw r8, r7, r6 " ); \
+ asm( "mulhwu r9, r7, r6 " ); \
+ asm( "adde r8, r8, r5 " ); \
+ asm( "lwz r7, 4(r4) " ); \
+ asm( "addze r5, r9 " ); \
+ asm( "addc r8, r8, r7 " ); \
+ asm( "stwu r8, 4(r4) " );
+
+#define MULADDC_STOP \
+ asm( "addze r5, r5 " ); \
+ asm( "addi r4, r4, 4 " ); \
+ asm( "addi r3, r3, 4 " ); \
+ asm( "stw r5, %0 " : "=m" (c)); \
+ asm( "stw r4, %0 " : "=m" (d)); \
+ asm( "stw r3, %0 " : "=m" (s) :: \
+ "r3", "r4", "r5", "r6", "r7", "r8", "r9" );
+
+#else
+
+#define MULADDC_INIT \
+ asm( "lwz %%r3, %0 " :: "m" (s)); \
+ asm( "lwz %%r4, %0 " :: "m" (d)); \
+ asm( "lwz %%r5, %0 " :: "m" (c)); \
+ asm( "lwz %%r6, %0 " :: "m" (b)); \
+ asm( "addi %r3, %r3, -4 " ); \
+ asm( "addi %r4, %r4, -4 " ); \
+ asm( "addic %r5, %r5, 0 " );
+
+#define MULADDC_CORE \
+ asm( "lwzu %r7, 4(%r3) " ); \
+ asm( "mullw %r8, %r7, %r6 " ); \
+ asm( "mulhwu %r9, %r7, %r6 " ); \
+ asm( "adde %r8, %r8, %r5 " ); \
+ asm( "lwz %r7, 4(%r4) " ); \
+ asm( "addze %r5, %r9 " ); \
+ asm( "addc %r8, %r8, %r7 " ); \
+ asm( "stwu %r8, 4(%r4) " );
+
+#define MULADDC_STOP \
+ asm( "addze %r5, %r5 " ); \
+ asm( "addi %r4, %r4, 4 " ); \
+ asm( "addi %r3, %r3, 4 " ); \
+ asm( "stw %%r5, %0 " : "=m" (c)); \
+ asm( "stw %%r4, %0 " : "=m" (d)); \
+ asm( "stw %%r3, %0 " : "=m" (s) :: \
+ "r3", "r4", "r5", "r6", "r7", "r8", "r9" );
+
+#endif
+
+#endif /* PPC32 */
+#endif /* PPC64 */
+
+#if defined(__sparc__)
+
+#define MULADDC_INIT \
+ asm( "ld %0, %%o0 " :: "m" (s)); \
+ asm( "ld %0, %%o1 " :: "m" (d)); \
+ asm( "ld %0, %%o2 " :: "m" (c)); \
+ asm( "ld %0, %%o3 " :: "m" (b));
+
+#define MULADDC_CORE \
+ asm( "ld [%o0], %o4 " ); \
+ asm( "inc 4, %o0 " ); \
+ asm( "ld [%o1], %o5 " ); \
+ asm( "umul %o3, %o4, %o4 " ); \
+ asm( "addcc %o4, %o2, %o4 " ); \
+ asm( "rd %y, %g1 " ); \
+ asm( "addx %g1, 0, %g1 " ); \
+ asm( "addcc %o4, %o5, %o4 " ); \
+ asm( "st %o4, [%o1] " ); \
+ asm( "addx %g1, 0, %o2 " ); \
+ asm( "inc 4, %o1 " );
+
+#define MULADDC_STOP \
+ asm( "st %%o2, %0 " : "=m" (c)); \
+ asm( "st %%o1, %0 " : "=m" (d)); \
+ asm( "st %%o0, %0 " : "=m" (s) :: \
+ "g1", "o0", "o1", "o2", "o3", "o4", "o5" );
+
+#endif /* SPARCv8 */
+
+#if defined(__microblaze__) || defined(microblaze)
+
+#define MULADDC_INIT \
+ asm( "lwi r3, %0 " :: "m" (s)); \
+ asm( "lwi r4, %0 " :: "m" (d)); \
+ asm( "lwi r5, %0 " :: "m" (c)); \
+ asm( "lwi r6, %0 " :: "m" (b)); \
+ asm( "andi r7, r6, 0xffff" ); \
+ asm( "bsrli r6, r6, 16 " );
+
+#define MULADDC_CORE \
+ asm( "lhui r8, r3, 0 " ); \
+ asm( "addi r3, r3, 2 " ); \
+ asm( "lhui r9, r3, 0 " ); \
+ asm( "addi r3, r3, 2 " ); \
+ asm( "mul r10, r9, r6 " ); \
+ asm( "mul r11, r8, r7 " ); \
+ asm( "mul r12, r9, r7 " ); \
+ asm( "mul r13, r8, r6 " ); \
+ asm( "bsrli r8, r10, 16 " ); \
+ asm( "bsrli r9, r11, 16 " ); \
+ asm( "add r13, r13, r8 " ); \
+ asm( "add r13, r13, r9 " ); \
+ asm( "bslli r10, r10, 16 " ); \
+ asm( "bslli r11, r11, 16 " ); \
+ asm( "add r12, r12, r10 " ); \
+ asm( "addc r13, r13, r0 " ); \
+ asm( "add r12, r12, r11 " ); \
+ asm( "addc r13, r13, r0 " ); \
+ asm( "lwi r10, r4, 0 " ); \
+ asm( "add r12, r12, r10 " ); \
+ asm( "addc r13, r13, r0 " ); \
+ asm( "add r12, r12, r5 " ); \
+ asm( "addc r5, r13, r0 " ); \
+ asm( "swi r12, r4, 0 " ); \
+ asm( "addi r4, r4, 4 " );
+
+#define MULADDC_STOP \
+ asm( "swi r5, %0 " : "=m" (c)); \
+ asm( "swi r4, %0 " : "=m" (d)); \
+ asm( "swi r3, %0 " : "=m" (s) :: \
+ "r3", "r4" , "r5" , "r6" , "r7" , "r8" , \
+ "r9", "r10", "r11", "r12", "r13" );
+
+#endif /* MicroBlaze */
+
+#if defined(__tricore__)
+
+#define MULADDC_INIT \
+ asm( "ld.a %%a2, %0 " :: "m" (s)); \
+ asm( "ld.a %%a3, %0 " :: "m" (d)); \
+ asm( "ld.w %%d4, %0 " :: "m" (c)); \
+ asm( "ld.w %%d1, %0 " :: "m" (b)); \
+ asm( "xor %d5, %d5 " );
+
+#define MULADDC_CORE \
+ asm( "ld.w %d0, [%a2+] " ); \
+ asm( "madd.u %e2, %e4, %d0, %d1 " ); \
+ asm( "ld.w %d0, [%a3] " ); \
+ asm( "addx %d2, %d2, %d0 " ); \
+ asm( "addc %d3, %d3, 0 " ); \
+ asm( "mov %d4, %d3 " ); \
+ asm( "st.w [%a3+], %d2 " );
+
+#define MULADDC_STOP \
+ asm( "st.w %0, %%d4 " : "=m" (c)); \
+ asm( "st.a %0, %%a3 " : "=m" (d)); \
+ asm( "st.a %0, %%a2 " : "=m" (s) :: \
+ "d0", "d1", "e2", "d4", "a2", "a3" );
+
+#endif /* TriCore */
+
+#if defined(__arm__)
+
+#define MULADDC_INIT \
+ asm( "ldr r0, %0 " :: "m" (s)); \
+ asm( "ldr r1, %0 " :: "m" (d)); \
+ asm( "ldr r2, %0 " :: "m" (c)); \
+ asm( "ldr r3, %0 " :: "m" (b));
+
+#define MULADDC_CORE \
+ asm( "ldr r4, [r0], #4 " ); \
+ asm( "mov r5, #0 " ); \
+ asm( "ldr r6, [r1] " ); \
+ asm( "umlal r2, r5, r3, r4 " ); \
+ asm( "adds r7, r6, r2 " ); \
+ asm( "adc r2, r5, #0 " ); \
+ asm( "str r7, [r1], #4 " );
+
+#define MULADDC_STOP \
+ asm( "str r2, %0 " : "=m" (c)); \
+ asm( "str r1, %0 " : "=m" (d)); \
+ asm( "str r0, %0 " : "=m" (s) :: \
+ "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7" );
+
+#endif /* ARMv3 */
+
+#if defined(__alpha__)
+
+#define MULADDC_INIT \
+ asm( "ldq $1, %0 " :: "m" (s)); \
+ asm( "ldq $2, %0 " :: "m" (d)); \
+ asm( "ldq $3, %0 " :: "m" (c)); \
+ asm( "ldq $4, %0 " :: "m" (b));
+
+#define MULADDC_CORE \
+ asm( "ldq $6, 0($1) " ); \
+ asm( "addq $1, 8, $1 " ); \
+ asm( "mulq $6, $4, $7 " ); \
+ asm( "umulh $6, $4, $6 " ); \
+ asm( "addq $7, $3, $7 " ); \
+ asm( "cmpult $7, $3, $3 " ); \
+ asm( "ldq $5, 0($2) " ); \
+ asm( "addq $7, $5, $7 " ); \
+ asm( "cmpult $7, $5, $5 " ); \
+ asm( "stq $7, 0($2) " ); \
+ asm( "addq $2, 8, $2 " ); \
+ asm( "addq $6, $3, $3 " ); \
+ asm( "addq $5, $3, $3 " );
+
+#define MULADDC_STOP \
+ asm( "stq $3, %0 " : "=m" (c)); \
+ asm( "stq $2, %0 " : "=m" (d)); \
+ asm( "stq $1, %0 " : "=m" (s) :: \
+ "$1", "$2", "$3", "$4", "$5", "$6", "$7" );
+
+#endif /* Alpha */
+
+#if defined(__mips__)
+
+#define MULADDC_INIT \
+ asm( "lw $10, %0 " :: "m" (s)); \
+ asm( "lw $11, %0 " :: "m" (d)); \
+ asm( "lw $12, %0 " :: "m" (c)); \
+ asm( "lw $13, %0 " :: "m" (b));
+
+#define MULADDC_CORE \
+ asm( "lw $14, 0($10) " ); \
+ asm( "multu $13, $14 " ); \
+ asm( "addi $10, $10, 4 " ); \
+ asm( "mflo $14 " ); \
+ asm( "mfhi $9 " ); \
+ asm( "addu $14, $12, $14 " ); \
+ asm( "lw $15, 0($11) " ); \
+ asm( "sltu $12, $14, $12 " ); \
+ asm( "addu $15, $14, $15 " ); \
+ asm( "sltu $14, $15, $14 " ); \
+ asm( "addu $12, $12, $9 " ); \
+ asm( "sw $15, 0($11) " ); \
+ asm( "addu $12, $12, $14 " ); \
+ asm( "addi $11, $11, 4 " );
+
+#define MULADDC_STOP \
+ asm( "sw $12, %0 " : "=m" (c)); \
+ asm( "sw $11, %0 " : "=m" (d)); \
+ asm( "sw $10, %0 " : "=m" (s) :: \
+ "$9", "$10", "$11", "$12", "$13", "$14", "$15" );
+
+#endif /* MIPS */
+#endif /* GNUC */
+
+#if (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)
+
+#define MULADDC_INIT \
+ __asm mov esi, s \
+ __asm mov edi, d \
+ __asm mov ecx, c \
+ __asm mov ebx, b
+
+#define MULADDC_CORE \
+ __asm lodsd \
+ __asm mul ebx \
+ __asm add eax, ecx \
+ __asm adc edx, 0 \
+ __asm add eax, [edi] \
+ __asm adc edx, 0 \
+ __asm mov ecx, edx \
+ __asm stosd
+
+#if defined(POLARSSL_HAVE_SSE2)
+
+#define EMIT __asm _emit
+
+#define MULADDC_HUIT \
+ EMIT 0x0F EMIT 0x6E EMIT 0xC9 \
+ EMIT 0x0F EMIT 0x6E EMIT 0xC3 \
+ EMIT 0x0F EMIT 0x6E EMIT 0x1F \
+ EMIT 0x0F EMIT 0xD4 EMIT 0xCB \
+ EMIT 0x0F EMIT 0x6E EMIT 0x16 \
+ EMIT 0x0F EMIT 0xF4 EMIT 0xD0 \
+ EMIT 0x0F EMIT 0x6E EMIT 0x66 EMIT 0x04 \
+ EMIT 0x0F EMIT 0xF4 EMIT 0xE0 \
+ EMIT 0x0F EMIT 0x6E EMIT 0x76 EMIT 0x08 \
+ EMIT 0x0F EMIT 0xF4 EMIT 0xF0 \
+ EMIT 0x0F EMIT 0x6E EMIT 0x7E EMIT 0x0C \
+ EMIT 0x0F EMIT 0xF4 EMIT 0xF8 \
+ EMIT 0x0F EMIT 0xD4 EMIT 0xCA \
+ EMIT 0x0F EMIT 0x6E EMIT 0x5F EMIT 0x04 \
+ EMIT 0x0F EMIT 0xD4 EMIT 0xDC \
+ EMIT 0x0F EMIT 0x6E EMIT 0x6F EMIT 0x08 \
+ EMIT 0x0F EMIT 0xD4 EMIT 0xEE \
+ EMIT 0x0F EMIT 0x6E EMIT 0x67 EMIT 0x0C \
+ EMIT 0x0F EMIT 0xD4 EMIT 0xFC \
+ EMIT 0x0F EMIT 0x7E EMIT 0x0F \
+ EMIT 0x0F EMIT 0x6E EMIT 0x56 EMIT 0x10 \
+ EMIT 0x0F EMIT 0xF4 EMIT 0xD0 \
+ EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \
+ EMIT 0x0F EMIT 0x6E EMIT 0x66 EMIT 0x14 \
+ EMIT 0x0F EMIT 0xF4 EMIT 0xE0 \
+ EMIT 0x0F EMIT 0xD4 EMIT 0xCB \
+ EMIT 0x0F EMIT 0x6E EMIT 0x76 EMIT 0x18 \
+ EMIT 0x0F EMIT 0xF4 EMIT 0xF0 \
+ EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x04 \
+ EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \
+ EMIT 0x0F EMIT 0x6E EMIT 0x5E EMIT 0x1C \
+ EMIT 0x0F EMIT 0xF4 EMIT 0xD8 \
+ EMIT 0x0F EMIT 0xD4 EMIT 0xCD \
+ EMIT 0x0F EMIT 0x6E EMIT 0x6F EMIT 0x10 \
+ EMIT 0x0F EMIT 0xD4 EMIT 0xD5 \
+ EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x08 \
+ EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \
+ EMIT 0x0F EMIT 0xD4 EMIT 0xCF \
+ EMIT 0x0F EMIT 0x6E EMIT 0x6F EMIT 0x14 \
+ EMIT 0x0F EMIT 0xD4 EMIT 0xE5 \
+ EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x0C \
+ EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \
+ EMIT 0x0F EMIT 0xD4 EMIT 0xCA \
+ EMIT 0x0F EMIT 0x6E EMIT 0x6F EMIT 0x18 \
+ EMIT 0x0F EMIT 0xD4 EMIT 0xF5 \
+ EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x10 \
+ EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \
+ EMIT 0x0F EMIT 0xD4 EMIT 0xCC \
+ EMIT 0x0F EMIT 0x6E EMIT 0x6F EMIT 0x1C \
+ EMIT 0x0F EMIT 0xD4 EMIT 0xDD \
+ EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x14 \
+ EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \
+ EMIT 0x0F EMIT 0xD4 EMIT 0xCE \
+ EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x18 \
+ EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \
+ EMIT 0x0F EMIT 0xD4 EMIT 0xCB \
+ EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x1C \
+ EMIT 0x83 EMIT 0xC7 EMIT 0x20 \
+ EMIT 0x83 EMIT 0xC6 EMIT 0x20 \
+ EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \
+ EMIT 0x0F EMIT 0x7E EMIT 0xC9
+
+#define MULADDC_STOP \
+ EMIT 0x0F EMIT 0x77 \
+ __asm mov c, ecx \
+ __asm mov d, edi \
+ __asm mov s, esi \
+
+#else
+
+#define MULADDC_STOP \
+ __asm mov c, ecx \
+ __asm mov d, edi \
+ __asm mov s, esi \
+
+#endif /* SSE2 */
+#endif /* MSVC */
+
+#endif /* POLARSSL_HAVE_ASM */
+
+#if !defined(MULADDC_CORE)
+#if defined(POLARSSL_HAVE_LONGLONG)
+
+#define MULADDC_INIT \
+{ \
+ t_dbl r; \
+ t_int r0, r1;
+
+#define MULADDC_CORE \
+ r = *(s++) * (t_dbl) b; \
+ r0 = r; \
+ r1 = r >> biL; \
+ r0 += c; r1 += (r0 < c); \
+ r0 += *d; r1 += (r0 < *d); \
+ c = r1; *(d++) = r0;
+
+#define MULADDC_STOP \
+}
+
+#else
+#define MULADDC_INIT \
+{ \
+ t_int s0, s1, b0, b1; \
+ t_int r0, r1, rx, ry; \
+ b0 = ( b << biH ) >> biH; \
+ b1 = ( b >> biH );
+
+#define MULADDC_CORE \
+ s0 = ( *s << biH ) >> biH; \
+ s1 = ( *s >> biH ); s++; \
+ rx = s0 * b1; r0 = s0 * b0; \
+ ry = s1 * b0; r1 = s1 * b1; \
+ r1 += ( rx >> biH ); \
+ r1 += ( ry >> biH ); \
+ rx <<= biH; ry <<= biH; \
+ r0 += rx; r1 += (r0 < rx); \
+ r0 += ry; r1 += (r0 < ry); \
+ r0 += c; r1 += (r0 < c); \
+ r0 += *d; r1 += (r0 < *d); \
+ c = r1; *(d++) = r0;
+
+#define MULADDC_STOP \
+}
+
+#endif /* C (generic) */
+#endif /* C (longlong) */
+
+#endif /* bn_mul.h */
diff --git a/package/px5g/src/polarssl/.svn/text-base/config.h.svn-base b/package/px5g/src/polarssl/.svn/text-base/config.h.svn-base
new file mode 100644
index 0000000..6463e52
--- /dev/null
+++ b/package/px5g/src/polarssl/.svn/text-base/config.h.svn-base
@@ -0,0 +1,329 @@
+/**
+ * \file config.h
+ *
+ * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
+ *
+ * Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the names of PolarSSL or XySSL nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This set of compile-time options may be used to enable
+ * or disable features selectively, and reduce the global
+ * memory footprint.
+ */
+#ifndef POLARSSL_CONFIG_H
+#define POLARSSL_CONFIG_H
+
+#ifndef _CRT_SECURE_NO_DEPRECATE
+#define _CRT_SECURE_NO_DEPRECATE 1
+#endif
+
+/*
+ * Uncomment if native integers are 8-bit wide.
+ *
+#define POLARSSL_HAVE_INT8
+ */
+
+/*
+ * Uncomment if native integers are 16-bit wide.
+ *
+#define POLARSSL_HAVE_INT16
+ */
+
+/*
+ * Uncomment if the compiler supports long long.
+ */
+#define POLARSSL_HAVE_LONGLONG
+
+
+/*
+ * Uncomment to enable the use of assembly code.
+ */
+#define POLARSSL_HAVE_ASM
+
+/*
+ * Uncomment if the CPU supports SSE2 (IA-32 specific).
+ *
+#define POLARSSL_HAVE_SSE2
+ */
+
+/*
+ * Enable all SSL/TLS debugging messages.
+ */
+#define POLARSSL_DEBUG_MSG
+
+/*
+ * Enable the checkup functions (*_self_test).
+ */
+#define POLARSSL_SELF_TEST
+
+/*
+ * Enable the prime-number generation code.
+ */
+#define POLARSSL_GENPRIME
+
+/*
+ * Uncomment this macro to store the AES tables in ROM.
+ *
+#define POLARSSL_AES_ROM_TABLES
+ */
+
+/*
+ * Module: library/aes.c
+ * Caller: library/ssl_tls.c
+ *
+ * This module enables the following ciphersuites:
+ * SSL_RSA_AES_128_SHA
+ * SSL_RSA_AES_256_SHA
+ * SSL_EDH_RSA_AES_256_SHA
+ */
+#define POLARSSL_AES_C
+
+/*
+ * Module: library/arc4.c
+ * Caller: library/ssl_tls.c
+ *
+ * This module enables the following ciphersuites:
+ * SSL_RSA_RC4_128_MD5
+ * SSL_RSA_RC4_128_SHA
+ */
+#define POLARSSL_ARC4_C
+
+/*
+ * Module: library/base64.c
+ * Caller: library/x509parse.c
+ *
+ * This module is required for X.509 support.
+ */
+#define POLARSSL_BASE64_C
+
+/*
+ * Module: library/bignum.c
+ * Caller: library/dhm.c
+ * library/rsa.c
+ * library/ssl_tls.c
+ * library/x509parse.c
+ *
+ * This module is required for RSA and DHM support.
+ */
+#define POLARSSL_BIGNUM_C
+
+/*
+ * Module: library/camellia.c
+ * Caller:
+ *
+ * This module enabled the following cipher suites:
+ */
+#define POLARSSL_CAMELLIA_C
+
+/*
+ * Module: library/certs.c
+ * Caller:
+ *
+ * This module is used for testing (ssl_client/server).
+ */
+#define POLARSSL_CERTS_C
+
+/*
+ * Module: library/debug.c
+ * Caller: library/ssl_cli.c
+ * library/ssl_srv.c
+ * library/ssl_tls.c
+ *
+ * This module provides debugging functions.
+ */
+#define POLARSSL_DEBUG_C
+
+/*
+ * Module: library/des.c
+ * Caller: library/ssl_tls.c
+ *
+ * This module enables the following ciphersuites:
+ * SSL_RSA_DES_168_SHA
+ * SSL_EDH_RSA_DES_168_SHA
+ */
+#define POLARSSL_DES_C
+
+/*
+ * Module: library/dhm.c
+ * Caller: library/ssl_cli.c
+ * library/ssl_srv.c
+ *
+ * This module enables the following ciphersuites:
+ * SSL_EDH_RSA_DES_168_SHA
+ * SSL_EDH_RSA_AES_256_SHA
+ */
+#define POLARSSL_DHM_C
+
+/*
+ * Module: library/havege.c
+ * Caller:
+ *
+ * This module enables the HAVEGE random number generator.
+ */
+#define POLARSSL_HAVEGE_C
+
+/*
+ * Module: library/md2.c
+ * Caller: library/x509parse.c
+ *
+ * Uncomment to enable support for (rare) MD2-signed X.509 certs.
+ *
+#define POLARSSL_MD2_C
+ */
+
+/*
+ * Module: library/md4.c
+ * Caller: library/x509parse.c
+ *
+ * Uncomment to enable support for (rare) MD4-signed X.509 certs.
+ *
+#define POLARSSL_MD4_C
+ */
+
+/*
+ * Module: library/md5.c
+ * Caller: library/ssl_tls.c
+ * library/x509parse.c
+ *
+ * This module is required for SSL/TLS and X.509.
+ */
+#define POLARSSL_MD5_C
+
+/*
+ * Module: library/net.c
+ * Caller:
+ *
+ * This module provides TCP/IP networking routines.
+ */
+#define POLARSSL_NET_C
+
+/*
+ * Module: library/padlock.c
+ * Caller: library/aes.c
+ *
+ * This modules adds support for the VIA PadLock on x86.
+ */
+#define POLARSSL_PADLOCK_C
+
+/*
+ * Module: library/rsa.c
+ * Caller: library/ssl_cli.c
+ * library/ssl_srv.c
+ * library/ssl_tls.c
+ * library/x509.c
+ *
+ * This module is required for SSL/TLS and MD5-signed certificates.
+ */
+#define POLARSSL_RSA_C
+
+/*
+ * Module: library/sha1.c
+ * Caller: library/ssl_cli.c
+ * library/ssl_srv.c
+ * library/ssl_tls.c
+ * library/x509parse.c
+ *
+ * This module is required for SSL/TLS and SHA1-signed certificates.
+ */
+#define POLARSSL_SHA1_C
+
+/*
+ * Module: library/sha2.c
+ * Caller:
+ *
+ * This module adds support for SHA-224 and SHA-256.
+ */
+#define POLARSSL_SHA2_C
+
+/*
+ * Module: library/sha4.c
+ * Caller:
+ *
+ * This module adds support for SHA-384 and SHA-512.
+ */
+#define POLARSSL_SHA4_C
+
+/*
+ * Module: library/ssl_cli.c
+ * Caller:
+ *
+ * This module is required for SSL/TLS client support.
+ */
+#define POLARSSL_SSL_CLI_C
+
+/*
+ * Module: library/ssl_srv.c
+ * Caller:
+ *
+ * This module is required for SSL/TLS server support.
+ */
+#define POLARSSL_SSL_SRV_C
+
+/*
+ * Module: library/ssl_tls.c
+ * Caller: library/ssl_cli.c
+ * library/ssl_srv.c
+ *
+ * This module is required for SSL/TLS.
+ */
+#define POLARSSL_SSL_TLS_C
+
+/*
+ * Module: library/timing.c
+ * Caller: library/havege.c
+ *
+ * This module is used by the HAVEGE random number generator.
+ */
+#define POLARSSL_TIMING_C
+
+/*
+ * Module: library/x509parse.c
+ * Caller: library/ssl_cli.c
+ * library/ssl_srv.c
+ * library/ssl_tls.c
+ *
+ * This module is required for X.509 certificate parsing.
+ */
+#define POLARSSL_X509_PARSE_C
+
+/*
+ * Module: library/x509_write.c
+ * Caller:
+ *
+ * This module is required for X.509 certificate writing.
+ */
+#define POLARSSL_X509_WRITE_C
+
+/*
+ * Module: library/xtea.c
+ * Caller:
+ */
+#define POLARSSL_XTEA_C
+
+#endif /* config.h */
diff --git a/package/px5g/src/polarssl/.svn/text-base/havege.h.svn-base b/package/px5g/src/polarssl/.svn/text-base/havege.h.svn-base
new file mode 100644
index 0000000..c27ceca
--- /dev/null
+++ b/package/px5g/src/polarssl/.svn/text-base/havege.h.svn-base
@@ -0,0 +1,75 @@
+/**
+ * \file havege.h
+ *
+ * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
+ *
+ * Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the names of PolarSSL or XySSL nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef POLARSSL_HAVEGE_H
+#define POLARSSL_HAVEGE_H
+
+#define COLLECT_SIZE 1024
+
+/**
+ * \brief HAVEGE state structure
+ */
+typedef struct
+{
+ int PT1, PT2, offset[2];
+ int pool[COLLECT_SIZE];
+ int WALK[8192];
+}
+havege_state;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \brief HAVEGE initialization
+ *
+ * \param hs HAVEGE state to be initialized
+ */
+void havege_init( havege_state *hs );
+
+/**
+ * \brief HAVEGE rand function
+ *
+ * \param rng_st points to an HAVEGE state
+ *
+ * \return A random int
+ */
+int havege_rand( void *p_rng );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* havege.h */
diff --git a/package/px5g/src/polarssl/.svn/text-base/rsa.h.svn-base b/package/px5g/src/polarssl/.svn/text-base/rsa.h.svn-base
new file mode 100644
index 0000000..b31dc2f
--- /dev/null
+++ b/package/px5g/src/polarssl/.svn/text-base/rsa.h.svn-base
@@ -0,0 +1,309 @@
+/**
+ * \file rsa.h
+ *
+ * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
+ *
+ * Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the names of PolarSSL or XySSL nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef POLARSSL_RSA_H
+#define POLARSSL_RSA_H
+
+#include "polarssl/bignum.h"
+
+#define POLARSSL_ERR_RSA_BAD_INPUT_DATA -0x0400
+#define POLARSSL_ERR_RSA_INVALID_PADDING -0x0410
+#define POLARSSL_ERR_RSA_KEY_GEN_FAILED -0x0420
+#define POLARSSL_ERR_RSA_KEY_CHECK_FAILED -0x0430
+#define POLARSSL_ERR_RSA_PUBLIC_FAILED -0x0440
+#define POLARSSL_ERR_RSA_PRIVATE_FAILED -0x0450
+#define POLARSSL_ERR_RSA_VERIFY_FAILED -0x0460
+#define POLARSSL_ERR_RSA_OUTPUT_TO_LARGE -0x0470
+
+/*
+ * PKCS#1 constants
+ */
+#define RSA_RAW 0
+#define RSA_MD2 2
+#define RSA_MD4 3
+#define RSA_MD5 4
+#define RSA_SHA1 5
+#define RSA_SHA256 6
+
+#define RSA_PUBLIC 0
+#define RSA_PRIVATE 1
+
+#define RSA_PKCS_V15 0
+#define RSA_PKCS_V21 1
+
+#define RSA_SIGN 1
+#define RSA_CRYPT 2
+
+/*
+ * DigestInfo ::= SEQUENCE {
+ * digestAlgorithm DigestAlgorithmIdentifier,
+ * digest Digest }
+ *
+ * DigestAlgorithmIdentifier ::= AlgorithmIdentifier
+ *
+ * Digest ::= OCTET STRING
+ */
+#define ASN1_HASH_MDX \
+ "\x30\x20\x30\x0C\x06\x08\x2A\x86\x48" \
+ "\x86\xF7\x0D\x02\x00\x05\x00\x04\x10"
+
+#define ASN1_HASH_SHA1 \
+ "\x30\x21\x30\x09\x06\x05\x2B\x0E\x03" \
+ "\x02\x1A\x05\x00\x04\x14"
+
+/**
+ * \brief RSA context structure
+ */
+typedef struct
+{
+ int ver; /*!< always 0 */
+ int len; /*!< size(N) in chars */
+
+ mpi N; /*!< public modulus */
+ mpi E; /*!< public exponent */
+
+ mpi D; /*!< private exponent */
+ mpi P; /*!< 1st prime factor */
+ mpi Q; /*!< 2nd prime factor */
+ mpi DP; /*!< D % (P - 1) */
+ mpi DQ; /*!< D % (Q - 1) */
+ mpi QP; /*!< 1 / (Q % P) */
+
+ mpi RN; /*!< cached R^2 mod N */
+ mpi RP; /*!< cached R^2 mod P */
+ mpi RQ; /*!< cached R^2 mod Q */
+
+ int padding; /*!< 1.5 or OAEP/PSS */
+ int hash_id; /*!< hash identifier */
+ int (*f_rng)(void *); /*!< RNG function */
+ void *p_rng; /*!< RNG parameter */
+}
+rsa_context;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \brief Initialize an RSA context
+ *
+ * \param ctx RSA context to be initialized
+ * \param padding RSA_PKCS_V15 or RSA_PKCS_V21
+ * \param hash_id RSA_PKCS_V21 hash identifier
+ * \param f_rng RNG function
+ * \param p_rng RNG parameter
+ *
+ * \note The hash_id parameter is actually ignored
+ * when using RSA_PKCS_V15 padding.
+ *
+ * \note Currently (xyssl-0.8), RSA_PKCS_V21 padding
+ * is not supported.
+ */
+void rsa_init( rsa_context *ctx,
+ int padding,
+ int hash_id,
+ int (*f_rng)(void *),
+ void *p_rng );
+
+/**
+ * \brief Generate an RSA keypair
+ *
+ * \param ctx RSA context that will hold the key
+ * \param nbits size of the public key in bits
+ * \param exponent public exponent (e.g., 65537)
+ *
+ * \note rsa_init() must be called beforehand to setup
+ * the RSA context (especially f_rng and p_rng).
+ *
+ * \return 0 if successful, or an POLARSSL_ERR_RSA_XXX error code
+ */
+int rsa_gen_key( rsa_context *ctx, int nbits, int exponent );
+
+/**
+ * \brief Check a public RSA key
+ *
+ * \param ctx RSA context to be checked
+ *
+ * \return 0 if successful, or an POLARSSL_ERR_RSA_XXX error code
+ */
+int rsa_check_pubkey( rsa_context *ctx );
+
+/**
+ * \brief Check a private RSA key
+ *
+ * \param ctx RSA context to be checked
+ *
+ * \return 0 if successful, or an POLARSSL_ERR_RSA_XXX error code
+ */
+int rsa_check_privkey( rsa_context *ctx );
+
+/**
+ * \brief Do an RSA public key operation
+ *
+ * \param ctx RSA context
+ * \param input input buffer
+ * \param output output buffer
+ *
+ * \return 0 if successful, or an POLARSSL_ERR_RSA_XXX error code
+ *
+ * \note This function does NOT take care of message
+ * padding. Also, be sure to set input[0] = 0.
+ *
+ * \note The input and output buffers must be large
+ * enough (eg. 128 bytes if RSA-1024 is used).
+ */
+int rsa_public( rsa_context *ctx,
+ unsigned char *input,
+ unsigned char *output );
+
+/**
+ * \brief Do an RSA private key operation
+ *
+ * \param ctx RSA context
+ * \param input input buffer
+ * \param output output buffer
+ *
+ * \return 0 if successful, or an POLARSSL_ERR_RSA_XXX error code
+ *
+ * \note The input and output buffers must be large
+ * enough (eg. 128 bytes if RSA-1024 is used).
+ */
+int rsa_private( rsa_context *ctx,
+ unsigned char *input,
+ unsigned char *output );
+
+/**
+ * \brief Add the message padding, then do an RSA operation
+ *
+ * \param ctx RSA context
+ * \param mode RSA_PUBLIC or RSA_PRIVATE
+ * \param ilen contains the the plaintext length
+ * \param input buffer holding the data to be encrypted
+ * \param output buffer that will hold the ciphertext
+ *
+ * \return 0 if successful, or an POLARSSL_ERR_RSA_XXX error code
+ *
+ * \note The output buffer must be as large as the size
+ * of ctx->N (eg. 128 bytes if RSA-1024 is used).
+ */
+int rsa_pkcs1_encrypt( rsa_context *ctx,
+ int mode, int ilen,
+ unsigned char *input,
+ unsigned char *output );
+
+/**
+ * \brief Do an RSA operation, then remove the message padding
+ *
+ * \param ctx RSA context
+ * \param mode RSA_PUBLIC or RSA_PRIVATE
+ * \param input buffer holding the encrypted data
+ * \param output buffer that will hold the plaintext
+ * \param olen will contain the plaintext length
+ * \param output_max_len maximum length of the output buffer
+ *
+ * \return 0 if successful, or an POLARSSL_ERR_RSA_XXX error code
+ *
+ * \note The output buffer must be as large as the size
+ * of ctx->N (eg. 128 bytes if RSA-1024 is used) otherwise
+ * an error is thrown.
+ */
+int rsa_pkcs1_decrypt( rsa_context *ctx,
+ int mode, int *olen,
+ unsigned char *input,
+ unsigned char *output,
+ int output_max_len);
+
+/**
+ * \brief Do a private RSA to sign a message digest
+ *
+ * \param ctx RSA context
+ * \param mode RSA_PUBLIC or RSA_PRIVATE
+ * \param hash_id RSA_RAW, RSA_MD{2,4,5} or RSA_SHA{1,256}
+ * \param hashlen message digest length (for RSA_RAW only)
+ * \param hash buffer holding the message digest
+ * \param sig buffer that will hold the ciphertext
+ *
+ * \return 0 if the signing operation was successful,
+ * or an POLARSSL_ERR_RSA_XXX error code
+ *
+ * \note The "sig" buffer must be as large as the size
+ * of ctx->N (eg. 128 bytes if RSA-1024 is used).
+ */
+int rsa_pkcs1_sign( rsa_context *ctx,
+ int mode,
+ int hash_id,
+ int hashlen,
+ unsigned char *hash,
+ unsigned char *sig );
+
+/**
+ * \brief Do a public RSA and check the message digest
+ *
+ * \param ctx points to an RSA public key
+ * \param mode RSA_PUBLIC or RSA_PRIVATE
+ * \param hash_id RSA_RAW, RSA_MD{2,4,5} or RSA_SHA{1,256}
+ * \param hashlen message digest length (for RSA_RAW only)
+ * \param hash buffer holding the message digest
+ * \param sig buffer holding the ciphertext
+ *
+ * \return 0 if the verify operation was successful,
+ * or an POLARSSL_ERR_RSA_XXX error code
+ *
+ * \note The "sig" buffer must be as large as the size
+ * of ctx->N (eg. 128 bytes if RSA-1024 is used).
+ */
+int rsa_pkcs1_verify( rsa_context *ctx,
+ int mode,
+ int hash_id,
+ int hashlen,
+ unsigned char *hash,
+ unsigned char *sig );
+
+/**
+ * \brief Free the components of an RSA key
+ */
+void rsa_free( rsa_context *ctx );
+
+/**
+ * \brief Checkup routine
+ *
+ * \return 0 if successful, or 1 if the test failed
+ */
+int rsa_self_test( int verbose );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* rsa.h */
diff --git a/package/px5g/src/polarssl/.svn/text-base/sha1.h.svn-base b/package/px5g/src/polarssl/.svn/text-base/sha1.h.svn-base
new file mode 100644
index 0000000..3ca7dc3
--- /dev/null
+++ b/package/px5g/src/polarssl/.svn/text-base/sha1.h.svn-base
@@ -0,0 +1,150 @@
+/**
+ * \file sha1.h
+ *
+ * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
+ *
+ * Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the names of PolarSSL or XySSL nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef POLARSSL_SHA1_H
+#define POLARSSL_SHA1_H
+
+/**
+ * \brief SHA-1 context structure
+ */
+typedef struct
+{
+ unsigned long total[2]; /*!< number of bytes processed */
+ unsigned long state[5]; /*!< intermediate digest state */
+ unsigned char buffer[64]; /*!< data block being processed */
+
+ unsigned char ipad[64]; /*!< HMAC: inner padding */
+ unsigned char opad[64]; /*!< HMAC: outer padding */
+}
+sha1_context;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \brief SHA-1 context setup
+ *
+ * \param ctx context to be initialized
+ */
+void sha1_starts( sha1_context *ctx );
+
+/**
+ * \brief SHA-1 process buffer
+ *
+ * \param ctx SHA-1 context
+ * \param input buffer holding the data
+ * \param ilen length of the input data
+ */
+void sha1_update( sha1_context *ctx, unsigned char *input, int ilen );
+
+/**
+ * \brief SHA-1 final digest
+ *
+ * \param ctx SHA-1 context
+ * \param output SHA-1 checksum result
+ */
+void sha1_finish( sha1_context *ctx, unsigned char output[20] );
+
+/**
+ * \brief Output = SHA-1( input buffer )
+ *
+ * \param input buffer holding the data
+ * \param ilen length of the input data
+ * \param output SHA-1 checksum result
+ */
+void sha1( unsigned char *input, int ilen, unsigned char output[20] );
+
+/**
+ * \brief Output = SHA-1( file contents )
+ *
+ * \param path input file name
+ * \param output SHA-1 checksum result
+ *
+ * \return 0 if successful, 1 if fopen failed,
+ * or 2 if fread failed
+ */
+int sha1_file( char *path, unsigned char output[20] );
+
+/**
+ * \brief SHA-1 HMAC context setup
+ *
+ * \param ctx HMAC context to be initialized
+ * \param key HMAC secret key
+ * \param keylen length of the HMAC key
+ */
+void sha1_hmac_starts( sha1_context *ctx, unsigned char *key, int keylen );
+
+/**
+ * \brief SHA-1 HMAC process buffer
+ *
+ * \param ctx HMAC context
+ * \param input buffer holding the data
+ * \param ilen length of the input data
+ */
+void sha1_hmac_update( sha1_context *ctx, unsigned char *input, int ilen );
+
+/**
+ * \brief SHA-1 HMAC final digest
+ *
+ * \param ctx HMAC context
+ * \param output SHA-1 HMAC checksum result
+ */
+void sha1_hmac_finish( sha1_context *ctx, unsigned char output[20] );
+
+/**
+ * \brief Output = HMAC-SHA-1( hmac key, input buffer )
+ *
+ * \param key HMAC secret key
+ * \param keylen length of the HMAC key
+ * \param input buffer holding the data
+ * \param ilen length of the input data
+ * \param output HMAC-SHA-1 result
+ */
+void sha1_hmac( unsigned char *key, int keylen,
+ unsigned char *input, int ilen,
+ unsigned char output[20] );
+
+/**
+ * \brief Checkup routine
+ *
+ * \return 0 if successful, or 1 if the test failed
+ */
+int sha1_self_test( int verbose );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* sha1.h */
diff --git a/package/px5g/src/polarssl/.svn/text-base/timing.h.svn-base b/package/px5g/src/polarssl/.svn/text-base/timing.h.svn-base
new file mode 100644
index 0000000..62d627f
--- /dev/null
+++ b/package/px5g/src/polarssl/.svn/text-base/timing.h.svn-base
@@ -0,0 +1,81 @@
+/**
+ * \file timing.h
+ *
+ * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
+ *
+ * Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the names of PolarSSL or XySSL nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef POLARSSL_TIMING_H
+#define POLARSSL_TIMING_H
+
+/**
+ * \brief timer structure
+ */
+struct hr_time
+{
+ unsigned char opaque[32];
+};
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern int alarmed;
+
+/**
+ * \brief Return the CPU cycle counter value
+ */
+unsigned long hardclock( void );
+
+/**
+ * \brief Return the elapsed time in milliseconds
+ *
+ * \param val points to a timer structure
+ * \param reset if set to 1, the timer is restarted
+ */
+unsigned long get_timer( struct hr_time *val, int reset );
+
+/**
+ * \brief Setup an alarm clock
+ *
+ * \param seconds delay before the "alarmed" flag is set
+ */
+void set_alarm( int seconds );
+
+/**
+ * \brief Sleep for a certain amount of time
+ */
+void m_sleep( int milliseconds );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* timing.h */
diff --git a/package/px5g/src/polarssl/.svn/text-base/x509.h.svn-base b/package/px5g/src/polarssl/.svn/text-base/x509.h.svn-base
new file mode 100644
index 0000000..908a1db
--- /dev/null
+++ b/package/px5g/src/polarssl/.svn/text-base/x509.h.svn-base
@@ -0,0 +1,549 @@
+/**
+ * \file x509.h
+ *
+ * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
+ *
+ * Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the names of PolarSSL or XySSL nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef POLARSSL_X509_H
+#define POLARSSL_X509_H
+
+#include "polarssl/rsa.h"
+
+#define POLARSSL_ERR_ASN1_OUT_OF_DATA -0x0014
+#define POLARSSL_ERR_ASN1_UNEXPECTED_TAG -0x0016
+#define POLARSSL_ERR_ASN1_INVALID_LENGTH -0x0018
+#define POLARSSL_ERR_ASN1_LENGTH_MISMATCH -0x001A
+#define POLARSSL_ERR_ASN1_INVALID_DATA -0x001C
+
+#define POLARSSL_ERR_X509_FEATURE_UNAVAILABLE -0x0020
+#define POLARSSL_ERR_X509_CERT_INVALID_PEM -0x0040
+#define POLARSSL_ERR_X509_CERT_INVALID_FORMAT -0x0060
+#define POLARSSL_ERR_X509_CERT_INVALID_VERSION -0x0080
+#define POLARSSL_ERR_X509_CERT_INVALID_SERIAL -0x00A0
+#define POLARSSL_ERR_X509_CERT_INVALID_ALG -0x00C0
+#define POLARSSL_ERR_X509_CERT_INVALID_NAME -0x00E0
+#define POLARSSL_ERR_X509_CERT_INVALID_DATE -0x0100
+#define POLARSSL_ERR_X509_CERT_INVALID_PUBKEY -0x0120
+#define POLARSSL_ERR_X509_CERT_INVALID_SIGNATURE -0x0140
+#define POLARSSL_ERR_X509_CERT_INVALID_EXTENSIONS -0x0160
+#define POLARSSL_ERR_X509_CERT_UNKNOWN_VERSION -0x0180
+#define POLARSSL_ERR_X509_CERT_UNKNOWN_SIG_ALG -0x01A0
+#define POLARSSL_ERR_X509_CERT_UNKNOWN_PK_ALG -0x01C0
+#define POLARSSL_ERR_X509_CERT_SIG_MISMATCH -0x01E0
+#define POLARSSL_ERR_X509_CERT_VERIFY_FAILED -0x0200
+#define POLARSSL_ERR_X509_KEY_INVALID_PEM -0x0220
+#define POLARSSL_ERR_X509_KEY_INVALID_VERSION -0x0240
+#define POLARSSL_ERR_X509_KEY_INVALID_FORMAT -0x0260
+#define POLARSSL_ERR_X509_KEY_INVALID_ENC_IV -0x0280
+#define POLARSSL_ERR_X509_KEY_UNKNOWN_ENC_ALG -0x02A0
+#define POLARSSL_ERR_X509_KEY_PASSWORD_REQUIRED -0x02C0
+#define POLARSSL_ERR_X509_KEY_PASSWORD_MISMATCH -0x02E0
+#define POLARSSL_ERR_X509_POINT_ERROR -0x0300
+#define POLARSSL_ERR_X509_VALUE_TO_LENGTH -0x0320
+
+#define BADCERT_EXPIRED 1
+#define BADCERT_REVOKED 2
+#define BADCERT_CN_MISMATCH 4
+#define BADCERT_NOT_TRUSTED 8
+
+/*
+ * DER constants
+ */
+#define ASN1_BOOLEAN 0x01
+#define ASN1_INTEGER 0x02
+#define ASN1_BIT_STRING 0x03
+#define ASN1_OCTET_STRING 0x04
+#define ASN1_NULL 0x05
+#define ASN1_OID 0x06
+#define ASN1_UTF8_STRING 0x0C
+#define ASN1_SEQUENCE 0x10
+#define ASN1_SET 0x11
+#define ASN1_PRINTABLE_STRING 0x13
+#define ASN1_T61_STRING 0x14
+#define ASN1_IA5_STRING 0x16
+#define ASN1_UTC_TIME 0x17
+#define ASN1_UNIVERSAL_STRING 0x1C
+#define ASN1_BMP_STRING 0x1E
+#define ASN1_PRIMITIVE 0x00
+#define ASN1_CONSTRUCTED 0x20
+#define ASN1_CONTEXT_SPECIFIC 0x80
+
+/*
+ * various object identifiers
+ */
+#define X520_COMMON_NAME 3
+#define X520_COUNTRY 6
+#define X520_LOCALITY 7
+#define X520_STATE 8
+#define X520_ORGANIZATION 10
+#define X520_ORG_UNIT 11
+#define PKCS9_EMAIL 1
+
+#define X509_OUTPUT_DER 0x01
+#define X509_OUTPUT_PEM 0x02
+#define PEM_LINE_LENGTH 72
+#define X509_ISSUER 0x01
+#define X509_SUBJECT 0x02
+
+#define OID_X520 "\x55\x04"
+#define OID_CN "\x55\x04\x03"
+#define OID_PKCS1 "\x2A\x86\x48\x86\xF7\x0D\x01\x01"
+#define OID_PKCS1_RSA "\x2A\x86\x48\x86\xF7\x0D\x01\x01\x01"
+#define OID_PKCS1_RSA_SHA "\x2A\x86\x48\x86\xF7\x0D\x01\x01\x05"
+#define OID_PKCS9 "\x2A\x86\x48\x86\xF7\x0D\x01\x09"
+#define OID_PKCS9_EMAIL "\x2A\x86\x48\x86\xF7\x0D\x01\x09\x01"
+
+/*
+ * Structures for parsing X.509 certificates
+ */
+typedef struct _x509_buf
+{
+ int tag;
+ int len;
+ unsigned char *p;
+}
+x509_buf;
+
+typedef struct _x509_name
+{
+ x509_buf oid;
+ x509_buf val;
+ struct _x509_name *next;
+}
+x509_name;
+
+typedef struct _x509_time
+{
+ int year, mon, day;
+ int hour, min, sec;
+}
+x509_time;
+
+typedef struct _x509_cert
+{
+ x509_buf raw;
+ x509_buf tbs;
+
+ int version;
+ x509_buf serial;
+ x509_buf sig_oid1;
+
+ x509_buf issuer_raw;
+ x509_buf subject_raw;
+
+ x509_name issuer;
+ x509_name subject;
+
+ x509_time valid_from;
+ x509_time valid_to;
+
+ x509_buf pk_oid;
+ rsa_context rsa;
+
+ x509_buf issuer_id;
+ x509_buf subject_id;
+ x509_buf v3_ext;
+
+ int ca_istrue;
+ int max_pathlen;
+
+ x509_buf sig_oid2;
+ x509_buf sig;
+
+ struct _x509_cert *next;
+}
+x509_cert;
+
+/*
+ * Structures for writing X.509 certificates
+ */
+typedef struct _x509_node
+{
+ unsigned char *data;
+ unsigned char *p;
+ unsigned char *end;
+
+ size_t len;
+}
+x509_node;
+
+typedef struct _x509_raw
+{
+ x509_node raw;
+ x509_node tbs;
+
+ x509_node version;
+ x509_node serial;
+ x509_node tbs_signalg;
+ x509_node issuer;
+ x509_node validity;
+ x509_node subject;
+ x509_node subpubkey;
+
+ x509_node signalg;
+ x509_node sign;
+}
+x509_raw;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \brief Parse one or more certificates and add them
+ * to the chained list
+ *
+ * \param chain points to the start of the chain
+ * \param buf buffer holding the certificate data
+ * \param buflen size of the buffer
+ *
+ * \return 0 if successful, or a specific X509 error code
+ */
+int x509parse_crt( x509_cert *crt, unsigned char *buf, int buflen );
+
+/**
+ * \brief Load one or more certificates and add them
+ * to the chained list
+ *
+ * \param chain points to the start of the chain
+ * \param path filename to read the certificates from
+ *
+ * \return 0 if successful, or a specific X509 error code
+ */
+int x509parse_crtfile( x509_cert *crt, char *path );
+
+/**
+ * \brief Parse a private RSA key
+ *
+ * \param rsa RSA context to be initialized
+ * \param buf input buffer
+ * \param buflen size of the buffer
+ * \param pwd password for decryption (optional)
+ * \param pwdlen size of the password
+ *
+ * \return 0 if successful, or a specific X509 error code
+ */
+int x509parse_key( rsa_context *rsa,
+ unsigned char *buf, int buflen,
+ unsigned char *pwd, int pwdlen );
+
+/**
+ * \brief Load and parse a private RSA key
+ *
+ * \param rsa RSA context to be initialized
+ * \param path filename to read the private key from
+ * \param pwd password to decrypt the file (can be NULL)
+ *
+ * \return 0 if successful, or a specific X509 error code
+ */
+int x509parse_keyfile( rsa_context *rsa, char *path, char *password );
+
+/**
+ * \brief Store the certificate DN in printable form into buf;
+ * no more than (end - buf) characters will be written.
+ */
+int x509parse_dn_gets( char *buf, char *end, x509_name *dn );
+
+/**
+ * \brief Returns an informational string about the
+ * certificate.
+ */
+char *x509parse_cert_info( char *prefix, x509_cert *crt );
+
+/**
+ * \brief Return 0 if the certificate is still valid,
+ * or BADCERT_EXPIRED
+ */
+int x509parse_expired( x509_cert *crt );
+
+/**
+ * \brief Verify the certificate signature
+ *
+ * \param crt a certificate to be verified
+ * \param trust_ca the trusted CA chain
+ * \param cn expected Common Name (can be set to
+ * NULL if the CN must not be verified)
+ * \param flags result of the verification
+ *
+ * \return 0 if successful or POLARSSL_ERR_X509_SIG_VERIFY_FAILED,
+ * in which case *flags will have one or more of
+ * the following values set:
+ * BADCERT_EXPIRED --
+ * BADCERT_REVOKED --
+ * BADCERT_CN_MISMATCH --
+ * BADCERT_NOT_TRUSTED
+ *
+ * \note TODO: add two arguments, depth and crl
+ */
+int x509parse_verify( x509_cert *crt,
+ x509_cert *trust_ca,
+ char *cn, int *flags );
+
+/**
+ * \brief Unallocate all certificate data
+ */
+void x509_free( x509_cert *crt );
+
+/**
+ * \brief Checkup routine
+ *
+ * \return 0 if successful, or 1 if the test failed
+ */
+int x509_self_test( int verbose );
+
+/**
+ * \brief Write a certificate info file
+ *
+ * \param chain points to the raw certificate data
+ * \param path filename to write the certificate to
+ * \param format X509_OUTPUT_DER or X509_OUTPUT_PEM
+ *
+ * \return 0 if successful, or a specific X509 error code
+ */
+int x509write_crtfile( x509_raw *chain,
+ unsigned char *path,
+ int format );
+
+/**
+ * \brief Write a certificate signing request message format file
+ *
+ * \param chain points to the raw certificate (with x509write_create_csr) data
+ * \param path filename to write the certificate to
+ * \param format X509_OUTPUT_DER or X509_OUTPUT_PEM
+ *
+ * \return 0 if successful, or a specific X509 error code
+ */
+int x509write_csrfile( x509_raw *chain,
+ unsigned char *path,
+ int format );
+
+/*
+ * \brief Write a private RSA key into a file
+ *
+ * \param rsa points to an RSA key
+ * \param path filename to write the key to
+ * \param format X509_OUTPUT_DER or X509_OUTPUT_PEM
+ *
+ * \return 0 if successful, or a specific X509 error code
+ */
+int x509write_keyfile( rsa_context *rsa,
+ char *path,
+ int format );
+
+/**
+ * \brief Add a public key to certificate
+ *
+ * \param chain points to the raw certificate data
+ * \param pubkey points to an RSA key
+ *
+ * \return 0 if successful, or a specific X509 error code
+ */
+int x509write_add_pubkey( x509_raw *chain, rsa_context *pubkey );
+
+/**
+ * \brief Create x509 subject/issuer field to raw certificate
+ * from string or CA cert. Make string NULL if you will
+ * use the CA copy function or make CA NULL then used
+ * the string parse.
+ *
+ * \param chain points to the raw certificate data
+ * \param names a string that can hold (separete with ";"):
+ * CN=CommonName
+ * -- O=Organization
+ * -- OU=OrgUnit
+ * -- ST=State
+ * -- L=Locality
+ * -- R=Email
+ * -- C=Country
+ * . Make that NULL if you didn't need that.
+ * \param flag flag is X509_ISSUER or X509_SUBJECT that defined
+ * where change
+ * \param ca the certificate for copy data. Make that NULL if you
+ * didn't need that.
+ * \param ca_flag set the ca field from copy to crt
+ *
+ * \return 0 if successful, or a specific X509 error code
+ */
+int x509write_add_customize ( x509_raw *crt,
+ unsigned char *names,
+ int flag,
+ x509_cert *ca,
+ int ca_flag );
+
+/**
+* \brief Add x509 issuer field
+*
+* \param chain points to the raw certificate data
+* \param issuer a string holding (separete with ";"):
+* CN=CommonName
+* -- O=Organization
+* -- OU=OrgUnit
+* -- ST=State
+* -- L=Locality
+* -- R=Email
+* -- C=Country
+* . Set this to NULL if not needed.
+* \return 0 if successful, or a specific X509 error code
+*/
+int x509write_add_issuer( x509_raw *crt, unsigned char *issuer);
+
+/**
+ * \brief Add x509 subject field
+ *
+ * \param chain points to the raw certificate data
+ * \param subject a string holding (separete with ";"):
+ * CN=CommonName
+ * -- O=Organization
+ * -- OU=OrgUnit
+ * -- ST=State
+ * -- L=Locality
+ * -- R=Email
+ * -- C=Country
+ * . Set this to NULL if not needed.
+ * \return 0 if successful, or a specific X509 error code
+ */
+int x509write_add_subject( x509_raw *crt, unsigned char *subject);
+
+/**
+* \brief Copy x509 issuer field from another certificate
+*
+* \param chain points to the raw certificate data
+* \param from_crt the certificate whose issuer is to be copied.
+* \return 0 if successful, or a specific X509 error code
+*/
+int x509write_copy_issuer(x509_raw *crt, x509_cert *from_crt);
+
+/**
+* \brief Copy x509 subject field from another certificate
+*
+* \param chain points to the raw certificate data
+* \param from_crt the certificate whose subject is to be copied.
+* \return 0 if successful, or a specific X509 error code
+*/
+int x509write_copy_subject(x509_raw *crt, x509_cert *from_crt);
+
+/**
+* \brief Copy x509 issuer field from the subject of another certificate
+*
+* \param chain points to the raw certificate data
+* \param from_crt the certificate whose subject is to be copied.
+* \return 0 if successful, or a specific X509 error code
+*/
+int x509write_copy_issuer_from_subject(x509_raw *crt, x509_cert *from_crt);
+
+/**
+* \brief Copy x509 subject field from the issuer of another certificate
+*
+* \param chain points to the raw certificate data
+* \param from_crt the certificate whose issuer is to be copied.
+* \return 0 if successful, or a specific X509 error code
+*/
+int x509write_copy_subject_from_issuer(x509_raw *crt, x509_cert *from_crt);
+
+/**
+ * \brief Create x509 validity time in UTC
+ *
+ * \param chain points to the raw certificate data
+ * \param before valid not before in format YYYY-MM-DD hh:mm:ss
+ * \param after valid not after in format YYYY-MM-DD hh:mm:ss
+ *
+ * \return 0 if successful, or a specific X509 error code
+ */
+int x509write_add_validity( x509_raw *crt,
+ unsigned char *before,
+ unsigned char *after );
+
+/**
+ * \brief Create a self-signed certificate
+ *
+ * \param chain points to the raw certificate data
+ * \param rsa a private key to sign the certificate
+ *
+ * \return 0 if successful, or a specific X509 error code
+ */
+int x509write_create_selfsign( x509_raw *crt, rsa_context *raw );
+
+/**
+ * \brief Create a certificate
+ *
+ * \param chain points to the raw certificate data
+ * \param rsa a private key to sign the certificate
+ *
+ * \return 0 if successful, or a specific X509 error code
+ */
+int x509write_create_sign( x509_raw *crt, rsa_context *raw );
+
+/**
+ * \brief Create a certificate signing request
+ *
+ * \param chain points to the raw certificate data. Didn't use the
+ * same chain that u have use for certificate.
+ * \param privkey a rsa private key
+ *
+ * \return 0 if successful, or a specific X509 error code
+ */
+int x509write_create_csr( x509_raw *chain, rsa_context *privkey );
+
+/**
+ * \brief Serialize an rsa key into DER
+ *
+ * \param rsa a rsa key for output
+ * \param node a x509 node for write into
+ *
+ * \return 0 if successful, or a specific X509 error code
+ */
+int x509write_serialize_key( rsa_context *rsa, x509_node *node );
+
+/**
+ * \brief Unallocate all raw certificate data
+ */
+void x509write_free_raw( x509_raw *crt );
+
+/**
+ * \brief Allocate all raw certificate data
+ */
+void x509write_init_raw( x509_raw *crt );
+
+/**
+ * \brief Unallocate all node certificate data
+ */
+void x509write_free_node( x509_node *crt_node );
+
+/**
+ * \brief Allocate all node certificate data
+ */
+void x509write_init_node( x509_node *crt_node );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* x509.h */
diff --git a/package/px5g/src/polarssl/base64.h b/package/px5g/src/polarssl/base64.h
new file mode 100644
index 0000000..c48267b
--- /dev/null
+++ b/package/px5g/src/polarssl/base64.h
@@ -0,0 +1,93 @@
+/**
+ * \file base64.h
+ *
+ * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
+ *
+ * Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the names of PolarSSL or XySSL nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef POLARSSL_BASE64_H
+#define POLARSSL_BASE64_H
+
+#define POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL -0x0010
+#define POLARSSL_ERR_BASE64_INVALID_CHARACTER -0x0012
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \brief Encode a buffer into base64 format
+ *
+ * \param dst destination buffer
+ * \param dlen size of the buffer
+ * \param src source buffer
+ * \param slen amount of data to be encoded
+ *
+ * \return 0 if successful, or POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL.
+ * *dlen is always updated to reflect the amount
+ * of data that has (or would have) been written.
+ *
+ * \note Call this function with *dlen = 0 to obtain the
+ * required buffer size in *dlen
+ */
+int base64_encode( unsigned char *dst, int *dlen,
+ unsigned char *src, int slen );
+
+/**
+ * \brief Decode a base64-formatted buffer
+ *
+ * \param dst destination buffer
+ * \param dlen size of the buffer
+ * \param src source buffer
+ * \param slen amount of data to be decoded
+ *
+ * \return 0 if successful, POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL, or
+ * POLARSSL_ERR_BASE64_INVALID_DATA if the input data is not
+ * correct. *dlen is always updated to reflect the amount
+ * of data that has (or would have) been written.
+ *
+ * \note Call this function with *dlen = 0 to obtain the
+ * required buffer size in *dlen
+ */
+int base64_decode( unsigned char *dst, int *dlen,
+ unsigned char *src, int slen );
+
+/**
+ * \brief Checkup routine
+ *
+ * \return 0 if successful, or 1 if the test failed
+ */
+int base64_self_test( int verbose );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* base64.h */
diff --git a/package/px5g/src/polarssl/bignum.h b/package/px5g/src/polarssl/bignum.h
new file mode 100644
index 0000000..c667303
--- /dev/null
+++ b/package/px5g/src/polarssl/bignum.h
@@ -0,0 +1,437 @@
+/**
+ * \file bignum.h
+ *
+ * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
+ *
+ * Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the names of PolarSSL or XySSL nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef POLARSSL_BIGNUM_H
+#define POLARSSL_BIGNUM_H
+
+#include <stdio.h>
+
+#define POLARSSL_ERR_MPI_FILE_IO_ERROR -0x0002
+#define POLARSSL_ERR_MPI_BAD_INPUT_DATA -0x0004
+#define POLARSSL_ERR_MPI_INVALID_CHARACTER -0x0006
+#define POLARSSL_ERR_MPI_BUFFER_TOO_SMALL -0x0008
+#define POLARSSL_ERR_MPI_NEGATIVE_VALUE -0x000A
+#define POLARSSL_ERR_MPI_DIVISION_BY_ZERO -0x000C
+#define POLARSSL_ERR_MPI_NOT_ACCEPTABLE -0x000E
+
+#define MPI_CHK(f) if( ( ret = f ) != 0 ) goto cleanup
+
+/*
+ * Define the base integer type, architecture-wise
+ */
+#if defined(POLARSSL_HAVE_INT8)
+typedef unsigned char t_int;
+typedef unsigned short t_dbl;
+#else
+#if defined(POLARSSL_HAVE_INT16)
+typedef unsigned short t_int;
+typedef unsigned long t_dbl;
+#else
+ typedef unsigned long t_int;
+ #if defined(_MSC_VER) && defined(_M_IX86)
+ typedef unsigned __int64 t_dbl;
+ #else
+ #if defined(__amd64__) || defined(__x86_64__) || \
+ defined(__ppc64__) || defined(__powerpc64__) || \
+ defined(__ia64__) || defined(__alpha__)
+ typedef unsigned int t_dbl __attribute__((mode(TI)));
+ #else
+ typedef unsigned long long t_dbl;
+ #endif
+ #endif
+#endif
+#endif
+
+/**
+ * \brief MPI structure
+ */
+typedef struct
+{
+ int s; /*!< integer sign */
+ int n; /*!< total # of limbs */
+ t_int *p; /*!< pointer to limbs */
+}
+mpi;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \brief Initialize one or more mpi
+ */
+void mpi_init( mpi *X, ... );
+
+/**
+ * \brief Unallocate one or more mpi
+ */
+void mpi_free( mpi *X, ... );
+
+/**
+ * \brief Enlarge to the specified number of limbs
+ *
+ * \return 0 if successful,
+ * 1 if memory allocation failed
+ */
+int mpi_grow( mpi *X, int nblimbs );
+
+/**
+ * \brief Copy the contents of Y into X
+ *
+ * \return 0 if successful,
+ * 1 if memory allocation failed
+ */
+int mpi_copy( mpi *X, mpi *Y );
+
+/**
+ * \brief Swap the contents of X and Y
+ */
+void mpi_swap( mpi *X, mpi *Y );
+
+/**
+ * \brief Set value from integer
+ *
+ * \return 0 if successful,
+ * 1 if memory allocation failed
+ */
+int mpi_lset( mpi *X, int z );
+
+/**
+ * \brief Return the number of least significant bits
+ */
+int mpi_lsb( mpi *X );
+
+/**
+ * \brief Return the number of most significant bits
+ */
+int mpi_msb( mpi *X );
+
+/**
+ * \brief Return the total size in bytes
+ */
+int mpi_size( mpi *X );
+
+/**
+ * \brief Import from an ASCII string
+ *
+ * \param X destination mpi
+ * \param radix input numeric base
+ * \param s null-terminated string buffer
+ *
+ * \return 0 if successful, or an POLARSSL_ERR_MPI_XXX error code
+ */
+int mpi_read_string( mpi *X, int radix, char *s );
+
+/**
+ * \brief Export into an ASCII string
+ *
+ * \param X source mpi
+ * \param radix output numeric base
+ * \param s string buffer
+ * \param slen string buffer size
+ *
+ * \return 0 if successful, or an POLARSSL_ERR_MPI_XXX error code
+ *
+ * \note Call this function with *slen = 0 to obtain the
+ * minimum required buffer size in *slen.
+ */
+int mpi_write_string( mpi *X, int radix, char *s, int *slen );
+
+/**
+ * \brief Read X from an opened file
+ *
+ * \param X destination mpi
+ * \param radix input numeric base
+ * \param fin input file handle
+ *
+ * \return 0 if successful, or an POLARSSL_ERR_MPI_XXX error code
+ */
+int mpi_read_file( mpi *X, int radix, FILE *fin );
+
+/**
+ * \brief Write X into an opened file, or stdout
+ *
+ * \param p prefix, can be NULL
+ * \param X source mpi
+ * \param radix output numeric base
+ * \param fout output file handle
+ *
+ * \return 0 if successful, or an POLARSSL_ERR_MPI_XXX error code
+ *
+ * \note Set fout == NULL to print X on the console.
+ */
+int mpi_write_file( char *p, mpi *X, int radix, FILE *fout );
+
+/**
+ * \brief Import X from unsigned binary data, big endian
+ *
+ * \param X destination mpi
+ * \param buf input buffer
+ * \param buflen input buffer size
+ *
+ * \return 0 if successful,
+ * 1 if memory allocation failed
+ */
+int mpi_read_binary( mpi *X, unsigned char *buf, int buflen );
+
+/**
+ * \brief Export X into unsigned binary data, big endian
+ *
+ * \param X source mpi
+ * \param buf output buffer
+ * \param buflen output buffer size
+ *
+ * \return 0 if successful,
+ * POLARSSL_ERR_MPI_BUFFER_TOO_SMALL if buf isn't large enough
+ *
+ * \note Call this function with *buflen = 0 to obtain the
+ * minimum required buffer size in *buflen.
+ */
+int mpi_write_binary( mpi *X, unsigned char *buf, int buflen );
+
+/**
+ * \brief Left-shift: X <<= count
+ *
+ * \return 0 if successful,
+ * 1 if memory allocation failed
+ */
+int mpi_shift_l( mpi *X, int count );
+
+/**
+ * \brief Right-shift: X >>= count
+ *
+ * \return 0 if successful,
+ * 1 if memory allocation failed
+ */
+int mpi_shift_r( mpi *X, int count );
+
+/**
+ * \brief Compare unsigned values
+ *
+ * \return 1 if |X| is greater than |Y|,
+ * -1 if |X| is lesser than |Y| or
+ * 0 if |X| is equal to |Y|
+ */
+int mpi_cmp_abs( mpi *X, mpi *Y );
+
+/**
+ * \brief Compare signed values
+ *
+ * \return 1 if X is greater than Y,
+ * -1 if X is lesser than Y or
+ * 0 if X is equal to Y
+ */
+int mpi_cmp_mpi( mpi *X, mpi *Y );
+
+/**
+ * \brief Compare signed values
+ *
+ * \return 1 if X is greater than z,
+ * -1 if X is lesser than z or
+ * 0 if X is equal to z
+ */
+int mpi_cmp_int( mpi *X, int z );
+
+/**
+ * \brief Unsigned addition: X = |A| + |B|
+ *
+ * \return 0 if successful,
+ * 1 if memory allocation failed
+ */
+int mpi_add_abs( mpi *X, mpi *A, mpi *B );
+
+/**
+ * \brief Unsigned substraction: X = |A| - |B|
+ *
+ * \return 0 if successful,
+ * POLARSSL_ERR_MPI_NEGATIVE_VALUE if B is greater than A
+ */
+int mpi_sub_abs( mpi *X, mpi *A, mpi *B );
+
+/**
+ * \brief Signed addition: X = A + B
+ *
+ * \return 0 if successful,
+ * 1 if memory allocation failed
+ */
+int mpi_add_mpi( mpi *X, mpi *A, mpi *B );
+
+/**
+ * \brief Signed substraction: X = A - B
+ *
+ * \return 0 if successful,
+ * 1 if memory allocation failed
+ */
+int mpi_sub_mpi( mpi *X, mpi *A, mpi *B );
+
+/**
+ * \brief Signed addition: X = A + b
+ *
+ * \return 0 if successful,
+ * 1 if memory allocation failed
+ */
+int mpi_add_int( mpi *X, mpi *A, int b );
+
+/**
+ * \brief Signed substraction: X = A - b
+ *
+ * \return 0 if successful,
+ * 1 if memory allocation failed
+ */
+int mpi_sub_int( mpi *X, mpi *A, int b );
+
+/**
+ * \brief Baseline multiplication: X = A * B
+ *
+ * \return 0 if successful,
+ * 1 if memory allocation failed
+ */
+int mpi_mul_mpi( mpi *X, mpi *A, mpi *B );
+
+/**
+ * \brief Baseline multiplication: X = A * b
+ *
+ * \return 0 if successful,
+ * 1 if memory allocation failed
+ */
+int mpi_mul_int( mpi *X, mpi *A, t_int b );
+
+/**
+ * \brief Division by mpi: A = Q * B + R
+ *
+ * \return 0 if successful,
+ * 1 if memory allocation failed,
+ * POLARSSL_ERR_MPI_DIVISION_BY_ZERO if B == 0
+ *
+ * \note Either Q or R can be NULL.
+ */
+int mpi_div_mpi( mpi *Q, mpi *R, mpi *A, mpi *B );
+
+/**
+ * \brief Division by int: A = Q * b + R
+ *
+ * \return 0 if successful,
+ * 1 if memory allocation failed,
+ * POLARSSL_ERR_MPI_DIVISION_BY_ZERO if b == 0
+ *
+ * \note Either Q or R can be NULL.
+ */
+int mpi_div_int( mpi *Q, mpi *R, mpi *A, int b );
+
+/**
+ * \brief Modulo: R = A mod B
+ *
+ * \return 0 if successful,
+ * 1 if memory allocation failed,
+ * POLARSSL_ERR_MPI_DIVISION_BY_ZERO if B == 0
+ */
+int mpi_mod_mpi( mpi *R, mpi *A, mpi *B );
+
+/**
+ * \brief Modulo: r = A mod b
+ *
+ * \return 0 if successful,
+ * 1 if memory allocation failed,
+ * POLARSSL_ERR_MPI_DIVISION_BY_ZERO if b == 0
+ */
+int mpi_mod_int( t_int *r, mpi *A, int b );
+
+/**
+ * \brief Sliding-window exponentiation: X = A^E mod N
+ *
+ * \return 0 if successful,
+ * 1 if memory allocation failed,
+ * POLARSSL_ERR_MPI_BAD_INPUT_DATA if N is negative or even
+ *
+ * \note _RR is used to avoid re-computing R*R mod N across
+ * multiple calls, which speeds up things a bit. It can
+ * be set to NULL if the extra performance is unneeded.
+ */
+int mpi_exp_mod( mpi *X, mpi *A, mpi *E, mpi *N, mpi *_RR );
+
+/**
+ * \brief Greatest common divisor: G = gcd(A, B)
+ *
+ * \return 0 if successful,
+ * 1 if memory allocation failed
+ */
+int mpi_gcd( mpi *G, mpi *A, mpi *B );
+
+/**
+ * \brief Modular inverse: X = A^-1 mod N
+ *
+ * \return 0 if successful,
+ * 1 if memory allocation failed,
+ * POLARSSL_ERR_MPI_BAD_INPUT_DATA if N is negative or nil
+ * POLARSSL_ERR_MPI_NOT_ACCEPTABLE if A has no inverse mod N
+ */
+int mpi_inv_mod( mpi *X, mpi *A, mpi *N );
+
+/**
+ * \brief Miller-Rabin primality test
+ *
+ * \return 0 if successful (probably prime),
+ * 1 if memory allocation failed,
+ * POLARSSL_ERR_MPI_NOT_ACCEPTABLE if X is not prime
+ */
+int mpi_is_prime( mpi *X, int (*f_rng)(void *), void *p_rng );
+
+/**
+ * \brief Prime number generation
+ *
+ * \param X destination mpi
+ * \param nbits required size of X in bits
+ * \param dh_flag if 1, then (X-1)/2 will be prime too
+ * \param f_rng RNG function
+ * \param p_rng RNG parameter
+ *
+ * \return 0 if successful (probably prime),
+ * 1 if memory allocation failed,
+ * POLARSSL_ERR_MPI_BAD_INPUT_DATA if nbits is < 3
+ */
+int mpi_gen_prime( mpi *X, int nbits, int dh_flag,
+ int (*f_rng)(void *), void *p_rng );
+
+/**
+ * \brief Checkup routine
+ *
+ * \return 0 if successful, or 1 if the test failed
+ */
+int mpi_self_test( int verbose );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* bignum.h */
diff --git a/package/px5g/src/polarssl/bn_mul.h b/package/px5g/src/polarssl/bn_mul.h
new file mode 100644
index 0000000..f6d34da
--- /dev/null
+++ b/package/px5g/src/polarssl/bn_mul.h
@@ -0,0 +1,731 @@
+/**
+ * \file bn_mul.h
+ *
+ * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
+ *
+ * Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the names of PolarSSL or XySSL nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+/*
+ * Multiply source vector [s] with b, add result
+ * to destination vector [d] and set carry c.
+ *
+ * Currently supports:
+ *
+ * . IA-32 (386+) . AMD64 / EM64T
+ * . IA-32 (SSE2) . Motorola 68000
+ * . PowerPC, 32-bit . MicroBlaze
+ * . PowerPC, 64-bit . TriCore
+ * . SPARC v8 . ARM v3+
+ * . Alpha . MIPS32
+ * . C, longlong . C, generic
+ */
+#ifndef POLARSSL_BN_MUL_H
+#define POLARSSL_BN_MUL_H
+
+#include "polarssl/config.h"
+
+#if defined(POLARSSL_HAVE_ASM)
+
+#if defined(__GNUC__)
+#if defined(__i386__)
+
+#define MULADDC_INIT \
+ asm( "movl %%ebx, %0 " : "=m" (t)); \
+ asm( "movl %0, %%esi " :: "m" (s)); \
+ asm( "movl %0, %%edi " :: "m" (d)); \
+ asm( "movl %0, %%ecx " :: "m" (c)); \
+ asm( "movl %0, %%ebx " :: "m" (b));
+
+#define MULADDC_CORE \
+ asm( "lodsl " ); \
+ asm( "mull %ebx " ); \
+ asm( "addl %ecx, %eax " ); \
+ asm( "adcl $0, %edx " ); \
+ asm( "addl (%edi), %eax " ); \
+ asm( "adcl $0, %edx " ); \
+ asm( "movl %edx, %ecx " ); \
+ asm( "stosl " );
+
+#if defined(POLARSSL_HAVE_SSE2)
+
+#define MULADDC_HUIT \
+ asm( "movd %ecx, %mm1 " ); \
+ asm( "movd %ebx, %mm0 " ); \
+ asm( "movd (%edi), %mm3 " ); \
+ asm( "paddq %mm3, %mm1 " ); \
+ asm( "movd (%esi), %mm2 " ); \
+ asm( "pmuludq %mm0, %mm2 " ); \
+ asm( "movd 4(%esi), %mm4 " ); \
+ asm( "pmuludq %mm0, %mm4 " ); \
+ asm( "movd 8(%esi), %mm6 " ); \
+ asm( "pmuludq %mm0, %mm6 " ); \
+ asm( "movd 12(%esi), %mm7 " ); \
+ asm( "pmuludq %mm0, %mm7 " ); \
+ asm( "paddq %mm2, %mm1 " ); \
+ asm( "movd 4(%edi), %mm3 " ); \
+ asm( "paddq %mm4, %mm3 " ); \
+ asm( "movd 8(%edi), %mm5 " ); \
+ asm( "paddq %mm6, %mm5 " ); \
+ asm( "movd 12(%edi), %mm4 " ); \
+ asm( "paddq %mm4, %mm7 " ); \
+ asm( "movd %mm1, (%edi) " ); \
+ asm( "movd 16(%esi), %mm2 " ); \
+ asm( "pmuludq %mm0, %mm2 " ); \
+ asm( "psrlq $32, %mm1 " ); \
+ asm( "movd 20(%esi), %mm4 " ); \
+ asm( "pmuludq %mm0, %mm4 " ); \
+ asm( "paddq %mm3, %mm1 " ); \
+ asm( "movd 24(%esi), %mm6 " ); \
+ asm( "pmuludq %mm0, %mm6 " ); \
+ asm( "movd %mm1, 4(%edi) " ); \
+ asm( "psrlq $32, %mm1 " ); \
+ asm( "movd 28(%esi), %mm3 " ); \
+ asm( "pmuludq %mm0, %mm3 " ); \
+ asm( "paddq %mm5, %mm1 " ); \
+ asm( "movd 16(%edi), %mm5 " ); \
+ asm( "paddq %mm5, %mm2 " ); \
+ asm( "movd %mm1, 8(%edi) " ); \
+ asm( "psrlq $32, %mm1 " ); \
+ asm( "paddq %mm7, %mm1 " ); \
+ asm( "movd 20(%edi), %mm5 " ); \
+ asm( "paddq %mm5, %mm4 " ); \
+ asm( "movd %mm1, 12(%edi) " ); \
+ asm( "psrlq $32, %mm1 " ); \
+ asm( "paddq %mm2, %mm1 " ); \
+ asm( "movd 24(%edi), %mm5 " ); \
+ asm( "paddq %mm5, %mm6 " ); \
+ asm( "movd %mm1, 16(%edi) " ); \
+ asm( "psrlq $32, %mm1 " ); \
+ asm( "paddq %mm4, %mm1 " ); \
+ asm( "movd 28(%edi), %mm5 " ); \
+ asm( "paddq %mm5, %mm3 " ); \
+ asm( "movd %mm1, 20(%edi) " ); \
+ asm( "psrlq $32, %mm1 " ); \
+ asm( "paddq %mm6, %mm1 " ); \
+ asm( "movd %mm1, 24(%edi) " ); \
+ asm( "psrlq $32, %mm1 " ); \
+ asm( "paddq %mm3, %mm1 " ); \
+ asm( "movd %mm1, 28(%edi) " ); \
+ asm( "addl $32, %edi " ); \
+ asm( "addl $32, %esi " ); \
+ asm( "psrlq $32, %mm1 " ); \
+ asm( "movd %mm1, %ecx " );
+
+#define MULADDC_STOP \
+ asm( "emms " ); \
+ asm( "movl %0, %%ebx " :: "m" (t)); \
+ asm( "movl %%ecx, %0 " : "=m" (c)); \
+ asm( "movl %%edi, %0 " : "=m" (d)); \
+ asm( "movl %%esi, %0 " : "=m" (s) :: \
+ "eax", "ecx", "edx", "esi", "edi" );
+
+#else
+
+#define MULADDC_STOP \
+ asm( "movl %0, %%ebx " :: "m" (t)); \
+ asm( "movl %%ecx, %0 " : "=m" (c)); \
+ asm( "movl %%edi, %0 " : "=m" (d)); \
+ asm( "movl %%esi, %0 " : "=m" (s) :: \
+ "eax", "ecx", "edx", "esi", "edi" );
+
+#endif /* SSE2 */
+#endif /* i386 */
+
+#if defined(__amd64__) || defined (__x86_64__)
+
+#define MULADDC_INIT \
+ asm( "movq %0, %%rsi " :: "m" (s)); \
+ asm( "movq %0, %%rdi " :: "m" (d)); \
+ asm( "movq %0, %%rcx " :: "m" (c)); \
+ asm( "movq %0, %%rbx " :: "m" (b)); \
+ asm( "xorq %r8, %r8 " );
+
+#define MULADDC_CORE \
+ asm( "movq (%rsi),%rax " ); \
+ asm( "mulq %rbx " ); \
+ asm( "addq $8, %rsi " ); \
+ asm( "addq %rcx, %rax " ); \
+ asm( "movq %r8, %rcx " ); \
+ asm( "adcq $0, %rdx " ); \
+ asm( "nop " ); \
+ asm( "addq %rax, (%rdi) " ); \
+ asm( "adcq %rdx, %rcx " ); \
+ asm( "addq $8, %rdi " );
+
+#define MULADDC_STOP \
+ asm( "movq %%rcx, %0 " : "=m" (c)); \
+ asm( "movq %%rdi, %0 " : "=m" (d)); \
+ asm( "movq %%rsi, %0 " : "=m" (s) :: \
+ "rax", "rcx", "rdx", "rbx", "rsi", "rdi", "r8" );
+
+#endif /* AMD64 */
+
+#if defined(__mc68020__) || defined(__mcpu32__)
+
+#define MULADDC_INIT \
+ asm( "movl %0, %%a2 " :: "m" (s)); \
+ asm( "movl %0, %%a3 " :: "m" (d)); \
+ asm( "movl %0, %%d3 " :: "m" (c)); \
+ asm( "movl %0, %%d2 " :: "m" (b)); \
+ asm( "moveq #0, %d0 " );
+
+#define MULADDC_CORE \
+ asm( "movel %a2@+, %d1 " ); \
+ asm( "mulul %d2, %d4:%d1 " ); \
+ asm( "addl %d3, %d1 " ); \
+ asm( "addxl %d0, %d4 " ); \
+ asm( "moveq #0, %d3 " ); \
+ asm( "addl %d1, %a3@+ " ); \
+ asm( "addxl %d4, %d3 " );
+
+#define MULADDC_STOP \
+ asm( "movl %%d3, %0 " : "=m" (c)); \
+ asm( "movl %%a3, %0 " : "=m" (d)); \
+ asm( "movl %%a2, %0 " : "=m" (s) :: \
+ "d0", "d1", "d2", "d3", "d4", "a2", "a3" );
+
+#define MULADDC_HUIT \
+ asm( "movel %a2@+, %d1 " ); \
+ asm( "mulul %d2, %d4:%d1 " ); \
+ asm( "addxl %d3, %d1 " ); \
+ asm( "addxl %d0, %d4 " ); \
+ asm( "addl %d1, %a3@+ " ); \
+ asm( "movel %a2@+, %d1 " ); \
+ asm( "mulul %d2, %d3:%d1 " ); \
+ asm( "addxl %d4, %d1 " ); \
+ asm( "addxl %d0, %d3 " ); \
+ asm( "addl %d1, %a3@+ " ); \
+ asm( "movel %a2@+, %d1 " ); \
+ asm( "mulul %d2, %d4:%d1 " ); \
+ asm( "addxl %d3, %d1 " ); \
+ asm( "addxl %d0, %d4 " ); \
+ asm( "addl %d1, %a3@+ " ); \
+ asm( "movel %a2@+, %d1 " ); \
+ asm( "mulul %d2, %d3:%d1 " ); \
+ asm( "addxl %d4, %d1 " ); \
+ asm( "addxl %d0, %d3 " ); \
+ asm( "addl %d1, %a3@+ " ); \
+ asm( "movel %a2@+, %d1 " ); \
+ asm( "mulul %d2, %d4:%d1 " ); \
+ asm( "addxl %d3, %d1 " ); \
+ asm( "addxl %d0, %d4 " ); \
+ asm( "addl %d1, %a3@+ " ); \
+ asm( "movel %a2@+, %d1 " ); \
+ asm( "mulul %d2, %d3:%d1 " ); \
+ asm( "addxl %d4, %d1 " ); \
+ asm( "addxl %d0, %d3 " ); \
+ asm( "addl %d1, %a3@+ " ); \
+ asm( "movel %a2@+, %d1 " ); \
+ asm( "mulul %d2, %d4:%d1 " ); \
+ asm( "addxl %d3, %d1 " ); \
+ asm( "addxl %d0, %d4 " ); \
+ asm( "addl %d1, %a3@+ " ); \
+ asm( "movel %a2@+, %d1 " ); \
+ asm( "mulul %d2, %d3:%d1 " ); \
+ asm( "addxl %d4, %d1 " ); \
+ asm( "addxl %d0, %d3 " ); \
+ asm( "addl %d1, %a3@+ " ); \
+ asm( "addxl %d0, %d3 " );
+
+#endif /* MC68000 */
+
+#if defined(__powerpc__) || defined(__ppc__)
+#if defined(__powerpc64__) || defined(__ppc64__)
+
+#if defined(__MACH__) && defined(__APPLE__)
+
+#define MULADDC_INIT \
+ asm( "ld r3, %0 " :: "m" (s)); \
+ asm( "ld r4, %0 " :: "m" (d)); \
+ asm( "ld r5, %0 " :: "m" (c)); \
+ asm( "ld r6, %0 " :: "m" (b)); \
+ asm( "addi r3, r3, -8 " ); \
+ asm( "addi r4, r4, -8 " ); \
+ asm( "addic r5, r5, 0 " );
+
+#define MULADDC_CORE \
+ asm( "ldu r7, 8(r3) " ); \
+ asm( "mulld r8, r7, r6 " ); \
+ asm( "mulhdu r9, r7, r6 " ); \
+ asm( "adde r8, r8, r5 " ); \
+ asm( "ld r7, 8(r4) " ); \
+ asm( "addze r5, r9 " ); \
+ asm( "addc r8, r8, r7 " ); \
+ asm( "stdu r8, 8(r4) " );
+
+#define MULADDC_STOP \
+ asm( "addze r5, r5 " ); \
+ asm( "addi r4, r4, 8 " ); \
+ asm( "addi r3, r3, 8 " ); \
+ asm( "std r5, %0 " : "=m" (c)); \
+ asm( "std r4, %0 " : "=m" (d)); \
+ asm( "std r3, %0 " : "=m" (s) :: \
+ "r3", "r4", "r5", "r6", "r7", "r8", "r9" );
+
+#else
+
+#define MULADDC_INIT \
+ asm( "ld %%r3, %0 " :: "m" (s)); \
+ asm( "ld %%r4, %0 " :: "m" (d)); \
+ asm( "ld %%r5, %0 " :: "m" (c)); \
+ asm( "ld %%r6, %0 " :: "m" (b)); \
+ asm( "addi %r3, %r3, -8 " ); \
+ asm( "addi %r4, %r4, -8 " ); \
+ asm( "addic %r5, %r5, 0 " );
+
+#define MULADDC_CORE \
+ asm( "ldu %r7, 8(%r3) " ); \
+ asm( "mulld %r8, %r7, %r6 " ); \
+ asm( "mulhdu %r9, %r7, %r6 " ); \
+ asm( "adde %r8, %r8, %r5 " ); \
+ asm( "ld %r7, 8(%r4) " ); \
+ asm( "addze %r5, %r9 " ); \
+ asm( "addc %r8, %r8, %r7 " ); \
+ asm( "stdu %r8, 8(%r4) " );
+
+#define MULADDC_STOP \
+ asm( "addze %r5, %r5 " ); \
+ asm( "addi %r4, %r4, 8 " ); \
+ asm( "addi %r3, %r3, 8 " ); \
+ asm( "std %%r5, %0 " : "=m" (c)); \
+ asm( "std %%r4, %0 " : "=m" (d)); \
+ asm( "std %%r3, %0 " : "=m" (s) :: \
+ "r3", "r4", "r5", "r6", "r7", "r8", "r9" );
+
+#endif
+
+#else /* PPC32 */
+
+#if defined(__MACH__) && defined(__APPLE__)
+
+#define MULADDC_INIT \
+ asm( "lwz r3, %0 " :: "m" (s)); \
+ asm( "lwz r4, %0 " :: "m" (d)); \
+ asm( "lwz r5, %0 " :: "m" (c)); \
+ asm( "lwz r6, %0 " :: "m" (b)); \
+ asm( "addi r3, r3, -4 " ); \
+ asm( "addi r4, r4, -4 " ); \
+ asm( "addic r5, r5, 0 " );
+
+#define MULADDC_CORE \
+ asm( "lwzu r7, 4(r3) " ); \
+ asm( "mullw r8, r7, r6 " ); \
+ asm( "mulhwu r9, r7, r6 " ); \
+ asm( "adde r8, r8, r5 " ); \
+ asm( "lwz r7, 4(r4) " ); \
+ asm( "addze r5, r9 " ); \
+ asm( "addc r8, r8, r7 " ); \
+ asm( "stwu r8, 4(r4) " );
+
+#define MULADDC_STOP \
+ asm( "addze r5, r5 " ); \
+ asm( "addi r4, r4, 4 " ); \
+ asm( "addi r3, r3, 4 " ); \
+ asm( "stw r5, %0 " : "=m" (c)); \
+ asm( "stw r4, %0 " : "=m" (d)); \
+ asm( "stw r3, %0 " : "=m" (s) :: \
+ "r3", "r4", "r5", "r6", "r7", "r8", "r9" );
+
+#else
+
+#define MULADDC_INIT \
+ asm( "lwz %%r3, %0 " :: "m" (s)); \
+ asm( "lwz %%r4, %0 " :: "m" (d)); \
+ asm( "lwz %%r5, %0 " :: "m" (c)); \
+ asm( "lwz %%r6, %0 " :: "m" (b)); \
+ asm( "addi %r3, %r3, -4 " ); \
+ asm( "addi %r4, %r4, -4 " ); \
+ asm( "addic %r5, %r5, 0 " );
+
+#define MULADDC_CORE \
+ asm( "lwzu %r7, 4(%r3) " ); \
+ asm( "mullw %r8, %r7, %r6 " ); \
+ asm( "mulhwu %r9, %r7, %r6 " ); \
+ asm( "adde %r8, %r8, %r5 " ); \
+ asm( "lwz %r7, 4(%r4) " ); \
+ asm( "addze %r5, %r9 " ); \
+ asm( "addc %r8, %r8, %r7 " ); \
+ asm( "stwu %r8, 4(%r4) " );
+
+#define MULADDC_STOP \
+ asm( "addze %r5, %r5 " ); \
+ asm( "addi %r4, %r4, 4 " ); \
+ asm( "addi %r3, %r3, 4 " ); \
+ asm( "stw %%r5, %0 " : "=m" (c)); \
+ asm( "stw %%r4, %0 " : "=m" (d)); \
+ asm( "stw %%r3, %0 " : "=m" (s) :: \
+ "r3", "r4", "r5", "r6", "r7", "r8", "r9" );
+
+#endif
+
+#endif /* PPC32 */
+#endif /* PPC64 */
+
+#if defined(__sparc__)
+
+#define MULADDC_INIT \
+ asm( "ld %0, %%o0 " :: "m" (s)); \
+ asm( "ld %0, %%o1 " :: "m" (d)); \
+ asm( "ld %0, %%o2 " :: "m" (c)); \
+ asm( "ld %0, %%o3 " :: "m" (b));
+
+#define MULADDC_CORE \
+ asm( "ld [%o0], %o4 " ); \
+ asm( "inc 4, %o0 " ); \
+ asm( "ld [%o1], %o5 " ); \
+ asm( "umul %o3, %o4, %o4 " ); \
+ asm( "addcc %o4, %o2, %o4 " ); \
+ asm( "rd %y, %g1 " ); \
+ asm( "addx %g1, 0, %g1 " ); \
+ asm( "addcc %o4, %o5, %o4 " ); \
+ asm( "st %o4, [%o1] " ); \
+ asm( "addx %g1, 0, %o2 " ); \
+ asm( "inc 4, %o1 " );
+
+#define MULADDC_STOP \
+ asm( "st %%o2, %0 " : "=m" (c)); \
+ asm( "st %%o1, %0 " : "=m" (d)); \
+ asm( "st %%o0, %0 " : "=m" (s) :: \
+ "g1", "o0", "o1", "o2", "o3", "o4", "o5" );
+
+#endif /* SPARCv8 */
+
+#if defined(__microblaze__) || defined(microblaze)
+
+#define MULADDC_INIT \
+ asm( "lwi r3, %0 " :: "m" (s)); \
+ asm( "lwi r4, %0 " :: "m" (d)); \
+ asm( "lwi r5, %0 " :: "m" (c)); \
+ asm( "lwi r6, %0 " :: "m" (b)); \
+ asm( "andi r7, r6, 0xffff" ); \
+ asm( "bsrli r6, r6, 16 " );
+
+#define MULADDC_CORE \
+ asm( "lhui r8, r3, 0 " ); \
+ asm( "addi r3, r3, 2 " ); \
+ asm( "lhui r9, r3, 0 " ); \
+ asm( "addi r3, r3, 2 " ); \
+ asm( "mul r10, r9, r6 " ); \
+ asm( "mul r11, r8, r7 " ); \
+ asm( "mul r12, r9, r7 " ); \
+ asm( "mul r13, r8, r6 " ); \
+ asm( "bsrli r8, r10, 16 " ); \
+ asm( "bsrli r9, r11, 16 " ); \
+ asm( "add r13, r13, r8 " ); \
+ asm( "add r13, r13, r9 " ); \
+ asm( "bslli r10, r10, 16 " ); \
+ asm( "bslli r11, r11, 16 " ); \
+ asm( "add r12, r12, r10 " ); \
+ asm( "addc r13, r13, r0 " ); \
+ asm( "add r12, r12, r11 " ); \
+ asm( "addc r13, r13, r0 " ); \
+ asm( "lwi r10, r4, 0 " ); \
+ asm( "add r12, r12, r10 " ); \
+ asm( "addc r13, r13, r0 " ); \
+ asm( "add r12, r12, r5 " ); \
+ asm( "addc r5, r13, r0 " ); \
+ asm( "swi r12, r4, 0 " ); \
+ asm( "addi r4, r4, 4 " );
+
+#define MULADDC_STOP \
+ asm( "swi r5, %0 " : "=m" (c)); \
+ asm( "swi r4, %0 " : "=m" (d)); \
+ asm( "swi r3, %0 " : "=m" (s) :: \
+ "r3", "r4" , "r5" , "r6" , "r7" , "r8" , \
+ "r9", "r10", "r11", "r12", "r13" );
+
+#endif /* MicroBlaze */
+
+#if defined(__tricore__)
+
+#define MULADDC_INIT \
+ asm( "ld.a %%a2, %0 " :: "m" (s)); \
+ asm( "ld.a %%a3, %0 " :: "m" (d)); \
+ asm( "ld.w %%d4, %0 " :: "m" (c)); \
+ asm( "ld.w %%d1, %0 " :: "m" (b)); \
+ asm( "xor %d5, %d5 " );
+
+#define MULADDC_CORE \
+ asm( "ld.w %d0, [%a2+] " ); \
+ asm( "madd.u %e2, %e4, %d0, %d1 " ); \
+ asm( "ld.w %d0, [%a3] " ); \
+ asm( "addx %d2, %d2, %d0 " ); \
+ asm( "addc %d3, %d3, 0 " ); \
+ asm( "mov %d4, %d3 " ); \
+ asm( "st.w [%a3+], %d2 " );
+
+#define MULADDC_STOP \
+ asm( "st.w %0, %%d4 " : "=m" (c)); \
+ asm( "st.a %0, %%a3 " : "=m" (d)); \
+ asm( "st.a %0, %%a2 " : "=m" (s) :: \
+ "d0", "d1", "e2", "d4", "a2", "a3" );
+
+#endif /* TriCore */
+
+#if defined(__arm__)
+
+#define MULADDC_INIT \
+ asm( "ldr r0, %0 " :: "m" (s)); \
+ asm( "ldr r1, %0 " :: "m" (d)); \
+ asm( "ldr r2, %0 " :: "m" (c)); \
+ asm( "ldr r3, %0 " :: "m" (b));
+
+#define MULADDC_CORE \
+ asm( "ldr r4, [r0], #4 " ); \
+ asm( "mov r5, #0 " ); \
+ asm( "ldr r6, [r1] " ); \
+ asm( "umlal r2, r5, r3, r4 " ); \
+ asm( "adds r7, r6, r2 " ); \
+ asm( "adc r2, r5, #0 " ); \
+ asm( "str r7, [r1], #4 " );
+
+#define MULADDC_STOP \
+ asm( "str r2, %0 " : "=m" (c)); \
+ asm( "str r1, %0 " : "=m" (d)); \
+ asm( "str r0, %0 " : "=m" (s) :: \
+ "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7" );
+
+#endif /* ARMv3 */
+
+#if defined(__alpha__)
+
+#define MULADDC_INIT \
+ asm( "ldq $1, %0 " :: "m" (s)); \
+ asm( "ldq $2, %0 " :: "m" (d)); \
+ asm( "ldq $3, %0 " :: "m" (c)); \
+ asm( "ldq $4, %0 " :: "m" (b));
+
+#define MULADDC_CORE \
+ asm( "ldq $6, 0($1) " ); \
+ asm( "addq $1, 8, $1 " ); \
+ asm( "mulq $6, $4, $7 " ); \
+ asm( "umulh $6, $4, $6 " ); \
+ asm( "addq $7, $3, $7 " ); \
+ asm( "cmpult $7, $3, $3 " ); \
+ asm( "ldq $5, 0($2) " ); \
+ asm( "addq $7, $5, $7 " ); \
+ asm( "cmpult $7, $5, $5 " ); \
+ asm( "stq $7, 0($2) " ); \
+ asm( "addq $2, 8, $2 " ); \
+ asm( "addq $6, $3, $3 " ); \
+ asm( "addq $5, $3, $3 " );
+
+#define MULADDC_STOP \
+ asm( "stq $3, %0 " : "=m" (c)); \
+ asm( "stq $2, %0 " : "=m" (d)); \
+ asm( "stq $1, %0 " : "=m" (s) :: \
+ "$1", "$2", "$3", "$4", "$5", "$6", "$7" );
+
+#endif /* Alpha */
+
+#if defined(__mips__)
+
+#define MULADDC_INIT \
+ asm( "lw $10, %0 " :: "m" (s)); \
+ asm( "lw $11, %0 " :: "m" (d)); \
+ asm( "lw $12, %0 " :: "m" (c)); \
+ asm( "lw $13, %0 " :: "m" (b));
+
+#define MULADDC_CORE \
+ asm( "lw $14, 0($10) " ); \
+ asm( "multu $13, $14 " ); \
+ asm( "addi $10, $10, 4 " ); \
+ asm( "mflo $14 " ); \
+ asm( "mfhi $9 " ); \
+ asm( "addu $14, $12, $14 " ); \
+ asm( "lw $15, 0($11) " ); \
+ asm( "sltu $12, $14, $12 " ); \
+ asm( "addu $15, $14, $15 " ); \
+ asm( "sltu $14, $15, $14 " ); \
+ asm( "addu $12, $12, $9 " ); \
+ asm( "sw $15, 0($11) " ); \
+ asm( "addu $12, $12, $14 " ); \
+ asm( "addi $11, $11, 4 " );
+
+#define MULADDC_STOP \
+ asm( "sw $12, %0 " : "=m" (c)); \
+ asm( "sw $11, %0 " : "=m" (d)); \
+ asm( "sw $10, %0 " : "=m" (s) :: \
+ "$9", "$10", "$11", "$12", "$13", "$14", "$15" );
+
+#endif /* MIPS */
+#endif /* GNUC */
+
+#if (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)
+
+#define MULADDC_INIT \
+ __asm mov esi, s \
+ __asm mov edi, d \
+ __asm mov ecx, c \
+ __asm mov ebx, b
+
+#define MULADDC_CORE \
+ __asm lodsd \
+ __asm mul ebx \
+ __asm add eax, ecx \
+ __asm adc edx, 0 \
+ __asm add eax, [edi] \
+ __asm adc edx, 0 \
+ __asm mov ecx, edx \
+ __asm stosd
+
+#if defined(POLARSSL_HAVE_SSE2)
+
+#define EMIT __asm _emit
+
+#define MULADDC_HUIT \
+ EMIT 0x0F EMIT 0x6E EMIT 0xC9 \
+ EMIT 0x0F EMIT 0x6E EMIT 0xC3 \
+ EMIT 0x0F EMIT 0x6E EMIT 0x1F \
+ EMIT 0x0F EMIT 0xD4 EMIT 0xCB \
+ EMIT 0x0F EMIT 0x6E EMIT 0x16 \
+ EMIT 0x0F EMIT 0xF4 EMIT 0xD0 \
+ EMIT 0x0F EMIT 0x6E EMIT 0x66 EMIT 0x04 \
+ EMIT 0x0F EMIT 0xF4 EMIT 0xE0 \
+ EMIT 0x0F EMIT 0x6E EMIT 0x76 EMIT 0x08 \
+ EMIT 0x0F EMIT 0xF4 EMIT 0xF0 \
+ EMIT 0x0F EMIT 0x6E EMIT 0x7E EMIT 0x0C \
+ EMIT 0x0F EMIT 0xF4 EMIT 0xF8 \
+ EMIT 0x0F EMIT 0xD4 EMIT 0xCA \
+ EMIT 0x0F EMIT 0x6E EMIT 0x5F EMIT 0x04 \
+ EMIT 0x0F EMIT 0xD4 EMIT 0xDC \
+ EMIT 0x0F EMIT 0x6E EMIT 0x6F EMIT 0x08 \
+ EMIT 0x0F EMIT 0xD4 EMIT 0xEE \
+ EMIT 0x0F EMIT 0x6E EMIT 0x67 EMIT 0x0C \
+ EMIT 0x0F EMIT 0xD4 EMIT 0xFC \
+ EMIT 0x0F EMIT 0x7E EMIT 0x0F \
+ EMIT 0x0F EMIT 0x6E EMIT 0x56 EMIT 0x10 \
+ EMIT 0x0F EMIT 0xF4 EMIT 0xD0 \
+ EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \
+ EMIT 0x0F EMIT 0x6E EMIT 0x66 EMIT 0x14 \
+ EMIT 0x0F EMIT 0xF4 EMIT 0xE0 \
+ EMIT 0x0F EMIT 0xD4 EMIT 0xCB \
+ EMIT 0x0F EMIT 0x6E EMIT 0x76 EMIT 0x18 \
+ EMIT 0x0F EMIT 0xF4 EMIT 0xF0 \
+ EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x04 \
+ EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \
+ EMIT 0x0F EMIT 0x6E EMIT 0x5E EMIT 0x1C \
+ EMIT 0x0F EMIT 0xF4 EMIT 0xD8 \
+ EMIT 0x0F EMIT 0xD4 EMIT 0xCD \
+ EMIT 0x0F EMIT 0x6E EMIT 0x6F EMIT 0x10 \
+ EMIT 0x0F EMIT 0xD4 EMIT 0xD5 \
+ EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x08 \
+ EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \
+ EMIT 0x0F EMIT 0xD4 EMIT 0xCF \
+ EMIT 0x0F EMIT 0x6E EMIT 0x6F EMIT 0x14 \
+ EMIT 0x0F EMIT 0xD4 EMIT 0xE5 \
+ EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x0C \
+ EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \
+ EMIT 0x0F EMIT 0xD4 EMIT 0xCA \
+ EMIT 0x0F EMIT 0x6E EMIT 0x6F EMIT 0x18 \
+ EMIT 0x0F EMIT 0xD4 EMIT 0xF5 \
+ EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x10 \
+ EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \
+ EMIT 0x0F EMIT 0xD4 EMIT 0xCC \
+ EMIT 0x0F EMIT 0x6E EMIT 0x6F EMIT 0x1C \
+ EMIT 0x0F EMIT 0xD4 EMIT 0xDD \
+ EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x14 \
+ EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \
+ EMIT 0x0F EMIT 0xD4 EMIT 0xCE \
+ EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x18 \
+ EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \
+ EMIT 0x0F EMIT 0xD4 EMIT 0xCB \
+ EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x1C \
+ EMIT 0x83 EMIT 0xC7 EMIT 0x20 \
+ EMIT 0x83 EMIT 0xC6 EMIT 0x20 \
+ EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \
+ EMIT 0x0F EMIT 0x7E EMIT 0xC9
+
+#define MULADDC_STOP \
+ EMIT 0x0F EMIT 0x77 \
+ __asm mov c, ecx \
+ __asm mov d, edi \
+ __asm mov s, esi \
+
+#else
+
+#define MULADDC_STOP \
+ __asm mov c, ecx \
+ __asm mov d, edi \
+ __asm mov s, esi \
+
+#endif /* SSE2 */
+#endif /* MSVC */
+
+#endif /* POLARSSL_HAVE_ASM */
+
+#if !defined(MULADDC_CORE)
+#if defined(POLARSSL_HAVE_LONGLONG)
+
+#define MULADDC_INIT \
+{ \
+ t_dbl r; \
+ t_int r0, r1;
+
+#define MULADDC_CORE \
+ r = *(s++) * (t_dbl) b; \
+ r0 = r; \
+ r1 = r >> biL; \
+ r0 += c; r1 += (r0 < c); \
+ r0 += *d; r1 += (r0 < *d); \
+ c = r1; *(d++) = r0;
+
+#define MULADDC_STOP \
+}
+
+#else
+#define MULADDC_INIT \
+{ \
+ t_int s0, s1, b0, b1; \
+ t_int r0, r1, rx, ry; \
+ b0 = ( b << biH ) >> biH; \
+ b1 = ( b >> biH );
+
+#define MULADDC_CORE \
+ s0 = ( *s << biH ) >> biH; \
+ s1 = ( *s >> biH ); s++; \
+ rx = s0 * b1; r0 = s0 * b0; \
+ ry = s1 * b0; r1 = s1 * b1; \
+ r1 += ( rx >> biH ); \
+ r1 += ( ry >> biH ); \
+ rx <<= biH; ry <<= biH; \
+ r0 += rx; r1 += (r0 < rx); \
+ r0 += ry; r1 += (r0 < ry); \
+ r0 += c; r1 += (r0 < c); \
+ r0 += *d; r1 += (r0 < *d); \
+ c = r1; *(d++) = r0;
+
+#define MULADDC_STOP \
+}
+
+#endif /* C (generic) */
+#endif /* C (longlong) */
+
+#endif /* bn_mul.h */
diff --git a/package/px5g/src/polarssl/config.h b/package/px5g/src/polarssl/config.h
new file mode 100644
index 0000000..6463e52
--- /dev/null
+++ b/package/px5g/src/polarssl/config.h
@@ -0,0 +1,329 @@
+/**
+ * \file config.h
+ *
+ * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
+ *
+ * Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the names of PolarSSL or XySSL nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This set of compile-time options may be used to enable
+ * or disable features selectively, and reduce the global
+ * memory footprint.
+ */
+#ifndef POLARSSL_CONFIG_H
+#define POLARSSL_CONFIG_H
+
+#ifndef _CRT_SECURE_NO_DEPRECATE
+#define _CRT_SECURE_NO_DEPRECATE 1
+#endif
+
+/*
+ * Uncomment if native integers are 8-bit wide.
+ *
+#define POLARSSL_HAVE_INT8
+ */
+
+/*
+ * Uncomment if native integers are 16-bit wide.
+ *
+#define POLARSSL_HAVE_INT16
+ */
+
+/*
+ * Uncomment if the compiler supports long long.
+ */
+#define POLARSSL_HAVE_LONGLONG
+
+
+/*
+ * Uncomment to enable the use of assembly code.
+ */
+#define POLARSSL_HAVE_ASM
+
+/*
+ * Uncomment if the CPU supports SSE2 (IA-32 specific).
+ *
+#define POLARSSL_HAVE_SSE2
+ */
+
+/*
+ * Enable all SSL/TLS debugging messages.
+ */
+#define POLARSSL_DEBUG_MSG
+
+/*
+ * Enable the checkup functions (*_self_test).
+ */
+#define POLARSSL_SELF_TEST
+
+/*
+ * Enable the prime-number generation code.
+ */
+#define POLARSSL_GENPRIME
+
+/*
+ * Uncomment this macro to store the AES tables in ROM.
+ *
+#define POLARSSL_AES_ROM_TABLES
+ */
+
+/*
+ * Module: library/aes.c
+ * Caller: library/ssl_tls.c
+ *
+ * This module enables the following ciphersuites:
+ * SSL_RSA_AES_128_SHA
+ * SSL_RSA_AES_256_SHA
+ * SSL_EDH_RSA_AES_256_SHA
+ */
+#define POLARSSL_AES_C
+
+/*
+ * Module: library/arc4.c
+ * Caller: library/ssl_tls.c
+ *
+ * This module enables the following ciphersuites:
+ * SSL_RSA_RC4_128_MD5
+ * SSL_RSA_RC4_128_SHA
+ */
+#define POLARSSL_ARC4_C
+
+/*
+ * Module: library/base64.c
+ * Caller: library/x509parse.c
+ *
+ * This module is required for X.509 support.
+ */
+#define POLARSSL_BASE64_C
+
+/*
+ * Module: library/bignum.c
+ * Caller: library/dhm.c
+ * library/rsa.c
+ * library/ssl_tls.c
+ * library/x509parse.c
+ *
+ * This module is required for RSA and DHM support.
+ */
+#define POLARSSL_BIGNUM_C
+
+/*
+ * Module: library/camellia.c
+ * Caller:
+ *
+ * This module enabled the following cipher suites:
+ */
+#define POLARSSL_CAMELLIA_C
+
+/*
+ * Module: library/certs.c
+ * Caller:
+ *
+ * This module is used for testing (ssl_client/server).
+ */
+#define POLARSSL_CERTS_C
+
+/*
+ * Module: library/debug.c
+ * Caller: library/ssl_cli.c
+ * library/ssl_srv.c
+ * library/ssl_tls.c
+ *
+ * This module provides debugging functions.
+ */
+#define POLARSSL_DEBUG_C
+
+/*
+ * Module: library/des.c
+ * Caller: library/ssl_tls.c
+ *
+ * This module enables the following ciphersuites:
+ * SSL_RSA_DES_168_SHA
+ * SSL_EDH_RSA_DES_168_SHA
+ */
+#define POLARSSL_DES_C
+
+/*
+ * Module: library/dhm.c
+ * Caller: library/ssl_cli.c
+ * library/ssl_srv.c
+ *
+ * This module enables the following ciphersuites:
+ * SSL_EDH_RSA_DES_168_SHA
+ * SSL_EDH_RSA_AES_256_SHA
+ */
+#define POLARSSL_DHM_C
+
+/*
+ * Module: library/havege.c
+ * Caller:
+ *
+ * This module enables the HAVEGE random number generator.
+ */
+#define POLARSSL_HAVEGE_C
+
+/*
+ * Module: library/md2.c
+ * Caller: library/x509parse.c
+ *
+ * Uncomment to enable support for (rare) MD2-signed X.509 certs.
+ *
+#define POLARSSL_MD2_C
+ */
+
+/*
+ * Module: library/md4.c
+ * Caller: library/x509parse.c
+ *
+ * Uncomment to enable support for (rare) MD4-signed X.509 certs.
+ *
+#define POLARSSL_MD4_C
+ */
+
+/*
+ * Module: library/md5.c
+ * Caller: library/ssl_tls.c
+ * library/x509parse.c
+ *
+ * This module is required for SSL/TLS and X.509.
+ */
+#define POLARSSL_MD5_C
+
+/*
+ * Module: library/net.c
+ * Caller:
+ *
+ * This module provides TCP/IP networking routines.
+ */
+#define POLARSSL_NET_C
+
+/*
+ * Module: library/padlock.c
+ * Caller: library/aes.c
+ *
+ * This modules adds support for the VIA PadLock on x86.
+ */
+#define POLARSSL_PADLOCK_C
+
+/*
+ * Module: library/rsa.c
+ * Caller: library/ssl_cli.c
+ * library/ssl_srv.c
+ * library/ssl_tls.c
+ * library/x509.c
+ *
+ * This module is required for SSL/TLS and MD5-signed certificates.
+ */
+#define POLARSSL_RSA_C
+
+/*
+ * Module: library/sha1.c
+ * Caller: library/ssl_cli.c
+ * library/ssl_srv.c
+ * library/ssl_tls.c
+ * library/x509parse.c
+ *
+ * This module is required for SSL/TLS and SHA1-signed certificates.
+ */
+#define POLARSSL_SHA1_C
+
+/*
+ * Module: library/sha2.c
+ * Caller:
+ *
+ * This module adds support for SHA-224 and SHA-256.
+ */
+#define POLARSSL_SHA2_C
+
+/*
+ * Module: library/sha4.c
+ * Caller:
+ *
+ * This module adds support for SHA-384 and SHA-512.
+ */
+#define POLARSSL_SHA4_C
+
+/*
+ * Module: library/ssl_cli.c
+ * Caller:
+ *
+ * This module is required for SSL/TLS client support.
+ */
+#define POLARSSL_SSL_CLI_C
+
+/*
+ * Module: library/ssl_srv.c
+ * Caller:
+ *
+ * This module is required for SSL/TLS server support.
+ */
+#define POLARSSL_SSL_SRV_C
+
+/*
+ * Module: library/ssl_tls.c
+ * Caller: library/ssl_cli.c
+ * library/ssl_srv.c
+ *
+ * This module is required for SSL/TLS.
+ */
+#define POLARSSL_SSL_TLS_C
+
+/*
+ * Module: library/timing.c
+ * Caller: library/havege.c
+ *
+ * This module is used by the HAVEGE random number generator.
+ */
+#define POLARSSL_TIMING_C
+
+/*
+ * Module: library/x509parse.c
+ * Caller: library/ssl_cli.c
+ * library/ssl_srv.c
+ * library/ssl_tls.c
+ *
+ * This module is required for X.509 certificate parsing.
+ */
+#define POLARSSL_X509_PARSE_C
+
+/*
+ * Module: library/x509_write.c
+ * Caller:
+ *
+ * This module is required for X.509 certificate writing.
+ */
+#define POLARSSL_X509_WRITE_C
+
+/*
+ * Module: library/xtea.c
+ * Caller:
+ */
+#define POLARSSL_XTEA_C
+
+#endif /* config.h */
diff --git a/package/px5g/src/polarssl/havege.h b/package/px5g/src/polarssl/havege.h
new file mode 100644
index 0000000..c27ceca
--- /dev/null
+++ b/package/px5g/src/polarssl/havege.h
@@ -0,0 +1,75 @@
+/**
+ * \file havege.h
+ *
+ * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
+ *
+ * Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the names of PolarSSL or XySSL nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef POLARSSL_HAVEGE_H
+#define POLARSSL_HAVEGE_H
+
+#define COLLECT_SIZE 1024
+
+/**
+ * \brief HAVEGE state structure
+ */
+typedef struct
+{
+ int PT1, PT2, offset[2];
+ int pool[COLLECT_SIZE];
+ int WALK[8192];
+}
+havege_state;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \brief HAVEGE initialization
+ *
+ * \param hs HAVEGE state to be initialized
+ */
+void havege_init( havege_state *hs );
+
+/**
+ * \brief HAVEGE rand function
+ *
+ * \param rng_st points to an HAVEGE state
+ *
+ * \return A random int
+ */
+int havege_rand( void *p_rng );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* havege.h */
diff --git a/package/px5g/src/polarssl/rsa.h b/package/px5g/src/polarssl/rsa.h
new file mode 100644
index 0000000..b31dc2f
--- /dev/null
+++ b/package/px5g/src/polarssl/rsa.h
@@ -0,0 +1,309 @@
+/**
+ * \file rsa.h
+ *
+ * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
+ *
+ * Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the names of PolarSSL or XySSL nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef POLARSSL_RSA_H
+#define POLARSSL_RSA_H
+
+#include "polarssl/bignum.h"
+
+#define POLARSSL_ERR_RSA_BAD_INPUT_DATA -0x0400
+#define POLARSSL_ERR_RSA_INVALID_PADDING -0x0410
+#define POLARSSL_ERR_RSA_KEY_GEN_FAILED -0x0420
+#define POLARSSL_ERR_RSA_KEY_CHECK_FAILED -0x0430
+#define POLARSSL_ERR_RSA_PUBLIC_FAILED -0x0440
+#define POLARSSL_ERR_RSA_PRIVATE_FAILED -0x0450
+#define POLARSSL_ERR_RSA_VERIFY_FAILED -0x0460
+#define POLARSSL_ERR_RSA_OUTPUT_TO_LARGE -0x0470
+
+/*
+ * PKCS#1 constants
+ */
+#define RSA_RAW 0
+#define RSA_MD2 2
+#define RSA_MD4 3
+#define RSA_MD5 4
+#define RSA_SHA1 5
+#define RSA_SHA256 6
+
+#define RSA_PUBLIC 0
+#define RSA_PRIVATE 1
+
+#define RSA_PKCS_V15 0
+#define RSA_PKCS_V21 1
+
+#define RSA_SIGN 1
+#define RSA_CRYPT 2
+
+/*
+ * DigestInfo ::= SEQUENCE {
+ * digestAlgorithm DigestAlgorithmIdentifier,
+ * digest Digest }
+ *
+ * DigestAlgorithmIdentifier ::= AlgorithmIdentifier
+ *
+ * Digest ::= OCTET STRING
+ */
+#define ASN1_HASH_MDX \
+ "\x30\x20\x30\x0C\x06\x08\x2A\x86\x48" \
+ "\x86\xF7\x0D\x02\x00\x05\x00\x04\x10"
+
+#define ASN1_HASH_SHA1 \
+ "\x30\x21\x30\x09\x06\x05\x2B\x0E\x03" \
+ "\x02\x1A\x05\x00\x04\x14"
+
+/**
+ * \brief RSA context structure
+ */
+typedef struct
+{
+ int ver; /*!< always 0 */
+ int len; /*!< size(N) in chars */
+
+ mpi N; /*!< public modulus */
+ mpi E; /*!< public exponent */
+
+ mpi D; /*!< private exponent */
+ mpi P; /*!< 1st prime factor */
+ mpi Q; /*!< 2nd prime factor */
+ mpi DP; /*!< D % (P - 1) */
+ mpi DQ; /*!< D % (Q - 1) */
+ mpi QP; /*!< 1 / (Q % P) */
+
+ mpi RN; /*!< cached R^2 mod N */
+ mpi RP; /*!< cached R^2 mod P */
+ mpi RQ; /*!< cached R^2 mod Q */
+
+ int padding; /*!< 1.5 or OAEP/PSS */
+ int hash_id; /*!< hash identifier */
+ int (*f_rng)(void *); /*!< RNG function */
+ void *p_rng; /*!< RNG parameter */
+}
+rsa_context;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \brief Initialize an RSA context
+ *
+ * \param ctx RSA context to be initialized
+ * \param padding RSA_PKCS_V15 or RSA_PKCS_V21
+ * \param hash_id RSA_PKCS_V21 hash identifier
+ * \param f_rng RNG function
+ * \param p_rng RNG parameter
+ *
+ * \note The hash_id parameter is actually ignored
+ * when using RSA_PKCS_V15 padding.
+ *
+ * \note Currently (xyssl-0.8), RSA_PKCS_V21 padding
+ * is not supported.
+ */
+void rsa_init( rsa_context *ctx,
+ int padding,
+ int hash_id,
+ int (*f_rng)(void *),
+ void *p_rng );
+
+/**
+ * \brief Generate an RSA keypair
+ *
+ * \param ctx RSA context that will hold the key
+ * \param nbits size of the public key in bits
+ * \param exponent public exponent (e.g., 65537)
+ *
+ * \note rsa_init() must be called beforehand to setup
+ * the RSA context (especially f_rng and p_rng).
+ *
+ * \return 0 if successful, or an POLARSSL_ERR_RSA_XXX error code
+ */
+int rsa_gen_key( rsa_context *ctx, int nbits, int exponent );
+
+/**
+ * \brief Check a public RSA key
+ *
+ * \param ctx RSA context to be checked
+ *
+ * \return 0 if successful, or an POLARSSL_ERR_RSA_XXX error code
+ */
+int rsa_check_pubkey( rsa_context *ctx );
+
+/**
+ * \brief Check a private RSA key
+ *
+ * \param ctx RSA context to be checked
+ *
+ * \return 0 if successful, or an POLARSSL_ERR_RSA_XXX error code
+ */
+int rsa_check_privkey( rsa_context *ctx );
+
+/**
+ * \brief Do an RSA public key operation
+ *
+ * \param ctx RSA context
+ * \param input input buffer
+ * \param output output buffer
+ *
+ * \return 0 if successful, or an POLARSSL_ERR_RSA_XXX error code
+ *
+ * \note This function does NOT take care of message
+ * padding. Also, be sure to set input[0] = 0.
+ *
+ * \note The input and output buffers must be large
+ * enough (eg. 128 bytes if RSA-1024 is used).
+ */
+int rsa_public( rsa_context *ctx,
+ unsigned char *input,
+ unsigned char *output );
+
+/**
+ * \brief Do an RSA private key operation
+ *
+ * \param ctx RSA context
+ * \param input input buffer
+ * \param output output buffer
+ *
+ * \return 0 if successful, or an POLARSSL_ERR_RSA_XXX error code
+ *
+ * \note The input and output buffers must be large
+ * enough (eg. 128 bytes if RSA-1024 is used).
+ */
+int rsa_private( rsa_context *ctx,
+ unsigned char *input,
+ unsigned char *output );
+
+/**
+ * \brief Add the message padding, then do an RSA operation
+ *
+ * \param ctx RSA context
+ * \param mode RSA_PUBLIC or RSA_PRIVATE
+ * \param ilen contains the the plaintext length
+ * \param input buffer holding the data to be encrypted
+ * \param output buffer that will hold the ciphertext
+ *
+ * \return 0 if successful, or an POLARSSL_ERR_RSA_XXX error code
+ *
+ * \note The output buffer must be as large as the size
+ * of ctx->N (eg. 128 bytes if RSA-1024 is used).
+ */
+int rsa_pkcs1_encrypt( rsa_context *ctx,
+ int mode, int ilen,
+ unsigned char *input,
+ unsigned char *output );
+
+/**
+ * \brief Do an RSA operation, then remove the message padding
+ *
+ * \param ctx RSA context
+ * \param mode RSA_PUBLIC or RSA_PRIVATE
+ * \param input buffer holding the encrypted data
+ * \param output buffer that will hold the plaintext
+ * \param olen will contain the plaintext length
+ * \param output_max_len maximum length of the output buffer
+ *
+ * \return 0 if successful, or an POLARSSL_ERR_RSA_XXX error code
+ *
+ * \note The output buffer must be as large as the size
+ * of ctx->N (eg. 128 bytes if RSA-1024 is used) otherwise
+ * an error is thrown.
+ */
+int rsa_pkcs1_decrypt( rsa_context *ctx,
+ int mode, int *olen,
+ unsigned char *input,
+ unsigned char *output,
+ int output_max_len);
+
+/**
+ * \brief Do a private RSA to sign a message digest
+ *
+ * \param ctx RSA context
+ * \param mode RSA_PUBLIC or RSA_PRIVATE
+ * \param hash_id RSA_RAW, RSA_MD{2,4,5} or RSA_SHA{1,256}
+ * \param hashlen message digest length (for RSA_RAW only)
+ * \param hash buffer holding the message digest
+ * \param sig buffer that will hold the ciphertext
+ *
+ * \return 0 if the signing operation was successful,
+ * or an POLARSSL_ERR_RSA_XXX error code
+ *
+ * \note The "sig" buffer must be as large as the size
+ * of ctx->N (eg. 128 bytes if RSA-1024 is used).
+ */
+int rsa_pkcs1_sign( rsa_context *ctx,
+ int mode,
+ int hash_id,
+ int hashlen,
+ unsigned char *hash,
+ unsigned char *sig );
+
+/**
+ * \brief Do a public RSA and check the message digest
+ *
+ * \param ctx points to an RSA public key
+ * \param mode RSA_PUBLIC or RSA_PRIVATE
+ * \param hash_id RSA_RAW, RSA_MD{2,4,5} or RSA_SHA{1,256}
+ * \param hashlen message digest length (for RSA_RAW only)
+ * \param hash buffer holding the message digest
+ * \param sig buffer holding the ciphertext
+ *
+ * \return 0 if the verify operation was successful,
+ * or an POLARSSL_ERR_RSA_XXX error code
+ *
+ * \note The "sig" buffer must be as large as the size
+ * of ctx->N (eg. 128 bytes if RSA-1024 is used).
+ */
+int rsa_pkcs1_verify( rsa_context *ctx,
+ int mode,
+ int hash_id,
+ int hashlen,
+ unsigned char *hash,
+ unsigned char *sig );
+
+/**
+ * \brief Free the components of an RSA key
+ */
+void rsa_free( rsa_context *ctx );
+
+/**
+ * \brief Checkup routine
+ *
+ * \return 0 if successful, or 1 if the test failed
+ */
+int rsa_self_test( int verbose );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* rsa.h */
diff --git a/package/px5g/src/polarssl/sha1.h b/package/px5g/src/polarssl/sha1.h
new file mode 100644
index 0000000..3ca7dc3
--- /dev/null
+++ b/package/px5g/src/polarssl/sha1.h
@@ -0,0 +1,150 @@
+/**
+ * \file sha1.h
+ *
+ * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
+ *
+ * Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the names of PolarSSL or XySSL nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef POLARSSL_SHA1_H
+#define POLARSSL_SHA1_H
+
+/**
+ * \brief SHA-1 context structure
+ */
+typedef struct
+{
+ unsigned long total[2]; /*!< number of bytes processed */
+ unsigned long state[5]; /*!< intermediate digest state */
+ unsigned char buffer[64]; /*!< data block being processed */
+
+ unsigned char ipad[64]; /*!< HMAC: inner padding */
+ unsigned char opad[64]; /*!< HMAC: outer padding */
+}
+sha1_context;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \brief SHA-1 context setup
+ *
+ * \param ctx context to be initialized
+ */
+void sha1_starts( sha1_context *ctx );
+
+/**
+ * \brief SHA-1 process buffer
+ *
+ * \param ctx SHA-1 context
+ * \param input buffer holding the data
+ * \param ilen length of the input data
+ */
+void sha1_update( sha1_context *ctx, unsigned char *input, int ilen );
+
+/**
+ * \brief SHA-1 final digest
+ *
+ * \param ctx SHA-1 context
+ * \param output SHA-1 checksum result
+ */
+void sha1_finish( sha1_context *ctx, unsigned char output[20] );
+
+/**
+ * \brief Output = SHA-1( input buffer )
+ *
+ * \param input buffer holding the data
+ * \param ilen length of the input data
+ * \param output SHA-1 checksum result
+ */
+void sha1( unsigned char *input, int ilen, unsigned char output[20] );
+
+/**
+ * \brief Output = SHA-1( file contents )
+ *
+ * \param path input file name
+ * \param output SHA-1 checksum result
+ *
+ * \return 0 if successful, 1 if fopen failed,
+ * or 2 if fread failed
+ */
+int sha1_file( char *path, unsigned char output[20] );
+
+/**
+ * \brief SHA-1 HMAC context setup
+ *
+ * \param ctx HMAC context to be initialized
+ * \param key HMAC secret key
+ * \param keylen length of the HMAC key
+ */
+void sha1_hmac_starts( sha1_context *ctx, unsigned char *key, int keylen );
+
+/**
+ * \brief SHA-1 HMAC process buffer
+ *
+ * \param ctx HMAC context
+ * \param input buffer holding the data
+ * \param ilen length of the input data
+ */
+void sha1_hmac_update( sha1_context *ctx, unsigned char *input, int ilen );
+
+/**
+ * \brief SHA-1 HMAC final digest
+ *
+ * \param ctx HMAC context
+ * \param output SHA-1 HMAC checksum result
+ */
+void sha1_hmac_finish( sha1_context *ctx, unsigned char output[20] );
+
+/**
+ * \brief Output = HMAC-SHA-1( hmac key, input buffer )
+ *
+ * \param key HMAC secret key
+ * \param keylen length of the HMAC key
+ * \param input buffer holding the data
+ * \param ilen length of the input data
+ * \param output HMAC-SHA-1 result
+ */
+void sha1_hmac( unsigned char *key, int keylen,
+ unsigned char *input, int ilen,
+ unsigned char output[20] );
+
+/**
+ * \brief Checkup routine
+ *
+ * \return 0 if successful, or 1 if the test failed
+ */
+int sha1_self_test( int verbose );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* sha1.h */
diff --git a/package/px5g/src/polarssl/timing.h b/package/px5g/src/polarssl/timing.h
new file mode 100644
index 0000000..62d627f
--- /dev/null
+++ b/package/px5g/src/polarssl/timing.h
@@ -0,0 +1,81 @@
+/**
+ * \file timing.h
+ *
+ * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
+ *
+ * Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the names of PolarSSL or XySSL nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef POLARSSL_TIMING_H
+#define POLARSSL_TIMING_H
+
+/**
+ * \brief timer structure
+ */
+struct hr_time
+{
+ unsigned char opaque[32];
+};
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern int alarmed;
+
+/**
+ * \brief Return the CPU cycle counter value
+ */
+unsigned long hardclock( void );
+
+/**
+ * \brief Return the elapsed time in milliseconds
+ *
+ * \param val points to a timer structure
+ * \param reset if set to 1, the timer is restarted
+ */
+unsigned long get_timer( struct hr_time *val, int reset );
+
+/**
+ * \brief Setup an alarm clock
+ *
+ * \param seconds delay before the "alarmed" flag is set
+ */
+void set_alarm( int seconds );
+
+/**
+ * \brief Sleep for a certain amount of time
+ */
+void m_sleep( int milliseconds );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* timing.h */
diff --git a/package/px5g/src/polarssl/x509.h b/package/px5g/src/polarssl/x509.h
new file mode 100644
index 0000000..908a1db
--- /dev/null
+++ b/package/px5g/src/polarssl/x509.h
@@ -0,0 +1,549 @@
+/**
+ * \file x509.h
+ *
+ * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
+ *
+ * Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the names of PolarSSL or XySSL nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef POLARSSL_X509_H
+#define POLARSSL_X509_H
+
+#include "polarssl/rsa.h"
+
+#define POLARSSL_ERR_ASN1_OUT_OF_DATA -0x0014
+#define POLARSSL_ERR_ASN1_UNEXPECTED_TAG -0x0016
+#define POLARSSL_ERR_ASN1_INVALID_LENGTH -0x0018
+#define POLARSSL_ERR_ASN1_LENGTH_MISMATCH -0x001A
+#define POLARSSL_ERR_ASN1_INVALID_DATA -0x001C
+
+#define POLARSSL_ERR_X509_FEATURE_UNAVAILABLE -0x0020
+#define POLARSSL_ERR_X509_CERT_INVALID_PEM -0x0040
+#define POLARSSL_ERR_X509_CERT_INVALID_FORMAT -0x0060
+#define POLARSSL_ERR_X509_CERT_INVALID_VERSION -0x0080
+#define POLARSSL_ERR_X509_CERT_INVALID_SERIAL -0x00A0
+#define POLARSSL_ERR_X509_CERT_INVALID_ALG -0x00C0
+#define POLARSSL_ERR_X509_CERT_INVALID_NAME -0x00E0
+#define POLARSSL_ERR_X509_CERT_INVALID_DATE -0x0100
+#define POLARSSL_ERR_X509_CERT_INVALID_PUBKEY -0x0120
+#define POLARSSL_ERR_X509_CERT_INVALID_SIGNATURE -0x0140
+#define POLARSSL_ERR_X509_CERT_INVALID_EXTENSIONS -0x0160
+#define POLARSSL_ERR_X509_CERT_UNKNOWN_VERSION -0x0180
+#define POLARSSL_ERR_X509_CERT_UNKNOWN_SIG_ALG -0x01A0
+#define POLARSSL_ERR_X509_CERT_UNKNOWN_PK_ALG -0x01C0
+#define POLARSSL_ERR_X509_CERT_SIG_MISMATCH -0x01E0
+#define POLARSSL_ERR_X509_CERT_VERIFY_FAILED -0x0200
+#define POLARSSL_ERR_X509_KEY_INVALID_PEM -0x0220
+#define POLARSSL_ERR_X509_KEY_INVALID_VERSION -0x0240
+#define POLARSSL_ERR_X509_KEY_INVALID_FORMAT -0x0260
+#define POLARSSL_ERR_X509_KEY_INVALID_ENC_IV -0x0280
+#define POLARSSL_ERR_X509_KEY_UNKNOWN_ENC_ALG -0x02A0
+#define POLARSSL_ERR_X509_KEY_PASSWORD_REQUIRED -0x02C0
+#define POLARSSL_ERR_X509_KEY_PASSWORD_MISMATCH -0x02E0
+#define POLARSSL_ERR_X509_POINT_ERROR -0x0300
+#define POLARSSL_ERR_X509_VALUE_TO_LENGTH -0x0320
+
+#define BADCERT_EXPIRED 1
+#define BADCERT_REVOKED 2
+#define BADCERT_CN_MISMATCH 4
+#define BADCERT_NOT_TRUSTED 8
+
+/*
+ * DER constants
+ */
+#define ASN1_BOOLEAN 0x01
+#define ASN1_INTEGER 0x02
+#define ASN1_BIT_STRING 0x03
+#define ASN1_OCTET_STRING 0x04
+#define ASN1_NULL 0x05
+#define ASN1_OID 0x06
+#define ASN1_UTF8_STRING 0x0C
+#define ASN1_SEQUENCE 0x10
+#define ASN1_SET 0x11
+#define ASN1_PRINTABLE_STRING 0x13
+#define ASN1_T61_STRING 0x14
+#define ASN1_IA5_STRING 0x16
+#define ASN1_UTC_TIME 0x17
+#define ASN1_UNIVERSAL_STRING 0x1C
+#define ASN1_BMP_STRING 0x1E
+#define ASN1_PRIMITIVE 0x00
+#define ASN1_CONSTRUCTED 0x20
+#define ASN1_CONTEXT_SPECIFIC 0x80
+
+/*
+ * various object identifiers
+ */
+#define X520_COMMON_NAME 3
+#define X520_COUNTRY 6
+#define X520_LOCALITY 7
+#define X520_STATE 8
+#define X520_ORGANIZATION 10
+#define X520_ORG_UNIT 11
+#define PKCS9_EMAIL 1
+
+#define X509_OUTPUT_DER 0x01
+#define X509_OUTPUT_PEM 0x02
+#define PEM_LINE_LENGTH 72
+#define X509_ISSUER 0x01
+#define X509_SUBJECT 0x02
+
+#define OID_X520 "\x55\x04"
+#define OID_CN "\x55\x04\x03"
+#define OID_PKCS1 "\x2A\x86\x48\x86\xF7\x0D\x01\x01"
+#define OID_PKCS1_RSA "\x2A\x86\x48\x86\xF7\x0D\x01\x01\x01"
+#define OID_PKCS1_RSA_SHA "\x2A\x86\x48\x86\xF7\x0D\x01\x01\x05"
+#define OID_PKCS9 "\x2A\x86\x48\x86\xF7\x0D\x01\x09"
+#define OID_PKCS9_EMAIL "\x2A\x86\x48\x86\xF7\x0D\x01\x09\x01"
+
+/*
+ * Structures for parsing X.509 certificates
+ */
+typedef struct _x509_buf
+{
+ int tag;
+ int len;
+ unsigned char *p;
+}
+x509_buf;
+
+typedef struct _x509_name
+{
+ x509_buf oid;
+ x509_buf val;
+ struct _x509_name *next;
+}
+x509_name;
+
+typedef struct _x509_time
+{
+ int year, mon, day;
+ int hour, min, sec;
+}
+x509_time;
+
+typedef struct _x509_cert
+{
+ x509_buf raw;
+ x509_buf tbs;
+
+ int version;
+ x509_buf serial;
+ x509_buf sig_oid1;
+
+ x509_buf issuer_raw;
+ x509_buf subject_raw;
+
+ x509_name issuer;
+ x509_name subject;
+
+ x509_time valid_from;
+ x509_time valid_to;
+
+ x509_buf pk_oid;
+ rsa_context rsa;
+
+ x509_buf issuer_id;
+ x509_buf subject_id;
+ x509_buf v3_ext;
+
+ int ca_istrue;
+ int max_pathlen;
+
+ x509_buf sig_oid2;
+ x509_buf sig;
+
+ struct _x509_cert *next;
+}
+x509_cert;
+
+/*
+ * Structures for writing X.509 certificates
+ */
+typedef struct _x509_node
+{
+ unsigned char *data;
+ unsigned char *p;
+ unsigned char *end;
+
+ size_t len;
+}
+x509_node;
+
+typedef struct _x509_raw
+{
+ x509_node raw;
+ x509_node tbs;
+
+ x509_node version;
+ x509_node serial;
+ x509_node tbs_signalg;
+ x509_node issuer;
+ x509_node validity;
+ x509_node subject;
+ x509_node subpubkey;
+
+ x509_node signalg;
+ x509_node sign;
+}
+x509_raw;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \brief Parse one or more certificates and add them
+ * to the chained list
+ *
+ * \param chain points to the start of the chain
+ * \param buf buffer holding the certificate data
+ * \param buflen size of the buffer
+ *
+ * \return 0 if successful, or a specific X509 error code
+ */
+int x509parse_crt( x509_cert *crt, unsigned char *buf, int buflen );
+
+/**
+ * \brief Load one or more certificates and add them
+ * to the chained list
+ *
+ * \param chain points to the start of the chain
+ * \param path filename to read the certificates from
+ *
+ * \return 0 if successful, or a specific X509 error code
+ */
+int x509parse_crtfile( x509_cert *crt, char *path );
+
+/**
+ * \brief Parse a private RSA key
+ *
+ * \param rsa RSA context to be initialized
+ * \param buf input buffer
+ * \param buflen size of the buffer
+ * \param pwd password for decryption (optional)
+ * \param pwdlen size of the password
+ *
+ * \return 0 if successful, or a specific X509 error code
+ */
+int x509parse_key( rsa_context *rsa,
+ unsigned char *buf, int buflen,
+ unsigned char *pwd, int pwdlen );
+
+/**
+ * \brief Load and parse a private RSA key
+ *
+ * \param rsa RSA context to be initialized
+ * \param path filename to read the private key from
+ * \param pwd password to decrypt the file (can be NULL)
+ *
+ * \return 0 if successful, or a specific X509 error code
+ */
+int x509parse_keyfile( rsa_context *rsa, char *path, char *password );
+
+/**
+ * \brief Store the certificate DN in printable form into buf;
+ * no more than (end - buf) characters will be written.
+ */
+int x509parse_dn_gets( char *buf, char *end, x509_name *dn );
+
+/**
+ * \brief Returns an informational string about the
+ * certificate.
+ */
+char *x509parse_cert_info( char *prefix, x509_cert *crt );
+
+/**
+ * \brief Return 0 if the certificate is still valid,
+ * or BADCERT_EXPIRED
+ */
+int x509parse_expired( x509_cert *crt );
+
+/**
+ * \brief Verify the certificate signature
+ *
+ * \param crt a certificate to be verified
+ * \param trust_ca the trusted CA chain
+ * \param cn expected Common Name (can be set to
+ * NULL if the CN must not be verified)
+ * \param flags result of the verification
+ *
+ * \return 0 if successful or POLARSSL_ERR_X509_SIG_VERIFY_FAILED,
+ * in which case *flags will have one or more of
+ * the following values set:
+ * BADCERT_EXPIRED --
+ * BADCERT_REVOKED --
+ * BADCERT_CN_MISMATCH --
+ * BADCERT_NOT_TRUSTED
+ *
+ * \note TODO: add two arguments, depth and crl
+ */
+int x509parse_verify( x509_cert *crt,
+ x509_cert *trust_ca,
+ char *cn, int *flags );
+
+/**
+ * \brief Unallocate all certificate data
+ */
+void x509_free( x509_cert *crt );
+
+/**
+ * \brief Checkup routine
+ *
+ * \return 0 if successful, or 1 if the test failed
+ */
+int x509_self_test( int verbose );
+
+/**
+ * \brief Write a certificate info file
+ *
+ * \param chain points to the raw certificate data
+ * \param path filename to write the certificate to
+ * \param format X509_OUTPUT_DER or X509_OUTPUT_PEM
+ *
+ * \return 0 if successful, or a specific X509 error code
+ */
+int x509write_crtfile( x509_raw *chain,
+ unsigned char *path,
+ int format );
+
+/**
+ * \brief Write a certificate signing request message format file
+ *
+ * \param chain points to the raw certificate (with x509write_create_csr) data
+ * \param path filename to write the certificate to
+ * \param format X509_OUTPUT_DER or X509_OUTPUT_PEM
+ *
+ * \return 0 if successful, or a specific X509 error code
+ */
+int x509write_csrfile( x509_raw *chain,
+ unsigned char *path,
+ int format );
+
+/*
+ * \brief Write a private RSA key into a file
+ *
+ * \param rsa points to an RSA key
+ * \param path filename to write the key to
+ * \param format X509_OUTPUT_DER or X509_OUTPUT_PEM
+ *
+ * \return 0 if successful, or a specific X509 error code
+ */
+int x509write_keyfile( rsa_context *rsa,
+ char *path,
+ int format );
+
+/**
+ * \brief Add a public key to certificate
+ *
+ * \param chain points to the raw certificate data
+ * \param pubkey points to an RSA key
+ *
+ * \return 0 if successful, or a specific X509 error code
+ */
+int x509write_add_pubkey( x509_raw *chain, rsa_context *pubkey );
+
+/**
+ * \brief Create x509 subject/issuer field to raw certificate
+ * from string or CA cert. Make string NULL if you will
+ * use the CA copy function or make CA NULL then used
+ * the string parse.
+ *
+ * \param chain points to the raw certificate data
+ * \param names a string that can hold (separete with ";"):
+ * CN=CommonName
+ * -- O=Organization
+ * -- OU=OrgUnit
+ * -- ST=State
+ * -- L=Locality
+ * -- R=Email
+ * -- C=Country
+ * . Make that NULL if you didn't need that.
+ * \param flag flag is X509_ISSUER or X509_SUBJECT that defined
+ * where change
+ * \param ca the certificate for copy data. Make that NULL if you
+ * didn't need that.
+ * \param ca_flag set the ca field from copy to crt
+ *
+ * \return 0 if successful, or a specific X509 error code
+ */
+int x509write_add_customize ( x509_raw *crt,
+ unsigned char *names,
+ int flag,
+ x509_cert *ca,
+ int ca_flag );
+
+/**
+* \brief Add x509 issuer field
+*
+* \param chain points to the raw certificate data
+* \param issuer a string holding (separete with ";"):
+* CN=CommonName
+* -- O=Organization
+* -- OU=OrgUnit
+* -- ST=State
+* -- L=Locality
+* -- R=Email
+* -- C=Country
+* . Set this to NULL if not needed.
+* \return 0 if successful, or a specific X509 error code
+*/
+int x509write_add_issuer( x509_raw *crt, unsigned char *issuer);
+
+/**
+ * \brief Add x509 subject field
+ *
+ * \param chain points to the raw certificate data
+ * \param subject a string holding (separete with ";"):
+ * CN=CommonName
+ * -- O=Organization
+ * -- OU=OrgUnit
+ * -- ST=State
+ * -- L=Locality
+ * -- R=Email
+ * -- C=Country
+ * . Set this to NULL if not needed.
+ * \return 0 if successful, or a specific X509 error code
+ */
+int x509write_add_subject( x509_raw *crt, unsigned char *subject);
+
+/**
+* \brief Copy x509 issuer field from another certificate
+*
+* \param chain points to the raw certificate data
+* \param from_crt the certificate whose issuer is to be copied.
+* \return 0 if successful, or a specific X509 error code
+*/
+int x509write_copy_issuer(x509_raw *crt, x509_cert *from_crt);
+
+/**
+* \brief Copy x509 subject field from another certificate
+*
+* \param chain points to the raw certificate data
+* \param from_crt the certificate whose subject is to be copied.
+* \return 0 if successful, or a specific X509 error code
+*/
+int x509write_copy_subject(x509_raw *crt, x509_cert *from_crt);
+
+/**
+* \brief Copy x509 issuer field from the subject of another certificate
+*
+* \param chain points to the raw certificate data
+* \param from_crt the certificate whose subject is to be copied.
+* \return 0 if successful, or a specific X509 error code
+*/
+int x509write_copy_issuer_from_subject(x509_raw *crt, x509_cert *from_crt);
+
+/**
+* \brief Copy x509 subject field from the issuer of another certificate
+*
+* \param chain points to the raw certificate data
+* \param from_crt the certificate whose issuer is to be copied.
+* \return 0 if successful, or a specific X509 error code
+*/
+int x509write_copy_subject_from_issuer(x509_raw *crt, x509_cert *from_crt);
+
+/**
+ * \brief Create x509 validity time in UTC
+ *
+ * \param chain points to the raw certificate data
+ * \param before valid not before in format YYYY-MM-DD hh:mm:ss
+ * \param after valid not after in format YYYY-MM-DD hh:mm:ss
+ *
+ * \return 0 if successful, or a specific X509 error code
+ */
+int x509write_add_validity( x509_raw *crt,
+ unsigned char *before,
+ unsigned char *after );
+
+/**
+ * \brief Create a self-signed certificate
+ *
+ * \param chain points to the raw certificate data
+ * \param rsa a private key to sign the certificate
+ *
+ * \return 0 if successful, or a specific X509 error code
+ */
+int x509write_create_selfsign( x509_raw *crt, rsa_context *raw );
+
+/**
+ * \brief Create a certificate
+ *
+ * \param chain points to the raw certificate data
+ * \param rsa a private key to sign the certificate
+ *
+ * \return 0 if successful, or a specific X509 error code
+ */
+int x509write_create_sign( x509_raw *crt, rsa_context *raw );
+
+/**
+ * \brief Create a certificate signing request
+ *
+ * \param chain points to the raw certificate data. Didn't use the
+ * same chain that u have use for certificate.
+ * \param privkey a rsa private key
+ *
+ * \return 0 if successful, or a specific X509 error code
+ */
+int x509write_create_csr( x509_raw *chain, rsa_context *privkey );
+
+/**
+ * \brief Serialize an rsa key into DER
+ *
+ * \param rsa a rsa key for output
+ * \param node a x509 node for write into
+ *
+ * \return 0 if successful, or a specific X509 error code
+ */
+int x509write_serialize_key( rsa_context *rsa, x509_node *node );
+
+/**
+ * \brief Unallocate all raw certificate data
+ */
+void x509write_free_raw( x509_raw *crt );
+
+/**
+ * \brief Allocate all raw certificate data
+ */
+void x509write_init_raw( x509_raw *crt );
+
+/**
+ * \brief Unallocate all node certificate data
+ */
+void x509write_free_node( x509_node *crt_node );
+
+/**
+ * \brief Allocate all node certificate data
+ */
+void x509write_init_node( x509_node *crt_node );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* x509.h */
diff --git a/package/px5g/src/px5g.c b/package/px5g/src/px5g.c
new file mode 100644
index 0000000..2b3e785
--- /dev/null
+++ b/package/px5g/src/px5g.c
@@ -0,0 +1,197 @@
+/*
+ * px5g - Embedded x509 key and certificate generator based on PolarSSL
+ *
+ * Copyright (C) 2009 Steven Barth <steven@midlink.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License, version 2.1 as published by the Free Software Foundation.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include "polarssl/havege.h"
+#include "polarssl/bignum.h"
+#include "polarssl/x509.h"
+#include "polarssl/rsa.h"
+
+#define PX5G_VERSION "0.1"
+#define PX5G_COPY "Copyright (c) 2009 Steven Barth <steven@midlink.org>"
+#define PX5G_LICENSE "Licensed under the GNU Lesser General Public License v2.1"
+
+int rsakey(char **arg) {
+ havege_state hs;
+ rsa_context rsa;
+
+ unsigned int ksize = 512;
+ int exp = 65537;
+ char *path = NULL;
+ int flag = X509_OUTPUT_PEM;
+
+ while (*arg && **arg == '-') {
+ if (!strcmp(*arg, "-out") && arg[1]) {
+ path = arg[1];
+ arg++;
+ } else if (!strcmp(*arg, "-3")) {
+ exp = 3;
+ } else if (!strcmp(*arg, "-der")) {
+ flag = X509_OUTPUT_DER;
+ }
+ arg++;
+ }
+
+ if (*arg) {
+ ksize = (unsigned int)atoi(*arg);
+ }
+
+ havege_init(&hs);
+ rsa_init(&rsa, RSA_PKCS_V15, 0, havege_rand, &hs);
+
+ fprintf(stderr, "Generating RSA private key, %i bit long modulus\n", ksize);
+ if (rsa_gen_key(&rsa, ksize, exp)) {
+ fprintf(stderr, "error: key generation failed\n");
+ return 1;
+ }
+
+ if (x509write_keyfile(&rsa, path, flag)) {
+ fprintf(stderr, "error: I/O error\n");
+ return 1;
+ }
+
+ rsa_free(&rsa);
+ return 0;
+}
+
+int selfsigned(char **arg) {
+ havege_state hs;
+ rsa_context rsa;
+ x509_node node;
+
+ char *subject = "";
+ unsigned int ksize = 512;
+ int exp = 65537;
+ unsigned int days = 30;
+ char *keypath = NULL, *certpath = NULL;
+ int flag = X509_OUTPUT_PEM;
+ time_t from = time(NULL), to;
+ char fstr[20], tstr[20];
+
+ while (*arg && **arg == '-') {
+ if (!strcmp(*arg, "-der")) {
+ flag = X509_OUTPUT_DER;
+ } else if (!strcmp(*arg, "-newkey") && arg[1]) {
+ if (strncmp(arg[1], "rsa:", 4)) {
+ fprintf(stderr, "error: invalid algorithm");
+ return 1;
+ }
+ ksize = (unsigned int)atoi(arg[1] + 4);
+ arg++;
+ } else if (!strcmp(*arg, "-days") && arg[1]) {
+ days = (unsigned int)atoi(arg[1]);
+ arg++;
+ } else if (!strcmp(*arg, "-keyout") && arg[1]) {
+ keypath = arg[1];
+ arg++;
+ } else if (!strcmp(*arg, "-out") && arg[1]) {
+ certpath = arg[1];
+ arg++;
+ } else if (!strcmp(*arg, "-subj") && arg[1]) {
+ if (arg[1][0] != '/' || strchr(arg[1], ';')) {
+ fprintf(stderr, "error: invalid subject");
+ return 1;
+ }
+ subject = calloc(strlen(arg[1]) + 1, 1);
+ char *oldc = arg[1] + 1, *newc = subject, *delim;
+ do {
+ delim = strchr(oldc, '=');
+ if (!delim) {
+ fprintf(stderr, "error: invalid subject");
+ return 1;
+ }
+ memcpy(newc, oldc, delim - oldc + 1);
+ newc += delim - oldc + 1;
+ oldc = delim + 1;
+
+ delim = strchr(oldc, '/');
+ if (!delim) {
+ delim = arg[1] + strlen(arg[1]);
+ }
+ memcpy(newc, oldc, delim - oldc);
+ newc += delim - oldc;
+ *newc++ = ';';
+ oldc = delim + 1;
+ } while(*delim);
+ arg++;
+ }
+ arg++;
+ }
+
+ havege_init(&hs);
+ rsa_init(&rsa, RSA_PKCS_V15, 0, havege_rand, &hs);
+ x509write_init_node(&node);
+ fprintf(stderr, "Generating RSA private key, %i bit long modulus\n", ksize);
+ if (rsa_gen_key(&rsa, ksize, exp)) {
+ fprintf(stderr, "error: key generation failed\n");
+ return 1;
+ }
+
+ if (keypath) {
+ if (x509write_keyfile(&rsa, keypath, flag)) {
+ fprintf(stderr, "error: I/O error\n");
+ return 1;
+ }
+ }
+
+ from = (from < 1000000000) ? 1000000000 : from;
+ strftime(fstr, sizeof(fstr), "%F %H:%M:%S", gmtime(&from));
+ to = from + 60 * 60 * 24 * days;
+ strftime(tstr, sizeof(tstr), "%F %H:%M:%S", gmtime(&to));
+
+ x509_raw cert;
+ x509write_init_raw(&cert);
+ x509write_add_pubkey(&cert, &rsa);
+ x509write_add_subject(&cert, (unsigned char*)subject);
+ x509write_add_validity(&cert, (unsigned char*)fstr, (unsigned char*)tstr);
+ fprintf(stderr, "Generating selfsigned certificate with subject '%s'"
+ " and validity %s-%s\n", subject, fstr, tstr);
+ if (x509write_create_selfsign(&cert, &rsa)) {
+ fprintf(stderr, "error: certificate generation failed\n");
+ }
+
+ if (x509write_crtfile(&cert, (unsigned char*)certpath, flag)) {
+ fprintf(stderr, "error: I/O error\n");
+ return 1;
+ }
+
+ x509write_free_raw(&cert);
+ rsa_free(&rsa);
+ return 0;
+}
+
+int main(int argc, char *argv[]) {
+ if (!argv[1]) {
+ //Usage
+ } else if (!strcmp(argv[1], "rsakey")) {
+ return rsakey(argv+2);
+ } else if (!strcmp(argv[1], "selfsigned")) {
+ return selfsigned(argv+2);
+ }
+
+ fprintf(stderr,
+ "PX5G X.509 Certificate Generator Utility v" PX5G_VERSION "\n" PX5G_COPY
+ "\nbased on PolarSSL by Christophe Devine and Paul Bakker\n\n");
+ fprintf(stderr, "Usage: %s [rsakey|selfsigned]\n", *argv);
+ return 1;
+}
diff --git a/package/switch/.svn/entries b/package/switch/.svn/entries
new file mode 100644
index 0000000..4cdeb02
--- /dev/null
+++ b/package/switch/.svn/entries
@@ -0,0 +1,68 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/switch
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-02-14T12:36:52.902349Z
+35596
+hauke
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+files
+dir
+
+src
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+c5e3e1982e3aac345525e1bc0fa75686
+2013-01-23T10:12:40.487841Z
+35307
+jogo
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1328
+
diff --git a/package/switch/.svn/prop-base/Makefile.svn-base b/package/switch/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..8e522ae
--- /dev/null
+++ b/package/switch/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:copyright
+V 30
+Copyright (C) 2006 OpenWrt.org
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/switch/.svn/text-base/Makefile.svn-base b/package/switch/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..c577584
--- /dev/null
+++ b/package/switch/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,59 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=kmod-switch
+PKG_RELEASE:=6
+
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/switch
+ SUBMENU:=Other modules
+ DEPENDS:=@TARGET_brcm47xx
+ TITLE:=Switch drivers
+ FILES:= \
+ $(PKG_BUILD_DIR)/switch-core.ko \
+ $(PKG_BUILD_DIR)/switch-adm.ko \
+ $(PKG_BUILD_DIR)/switch-robo.ko
+ AUTOLOAD:=$(call AutoLoad,20,switch-core switch-robo switch-adm)
+endef
+
+define KernelPackage/switch/description
+ This package contains switch drivers for ADM6996L and BCM53XX RoboSwitch.
+endef
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+define Build/Compile
+ $(MAKE) -C "$(LINUX_DIR)" \
+ CROSS_COMPILE="$(TARGET_CROSS)" \
+ ARCH="$(LINUX_KARCH)" \
+ SUBDIRS="$(PKG_BUILD_DIR)" \
+ EXTRA_CFLAGS="$(BUILDFLAGS)" \
+ modules
+endef
+
+define Build/InstallDev
+ mkdir -p $(1)/usr/include
+ $(CP) ./src/switch-core.h $(1)/usr/include/
+endef
+
+define Build/UninstallDev
+ rm -f $(1)/usr/include/switch-core.h
+endef
+
+define KernelPackage/switch/install
+ $(INSTALL_DIR) $(1)/lib/network/
+ $(INSTALL_BIN) ./files/switch.sh $(1)/lib/network/
+endef
+
+$(eval $(call KernelPackage,switch))
diff --git a/package/switch/Makefile b/package/switch/Makefile
new file mode 100644
index 0000000..c577584
--- /dev/null
+++ b/package/switch/Makefile
@@ -0,0 +1,59 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=kmod-switch
+PKG_RELEASE:=6
+
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/switch
+ SUBMENU:=Other modules
+ DEPENDS:=@TARGET_brcm47xx
+ TITLE:=Switch drivers
+ FILES:= \
+ $(PKG_BUILD_DIR)/switch-core.ko \
+ $(PKG_BUILD_DIR)/switch-adm.ko \
+ $(PKG_BUILD_DIR)/switch-robo.ko
+ AUTOLOAD:=$(call AutoLoad,20,switch-core switch-robo switch-adm)
+endef
+
+define KernelPackage/switch/description
+ This package contains switch drivers for ADM6996L and BCM53XX RoboSwitch.
+endef
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+define Build/Compile
+ $(MAKE) -C "$(LINUX_DIR)" \
+ CROSS_COMPILE="$(TARGET_CROSS)" \
+ ARCH="$(LINUX_KARCH)" \
+ SUBDIRS="$(PKG_BUILD_DIR)" \
+ EXTRA_CFLAGS="$(BUILDFLAGS)" \
+ modules
+endef
+
+define Build/InstallDev
+ mkdir -p $(1)/usr/include
+ $(CP) ./src/switch-core.h $(1)/usr/include/
+endef
+
+define Build/UninstallDev
+ rm -f $(1)/usr/include/switch-core.h
+endef
+
+define KernelPackage/switch/install
+ $(INSTALL_DIR) $(1)/lib/network/
+ $(INSTALL_BIN) ./files/switch.sh $(1)/lib/network/
+endef
+
+$(eval $(call KernelPackage,switch))
diff --git a/package/switch/files/.svn/entries b/package/switch/files/.svn/entries
new file mode 100644
index 0000000..6628d56
--- /dev/null
+++ b/package/switch/files/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/switch/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-03-13T21:15:41.540468Z
+30937
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+switch.sh
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+77b0b67b3bf9504722313bf2bfb21eb7
+2012-03-13T21:15:41.540468Z
+30937
+jow
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1105
+
diff --git a/package/switch/files/.svn/prop-base/switch.sh.svn-base b/package/switch/files/.svn/prop-base/switch.sh.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/switch/files/.svn/prop-base/switch.sh.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/switch/files/.svn/text-base/switch.sh.svn-base b/package/switch/files/.svn/text-base/switch.sh.svn-base
new file mode 100644
index 0000000..2563d41
--- /dev/null
+++ b/package/switch/files/.svn/text-base/switch.sh.svn-base
@@ -0,0 +1,53 @@
+#!/bin/sh
+# Copyright (C) 2006-2010 OpenWrt.org
+
+setup_switch_hw() {
+ local dev="$1"
+ local enable reset evlan
+
+ config_get_bool enable "$dev" enable 1
+ config_get_bool evlan "$dev" enable_vlan 1
+ config_get_bool reset "$dev" reset 1
+
+ local proc="/proc/switch/$dev"
+ [ -d "$proc" ] && {
+ ifconfig "$dev" up
+ echo "$reset" > "$proc/reset"
+ echo "$evlan" > "$proc/enable_vlan"
+ [ -f "$proc/enable" ] && echo "$enable" > "$proc/enable"
+ }
+
+ local vlan
+ for vlan in `seq 0 15`; do
+ proc="/proc/switch/$dev/vlan/$vlan/ports"
+ [ -f "$proc" ] && echo "" > "$proc"
+ done
+}
+
+setup_switch_vlan() {
+ local s="$1"
+ local dev vlan ports
+
+ config_get dev "$s" device
+ config_get vlan "$s" vlan
+ config_get ports "$s" ports
+
+ [ -n "$dev" ] && [ -n "$vlan" ] && {
+ ports="${ports%\*}"
+
+ [ "$_vlan_pvid_set" = 1 ] || {
+ ports="$ports*"
+ _vlan_pvid_set=1
+ }
+
+ local proc="/proc/switch/$dev/vlan/$vlan/ports"
+ [ -f "$proc" ] && echo "$ports" > "$proc"
+ }
+}
+
+setup_switch() {
+ _vlan_pvid_set=0
+ config_load network
+ config_foreach setup_switch_hw switch
+ config_foreach setup_switch_vlan switch_vlan
+}
diff --git a/package/switch/files/switch.sh b/package/switch/files/switch.sh
new file mode 100644
index 0000000..2563d41
--- /dev/null
+++ b/package/switch/files/switch.sh
@@ -0,0 +1,53 @@
+#!/bin/sh
+# Copyright (C) 2006-2010 OpenWrt.org
+
+setup_switch_hw() {
+ local dev="$1"
+ local enable reset evlan
+
+ config_get_bool enable "$dev" enable 1
+ config_get_bool evlan "$dev" enable_vlan 1
+ config_get_bool reset "$dev" reset 1
+
+ local proc="/proc/switch/$dev"
+ [ -d "$proc" ] && {
+ ifconfig "$dev" up
+ echo "$reset" > "$proc/reset"
+ echo "$evlan" > "$proc/enable_vlan"
+ [ -f "$proc/enable" ] && echo "$enable" > "$proc/enable"
+ }
+
+ local vlan
+ for vlan in `seq 0 15`; do
+ proc="/proc/switch/$dev/vlan/$vlan/ports"
+ [ -f "$proc" ] && echo "" > "$proc"
+ done
+}
+
+setup_switch_vlan() {
+ local s="$1"
+ local dev vlan ports
+
+ config_get dev "$s" device
+ config_get vlan "$s" vlan
+ config_get ports "$s" ports
+
+ [ -n "$dev" ] && [ -n "$vlan" ] && {
+ ports="${ports%\*}"
+
+ [ "$_vlan_pvid_set" = 1 ] || {
+ ports="$ports*"
+ _vlan_pvid_set=1
+ }
+
+ local proc="/proc/switch/$dev/vlan/$vlan/ports"
+ [ -f "$proc" ] && echo "$ports" > "$proc"
+ }
+}
+
+setup_switch() {
+ _vlan_pvid_set=0
+ config_load network
+ config_foreach setup_switch_hw switch
+ config_foreach setup_switch_vlan switch_vlan
+}
diff --git a/package/switch/src/.svn/entries b/package/switch/src/.svn/entries
new file mode 100644
index 0000000..e382659
--- /dev/null
+++ b/package/switch/src/.svn/entries
@@ -0,0 +1,266 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/switch/src
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-02-14T12:36:52.902349Z
+35596
+hauke
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+switch-adm.c
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+bc2a0de5cb0ce3cb8f2680971558db52
+2013-02-14T12:36:52.902349Z
+35596
+hauke
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+13508
+
+switch-robo.c
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+dd5bc0934968d4cd38f22f7595f32f87
+2013-02-14T12:36:52.902349Z
+35596
+hauke
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+22794
+
+gpio.h
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+0260cffd83c76eb0d321490e222501ab
+2012-08-04T19:46:25.622889Z
+32992
+hauke
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+591
+
+switch-core.c
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+01ebcde595909465d09e93903e8b48d0
+2013-02-14T12:36:52.902349Z
+35596
+hauke
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+12936
+
+etc53xx.h
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+2b3e7c91b60d87e98a7aec97df83d2af
+2013-02-13T16:03:03.841133Z
+35580
+hauke
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+31503
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+09d9636b9bceb4b90344969b00303fc7
+2009-04-17T14:09:46.037367Z
+15242
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+483
+
+switch-core.h
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+e3f8c76fc4c55862fb88c1aa4d7b0bfc
+2013-02-14T12:36:52.902349Z
+35596
+hauke
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1254
+
diff --git a/package/switch/src/.svn/prop-base/Makefile.svn-base b/package/switch/src/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/switch/src/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/switch/src/.svn/prop-base/etc53xx.h.svn-base b/package/switch/src/.svn/prop-base/etc53xx.h.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/switch/src/.svn/prop-base/etc53xx.h.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/switch/src/.svn/prop-base/gpio.h.svn-base b/package/switch/src/.svn/prop-base/gpio.h.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/switch/src/.svn/prop-base/gpio.h.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/switch/src/.svn/prop-base/switch-adm.c.svn-base b/package/switch/src/.svn/prop-base/switch-adm.c.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/switch/src/.svn/prop-base/switch-adm.c.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/switch/src/.svn/prop-base/switch-core.c.svn-base b/package/switch/src/.svn/prop-base/switch-core.c.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/switch/src/.svn/prop-base/switch-core.c.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/switch/src/.svn/prop-base/switch-core.h.svn-base b/package/switch/src/.svn/prop-base/switch-core.h.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/switch/src/.svn/prop-base/switch-core.h.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/switch/src/.svn/prop-base/switch-robo.c.svn-base b/package/switch/src/.svn/prop-base/switch-robo.c.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/switch/src/.svn/prop-base/switch-robo.c.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/switch/src/.svn/text-base/Makefile.svn-base b/package/switch/src/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..b6934cc
--- /dev/null
+++ b/package/switch/src/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,18 @@
+#
+# Makefile for switch driver
+#
+# Copyright (C) 2005 Felix Fietkau <nbd@openwrt.org>
+#
+# 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 of the License, or (at your option) any later version.
+#
+
+obj-m := switch-core.o switch-adm.o switch-robo.o
+
+ifeq ($(MAKING_MODULES),1)
+export-objs := switch-core.o
+
+-include $(TOPDIR)/Rules.make
+endif
diff --git a/package/switch/src/.svn/text-base/etc53xx.h.svn-base b/package/switch/src/.svn/text-base/etc53xx.h.svn-base
new file mode 100644
index 0000000..0cd217e
--- /dev/null
+++ b/package/switch/src/.svn/text-base/etc53xx.h.svn-base
@@ -0,0 +1,624 @@
+/*
+ * Broadcom Home Gateway Reference Design
+ * BCM53xx Register definitions
+ *
+ * Copyright 2004, Broadcom Corporation
+ * All Rights Reserved.
+ *
+ * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
+ * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
+ * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
+ * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
+ */
+
+#ifndef __BCM535M_H_
+#define __BCM535M_H_
+
+/* ROBO embedded device type */
+#define ROBO_DEV_5380 1
+#define ROBO_DEV_5365 2
+#define ROBO_DEV_5350 3
+#define ROBO_DEV_53115 4
+
+/* BCM5325m GLOBAL PAGE REGISTER MAP */
+#ifndef _CFE_
+#pragma pack(1)
+#endif
+
+/* BCM5325m Serial Management Port (SMP) Page offsets */
+#define ROBO_CTRL_PAGE 0x00 /* Control registers */
+#define ROBO_STAT_PAGE 0x01 /* Status register */
+#define ROBO_MGMT_PAGE 0x02 /* Management Mode registers */
+#define ROBO_MIB_AC_PAGE 0x03 /* MIB Autocast registers */
+#define ROBO_ARLCTRL_PAGE 0x04 /* ARL Control Registers */
+#define ROBO_ARLIO_PAGE 0x05 /* ARL Access Registers */
+#define ROBO_FRAMEBUF_PAGE 0x06 /* Management frame access registers */
+#define ROBO_MEM_ACCESS_PAGE 0x08 /* Memory access registers */
+
+/* PHY Registers */
+#define ROBO_PORT0_MII_PAGE 0x10 /* Port 0 MII Registers */
+#define ROBO_PORT1_MII_PAGE 0x11 /* Port 1 MII Registers */
+#define ROBO_PORT2_MII_PAGE 0x12 /* Port 2 MII Registers */
+#define ROBO_PORT3_MII_PAGE 0x13 /* Port 3 MII Registers */
+#define ROBO_PORT4_MII_PAGE 0x14 /* Port 4 MII Registers */
+/* (start) registers only for BCM5380 */
+#define ROBO_PORT5_MII_PAGE 0x15 /* Port 5 MII Registers */
+#define ROBO_PORT6_MII_PAGE 0x16 /* Port 6 MII Registers */
+#define ROBO_PORT7_MII_PAGE 0x17 /* Port 7 MII Registers */
+/* (end) registers only for BCM5380 */
+#define ROBO_IM_PORT_PAGE 0x18 /* Inverse MII Port (to EMAC) */
+#define ROBO_ALL_PORT_PAGE 0x19 /* All ports MII Registers (broadcast)*/
+
+/* MAC Statistics registers */
+#define ROBO_PORT0_MIB_PAGE 0x20 /* Port 0 10/100 MIB Statistics */
+#define ROBO_PORT1_MIB_PAGE 0x21 /* Port 1 10/100 MIB Statistics */
+#define ROBO_PORT2_MIB_PAGE 0x22 /* Port 2 10/100 MIB Statistics */
+#define ROBO_PORT3_MIB_PAGE 0x23 /* Port 3 10/100 MIB Statistics */
+#define ROBO_PORT4_MIB_PAGE 0x24 /* Port 4 10/100 MIB Statistics */
+/* (start) registers only for BCM5380 */
+#define ROBO_PORT5_MIB_PAGE 0x25 /* Port 5 10/100 MIB Statistics */
+#define ROBO_PORT6_MIB_PAGE 0x26 /* Port 6 10/100 MIB Statistics */
+#define ROBO_PORT7_MIB_PAGE 0x27 /* Port 7 10/100 MIB Statistics */
+/* (end) registers only for BCM5380 */
+#define ROBO_IM_PORT_MIB_PAGE 0x28 /* Inverse MII Port MIB Statistics */
+
+/* Quality of Service (QoS) Registers */
+#define ROBO_QOS_PAGE 0x30 /* QoS Registers */
+
+/* VLAN Registers */
+#define ROBO_VLAN_PAGE 0x34 /* VLAN Registers */
+
+/* Note SPI Data/IO Registers not used */
+#define ROBO_SPI_DATA_IO_0_PAGE 0xf0 /* SPI Data I/O 0 */
+#define ROBO_SPI_DATA_IO_1_PAGE 0xf1 /* SPI Data I/O 1 */
+#define ROBO_SPI_DATA_IO_2_PAGE 0xf2 /* SPI Data I/O 2 */
+#define ROBO_SPI_DATA_IO_3_PAGE 0xf3 /* SPI Data I/O 3 */
+#define ROBO_SPI_DATA_IO_4_PAGE 0xf4 /* SPI Data I/O 4 */
+#define ROBO_SPI_DATA_IO_5_PAGE 0xf5 /* SPI Data I/O 5 */
+#define ROBO_SPI_DATA_IO_6_PAGE 0xf6 /* SPI Data I/O 6 */
+#define ROBO_SPI_DATA_IO_7_PAGE 0xf7 /* SPI Data I/O 7 */
+
+#define ROBO_SPI_STATUS_PAGE 0xfe /* SPI Status Registers */
+#define ROBO_PAGE_PAGE 0xff /* Page Registers */
+
+
+/* BCM5325m CONTROL PAGE (0x00) REGISTER MAP : 8bit (byte) registers */
+typedef struct _ROBO_PORT_CTRL_STRUC
+{
+ unsigned char rx_disable:1; /* rx disable */
+ unsigned char tx_disable:1; /* tx disable */
+ unsigned char rsvd:3; /* reserved */
+ unsigned char stp_state:3; /* spanning tree state */
+} ROBO_PORT_CTRL_STRUC;
+
+#define ROBO_PORT0_CTRL 0x00 /* 10/100 Port 0 Control */
+#define ROBO_PORT1_CTRL 0x01 /* 10/100 Port 1 Control */
+#define ROBO_PORT2_CTRL 0x02 /* 10/100 Port 2 Control */
+#define ROBO_PORT3_CTRL 0x03 /* 10/100 Port 3 Control */
+#define ROBO_PORT4_CTRL 0x04 /* 10/100 Port 4 Control */
+/* (start) registers only for BCM5380 */
+#define ROBO_PORT5_CTRL 0x05 /* 10/100 Port 5 Control */
+#define ROBO_PORT6_CTRL 0x06 /* 10/100 Port 6 Control */
+#define ROBO_PORT7_CTRL 0x07 /* 10/100 Port 7 Control */
+/* (end) registers only for BCM5380 */
+#define ROBO_IM_PORT_CTRL 0x08 /* 10/100 Port 8 Control */
+#define ROBO_SMP_CTRL 0x0a /* SMP Control register */
+#define ROBO_SWITCH_MODE 0x0b /* Switch Mode Control */
+#define ROBO_PORT_OVERRIDE_CTRL 0x0e /* Port state override */
+#define ROBO_PORT_OVERRIDE_RVMII (1<<4) /* Bit 4 enables RvMII */
+#define ROBO_PD_MODE_CTRL 0x0f /* Power-down mode control */
+#define ROBO_IP_MULTICAST_CTRL 0x21 /* IP Multicast control */
+
+/* BCM5325m STATUS PAGE (0x01) REGISTER MAP : 16bit/48bit registers */
+#define ROBO_HALF_DUPLEX 0
+#define ROBO_FULL_DUPLEX 1
+
+#define ROBO_LINK_STAT_SUMMARY 0x00 /* Link Status Summary: 16bit */
+#define ROBO_LINK_STAT_CHANGE 0x02 /* Link Status Change: 16bit */
+#define ROBO_SPEED_STAT_SUMMARY 0x04 /* Port Speed Summary: 16bit*/
+#define ROBO_DUPLEX_STAT_SUMMARY 0x06 /* Duplex Status Summary: 16bit */
+#define ROBO_PAUSE_STAT_SUMMARY 0x08 /* PAUSE Status Summary: 16bit */
+#define ROBO_SOURCE_ADDR_CHANGE 0x0C /* Source Address Change: 16bit */
+#define ROBO_LSA_PORT0 0x10 /* Last Source Addr, Port 0: 48bits*/
+#define ROBO_LSA_PORT1 0x16 /* Last Source Addr, Port 1: 48bits*/
+#define ROBO_LSA_PORT2 0x1c /* Last Source Addr, Port 2: 48bits*/
+#define ROBO_LSA_PORT3 0x22 /* Last Source Addr, Port 3: 48bits*/
+#define ROBO_LSA_PORT4 0x28 /* Last Source Addr, Port 4: 48bits*/
+#define ROBO_LSA_IM_PORT 0x40 /* Last Source Addr, IM Port: 48bits*/
+
+/* BCM5325m MANAGEMENT MODE REGISTERS (0x02) REGISTER MAP: 8/48 bit regs*/
+typedef struct _ROBO_GLOBAL_CONFIG_STRUC
+{
+ unsigned char resetMIB:1; /* reset MIB counters */
+ unsigned char rxBPDU:1; /* receive BDPU enable */
+ unsigned char rsvd1:2; /* reserved */
+ unsigned char MIBacHdrCtrl:1; /* MIB autocast header control */
+ unsigned char MIBac:1; /* MIB autocast enable */
+ unsigned char frameMgmtPort:2; /* frame management port */
+} ROBO_GLOBAL_CONFIG_STRUC;
+#define ROBO_GLOBAL_CONFIG 0x00 /* Global Management Config: 8bit*/
+#define ROBO_MGMT_PORT_ID 0x02 /* Management Port ID: 8bit*/
+#define ROBO_RMON_MIB_STEER 0x04 /* RMON Mib Steering: 16bit */
+#define ROBO_MIB_MODE_SELECT 0x04 /* MIB Mode select: 16bit (BCM5350) */
+#define ROBO_AGE_TIMER_CTRL 0x06 /* Age time control: 32bit */
+#define ROBO_MIRROR_CAP_CTRL 0x10 /* Mirror Capture : 16bit */
+#define ROBO_MIRROR_ING_CTRL 0x12 /* Mirror Ingress Control: 16bit */
+#define ROBO_MIRROR_ING_DIV_CTRL 0x14 /* Mirror Ingress Divider: 16bit */
+#define ROBO_MIRROR_ING_MAC_ADDR 0x16 /* Ingress Mirror MAC Addr: 48bit*/
+#define ROBO_MIRROR_EGR_CTRL 0x1c /* Mirror Egress Control: 16bit */
+#define ROBO_MIRROR_EGR_DIV_CTRL 0x1e /* Mirror Egress Divider: 16bit */
+#define ROBO_MIRROR_EGR_MAC_ADDR 0x20 /* Egress Mirror MAC Addr: 48bit*/
+
+/* BCM5325m MIB AUTOCAST REGISTERS (0x03) REGISTER MAP: 8/16/48 bit regs */
+#define ROBO_MIB_AC_PORT 0x00 /* MIB Autocast Port: 16bit */
+#define ROBO_MIB_AC_HDR_PTR 0x02 /* MIB Autocast Header pointer:16bit*/
+#define ROBO_MIB_AC_HDR_LEN 0x04 /* MIB Autocast Header Len: 16bit */
+#define ROBO_MIB_AC_DA 0x06 /* MIB Autocast DA: 48bit */
+#define ROBO_MIB_AC_SA 0x0c /* MIB Autocast SA: 48bit */
+#define ROBO_MIB_AC_TYPE 0x12 /* MIB Autocast Type: 16bit */
+#define ROBO_MIB_AC_RATE 0x14 /* MIB Autocast Rate: 8bit */
+#define ROBO_GET_AC_RATE(secs) ((secs)*10)
+#define ROBO_AC_RATE_MAX 0xff
+#define ROBO_AC_RATE_DEFAULT 0x64 /* 10 secs */
+typedef struct _ROBO_MIB_AC_STRUCT
+{
+ unsigned char opcode:4; /* Tx MIB Autocast opcode */
+ unsigned char portno:4; /* zero-based port no. */
+ unsigned char portstate:8; /* port state */
+ unsigned long long TxOctets;
+ unsigned int TxDropPkts;
+ unsigned int rsvd;
+ unsigned int TxBroadcastPkts;
+ unsigned int TxMulticastPkts;
+ unsigned int TxUnicastPkts;
+ unsigned int TxCollisions;
+ unsigned int TxSingleCollision;
+ unsigned int TxMultiCollision;
+ unsigned int TxDeferredTransmit;
+ unsigned int TxLateCollision;
+ unsigned int TxExcessiveCollision;
+ unsigned int TxFrameInDiscards;
+ unsigned int TxPausePkts;
+ unsigned int rsvd1[2];
+ unsigned long long RxOctets;
+ unsigned int RxUndersizePkts;
+ unsigned int RxPausePkts;
+ unsigned int RxPkts64Octets;
+ unsigned int RxPkts64to127Octets;
+ unsigned int RxPkts128to255Octets;
+ unsigned int RxPkts256to511Octets;
+ unsigned int RxPkts512to1023Octets;
+ unsigned int RxPkts1024to1522Octets;
+ unsigned int RxOversizePkts;
+ unsigned int RxJabbers;
+ unsigned int RxAlignmentErrors;
+ unsigned int RxFCSErrors;
+ unsigned long long RxGoodOctets;
+ unsigned int RxDropPkts;
+ unsigned int RxUnicastPkts;
+ unsigned int RxMulticastPkts;
+ unsigned int RxBroadcastPkts;
+ unsigned int RxSAChanges;
+ unsigned int RxFragments;
+ unsigned int RxExcessSizeDisc;
+ unsigned int RxSymbolError;
+} ROBO_MIB_AC_STRUCT;
+
+/* BCM5325m ARL CONTROL REGISTERS (0x04) REGISTER MAP: 8/16/48/64 bit regs */
+#define ROBO_ARL_CONFIG 0x00 /* ARL Global Configuration: 8bit*/
+#define ROBO_BPDU_MC_ADDR_REG 0x04 /* BPDU Multicast Address Reg:64bit*/
+#define ROBO_MULTIPORT_ADDR_1 0x10 /* Multiport Address 1: 48 bits*/
+#define ROBO_MULTIPORT_VECTOR_1 0x16 /* Multiport Vector 1: 16 bits */
+#define ROBO_MULTIPORT_ADDR_2 0x20 /* Multiport Address 2: 48 bits*/
+#define ROBO_MULTIPORT_VECTOR_2 0x26 /* Multiport Vector 2: 16 bits */
+#define ROBO_SECURE_SRC_PORT_MASK 0x30 /* Secure Source Port Mask: 16 bits*/
+#define ROBO_SECURE_DST_PORT_MASK 0x32 /* Secure Dest Port Mask: 16 bits */
+
+
+/* BCM5325m ARL IO REGISTERS (0x05) REGISTER MAP: 8/16/48/64 bit regs */
+#define ARL_TABLE_WRITE 0 /* for read/write state in control reg */
+#define ARL_TABLE_READ 1 /* for read/write state in control reg */
+#ifdef BCM5380
+#define ARL_VID_BYTES 2 /* number of bytes for VID */
+#else
+#define ARL_VID_BYTES 1 /* number of bytes for VID */
+#endif
+typedef struct _ROBO_ARL_RW_CTRL_STRUC
+{
+ unsigned char ARLrw:1; /* ARL read/write (1=read) */
+ unsigned char rsvd:6; /* reserved */
+ unsigned char ARLStart:1; /* ARL start/done (1=start) */
+} ROBO_ARL_RW_CTRL_STRUC;
+typedef struct _ROBO_ARL_SEARCH_CTRL_STRUC
+{
+ unsigned char valid:1; /* ARL search result valid */
+ unsigned char rsvd:6; /* reserved */
+ unsigned char ARLStart:1; /* ARL start/done (1=start) */
+} ROBO_ARL_SEARCH_CTRL_STRUC;
+typedef struct _ROBO_ARL_ENTRY_CTRL_STRUC
+{
+ unsigned char portID:4; /* port id */
+ unsigned char chipID:2; /* chip id */
+ unsigned char rsvd:5; /* reserved */
+ unsigned char prio:2; /* priority */
+ unsigned char age:1; /* age */
+ unsigned char staticEn:1; /* static */
+ unsigned char valid:1; /* valid */
+} ROBO_ARL_ENTRY_CTRL_STRUC;
+typedef struct _ROBO_ARL_SEARCH_RESULT_CTRL_STRUC
+{
+ unsigned char portID:4; /* port id */
+ unsigned char rsvd:1; /* reserved */
+ unsigned char vid:8; /* vlan id */
+ unsigned char age:1; /* age */
+ unsigned char staticEn:1; /* static */
+ unsigned char valid:1; /* valid */
+} ROBO_ARL_SEARCH_RESULT_CTRL_STRUC;
+typedef struct _ROBO_ARL_ENTRY_MAC_STRUC
+{
+ unsigned char macBytes[6]; /* MAC address */
+} ROBO_ARL_ENTRY_MAC_STRUC;
+
+typedef struct _ROBO_ARL_ENTRY_STRUC
+{
+ ROBO_ARL_ENTRY_MAC_STRUC mac; /* MAC address */
+ ROBO_ARL_ENTRY_CTRL_STRUC ctrl; /* control bits */
+} ROBO_ARL_ENTRY_STRUC;
+
+typedef struct _ROBO_ARL_SEARCH_RESULT_STRUC
+{
+ ROBO_ARL_ENTRY_MAC_STRUC mac; /* MAC address */
+ ROBO_ARL_SEARCH_RESULT_CTRL_STRUC ctrl; /* control bits */
+} ROBO_ARL_SEARCH_RESULT_STRUC;
+
+/* multicast versions of ARL entry structs */
+typedef struct _ROBO_ARL_ENTRY_MCAST_CTRL_STRUC
+{
+ unsigned int portMask:12;/* multicast port mask */
+ unsigned char prio:1; /* priority */
+ unsigned char gigPort:1; /* gigabit port 1 mask */
+ unsigned char staticEn:1; /* static */
+ unsigned char valid:1; /* valid */
+} ROBO_ARL_ENTRY_MCAST_CTRL_STRUC;
+typedef struct _ROBO_ARL_SEARCH_RESULT_MCAST_CTRL_STRUC
+{
+ unsigned int portMask:13; /* multicast port mask */
+ unsigned char age:1; /* age */
+ unsigned char staticEn:1; /* static */
+ unsigned char valid:1; /* valid */
+} ROBO_ARL_SEARCH_RESULT_MCAST_CTRL_STRUC;
+/* BCM5350 extension register */
+typedef struct _ROBO_ARL_SEARCH_RESULT_EXTENSION
+{
+ unsigned int prio:2; /* priority */
+ unsigned int portMask:1; /* MSB (MII) of port mask for multicast */
+ unsigned int reserved:5;
+} ROBO_ARL_SEARCH_RESULT_EXTENSION;
+
+typedef struct _ROBO_ARL_ENTRY_MCAST_STRUC
+{
+ ROBO_ARL_ENTRY_MAC_STRUC mac; /* MAC address */
+ ROBO_ARL_ENTRY_MCAST_CTRL_STRUC ctrl; /* control bits */
+} ROBO_ARL_ENTRY_MCAST_STRUC;
+typedef struct _ROBO_ARL_SEARCH_RESULT_MCAST_STRUC
+{
+ ROBO_ARL_ENTRY_MAC_STRUC mac; /* MAC address */
+ ROBO_ARL_SEARCH_RESULT_MCAST_CTRL_STRUC ctrl; /* control bits */
+} ROBO_ARL_SEARCH_RESULT_MCAST_STRUC;
+
+#define ROBO_ARL_RW_CTRL 0x00 /* ARL Read/Write Control : 8bit */
+#define ROBO_ARL_MAC_ADDR_IDX 0x02 /* MAC Address Index: 48bit */
+#define ROBO_ARL_VID_TABLE_IDX 0x08 /* VID Table Address Index: 8bit */
+#define ROBO_ARL_ENTRY0 0x10 /* ARL Entry 0 : 64 bit */
+#define ROBO_ARL_ENTRY1 0x18 /* ARL Entry 1 : 64 bit */
+#define ROBO_ARL_SEARCH_CTRL 0x20 /* ARL Search Control: 8bit */
+#define ROBO_ARL_SEARCH_ADDR 0x22 /* ARL Search Address: 16bit */
+#define ROBO_ARL_SEARCH_RESULT 0x24 /* ARL Search Result: 64bit */
+#define ROBO_ARL_SEARCH_RESULT_EXT 0x2c /* ARL Search Result Extension (5350): 8bit */
+#define ROBO_ARL_VID_ENTRY0 0x30 /* ARL VID Entry 0: 64bit */
+#define ROBO_ARL_VID_ENTRY1 0x32 /* ARL VID Entry 1: 64bit */
+#define ROBO_ARL_SEARCH_CTRL_53115 0x50 /* ARL Search Control: 8bit */
+#define ROBO_ARL_SEARCH_ADDR_53115 0x51 /* ARL Search Address: 16bit */
+#define ROBO_ARL_SEARCH_RESULT_53115 0x60 /* ARL Search Result: 64bit */
+#define ROBO_ARL_SEARCH_RESULT_EXT_53115 0x68 /* ARL Search Result Extension (53115): 16bit */
+
+/* BCM5395/5397/5398/53115 */
+#define ROBO_VTBL_ACCESS 0x60 /* VLAN table access: 8bit */
+#define ROBO_VTBL_INDX 0x61 /* VLAN table address index: 16bit */
+#define ROBO_VTBL_ENTRY 0x63 /* VLAN table entry: 32bit */
+#define ROBO_VTBL_ACCESS_5395 0x80 /* VLAN table access: 8bit */
+#define ROBO_VTBL_INDX_5395 0x81 /* VLAN table address index: 16bit */
+#define ROBO_VTBL_ENTRY_5395 0x83 /* VLAN table entry: 32bit */
+
+/* BCM5325m MANAGEMENT FRAME REGISTERS (0x6) REGISTER MAP: 8/16 bit regs */
+#define ROBO_MGMT_FRAME_RD_DATA 0x00 /* Management Frame Read Data :8bit*/
+#define ROBO_MGMT_FRAME_WR_DATA 0x01 /* Management Frame Write Data:8bit*/
+#define ROBO_MGMT_FRAME_WR_CTRL 0x02 /* Write Control: 16bit */
+#define ROBO_MGMT_FRAME_RD_STAT 0x04 /* Read Status: 16bit */
+
+/* BCM5325m MEMORY ACCESS REGISTERS (Page 0x08) REGISTER MAP: 32 bit regs */
+#define MEM_TABLE_READ 1 /* for read/write state in mem access reg */
+#define MEM_TABLE_WRITE 0 /* for read/write state in mem access reg */
+#define MEM_TABLE_ACCESS_START 1 /* for mem access read/write start */
+#define MEM_TABLE_ACCESS_DONE 0 /* for mem access read/write done */
+#define VLAN_TABLE_ADDR 0x3800 /* BCM5380 only */
+#ifdef BCM5380
+#define NUM_ARL_TABLE_ENTRIES 4096 /* number of entries in ARL table */
+#define NUM_VLAN_TABLE_ENTRIES 2048 /* number of entries in VLAN table */
+#define ARL_TABLE_ADDR 0 /* offset of ARL table start */
+#else
+#define NUM_ARL_TABLE_ENTRIES 2048 /* number of entries in ARL table */
+#define NUM_VLAN_TABLE_ENTRIES 256 /* number of entries in VLAN table */
+#define ARL_TABLE_ADDR 0x3800 /* offset of ARL table start */
+/* corresponding values for 5350 */
+#define NUM_ARL_TABLE_ENTRIES_5350 1024 /* number of entries in ARL table (5350) */
+#define NUM_VLAN_TABLE_ENTRIES_5350 16 /* number of entries in VLAN table */
+#define ARL_TABLE_ADDR_5350 0x1c00 /* offset of ARL table start (5350) */
+#endif
+#define NUM_ARL_TABLE_ENTRIES_53115 4096 /* number of entries in ARL table (53115) */
+#define NUM_VLAN_TABLE_ENTRIES_53115 4096 /* number of entries in VLAN table */
+typedef struct _ROBO_MEM_ACCESS_CTRL_STRUC
+{
+ unsigned int memAddr:14; /* 64-bit memory address */
+ unsigned char rsvd:4; /* reserved */
+ unsigned char readEn:1; /* read enable (0 == write) */
+ unsigned char startDone:1;/* memory access start/done */
+ unsigned int rsvd1:12; /* reserved */
+} ROBO_MEM_ACCESS_CTRL_STRUC;
+typedef struct _ROBO_MEM_ACCESS_DATA_STRUC
+{
+ unsigned int memData[2]; /* 64-bit data */
+ unsigned short rsvd; /* reserved */
+} ROBO_MEM_ACCESS_DATA_STRUC;
+
+#ifdef BCM5380
+typedef struct _ROBO_ARL_TABLE_DATA_STRUC
+{
+ unsigned char MACaddr[6]; /* MAC addr */
+ unsigned int portID:4; /* port ID */
+ unsigned int chipID:2; /* chip ID */
+ unsigned int rsvd:6; /* reserved */
+ unsigned int highPrio:1; /* high priority address */
+ unsigned int age:1; /* entry accessed/learned since ageing process */
+ unsigned int staticAddr:1;/* entry is static */
+ unsigned int valid:1; /* entry is valid */
+ unsigned int vid:12; /* vlan id */
+ unsigned int rsvd2:4; /* reserved */
+} ROBO_ARL_TABLE_DATA_STRUC;
+#else
+typedef struct _ROBO_ARL_TABLE_DATA_STRUC
+{
+ unsigned char MACaddr[6]; /* MAC addr */
+ unsigned int portID:4; /* port ID */
+ unsigned int chipID:2; /* chip ID */
+ unsigned int rsvd:7; /* reserved */
+ unsigned int age:1; /* entry accessed/learned since ageing process */
+ unsigned int staticAddr:1;/* entry is static */
+ unsigned int valid:1; /* entry is valid */
+} ROBO_ARL_TABLE_DATA_STRUC;
+#endif
+
+/* multicast format*/
+typedef struct _ROBO_ARL_TABLE_MCAST_DATA_STRUC
+{
+ unsigned char MACaddr[6]; /* MAC addr */
+ unsigned int portMask:12;/* multicast port mask */
+ unsigned char prio:1; /* priority */
+ unsigned char gigPort:1; /* gigabit port 1 mask */
+ unsigned char staticEn:1; /* static */
+ unsigned char valid:1; /* valid */
+ unsigned int vid:12; /* vlan id */
+ unsigned int rsvd2:4; /* reserved */
+} ROBO_ARL_TABLE_MCAST_DATA_STRUC;
+#define ROBO_MEM_ACCESS_CTRL 0x00 /* Memory Read/Write Control :32bit*/
+#define ROBO_MEM_ACCESS_DATA 0x04 /* Memory Read/Write Data:64bit*/
+
+/* BCM5325m SWITCH PORT (0x10-18) REGISTER MAP: 8/16 bit regs */
+typedef struct _ROBO_MII_CTRL_STRUC
+{
+ unsigned char rsvd:8; /* reserved */
+ unsigned char duplex:1; /* duplex mode */
+ unsigned char restartAN:1;/* restart auto-negotiation */
+ unsigned char rsvd1:1; /* reserved */
+ unsigned char powerDown:1;/* power down */
+ unsigned char ANenable:1; /* auto-negotiation enable */
+ unsigned char speed:1; /* forced speed selection */
+ unsigned char loopback:1; /* loopback */
+ unsigned char reset:1; /* reset */
+} ROBO_MII_CTRL_STRUC;
+typedef struct _ROBO_MII_AN_ADVERT_STRUC
+{
+ unsigned char selector:5; /* advertise selector field */
+ unsigned char T10BaseT:1; /* advertise 10BaseT */
+ unsigned char T10BaseTFull:1; /* advertise 10BaseT, full duplex */
+ unsigned char T100BaseX:1; /* advertise 100BaseX */
+ unsigned char T100BaseXFull:1;/* advertise 100BaseX full duplex */
+ unsigned char noT4:1; /* do not advertise T4 */
+ unsigned char pause:1; /* advertise pause for full duplex */
+ unsigned char rsvd:2; /* reserved */
+ unsigned char remoteFault:1; /* transmit remote fault */
+ unsigned char rsvd1:1; /* reserved */
+ unsigned char nextPage:1; /* nex page operation supported */
+} ROBO_MII_AN_ADVERT_STRUC;
+#define ROBO_MII_CTRL 0x00 /* Port MII Control */
+#define ROBO_MII_STAT 0x02 /* Port MII Status */
+/* Fields of link status register */
+#define ROBO_MII_STAT_JABBER (1<<1) /* Jabber detected */
+#define ROBO_MII_STAT_LINK (1<<2) /* Link status */
+
+#define ROBO_MII_PHYID_HI 0x04 /* Port PHY ID High */
+#define ROBO_MII_PHYID_LO 0x06 /* Port PHY ID Low */
+#define ROBO_MII_ANA_REG 0x08 /* MII Auto-Neg Advertisement */
+#define ROBO_MII_ANP_REG 0x0a /* MII Auto-Neg Partner Ability */
+#define ROBO_MII_AN_EXP_REG 0x0c /* MII Auto-Neg Expansion */
+#define ROBO_MII_AN_NP_REG 0x0e /* MII next page */
+#define ROBO_MII_ANP_NP_REG 0x10 /* MII Partner next page */
+#define ROBO_MII_100BX_AUX_CTRL 0x20 /* 100BASE-X Auxiliary Control */
+#define ROBO_MII_100BX_AUX_STAT 0x22 /* 100BASE-X Auxiliary Status */
+#define ROBO_MII_100BX_RCV_ERR_CTR 0x24 /* 100BASE-X Receive Error Ctr */
+#define ROBO_MII_100BX_RCV_FS_ERR 0x26 /* 100BASE-X Rcv False Sense Ctr */
+#define ROBO_MII_AUX_CTRL 0x30 /* Auxiliary Control/Status */
+/* Fields of Auxiliary control register */
+#define ROBO_MII_AUX_CTRL_FD (1<<0) /* Full duplex link detected*/
+#define ROBO_MII_AUX_CTRL_SP100 (1<<1) /* Speed 100 indication */
+#define ROBO_MII_AUX_STATUS 0x32 /* Aux Status Summary */
+#define ROBO_MII_CONN_STATUS 0x34 /* Aux Connection Status */
+#define ROBO_MII_AUX_MODE2 0x36 /* Aux Mode 2 */
+#define ROBO_MII_AUX_ERR_STATUS 0x38 /* Aux Error and General Status */
+#define ROBO_MII_AUX_MULTI_PHY 0x3c /* Aux Multiple PHY Register*/
+#define ROBO_MII_BROADCOM_TEST 0x3e /* Broadcom Test Register */
+
+
+/* BCM5325m PORT MIB REGISTERS (Pages 0x20-0x24,0x28) REGISTER MAP: 64/32 */
+/* Tranmit Statistics */
+#define ROBO_MIB_TX_OCTETS 0x00 /* 64b: TxOctets */
+#define ROBO_MIB_TX_DROP_PKTS 0x08 /* 32b: TxDropPkts */
+#define ROBO_MIB_TX_BC_PKTS 0x10 /* 32b: TxBroadcastPkts */
+#define ROBO_MIB_TX_MC_PKTS 0x14 /* 32b: TxMulticastPkts */
+#define ROBO_MIB_TX_UC_PKTS 0x18 /* 32b: TxUnicastPkts */
+#define ROBO_MIB_TX_COLLISIONS 0x1c /* 32b: TxCollisions */
+#define ROBO_MIB_TX_SINGLE_COLLISIONS 0x20 /* 32b: TxSingleCollision */
+#define ROBO_MIB_TX_MULTI_COLLISIONS 0x24 /* 32b: TxMultiCollision */
+#define ROBO_MIB_TX_DEFER_TX 0x28 /* 32b: TxDeferred Transmit */
+#define ROBO_MIB_TX_LATE_COLLISIONS 0x2c /* 32b: TxLateCollision */
+#define ROBO_MIB_EXCESS_COLLISIONS 0x30 /* 32b: TxExcessiveCollision*/
+#define ROBO_MIB_FRAME_IN_DISCARDS 0x34 /* 32b: TxFrameInDiscards */
+#define ROBO_MIB_TX_PAUSE_PKTS 0x38 /* 32b: TxPausePkts */
+
+/* Receive Statistics */
+#define ROBO_MIB_RX_OCTETS 0x44 /* 64b: RxOctets */
+#define ROBO_MIB_RX_UNDER_SIZE_PKTS 0x4c /* 32b: RxUndersizePkts(runts)*/
+#define ROBO_MIB_RX_PAUSE_PKTS 0x50 /* 32b: RxPausePkts */
+#define ROBO_MIB_RX_PKTS_64 0x54 /* 32b: RxPkts64Octets */
+#define ROBO_MIB_RX_PKTS_65_TO_127 0x58 /* 32b: RxPkts64to127Octets*/
+#define ROBO_MIB_RX_PKTS_128_TO_255 0x5c /* 32b: RxPkts128to255Octets*/
+#define ROBO_MIB_RX_PKTS_256_TO_511 0x60 /* 32b: RxPkts256to511Octets*/
+#define ROBO_MIB_RX_PKTS_512_TO_1023 0x64 /* 32b: RxPkts512to1023Octets*/
+#define ROBO_MIB_RX_PKTS_1024_TO_1522 0x68 /* 32b: RxPkts1024to1522Octets*/
+#define ROBO_MIB_RX_OVER_SIZE_PKTS 0x6c /* 32b: RxOversizePkts*/
+#define ROBO_MIB_RX_JABBERS 0x70 /* 32b: RxJabbers*/
+#define ROBO_MIB_RX_ALIGNMENT_ERRORS 0x74 /* 32b: RxAlignmentErrors*/
+#define ROBO_MIB_RX_FCS_ERRORS 0x78 /* 32b: RxFCSErrors */
+#define ROBO_MIB_RX_GOOD_OCTETS 0x7c /* 32b: RxGoodOctets */
+#define ROBO_MIB_RX_DROP_PKTS 0x84 /* 32b: RxDropPkts */
+#define ROBO_MIB_RX_UC_PKTS 0x88 /* 32b: RxUnicastPkts */
+#define ROBO_MIB_RX_MC_PKTS 0x8c /* 32b: RxMulticastPkts */
+#define ROBO_MIB_RX_BC_PKTS 0x90 /* 32b: RxBroadcastPkts */
+#define ROBO_MIB_RX_SA_CHANGES 0x94 /* 32b: RxSAChanges */
+#define ROBO_MIB_RX_FRAGMENTS 0x98 /* 32b: RxFragments */
+#define ROBO_MIB_RX_EXCESS_SZ_DISC 0x9c /* 32b: RxExcessSizeDisc*/
+#define ROBO_MIB_RX_SYMBOL_ERROR 0xa0 /* 32b: RxSymbolError */
+
+/* BCM5350 MIB Statistics */
+/* Group 0 */
+#define ROBO_MIB_TX_GOOD_PKTS 0x00 /* 16b: TxGoodPkts */
+#define ROBO_MIB_TX_UNICAST_PKTS 0x02 /* 16b: TxUnicastPkts */
+#define ROBO_MIB_RX_GOOD_PKTS 0x04 /* 16b: RxGoodPkts */
+#define ROBO_MIB_RX_GOOD_UNICAST_PKTS 0x06 /* 16b: RxGoodUnicastPkts */
+/* Group 1 */
+#define ROBO_MIB_TX_COLLISION 0x00 /* 16b: TxCollision */
+#define ROBO_MIB_TX_OCTETS_5350 0x02 /* 16b: TxOctets */
+#define ROBO_MIB_RX_FCS_ERRORS_5350 0x04 /* 16b: RxFCSErrors */
+#define ROBO_MIB_RX_GOOD_OCTETS_5350 0x06 /* 16b: RxGoodOctets */
+
+/* BCM5325m QoS REGISTERS (Page 0x30) REGISTER MAP: 8/16 */
+#define ROBO_QOS_CTRL 0x00 /* 16b: QoS Control Register */
+#define ROBO_QOS_LOCAL_WEIGHT_CTRL 0x10 /* 8b: Local HQ/LQ Weight Register*/
+#define ROBO_QOS_CPU_WEIGHT_CTRL 0x12 /* 8b: CPU HQ/LQ Weight Register*/
+#define ROBO_QOS_PAUSE_ENA 0x13 /* 16b: Qos Pause Enable Register*/
+#define ROBO_QOS_PRIO_THRESHOLD 0x15 /* 8b: Priority Threshold Register*/
+#define ROBO_QOS_RESERVED 0x16 /* 8b: Qos Reserved Register */
+
+/* BCM5325m VLAN REGISTERS (Page 0x34) REGISTER MAP: 8/16bit */
+typedef struct _ROBO_VLAN_CTRL0_STRUC
+{
+ unsigned char frameControlP:2; /* 802.1P frame control */
+ unsigned char frameControlQ:2; /* 802.1Q frame control */
+ unsigned char dropMissedVID:1; /* enable drop missed VID packet */
+ unsigned char vidMacHash:1; /* VID_MAC hash enable */
+ unsigned char vidMacCheck:1; /* VID_MAC check enable */
+ unsigned char VLANen:1; /* 802.1Q VLAN enable */
+} ROBO_VLAN_CTRL0_STRUC;
+#define VLAN_TABLE_WRITE 1 /* for read/write state in table access reg */
+#define VLAN_TABLE_READ 0 /* for read/write state in table access reg */
+#define VLAN_ID_HIGH_BITS 0 /* static high bits in table access reg */
+#define VLAN_ID_MAX 15 /* max VLAN id (5350) */
+#define VLAN_ID_MAX_5365 255 /* max VLAN id */
+#define VLAN_ID_MAX_5395 4094 /* max VLAN id (5395) */
+#define VLAN_ID_MASK VLAN_ID_MAX /* VLAN id mask */
+#ifdef BCM5380
+#define VLAN_UNTAG_SHIFT 13 /* for postioning untag bits in write reg */
+#define VLAN_VALID 0x4000000 /* valid bit in write reg */
+#else
+#define VLAN_UNTAG_SHIFT 7 /* for postioning untag bits in write reg */
+#define VLAN_VALID 0x4000 /* valid bit in write reg */
+/* corresponding values for 5350 */
+#define VLAN_UNTAG_SHIFT_5350 6 /* for postioning untag bits in write reg */
+#define VLAN_VALID_5350 0x00100000 /* valid bit in write reg */
+#endif
+typedef struct _ROBO_VLAN_TABLE_ACCESS_STRUC
+{
+ unsigned char VLANid:8; /* VLAN ID (low 8 bits) */
+ unsigned char VLANidHi:4; /* VLAN ID (fixed upper portion) */
+ unsigned char readWriteState:1; /* read/write state (write = 1) */
+ volatile unsigned char readWriteEnable:1; /* table read/write enable */
+ unsigned char rsvd:2; /* reserved */
+} ROBO_VLAN_TABLE_ACCESS_STRUC;
+#ifdef BCM5380
+typedef struct _ROBO_VLAN_READ_WRITE_STRUC
+{
+ unsigned int VLANgroup:13;/* VLAN group mask */
+ unsigned int VLANuntag:13;/* VLAN untag enable mask */
+ unsigned char valid:1; /* valid */
+ unsigned char rsvd:5; /* reserved */
+} ROBO_VLAN_READ_WRITE_STRUC;
+#else
+typedef struct _ROBO_VLAN_READ_WRITE_STRUC
+{
+ unsigned char VLANgroup:7; /* VLAN group mask */
+ unsigned char VLANuntag:7; /* VLAN untag enable mask */
+ unsigned char valid:1; /* valid */
+ unsigned char rsvd:1; /* reserved */
+} ROBO_VLAN_READ_WRITE_STRUC;
+typedef struct _ROBO_VLAN_READ_WRITE_STRUC_5350
+{
+ unsigned char VLANgroup:6; /* VLAN group mask */
+ unsigned char VLANuntag:6; /* VLAN untag enable mask */
+ unsigned char highVID:8; /* upper bits of vid */
+ unsigned char valid:1; /* valid */
+ unsigned int rsvd:11; /* reserved */
+} ROBO_VLAN_READ_WRITE_STRUC_5350;
+#endif
+#define ROBO_VLAN_CTRL0 0x00 /* 8b: VLAN Control 0 Register */
+#define ROBO_VLAN_CTRL1 0x01 /* 8b: VLAN Control 1 Register */
+#define ROBO_VLAN_CTRL2 0x02 /* 8b: VLAN Control 2 Register */
+#define ROBO_VLAN_CTRL3 0x03 /* 8b: VLAN Control 3 Register */
+#define ROBO_VLAN_CTRL4 0x04 /* 8b: VLAN Control 4 Register */
+#define ROBO_VLAN_CTRL5 0x05 /* 8b: VLAN Control 5 Register */
+#define ROBO_VLAN_TABLE_ACCESS_5365 0x08 /* 14b: VLAN Table Access Register */
+#define ROBO_VLAN_TABLE_ACCESS 0x06 /* 14b: VLAN Table Access Register (5350) */
+#define ROBO_VLAN_WRITE_5365 0x0a /* 15b: VLAN Write Register */
+#define ROBO_VLAN_WRITE 0x08 /* 15b: VLAN Write Register (5350) */
+#define ROBO_VLAN_READ 0x0c /* 15b: VLAN Read Register */
+#define ROBO_VLAN_PORT0_DEF_TAG 0x10 /* 16b: VLAN Port 0 Default Tag Register */
+#define ROBO_VLAN_PORT1_DEF_TAG 0x12 /* 16b: VLAN Port 1 Default Tag Register */
+#define ROBO_VLAN_PORT2_DEF_TAG 0x14 /* 16b: VLAN Port 2 Default Tag Register */
+#define ROBO_VLAN_PORT3_DEF_TAG 0x16 /* 16b: VLAN Port 3 Default Tag Register */
+#define ROBO_VLAN_PORT4_DEF_TAG 0x18 /* 16b: VLAN Port 4 Default Tag Register */
+#define ROBO_VLAN_PORTMII_DEF_TAG 0x1a /* 16b: VLAN Port MII Default Tag Register */
+/* 5380 only */
+#define ROBO_VLAN_PORT5_DEF_TAG 0x1a /* 16b: VLAN Port 5 Default Tag Register */
+#define ROBO_VLAN_PORT6_DEF_TAG 0x1c /* 16b: VLAN Port 6 Default Tag Register */
+#define ROBO_VLAN_PORT7_DEF_TAG 0x1e /* 16b: VLAN Port 7 Default Tag Register */
+#define ROBO_VLAN_PORT8_DEF_TAG 0x20 /* 16b: VLAN Port 8 Default Tag Register */
+/* 53115 only */
+#define ROBO_DUPLEX_STAT_SUMMARY_53115 0x08 /* Duplex Status Summary: 16bit */
+#define ROBO_JUMBO_PAGE 0x40
+#define ROBO_JUMBO_CTRL 0x01 /* 32bit */
+#define ROBO_JUMBO_SIZE 0x05 /* 16bit */
+
+#ifndef _CFE_
+#pragma pack()
+#endif
+
+#endif /* !__BCM535M_H_ */
diff --git a/package/switch/src/.svn/text-base/gpio.h.svn-base b/package/switch/src/.svn/text-base/gpio.h.svn-base
new file mode 100644
index 0000000..cb734f7
--- /dev/null
+++ b/package/switch/src/.svn/text-base/gpio.h.svn-base
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2006 OpenWrt.org
+ *
+ * This is free software, licensed under the GNU General Public License v2.
+ * See /LICENSE for more information.
+ */
+
+#ifndef __GPIO_H
+#define __GPIO_H
+
+#ifdef CONFIG_BCM47XX
+#include <linux/gpio.h>
+#else
+#warning "Unsupported configuration."
+
+#define bcm47xx_gpio_in(mask) (-1U)
+#define bcm47xx_gpio_out(mask, value) (-1U)
+#define bcm47xx_gpio_outen(mask, value) (-1U)
+#define bcm47xx_gpio_control(mask, value) (-1U)
+#define bcm47xx_gpio_intmask(mask, value) (-1U)
+#define bcm47xx_gpio_polarity(mask, value) (-1U)
+
+#endif
+
+#endif /* __GPIO_H */
diff --git a/package/switch/src/.svn/text-base/switch-adm.c.svn-base b/package/switch/src/.svn/text-base/switch-adm.c.svn-base
new file mode 100644
index 0000000..8c0ddc6
--- /dev/null
+++ b/package/switch/src/.svn/text-base/switch-adm.c.svn-base
@@ -0,0 +1,596 @@
+/*
+ * ADMTEK Adm6996 switch configuration module
+ *
+ * Copyright (C) 2005 Felix Fietkau <nbd@nbd.name>
+ *
+ * Partially based on Broadcom Home Networking Division 10/100 Mbit/s
+ * Ethernet Device Driver (from Montavista 2.4.20_mvl31 Kernel).
+ * Copyright (C) 2004 Broadcom Corporation
+ *
+ * adm_rreg function from adm6996
+ * Copyright (C) 2004 Nikki Chumakov <nikki@gattaca.ru>
+ *
+ * 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
+ * of the License, 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; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/if.h>
+#include <linux/if_arp.h>
+#include <linux/sockios.h>
+#include <linux/delay.h>
+#include <asm/uaccess.h>
+
+#include "switch-core.h"
+#include "gpio.h"
+
+#ifdef CONFIG_BCM47XX
+#include <bcm47xx_nvram.h>
+#endif
+
+#define DRIVER_NAME "adm6996"
+#define DRIVER_VERSION "0.01"
+
+static int eecs = 0;
+static int eesk = 0;
+static int eedi = 0;
+static int eerc = 0;
+static int force = 0;
+
+MODULE_AUTHOR("Felix Fietkau <openwrt@nbd.name>");
+MODULE_LICENSE("GPL");
+module_param(eecs, int, 0);
+module_param(eesk, int, 0);
+module_param(eedi, int, 0);
+module_param(eerc, int, 0);
+module_param(force, int, 0);
+
+/* Minimum timing constants */
+#define EECK_EDGE_TIME 3 /* 3us - max(adm 2.5us, 93c 1us) */
+#define EEDI_SETUP_TIME 1 /* 1us - max(adm 10ns, 93c 400ns) */
+#define EECS_SETUP_TIME 1 /* 1us - max(adm no, 93c 200ns) */
+
+/* Handy macros for writing fixed length values */
+#define adm_write8(cs, b) { __u8 val = (__u8) (b); adm_write(cs, &val, sizeof(val)*8); }
+#define adm_write16(cs, w) { __u16 val = hton16(w); adm_write(cs, (__u8 *)&val, sizeof(val)*8); }
+#define adm_write32(cs, i) { uint32 val = hton32(i); adm_write(cs, (__u8 *)&val, sizeof(val)*8); }
+
+#define atoi(str) simple_strtoul(((str != NULL) ? str : ""), NULL, 0)
+
+#ifdef CONFIG_BCM47XX
+
+/* Return gpio pin number assigned to the named pin */
+/*
+* Variable should be in format:
+*
+* gpio<N>=pin_name
+*
+* 'def_pin' is returned if there is no such variable found.
+*/
+static unsigned int get_gpiopin(char *pin_name, unsigned int def_pin)
+{
+ char name[] = "gpioXXXX";
+ char val[10];
+ unsigned int pin;
+
+ /* Go thru all possibilities till a match in pin name */
+ for (pin = 0; pin < 16; pin ++) {
+ sprintf(name, "gpio%d", pin);
+ if (bcm47xx_nvram_getenv(name, val, sizeof(val)) >= 0) {
+ if (!strcmp(val, pin_name))
+ return pin;
+ }
+ }
+ return def_pin;
+}
+#endif
+
+
+static void adm_write(int cs, char *buf, unsigned int bits)
+{
+ int i, len = (bits + 7) / 8;
+ __u8 mask;
+
+ bcm47xx_gpio_out(eecs, (cs ? eecs : 0));
+ udelay(EECK_EDGE_TIME);
+
+ /* Byte assemble from MSB to LSB */
+ for (i = 0; i < len; i++) {
+ /* Bit bang from MSB to LSB */
+ for (mask = 0x80; mask && bits > 0; mask >>= 1, bits --) {
+ /* Clock low */
+ bcm47xx_gpio_out(eesk, 0);
+ udelay(EECK_EDGE_TIME);
+
+ /* Output on rising edge */
+ bcm47xx_gpio_out(eedi, ((mask & buf[i]) ? eedi : 0));
+ udelay(EEDI_SETUP_TIME);
+
+ /* Clock high */
+ bcm47xx_gpio_out(eesk, eesk);
+ udelay(EECK_EDGE_TIME);
+ }
+ }
+
+ /* Clock low */
+ bcm47xx_gpio_out(eesk, 0);
+ udelay(EECK_EDGE_TIME);
+
+ if (cs)
+ bcm47xx_gpio_out(eecs, 0);
+}
+
+
+static void adm_read(int cs, char *buf, unsigned int bits)
+{
+ int i, len = (bits + 7) / 8;
+ __u8 mask;
+
+ bcm47xx_gpio_out(eecs, (cs ? eecs : 0));
+ udelay(EECK_EDGE_TIME);
+
+ /* Byte assemble from MSB to LSB */
+ for (i = 0; i < len; i++) {
+ __u8 byte;
+
+ /* Bit bang from MSB to LSB */
+ for (mask = 0x80, byte = 0; mask && bits > 0; mask >>= 1, bits --) {
+ __u8 gp;
+
+ /* Clock low */
+ bcm47xx_gpio_out(eesk, 0);
+ udelay(EECK_EDGE_TIME);
+
+ /* Input on rising edge */
+ gp = bcm47xx_gpio_in(~0);
+ if (gp & eedi)
+ byte |= mask;
+
+ /* Clock high */
+ bcm47xx_gpio_out(eesk, eesk);
+ udelay(EECK_EDGE_TIME);
+ }
+
+ *buf++ = byte;
+ }
+
+ /* Clock low */
+ bcm47xx_gpio_out(eesk, 0);
+ udelay(EECK_EDGE_TIME);
+
+ if (cs)
+ bcm47xx_gpio_out(eecs, 0);
+}
+
+
+/* Enable outputs with specified value to the chip */
+static void adm_enout(__u8 pins, __u8 val)
+{
+ /* Prepare GPIO output value */
+ bcm47xx_gpio_out(pins, val);
+
+ /* Enable GPIO outputs */
+ bcm47xx_gpio_outen(pins, pins);
+ udelay(EECK_EDGE_TIME);
+}
+
+
+/* Disable outputs to the chip */
+static void adm_disout(__u8 pins)
+{
+ /* Disable GPIO outputs */
+ bcm47xx_gpio_outen(pins, 0);
+ udelay(EECK_EDGE_TIME);
+}
+
+
+/* Advance clock(s) */
+static void adm_adclk(int clocks)
+{
+ int i;
+ for (i = 0; i < clocks; i++) {
+ /* Clock high */
+ bcm47xx_gpio_out(eesk, eesk);
+ udelay(EECK_EDGE_TIME);
+
+ /* Clock low */
+ bcm47xx_gpio_out(eesk, 0);
+ udelay(EECK_EDGE_TIME);
+ }
+}
+
+static __u32 adm_rreg(__u8 table, __u8 addr)
+{
+ /* cmd: 01 10 T DD R RRRRRR */
+ __u8 bits[6] = {
+ 0xFF, 0xFF, 0xFF, 0xFF,
+ (0x06 << 4) | ((table & 0x01) << 3 | (addr&64)>>6),
+ ((addr&63)<<2)
+ };
+
+ __u8 rbits[4];
+
+ /* Enable GPIO outputs with all pins to 0 */
+ adm_enout((__u8)(eecs | eesk | eedi), 0);
+
+ adm_write(0, bits, 46);
+ adm_disout((__u8)(eedi));
+ adm_adclk(2);
+ adm_read (0, rbits, 32);
+
+ /* Extra clock(s) required per datasheet */
+ adm_adclk(2);
+
+ /* Disable GPIO outputs */
+ adm_disout((__u8)(eecs | eesk));
+
+ if (!table) /* EEPROM has 16-bit registers, but pumps out two registers in one request */
+ return (addr & 0x01 ? (rbits[0]<<8) | rbits[1] : (rbits[2]<<8) | (rbits[3]));
+ else
+ return (rbits[0]<<24) | (rbits[1]<<16) | (rbits[2]<<8) | rbits[3];
+}
+
+
+
+/* Write chip configuration register */
+/* Follow 93c66 timing and chip's min EEPROM timing requirement */
+void
+adm_wreg(__u8 addr, __u16 val)
+{
+ /* cmd(27bits): sb(1) + opc(01) + addr(bbbbbbbb) + data(bbbbbbbbbbbbbbbb) */
+ __u8 bits[4] = {
+ (0x05 << 5) | (addr >> 3),
+ (addr << 5) | (__u8)(val >> 11),
+ (__u8)(val >> 3),
+ (__u8)(val << 5)
+ };
+
+ /* Enable GPIO outputs with all pins to 0 */
+ adm_enout((__u8)(eecs | eesk | eedi), 0);
+
+ /* Write cmd. Total 27 bits */
+ adm_write(1, bits, 27);
+
+ /* Extra clock(s) required per datasheet */
+ adm_adclk(2);
+
+ /* Disable GPIO outputs */
+ adm_disout((__u8)(eecs | eesk | eedi));
+}
+
+
+/* Port configuration registers */
+static int port_conf[] = { 0x01, 0x03, 0x05, 0x07, 0x08, 0x09 };
+
+/* Bits in VLAN port mapping */
+static int vlan_ports[] = { 1 << 0, 1 << 2, 1 << 4, 1 << 6, 1 << 7, 1 << 8 };
+
+static int handle_vlan_port_read(void *driver, char *buf, int nr)
+{
+ int ports, i, c, len = 0;
+
+ if ((nr < 0) || (nr > 15))
+ return 0;
+
+ /* Get VLAN port map */
+ ports = adm_rreg(0, 0x13 + nr);
+
+ for (i = 0; i <= 5; i++) {
+ if (ports & vlan_ports[i]) {
+ c = adm_rreg(0, port_conf[i]);
+
+ len += sprintf(buf + len, "%d", i);
+ if (c & (1 << 4)) {
+ buf[len++] = 't';
+ if (((c & (0xf << 10)) >> 10) == nr)
+ buf[len++] = '*';
+ } else if (i == 5)
+ buf[len++] = 'u';
+
+ buf[len++] = '\t';
+ }
+ }
+ len += sprintf(buf + len, "\n");
+
+ return len;
+}
+
+static int handle_vlan_port_write(void *driver, char *buf, int nr)
+{
+ int i, cfg, ports;
+ switch_driver *d = (switch_driver *) driver;
+ switch_vlan_config *c = switch_parse_vlan(d, buf);
+
+ if (c == NULL)
+ return -1;
+
+ ports = adm_rreg(0, 0x13 + nr);
+ for (i = 0; i < d->ports; i++) {
+ if (c->port & (1 << i)) {
+ ports |= vlan_ports[i];
+
+ cfg = adm_rreg(0, port_conf[i]);
+
+ /* Tagging */
+ if (c->untag & (1 << i))
+ cfg &= ~(1 << 4);
+ else
+ cfg |= (1 << 4);
+
+ if ((c->untag | c->pvid) & (1 << i)) {
+ cfg = (cfg & ~(0xf << 10)) | (nr << 10);
+ }
+
+ adm_wreg(port_conf[i], (__u16) cfg);
+ } else {
+ ports &= ~(vlan_ports[i]);
+ }
+ }
+ adm_wreg(0x13 + nr, (__u16) ports);
+
+ kfree(c);
+ return 0;
+}
+
+static int handle_port_enable_read(void *driver, char *buf, int nr)
+{
+ return sprintf(buf, "%d\n", ((adm_rreg(0, port_conf[nr]) & (1 << 5)) ? 0 : 1));
+}
+
+static int handle_port_enable_write(void *driver, char *buf, int nr)
+{
+ int reg = adm_rreg(0, port_conf[nr]);
+
+ if (buf[0] == '0')
+ reg |= (1 << 5);
+ else if (buf[0] == '1')
+ reg &= ~(1 << 5);
+ else return -1;
+
+ adm_wreg(port_conf[nr], (__u16) reg);
+ return 0;
+}
+
+static int handle_port_media_read(void *driver, char *buf, int nr)
+{
+ int len;
+ int media = 0;
+ int reg = adm_rreg(0, port_conf[nr]);
+
+ if (reg & (1 << 1))
+ media |= SWITCH_MEDIA_AUTO;
+ if (reg & (1 << 2))
+ media |= SWITCH_MEDIA_100;
+ if (reg & (1 << 3))
+ media |= SWITCH_MEDIA_FD;
+
+ len = switch_print_media(buf, media);
+ return len + sprintf(buf + len, "\n");
+}
+
+static int handle_port_media_write(void *driver, char *buf, int nr)
+{
+ int media = switch_parse_media(buf);
+ int reg = adm_rreg(0, port_conf[nr]);
+
+ if (media < 0 || media & SWITCH_MEDIA_1000)
+ return -1;
+
+ reg &= ~((1 << 1) | (1 << 2) | (1 << 3));
+ if (media & SWITCH_MEDIA_AUTO)
+ reg |= 1 << 1;
+ if (media & SWITCH_MEDIA_100)
+ reg |= 1 << 2;
+ if (media & SWITCH_MEDIA_FD)
+ reg |= 1 << 3;
+
+ adm_wreg(port_conf[nr], reg);
+
+ return 0;
+}
+
+static int handle_vlan_enable_read(void *driver, char *buf, int nr)
+{
+ return sprintf(buf, "%d\n", ((adm_rreg(0, 0x11) & (1 << 5)) ? 1 : 0));
+}
+
+static int handle_vlan_enable_write(void *driver, char *buf, int nr)
+{
+ int reg = adm_rreg(0, 0x11);
+
+ if (buf[0] == '1')
+ reg |= (1 << 5);
+ else if (buf[0] == '0')
+ reg &= ~(1 << 5);
+ else return -1;
+
+ adm_wreg(0x11, (__u16) reg);
+ return 0;
+}
+
+static int handle_reset(void *driver, char *buf, int nr)
+{
+ int i;
+ u32 cfg;
+
+ /*
+ * Reset sequence: RC high->low(100ms)->high(30ms)
+ *
+ * WAR: Certain boards don't have the correct power on
+ * reset logic therefore we must explicitly perform the
+ * sequence in software.
+ */
+ if (eerc) {
+ /* Keep RC high for at least 20ms */
+ adm_enout(eerc, eerc);
+ for (i = 0; i < 20; i ++)
+ udelay(1000);
+ /* Keep RC low for at least 100ms */
+ adm_enout(eerc, 0);
+ for (i = 0; i < 100; i++)
+ udelay(1000);
+ /* Set default configuration */
+ adm_enout((__u8)(eesk | eedi), eesk);
+ /* Keep RC high for at least 30ms */
+ adm_enout(eerc, eerc);
+ for (i = 0; i < 30; i++)
+ udelay(1000);
+ /* Leave RC high and disable GPIO outputs */
+ adm_disout((__u8)(eecs | eesk | eedi));
+
+ }
+
+ /* set up initial configuration for cpu port */
+ cfg = (0x8000 | /* Auto MDIX */
+ (0xf << 10) | /* PVID */
+ (1 << 4) | /* Tagging */
+ 0xf); /* full duplex, 100Mbps, auto neg, flow ctrl */
+ adm_wreg(port_conf[5], cfg);
+
+ /* vlan mode select register (0x11): vlan on, mac clone */
+ adm_wreg(0x11, 0xff30);
+
+ return 0;
+}
+
+static int handle_registers(void *driver, char *buf, int nr)
+{
+ int i, len = 0;
+
+ for (i = 0; i <= 0x33; i++) {
+ len += sprintf(buf + len, "0x%02x: 0x%04x\n", i, adm_rreg(0, i));
+ }
+
+ return len;
+}
+
+static int handle_counters(void *driver, char *buf, int nr)
+{
+ int i, len = 0;
+
+ for (i = 0; i <= 0x3c; i++) {
+ len += sprintf(buf + len, "0x%02x: 0x%08x\n", i, adm_rreg(1, i));
+ }
+
+ return len;
+}
+
+static int detect_adm(void)
+{
+ int ret = 0;
+
+#ifdef CONFIG_BCM47XX
+ char buf[20];
+ int boardflags = 0;
+ int boardnum = 0;
+
+ if (bcm47xx_nvram_getenv("boardflags", buf, sizeof(buf)) >= 0)
+ boardflags = simple_strtoul(buf, NULL, 0);
+
+ if (bcm47xx_nvram_getenv("boardnum", buf, sizeof(buf)) >= 0)
+ boardnum = simple_strtoul(buf, NULL, 0);
+
+ if ((boardnum == 44) && (boardflags == 0x0388)) { /* Trendware TEW-411BRP+ */
+ ret = 1;
+
+ eecs = get_gpiopin("adm_eecs", 2);
+ eesk = get_gpiopin("adm_eesk", 3);
+ eedi = get_gpiopin("adm_eedi", 4);
+ eerc = get_gpiopin("adm_rc", 5);
+
+ } else if ((boardflags & 0x80) || force) {
+ ret = 1;
+
+ eecs = get_gpiopin("adm_eecs", 2);
+ eesk = get_gpiopin("adm_eesk", 3);
+ eedi = get_gpiopin("adm_eedi", 4);
+ eerc = get_gpiopin("adm_rc", 0);
+
+ } else if (bcm47xx_nvram_getenv("boardtype", buf, sizeof(buf)) >= 0) {
+ if (strcmp(buf, "bcm94710dev") == 0) {
+ if (bcm47xx_nvram_getenv("boardnum", buf, sizeof(buf)) >= 0) {
+ if (strncmp(buf, "42", 2) == 0) {
+ /* WRT54G v1.1 hack */
+ eecs = 2;
+ eesk = 3;
+ eedi = 5;
+
+ ret = 1;
+ }
+ }
+ }
+ }
+
+ if (eecs)
+ eecs = (1 << eecs);
+ if (eesk)
+ eesk = (1 << eesk);
+ if (eedi)
+ eedi = (1 << eedi);
+ if (eerc)
+ eerc = (1 << eerc);
+#else
+ ret = 1;
+#endif
+
+ return ret;
+}
+
+static int __init adm_init(void)
+{
+ switch_config cfg[] = {
+ {"registers", handle_registers, NULL},
+ {"counters", handle_counters, NULL},
+ {"reset", NULL, handle_reset},
+ {"enable_vlan", handle_vlan_enable_read, handle_vlan_enable_write},
+ {NULL, NULL, NULL}
+ };
+ switch_config port[] = {
+ {"enable", handle_port_enable_read, handle_port_enable_write},
+ {"media", handle_port_media_read, handle_port_media_write},
+ {NULL, NULL, NULL}
+ };
+ switch_config vlan[] = {
+ {"ports", handle_vlan_port_read, handle_vlan_port_write},
+ {NULL, NULL, NULL}
+ };
+ switch_driver driver = {
+ name: DRIVER_NAME,
+ version: DRIVER_VERSION,
+ interface: "eth0",
+ ports: 6,
+ cpuport: 5,
+ vlans: 16,
+ driver_handlers: cfg,
+ port_handlers: port,
+ vlan_handlers: vlan,
+ };
+ snprintf(driver.dev_name, SWITCH_NAME_BUFSZ, DRIVER_NAME);
+
+ if (!detect_adm())
+ return -ENODEV;
+
+ return switch_register_driver(&driver);
+}
+
+static void __exit adm_exit(void)
+{
+ switch_unregister_driver(DRIVER_NAME);
+}
+
+
+module_init(adm_init);
+module_exit(adm_exit);
diff --git a/package/switch/src/.svn/text-base/switch-core.c.svn-base b/package/switch/src/.svn/text-base/switch-core.c.svn-base
new file mode 100644
index 0000000..fc8a6bf
--- /dev/null
+++ b/package/switch/src/.svn/text-base/switch-core.c.svn-base
@@ -0,0 +1,527 @@
+/*
+ * switch-core.c
+ *
+ * Copyright (C) 2005 Felix Fietkau <openwrt@nbd.name>
+ *
+ * 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
+ * of the License, 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ *
+ * Basic doc of driver's /proc interface:
+ * /proc/switch/<interface>/
+ * registers: read-only
+ * counters: read-only
+ * reset: write causes hardware reset
+ * enable_vlan: "0", "1"
+ * port/<port-number>/
+ * enabled: "0", "1"
+ * media: "AUTO", "1000FD", "1000HD", "100FD", "100HD", "10FD", "10HD"
+ * vlan/<port-number>/
+ * ports: same syntax as for nvram's vlan*ports (eg. "1 2 3 4 5*")
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <asm/uaccess.h>
+#include <linux/proc_fs.h>
+#include <linux/list.h>
+
+#include "switch-core.h"
+
+static int drv_num = 0;
+static struct proc_dir_entry *switch_root;
+switch_driver drivers;
+
+typedef struct {
+ struct list_head list;
+ struct proc_dir_entry *parent;
+ int nr;
+ void *driver;
+ switch_config handler;
+} switch_proc_handler;
+
+typedef struct {
+ struct proc_dir_entry *driver_dir, *port_dir, *vlan_dir;
+ struct proc_dir_entry **ports, **vlans;
+ switch_proc_handler data;
+ int nr;
+} switch_priv;
+
+static ssize_t switch_proc_read(struct file *file, char *buf, size_t count, loff_t *ppos);
+static ssize_t switch_proc_write(struct file *file, const char *buf, size_t count, void *data);
+
+static struct file_operations switch_proc_fops = {
+ .read = (ssize_t (*) (struct file *, char __user *, size_t, loff_t *))switch_proc_read,
+ .write = (ssize_t (*) (struct file *, const char __user *, size_t, loff_t *))switch_proc_write
+};
+
+static ssize_t switch_proc_read(struct file *file, char *buf, size_t count, loff_t *ppos)
+{
+ struct proc_dir_entry *dent = PDE(file->f_dentry->d_inode);
+ char *page;
+ int len = 0;
+
+ if ((page = kmalloc(SWITCH_MAX_BUFSZ, GFP_KERNEL)) == NULL)
+ return -ENOBUFS;
+
+ if (dent->data != NULL) {
+ switch_proc_handler *handler = (switch_proc_handler *) dent->data;
+ if (handler->handler.read != NULL)
+ len += handler->handler.read(handler->driver, page + len, handler->nr);
+ }
+ len += 1;
+
+ if (*ppos < len) {
+ len = min_t(int, len - *ppos, count);
+ if (copy_to_user(buf, (page + *ppos), len)) {
+ kfree(page);
+ return -EFAULT;
+ }
+ *ppos += len;
+ } else {
+ len = 0;
+ }
+
+ kfree(page);
+ return len;
+}
+
+
+static ssize_t switch_proc_write(struct file *file, const char *buf, size_t count, void *data)
+{
+ struct proc_dir_entry *dent = PDE(file->f_dentry->d_inode);
+ char *page;
+ int ret = -EINVAL;
+
+ if ((page = kmalloc(count + 1, GFP_KERNEL)) == NULL)
+ return -ENOBUFS;
+
+ if (copy_from_user(page, buf, count)) {
+ kfree(page);
+ return -EINVAL;
+ }
+ page[count] = 0;
+
+ if (dent->data != NULL) {
+ switch_proc_handler *handler = (switch_proc_handler *) dent->data;
+ if (handler->handler.write != NULL) {
+ if ((ret = handler->handler.write(handler->driver, page, handler->nr)) >= 0)
+ ret = count;
+ }
+ }
+
+ kfree(page);
+ return ret;
+}
+
+static int handle_driver_name(void *driver, char *buf, int nr)
+{
+ const char *name = ((switch_driver *) driver)->name;
+ return sprintf(buf, "%s\n", name);
+}
+
+static int handle_driver_version(void *driver, char *buf, int nr)
+{
+ const char *version = ((switch_driver *) driver)->version;
+ strcpy(buf, version);
+ return sprintf(buf, "%s\n", version);
+}
+
+static int handle_driver_cpuport(void *driver, char *buf, int nr)
+{
+ int cpuport = ((switch_driver *) driver)->cpuport;
+ return sprintf(buf, "%i\n", cpuport);
+}
+
+static int handle_driver_ports(void *driver, char *buf, int nr)
+{
+ int ports = ((switch_driver *) driver)->ports;
+ return sprintf(buf, "%i\n", ports);
+}
+
+static int handle_driver_vlans(void *driver, char *buf, int nr)
+{
+ int vlans = ((switch_driver *) driver)->vlans;
+ return sprintf(buf, "%i\n", vlans);
+}
+
+static int handle_driver_dev_name(void *driver, char *buf, int nr)
+{
+ char *dev_name = ((switch_driver *) driver)->dev_name;
+ return sprintf(buf, "%s\n", dev_name);
+}
+
+static void add_handler(switch_driver *driver, const switch_config *handler, struct proc_dir_entry *parent, int nr)
+{
+ switch_priv *priv = (switch_priv *) driver->data;
+ struct proc_dir_entry *p;
+ int mode;
+
+ switch_proc_handler *tmp;
+ tmp = (switch_proc_handler *) kmalloc(sizeof(switch_proc_handler), GFP_KERNEL);
+ if (!tmp)
+ return;
+ INIT_LIST_HEAD(&tmp->list);
+ tmp->parent = parent;
+ tmp->nr = nr;
+ tmp->driver = driver;
+ memcpy(&tmp->handler, handler, sizeof(switch_config));
+ list_add(&tmp->list, &priv->data.list);
+
+ mode = 0;
+ if (handler->read != NULL) mode |= S_IRUSR;
+ if (handler->write != NULL) mode |= S_IWUSR;
+
+ if ((p = create_proc_entry(handler->name, mode, parent)) != NULL) {
+ p->data = (void *) tmp;
+ p->proc_fops = &switch_proc_fops;
+ }
+}
+
+static inline void add_handlers(switch_driver *driver, const switch_config *handlers, struct proc_dir_entry *parent, int nr)
+{
+ int i;
+
+ for (i = 0; handlers[i].name != NULL; i++) {
+ add_handler(driver, &(handlers[i]), parent, nr);
+ }
+}
+
+static void remove_handlers(switch_priv *priv)
+{
+ struct list_head *pos, *q;
+ switch_proc_handler *tmp;
+
+ list_for_each_safe(pos, q, &priv->data.list) {
+ tmp = list_entry(pos, switch_proc_handler, list);
+ list_del(pos);
+ remove_proc_entry(tmp->handler.name, tmp->parent);
+ kfree(tmp);
+ }
+}
+
+
+static void do_unregister(switch_driver *driver)
+{
+ char buf[4];
+ int i;
+ switch_priv *priv = (switch_priv *) driver->data;
+
+ remove_handlers(priv);
+
+ for(i = 0; priv->ports[i] != NULL; i++) {
+ sprintf(buf, "%d", i);
+ remove_proc_entry(buf, priv->port_dir);
+ }
+ kfree(priv->ports);
+ remove_proc_entry("port", priv->driver_dir);
+
+ for(i = 0; priv->vlans[i] != NULL; i++) {
+ sprintf(buf, "%d", i);
+ remove_proc_entry(buf, priv->vlan_dir);
+ }
+ kfree(priv->vlans);
+ remove_proc_entry("vlan", priv->driver_dir);
+
+ remove_proc_entry(driver->interface, switch_root);
+
+ if (priv->nr == (drv_num - 1))
+ drv_num--;
+
+ kfree(priv);
+}
+
+switch_config global_driver_handlers[] = {
+ {"driver", handle_driver_name, NULL},
+ {"version", handle_driver_version, NULL},
+ {"cpuport", handle_driver_cpuport, NULL},
+ {"ports", handle_driver_ports, NULL},
+ {"vlans", handle_driver_vlans, NULL},
+ {"dev_name", handle_driver_dev_name, NULL},
+ {NULL, NULL, NULL}
+};
+
+static int do_register(switch_driver *driver)
+{
+ switch_priv *priv;
+ int i;
+ char buf[4];
+
+ priv = kmalloc(sizeof(switch_priv), GFP_KERNEL);
+ if (!priv)
+ return -ENOMEM;
+ driver->data = (void *) priv;
+
+ priv->ports = kmalloc((driver->ports + 1) * sizeof(struct proc_dir_entry *),
+ GFP_KERNEL);
+ if (!priv->ports) {
+ kfree(priv);
+ return -ENOMEM;
+ }
+ priv->vlans = kmalloc((driver->vlans + 1) * sizeof(struct proc_dir_entry *),
+ GFP_KERNEL);
+ if (!priv->vlans) {
+ kfree(priv->ports);
+ kfree(priv);
+ return -ENOMEM;
+ }
+
+ INIT_LIST_HEAD(&priv->data.list);
+
+ priv->nr = drv_num++;
+ priv->driver_dir = proc_mkdir(driver->interface, switch_root);
+ if (driver->driver_handlers != NULL) {
+ add_handlers(driver, driver->driver_handlers, priv->driver_dir, 0);
+ add_handlers(driver, global_driver_handlers, priv->driver_dir, 0);
+ }
+
+ priv->port_dir = proc_mkdir("port", priv->driver_dir);
+ for (i = 0; i < driver->ports; i++) {
+ sprintf(buf, "%d", i);
+ priv->ports[i] = proc_mkdir(buf, priv->port_dir);
+ if (driver->port_handlers != NULL)
+ add_handlers(driver, driver->port_handlers, priv->ports[i], i);
+ }
+ priv->ports[i] = NULL;
+
+ priv->vlan_dir = proc_mkdir("vlan", priv->driver_dir);
+ for (i = 0; i < driver->vlans; i++) {
+ sprintf(buf, "%d", i);
+ priv->vlans[i] = proc_mkdir(buf, priv->vlan_dir);
+ if (driver->vlan_handlers != NULL)
+ add_handlers(driver, driver->vlan_handlers, priv->vlans[i], i);
+ }
+ priv->vlans[i] = NULL;
+
+
+ return 0;
+}
+
+static inline int isspace(char c) {
+ switch(c) {
+ case ' ':
+ case 0x09:
+ case 0x0a:
+ case 0x0d:
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+#define toupper(c) (islower(c) ? ((c) ^ 0x20) : (c))
+#define islower(c) (((unsigned char)((c) - 'a')) < 26)
+
+int switch_parse_media(char *buf)
+{
+ char *str = buf;
+ while (*buf != 0) {
+ *buf = toupper(*buf);
+ buf++;
+ }
+
+ if (strncmp(str, "AUTO", 4) == 0)
+ return SWITCH_MEDIA_AUTO;
+ else if (strncmp(str, "1000FD", 6) == 0)
+ return SWITCH_MEDIA_1000 | SWITCH_MEDIA_FD;
+ else if (strncmp(str, "1000HD", 6) == 0)
+ return SWITCH_MEDIA_1000;
+ else if (strncmp(str, "100FD", 5) == 0)
+ return SWITCH_MEDIA_100 | SWITCH_MEDIA_FD;
+ else if (strncmp(str, "100HD", 5) == 0)
+ return SWITCH_MEDIA_100;
+ else if (strncmp(str, "10FD", 4) == 0)
+ return SWITCH_MEDIA_FD;
+ else if (strncmp(str, "10HD", 4) == 0)
+ return 0;
+ else return -1;
+}
+
+int switch_print_media(char *buf, int media)
+{
+ int len = 0;
+
+ if (media & SWITCH_MEDIA_AUTO)
+ len = sprintf(buf, "Auto");
+ else if (media == (SWITCH_MEDIA_1000 | SWITCH_MEDIA_FD))
+ len = sprintf(buf, "1000FD");
+ else if (media == SWITCH_MEDIA_1000)
+ len = sprintf(buf, "1000HD");
+ else if (media == (SWITCH_MEDIA_100 | SWITCH_MEDIA_FD))
+ len = sprintf(buf, "100FD");
+ else if (media == SWITCH_MEDIA_100)
+ len = sprintf(buf, "100HD");
+ else if (media == SWITCH_MEDIA_FD)
+ len = sprintf(buf, "10FD");
+ else if (media == 0)
+ len = sprintf(buf, "10HD");
+ else
+ len = sprintf(buf, "Invalid");
+
+ return len;
+}
+
+switch_vlan_config *switch_parse_vlan(switch_driver *driver, char *buf)
+{
+ switch_vlan_config *c;
+ int j, u, p, s;
+
+ c = kzalloc(sizeof(switch_vlan_config), GFP_KERNEL);
+ if (!c)
+ return NULL;
+
+ while (isspace(*buf)) buf++;
+ j = 0;
+ while (*buf >= '0' && *buf <= '9') {
+ j *= 10;
+ j += *buf++ - '0';
+
+ u = ((j == driver->cpuport) ? 0 : 1);
+ p = 0;
+ s = !(*buf >= '0' && *buf <= '9');
+
+ if (s) {
+ while (s && !isspace(*buf) && (*buf != 0)) {
+ switch(*buf) {
+ case 'u':
+ u = 1;
+ break;
+ case 't':
+ u = 0;
+ break;
+ case '*':
+ p = 1;
+ break;
+ }
+ buf++;
+ }
+ c->port |= (1 << j);
+ if (u)
+ c->untag |= (1 << j);
+ if (p)
+ c->pvid |= (1 << j);
+
+ j = 0;
+ }
+
+ while (isspace(*buf)) buf++;
+ }
+ if (*buf != 0) {
+ kfree(c);
+ return NULL;
+ }
+
+ c->port &= (1 << driver->ports) - 1;
+ c->untag &= (1 << driver->ports) - 1;
+ c->pvid &= (1 << driver->ports) - 1;
+
+ return c;
+}
+
+
+int switch_device_registered (char* device) {
+ struct list_head *pos;
+
+ list_for_each(pos, &drivers.list) {
+ if (strcmp(list_entry(pos, switch_driver, list)->interface, device) == 0) {
+ printk("There is already a switch registered on the device '%s'\n", device);
+ return -EINVAL;
+ }
+ }
+
+ return 0;
+}
+
+
+int switch_register_driver(switch_driver *driver)
+{
+ struct list_head *pos;
+ switch_driver *new;
+ int ret;
+
+ list_for_each(pos, &drivers.list) {
+ if (strcmp(list_entry(pos, switch_driver, list)->name, driver->name) == 0) {
+ printk("Switch driver '%s' already exists in the kernel\n", driver->name);
+ return -EINVAL;
+ }
+ if (strcmp(list_entry(pos, switch_driver, list)->interface, driver->interface) == 0) {
+ printk("There is already a switch registered on the device '%s'\n", driver->interface);
+ return -EINVAL;
+ }
+ }
+
+ new = kmalloc(sizeof(switch_driver), GFP_KERNEL);
+ if (!new)
+ return -ENOMEM;
+ memcpy(new, driver, sizeof(switch_driver));
+ new->name = strdup(driver->name);
+ new->interface = strdup(driver->interface);
+
+ if ((ret = do_register(new)) < 0) {
+ kfree(new->name);
+ kfree(new);
+ return ret;
+ }
+ INIT_LIST_HEAD(&new->list);
+ list_add(&new->list, &drivers.list);
+
+ return 0;
+}
+
+void switch_unregister_driver(char *name) {
+ struct list_head *pos, *q;
+ switch_driver *tmp;
+
+ list_for_each_safe(pos, q, &drivers.list) {
+ tmp = list_entry(pos, switch_driver, list);
+ if (strcmp(tmp->name, name) == 0) {
+ do_unregister(tmp);
+ list_del(pos);
+ kfree(tmp->name);
+ kfree(tmp);
+
+ return;
+ }
+ }
+}
+
+static int __init switch_init(void)
+{
+ if ((switch_root = proc_mkdir("switch", NULL)) == NULL) {
+ printk("%s: proc_mkdir failed.\n", __FILE__);
+ return -ENODEV;
+ }
+
+ INIT_LIST_HEAD(&drivers.list);
+
+ return 0;
+}
+
+static void __exit switch_exit(void)
+{
+ remove_proc_entry("switch", NULL);
+}
+
+MODULE_AUTHOR("Felix Fietkau <openwrt@nbd.name>");
+MODULE_LICENSE("GPL");
+
+EXPORT_SYMBOL(switch_device_registered);
+EXPORT_SYMBOL(switch_register_driver);
+EXPORT_SYMBOL(switch_unregister_driver);
+EXPORT_SYMBOL(switch_parse_vlan);
+EXPORT_SYMBOL(switch_parse_media);
+EXPORT_SYMBOL(switch_print_media);
+
+module_init(switch_init);
+module_exit(switch_exit);
diff --git a/package/switch/src/.svn/text-base/switch-core.h.svn-base b/package/switch/src/.svn/text-base/switch-core.h.svn-base
new file mode 100644
index 0000000..cc520e4
--- /dev/null
+++ b/package/switch/src/.svn/text-base/switch-core.h.svn-base
@@ -0,0 +1,55 @@
+#ifndef __SWITCH_CORE_H
+#define __SWITCH_CORE_H
+
+#include <linux/version.h>
+#include <linux/list.h>
+#define SWITCH_MAX_BUFSZ 4096
+#define SWITCH_NAME_BUFSZ 16
+
+#define SWITCH_MEDIA_AUTO 1
+#define SWITCH_MEDIA_100 2
+#define SWITCH_MEDIA_FD 4
+#define SWITCH_MEDIA_1000 8
+
+typedef int (*switch_handler)(void *driver, char *buf, int nr);
+
+typedef struct {
+ const char *name;
+ switch_handler read, write;
+} switch_config;
+
+typedef struct {
+ struct list_head list;
+ const char *name;
+ const char *version;
+ const char *interface;
+ int cpuport;
+ int ports;
+ int vlans;
+ const switch_config *driver_handlers, *port_handlers, *vlan_handlers;
+ void *data;
+ void *priv;
+ char dev_name[SWITCH_NAME_BUFSZ];
+} switch_driver;
+
+typedef struct {
+ u32 port, untag, pvid;
+} switch_vlan_config;
+
+
+extern int switch_device_registered (char* device);
+extern int switch_register_driver(switch_driver *driver);
+extern void switch_unregister_driver(char *name);
+extern switch_vlan_config *switch_parse_vlan(switch_driver *driver, char *buf);
+extern int switch_parse_media(char *buf);
+extern int switch_print_media(char *buf, int media);
+
+static inline char *strdup(const char *str)
+{
+ char *new = kmalloc(strlen(str) + 1, GFP_KERNEL);
+ strcpy(new, str);
+ return new;
+}
+
+
+#endif
diff --git a/package/switch/src/.svn/text-base/switch-robo.c.svn-base b/package/switch/src/.svn/text-base/switch-robo.c.svn-base
new file mode 100644
index 0000000..f715972
--- /dev/null
+++ b/package/switch/src/.svn/text-base/switch-robo.c.svn-base
@@ -0,0 +1,892 @@
+/*
+ * Broadcom BCM5325E/536x switch configuration module
+ *
+ * Copyright (C) 2005 Felix Fietkau <nbd@nbd.name>
+ * Copyright (C) 2008 Michael Buesch <mb@bu3sch.de>
+ * Copyright (C) 2013 Hauke Mehrtens <hauke@hauke-m.de>
+ * Based on 'robocfg' by Oleg I. Vdovikin
+ *
+ * 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
+ * of the License, 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; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/if.h>
+#include <linux/if_arp.h>
+#include <linux/sockios.h>
+#include <linux/ethtool.h>
+#include <linux/mii.h>
+#include <linux/delay.h>
+#include <linux/gpio.h>
+#include <asm/uaccess.h>
+
+#include "switch-core.h"
+#include "etc53xx.h"
+
+#ifdef CONFIG_BCM47XX
+#include <bcm47xx_nvram.h>
+#endif
+
+#define DRIVER_NAME "bcm53xx"
+#define DRIVER_VERSION "0.03"
+#define PFX "roboswitch: "
+
+#define ROBO_PHY_ADDR 0x1E /* robo switch phy address */
+#define ROBO_PHY_ADDR_TG3 0x01 /* Tigon3 PHY address */
+#define ROBO_PHY_ADDR_BCM63XX 0x00 /* BCM63XX PHY address */
+
+/* MII registers */
+#define REG_MII_PAGE 0x10 /* MII Page register */
+#define REG_MII_ADDR 0x11 /* MII Address register */
+#define REG_MII_DATA0 0x18 /* MII Data register 0 */
+
+#define REG_MII_PAGE_ENABLE 1
+#define REG_MII_ADDR_WRITE 1
+#define REG_MII_ADDR_READ 2
+
+/* Robo device ID register (in ROBO_MGMT_PAGE) */
+#define ROBO_DEVICE_ID 0x30
+#define ROBO_DEVICE_ID_5325 0x25 /* Faked */
+#define ROBO_DEVICE_ID_5395 0x95
+#define ROBO_DEVICE_ID_5397 0x97
+#define ROBO_DEVICE_ID_5398 0x98
+#define ROBO_DEVICE_ID_53115 0x3115
+#define ROBO_DEVICE_ID_53125 0x3125
+
+/* Private et.o ioctls */
+#define SIOCGETCPHYRD (SIOCDEVPRIVATE + 9)
+#define SIOCSETCPHYWR (SIOCDEVPRIVATE + 10)
+
+/* Data structure for a Roboswitch device. */
+struct robo_switch {
+ char *device; /* The device name string (ethX) */
+ u16 devid; /* ROBO_DEVICE_ID_53xx */
+ bool is_5365;
+ bool gmii; /* gigabit mii */
+ u8 corerev;
+ int gpio_robo_reset;
+ int gpio_lanports_enable;
+ struct ifreq ifr;
+ struct net_device *dev;
+ unsigned char port[9];
+};
+
+/* Currently we can only have one device in the system. */
+static struct robo_switch robo;
+
+
+static int do_ioctl(int cmd)
+{
+ mm_segment_t old_fs = get_fs();
+ int ret;
+
+ set_fs(KERNEL_DS);
+ ret = robo.dev->netdev_ops->ndo_do_ioctl(robo.dev, &robo.ifr, cmd);
+ set_fs(old_fs);
+
+ return ret;
+}
+
+static u16 mdio_read(__u16 phy_id, __u8 reg)
+{
+ struct mii_ioctl_data *mii = if_mii(&robo.ifr);
+ int err;
+
+ mii->phy_id = phy_id;
+ mii->reg_num = reg;
+
+ err = do_ioctl(SIOCGMIIREG);
+ if (err < 0) {
+ printk(KERN_ERR PFX "failed to read mdio reg %i with err %i.\n", reg, err);
+
+ return 0xffff;
+ }
+
+ return mii->val_out;
+}
+
+static void mdio_write(__u16 phy_id, __u8 reg, __u16 val)
+{
+ struct mii_ioctl_data *mii = if_mii(&robo.ifr);
+ int err;
+
+ mii->phy_id = phy_id;
+ mii->reg_num = reg;
+ mii->val_in = val;
+
+ err = do_ioctl(SIOCSMIIREG);
+ if (err < 0) {
+ printk(KERN_ERR PFX "failed to write mdio reg: %i with err %i.\n", reg, err);
+ return;
+ }
+}
+
+static int robo_reg(__u8 page, __u8 reg, __u8 op)
+{
+ int i = 3;
+
+ /* set page number */
+ mdio_write(ROBO_PHY_ADDR, REG_MII_PAGE,
+ (page << 8) | REG_MII_PAGE_ENABLE);
+
+ /* set register address */
+ mdio_write(ROBO_PHY_ADDR, REG_MII_ADDR,
+ (reg << 8) | op);
+
+ /* check if operation completed */
+ while (i--) {
+ if ((mdio_read(ROBO_PHY_ADDR, REG_MII_ADDR) & 3) == 0)
+ return 0;
+ }
+
+ printk(KERN_ERR PFX "timeout in robo_reg on page %i and reg %i with op %i.\n", page, reg, op);
+
+ return 1;
+}
+
+/*
+static void robo_read(__u8 page, __u8 reg, __u16 *val, int count)
+{
+ int i;
+
+ robo_reg(page, reg, REG_MII_ADDR_READ);
+
+ for (i = 0; i < count; i++)
+ val[i] = mdio_read(ROBO_PHY_ADDR, REG_MII_DATA0 + i);
+}
+*/
+
+static __u16 robo_read16(__u8 page, __u8 reg)
+{
+ robo_reg(page, reg, REG_MII_ADDR_READ);
+
+ return mdio_read(ROBO_PHY_ADDR, REG_MII_DATA0);
+}
+
+static __u32 robo_read32(__u8 page, __u8 reg)
+{
+ robo_reg(page, reg, REG_MII_ADDR_READ);
+
+ return mdio_read(ROBO_PHY_ADDR, REG_MII_DATA0) |
+ (mdio_read(ROBO_PHY_ADDR, REG_MII_DATA0 + 1) << 16);
+}
+
+static void robo_write16(__u8 page, __u8 reg, __u16 val16)
+{
+ /* write data */
+ mdio_write(ROBO_PHY_ADDR, REG_MII_DATA0, val16);
+
+ robo_reg(page, reg, REG_MII_ADDR_WRITE);
+}
+
+static void robo_write32(__u8 page, __u8 reg, __u32 val32)
+{
+ /* write data */
+ mdio_write(ROBO_PHY_ADDR, REG_MII_DATA0, val32 & 0xFFFF);
+ mdio_write(ROBO_PHY_ADDR, REG_MII_DATA0 + 1, val32 >> 16);
+
+ robo_reg(page, reg, REG_MII_ADDR_WRITE);
+}
+
+/* checks that attached switch is 5365 */
+static bool robo_bcm5365(void)
+{
+ /* set vlan access id to 15 and read it back */
+ __u16 val16 = 15;
+ robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS, val16);
+
+ /* 5365 will refuse this as it does not have this reg */
+ return robo_read16(ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS) != val16;
+}
+
+static bool robo_gmii(void)
+{
+ if (mdio_read(0, ROBO_MII_STAT) & 0x0100)
+ return ((mdio_read(0, 0x0f) & 0xf000) != 0);
+ return false;
+}
+
+static int robo_switch_enable(void)
+{
+ unsigned int i, last_port;
+ u16 val;
+#ifdef CONFIG_BCM47XX
+ char buf[20];
+#endif
+
+ val = robo_read16(ROBO_CTRL_PAGE, ROBO_SWITCH_MODE);
+ if (!(val & (1 << 1))) {
+ /* Unmanaged mode */
+ val &= ~(1 << 0);
+ /* With forwarding */
+ val |= (1 << 1);
+ robo_write16(ROBO_CTRL_PAGE, ROBO_SWITCH_MODE, val);
+ val = robo_read16(ROBO_CTRL_PAGE, ROBO_SWITCH_MODE);
+ if (!(val & (1 << 1))) {
+ printk(KERN_ERR PFX "Failed to enable switch\n");
+ return -EBUSY;
+ }
+
+ /* No spanning tree for unmanaged mode */
+ last_port = (robo.devid == ROBO_DEVICE_ID_5398) ?
+ ROBO_PORT7_CTRL : ROBO_PORT4_CTRL;
+ for (i = ROBO_PORT0_CTRL; i <= last_port; i++)
+ robo_write16(ROBO_CTRL_PAGE, i, 0);
+
+ /* No spanning tree on IMP port too */
+ robo_write16(ROBO_CTRL_PAGE, ROBO_IM_PORT_CTRL, 0);
+ }
+
+ if (robo.devid == ROBO_DEVICE_ID_53125) {
+ /* Make IM port status link by default */
+ val = robo_read16(ROBO_CTRL_PAGE, ROBO_PORT_OVERRIDE_CTRL) | 0xb1;
+ robo_write16(ROBO_CTRL_PAGE, ROBO_PORT_OVERRIDE_CTRL, val);
+ // TODO: init EEE feature
+ }
+
+#ifdef CONFIG_BCM47XX
+ /* WAN port LED, except for Netgear WGT634U */
+ if (bcm47xx_nvram_getenv("nvram_type", buf, sizeof(buf)) >= 0) {
+ if (strcmp(buf, "cfe") != 0)
+ robo_write16(ROBO_CTRL_PAGE, 0x16, 0x1F);
+ }
+#endif
+ return 0;
+}
+
+static void robo_switch_reset(void)
+{
+ if ((robo.devid == ROBO_DEVICE_ID_5395) ||
+ (robo.devid == ROBO_DEVICE_ID_5397) ||
+ (robo.devid == ROBO_DEVICE_ID_5398)) {
+ /* Trigger a software reset. */
+ robo_write16(ROBO_CTRL_PAGE, 0x79, 0x83);
+ mdelay(500);
+ robo_write16(ROBO_CTRL_PAGE, 0x79, 0);
+ }
+}
+
+#ifdef CONFIG_BCM47XX
+static int get_gpio_pin(const char *name)
+{
+ int i, err;
+ char nvram_var[10];
+ char buf[30];
+
+ for (i = 0; i < 16; i++) {
+ err = snprintf(nvram_var, sizeof(nvram_var), "gpio%i", i);
+ if (err <= 0)
+ continue;
+ err = bcm47xx_nvram_getenv(nvram_var, buf, sizeof(buf));
+ if (err <= 0)
+ continue;
+ if (!strcmp(name, buf))
+ return i;
+ }
+ return -1;
+}
+#endif
+
+static int robo_probe(char *devname)
+{
+ __u32 phyid;
+ unsigned int i;
+ int err = -1;
+ struct mii_ioctl_data *mii;
+
+ printk(KERN_INFO PFX "Probing device '%s'\n", devname);
+ strcpy(robo.ifr.ifr_name, devname);
+
+ if ((robo.dev = dev_get_by_name(&init_net, devname)) == NULL) {
+ printk(KERN_ERR PFX "No such device\n");
+ err = -ENODEV;
+ goto err_done;
+ }
+ if (!robo.dev->netdev_ops || !robo.dev->netdev_ops->ndo_do_ioctl) {
+ printk(KERN_ERR PFX "ndo_do_ioctl not implemented in ethernet driver\n");
+ err = -ENXIO;
+ goto err_put;
+ }
+
+ robo.device = devname;
+
+ /* try access using MII ioctls - get phy address */
+ err = do_ioctl(SIOCGMIIPHY);
+ if (err < 0) {
+ printk(KERN_ERR PFX "error (%i) while accessing MII phy registers with ioctls\n", err);
+ goto err_put;
+ }
+
+ /* got phy address check for robo address */
+ mii = if_mii(&robo.ifr);
+ if ((mii->phy_id != ROBO_PHY_ADDR) &&
+ (mii->phy_id != ROBO_PHY_ADDR_BCM63XX) &&
+ (mii->phy_id != ROBO_PHY_ADDR_TG3)) {
+ printk(KERN_ERR PFX "Invalid phy address (%d)\n", mii->phy_id);
+ err = -ENODEV;
+ goto err_put;
+ }
+
+#ifdef CONFIG_BCM47XX
+ robo.gpio_lanports_enable = get_gpio_pin("lanports_enable");
+ if (robo.gpio_lanports_enable >= 0) {
+ err = gpio_request(robo.gpio_lanports_enable, "lanports_enable");
+ if (err) {
+ printk(KERN_ERR PFX "error (%i) requesting lanports_enable gpio (%i)\n",
+ err, robo.gpio_lanports_enable);
+ goto err_put;
+ }
+ gpio_direction_output(robo.gpio_lanports_enable, 1);
+ mdelay(5);
+ }
+
+ robo.gpio_robo_reset = get_gpio_pin("robo_reset");
+ if (robo.gpio_robo_reset >= 0) {
+ err = gpio_request(robo.gpio_robo_reset, "robo_reset");
+ if (err) {
+ printk(KERN_ERR PFX "error (%i) requesting robo_reset gpio (%i)\n",
+ err, robo.gpio_robo_reset);
+ goto err_gpio_robo;
+ }
+ gpio_set_value(robo.gpio_robo_reset, 0);
+ gpio_direction_output(robo.gpio_robo_reset, 1);
+ gpio_set_value(robo.gpio_robo_reset, 0);
+ mdelay(50);
+
+ gpio_set_value(robo.gpio_robo_reset, 1);
+ mdelay(20);
+ } else {
+ // TODO: reset the internal robo switch
+ }
+#endif
+
+ phyid = mdio_read(ROBO_PHY_ADDR, 0x2) |
+ (mdio_read(ROBO_PHY_ADDR, 0x3) << 16);
+
+ if (phyid == 0xffffffff || phyid == 0x55210022) {
+ printk(KERN_ERR PFX "No Robo switch in managed mode found, phy_id = 0x%08x\n", phyid);
+ err = -ENODEV;
+ goto err_gpio_lanports;
+ }
+
+ /* Get the device ID */
+ for (i = 0; i < 10; i++) {
+ robo.devid = robo_read16(ROBO_MGMT_PAGE, ROBO_DEVICE_ID);
+ if (robo.devid)
+ break;
+ udelay(10);
+ }
+ if (!robo.devid)
+ robo.devid = ROBO_DEVICE_ID_5325; /* Fake it */
+ if (robo.devid == ROBO_DEVICE_ID_5325)
+ robo.is_5365 = robo_bcm5365();
+ else
+ robo.is_5365 = false;
+
+ robo.gmii = robo_gmii();
+ if (robo.devid == ROBO_DEVICE_ID_5325) {
+ for (i = 0; i < 5; i++)
+ robo.port[i] = i;
+ } else {
+ for (i = 0; i < 8; i++)
+ robo.port[i] = i;
+ }
+ robo.port[i] = ROBO_IM_PORT_CTRL;
+
+ robo_switch_reset();
+ err = robo_switch_enable();
+ if (err)
+ goto err_gpio_lanports;
+
+ printk(KERN_INFO PFX "found a 5%s%x!%s at %s\n", robo.devid & 0xff00 ? "" : "3", robo.devid,
+ robo.is_5365 ? " It's a BCM5365." : "", devname);
+
+ return 0;
+
+err_gpio_lanports:
+ if (robo.gpio_lanports_enable >= 0)
+ gpio_free(robo.gpio_lanports_enable);
+err_gpio_robo:
+ if (robo.gpio_robo_reset >= 0)
+ gpio_free(robo.gpio_robo_reset);
+err_put:
+ dev_put(robo.dev);
+ robo.dev = NULL;
+err_done:
+ return err;
+}
+
+static int handle_vlan_port_read_old(switch_driver *d, char *buf, int nr)
+{
+ __u16 val16;
+ int len = 0;
+ int j;
+
+ val16 = (nr) /* vlan */ | (0 << 12) /* read */ | (1 << 13) /* enable */;
+
+ if (robo.is_5365) {
+ robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS_5365, val16);
+ /* actual read */
+ val16 = robo_read16(ROBO_VLAN_PAGE, ROBO_VLAN_READ);
+ if ((val16 & (1 << 14)) /* valid */) {
+ for (j = 0; j < d->ports; j++) {
+ if (val16 & (1 << j)) {
+ len += sprintf(buf + len, "%d", j);
+ if (val16 & (1 << (j + 7))) {
+ if (j == d->cpuport)
+ buf[len++] = 'u';
+ } else {
+ buf[len++] = 't';
+ if (robo_read16(ROBO_VLAN_PAGE, ROBO_VLAN_PORT0_DEF_TAG + (j << 1)) == nr)
+ buf[len++] = '*';
+ }
+ buf[len++] = '\t';
+ }
+ }
+ len += sprintf(buf + len, "\n");
+ }
+ } else {
+ u32 val32;
+ robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS, val16);
+ /* actual read */
+ val32 = robo_read32(ROBO_VLAN_PAGE, ROBO_VLAN_READ);
+ if ((val32 & (1 << 20)) /* valid */) {
+ for (j = 0; j < d->ports; j++) {
+ if (val32 & (1 << j)) {
+ len += sprintf(buf + len, "%d", j);
+ if (val32 & (1 << (j + d->ports))) {
+ if (j == d->cpuport)
+ buf[len++] = 'u';
+ } else {
+ buf[len++] = 't';
+ if (robo_read16(ROBO_VLAN_PAGE, ROBO_VLAN_PORT0_DEF_TAG + (j << 1)) == nr)
+ buf[len++] = '*';
+ }
+ buf[len++] = '\t';
+ }
+ }
+ len += sprintf(buf + len, "\n");
+ }
+ }
+
+ buf[len] = '\0';
+
+ return len;
+}
+
+static int handle_vlan_port_read_new(switch_driver *d, char *buf, int nr)
+{
+ __u8 vtbl_entry, vtbl_index, vtbl_access;
+ __u32 val32;
+ int len = 0;
+ int j;
+
+ if ((robo.devid == ROBO_DEVICE_ID_5395) ||
+ (robo.devid == ROBO_DEVICE_ID_53115) ||
+ (robo.devid == ROBO_DEVICE_ID_53125)) {
+ vtbl_access = ROBO_VTBL_ACCESS_5395;
+ vtbl_index = ROBO_VTBL_INDX_5395;
+ vtbl_entry = ROBO_VTBL_ENTRY_5395;
+ } else {
+ vtbl_access = ROBO_VTBL_ACCESS;
+ vtbl_index = ROBO_VTBL_INDX;
+ vtbl_entry = ROBO_VTBL_ENTRY;
+ }
+
+ robo_write16(ROBO_ARLIO_PAGE, vtbl_index, nr);
+ robo_write16(ROBO_ARLIO_PAGE, vtbl_access, (1 << 7) | (1 << 0));
+ val32 = robo_read32(ROBO_ARLIO_PAGE, vtbl_entry);
+ for (j = 0; j < d->ports; j++) {
+ if (val32 & (1 << j)) {
+ len += sprintf(buf + len, "%d", j);
+ if (val32 & (1 << (j + d->ports))) {
+ if (j == d->cpuport)
+ buf[len++] = 'u';
+ } else {
+ buf[len++] = 't';
+ if (robo_read16(ROBO_VLAN_PAGE, ROBO_VLAN_PORT0_DEF_TAG + (j << 1)) == nr)
+ buf[len++] = '*';
+ }
+ buf[len++] = '\t';
+ }
+ }
+ len += sprintf(buf + len, "\n");
+ buf[len] = '\0';
+ return len;
+}
+
+static int handle_vlan_port_read(void *driver, char *buf, int nr)
+{
+ switch_driver *d = (switch_driver *) driver;
+
+ if (robo.devid != ROBO_DEVICE_ID_5325)
+ return handle_vlan_port_read_new(d, buf, nr);
+ else
+ return handle_vlan_port_read_old(d, buf, nr);
+}
+
+static void handle_vlan_port_write_old(switch_driver *d, switch_vlan_config *c, int nr)
+{
+ __u16 val16;
+ __u32 val32;
+ __u32 untag = ((c->untag & ~(1 << d->cpuport)) << d->ports);
+
+ /* write config now */
+ val16 = (nr) /* vlan */ | (1 << 12) /* write */ | (1 << 13) /* enable */;
+ if (robo.is_5365) {
+ robo_write32(ROBO_VLAN_PAGE, ROBO_VLAN_WRITE_5365,
+ (1 << 14) /* valid */ | (untag << 1 ) | c->port);
+ robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS_5365, val16);
+ } else {
+ if (robo.corerev < 3)
+ val32 = (1 << 20) | ((nr >> 4) << 12) | untag | c->port;
+ else
+ val32 = (1 << 24) | (nr << 12) | untag | c->port;
+ robo_write32(ROBO_VLAN_PAGE, ROBO_VLAN_WRITE, val32);
+ robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS, val16);
+ }
+}
+
+static void handle_vlan_port_write_new(switch_driver *d, switch_vlan_config *c, int nr)
+{
+ __u8 vtbl_entry, vtbl_index, vtbl_access;
+ __u32 untag = ((c->untag & ~(1 << d->cpuport)) << d->ports);
+
+ /* write config now */
+ if ((robo.devid == ROBO_DEVICE_ID_5395) ||
+ (robo.devid == ROBO_DEVICE_ID_53115) ||
+ (robo.devid == ROBO_DEVICE_ID_53125)) {
+ vtbl_access = ROBO_VTBL_ACCESS_5395;
+ vtbl_index = ROBO_VTBL_INDX_5395;
+ vtbl_entry = ROBO_VTBL_ENTRY_5395;
+ } else {
+ vtbl_access = ROBO_VTBL_ACCESS;
+ vtbl_index = ROBO_VTBL_INDX;
+ vtbl_entry = ROBO_VTBL_ENTRY;
+ }
+
+ robo_write32(ROBO_ARLIO_PAGE, vtbl_entry, untag | c->port);
+ robo_write16(ROBO_ARLIO_PAGE, vtbl_index, nr);
+ robo_write16(ROBO_ARLIO_PAGE, vtbl_access, 1 << 7);
+}
+
+static int handle_vlan_port_write(void *driver, char *buf, int nr)
+{
+ switch_driver *d = (switch_driver *)driver;
+ switch_vlan_config *c = switch_parse_vlan(d, buf);
+ int j;
+
+ if (c == NULL)
+ return -EINVAL;
+
+ for (j = 0; j < d->ports; j++) {
+ if ((c->untag | c->pvid) & (1 << j)) {
+ /* change default vlan tag */
+ robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_PORT0_DEF_TAG + (j << 1), nr);
+ }
+ }
+
+ if (robo.devid != ROBO_DEVICE_ID_5325)
+ handle_vlan_port_write_new(d, c, nr);
+ else
+ handle_vlan_port_write_old(d, c, nr);
+
+ kfree(c);
+ return 0;
+}
+
+#define set_switch(state) \
+ robo_write16(ROBO_CTRL_PAGE, ROBO_SWITCH_MODE, (robo_read16(ROBO_CTRL_PAGE, ROBO_SWITCH_MODE) & ~2) | (state ? 2 : 0));
+
+static int handle_enable_read(void *driver, char *buf, int nr)
+{
+ return sprintf(buf, "%d\n", (((robo_read16(ROBO_CTRL_PAGE, ROBO_SWITCH_MODE) & 2) == 2) ? 1 : 0));
+}
+
+static int handle_enable_write(void *driver, char *buf, int nr)
+{
+ set_switch(buf[0] == '1');
+
+ return 0;
+}
+
+static int handle_port_enable_read(void *driver, char *buf, int nr)
+{
+ return sprintf(buf, "%d\n", ((robo_read16(ROBO_CTRL_PAGE, robo.port[nr]) & 3) == 3 ? 0 : 1));
+}
+
+static int handle_port_enable_write(void *driver, char *buf, int nr)
+{
+ u16 val16;
+
+ if (buf[0] == '0')
+ val16 = 3; /* disabled */
+ else if (buf[0] == '1')
+ val16 = 0; /* enabled */
+ else
+ return -EINVAL;
+
+ robo_write16(ROBO_CTRL_PAGE, robo.port[nr],
+ (robo_read16(ROBO_CTRL_PAGE, robo.port[nr]) & ~3) | val16);
+
+ return 0;
+}
+
+static int handle_port_media_read(void *driver, char *buf, int nr)
+{
+ u16 bmcr = mdio_read(robo.port[nr], MII_BMCR);
+ int media, len;
+
+ if (bmcr & BMCR_ANENABLE)
+ media = SWITCH_MEDIA_AUTO;
+ else {
+ if (bmcr & BMCR_SPEED1000)
+ media = SWITCH_MEDIA_1000;
+ else if (bmcr & BMCR_SPEED100)
+ media = SWITCH_MEDIA_100;
+ else
+ media = 0;
+
+ if (bmcr & BMCR_FULLDPLX)
+ media |= SWITCH_MEDIA_FD;
+ }
+
+ len = switch_print_media(buf, media);
+ return len + sprintf(buf + len, "\n");
+}
+
+static int handle_port_media_write(void *driver, char *buf, int nr)
+{
+ int media = switch_parse_media(buf);
+ u16 bmcr, bmcr_mask;
+
+ if (media & SWITCH_MEDIA_AUTO)
+ bmcr = BMCR_ANENABLE | BMCR_ANRESTART;
+ else {
+ if (media & SWITCH_MEDIA_1000) {
+ if (!robo.gmii)
+ return -EINVAL;
+ bmcr = BMCR_SPEED1000;
+ }
+ else if (media & SWITCH_MEDIA_100)
+ bmcr = BMCR_SPEED100;
+ else
+ bmcr = 0;
+
+ if (media & SWITCH_MEDIA_FD)
+ bmcr |= BMCR_FULLDPLX;
+ }
+
+ bmcr_mask = ~(BMCR_SPEED1000 | BMCR_SPEED100 | BMCR_FULLDPLX | BMCR_ANENABLE | BMCR_ANRESTART);
+ mdio_write(robo.port[nr], MII_BMCR,
+ (mdio_read(robo.port[nr], MII_BMCR) & bmcr_mask) | bmcr);
+
+ return 0;
+}
+
+static int handle_enable_vlan_read(void *driver, char *buf, int nr)
+{
+ return sprintf(buf, "%d\n", (((robo_read16(ROBO_VLAN_PAGE, ROBO_VLAN_CTRL0) & (1 << 7)) == (1 << 7)) ? 1 : 0));
+}
+
+static int handle_enable_vlan_write(void *driver, char *buf, int nr)
+{
+ __u16 val16;
+ int disable = ((buf[0] != '1') ? 1 : 0);
+
+ val16 = robo_read16(ROBO_VLAN_PAGE, ROBO_VLAN_CTRL0);
+ robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_CTRL0, disable ? 0 :
+ val16 | (1 << 7) /* 802.1Q VLAN */ | (3 << 5) /* mac check and hash */);
+
+ val16 = robo_read16(ROBO_VLAN_PAGE, ROBO_VLAN_CTRL1);
+ robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_CTRL1, disable ? 0 :
+ val16 | (robo.devid == ROBO_DEVICE_ID_5325 ? (1 << 1) :
+ 0) | (1 << 2) | (1 << 3)); /* RSV multicast */
+
+ if (robo.devid != ROBO_DEVICE_ID_5325)
+ return 0;
+
+ robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_CTRL4, disable ? 0 :
+ (1 << 6) /* drop invalid VID frames */);
+ robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_CTRL5, disable ? 0 :
+ (1 << 3) /* drop miss V table frames */);
+
+ return 0;
+}
+
+static void handle_reset_old(switch_driver *d, char *buf, int nr)
+{
+ int j;
+ __u16 val16;
+
+ /* reset vlans */
+ for (j = 0; j <= ((robo.is_5365) ? VLAN_ID_MAX_5365 : VLAN_ID_MAX); j++) {
+ /* write config now */
+ val16 = (j) /* vlan */ | (1 << 12) /* write */ | (1 << 13) /* enable */;
+ if (robo.is_5365)
+ robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_WRITE_5365, 0);
+ else
+ robo_write32(ROBO_VLAN_PAGE, ROBO_VLAN_WRITE, 0);
+ robo_write16(ROBO_VLAN_PAGE, robo.is_5365 ? ROBO_VLAN_TABLE_ACCESS_5365 :
+ ROBO_VLAN_TABLE_ACCESS,
+ val16);
+ }
+}
+
+static void handle_reset_new(switch_driver *d, char *buf, int nr)
+{
+ int j;
+ __u8 vtbl_entry, vtbl_index, vtbl_access;
+
+ if ((robo.devid == ROBO_DEVICE_ID_5395) ||
+ (robo.devid == ROBO_DEVICE_ID_53115) ||
+ (robo.devid == ROBO_DEVICE_ID_53125)) {
+ vtbl_access = ROBO_VTBL_ACCESS_5395;
+ vtbl_index = ROBO_VTBL_INDX_5395;
+ vtbl_entry = ROBO_VTBL_ENTRY_5395;
+ } else {
+ vtbl_access = ROBO_VTBL_ACCESS;
+ vtbl_index = ROBO_VTBL_INDX;
+ vtbl_entry = ROBO_VTBL_ENTRY;
+ }
+
+ for (j = 0; j <= VLAN_ID_MAX; j++) {
+ /* write config now */
+ robo_write32(ROBO_ARLIO_PAGE, vtbl_entry, 0);
+ robo_write16(ROBO_ARLIO_PAGE, vtbl_index, j);
+ robo_write16(ROBO_ARLIO_PAGE, vtbl_access, 1 << 7);
+ }
+}
+
+static int handle_reset(void *driver, char *buf, int nr)
+{
+ int j;
+ switch_driver *d = (switch_driver *) driver;
+
+ /* disable switching */
+ set_switch(0);
+
+ if (robo.devid != ROBO_DEVICE_ID_5325)
+ handle_reset_new(d, buf, nr);
+ else
+ handle_reset_old(d, buf, nr);
+
+ /* reset ports to a known good state */
+ for (j = 0; j < d->ports; j++) {
+ robo_write16(ROBO_CTRL_PAGE, robo.port[j], 0x0000);
+ robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_PORT0_DEF_TAG + (j << 1), 0);
+ }
+
+ /* enable switching */
+ set_switch(1);
+
+ /* enable vlans */
+ handle_enable_vlan_write(driver, "1", 0);
+
+ return 0;
+}
+
+static int __init robo_init(void)
+{
+ int notfound = 1;
+ char *device;
+
+ device = strdup("ethX");
+ for (device[3] = '0'; (device[3] <= '3') && notfound; device[3]++) {
+ if (! switch_device_registered (device))
+ notfound = robo_probe(device);
+ }
+ device[3]--;
+
+ if (notfound) {
+ kfree(device);
+ return -ENODEV;
+ } else {
+ static const switch_config cfg[] = {
+ {
+ .name = "enable",
+ .read = handle_enable_read,
+ .write = handle_enable_write
+ }, {
+ .name = "enable_vlan",
+ .read = handle_enable_vlan_read,
+ .write = handle_enable_vlan_write
+ }, {
+ .name = "reset",
+ .read = NULL,
+ .write = handle_reset
+ }, { NULL, },
+ };
+ static const switch_config port[] = {
+ {
+ .name = "enable",
+ .read = handle_port_enable_read,
+ .write = handle_port_enable_write
+ }, {
+ .name = "media",
+ .read = handle_port_media_read,
+ .write = handle_port_media_write
+ }, { NULL, },
+ };
+ static const switch_config vlan[] = {
+ {
+ .name = "ports",
+ .read = handle_vlan_port_read,
+ .write = handle_vlan_port_write
+ }, { NULL, },
+ };
+ switch_driver driver = {
+ .name = DRIVER_NAME,
+ .version = DRIVER_VERSION,
+ .interface = device,
+ .cpuport = 5,
+ .ports = 6,
+ .vlans = 16,
+ .driver_handlers = cfg,
+ .port_handlers = port,
+ .vlan_handlers = vlan,
+ };
+ if (robo.devid != ROBO_DEVICE_ID_5325) {
+ driver.ports = 9;
+ driver.cpuport = 8;
+ }
+ if (robo.is_5365)
+ snprintf(driver.dev_name, SWITCH_NAME_BUFSZ, "BCM5365");
+ else
+ snprintf(driver.dev_name, SWITCH_NAME_BUFSZ, "BCM5%s%x", robo.devid & 0xff00 ? "" : "3", robo.devid);
+
+ return switch_register_driver(&driver);
+ }
+}
+
+static void __exit robo_exit(void)
+{
+ switch_unregister_driver(DRIVER_NAME);
+ if (robo.dev)
+ dev_put(robo.dev);
+ if (robo.gpio_robo_reset >= 0)
+ gpio_free(robo.gpio_robo_reset);
+ if (robo.gpio_lanports_enable >= 0)
+ gpio_free(robo.gpio_lanports_enable);
+ kfree(robo.device);
+}
+
+
+MODULE_AUTHOR("Felix Fietkau <openwrt@nbd.name>");
+MODULE_LICENSE("GPL");
+
+module_init(robo_init);
+module_exit(robo_exit);
diff --git a/package/switch/src/Makefile b/package/switch/src/Makefile
new file mode 100644
index 0000000..b6934cc
--- /dev/null
+++ b/package/switch/src/Makefile
@@ -0,0 +1,18 @@
+#
+# Makefile for switch driver
+#
+# Copyright (C) 2005 Felix Fietkau <nbd@openwrt.org>
+#
+# 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 of the License, or (at your option) any later version.
+#
+
+obj-m := switch-core.o switch-adm.o switch-robo.o
+
+ifeq ($(MAKING_MODULES),1)
+export-objs := switch-core.o
+
+-include $(TOPDIR)/Rules.make
+endif
diff --git a/package/switch/src/etc53xx.h b/package/switch/src/etc53xx.h
new file mode 100644
index 0000000..0cd217e
--- /dev/null
+++ b/package/switch/src/etc53xx.h
@@ -0,0 +1,624 @@
+/*
+ * Broadcom Home Gateway Reference Design
+ * BCM53xx Register definitions
+ *
+ * Copyright 2004, Broadcom Corporation
+ * All Rights Reserved.
+ *
+ * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
+ * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
+ * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
+ * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
+ */
+
+#ifndef __BCM535M_H_
+#define __BCM535M_H_
+
+/* ROBO embedded device type */
+#define ROBO_DEV_5380 1
+#define ROBO_DEV_5365 2
+#define ROBO_DEV_5350 3
+#define ROBO_DEV_53115 4
+
+/* BCM5325m GLOBAL PAGE REGISTER MAP */
+#ifndef _CFE_
+#pragma pack(1)
+#endif
+
+/* BCM5325m Serial Management Port (SMP) Page offsets */
+#define ROBO_CTRL_PAGE 0x00 /* Control registers */
+#define ROBO_STAT_PAGE 0x01 /* Status register */
+#define ROBO_MGMT_PAGE 0x02 /* Management Mode registers */
+#define ROBO_MIB_AC_PAGE 0x03 /* MIB Autocast registers */
+#define ROBO_ARLCTRL_PAGE 0x04 /* ARL Control Registers */
+#define ROBO_ARLIO_PAGE 0x05 /* ARL Access Registers */
+#define ROBO_FRAMEBUF_PAGE 0x06 /* Management frame access registers */
+#define ROBO_MEM_ACCESS_PAGE 0x08 /* Memory access registers */
+
+/* PHY Registers */
+#define ROBO_PORT0_MII_PAGE 0x10 /* Port 0 MII Registers */
+#define ROBO_PORT1_MII_PAGE 0x11 /* Port 1 MII Registers */
+#define ROBO_PORT2_MII_PAGE 0x12 /* Port 2 MII Registers */
+#define ROBO_PORT3_MII_PAGE 0x13 /* Port 3 MII Registers */
+#define ROBO_PORT4_MII_PAGE 0x14 /* Port 4 MII Registers */
+/* (start) registers only for BCM5380 */
+#define ROBO_PORT5_MII_PAGE 0x15 /* Port 5 MII Registers */
+#define ROBO_PORT6_MII_PAGE 0x16 /* Port 6 MII Registers */
+#define ROBO_PORT7_MII_PAGE 0x17 /* Port 7 MII Registers */
+/* (end) registers only for BCM5380 */
+#define ROBO_IM_PORT_PAGE 0x18 /* Inverse MII Port (to EMAC) */
+#define ROBO_ALL_PORT_PAGE 0x19 /* All ports MII Registers (broadcast)*/
+
+/* MAC Statistics registers */
+#define ROBO_PORT0_MIB_PAGE 0x20 /* Port 0 10/100 MIB Statistics */
+#define ROBO_PORT1_MIB_PAGE 0x21 /* Port 1 10/100 MIB Statistics */
+#define ROBO_PORT2_MIB_PAGE 0x22 /* Port 2 10/100 MIB Statistics */
+#define ROBO_PORT3_MIB_PAGE 0x23 /* Port 3 10/100 MIB Statistics */
+#define ROBO_PORT4_MIB_PAGE 0x24 /* Port 4 10/100 MIB Statistics */
+/* (start) registers only for BCM5380 */
+#define ROBO_PORT5_MIB_PAGE 0x25 /* Port 5 10/100 MIB Statistics */
+#define ROBO_PORT6_MIB_PAGE 0x26 /* Port 6 10/100 MIB Statistics */
+#define ROBO_PORT7_MIB_PAGE 0x27 /* Port 7 10/100 MIB Statistics */
+/* (end) registers only for BCM5380 */
+#define ROBO_IM_PORT_MIB_PAGE 0x28 /* Inverse MII Port MIB Statistics */
+
+/* Quality of Service (QoS) Registers */
+#define ROBO_QOS_PAGE 0x30 /* QoS Registers */
+
+/* VLAN Registers */
+#define ROBO_VLAN_PAGE 0x34 /* VLAN Registers */
+
+/* Note SPI Data/IO Registers not used */
+#define ROBO_SPI_DATA_IO_0_PAGE 0xf0 /* SPI Data I/O 0 */
+#define ROBO_SPI_DATA_IO_1_PAGE 0xf1 /* SPI Data I/O 1 */
+#define ROBO_SPI_DATA_IO_2_PAGE 0xf2 /* SPI Data I/O 2 */
+#define ROBO_SPI_DATA_IO_3_PAGE 0xf3 /* SPI Data I/O 3 */
+#define ROBO_SPI_DATA_IO_4_PAGE 0xf4 /* SPI Data I/O 4 */
+#define ROBO_SPI_DATA_IO_5_PAGE 0xf5 /* SPI Data I/O 5 */
+#define ROBO_SPI_DATA_IO_6_PAGE 0xf6 /* SPI Data I/O 6 */
+#define ROBO_SPI_DATA_IO_7_PAGE 0xf7 /* SPI Data I/O 7 */
+
+#define ROBO_SPI_STATUS_PAGE 0xfe /* SPI Status Registers */
+#define ROBO_PAGE_PAGE 0xff /* Page Registers */
+
+
+/* BCM5325m CONTROL PAGE (0x00) REGISTER MAP : 8bit (byte) registers */
+typedef struct _ROBO_PORT_CTRL_STRUC
+{
+ unsigned char rx_disable:1; /* rx disable */
+ unsigned char tx_disable:1; /* tx disable */
+ unsigned char rsvd:3; /* reserved */
+ unsigned char stp_state:3; /* spanning tree state */
+} ROBO_PORT_CTRL_STRUC;
+
+#define ROBO_PORT0_CTRL 0x00 /* 10/100 Port 0 Control */
+#define ROBO_PORT1_CTRL 0x01 /* 10/100 Port 1 Control */
+#define ROBO_PORT2_CTRL 0x02 /* 10/100 Port 2 Control */
+#define ROBO_PORT3_CTRL 0x03 /* 10/100 Port 3 Control */
+#define ROBO_PORT4_CTRL 0x04 /* 10/100 Port 4 Control */
+/* (start) registers only for BCM5380 */
+#define ROBO_PORT5_CTRL 0x05 /* 10/100 Port 5 Control */
+#define ROBO_PORT6_CTRL 0x06 /* 10/100 Port 6 Control */
+#define ROBO_PORT7_CTRL 0x07 /* 10/100 Port 7 Control */
+/* (end) registers only for BCM5380 */
+#define ROBO_IM_PORT_CTRL 0x08 /* 10/100 Port 8 Control */
+#define ROBO_SMP_CTRL 0x0a /* SMP Control register */
+#define ROBO_SWITCH_MODE 0x0b /* Switch Mode Control */
+#define ROBO_PORT_OVERRIDE_CTRL 0x0e /* Port state override */
+#define ROBO_PORT_OVERRIDE_RVMII (1<<4) /* Bit 4 enables RvMII */
+#define ROBO_PD_MODE_CTRL 0x0f /* Power-down mode control */
+#define ROBO_IP_MULTICAST_CTRL 0x21 /* IP Multicast control */
+
+/* BCM5325m STATUS PAGE (0x01) REGISTER MAP : 16bit/48bit registers */
+#define ROBO_HALF_DUPLEX 0
+#define ROBO_FULL_DUPLEX 1
+
+#define ROBO_LINK_STAT_SUMMARY 0x00 /* Link Status Summary: 16bit */
+#define ROBO_LINK_STAT_CHANGE 0x02 /* Link Status Change: 16bit */
+#define ROBO_SPEED_STAT_SUMMARY 0x04 /* Port Speed Summary: 16bit*/
+#define ROBO_DUPLEX_STAT_SUMMARY 0x06 /* Duplex Status Summary: 16bit */
+#define ROBO_PAUSE_STAT_SUMMARY 0x08 /* PAUSE Status Summary: 16bit */
+#define ROBO_SOURCE_ADDR_CHANGE 0x0C /* Source Address Change: 16bit */
+#define ROBO_LSA_PORT0 0x10 /* Last Source Addr, Port 0: 48bits*/
+#define ROBO_LSA_PORT1 0x16 /* Last Source Addr, Port 1: 48bits*/
+#define ROBO_LSA_PORT2 0x1c /* Last Source Addr, Port 2: 48bits*/
+#define ROBO_LSA_PORT3 0x22 /* Last Source Addr, Port 3: 48bits*/
+#define ROBO_LSA_PORT4 0x28 /* Last Source Addr, Port 4: 48bits*/
+#define ROBO_LSA_IM_PORT 0x40 /* Last Source Addr, IM Port: 48bits*/
+
+/* BCM5325m MANAGEMENT MODE REGISTERS (0x02) REGISTER MAP: 8/48 bit regs*/
+typedef struct _ROBO_GLOBAL_CONFIG_STRUC
+{
+ unsigned char resetMIB:1; /* reset MIB counters */
+ unsigned char rxBPDU:1; /* receive BDPU enable */
+ unsigned char rsvd1:2; /* reserved */
+ unsigned char MIBacHdrCtrl:1; /* MIB autocast header control */
+ unsigned char MIBac:1; /* MIB autocast enable */
+ unsigned char frameMgmtPort:2; /* frame management port */
+} ROBO_GLOBAL_CONFIG_STRUC;
+#define ROBO_GLOBAL_CONFIG 0x00 /* Global Management Config: 8bit*/
+#define ROBO_MGMT_PORT_ID 0x02 /* Management Port ID: 8bit*/
+#define ROBO_RMON_MIB_STEER 0x04 /* RMON Mib Steering: 16bit */
+#define ROBO_MIB_MODE_SELECT 0x04 /* MIB Mode select: 16bit (BCM5350) */
+#define ROBO_AGE_TIMER_CTRL 0x06 /* Age time control: 32bit */
+#define ROBO_MIRROR_CAP_CTRL 0x10 /* Mirror Capture : 16bit */
+#define ROBO_MIRROR_ING_CTRL 0x12 /* Mirror Ingress Control: 16bit */
+#define ROBO_MIRROR_ING_DIV_CTRL 0x14 /* Mirror Ingress Divider: 16bit */
+#define ROBO_MIRROR_ING_MAC_ADDR 0x16 /* Ingress Mirror MAC Addr: 48bit*/
+#define ROBO_MIRROR_EGR_CTRL 0x1c /* Mirror Egress Control: 16bit */
+#define ROBO_MIRROR_EGR_DIV_CTRL 0x1e /* Mirror Egress Divider: 16bit */
+#define ROBO_MIRROR_EGR_MAC_ADDR 0x20 /* Egress Mirror MAC Addr: 48bit*/
+
+/* BCM5325m MIB AUTOCAST REGISTERS (0x03) REGISTER MAP: 8/16/48 bit regs */
+#define ROBO_MIB_AC_PORT 0x00 /* MIB Autocast Port: 16bit */
+#define ROBO_MIB_AC_HDR_PTR 0x02 /* MIB Autocast Header pointer:16bit*/
+#define ROBO_MIB_AC_HDR_LEN 0x04 /* MIB Autocast Header Len: 16bit */
+#define ROBO_MIB_AC_DA 0x06 /* MIB Autocast DA: 48bit */
+#define ROBO_MIB_AC_SA 0x0c /* MIB Autocast SA: 48bit */
+#define ROBO_MIB_AC_TYPE 0x12 /* MIB Autocast Type: 16bit */
+#define ROBO_MIB_AC_RATE 0x14 /* MIB Autocast Rate: 8bit */
+#define ROBO_GET_AC_RATE(secs) ((secs)*10)
+#define ROBO_AC_RATE_MAX 0xff
+#define ROBO_AC_RATE_DEFAULT 0x64 /* 10 secs */
+typedef struct _ROBO_MIB_AC_STRUCT
+{
+ unsigned char opcode:4; /* Tx MIB Autocast opcode */
+ unsigned char portno:4; /* zero-based port no. */
+ unsigned char portstate:8; /* port state */
+ unsigned long long TxOctets;
+ unsigned int TxDropPkts;
+ unsigned int rsvd;
+ unsigned int TxBroadcastPkts;
+ unsigned int TxMulticastPkts;
+ unsigned int TxUnicastPkts;
+ unsigned int TxCollisions;
+ unsigned int TxSingleCollision;
+ unsigned int TxMultiCollision;
+ unsigned int TxDeferredTransmit;
+ unsigned int TxLateCollision;
+ unsigned int TxExcessiveCollision;
+ unsigned int TxFrameInDiscards;
+ unsigned int TxPausePkts;
+ unsigned int rsvd1[2];
+ unsigned long long RxOctets;
+ unsigned int RxUndersizePkts;
+ unsigned int RxPausePkts;
+ unsigned int RxPkts64Octets;
+ unsigned int RxPkts64to127Octets;
+ unsigned int RxPkts128to255Octets;
+ unsigned int RxPkts256to511Octets;
+ unsigned int RxPkts512to1023Octets;
+ unsigned int RxPkts1024to1522Octets;
+ unsigned int RxOversizePkts;
+ unsigned int RxJabbers;
+ unsigned int RxAlignmentErrors;
+ unsigned int RxFCSErrors;
+ unsigned long long RxGoodOctets;
+ unsigned int RxDropPkts;
+ unsigned int RxUnicastPkts;
+ unsigned int RxMulticastPkts;
+ unsigned int RxBroadcastPkts;
+ unsigned int RxSAChanges;
+ unsigned int RxFragments;
+ unsigned int RxExcessSizeDisc;
+ unsigned int RxSymbolError;
+} ROBO_MIB_AC_STRUCT;
+
+/* BCM5325m ARL CONTROL REGISTERS (0x04) REGISTER MAP: 8/16/48/64 bit regs */
+#define ROBO_ARL_CONFIG 0x00 /* ARL Global Configuration: 8bit*/
+#define ROBO_BPDU_MC_ADDR_REG 0x04 /* BPDU Multicast Address Reg:64bit*/
+#define ROBO_MULTIPORT_ADDR_1 0x10 /* Multiport Address 1: 48 bits*/
+#define ROBO_MULTIPORT_VECTOR_1 0x16 /* Multiport Vector 1: 16 bits */
+#define ROBO_MULTIPORT_ADDR_2 0x20 /* Multiport Address 2: 48 bits*/
+#define ROBO_MULTIPORT_VECTOR_2 0x26 /* Multiport Vector 2: 16 bits */
+#define ROBO_SECURE_SRC_PORT_MASK 0x30 /* Secure Source Port Mask: 16 bits*/
+#define ROBO_SECURE_DST_PORT_MASK 0x32 /* Secure Dest Port Mask: 16 bits */
+
+
+/* BCM5325m ARL IO REGISTERS (0x05) REGISTER MAP: 8/16/48/64 bit regs */
+#define ARL_TABLE_WRITE 0 /* for read/write state in control reg */
+#define ARL_TABLE_READ 1 /* for read/write state in control reg */
+#ifdef BCM5380
+#define ARL_VID_BYTES 2 /* number of bytes for VID */
+#else
+#define ARL_VID_BYTES 1 /* number of bytes for VID */
+#endif
+typedef struct _ROBO_ARL_RW_CTRL_STRUC
+{
+ unsigned char ARLrw:1; /* ARL read/write (1=read) */
+ unsigned char rsvd:6; /* reserved */
+ unsigned char ARLStart:1; /* ARL start/done (1=start) */
+} ROBO_ARL_RW_CTRL_STRUC;
+typedef struct _ROBO_ARL_SEARCH_CTRL_STRUC
+{
+ unsigned char valid:1; /* ARL search result valid */
+ unsigned char rsvd:6; /* reserved */
+ unsigned char ARLStart:1; /* ARL start/done (1=start) */
+} ROBO_ARL_SEARCH_CTRL_STRUC;
+typedef struct _ROBO_ARL_ENTRY_CTRL_STRUC
+{
+ unsigned char portID:4; /* port id */
+ unsigned char chipID:2; /* chip id */
+ unsigned char rsvd:5; /* reserved */
+ unsigned char prio:2; /* priority */
+ unsigned char age:1; /* age */
+ unsigned char staticEn:1; /* static */
+ unsigned char valid:1; /* valid */
+} ROBO_ARL_ENTRY_CTRL_STRUC;
+typedef struct _ROBO_ARL_SEARCH_RESULT_CTRL_STRUC
+{
+ unsigned char portID:4; /* port id */
+ unsigned char rsvd:1; /* reserved */
+ unsigned char vid:8; /* vlan id */
+ unsigned char age:1; /* age */
+ unsigned char staticEn:1; /* static */
+ unsigned char valid:1; /* valid */
+} ROBO_ARL_SEARCH_RESULT_CTRL_STRUC;
+typedef struct _ROBO_ARL_ENTRY_MAC_STRUC
+{
+ unsigned char macBytes[6]; /* MAC address */
+} ROBO_ARL_ENTRY_MAC_STRUC;
+
+typedef struct _ROBO_ARL_ENTRY_STRUC
+{
+ ROBO_ARL_ENTRY_MAC_STRUC mac; /* MAC address */
+ ROBO_ARL_ENTRY_CTRL_STRUC ctrl; /* control bits */
+} ROBO_ARL_ENTRY_STRUC;
+
+typedef struct _ROBO_ARL_SEARCH_RESULT_STRUC
+{
+ ROBO_ARL_ENTRY_MAC_STRUC mac; /* MAC address */
+ ROBO_ARL_SEARCH_RESULT_CTRL_STRUC ctrl; /* control bits */
+} ROBO_ARL_SEARCH_RESULT_STRUC;
+
+/* multicast versions of ARL entry structs */
+typedef struct _ROBO_ARL_ENTRY_MCAST_CTRL_STRUC
+{
+ unsigned int portMask:12;/* multicast port mask */
+ unsigned char prio:1; /* priority */
+ unsigned char gigPort:1; /* gigabit port 1 mask */
+ unsigned char staticEn:1; /* static */
+ unsigned char valid:1; /* valid */
+} ROBO_ARL_ENTRY_MCAST_CTRL_STRUC;
+typedef struct _ROBO_ARL_SEARCH_RESULT_MCAST_CTRL_STRUC
+{
+ unsigned int portMask:13; /* multicast port mask */
+ unsigned char age:1; /* age */
+ unsigned char staticEn:1; /* static */
+ unsigned char valid:1; /* valid */
+} ROBO_ARL_SEARCH_RESULT_MCAST_CTRL_STRUC;
+/* BCM5350 extension register */
+typedef struct _ROBO_ARL_SEARCH_RESULT_EXTENSION
+{
+ unsigned int prio:2; /* priority */
+ unsigned int portMask:1; /* MSB (MII) of port mask for multicast */
+ unsigned int reserved:5;
+} ROBO_ARL_SEARCH_RESULT_EXTENSION;
+
+typedef struct _ROBO_ARL_ENTRY_MCAST_STRUC
+{
+ ROBO_ARL_ENTRY_MAC_STRUC mac; /* MAC address */
+ ROBO_ARL_ENTRY_MCAST_CTRL_STRUC ctrl; /* control bits */
+} ROBO_ARL_ENTRY_MCAST_STRUC;
+typedef struct _ROBO_ARL_SEARCH_RESULT_MCAST_STRUC
+{
+ ROBO_ARL_ENTRY_MAC_STRUC mac; /* MAC address */
+ ROBO_ARL_SEARCH_RESULT_MCAST_CTRL_STRUC ctrl; /* control bits */
+} ROBO_ARL_SEARCH_RESULT_MCAST_STRUC;
+
+#define ROBO_ARL_RW_CTRL 0x00 /* ARL Read/Write Control : 8bit */
+#define ROBO_ARL_MAC_ADDR_IDX 0x02 /* MAC Address Index: 48bit */
+#define ROBO_ARL_VID_TABLE_IDX 0x08 /* VID Table Address Index: 8bit */
+#define ROBO_ARL_ENTRY0 0x10 /* ARL Entry 0 : 64 bit */
+#define ROBO_ARL_ENTRY1 0x18 /* ARL Entry 1 : 64 bit */
+#define ROBO_ARL_SEARCH_CTRL 0x20 /* ARL Search Control: 8bit */
+#define ROBO_ARL_SEARCH_ADDR 0x22 /* ARL Search Address: 16bit */
+#define ROBO_ARL_SEARCH_RESULT 0x24 /* ARL Search Result: 64bit */
+#define ROBO_ARL_SEARCH_RESULT_EXT 0x2c /* ARL Search Result Extension (5350): 8bit */
+#define ROBO_ARL_VID_ENTRY0 0x30 /* ARL VID Entry 0: 64bit */
+#define ROBO_ARL_VID_ENTRY1 0x32 /* ARL VID Entry 1: 64bit */
+#define ROBO_ARL_SEARCH_CTRL_53115 0x50 /* ARL Search Control: 8bit */
+#define ROBO_ARL_SEARCH_ADDR_53115 0x51 /* ARL Search Address: 16bit */
+#define ROBO_ARL_SEARCH_RESULT_53115 0x60 /* ARL Search Result: 64bit */
+#define ROBO_ARL_SEARCH_RESULT_EXT_53115 0x68 /* ARL Search Result Extension (53115): 16bit */
+
+/* BCM5395/5397/5398/53115 */
+#define ROBO_VTBL_ACCESS 0x60 /* VLAN table access: 8bit */
+#define ROBO_VTBL_INDX 0x61 /* VLAN table address index: 16bit */
+#define ROBO_VTBL_ENTRY 0x63 /* VLAN table entry: 32bit */
+#define ROBO_VTBL_ACCESS_5395 0x80 /* VLAN table access: 8bit */
+#define ROBO_VTBL_INDX_5395 0x81 /* VLAN table address index: 16bit */
+#define ROBO_VTBL_ENTRY_5395 0x83 /* VLAN table entry: 32bit */
+
+/* BCM5325m MANAGEMENT FRAME REGISTERS (0x6) REGISTER MAP: 8/16 bit regs */
+#define ROBO_MGMT_FRAME_RD_DATA 0x00 /* Management Frame Read Data :8bit*/
+#define ROBO_MGMT_FRAME_WR_DATA 0x01 /* Management Frame Write Data:8bit*/
+#define ROBO_MGMT_FRAME_WR_CTRL 0x02 /* Write Control: 16bit */
+#define ROBO_MGMT_FRAME_RD_STAT 0x04 /* Read Status: 16bit */
+
+/* BCM5325m MEMORY ACCESS REGISTERS (Page 0x08) REGISTER MAP: 32 bit regs */
+#define MEM_TABLE_READ 1 /* for read/write state in mem access reg */
+#define MEM_TABLE_WRITE 0 /* for read/write state in mem access reg */
+#define MEM_TABLE_ACCESS_START 1 /* for mem access read/write start */
+#define MEM_TABLE_ACCESS_DONE 0 /* for mem access read/write done */
+#define VLAN_TABLE_ADDR 0x3800 /* BCM5380 only */
+#ifdef BCM5380
+#define NUM_ARL_TABLE_ENTRIES 4096 /* number of entries in ARL table */
+#define NUM_VLAN_TABLE_ENTRIES 2048 /* number of entries in VLAN table */
+#define ARL_TABLE_ADDR 0 /* offset of ARL table start */
+#else
+#define NUM_ARL_TABLE_ENTRIES 2048 /* number of entries in ARL table */
+#define NUM_VLAN_TABLE_ENTRIES 256 /* number of entries in VLAN table */
+#define ARL_TABLE_ADDR 0x3800 /* offset of ARL table start */
+/* corresponding values for 5350 */
+#define NUM_ARL_TABLE_ENTRIES_5350 1024 /* number of entries in ARL table (5350) */
+#define NUM_VLAN_TABLE_ENTRIES_5350 16 /* number of entries in VLAN table */
+#define ARL_TABLE_ADDR_5350 0x1c00 /* offset of ARL table start (5350) */
+#endif
+#define NUM_ARL_TABLE_ENTRIES_53115 4096 /* number of entries in ARL table (53115) */
+#define NUM_VLAN_TABLE_ENTRIES_53115 4096 /* number of entries in VLAN table */
+typedef struct _ROBO_MEM_ACCESS_CTRL_STRUC
+{
+ unsigned int memAddr:14; /* 64-bit memory address */
+ unsigned char rsvd:4; /* reserved */
+ unsigned char readEn:1; /* read enable (0 == write) */
+ unsigned char startDone:1;/* memory access start/done */
+ unsigned int rsvd1:12; /* reserved */
+} ROBO_MEM_ACCESS_CTRL_STRUC;
+typedef struct _ROBO_MEM_ACCESS_DATA_STRUC
+{
+ unsigned int memData[2]; /* 64-bit data */
+ unsigned short rsvd; /* reserved */
+} ROBO_MEM_ACCESS_DATA_STRUC;
+
+#ifdef BCM5380
+typedef struct _ROBO_ARL_TABLE_DATA_STRUC
+{
+ unsigned char MACaddr[6]; /* MAC addr */
+ unsigned int portID:4; /* port ID */
+ unsigned int chipID:2; /* chip ID */
+ unsigned int rsvd:6; /* reserved */
+ unsigned int highPrio:1; /* high priority address */
+ unsigned int age:1; /* entry accessed/learned since ageing process */
+ unsigned int staticAddr:1;/* entry is static */
+ unsigned int valid:1; /* entry is valid */
+ unsigned int vid:12; /* vlan id */
+ unsigned int rsvd2:4; /* reserved */
+} ROBO_ARL_TABLE_DATA_STRUC;
+#else
+typedef struct _ROBO_ARL_TABLE_DATA_STRUC
+{
+ unsigned char MACaddr[6]; /* MAC addr */
+ unsigned int portID:4; /* port ID */
+ unsigned int chipID:2; /* chip ID */
+ unsigned int rsvd:7; /* reserved */
+ unsigned int age:1; /* entry accessed/learned since ageing process */
+ unsigned int staticAddr:1;/* entry is static */
+ unsigned int valid:1; /* entry is valid */
+} ROBO_ARL_TABLE_DATA_STRUC;
+#endif
+
+/* multicast format*/
+typedef struct _ROBO_ARL_TABLE_MCAST_DATA_STRUC
+{
+ unsigned char MACaddr[6]; /* MAC addr */
+ unsigned int portMask:12;/* multicast port mask */
+ unsigned char prio:1; /* priority */
+ unsigned char gigPort:1; /* gigabit port 1 mask */
+ unsigned char staticEn:1; /* static */
+ unsigned char valid:1; /* valid */
+ unsigned int vid:12; /* vlan id */
+ unsigned int rsvd2:4; /* reserved */
+} ROBO_ARL_TABLE_MCAST_DATA_STRUC;
+#define ROBO_MEM_ACCESS_CTRL 0x00 /* Memory Read/Write Control :32bit*/
+#define ROBO_MEM_ACCESS_DATA 0x04 /* Memory Read/Write Data:64bit*/
+
+/* BCM5325m SWITCH PORT (0x10-18) REGISTER MAP: 8/16 bit regs */
+typedef struct _ROBO_MII_CTRL_STRUC
+{
+ unsigned char rsvd:8; /* reserved */
+ unsigned char duplex:1; /* duplex mode */
+ unsigned char restartAN:1;/* restart auto-negotiation */
+ unsigned char rsvd1:1; /* reserved */
+ unsigned char powerDown:1;/* power down */
+ unsigned char ANenable:1; /* auto-negotiation enable */
+ unsigned char speed:1; /* forced speed selection */
+ unsigned char loopback:1; /* loopback */
+ unsigned char reset:1; /* reset */
+} ROBO_MII_CTRL_STRUC;
+typedef struct _ROBO_MII_AN_ADVERT_STRUC
+{
+ unsigned char selector:5; /* advertise selector field */
+ unsigned char T10BaseT:1; /* advertise 10BaseT */
+ unsigned char T10BaseTFull:1; /* advertise 10BaseT, full duplex */
+ unsigned char T100BaseX:1; /* advertise 100BaseX */
+ unsigned char T100BaseXFull:1;/* advertise 100BaseX full duplex */
+ unsigned char noT4:1; /* do not advertise T4 */
+ unsigned char pause:1; /* advertise pause for full duplex */
+ unsigned char rsvd:2; /* reserved */
+ unsigned char remoteFault:1; /* transmit remote fault */
+ unsigned char rsvd1:1; /* reserved */
+ unsigned char nextPage:1; /* nex page operation supported */
+} ROBO_MII_AN_ADVERT_STRUC;
+#define ROBO_MII_CTRL 0x00 /* Port MII Control */
+#define ROBO_MII_STAT 0x02 /* Port MII Status */
+/* Fields of link status register */
+#define ROBO_MII_STAT_JABBER (1<<1) /* Jabber detected */
+#define ROBO_MII_STAT_LINK (1<<2) /* Link status */
+
+#define ROBO_MII_PHYID_HI 0x04 /* Port PHY ID High */
+#define ROBO_MII_PHYID_LO 0x06 /* Port PHY ID Low */
+#define ROBO_MII_ANA_REG 0x08 /* MII Auto-Neg Advertisement */
+#define ROBO_MII_ANP_REG 0x0a /* MII Auto-Neg Partner Ability */
+#define ROBO_MII_AN_EXP_REG 0x0c /* MII Auto-Neg Expansion */
+#define ROBO_MII_AN_NP_REG 0x0e /* MII next page */
+#define ROBO_MII_ANP_NP_REG 0x10 /* MII Partner next page */
+#define ROBO_MII_100BX_AUX_CTRL 0x20 /* 100BASE-X Auxiliary Control */
+#define ROBO_MII_100BX_AUX_STAT 0x22 /* 100BASE-X Auxiliary Status */
+#define ROBO_MII_100BX_RCV_ERR_CTR 0x24 /* 100BASE-X Receive Error Ctr */
+#define ROBO_MII_100BX_RCV_FS_ERR 0x26 /* 100BASE-X Rcv False Sense Ctr */
+#define ROBO_MII_AUX_CTRL 0x30 /* Auxiliary Control/Status */
+/* Fields of Auxiliary control register */
+#define ROBO_MII_AUX_CTRL_FD (1<<0) /* Full duplex link detected*/
+#define ROBO_MII_AUX_CTRL_SP100 (1<<1) /* Speed 100 indication */
+#define ROBO_MII_AUX_STATUS 0x32 /* Aux Status Summary */
+#define ROBO_MII_CONN_STATUS 0x34 /* Aux Connection Status */
+#define ROBO_MII_AUX_MODE2 0x36 /* Aux Mode 2 */
+#define ROBO_MII_AUX_ERR_STATUS 0x38 /* Aux Error and General Status */
+#define ROBO_MII_AUX_MULTI_PHY 0x3c /* Aux Multiple PHY Register*/
+#define ROBO_MII_BROADCOM_TEST 0x3e /* Broadcom Test Register */
+
+
+/* BCM5325m PORT MIB REGISTERS (Pages 0x20-0x24,0x28) REGISTER MAP: 64/32 */
+/* Tranmit Statistics */
+#define ROBO_MIB_TX_OCTETS 0x00 /* 64b: TxOctets */
+#define ROBO_MIB_TX_DROP_PKTS 0x08 /* 32b: TxDropPkts */
+#define ROBO_MIB_TX_BC_PKTS 0x10 /* 32b: TxBroadcastPkts */
+#define ROBO_MIB_TX_MC_PKTS 0x14 /* 32b: TxMulticastPkts */
+#define ROBO_MIB_TX_UC_PKTS 0x18 /* 32b: TxUnicastPkts */
+#define ROBO_MIB_TX_COLLISIONS 0x1c /* 32b: TxCollisions */
+#define ROBO_MIB_TX_SINGLE_COLLISIONS 0x20 /* 32b: TxSingleCollision */
+#define ROBO_MIB_TX_MULTI_COLLISIONS 0x24 /* 32b: TxMultiCollision */
+#define ROBO_MIB_TX_DEFER_TX 0x28 /* 32b: TxDeferred Transmit */
+#define ROBO_MIB_TX_LATE_COLLISIONS 0x2c /* 32b: TxLateCollision */
+#define ROBO_MIB_EXCESS_COLLISIONS 0x30 /* 32b: TxExcessiveCollision*/
+#define ROBO_MIB_FRAME_IN_DISCARDS 0x34 /* 32b: TxFrameInDiscards */
+#define ROBO_MIB_TX_PAUSE_PKTS 0x38 /* 32b: TxPausePkts */
+
+/* Receive Statistics */
+#define ROBO_MIB_RX_OCTETS 0x44 /* 64b: RxOctets */
+#define ROBO_MIB_RX_UNDER_SIZE_PKTS 0x4c /* 32b: RxUndersizePkts(runts)*/
+#define ROBO_MIB_RX_PAUSE_PKTS 0x50 /* 32b: RxPausePkts */
+#define ROBO_MIB_RX_PKTS_64 0x54 /* 32b: RxPkts64Octets */
+#define ROBO_MIB_RX_PKTS_65_TO_127 0x58 /* 32b: RxPkts64to127Octets*/
+#define ROBO_MIB_RX_PKTS_128_TO_255 0x5c /* 32b: RxPkts128to255Octets*/
+#define ROBO_MIB_RX_PKTS_256_TO_511 0x60 /* 32b: RxPkts256to511Octets*/
+#define ROBO_MIB_RX_PKTS_512_TO_1023 0x64 /* 32b: RxPkts512to1023Octets*/
+#define ROBO_MIB_RX_PKTS_1024_TO_1522 0x68 /* 32b: RxPkts1024to1522Octets*/
+#define ROBO_MIB_RX_OVER_SIZE_PKTS 0x6c /* 32b: RxOversizePkts*/
+#define ROBO_MIB_RX_JABBERS 0x70 /* 32b: RxJabbers*/
+#define ROBO_MIB_RX_ALIGNMENT_ERRORS 0x74 /* 32b: RxAlignmentErrors*/
+#define ROBO_MIB_RX_FCS_ERRORS 0x78 /* 32b: RxFCSErrors */
+#define ROBO_MIB_RX_GOOD_OCTETS 0x7c /* 32b: RxGoodOctets */
+#define ROBO_MIB_RX_DROP_PKTS 0x84 /* 32b: RxDropPkts */
+#define ROBO_MIB_RX_UC_PKTS 0x88 /* 32b: RxUnicastPkts */
+#define ROBO_MIB_RX_MC_PKTS 0x8c /* 32b: RxMulticastPkts */
+#define ROBO_MIB_RX_BC_PKTS 0x90 /* 32b: RxBroadcastPkts */
+#define ROBO_MIB_RX_SA_CHANGES 0x94 /* 32b: RxSAChanges */
+#define ROBO_MIB_RX_FRAGMENTS 0x98 /* 32b: RxFragments */
+#define ROBO_MIB_RX_EXCESS_SZ_DISC 0x9c /* 32b: RxExcessSizeDisc*/
+#define ROBO_MIB_RX_SYMBOL_ERROR 0xa0 /* 32b: RxSymbolError */
+
+/* BCM5350 MIB Statistics */
+/* Group 0 */
+#define ROBO_MIB_TX_GOOD_PKTS 0x00 /* 16b: TxGoodPkts */
+#define ROBO_MIB_TX_UNICAST_PKTS 0x02 /* 16b: TxUnicastPkts */
+#define ROBO_MIB_RX_GOOD_PKTS 0x04 /* 16b: RxGoodPkts */
+#define ROBO_MIB_RX_GOOD_UNICAST_PKTS 0x06 /* 16b: RxGoodUnicastPkts */
+/* Group 1 */
+#define ROBO_MIB_TX_COLLISION 0x00 /* 16b: TxCollision */
+#define ROBO_MIB_TX_OCTETS_5350 0x02 /* 16b: TxOctets */
+#define ROBO_MIB_RX_FCS_ERRORS_5350 0x04 /* 16b: RxFCSErrors */
+#define ROBO_MIB_RX_GOOD_OCTETS_5350 0x06 /* 16b: RxGoodOctets */
+
+/* BCM5325m QoS REGISTERS (Page 0x30) REGISTER MAP: 8/16 */
+#define ROBO_QOS_CTRL 0x00 /* 16b: QoS Control Register */
+#define ROBO_QOS_LOCAL_WEIGHT_CTRL 0x10 /* 8b: Local HQ/LQ Weight Register*/
+#define ROBO_QOS_CPU_WEIGHT_CTRL 0x12 /* 8b: CPU HQ/LQ Weight Register*/
+#define ROBO_QOS_PAUSE_ENA 0x13 /* 16b: Qos Pause Enable Register*/
+#define ROBO_QOS_PRIO_THRESHOLD 0x15 /* 8b: Priority Threshold Register*/
+#define ROBO_QOS_RESERVED 0x16 /* 8b: Qos Reserved Register */
+
+/* BCM5325m VLAN REGISTERS (Page 0x34) REGISTER MAP: 8/16bit */
+typedef struct _ROBO_VLAN_CTRL0_STRUC
+{
+ unsigned char frameControlP:2; /* 802.1P frame control */
+ unsigned char frameControlQ:2; /* 802.1Q frame control */
+ unsigned char dropMissedVID:1; /* enable drop missed VID packet */
+ unsigned char vidMacHash:1; /* VID_MAC hash enable */
+ unsigned char vidMacCheck:1; /* VID_MAC check enable */
+ unsigned char VLANen:1; /* 802.1Q VLAN enable */
+} ROBO_VLAN_CTRL0_STRUC;
+#define VLAN_TABLE_WRITE 1 /* for read/write state in table access reg */
+#define VLAN_TABLE_READ 0 /* for read/write state in table access reg */
+#define VLAN_ID_HIGH_BITS 0 /* static high bits in table access reg */
+#define VLAN_ID_MAX 15 /* max VLAN id (5350) */
+#define VLAN_ID_MAX_5365 255 /* max VLAN id */
+#define VLAN_ID_MAX_5395 4094 /* max VLAN id (5395) */
+#define VLAN_ID_MASK VLAN_ID_MAX /* VLAN id mask */
+#ifdef BCM5380
+#define VLAN_UNTAG_SHIFT 13 /* for postioning untag bits in write reg */
+#define VLAN_VALID 0x4000000 /* valid bit in write reg */
+#else
+#define VLAN_UNTAG_SHIFT 7 /* for postioning untag bits in write reg */
+#define VLAN_VALID 0x4000 /* valid bit in write reg */
+/* corresponding values for 5350 */
+#define VLAN_UNTAG_SHIFT_5350 6 /* for postioning untag bits in write reg */
+#define VLAN_VALID_5350 0x00100000 /* valid bit in write reg */
+#endif
+typedef struct _ROBO_VLAN_TABLE_ACCESS_STRUC
+{
+ unsigned char VLANid:8; /* VLAN ID (low 8 bits) */
+ unsigned char VLANidHi:4; /* VLAN ID (fixed upper portion) */
+ unsigned char readWriteState:1; /* read/write state (write = 1) */
+ volatile unsigned char readWriteEnable:1; /* table read/write enable */
+ unsigned char rsvd:2; /* reserved */
+} ROBO_VLAN_TABLE_ACCESS_STRUC;
+#ifdef BCM5380
+typedef struct _ROBO_VLAN_READ_WRITE_STRUC
+{
+ unsigned int VLANgroup:13;/* VLAN group mask */
+ unsigned int VLANuntag:13;/* VLAN untag enable mask */
+ unsigned char valid:1; /* valid */
+ unsigned char rsvd:5; /* reserved */
+} ROBO_VLAN_READ_WRITE_STRUC;
+#else
+typedef struct _ROBO_VLAN_READ_WRITE_STRUC
+{
+ unsigned char VLANgroup:7; /* VLAN group mask */
+ unsigned char VLANuntag:7; /* VLAN untag enable mask */
+ unsigned char valid:1; /* valid */
+ unsigned char rsvd:1; /* reserved */
+} ROBO_VLAN_READ_WRITE_STRUC;
+typedef struct _ROBO_VLAN_READ_WRITE_STRUC_5350
+{
+ unsigned char VLANgroup:6; /* VLAN group mask */
+ unsigned char VLANuntag:6; /* VLAN untag enable mask */
+ unsigned char highVID:8; /* upper bits of vid */
+ unsigned char valid:1; /* valid */
+ unsigned int rsvd:11; /* reserved */
+} ROBO_VLAN_READ_WRITE_STRUC_5350;
+#endif
+#define ROBO_VLAN_CTRL0 0x00 /* 8b: VLAN Control 0 Register */
+#define ROBO_VLAN_CTRL1 0x01 /* 8b: VLAN Control 1 Register */
+#define ROBO_VLAN_CTRL2 0x02 /* 8b: VLAN Control 2 Register */
+#define ROBO_VLAN_CTRL3 0x03 /* 8b: VLAN Control 3 Register */
+#define ROBO_VLAN_CTRL4 0x04 /* 8b: VLAN Control 4 Register */
+#define ROBO_VLAN_CTRL5 0x05 /* 8b: VLAN Control 5 Register */
+#define ROBO_VLAN_TABLE_ACCESS_5365 0x08 /* 14b: VLAN Table Access Register */
+#define ROBO_VLAN_TABLE_ACCESS 0x06 /* 14b: VLAN Table Access Register (5350) */
+#define ROBO_VLAN_WRITE_5365 0x0a /* 15b: VLAN Write Register */
+#define ROBO_VLAN_WRITE 0x08 /* 15b: VLAN Write Register (5350) */
+#define ROBO_VLAN_READ 0x0c /* 15b: VLAN Read Register */
+#define ROBO_VLAN_PORT0_DEF_TAG 0x10 /* 16b: VLAN Port 0 Default Tag Register */
+#define ROBO_VLAN_PORT1_DEF_TAG 0x12 /* 16b: VLAN Port 1 Default Tag Register */
+#define ROBO_VLAN_PORT2_DEF_TAG 0x14 /* 16b: VLAN Port 2 Default Tag Register */
+#define ROBO_VLAN_PORT3_DEF_TAG 0x16 /* 16b: VLAN Port 3 Default Tag Register */
+#define ROBO_VLAN_PORT4_DEF_TAG 0x18 /* 16b: VLAN Port 4 Default Tag Register */
+#define ROBO_VLAN_PORTMII_DEF_TAG 0x1a /* 16b: VLAN Port MII Default Tag Register */
+/* 5380 only */
+#define ROBO_VLAN_PORT5_DEF_TAG 0x1a /* 16b: VLAN Port 5 Default Tag Register */
+#define ROBO_VLAN_PORT6_DEF_TAG 0x1c /* 16b: VLAN Port 6 Default Tag Register */
+#define ROBO_VLAN_PORT7_DEF_TAG 0x1e /* 16b: VLAN Port 7 Default Tag Register */
+#define ROBO_VLAN_PORT8_DEF_TAG 0x20 /* 16b: VLAN Port 8 Default Tag Register */
+/* 53115 only */
+#define ROBO_DUPLEX_STAT_SUMMARY_53115 0x08 /* Duplex Status Summary: 16bit */
+#define ROBO_JUMBO_PAGE 0x40
+#define ROBO_JUMBO_CTRL 0x01 /* 32bit */
+#define ROBO_JUMBO_SIZE 0x05 /* 16bit */
+
+#ifndef _CFE_
+#pragma pack()
+#endif
+
+#endif /* !__BCM535M_H_ */
diff --git a/package/switch/src/gpio.h b/package/switch/src/gpio.h
new file mode 100644
index 0000000..cb734f7
--- /dev/null
+++ b/package/switch/src/gpio.h
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2006 OpenWrt.org
+ *
+ * This is free software, licensed under the GNU General Public License v2.
+ * See /LICENSE for more information.
+ */
+
+#ifndef __GPIO_H
+#define __GPIO_H
+
+#ifdef CONFIG_BCM47XX
+#include <linux/gpio.h>
+#else
+#warning "Unsupported configuration."
+
+#define bcm47xx_gpio_in(mask) (-1U)
+#define bcm47xx_gpio_out(mask, value) (-1U)
+#define bcm47xx_gpio_outen(mask, value) (-1U)
+#define bcm47xx_gpio_control(mask, value) (-1U)
+#define bcm47xx_gpio_intmask(mask, value) (-1U)
+#define bcm47xx_gpio_polarity(mask, value) (-1U)
+
+#endif
+
+#endif /* __GPIO_H */
diff --git a/package/switch/src/switch-adm.c b/package/switch/src/switch-adm.c
new file mode 100644
index 0000000..8c0ddc6
--- /dev/null
+++ b/package/switch/src/switch-adm.c
@@ -0,0 +1,596 @@
+/*
+ * ADMTEK Adm6996 switch configuration module
+ *
+ * Copyright (C) 2005 Felix Fietkau <nbd@nbd.name>
+ *
+ * Partially based on Broadcom Home Networking Division 10/100 Mbit/s
+ * Ethernet Device Driver (from Montavista 2.4.20_mvl31 Kernel).
+ * Copyright (C) 2004 Broadcom Corporation
+ *
+ * adm_rreg function from adm6996
+ * Copyright (C) 2004 Nikki Chumakov <nikki@gattaca.ru>
+ *
+ * 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
+ * of the License, 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; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/if.h>
+#include <linux/if_arp.h>
+#include <linux/sockios.h>
+#include <linux/delay.h>
+#include <asm/uaccess.h>
+
+#include "switch-core.h"
+#include "gpio.h"
+
+#ifdef CONFIG_BCM47XX
+#include <bcm47xx_nvram.h>
+#endif
+
+#define DRIVER_NAME "adm6996"
+#define DRIVER_VERSION "0.01"
+
+static int eecs = 0;
+static int eesk = 0;
+static int eedi = 0;
+static int eerc = 0;
+static int force = 0;
+
+MODULE_AUTHOR("Felix Fietkau <openwrt@nbd.name>");
+MODULE_LICENSE("GPL");
+module_param(eecs, int, 0);
+module_param(eesk, int, 0);
+module_param(eedi, int, 0);
+module_param(eerc, int, 0);
+module_param(force, int, 0);
+
+/* Minimum timing constants */
+#define EECK_EDGE_TIME 3 /* 3us - max(adm 2.5us, 93c 1us) */
+#define EEDI_SETUP_TIME 1 /* 1us - max(adm 10ns, 93c 400ns) */
+#define EECS_SETUP_TIME 1 /* 1us - max(adm no, 93c 200ns) */
+
+/* Handy macros for writing fixed length values */
+#define adm_write8(cs, b) { __u8 val = (__u8) (b); adm_write(cs, &val, sizeof(val)*8); }
+#define adm_write16(cs, w) { __u16 val = hton16(w); adm_write(cs, (__u8 *)&val, sizeof(val)*8); }
+#define adm_write32(cs, i) { uint32 val = hton32(i); adm_write(cs, (__u8 *)&val, sizeof(val)*8); }
+
+#define atoi(str) simple_strtoul(((str != NULL) ? str : ""), NULL, 0)
+
+#ifdef CONFIG_BCM47XX
+
+/* Return gpio pin number assigned to the named pin */
+/*
+* Variable should be in format:
+*
+* gpio<N>=pin_name
+*
+* 'def_pin' is returned if there is no such variable found.
+*/
+static unsigned int get_gpiopin(char *pin_name, unsigned int def_pin)
+{
+ char name[] = "gpioXXXX";
+ char val[10];
+ unsigned int pin;
+
+ /* Go thru all possibilities till a match in pin name */
+ for (pin = 0; pin < 16; pin ++) {
+ sprintf(name, "gpio%d", pin);
+ if (bcm47xx_nvram_getenv(name, val, sizeof(val)) >= 0) {
+ if (!strcmp(val, pin_name))
+ return pin;
+ }
+ }
+ return def_pin;
+}
+#endif
+
+
+static void adm_write(int cs, char *buf, unsigned int bits)
+{
+ int i, len = (bits + 7) / 8;
+ __u8 mask;
+
+ bcm47xx_gpio_out(eecs, (cs ? eecs : 0));
+ udelay(EECK_EDGE_TIME);
+
+ /* Byte assemble from MSB to LSB */
+ for (i = 0; i < len; i++) {
+ /* Bit bang from MSB to LSB */
+ for (mask = 0x80; mask && bits > 0; mask >>= 1, bits --) {
+ /* Clock low */
+ bcm47xx_gpio_out(eesk, 0);
+ udelay(EECK_EDGE_TIME);
+
+ /* Output on rising edge */
+ bcm47xx_gpio_out(eedi, ((mask & buf[i]) ? eedi : 0));
+ udelay(EEDI_SETUP_TIME);
+
+ /* Clock high */
+ bcm47xx_gpio_out(eesk, eesk);
+ udelay(EECK_EDGE_TIME);
+ }
+ }
+
+ /* Clock low */
+ bcm47xx_gpio_out(eesk, 0);
+ udelay(EECK_EDGE_TIME);
+
+ if (cs)
+ bcm47xx_gpio_out(eecs, 0);
+}
+
+
+static void adm_read(int cs, char *buf, unsigned int bits)
+{
+ int i, len = (bits + 7) / 8;
+ __u8 mask;
+
+ bcm47xx_gpio_out(eecs, (cs ? eecs : 0));
+ udelay(EECK_EDGE_TIME);
+
+ /* Byte assemble from MSB to LSB */
+ for (i = 0; i < len; i++) {
+ __u8 byte;
+
+ /* Bit bang from MSB to LSB */
+ for (mask = 0x80, byte = 0; mask && bits > 0; mask >>= 1, bits --) {
+ __u8 gp;
+
+ /* Clock low */
+ bcm47xx_gpio_out(eesk, 0);
+ udelay(EECK_EDGE_TIME);
+
+ /* Input on rising edge */
+ gp = bcm47xx_gpio_in(~0);
+ if (gp & eedi)
+ byte |= mask;
+
+ /* Clock high */
+ bcm47xx_gpio_out(eesk, eesk);
+ udelay(EECK_EDGE_TIME);
+ }
+
+ *buf++ = byte;
+ }
+
+ /* Clock low */
+ bcm47xx_gpio_out(eesk, 0);
+ udelay(EECK_EDGE_TIME);
+
+ if (cs)
+ bcm47xx_gpio_out(eecs, 0);
+}
+
+
+/* Enable outputs with specified value to the chip */
+static void adm_enout(__u8 pins, __u8 val)
+{
+ /* Prepare GPIO output value */
+ bcm47xx_gpio_out(pins, val);
+
+ /* Enable GPIO outputs */
+ bcm47xx_gpio_outen(pins, pins);
+ udelay(EECK_EDGE_TIME);
+}
+
+
+/* Disable outputs to the chip */
+static void adm_disout(__u8 pins)
+{
+ /* Disable GPIO outputs */
+ bcm47xx_gpio_outen(pins, 0);
+ udelay(EECK_EDGE_TIME);
+}
+
+
+/* Advance clock(s) */
+static void adm_adclk(int clocks)
+{
+ int i;
+ for (i = 0; i < clocks; i++) {
+ /* Clock high */
+ bcm47xx_gpio_out(eesk, eesk);
+ udelay(EECK_EDGE_TIME);
+
+ /* Clock low */
+ bcm47xx_gpio_out(eesk, 0);
+ udelay(EECK_EDGE_TIME);
+ }
+}
+
+static __u32 adm_rreg(__u8 table, __u8 addr)
+{
+ /* cmd: 01 10 T DD R RRRRRR */
+ __u8 bits[6] = {
+ 0xFF, 0xFF, 0xFF, 0xFF,
+ (0x06 << 4) | ((table & 0x01) << 3 | (addr&64)>>6),
+ ((addr&63)<<2)
+ };
+
+ __u8 rbits[4];
+
+ /* Enable GPIO outputs with all pins to 0 */
+ adm_enout((__u8)(eecs | eesk | eedi), 0);
+
+ adm_write(0, bits, 46);
+ adm_disout((__u8)(eedi));
+ adm_adclk(2);
+ adm_read (0, rbits, 32);
+
+ /* Extra clock(s) required per datasheet */
+ adm_adclk(2);
+
+ /* Disable GPIO outputs */
+ adm_disout((__u8)(eecs | eesk));
+
+ if (!table) /* EEPROM has 16-bit registers, but pumps out two registers in one request */
+ return (addr & 0x01 ? (rbits[0]<<8) | rbits[1] : (rbits[2]<<8) | (rbits[3]));
+ else
+ return (rbits[0]<<24) | (rbits[1]<<16) | (rbits[2]<<8) | rbits[3];
+}
+
+
+
+/* Write chip configuration register */
+/* Follow 93c66 timing and chip's min EEPROM timing requirement */
+void
+adm_wreg(__u8 addr, __u16 val)
+{
+ /* cmd(27bits): sb(1) + opc(01) + addr(bbbbbbbb) + data(bbbbbbbbbbbbbbbb) */
+ __u8 bits[4] = {
+ (0x05 << 5) | (addr >> 3),
+ (addr << 5) | (__u8)(val >> 11),
+ (__u8)(val >> 3),
+ (__u8)(val << 5)
+ };
+
+ /* Enable GPIO outputs with all pins to 0 */
+ adm_enout((__u8)(eecs | eesk | eedi), 0);
+
+ /* Write cmd. Total 27 bits */
+ adm_write(1, bits, 27);
+
+ /* Extra clock(s) required per datasheet */
+ adm_adclk(2);
+
+ /* Disable GPIO outputs */
+ adm_disout((__u8)(eecs | eesk | eedi));
+}
+
+
+/* Port configuration registers */
+static int port_conf[] = { 0x01, 0x03, 0x05, 0x07, 0x08, 0x09 };
+
+/* Bits in VLAN port mapping */
+static int vlan_ports[] = { 1 << 0, 1 << 2, 1 << 4, 1 << 6, 1 << 7, 1 << 8 };
+
+static int handle_vlan_port_read(void *driver, char *buf, int nr)
+{
+ int ports, i, c, len = 0;
+
+ if ((nr < 0) || (nr > 15))
+ return 0;
+
+ /* Get VLAN port map */
+ ports = adm_rreg(0, 0x13 + nr);
+
+ for (i = 0; i <= 5; i++) {
+ if (ports & vlan_ports[i]) {
+ c = adm_rreg(0, port_conf[i]);
+
+ len += sprintf(buf + len, "%d", i);
+ if (c & (1 << 4)) {
+ buf[len++] = 't';
+ if (((c & (0xf << 10)) >> 10) == nr)
+ buf[len++] = '*';
+ } else if (i == 5)
+ buf[len++] = 'u';
+
+ buf[len++] = '\t';
+ }
+ }
+ len += sprintf(buf + len, "\n");
+
+ return len;
+}
+
+static int handle_vlan_port_write(void *driver, char *buf, int nr)
+{
+ int i, cfg, ports;
+ switch_driver *d = (switch_driver *) driver;
+ switch_vlan_config *c = switch_parse_vlan(d, buf);
+
+ if (c == NULL)
+ return -1;
+
+ ports = adm_rreg(0, 0x13 + nr);
+ for (i = 0; i < d->ports; i++) {
+ if (c->port & (1 << i)) {
+ ports |= vlan_ports[i];
+
+ cfg = adm_rreg(0, port_conf[i]);
+
+ /* Tagging */
+ if (c->untag & (1 << i))
+ cfg &= ~(1 << 4);
+ else
+ cfg |= (1 << 4);
+
+ if ((c->untag | c->pvid) & (1 << i)) {
+ cfg = (cfg & ~(0xf << 10)) | (nr << 10);
+ }
+
+ adm_wreg(port_conf[i], (__u16) cfg);
+ } else {
+ ports &= ~(vlan_ports[i]);
+ }
+ }
+ adm_wreg(0x13 + nr, (__u16) ports);
+
+ kfree(c);
+ return 0;
+}
+
+static int handle_port_enable_read(void *driver, char *buf, int nr)
+{
+ return sprintf(buf, "%d\n", ((adm_rreg(0, port_conf[nr]) & (1 << 5)) ? 0 : 1));
+}
+
+static int handle_port_enable_write(void *driver, char *buf, int nr)
+{
+ int reg = adm_rreg(0, port_conf[nr]);
+
+ if (buf[0] == '0')
+ reg |= (1 << 5);
+ else if (buf[0] == '1')
+ reg &= ~(1 << 5);
+ else return -1;
+
+ adm_wreg(port_conf[nr], (__u16) reg);
+ return 0;
+}
+
+static int handle_port_media_read(void *driver, char *buf, int nr)
+{
+ int len;
+ int media = 0;
+ int reg = adm_rreg(0, port_conf[nr]);
+
+ if (reg & (1 << 1))
+ media |= SWITCH_MEDIA_AUTO;
+ if (reg & (1 << 2))
+ media |= SWITCH_MEDIA_100;
+ if (reg & (1 << 3))
+ media |= SWITCH_MEDIA_FD;
+
+ len = switch_print_media(buf, media);
+ return len + sprintf(buf + len, "\n");
+}
+
+static int handle_port_media_write(void *driver, char *buf, int nr)
+{
+ int media = switch_parse_media(buf);
+ int reg = adm_rreg(0, port_conf[nr]);
+
+ if (media < 0 || media & SWITCH_MEDIA_1000)
+ return -1;
+
+ reg &= ~((1 << 1) | (1 << 2) | (1 << 3));
+ if (media & SWITCH_MEDIA_AUTO)
+ reg |= 1 << 1;
+ if (media & SWITCH_MEDIA_100)
+ reg |= 1 << 2;
+ if (media & SWITCH_MEDIA_FD)
+ reg |= 1 << 3;
+
+ adm_wreg(port_conf[nr], reg);
+
+ return 0;
+}
+
+static int handle_vlan_enable_read(void *driver, char *buf, int nr)
+{
+ return sprintf(buf, "%d\n", ((adm_rreg(0, 0x11) & (1 << 5)) ? 1 : 0));
+}
+
+static int handle_vlan_enable_write(void *driver, char *buf, int nr)
+{
+ int reg = adm_rreg(0, 0x11);
+
+ if (buf[0] == '1')
+ reg |= (1 << 5);
+ else if (buf[0] == '0')
+ reg &= ~(1 << 5);
+ else return -1;
+
+ adm_wreg(0x11, (__u16) reg);
+ return 0;
+}
+
+static int handle_reset(void *driver, char *buf, int nr)
+{
+ int i;
+ u32 cfg;
+
+ /*
+ * Reset sequence: RC high->low(100ms)->high(30ms)
+ *
+ * WAR: Certain boards don't have the correct power on
+ * reset logic therefore we must explicitly perform the
+ * sequence in software.
+ */
+ if (eerc) {
+ /* Keep RC high for at least 20ms */
+ adm_enout(eerc, eerc);
+ for (i = 0; i < 20; i ++)
+ udelay(1000);
+ /* Keep RC low for at least 100ms */
+ adm_enout(eerc, 0);
+ for (i = 0; i < 100; i++)
+ udelay(1000);
+ /* Set default configuration */
+ adm_enout((__u8)(eesk | eedi), eesk);
+ /* Keep RC high for at least 30ms */
+ adm_enout(eerc, eerc);
+ for (i = 0; i < 30; i++)
+ udelay(1000);
+ /* Leave RC high and disable GPIO outputs */
+ adm_disout((__u8)(eecs | eesk | eedi));
+
+ }
+
+ /* set up initial configuration for cpu port */
+ cfg = (0x8000 | /* Auto MDIX */
+ (0xf << 10) | /* PVID */
+ (1 << 4) | /* Tagging */
+ 0xf); /* full duplex, 100Mbps, auto neg, flow ctrl */
+ adm_wreg(port_conf[5], cfg);
+
+ /* vlan mode select register (0x11): vlan on, mac clone */
+ adm_wreg(0x11, 0xff30);
+
+ return 0;
+}
+
+static int handle_registers(void *driver, char *buf, int nr)
+{
+ int i, len = 0;
+
+ for (i = 0; i <= 0x33; i++) {
+ len += sprintf(buf + len, "0x%02x: 0x%04x\n", i, adm_rreg(0, i));
+ }
+
+ return len;
+}
+
+static int handle_counters(void *driver, char *buf, int nr)
+{
+ int i, len = 0;
+
+ for (i = 0; i <= 0x3c; i++) {
+ len += sprintf(buf + len, "0x%02x: 0x%08x\n", i, adm_rreg(1, i));
+ }
+
+ return len;
+}
+
+static int detect_adm(void)
+{
+ int ret = 0;
+
+#ifdef CONFIG_BCM47XX
+ char buf[20];
+ int boardflags = 0;
+ int boardnum = 0;
+
+ if (bcm47xx_nvram_getenv("boardflags", buf, sizeof(buf)) >= 0)
+ boardflags = simple_strtoul(buf, NULL, 0);
+
+ if (bcm47xx_nvram_getenv("boardnum", buf, sizeof(buf)) >= 0)
+ boardnum = simple_strtoul(buf, NULL, 0);
+
+ if ((boardnum == 44) && (boardflags == 0x0388)) { /* Trendware TEW-411BRP+ */
+ ret = 1;
+
+ eecs = get_gpiopin("adm_eecs", 2);
+ eesk = get_gpiopin("adm_eesk", 3);
+ eedi = get_gpiopin("adm_eedi", 4);
+ eerc = get_gpiopin("adm_rc", 5);
+
+ } else if ((boardflags & 0x80) || force) {
+ ret = 1;
+
+ eecs = get_gpiopin("adm_eecs", 2);
+ eesk = get_gpiopin("adm_eesk", 3);
+ eedi = get_gpiopin("adm_eedi", 4);
+ eerc = get_gpiopin("adm_rc", 0);
+
+ } else if (bcm47xx_nvram_getenv("boardtype", buf, sizeof(buf)) >= 0) {
+ if (strcmp(buf, "bcm94710dev") == 0) {
+ if (bcm47xx_nvram_getenv("boardnum", buf, sizeof(buf)) >= 0) {
+ if (strncmp(buf, "42", 2) == 0) {
+ /* WRT54G v1.1 hack */
+ eecs = 2;
+ eesk = 3;
+ eedi = 5;
+
+ ret = 1;
+ }
+ }
+ }
+ }
+
+ if (eecs)
+ eecs = (1 << eecs);
+ if (eesk)
+ eesk = (1 << eesk);
+ if (eedi)
+ eedi = (1 << eedi);
+ if (eerc)
+ eerc = (1 << eerc);
+#else
+ ret = 1;
+#endif
+
+ return ret;
+}
+
+static int __init adm_init(void)
+{
+ switch_config cfg[] = {
+ {"registers", handle_registers, NULL},
+ {"counters", handle_counters, NULL},
+ {"reset", NULL, handle_reset},
+ {"enable_vlan", handle_vlan_enable_read, handle_vlan_enable_write},
+ {NULL, NULL, NULL}
+ };
+ switch_config port[] = {
+ {"enable", handle_port_enable_read, handle_port_enable_write},
+ {"media", handle_port_media_read, handle_port_media_write},
+ {NULL, NULL, NULL}
+ };
+ switch_config vlan[] = {
+ {"ports", handle_vlan_port_read, handle_vlan_port_write},
+ {NULL, NULL, NULL}
+ };
+ switch_driver driver = {
+ name: DRIVER_NAME,
+ version: DRIVER_VERSION,
+ interface: "eth0",
+ ports: 6,
+ cpuport: 5,
+ vlans: 16,
+ driver_handlers: cfg,
+ port_handlers: port,
+ vlan_handlers: vlan,
+ };
+ snprintf(driver.dev_name, SWITCH_NAME_BUFSZ, DRIVER_NAME);
+
+ if (!detect_adm())
+ return -ENODEV;
+
+ return switch_register_driver(&driver);
+}
+
+static void __exit adm_exit(void)
+{
+ switch_unregister_driver(DRIVER_NAME);
+}
+
+
+module_init(adm_init);
+module_exit(adm_exit);
diff --git a/package/switch/src/switch-core.c b/package/switch/src/switch-core.c
new file mode 100644
index 0000000..fc8a6bf
--- /dev/null
+++ b/package/switch/src/switch-core.c
@@ -0,0 +1,527 @@
+/*
+ * switch-core.c
+ *
+ * Copyright (C) 2005 Felix Fietkau <openwrt@nbd.name>
+ *
+ * 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
+ * of the License, 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ *
+ * Basic doc of driver's /proc interface:
+ * /proc/switch/<interface>/
+ * registers: read-only
+ * counters: read-only
+ * reset: write causes hardware reset
+ * enable_vlan: "0", "1"
+ * port/<port-number>/
+ * enabled: "0", "1"
+ * media: "AUTO", "1000FD", "1000HD", "100FD", "100HD", "10FD", "10HD"
+ * vlan/<port-number>/
+ * ports: same syntax as for nvram's vlan*ports (eg. "1 2 3 4 5*")
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <asm/uaccess.h>
+#include <linux/proc_fs.h>
+#include <linux/list.h>
+
+#include "switch-core.h"
+
+static int drv_num = 0;
+static struct proc_dir_entry *switch_root;
+switch_driver drivers;
+
+typedef struct {
+ struct list_head list;
+ struct proc_dir_entry *parent;
+ int nr;
+ void *driver;
+ switch_config handler;
+} switch_proc_handler;
+
+typedef struct {
+ struct proc_dir_entry *driver_dir, *port_dir, *vlan_dir;
+ struct proc_dir_entry **ports, **vlans;
+ switch_proc_handler data;
+ int nr;
+} switch_priv;
+
+static ssize_t switch_proc_read(struct file *file, char *buf, size_t count, loff_t *ppos);
+static ssize_t switch_proc_write(struct file *file, const char *buf, size_t count, void *data);
+
+static struct file_operations switch_proc_fops = {
+ .read = (ssize_t (*) (struct file *, char __user *, size_t, loff_t *))switch_proc_read,
+ .write = (ssize_t (*) (struct file *, const char __user *, size_t, loff_t *))switch_proc_write
+};
+
+static ssize_t switch_proc_read(struct file *file, char *buf, size_t count, loff_t *ppos)
+{
+ struct proc_dir_entry *dent = PDE(file->f_dentry->d_inode);
+ char *page;
+ int len = 0;
+
+ if ((page = kmalloc(SWITCH_MAX_BUFSZ, GFP_KERNEL)) == NULL)
+ return -ENOBUFS;
+
+ if (dent->data != NULL) {
+ switch_proc_handler *handler = (switch_proc_handler *) dent->data;
+ if (handler->handler.read != NULL)
+ len += handler->handler.read(handler->driver, page + len, handler->nr);
+ }
+ len += 1;
+
+ if (*ppos < len) {
+ len = min_t(int, len - *ppos, count);
+ if (copy_to_user(buf, (page + *ppos), len)) {
+ kfree(page);
+ return -EFAULT;
+ }
+ *ppos += len;
+ } else {
+ len = 0;
+ }
+
+ kfree(page);
+ return len;
+}
+
+
+static ssize_t switch_proc_write(struct file *file, const char *buf, size_t count, void *data)
+{
+ struct proc_dir_entry *dent = PDE(file->f_dentry->d_inode);
+ char *page;
+ int ret = -EINVAL;
+
+ if ((page = kmalloc(count + 1, GFP_KERNEL)) == NULL)
+ return -ENOBUFS;
+
+ if (copy_from_user(page, buf, count)) {
+ kfree(page);
+ return -EINVAL;
+ }
+ page[count] = 0;
+
+ if (dent->data != NULL) {
+ switch_proc_handler *handler = (switch_proc_handler *) dent->data;
+ if (handler->handler.write != NULL) {
+ if ((ret = handler->handler.write(handler->driver, page, handler->nr)) >= 0)
+ ret = count;
+ }
+ }
+
+ kfree(page);
+ return ret;
+}
+
+static int handle_driver_name(void *driver, char *buf, int nr)
+{
+ const char *name = ((switch_driver *) driver)->name;
+ return sprintf(buf, "%s\n", name);
+}
+
+static int handle_driver_version(void *driver, char *buf, int nr)
+{
+ const char *version = ((switch_driver *) driver)->version;
+ strcpy(buf, version);
+ return sprintf(buf, "%s\n", version);
+}
+
+static int handle_driver_cpuport(void *driver, char *buf, int nr)
+{
+ int cpuport = ((switch_driver *) driver)->cpuport;
+ return sprintf(buf, "%i\n", cpuport);
+}
+
+static int handle_driver_ports(void *driver, char *buf, int nr)
+{
+ int ports = ((switch_driver *) driver)->ports;
+ return sprintf(buf, "%i\n", ports);
+}
+
+static int handle_driver_vlans(void *driver, char *buf, int nr)
+{
+ int vlans = ((switch_driver *) driver)->vlans;
+ return sprintf(buf, "%i\n", vlans);
+}
+
+static int handle_driver_dev_name(void *driver, char *buf, int nr)
+{
+ char *dev_name = ((switch_driver *) driver)->dev_name;
+ return sprintf(buf, "%s\n", dev_name);
+}
+
+static void add_handler(switch_driver *driver, const switch_config *handler, struct proc_dir_entry *parent, int nr)
+{
+ switch_priv *priv = (switch_priv *) driver->data;
+ struct proc_dir_entry *p;
+ int mode;
+
+ switch_proc_handler *tmp;
+ tmp = (switch_proc_handler *) kmalloc(sizeof(switch_proc_handler), GFP_KERNEL);
+ if (!tmp)
+ return;
+ INIT_LIST_HEAD(&tmp->list);
+ tmp->parent = parent;
+ tmp->nr = nr;
+ tmp->driver = driver;
+ memcpy(&tmp->handler, handler, sizeof(switch_config));
+ list_add(&tmp->list, &priv->data.list);
+
+ mode = 0;
+ if (handler->read != NULL) mode |= S_IRUSR;
+ if (handler->write != NULL) mode |= S_IWUSR;
+
+ if ((p = create_proc_entry(handler->name, mode, parent)) != NULL) {
+ p->data = (void *) tmp;
+ p->proc_fops = &switch_proc_fops;
+ }
+}
+
+static inline void add_handlers(switch_driver *driver, const switch_config *handlers, struct proc_dir_entry *parent, int nr)
+{
+ int i;
+
+ for (i = 0; handlers[i].name != NULL; i++) {
+ add_handler(driver, &(handlers[i]), parent, nr);
+ }
+}
+
+static void remove_handlers(switch_priv *priv)
+{
+ struct list_head *pos, *q;
+ switch_proc_handler *tmp;
+
+ list_for_each_safe(pos, q, &priv->data.list) {
+ tmp = list_entry(pos, switch_proc_handler, list);
+ list_del(pos);
+ remove_proc_entry(tmp->handler.name, tmp->parent);
+ kfree(tmp);
+ }
+}
+
+
+static void do_unregister(switch_driver *driver)
+{
+ char buf[4];
+ int i;
+ switch_priv *priv = (switch_priv *) driver->data;
+
+ remove_handlers(priv);
+
+ for(i = 0; priv->ports[i] != NULL; i++) {
+ sprintf(buf, "%d", i);
+ remove_proc_entry(buf, priv->port_dir);
+ }
+ kfree(priv->ports);
+ remove_proc_entry("port", priv->driver_dir);
+
+ for(i = 0; priv->vlans[i] != NULL; i++) {
+ sprintf(buf, "%d", i);
+ remove_proc_entry(buf, priv->vlan_dir);
+ }
+ kfree(priv->vlans);
+ remove_proc_entry("vlan", priv->driver_dir);
+
+ remove_proc_entry(driver->interface, switch_root);
+
+ if (priv->nr == (drv_num - 1))
+ drv_num--;
+
+ kfree(priv);
+}
+
+switch_config global_driver_handlers[] = {
+ {"driver", handle_driver_name, NULL},
+ {"version", handle_driver_version, NULL},
+ {"cpuport", handle_driver_cpuport, NULL},
+ {"ports", handle_driver_ports, NULL},
+ {"vlans", handle_driver_vlans, NULL},
+ {"dev_name", handle_driver_dev_name, NULL},
+ {NULL, NULL, NULL}
+};
+
+static int do_register(switch_driver *driver)
+{
+ switch_priv *priv;
+ int i;
+ char buf[4];
+
+ priv = kmalloc(sizeof(switch_priv), GFP_KERNEL);
+ if (!priv)
+ return -ENOMEM;
+ driver->data = (void *) priv;
+
+ priv->ports = kmalloc((driver->ports + 1) * sizeof(struct proc_dir_entry *),
+ GFP_KERNEL);
+ if (!priv->ports) {
+ kfree(priv);
+ return -ENOMEM;
+ }
+ priv->vlans = kmalloc((driver->vlans + 1) * sizeof(struct proc_dir_entry *),
+ GFP_KERNEL);
+ if (!priv->vlans) {
+ kfree(priv->ports);
+ kfree(priv);
+ return -ENOMEM;
+ }
+
+ INIT_LIST_HEAD(&priv->data.list);
+
+ priv->nr = drv_num++;
+ priv->driver_dir = proc_mkdir(driver->interface, switch_root);
+ if (driver->driver_handlers != NULL) {
+ add_handlers(driver, driver->driver_handlers, priv->driver_dir, 0);
+ add_handlers(driver, global_driver_handlers, priv->driver_dir, 0);
+ }
+
+ priv->port_dir = proc_mkdir("port", priv->driver_dir);
+ for (i = 0; i < driver->ports; i++) {
+ sprintf(buf, "%d", i);
+ priv->ports[i] = proc_mkdir(buf, priv->port_dir);
+ if (driver->port_handlers != NULL)
+ add_handlers(driver, driver->port_handlers, priv->ports[i], i);
+ }
+ priv->ports[i] = NULL;
+
+ priv->vlan_dir = proc_mkdir("vlan", priv->driver_dir);
+ for (i = 0; i < driver->vlans; i++) {
+ sprintf(buf, "%d", i);
+ priv->vlans[i] = proc_mkdir(buf, priv->vlan_dir);
+ if (driver->vlan_handlers != NULL)
+ add_handlers(driver, driver->vlan_handlers, priv->vlans[i], i);
+ }
+ priv->vlans[i] = NULL;
+
+
+ return 0;
+}
+
+static inline int isspace(char c) {
+ switch(c) {
+ case ' ':
+ case 0x09:
+ case 0x0a:
+ case 0x0d:
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+#define toupper(c) (islower(c) ? ((c) ^ 0x20) : (c))
+#define islower(c) (((unsigned char)((c) - 'a')) < 26)
+
+int switch_parse_media(char *buf)
+{
+ char *str = buf;
+ while (*buf != 0) {
+ *buf = toupper(*buf);
+ buf++;
+ }
+
+ if (strncmp(str, "AUTO", 4) == 0)
+ return SWITCH_MEDIA_AUTO;
+ else if (strncmp(str, "1000FD", 6) == 0)
+ return SWITCH_MEDIA_1000 | SWITCH_MEDIA_FD;
+ else if (strncmp(str, "1000HD", 6) == 0)
+ return SWITCH_MEDIA_1000;
+ else if (strncmp(str, "100FD", 5) == 0)
+ return SWITCH_MEDIA_100 | SWITCH_MEDIA_FD;
+ else if (strncmp(str, "100HD", 5) == 0)
+ return SWITCH_MEDIA_100;
+ else if (strncmp(str, "10FD", 4) == 0)
+ return SWITCH_MEDIA_FD;
+ else if (strncmp(str, "10HD", 4) == 0)
+ return 0;
+ else return -1;
+}
+
+int switch_print_media(char *buf, int media)
+{
+ int len = 0;
+
+ if (media & SWITCH_MEDIA_AUTO)
+ len = sprintf(buf, "Auto");
+ else if (media == (SWITCH_MEDIA_1000 | SWITCH_MEDIA_FD))
+ len = sprintf(buf, "1000FD");
+ else if (media == SWITCH_MEDIA_1000)
+ len = sprintf(buf, "1000HD");
+ else if (media == (SWITCH_MEDIA_100 | SWITCH_MEDIA_FD))
+ len = sprintf(buf, "100FD");
+ else if (media == SWITCH_MEDIA_100)
+ len = sprintf(buf, "100HD");
+ else if (media == SWITCH_MEDIA_FD)
+ len = sprintf(buf, "10FD");
+ else if (media == 0)
+ len = sprintf(buf, "10HD");
+ else
+ len = sprintf(buf, "Invalid");
+
+ return len;
+}
+
+switch_vlan_config *switch_parse_vlan(switch_driver *driver, char *buf)
+{
+ switch_vlan_config *c;
+ int j, u, p, s;
+
+ c = kzalloc(sizeof(switch_vlan_config), GFP_KERNEL);
+ if (!c)
+ return NULL;
+
+ while (isspace(*buf)) buf++;
+ j = 0;
+ while (*buf >= '0' && *buf <= '9') {
+ j *= 10;
+ j += *buf++ - '0';
+
+ u = ((j == driver->cpuport) ? 0 : 1);
+ p = 0;
+ s = !(*buf >= '0' && *buf <= '9');
+
+ if (s) {
+ while (s && !isspace(*buf) && (*buf != 0)) {
+ switch(*buf) {
+ case 'u':
+ u = 1;
+ break;
+ case 't':
+ u = 0;
+ break;
+ case '*':
+ p = 1;
+ break;
+ }
+ buf++;
+ }
+ c->port |= (1 << j);
+ if (u)
+ c->untag |= (1 << j);
+ if (p)
+ c->pvid |= (1 << j);
+
+ j = 0;
+ }
+
+ while (isspace(*buf)) buf++;
+ }
+ if (*buf != 0) {
+ kfree(c);
+ return NULL;
+ }
+
+ c->port &= (1 << driver->ports) - 1;
+ c->untag &= (1 << driver->ports) - 1;
+ c->pvid &= (1 << driver->ports) - 1;
+
+ return c;
+}
+
+
+int switch_device_registered (char* device) {
+ struct list_head *pos;
+
+ list_for_each(pos, &drivers.list) {
+ if (strcmp(list_entry(pos, switch_driver, list)->interface, device) == 0) {
+ printk("There is already a switch registered on the device '%s'\n", device);
+ return -EINVAL;
+ }
+ }
+
+ return 0;
+}
+
+
+int switch_register_driver(switch_driver *driver)
+{
+ struct list_head *pos;
+ switch_driver *new;
+ int ret;
+
+ list_for_each(pos, &drivers.list) {
+ if (strcmp(list_entry(pos, switch_driver, list)->name, driver->name) == 0) {
+ printk("Switch driver '%s' already exists in the kernel\n", driver->name);
+ return -EINVAL;
+ }
+ if (strcmp(list_entry(pos, switch_driver, list)->interface, driver->interface) == 0) {
+ printk("There is already a switch registered on the device '%s'\n", driver->interface);
+ return -EINVAL;
+ }
+ }
+
+ new = kmalloc(sizeof(switch_driver), GFP_KERNEL);
+ if (!new)
+ return -ENOMEM;
+ memcpy(new, driver, sizeof(switch_driver));
+ new->name = strdup(driver->name);
+ new->interface = strdup(driver->interface);
+
+ if ((ret = do_register(new)) < 0) {
+ kfree(new->name);
+ kfree(new);
+ return ret;
+ }
+ INIT_LIST_HEAD(&new->list);
+ list_add(&new->list, &drivers.list);
+
+ return 0;
+}
+
+void switch_unregister_driver(char *name) {
+ struct list_head *pos, *q;
+ switch_driver *tmp;
+
+ list_for_each_safe(pos, q, &drivers.list) {
+ tmp = list_entry(pos, switch_driver, list);
+ if (strcmp(tmp->name, name) == 0) {
+ do_unregister(tmp);
+ list_del(pos);
+ kfree(tmp->name);
+ kfree(tmp);
+
+ return;
+ }
+ }
+}
+
+static int __init switch_init(void)
+{
+ if ((switch_root = proc_mkdir("switch", NULL)) == NULL) {
+ printk("%s: proc_mkdir failed.\n", __FILE__);
+ return -ENODEV;
+ }
+
+ INIT_LIST_HEAD(&drivers.list);
+
+ return 0;
+}
+
+static void __exit switch_exit(void)
+{
+ remove_proc_entry("switch", NULL);
+}
+
+MODULE_AUTHOR("Felix Fietkau <openwrt@nbd.name>");
+MODULE_LICENSE("GPL");
+
+EXPORT_SYMBOL(switch_device_registered);
+EXPORT_SYMBOL(switch_register_driver);
+EXPORT_SYMBOL(switch_unregister_driver);
+EXPORT_SYMBOL(switch_parse_vlan);
+EXPORT_SYMBOL(switch_parse_media);
+EXPORT_SYMBOL(switch_print_media);
+
+module_init(switch_init);
+module_exit(switch_exit);
diff --git a/package/switch/src/switch-core.h b/package/switch/src/switch-core.h
new file mode 100644
index 0000000..cc520e4
--- /dev/null
+++ b/package/switch/src/switch-core.h
@@ -0,0 +1,55 @@
+#ifndef __SWITCH_CORE_H
+#define __SWITCH_CORE_H
+
+#include <linux/version.h>
+#include <linux/list.h>
+#define SWITCH_MAX_BUFSZ 4096
+#define SWITCH_NAME_BUFSZ 16
+
+#define SWITCH_MEDIA_AUTO 1
+#define SWITCH_MEDIA_100 2
+#define SWITCH_MEDIA_FD 4
+#define SWITCH_MEDIA_1000 8
+
+typedef int (*switch_handler)(void *driver, char *buf, int nr);
+
+typedef struct {
+ const char *name;
+ switch_handler read, write;
+} switch_config;
+
+typedef struct {
+ struct list_head list;
+ const char *name;
+ const char *version;
+ const char *interface;
+ int cpuport;
+ int ports;
+ int vlans;
+ const switch_config *driver_handlers, *port_handlers, *vlan_handlers;
+ void *data;
+ void *priv;
+ char dev_name[SWITCH_NAME_BUFSZ];
+} switch_driver;
+
+typedef struct {
+ u32 port, untag, pvid;
+} switch_vlan_config;
+
+
+extern int switch_device_registered (char* device);
+extern int switch_register_driver(switch_driver *driver);
+extern void switch_unregister_driver(char *name);
+extern switch_vlan_config *switch_parse_vlan(switch_driver *driver, char *buf);
+extern int switch_parse_media(char *buf);
+extern int switch_print_media(char *buf, int media);
+
+static inline char *strdup(const char *str)
+{
+ char *new = kmalloc(strlen(str) + 1, GFP_KERNEL);
+ strcpy(new, str);
+ return new;
+}
+
+
+#endif
diff --git a/package/switch/src/switch-robo.c b/package/switch/src/switch-robo.c
new file mode 100644
index 0000000..f715972
--- /dev/null
+++ b/package/switch/src/switch-robo.c
@@ -0,0 +1,892 @@
+/*
+ * Broadcom BCM5325E/536x switch configuration module
+ *
+ * Copyright (C) 2005 Felix Fietkau <nbd@nbd.name>
+ * Copyright (C) 2008 Michael Buesch <mb@bu3sch.de>
+ * Copyright (C) 2013 Hauke Mehrtens <hauke@hauke-m.de>
+ * Based on 'robocfg' by Oleg I. Vdovikin
+ *
+ * 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
+ * of the License, 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; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/if.h>
+#include <linux/if_arp.h>
+#include <linux/sockios.h>
+#include <linux/ethtool.h>
+#include <linux/mii.h>
+#include <linux/delay.h>
+#include <linux/gpio.h>
+#include <asm/uaccess.h>
+
+#include "switch-core.h"
+#include "etc53xx.h"
+
+#ifdef CONFIG_BCM47XX
+#include <bcm47xx_nvram.h>
+#endif
+
+#define DRIVER_NAME "bcm53xx"
+#define DRIVER_VERSION "0.03"
+#define PFX "roboswitch: "
+
+#define ROBO_PHY_ADDR 0x1E /* robo switch phy address */
+#define ROBO_PHY_ADDR_TG3 0x01 /* Tigon3 PHY address */
+#define ROBO_PHY_ADDR_BCM63XX 0x00 /* BCM63XX PHY address */
+
+/* MII registers */
+#define REG_MII_PAGE 0x10 /* MII Page register */
+#define REG_MII_ADDR 0x11 /* MII Address register */
+#define REG_MII_DATA0 0x18 /* MII Data register 0 */
+
+#define REG_MII_PAGE_ENABLE 1
+#define REG_MII_ADDR_WRITE 1
+#define REG_MII_ADDR_READ 2
+
+/* Robo device ID register (in ROBO_MGMT_PAGE) */
+#define ROBO_DEVICE_ID 0x30
+#define ROBO_DEVICE_ID_5325 0x25 /* Faked */
+#define ROBO_DEVICE_ID_5395 0x95
+#define ROBO_DEVICE_ID_5397 0x97
+#define ROBO_DEVICE_ID_5398 0x98
+#define ROBO_DEVICE_ID_53115 0x3115
+#define ROBO_DEVICE_ID_53125 0x3125
+
+/* Private et.o ioctls */
+#define SIOCGETCPHYRD (SIOCDEVPRIVATE + 9)
+#define SIOCSETCPHYWR (SIOCDEVPRIVATE + 10)
+
+/* Data structure for a Roboswitch device. */
+struct robo_switch {
+ char *device; /* The device name string (ethX) */
+ u16 devid; /* ROBO_DEVICE_ID_53xx */
+ bool is_5365;
+ bool gmii; /* gigabit mii */
+ u8 corerev;
+ int gpio_robo_reset;
+ int gpio_lanports_enable;
+ struct ifreq ifr;
+ struct net_device *dev;
+ unsigned char port[9];
+};
+
+/* Currently we can only have one device in the system. */
+static struct robo_switch robo;
+
+
+static int do_ioctl(int cmd)
+{
+ mm_segment_t old_fs = get_fs();
+ int ret;
+
+ set_fs(KERNEL_DS);
+ ret = robo.dev->netdev_ops->ndo_do_ioctl(robo.dev, &robo.ifr, cmd);
+ set_fs(old_fs);
+
+ return ret;
+}
+
+static u16 mdio_read(__u16 phy_id, __u8 reg)
+{
+ struct mii_ioctl_data *mii = if_mii(&robo.ifr);
+ int err;
+
+ mii->phy_id = phy_id;
+ mii->reg_num = reg;
+
+ err = do_ioctl(SIOCGMIIREG);
+ if (err < 0) {
+ printk(KERN_ERR PFX "failed to read mdio reg %i with err %i.\n", reg, err);
+
+ return 0xffff;
+ }
+
+ return mii->val_out;
+}
+
+static void mdio_write(__u16 phy_id, __u8 reg, __u16 val)
+{
+ struct mii_ioctl_data *mii = if_mii(&robo.ifr);
+ int err;
+
+ mii->phy_id = phy_id;
+ mii->reg_num = reg;
+ mii->val_in = val;
+
+ err = do_ioctl(SIOCSMIIREG);
+ if (err < 0) {
+ printk(KERN_ERR PFX "failed to write mdio reg: %i with err %i.\n", reg, err);
+ return;
+ }
+}
+
+static int robo_reg(__u8 page, __u8 reg, __u8 op)
+{
+ int i = 3;
+
+ /* set page number */
+ mdio_write(ROBO_PHY_ADDR, REG_MII_PAGE,
+ (page << 8) | REG_MII_PAGE_ENABLE);
+
+ /* set register address */
+ mdio_write(ROBO_PHY_ADDR, REG_MII_ADDR,
+ (reg << 8) | op);
+
+ /* check if operation completed */
+ while (i--) {
+ if ((mdio_read(ROBO_PHY_ADDR, REG_MII_ADDR) & 3) == 0)
+ return 0;
+ }
+
+ printk(KERN_ERR PFX "timeout in robo_reg on page %i and reg %i with op %i.\n", page, reg, op);
+
+ return 1;
+}
+
+/*
+static void robo_read(__u8 page, __u8 reg, __u16 *val, int count)
+{
+ int i;
+
+ robo_reg(page, reg, REG_MII_ADDR_READ);
+
+ for (i = 0; i < count; i++)
+ val[i] = mdio_read(ROBO_PHY_ADDR, REG_MII_DATA0 + i);
+}
+*/
+
+static __u16 robo_read16(__u8 page, __u8 reg)
+{
+ robo_reg(page, reg, REG_MII_ADDR_READ);
+
+ return mdio_read(ROBO_PHY_ADDR, REG_MII_DATA0);
+}
+
+static __u32 robo_read32(__u8 page, __u8 reg)
+{
+ robo_reg(page, reg, REG_MII_ADDR_READ);
+
+ return mdio_read(ROBO_PHY_ADDR, REG_MII_DATA0) |
+ (mdio_read(ROBO_PHY_ADDR, REG_MII_DATA0 + 1) << 16);
+}
+
+static void robo_write16(__u8 page, __u8 reg, __u16 val16)
+{
+ /* write data */
+ mdio_write(ROBO_PHY_ADDR, REG_MII_DATA0, val16);
+
+ robo_reg(page, reg, REG_MII_ADDR_WRITE);
+}
+
+static void robo_write32(__u8 page, __u8 reg, __u32 val32)
+{
+ /* write data */
+ mdio_write(ROBO_PHY_ADDR, REG_MII_DATA0, val32 & 0xFFFF);
+ mdio_write(ROBO_PHY_ADDR, REG_MII_DATA0 + 1, val32 >> 16);
+
+ robo_reg(page, reg, REG_MII_ADDR_WRITE);
+}
+
+/* checks that attached switch is 5365 */
+static bool robo_bcm5365(void)
+{
+ /* set vlan access id to 15 and read it back */
+ __u16 val16 = 15;
+ robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS, val16);
+
+ /* 5365 will refuse this as it does not have this reg */
+ return robo_read16(ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS) != val16;
+}
+
+static bool robo_gmii(void)
+{
+ if (mdio_read(0, ROBO_MII_STAT) & 0x0100)
+ return ((mdio_read(0, 0x0f) & 0xf000) != 0);
+ return false;
+}
+
+static int robo_switch_enable(void)
+{
+ unsigned int i, last_port;
+ u16 val;
+#ifdef CONFIG_BCM47XX
+ char buf[20];
+#endif
+
+ val = robo_read16(ROBO_CTRL_PAGE, ROBO_SWITCH_MODE);
+ if (!(val & (1 << 1))) {
+ /* Unmanaged mode */
+ val &= ~(1 << 0);
+ /* With forwarding */
+ val |= (1 << 1);
+ robo_write16(ROBO_CTRL_PAGE, ROBO_SWITCH_MODE, val);
+ val = robo_read16(ROBO_CTRL_PAGE, ROBO_SWITCH_MODE);
+ if (!(val & (1 << 1))) {
+ printk(KERN_ERR PFX "Failed to enable switch\n");
+ return -EBUSY;
+ }
+
+ /* No spanning tree for unmanaged mode */
+ last_port = (robo.devid == ROBO_DEVICE_ID_5398) ?
+ ROBO_PORT7_CTRL : ROBO_PORT4_CTRL;
+ for (i = ROBO_PORT0_CTRL; i <= last_port; i++)
+ robo_write16(ROBO_CTRL_PAGE, i, 0);
+
+ /* No spanning tree on IMP port too */
+ robo_write16(ROBO_CTRL_PAGE, ROBO_IM_PORT_CTRL, 0);
+ }
+
+ if (robo.devid == ROBO_DEVICE_ID_53125) {
+ /* Make IM port status link by default */
+ val = robo_read16(ROBO_CTRL_PAGE, ROBO_PORT_OVERRIDE_CTRL) | 0xb1;
+ robo_write16(ROBO_CTRL_PAGE, ROBO_PORT_OVERRIDE_CTRL, val);
+ // TODO: init EEE feature
+ }
+
+#ifdef CONFIG_BCM47XX
+ /* WAN port LED, except for Netgear WGT634U */
+ if (bcm47xx_nvram_getenv("nvram_type", buf, sizeof(buf)) >= 0) {
+ if (strcmp(buf, "cfe") != 0)
+ robo_write16(ROBO_CTRL_PAGE, 0x16, 0x1F);
+ }
+#endif
+ return 0;
+}
+
+static void robo_switch_reset(void)
+{
+ if ((robo.devid == ROBO_DEVICE_ID_5395) ||
+ (robo.devid == ROBO_DEVICE_ID_5397) ||
+ (robo.devid == ROBO_DEVICE_ID_5398)) {
+ /* Trigger a software reset. */
+ robo_write16(ROBO_CTRL_PAGE, 0x79, 0x83);
+ mdelay(500);
+ robo_write16(ROBO_CTRL_PAGE, 0x79, 0);
+ }
+}
+
+#ifdef CONFIG_BCM47XX
+static int get_gpio_pin(const char *name)
+{
+ int i, err;
+ char nvram_var[10];
+ char buf[30];
+
+ for (i = 0; i < 16; i++) {
+ err = snprintf(nvram_var, sizeof(nvram_var), "gpio%i", i);
+ if (err <= 0)
+ continue;
+ err = bcm47xx_nvram_getenv(nvram_var, buf, sizeof(buf));
+ if (err <= 0)
+ continue;
+ if (!strcmp(name, buf))
+ return i;
+ }
+ return -1;
+}
+#endif
+
+static int robo_probe(char *devname)
+{
+ __u32 phyid;
+ unsigned int i;
+ int err = -1;
+ struct mii_ioctl_data *mii;
+
+ printk(KERN_INFO PFX "Probing device '%s'\n", devname);
+ strcpy(robo.ifr.ifr_name, devname);
+
+ if ((robo.dev = dev_get_by_name(&init_net, devname)) == NULL) {
+ printk(KERN_ERR PFX "No such device\n");
+ err = -ENODEV;
+ goto err_done;
+ }
+ if (!robo.dev->netdev_ops || !robo.dev->netdev_ops->ndo_do_ioctl) {
+ printk(KERN_ERR PFX "ndo_do_ioctl not implemented in ethernet driver\n");
+ err = -ENXIO;
+ goto err_put;
+ }
+
+ robo.device = devname;
+
+ /* try access using MII ioctls - get phy address */
+ err = do_ioctl(SIOCGMIIPHY);
+ if (err < 0) {
+ printk(KERN_ERR PFX "error (%i) while accessing MII phy registers with ioctls\n", err);
+ goto err_put;
+ }
+
+ /* got phy address check for robo address */
+ mii = if_mii(&robo.ifr);
+ if ((mii->phy_id != ROBO_PHY_ADDR) &&
+ (mii->phy_id != ROBO_PHY_ADDR_BCM63XX) &&
+ (mii->phy_id != ROBO_PHY_ADDR_TG3)) {
+ printk(KERN_ERR PFX "Invalid phy address (%d)\n", mii->phy_id);
+ err = -ENODEV;
+ goto err_put;
+ }
+
+#ifdef CONFIG_BCM47XX
+ robo.gpio_lanports_enable = get_gpio_pin("lanports_enable");
+ if (robo.gpio_lanports_enable >= 0) {
+ err = gpio_request(robo.gpio_lanports_enable, "lanports_enable");
+ if (err) {
+ printk(KERN_ERR PFX "error (%i) requesting lanports_enable gpio (%i)\n",
+ err, robo.gpio_lanports_enable);
+ goto err_put;
+ }
+ gpio_direction_output(robo.gpio_lanports_enable, 1);
+ mdelay(5);
+ }
+
+ robo.gpio_robo_reset = get_gpio_pin("robo_reset");
+ if (robo.gpio_robo_reset >= 0) {
+ err = gpio_request(robo.gpio_robo_reset, "robo_reset");
+ if (err) {
+ printk(KERN_ERR PFX "error (%i) requesting robo_reset gpio (%i)\n",
+ err, robo.gpio_robo_reset);
+ goto err_gpio_robo;
+ }
+ gpio_set_value(robo.gpio_robo_reset, 0);
+ gpio_direction_output(robo.gpio_robo_reset, 1);
+ gpio_set_value(robo.gpio_robo_reset, 0);
+ mdelay(50);
+
+ gpio_set_value(robo.gpio_robo_reset, 1);
+ mdelay(20);
+ } else {
+ // TODO: reset the internal robo switch
+ }
+#endif
+
+ phyid = mdio_read(ROBO_PHY_ADDR, 0x2) |
+ (mdio_read(ROBO_PHY_ADDR, 0x3) << 16);
+
+ if (phyid == 0xffffffff || phyid == 0x55210022) {
+ printk(KERN_ERR PFX "No Robo switch in managed mode found, phy_id = 0x%08x\n", phyid);
+ err = -ENODEV;
+ goto err_gpio_lanports;
+ }
+
+ /* Get the device ID */
+ for (i = 0; i < 10; i++) {
+ robo.devid = robo_read16(ROBO_MGMT_PAGE, ROBO_DEVICE_ID);
+ if (robo.devid)
+ break;
+ udelay(10);
+ }
+ if (!robo.devid)
+ robo.devid = ROBO_DEVICE_ID_5325; /* Fake it */
+ if (robo.devid == ROBO_DEVICE_ID_5325)
+ robo.is_5365 = robo_bcm5365();
+ else
+ robo.is_5365 = false;
+
+ robo.gmii = robo_gmii();
+ if (robo.devid == ROBO_DEVICE_ID_5325) {
+ for (i = 0; i < 5; i++)
+ robo.port[i] = i;
+ } else {
+ for (i = 0; i < 8; i++)
+ robo.port[i] = i;
+ }
+ robo.port[i] = ROBO_IM_PORT_CTRL;
+
+ robo_switch_reset();
+ err = robo_switch_enable();
+ if (err)
+ goto err_gpio_lanports;
+
+ printk(KERN_INFO PFX "found a 5%s%x!%s at %s\n", robo.devid & 0xff00 ? "" : "3", robo.devid,
+ robo.is_5365 ? " It's a BCM5365." : "", devname);
+
+ return 0;
+
+err_gpio_lanports:
+ if (robo.gpio_lanports_enable >= 0)
+ gpio_free(robo.gpio_lanports_enable);
+err_gpio_robo:
+ if (robo.gpio_robo_reset >= 0)
+ gpio_free(robo.gpio_robo_reset);
+err_put:
+ dev_put(robo.dev);
+ robo.dev = NULL;
+err_done:
+ return err;
+}
+
+static int handle_vlan_port_read_old(switch_driver *d, char *buf, int nr)
+{
+ __u16 val16;
+ int len = 0;
+ int j;
+
+ val16 = (nr) /* vlan */ | (0 << 12) /* read */ | (1 << 13) /* enable */;
+
+ if (robo.is_5365) {
+ robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS_5365, val16);
+ /* actual read */
+ val16 = robo_read16(ROBO_VLAN_PAGE, ROBO_VLAN_READ);
+ if ((val16 & (1 << 14)) /* valid */) {
+ for (j = 0; j < d->ports; j++) {
+ if (val16 & (1 << j)) {
+ len += sprintf(buf + len, "%d", j);
+ if (val16 & (1 << (j + 7))) {
+ if (j == d->cpuport)
+ buf[len++] = 'u';
+ } else {
+ buf[len++] = 't';
+ if (robo_read16(ROBO_VLAN_PAGE, ROBO_VLAN_PORT0_DEF_TAG + (j << 1)) == nr)
+ buf[len++] = '*';
+ }
+ buf[len++] = '\t';
+ }
+ }
+ len += sprintf(buf + len, "\n");
+ }
+ } else {
+ u32 val32;
+ robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS, val16);
+ /* actual read */
+ val32 = robo_read32(ROBO_VLAN_PAGE, ROBO_VLAN_READ);
+ if ((val32 & (1 << 20)) /* valid */) {
+ for (j = 0; j < d->ports; j++) {
+ if (val32 & (1 << j)) {
+ len += sprintf(buf + len, "%d", j);
+ if (val32 & (1 << (j + d->ports))) {
+ if (j == d->cpuport)
+ buf[len++] = 'u';
+ } else {
+ buf[len++] = 't';
+ if (robo_read16(ROBO_VLAN_PAGE, ROBO_VLAN_PORT0_DEF_TAG + (j << 1)) == nr)
+ buf[len++] = '*';
+ }
+ buf[len++] = '\t';
+ }
+ }
+ len += sprintf(buf + len, "\n");
+ }
+ }
+
+ buf[len] = '\0';
+
+ return len;
+}
+
+static int handle_vlan_port_read_new(switch_driver *d, char *buf, int nr)
+{
+ __u8 vtbl_entry, vtbl_index, vtbl_access;
+ __u32 val32;
+ int len = 0;
+ int j;
+
+ if ((robo.devid == ROBO_DEVICE_ID_5395) ||
+ (robo.devid == ROBO_DEVICE_ID_53115) ||
+ (robo.devid == ROBO_DEVICE_ID_53125)) {
+ vtbl_access = ROBO_VTBL_ACCESS_5395;
+ vtbl_index = ROBO_VTBL_INDX_5395;
+ vtbl_entry = ROBO_VTBL_ENTRY_5395;
+ } else {
+ vtbl_access = ROBO_VTBL_ACCESS;
+ vtbl_index = ROBO_VTBL_INDX;
+ vtbl_entry = ROBO_VTBL_ENTRY;
+ }
+
+ robo_write16(ROBO_ARLIO_PAGE, vtbl_index, nr);
+ robo_write16(ROBO_ARLIO_PAGE, vtbl_access, (1 << 7) | (1 << 0));
+ val32 = robo_read32(ROBO_ARLIO_PAGE, vtbl_entry);
+ for (j = 0; j < d->ports; j++) {
+ if (val32 & (1 << j)) {
+ len += sprintf(buf + len, "%d", j);
+ if (val32 & (1 << (j + d->ports))) {
+ if (j == d->cpuport)
+ buf[len++] = 'u';
+ } else {
+ buf[len++] = 't';
+ if (robo_read16(ROBO_VLAN_PAGE, ROBO_VLAN_PORT0_DEF_TAG + (j << 1)) == nr)
+ buf[len++] = '*';
+ }
+ buf[len++] = '\t';
+ }
+ }
+ len += sprintf(buf + len, "\n");
+ buf[len] = '\0';
+ return len;
+}
+
+static int handle_vlan_port_read(void *driver, char *buf, int nr)
+{
+ switch_driver *d = (switch_driver *) driver;
+
+ if (robo.devid != ROBO_DEVICE_ID_5325)
+ return handle_vlan_port_read_new(d, buf, nr);
+ else
+ return handle_vlan_port_read_old(d, buf, nr);
+}
+
+static void handle_vlan_port_write_old(switch_driver *d, switch_vlan_config *c, int nr)
+{
+ __u16 val16;
+ __u32 val32;
+ __u32 untag = ((c->untag & ~(1 << d->cpuport)) << d->ports);
+
+ /* write config now */
+ val16 = (nr) /* vlan */ | (1 << 12) /* write */ | (1 << 13) /* enable */;
+ if (robo.is_5365) {
+ robo_write32(ROBO_VLAN_PAGE, ROBO_VLAN_WRITE_5365,
+ (1 << 14) /* valid */ | (untag << 1 ) | c->port);
+ robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS_5365, val16);
+ } else {
+ if (robo.corerev < 3)
+ val32 = (1 << 20) | ((nr >> 4) << 12) | untag | c->port;
+ else
+ val32 = (1 << 24) | (nr << 12) | untag | c->port;
+ robo_write32(ROBO_VLAN_PAGE, ROBO_VLAN_WRITE, val32);
+ robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS, val16);
+ }
+}
+
+static void handle_vlan_port_write_new(switch_driver *d, switch_vlan_config *c, int nr)
+{
+ __u8 vtbl_entry, vtbl_index, vtbl_access;
+ __u32 untag = ((c->untag & ~(1 << d->cpuport)) << d->ports);
+
+ /* write config now */
+ if ((robo.devid == ROBO_DEVICE_ID_5395) ||
+ (robo.devid == ROBO_DEVICE_ID_53115) ||
+ (robo.devid == ROBO_DEVICE_ID_53125)) {
+ vtbl_access = ROBO_VTBL_ACCESS_5395;
+ vtbl_index = ROBO_VTBL_INDX_5395;
+ vtbl_entry = ROBO_VTBL_ENTRY_5395;
+ } else {
+ vtbl_access = ROBO_VTBL_ACCESS;
+ vtbl_index = ROBO_VTBL_INDX;
+ vtbl_entry = ROBO_VTBL_ENTRY;
+ }
+
+ robo_write32(ROBO_ARLIO_PAGE, vtbl_entry, untag | c->port);
+ robo_write16(ROBO_ARLIO_PAGE, vtbl_index, nr);
+ robo_write16(ROBO_ARLIO_PAGE, vtbl_access, 1 << 7);
+}
+
+static int handle_vlan_port_write(void *driver, char *buf, int nr)
+{
+ switch_driver *d = (switch_driver *)driver;
+ switch_vlan_config *c = switch_parse_vlan(d, buf);
+ int j;
+
+ if (c == NULL)
+ return -EINVAL;
+
+ for (j = 0; j < d->ports; j++) {
+ if ((c->untag | c->pvid) & (1 << j)) {
+ /* change default vlan tag */
+ robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_PORT0_DEF_TAG + (j << 1), nr);
+ }
+ }
+
+ if (robo.devid != ROBO_DEVICE_ID_5325)
+ handle_vlan_port_write_new(d, c, nr);
+ else
+ handle_vlan_port_write_old(d, c, nr);
+
+ kfree(c);
+ return 0;
+}
+
+#define set_switch(state) \
+ robo_write16(ROBO_CTRL_PAGE, ROBO_SWITCH_MODE, (robo_read16(ROBO_CTRL_PAGE, ROBO_SWITCH_MODE) & ~2) | (state ? 2 : 0));
+
+static int handle_enable_read(void *driver, char *buf, int nr)
+{
+ return sprintf(buf, "%d\n", (((robo_read16(ROBO_CTRL_PAGE, ROBO_SWITCH_MODE) & 2) == 2) ? 1 : 0));
+}
+
+static int handle_enable_write(void *driver, char *buf, int nr)
+{
+ set_switch(buf[0] == '1');
+
+ return 0;
+}
+
+static int handle_port_enable_read(void *driver, char *buf, int nr)
+{
+ return sprintf(buf, "%d\n", ((robo_read16(ROBO_CTRL_PAGE, robo.port[nr]) & 3) == 3 ? 0 : 1));
+}
+
+static int handle_port_enable_write(void *driver, char *buf, int nr)
+{
+ u16 val16;
+
+ if (buf[0] == '0')
+ val16 = 3; /* disabled */
+ else if (buf[0] == '1')
+ val16 = 0; /* enabled */
+ else
+ return -EINVAL;
+
+ robo_write16(ROBO_CTRL_PAGE, robo.port[nr],
+ (robo_read16(ROBO_CTRL_PAGE, robo.port[nr]) & ~3) | val16);
+
+ return 0;
+}
+
+static int handle_port_media_read(void *driver, char *buf, int nr)
+{
+ u16 bmcr = mdio_read(robo.port[nr], MII_BMCR);
+ int media, len;
+
+ if (bmcr & BMCR_ANENABLE)
+ media = SWITCH_MEDIA_AUTO;
+ else {
+ if (bmcr & BMCR_SPEED1000)
+ media = SWITCH_MEDIA_1000;
+ else if (bmcr & BMCR_SPEED100)
+ media = SWITCH_MEDIA_100;
+ else
+ media = 0;
+
+ if (bmcr & BMCR_FULLDPLX)
+ media |= SWITCH_MEDIA_FD;
+ }
+
+ len = switch_print_media(buf, media);
+ return len + sprintf(buf + len, "\n");
+}
+
+static int handle_port_media_write(void *driver, char *buf, int nr)
+{
+ int media = switch_parse_media(buf);
+ u16 bmcr, bmcr_mask;
+
+ if (media & SWITCH_MEDIA_AUTO)
+ bmcr = BMCR_ANENABLE | BMCR_ANRESTART;
+ else {
+ if (media & SWITCH_MEDIA_1000) {
+ if (!robo.gmii)
+ return -EINVAL;
+ bmcr = BMCR_SPEED1000;
+ }
+ else if (media & SWITCH_MEDIA_100)
+ bmcr = BMCR_SPEED100;
+ else
+ bmcr = 0;
+
+ if (media & SWITCH_MEDIA_FD)
+ bmcr |= BMCR_FULLDPLX;
+ }
+
+ bmcr_mask = ~(BMCR_SPEED1000 | BMCR_SPEED100 | BMCR_FULLDPLX | BMCR_ANENABLE | BMCR_ANRESTART);
+ mdio_write(robo.port[nr], MII_BMCR,
+ (mdio_read(robo.port[nr], MII_BMCR) & bmcr_mask) | bmcr);
+
+ return 0;
+}
+
+static int handle_enable_vlan_read(void *driver, char *buf, int nr)
+{
+ return sprintf(buf, "%d\n", (((robo_read16(ROBO_VLAN_PAGE, ROBO_VLAN_CTRL0) & (1 << 7)) == (1 << 7)) ? 1 : 0));
+}
+
+static int handle_enable_vlan_write(void *driver, char *buf, int nr)
+{
+ __u16 val16;
+ int disable = ((buf[0] != '1') ? 1 : 0);
+
+ val16 = robo_read16(ROBO_VLAN_PAGE, ROBO_VLAN_CTRL0);
+ robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_CTRL0, disable ? 0 :
+ val16 | (1 << 7) /* 802.1Q VLAN */ | (3 << 5) /* mac check and hash */);
+
+ val16 = robo_read16(ROBO_VLAN_PAGE, ROBO_VLAN_CTRL1);
+ robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_CTRL1, disable ? 0 :
+ val16 | (robo.devid == ROBO_DEVICE_ID_5325 ? (1 << 1) :
+ 0) | (1 << 2) | (1 << 3)); /* RSV multicast */
+
+ if (robo.devid != ROBO_DEVICE_ID_5325)
+ return 0;
+
+ robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_CTRL4, disable ? 0 :
+ (1 << 6) /* drop invalid VID frames */);
+ robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_CTRL5, disable ? 0 :
+ (1 << 3) /* drop miss V table frames */);
+
+ return 0;
+}
+
+static void handle_reset_old(switch_driver *d, char *buf, int nr)
+{
+ int j;
+ __u16 val16;
+
+ /* reset vlans */
+ for (j = 0; j <= ((robo.is_5365) ? VLAN_ID_MAX_5365 : VLAN_ID_MAX); j++) {
+ /* write config now */
+ val16 = (j) /* vlan */ | (1 << 12) /* write */ | (1 << 13) /* enable */;
+ if (robo.is_5365)
+ robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_WRITE_5365, 0);
+ else
+ robo_write32(ROBO_VLAN_PAGE, ROBO_VLAN_WRITE, 0);
+ robo_write16(ROBO_VLAN_PAGE, robo.is_5365 ? ROBO_VLAN_TABLE_ACCESS_5365 :
+ ROBO_VLAN_TABLE_ACCESS,
+ val16);
+ }
+}
+
+static void handle_reset_new(switch_driver *d, char *buf, int nr)
+{
+ int j;
+ __u8 vtbl_entry, vtbl_index, vtbl_access;
+
+ if ((robo.devid == ROBO_DEVICE_ID_5395) ||
+ (robo.devid == ROBO_DEVICE_ID_53115) ||
+ (robo.devid == ROBO_DEVICE_ID_53125)) {
+ vtbl_access = ROBO_VTBL_ACCESS_5395;
+ vtbl_index = ROBO_VTBL_INDX_5395;
+ vtbl_entry = ROBO_VTBL_ENTRY_5395;
+ } else {
+ vtbl_access = ROBO_VTBL_ACCESS;
+ vtbl_index = ROBO_VTBL_INDX;
+ vtbl_entry = ROBO_VTBL_ENTRY;
+ }
+
+ for (j = 0; j <= VLAN_ID_MAX; j++) {
+ /* write config now */
+ robo_write32(ROBO_ARLIO_PAGE, vtbl_entry, 0);
+ robo_write16(ROBO_ARLIO_PAGE, vtbl_index, j);
+ robo_write16(ROBO_ARLIO_PAGE, vtbl_access, 1 << 7);
+ }
+}
+
+static int handle_reset(void *driver, char *buf, int nr)
+{
+ int j;
+ switch_driver *d = (switch_driver *) driver;
+
+ /* disable switching */
+ set_switch(0);
+
+ if (robo.devid != ROBO_DEVICE_ID_5325)
+ handle_reset_new(d, buf, nr);
+ else
+ handle_reset_old(d, buf, nr);
+
+ /* reset ports to a known good state */
+ for (j = 0; j < d->ports; j++) {
+ robo_write16(ROBO_CTRL_PAGE, robo.port[j], 0x0000);
+ robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_PORT0_DEF_TAG + (j << 1), 0);
+ }
+
+ /* enable switching */
+ set_switch(1);
+
+ /* enable vlans */
+ handle_enable_vlan_write(driver, "1", 0);
+
+ return 0;
+}
+
+static int __init robo_init(void)
+{
+ int notfound = 1;
+ char *device;
+
+ device = strdup("ethX");
+ for (device[3] = '0'; (device[3] <= '3') && notfound; device[3]++) {
+ if (! switch_device_registered (device))
+ notfound = robo_probe(device);
+ }
+ device[3]--;
+
+ if (notfound) {
+ kfree(device);
+ return -ENODEV;
+ } else {
+ static const switch_config cfg[] = {
+ {
+ .name = "enable",
+ .read = handle_enable_read,
+ .write = handle_enable_write
+ }, {
+ .name = "enable_vlan",
+ .read = handle_enable_vlan_read,
+ .write = handle_enable_vlan_write
+ }, {
+ .name = "reset",
+ .read = NULL,
+ .write = handle_reset
+ }, { NULL, },
+ };
+ static const switch_config port[] = {
+ {
+ .name = "enable",
+ .read = handle_port_enable_read,
+ .write = handle_port_enable_write
+ }, {
+ .name = "media",
+ .read = handle_port_media_read,
+ .write = handle_port_media_write
+ }, { NULL, },
+ };
+ static const switch_config vlan[] = {
+ {
+ .name = "ports",
+ .read = handle_vlan_port_read,
+ .write = handle_vlan_port_write
+ }, { NULL, },
+ };
+ switch_driver driver = {
+ .name = DRIVER_NAME,
+ .version = DRIVER_VERSION,
+ .interface = device,
+ .cpuport = 5,
+ .ports = 6,
+ .vlans = 16,
+ .driver_handlers = cfg,
+ .port_handlers = port,
+ .vlan_handlers = vlan,
+ };
+ if (robo.devid != ROBO_DEVICE_ID_5325) {
+ driver.ports = 9;
+ driver.cpuport = 8;
+ }
+ if (robo.is_5365)
+ snprintf(driver.dev_name, SWITCH_NAME_BUFSZ, "BCM5365");
+ else
+ snprintf(driver.dev_name, SWITCH_NAME_BUFSZ, "BCM5%s%x", robo.devid & 0xff00 ? "" : "3", robo.devid);
+
+ return switch_register_driver(&driver);
+ }
+}
+
+static void __exit robo_exit(void)
+{
+ switch_unregister_driver(DRIVER_NAME);
+ if (robo.dev)
+ dev_put(robo.dev);
+ if (robo.gpio_robo_reset >= 0)
+ gpio_free(robo.gpio_robo_reset);
+ if (robo.gpio_lanports_enable >= 0)
+ gpio_free(robo.gpio_lanports_enable);
+ kfree(robo.device);
+}
+
+
+MODULE_AUTHOR("Felix Fietkau <openwrt@nbd.name>");
+MODULE_LICENSE("GPL");
+
+module_init(robo_init);
+module_exit(robo_exit);
diff --git a/package/system/.svn/entries b/package/system/.svn/entries
new file mode 100644
index 0000000..6bfffd0
--- /dev/null
+++ b/package/system/.svn/entries
@@ -0,0 +1,85 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/system
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-02-01T15:50:49.759805Z
+35431
+juhosg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+vsc73x5-ucode
+dir
+
+i2c-gpio-custom
+dir
+
+wrt55agv2-spidevs
+dir
+
+rotary-gpio-custom
+dir
+
+mmc_over_gpio
+dir
+
+hostap-driver
+dir
+
+gpio-button-hotplug
+dir
+
+avila-wdt
+dir
+
+spidev_test
+dir
+
+button-hotplug
+dir
+
+w1-gpio-custom
+dir
+
+ep80579-drivers
+dir
+
+utils
+dir
+
+spi-ks8995
+dir
+
+ixp4xx-microcode
+dir
+
+rtc-rv5c386a
+dir
+
+brcm2708-gpu-fw
+dir
+
+ar7-atm
+dir
+
+om-watchdog
+dir
+
diff --git a/package/system/ar7-atm/.svn/entries b/package/system/ar7-atm/.svn/entries
new file mode 100644
index 0000000..5e9ddb4
--- /dev/null
+++ b/package/system/ar7-atm/.svn/entries
@@ -0,0 +1,102 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/system/ar7-atm
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-11-16T13:00:41.605579Z
+34205
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+patches-D7.05.01.00
+dir
+
+patches-D7.04.03.00
+dir
+
+Config.in
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+628209d236f3f583ab3725093fd68719
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+458
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+d4c22d7bf8ec58beeafc559aa19d3fde
+2012-11-16T13:00:41.605579Z
+34205
+florian
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2562
+
diff --git a/package/system/ar7-atm/.svn/prop-base/Makefile.svn-base b/package/system/ar7-atm/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..8e522ae
--- /dev/null
+++ b/package/system/ar7-atm/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:copyright
+V 30
+Copyright (C) 2006 OpenWrt.org
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/system/ar7-atm/.svn/text-base/Config.in.svn-base b/package/system/ar7-atm/.svn/text-base/Config.in.svn-base
new file mode 100644
index 0000000..479b7ad
--- /dev/null
+++ b/package/system/ar7-atm/.svn/text-base/Config.in.svn-base
@@ -0,0 +1,22 @@
+menu "Configuration"
+ depends on (PACKAGE_kmod-sangam-atm-annex-a || PACKAGE_kmod-sangam-atm-annex-b)
+
+choice
+ prompt "Firmware version"
+ default AR7_ATM_FW_VERSION_704
+ help
+ This option allows you to switch between firmware/driver versions which
+ might improve the DSL line speed.
+
+config AR7_ATM_FW_VERSION_705
+ bool "D7.05.01.00"
+
+config AR7_ATM_FW_VERSION_704
+ bool "D7.04.03.00"
+
+config AR7_ATM_FW_VERSION_703
+ bool "D7.03.01.00"
+
+endchoice
+
+endmenu
diff --git a/package/system/ar7-atm/.svn/text-base/Makefile.svn-base b/package/system/ar7-atm/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..59e9e79
--- /dev/null
+++ b/package/system/ar7-atm/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,100 @@
+#
+# Copyright (C) 2006-2009 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=sangam_atm
+
+ifeq ($(CONFIG_AR7_ATM_FW_VERSION_705),y)
+PKG_VERSION:=D7.05.01.00
+PKG_MD5SUM:=42ee465be5cfbe9476fc25deb260d450
+PKG_RELEASE:=R1
+PATCH_DIR:=patches-$(PKG_VERSION)
+endif
+
+ifeq ($(CONFIG_AR7_ATM_FW_VERSION_704),y)
+PKG_VERSION:=D7.04.03.00
+PKG_MD5SUM:=3d76004e46f09e88931f91670cb420ad
+PKG_RELEASE:=R1
+PATCH_DIR:=patches-$(PKG_VERSION)
+endif
+
+ifeq ($(CONFIG_AR7_ATM_FW_VERSION_703),y)
+PKG_VERSION:=D7.03.01.00
+PKG_MD5SUM:=bc6e9c6adb1be25820c7ee661de8ca7d
+PKG_RELEASE:=R2
+PATCH_DIR:=patches-D7.04.03.00
+endif
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_RELEASE).tar.bz2
+PKG_SOURCE_URL:=http://mirror2.openwrt.org/sources
+
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/sangam-atm/Default
+ SUBMENU:=Network Devices
+ DEPENDS:=@TARGET_ar7_generic +kmod-atm
+ TITLE:=AR7 ADSL driver
+ FILES:=$(PKG_BUILD_DIR)/tiatm.ko
+ AUTOLOAD:=$(call AutoLoad,50,tiatm)
+ MAINTAINER:=Florian Fainelli <florian@openwrt.org>
+ MENU:=1
+endef
+
+define KernelPackage/sangam-atm/config
+ source "$(SOURCE)/Config.in"
+endef
+
+define KernelPackage/sangam-atm-annex-a
+$(call KernelPackage/sangam-atm/Default)
+ TITLE+= (Annex A, ADSL over POTS)
+endef
+
+define KernelPackage/sangam-atm-annex-a/description
+ The AR7 ADSL driver for Annex A (ADSL over POTS).
+endef
+
+define KernelPackage/sangam-atm-annex-a/config
+$(call KernelPackage/sangam-atm/config)
+endef
+
+define KernelPackage/sangam-atm-annex-b
+$(call KernelPackage/sangam-atm/Default)
+ TITLE+= (Annex B, ADSL over ISDN)
+endef
+
+define KernelPackage/sangam-atm-annex-b/description
+ The AR7 ADSL driver for Annex B (ADSL over ISDN).
+endef
+
+define KernelPackage/sangam-atm-annex-a/config
+$(call KernelPackage/sangam-atm/config)
+endef
+
+define Build/Compile
+ $(MAKE) -C "$(LINUX_DIR)" \
+ CROSS_COMPILE="$(TARGET_CROSS)" \
+ ARCH="$(LINUX_KARCH)" \
+ SUBDIRS="$(PKG_BUILD_DIR)" \
+ modules
+endef
+
+define KernelPackage/sangam-atm-annex-a/install
+ mkdir -p $(1)/lib/firmware
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/ar0700mp.bin $(1)/lib/firmware/
+ ln -sf ar0700mp.bin $(1)/lib/firmware/ar0700xx.bin
+endef
+
+define KernelPackage/sangam-atm-annex-b/install
+ mkdir -p $(1)/lib/firmware
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/ar0700db.bin $(1)/lib/firmware/
+ ln -sf ar0700db.bin $(1)/lib/firmware/ar0700xx.bin
+endef
+
+$(eval $(call KernelPackage,sangam-atm-annex-a))
+$(eval $(call KernelPackage,sangam-atm-annex-b))
diff --git a/package/system/ar7-atm/Config.in b/package/system/ar7-atm/Config.in
new file mode 100644
index 0000000..479b7ad
--- /dev/null
+++ b/package/system/ar7-atm/Config.in
@@ -0,0 +1,22 @@
+menu "Configuration"
+ depends on (PACKAGE_kmod-sangam-atm-annex-a || PACKAGE_kmod-sangam-atm-annex-b)
+
+choice
+ prompt "Firmware version"
+ default AR7_ATM_FW_VERSION_704
+ help
+ This option allows you to switch between firmware/driver versions which
+ might improve the DSL line speed.
+
+config AR7_ATM_FW_VERSION_705
+ bool "D7.05.01.00"
+
+config AR7_ATM_FW_VERSION_704
+ bool "D7.04.03.00"
+
+config AR7_ATM_FW_VERSION_703
+ bool "D7.03.01.00"
+
+endchoice
+
+endmenu
diff --git a/package/system/ar7-atm/Makefile b/package/system/ar7-atm/Makefile
new file mode 100644
index 0000000..59e9e79
--- /dev/null
+++ b/package/system/ar7-atm/Makefile
@@ -0,0 +1,100 @@
+#
+# Copyright (C) 2006-2009 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=sangam_atm
+
+ifeq ($(CONFIG_AR7_ATM_FW_VERSION_705),y)
+PKG_VERSION:=D7.05.01.00
+PKG_MD5SUM:=42ee465be5cfbe9476fc25deb260d450
+PKG_RELEASE:=R1
+PATCH_DIR:=patches-$(PKG_VERSION)
+endif
+
+ifeq ($(CONFIG_AR7_ATM_FW_VERSION_704),y)
+PKG_VERSION:=D7.04.03.00
+PKG_MD5SUM:=3d76004e46f09e88931f91670cb420ad
+PKG_RELEASE:=R1
+PATCH_DIR:=patches-$(PKG_VERSION)
+endif
+
+ifeq ($(CONFIG_AR7_ATM_FW_VERSION_703),y)
+PKG_VERSION:=D7.03.01.00
+PKG_MD5SUM:=bc6e9c6adb1be25820c7ee661de8ca7d
+PKG_RELEASE:=R2
+PATCH_DIR:=patches-D7.04.03.00
+endif
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_RELEASE).tar.bz2
+PKG_SOURCE_URL:=http://mirror2.openwrt.org/sources
+
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/sangam-atm/Default
+ SUBMENU:=Network Devices
+ DEPENDS:=@TARGET_ar7_generic +kmod-atm
+ TITLE:=AR7 ADSL driver
+ FILES:=$(PKG_BUILD_DIR)/tiatm.ko
+ AUTOLOAD:=$(call AutoLoad,50,tiatm)
+ MAINTAINER:=Florian Fainelli <florian@openwrt.org>
+ MENU:=1
+endef
+
+define KernelPackage/sangam-atm/config
+ source "$(SOURCE)/Config.in"
+endef
+
+define KernelPackage/sangam-atm-annex-a
+$(call KernelPackage/sangam-atm/Default)
+ TITLE+= (Annex A, ADSL over POTS)
+endef
+
+define KernelPackage/sangam-atm-annex-a/description
+ The AR7 ADSL driver for Annex A (ADSL over POTS).
+endef
+
+define KernelPackage/sangam-atm-annex-a/config
+$(call KernelPackage/sangam-atm/config)
+endef
+
+define KernelPackage/sangam-atm-annex-b
+$(call KernelPackage/sangam-atm/Default)
+ TITLE+= (Annex B, ADSL over ISDN)
+endef
+
+define KernelPackage/sangam-atm-annex-b/description
+ The AR7 ADSL driver for Annex B (ADSL over ISDN).
+endef
+
+define KernelPackage/sangam-atm-annex-a/config
+$(call KernelPackage/sangam-atm/config)
+endef
+
+define Build/Compile
+ $(MAKE) -C "$(LINUX_DIR)" \
+ CROSS_COMPILE="$(TARGET_CROSS)" \
+ ARCH="$(LINUX_KARCH)" \
+ SUBDIRS="$(PKG_BUILD_DIR)" \
+ modules
+endef
+
+define KernelPackage/sangam-atm-annex-a/install
+ mkdir -p $(1)/lib/firmware
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/ar0700mp.bin $(1)/lib/firmware/
+ ln -sf ar0700mp.bin $(1)/lib/firmware/ar0700xx.bin
+endef
+
+define KernelPackage/sangam-atm-annex-b/install
+ mkdir -p $(1)/lib/firmware
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/ar0700db.bin $(1)/lib/firmware/
+ ln -sf ar0700db.bin $(1)/lib/firmware/ar0700xx.bin
+endef
+
+$(eval $(call KernelPackage,sangam-atm-annex-a))
+$(eval $(call KernelPackage,sangam-atm-annex-b))
diff --git a/package/system/ar7-atm/patches-D7.04.03.00/.svn/entries b/package/system/ar7-atm/patches-D7.04.03.00/.svn/entries
new file mode 100644
index 0000000..6c999e6
--- /dev/null
+++ b/package/system/ar7-atm/patches-D7.04.03.00/.svn/entries
@@ -0,0 +1,436 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/system/ar7-atm/patches-D7.04.03.00
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+110-interrupt_fix.patch
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+9475e9861bdcffc598ab077798502f23
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1122
+
+120-no_dumb_inline.patch
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+b684226cb224270aa8ac892c541c07b8
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+456
+
+180-git_headers_include.patch
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+2213d63bc8a58e2e44bb99d11a9757ad
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1158
+
+200-2.6.37_args.patch
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+7ef649f7d3336dffd87639b731af1da7
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+963
+
+210-3.3-remove-smp_lock.h.patch
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+4046468eab4c90c22b28bcc19e775be7
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+812
+
+130-powercutback.patch
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+78df8a199c9e218b6ac4f89eab0127d3
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1770
+
+160-module-params.patch
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+5e5616d74d16628146e626701ef29a2d
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+18659
+
+100-compile_fix.patch
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+4d52f79f2daaa28729b0df6d38f0eadd
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+21393
+
+140-debug_mode.patch
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+7d5a8b87c960d86419a6b13d22aa0166
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1065
+
+150-tasklet_mode.patch
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+ab53999f8a021882c5a4a47b745faf9b
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+690
+
+170-bus_id_removal.patch
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+1bfe6ab655af228d86349da78a04732d
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+740
+
+190-2.6.32_proc_fixes.patch
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+c31a9952d4d6a7d7237d3242fc1d0201
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1889
+
diff --git a/package/system/ar7-atm/patches-D7.04.03.00/.svn/prop-base/100-compile_fix.patch.svn-base b/package/system/ar7-atm/patches-D7.04.03.00/.svn/prop-base/100-compile_fix.patch.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/system/ar7-atm/patches-D7.04.03.00/.svn/prop-base/100-compile_fix.patch.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/system/ar7-atm/patches-D7.04.03.00/.svn/text-base/100-compile_fix.patch.svn-base b/package/system/ar7-atm/patches-D7.04.03.00/.svn/text-base/100-compile_fix.patch.svn-base
new file mode 100644
index 0000000..df5fe53
--- /dev/null
+++ b/package/system/ar7-atm/patches-D7.04.03.00/.svn/text-base/100-compile_fix.patch.svn-base
@@ -0,0 +1,768 @@
+--- a/cppi_cpaal5.c
++++ b/cppi_cpaal5.c
+@@ -352,7 +352,7 @@ static int halRxReturn(HAL_RECEIVEINFO *
+ {
+ /* malloc failed, add this RCB to Needs Buffer List */
+ TempRcb->FragCount = 1; /*MJH+030417*/
+- (HAL_RCB *)TempRcb->Eop = TempRcb; /* GSG +030430 */
++ TempRcb->Eop = TempRcb; /* GSG +030430 */
+
+ if(HalDev->NeedsCount < MAX_NEEDS) /* +MJH 030410 */
+ { /* +MJH 030410 */
+--- a/dsl_hal_api.c
++++ b/dsl_hal_api.c
+@@ -254,15 +254,15 @@
+ * of phyEnableDisableWord & phyControlWord to avoid changing API struct
+ * which may cause change required to application data structure.
+ ******************************************************************************/
+-#include <dev_host_interface.h>
+-#include <dsl_hal_register.h>
+-#include <dsl_hal_support.h>
++#include "dev_host_interface.h"
++#include "dsl_hal_register.h"
++#include "dsl_hal_support.h"
+
+ #ifndef NO_ADV_STATS
+-#include <dsl_hal_logtable.h>
++#include "dsl_hal_logtable.h"
+ #endif
+
+-#include <dsl_hal_version.h>
++#include "dsl_hal_version.h"
+
+ // UR8_MERGE_START CQ11054 Jack Zhang
+ static unsigned int highprecision_selected = 0; //By default we use low precision for backward compt.
+--- a/dsl_hal_support.c
++++ b/dsl_hal_support.c
+@@ -140,9 +140,9 @@
+ * oamFeature are overriden
+ // UR8_MERGE_END CQ10774 Ram
+ *******************************************************************************/
+-#include <dev_host_interface.h>
+-#include <dsl_hal_register.h>
+-#include <dsl_hal_support.h>
++#include "dev_host_interface.h"
++#include "dsl_hal_register.h"
++#include "dsl_hal_support.h"
+
+ #define NUM_READ_RETRIES 3
+ static unsigned int dslhal_support_adsl2ByteSwap32(unsigned int in32Bits);
+--- a/dsl_hal_support.h
++++ b/dsl_hal_support.h
+@@ -49,7 +49,7 @@
+ * 04Nov05 0.11.00 CPH Fixed T1413 mode got Zero DS/US rate when DSL_BIT_TMODE is set.
+ *******************************************************************************/
+
+-#include <dsl_hal_api.h>
++#include "dsl_hal_api.h"
+
+ #define virtual2Physical(a) (((int)a)&~0xe0000000)
+ /* External Function Prototype Declarations */
+--- a/Makefile
++++ b/Makefile
+@@ -1,18 +1,9 @@
+-# File: drivers/atm/ti_evm3/Makefile
+ #
+-# Makefile for the Texas Instruments EVM3 ADSL/ATM driver.
++# Makefile for the TIATM device driver.
+ #
+-#
+-# Copyright (c) 2000 Texas Instruments Incorporated.
+-# Jeff Harrell (jharrell@telogy.com)
+-# Viren Balar (vbalar@ti.com)
+-# Victor Wells (vwells@telogy.com)
+-#
+-include $(TOPDIR)/Rules.make
+-
+-
+-
+-
+-
+-
+
++CONFIG_SANGAM_ATM=m
++#EXTRA_CFLAGS += -DEL -I. -DPOST_SILICON -DCOMMON_NSP -DCONFIG_LED_MODULE -DDEREGISTER_LED -DNO_ACT
++EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -DNO_ACT -D__NO__VOICE_PATCH__ -DEL
++obj-$(CONFIG_SANGAM_ATM) := tiatm.o
++tiatm-objs += cpsar.o aal5sar.o tn7sar.o tn7atm.o tn7dsl.o dsl_hal_api.o dsl_hal_support.o
+--- a/tn7atm.c
++++ b/tn7atm.c
+@@ -61,7 +61,6 @@
+ * UR8_MERGE_END CQ11057*
+ *********************************************************************************************/
+
+-#include <linux/config.h>
+ #include <linux/kernel.h>
+ #include <linux/module.h>
+ #include <linux/init.h>
+@@ -69,11 +68,14 @@
+ #include <linux/delay.h>
+ #include <linux/spinlock.h>
+ #include <linux/smp_lock.h>
+-#include <asm/io.h>
+-#include <asm/mips-boards/prom.h>
+ #include <linux/proc_fs.h>
+ #include <linux/string.h>
+ #include <linux/ctype.h>
++
++#include <asm/io.h>
++#include <asm/ar7/ar7.h>
++#include <asm/ar7/prom.h>
++
+ #include "dsl_hal_api.h"
+ #include "tn7atm.h"
+ #include "tn7api.h"
+@@ -82,6 +84,7 @@
+ #include "dsl_hal_register.h"
+
+ #ifdef MODULE
++MODULE_LICENSE("GPL");
+ MODULE_DESCRIPTION ("Tnetd73xx ATM Device Driver");
+ MODULE_AUTHOR ("Zhicheng Tang");
+ #endif
+@@ -100,9 +103,9 @@ MODULE_AUTHOR ("Zhicheng Tang");
+
+ /*end of externs */
+
+-#ifndef TI_STATIC_ALLOCATIONS
+-#define TI_STATIC_ALLOCATIONS
+-#endif
++//#ifndef TI_STATIC_ALLOCATIONS
++//#define TI_STATIC_ALLOCATIONS
++//#endif
+
+ #define tn7atm_kfree_skb(x) dev_kfree_skb(x)
+
+@@ -114,7 +117,7 @@ static int EnableQoS = FALSE;
+ /* prototypes */
+ static int tn7atm_set_can_support_adsl2 (int can);
+
+-static int tn7atm_open (struct atm_vcc *vcc, short vpi, int vci);
++static int tn7atm_open (struct atm_vcc *vcc);
+
+ static void tn7atm_close (struct atm_vcc *vcc);
+
+@@ -257,13 +260,12 @@ static const struct atmdev_ops tn7atm_op
+ getsockopt: NULL,
+ setsockopt: NULL,
+ send: tn7atm_send,
+- sg_send: NULL,
+ phy_put: NULL,
+ phy_get: NULL,
+ change_qos: tn7atm_change_qos,
+ };
+
+-const char drv_proc_root_folder[] = "avalanche/";
++const char drv_proc_root_folder[] = "avalanche";
+ static struct proc_dir_entry *root_proc_dir_entry = NULL;
+ #define DRV_PROC_MODE 0644
+ static int proc_root_already_exists = TRUE;
+@@ -559,56 +561,6 @@ static int turbodsl_check_priority_type(
+
+ /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+- * Function: int tn7atm_walk_vccs(struct atm_dev *dev, short *vcc, int *vci)
+- *
+- * Description: retrieve VPI/VCI for connection
+- *
+- *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+-static int tn7atm_walk_vccs (struct atm_vcc *vcc, short *vpi, int *vci)
+-{
+- struct atm_vcc *walk;
+-
+- /*
+- * find a free VPI
+- */
+- if (*vpi == ATM_VPI_ANY)
+- {
+-
+- for (*vpi = 0, walk = vcc->dev->vccs; walk; walk = walk->next)
+- {
+-
+- if ((walk->vci == *vci) && (walk->vpi == *vpi))
+- {
+- (*vpi)++;
+- walk = vcc->dev->vccs;
+- }
+- }
+- }
+-
+- /*
+- * find a free VCI
+- */
+- if (*vci == ATM_VCI_ANY)
+- {
+-
+- for (*vci = ATM_NOT_RSV_VCI, walk = vcc->dev->vccs; walk;
+- walk = walk->next)
+- {
+-
+- if ((walk->vpi = *vpi) && (walk->vci == *vci))
+- {
+- *vci = walk->vci + 1;
+- walk = vcc->dev->vccs;
+- }
+- }
+- }
+-
+- return 0;
+-}
+-
+-
+-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+- *
+ * Function: int tn7atm_sar_irq(void)
+ *
+ * Description: tnetd73xx SAR interrupt.
+@@ -693,7 +645,7 @@ static int __init tn7atm_irq_request (st
+ * Register SAR interrupt
+ */
+ priv->sar_irq = LNXINTNUM (ATM_SAR_INT); /* Interrupt line # */
+- if (request_irq (priv->sar_irq, tn7atm_sar_irq, SA_INTERRUPT, "SAR ", dev))
++ if (request_irq (priv->sar_irq, tn7atm_sar_irq, IRQF_DISABLED, "SAR ", dev))
+ printk ("Could not register tn7atm_sar_irq\n");
+
+ /*
+@@ -704,14 +656,14 @@ static int __init tn7atm_irq_request (st
+ {
+ def_sar_inter_pace = os_atoi (ptr);
+ }
+- avalanche_request_pacing (priv->sar_irq, ATM_SAR_INT_PACING_BLOCK_NUM,
+- def_sar_inter_pace);
++/* avalanche_request_pacing (priv->sar_irq, ATM_SAR_INT_PACING_BLOCK_NUM,
++ def_sar_inter_pace);*/
+
+ /*
+ * Reigster Receive interrupt A
+ */
+ priv->dsl_irq = LNXINTNUM (ATM_DSL_INT); /* Interrupt line # */
+- if (request_irq (priv->dsl_irq, tn7atm_dsl_irq, SA_INTERRUPT, "DSL ", dev))
++ if (request_irq (priv->dsl_irq, tn7atm_dsl_irq, IRQF_DISABLED, "DSL ", dev))
+ printk ("Could not register tn7atm_dsl_irq\n");
+
+ /***** VRB Tasklet Mode ****/
+@@ -875,11 +827,15 @@ static int __init tn7atm_get_ESI (struct
+ #define ATM_VBR_RT 5
+ #endif
+
+-int tn7atm_open (struct atm_vcc *vcc, short vpi, int vci)
++int tn7atm_open (struct atm_vcc *vcc)
+ {
+ tn7atm_activate_vc_parm_t tn7atm_activate_vc_parm;
+ int rc;
+ //int flags;
++ tn7atm_activate_vc_parm.pcr = 0x20000;
++ tn7atm_activate_vc_parm.scr = 0x20000;
++ tn7atm_activate_vc_parm.mbs = 0x20000;
++ tn7atm_activate_vc_parm.cdvt = 10000;
+
+ dgprintf(1, "tn7atm_open()\n");
+
+@@ -891,24 +847,18 @@ int tn7atm_open (struct atm_vcc *vcc, sh
+ return -1;
+ }
+
+- MOD_INC_USE_COUNT;
++// MOD_INC_USE_COUNT;
+
+- /* find a free VPI/VCI */
+- tn7atm_walk_vccs(vcc, &vpi, &vci);
+-
+- vcc->vpi = vpi;
+- vcc->vci = vci;
+-
+- if ((vci == ATM_VCI_UNSPEC) || (vpi == ATM_VCI_UNSPEC))
++ if ((vcc->vci == ATM_VCI_UNSPEC) || (vcc->vpi == ATM_VCI_UNSPEC))
+ {
+- MOD_DEC_USE_COUNT;
++// MOD_DEC_USE_COUNT;
+ return -EBUSY;
+ }
+
+- tn7atm_activate_vc_parm.vpi = vpi;
+- tn7atm_activate_vc_parm.vci = vci;
++ tn7atm_activate_vc_parm.vpi = vcc->vpi;
++ tn7atm_activate_vc_parm.vci = vcc->vci;
+
+- if ((vpi == CLEAR_EOC_VPI) && (vci == CLEAR_EOC_VCI))
++ if ((vcc->vpi == CLEAR_EOC_VPI) && (vcc->vci == CLEAR_EOC_VCI))
+ {
+ /* always use (max_dma_chan+1) for clear eoc */
+ tn7atm_activate_vc_parm.chan = EOC_DMA_CHAN;
+@@ -916,7 +866,7 @@ int tn7atm_open (struct atm_vcc *vcc, sh
+ /* check to see whether clear eoc is opened or not */
+ if (tn7atm_activate_vc_parm.priv->lut[tn7atm_activate_vc_parm.chan].inuse)
+ {
+- MOD_DEC_USE_COUNT;
++// MOD_DEC_USE_COUNT;
+ printk("tn7atm_open: Clear EOC channel (dmachan=%d) already in use.\n", tn7atm_activate_vc_parm.chan);
+ return -EBUSY;
+ }
+@@ -925,7 +875,7 @@ int tn7atm_open (struct atm_vcc *vcc, sh
+ if (rc)
+ {
+ printk("tn7atm_open: failed to setup clear_eoc\n");
+- MOD_DEC_USE_COUNT;
++// MOD_DEC_USE_COUNT;
+ return -EBUSY;
+ }
+ tn7atm_set_lut(tn7atm_activate_vc_parm.priv,vcc, tn7atm_activate_vc_parm.chan);
+@@ -934,17 +884,17 @@ int tn7atm_open (struct atm_vcc *vcc, sh
+ }
+ else /* PVC channel setup */
+ {
+- if ((vpi==REMOTE_MGMT_VPI) && (vci==REMOTE_MGMT_VCI))
++ if ((vcc->vpi==REMOTE_MGMT_VPI) && (vcc->vci==REMOTE_MGMT_VCI))
+ {
+ tn7atm_activate_vc_parm.chan = 14; /* always use chan 14 for MII PVC-base romote mgmt */
+ }
+ else
+ {
+- rc = tn7atm_lut_find(vpi, vci);
++ rc = tn7atm_lut_find(vcc->vpi, vcc->vci);
+ /* check to see whether PVC is opened or not */
+ if(ATM_NO_DMA_CHAN != rc)
+ {
+- MOD_DEC_USE_COUNT;
++// MOD_DEC_USE_COUNT;
+ printk("PVC already opened. dmachan = %d\n", rc);
+ return -EBUSY;
+ }
+@@ -976,6 +926,7 @@ int tn7atm_open (struct atm_vcc *vcc, sh
+ tn7atm_activate_vc_parm.priority = 2;
+ break;
+
++#if 0
+ case ATM_VBR: /* Variable Bit Rate-Non RealTime*/
+ tn7atm_activate_vc_parm.qos = 1;
+ tn7atm_activate_vc_parm.priority = 1;
+@@ -997,6 +948,7 @@ int tn7atm_open (struct atm_vcc *vcc, sh
+ tn7atm_activate_vc_parm.mbs = vcc->qos.txtp.max_pcr;
+ tn7atm_activate_vc_parm.cdvt = vcc->qos.txtp.max_cdv;
+ break;
++#endif
+
+ default:
+ tn7atm_activate_vc_parm.qos = 2;
+@@ -1024,7 +976,7 @@ int tn7atm_open (struct atm_vcc *vcc, sh
+ if (rc < 0)
+ {
+ printk("failed to activate hw channel\n");
+- MOD_DEC_USE_COUNT;
++// MOD_DEC_USE_COUNT;
+ tn7atm_lut_clear(vcc, tn7atm_activate_vc_parm.chan);
+ //spin_unlock_irqrestore(&chan_init_lock, flags);
+ return -EBUSY;
+@@ -1114,7 +1066,7 @@ void tn7atm_close (struct atm_vcc *vcc)
+ tn7atm_lut_clear (vcc, dmachan);
+ //spin_unlock_irqrestore (&closeLock, closeFlag);
+
+- MOD_DEC_USE_COUNT;
++// MOD_DEC_USE_COUNT;
+
+ dgprintf (1, "Leave tn7atm_close\n");
+ }
+@@ -1528,8 +1480,7 @@ int tn7atm_receive (void *os_dev, int ch
+ * firewall is on */
+
+ dgprintf (3, "pushing the skb...\n");
+-
+- skb->stamp = vcc->timestamp = xtime;
++ __net_timestamp(skb);
+
+ xdump ((unsigned char *) skb->data, skb->len, 5);
+
+@@ -1725,8 +1676,7 @@ static void tn7atm_exit (void)
+
+ kfree (dev->dev_data);
+
+- // atm_dev_deregister (dev);
+- shutdown_atm_dev (dev);
++ atm_dev_deregister (dev);
+
+ /*
+ * remove proc entries
+@@ -1885,9 +1835,6 @@ static int __init tn7atm_detect (void)
+ /*
+ * Set up proc entry for atm stats
+ */
+- if (tn7atm_xlate_proc_name
+- (drv_proc_root_folder, &root_proc_dir_entry, &residual))
+- {
+ printk ("Creating new root folder %s in the proc for the driver stats \n",
+ drv_proc_root_folder);
+ root_proc_dir_entry = proc_mkdir (drv_proc_root_folder, NULL);
+@@ -1897,7 +1844,6 @@ static int __init tn7atm_detect (void)
+ return -ENOMEM;
+ }
+ proc_root_already_exists = FALSE;
+- }
+
+ /*
+ * AV: Clean-up. Moved all the definitions to the data structure.
+@@ -2479,7 +2425,5 @@ static int tn7atm_proc_qos_write(struct
+ return count;
+ }
+
+-#ifdef MODULE
+ module_init (tn7atm_detect);
+ module_exit (tn7atm_exit);
+-#endif /* MODULE */
+--- a/tn7atm.h
++++ b/tn7atm.h
+@@ -19,7 +19,8 @@
+ //#include "mips_support.h"
+ #include <linux/list.h>
+
+-#include <linux/config.h>
++#define MIPS_EXCEPTION_OFFSET 8
++#define LNXINTNUM(x)((x) + MIPS_EXCEPTION_OFFSET)
+
+ #ifdef CONFIG_MODVERSIONS
+ #include <linux/modversions.h>
+--- a/tn7dsl.c
++++ b/tn7dsl.c
+@@ -94,7 +94,6 @@
+ * 1/02/07 JZ CQ11054: Data Precision and Range Changes for TR-069 Conformance
+ * UR8_MERGE_END CQ11054*
+ *********************************************************************************************/
+-#include <linux/config.h>
+ #include <linux/kernel.h>
+ #include <linux/module.h>
+ #include <linux/init.h>
+@@ -102,8 +101,6 @@
+ #include <linux/delay.h>
+ #include <linux/spinlock.h>
+ #include <linux/smp_lock.h>
+-#include <asm/io.h>
+-#include <asm/mips-boards/prom.h>
+ #include <linux/proc_fs.h>
+ #include <linux/string.h>
+ #include <linux/ctype.h>
+@@ -111,6 +108,12 @@
+ #include <linux/timer.h>
+ #include <linux/vmalloc.h>
+ #include <linux/file.h>
++#include <linux/firmware.h>
++
++#include <asm/io.h>
++#include <asm/ar7/ar7.h>
++#include <asm/ar7/prom.h>
++
+ /* Modules specific header files */
+ #include "tn7atm.h"
+ #include "tn7api.h"
+@@ -173,7 +176,7 @@ led_reg_t ledreg[2];
+ static struct led_funcs ledreg[2];
+ #endif
+
+-#define DEV_DSLMOD 1
++#define DEV_DSLMOD CTL_UNNUMBERED
+ #define MAX_STR_SIZE 256
+ #define DSL_MOD_SIZE 256
+
+@@ -299,7 +302,7 @@ static PITIDSLHW_T pIhw;
+ static volatile int bshutdown;
+ static char info[MAX_STR_SIZE];
+ /* Used for DSL Polling enable */
+-static DECLARE_MUTEX_LOCKED (adsl_sem_overlay);
++static struct semaphore adsl_sem_overlay;
+
+ //kthread_t overlay_thread;
+ /* end of module wide declars */
+@@ -323,6 +326,14 @@ static int tn7dsl_proc_snr_print (char *
+ #define gDot1(a) ((a>0)?(a%10):((-a)%10))
+ // UR8_MERGE_END CQ11054*
+
++int avalanche_request_intr_pacing(int irq_nr, unsigned int blk_num,
++ unsigned int pace_value)
++{
++ printk("avalanche_request_pacing(%d, %u, %u); // not implemented\n", irq_nr, blk_num, pace_value);
++ return 0;
++}
++
++
+ int os_atoi(const char *pStr)
+ {
+ int MulNeg = (*pStr == '-' ? -1 : 1);
+@@ -359,39 +370,6 @@ void dprintf (int uDbgLevel, char *szFmt
+ #endif
+ }
+
+-int strcmp(const char *s1, const char *s2)
+-{
+-
+- int size = strlen(s1);
+-
+- return(strncmp(s1, s2, size));
+-}
+-
+-int strncmp(const char *s1, const char *s2, size_t size)
+-{
+- int i = 0;
+- int max_size = (int)size;
+-
+- while((s1[i] != 0) && i < max_size)
+- {
+- if(s2[i] == 0)
+- {
+- return -1;
+- }
+- if(s1[i] != s2[i])
+- {
+- return 1;
+- }
+- i++;
+- }
+- if(s2[i] != 0)
+- {
+- return 1;
+- }
+-
+- return 0;
+-}
+-
+ // * UR8_MERGE_START CQ10640 Jack Zhang
+ int tn7dsl_dump_dsp_memory(char *input_str) //cph99
+ {
+@@ -441,101 +419,74 @@ unsigned int shim_osGetCpuFrequency(void
+ return CpuFrequency;
+ }
+
+-int shim_osLoadFWImage(unsigned char *ptr)
++static void avsar_release(struct device *dev)
+ {
+- unsigned int bytesRead;
+- mm_segment_t oldfs;
+- static struct file *filp;
+- unsigned int imageLength=0x5ffff;
+-
+-
+- dgprintf(4, "tn7dsl_read_dsp()\n");
+-
+- dgprintf(4,"open file %s\n", DSP_FIRMWARE_PATH);
+-
+- filp=filp_open(DSP_FIRMWARE_PATH,00,O_RDONLY);
+- if(filp ==NULL)
+- {
+- printk("Failed: Could not open DSP binary file\n");
+- return -1;
+- }
+-
+- if (filp->f_dentry != NULL)
+- {
+- if (filp->f_dentry->d_inode != NULL)
+- {
+- printk ("DSP binary filesize = %d bytes\n",
+- (int) filp->f_dentry->d_inode->i_size);
+- imageLength = (unsigned int)filp->f_dentry->d_inode->i_size + 0x200;
+- }
+- }
+-
+- if (filp->f_op->read==NULL)
+- return -1; /* File(system) doesn't allow reads */
+-
+- /*
+- * Disable parameter checking
+- */
+- oldfs = get_fs();
+- set_fs(KERNEL_DS);
+-
+- /*
+- * Now read bytes from postion "StartPos"
+- */
+- filp->f_pos = 0;
+-
+- bytesRead = filp->f_op->read(filp,ptr,imageLength,&filp->f_pos);
+-
+- dgprintf(4,"file length = %d\n", bytesRead);
+-
+- set_fs(oldfs);
+-
+- /*
+- * Close the file
+- */
+- fput(filp);
+-
+- return bytesRead;
++ printk(KERN_DEBUG "avsar firmware released\n");
+ }
+
++static struct device avsar = {
++ .bus_id = "vlynq",
++ .release = avsar_release,
++};
+
+-unsigned int shim_read_overlay_page (void *ptr, unsigned int secOffset,
+- unsigned int secLength)
++int shim_osLoadFWImage(unsigned char *ptr)
+ {
+- unsigned int bytesRead;
+- mm_segment_t oldfs;
+- struct file *filp;
+-
+- dgprintf(4,"shim_read_overlay_page\n");
+- //dgprintf(4,"sec offset=%d, sec length =%d\n", secOffset, secLength);
++ const struct firmware *fw_entry;
++ size_t size;
+
+- filp=filp_open(DSP_FIRMWARE_PATH,00,O_RDONLY);
+- if(filp ==NULL)
+- {
+- printk("Failed: Could not open DSP binary file\n");
+- return -1;
+- }
+-
+- if (filp->f_op->read==NULL)
+- return -1; /* File(system) doesn't allow reads */
+-
+- /*
+- * Now read bytes from postion "StartPos"
+- */
+-
+- if(filp->f_op->llseek)
+- filp->f_op->llseek(filp,secOffset, 0);
+- oldfs = get_fs();
+- set_fs(KERNEL_DS);
+- filp->f_pos = secOffset;
+- bytesRead = filp->f_op->read(filp,ptr,secLength,&filp->f_pos);
+-
+- set_fs(oldfs);
+- /*
+- * Close the file
+- */
+- fput(filp);
+- return bytesRead;
++ printk("requesting firmware image \"ar0700xx.bin\"\n");
++ if(device_register(&avsar) < 0) {
++ printk(KERN_ERR
++ "avsar: device_register fails\n");
++ return -1;
++ }
++
++ if(request_firmware(&fw_entry, "ar0700xx.bin", &avsar)) {
++ printk(KERN_ERR
++ "avsar: Firmware not available\n");
++ device_unregister(&avsar);
++ return -1;
++ }
++ size = fw_entry->size;
++ device_unregister(&avsar);
++ if(size > 0x5ffff) {
++ printk(KERN_ERR
++ "avsar: Firmware too big (%d bytes)\n", size);
++ release_firmware(fw_entry);
++ return -1;
++ }
++ memcpy(ptr, fw_entry->data, size);
++ release_firmware(fw_entry);
++ return size;
++}
++
++unsigned int shim_read_overlay_page(void *ptr, unsigned int secOffset, unsigned int secLength)
++{
++ const struct firmware *fw_entry;
++
++ printk("requesting firmware image \"ar0700xx.bin\"\n");
++ if(device_register(&avsar) < 0) {
++ printk(KERN_ERR
++ "avsar: device_register fails\n");
++ return -1;
++ }
++
++ if(request_firmware(&fw_entry, "ar0700xx.bin", &avsar)) {
++ printk(KERN_ERR
++ "avsar: Firmware not available\n");
++ device_unregister(&avsar);
++ return -1;
++ }
++ device_unregister(&avsar);
++ if(fw_entry->size > secLength) {
++ printk(KERN_ERR
++ "avsar: Firmware too big (%d bytes)\n", fw_entry->size);
++ release_firmware(fw_entry);
++ return -1;
++ }
++ memcpy(ptr + secOffset, fw_entry->data, secLength);
++ release_firmware(fw_entry);
++ return secLength;
+ }
+
+ int shim_osLoadDebugFWImage(unsigned char *ptr)
+@@ -3064,6 +3015,7 @@ int tn7dsl_init(void *priv)
+ int high_precision_selected = 0;
+ // UR8_MERGE_END CQ11054*
+
++ sema_init(&adsl_sem_overlay, 0);
+ /*
+ * start dsl
+ */
+@@ -3442,7 +3394,7 @@ static int dslmod_sysctl(ctl_table *ctl,
+ */
+ if(write)
+ {
+- ret = proc_dostring(ctl, write, filp, buffer, lenp);
++ ret = proc_dostring(ctl, write, filp, buffer, lenp, 0);
+
+ switch (ctl->ctl_name)
+ {
+@@ -3528,14 +3480,14 @@ static int dslmod_sysctl(ctl_table *ctl,
+ else
+ {
+ len += sprintf(info+len, mod_req);
+- ret = proc_dostring(ctl, write, filp, buffer, lenp);
++ ret = proc_dostring(ctl, write, filp, buffer, lenp, 0);
+ }
+ return ret;
+ }
+
+
+ ctl_table dslmod_table[] = {
+- {DEV_DSLMOD, "dslmod", info, DSL_MOD_SIZE, 0644, NULL, &dslmod_sysctl}
++ {DEV_DSLMOD, "dslmod", info, DSL_MOD_SIZE, 0644, NULL, NULL, &dslmod_sysctl, &sysctl_string}
+ ,
+ {0}
+ };
+@@ -3558,8 +3510,7 @@ void tn7dsl_dslmod_sysctl_register(void)
+ if (initialized == 1)
+ return;
+
+- dslmod_sysctl_header = register_sysctl_table(dslmod_root_table, 1);
+- dslmod_root_table->child->de->owner = THIS_MODULE;
++ dslmod_sysctl_header = register_sysctl_table(dslmod_root_table);
+
+ /*
+ * set the defaults
+@@ -4821,4 +4772,4 @@ int tn7dsl_proc_PMDus(char* buf, char **
+ }
+ #endif //NO_ADV_STATS
+ #endif //TR69_PMD_IN
+-// * UR8_MERGE_END CQ11057 *
+\ No newline at end of file
++// * UR8_MERGE_END CQ11057 *
+--- a/tn7sar.c
++++ b/tn7sar.c
+@@ -42,7 +42,6 @@
+ * UR8_MERGE_END CQ10700
+ *******************************************************************************/
+
+-#include <linux/config.h>
+ #include <linux/kernel.h>
+ #include <linux/module.h>
+ #include <linux/init.h>
+@@ -50,12 +49,13 @@
+ #include <linux/delay.h>
+ #include <linux/spinlock.h>
+ #include <linux/smp_lock.h>
+-#include <asm/io.h>
+-#include <asm/mips-boards/prom.h>
+ #include <linux/proc_fs.h>
+ #include <linux/string.h>
+ #include <linux/ctype.h>
+
++#include <asm/io.h>
++#include <asm/ar7/ar7.h>
++#include <asm/ar7/prom.h>
+
+ #define _CPHAL_AAL5
+ #define _CPHAL_SAR
diff --git a/package/system/ar7-atm/patches-D7.04.03.00/.svn/text-base/110-interrupt_fix.patch.svn-base b/package/system/ar7-atm/patches-D7.04.03.00/.svn/text-base/110-interrupt_fix.patch.svn-base
new file mode 100644
index 0000000..9acb862
--- /dev/null
+++ b/package/system/ar7-atm/patches-D7.04.03.00/.svn/text-base/110-interrupt_fix.patch.svn-base
@@ -0,0 +1,37 @@
+--- a/tn7atm.c
++++ b/tn7atm.c
+@@ -566,7 +566,7 @@ static int turbodsl_check_priority_type(
+ * Description: tnetd73xx SAR interrupt.
+ *
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+-static void tn7atm_sar_irq (int irq, void *voiddev, struct pt_regs *regs)
++static irqreturn_t tn7atm_sar_irq (int irq, void *voiddev)
+ {
+ struct atm_dev *atmdev;
+ Tn7AtmPrivate *priv;
+@@ -593,6 +593,7 @@ static void tn7atm_sar_irq (int irq, voi
+ #ifdef TIATM_INST_SUPP
+ psp_trace_par (ATM_DRV_SAR_ISR_EXIT, retval);
+ #endif
++ return IRQ_HANDLED;
+ }
+
+ /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+@@ -602,7 +603,7 @@ static void tn7atm_sar_irq (int irq, voi
+ * Description: tnetd73xx DSL interrupt.
+ *
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+-static void tn7atm_dsl_irq (int irq, void *voiddev, struct pt_regs *regs)
++static irqreturn_t tn7atm_dsl_irq (int irq, void *voiddev)
+ {
+ struct atm_dev *atmdev;
+ Tn7AtmPrivate *priv;
+@@ -624,6 +625,8 @@ static void tn7atm_dsl_irq (int irq, voi
+ #ifdef TIATM_INST_SUPP
+ psp_trace_par (ATM_DRV_DSL_ISR_EXIT, retval);
+ #endif
++
++ return IRQ_HANDLED;
+ }
+
+ /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/package/system/ar7-atm/patches-D7.04.03.00/.svn/text-base/120-no_dumb_inline.patch.svn-base b/package/system/ar7-atm/patches-D7.04.03.00/.svn/text-base/120-no_dumb_inline.patch.svn-base
new file mode 100644
index 0000000..2968fdc
--- /dev/null
+++ b/package/system/ar7-atm/patches-D7.04.03.00/.svn/text-base/120-no_dumb_inline.patch.svn-base
@@ -0,0 +1,11 @@
+--- a/tn7api.h
++++ b/tn7api.h
+@@ -107,7 +107,7 @@ int tn7dsl_proc_dbg_rmsgs4(char* buf, ch
+
+ int tn7dsl_proc_write_stats(struct file *fp, const char * buf, unsigned long count, void * data);
+ int tn7dsl_proc_modem(char* buf, char **start, off_t offset, int count,int *eof, void *data);
+-inline int tn7dsl_handle_interrupt(void);
++int tn7dsl_handle_interrupt(void);
+
+ void tn7dsl_dslmod_sysctl_register(void);
+ void tn7dsl_dslmod_sysctl_unregister(void);
diff --git a/package/system/ar7-atm/patches-D7.04.03.00/.svn/text-base/130-powercutback.patch.svn-base b/package/system/ar7-atm/patches-D7.04.03.00/.svn/text-base/130-powercutback.patch.svn-base
new file mode 100644
index 0000000..ec00df9
--- /dev/null
+++ b/package/system/ar7-atm/patches-D7.04.03.00/.svn/text-base/130-powercutback.patch.svn-base
@@ -0,0 +1,44 @@
+--- a/dsl_hal_advcfg.c
++++ b/dsl_hal_advcfg.c
+@@ -36,9 +36,9 @@
+ * 05Jul05 0.00.09 CPH CQ9775: Change dslhal_advcfg_configDsTones input parameters & support for ADSL2+
+ * 24Jul05 0.00.10 CPH Fixed comments in dslhal_advcfg_configDsTones function header
+ *******************************************************************************/
+-#include <dev_host_interface.h>
+-#include <dsl_hal_register.h>
+-#include <dsl_hal_support.h>
++#include "dev_host_interface.h"
++#include "dsl_hal_register.h"
++#include "dsl_hal_support.h"
+
+ /*****************************************************************************/
+ /* ACT API functions -- To be moved into their own independent module --RamP */
+--- a/Makefile
++++ b/Makefile
+@@ -4,6 +4,7 @@
+
+ CONFIG_SANGAM_ATM=m
+ #EXTRA_CFLAGS += -DEL -I. -DPOST_SILICON -DCOMMON_NSP -DCONFIG_LED_MODULE -DDEREGISTER_LED -DNO_ACT
+-EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -DNO_ACT -D__NO__VOICE_PATCH__ -DEL
++#EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -DNO_ACT -D__NO__VOICE_PATCH__ -DEL
++EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -D__NO__VOICE_PATCH__ -DEL
+ obj-$(CONFIG_SANGAM_ATM) := tiatm.o
+-tiatm-objs += cpsar.o aal5sar.o tn7sar.o tn7atm.o tn7dsl.o dsl_hal_api.o dsl_hal_support.o
++tiatm-objs += cpsar.o aal5sar.o tn7sar.o tn7atm.o tn7dsl.o dsl_hal_api.o dsl_hal_support.o dsl_hal_advcfg.o
+--- a/tn7dsl.c
++++ b/tn7dsl.c
+@@ -2869,6 +2869,14 @@ static int tn7dsl_set_dsl(void)
+ dslhal_api_setRateAdaptFlag(pIhw, os_atoi(ptr));
+ }
+
++ // set powercutback
++ ptr = NULL;
++ ptr = prom_getenv("powercutback");
++ if(ptr)
++ {
++ dslhal_advcfg_onOffPcb(pIhw, os_atoi(ptr));
++ }
++
+ // trellis
+ ptr = NULL;
+ ptr = prom_getenv("trellis");
diff --git a/package/system/ar7-atm/patches-D7.04.03.00/.svn/text-base/140-debug_mode.patch.svn-base b/package/system/ar7-atm/patches-D7.04.03.00/.svn/text-base/140-debug_mode.patch.svn-base
new file mode 100644
index 0000000..ce3697b
--- /dev/null
+++ b/package/system/ar7-atm/patches-D7.04.03.00/.svn/text-base/140-debug_mode.patch.svn-base
@@ -0,0 +1,16 @@
+--- a/tn7sar.c
++++ b/tn7sar.c
+@@ -103,10 +103,10 @@ enum
+
+ #define RESERVED_OAM_CHANNEL 15
+
+-#define AAL5_PARM "id=aal5, base = 0x03000000, offset = 0, int_line=15, ch0=[RxBufSize=1522; RxNumBuffers = 32; RxServiceMax = 50; TxServiceMax=50; TxNumBuffers=32; CpcsUU=0x5aa5; TxVc_CellRate=0x3000; TxVc_AtmHeader=0x00000640]"
+-#define SAR_PARM "id=sar,base = 0x03000000, reset_bit = 9, offset = 0; UniNni = 0, PdspEnable = 1"
++#define CH0_PARM "RxBufSize=1522, RxNumBuffers=32, RxServiceMax=50, TxServiceMax=50, TxNumBuffers=32, CpcsUU=0x5aa5, TxVc_CellRate=0x3000, TxVc_AtmHeader=0x00000640"
++#define AAL5_PARM "id=aal5, base=0x03000000, offset=0, int_line=15, ch0=[" CH0_PARM "]"
++#define SAR_PARM "id=sar, base=0x03000000, reset_bit=9, offset=0; UniNni=0, PdspEnable=1, Debug=0xFFFFFFFF"
+ #define RESET_PARM "id=ResetControl, base=0xA8611600"
+-#define CH0_PARM "RxBufSize=1522, RxNumBuffers = 32, RxServiceMax = 50, TxServiceMax=50, TxNumBuffers=32, CpcsUU=0x5aa5, TxVc_CellRate=0x3000, TxVc_AtmHeader=0x00000640"
+
+ #define MAX_PVC_TABLE_ENTRY 16
+
diff --git a/package/system/ar7-atm/patches-D7.04.03.00/.svn/text-base/150-tasklet_mode.patch.svn-base b/package/system/ar7-atm/patches-D7.04.03.00/.svn/text-base/150-tasklet_mode.patch.svn-base
new file mode 100644
index 0000000..97b8cec
--- /dev/null
+++ b/package/system/ar7-atm/patches-D7.04.03.00/.svn/text-base/150-tasklet_mode.patch.svn-base
@@ -0,0 +1,11 @@
+--- a/Makefile
++++ b/Makefile
+@@ -5,6 +5,7 @@
+ CONFIG_SANGAM_ATM=m
+ #EXTRA_CFLAGS += -DEL -I. -DPOST_SILICON -DCOMMON_NSP -DCONFIG_LED_MODULE -DDEREGISTER_LED -DNO_ACT
+ #EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -DNO_ACT -D__NO__VOICE_PATCH__ -DEL
+-EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -D__NO__VOICE_PATCH__ -DEL
++#EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -D__NO__VOICE_PATCH__ -DEL
++EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -D__NO__VOICE_PATCH__ -DEL -DCPATM_TASKLET_MODE
+ obj-$(CONFIG_SANGAM_ATM) := tiatm.o
+ tiatm-objs += cpsar.o aal5sar.o tn7sar.o tn7atm.o tn7dsl.o dsl_hal_api.o dsl_hal_support.o dsl_hal_advcfg.o
diff --git a/package/system/ar7-atm/patches-D7.04.03.00/.svn/text-base/160-module-params.patch.svn-base b/package/system/ar7-atm/patches-D7.04.03.00/.svn/text-base/160-module-params.patch.svn-base
new file mode 100644
index 0000000..67802ae
--- /dev/null
+++ b/package/system/ar7-atm/patches-D7.04.03.00/.svn/text-base/160-module-params.patch.svn-base
@@ -0,0 +1,589 @@
+--- a/tn7atm.c
++++ b/tn7atm.c
+@@ -87,6 +87,146 @@
+ MODULE_LICENSE("GPL");
+ MODULE_DESCRIPTION ("Tnetd73xx ATM Device Driver");
+ MODULE_AUTHOR ("Zhicheng Tang");
++
++int mp_sar_ipacemax = -1;
++module_param_named(ipacemax, mp_sar_ipacemax, int, 0);
++MODULE_PARM_DESC(ipacemax, "Interrupt pacing");
++
++char *mp_macc = NULL;
++module_param_named(macc, mp_macc, charp, 0);
++MODULE_PARM_DESC(macc, "MAC address");
++
++int mp_dsp_noboost = -1;
++module_param_named(dsp_noboost, mp_dsp_noboost, int, 0);
++MODULE_PARM_DESC(dsp_noboost, "Suppress DSP frequency boost");
++
++int mp_dsp_freq = -1;
++module_param_named(dsp_freq, mp_dsp_freq, int, 0);
++MODULE_PARM_DESC(dsp_freq, "Frequency to boost the DSP to");
++
++char *mp_featctl0 = NULL;
++module_param_named(featctl0, mp_featctl0, charp, 0);
++MODULE_PARM_DESC(featctl0, "DSL feature control 0");
++
++char *mp_featctl1 = NULL;
++module_param_named(featctl1, mp_featctl1, charp, 0);
++MODULE_PARM_DESC(featctl1, "DSL feature control 1");
++
++char *mp_phyctl0 = NULL;
++module_param_named(phyctl0, mp_phyctl0, charp, 0);
++MODULE_PARM_DESC(phyctl0, "DSL PHY control 0");
++
++char *mp_phyctl1 = NULL;
++module_param_named(phyctl1, mp_phyctl1, charp, 0);
++MODULE_PARM_DESC(phyctl1, "DSL PHY control 1");
++
++int mp_turbodsl = -1;
++module_param_named(turbodsl, mp_turbodsl, int, 0);
++MODULE_PARM_DESC(turbodsl, "Enable TurboDSL");
++
++int mp_sar_rxbuf = -1;
++module_param_named(sar_rxbuf, mp_sar_rxbuf, int, 0);
++MODULE_PARM_DESC(sar_rxbuf, "SAR RxBuf size");
++
++int mp_sar_rxmax = -1;
++module_param_named(sar_rxmax, mp_sar_rxmax, int, 0);
++MODULE_PARM_DESC(sar_rxmax, "SAR RxMax size");
++
++int mp_sar_txbuf = -1;
++module_param_named(sar_txbuf, mp_sar_txbuf, int, 0);
++MODULE_PARM_DESC(sar_txbuf, "SAR TxBuf size");
++
++int mp_sar_txmax = -1;
++module_param_named(sar_txmax, mp_sar_txmax, int, 0);
++MODULE_PARM_DESC(sar_txmax, "SAR TxMax size");
++
++char *mp_modulation = NULL;
++module_param_named(modulation, mp_modulation, charp, 0);
++MODULE_PARM_DESC(modulation, "Modulation");
++
++int mp_fine_gain_control = -1;
++module_param_named(fine_gain_control, mp_fine_gain_control, int, 0);
++MODULE_PARM_DESC(fine_gain_control, "Fine gain control");
++
++int mp_fine_gain_value = -1;
++module_param_named(fine_gain_value, mp_fine_gain_value, int, 0);
++MODULE_PARM_DESC(fine_gain_value, "Fine gain value");
++
++int mp_enable_margin_retrain = -1;
++module_param_named(enable_margin_retrain, mp_enable_margin_retrain, int, 0);
++MODULE_PARM_DESC(enable_margin_retrain, "Enable margin retrain");
++
++int mp_margin_threshold = -1;
++module_param_named(margin_threshold, mp_margin_threshold, int, 0);
++MODULE_PARM_DESC(margin_threshold, "Margin retrain treshold");
++
++int mp_enable_rate_adapt = -1;
++module_param_named(enable_rate_adapt, mp_enable_rate_adapt, int, 0);
++MODULE_PARM_DESC(enable_rate_adapt, "Enable rate adaption");
++
++int mp_powercutback = -1;
++module_param_named(powercutback, mp_powercutback, int, 0);
++MODULE_PARM_DESC(powercutback, "Enable / disable powercutback");
++
++int mp_trellis = -1;
++module_param_named(trellis, mp_trellis, int, 0);
++MODULE_PARM_DESC(trellis, "Enable / disable trellis coding");
++
++int mp_bitswap = -1;
++module_param_named(bitswap, mp_bitswap, int, 0);
++MODULE_PARM_DESC(bitswap, "Enable / disable bitswap");
++
++int mp_maximum_bits_per_carrier = -1;
++module_param_named(maximum_bits_per_carrier, mp_maximum_bits_per_carrier, int, 0);
++MODULE_PARM_DESC(maximum_bits_per_carrier, "Maximum bits per carrier");
++
++int mp_maximum_interleave_depth = -1;
++module_param_named(maximum_interleave_depth, mp_maximum_interleave_depth, int, 0);
++MODULE_PARM_DESC(maximum_interleave_depth, "Maximum interleave depth");
++
++int mp_pair_selection = -1;
++module_param_named(pair_selection, mp_pair_selection, int, 0);
++MODULE_PARM_DESC(pair_selection, "Pair selection");
++
++int mp_dgas_polarity = -1;
++module_param_named(dgas_polarity, mp_dgas_polarity, int, 0);
++MODULE_PARM_DESC(dgas_polarity, "DGAS polarity");
++
++int mp_los_alarm = -1;
++module_param_named(los_alarm, mp_los_alarm, int, 0);
++MODULE_PARM_DESC(los_alarm, "LOS alarm");
++
++char *mp_eoc_vendor_id = NULL;
++module_param_named(eoc_vendor_id, mp_eoc_vendor_id, charp, 0);
++MODULE_PARM_DESC(eoc_vendor_id, "EOC vendor id");
++
++int mp_eoc_vendor_revision = -1;
++module_param_named(eoc_vendor_revision, mp_eoc_vendor_revision, int, 0);
++MODULE_PARM_DESC(eoc_vendor_revision, "EOC vendor revision");
++
++char *mp_eoc_vendor_serialnum = NULL;
++module_param_named(eoc_vendor_serialnum, mp_eoc_vendor_serialnum, charp, 0);
++MODULE_PARM_DESC(eoc_vendor_serialnum, "EOC vendor serial number");
++
++char *mp_invntry_vernum = NULL;
++module_param_named(invntry_vernum, mp_invntry_vernum, charp, 0);
++MODULE_PARM_DESC(invntry_vernum, "Inventory revision number");
++
++int mp_dsl_bit_tmode = -1;
++module_param_named(dsl_bit_tmode, mp_dsl_bit_tmode, int, 0);
++MODULE_PARM_DESC(dsl_bit_tmode, "DSL bit training mode");
++
++int mp_high_precision = -1;
++module_param_named(high_precision, mp_high_precision, int, 0);
++MODULE_PARM_DESC(high_precision, "High precision");
++
++int mp_autopvc_enable = -1;
++module_param_named(autopvc_enable, mp_autopvc_enable, int, 0);
++MODULE_PARM_DESC(autopvc_enable, "Enable / disable automatic PVC");
++
++int mp_oam_lb_timeout = -1;
++module_param_named(oam_lb_timeout, mp_oam_lb_timeout, int, 0);
++MODULE_PARM_DESC(oam_lb_timeout, "OAM LB timeout");
+ #endif
+
+ #ifndef TRUE
+@@ -655,9 +795,9 @@
+ * interrupt pacing
+ */
+ ptr = prom_getenv ("sar_ipacemax");
+- if (ptr)
++ if (ptr || mp_sar_ipacemax != -1)
+ {
+- def_sar_inter_pace = os_atoi (ptr);
++ def_sar_inter_pace = mp_sar_ipacemax == -1 ? os_atoi (ptr) : mp_sar_ipacemax;
+ }
+ /* avalanche_request_pacing (priv->sar_irq, ATM_SAR_INT_PACING_BLOCK_NUM,
+ def_sar_inter_pace);*/
+@@ -795,9 +935,18 @@
+ {
+ int i;
+ char esi_addr[ESI_LEN] = { 0x00, 0x00, 0x11, 0x22, 0x33, 0x44 };
+- char *esiaddr_str = NULL;
++ char *esiaddr_str = mp_macc;
+
+- esiaddr_str = prom_getenv ("maca");
++ if (esiaddr_str == NULL)
++ esiaddr_str = prom_getenv ("macdsl");
++ if (esiaddr_str == NULL)
++ esiaddr_str = prom_getenv ("macc");
++ if (esiaddr_str == NULL)
++ esiaddr_str = prom_getenv ("HWA_1");
++ if (esiaddr_str == NULL)
++ esiaddr_str = prom_getenv ("macb");
++ if (esiaddr_str == NULL)
++ esiaddr_str = prom_getenv ("maca");
+
+ if (!esiaddr_str)
+ {
+@@ -1930,15 +2079,15 @@
+ //UR8_MERGE_END CQ10450*
+
+ cp = prom_getenv ("dsp_noboost");
+- if (cp)
++ if (cp || mp_dsp_noboost != -1)
+ {
+- dsp_noboost = os_atoi (cp);
++ dsp_noboost = mp_dsp_noboost == -1 ? os_atoi (cp) : mp_dsp_noboost;
+ }
+
+ cp = (char *) prom_getenv ("dsp_freq");
+- if (cp)
++ if (cp || mp_dsp_freq != -1)
+ {
+- dspfreq = os_atoi (cp);
++ dspfreq = mp_dsp_freq == -1 ? os_atoi (cp) : mp_dsp_freq;
+ if (dspfreq == 250)
+ {
+ boostDsp = 1;
+@@ -2187,8 +2336,9 @@
+ // Inter-Op DSL phy Control
+ // Note the setting of _dsl_Feature_0 and _dsl_Feature_1 must before
+ // dslhal_api_dslStartup (in tn7dsl_init()).
+- if ((ptr = prom_getenv ("DSL_FEATURE_CNTL_0")) != NULL)
++ if ((ptr = prom_getenv ("DSL_FEATURE_CNTL_0")) != NULL || mp_featctl0 != NULL)
+ {
++ if (mp_featctl0 != NULL) ptr = mp_featctl0;
+ if ((ptr[0] == '0') && (ptr[1] == 'x')) // skip 0x before pass to
+ // os_atoh
+ ptr += 2;
+@@ -2196,8 +2346,9 @@
+ _dsl_Feature_0_defined = 1;
+ }
+
+- if ((ptr = prom_getenv ("DSL_FEATURE_CNTL_1")) != NULL)
++ if ((ptr = prom_getenv ("DSL_FEATURE_CNTL_1")) != NULL || mp_featctl1 != NULL)
+ {
++ if (mp_featctl1 != NULL) ptr = mp_featctl1;
+ if ((ptr[0] == '0') && (ptr[1] == 'x')) // skip 0x before pass to
+ // os_atoh
+ ptr += 2;
+@@ -2209,8 +2360,9 @@
+ // DSL phy Feature Control
+ // Note the setting of _dsl_PhyControl_0 and _dsl_PhyControl_1 must before
+ // dslhal_api_dslStartup (in tn7dsl_init()).
+- if ((ptr = prom_getenv ("DSL_PHY_CNTL_0")) != NULL)
++ if ((ptr = prom_getenv ("DSL_PHY_CNTL_0")) != NULL || mp_phyctl0 != NULL)
+ {
++ if (mp_phyctl0 != NULL) ptr = mp_phyctl0;
+ if ((ptr[0] == '0') && (ptr[1] == 'x')) // skip 0x before pass to
+ // os_atoh
+ ptr += 2;
+@@ -2218,8 +2370,9 @@
+ _dsl_PhyControl_0_defined = 1;
+ }
+
+- if ((ptr = prom_getenv ("DSL_PHY_CNTL_1")) != NULL)
++ if ((ptr = prom_getenv ("DSL_PHY_CNTL_1")) != NULL || mp_phyctl1 != NULL)
+ {
++ if (mp_phyctl1 != NULL) ptr = mp_phyctl1;
+ if ((ptr[0] == '0') && (ptr[1] == 'x')) // skip 0x before pass to
+ // os_atoh
+ ptr += 2;
+@@ -2247,9 +2400,9 @@
+ priv->bTurboDsl = 1;
+ // read config for turbo dsl
+ ptr = prom_getenv ("TurboDSL");
+- if (ptr)
++ if (ptr || mp_turbodsl != -1)
+ {
+- priv->bTurboDsl = os_atoi (ptr);
++ priv->bTurboDsl = mp_turbodsl == -1 ? os_atoi (ptr) : mp_turbodsl;
+ }
+
+ // @Added to make Rx buffer number & Service max configurable through
+@@ -2257,30 +2410,30 @@
+ priv->sarRxBuf = RX_BUFFER_NUM;
+ ptr = NULL;
+ ptr = prom_getenv ("SarRxBuf");
+- if (ptr)
++ if (ptr || mp_sar_rxbuf != -1)
+ {
+- priv->sarRxBuf = os_atoi (ptr);
++ priv->sarRxBuf = mp_sar_rxbuf == -1 ? os_atoi (ptr) : mp_sar_rxbuf;
+ }
+ priv->sarRxMax = RX_SERVICE_MAX;
+ ptr = NULL;
+ ptr = prom_getenv ("SarRxMax");
+- if (ptr)
++ if (ptr || mp_sar_rxmax != -1)
+ {
+- priv->sarRxMax = os_atoi (ptr);
++ priv->sarRxMax = mp_sar_rxmax == -1 ? os_atoi (ptr) : mp_sar_rxmax;
+ }
+ priv->sarTxBuf = TX_BUFFER_NUM;
+ ptr = NULL;
+ ptr = prom_getenv ("SarTxBuf");
+- if (ptr)
++ if (ptr || mp_sar_txbuf != -1)
+ {
+- priv->sarTxBuf = os_atoi (ptr);
++ priv->sarTxBuf = mp_sar_txbuf == -1 ? os_atoi (ptr) : mp_sar_txbuf;
+ }
+ priv->sarTxMax = TX_SERVICE_MAX;
+ ptr = NULL;
+ ptr = prom_getenv ("SarTxMax");
+- if (ptr)
++ if (ptr || mp_sar_txmax != -1)
+ {
+- priv->sarTxMax = os_atoi (ptr);
++ priv->sarTxMax = mp_sar_txmax == -1 ? os_atoi (ptr) : mp_sar_txmax;
+ }
+
+ return 0;
+--- a/tn7dsl.c
++++ b/tn7dsl.c
+@@ -136,6 +136,27 @@
+ #define NEW_TRAINING_VAL_T1413 128
+ #define NEW_TRAINING_VAL_MMODE 255
+
++extern char *mp_modulation;
++extern int mp_fine_gain_control;
++extern int mp_fine_gain_value;
++extern int mp_enable_margin_retrain;
++extern int mp_margin_threshold;
++extern int mp_enable_rate_adapt;
++extern int mp_powercutback;
++extern int mp_trellis;
++extern int mp_bitswap;
++extern int mp_maximum_bits_per_carrier;
++extern int mp_maximum_interleave_depth;
++extern int mp_pair_selection;
++extern int mp_dgas_polarity;
++extern int mp_los_alarm;
++extern char *mp_eoc_vendor_id;
++extern int mp_eoc_vendor_revision;
++extern char *mp_eoc_vendor_serialnum;
++extern char *mp_invntry_vernum;
++extern int mp_dsl_bit_tmode;
++extern int mp_high_precision;
++
+ int testflag1 = 0;
+ extern int __guDbgLevel;
+ extern sar_stat_t sarStat;
+@@ -2818,84 +2839,80 @@ static int tn7dsl_set_dsl(void)
+
+ // modulation
+ ptr = prom_getenv("modulation");
+- if (ptr)
++ if (ptr || mp_modulation != NULL)
+ {
+- tn7dsl_set_modulation(ptr, FALSE);
++ tn7dsl_set_modulation(mp_modulation == NULL ? ptr : mp_modulation, FALSE);
+ }
+
+ // Fine Gains
+ ptr = prom_getenv("fine_gain_control");
+- if (ptr)
++ if (ptr || mp_fine_gain_control != -1)
+ {
+- value = os_atoi(ptr);
++ value = mp_fine_gain_control == -1 ? os_atoi(ptr) : mp_fine_gain_control;
+ tn7dsl_ctrl_fineGain(value);
+ }
+ ptr = NULL;
+ ptr = prom_getenv("fine_gain_value");
+- if(ptr)
+- tn7dsl_set_fineGainValue(os_atoh(ptr));
++ if(ptr || mp_fine_gain_value != -1)
++ tn7dsl_set_fineGainValue(mp_fine_gain_value == -1 ? os_atoh(ptr) : mp_fine_gain_value);
+
+ // margin retrain
+ ptr = NULL;
+ ptr = prom_getenv("enable_margin_retrain");
+- if(ptr)
++ value = mp_enable_margin_retrain == -1 ? (ptr ? os_atoi(ptr) : 0) : mp_enable_margin_retrain;
++
++ if (value == 1)
+ {
+- value = os_atoi(ptr);
+- if(value == 1)
++ dslhal_api_setMarginMonitorFlags(pIhw, 0, 1);
++ bMarginRetrainEnable = 1;
++ //printk("enable showtime margin monitor.\n");
++
++ ptr = NULL;
++ ptr = prom_getenv("margin_threshold");
++ value = mp_margin_threshold == -1 ? (ptr ? os_atoi(ptr) : 0) : mp_margin_threshold;
++
++ if(value >= 0)
+ {
+- dslhal_api_setMarginMonitorFlags(pIhw, 0, 1);
+- bMarginRetrainEnable = 1;
+- //printk("enable showtime margin monitor.\n");
+- ptr = NULL;
+- ptr = prom_getenv("margin_threshold");
+- if(ptr)
+- {
+- value = os_atoi(ptr);
+- //printk("Set margin threshold to %d x 0.5 db\n",value);
+- if(value >= 0)
+- {
+- dslhal_api_setMarginThreshold(pIhw, value);
+- bMarginThConfig=1;
+- }
+- }
++ dslhal_api_setMarginThreshold(pIhw, value);
++ bMarginThConfig=1;
+ }
+ }
+
+ // rate adapt
+ ptr = NULL;
+ ptr = prom_getenv("enable_rate_adapt");
+- if(ptr)
++ if(ptr || mp_enable_rate_adapt != -1)
+ {
+- dslhal_api_setRateAdaptFlag(pIhw, os_atoi(ptr));
++ dslhal_api_setRateAdaptFlag(pIhw, mp_enable_rate_adapt == -1 ? os_atoi(ptr) : mp_enable_rate_adapt);
+ }
+
+ // set powercutback
+ ptr = NULL;
+ ptr = prom_getenv("powercutback");
+- if(ptr)
++ if(ptr || mp_powercutback != -1)
+ {
+- dslhal_advcfg_onOffPcb(pIhw, os_atoi(ptr));
++ dslhal_advcfg_onOffPcb(pIhw, mp_powercutback == -1 ? os_atoi(ptr) : mp_powercutback);
+ }
+
+ // trellis
+ ptr = NULL;
+ ptr = prom_getenv("trellis");
+- if(ptr)
++ if(ptr || mp_trellis != -1)
+ {
+- dslhal_api_setTrellisFlag(pIhw, os_atoi(ptr));
+- trellis = os_atoi(ptr);
++ trellis = mp_trellis == -1 ? os_atoi(ptr) : mp_trellis;
++ dslhal_api_setTrellisFlag(pIhw, trellis);
+ //printk("trellis=%d\n");
+ }
+
+ // bitswap
+ ptr = NULL;
+ ptr = prom_getenv("bitswap");
+- if(ptr)
++ if(ptr || mp_bitswap != -1)
+ {
+ int offset[2] = {33, 0};
+ unsigned int bitswap;
+
+- bitswap = os_atoi(ptr);
++ bitswap = mp_bitswap == -1 ? os_atoi(ptr) : mp_bitswap;
+
+ tn7dsl_generic_read(2, offset);
+ dslReg &= dslhal_support_byteSwap32(0xFFFFFF00);
+@@ -2913,46 +2930,47 @@ static int tn7dsl_set_dsl(void)
+ // maximum bits per carrier
+ ptr = NULL;
+ ptr = prom_getenv("maximum_bits_per_carrier");
+- if(ptr)
++ if(ptr || mp_maximum_bits_per_carrier != -1)
+ {
+- dslhal_api_setMaxBitsPerCarrierUpstream(pIhw, os_atoi(ptr));
++ dslhal_api_setMaxBitsPerCarrierUpstream(pIhw, mp_maximum_bits_per_carrier == -1 ? os_atoi(ptr) : mp_maximum_bits_per_carrier);
+ }
+
+ // maximum interleave depth
+ ptr = NULL;
+ ptr = prom_getenv("maximum_interleave_depth");
+- if(ptr)
++ if(ptr || mp_maximum_interleave_depth != -1)
+ {
+- dslhal_api_setMaxInterleaverDepth(pIhw, os_atoi(ptr));
++ dslhal_api_setMaxInterleaverDepth(pIhw, mp_maximum_interleave_depth == -1 ? os_atoi(ptr) : mp_maximum_interleave_depth);
+ }
+
+ // inner and outer pairs
+ ptr = NULL;
+ ptr = prom_getenv("pair_selection");
+- if(ptr)
++ if(ptr || mp_pair_selection != -1)
+ {
+- dslhal_api_selectInnerOuterPair(pIhw, os_atoi(ptr));
++ dslhal_api_selectInnerOuterPair(pIhw, mp_pair_selection == -1 ? os_atoi(ptr) : mp_pair_selection);
+ }
+
+ ptr = NULL;
+ ptr = prom_getenv("dgas_polarity");
+- if(ptr)
++ if(ptr || mp_dgas_polarity != -1)
+ {
+ dslhal_api_configureDgaspLpr(pIhw, 1, 1);
+- dslhal_api_configureDgaspLpr(pIhw, 0, os_atoi(ptr));
++ dslhal_api_configureDgaspLpr(pIhw, 0, mp_dgas_polarity == -1 ? os_atoi(ptr) : mp_dgas_polarity);
+ }
+
+ ptr = NULL;
+ ptr = prom_getenv("los_alarm");
+- if(ptr)
++ if(ptr || mp_los_alarm != -1)
+ {
+- dslhal_api_disableLosAlarm(pIhw, os_atoi(ptr));
++ dslhal_api_disableLosAlarm(pIhw, mp_los_alarm == -1 ? os_atoi(ptr) : mp_los_alarm);
+ }
+
+ ptr = NULL;
+ ptr = prom_getenv("eoc_vendor_id");
+- if(ptr)
++ if(ptr || mp_eoc_vendor_id != NULL)
+ {
++ ptr = mp_eoc_vendor_id == NULL ? ptr : mp_eoc_vendor_id;
+ for(i=0;i<8;i++)
+ {
+ tmp[0]=ptr[i*2];
+@@ -2977,26 +2995,26 @@ static int tn7dsl_set_dsl(void)
+ }
+ ptr = NULL;
+ ptr = prom_getenv("eoc_vendor_revision");
+- if(ptr)
++ if(ptr || mp_eoc_vendor_revision != -1)
+ {
+- value = os_atoi(ptr);
++ value = mp_eoc_vendor_revision == -1 ? os_atoi(ptr) : mp_eoc_vendor_revision;
+ //printk("eoc rev=%d\n", os_atoi(ptr));
+ dslhal_api_setEocRevisionNumber(pIhw, (char *)&value);
+
+ }
+ ptr = NULL;
+ ptr = prom_getenv("eoc_vendor_serialnum");
+- if(ptr)
++ if(ptr || mp_eoc_vendor_serialnum != NULL)
+ {
+- dslhal_api_setEocSerialNumber(pIhw, ptr);
++ dslhal_api_setEocSerialNumber(pIhw, mp_eoc_vendor_serialnum == NULL ? ptr : mp_eoc_vendor_serialnum);
+ }
+
+ // CQ10037 Added invntry_vernum environment variable to be able to set version number in ADSL2, ADSL2+ modes.
+ ptr = NULL;
+ ptr = prom_getenv("invntry_vernum");
+- if(ptr)
++ if(ptr || mp_invntry_vernum != NULL)
+ {
+- dslhal_api_setEocRevisionNumber(pIhw, ptr);
++ dslhal_api_setEocRevisionNumber(pIhw, mp_invntry_vernum == NULL ? ptr : mp_invntry_vernum);
+ }
+
+ return 0;
+@@ -3041,7 +3059,7 @@ int tn7dsl_init(void *priv)
+ * backward compatibility.
+ */
+ cp = prom_getenv("DSL_BIT_TMODE");
+- if (cp)
++ if (cp || mp_dsl_bit_tmode != -1)
+ {
+ printk("%s : env var DSL_BIT_TMODE is set\n", __FUNCTION__);
+ /*
+@@ -3070,9 +3088,9 @@ int tn7dsl_init(void *priv)
+
+ // UR8_MERGE_START CQ11054 Jack Zhang
+ cp = prom_getenv("high_precision");
+- if (cp)
++ if (cp || mp_high_precision != -1)
+ {
+- high_precision_selected = os_atoi(cp);
++ high_precision_selected = mp_high_precision == -1 ? os_atoi(cp) : mp_high_precision;
+ }
+ if ( high_precision_selected)
+ {
+--- a/tn7sar.c
++++ b/tn7sar.c
+@@ -74,6 +74,8 @@ typedef void OS_SETUP;
+ /* PDSP Firmware files */
+ #include "tnetd7300_sar_firm.h"
+
++extern int mp_oam_lb_timeout;
++extern int mp_autopvc_enable;
+
+ enum
+ {
+@@ -817,9 +819,9 @@ int tn7sar_setup_oam_channel(Tn7AtmPriva
+ pHalDev = (HAL_DEVICE *)priv->pSarHalDev;
+
+ pauto_pvc = prom_getenv("autopvc_enable");
+- if(pauto_pvc) //CQ10273
++ if(pauto_pvc || mp_autopvc_enable != -1) //CQ10273
+ {
+- auto_pvc =tn7sar_strtoul(pauto_pvc, NULL, 10);
++ auto_pvc = mp_autopvc_enable == -1 ? tn7sar_strtoul(pauto_pvc, NULL, 10) : mp_autopvc_enable;
+ }
+
+ memset(&chInfo, 0xff, sizeof(chInfo));
+@@ -985,9 +987,9 @@ int tn7sar_init(struct atm_dev *dev, Tn7
+
+ /* read in oam lb timeout value */
+ pLbTimeout = prom_getenv("oam_lb_timeout");
+- if(pLbTimeout)
++ if(pLbTimeout || mp_oam_lb_timeout != -1)
+ {
+- lbTimeout =tn7sar_strtoul(pLbTimeout, NULL, 10);
++ lbTimeout = mp_oam_lb_timeout == -1 ? tn7sar_strtoul(pLbTimeout, NULL, 10) : mp_oam_lb_timeout;
+ oamLbTimeout = lbTimeout;
+ pHalFunc->Control(pHalDev,"OamLbTimeout", "Set", &lbTimeout);
+ }
diff --git a/package/system/ar7-atm/patches-D7.04.03.00/.svn/text-base/170-bus_id_removal.patch.svn-base b/package/system/ar7-atm/patches-D7.04.03.00/.svn/text-base/170-bus_id_removal.patch.svn-base
new file mode 100644
index 0000000..9f1f0fd
--- /dev/null
+++ b/package/system/ar7-atm/patches-D7.04.03.00/.svn/text-base/170-bus_id_removal.patch.svn-base
@@ -0,0 +1,30 @@
+--- a/tn7dsl.c
++++ b/tn7dsl.c
+@@ -109,6 +109,7 @@
+ #include <linux/vmalloc.h>
+ #include <linux/file.h>
+ #include <linux/firmware.h>
++#include <linux/version.h>
+
+ #include <asm/io.h>
+ #include <asm/ar7/ar7.h>
+@@ -446,7 +447,9 @@ static void avsar_release(struct device
+ }
+
+ static struct device avsar = {
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)
+ .bus_id = "vlynq",
++#endif
+ .release = avsar_release,
+ };
+
+@@ -455,6 +458,9 @@ int shim_osLoadFWImage(unsigned char *pt
+ const struct firmware *fw_entry;
+ size_t size;
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30)
++ dev_set_name(&avsar, "avsar");
++#endif
+ printk("requesting firmware image \"ar0700xx.bin\"\n");
+ if(device_register(&avsar) < 0) {
+ printk(KERN_ERR
diff --git a/package/system/ar7-atm/patches-D7.04.03.00/.svn/text-base/180-git_headers_include.patch.svn-base b/package/system/ar7-atm/patches-D7.04.03.00/.svn/text-base/180-git_headers_include.patch.svn-base
new file mode 100644
index 0000000..6bd8f48
--- /dev/null
+++ b/package/system/ar7-atm/patches-D7.04.03.00/.svn/text-base/180-git_headers_include.patch.svn-base
@@ -0,0 +1,54 @@
+--- a/tn7atm.c
++++ b/tn7atm.c
+@@ -71,10 +71,16 @@
+ #include <linux/proc_fs.h>
+ #include <linux/string.h>
+ #include <linux/ctype.h>
++#include <linux/version.h>
+
+ #include <asm/io.h>
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)
+ #include <asm/ar7/ar7.h>
+ #include <asm/ar7/prom.h>
++#else
++#include <asm/mach-ar7/ar7.h>
++#include <asm/mach-ar7/prom.h>
++#endif
+
+ #include "dsl_hal_api.h"
+ #include "tn7atm.h"
+--- a/tn7dsl.c
++++ b/tn7dsl.c
+@@ -112,8 +112,13 @@
+ #include <linux/version.h>
+
+ #include <asm/io.h>
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)
+ #include <asm/ar7/ar7.h>
+ #include <asm/ar7/prom.h>
++#else
++#include <asm/mach-ar7/ar7.h>
++#include <asm/mach-ar7/prom.h>
++#endif
+
+ /* Modules specific header files */
+ #include "tn7atm.h"
+--- a/tn7sar.c
++++ b/tn7sar.c
+@@ -52,10 +52,16 @@
+ #include <linux/proc_fs.h>
+ #include <linux/string.h>
+ #include <linux/ctype.h>
++#include <linux/version.h>
+
+ #include <asm/io.h>
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)
+ #include <asm/ar7/ar7.h>
+ #include <asm/ar7/prom.h>
++#else
++#include <asm/mach-ar7/ar7.h>
++#include <asm/mach-ar7/prom.h>
++#endif
+
+ #define _CPHAL_AAL5
+ #define _CPHAL_SAR
diff --git a/package/system/ar7-atm/patches-D7.04.03.00/.svn/text-base/190-2.6.32_proc_fixes.patch.svn-base b/package/system/ar7-atm/patches-D7.04.03.00/.svn/text-base/190-2.6.32_proc_fixes.patch.svn-base
new file mode 100644
index 0000000..11487bf
--- /dev/null
+++ b/package/system/ar7-atm/patches-D7.04.03.00/.svn/text-base/190-2.6.32_proc_fixes.patch.svn-base
@@ -0,0 +1,79 @@
+--- a/tn7dsl.c
++++ b/tn7dsl.c
+@@ -203,7 +203,11 @@ led_reg_t ledreg[2];
+ static struct led_funcs ledreg[2];
+ #endif
+
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
+ #define DEV_DSLMOD CTL_UNNUMBERED
++#else
++#define DEV_DSLMOD 0
++#endif
+ #define MAX_STR_SIZE 256
+ #define DSL_MOD_SIZE 256
+
+@@ -3431,9 +3435,16 @@ static int dslmod_sysctl(ctl_table *ctl,
+ */
+ if(write)
+ {
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)
+ ret = proc_dostring(ctl, write, filp, buffer, lenp, 0);
+-
++#else
++ ret = proc_dostring(ctl, write, buffer, lenp, 0);
++#endif
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
+ switch (ctl->ctl_name)
++#else
++ switch ((long)ctl->extra2)
++#endif
+ {
+ case DEV_DSLMOD:
+ ptr = strpbrk(info, " \t");
+@@ -3517,14 +3528,29 @@ static int dslmod_sysctl(ctl_table *ctl,
+ else
+ {
+ len += sprintf(info+len, mod_req);
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)
+ ret = proc_dostring(ctl, write, filp, buffer, lenp, 0);
++#else
++ ret = proc_dostring(ctl, write, buffer, lenp, 0);
++#endif
+ }
+ return ret;
+ }
+
+
+ ctl_table dslmod_table[] = {
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
+ {DEV_DSLMOD, "dslmod", info, DSL_MOD_SIZE, 0644, NULL, NULL, &dslmod_sysctl, &sysctl_string}
++#else
++ {
++ .procname = "dslmod",
++ .data = info,
++ .maxlen = DSL_MOD_SIZE,
++ .mode = 0644,
++ .proc_handler = &dslmod_sysctl,
++ .extra2 = (void *)DEV_DSLMOD,
++ }
++#endif
+ ,
+ {0}
+ };
+@@ -3532,7 +3558,16 @@ ctl_table dslmod_table[] = {
+ /* Make sure that /proc/sys/dev is there */
+ ctl_table dslmod_root_table[] = {
+ #ifdef CONFIG_PROC_FS
++ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
+ {CTL_DEV, "dev", NULL, 0, 0555, dslmod_table}
++ #else
++ {
++ .procname = "dev",
++ .maxlen = 0,
++ .mode = 0555,
++ .child = dslmod_table,
++ }
++ #endif
+ ,
+ #endif /* CONFIG_PROC_FS */
+ {0}
diff --git a/package/system/ar7-atm/patches-D7.04.03.00/.svn/text-base/200-2.6.37_args.patch.svn-base b/package/system/ar7-atm/patches-D7.04.03.00/.svn/text-base/200-2.6.37_args.patch.svn-base
new file mode 100644
index 0000000..59c1d58
--- /dev/null
+++ b/package/system/ar7-atm/patches-D7.04.03.00/.svn/text-base/200-2.6.37_args.patch.svn-base
@@ -0,0 +1,36 @@
+--- a/tn7atm.c
++++ b/tn7atm.c
+@@ -1867,7 +1867,11 @@ static int __init tn7atm_register (Tn7At
+
+ dgprintf (4, "device %s being registered\n", priv->name);
+
++ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37)
+ mydev = atm_dev_register (priv->proc_name, &tn7atm_ops, -1, NULL);
++ #else
++ mydev = atm_dev_register (priv->proc_name, NULL, &tn7atm_ops, -1, NULL);
++ #endif
+
+ if (mydev == NULL)
+ {
+--- a/tn7dsl.c
++++ b/tn7dsl.c
+@@ -466,14 +466,17 @@ int shim_osLoadFWImage(unsigned char *pt
+ {
+ const struct firmware *fw_entry;
+ size_t size;
++ int ret;
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30)
+ dev_set_name(&avsar, "avsar");
+ #endif
+ printk("requesting firmware image \"ar0700xx.bin\"\n");
+- if(device_register(&avsar) < 0) {
++ dev_set_name(&avsar, "avsar");
++ ret = device_register(&avsar);
++ if (ret < 0) {
+ printk(KERN_ERR
+- "avsar: device_register fails\n");
++ "avsar: device_register fails, error%i\n", ret);
+ return -1;
+ }
+
diff --git a/package/system/ar7-atm/patches-D7.04.03.00/.svn/text-base/210-3.3-remove-smp_lock.h.patch.svn-base b/package/system/ar7-atm/patches-D7.04.03.00/.svn/text-base/210-3.3-remove-smp_lock.h.patch.svn-base
new file mode 100644
index 0000000..525218c
--- /dev/null
+++ b/package/system/ar7-atm/patches-D7.04.03.00/.svn/text-base/210-3.3-remove-smp_lock.h.patch.svn-base
@@ -0,0 +1,33 @@
+--- a/tn7atm.c
++++ b/tn7atm.c
+@@ -67,7 +67,7 @@
+ #include <linux/atmdev.h>
+ #include <linux/delay.h>
+ #include <linux/spinlock.h>
+-#include <linux/smp_lock.h>
++#include <linux/interrupt.h>
+ #include <linux/proc_fs.h>
+ #include <linux/string.h>
+ #include <linux/ctype.h>
+--- a/tn7sar.c
++++ b/tn7sar.c
+@@ -48,7 +48,7 @@
+ #include <linux/atmdev.h>
+ #include <linux/delay.h>
+ #include <linux/spinlock.h>
+-#include <linux/smp_lock.h>
++#include <linux/interrupt.h>
+ #include <linux/proc_fs.h>
+ #include <linux/string.h>
+ #include <linux/ctype.h>
+--- a/tn7dsl.c
++++ b/tn7dsl.c
+@@ -100,7 +100,7 @@
+ #include <linux/atmdev.h>
+ #include <linux/delay.h>
+ #include <linux/spinlock.h>
+-#include <linux/smp_lock.h>
++#include <linux/interrupt.h>
+ #include <linux/proc_fs.h>
+ #include <linux/string.h>
+ #include <linux/ctype.h>
diff --git a/package/system/ar7-atm/patches-D7.04.03.00/100-compile_fix.patch b/package/system/ar7-atm/patches-D7.04.03.00/100-compile_fix.patch
new file mode 100644
index 0000000..df5fe53
--- /dev/null
+++ b/package/system/ar7-atm/patches-D7.04.03.00/100-compile_fix.patch
@@ -0,0 +1,768 @@
+--- a/cppi_cpaal5.c
++++ b/cppi_cpaal5.c
+@@ -352,7 +352,7 @@ static int halRxReturn(HAL_RECEIVEINFO *
+ {
+ /* malloc failed, add this RCB to Needs Buffer List */
+ TempRcb->FragCount = 1; /*MJH+030417*/
+- (HAL_RCB *)TempRcb->Eop = TempRcb; /* GSG +030430 */
++ TempRcb->Eop = TempRcb; /* GSG +030430 */
+
+ if(HalDev->NeedsCount < MAX_NEEDS) /* +MJH 030410 */
+ { /* +MJH 030410 */
+--- a/dsl_hal_api.c
++++ b/dsl_hal_api.c
+@@ -254,15 +254,15 @@
+ * of phyEnableDisableWord & phyControlWord to avoid changing API struct
+ * which may cause change required to application data structure.
+ ******************************************************************************/
+-#include <dev_host_interface.h>
+-#include <dsl_hal_register.h>
+-#include <dsl_hal_support.h>
++#include "dev_host_interface.h"
++#include "dsl_hal_register.h"
++#include "dsl_hal_support.h"
+
+ #ifndef NO_ADV_STATS
+-#include <dsl_hal_logtable.h>
++#include "dsl_hal_logtable.h"
+ #endif
+
+-#include <dsl_hal_version.h>
++#include "dsl_hal_version.h"
+
+ // UR8_MERGE_START CQ11054 Jack Zhang
+ static unsigned int highprecision_selected = 0; //By default we use low precision for backward compt.
+--- a/dsl_hal_support.c
++++ b/dsl_hal_support.c
+@@ -140,9 +140,9 @@
+ * oamFeature are overriden
+ // UR8_MERGE_END CQ10774 Ram
+ *******************************************************************************/
+-#include <dev_host_interface.h>
+-#include <dsl_hal_register.h>
+-#include <dsl_hal_support.h>
++#include "dev_host_interface.h"
++#include "dsl_hal_register.h"
++#include "dsl_hal_support.h"
+
+ #define NUM_READ_RETRIES 3
+ static unsigned int dslhal_support_adsl2ByteSwap32(unsigned int in32Bits);
+--- a/dsl_hal_support.h
++++ b/dsl_hal_support.h
+@@ -49,7 +49,7 @@
+ * 04Nov05 0.11.00 CPH Fixed T1413 mode got Zero DS/US rate when DSL_BIT_TMODE is set.
+ *******************************************************************************/
+
+-#include <dsl_hal_api.h>
++#include "dsl_hal_api.h"
+
+ #define virtual2Physical(a) (((int)a)&~0xe0000000)
+ /* External Function Prototype Declarations */
+--- a/Makefile
++++ b/Makefile
+@@ -1,18 +1,9 @@
+-# File: drivers/atm/ti_evm3/Makefile
+ #
+-# Makefile for the Texas Instruments EVM3 ADSL/ATM driver.
++# Makefile for the TIATM device driver.
+ #
+-#
+-# Copyright (c) 2000 Texas Instruments Incorporated.
+-# Jeff Harrell (jharrell@telogy.com)
+-# Viren Balar (vbalar@ti.com)
+-# Victor Wells (vwells@telogy.com)
+-#
+-include $(TOPDIR)/Rules.make
+-
+-
+-
+-
+-
+-
+
++CONFIG_SANGAM_ATM=m
++#EXTRA_CFLAGS += -DEL -I. -DPOST_SILICON -DCOMMON_NSP -DCONFIG_LED_MODULE -DDEREGISTER_LED -DNO_ACT
++EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -DNO_ACT -D__NO__VOICE_PATCH__ -DEL
++obj-$(CONFIG_SANGAM_ATM) := tiatm.o
++tiatm-objs += cpsar.o aal5sar.o tn7sar.o tn7atm.o tn7dsl.o dsl_hal_api.o dsl_hal_support.o
+--- a/tn7atm.c
++++ b/tn7atm.c
+@@ -61,7 +61,6 @@
+ * UR8_MERGE_END CQ11057*
+ *********************************************************************************************/
+
+-#include <linux/config.h>
+ #include <linux/kernel.h>
+ #include <linux/module.h>
+ #include <linux/init.h>
+@@ -69,11 +68,14 @@
+ #include <linux/delay.h>
+ #include <linux/spinlock.h>
+ #include <linux/smp_lock.h>
+-#include <asm/io.h>
+-#include <asm/mips-boards/prom.h>
+ #include <linux/proc_fs.h>
+ #include <linux/string.h>
+ #include <linux/ctype.h>
++
++#include <asm/io.h>
++#include <asm/ar7/ar7.h>
++#include <asm/ar7/prom.h>
++
+ #include "dsl_hal_api.h"
+ #include "tn7atm.h"
+ #include "tn7api.h"
+@@ -82,6 +84,7 @@
+ #include "dsl_hal_register.h"
+
+ #ifdef MODULE
++MODULE_LICENSE("GPL");
+ MODULE_DESCRIPTION ("Tnetd73xx ATM Device Driver");
+ MODULE_AUTHOR ("Zhicheng Tang");
+ #endif
+@@ -100,9 +103,9 @@ MODULE_AUTHOR ("Zhicheng Tang");
+
+ /*end of externs */
+
+-#ifndef TI_STATIC_ALLOCATIONS
+-#define TI_STATIC_ALLOCATIONS
+-#endif
++//#ifndef TI_STATIC_ALLOCATIONS
++//#define TI_STATIC_ALLOCATIONS
++//#endif
+
+ #define tn7atm_kfree_skb(x) dev_kfree_skb(x)
+
+@@ -114,7 +117,7 @@ static int EnableQoS = FALSE;
+ /* prototypes */
+ static int tn7atm_set_can_support_adsl2 (int can);
+
+-static int tn7atm_open (struct atm_vcc *vcc, short vpi, int vci);
++static int tn7atm_open (struct atm_vcc *vcc);
+
+ static void tn7atm_close (struct atm_vcc *vcc);
+
+@@ -257,13 +260,12 @@ static const struct atmdev_ops tn7atm_op
+ getsockopt: NULL,
+ setsockopt: NULL,
+ send: tn7atm_send,
+- sg_send: NULL,
+ phy_put: NULL,
+ phy_get: NULL,
+ change_qos: tn7atm_change_qos,
+ };
+
+-const char drv_proc_root_folder[] = "avalanche/";
++const char drv_proc_root_folder[] = "avalanche";
+ static struct proc_dir_entry *root_proc_dir_entry = NULL;
+ #define DRV_PROC_MODE 0644
+ static int proc_root_already_exists = TRUE;
+@@ -559,56 +561,6 @@ static int turbodsl_check_priority_type(
+
+ /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+- * Function: int tn7atm_walk_vccs(struct atm_dev *dev, short *vcc, int *vci)
+- *
+- * Description: retrieve VPI/VCI for connection
+- *
+- *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+-static int tn7atm_walk_vccs (struct atm_vcc *vcc, short *vpi, int *vci)
+-{
+- struct atm_vcc *walk;
+-
+- /*
+- * find a free VPI
+- */
+- if (*vpi == ATM_VPI_ANY)
+- {
+-
+- for (*vpi = 0, walk = vcc->dev->vccs; walk; walk = walk->next)
+- {
+-
+- if ((walk->vci == *vci) && (walk->vpi == *vpi))
+- {
+- (*vpi)++;
+- walk = vcc->dev->vccs;
+- }
+- }
+- }
+-
+- /*
+- * find a free VCI
+- */
+- if (*vci == ATM_VCI_ANY)
+- {
+-
+- for (*vci = ATM_NOT_RSV_VCI, walk = vcc->dev->vccs; walk;
+- walk = walk->next)
+- {
+-
+- if ((walk->vpi = *vpi) && (walk->vci == *vci))
+- {
+- *vci = walk->vci + 1;
+- walk = vcc->dev->vccs;
+- }
+- }
+- }
+-
+- return 0;
+-}
+-
+-
+-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+- *
+ * Function: int tn7atm_sar_irq(void)
+ *
+ * Description: tnetd73xx SAR interrupt.
+@@ -693,7 +645,7 @@ static int __init tn7atm_irq_request (st
+ * Register SAR interrupt
+ */
+ priv->sar_irq = LNXINTNUM (ATM_SAR_INT); /* Interrupt line # */
+- if (request_irq (priv->sar_irq, tn7atm_sar_irq, SA_INTERRUPT, "SAR ", dev))
++ if (request_irq (priv->sar_irq, tn7atm_sar_irq, IRQF_DISABLED, "SAR ", dev))
+ printk ("Could not register tn7atm_sar_irq\n");
+
+ /*
+@@ -704,14 +656,14 @@ static int __init tn7atm_irq_request (st
+ {
+ def_sar_inter_pace = os_atoi (ptr);
+ }
+- avalanche_request_pacing (priv->sar_irq, ATM_SAR_INT_PACING_BLOCK_NUM,
+- def_sar_inter_pace);
++/* avalanche_request_pacing (priv->sar_irq, ATM_SAR_INT_PACING_BLOCK_NUM,
++ def_sar_inter_pace);*/
+
+ /*
+ * Reigster Receive interrupt A
+ */
+ priv->dsl_irq = LNXINTNUM (ATM_DSL_INT); /* Interrupt line # */
+- if (request_irq (priv->dsl_irq, tn7atm_dsl_irq, SA_INTERRUPT, "DSL ", dev))
++ if (request_irq (priv->dsl_irq, tn7atm_dsl_irq, IRQF_DISABLED, "DSL ", dev))
+ printk ("Could not register tn7atm_dsl_irq\n");
+
+ /***** VRB Tasklet Mode ****/
+@@ -875,11 +827,15 @@ static int __init tn7atm_get_ESI (struct
+ #define ATM_VBR_RT 5
+ #endif
+
+-int tn7atm_open (struct atm_vcc *vcc, short vpi, int vci)
++int tn7atm_open (struct atm_vcc *vcc)
+ {
+ tn7atm_activate_vc_parm_t tn7atm_activate_vc_parm;
+ int rc;
+ //int flags;
++ tn7atm_activate_vc_parm.pcr = 0x20000;
++ tn7atm_activate_vc_parm.scr = 0x20000;
++ tn7atm_activate_vc_parm.mbs = 0x20000;
++ tn7atm_activate_vc_parm.cdvt = 10000;
+
+ dgprintf(1, "tn7atm_open()\n");
+
+@@ -891,24 +847,18 @@ int tn7atm_open (struct atm_vcc *vcc, sh
+ return -1;
+ }
+
+- MOD_INC_USE_COUNT;
++// MOD_INC_USE_COUNT;
+
+- /* find a free VPI/VCI */
+- tn7atm_walk_vccs(vcc, &vpi, &vci);
+-
+- vcc->vpi = vpi;
+- vcc->vci = vci;
+-
+- if ((vci == ATM_VCI_UNSPEC) || (vpi == ATM_VCI_UNSPEC))
++ if ((vcc->vci == ATM_VCI_UNSPEC) || (vcc->vpi == ATM_VCI_UNSPEC))
+ {
+- MOD_DEC_USE_COUNT;
++// MOD_DEC_USE_COUNT;
+ return -EBUSY;
+ }
+
+- tn7atm_activate_vc_parm.vpi = vpi;
+- tn7atm_activate_vc_parm.vci = vci;
++ tn7atm_activate_vc_parm.vpi = vcc->vpi;
++ tn7atm_activate_vc_parm.vci = vcc->vci;
+
+- if ((vpi == CLEAR_EOC_VPI) && (vci == CLEAR_EOC_VCI))
++ if ((vcc->vpi == CLEAR_EOC_VPI) && (vcc->vci == CLEAR_EOC_VCI))
+ {
+ /* always use (max_dma_chan+1) for clear eoc */
+ tn7atm_activate_vc_parm.chan = EOC_DMA_CHAN;
+@@ -916,7 +866,7 @@ int tn7atm_open (struct atm_vcc *vcc, sh
+ /* check to see whether clear eoc is opened or not */
+ if (tn7atm_activate_vc_parm.priv->lut[tn7atm_activate_vc_parm.chan].inuse)
+ {
+- MOD_DEC_USE_COUNT;
++// MOD_DEC_USE_COUNT;
+ printk("tn7atm_open: Clear EOC channel (dmachan=%d) already in use.\n", tn7atm_activate_vc_parm.chan);
+ return -EBUSY;
+ }
+@@ -925,7 +875,7 @@ int tn7atm_open (struct atm_vcc *vcc, sh
+ if (rc)
+ {
+ printk("tn7atm_open: failed to setup clear_eoc\n");
+- MOD_DEC_USE_COUNT;
++// MOD_DEC_USE_COUNT;
+ return -EBUSY;
+ }
+ tn7atm_set_lut(tn7atm_activate_vc_parm.priv,vcc, tn7atm_activate_vc_parm.chan);
+@@ -934,17 +884,17 @@ int tn7atm_open (struct atm_vcc *vcc, sh
+ }
+ else /* PVC channel setup */
+ {
+- if ((vpi==REMOTE_MGMT_VPI) && (vci==REMOTE_MGMT_VCI))
++ if ((vcc->vpi==REMOTE_MGMT_VPI) && (vcc->vci==REMOTE_MGMT_VCI))
+ {
+ tn7atm_activate_vc_parm.chan = 14; /* always use chan 14 for MII PVC-base romote mgmt */
+ }
+ else
+ {
+- rc = tn7atm_lut_find(vpi, vci);
++ rc = tn7atm_lut_find(vcc->vpi, vcc->vci);
+ /* check to see whether PVC is opened or not */
+ if(ATM_NO_DMA_CHAN != rc)
+ {
+- MOD_DEC_USE_COUNT;
++// MOD_DEC_USE_COUNT;
+ printk("PVC already opened. dmachan = %d\n", rc);
+ return -EBUSY;
+ }
+@@ -976,6 +926,7 @@ int tn7atm_open (struct atm_vcc *vcc, sh
+ tn7atm_activate_vc_parm.priority = 2;
+ break;
+
++#if 0
+ case ATM_VBR: /* Variable Bit Rate-Non RealTime*/
+ tn7atm_activate_vc_parm.qos = 1;
+ tn7atm_activate_vc_parm.priority = 1;
+@@ -997,6 +948,7 @@ int tn7atm_open (struct atm_vcc *vcc, sh
+ tn7atm_activate_vc_parm.mbs = vcc->qos.txtp.max_pcr;
+ tn7atm_activate_vc_parm.cdvt = vcc->qos.txtp.max_cdv;
+ break;
++#endif
+
+ default:
+ tn7atm_activate_vc_parm.qos = 2;
+@@ -1024,7 +976,7 @@ int tn7atm_open (struct atm_vcc *vcc, sh
+ if (rc < 0)
+ {
+ printk("failed to activate hw channel\n");
+- MOD_DEC_USE_COUNT;
++// MOD_DEC_USE_COUNT;
+ tn7atm_lut_clear(vcc, tn7atm_activate_vc_parm.chan);
+ //spin_unlock_irqrestore(&chan_init_lock, flags);
+ return -EBUSY;
+@@ -1114,7 +1066,7 @@ void tn7atm_close (struct atm_vcc *vcc)
+ tn7atm_lut_clear (vcc, dmachan);
+ //spin_unlock_irqrestore (&closeLock, closeFlag);
+
+- MOD_DEC_USE_COUNT;
++// MOD_DEC_USE_COUNT;
+
+ dgprintf (1, "Leave tn7atm_close\n");
+ }
+@@ -1528,8 +1480,7 @@ int tn7atm_receive (void *os_dev, int ch
+ * firewall is on */
+
+ dgprintf (3, "pushing the skb...\n");
+-
+- skb->stamp = vcc->timestamp = xtime;
++ __net_timestamp(skb);
+
+ xdump ((unsigned char *) skb->data, skb->len, 5);
+
+@@ -1725,8 +1676,7 @@ static void tn7atm_exit (void)
+
+ kfree (dev->dev_data);
+
+- // atm_dev_deregister (dev);
+- shutdown_atm_dev (dev);
++ atm_dev_deregister (dev);
+
+ /*
+ * remove proc entries
+@@ -1885,9 +1835,6 @@ static int __init tn7atm_detect (void)
+ /*
+ * Set up proc entry for atm stats
+ */
+- if (tn7atm_xlate_proc_name
+- (drv_proc_root_folder, &root_proc_dir_entry, &residual))
+- {
+ printk ("Creating new root folder %s in the proc for the driver stats \n",
+ drv_proc_root_folder);
+ root_proc_dir_entry = proc_mkdir (drv_proc_root_folder, NULL);
+@@ -1897,7 +1844,6 @@ static int __init tn7atm_detect (void)
+ return -ENOMEM;
+ }
+ proc_root_already_exists = FALSE;
+- }
+
+ /*
+ * AV: Clean-up. Moved all the definitions to the data structure.
+@@ -2479,7 +2425,5 @@ static int tn7atm_proc_qos_write(struct
+ return count;
+ }
+
+-#ifdef MODULE
+ module_init (tn7atm_detect);
+ module_exit (tn7atm_exit);
+-#endif /* MODULE */
+--- a/tn7atm.h
++++ b/tn7atm.h
+@@ -19,7 +19,8 @@
+ //#include "mips_support.h"
+ #include <linux/list.h>
+
+-#include <linux/config.h>
++#define MIPS_EXCEPTION_OFFSET 8
++#define LNXINTNUM(x)((x) + MIPS_EXCEPTION_OFFSET)
+
+ #ifdef CONFIG_MODVERSIONS
+ #include <linux/modversions.h>
+--- a/tn7dsl.c
++++ b/tn7dsl.c
+@@ -94,7 +94,6 @@
+ * 1/02/07 JZ CQ11054: Data Precision and Range Changes for TR-069 Conformance
+ * UR8_MERGE_END CQ11054*
+ *********************************************************************************************/
+-#include <linux/config.h>
+ #include <linux/kernel.h>
+ #include <linux/module.h>
+ #include <linux/init.h>
+@@ -102,8 +101,6 @@
+ #include <linux/delay.h>
+ #include <linux/spinlock.h>
+ #include <linux/smp_lock.h>
+-#include <asm/io.h>
+-#include <asm/mips-boards/prom.h>
+ #include <linux/proc_fs.h>
+ #include <linux/string.h>
+ #include <linux/ctype.h>
+@@ -111,6 +108,12 @@
+ #include <linux/timer.h>
+ #include <linux/vmalloc.h>
+ #include <linux/file.h>
++#include <linux/firmware.h>
++
++#include <asm/io.h>
++#include <asm/ar7/ar7.h>
++#include <asm/ar7/prom.h>
++
+ /* Modules specific header files */
+ #include "tn7atm.h"
+ #include "tn7api.h"
+@@ -173,7 +176,7 @@ led_reg_t ledreg[2];
+ static struct led_funcs ledreg[2];
+ #endif
+
+-#define DEV_DSLMOD 1
++#define DEV_DSLMOD CTL_UNNUMBERED
+ #define MAX_STR_SIZE 256
+ #define DSL_MOD_SIZE 256
+
+@@ -299,7 +302,7 @@ static PITIDSLHW_T pIhw;
+ static volatile int bshutdown;
+ static char info[MAX_STR_SIZE];
+ /* Used for DSL Polling enable */
+-static DECLARE_MUTEX_LOCKED (adsl_sem_overlay);
++static struct semaphore adsl_sem_overlay;
+
+ //kthread_t overlay_thread;
+ /* end of module wide declars */
+@@ -323,6 +326,14 @@ static int tn7dsl_proc_snr_print (char *
+ #define gDot1(a) ((a>0)?(a%10):((-a)%10))
+ // UR8_MERGE_END CQ11054*
+
++int avalanche_request_intr_pacing(int irq_nr, unsigned int blk_num,
++ unsigned int pace_value)
++{
++ printk("avalanche_request_pacing(%d, %u, %u); // not implemented\n", irq_nr, blk_num, pace_value);
++ return 0;
++}
++
++
+ int os_atoi(const char *pStr)
+ {
+ int MulNeg = (*pStr == '-' ? -1 : 1);
+@@ -359,39 +370,6 @@ void dprintf (int uDbgLevel, char *szFmt
+ #endif
+ }
+
+-int strcmp(const char *s1, const char *s2)
+-{
+-
+- int size = strlen(s1);
+-
+- return(strncmp(s1, s2, size));
+-}
+-
+-int strncmp(const char *s1, const char *s2, size_t size)
+-{
+- int i = 0;
+- int max_size = (int)size;
+-
+- while((s1[i] != 0) && i < max_size)
+- {
+- if(s2[i] == 0)
+- {
+- return -1;
+- }
+- if(s1[i] != s2[i])
+- {
+- return 1;
+- }
+- i++;
+- }
+- if(s2[i] != 0)
+- {
+- return 1;
+- }
+-
+- return 0;
+-}
+-
+ // * UR8_MERGE_START CQ10640 Jack Zhang
+ int tn7dsl_dump_dsp_memory(char *input_str) //cph99
+ {
+@@ -441,101 +419,74 @@ unsigned int shim_osGetCpuFrequency(void
+ return CpuFrequency;
+ }
+
+-int shim_osLoadFWImage(unsigned char *ptr)
++static void avsar_release(struct device *dev)
+ {
+- unsigned int bytesRead;
+- mm_segment_t oldfs;
+- static struct file *filp;
+- unsigned int imageLength=0x5ffff;
+-
+-
+- dgprintf(4, "tn7dsl_read_dsp()\n");
+-
+- dgprintf(4,"open file %s\n", DSP_FIRMWARE_PATH);
+-
+- filp=filp_open(DSP_FIRMWARE_PATH,00,O_RDONLY);
+- if(filp ==NULL)
+- {
+- printk("Failed: Could not open DSP binary file\n");
+- return -1;
+- }
+-
+- if (filp->f_dentry != NULL)
+- {
+- if (filp->f_dentry->d_inode != NULL)
+- {
+- printk ("DSP binary filesize = %d bytes\n",
+- (int) filp->f_dentry->d_inode->i_size);
+- imageLength = (unsigned int)filp->f_dentry->d_inode->i_size + 0x200;
+- }
+- }
+-
+- if (filp->f_op->read==NULL)
+- return -1; /* File(system) doesn't allow reads */
+-
+- /*
+- * Disable parameter checking
+- */
+- oldfs = get_fs();
+- set_fs(KERNEL_DS);
+-
+- /*
+- * Now read bytes from postion "StartPos"
+- */
+- filp->f_pos = 0;
+-
+- bytesRead = filp->f_op->read(filp,ptr,imageLength,&filp->f_pos);
+-
+- dgprintf(4,"file length = %d\n", bytesRead);
+-
+- set_fs(oldfs);
+-
+- /*
+- * Close the file
+- */
+- fput(filp);
+-
+- return bytesRead;
++ printk(KERN_DEBUG "avsar firmware released\n");
+ }
+
++static struct device avsar = {
++ .bus_id = "vlynq",
++ .release = avsar_release,
++};
+
+-unsigned int shim_read_overlay_page (void *ptr, unsigned int secOffset,
+- unsigned int secLength)
++int shim_osLoadFWImage(unsigned char *ptr)
+ {
+- unsigned int bytesRead;
+- mm_segment_t oldfs;
+- struct file *filp;
+-
+- dgprintf(4,"shim_read_overlay_page\n");
+- //dgprintf(4,"sec offset=%d, sec length =%d\n", secOffset, secLength);
++ const struct firmware *fw_entry;
++ size_t size;
+
+- filp=filp_open(DSP_FIRMWARE_PATH,00,O_RDONLY);
+- if(filp ==NULL)
+- {
+- printk("Failed: Could not open DSP binary file\n");
+- return -1;
+- }
+-
+- if (filp->f_op->read==NULL)
+- return -1; /* File(system) doesn't allow reads */
+-
+- /*
+- * Now read bytes from postion "StartPos"
+- */
+-
+- if(filp->f_op->llseek)
+- filp->f_op->llseek(filp,secOffset, 0);
+- oldfs = get_fs();
+- set_fs(KERNEL_DS);
+- filp->f_pos = secOffset;
+- bytesRead = filp->f_op->read(filp,ptr,secLength,&filp->f_pos);
+-
+- set_fs(oldfs);
+- /*
+- * Close the file
+- */
+- fput(filp);
+- return bytesRead;
++ printk("requesting firmware image \"ar0700xx.bin\"\n");
++ if(device_register(&avsar) < 0) {
++ printk(KERN_ERR
++ "avsar: device_register fails\n");
++ return -1;
++ }
++
++ if(request_firmware(&fw_entry, "ar0700xx.bin", &avsar)) {
++ printk(KERN_ERR
++ "avsar: Firmware not available\n");
++ device_unregister(&avsar);
++ return -1;
++ }
++ size = fw_entry->size;
++ device_unregister(&avsar);
++ if(size > 0x5ffff) {
++ printk(KERN_ERR
++ "avsar: Firmware too big (%d bytes)\n", size);
++ release_firmware(fw_entry);
++ return -1;
++ }
++ memcpy(ptr, fw_entry->data, size);
++ release_firmware(fw_entry);
++ return size;
++}
++
++unsigned int shim_read_overlay_page(void *ptr, unsigned int secOffset, unsigned int secLength)
++{
++ const struct firmware *fw_entry;
++
++ printk("requesting firmware image \"ar0700xx.bin\"\n");
++ if(device_register(&avsar) < 0) {
++ printk(KERN_ERR
++ "avsar: device_register fails\n");
++ return -1;
++ }
++
++ if(request_firmware(&fw_entry, "ar0700xx.bin", &avsar)) {
++ printk(KERN_ERR
++ "avsar: Firmware not available\n");
++ device_unregister(&avsar);
++ return -1;
++ }
++ device_unregister(&avsar);
++ if(fw_entry->size > secLength) {
++ printk(KERN_ERR
++ "avsar: Firmware too big (%d bytes)\n", fw_entry->size);
++ release_firmware(fw_entry);
++ return -1;
++ }
++ memcpy(ptr + secOffset, fw_entry->data, secLength);
++ release_firmware(fw_entry);
++ return secLength;
+ }
+
+ int shim_osLoadDebugFWImage(unsigned char *ptr)
+@@ -3064,6 +3015,7 @@ int tn7dsl_init(void *priv)
+ int high_precision_selected = 0;
+ // UR8_MERGE_END CQ11054*
+
++ sema_init(&adsl_sem_overlay, 0);
+ /*
+ * start dsl
+ */
+@@ -3442,7 +3394,7 @@ static int dslmod_sysctl(ctl_table *ctl,
+ */
+ if(write)
+ {
+- ret = proc_dostring(ctl, write, filp, buffer, lenp);
++ ret = proc_dostring(ctl, write, filp, buffer, lenp, 0);
+
+ switch (ctl->ctl_name)
+ {
+@@ -3528,14 +3480,14 @@ static int dslmod_sysctl(ctl_table *ctl,
+ else
+ {
+ len += sprintf(info+len, mod_req);
+- ret = proc_dostring(ctl, write, filp, buffer, lenp);
++ ret = proc_dostring(ctl, write, filp, buffer, lenp, 0);
+ }
+ return ret;
+ }
+
+
+ ctl_table dslmod_table[] = {
+- {DEV_DSLMOD, "dslmod", info, DSL_MOD_SIZE, 0644, NULL, &dslmod_sysctl}
++ {DEV_DSLMOD, "dslmod", info, DSL_MOD_SIZE, 0644, NULL, NULL, &dslmod_sysctl, &sysctl_string}
+ ,
+ {0}
+ };
+@@ -3558,8 +3510,7 @@ void tn7dsl_dslmod_sysctl_register(void)
+ if (initialized == 1)
+ return;
+
+- dslmod_sysctl_header = register_sysctl_table(dslmod_root_table, 1);
+- dslmod_root_table->child->de->owner = THIS_MODULE;
++ dslmod_sysctl_header = register_sysctl_table(dslmod_root_table);
+
+ /*
+ * set the defaults
+@@ -4821,4 +4772,4 @@ int tn7dsl_proc_PMDus(char* buf, char **
+ }
+ #endif //NO_ADV_STATS
+ #endif //TR69_PMD_IN
+-// * UR8_MERGE_END CQ11057 *
+\ No newline at end of file
++// * UR8_MERGE_END CQ11057 *
+--- a/tn7sar.c
++++ b/tn7sar.c
+@@ -42,7 +42,6 @@
+ * UR8_MERGE_END CQ10700
+ *******************************************************************************/
+
+-#include <linux/config.h>
+ #include <linux/kernel.h>
+ #include <linux/module.h>
+ #include <linux/init.h>
+@@ -50,12 +49,13 @@
+ #include <linux/delay.h>
+ #include <linux/spinlock.h>
+ #include <linux/smp_lock.h>
+-#include <asm/io.h>
+-#include <asm/mips-boards/prom.h>
+ #include <linux/proc_fs.h>
+ #include <linux/string.h>
+ #include <linux/ctype.h>
+
++#include <asm/io.h>
++#include <asm/ar7/ar7.h>
++#include <asm/ar7/prom.h>
+
+ #define _CPHAL_AAL5
+ #define _CPHAL_SAR
diff --git a/package/system/ar7-atm/patches-D7.04.03.00/110-interrupt_fix.patch b/package/system/ar7-atm/patches-D7.04.03.00/110-interrupt_fix.patch
new file mode 100644
index 0000000..9acb862
--- /dev/null
+++ b/package/system/ar7-atm/patches-D7.04.03.00/110-interrupt_fix.patch
@@ -0,0 +1,37 @@
+--- a/tn7atm.c
++++ b/tn7atm.c
+@@ -566,7 +566,7 @@ static int turbodsl_check_priority_type(
+ * Description: tnetd73xx SAR interrupt.
+ *
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+-static void tn7atm_sar_irq (int irq, void *voiddev, struct pt_regs *regs)
++static irqreturn_t tn7atm_sar_irq (int irq, void *voiddev)
+ {
+ struct atm_dev *atmdev;
+ Tn7AtmPrivate *priv;
+@@ -593,6 +593,7 @@ static void tn7atm_sar_irq (int irq, voi
+ #ifdef TIATM_INST_SUPP
+ psp_trace_par (ATM_DRV_SAR_ISR_EXIT, retval);
+ #endif
++ return IRQ_HANDLED;
+ }
+
+ /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+@@ -602,7 +603,7 @@ static void tn7atm_sar_irq (int irq, voi
+ * Description: tnetd73xx DSL interrupt.
+ *
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+-static void tn7atm_dsl_irq (int irq, void *voiddev, struct pt_regs *regs)
++static irqreturn_t tn7atm_dsl_irq (int irq, void *voiddev)
+ {
+ struct atm_dev *atmdev;
+ Tn7AtmPrivate *priv;
+@@ -624,6 +625,8 @@ static void tn7atm_dsl_irq (int irq, voi
+ #ifdef TIATM_INST_SUPP
+ psp_trace_par (ATM_DRV_DSL_ISR_EXIT, retval);
+ #endif
++
++ return IRQ_HANDLED;
+ }
+
+ /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/package/system/ar7-atm/patches-D7.04.03.00/120-no_dumb_inline.patch b/package/system/ar7-atm/patches-D7.04.03.00/120-no_dumb_inline.patch
new file mode 100644
index 0000000..2968fdc
--- /dev/null
+++ b/package/system/ar7-atm/patches-D7.04.03.00/120-no_dumb_inline.patch
@@ -0,0 +1,11 @@
+--- a/tn7api.h
++++ b/tn7api.h
+@@ -107,7 +107,7 @@ int tn7dsl_proc_dbg_rmsgs4(char* buf, ch
+
+ int tn7dsl_proc_write_stats(struct file *fp, const char * buf, unsigned long count, void * data);
+ int tn7dsl_proc_modem(char* buf, char **start, off_t offset, int count,int *eof, void *data);
+-inline int tn7dsl_handle_interrupt(void);
++int tn7dsl_handle_interrupt(void);
+
+ void tn7dsl_dslmod_sysctl_register(void);
+ void tn7dsl_dslmod_sysctl_unregister(void);
diff --git a/package/system/ar7-atm/patches-D7.04.03.00/130-powercutback.patch b/package/system/ar7-atm/patches-D7.04.03.00/130-powercutback.patch
new file mode 100644
index 0000000..ec00df9
--- /dev/null
+++ b/package/system/ar7-atm/patches-D7.04.03.00/130-powercutback.patch
@@ -0,0 +1,44 @@
+--- a/dsl_hal_advcfg.c
++++ b/dsl_hal_advcfg.c
+@@ -36,9 +36,9 @@
+ * 05Jul05 0.00.09 CPH CQ9775: Change dslhal_advcfg_configDsTones input parameters & support for ADSL2+
+ * 24Jul05 0.00.10 CPH Fixed comments in dslhal_advcfg_configDsTones function header
+ *******************************************************************************/
+-#include <dev_host_interface.h>
+-#include <dsl_hal_register.h>
+-#include <dsl_hal_support.h>
++#include "dev_host_interface.h"
++#include "dsl_hal_register.h"
++#include "dsl_hal_support.h"
+
+ /*****************************************************************************/
+ /* ACT API functions -- To be moved into their own independent module --RamP */
+--- a/Makefile
++++ b/Makefile
+@@ -4,6 +4,7 @@
+
+ CONFIG_SANGAM_ATM=m
+ #EXTRA_CFLAGS += -DEL -I. -DPOST_SILICON -DCOMMON_NSP -DCONFIG_LED_MODULE -DDEREGISTER_LED -DNO_ACT
+-EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -DNO_ACT -D__NO__VOICE_PATCH__ -DEL
++#EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -DNO_ACT -D__NO__VOICE_PATCH__ -DEL
++EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -D__NO__VOICE_PATCH__ -DEL
+ obj-$(CONFIG_SANGAM_ATM) := tiatm.o
+-tiatm-objs += cpsar.o aal5sar.o tn7sar.o tn7atm.o tn7dsl.o dsl_hal_api.o dsl_hal_support.o
++tiatm-objs += cpsar.o aal5sar.o tn7sar.o tn7atm.o tn7dsl.o dsl_hal_api.o dsl_hal_support.o dsl_hal_advcfg.o
+--- a/tn7dsl.c
++++ b/tn7dsl.c
+@@ -2869,6 +2869,14 @@ static int tn7dsl_set_dsl(void)
+ dslhal_api_setRateAdaptFlag(pIhw, os_atoi(ptr));
+ }
+
++ // set powercutback
++ ptr = NULL;
++ ptr = prom_getenv("powercutback");
++ if(ptr)
++ {
++ dslhal_advcfg_onOffPcb(pIhw, os_atoi(ptr));
++ }
++
+ // trellis
+ ptr = NULL;
+ ptr = prom_getenv("trellis");
diff --git a/package/system/ar7-atm/patches-D7.04.03.00/140-debug_mode.patch b/package/system/ar7-atm/patches-D7.04.03.00/140-debug_mode.patch
new file mode 100644
index 0000000..ce3697b
--- /dev/null
+++ b/package/system/ar7-atm/patches-D7.04.03.00/140-debug_mode.patch
@@ -0,0 +1,16 @@
+--- a/tn7sar.c
++++ b/tn7sar.c
+@@ -103,10 +103,10 @@ enum
+
+ #define RESERVED_OAM_CHANNEL 15
+
+-#define AAL5_PARM "id=aal5, base = 0x03000000, offset = 0, int_line=15, ch0=[RxBufSize=1522; RxNumBuffers = 32; RxServiceMax = 50; TxServiceMax=50; TxNumBuffers=32; CpcsUU=0x5aa5; TxVc_CellRate=0x3000; TxVc_AtmHeader=0x00000640]"
+-#define SAR_PARM "id=sar,base = 0x03000000, reset_bit = 9, offset = 0; UniNni = 0, PdspEnable = 1"
++#define CH0_PARM "RxBufSize=1522, RxNumBuffers=32, RxServiceMax=50, TxServiceMax=50, TxNumBuffers=32, CpcsUU=0x5aa5, TxVc_CellRate=0x3000, TxVc_AtmHeader=0x00000640"
++#define AAL5_PARM "id=aal5, base=0x03000000, offset=0, int_line=15, ch0=[" CH0_PARM "]"
++#define SAR_PARM "id=sar, base=0x03000000, reset_bit=9, offset=0; UniNni=0, PdspEnable=1, Debug=0xFFFFFFFF"
+ #define RESET_PARM "id=ResetControl, base=0xA8611600"
+-#define CH0_PARM "RxBufSize=1522, RxNumBuffers = 32, RxServiceMax = 50, TxServiceMax=50, TxNumBuffers=32, CpcsUU=0x5aa5, TxVc_CellRate=0x3000, TxVc_AtmHeader=0x00000640"
+
+ #define MAX_PVC_TABLE_ENTRY 16
+
diff --git a/package/system/ar7-atm/patches-D7.04.03.00/150-tasklet_mode.patch b/package/system/ar7-atm/patches-D7.04.03.00/150-tasklet_mode.patch
new file mode 100644
index 0000000..97b8cec
--- /dev/null
+++ b/package/system/ar7-atm/patches-D7.04.03.00/150-tasklet_mode.patch
@@ -0,0 +1,11 @@
+--- a/Makefile
++++ b/Makefile
+@@ -5,6 +5,7 @@
+ CONFIG_SANGAM_ATM=m
+ #EXTRA_CFLAGS += -DEL -I. -DPOST_SILICON -DCOMMON_NSP -DCONFIG_LED_MODULE -DDEREGISTER_LED -DNO_ACT
+ #EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -DNO_ACT -D__NO__VOICE_PATCH__ -DEL
+-EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -D__NO__VOICE_PATCH__ -DEL
++#EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -D__NO__VOICE_PATCH__ -DEL
++EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -D__NO__VOICE_PATCH__ -DEL -DCPATM_TASKLET_MODE
+ obj-$(CONFIG_SANGAM_ATM) := tiatm.o
+ tiatm-objs += cpsar.o aal5sar.o tn7sar.o tn7atm.o tn7dsl.o dsl_hal_api.o dsl_hal_support.o dsl_hal_advcfg.o
diff --git a/package/system/ar7-atm/patches-D7.04.03.00/160-module-params.patch b/package/system/ar7-atm/patches-D7.04.03.00/160-module-params.patch
new file mode 100644
index 0000000..67802ae
--- /dev/null
+++ b/package/system/ar7-atm/patches-D7.04.03.00/160-module-params.patch
@@ -0,0 +1,589 @@
+--- a/tn7atm.c
++++ b/tn7atm.c
+@@ -87,6 +87,146 @@
+ MODULE_LICENSE("GPL");
+ MODULE_DESCRIPTION ("Tnetd73xx ATM Device Driver");
+ MODULE_AUTHOR ("Zhicheng Tang");
++
++int mp_sar_ipacemax = -1;
++module_param_named(ipacemax, mp_sar_ipacemax, int, 0);
++MODULE_PARM_DESC(ipacemax, "Interrupt pacing");
++
++char *mp_macc = NULL;
++module_param_named(macc, mp_macc, charp, 0);
++MODULE_PARM_DESC(macc, "MAC address");
++
++int mp_dsp_noboost = -1;
++module_param_named(dsp_noboost, mp_dsp_noboost, int, 0);
++MODULE_PARM_DESC(dsp_noboost, "Suppress DSP frequency boost");
++
++int mp_dsp_freq = -1;
++module_param_named(dsp_freq, mp_dsp_freq, int, 0);
++MODULE_PARM_DESC(dsp_freq, "Frequency to boost the DSP to");
++
++char *mp_featctl0 = NULL;
++module_param_named(featctl0, mp_featctl0, charp, 0);
++MODULE_PARM_DESC(featctl0, "DSL feature control 0");
++
++char *mp_featctl1 = NULL;
++module_param_named(featctl1, mp_featctl1, charp, 0);
++MODULE_PARM_DESC(featctl1, "DSL feature control 1");
++
++char *mp_phyctl0 = NULL;
++module_param_named(phyctl0, mp_phyctl0, charp, 0);
++MODULE_PARM_DESC(phyctl0, "DSL PHY control 0");
++
++char *mp_phyctl1 = NULL;
++module_param_named(phyctl1, mp_phyctl1, charp, 0);
++MODULE_PARM_DESC(phyctl1, "DSL PHY control 1");
++
++int mp_turbodsl = -1;
++module_param_named(turbodsl, mp_turbodsl, int, 0);
++MODULE_PARM_DESC(turbodsl, "Enable TurboDSL");
++
++int mp_sar_rxbuf = -1;
++module_param_named(sar_rxbuf, mp_sar_rxbuf, int, 0);
++MODULE_PARM_DESC(sar_rxbuf, "SAR RxBuf size");
++
++int mp_sar_rxmax = -1;
++module_param_named(sar_rxmax, mp_sar_rxmax, int, 0);
++MODULE_PARM_DESC(sar_rxmax, "SAR RxMax size");
++
++int mp_sar_txbuf = -1;
++module_param_named(sar_txbuf, mp_sar_txbuf, int, 0);
++MODULE_PARM_DESC(sar_txbuf, "SAR TxBuf size");
++
++int mp_sar_txmax = -1;
++module_param_named(sar_txmax, mp_sar_txmax, int, 0);
++MODULE_PARM_DESC(sar_txmax, "SAR TxMax size");
++
++char *mp_modulation = NULL;
++module_param_named(modulation, mp_modulation, charp, 0);
++MODULE_PARM_DESC(modulation, "Modulation");
++
++int mp_fine_gain_control = -1;
++module_param_named(fine_gain_control, mp_fine_gain_control, int, 0);
++MODULE_PARM_DESC(fine_gain_control, "Fine gain control");
++
++int mp_fine_gain_value = -1;
++module_param_named(fine_gain_value, mp_fine_gain_value, int, 0);
++MODULE_PARM_DESC(fine_gain_value, "Fine gain value");
++
++int mp_enable_margin_retrain = -1;
++module_param_named(enable_margin_retrain, mp_enable_margin_retrain, int, 0);
++MODULE_PARM_DESC(enable_margin_retrain, "Enable margin retrain");
++
++int mp_margin_threshold = -1;
++module_param_named(margin_threshold, mp_margin_threshold, int, 0);
++MODULE_PARM_DESC(margin_threshold, "Margin retrain treshold");
++
++int mp_enable_rate_adapt = -1;
++module_param_named(enable_rate_adapt, mp_enable_rate_adapt, int, 0);
++MODULE_PARM_DESC(enable_rate_adapt, "Enable rate adaption");
++
++int mp_powercutback = -1;
++module_param_named(powercutback, mp_powercutback, int, 0);
++MODULE_PARM_DESC(powercutback, "Enable / disable powercutback");
++
++int mp_trellis = -1;
++module_param_named(trellis, mp_trellis, int, 0);
++MODULE_PARM_DESC(trellis, "Enable / disable trellis coding");
++
++int mp_bitswap = -1;
++module_param_named(bitswap, mp_bitswap, int, 0);
++MODULE_PARM_DESC(bitswap, "Enable / disable bitswap");
++
++int mp_maximum_bits_per_carrier = -1;
++module_param_named(maximum_bits_per_carrier, mp_maximum_bits_per_carrier, int, 0);
++MODULE_PARM_DESC(maximum_bits_per_carrier, "Maximum bits per carrier");
++
++int mp_maximum_interleave_depth = -1;
++module_param_named(maximum_interleave_depth, mp_maximum_interleave_depth, int, 0);
++MODULE_PARM_DESC(maximum_interleave_depth, "Maximum interleave depth");
++
++int mp_pair_selection = -1;
++module_param_named(pair_selection, mp_pair_selection, int, 0);
++MODULE_PARM_DESC(pair_selection, "Pair selection");
++
++int mp_dgas_polarity = -1;
++module_param_named(dgas_polarity, mp_dgas_polarity, int, 0);
++MODULE_PARM_DESC(dgas_polarity, "DGAS polarity");
++
++int mp_los_alarm = -1;
++module_param_named(los_alarm, mp_los_alarm, int, 0);
++MODULE_PARM_DESC(los_alarm, "LOS alarm");
++
++char *mp_eoc_vendor_id = NULL;
++module_param_named(eoc_vendor_id, mp_eoc_vendor_id, charp, 0);
++MODULE_PARM_DESC(eoc_vendor_id, "EOC vendor id");
++
++int mp_eoc_vendor_revision = -1;
++module_param_named(eoc_vendor_revision, mp_eoc_vendor_revision, int, 0);
++MODULE_PARM_DESC(eoc_vendor_revision, "EOC vendor revision");
++
++char *mp_eoc_vendor_serialnum = NULL;
++module_param_named(eoc_vendor_serialnum, mp_eoc_vendor_serialnum, charp, 0);
++MODULE_PARM_DESC(eoc_vendor_serialnum, "EOC vendor serial number");
++
++char *mp_invntry_vernum = NULL;
++module_param_named(invntry_vernum, mp_invntry_vernum, charp, 0);
++MODULE_PARM_DESC(invntry_vernum, "Inventory revision number");
++
++int mp_dsl_bit_tmode = -1;
++module_param_named(dsl_bit_tmode, mp_dsl_bit_tmode, int, 0);
++MODULE_PARM_DESC(dsl_bit_tmode, "DSL bit training mode");
++
++int mp_high_precision = -1;
++module_param_named(high_precision, mp_high_precision, int, 0);
++MODULE_PARM_DESC(high_precision, "High precision");
++
++int mp_autopvc_enable = -1;
++module_param_named(autopvc_enable, mp_autopvc_enable, int, 0);
++MODULE_PARM_DESC(autopvc_enable, "Enable / disable automatic PVC");
++
++int mp_oam_lb_timeout = -1;
++module_param_named(oam_lb_timeout, mp_oam_lb_timeout, int, 0);
++MODULE_PARM_DESC(oam_lb_timeout, "OAM LB timeout");
+ #endif
+
+ #ifndef TRUE
+@@ -655,9 +795,9 @@
+ * interrupt pacing
+ */
+ ptr = prom_getenv ("sar_ipacemax");
+- if (ptr)
++ if (ptr || mp_sar_ipacemax != -1)
+ {
+- def_sar_inter_pace = os_atoi (ptr);
++ def_sar_inter_pace = mp_sar_ipacemax == -1 ? os_atoi (ptr) : mp_sar_ipacemax;
+ }
+ /* avalanche_request_pacing (priv->sar_irq, ATM_SAR_INT_PACING_BLOCK_NUM,
+ def_sar_inter_pace);*/
+@@ -795,9 +935,18 @@
+ {
+ int i;
+ char esi_addr[ESI_LEN] = { 0x00, 0x00, 0x11, 0x22, 0x33, 0x44 };
+- char *esiaddr_str = NULL;
++ char *esiaddr_str = mp_macc;
+
+- esiaddr_str = prom_getenv ("maca");
++ if (esiaddr_str == NULL)
++ esiaddr_str = prom_getenv ("macdsl");
++ if (esiaddr_str == NULL)
++ esiaddr_str = prom_getenv ("macc");
++ if (esiaddr_str == NULL)
++ esiaddr_str = prom_getenv ("HWA_1");
++ if (esiaddr_str == NULL)
++ esiaddr_str = prom_getenv ("macb");
++ if (esiaddr_str == NULL)
++ esiaddr_str = prom_getenv ("maca");
+
+ if (!esiaddr_str)
+ {
+@@ -1930,15 +2079,15 @@
+ //UR8_MERGE_END CQ10450*
+
+ cp = prom_getenv ("dsp_noboost");
+- if (cp)
++ if (cp || mp_dsp_noboost != -1)
+ {
+- dsp_noboost = os_atoi (cp);
++ dsp_noboost = mp_dsp_noboost == -1 ? os_atoi (cp) : mp_dsp_noboost;
+ }
+
+ cp = (char *) prom_getenv ("dsp_freq");
+- if (cp)
++ if (cp || mp_dsp_freq != -1)
+ {
+- dspfreq = os_atoi (cp);
++ dspfreq = mp_dsp_freq == -1 ? os_atoi (cp) : mp_dsp_freq;
+ if (dspfreq == 250)
+ {
+ boostDsp = 1;
+@@ -2187,8 +2336,9 @@
+ // Inter-Op DSL phy Control
+ // Note the setting of _dsl_Feature_0 and _dsl_Feature_1 must before
+ // dslhal_api_dslStartup (in tn7dsl_init()).
+- if ((ptr = prom_getenv ("DSL_FEATURE_CNTL_0")) != NULL)
++ if ((ptr = prom_getenv ("DSL_FEATURE_CNTL_0")) != NULL || mp_featctl0 != NULL)
+ {
++ if (mp_featctl0 != NULL) ptr = mp_featctl0;
+ if ((ptr[0] == '0') && (ptr[1] == 'x')) // skip 0x before pass to
+ // os_atoh
+ ptr += 2;
+@@ -2196,8 +2346,9 @@
+ _dsl_Feature_0_defined = 1;
+ }
+
+- if ((ptr = prom_getenv ("DSL_FEATURE_CNTL_1")) != NULL)
++ if ((ptr = prom_getenv ("DSL_FEATURE_CNTL_1")) != NULL || mp_featctl1 != NULL)
+ {
++ if (mp_featctl1 != NULL) ptr = mp_featctl1;
+ if ((ptr[0] == '0') && (ptr[1] == 'x')) // skip 0x before pass to
+ // os_atoh
+ ptr += 2;
+@@ -2209,8 +2360,9 @@
+ // DSL phy Feature Control
+ // Note the setting of _dsl_PhyControl_0 and _dsl_PhyControl_1 must before
+ // dslhal_api_dslStartup (in tn7dsl_init()).
+- if ((ptr = prom_getenv ("DSL_PHY_CNTL_0")) != NULL)
++ if ((ptr = prom_getenv ("DSL_PHY_CNTL_0")) != NULL || mp_phyctl0 != NULL)
+ {
++ if (mp_phyctl0 != NULL) ptr = mp_phyctl0;
+ if ((ptr[0] == '0') && (ptr[1] == 'x')) // skip 0x before pass to
+ // os_atoh
+ ptr += 2;
+@@ -2218,8 +2370,9 @@
+ _dsl_PhyControl_0_defined = 1;
+ }
+
+- if ((ptr = prom_getenv ("DSL_PHY_CNTL_1")) != NULL)
++ if ((ptr = prom_getenv ("DSL_PHY_CNTL_1")) != NULL || mp_phyctl1 != NULL)
+ {
++ if (mp_phyctl1 != NULL) ptr = mp_phyctl1;
+ if ((ptr[0] == '0') && (ptr[1] == 'x')) // skip 0x before pass to
+ // os_atoh
+ ptr += 2;
+@@ -2247,9 +2400,9 @@
+ priv->bTurboDsl = 1;
+ // read config for turbo dsl
+ ptr = prom_getenv ("TurboDSL");
+- if (ptr)
++ if (ptr || mp_turbodsl != -1)
+ {
+- priv->bTurboDsl = os_atoi (ptr);
++ priv->bTurboDsl = mp_turbodsl == -1 ? os_atoi (ptr) : mp_turbodsl;
+ }
+
+ // @Added to make Rx buffer number & Service max configurable through
+@@ -2257,30 +2410,30 @@
+ priv->sarRxBuf = RX_BUFFER_NUM;
+ ptr = NULL;
+ ptr = prom_getenv ("SarRxBuf");
+- if (ptr)
++ if (ptr || mp_sar_rxbuf != -1)
+ {
+- priv->sarRxBuf = os_atoi (ptr);
++ priv->sarRxBuf = mp_sar_rxbuf == -1 ? os_atoi (ptr) : mp_sar_rxbuf;
+ }
+ priv->sarRxMax = RX_SERVICE_MAX;
+ ptr = NULL;
+ ptr = prom_getenv ("SarRxMax");
+- if (ptr)
++ if (ptr || mp_sar_rxmax != -1)
+ {
+- priv->sarRxMax = os_atoi (ptr);
++ priv->sarRxMax = mp_sar_rxmax == -1 ? os_atoi (ptr) : mp_sar_rxmax;
+ }
+ priv->sarTxBuf = TX_BUFFER_NUM;
+ ptr = NULL;
+ ptr = prom_getenv ("SarTxBuf");
+- if (ptr)
++ if (ptr || mp_sar_txbuf != -1)
+ {
+- priv->sarTxBuf = os_atoi (ptr);
++ priv->sarTxBuf = mp_sar_txbuf == -1 ? os_atoi (ptr) : mp_sar_txbuf;
+ }
+ priv->sarTxMax = TX_SERVICE_MAX;
+ ptr = NULL;
+ ptr = prom_getenv ("SarTxMax");
+- if (ptr)
++ if (ptr || mp_sar_txmax != -1)
+ {
+- priv->sarTxMax = os_atoi (ptr);
++ priv->sarTxMax = mp_sar_txmax == -1 ? os_atoi (ptr) : mp_sar_txmax;
+ }
+
+ return 0;
+--- a/tn7dsl.c
++++ b/tn7dsl.c
+@@ -136,6 +136,27 @@
+ #define NEW_TRAINING_VAL_T1413 128
+ #define NEW_TRAINING_VAL_MMODE 255
+
++extern char *mp_modulation;
++extern int mp_fine_gain_control;
++extern int mp_fine_gain_value;
++extern int mp_enable_margin_retrain;
++extern int mp_margin_threshold;
++extern int mp_enable_rate_adapt;
++extern int mp_powercutback;
++extern int mp_trellis;
++extern int mp_bitswap;
++extern int mp_maximum_bits_per_carrier;
++extern int mp_maximum_interleave_depth;
++extern int mp_pair_selection;
++extern int mp_dgas_polarity;
++extern int mp_los_alarm;
++extern char *mp_eoc_vendor_id;
++extern int mp_eoc_vendor_revision;
++extern char *mp_eoc_vendor_serialnum;
++extern char *mp_invntry_vernum;
++extern int mp_dsl_bit_tmode;
++extern int mp_high_precision;
++
+ int testflag1 = 0;
+ extern int __guDbgLevel;
+ extern sar_stat_t sarStat;
+@@ -2818,84 +2839,80 @@ static int tn7dsl_set_dsl(void)
+
+ // modulation
+ ptr = prom_getenv("modulation");
+- if (ptr)
++ if (ptr || mp_modulation != NULL)
+ {
+- tn7dsl_set_modulation(ptr, FALSE);
++ tn7dsl_set_modulation(mp_modulation == NULL ? ptr : mp_modulation, FALSE);
+ }
+
+ // Fine Gains
+ ptr = prom_getenv("fine_gain_control");
+- if (ptr)
++ if (ptr || mp_fine_gain_control != -1)
+ {
+- value = os_atoi(ptr);
++ value = mp_fine_gain_control == -1 ? os_atoi(ptr) : mp_fine_gain_control;
+ tn7dsl_ctrl_fineGain(value);
+ }
+ ptr = NULL;
+ ptr = prom_getenv("fine_gain_value");
+- if(ptr)
+- tn7dsl_set_fineGainValue(os_atoh(ptr));
++ if(ptr || mp_fine_gain_value != -1)
++ tn7dsl_set_fineGainValue(mp_fine_gain_value == -1 ? os_atoh(ptr) : mp_fine_gain_value);
+
+ // margin retrain
+ ptr = NULL;
+ ptr = prom_getenv("enable_margin_retrain");
+- if(ptr)
++ value = mp_enable_margin_retrain == -1 ? (ptr ? os_atoi(ptr) : 0) : mp_enable_margin_retrain;
++
++ if (value == 1)
+ {
+- value = os_atoi(ptr);
+- if(value == 1)
++ dslhal_api_setMarginMonitorFlags(pIhw, 0, 1);
++ bMarginRetrainEnable = 1;
++ //printk("enable showtime margin monitor.\n");
++
++ ptr = NULL;
++ ptr = prom_getenv("margin_threshold");
++ value = mp_margin_threshold == -1 ? (ptr ? os_atoi(ptr) : 0) : mp_margin_threshold;
++
++ if(value >= 0)
+ {
+- dslhal_api_setMarginMonitorFlags(pIhw, 0, 1);
+- bMarginRetrainEnable = 1;
+- //printk("enable showtime margin monitor.\n");
+- ptr = NULL;
+- ptr = prom_getenv("margin_threshold");
+- if(ptr)
+- {
+- value = os_atoi(ptr);
+- //printk("Set margin threshold to %d x 0.5 db\n",value);
+- if(value >= 0)
+- {
+- dslhal_api_setMarginThreshold(pIhw, value);
+- bMarginThConfig=1;
+- }
+- }
++ dslhal_api_setMarginThreshold(pIhw, value);
++ bMarginThConfig=1;
+ }
+ }
+
+ // rate adapt
+ ptr = NULL;
+ ptr = prom_getenv("enable_rate_adapt");
+- if(ptr)
++ if(ptr || mp_enable_rate_adapt != -1)
+ {
+- dslhal_api_setRateAdaptFlag(pIhw, os_atoi(ptr));
++ dslhal_api_setRateAdaptFlag(pIhw, mp_enable_rate_adapt == -1 ? os_atoi(ptr) : mp_enable_rate_adapt);
+ }
+
+ // set powercutback
+ ptr = NULL;
+ ptr = prom_getenv("powercutback");
+- if(ptr)
++ if(ptr || mp_powercutback != -1)
+ {
+- dslhal_advcfg_onOffPcb(pIhw, os_atoi(ptr));
++ dslhal_advcfg_onOffPcb(pIhw, mp_powercutback == -1 ? os_atoi(ptr) : mp_powercutback);
+ }
+
+ // trellis
+ ptr = NULL;
+ ptr = prom_getenv("trellis");
+- if(ptr)
++ if(ptr || mp_trellis != -1)
+ {
+- dslhal_api_setTrellisFlag(pIhw, os_atoi(ptr));
+- trellis = os_atoi(ptr);
++ trellis = mp_trellis == -1 ? os_atoi(ptr) : mp_trellis;
++ dslhal_api_setTrellisFlag(pIhw, trellis);
+ //printk("trellis=%d\n");
+ }
+
+ // bitswap
+ ptr = NULL;
+ ptr = prom_getenv("bitswap");
+- if(ptr)
++ if(ptr || mp_bitswap != -1)
+ {
+ int offset[2] = {33, 0};
+ unsigned int bitswap;
+
+- bitswap = os_atoi(ptr);
++ bitswap = mp_bitswap == -1 ? os_atoi(ptr) : mp_bitswap;
+
+ tn7dsl_generic_read(2, offset);
+ dslReg &= dslhal_support_byteSwap32(0xFFFFFF00);
+@@ -2913,46 +2930,47 @@ static int tn7dsl_set_dsl(void)
+ // maximum bits per carrier
+ ptr = NULL;
+ ptr = prom_getenv("maximum_bits_per_carrier");
+- if(ptr)
++ if(ptr || mp_maximum_bits_per_carrier != -1)
+ {
+- dslhal_api_setMaxBitsPerCarrierUpstream(pIhw, os_atoi(ptr));
++ dslhal_api_setMaxBitsPerCarrierUpstream(pIhw, mp_maximum_bits_per_carrier == -1 ? os_atoi(ptr) : mp_maximum_bits_per_carrier);
+ }
+
+ // maximum interleave depth
+ ptr = NULL;
+ ptr = prom_getenv("maximum_interleave_depth");
+- if(ptr)
++ if(ptr || mp_maximum_interleave_depth != -1)
+ {
+- dslhal_api_setMaxInterleaverDepth(pIhw, os_atoi(ptr));
++ dslhal_api_setMaxInterleaverDepth(pIhw, mp_maximum_interleave_depth == -1 ? os_atoi(ptr) : mp_maximum_interleave_depth);
+ }
+
+ // inner and outer pairs
+ ptr = NULL;
+ ptr = prom_getenv("pair_selection");
+- if(ptr)
++ if(ptr || mp_pair_selection != -1)
+ {
+- dslhal_api_selectInnerOuterPair(pIhw, os_atoi(ptr));
++ dslhal_api_selectInnerOuterPair(pIhw, mp_pair_selection == -1 ? os_atoi(ptr) : mp_pair_selection);
+ }
+
+ ptr = NULL;
+ ptr = prom_getenv("dgas_polarity");
+- if(ptr)
++ if(ptr || mp_dgas_polarity != -1)
+ {
+ dslhal_api_configureDgaspLpr(pIhw, 1, 1);
+- dslhal_api_configureDgaspLpr(pIhw, 0, os_atoi(ptr));
++ dslhal_api_configureDgaspLpr(pIhw, 0, mp_dgas_polarity == -1 ? os_atoi(ptr) : mp_dgas_polarity);
+ }
+
+ ptr = NULL;
+ ptr = prom_getenv("los_alarm");
+- if(ptr)
++ if(ptr || mp_los_alarm != -1)
+ {
+- dslhal_api_disableLosAlarm(pIhw, os_atoi(ptr));
++ dslhal_api_disableLosAlarm(pIhw, mp_los_alarm == -1 ? os_atoi(ptr) : mp_los_alarm);
+ }
+
+ ptr = NULL;
+ ptr = prom_getenv("eoc_vendor_id");
+- if(ptr)
++ if(ptr || mp_eoc_vendor_id != NULL)
+ {
++ ptr = mp_eoc_vendor_id == NULL ? ptr : mp_eoc_vendor_id;
+ for(i=0;i<8;i++)
+ {
+ tmp[0]=ptr[i*2];
+@@ -2977,26 +2995,26 @@ static int tn7dsl_set_dsl(void)
+ }
+ ptr = NULL;
+ ptr = prom_getenv("eoc_vendor_revision");
+- if(ptr)
++ if(ptr || mp_eoc_vendor_revision != -1)
+ {
+- value = os_atoi(ptr);
++ value = mp_eoc_vendor_revision == -1 ? os_atoi(ptr) : mp_eoc_vendor_revision;
+ //printk("eoc rev=%d\n", os_atoi(ptr));
+ dslhal_api_setEocRevisionNumber(pIhw, (char *)&value);
+
+ }
+ ptr = NULL;
+ ptr = prom_getenv("eoc_vendor_serialnum");
+- if(ptr)
++ if(ptr || mp_eoc_vendor_serialnum != NULL)
+ {
+- dslhal_api_setEocSerialNumber(pIhw, ptr);
++ dslhal_api_setEocSerialNumber(pIhw, mp_eoc_vendor_serialnum == NULL ? ptr : mp_eoc_vendor_serialnum);
+ }
+
+ // CQ10037 Added invntry_vernum environment variable to be able to set version number in ADSL2, ADSL2+ modes.
+ ptr = NULL;
+ ptr = prom_getenv("invntry_vernum");
+- if(ptr)
++ if(ptr || mp_invntry_vernum != NULL)
+ {
+- dslhal_api_setEocRevisionNumber(pIhw, ptr);
++ dslhal_api_setEocRevisionNumber(pIhw, mp_invntry_vernum == NULL ? ptr : mp_invntry_vernum);
+ }
+
+ return 0;
+@@ -3041,7 +3059,7 @@ int tn7dsl_init(void *priv)
+ * backward compatibility.
+ */
+ cp = prom_getenv("DSL_BIT_TMODE");
+- if (cp)
++ if (cp || mp_dsl_bit_tmode != -1)
+ {
+ printk("%s : env var DSL_BIT_TMODE is set\n", __FUNCTION__);
+ /*
+@@ -3070,9 +3088,9 @@ int tn7dsl_init(void *priv)
+
+ // UR8_MERGE_START CQ11054 Jack Zhang
+ cp = prom_getenv("high_precision");
+- if (cp)
++ if (cp || mp_high_precision != -1)
+ {
+- high_precision_selected = os_atoi(cp);
++ high_precision_selected = mp_high_precision == -1 ? os_atoi(cp) : mp_high_precision;
+ }
+ if ( high_precision_selected)
+ {
+--- a/tn7sar.c
++++ b/tn7sar.c
+@@ -74,6 +74,8 @@ typedef void OS_SETUP;
+ /* PDSP Firmware files */
+ #include "tnetd7300_sar_firm.h"
+
++extern int mp_oam_lb_timeout;
++extern int mp_autopvc_enable;
+
+ enum
+ {
+@@ -817,9 +819,9 @@ int tn7sar_setup_oam_channel(Tn7AtmPriva
+ pHalDev = (HAL_DEVICE *)priv->pSarHalDev;
+
+ pauto_pvc = prom_getenv("autopvc_enable");
+- if(pauto_pvc) //CQ10273
++ if(pauto_pvc || mp_autopvc_enable != -1) //CQ10273
+ {
+- auto_pvc =tn7sar_strtoul(pauto_pvc, NULL, 10);
++ auto_pvc = mp_autopvc_enable == -1 ? tn7sar_strtoul(pauto_pvc, NULL, 10) : mp_autopvc_enable;
+ }
+
+ memset(&chInfo, 0xff, sizeof(chInfo));
+@@ -985,9 +987,9 @@ int tn7sar_init(struct atm_dev *dev, Tn7
+
+ /* read in oam lb timeout value */
+ pLbTimeout = prom_getenv("oam_lb_timeout");
+- if(pLbTimeout)
++ if(pLbTimeout || mp_oam_lb_timeout != -1)
+ {
+- lbTimeout =tn7sar_strtoul(pLbTimeout, NULL, 10);
++ lbTimeout = mp_oam_lb_timeout == -1 ? tn7sar_strtoul(pLbTimeout, NULL, 10) : mp_oam_lb_timeout;
+ oamLbTimeout = lbTimeout;
+ pHalFunc->Control(pHalDev,"OamLbTimeout", "Set", &lbTimeout);
+ }
diff --git a/package/system/ar7-atm/patches-D7.04.03.00/170-bus_id_removal.patch b/package/system/ar7-atm/patches-D7.04.03.00/170-bus_id_removal.patch
new file mode 100644
index 0000000..9f1f0fd
--- /dev/null
+++ b/package/system/ar7-atm/patches-D7.04.03.00/170-bus_id_removal.patch
@@ -0,0 +1,30 @@
+--- a/tn7dsl.c
++++ b/tn7dsl.c
+@@ -109,6 +109,7 @@
+ #include <linux/vmalloc.h>
+ #include <linux/file.h>
+ #include <linux/firmware.h>
++#include <linux/version.h>
+
+ #include <asm/io.h>
+ #include <asm/ar7/ar7.h>
+@@ -446,7 +447,9 @@ static void avsar_release(struct device
+ }
+
+ static struct device avsar = {
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)
+ .bus_id = "vlynq",
++#endif
+ .release = avsar_release,
+ };
+
+@@ -455,6 +458,9 @@ int shim_osLoadFWImage(unsigned char *pt
+ const struct firmware *fw_entry;
+ size_t size;
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30)
++ dev_set_name(&avsar, "avsar");
++#endif
+ printk("requesting firmware image \"ar0700xx.bin\"\n");
+ if(device_register(&avsar) < 0) {
+ printk(KERN_ERR
diff --git a/package/system/ar7-atm/patches-D7.04.03.00/180-git_headers_include.patch b/package/system/ar7-atm/patches-D7.04.03.00/180-git_headers_include.patch
new file mode 100644
index 0000000..6bd8f48
--- /dev/null
+++ b/package/system/ar7-atm/patches-D7.04.03.00/180-git_headers_include.patch
@@ -0,0 +1,54 @@
+--- a/tn7atm.c
++++ b/tn7atm.c
+@@ -71,10 +71,16 @@
+ #include <linux/proc_fs.h>
+ #include <linux/string.h>
+ #include <linux/ctype.h>
++#include <linux/version.h>
+
+ #include <asm/io.h>
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)
+ #include <asm/ar7/ar7.h>
+ #include <asm/ar7/prom.h>
++#else
++#include <asm/mach-ar7/ar7.h>
++#include <asm/mach-ar7/prom.h>
++#endif
+
+ #include "dsl_hal_api.h"
+ #include "tn7atm.h"
+--- a/tn7dsl.c
++++ b/tn7dsl.c
+@@ -112,8 +112,13 @@
+ #include <linux/version.h>
+
+ #include <asm/io.h>
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)
+ #include <asm/ar7/ar7.h>
+ #include <asm/ar7/prom.h>
++#else
++#include <asm/mach-ar7/ar7.h>
++#include <asm/mach-ar7/prom.h>
++#endif
+
+ /* Modules specific header files */
+ #include "tn7atm.h"
+--- a/tn7sar.c
++++ b/tn7sar.c
+@@ -52,10 +52,16 @@
+ #include <linux/proc_fs.h>
+ #include <linux/string.h>
+ #include <linux/ctype.h>
++#include <linux/version.h>
+
+ #include <asm/io.h>
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)
+ #include <asm/ar7/ar7.h>
+ #include <asm/ar7/prom.h>
++#else
++#include <asm/mach-ar7/ar7.h>
++#include <asm/mach-ar7/prom.h>
++#endif
+
+ #define _CPHAL_AAL5
+ #define _CPHAL_SAR
diff --git a/package/system/ar7-atm/patches-D7.04.03.00/190-2.6.32_proc_fixes.patch b/package/system/ar7-atm/patches-D7.04.03.00/190-2.6.32_proc_fixes.patch
new file mode 100644
index 0000000..11487bf
--- /dev/null
+++ b/package/system/ar7-atm/patches-D7.04.03.00/190-2.6.32_proc_fixes.patch
@@ -0,0 +1,79 @@
+--- a/tn7dsl.c
++++ b/tn7dsl.c
+@@ -203,7 +203,11 @@ led_reg_t ledreg[2];
+ static struct led_funcs ledreg[2];
+ #endif
+
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
+ #define DEV_DSLMOD CTL_UNNUMBERED
++#else
++#define DEV_DSLMOD 0
++#endif
+ #define MAX_STR_SIZE 256
+ #define DSL_MOD_SIZE 256
+
+@@ -3431,9 +3435,16 @@ static int dslmod_sysctl(ctl_table *ctl,
+ */
+ if(write)
+ {
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)
+ ret = proc_dostring(ctl, write, filp, buffer, lenp, 0);
+-
++#else
++ ret = proc_dostring(ctl, write, buffer, lenp, 0);
++#endif
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
+ switch (ctl->ctl_name)
++#else
++ switch ((long)ctl->extra2)
++#endif
+ {
+ case DEV_DSLMOD:
+ ptr = strpbrk(info, " \t");
+@@ -3517,14 +3528,29 @@ static int dslmod_sysctl(ctl_table *ctl,
+ else
+ {
+ len += sprintf(info+len, mod_req);
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)
+ ret = proc_dostring(ctl, write, filp, buffer, lenp, 0);
++#else
++ ret = proc_dostring(ctl, write, buffer, lenp, 0);
++#endif
+ }
+ return ret;
+ }
+
+
+ ctl_table dslmod_table[] = {
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
+ {DEV_DSLMOD, "dslmod", info, DSL_MOD_SIZE, 0644, NULL, NULL, &dslmod_sysctl, &sysctl_string}
++#else
++ {
++ .procname = "dslmod",
++ .data = info,
++ .maxlen = DSL_MOD_SIZE,
++ .mode = 0644,
++ .proc_handler = &dslmod_sysctl,
++ .extra2 = (void *)DEV_DSLMOD,
++ }
++#endif
+ ,
+ {0}
+ };
+@@ -3532,7 +3558,16 @@ ctl_table dslmod_table[] = {
+ /* Make sure that /proc/sys/dev is there */
+ ctl_table dslmod_root_table[] = {
+ #ifdef CONFIG_PROC_FS
++ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
+ {CTL_DEV, "dev", NULL, 0, 0555, dslmod_table}
++ #else
++ {
++ .procname = "dev",
++ .maxlen = 0,
++ .mode = 0555,
++ .child = dslmod_table,
++ }
++ #endif
+ ,
+ #endif /* CONFIG_PROC_FS */
+ {0}
diff --git a/package/system/ar7-atm/patches-D7.04.03.00/200-2.6.37_args.patch b/package/system/ar7-atm/patches-D7.04.03.00/200-2.6.37_args.patch
new file mode 100644
index 0000000..59c1d58
--- /dev/null
+++ b/package/system/ar7-atm/patches-D7.04.03.00/200-2.6.37_args.patch
@@ -0,0 +1,36 @@
+--- a/tn7atm.c
++++ b/tn7atm.c
+@@ -1867,7 +1867,11 @@ static int __init tn7atm_register (Tn7At
+
+ dgprintf (4, "device %s being registered\n", priv->name);
+
++ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37)
+ mydev = atm_dev_register (priv->proc_name, &tn7atm_ops, -1, NULL);
++ #else
++ mydev = atm_dev_register (priv->proc_name, NULL, &tn7atm_ops, -1, NULL);
++ #endif
+
+ if (mydev == NULL)
+ {
+--- a/tn7dsl.c
++++ b/tn7dsl.c
+@@ -466,14 +466,17 @@ int shim_osLoadFWImage(unsigned char *pt
+ {
+ const struct firmware *fw_entry;
+ size_t size;
++ int ret;
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30)
+ dev_set_name(&avsar, "avsar");
+ #endif
+ printk("requesting firmware image \"ar0700xx.bin\"\n");
+- if(device_register(&avsar) < 0) {
++ dev_set_name(&avsar, "avsar");
++ ret = device_register(&avsar);
++ if (ret < 0) {
+ printk(KERN_ERR
+- "avsar: device_register fails\n");
++ "avsar: device_register fails, error%i\n", ret);
+ return -1;
+ }
+
diff --git a/package/system/ar7-atm/patches-D7.04.03.00/210-3.3-remove-smp_lock.h.patch b/package/system/ar7-atm/patches-D7.04.03.00/210-3.3-remove-smp_lock.h.patch
new file mode 100644
index 0000000..525218c
--- /dev/null
+++ b/package/system/ar7-atm/patches-D7.04.03.00/210-3.3-remove-smp_lock.h.patch
@@ -0,0 +1,33 @@
+--- a/tn7atm.c
++++ b/tn7atm.c
+@@ -67,7 +67,7 @@
+ #include <linux/atmdev.h>
+ #include <linux/delay.h>
+ #include <linux/spinlock.h>
+-#include <linux/smp_lock.h>
++#include <linux/interrupt.h>
+ #include <linux/proc_fs.h>
+ #include <linux/string.h>
+ #include <linux/ctype.h>
+--- a/tn7sar.c
++++ b/tn7sar.c
+@@ -48,7 +48,7 @@
+ #include <linux/atmdev.h>
+ #include <linux/delay.h>
+ #include <linux/spinlock.h>
+-#include <linux/smp_lock.h>
++#include <linux/interrupt.h>
+ #include <linux/proc_fs.h>
+ #include <linux/string.h>
+ #include <linux/ctype.h>
+--- a/tn7dsl.c
++++ b/tn7dsl.c
+@@ -100,7 +100,7 @@
+ #include <linux/atmdev.h>
+ #include <linux/delay.h>
+ #include <linux/spinlock.h>
+-#include <linux/smp_lock.h>
++#include <linux/interrupt.h>
+ #include <linux/proc_fs.h>
+ #include <linux/string.h>
+ #include <linux/ctype.h>
diff --git a/package/system/ar7-atm/patches-D7.05.01.00/.svn/entries b/package/system/ar7-atm/patches-D7.05.01.00/.svn/entries
new file mode 100644
index 0000000..3f63559
--- /dev/null
+++ b/package/system/ar7-atm/patches-D7.05.01.00/.svn/entries
@@ -0,0 +1,436 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/system/ar7-atm/patches-D7.05.01.00
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+110-interrupt_fix.patch
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+34c4d46673ebb1e04cb0a39b74788c44
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1122
+
+120-no_dumb_inline.patch
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+45face04d32d1e077aaa4ff03b920b9e
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+394
+
+180-git_headers_include.patch
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+c65763bc85cc4772d53e7bdad4380e71
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1148
+
+200-2.6.37_args.patch
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+452fd807a8d1853738824c353171d398
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+963
+
+210-3.3-remove-smp_lock.h.patch
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+7acd6fa040446dcbf06fc451370a34c4
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+812
+
+130-powercutback.patch
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+5ed8db6656289bb5c405f91cbc9f3072
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1770
+
+160-module-params.patch
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+0e74cfa288267e57c99a3fef76ac4b04
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+21391
+
+100-compile_fix.patch
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+f463ed052186b1cf888b4439e1343067
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+22074
+
+140-debug_mode.patch
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+09f11ce1a1d61e25c8837f99bfcd517e
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1101
+
+150-tasklet_mode.patch
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+ab53999f8a021882c5a4a47b745faf9b
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+690
+
+170-bus_id_removal.patch
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+a88213b23198760630073fe37f2c8b26
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+740
+
+190-2.6.32_proc_fixes.patch
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+4eaead4ef5e9ec488347525f5ba6a28a
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1889
+
diff --git a/package/system/ar7-atm/patches-D7.05.01.00/.svn/prop-base/100-compile_fix.patch.svn-base b/package/system/ar7-atm/patches-D7.05.01.00/.svn/prop-base/100-compile_fix.patch.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/system/ar7-atm/patches-D7.05.01.00/.svn/prop-base/100-compile_fix.patch.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/system/ar7-atm/patches-D7.05.01.00/.svn/text-base/100-compile_fix.patch.svn-base b/package/system/ar7-atm/patches-D7.05.01.00/.svn/text-base/100-compile_fix.patch.svn-base
new file mode 100644
index 0000000..7dee220
--- /dev/null
+++ b/package/system/ar7-atm/patches-D7.05.01.00/.svn/text-base/100-compile_fix.patch.svn-base
@@ -0,0 +1,808 @@
+--- a/cppi_cpaal5.c
++++ b/cppi_cpaal5.c
+@@ -360,7 +360,7 @@ static int halRxReturn(HAL_RECEIVEINFO *
+ {
+ /* malloc failed, add this RCB to Needs Buffer List */
+ TempRcb->FragCount = 1; /*MJH+030417*/
+- (HAL_RCB *)TempRcb->Eop = TempRcb; /* GSG +030430 */
++ TempRcb->Eop = TempRcb; /* GSG +030430 */
+
+ if(HalDev->NeedsCount < MAX_NEEDS) /* +MJH 030410 */
+ { /* +MJH 030410 */
+--- a/dsl_hal_api.c
++++ b/dsl_hal_api.c
+@@ -273,15 +273,15 @@
+ * 09/15/07 CPH CQ11466 Added EFM support
+ * 09/27/07 EYin CQ11929: Added NFEC/INP/Lp/Rp reporting for only ADSL2/2+ mode.
+ ******************************************************************************/
+-#include <dev_host_interface.h>
+-#include <dsl_hal_register.h>
+-#include <dsl_hal_support.h>
++#include "dev_host_interface.h"
++#include "dsl_hal_register.h"
++#include "dsl_hal_support.h"
+
+ #ifndef NO_ADV_STATS
+-#include <dsl_hal_logtable.h>
++#include "dsl_hal_logtable.h"
+ #endif
+
+-#include <dsl_hal_version.h>
++#include "dsl_hal_version.h"
+
+ // UR8_MERGE_START CQ11054 Jack Zhang
+ static unsigned int highprecision_selected = 0; //By default we use low precision for backward compt.
+--- a/dsl_hal_support.c
++++ b/dsl_hal_support.c
+@@ -142,9 +142,9 @@
+ * UR8_MERGE_START_END CQ11922 Tim
+ * 04Sep07 0.14.00 Tim CQ11922: Added support for new scratchram for INP NDR tables
+ *******************************************************************************/
+-#include <dev_host_interface.h>
+-#include <dsl_hal_register.h>
+-#include <dsl_hal_support.h>
++#include "dev_host_interface.h"
++#include "dsl_hal_register.h"
++#include "dsl_hal_support.h"
+
+ #define NUM_READ_RETRIES 3
+ static unsigned int dslhal_support_adsl2ByteSwap32(unsigned int in32Bits);
+--- a/dsl_hal_support.h
++++ b/dsl_hal_support.h
+@@ -49,7 +49,7 @@
+ * 04Nov05 0.11.00 CPH Fixed T1413 mode got Zero DS/US rate when DSL_BIT_TMODE is set.
+ *******************************************************************************/
+
+-#include <dsl_hal_api.h>
++#include "dsl_hal_api.h"
+
+ #define virtual2Physical(a) (((int)a)&~0xe0000000)
+ /* External Function Prototype Declarations */
+--- a/Makefile
++++ b/Makefile
+@@ -1,18 +1,9 @@
+-# File: drivers/atm/ti_evm3/Makefile
+ #
+-# Makefile for the Texas Instruments EVM3 ADSL/ATM driver.
++# Makefile for the TIATM device driver.
+ #
+-#
+-# Copyright (c) 2000 Texas Instruments Incorporated.
+-# Jeff Harrell (jharrell@telogy.com)
+-# Viren Balar (vbalar@ti.com)
+-# Victor Wells (vwells@telogy.com)
+-#
+-include $(TOPDIR)/Rules.make
+-
+-
+-
+-
+-
+-
+
++CONFIG_SANGAM_ATM=m
++#EXTRA_CFLAGS += -DEL -I. -DPOST_SILICON -DCOMMON_NSP -DCONFIG_LED_MODULE -DDEREGISTER_LED -DNO_ACT
++EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -DNO_ACT -D__NO__VOICE_PATCH__ -DEL
++obj-$(CONFIG_SANGAM_ATM) := tiatm.o
++tiatm-objs += cpsar.o aal5sar.o tn7sar.o tn7atm.o tn7dsl.o dsl_hal_api.o dsl_hal_support.o
+--- a/tn7atm.c
++++ b/tn7atm.c
+@@ -66,7 +66,6 @@
+ * 09/18/07 CPH CQ11466 Added EFM Support
+ *********************************************************************************************/
+
+-#include <linux/config.h>
+ #include <linux/kernel.h>
+ #include <linux/module.h>
+ #include <linux/init.h>
+@@ -74,11 +73,14 @@
+ #include <linux/delay.h>
+ #include <linux/spinlock.h>
+ #include <linux/smp_lock.h>
+-#include <asm/io.h>
+-#include <asm/mips-boards/prom.h>
+ #include <linux/proc_fs.h>
+ #include <linux/string.h>
+ #include <linux/ctype.h>
++
++#include <asm/io.h>
++#include <asm/ar7/ar7.h>
++#include <asm/ar7/prom.h>
++
+ #include "dsl_hal_api.h"
+ #ifdef AR7_EFM
+ #include "tn7efm.h"
+@@ -90,6 +92,7 @@
+ #include "dsl_hal_register.h"
+
+ #ifdef MODULE
++MODULE_LICENSE("GPL");
+ MODULE_DESCRIPTION ("Tnetd73xx ATM Device Driver");
+ MODULE_AUTHOR ("Zhicheng Tang");
+ #endif
+@@ -108,9 +111,9 @@ MODULE_AUTHOR ("Zhicheng Tang");
+
+ /*end of externs */
+
+-#ifndef TI_STATIC_ALLOCATIONS
+-#define TI_STATIC_ALLOCATIONS
+-#endif
++//#ifndef TI_STATIC_ALLOCATIONS
++//#define TI_STATIC_ALLOCATIONS
++//#endif
+
+ #define tn7atm_kfree_skb(x) dev_kfree_skb(x)
+
+@@ -135,7 +138,7 @@ static int EnableQoS = FALSE;
+ /* prototypes */
+ static int tn7atm_set_can_support_adsl2 (int can);
+
+-static int tn7atm_open (struct atm_vcc *vcc, short vpi, int vci);
++static int tn7atm_open (struct atm_vcc *vcc);
+
+ void tn7atm_close (struct atm_vcc *vcc);
+
+@@ -298,13 +301,12 @@ static const struct atmdev_ops tn7atm_op
+ getsockopt: NULL,
+ setsockopt: NULL,
+ send: tn7atm_send,
+- sg_send: NULL,
+ phy_put: NULL,
+ phy_get: NULL,
+ change_qos: tn7atm_change_qos,
+ };
+
+-const char drv_proc_root_folder[] = "avalanche/";
++const char drv_proc_root_folder[] = "avalanche";
+ static struct proc_dir_entry *root_proc_dir_entry = NULL;
+ #define DRV_PROC_MODE 0644
+ static int proc_root_already_exists = TRUE;
+@@ -626,56 +628,6 @@ static int turbodsl_check_priority_type(
+
+ /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+- * Function: int tn7atm_walk_vccs(struct atm_dev *dev, short *vcc, int *vci)
+- *
+- * Description: retrieve VPI/VCI for connection
+- *
+- *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+-static int tn7atm_walk_vccs (struct atm_vcc *vcc, short *vpi, int *vci)
+-{
+- struct atm_vcc *walk;
+-
+- /*
+- * find a free VPI
+- */
+- if (*vpi == ATM_VPI_ANY)
+- {
+-
+- for (*vpi = 0, walk = vcc->dev->vccs; walk; walk = walk->next)
+- {
+-
+- if ((walk->vci == *vci) && (walk->vpi == *vpi))
+- {
+- (*vpi)++;
+- walk = vcc->dev->vccs;
+- }
+- }
+- }
+-
+- /*
+- * find a free VCI
+- */
+- if (*vci == ATM_VCI_ANY)
+- {
+-
+- for (*vci = ATM_NOT_RSV_VCI, walk = vcc->dev->vccs; walk;
+- walk = walk->next)
+- {
+-
+- if ((walk->vpi = *vpi) && (walk->vci == *vci))
+- {
+- *vci = walk->vci + 1;
+- walk = vcc->dev->vccs;
+- }
+- }
+- }
+-
+- return 0;
+-}
+-
+-
+-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+- *
+ * Function: int tn7atm_sar_irq(void)
+ *
+ * Description: tnetd73xx SAR interrupt.
+@@ -766,7 +718,7 @@ static int __init tn7atm_irq_request (st
+
+ priv->sar_irq = LNXINTNUM (ATM_SAR_INT); /* Interrupt line # */
+
+- if (request_irq (priv->sar_irq, tn7atm_sar_irq, SA_INTERRUPT, "SAR ", dev))
++ if (request_irq (priv->sar_irq, tn7atm_sar_irq, IRQF_DISABLED, "SAR ", dev))
+ printk ("Could not register tn7atm_sar_irq\n");
+
+ /*
+@@ -777,8 +729,8 @@ static int __init tn7atm_irq_request (st
+ {
+ def_sar_inter_pace = os_atoi (ptr);
+ }
+- avalanche_request_pacing (priv->sar_irq, ATM_SAR_INT_PACING_BLOCK_NUM,
+- def_sar_inter_pace);
++ /* avalanche_request_pacing (priv->sar_irq, ATM_SAR_INT_PACING_BLOCK_NUM,
++ def_sar_inter_pace); */
+
+
+ #ifdef AR7_EFM
+@@ -790,7 +742,7 @@ static int __init tn7atm_irq_request (st
+ * Reigster Receive interrupt A
+ */
+ priv->dsl_irq = LNXINTNUM (ATM_DSL_INT); /* Interrupt line # */
+- if (request_irq (priv->dsl_irq, tn7atm_dsl_irq, SA_INTERRUPT, "DSL ", dev))
++ if (request_irq (priv->dsl_irq, tn7atm_dsl_irq, IRQF_DISABLED, "DSL ", dev))
+ printk ("Could not register tn7atm_dsl_irq\n");
+
+ /***** VRB Tasklet Mode ****/
+@@ -958,11 +910,15 @@ static int __init tn7atm_get_ESI (struct
+ #define ATM_VBR_RT 5
+ #endif
+
+-int tn7atm_open (struct atm_vcc *vcc, short vpi, int vci)
++int tn7atm_open (struct atm_vcc *vcc)
+ {
+ tn7atm_activate_vc_parm_t tn7atm_activate_vc_parm;
+ int rc;
+ //int flags;
++ tn7atm_activate_vc_parm.pcr = 0x20000;
++ tn7atm_activate_vc_parm.scr = 0x20000;
++ tn7atm_activate_vc_parm.mbs = 0x20000;
++ tn7atm_activate_vc_parm.cdvt = 10000;
+
+ dgprintf(1, "tn7atm_open()\n");
+
+@@ -974,24 +930,18 @@ int tn7atm_open (struct atm_vcc *vcc, sh
+ return -1;
+ }
+
+- MOD_INC_USE_COUNT;
++// MOD_INC_USE_COUNT;
+
+- /* find a free VPI/VCI */
+- tn7atm_walk_vccs(vcc, &vpi, &vci);
+-
+- vcc->vpi = vpi;
+- vcc->vci = vci;
+-
+- if ((vci == ATM_VCI_UNSPEC) || (vpi == ATM_VCI_UNSPEC))
++ if ((vcc->vci == ATM_VCI_UNSPEC) || (vcc->vpi == ATM_VCI_UNSPEC))
+ {
+- MOD_DEC_USE_COUNT;
++// MOD_DEC_USE_COUNT;
+ return -EBUSY;
+ }
+
+- tn7atm_activate_vc_parm.vpi = vpi;
+- tn7atm_activate_vc_parm.vci = vci;
++ tn7atm_activate_vc_parm.vpi = vcc->vpi;
++ tn7atm_activate_vc_parm.vci = vcc->vci;
+
+- if ((vpi == CLEAR_EOC_VPI) && (vci == CLEAR_EOC_VCI))
++ if ((vcc->vpi == CLEAR_EOC_VPI) && (vcc->vci == CLEAR_EOC_VCI))
+ {
+ /* always use (max_dma_chan+1) for clear eoc */
+ tn7atm_activate_vc_parm.chan = EOC_DMA_CHAN;
+@@ -999,7 +949,7 @@ int tn7atm_open (struct atm_vcc *vcc, sh
+ /* check to see whether clear eoc is opened or not */
+ if (tn7atm_activate_vc_parm.priv->lut[tn7atm_activate_vc_parm.chan].inuse)
+ {
+- MOD_DEC_USE_COUNT;
++// MOD_DEC_USE_COUNT;
+ printk("tn7atm_open: Clear EOC channel (dmachan=%d) already in use.\n", tn7atm_activate_vc_parm.chan);
+ return -EBUSY;
+ }
+@@ -1008,7 +958,7 @@ int tn7atm_open (struct atm_vcc *vcc, sh
+ if (rc)
+ {
+ printk("tn7atm_open: failed to setup clear_eoc\n");
+- MOD_DEC_USE_COUNT;
++// MOD_DEC_USE_COUNT;
+ return -EBUSY;
+ }
+ tn7atm_set_lut(tn7atm_activate_vc_parm.priv,vcc, tn7atm_activate_vc_parm.chan);
+@@ -1017,17 +967,17 @@ int tn7atm_open (struct atm_vcc *vcc, sh
+ }
+ else /* PVC channel setup */
+ {
+- if ((vpi==REMOTE_MGMT_VPI) && (vci==REMOTE_MGMT_VCI))
++ if ((vcc->vpi==REMOTE_MGMT_VPI) && (vcc->vci==REMOTE_MGMT_VCI))
+ {
+ tn7atm_activate_vc_parm.chan = 14; /* always use chan 14 for MII PVC-base romote mgmt */
+ }
+ else
+ {
+- rc = tn7atm_lut_find(vpi, vci);
++ rc = tn7atm_lut_find(vcc->vpi, vcc->vci);
+ /* check to see whether PVC is opened or not */
+ if(ATM_NO_DMA_CHAN != rc)
+ {
+- MOD_DEC_USE_COUNT;
++// MOD_DEC_USE_COUNT;
+ printk("PVC already opened. dmachan = %d\n", rc);
+ return -EBUSY;
+ }
+@@ -1059,6 +1009,7 @@ int tn7atm_open (struct atm_vcc *vcc, sh
+ tn7atm_activate_vc_parm.priority = 2;
+ break;
+
++#if 0
+ case ATM_VBR: /* Variable Bit Rate-Non RealTime*/
+ tn7atm_activate_vc_parm.qos = 1;
+ tn7atm_activate_vc_parm.priority = 1;
+@@ -1080,6 +1031,7 @@ int tn7atm_open (struct atm_vcc *vcc, sh
+ tn7atm_activate_vc_parm.mbs = vcc->qos.txtp.max_pcr;
+ tn7atm_activate_vc_parm.cdvt = vcc->qos.txtp.max_cdv;
+ break;
++#endif
+
+ default:
+ tn7atm_activate_vc_parm.qos = 2;
+@@ -1107,7 +1059,7 @@ int tn7atm_open (struct atm_vcc *vcc, sh
+ if (rc < 0)
+ {
+ printk("failed to activate hw channel\n");
+- MOD_DEC_USE_COUNT;
++// MOD_DEC_USE_COUNT;
+ tn7atm_lut_clear(vcc, tn7atm_activate_vc_parm.chan);
+ //spin_unlock_irqrestore(&chan_init_lock, flags);
+ return -EBUSY;
+@@ -1197,7 +1149,7 @@ void tn7atm_close (struct atm_vcc *vcc)
+ tn7atm_lut_clear (vcc, dmachan);
+ //spin_unlock_irqrestore (&closeLock, closeFlag);
+
+- MOD_DEC_USE_COUNT;
++// MOD_DEC_USE_COUNT;
+
+ dgprintf (1, "Leave tn7atm_close\n");
+ }
+@@ -1630,8 +1582,7 @@ int tn7atm_receive (void *os_dev, int ch
+ * firewall is on */
+
+ dgprintf (3, "pushing the skb...\n");
+-
+- skb->stamp = vcc->timestamp = xtime;
++ __net_timestamp(skb);
+
+ xdump ((unsigned char *) skb->data, skb->len, 5);
+
+@@ -1854,8 +1805,7 @@ printk("!!!free atm irq: tn7atm_exit\n")
+
+ kfree (dev->dev_data);
+
+- // atm_dev_deregister (dev);
+- shutdown_atm_dev (dev);
++ atm_dev_deregister (dev);
+
+ /*
+ * remove proc entries
+@@ -2086,9 +2036,6 @@ static int __init tn7atm_detect (void)
+ * Set up proc entry for atm stats
+ */
+
+- if (tn7atm_xlate_proc_name
+- (drv_proc_root_folder, &root_proc_dir_entry, &residual))
+- {
+ printk ("Creating new root folder %s in the proc for the driver stats \n",
+ drv_proc_root_folder);
+ root_proc_dir_entry = proc_mkdir (drv_proc_root_folder, NULL);
+@@ -2098,7 +2045,6 @@ static int __init tn7atm_detect (void)
+ return -ENOMEM;
+ }
+ proc_root_already_exists = FALSE;
+- }
+
+
+ /*
+@@ -2731,7 +2677,5 @@ int tn7atm_proc_turbodsl_write(struct fi
+ return count;
+ }
+
+-#ifdef MODULE
+ module_init (tn7atm_detect);
+ module_exit (tn7atm_exit);
+-#endif /* MODULE */
+--- a/tn7atm.h
++++ b/tn7atm.h
+@@ -20,7 +20,8 @@
+ //#include "mips_support.h"
+ #include <linux/list.h>
+
+-#include <linux/config.h>
++#define MIPS_EXCEPTION_OFFSET 8
++#define LNXINTNUM(x)((x) + MIPS_EXCEPTION_OFFSET)
+
+ #ifdef CONFIG_MODVERSIONS
+ #include <linux/modversions.h>
+--- a/tn7dsl.c
++++ b/tn7dsl.c
+@@ -102,7 +102,6 @@
+ * UR8_MERGE_END CQ11813
+ * 09/18/07 CPH CQ11466: Added EFM support.
+ *********************************************************************************************/
+-#include <linux/config.h>
+ #include <linux/kernel.h>
+ #include <linux/module.h>
+ #include <linux/init.h>
+@@ -110,8 +109,6 @@
+ #include <linux/delay.h>
+ #include <linux/spinlock.h>
+ #include <linux/smp_lock.h>
+-#include <asm/io.h>
+-#include <asm/mips-boards/prom.h>
+ #include <linux/proc_fs.h>
+ #include <linux/string.h>
+ #include <linux/ctype.h>
+@@ -119,6 +116,12 @@
+ #include <linux/timer.h>
+ #include <linux/vmalloc.h>
+ #include <linux/file.h>
++#include <linux/firmware.h>
++
++#include <asm/io.h>
++#include <asm/ar7/ar7.h>
++#include <asm/ar7/prom.h>
++
+ /* Modules specific header files */
+ #ifdef AR7_EFM
+ #include "tn7efm.h"
+@@ -185,7 +188,7 @@ led_reg_t ledreg[2];
+ static struct led_funcs ledreg[2];
+ #endif
+
+-#define DEV_DSLMOD 1
++#define DEV_DSLMOD CTL_UNNUMBERED
+ #define MAX_STR_SIZE 256
+ #define DSL_MOD_SIZE 256
+
+@@ -316,7 +319,7 @@ static PITIDSLHW_T pIhw;
+ static volatile int bshutdown;
+ static char info[MAX_STR_SIZE];
+ /* Used for DSL Polling enable */
+-static DECLARE_MUTEX_LOCKED (adsl_sem_overlay);
++static struct semaphore adsl_sem_overlay;
+
+ //kthread_t overlay_thread;
+ /* end of module wide declars */
+@@ -369,6 +372,14 @@ int os_atoih (const char *pstr)
+ return val;
+ }
+
++int avalanche_request_intr_pacing(int irq_nr, unsigned int blk_num,
++ unsigned int pace_value)
++{
++ printk("avalanche_request_pacing(%d, %u, %u); // not implemented\n", irq_nr, blk_num, pace_value);
++ return 0;
++}
++
++
+ int os_atoi(const char *pStr)
+ {
+ int MulNeg = (*pStr == '-' ? -1 : 1);
+@@ -405,39 +416,6 @@ void dprintf (int uDbgLevel, char *szFmt
+ #endif
+ }
+
+-int strcmp(const char *s1, const char *s2)
+-{
+-
+- int size = strlen(s1);
+-
+- return(strncmp(s1, s2, size));
+-}
+-
+-int strncmp(const char *s1, const char *s2, size_t size)
+-{
+- int i = 0;
+- int max_size = (int)size;
+-
+- while((s1[i] != 0) && i < max_size)
+- {
+- if(s2[i] == 0)
+- {
+- return -1;
+- }
+- if(s1[i] != s2[i])
+- {
+- return 1;
+- }
+- i++;
+- }
+- if(s2[i] != 0)
+- {
+- return 1;
+- }
+-
+- return 0;
+-}
+-
+ // * UR8_MERGE_START CQ10640 Jack Zhang
+ int tn7dsl_dump_dsp_memory(char *input_str) //cph99
+ {
+@@ -487,144 +465,78 @@ unsigned int shim_osGetCpuFrequency(void
+ return CpuFrequency;
+ }
+
+-int shim_osLoadFWImage(unsigned char *ptr)
++static void avsar_release(struct device *dev)
+ {
+- unsigned int bytesRead;
+- mm_segment_t oldfs;
+- static struct file *filp;
+- unsigned int imageLength=0x5ffff;
+-
+-#ifdef AR7_EFM
+- int dp_alt=0;
+- char *ptr1=NULL;
+-#ifdef EFM_DEBUG
+- char *ptr2=NULL;
+- char *ptr3=NULL;
+-#endif
+-
+- if ((ptr1 = prom_getenv("DSL_DP_ALT")) != NULL)
+- {
+- dp_alt=os_atoi(ptr1);
+- if (dp_alt==1)
+- {
+- filp = filp_open(DSP_DEBUG_FIRMWARE_PATH,00,O_RDONLY);
+- if (!IS_ERR(filp))
+- {
+- strcpy (DSP_FIRMWARE_PATH, DSP_DEBUG_FIRMWARE_PATH);
+- }
+- }
+-#ifdef EFM_DEBUG
+- else if (dp_alt==2)
+- {
+- if ((ptr2 = prom_getenv("DSL_DP")) != NULL)
+- {
+- if (!strncmp(ptr2, "DSL_DP", 6))
+- { // indirect naming
+- if ((ptr3 = prom_getenv(ptr2)) != NULL)
+- filp = filp_open(ptr3,00,O_RDONLY);
+- ptr2 = ptr3; // redirect ptr2 to ptr3
+- }
+-
+- filp = filp_open(ptr2,00,O_RDONLY);
+- if (!IS_ERR(filp))
+- {
+- strcpy (DSP_FIRMWARE_PATH, ptr2);
+- }
+- }
+- }
+- printk("dp_path=%s\n", DSP_FIRMWARE_PATH);
+-#endif
+- }
+-#endif
+-
+- dgprintf(4, "tn7dsl_read_dsp()\n");
+-
+- dgprintf(4,"open file %s\n", DSP_FIRMWARE_PATH);
+-
+- filp=filp_open(DSP_FIRMWARE_PATH,00,O_RDONLY);
+- if(IS_ERR(filp))
+- {
+- printk("Failed: Could not open DSP binary file\n");
+- return -1;
+- }
+-
+- if (filp->f_dentry != NULL)
+- {
+- if (filp->f_dentry->d_inode != NULL)
+- {
+- printk ("DSP binary filesize = %d bytes\n",
+- (int) filp->f_dentry->d_inode->i_size);
+- imageLength = (unsigned int)filp->f_dentry->d_inode->i_size + 0x200;
+- }
+- }
+-
+- if (filp->f_op->read==NULL)
+- return -1; /* File(system) doesn't allow reads */
+-
+- /*
+- * Disable parameter checking
+- */
+- oldfs = get_fs();
+- set_fs(KERNEL_DS);
+-
+- /*
+- * Now read bytes from postion "StartPos"
+- */
+- filp->f_pos = 0;
+-
+- bytesRead = filp->f_op->read(filp,ptr,imageLength,&filp->f_pos);
+-
+- dgprintf(4,"file length = %d\n", bytesRead);
+-
+- set_fs(oldfs);
+-
+- /*
+- * Close the file
+- */
+- fput(filp);
+-
+- return bytesRead;
++ printk(KERN_DEBUG "avsar firmware released\n");
+ }
+
++static struct device avsar = {
++ .bus_id = "vlynq",
++ .release = avsar_release,
++};
+
+-unsigned int shim_read_overlay_page (void *ptr, unsigned int secOffset,
+- unsigned int secLength)
++int shim_osLoadFWImage(unsigned char *ptr)
+ {
+- unsigned int bytesRead;
+- mm_segment_t oldfs;
+- struct file *filp;
+-
+- dgprintf(4,"shim_read_overlay_page\n");
+- //dgprintf(4,"sec offset=%d, sec length =%d\n", secOffset, secLength);
++ const struct firmware *fw_entry;
++ size_t size;
+
+- filp=filp_open(DSP_FIRMWARE_PATH,00,O_RDONLY);
+- if(filp ==NULL)
+- {
+- printk("Failed: Could not open DSP binary file\n");
+- return -1;
+- }
+-
+- if (filp->f_op->read==NULL)
+- return -1; /* File(system) doesn't allow reads */
+-
+- /*
+- * Now read bytes from postion "StartPos"
+- */
++ printk("requesting firmware image \"ar0700xx.bin\"\n");
++ if(device_register(&avsar) < 0) {
++ printk(KERN_ERR
++ "avsar: device_register fails\n");
++ return -1;
++ }
++
++ if (request_firmware(&fw_entry, "ar0700xx.bin", &avsar)) {
++ printk(KERN_ERR
++ "avsar: Firmware not available\n");
++ device_unregister(&avsar);
++ return -1;
++ }
++ size = fw_entry->size;
++ device_unregister(&avsar);
++ if (size > 0x6ffff) {
++ printk(KERN_ERR
++ "avsar: Firmware too big (%d bytes)\n", size);
++ release_firmware(fw_entry);
++ return -1;
++ }
++ memcpy(ptr, fw_entry->data, size);
++ release_firmware(fw_entry);
++ return size;
++}
++
++unsigned int shim_read_overlay_page(void *ptr, unsigned int secOffset, unsigned int secLength)
++{
++ const struct firmware *fw_entry;
++
++ printk("requesting firmware image \"ar0700xx.bin\"\n");
++ if (device_register(&avsar) < 0) {
++ printk(KERN_ERR
++ "avsar: device_register fails\n");
++ return -1;
++ }
++
++ if (request_firmware(&fw_entry, "ar0700xx.bin", &avsar)) {
++ printk(KERN_ERR
++ "avsar: Firmware not available\n");
++ device_unregister(&avsar);
++ return -1;
++ }
++
++ device_unregister(&avsar);
++ if (fw_entry->size > secLength) {
++ printk(KERN_ERR
++ "avsar: Firmware too big (%d bytes)\n", fw_entry->size);
++ release_firmware(fw_entry);
++ return -1;
++ }
++ memcpy(ptr + secOffset, fw_entry->data, secLength);
++ release_firmware(fw_entry);
++ return secLength;
++}
+
+- if(filp->f_op->llseek)
+- filp->f_op->llseek(filp,secOffset, 0);
+- oldfs = get_fs();
+- set_fs(KERNEL_DS);
+- filp->f_pos = secOffset;
+- bytesRead = filp->f_op->read(filp,ptr,secLength,&filp->f_pos);
+
+- set_fs(oldfs);
+- /*
+- * Close the file
+- */
+- fput(filp);
+- return bytesRead;
+-}
+
+ int shim_osLoadDebugFWImage(unsigned char *ptr)
+ {
+@@ -3287,6 +3199,7 @@ int tn7dsl_init(void *priv)
+ int high_precision_selected = 0;
+ // UR8_MERGE_END CQ11054*
+
++ sema_init(&adsl_sem_overlay, 0);
+ /*
+ * start dsl
+ */
+@@ -3665,7 +3578,7 @@ static int dslmod_sysctl(ctl_table *ctl,
+ */
+ if(write)
+ {
+- ret = proc_dostring(ctl, write, filp, buffer, lenp);
++ ret = proc_dostring(ctl, write, filp, buffer, lenp, 0);
+
+ switch (ctl->ctl_name)
+ {
+@@ -3751,14 +3664,14 @@ static int dslmod_sysctl(ctl_table *ctl,
+ else
+ {
+ len += sprintf(info+len, mod_req);
+- ret = proc_dostring(ctl, write, filp, buffer, lenp);
++ ret = proc_dostring(ctl, write, filp, buffer, lenp, 0);
+ }
+ return ret;
+ }
+
+
+ ctl_table dslmod_table[] = {
+- {DEV_DSLMOD, "dslmod", info, DSL_MOD_SIZE, 0644, NULL, &dslmod_sysctl}
++ {DEV_DSLMOD, "dslmod", info, DSL_MOD_SIZE, 0644, NULL, NULL, &dslmod_sysctl, &sysctl_string}
+ ,
+ {0}
+ };
+@@ -3781,8 +3694,7 @@ void tn7dsl_dslmod_sysctl_register(void)
+ if (initialized == 1)
+ return;
+
+- dslmod_sysctl_header = register_sysctl_table(dslmod_root_table, 1);
+- dslmod_root_table->child->de->owner = THIS_MODULE;
++ dslmod_sysctl_header = register_sysctl_table(dslmod_root_table);
+
+ /*
+ * set the defaults
+--- a/tn7sar.c
++++ b/tn7sar.c
+@@ -43,7 +43,6 @@
+ * 09/18/07 CPH CQ11466: Added EFM support.
+ *******************************************************************************/
+
+-#include <linux/config.h>
+ #include <linux/kernel.h>
+ #include <linux/module.h>
+ #include <linux/init.h>
+@@ -51,12 +50,13 @@
+ #include <linux/delay.h>
+ #include <linux/spinlock.h>
+ #include <linux/smp_lock.h>
+-#include <asm/io.h>
+-#include <asm/mips-boards/prom.h>
+ #include <linux/proc_fs.h>
+ #include <linux/string.h>
+ #include <linux/ctype.h>
+
++#include <asm/io.h>
++#include <asm/ar7/ar7.h>
++#include <asm/ar7/prom.h>
+
+ #define _CPHAL_AAL5
+ #define _CPHAL_SAR
diff --git a/package/system/ar7-atm/patches-D7.05.01.00/.svn/text-base/110-interrupt_fix.patch.svn-base b/package/system/ar7-atm/patches-D7.05.01.00/.svn/text-base/110-interrupt_fix.patch.svn-base
new file mode 100644
index 0000000..1122457
--- /dev/null
+++ b/package/system/ar7-atm/patches-D7.05.01.00/.svn/text-base/110-interrupt_fix.patch.svn-base
@@ -0,0 +1,37 @@
+--- a/tn7atm.c
++++ b/tn7atm.c
+@@ -633,7 +633,7 @@ static int turbodsl_check_priority_type(
+ * Description: tnetd73xx SAR interrupt.
+ *
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+-static void tn7atm_sar_irq (int irq, void *voiddev, struct pt_regs *regs)
++static irqreturn_t tn7atm_sar_irq (int irq, void *voiddev)
+ {
+ struct atm_dev *atmdev;
+ Tn7AtmPrivate *priv;
+@@ -660,6 +660,7 @@ static void tn7atm_sar_irq (int irq, voi
+ #ifdef TIATM_INST_SUPP
+ psp_trace_par (ATM_DRV_SAR_ISR_EXIT, retval);
+ #endif
++ return IRQ_HANDLED;
+ }
+
+ /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+@@ -669,7 +670,7 @@ static void tn7atm_sar_irq (int irq, voi
+ * Description: tnetd73xx DSL interrupt.
+ *
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+-static void tn7atm_dsl_irq (int irq, void *voiddev, struct pt_regs *regs)
++static irqreturn_t tn7atm_dsl_irq (int irq, void *voiddev)
+ {
+ struct atm_dev *atmdev;
+ Tn7AtmPrivate *priv;
+@@ -691,6 +692,8 @@ static void tn7atm_dsl_irq (int irq, voi
+ #ifdef TIATM_INST_SUPP
+ psp_trace_par (ATM_DRV_DSL_ISR_EXIT, retval);
+ #endif
++
++ return IRQ_HANDLED;
+ }
+
+ /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/package/system/ar7-atm/patches-D7.05.01.00/.svn/text-base/120-no_dumb_inline.patch.svn-base b/package/system/ar7-atm/patches-D7.05.01.00/.svn/text-base/120-no_dumb_inline.patch.svn-base
new file mode 100644
index 0000000..e9d99df
--- /dev/null
+++ b/package/system/ar7-atm/patches-D7.05.01.00/.svn/text-base/120-no_dumb_inline.patch.svn-base
@@ -0,0 +1,11 @@
+--- a/tn7api.h
++++ b/tn7api.h
+@@ -118,7 +118,7 @@ int tn7dsl_proc_dbgmsg_write(struct file
+ int tn7dsl_proc_dbgmsg_read(char* buf, char **start, off_t offset, int count,int *eof, void *data);
+ #endif
+ //UR8_MERGE_END CQ11813
+-inline int tn7dsl_handle_interrupt(void);
++int tn7dsl_handle_interrupt(void);
+
+ void tn7dsl_dslmod_sysctl_register(void);
+ void tn7dsl_dslmod_sysctl_unregister(void);
diff --git a/package/system/ar7-atm/patches-D7.05.01.00/.svn/text-base/130-powercutback.patch.svn-base b/package/system/ar7-atm/patches-D7.05.01.00/.svn/text-base/130-powercutback.patch.svn-base
new file mode 100644
index 0000000..4154864
--- /dev/null
+++ b/package/system/ar7-atm/patches-D7.05.01.00/.svn/text-base/130-powercutback.patch.svn-base
@@ -0,0 +1,44 @@
+--- a/dsl_hal_advcfg.c
++++ b/dsl_hal_advcfg.c
+@@ -36,9 +36,9 @@
+ * 05Jul05 0.00.09 CPH CQ9775: Change dslhal_advcfg_configDsTones input parameters & support for ADSL2+
+ * 24Jul05 0.00.10 CPH Fixed comments in dslhal_advcfg_configDsTones function header
+ *******************************************************************************/
+-#include <dev_host_interface.h>
+-#include <dsl_hal_register.h>
+-#include <dsl_hal_support.h>
++#include "dev_host_interface.h"
++#include "dsl_hal_register.h"
++#include "dsl_hal_support.h"
+
+ /*****************************************************************************/
+ /* ACT API functions -- To be moved into their own independent module --RamP */
+--- a/Makefile
++++ b/Makefile
+@@ -4,6 +4,7 @@
+
+ CONFIG_SANGAM_ATM=m
+ #EXTRA_CFLAGS += -DEL -I. -DPOST_SILICON -DCOMMON_NSP -DCONFIG_LED_MODULE -DDEREGISTER_LED -DNO_ACT
+-EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -DNO_ACT -D__NO__VOICE_PATCH__ -DEL
++#EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -DNO_ACT -D__NO__VOICE_PATCH__ -DEL
++EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -D__NO__VOICE_PATCH__ -DEL
+ obj-$(CONFIG_SANGAM_ATM) := tiatm.o
+-tiatm-objs += cpsar.o aal5sar.o tn7sar.o tn7atm.o tn7dsl.o dsl_hal_api.o dsl_hal_support.o
++tiatm-objs += cpsar.o aal5sar.o tn7sar.o tn7atm.o tn7dsl.o dsl_hal_api.o dsl_hal_support.o dsl_hal_advcfg.o
+--- a/tn7dsl.c
++++ b/tn7dsl.c
+@@ -3053,6 +3053,14 @@ static int tn7dsl_set_dsl(void)
+ dslhal_api_setRateAdaptFlag(pIhw, os_atoi(ptr));
+ }
+
++ // set powercutback
++ ptr = NULL;
++ ptr = prom_getenv("powercutback");
++ if(ptr)
++ {
++ dslhal_advcfg_onOffPcb(pIhw, os_atoi(ptr));
++ }
++
+ // trellis
+ ptr = NULL;
+ ptr = prom_getenv("trellis");
diff --git a/package/system/ar7-atm/patches-D7.05.01.00/.svn/text-base/140-debug_mode.patch.svn-base b/package/system/ar7-atm/patches-D7.05.01.00/.svn/text-base/140-debug_mode.patch.svn-base
new file mode 100644
index 0000000..3873827
--- /dev/null
+++ b/package/system/ar7-atm/patches-D7.05.01.00/.svn/text-base/140-debug_mode.patch.svn-base
@@ -0,0 +1,16 @@
+--- a/tn7sar.c
++++ b/tn7sar.c
+@@ -125,10 +125,10 @@ enum
+ //09/05/07: cph, move to tn7atm.h
+ // #define RESERVED_OAM_CHANNEL 15
+
+-#define AAL5_PARM "id=aal5, base = 0x03000000, offset = 0, int_line=15, ch0=[RxBufSize=1522; RxNumBuffers = 32; RxServiceMax = 50; TxServiceMax=50; TxNumBuffers=32; CpcsUU=0x5aa5; TxVc_CellRate=0x3000; TxVc_AtmHeader=0x00000640]"
+-#define SAR_PARM "id=sar,base = 0x03000000, reset_bit = 9, offset = 0; UniNni = 0, PdspEnable = 1"
++#define CH0_PARM "RxBufSize=1522, RxNumBuffers=32, RxServiceMax=50, TxServiceMax=50, TxNumBuffers=32, CpcsUU=0x5aa5, TxVc_CellRate=0x3000, TxVc_AtmHeader=0x00000640"
++#define AAL5_PARM "id=aal5, base=0x03000000, offset=0, int_line=15, ch0=[" CH0_PARM "]"
++#define SAR_PARM "id=sar, base=0x03000000, reset_bit=9, offset=0; UniNni=0, PdspEnable=1, Debug=0xFFFFFFFF"
+ #define RESET_PARM "id=ResetControl, base=0xA8611600"
+-#define CH0_PARM "RxBufSize=1522, RxNumBuffers = 32, RxServiceMax = 50, TxServiceMax=50, TxNumBuffers=32, CpcsUU=0x5aa5, TxVc_CellRate=0x3000, TxVc_AtmHeader=0x00000640"
+
+ #define MAX_PVC_TABLE_ENTRY 16
+
diff --git a/package/system/ar7-atm/patches-D7.05.01.00/.svn/text-base/150-tasklet_mode.patch.svn-base b/package/system/ar7-atm/patches-D7.05.01.00/.svn/text-base/150-tasklet_mode.patch.svn-base
new file mode 100644
index 0000000..97b8cec
--- /dev/null
+++ b/package/system/ar7-atm/patches-D7.05.01.00/.svn/text-base/150-tasklet_mode.patch.svn-base
@@ -0,0 +1,11 @@
+--- a/Makefile
++++ b/Makefile
+@@ -5,6 +5,7 @@
+ CONFIG_SANGAM_ATM=m
+ #EXTRA_CFLAGS += -DEL -I. -DPOST_SILICON -DCOMMON_NSP -DCONFIG_LED_MODULE -DDEREGISTER_LED -DNO_ACT
+ #EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -DNO_ACT -D__NO__VOICE_PATCH__ -DEL
+-EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -D__NO__VOICE_PATCH__ -DEL
++#EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -D__NO__VOICE_PATCH__ -DEL
++EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -D__NO__VOICE_PATCH__ -DEL -DCPATM_TASKLET_MODE
+ obj-$(CONFIG_SANGAM_ATM) := tiatm.o
+ tiatm-objs += cpsar.o aal5sar.o tn7sar.o tn7atm.o tn7dsl.o dsl_hal_api.o dsl_hal_support.o dsl_hal_advcfg.o
diff --git a/package/system/ar7-atm/patches-D7.05.01.00/.svn/text-base/160-module-params.patch.svn-base b/package/system/ar7-atm/patches-D7.05.01.00/.svn/text-base/160-module-params.patch.svn-base
new file mode 100644
index 0000000..75a41d1
--- /dev/null
+++ b/package/system/ar7-atm/patches-D7.05.01.00/.svn/text-base/160-module-params.patch.svn-base
@@ -0,0 +1,675 @@
+--- a/tn7atm.c
++++ b/tn7atm.c
+@@ -95,6 +95,146 @@
+ MODULE_LICENSE("GPL");
+ MODULE_DESCRIPTION ("Tnetd73xx ATM Device Driver");
+ MODULE_AUTHOR ("Zhicheng Tang");
++
++int mp_sar_ipacemax = -1;
++module_param_named(ipacemax, mp_sar_ipacemax, int, 0);
++MODULE_PARM_DESC(ipacemax, "Interrupt pacing");
++
++char *mp_macc = NULL;
++module_param_named(macc, mp_macc, charp, 0);
++MODULE_PARM_DESC(macc, "MAC address");
++
++int mp_dsp_noboost = -1;
++module_param_named(dsp_noboost, mp_dsp_noboost, int, 0);
++MODULE_PARM_DESC(dsp_noboost, "Suppress DSP frequency boost");
++
++int mp_dsp_freq = -1;
++module_param_named(dsp_freq, mp_dsp_freq, int, 0);
++MODULE_PARM_DESC(dsp_freq, "Frequency to boost the DSP to");
++
++char *mp_featctl0 = NULL;
++module_param_named(featctl0, mp_featctl0, charp, 0);
++MODULE_PARM_DESC(featctl0, "DSL feature control 0");
++
++char *mp_featctl1 = NULL;
++module_param_named(featctl1, mp_featctl1, charp, 0);
++MODULE_PARM_DESC(featctl1, "DSL feature control 1");
++
++char *mp_phyctl0 = NULL;
++module_param_named(phyctl0, mp_phyctl0, charp, 0);
++MODULE_PARM_DESC(phyctl0, "DSL PHY control 0");
++
++char *mp_phyctl1 = NULL;
++module_param_named(phyctl1, mp_phyctl1, charp, 0);
++MODULE_PARM_DESC(phyctl1, "DSL PHY control 1");
++
++int mp_turbodsl = -1;
++module_param_named(turbodsl, mp_turbodsl, int, 0);
++MODULE_PARM_DESC(turbodsl, "Enable TurboDSL");
++
++int mp_sar_rxbuf = -1;
++module_param_named(sar_rxbuf, mp_sar_rxbuf, int, 0);
++MODULE_PARM_DESC(sar_rxbuf, "SAR RxBuf size");
++
++int mp_sar_rxmax = -1;
++module_param_named(sar_rxmax, mp_sar_rxmax, int, 0);
++MODULE_PARM_DESC(sar_rxmax, "SAR RxMax size");
++
++int mp_sar_txbuf = -1;
++module_param_named(sar_txbuf, mp_sar_txbuf, int, 0);
++MODULE_PARM_DESC(sar_txbuf, "SAR TxBuf size");
++
++int mp_sar_txmax = -1;
++module_param_named(sar_txmax, mp_sar_txmax, int, 0);
++MODULE_PARM_DESC(sar_txmax, "SAR TxMax size");
++
++char *mp_modulation = NULL;
++module_param_named(modulation, mp_modulation, charp, 0);
++MODULE_PARM_DESC(modulation, "Modulation");
++
++int mp_fine_gain_control = -1;
++module_param_named(fine_gain_control, mp_fine_gain_control, int, 0);
++MODULE_PARM_DESC(fine_gain_control, "Fine gain control");
++
++int mp_fine_gain_value = -1;
++module_param_named(fine_gain_value, mp_fine_gain_value, int, 0);
++MODULE_PARM_DESC(fine_gain_value, "Fine gain value");
++
++int mp_enable_margin_retrain = -1;
++module_param_named(enable_margin_retrain, mp_enable_margin_retrain, int, 0);
++MODULE_PARM_DESC(enable_margin_retrain, "Enable margin retrain");
++
++int mp_margin_threshold = -1;
++module_param_named(margin_threshold, mp_margin_threshold, int, 0);
++MODULE_PARM_DESC(margin_threshold, "Margin retrain treshold");
++
++int mp_enable_rate_adapt = -1;
++module_param_named(enable_rate_adapt, mp_enable_rate_adapt, int, 0);
++MODULE_PARM_DESC(enable_rate_adapt, "Enable rate adaption");
++
++int mp_powercutback = -1;
++module_param_named(powercutback, mp_powercutback, int, 0);
++MODULE_PARM_DESC(powercutback, "Enable / disable powercutback");
++
++int mp_trellis = -1;
++module_param_named(trellis, mp_trellis, int, 0);
++MODULE_PARM_DESC(trellis, "Enable / disable trellis coding");
++
++int mp_bitswap = -1;
++module_param_named(bitswap, mp_bitswap, int, 0);
++MODULE_PARM_DESC(bitswap, "Enable / disable bitswap");
++
++int mp_maximum_bits_per_carrier = -1;
++module_param_named(maximum_bits_per_carrier, mp_maximum_bits_per_carrier, int, 0);
++MODULE_PARM_DESC(maximum_bits_per_carrier, "Maximum bits per carrier");
++
++int mp_maximum_interleave_depth = -1;
++module_param_named(maximum_interleave_depth, mp_maximum_interleave_depth, int, 0);
++MODULE_PARM_DESC(maximum_interleave_depth, "Maximum interleave depth");
++
++int mp_pair_selection = -1;
++module_param_named(pair_selection, mp_pair_selection, int, 0);
++MODULE_PARM_DESC(pair_selection, "Pair selection");
++
++int mp_dgas_polarity = -1;
++module_param_named(dgas_polarity, mp_dgas_polarity, int, 0);
++MODULE_PARM_DESC(dgas_polarity, "DGAS polarity");
++
++int mp_los_alarm = -1;
++module_param_named(los_alarm, mp_los_alarm, int, 0);
++MODULE_PARM_DESC(los_alarm, "LOS alarm");
++
++char *mp_eoc_vendor_id = NULL;
++module_param_named(eoc_vendor_id, mp_eoc_vendor_id, charp, 0);
++MODULE_PARM_DESC(eoc_vendor_id, "EOC vendor id");
++
++int mp_eoc_vendor_revision = -1;
++module_param_named(eoc_vendor_revision, mp_eoc_vendor_revision, int, 0);
++MODULE_PARM_DESC(eoc_vendor_revision, "EOC vendor revision");
++
++char *mp_eoc_vendor_serialnum = NULL;
++module_param_named(eoc_vendor_serialnum, mp_eoc_vendor_serialnum, charp, 0);
++MODULE_PARM_DESC(eoc_vendor_serialnum, "EOC vendor serial number");
++
++char *mp_invntry_vernum = NULL;
++module_param_named(invntry_vernum, mp_invntry_vernum, charp, 0);
++MODULE_PARM_DESC(invntry_vernum, "Inventory revision number");
++
++int mp_dsl_bit_tmode = -1;
++module_param_named(dsl_bit_tmode, mp_dsl_bit_tmode, int, 0);
++MODULE_PARM_DESC(dsl_bit_tmode, "DSL bit training mode");
++
++int mp_high_precision = -1;
++module_param_named(high_precision, mp_high_precision, int, 0);
++MODULE_PARM_DESC(high_precision, "High precision");
++
++int mp_autopvc_enable = -1;
++module_param_named(autopvc_enable, mp_autopvc_enable, int, 0);
++MODULE_PARM_DESC(autopvc_enable, "Enable / disable automatic PVC");
++
++int mp_oam_lb_timeout = -1;
++module_param_named(oam_lb_timeout, mp_oam_lb_timeout, int, 0);
++MODULE_PARM_DESC(oam_lb_timeout, "OAM LB timeout");
+ #endif
+
+ #ifndef TRUE
+@@ -728,9 +868,9 @@
+ * interrupt pacing
+ */
+ ptr = prom_getenv ("sar_ipacemax");
+- if (ptr)
++ if (ptr || mp_sar_ipacemax != -1)
+ {
+- def_sar_inter_pace = os_atoi (ptr);
++ def_sar_inter_pace = mp_sar_ipacemax == -1 ? os_atoi (ptr) : mp_sar_ipacemax;
+ }
+ /* avalanche_request_pacing (priv->sar_irq, ATM_SAR_INT_PACING_BLOCK_NUM,
+ def_sar_inter_pace); */
+@@ -878,9 +1018,18 @@
+ {
+ int i;
+ char esi_addr[ESI_LEN] = { 0x00, 0x00, 0x11, 0x22, 0x33, 0x44 };
+- char *esiaddr_str = NULL;
++ char *esiaddr_str = mp_macc;
+
+- esiaddr_str = prom_getenv ("macc");
++ if (esiaddr_str == NULL)
++ esiaddr_str = prom_getenv ("macdsl");
++ if (esiaddr_str == NULL)
++ esiaddr_str = prom_getenv ("macc");
++ if (esiaddr_str == NULL)
++ esiaddr_str = prom_getenv ("HWA_1");
++ if (esiaddr_str == NULL)
++ esiaddr_str = prom_getenv ("macb");
++ if (esiaddr_str == NULL)
++ esiaddr_str = prom_getenv ("maca");
+
+ if (!esiaddr_str)
+ {
+@@ -2139,15 +2288,15 @@
+ //UR8_MERGE_END CQ10450*
+
+ cp = prom_getenv ("dsp_noboost");
+- if (cp)
++ if (cp || mp_dsp_noboost != -1)
+ {
+- dsp_noboost = os_atoi (cp);
++ dsp_noboost = mp_dsp_noboost == -1 ? os_atoi (cp) : mp_dsp_noboost;
+ }
+
+ cp = (char *) prom_getenv ("dsp_freq");
+- if (cp)
++ if (cp || mp_dsp_freq != -1)
+ {
+- dspfreq = os_atoi (cp);
++ dspfreq = mp_dsp_freq == -1 ? os_atoi (cp) : mp_dsp_freq;
+ if (dspfreq == 250)
+ {
+ boostDsp = 1;
+@@ -2396,15 +2545,17 @@
+ // Inter-Op DSL phy Control
+ // Note the setting of _dsl_Feature_0 and _dsl_Feature_1 must before
+ // dslhal_api_dslStartup (in tn7dsl_init()).
+- if ((ptr = prom_getenv ("DSL_FEATURE_CNTL_0")) != NULL)
++ if ((ptr = prom_getenv ("DSL_FEATURE_CNTL_0")) != NULL || mp_featctl0 != NULL)
+ {
+- _dsl_Feature_0 = os_atoih (ptr);
++ if (mp_featctl0 != NULL) ptr = mp_featctl0;
++ _dsl_Feature_0 = os_atoh (ptr);
+ _dsl_Feature_0_defined = 1;
+ }
+
+- if ((ptr = prom_getenv ("DSL_FEATURE_CNTL_1")) != NULL)
++ if ((ptr = prom_getenv ("DSL_FEATURE_CNTL_1")) != NULL || mp_featctl1 != NULL)
+ {
+- _dsl_Feature_1 = os_atoih (ptr);
++ if (mp_featctl1 != NULL) ptr = mp_featctl1;
++ _dsl_Feature_1 = os_atoh (ptr);
+ _dsl_Feature_1_defined = 1;
+ }
+
+@@ -2412,15 +2563,17 @@
+ // DSL phy Feature Control
+ // Note the setting of _dsl_PhyControl_0 and _dsl_PhyControl_1 must before
+ // dslhal_api_dslStartup (in tn7dsl_init()).
+- if ((ptr = prom_getenv ("DSL_PHY_CNTL_0")) != NULL)
++ if ((ptr = prom_getenv ("DSL_PHY_CNTL_0")) != NULL || mp_phyctl0 != NULL)
+ {
+- _dsl_PhyControl_0 = os_atoih (ptr);
++ if (mp_phyctl0 != NULL) ptr = mp_phyctl0;
++ _dsl_PhyControl_0 = os_atoh (ptr);
+ _dsl_PhyControl_0_defined = 1;
+ }
+
+- if ((ptr = prom_getenv ("DSL_PHY_CNTL_1")) != NULL)
++ if ((ptr = prom_getenv ("DSL_PHY_CNTL_1")) != NULL || mp_phyctl1 != NULL)
+ {
+- _dsl_PhyControl_1 = os_atoih (ptr);
++ if (mp_phyctl1 != NULL) ptr = mp_phyctl1;
++ _dsl_PhyControl_1 = os_atoh (ptr);
+ _dsl_PhyControl_1_defined = 1;
+ }
+
+@@ -2440,12 +2593,12 @@
+ // read config for turbo dsl
+
+ ptr = prom_getenv ("TurboDSL");
+- if (ptr)
++ if (ptr || mp_turbodsl != -1)
+ {
+ #if 1 //[KT]
+ bTurboDsl = os_atoi (ptr);
+ #else
+- priv->bTurboDsl = os_atoi (ptr);
++ priv->bTurboDsl = mp_turbodsl == -1 ? os_atoi (ptr) : mp_turbodsl;
+ #endif
+ }
+ else
+@@ -2459,33 +2612,33 @@
+ priv->sarRxBuf = RX_BUFFER_NUM;
+ ptr = NULL;
+ ptr = prom_getenv ("SarRxBuf");
+- if (ptr)
++ if (ptr || mp_sar_rxbuf != -1)
+ {
+- priv->sarRxBuf = os_atoi (ptr);
++ priv->sarRxBuf = mp_sar_rxbuf == -1 ? os_atoi (ptr) : mp_sar_rxbuf;
+ }
+
+ priv->sarRxMax = RX_SERVICE_MAX;
+ ptr = NULL;
+ ptr = prom_getenv ("SarRxMax");
+- if (ptr)
++ if (ptr || mp_sar_rxmax != -1)
+ {
+- priv->sarRxMax = os_atoi (ptr);
++ priv->sarRxMax = mp_sar_rxmax == -1 ? os_atoi (ptr) : mp_sar_rxmax;
+ }
+
+ priv->sarTxBuf = TX_BUFFER_NUM;
+ ptr = NULL;
+ ptr = prom_getenv ("SarTxBuf");
+- if (ptr)
++ if (ptr || mp_sar_txbuf != -1)
+ {
+- priv->sarTxBuf = os_atoi (ptr);
++ priv->sarTxBuf = mp_sar_txbuf == -1 ? os_atoi (ptr) : mp_sar_txbuf;
+ }
+
+ priv->sarTxMax = TX_SERVICE_MAX;
+ ptr = NULL;
+ ptr = prom_getenv ("SarTxMax");
+- if (ptr)
++ if (ptr || mp_sar_txmax != -1)
+ {
+- priv->sarTxMax = os_atoi (ptr);
++ priv->sarTxMax = mp_sar_txmax == -1 ? os_atoi (ptr) : mp_sar_txmax;
+ }
+
+ #ifdef AR7_EFM
+--- a/tn7dsl.c
++++ b/tn7dsl.c
+@@ -148,6 +148,27 @@
+ #define NEW_TRAINING_VAL_T1413 128
+ #define NEW_TRAINING_VAL_MMODE 255
+
++extern char *mp_modulation;
++extern int mp_fine_gain_control;
++extern int mp_fine_gain_value;
++extern int mp_enable_margin_retrain;
++extern int mp_margin_threshold;
++extern int mp_enable_rate_adapt;
++extern int mp_powercutback;
++extern int mp_trellis;
++extern int mp_bitswap;
++extern int mp_maximum_bits_per_carrier;
++extern int mp_maximum_interleave_depth;
++extern int mp_pair_selection;
++extern int mp_dgas_polarity;
++extern int mp_los_alarm;
++extern char *mp_eoc_vendor_id;
++extern int mp_eoc_vendor_revision;
++extern char *mp_eoc_vendor_serialnum;
++extern char *mp_invntry_vernum;
++extern int mp_dsl_bit_tmode;
++extern int mp_high_precision;
++
+ int testflag1 = 0;
+ extern int __guDbgLevel;
+ extern sar_stat_t sarStat;
+@@ -2933,24 +2954,24 @@ static int tn7dsl_set_dsl(void)
+ (unsigned char *) &oamFeature, 4);
+
+ ptr = prom_getenv("DSL_FEATURE_CNTL_0");
+- if(!ptr)
+- prom_setenv("DSL_FEATURE_CNTL_0", "0x00004000");
++ //if(!ptr)
++ //prom_setenv("DSL_FEATURE_CNTL_0", "0x00004000");
+
+ ptr = prom_getenv("DSL_FEATURE_CNTL_1");
+- if(!ptr)
+- prom_setenv("DSL_FEATURE_CNTL_1", "0x00000000");
++ //if(!ptr)
++ //prom_setenv("DSL_FEATURE_CNTL_1", "0x00000000");
+
+ ptr = prom_getenv("DSL_PHY_CNTL_0");
+- if(!ptr)
+- prom_setenv("DSL_PHY_CNTL_0", "0x00000400");
++ //if(!ptr)
++ //prom_setenv("DSL_PHY_CNTL_0", "0x00000400");
+
+ ptr = prom_getenv("enable_margin_retrain");
+- if(!ptr)
+- prom_setenv("enable_margin_retrain", "0");
++ //if(!ptr)
++ //prom_setenv("enable_margin_retrain", "0");
+
+ ptr = prom_getenv("modulation");
+- if(!ptr)
+- prom_setenv("modulation", "0xbf");
++ //if(!ptr)
++ //prom_setenv("modulation", "0xbf");
+
+ #define EOC_VENDOR_ID "4200534153000000"
+ #define EOC_VENDOR_REVISION "FW370090708b1_55"
+@@ -2959,25 +2980,25 @@ static int tn7dsl_set_dsl(void)
+ ptr = prom_getenv("eoc_vendor_id");
+ if(!ptr || strcmp(ptr,EOC_VENDOR_ID) != 0 || strlen(ptr) != strlen(EOC_VENDOR_ID))
+ {
+- if(ptr)
+- prom_unsetenv("eoc_vendor_id");
+- prom_setenv("eoc_vendor_id",EOC_VENDOR_ID);
++ //if(ptr)
++ //prom_unsetenv("eoc_vendor_id");
++ //prom_setenv("eoc_vendor_id",EOC_VENDOR_ID);
+ }
+
+ ptr = prom_getenv("eoc_vendor_revision");
+ if(!ptr || strcmp(ptr,EOC_VENDOR_REVISION) != 0 || strlen(ptr) != strlen(EOC_VENDOR_REVISION))
+ {
+- if(ptr)
+- prom_unsetenv("eoc_vendor_revision");
+- prom_setenv("eoc_vendor_revision",EOC_VENDOR_REVISION);
++ //if(ptr)
++ //prom_unsetenv("eoc_vendor_revision");
++ //prom_setenv("eoc_vendor_revision",EOC_VENDOR_REVISION);
+ }
+
+ ptr = prom_getenv("eoc_vendor_serialnum");
+ if(!ptr || strcmp(ptr,EOC_VENDOR_SERIALNUM) != 0 || strlen(ptr) != strlen(EOC_VENDOR_SERIALNUM))
+ {
+- if(ptr)
+- prom_unsetenv("eoc_vendor_serialnum");
+- prom_setenv("eoc_vendor_serialnum",EOC_VENDOR_SERIALNUM);
++ //if(ptr)
++ // prom_unsetenv("eoc_vendor_serialnum");
++ //prom_setenv("eoc_vendor_serialnum",EOC_VENDOR_SERIALNUM);
+ }
+
+ /* Do only if we are in the new Base PSP 7.4.*/
+@@ -2994,92 +3015,88 @@ static int tn7dsl_set_dsl(void)
+ we clear the modulation environment variable, as this could potentially
+ not have the same meaning in the new mode.
+ */
+- prom_unsetenv("modulation");
+- prom_setenv("DSL_UPG_DONE", "1");
++ //prom_unsetenv("modulation");
++ //prom_setenv("DSL_UPG_DONE", "1");
+ }
+ }
+ #endif
+
+ // modulation
+ ptr = prom_getenv("modulation");
+- if (ptr)
++ if (ptr || mp_modulation != NULL)
+ {
+- tn7dsl_set_modulation(ptr, FALSE);
++ tn7dsl_set_modulation(mp_modulation == NULL ? ptr : mp_modulation, FALSE);
+ }
+
+ // Fine Gains
+ ptr = prom_getenv("fine_gain_control");
+- if (ptr)
++ if (ptr || mp_fine_gain_control != -1)
+ {
+- value = os_atoi(ptr);
++ value = mp_fine_gain_control == -1 ? os_atoi(ptr) : mp_fine_gain_control;
+ tn7dsl_ctrl_fineGain(value);
+ }
+ ptr = NULL;
+ ptr = prom_getenv("fine_gain_value");
+- if(ptr)
+- tn7dsl_set_fineGainValue(os_atoh(ptr));
++ if(ptr || mp_fine_gain_value != -1)
++ tn7dsl_set_fineGainValue(mp_fine_gain_value == -1 ? os_atoh(ptr) : mp_fine_gain_value);
+
+ // margin retrain
+ ptr = NULL;
+ ptr = prom_getenv("enable_margin_retrain");
+- if(ptr)
++ value = mp_enable_margin_retrain == -1 ? (ptr ? os_atoi(ptr) : 0) : mp_enable_margin_retrain;
++
++ if (value == 1)
+ {
+- value = os_atoi(ptr);
+- if(value == 1)
++ dslhal_api_setMarginMonitorFlags(pIhw, 0, 1);
++ bMarginRetrainEnable = 1;
++ //printk("enable showtime margin monitor.\n");
++
++ ptr = NULL;
++ ptr = prom_getenv("margin_threshold");
++ value = mp_margin_threshold == -1 ? (ptr ? os_atoi(ptr) : 0) : mp_margin_threshold;
++
++ if(value >= 0)
+ {
+- dslhal_api_setMarginMonitorFlags(pIhw, 0, 1);
+- bMarginRetrainEnable = 1;
+- //printk("enable showtime margin monitor.\n");
+- ptr = NULL;
+- ptr = prom_getenv("margin_threshold");
+- if(ptr)
+- {
+- value = os_atoi(ptr);
+- //printk("Set margin threshold to %d x 0.5 db\n",value);
+- if(value >= 0)
+- {
+- dslhal_api_setMarginThreshold(pIhw, value);
+- bMarginThConfig=1;
+- }
+- }
++ dslhal_api_setMarginThreshold(pIhw, value);
++ bMarginThConfig=1;
+ }
+ }
+
+ // rate adapt
+ ptr = NULL;
+ ptr = prom_getenv("enable_rate_adapt");
+- if(ptr)
++ if(ptr || mp_enable_rate_adapt != -1)
+ {
+- dslhal_api_setRateAdaptFlag(pIhw, os_atoi(ptr));
++ dslhal_api_setRateAdaptFlag(pIhw, mp_enable_rate_adapt == -1 ? os_atoi(ptr) : mp_enable_rate_adapt);
+ }
+
+ // set powercutback
+ ptr = NULL;
+ ptr = prom_getenv("powercutback");
+- if(ptr)
++ if(ptr || mp_powercutback != -1)
+ {
+- dslhal_advcfg_onOffPcb(pIhw, os_atoi(ptr));
++ dslhal_advcfg_onOffPcb(pIhw, mp_powercutback == -1 ? os_atoi(ptr) : mp_powercutback);
+ }
+
+ // trellis
+ ptr = NULL;
+ ptr = prom_getenv("trellis");
+- if(ptr)
++ if(ptr || mp_trellis != -1)
+ {
+- dslhal_api_setTrellisFlag(pIhw, os_atoi(ptr));
+- trellis = os_atoi(ptr);
++ trellis = mp_trellis == -1 ? os_atoi(ptr) : mp_trellis;
++ dslhal_api_setTrellisFlag(pIhw, trellis);
+ //printk("trellis=%d\n");
+ }
+
+ // bitswap
+ ptr = NULL;
+ ptr = prom_getenv("bitswap");
+- if(ptr)
++ if(ptr || mp_bitswap != -1)
+ {
+ int offset[2] = {33, 0};
+ unsigned int bitswap;
+
+- bitswap = os_atoi(ptr);
++ bitswap = mp_bitswap == -1 ? os_atoi(ptr) : mp_bitswap;
+
+ tn7dsl_generic_read(2, offset);
+ dslReg &= dslhal_support_byteSwap32(0xFFFFFF00);
+@@ -3097,46 +3114,47 @@ static int tn7dsl_set_dsl(void)
+ // maximum bits per carrier
+ ptr = NULL;
+ ptr = prom_getenv("maximum_bits_per_carrier");
+- if(ptr)
++ if(ptr || mp_maximum_bits_per_carrier != -1)
+ {
+- dslhal_api_setMaxBitsPerCarrierUpstream(pIhw, os_atoi(ptr));
++ dslhal_api_setMaxBitsPerCarrierUpstream(pIhw, mp_maximum_bits_per_carrier == -1 ? os_atoi(ptr) : mp_maximum_bits_per_carrier);
+ }
+
+ // maximum interleave depth
+ ptr = NULL;
+ ptr = prom_getenv("maximum_interleave_depth");
+- if(ptr)
++ if(ptr || mp_maximum_interleave_depth != -1)
+ {
+- dslhal_api_setMaxInterleaverDepth(pIhw, os_atoi(ptr));
++ dslhal_api_setMaxInterleaverDepth(pIhw, mp_maximum_interleave_depth == -1 ? os_atoi(ptr) : mp_maximum_interleave_depth);
+ }
+
+ // inner and outer pairs
+ ptr = NULL;
+ ptr = prom_getenv("pair_selection");
+- if(ptr)
++ if(ptr || mp_pair_selection != -1)
+ {
+- dslhal_api_selectInnerOuterPair(pIhw, os_atoi(ptr));
++ dslhal_api_selectInnerOuterPair(pIhw, mp_pair_selection == -1 ? os_atoi(ptr) : mp_pair_selection);
+ }
+
+ ptr = NULL;
+ ptr = prom_getenv("dgas_polarity");
+- if(ptr)
++ if(ptr || mp_dgas_polarity != -1)
+ {
+ dslhal_api_configureDgaspLpr(pIhw, 1, 1);
+- dslhal_api_configureDgaspLpr(pIhw, 0, os_atoi(ptr));
++ dslhal_api_configureDgaspLpr(pIhw, 0, mp_dgas_polarity == -1 ? os_atoi(ptr) : mp_dgas_polarity);
+ }
+
+ ptr = NULL;
+ ptr = prom_getenv("los_alarm");
+- if(ptr)
++ if(ptr || mp_los_alarm != -1)
+ {
+- dslhal_api_disableLosAlarm(pIhw, os_atoi(ptr));
++ dslhal_api_disableLosAlarm(pIhw, mp_los_alarm == -1 ? os_atoi(ptr) : mp_los_alarm);
+ }
+
+ ptr = NULL;
+ ptr = prom_getenv("eoc_vendor_id");
+- if(ptr)
++ if(ptr || mp_eoc_vendor_id != NULL)
+ {
++ ptr = mp_eoc_vendor_id == NULL ? ptr : mp_eoc_vendor_id;
+ for(i=0;i<8;i++)
+ {
+ tmp[0]=ptr[i*2];
+@@ -3161,26 +3179,26 @@ static int tn7dsl_set_dsl(void)
+ }
+ ptr = NULL;
+ ptr = prom_getenv("eoc_vendor_revision");
+- if(ptr)
++ if(ptr || mp_eoc_vendor_revision != -1)
+ {
+- value = os_atoi(ptr);
++ value = mp_eoc_vendor_revision == -1 ? os_atoi(ptr) : mp_eoc_vendor_revision;
+ //printk("eoc rev=%d\n", os_atoi(ptr));
+ dslhal_api_setEocRevisionNumber(pIhw, (char *)&value);
+
+ }
+ ptr = NULL;
+ ptr = prom_getenv("eoc_vendor_serialnum");
+- if(ptr)
++ if(ptr || mp_eoc_vendor_serialnum != NULL)
+ {
+- dslhal_api_setEocSerialNumber(pIhw, ptr);
++ dslhal_api_setEocSerialNumber(pIhw, mp_eoc_vendor_serialnum == NULL ? ptr : mp_eoc_vendor_serialnum);
+ }
+
+ // CQ10037 Added invntry_vernum environment variable to be able to set version number in ADSL2, ADSL2+ modes.
+ ptr = NULL;
+ ptr = prom_getenv("invntry_vernum");
+- if(ptr)
++ if(ptr || mp_invntry_vernum != NULL)
+ {
+- dslhal_api_setEocRevisionNumber(pIhw, ptr);
++ dslhal_api_setEocRevisionNumber(pIhw, mp_invntry_vernum == NULL ? ptr : mp_invntry_vernum);
+ }
+
+ return 0;
+@@ -3225,7 +3243,7 @@ int tn7dsl_init(void *priv)
+ * backward compatibility.
+ */
+ cp = prom_getenv("DSL_BIT_TMODE");
+- if (cp)
++ if (cp || mp_dsl_bit_tmode != -1)
+ {
+ printk("%s : env var DSL_BIT_TMODE is set\n", __FUNCTION__);
+ /*
+@@ -3254,9 +3272,9 @@ int tn7dsl_init(void *priv)
+
+ // UR8_MERGE_START CQ11054 Jack Zhang
+ cp = prom_getenv("high_precision");
+- if (cp)
++ if (cp || mp_high_precision != -1)
+ {
+- high_precision_selected = os_atoi(cp);
++ high_precision_selected = mp_high_precision == -1 ? os_atoi(cp) : mp_high_precision;
+ }
+ if ( high_precision_selected)
+ {
+--- a/tn7sar.c
++++ b/tn7sar.c
+@@ -76,6 +76,8 @@ typedef void OS_SETUP;
+ #include "tn7atm.h"
+ #include "tn7api.h"
+
++extern int mp_oam_lb_timeout;
++extern int mp_autopvc_enable;
+
+ /* PDSP Firmware files */
+ #include "tnetd7300_sar_firm.h"
+@@ -932,9 +934,9 @@ int tn7sar_setup_oam_channel(Tn7AtmPriva
+ pHalDev = (HAL_DEVICE *)priv->pSarHalDev;
+
+ pauto_pvc = prom_getenv("autopvc_enable");
+- if(pauto_pvc) //CQ10273
++ if(pauto_pvc || mp_autopvc_enable != -1) //CQ10273
+ {
+- auto_pvc =tn7sar_strtoul(pauto_pvc, NULL, 10);
++ auto_pvc = mp_autopvc_enable == -1 ? tn7sar_strtoul(pauto_pvc, NULL, 10) : mp_autopvc_enable;
+ }
+
+ memset(&chInfo, 0xff, sizeof(chInfo));
+@@ -1133,9 +1135,9 @@ int tn7sar_init(struct atm_dev *dev, Tn7
+
+ /* read in oam lb timeout value */
+ pLbTimeout = prom_getenv("oam_lb_timeout");
+- if(pLbTimeout)
++ if(pLbTimeout || mp_oam_lb_timeout != -1)
+ {
+- lbTimeout =tn7sar_strtoul(pLbTimeout, NULL, 10);
++ lbTimeout = mp_oam_lb_timeout == -1 ? tn7sar_strtoul(pLbTimeout, NULL, 10) : mp_oam_lb_timeout;
+ oamLbTimeout = lbTimeout;
+ pHalFunc->Control(pHalDev,"OamLbTimeout", "Set", &lbTimeout);
+ }
diff --git a/package/system/ar7-atm/patches-D7.05.01.00/.svn/text-base/170-bus_id_removal.patch.svn-base b/package/system/ar7-atm/patches-D7.05.01.00/.svn/text-base/170-bus_id_removal.patch.svn-base
new file mode 100644
index 0000000..6692f40
--- /dev/null
+++ b/package/system/ar7-atm/patches-D7.05.01.00/.svn/text-base/170-bus_id_removal.patch.svn-base
@@ -0,0 +1,30 @@
+--- a/tn7dsl.c
++++ b/tn7dsl.c
+@@ -117,6 +117,7 @@
+ #include <linux/vmalloc.h>
+ #include <linux/file.h>
+ #include <linux/firmware.h>
++#include <linux/version.h>
+
+ #include <asm/io.h>
+ #include <asm/ar7/ar7.h>
+@@ -492,7 +493,9 @@ static void avsar_release(struct device
+ }
+
+ static struct device avsar = {
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)
+ .bus_id = "vlynq",
++#endif
+ .release = avsar_release,
+ };
+
+@@ -501,6 +504,9 @@ int shim_osLoadFWImage(unsigned char *pt
+ const struct firmware *fw_entry;
+ size_t size;
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30)
++ dev_set_name(&avsar, "avsar");
++#endif
+ printk("requesting firmware image \"ar0700xx.bin\"\n");
+ if(device_register(&avsar) < 0) {
+ printk(KERN_ERR
diff --git a/package/system/ar7-atm/patches-D7.05.01.00/.svn/text-base/180-git_headers_include.patch.svn-base b/package/system/ar7-atm/patches-D7.05.01.00/.svn/text-base/180-git_headers_include.patch.svn-base
new file mode 100644
index 0000000..feb6ea8
--- /dev/null
+++ b/package/system/ar7-atm/patches-D7.05.01.00/.svn/text-base/180-git_headers_include.patch.svn-base
@@ -0,0 +1,54 @@
+--- a/tn7atm.c
++++ b/tn7atm.c
+@@ -76,10 +76,16 @@
+ #include <linux/proc_fs.h>
+ #include <linux/string.h>
+ #include <linux/ctype.h>
++#include <linux/version.h>
+
+ #include <asm/io.h>
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)
+ #include <asm/ar7/ar7.h>
+ #include <asm/ar7/prom.h>
++#else
++#include <asm/mach-ar7/ar7.h>
++#include <asm/mach-ar7/prom.h>
++#endif
+
+ #include "dsl_hal_api.h"
+ #ifdef AR7_EFM
+--- a/tn7dsl.c
++++ b/tn7dsl.c
+@@ -120,8 +120,13 @@
+ #include <linux/version.h>
+
+ #include <asm/io.h>
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)
+ #include <asm/ar7/ar7.h>
+ #include <asm/ar7/prom.h>
++#else
++#include <asm/mach-ar7/ar7.h>
++#include <asm/mach-ar7/prom.h>
++#endif
+
+ /* Modules specific header files */
+ #ifdef AR7_EFM
+--- a/tn7sar.c
++++ b/tn7sar.c
+@@ -53,10 +53,16 @@
+ #include <linux/proc_fs.h>
+ #include <linux/string.h>
+ #include <linux/ctype.h>
++#include <linux/version.h>
+
+ #include <asm/io.h>
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)
+ #include <asm/ar7/ar7.h>
+ #include <asm/ar7/prom.h>
++#else
++#include <asm/mach-ar7/ar7.h>
++#include <asm/mach-ar7/prom.h>
++#endif
+
+ #define _CPHAL_AAL5
+ #define _CPHAL_SAR
diff --git a/package/system/ar7-atm/patches-D7.05.01.00/.svn/text-base/190-2.6.32_proc_fixes.patch.svn-base b/package/system/ar7-atm/patches-D7.05.01.00/.svn/text-base/190-2.6.32_proc_fixes.patch.svn-base
new file mode 100644
index 0000000..52ebbc1
--- /dev/null
+++ b/package/system/ar7-atm/patches-D7.05.01.00/.svn/text-base/190-2.6.32_proc_fixes.patch.svn-base
@@ -0,0 +1,79 @@
+--- a/tn7dsl.c
++++ b/tn7dsl.c
+@@ -215,7 +215,11 @@ led_reg_t ledreg[2];
+ static struct led_funcs ledreg[2];
+ #endif
+
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
+ #define DEV_DSLMOD CTL_UNNUMBERED
++#else
++#define DEV_DSLMOD 0
++#endif
+ #define MAX_STR_SIZE 256
+ #define DSL_MOD_SIZE 256
+
+@@ -3615,9 +3619,16 @@ static int dslmod_sysctl(ctl_table *ctl,
+ */
+ if(write)
+ {
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)
+ ret = proc_dostring(ctl, write, filp, buffer, lenp, 0);
+-
++#else
++ ret = proc_dostring(ctl, write, buffer, lenp, 0);
++#endif
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
+ switch (ctl->ctl_name)
++#else
++ switch ((long)ctl->extra2)
++#endif
+ {
+ case DEV_DSLMOD:
+ ptr = strpbrk(info, " \t");
+@@ -3701,14 +3712,29 @@ static int dslmod_sysctl(ctl_table *ctl,
+ else
+ {
+ len += sprintf(info+len, mod_req);
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)
+ ret = proc_dostring(ctl, write, filp, buffer, lenp, 0);
++#else
++ ret = proc_dostring(ctl, write, buffer, lenp, 0);
++#endif
+ }
+ return ret;
+ }
+
+
+ ctl_table dslmod_table[] = {
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
+ {DEV_DSLMOD, "dslmod", info, DSL_MOD_SIZE, 0644, NULL, NULL, &dslmod_sysctl, &sysctl_string}
++#else
++ {
++ .procname = "dslmod",
++ .data = info,
++ .maxlen = DSL_MOD_SIZE,
++ .mode = 0644,
++ .proc_handler = &dslmod_sysctl,
++ .extra2 = (void *)DEV_DSLMOD,
++ }
++#endif
+ ,
+ {0}
+ };
+@@ -3716,7 +3742,16 @@ ctl_table dslmod_table[] = {
+ /* Make sure that /proc/sys/dev is there */
+ ctl_table dslmod_root_table[] = {
+ #ifdef CONFIG_PROC_FS
++ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
+ {CTL_DEV, "dev", NULL, 0, 0555, dslmod_table}
++ #else
++ {
++ .procname = "dev",
++ .maxlen = 0,
++ .mode = 0555,
++ .child = dslmod_table,
++ }
++ #endif
+ ,
+ #endif /* CONFIG_PROC_FS */
+ {0}
diff --git a/package/system/ar7-atm/patches-D7.05.01.00/.svn/text-base/200-2.6.37_args.patch.svn-base b/package/system/ar7-atm/patches-D7.05.01.00/.svn/text-base/200-2.6.37_args.patch.svn-base
new file mode 100644
index 0000000..a3bff1b
--- /dev/null
+++ b/package/system/ar7-atm/patches-D7.05.01.00/.svn/text-base/200-2.6.37_args.patch.svn-base
@@ -0,0 +1,36 @@
+--- a/tn7atm.c
++++ b/tn7atm.c
+@@ -2000,7 +2000,11 @@ static int __init tn7atm_register (Tn7At
+
+ dgprintf (4, "device %s being registered\n", priv->name);
+
++ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37)
+ mydev = atm_dev_register (priv->proc_name, &tn7atm_ops, -1, NULL);
++ #else
++ mydev = atm_dev_register (priv->proc_name, NULL, &tn7atm_ops, -1, NULL);
++ #endif
+
+ if (mydev == NULL)
+ {
+--- a/tn7dsl.c
++++ b/tn7dsl.c
+@@ -512,14 +512,17 @@ int shim_osLoadFWImage(unsigned char *pt
+ {
+ const struct firmware *fw_entry;
+ size_t size;
++ int ret;
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30)
+ dev_set_name(&avsar, "avsar");
+ #endif
+ printk("requesting firmware image \"ar0700xx.bin\"\n");
+- if(device_register(&avsar) < 0) {
++ dev_set_name(&avsar, "avsar");
++ ret = device_register(&avsar);
++ if (ret < 0) {
+ printk(KERN_ERR
+- "avsar: device_register fails\n");
++ "avsar: device_register fails, error%i\n", ret);
+ return -1;
+ }
+
diff --git a/package/system/ar7-atm/patches-D7.05.01.00/.svn/text-base/210-3.3-remove-smp_lock.h.patch.svn-base b/package/system/ar7-atm/patches-D7.05.01.00/.svn/text-base/210-3.3-remove-smp_lock.h.patch.svn-base
new file mode 100644
index 0000000..975ebaf
--- /dev/null
+++ b/package/system/ar7-atm/patches-D7.05.01.00/.svn/text-base/210-3.3-remove-smp_lock.h.patch.svn-base
@@ -0,0 +1,33 @@
+--- a/tn7atm.c
++++ b/tn7atm.c
+@@ -72,7 +72,7 @@
+ #include <linux/atmdev.h>
+ #include <linux/delay.h>
+ #include <linux/spinlock.h>
+-#include <linux/smp_lock.h>
++#include <linux/interrupt.h>
+ #include <linux/proc_fs.h>
+ #include <linux/string.h>
+ #include <linux/ctype.h>
+--- a/tn7sar.c
++++ b/tn7sar.c
+@@ -49,7 +49,7 @@
+ #include <linux/atmdev.h>
+ #include <linux/delay.h>
+ #include <linux/spinlock.h>
+-#include <linux/smp_lock.h>
++#include <linux/interrupt.h>
+ #include <linux/proc_fs.h>
+ #include <linux/string.h>
+ #include <linux/ctype.h>
+--- a/tn7dsl.c
++++ b/tn7dsl.c
+@@ -108,7 +108,7 @@
+ #include <linux/atmdev.h>
+ #include <linux/delay.h>
+ #include <linux/spinlock.h>
+-#include <linux/smp_lock.h>
++#include <linux/interrupt.h>
+ #include <linux/proc_fs.h>
+ #include <linux/string.h>
+ #include <linux/ctype.h>
diff --git a/package/system/ar7-atm/patches-D7.05.01.00/100-compile_fix.patch b/package/system/ar7-atm/patches-D7.05.01.00/100-compile_fix.patch
new file mode 100644
index 0000000..7dee220
--- /dev/null
+++ b/package/system/ar7-atm/patches-D7.05.01.00/100-compile_fix.patch
@@ -0,0 +1,808 @@
+--- a/cppi_cpaal5.c
++++ b/cppi_cpaal5.c
+@@ -360,7 +360,7 @@ static int halRxReturn(HAL_RECEIVEINFO *
+ {
+ /* malloc failed, add this RCB to Needs Buffer List */
+ TempRcb->FragCount = 1; /*MJH+030417*/
+- (HAL_RCB *)TempRcb->Eop = TempRcb; /* GSG +030430 */
++ TempRcb->Eop = TempRcb; /* GSG +030430 */
+
+ if(HalDev->NeedsCount < MAX_NEEDS) /* +MJH 030410 */
+ { /* +MJH 030410 */
+--- a/dsl_hal_api.c
++++ b/dsl_hal_api.c
+@@ -273,15 +273,15 @@
+ * 09/15/07 CPH CQ11466 Added EFM support
+ * 09/27/07 EYin CQ11929: Added NFEC/INP/Lp/Rp reporting for only ADSL2/2+ mode.
+ ******************************************************************************/
+-#include <dev_host_interface.h>
+-#include <dsl_hal_register.h>
+-#include <dsl_hal_support.h>
++#include "dev_host_interface.h"
++#include "dsl_hal_register.h"
++#include "dsl_hal_support.h"
+
+ #ifndef NO_ADV_STATS
+-#include <dsl_hal_logtable.h>
++#include "dsl_hal_logtable.h"
+ #endif
+
+-#include <dsl_hal_version.h>
++#include "dsl_hal_version.h"
+
+ // UR8_MERGE_START CQ11054 Jack Zhang
+ static unsigned int highprecision_selected = 0; //By default we use low precision for backward compt.
+--- a/dsl_hal_support.c
++++ b/dsl_hal_support.c
+@@ -142,9 +142,9 @@
+ * UR8_MERGE_START_END CQ11922 Tim
+ * 04Sep07 0.14.00 Tim CQ11922: Added support for new scratchram for INP NDR tables
+ *******************************************************************************/
+-#include <dev_host_interface.h>
+-#include <dsl_hal_register.h>
+-#include <dsl_hal_support.h>
++#include "dev_host_interface.h"
++#include "dsl_hal_register.h"
++#include "dsl_hal_support.h"
+
+ #define NUM_READ_RETRIES 3
+ static unsigned int dslhal_support_adsl2ByteSwap32(unsigned int in32Bits);
+--- a/dsl_hal_support.h
++++ b/dsl_hal_support.h
+@@ -49,7 +49,7 @@
+ * 04Nov05 0.11.00 CPH Fixed T1413 mode got Zero DS/US rate when DSL_BIT_TMODE is set.
+ *******************************************************************************/
+
+-#include <dsl_hal_api.h>
++#include "dsl_hal_api.h"
+
+ #define virtual2Physical(a) (((int)a)&~0xe0000000)
+ /* External Function Prototype Declarations */
+--- a/Makefile
++++ b/Makefile
+@@ -1,18 +1,9 @@
+-# File: drivers/atm/ti_evm3/Makefile
+ #
+-# Makefile for the Texas Instruments EVM3 ADSL/ATM driver.
++# Makefile for the TIATM device driver.
+ #
+-#
+-# Copyright (c) 2000 Texas Instruments Incorporated.
+-# Jeff Harrell (jharrell@telogy.com)
+-# Viren Balar (vbalar@ti.com)
+-# Victor Wells (vwells@telogy.com)
+-#
+-include $(TOPDIR)/Rules.make
+-
+-
+-
+-
+-
+-
+
++CONFIG_SANGAM_ATM=m
++#EXTRA_CFLAGS += -DEL -I. -DPOST_SILICON -DCOMMON_NSP -DCONFIG_LED_MODULE -DDEREGISTER_LED -DNO_ACT
++EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -DNO_ACT -D__NO__VOICE_PATCH__ -DEL
++obj-$(CONFIG_SANGAM_ATM) := tiatm.o
++tiatm-objs += cpsar.o aal5sar.o tn7sar.o tn7atm.o tn7dsl.o dsl_hal_api.o dsl_hal_support.o
+--- a/tn7atm.c
++++ b/tn7atm.c
+@@ -66,7 +66,6 @@
+ * 09/18/07 CPH CQ11466 Added EFM Support
+ *********************************************************************************************/
+
+-#include <linux/config.h>
+ #include <linux/kernel.h>
+ #include <linux/module.h>
+ #include <linux/init.h>
+@@ -74,11 +73,14 @@
+ #include <linux/delay.h>
+ #include <linux/spinlock.h>
+ #include <linux/smp_lock.h>
+-#include <asm/io.h>
+-#include <asm/mips-boards/prom.h>
+ #include <linux/proc_fs.h>
+ #include <linux/string.h>
+ #include <linux/ctype.h>
++
++#include <asm/io.h>
++#include <asm/ar7/ar7.h>
++#include <asm/ar7/prom.h>
++
+ #include "dsl_hal_api.h"
+ #ifdef AR7_EFM
+ #include "tn7efm.h"
+@@ -90,6 +92,7 @@
+ #include "dsl_hal_register.h"
+
+ #ifdef MODULE
++MODULE_LICENSE("GPL");
+ MODULE_DESCRIPTION ("Tnetd73xx ATM Device Driver");
+ MODULE_AUTHOR ("Zhicheng Tang");
+ #endif
+@@ -108,9 +111,9 @@ MODULE_AUTHOR ("Zhicheng Tang");
+
+ /*end of externs */
+
+-#ifndef TI_STATIC_ALLOCATIONS
+-#define TI_STATIC_ALLOCATIONS
+-#endif
++//#ifndef TI_STATIC_ALLOCATIONS
++//#define TI_STATIC_ALLOCATIONS
++//#endif
+
+ #define tn7atm_kfree_skb(x) dev_kfree_skb(x)
+
+@@ -135,7 +138,7 @@ static int EnableQoS = FALSE;
+ /* prototypes */
+ static int tn7atm_set_can_support_adsl2 (int can);
+
+-static int tn7atm_open (struct atm_vcc *vcc, short vpi, int vci);
++static int tn7atm_open (struct atm_vcc *vcc);
+
+ void tn7atm_close (struct atm_vcc *vcc);
+
+@@ -298,13 +301,12 @@ static const struct atmdev_ops tn7atm_op
+ getsockopt: NULL,
+ setsockopt: NULL,
+ send: tn7atm_send,
+- sg_send: NULL,
+ phy_put: NULL,
+ phy_get: NULL,
+ change_qos: tn7atm_change_qos,
+ };
+
+-const char drv_proc_root_folder[] = "avalanche/";
++const char drv_proc_root_folder[] = "avalanche";
+ static struct proc_dir_entry *root_proc_dir_entry = NULL;
+ #define DRV_PROC_MODE 0644
+ static int proc_root_already_exists = TRUE;
+@@ -626,56 +628,6 @@ static int turbodsl_check_priority_type(
+
+ /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+- * Function: int tn7atm_walk_vccs(struct atm_dev *dev, short *vcc, int *vci)
+- *
+- * Description: retrieve VPI/VCI for connection
+- *
+- *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+-static int tn7atm_walk_vccs (struct atm_vcc *vcc, short *vpi, int *vci)
+-{
+- struct atm_vcc *walk;
+-
+- /*
+- * find a free VPI
+- */
+- if (*vpi == ATM_VPI_ANY)
+- {
+-
+- for (*vpi = 0, walk = vcc->dev->vccs; walk; walk = walk->next)
+- {
+-
+- if ((walk->vci == *vci) && (walk->vpi == *vpi))
+- {
+- (*vpi)++;
+- walk = vcc->dev->vccs;
+- }
+- }
+- }
+-
+- /*
+- * find a free VCI
+- */
+- if (*vci == ATM_VCI_ANY)
+- {
+-
+- for (*vci = ATM_NOT_RSV_VCI, walk = vcc->dev->vccs; walk;
+- walk = walk->next)
+- {
+-
+- if ((walk->vpi = *vpi) && (walk->vci == *vci))
+- {
+- *vci = walk->vci + 1;
+- walk = vcc->dev->vccs;
+- }
+- }
+- }
+-
+- return 0;
+-}
+-
+-
+-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+- *
+ * Function: int tn7atm_sar_irq(void)
+ *
+ * Description: tnetd73xx SAR interrupt.
+@@ -766,7 +718,7 @@ static int __init tn7atm_irq_request (st
+
+ priv->sar_irq = LNXINTNUM (ATM_SAR_INT); /* Interrupt line # */
+
+- if (request_irq (priv->sar_irq, tn7atm_sar_irq, SA_INTERRUPT, "SAR ", dev))
++ if (request_irq (priv->sar_irq, tn7atm_sar_irq, IRQF_DISABLED, "SAR ", dev))
+ printk ("Could not register tn7atm_sar_irq\n");
+
+ /*
+@@ -777,8 +729,8 @@ static int __init tn7atm_irq_request (st
+ {
+ def_sar_inter_pace = os_atoi (ptr);
+ }
+- avalanche_request_pacing (priv->sar_irq, ATM_SAR_INT_PACING_BLOCK_NUM,
+- def_sar_inter_pace);
++ /* avalanche_request_pacing (priv->sar_irq, ATM_SAR_INT_PACING_BLOCK_NUM,
++ def_sar_inter_pace); */
+
+
+ #ifdef AR7_EFM
+@@ -790,7 +742,7 @@ static int __init tn7atm_irq_request (st
+ * Reigster Receive interrupt A
+ */
+ priv->dsl_irq = LNXINTNUM (ATM_DSL_INT); /* Interrupt line # */
+- if (request_irq (priv->dsl_irq, tn7atm_dsl_irq, SA_INTERRUPT, "DSL ", dev))
++ if (request_irq (priv->dsl_irq, tn7atm_dsl_irq, IRQF_DISABLED, "DSL ", dev))
+ printk ("Could not register tn7atm_dsl_irq\n");
+
+ /***** VRB Tasklet Mode ****/
+@@ -958,11 +910,15 @@ static int __init tn7atm_get_ESI (struct
+ #define ATM_VBR_RT 5
+ #endif
+
+-int tn7atm_open (struct atm_vcc *vcc, short vpi, int vci)
++int tn7atm_open (struct atm_vcc *vcc)
+ {
+ tn7atm_activate_vc_parm_t tn7atm_activate_vc_parm;
+ int rc;
+ //int flags;
++ tn7atm_activate_vc_parm.pcr = 0x20000;
++ tn7atm_activate_vc_parm.scr = 0x20000;
++ tn7atm_activate_vc_parm.mbs = 0x20000;
++ tn7atm_activate_vc_parm.cdvt = 10000;
+
+ dgprintf(1, "tn7atm_open()\n");
+
+@@ -974,24 +930,18 @@ int tn7atm_open (struct atm_vcc *vcc, sh
+ return -1;
+ }
+
+- MOD_INC_USE_COUNT;
++// MOD_INC_USE_COUNT;
+
+- /* find a free VPI/VCI */
+- tn7atm_walk_vccs(vcc, &vpi, &vci);
+-
+- vcc->vpi = vpi;
+- vcc->vci = vci;
+-
+- if ((vci == ATM_VCI_UNSPEC) || (vpi == ATM_VCI_UNSPEC))
++ if ((vcc->vci == ATM_VCI_UNSPEC) || (vcc->vpi == ATM_VCI_UNSPEC))
+ {
+- MOD_DEC_USE_COUNT;
++// MOD_DEC_USE_COUNT;
+ return -EBUSY;
+ }
+
+- tn7atm_activate_vc_parm.vpi = vpi;
+- tn7atm_activate_vc_parm.vci = vci;
++ tn7atm_activate_vc_parm.vpi = vcc->vpi;
++ tn7atm_activate_vc_parm.vci = vcc->vci;
+
+- if ((vpi == CLEAR_EOC_VPI) && (vci == CLEAR_EOC_VCI))
++ if ((vcc->vpi == CLEAR_EOC_VPI) && (vcc->vci == CLEAR_EOC_VCI))
+ {
+ /* always use (max_dma_chan+1) for clear eoc */
+ tn7atm_activate_vc_parm.chan = EOC_DMA_CHAN;
+@@ -999,7 +949,7 @@ int tn7atm_open (struct atm_vcc *vcc, sh
+ /* check to see whether clear eoc is opened or not */
+ if (tn7atm_activate_vc_parm.priv->lut[tn7atm_activate_vc_parm.chan].inuse)
+ {
+- MOD_DEC_USE_COUNT;
++// MOD_DEC_USE_COUNT;
+ printk("tn7atm_open: Clear EOC channel (dmachan=%d) already in use.\n", tn7atm_activate_vc_parm.chan);
+ return -EBUSY;
+ }
+@@ -1008,7 +958,7 @@ int tn7atm_open (struct atm_vcc *vcc, sh
+ if (rc)
+ {
+ printk("tn7atm_open: failed to setup clear_eoc\n");
+- MOD_DEC_USE_COUNT;
++// MOD_DEC_USE_COUNT;
+ return -EBUSY;
+ }
+ tn7atm_set_lut(tn7atm_activate_vc_parm.priv,vcc, tn7atm_activate_vc_parm.chan);
+@@ -1017,17 +967,17 @@ int tn7atm_open (struct atm_vcc *vcc, sh
+ }
+ else /* PVC channel setup */
+ {
+- if ((vpi==REMOTE_MGMT_VPI) && (vci==REMOTE_MGMT_VCI))
++ if ((vcc->vpi==REMOTE_MGMT_VPI) && (vcc->vci==REMOTE_MGMT_VCI))
+ {
+ tn7atm_activate_vc_parm.chan = 14; /* always use chan 14 for MII PVC-base romote mgmt */
+ }
+ else
+ {
+- rc = tn7atm_lut_find(vpi, vci);
++ rc = tn7atm_lut_find(vcc->vpi, vcc->vci);
+ /* check to see whether PVC is opened or not */
+ if(ATM_NO_DMA_CHAN != rc)
+ {
+- MOD_DEC_USE_COUNT;
++// MOD_DEC_USE_COUNT;
+ printk("PVC already opened. dmachan = %d\n", rc);
+ return -EBUSY;
+ }
+@@ -1059,6 +1009,7 @@ int tn7atm_open (struct atm_vcc *vcc, sh
+ tn7atm_activate_vc_parm.priority = 2;
+ break;
+
++#if 0
+ case ATM_VBR: /* Variable Bit Rate-Non RealTime*/
+ tn7atm_activate_vc_parm.qos = 1;
+ tn7atm_activate_vc_parm.priority = 1;
+@@ -1080,6 +1031,7 @@ int tn7atm_open (struct atm_vcc *vcc, sh
+ tn7atm_activate_vc_parm.mbs = vcc->qos.txtp.max_pcr;
+ tn7atm_activate_vc_parm.cdvt = vcc->qos.txtp.max_cdv;
+ break;
++#endif
+
+ default:
+ tn7atm_activate_vc_parm.qos = 2;
+@@ -1107,7 +1059,7 @@ int tn7atm_open (struct atm_vcc *vcc, sh
+ if (rc < 0)
+ {
+ printk("failed to activate hw channel\n");
+- MOD_DEC_USE_COUNT;
++// MOD_DEC_USE_COUNT;
+ tn7atm_lut_clear(vcc, tn7atm_activate_vc_parm.chan);
+ //spin_unlock_irqrestore(&chan_init_lock, flags);
+ return -EBUSY;
+@@ -1197,7 +1149,7 @@ void tn7atm_close (struct atm_vcc *vcc)
+ tn7atm_lut_clear (vcc, dmachan);
+ //spin_unlock_irqrestore (&closeLock, closeFlag);
+
+- MOD_DEC_USE_COUNT;
++// MOD_DEC_USE_COUNT;
+
+ dgprintf (1, "Leave tn7atm_close\n");
+ }
+@@ -1630,8 +1582,7 @@ int tn7atm_receive (void *os_dev, int ch
+ * firewall is on */
+
+ dgprintf (3, "pushing the skb...\n");
+-
+- skb->stamp = vcc->timestamp = xtime;
++ __net_timestamp(skb);
+
+ xdump ((unsigned char *) skb->data, skb->len, 5);
+
+@@ -1854,8 +1805,7 @@ printk("!!!free atm irq: tn7atm_exit\n")
+
+ kfree (dev->dev_data);
+
+- // atm_dev_deregister (dev);
+- shutdown_atm_dev (dev);
++ atm_dev_deregister (dev);
+
+ /*
+ * remove proc entries
+@@ -2086,9 +2036,6 @@ static int __init tn7atm_detect (void)
+ * Set up proc entry for atm stats
+ */
+
+- if (tn7atm_xlate_proc_name
+- (drv_proc_root_folder, &root_proc_dir_entry, &residual))
+- {
+ printk ("Creating new root folder %s in the proc for the driver stats \n",
+ drv_proc_root_folder);
+ root_proc_dir_entry = proc_mkdir (drv_proc_root_folder, NULL);
+@@ -2098,7 +2045,6 @@ static int __init tn7atm_detect (void)
+ return -ENOMEM;
+ }
+ proc_root_already_exists = FALSE;
+- }
+
+
+ /*
+@@ -2731,7 +2677,5 @@ int tn7atm_proc_turbodsl_write(struct fi
+ return count;
+ }
+
+-#ifdef MODULE
+ module_init (tn7atm_detect);
+ module_exit (tn7atm_exit);
+-#endif /* MODULE */
+--- a/tn7atm.h
++++ b/tn7atm.h
+@@ -20,7 +20,8 @@
+ //#include "mips_support.h"
+ #include <linux/list.h>
+
+-#include <linux/config.h>
++#define MIPS_EXCEPTION_OFFSET 8
++#define LNXINTNUM(x)((x) + MIPS_EXCEPTION_OFFSET)
+
+ #ifdef CONFIG_MODVERSIONS
+ #include <linux/modversions.h>
+--- a/tn7dsl.c
++++ b/tn7dsl.c
+@@ -102,7 +102,6 @@
+ * UR8_MERGE_END CQ11813
+ * 09/18/07 CPH CQ11466: Added EFM support.
+ *********************************************************************************************/
+-#include <linux/config.h>
+ #include <linux/kernel.h>
+ #include <linux/module.h>
+ #include <linux/init.h>
+@@ -110,8 +109,6 @@
+ #include <linux/delay.h>
+ #include <linux/spinlock.h>
+ #include <linux/smp_lock.h>
+-#include <asm/io.h>
+-#include <asm/mips-boards/prom.h>
+ #include <linux/proc_fs.h>
+ #include <linux/string.h>
+ #include <linux/ctype.h>
+@@ -119,6 +116,12 @@
+ #include <linux/timer.h>
+ #include <linux/vmalloc.h>
+ #include <linux/file.h>
++#include <linux/firmware.h>
++
++#include <asm/io.h>
++#include <asm/ar7/ar7.h>
++#include <asm/ar7/prom.h>
++
+ /* Modules specific header files */
+ #ifdef AR7_EFM
+ #include "tn7efm.h"
+@@ -185,7 +188,7 @@ led_reg_t ledreg[2];
+ static struct led_funcs ledreg[2];
+ #endif
+
+-#define DEV_DSLMOD 1
++#define DEV_DSLMOD CTL_UNNUMBERED
+ #define MAX_STR_SIZE 256
+ #define DSL_MOD_SIZE 256
+
+@@ -316,7 +319,7 @@ static PITIDSLHW_T pIhw;
+ static volatile int bshutdown;
+ static char info[MAX_STR_SIZE];
+ /* Used for DSL Polling enable */
+-static DECLARE_MUTEX_LOCKED (adsl_sem_overlay);
++static struct semaphore adsl_sem_overlay;
+
+ //kthread_t overlay_thread;
+ /* end of module wide declars */
+@@ -369,6 +372,14 @@ int os_atoih (const char *pstr)
+ return val;
+ }
+
++int avalanche_request_intr_pacing(int irq_nr, unsigned int blk_num,
++ unsigned int pace_value)
++{
++ printk("avalanche_request_pacing(%d, %u, %u); // not implemented\n", irq_nr, blk_num, pace_value);
++ return 0;
++}
++
++
+ int os_atoi(const char *pStr)
+ {
+ int MulNeg = (*pStr == '-' ? -1 : 1);
+@@ -405,39 +416,6 @@ void dprintf (int uDbgLevel, char *szFmt
+ #endif
+ }
+
+-int strcmp(const char *s1, const char *s2)
+-{
+-
+- int size = strlen(s1);
+-
+- return(strncmp(s1, s2, size));
+-}
+-
+-int strncmp(const char *s1, const char *s2, size_t size)
+-{
+- int i = 0;
+- int max_size = (int)size;
+-
+- while((s1[i] != 0) && i < max_size)
+- {
+- if(s2[i] == 0)
+- {
+- return -1;
+- }
+- if(s1[i] != s2[i])
+- {
+- return 1;
+- }
+- i++;
+- }
+- if(s2[i] != 0)
+- {
+- return 1;
+- }
+-
+- return 0;
+-}
+-
+ // * UR8_MERGE_START CQ10640 Jack Zhang
+ int tn7dsl_dump_dsp_memory(char *input_str) //cph99
+ {
+@@ -487,144 +465,78 @@ unsigned int shim_osGetCpuFrequency(void
+ return CpuFrequency;
+ }
+
+-int shim_osLoadFWImage(unsigned char *ptr)
++static void avsar_release(struct device *dev)
+ {
+- unsigned int bytesRead;
+- mm_segment_t oldfs;
+- static struct file *filp;
+- unsigned int imageLength=0x5ffff;
+-
+-#ifdef AR7_EFM
+- int dp_alt=0;
+- char *ptr1=NULL;
+-#ifdef EFM_DEBUG
+- char *ptr2=NULL;
+- char *ptr3=NULL;
+-#endif
+-
+- if ((ptr1 = prom_getenv("DSL_DP_ALT")) != NULL)
+- {
+- dp_alt=os_atoi(ptr1);
+- if (dp_alt==1)
+- {
+- filp = filp_open(DSP_DEBUG_FIRMWARE_PATH,00,O_RDONLY);
+- if (!IS_ERR(filp))
+- {
+- strcpy (DSP_FIRMWARE_PATH, DSP_DEBUG_FIRMWARE_PATH);
+- }
+- }
+-#ifdef EFM_DEBUG
+- else if (dp_alt==2)
+- {
+- if ((ptr2 = prom_getenv("DSL_DP")) != NULL)
+- {
+- if (!strncmp(ptr2, "DSL_DP", 6))
+- { // indirect naming
+- if ((ptr3 = prom_getenv(ptr2)) != NULL)
+- filp = filp_open(ptr3,00,O_RDONLY);
+- ptr2 = ptr3; // redirect ptr2 to ptr3
+- }
+-
+- filp = filp_open(ptr2,00,O_RDONLY);
+- if (!IS_ERR(filp))
+- {
+- strcpy (DSP_FIRMWARE_PATH, ptr2);
+- }
+- }
+- }
+- printk("dp_path=%s\n", DSP_FIRMWARE_PATH);
+-#endif
+- }
+-#endif
+-
+- dgprintf(4, "tn7dsl_read_dsp()\n");
+-
+- dgprintf(4,"open file %s\n", DSP_FIRMWARE_PATH);
+-
+- filp=filp_open(DSP_FIRMWARE_PATH,00,O_RDONLY);
+- if(IS_ERR(filp))
+- {
+- printk("Failed: Could not open DSP binary file\n");
+- return -1;
+- }
+-
+- if (filp->f_dentry != NULL)
+- {
+- if (filp->f_dentry->d_inode != NULL)
+- {
+- printk ("DSP binary filesize = %d bytes\n",
+- (int) filp->f_dentry->d_inode->i_size);
+- imageLength = (unsigned int)filp->f_dentry->d_inode->i_size + 0x200;
+- }
+- }
+-
+- if (filp->f_op->read==NULL)
+- return -1; /* File(system) doesn't allow reads */
+-
+- /*
+- * Disable parameter checking
+- */
+- oldfs = get_fs();
+- set_fs(KERNEL_DS);
+-
+- /*
+- * Now read bytes from postion "StartPos"
+- */
+- filp->f_pos = 0;
+-
+- bytesRead = filp->f_op->read(filp,ptr,imageLength,&filp->f_pos);
+-
+- dgprintf(4,"file length = %d\n", bytesRead);
+-
+- set_fs(oldfs);
+-
+- /*
+- * Close the file
+- */
+- fput(filp);
+-
+- return bytesRead;
++ printk(KERN_DEBUG "avsar firmware released\n");
+ }
+
++static struct device avsar = {
++ .bus_id = "vlynq",
++ .release = avsar_release,
++};
+
+-unsigned int shim_read_overlay_page (void *ptr, unsigned int secOffset,
+- unsigned int secLength)
++int shim_osLoadFWImage(unsigned char *ptr)
+ {
+- unsigned int bytesRead;
+- mm_segment_t oldfs;
+- struct file *filp;
+-
+- dgprintf(4,"shim_read_overlay_page\n");
+- //dgprintf(4,"sec offset=%d, sec length =%d\n", secOffset, secLength);
++ const struct firmware *fw_entry;
++ size_t size;
+
+- filp=filp_open(DSP_FIRMWARE_PATH,00,O_RDONLY);
+- if(filp ==NULL)
+- {
+- printk("Failed: Could not open DSP binary file\n");
+- return -1;
+- }
+-
+- if (filp->f_op->read==NULL)
+- return -1; /* File(system) doesn't allow reads */
+-
+- /*
+- * Now read bytes from postion "StartPos"
+- */
++ printk("requesting firmware image \"ar0700xx.bin\"\n");
++ if(device_register(&avsar) < 0) {
++ printk(KERN_ERR
++ "avsar: device_register fails\n");
++ return -1;
++ }
++
++ if (request_firmware(&fw_entry, "ar0700xx.bin", &avsar)) {
++ printk(KERN_ERR
++ "avsar: Firmware not available\n");
++ device_unregister(&avsar);
++ return -1;
++ }
++ size = fw_entry->size;
++ device_unregister(&avsar);
++ if (size > 0x6ffff) {
++ printk(KERN_ERR
++ "avsar: Firmware too big (%d bytes)\n", size);
++ release_firmware(fw_entry);
++ return -1;
++ }
++ memcpy(ptr, fw_entry->data, size);
++ release_firmware(fw_entry);
++ return size;
++}
++
++unsigned int shim_read_overlay_page(void *ptr, unsigned int secOffset, unsigned int secLength)
++{
++ const struct firmware *fw_entry;
++
++ printk("requesting firmware image \"ar0700xx.bin\"\n");
++ if (device_register(&avsar) < 0) {
++ printk(KERN_ERR
++ "avsar: device_register fails\n");
++ return -1;
++ }
++
++ if (request_firmware(&fw_entry, "ar0700xx.bin", &avsar)) {
++ printk(KERN_ERR
++ "avsar: Firmware not available\n");
++ device_unregister(&avsar);
++ return -1;
++ }
++
++ device_unregister(&avsar);
++ if (fw_entry->size > secLength) {
++ printk(KERN_ERR
++ "avsar: Firmware too big (%d bytes)\n", fw_entry->size);
++ release_firmware(fw_entry);
++ return -1;
++ }
++ memcpy(ptr + secOffset, fw_entry->data, secLength);
++ release_firmware(fw_entry);
++ return secLength;
++}
+
+- if(filp->f_op->llseek)
+- filp->f_op->llseek(filp,secOffset, 0);
+- oldfs = get_fs();
+- set_fs(KERNEL_DS);
+- filp->f_pos = secOffset;
+- bytesRead = filp->f_op->read(filp,ptr,secLength,&filp->f_pos);
+
+- set_fs(oldfs);
+- /*
+- * Close the file
+- */
+- fput(filp);
+- return bytesRead;
+-}
+
+ int shim_osLoadDebugFWImage(unsigned char *ptr)
+ {
+@@ -3287,6 +3199,7 @@ int tn7dsl_init(void *priv)
+ int high_precision_selected = 0;
+ // UR8_MERGE_END CQ11054*
+
++ sema_init(&adsl_sem_overlay, 0);
+ /*
+ * start dsl
+ */
+@@ -3665,7 +3578,7 @@ static int dslmod_sysctl(ctl_table *ctl,
+ */
+ if(write)
+ {
+- ret = proc_dostring(ctl, write, filp, buffer, lenp);
++ ret = proc_dostring(ctl, write, filp, buffer, lenp, 0);
+
+ switch (ctl->ctl_name)
+ {
+@@ -3751,14 +3664,14 @@ static int dslmod_sysctl(ctl_table *ctl,
+ else
+ {
+ len += sprintf(info+len, mod_req);
+- ret = proc_dostring(ctl, write, filp, buffer, lenp);
++ ret = proc_dostring(ctl, write, filp, buffer, lenp, 0);
+ }
+ return ret;
+ }
+
+
+ ctl_table dslmod_table[] = {
+- {DEV_DSLMOD, "dslmod", info, DSL_MOD_SIZE, 0644, NULL, &dslmod_sysctl}
++ {DEV_DSLMOD, "dslmod", info, DSL_MOD_SIZE, 0644, NULL, NULL, &dslmod_sysctl, &sysctl_string}
+ ,
+ {0}
+ };
+@@ -3781,8 +3694,7 @@ void tn7dsl_dslmod_sysctl_register(void)
+ if (initialized == 1)
+ return;
+
+- dslmod_sysctl_header = register_sysctl_table(dslmod_root_table, 1);
+- dslmod_root_table->child->de->owner = THIS_MODULE;
++ dslmod_sysctl_header = register_sysctl_table(dslmod_root_table);
+
+ /*
+ * set the defaults
+--- a/tn7sar.c
++++ b/tn7sar.c
+@@ -43,7 +43,6 @@
+ * 09/18/07 CPH CQ11466: Added EFM support.
+ *******************************************************************************/
+
+-#include <linux/config.h>
+ #include <linux/kernel.h>
+ #include <linux/module.h>
+ #include <linux/init.h>
+@@ -51,12 +50,13 @@
+ #include <linux/delay.h>
+ #include <linux/spinlock.h>
+ #include <linux/smp_lock.h>
+-#include <asm/io.h>
+-#include <asm/mips-boards/prom.h>
+ #include <linux/proc_fs.h>
+ #include <linux/string.h>
+ #include <linux/ctype.h>
+
++#include <asm/io.h>
++#include <asm/ar7/ar7.h>
++#include <asm/ar7/prom.h>
+
+ #define _CPHAL_AAL5
+ #define _CPHAL_SAR
diff --git a/package/system/ar7-atm/patches-D7.05.01.00/110-interrupt_fix.patch b/package/system/ar7-atm/patches-D7.05.01.00/110-interrupt_fix.patch
new file mode 100644
index 0000000..1122457
--- /dev/null
+++ b/package/system/ar7-atm/patches-D7.05.01.00/110-interrupt_fix.patch
@@ -0,0 +1,37 @@
+--- a/tn7atm.c
++++ b/tn7atm.c
+@@ -633,7 +633,7 @@ static int turbodsl_check_priority_type(
+ * Description: tnetd73xx SAR interrupt.
+ *
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+-static void tn7atm_sar_irq (int irq, void *voiddev, struct pt_regs *regs)
++static irqreturn_t tn7atm_sar_irq (int irq, void *voiddev)
+ {
+ struct atm_dev *atmdev;
+ Tn7AtmPrivate *priv;
+@@ -660,6 +660,7 @@ static void tn7atm_sar_irq (int irq, voi
+ #ifdef TIATM_INST_SUPP
+ psp_trace_par (ATM_DRV_SAR_ISR_EXIT, retval);
+ #endif
++ return IRQ_HANDLED;
+ }
+
+ /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+@@ -669,7 +670,7 @@ static void tn7atm_sar_irq (int irq, voi
+ * Description: tnetd73xx DSL interrupt.
+ *
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+-static void tn7atm_dsl_irq (int irq, void *voiddev, struct pt_regs *regs)
++static irqreturn_t tn7atm_dsl_irq (int irq, void *voiddev)
+ {
+ struct atm_dev *atmdev;
+ Tn7AtmPrivate *priv;
+@@ -691,6 +692,8 @@ static void tn7atm_dsl_irq (int irq, voi
+ #ifdef TIATM_INST_SUPP
+ psp_trace_par (ATM_DRV_DSL_ISR_EXIT, retval);
+ #endif
++
++ return IRQ_HANDLED;
+ }
+
+ /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/package/system/ar7-atm/patches-D7.05.01.00/120-no_dumb_inline.patch b/package/system/ar7-atm/patches-D7.05.01.00/120-no_dumb_inline.patch
new file mode 100644
index 0000000..e9d99df
--- /dev/null
+++ b/package/system/ar7-atm/patches-D7.05.01.00/120-no_dumb_inline.patch
@@ -0,0 +1,11 @@
+--- a/tn7api.h
++++ b/tn7api.h
+@@ -118,7 +118,7 @@ int tn7dsl_proc_dbgmsg_write(struct file
+ int tn7dsl_proc_dbgmsg_read(char* buf, char **start, off_t offset, int count,int *eof, void *data);
+ #endif
+ //UR8_MERGE_END CQ11813
+-inline int tn7dsl_handle_interrupt(void);
++int tn7dsl_handle_interrupt(void);
+
+ void tn7dsl_dslmod_sysctl_register(void);
+ void tn7dsl_dslmod_sysctl_unregister(void);
diff --git a/package/system/ar7-atm/patches-D7.05.01.00/130-powercutback.patch b/package/system/ar7-atm/patches-D7.05.01.00/130-powercutback.patch
new file mode 100644
index 0000000..4154864
--- /dev/null
+++ b/package/system/ar7-atm/patches-D7.05.01.00/130-powercutback.patch
@@ -0,0 +1,44 @@
+--- a/dsl_hal_advcfg.c
++++ b/dsl_hal_advcfg.c
+@@ -36,9 +36,9 @@
+ * 05Jul05 0.00.09 CPH CQ9775: Change dslhal_advcfg_configDsTones input parameters & support for ADSL2+
+ * 24Jul05 0.00.10 CPH Fixed comments in dslhal_advcfg_configDsTones function header
+ *******************************************************************************/
+-#include <dev_host_interface.h>
+-#include <dsl_hal_register.h>
+-#include <dsl_hal_support.h>
++#include "dev_host_interface.h"
++#include "dsl_hal_register.h"
++#include "dsl_hal_support.h"
+
+ /*****************************************************************************/
+ /* ACT API functions -- To be moved into their own independent module --RamP */
+--- a/Makefile
++++ b/Makefile
+@@ -4,6 +4,7 @@
+
+ CONFIG_SANGAM_ATM=m
+ #EXTRA_CFLAGS += -DEL -I. -DPOST_SILICON -DCOMMON_NSP -DCONFIG_LED_MODULE -DDEREGISTER_LED -DNO_ACT
+-EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -DNO_ACT -D__NO__VOICE_PATCH__ -DEL
++#EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -DNO_ACT -D__NO__VOICE_PATCH__ -DEL
++EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -D__NO__VOICE_PATCH__ -DEL
+ obj-$(CONFIG_SANGAM_ATM) := tiatm.o
+-tiatm-objs += cpsar.o aal5sar.o tn7sar.o tn7atm.o tn7dsl.o dsl_hal_api.o dsl_hal_support.o
++tiatm-objs += cpsar.o aal5sar.o tn7sar.o tn7atm.o tn7dsl.o dsl_hal_api.o dsl_hal_support.o dsl_hal_advcfg.o
+--- a/tn7dsl.c
++++ b/tn7dsl.c
+@@ -3053,6 +3053,14 @@ static int tn7dsl_set_dsl(void)
+ dslhal_api_setRateAdaptFlag(pIhw, os_atoi(ptr));
+ }
+
++ // set powercutback
++ ptr = NULL;
++ ptr = prom_getenv("powercutback");
++ if(ptr)
++ {
++ dslhal_advcfg_onOffPcb(pIhw, os_atoi(ptr));
++ }
++
+ // trellis
+ ptr = NULL;
+ ptr = prom_getenv("trellis");
diff --git a/package/system/ar7-atm/patches-D7.05.01.00/140-debug_mode.patch b/package/system/ar7-atm/patches-D7.05.01.00/140-debug_mode.patch
new file mode 100644
index 0000000..3873827
--- /dev/null
+++ b/package/system/ar7-atm/patches-D7.05.01.00/140-debug_mode.patch
@@ -0,0 +1,16 @@
+--- a/tn7sar.c
++++ b/tn7sar.c
+@@ -125,10 +125,10 @@ enum
+ //09/05/07: cph, move to tn7atm.h
+ // #define RESERVED_OAM_CHANNEL 15
+
+-#define AAL5_PARM "id=aal5, base = 0x03000000, offset = 0, int_line=15, ch0=[RxBufSize=1522; RxNumBuffers = 32; RxServiceMax = 50; TxServiceMax=50; TxNumBuffers=32; CpcsUU=0x5aa5; TxVc_CellRate=0x3000; TxVc_AtmHeader=0x00000640]"
+-#define SAR_PARM "id=sar,base = 0x03000000, reset_bit = 9, offset = 0; UniNni = 0, PdspEnable = 1"
++#define CH0_PARM "RxBufSize=1522, RxNumBuffers=32, RxServiceMax=50, TxServiceMax=50, TxNumBuffers=32, CpcsUU=0x5aa5, TxVc_CellRate=0x3000, TxVc_AtmHeader=0x00000640"
++#define AAL5_PARM "id=aal5, base=0x03000000, offset=0, int_line=15, ch0=[" CH0_PARM "]"
++#define SAR_PARM "id=sar, base=0x03000000, reset_bit=9, offset=0; UniNni=0, PdspEnable=1, Debug=0xFFFFFFFF"
+ #define RESET_PARM "id=ResetControl, base=0xA8611600"
+-#define CH0_PARM "RxBufSize=1522, RxNumBuffers = 32, RxServiceMax = 50, TxServiceMax=50, TxNumBuffers=32, CpcsUU=0x5aa5, TxVc_CellRate=0x3000, TxVc_AtmHeader=0x00000640"
+
+ #define MAX_PVC_TABLE_ENTRY 16
+
diff --git a/package/system/ar7-atm/patches-D7.05.01.00/150-tasklet_mode.patch b/package/system/ar7-atm/patches-D7.05.01.00/150-tasklet_mode.patch
new file mode 100644
index 0000000..97b8cec
--- /dev/null
+++ b/package/system/ar7-atm/patches-D7.05.01.00/150-tasklet_mode.patch
@@ -0,0 +1,11 @@
+--- a/Makefile
++++ b/Makefile
+@@ -5,6 +5,7 @@
+ CONFIG_SANGAM_ATM=m
+ #EXTRA_CFLAGS += -DEL -I. -DPOST_SILICON -DCOMMON_NSP -DCONFIG_LED_MODULE -DDEREGISTER_LED -DNO_ACT
+ #EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -DNO_ACT -D__NO__VOICE_PATCH__ -DEL
+-EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -D__NO__VOICE_PATCH__ -DEL
++#EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -D__NO__VOICE_PATCH__ -DEL
++EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -D__NO__VOICE_PATCH__ -DEL -DCPATM_TASKLET_MODE
+ obj-$(CONFIG_SANGAM_ATM) := tiatm.o
+ tiatm-objs += cpsar.o aal5sar.o tn7sar.o tn7atm.o tn7dsl.o dsl_hal_api.o dsl_hal_support.o dsl_hal_advcfg.o
diff --git a/package/system/ar7-atm/patches-D7.05.01.00/160-module-params.patch b/package/system/ar7-atm/patches-D7.05.01.00/160-module-params.patch
new file mode 100644
index 0000000..75a41d1
--- /dev/null
+++ b/package/system/ar7-atm/patches-D7.05.01.00/160-module-params.patch
@@ -0,0 +1,675 @@
+--- a/tn7atm.c
++++ b/tn7atm.c
+@@ -95,6 +95,146 @@
+ MODULE_LICENSE("GPL");
+ MODULE_DESCRIPTION ("Tnetd73xx ATM Device Driver");
+ MODULE_AUTHOR ("Zhicheng Tang");
++
++int mp_sar_ipacemax = -1;
++module_param_named(ipacemax, mp_sar_ipacemax, int, 0);
++MODULE_PARM_DESC(ipacemax, "Interrupt pacing");
++
++char *mp_macc = NULL;
++module_param_named(macc, mp_macc, charp, 0);
++MODULE_PARM_DESC(macc, "MAC address");
++
++int mp_dsp_noboost = -1;
++module_param_named(dsp_noboost, mp_dsp_noboost, int, 0);
++MODULE_PARM_DESC(dsp_noboost, "Suppress DSP frequency boost");
++
++int mp_dsp_freq = -1;
++module_param_named(dsp_freq, mp_dsp_freq, int, 0);
++MODULE_PARM_DESC(dsp_freq, "Frequency to boost the DSP to");
++
++char *mp_featctl0 = NULL;
++module_param_named(featctl0, mp_featctl0, charp, 0);
++MODULE_PARM_DESC(featctl0, "DSL feature control 0");
++
++char *mp_featctl1 = NULL;
++module_param_named(featctl1, mp_featctl1, charp, 0);
++MODULE_PARM_DESC(featctl1, "DSL feature control 1");
++
++char *mp_phyctl0 = NULL;
++module_param_named(phyctl0, mp_phyctl0, charp, 0);
++MODULE_PARM_DESC(phyctl0, "DSL PHY control 0");
++
++char *mp_phyctl1 = NULL;
++module_param_named(phyctl1, mp_phyctl1, charp, 0);
++MODULE_PARM_DESC(phyctl1, "DSL PHY control 1");
++
++int mp_turbodsl = -1;
++module_param_named(turbodsl, mp_turbodsl, int, 0);
++MODULE_PARM_DESC(turbodsl, "Enable TurboDSL");
++
++int mp_sar_rxbuf = -1;
++module_param_named(sar_rxbuf, mp_sar_rxbuf, int, 0);
++MODULE_PARM_DESC(sar_rxbuf, "SAR RxBuf size");
++
++int mp_sar_rxmax = -1;
++module_param_named(sar_rxmax, mp_sar_rxmax, int, 0);
++MODULE_PARM_DESC(sar_rxmax, "SAR RxMax size");
++
++int mp_sar_txbuf = -1;
++module_param_named(sar_txbuf, mp_sar_txbuf, int, 0);
++MODULE_PARM_DESC(sar_txbuf, "SAR TxBuf size");
++
++int mp_sar_txmax = -1;
++module_param_named(sar_txmax, mp_sar_txmax, int, 0);
++MODULE_PARM_DESC(sar_txmax, "SAR TxMax size");
++
++char *mp_modulation = NULL;
++module_param_named(modulation, mp_modulation, charp, 0);
++MODULE_PARM_DESC(modulation, "Modulation");
++
++int mp_fine_gain_control = -1;
++module_param_named(fine_gain_control, mp_fine_gain_control, int, 0);
++MODULE_PARM_DESC(fine_gain_control, "Fine gain control");
++
++int mp_fine_gain_value = -1;
++module_param_named(fine_gain_value, mp_fine_gain_value, int, 0);
++MODULE_PARM_DESC(fine_gain_value, "Fine gain value");
++
++int mp_enable_margin_retrain = -1;
++module_param_named(enable_margin_retrain, mp_enable_margin_retrain, int, 0);
++MODULE_PARM_DESC(enable_margin_retrain, "Enable margin retrain");
++
++int mp_margin_threshold = -1;
++module_param_named(margin_threshold, mp_margin_threshold, int, 0);
++MODULE_PARM_DESC(margin_threshold, "Margin retrain treshold");
++
++int mp_enable_rate_adapt = -1;
++module_param_named(enable_rate_adapt, mp_enable_rate_adapt, int, 0);
++MODULE_PARM_DESC(enable_rate_adapt, "Enable rate adaption");
++
++int mp_powercutback = -1;
++module_param_named(powercutback, mp_powercutback, int, 0);
++MODULE_PARM_DESC(powercutback, "Enable / disable powercutback");
++
++int mp_trellis = -1;
++module_param_named(trellis, mp_trellis, int, 0);
++MODULE_PARM_DESC(trellis, "Enable / disable trellis coding");
++
++int mp_bitswap = -1;
++module_param_named(bitswap, mp_bitswap, int, 0);
++MODULE_PARM_DESC(bitswap, "Enable / disable bitswap");
++
++int mp_maximum_bits_per_carrier = -1;
++module_param_named(maximum_bits_per_carrier, mp_maximum_bits_per_carrier, int, 0);
++MODULE_PARM_DESC(maximum_bits_per_carrier, "Maximum bits per carrier");
++
++int mp_maximum_interleave_depth = -1;
++module_param_named(maximum_interleave_depth, mp_maximum_interleave_depth, int, 0);
++MODULE_PARM_DESC(maximum_interleave_depth, "Maximum interleave depth");
++
++int mp_pair_selection = -1;
++module_param_named(pair_selection, mp_pair_selection, int, 0);
++MODULE_PARM_DESC(pair_selection, "Pair selection");
++
++int mp_dgas_polarity = -1;
++module_param_named(dgas_polarity, mp_dgas_polarity, int, 0);
++MODULE_PARM_DESC(dgas_polarity, "DGAS polarity");
++
++int mp_los_alarm = -1;
++module_param_named(los_alarm, mp_los_alarm, int, 0);
++MODULE_PARM_DESC(los_alarm, "LOS alarm");
++
++char *mp_eoc_vendor_id = NULL;
++module_param_named(eoc_vendor_id, mp_eoc_vendor_id, charp, 0);
++MODULE_PARM_DESC(eoc_vendor_id, "EOC vendor id");
++
++int mp_eoc_vendor_revision = -1;
++module_param_named(eoc_vendor_revision, mp_eoc_vendor_revision, int, 0);
++MODULE_PARM_DESC(eoc_vendor_revision, "EOC vendor revision");
++
++char *mp_eoc_vendor_serialnum = NULL;
++module_param_named(eoc_vendor_serialnum, mp_eoc_vendor_serialnum, charp, 0);
++MODULE_PARM_DESC(eoc_vendor_serialnum, "EOC vendor serial number");
++
++char *mp_invntry_vernum = NULL;
++module_param_named(invntry_vernum, mp_invntry_vernum, charp, 0);
++MODULE_PARM_DESC(invntry_vernum, "Inventory revision number");
++
++int mp_dsl_bit_tmode = -1;
++module_param_named(dsl_bit_tmode, mp_dsl_bit_tmode, int, 0);
++MODULE_PARM_DESC(dsl_bit_tmode, "DSL bit training mode");
++
++int mp_high_precision = -1;
++module_param_named(high_precision, mp_high_precision, int, 0);
++MODULE_PARM_DESC(high_precision, "High precision");
++
++int mp_autopvc_enable = -1;
++module_param_named(autopvc_enable, mp_autopvc_enable, int, 0);
++MODULE_PARM_DESC(autopvc_enable, "Enable / disable automatic PVC");
++
++int mp_oam_lb_timeout = -1;
++module_param_named(oam_lb_timeout, mp_oam_lb_timeout, int, 0);
++MODULE_PARM_DESC(oam_lb_timeout, "OAM LB timeout");
+ #endif
+
+ #ifndef TRUE
+@@ -728,9 +868,9 @@
+ * interrupt pacing
+ */
+ ptr = prom_getenv ("sar_ipacemax");
+- if (ptr)
++ if (ptr || mp_sar_ipacemax != -1)
+ {
+- def_sar_inter_pace = os_atoi (ptr);
++ def_sar_inter_pace = mp_sar_ipacemax == -1 ? os_atoi (ptr) : mp_sar_ipacemax;
+ }
+ /* avalanche_request_pacing (priv->sar_irq, ATM_SAR_INT_PACING_BLOCK_NUM,
+ def_sar_inter_pace); */
+@@ -878,9 +1018,18 @@
+ {
+ int i;
+ char esi_addr[ESI_LEN] = { 0x00, 0x00, 0x11, 0x22, 0x33, 0x44 };
+- char *esiaddr_str = NULL;
++ char *esiaddr_str = mp_macc;
+
+- esiaddr_str = prom_getenv ("macc");
++ if (esiaddr_str == NULL)
++ esiaddr_str = prom_getenv ("macdsl");
++ if (esiaddr_str == NULL)
++ esiaddr_str = prom_getenv ("macc");
++ if (esiaddr_str == NULL)
++ esiaddr_str = prom_getenv ("HWA_1");
++ if (esiaddr_str == NULL)
++ esiaddr_str = prom_getenv ("macb");
++ if (esiaddr_str == NULL)
++ esiaddr_str = prom_getenv ("maca");
+
+ if (!esiaddr_str)
+ {
+@@ -2139,15 +2288,15 @@
+ //UR8_MERGE_END CQ10450*
+
+ cp = prom_getenv ("dsp_noboost");
+- if (cp)
++ if (cp || mp_dsp_noboost != -1)
+ {
+- dsp_noboost = os_atoi (cp);
++ dsp_noboost = mp_dsp_noboost == -1 ? os_atoi (cp) : mp_dsp_noboost;
+ }
+
+ cp = (char *) prom_getenv ("dsp_freq");
+- if (cp)
++ if (cp || mp_dsp_freq != -1)
+ {
+- dspfreq = os_atoi (cp);
++ dspfreq = mp_dsp_freq == -1 ? os_atoi (cp) : mp_dsp_freq;
+ if (dspfreq == 250)
+ {
+ boostDsp = 1;
+@@ -2396,15 +2545,17 @@
+ // Inter-Op DSL phy Control
+ // Note the setting of _dsl_Feature_0 and _dsl_Feature_1 must before
+ // dslhal_api_dslStartup (in tn7dsl_init()).
+- if ((ptr = prom_getenv ("DSL_FEATURE_CNTL_0")) != NULL)
++ if ((ptr = prom_getenv ("DSL_FEATURE_CNTL_0")) != NULL || mp_featctl0 != NULL)
+ {
+- _dsl_Feature_0 = os_atoih (ptr);
++ if (mp_featctl0 != NULL) ptr = mp_featctl0;
++ _dsl_Feature_0 = os_atoh (ptr);
+ _dsl_Feature_0_defined = 1;
+ }
+
+- if ((ptr = prom_getenv ("DSL_FEATURE_CNTL_1")) != NULL)
++ if ((ptr = prom_getenv ("DSL_FEATURE_CNTL_1")) != NULL || mp_featctl1 != NULL)
+ {
+- _dsl_Feature_1 = os_atoih (ptr);
++ if (mp_featctl1 != NULL) ptr = mp_featctl1;
++ _dsl_Feature_1 = os_atoh (ptr);
+ _dsl_Feature_1_defined = 1;
+ }
+
+@@ -2412,15 +2563,17 @@
+ // DSL phy Feature Control
+ // Note the setting of _dsl_PhyControl_0 and _dsl_PhyControl_1 must before
+ // dslhal_api_dslStartup (in tn7dsl_init()).
+- if ((ptr = prom_getenv ("DSL_PHY_CNTL_0")) != NULL)
++ if ((ptr = prom_getenv ("DSL_PHY_CNTL_0")) != NULL || mp_phyctl0 != NULL)
+ {
+- _dsl_PhyControl_0 = os_atoih (ptr);
++ if (mp_phyctl0 != NULL) ptr = mp_phyctl0;
++ _dsl_PhyControl_0 = os_atoh (ptr);
+ _dsl_PhyControl_0_defined = 1;
+ }
+
+- if ((ptr = prom_getenv ("DSL_PHY_CNTL_1")) != NULL)
++ if ((ptr = prom_getenv ("DSL_PHY_CNTL_1")) != NULL || mp_phyctl1 != NULL)
+ {
+- _dsl_PhyControl_1 = os_atoih (ptr);
++ if (mp_phyctl1 != NULL) ptr = mp_phyctl1;
++ _dsl_PhyControl_1 = os_atoh (ptr);
+ _dsl_PhyControl_1_defined = 1;
+ }
+
+@@ -2440,12 +2593,12 @@
+ // read config for turbo dsl
+
+ ptr = prom_getenv ("TurboDSL");
+- if (ptr)
++ if (ptr || mp_turbodsl != -1)
+ {
+ #if 1 //[KT]
+ bTurboDsl = os_atoi (ptr);
+ #else
+- priv->bTurboDsl = os_atoi (ptr);
++ priv->bTurboDsl = mp_turbodsl == -1 ? os_atoi (ptr) : mp_turbodsl;
+ #endif
+ }
+ else
+@@ -2459,33 +2612,33 @@
+ priv->sarRxBuf = RX_BUFFER_NUM;
+ ptr = NULL;
+ ptr = prom_getenv ("SarRxBuf");
+- if (ptr)
++ if (ptr || mp_sar_rxbuf != -1)
+ {
+- priv->sarRxBuf = os_atoi (ptr);
++ priv->sarRxBuf = mp_sar_rxbuf == -1 ? os_atoi (ptr) : mp_sar_rxbuf;
+ }
+
+ priv->sarRxMax = RX_SERVICE_MAX;
+ ptr = NULL;
+ ptr = prom_getenv ("SarRxMax");
+- if (ptr)
++ if (ptr || mp_sar_rxmax != -1)
+ {
+- priv->sarRxMax = os_atoi (ptr);
++ priv->sarRxMax = mp_sar_rxmax == -1 ? os_atoi (ptr) : mp_sar_rxmax;
+ }
+
+ priv->sarTxBuf = TX_BUFFER_NUM;
+ ptr = NULL;
+ ptr = prom_getenv ("SarTxBuf");
+- if (ptr)
++ if (ptr || mp_sar_txbuf != -1)
+ {
+- priv->sarTxBuf = os_atoi (ptr);
++ priv->sarTxBuf = mp_sar_txbuf == -1 ? os_atoi (ptr) : mp_sar_txbuf;
+ }
+
+ priv->sarTxMax = TX_SERVICE_MAX;
+ ptr = NULL;
+ ptr = prom_getenv ("SarTxMax");
+- if (ptr)
++ if (ptr || mp_sar_txmax != -1)
+ {
+- priv->sarTxMax = os_atoi (ptr);
++ priv->sarTxMax = mp_sar_txmax == -1 ? os_atoi (ptr) : mp_sar_txmax;
+ }
+
+ #ifdef AR7_EFM
+--- a/tn7dsl.c
++++ b/tn7dsl.c
+@@ -148,6 +148,27 @@
+ #define NEW_TRAINING_VAL_T1413 128
+ #define NEW_TRAINING_VAL_MMODE 255
+
++extern char *mp_modulation;
++extern int mp_fine_gain_control;
++extern int mp_fine_gain_value;
++extern int mp_enable_margin_retrain;
++extern int mp_margin_threshold;
++extern int mp_enable_rate_adapt;
++extern int mp_powercutback;
++extern int mp_trellis;
++extern int mp_bitswap;
++extern int mp_maximum_bits_per_carrier;
++extern int mp_maximum_interleave_depth;
++extern int mp_pair_selection;
++extern int mp_dgas_polarity;
++extern int mp_los_alarm;
++extern char *mp_eoc_vendor_id;
++extern int mp_eoc_vendor_revision;
++extern char *mp_eoc_vendor_serialnum;
++extern char *mp_invntry_vernum;
++extern int mp_dsl_bit_tmode;
++extern int mp_high_precision;
++
+ int testflag1 = 0;
+ extern int __guDbgLevel;
+ extern sar_stat_t sarStat;
+@@ -2933,24 +2954,24 @@ static int tn7dsl_set_dsl(void)
+ (unsigned char *) &oamFeature, 4);
+
+ ptr = prom_getenv("DSL_FEATURE_CNTL_0");
+- if(!ptr)
+- prom_setenv("DSL_FEATURE_CNTL_0", "0x00004000");
++ //if(!ptr)
++ //prom_setenv("DSL_FEATURE_CNTL_0", "0x00004000");
+
+ ptr = prom_getenv("DSL_FEATURE_CNTL_1");
+- if(!ptr)
+- prom_setenv("DSL_FEATURE_CNTL_1", "0x00000000");
++ //if(!ptr)
++ //prom_setenv("DSL_FEATURE_CNTL_1", "0x00000000");
+
+ ptr = prom_getenv("DSL_PHY_CNTL_0");
+- if(!ptr)
+- prom_setenv("DSL_PHY_CNTL_0", "0x00000400");
++ //if(!ptr)
++ //prom_setenv("DSL_PHY_CNTL_0", "0x00000400");
+
+ ptr = prom_getenv("enable_margin_retrain");
+- if(!ptr)
+- prom_setenv("enable_margin_retrain", "0");
++ //if(!ptr)
++ //prom_setenv("enable_margin_retrain", "0");
+
+ ptr = prom_getenv("modulation");
+- if(!ptr)
+- prom_setenv("modulation", "0xbf");
++ //if(!ptr)
++ //prom_setenv("modulation", "0xbf");
+
+ #define EOC_VENDOR_ID "4200534153000000"
+ #define EOC_VENDOR_REVISION "FW370090708b1_55"
+@@ -2959,25 +2980,25 @@ static int tn7dsl_set_dsl(void)
+ ptr = prom_getenv("eoc_vendor_id");
+ if(!ptr || strcmp(ptr,EOC_VENDOR_ID) != 0 || strlen(ptr) != strlen(EOC_VENDOR_ID))
+ {
+- if(ptr)
+- prom_unsetenv("eoc_vendor_id");
+- prom_setenv("eoc_vendor_id",EOC_VENDOR_ID);
++ //if(ptr)
++ //prom_unsetenv("eoc_vendor_id");
++ //prom_setenv("eoc_vendor_id",EOC_VENDOR_ID);
+ }
+
+ ptr = prom_getenv("eoc_vendor_revision");
+ if(!ptr || strcmp(ptr,EOC_VENDOR_REVISION) != 0 || strlen(ptr) != strlen(EOC_VENDOR_REVISION))
+ {
+- if(ptr)
+- prom_unsetenv("eoc_vendor_revision");
+- prom_setenv("eoc_vendor_revision",EOC_VENDOR_REVISION);
++ //if(ptr)
++ //prom_unsetenv("eoc_vendor_revision");
++ //prom_setenv("eoc_vendor_revision",EOC_VENDOR_REVISION);
+ }
+
+ ptr = prom_getenv("eoc_vendor_serialnum");
+ if(!ptr || strcmp(ptr,EOC_VENDOR_SERIALNUM) != 0 || strlen(ptr) != strlen(EOC_VENDOR_SERIALNUM))
+ {
+- if(ptr)
+- prom_unsetenv("eoc_vendor_serialnum");
+- prom_setenv("eoc_vendor_serialnum",EOC_VENDOR_SERIALNUM);
++ //if(ptr)
++ // prom_unsetenv("eoc_vendor_serialnum");
++ //prom_setenv("eoc_vendor_serialnum",EOC_VENDOR_SERIALNUM);
+ }
+
+ /* Do only if we are in the new Base PSP 7.4.*/
+@@ -2994,92 +3015,88 @@ static int tn7dsl_set_dsl(void)
+ we clear the modulation environment variable, as this could potentially
+ not have the same meaning in the new mode.
+ */
+- prom_unsetenv("modulation");
+- prom_setenv("DSL_UPG_DONE", "1");
++ //prom_unsetenv("modulation");
++ //prom_setenv("DSL_UPG_DONE", "1");
+ }
+ }
+ #endif
+
+ // modulation
+ ptr = prom_getenv("modulation");
+- if (ptr)
++ if (ptr || mp_modulation != NULL)
+ {
+- tn7dsl_set_modulation(ptr, FALSE);
++ tn7dsl_set_modulation(mp_modulation == NULL ? ptr : mp_modulation, FALSE);
+ }
+
+ // Fine Gains
+ ptr = prom_getenv("fine_gain_control");
+- if (ptr)
++ if (ptr || mp_fine_gain_control != -1)
+ {
+- value = os_atoi(ptr);
++ value = mp_fine_gain_control == -1 ? os_atoi(ptr) : mp_fine_gain_control;
+ tn7dsl_ctrl_fineGain(value);
+ }
+ ptr = NULL;
+ ptr = prom_getenv("fine_gain_value");
+- if(ptr)
+- tn7dsl_set_fineGainValue(os_atoh(ptr));
++ if(ptr || mp_fine_gain_value != -1)
++ tn7dsl_set_fineGainValue(mp_fine_gain_value == -1 ? os_atoh(ptr) : mp_fine_gain_value);
+
+ // margin retrain
+ ptr = NULL;
+ ptr = prom_getenv("enable_margin_retrain");
+- if(ptr)
++ value = mp_enable_margin_retrain == -1 ? (ptr ? os_atoi(ptr) : 0) : mp_enable_margin_retrain;
++
++ if (value == 1)
+ {
+- value = os_atoi(ptr);
+- if(value == 1)
++ dslhal_api_setMarginMonitorFlags(pIhw, 0, 1);
++ bMarginRetrainEnable = 1;
++ //printk("enable showtime margin monitor.\n");
++
++ ptr = NULL;
++ ptr = prom_getenv("margin_threshold");
++ value = mp_margin_threshold == -1 ? (ptr ? os_atoi(ptr) : 0) : mp_margin_threshold;
++
++ if(value >= 0)
+ {
+- dslhal_api_setMarginMonitorFlags(pIhw, 0, 1);
+- bMarginRetrainEnable = 1;
+- //printk("enable showtime margin monitor.\n");
+- ptr = NULL;
+- ptr = prom_getenv("margin_threshold");
+- if(ptr)
+- {
+- value = os_atoi(ptr);
+- //printk("Set margin threshold to %d x 0.5 db\n",value);
+- if(value >= 0)
+- {
+- dslhal_api_setMarginThreshold(pIhw, value);
+- bMarginThConfig=1;
+- }
+- }
++ dslhal_api_setMarginThreshold(pIhw, value);
++ bMarginThConfig=1;
+ }
+ }
+
+ // rate adapt
+ ptr = NULL;
+ ptr = prom_getenv("enable_rate_adapt");
+- if(ptr)
++ if(ptr || mp_enable_rate_adapt != -1)
+ {
+- dslhal_api_setRateAdaptFlag(pIhw, os_atoi(ptr));
++ dslhal_api_setRateAdaptFlag(pIhw, mp_enable_rate_adapt == -1 ? os_atoi(ptr) : mp_enable_rate_adapt);
+ }
+
+ // set powercutback
+ ptr = NULL;
+ ptr = prom_getenv("powercutback");
+- if(ptr)
++ if(ptr || mp_powercutback != -1)
+ {
+- dslhal_advcfg_onOffPcb(pIhw, os_atoi(ptr));
++ dslhal_advcfg_onOffPcb(pIhw, mp_powercutback == -1 ? os_atoi(ptr) : mp_powercutback);
+ }
+
+ // trellis
+ ptr = NULL;
+ ptr = prom_getenv("trellis");
+- if(ptr)
++ if(ptr || mp_trellis != -1)
+ {
+- dslhal_api_setTrellisFlag(pIhw, os_atoi(ptr));
+- trellis = os_atoi(ptr);
++ trellis = mp_trellis == -1 ? os_atoi(ptr) : mp_trellis;
++ dslhal_api_setTrellisFlag(pIhw, trellis);
+ //printk("trellis=%d\n");
+ }
+
+ // bitswap
+ ptr = NULL;
+ ptr = prom_getenv("bitswap");
+- if(ptr)
++ if(ptr || mp_bitswap != -1)
+ {
+ int offset[2] = {33, 0};
+ unsigned int bitswap;
+
+- bitswap = os_atoi(ptr);
++ bitswap = mp_bitswap == -1 ? os_atoi(ptr) : mp_bitswap;
+
+ tn7dsl_generic_read(2, offset);
+ dslReg &= dslhal_support_byteSwap32(0xFFFFFF00);
+@@ -3097,46 +3114,47 @@ static int tn7dsl_set_dsl(void)
+ // maximum bits per carrier
+ ptr = NULL;
+ ptr = prom_getenv("maximum_bits_per_carrier");
+- if(ptr)
++ if(ptr || mp_maximum_bits_per_carrier != -1)
+ {
+- dslhal_api_setMaxBitsPerCarrierUpstream(pIhw, os_atoi(ptr));
++ dslhal_api_setMaxBitsPerCarrierUpstream(pIhw, mp_maximum_bits_per_carrier == -1 ? os_atoi(ptr) : mp_maximum_bits_per_carrier);
+ }
+
+ // maximum interleave depth
+ ptr = NULL;
+ ptr = prom_getenv("maximum_interleave_depth");
+- if(ptr)
++ if(ptr || mp_maximum_interleave_depth != -1)
+ {
+- dslhal_api_setMaxInterleaverDepth(pIhw, os_atoi(ptr));
++ dslhal_api_setMaxInterleaverDepth(pIhw, mp_maximum_interleave_depth == -1 ? os_atoi(ptr) : mp_maximum_interleave_depth);
+ }
+
+ // inner and outer pairs
+ ptr = NULL;
+ ptr = prom_getenv("pair_selection");
+- if(ptr)
++ if(ptr || mp_pair_selection != -1)
+ {
+- dslhal_api_selectInnerOuterPair(pIhw, os_atoi(ptr));
++ dslhal_api_selectInnerOuterPair(pIhw, mp_pair_selection == -1 ? os_atoi(ptr) : mp_pair_selection);
+ }
+
+ ptr = NULL;
+ ptr = prom_getenv("dgas_polarity");
+- if(ptr)
++ if(ptr || mp_dgas_polarity != -1)
+ {
+ dslhal_api_configureDgaspLpr(pIhw, 1, 1);
+- dslhal_api_configureDgaspLpr(pIhw, 0, os_atoi(ptr));
++ dslhal_api_configureDgaspLpr(pIhw, 0, mp_dgas_polarity == -1 ? os_atoi(ptr) : mp_dgas_polarity);
+ }
+
+ ptr = NULL;
+ ptr = prom_getenv("los_alarm");
+- if(ptr)
++ if(ptr || mp_los_alarm != -1)
+ {
+- dslhal_api_disableLosAlarm(pIhw, os_atoi(ptr));
++ dslhal_api_disableLosAlarm(pIhw, mp_los_alarm == -1 ? os_atoi(ptr) : mp_los_alarm);
+ }
+
+ ptr = NULL;
+ ptr = prom_getenv("eoc_vendor_id");
+- if(ptr)
++ if(ptr || mp_eoc_vendor_id != NULL)
+ {
++ ptr = mp_eoc_vendor_id == NULL ? ptr : mp_eoc_vendor_id;
+ for(i=0;i<8;i++)
+ {
+ tmp[0]=ptr[i*2];
+@@ -3161,26 +3179,26 @@ static int tn7dsl_set_dsl(void)
+ }
+ ptr = NULL;
+ ptr = prom_getenv("eoc_vendor_revision");
+- if(ptr)
++ if(ptr || mp_eoc_vendor_revision != -1)
+ {
+- value = os_atoi(ptr);
++ value = mp_eoc_vendor_revision == -1 ? os_atoi(ptr) : mp_eoc_vendor_revision;
+ //printk("eoc rev=%d\n", os_atoi(ptr));
+ dslhal_api_setEocRevisionNumber(pIhw, (char *)&value);
+
+ }
+ ptr = NULL;
+ ptr = prom_getenv("eoc_vendor_serialnum");
+- if(ptr)
++ if(ptr || mp_eoc_vendor_serialnum != NULL)
+ {
+- dslhal_api_setEocSerialNumber(pIhw, ptr);
++ dslhal_api_setEocSerialNumber(pIhw, mp_eoc_vendor_serialnum == NULL ? ptr : mp_eoc_vendor_serialnum);
+ }
+
+ // CQ10037 Added invntry_vernum environment variable to be able to set version number in ADSL2, ADSL2+ modes.
+ ptr = NULL;
+ ptr = prom_getenv("invntry_vernum");
+- if(ptr)
++ if(ptr || mp_invntry_vernum != NULL)
+ {
+- dslhal_api_setEocRevisionNumber(pIhw, ptr);
++ dslhal_api_setEocRevisionNumber(pIhw, mp_invntry_vernum == NULL ? ptr : mp_invntry_vernum);
+ }
+
+ return 0;
+@@ -3225,7 +3243,7 @@ int tn7dsl_init(void *priv)
+ * backward compatibility.
+ */
+ cp = prom_getenv("DSL_BIT_TMODE");
+- if (cp)
++ if (cp || mp_dsl_bit_tmode != -1)
+ {
+ printk("%s : env var DSL_BIT_TMODE is set\n", __FUNCTION__);
+ /*
+@@ -3254,9 +3272,9 @@ int tn7dsl_init(void *priv)
+
+ // UR8_MERGE_START CQ11054 Jack Zhang
+ cp = prom_getenv("high_precision");
+- if (cp)
++ if (cp || mp_high_precision != -1)
+ {
+- high_precision_selected = os_atoi(cp);
++ high_precision_selected = mp_high_precision == -1 ? os_atoi(cp) : mp_high_precision;
+ }
+ if ( high_precision_selected)
+ {
+--- a/tn7sar.c
++++ b/tn7sar.c
+@@ -76,6 +76,8 @@ typedef void OS_SETUP;
+ #include "tn7atm.h"
+ #include "tn7api.h"
+
++extern int mp_oam_lb_timeout;
++extern int mp_autopvc_enable;
+
+ /* PDSP Firmware files */
+ #include "tnetd7300_sar_firm.h"
+@@ -932,9 +934,9 @@ int tn7sar_setup_oam_channel(Tn7AtmPriva
+ pHalDev = (HAL_DEVICE *)priv->pSarHalDev;
+
+ pauto_pvc = prom_getenv("autopvc_enable");
+- if(pauto_pvc) //CQ10273
++ if(pauto_pvc || mp_autopvc_enable != -1) //CQ10273
+ {
+- auto_pvc =tn7sar_strtoul(pauto_pvc, NULL, 10);
++ auto_pvc = mp_autopvc_enable == -1 ? tn7sar_strtoul(pauto_pvc, NULL, 10) : mp_autopvc_enable;
+ }
+
+ memset(&chInfo, 0xff, sizeof(chInfo));
+@@ -1133,9 +1135,9 @@ int tn7sar_init(struct atm_dev *dev, Tn7
+
+ /* read in oam lb timeout value */
+ pLbTimeout = prom_getenv("oam_lb_timeout");
+- if(pLbTimeout)
++ if(pLbTimeout || mp_oam_lb_timeout != -1)
+ {
+- lbTimeout =tn7sar_strtoul(pLbTimeout, NULL, 10);
++ lbTimeout = mp_oam_lb_timeout == -1 ? tn7sar_strtoul(pLbTimeout, NULL, 10) : mp_oam_lb_timeout;
+ oamLbTimeout = lbTimeout;
+ pHalFunc->Control(pHalDev,"OamLbTimeout", "Set", &lbTimeout);
+ }
diff --git a/package/system/ar7-atm/patches-D7.05.01.00/170-bus_id_removal.patch b/package/system/ar7-atm/patches-D7.05.01.00/170-bus_id_removal.patch
new file mode 100644
index 0000000..6692f40
--- /dev/null
+++ b/package/system/ar7-atm/patches-D7.05.01.00/170-bus_id_removal.patch
@@ -0,0 +1,30 @@
+--- a/tn7dsl.c
++++ b/tn7dsl.c
+@@ -117,6 +117,7 @@
+ #include <linux/vmalloc.h>
+ #include <linux/file.h>
+ #include <linux/firmware.h>
++#include <linux/version.h>
+
+ #include <asm/io.h>
+ #include <asm/ar7/ar7.h>
+@@ -492,7 +493,9 @@ static void avsar_release(struct device
+ }
+
+ static struct device avsar = {
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)
+ .bus_id = "vlynq",
++#endif
+ .release = avsar_release,
+ };
+
+@@ -501,6 +504,9 @@ int shim_osLoadFWImage(unsigned char *pt
+ const struct firmware *fw_entry;
+ size_t size;
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30)
++ dev_set_name(&avsar, "avsar");
++#endif
+ printk("requesting firmware image \"ar0700xx.bin\"\n");
+ if(device_register(&avsar) < 0) {
+ printk(KERN_ERR
diff --git a/package/system/ar7-atm/patches-D7.05.01.00/180-git_headers_include.patch b/package/system/ar7-atm/patches-D7.05.01.00/180-git_headers_include.patch
new file mode 100644
index 0000000..feb6ea8
--- /dev/null
+++ b/package/system/ar7-atm/patches-D7.05.01.00/180-git_headers_include.patch
@@ -0,0 +1,54 @@
+--- a/tn7atm.c
++++ b/tn7atm.c
+@@ -76,10 +76,16 @@
+ #include <linux/proc_fs.h>
+ #include <linux/string.h>
+ #include <linux/ctype.h>
++#include <linux/version.h>
+
+ #include <asm/io.h>
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)
+ #include <asm/ar7/ar7.h>
+ #include <asm/ar7/prom.h>
++#else
++#include <asm/mach-ar7/ar7.h>
++#include <asm/mach-ar7/prom.h>
++#endif
+
+ #include "dsl_hal_api.h"
+ #ifdef AR7_EFM
+--- a/tn7dsl.c
++++ b/tn7dsl.c
+@@ -120,8 +120,13 @@
+ #include <linux/version.h>
+
+ #include <asm/io.h>
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)
+ #include <asm/ar7/ar7.h>
+ #include <asm/ar7/prom.h>
++#else
++#include <asm/mach-ar7/ar7.h>
++#include <asm/mach-ar7/prom.h>
++#endif
+
+ /* Modules specific header files */
+ #ifdef AR7_EFM
+--- a/tn7sar.c
++++ b/tn7sar.c
+@@ -53,10 +53,16 @@
+ #include <linux/proc_fs.h>
+ #include <linux/string.h>
+ #include <linux/ctype.h>
++#include <linux/version.h>
+
+ #include <asm/io.h>
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)
+ #include <asm/ar7/ar7.h>
+ #include <asm/ar7/prom.h>
++#else
++#include <asm/mach-ar7/ar7.h>
++#include <asm/mach-ar7/prom.h>
++#endif
+
+ #define _CPHAL_AAL5
+ #define _CPHAL_SAR
diff --git a/package/system/ar7-atm/patches-D7.05.01.00/190-2.6.32_proc_fixes.patch b/package/system/ar7-atm/patches-D7.05.01.00/190-2.6.32_proc_fixes.patch
new file mode 100644
index 0000000..52ebbc1
--- /dev/null
+++ b/package/system/ar7-atm/patches-D7.05.01.00/190-2.6.32_proc_fixes.patch
@@ -0,0 +1,79 @@
+--- a/tn7dsl.c
++++ b/tn7dsl.c
+@@ -215,7 +215,11 @@ led_reg_t ledreg[2];
+ static struct led_funcs ledreg[2];
+ #endif
+
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
+ #define DEV_DSLMOD CTL_UNNUMBERED
++#else
++#define DEV_DSLMOD 0
++#endif
+ #define MAX_STR_SIZE 256
+ #define DSL_MOD_SIZE 256
+
+@@ -3615,9 +3619,16 @@ static int dslmod_sysctl(ctl_table *ctl,
+ */
+ if(write)
+ {
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)
+ ret = proc_dostring(ctl, write, filp, buffer, lenp, 0);
+-
++#else
++ ret = proc_dostring(ctl, write, buffer, lenp, 0);
++#endif
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
+ switch (ctl->ctl_name)
++#else
++ switch ((long)ctl->extra2)
++#endif
+ {
+ case DEV_DSLMOD:
+ ptr = strpbrk(info, " \t");
+@@ -3701,14 +3712,29 @@ static int dslmod_sysctl(ctl_table *ctl,
+ else
+ {
+ len += sprintf(info+len, mod_req);
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)
+ ret = proc_dostring(ctl, write, filp, buffer, lenp, 0);
++#else
++ ret = proc_dostring(ctl, write, buffer, lenp, 0);
++#endif
+ }
+ return ret;
+ }
+
+
+ ctl_table dslmod_table[] = {
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
+ {DEV_DSLMOD, "dslmod", info, DSL_MOD_SIZE, 0644, NULL, NULL, &dslmod_sysctl, &sysctl_string}
++#else
++ {
++ .procname = "dslmod",
++ .data = info,
++ .maxlen = DSL_MOD_SIZE,
++ .mode = 0644,
++ .proc_handler = &dslmod_sysctl,
++ .extra2 = (void *)DEV_DSLMOD,
++ }
++#endif
+ ,
+ {0}
+ };
+@@ -3716,7 +3742,16 @@ ctl_table dslmod_table[] = {
+ /* Make sure that /proc/sys/dev is there */
+ ctl_table dslmod_root_table[] = {
+ #ifdef CONFIG_PROC_FS
++ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
+ {CTL_DEV, "dev", NULL, 0, 0555, dslmod_table}
++ #else
++ {
++ .procname = "dev",
++ .maxlen = 0,
++ .mode = 0555,
++ .child = dslmod_table,
++ }
++ #endif
+ ,
+ #endif /* CONFIG_PROC_FS */
+ {0}
diff --git a/package/system/ar7-atm/patches-D7.05.01.00/200-2.6.37_args.patch b/package/system/ar7-atm/patches-D7.05.01.00/200-2.6.37_args.patch
new file mode 100644
index 0000000..a3bff1b
--- /dev/null
+++ b/package/system/ar7-atm/patches-D7.05.01.00/200-2.6.37_args.patch
@@ -0,0 +1,36 @@
+--- a/tn7atm.c
++++ b/tn7atm.c
+@@ -2000,7 +2000,11 @@ static int __init tn7atm_register (Tn7At
+
+ dgprintf (4, "device %s being registered\n", priv->name);
+
++ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37)
+ mydev = atm_dev_register (priv->proc_name, &tn7atm_ops, -1, NULL);
++ #else
++ mydev = atm_dev_register (priv->proc_name, NULL, &tn7atm_ops, -1, NULL);
++ #endif
+
+ if (mydev == NULL)
+ {
+--- a/tn7dsl.c
++++ b/tn7dsl.c
+@@ -512,14 +512,17 @@ int shim_osLoadFWImage(unsigned char *pt
+ {
+ const struct firmware *fw_entry;
+ size_t size;
++ int ret;
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30)
+ dev_set_name(&avsar, "avsar");
+ #endif
+ printk("requesting firmware image \"ar0700xx.bin\"\n");
+- if(device_register(&avsar) < 0) {
++ dev_set_name(&avsar, "avsar");
++ ret = device_register(&avsar);
++ if (ret < 0) {
+ printk(KERN_ERR
+- "avsar: device_register fails\n");
++ "avsar: device_register fails, error%i\n", ret);
+ return -1;
+ }
+
diff --git a/package/system/ar7-atm/patches-D7.05.01.00/210-3.3-remove-smp_lock.h.patch b/package/system/ar7-atm/patches-D7.05.01.00/210-3.3-remove-smp_lock.h.patch
new file mode 100644
index 0000000..975ebaf
--- /dev/null
+++ b/package/system/ar7-atm/patches-D7.05.01.00/210-3.3-remove-smp_lock.h.patch
@@ -0,0 +1,33 @@
+--- a/tn7atm.c
++++ b/tn7atm.c
+@@ -72,7 +72,7 @@
+ #include <linux/atmdev.h>
+ #include <linux/delay.h>
+ #include <linux/spinlock.h>
+-#include <linux/smp_lock.h>
++#include <linux/interrupt.h>
+ #include <linux/proc_fs.h>
+ #include <linux/string.h>
+ #include <linux/ctype.h>
+--- a/tn7sar.c
++++ b/tn7sar.c
+@@ -49,7 +49,7 @@
+ #include <linux/atmdev.h>
+ #include <linux/delay.h>
+ #include <linux/spinlock.h>
+-#include <linux/smp_lock.h>
++#include <linux/interrupt.h>
+ #include <linux/proc_fs.h>
+ #include <linux/string.h>
+ #include <linux/ctype.h>
+--- a/tn7dsl.c
++++ b/tn7dsl.c
+@@ -108,7 +108,7 @@
+ #include <linux/atmdev.h>
+ #include <linux/delay.h>
+ #include <linux/spinlock.h>
+-#include <linux/smp_lock.h>
++#include <linux/interrupt.h>
+ #include <linux/proc_fs.h>
+ #include <linux/string.h>
+ #include <linux/ctype.h>
diff --git a/package/system/avila-wdt/.svn/entries b/package/system/avila-wdt/.svn/entries
new file mode 100644
index 0000000..ad602bb
--- /dev/null
+++ b/package/system/avila-wdt/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/system/avila-wdt
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+src
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+b4431f6789bc5aee2287a6e490ede176
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+848
+
diff --git a/package/system/avila-wdt/.svn/text-base/Makefile.svn-base b/package/system/avila-wdt/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..5bf6bf4
--- /dev/null
+++ b/package/system/avila-wdt/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,40 @@
+#
+# Copyright (C) 2008 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=avila-wdt
+PKG_RELEASE:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/avila-wdt
+ SUBMENU:=Other modules
+ TITLE:=GPIO hardware watchdog driver for modified Avila boards
+ DEPENDS:=@GPIO_SUPPORT @TARGET_ixp4xx
+ FILES:=$(PKG_BUILD_DIR)/avila-wdt.ko
+ AUTOLOAD:=$(call AutoLoad,10,avila-wdt)
+endef
+
+MAKE_OPTS:= \
+ ARCH="$(LINUX_KARCH)" \
+ CROSS_COMPILE="$(TARGET_CROSS)" \
+ SUBDIRS="$(PKG_BUILD_DIR)"
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+define Build/Compile
+ $(MAKE) -C "$(LINUX_DIR)" \
+ $(MAKE_OPTS) \
+ modules
+endef
+
+$(eval $(call KernelPackage,avila-wdt))
diff --git a/package/system/avila-wdt/Makefile b/package/system/avila-wdt/Makefile
new file mode 100644
index 0000000..5bf6bf4
--- /dev/null
+++ b/package/system/avila-wdt/Makefile
@@ -0,0 +1,40 @@
+#
+# Copyright (C) 2008 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=avila-wdt
+PKG_RELEASE:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/avila-wdt
+ SUBMENU:=Other modules
+ TITLE:=GPIO hardware watchdog driver for modified Avila boards
+ DEPENDS:=@GPIO_SUPPORT @TARGET_ixp4xx
+ FILES:=$(PKG_BUILD_DIR)/avila-wdt.ko
+ AUTOLOAD:=$(call AutoLoad,10,avila-wdt)
+endef
+
+MAKE_OPTS:= \
+ ARCH="$(LINUX_KARCH)" \
+ CROSS_COMPILE="$(TARGET_CROSS)" \
+ SUBDIRS="$(PKG_BUILD_DIR)"
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+define Build/Compile
+ $(MAKE) -C "$(LINUX_DIR)" \
+ $(MAKE_OPTS) \
+ modules
+endef
+
+$(eval $(call KernelPackage,avila-wdt))
diff --git a/package/system/avila-wdt/src/.svn/entries b/package/system/avila-wdt/src/.svn/entries
new file mode 100644
index 0000000..b896c26
--- /dev/null
+++ b/package/system/avila-wdt/src/.svn/entries
@@ -0,0 +1,96 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/system/avila-wdt/src
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+avila-wdt.c
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+d6bb3a5d2fef782fd2693b5d38709996
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5144
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+794d0d6b88b314f753a0f533a4696e4a
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+21
+
diff --git a/package/system/avila-wdt/src/.svn/text-base/Makefile.svn-base b/package/system/avila-wdt/src/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..90d9065
--- /dev/null
+++ b/package/system/avila-wdt/src/.svn/text-base/Makefile.svn-base
@@ -0,0 +1 @@
+obj-m := avila-wdt.o
diff --git a/package/system/avila-wdt/src/.svn/text-base/avila-wdt.c.svn-base b/package/system/avila-wdt/src/.svn/text-base/avila-wdt.c.svn-base
new file mode 100644
index 0000000..981f385
--- /dev/null
+++ b/package/system/avila-wdt/src/.svn/text-base/avila-wdt.c.svn-base
@@ -0,0 +1,231 @@
+/*
+ * avila-wdt.c
+ * Copyright (C) 2009 Felix Fietkau <nbd@openwrt.org>
+ *
+ * based on:
+ * drivers/char/watchdog/ixp4xx_wdt.c
+ *
+ * Watchdog driver for Intel IXP4xx network processors
+ *
+ * Author: Deepak Saxena <dsaxena@plexity.net>
+ *
+ * Copyright 2004 (c) MontaVista, Software, Inc.
+ * Based on sa1100 driver, Copyright (C) 2000 Oleg Drokin <green@crimea.edu>
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2. This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/jiffies.h>
+#include <linux/timer.h>
+#include <linux/fs.h>
+#include <linux/miscdevice.h>
+#include <linux/watchdog.h>
+#include <linux/init.h>
+#include <linux/bitops.h>
+#include <linux/uaccess.h>
+#include <mach/hardware.h>
+
+static int nowayout = WATCHDOG_NOWAYOUT;
+static int heartbeat = 20; /* (secs) Default is 20 seconds */
+static unsigned long wdt_status;
+static atomic_t wdt_counter;
+struct timer_list wdt_timer;
+
+#define WDT_IN_USE 0
+#define WDT_OK_TO_CLOSE 1
+#define WDT_RUNNING 2
+
+static void wdt_refresh(unsigned long data)
+{
+ if (test_bit(WDT_RUNNING, &wdt_status)) {
+ if (atomic_dec_and_test(&wdt_counter)) {
+ printk(KERN_WARNING "Avila watchdog expired, expect a reboot soon!\n");
+ clear_bit(WDT_RUNNING, &wdt_status);
+ return;
+ }
+ }
+
+ /* strobe to the watchdog */
+ gpio_line_set(14, IXP4XX_GPIO_HIGH);
+ gpio_line_set(14, IXP4XX_GPIO_LOW);
+
+ mod_timer(&wdt_timer, jiffies + msecs_to_jiffies(500));
+}
+
+static void wdt_enable(void)
+{
+ atomic_set(&wdt_counter, heartbeat * 2);
+
+ /* Disable clock generator output on GPIO 14/15 */
+ *IXP4XX_GPIO_GPCLKR &= ~(1 << 8);
+
+ /* activate GPIO 14 out */
+ gpio_line_config(14, IXP4XX_GPIO_OUT);
+ gpio_line_set(14, IXP4XX_GPIO_LOW);
+
+ if (!test_bit(WDT_RUNNING, &wdt_status))
+ wdt_refresh(0);
+ set_bit(WDT_RUNNING, &wdt_status);
+}
+
+static void wdt_disable(void)
+{
+ /* Re-enable clock generator output on GPIO 14/15 */
+ *IXP4XX_GPIO_GPCLKR |= (1 << 8);
+}
+
+static int avila_wdt_open(struct inode *inode, struct file *file)
+{
+ if (test_and_set_bit(WDT_IN_USE, &wdt_status))
+ return -EBUSY;
+
+ clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
+ wdt_enable();
+ return nonseekable_open(inode, file);
+}
+
+static ssize_t
+avila_wdt_write(struct file *file, const char *data, size_t len, loff_t *ppos)
+{
+ if (len) {
+ if (!nowayout) {
+ size_t i;
+
+ clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
+
+ for (i = 0; i != len; i++) {
+ char c;
+
+ if (get_user(c, data + i))
+ return -EFAULT;
+ if (c == 'V')
+ set_bit(WDT_OK_TO_CLOSE, &wdt_status);
+ }
+ }
+ wdt_enable();
+ }
+ return len;
+}
+
+static struct watchdog_info ident = {
+ .options = WDIOF_CARDRESET | WDIOF_MAGICCLOSE |
+ WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING,
+ .identity = "Avila Watchdog",
+};
+
+
+static long avila_wdt_ioctl(struct file *file, unsigned int cmd,
+ unsigned long arg)
+{
+ int ret = -ENOTTY;
+ int time;
+
+ switch (cmd) {
+ case WDIOC_GETSUPPORT:
+ ret = copy_to_user((struct watchdog_info *)arg, &ident,
+ sizeof(ident)) ? -EFAULT : 0;
+ break;
+
+ case WDIOC_GETSTATUS:
+ ret = put_user(0, (int *)arg);
+ break;
+
+ case WDIOC_KEEPALIVE:
+ wdt_enable();
+ ret = 0;
+ break;
+
+ case WDIOC_SETTIMEOUT:
+ ret = get_user(time, (int *)arg);
+ if (ret)
+ break;
+
+ if (time <= 0 || time > 60) {
+ ret = -EINVAL;
+ break;
+ }
+
+ heartbeat = time;
+ wdt_enable();
+ /* Fall through */
+
+ case WDIOC_GETTIMEOUT:
+ ret = put_user(heartbeat, (int *)arg);
+ break;
+ }
+ return ret;
+}
+
+static int avila_wdt_release(struct inode *inode, struct file *file)
+{
+ if (test_bit(WDT_OK_TO_CLOSE, &wdt_status))
+ wdt_disable();
+ else
+ printk(KERN_CRIT "WATCHDOG: Device closed unexpectedly - "
+ "timer will not stop\n");
+ clear_bit(WDT_IN_USE, &wdt_status);
+ clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
+
+ return 0;
+}
+
+
+static const struct file_operations avila_wdt_fops = {
+ .owner = THIS_MODULE,
+ .llseek = no_llseek,
+ .write = avila_wdt_write,
+ .unlocked_ioctl = avila_wdt_ioctl,
+ .open = avila_wdt_open,
+ .release = avila_wdt_release,
+};
+
+static struct miscdevice avila_wdt_miscdev = {
+ .minor = WATCHDOG_MINOR + 1,
+ .name = "avila_watchdog",
+ .fops = &avila_wdt_fops,
+};
+
+static int __init avila_wdt_init(void)
+{
+ int ret;
+
+ init_timer(&wdt_timer);
+ wdt_timer.expires = 0;
+ wdt_timer.data = 0;
+ wdt_timer.function = wdt_refresh;
+ ret = misc_register(&avila_wdt_miscdev);
+ if (ret == 0)
+ printk(KERN_INFO "Avila Watchdog Timer: heartbeat %d sec\n",
+ heartbeat);
+ return ret;
+}
+
+static void __exit avila_wdt_exit(void)
+{
+ misc_deregister(&avila_wdt_miscdev);
+ del_timer(&wdt_timer);
+ wdt_disable();
+}
+
+
+module_init(avila_wdt_init);
+module_exit(avila_wdt_exit);
+
+MODULE_AUTHOR("Felix Fietkau <nbd@openwrt.org>");
+MODULE_DESCRIPTION("Gateworks Avila Hardware Watchdog");
+
+module_param(heartbeat, int, 0);
+MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds (default 20s)");
+
+module_param(nowayout, int, 0);
+MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started");
+
+MODULE_LICENSE("GPL");
+MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
+
diff --git a/package/system/avila-wdt/src/Makefile b/package/system/avila-wdt/src/Makefile
new file mode 100644
index 0000000..90d9065
--- /dev/null
+++ b/package/system/avila-wdt/src/Makefile
@@ -0,0 +1 @@
+obj-m := avila-wdt.o
diff --git a/package/system/avila-wdt/src/avila-wdt.c b/package/system/avila-wdt/src/avila-wdt.c
new file mode 100644
index 0000000..981f385
--- /dev/null
+++ b/package/system/avila-wdt/src/avila-wdt.c
@@ -0,0 +1,231 @@
+/*
+ * avila-wdt.c
+ * Copyright (C) 2009 Felix Fietkau <nbd@openwrt.org>
+ *
+ * based on:
+ * drivers/char/watchdog/ixp4xx_wdt.c
+ *
+ * Watchdog driver for Intel IXP4xx network processors
+ *
+ * Author: Deepak Saxena <dsaxena@plexity.net>
+ *
+ * Copyright 2004 (c) MontaVista, Software, Inc.
+ * Based on sa1100 driver, Copyright (C) 2000 Oleg Drokin <green@crimea.edu>
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2. This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/jiffies.h>
+#include <linux/timer.h>
+#include <linux/fs.h>
+#include <linux/miscdevice.h>
+#include <linux/watchdog.h>
+#include <linux/init.h>
+#include <linux/bitops.h>
+#include <linux/uaccess.h>
+#include <mach/hardware.h>
+
+static int nowayout = WATCHDOG_NOWAYOUT;
+static int heartbeat = 20; /* (secs) Default is 20 seconds */
+static unsigned long wdt_status;
+static atomic_t wdt_counter;
+struct timer_list wdt_timer;
+
+#define WDT_IN_USE 0
+#define WDT_OK_TO_CLOSE 1
+#define WDT_RUNNING 2
+
+static void wdt_refresh(unsigned long data)
+{
+ if (test_bit(WDT_RUNNING, &wdt_status)) {
+ if (atomic_dec_and_test(&wdt_counter)) {
+ printk(KERN_WARNING "Avila watchdog expired, expect a reboot soon!\n");
+ clear_bit(WDT_RUNNING, &wdt_status);
+ return;
+ }
+ }
+
+ /* strobe to the watchdog */
+ gpio_line_set(14, IXP4XX_GPIO_HIGH);
+ gpio_line_set(14, IXP4XX_GPIO_LOW);
+
+ mod_timer(&wdt_timer, jiffies + msecs_to_jiffies(500));
+}
+
+static void wdt_enable(void)
+{
+ atomic_set(&wdt_counter, heartbeat * 2);
+
+ /* Disable clock generator output on GPIO 14/15 */
+ *IXP4XX_GPIO_GPCLKR &= ~(1 << 8);
+
+ /* activate GPIO 14 out */
+ gpio_line_config(14, IXP4XX_GPIO_OUT);
+ gpio_line_set(14, IXP4XX_GPIO_LOW);
+
+ if (!test_bit(WDT_RUNNING, &wdt_status))
+ wdt_refresh(0);
+ set_bit(WDT_RUNNING, &wdt_status);
+}
+
+static void wdt_disable(void)
+{
+ /* Re-enable clock generator output on GPIO 14/15 */
+ *IXP4XX_GPIO_GPCLKR |= (1 << 8);
+}
+
+static int avila_wdt_open(struct inode *inode, struct file *file)
+{
+ if (test_and_set_bit(WDT_IN_USE, &wdt_status))
+ return -EBUSY;
+
+ clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
+ wdt_enable();
+ return nonseekable_open(inode, file);
+}
+
+static ssize_t
+avila_wdt_write(struct file *file, const char *data, size_t len, loff_t *ppos)
+{
+ if (len) {
+ if (!nowayout) {
+ size_t i;
+
+ clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
+
+ for (i = 0; i != len; i++) {
+ char c;
+
+ if (get_user(c, data + i))
+ return -EFAULT;
+ if (c == 'V')
+ set_bit(WDT_OK_TO_CLOSE, &wdt_status);
+ }
+ }
+ wdt_enable();
+ }
+ return len;
+}
+
+static struct watchdog_info ident = {
+ .options = WDIOF_CARDRESET | WDIOF_MAGICCLOSE |
+ WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING,
+ .identity = "Avila Watchdog",
+};
+
+
+static long avila_wdt_ioctl(struct file *file, unsigned int cmd,
+ unsigned long arg)
+{
+ int ret = -ENOTTY;
+ int time;
+
+ switch (cmd) {
+ case WDIOC_GETSUPPORT:
+ ret = copy_to_user((struct watchdog_info *)arg, &ident,
+ sizeof(ident)) ? -EFAULT : 0;
+ break;
+
+ case WDIOC_GETSTATUS:
+ ret = put_user(0, (int *)arg);
+ break;
+
+ case WDIOC_KEEPALIVE:
+ wdt_enable();
+ ret = 0;
+ break;
+
+ case WDIOC_SETTIMEOUT:
+ ret = get_user(time, (int *)arg);
+ if (ret)
+ break;
+
+ if (time <= 0 || time > 60) {
+ ret = -EINVAL;
+ break;
+ }
+
+ heartbeat = time;
+ wdt_enable();
+ /* Fall through */
+
+ case WDIOC_GETTIMEOUT:
+ ret = put_user(heartbeat, (int *)arg);
+ break;
+ }
+ return ret;
+}
+
+static int avila_wdt_release(struct inode *inode, struct file *file)
+{
+ if (test_bit(WDT_OK_TO_CLOSE, &wdt_status))
+ wdt_disable();
+ else
+ printk(KERN_CRIT "WATCHDOG: Device closed unexpectedly - "
+ "timer will not stop\n");
+ clear_bit(WDT_IN_USE, &wdt_status);
+ clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
+
+ return 0;
+}
+
+
+static const struct file_operations avila_wdt_fops = {
+ .owner = THIS_MODULE,
+ .llseek = no_llseek,
+ .write = avila_wdt_write,
+ .unlocked_ioctl = avila_wdt_ioctl,
+ .open = avila_wdt_open,
+ .release = avila_wdt_release,
+};
+
+static struct miscdevice avila_wdt_miscdev = {
+ .minor = WATCHDOG_MINOR + 1,
+ .name = "avila_watchdog",
+ .fops = &avila_wdt_fops,
+};
+
+static int __init avila_wdt_init(void)
+{
+ int ret;
+
+ init_timer(&wdt_timer);
+ wdt_timer.expires = 0;
+ wdt_timer.data = 0;
+ wdt_timer.function = wdt_refresh;
+ ret = misc_register(&avila_wdt_miscdev);
+ if (ret == 0)
+ printk(KERN_INFO "Avila Watchdog Timer: heartbeat %d sec\n",
+ heartbeat);
+ return ret;
+}
+
+static void __exit avila_wdt_exit(void)
+{
+ misc_deregister(&avila_wdt_miscdev);
+ del_timer(&wdt_timer);
+ wdt_disable();
+}
+
+
+module_init(avila_wdt_init);
+module_exit(avila_wdt_exit);
+
+MODULE_AUTHOR("Felix Fietkau <nbd@openwrt.org>");
+MODULE_DESCRIPTION("Gateworks Avila Hardware Watchdog");
+
+module_param(heartbeat, int, 0);
+MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds (default 20s)");
+
+module_param(nowayout, int, 0);
+MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started");
+
+MODULE_LICENSE("GPL");
+MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
+
diff --git a/package/system/brcm2708-gpu-fw/.svn/entries b/package/system/brcm2708-gpu-fw/.svn/entries
new file mode 100644
index 0000000..ef92d11
--- /dev/null
+++ b/package/system/brcm2708-gpu-fw/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/system/brcm2708-gpu-fw
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+c13ad95ba3aa7cd00400acbf77568400
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1104
+
diff --git a/package/system/brcm2708-gpu-fw/.svn/text-base/Makefile.svn-base b/package/system/brcm2708-gpu-fw/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..45c727c
--- /dev/null
+++ b/package/system/brcm2708-gpu-fw/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,46 @@
+#
+# Copyright (C) 2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=brcm2708-gpu-fw
+PKG_REV:=29ce6bcf278e7e79cd8a2b84c6aa9db9864ca91d
+PKG_VERSION:=20120529
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=git://github.com/raspberrypi/firmware.git
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE_VERSION:=$(PKG_REV)
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/brcm2708-gpu-fw
+ SECTION:=boot
+ CATEGORY:=Boot Loaders
+ DEPENDS:=@TARGET_brcm2708
+ TITLE:=brcm2708-gpu-fw
+ DEFAULT:=y if (TARGET_brcm2708)
+endef
+
+define Package/brcm2708-gpu-fw/description
+ GPU and kernel boot firmware for brcm2708.
+endef
+
+define Build/Compile
+endef
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(BUILD_DIR)/brcm2708-gpu-fw-boot
+ $(CP) $(PKG_BUILD_DIR)/boot/* $(BUILD_DIR)/brcm2708-gpu-fw-boot
+endef
+
+$(eval $(call BuildPackage,brcm2708-gpu-fw))
+
diff --git a/package/system/brcm2708-gpu-fw/Makefile b/package/system/brcm2708-gpu-fw/Makefile
new file mode 100644
index 0000000..45c727c
--- /dev/null
+++ b/package/system/brcm2708-gpu-fw/Makefile
@@ -0,0 +1,46 @@
+#
+# Copyright (C) 2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=brcm2708-gpu-fw
+PKG_REV:=29ce6bcf278e7e79cd8a2b84c6aa9db9864ca91d
+PKG_VERSION:=20120529
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=git://github.com/raspberrypi/firmware.git
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE_VERSION:=$(PKG_REV)
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/brcm2708-gpu-fw
+ SECTION:=boot
+ CATEGORY:=Boot Loaders
+ DEPENDS:=@TARGET_brcm2708
+ TITLE:=brcm2708-gpu-fw
+ DEFAULT:=y if (TARGET_brcm2708)
+endef
+
+define Package/brcm2708-gpu-fw/description
+ GPU and kernel boot firmware for brcm2708.
+endef
+
+define Build/Compile
+endef
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(BUILD_DIR)/brcm2708-gpu-fw-boot
+ $(CP) $(PKG_BUILD_DIR)/boot/* $(BUILD_DIR)/brcm2708-gpu-fw-boot
+endef
+
+$(eval $(call BuildPackage,brcm2708-gpu-fw))
+
diff --git a/package/system/button-hotplug/.svn/entries b/package/system/button-hotplug/.svn/entries
new file mode 100644
index 0000000..cc5f3bb
--- /dev/null
+++ b/package/system/button-hotplug/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/system/button-hotplug
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+src
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+873f7ecdc34e7b34261e99d3ddffa866
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1213
+
diff --git a/package/system/button-hotplug/.svn/prop-base/Makefile.svn-base b/package/system/button-hotplug/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/system/button-hotplug/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/system/button-hotplug/.svn/text-base/Makefile.svn-base b/package/system/button-hotplug/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..35ea6d4
--- /dev/null
+++ b/package/system/button-hotplug/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,53 @@
+#
+# Copyright (C) 2008-2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=button-hotplug
+PKG_RELEASE:=3
+
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/button-hotplug
+ SUBMENU:=Other modules
+ TITLE:=Button Hotplug driver
+ FILES:=$(PKG_BUILD_DIR)/button-hotplug.ko
+ AUTOLOAD:=$(call AutoLoad,30,button-hotplug)
+ KCONFIG:=
+endef
+
+define KernelPackage/button-hotplug/description
+ Kernel module to generate button hotplug events
+endef
+
+EXTRA_KCONFIG:= \
+ CONFIG_BUTTON_HOTPLUG=m
+
+EXTRA_CFLAGS:= \
+ $(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=m,%,$(filter %=m,$(EXTRA_KCONFIG)))) \
+ $(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=y,%,$(filter %=y,$(EXTRA_KCONFIG)))) \
+
+MAKE_OPTS:= \
+ ARCH="$(LINUX_KARCH)" \
+ CROSS_COMPILE="$(TARGET_CROSS)" \
+ SUBDIRS="$(PKG_BUILD_DIR)" \
+ EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \
+ $(EXTRA_KCONFIG)
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+define Build/Compile
+ $(MAKE) -C "$(LINUX_DIR)" \
+ $(MAKE_OPTS) \
+ modules
+endef
+
+$(eval $(call KernelPackage,button-hotplug))
diff --git a/package/system/button-hotplug/Makefile b/package/system/button-hotplug/Makefile
new file mode 100644
index 0000000..35ea6d4
--- /dev/null
+++ b/package/system/button-hotplug/Makefile
@@ -0,0 +1,53 @@
+#
+# Copyright (C) 2008-2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=button-hotplug
+PKG_RELEASE:=3
+
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/button-hotplug
+ SUBMENU:=Other modules
+ TITLE:=Button Hotplug driver
+ FILES:=$(PKG_BUILD_DIR)/button-hotplug.ko
+ AUTOLOAD:=$(call AutoLoad,30,button-hotplug)
+ KCONFIG:=
+endef
+
+define KernelPackage/button-hotplug/description
+ Kernel module to generate button hotplug events
+endef
+
+EXTRA_KCONFIG:= \
+ CONFIG_BUTTON_HOTPLUG=m
+
+EXTRA_CFLAGS:= \
+ $(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=m,%,$(filter %=m,$(EXTRA_KCONFIG)))) \
+ $(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=y,%,$(filter %=y,$(EXTRA_KCONFIG)))) \
+
+MAKE_OPTS:= \
+ ARCH="$(LINUX_KARCH)" \
+ CROSS_COMPILE="$(TARGET_CROSS)" \
+ SUBDIRS="$(PKG_BUILD_DIR)" \
+ EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \
+ $(EXTRA_KCONFIG)
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+define Build/Compile
+ $(MAKE) -C "$(LINUX_DIR)" \
+ $(MAKE_OPTS) \
+ modules
+endef
+
+$(eval $(call KernelPackage,button-hotplug))
diff --git a/package/system/button-hotplug/src/.svn/entries b/package/system/button-hotplug/src/.svn/entries
new file mode 100644
index 0000000..cbc7ee1
--- /dev/null
+++ b/package/system/button-hotplug/src/.svn/entries
@@ -0,0 +1,130 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/system/button-hotplug/src
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+Kconfig
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+7c31ee5038581213b5be95061f80a1aa
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+56
+
+button-hotplug.c
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+f9aeb34897c461a2e94bca8c8bd26cfc
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+7547
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+13b37b3ab63a3e677d3f144aa08178b3
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+48
+
diff --git a/package/system/button-hotplug/src/.svn/prop-base/Makefile.svn-base b/package/system/button-hotplug/src/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/system/button-hotplug/src/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/system/button-hotplug/src/.svn/prop-base/button-hotplug.c.svn-base b/package/system/button-hotplug/src/.svn/prop-base/button-hotplug.c.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/system/button-hotplug/src/.svn/prop-base/button-hotplug.c.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/system/button-hotplug/src/.svn/text-base/Kconfig.svn-base b/package/system/button-hotplug/src/.svn/text-base/Kconfig.svn-base
new file mode 100644
index 0000000..aa292e9
--- /dev/null
+++ b/package/system/button-hotplug/src/.svn/text-base/Kconfig.svn-base
@@ -0,0 +1,2 @@
+config BUTTON_HOTPLUG
+ tristate "Button Hotplug driver"
diff --git a/package/system/button-hotplug/src/.svn/text-base/Makefile.svn-base b/package/system/button-hotplug/src/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..230d604
--- /dev/null
+++ b/package/system/button-hotplug/src/.svn/text-base/Makefile.svn-base
@@ -0,0 +1 @@
+obj-${CONFIG_BUTTON_HOTPLUG} += button-hotplug.o \ No newline at end of file
diff --git a/package/system/button-hotplug/src/.svn/text-base/button-hotplug.c.svn-base b/package/system/button-hotplug/src/.svn/text-base/button-hotplug.c.svn-base
new file mode 100644
index 0000000..4a8c4a8
--- /dev/null
+++ b/package/system/button-hotplug/src/.svn/text-base/button-hotplug.c.svn-base
@@ -0,0 +1,349 @@
+/*
+ * Button Hotplug driver
+ *
+ * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
+ *
+ * Based on the diag.c - GPIO interface driver for Broadcom boards
+ * Copyright (C) 2006 Mike Baker <mbm@openwrt.org>,
+ * Copyright (C) 2006-2007 Felix Fietkau <nbd@openwrt.org>
+ * Copyright (C) 2008 Andy Boyett <agb@openwrt.org>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ */
+
+#include <linux/module.h>
+#include <linux/version.h>
+#include <linux/kmod.h>
+#include <linux/input.h>
+
+#include <linux/workqueue.h>
+#include <linux/skbuff.h>
+#include <linux/netlink.h>
+#include <linux/kobject.h>
+
+#define DRV_NAME "button-hotplug"
+#define DRV_VERSION "0.4.1"
+#define DRV_DESC "Button Hotplug driver"
+
+#define BH_SKB_SIZE 2048
+
+#define PFX DRV_NAME ": "
+
+#undef BH_DEBUG
+
+#ifdef BH_DEBUG
+#define BH_DBG(fmt, args...) printk(KERN_DEBUG "%s: " fmt, DRV_NAME, ##args )
+#else
+#define BH_DBG(fmt, args...) do {} while (0)
+#endif
+
+#define BH_ERR(fmt, args...) printk(KERN_ERR "%s: " fmt, DRV_NAME, ##args )
+
+#ifndef BIT_MASK
+#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG))
+#endif
+
+struct bh_priv {
+ unsigned long *seen;
+ struct input_handle handle;
+};
+
+struct bh_event {
+ const char *name;
+ char *action;
+ unsigned long seen;
+
+ struct sk_buff *skb;
+ struct work_struct work;
+};
+
+struct bh_map {
+ unsigned int code;
+ const char *name;
+};
+
+extern u64 uevent_next_seqnum(void);
+
+#define BH_MAP(_code, _name) \
+ { \
+ .code = (_code), \
+ .name = (_name), \
+ }
+
+static struct bh_map button_map[] = {
+ BH_MAP(BTN_0, "BTN_0"),
+ BH_MAP(BTN_1, "BTN_1"),
+ BH_MAP(BTN_2, "BTN_2"),
+ BH_MAP(BTN_3, "BTN_3"),
+ BH_MAP(BTN_4, "BTN_4"),
+ BH_MAP(BTN_5, "BTN_5"),
+ BH_MAP(BTN_6, "BTN_6"),
+ BH_MAP(BTN_7, "BTN_7"),
+ BH_MAP(BTN_8, "BTN_8"),
+ BH_MAP(BTN_9, "BTN_9"),
+ BH_MAP(KEY_RESTART, "reset"),
+#ifdef KEY_WPS_BUTTON
+ BH_MAP(KEY_WPS_BUTTON, "wps"),
+#endif /* KEY_WPS_BUTTON */
+};
+
+/* -------------------------------------------------------------------------*/
+
+static int bh_event_add_var(struct bh_event *event, int argv,
+ const char *format, ...)
+{
+ static char buf[128];
+ char *s;
+ va_list args;
+ int len;
+
+ if (argv)
+ return 0;
+
+ va_start(args, format);
+ len = vsnprintf(buf, sizeof(buf), format, args);
+ va_end(args);
+
+ if (len >= sizeof(buf)) {
+ BH_ERR("buffer size too small\n");
+ WARN_ON(1);
+ return -ENOMEM;
+ }
+
+ s = skb_put(event->skb, len + 1);
+ strcpy(s, buf);
+
+ BH_DBG("added variable '%s'\n", s);
+
+ return 0;
+}
+
+static int button_hotplug_fill_event(struct bh_event *event)
+{
+ int ret;
+
+ ret = bh_event_add_var(event, 0, "HOME=%s", "/");
+ if (ret)
+ return ret;
+
+ ret = bh_event_add_var(event, 0, "PATH=%s",
+ "/sbin:/bin:/usr/sbin:/usr/bin");
+ if (ret)
+ return ret;
+
+ ret = bh_event_add_var(event, 0, "SUBSYSTEM=%s", "button");
+ if (ret)
+ return ret;
+
+ ret = bh_event_add_var(event, 0, "ACTION=%s", event->action);
+ if (ret)
+ return ret;
+
+ ret = bh_event_add_var(event, 0, "BUTTON=%s", event->name);
+ if (ret)
+ return ret;
+
+ ret = bh_event_add_var(event, 0, "SEEN=%ld", event->seen);
+ if (ret)
+ return ret;
+
+ ret = bh_event_add_var(event, 0, "SEQNUM=%llu", uevent_next_seqnum());
+
+ return ret;
+}
+
+static void button_hotplug_work(struct work_struct *work)
+{
+ struct bh_event *event = container_of(work, struct bh_event, work);
+ int ret = 0;
+
+ event->skb = alloc_skb(BH_SKB_SIZE, GFP_KERNEL);
+ if (!event->skb)
+ goto out_free_event;
+
+ ret = bh_event_add_var(event, 0, "%s@", event->action);
+ if (ret)
+ goto out_free_skb;
+
+ ret = button_hotplug_fill_event(event);
+ if (ret)
+ goto out_free_skb;
+
+ NETLINK_CB(event->skb).dst_group = 1;
+ broadcast_uevent(event->skb, 0, 1, GFP_KERNEL);
+
+ out_free_skb:
+ if (ret) {
+ BH_ERR("work error %d\n", ret);
+ kfree_skb(event->skb);
+ }
+ out_free_event:
+ kfree(event);
+}
+
+static int button_hotplug_create_event(const char *name, unsigned long seen,
+ int pressed)
+{
+ struct bh_event *event;
+
+ BH_DBG("create event, name=%s, seen=%lu, pressed=%d\n",
+ name, seen, pressed);
+
+ event = kzalloc(sizeof(*event), GFP_KERNEL);
+ if (!event)
+ return -ENOMEM;
+
+ event->name = name;
+ event->seen = seen;
+ event->action = pressed ? "pressed" : "released";
+
+ INIT_WORK(&event->work, (void *)(void *)button_hotplug_work);
+ schedule_work(&event->work);
+
+ return 0;
+}
+
+/* -------------------------------------------------------------------------*/
+
+#ifdef CONFIG_HOTPLUG
+static int button_get_index(unsigned int code)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(button_map); i++)
+ if (button_map[i].code == code)
+ return i;
+
+ return -1;
+}
+static void button_hotplug_event(struct input_handle *handle,
+ unsigned int type, unsigned int code, int value)
+{
+ struct bh_priv *priv = handle->private;
+ unsigned long seen = jiffies;
+ int btn;
+
+ BH_DBG("event type=%u, code=%u, value=%d\n", type, code, value);
+
+ if (type != EV_KEY)
+ return;
+
+ btn = button_get_index(code);
+ if (btn < 0)
+ return;
+
+ button_hotplug_create_event(button_map[btn].name,
+ (seen - priv->seen[btn]) / HZ, value);
+ priv->seen[btn] = seen;
+}
+#else
+static void button_hotplug_event(struct input_handle *handle,
+ unsigned int type, unsigned int code, int value)
+{
+}
+#endif /* CONFIG_HOTPLUG */
+
+static int button_hotplug_connect(struct input_handler *handler,
+ struct input_dev *dev, const struct input_device_id *id)
+{
+ struct bh_priv *priv;
+ int ret;
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(button_map); i++)
+ if (test_bit(button_map[i].code, dev->keybit))
+ break;
+
+ if (i == ARRAY_SIZE(button_map))
+ return -ENODEV;
+
+ priv = kzalloc(sizeof(*priv) +
+ (sizeof(unsigned long) * ARRAY_SIZE(button_map)),
+ GFP_KERNEL);
+ if (!priv)
+ return -ENOMEM;
+
+ priv->seen = (unsigned long *) &priv[1];
+ priv->handle.private = priv;
+ priv->handle.dev = dev;
+ priv->handle.handler = handler;
+ priv->handle.name = DRV_NAME;
+
+ ret = input_register_handle(&priv->handle);
+ if (ret)
+ goto err_free_priv;
+
+ ret = input_open_device(&priv->handle);
+ if (ret)
+ goto err_unregister_handle;
+
+ BH_DBG("connected to %s\n", dev->name);
+
+ return 0;
+
+ err_unregister_handle:
+ input_unregister_handle(&priv->handle);
+
+ err_free_priv:
+ kfree(priv);
+ return ret;
+}
+
+static void button_hotplug_disconnect(struct input_handle *handle)
+{
+ struct bh_priv *priv = handle->private;
+
+ input_close_device(handle);
+ input_unregister_handle(handle);
+
+ kfree(priv);
+}
+
+static const struct input_device_id button_hotplug_ids[] = {
+ {
+ .flags = INPUT_DEVICE_ID_MATCH_EVBIT,
+ .evbit = { BIT_MASK(EV_KEY) },
+ },
+ {
+ /* Terminating entry */
+ },
+};
+
+MODULE_DEVICE_TABLE(input, button_hotplug_ids);
+
+static struct input_handler button_hotplug_handler = {
+ .event = button_hotplug_event,
+ .connect = button_hotplug_connect,
+ .disconnect = button_hotplug_disconnect,
+ .name = DRV_NAME,
+ .id_table = button_hotplug_ids,
+};
+
+/* -------------------------------------------------------------------------*/
+
+static int __init button_hotplug_init(void)
+{
+ int ret;
+
+ printk(KERN_INFO DRV_DESC " version " DRV_VERSION "\n");
+ ret = input_register_handler(&button_hotplug_handler);
+ if (ret)
+ BH_ERR("unable to register input handler\n");
+
+ return ret;
+}
+module_init(button_hotplug_init);
+
+static void __exit button_hotplug_exit(void)
+{
+ input_unregister_handler(&button_hotplug_handler);
+}
+module_exit(button_hotplug_exit);
+
+MODULE_DESCRIPTION(DRV_DESC);
+MODULE_VERSION(DRV_VERSION);
+MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
+MODULE_LICENSE("GPL v2");
+
diff --git a/package/system/button-hotplug/src/Kconfig b/package/system/button-hotplug/src/Kconfig
new file mode 100644
index 0000000..aa292e9
--- /dev/null
+++ b/package/system/button-hotplug/src/Kconfig
@@ -0,0 +1,2 @@
+config BUTTON_HOTPLUG
+ tristate "Button Hotplug driver"
diff --git a/package/system/button-hotplug/src/Makefile b/package/system/button-hotplug/src/Makefile
new file mode 100644
index 0000000..230d604
--- /dev/null
+++ b/package/system/button-hotplug/src/Makefile
@@ -0,0 +1 @@
+obj-${CONFIG_BUTTON_HOTPLUG} += button-hotplug.o \ No newline at end of file
diff --git a/package/system/button-hotplug/src/button-hotplug.c b/package/system/button-hotplug/src/button-hotplug.c
new file mode 100644
index 0000000..4a8c4a8
--- /dev/null
+++ b/package/system/button-hotplug/src/button-hotplug.c
@@ -0,0 +1,349 @@
+/*
+ * Button Hotplug driver
+ *
+ * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
+ *
+ * Based on the diag.c - GPIO interface driver for Broadcom boards
+ * Copyright (C) 2006 Mike Baker <mbm@openwrt.org>,
+ * Copyright (C) 2006-2007 Felix Fietkau <nbd@openwrt.org>
+ * Copyright (C) 2008 Andy Boyett <agb@openwrt.org>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ */
+
+#include <linux/module.h>
+#include <linux/version.h>
+#include <linux/kmod.h>
+#include <linux/input.h>
+
+#include <linux/workqueue.h>
+#include <linux/skbuff.h>
+#include <linux/netlink.h>
+#include <linux/kobject.h>
+
+#define DRV_NAME "button-hotplug"
+#define DRV_VERSION "0.4.1"
+#define DRV_DESC "Button Hotplug driver"
+
+#define BH_SKB_SIZE 2048
+
+#define PFX DRV_NAME ": "
+
+#undef BH_DEBUG
+
+#ifdef BH_DEBUG
+#define BH_DBG(fmt, args...) printk(KERN_DEBUG "%s: " fmt, DRV_NAME, ##args )
+#else
+#define BH_DBG(fmt, args...) do {} while (0)
+#endif
+
+#define BH_ERR(fmt, args...) printk(KERN_ERR "%s: " fmt, DRV_NAME, ##args )
+
+#ifndef BIT_MASK
+#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG))
+#endif
+
+struct bh_priv {
+ unsigned long *seen;
+ struct input_handle handle;
+};
+
+struct bh_event {
+ const char *name;
+ char *action;
+ unsigned long seen;
+
+ struct sk_buff *skb;
+ struct work_struct work;
+};
+
+struct bh_map {
+ unsigned int code;
+ const char *name;
+};
+
+extern u64 uevent_next_seqnum(void);
+
+#define BH_MAP(_code, _name) \
+ { \
+ .code = (_code), \
+ .name = (_name), \
+ }
+
+static struct bh_map button_map[] = {
+ BH_MAP(BTN_0, "BTN_0"),
+ BH_MAP(BTN_1, "BTN_1"),
+ BH_MAP(BTN_2, "BTN_2"),
+ BH_MAP(BTN_3, "BTN_3"),
+ BH_MAP(BTN_4, "BTN_4"),
+ BH_MAP(BTN_5, "BTN_5"),
+ BH_MAP(BTN_6, "BTN_6"),
+ BH_MAP(BTN_7, "BTN_7"),
+ BH_MAP(BTN_8, "BTN_8"),
+ BH_MAP(BTN_9, "BTN_9"),
+ BH_MAP(KEY_RESTART, "reset"),
+#ifdef KEY_WPS_BUTTON
+ BH_MAP(KEY_WPS_BUTTON, "wps"),
+#endif /* KEY_WPS_BUTTON */
+};
+
+/* -------------------------------------------------------------------------*/
+
+static int bh_event_add_var(struct bh_event *event, int argv,
+ const char *format, ...)
+{
+ static char buf[128];
+ char *s;
+ va_list args;
+ int len;
+
+ if (argv)
+ return 0;
+
+ va_start(args, format);
+ len = vsnprintf(buf, sizeof(buf), format, args);
+ va_end(args);
+
+ if (len >= sizeof(buf)) {
+ BH_ERR("buffer size too small\n");
+ WARN_ON(1);
+ return -ENOMEM;
+ }
+
+ s = skb_put(event->skb, len + 1);
+ strcpy(s, buf);
+
+ BH_DBG("added variable '%s'\n", s);
+
+ return 0;
+}
+
+static int button_hotplug_fill_event(struct bh_event *event)
+{
+ int ret;
+
+ ret = bh_event_add_var(event, 0, "HOME=%s", "/");
+ if (ret)
+ return ret;
+
+ ret = bh_event_add_var(event, 0, "PATH=%s",
+ "/sbin:/bin:/usr/sbin:/usr/bin");
+ if (ret)
+ return ret;
+
+ ret = bh_event_add_var(event, 0, "SUBSYSTEM=%s", "button");
+ if (ret)
+ return ret;
+
+ ret = bh_event_add_var(event, 0, "ACTION=%s", event->action);
+ if (ret)
+ return ret;
+
+ ret = bh_event_add_var(event, 0, "BUTTON=%s", event->name);
+ if (ret)
+ return ret;
+
+ ret = bh_event_add_var(event, 0, "SEEN=%ld", event->seen);
+ if (ret)
+ return ret;
+
+ ret = bh_event_add_var(event, 0, "SEQNUM=%llu", uevent_next_seqnum());
+
+ return ret;
+}
+
+static void button_hotplug_work(struct work_struct *work)
+{
+ struct bh_event *event = container_of(work, struct bh_event, work);
+ int ret = 0;
+
+ event->skb = alloc_skb(BH_SKB_SIZE, GFP_KERNEL);
+ if (!event->skb)
+ goto out_free_event;
+
+ ret = bh_event_add_var(event, 0, "%s@", event->action);
+ if (ret)
+ goto out_free_skb;
+
+ ret = button_hotplug_fill_event(event);
+ if (ret)
+ goto out_free_skb;
+
+ NETLINK_CB(event->skb).dst_group = 1;
+ broadcast_uevent(event->skb, 0, 1, GFP_KERNEL);
+
+ out_free_skb:
+ if (ret) {
+ BH_ERR("work error %d\n", ret);
+ kfree_skb(event->skb);
+ }
+ out_free_event:
+ kfree(event);
+}
+
+static int button_hotplug_create_event(const char *name, unsigned long seen,
+ int pressed)
+{
+ struct bh_event *event;
+
+ BH_DBG("create event, name=%s, seen=%lu, pressed=%d\n",
+ name, seen, pressed);
+
+ event = kzalloc(sizeof(*event), GFP_KERNEL);
+ if (!event)
+ return -ENOMEM;
+
+ event->name = name;
+ event->seen = seen;
+ event->action = pressed ? "pressed" : "released";
+
+ INIT_WORK(&event->work, (void *)(void *)button_hotplug_work);
+ schedule_work(&event->work);
+
+ return 0;
+}
+
+/* -------------------------------------------------------------------------*/
+
+#ifdef CONFIG_HOTPLUG
+static int button_get_index(unsigned int code)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(button_map); i++)
+ if (button_map[i].code == code)
+ return i;
+
+ return -1;
+}
+static void button_hotplug_event(struct input_handle *handle,
+ unsigned int type, unsigned int code, int value)
+{
+ struct bh_priv *priv = handle->private;
+ unsigned long seen = jiffies;
+ int btn;
+
+ BH_DBG("event type=%u, code=%u, value=%d\n", type, code, value);
+
+ if (type != EV_KEY)
+ return;
+
+ btn = button_get_index(code);
+ if (btn < 0)
+ return;
+
+ button_hotplug_create_event(button_map[btn].name,
+ (seen - priv->seen[btn]) / HZ, value);
+ priv->seen[btn] = seen;
+}
+#else
+static void button_hotplug_event(struct input_handle *handle,
+ unsigned int type, unsigned int code, int value)
+{
+}
+#endif /* CONFIG_HOTPLUG */
+
+static int button_hotplug_connect(struct input_handler *handler,
+ struct input_dev *dev, const struct input_device_id *id)
+{
+ struct bh_priv *priv;
+ int ret;
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(button_map); i++)
+ if (test_bit(button_map[i].code, dev->keybit))
+ break;
+
+ if (i == ARRAY_SIZE(button_map))
+ return -ENODEV;
+
+ priv = kzalloc(sizeof(*priv) +
+ (sizeof(unsigned long) * ARRAY_SIZE(button_map)),
+ GFP_KERNEL);
+ if (!priv)
+ return -ENOMEM;
+
+ priv->seen = (unsigned long *) &priv[1];
+ priv->handle.private = priv;
+ priv->handle.dev = dev;
+ priv->handle.handler = handler;
+ priv->handle.name = DRV_NAME;
+
+ ret = input_register_handle(&priv->handle);
+ if (ret)
+ goto err_free_priv;
+
+ ret = input_open_device(&priv->handle);
+ if (ret)
+ goto err_unregister_handle;
+
+ BH_DBG("connected to %s\n", dev->name);
+
+ return 0;
+
+ err_unregister_handle:
+ input_unregister_handle(&priv->handle);
+
+ err_free_priv:
+ kfree(priv);
+ return ret;
+}
+
+static void button_hotplug_disconnect(struct input_handle *handle)
+{
+ struct bh_priv *priv = handle->private;
+
+ input_close_device(handle);
+ input_unregister_handle(handle);
+
+ kfree(priv);
+}
+
+static const struct input_device_id button_hotplug_ids[] = {
+ {
+ .flags = INPUT_DEVICE_ID_MATCH_EVBIT,
+ .evbit = { BIT_MASK(EV_KEY) },
+ },
+ {
+ /* Terminating entry */
+ },
+};
+
+MODULE_DEVICE_TABLE(input, button_hotplug_ids);
+
+static struct input_handler button_hotplug_handler = {
+ .event = button_hotplug_event,
+ .connect = button_hotplug_connect,
+ .disconnect = button_hotplug_disconnect,
+ .name = DRV_NAME,
+ .id_table = button_hotplug_ids,
+};
+
+/* -------------------------------------------------------------------------*/
+
+static int __init button_hotplug_init(void)
+{
+ int ret;
+
+ printk(KERN_INFO DRV_DESC " version " DRV_VERSION "\n");
+ ret = input_register_handler(&button_hotplug_handler);
+ if (ret)
+ BH_ERR("unable to register input handler\n");
+
+ return ret;
+}
+module_init(button_hotplug_init);
+
+static void __exit button_hotplug_exit(void)
+{
+ input_unregister_handler(&button_hotplug_handler);
+}
+module_exit(button_hotplug_exit);
+
+MODULE_DESCRIPTION(DRV_DESC);
+MODULE_VERSION(DRV_VERSION);
+MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
+MODULE_LICENSE("GPL v2");
+
diff --git a/package/system/ep80579-drivers/.svn/entries b/package/system/ep80579-drivers/.svn/entries
new file mode 100644
index 0000000..f8d9740
--- /dev/null
+++ b/package/system/ep80579-drivers/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/system/ep80579-drivers
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+81c28424dc0eb3666e73976e9be4b65d
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2443
+
diff --git a/package/system/ep80579-drivers/.svn/text-base/Makefile.svn-base b/package/system/ep80579-drivers/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..61d3bc2
--- /dev/null
+++ b/package/system/ep80579-drivers/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,92 @@
+#
+# Copyright (C) 2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=ep80579-drivers
+PKG_VERSION:=1.0.34
+PKG_RELEASE:=1
+
+PKG_SOURCE:=Embedded.L.1.0.34.ADI.R100.tar.gz
+PKG_SOURCE_URL:=ftp://ftp.adiengineering.com/Archive/OcracokeIsland/Drivers/Linux/1.0.34/
+PKG_MD5SUM:=61df9778f8c1f919257d2f48a0bcb000
+
+PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
+
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/ep80579-drivers/Default
+ DEPENDS:=@TARGET_x86_ep80579
+endef
+
+define KernelPackage/ep80579-eth
+$(call KernelPackage/ep80579-drivers/Default)
+ SUBMENU:=Network Devices
+ TITLE:=Intel EP80579 ethernet driver
+ FILES:= \
+ $(PKG_BUILD_DIR)/Embedded/src/GbE/gcu.ko \
+ $(PKG_BUILD_DIR)/Embedded/src/GbE/iegbe.ko
+ AUTOLOAD:=$(call AutoLoad,40,gcu iegbe)
+endef
+
+define KernelPackage/ep80579-misc
+$(call KernelPackage/ep80579-drivers/Default)
+ SUBMENU:=Other modules
+ TITLE:=Misc. Intel EP80579 drivers (DMA,, gpio)
+ FILES:= \
+ $(PKG_BUILD_DIR)/Embedded/src/EDMA/dma.ko \
+ $(PKG_BUILD_DIR)/Embedded/src/GPIO/gpio.ko
+ AUTOLOAD:=$(call AutoLoad,40,gpio dma)
+endef
+
+define KernelPackage/ep80579-can
+$(call KernelPackage/ep80579-drivers/Default)
+ SUBMENU:=Other modules
+ TITLE:=Intel EP80579 CAN driver
+ FILES:= \
+ $(PKG_BUILD_DIR)/Embedded/src/1588/timesync.ko \
+ $(PKG_BUILD_DIR)/Embedded/src/CAN/can.ko
+ AUTOLOAD:=$(call AutoLoad,40,timesync can)
+endef
+
+define Build/Prepare
+ rm -rf $(PKG_BUILD_DIR)
+ mkdir -p $(PKG_BUILD_DIR)
+ tar xzvf $(DL_DIR)/$(PKG_SOURCE) -C $(PKG_BUILD_DIR)/
+ $(Build/Patch)
+endef
+
+define Build/Compile/Subdir
+ $(MAKE) -C "$(LINUX_DIR)" \
+ KSRC="$(LINUX_DIR)" \
+ KOBJ="$(LINUX_DIR)" \
+ ENV_DIR=$(PKG_BUILD_DIR)/Embedded \
+ SUBDIRS="$(PKG_BUILD_DIR)/Embedded/src/$(1)" \
+ CROSS_COMPILE="$(TARGET_CROSS)" \
+ ARCHIVER="$(TARGET_CROSS)ar" \
+ COMPILER="$(TARGET_CC)" \
+ LINKER="$(TARGET_CROSS)ld" \
+ ARCH="$(LINUX_KARCH)"
+endef
+
+define Build/Compile
+ $(call Build/Compile/Subdir,GbE)
+ $(call Build/Compile/Subdir,CAN)
+ $(call Build/Compile/Subdir,EDMA)
+ $(call Build/Compile/Subdir,GPIO)
+ $(call Build/Compile/Subdir,WDT)
+ $(call Build/Compile/Subdir,1588)
+endef
+
+define KernelPackage/ep80579-eth/install
+endef
+
+$(eval $(call KernelPackage,ep80579-can))
+$(eval $(call KernelPackage,ep80579-eth))
+$(eval $(call KernelPackage,ep80579-misc))
+
diff --git a/package/system/ep80579-drivers/Makefile b/package/system/ep80579-drivers/Makefile
new file mode 100644
index 0000000..61d3bc2
--- /dev/null
+++ b/package/system/ep80579-drivers/Makefile
@@ -0,0 +1,92 @@
+#
+# Copyright (C) 2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=ep80579-drivers
+PKG_VERSION:=1.0.34
+PKG_RELEASE:=1
+
+PKG_SOURCE:=Embedded.L.1.0.34.ADI.R100.tar.gz
+PKG_SOURCE_URL:=ftp://ftp.adiengineering.com/Archive/OcracokeIsland/Drivers/Linux/1.0.34/
+PKG_MD5SUM:=61df9778f8c1f919257d2f48a0bcb000
+
+PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
+
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/ep80579-drivers/Default
+ DEPENDS:=@TARGET_x86_ep80579
+endef
+
+define KernelPackage/ep80579-eth
+$(call KernelPackage/ep80579-drivers/Default)
+ SUBMENU:=Network Devices
+ TITLE:=Intel EP80579 ethernet driver
+ FILES:= \
+ $(PKG_BUILD_DIR)/Embedded/src/GbE/gcu.ko \
+ $(PKG_BUILD_DIR)/Embedded/src/GbE/iegbe.ko
+ AUTOLOAD:=$(call AutoLoad,40,gcu iegbe)
+endef
+
+define KernelPackage/ep80579-misc
+$(call KernelPackage/ep80579-drivers/Default)
+ SUBMENU:=Other modules
+ TITLE:=Misc. Intel EP80579 drivers (DMA,, gpio)
+ FILES:= \
+ $(PKG_BUILD_DIR)/Embedded/src/EDMA/dma.ko \
+ $(PKG_BUILD_DIR)/Embedded/src/GPIO/gpio.ko
+ AUTOLOAD:=$(call AutoLoad,40,gpio dma)
+endef
+
+define KernelPackage/ep80579-can
+$(call KernelPackage/ep80579-drivers/Default)
+ SUBMENU:=Other modules
+ TITLE:=Intel EP80579 CAN driver
+ FILES:= \
+ $(PKG_BUILD_DIR)/Embedded/src/1588/timesync.ko \
+ $(PKG_BUILD_DIR)/Embedded/src/CAN/can.ko
+ AUTOLOAD:=$(call AutoLoad,40,timesync can)
+endef
+
+define Build/Prepare
+ rm -rf $(PKG_BUILD_DIR)
+ mkdir -p $(PKG_BUILD_DIR)
+ tar xzvf $(DL_DIR)/$(PKG_SOURCE) -C $(PKG_BUILD_DIR)/
+ $(Build/Patch)
+endef
+
+define Build/Compile/Subdir
+ $(MAKE) -C "$(LINUX_DIR)" \
+ KSRC="$(LINUX_DIR)" \
+ KOBJ="$(LINUX_DIR)" \
+ ENV_DIR=$(PKG_BUILD_DIR)/Embedded \
+ SUBDIRS="$(PKG_BUILD_DIR)/Embedded/src/$(1)" \
+ CROSS_COMPILE="$(TARGET_CROSS)" \
+ ARCHIVER="$(TARGET_CROSS)ar" \
+ COMPILER="$(TARGET_CC)" \
+ LINKER="$(TARGET_CROSS)ld" \
+ ARCH="$(LINUX_KARCH)"
+endef
+
+define Build/Compile
+ $(call Build/Compile/Subdir,GbE)
+ $(call Build/Compile/Subdir,CAN)
+ $(call Build/Compile/Subdir,EDMA)
+ $(call Build/Compile/Subdir,GPIO)
+ $(call Build/Compile/Subdir,WDT)
+ $(call Build/Compile/Subdir,1588)
+endef
+
+define KernelPackage/ep80579-eth/install
+endef
+
+$(eval $(call KernelPackage,ep80579-can))
+$(eval $(call KernelPackage,ep80579-eth))
+$(eval $(call KernelPackage,ep80579-misc))
+
diff --git a/package/system/ep80579-drivers/patches/.svn/entries b/package/system/ep80579-drivers/patches/.svn/entries
new file mode 100644
index 0000000..9ee13b0
--- /dev/null
+++ b/package/system/ep80579-drivers/patches/.svn/entries
@@ -0,0 +1,980 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/system/ep80579-drivers/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+601-2.6.32_includes.patch
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+76d712fc35a51a030564b58385e25b99
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+781
+
+106-iegbe_new_irqf_constant.patch
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+a0aed6adb700a205511dd3ebdd70a956
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+521
+
+210-can_include_linux_fs_h.patch
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+e9222415af4999267d302cf190d694ef
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+263
+
+713-3.3-gpio-fixes.patch
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+ce03bbbaef6282522db09e52fd0b87ea
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1182
+
+150-ocracoke_island.patch
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+bef151d5aaf2af8716a7e5af2884a013
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+21129
+
+714-3.3-wdt-fixes.patch
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+50ffd0d04130c6d2bdf2deb82fe41b73
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1397
+
+712-3.3-can-fixes.patch
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+bab2aebaae8d0dd816c3d19a9158a6e9
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1343
+
+600-2.6.27_includes.patch
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+ae63a5800f0d6497320b0c3b0d7ef0fc
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+688
+
+500-1588_fix_irq_request_warning.patch
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+aa134b633f119ff59ae5784a6cf93c11
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+975
+
+400-edma_fix_irq_request_warning.patch
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+9a370d81b5633ccc5834a8c0b25efe5e
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+874
+
+102-iegbe_nuke_polling_netdev.patch
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+816d22803f2296c4a3929f5d6edf026e
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3167
+
+103-iegbe_convert_unicast_addr_list.patch
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+e0801fbea6d180a81489055843305ed6
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1621
+
+200-can_fix_ioctl_numbers.patch
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+f41e347262d1334d4c4a2daccc87de55
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+370
+
+220-can_fix_irq_request.patch
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+68917abad67a906ff07264af76a5ee9d
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+788
+
+715-3.3-1588-fixes.patch
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+a569bb5602aeb72bd2b49cdf3412a2f7
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1328
+
+100-iegbe_netdev_ops.patch
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+0974aeaa4a5404292dffc468013611a3
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1885
+
+230-can_remove_driver_data_direct_access.patch
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+837db1ad180065c1b083507fa0248583
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1472
+
+104-iegbe_group_address_list_and_its_count.patch
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+c9c7a3841820e017537f826e112867cf
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+610
+
+700-iegbe_kcompat_2.6.30.patch
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+dfc01b24effdbe2ece004ff6dcbe7500
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+677
+
+701-iegbe_poll_dev.patch
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+36ad623e5548765511215a6378ed5279
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+392
+
+002-cflags_cleanup.patch
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+456a94f613532ed07f92f43086dfa631
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+389
+
+001-igbe_update.patch
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+4c849fbf5c3d46d18d531cbb5ed28d58
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+383749
+
+003-new_irqf_constants.patch
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+17f098973dd699d9facd47d7125b83e2
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1855
+
+105-iegbe_new_dma_masks.patch
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+f17922a83b7b02e6da1cf989fd1bae32
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+782
+
+710-3.3-fix-generated-header-locations.patch
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+47a67a78b1e169ccf2f38f5a13649c23
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3270
+
+101-iegbe_fix_napi_interface.patch
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+c3f3a3bbfa893cf17a9750bccb1387e5
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1459
+
+300-wdt_compile_fix.patch
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+294273f54dbe538181df67744700f703
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2487
+
+711-3.3-gbe-fixes.patch
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+dc96fc0d38d3cf7f494184383637d39d
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+12724
+
diff --git a/package/system/ep80579-drivers/patches/.svn/text-base/001-igbe_update.patch.svn-base b/package/system/ep80579-drivers/patches/.svn/text-base/001-igbe_update.patch.svn-base
new file mode 100644
index 0000000..80ca0ef
--- /dev/null
+++ b/package/system/ep80579-drivers/patches/.svn/text-base/001-igbe_update.patch.svn-base
@@ -0,0 +1,11755 @@
+--- a/Embedded/src/GbE/gcu.h
++++ b/Embedded/src/GbE/gcu.h
+@@ -2,7 +2,7 @@
+
+ GPL LICENSE SUMMARY
+
+- Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
++ Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of version 2 of the GNU General Public License as
+@@ -22,7 +22,7 @@ GPL LICENSE SUMMARY
+ Contact Information:
+ Intel Corporation
+
+- version: Embedded.L.1.0.34
++ version: Embedded.Release.Patch.L.1.0.7-5
+
+ Contact Information:
+
+--- a/Embedded/src/GbE/gcu_if.c
++++ b/Embedded/src/GbE/gcu_if.c
+@@ -2,7 +2,7 @@
+
+ GPL LICENSE SUMMARY
+
+- Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
++ Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of version 2 of the GNU General Public License as
+@@ -22,7 +22,7 @@ GPL LICENSE SUMMARY
+ Contact Information:
+ Intel Corporation
+
+- version: Embedded.L.1.0.34
++ version: Embedded.Release.Patch.L.1.0.7-5
+
+ Contact Information:
+
+@@ -330,10 +330,17 @@ gcu_write_verify(uint32_t phy_num, uint3
+ */
+ void gcu_iegbe_resume(struct pci_dev *pdev)
+ {
++#if ( ( LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,6) ) && \
++ ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10) ) )
++ struct net_device *netdev = pci_get_drvdata(pdev);
++ struct gcu_adapter *adapter = netdev_priv(netdev);
++#endif
++
+ GCU_DBG("%s\n", __func__);
+
+ pci_restore_state(pdev);
+- pci_enable_device(pdev);
++ if(!pci_enable_device(pdev))
++ GCU_DBG("pci_enable_device failed!\n",);
+
+ return;
+ }
+@@ -348,6 +355,12 @@ EXPORT_SYMBOL(gcu_iegbe_resume);
+ */
+ int gcu_iegbe_suspend(struct pci_dev *pdev, uint32_t state)
+ {
++#if ( ( LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,6) ) && \
++ ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10) ) )
++ struct net_device *netdev = pci_get_drvdata(pdev);
++ struct gcu_adapter *adapter = netdev_priv(netdev);
++#endif
++
+ GCU_DBG("%s\n", __func__);
+
+ pci_save_state(pdev);
+--- a/Embedded/src/GbE/gcu_if.h
++++ b/Embedded/src/GbE/gcu_if.h
+@@ -2,7 +2,7 @@
+
+ GPL LICENSE SUMMARY
+
+- Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
++ Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of version 2 of the GNU General Public License as
+@@ -22,7 +22,7 @@ GPL LICENSE SUMMARY
+ Contact Information:
+ Intel Corporation
+
+- version: Embedded.L.1.0.34
++ version: Embedded.Release.Patch.L.1.0.7-5
+
+ Contact Information:
+
+--- a/Embedded/src/GbE/gcu_main.c
++++ b/Embedded/src/GbE/gcu_main.c
+@@ -2,7 +2,7 @@
+
+ GPL LICENSE SUMMARY
+
+- Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
++ Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of version 2 of the GNU General Public License as
+@@ -22,7 +22,7 @@ GPL LICENSE SUMMARY
+ Contact Information:
+ Intel Corporation
+
+- version: Embedded.L.1.0.34
++ version: Embedded.Release.Patch.L.1.0.7-5
+
+ Contact Information:
+
+@@ -94,6 +94,7 @@ static struct pci_driver gcu_driver = {
+
+ static struct gcu_adapter *global_adapter = 0;
+ static spinlock_t global_adapter_spinlock = SPIN_LOCK_UNLOCKED;
++static unsigned long g_intflags = 0;
+
+ MODULE_AUTHOR("Intel(R) Corporation");
+ MODULE_DESCRIPTION("Global Configuration Unit Driver");
+@@ -124,7 +125,7 @@ gcu_init_module(void)
+
+ printk(KERN_INFO "%s\n", gcu_copyright);
+
+- ret = pci_module_init(&gcu_driver);
++ ret = pci_register_driver(&gcu_driver);
+ if(ret >= 0) {
+ register_reboot_notifier(&gcu_notifier_reboot);
+ }
+@@ -199,8 +200,6 @@ gcu_probe(struct pci_dev *pdev,
+ return -ENOMEM;
+ }
+
+- SET_MODULE_OWNER(adapter);
+-
+ pci_set_drvdata(pdev, adapter);
+
+ adapter->pdev = pdev;
+@@ -238,7 +237,6 @@ gcu_probe(struct pci_dev *pdev,
+ return 0;
+ }
+
+-
+ /**
+ * gcu_probe_err - gcu_probe error handler
+ * @err: gcu_err_type
+@@ -295,7 +293,7 @@ gcu_notify_reboot(struct notifier_block
+ case SYS_DOWN:
+ case SYS_HALT:
+ case SYS_POWER_OFF:
+- while((pdev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pdev))) {
++ while((pdev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pdev))) {
+ if(pci_dev_driver(pdev) == &gcu_driver){
+ gcu_suspend(pdev, 0x3);
+ }
+@@ -318,6 +316,11 @@ static int
+ gcu_suspend(struct pci_dev *pdev, uint32_t state)
+ {
+ /*struct gcu_adapter *adapter = pci_get_drvdata(pdev); */
++#if ( ( LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,6) ) && \
++ ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10) ) )
++ struct net_device *netdev = pci_get_drvdata(pdev);
++ struct gcu_adapter *adapter = netdev_priv(netdev);
++#endif
+
+ GCU_DBG("%s\n", __func__);
+
+@@ -338,7 +341,6 @@ gcu_suspend(struct pci_dev *pdev, uint32
+ return state;
+ }
+
+-
+ /**
+ * alloc_gcu_adapter
+ *
+@@ -412,7 +414,7 @@ gcu_get_adapter(void)
+ return NULL;
+ }
+
+- spin_lock(&global_adapter_spinlock);
++ spin_lock_irqsave(&global_adapter_spinlock, g_intflags);
+
+ return global_adapter;
+ }
+@@ -437,7 +439,7 @@ gcu_release_adapter(const struct gcu_ada
+ *adapter = 0;
+ }
+
+- spin_unlock(&global_adapter_spinlock);
++ spin_unlock_irqrestore(&global_adapter_spinlock, g_intflags);
+
+ return;
+ }
+--- a/Embedded/src/GbE/gcu_reg.h
++++ b/Embedded/src/GbE/gcu_reg.h
+@@ -2,7 +2,7 @@
+
+ GPL LICENSE SUMMARY
+
+- Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
++ Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of version 2 of the GNU General Public License as
+@@ -22,7 +22,7 @@ GPL LICENSE SUMMARY
+ Contact Information:
+ Intel Corporation
+
+- version: Embedded.L.1.0.34
++ version: Embedded.Release.Patch.L.1.0.7-5
+
+ Contact Information:
+
+--- a/Embedded/src/GbE/iegbe.7
++++ b/Embedded/src/GbE/iegbe.7
+@@ -1,7 +1,7 @@
+
+ .\" GPL LICENSE SUMMARY
+ .\"
+-.\" Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
++.\" Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
+ .\"
+ .\" This program is free software; you can redistribute it and/or modify
+ .\" it under the terms of version 2 of the GNU General Public License as
+@@ -21,7 +21,7 @@
+ .\" Contact Information:
+ .\" Intel Corporation
+ .\"
+-.\" version: Embedded.L.1.0.34
++.\" version: Embedded.Release.Patch.L.1.0.7-5
+
+ .\" LICENSE
+ .\"
+--- a/Embedded/src/GbE/iegbe_ethtool.c
++++ b/Embedded/src/GbE/iegbe_ethtool.c
+@@ -2,7 +2,7 @@
+
+ GPL LICENSE SUMMARY
+
+- Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
++ Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of version 2 of the GNU General Public License as
+@@ -22,7 +22,7 @@ GPL LICENSE SUMMARY
+ Contact Information:
+ Intel Corporation
+
+- version: Embedded.L.1.0.34
++ version: Embedded.Release.Patch.L.1.0.7-5
+
+ Contact Information:
+
+@@ -132,22 +132,6 @@ static const struct iegbe_stats iegbe_gs
+ { "cpp_master", E1000_STAT(icr_cpp_master) },
+ { "stat", E1000_STAT(icr_stat) },
+ #endif
+-#ifdef IEGBE_GBE_WORKAROUND
+- { "txqec", E1000_STAT(stats.txqec) },
+- { "tx_next_to_clean", E1000_STAT(stats.tx_next_to_clean) },
+- { "tx_next_to_use", E1000_STAT(stats.tx_next_to_use) },
+- { "num_tx_queues", E1000_STAT(stats.num_tx_queues) },
+-
+- { "num_rx_buf_alloc", E1000_STAT(stats.num_rx_buf_alloc) },
+- { "rx_next_to_clean", E1000_STAT(stats.rx_next_to_clean) },
+- { "rx_next_to_use", E1000_STAT(stats.rx_next_to_use) },
+- { "cc_gt_num_rx", E1000_STAT(stats.cc_gt_num_rx) },
+- { "tx_hnet", E1000_STAT(stats.tx_hnet) },
+- { "tx_hnentu", E1000_STAT(stats.tx_hnentu) },
+- { "RUC", E1000_STAT(stats.ruc) },
+- { "RFC", E1000_STAT(stats.rfc) },
+-
+-#endif
+ };
+ #define E1000_STATS_LEN \
+ sizeof(iegbe_gstrings_stats) / sizeof(struct iegbe_stats)
+@@ -158,7 +142,7 @@ static const char iegbe_gstrings_test[][
+ "Interrupt test (offline)", "Loopback test (offline)",
+ "Link test (on/offline)"
+ };
+-#define E1000_TEST_LEN (sizeof(iegbe_gstrings_test) / (ETH_GSTRING_LEN))
++#define E1000_TEST_LEN (sizeof(iegbe_gstrings_test) / ETH_GSTRING_LEN)
+ #endif /* ETHTOOL_TEST */
+
+ #define E1000_REGS_LEN 0x20
+@@ -176,9 +160,7 @@ iegbe_get_settings(struct net_device *ne
+ SUPPORTED_10baseT_Full |
+ SUPPORTED_100baseT_Half |
+ SUPPORTED_100baseT_Full |
+-#ifndef IEGBE_10_100_ONLY
+ SUPPORTED_1000baseT_Full|
+-#endif
+ SUPPORTED_Autoneg |
+ SUPPORTED_TP);
+
+@@ -259,21 +241,13 @@ iegbe_set_settings(struct net_device *ne
+ ADVERTISED_10baseT_Full |
+ ADVERTISED_100baseT_Half |
+ ADVERTISED_100baseT_Full |
+-#ifndef IEGBE_10_100_ONLY
+ ADVERTISED_1000baseT_Full|
+-#endif
+-
+ ADVERTISED_Autoneg |
+ ADVERTISED_TP;
+ ecmd->advertising = hw->autoneg_advertised;
+ }
+- } else {
+- uint16_t duplex;
+-
+- // ethtool uses DUPLEX_FULL/DUPLEX_HALF
+- // the driver needs FULL_DUPLEX/HALF_DUPLEX
+- duplex = (ecmd->duplex == DUPLEX_FULL) ? FULL_DUPLEX : HALF_DUPLEX;
+- if(iegbe_set_spd_dplx(adapter, ecmd->speed + duplex))
++ } else
++ if(iegbe_set_spd_dplx(adapter, ecmd->speed + ecmd->duplex)){
+ return -EINVAL;
+ }
+ /* reset the link */
+@@ -728,8 +702,8 @@ iegbe_set_ringparam(struct net_device *n
+ struct iegbe_rx_ring *rxdr, *rx_old, *rx_new;
+ int i, err, tx_ring_size, rx_ring_size;
+
+- tx_ring_size = sizeof(struct iegbe_tx_ring) * adapter->num_queues;
+- rx_ring_size = sizeof(struct iegbe_rx_ring) * adapter->num_queues;
++ tx_ring_size = sizeof(struct iegbe_tx_ring) * adapter->num_tx_queues;
++ rx_ring_size = sizeof(struct iegbe_rx_ring) * adapter->num_rx_queues;
+
+ if (netif_running(adapter->netdev)){
+ iegbe_down(adapter);
+@@ -768,10 +742,10 @@ iegbe_set_ringparam(struct net_device *n
+ E1000_MAX_TXD : E1000_MAX_82544_TXD));
+ E1000_ROUNDUP(txdr->count, REQ_TX_DESCRIPTOR_MULTIPLE);
+
+- for (i = 0; i < adapter->num_queues; i++) {
+- txdr[i].count = txdr->count;
+- rxdr[i].count = rxdr->count;
+- }
++ for (i = 0; i < adapter->num_tx_queues; i++)
++ txdr[i].count = txdr->count;
++ for (i = 0; i < adapter->num_rx_queues; i++)
++ rxdr[i].count = rxdr->count;
+
+ if(netif_running(adapter->netdev)) {
+ /* Try to get new resources before deleting old */
+@@ -950,8 +924,7 @@ iegbe_eeprom_test(struct iegbe_adapter *
+
+ static irqreturn_t
+ iegbe_test_intr(int irq,
+- void *data,
+- struct pt_regs *regs)
++ void *data)
+ {
+ struct net_device *netdev = (struct net_device *) data;
+ struct iegbe_adapter *adapter = netdev_priv(netdev);
+@@ -973,7 +946,7 @@ iegbe_intr_test(struct iegbe_adapter *ad
+ /* Hook up test interrupt handler just for this test */
+ if(!request_irq(irq, &iegbe_test_intr, 0, netdev->name, netdev)) {
+ shared_int = FALSE;
+- } else if(request_irq(irq, &iegbe_test_intr, SA_SHIRQ,
++ } else if(request_irq(irq, &iegbe_test_intr, IRQF_SHARED,
+ netdev->name, netdev)){
+ *data = 1;
+ return -1;
+@@ -1393,7 +1366,7 @@ iegbe_set_phy_loopback(struct iegbe_adap
+ * attempt this 10 times.
+ */
+ while(iegbe_nonintegrated_phy_loopback(adapter) &&
+- count++ < 0xa) { };
++ count++ < 0xa);
+ if(count < 0xb) {
+ return 0;
+ }
+--- a/Embedded/src/GbE/iegbe.h
++++ b/Embedded/src/GbE/iegbe.h
+@@ -1,7 +1,7 @@
+ /*******************************************************************************
+ GPL LICENSE SUMMARY
+
+- Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
++ Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of version 2 of the GNU General Public License as
+@@ -21,7 +21,7 @@ GPL LICENSE SUMMARY
+ Contact Information:
+ Intel Corporation
+
+- version: Embedded.L.1.0.34
++ version: Embedded.Release.Patch.L.1.0.7-5
+
+ Contact Information:
+
+@@ -127,9 +127,12 @@ struct iegbe_adapter;
+ #define E1000_MIN_RXD 80
+ #define E1000_MAX_82544_RXD 4096
+
++#define MAXIMUM_ETHERNET_VLAN_SIZE 1522
+ /* Supported Rx Buffer Sizes */
+ #define E1000_RXBUFFER_128 128 /* Used for packet split */
+ #define E1000_RXBUFFER_256 256 /* Used for packet split */
++#define E1000_RXBUFFER_512 512
++#define E1000_RXBUFFER_1024 1024
+ #define E1000_RXBUFFER_2048 2048
+ #define E1000_RXBUFFER_4096 4096
+ #define E1000_RXBUFFER_8192 8192
+@@ -164,11 +167,9 @@ struct iegbe_adapter;
+ #define E1000_MASTER_SLAVE iegbe_ms_hw_default
+ #endif
+
+-#ifdef NETIF_F_HW_VLAN_TX
+-#define E1000_MNG_VLAN_NONE -1
+-#endif
++#define E1000_MNG_VLAN_NONE (-1)
+ /* Number of packet split data buffers (not including the header buffer) */
+-#define PS_PAGE_BUFFERS MAX_PS_BUFFERS-1
++#define PS_PAGE_BUFFERS (MAX_PS_BUFFERS - 1)
+
+ /* only works for sizes that are powers of 2 */
+ #define E1000_ROUNDUP(i, size) ((i) = (((i) + (size) - 1) & ~((size) - 1)))
+@@ -206,6 +207,7 @@ struct iegbe_tx_ring {
+ spinlock_t tx_lock;
+ uint16_t tdh;
+ uint16_t tdt;
++ boolean_t last_tx_tso;
+ uint64_t pkt;
+ };
+
+@@ -228,6 +230,9 @@ struct iegbe_rx_ring {
+ struct iegbe_ps_page *ps_page;
+ struct iegbe_ps_page_dma *ps_page_dma;
+
++ /* cpu for rx queue */
++ int cpu;
++
+ uint16_t rdh;
+ uint16_t rdt;
+ uint64_t pkt;
+@@ -252,10 +257,8 @@ struct iegbe_adapter {
+ struct timer_list tx_fifo_stall_timer;
+ struct timer_list watchdog_timer;
+ struct timer_list phy_info_timer;
+-#ifdef NETIF_F_HW_VLAN_TX
+ struct vlan_group *vlgrp;
+ uint16_t mng_vlan_id;
+-#endif
+ uint32_t bd_number;
+ uint32_t rx_buffer_len;
+ uint32_t part_num;
+@@ -265,8 +268,18 @@ struct iegbe_adapter {
+ uint16_t link_speed;
+ uint16_t link_duplex;
+ spinlock_t stats_lock;
+- atomic_t irq_sem;
+- struct work_struct tx_timeout_task;
++ spinlock_t tx_queue_lock;
++ unsigned int total_tx_bytes;
++ unsigned int total_tx_packets;
++ unsigned int total_rx_bytes;
++ unsigned int total_rx_packets;
++ /* Interrupt Throttle Rate */
++ uint32_t itr;
++ uint32_t itr_setting;
++ uint16_t tx_itr;
++ uint16_t rx_itr;
++
++ struct work_struct reset_task;
+ uint8_t fc_autoneg;
+
+ #ifdef ETHTOOL_PHYS_ID
+@@ -276,9 +289,8 @@ struct iegbe_adapter {
+
+ /* TX */
+ struct iegbe_tx_ring *tx_ring; /* One per active queue */
+-#ifdef CONFIG_E1000_MQ
+- struct iegbe_tx_ring **cpu_tx_ring; /* per-cpu */
+-#endif
++ unsigned int restart_queue;
++ unsigned long tx_queue_len;
+ uint32_t txd_cmd;
+ uint32_t tx_int_delay;
+ uint32_t tx_abs_int_delay;
+@@ -286,46 +298,33 @@ struct iegbe_adapter {
+ uint64_t gotcl_old;
+ uint64_t tpt_old;
+ uint64_t colc_old;
++ uint32_t tx_timeout_count;
+ uint32_t tx_fifo_head;
+ uint32_t tx_head_addr;
+ uint32_t tx_fifo_size;
++ uint8_t tx_timeout_factor;
+ atomic_t tx_fifo_stall;
+ boolean_t pcix_82544;
+ boolean_t detect_tx_hung;
+
+ /* RX */
+-#ifdef CONFIG_E1000_NAPI
+- boolean_t (*clean_rx) (struct iegbe_adapter *adapter,
++ bool (*clean_rx)(struct iegbe_adapter *adapter,
+ struct iegbe_rx_ring *rx_ring,
+ int *work_done, int work_to_do);
+-#else
+- boolean_t (*clean_rx) (struct iegbe_adapter *adapter,
+- struct iegbe_rx_ring *rx_ring);
+-#endif
+-
+-#ifdef IEGBE_GBE_WORKAROUND
+ void (*alloc_rx_buf) (struct iegbe_adapter *adapter,
+- struct iegbe_rx_ring *rx_ring,
+- int cleaned_count);
+-#else
+- void (*alloc_rx_buf) (struct iegbe_adapter *adapter,
+- struct iegbe_rx_ring *rx_ring);
+-#endif
+-
++ struct iegbe_rx_ring *rx_ring,
++ int cleaned_count);
+ struct iegbe_rx_ring *rx_ring; /* One per active queue */
+-#ifdef CONFIG_E1000_NAPI
++ struct napi_struct napi;
+ struct net_device *polling_netdev; /* One per active queue */
+-#endif
+-#ifdef CONFIG_E1000_MQ
+- struct net_device **cpu_netdev; /* per-cpu */
+- struct call_async_data_struct rx_sched_call_data;
+- int cpu_for_queue[4];
+-#endif
+- int num_queues;
++
++ int num_tx_queues;
++ int num_rx_queues;
+
+ uint64_t hw_csum_err;
+ uint64_t hw_csum_good;
+ uint64_t rx_hdr_split;
++ uint32_t alloc_rx_buff_failed;
+ uint32_t rx_int_delay;
+ uint32_t rx_abs_int_delay;
+ boolean_t rx_csum;
+@@ -334,8 +333,6 @@ struct iegbe_adapter {
+ uint64_t gorcl_old;
+ uint16_t rx_ps_bsize0;
+
+- /* Interrupt Throttle Rate */
+- uint32_t itr;
+
+ /* OS defined structs */
+ struct net_device *netdev;
+@@ -378,7 +375,21 @@ struct iegbe_adapter {
+ #ifdef CONFIG_PCI_MSI
+ boolean_t have_msi;
+ #endif
+-#define IEGBE_INTD_DISABLE 0x0400
++ /* to not mess up cache alignment, always add to the bottom */
++ boolean_t tso_force;
++ boolean_t smart_power_down; /* phy smart power down */
++ boolean_t quad_port_a;
++ unsigned long flags;
++ uint32_t eeprom_wol;
++ int bars;
++ int need_ioport;
+ };
++
++enum iegbe_state_t {
++ __E1000_TESTING,
++ __E1000_RESETTING,
++ __E1000_DOWN
++};
++#define IEGBE_INTD_DISABLE 0x0400
+ #endif /* _IEGBE_H_ */
+
+--- a/Embedded/src/GbE/iegbe_hw.c
++++ b/Embedded/src/GbE/iegbe_hw.c
+@@ -2,7 +2,7 @@
+
+ GPL LICENSE SUMMARY
+
+- Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
++ Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of version 2 of the GNU General Public License as
+@@ -22,7 +22,7 @@ GPL LICENSE SUMMARY
+ Contact Information:
+ Intel Corporation
+
+- version: Embedded.L.1.0.34
++ version: Embedded.Release.Patch.L.1.0.7-5
+
+ Contact Information:
+
+@@ -2115,7 +2115,7 @@ iegbe_config_mac_to_phy(struct iegbe_hw
+
+ ret_val = iegbe_oem_set_trans_gasket(hw);
+ if(ret_val){
+- return ret_val;
++ return ret_val;
+ }
+ ret_val = iegbe_oem_phy_is_full_duplex(
+ hw, (int *) &is_FullDuplex);
+@@ -2164,7 +2164,7 @@ iegbe_config_mac_to_phy(struct iegbe_hw
+ }
+ /* Write the configured values back to the Device Control Reg. */
+ E1000_WRITE_REG(hw, CTRL, ctrl);
+- return E1000_SUCCESS;
++ return ret_val;
+ }
+
+ /*****************************************************************************
+@@ -2684,7 +2684,7 @@ iegbe_check_for_link(struct iegbe_hw *hw
+
+ if(hw->autoneg_failed == 0) {
+ hw->autoneg_failed = 1;
+- return 0;
++ return E1000_SUCCESS;
+ }
+ DEBUGOUT("NOT RXing /C/, disable AutoNeg and force link.\r\n");
+
+@@ -5875,7 +5875,7 @@ iegbe_get_cable_length(struct iegbe_hw *
+ max_agc = cur_agc;
+ }
+ }
+-
++
+ /* This is to fix a Klockwork defect, that the array index might
+ * be out of bounds. 113 is table size */
+ if (cur_agc < 0x71){
+--- a/Embedded/src/GbE/iegbe_hw.h
++++ b/Embedded/src/GbE/iegbe_hw.h
+@@ -2,7 +2,7 @@
+
+ GPL LICENSE SUMMARY
+
+- Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
++ Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of version 2 of the GNU General Public License as
+@@ -22,7 +22,7 @@ GPL LICENSE SUMMARY
+ Contact Information:
+ Intel Corporation
+
+- version: Embedded.L.1.0.34
++ version: Embedded.Release.Patch.L.1.0.7-5
+
+ Contact Information:
+
+@@ -299,7 +299,7 @@ void iegbe_set_media_type(struct iegbe_h
+ /* Link Configuration */
+ int32_t iegbe_setup_link(struct iegbe_hw *hw);
+ int32_t iegbe_phy_setup_autoneg(struct iegbe_hw *hw);
+-void iegbe_config_collision_dist(struct iegbe_hw *hw);
++void iegbe_config_collision_dist(struct iegbe_hw *hw);
+ int32_t iegbe_config_fc_after_link_up(struct iegbe_hw *hw);
+ int32_t iegbe_check_for_link(struct iegbe_hw *hw);
+ int32_t iegbe_get_speed_and_duplex(struct iegbe_hw *hw, uint16_t * speed, uint16_t * duplex);
+@@ -588,14 +588,6 @@ uint8_t iegbe_arc_subsystem_valid(struct
+ * o LSC = Link Status Change
+ */
+
+-#ifdef IEGBE_GBE_WORKAROUND
+-#define IMS_ENABLE_MASK ( \
+- E1000_IMS_RXT0 | \
+- E1000_IMS_TXQE | \
+- E1000_IMS_RXDMT0 | \
+- E1000_IMS_RXSEQ | \
+- E1000_IMS_LSC)
+-#else
+ #define IMS_ENABLE_MASK ( \
+ E1000_IMS_RXT0 | \
+ E1000_IMS_TXDW | \
+@@ -606,8 +598,7 @@ uint8_t iegbe_arc_subsystem_valid(struct
+ E1000_ICR_PB | \
+ E1000_ICR_CPP_TARGET | \
+ E1000_ICR_CPP_MASTER | \
+- E1000_IMS_LSC)
+-#endif
++ E1000_ICR_LSC)
+
+ /* Number of high/low register pairs in the RAR. The RAR (Receive Address
+ * Registers) holds the directed and multicast addresses that we monitor. We
+@@ -923,10 +914,15 @@ struct iegbe_ffvt_entry {
+ #define E1000_ICS 0x000C8 /* Interrupt Cause Set - WO */
+ #define E1000_IMS 0x000D0 /* Interrupt Mask Set - RW */
+ #define E1000_IMC 0x000D8 /* Interrupt Mask Clear - WO */
+-// Register conflict, does not exist for ICP_xxxx hardware
+-// #define E1000_IAM 0x000E0 /* Interrupt Acknowledge Auto Mask */
+ #define E1000_CTRL_AUX 0x000E0 /* Aux Control -RW */
++#define E1000_IAM 0x000E0 /* Interrupt Acknowledge Auto Mask */
+ #define E1000_RCTL 0x00100 /* RX Control - RW */
++#define E1000_RDTR1 0x02820 /* RX Delay Timer (1) - RW */
++#define E1000_RDBAL1 0x02900 /* RX Descriptor Base Address Low (1) - RW */
++#define E1000_RDBAH1 0x02904 /* RX Descriptor Base Address High (1) - RW */
++#define E1000_RDLEN1 0x02908 /* RX Descriptor Length (1) - RW */
++#define E1000_RDH1 0x02910 /* RX Descriptor Head (1) - RW */
++#define E1000_RDT1 0x02918 /* RX Descriptor Tail (1) - RW */
+ #define E1000_FCTTV 0x00170 /* Flow Control Transmit Timer Value - RW */
+ #define E1000_TXCW 0x00178 /* TX Configuration Word - RW */
+ #define E1000_RXCW 0x00180 /* RX Configuration Word - RO */
+@@ -1282,8 +1278,6 @@ struct iegbe_ffvt_entry {
+ #define E1000_82542_FFMT E1000_FFMT
+ #define E1000_82542_FFVT E1000_FFVT
+ #define E1000_82542_HOST_IF E1000_HOST_IF
+-// Register conflict with ICP_xxxx hardware, no IAM
+-// #define E1000_82542_IAM E1000_IAM
+ #define E1000_82542_EEMNGCTL E1000_EEMNGCTL
+ #define E1000_82542_PSRCTL E1000_PSRCTL
+ #define E1000_82542_RAID E1000_RAID
+@@ -1329,6 +1323,7 @@ struct iegbe_hw_stats {
+ uint64_t algnerrc;
+ uint64_t symerrs;
+ uint64_t rxerrc;
++ uint64_t txerrc;
+ uint64_t mpc;
+ uint64_t scc;
+ uint64_t ecol;
+@@ -1363,6 +1358,7 @@ struct iegbe_hw_stats {
+ uint64_t ruc;
+ uint64_t rfc;
+ uint64_t roc;
++ uint64_t rlerrc;
+ uint64_t rjc;
+ uint64_t mgprc;
+ uint64_t mgpdc;
+@@ -1392,19 +1388,6 @@ struct iegbe_hw_stats {
+ uint64_t ictxqmtc;
+ uint64_t icrxdmtc;
+ uint64_t icrxoc;
+-#ifdef IEGBE_GBE_WORKAROUND
+- u64 txqec;
+- u64 tx_next_to_clean;
+- u64 tx_next_to_use;
+- u64 cc_gt_num_rx;
+- u64 tx_hnet;
+- u64 tx_hnentu;
+- u64 num_tx_queues;
+-
+- u64 num_rx_buf_alloc;
+- u64 rx_next_to_clean;
+- u64 rx_next_to_use;
+-#endif
+ };
+
+ /* Structure containing variables used by the shared code (iegbe_hw.c) */
+@@ -1484,6 +1467,7 @@ struct iegbe_hw {
+ boolean_t ifs_params_forced;
+ boolean_t in_ifs_mode;
+ boolean_t mng_reg_access_disabled;
++ boolean_t rx_needs_kicking;
+ boolean_t icp_xxxx_is_link_up;
+ };
+
+@@ -2358,17 +2342,23 @@ struct iegbe_host_command_info {
+ #define E1000_EXTCNF_SIZE_EXT_PHY_LENGTH 0x000000FF
+ #define E1000_EXTCNF_SIZE_EXT_DOCK_LENGTH 0x0000FF00
+ #define E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH 0x00FF0000
++#define E1000_EXTCNF_CTRL_LCD_WRITE_ENABLE 0x00000001
++#define E1000_EXTCNF_CTRL_SWFLAG 0x00000020
+
+ /* PBA constants */
++#define E1000_PBA_8K 0x0008 /* 8KB, default Rx allocation */
+ #define E1000_PBA_12K 0x000C /* 12KB, default Rx allocation */
+ #define E1000_PBA_16K 0x0010 /* 16KB, default TX allocation */
++#define E1000_PBA_20K 0x0014
+ #define E1000_PBA_22K 0x0016
+ #define E1000_PBA_24K 0x0018
+ #define E1000_PBA_30K 0x001E
+ #define E1000_PBA_32K 0x0020
++#define E1000_PBA_34K 0x0022
+ #define E1000_PBA_38K 0x0026
+ #define E1000_PBA_40K 0x0028
+ #define E1000_PBA_48K 0x0030 /* 48KB, default RX allocation */
++#define E1000_PBS_16K E1000_PBA_16K
+
+ /* Flow Control Constants */
+ #define FLOW_CONTROL_ADDRESS_LOW 0x00C28001
+@@ -2899,7 +2889,7 @@ struct iegbe_host_command_info {
+ #define M88E1000_14_PHY_ID M88E1000_E_PHY_ID
+ #define M88E1011_I_REV_4 0x04
+ #define M88E1111_I_PHY_ID 0x01410CC2
+-#define M88E1141_E_PHY_ID 0x01410CD4
++#define M88E1141_E_PHY_ID 0x01410CD0
+ #define L1LXT971A_PHY_ID 0x001378E0
+
+ /* Miscellaneous PHY bit definitions. */
+--- a/Embedded/src/GbE/iegbe_main.c
++++ b/Embedded/src/GbE/iegbe_main.c
+@@ -2,7 +2,7 @@
+
+ GPL LICENSE SUMMARY
+
+- Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
++ Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of version 2 of the GNU General Public License as
+@@ -22,7 +22,7 @@ GPL LICENSE SUMMARY
+ Contact Information:
+ Intel Corporation
+
+- version: Embedded.L.1.0.34
++ version: Embedded.Release.Patch.L.1.0.7-5
+
+ Contact Information:
+
+@@ -42,103 +42,15 @@ GPL LICENSE SUMMARY
+
+ #include "iegbe.h"
+ #include "gcu_if.h"
+-
+-/* Change Log
+- * 6.0.58 4/20/05
+- * o iegbe_set_spd_dplx tests for compatible speed/duplex specification
+- * for fiber adapters
+- * 6.0.57 4/19/05
+- * o Added code to fix register test failure for devices >= 82571
+- *
+- * 6.0.52 3/15/05
+- * o Added stats_lock around iegbe_read_phy_reg commands to avoid concurrent
+- * calls, one from mii_ioctl and other from within update_stats while
+- * processing MIIREG ioctl.
+- *
+- * 6.1.2 4/13/05
+- * o Fixed ethtool diagnostics
+- * o Enabled flow control to take default eeprom settings
+- * o Added stats_lock around iegbe_read_phy_reg commands to avoid concurrent
+- * calls, one from mii_ioctl and other from within update_stats while processing
+- * MIIREG ioctl.
+- * 6.0.55 3/23/05
+- * o Support for MODULE_VERSION
+- * o Fix APM setting for 82544 based adapters
+- * 6.0.54 3/26/05
+- * o Added a timer to expire packets that were deferred for cleanup
+- * 6.0.52 3/15/05
+- * o Added stats_lock around iegbe_read_phy_reg commands to avoid concurrent
+- * calls, one from mii_ioctl and other from within update_stats while
+- * processing MIIREG ioctl.
+- * 6.0.47 3/2/05
+- * o Added enhanced functionality to the loopback diags to wrap the
+- * descriptor rings
+- * o Added manageability vlan filtering workaround.
+- *
+- * 6.0.44+ 2/15/05
+- * o Added code to handle raw packet based DHCP packets
+- * o Added code to fix the errata 10 buffer overflow issue
+- * o Sync up with WR01-05
+- * o applied Anton's patch to resolve tx hang in hardware
+- * o iegbe timeouts with early writeback patch
+- * o Removed Queensport IDs
+- * o fixed driver panic if MAC receives a bad large packets when packet
+- * split is enabled
+- * o Applied Andrew Mortons patch - iegbe stops working after resume
+- * 5.2.29 12/24/03
+- * o Bug fix: Endianess issue causing ethtool diags to fail on ppc.
+- * o Bug fix: Use pdev->irq instead of netdev->irq for MSI support.
+- * o Report driver message on user override of InterruptThrottleRate module
+- * parameter.
+- * o Bug fix: Change I/O address storage from uint32_t to unsigned long.
+- * o Feature: Added ethtool RINGPARAM support.
+- * o Feature: Added netpoll support.
+- * o Bug fix: Race between Tx queue and Tx clean fixed with a spin lock.
+- * o Bug fix: Allow 1000/Full setting for autoneg param for fiber connections.
+- * Jon D Mason [jonmason@us.ibm.com].
+- *
+- * 5.2.22 10/15/03
+- * o Bug fix: SERDES devices might be connected to a back-plane switch that
+- * doesn't support auto-neg, so add the capability to force 1000/Full.
+- * Also, since forcing 1000/Full, sample RxSynchronize bit to detect link
+- * state.
+- * o Bug fix: Flow control settings for hi/lo watermark didn't consider
+- * changes in the RX FIFO size, which could occur with Jumbo Frames or with
+- * the reduced FIFO in 82547.
+- * o Bug fix: Better propagation of error codes.
+- * [Janice Girouard (janiceg -a-t- us.ibm.com)]
+- * o Bug fix: hang under heavy Tx stress when running out of Tx descriptors;
+- * wasn't clearing context descriptor when backing out of send because of
+- * no-resource condition.
+- * o Bug fix: check netif_running in dev->poll so we don't have to hang in
+- * dev->close until all polls are finished. [Rober Olsson
+- * (robert.olsson@data.slu.se)].
+- * o Revert TxDescriptor ring size back to 256 since change to 1024 wasn't
+- * accepted into the kernel.
+- *
+- * 5.2.16 8/8/03
+- */
+-
+-#ifdef IEGBE_GBE_WORKAROUND
+-#define IEGBE_GBE_WORKAROUND_NUM_RX_DESCRIPTORS 1
+-#endif
++#include <linux/ipv6.h>
++#include <net/ip6_checksum.h>
+
+ char iegbe_driver_name[] = "iegbe";
+ char iegbe_driver_string[] = "Gigabit Ethernet Controller Driver";
+-#ifndef CONFIG_E1000_NAPI
+-#define DRIVERNAPI
+-#else
+-#define DRIVERNAPI "-NAPI"
+-#endif
+-#define DRV_VERSION "0.8.0"DRIVERNAPI
++#define DRV_VERSION "1.0.0-K28-NAPI"
+ char iegbe_driver_version[] = DRV_VERSION;
+-char iegbe_copyright[] = "Copyright (c) 1999-2007 Intel Corporation.";
++char iegbe_copyright[] = "Copyright (c) 1999-2009 Intel Corporation.";
+
+-#define E1000_FIFO_HDR 0x10
+-#define E1000_82547_PAD_LEN 0x3E0
+-#define MINIMUM_DHCP_PACKET_SIZE 282
+-#define TXD_USE_COUNT(S, X) (((S) >> (X)) + 1 )
+-#define E1000_CTRL_EN_PHY_PWR_MGMT 0x00200000
+
+ /* iegbe_pci_tbl - PCI Device ID Table
+ *
+@@ -148,95 +60,48 @@ char iegbe_copyright[] = "Copyright (c)
+ * {PCI_DEVICE(PCI_VENDOR_ID_INTEL, device_id)}
+ */
+ static struct pci_device_id iegbe_pci_tbl[] = {
+-/* INTEL_E1000_ETHERNET_DEVICE(0x1000), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x1001), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x1004), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x1008), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x1009), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x100C), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x100D), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x100E), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x100F), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x1010), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x1011), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x1012), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x1013), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x1014), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x1015), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x1016), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x1017), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x1018), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x1019), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x101A), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x101D), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x101E), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x1026), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x1027), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x1028), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x105E), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x105F), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x1060), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x1075), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x1076), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x1077), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x1078), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x1079), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x107A), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x107B), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x107C), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x107D), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x107E), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x107F), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x108A), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x108B), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x108C), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x109A), */
+- INTEL_E1000_ETHERNET_DEVICE(0x5040),
+- INTEL_E1000_ETHERNET_DEVICE(0x5041),
+- INTEL_E1000_ETHERNET_DEVICE(0x5042),
+- INTEL_E1000_ETHERNET_DEVICE(0x5043),
+- INTEL_E1000_ETHERNET_DEVICE(0x5044),
+- INTEL_E1000_ETHERNET_DEVICE(0x5045),
+- INTEL_E1000_ETHERNET_DEVICE(0x5046),
+- INTEL_E1000_ETHERNET_DEVICE(0x5047),
+- INTEL_E1000_ETHERNET_DEVICE(0x5048),
+- INTEL_E1000_ETHERNET_DEVICE(0x5049),
+- INTEL_E1000_ETHERNET_DEVICE(0x504A),
+- INTEL_E1000_ETHERNET_DEVICE(0x504B),
+- /* required last entry */
++ INTEL_E1000_ETHERNET_DEVICE(0x5040),
++ INTEL_E1000_ETHERNET_DEVICE(0x5041),
++ INTEL_E1000_ETHERNET_DEVICE(0x5042),
++ INTEL_E1000_ETHERNET_DEVICE(0x5043),
++ INTEL_E1000_ETHERNET_DEVICE(0x5044),
++ INTEL_E1000_ETHERNET_DEVICE(0x5045),
++ INTEL_E1000_ETHERNET_DEVICE(0x5046),
++ INTEL_E1000_ETHERNET_DEVICE(0x5047),
++ INTEL_E1000_ETHERNET_DEVICE(0x5048),
++ INTEL_E1000_ETHERNET_DEVICE(0x5049),
++ INTEL_E1000_ETHERNET_DEVICE(0x504A),
++ INTEL_E1000_ETHERNET_DEVICE(0x504B),
++ /* required last entry */
+ {0,}
+ };
+
+ MODULE_DEVICE_TABLE(pci, iegbe_pci_tbl);
+
+-DEFINE_SPINLOCK(print_lock);
+
+ int iegbe_up(struct iegbe_adapter *adapter);
+ void iegbe_down(struct iegbe_adapter *adapter);
++void iegbe_reinit_locked(struct iegbe_adapter *adapter);
+ void iegbe_reset(struct iegbe_adapter *adapter);
+ int iegbe_set_spd_dplx(struct iegbe_adapter *adapter, uint16_t spddplx);
+ int iegbe_setup_all_tx_resources(struct iegbe_adapter *adapter);
+ int iegbe_setup_all_rx_resources(struct iegbe_adapter *adapter);
+ void iegbe_free_all_tx_resources(struct iegbe_adapter *adapter);
+ void iegbe_free_all_rx_resources(struct iegbe_adapter *adapter);
+-int iegbe_setup_tx_resources(struct iegbe_adapter *adapter,
++static int iegbe_setup_tx_resources(struct iegbe_adapter *adapter,
+ struct iegbe_tx_ring *txdr);
+-int iegbe_setup_rx_resources(struct iegbe_adapter *adapter,
++static int iegbe_setup_rx_resources(struct iegbe_adapter *adapter,
+ struct iegbe_rx_ring *rxdr);
+-void iegbe_free_tx_resources(struct iegbe_adapter *adapter,
++static void iegbe_free_tx_resources(struct iegbe_adapter *adapter,
+ struct iegbe_tx_ring *tx_ring);
+-void iegbe_free_rx_resources(struct iegbe_adapter *adapter,
++static void iegbe_free_rx_resources(struct iegbe_adapter *adapter,
+ struct iegbe_rx_ring *rx_ring);
+ void iegbe_update_stats(struct iegbe_adapter *adapter);
+-
+ static int iegbe_init_module(void);
+ static void iegbe_exit_module(void);
+ static int iegbe_probe(struct pci_dev *pdev, const struct pci_device_id *ent);
+ static void __devexit iegbe_remove(struct pci_dev *pdev);
+ static int iegbe_alloc_queues(struct iegbe_adapter *adapter);
+-#ifdef CONFIG_E1000_MQ
+-static void iegbe_setup_queue_mapping(struct iegbe_adapter *adapter);
+-#endif
+ static int iegbe_sw_init(struct iegbe_adapter *adapter);
+ static int iegbe_open(struct net_device *netdev);
+ static int iegbe_close(struct net_device *netdev);
+@@ -249,7 +114,8 @@ static void iegbe_clean_tx_ring(struct i
+ struct iegbe_tx_ring *tx_ring);
+ static void iegbe_clean_rx_ring(struct iegbe_adapter *adapter,
+ struct iegbe_rx_ring *rx_ring);
+-static void iegbe_set_multi(struct net_device *netdev);
++
++static void iegbe_set_rx_mode(struct net_device *netdev);
+ static void iegbe_update_phy_info(unsigned long data);
+ static void iegbe_watchdog(unsigned long data);
+ static void iegbe_82547_tx_fifo_stall(unsigned long data);
+@@ -257,66 +123,46 @@ static int iegbe_xmit_frame(struct sk_bu
+ static struct net_device_stats * iegbe_get_stats(struct net_device *netdev);
+ static int iegbe_change_mtu(struct net_device *netdev, int new_mtu);
+ static int iegbe_set_mac(struct net_device *netdev, void *p);
+-static irqreturn_t iegbe_intr(int irq, void *data, struct pt_regs *regs);
++static irqreturn_t iegbe_intr(int irq, void *data);
+
+-void iegbe_tasklet(unsigned long);
++static irqreturn_t iegbe_intr_msi(int irq, void *data);
+
+-#ifndef IEGBE_GBE_WORKAROUND
+-static boolean_t iegbe_clean_tx_irq(struct iegbe_adapter *adapter,
++static bool iegbe_clean_tx_irq(struct iegbe_adapter *adapter,
+ struct iegbe_tx_ring *tx_ring);
+-#endif
+-
+-#ifdef CONFIG_E1000_NAPI
+-static int iegbe_clean(struct net_device *poll_dev, int *budget);
+-static boolean_t iegbe_clean_rx_irq(struct iegbe_adapter *adapter,
++static int iegbe_clean(struct napi_struct *napi, int budget);
++static bool iegbe_clean_rx_irq(struct iegbe_adapter *adapter,
+ struct iegbe_rx_ring *rx_ring,
+ int *work_done, int work_to_do);
+-static boolean_t iegbe_clean_rx_irq_ps(struct iegbe_adapter *adapter,
++static bool iegbe_clean_rx_irq_ps(struct iegbe_adapter *adapter,
+ struct iegbe_rx_ring *rx_ring,
+ int *work_done, int work_to_do);
+-#else
+-static boolean_t iegbe_clean_rx_irq(struct iegbe_adapter *adapter,
+- struct iegbe_rx_ring *rx_ring);
+-static boolean_t iegbe_clean_rx_irq_ps(struct iegbe_adapter *adapter,
+- struct iegbe_rx_ring *rx_ring);
+-#endif
+
+-#ifdef IEGBE_GBE_WORKAROUND
++
+ static void iegbe_alloc_rx_buffers(struct iegbe_adapter *adapter,
+ struct iegbe_rx_ring *rx_ring,
+ int cleaned_count);
+ static void iegbe_alloc_rx_buffers_ps(struct iegbe_adapter *adapter,
+ struct iegbe_rx_ring *rx_ring,
+ int cleaned_count);
+-#else
+-static void iegbe_alloc_rx_buffers(struct iegbe_adapter *adapter,
+- struct iegbe_rx_ring *rx_ring);
+-static void iegbe_alloc_rx_buffers_ps(struct iegbe_adapter *adapter,
+- struct iegbe_rx_ring *rx_ring);
+-#endif
++
+
+ static int iegbe_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd);
+-#ifdef SIOCGMIIPHY
+ static int iegbe_mii_ioctl(struct net_device *netdev, struct ifreq *ifr,
+- int cmd);
+-#endif
++ int cmd);
+ void set_ethtool_ops(struct net_device *netdev);
+ extern int ethtool_ioctl(struct ifreq *ifr);
+ static void iegbe_enter_82542_rst(struct iegbe_adapter *adapter);
+ static void iegbe_leave_82542_rst(struct iegbe_adapter *adapter);
+ static void iegbe_tx_timeout(struct net_device *dev);
+-static void iegbe_tx_timeout_task(struct net_device *dev);
++static void iegbe_reset_task(struct work_struct *work);
+ static void iegbe_smartspeed(struct iegbe_adapter *adapter);
+ static inline int iegbe_82547_fifo_workaround(struct iegbe_adapter *adapter,
+- struct sk_buff *skb);
++ struct sk_buff *skb);
+
+-#ifdef NETIF_F_HW_VLAN_TX
+-static void iegbe_vlan_rx_register(struct net_device *netdev,
+- struct vlan_group *grp);
++static void iegbe_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp);
+ static void iegbe_vlan_rx_add_vid(struct net_device *netdev, uint16_t vid);
+ static void iegbe_vlan_rx_kill_vid(struct net_device *netdev, uint16_t vid);
+ static void iegbe_restore_vlan(struct iegbe_adapter *adapter);
+-#endif
+
+ static int iegbe_notify_reboot(struct notifier_block *,
+ unsigned long event,
+@@ -331,15 +177,17 @@ static int iegbe_resume(struct pci_dev *
+ static void iegbe_netpoll (struct net_device *netdev);
+ #endif
+
+-#ifdef CONFIG_E1000_MQ
+-/* for multiple Rx queues */
++#define COPYBREAK_DEFAULT 256
++static unsigned int copybreak __read_mostly = COPYBREAK_DEFAULT;
++module_param(copybreak, uint, 0644);
++MODULE_PARM_DESC(copybreak,
++ "Maximum size of packet that is copied to a new buffer on receive");
+ void iegbe_rx_schedule(void *data);
+-#endif
+
+ struct notifier_block iegbe_notifier_reboot = {
+- .notifier_call = iegbe_notify_reboot,
+- .next = NULL,
+- .priority = 0
++ .notifier_call = iegbe_notify_reboot,
++ .next = NULL,
++ .priority = 0
+ };
+
+ /* Exported from other modules */
+@@ -347,14 +195,14 @@ struct notifier_block iegbe_notifier_reb
+ extern void iegbe_check_options(struct iegbe_adapter *adapter);
+
+ static struct pci_driver iegbe_driver = {
+- .name = iegbe_driver_name,
+- .id_table = iegbe_pci_tbl,
+- .probe = iegbe_probe,
+- .remove = __devexit_p(iegbe_remove),
+- /* Power Managment Hooks */
++ .name = iegbe_driver_name,
++ .id_table = iegbe_pci_tbl,
++ .probe = iegbe_probe,
++ .remove = __devexit_p(iegbe_remove),
++ /* Power Managment Hooks */
+ #ifdef CONFIG_PM
+- .suspend = iegbe_suspend,
+- .resume = iegbe_resume
++ .suspend = iegbe_suspend,
++ .resume = iegbe_resume
+ #endif
+ };
+
+@@ -364,46 +212,17 @@ MODULE_LICENSE("GPL");
+ MODULE_VERSION(DRV_VERSION);
+
+ static int debug = NETIF_MSG_DRV | NETIF_MSG_PROBE;
+-module_param(debug, int, 0);
++module_param(debug, int, 0x0);
+ MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)");
+
+-static uint8_t gcu_suspend = 0;
+-static uint8_t gcu_resume = 0;
++static uint8_t gcu_suspend = 0x0;
++static uint8_t gcu_resume = 0x0;
+ struct pci_dev *gcu = NULL;
+
+-unsigned long tasklet_data;
+-DECLARE_TASKLET(iegbe_reset_tasklet, iegbe_tasklet, (unsigned long) &tasklet_data);
+
+ /**
+ * iegbe_iegbe_tasklet -*
+ **/
+-void iegbe_tasklet(unsigned long data)
+-{
+- char* err_msg = "TEST";
+- uint32_t *icr = (uint32_t*) data;
+- uint32_t gbe = *icr & 0x000000FF;
+- if( *icr & E1000_ICR_RX_DESC_FIFO_PAR) { /* 21 */
+- err_msg = "DMA Transmit Descriptor 2-bit ECC Error!";
+- }
+- if( *icr & E1000_ICR_TX_DESC_FIFO_PAR) { /* 20 */
+- err_msg = "DMA Receive Descriptor 2-bit ECC Error!";
+- }
+- if( *icr & E1000_ICR_PB) { /* 23 */
+- err_msg = "DMA Packet Buffer 2-bit ECC Error!";
+- }
+- if( *icr & E1000_ICR_CPP_TARGET) { /* 27 */
+- err_msg = "Statistic Register ECC Error!";
+- }
+- if( *icr & E1000_ICR_CPP_MASTER) {
+- err_msg = "CPP Error!";
+- }
+- spin_lock(&print_lock);
+- printk("IEGBE%d: System Reset due to: %s\n", gbe, err_msg);
+- dump_stack();
+- spin_unlock(&print_lock);
+- panic(err_msg);
+- return;
+-}
+ /**
+ * iegbe_init_module - Driver Registration Routine
+ *
+@@ -411,21 +230,24 @@ void iegbe_tasklet(unsigned long data)
+ * loaded. All it does is register with the PCI subsystem.
+ **/
+
+-static int __init
+-iegbe_init_module(void)
++static int __init iegbe_init_module(void)
+ {
+- int ret;
++ int ret;
+
+ printk(KERN_INFO "%s - version %s\n",
+- iegbe_driver_string, iegbe_driver_version);
++ iegbe_driver_string, iegbe_driver_version);
+
+- printk(KERN_INFO "%s\n", iegbe_copyright);
++ printk(KERN_INFO "%s\n", iegbe_copyright);
+
+- ret = pci_module_init(&iegbe_driver);
+- if(ret >= 0) {
+- register_reboot_notifier(&iegbe_notifier_reboot);
+- }
+- return ret;
++ ret = pci_register_driver(&iegbe_driver);
++ if (copybreak != COPYBREAK_DEFAULT) {
++ if (copybreak == 0)
++ printk(KERN_INFO "iegbe: copybreak disabled\n");
++ else
++ printk(KERN_INFO "iegbe: copybreak enabled for "
++ "packets <= %u bytes\n", copybreak);
++ }
++ return ret;
+ }
+
+ module_init(iegbe_init_module);
+@@ -437,29 +259,51 @@ module_init(iegbe_init_module);
+ * from memory.
+ **/
+
+-static void __exit
+-iegbe_exit_module(void)
++static void __exit iegbe_exit_module(void)
+ {
+-
+- unregister_reboot_notifier(&iegbe_notifier_reboot);
+- pci_unregister_driver(&iegbe_driver);
++ pci_unregister_driver(&iegbe_driver);
+ }
+
+ module_exit(iegbe_exit_module);
+
++static int iegbe_request_irq(struct iegbe_adapter *adapter)
++{
++ struct net_device *netdev = adapter->netdev;
++ irq_handler_t handler = iegbe_intr;
++ int irq_flags = IRQF_SHARED;
++ int err;
++ adapter->have_msi = !pci_enable_msi(adapter->pdev);
++ if (adapter->have_msi) {
++ handler = iegbe_intr_msi;
++ irq_flags = 0;
++ }
++ err = request_irq(adapter->pdev->irq, handler, irq_flags, netdev->name,
++ netdev);
++ if (err) {
++ if (adapter->have_msi)
++ pci_disable_msi(adapter->pdev);
++ DPRINTK(PROBE, ERR,
++ "Unable to allocate interrupt Error: %d\n", err);
++ }
++ return err;
++}
++static void iegbe_free_irq(struct iegbe_adapter *adapter)
++{
++ struct net_device *netdev = adapter->netdev;
++ free_irq(adapter->pdev->irq, netdev);
++ if (adapter->have_msi)
++ pci_disable_msi(adapter->pdev);
++}
+ /**
+ * iegbe_irq_disable - Mask off interrupt generation on the NIC
+ * @adapter: board private structure
+ **/
+
+-static inline void
+-iegbe_irq_disable(struct iegbe_adapter *adapter)
++static void iegbe_irq_disable(struct iegbe_adapter *adapter)
+ {
+-
+- atomic_inc(&adapter->irq_sem);
+- E1000_WRITE_REG(&adapter->hw, IMC, ~0);
+- E1000_WRITE_FLUSH(&adapter->hw);
+- synchronize_irq(adapter->pdev->irq);
++ E1000_WRITE_REG(&adapter->hw, IMC, ~0);
++ E1000_WRITE_FLUSH(&adapter->hw);
++ synchronize_irq(adapter->pdev->irq);
+ }
+
+ /**
+@@ -470,244 +314,414 @@ iegbe_irq_disable(struct iegbe_adapter *
+ static inline void
+ iegbe_irq_enable(struct iegbe_adapter *adapter)
+ {
+-
+- if(likely(atomic_dec_and_test(&adapter->irq_sem))) {
+- E1000_WRITE_REG(&adapter->hw, IMS, IMS_ENABLE_MASK);
+- E1000_WRITE_FLUSH(&adapter->hw);
+- }
++ E1000_WRITE_REG(&adapter->hw, IMS, IMS_ENABLE_MASK);
++ E1000_WRITE_FLUSH(&adapter->hw);
+ }
+-#ifdef NETIF_F_HW_VLAN_TX
+-void
+-iegbe_update_mng_vlan(struct iegbe_adapter *adapter)
+-{
+- struct net_device *netdev = adapter->netdev;
+- uint16_t vid = adapter->hw.mng_cookie.vlan_id;
+- uint16_t old_vid = adapter->mng_vlan_id;
+
+- if(adapter->vlgrp) {
+- if(!adapter->vlgrp->vlan_devices[vid]) {
+- if(adapter->hw.mng_cookie.status &
+- E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) {
+- iegbe_vlan_rx_add_vid(netdev, vid);
+- adapter->mng_vlan_id = vid;
+- } else {
+- adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
+- }
+- if((old_vid != (uint16_t)E1000_MNG_VLAN_NONE) &&
+- (vid != old_vid) &&
+- !adapter->vlgrp->vlan_devices[old_vid]) {
+- iegbe_vlan_rx_kill_vid(netdev, old_vid);
+- }
+- }
+-}
++static void iegbe_update_mng_vlan(struct iegbe_adapter *adapter)
++{
++ struct iegbe_hw *hw = &adapter->hw;
++ struct net_device *netdev = adapter->netdev;
++ u16 vid = hw->mng_cookie.vlan_id;
++ u16 old_vid = adapter->mng_vlan_id;
++ if (adapter->vlgrp) {
++ if (!vlan_group_get_device(adapter->vlgrp, vid)) {
++ if (hw->mng_cookie.status &
++ E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) {
++ iegbe_vlan_rx_add_vid(netdev, vid);
++ adapter->mng_vlan_id = vid;
++ } else
++ adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
++
++ if ((old_vid != (u16)E1000_MNG_VLAN_NONE) &&
++ (vid != old_vid) &&
++ !vlan_group_get_device(adapter->vlgrp, old_vid))
++ iegbe_vlan_rx_kill_vid(netdev, old_vid);
++ } else
++ adapter->mng_vlan_id = vid;
++ }
+ }
+-#endif
+
+-int
+-iegbe_up(struct iegbe_adapter *adapter)
++/**
++ * iegbe_configure - configure the hardware for RX and TX
++ * @adapter = private board structure
++ **/
++static void iegbe_configure(struct iegbe_adapter *adapter)
+ {
+ struct net_device *netdev = adapter->netdev;
+- int i, err;
+- uint16_t pci_cmd;
+-
+- /* hardware has been reset, we need to reload some things */
+-
+- /* Reset the PHY if it was previously powered down */
+- if(adapter->hw.media_type == iegbe_media_type_copper
+- || (adapter->hw.media_type == iegbe_media_type_oem
+- && iegbe_oem_phy_is_copper(&adapter->hw))) {
+- uint16_t mii_reg;
+- iegbe_read_phy_reg(&adapter->hw, PHY_CTRL, &mii_reg);
+- if(mii_reg & MII_CR_POWER_DOWN){
+- iegbe_phy_reset(&adapter->hw);
+- }
+- }
++ int i;
+
+- iegbe_set_multi(netdev);
++ iegbe_set_rx_mode(netdev);
+
+-#ifdef NETIF_F_HW_VLAN_TX
+ iegbe_restore_vlan(adapter);
+-#endif
+
+ iegbe_configure_tx(adapter);
+ iegbe_setup_rctl(adapter);
+ iegbe_configure_rx(adapter);
++ /* call E1000_DESC_UNUSED which always leaves
++ * at least 1 descriptor unused to make sure
++ * next_to_use != next_to_clean */
++ for (i = 0; i < adapter->num_rx_queues; i++) {
++ struct iegbe_rx_ring *ring = &adapter->rx_ring[i];
++ adapter->alloc_rx_buf(adapter, ring,
++ E1000_DESC_UNUSED(ring));
++ }
+
+-#ifdef IEGBE_GBE_WORKAROUND
+- for (i = 0; i < adapter->num_queues; i++)
+- adapter->alloc_rx_buf(adapter, &adapter->rx_ring[i],
+- IEGBE_GBE_WORKAROUND_NUM_RX_DESCRIPTORS + 1);
+-#else
+- for (i = 0; i < adapter->num_queues; i++)
+- adapter->alloc_rx_buf(adapter, &adapter->rx_ring[i]);
+-#endif
++ adapter->tx_queue_len = netdev->tx_queue_len;
++}
+
+-#ifdef CONFIG_PCI_MSI
+- if(adapter->hw.mac_type > iegbe_82547_rev_2
+- || adapter->hw.mac_type == iegbe_icp_xxxx) {
+- adapter->have_msi = TRUE;
+- if((err = pci_enable_msi(adapter->pdev))) {
+- DPRINTK(PROBE, ERR,
+- "Unable to allocate MSI interrupt Error: %d\n", err);
+- adapter->have_msi = FALSE;
+- }
+- }
+- pci_read_config_word(adapter->pdev, PCI_COMMAND, &pci_cmd);
+- pci_write_config_word(adapter->pdev, PCI_COMMAND, pci_cmd | IEGBE_INTD_DISABLE);
++int iegbe_up(struct iegbe_adapter *adapter)
++{
++ /* hardware has been reset, we need to reload some things */
++ iegbe_configure(adapter);
+
+-#endif
+- if((err = request_irq(adapter->pdev->irq, &iegbe_intr,
+- SA_SHIRQ | SA_SAMPLE_RANDOM,
+- netdev->name, netdev))) {
+- DPRINTK(PROBE, ERR,
+- "Unable to allocate interrupt Error: %d\n", err);
+- return err;
+- }
++ clear_bit(__E1000_DOWN, &adapter->flags);
+
+- mod_timer(&adapter->watchdog_timer, jiffies);
++ napi_enable(&adapter->napi);
+
+-#ifdef CONFIG_E1000_NAPI
+- netif_poll_enable(netdev);
+-#endif
+ iegbe_irq_enable(adapter);
+
++ adapter->hw.get_link_status = 0x1;
+ return 0;
+ }
+
+-void
+-iegbe_down(struct iegbe_adapter *adapter)
+-{
+- struct net_device *netdev = adapter->netdev;
+-
+- iegbe_irq_disable(adapter);
+-#ifdef CONFIG_E1000_MQ
+- while (atomic_read(&adapter->rx_sched_call_data.count) != 0) { };
+-#endif
+- free_irq(adapter->pdev->irq, netdev);
+-#ifdef CONFIG_PCI_MSI
+- if((adapter->hw.mac_type > iegbe_82547_rev_2
+- || adapter->hw.mac_type == iegbe_icp_xxxx)
+- && adapter->have_msi == TRUE) {
+- pci_disable_msi(adapter->pdev);
+- }
+-#endif
+- del_timer_sync(&adapter->tx_fifo_stall_timer);
+- del_timer_sync(&adapter->watchdog_timer);
+- del_timer_sync(&adapter->phy_info_timer);
++/**
++ * iegbe_power_up_phy - restore link in case the phy was powered down
++ * @adapter: address of board private structure
++ *
++ * The phy may be powered down to save power and turn off link when the
++ * driver is unloaded and wake on lan is not enabled (among others)
++ * *** this routine MUST be followed by a call to iegbe_reset ***
++ *
++ **/
+
+-#ifdef CONFIG_E1000_NAPI
+- netif_poll_disable(netdev);
+-#endif
+- adapter->link_speed = 0;
+- adapter->link_duplex = 0;
+- netif_carrier_off(netdev);
+- netif_stop_queue(netdev);
++void iegbe_power_up_phy(struct iegbe_adapter *adapter)
++{
++ struct iegbe_hw *hw = &adapter->hw;
++ u16 mii_reg = 0;
+
+- iegbe_reset(adapter);
+- iegbe_clean_all_tx_rings(adapter);
+- iegbe_clean_all_rx_rings(adapter);
++ /* Just clear the power down bit to wake the phy back up */
++ if (hw->media_type == iegbe_media_type_copper) {
++ /* according to the manual, the phy will retain its
++ * settings across a power-down/up cycle */
++ iegbe_read_phy_reg(hw, PHY_CTRL, &mii_reg);
++ mii_reg &= ~MII_CR_POWER_DOWN;
++ iegbe_write_phy_reg(hw, PHY_CTRL, mii_reg);
++ }
++}
+
+- /* If WoL is not enabled and management mode is not IAMT
+- * or if WoL is not enabled and OEM PHY is copper based,
+- * power down the PHY so no link is implied when interface is down */
+- if(!adapter->wol
+- && ((adapter->hw.mac_type >= iegbe_82540
+- && adapter->hw.media_type == iegbe_media_type_copper
+- && !iegbe_check_mng_mode(&adapter->hw)
+- && !(E1000_READ_REG(&adapter->hw, MANC) & E1000_MANC_SMBUS_EN))
+- || (adapter->hw.media_type == iegbe_media_type_oem
+- && iegbe_oem_phy_is_copper(&adapter->hw)))){
++static void iegbe_power_down_phy(struct iegbe_adapter *adapter)
++{
++ struct iegbe_hw *hw = &adapter->hw;
+
+- uint16_t mii_reg;
+- iegbe_read_phy_reg(&adapter->hw, PHY_CTRL, &mii_reg);
++ /* Power down the PHY so no link is implied when interface is down *
++ * The PHY cannot be powered down if any of the following is true *
++ * (a) WoL is enabled
++ * (b) AMT is active
++ * (c) SoL/IDER session is active */
++ if (!adapter->wol && hw->mac_type >= iegbe_82540 &&
++ hw->media_type == iegbe_media_type_copper) {
++ u16 mii_reg = 0;
++
++ switch (hw->mac_type) {
++ case iegbe_82540:
++ case iegbe_82545:
++ case iegbe_82545_rev_3:
++ case iegbe_82546:
++ case iegbe_82546_rev_3:
++ case iegbe_82541:
++ case iegbe_82541_rev_2:
++ case iegbe_82547:
++ case iegbe_82547_rev_2:
++ if (E1000_READ_REG(&adapter->hw, MANC) & E1000_MANC_SMBUS_EN)
++ goto out;
++ break;
++ case iegbe_82571:
++ case iegbe_82572:
++ case iegbe_82573:
++ if (iegbe_check_mng_mode(hw) ||
++ iegbe_check_phy_reset_block(hw))
++ goto out;
++ break;
++ default:
++ goto out;
++ }
++ iegbe_read_phy_reg(hw, PHY_CTRL, &mii_reg);
+ mii_reg |= MII_CR_POWER_DOWN;
+- iegbe_write_phy_reg(&adapter->hw, PHY_CTRL, mii_reg);
++ iegbe_write_phy_reg(hw, PHY_CTRL, mii_reg);
+ mdelay(1);
+ }
++out:
++ return;
+ }
+
+-void
+-iegbe_reset(struct iegbe_adapter *adapter)
++void iegbe_down(struct iegbe_adapter *adapter)
+ {
+- struct net_device *netdev = adapter->netdev;
+- uint32_t pba, manc;
+- uint16_t fc_high_water_mark = E1000_FC_HIGH_DIFF;
+- uint16_t fc_low_water_mark = E1000_FC_LOW_DIFF;
++ struct net_device *netdev = adapter->netdev;
+
++ /* signal that we're down so the interrupt handler does not
++ * reschedule our watchdog timer */
++ set_bit(__E1000_DOWN, &adapter->flags);
+
+- /* Repartition Pba for greater than 9k mtu
+- * To take effect CTRL.RST is required.
+- */
++ napi_disable(&adapter->napi);
+
+- switch (adapter->hw.mac_type) {
+- case iegbe_82547:
+- case iegbe_82547_rev_2:
+- pba = E1000_PBA_30K;
+- break;
+- case iegbe_82571:
+- case iegbe_82572:
+- pba = E1000_PBA_38K;
+- break;
+- case iegbe_82573:
+- pba = E1000_PBA_12K;
++ iegbe_irq_disable(adapter);
++
++ del_timer_sync(&adapter->tx_fifo_stall_timer);
++ del_timer_sync(&adapter->watchdog_timer);
++ del_timer_sync(&adapter->phy_info_timer);
++
++ netdev->tx_queue_len = adapter->tx_queue_len;
++ adapter->link_speed = 0;
++ adapter->link_duplex = 0;
++ netif_carrier_off(netdev);
++ netif_stop_queue(netdev);
++
++ iegbe_reset(adapter);
++ iegbe_clean_all_tx_rings(adapter);
++ iegbe_clean_all_rx_rings(adapter);
++}
++void iegbe_reinit_locked(struct iegbe_adapter *adapter)
++{
++ WARN_ON(in_interrupt());
++ while (test_and_set_bit(__E1000_RESETTING, &adapter->flags))
++ msleep(1);
++ iegbe_down(adapter);
++ iegbe_up(adapter);
++ clear_bit(__E1000_RESETTING, &adapter->flags);
++}
++
++void iegbe_reset(struct iegbe_adapter *adapter)
++{
++ struct iegbe_hw *hw = &adapter->hw;
++ u32 pba = 0, tx_space, min_tx_space, min_rx_space;
++ u16 fc_high_water_mark = E1000_FC_HIGH_DIFF;
++ bool legacy_pba_adjust = false;
++
++ /* Repartition Pba for greater than 9k mtu
++ * To take effect CTRL.RST is required.
++ */
++
++ switch (hw->mac_type) {
++ case iegbe_82542_rev2_0:
++ case iegbe_82542_rev2_1:
++ case iegbe_82543:
++ case iegbe_82544:
++ case iegbe_82540:
++ case iegbe_82541:
++ case iegbe_82541_rev_2:
++ case iegbe_icp_xxxx:
++ legacy_pba_adjust = true;
++ pba = E1000_PBA_48K;
+ break;
+- default:
++ case iegbe_82545:
++ case iegbe_82545_rev_3:
++ case iegbe_82546:
++ case iegbe_82546_rev_3:
+ pba = E1000_PBA_48K;
+ break;
+- }
++ case iegbe_82547:
++ case iegbe_82573:
++ case iegbe_82547_rev_2:
++ legacy_pba_adjust = true;
++ pba = E1000_PBA_30K;
++ break;
++ case iegbe_82571:
++ case iegbe_82572:
++ case iegbe_undefined:
++ case iegbe_num_macs:
++ break;
++ }
++
++ if (legacy_pba_adjust) {
++ if (adapter->netdev->mtu > E1000_RXBUFFER_8192)
++ pba -= 8; /* allocate more FIFO for Tx */
++ /* send an XOFF when there is enough space in the
++ * Rx FIFO to hold one extra full size Rx packet
++ */
+
+- if((adapter->hw.mac_type != iegbe_82573) &&
+- (adapter->rx_buffer_len > E1000_RXBUFFER_8192)) {
+- pba -= 0x8; /* allocate more FIFO for Tx */
+- /* send an XOFF when there is enough space in the
+- * Rx FIFO to hold one extra full size Rx packet
+- */
+- fc_high_water_mark = netdev->mtu + ENET_HEADER_SIZE +
+- ETHERNET_FCS_SIZE + 0x1;
+- fc_low_water_mark = fc_high_water_mark + 0x8;
+- }
+
++ if (hw->mac_type == iegbe_82547) {
++ adapter->tx_fifo_head = 0;
++ adapter->tx_head_addr = pba << E1000_TX_HEAD_ADDR_SHIFT;
++ adapter->tx_fifo_size =
++ (E1000_PBA_40K - pba) << E1000_PBA_BYTES_SHIFT;
++ atomic_set(&adapter->tx_fifo_stall, 0);
++ }
++ } else if (hw->max_frame_size > MAXIMUM_ETHERNET_FRAME_SIZE) {
++ E1000_WRITE_REG(&adapter->hw, PBA, pba);
++
++ /* To maintain wire speed transmits, the Tx FIFO should be
++ * large enough to accomodate two full transmit packets,
++ * rounded up to the next 1KB and expressed in KB. Likewise,
++ * the Rx FIFO should be large enough to accomodate at least
++ * one full receive packet and is similarly rounded up and
++ * expressed in KB. */
++ pba = E1000_READ_REG(&adapter->hw, PBA);
++ /* upper 16 bits has Tx packet buffer allocation size in KB */
++ tx_space = pba >> 16;
++ /* lower 16 bits has Rx packet buffer allocation size in KB */
++ pba &= 0xffff;
++ /* don't include ethernet FCS because hardware appends/strips */
++ min_rx_space = adapter->netdev->mtu + ENET_HEADER_SIZE +
++ VLAN_TAG_SIZE;
++ min_tx_space = min_rx_space;
++ min_tx_space *= 2;
++ min_tx_space = ALIGN(min_tx_space, 1024);
++ min_tx_space >>= 10;
++ min_rx_space = ALIGN(min_rx_space, 1024);
++ min_rx_space >>= 10;
++
++ /* If current Tx allocation is less than the min Tx FIFO size,
++ * and the min Tx FIFO size is less than the current Rx FIFO
++ * allocation, take space away from current Rx allocation */
++ if (tx_space < min_tx_space &&
++ ((min_tx_space - tx_space) < pba)) {
++ pba = pba - (min_tx_space - tx_space);
++
++ /* PCI/PCIx hardware has PBA alignment constraints */
++ switch (hw->mac_type) {
++ case iegbe_82545 ... iegbe_82546_rev_3:
++ pba &= ~(E1000_PBA_8K - 1);
++ break;
++ default:
++ break;
++ }
+
+- if(adapter->hw.mac_type == iegbe_82547) {
+- adapter->tx_fifo_head = 0;
+- adapter->tx_head_addr = pba << E1000_TX_HEAD_ADDR_SHIFT;
+- adapter->tx_fifo_size =
+- (E1000_PBA_40K - pba) << E1000_PBA_BYTES_SHIFT;
+- atomic_set(&adapter->tx_fifo_stall, 0);
++ /* if short on rx space, rx wins and must trump tx
++ * adjustment or use Early Receive if available */
++ if (pba < min_rx_space) {
++ switch (hw->mac_type) {
++ case iegbe_82573:
++ /* ERT enabled in iegbe_configure_rx */
++ break;
++ default:
++ pba = min_rx_space;
++ break;
++ }
++ }
++ }
+ }
+
+ E1000_WRITE_REG(&adapter->hw, PBA, pba);
+
+ /* flow control settings */
+- adapter->hw.fc_high_water = (pba << E1000_PBA_BYTES_SHIFT) -
+- fc_high_water_mark;
+- adapter->hw.fc_low_water = (pba << E1000_PBA_BYTES_SHIFT) -
+- fc_low_water_mark;
+- adapter->hw.fc_pause_time = E1000_FC_PAUSE_TIME;
+- adapter->hw.fc_send_xon = 1;
+- adapter->hw.fc = adapter->hw.original_fc;
++ /* Set the FC high water mark to 90% of the FIFO size.
++ * Required to clear last 3 LSB */
++ fc_high_water_mark = ((pba * 9216)/10) & 0xFFF8;
++ /* We can't use 90% on small FIFOs because the remainder
++ * would be less than 1 full frame. In this case, we size
++ * it to allow at least a full frame above the high water
++ * mark. */
++ if (pba < E1000_PBA_16K)
++ fc_high_water_mark = (pba * 1024) - 1600;
++
++ hw->fc_high_water = fc_high_water_mark;
++ hw->fc_low_water = fc_high_water_mark - 8;
++ hw->fc_pause_time = E1000_FC_PAUSE_TIME;
++ hw->fc_send_xon = 1;
++ hw->fc = hw->original_fc;
+
+ /* Allow time for pending master requests to run */
+- iegbe_reset_hw(&adapter->hw);
+- if(adapter->hw.mac_type >= iegbe_82544){
++ iegbe_reset_hw(hw);
++ if (hw->mac_type >= iegbe_82544)
+ E1000_WRITE_REG(&adapter->hw, WUC, 0);
+- }
+- if(iegbe_init_hw(&adapter->hw)) {
++
++ if (iegbe_init_hw(hw))
+ DPRINTK(PROBE, ERR, "Hardware Error\n");
+- }
+-#ifdef NETIF_F_HW_VLAN_TX
+ iegbe_update_mng_vlan(adapter);
+-#endif
++
++ /* if (adapter->hwflags & HWFLAGS_PHY_PWR_BIT) { */
++ if (hw->mac_type >= iegbe_82544 &&
++ hw->mac_type <= iegbe_82547_rev_2 &&
++ hw->autoneg == 1 &&
++ hw->autoneg_advertised == ADVERTISE_1000_FULL) {
++ u32 ctrl = E1000_READ_REG(&adapter->hw, CTRL);
++ /* clear phy power management bit if we are in gig only mode,
++ * which if enabled will attempt negotiation to 100Mb, which
++ * can cause a loss of link at power off or driver unload */
++ ctrl &= ~E1000_CTRL_SWDPIN3;
++ E1000_WRITE_REG(&adapter->hw, CTRL, ctrl);
++ }
++
+ /* Enable h/w to recognize an 802.1Q VLAN Ethernet packet */
+ E1000_WRITE_REG(&adapter->hw, VET, ETHERNET_IEEE_VLAN_TYPE);
+
+- iegbe_reset_adaptive(&adapter->hw);
+- iegbe_phy_get_info(&adapter->hw, &adapter->phy_info);
+- if(adapter->en_mng_pt) {
+- manc = E1000_READ_REG(&adapter->hw, MANC);
+- manc |= (E1000_MANC_ARP_EN | E1000_MANC_EN_MNG2HOST);
+- E1000_WRITE_REG(&adapter->hw, MANC, manc);
++ iegbe_reset_adaptive(hw);
++ iegbe_phy_get_info(hw, &adapter->phy_info);
++
++ if (!adapter->smart_power_down &&
++ (hw->mac_type == iegbe_82571 ||
++ hw->mac_type == iegbe_82572)) {
++ u16 phy_data = 0;
++ /* speed up time to link by disabling smart power down, ignore
++ * the return value of this function because there is nothing
++ * different we would do if it failed */
++ iegbe_read_phy_reg(hw, IGP02E1000_PHY_POWER_MGMT,
++ &phy_data);
++ phy_data &= ~IGP02E1000_PM_SPD;
++ iegbe_write_phy_reg(hw, IGP02E1000_PHY_POWER_MGMT,
++ phy_data);
++ }
++
++}
++
++/**
++ * Dump the eeprom for users having checksum issues
++ **/
++static void iegbe_dump_eeprom(struct iegbe_adapter *adapter)
++{
++ struct net_device *netdev = adapter->netdev;
++ struct ethtool_eeprom eeprom;
++ const struct ethtool_ops *ops = netdev->ethtool_ops;
++ u8 *data;
++ int i;
++ u16 csum_old, csum_new = 0;
++
++ eeprom.len = ops->get_eeprom_len(netdev);
++ eeprom.offset = 0;
++
++ data = kmalloc(eeprom.len, GFP_KERNEL);
++ if (!data) {
++ printk(KERN_ERR "Unable to allocate memory to dump EEPROM"
++ " data\n");
++ return;
+ }
++
++ ops->get_eeprom(netdev, &eeprom, data);
++
++ csum_old = (data[EEPROM_CHECKSUM_REG * 2]) +
++ (data[EEPROM_CHECKSUM_REG * 2 + 1] << 8);
++ for (i = 0; i < EEPROM_CHECKSUM_REG * 2; i += 2)
++ csum_new += data[i] + (data[i + 1] << 8);
++ csum_new = EEPROM_SUM - csum_new;
++
++ printk(KERN_ERR "/*********************/\n");
++ printk(KERN_ERR "Current EEPROM Checksum : 0x%04x\n", csum_old);
++ printk(KERN_ERR "Calculated : 0x%04x\n", csum_new);
++
++ printk(KERN_ERR "Offset Values\n");
++ printk(KERN_ERR "======== ======\n");
++ print_hex_dump(KERN_ERR, "", DUMP_PREFIX_OFFSET, 16, 1, data, 128, 0);
++
++ printk(KERN_ERR "Include this output when contacting your support "
++ "provider.\n");
++ printk(KERN_ERR "This is not a software error! Something bad "
++ "happened to your hardware or\n");
++ printk(KERN_ERR "EEPROM image. Ignoring this "
++ "problem could result in further problems,\n");
++ printk(KERN_ERR "possibly loss of data, corruption or system hangs!\n");
++ printk(KERN_ERR "The MAC Address will be reset to 00:00:00:00:00:00, "
++ "which is invalid\n");
++ printk(KERN_ERR "and requires you to set the proper MAC "
++ "address manually before continuing\n");
++ printk(KERN_ERR "to enable this network device.\n");
++ printk(KERN_ERR "Please inspect the EEPROM dump and report the issue "
++ "to your hardware vendor\n");
++ printk(KERN_ERR "or Intel Customer Support.\n");
++ printk(KERN_ERR "/*********************/\n");
++
++ kfree(data);
+ }
+
+ /**
+@@ -721,184 +735,166 @@ iegbe_reset(struct iegbe_adapter *adapte
+ * The OS initialization, configuring of the adapter private structure,
+ * and a hardware reset occur.
+ **/
+-
+-static int __devinit
+-iegbe_probe(struct pci_dev *pdev,
++static int __devinit iegbe_probe(struct pci_dev *pdev,
+ const struct pci_device_id *ent)
+ {
+- struct net_device *netdev;
+- struct iegbe_adapter *adapter;
+- unsigned long mmio_start, mmio_len;
+- uint32_t ctrl_ext;
+- uint32_t swsm;
++ struct net_device *netdev;
++ struct iegbe_adapter *adapter;
++ struct iegbe_hw *hw;
+
+ static int cards_found = 0;
++ int i, err, pci_using_dac;
++ u16 eeprom_data = 0;
++ u16 eeprom_apme_mask = E1000_EEPROM_APME;
++ int bars;
++ DECLARE_MAC_BUF(mac);
+
+- int i, err, pci_using_dac;
+- uint16_t eeprom_data = 0;
+- uint16_t eeprom_apme_mask = E1000_EEPROM_APME;
++ bars = pci_select_bars(pdev, IORESOURCE_MEM);
++ err = pci_enable_device(pdev);
+
++ if (err)
++ return err;
+
+- if((err = pci_enable_device(pdev))) {
+- return err;
+- }
+- if(!(err = pci_set_dma_mask(pdev, PCI_DMA_64BIT))) {
++ if (!pci_set_dma_mask(pdev, DMA_64BIT_MASK) &&
++ !pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK)) {
+ pci_using_dac = 1;
+- } else {
+- if((err = pci_set_dma_mask(pdev, PCI_DMA_32BIT))) {
+- E1000_ERR("No usable DMA configuration, aborting\n");
+- return err;
+- }
++ } else {
++ err = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
++ if (err) {
++ err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
++ if (err) {
++ E1000_ERR("No usable DMA configuration, "
++ "aborting\n");
++ goto err_dma;
++ }
++ }
+ pci_using_dac = 0;
+- }
+-
+- if((err = pci_request_regions(pdev, iegbe_driver_name))) {
+- return err;
+ }
+- pci_set_master(pdev);
+
+- netdev = alloc_etherdev(sizeof(struct iegbe_adapter));
+- if(!netdev) {
+- err = -ENOMEM;
+- goto err_alloc_etherdev;
+- }
++ err = pci_request_selected_regions(pdev, bars, iegbe_driver_name);
++ if (err)
++ goto err_pci_reg;
++
++ pci_set_master(pdev);
++
++ err = -ENOMEM;
++ netdev = alloc_etherdev(sizeof(struct iegbe_adapter));
++ if (!netdev)
++ goto err_alloc_etherdev;
+
+- SET_MODULE_OWNER(netdev);
+ SET_NETDEV_DEV(netdev, &pdev->dev);
+
+- pci_set_drvdata(pdev, netdev);
+- adapter = netdev_priv(netdev);
+- adapter->netdev = netdev;
+- adapter->pdev = pdev;
+- adapter->hw.back = adapter;
+- adapter->msg_enable = (0x1 << debug) - 0x1;
+-
+- mmio_start = pci_resource_start(pdev, BAR_0);
+- mmio_len = pci_resource_len(pdev, BAR_0);
+-
+- adapter->hw.hw_addr = ioremap(mmio_start, mmio_len);
+- if(!adapter->hw.hw_addr) {
+- err = -EIO;
+- goto err_ioremap;
+- }
+-
+- for(i = BAR_1; i <= BAR_5; i++) {
+- if(pci_resource_len(pdev, i) == 0) {
+- continue;
+- }
+- if(pci_resource_flags(pdev, i) & IORESOURCE_IO) {
+- adapter->hw.io_base = pci_resource_start(pdev, i);
+- break;
+- }
+- }
+-
+- netdev->open = &iegbe_open;
+- netdev->stop = &iegbe_close;
+- netdev->hard_start_xmit = &iegbe_xmit_frame;
+- netdev->get_stats = &iegbe_get_stats;
+- netdev->set_multicast_list = &iegbe_set_multi;
++ pci_set_drvdata(pdev, netdev);
++ adapter = netdev_priv(netdev);
++ adapter->netdev = netdev;
++ adapter->pdev = pdev;
++ adapter->msg_enable = (1 << debug) - 1;
++ adapter->bars = bars;
++
++ hw = &adapter->hw;
++ hw->back = adapter;
++
++ err = -EIO;
++ hw->hw_addr = ioremap(pci_resource_start(pdev, BAR_0),
++ pci_resource_len(pdev, BAR_0));
++ if (!hw->hw_addr)
++ goto err_ioremap;
++
++ netdev->open = &iegbe_open;
++ netdev->stop = &iegbe_close;
++ netdev->hard_start_xmit = &iegbe_xmit_frame;
++ netdev->get_stats = &iegbe_get_stats;
++ netdev->set_rx_mode = &iegbe_set_rx_mode;
+ netdev->set_mac_address = &iegbe_set_mac;
+- netdev->change_mtu = &iegbe_change_mtu;
+- netdev->do_ioctl = &iegbe_ioctl;
++ netdev->change_mtu = &iegbe_change_mtu;
++ netdev->do_ioctl = &iegbe_ioctl;
+ set_ethtool_ops(netdev);
+-#ifdef HAVE_TX_TIMEOUT
+- netdev->tx_timeout = &iegbe_tx_timeout;
+- netdev->watchdog_timeo = 0x5 * HZ;
+-#endif
+-#ifdef CONFIG_E1000_NAPI
+- netdev->poll = &iegbe_clean;
+- netdev->weight = 0x40;
+-#endif
+-#ifdef NETIF_F_HW_VLAN_TX
+- netdev->vlan_rx_register = iegbe_vlan_rx_register;
+- netdev->vlan_rx_add_vid = iegbe_vlan_rx_add_vid;
+- netdev->vlan_rx_kill_vid = iegbe_vlan_rx_kill_vid;
+-#endif
++ netdev->tx_timeout = &iegbe_tx_timeout;
++ netdev->watchdog_timeo = 5 * HZ;
++ netif_napi_add(netdev, &adapter->napi, iegbe_clean, 64);
++ netdev->vlan_rx_register = iegbe_vlan_rx_register;
++ netdev->vlan_rx_add_vid = iegbe_vlan_rx_add_vid;
++ netdev->vlan_rx_kill_vid = iegbe_vlan_rx_kill_vid;
+ #ifdef CONFIG_NET_POLL_CONTROLLER
+- netdev->poll_controller = iegbe_netpoll;
++ netdev->poll_controller = iegbe_netpoll;
+ #endif
+- strcpy(netdev->name, pci_name(pdev));
++ strncpy(netdev->name, pci_name(pdev), sizeof(netdev->name) - 1);
+
+- netdev->mem_start = mmio_start;
+- netdev->mem_end = mmio_start + mmio_len;
+- netdev->base_addr = adapter->hw.io_base;
+
+- adapter->bd_number = cards_found;
++ adapter->bd_number = cards_found;
+
+- /* setup the private structure */
++ /* setup the private structure */
+
+- if((err = iegbe_sw_init(adapter))) {
+- goto err_sw_init;
+- }
+- if((err = iegbe_check_phy_reset_block(&adapter->hw))) {
+- DPRINTK(PROBE, INFO, "PHY reset is blocked due to SOL/IDER session.\n");
+- }
+-#ifdef MAX_SKB_FRAGS
+- if(adapter->hw.mac_type >= iegbe_82543) {
+-#ifdef NETIF_F_HW_VLAN_TX
+- netdev->features = NETIF_F_SG |
+- NETIF_F_HW_CSUM |
+- NETIF_F_HW_VLAN_TX |
+- NETIF_F_HW_VLAN_RX |
+- NETIF_F_HW_VLAN_FILTER;
+-#else
+- netdev->features = NETIF_F_SG | NETIF_F_HW_CSUM;
+-#endif
+- }
++ err = iegbe_sw_init(adapter);
++ if (err)
++ goto err_sw_init;
++ err = -EIO;
++ if (iegbe_check_phy_reset_block(hw))
++ DPRINTK(PROBE, INFO, "PHY reset is blocked due to SOL/IDER session.\n");
+
+-#ifdef NETIF_F_TSO
+- if((adapter->hw.mac_type >= iegbe_82544) &&
+- (adapter->hw.mac_type != iegbe_82547)) {
+- netdev->features |= NETIF_F_TSO;
+- }
+-#ifdef NETIF_F_TSO_IPV6
+- if(adapter->hw.mac_type > iegbe_82547_rev_2) {
+- netdev->features |= NETIF_F_TSO_IPV6;
+- }
+-#endif
+-#endif
+- if(pci_using_dac) {
+- netdev->features |= NETIF_F_HIGHDMA;
++ if (hw->mac_type >= iegbe_82543) {
++ netdev->features = NETIF_F_SG |
++ NETIF_F_HW_CSUM |
++ NETIF_F_HW_VLAN_TX |
++ NETIF_F_HW_VLAN_RX |
++ NETIF_F_HW_VLAN_FILTER;
+ }
+-#endif
+-#ifdef NETIF_F_LLTX
+- netdev->features |= NETIF_F_LLTX;
+-#endif
+
+- adapter->en_mng_pt = iegbe_enable_mng_pass_thru(&adapter->hw);
++ if ((hw->mac_type >= iegbe_82544) &&
++ (hw->mac_type != iegbe_82547))
++ netdev->features |= NETIF_F_TSO;
+
+- /* before reading the EEPROM, reset the controller to
+- * put the device in a known good starting state */
++ if (hw->mac_type > iegbe_82547_rev_2)
++ netdev->features |= NETIF_F_TSO6;
++ if (pci_using_dac)
++ netdev->features |= NETIF_F_HIGHDMA;
++
++ netdev->features |= NETIF_F_LLTX;
+
+- iegbe_reset_hw(&adapter->hw);
++ adapter->en_mng_pt = iegbe_enable_mng_pass_thru(hw);
+
+- /* make sure the EEPROM is good */
+- if(iegbe_validate_eeprom_checksum(&adapter->hw) < 0) {
+- DPRINTK(PROBE, ERR, "The EEPROM Checksum Is Not Valid\n");
+- err = -EIO;
++ /* initialize eeprom parameters */
++
++ if (iegbe_init_eeprom_params(hw)) {
++ E1000_ERR("EEPROM initialization failed\n");
+ goto err_eeprom;
+ }
+
+- /* copy the MAC address out of the EEPROM */
++ /* before reading the EEPROM, reset the controller to
++ * put the device in a known good starting state */
+
+- if(iegbe_read_mac_addr(&adapter->hw)) {
+- DPRINTK(PROBE, ERR, "EEPROM Read Error\n");
+- }
+- memcpy(netdev->dev_addr, adapter->hw.mac_addr, netdev->addr_len);
++ iegbe_reset_hw(hw);
+
+- if(!is_valid_ether_addr(netdev->dev_addr)) {
+- DPRINTK(PROBE, ERR, "Invalid MAC Address\n");
+- err = -EIO;
+- goto err_eeprom;
+- }
++ /* make sure the EEPROM is good */
++ if (iegbe_validate_eeprom_checksum(hw) < 0) {
++ DPRINTK(PROBE, ERR, "The EEPROM Checksum Is Not Valid\n");
++ iegbe_dump_eeprom(adapter);
++ /*
++ * set MAC address to all zeroes to invalidate and temporary
++ * disable this device for the user. This blocks regular
++ * traffic while still permitting ethtool ioctls from reaching
++ * the hardware as well as allowing the user to run the
++ * interface after manually setting a hw addr using
++ * `ip set address`
++ */
++ memset(hw->mac_addr, 0, netdev->addr_len);
++ } else {
++ /* copy the MAC address out of the EEPROM */
++ if (iegbe_read_mac_addr(hw))
++ DPRINTK(PROBE, ERR, "EEPROM Read Error\n");
++ }
++ /* don't block initalization here due to bad MAC address */
++ memcpy(netdev->dev_addr, hw->mac_addr, netdev->addr_len);
++ memcpy(netdev->perm_addr, hw->mac_addr, netdev->addr_len);
+
+- iegbe_read_part_num(&adapter->hw, &(adapter->part_num));
++ if (!is_valid_ether_addr(netdev->perm_addr))
++ DPRINTK(PROBE, ERR, "Invalid MAC Address\n");
+
+- iegbe_get_bus_info(&adapter->hw);
++ iegbe_get_bus_info(hw);
+
+ init_timer(&adapter->tx_fifo_stall_timer);
+ adapter->tx_fifo_stall_timer.function = &iegbe_82547_tx_fifo_stall;
+- adapter->tx_fifo_stall_timer.data = (unsigned long) adapter;
++ adapter->tx_fifo_stall_timer.data = (unsigned long)adapter;
+
+ init_timer(&adapter->watchdog_timer);
+ adapter->watchdog_timer.function = &iegbe_watchdog;
+@@ -906,75 +902,50 @@ iegbe_probe(struct pci_dev *pdev,
+
+ init_timer(&adapter->phy_info_timer);
+ adapter->phy_info_timer.function = &iegbe_update_phy_info;
+- adapter->phy_info_timer.data = (unsigned long) adapter;
+-
+- INIT_WORK(&adapter->tx_timeout_task,
+- (void (*)(void *))iegbe_tx_timeout_task, netdev);
++ adapter->phy_info_timer.data = (unsigned long)adapter;
+
+- /* we're going to reset, so assume we have no link for now */
+-
+- netif_carrier_off(netdev);
+- netif_stop_queue(netdev);
++ INIT_WORK(&adapter->reset_task, iegbe_reset_task);
+
+- iegbe_check_options(adapter);
++ iegbe_check_options(adapter);
+
+- /* Initial Wake on LAN setting
+- * If APM wake is enabled in the EEPROM,
+- * enable the ACPI Magic Packet filter
+- */
++ /* Initial Wake on LAN setting
++ * If APM wake is enabled in the EEPROM,
++ * enable the ACPI Magic Packet filter
++ */
+
+- switch(adapter->hw.mac_type) {
+- case iegbe_82542_rev2_0:
+- case iegbe_82542_rev2_1:
+- case iegbe_82543:
+- break;
+- case iegbe_82544:
+- iegbe_read_eeprom(&adapter->hw,
+- EEPROM_INIT_CONTROL2_REG, 1, &eeprom_data);
+- eeprom_apme_mask = E1000_EEPROM_82544_APM;
+- break;
++ switch(adapter->hw.mac_type) {
++ case iegbe_82542_rev2_0:
++ case iegbe_82542_rev2_1:
++ case iegbe_82543:
++ break;
++ case iegbe_82544:
++ iegbe_read_eeprom(&adapter->hw,
++ EEPROM_INIT_CONTROL2_REG, 1, &eeprom_data);
++ eeprom_apme_mask = E1000_EEPROM_82544_APM;
++ break;
+ case iegbe_icp_xxxx:
+- iegbe_read_eeprom(&adapter->hw,
+- EEPROM_INIT_CONTROL3_ICP_xxxx(adapter->bd_number),
+- 1, &eeprom_data);
+- eeprom_apme_mask = EEPROM_CTRL3_APME_ICP_xxxx;
+- break;
+- case iegbe_82546:
+- case iegbe_82546_rev_3:
+- if((E1000_READ_REG(&adapter->hw, STATUS) & E1000_STATUS_FUNC_1)
+- && (adapter->hw.media_type == iegbe_media_type_copper)) {
+- iegbe_read_eeprom(&adapter->hw,
+- EEPROM_INIT_CONTROL3_PORT_B, 1, &eeprom_data);
+- break;
+- }
+- /* Fall Through */
+- default:
+- iegbe_read_eeprom(&adapter->hw,
+- EEPROM_INIT_CONTROL3_PORT_A, 1, &eeprom_data);
+- break;
+- }
++ iegbe_read_eeprom(&adapter->hw,
++ EEPROM_INIT_CONTROL3_ICP_xxxx(adapter->bd_number),
++ 1, &eeprom_data);
++ eeprom_apme_mask = EEPROM_CTRL3_APME_ICP_xxxx;
++ break;
++ case iegbe_82546:
++ case iegbe_82546_rev_3:
++ if((E1000_READ_REG(&adapter->hw, STATUS) & E1000_STATUS_FUNC_1)
++ && (adapter->hw.media_type == iegbe_media_type_copper)) {
++ iegbe_read_eeprom(&adapter->hw,
++ EEPROM_INIT_CONTROL3_PORT_B, 1, &eeprom_data);
++ break;
++ }
++ /* Fall Through */
++ default:
++ iegbe_read_eeprom(&adapter->hw,
++ EEPROM_INIT_CONTROL3_PORT_A, 1, &eeprom_data);
++ break;
++ }
+ if(eeprom_data & eeprom_apme_mask) {
+- adapter->wol |= E1000_WUFC_MAG;
++ adapter->wol |= E1000_WUFC_MAG;
+ }
+- /* reset the hardware with the new settings */
+- iegbe_reset(adapter);
+-
+- /* Let firmware know the driver has taken over */
+- switch(adapter->hw.mac_type) {
+- case iegbe_82571:
+- case iegbe_82572:
+- ctrl_ext = E1000_READ_REG(&adapter->hw, CTRL_EXT);
+- E1000_WRITE_REG(&adapter->hw, CTRL_EXT,
+- ctrl_ext | E1000_CTRL_EXT_DRV_LOAD);
+- break;
+- case iegbe_82573:
+- swsm = E1000_READ_REG(&adapter->hw, SWSM);
+- E1000_WRITE_REG(&adapter->hw, SWSM,
+- swsm | E1000_SWSM_DRV_LOAD);
+- break;
+- default:
+- break;
+- }
+
+ /* The ICP_xxxx device has multiple, duplicate interrupt
+ * registers, so disable all but the first one
+@@ -987,24 +958,40 @@ iegbe_probe(struct pci_dev *pdev,
+ E1000_WRITE_REG(&adapter->hw, IMC2, ~0UL);
+ }
+
+- strcpy(netdev->name, "eth%d");
+- if((err = register_netdev(netdev))) {
+- goto err_register;
+- }
++ iegbe_reset(adapter);
++ netif_carrier_off(netdev);
++ netif_stop_queue(netdev);
++ strcpy(netdev->name, "eth%d");
++ err = register_netdev(netdev);
++ if (err)
++ goto err_register;
++
+ DPRINTK(PROBE, INFO, "Intel(R) PRO/1000 Network Connection\n");
+
+- cards_found++;
+- return 0;
++ cards_found++;
++ return 0;
+
+ err_register:
+-err_sw_init:
+ err_eeprom:
+- iounmap(adapter->hw.hw_addr);
++ if (!iegbe_check_phy_reset_block(hw))
++ iegbe_phy_hw_reset(hw);
++ if (hw->flash_address)
++ iounmap(hw->flash_address);
++ for (i = 0; i < adapter->num_rx_queues; i++)
++ dev_put(&adapter->polling_netdev[i]);
++ kfree(adapter->tx_ring);
++ kfree(adapter->rx_ring);
++ kfree(adapter->polling_netdev);
++err_sw_init:
++ iounmap(hw->hw_addr);
+ err_ioremap:
+- free_netdev(netdev);
++ free_netdev(netdev);
+ err_alloc_etherdev:
+- pci_release_regions(pdev);
+- return err;
++ pci_release_selected_regions(pdev, bars);
++err_pci_reg:
++err_dma:
++ pci_disable_device(pdev);
++ return err;
+ }
+
+ /**
+@@ -1020,64 +1007,36 @@ err_alloc_etherdev:
+ static void __devexit
+ iegbe_remove(struct pci_dev *pdev)
+ {
+- struct net_device *netdev = pci_get_drvdata(pdev);
+- struct iegbe_adapter *adapter = netdev_priv(netdev);
+- uint32_t ctrl_ext;
+- uint32_t manc, swsm;
+-#ifdef CONFIG_E1000_NAPI
+- int i;
+-#endif
+-
+- if(adapter->hw.mac_type >= iegbe_82540
+- && adapter->hw.mac_type != iegbe_icp_xxxx
+- && adapter->hw.media_type == iegbe_media_type_copper) {
+- manc = E1000_READ_REG(&adapter->hw, MANC);
+- if(manc & E1000_MANC_SMBUS_EN) {
+- manc |= E1000_MANC_ARP_EN;
+- E1000_WRITE_REG(&adapter->hw, MANC, manc);
+- }
+- }
+-
+- switch(adapter->hw.mac_type) {
+- case iegbe_82571:
+- case iegbe_82572:
+- ctrl_ext = E1000_READ_REG(&adapter->hw, CTRL_EXT);
+- E1000_WRITE_REG(&adapter->hw, CTRL_EXT,
+- ctrl_ext & ~E1000_CTRL_EXT_DRV_LOAD);
+- break;
+- case iegbe_82573:
+- swsm = E1000_READ_REG(&adapter->hw, SWSM);
+- E1000_WRITE_REG(&adapter->hw, SWSM,
+- swsm & ~E1000_SWSM_DRV_LOAD);
+- break;
+-
+- default:
+- break;
+- }
++ struct net_device *netdev = pci_get_drvdata(pdev);
++ struct iegbe_adapter *adapter = netdev_priv(netdev);
++ uint32_t manc;
++ int i;
++
++ if(adapter->hw.mac_type >= iegbe_82540
++ && adapter->hw.mac_type != iegbe_icp_xxxx
++ && adapter->hw.media_type == iegbe_media_type_copper) {
++ manc = E1000_READ_REG(&adapter->hw, MANC);
++ if(manc & E1000_MANC_SMBUS_EN) {
++ manc |= E1000_MANC_ARP_EN;
++ E1000_WRITE_REG(&adapter->hw, MANC, manc);
++ }
++ }
+
+- unregister_netdev(netdev);
+-#ifdef CONFIG_E1000_NAPI
+- for (i = 0; i < adapter->num_queues; i++)
++ unregister_netdev(netdev);
++ for (i = 0x0; i < adapter->num_rx_queues; i++)
+ dev_put(&adapter->polling_netdev[i]);
+-#endif
+
+ if(!iegbe_check_phy_reset_block(&adapter->hw)) {
+- iegbe_phy_hw_reset(&adapter->hw);
++ iegbe_phy_hw_reset(&adapter->hw);
+ }
+- kfree(adapter->tx_ring);
+- kfree(adapter->rx_ring);
+-#ifdef CONFIG_E1000_NAPI
+- kfree(adapter->polling_netdev);
+-#endif
++ kfree(adapter->tx_ring);
++ kfree(adapter->rx_ring);
++ kfree(adapter->polling_netdev);
+
+- iounmap(adapter->hw.hw_addr);
+- pci_release_regions(pdev);
++ iounmap(adapter->hw.hw_addr);
++ pci_release_regions(pdev);
+
+-#ifdef CONFIG_E1000_MQ
+- free_percpu(adapter->cpu_netdev);
+- free_percpu(adapter->cpu_tx_ring);
+-#endif
+- free_netdev(netdev);
++ free_netdev(netdev);
+ }
+
+ /**
+@@ -1092,118 +1051,78 @@ iegbe_remove(struct pci_dev *pdev)
+ static int __devinit
+ iegbe_sw_init(struct iegbe_adapter *adapter)
+ {
+- struct iegbe_hw *hw = &adapter->hw;
+- struct net_device *netdev = adapter->netdev;
+- struct pci_dev *pdev = adapter->pdev;
+-#ifdef CONFIG_E1000_NAPI
+- int i;
+-#endif
++ struct iegbe_hw *hw = &adapter->hw;
++ struct net_device *netdev = adapter->netdev;
++ struct pci_dev *pdev = adapter->pdev;
++ int i;
+
+- /* PCI config space info */
++ /* PCI config space info */
+
+- hw->vendor_id = pdev->vendor;
+- hw->device_id = pdev->device;
+- hw->subsystem_vendor_id = pdev->subsystem_vendor;
+- hw->subsystem_id = pdev->subsystem_device;
++ hw->vendor_id = pdev->vendor;
++ hw->device_id = pdev->device;
++ hw->subsystem_vendor_id = pdev->subsystem_vendor;
++ hw->subsystem_id = pdev->subsystem_device;
+
+- pci_read_config_byte(pdev, PCI_REVISION_ID, &hw->revision_id);
++ pci_read_config_byte(pdev, PCI_REVISION_ID, &hw->revision_id);
+
+- pci_read_config_word(pdev, PCI_COMMAND, &hw->pci_cmd_word);
++ pci_read_config_word(pdev, PCI_COMMAND, &hw->pci_cmd_word);
+
+- adapter->rx_buffer_len = E1000_RXBUFFER_2048;
+- adapter->rx_ps_bsize0 = E1000_RXBUFFER_256;
+- hw->max_frame_size = netdev->mtu +
+- ENET_HEADER_SIZE + ETHERNET_FCS_SIZE;
+- hw->min_frame_size = MINIMUM_ETHERNET_FRAME_SIZE;
++ adapter->rx_buffer_len = E1000_RXBUFFER_2048;
++ adapter->rx_ps_bsize0 = E1000_RXBUFFER_256;
++ hw->max_frame_size = netdev->mtu +
++ ENET_HEADER_SIZE + ETHERNET_FCS_SIZE;
++ hw->min_frame_size = MINIMUM_ETHERNET_FRAME_SIZE;
+
+- /* identify the MAC */
++ /* identify the MAC */
+
+- if(iegbe_set_mac_type(hw)) {
++ if (iegbe_set_mac_type(hw)) {
+ DPRINTK(PROBE, ERR, "Unknown MAC Type\n");
+ return -EIO;
+ }
+
+- /* initialize eeprom parameters */
+-
+- if(iegbe_init_eeprom_params(hw)) {
+- E1000_ERR("EEPROM initialization failed\n");
+- return -EIO;
+- }
+-
+- switch(hw->mac_type) {
+- default:
+- break;
+- case iegbe_82541:
+- case iegbe_82547:
+- case iegbe_82541_rev_2:
+- case iegbe_82547_rev_2:
+- hw->phy_init_script = 0x1;
+- break;
+- }
+-
+- iegbe_set_media_type(hw);
++ iegbe_set_media_type(hw);
+
+- hw->wait_autoneg_complete = FALSE;
+- hw->tbi_compatibility_en = TRUE;
+- hw->adaptive_ifs = TRUE;
++ hw->wait_autoneg_complete = FALSE;
++ hw->tbi_compatibility_en = TRUE;
++ hw->adaptive_ifs = TRUE;
+
+- /* Copper options */
++ /* Copper options */
+
+- if(hw->media_type == iegbe_media_type_copper
++ if(hw->media_type == iegbe_media_type_copper
+ || (hw->media_type == iegbe_media_type_oem
+ && iegbe_oem_phy_is_copper(&adapter->hw))) {
+- hw->mdix = AUTO_ALL_MODES;
+- hw->disable_polarity_correction = FALSE;
+- hw->master_slave = E1000_MASTER_SLAVE;
+- }
++ hw->mdix = AUTO_ALL_MODES;
++ hw->disable_polarity_correction = FALSE;
++ hw->master_slave = E1000_MASTER_SLAVE;
++ }
+
+-#ifdef CONFIG_E1000_MQ
+- /* Number of supported queues */
+- switch (hw->mac_type) {
+- case iegbe_82571:
+- case iegbe_82572:
+- adapter->num_queues = 0x2;
+- break;
+- default:
+- adapter->num_queues = 0x1;
+- break;
+- }
+- adapter->num_queues = min(adapter->num_queues, num_online_cpus());
+-#else
+- adapter->num_queues = 0x1;
+-#endif
++ adapter->num_tx_queues = 0x1;
++ adapter->num_rx_queues = 0x1;
+
+ if (iegbe_alloc_queues(adapter)) {
+ DPRINTK(PROBE, ERR, "Unable to allocate memory for queues\n");
+ return -ENOMEM;
+ }
+
+-#ifdef CONFIG_E1000_NAPI
+- for (i = 0; i < adapter->num_queues; i++) {
++ for (i = 0; i < adapter->num_rx_queues; i++) {
+ adapter->polling_netdev[i].priv = adapter;
+- adapter->polling_netdev[i].poll = &iegbe_clean;
+- adapter->polling_netdev[i].weight = 0x40;
+ dev_hold(&adapter->polling_netdev[i]);
+ set_bit(__LINK_STATE_START, &adapter->polling_netdev[i].state);
+ }
+-#endif
+-
+-#ifdef CONFIG_E1000_MQ
+- iegbe_setup_queue_mapping(adapter);
+-#endif
++ spin_lock_init(&adapter->tx_queue_lock);
+
+ /*
+- * for ICP_XXXX style controllers, it is necessary to keep
+- * track of the last known state of the link to determine if
+- * the link experienced a change in state when iegbe_watchdog
+- * fires
+- */
+- adapter->hw.icp_xxxx_is_link_up = FALSE;
++ * for ICP_XXXX style controllers, it is necessary to keep
++ * track of the last known state of the link to determine if
++ * the link experienced a change in state when iegbe_watchdog
++ * fires
++ */
++ adapter->hw.icp_xxxx_is_link_up = FALSE;
+
+- atomic_set(&adapter->irq_sem, 1);
+- spin_lock_init(&adapter->stats_lock);
++ spin_lock_init(&adapter->stats_lock);
+
+- return 0;
++ set_bit(__E1000_DOWN, &adapter->flags);
++ return 0x0;
+ }
+
+ /**
+@@ -1218,71 +1137,31 @@ iegbe_sw_init(struct iegbe_adapter *adap
+ static int __devinit
+ iegbe_alloc_queues(struct iegbe_adapter *adapter)
+ {
+- int size;
+
+- size = sizeof(struct iegbe_tx_ring) * adapter->num_queues;
+- adapter->tx_ring = kmalloc(size, GFP_KERNEL);
+- if (!adapter->tx_ring){
++
++ adapter->tx_ring = kcalloc(adapter->num_tx_queues,
++ sizeof(struct iegbe_tx_ring), GFP_KERNEL);
++ if (!adapter->tx_ring)
+ return -ENOMEM;
+- }
+- memset(adapter->tx_ring, 0, size);
+
+- size = sizeof(struct iegbe_rx_ring) * adapter->num_queues;
+- adapter->rx_ring = kmalloc(size, GFP_KERNEL);
++ adapter->rx_ring = kcalloc(adapter->num_rx_queues,
++ sizeof(struct iegbe_rx_ring), GFP_KERNEL);
+ if (!adapter->rx_ring) {
+ kfree(adapter->tx_ring);
+ return -ENOMEM;
+ }
+- memset(adapter->rx_ring, 0, size);
+
+-#ifdef CONFIG_E1000_NAPI
+- size = sizeof(struct net_device) * adapter->num_queues;
+- adapter->polling_netdev = kmalloc(size, GFP_KERNEL);
++ adapter->polling_netdev = kcalloc(adapter->num_rx_queues,
++ sizeof(struct net_device),
++ GFP_KERNEL);
+ if (!adapter->polling_netdev) {
+ kfree(adapter->tx_ring);
+ kfree(adapter->rx_ring);
+ return -ENOMEM;
+ }
+- memset(adapter->polling_netdev, 0, size);
+-#endif
+-
+- return E1000_SUCCESS;
+-}
+
+-#ifdef CONFIG_E1000_MQ
+-static void __devinit
+-iegbe_setup_queue_mapping(struct iegbe_adapter *adapter)
+-{
+- int i, cpu;
+-
+- adapter->rx_sched_call_data.func = iegbe_rx_schedule;
+- adapter->rx_sched_call_data.info = adapter->netdev;
+- cpus_clear(adapter->rx_sched_call_data.cpumask);
+-
+- adapter->cpu_netdev = alloc_percpu(struct net_device *);
+- adapter->cpu_tx_ring = alloc_percpu(struct iegbe_tx_ring *);
+-
+- lock_cpu_hotplug();
+- i = 0;
+- for_each_online_cpu(cpu) {
+- *per_cpu_ptr(adapter->cpu_tx_ring, cpu) =
+- &adapter->tx_ring[i % adapter->num_queues];
+- /* This is incomplete because we'd like to assign separate
+- * physical cpus to these netdev polling structures and
+- * avoid saturating a subset of cpus.
+- */
+- if (i < adapter->num_queues) {
+- *per_cpu_ptr(adapter->cpu_netdev, cpu) =
+- &adapter->polling_netdev[i];
+- adapter->cpu_for_queue[i] = cpu;
+- } else {
+- *per_cpu_ptr(adapter->cpu_netdev, cpu) = NULL;
+- }
+- i++;
+- }
+- unlock_cpu_hotplug();
++ return E1000_SUCCESS;
+ }
+-#endif
+
+ /**
+ * iegbe_open - Called when a network interface is made active
+@@ -1300,40 +1179,62 @@ iegbe_setup_queue_mapping(struct iegbe_a
+ static int
+ iegbe_open(struct net_device *netdev)
+ {
+- struct iegbe_adapter *adapter = netdev_priv(netdev);
+- int err;
++ struct iegbe_adapter *adapter = netdev_priv(netdev);
++ struct iegbe_hw *hw = &adapter->hw;
++ int err;
++
+
++ /* allocate receive descriptors */
++ if (test_bit(__E1000_TESTING, &adapter->flags))
++ return -EBUSY;
+
+- /* allocate receive descriptors */
++ /* allocate transmit descriptors */
++ err = iegbe_setup_all_tx_resources(adapter);
++ if (err)
++ goto err_setup_tx;
+
+- if ((err = iegbe_setup_all_rx_resources(adapter))) {
++ err = iegbe_setup_all_rx_resources(adapter);
++ if (err)
+ goto err_setup_rx;
+- }
+- /* allocate transmit descriptors */
+- if ((err = iegbe_setup_all_tx_resources(adapter))) {
+- goto err_setup_tx;
+- }
+- if ((err = iegbe_up(adapter))) {
+- goto err_up;
+- }
+-#ifdef NETIF_F_HW_VLAN_TX
+- adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
+- if ((adapter->hw.mng_cookie.status &
+- E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT)) {
+- iegbe_update_mng_vlan(adapter);
+- }
+-#endif
+
+- return E1000_SUCCESS;
++ iegbe_power_up_phy(adapter);
++ adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
++ if ((hw->mng_cookie.status &
++ E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT)) {
++ iegbe_update_mng_vlan(adapter);
++ }
++
++ /* before we allocate an interrupt, we must be ready to handle it.
++ * Setting DEBUG_SHIRQ in the kernel makes it fire an interrupt
++ * as soon as we call pci_request_irq, so we have to setup our
++ * clean_rx handler before we do so. */
++ iegbe_configure(adapter);
++ err = iegbe_request_irq(adapter);
++ if (err)
++ goto err_req_irq;
+
+-err_up:
+- iegbe_free_all_tx_resources(adapter);
+-err_setup_tx:
+- iegbe_free_all_rx_resources(adapter);
++ /* From here on the code is the same as iegbe_up() */
++ clear_bit(__E1000_DOWN, &adapter->flags);
++
++ napi_enable(&adapter->napi);
++
++ iegbe_irq_enable(adapter);
++
++ netif_start_queue(netdev);
++
++ /* fire a link status change interrupt to start the watchdog */
++
++ return E1000_SUCCESS;
++
++err_req_irq:
++ iegbe_power_down_phy(adapter);
++ iegbe_free_all_rx_resources(adapter);
+ err_setup_rx:
+- iegbe_reset(adapter);
++ iegbe_free_all_tx_resources(adapter);
++err_setup_tx:
++ iegbe_reset(adapter);
+
+- return err;
++ return err;
+ }
+
+ /**
+@@ -1348,22 +1249,25 @@ err_setup_rx:
+ * hardware, and all transmit and receive resources are freed.
+ **/
+
+-static int
+-iegbe_close(struct net_device *netdev)
++static int iegbe_close(struct net_device *netdev)
+ {
+- struct iegbe_adapter *adapter = netdev_priv(netdev);
+-
+- iegbe_down(adapter);
+-
+- iegbe_free_all_tx_resources(adapter);
+- iegbe_free_all_rx_resources(adapter);
++ struct iegbe_adapter *adapter = netdev_priv(netdev);
++ struct iegbe_hw *hw = &adapter->hw;
+
+-#ifdef NETIF_F_HW_VLAN_TX
+- if((adapter->hw.mng_cookie.status &
+- E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT)) {
++ WARN_ON(test_bit(__E1000_RESETTING, &adapter->flags));
++ iegbe_down(adapter);
++ iegbe_power_down_phy(adapter);
++ iegbe_free_irq(adapter);
++
++ iegbe_free_all_tx_resources(adapter);
++ iegbe_free_all_rx_resources(adapter);
++
++ if ((hw->mng_cookie.status &
++ E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) &&
++ !(adapter->vlgrp &&
++ vlan_group_get_device(adapter->vlgrp, adapter->mng_vlan_id))) {
+ iegbe_vlan_rx_kill_vid(netdev, adapter->mng_vlan_id);
+ }
+-#endif
+ return 0;
+ }
+
+@@ -1375,19 +1279,19 @@ iegbe_close(struct net_device *netdev)
+ **/
+ static inline boolean_t
+ iegbe_check_64k_bound(struct iegbe_adapter *adapter,
+- void *start, unsigned long len)
++ void *start, unsigned long len)
+ {
+- unsigned long begin = (unsigned long) start;
+- unsigned long end = begin + len;
++ unsigned long begin = (unsigned long) start;
++ unsigned long end = begin + len;
+
+- /* First rev 82545 and 82546 need to not allow any memory
+- * write location to cross 64k boundary due to errata 23 */
+- if(adapter->hw.mac_type == iegbe_82545 ||
+- adapter->hw.mac_type == iegbe_82546) {
+- return ((begin ^ (end - 1)) >> 0x10) != 0 ? FALSE : TRUE;
+- }
++ /* First rev 82545 and 82546 need to not allow any memory
++ * write location to cross 64k boundary due to errata 23 */
++ if(adapter->hw.mac_type == iegbe_82545 ||
++ adapter->hw.mac_type == iegbe_82546) {
++ return ((begin ^ (end - 1)) >> 0x10) != 0x0 ? FALSE : TRUE;
++ }
+
+- return TRUE;
++ return TRUE;
+ }
+
+ /**
+@@ -1398,102 +1302,98 @@ iegbe_check_64k_bound(struct iegbe_adapt
+ * Return 0 on success, negative on failure
+ **/
+
+-int
+-iegbe_setup_tx_resources(struct iegbe_adapter *adapter,
++static int iegbe_setup_tx_resources(struct iegbe_adapter *adapter,
+ struct iegbe_tx_ring *txdr)
+ {
+- struct pci_dev *pdev = adapter->pdev;
+- int size;
++ struct pci_dev *pdev = adapter->pdev;
++ int size;
+
+- size = sizeof(struct iegbe_buffer) * txdr->count;
+- txdr->buffer_info = vmalloc(size);
+- if (!txdr->buffer_info) {
+- DPRINTK(PROBE, ERR,
+- "Unable to allocate memory for the transmit descriptor ring\n");
+- return -ENOMEM;
+- }
++ size = sizeof(struct iegbe_buffer) * txdr->count;
++ txdr->buffer_info = vmalloc(size);
++ if (!txdr->buffer_info) {
++ DPRINTK(PROBE, ERR,
++ "Unable to allocate memory for the transmit descriptor ring\n");
++ return -ENOMEM;
++ }
+ memset(txdr->buffer_info, 0, size);
+- memset(&txdr->previous_buffer_info, 0, sizeof(struct iegbe_buffer));
+
+- /* round up to nearest 4K */
++ /* round up to nearest 4K */
+
+- txdr->size = txdr->count * sizeof(struct iegbe_tx_desc);
+- E1000_ROUNDUP(txdr->size, 0x1000);
++ txdr->size = txdr->count * sizeof(struct iegbe_tx_desc);
++ txdr->size = ALIGN(txdr->size, 4096);
+
+- txdr->desc = pci_alloc_consistent(pdev, txdr->size, &txdr->dma);
+- if (!txdr->desc) {
++ txdr->desc = pci_alloc_consistent(pdev, txdr->size, &txdr->dma);
++ if (!txdr->desc) {
+ setup_tx_desc_die:
+- vfree(txdr->buffer_info);
+- DPRINTK(PROBE, ERR,
+- "Unable to allocate memory for the transmit descriptor ring\n");
+- return -ENOMEM;
+- }
+-
+- /* Fix for errata 23, can't cross 64kB boundary */
+- if (!iegbe_check_64k_bound(adapter, txdr->desc, txdr->size)) {
+- void *olddesc = txdr->desc;
+- dma_addr_t olddma = txdr->dma;
+- DPRINTK(TX_ERR, ERR, "txdr align check failed: %u bytes "
+- "at %p\n", txdr->size, txdr->desc);
+- /* Try again, without freeing the previous */
+- txdr->desc = pci_alloc_consistent(pdev, txdr->size, &txdr->dma);
+- /* Failed allocation, critical failure */
+- if (!txdr->desc) {
+- pci_free_consistent(pdev, txdr->size, olddesc, olddma);
+- goto setup_tx_desc_die;
+- }
++ vfree(txdr->buffer_info);
++ DPRINTK(PROBE, ERR,
++ "Unable to allocate memory for the transmit descriptor ring\n");
++ return -ENOMEM;
++ }
++
++ /* Fix for errata 23, can't cross 64kB boundary */
++ if (!iegbe_check_64k_bound(adapter, txdr->desc, txdr->size)) {
++ void *olddesc = txdr->desc;
++ dma_addr_t olddma = txdr->dma;
++ DPRINTK(TX_ERR, ERR, "txdr align check failed: %u bytes "
++ "at %p\n", txdr->size, txdr->desc);
++ /* Try again, without freeing the previous */
++ txdr->desc = pci_alloc_consistent(pdev, txdr->size, &txdr->dma);
++ /* Failed allocation, critical failure */
++ if (!txdr->desc) {
++ pci_free_consistent(pdev, txdr->size, olddesc, olddma);
++ goto setup_tx_desc_die;
++ }
+
+- if (!iegbe_check_64k_bound(adapter, txdr->desc, txdr->size)) {
+- /* give up */
+- pci_free_consistent(pdev, txdr->size, txdr->desc,
+- txdr->dma);
+- pci_free_consistent(pdev, txdr->size, olddesc, olddma);
+- DPRINTK(PROBE, ERR,
+- "Unable to allocate aligned memory "
+- "for the transmit descriptor ring\n");
+- vfree(txdr->buffer_info);
+- return -ENOMEM;
+- } else {
+- /* Free old allocation, new allocation was successful */
+- pci_free_consistent(pdev, txdr->size, olddesc, olddma);
+- }
+- }
++ if (!iegbe_check_64k_bound(adapter, txdr->desc, txdr->size)) {
++ /* give up */
++ pci_free_consistent(pdev, txdr->size, txdr->desc,
++ txdr->dma);
++ pci_free_consistent(pdev, txdr->size, olddesc, olddma);
++ DPRINTK(PROBE, ERR,
++ "Unable to allocate aligned memory "
++ "for the transmit descriptor ring\n");
++ vfree(txdr->buffer_info);
++ return -ENOMEM;
++ } else {
++ /* Free old allocation, new allocation was successful */
++ pci_free_consistent(pdev, txdr->size, olddesc, olddma);
++ }
++ }
+ memset(txdr->desc, 0, txdr->size);
+
+ txdr->next_to_use = 0;
+ txdr->next_to_clean = 0;
+- spin_lock_init(&txdr->tx_lock);
++ spin_lock_init(&txdr->tx_lock);
+
+ return 0;
+ }
+
+ /**
+ * iegbe_setup_all_tx_resources - wrapper to allocate Tx resources
+- * (Descriptors) for all queues
++ * (Descriptors) for all queues
+ * @adapter: board private structure
+ *
+- * If this function returns with an error, then it's possible one or
+- * more of the rings is populated (while the rest are not). It is the
+- * callers duty to clean those orphaned rings.
+- *
+ * Return 0 on success, negative on failure
+ **/
+
+-int
+-iegbe_setup_all_tx_resources(struct iegbe_adapter *adapter)
++int iegbe_setup_all_tx_resources(struct iegbe_adapter *adapter)
+ {
+ int i, err = 0;
+
+- for (i = 0; i < adapter->num_queues; i++) {
++ for (i = 0; i < adapter->num_tx_queues; i++) {
+ err = iegbe_setup_tx_resources(adapter, &adapter->tx_ring[i]);
+ if (err) {
+ DPRINTK(PROBE, ERR,
+ "Allocation for Tx Queue %u failed\n", i);
++ for (i-- ; i >= 0; i--)
++ iegbe_free_tx_resources(adapter,
++ &adapter->tx_ring[i]);
+ break;
+ }
+ }
+
+- return err;
++ return err;
+ }
+
+ /**
+@@ -1512,113 +1412,108 @@ iegbe_configure_tx(struct iegbe_adapter
+
+ /* Setup the HW Tx Head and Tail descriptor pointers */
+
+- switch (adapter->num_queues) {
++ switch (adapter->num_tx_queues) {
+ case 0x2:
+ tdba = adapter->tx_ring[0x1].dma;
+ tdlen = adapter->tx_ring[0x1].count *
+- sizeof(struct iegbe_tx_desc);
+- E1000_WRITE_REG(hw, TDBAL1, (tdba & 0x00000000ffffffffULL));
++ sizeof(struct iegbe_tx_desc);
++ E1000_WRITE_REG(hw, TDBAL1, (tdba & 0x00000000ffffffffULL));
+ E1000_WRITE_REG(hw, TDBAH1, (tdba >> 0x20));
+- E1000_WRITE_REG(hw, TDLEN1, tdlen);
+- E1000_WRITE_REG(hw, TDH1, 0);
+- E1000_WRITE_REG(hw, TDT1, 0);
++ E1000_WRITE_REG(hw, TDLEN1, tdlen);
++ E1000_WRITE_REG(hw, TDH1, 0x0);
++ E1000_WRITE_REG(hw, TDT1, 0x0);
+ adapter->tx_ring[0x1].tdh = E1000_TDH1;
+ adapter->tx_ring[0x1].tdt = E1000_TDT1;
+- /* Fall Through */
++ /* Fall Through */
+ case 0x1:
+- default:
+- tdba = adapter->tx_ring[0].dma;
+- tdlen = adapter->tx_ring[0].count *
+- sizeof(struct iegbe_tx_desc);
+- E1000_WRITE_REG(hw, TDBAL, (tdba & 0x00000000ffffffffULL));
++ default:
++ tdba = adapter->tx_ring[0x0].dma;
++ tdlen = adapter->tx_ring[0x0].count *
++ sizeof(struct iegbe_tx_desc);
++ E1000_WRITE_REG(hw, TDBAL, (tdba & 0x00000000ffffffffULL));
+ E1000_WRITE_REG(hw, TDBAH, (tdba >> 0x20));
+- E1000_WRITE_REG(hw, TDLEN, tdlen);
+- E1000_WRITE_REG(hw, TDH, 0);
+- E1000_WRITE_REG(hw, TDT, 0);
+- adapter->tx_ring[0].tdh = E1000_TDH;
+- adapter->tx_ring[0].tdt = E1000_TDT;
+- break;
+- }
+-
+- /* Set the default values for the Tx Inter Packet Gap timer */
+-
+- switch (hw->mac_type) {
+- case iegbe_82542_rev2_0:
+- case iegbe_82542_rev2_1:
+- tipg = DEFAULT_82542_TIPG_IPGT;
+- tipg |= DEFAULT_82542_TIPG_IPGR1 << E1000_TIPG_IPGR1_SHIFT;
+- tipg |= DEFAULT_82542_TIPG_IPGR2 << E1000_TIPG_IPGR2_SHIFT;
+- break;
+- default:
+- switch(hw->media_type) {
+- case iegbe_media_type_fiber:
+- case iegbe_media_type_internal_serdes:
+- tipg = DEFAULT_82543_TIPG_IPGT_FIBER;
+- break;
+- case iegbe_media_type_copper:
+- tipg = DEFAULT_82543_TIPG_IPGT_COPPER;
+- break;
+- case iegbe_media_type_oem:
+- default:
++ E1000_WRITE_REG(hw, TDLEN, tdlen);
++ E1000_WRITE_REG(hw, TDH, 0x0);
++ E1000_WRITE_REG(hw, TDT, 0x0);
++ adapter->tx_ring[0x0].tdh = E1000_TDH;
++ adapter->tx_ring[0x0].tdt = E1000_TDT;
++ break;
++ }
++
++ /* Set the default values for the Tx Inter Packet Gap timer */
++
++ switch (hw->mac_type) {
++ case iegbe_82542_rev2_0:
++ case iegbe_82542_rev2_1:
++ tipg = DEFAULT_82542_TIPG_IPGT;
++ tipg |= DEFAULT_82542_TIPG_IPGR1 << E1000_TIPG_IPGR1_SHIFT;
++ tipg |= DEFAULT_82542_TIPG_IPGR2 << E1000_TIPG_IPGR2_SHIFT;
++ break;
++ default:
++ switch(hw->media_type) {
++ case iegbe_media_type_fiber:
++ case iegbe_media_type_internal_serdes:
++ tipg = DEFAULT_82543_TIPG_IPGT_FIBER;
++ break;
++ case iegbe_media_type_copper:
++ tipg = DEFAULT_82543_TIPG_IPGT_COPPER;
++ break;
++ case iegbe_media_type_oem:
++ default:
+ tipg = (0xFFFFFFFFUL >> (sizeof(tipg)*0x8 -
+ E1000_TIPG_IPGR1_SHIFT))
+- & iegbe_oem_get_tipg(&adapter->hw);
+- break;
+- }
+- tipg |= DEFAULT_82543_TIPG_IPGR1 << E1000_TIPG_IPGR1_SHIFT;
+- tipg |= DEFAULT_82543_TIPG_IPGR2 << E1000_TIPG_IPGR2_SHIFT;
+- }
+- E1000_WRITE_REG(hw, TIPG, tipg);
++ & iegbe_oem_get_tipg(&adapter->hw);
++ break;
++ }
++ tipg |= DEFAULT_82543_TIPG_IPGR1 << E1000_TIPG_IPGR1_SHIFT;
++ tipg |= DEFAULT_82543_TIPG_IPGR2 << E1000_TIPG_IPGR2_SHIFT;
++ }
++ E1000_WRITE_REG(hw, TIPG, tipg);
+
+- /* Set the Tx Interrupt Delay register */
++ /* Set the Tx Interrupt Delay register */
+
+- E1000_WRITE_REG(hw, TIDV, adapter->tx_int_delay);
++ E1000_WRITE_REG(hw, TIDV, adapter->tx_int_delay);
+ if (hw->mac_type >= iegbe_82540) {
+- E1000_WRITE_REG(hw, TADV, adapter->tx_abs_int_delay);
++ E1000_WRITE_REG(hw, TADV, adapter->tx_abs_int_delay);
+ }
+- /* Program the Transmit Control Register */
++ /* Program the Transmit Control Register */
+
+- tctl = E1000_READ_REG(hw, TCTL);
++ tctl = E1000_READ_REG(hw, TCTL);
+
+- tctl &= ~E1000_TCTL_CT;
+- tctl |= E1000_TCTL_EN | E1000_TCTL_PSP | E1000_TCTL_RTLC |
+- (E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT);
++ tctl &= ~E1000_TCTL_CT;
++ tctl |= E1000_TCTL_EN | E1000_TCTL_PSP | E1000_TCTL_RTLC |
++ (E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT);
+
+- E1000_WRITE_REG(hw, TCTL, tctl);
++ E1000_WRITE_REG(hw, TCTL, tctl);
+
+- if (hw->mac_type == iegbe_82571 || hw->mac_type == iegbe_82572) {
+- tarc = E1000_READ_REG(hw, TARC0);
++ if (hw->mac_type == iegbe_82571 || hw->mac_type == iegbe_82572) {
++ tarc = E1000_READ_REG(hw, TARC0);
+ tarc |= ((0x1 << 0x19) | (0x1 << 0x15));
+- E1000_WRITE_REG(hw, TARC0, tarc);
+- tarc = E1000_READ_REG(hw, TARC1);
++ E1000_WRITE_REG(hw, TARC0, tarc);
++ tarc = E1000_READ_REG(hw, TARC1);
+ tarc |= (0x1 << 0x19);
+ if (tctl & E1000_TCTL_MULR) {
+ tarc &= ~(0x1 << 0x1c);
+ } else {
+ tarc |= (0x1 << 0x1c);
+ }
+- E1000_WRITE_REG(hw, TARC1, tarc);
+- }
++ E1000_WRITE_REG(hw, TARC1, tarc);
++ }
+
+- iegbe_config_collision_dist(hw);
++ iegbe_config_collision_dist(hw);
+
+- /* Setup Transmit Descriptor Settings for eop descriptor */
+- adapter->txd_cmd = E1000_TXD_CMD_IDE | E1000_TXD_CMD_EOP |
+- E1000_TXD_CMD_IFCS;
++ /* Setup Transmit Descriptor Settings for eop descriptor */
++ adapter->txd_cmd = E1000_TXD_CMD_IDE | E1000_TXD_CMD_EOP |
++ E1000_TXD_CMD_IFCS;
+
+ if (hw->mac_type < iegbe_82543) {
+- adapter->txd_cmd |= E1000_TXD_CMD_RPS;
++ adapter->txd_cmd |= E1000_TXD_CMD_RPS;
+ } else {
+-#ifdef IEGBE_GBE_WORKAROUND
+- /* Disable the RS bit in the Tx descriptor */
+- adapter->txd_cmd &= ~E1000_TXD_CMD_RS;
+-#else
+- adapter->txd_cmd |= E1000_TXD_CMD_RS;
+-#endif
++ adapter->txd_cmd |= E1000_TXD_CMD_RS;
+ }
+- /* Cache if we're 82544 running in PCI-X because we'll
+- * need this to apply a workaround later in the send path. */
+- if (hw->mac_type == iegbe_82544 &&
++ /* Cache if we're 82544 running in PCI-X because we'll
++ * need this to apply a workaround later in the send path. */
++ if (hw->mac_type == iegbe_82544 &&
+ hw->bus_type == iegbe_bus_type_pcix) {
+ adapter->pcix_82544 = 0x1;
+ }
+@@ -1632,96 +1527,95 @@ iegbe_configure_tx(struct iegbe_adapter
+ * Returns 0 on success, negative on failure
+ **/
+
+-int
+-iegbe_setup_rx_resources(struct iegbe_adapter *adapter,
++static int iegbe_setup_rx_resources(struct iegbe_adapter *adapter,
+ struct iegbe_rx_ring *rxdr)
+ {
+- struct pci_dev *pdev = adapter->pdev;
+- int size, desc_len;
+-
+- size = sizeof(struct iegbe_buffer) * rxdr->count;
+- rxdr->buffer_info = vmalloc(size);
+- if (!rxdr->buffer_info) {
+- DPRINTK(PROBE, ERR,
+- "Unable to allocate memory for the receive descriptor ring\n");
+- return -ENOMEM;
+- }
+- memset(rxdr->buffer_info, 0, size);
+-
+- size = sizeof(struct iegbe_ps_page) * rxdr->count;
+- rxdr->ps_page = kmalloc(size, GFP_KERNEL);
+- if (!rxdr->ps_page) {
+- vfree(rxdr->buffer_info);
+- DPRINTK(PROBE, ERR,
+- "Unable to allocate memory for the receive descriptor ring\n");
+- return -ENOMEM;
+- }
+- memset(rxdr->ps_page, 0, size);
+-
+- size = sizeof(struct iegbe_ps_page_dma) * rxdr->count;
+- rxdr->ps_page_dma = kmalloc(size, GFP_KERNEL);
+- if (!rxdr->ps_page_dma) {
+- vfree(rxdr->buffer_info);
+- kfree(rxdr->ps_page);
+- DPRINTK(PROBE, ERR,
+- "Unable to allocate memory for the receive descriptor ring\n");
+- return -ENOMEM;
+- }
+- memset(rxdr->ps_page_dma, 0, size);
++ struct iegbe_hw *hw = &adapter->hw;
++ struct pci_dev *pdev = adapter->pdev;
++ int size, desc_len;
+
+- if (adapter->hw.mac_type <= iegbe_82547_rev_2) {
+- desc_len = sizeof(struct iegbe_rx_desc);
+- } else {
+- desc_len = sizeof(union iegbe_rx_desc_packet_split);
++ size = sizeof(struct iegbe_buffer) * rxdr->count;
++ rxdr->buffer_info = vmalloc(size);
++ if (!rxdr->buffer_info) {
++ DPRINTK(PROBE, ERR,
++ "Unable to allocate memory for the receive descriptor ring\n");
++ return -ENOMEM;
+ }
+- /* Round up to nearest 4K */
+-
+- rxdr->size = rxdr->count * desc_len;
+- E1000_ROUNDUP(rxdr->size, 0x1000);
+-
+- rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma);
++ memset(rxdr->buffer_info, 0, size);
+
+- if (!rxdr->desc) {
+- DPRINTK(PROBE, ERR,
+- "Unable to allocate memory for the receive descriptor ring\n");
++ rxdr->ps_page = kcalloc(rxdr->count, sizeof(struct iegbe_ps_page),
++ GFP_KERNEL);
++ if (!rxdr->ps_page) {
++ vfree(rxdr->buffer_info);
++ DPRINTK(PROBE, ERR,
++ "Unable to allocate memory for the receive descriptor ring\n");
++ return -ENOMEM;
++ }
++
++ rxdr->ps_page_dma = kcalloc(rxdr->count,
++ sizeof(struct iegbe_ps_page_dma),
++ GFP_KERNEL);
++ if (!rxdr->ps_page_dma) {
++ vfree(rxdr->buffer_info);
++ kfree(rxdr->ps_page);
++ DPRINTK(PROBE, ERR,
++ "Unable to allocate memory for the receive descriptor ring\n");
++ return -ENOMEM;
++ }
++
++ if (hw->mac_type <= iegbe_82547_rev_2)
++ desc_len = sizeof(struct iegbe_rx_desc);
++ else
++ desc_len = sizeof(union iegbe_rx_desc_packet_split);
++
++ /* Round up to nearest 4K */
++
++ rxdr->size = rxdr->count * desc_len;
++ rxdr->size = ALIGN(rxdr->size, 4096);
++
++ rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma);
++
++ if (!rxdr->desc) {
++ DPRINTK(PROBE, ERR,
++ "Unable to allocate memory for the receive descriptor ring\n");
+ setup_rx_desc_die:
+- vfree(rxdr->buffer_info);
+- kfree(rxdr->ps_page);
+- kfree(rxdr->ps_page_dma);
+- return -ENOMEM;
+- }
+-
+- /* Fix for errata 23, can't cross 64kB boundary */
+- if (!iegbe_check_64k_bound(adapter, rxdr->desc, rxdr->size)) {
+- void *olddesc = rxdr->desc;
+- dma_addr_t olddma = rxdr->dma;
+- DPRINTK(RX_ERR, ERR, "rxdr align check failed: %u bytes "
+- "at %p\n", rxdr->size, rxdr->desc);
+- /* Try again, without freeing the previous */
+- rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma);
+- /* Failed allocation, critical failure */
+- if (!rxdr->desc) {
+- pci_free_consistent(pdev, rxdr->size, olddesc, olddma);
+- DPRINTK(PROBE, ERR,
+- "Unable to allocate memory "
+- "for the receive descriptor ring\n");
+- goto setup_rx_desc_die;
+- }
++ vfree(rxdr->buffer_info);
++ kfree(rxdr->ps_page);
++ kfree(rxdr->ps_page_dma);
++ return -ENOMEM;
++ }
++
++ /* Fix for errata 23, can't cross 64kB boundary */
++ if (!iegbe_check_64k_bound(adapter, rxdr->desc, rxdr->size)) {
++ void *olddesc = rxdr->desc;
++ dma_addr_t olddma = rxdr->dma;
++ DPRINTK(RX_ERR, ERR, "rxdr align check failed: %u bytes "
++ "at %p\n", rxdr->size, rxdr->desc);
++ /* Try again, without freeing the previous */
++ rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma);
++ /* Failed allocation, critical failure */
++ if (!rxdr->desc) {
++ pci_free_consistent(pdev, rxdr->size, olddesc, olddma);
++ DPRINTK(PROBE, ERR,
++ "Unable to allocate memory "
++ "for the receive descriptor ring\n");
++ goto setup_rx_desc_die;
++ }
+
+- if (!iegbe_check_64k_bound(adapter, rxdr->desc, rxdr->size)) {
+- /* give up */
+- pci_free_consistent(pdev, rxdr->size, rxdr->desc,
+- rxdr->dma);
+- pci_free_consistent(pdev, rxdr->size, olddesc, olddma);
+- DPRINTK(PROBE, ERR,
+- "Unable to allocate aligned memory "
+- "for the receive descriptor ring\n");
+- goto setup_rx_desc_die;
+- } else {
+- /* Free old allocation, new allocation was successful */
+- pci_free_consistent(pdev, rxdr->size, olddesc, olddma);
+- }
+- }
++ if (!iegbe_check_64k_bound(adapter, rxdr->desc, rxdr->size)) {
++ /* give up */
++ pci_free_consistent(pdev, rxdr->size, rxdr->desc,
++ rxdr->dma);
++ pci_free_consistent(pdev, rxdr->size, olddesc, olddma);
++ DPRINTK(PROBE, ERR,
++ "Unable to allocate aligned memory "
++ "for the receive descriptor ring\n");
++ goto setup_rx_desc_die;
++ } else {
++ /* Free old allocation, new allocation was successful */
++ pci_free_consistent(pdev, rxdr->size, olddesc, olddma);
++ }
++ }
+ memset(rxdr->desc, 0, rxdr->size);
+
+ rxdr->next_to_clean = 0;
+@@ -1732,7 +1626,7 @@ setup_rx_desc_die:
+
+ /**
+ * iegbe_setup_all_rx_resources - wrapper to allocate Rx resources
+- * (Descriptors) for all queues
++ * (Descriptors) for all queues
+ * @adapter: board private structure
+ *
+ * If this function returns with an error, then it's possible one or
+@@ -1742,21 +1636,23 @@ setup_rx_desc_die:
+ * Return 0 on success, negative on failure
+ **/
+
+-int
+-iegbe_setup_all_rx_resources(struct iegbe_adapter *adapter)
++int iegbe_setup_all_rx_resources(struct iegbe_adapter *adapter)
+ {
+ int i, err = 0;
+
+- for (i = 0; i < adapter->num_queues; i++) {
++ for (i = 0; i < adapter->num_rx_queues; i++) {
+ err = iegbe_setup_rx_resources(adapter, &adapter->rx_ring[i]);
+ if (err) {
+ DPRINTK(PROBE, ERR,
+ "Allocation for Rx Queue %u failed\n", i);
++ for (i-- ; i >= 0; i--)
++ iegbe_free_rx_resources(adapter,
++ &adapter->rx_ring[i]);
+ break;
+ }
+ }
+
+- return err;
++ return err;
+ }
+
+ /**
+@@ -1765,105 +1661,104 @@ iegbe_setup_all_rx_resources(struct iegb
+ **/
+ #define PAGE_USE_COUNT(S) (((S) >> PAGE_SHIFT) + \
+ (((S) & (PAGE_SIZE - 1)) ? 1 : 0))
+-static void
+-iegbe_setup_rctl(struct iegbe_adapter *adapter)
++static void iegbe_setup_rctl(struct iegbe_adapter *adapter)
+ {
+- uint32_t rctl, rfctl;
+- uint32_t psrctl = 0;
+-#ifdef CONFIG_E1000_PACKET_SPLIT
+- uint32_t pages = 0;
+-#endif
+-
+- rctl = E1000_READ_REG(&adapter->hw, RCTL);
+-
+- rctl &= ~(0x3 << E1000_RCTL_MO_SHIFT);
+-
+- rctl |= E1000_RCTL_EN | E1000_RCTL_BAM |
+- E1000_RCTL_LBM_NO | E1000_RCTL_RDMTS_HALF |
+- (adapter->hw.mc_filter_type << E1000_RCTL_MO_SHIFT);
+-
+- if(adapter->hw.tbi_compatibility_on == 0x1) {
+- rctl |= E1000_RCTL_SBP;
+- } else {
+- rctl &= ~E1000_RCTL_SBP;
+- }
+- if(adapter->netdev->mtu <= ETH_DATA_LEN) {
+- rctl &= ~E1000_RCTL_LPE;
+- } else {
+- rctl |= E1000_RCTL_LPE;
+- }
+- /* Setup buffer sizes */
+- if(adapter->hw.mac_type >= iegbe_82571) {
+- /* We can now specify buffers in 1K increments.
+- * BSIZE and BSEX are ignored in this case. */
+- rctl |= adapter->rx_buffer_len << 0x11;
+- } else {
+- rctl &= ~E1000_RCTL_SZ_4096;
+- rctl |= E1000_RCTL_BSEX;
+- switch (adapter->rx_buffer_len) {
+- case E1000_RXBUFFER_2048:
+- default:
+- rctl |= E1000_RCTL_SZ_2048;
++ struct iegbe_hw *hw = &adapter->hw;
++ u32 rctl, rfctl;
++ u32 psrctl = 0;
++#ifndef CONFIG_E1000_DISABLE_PACKET_SPLIT
++ u32 pages = 0;
++#endif
++
++ rctl = E1000_READ_REG(&adapter->hw, RCTL);
++
++ rctl &= ~(3 << E1000_RCTL_MO_SHIFT);
++
++ rctl |= E1000_RCTL_EN | E1000_RCTL_BAM |
++ E1000_RCTL_LBM_NO | E1000_RCTL_RDMTS_HALF |
++ (hw->mc_filter_type << E1000_RCTL_MO_SHIFT);
++
++ if (hw->tbi_compatibility_on == 1)
++ rctl |= E1000_RCTL_SBP;
++ else
++ rctl &= ~E1000_RCTL_SBP;
++
++ if (adapter->netdev->mtu <= ETH_DATA_LEN)
++ rctl &= ~E1000_RCTL_LPE;
++ else
++ rctl |= E1000_RCTL_LPE;
++
++ /* Setup buffer sizes */
++ /* We can now specify buffers in 1K increments.
++ * BSIZE and BSEX are ignored in this case. */
++ rctl &= ~E1000_RCTL_SZ_4096;
++ rctl |= E1000_RCTL_BSEX;
++ switch (adapter->rx_buffer_len) {
++ case E1000_RXBUFFER_256:
++ rctl |= E1000_RCTL_SZ_256;
+ rctl &= ~E1000_RCTL_BSEX;
+ break;
+- case E1000_RXBUFFER_4096:
+- rctl |= E1000_RCTL_SZ_4096;
+- break;
+- case E1000_RXBUFFER_8192:
+- rctl |= E1000_RCTL_SZ_8192;
+- break;
+- case E1000_RXBUFFER_16384:
+- rctl |= E1000_RCTL_SZ_16384;
+- break;
+- }
+- }
++ case E1000_RXBUFFER_2048:
++ default:
++ rctl |= E1000_RCTL_SZ_2048;
++ rctl &= ~E1000_RCTL_BSEX;
++ break;
++ case E1000_RXBUFFER_4096:
++ rctl |= E1000_RCTL_SZ_4096;
++ break;
++ case E1000_RXBUFFER_8192:
++ rctl |= E1000_RCTL_SZ_8192;
++ break;
++ case E1000_RXBUFFER_16384:
++ rctl |= E1000_RCTL_SZ_16384;
++ break;
++ }
+
+-#ifdef CONFIG_E1000_PACKET_SPLIT
+- /* 82571 and greater support packet-split where the protocol
+- * header is placed in skb->data and the packet data is
+- * placed in pages hanging off of skb_shinfo(skb)->nr_frags.
+- * In the case of a non-split, skb->data is linearly filled,
+- * followed by the page buffers. Therefore, skb->data is
+- * sized to hold the largest protocol header.
+- */
+- pages = PAGE_USE_COUNT(adapter->netdev->mtu);
+- if ((adapter->hw.mac_type > iegbe_82547_rev_2) && (pages <= 0x3) &&
+- PAGE_SIZE <= 0x4000) {
+- adapter->rx_ps_pages = pages;
+- } else {
++#ifndef CONFIG_E1000_DISABLE_PACKET_SPLIT
++ /* 82571 and greater support packet-split where the protocol
++ * header is placed in skb->data and the packet data is
++ * placed in pages hanging off of skb_shinfo(skb)->nr_frags.
++ * In the case of a non-split, skb->data is linearly filled,
++ * followed by the page buffers. Therefore, skb->data is
++ * sized to hold the largest protocol header.
++ */
++ pages = PAGE_USE_COUNT(adapter->netdev->mtu);
++ if ((hw->mac_type >= iegbe_82571) && (pages <= 3) &&
++ PAGE_SIZE <= 16384 && (rctl & E1000_RCTL_LPE))
++ adapter->rx_ps_pages = pages;
++ else
+ adapter->rx_ps_pages = 0;
+- }
+ #endif
+- if (adapter->rx_ps_pages) {
+- /* Configure extra packet-split registers */
+- rfctl = E1000_READ_REG(&adapter->hw, RFCTL);
+- rfctl |= E1000_RFCTL_EXTEN;
+- /* disable IPv6 packet split support */
+- rfctl |= E1000_RFCTL_IPV6_DIS;
+- E1000_WRITE_REG(&adapter->hw, RFCTL, rfctl);
+-
+- rctl |= E1000_RCTL_DTYP_PS | E1000_RCTL_SECRC;
+-
+- psrctl |= adapter->rx_ps_bsize0 >>
+- E1000_PSRCTL_BSIZE0_SHIFT;
+-
+- switch (adapter->rx_ps_pages) {
+- case 0x3:
+- psrctl |= PAGE_SIZE <<
+- E1000_PSRCTL_BSIZE3_SHIFT;
+- case 0x2:
+- psrctl |= PAGE_SIZE <<
+- E1000_PSRCTL_BSIZE2_SHIFT;
+- case 0x1:
+- psrctl |= PAGE_SIZE >>
+- E1000_PSRCTL_BSIZE1_SHIFT;
+- break;
+- }
++ if (adapter->rx_ps_pages) {
++ /* Configure extra packet-split registers */
++ rfctl = E1000_READ_REG(&adapter->hw, RFCTL);
++ rfctl |= E1000_RFCTL_EXTEN;
++ /* disable IPv6 packet split support */
++ rfctl |= (E1000_RFCTL_IPV6_EX_DIS |
++ E1000_RFCTL_NEW_IPV6_EXT_DIS);
++
++ rctl |= E1000_RCTL_DTYP_PS;
++
++ psrctl |= adapter->rx_ps_bsize0 >>
++ E1000_PSRCTL_BSIZE0_SHIFT;
++
++ switch (adapter->rx_ps_pages) {
++ case 3:
++ psrctl |= PAGE_SIZE <<
++ E1000_PSRCTL_BSIZE3_SHIFT;
++ case 2:
++ psrctl |= PAGE_SIZE <<
++ E1000_PSRCTL_BSIZE2_SHIFT;
++ case 1:
++ psrctl |= PAGE_SIZE >>
++ E1000_PSRCTL_BSIZE1_SHIFT;
++ break;
++ }
+
+- E1000_WRITE_REG(&adapter->hw, PSRCTL, psrctl);
+- }
++ E1000_WRITE_REG(&adapter->hw, PSRCTL, psrctl);
++ }
+
+- E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
++ E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
+ }
+
+ /**
+@@ -1873,145 +1768,87 @@ iegbe_setup_rctl(struct iegbe_adapter *a
+ * Configure the Rx unit of the MAC after a reset.
+ **/
+
+-static void
+-iegbe_configure_rx(struct iegbe_adapter *adapter)
++static void iegbe_configure_rx(struct iegbe_adapter *adapter)
+ {
+- uint64_t rdba;
+- struct iegbe_hw *hw = &adapter->hw;
+- uint32_t rdlen, rctl, rxcsum, ctrl_ext;
+-#ifdef CONFIG_E1000_MQ
+- uint32_t reta, mrqc;
+- int i;
+-#endif
++ u64 rdba;
++ struct iegbe_hw *hw = &adapter->hw;
++ u32 rdlen, rctl, rxcsum, ctrl_ext;
+
+- if (adapter->rx_ps_pages) {
++ if (adapter->rx_ps_pages) {
+ rdlen = adapter->rx_ring[0].count *
+- sizeof(union iegbe_rx_desc_packet_split);
+- adapter->clean_rx = iegbe_clean_rx_irq_ps;
+- adapter->alloc_rx_buf = iegbe_alloc_rx_buffers_ps;
+- } else {
++ sizeof(union iegbe_rx_desc_packet_split);
++ adapter->clean_rx = iegbe_clean_rx_irq_ps;
++ adapter->alloc_rx_buf = iegbe_alloc_rx_buffers_ps;
++ } else {
+ rdlen = adapter->rx_ring[0].count *
+- sizeof(struct iegbe_rx_desc);
+- adapter->clean_rx = iegbe_clean_rx_irq;
+- adapter->alloc_rx_buf = iegbe_alloc_rx_buffers;
+- }
++ sizeof(struct iegbe_rx_desc);
++ adapter->clean_rx = iegbe_clean_rx_irq;
++ adapter->alloc_rx_buf = iegbe_alloc_rx_buffers;
++ }
+
+- /* disable receives while setting up the descriptors */
+- rctl = E1000_READ_REG(hw, RCTL);
+- E1000_WRITE_REG(hw, RCTL, rctl & ~E1000_RCTL_EN);
++ /* disable receives while setting up the descriptors */
++ rctl = E1000_READ_REG(hw, RCTL);
++ E1000_WRITE_REG(hw, RCTL, rctl & ~E1000_RCTL_EN);
+
+- /* set the Receive Delay Timer Register */
+- E1000_WRITE_REG(hw, RDTR, adapter->rx_int_delay);
++ /* set the Receive Delay Timer Register */
++ E1000_WRITE_REG(hw, RDTR, adapter->rx_int_delay);
+
+- if (hw->mac_type >= iegbe_82540) {
+- E1000_WRITE_REG(hw, RADV, adapter->rx_abs_int_delay);
+- if(adapter->itr > 0x1) {
+- E1000_WRITE_REG(hw, ITR,
+- 0x3b9aca00 / (adapter->itr * 0x100));
++ if (hw->mac_type >= iegbe_82540) {
++ E1000_WRITE_REG(hw, RADV, adapter->rx_abs_int_delay);
++ if (adapter->itr_setting != 0)
++ E1000_WRITE_REG(&adapter->hw, ITR, 1000000000 / (adapter->itr * 256));
+ }
+- }
+
+- if (hw->mac_type >= iegbe_82571) {
+- /* Reset delay timers after every interrupt */
+- ctrl_ext = E1000_READ_REG(hw, CTRL_EXT);
+- ctrl_ext |= E1000_CTRL_EXT_CANC;
+- E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext);
+- E1000_WRITE_FLUSH(hw);
+- }
++ if (hw->mac_type >= iegbe_82571) {
++ /* Reset delay timers after every interrupt */
++ ctrl_ext = E1000_READ_REG(hw, CTRL_EXT);
++ ctrl_ext |= E1000_CTRL_EXT_CANC;
++ E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext);
++ E1000_WRITE_FLUSH(hw);
++ }
+
+ /* Setup the HW Rx Head and Tail Descriptor Pointers and
+ * the Base and Length of the Rx Descriptor Ring */
+- switch (adapter->num_queues) {
+-#ifdef CONFIG_E1000_MQ
+- case 0x2:
+- rdba = adapter->rx_ring[0x1].dma;
+- E1000_WRITE_REG(hw, RDBAL1, (rdba & 0x00000000ffffffffULL));
+- E1000_WRITE_REG(hw, RDBAH1, (rdba >> 0x20));
+- E1000_WRITE_REG(hw, RDLEN1, rdlen);
+- E1000_WRITE_REG(hw, RDH1, 0);
+- E1000_WRITE_REG(hw, RDT1, 0);
+- adapter->rx_ring[1].rdh = E1000_RDH1;
+- adapter->rx_ring[1].rdt = E1000_RDT1;
+- /* Fall Through */
+-#endif
+- case 0x1:
+- default:
++ switch (adapter->num_rx_queues) {
++ case 1:
++ default:
+ rdba = adapter->rx_ring[0].dma;
+- E1000_WRITE_REG(hw, RDBAL, (rdba & 0x00000000ffffffffULL));
++ E1000_WRITE_REG(hw, RDBAL, (rdba & 0x00000000ffffffffULL));
+ E1000_WRITE_REG(hw, RDBAH, (rdba >> 0x20));
+- E1000_WRITE_REG(hw, RDLEN, rdlen);
+- E1000_WRITE_REG(hw, RDH, 0);
+- E1000_WRITE_REG(hw, RDT, 0);
+- adapter->rx_ring[0].rdh = E1000_RDH;
+- adapter->rx_ring[0].rdt = E1000_RDT;
+- break;
+- }
++ E1000_WRITE_REG(hw, RDLEN, rdlen);
++ adapter->rx_ring[0].rdh = ((hw->mac_type >= iegbe_82543) ? E1000_RDH : E1000_82542_RDH);
++ adapter->rx_ring[0].rdt = ((hw->mac_type >= iegbe_82543) ? E1000_RDT : E1000_82542_RDT);
++ break;
++ }
+
+-#ifdef CONFIG_E1000_MQ
+- if (adapter->num_queues > 0x1) {
+- uint32_t random[0xa];
+-
+- get_random_bytes(&random[0], FORTY);
+-
+- if (hw->mac_type <= iegbe_82572) {
+- E1000_WRITE_REG(hw, RSSIR, 0);
+- E1000_WRITE_REG(hw, RSSIM, 0);
+- }
+
+- switch (adapter->num_queues) {
+- case 0x2:
+- default:
+- reta = 0x00800080;
+- mrqc = E1000_MRQC_ENABLE_RSS_2Q;
+- break;
+- }
+-
+- /* Fill out redirection table */
+- for (i = 0; i < 0x20; i++)
+- E1000_WRITE_REG_ARRAY(hw, RETA, i, reta);
+- /* Fill out hash function seeds */
+- for (i = 0; i < 0xa; i++)
+- E1000_WRITE_REG_ARRAY(hw, RSSRK, i, random[i]);
+-
+- mrqc |= (E1000_MRQC_RSS_FIELD_IPV4 |
+- E1000_MRQC_RSS_FIELD_IPV4_TCP);
+- E1000_WRITE_REG(hw, MRQC, mrqc);
+- }
+-
+- /* Multiqueue and packet checksumming are mutually exclusive. */
+- if (hw->mac_type >= iegbe_82571) {
+- rxcsum = E1000_READ_REG(hw, RXCSUM);
+- rxcsum |= E1000_RXCSUM_PCSD;
+- E1000_WRITE_REG(hw, RXCSUM, rxcsum);
+- }
+-
+-#else
++ /* Enable 82543 Receive Checksum Offload for TCP and UDP */
++ if (hw->mac_type >= iegbe_82543) {
++ rxcsum = E1000_READ_REG(hw, RXCSUM);
++ if(adapter->rx_csum == TRUE) {
++ rxcsum |= E1000_RXCSUM_TUOFL;
++
++ /* Enable 82571 IPv4 payload checksum for UDP fragments
++ * Must be used in conjunction with packet-split. */
++ if ((hw->mac_type >= iegbe_82571) &&
++ (adapter->rx_ps_pages)) {
++ rxcsum |= E1000_RXCSUM_IPPCSE;
++ }
++ } else {
++ rxcsum &= ~E1000_RXCSUM_TUOFL;
++ /* don't need to clear IPPCSE as it defaults to 0 */
++ }
++ E1000_WRITE_REG(hw, RXCSUM, rxcsum);
++ }
+
+- /* Enable 82543 Receive Checksum Offload for TCP and UDP */
+- if (hw->mac_type >= iegbe_82543) {
+- rxcsum = E1000_READ_REG(hw, RXCSUM);
+- if(adapter->rx_csum == TRUE) {
+- rxcsum |= E1000_RXCSUM_TUOFL;
+-
+- /* Enable 82571 IPv4 payload checksum for UDP fragments
+- * Must be used in conjunction with packet-split. */
+- if ((hw->mac_type >= iegbe_82571) &&
+- (adapter->rx_ps_pages)) {
+- rxcsum |= E1000_RXCSUM_IPPCSE;
+- }
+- } else {
+- rxcsum &= ~E1000_RXCSUM_TUOFL;
+- /* don't need to clear IPPCSE as it defaults to 0 */
+- }
+- E1000_WRITE_REG(hw, RXCSUM, rxcsum);
+- }
+-#endif /* CONFIG_E1000_MQ */
++ /* enable early receives on 82573, only takes effect if using > 2048
++ * byte total frame size. for example only for jumbo frames */
++#define E1000_ERT_2048 0x100
++ if (hw->mac_type == iegbe_82573)
++ E1000_WRITE_REG(&adapter->hw, ERT, E1000_ERT_2048);
+
+- if (hw->mac_type == iegbe_82573) {
+- E1000_WRITE_REG(hw, ERT, 0x0100);
+- }
+ /* Enable Receives */
+- E1000_WRITE_REG(hw, RCTL, rctl);
++ E1000_WRITE_REG(hw, RCTL, rctl);
+ }
+
+ /**
+@@ -2022,20 +1859,19 @@ iegbe_configure_rx(struct iegbe_adapter
+ * Free all transmit software resources
+ **/
+
+-void
+-iegbe_free_tx_resources(struct iegbe_adapter *adapter,
++static void iegbe_free_tx_resources(struct iegbe_adapter *adapter,
+ struct iegbe_tx_ring *tx_ring)
+ {
+- struct pci_dev *pdev = adapter->pdev;
++ struct pci_dev *pdev = adapter->pdev;
+
+- iegbe_clean_tx_ring(adapter, tx_ring);
++ iegbe_clean_tx_ring(adapter, tx_ring);
+
+- vfree(tx_ring->buffer_info);
+- tx_ring->buffer_info = NULL;
++ vfree(tx_ring->buffer_info);
++ tx_ring->buffer_info = NULL;
+
+- pci_free_consistent(pdev, tx_ring->size, tx_ring->desc, tx_ring->dma);
++ pci_free_consistent(pdev, tx_ring->size, tx_ring->desc, tx_ring->dma);
+
+- tx_ring->desc = NULL;
++ tx_ring->desc = NULL;
+ }
+
+ /**
+@@ -2048,85 +1884,29 @@ iegbe_free_tx_resources(struct iegbe_ada
+ void
+ iegbe_free_all_tx_resources(struct iegbe_adapter *adapter)
+ {
+- int i;
++ int i;
+
+- for (i = 0; i < adapter->num_queues; i++)
++ for (i = 0x0; i < adapter->num_tx_queues; i++)
+ iegbe_free_tx_resources(adapter, &adapter->tx_ring[i]);
+ }
+
+ static inline void
+ iegbe_unmap_and_free_tx_resource(struct iegbe_adapter *adapter,
+- struct iegbe_buffer *buffer_info)
+-{
+- if(buffer_info->dma) {
+- pci_unmap_page(adapter->pdev,
+- buffer_info->dma,
+- buffer_info->length,
+- PCI_DMA_TODEVICE);
+- buffer_info->dma = 0;
+- }
+- if(buffer_info->skb) {
+- dev_kfree_skb_any(buffer_info->skb);
+- buffer_info->skb = NULL;
+- }
+-}
+-
+-#ifdef IEGBE_GBE_WORKAROUND
+-/**
+- * iegbe_clean_tx_ring_partial - Free Tx Buffers without using the DD
+- * bit in the descriptor
+- * @adapter: board private structure
+- * @tx_ring: ring to be cleaned
+- **/
+-static void iegbe_clean_tx_ring_partial(struct iegbe_adapter *adapter,
+- struct iegbe_tx_ring *tx_ring)
++ struct iegbe_buffer *buffer_info)
+ {
+- struct iegbe_buffer *buffer_info;
+- struct iegbe_tx_desc *tx_desc;
+- struct net_device *netdev = adapter->netdev;
+- unsigned int i;
+- unsigned tail;
+- unsigned head;
+- int cleaned = FALSE;
+-
+- tail = readl(adapter->hw.hw_addr + tx_ring->tdt);
+- head = readl(adapter->hw.hw_addr + tx_ring->tdh);
+-
+- if (head != tail) {
+- adapter->stats.tx_hnet++;
+- }
+- if (head != tx_ring->next_to_use) {
+- adapter->stats.tx_hnentu++;
+- }
+- /* Free all the Tx ring sk_buffs from next_to_clean up until
+- * the current head pointer
+- */
+- i = tx_ring->next_to_clean;
+- while(i != head) {
+- cleaned = TRUE;
+- tx_desc = E1000_TX_DESC(*tx_ring, i);
+-
+- buffer_info = &tx_ring->buffer_info[i];
+- iegbe_unmap_and_free_tx_resource(adapter, buffer_info);
+-
+- tx_desc->upper.data = 0;
+-
+- if (unlikely(++i == tx_ring->count)) { i = 0; }
+-
+- }
+- tx_ring->next_to_clean = head;
+-
+- spin_lock(&tx_ring->tx_lock);
+-
+- /* Wake up the queue if it's currently stopped */
+- if (unlikely(cleaned && netif_queue_stopped(netdev) &&
+- netif_carrier_ok(netdev))) {
+- netif_wake_queue(netdev);
++ if(buffer_info->dma) {
++ pci_unmap_page(adapter->pdev,
++ buffer_info->dma,
++ buffer_info->length,
++ PCI_DMA_TODEVICE);
++ buffer_info->dma = 0x0;
++ }
++ if(buffer_info->skb) {
++ dev_kfree_skb_any(buffer_info->skb);
++ buffer_info->skb = NULL;
+ }
+-
+- spin_unlock(&tx_ring->tx_lock);
+ }
+-#endif
++
+
+ /**
+ * iegbe_clean_tx_ring - Free Tx Buffers
+@@ -2134,38 +1914,34 @@ static void iegbe_clean_tx_ring_partial(
+ * @tx_ring: ring to be cleaned
+ **/
+
+-static void
+-iegbe_clean_tx_ring(struct iegbe_adapter *adapter,
++static void iegbe_clean_tx_ring(struct iegbe_adapter *adapter,
+ struct iegbe_tx_ring *tx_ring)
+ {
+- struct iegbe_buffer *buffer_info;
+- unsigned long size;
+- unsigned int i;
+-
+- /* Free all the Tx ring sk_buffs */
++ struct iegbe_hw *hw = &adapter->hw;
++ struct iegbe_buffer *buffer_info;
++ unsigned long size;
++ unsigned int i;
+
+- if (likely(tx_ring->previous_buffer_info.skb != NULL)) {
+- iegbe_unmap_and_free_tx_resource(adapter,
+- &tx_ring->previous_buffer_info);
+- }
++ /* Free all the Tx ring sk_buffs */
+
+ for (i = 0; i < tx_ring->count; i++) {
+- buffer_info = &tx_ring->buffer_info[i];
+- iegbe_unmap_and_free_tx_resource(adapter, buffer_info);
+- }
++ buffer_info = &tx_ring->buffer_info[i];
++ iegbe_unmap_and_free_tx_resource(adapter, buffer_info);
++ }
+
+- size = sizeof(struct iegbe_buffer) * tx_ring->count;
++ size = sizeof(struct iegbe_buffer) * tx_ring->count;
+ memset(tx_ring->buffer_info, 0, size);
+
+- /* Zero out the descriptor ring */
++ /* Zero out the descriptor ring */
+
+ memset(tx_ring->desc, 0, tx_ring->size);
+
+ tx_ring->next_to_use = 0;
+ tx_ring->next_to_clean = 0;
++ tx_ring->last_tx_tso = 0;
+
+- writel(0, adapter->hw.hw_addr + tx_ring->tdh);
+- writel(0, adapter->hw.hw_addr + tx_ring->tdt);
++ writel(0, hw->hw_addr + tx_ring->tdh);
++ writel(0, hw->hw_addr + tx_ring->tdt);
+ }
+
+ /**
+@@ -2173,12 +1949,11 @@ iegbe_clean_tx_ring(struct iegbe_adapter
+ * @adapter: board private structure
+ **/
+
+-static void
+-iegbe_clean_all_tx_rings(struct iegbe_adapter *adapter)
++static void iegbe_clean_all_tx_rings(struct iegbe_adapter *adapter)
+ {
+- int i;
++ int i;
+
+- for (i = 0; i < adapter->num_queues; i++)
++ for (i = 0; i < adapter->num_tx_queues; i++)
+ iegbe_clean_tx_ring(adapter, &adapter->tx_ring[i]);
+ }
+
+@@ -2190,24 +1965,23 @@ iegbe_clean_all_tx_rings(struct iegbe_ad
+ * Free all receive software resources
+ **/
+
+-void
+-iegbe_free_rx_resources(struct iegbe_adapter *adapter,
++static void iegbe_free_rx_resources(struct iegbe_adapter *adapter,
+ struct iegbe_rx_ring *rx_ring)
+ {
+- struct pci_dev *pdev = adapter->pdev;
++ struct pci_dev *pdev = adapter->pdev;
+
+- iegbe_clean_rx_ring(adapter, rx_ring);
++ iegbe_clean_rx_ring(adapter, rx_ring);
+
+- vfree(rx_ring->buffer_info);
+- rx_ring->buffer_info = NULL;
+- kfree(rx_ring->ps_page);
+- rx_ring->ps_page = NULL;
+- kfree(rx_ring->ps_page_dma);
+- rx_ring->ps_page_dma = NULL;
++ vfree(rx_ring->buffer_info);
++ rx_ring->buffer_info = NULL;
++ kfree(rx_ring->ps_page);
++ rx_ring->ps_page = NULL;
++ kfree(rx_ring->ps_page_dma);
++ rx_ring->ps_page_dma = NULL;
+
+- pci_free_consistent(pdev, rx_ring->size, rx_ring->desc, rx_ring->dma);
++ pci_free_consistent(pdev, rx_ring->size, rx_ring->desc, rx_ring->dma);
+
+- rx_ring->desc = NULL;
++ rx_ring->desc = NULL;
+ }
+
+ /**
+@@ -2217,12 +1991,11 @@ iegbe_free_rx_resources(struct iegbe_ada
+ * Free all receive software resources
+ **/
+
+-void
+-iegbe_free_all_rx_resources(struct iegbe_adapter *adapter)
++void iegbe_free_all_rx_resources(struct iegbe_adapter *adapter)
+ {
+- int i;
++ int i;
+
+- for (i = 0; i < adapter->num_queues; i++)
++ for (i = 0; i < adapter->num_rx_queues; i++)
+ iegbe_free_rx_resources(adapter, &adapter->rx_ring[i]);
+ }
+
+@@ -2232,60 +2005,59 @@ iegbe_free_all_rx_resources(struct iegbe
+ * @rx_ring: ring to free buffers from
+ **/
+
+-static void
+-iegbe_clean_rx_ring(struct iegbe_adapter *adapter,
++static void iegbe_clean_rx_ring(struct iegbe_adapter *adapter,
+ struct iegbe_rx_ring *rx_ring)
+ {
+- struct iegbe_buffer *buffer_info;
+- struct iegbe_ps_page *ps_page;
+- struct iegbe_ps_page_dma *ps_page_dma;
+- struct pci_dev *pdev = adapter->pdev;
+- unsigned long size;
+- unsigned int i, j;
+-
+- /* Free all the Rx ring sk_buffs */
++ struct iegbe_hw *hw = &adapter->hw;
++ struct iegbe_buffer *buffer_info;
++ struct iegbe_ps_page *ps_page;
++ struct iegbe_ps_page_dma *ps_page_dma;
++ struct pci_dev *pdev = adapter->pdev;
++ unsigned long size;
++ unsigned int i, j;
++
++ /* Free all the Rx ring sk_buffs */
++
++ for (i = 0; i < rx_ring->count; i++) {
++ buffer_info = &rx_ring->buffer_info[i];
++ if(buffer_info->skb) {
++ pci_unmap_single(pdev,
++ buffer_info->dma,
++ buffer_info->length,
++ PCI_DMA_FROMDEVICE);
+
+- for(i = 0; i < rx_ring->count; i++) {
+- buffer_info = &rx_ring->buffer_info[i];
+- if(buffer_info->skb) {
+- ps_page = &rx_ring->ps_page[i];
+- ps_page_dma = &rx_ring->ps_page_dma[i];
+- pci_unmap_single(pdev,
+- buffer_info->dma,
+- buffer_info->length,
+- PCI_DMA_FROMDEVICE);
+-
+- dev_kfree_skb(buffer_info->skb);
+- buffer_info->skb = NULL;
+-
+- for(j = 0; j < adapter->rx_ps_pages; j++) {
+- if(!ps_page->ps_page[j]) { break; }
+- pci_unmap_single(pdev,
+- ps_page_dma->ps_page_dma[j],
+- PAGE_SIZE, PCI_DMA_FROMDEVICE);
+- ps_page_dma->ps_page_dma[j] = 0;
+- put_page(ps_page->ps_page[j]);
+- ps_page->ps_page[j] = NULL;
+- }
++ dev_kfree_skb(buffer_info->skb);
++ buffer_info->skb = NULL;
+ }
+- }
++ ps_page = &rx_ring->ps_page[i];
++ ps_page_dma = &rx_ring->ps_page_dma[i];
++ for (j = 0; j < adapter->rx_ps_pages; j++) {
++ if (!ps_page->ps_page[j]) break;
++ pci_unmap_page(pdev,
++ ps_page_dma->ps_page_dma[j],
++ PAGE_SIZE, PCI_DMA_FROMDEVICE);
++ ps_page_dma->ps_page_dma[j] = 0;
++ put_page(ps_page->ps_page[j]);
++ ps_page->ps_page[j] = NULL;
++ }
++ }
+
+- size = sizeof(struct iegbe_buffer) * rx_ring->count;
++ size = sizeof(struct iegbe_buffer) * rx_ring->count;
+ memset(rx_ring->buffer_info, 0, size);
+- size = sizeof(struct iegbe_ps_page) * rx_ring->count;
++ size = sizeof(struct iegbe_ps_page) * rx_ring->count;
+ memset(rx_ring->ps_page, 0, size);
+- size = sizeof(struct iegbe_ps_page_dma) * rx_ring->count;
++ size = sizeof(struct iegbe_ps_page_dma) * rx_ring->count;
+ memset(rx_ring->ps_page_dma, 0, size);
+
+- /* Zero out the descriptor ring */
++ /* Zero out the descriptor ring */
+
+ memset(rx_ring->desc, 0, rx_ring->size);
+
+ rx_ring->next_to_clean = 0;
+ rx_ring->next_to_use = 0;
+
+- writel(0, adapter->hw.hw_addr + rx_ring->rdh);
+- writel(0, adapter->hw.hw_addr + rx_ring->rdt);
++ writel(0, hw->hw_addr + rx_ring->rdh);
++ writel(0, hw->hw_addr + rx_ring->rdt);
+ }
+
+ /**
+@@ -2293,60 +2065,54 @@ iegbe_clean_rx_ring(struct iegbe_adapter
+ * @adapter: board private structure
+ **/
+
+-static void
+-iegbe_clean_all_rx_rings(struct iegbe_adapter *adapter)
++static void iegbe_clean_all_rx_rings(struct iegbe_adapter *adapter)
+ {
+- int i;
++ int i;
+
+- for (i = 0; i < adapter->num_queues; i++)
++ for (i = 0; i < adapter->num_rx_queues; i++)
+ iegbe_clean_rx_ring(adapter, &adapter->rx_ring[i]);
+ }
+
+ /* The 82542 2.0 (revision 2) needs to have the receive unit in reset
+ * and memory write and invalidate disabled for certain operations
+ */
+-static void
+-iegbe_enter_82542_rst(struct iegbe_adapter *adapter)
++static void iegbe_enter_82542_rst(struct iegbe_adapter *adapter)
+ {
+- struct net_device *netdev = adapter->netdev;
+- uint32_t rctl;
++ struct net_device *netdev = adapter->netdev;
++ uint32_t rctl;
+
+- iegbe_pci_clear_mwi(&adapter->hw);
++ iegbe_pci_clear_mwi(&adapter->hw);
+
+- rctl = E1000_READ_REG(&adapter->hw, RCTL);
+- rctl |= E1000_RCTL_RST;
+- E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
+- E1000_WRITE_FLUSH(&adapter->hw);
++ rctl = E1000_READ_REG(&adapter->hw, RCTL);
++ rctl |= E1000_RCTL_RST;
++ E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
++ E1000_WRITE_FLUSH(&adapter->hw);
+ mdelay(0x5);
+
+ if(netif_running(netdev)) {
+- iegbe_clean_all_rx_rings(adapter);
+-}
++ iegbe_clean_all_rx_rings(adapter);
++ }
+ }
+
+ static void
+ iegbe_leave_82542_rst(struct iegbe_adapter *adapter)
+ {
+- struct net_device *netdev = adapter->netdev;
+- uint32_t rctl;
++ struct net_device *netdev = adapter->netdev;
++ uint32_t rctl;
+
+- rctl = E1000_READ_REG(&adapter->hw, RCTL);
+- rctl &= ~E1000_RCTL_RST;
+- E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
+- E1000_WRITE_FLUSH(&adapter->hw);
++ rctl = E1000_READ_REG(&adapter->hw, RCTL);
++ rctl &= ~E1000_RCTL_RST;
++ E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
++ E1000_WRITE_FLUSH(&adapter->hw);
+ mdelay(0x5);
+
+ if(adapter->hw.pci_cmd_word & PCI_COMMAND_INVALIDATE) {
+- iegbe_pci_set_mwi(&adapter->hw);
++ iegbe_pci_set_mwi(&adapter->hw);
+ }
+ if(netif_running(netdev)) {
++ struct iegbe_rx_ring *ring = &adapter->rx_ring[0x0];
+ iegbe_configure_rx(adapter);
+-#ifdef IEGBE_GBE_WORKAROUND
+- iegbe_alloc_rx_buffers(adapter, &adapter->rx_ring[0],
+- IEGBE_GBE_WORKAROUND_NUM_RX_DESCRIPTORS + 1);
+-#else
+- iegbe_alloc_rx_buffers(adapter, &adapter->rx_ring[0]);
+-#endif
++ adapter->alloc_rx_buf(adapter, ring, E1000_DESC_UNUSED(ring));
+ }
+ }
+
+@@ -2358,133 +2124,153 @@ iegbe_leave_82542_rst(struct iegbe_adapt
+ * Returns 0 on success, negative on failure
+ **/
+
+-static int
+-iegbe_set_mac(struct net_device *netdev, void *p)
++static int iegbe_set_mac(struct net_device *netdev, void *p)
+ {
+- struct iegbe_adapter *adapter = netdev_priv(netdev);
+- struct sockaddr *addr = p;
++ struct iegbe_adapter *adapter = netdev_priv(netdev);
++ struct sockaddr *addr = p;
+
+ if(!is_valid_ether_addr(addr->sa_data)) {
+- return -EADDRNOTAVAIL;
++ return -EADDRNOTAVAIL;
+ }
+- /* 82542 2.0 needs to be in reset to write receive address registers */
++ /* 82542 2.0 needs to be in reset to write receive address registers */
+
+ if(adapter->hw.mac_type == iegbe_82542_rev2_0) {
+- iegbe_enter_82542_rst(adapter);
++ iegbe_enter_82542_rst(adapter);
+ }
+- memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
+- memcpy(adapter->hw.mac_addr, addr->sa_data, netdev->addr_len);
++ memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
++ memcpy(adapter->hw.mac_addr, addr->sa_data, netdev->addr_len);
+
+- iegbe_rar_set(&adapter->hw, adapter->hw.mac_addr, 0);
++ iegbe_rar_set(&adapter->hw, adapter->hw.mac_addr, 0x0);
+
+- /* With 82571 controllers, LAA may be overwritten (with the default)
+- * due to controller reset from the other port. */
+- if (adapter->hw.mac_type == iegbe_82571) {
+- /* activate the work around */
++ /* With 82571 controllers, LAA may be overwritten (with the default)
++ * due to controller reset from the other port. */
++ if (adapter->hw.mac_type == iegbe_82571) {
++ /* activate the work around */
+ adapter->hw.laa_is_present = 0x1;
+
+- /* Hold a copy of the LAA in RAR[14] This is done so that
+- * between the time RAR[0] gets clobbered and the time it
+- * gets fixed (in iegbe_watchdog), the actual LAA is in one
+- * of the RARs and no incoming packets directed to this port
+- * are dropped. Eventaully the LAA will be in RAR[0] and
+- * RAR[14] */
+- iegbe_rar_set(&adapter->hw, adapter->hw.mac_addr,
++ /* Hold a copy of the LAA in RAR[14] This is done so that
++ * between the time RAR[0] gets clobbered and the time it
++ * gets fixed (in iegbe_watchdog), the actual LAA is in one
++ * of the RARs and no incoming packets directed to this port
++ * are dropped. Eventaully the LAA will be in RAR[0] and
++ * RAR[14] */
++ iegbe_rar_set(&adapter->hw, adapter->hw.mac_addr,
+ E1000_RAR_ENTRIES - 0x1);
+- }
++ }
+
+ if(adapter->hw.mac_type == iegbe_82542_rev2_0) {
+- iegbe_leave_82542_rst(adapter);
++ iegbe_leave_82542_rst(adapter);
+ }
+- return 0;
++ return 0x0;
+ }
+
+ /**
+- * iegbe_set_multi - Multicast and Promiscuous mode set
++ * iegbe_set_rx_mode - Secondary Unicast, Multicast and Promiscuous mode set
+ * @netdev: network interface device structure
+ *
+- * The set_multi entry point is called whenever the multicast address
+- * list or the network interface flags are updated. This routine is
+- * responsible for configuring the hardware for proper multicast,
++ * The set_rx_mode entry point is called whenever the unicast or multicast
++ * address lists or the network interface flags are updated. This routine is
++ * responsible for configuring the hardware for proper unicast, multicast,
+ * promiscuous mode, and all-multi behavior.
+ **/
+
+-static void
+-iegbe_set_multi(struct net_device *netdev)
++static void iegbe_set_rx_mode(struct net_device *netdev)
+ {
+ struct iegbe_adapter *adapter = netdev_priv(netdev);
+ struct iegbe_hw *hw = &adapter->hw;
+- struct dev_mc_list *mc_ptr;
+- uint32_t rctl;
+- uint32_t hash_value;
++ struct dev_addr_list *uc_ptr;
++ struct dev_addr_list *mc_ptr;
++ u32 rctl;
++ u32 hash_value;
+ int i, rar_entries = E1000_RAR_ENTRIES;
++int mta_reg_count = E1000_NUM_MTA_REGISTERS;
+
+ /* reserve RAR[14] for LAA over-write work-around */
+- if (adapter->hw.mac_type == iegbe_82571) {
++ if (hw->mac_type == iegbe_82571)
+ rar_entries--;
+- }
++
+ /* Check for Promiscuous and All Multicast modes */
+
+- rctl = E1000_READ_REG(hw, RCTL);
++ rctl = E1000_READ_REG(&adapter->hw, RCTL);
+
+ if (netdev->flags & IFF_PROMISC) {
+ rctl |= (E1000_RCTL_UPE | E1000_RCTL_MPE);
+- } else if (netdev->flags & IFF_ALLMULTI) {
+- rctl |= E1000_RCTL_MPE;
+- rctl &= ~E1000_RCTL_UPE;
++ rctl &= ~E1000_RCTL_VFE;
+ } else {
+- rctl &= ~(E1000_RCTL_UPE | E1000_RCTL_MPE);
++ if (netdev->flags & IFF_ALLMULTI) {
++ rctl |= E1000_RCTL_MPE;
++ } else {
++ rctl &= ~E1000_RCTL_MPE;
++ }
++ }
++
++ uc_ptr = NULL;
++ if (netdev->uc_count > rar_entries - 1) {
++ rctl |= E1000_RCTL_UPE;
++ } else if (!(netdev->flags & IFF_PROMISC)) {
++ rctl &= ~E1000_RCTL_UPE;
++ uc_ptr = netdev->uc_list;
+ }
+
+- E1000_WRITE_REG(hw, RCTL, rctl);
++ E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
+
+ /* 82542 2.0 needs to be in reset to write receive address registers */
+
+- if (hw->mac_type == iegbe_82542_rev2_0) {
++ if (hw->mac_type == iegbe_82542_rev2_0)
+ iegbe_enter_82542_rst(adapter);
+- }
+- /* load the first 14 multicast address into the exact filters 1-14
++
++ /* load the first 14 addresses into the exact filters 1-14. Unicast
++ * addresses take precedence to avoid disabling unicast filtering
++ * when possible.
++ *
+ * RAR 0 is used for the station MAC adddress
+ * if there are not 14 addresses, go ahead and clear the filters
+ * -- with 82571 controllers only 0-13 entries are filled here
+ */
+ mc_ptr = netdev->mc_list;
+
+- for (i = 0x1; i < rar_entries; i++) {
+- if (mc_ptr) {
+- iegbe_rar_set(hw, mc_ptr->dmi_addr, i);
++ for (i = 1; i < rar_entries; i++) {
++ if (uc_ptr) {
++ iegbe_rar_set(hw, uc_ptr->da_addr, i);
++ uc_ptr = uc_ptr->next;
++ } else if (mc_ptr) {
++ iegbe_rar_set(hw, mc_ptr->da_addr, i);
+ mc_ptr = mc_ptr->next;
+ } else {
+- E1000_WRITE_REG_ARRAY(hw, RA, i << 0x1, 0);
+- E1000_WRITE_REG_ARRAY(hw, RA, (i << 0x1) + 0x1, 0);
++ E1000_WRITE_REG_ARRAY(hw, RA, i << 1, 0);
++ E1000_WRITE_FLUSH(&adapter->hw);
++ E1000_WRITE_REG_ARRAY(hw, RA, (i << 1) + 1, 0);
++ E1000_WRITE_FLUSH(&adapter->hw);
+ }
+ }
++ WARN_ON(uc_ptr != NULL);
+
+ /* clear the old settings from the multicast hash table */
+
+- for (i = 0; i < E1000_NUM_MTA_REGISTERS; i++)
++ for (i = 0; i < mta_reg_count; i++) {
+ E1000_WRITE_REG_ARRAY(hw, MTA, i, 0);
++ E1000_WRITE_FLUSH(&adapter->hw);
++ }
+
+ /* load any remaining addresses into the hash table */
+
+ for (; mc_ptr; mc_ptr = mc_ptr->next) {
+- hash_value = iegbe_hash_mc_addr(hw, mc_ptr->dmi_addr);
++ hash_value = iegbe_hash_mc_addr(hw, mc_ptr->da_addr);
+ iegbe_mta_set(hw, hash_value);
+ }
+
+- if (hw->mac_type == iegbe_82542_rev2_0) {
++ if (hw->mac_type == iegbe_82542_rev2_0)
+ iegbe_leave_82542_rst(adapter);
+ }
+-}
+
+ /* Need to wait a few seconds after link up to get diagnostic information from
+ * the phy */
+
+-static void
+-iegbe_update_phy_info(unsigned long data)
++static void iegbe_update_phy_info(unsigned long data)
+ {
+- struct iegbe_adapter *adapter = (struct iegbe_adapter *) data;
+- iegbe_phy_get_info(&adapter->hw, &adapter->phy_info);
++ struct iegbe_adapter *adapter = (struct iegbe_adapter *) data;
++ struct iegbe_hw *hw = &adapter->hw;
++ iegbe_phy_get_info(hw, &adapter->phy_info);
+ }
+
+ /**
+@@ -2492,54 +2278,54 @@ iegbe_update_phy_info(unsigned long data
+ * @data: pointer to adapter cast into an unsigned long
+ **/
+
+-static void
+-iegbe_82547_tx_fifo_stall(unsigned long data)
++static void iegbe_82547_tx_fifo_stall(unsigned long data)
+ {
+- struct iegbe_adapter *adapter = (struct iegbe_adapter *) data;
+- struct net_device *netdev = adapter->netdev;
+- uint32_t tctl;
++ struct iegbe_adapter *adapter = (struct iegbe_adapter *) data;
++ struct net_device *netdev = adapter->netdev;
++ u32 tctl;
+
+- if(atomic_read(&adapter->tx_fifo_stall)) {
+- if((E1000_READ_REG(&adapter->hw, TDT) ==
+- E1000_READ_REG(&adapter->hw, TDH)) &&
+- (E1000_READ_REG(&adapter->hw, TDFT) ==
+- E1000_READ_REG(&adapter->hw, TDFH)) &&
+- (E1000_READ_REG(&adapter->hw, TDFTS) ==
+- E1000_READ_REG(&adapter->hw, TDFHS))) {
+- tctl = E1000_READ_REG(&adapter->hw, TCTL);
+- E1000_WRITE_REG(&adapter->hw, TCTL,
+- tctl & ~E1000_TCTL_EN);
+- E1000_WRITE_REG(&adapter->hw, TDFT,
+- adapter->tx_head_addr);
+- E1000_WRITE_REG(&adapter->hw, TDFH,
+- adapter->tx_head_addr);
+- E1000_WRITE_REG(&adapter->hw, TDFTS,
+- adapter->tx_head_addr);
+- E1000_WRITE_REG(&adapter->hw, TDFHS,
+- adapter->tx_head_addr);
+- E1000_WRITE_REG(&adapter->hw, TCTL, tctl);
+- E1000_WRITE_FLUSH(&adapter->hw);
+-
+- adapter->tx_fifo_head = 0;
+- atomic_set(&adapter->tx_fifo_stall, 0);
+- netif_wake_queue(netdev);
+- } else {
++ if(atomic_read(&adapter->tx_fifo_stall)) {
++ if((E1000_READ_REG(&adapter->hw, TDT) ==
++ E1000_READ_REG(&adapter->hw, TDH)) &&
++ (E1000_READ_REG(&adapter->hw, TDFT) ==
++ E1000_READ_REG(&adapter->hw, TDFH)) &&
++ (E1000_READ_REG(&adapter->hw, TDFTS) ==
++ E1000_READ_REG(&adapter->hw, TDFHS))) {
++ tctl = E1000_READ_REG(&adapter->hw, TCTL);
++ E1000_WRITE_REG(&adapter->hw, TCTL,
++ tctl & ~E1000_TCTL_EN);
++ E1000_WRITE_REG(&adapter->hw, TDFT,
++ adapter->tx_head_addr);
++ E1000_WRITE_REG(&adapter->hw, TDFH,
++ adapter->tx_head_addr);
++ E1000_WRITE_REG(&adapter->hw, TDFTS,
++ adapter->tx_head_addr);
++ E1000_WRITE_REG(&adapter->hw, TDFHS,
++ adapter->tx_head_addr);
++ E1000_WRITE_REG(&adapter->hw, TCTL, tctl);
++ E1000_WRITE_FLUSH(&adapter->hw);
++
++ adapter->tx_fifo_head = 0x0;
++ atomic_set(&adapter->tx_fifo_stall, 0x0);
++ netif_wake_queue(netdev);
++ } else {
+ mod_timer(&adapter->tx_fifo_stall_timer, jiffies + 0x1);
+- }
+- }
++ }
++ }
+ }
+
++
+ /**
+ * iegbe_watchdog - Timer Call-back
+ * @data: pointer to adapter cast into an unsigned long
+ **/
+-static void
+-iegbe_watchdog(unsigned long data)
++static void iegbe_watchdog(unsigned long data)
+ {
+- struct iegbe_adapter *adapter = (struct iegbe_adapter *) data;
+- struct net_device *netdev = adapter->netdev;
+- struct iegbe_tx_ring *txdr = &adapter->tx_ring[0];
+- uint32_t link;
++ struct iegbe_adapter *adapter = (struct iegbe_adapter *) data;
++ struct iegbe_hw *hw = &adapter->hw;
++ struct net_device *netdev = adapter->netdev;
++ struct iegbe_tx_ring *txdr = adapter->tx_ring;
++ u32 link, tctl;
+
+ /*
+ * Test the PHY for link status on icp_xxxx MACs.
+@@ -2547,123 +2333,305 @@ iegbe_watchdog(unsigned long data)
+ * in the adapter->hw structure, then set hw->get_link_status = 1
+ */
+ if(adapter->hw.mac_type == iegbe_icp_xxxx) {
+- int isUp = 0;
++ int isUp = 0x0;
+ int32_t ret_val;
+
+ ret_val = iegbe_oem_phy_is_link_up(&adapter->hw, &isUp);
+ if(ret_val != E1000_SUCCESS) {
+- isUp = 0;
+- }
++ isUp = 0x0;
++ }
+ if(isUp != adapter->hw.icp_xxxx_is_link_up) {
+ adapter->hw.get_link_status = 0x1;
+ }
+ }
+
+- iegbe_check_for_link(&adapter->hw);
+- if (adapter->hw.mac_type == iegbe_82573) {
+- iegbe_enable_tx_pkt_filtering(&adapter->hw);
++ iegbe_check_for_link(&adapter->hw);
++ if (adapter->hw.mac_type == iegbe_82573) {
++ iegbe_enable_tx_pkt_filtering(&adapter->hw);
+ #ifdef NETIF_F_HW_VLAN_TX
+ if (adapter->mng_vlan_id != adapter->hw.mng_cookie.vlan_id) {
+- iegbe_update_mng_vlan(adapter);
++ iegbe_update_mng_vlan(adapter);
+ }
+ #endif
+- }
++ }
+
+- if ((adapter->hw.media_type == iegbe_media_type_internal_serdes) &&
+- !(E1000_READ_REG(&adapter->hw, TXCW) & E1000_TXCW_ANE)) {
+- link = !adapter->hw.serdes_link_down;
+- } else {
++ if ((adapter->hw.media_type == iegbe_media_type_internal_serdes) &&
++ !(E1000_READ_REG(&adapter->hw, TXCW) & E1000_TXCW_ANE)) {
++ link = !adapter->hw.serdes_link_down;
++ } else {
+
+- if(adapter->hw.mac_type != iegbe_icp_xxxx) {
+- link = E1000_READ_REG(&adapter->hw, STATUS) & E1000_STATUS_LU;
+- } else {
+- int isUp = 0;
++ if(adapter->hw.mac_type != iegbe_icp_xxxx) {
++ link = E1000_READ_REG(&adapter->hw, STATUS) & E1000_STATUS_LU;
++ } else {
++ int isUp = 0x0;
+ if(iegbe_oem_phy_is_link_up(&adapter->hw, &isUp) != E1000_SUCCESS) {
+- isUp = 0;
++ isUp = 0x0;
+ }
+- link = isUp;
+- }
+- }
++ link = isUp;
++ }
++ }
+
+- if (link) {
+- if (!netif_carrier_ok(netdev)) {
+- iegbe_get_speed_and_duplex(&adapter->hw,
+- &adapter->link_speed,
+- &adapter->link_duplex);
+-
+- DPRINTK(LINK, INFO, "NIC Link is Up %d Mbps %s\n",
+- adapter->link_speed,
+- adapter->link_duplex == FULL_DUPLEX ?
+- "Full Duplex" : "Half Duplex");
++ if (link) {
++ if (!netif_carrier_ok(netdev)) {
++ u32 ctrl;
++ bool txb2b = true;
++ iegbe_get_speed_and_duplex(hw,
++ &adapter->link_speed,
++ &adapter->link_duplex);
+
+- netif_carrier_on(netdev);
+- netif_wake_queue(netdev);
+- mod_timer(&adapter->phy_info_timer, jiffies + 0x2 * HZ);
++ ctrl = E1000_READ_REG(&adapter->hw, CTRL);
++ DPRINTK(LINK, INFO, "NIC Link is Up %d Mbps %s, "
++ "Flow Control: %s\n",
++ adapter->link_speed,
++ adapter->link_duplex == FULL_DUPLEX ?
++ "Full Duplex" : "Half Duplex",
++ ((ctrl & E1000_CTRL_TFCE) && (ctrl &
++ E1000_CTRL_RFCE)) ? "RX/TX" : ((ctrl &
++ E1000_CTRL_RFCE) ? "RX" : ((ctrl &
++ E1000_CTRL_TFCE) ? "TX" : "None" )));
++
++ /* tweak tx_queue_len according to speed/duplex
++ * and adjust the timeout factor */
++ netdev->tx_queue_len = adapter->tx_queue_len;
++ adapter->tx_timeout_factor = 1;
++ switch (adapter->link_speed) {
++ case SPEED_10:
++ txb2b = false;
++ netdev->tx_queue_len = 10;
++ adapter->tx_timeout_factor = 8;
++ break;
++ case SPEED_100:
++ txb2b = false;
++ netdev->tx_queue_len = 100;
++ break;
++ }
++ if ((hw->mac_type == iegbe_82571 ||
++ hw->mac_type == iegbe_82572) &&
++ !txb2b) {
++ u32 tarc0;
++ tarc0 = E1000_READ_REG(&adapter->hw, TARC0);
++ tarc0 &= ~(1 << 21);
++ E1000_WRITE_REG(&adapter->hw, TARC0, tarc0);
++ }
++ /* disable TSO for pcie and 10/100 speeds, to avoid
++ * some hardware issues */
++ if (!adapter->tso_force &&
++ hw->bus_type == iegbe_bus_type_pci_express){
++ switch (adapter->link_speed) {
++ case SPEED_10:
++ case SPEED_100:
++ DPRINTK(PROBE,INFO,
++ "10/100 speed: disabling TSO\n");
++ netdev->features &= ~NETIF_F_TSO;
++ netdev->features &= ~NETIF_F_TSO6;
++ break;
++ case SPEED_1000:
++ netdev->features |= NETIF_F_TSO;
++ netdev->features |= NETIF_F_TSO6;
++ break;
++ default:
++ break;
++ }
++ }
++ tctl = E1000_READ_REG(&adapter->hw, TCTL);
++ tctl |= E1000_TCTL_EN;
++ E1000_WRITE_REG(&adapter->hw, TCTL, tctl);
++ netif_carrier_on(netdev);
++ netif_wake_queue(netdev);
++ mod_timer(&adapter->phy_info_timer, round_jiffies(jiffies + 2 * HZ));
+ adapter->smartspeed = 0;
++ } else {
++ if (hw->rx_needs_kicking) {
++ u32 rctl = E1000_READ_REG(&adapter->hw, RCTL);
++ E1000_WRITE_REG(&adapter->hw, RCTL, rctl | E1000_RCTL_EN);
++ }
+ }
+- } else {
+- if (netif_carrier_ok(netdev)) {
++ } else {
++ if (netif_carrier_ok(netdev)) {
+ adapter->link_speed = 0;
+ adapter->link_duplex = 0;
+- DPRINTK(LINK, INFO, "NIC Link is Down\n");
+- netif_carrier_off(netdev);
+- netif_stop_queue(netdev);
+- mod_timer(&adapter->phy_info_timer, jiffies + 0x2 * HZ);
+- }
++ DPRINTK(LINK, INFO, "NIC Link is Down\n");
++ netif_carrier_off(netdev);
++ netif_stop_queue(netdev);
++ mod_timer(&adapter->phy_info_timer, round_jiffies(jiffies + 2 * HZ));
++ }
+
+- iegbe_smartspeed(adapter);
+- }
++ iegbe_smartspeed(adapter);
++ }
++
++ iegbe_update_stats(adapter);
++
++ hw->tx_packet_delta = adapter->stats.tpt - adapter->tpt_old;
++ adapter->tpt_old = adapter->stats.tpt;
++ hw->collision_delta = adapter->stats.colc - adapter->colc_old;
++ adapter->colc_old = adapter->stats.colc;
++
++ adapter->gorcl = adapter->stats.gorcl - adapter->gorcl_old;
++ adapter->gorcl_old = adapter->stats.gorcl;
++ adapter->gotcl = adapter->stats.gotcl - adapter->gotcl_old;
++ adapter->gotcl_old = adapter->stats.gotcl;
++
++ iegbe_update_adaptive(hw);
++
++ if (!netif_carrier_ok(netdev)) {
++ if (E1000_DESC_UNUSED(txdr) + 1 < txdr->count) {
++ /* We've lost link, so the controller stops DMA,
++ * but we've got queued Tx work that's never going
++ * to get done, so reset controller to flush Tx.
++ * (Do the reset outside of interrupt context). */
++ adapter->tx_timeout_count++;
++ schedule_work(&adapter->reset_task);
++ }
++ }
++
++ /* Cause software interrupt to ensure rx ring is cleaned */
++ E1000_WRITE_REG(&adapter->hw, ICS, E1000_ICS_RXDMT0);
++
++ /* Force detection of hung controller every watchdog period */
++ adapter->detect_tx_hung = TRUE;
++
++ /* With 82571 controllers, LAA may be overwritten due to controller
++ * reset from the other port. Set the appropriate LAA in RAR[0] */
++ if (adapter->hw.mac_type == iegbe_82571 && adapter->hw.laa_is_present) {
++ iegbe_rar_set(&adapter->hw, adapter->hw.mac_addr, 0x0);
++ }
++ /* Reset the timer */
++ mod_timer(&adapter->watchdog_timer, round_jiffies(jiffies + 2 * HZ));
++}
++
++enum latency_range {
++ lowest_latency = 0,
++ low_latency = 1,
++ bulk_latency = 2,
++ latency_invalid = 255
++};
+
+- iegbe_update_stats(adapter);
++/**
++ * iegbe_update_itr - update the dynamic ITR value based on statistics
++ * Stores a new ITR value based on packets and byte
++ * counts during the last interrupt. The advantage of per interrupt
++ * computation is faster updates and more accurate ITR for the current
++ * traffic pattern. Constants in this function were computed
++ * based on theoretical maximum wire speed and thresholds were set based
++ * on testing data as well as attempting to minimize response time
++ * while increasing bulk throughput.
++ * this functionality is controlled by the InterruptThrottleRate module
++ * parameter (see iegbe_param.c)
++ * @adapter: pointer to adapter
++ * @itr_setting: current adapter->itr
++ * @packets: the number of packets during this measurement interval
++ * @bytes: the number of bytes during this measurement interval
++ **/
++static unsigned int iegbe_update_itr(struct iegbe_adapter *adapter,
++ u16 itr_setting, int packets, int bytes)
++{
++ unsigned int retval = itr_setting;
++ struct iegbe_hw *hw = &adapter->hw;
+
+- adapter->hw.tx_packet_delta = adapter->stats.tpt - adapter->tpt_old;
+- adapter->tpt_old = adapter->stats.tpt;
+- adapter->hw.collision_delta = adapter->stats.colc - adapter->colc_old;
+- adapter->colc_old = adapter->stats.colc;
+-
+- adapter->gorcl = adapter->stats.gorcl - adapter->gorcl_old;
+- adapter->gorcl_old = adapter->stats.gorcl;
+- adapter->gotcl = adapter->stats.gotcl - adapter->gotcl_old;
+- adapter->gotcl_old = adapter->stats.gotcl;
+-
+- iegbe_update_adaptive(&adapter->hw);
+-
+- if (adapter->num_queues == 0x1 && !netif_carrier_ok(netdev)) {
+- if (E1000_DESC_UNUSED(txdr) + 0x1 < txdr->count) {
+- /* We've lost link, so the controller stops DMA,
+- * but we've got queued Tx work that's never going
+- * to get done, so reset controller to flush Tx.
+- * (Do the reset outside of interrupt context). */
+- schedule_work(&adapter->tx_timeout_task);
++ if (unlikely(hw->mac_type < iegbe_82540))
++ goto update_itr_done;
++
++ if (packets == 0)
++ goto update_itr_done;
++
++ switch (itr_setting) {
++ case lowest_latency:
++ /* jumbo frames get bulk treatment*/
++ if (bytes/packets > 8000)
++ retval = bulk_latency;
++ else if ((packets < 5) && (bytes > 512))
++ retval = low_latency;
++ break;
++ case low_latency: /* 50 usec aka 20000 ints/s */
++ if (bytes > 10000) {
++ /* jumbo frames need bulk latency setting */
++ if (bytes/packets > 8000)
++ retval = bulk_latency;
++ else if ((packets < 10) || ((bytes/packets) > 1200))
++ retval = bulk_latency;
++ else if ((packets > 35))
++ retval = lowest_latency;
++ } else if (bytes/packets > 2000)
++ retval = bulk_latency;
++ else if (packets <= 2 && bytes < 512)
++ retval = lowest_latency;
++ break;
++ case bulk_latency: /* 250 usec aka 4000 ints/s */
++ if (bytes > 25000) {
++ if (packets > 35)
++ retval = low_latency;
++ } else if (bytes < 6000) {
++ retval = low_latency;
+ }
++ break;
+ }
+
+- /* Dynamic mode for Interrupt Throttle Rate (ITR) */
+- if (adapter->hw.mac_type >= iegbe_82540 && adapter->itr == 0x1) {
+- /* Symmetric Tx/Rx gets a reduced ITR=2000; Total
+- * asymmetrical Tx or Rx gets ITR=8000; everyone
+- * else is between 2000-8000. */
+- uint32_t goc = (adapter->gotcl + adapter->gorcl) / 0x2710;
+- uint32_t dif = (adapter->gotcl > adapter->gorcl ?
+- adapter->gotcl - adapter->gorcl :
+- adapter->gorcl - adapter->gotcl) / 0x2710;
+- uint32_t itr = goc > 0 ? (dif * 0x1770 / goc + 0x7d0) : 0x1f40;
+- E1000_WRITE_REG(&adapter->hw, ITR, 0x3b9aca00 / (itr * 0x100));
+- }
++update_itr_done:
++ return retval;
++}
+
+- /* Cause software interrupt to ensure rx ring is cleaned */
+- E1000_WRITE_REG(&adapter->hw, ICS, E1000_ICS_RXDMT0);
++static void iegbe_set_itr(struct iegbe_adapter *adapter)
++{
++ struct iegbe_hw *hw = &adapter->hw;
++ u16 current_itr;
++ u32 new_itr = adapter->itr;
+
+- /* Force detection of hung controller every watchdog period */
+- adapter->detect_tx_hung = TRUE;
++ if (unlikely(hw->mac_type < iegbe_82540))
++ return;
+
+- /* With 82571 controllers, LAA may be overwritten due to controller
+- * reset from the other port. Set the appropriate LAA in RAR[0] */
+- if (adapter->hw.mac_type == iegbe_82571 && adapter->hw.laa_is_present) {
+- iegbe_rar_set(&adapter->hw, adapter->hw.mac_addr, 0);
+- }
+- /* Reset the timer */
+- mod_timer(&adapter->watchdog_timer, jiffies + 0x2 * HZ);
++ /* for non-gigabit speeds, just fix the interrupt rate at 4000 */
++ if (unlikely(adapter->link_speed != SPEED_1000)) {
++ current_itr = 0;
++ new_itr = 4000;
++ goto set_itr_now;
++ }
++
++ adapter->tx_itr = iegbe_update_itr(adapter,
++ adapter->tx_itr,
++ adapter->total_tx_packets,
++ adapter->total_tx_bytes);
++ /* conservative mode (itr 3) eliminates the lowest_latency setting */
++ if (adapter->itr_setting == 3 && adapter->tx_itr == lowest_latency)
++ adapter->tx_itr = low_latency;
++
++ adapter->rx_itr = iegbe_update_itr(adapter,
++ adapter->rx_itr,
++ adapter->total_rx_packets,
++ adapter->total_rx_bytes);
++ /* conservative mode (itr 3) eliminates the lowest_latency setting */
++ if (adapter->itr_setting == 3 && adapter->rx_itr == lowest_latency)
++ adapter->rx_itr = low_latency;
++
++ current_itr = max(adapter->rx_itr, adapter->tx_itr);
++
++ switch (current_itr) {
++ /* counts and packets in update_itr are dependent on these numbers */
++ case lowest_latency:
++ new_itr = 70000;
++ break;
++ case low_latency:
++ new_itr = 20000; /* aka hwitr = ~200 */
++ break;
++ case bulk_latency:
++ new_itr = 4000;
++ break;
++ default:
++ break;
++ }
++
++set_itr_now:
++ if (new_itr != adapter->itr) {
++ /* this attempts to bias the interrupt rate towards Bulk
++ * by adding intermediate steps when interrupt rate is
++ * increasing */
++ new_itr = new_itr > adapter->itr ?
++ min(adapter->itr + (new_itr >> 2), new_itr) :
++ new_itr;
++ adapter->itr = new_itr;
++ E1000_WRITE_REG(&adapter->hw, ITR, 1000000000 / (new_itr * 256));
++ }
++
++ return;
+ }
+
+ #define E1000_TX_FLAGS_CSUM 0x00000001
+@@ -2673,55 +2641,48 @@ iegbe_watchdog(unsigned long data)
+ #define E1000_TX_FLAGS_VLAN_MASK 0xffff0000
+ #define E1000_TX_FLAGS_VLAN_SHIFT 16
+
+-static inline int
+-iegbe_tso(struct iegbe_adapter *adapter, struct iegbe_tx_ring *tx_ring,
+- struct sk_buff *skb)
++static int iegbe_tso(struct iegbe_adapter *adapter,
++ struct iegbe_tx_ring *tx_ring, struct sk_buff *skb)
+ {
+-#ifdef NETIF_F_TSO
+ struct iegbe_context_desc *context_desc;
++ struct iegbe_buffer *buffer_info;
+ unsigned int i;
+- uint32_t cmd_length = 0;
+- uint16_t ipcse = 0, tucse, mss;
+- uint8_t ipcss, ipcso, tucss, tucso, hdr_len;
++ u32 cmd_length = 0;
++ u16 ipcse = 0, tucse, mss;
++ u8 ipcss, ipcso, tucss, tucso, hdr_len;
+ int err;
+
+ if (skb_is_gso(skb)) {
+ if (skb_header_cloned(skb)) {
+ err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC);
+- if (err) {
++ if (err)
+ return err;
+ }
+- }
+
+- hdr_len = ((skb->h.raw - skb->data) + (skb->h.th->doff << 0x2));
++ hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
+ mss = skb_shinfo(skb)->gso_size;
+ if (skb->protocol == htons(ETH_P_IP)) {
+- skb->nh.iph->tot_len = 0;
+- skb->nh.iph->check = 0;
+- skb->h.th->check =
+- ~csum_tcpudp_magic(skb->nh.iph->saddr,
+- skb->nh.iph->daddr,
+- 0,
+- IPPROTO_TCP,
+- 0);
++ struct iphdr *iph = ip_hdr(skb);
++ iph->tot_len = 0;
++ iph->check = 0;
++ tcp_hdr(skb)->check = ~csum_tcpudp_magic(iph->saddr,
++ iph->daddr, 0,
++ IPPROTO_TCP,
++ 0);
+ cmd_length = E1000_TXD_CMD_IP;
+- ipcse = skb->h.raw - skb->data - 0x1;
+-#ifdef NETIF_F_TSO_IPV6
+- } else if (skb->protocol == ntohs(ETH_P_IPV6)) {
+- skb->nh.ipv6h->payload_len = 0;
+- skb->h.th->check =
+- ~csum_ipv6_magic(&skb->nh.ipv6h->saddr,
+- &skb->nh.ipv6h->daddr,
+- 0,
+- IPPROTO_TCP,
+- 0);
++ ipcse = skb_transport_offset(skb) - 1;
++ } else if (skb->protocol == htons(ETH_P_IPV6)) {
++ ipv6_hdr(skb)->payload_len = 0;
++ tcp_hdr(skb)->check =
++ ~csum_ipv6_magic(&ipv6_hdr(skb)->saddr,
++ &ipv6_hdr(skb)->daddr,
++ 0, IPPROTO_TCP, 0);
+ ipcse = 0;
+-#endif
+ }
+- ipcss = skb->nh.raw - skb->data;
+- ipcso = (void *)&(skb->nh.iph->check) - (void *)skb->data;
+- tucss = skb->h.raw - skb->data;
+- tucso = (void *)&(skb->h.th->check) - (void *)skb->data;
++ ipcss = skb_network_offset(skb);
++ ipcso = (void *)&(ip_hdr(skb)->check) - (void *)skb->data;
++ tucss = skb_transport_offset(skb);
++ tucso = (void *)&(tcp_hdr(skb)->check) - (void *)skb->data;
+ tucse = 0;
+
+ cmd_length |= (E1000_TXD_CMD_DEXT | E1000_TXD_CMD_TSE |
+@@ -2729,6 +2690,7 @@ iegbe_tso(struct iegbe_adapter *adapter,
+
+ i = tx_ring->next_to_use;
+ context_desc = E1000_CONTEXT_DESC(*tx_ring, i);
++ buffer_info = &tx_ring->buffer_info[i];
+
+ context_desc->lower_setup.ip_fields.ipcss = ipcss;
+ context_desc->lower_setup.ip_fields.ipcso = ipcso;
+@@ -2740,205 +2702,218 @@ iegbe_tso(struct iegbe_adapter *adapter,
+ context_desc->tcp_seg_setup.fields.hdr_len = hdr_len;
+ context_desc->cmd_and_length = cpu_to_le32(cmd_length);
+
+- if (++i == tx_ring->count) { i = 0; }
++ buffer_info->time_stamp = jiffies;
++ buffer_info->next_to_watch = i;
++
++ if (++i == tx_ring->count) i = 0;
+ tx_ring->next_to_use = i;
+
+- return TRUE;
++ return true;
+ }
+-#endif
+-
+- return FALSE;
++ return false;
+ }
+
+-static inline boolean_t
+-iegbe_tx_csum(struct iegbe_adapter *adapter, struct iegbe_tx_ring *tx_ring,
+- struct sk_buff *skb)
++static bool iegbe_tx_csum(struct iegbe_adapter *adapter,
++ struct iegbe_tx_ring *tx_ring, struct sk_buff *skb)
+ {
+ struct iegbe_context_desc *context_desc;
++ struct iegbe_buffer *buffer_info;
+ unsigned int i;
+- uint8_t css;
++ u8 css;
+
+- if (likely(skb->ip_summed == CHECKSUM_HW)) {
+- css = skb->h.raw - skb->data;
++ if (likely(skb->ip_summed == CHECKSUM_PARTIAL)) {
++ css = skb_transport_offset(skb);
+
+- i = tx_ring->next_to_use;
+- context_desc = E1000_CONTEXT_DESC(*tx_ring, i);
++ i = tx_ring->next_to_use;
++ buffer_info = &tx_ring->buffer_info[i];
++ context_desc = E1000_CONTEXT_DESC(*tx_ring, i);
+
++ context_desc->lower_setup.ip_config = 0;
+ context_desc->upper_setup.tcp_fields.tucss = css;
+- context_desc->upper_setup.tcp_fields.tucso = css + skb->csum;
++ context_desc->upper_setup.tcp_fields.tucso =
++ css + skb->csum_offset;
+ context_desc->upper_setup.tcp_fields.tucse = 0;
+ context_desc->tcp_seg_setup.data = 0;
+ context_desc->cmd_and_length = cpu_to_le32(E1000_TXD_CMD_DEXT);
+
+- if (unlikely(++i == tx_ring->count)) { i = 0; }
++ buffer_info->time_stamp = jiffies;
++ buffer_info->next_to_watch = i;
++
++ if (unlikely(++i == tx_ring->count)) i = 0;
+ tx_ring->next_to_use = i;
+
+- return TRUE;
++ return true;
+ }
+
+- return FALSE;
++ return false;
+ }
+
+-#define E1000_MAX_TXD_PWR 12
+-#define E1000_MAX_DATA_PER_TXD (1<<E1000_MAX_TXD_PWR)
++#define E1000_MAX_TXD_PWR 12
++#define E1000_MAX_DATA_PER_TXD (1<<E1000_MAX_TXD_PWR)
+
+-static inline int
+-iegbe_tx_map(struct iegbe_adapter *adapter, struct iegbe_tx_ring *tx_ring,
+- struct sk_buff *skb, unsigned int first, unsigned int max_per_txd,
+- unsigned int nr_frags, unsigned int mss)
++static int iegbe_tx_map(struct iegbe_adapter *adapter,
++ struct iegbe_tx_ring *tx_ring,
++ struct sk_buff *skb, unsigned int first,
++ unsigned int max_per_txd, unsigned int nr_frags,
++ unsigned int mss)
+ {
+- struct iegbe_buffer *buffer_info;
+- unsigned int len = skb->len;
++ struct iegbe_hw *hw = &adapter->hw;
++ struct iegbe_buffer *buffer_info;
++ unsigned int len = skb->len;
+ unsigned int offset = 0, size, count = 0, i;
+-#ifdef MAX_SKB_FRAGS
+- unsigned int f;
+- len -= skb->data_len;
+-#endif
++ unsigned int f;
++ len -= skb->data_len;
+
+- i = tx_ring->next_to_use;
++ i = tx_ring->next_to_use;
++
++ while(len) {
++ buffer_info = &tx_ring->buffer_info[i];
++ size = min(len, max_per_txd);
++ /* Workaround for Controller erratum --
++ * descriptor for non-tso packet in a linear SKB that follows a
++ * tso gets written back prematurely before the data is fully
++ * DMA'd to the controller */
++ if (!skb->data_len && tx_ring->last_tx_tso &&
++ !skb_is_gso(skb)) {
++ tx_ring->last_tx_tso = 0;
++ size -= 4;
++ }
+
+- while(len) {
+- buffer_info = &tx_ring->buffer_info[i];
+- size = min(len, max_per_txd);
+-#ifdef NETIF_F_TSO
+ /* Workaround for premature desc write-backs
+ * in TSO mode. Append 4-byte sentinel desc */
+- if(unlikely(mss && !nr_frags && size == len && size > 0x8)) {
+- size -= 0x4;
++ if (unlikely(mss && !nr_frags && size == len && size > 8))
++ size -= 4;
++ /* work-around for errata 10 and it applies
++ * to all controllers in PCI-X mode
++ * The fix is to make sure that the first descriptor of a
++ * packet is smaller than 2048 - 16 - 16 (or 2016) bytes
++ */
++ if (unlikely((hw->bus_type == iegbe_bus_type_pcix) &&
++ (size > 2015) && count == 0))
++ size = 2015;
++
++ /* Workaround for potential 82544 hang in PCI-X. Avoid
++ * terminating buffers within evenly-aligned dwords. */
++ if(unlikely(adapter->pcix_82544 &&
++ !((unsigned long)(skb->data + offset + size - 1) & 4) &&
++ size > 4))
++ size -= 4;
++
++ buffer_info->length = size;
++ buffer_info->dma =
++ pci_map_single(adapter->pdev,
++ skb->data + offset,
++ size,
++ PCI_DMA_TODEVICE);
++ buffer_info->time_stamp = jiffies;
++ buffer_info->next_to_watch = i;
++
++ len -= size;
++ offset += size;
++ count++;
++ if (unlikely(++i == tx_ring->count)) i = 0;
++ }
++
++ for (f = 0; f < nr_frags; f++) {
++ struct skb_frag_struct *frag;
++
++ frag = &skb_shinfo(skb)->frags[f];
++ len = frag->size;
++ offset = frag->page_offset;
++
++ while(len) {
++ buffer_info = &tx_ring->buffer_info[i];
++ size = min(len, max_per_txd);
++ /* Workaround for premature desc write-backs
++ * in TSO mode. Append 4-byte sentinel desc */
++ if (unlikely(mss && f == (nr_frags-1) && size == len && size > 8))
++ size -= 4;
++ /* Workaround for potential 82544 hang in PCI-X.
++ * Avoid terminating buffers within evenly-aligned
++ * dwords. */
++ if(unlikely(adapter->pcix_82544 &&
++ !((unsigned long)(frag->page+offset+size-1) & 4) &&
++ size > 4))
++ size -= 4;
++
++ buffer_info->length = size;
++ buffer_info->dma =
++ pci_map_page(adapter->pdev,
++ frag->page,
++ offset,
++ size,
++ PCI_DMA_TODEVICE);
++ buffer_info->time_stamp = jiffies;
++ buffer_info->next_to_watch = i;
++
++ len -= size;
++ offset += size;
++ count++;
++ if (unlikely(++i == tx_ring->count)) i = 0;
+ }
+-#endif
+- /* work-around for errata 10 and it applies
+- * to all controllers in PCI-X mode
+- * The fix is to make sure that the first descriptor of a
+- * packet is smaller than 2048 - 16 - 16 (or 2016) bytes
+- */
+- if(unlikely((adapter->hw.bus_type == iegbe_bus_type_pcix) &&
+- (size > 0x7df) && count == 0)) {
+- size = 0x7df;
+- }
+- /* Workaround for potential 82544 hang in PCI-X. Avoid
+- * terminating buffers within evenly-aligned dwords. */
+- if(unlikely(adapter->pcix_82544 &&
+- !((unsigned long)(skb->data + offset + size - 0x8) & 0x4) &&
+- size > 0x4)) {
+- size -= 0x4;
+- }
+- buffer_info->length = size;
+- buffer_info->dma =
+- pci_map_single(adapter->pdev,
+- skb->data + offset,
+- size,
+- PCI_DMA_TODEVICE);
+- buffer_info->time_stamp = jiffies;
+-
+- len -= size;
+- offset += size;
+- count++;
+- if(unlikely(++i == tx_ring->count)) { i = 0; }
+- }
+-
+-#ifdef MAX_SKB_FRAGS
+- for(f = 0; f < nr_frags; f++) {
+- struct skb_frag_struct *frag;
+-
+- frag = &skb_shinfo(skb)->frags[f];
+- len = frag->size;
+- offset = frag->page_offset;
+-
+- while(len) {
+- buffer_info = &tx_ring->buffer_info[i];
+- size = min(len, max_per_txd);
+-#ifdef NETIF_F_TSO
+- /* Workaround for premature desc write-backs
+- * in TSO mode. Append 4-byte sentinel desc */
+- if(unlikely(mss && f == (nr_frags-0x1) &&
+- size == len && size > 0x8)) {
+- size -= 0x4;
+- }
+-#endif
+- /* Workaround for potential 82544 hang in PCI-X.
+- * Avoid terminating buffers within evenly-aligned
+- * dwords. */
+- if(unlikely(adapter->pcix_82544 &&
+- !((unsigned long)(frag->page+offset+size-0x1) & 0x4) &&
+- size > 0x4)) {
+- size -= 0x4;
+- }
+- buffer_info->length = size;
+- buffer_info->dma =
+- pci_map_page(adapter->pdev,
+- frag->page,
+- offset,
+- size,
+- PCI_DMA_TODEVICE);
+- buffer_info->time_stamp = jiffies;
+-
+- len -= size;
+- offset += size;
+- count++;
+- if(unlikely(++i == tx_ring->count)) { i = 0; }
+- }
+- }
+-#endif
++ }
+
+- i = (i == 0) ? tx_ring->count - 0x1 : i - 0x1;
+- tx_ring->buffer_info[i].skb = skb;
+- tx_ring->buffer_info[first].next_to_watch = i;
++ i = (i == 0) ? tx_ring->count - 1 : i - 1;
++ tx_ring->buffer_info[i].skb = skb;
++ tx_ring->buffer_info[first].next_to_watch = i;
+
+- return count;
++ return count;
+ }
+
+-static inline void
+-iegbe_tx_queue(struct iegbe_adapter *adapter, struct iegbe_tx_ring *tx_ring,
+- int tx_flags, int count)
++static void iegbe_tx_queue(struct iegbe_adapter *adapter,
++ struct iegbe_tx_ring *tx_ring, int tx_flags,
++ int count)
+ {
++ struct iegbe_hw *hw = &adapter->hw;
+ struct iegbe_tx_desc *tx_desc = NULL;
+ struct iegbe_buffer *buffer_info;
+- uint32_t txd_upper = 0, txd_lower = E1000_TXD_CMD_IFCS;
++ u32 txd_upper = 0, txd_lower = E1000_TXD_CMD_IFCS;
+ unsigned int i;
+
+- if(likely(tx_flags & E1000_TX_FLAGS_TSO)) {
++ if (likely(tx_flags & E1000_TX_FLAGS_TSO)) {
+ txd_lower |= E1000_TXD_CMD_DEXT | E1000_TXD_DTYP_D |
+ E1000_TXD_CMD_TSE;
+- txd_upper |= E1000_TXD_POPTS_TXSM << 0x8;
++ txd_upper |= E1000_TXD_POPTS_TXSM << 8;
+
+- if(likely(tx_flags & E1000_TX_FLAGS_IPV4)) {
+- txd_upper |= E1000_TXD_POPTS_IXSM << 0x8;
+- }
++ if (likely(tx_flags & E1000_TX_FLAGS_IPV4))
++ txd_upper |= E1000_TXD_POPTS_IXSM << 8;
+ }
+
+- if(likely(tx_flags & E1000_TX_FLAGS_CSUM)) {
++ if (likely(tx_flags & E1000_TX_FLAGS_CSUM)) {
+ txd_lower |= E1000_TXD_CMD_DEXT | E1000_TXD_DTYP_D;
+- txd_upper |= E1000_TXD_POPTS_TXSM << 0x8;
+- }
+-
+- if(unlikely(tx_flags & E1000_TX_FLAGS_VLAN)) {
+- txd_lower |= E1000_TXD_CMD_VLE;
+- txd_upper |= (tx_flags & E1000_TX_FLAGS_VLAN_MASK);
++ txd_upper |= E1000_TXD_POPTS_TXSM << 8;
+ }
+
+- i = tx_ring->next_to_use;
++ if(unlikely(tx_flags & E1000_TX_FLAGS_VLAN)) {
++ txd_lower |= E1000_TXD_CMD_VLE;
++ txd_upper |= (tx_flags & E1000_TX_FLAGS_VLAN_MASK);
++ }
+
+- while(count--) {
+- buffer_info = &tx_ring->buffer_info[i];
+- tx_desc = E1000_TX_DESC(*tx_ring, i);
+- tx_desc->buffer_addr = cpu_to_le64(buffer_info->dma);
+- tx_desc->lower.data =
+- cpu_to_le32(txd_lower | buffer_info->length);
+- tx_desc->upper.data = cpu_to_le32(txd_upper);
+- if(unlikely(++i == tx_ring->count)) { i = 0; }
+- }
+- if(tx_desc != NULL) {
+- tx_desc->lower.data |= cpu_to_le32(adapter->txd_cmd);
+- }
+- /* Force memory writes to complete before letting h/w
+- * know there are new descriptors to fetch. (Only
+- * applicable for weak-ordered memory model archs,
+- * such as IA-64). */
+- wmb();
++ i = tx_ring->next_to_use;
+
+- tx_ring->next_to_use = i;
+- writel(i, adapter->hw.hw_addr + tx_ring->tdt);
++ while(count--) {
++ buffer_info = &tx_ring->buffer_info[i];
++ tx_desc = E1000_TX_DESC(*tx_ring, i);
++ tx_desc->buffer_addr = cpu_to_le64(buffer_info->dma);
++ tx_desc->lower.data =
++ cpu_to_le32(txd_lower | buffer_info->length);
++ tx_desc->upper.data = cpu_to_le32(txd_upper);
++ if (unlikely(++i == tx_ring->count)) i = 0;
++ }
++
++ tx_desc->lower.data |= cpu_to_le32(adapter->txd_cmd);
++
++ /* Force memory writes to complete before letting h/w
++ * know there are new descriptors to fetch. (Only
++ * applicable for weak-ordered memory model archs,
++ * such as IA-64). */
++ wmb();
++
++ tx_ring->next_to_use = i;
++ writel(i, hw->hw_addr + tx_ring->tdt);
++ /* we need this if more than one processor can write to our tail
++ * at a time, it syncronizes IO on IA64/Altix systems */
++ mmiowb();
+ }
+
+ /**
+@@ -2950,113 +2925,132 @@ iegbe_tx_queue(struct iegbe_adapter *ada
+ * to the beginning of the Tx FIFO.
+ **/
+
+-static inline int
+-iegbe_82547_fifo_workaround(struct iegbe_adapter *adapter, struct sk_buff *skb)
++#define E1000_FIFO_HDR 0x10
++#define E1000_82547_PAD_LEN 0x3E0
++static int iegbe_82547_fifo_workaround(struct iegbe_adapter *adapter,
++ struct sk_buff *skb)
+ {
+- uint32_t fifo_space = adapter->tx_fifo_size - adapter->tx_fifo_head;
+- uint32_t skb_fifo_len = skb->len + E1000_FIFO_HDR;
++ u32 fifo_space = adapter->tx_fifo_size - adapter->tx_fifo_head;
++ u32 skb_fifo_len = skb->len + E1000_FIFO_HDR;
+
+- E1000_ROUNDUP(skb_fifo_len, E1000_FIFO_HDR);
++ skb_fifo_len = ALIGN(skb_fifo_len, E1000_FIFO_HDR);
+
+- if(adapter->link_duplex != HALF_DUPLEX) {
+- goto no_fifo_stall_required;
+- }
+- if(atomic_read(&adapter->tx_fifo_stall)) {
+- return 1;
++ if (adapter->link_duplex != HALF_DUPLEX)
++ goto no_fifo_stall_required;
++
++ if (atomic_read(&adapter->tx_fifo_stall))
++ return 1;
++
++ if(skb_fifo_len >= (E1000_82547_PAD_LEN + fifo_space)) {
++ atomic_set(&adapter->tx_fifo_stall, 1);
++ return 1;
+ }
+- if(skb_fifo_len >= (E1000_82547_PAD_LEN + fifo_space)) {
+- atomic_set(&adapter->tx_fifo_stall, 0x1);
+- return 1;
+- }
+
+ no_fifo_stall_required:
+- adapter->tx_fifo_head += skb_fifo_len;
+- if(adapter->tx_fifo_head >= adapter->tx_fifo_size) {
+- adapter->tx_fifo_head -= adapter->tx_fifo_size;
+- }
++ adapter->tx_fifo_head += skb_fifo_len;
++ if (adapter->tx_fifo_head >= adapter->tx_fifo_size)
++ adapter->tx_fifo_head -= adapter->tx_fifo_size;
+ return 0;
+ }
+
+-static inline int
+-iegbe_transfer_dhcp_info(struct iegbe_adapter *adapter, struct sk_buff *skb)
++#define MINIMUM_DHCP_PACKET_SIZE 282
++static int iegbe_transfer_dhcp_info(struct iegbe_adapter *adapter,
++ struct sk_buff *skb)
+ {
+ struct iegbe_hw *hw = &adapter->hw;
+- uint16_t length, offset;
+-#ifdef NETIF_F_HW_VLAN_TX
+- if(vlan_tx_tag_present(skb)) {
+- if(!((vlan_tx_tag_get(skb) == adapter->hw.mng_cookie.vlan_id) &&
+- ( adapter->hw.mng_cookie.status &
+- E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT)) ) {
++ u16 length, offset;
++ if (vlan_tx_tag_present(skb)) {
++ if (!((vlan_tx_tag_get(skb) == hw->mng_cookie.vlan_id) &&
++ ( hw->mng_cookie.status &
++ E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT)) )
+ return 0;
+ }
+- }
+-#endif
+- if(htons(ETH_P_IP) == skb->protocol) {
+- const struct iphdr *ip = skb->nh.iph;
+- if(IPPROTO_UDP == ip->protocol) {
+- struct udphdr *udp = (struct udphdr *)(skb->h.uh);
+- if(ntohs(udp->dest) == 0x43) { /* 0x43 = 67 */
+- offset = (uint8_t *)udp + 0x8 - skb->data;
+- length = skb->len - offset;
+-
+- return iegbe_mng_write_dhcp_info(hw,
+- (uint8_t *)udp + 0x8, length);
+- }
+- }
+- } else if((skb->len > MINIMUM_DHCP_PACKET_SIZE) && (!skb->protocol)) {
+- struct ethhdr *eth = (struct ethhdr *) skb->data;
+- if((htons(ETH_P_IP) == eth->h_proto)) {
++ if (skb->len > MINIMUM_DHCP_PACKET_SIZE) {
++ struct ethhdr *eth = (struct ethhdr *)skb->data;
++ if ((htons(ETH_P_IP) == eth->h_proto)) {
+ const struct iphdr *ip =
+- (struct iphdr *)((uint8_t *)skb->data+0xe);
+- if(IPPROTO_UDP == ip->protocol) {
++ (struct iphdr *)((u8 *)skb->data+14);
++ if (IPPROTO_UDP == ip->protocol) {
+ struct udphdr *udp =
+- (struct udphdr *)((uint8_t *)ip +
+- (ip->ihl << 0x2));
+- if(ntohs(udp->dest) == 0x43) {
+- offset = (uint8_t *)udp + 0x8 - skb->data;
++ (struct udphdr *)((u8 *)ip +
++ (ip->ihl << 2));
++ if (ntohs(udp->dest) == 67) {
++ offset = (u8 *)udp + 8 - skb->data;
+ length = skb->len - offset;
+
+ return iegbe_mng_write_dhcp_info(hw,
+- (uint8_t *)udp + 0x8,
++ (u8 *)udp + 8,
+ length);
+- }
++ }
+ }
+ }
+ }
+ return 0;
+ }
+
+-static int
+-iegbe_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
++static int __iegbe_maybe_stop_tx(struct net_device *netdev, int size)
++{
++ struct iegbe_adapter *adapter = netdev_priv(netdev);
++ struct iegbe_tx_ring *tx_ring = adapter->tx_ring;
++
++ netif_stop_queue(netdev);
++ /* Herbert's original patch had:
++ * smp_mb__after_netif_stop_queue();
++ * but since that doesn't exist yet, just open code it. */
++ smp_mb();
++
++ /* We need to check again in a case another CPU has just
++ * made room available. */
++ if (likely(E1000_DESC_UNUSED(tx_ring) < size))
++ return -EBUSY;
++
++ /* A reprieve! */
++ netif_start_queue(netdev);
++ ++adapter->restart_queue;
++ return 0;
++}
++
++static int iegbe_maybe_stop_tx(struct net_device *netdev,
++ struct iegbe_tx_ring *tx_ring, int size)
++{
++ if (likely(E1000_DESC_UNUSED(tx_ring) >= size))
++ return 0;
++ return __iegbe_maybe_stop_tx(netdev, size);
++}
++
++#define TXD_USE_COUNT(S, X) (((S) >> (X)) + 1 )
++static int iegbe_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
+ {
+ struct iegbe_adapter *adapter = netdev_priv(netdev);
++ struct iegbe_hw *hw = &adapter->hw;
+ struct iegbe_tx_ring *tx_ring;
+ unsigned int first, max_per_txd = E1000_MAX_DATA_PER_TXD;
+ unsigned int max_txd_pwr = E1000_MAX_TXD_PWR;
+ unsigned int tx_flags = 0;
+- unsigned int len = skb->len;
++ unsigned int len = skb->len - skb->data_len;
+ unsigned long flags = 0;
+- unsigned int nr_frags = 0;
+- unsigned int mss = 0;
++ unsigned int nr_frags;
++ unsigned int mss;
+ int count = 0;
+- int tso;
+-#ifdef MAX_SKB_FRAGS
++ int tso;
+ unsigned int f;
+- len -= skb->data_len;
+-#endif
+
+-#ifdef CONFIG_E1000_MQ
+- tx_ring = *per_cpu_ptr(adapter->cpu_tx_ring, smp_processor_id());
+-#else
++ /* This goes back to the question of how to logically map a tx queue
++ * to a flow. Right now, performance is impacted slightly negatively
++ * if using multiple tx queues. If the stack breaks away from a
++ * single qdisc implementation, we can look at this again. */
+ tx_ring = adapter->tx_ring;
+-#endif
+
+ if (unlikely(skb->len <= 0)) {
+ dev_kfree_skb_any(skb);
+ return NETDEV_TX_OK;
+ }
+
+-#ifdef NETIF_F_TSO
++ /* 82571 and newer doesn't need the workaround that limited descriptor
++ * length to 4kB */
++ if (hw->mac_type >= iegbe_82571)
++ max_per_txd = 8192;
++
+ mss = skb_shinfo(skb)->gso_size;
+ /* The controller does a simple calculation to
+ * make sure there is enough room in the FIFO before
+@@ -3064,164 +3058,150 @@ iegbe_xmit_frame(struct sk_buff *skb, st
+ * 4 = ceil(buffer len/mss). To make sure we don't
+ * overrun the FIFO, adjust the max buffer len if mss
+ * drops. */
+- if(mss) {
+- max_per_txd = min(mss << 0x2, max_per_txd);
+- max_txd_pwr = fls(max_per_txd) - 0x1;
++ if (mss) {
++ u8 hdr_len;
++ max_per_txd = min(mss << 2, max_per_txd);
++ max_txd_pwr = fls(max_per_txd) - 1;
++
++ /* TSO Workaround for 82571/2/3 Controllers -- if skb->data
++ * points to just header, pull a few bytes of payload from
++ * frags into skb->data */
++ hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
++ if (skb->data_len && hdr_len == len) {
++ switch (hw->mac_type) {
++ case iegbe_82544:
++ /* Make sure we have room to chop off 4 bytes,
++ * and that the end alignment will work out to
++ * this hardware's requirements
++ * NOTE: this is a TSO only workaround
++ * if end byte alignment not correct move us
++ * into the next dword */
++ break;
++ /* fall through */
++ case iegbe_82571:
++ case iegbe_82572:
++ case iegbe_82573:
++ break;
++ default:
++ /* do nothing */
++ break;
++ }
++ }
+ }
+
+- if((mss) || (skb->ip_summed == CHECKSUM_HW)) {
++ /* reserve a descriptor for the offload context */
++ if ((mss) || (skb->ip_summed == CHECKSUM_PARTIAL))
+ count++;
+- }
+ count++;
+-#else
+- if(skb->ip_summed == CHECKSUM_HW) {
++
++ /* Controller Erratum workaround */
++ if (!skb->data_len && tx_ring->last_tx_tso && !skb_is_gso(skb))
+ count++;
+- {
+-#endif
++
+ count += TXD_USE_COUNT(len, max_txd_pwr);
+
+- if(adapter->pcix_82544) {
++ if (adapter->pcix_82544)
+ count++;
+- }
++
+ /* work-around for errata 10 and it applies to all controllers
+ * in PCI-X mode, so add one more descriptor to the count
+ */
+- if(unlikely((adapter->hw.bus_type == iegbe_bus_type_pcix) &&
+- (len > 0x7df))) {
++ if (unlikely((hw->bus_type == iegbe_bus_type_pcix) &&
++ (len > 2015)))
+ count++;
+- }
+-#ifdef MAX_SKB_FRAGS
++
+ nr_frags = skb_shinfo(skb)->nr_frags;
+- for(f = 0; f < nr_frags; f++)
++ for (f = 0; f < nr_frags; f++)
+ count += TXD_USE_COUNT(skb_shinfo(skb)->frags[f].size,
+ max_txd_pwr);
+- if(adapter->pcix_82544) {
++ if (adapter->pcix_82544)
+ count += nr_frags;
+- }
+-#ifdef NETIF_F_TSO
+- /* TSO Workaround for 82571/2 Controllers -- if skb->data
+- * points to just header, pull a few bytes of payload from
+- * frags into skb->data */
+- if (skb_is_gso(skb)) {
+- uint8_t hdr_len;
+- hdr_len = ((skb->h.raw - skb->data) + (skb->h.th->doff << 0x2));
+- if (skb->data_len && (hdr_len < (skb->len - skb->data_len)) &&
+- (adapter->hw.mac_type == iegbe_82571 ||
+- adapter->hw.mac_type == iegbe_82572)) {
+- unsigned int pull_size;
+- pull_size = min((unsigned int)0x4, skb->data_len);
+- if (!__pskb_pull_tail(skb, pull_size)) {
+- printk(KERN_ERR "__pskb_pull_tail failed.\n");
+- dev_kfree_skb_any(skb);
+- return -EFAULT;
+- }
+- }
+- }
+-#endif
+-#endif
+
+- if(adapter->hw.tx_pkt_filtering && (adapter->hw.mac_type == iegbe_82573) ) {
++
++ if (hw->tx_pkt_filtering &&
++ (hw->mac_type == iegbe_82573))
+ iegbe_transfer_dhcp_info(adapter, skb);
+- }
+-#ifdef NETIF_F_LLTX
+- local_irq_save(flags);
+- if (!spin_trylock(&tx_ring->tx_lock)) {
++
++ if (!spin_trylock_irqsave(&tx_ring->tx_lock, flags))
+ /* Collision - tell upper layer to requeue */
+- local_irq_restore(flags);
+ return NETDEV_TX_LOCKED;
+- }
+-#else
+- spin_lock_irqsave(&tx_ring->tx_lock, flags);
+-#endif
+
+ /* need: count + 2 desc gap to keep tail from touching
+ * head, otherwise try next time */
+- if (unlikely(E1000_DESC_UNUSED(tx_ring) < count + 0x2)) {
+- netif_stop_queue(netdev);
++ if (unlikely(iegbe_maybe_stop_tx(netdev, tx_ring, count + 2))) {
+ spin_unlock_irqrestore(&tx_ring->tx_lock, flags);
+ return NETDEV_TX_BUSY;
+ }
+
+- if(unlikely(adapter->hw.mac_type == iegbe_82547)) {
+- if(unlikely(iegbe_82547_fifo_workaround(adapter, skb))) {
++ if (unlikely(hw->mac_type == iegbe_82547)) {
++ if (unlikely(iegbe_82547_fifo_workaround(adapter, skb))) {
+ netif_stop_queue(netdev);
+- mod_timer(&adapter->tx_fifo_stall_timer, jiffies);
++ mod_timer(&adapter->tx_fifo_stall_timer, jiffies + 1);
+ spin_unlock_irqrestore(&tx_ring->tx_lock, flags);
+ return NETDEV_TX_BUSY;
+ }
+ }
+
+-#ifndef NETIF_F_LLTX
+- spin_unlock_irqrestore(&tx_ring->tx_lock, flags);
+-#endif
+-
+-#ifdef NETIF_F_HW_VLAN_TX
+- if(unlikely(adapter->vlgrp && vlan_tx_tag_present(skb))) {
++ if (unlikely(adapter->vlgrp && vlan_tx_tag_present(skb))) {
+ tx_flags |= E1000_TX_FLAGS_VLAN;
+ tx_flags |= (vlan_tx_tag_get(skb) << E1000_TX_FLAGS_VLAN_SHIFT);
+ }
+-#endif
+
+ first = tx_ring->next_to_use;
+
+ tso = iegbe_tso(adapter, tx_ring, skb);
+ if (tso < 0) {
+ dev_kfree_skb_any(skb);
+-#ifdef NETIF_F_LLTX
+ spin_unlock_irqrestore(&tx_ring->tx_lock, flags);
+-#endif
+ return NETDEV_TX_OK;
+ }
+
+- if (likely(tso)) {
++ if (likely(tso)) {
++ tx_ring->last_tx_tso = 1;
+ tx_flags |= E1000_TX_FLAGS_TSO;
+- } else if (likely(iegbe_tx_csum(adapter, tx_ring, skb))) {
++ } else if (likely(iegbe_tx_csum(adapter, tx_ring, skb)))
+ tx_flags |= E1000_TX_FLAGS_CSUM;
+- }
++
+ /* Old method was to assume IPv4 packet by default if TSO was enabled.
+ * 82571 hardware supports TSO capabilities for IPv6 as well...
+ * no longer assume, we must. */
+- if (likely(skb->protocol == ntohs(ETH_P_IP))) {
++ if (likely(skb->protocol == htons(ETH_P_IP)))
+ tx_flags |= E1000_TX_FLAGS_IPV4;
+- }
++
+ iegbe_tx_queue(adapter, tx_ring, tx_flags,
+ iegbe_tx_map(adapter, tx_ring, skb, first,
+ max_per_txd, nr_frags, mss));
+
+ netdev->trans_start = jiffies;
+
+-#ifdef NETIF_F_LLTX
+ /* Make sure there is space in the ring for the next send. */
+- if (unlikely(E1000_DESC_UNUSED(tx_ring) < MAX_SKB_FRAGS + 0x2)) {
+- netif_stop_queue(netdev);
+- }
+- spin_unlock_irqrestore(&tx_ring->tx_lock, flags);
+-#endif
++ iegbe_maybe_stop_tx(netdev, tx_ring, MAX_SKB_FRAGS + 2);
+
++ spin_unlock_irqrestore(&tx_ring->tx_lock, flags);
+ return NETDEV_TX_OK;
+ }
+
++
+ /**
+ * iegbe_tx_timeout - Respond to a Tx Hang
+ * @netdev: network interface device structure
+ **/
+
+-static void
+-iegbe_tx_timeout(struct net_device *netdev)
++static void iegbe_tx_timeout(struct net_device *netdev)
+ {
+- struct iegbe_adapter *adapter = netdev_priv(netdev);
++ struct iegbe_adapter *adapter = netdev_priv(netdev);
+
+- /* Do the reset outside of interrupt context */
+- schedule_work(&adapter->tx_timeout_task);
++ /* Do the reset outside of interrupt context */
++ adapter->tx_timeout_count++;
++ schedule_work(&adapter->reset_task);
+ }
+
+-static void
+-iegbe_tx_timeout_task(struct net_device *netdev)
++static void iegbe_reset_task(struct work_struct *work)
+ {
+- struct iegbe_adapter *adapter = netdev_priv(netdev);
++ struct iegbe_adapter *adapter =
++ container_of(work, struct iegbe_adapter, reset_task);
+
+- iegbe_down(adapter);
+- iegbe_up(adapter);
++ iegbe_reinit_locked(adapter);
+ }
+
+ /**
+@@ -3232,13 +3212,12 @@ iegbe_tx_timeout_task(struct net_device
+ * The statistics are actually updated from the timer callback.
+ **/
+
+-static struct net_device_stats *
+-iegbe_get_stats(struct net_device *netdev)
++static struct net_device_stats *iegbe_get_stats(struct net_device *netdev)
+ {
+- struct iegbe_adapter *adapter = netdev_priv(netdev);
++ struct iegbe_adapter *adapter = netdev_priv(netdev);
+
+- iegbe_update_stats(adapter);
+- return &adapter->net_stats;
++ /* only return the current stats */
++ return &adapter->net_stats;
+ }
+
+ /**
+@@ -3249,67 +3228,55 @@ iegbe_get_stats(struct net_device *netde
+ * Returns 0 on success, negative on failure
+ **/
+
+-static int
+-iegbe_change_mtu(struct net_device *netdev, int new_mtu)
++static int iegbe_change_mtu(struct net_device *netdev, int new_mtu)
+ {
+- struct iegbe_adapter *adapter = netdev_priv(netdev);
+- int max_frame = new_mtu + ENET_HEADER_SIZE + ETHERNET_FCS_SIZE;
++ struct iegbe_adapter *adapter = netdev_priv(netdev);
++ struct iegbe_hw *hw = &adapter->hw;
++ int max_frame = new_mtu + ENET_HEADER_SIZE + ETHERNET_FCS_SIZE;
+
+- if((max_frame < MINIMUM_ETHERNET_FRAME_SIZE) ||
+- (max_frame > MAX_JUMBO_FRAME_SIZE)) {
+- DPRINTK(PROBE, ERR, "Invalid MTU setting\n");
+- return -EINVAL;
+- }
++ if((max_frame < MINIMUM_ETHERNET_FRAME_SIZE) ||
++ (max_frame > MAX_JUMBO_FRAME_SIZE)) {
++ DPRINTK(PROBE, ERR, "Invalid MTU setting\n");
++ return -EINVAL;
++ }
+
++ /* Adapter-specific max frame size limits. */
++ switch (hw->mac_type) {
++ case iegbe_undefined ... iegbe_82542_rev2_1:
++ if (max_frame > MAXIMUM_ETHERNET_FRAME_SIZE) {
++ DPRINTK(PROBE, ERR, "Jumbo Frames not supported.\n");
++ return -EINVAL;
++ }
++ break;
++ case iegbe_82571:
++ case iegbe_82572:
+ #define MAX_STD_JUMBO_FRAME_SIZE 9234
+- /* might want this to be bigger enum check... */
+- /* 82571 controllers limit jumbo frame size to 10500 bytes */
+- if ((adapter->hw.mac_type == iegbe_82571 ||
+- adapter->hw.mac_type == iegbe_82572) &&
+- max_frame > MAX_STD_JUMBO_FRAME_SIZE) {
+- DPRINTK(PROBE, ERR, "MTU > 9216 bytes not supported "
+- "on 82571 and 82572 controllers.\n");
+- return -EINVAL;
+- }
+-
+- if(adapter->hw.mac_type == iegbe_82573 &&
+- max_frame > MAXIMUM_ETHERNET_FRAME_SIZE) {
+- DPRINTK(PROBE, ERR, "Jumbo Frames not supported "
+- "on 82573\n");
+- return -EINVAL;
+- }
+-
+- if(adapter->hw.mac_type > iegbe_82547_rev_2) {
+- adapter->rx_buffer_len = max_frame;
+- E1000_ROUNDUP(adapter->rx_buffer_len, 0x1024);
+- } else {
+- if(unlikely((adapter->hw.mac_type < iegbe_82543) &&
+- (max_frame > MAXIMUM_ETHERNET_FRAME_SIZE))) {
+- DPRINTK(PROBE, ERR, "Jumbo Frames not supported "
+- "on 82542\n");
+- return -EINVAL;
+-
+- } else {
+- if(max_frame <= E1000_RXBUFFER_2048) {
+- adapter->rx_buffer_len = E1000_RXBUFFER_2048;
+- } else if(max_frame <= E1000_RXBUFFER_4096) {
+- adapter->rx_buffer_len = E1000_RXBUFFER_4096;
+- } else if(max_frame <= E1000_RXBUFFER_8192) {
+- adapter->rx_buffer_len = E1000_RXBUFFER_8192;
+- } else if(max_frame <= E1000_RXBUFFER_16384) {
+- adapter->rx_buffer_len = E1000_RXBUFFER_16384;
+- }
++ if (max_frame > MAX_STD_JUMBO_FRAME_SIZE) {
++ DPRINTK(PROBE, ERR, "MTU > 9216 not supported.\n");
++ return -EINVAL;
+ }
++ break;
++ default:
++ break;
+ }
++ if (max_frame <= E1000_RXBUFFER_256)
++ adapter->rx_buffer_len = E1000_RXBUFFER_256;
++ else if (max_frame <= E1000_RXBUFFER_2048)
++ adapter->rx_buffer_len = E1000_RXBUFFER_2048;
++ else if (max_frame <= E1000_RXBUFFER_4096)
++ adapter->rx_buffer_len = E1000_RXBUFFER_4096;
++ else if (max_frame <= E1000_RXBUFFER_8192)
++ adapter->rx_buffer_len = E1000_RXBUFFER_8192;
++ else if (max_frame <= E1000_RXBUFFER_16384)
++ adapter->rx_buffer_len = E1000_RXBUFFER_16384;
+
+- netdev->mtu = new_mtu;
++ /* adjust allocation if LPE protects us, and we aren't using SBP */
+
+- if(netif_running(netdev)) {
+- iegbe_down(adapter);
+- iegbe_up(adapter);
+- }
++ netdev->mtu = new_mtu;
++ hw->max_frame_size = max_frame;
+
+- adapter->hw.max_frame_size = max_frame;
++ if (netif_running(netdev))
++ iegbe_reinit_locked(adapter);
+
+ return 0;
+ }
+@@ -3319,224 +3286,189 @@ iegbe_change_mtu(struct net_device *netd
+ * @adapter: board private structure
+ **/
+
+-void
+-iegbe_update_stats(struct iegbe_adapter *adapter)
++void iegbe_update_stats(struct iegbe_adapter *adapter)
+ {
+- struct iegbe_hw *hw = &adapter->hw;
+- unsigned long flags = 0;
+- uint16_t phy_tmp;
++ struct iegbe_hw *hw = &adapter->hw;
++ unsigned long flags = 0x0;
++ uint16_t phy_tmp;
+
+ #define PHY_IDLE_ERROR_COUNT_MASK 0x00FF
+
+- spin_lock_irqsave(&adapter->stats_lock, flags);
++ spin_lock_irqsave(&adapter->stats_lock, flags);
+
+- /* these counters are modified from iegbe_adjust_tbi_stats,
+- * called from the interrupt context, so they must only
+- * be written while holding adapter->stats_lock
+- */
++ /* these counters are modified from iegbe_adjust_tbi_stats,
++ * called from the interrupt context, so they must only
++ * be written while holding adapter->stats_lock
++ */
+
+- adapter->stats.crcerrs += E1000_READ_REG(hw, CRCERRS);
+- adapter->stats.gprc += E1000_READ_REG(hw, GPRC);
+- adapter->stats.gorcl += E1000_READ_REG(hw, GORCL);
+- adapter->stats.gorch += E1000_READ_REG(hw, GORCH);
+- adapter->stats.bprc += E1000_READ_REG(hw, BPRC);
+- adapter->stats.mprc += E1000_READ_REG(hw, MPRC);
+- adapter->stats.roc += E1000_READ_REG(hw, ROC);
+- adapter->stats.prc64 += E1000_READ_REG(hw, PRC64);
+- adapter->stats.prc127 += E1000_READ_REG(hw, PRC127);
+- adapter->stats.prc255 += E1000_READ_REG(hw, PRC255);
+- adapter->stats.prc511 += E1000_READ_REG(hw, PRC511);
+- adapter->stats.prc1023 += E1000_READ_REG(hw, PRC1023);
+- adapter->stats.prc1522 += E1000_READ_REG(hw, PRC1522);
+-
+- adapter->stats.symerrs += E1000_READ_REG(hw, SYMERRS);
+- adapter->stats.mpc += E1000_READ_REG(hw, MPC);
+- adapter->stats.scc += E1000_READ_REG(hw, SCC);
+- adapter->stats.ecol += E1000_READ_REG(hw, ECOL);
+- adapter->stats.mcc += E1000_READ_REG(hw, MCC);
+- adapter->stats.latecol += E1000_READ_REG(hw, LATECOL);
+- adapter->stats.dc += E1000_READ_REG(hw, DC);
+- adapter->stats.sec += E1000_READ_REG(hw, SEC);
+- adapter->stats.rlec += E1000_READ_REG(hw, RLEC);
+- adapter->stats.xonrxc += E1000_READ_REG(hw, XONRXC);
+- adapter->stats.xontxc += E1000_READ_REG(hw, XONTXC);
+- adapter->stats.xoffrxc += E1000_READ_REG(hw, XOFFRXC);
+- adapter->stats.xofftxc += E1000_READ_REG(hw, XOFFTXC);
+- adapter->stats.fcruc += E1000_READ_REG(hw, FCRUC);
+- adapter->stats.gptc += E1000_READ_REG(hw, GPTC);
+- adapter->stats.gotcl += E1000_READ_REG(hw, GOTCL);
+- adapter->stats.gotch += E1000_READ_REG(hw, GOTCH);
+- adapter->stats.rnbc += E1000_READ_REG(hw, RNBC);
+- adapter->stats.ruc += E1000_READ_REG(hw, RUC);
+- adapter->stats.rfc += E1000_READ_REG(hw, RFC);
+- adapter->stats.rjc += E1000_READ_REG(hw, RJC);
+- adapter->stats.torl += E1000_READ_REG(hw, TORL);
+- adapter->stats.torh += E1000_READ_REG(hw, TORH);
+- adapter->stats.totl += E1000_READ_REG(hw, TOTL);
+- adapter->stats.toth += E1000_READ_REG(hw, TOTH);
+- adapter->stats.tpr += E1000_READ_REG(hw, TPR);
+- adapter->stats.ptc64 += E1000_READ_REG(hw, PTC64);
+- adapter->stats.ptc127 += E1000_READ_REG(hw, PTC127);
+- adapter->stats.ptc255 += E1000_READ_REG(hw, PTC255);
+- adapter->stats.ptc511 += E1000_READ_REG(hw, PTC511);
+- adapter->stats.ptc1023 += E1000_READ_REG(hw, PTC1023);
+- adapter->stats.ptc1522 += E1000_READ_REG(hw, PTC1522);
+- adapter->stats.mptc += E1000_READ_REG(hw, MPTC);
+- adapter->stats.bptc += E1000_READ_REG(hw, BPTC);
+-
+- /* used for adaptive IFS */
+-
+- hw->tx_packet_delta = E1000_READ_REG(hw, TPT);
+- adapter->stats.tpt += hw->tx_packet_delta;
+- hw->collision_delta = E1000_READ_REG(hw, COLC);
+- adapter->stats.colc += hw->collision_delta;
+-
+- if(hw->mac_type >= iegbe_82543) {
+- adapter->stats.algnerrc += E1000_READ_REG(hw, ALGNERRC);
+- adapter->stats.rxerrc += E1000_READ_REG(hw, RXERRC);
+- adapter->stats.tncrs += E1000_READ_REG(hw, TNCRS);
+- adapter->stats.cexterr += E1000_READ_REG(hw, CEXTERR);
+- adapter->stats.tsctc += E1000_READ_REG(hw, TSCTC);
+- adapter->stats.tsctfc += E1000_READ_REG(hw, TSCTFC);
+- }
+- if(hw->mac_type > iegbe_82547_rev_2) {
+- adapter->stats.iac += E1000_READ_REG(hw, IAC);
+- adapter->stats.icrxoc += E1000_READ_REG(hw, ICRXOC);
+- adapter->stats.icrxptc += E1000_READ_REG(hw, ICRXPTC);
+- adapter->stats.icrxatc += E1000_READ_REG(hw, ICRXATC);
+- adapter->stats.ictxptc += E1000_READ_REG(hw, ICTXPTC);
+- adapter->stats.ictxatc += E1000_READ_REG(hw, ICTXATC);
+- adapter->stats.ictxqec += E1000_READ_REG(hw, ICTXQEC);
+- adapter->stats.ictxqmtc += E1000_READ_REG(hw, ICTXQMTC);
+- adapter->stats.icrxdmtc += E1000_READ_REG(hw, ICRXDMTC);
+- }
+-
+- /* Fill out the OS statistics structure */
+-
+- adapter->net_stats.rx_packets = adapter->stats.gprc;
+- adapter->net_stats.tx_packets = adapter->stats.gptc;
+- adapter->net_stats.rx_bytes = adapter->stats.gorcl;
+- adapter->net_stats.tx_bytes = adapter->stats.gotcl;
+- adapter->net_stats.multicast = adapter->stats.mprc;
+- adapter->net_stats.collisions = adapter->stats.colc;
+-
+- /* Rx Errors */
+-
+- adapter->net_stats.rx_errors = adapter->stats.rxerrc +
+- adapter->stats.crcerrs + adapter->stats.algnerrc +
+- adapter->stats.rlec + adapter->stats.mpc +
+- adapter->stats.cexterr;
+- adapter->net_stats.rx_dropped = adapter->stats.mpc;
+- adapter->net_stats.rx_length_errors = adapter->stats.rlec;
+- adapter->net_stats.rx_crc_errors = adapter->stats.crcerrs;
+- adapter->net_stats.rx_frame_errors = adapter->stats.algnerrc;
+- adapter->net_stats.rx_fifo_errors = adapter->stats.mpc;
+- adapter->net_stats.rx_missed_errors = adapter->stats.mpc;
+-
+- /* Tx Errors */
+-
+- adapter->net_stats.tx_errors = adapter->stats.ecol +
+- adapter->stats.latecol;
+- adapter->net_stats.tx_aborted_errors = adapter->stats.ecol;
+- adapter->net_stats.tx_window_errors = adapter->stats.latecol;
+- adapter->net_stats.tx_carrier_errors = adapter->stats.tncrs;
++ adapter->stats.crcerrs += E1000_READ_REG(hw, CRCERRS);
++ adapter->stats.gprc += E1000_READ_REG(hw, GPRC);
++ adapter->stats.gorcl += E1000_READ_REG(hw, GORCL);
++ adapter->stats.gorch += E1000_READ_REG(hw, GORCH);
++ adapter->stats.bprc += E1000_READ_REG(hw, BPRC);
++ adapter->stats.mprc += E1000_READ_REG(hw, MPRC);
++ adapter->stats.roc += E1000_READ_REG(hw, ROC);
++ adapter->stats.prc64 += E1000_READ_REG(hw, PRC64);
++ adapter->stats.prc127 += E1000_READ_REG(hw, PRC127);
++ adapter->stats.prc255 += E1000_READ_REG(hw, PRC255);
++ adapter->stats.prc511 += E1000_READ_REG(hw, PRC511);
++ adapter->stats.prc1023 += E1000_READ_REG(hw, PRC1023);
++ adapter->stats.prc1522 += E1000_READ_REG(hw, PRC1522);
++
++ adapter->stats.symerrs += E1000_READ_REG(hw, SYMERRS);
++ adapter->stats.mpc += E1000_READ_REG(hw, MPC);
++ adapter->stats.scc += E1000_READ_REG(hw, SCC);
++ adapter->stats.ecol += E1000_READ_REG(hw, ECOL);
++ adapter->stats.mcc += E1000_READ_REG(hw, MCC);
++ adapter->stats.latecol += E1000_READ_REG(hw, LATECOL);
++ adapter->stats.dc += E1000_READ_REG(hw, DC);
++ adapter->stats.sec += E1000_READ_REG(hw, SEC);
++ adapter->stats.rlec += E1000_READ_REG(hw, RLEC);
++ adapter->stats.xonrxc += E1000_READ_REG(hw, XONRXC);
++ adapter->stats.xontxc += E1000_READ_REG(hw, XONTXC);
++ adapter->stats.xoffrxc += E1000_READ_REG(hw, XOFFRXC);
++ adapter->stats.xofftxc += E1000_READ_REG(hw, XOFFTXC);
++ adapter->stats.fcruc += E1000_READ_REG(hw, FCRUC);
++ adapter->stats.gptc += E1000_READ_REG(hw, GPTC);
++ adapter->stats.gotcl += E1000_READ_REG(hw, GOTCL);
++ adapter->stats.gotch += E1000_READ_REG(hw, GOTCH);
++ adapter->stats.rnbc += E1000_READ_REG(hw, RNBC);
++ adapter->stats.ruc += E1000_READ_REG(hw, RUC);
++ adapter->stats.rfc += E1000_READ_REG(hw, RFC);
++ adapter->stats.rjc += E1000_READ_REG(hw, RJC);
++ adapter->stats.torl += E1000_READ_REG(hw, TORL);
++ adapter->stats.torh += E1000_READ_REG(hw, TORH);
++ adapter->stats.totl += E1000_READ_REG(hw, TOTL);
++ adapter->stats.toth += E1000_READ_REG(hw, TOTH);
++ adapter->stats.tpr += E1000_READ_REG(hw, TPR);
++ adapter->stats.ptc64 += E1000_READ_REG(hw, PTC64);
++ adapter->stats.ptc127 += E1000_READ_REG(hw, PTC127);
++ adapter->stats.ptc255 += E1000_READ_REG(hw, PTC255);
++ adapter->stats.ptc511 += E1000_READ_REG(hw, PTC511);
++ adapter->stats.ptc1023 += E1000_READ_REG(hw, PTC1023);
++ adapter->stats.ptc1522 += E1000_READ_REG(hw, PTC1522);
++ adapter->stats.mptc += E1000_READ_REG(hw, MPTC);
++ adapter->stats.bptc += E1000_READ_REG(hw, BPTC);
++
++ /* used for adaptive IFS */
++
++ hw->tx_packet_delta = E1000_READ_REG(hw, TPT);
++ adapter->stats.tpt += hw->tx_packet_delta;
++ hw->collision_delta = E1000_READ_REG(hw, COLC);
++ adapter->stats.colc += hw->collision_delta;
++
++ if(hw->mac_type >= iegbe_82543) {
++ adapter->stats.algnerrc += E1000_READ_REG(hw, ALGNERRC);
++ adapter->stats.rxerrc += E1000_READ_REG(hw, RXERRC);
++ adapter->stats.tncrs += E1000_READ_REG(hw, TNCRS);
++ adapter->stats.cexterr += E1000_READ_REG(hw, CEXTERR);
++ adapter->stats.tsctc += E1000_READ_REG(hw, TSCTC);
++ adapter->stats.tsctfc += E1000_READ_REG(hw, TSCTFC);
++ }
++ if(hw->mac_type > iegbe_82547_rev_2) {
++ adapter->stats.iac += E1000_READ_REG(hw, IAC);
++ adapter->stats.icrxoc += E1000_READ_REG(hw, ICRXOC);
++ adapter->stats.icrxptc += E1000_READ_REG(hw, ICRXPTC);
++ adapter->stats.icrxatc += E1000_READ_REG(hw, ICRXATC);
++ adapter->stats.ictxptc += E1000_READ_REG(hw, ICTXPTC);
++ adapter->stats.ictxatc += E1000_READ_REG(hw, ICTXATC);
++ adapter->stats.ictxqec += E1000_READ_REG(hw, ICTXQEC);
++ adapter->stats.ictxqmtc += E1000_READ_REG(hw, ICTXQMTC);
++ adapter->stats.icrxdmtc += E1000_READ_REG(hw, ICRXDMTC);
++ }
++
++ /* Fill out the OS statistics structure */
++
++ adapter->net_stats.rx_packets = adapter->stats.gprc;
++ adapter->net_stats.tx_packets = adapter->stats.gptc;
++ adapter->net_stats.rx_bytes = adapter->stats.gorcl;
++ adapter->net_stats.tx_bytes = adapter->stats.gotcl;
++ adapter->net_stats.multicast = adapter->stats.mprc;
++ adapter->net_stats.collisions = adapter->stats.colc;
++
++ /* Rx Errors */
++
++ adapter->net_stats.rx_errors = adapter->stats.rxerrc +
++ adapter->stats.crcerrs + adapter->stats.algnerrc +
++ adapter->stats.rlec + adapter->stats.mpc +
++ adapter->stats.cexterr;
++ adapter->net_stats.rx_dropped = adapter->stats.mpc;
++ adapter->net_stats.rx_length_errors = adapter->stats.rlec;
++ adapter->net_stats.rx_crc_errors = adapter->stats.crcerrs;
++ adapter->net_stats.rx_frame_errors = adapter->stats.algnerrc;
++ adapter->net_stats.rx_fifo_errors = adapter->stats.mpc;
++ adapter->net_stats.rx_missed_errors = adapter->stats.mpc;
++
++ /* Tx Errors */
++
++ adapter->net_stats.tx_errors = adapter->stats.ecol +
++ adapter->stats.latecol;
++ adapter->net_stats.tx_aborted_errors = adapter->stats.ecol;
++ adapter->net_stats.tx_window_errors = adapter->stats.latecol;
++ adapter->net_stats.tx_carrier_errors = adapter->stats.tncrs;
+
+- /* Tx Dropped needs to be maintained elsewhere */
++ /* Tx Dropped needs to be maintained elsewhere */
+
+- /* Phy Stats */
++ /* Phy Stats */
+
+- if(hw->media_type == iegbe_media_type_copper
++ if(hw->media_type == iegbe_media_type_copper
+ || (hw->media_type == iegbe_media_type_oem
+ && iegbe_oem_phy_is_copper(&adapter->hw))) {
+- if((adapter->link_speed == SPEED_1000) &&
+- (!iegbe_read_phy_reg(hw, PHY_1000T_STATUS, &phy_tmp))) {
+- phy_tmp &= PHY_IDLE_ERROR_COUNT_MASK;
+- adapter->phy_stats.idle_errors += phy_tmp;
+- }
++ if((adapter->link_speed == SPEED_1000) &&
++ (!iegbe_read_phy_reg(hw, PHY_1000T_STATUS, &phy_tmp))) {
++ phy_tmp &= PHY_IDLE_ERROR_COUNT_MASK;
++ adapter->phy_stats.idle_errors += phy_tmp;
++ }
+
+- if((hw->mac_type <= iegbe_82546) &&
+- (hw->phy_type == iegbe_phy_m88) &&
++ if((hw->mac_type <= iegbe_82546) &&
++ (hw->phy_type == iegbe_phy_m88) &&
+ !iegbe_read_phy_reg(hw, M88E1000_RX_ERR_CNTR, &phy_tmp)) {
+- adapter->phy_stats.receive_errors += phy_tmp;
+- }
++ adapter->phy_stats.receive_errors += phy_tmp;
++ }
+ }
+
+- spin_unlock_irqrestore(&adapter->stats_lock, flags);
++ spin_unlock_irqrestore(&adapter->stats_lock, flags);
+ }
+
+-#ifdef CONFIG_E1000_MQ
+-void
+-iegbe_rx_schedule(void *data)
++/**
++ * iegbe_intr_msi - Interrupt Handler
++ * @irq: interrupt number
++ * @data: pointer to a network interface device structure
++ **/
++
++static irqreturn_t iegbe_intr_msi(int irq, void *data)
+ {
+- struct net_device *poll_dev, *netdev = data;
+- struct iegbe_adapter *adapter = netdev->priv;
+- int this_cpu = get_cpu();
+-
+- poll_dev = *per_cpu_ptr(adapter->cpu_netdev, this_cpu);
+- if (poll_dev == NULL) {
+- put_cpu();
+- return;
++ struct net_device *netdev = data;
++ struct iegbe_adapter *adapter = netdev_priv(netdev);
++ struct iegbe_hw *hw = &adapter->hw;
++ u32 icr = E1000_READ_REG(&adapter->hw, ICR);
++ if (icr & (E1000_ICR_RXSEQ | E1000_ICR_LSC)) {
++ hw->get_link_status = 1;
++ if (!test_bit(__E1000_DOWN, &adapter->flags))
++ mod_timer(&adapter->watchdog_timer, jiffies + 1);
+ }
+
+- if (likely(netif_rx_schedule_prep(poll_dev))) {
+- __netif_rx_schedule(poll_dev);
+- } else {
+- iegbe_irq_enable(adapter);
+- }
+- put_cpu();
+-}
+-#endif
+-
+-#ifdef IEGBE_GBE_WORKAROUND
+-/*
+- * Check for tx hang condition. This is the condition where a
+- * decsriptor is in the hardware and hasn't been processed for a
+- * while. This code is similar to the check in iegbe_clean_rx_irq()
+- */
+-static void
+-iegbe_tx_hang_check(struct iegbe_adapter *adapter,
+- struct iegbe_tx_ring *tx_ring)
+-{
+- struct net_device *netdev = adapter->netdev;
+- unsigned int i;
++ if(unlikely(icr & (E1000_ICR_RX_DESC_FIFO_PAR
++ | E1000_ICR_TX_DESC_FIFO_PAR
++ | E1000_ICR_PB
++ | E1000_ICR_CPP_TARGET
++ | E1000_ICR_CPP_MASTER ))) {
+
+- /* Check for a hang condition using the buffer currently at the Tx
+- head pointer */
+- i = readl(adapter->hw.hw_addr + tx_ring->tdh);
+-
+- if (adapter->detect_tx_hung) {
+- /* Detect a transmit hang in hardware, this serializes the
+- * check with the clearing of time_stamp and movement of i */
+- adapter->detect_tx_hung = FALSE;
+-
+- if (tx_ring->buffer_info[i].dma &&
+- time_after(jiffies, tx_ring->buffer_info[i].time_stamp + HZ)
+- && !(E1000_READ_REG(&adapter->hw, STATUS) &
+- E1000_STATUS_TXOFF)) {
+-
+- /* detected Tx unit hang */
+- DPRINTK(DRV, ERR, "Detected Tx Unit Hang\n"
+- " TDH <%x>\n"
+- " TDT <%x>\n"
+- " next_to_use <%x>\n"
+- " next_to_clean <%x>\n"
+- "buffer_info[tdh]\n"
+- " dma <%zx>\n"
+- " time_stamp <%lx>\n"
+- " jiffies <%lx>\n",
+- readl(adapter->hw.hw_addr + tx_ring->tdh),
+- readl(adapter->hw.hw_addr + tx_ring->tdt),
+- tx_ring->next_to_use,
+- tx_ring->next_to_clean,
+- (size_t)tx_ring->buffer_info[i].dma,
+- tx_ring->buffer_info[i].time_stamp,
+- jiffies);
+- netif_stop_queue(netdev);
+- }
++ iegbe_irq_disable(adapter);
++ printk("Critical error! ICR = 0x%x\n", icr);
++ return IRQ_HANDLED;
+ }
+-}
++ if (likely(netif_rx_schedule_prep(netdev, &adapter->napi))) {
++ adapter->total_tx_bytes = 0;
++ adapter->total_tx_packets = 0;
++ adapter->total_rx_bytes = 0;
++ adapter->total_rx_packets = 0;
++ __netif_rx_schedule(netdev, &adapter->napi);
++ } else
++ iegbe_irq_enable(adapter);
+
+-#endif
++ return IRQ_HANDLED;
++}
+
+ /**
+ * iegbe_intr - Interrupt Handler
+@@ -3546,364 +3478,208 @@ iegbe_tx_hang_check(struct iegbe_adapter
+ **/
+
+ static irqreturn_t
+-iegbe_intr(int irq, void *data, struct pt_regs *regs)
++iegbe_intr(int irq, void *data)
+ {
+- struct net_device *netdev = data;
+- struct iegbe_adapter *adapter = netdev_priv(netdev);
+- struct iegbe_hw *hw = &adapter->hw;
+- uint32_t rctl, tctl;
+- uint32_t icr = E1000_READ_REG(hw, ICR);
+-#ifndef CONFIG_E1000_NAPI
+- uint32_t i;
+-#ifdef IEGBE_GBE_WORKAROUND
+- int rx_cleaned;
+-#endif
+-#endif
++ struct net_device *netdev = data;
++ struct iegbe_adapter *adapter = netdev_priv(netdev);
++ struct iegbe_hw *hw = &adapter->hw;
++ u32 icr = E1000_READ_REG(&adapter->hw, ICR);
+
+- if(unlikely(!icr)) {
++ if (unlikely(!icr))
+ return IRQ_NONE; /* Not our interrupt */
+- }
++
++ /* IMS will not auto-mask if INT_ASSERTED is not set, and if it is
++ * not set, then the adapter didn't send an interrupt */
++ if (unlikely(hw->mac_type >= iegbe_82571 &&
++ !(icr & E1000_ICR_INT_ASSERTED)))
++ return IRQ_NONE;
++
++
+ if(unlikely(icr & (E1000_ICR_RX_DESC_FIFO_PAR
+- | E1000_ICR_TX_DESC_FIFO_PAR
+- | E1000_ICR_PB
+- | E1000_ICR_CPP_TARGET
+- | E1000_ICR_CPP_MASTER ))) {
++ | E1000_ICR_TX_DESC_FIFO_PAR
++ | E1000_ICR_PB
++ | E1000_ICR_CPP_TARGET
++ | E1000_ICR_CPP_MASTER ))) {
+
+ iegbe_irq_disable(adapter);
+- tctl = E1000_READ_REG(&adapter->hw, TCTL);
+- rctl = E1000_READ_REG(&adapter->hw, RCTL);
+- E1000_WRITE_REG(&adapter->hw, RCTL, rctl & ~E1000_TCTL_EN);
+- E1000_WRITE_REG(&adapter->hw, RCTL, rctl & ~E1000_RCTL_EN);
+-
+- tasklet_data = (unsigned long) (icr + adapter->bd_number);
+- tasklet_schedule(&iegbe_reset_tasklet);
+-
+- return IRQ_HANDLED;
+- }
+-
+-#ifdef CONFIG_E1000_NAPI
+- atomic_inc(&adapter->irq_sem);
+-#ifdef IEGBE_GBE_WORKAROUND
+- /* Ensure that the TXQE interrupt is enabled in NAPI mode */
+- E1000_WRITE_REG(hw, IMC, ~E1000_IMS_TXQE);
+-#else
+- E1000_WRITE_REG(hw, IMC, ~0);
+-#endif
+- E1000_WRITE_FLUSH(hw);
+-#ifdef CONFIG_E1000_MQ
+- if (atomic_read(&adapter->rx_sched_call_data.count) == 0) {
+- cpu_set(adapter->cpu_for_queue[0],
+- adapter->rx_sched_call_data.cpumask);
+- for (i = 1; i < adapter->num_queues; i++) {
+- cpu_set(adapter->cpu_for_queue[i],
+- adapter->rx_sched_call_data.cpumask);
+- atomic_inc(&adapter->irq_sem);
+- }
+- atomic_set(&adapter->rx_sched_call_data.count, i);
+- smp_call_async_mask(&adapter->rx_sched_call_data);
+- } else {
+- DEBUGOUT("call_data.count == %u\n",
+- atomic_read(&adapter->rx_sched_call_data.count));
++ printk("Critical error! ICR = 0x%x\n", icr);
++ return IRQ_HANDLED;
+ }
+-#else
+- if (likely(netif_rx_schedule_prep(&adapter->polling_netdev[0]))) {
+- __netif_rx_schedule(&adapter->polling_netdev[0]);
+- } else {
+- iegbe_irq_enable(adapter);
+- }
+-#endif
+-
+-#ifdef IEGBE_GBE_WORKAROUND
+- /* Clean the Tx ring */
+- for (i = 0; i < E1000_MAX_INTR; i++) {
+- adapter->stats.rx_next_to_clean = adapter->rx_ring->next_to_clean;
+- adapter->stats.rx_next_to_use = adapter->rx_ring->next_to_use;
+-
+- adapter->stats.tx_next_to_clean = adapter->tx_ring->next_to_clean;
+- adapter->stats.tx_next_to_use = adapter->tx_ring->next_to_use;
+-
+- /* Only clean Tx descriptors for a TXQE interrupt */
+- if(icr & E1000_ICR_TXQE) {
+- adapter->stats.txqec++;
+- iegbe_clean_tx_ring_partial(adapter, adapter->tx_ring);
+- }
+- else {
+- iegbe_tx_hang_check(adapter, adapter->tx_ring);
+- }
+- }
+
+-#endif /*IEGBE_GBE_WORKAROUND */
+-
+-#else
+- /* Writing IMC and IMS is needed for 82547.
+- * Due to Hub Link bus being occupied, an interrupt
+- * de-assertion message is not able to be sent.
+- * When an interrupt assertion message is generated later,
+- * two messages are re-ordered and sent out.
+- * That causes APIC to think 82547 is in de-assertion
+- * state, while 82547 is in assertion state, resulting
+- * in dead lock. Writing IMC forces 82547 into
+- * de-assertion state.
+- */
+- if (hw->mac_type == iegbe_82547 || hw->mac_type == iegbe_82547_rev_2) {
+- atomic_inc(&adapter->irq_sem);
+- E1000_WRITE_REG(hw, IMC, ~0);
+- }
+-
+-#ifdef IEGBE_GBE_WORKAROUND
+-
+- for (i = 0; i < E1000_MAX_INTR; i++) {
+- rx_cleaned = adapter->clean_rx(adapter, adapter->rx_ring);
+- adapter->stats.rx_next_to_clean = adapter->rx_ring->next_to_clean;
+- adapter->stats.rx_next_to_use = adapter->rx_ring->next_to_use;
+-
+- adapter->stats.tx_next_to_clean = adapter->tx_ring->next_to_clean;
+- adapter->stats.tx_next_to_use = adapter->tx_ring->next_to_use;
+-
+- /* Only clean Tx descriptors for a TXQE interrupt */
+- if(icr & E1000_ICR_TXQE) {
+- adapter->stats.txqec++;
+- iegbe_clean_tx_ring_partial(adapter, adapter->tx_ring);
+- }
+- else {
+- iegbe_tx_hang_check(adapter, adapter->tx_ring);
+- }
+- if(!rx_cleaned) {
+- break;
+- }
++ /* Interrupt Auto-Mask...upon reading ICR, interrupts are masked. No
++ * need for the IMC write */
++ if (unlikely(icr & (E1000_ICR_RXSEQ | E1000_ICR_LSC))) {
++ hw->get_link_status = 1;
++ /* guard against interrupt when we're going down */
++ if (!test_bit(__E1000_DOWN, &adapter->flags))
++ mod_timer(&adapter->watchdog_timer, jiffies + 1);
++
+ }
+
+-#else
+- for (i = 0; i < E1000_MAX_INTR; i++)
+- if(unlikely(!adapter->clean_rx(adapter, adapter->rx_ring) &
+- !iegbe_clean_tx_irq(adapter, adapter->tx_ring))) {
+- break;
+- }
+-#endif
+-
+- if (hw->mac_type == iegbe_82547 || hw->mac_type == iegbe_82547_rev_2) {
+- iegbe_irq_enable(adapter);
+- }
+-#endif
+-#ifdef E1000_COUNT_ICR
+- adapter->icr_txdw += icr & 0x01UL;
+- icr >>= 0x1;
+- adapter->icr_txqe += icr & 0x01UL;
+- icr >>= 0x1;
+- adapter->icr_lsc += icr & 0x01UL;
+- icr >>= 0x1;
+- adapter->icr_rxseq += icr & 0x01UL;
+- icr >>= 0x1;
+- adapter->icr_rxdmt += icr & 0x01UL;
+- icr >>= 0x1;
+- adapter->icr_rxo += icr & 0x01UL;
+- icr >>= 0x1;
+- adapter->icr_rxt += icr & 0x01UL;
+- if(hw->mac_type != iegbe_icp_xxxx) {
+- icr >>= 0x2;
+- adapter->icr_mdac += icr & 0x01UL;
+- icr >>= 0x1;
+- adapter->icr_rxcfg += icr & 0x01UL;
+- icr >>= 0x1;
+- adapter->icr_gpi += icr & 0x01UL;
+- } else {
+- icr >>= 0x4;
+- }
+- if(hw->mac_type == iegbe_icp_xxxx) {
+- icr >>= 0xc;
+- adapter->icr_pb += icr & 0x01UL;
+- icr >>= 0x3;
+- adapter->icr_intmem_icp_xxxx += icr & 0x01UL;
+- icr >>= 0x1;
+- adapter->icr_cpp_target += icr & 0x01UL;
+- icr >>= 0x1;
+- adapter->icr_cpp_master += icr & 0x01UL;
+- icr >>= 0x1;
+- adapter->icr_stat += icr & 0x01UL;
++ if (unlikely(hw->mac_type < iegbe_82571)) {
++ E1000_WRITE_REG(&adapter->hw, IMC, ~0);
++ E1000_WRITE_FLUSH(&adapter->hw);
+ }
+-#endif
++ if (likely(netif_rx_schedule_prep(netdev, &adapter->napi))) {
++ adapter->total_tx_bytes = 0;
++ adapter->total_tx_packets = 0;
++ adapter->total_rx_bytes = 0;
++ adapter->total_rx_packets = 0;
++ __netif_rx_schedule(netdev, &adapter->napi);
++ } else
++ /* this really should not happen! if it does it is basically a
++ * bug, but not a hard error, so enable ints and continue */
++ iegbe_irq_enable(adapter);
+
+ return IRQ_HANDLED;
+ }
+
+-#ifdef CONFIG_E1000_NAPI
+ /**
+ * iegbe_clean - NAPI Rx polling callback
+ * @adapter: board private structure
+ **/
+-
+-static int
+-iegbe_clean(struct net_device *poll_dev, int *budget)
++static int iegbe_clean(struct napi_struct *napi, int budget)
+ {
+- struct iegbe_adapter *adapter;
+- int work_to_do = min(*budget, poll_dev->quota);
+- int tx_cleaned, i = 0, work_done = 0;
++ struct iegbe_adapter *adapter = container_of(napi, struct iegbe_adapter, napi);
++ struct net_device *poll_dev = adapter->netdev;
++ int tx_cleaned = 0, work_done = 0;
+
+ /* Must NOT use netdev_priv macro here. */
+ adapter = poll_dev->priv;
+
+- /* Keep link state information with original netdev */
+- if (!netif_carrier_ok(adapter->netdev)) {
+- goto quit_polling;
+- }
+- while (poll_dev != &adapter->polling_netdev[i]) {
+- i++;
+- if (unlikely(i == adapter->num_queues)) {
+- BUG();
+- }
+- }
+-
+-#ifdef IEGBE_GBE_WORKAROUND
+- /* Tx descriptors are cleaned in iegbe_intr(). No need to clean
+- them here */
+- tx_cleaned = FALSE;
+-#else
+- tx_cleaned = iegbe_clean_tx_irq(adapter, &adapter->tx_ring[i]);
+-#endif
+- adapter->clean_rx(adapter, &adapter->rx_ring[i],
+- &work_done, work_to_do);
+-
+- *budget -= work_done;
+- poll_dev->quota -= work_done;
+-
+- /* If no Tx and not enough Rx work done, exit the polling mode */
+- if((!tx_cleaned && (work_done == 0)) ||
+- !netif_running(adapter->netdev)) {
+-quit_polling:
+- netif_rx_complete(poll_dev);
++ /* iegbe_clean is called per-cpu. This lock protects
++ * tx_ring[0] from being cleaned by multiple cpus
++ * simultaneously. A failure obtaining the lock means
++ * tx_ring[0] is currently being cleaned anyway. */
++ if (spin_trylock(&adapter->tx_queue_lock)) {
++ tx_cleaned = iegbe_clean_tx_irq(adapter,
++ &adapter->tx_ring[0]);
++ spin_unlock(&adapter->tx_queue_lock);
++ }
++
++ adapter->clean_rx(adapter, &adapter->rx_ring[0],
++ &work_done, budget);
++
++ if (tx_cleaned)
++ work_done = budget;
++
++ /* If budget not fully consumed, exit the polling mode */
++ if (work_done < budget) {
++ if (likely(adapter->itr_setting & 3))
++ iegbe_set_itr(adapter);
++ netif_rx_complete(poll_dev, napi);
+ iegbe_irq_enable(adapter);
+- return 0;
+ }
+
+- return 1;
++ return work_done;
+ }
+
+-#endif
+-
+-
+-#ifndef IEGBE_GBE_WORKAROUND
+ /**
+ * iegbe_clean_tx_irq - Reclaim resources after transmit completes
+ * @adapter: board private structure
+ **/
+-
+-static boolean_t
+-iegbe_clean_tx_irq(struct iegbe_adapter *adapter,
++static bool iegbe_clean_tx_irq(struct iegbe_adapter *adapter,
+ struct iegbe_tx_ring *tx_ring)
+ {
+- struct net_device *netdev = adapter->netdev;
+- struct iegbe_tx_desc *tx_desc, *eop_desc;
+- struct iegbe_buffer *buffer_info;
+- unsigned int i, eop;
+- boolean_t cleaned = FALSE;
++ struct iegbe_hw *hw = &adapter->hw;
++ struct net_device *netdev = adapter->netdev;
++ struct iegbe_tx_desc *tx_desc, *eop_desc;
++ struct iegbe_buffer *buffer_info;
++ unsigned int i, eop;
++ unsigned int count = 0;
++ bool cleaned = false;
++ unsigned int total_tx_bytes=0, total_tx_packets=0;
+
+- i = tx_ring->next_to_clean;
+- eop = tx_ring->buffer_info[i].next_to_watch;
+- eop_desc = E1000_TX_DESC(*tx_ring, eop);
++ i = tx_ring->next_to_clean;
++ eop = tx_ring->buffer_info[i].next_to_watch;
++ eop_desc = E1000_TX_DESC(*tx_ring, eop);
+
+ while (eop_desc->upper.data & cpu_to_le32(E1000_TXD_STAT_DD)) {
+- /* Premature writeback of Tx descriptors clear (free buffers
+- * and unmap pci_mapping) previous_buffer_info */
+- if (likely(tx_ring->previous_buffer_info.skb != NULL)) {
+- iegbe_unmap_and_free_tx_resource(adapter,
+- &tx_ring->previous_buffer_info);
+- }
+-
+- for (cleaned = FALSE; !cleaned; ) {
+- tx_desc = E1000_TX_DESC(*tx_ring, i);
+- buffer_info = &tx_ring->buffer_info[i];
+- cleaned = (i == eop);
+-
+-#ifdef NETIF_F_TSO
+- if (!(netdev->features & NETIF_F_TSO)) {
+-#endif
+- iegbe_unmap_and_free_tx_resource(adapter,
+- buffer_info);
+-#ifdef NETIF_F_TSO
+- } else {
+- if (cleaned) {
+- memcpy(&tx_ring->previous_buffer_info,
+- buffer_info,
+- sizeof(struct iegbe_buffer));
+- memset(buffer_info, 0,
+- sizeof(struct iegbe_buffer));
+- } else {
+- iegbe_unmap_and_free_tx_resource(
+- adapter, buffer_info);
+- }
+- }
+-#endif
+-
+- tx_desc->buffer_addr = 0;
+- tx_desc->lower.data = 0;
++ for (cleaned = false; !cleaned; ) {
++ tx_desc = E1000_TX_DESC(*tx_ring, i);
++ buffer_info = &tx_ring->buffer_info[i];
++ cleaned = (i == eop);
++
++ if (cleaned) {
++ struct sk_buff *skb = buffer_info->skb;
++ unsigned int segs = 0, bytecount;
++ segs = skb_shinfo(skb)->gso_segs ?: 1;
++ bytecount = ((segs - 1) * skb_headlen(skb)) +
++ skb->len;
++ total_tx_packets += segs;
++ total_tx_bytes += bytecount;
++ }
++ iegbe_unmap_and_free_tx_resource(adapter, buffer_info);
+ tx_desc->upper.data = 0;
+
+- if (unlikely(++i == tx_ring->count)) { i = 0; }
+- }
+-
+- tx_ring->pkt++;
++ if (unlikely(++i == tx_ring->count)) i = 0;
++ }
+
+- eop = tx_ring->buffer_info[i].next_to_watch;
+- eop_desc = E1000_TX_DESC(*tx_ring, eop);
+- }
++ eop = tx_ring->buffer_info[i].next_to_watch;
++ eop_desc = E1000_TX_DESC(*tx_ring, eop);
++#define E1000_TX_WEIGHT 64
++ /* weight of a sort for tx, to avoid endless transmit cleanup */
++ if (count++ == E1000_TX_WEIGHT)
++ break;
++ }
+
+ tx_ring->next_to_clean = i;
+
+- spin_lock(&tx_ring->tx_lock);
++#define TX_WAKE_THRESHOLD 32
+
+- if (unlikely(cleaned && netif_queue_stopped(netdev) &&
+- netif_carrier_ok(netdev))) {
+- netif_wake_queue(netdev);
+- }
+- spin_unlock(&tx_ring->tx_lock);
+-
+- if (adapter->detect_tx_hung) {
+- /* Detect a transmit hang in hardware, this serializes the
+- * check with the clearing of time_stamp and movement of i */
+- adapter->detect_tx_hung = FALSE;
+-
+- if (tx_ring->buffer_info[i].dma &&
+- time_after(jiffies, tx_ring->buffer_info[i].time_stamp + HZ)
+- && !(E1000_READ_REG(&adapter->hw, STATUS) &
+- E1000_STATUS_TXOFF)) {
+-
+- /* detected Tx unit hang */
+- i = tx_ring->next_to_clean;
+- eop = tx_ring->buffer_info[i].next_to_watch;
+- eop_desc = E1000_TX_DESC(*tx_ring, eop);
+- DPRINTK(DRV, ERR, "Detected Tx Unit Hang\n"
+- " TDH <%x>\n"
+- " TDT <%x>\n"
+- " next_to_use <%x>\n"
+- " next_to_clean <%x>\n"
+- "buffer_info[next_to_clean]\n"
+- " dma <%zx>\n"
+- " time_stamp <%lx>\n"
+- " next_to_watch <%x>\n"
+- " jiffies <%lx>\n"
+- " next_to_watch.status <%x>\n",
+- readl(adapter->hw.hw_addr + tx_ring->tdh),
+- readl(adapter->hw.hw_addr + tx_ring->tdt),
+- tx_ring->next_to_use,
+- i,
+- (size_t)tx_ring->buffer_info[i].dma,
+- tx_ring->buffer_info[i].time_stamp,
+- eop,
+- jiffies,
+- eop_desc->upper.fields.status);
+- netif_stop_queue(netdev);
++ if (unlikely(cleaned && netif_carrier_ok(netdev) &&
++ E1000_DESC_UNUSED(tx_ring) >= TX_WAKE_THRESHOLD)) {
++ /* Make sure that anybody stopping the queue after this
++ * sees the new next_to_clean.
++ */
++ smp_mb();
++ if (netif_queue_stopped(netdev)) {
++ netif_wake_queue(netdev);
++ ++adapter->restart_queue;
+ }
+ }
+-#ifdef NETIF_F_TSO
+- if (unlikely(!(eop_desc->upper.data & cpu_to_le32(E1000_TXD_STAT_DD)) &&
+- time_after(jiffies, tx_ring->previous_buffer_info.time_stamp + HZ))) {
+- iegbe_unmap_and_free_tx_resource(
+- adapter, &tx_ring->previous_buffer_info);
++
++ if (adapter->detect_tx_hung) {
++ /* Detect a transmit hang in hardware, this serializes the
++ * check with the clearing of time_stamp and movement of i */
++ adapter->detect_tx_hung = false;
++
++ if (tx_ring->buffer_info[eop].dma &&
++ time_after(jiffies, tx_ring->buffer_info[eop].time_stamp +
++ (adapter->tx_timeout_factor * HZ))
++ && !(E1000_READ_REG(hw, STATUS) & E1000_STATUS_TXOFF)) {
++
++ /* detected Tx unit hang */
++ DPRINTK(DRV, ERR, "Detected Tx Unit Hang\n"
++ " Tx Queue <%lu>\n"
++ " TDH <%x>\n"
++ " TDT <%x>\n"
++ " next_to_use <%x>\n"
++ " next_to_clean <%x>\n"
++ "buffer_info[next_to_clean]\n"
++ " time_stamp <%lx>\n"
++ " next_to_watch <%x>\n"
++ " jiffies <%lx>\n"
++ " next_to_watch.status <%x>\n",
++ (unsigned long)((tx_ring - adapter->tx_ring) /
++ sizeof(struct iegbe_tx_ring)),
++ readl(hw->hw_addr + tx_ring->tdh),
++ readl(hw->hw_addr + tx_ring->tdt),
++ tx_ring->next_to_use,
++ tx_ring->next_to_clean,
++ tx_ring->buffer_info[eop].time_stamp,
++ eop,
++ jiffies,
++ eop_desc->upper.fields.status);
++ netif_stop_queue(netdev);
++ }
+ }
+-#endif
+- return cleaned;
++ adapter->total_tx_bytes += total_tx_bytes;
++ adapter->total_tx_packets += total_tx_packets;
++ adapter->net_stats.tx_bytes += total_tx_bytes;
++ adapter->net_stats.tx_packets += total_tx_packets;
++ return cleaned;
+ }
+-#endif
+
+ /**
+ * iegbe_rx_checksum - Receive Checksum Offload for 82543
+@@ -3913,192 +3689,193 @@ iegbe_clean_tx_irq(struct iegbe_adapter
+ * @sk_buff: socket buffer with received data
+ **/
+
+-static inline void
+-iegbe_rx_checksum(struct iegbe_adapter *adapter,
+- uint32_t status_err, uint32_t csum,
+- struct sk_buff *skb)
++static void iegbe_rx_checksum(struct iegbe_adapter *adapter, u32 status_err,
++ u32 csum, struct sk_buff *skb)
+ {
+- uint16_t status = (uint16_t)status_err;
+- uint8_t errors = (uint8_t)(status_err >> 0x18);
++ struct iegbe_hw *hw = &adapter->hw;
++ u16 status = (u16)status_err;
++ u8 errors = (u8)(status_err >> 24);
+ skb->ip_summed = CHECKSUM_NONE;
+
+- /* 82543 or newer only */
+- if(unlikely(adapter->hw.mac_type < iegbe_82543)) { return; }
+- /* Ignore Checksum bit is set */
+- if(unlikely(status & E1000_RXD_STAT_IXSM)) { return; }
+- /* TCP/UDP checksum error bit is set */
+- if(unlikely(errors & E1000_RXD_ERR_TCPE)) {
+- /* let the stack verify checksum errors */
+- adapter->hw_csum_err++;
+- return;
+- }
+- /* TCP/UDP Checksum has not been calculated */
+- if(adapter->hw.mac_type <= iegbe_82547_rev_2) {
+- if(!(status & E1000_RXD_STAT_TCPCS)) {
+- return;
++ /* 82543 or newer only */
++ if (unlikely(hw->mac_type < iegbe_82543)) return;
++ /* Ignore Checksum bit is set */
++ if (unlikely(status & E1000_RXD_STAT_IXSM)) return;
++ /* TCP/UDP checksum error bit is set */
++ if(unlikely(errors & E1000_RXD_ERR_TCPE)) {
++ /* let the stack verify checksum errors */
++ adapter->hw_csum_err++;
++ return;
++ }
++ /* TCP/UDP Checksum has not been calculated */
++ if (hw->mac_type <= iegbe_82547_rev_2) {
++ if (!(status & E1000_RXD_STAT_TCPCS))
++ return;
++ } else {
++ if (!(status & (E1000_RXD_STAT_TCPCS | E1000_RXD_STAT_UDPCS)))
++ return;
+ }
+- } else {
+- if(!(status & (E1000_RXD_STAT_TCPCS | E1000_RXD_STAT_UDPCS))) {
+- return;
+- }
++ /* It must be a TCP or UDP packet with a valid checksum */
++ if(likely(status & E1000_RXD_STAT_TCPCS)) {
++ /* TCP checksum is good */
++ skb->ip_summed = CHECKSUM_UNNECESSARY;
++ } else if (hw->mac_type > iegbe_82547_rev_2) {
++ /* IP fragment with UDP payload */
++ /* Hardware complements the payload checksum, so we undo it
++ * and then put the value in host order for further stack use.
++ */
++ __sum16 sum = (__force __sum16)htons(csum);
++ skb->csum = csum_unfold(~sum);
++ skb->ip_summed = CHECKSUM_COMPLETE;
+ }
+- /* It must be a TCP or UDP packet with a valid checksum */
+- if(likely(status & E1000_RXD_STAT_TCPCS)) {
+- /* TCP checksum is good */
+- skb->ip_summed = CHECKSUM_UNNECESSARY;
+- } else if(adapter->hw.mac_type > iegbe_82547_rev_2) {
+- /* IP fragment with UDP payload */
+- /* Hardware complements the payload checksum, so we undo it
+- * and then put the value in host order for further stack use.
+- */
+- csum = ntohl(csum ^ 0xFFFF);
+- skb->csum = csum;
+- skb->ip_summed = CHECKSUM_HW;
+- }
+- adapter->hw_csum_good++;
++ adapter->hw_csum_good++;
+ }
+
+ /**
+ * iegbe_clean_rx_irq - Send received data up the network stack; legacy
+ * @adapter: board private structure
+ **/
+-
+-static boolean_t
+-#ifdef CONFIG_E1000_NAPI
+-iegbe_clean_rx_irq(struct iegbe_adapter *adapter,
++static bool iegbe_clean_rx_irq(struct iegbe_adapter *adapter,
+ struct iegbe_rx_ring *rx_ring,
+ int *work_done, int work_to_do)
+-#else
+-iegbe_clean_rx_irq(struct iegbe_adapter *adapter,
+- struct iegbe_rx_ring *rx_ring)
+-#endif
+ {
+- struct net_device *netdev = adapter->netdev;
+- struct pci_dev *pdev = adapter->pdev;
+- struct iegbe_rx_desc *rx_desc;
+- struct iegbe_buffer *buffer_info;
+- struct sk_buff *skb;
+- unsigned long flags = 0;
+- uint32_t length;
+- uint8_t last_byte;
+- unsigned int i;
+- boolean_t cleaned = FALSE;
+-
+-#ifdef IEGBE_GBE_WORKAROUND
+- /* Need to keep track of the amount of Rx descriptors that we
+- cleaned to ensure that we don't supply too many back to the
+- hardware */
+- int cleaned_count = 0;
+-#endif
+-
+- i = rx_ring->next_to_clean;
+- rx_desc = E1000_RX_DESC(*rx_ring, i);
+-
+- while(rx_desc->status & E1000_RXD_STAT_DD) {
+- buffer_info = &rx_ring->buffer_info[i];
+-#ifdef CONFIG_E1000_NAPI
+- if(*work_done >= work_to_do) {
+- break;
+- }
+- (*work_done)++;
+-#endif
+- cleaned = TRUE;
++ struct iegbe_hw *hw = &adapter->hw;
++ struct net_device *netdev = adapter->netdev;
++ struct pci_dev *pdev = adapter->pdev;
++ struct iegbe_rx_desc *rx_desc, *next_rxd;
++ struct iegbe_buffer *buffer_info, *next_buffer;
++ unsigned long flags;
++ u32 length;
++ u8 last_byte;
++ unsigned int i;
++ int cleaned_count = 0;
++ bool cleaned = false;
++ unsigned int total_rx_bytes=0, total_rx_packets=0;
+
+-#ifdef IEGBE_GBE_WORKAROUND
+- cleaned_count++;
+-#endif
++ i = rx_ring->next_to_clean;
++ rx_desc = E1000_RX_DESC(*rx_ring, i);
++ buffer_info = &rx_ring->buffer_info[i];
+
+- pci_unmap_single(pdev,
+- buffer_info->dma,
+- buffer_info->length,
+- PCI_DMA_FROMDEVICE);
++ while(rx_desc->status & E1000_RXD_STAT_DD) {
++ struct sk_buff *skb;
++ u8 status;
++ if (*work_done >= work_to_do)
++ break;
++ (*work_done)++;
+
++ status = rx_desc->status;
+ skb = buffer_info->skb;
+- length = le16_to_cpu(rx_desc->length);
++ buffer_info->skb = NULL;
++ prefetch(skb->data - NET_IP_ALIGN);
++ if (++i == rx_ring->count) i = 0;
++ next_rxd = E1000_RX_DESC(*rx_ring, i);
++ prefetch(next_rxd);
++ next_buffer = &rx_ring->buffer_info[i];
++ cleaned = true;
++ cleaned_count++;
++ pci_unmap_single(pdev,
++ buffer_info->dma,
++ buffer_info->length,
++ PCI_DMA_FROMDEVICE);
++
++ length = le16_to_cpu(rx_desc->length);
++
++ if (unlikely(!(status & E1000_RXD_STAT_EOP))) {
++ /* All receives must fit into a single buffer */
++ E1000_DBG("%s: Receive packet consumed multiple"
++ " buffers\n", netdev->name);
++ buffer_info->skb = skb;
++ goto next_desc;
++ }
+
+- if(unlikely(!(rx_desc->status & E1000_RXD_STAT_EOP))) {
+- /* All receives must fit into a single buffer */
+- E1000_DBG("%s: Receive packet consumed multiple"
+- " buffers\n", netdev->name);
+- dev_kfree_skb_irq(skb);
+- goto next_desc;
+- }
++ if(unlikely(rx_desc->errors & E1000_RXD_ERR_FRAME_ERR_MASK)) {
++ last_byte = *(skb->data + length - 1);
++ if (TBI_ACCEPT(hw, status, rx_desc->errors, length,
++ last_byte)) {
++ spin_lock_irqsave(&adapter->stats_lock, flags);
++ iegbe_tbi_adjust_stats(hw, &adapter->stats,
++ length, skb->data);
++ spin_unlock_irqrestore(&adapter->stats_lock,
++ flags);
++ length--;
++ } else {
++ buffer_info->skb = skb;
++ goto next_desc;
++ }
++ }
+
+- if(unlikely(rx_desc->errors & E1000_RXD_ERR_FRAME_ERR_MASK)) {
+- last_byte = *(skb->data + length - 0x1);
+- if(TBI_ACCEPT(&adapter->hw, rx_desc->status,
+- rx_desc->errors, length, last_byte)) {
+- spin_lock_irqsave(&adapter->stats_lock, flags);
+- iegbe_tbi_adjust_stats(&adapter->hw,
+- &adapter->stats,
+- length, skb->data);
+- spin_unlock_irqrestore(&adapter->stats_lock,
+- flags);
+- length--;
+- } else {
+- dev_kfree_skb_irq(skb);
+- goto next_desc;
++ /* adjust length to remove Ethernet CRC, this must be
++ * done after the TBI_ACCEPT workaround above */
++ length -= 4;
++
++ /* probably a little skewed due to removing CRC */
++ total_rx_bytes += length;
++ total_rx_packets++;
++
++ /* code added for copybreak, this should improve
++ * performance for small packets with large amounts
++ * of reassembly being done in the stack */
++ if (length < copybreak) {
++ struct sk_buff *new_skb =
++ netdev_alloc_skb(netdev, length + NET_IP_ALIGN);
++ if (new_skb) {
++ skb_reserve(new_skb, NET_IP_ALIGN);
++ skb_copy_to_linear_data_offset(new_skb,
++ -NET_IP_ALIGN,
++ (skb->data -
++ NET_IP_ALIGN),
++ (length +
++ NET_IP_ALIGN));
++ /* save the skb in buffer_info as good */
++ buffer_info->skb = skb;
++ skb = new_skb;
+ }
++ /* else just continue with the old one */
+ }
+-
+- /* Good Receive */
+- skb_put(skb, length - ETHERNET_FCS_SIZE);
++ /* Good Receive */
++ skb_put(skb, length);
+
+ /* Receive Checksum Offload */
+ iegbe_rx_checksum(adapter,
+- (uint32_t)(rx_desc->status) |
+- ((uint32_t)(rx_desc->errors) << 0x18),
+- rx_desc->csum, skb);
++ (u32)(status) |
++ ((u32)(rx_desc->errors) << 24),
++ le16_to_cpu(rx_desc->csum), skb);
++
+ skb->protocol = eth_type_trans(skb, netdev);
+-#ifdef CONFIG_E1000_NAPI
+-#ifdef NETIF_F_HW_VLAN_TX
+- if(unlikely(adapter->vlgrp &&
+- (rx_desc->status & E1000_RXD_STAT_VP))) {
++
++ if (unlikely(adapter->vlgrp &&
++ (status & E1000_RXD_STAT_VP))) {
+ vlan_hwaccel_receive_skb(skb, adapter->vlgrp,
+- le16_to_cpu(rx_desc->special) &
+- E1000_RXD_SPC_VLAN_MASK);
++ le16_to_cpu(rx_desc->special));
+ } else {
+ netif_receive_skb(skb);
+ }
+-#else
+- netif_receive_skb(skb);
+-#endif
+-#else /* CONFIG_E1000_NAPI */
+-#ifdef NETIF_F_HW_VLAN_TX
+- if(unlikely(adapter->vlgrp &&
+- (rx_desc->status & E1000_RXD_STAT_VP))) {
+- vlan_hwaccel_rx(skb, adapter->vlgrp,
+- le16_to_cpu(rx_desc->special) &
+- E1000_RXD_SPC_VLAN_MASK);
+- } else {
+- netif_rx(skb);
+- }
+-#else
+- netif_rx(skb);
+-#endif
+-#endif /* CONFIG_E1000_NAPI */
++
+ netdev->last_rx = jiffies;
+- rx_ring->pkt++;
+
+ next_desc:
+ rx_desc->status = 0;
+- buffer_info->skb = NULL;
+- if(unlikely(++i == rx_ring->count)) { i = 0; }
+
+- rx_desc = E1000_RX_DESC(*rx_ring, i);
++ /* return some buffers to hardware, one at a time is too slow */
++ if (unlikely(cleaned_count >= E1000_RX_BUFFER_WRITE)) {
++ adapter->alloc_rx_buf(adapter, rx_ring, cleaned_count);
++ cleaned_count = 0;
++ }
++
++ /* use prefetched values */
++ rx_desc = next_rxd;
++ buffer_info = next_buffer;
+ }
+ rx_ring->next_to_clean = i;
+
+-#ifdef IEGBE_GBE_WORKAROUND
+- /* Only allocate the number of buffers that we have actually
+- cleaned! */
+- if (cleaned_count) {
+- adapter->alloc_rx_buf(adapter, rx_ring, cleaned_count);
+- }
+-#else
+- adapter->alloc_rx_buf(adapter, rx_ring);
+-#endif
+-
++ cleaned_count = E1000_DESC_UNUSED(rx_ring);
++ if (cleaned_count)
++ adapter->alloc_rx_buf(adapter, rx_ring, cleaned_count);
++
++ adapter->total_rx_packets += total_rx_packets;
++ adapter->total_rx_bytes += total_rx_bytes;
++ adapter->net_stats.rx_bytes += total_rx_bytes;
++ adapter->net_stats.rx_packets += total_rx_packets;
+ return cleaned;
+ }
+
+@@ -4107,161 +3884,153 @@ next_desc:
+ * @adapter: board private structure
+ **/
+
+-static boolean_t
+-#ifdef CONFIG_E1000_NAPI
+-iegbe_clean_rx_irq_ps(struct iegbe_adapter *adapter,
++static bool iegbe_clean_rx_irq_ps(struct iegbe_adapter *adapter,
+ struct iegbe_rx_ring *rx_ring,
+ int *work_done, int work_to_do)
+-#else
+-iegbe_clean_rx_irq_ps(struct iegbe_adapter *adapter,
+- struct iegbe_rx_ring *rx_ring)
+-#endif
+ {
+- union iegbe_rx_desc_packet_split *rx_desc;
+- struct net_device *netdev = adapter->netdev;
+- struct pci_dev *pdev = adapter->pdev;
+- struct iegbe_buffer *buffer_info;
+- struct iegbe_ps_page *ps_page;
+- struct iegbe_ps_page_dma *ps_page_dma;
+- struct sk_buff *skb;
+- unsigned int i, j;
+- uint32_t length, staterr;
+- boolean_t cleaned = FALSE;
+-
+-#ifdef IEGBE_GBE_WORKAROUND
+- /* Need to keep track of the amount of Rx descriptors that we
+- cleaned to ensure that we don't supply too many back to the
+- hardware */
+- int cleaned_count = 0;
+-#endif
+-
+- i = rx_ring->next_to_clean;
+- rx_desc = E1000_RX_DESC_PS(*rx_ring, i);
+- staterr = le32_to_cpu(rx_desc->wb.middle.status_error);
+-
+- while(staterr & E1000_RXD_STAT_DD) {
+- buffer_info = &rx_ring->buffer_info[i];
+- ps_page = &rx_ring->ps_page[i];
+- ps_page_dma = &rx_ring->ps_page_dma[i];
+-#ifdef CONFIG_E1000_NAPI
+- if(unlikely(*work_done >= work_to_do)) {
+- break;
+- }
+- (*work_done)++;
+-#endif
+- cleaned = TRUE;
+-
+-#ifdef IEGBE_GBE_WORKAROUND
+- cleaned_count++;
+-#endif
++ union iegbe_rx_desc_packet_split *rx_desc, *next_rxd;
++ struct net_device *netdev = adapter->netdev;
++ struct pci_dev *pdev = adapter->pdev;
++ struct iegbe_buffer *buffer_info, *next_buffer;
++ struct iegbe_ps_page *ps_page;
++ struct iegbe_ps_page_dma *ps_page_dma;
++ struct sk_buff *skb;
++ unsigned int i, j;
++ u32 length, staterr;
++ int cleaned_count = 0;
++ bool cleaned = false;
++ unsigned int total_rx_bytes=0, total_rx_packets=0;
++
++ i = rx_ring->next_to_clean;
++ rx_desc = E1000_RX_DESC_PS(*rx_ring, i);
++ staterr = le32_to_cpu(rx_desc->wb.middle.status_error);
++ buffer_info = &rx_ring->buffer_info[i];
+
+- pci_unmap_single(pdev, buffer_info->dma,
+- buffer_info->length,
+- PCI_DMA_FROMDEVICE);
++ while(staterr & E1000_RXD_STAT_DD) {
++ ps_page = &rx_ring->ps_page[i];
++ ps_page_dma = &rx_ring->ps_page_dma[i];
++
++ if (unlikely(*work_done >= work_to_do))
++ break;
++ (*work_done)++;
+
+ skb = buffer_info->skb;
++ prefetch(skb->data - NET_IP_ALIGN);
++ if (++i == rx_ring->count) i = 0;
++ next_rxd = E1000_RX_DESC_PS(*rx_ring, i);
++ prefetch(next_rxd);
++ next_buffer = &rx_ring->buffer_info[i];
++ cleaned = true;
++ cleaned_count++;
++ pci_unmap_single(pdev, buffer_info->dma,
++ buffer_info->length,
++ PCI_DMA_FROMDEVICE);
++
++ if(unlikely(!(staterr & E1000_RXD_STAT_EOP))) {
++ E1000_DBG("%s: Packet Split buffers didn't pick up"
++ " the full packet\n", netdev->name);
++ dev_kfree_skb_irq(skb);
++ goto next_desc;
++ }
+
+- if(unlikely(!(staterr & E1000_RXD_STAT_EOP))) {
+- E1000_DBG("%s: Packet Split buffers didn't pick up"
+- " the full packet\n", netdev->name);
+- dev_kfree_skb_irq(skb);
+- goto next_desc;
+- }
+-
+- if(unlikely(staterr & E1000_RXDEXT_ERR_FRAME_ERR_MASK)) {
+- dev_kfree_skb_irq(skb);
+- goto next_desc;
+- }
+-
+- length = le16_to_cpu(rx_desc->wb.middle.length0);
++ if(unlikely(staterr & E1000_RXDEXT_ERR_FRAME_ERR_MASK)) {
++ dev_kfree_skb_irq(skb);
++ goto next_desc;
++ }
+
+- if(unlikely(!length)) {
+- E1000_DBG("%s: Last part of the packet spanning"
+- " multiple descriptors\n", netdev->name);
+- dev_kfree_skb_irq(skb);
+- goto next_desc;
+- }
++ length = le16_to_cpu(rx_desc->wb.middle.length0);
+
+- /* Good Receive */
+- skb_put(skb, length);
+-
+- for(j = 0; j < adapter->rx_ps_pages; j++) {
+- if(!(length = le16_to_cpu(rx_desc->wb.upper.length[j]))) {
+- break;
+- }
+- pci_unmap_page(pdev, ps_page_dma->ps_page_dma[j],
+- PAGE_SIZE, PCI_DMA_FROMDEVICE);
+- ps_page_dma->ps_page_dma[j] = 0;
+- skb_shinfo(skb)->frags[j].page =
+- ps_page->ps_page[j];
+- ps_page->ps_page[j] = NULL;
+- skb_shinfo(skb)->frags[j].page_offset = 0;
+- skb_shinfo(skb)->frags[j].size = length;
+- skb_shinfo(skb)->nr_frags++;
+- skb->len += length;
+- skb->data_len += length;
+- }
++ if(unlikely(!length)) {
++ E1000_DBG("%s: Last part of the packet spanning"
++ " multiple descriptors\n", netdev->name);
++ dev_kfree_skb_irq(skb);
++ goto next_desc;
++ }
+
+- iegbe_rx_checksum(adapter, staterr,
+- rx_desc->wb.lower.hi_dword.csum_ip.csum, skb);
+- skb->protocol = eth_type_trans(skb, netdev);
++ /* Good Receive */
++ skb_put(skb, length);
+
+- if(likely(rx_desc->wb.upper.header_status &
+- E1000_RXDPS_HDRSTAT_HDRSP)) {
+- adapter->rx_hdr_split++;
+-#ifdef HAVE_RX_ZERO_COPY
+- skb_shinfo(skb)->zero_copy = TRUE;
+-#endif
+- }
+-#ifdef CONFIG_E1000_NAPI
+-#ifdef NETIF_F_HW_VLAN_TX
+- if(unlikely(adapter->vlgrp && (staterr & E1000_RXD_STAT_VP))) {
+- vlan_hwaccel_receive_skb(skb, adapter->vlgrp,
+- le16_to_cpu(rx_desc->wb.middle.vlan) &
+- E1000_RXD_SPC_VLAN_MASK);
+- } else {
+- netif_receive_skb(skb);
+- }
+-#else
+- netif_receive_skb(skb);
+-#endif
+-#else /* CONFIG_E1000_NAPI */
+-#ifdef NETIF_F_HW_VLAN_TX
+- if(unlikely(adapter->vlgrp && (staterr & E1000_RXD_STAT_VP))) {
+- vlan_hwaccel_rx(skb, adapter->vlgrp,
+- le16_to_cpu(rx_desc->wb.middle.vlan) &
+- E1000_RXD_SPC_VLAN_MASK);
+- } else {
+- netif_rx(skb);
+- }
+-#else
+- netif_rx(skb);
+-#endif
+-#endif /* CONFIG_E1000_NAPI */
+- netdev->last_rx = jiffies;
+- rx_ring->pkt++;
++ {
++ int l1 = le16_to_cpu(rx_desc->wb.upper.length[0]);
++ if (l1 && (l1 <= copybreak) && ((length + l1) <= adapter->rx_ps_bsize0)) {
++ u8 *vaddr;
++ pci_dma_sync_single_for_cpu(pdev,
++ ps_page_dma->ps_page_dma[0],
++ PAGE_SIZE,
++ PCI_DMA_FROMDEVICE);
++ vaddr = kmap_atomic(ps_page->ps_page[0],
++ KM_SKB_DATA_SOFTIRQ);
++ memcpy(skb_tail_pointer(skb), vaddr, l1);
++ kunmap_atomic(vaddr, KM_SKB_DATA_SOFTIRQ);
++ pci_dma_sync_single_for_device(pdev,
++ ps_page_dma->ps_page_dma[0],
++ PAGE_SIZE, PCI_DMA_FROMDEVICE);
++ l1 -= 4;
++ skb_put(skb, l1);
++ goto copydone;
++ } /* if */
++ }
++ for (j = 0; j < adapter->rx_ps_pages; j++) {
++ length = le16_to_cpu(rx_desc->wb.upper.length[j]);
++ if (!length)
++ break;
++ pci_unmap_page(pdev, ps_page_dma->ps_page_dma[j],
++ PAGE_SIZE, PCI_DMA_FROMDEVICE);
++ ps_page_dma->ps_page_dma[j] = 0;
++ skb_fill_page_desc(skb, j, ps_page->ps_page[j], 0,
++ length);
++ ps_page->ps_page[j] = NULL;
++ skb->len += length;
++ skb->data_len += length;
++ skb->truesize += length;
++ }
+
+-next_desc:
+- rx_desc->wb.middle.status_error &= ~0xFF;
+- buffer_info->skb = NULL;
+- if(unlikely(++i == rx_ring->count)) { i = 0; }
++ pskb_trim(skb, skb->len - 4);
++copydone:
++ total_rx_bytes += skb->len;
++ total_rx_packets++;
++ iegbe_rx_checksum(adapter, staterr,
++ le16_to_cpu(rx_desc->wb.lower.hi_dword.csum_ip.csum), skb);
++ skb->protocol = eth_type_trans(skb, netdev);
++
++ if(likely(rx_desc->wb.upper.header_status &
++ cpu_to_le16(E1000_RXDPS_HDRSTAT_HDRSP)))
++ adapter->rx_hdr_split++;
++
++ if(unlikely(adapter->vlgrp && (staterr & E1000_RXD_STAT_VP))) {
++ vlan_hwaccel_receive_skb(skb, adapter->vlgrp,
++ le16_to_cpu(rx_desc->wb.middle.vlan));
++ } else {
++ netif_receive_skb(skb);
++ }
+
+- rx_desc = E1000_RX_DESC_PS(*rx_ring, i);
+- staterr = le32_to_cpu(rx_desc->wb.middle.status_error);
+- }
+- rx_ring->next_to_clean = i;
++ netdev->last_rx = jiffies;
+
+-#ifdef IEGBE_GBE_WORKAROUND
+- /* Only allocate the number of buffers that we have actually
+- cleaned! */
+- if (cleaned_count) {
+- adapter->alloc_rx_buf(adapter, rx_ring, cleaned_count);
+- }
+-#else
+- adapter->alloc_rx_buf(adapter, rx_ring);
+-#endif
++next_desc:
++ rx_desc->wb.middle.status_error &= cpu_to_le32(~0xFF);
++ buffer_info->skb = NULL;
+
+- return cleaned;
++ if (unlikely(cleaned_count >= E1000_RX_BUFFER_WRITE)) {
++ adapter->alloc_rx_buf(adapter, rx_ring, cleaned_count);
++ cleaned_count = 0;
++ }
++
++ /* use prefetched values */
++ rx_desc = next_rxd;
++ buffer_info = next_buffer;
++ staterr = le32_to_cpu(rx_desc->wb.middle.status_error);
++ }
++ rx_ring->next_to_clean = i;
++
++ cleaned_count = E1000_DESC_UNUSED(rx_ring);
++ if (cleaned_count)
++ adapter->alloc_rx_buf(adapter, rx_ring, cleaned_count);
++
++ adapter->total_rx_packets += total_rx_packets;
++ adapter->total_rx_bytes += total_rx_bytes;
++ adapter->net_stats.rx_bytes += total_rx_bytes;
++ adapter->net_stats.rx_packets += total_rx_packets;
++ return cleaned;
+ }
+
+ /**
+@@ -4269,142 +4038,115 @@ next_desc:
+ * @adapter: address of board private structure
+ **/
+
+-#ifdef IEGBE_GBE_WORKAROUND
+-static void
+-iegbe_alloc_rx_buffers(struct iegbe_adapter *adapter,
++
++static void iegbe_alloc_rx_buffers(struct iegbe_adapter *adapter,
+ struct iegbe_rx_ring *rx_ring,
+ int cleaned_count)
+-#else
+-static void
+-iegbe_alloc_rx_buffers(struct iegbe_adapter *adapter,
+- struct iegbe_rx_ring *rx_ring)
+-#endif
+ {
+- struct net_device *netdev = adapter->netdev;
+- struct pci_dev *pdev = adapter->pdev;
+- struct iegbe_rx_desc *rx_desc;
+- struct iegbe_buffer *buffer_info;
+- struct sk_buff *skb;
+- unsigned int i;
+- unsigned int bufsz = adapter->rx_buffer_len + NET_IP_ALIGN;
+-
+- i = rx_ring->next_to_use;
+- buffer_info = &rx_ring->buffer_info[i];
++ struct iegbe_hw *hw = &adapter->hw;
++ struct net_device *netdev = adapter->netdev;
++ struct pci_dev *pdev = adapter->pdev;
++ struct iegbe_rx_desc *rx_desc;
++ struct iegbe_buffer *buffer_info;
++ struct sk_buff *skb;
++ unsigned int i;
++ unsigned int bufsz = adapter->rx_buffer_len + NET_IP_ALIGN;
+
+-#ifdef IEGBE_GBE_WORKAROUND
+- if (cleaned_count > IEGBE_GBE_WORKAROUND_NUM_RX_DESCRIPTORS) {
+- adapter->stats.cc_gt_num_rx++;
+- }
+- while(cleaned_count-- && !buffer_info->skb) {
+-#else
+- while(!buffer_info->skb) {
+-#endif
+- skb = dev_alloc_skb(bufsz);
++ i = rx_ring->next_to_use;
++ buffer_info = &rx_ring->buffer_info[i];
+
+- if(unlikely(!skb)) {
+- /* Better luck next round */
+- break;
+- }
++ while (cleaned_count--) {
++ skb = buffer_info->skb;
++ if (skb) {
++ skb_trim(skb, 0);
++ goto map_skb;
++ }
++ skb = netdev_alloc_skb(netdev, bufsz);
++
++ if(unlikely(!skb)) {
++ /* Better luck next round */
++ adapter->alloc_rx_buff_failed++;
++ break;
++ }
+
+- /* Fix for errata 23, can't cross 64kB boundary */
+- if(!iegbe_check_64k_bound(adapter, skb->data, bufsz)) {
+- struct sk_buff *oldskb = skb;
+- DPRINTK(RX_ERR, ERR, "skb align check failed: %u bytes "
+- "at %p\n", bufsz, skb->data);
+- /* Try again, without freeing the previous */
+- skb = dev_alloc_skb(bufsz);
+- /* Failed allocation, critical failure */
+- if(!skb) {
+- dev_kfree_skb(oldskb);
+- break;
+- }
++ /* Fix for errata 23, can't cross 64kB boundary */
++ if(!iegbe_check_64k_bound(adapter, skb->data, bufsz)) {
++ struct sk_buff *oldskb = skb;
++ DPRINTK(RX_ERR, ERR, "skb align check failed: %u bytes "
++ "at %p\n", bufsz, skb->data);
++ /* Try again, without freeing the previous */
++ skb = netdev_alloc_skb(netdev, bufsz);
++ /* Failed allocation, critical failure */
++ if(!skb) {
++ dev_kfree_skb(oldskb);
++ break;
++ }
+
+- if(!iegbe_check_64k_bound(adapter, skb->data, bufsz)) {
+- /* give up */
+- dev_kfree_skb(skb);
+- dev_kfree_skb(oldskb);
+- break; /* while !buffer_info->skb */
+- } else {
+- /* Use new allocation */
+- dev_kfree_skb(oldskb);
++ if(!iegbe_check_64k_bound(adapter, skb->data, bufsz)) {
++ /* give up */
++ dev_kfree_skb(skb);
++ dev_kfree_skb(oldskb);
++ break; /* while !buffer_info->skb */
+ }
+- }
+- /* Make buffer alignment 2 beyond a 16 byte boundary
+- * this will result in a 16 byte aligned IP header after
+- * the 14 byte MAC header is removed
+- */
+- skb_reserve(skb, NET_IP_ALIGN);
+-
+- skb->dev = netdev;
+-
+- buffer_info->skb = skb;
+- buffer_info->length = adapter->rx_buffer_len;
+- buffer_info->dma = pci_map_single(pdev,
+- skb->data,
+- adapter->rx_buffer_len,
+- PCI_DMA_FROMDEVICE);
+-
+- /* Fix for errata 23, can't cross 64kB boundary */
+- if(!iegbe_check_64k_bound(adapter,
+- (void *)(unsigned long)buffer_info->dma,
+- adapter->rx_buffer_len)) {
+- DPRINTK(RX_ERR, ERR,
+- "dma align check failed: %u bytes at %p\n",
+- adapter->rx_buffer_len,
+- (void *)(unsigned long)buffer_info->dma);
+- dev_kfree_skb(skb);
+- buffer_info->skb = NULL;
+-
+- pci_unmap_single(pdev, buffer_info->dma,
+- adapter->rx_buffer_len,
+- PCI_DMA_FROMDEVICE);
+-
+- break; /* while !buffer_info->skb */
+- }
+- rx_desc = E1000_RX_DESC(*rx_ring, i);
+- rx_desc->buffer_addr = cpu_to_le64(buffer_info->dma);
+-
+-#ifdef IEGBE_GBE_WORKAROUND_DISABLED
+- adapter->stats.num_rx_buf_alloc++;
++ /* Use new allocation */
++ dev_kfree_skb(oldskb);
++ }
++ /* Make buffer alignment 2 beyond a 16 byte boundary
++ * this will result in a 16 byte aligned IP header after
++ * the 14 byte MAC header is removed
++ */
++ skb_reserve(skb, NET_IP_ALIGN);
++
++
++ buffer_info->skb = skb;
++ buffer_info->length = adapter->rx_buffer_len;
++map_skb:
++ buffer_info->dma = pci_map_single(pdev,
++ skb->data,
++ adapter->rx_buffer_len,
++ PCI_DMA_FROMDEVICE);
++
++ /* Fix for errata 23, can't cross 64kB boundary */
++ if(!iegbe_check_64k_bound(adapter,
++ (void *)(unsigned long)buffer_info->dma,
++ adapter->rx_buffer_len)) {
++ DPRINTK(RX_ERR, ERR,
++ "dma align check failed: %u bytes at %p\n",
++ adapter->rx_buffer_len,
++ (void *)(unsigned long)buffer_info->dma);
++ dev_kfree_skb(skb);
++ buffer_info->skb = NULL;
++
++ pci_unmap_single(pdev, buffer_info->dma,
++ adapter->rx_buffer_len,
++ PCI_DMA_FROMDEVICE);
+
+- /* Force memory writes to complete before letting h/w
+- * know there are new descriptors to fetch. (Only
+- * applicable for weak-ordered memory model archs,
+- * such as IA-64). */
+- wmb();
+- writel(i, adapter->hw.hw_addr + rx_ring->rdt);
++ break; /* while !buffer_info->skb */
++ }
++ rx_desc = E1000_RX_DESC(*rx_ring, i);
++ rx_desc->buffer_addr = cpu_to_le64(buffer_info->dma);
+
+-#endif
+-#ifndef IEGBE_GBE_WORKAROUND
+- if(unlikely((i & ~(E1000_RX_BUFFER_WRITE - 0x1)) == i)) {
+- /* Force memory writes to complete before letting h/w
+- * know there are new descriptors to fetch. (Only
+- * applicable for weak-ordered memory model archs,
+- * such as IA-64). */
+- wmb();
+- writel(i, adapter->hw.hw_addr + rx_ring->rdt);
+- }
+-#endif
+- if(unlikely(++i == rx_ring->count)) { i = 0; }
+- buffer_info = &rx_ring->buffer_info[i];
+- }
++ /* Force memory writes to complete before letting h/w
++ * know there are new descriptors to fetch. (Only
++ * applicable for weak-ordered memory model archs,
++ * such as IA-64). */
++ if (unlikely(++i == rx_ring->count))
++ i = 0;
++ buffer_info = &rx_ring->buffer_info[i];
++ }
+
+-#ifdef IEGBE_GBE_WORKAROUND
+ if (likely(rx_ring->next_to_use != i)) {
+- rx_ring->next_to_use = i;
+- if (unlikely(i-- == 0)) {
+- i = (rx_ring->count - 0x1);
+- }
++ rx_ring->next_to_use = i;
++ if (unlikely(i-- == 0))
++ i = (rx_ring->count - 1);
++
+ /* Force memory writes to complete before letting h/w
+ * know there are new descriptors to fetch. (Only
+ * applicable for weak-ordered memory model archs,
+ * such as IA-64). */
+ wmb();
+- writel(i, adapter->hw.hw_addr + rx_ring->rdt);
++ writel(i, hw->hw_addr + rx_ring->rdt);
+ }
+-#else
+- rx_ring->next_to_use = i;
+-#endif
+ }
+
+ /**
+@@ -4412,49 +4154,41 @@ iegbe_alloc_rx_buffers(struct iegbe_adap
+ * @adapter: address of board private structure
+ **/
+
+-#ifdef IEGBE_GBE_WORKAROUND
+-static void
+-iegbe_alloc_rx_buffers_ps(struct iegbe_adapter *adapter,
++
++static void iegbe_alloc_rx_buffers_ps(struct iegbe_adapter *adapter,
+ struct iegbe_rx_ring *rx_ring,
+ int cleaned_count)
+-#else
+-static void
+-iegbe_alloc_rx_buffers_ps(struct iegbe_adapter *adapter,
+- struct iegbe_rx_ring *rx_ring)
+-#endif
+ {
+- struct net_device *netdev = adapter->netdev;
+- struct pci_dev *pdev = adapter->pdev;
+- union iegbe_rx_desc_packet_split *rx_desc;
+- struct iegbe_buffer *buffer_info;
+- struct iegbe_ps_page *ps_page;
+- struct iegbe_ps_page_dma *ps_page_dma;
+- struct sk_buff *skb;
+- unsigned int i, j;
+-
+- i = rx_ring->next_to_use;
+- buffer_info = &rx_ring->buffer_info[i];
+- ps_page = &rx_ring->ps_page[i];
+- ps_page_dma = &rx_ring->ps_page_dma[i];
++ struct iegbe_hw *hw = &adapter->hw;
++ struct net_device *netdev = adapter->netdev;
++ struct pci_dev *pdev = adapter->pdev;
++ union iegbe_rx_desc_packet_split *rx_desc;
++ struct iegbe_buffer *buffer_info;
++ struct iegbe_ps_page *ps_page;
++ struct iegbe_ps_page_dma *ps_page_dma;
++ struct sk_buff *skb;
++ unsigned int i, j;
++
++ i = rx_ring->next_to_use;
++ buffer_info = &rx_ring->buffer_info[i];
++ ps_page = &rx_ring->ps_page[i];
++ ps_page_dma = &rx_ring->ps_page_dma[i];
+
+-#ifdef IEGBE_GBE_WORKAROUND
+- while(cleaned_count-- && !buffer_info->skb) {
+-#else
+- while(!buffer_info->skb) {
+-#endif
+- rx_desc = E1000_RX_DESC_PS(*rx_ring, i);
++ while (cleaned_count--) {
++ rx_desc = E1000_RX_DESC_PS(*rx_ring, i);
+
+ for (j = 0; j < PS_PAGE_BUFFERS; j++) {
+- if (j < adapter->rx_ps_pages) {
+- if (likely(!ps_page->ps_page[j])) {
+- ps_page->ps_page[j] =
+- alloc_page(GFP_ATOMIC);
++ if (j < adapter->rx_ps_pages) {
++ if (likely(!ps_page->ps_page[j])) {
++ ps_page->ps_page[j] =
++ alloc_page(GFP_ATOMIC);
+ if (unlikely(!ps_page->ps_page[j])) {
+- goto no_buffers;
++ adapter->alloc_rx_buff_failed++;
++ goto no_buffers;
+ }
+- ps_page_dma->ps_page_dma[j] =
+- pci_map_page(pdev,
+- ps_page->ps_page[j],
++ ps_page_dma->ps_page_dma[j] =
++ pci_map_page(pdev,
++ ps_page->ps_page[j],
+ 0, PAGE_SIZE,
+ PCI_DMA_FROMDEVICE);
+ }
+@@ -4462,26 +4196,26 @@ iegbe_alloc_rx_buffers_ps(struct iegbe_a
+ * change because each write-back erases
+ * this info.
+ */
+- rx_desc->read.buffer_addr[j+0x1] =
++ rx_desc->read.buffer_addr[j+1] =
+ cpu_to_le64(ps_page_dma->ps_page_dma[j]);
+- } else {
+- rx_desc->read.buffer_addr[j+0x1] = ~0;
+- }
++ } else
++ rx_desc->read.buffer_addr[j+1] = ~cpu_to_le64(0);
+ }
+
+- skb = dev_alloc_skb(adapter->rx_ps_bsize0 + NET_IP_ALIGN);
++ skb = netdev_alloc_skb(netdev,
++ adapter->rx_ps_bsize0 + NET_IP_ALIGN);
+
+- if (unlikely(!skb)) {
++ if (unlikely(!skb)) {
++ adapter->alloc_rx_buff_failed++;
+ break;
+- }
++ }
++
+ /* Make buffer alignment 2 beyond a 16 byte boundary
+ * this will result in a 16 byte aligned IP header after
+ * the 14 byte MAC header is removed
+ */
+ skb_reserve(skb, NET_IP_ALIGN);
+
+- skb->dev = netdev;
+-
+ buffer_info->skb = skb;
+ buffer_info->length = adapter->rx_ps_bsize0;
+ buffer_info->dma = pci_map_single(pdev, skb->data,
+@@ -4490,27 +4224,28 @@ iegbe_alloc_rx_buffers_ps(struct iegbe_a
+
+ rx_desc->read.buffer_addr[0] = cpu_to_le64(buffer_info->dma);
+
+- if (unlikely((i & ~(E1000_RX_BUFFER_WRITE - 0x1)) == i)) {
+- /* Force memory writes to complete before letting h/w
+- * know there are new descriptors to fetch. (Only
+- * applicable for weak-ordered memory model archs,
+- * such as IA-64). */
+- wmb();
+- /* Hardware increments by 16 bytes, but packet split
+- * descriptors are 32 bytes...so we increment tail
+- * twice as much.
+- */
+- writel(i<<1, adapter->hw.hw_addr + rx_ring->rdt);
+- }
+-
+- if (unlikely(++i == rx_ring->count)) { i = 0; }
++ if (unlikely(++i == rx_ring->count)) i = 0;
+ buffer_info = &rx_ring->buffer_info[i];
+ ps_page = &rx_ring->ps_page[i];
+ ps_page_dma = &rx_ring->ps_page_dma[i];
+ }
+
+ no_buffers:
+- rx_ring->next_to_use = i;
++ if (likely(rx_ring->next_to_use != i)) {
++ rx_ring->next_to_use = i;
++ if (unlikely(i-- == 0)) i = (rx_ring->count - 1);
++
++ /* Force memory writes to complete before letting h/w
++ * know there are new descriptors to fetch. (Only
++ * applicable for weak-ordered memory model archs,
++ * such as IA-64). */
++ wmb();
++ /* Hardware increments by 16 bytes, but packet split
++ * descriptors are 32 bytes...so we increment tail
++ * twice as much.
++ */
++ writel(i<<1, hw->hw_addr + rx_ring->rdt);
++ }
+ }
+
+ /**
+@@ -4521,52 +4256,52 @@ no_buffers:
+ static void
+ iegbe_smartspeed(struct iegbe_adapter *adapter)
+ {
+- uint16_t phy_status;
+- uint16_t phy_ctrl;
++ uint16_t phy_status;
++ uint16_t phy_ctrl;
+
+- if((adapter->hw.phy_type != iegbe_phy_igp) || !adapter->hw.autoneg ||
++ if((adapter->hw.phy_type != iegbe_phy_igp) || !adapter->hw.autoneg ||
+ !(adapter->hw.autoneg_advertised & ADVERTISE_1000_FULL)) {
+- return;
++ return;
+ }
+- if(adapter->smartspeed == 0) {
+- /* If Master/Slave config fault is asserted twice,
+- * we assume back-to-back */
+- iegbe_read_phy_reg(&adapter->hw, PHY_1000T_STATUS, &phy_status);
++ if(adapter->smartspeed == 0x0) {
++ /* If Master/Slave config fault is asserted twice,
++ * we assume back-to-back */
++ iegbe_read_phy_reg(&adapter->hw, PHY_1000T_STATUS, &phy_status);
+ if(!(phy_status & SR_1000T_MS_CONFIG_FAULT)) { return; }
+- iegbe_read_phy_reg(&adapter->hw, PHY_1000T_STATUS, &phy_status);
++ iegbe_read_phy_reg(&adapter->hw, PHY_1000T_STATUS, &phy_status);
+ if(!(phy_status & SR_1000T_MS_CONFIG_FAULT)) { return; }
+- iegbe_read_phy_reg(&adapter->hw, PHY_1000T_CTRL, &phy_ctrl);
+- if(phy_ctrl & CR_1000T_MS_ENABLE) {
+- phy_ctrl &= ~CR_1000T_MS_ENABLE;
+- iegbe_write_phy_reg(&adapter->hw, PHY_1000T_CTRL,
+- phy_ctrl);
+- adapter->smartspeed++;
+- if(!iegbe_phy_setup_autoneg(&adapter->hw) &&
+- !iegbe_read_phy_reg(&adapter->hw, PHY_CTRL,
+- &phy_ctrl)) {
+- phy_ctrl |= (MII_CR_AUTO_NEG_EN |
+- MII_CR_RESTART_AUTO_NEG);
+- iegbe_write_phy_reg(&adapter->hw, PHY_CTRL,
+- phy_ctrl);
+- }
+- }
+- return;
+- } else if(adapter->smartspeed == E1000_SMARTSPEED_DOWNSHIFT) {
+- /* If still no link, perhaps using 2/3 pair cable */
+- iegbe_read_phy_reg(&adapter->hw, PHY_1000T_CTRL, &phy_ctrl);
+- phy_ctrl |= CR_1000T_MS_ENABLE;
+- iegbe_write_phy_reg(&adapter->hw, PHY_1000T_CTRL, phy_ctrl);
+- if(!iegbe_phy_setup_autoneg(&adapter->hw) &&
+- !iegbe_read_phy_reg(&adapter->hw, PHY_CTRL, &phy_ctrl)) {
+- phy_ctrl |= (MII_CR_AUTO_NEG_EN |
+- MII_CR_RESTART_AUTO_NEG);
+- iegbe_write_phy_reg(&adapter->hw, PHY_CTRL, phy_ctrl);
+- }
+- }
+- /* Restart process after E1000_SMARTSPEED_MAX iterations */
++ iegbe_read_phy_reg(&adapter->hw, PHY_1000T_CTRL, &phy_ctrl);
++ if(phy_ctrl & CR_1000T_MS_ENABLE) {
++ phy_ctrl &= ~CR_1000T_MS_ENABLE;
++ iegbe_write_phy_reg(&adapter->hw, PHY_1000T_CTRL,
++ phy_ctrl);
++ adapter->smartspeed++;
++ if(!iegbe_phy_setup_autoneg(&adapter->hw) &&
++ !iegbe_read_phy_reg(&adapter->hw, PHY_CTRL,
++ &phy_ctrl)) {
++ phy_ctrl |= (MII_CR_AUTO_NEG_EN |
++ MII_CR_RESTART_AUTO_NEG);
++ iegbe_write_phy_reg(&adapter->hw, PHY_CTRL,
++ phy_ctrl);
++ }
++ }
++ return;
++ } else if(adapter->smartspeed == E1000_SMARTSPEED_DOWNSHIFT) {
++ /* If still no link, perhaps using 2/3 pair cable */
++ iegbe_read_phy_reg(&adapter->hw, PHY_1000T_CTRL, &phy_ctrl);
++ phy_ctrl |= CR_1000T_MS_ENABLE;
++ iegbe_write_phy_reg(&adapter->hw, PHY_1000T_CTRL, phy_ctrl);
++ if(!iegbe_phy_setup_autoneg(&adapter->hw) &&
++ !iegbe_read_phy_reg(&adapter->hw, PHY_CTRL, &phy_ctrl)) {
++ phy_ctrl |= (MII_CR_AUTO_NEG_EN |
++ MII_CR_RESTART_AUTO_NEG);
++ iegbe_write_phy_reg(&adapter->hw, PHY_CTRL, phy_ctrl);
++ }
++ }
++ /* Restart process after E1000_SMARTSPEED_MAX iterations */
+ if(adapter->smartspeed++ == E1000_SMARTSPEED_MAX) {
+- adapter->smartspeed = 0;
+-}
++ adapter->smartspeed = 0x0;
++ }
+ }
+
+ /**
+@@ -4576,23 +4311,22 @@ iegbe_smartspeed(struct iegbe_adapter *a
+ * @cmd:
+ **/
+
+-static int
+-iegbe_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
++static int iegbe_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
+ {
+- switch (cmd) {
++ switch (cmd) {
+ #ifdef SIOCGMIIPHY
+- case SIOCGMIIPHY:
+- case SIOCGMIIREG:
+- case SIOCSMIIREG:
+- return iegbe_mii_ioctl(netdev, ifr, cmd);
++ case SIOCGMIIPHY:
++ case SIOCGMIIREG:
++ case SIOCSMIIREG:
++ return iegbe_mii_ioctl(netdev, ifr, cmd);
+ #endif
+ #ifdef ETHTOOL_OPS_COMPAT
+- case SIOCETHTOOL:
+- return ethtool_ioctl(ifr);
++ case SIOCETHTOOL:
++ return ethtool_ioctl(ifr);
+ #endif
+- default:
+- return -EOPNOTSUPP;
+- }
++ default:
++ return -EOPNOTSUPP;
++ }
+ }
+
+ #ifdef SIOCGMIIPHY
+@@ -4603,534 +4337,510 @@ iegbe_ioctl(struct net_device *netdev, s
+ * @cmd:
+ **/
+
+-static int
+-iegbe_mii_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
++static int iegbe_mii_ioctl(struct net_device *netdev, struct ifreq *ifr,
++ int cmd)
+ {
+- struct iegbe_adapter *adapter = netdev_priv(netdev);
+- struct mii_ioctl_data *data = if_mii(ifr);
+- int retval;
+- uint16_t mii_reg;
+- uint16_t spddplx;
+- unsigned long flags;
+-
+- if((adapter->hw.media_type == iegbe_media_type_oem &&
+- !iegbe_oem_phy_is_copper(&adapter->hw)) ||
+- adapter->hw.media_type == iegbe_media_type_fiber ||
+- adapter->hw.media_type == iegbe_media_type_internal_serdes ) {
+- return -EOPNOTSUPP;
+- }
+- switch (cmd) {
+- case SIOCGMIIPHY:
+- data->phy_id = adapter->hw.phy_addr;
+- break;
+- case SIOCGMIIREG:
++ struct iegbe_adapter *adapter = netdev_priv(netdev);
++ struct mii_ioctl_data *data = if_mii(ifr);
++ int retval;
++ uint16_t mii_reg;
++ uint16_t spddplx;
++ unsigned long flags = 0;
++
++ if((adapter->hw.media_type == iegbe_media_type_oem
++ && !iegbe_oem_phy_is_copper(&adapter->hw))
++ ||adapter->hw.media_type != iegbe_media_type_copper) {
++ return -EOPNOTSUPP;
++ }
++ switch (cmd) {
++ case SIOCGMIIPHY:
++ data->phy_id = adapter->hw.phy_addr;
++ break;
++ case SIOCGMIIREG:
+ if(!capable(CAP_NET_ADMIN)) {
+- return -EPERM;
++ return -EPERM;
+ }
+- spin_lock_irqsave(&adapter->stats_lock, flags);
+- if(iegbe_read_phy_reg(&adapter->hw, data->reg_num & 0x1F,
+- &data->val_out)) {
+- spin_unlock_irqrestore(&adapter->stats_lock, flags);
+- return -EIO;
+- }
+- spin_unlock_irqrestore(&adapter->stats_lock, flags);
+- break;
+- case SIOCSMIIREG:
++ spin_lock_irqsave(&adapter->stats_lock, flags);
++ if(iegbe_read_phy_reg(&adapter->hw, data->reg_num & 0x1F,
++ &data->val_out)) {
++ spin_unlock_irqrestore(&adapter->stats_lock, flags);
++ return -EIO;
++ }
++ spin_unlock_irqrestore(&adapter->stats_lock, flags);
++ break;
++ case SIOCSMIIREG:
+ if(!capable(CAP_NET_ADMIN)){
+- return -EPERM;
++ return -EPERM;
+ }
+ if(data->reg_num & ~(0x1F)) {
+- return -EFAULT;
++ return -EFAULT;
+ }
+- mii_reg = data->val_in;
+- spin_lock_irqsave(&adapter->stats_lock, flags);
+- if(iegbe_write_phy_reg(&adapter->hw, data->reg_num,
+- mii_reg)) {
+- spin_unlock_irqrestore(&adapter->stats_lock, flags);
+- return -EIO;
+- }
+- switch(adapter->hw.phy_type) {
+- case iegbe_phy_m88:
+- switch (data->reg_num) {
+- case PHY_CTRL:
++ mii_reg = data->val_in;
++ spin_lock_irqsave(&adapter->stats_lock, flags);
++ if(iegbe_write_phy_reg(&adapter->hw, data->reg_num,
++ mii_reg)) {
++ spin_unlock_irqrestore(&adapter->stats_lock, flags);
++ return -EIO;
++ }
++ switch(adapter->hw.phy_type) {
++ case iegbe_phy_m88:
++ switch (data->reg_num) {
++ case PHY_CTRL:
+ if(mii_reg & MII_CR_POWER_DOWN) {
+- break;
++ break;
+ }
+- if(mii_reg & MII_CR_AUTO_NEG_EN) {
+- adapter->hw.autoneg = 1;
+- adapter->hw.autoneg_advertised = 0x2F;
+- } else {
++ if(mii_reg & MII_CR_AUTO_NEG_EN) {
++ adapter->hw.autoneg = 1;
++ adapter->hw.autoneg_advertised = 0x2F;
++ } else {
+ if(mii_reg & 0x40){
+- spddplx = SPEED_1000;
++ spddplx = SPEED_1000;
+ } else if(mii_reg & 0x2000) {
+- spddplx = SPEED_100;
++ spddplx = SPEED_100;
+ } else {
+- spddplx = SPEED_10;
++ spddplx = SPEED_10;
+ }
+- spddplx += (mii_reg & 0x100)
+- ? FULL_DUPLEX :
+- HALF_DUPLEX;
+- retval = iegbe_set_spd_dplx(adapter,
+- spddplx);
+- if(retval) {
+- spin_unlock_irqrestore(
+- &adapter->stats_lock,
+- flags);
+- return retval;
+- }
+- }
+- if(netif_running(adapter->netdev)) {
+- iegbe_down(adapter);
+- iegbe_up(adapter);
++ spddplx += (mii_reg & 0x100)
++ ? FULL_DUPLEX :
++ HALF_DUPLEX;
++ retval = iegbe_set_spd_dplx(adapter,
++ spddplx);
++ if(retval) {
++ spin_unlock_irqrestore(
++ &adapter->stats_lock,
++ flags);
++ return retval;
++ }
++ }
++ if(netif_running(adapter->netdev)) {
++ iegbe_down(adapter);
++ iegbe_up(adapter);
+ } else {
+- iegbe_reset(adapter);
++ iegbe_reset(adapter);
+ }
+- break;
+- case M88E1000_PHY_SPEC_CTRL:
+- case M88E1000_EXT_PHY_SPEC_CTRL:
+- if(iegbe_phy_reset(&adapter->hw)) {
+- spin_unlock_irqrestore(
+- &adapter->stats_lock, flags);
+- return -EIO;
+- }
+- break;
+- }
+- break;
++ break;
++ case M88E1000_PHY_SPEC_CTRL:
++ case M88E1000_EXT_PHY_SPEC_CTRL:
++ if(iegbe_phy_reset(&adapter->hw)) {
++ spin_unlock_irqrestore(
++ &adapter->stats_lock, flags);
++ return -EIO;
++ }
++ break;
++ }
++ break;
+
+- case iegbe_phy_oem:
+- retval = iegbe_oem_mii_ioctl(adapter, flags, ifr, cmd);
+- if(retval) {
+- spin_unlock_irqrestore(
+- &adapter->stats_lock, flags);
+- return retval;
+- }
+- break;
++ case iegbe_phy_oem:
++ retval = iegbe_oem_mii_ioctl(adapter, flags, ifr, cmd);
++ if(retval) {
++ spin_unlock_irqrestore(
++ &adapter->stats_lock, flags);
++ return retval;
++ }
++ break;
+
+- default:
+- switch (data->reg_num) {
+- case PHY_CTRL:
++ default:
++ switch (data->reg_num) {
++ case PHY_CTRL:
+ if(mii_reg & MII_CR_POWER_DOWN) {
+- break;
++ break;
+ }
+- if(netif_running(adapter->netdev)) {
+- iegbe_down(adapter);
+- iegbe_up(adapter);
++ if(netif_running(adapter->netdev)) {
++ iegbe_down(adapter);
++ iegbe_up(adapter);
+ } else {
+- iegbe_reset(adapter);
++ iegbe_reset(adapter);
+ }
+- break;
+- }
+- }
+- spin_unlock_irqrestore(&adapter->stats_lock, flags);
+- break;
+- default:
+- return -EOPNOTSUPP;
+- }
+- return E1000_SUCCESS;
++ break;
++ }
++ }
++ spin_unlock_irqrestore(&adapter->stats_lock, flags);
++ break;
++ default:
++ return -EOPNOTSUPP;
++ }
++ return E1000_SUCCESS;
+ }
+ #endif
+
+-void
+-iegbe_pci_set_mwi(struct iegbe_hw *hw)
++void iegbe_pci_set_mwi(struct iegbe_hw *hw)
+ {
+- struct iegbe_adapter *adapter = hw->back;
+-#ifdef HAVE_PCI_SET_MWI
+- int ret_val = pci_set_mwi(adapter->pdev);
+-
+- if(ret_val) {
+- DPRINTK(PROBE, ERR, "Error in setting MWI\n");
+- }
+-#else
+- pci_write_config_word(adapter->pdev, PCI_COMMAND,
+- adapter->hw.pci_cmd_word |
+- PCI_COMMAND_INVALIDATE);
+-#endif
++ struct iegbe_adapter *adapter = hw->back;
++ int ret_val = pci_set_mwi(adapter->pdev);
++
++ if (ret_val)
++ DPRINTK(PROBE, ERR, "Error in setting MWI\n");
+ }
+
+-void
+-iegbe_pci_clear_mwi(struct iegbe_hw *hw)
++void iegbe_pci_clear_mwi(struct iegbe_hw *hw)
+ {
+- struct iegbe_adapter *adapter = hw->back;
++ struct iegbe_adapter *adapter = hw->back;
+
+-#ifdef HAVE_PCI_SET_MWI
+- pci_clear_mwi(adapter->pdev);
+-#else
+- pci_write_config_word(adapter->pdev, PCI_COMMAND,
+- adapter->hw.pci_cmd_word &
+- ~PCI_COMMAND_INVALIDATE);
+-#endif
++ pci_clear_mwi(adapter->pdev);
+ }
+
+ void
+ iegbe_read_pci_cfg(struct iegbe_hw *hw, uint32_t reg, uint16_t *value)
+ {
+- struct iegbe_adapter *adapter = hw->back;
++ struct iegbe_adapter *adapter = hw->back;
+
+- pci_read_config_word(adapter->pdev, reg, value);
++ pci_read_config_word(adapter->pdev, reg, value);
+ }
+
+ void
+ iegbe_write_pci_cfg(struct iegbe_hw *hw, uint32_t reg, uint16_t *value)
+ {
+- struct iegbe_adapter *adapter = hw->back;
++ struct iegbe_adapter *adapter = hw->back;
+
+- pci_write_config_word(adapter->pdev, reg, *value);
++ pci_write_config_word(adapter->pdev, reg, *value);
+ }
+
+ uint32_t
+ iegbe_io_read(struct iegbe_hw *hw, unsigned long port)
+ {
+- return inl(port);
++ return inl(port);
+ }
+
+ void
+ iegbe_io_write(struct iegbe_hw *hw, unsigned long port, uint32_t value)
+ {
+- outl(value, port);
++ outl(value, port);
+ }
+
+-#ifdef NETIF_F_HW_VLAN_TX
+-static void
+-iegbe_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp)
++static void iegbe_vlan_rx_register(struct net_device *netdev,
++ struct vlan_group *grp)
+ {
+- struct iegbe_adapter *adapter = netdev_priv(netdev);
+- uint32_t ctrl, rctl;
+-
+- iegbe_irq_disable(adapter);
+- adapter->vlgrp = grp;
+-
+- if(grp) {
+- /* enable VLAN tag insert/strip */
+- ctrl = E1000_READ_REG(&adapter->hw, CTRL);
+- ctrl |= E1000_CTRL_VME;
+- E1000_WRITE_REG(&adapter->hw, CTRL, ctrl);
+-
+- /* enable VLAN receive filtering */
+- rctl = E1000_READ_REG(&adapter->hw, RCTL);
+- rctl |= E1000_RCTL_VFE;
+- rctl &= ~E1000_RCTL_CFIEN;
+- E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
+- iegbe_update_mng_vlan(adapter);
+- } else {
+- /* disable VLAN tag insert/strip */
+- ctrl = E1000_READ_REG(&adapter->hw, CTRL);
+- ctrl &= ~E1000_CTRL_VME;
+- E1000_WRITE_REG(&adapter->hw, CTRL, ctrl);
++ struct iegbe_adapter *adapter = netdev_priv(netdev);
++ uint32_t ctrl, rctl;
+
+- /* disable VLAN filtering */
+- rctl = E1000_READ_REG(&adapter->hw, RCTL);
+- rctl &= ~E1000_RCTL_VFE;
+- E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
+- if(adapter->mng_vlan_id != (uint16_t)E1000_MNG_VLAN_NONE) {
+- iegbe_vlan_rx_kill_vid(netdev, adapter->mng_vlan_id);
+- adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
+- }
+- }
++ if (!test_bit(__E1000_DOWN, &adapter->flags))
++ iegbe_irq_disable(adapter);
++ adapter->vlgrp = grp;
++
++ if(grp) {
++ /* enable VLAN tag insert/strip */
++ ctrl = E1000_READ_REG(&adapter->hw, CTRL);
++ ctrl |= E1000_CTRL_VME;
++ E1000_WRITE_REG(&adapter->hw, CTRL, ctrl);
++
++ /* enable VLAN receive filtering */
++ rctl = E1000_READ_REG(&adapter->hw, RCTL);
++ rctl |= E1000_RCTL_VFE;
++ rctl &= ~E1000_RCTL_CFIEN;
++ E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
++ iegbe_update_mng_vlan(adapter);
++ } else {
++ /* disable VLAN tag insert/strip */
++ ctrl = E1000_READ_REG(&adapter->hw, CTRL);
++ ctrl &= ~E1000_CTRL_VME;
++ E1000_WRITE_REG(&adapter->hw, CTRL, ctrl);
++
++ /* disable VLAN filtering */
++ rctl = E1000_READ_REG(&adapter->hw, RCTL);
++ rctl &= ~E1000_RCTL_VFE;
++ E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
++ if(adapter->mng_vlan_id != (uint16_t)E1000_MNG_VLAN_NONE) {
++ iegbe_vlan_rx_kill_vid(netdev, adapter->mng_vlan_id);
++ adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
++ }
++ }
+
+- iegbe_irq_enable(adapter);
++ if (!test_bit(__E1000_DOWN, &adapter->flags))
++ iegbe_irq_enable(adapter);
+ }
+
+-static void
+-iegbe_vlan_rx_add_vid(struct net_device *netdev, uint16_t vid)
++static void iegbe_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
+ {
+- struct iegbe_adapter *adapter = netdev_priv(netdev);
+- uint32_t vfta, index;
+- if((adapter->hw.mng_cookie.status &
+- E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) &&
++ struct iegbe_adapter *adapter = netdev_priv(netdev);
++ uint32_t vfta, index;
++ if((adapter->hw.mng_cookie.status &
++ E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) &&
+ (vid == adapter->mng_vlan_id)) {
+- return;
++ return;
+ }
+- /* add VID to filter table */
++ /* add VID to filter table */
+ index = (vid >> 0x5) & 0x7F;
+- vfta = E1000_READ_REG_ARRAY(&adapter->hw, VFTA, index);
++ vfta = E1000_READ_REG_ARRAY(&adapter->hw, VFTA, index);
+ vfta |= (0x1 << (vid & 0x1F));
+- iegbe_write_vfta(&adapter->hw, index, vfta);
++ iegbe_write_vfta(&adapter->hw, index, vfta);
+ }
+
+-static void
+-iegbe_vlan_rx_kill_vid(struct net_device *netdev, uint16_t vid)
++static void iegbe_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
+ {
+ struct iegbe_adapter *adapter = netdev_priv(netdev);
+- uint32_t vfta, index;
++ u32 vfta, index;
+
++ if (!test_bit(__E1000_DOWN, &adapter->flags))
+ iegbe_irq_disable(adapter);
+-
+- if(adapter->vlgrp) {
+- adapter->vlgrp->vlan_devices[vid] = NULL;
+- }
++ vlan_group_set_device(adapter->vlgrp, vid, NULL);
++ if (!test_bit(__E1000_DOWN, &adapter->flags))
+ iegbe_irq_enable(adapter);
+
+- if((adapter->hw.mng_cookie.status &
+- E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) &&
+- (vid == adapter->mng_vlan_id)) {
+- return;
+- }
+ /* remove VID from filter table */
+- index = (vid >> 0x5) & 0x7F;
++ index = (vid >> 0x5) & 0x7F;
+ vfta = E1000_READ_REG_ARRAY(&adapter->hw, VFTA, index);
+- vfta &= ~(0x1 << (vid & 0x1F));
++ vfta &= ~(0x1 << (vid & 0x1F));
+ iegbe_write_vfta(&adapter->hw, index, vfta);
+ }
+
+-static void
+-iegbe_restore_vlan(struct iegbe_adapter *adapter)
++static void iegbe_restore_vlan(struct iegbe_adapter *adapter)
+ {
+ iegbe_vlan_rx_register(adapter->netdev, adapter->vlgrp);
+
+- if(adapter->vlgrp) {
+- uint16_t vid;
+- for(vid = 0; vid < VLAN_GROUP_ARRAY_LEN; vid++) {
+- if(!adapter->vlgrp->vlan_devices[vid]) {
++ if (adapter->vlgrp) {
++ u16 vid;
++ for (vid = 0x0; vid < VLAN_GROUP_ARRAY_LEN; vid++) {
++ if (!vlan_group_get_device(adapter->vlgrp, vid))
+ continue;
+- }
+ iegbe_vlan_rx_add_vid(adapter->netdev, vid);
+ }
+ }
+ }
+-#endif
+
+-int
+-iegbe_set_spd_dplx(struct iegbe_adapter *adapter, uint16_t spddplx)
++
++int iegbe_set_spd_dplx(struct iegbe_adapter *adapter, u16 spddplx)
+ {
+- adapter->hw.autoneg = 0;
++ adapter->hw.autoneg = 0x0;
+
+- /* Fiber NICs only allow 1000 gbps Full duplex */
+- if((adapter->hw.media_type == iegbe_media_type_fiber
++ /* Fiber NICs only allow 1000 gbps Full duplex */
++ if((adapter->hw.media_type == iegbe_media_type_fiber
+ || (adapter->hw.media_type == iegbe_media_type_oem
+ && !iegbe_oem_phy_is_copper(&adapter->hw)))
+- && spddplx != (SPEED_1000 + FULL_DUPLEX)) {
+- DPRINTK(PROBE, ERR, "Unsupported Speed/Duplex configuration\n");
+- return -EINVAL;
+- }
+-
+- switch(spddplx) {
+- case SPEED_10 + HALF_DUPLEX:
+- adapter->hw.forced_speed_duplex = iegbe_10_half;
+- break;
+- case SPEED_10 + FULL_DUPLEX:
+- adapter->hw.forced_speed_duplex = iegbe_10_full;
+- break;
+- case SPEED_100 + HALF_DUPLEX:
+- adapter->hw.forced_speed_duplex = iegbe_100_half;
+- break;
+- case SPEED_100 + FULL_DUPLEX:
+- adapter->hw.forced_speed_duplex = iegbe_100_full;
+- break;
+- case SPEED_1000 + FULL_DUPLEX:
++ && spddplx != (SPEED_1000 + DUPLEX_FULL)) {
++ DPRINTK(PROBE, ERR, "Unsupported Speed/Duplex configuration\n");
++ return -EINVAL;
++ }
++
++ switch(spddplx) {
++ case SPEED_10 + DUPLEX_HALF:
++ adapter->hw.forced_speed_duplex = iegbe_10_half;
++ break;
++ case SPEED_10 + DUPLEX_FULL:
++ adapter->hw.forced_speed_duplex = iegbe_10_full;
++ break;
++ case SPEED_100 + DUPLEX_HALF:
++ adapter->hw.forced_speed_duplex = iegbe_100_half;
++ break;
++ case SPEED_100 + DUPLEX_FULL:
++ adapter->hw.forced_speed_duplex = iegbe_100_full;
++ break;
++ case SPEED_1000 + DUPLEX_FULL:
+ adapter->hw.autoneg = 0x1;
+- adapter->hw.autoneg_advertised = ADVERTISE_1000_FULL;
+- break;
+- case SPEED_1000 + HALF_DUPLEX: /* not supported */
+- default:
+- DPRINTK(PROBE, ERR, "Unsupported Speed/Duplex configuration\n");
+- return -EINVAL;
+- }
+- return 0;
++ adapter->hw.autoneg_advertised = ADVERTISE_1000_FULL;
++ break;
++ case SPEED_1000 + DUPLEX_HALF: /* not supported */
++ default:
++ DPRINTK(PROBE, ERR, "Unsupported Speed/Duplex configuration\n");
++ return -EINVAL;
++ }
++ return 0x0;
+ }
+
+ static int
+ iegbe_notify_reboot(struct notifier_block *nb, unsigned long event, void *p)
+ {
+- struct pci_dev *pdev = NULL;
++ struct pci_dev *pdev = NULL;
+ pm_message_t state = {0x3};
+
+
+- switch(event) {
+- case SYS_DOWN:
+- case SYS_HALT:
+- case SYS_POWER_OFF:
+- while((pdev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pdev))) {
++ switch(event) {
++ case SYS_DOWN:
++ case SYS_HALT:
++ case SYS_POWER_OFF:
++ while((pdev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pdev))) {
+ if(pci_dev_driver(pdev) == &iegbe_driver) {
+- iegbe_suspend(pdev, state);
+- }
+- }
++ iegbe_suspend(pdev, state);
++ }
++ }
+ }
+- return NOTIFY_DONE;
++ return NOTIFY_DONE;
+ }
+
+ static int
+ iegbe_suspend(struct pci_dev *pdev, pm_message_t state)
+ {
+- struct net_device *netdev = pci_get_drvdata(pdev);
+- struct iegbe_adapter *adapter = netdev_priv(netdev);
+- uint32_t ctrl, ctrl_ext, rctl, manc, status, swsm;
+- uint32_t wufc = adapter->wol;
+- uint16_t cmd_word;
++ struct net_device *netdev = pci_get_drvdata(pdev);
++ struct iegbe_adapter *adapter = netdev_priv(netdev);
++ uint32_t ctrl, ctrl_ext, rctl, manc, status, swsm;
++ uint32_t wufc = adapter->wol;
++ uint16_t cmd_word;
+
+- netif_device_detach(netdev);
++ netif_device_detach(netdev);
+
+ if(netif_running(netdev)) {
+- iegbe_down(adapter);
++ WARN_ON(test_bit(__E1000_RESETTING, &adapter->flags));
++ iegbe_down(adapter);
+ }
+- /*
+- * ICP_XXXX style MACs do not have a link up bit in
+- * the STATUS register, query the PHY directly
+- */
+- if(adapter->hw.mac_type != iegbe_icp_xxxx) {
+- status = E1000_READ_REG(&adapter->hw, STATUS);
++ /*
++ * ICP_XXXX style MACs do not have a link up bit in
++ * the STATUS register, query the PHY directly
++ */
++ if(adapter->hw.mac_type != iegbe_icp_xxxx) {
++ status = E1000_READ_REG(&adapter->hw, STATUS);
+ if(status & E1000_STATUS_LU) {
+- wufc &= ~E1000_WUFC_LNKC;
++ wufc &= ~E1000_WUFC_LNKC;
+ }
+- } else {
+- int isUp = 0;
++ } else {
++ int isUp = 0x0;
+ if(iegbe_oem_phy_is_link_up(&adapter->hw, &isUp) != E1000_SUCCESS) {
+- isUp = 0;
++ isUp = 0x0;
+ }
+ if(isUp) {
+- wufc &= ~E1000_WUFC_LNKC;
+- }
++ wufc &= ~E1000_WUFC_LNKC;
++ }
+ }
+
+- if(wufc) {
+- iegbe_setup_rctl(adapter);
+- iegbe_set_multi(netdev);
+-
+- /* turn on all-multi mode if wake on multicast is enabled */
+- if(adapter->wol & E1000_WUFC_MC) {
+- rctl = E1000_READ_REG(&adapter->hw, RCTL);
+- rctl |= E1000_RCTL_MPE;
+- E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
+- }
++ if(wufc) {
++ iegbe_setup_rctl(adapter);
++ iegbe_set_rx_mode(netdev);
++
++ /* turn on all-multi mode if wake on multicast is enabled */
++ if(adapter->wol & E1000_WUFC_MC) {
++ rctl = E1000_READ_REG(&adapter->hw, RCTL);
++ rctl |= E1000_RCTL_MPE;
++ E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
++ }
+
+- if(adapter->hw.mac_type >= iegbe_82540) {
+- ctrl = E1000_READ_REG(&adapter->hw, CTRL);
+- /* advertise wake from D3Cold */
+- #define E1000_CTRL_ADVD3WUC 0x00100000
+- /* phy power management enable */
+- ctrl |= E1000_CTRL_ADVD3WUC |
+- (adapter->hw.mac_type != iegbe_icp_xxxx
+- ? E1000_CTRL_EN_PHY_PWR_MGMT : 0);
++ if(adapter->hw.mac_type >= iegbe_82540) {
++ ctrl = E1000_READ_REG(&adapter->hw, CTRL);
++ /* advertise wake from D3Cold */
++ #define E1000_CTRL_ADVD3WUC 0x00100000
++ /* phy power management enable */
++ #define E1000_CTRL_EN_PHY_PWR_MGMT 0x00200000
++ ctrl |= E1000_CTRL_ADVD3WUC |
++ (adapter->hw.mac_type != iegbe_icp_xxxx
++ ? E1000_CTRL_EN_PHY_PWR_MGMT : 0x0);
+
+- E1000_WRITE_REG(&adapter->hw, CTRL, ctrl);
+- }
++ E1000_WRITE_REG(&adapter->hw, CTRL, ctrl);
++ }
+
+- if(adapter->hw.media_type == iegbe_media_type_fiber ||
+- adapter->hw.media_type == iegbe_media_type_internal_serdes) {
+- /* keep the laser running in D3 */
+- ctrl_ext = E1000_READ_REG(&adapter->hw, CTRL_EXT);
+- ctrl_ext |= E1000_CTRL_EXT_SDP7_DATA;
+- E1000_WRITE_REG(&adapter->hw, CTRL_EXT, ctrl_ext);
+- }
++ if(adapter->hw.media_type == iegbe_media_type_fiber ||
++ adapter->hw.media_type == iegbe_media_type_internal_serdes) {
++ /* keep the laser running in D3 */
++ ctrl_ext = E1000_READ_REG(&adapter->hw, CTRL_EXT);
++ ctrl_ext |= E1000_CTRL_EXT_SDP7_DATA;
++ E1000_WRITE_REG(&adapter->hw, CTRL_EXT, ctrl_ext);
++ }
+
+ /* Allow OEM PHYs (if any exist) to keep the laser
+ *running in D3 */
+ iegbe_oem_fiber_live_in_suspend(&adapter->hw);
+
+- /* Allow time for pending master requests to run */
+- iegbe_disable_pciex_master(&adapter->hw);
++ /* Allow time for pending master requests to run */
++ iegbe_disable_pciex_master(&adapter->hw);
+
+- E1000_WRITE_REG(&adapter->hw, WUC, E1000_WUC_PME_EN);
+- E1000_WRITE_REG(&adapter->hw, WUFC, wufc);
++ E1000_WRITE_REG(&adapter->hw, WUC, E1000_WUC_PME_EN);
++ E1000_WRITE_REG(&adapter->hw, WUFC, wufc);
+ pci_enable_wake(pdev, 0x3, 0x1);
+ pci_enable_wake(pdev, 0x4, 0x1); /* 4 == D3 cold */
+- } else {
+- E1000_WRITE_REG(&adapter->hw, WUC, 0);
+- E1000_WRITE_REG(&adapter->hw, WUFC, 0);
+- pci_enable_wake(pdev, 0x3, 0);
+- pci_enable_wake(pdev, 0x4, 0); /* 4 == D3 cold */
+- }
++ } else {
++ E1000_WRITE_REG(&adapter->hw, WUC, 0x0);
++ E1000_WRITE_REG(&adapter->hw, WUFC, 0x0);
++ pci_enable_wake(pdev, 0x3, 0x0);
++ pci_enable_wake(pdev, 0x4, 0x0); /* 4 == D3 cold */
++ }
+
+- pci_save_state(pdev);
+-
+- if(adapter->hw.mac_type >= iegbe_82540
+- && adapter->hw.mac_type != iegbe_icp_xxxx
+- && adapter->hw.media_type == iegbe_media_type_copper) {
+- manc = E1000_READ_REG(&adapter->hw, MANC);
+- if(manc & E1000_MANC_SMBUS_EN) {
+- manc |= E1000_MANC_ARP_EN;
+- E1000_WRITE_REG(&adapter->hw, MANC, manc);
++ pci_save_state(pdev);
++
++ if(adapter->hw.mac_type >= iegbe_82540
++ && adapter->hw.mac_type != iegbe_icp_xxxx
++ && adapter->hw.media_type == iegbe_media_type_copper) {
++ manc = E1000_READ_REG(&adapter->hw, MANC);
++ if(manc & E1000_MANC_SMBUS_EN) {
++ manc |= E1000_MANC_ARP_EN;
++ E1000_WRITE_REG(&adapter->hw, MANC, manc);
+ pci_enable_wake(pdev, 0x3, 0x1);
+ pci_enable_wake(pdev, 0x4, 0x1); /* 4 == D3 cold */
+- }
+- }
++ }
++ }
+
+- switch(adapter->hw.mac_type) {
+- case iegbe_82571:
+- case iegbe_82572:
+- ctrl_ext = E1000_READ_REG(&adapter->hw, CTRL_EXT);
+- E1000_WRITE_REG(&adapter->hw, CTRL_EXT,
+- ctrl_ext & ~E1000_CTRL_EXT_DRV_LOAD);
+- break;
+- case iegbe_82573:
+- swsm = E1000_READ_REG(&adapter->hw, SWSM);
+- E1000_WRITE_REG(&adapter->hw, SWSM,
+- swsm & ~E1000_SWSM_DRV_LOAD);
+- break;
+- default:
+- break;
+- }
++ switch(adapter->hw.mac_type) {
++ case iegbe_82571:
++ case iegbe_82572:
++ ctrl_ext = E1000_READ_REG(&adapter->hw, CTRL_EXT);
++ E1000_WRITE_REG(&adapter->hw, CTRL_EXT,
++ ctrl_ext & ~E1000_CTRL_EXT_DRV_LOAD);
++ break;
++ case iegbe_82573:
++ swsm = E1000_READ_REG(&adapter->hw, SWSM);
++ E1000_WRITE_REG(&adapter->hw, SWSM,
++ swsm & ~E1000_SWSM_DRV_LOAD);
++ break;
++ default:
++ break;
++ }
+
+- pci_disable_device(pdev);
+- if(adapter->hw.mac_type == iegbe_icp_xxxx) {
+- /*
+- * ICP xxxx devices are not true PCI devices, in the context
+- * of power management, disabling the bus mastership is not
+- * sufficient to disable the device, it is also necessary to
+- * disable IO, Memory, and Interrupts if they are enabled.
+- */
+- pci_read_config_word(pdev, PCI_COMMAND, &cmd_word);
++ pci_disable_device(pdev);
++ if(adapter->hw.mac_type == iegbe_icp_xxxx) {
++ /*
++ * ICP xxxx devices are not true PCI devices, in the context
++ * of power management, disabling the bus mastership is not
++ * sufficient to disable the device, it is also necessary to
++ * disable IO, Memory, and Interrupts if they are enabled.
++ */
++ pci_read_config_word(pdev, PCI_COMMAND, &cmd_word);
+ if(cmd_word & PCI_COMMAND_IO) {
+- cmd_word &= ~PCI_COMMAND_IO;
++ cmd_word &= ~PCI_COMMAND_IO;
+ }
+ if(cmd_word & PCI_COMMAND_MEMORY) {
+- cmd_word &= ~PCI_COMMAND_MEMORY;
++ cmd_word &= ~PCI_COMMAND_MEMORY;
+ }
+ if(cmd_word & PCI_COMMAND_INTX_DISABLE) {
+- cmd_word &= ~PCI_COMMAND_INTX_DISABLE;
++ cmd_word &= ~PCI_COMMAND_INTX_DISABLE;
+ }
+- pci_write_config_word(pdev, PCI_COMMAND, cmd_word);
+- }
++ pci_write_config_word(pdev, PCI_COMMAND, cmd_word);
++ }
+
+- state.event = (state.event > 0) ? 0x3 : 0;
+- pci_set_power_state(pdev, state.event);
+- if(gcu_suspend == 0)
++ state.event = (state.event > 0x0) ? 0x3 : 0x0;
++ pci_set_power_state(pdev, state.event);
++ if(gcu_suspend == 0x0)
+ {
+ if(gcu == NULL) {
+- gcu = pci_find_device(PCI_VENDOR_ID_INTEL, GCU_DEVID, NULL);
+- }
++ gcu = pci_get_device(PCI_VENDOR_ID_INTEL, GCU_DEVID, NULL);
++ }
+ gcu_iegbe_suspend(gcu, 0x3);
+- gcu_suspend = 1;
+- gcu_resume = 0;
++ gcu_suspend = 0x1;
++ gcu_resume = 0x0;
+ }
+- return 0;
++ return 0x0;
+ }
+
+ #ifdef CONFIG_PM
+ static int
+ iegbe_resume(struct pci_dev *pdev)
+ {
+- struct net_device *netdev = pci_get_drvdata(pdev);
+- struct iegbe_adapter *adapter = netdev_priv(netdev);
+- uint32_t manc, ret_val, swsm;
+- uint32_t ctrl_ext;
++ struct net_device *netdev = pci_get_drvdata(pdev);
++ struct iegbe_adapter *adapter = netdev_priv(netdev);
++ uint32_t manc, ret_val, swsm;
++ uint32_t ctrl_ext;
+ int offset;
+ uint32_t vdid;
+
+- if(gcu_resume == 0)
++ if(gcu_resume == 0x0)
+ {
+ if(gcu == NULL) {
+- gcu = pci_find_device(PCI_VENDOR_ID_INTEL, GCU_DEVID, NULL);
++ gcu = pci_get_device(PCI_VENDOR_ID_INTEL, GCU_DEVID, NULL);
+ pci_read_config_dword(gcu, 0x00, &vdid);
+- }
+-
++ }
++
+ if(gcu) {
+ gcu_iegbe_resume(gcu);
+- gcu_resume = 1;
+- gcu_suspend = 0;
++ gcu_resume = 0x1;
++ gcu_suspend = 0x0;
+ } else {
+ printk("Unable to resume GCU!\n");
+- }
++ }
+ }
+ pci_set_power_state(pdev, 0x0);
+- pci_restore_state(pdev);
+- ret_val = pci_enable_device(pdev);
+- pci_set_master(pdev);
++ pci_restore_state(pdev);
++ ret_val = pci_enable_device(pdev);
++ pci_set_master(pdev);
+
+ pci_enable_wake(pdev, 0x3, 0x0);
+ pci_enable_wake(pdev, 0x4, 0x0); /* 4 == D3 cold */
+
+- iegbe_reset(adapter);
+- E1000_WRITE_REG(&adapter->hw, WUS, ~0);
++ iegbe_reset(adapter);
++ E1000_WRITE_REG(&adapter->hw, WUS, ~0);
+ offset = pci_find_capability(adapter->pdev, PCI_CAP_ID_ST)
+ + PCI_ST_SMIA_OFFSET;
+ pci_write_config_dword(adapter->pdev, offset, 0x00000006);
+@@ -5138,51 +4848,52 @@ iegbe_resume(struct pci_dev *pdev)
+ E1000_WRITE_REG(&adapter->hw, IMC2, ~0UL);
+
+ if(netif_running(netdev)) {
+- iegbe_up(adapter);
++ iegbe_up(adapter);
+ }
+- netif_device_attach(netdev);
+-
+- if(adapter->hw.mac_type >= iegbe_82540
+- && adapter->hw.mac_type != iegbe_icp_xxxx
+- && adapter->hw.media_type == iegbe_media_type_copper) {
+- manc = E1000_READ_REG(&adapter->hw, MANC);
+- manc &= ~(E1000_MANC_ARP_EN);
+- E1000_WRITE_REG(&adapter->hw, MANC, manc);
+- }
++ netif_device_attach(netdev);
+
+- switch(adapter->hw.mac_type) {
+- case iegbe_82571:
+- case iegbe_82572:
+- ctrl_ext = E1000_READ_REG(&adapter->hw, CTRL_EXT);
+- E1000_WRITE_REG(&adapter->hw, CTRL_EXT,
+- ctrl_ext | E1000_CTRL_EXT_DRV_LOAD);
+- break;
+- case iegbe_82573:
+- swsm = E1000_READ_REG(&adapter->hw, SWSM);
+- E1000_WRITE_REG(&adapter->hw, SWSM,
+- swsm | E1000_SWSM_DRV_LOAD);
+- break;
+- default:
+- break;
+- }
++ if(adapter->hw.mac_type >= iegbe_82540
++ && adapter->hw.mac_type != iegbe_icp_xxxx
++ && adapter->hw.media_type == iegbe_media_type_copper) {
++ manc = E1000_READ_REG(&adapter->hw, MANC);
++ manc &= ~(E1000_MANC_ARP_EN);
++ E1000_WRITE_REG(&adapter->hw, MANC, manc);
++ }
++
++ switch(adapter->hw.mac_type) {
++ case iegbe_82571:
++ case iegbe_82572:
++ ctrl_ext = E1000_READ_REG(&adapter->hw, CTRL_EXT);
++ E1000_WRITE_REG(&adapter->hw, CTRL_EXT,
++ ctrl_ext | E1000_CTRL_EXT_DRV_LOAD);
++ break;
++ case iegbe_82573:
++ swsm = E1000_READ_REG(&adapter->hw, SWSM);
++ E1000_WRITE_REG(&adapter->hw, SWSM,
++ swsm | E1000_SWSM_DRV_LOAD);
++ break;
++ default:
++ break;
++ }
++#endif
+
+- return 0;
++ return 0x0;
+ }
+-#endif
++
+ #ifdef CONFIG_NET_POLL_CONTROLLER
+ /*
+ * Polling 'interrupt' - used by things like netconsole to send skbs
+ * without having to re-enable interrupts. It's not called while
+ * the interrupt routine is executing.
+ */
+-static void
+-iegbe_netpoll(struct net_device *netdev)
++static void iegbe_netpoll(struct net_device *netdev)
+ {
+- struct iegbe_adapter *adapter = netdev_priv(netdev);
+- disable_irq(adapter->pdev->irq);
+- iegbe_intr(adapter->pdev->irq, netdev, NULL);
+- enable_irq(adapter->pdev->irq);
++ struct iegbe_adapter *adapter = netdev_priv(netdev);
++ disable_irq(adapter->pdev->irq);
++ iegbe_intr(adapter->pdev->irq, netdev);
++ enable_irq(adapter->pdev->irq);
+ }
+ #endif
+
++
+ /* iegbe_main.c */
+--- a/Embedded/src/GbE/iegbe_oem_phy.c
++++ b/Embedded/src/GbE/iegbe_oem_phy.c
+@@ -2,31 +2,31 @@
+
+ GPL LICENSE SUMMARY
+
+- Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
++ Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
+
+- This program is free software; you can redistribute it and/or modify
++ This program is free software; you can redistribute it and/or modify
+ it under the terms of version 2 of the GNU General Public License as
+ published by the Free Software Foundation.
+
+- 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
++ 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; if not, write to the Free Software
++ 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., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+- The full GNU General Public License is included in this distribution
++ The full GNU General Public License is included in this distribution
+ in the file called LICENSE.GPL.
+
+ Contact Information:
+ Intel Corporation
+
+- version: Embedded.L.1.0.34
++ version: Embedded.Release.Patch.L.1.0.7-5
+
+ Contact Information:
+
+- Intel Corporation, 5000 W Chandler Blvd, Chandler, AZ 85226
++ Intel Corporation, 5000 W Chandler Blvd, Chandler, AZ 85226
+
+ *****************************************************************************/
+ /**************************************************************************
+@@ -65,11 +65,6 @@ static int32_t iegbe_oem_link_m88_setup(
+ static int32_t iegbe_oem_set_phy_mode(struct iegbe_hw *hw);
+ static int32_t iegbe_oem_detect_phy(struct iegbe_hw *hw);
+
+-/* Define specific BCM functions */
+-static int32_t iegbe_oem_link_bcm5481_setup(struct iegbe_hw *hw);
+-static int32_t bcm5481_read_18sv (struct iegbe_hw *hw, int sv, uint16_t *data);
+-static int32_t oi_phy_setup (struct iegbe_hw *hw);
+-
+ /**
+ * iegbe_oem_setup_link
+ * @hw: iegbe_hw struct containing device specific information
+@@ -84,7 +79,7 @@ iegbe_oem_setup_link(struct iegbe_hw *hw
+ {
+ #ifdef EXTERNAL_MDIO
+
+- /*
++ /*
+ * see iegbe_setup_copper_link() as the primary example. Look at both
+ * the M88 and IGP functions that are called for ideas, possibly for
+ * power management.
+@@ -102,14 +97,14 @@ iegbe_oem_setup_link(struct iegbe_hw *hw
+ }
+ /* AFU: add test to exit out if improper phy type
+ */
+- /* relevent parts of iegbe_copper_link_preconfig */
+- ctrl = E1000_READ_REG(hw, CTRL);
+- ctrl |= E1000_CTRL_SLU;
+- ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
+- E1000_WRITE_REG(hw, CTRL, ctrl);
+-
++ /* relevent parts of iegbe_copper_link_preconfig */
++ ctrl = E1000_READ_REG(hw, CTRL);
++ ctrl |= E1000_CTRL_SLU;
++ ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
++ E1000_WRITE_REG(hw, CTRL, ctrl);
++
+ /* this is required for *hw init */
+- ret_val = iegbe_oem_detect_phy(hw);
++ ret_val = iegbe_oem_detect_phy(hw);
+ if(ret_val) {
+ return ret_val;
+ }
+@@ -119,23 +114,13 @@ iegbe_oem_setup_link(struct iegbe_hw *hw
+ }
+
+ switch (hw->phy_id) {
+- case BCM5395S_PHY_ID:
+- return E1000_SUCCESS;
+- break;
+-
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+ ret_val = iegbe_oem_link_m88_setup(hw);
+- if(ret_val) {
+- return ret_val;
+- }
+- break;
+- case BCM5481_PHY_ID:
+- ret_val = iegbe_oem_link_bcm5481_setup(hw);
+- if(ret_val) {
+- return ret_val;
++ if(ret_val) {
++ return ret_val;
+ }
+- break;
++ break;
+ default:
+ DEBUGOUT("Invalid PHY ID\n");
+ return -E1000_ERR_PHY_TYPE;
+@@ -143,16 +128,16 @@ iegbe_oem_setup_link(struct iegbe_hw *hw
+
+ if(hw->autoneg) {
+ ret_val = iegbe_copper_link_autoneg(hw);
+- if(ret_val) {
+- return ret_val;
+- }
++ if(ret_val) {
++ return ret_val;
+ }
++ }
+ else {
+ DEBUGOUT("Forcing speed and duplex\n");
+ ret_val = iegbe_phy_force_speed_duplex(hw);
+ }
+-
+- /*
++
++ /*
+ * Check link status. Wait up to 100 microseconds for link to become
+ * valid.
+ */
+@@ -194,51 +179,6 @@ iegbe_oem_setup_link(struct iegbe_hw *hw
+ #endif /* ifdef EXTERNAL_MDIO */
+ }
+
+-/**
+- * iegbe_oem_link_bcm5481_setup
+- * @hw: iegbe_hw struct containing device specific information
+- *
+- * Returns E1000_SUCCESS, negative E1000 error code on failure
+- *
+- * copied verbatim from iegbe_oem_link_m88_setup
+- **/
+-static int32_t
+-iegbe_oem_link_bcm5481_setup(struct iegbe_hw *hw)
+-{
+- int32_t ret_val;
+- uint16_t phy_data;
+-
+- //DEBUGFUNC(__func__);
+-
+- if(!hw)
+- return -1;
+-
+- /* phy_reset_disable is set in iegbe_oem_set_phy_mode */
+- if(hw->phy_reset_disable)
+- return E1000_SUCCESS;
+-
+- // Enable MDIX in extended control reg.
+- ret_val = iegbe_oem_read_phy_reg_ex(hw, BCM5481_ECTRL, &phy_data);
+- if(ret_val)
+- {
+- DEBUGOUT("Unable to read BCM5481_ECTRL register\n");
+- return ret_val;
+- }
+-
+- phy_data &= ~BCM5481_ECTRL_DISMDIX;
+- ret_val = iegbe_oem_write_phy_reg_ex(hw, BCM5481_ECTRL, phy_data);
+- if(ret_val)
+- {
+- DEBUGOUT("Unable to write BCM5481_ECTRL register\n");
+- return ret_val;
+- }
+-
+- ret_val = oi_phy_setup (hw);
+- if (ret_val)
+- return ret_val;
+-
+- return E1000_SUCCESS;
+-}
+
+ /**
+ * iegbe_oem_link_m88_setup
+@@ -253,7 +193,7 @@ static int32_t
+ iegbe_oem_link_m88_setup(struct iegbe_hw *hw)
+ {
+ int32_t ret_val;
+- uint16_t phy_data;
++ uint16_t phy_data = 0;
+
+ DEBUGFUNC1("%s",__func__);
+
+@@ -261,7 +201,7 @@ iegbe_oem_link_m88_setup(struct iegbe_hw
+ return -1;
+ }
+
+- ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_CTRL,
++ ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_CTRL,
+ &phy_data);
+ phy_data |= 0x00000008;
+ ret_val = iegbe_oem_write_phy_reg_ex(hw, M88E1000_PHY_SPEC_CTRL, phy_data);
+@@ -279,7 +219,7 @@ iegbe_oem_link_m88_setup(struct iegbe_hw
+
+ phy_data &= ~M88E1000_PSCR_ASSERT_CRS_ON_TX;
+
+- /*
++ /*
+ * Options:
+ * MDI/MDI-X = 0 (default)
+ * 0 - Auto for all speeds
+@@ -305,7 +245,7 @@ iegbe_oem_link_m88_setup(struct iegbe_hw
+ break;
+ }
+
+- /*
++ /*
+ * Options:
+ * disable_polarity_correction = 0 (default)
+ * Automatic Correction for Reversed Cable Polarity
+@@ -316,25 +256,25 @@ iegbe_oem_link_m88_setup(struct iegbe_hw
+
+ if(hw->disable_polarity_correction == 1) {
+ phy_data |= M88E1000_PSCR_POLARITY_REVERSAL;
+- }
++ }
+ ret_val = iegbe_oem_write_phy_reg_ex(hw, M88E1000_PHY_SPEC_CTRL, phy_data);
+ if(ret_val) {
+ DEBUGOUT("Unable to write M88E1000_PHY_SPEC_CTRL register\n");
+ return ret_val;
+ }
+
+- /*
++ /*
+ * Force TX_CLK in the Extended PHY Specific Control Register
+ * to 25MHz clock.
+ */
+- ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_EXT_PHY_SPEC_CTRL,
++ ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_EXT_PHY_SPEC_CTRL,
+ &phy_data);
+ if(ret_val) {
+ DEBUGOUT("Unable to read M88E1000_EXT_PHY_SPEC_CTRL register\n");
+ return ret_val;
+ }
+
+- /*
++ /*
+ * For Truxton, it is necessary to add RGMII tx and rx
+ * timing delay though the EXT_PHY_SPEC_CTRL register
+ */
+@@ -350,13 +290,13 @@ iegbe_oem_link_m88_setup(struct iegbe_hw
+ phy_data |= (M88E1000_EPSCR_MASTER_DOWNSHIFT_1X |
+ M88E1000_EPSCR_SLAVE_DOWNSHIFT_1X);
+ }
+- ret_val = iegbe_oem_write_phy_reg_ex(hw, M88E1000_EXT_PHY_SPEC_CTRL,
++ ret_val = iegbe_oem_write_phy_reg_ex(hw, M88E1000_EXT_PHY_SPEC_CTRL,
+ phy_data);
+ if(ret_val) {
+ DEBUGOUT("Unable to read M88E1000_EXT_PHY_SPEC_CTRL register\n");
+ return ret_val;
+ }
+-
++
+
+ /* SW Reset the PHY so all changes take effect */
+ ret_val = iegbe_phy_hw_reset(hw);
+@@ -371,7 +311,7 @@ iegbe_oem_link_m88_setup(struct iegbe_hw
+ /**
+ * iegbe_oem_force_mdi
+ * @hw: iegbe_hw struct containing device specific information
+- * @resetPhy: returns true if after calling this function the
++ * @resetPhy: returns true if after calling this function the
+ * PHY requires a reset
+ *
+ * Returns E1000_SUCCESS, negative E1000 error code on failure
+@@ -379,7 +319,7 @@ iegbe_oem_link_m88_setup(struct iegbe_hw
+ * This is called from iegbe_phy_force_speed_duplex, which is
+ * called from iegbe_oem_setup_link.
+ **/
+-int32_t
++int32_t
+ iegbe_oem_force_mdi(struct iegbe_hw *hw, int *resetPhy)
+ {
+ #ifdef EXTERNAL_MDIO
+@@ -393,35 +333,30 @@ iegbe_oem_force_mdi(struct iegbe_hw *hw,
+ return -1;
+ }
+
+- /*
++ /*
+ * a boolean to indicate if the phy needs to be reset
+- *
++ *
+ * Make note that the M88 phy is what'll be used on Truxton
+ * see iegbe_phy_force_speed_duplex, which does the following for M88
+ */
+ switch (hw->phy_id) {
+- case BCM5395S_PHY_ID:
+- case BCM5481_PHY_ID:
+- DEBUGOUT("WARNING: An empty iegbe_oem_force_mdi() has been called!\n");
+- break;
+-
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+- ret_val = iegbe_oem_read_phy_reg_ex(hw,
+- M88E1000_PHY_SPEC_CTRL,
++ ret_val = iegbe_oem_read_phy_reg_ex(hw,
++ M88E1000_PHY_SPEC_CTRL,
+ &phy_data);
+ if(ret_val) {
+ DEBUGOUT("Unable to read M88E1000_PHY_SPEC_CTRL register\n");
+ return ret_val;
+ }
+-
++
+ /*
+- * Clear Auto-Crossover to force MDI manually. M88E1000 requires
++ * Clear Auto-Crossover to force MDI manually. M88E1000 requires
+ * MDI forced whenever speed are duplex are forced.
+ */
+-
++
+ phy_data &= ~M88E1000_PSCR_AUTO_X_MODE;
+- ret_val = iegbe_oem_write_phy_reg_ex(hw, M88E1000_PHY_SPEC_CTRL,
++ ret_val = iegbe_oem_write_phy_reg_ex(hw, M88E1000_PHY_SPEC_CTRL,
+ phy_data);
+ if(ret_val) {
+ DEBUGOUT("Unable to write M88E1000_PHY_SPEC_CTRL register\n");
+@@ -458,7 +393,7 @@ iegbe_oem_force_mdi(struct iegbe_hw *hw,
+ * This is called from iegbe_phy_force_speed_duplex, which is
+ * called from iegbe_oem_setup_link.
+ **/
+-int32_t
++int32_t
+ iegbe_oem_phy_reset_dsp(struct iegbe_hw *hw)
+ {
+ #ifdef EXTERNAL_MDIO
+@@ -478,10 +413,8 @@ iegbe_oem_phy_reset_dsp(struct iegbe_hw
+ * no-op.
+ */
+ switch (hw->phy_id) {
+- case M88E1000_I_PHY_ID:
+- case M88E1141_E_PHY_ID:
+- case BCM5481_PHY_ID:
+- case BCM5395S_PHY_ID:
++ case M88E1000_I_PHY_ID:
++ case M88E1141_E_PHY_ID:
+ DEBUGOUT("No DSP to reset on OEM PHY\n");
+ break;
+ default:
+@@ -508,7 +441,7 @@ iegbe_oem_phy_reset_dsp(struct iegbe_hw
+ * This is called from iegbe_phy_force_speed_duplex, which is
+ * called from iegbe_oem_setup_link.
+ **/
+-int32_t
++int32_t
+ iegbe_oem_cleanup_after_phy_reset(struct iegbe_hw *hw)
+ {
+ #ifdef EXTERNAL_MDIO
+@@ -520,29 +453,24 @@ iegbe_oem_cleanup_after_phy_reset(struct
+
+ if(!hw) {
+ return -1;
+- }
++ }
+
+- /*
++ /*
+ * Make note that the M88 phy is what'll be used on Truxton.
+ * see iegbe_phy_force_speed_duplex, which does the following for M88
+ */
+ switch (hw->phy_id) {
+- case BCM5395S_PHY_ID:
+- case BCM5481_PHY_ID:
+- DEBUGOUT("WARNING: An empty iegbe_oem_cleanup_after_phy_reset() has been called!\n");
+- break;
+-
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+ /*
+- * Because we reset the PHY above, we need to re-force
++ * Because we reset the PHY above, we need to re-force
+ * TX_CLK in the Extended PHY Specific Control Register to
+ * 25MHz clock. This value defaults back to a 2.5MHz clock
+ * when the PHY is reset.
+ */
+
+ ret_val = iegbe_oem_read_phy_reg_ex(hw,
+- M88E1000_EXT_PHY_SPEC_CTRL,
++ M88E1000_EXT_PHY_SPEC_CTRL,
+ &phy_data);
+ if(ret_val) {
+ DEBUGOUT("Unable to read M88E1000_EXT_SPEC_CTRL register\n");
+@@ -550,22 +478,23 @@ iegbe_oem_cleanup_after_phy_reset(struct
+ }
+
+ phy_data |= M88E1000_EPSCR_TX_CLK_25;
+- ret_val = iegbe_oem_write_phy_reg_ex(hw,
+- M88E1000_EXT_PHY_SPEC_CTRL,
++ ret_val = iegbe_oem_write_phy_reg_ex(hw,
++ M88E1000_EXT_PHY_SPEC_CTRL,
+ phy_data);
+ if(ret_val) {
+- DEBUGOUT("Unable to write M88E1000_EXT_PHY_SPEC_CTRL register\n");
++ DEBUGOUT("Unable to write M88E1000_EXT_PHY_SPEC_CTRL "
++ "register\n");
+ return ret_val;
+ }
+
+ /*
+ * In addition, because of the s/w reset above, we need to enable
+- * CRX on TX. This must be set for both full and half duplex
++ * CRX on TX. This must be set for both full and half duplex
+ * operation.
+ */
+
+- ret_val = iegbe_oem_read_phy_reg_ex(hw,
+- M88E1000_PHY_SPEC_CTRL,
++ ret_val = iegbe_oem_read_phy_reg_ex(hw,
++ M88E1000_PHY_SPEC_CTRL,
+ &phy_data);
+ if(ret_val) {
+ DEBUGOUT("Unable to read M88E1000_PHY_SPEC_CTRL register\n");
+@@ -573,12 +502,12 @@ iegbe_oem_cleanup_after_phy_reset(struct
+ }
+
+ phy_data &= ~M88E1000_PSCR_ASSERT_CRS_ON_TX;
+- ret_val = iegbe_oem_write_phy_reg_ex(hw, M88E1000_PHY_SPEC_CTRL,
++ ret_val = iegbe_oem_write_phy_reg_ex(hw, M88E1000_PHY_SPEC_CTRL,
+ phy_data);
+ if(ret_val) {
+ DEBUGOUT("Unable to write M88E1000_PHY_SPEC_CTRL register\n");
+ return ret_val;
+- }
++ }
+ break;
+ default:
+ DEBUGOUT("Invalid PHY ID\n");
+@@ -604,12 +533,12 @@ iegbe_oem_cleanup_after_phy_reset(struct
+ * This is called from iegbe_oem_setup_link which is
+ * called from iegbe_setup_link.
+ **/
+-static int32_t
++static int32_t
+ iegbe_oem_set_phy_mode(struct iegbe_hw *hw)
+ {
+ /*
+ * it is unclear if it is necessary to set the phy mode. Right now only
+- * one MAC 82545 Rev 3 does it, but the other MACs like Tolapai do not.
++ * one MAC 82545 Rev 3 does it, but the other MACs like tola do not.
+ * Leave the functionality off for now until it is determined that Tolapai
+ * needs it as well.
+ */
+@@ -638,41 +567,37 @@ iegbe_oem_set_phy_mode(struct iegbe_hw *
+ #ifndef skip_set_mode
+ DEBUGOUT("No need to call oem_set_phy_mode on Truxton\n");
+ #else
+- /*
++ /*
+ * Make note that the M88 phy is what'll be used on Truxton.
+ *
+ * use iegbe_set_phy_mode as example
+ */
+ switch (hw->phy_id) {
+- case BCM5395S_PHY_ID:
+- case BCM5481_PHY_ID:
+- DEBUGOUT("WARNING: An empty iegbe_oem_set_phy_mode() has been called!\n");
+- break;
+-
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+- ret_val = iegbe_read_eeprom(hw,
+- EEPROM_PHY_CLASS_WORD,
+- 1,
++ ret_val = iegbe_read_eeprom(hw,
++ EEPROM_PHY_CLASS_WORD,
++ 1,
+ &eeprom_data);
+ if(ret_val) {
+ return ret_val;
+ }
+
+- if((eeprom_data != EEPROM_RESERVED_WORD) &&
+- (eeprom_data & EEPROM_PHY_CLASS_A))
++ if((eeprom_data != EEPROM_RESERVED_WORD) &&
++ (eeprom_data & EEPROM_PHY_CLASS_A))
+ {
+- ret_val = iegbe_oem_write_phy_reg_ex(hw,
+- M88E1000_PHY_PAGE_SELECT,
+- 0x000B);
++ ret_val = iegbe_oem_write_phy_reg_ex(hw,
++ M88E1000_PHY_PAGE_SELECT,
++ 0x000B);
+ if(ret_val) {
+- DEBUGOUT("Unable to write to M88E1000_PHY_PAGE_SELECT register on PHY\n");
++ DEBUGOUT("Unable to write to M88E1000_PHY_PAGE_SELECT "
++ "register on PHY\n");
+ return ret_val;
+ }
+
+- ret_val = iegbe_oem_write_phy_reg_ex(hw,
+- M88E1000_PHY_GEN_CONTROL,
+- 0x8104);
++ ret_val = iegbe_oem_write_phy_reg_ex(hw,
++ M88E1000_PHY_GEN_CONTROL,
++ 0x8104);
+ if(ret_val) {
+ DEBUGOUT("Unable to write to M88E1000_PHY_GEN_CONTROL"
+ "register on PHY\n");
+@@ -687,11 +612,12 @@ iegbe_oem_set_phy_mode(struct iegbe_hw *
+ return -E1000_ERR_PHY_TYPE;
+ }
+ #endif
+-
++
+ return E1000_SUCCESS;
+
+ }
+
++
+ /**
+ * iegbe_oem_detect_phy
+ * @hw: iegbe_hw struct containing device specific information
+@@ -702,7 +628,7 @@ iegbe_oem_set_phy_mode(struct iegbe_hw *
+ *
+ * This borrows heavily from iegbe_detect_gig_phy
+ **/
+-static int32_t
++static int32_t
+ iegbe_oem_detect_phy(struct iegbe_hw *hw)
+ {
+ int32_t ret_val;
+@@ -715,33 +641,20 @@ iegbe_oem_detect_phy(struct iegbe_hw *hw
+ }
+ hw->phy_type = iegbe_phy_oem;
+
+-{
+- // If MAC2 (BCM5395 switch), manually detect the phy
+- struct iegbe_adapter *adapter;
+- uint32_t device_number;
+- adapter = (struct iegbe_adapter *) hw->back;
+- device_number = PCI_SLOT(adapter->pdev->devfn);
+- if (device_number == ICP_XXXX_MAC_2) {
+- hw->phy_id = BCM5395S_PHY_ID;
+- hw->phy_revision = 0;
+- return E1000_SUCCESS;
+- }
+-}
+-
+-
+ ret_val = iegbe_oem_read_phy_reg_ex(hw, PHY_ID1, &phy_id_high);
+ if(ret_val) {
+ DEBUGOUT("Unable to read PHY register PHY_ID1\n");
+ return ret_val;
+ }
+-
++
+ usec_delay(0x14);
+ ret_val = iegbe_oem_read_phy_reg_ex(hw, PHY_ID2, &phy_id_low);
+ if(ret_val) {
+ DEBUGOUT("Unable to read PHY register PHY_ID2\n");
+ return ret_val;
+ }
+- hw->phy_id = (uint32_t) ((phy_id_high << 0x10) + phy_id_low);
++ hw->phy_id = (uint32_t) ((phy_id_high << 0x10) +
++ (phy_id_low & PHY_REVISION_MASK));
+ hw->phy_revision = (uint32_t) phy_id_low & ~PHY_REVISION_MASK;
+
+ return E1000_SUCCESS;
+@@ -753,15 +666,15 @@ iegbe_oem_detect_phy(struct iegbe_hw *hw
+ * @hw: iegbe_hw struct containing device specific information
+ *
+ * Returns the value of the Inter Packet Gap (IPG) Transmit Time (IPGT) in the
+- * Transmit IPG register appropriate for the given PHY. This field is only 10
++ * Transmit IPG register appropriate for the given PHY. This field is only 10
+ * bits wide.
+ *
+ * In the original iegbe code, only the IPGT field varied between media types.
+- * If the OEM phy requires setting IPG Receive Time 1 & 2 Registers, it would
++ * If the OEM phy requires setting IPG Receive Time 1 & 2 Registers, it would
+ * be required to modify the iegbe_config_tx() function to accomdate the change
+ *
+ **/
+-uint32_t
++uint32_t
+ iegbe_oem_get_tipg(struct iegbe_hw *hw)
+ {
+ #ifdef EXTERNAL_MDIO
+@@ -777,15 +690,13 @@ iegbe_oem_get_tipg(struct iegbe_hw *hw)
+ switch (hw->phy_id) {
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+- case BCM5481_PHY_ID:
+- case BCM5395S_PHY_ID:
+ phy_num = DEFAULT_ICP_XXXX_TIPG_IPGT;
+ break;
+ default:
+ DEBUGOUT("Invalid PHY ID\n");
+ return DEFAULT_ICP_XXXX_TIPG_IPGT;
+ }
+-
++
+ return phy_num;
+
+ #else /* ifdef EXTERNAL_MDIO */
+@@ -803,15 +714,15 @@ iegbe_oem_get_tipg(struct iegbe_hw *hw)
+ * iegbe_oem_phy_is_copper
+ * @hw: iegbe_hw struct containing device specific information
+ *
+- * Test for media type within the iegbe driver is common, so this is a simple
+- * test for copper PHYs. The ICP_XXXX family of controllers initially only
+- * supported copper interconnects (no TBI (ten bit interface) for Fiber
+- * existed). If future revs support either Fiber or an internal SERDES, it
+- * may become necessary to evaluate where this function is used to go beyond
++ * Test for media type within the iegbe driver is common, so this is a simple
++ * test for copper PHYs. The ICP_XXXX family of controllers initially only
++ * supported copper interconnects (no TBI (ten bit interface) for Fiber
++ * existed). If future revs support either Fiber or an internal SERDES, it
++ * may become necessary to evaluate where this function is used to go beyond
+ * determining whether or not media type is just copper.
+ *
+ **/
+-int
++int
+ iegbe_oem_phy_is_copper(struct iegbe_hw *hw)
+ {
+ #ifdef EXTERNAL_MDIO
+@@ -827,23 +738,21 @@ iegbe_oem_phy_is_copper(struct iegbe_hw
+ switch (hw->phy_id) {
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+- case BCM5481_PHY_ID:
+- case BCM5395S_PHY_ID:
+ isCopper = TRUE;
+ break;
+ default:
+ DEBUGOUT("Invalid PHY ID\n");
+ return -E1000_ERR_PHY_TYPE;
+ }
+-
++
+ return isCopper;
+
+ #else /* ifdef EXTERNAL_MDIO */
+
+- /*
++ /*
+ * caught between returning true or false. True allows it to
+ * be entered into && statements w/o ill effect, but false
+- * would make more sense
++ * would make more sense
+ */
+ DEBUGOUT("Invalid value for transceiver type, return FALSE\n");
+ return FALSE;
+@@ -856,19 +765,19 @@ iegbe_oem_phy_is_copper(struct iegbe_hw
+ * iegbe_oem_get_phy_dev_number
+ * @hw: iegbe_hw struct containing device specific information
+ *
+- * For ICP_XXXX family of devices, there are 3 MACs, each of which may
+- * have a different PHY (and indeed a different media interface). This
+- * function is used to indicate which of the MAC/PHY pairs we are interested
++ * For ICP_XXXX family of devices, there are 3 MACs, each of which may
++ * have a different PHY (and indeed a different media interface). This
++ * function is used to indicate which of the MAC/PHY pairs we are interested
+ * in.
+- *
++ *
+ **/
+-uint32_t
++uint32_t
+ iegbe_oem_get_phy_dev_number(struct iegbe_hw *hw)
+ {
+ #ifdef EXTERNAL_MDIO
+
+- /*
+- * for ICP_XXXX family of devices, the three network interfaces are
++ /*
++ * for ICP_XXXX family of devices, the three network interfaces are
+ * differentiated by their PCI device number, where the three share
+ * the same PCI bus
+ */
+@@ -886,15 +795,15 @@ iegbe_oem_get_phy_dev_number(struct iegb
+
+ switch(device_number)
+ {
+- case ICP_XXXX_MAC_0:
++ case ICP_XXXX_MAC_0:
++ hw->phy_addr = 0x00;
++ break;
++ case ICP_XXXX_MAC_1:
+ hw->phy_addr = 0x01;
+ break;
+- case ICP_XXXX_MAC_1:
++ case ICP_XXXX_MAC_2:
+ hw->phy_addr = 0x02;
+ break;
+- case ICP_XXXX_MAC_2:
+- hw->phy_addr = 0x00;
+- break;
+ default: hw->phy_addr = 0x00;
+ }
+ return hw->phy_addr;
+@@ -915,7 +824,7 @@ iegbe_oem_get_phy_dev_number(struct iegb
+ * @cmd: the original IOCTL command that instigated the call chain.
+ *
+ * This function abstracts out the code necessary to service the
+- * SIOCSMIIREG case within the iegbe_mii_ioctl() for oem PHYs.
++ * SIOCSMIIREG case within the iegbe_mii_ioctl() for oem PHYs.
+ * iegbe_mii_ioctl() was implemented for copper phy's only and this
+ * function will only be called if iegbe_oem_phy_is_copper() returns true for
+ * a given MAC. Note that iegbe_mii_ioctl() has a compile flag
+@@ -924,14 +833,14 @@ iegbe_oem_get_phy_dev_number(struct iegb
+ * NOTE: a spinlock is in effect for the duration of this call. It is
+ * imperative that a negative value be returned on any error, so
+ * the spinlock can be released properly.
+- *
++ *
+ **/
+ int
+ iegbe_oem_mii_ioctl(struct iegbe_adapter *adapter, unsigned long flags,
+ struct ifreq *ifr, int cmd)
+ {
+ #ifdef EXTERNAL_MDIO
+-
++
+ struct mii_ioctl_data *data = if_mii(ifr);
+ uint16_t mii_reg = data->val_in;
+ uint16_t spddplx;
+@@ -942,12 +851,6 @@ iegbe_oem_mii_ioctl(struct iegbe_adapter
+ if(!adapter || !ifr) {
+ return -1;
+ }
+-
+- // If MAC2 (BCM5395 switch) then leave now
+- if ((PCI_SLOT(adapter->pdev->devfn)) == ICP_XXXX_MAC_2) {
+- return -1;
+- }
+-
+ switch (data->reg_num) {
+ case PHY_CTRL:
+ if(mii_reg & MII_CR_POWER_DOWN) {
+@@ -956,7 +859,7 @@ iegbe_oem_mii_ioctl(struct iegbe_adapter
+ if(mii_reg & MII_CR_AUTO_NEG_EN) {
+ adapter->hw.autoneg = 1;
+ adapter->hw.autoneg_advertised = ICP_XXXX_AUTONEG_ADV_DEFAULT;
+- }
++ }
+ else {
+ if(mii_reg & 0x40) {
+ spddplx = SPEED_1000;
+@@ -976,7 +879,7 @@ iegbe_oem_mii_ioctl(struct iegbe_adapter
+ if(netif_running(adapter->netdev)) {
+ iegbe_down(adapter);
+ iegbe_up(adapter);
+- }
++ }
+ else {
+ iegbe_reset(adapter);
+ }
+@@ -1043,10 +946,10 @@ void iegbe_oem_fiber_live_in_suspend(str
+ * Note: The call to iegbe_get_regs() assumed an array of 24 elements
+ * where the last 11 are passed to this function. If the array
+ * that is passed to the calling function has its size or element
+- * defintions changed, this function becomes broken.
++ * defintions changed, this function becomes broken.
+ *
+ **/
+-void iegbe_oem_get_phy_regs(struct iegbe_adapter *adapter, uint32_t *data,
++void iegbe_oem_get_phy_regs(struct iegbe_adapter *adapter, uint32_t *data,
+ uint32_t data_len)
+ {
+ #define EXPECTED_ARRAY_LEN 11
+@@ -1062,13 +965,13 @@ void iegbe_oem_get_phy_regs(struct iegbe
+ * Use the corrected_length variable to make sure we don't exceed that
+ * length
+ */
+- corrected_len = data_len>EXPECTED_ARRAY_LEN
++ corrected_len = data_len>EXPECTED_ARRAY_LEN
+ ? EXPECTED_ARRAY_LEN : data_len;
+ memset(data, 0, corrected_len*sizeof(uint32_t));
+
+ #ifdef EXTERNAL_MDIO
+
+- /*
++ /*
+ * Fill data[] with...
+ *
+ * [0] = cable length
+@@ -1084,16 +987,11 @@ void iegbe_oem_get_phy_regs(struct iegbe
+ * [10] = mdix mode
+ */
+ switch (adapter->hw.phy_id) {
+- case BCM5395S_PHY_ID:
+- case BCM5481_PHY_ID:
+- DEBUGOUT("WARNING: An empty iegbe_oem_get_phy_regs() has been called!\n");
+- break;
+-
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+ if(corrected_len > 0) {
+- iegbe_oem_read_phy_reg_ex(&adapter->hw,
+- M88E1000_PHY_SPEC_STATUS,
++ iegbe_oem_read_phy_reg_ex(&adapter->hw,
++ M88E1000_PHY_SPEC_STATUS,
+ (uint16_t *) &data[0]);
+ }
+ if(corrected_len > 0x1){
+@@ -1106,7 +1004,7 @@ void iegbe_oem_get_phy_regs(struct iegbe
+ data[0x3] = 0x0; /* Dummy (to align w/ IGP phy reg dump) */
+ }
+ if(corrected_len > 0x4) {
+- iegbe_oem_read_phy_reg_ex(&adapter->hw, M88E1000_PHY_SPEC_CTRL,
++ iegbe_oem_read_phy_reg_ex(&adapter->hw, M88E1000_PHY_SPEC_CTRL,
+ (uint16_t *) &data[0x4]);
+ }
+ if(corrected_len > 0x5) {
+@@ -1144,7 +1042,7 @@ void iegbe_oem_get_phy_regs(struct iegbe
+ * This is called from iegbe_set_phy_loopback in response from call from
+ * ethtool to place the PHY into loopback mode.
+ **/
+-int
++int
+ iegbe_oem_phy_loopback(struct iegbe_adapter *adapter)
+ {
+ #ifdef EXTERNAL_MDIO
+@@ -1165,23 +1063,18 @@ iegbe_oem_phy_loopback(struct iegbe_adap
+ * was that nonintegrated called iegbe_phy_reset_clk_and_crs(),
+ * hopefully this won't matter as CRS required for half-duplex
+ * operation and this is set to full duplex.
+- *
++ *
+ * Make note that the M88 phy is what'll be used on Truxton
+ * Loopback configuration is the same for each of the supported PHYs.
+ */
+ switch (adapter->hw.phy_id) {
+- case BCM5395S_PHY_ID:
+- DEBUGOUT("WARNING: An empty iegbe_oem_phy_loopback() has been called!\n");
+- break;
+-
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+- case BCM5481_PHY_ID:
+
+ adapter->hw.autoneg = FALSE;
+
+ /* turn off Auto-MDI/MDIX */
+- /*ret_val = iegbe_oem_write_phy_reg_ex(&adapter->hw,
++ /*ret_val = iegbe_oem_write_phy_reg_ex(&adapter->hw,
+ M88E1000_PHY_SPEC_CTRL, 0x0808);
+ if(ret_val)
+ {
+@@ -1206,10 +1099,10 @@ iegbe_oem_phy_loopback(struct iegbe_adap
+ DEBUGOUT("Unable to write to register PHY_CTRL\n");
+ return ret_val;
+ }
+-
+-
++
++
+ /* force 1000, set loopback */
+- /*ret_val =
++ /*ret_val =
+ iegbe_oem_write_phy_reg_ex(&adapter->hw, PHY_CTRL, 0x4140); */
+ ret_val = iegbe_oem_write_phy_reg_ex(&adapter->hw, PHY_CTRL, 0x6100);
+ if(ret_val) {
+@@ -1228,21 +1121,21 @@ iegbe_oem_phy_loopback(struct iegbe_adap
+ E1000_WRITE_REG(&adapter->hw, CTRL, ctrl_reg);
+
+ /*
+- * Write out to PHY registers 29 and 30 to disable the Receiver.
++ * Write out to PHY registers 29 and 30 to disable the Receiver.
+ * This directly lifted from iegbe_phy_disable_receiver().
+- *
++ *
+ * The code is currently commented out as for the M88 used in
+ * Truxton, registers 29 and 30 are unutilized. Leave in, just
+- * in case we are on the receiving end of an 'undocumented'
++ * in case we are on the receiving end of an 'undocumented'
+ * feature
+ */
+- /*
++ /*
+ * iegbe_oem_write_phy_reg_ex(&adapter->hw, 29, 0x001F);
+ * iegbe_oem_write_phy_reg_ex(&adapter->hw, 30, 0x8FFC);
+ * iegbe_oem_write_phy_reg_ex(&adapter->hw, 29, 0x001A);
+ * iegbe_oem_write_phy_reg_ex(&adapter->hw, 30, 0x8FF0);
+ */
+-
++
+ break;
+ default:
+ DEBUGOUT("Invalid PHY ID\n");
+@@ -1268,15 +1161,15 @@ iegbe_oem_phy_loopback(struct iegbe_adap
+ * ethtool to place the PHY out of loopback mode. This handles the OEM
+ * specific part of loopback cleanup.
+ **/
+-void
++void
+ iegbe_oem_loopback_cleanup(struct iegbe_adapter *adapter)
+ {
+ #ifdef EXTERNAL_MDIO
+
+- /*
+- * This borrows liberally from iegbe_loopback_cleanup().
++ /*
++ * This borrows liberally from iegbe_loopback_cleanup().
+ * making note that the M88 phy is what'll be used on Truxton
+- *
++ *
+ * Loopback cleanup is the same for all supported PHYs.
+ */
+ int32_t ret_val;
+@@ -1289,38 +1182,32 @@ iegbe_oem_loopback_cleanup(struct iegbe_
+ }
+
+ switch (adapter->hw.phy_id) {
+- case BCM5395S_PHY_ID:
+- DEBUGOUT("WARNING: An empty iegbe_oem_loopback_cleanup() has been called!\n");
+- return;
+- break;
+-
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+- case BCM5481_PHY_ID:
+ default:
+ adapter->hw.autoneg = TRUE;
+-
+- ret_val = iegbe_oem_read_phy_reg_ex(&adapter->hw, PHY_CTRL,
++
++ ret_val = iegbe_oem_read_phy_reg_ex(&adapter->hw, PHY_CTRL,
+ &phy_reg);
+ if(ret_val) {
+ DEBUGOUT("Unable to read to register PHY_CTRL\n");
+ return;
+ }
+-
++
+ if(phy_reg & MII_CR_LOOPBACK) {
+ phy_reg &= ~MII_CR_LOOPBACK;
+-
+- ret_val = iegbe_oem_write_phy_reg_ex(&adapter->hw, PHY_CTRL,
++
++ ret_val = iegbe_oem_write_phy_reg_ex(&adapter->hw, PHY_CTRL,
+ phy_reg);
+ if(ret_val) {
+ DEBUGOUT("Unable to write to register PHY_CTRL\n");
+ return;
+ }
+-
++
+ iegbe_phy_reset(&adapter->hw);
+ }
+ }
+-
++
+ #endif /* ifdef EXTERNAL_MDIO */
+ return;
+
+@@ -1336,7 +1223,7 @@ iegbe_oem_loopback_cleanup(struct iegbe_
+ * Called by iegbe_check_downshift(), checks the PHY to see if it running
+ * at as speed slower than its maximum.
+ **/
+-uint32_t
++uint32_t
+ iegbe_oem_phy_speed_downgraded(struct iegbe_hw *hw, uint16_t *isDowngraded)
+ {
+ #ifdef EXTERNAL_MDIO
+@@ -1356,24 +1243,19 @@ iegbe_oem_phy_speed_downgraded(struct ie
+ */
+
+ switch (hw->phy_id) {
+- case BCM5395S_PHY_ID:
+- case BCM5481_PHY_ID:
+- *isDowngraded = 0;
+- break;
+-
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+- ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_STATUS,
++ ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_STATUS,
+ &phy_data);
+ if(ret_val) {
+ DEBUGOUT("Unable to read register M88E1000_PHY_SPEC_STATUS\n");
+ return ret_val;
+ }
+-
+- *isDowngraded = (phy_data & M88E1000_PSSR_DOWNSHIFT)
++
++ *isDowngraded = (phy_data & M88E1000_PSSR_DOWNSHIFT)
+ >> M88E1000_PSSR_DOWNSHIFT_SHIFT;
+-
+- break;
++
++ break;
+ default:
+ DEBUGOUT("Invalid PHY ID\n");
+ return 1;
+@@ -1388,7 +1270,7 @@ iegbe_oem_phy_speed_downgraded(struct ie
+ }
+
+ *isDowngraded = 0;
+- return 0;
++ return 0;
+
+ #endif /* ifdef EXTERNAL_MDIO */
+ }
+@@ -1403,7 +1285,7 @@ iegbe_oem_phy_speed_downgraded(struct ie
+ * Called by iegbe_check_downshift(), checks the PHY to see if it running
+ * at as speed slower than its maximum.
+ **/
+-int32_t
++int32_t
+ iegbe_oem_check_polarity(struct iegbe_hw *hw, uint16_t *polarity)
+ {
+ #ifdef EXTERNAL_MDIO
+@@ -1417,33 +1299,27 @@ iegbe_oem_check_polarity(struct iegbe_hw
+ return -1;
+ }
+
+- /*
++ /*
+ * borrow liberally from iegbe_check_polarity.
+ * Make note that the M88 phy is what'll be used on Truxton
+ */
+
+ switch (hw->phy_id) {
+- case BCM5395S_PHY_ID:
+- case BCM5481_PHY_ID:
+- *polarity = 0;
+- break;
+-
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+ /* return the Polarity bit in the Status register. */
+- ret_val = iegbe_oem_read_phy_reg_ex(hw,
+- M88E1000_PHY_SPEC_STATUS,
++ ret_val = iegbe_oem_read_phy_reg_ex(hw,
++ M88E1000_PHY_SPEC_STATUS,
+ &phy_data);
+ if(ret_val) {
+ DEBUGOUT("Unable to read register M88E1000_PHY_SPEC_STATUS\n");
+ return ret_val;
+ }
+
+- *polarity = (phy_data & M88E1000_PSSR_REV_POLARITY)
++ *polarity = (phy_data & M88E1000_PSSR_REV_POLARITY)
+ >> M88E1000_PSSR_REV_POLARITY_SHIFT;
+-
+- break;
+-
++
++ break;
+ default:
+ DEBUGOUT("Invalid PHY ID\n");
+ return -E1000_ERR_PHY_TYPE;
+@@ -1472,7 +1348,7 @@ iegbe_oem_check_polarity(struct iegbe_hw
+ * the MAC with the PHY. It turns out on ICP_XXXX, this is not
+ * done automagically.
+ **/
+-int32_t
++int32_t
+ iegbe_oem_phy_is_full_duplex(struct iegbe_hw *hw, int *isFD)
+ {
+ #ifdef EXTERNAL_MDIO
+@@ -1485,40 +1361,22 @@ iegbe_oem_phy_is_full_duplex(struct iegb
+ if(!hw || !isFD) {
+ return -1;
+ }
+- /*
++ /*
+ * Make note that the M88 phy is what'll be used on Truxton
+ * see iegbe_config_mac_to_phy
+ */
+-
++
+ switch (hw->phy_id) {
+- case BCM5395S_PHY_ID:
+- /* Always full duplex */
+- *isFD = 1;
+- break;
+-
+- case BCM5481_PHY_ID:
+- ret_val = iegbe_read_phy_reg(hw, BCM5481_ASTAT, &phy_data);
+- if(ret_val) return ret_val;
+-
+- switch (BCM5481_ASTAT_HCD(phy_data)) {
+- case BCM5481_ASTAT_1KBTFD:
+- case BCM5481_ASTAT_100BTXFD:
+- *isFD = 1;
+- break;
+- default:
+- *isFD = 0;
+- }
+- break;
+-
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+- ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_STATUS, &phy_data);
+- if(ret_val) {
+- DEBUGOUT("Unable to read register M88E1000_PHY_SPEC_STATUS\n");
+- return ret_val;
+- }
++ ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_STATUS,
++ &phy_data);
++ if(ret_val) {
++ DEBUGOUT("Unable to read register M88E1000_PHY_SPEC_STATUS\n");
++ return ret_val;
++ }
+ *isFD = (phy_data & M88E1000_PSSR_DPLX) != 0;
+-
++
+ break;
+ default:
+ DEBUGOUT("Invalid PHY ID\n");
+@@ -1546,7 +1404,7 @@ iegbe_oem_phy_is_full_duplex(struct iegb
+ * the MAC with the PHY. It turns out on ICP_XXXX, this is not
+ * done automagically.
+ **/
+-int32_t
++int32_t
+ iegbe_oem_phy_is_speed_1000(struct iegbe_hw *hw, int *is1000)
+ {
+ #ifdef EXTERNAL_MDIO
+@@ -1565,28 +1423,10 @@ iegbe_oem_phy_is_speed_1000(struct iegbe
+ */
+
+ switch (hw->phy_id) {
+- case BCM5395S_PHY_ID:
+- /* Always 1000mb */
+- *is1000 = 1;
+- break;
+-
+- case BCM5481_PHY_ID:
+- ret_val = iegbe_read_phy_reg(hw, BCM5481_ASTAT, &phy_data);
+- if(ret_val) return ret_val;
+-
+- switch (BCM5481_ASTAT_HCD(phy_data)) {
+- case BCM5481_ASTAT_1KBTFD:
+- case BCM5481_ASTAT_1KBTHD:
+- *is1000 = 1;
+- break;
+- default:
+- *is1000 = 0;
+- }
+- break;
+-
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+- ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_STATUS, &phy_data);
++ ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_STATUS,
++ &phy_data);
+ if(ret_val) {
+ DEBUGOUT("Unable to read register M88E1000_PHY_SPEC_STATUS\n");
+ return ret_val;
+@@ -1638,28 +1478,9 @@ iegbe_oem_phy_is_speed_100(struct iegbe_
+ * see iegbe_config_mac_to_phy
+ */
+ switch (hw->phy_id) {
+- case BCM5395S_PHY_ID:
+- /* Always 1000Mb, never 100mb */
+- *is100 = 0;
+- break;
+-
+- case BCM5481_PHY_ID:
+- ret_val = iegbe_read_phy_reg(hw, BCM5481_ASTAT, &phy_data);
+- if(ret_val) return ret_val;
+-
+- switch (BCM5481_ASTAT_HCD(phy_data)) {
+- case BCM5481_ASTAT_100BTXFD:
+- case BCM5481_ASTAT_100BTXHD:
+- *is100 = 1;
+- break;
+- default:
+- *is100 = 0;
+- }
+- break;
+-
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+- ret_val = iegbe_oem_read_phy_reg_ex(hw,
++ ret_val = iegbe_oem_read_phy_reg_ex(hw,
+ M88E1000_PHY_SPEC_STATUS,
+ &phy_data);
+ if(ret_val) {
+@@ -1714,29 +1535,24 @@ iegbe_oem_phy_get_info(struct iegbe_hw *
+ * see iegbe_phy_m88_get_info
+ */
+ switch (hw->phy_id) {
+- case BCM5395S_PHY_ID:
+- case BCM5481_PHY_ID:
+- DEBUGOUT("WARNING: An empty iegbe_oem_phy_get_info() has been called!\n");
+- break;
+-
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+- /* The downshift status is checked only once, after link is
+- * established and it stored in the hw->speed_downgraded parameter.*/
++ /* The downshift status is checked only once, after link is
++ * established and it stored in the hw->speed_downgraded parameter.*/
+ phy_info->downshift = (iegbe_downshift)hw->speed_downgraded;
+-
+- ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_CTRL,
++
++ ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_CTRL,
+ &phy_data);
+ if(ret_val) {
+ DEBUGOUT("Unable to read register M88E1000_PHY_SPEC_CTRL\n");
+ return ret_val;
+ }
+
+- phy_info->extended_10bt_distance =
+- (phy_data & M88E1000_PSCR_10BT_EXT_DIST_ENABLE)
++ phy_info->extended_10bt_distance =
++ (phy_data & M88E1000_PSCR_10BT_EXT_DIST_ENABLE)
+ >> M88E1000_PSCR_10BT_EXT_DIST_ENABLE_SHIFT;
+ phy_info->polarity_correction =
+- (phy_data & M88E1000_PSCR_POLARITY_REVERSAL)
++ (phy_data & M88E1000_PSCR_POLARITY_REVERSAL)
+ >> M88E1000_PSCR_POLARITY_REVERSAL_SHIFT;
+
+ /* Check polarity status */
+@@ -1747,11 +1563,11 @@ iegbe_oem_phy_get_info(struct iegbe_hw *
+
+ phy_info->cable_polarity = polarity;
+
+- ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_STATUS,
++ ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_STATUS,
+ &phy_data);
+ if(ret_val) {
+- DEBUGOUT("Unable to read register M88E1000_PHY_SPEC_STATUS\n");
+- return ret_val;
++ DEBUGOUT("Unable to read register M88E1000_PHY_SPEC_STATUS\n");
++ return ret_val;
+ }
+
+ phy_info->mdix_mode = (phy_data & M88E1000_PSSR_MDIX)
+@@ -1761,24 +1577,24 @@ iegbe_oem_phy_get_info(struct iegbe_hw *
+ /* Cable Length Estimation and Local/Remote Receiver Information
+ * are only valid at 1000 Mbps.
+ */
+- phy_info->cable_length =
++ phy_info->cable_length =
+ (phy_data & M88E1000_PSSR_CABLE_LENGTH)
+ >> M88E1000_PSSR_CABLE_LENGTH_SHIFT;
+
+- ret_val = iegbe_oem_read_phy_reg_ex(hw, PHY_1000T_STATUS,
++ ret_val = iegbe_oem_read_phy_reg_ex(hw, PHY_1000T_STATUS,
+ &phy_data);
+ if(ret_val) {
+ DEBUGOUT("Unable to read register PHY_1000T_STATUS\n");
+ return ret_val;
+ }
+
+- phy_info->local_rx = (phy_data & SR_1000T_LOCAL_RX_STATUS)
++ phy_info->local_rx = (phy_data & SR_1000T_LOCAL_RX_STATUS)
+ >> SR_1000T_LOCAL_RX_STATUS_SHIFT;
+-
+- phy_info->remote_rx = (phy_data & SR_1000T_REMOTE_RX_STATUS)
++
++ phy_info->remote_rx = (phy_data & SR_1000T_REMOTE_RX_STATUS)
+ >> SR_1000T_REMOTE_RX_STATUS_SHIFT;
+ }
+-
++
+ break;
+ default:
+ DEBUGOUT("Invalid PHY ID\n");
+@@ -1801,7 +1617,7 @@ iegbe_oem_phy_get_info(struct iegbe_hw *
+ * This function will perform a software initiated reset of
+ * the PHY
+ **/
+-int32_t
++int32_t
+ iegbe_oem_phy_hw_reset(struct iegbe_hw *hw)
+ {
+ #ifdef EXTERNAL_MDIO
+@@ -1815,18 +1631,13 @@ iegbe_oem_phy_hw_reset(struct iegbe_hw *
+ return -1;
+ }
+ /*
+- * This code pretty much copies the default case from
++ * This code pretty much copies the default case from
+ * iegbe_phy_reset() as that is what is appropriate for
+- * the M88 used in truxton.
++ * the M88 used in truxton.
+ */
+ switch (hw->phy_id) {
+- case BCM5395S_PHY_ID:
+- DEBUGOUT("WARNING: An empty iegbe_oem_phy_hw_reset() has been called!\n");
+- break;
+-
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+- case BCM5481_PHY_ID:
+ ret_val = iegbe_oem_read_phy_reg_ex(hw, PHY_CTRL, &phy_data);
+ if(ret_val) {
+ DEBUGOUT("Unable to read register PHY_CTRL\n");
+@@ -1864,7 +1675,7 @@ iegbe_oem_phy_hw_reset(struct iegbe_hw *
+ * to perform and post reset initialiation. Not all PHYs require
+ * this, which is why it was split off as a seperate function.
+ **/
+-void
++void
+ iegbe_oem_phy_init_script(struct iegbe_hw *hw)
+ {
+ #ifdef EXTERNAL_MDIO
+@@ -1877,19 +1688,17 @@ iegbe_oem_phy_init_script(struct iegbe_h
+
+ /* call the GCU func that can do any phy specific init
+ * functions after a reset
+- *
++ *
+ * Make note that the M88 phy is what'll be used on Truxton
+ *
+- * The closest thing is in iegbe_phy_init_script, however this is
++ * The closest thing is in iegbe_phy_init_script, however this is
+ * for the IGP style of phy. This is probably a no-op for truxton
+ * but may be needed by OEM's later on
+- *
++ *
+ */
+ switch (hw->phy_id) {
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+- case BCM5481_PHY_ID:
+- case BCM5395S_PHY_ID:
+ DEBUGOUT("Nothing to do for OEM PHY Init");
+ break;
+ default:
+@@ -1926,13 +1735,8 @@ iegbe_oem_read_phy_reg_ex(struct iegbe_h
+ return -1;
+ }
+
+- if (hw->phy_id == BCM5395S_PHY_ID) {
+- DEBUGOUT("WARNING: iegbe_oem_read_phy_reg_ex() has been unexpectedly called!\n");
+- return -1;
+- }
+-
+ /* call the GCU func that will read the phy
+- *
++ *
+ * Make note that the M88 phy is what'll be used on Truxton.
+ *
+ * The closest thing is in iegbe_read_phy_reg_ex.
+@@ -1940,7 +1744,7 @@ iegbe_oem_read_phy_reg_ex(struct iegbe_h
+ * NOTE: this is 1 (of 2) functions that is truly dependant on the
+ * gcu module
+ */
+-
++
+ ret_val = gcu_read_eth_phy(iegbe_oem_get_phy_dev_number(hw),
+ reg_addr, phy_data);
+ if(ret_val) {
+@@ -1962,10 +1766,10 @@ iegbe_oem_read_phy_reg_ex(struct iegbe_h
+ *
+ * Returns E1000_SUCCESS, negative E1000 error code on failure
+ *
+- * This is called from iegbe_config_mac_to_phy. Various supported
++ * This is called from iegbe_config_mac_to_phy. Various supported
+ * Phys may require the RGMII/RMII Translation gasket be set to RMII.
+ **/
+-int32_t
++int32_t
+ iegbe_oem_set_trans_gasket(struct iegbe_hw *hw)
+ {
+ #ifdef EXTERNAL_MDIO
+@@ -1978,17 +1782,12 @@ iegbe_oem_set_trans_gasket(struct iegbe_
+ }
+
+ switch (hw->phy_id) {
+- case BCM5395S_PHY_ID:
+- case BCM5481_PHY_ID:
+- DEBUGOUT("WARNING: An empty iegbe_oem_set_trans_gasket() has been called!\n");
+- break;
+-
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+ /* Gasket set correctly for Marvell Phys, so nothing to do */
+ break;
+ /* Add your PHY_ID here if your device requires an RMII interface
+- case YOUR_PHY_ID:
++ case YOUR_PHY_ID:
+ ctrl_aux_reg = E1000_READ_REG(hw, CTRL_AUX);
+ ctrl_aux_reg |= E1000_CTRL_AUX_ICP_xxxx_MII_TGS; // Set the RGMII_RMII bit
+ */
+@@ -2032,7 +1831,7 @@ iegbe_oem_write_phy_reg_ex(struct iegbe_
+ return -1;
+ }
+ /* call the GCU func that will write to the phy
+- *
++ *
+ * Make note that the M88 phy is what'll be used on Truxton.
+ *
+ * The closest thing is in iegbe_write_phy_reg_ex
+@@ -2062,11 +1861,11 @@ iegbe_oem_write_phy_reg_ex(struct iegbe_
+ * @hw struct iegbe_hw hardware specific data
+ *
+ * iegbe_reset_hw is called to reset the MAC. If, for
+- * some reason the PHY needs to be reset as well, this
++ * some reason the PHY needs to be reset as well, this
+ * should return TRUE and then iegbe_oem_phy_hw_reset()
+ * will be called.
+ **/
+-int
++int
+ iegbe_oem_phy_needs_reset_with_mac(struct iegbe_hw *hw)
+ {
+ #ifdef EXTERNAL_MDIO
+@@ -2079,16 +1878,14 @@ iegbe_oem_phy_needs_reset_with_mac(struc
+ return FALSE;
+ }
+
+- /*
++ /*
+ * From the original iegbe driver, the M88
+- * PHYs did not seem to need this reset,
++ * PHYs did not seem to need this reset,
+ * so returning FALSE.
+ */
+ switch (hw->phy_id) {
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+- case BCM5481_PHY_ID:
+- case BCM5395S_PHY_ID:
+ ret_val = FALSE;
+ break;
+ default:
+@@ -2116,7 +1913,7 @@ iegbe_oem_phy_needs_reset_with_mac(struc
+ * tweaking of the PHY, for PHYs that support a DSP.
+ *
+ **/
+-int32_t
++int32_t
+ iegbe_oem_config_dsp_after_link_change(struct iegbe_hw *hw,
+ int link_up)
+ {
+@@ -2138,8 +1935,6 @@ iegbe_oem_config_dsp_after_link_change(s
+ switch (hw->phy_id) {
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+- case BCM5481_PHY_ID:
+- case BCM5395S_PHY_ID:
+ DEBUGOUT("No DSP to configure on OEM PHY");
+ break;
+ default:
+@@ -2165,7 +1960,7 @@ iegbe_oem_config_dsp_after_link_change(s
+ *
+ *
+ **/
+-int32_t
++int32_t
+ iegbe_oem_get_cable_length(struct iegbe_hw *hw,
+ uint16_t *min_length,
+ uint16_t *max_length)
+@@ -2177,21 +1972,15 @@ iegbe_oem_get_cable_length(struct iegbe_
+ uint16_t phy_data;
+
+ DEBUGFUNC1("%s",__func__);
+-
++
+ if(!hw || !min_length || !max_length) {
+ return -1;
+ }
+
+ switch (hw->phy_id) {
+- case BCM5395S_PHY_ID:
+- case BCM5481_PHY_ID:
+- *min_length = 0;
+- *max_length = iegbe_igp_cable_length_150;
+- break;
+-
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+- ret_val = iegbe_oem_read_phy_reg_ex(hw,
++ ret_val = iegbe_oem_read_phy_reg_ex(hw,
+ M88E1000_PHY_SPEC_STATUS,
+ &phy_data);
+ if(ret_val) {
+@@ -2246,13 +2035,13 @@ iegbe_oem_get_cable_length(struct iegbe_
+ /**
+ * iegbe_oem_phy_is_link_up
+ * @hw iegbe_hw struct containing device specific information
+- * @isUp a boolean returning true if link is up
++ * @isUp a boolean returning true if link is up
+ *
+ * This is called as part of iegbe_config_mac_to_phy() to align
+ * the MAC with the PHY. It turns out on ICP_XXXX, this is not
+ * done automagically.
+ **/
+-int32_t
++int32_t
+ iegbe_oem_phy_is_link_up(struct iegbe_hw *hw, int *isUp)
+ {
+ #ifdef EXTERNAL_MDIO
+@@ -2266,35 +2055,19 @@ iegbe_oem_phy_is_link_up(struct iegbe_hw
+ if(!hw || !isUp) {
+ return -1;
+ }
+- /*
++ /*
+ * Make note that the M88 phy is what'll be used on Truxton
+ * see iegbe_config_mac_to_phy
+ */
+
+ switch (hw->phy_id) {
+- case BCM5395S_PHY_ID:
+- /* Link always up */
+- *isUp = TRUE;
+- return E1000_SUCCESS;
+- break;
+-
+- case BCM5481_PHY_ID:
+- iegbe_oem_read_phy_reg_ex(hw, BCM5481_ESTAT, &phy_data);
+- ret_val = iegbe_oem_read_phy_reg_ex(hw, BCM5481_ESTAT, &phy_data);
+- if(ret_val)
+- {
+- DEBUGOUT("Unable to read PHY register BCM5481_ESTAT\n");
+- return ret_val;
+- }
+- statusMask = BCM5481_ESTAT_LINK;
+- break;
+-
+- case M88E1000_I_PHY_ID:
++ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+- iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_STATUS, &phy_data);
+- ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_STATUS, &phy_data);
++ iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_STATUS, &phy_data);
++ ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_STATUS,
++ &phy_data);
+ statusMask = M88E1000_PSSR_LINK;
+- break;
++ break;
+ default:
+ DEBUGOUT("Invalid PHY ID\n");
+ return -E1000_ERR_PHY_TYPE;
+@@ -2319,213 +2092,3 @@ iegbe_oem_phy_is_link_up(struct iegbe_hw
+ #endif /* ifdef EXTERNAL_MDIO */
+ }
+
+-
+-
+-//-----
+-// Read BCM5481 expansion register
+-//
+-int32_t
+-bcm5481_read_ex (struct iegbe_hw *hw, uint16_t reg, uint16_t *data)
+-{
+- int ret;
+- uint16_t selector;
+- uint16_t reg_data;
+-
+- // Get the current value of bits 15:12
+- ret = iegbe_oem_read_phy_reg_ex (hw, 0x15, &selector);
+- if (ret)
+- return ret;
+-
+- // Select the expansion register
+- selector &= 0xf000;
+- selector |= (0xf << 8) | (reg);
+- iegbe_oem_write_phy_reg_ex (hw, 0x17, selector);
+-
+- // Read the expansion register
+- ret = iegbe_oem_read_phy_reg_ex (hw, 0x15, &reg_data);
+-
+- // De-select the expansion registers.
+- selector &= 0xf000;
+- iegbe_oem_write_phy_reg_ex (hw, 0x17, selector);
+-
+- if (ret)
+- return ret;
+-
+- *data = reg_data;
+- return ret;
+-}
+-
+-//-----
+-// Read reg 0x18 sub-register
+-//
+-static int32_t
+-bcm5481_read_18sv (struct iegbe_hw *hw, int sv, uint16_t *data)
+-{
+- int ret;
+- uint16_t tmp_data;
+-
+- // Select reg 0x18, sv
+- tmp_data = ((sv & BCM5481_R18H_SV_MASK) << 12) | BCM5481_R18H_SV_MCTRL;
+- ret = iegbe_oem_write_phy_reg_ex (hw, BCM5481_R18H, tmp_data);
+- if(ret)
+- return ret;
+-
+- // Read reg 0x18, sv
+- ret = iegbe_oem_read_phy_reg_ex (hw, BCM5481_R18H, &tmp_data);
+- if(ret)
+- return ret;
+-
+- *data = tmp_data;
+- return ret;
+-}
+-
+-//-----
+-// Read reg 0x1C sub-register
+-//
+-int32_t
+-bcm5481_read_1csv (struct iegbe_hw *hw, int sv, uint16_t *data)
+-{
+- int ret;
+- uint16_t tmp_data;
+-
+- // Select reg 0x1c, sv
+- tmp_data = ((sv & BCM5481_R1CH_SV_MASK) << BCM5481_R1CH_SV_SHIFT);
+-
+- ret = iegbe_oem_write_phy_reg_ex (hw, BCM5481_R1CH, tmp_data);
+- if(ret)
+- return ret;
+-
+- // Read reg 0x1c, sv
+- ret = iegbe_oem_read_phy_reg_ex (hw, BCM5481_R1CH, &tmp_data);
+- if(ret)
+- return ret;
+-
+- *data = tmp_data;
+- return ret;
+-}
+-
+-//-----
+-// Read-modify-write a 0x1C register.
+-//
+-// hw - hardware access info.
+-// reg - 0x1C register to modify.
+-// data - bits which should be set.
+-// mask - the '1' bits in this argument will be cleared in the data
+-// read from 'reg' then 'data' will be or'd in and the result
+-// will be written to 'reg'.
+-
+-int32_t
+-bcm5481_rmw_1csv (struct iegbe_hw *hw, uint16_t reg, uint16_t data, uint16_t mask)
+-{
+- int32_t ret;
+- uint16_t reg_data;
+-
+- ret = 0;
+-
+- ret = bcm5481_read_1csv (hw, reg, &reg_data);
+- if (ret)
+- {
+- DEBUGOUT("Unable to read BCM5481 1CH register\n");
+- printk (KERN_ERR "Unable to read BCM5481 1CH register [0x%x]\n", reg);
+- return ret;
+- }
+-
+- reg_data &= ~mask;
+- reg_data |= (BCM5481_R1CH_WE | data);
+-
+- ret = iegbe_oem_write_phy_reg_ex (hw, BCM5481_R1CH, reg_data);
+- if(ret)
+- {
+- DEBUGOUT("Unable to write BCM5481 1CH register\n");
+- printk (KERN_ERR "Unable to write BCM5481 1CH register\n");
+- return ret;
+- }
+-
+- return ret;
+-}
+-
+-int32_t
+-oi_phy_setup (struct iegbe_hw *hw)
+-{
+- int ret;
+- uint16_t pmii_data;
+- uint16_t mctrl_data;
+- uint16_t cacr_data;
+- uint16_t sc1_data;
+- uint16_t lctl_data;
+-
+- ret = 0;
+-
+- // Set low power mode via reg 0x18, sv010, bit 6
+- // Do a read-modify-write on reg 0x18, sv010 register to preserve existing bits.
+- ret = bcm5481_read_18sv (hw, BCM5481_R18H_SV_PMII, &pmii_data);
+- if (ret)
+- {
+- DEBUGOUT("Unable to read BCM5481_R18H_SV_PMII register\n");
+- printk (KERN_ERR "Unable to read BCM5481_R18H_SV_PMII register\n");
+- return ret;
+- }
+-
+- // Set the LPM bit in the data just read and write back to sv010
+- // The shadow register select bits [2:0] are set by reading the sv010
+- // register.
+- pmii_data |= BCM5481_R18H_SV010_LPM;
+- ret = iegbe_oem_write_phy_reg_ex (hw, BCM5481_R18H, pmii_data);
+- if(ret)
+- {
+- DEBUGOUT("Unable to write BCM5481_R18H register\n");
+- printk (KERN_ERR "Unable to write BCM5481_R18H register\n");
+- return ret;
+- }
+-
+-
+- // Set the RGMII RXD to RXC skew bit in reg 0x18, sv111
+-
+- if (bcm5481_read_18sv (hw, BCM5481_R18H_SV_MCTRL, &mctrl_data))
+- {
+- DEBUGOUT("Unable to read BCM5481_R18H_SV_MCTRL register\n");
+- printk (KERN_ERR "Unable to read BCM5481_R18H_SV_MCTRL register\n");
+- return ret;
+- }
+- mctrl_data |= (BCM5481_R18H_WE | BCM5481_R18H_SV111_SKEW);
+-
+- ret = iegbe_oem_write_phy_reg_ex (hw, BCM5481_R18H, mctrl_data);
+- if(ret)
+- {
+- DEBUGOUT("Unable to write BCM5481_R18H register\n");
+- printk (KERN_ERR "Unable to write BCM5481_R18H register\n");
+- return ret;
+- }
+-
+-
+- // Enable RGMII transmit clock delay in reg 0x1c, sv00011
+- ret = bcm5481_read_1csv (hw, BCM5481_R1CH_CACR, &cacr_data);
+- if (ret)
+- {
+- DEBUGOUT("Unable to read BCM5481_R1CH_CACR register\n");
+- printk (KERN_ERR "Unable to read BCM5481_R1CH_CACR register\n");
+- return ret;
+- }
+-
+- cacr_data |= (BCM5481_R1CH_WE | BCM5481_R1CH_CACR_TCD);
+-
+- ret = iegbe_oem_write_phy_reg_ex (hw, BCM5481_R1CH, cacr_data);
+- if(ret)
+- {
+- DEBUGOUT("Unable to write BCM5481_R1CH register\n");
+- printk (KERN_ERR "Unable to write BCM5481_R1CH register\n");
+- return ret;
+- }
+-
+- // Enable dual link speed indication (0x1c, sv 00010, bit 2)
+- ret = bcm5481_rmw_1csv (hw, BCM5481_R1CH_SC1, BCM5481_R1CH_SC1_LINK, BCM5481_R1CH_SC1_LINK);
+- if (ret)
+- return ret;
+-
+- // Enable link and activity on ACTIVITY LED (0x1c, sv 01001, bit 4=1, bit 3=0)
+- ret = bcm5481_rmw_1csv (hw, BCM5481_R1CH_LCTRL, BCM5481_R1CH_LCTRL_ALEN, BCM5481_R1CH_LCTRL_ALEN | BCM5481_R1CH_LCTRL_AEN);
+- if (ret)
+- return ret;
+-
+- return ret;
+-}
+--- a/Embedded/src/GbE/iegbe_oem_phy.h
++++ b/Embedded/src/GbE/iegbe_oem_phy.h
+@@ -2,31 +2,31 @@
+
+ GPL LICENSE SUMMARY
+
+- Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
++ Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
+
+- This program is free software; you can redistribute it and/or modify
++ This program is free software; you can redistribute it and/or modify
+ it under the terms of version 2 of the GNU General Public License as
+ published by the Free Software Foundation.
+
+- 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
++ 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; if not, write to the Free Software
++ 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., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+- The full GNU General Public License is included in this distribution
++ The full GNU General Public License is included in this distribution
+ in the file called LICENSE.GPL.
+
+ Contact Information:
+ Intel Corporation
+
+- version: Embedded.L.1.0.34
++ version: Embedded.Release.Patch.L.1.0.7-5
+
+ Contact Information:
+-
+- Intel Corporation, 5000 W Chandler Blvd, Chandler, AZ 85226
++
++ Intel Corporation, 5000 W Chandler Blvd, Chandler, AZ 85226
+
+ *******************************************************************************/
+ #ifndef _IEGBE_OEM_PHY_H_
+@@ -45,10 +45,10 @@ int32_t iegbe_oem_set_trans_gasket(struc
+ uint32_t iegbe_oem_get_tipg(struct iegbe_hw *hw);
+ int iegbe_oem_phy_is_copper(struct iegbe_hw *hw);
+ uint32_t iegbe_oem_get_phy_dev_number(struct iegbe_hw *hw);
+-int iegbe_oem_mii_ioctl(struct iegbe_adapter *adapter, unsigned long flags,
++int iegbe_oem_mii_ioctl(struct iegbe_adapter *adapter, unsigned long flags,
+ struct ifreq *ifr, int cmd);
+ void iegbe_oem_fiber_live_in_suspend(struct iegbe_hw *hw);
+-void iegbe_oem_get_phy_regs(struct iegbe_adapter *adapter, uint32_t *data,
++void iegbe_oem_get_phy_regs(struct iegbe_adapter *adapter, uint32_t *data,
+ uint32_t data_length);
+ int iegbe_oem_phy_loopback(struct iegbe_adapter *adapter);
+ void iegbe_oem_loopback_cleanup(struct iegbe_adapter *adapter);
+@@ -94,81 +94,14 @@ int32_t iegbe_oem_phy_is_link_up(struct
+ #define ICP_XXXX_MAC_2 2
+
+ #define DEFAULT_ICP_XXXX_TIPG_IPGT 8 /* Inter Packet Gap Transmit Time */
+-#define ICP_XXXX_TIPG_IPGT_MASK 0x000003FFUL
+-#define BCM5481_PHY_ID 0x0143BCA2
+-#define BCM5395S_PHY_ID 0x0143BCF0
++#define ICP_XXXX_TIPG_IPGT_MASK 0x000003FFUL
+
+ /* Miscellaneous defines */
+ #ifdef IEGBE_10_100_ONLY
+- #define ICP_XXXX_AUTONEG_ADV_DEFAULT 0x0F
++ #define ICP_XXXX_AUTONEG_ADV_DEFAULT 0x0F
+ #else
+ #define ICP_XXXX_AUTONEG_ADV_DEFAULT 0x2F
+ #endif
+
+-//-----
+-// BCM5481 specifics
+-
+-#define BCM5481_ECTRL (0x10)
+-#define BCM5481_ESTAT (0x11)
+-#define BCM5481_RXERR (0x12)
+-#define BCM5481_EXPRW (0x15)
+-#define BCM5481_EXPACC (0x17)
+-#define BCM5481_ASTAT (0x19)
+-#define BCM5481_R18H (0x18)
+-#define BCM5481_R1CH (0x1c)
+-
+-//-----
+-// indirect register access via register 18h
+-
+-#define BCM5481_R18H_SV_MASK (7) // Mask for SV bits.
+-#define BCM5481_R18H_SV_ACTRL (0) // SV000 Aux. control
+-#define BCM5481_R18H_SV_10BT (1) // SV001 10Base-T
+-#define BCM5481_R18H_SV_PMII (2) // SV010 Power/MII control
+-#define BCM5481_R18H_SV_MTEST (4) // SV100 Misc. test
+-#define BCM5481_R18H_SV_MCTRL (7) // SV111 Misc. control
+-
+-#define BCM5481_R18H_SV001_POL (1 << 13) // Polarity
+-#define BCM5481_R18H_SV010_LPM (1 << 6)
+-#define BCM5481_R18H_SV111_SKEW (1 << 8)
+-#define BCM5481_R18H_WE (1 << 15) // Write enable
+-
+-// 0x1c registers
+-#define BCM5481_R1CH_SV_SHIFT (10)
+-#define BCM5481_R1CH_SV_MASK (0x1f)
+-#define BCM5481_R1CH_SC1 (0x02) // sv00010 Spare control 1
+-#define BCM5481_R1CH_CACR (0x03) // sv00011 Clock alignment control
+-#define BCM5481_R1CH_LCTRL (0x09) // sv01001 LED control
+-#define BCM5481_R1CH_LEDS1 (0x0d) // sv01101 LED selector 1
+-
+-// 0x1c common
+-#define BCM5481_R1CH_WE (1 << 15) // Write enable
+-
+-// 0x1c, sv 00010
+-#define BCM5481_R1CH_SC1_LINK (1 << 2) // sv00010 Linkspeed
+-
+-// 0x1c, sv 00011
+-#define BCM5481_R1CH_CACR_TCD (1 << 9) // sv00011 RGMII tx clock delay
+-
+-// 0x1c, sv 01001
+-#define BCM5481_R1CH_LCTRL_ALEN (1 << 4) // Activity/Link enable on ACTIVITY LED
+-#define BCM5481_R1CH_LCTRL_AEN (1 << 3) // Activity enable on ACTIVITY LED
+-
+-
+-#define BCM5481_ECTRL_DISMDIX (1 <<14)
+-
+-#define BCM5481_MCTRL_AUTOMDIX (1 <<9)
+-
+-#define BCM5481_ESTAT_LINK (1 << 8)
+-
+-#define BCM5481_ASTAT_ANC (1 << 15)
+-#define BCM5481_ASTAT_ANHCD (7 << 8)
+-#define BCM5481_ASTAT_HCD(x) ((x >> 8) & 7)
+-#define BCM5481_ASTAT_1KBTFD (0x7)
+-#define BCM5481_ASTAT_1KBTHD (0x6)
+-#define BCM5481_ASTAT_100BTXFD (0x5)
+-#define BCM5481_ASTAT_100BTXHD (0x3)
+-
+-// end BCM5481 specifics
+-
+ #endif /* ifndef _IEGBE_OEM_PHY_H_ */
+-
++
+--- a/Embedded/src/GbE/iegbe_osdep.h
++++ b/Embedded/src/GbE/iegbe_osdep.h
+@@ -2,7 +2,7 @@
+
+ GPL LICENSE SUMMARY
+
+- Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
++ Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of version 2 of the GNU General Public License as
+@@ -22,7 +22,7 @@ GPL LICENSE SUMMARY
+ Contact Information:
+ Intel Corporation
+
+- version: Embedded.L.1.0.34
++ version: Embedded.Release.Patch.L.1.0.7-5
+
+ Contact Information:
+
+--- a/Embedded/src/GbE/iegbe_param.c
++++ b/Embedded/src/GbE/iegbe_param.c
+@@ -2,7 +2,7 @@
+
+ GPL LICENSE SUMMARY
+
+- Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
++ Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of version 2 of the GNU General Public License as
+@@ -22,7 +22,7 @@ GPL LICENSE SUMMARY
+ Contact Information:
+ Intel Corporation
+
+- version: Embedded.L.1.0.34
++ version: Embedded.Release.Patch.L.1.0.7-5
+
+ Contact Information:
+
+@@ -239,11 +239,7 @@ E1000_PARAM(InterruptThrottleRate, "Inte
+ #define MAX_TXABSDELAY 0xFFFF
+ #define MIN_TXABSDELAY 0
+
+-#ifdef IEGBE_GBE_WORKAROUND
+-#define DEFAULT_ITR 0
+-#else
+ #define DEFAULT_ITR 8000
+-#endif
+
+
+ #define MAX_ITR 100000
+@@ -373,7 +369,7 @@ iegbe_check_options(struct iegbe_adapter
+ tx_ring->count = opt.def;
+ }
+ #endif
+- for (i = 0; i < adapter->num_queues; i++)
++ for (i = 0; i < adapter->num_tx_queues; i++)
+ tx_ring[i].count = tx_ring->count;
+ }
+ { /* Receive Descriptor Count */
+@@ -403,7 +399,7 @@ iegbe_check_options(struct iegbe_adapter
+ rx_ring->count = opt.def;
+ }
+ #endif
+- for (i = 0; i < adapter->num_queues; i++)
++ for (i = 0; i < adapter->num_rx_queues; i++)
+ rx_ring[i].count = rx_ring->count;
+ }
+ { /* Checksum Offload Enable/Disable */
+--- a/Embedded/src/GbE/kcompat.c
++++ b/Embedded/src/GbE/kcompat.c
+@@ -1,8 +1,8 @@
+-/************************************************************
+-
++/************************************************************
++
+ GPL LICENSE SUMMARY
+
+- Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
++ Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of version 2 of the GNU General Public License as
+@@ -22,183 +22,192 @@ GPL LICENSE SUMMARY
+ Contact Information:
+ Intel Corporation
+
+- version: Embedded.L.1.0.34
+-
+- Contact Information:
+-
+- Intel Corporation, 5000 W Chandler Blvd, Chandler, AZ 85226
+-
+-**************************************************************/
+-/**************************************************************************
+- * @ingroup KCOMPAT_GENERAL
+- *
+- * @file kcompat.c
+- *
+- * @description
+- *
+- *
+- **************************************************************************/
+-#include "kcompat.h"
+-
+-/*************************************************************/
+-/* 2.4.13 => 2.4.3 */
+-#if ( LINUX_VERSION_CODE < KERNEL_VERSION(0x2,0x4,0xd) )
+-
+-/**************************************/
+-/* PCI DMA MAPPING */
+-
+-#if defined(CONFIG_HIGHMEM)
+-
+-#ifndef PCI_DRAM_OFFSET
+-#define PCI_DRAM_OFFSET 0
+-#endif
+-
+-u64 _kc_pci_map_page(struct pci_dev *dev,
+- struct page *page,
+- unsigned long offset,
+- size_t size,
+- int direction)
+-{
+- u64 ret_val;
+- ret_val = (((u64)(page - mem_map) << PAGE_SHIFT) + offset +
+- PCI_DRAM_OFFSET);
+- return ret_val;
+-}
+-
+-#else /* CONFIG_HIGHMEM */
+-
+-u64 _kc_pci_map_page(struct pci_dev *dev,
+- struct page *page,
+- unsigned long offset,
+- size_t size,
+- int direction)
+-{
+- return pci_map_single(dev, (void *)page_address(page) + offset,
+- size, direction);
+-}
+-
+-#endif /* CONFIG_HIGHMEM */
+-
+-void _kc_pci_unmap_page(struct pci_dev *dev,
+- u64 dma_addr,
+- size_t size,
+- int direction)
+-{
+- return pci_unmap_single(dev, dma_addr, size, direction);
+-}
+-
+-#endif /* 2.4.13 => 2.4.3 */
+-
+-
+-/*****************************************************************************/
+-/* 2.4.3 => 2.4.0 */
+-#if ( LINUX_VERSION_CODE < KERNEL_VERSION(0x2,0x4,0x3) )
+-
+-/**************************************/
+-/* PCI DRIVER API */
+-
+-int _kc_pci_set_dma_mask(struct pci_dev *dev, dma_addr_t mask)
+-{
+- if(!pci_dma_supported(dev, mask)) {
+- return -EIO;
+- }
+- dev->dma_mask = mask;
+- return 0;
+-}
+-
+-int _kc_pci_request_regions(struct pci_dev *dev, char *res_name)
+-{
+- int i;
+-
+- for (i = 0; i < 0x6; i++) {
+- if (pci_resource_len(dev, i) == 0) {
+- continue;
+- }
+- if (pci_resource_flags(dev, i) & IORESOURCE_IO) {
+- if (!request_region(pci_resource_start(dev, i),
+- pci_resource_len(dev, i), res_name)) {
+- pci_release_regions(dev);
+- return -EBUSY;
+- }
+- } else if (pci_resource_flags(dev, i) & IORESOURCE_MEM) {
+- if (!request_mem_region(pci_resource_start(dev, i),
+- pci_resource_len(dev, i),
+- res_name)) {
+- pci_release_regions(dev);
+- return -EBUSY;
+- }
+- }
+- }
+- return 0;
+-}
+-
+-void _kc_pci_release_regions(struct pci_dev *dev)
+-{
+- int i;
+-
+- for (i = 0; i < 0x6; i++) {
+- if (pci_resource_len(dev, i) == 0) {
+- continue;
+- }
+- if (pci_resource_flags(dev, i) & IORESOURCE_IO){
+- release_region(pci_resource_start(dev, i),
+- pci_resource_len(dev, i));
+- } else if (pci_resource_flags(dev, i) & IORESOURCE_MEM) {
+- release_mem_region(pci_resource_start(dev, i),
+- pci_resource_len(dev, i));
+- }
+- }
+-}
+-
+-/**************************************/
+-/* NETWORK DRIVER API */
+-
+-struct net_device * _kc_alloc_etherdev(int sizeof_priv)
+-{
+- struct net_device *dev;
+- int alloc_size;
+-
+- alloc_size = sizeof(*dev) + sizeof_priv + IFNAMSIZ + 0x1f;
+-
+- dev = kmalloc(alloc_size, GFP_KERNEL);
+-
+- if (!dev) { return NULL; }
+-
+- memset(dev, 0, alloc_size);
+-
+- if (sizeof_priv) {
+- dev->priv = (void *) (((unsigned long)(dev + 1) + 0x1f) & ~0x1f);
+- }
+- dev->name[0] = '\0';
+-
+- ether_setup(dev);
+-
+- return dev;
+-}
+-
+-int _kc_is_valid_ether_addr(u8 *addr)
+-{
+- const char zaddr[0x6] = {0,};
+-
+- return !(addr[0]&1) && memcmp( addr, zaddr, 0x6);
+-}
+-
+-#endif /* 2.4.3 => 2.4.0 */
+-
+-
+-/*****************************************************************/
+-/* 2.4.6 => 2.4.3 */
+-#if ( LINUX_VERSION_CODE < KERNEL_VERSION(0x2,0x4,0x6) )
+-
+-int _kc_pci_set_power_state(struct pci_dev *dev, int state)
+-{ return 0; }
+-int _kc_pci_save_state(struct pci_dev *dev, u32 *buffer)
+-{ return 0; }
+-int _kc_pci_restore_state(struct pci_dev *pdev, u32 *buffer)
+-{ return 0; }
+-int _kc_pci_enable_wake(struct pci_dev *pdev, u32 state, int enable)
+-{ return 0; }
+-
+-#endif /* 2.4.6 => 2.4.3 */
+-
+-
++ version: Embedded.Release.Patch.L.1.0.7-5
++
++ Contact Information:
++
++ Intel Corporation, 5000 W Chandler Blvd, Chandler, AZ 85226
++
++**************************************************************/
++/**************************************************************************
++ * @ingroup KCOMPAT_GENERAL
++ *
++ * @file kcompat.c
++ *
++ * @description
++ *
++ *
++ **************************************************************************/
++#include "kcompat.h"
++
++/*************************************************************/
++/* 2.4.13 => 2.4.3 */
++#if ( LINUX_VERSION_CODE < KERNEL_VERSION(0x2,0x4,0xd) )
++
++/**************************************/
++/* PCI DMA MAPPING */
++
++#if defined(CONFIG_HIGHMEM)
++
++#ifndef PCI_DRAM_OFFSET
++#define PCI_DRAM_OFFSET 0
++#endif
++
++u64 _kc_pci_map_page(struct pci_dev *dev,
++ struct page *page,
++ unsigned long offset,
++ size_t size,
++ int direction)
++{
++ u64 ret_val;
++ ret_val = (((u64)(page - mem_map) << PAGE_SHIFT) + offset +
++ PCI_DRAM_OFFSET);
++ return ret_val;
++}
++
++#else /* CONFIG_HIGHMEM */
++
++u64 _kc_pci_map_page(struct pci_dev *dev,
++ struct page *page,
++ unsigned long offset,
++ size_t size,
++ int direction)
++{
++ return pci_map_single(dev, (void *)page_address(page) + offset,
++ size, direction);
++}
++
++#endif /* CONFIG_HIGHMEM */
++
++void _kc_pci_unmap_page(struct pci_dev *dev,
++ u64 dma_addr,
++ size_t size,
++ int direction)
++{
++ return pci_unmap_single(dev, dma_addr, size, direction);
++}
++
++#endif /* 2.4.13 => 2.4.3 */
++
++
++/*****************************************************************************/
++/* 2.4.3 => 2.4.0 */
++#if ( LINUX_VERSION_CODE < KERNEL_VERSION(0x2,0x4,0x3) )
++
++/**************************************/
++/* PCI DRIVER API */
++
++int _kc_pci_set_dma_mask(struct pci_dev *dev, dma_addr_t mask)
++{
++ if(!pci_dma_supported(dev, mask)) {
++ return -EIO;
++ }
++ dev->dma_mask = mask;
++ return 0;
++}
++
++int _kc_pci_request_regions(struct pci_dev *dev, char *res_name)
++{
++ int i;
++
++ for (i = 0; i < 0x6; i++) {
++ if (pci_resource_len(dev, i) == 0) {
++ continue;
++ }
++ if (pci_resource_flags(dev, i) & IORESOURCE_IO) {
++ if (!request_region(pci_resource_start(dev, i),
++ pci_resource_len(dev, i), res_name)) {
++ pci_release_regions(dev);
++ return -EBUSY;
++ }
++ } else if (pci_resource_flags(dev, i) & IORESOURCE_MEM) {
++ if (!request_mem_region(pci_resource_start(dev, i),
++ pci_resource_len(dev, i),
++ res_name)) {
++ pci_release_regions(dev);
++ return -EBUSY;
++ }
++ }
++ }
++ return 0;
++}
++
++void _kc_pci_release_regions(struct pci_dev *dev)
++{
++ int i;
++
++ for (i = 0; i < 0x6; i++) {
++ if (pci_resource_len(dev, i) == 0) {
++ continue;
++ }
++ if (pci_resource_flags(dev, i) & IORESOURCE_IO){
++ release_region(pci_resource_start(dev, i),
++ pci_resource_len(dev, i));
++ } else if (pci_resource_flags(dev, i) & IORESOURCE_MEM) {
++ release_mem_region(pci_resource_start(dev, i),
++ pci_resource_len(dev, i));
++ }
++ }
++}
++
++/**************************************/
++/* NETWORK DRIVER API */
++
++struct net_device * _kc_alloc_etherdev(int sizeof_priv)
++{
++ struct net_device *dev;
++ int alloc_size;
++
++ alloc_size = sizeof(*dev) + sizeof_priv + IFNAMSIZ + 0x1f;
++
++ dev = kmalloc(alloc_size, GFP_KERNEL);
++
++ if (!dev) { return NULL; }
++
++ memset(dev, 0, alloc_size);
++
++ if (sizeof_priv) {
++ dev->priv = (void *) (((unsigned long)(dev + 1) + 0x1f) & ~0x1f);
++ }
++ dev->name[0] = '\0';
++
++ ether_setup(dev);
++
++ return dev;
++}
++
++int _kc_is_valid_ether_addr(u8 *addr)
++{
++ const char zaddr[0x6] = {0,};
++
++ return !(addr[0]&1) && memcmp( addr, zaddr, 0x6);
++}
++
++#endif /* 2.4.3 => 2.4.0 */
++
++
++/*****************************************************************/
++/* 2.4.6 => 2.4.3 */
++#if ( LINUX_VERSION_CODE < KERNEL_VERSION(0x2,0x4,0x6) )
++
++int _kc_pci_set_power_state(struct pci_dev *dev, int state)
++{ return 0; }
++int _kc_pci_save_state(struct pci_dev *dev, u32 *buffer)
++{ return 0; }
++int _kc_pci_restore_state(struct pci_dev *pdev, u32 *buffer)
++{ return 0; }
++int _kc_pci_enable_wake(struct pci_dev *pdev, u32 state, int enable)
++{ return 0; }
++
++#endif /* 2.4.6 => 2.4.3 */
++
++
++
++#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,24) )
++
++void dump_stack(void)
++{
++}
++
++#endif /* 2.4.24 */
++
+--- a/Embedded/src/GbE/kcompat_ethtool.c
++++ b/Embedded/src/GbE/kcompat_ethtool.c
+@@ -2,7 +2,7 @@
+ /*
+ * GPL LICENSE SUMMARY
+ *
+- * Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
++ * Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+@@ -22,7 +22,7 @@
+ * Contact Information:
+ * Intel Corporation
+ *
+- * version: Embedded.L.1.0.34
++ * version: Embedded.Release.Patch.L.1.0.7-5
+ */
+
+ /**************************************************************************
+@@ -779,6 +779,7 @@ static int ethtool_get_stats(struct net_
+ }
+
+ /* The main entry point in this file. Called from net/core/dev.c */
++
+ #define ETHTOOL_OPS_COMPAT
+ int ethtool_ioctl(struct ifreq *ifr)
+ {
+--- a/Embedded/src/GbE/kcompat.h
++++ b/Embedded/src/GbE/kcompat.h
+@@ -2,7 +2,7 @@
+
+ GPL LICENSE SUMMARY
+
+- Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
++ Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of version 2 of the GNU General Public License as
+@@ -22,7 +22,7 @@ GPL LICENSE SUMMARY
+ Contact Information:
+ Intel Corporation
+
+- version: Embedded.L.1.0.34
++ version: Embedded.Release.Patch.L.1.0.7-5
+
+ Contact Information:
+
+@@ -69,15 +69,6 @@ GPL LICENSE SUMMARY
+ #define CONFIG_NET_POLL_CONTROLLER
+ #endif
+
+-#ifdef E1000_NAPI
+-#undef CONFIG_E1000_NAPI
+-#define CONFIG_E1000_NAPI
+-#endif
+-
+-#ifdef E1000_NO_NAPI
+-#undef CONFIG_E1000_NAPI
+-#endif
+-
+ #ifndef module_param
+ #define module_param(v,t,p) MODULE_PARM(v, "i");
+ #endif
+@@ -554,35 +545,14 @@ extern void _kc_pci_unmap_page(struct pc
+ #endif
+
+ /*****************************************************************************/
+-/* 2.4.23 => 2.4.22 */
+-#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,23) )
+-#ifdef CONFIG_E1000_NAPI
+-#ifndef netif_poll_disable
+-#define netif_poll_disable(x) _kc_netif_poll_disable(x)
+-static inline void _kc_netif_poll_disable(struct net_device *netdev)
+-{
+- while (test_and_set_bit(__LINK_STATE_RX_SCHED, &netdev->state)) {
+- /* No hurry */
+- current->state = TASK_INTERRUPTIBLE;
+- schedule_timeout(1);
+- }
+-}
+-#endif
+-#ifndef netif_poll_enable
+-#define netif_poll_enable(x) _kc_netif_poll_enable(x)
+-static inline void _kc_netif_poll_enable(struct net_device *netdev)
+-{
+- clear_bit(__LINK_STATE_RX_SCHED, &netdev->state);
+-}
+-#endif
+-#endif
+-#endif
+-
+-/*****************************************************************************/
+ /* 2.5.28 => 2.4.23 */
+ #if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,5,28) )
+
++#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,23) )
++static inline void _kc_synchronize_irq(void) { barrier(); }
++#else
+ static inline void _kc_synchronize_irq() { synchronize_irq(); }
++#endif /* 2.4.23 */
+ #undef synchronize_irq
+ #define synchronize_irq(X) _kc_synchronize_irq()
+
+@@ -747,6 +717,37 @@ static inline struct mii_ioctl_data *_kc
+ #define skb_header_cloned(x) 0
+ #endif /* SKB_DATAREF_SHIFT not defined */
+
++#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10) )
++
++#define ioread32(addr) readl(addr)
++#define iowrite32(val,addr) writel(val,addr)
++
++#endif /* 2.6.10 */
++
++#ifndef DEFINE_SPINLOCK
++#define DEFINE_SPINLOCK(s) spinlock_t s = SPIN_LOCK_UNLOCKED
++#endif /* DEFINE_SPINLOCK */
++
++#ifndef PCI_COMMAND_INTX_DISABLE
++#define PCI_COMMAND_INTX_DISABLE 0x400 /* INTx Emulation Disable */
++#endif /* PCI_COMMAND_INTX_DISABLE */
++
++#ifndef ETH_GSTRING_LEN
++#define ETH_GSTRING_LEN 32
++#endif /* ETH_GSTRING_LEN */
++
++#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,24) )
++
++extern void dump_stack(void);
++
++#undef register_reboot_notifier
++#define register_reboot_notifier(a)
++
++#undef unregister_reboot_notifier
++#define unregister_reboot_notifier(a)
++
++#endif /* 2.4.24 */
++
+ #endif /* _KCOMPAT_H_ */
+
+
+--- a/Embedded/src/GbE/Makefile
++++ b/Embedded/src/GbE/Makefile
+@@ -1,6 +1,6 @@
+ # GPL LICENSE SUMMARY
+ #
+-# Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
++# Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
+ #
+ # This program is free software; you can redistribute it and/or modify
+ # it under the terms of version 2 of the GNU General Public License as
+@@ -20,7 +20,7 @@
+ # Contact Information:
+ # Intel Corporation
+ #
+-# version: Embedded.L.1.0.34
++# version: Embedded.Release.Patch.L.1.0.7-5
+
+ ###########################################################################
+ # Driver files
+@@ -35,6 +35,8 @@ MDIO_PHONY_CFILES = gcu.c
+ MDIO_CFILES = gcu_main.c gcu_if.c
+ MDIO_HFILES = gcu.h gcu_if.h gcu_reg.h kcompat.h
+
++KVER=$(shell uname -r)
++
+ #
+ # Variables:
+ # KSRC (path to kernel source to build against)
+@@ -50,45 +52,16 @@ MDIO_HFILES = gcu.h gcu_if.h gcu_reg.h k
+
+ # set KSRC, KOBJ, and EXTERNAL_MDIO to default values of not already set
+ #
+-KOBJ ?= /usr/src/kernels/linux
+-KSRC ?= /usr/src/kernels/linux
++#KOBJ=/usr/src/kernels/linux
++#KSRC=/usr/src/kernels/linux
++#KSRC=$(KOBJ)
+ EXTERNAL_MDIO ?= 1
+ GBE_NAME = iegbe
+ GCU_NAME = gcu
+
+-# By default the workaround for the IEGBE writeback issue is enabled
+-#
+-IEGBE_GBE_WORKAROUND ?= 0
+-
+-# If the platform only supports 10/100 this variable needs to be set
+-# so the default advertisement is set appropriately.
+-# By default, this variable will be disabled.
+-#
+-IEGBE_10_100_ONLY ?= 0
+-
+-# check for version.h and autoconf.h for running kernel in /boot (SUSE)
+-ifneq (,$(wildcard /boot/vmlinuz.version.h))
+- VERSION_FILE := /boot/vmlinuz.version.h
+- CONFIG_FILE := /boot/vmlinuz.autoconf.h
+- KVER := $(shell $(CC) $(CFLAGS) -E -dM $(VERSION_FILE) | \
+- grep UTS_RELEASE | awk '{ print $$3 }' | sed 's/\"//g')
+- ifeq ($(KVER),$(shell uname -r))
+- # set up include path to override headers from kernel source
+- x:=$(shell rm -rf include)
+- x:=$(shell mkdir -p include/linux)
+- x:=$(shell cp /boot/vmlinuz.version.h include/linux/version.h)
+- x:=$(shell cp /boot/vmlinuz.autoconf.h include/linux/autoconf.h)
+- CFLAGS += -I./include
+- else
+- VERSION_FILE := $(KOBJ)/include/linux/version.h
+- UTS_REL_FILE := $(KSRC)/include/linux/utsrelease.h
+- CONFIG_FILE := $(KOBJ)/include/linux/autoconf.h
+- endif
+-else
+- VERSION_FILE := $(KOBJ)/include/linux/version.h
+- UTS_REL_FILE := $(KSRC)/include/linux/utsrelease.h
+- CONFIG_FILE := $(KOBJ)/include/linux/autoconf.h
+-endif
++VERSION_FILE := $(KSRC)/include/linux/version.h
++UTS_REL_FILE := $(KSRC)/include/linux/utsrelease.h
++CONFIG_FILE := $(KSRC)/include/linux/autoconf.h
+
+ ifeq (,$(wildcard $(VERSION_FILE)))
+ $(error Linux kernel source not configured - missing version.h)
+@@ -98,83 +71,8 @@ ifeq (,$(wildcard $(CONFIG_FILE)))
+ $(error Linux kernel source not configured - missing autoconf.h)
+ endif
+
+-# as of 2.6.16, kernel define UTS_RELEASE has been moved to utsrelease.h
+-# so check that file for kernel version string instead of version.h
+-USE_UTS_REL := $(shell [ -f $(UTS_REL_FILE) ] && echo "1")
+-
+-# pick a compiler
+-ifneq (,$(findstring egcs-2.91.66, $(shell cat /proc/version)))
+- CC := kgcc gcc cc
+-else
+- CC := gcc cc
+-endif
+-test_cc = $(shell $(cc) --version > /dev/null 2>&1 && echo $(cc))
+-CC := $(foreach cc, $(CC), $(test_cc))
+-CC := $(firstword $(CC))
+-ifeq (,$(CC))
+- $(error Compiler not found)
+-endif
+-
+-# we need to know what platform the driver is being built on
+-# some additional features are only built on Intel platforms
+-ARCH := $(shell uname -m | sed 's/i.86/i386/')
+-ifeq ($(ARCH),alpha)
+- CFLAGS += -ffixed-8 -mno-fp-regs
+-endif
+-ifeq ($(ARCH),x86_64)
+- CFLAGS += -mcmodel=kernel -mno-red-zone
+-endif
+-ifeq ($(ARCH),ppc)
+- CFLAGS += -msoft-float
+-endif
+-ifeq ($(ARCH),ppc64)
+- CFLAGS += -m64 -msoft-float
+- LDFLAGS += -melf64ppc
+-endif
+-
+-# standard flags for module builds
+-CFLAGS += -DLINUX -D__KERNEL__ -DMODULE -O2 -pipe -Wall
+-CFLAGS += -I$(KSRC)/include -I.
+-CFLAGS += $(shell [ -f $(KSRC)/include/linux/modversions.h ] && \
+- echo "-DMODVERSIONS -DEXPORT_SYMTAB \
+- -include $(KSRC)/include/linux/modversions.h")
+-
+-ifeq ($(IEGBE_GBE_WORKAROUND), 1)
+-CFLAGS += -DIEGBE_GBE_WORKAROUND -DE1000_NO_NAPI
+-endif
+-
+-ifeq ($(IEGBE_10_100_ONLY), 1)
+-CFLAGS += -DIEGBE_10_100_ONLY
+-endif
+-
+-CFLAGS += $(CFLAGS_EXTRA)
+-#ifeq (,$(shell echo $(CFLAGS_EXTRA) | grep NAPI))
+-#CFLAGS += -DE1000_NO_NAPI
+-#CFLAGS_EXTRA += -DE1000_NO_NAPI
+-#endif
+-
+-RHC := $(KSRC)/include/linux/rhconfig.h
+-ifneq (,$(wildcard $(RHC)))
+- # 7.3 typo in rhconfig.h
+- ifneq (,$(shell $(CC) $(CFLAGS) -E -dM $(RHC) | grep __module__bigmem))
+- CFLAGS += -D__module_bigmem
+- endif
+-endif
+-
+-# get the kernel version - we use this to find the correct install path
+-ifeq ($(USE_UTS_REL), 1)
+- KVER := $(shell $(CC) $(CFLAGS) -E -dM $(UTS_REL_FILE) | grep UTS_RELEASE | \
+- awk '{ print $$3 }' | sed 's/\"//g')
+-else
+- KVER := $(shell $(CC) $(CFLAGS) -E -dM $(VERSION_FILE) | grep UTS_RELEASE | \
+- awk '{ print $$3 }' | sed 's/\"//g')
+-endif
+-
+-KKVER := $(shell echo $(KVER) | \
+- awk '{ if ($$0 ~ /2\.[6-9]\./) print "1"; else print "0"}')
+-ifeq ($(KKVER), 0)
+- $(error *** Aborting the build. \
+- *** This driver is not supported on kernel versions older than 2.6.18)
++ifeq (,$(wildcard $(UTS_REL_FILE)))
++ $(error Linux kernel source not configured - missing utsrelease.h)
+ endif
+
+ # set the install path
+@@ -202,11 +100,11 @@ ifneq ($(SMP),$(shell uname -a | grep SM
+ endif
+
+ ifeq ($(SMP),1)
+- CFLAGS += -D__SMP__
++ EXTRA_CFLAGS += -D__SMP__
+ endif
+
+ ifeq ($(EXTERNAL_MDIO), 1)
+- CFLAGS += -DEXTERNAL_MDIO
++ EXTRA_CFLAGS += -DEXTERNAL_MDIO
+ endif
+
+ ###########################################################################
+@@ -223,7 +121,6 @@ MANSECTION = 7
+ MANFILE = $(TARGET:.ko=.$(MANSECTION))
+
+ ifneq ($(PATCHLEVEL),)
+- EXTRA_CFLAGS += $(CFLAGS_EXTRA)
+ obj-m += $(TARGET:.ko=.o)
+ iegbe-objs := $(CFILES:.c=.o)
+ ifeq ($(EXTERNAL_MDIO),1)
+--- a/filelist
++++ b/filelist
+@@ -1,41 +1,3 @@
+-Embedded/Makefile
+-Embedded/environment.mk
+-Embedded/src/1588/1588.c
+-Embedded/src/1588/1588.h
+-Embedded/src/1588/IxTimeSyncAcc_p.h
+-Embedded/src/1588/Makefile
+-Embedded/src/1588/ixtimesyncacc.c
+-Embedded/src/1588/ixtimesyncacc.h
+-Embedded/src/1588/linux_ioctls.h
+-Embedded/src/CAN/Makefile
+-Embedded/src/CAN/can_fifo.c
+-Embedded/src/CAN/can_fifo.h
+-Embedded/src/CAN/can_ioctl.h
+-Embedded/src/CAN/can_main.c
+-Embedded/src/CAN/can_main.h
+-Embedded/src/CAN/can_port.h
+-Embedded/src/CAN/icp_can.c
+-Embedded/src/CAN/icp_can.h
+-Embedded/src/CAN/icp_can_regs.h
+-Embedded/src/CAN/icp_can_types.h
+-Embedded/src/CAN/icp_can_user.h
+-Embedded/src/EDMA/Makefile
+-Embedded/src/EDMA/dma.h
+-Embedded/src/EDMA/dma_api.h
+-Embedded/src/EDMA/dma_client_api.c
+-Embedded/src/EDMA/dma_common.c
+-Embedded/src/EDMA/dma_internals.h
+-Embedded/src/EDMA/dma_linux.c
+-Embedded/src/EDMA/os/os.c
+-Embedded/src/EDMA/os/os.h
+-Embedded/src/EDMA/os/os_list.c
+-Embedded/src/EDMA/os/os_list.h
+-Embedded/src/EDMA/os/os_types.h
+-Embedded/src/GPIO/Makefile
+-Embedded/src/GPIO/common.h
+-Embedded/src/GPIO/gpio.h
+-Embedded/src/GPIO/gpio_ref.c
+-Embedded/src/GPIO/linux_ioctls.h
+ Embedded/src/GbE/Makefile
+ Embedded/src/GbE/gcu.h
+ Embedded/src/GbE/gcu_if.c
+@@ -55,16 +17,6 @@ Embedded/src/GbE/iegbe_param.c
+ Embedded/src/GbE/kcompat.c
+ Embedded/src/GbE/kcompat.h
+ Embedded/src/GbE/kcompat_ethtool.c
+-Embedded/src/WDT/Makefile
+-Embedded/src/WDT/iwdt.c
+-Embedded/src/WDT/iwdt.h
+-Embedded/src/patches/Intel_EP80579_RHEL5.patch
+-Embedded/src/patches/pci.ids_RHEL5.patch
+ LICENSE.GPL
+-build_system/build_files/Core/ia.mk
+-build_system/build_files/OS/linux_2.6.mk
+-build_system/build_files/OS/linux_2.6_kernel_space_rules.mk
+-build_system/build_files/common.mk
+-build_system/build_files/rules.mk
+ filelist
+ versionfile
+--- a/versionfile
++++ b/versionfile
+@@ -1,4 +1,4 @@
+-PACKAGE_TYPE=Embedded
++PACKAGE_TYPE=Embedded.Release.Patch
+
+ PACKAGE_OS=L
+
+@@ -6,4 +6,6 @@ PACKAGE_VERSION_MAJOR_NUMBER=1
+
+ PACKAGE_VERSION_MINOR_NUMBER=0
+
+-PACKAGE_VERSION_PATCH_NUMBER=34
++PACKAGE_VERSION_PATCH_NUMBER=7
++
++PACKAGE_VERSION_BUILD_NUMBER=5
diff --git a/package/system/ep80579-drivers/patches/.svn/text-base/002-cflags_cleanup.patch.svn-base b/package/system/ep80579-drivers/patches/.svn/text-base/002-cflags_cleanup.patch.svn-base
new file mode 100644
index 0000000..f897527
--- /dev/null
+++ b/package/system/ep80579-drivers/patches/.svn/text-base/002-cflags_cleanup.patch.svn-base
@@ -0,0 +1,22 @@
+--- a/build_system/build_files/common.mk
++++ b/build_system/build_files/common.mk
+@@ -122,7 +122,7 @@ CC=$(COMPILER)
+ LD=$(LINKER)
+ AR=$(ARCHIVER)
+
+-CFLAGS+=-O2
++#CFLAGS+=-O2
+
+
+ PWD= $(shell pwd)
+--- a/build_system/build_files/OS/linux_2.6.mk
++++ b/build_system/build_files/OS/linux_2.6.mk
+@@ -80,7 +80,7 @@ endif
+
+
+ ifeq ($(OS_LEVEL), kernel_space)
+-CFLAGS+=
++#CFLAGS+=
+ endif
+
+
diff --git a/package/system/ep80579-drivers/patches/.svn/text-base/003-new_irqf_constants.patch.svn-base b/package/system/ep80579-drivers/patches/.svn/text-base/003-new_irqf_constants.patch.svn-base
new file mode 100644
index 0000000..af231f2
--- /dev/null
+++ b/package/system/ep80579-drivers/patches/.svn/text-base/003-new_irqf_constants.patch.svn-base
@@ -0,0 +1,53 @@
+--- a/Embedded/src/1588/1588.c
++++ b/Embedded/src/1588/1588.c
+@@ -291,7 +291,7 @@ int pci_probe(struct pci_dev *dev, const
+
+ }
+
+- if ( request_irq(dev->irq, &timesync_isr, SA_SHIRQ, DRIVERNAME,
++ if ( request_irq(dev->irq, &timesync_isr, IRQF_SHARED, DRIVERNAME,
+ &g_drvr_data) )
+ {
+ printk("%s-pci_probe: irq\n", DRIVERNAME);
+--- a/Embedded/src/CAN/can_main.c
++++ b/Embedded/src/CAN/can_main.c
+@@ -424,7 +424,7 @@ int can_open(struct inode *inode, struct
+ err = request_irq(
+ can_os->irq,
+ can_irq_handler,
+- SA_SHIRQ,
++ IRQF_SHARED,
+ iminor(can_os->inode) ? CAN_PROC_1 : CAN_PROC_0,
+ &(g_can_os[iminor(can_os->inode)])
+ );
+--- a/Embedded/src/EDMA/dma_linux.c
++++ b/Embedded/src/EDMA/dma_linux.c
+@@ -367,7 +367,7 @@ int32_t edma_resume(struct pci_dev *dev)
+ return -ENODEV;
+ }
+
+- if (request_irq(dev->irq, &edma_irq_handler, SA_SHIRQ,
++ if (request_irq(dev->irq, &edma_irq_handler, IRQF_SHARED,
+ g_char_drvr_name, dev) )
+ {
+
+@@ -829,7 +829,7 @@ int32_t edma_probe(struct pci_dev * dev,
+ /*
+ * Obtain a (shared) Interrupt Request (IRQ) Line from the OS.
+ */
+- if (request_irq(dev->irq, &edma_irq_handler, SA_SHIRQ,
++ if (request_irq(dev->irq, &edma_irq_handler, IRQF_SHARED,
+ g_char_drvr_name, dev) )
+ {
+
+--- a/Embedded/src/WDT/iwdt.c
++++ b/Embedded/src/WDT/iwdt.c
+@@ -1461,7 +1461,7 @@ static int __init wdt_init_one(struct pc
+
+ /* Request irq only if wdt_irq is other than 0 */
+ if (wdt_irq) {
+- if (request_irq(wdt_irq, wdt_isr, SA_INTERRUPT | SA_SHIRQ,
++ if (request_irq(wdt_irq, wdt_isr, IRQF_DISABLED | IRQF_SHARED,
+ "iwdt", &wdt_miscdev)) {
+ printk("IRQ %d is not free.\n", wdt_irq);
+ return -EIO;
diff --git a/package/system/ep80579-drivers/patches/.svn/text-base/100-iegbe_netdev_ops.patch.svn-base b/package/system/ep80579-drivers/patches/.svn/text-base/100-iegbe_netdev_ops.patch.svn-base
new file mode 100644
index 0000000..162449c
--- /dev/null
+++ b/package/system/ep80579-drivers/patches/.svn/text-base/100-iegbe_netdev_ops.patch.svn-base
@@ -0,0 +1,56 @@
+--- a/Embedded/src/GbE/iegbe_main.c
++++ b/Embedded/src/GbE/iegbe_main.c
+@@ -724,6 +724,26 @@ static void iegbe_dump_eeprom(struct ieg
+ kfree(data);
+ }
+
++static const struct net_device_ops iegbe_netdev_ops = {
++ .ndo_open = iegbe_open,
++ .ndo_stop = iegbe_close,
++ .ndo_start_xmit = iegbe_xmit_frame,
++ .ndo_get_stats = iegbe_get_stats,
++ .ndo_set_rx_mode = iegbe_set_rx_mode,
++ .ndo_set_mac_address = iegbe_set_mac,
++ .ndo_tx_timeout = iegbe_tx_timeout,
++ .ndo_change_mtu = iegbe_change_mtu,
++ .ndo_do_ioctl = iegbe_ioctl,
++ .ndo_validate_addr = eth_validate_addr,
++
++ .ndo_vlan_rx_register = iegbe_vlan_rx_register,
++ .ndo_vlan_rx_add_vid = iegbe_vlan_rx_add_vid,
++ .ndo_vlan_rx_kill_vid = iegbe_vlan_rx_kill_vid,
++#ifdef CONFIG_NET_POLL_CONTROLLER
++ .ndo_poll_controller = iegbe_netpoll,
++#endif
++};
++
+ /**
+ * iegbe_probe - Device Initialization Routine
+ * @pdev: PCI device information struct
+@@ -800,24 +820,11 @@ static int __devinit iegbe_probe(struct
+ if (!hw->hw_addr)
+ goto err_ioremap;
+
+- netdev->open = &iegbe_open;
+- netdev->stop = &iegbe_close;
+- netdev->hard_start_xmit = &iegbe_xmit_frame;
+- netdev->get_stats = &iegbe_get_stats;
+- netdev->set_rx_mode = &iegbe_set_rx_mode;
+- netdev->set_mac_address = &iegbe_set_mac;
+- netdev->change_mtu = &iegbe_change_mtu;
+- netdev->do_ioctl = &iegbe_ioctl;
++ netdev->netdev_ops = &iegbe_netdev_ops;
+ set_ethtool_ops(netdev);
+- netdev->tx_timeout = &iegbe_tx_timeout;
+ netdev->watchdog_timeo = 5 * HZ;
+ netif_napi_add(netdev, &adapter->napi, iegbe_clean, 64);
+- netdev->vlan_rx_register = iegbe_vlan_rx_register;
+- netdev->vlan_rx_add_vid = iegbe_vlan_rx_add_vid;
+- netdev->vlan_rx_kill_vid = iegbe_vlan_rx_kill_vid;
+-#ifdef CONFIG_NET_POLL_CONTROLLER
+- netdev->poll_controller = iegbe_netpoll;
+-#endif
++
+ strncpy(netdev->name, pci_name(pdev), sizeof(netdev->name) - 1);
+
+
diff --git a/package/system/ep80579-drivers/patches/.svn/text-base/101-iegbe_fix_napi_interface.patch.svn-base b/package/system/ep80579-drivers/patches/.svn/text-base/101-iegbe_fix_napi_interface.patch.svn-base
new file mode 100644
index 0000000..921d464
--- /dev/null
+++ b/package/system/ep80579-drivers/patches/.svn/text-base/101-iegbe_fix_napi_interface.patch.svn-base
@@ -0,0 +1,41 @@
+--- a/Embedded/src/GbE/iegbe_main.c
++++ b/Embedded/src/GbE/iegbe_main.c
+@@ -3465,12 +3465,12 @@ static irqreturn_t iegbe_intr_msi(int ir
+ printk("Critical error! ICR = 0x%x\n", icr);
+ return IRQ_HANDLED;
+ }
+- if (likely(netif_rx_schedule_prep(netdev, &adapter->napi))) {
++ if (likely(napi_schedule_prep(&adapter->napi))) {
+ adapter->total_tx_bytes = 0;
+ adapter->total_tx_packets = 0;
+ adapter->total_rx_bytes = 0;
+ adapter->total_rx_packets = 0;
+- __netif_rx_schedule(netdev, &adapter->napi);
++ __napi_schedule(&adapter->napi);
+ } else
+ iegbe_irq_enable(adapter);
+
+@@ -3527,12 +3527,12 @@ iegbe_intr(int irq, void *data)
+ E1000_WRITE_REG(&adapter->hw, IMC, ~0);
+ E1000_WRITE_FLUSH(&adapter->hw);
+ }
+- if (likely(netif_rx_schedule_prep(netdev, &adapter->napi))) {
++ if (likely(napi_schedule_prep(&adapter->napi))) {
+ adapter->total_tx_bytes = 0;
+ adapter->total_tx_packets = 0;
+ adapter->total_rx_bytes = 0;
+ adapter->total_rx_packets = 0;
+- __netif_rx_schedule(netdev, &adapter->napi);
++ __napi_schedule(&adapter->napi);
+ } else
+ /* this really should not happen! if it does it is basically a
+ * bug, but not a hard error, so enable ints and continue */
+@@ -3574,7 +3574,7 @@ static int iegbe_clean(struct napi_struc
+ if (work_done < budget) {
+ if (likely(adapter->itr_setting & 3))
+ iegbe_set_itr(adapter);
+- netif_rx_complete(poll_dev, napi);
++ napi_complete(napi);
+ iegbe_irq_enable(adapter);
+ }
+
diff --git a/package/system/ep80579-drivers/patches/.svn/text-base/102-iegbe_nuke_polling_netdev.patch.svn-base b/package/system/ep80579-drivers/patches/.svn/text-base/102-iegbe_nuke_polling_netdev.patch.svn-base
new file mode 100644
index 0000000..f7ca627
--- /dev/null
+++ b/package/system/ep80579-drivers/patches/.svn/text-base/102-iegbe_nuke_polling_netdev.patch.svn-base
@@ -0,0 +1,103 @@
+--- a/Embedded/src/GbE/iegbe.h
++++ b/Embedded/src/GbE/iegbe.h
+@@ -316,7 +316,6 @@ struct iegbe_adapter {
+ int cleaned_count);
+ struct iegbe_rx_ring *rx_ring; /* One per active queue */
+ struct napi_struct napi;
+- struct net_device *polling_netdev; /* One per active queue */
+
+ int num_tx_queues;
+ int num_rx_queues;
+--- a/Embedded/src/GbE/iegbe_main.c
++++ b/Embedded/src/GbE/iegbe_main.c
+@@ -763,7 +763,7 @@ static int __devinit iegbe_probe(struct
+ struct iegbe_hw *hw;
+
+ static int cards_found = 0;
+- int i, err, pci_using_dac;
++ int err, pci_using_dac;
+ u16 eeprom_data = 0;
+ u16 eeprom_apme_mask = E1000_EEPROM_APME;
+ int bars;
+@@ -984,11 +984,8 @@ err_eeprom:
+ iegbe_phy_hw_reset(hw);
+ if (hw->flash_address)
+ iounmap(hw->flash_address);
+- for (i = 0; i < adapter->num_rx_queues; i++)
+- dev_put(&adapter->polling_netdev[i]);
+ kfree(adapter->tx_ring);
+ kfree(adapter->rx_ring);
+- kfree(adapter->polling_netdev);
+ err_sw_init:
+ iounmap(hw->hw_addr);
+ err_ioremap:
+@@ -1017,7 +1014,6 @@ iegbe_remove(struct pci_dev *pdev)
+ struct net_device *netdev = pci_get_drvdata(pdev);
+ struct iegbe_adapter *adapter = netdev_priv(netdev);
+ uint32_t manc;
+- int i;
+
+ if(adapter->hw.mac_type >= iegbe_82540
+ && adapter->hw.mac_type != iegbe_icp_xxxx
+@@ -1030,15 +1026,11 @@ iegbe_remove(struct pci_dev *pdev)
+ }
+
+ unregister_netdev(netdev);
+- for (i = 0x0; i < adapter->num_rx_queues; i++)
+- dev_put(&adapter->polling_netdev[i]);
+-
+ if(!iegbe_check_phy_reset_block(&adapter->hw)) {
+ iegbe_phy_hw_reset(&adapter->hw);
+ }
+ kfree(adapter->tx_ring);
+ kfree(adapter->rx_ring);
+- kfree(adapter->polling_netdev);
+
+ iounmap(adapter->hw.hw_addr);
+ pci_release_regions(pdev);
+@@ -1061,7 +1053,6 @@ iegbe_sw_init(struct iegbe_adapter *adap
+ struct iegbe_hw *hw = &adapter->hw;
+ struct net_device *netdev = adapter->netdev;
+ struct pci_dev *pdev = adapter->pdev;
+- int i;
+
+ /* PCI config space info */
+
+@@ -1111,11 +1102,6 @@ iegbe_sw_init(struct iegbe_adapter *adap
+ return -ENOMEM;
+ }
+
+- for (i = 0; i < adapter->num_rx_queues; i++) {
+- adapter->polling_netdev[i].priv = adapter;
+- dev_hold(&adapter->polling_netdev[i]);
+- set_bit(__LINK_STATE_START, &adapter->polling_netdev[i].state);
+- }
+ spin_lock_init(&adapter->tx_queue_lock);
+
+ /*
+@@ -1137,8 +1123,7 @@ iegbe_sw_init(struct iegbe_adapter *adap
+ * @adapter: board private structure to initialize
+ *
+ * We allocate one ring per queue at run-time since we don't know the
+- * number of queues at compile-time. The polling_netdev array is
+- * intended for Multiqueue, but should work fine with a single queue.
++ * number of queues at compile-time.
+ **/
+
+ static int __devinit
+@@ -1158,15 +1143,6 @@ iegbe_alloc_queues(struct iegbe_adapter
+ return -ENOMEM;
+ }
+
+- adapter->polling_netdev = kcalloc(adapter->num_rx_queues,
+- sizeof(struct net_device),
+- GFP_KERNEL);
+- if (!adapter->polling_netdev) {
+- kfree(adapter->tx_ring);
+- kfree(adapter->rx_ring);
+- return -ENOMEM;
+- }
+-
+ return E1000_SUCCESS;
+ }
+
diff --git a/package/system/ep80579-drivers/patches/.svn/text-base/103-iegbe_convert_unicast_addr_list.patch.svn-base b/package/system/ep80579-drivers/patches/.svn/text-base/103-iegbe_convert_unicast_addr_list.patch.svn-base
new file mode 100644
index 0000000..71d2d54
--- /dev/null
+++ b/package/system/ep80579-drivers/patches/.svn/text-base/103-iegbe_convert_unicast_addr_list.patch.svn-base
@@ -0,0 +1,60 @@
+--- a/Embedded/src/GbE/iegbe_main.c
++++ b/Embedded/src/GbE/iegbe_main.c
+@@ -2161,7 +2161,8 @@ static void iegbe_set_rx_mode(struct net
+ {
+ struct iegbe_adapter *adapter = netdev_priv(netdev);
+ struct iegbe_hw *hw = &adapter->hw;
+- struct dev_addr_list *uc_ptr;
++ struct netdev_hw_addr *ha;
++ bool use_uc = false;
+ struct dev_addr_list *mc_ptr;
+ u32 rctl;
+ u32 hash_value;
+@@ -2187,12 +2188,11 @@ int mta_reg_count = E1000_NUM_MTA_REGIST
+ }
+ }
+
+- uc_ptr = NULL;
+ if (netdev->uc_count > rar_entries - 1) {
+ rctl |= E1000_RCTL_UPE;
+ } else if (!(netdev->flags & IFF_PROMISC)) {
+ rctl &= ~E1000_RCTL_UPE;
+- uc_ptr = netdev->uc_list;
++ use_uc = true;
+ }
+
+ E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
+@@ -2210,13 +2210,20 @@ int mta_reg_count = E1000_NUM_MTA_REGIST
+ * if there are not 14 addresses, go ahead and clear the filters
+ * -- with 82571 controllers only 0-13 entries are filled here
+ */
++ i = 1;
++ if (use_uc)
++ list_for_each_entry(ha, &netdev->uc_list, list) {
++ if (i == rar_entries)
++ break;
++ iegbe_rar_set(hw, ha->addr, i++);
++ }
++
++ WARN_ON(i == rar_entries);
++
+ mc_ptr = netdev->mc_list;
+
+- for (i = 1; i < rar_entries; i++) {
+- if (uc_ptr) {
+- iegbe_rar_set(hw, uc_ptr->da_addr, i);
+- uc_ptr = uc_ptr->next;
+- } else if (mc_ptr) {
++ for (; i < rar_entries; i++) {
++ if (mc_ptr) {
+ iegbe_rar_set(hw, mc_ptr->da_addr, i);
+ mc_ptr = mc_ptr->next;
+ } else {
+@@ -2226,7 +2233,6 @@ int mta_reg_count = E1000_NUM_MTA_REGIST
+ E1000_WRITE_FLUSH(&adapter->hw);
+ }
+ }
+- WARN_ON(uc_ptr != NULL);
+
+ /* clear the old settings from the multicast hash table */
+
diff --git a/package/system/ep80579-drivers/patches/.svn/text-base/104-iegbe_group_address_list_and_its_count.patch.svn-base b/package/system/ep80579-drivers/patches/.svn/text-base/104-iegbe_group_address_list_and_its_count.patch.svn-base
new file mode 100644
index 0000000..c6eced6
--- /dev/null
+++ b/package/system/ep80579-drivers/patches/.svn/text-base/104-iegbe_group_address_list_and_its_count.patch.svn-base
@@ -0,0 +1,20 @@
+--- a/Embedded/src/GbE/iegbe_main.c
++++ b/Embedded/src/GbE/iegbe_main.c
+@@ -2188,7 +2188,7 @@ int mta_reg_count = E1000_NUM_MTA_REGIST
+ }
+ }
+
+- if (netdev->uc_count > rar_entries - 1) {
++ if (netdev->uc.count > rar_entries - 1) {
+ rctl |= E1000_RCTL_UPE;
+ } else if (!(netdev->flags & IFF_PROMISC)) {
+ rctl &= ~E1000_RCTL_UPE;
+@@ -2212,7 +2212,7 @@ int mta_reg_count = E1000_NUM_MTA_REGIST
+ */
+ i = 1;
+ if (use_uc)
+- list_for_each_entry(ha, &netdev->uc_list, list) {
++ list_for_each_entry(ha, &netdev->uc.list, list) {
+ if (i == rar_entries)
+ break;
+ iegbe_rar_set(hw, ha->addr, i++);
diff --git a/package/system/ep80579-drivers/patches/.svn/text-base/105-iegbe_new_dma_masks.patch.svn-base b/package/system/ep80579-drivers/patches/.svn/text-base/105-iegbe_new_dma_masks.patch.svn-base
new file mode 100644
index 0000000..d5fc46f
--- /dev/null
+++ b/package/system/ep80579-drivers/patches/.svn/text-base/105-iegbe_new_dma_masks.patch.svn-base
@@ -0,0 +1,20 @@
+--- a/Embedded/src/GbE/iegbe_main.c
++++ b/Embedded/src/GbE/iegbe_main.c
+@@ -775,13 +775,13 @@ static int __devinit iegbe_probe(struct
+ if (err)
+ return err;
+
+- if (!pci_set_dma_mask(pdev, DMA_64BIT_MASK) &&
+- !pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK)) {
++ if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64)) &&
++ !pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64))) {
+ pci_using_dac = 1;
+ } else {
+- err = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
++ err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
+ if (err) {
+- err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
++ err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
+ if (err) {
+ E1000_ERR("No usable DMA configuration, "
+ "aborting\n");
diff --git a/package/system/ep80579-drivers/patches/.svn/text-base/106-iegbe_new_irqf_constant.patch.svn-base b/package/system/ep80579-drivers/patches/.svn/text-base/106-iegbe_new_irqf_constant.patch.svn-base
new file mode 100644
index 0000000..a08e8c7
--- /dev/null
+++ b/package/system/ep80579-drivers/patches/.svn/text-base/106-iegbe_new_irqf_constant.patch.svn-base
@@ -0,0 +1,12 @@
+--- a/Embedded/src/GbE/iegbe_ethtool.c
++++ b/Embedded/src/GbE/iegbe_ethtool.c
+@@ -944,7 +944,8 @@ iegbe_intr_test(struct iegbe_adapter *ad
+ *data = 0;
+
+ /* Hook up test interrupt handler just for this test */
+- if(!request_irq(irq, &iegbe_test_intr, 0, netdev->name, netdev)) {
++ if(!request_irq(irq, &iegbe_test_intr, IRQF_PROBE_SHARED, netdev->name,
++ netdev)) {
+ shared_int = FALSE;
+ } else if(request_irq(irq, &iegbe_test_intr, IRQF_SHARED,
+ netdev->name, netdev)){
diff --git a/package/system/ep80579-drivers/patches/.svn/text-base/150-ocracoke_island.patch.svn-base b/package/system/ep80579-drivers/patches/.svn/text-base/150-ocracoke_island.patch.svn-base
new file mode 100644
index 0000000..ae74e0c
--- /dev/null
+++ b/package/system/ep80579-drivers/patches/.svn/text-base/150-ocracoke_island.patch.svn-base
@@ -0,0 +1,747 @@
+--- a/Embedded/src/GbE/iegbe_oem_phy.c
++++ b/Embedded/src/GbE/iegbe_oem_phy.c
+@@ -65,6 +65,10 @@ static int32_t iegbe_oem_link_m88_setup(
+ static int32_t iegbe_oem_set_phy_mode(struct iegbe_hw *hw);
+ static int32_t iegbe_oem_detect_phy(struct iegbe_hw *hw);
+
++static int32_t iegbe_oem_link_bcm5481_setup(struct iegbe_hw *hw);
++static int32_t bcm5481_read_18sv (struct iegbe_hw *hw, int sv, uint16_t *data);
++static int32_t oi_phy_setup (struct iegbe_hw *hw);
++
+ /**
+ * iegbe_oem_setup_link
+ * @hw: iegbe_hw struct containing device specific information
+@@ -114,6 +118,10 @@ iegbe_oem_setup_link(struct iegbe_hw *hw
+ }
+
+ switch (hw->phy_id) {
++ case BCM5395S_PHY_ID:
++ return E1000_SUCCESS;
++ break;
++
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+ ret_val = iegbe_oem_link_m88_setup(hw);
+@@ -121,6 +129,12 @@ iegbe_oem_setup_link(struct iegbe_hw *hw
+ return ret_val;
+ }
+ break;
++ case BCM5481_PHY_ID:
++ ret_val = iegbe_oem_link_bcm5481_setup(hw);
++ if(ret_val) {
++ return ret_val;
++ }
++ break;
+ default:
+ DEBUGOUT("Invalid PHY ID\n");
+ return -E1000_ERR_PHY_TYPE;
+@@ -179,6 +193,51 @@ iegbe_oem_setup_link(struct iegbe_hw *hw
+ #endif /* ifdef EXTERNAL_MDIO */
+ }
+
++/**
++ * iegbe_oem_link_bcm5481_setup
++ * @hw: iegbe_hw struct containing device specific information
++ *
++ * Returns E1000_SUCCESS, negative E1000 error code on failure
++ *
++ * copied verbatim from iegbe_oem_link_m88_setup
++ **/
++static int32_t
++iegbe_oem_link_bcm5481_setup(struct iegbe_hw *hw)
++{
++ int32_t ret_val;
++ uint16_t phy_data;
++
++ //DEBUGFUNC(__func__);
++
++ if(!hw)
++ return -1;
++
++ /* phy_reset_disable is set in iegbe_oem_set_phy_mode */
++ if(hw->phy_reset_disable)
++ return E1000_SUCCESS;
++
++ // Enable MDIX in extended control reg.
++ ret_val = iegbe_oem_read_phy_reg_ex(hw, BCM5481_ECTRL, &phy_data);
++ if(ret_val)
++ {
++ DEBUGOUT("Unable to read BCM5481_ECTRL register\n");
++ return ret_val;
++ }
++
++ phy_data &= ~BCM5481_ECTRL_DISMDIX;
++ ret_val = iegbe_oem_write_phy_reg_ex(hw, BCM5481_ECTRL, phy_data);
++ if(ret_val)
++ {
++ DEBUGOUT("Unable to write BCM5481_ECTRL register\n");
++ return ret_val;
++ }
++
++ ret_val = oi_phy_setup (hw);
++ if (ret_val)
++ return ret_val;
++
++ return E1000_SUCCESS;
++}
+
+ /**
+ * iegbe_oem_link_m88_setup
+@@ -340,6 +399,11 @@ iegbe_oem_force_mdi(struct iegbe_hw *hw,
+ * see iegbe_phy_force_speed_duplex, which does the following for M88
+ */
+ switch (hw->phy_id) {
++ case BCM5395S_PHY_ID:
++ case BCM5481_PHY_ID:
++ DEBUGOUT("WARNING: An empty iegbe_oem_force_mdi() has been called!\n");
++ break;
++
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+ ret_val = iegbe_oem_read_phy_reg_ex(hw,
+@@ -415,6 +479,8 @@ iegbe_oem_phy_reset_dsp(struct iegbe_hw
+ switch (hw->phy_id) {
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
++ case BCM5481_PHY_ID:
++ case BCM5395S_PHY_ID:
+ DEBUGOUT("No DSP to reset on OEM PHY\n");
+ break;
+ default:
+@@ -460,6 +526,11 @@ iegbe_oem_cleanup_after_phy_reset(struct
+ * see iegbe_phy_force_speed_duplex, which does the following for M88
+ */
+ switch (hw->phy_id) {
++ case BCM5395S_PHY_ID:
++ case BCM5481_PHY_ID:
++ DEBUGOUT("WARNING: An empty iegbe_oem_cleanup_after_phy_reset() has been called!\n");
++ break;
++
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+ /*
+@@ -573,6 +644,11 @@ iegbe_oem_set_phy_mode(struct iegbe_hw *
+ * use iegbe_set_phy_mode as example
+ */
+ switch (hw->phy_id) {
++ case BCM5395S_PHY_ID:
++ case BCM5481_PHY_ID:
++ DEBUGOUT("WARNING: An empty iegbe_oem_set_phy_mode() has been called!\n");
++ break;
++
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+ ret_val = iegbe_read_eeprom(hw,
+@@ -641,6 +717,19 @@ iegbe_oem_detect_phy(struct iegbe_hw *hw
+ }
+ hw->phy_type = iegbe_phy_oem;
+
++{
++ // If MAC2 (BCM5395 switch), manually detect the phy
++ struct iegbe_adapter *adapter;
++ uint32_t device_number;
++ adapter = (struct iegbe_adapter *) hw->back;
++ device_number = PCI_SLOT(adapter->pdev->devfn);
++ if (device_number == ICP_XXXX_MAC_2) {
++ hw->phy_id = BCM5395S_PHY_ID;
++ hw->phy_revision = 0;
++ return E1000_SUCCESS;
++ }
++}
++
+ ret_val = iegbe_oem_read_phy_reg_ex(hw, PHY_ID1, &phy_id_high);
+ if(ret_val) {
+ DEBUGOUT("Unable to read PHY register PHY_ID1\n");
+@@ -690,6 +779,8 @@ iegbe_oem_get_tipg(struct iegbe_hw *hw)
+ switch (hw->phy_id) {
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
++ case BCM5481_PHY_ID:
++ case BCM5395S_PHY_ID:
+ phy_num = DEFAULT_ICP_XXXX_TIPG_IPGT;
+ break;
+ default:
+@@ -738,6 +829,8 @@ iegbe_oem_phy_is_copper(struct iegbe_hw
+ switch (hw->phy_id) {
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
++ case BCM5481_PHY_ID:
++ case BCM5395S_PHY_ID:
+ isCopper = TRUE;
+ break;
+ default:
+@@ -796,13 +889,13 @@ iegbe_oem_get_phy_dev_number(struct iegb
+ switch(device_number)
+ {
+ case ICP_XXXX_MAC_0:
+- hw->phy_addr = 0x00;
++ hw->phy_addr = 0x01;
+ break;
+ case ICP_XXXX_MAC_1:
+- hw->phy_addr = 0x01;
++ hw->phy_addr = 0x02;
+ break;
+ case ICP_XXXX_MAC_2:
+- hw->phy_addr = 0x02;
++ hw->phy_addr = 0x00;
+ break;
+ default: hw->phy_addr = 0x00;
+ }
+@@ -851,6 +944,12 @@ iegbe_oem_mii_ioctl(struct iegbe_adapter
+ if(!adapter || !ifr) {
+ return -1;
+ }
++
++ // If MAC2 (BCM5395 switch) then leave now
++ if ((PCI_SLOT(adapter->pdev->devfn)) == ICP_XXXX_MAC_2) {
++ return -1;
++ }
++
+ switch (data->reg_num) {
+ case PHY_CTRL:
+ if(mii_reg & MII_CR_POWER_DOWN) {
+@@ -987,6 +1086,11 @@ void iegbe_oem_get_phy_regs(struct iegbe
+ * [10] = mdix mode
+ */
+ switch (adapter->hw.phy_id) {
++ case BCM5395S_PHY_ID:
++ case BCM5481_PHY_ID:
++ DEBUGOUT("WARNING: An empty iegbe_oem_get_phy_regs() has been called!\n");
++ break;
++
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+ if(corrected_len > 0) {
+@@ -1068,8 +1172,13 @@ iegbe_oem_phy_loopback(struct iegbe_adap
+ * Loopback configuration is the same for each of the supported PHYs.
+ */
+ switch (adapter->hw.phy_id) {
++ case BCM5395S_PHY_ID:
++ DEBUGOUT("WARNING: An empty iegbe_oem_phy_loopback() has been called!\n");
++ break;
++
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
++ case BCM5481_PHY_ID:
+
+ adapter->hw.autoneg = FALSE;
+
+@@ -1182,8 +1291,14 @@ iegbe_oem_loopback_cleanup(struct iegbe_
+ }
+
+ switch (adapter->hw.phy_id) {
++ case BCM5395S_PHY_ID:
++ DEBUGOUT("WARNING: An empty iegbe_oem_loopback_cleanup() has been called!\n");
++ return;
++ break;
++
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
++ case BCM5481_PHY_ID:
+ default:
+ adapter->hw.autoneg = TRUE;
+
+@@ -1243,6 +1358,11 @@ iegbe_oem_phy_speed_downgraded(struct ie
+ */
+
+ switch (hw->phy_id) {
++ case BCM5395S_PHY_ID:
++ case BCM5481_PHY_ID:
++ *isDowngraded = 0;
++ break;
++
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+ ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_STATUS,
+@@ -1305,6 +1425,11 @@ iegbe_oem_check_polarity(struct iegbe_hw
+ */
+
+ switch (hw->phy_id) {
++ case BCM5395S_PHY_ID:
++ case BCM5481_PHY_ID:
++ *polarity = 0;
++ break;
++
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+ /* return the Polarity bit in the Status register. */
+@@ -1367,6 +1492,25 @@ iegbe_oem_phy_is_full_duplex(struct iegb
+ */
+
+ switch (hw->phy_id) {
++ case BCM5395S_PHY_ID:
++ /* Always full duplex */
++ *isFD = 1;
++ break;
++
++ case BCM5481_PHY_ID:
++ ret_val = iegbe_read_phy_reg(hw, BCM5481_ASTAT, &phy_data);
++ if(ret_val) return ret_val;
++
++ switch (BCM5481_ASTAT_HCD(phy_data)) {
++ case BCM5481_ASTAT_1KBTFD:
++ case BCM5481_ASTAT_100BTXFD:
++ *isFD = 1;
++ break;
++ default:
++ *isFD = 0;
++ }
++ break;
++
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+ ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_STATUS,
+@@ -1423,6 +1567,25 @@ iegbe_oem_phy_is_speed_1000(struct iegbe
+ */
+
+ switch (hw->phy_id) {
++ case BCM5395S_PHY_ID:
++ /* Always 1000mb */
++ *is1000 = 1;
++ break;
++
++ case BCM5481_PHY_ID:
++ ret_val = iegbe_read_phy_reg(hw, BCM5481_ASTAT, &phy_data);
++ if(ret_val) return ret_val;
++
++ switch (BCM5481_ASTAT_HCD(phy_data)) {
++ case BCM5481_ASTAT_1KBTFD:
++ case BCM5481_ASTAT_1KBTHD:
++ *is1000 = 1;
++ break;
++ default:
++ *is1000 = 0;
++ }
++ break;
++
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+ ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_STATUS,
+@@ -1478,6 +1641,25 @@ iegbe_oem_phy_is_speed_100(struct iegbe_
+ * see iegbe_config_mac_to_phy
+ */
+ switch (hw->phy_id) {
++ case BCM5395S_PHY_ID:
++ /* Always 1000Mb, never 100mb */
++ *is100 = 0;
++ break;
++
++ case BCM5481_PHY_ID:
++ ret_val = iegbe_read_phy_reg(hw, BCM5481_ASTAT, &phy_data);
++ if(ret_val) return ret_val;
++
++ switch (BCM5481_ASTAT_HCD(phy_data)) {
++ case BCM5481_ASTAT_100BTXFD:
++ case BCM5481_ASTAT_100BTXHD:
++ *is100 = 1;
++ break;
++ default:
++ *is100 = 0;
++ }
++ break;
++
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+ ret_val = iegbe_oem_read_phy_reg_ex(hw,
+@@ -1535,6 +1717,11 @@ iegbe_oem_phy_get_info(struct iegbe_hw *
+ * see iegbe_phy_m88_get_info
+ */
+ switch (hw->phy_id) {
++ case BCM5395S_PHY_ID:
++ case BCM5481_PHY_ID:
++ DEBUGOUT("WARNING: An empty iegbe_oem_phy_get_info() has been called!\n");
++ break;
++
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+ /* The downshift status is checked only once, after link is
+@@ -1636,8 +1823,13 @@ iegbe_oem_phy_hw_reset(struct iegbe_hw *
+ * the M88 used in truxton.
+ */
+ switch (hw->phy_id) {
++ case BCM5395S_PHY_ID:
++ DEBUGOUT("WARNING: An empty iegbe_oem_phy_hw_reset() has been called!\n");
++ break;
++
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
++ case BCM5481_PHY_ID:
+ ret_val = iegbe_oem_read_phy_reg_ex(hw, PHY_CTRL, &phy_data);
+ if(ret_val) {
+ DEBUGOUT("Unable to read register PHY_CTRL\n");
+@@ -1699,6 +1891,8 @@ iegbe_oem_phy_init_script(struct iegbe_h
+ switch (hw->phy_id) {
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
++ case BCM5481_PHY_ID:
++ case BCM5395S_PHY_ID:
+ DEBUGOUT("Nothing to do for OEM PHY Init");
+ break;
+ default:
+@@ -1735,6 +1929,11 @@ iegbe_oem_read_phy_reg_ex(struct iegbe_h
+ return -1;
+ }
+
++ if (hw->phy_id == BCM5395S_PHY_ID) {
++ DEBUGOUT("WARNING: iegbe_oem_read_phy_reg_ex() has been unexpectedly called!\n");
++ return -1;
++ }
++
+ /* call the GCU func that will read the phy
+ *
+ * Make note that the M88 phy is what'll be used on Truxton.
+@@ -1782,6 +1981,11 @@ iegbe_oem_set_trans_gasket(struct iegbe_
+ }
+
+ switch (hw->phy_id) {
++ case BCM5395S_PHY_ID:
++ case BCM5481_PHY_ID:
++ DEBUGOUT("WARNING: An empty iegbe_oem_set_trans_gasket() has been called!\n");
++ break;
++
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+ /* Gasket set correctly for Marvell Phys, so nothing to do */
+@@ -1886,6 +2090,8 @@ iegbe_oem_phy_needs_reset_with_mac(struc
+ switch (hw->phy_id) {
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
++ case BCM5481_PHY_ID:
++ case BCM5395S_PHY_ID:
+ ret_val = FALSE;
+ break;
+ default:
+@@ -1935,6 +2141,8 @@ iegbe_oem_config_dsp_after_link_change(s
+ switch (hw->phy_id) {
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
++ case BCM5481_PHY_ID:
++ case BCM5395S_PHY_ID:
+ DEBUGOUT("No DSP to configure on OEM PHY");
+ break;
+ default:
+@@ -1978,6 +2186,12 @@ iegbe_oem_get_cable_length(struct iegbe_
+ }
+
+ switch (hw->phy_id) {
++ case BCM5395S_PHY_ID:
++ case BCM5481_PHY_ID:
++ *min_length = 0;
++ *max_length = iegbe_igp_cable_length_150;
++ break;
++
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+ ret_val = iegbe_oem_read_phy_reg_ex(hw,
+@@ -2061,6 +2275,23 @@ iegbe_oem_phy_is_link_up(struct iegbe_hw
+ */
+
+ switch (hw->phy_id) {
++ case BCM5395S_PHY_ID:
++ /* Link always up */
++ *isUp = TRUE;
++ return E1000_SUCCESS;
++ break;
++
++ case BCM5481_PHY_ID:
++ iegbe_oem_read_phy_reg_ex(hw, BCM5481_ESTAT, &phy_data);
++ ret_val = iegbe_oem_read_phy_reg_ex(hw, BCM5481_ESTAT, &phy_data);
++ if(ret_val)
++ {
++ DEBUGOUT("Unable to read PHY register BCM5481_ESTAT\n");
++ return ret_val;
++ }
++ statusMask = BCM5481_ESTAT_LINK;
++ break;
++
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+ iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_STATUS, &phy_data);
+@@ -2092,3 +2323,210 @@ iegbe_oem_phy_is_link_up(struct iegbe_hw
+ #endif /* ifdef EXTERNAL_MDIO */
+ }
+
++
++
++//-----
++// Read BCM5481 expansion register
++//
++int32_t
++bcm5481_read_ex (struct iegbe_hw *hw, uint16_t reg, uint16_t *data)
++{
++ int ret;
++ uint16_t selector;
++ uint16_t reg_data;
++
++ // Get the current value of bits 15:12
++ ret = iegbe_oem_read_phy_reg_ex (hw, 0x15, &selector);
++ if (ret)
++ return ret;
++
++ // Select the expansion register
++ selector &= 0xf000;
++ selector |= (0xf << 8) | (reg);
++ iegbe_oem_write_phy_reg_ex (hw, 0x17, selector);
++
++ // Read the expansion register
++ ret = iegbe_oem_read_phy_reg_ex (hw, 0x15, &reg_data);
++
++ // De-select the expansion registers.
++ selector &= 0xf000;
++ iegbe_oem_write_phy_reg_ex (hw, 0x17, selector);
++
++ if (ret)
++ return ret;
++
++ *data = reg_data;
++ return ret;
++}
++
++//-----
++// Read reg 0x18 sub-register
++//
++static int32_t
++bcm5481_read_18sv (struct iegbe_hw *hw, int sv, uint16_t *data)
++{
++ int ret;
++ uint16_t tmp_data;
++
++ // Select reg 0x18, sv
++ tmp_data = ((sv & BCM5481_R18H_SV_MASK) << 12) | BCM5481_R18H_SV_MCTRL;
++ ret = iegbe_oem_write_phy_reg_ex (hw, BCM5481_R18H, tmp_data);
++ if(ret)
++ return ret;
++
++ // Read reg 0x18, sv
++ ret = iegbe_oem_read_phy_reg_ex (hw, BCM5481_R18H, &tmp_data);
++ if(ret)
++ return ret;
++
++ *data = tmp_data;
++ return ret;
++}
++
++//-----
++// Read reg 0x1C sub-register
++//
++int32_t
++bcm5481_read_1csv (struct iegbe_hw *hw, int sv, uint16_t *data)
++{
++ int ret;
++ uint16_t tmp_data;
++
++ // Select reg 0x1c, sv
++ tmp_data = ((sv & BCM5481_R1CH_SV_MASK) << BCM5481_R1CH_SV_SHIFT);
++
++ ret = iegbe_oem_write_phy_reg_ex (hw, BCM5481_R1CH, tmp_data);
++ if(ret)
++ return ret;
++
++ // Read reg 0x1c, sv
++ ret = iegbe_oem_read_phy_reg_ex (hw, BCM5481_R1CH, &tmp_data);
++ if(ret)
++ return ret;
++
++ *data = tmp_data;
++ return ret;
++}
++
++//-----
++// Read-modify-write a 0x1C register.
++//
++// hw - hardware access info.
++// reg - 0x1C register to modify.
++// data - bits which should be set.
++// mask - the '1' bits in this argument will be cleared in the data
++// read from 'reg' then 'data' will be or'd in and the result
++// will be written to 'reg'.
++
++int32_t
++bcm5481_rmw_1csv (struct iegbe_hw *hw, uint16_t reg, uint16_t data, uint16_t mask)
++{
++ int32_t ret;
++ uint16_t reg_data;
++
++ ret = 0;
++
++ ret = bcm5481_read_1csv (hw, reg, &reg_data);
++ if (ret)
++ {
++ DEBUGOUT("Unable to read BCM5481 1CH register\n");
++ printk (KERN_ERR "Unable to read BCM5481 1CH register [0x%x]\n", reg);
++ return ret;
++ }
++
++ reg_data &= ~mask;
++ reg_data |= (BCM5481_R1CH_WE | data);
++
++ ret = iegbe_oem_write_phy_reg_ex (hw, BCM5481_R1CH, reg_data);
++ if(ret)
++ {
++ DEBUGOUT("Unable to write BCM5481 1CH register\n");
++ printk (KERN_ERR "Unable to write BCM5481 1CH register\n");
++ return ret;
++ }
++
++ return ret;
++}
++
++int32_t
++oi_phy_setup (struct iegbe_hw *hw)
++{
++ int ret;
++ uint16_t pmii_data;
++ uint16_t mctrl_data;
++ uint16_t cacr_data;
++
++ ret = 0;
++
++ // Set low power mode via reg 0x18, sv010, bit 6
++ // Do a read-modify-write on reg 0x18, sv010 register to preserve existing bits.
++ ret = bcm5481_read_18sv (hw, BCM5481_R18H_SV_PMII, &pmii_data);
++ if (ret)
++ {
++ DEBUGOUT("Unable to read BCM5481_R18H_SV_PMII register\n");
++ printk (KERN_ERR "Unable to read BCM5481_R18H_SV_PMII register\n");
++ return ret;
++ }
++
++ // Set the LPM bit in the data just read and write back to sv010
++ // The shadow register select bits [2:0] are set by reading the sv010
++ // register.
++ pmii_data |= BCM5481_R18H_SV010_LPM;
++ ret = iegbe_oem_write_phy_reg_ex (hw, BCM5481_R18H, pmii_data);
++ if(ret)
++ {
++ DEBUGOUT("Unable to write BCM5481_R18H register\n");
++ printk (KERN_ERR "Unable to write BCM5481_R18H register\n");
++ return ret;
++ }
++
++
++ // Set the RGMII RXD to RXC skew bit in reg 0x18, sv111
++
++ if (bcm5481_read_18sv (hw, BCM5481_R18H_SV_MCTRL, &mctrl_data))
++ {
++ DEBUGOUT("Unable to read BCM5481_R18H_SV_MCTRL register\n");
++ printk (KERN_ERR "Unable to read BCM5481_R18H_SV_MCTRL register\n");
++ return ret;
++ }
++ mctrl_data |= (BCM5481_R18H_WE | BCM5481_R18H_SV111_SKEW);
++
++ ret = iegbe_oem_write_phy_reg_ex (hw, BCM5481_R18H, mctrl_data);
++ if(ret)
++ {
++ DEBUGOUT("Unable to write BCM5481_R18H register\n");
++ printk (KERN_ERR "Unable to write BCM5481_R18H register\n");
++ return ret;
++ }
++
++ // Enable RGMII transmit clock delay in reg 0x1c, sv00011
++ ret = bcm5481_read_1csv (hw, BCM5481_R1CH_CACR, &cacr_data);
++ if (ret)
++ {
++ DEBUGOUT("Unable to read BCM5481_R1CH_CACR register\n");
++ printk (KERN_ERR "Unable to read BCM5481_R1CH_CACR register\n");
++ return ret;
++ }
++
++ cacr_data |= (BCM5481_R1CH_WE | BCM5481_R1CH_CACR_TCD);
++
++ ret = iegbe_oem_write_phy_reg_ex (hw, BCM5481_R1CH, cacr_data);
++ if(ret)
++ {
++ DEBUGOUT("Unable to write BCM5481_R1CH register\n");
++ printk (KERN_ERR "Unable to write BCM5481_R1CH register\n");
++ return ret;
++ }
++
++ // Enable dual link speed indication (0x1c, sv 00010, bit 2)
++ ret = bcm5481_rmw_1csv (hw, BCM5481_R1CH_SC1, BCM5481_R1CH_SC1_LINK, BCM5481_R1CH_SC1_LINK);
++ if (ret)
++ return ret;
++
++ // Enable link and activity on ACTIVITY LED (0x1c, sv 01001, bit 4=1, bit 3=0)
++ ret = bcm5481_rmw_1csv (hw, BCM5481_R1CH_LCTRL, BCM5481_R1CH_LCTRL_ALEN, BCM5481_R1CH_LCTRL_ALEN | BCM5481_R1CH_LCTRL_AEN);
++ if (ret)
++ return ret;
++
++ return ret;
++}
+--- a/Embedded/src/GbE/iegbe_oem_phy.h
++++ b/Embedded/src/GbE/iegbe_oem_phy.h
+@@ -95,6 +95,8 @@ int32_t iegbe_oem_phy_is_link_up(struct
+
+ #define DEFAULT_ICP_XXXX_TIPG_IPGT 8 /* Inter Packet Gap Transmit Time */
+ #define ICP_XXXX_TIPG_IPGT_MASK 0x000003FFUL
++#define BCM5481_PHY_ID 0x0143BCA0
++#define BCM5395S_PHY_ID 0x0143BCF0
+
+ /* Miscellaneous defines */
+ #ifdef IEGBE_10_100_ONLY
+@@ -103,5 +105,65 @@ int32_t iegbe_oem_phy_is_link_up(struct
+ #define ICP_XXXX_AUTONEG_ADV_DEFAULT 0x2F
+ #endif
+
++/* BCM5481 specifics */
++
++#define BCM5481_ECTRL (0x10)
++#define BCM5481_ESTAT (0x11)
++#define BCM5481_RXERR (0x12)
++#define BCM5481_EXPRW (0x15)
++#define BCM5481_EXPACC (0x17)
++#define BCM5481_ASTAT (0x19)
++#define BCM5481_R18H (0x18)
++#define BCM5481_R1CH (0x1c)
++
++/* indirect register access via register 18h */
++
++#define BCM5481_R18H_SV_MASK (7) // Mask for SV bits.
++#define BCM5481_R18H_SV_ACTRL (0) // SV000 Aux. control
++#define BCM5481_R18H_SV_10BT (1) // SV001 10Base-T
++#define BCM5481_R18H_SV_PMII (2) // SV010 Power/MII control
++#define BCM5481_R18H_SV_MTEST (4) // SV100 Misc. test
++#define BCM5481_R18H_SV_MCTRL (7) // SV111 Misc. control
++
++#define BCM5481_R18H_SV001_POL (1 << 13) // Polarity
++#define BCM5481_R18H_SV010_LPM (1 << 6)
++#define BCM5481_R18H_SV111_SKEW (1 << 8)
++#define BCM5481_R18H_WE (1 << 15) // Write enable
++
++// 0x1c registers
++#define BCM5481_R1CH_SV_SHIFT (10)
++#define BCM5481_R1CH_SV_MASK (0x1f)
++#define BCM5481_R1CH_SC1 (0x02) // sv00010 Spare control 1
++#define BCM5481_R1CH_CACR (0x03) // sv00011 Clock alignment control
++#define BCM5481_R1CH_LCTRL (0x09) // sv01001 LED control
++#define BCM5481_R1CH_LEDS1 (0x0d) // sv01101 LED selector 1
++
++// 0x1c common
++#define BCM5481_R1CH_WE (1 << 15) // Write enable
++
++// 0x1c, sv 00010
++#define BCM5481_R1CH_SC1_LINK (1 << 2) // sv00010 Linkspeed
++
++// 0x1c, sv 00011
++#define BCM5481_R1CH_CACR_TCD (1 << 9) // sv00011 RGMII tx clock delay
++
++// 0x1c, sv 01001
++#define BCM5481_R1CH_LCTRL_ALEN (1 << 4) // Activity/Link enable on ACTIVITY LED
++#define BCM5481_R1CH_LCTRL_AEN (1 << 3) // Activity enable on ACTIVITY LED
++
++#define BCM5481_ECTRL_DISMDIX (1 <<14)
++
++#define BCM5481_MCTRL_AUTOMDIX (1 <<9)
++
++#define BCM5481_ESTAT_LINK (1 << 8)
++
++#define BCM5481_ASTAT_ANC (1 << 15)
++#define BCM5481_ASTAT_ANHCD (7 << 8)
++#define BCM5481_ASTAT_HCD(x) ((x >> 8) & 7)
++#define BCM5481_ASTAT_1KBTFD (0x7)
++#define BCM5481_ASTAT_1KBTHD (0x6)
++#define BCM5481_ASTAT_100BTXFD (0x5)
++#define BCM5481_ASTAT_100BTXHD (0x3)
++
+ #endif /* ifndef _IEGBE_OEM_PHY_H_ */
+
diff --git a/package/system/ep80579-drivers/patches/.svn/text-base/200-can_fix_ioctl_numbers.patch.svn-base b/package/system/ep80579-drivers/patches/.svn/text-base/200-can_fix_ioctl_numbers.patch.svn-base
new file mode 100644
index 0000000..2919466
--- /dev/null
+++ b/package/system/ep80579-drivers/patches/.svn/text-base/200-can_fix_ioctl_numbers.patch.svn-base
@@ -0,0 +1,11 @@
+--- a/Embedded/src/CAN/icp_can_user.h
++++ b/Embedded/src/CAN/icp_can_user.h
+@@ -63,6 +63,8 @@
+ #ifndef __ICP_CAN_USER_H__
+ #define __ICP_CAN_USER_H__
+
++#include <linux/ioctl.h>
++
+ /*****************************************************************************
+ * Device IO control codes.
+ *****************************************************************************/
diff --git a/package/system/ep80579-drivers/patches/.svn/text-base/210-can_include_linux_fs_h.patch.svn-base b/package/system/ep80579-drivers/patches/.svn/text-base/210-can_include_linux_fs_h.patch.svn-base
new file mode 100644
index 0000000..26c53dc
--- /dev/null
+++ b/package/system/ep80579-drivers/patches/.svn/text-base/210-can_include_linux_fs_h.patch.svn-base
@@ -0,0 +1,11 @@
+--- a/Embedded/src/CAN/can_main.c
++++ b/Embedded/src/CAN/can_main.c
+@@ -70,6 +70,8 @@
+
+ #include "can_main.h"
+ #include "can_ioctl.h"
++#include <linux/fs.h>
++
+
+ MODULE_AUTHOR("Intel(R) Corporation");
+ MODULE_DESCRIPTION("Controller Area Network Driver");
diff --git a/package/system/ep80579-drivers/patches/.svn/text-base/220-can_fix_irq_request.patch.svn-base b/package/system/ep80579-drivers/patches/.svn/text-base/220-can_fix_irq_request.patch.svn-base
new file mode 100644
index 0000000..2950cc7
--- /dev/null
+++ b/package/system/ep80579-drivers/patches/.svn/text-base/220-can_fix_irq_request.patch.svn-base
@@ -0,0 +1,23 @@
+--- a/Embedded/src/CAN/can_main.c
++++ b/Embedded/src/CAN/can_main.c
+@@ -654,7 +654,7 @@ int can_dev_io(struct inode *inode, stru
+ /*****************************************************************************
+ * Interrupt handler.
+ *****************************************************************************/
+-irqreturn_t can_irq_handler(int irq, void *dev_id, struct pt_regs *regs)
++irqreturn_t can_irq_handler(int irq, void *dev_id)
+ {
+ can_os_t *can_os = (can_os_t *) dev_id;
+ unsigned int int_status;
+--- a/Embedded/src/CAN/can_main.h
++++ b/Embedded/src/CAN/can_main.h
+@@ -165,8 +165,7 @@ int can_dev_io(
+
+ irqreturn_t can_irq_handler(
+ int irq,
+- void *dev_id,
+- struct pt_regs *regs);
++ void *dev_id);
+
+ void can_tasklet(
+ unsigned long arg
diff --git a/package/system/ep80579-drivers/patches/.svn/text-base/230-can_remove_driver_data_direct_access.patch.svn-base b/package/system/ep80579-drivers/patches/.svn/text-base/230-can_remove_driver_data_direct_access.patch.svn-base
new file mode 100644
index 0000000..19dbb7e
--- /dev/null
+++ b/package/system/ep80579-drivers/patches/.svn/text-base/230-can_remove_driver_data_direct_access.patch.svn-base
@@ -0,0 +1,40 @@
+--- a/Embedded/src/CAN/can_main.c
++++ b/Embedded/src/CAN/can_main.c
+@@ -214,8 +214,8 @@ int can_pci_probe(struct pci_dev *dev, c
+ spin_lock_init(&(g_can_os[can_num].int_spinlock));
+ spin_lock_init(&(g_can_os[can_num].open_spinlock));
+
+- dev->dev.driver_data = (void *) &(g_can_os[can_num]);
+- if (!dev->dev.driver_data)
++ dev_set_drvdata(&dev->dev, (void *) &(g_can_os[can_num]));
++ if (!dev_get_drvdata(&dev->dev))
+ {
+ printk("Couldn't create CAN device %d. Exiting.\n",
+ dev->device);
+@@ -237,7 +237,7 @@ int can_pci_probe(struct pci_dev *dev, c
+ *****************************************************************************/
+ void can_pci_remove(struct pci_dev *dev)
+ {
+- can_os_t *can_os = dev->dev.driver_data;
++ can_os_t *can_os = dev_get_drvdata(&dev->dev);
+
+ iounmap(can_os->pci_remap);
+ icp_can_destroy(can_os->can);
+@@ -251,7 +251,7 @@ int can_pci_suspend(struct pci_dev *dev,
+ {
+ unsigned int i;
+ unsigned int int_status;
+- can_os_t *can_os = dev->dev.driver_data;
++ can_os_t *can_os = dev_get_drvdata(&dev->dev);
+ int err;
+
+ /* Indicate that we are suspending */
+@@ -322,7 +322,7 @@ int can_pci_suspend(struct pci_dev *dev,
+ int can_pci_resume(struct pci_dev *dev)
+ {
+ unsigned int i;
+- can_os_t *can_os = dev->dev.driver_data;
++ can_os_t *can_os = dev_get_drvdata(&dev->dev);
+
+ /* Restore PCI CFG space */
+ pci_restore_state(dev);
diff --git a/package/system/ep80579-drivers/patches/.svn/text-base/300-wdt_compile_fix.patch.svn-base b/package/system/ep80579-drivers/patches/.svn/text-base/300-wdt_compile_fix.patch.svn-base
new file mode 100644
index 0000000..59242b8
--- /dev/null
+++ b/package/system/ep80579-drivers/patches/.svn/text-base/300-wdt_compile_fix.patch.svn-base
@@ -0,0 +1,59 @@
+--- a/Embedded/src/WDT/iwdt.c
++++ b/Embedded/src/WDT/iwdt.c
+@@ -180,19 +180,19 @@ MODULE_PARM_DESC(wdt_scale, "Intel WDT s
+ module_param(wdt_intr_type, byte, WDT_INT_TYPE_IRQ);
+ MODULE_PARM_DESC(wdt_intr_type, "Intel WDT interrupt type (default SERIRQ).");
+
+-module_param(wdt_margin1, uint, TIMER_MARGIN);
++module_param(wdt_margin1, uint, 0);
+ MODULE_PARM_DESC(wdt_margin1, "First stage Intel WDT timeout in steps of 1 ms by default.");
+
+-module_param(wdt_margin2, uint, TIMER_MARGIN);
++module_param(wdt_margin2, uint, 0);
+ MODULE_PARM_DESC(wdt_margin2, "Second stage Intel WDT timeout in steps of 1 ms by default.");
+
+ module_param(nowayout, int, 0);
+ MODULE_PARM_DESC(nowayout, "Intel WDT can't be stopped once started (default=0)");
+
+-module_param(wdt_index_port, int, 0x4E);
++module_param(wdt_index_port, int, 0);
+ MODULE_PARM_DESC(wdt_index_port, "WDT Index Port (default 0x4e)");
+
+-module_param(wdt_data_port, int, 0x4E);
++module_param(wdt_data_port, int, 0);
+ MODULE_PARM_DESC(wdt_data_port, "WDT Data Port (default 0x4f)");
+
+ static int wdt_get_iobase(struct pci_dev *dev, u16 *iobase, int *irq);
+@@ -218,7 +218,7 @@ static ssize_t wdt_write(struct file *fi
+ size_t count, loff_t * pos);
+ static int wdt_ioctl(struct inode *inode, struct file *file,
+ unsigned int cmd, unsigned long arg);
+-static irqreturn_t wdt_isr(int irq, void *dev_id, struct pt_regs *regs);
++static irqreturn_t wdt_isr(int irq, void *dev_id);
+ static void __exit wdt_cleanup(void);
+ static int __init wdt_init(void);
+ static int __init wdt_init_one(struct pci_dev *dev,
+@@ -255,7 +255,7 @@ static struct pci_driver wdt_driver = {
+ name: "iwdt",
+ id_table: lpc_pci_tbl,
+ probe: wdt_init_one,
+- remove: __devexit(wdt_remove_one),
++ remove: __devexit_p(wdt_remove_one),
+ suspend: wdt_pci_suspend,
+ resume: wdt_pci_resume,
+ };
+@@ -1393,12 +1393,12 @@ static int wdt_ioctl(struct inode *inode
+
+ /*
+ * Function Name: wdt_isr()
+- * Parameter: int irq - irq number, void *dev_id, struct pt_regs *regs
++ * Parameter: int irq - irq number, void *dev_id
+ * Return Value:: IRQ_NONE - if the interrupt is not for wdt.
+ * IRQ_HANDLED - if it is for wdt.
+ * Description: This is the interrupt service routine of the WDT.
+ */
+-static irqreturn_t wdt_isr(int irq, void *dev_id, struct pt_regs *regs)
++static irqreturn_t wdt_isr(int irq, void *dev_id)
+ {
+ u8 val;
+
diff --git a/package/system/ep80579-drivers/patches/.svn/text-base/400-edma_fix_irq_request_warning.patch.svn-base b/package/system/ep80579-drivers/patches/.svn/text-base/400-edma_fix_irq_request_warning.patch.svn-base
new file mode 100644
index 0000000..d858aff
--- /dev/null
+++ b/package/system/ep80579-drivers/patches/.svn/text-base/400-edma_fix_irq_request_warning.patch.svn-base
@@ -0,0 +1,22 @@
+--- a/Embedded/src/EDMA/dma_linux.c
++++ b/Embedded/src/EDMA/dma_linux.c
+@@ -149,8 +149,7 @@ int32_t edma_suspend (struct pci_dev *de
+ int32_t edma_resume(struct pci_dev *dev);
+ int32_t initialize_edma_device(struct edma_device *device);
+
+-static irqreturn_t edma_irq_handler(int32_t irq, void * dev_id,
+- struct pt_regs * regs);
++static irqreturn_t edma_irq_handler(int32_t irq, void * dev_id);
+
+ /* Prototypes - Misc. */
+
+@@ -429,8 +428,7 @@ int32_t edma_release(struct inode * inod
+ * Return Values: HANDLED = 1, NOT_HANDLED = 0
+ *****************************************************************************/
+
+-static irqreturn_t edma_irq_handler(int32_t irq, void * dev_id,
+- struct pt_regs * regs)
++static irqreturn_t edma_irq_handler(int32_t irq, void * dev_id)
+ {
+
+ uint32_t clear_bits;
diff --git a/package/system/ep80579-drivers/patches/.svn/text-base/500-1588_fix_irq_request_warning.patch.svn-base b/package/system/ep80579-drivers/patches/.svn/text-base/500-1588_fix_irq_request_warning.patch.svn-base
new file mode 100644
index 0000000..f3f9acb
--- /dev/null
+++ b/package/system/ep80579-drivers/patches/.svn/text-base/500-1588_fix_irq_request_warning.patch.svn-base
@@ -0,0 +1,22 @@
+--- a/Embedded/src/1588/1588.c
++++ b/Embedded/src/1588/1588.c
+@@ -631,7 +631,7 @@ int restore_interrupts(void)
+ IRQ_NONE => this device did not interrupt
+
+ ******************************************************************************/
+-irqreturn_t timesync_isr(int irq, void *dev_id, struct pt_regs *regs)
++irqreturn_t timesync_isr(int irq, void *dev_id)
+ {
+ if ( !ixTimeSyncAccEventAmmsFlagGet() && !ixTimeSyncAccEventAsmsFlagGet()&&
+ !ixTimeSyncAccEventAtmFlagGet() && !ixTimeSyncAccEventPpsmFlagGet()&&
+--- a/Embedded/src/1588/1588.h
++++ b/Embedded/src/1588/1588.h
+@@ -128,7 +128,7 @@ int pci_suspend(struct pci_dev *dev, pm_
+ int pci_resume(struct pci_dev *dev);
+ int pci_probe(struct pci_dev *dev, const struct pci_device_id *id);
+ void pci_remove(struct pci_dev *dev);
+-irqreturn_t timesync_isr(int irq, void *dev_id, struct pt_regs *regs);
++irqreturn_t timesync_isr(int irq, void *dev_id);
+
+ // private functions
+ int save_reg_state(void);
diff --git a/package/system/ep80579-drivers/patches/.svn/text-base/600-2.6.27_includes.patch.svn-base b/package/system/ep80579-drivers/patches/.svn/text-base/600-2.6.27_includes.patch.svn-base
new file mode 100644
index 0000000..c11275e
--- /dev/null
+++ b/package/system/ep80579-drivers/patches/.svn/text-base/600-2.6.27_includes.patch.svn-base
@@ -0,0 +1,22 @@
+--- a/Embedded/src/CAN/can_main.h
++++ b/Embedded/src/CAN/can_main.h
+@@ -65,7 +65,7 @@
+
+ #include <linux/interrupt.h>
+ #include <linux/pci.h>
+-#include <asm/semaphore.h>
++#include <linux/semaphore.h>
+ #include <linux/spinlock.h>
+ #include <linux/cdev.h>
+ #include <asm/uaccess.h>
+--- a/Embedded/src/EDMA/dma_linux.c
++++ b/Embedded/src/EDMA/dma_linux.c
+@@ -87,7 +87,7 @@
+ #include <linux/fcntl.h> /* O_ACCMODE */
+ #include <asm/system.h> /* cli, *_flags */
+ #include <asm/uaccess.h> /* copy_to_user */
+-#include <asm/semaphore.h>
++#include <linux/semaphore.h>
+ #include <asm/io.h> /* inb(), outb() */
+ #include <linux/kmod.h>
+ #include <linux/ioport.h> /* request_region */
diff --git a/package/system/ep80579-drivers/patches/.svn/text-base/601-2.6.32_includes.patch.svn-base b/package/system/ep80579-drivers/patches/.svn/text-base/601-2.6.32_includes.patch.svn-base
new file mode 100644
index 0000000..291fb0a
--- /dev/null
+++ b/package/system/ep80579-drivers/patches/.svn/text-base/601-2.6.32_includes.patch.svn-base
@@ -0,0 +1,30 @@
+--- a/Embedded/src/1588/1588.c
++++ b/Embedded/src/1588/1588.c
+@@ -72,6 +72,7 @@
+ *
+ ****************************************************************************/
+
++#include <linux/sched.h>
+ #include "1588.h"
+
+ MODULE_AUTHOR("Intel(R) Corporation");
+--- a/Embedded/src/CAN/can_main.c
++++ b/Embedded/src/CAN/can_main.c
+@@ -68,6 +68,7 @@
+ *
+ **************************************************************************/
+
++#include <linux/sched.h>
+ #include "can_main.h"
+ #include "can_ioctl.h"
+ #include <linux/fs.h>
+--- a/Embedded/src/WDT/iwdt.c
++++ b/Embedded/src/WDT/iwdt.c
+@@ -137,6 +137,7 @@
+ #include <linux/watchdog.h>
+ #include <linux/miscdevice.h>
+ #include <linux/interrupt.h>
++#include <linux/sched.h>
+ #include "iwdt.h"
+
+ MODULE_AUTHOR("Intel(R) Corporation");
diff --git a/package/system/ep80579-drivers/patches/.svn/text-base/700-iegbe_kcompat_2.6.30.patch.svn-base b/package/system/ep80579-drivers/patches/.svn/text-base/700-iegbe_kcompat_2.6.30.patch.svn-base
new file mode 100644
index 0000000..ca8c1bb
--- /dev/null
+++ b/package/system/ep80579-drivers/patches/.svn/text-base/700-iegbe_kcompat_2.6.30.patch.svn-base
@@ -0,0 +1,31 @@
+--- a/Embedded/src/GbE/kcompat.h
++++ b/Embedded/src/GbE/kcompat.h
+@@ -46,12 +46,6 @@ GPL LICENSE SUMMARY
+ #include <linux/sched.h>
+ #include <asm/io.h>
+
+-#ifndef IRQ_HANDLED
+-#define irqreturn_t void
+-#define IRQ_HANDLED
+-#define IRQ_NONE
+-#endif
+-
+ #ifndef SET_NETDEV_DEV
+ #define SET_NETDEV_DEV(net, pdev)
+ #endif
+@@ -748,6 +742,15 @@ extern void dump_stack(void);
+
+ #endif /* 2.4.24 */
+
++/*****************************************************************************/
++#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30) )
++#ifndef IRQ_HANDLED
++#define irqreturn_t void
++#define IRQ_HANDLED
++#define IRQ_NONE
++#endif
++#endif /* < 2.6.30 */
++
+ #endif /* _KCOMPAT_H_ */
+
+
diff --git a/package/system/ep80579-drivers/patches/.svn/text-base/701-iegbe_poll_dev.patch.svn-base b/package/system/ep80579-drivers/patches/.svn/text-base/701-iegbe_poll_dev.patch.svn-base
new file mode 100644
index 0000000..63a1326
--- /dev/null
+++ b/package/system/ep80579-drivers/patches/.svn/text-base/701-iegbe_poll_dev.patch.svn-base
@@ -0,0 +1,11 @@
+--- a/Embedded/src/GbE/iegbe_main.c
++++ b/Embedded/src/GbE/iegbe_main.c
+@@ -3534,7 +3534,7 @@ static int iegbe_clean(struct napi_struc
+ int tx_cleaned = 0, work_done = 0;
+
+ /* Must NOT use netdev_priv macro here. */
+- adapter = poll_dev->priv;
++ adapter = netdev_priv(poll_dev);
+
+ /* iegbe_clean is called per-cpu. This lock protects
+ * tx_ring[0] from being cleaned by multiple cpus
diff --git a/package/system/ep80579-drivers/patches/.svn/text-base/710-3.3-fix-generated-header-locations.patch.svn-base b/package/system/ep80579-drivers/patches/.svn/text-base/710-3.3-fix-generated-header-locations.patch.svn-base
new file mode 100644
index 0000000..793d08d
--- /dev/null
+++ b/package/system/ep80579-drivers/patches/.svn/text-base/710-3.3-fix-generated-header-locations.patch.svn-base
@@ -0,0 +1,91 @@
+--- a/Embedded/src/GbE/Makefile
++++ b/Embedded/src/GbE/Makefile
+@@ -60,19 +60,19 @@ GBE_NAME = iegbe
+ GCU_NAME = gcu
+
+ VERSION_FILE := $(KSRC)/include/linux/version.h
+-UTS_REL_FILE := $(KSRC)/include/linux/utsrelease.h
+-CONFIG_FILE := $(KSRC)/include/linux/autoconf.h
++UTS_REL_FILE := $(KSRC)/include/generated/utsrelease.h
++CONFIG_FILE := $(KSRC)/include/generated/autoconf.h
+
+ ifeq (,$(wildcard $(VERSION_FILE)))
+ $(error Linux kernel source not configured - missing version.h)
+ endif
+
+ ifeq (,$(wildcard $(CONFIG_FILE)))
+- $(error Linux kernel source not configured - missing autoconf.h)
++ $(error Linux kernel source not configured - missing autoconf.h)
+ endif
+
+ ifeq (,$(wildcard $(UTS_REL_FILE)))
+- $(error Linux kernel source not configured - missing utsrelease.h)
++ $(error Linux kernel source not configured - missing utsrelease.h)
+ endif
+
+ # set the install path
+--- a/Embedded/src/1588/Makefile
++++ b/Embedded/src/1588/Makefile
+@@ -97,8 +97,8 @@ OUTPUT_PATH ?= /
+ EXTRA_LDFLAGS += -whole-archive
+
+ VERSION_FILE := $(KOBJ)/include/linux/version.h
+-UTS_REL_FILE := $(KSRC)/include/linux/utsrelease.h
+-CONFIG_FILE := $(KOBJ)/include/linux/autoconf.h
++UTS_REL_FILE := $(KSRC)/include/generated/utsrelease.h
++CONFIG_FILE := $(KOBJ)/include/generated/autoconf.h
+
+
+ # as of 2.6.16, kernel define UTS_RELEASE has been moved to utsrelease.h
+--- a/Embedded/src/CAN/Makefile
++++ b/Embedded/src/CAN/Makefile
+@@ -100,8 +100,8 @@ OUTPUT_PATH ?= /
+ EXTRA_LDFLAGS += -whole-archive
+
+ VERSION_FILE := $(KOBJ)/include/linux/version.h
+-UTS_REL_FILE := $(KSRC)/include/linux/utsrelease.h
+-CONFIG_FILE := $(KOBJ)/include/linux/autoconf.h
++UTS_REL_FILE := $(KSRC)/include/generated/utsrelease.h
++CONFIG_FILE := $(KOBJ)/include/generated/autoconf.h
+
+
+ # as of 2.6.16, kernel define UTS_RELEASE has been moved to utsrelease.h
+--- a/Embedded/src/EDMA/Makefile
++++ b/Embedded/src/EDMA/Makefile
+@@ -114,8 +114,8 @@ OUTPUT_PATH ?= /
+ EXTRA_LDFLAGS += -whole-archive
+
+ VERSION_FILE := $(KOBJ)/include/linux/version.h
+-UTS_REL_FILE := $(KSRC)/include/linux/utsrelease.h
+-CONFIG_FILE := $(KOBJ)/include/linux/autoconf.h
++UTS_REL_FILE := $(KSRC)/include/generated/utsrelease.h
++CONFIG_FILE := $(KOBJ)/include/generated/autoconf.h
+
+
+ # as of 2.6.16, kernel define UTS_RELEASE has been moved to utsrelease.h
+--- a/Embedded/src/GPIO/Makefile
++++ b/Embedded/src/GPIO/Makefile
+@@ -97,8 +97,8 @@ OUTPUT_PATH ?= /
+ EXTRA_LDFLAGS += -whole-archive
+
+ VERSION_FILE := $(KOBJ)/include/linux/version.h
+-UTS_REL_FILE := $(KSRC)/include/linux/utsrelease.h
+-CONFIG_FILE := $(KOBJ)/include/linux/autoconf.h
++UTS_REL_FILE := $(KSRC)/include/generated/utsrelease.h
++CONFIG_FILE := $(KOBJ)/include/generated/autoconf.h
+
+
+ # as of 2.6.16, kernel define UTS_RELEASE has been moved to utsrelease.h
+--- a/Embedded/src/WDT/Makefile
++++ b/Embedded/src/WDT/Makefile
+@@ -99,8 +99,8 @@ OUTPUT_PATH ?= /
+ EXTRA_LDFLAGS += -whole-archive
+
+ VERSION_FILE := $(KOBJ)/include/linux/version.h
+-UTS_REL_FILE := $(KSRC)/include/linux/utsrelease.h
+-CONFIG_FILE := $(KOBJ)/include/linux/autoconf.h
++UTS_REL_FILE := $(KSRC)/include/generated/utsrelease.h
++CONFIG_FILE := $(KOBJ)/include/generated/autoconf.h
+
+
+ # as of 2.6.16, kernel define UTS_RELEASE has been moved to utsrelease.h
diff --git a/package/system/ep80579-drivers/patches/.svn/text-base/711-3.3-gbe-fixes.patch.svn-base b/package/system/ep80579-drivers/patches/.svn/text-base/711-3.3-gbe-fixes.patch.svn-base
new file mode 100644
index 0000000..7b2df63
--- /dev/null
+++ b/package/system/ep80579-drivers/patches/.svn/text-base/711-3.3-gbe-fixes.patch.svn-base
@@ -0,0 +1,392 @@
+--- a/Embedded/src/GbE/kcompat.h
++++ b/Embedded/src/GbE/kcompat.h
+@@ -590,6 +590,10 @@ static inline void _kc_synchronize_irq()
+ #define ETHTOOL_OPS_COMPAT
+ #endif
+
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
++#define HAVE_NETIF_MSG 1
++#endif
++
+ #ifndef HAVE_NETIF_MSG
+ #define HAVE_NETIF_MSG 1
+ enum {
+--- a/Embedded/src/GbE/iegbe_main.c
++++ b/Embedded/src/GbE/iegbe_main.c
+@@ -159,9 +159,9 @@ static void iegbe_smartspeed(struct iegb
+ static inline int iegbe_82547_fifo_workaround(struct iegbe_adapter *adapter,
+ struct sk_buff *skb);
+
+-static void iegbe_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp);
+-static void iegbe_vlan_rx_add_vid(struct net_device *netdev, uint16_t vid);
+-static void iegbe_vlan_rx_kill_vid(struct net_device *netdev, uint16_t vid);
++static bool iegbe_vlan_used(struct iegbe_adapter *adapter);
++static int iegbe_vlan_rx_add_vid(struct net_device *netdev, uint16_t vid);
++static int iegbe_vlan_rx_kill_vid(struct net_device *netdev, uint16_t vid);
+ static void iegbe_restore_vlan(struct iegbe_adapter *adapter);
+
+ static int iegbe_notify_reboot(struct notifier_block *,
+@@ -324,8 +324,8 @@ static void iegbe_update_mng_vlan(struct
+ struct net_device *netdev = adapter->netdev;
+ u16 vid = hw->mng_cookie.vlan_id;
+ u16 old_vid = adapter->mng_vlan_id;
+- if (adapter->vlgrp) {
+- if (!vlan_group_get_device(adapter->vlgrp, vid)) {
++ if (iegbe_vlan_used(adapter)) {
++ if (!test_bit(old_vid, adapter->active_vlans)) {
+ if (hw->mng_cookie.status &
+ E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) {
+ iegbe_vlan_rx_add_vid(netdev, vid);
+@@ -335,7 +335,7 @@ static void iegbe_update_mng_vlan(struct
+
+ if ((old_vid != (u16)E1000_MNG_VLAN_NONE) &&
+ (vid != old_vid) &&
+- !vlan_group_get_device(adapter->vlgrp, old_vid))
++ !test_bit(old_vid, adapter->active_vlans))
+ iegbe_vlan_rx_kill_vid(netdev, old_vid);
+ } else
+ adapter->mng_vlan_id = vid;
+@@ -736,7 +736,6 @@ static const struct net_device_ops iegbe
+ .ndo_do_ioctl = iegbe_ioctl,
+ .ndo_validate_addr = eth_validate_addr,
+
+- .ndo_vlan_rx_register = iegbe_vlan_rx_register,
+ .ndo_vlan_rx_add_vid = iegbe_vlan_rx_add_vid,
+ .ndo_vlan_rx_kill_vid = iegbe_vlan_rx_kill_vid,
+ #ifdef CONFIG_NET_POLL_CONTROLLER
+@@ -767,7 +766,6 @@ static int __devinit iegbe_probe(struct
+ u16 eeprom_data = 0;
+ u16 eeprom_apme_mask = E1000_EEPROM_APME;
+ int bars;
+- DECLARE_MAC_BUF(mac);
+
+ bars = pci_select_bars(pdev, IORESOURCE_MEM);
+ err = pci_enable_device(pdev);
+@@ -1247,8 +1245,7 @@ static int iegbe_close(struct net_device
+
+ if ((hw->mng_cookie.status &
+ E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) &&
+- !(adapter->vlgrp &&
+- vlan_group_get_device(adapter->vlgrp, adapter->mng_vlan_id))) {
++ !test_bit(adapter->mng_vlan_id, adapter->active_vlans)) {
+ iegbe_vlan_rx_kill_vid(netdev, adapter->mng_vlan_id);
+ }
+ return 0;
+@@ -2163,11 +2160,13 @@ static void iegbe_set_rx_mode(struct net
+ struct iegbe_hw *hw = &adapter->hw;
+ struct netdev_hw_addr *ha;
+ bool use_uc = false;
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
+ struct dev_addr_list *mc_ptr;
+- u32 rctl;
+ u32 hash_value;
+- int i, rar_entries = E1000_RAR_ENTRIES;
+ int mta_reg_count = E1000_NUM_MTA_REGISTERS;
++#endif
++ u32 rctl;
++ int i, rar_entries = E1000_RAR_ENTRIES;
+
+ /* reserve RAR[14] for LAA over-write work-around */
+ if (hw->mac_type == iegbe_82571)
+@@ -2220,6 +2219,7 @@ int mta_reg_count = E1000_NUM_MTA_REGIST
+
+ WARN_ON(i == rar_entries);
+
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
+ mc_ptr = netdev->mc_list;
+
+ for (; i < rar_entries; i++) {
+@@ -2247,6 +2247,7 @@ int mta_reg_count = E1000_NUM_MTA_REGIST
+ hash_value = iegbe_hash_mc_addr(hw, mc_ptr->da_addr);
+ iegbe_mta_set(hw, hash_value);
+ }
++#endif
+
+ if (hw->mac_type == iegbe_82542_rev2_0)
+ iegbe_leave_82542_rst(adapter);
+@@ -2821,14 +2822,14 @@ static int iegbe_tx_map(struct iegbe_ada
+ * Avoid terminating buffers within evenly-aligned
+ * dwords. */
+ if(unlikely(adapter->pcix_82544 &&
+- !((unsigned long)(frag->page+offset+size-1) & 4) &&
++ !((unsigned long)(frag->page.p+offset+size-1) & 4) &&
+ size > 4))
+ size -= 4;
+
+ buffer_info->length = size;
+ buffer_info->dma =
+ pci_map_page(adapter->pdev,
+- frag->page,
++ frag->page.p,
+ offset,
+ size,
+ PCI_DMA_TODEVICE);
+@@ -3131,7 +3132,7 @@ static int iegbe_xmit_frame(struct sk_bu
+ }
+ }
+
+- if (unlikely(adapter->vlgrp && vlan_tx_tag_present(skb))) {
++ if (unlikely(iegbe_vlan_used(adapter) && vlan_tx_tag_present(skb))) {
+ tx_flags |= E1000_TX_FLAGS_VLAN;
+ tx_flags |= (vlan_tx_tag_get(skb) << E1000_TX_FLAGS_VLAN_SHIFT);
+ }
+@@ -3832,10 +3833,12 @@ static bool iegbe_clean_rx_irq(struct ie
+
+ skb->protocol = eth_type_trans(skb, netdev);
+
+- if (unlikely(adapter->vlgrp &&
++ if (unlikely(iegbe_vlan_used(adapter) &&
+ (status & E1000_RXD_STAT_VP))) {
+- vlan_hwaccel_receive_skb(skb, adapter->vlgrp,
+- le16_to_cpu(rx_desc->special));
++ u16 vid;
++
++ vid = le16_to_cpu(rx_desc->special);
++ __vlan_hwaccel_put_tag(skb, vid);
+ } else {
+ netif_receive_skb(skb);
+ }
+@@ -3986,9 +3989,10 @@ copydone:
+ cpu_to_le16(E1000_RXDPS_HDRSTAT_HDRSP)))
+ adapter->rx_hdr_split++;
+
+- if(unlikely(adapter->vlgrp && (staterr & E1000_RXD_STAT_VP))) {
+- vlan_hwaccel_receive_skb(skb, adapter->vlgrp,
+- le16_to_cpu(rx_desc->wb.middle.vlan));
++ if(unlikely(iegbe_vlan_used(adapter) && (staterr & E1000_RXD_STAT_VP))) {
++ u16 vid;
++ vid = le16_to_cpu(rx_desc->wb.middle.vlan);
++ __vlan_hwaccel_put_tag(skb, vid);
+ } else {
+ netif_receive_skb(skb);
+ }
+@@ -4496,17 +4500,25 @@ iegbe_io_write(struct iegbe_hw *hw, unsi
+ outl(value, port);
+ }
+
+-static void iegbe_vlan_rx_register(struct net_device *netdev,
+- struct vlan_group *grp)
++static bool iegbe_vlan_used(struct iegbe_adapter *adapter)
++{
++ u16 vid;
++
++ for_each_set_bit(vid, adapter->active_vlans, VLAN_N_VID)
++ return true;
++
++ return false;
++}
++
++static void iegbe_vlan_mode(struct net_device *netdev, bool vlan_on)
+ {
+ struct iegbe_adapter *adapter = netdev_priv(netdev);
+ uint32_t ctrl, rctl;
+
+ if (!test_bit(__E1000_DOWN, &adapter->flags))
+ iegbe_irq_disable(adapter);
+- adapter->vlgrp = grp;
+
+- if(grp) {
++ if(vlan_on) {
+ /* enable VLAN tag insert/strip */
+ ctrl = E1000_READ_REG(&adapter->hw, CTRL);
+ ctrl |= E1000_CTRL_VME;
+@@ -4538,30 +4550,37 @@ static void iegbe_vlan_rx_register(struc
+ iegbe_irq_enable(adapter);
+ }
+
+-static void iegbe_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
++static int iegbe_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
+ {
+ struct iegbe_adapter *adapter = netdev_priv(netdev);
+ uint32_t vfta, index;
+ if((adapter->hw.mng_cookie.status &
+ E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) &&
+ (vid == adapter->mng_vlan_id)) {
+- return;
++ return 0;
+ }
++
++ if (!iegbe_vlan_used(adapter))
++ iegbe_vlan_mode(netdev, true);
++
+ /* add VID to filter table */
+ index = (vid >> 0x5) & 0x7F;
+ vfta = E1000_READ_REG_ARRAY(&adapter->hw, VFTA, index);
+ vfta |= (0x1 << (vid & 0x1F));
+ iegbe_write_vfta(&adapter->hw, index, vfta);
++
++ set_bit(vid, adapter->active_vlans);
++
++ return 0;
+ }
+
+-static void iegbe_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
++static int iegbe_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
+ {
+ struct iegbe_adapter *adapter = netdev_priv(netdev);
+ u32 vfta, index;
+
+ if (!test_bit(__E1000_DOWN, &adapter->flags))
+ iegbe_irq_disable(adapter);
+- vlan_group_set_device(adapter->vlgrp, vid, NULL);
+ if (!test_bit(__E1000_DOWN, &adapter->flags))
+ iegbe_irq_enable(adapter);
+
+@@ -4570,21 +4589,26 @@ static void iegbe_vlan_rx_kill_vid(struc
+ vfta = E1000_READ_REG_ARRAY(&adapter->hw, VFTA, index);
+ vfta &= ~(0x1 << (vid & 0x1F));
+ iegbe_write_vfta(&adapter->hw, index, vfta);
++
++ clear_bit(vid, adapter->active_vlans);
++
++ if (!iegbe_vlan_used(adapter))
++ iegbe_vlan_mode(netdev, false);
++
++ return 0;
+ }
+
+ static void iegbe_restore_vlan(struct iegbe_adapter *adapter)
+ {
+- iegbe_vlan_rx_register(adapter->netdev, adapter->vlgrp);
+-
+- if (adapter->vlgrp) {
+ u16 vid;
+- for (vid = 0x0; vid < VLAN_GROUP_ARRAY_LEN; vid++) {
+- if (!vlan_group_get_device(adapter->vlgrp, vid))
+- continue;
++
++ if (!iegbe_vlan_used(adapter))
++ return;
++
++ iegbe_vlan_mode(adapter->netdev, true);
++ for_each_set_bit(vid, adapter->active_vlans, VLAN_N_VID)
+ iegbe_vlan_rx_add_vid(adapter->netdev, vid);
+ }
+- }
+-}
+
+
+ int iegbe_set_spd_dplx(struct iegbe_adapter *adapter, u16 spddplx)
+@@ -4864,10 +4888,11 @@ iegbe_resume(struct pci_dev *pdev)
+ default:
+ break;
+ }
+-#endif
+
+ return 0x0;
+ }
++#endif
++
+
+ #ifdef CONFIG_NET_POLL_CONTROLLER
+ /*
+--- a/Embedded/src/GbE/iegbe_ethtool.c
++++ b/Embedded/src/GbE/iegbe_ethtool.c
+@@ -327,6 +327,7 @@ iegbe_set_pauseparam(struct net_device *
+ return 0;
+ }
+
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
+ static uint32_t
+ iegbe_get_rx_csum(struct net_device *netdev)
+ {
+@@ -392,6 +393,7 @@ iegbe_set_tso(struct net_device *netdev,
+ return 0;
+ }
+ #endif /* NETIF_F_TSO */
++#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0)) */
+
+ static uint32_t
+ iegbe_get_msglevel(struct net_device *netdev)
+@@ -807,6 +809,7 @@ err_setup_rx:
+ E1000_82542_##R : E1000_##R; \
+ return 1; } }
+
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
+ static int
+ iegbe_reg_test(struct iegbe_adapter *adapter, uint64_t *data)
+ {
+@@ -1710,6 +1713,7 @@ iegbe_diag_test(struct net_device *netde
+ }
+ msleep_interruptible(0xfa0);
+ }
++#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0)) */
+
+ static void
+ iegbe_get_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
+@@ -1812,6 +1816,7 @@ iegbe_set_wol(struct net_device *netdev,
+ /* bit defines for adapter->led_status */
+ #define E1000_LED_ON 0
+
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
+ static void
+ iegbe_led_blink_callback(unsigned long data)
+ {
+@@ -1864,6 +1869,7 @@ iegbe_phys_id(struct net_device *netdev,
+
+ return 0;
+ }
++#endif
+
+ static int
+ iegbe_nway_reset(struct net_device *netdev)
+@@ -1876,11 +1882,13 @@ iegbe_nway_reset(struct net_device *netd
+ return 0;
+ }
+
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
+ static int
+ iegbe_get_stats_count(struct net_device *netdev)
+ {
+ return E1000_STATS_LEN;
+ }
++#endif
+
+ static void
+ iegbe_get_ethtool_stats(struct net_device *netdev,
+@@ -1936,6 +1944,8 @@ struct ethtool_ops iegbe_ethtool_ops = {
+ .set_ringparam = iegbe_set_ringparam,
+ .get_pauseparam = iegbe_get_pauseparam,
+ .set_pauseparam = iegbe_set_pauseparam,
++
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
+ .get_rx_csum = iegbe_get_rx_csum,
+ .set_rx_csum = iegbe_set_rx_csum,
+ .get_tx_csum = iegbe_get_tx_csum,
+@@ -1946,11 +1956,13 @@ struct ethtool_ops iegbe_ethtool_ops = {
+ .get_tso = ethtool_op_get_tso,
+ .set_tso = iegbe_set_tso,
+ #endif
++
+ .self_test_count = iegbe_diag_test_count,
+ .self_test = iegbe_diag_test,
+- .get_strings = iegbe_get_strings,
+ .phys_id = iegbe_phys_id,
+ .get_stats_count = iegbe_get_stats_count,
++#endif
++ .get_strings = iegbe_get_strings,
+ .get_ethtool_stats = iegbe_get_ethtool_stats,
+ };
+
+--- a/Embedded/src/GbE/gcu_main.c
++++ b/Embedded/src/GbE/gcu_main.c
+@@ -93,7 +93,7 @@ static struct pci_driver gcu_driver = {
+ };
+
+ static struct gcu_adapter *global_adapter = 0;
+-static spinlock_t global_adapter_spinlock = SPIN_LOCK_UNLOCKED;
++static DEFINE_SPINLOCK(global_adapter_spinlock);
+ static unsigned long g_intflags = 0;
+
+ MODULE_AUTHOR("Intel(R) Corporation");
+--- a/Embedded/src/GbE/iegbe.h
++++ b/Embedded/src/GbE/iegbe.h
+@@ -257,7 +257,7 @@ struct iegbe_adapter {
+ struct timer_list tx_fifo_stall_timer;
+ struct timer_list watchdog_timer;
+ struct timer_list phy_info_timer;
+- struct vlan_group *vlgrp;
++ unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
+ uint16_t mng_vlan_id;
+ uint32_t bd_number;
+ uint32_t rx_buffer_len;
diff --git a/package/system/ep80579-drivers/patches/.svn/text-base/712-3.3-can-fixes.patch.svn-base b/package/system/ep80579-drivers/patches/.svn/text-base/712-3.3-can-fixes.patch.svn-base
new file mode 100644
index 0000000..f46f900
--- /dev/null
+++ b/package/system/ep80579-drivers/patches/.svn/text-base/712-3.3-can-fixes.patch.svn-base
@@ -0,0 +1,41 @@
+--- a/Embedded/src/CAN/can_main.c
++++ b/Embedded/src/CAN/can_main.c
+@@ -72,6 +72,7 @@
+ #include "can_main.h"
+ #include "can_ioctl.h"
+ #include <linux/fs.h>
++#include <linux/module.h>
+
+
+ MODULE_AUTHOR("Intel(R) Corporation");
+@@ -110,7 +111,7 @@ struct file_operations file_ops = {
+ .owner = THIS_MODULE,
+ .read = can_read,
+ .write = can_write,
+- .ioctl = can_dev_io,
++ .unlocked_ioctl = can_dev_io,
+ .open = can_open,
+ .release = can_release
+ };
+@@ -594,8 +595,7 @@ int icp_can_reset(can_os_t *can_os)
+ /*****************************************************************************
+ * Device IO control function. Used by user apps to configure CAN device.
+ *****************************************************************************/
+-int can_dev_io(struct inode *inode, struct file *filp, unsigned int cmd,
+- unsigned long arg)
++long can_dev_io(struct file *filp, unsigned int cmd, unsigned long arg)
+ {
+ can_os_t *can_os;
+ unsigned int err=0;
+--- a/Embedded/src/CAN/can_main.h
++++ b/Embedded/src/CAN/can_main.h
+@@ -157,8 +157,7 @@ ssize_t can_write(
+ int icp_can_reset(
+ can_os_t *can_os);
+
+-int can_dev_io(
+- struct inode *inode,
++long can_dev_io(
+ struct file *filp,
+ unsigned int cmd,
+ unsigned long arg);
diff --git a/package/system/ep80579-drivers/patches/.svn/text-base/713-3.3-gpio-fixes.patch.svn-base b/package/system/ep80579-drivers/patches/.svn/text-base/713-3.3-gpio-fixes.patch.svn-base
new file mode 100644
index 0000000..47fb920
--- /dev/null
+++ b/package/system/ep80579-drivers/patches/.svn/text-base/713-3.3-gpio-fixes.patch.svn-base
@@ -0,0 +1,33 @@
+--- a/Embedded/src/GPIO/gpio.h
++++ b/Embedded/src/GPIO/gpio.h
+@@ -121,8 +121,7 @@ int gpio_init(void);
+ void gpio_close(void);
+ int gpio_open(struct inode *inode, struct file *filp);
+ int gpio_release(struct inode *inode, struct file *filp);
+-int gpio_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
+- unsigned long arg);
++long gpio_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
+
+ // private driver functions
+ int gpio_getpininfo(int Signal, char *pBuff);
+@@ -134,7 +133,7 @@ struct file_operations file_ops =
+ .owner = THIS_MODULE,
+ .open = gpio_open,
+ .release = gpio_release,
+- .ioctl = gpio_ioctl,
++ .unlocked_ioctl = gpio_ioctl,
+ };
+
+ #endif
+--- a/Embedded/src/GPIO/gpio_ref.c
++++ b/Embedded/src/GPIO/gpio_ref.c
+@@ -251,8 +251,7 @@ int gpio_release(struct inode *inode, st
+ 0 => success
+ < 0 => error
+ ******************************************************************************/
+-int gpio_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
+- unsigned long arg)
++long gpio_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
+ {
+ gpio_ioctl_t Info;
+ u_int bitstr = 0;
diff --git a/package/system/ep80579-drivers/patches/.svn/text-base/714-3.3-wdt-fixes.patch.svn-base b/package/system/ep80579-drivers/patches/.svn/text-base/714-3.3-wdt-fixes.patch.svn-base
new file mode 100644
index 0000000..60cc4ae
--- /dev/null
+++ b/package/system/ep80579-drivers/patches/.svn/text-base/714-3.3-wdt-fixes.patch.svn-base
@@ -0,0 +1,31 @@
+--- a/Embedded/src/WDT/iwdt.c
++++ b/Embedded/src/WDT/iwdt.c
+@@ -217,8 +217,7 @@ static int wdt_open(struct inode *inode,
+ static int wdt_release(struct inode *inode, struct file *file);
+ static ssize_t wdt_write(struct file *file, const char *data,
+ size_t count, loff_t * pos);
+-static int wdt_ioctl(struct inode *inode, struct file *file,
+- unsigned int cmd, unsigned long arg);
++static long wdt_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
+ static irqreturn_t wdt_isr(int irq, void *dev_id);
+ static void __exit wdt_cleanup(void);
+ static int __init wdt_init(void);
+@@ -243,7 +242,7 @@ static struct pci_device_id lpc_pci_tbl[
+ static struct file_operations wdt_fops = {
+ owner: THIS_MODULE,
+ write: wdt_write,
+- ioctl: wdt_ioctl,
++ unlocked_ioctl: wdt_ioctl,
+ open: wdt_open,
+ release: wdt_release,
+ };
+@@ -1201,8 +1200,7 @@ char *wdt_get_ioctl_string(unsigned int
+ * Return Value: 0 - successful, negative value - failed.
+ * Description: This function is used to provide IO interface.
+ */
+-static int wdt_ioctl(struct inode *inode, struct file *file,
+- unsigned int cmd, unsigned long arg)
++static long wdt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+ {
+ u8 mode=0, scale=0, int_type=0;
+ u32 u_margin=0, dcount=0;
diff --git a/package/system/ep80579-drivers/patches/.svn/text-base/715-3.3-1588-fixes.patch.svn-base b/package/system/ep80579-drivers/patches/.svn/text-base/715-3.3-1588-fixes.patch.svn-base
new file mode 100644
index 0000000..ac5dd1f
--- /dev/null
+++ b/package/system/ep80579-drivers/patches/.svn/text-base/715-3.3-1588-fixes.patch.svn-base
@@ -0,0 +1,33 @@
+--- a/Embedded/src/1588/1588.c
++++ b/Embedded/src/1588/1588.c
+@@ -664,8 +664,7 @@ irqreturn_t timesync_isr(int irq, void *
+ 0 => success
+ < 0 => error
+ ******************************************************************************/
+-int timesync_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
+- unsigned long arg)
++long timesync_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
+ {
+ wait_queue_head_t *event = NULL;
+ unsigned int bytes_ret = 0;
+--- a/Embedded/src/1588/1588.h
++++ b/Embedded/src/1588/1588.h
+@@ -121,8 +121,7 @@ MODULE_DEVICE_TABLE(pci, pci_ids);
+ // Linux functions
+ int timesync_open(struct inode *inode, struct file *filp);
+ int timesync_release(struct inode *inode, struct file *filp);
+-int timesync_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
+- unsigned long arg);
++long timesync_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
+ void timesync_close(void);
+ int pci_suspend(struct pci_dev *dev, pm_message_t state);
+ int pci_resume(struct pci_dev *dev);
+@@ -142,7 +141,7 @@ struct file_operations file_ops =
+ .owner = THIS_MODULE,
+ .open = timesync_open,
+ .release = timesync_release,
+- .ioctl = timesync_ioctl,
++ .unlocked_ioctl = timesync_ioctl,
+ };
+
+ // Linux pci operations
diff --git a/package/system/ep80579-drivers/patches/001-igbe_update.patch b/package/system/ep80579-drivers/patches/001-igbe_update.patch
new file mode 100644
index 0000000..80ca0ef
--- /dev/null
+++ b/package/system/ep80579-drivers/patches/001-igbe_update.patch
@@ -0,0 +1,11755 @@
+--- a/Embedded/src/GbE/gcu.h
++++ b/Embedded/src/GbE/gcu.h
+@@ -2,7 +2,7 @@
+
+ GPL LICENSE SUMMARY
+
+- Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
++ Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of version 2 of the GNU General Public License as
+@@ -22,7 +22,7 @@ GPL LICENSE SUMMARY
+ Contact Information:
+ Intel Corporation
+
+- version: Embedded.L.1.0.34
++ version: Embedded.Release.Patch.L.1.0.7-5
+
+ Contact Information:
+
+--- a/Embedded/src/GbE/gcu_if.c
++++ b/Embedded/src/GbE/gcu_if.c
+@@ -2,7 +2,7 @@
+
+ GPL LICENSE SUMMARY
+
+- Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
++ Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of version 2 of the GNU General Public License as
+@@ -22,7 +22,7 @@ GPL LICENSE SUMMARY
+ Contact Information:
+ Intel Corporation
+
+- version: Embedded.L.1.0.34
++ version: Embedded.Release.Patch.L.1.0.7-5
+
+ Contact Information:
+
+@@ -330,10 +330,17 @@ gcu_write_verify(uint32_t phy_num, uint3
+ */
+ void gcu_iegbe_resume(struct pci_dev *pdev)
+ {
++#if ( ( LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,6) ) && \
++ ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10) ) )
++ struct net_device *netdev = pci_get_drvdata(pdev);
++ struct gcu_adapter *adapter = netdev_priv(netdev);
++#endif
++
+ GCU_DBG("%s\n", __func__);
+
+ pci_restore_state(pdev);
+- pci_enable_device(pdev);
++ if(!pci_enable_device(pdev))
++ GCU_DBG("pci_enable_device failed!\n",);
+
+ return;
+ }
+@@ -348,6 +355,12 @@ EXPORT_SYMBOL(gcu_iegbe_resume);
+ */
+ int gcu_iegbe_suspend(struct pci_dev *pdev, uint32_t state)
+ {
++#if ( ( LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,6) ) && \
++ ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10) ) )
++ struct net_device *netdev = pci_get_drvdata(pdev);
++ struct gcu_adapter *adapter = netdev_priv(netdev);
++#endif
++
+ GCU_DBG("%s\n", __func__);
+
+ pci_save_state(pdev);
+--- a/Embedded/src/GbE/gcu_if.h
++++ b/Embedded/src/GbE/gcu_if.h
+@@ -2,7 +2,7 @@
+
+ GPL LICENSE SUMMARY
+
+- Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
++ Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of version 2 of the GNU General Public License as
+@@ -22,7 +22,7 @@ GPL LICENSE SUMMARY
+ Contact Information:
+ Intel Corporation
+
+- version: Embedded.L.1.0.34
++ version: Embedded.Release.Patch.L.1.0.7-5
+
+ Contact Information:
+
+--- a/Embedded/src/GbE/gcu_main.c
++++ b/Embedded/src/GbE/gcu_main.c
+@@ -2,7 +2,7 @@
+
+ GPL LICENSE SUMMARY
+
+- Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
++ Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of version 2 of the GNU General Public License as
+@@ -22,7 +22,7 @@ GPL LICENSE SUMMARY
+ Contact Information:
+ Intel Corporation
+
+- version: Embedded.L.1.0.34
++ version: Embedded.Release.Patch.L.1.0.7-5
+
+ Contact Information:
+
+@@ -94,6 +94,7 @@ static struct pci_driver gcu_driver = {
+
+ static struct gcu_adapter *global_adapter = 0;
+ static spinlock_t global_adapter_spinlock = SPIN_LOCK_UNLOCKED;
++static unsigned long g_intflags = 0;
+
+ MODULE_AUTHOR("Intel(R) Corporation");
+ MODULE_DESCRIPTION("Global Configuration Unit Driver");
+@@ -124,7 +125,7 @@ gcu_init_module(void)
+
+ printk(KERN_INFO "%s\n", gcu_copyright);
+
+- ret = pci_module_init(&gcu_driver);
++ ret = pci_register_driver(&gcu_driver);
+ if(ret >= 0) {
+ register_reboot_notifier(&gcu_notifier_reboot);
+ }
+@@ -199,8 +200,6 @@ gcu_probe(struct pci_dev *pdev,
+ return -ENOMEM;
+ }
+
+- SET_MODULE_OWNER(adapter);
+-
+ pci_set_drvdata(pdev, adapter);
+
+ adapter->pdev = pdev;
+@@ -238,7 +237,6 @@ gcu_probe(struct pci_dev *pdev,
+ return 0;
+ }
+
+-
+ /**
+ * gcu_probe_err - gcu_probe error handler
+ * @err: gcu_err_type
+@@ -295,7 +293,7 @@ gcu_notify_reboot(struct notifier_block
+ case SYS_DOWN:
+ case SYS_HALT:
+ case SYS_POWER_OFF:
+- while((pdev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pdev))) {
++ while((pdev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pdev))) {
+ if(pci_dev_driver(pdev) == &gcu_driver){
+ gcu_suspend(pdev, 0x3);
+ }
+@@ -318,6 +316,11 @@ static int
+ gcu_suspend(struct pci_dev *pdev, uint32_t state)
+ {
+ /*struct gcu_adapter *adapter = pci_get_drvdata(pdev); */
++#if ( ( LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,6) ) && \
++ ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10) ) )
++ struct net_device *netdev = pci_get_drvdata(pdev);
++ struct gcu_adapter *adapter = netdev_priv(netdev);
++#endif
+
+ GCU_DBG("%s\n", __func__);
+
+@@ -338,7 +341,6 @@ gcu_suspend(struct pci_dev *pdev, uint32
+ return state;
+ }
+
+-
+ /**
+ * alloc_gcu_adapter
+ *
+@@ -412,7 +414,7 @@ gcu_get_adapter(void)
+ return NULL;
+ }
+
+- spin_lock(&global_adapter_spinlock);
++ spin_lock_irqsave(&global_adapter_spinlock, g_intflags);
+
+ return global_adapter;
+ }
+@@ -437,7 +439,7 @@ gcu_release_adapter(const struct gcu_ada
+ *adapter = 0;
+ }
+
+- spin_unlock(&global_adapter_spinlock);
++ spin_unlock_irqrestore(&global_adapter_spinlock, g_intflags);
+
+ return;
+ }
+--- a/Embedded/src/GbE/gcu_reg.h
++++ b/Embedded/src/GbE/gcu_reg.h
+@@ -2,7 +2,7 @@
+
+ GPL LICENSE SUMMARY
+
+- Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
++ Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of version 2 of the GNU General Public License as
+@@ -22,7 +22,7 @@ GPL LICENSE SUMMARY
+ Contact Information:
+ Intel Corporation
+
+- version: Embedded.L.1.0.34
++ version: Embedded.Release.Patch.L.1.0.7-5
+
+ Contact Information:
+
+--- a/Embedded/src/GbE/iegbe.7
++++ b/Embedded/src/GbE/iegbe.7
+@@ -1,7 +1,7 @@
+
+ .\" GPL LICENSE SUMMARY
+ .\"
+-.\" Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
++.\" Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
+ .\"
+ .\" This program is free software; you can redistribute it and/or modify
+ .\" it under the terms of version 2 of the GNU General Public License as
+@@ -21,7 +21,7 @@
+ .\" Contact Information:
+ .\" Intel Corporation
+ .\"
+-.\" version: Embedded.L.1.0.34
++.\" version: Embedded.Release.Patch.L.1.0.7-5
+
+ .\" LICENSE
+ .\"
+--- a/Embedded/src/GbE/iegbe_ethtool.c
++++ b/Embedded/src/GbE/iegbe_ethtool.c
+@@ -2,7 +2,7 @@
+
+ GPL LICENSE SUMMARY
+
+- Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
++ Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of version 2 of the GNU General Public License as
+@@ -22,7 +22,7 @@ GPL LICENSE SUMMARY
+ Contact Information:
+ Intel Corporation
+
+- version: Embedded.L.1.0.34
++ version: Embedded.Release.Patch.L.1.0.7-5
+
+ Contact Information:
+
+@@ -132,22 +132,6 @@ static const struct iegbe_stats iegbe_gs
+ { "cpp_master", E1000_STAT(icr_cpp_master) },
+ { "stat", E1000_STAT(icr_stat) },
+ #endif
+-#ifdef IEGBE_GBE_WORKAROUND
+- { "txqec", E1000_STAT(stats.txqec) },
+- { "tx_next_to_clean", E1000_STAT(stats.tx_next_to_clean) },
+- { "tx_next_to_use", E1000_STAT(stats.tx_next_to_use) },
+- { "num_tx_queues", E1000_STAT(stats.num_tx_queues) },
+-
+- { "num_rx_buf_alloc", E1000_STAT(stats.num_rx_buf_alloc) },
+- { "rx_next_to_clean", E1000_STAT(stats.rx_next_to_clean) },
+- { "rx_next_to_use", E1000_STAT(stats.rx_next_to_use) },
+- { "cc_gt_num_rx", E1000_STAT(stats.cc_gt_num_rx) },
+- { "tx_hnet", E1000_STAT(stats.tx_hnet) },
+- { "tx_hnentu", E1000_STAT(stats.tx_hnentu) },
+- { "RUC", E1000_STAT(stats.ruc) },
+- { "RFC", E1000_STAT(stats.rfc) },
+-
+-#endif
+ };
+ #define E1000_STATS_LEN \
+ sizeof(iegbe_gstrings_stats) / sizeof(struct iegbe_stats)
+@@ -158,7 +142,7 @@ static const char iegbe_gstrings_test[][
+ "Interrupt test (offline)", "Loopback test (offline)",
+ "Link test (on/offline)"
+ };
+-#define E1000_TEST_LEN (sizeof(iegbe_gstrings_test) / (ETH_GSTRING_LEN))
++#define E1000_TEST_LEN (sizeof(iegbe_gstrings_test) / ETH_GSTRING_LEN)
+ #endif /* ETHTOOL_TEST */
+
+ #define E1000_REGS_LEN 0x20
+@@ -176,9 +160,7 @@ iegbe_get_settings(struct net_device *ne
+ SUPPORTED_10baseT_Full |
+ SUPPORTED_100baseT_Half |
+ SUPPORTED_100baseT_Full |
+-#ifndef IEGBE_10_100_ONLY
+ SUPPORTED_1000baseT_Full|
+-#endif
+ SUPPORTED_Autoneg |
+ SUPPORTED_TP);
+
+@@ -259,21 +241,13 @@ iegbe_set_settings(struct net_device *ne
+ ADVERTISED_10baseT_Full |
+ ADVERTISED_100baseT_Half |
+ ADVERTISED_100baseT_Full |
+-#ifndef IEGBE_10_100_ONLY
+ ADVERTISED_1000baseT_Full|
+-#endif
+-
+ ADVERTISED_Autoneg |
+ ADVERTISED_TP;
+ ecmd->advertising = hw->autoneg_advertised;
+ }
+- } else {
+- uint16_t duplex;
+-
+- // ethtool uses DUPLEX_FULL/DUPLEX_HALF
+- // the driver needs FULL_DUPLEX/HALF_DUPLEX
+- duplex = (ecmd->duplex == DUPLEX_FULL) ? FULL_DUPLEX : HALF_DUPLEX;
+- if(iegbe_set_spd_dplx(adapter, ecmd->speed + duplex))
++ } else
++ if(iegbe_set_spd_dplx(adapter, ecmd->speed + ecmd->duplex)){
+ return -EINVAL;
+ }
+ /* reset the link */
+@@ -728,8 +702,8 @@ iegbe_set_ringparam(struct net_device *n
+ struct iegbe_rx_ring *rxdr, *rx_old, *rx_new;
+ int i, err, tx_ring_size, rx_ring_size;
+
+- tx_ring_size = sizeof(struct iegbe_tx_ring) * adapter->num_queues;
+- rx_ring_size = sizeof(struct iegbe_rx_ring) * adapter->num_queues;
++ tx_ring_size = sizeof(struct iegbe_tx_ring) * adapter->num_tx_queues;
++ rx_ring_size = sizeof(struct iegbe_rx_ring) * adapter->num_rx_queues;
+
+ if (netif_running(adapter->netdev)){
+ iegbe_down(adapter);
+@@ -768,10 +742,10 @@ iegbe_set_ringparam(struct net_device *n
+ E1000_MAX_TXD : E1000_MAX_82544_TXD));
+ E1000_ROUNDUP(txdr->count, REQ_TX_DESCRIPTOR_MULTIPLE);
+
+- for (i = 0; i < adapter->num_queues; i++) {
+- txdr[i].count = txdr->count;
+- rxdr[i].count = rxdr->count;
+- }
++ for (i = 0; i < adapter->num_tx_queues; i++)
++ txdr[i].count = txdr->count;
++ for (i = 0; i < adapter->num_rx_queues; i++)
++ rxdr[i].count = rxdr->count;
+
+ if(netif_running(adapter->netdev)) {
+ /* Try to get new resources before deleting old */
+@@ -950,8 +924,7 @@ iegbe_eeprom_test(struct iegbe_adapter *
+
+ static irqreturn_t
+ iegbe_test_intr(int irq,
+- void *data,
+- struct pt_regs *regs)
++ void *data)
+ {
+ struct net_device *netdev = (struct net_device *) data;
+ struct iegbe_adapter *adapter = netdev_priv(netdev);
+@@ -973,7 +946,7 @@ iegbe_intr_test(struct iegbe_adapter *ad
+ /* Hook up test interrupt handler just for this test */
+ if(!request_irq(irq, &iegbe_test_intr, 0, netdev->name, netdev)) {
+ shared_int = FALSE;
+- } else if(request_irq(irq, &iegbe_test_intr, SA_SHIRQ,
++ } else if(request_irq(irq, &iegbe_test_intr, IRQF_SHARED,
+ netdev->name, netdev)){
+ *data = 1;
+ return -1;
+@@ -1393,7 +1366,7 @@ iegbe_set_phy_loopback(struct iegbe_adap
+ * attempt this 10 times.
+ */
+ while(iegbe_nonintegrated_phy_loopback(adapter) &&
+- count++ < 0xa) { };
++ count++ < 0xa);
+ if(count < 0xb) {
+ return 0;
+ }
+--- a/Embedded/src/GbE/iegbe.h
++++ b/Embedded/src/GbE/iegbe.h
+@@ -1,7 +1,7 @@
+ /*******************************************************************************
+ GPL LICENSE SUMMARY
+
+- Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
++ Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of version 2 of the GNU General Public License as
+@@ -21,7 +21,7 @@ GPL LICENSE SUMMARY
+ Contact Information:
+ Intel Corporation
+
+- version: Embedded.L.1.0.34
++ version: Embedded.Release.Patch.L.1.0.7-5
+
+ Contact Information:
+
+@@ -127,9 +127,12 @@ struct iegbe_adapter;
+ #define E1000_MIN_RXD 80
+ #define E1000_MAX_82544_RXD 4096
+
++#define MAXIMUM_ETHERNET_VLAN_SIZE 1522
+ /* Supported Rx Buffer Sizes */
+ #define E1000_RXBUFFER_128 128 /* Used for packet split */
+ #define E1000_RXBUFFER_256 256 /* Used for packet split */
++#define E1000_RXBUFFER_512 512
++#define E1000_RXBUFFER_1024 1024
+ #define E1000_RXBUFFER_2048 2048
+ #define E1000_RXBUFFER_4096 4096
+ #define E1000_RXBUFFER_8192 8192
+@@ -164,11 +167,9 @@ struct iegbe_adapter;
+ #define E1000_MASTER_SLAVE iegbe_ms_hw_default
+ #endif
+
+-#ifdef NETIF_F_HW_VLAN_TX
+-#define E1000_MNG_VLAN_NONE -1
+-#endif
++#define E1000_MNG_VLAN_NONE (-1)
+ /* Number of packet split data buffers (not including the header buffer) */
+-#define PS_PAGE_BUFFERS MAX_PS_BUFFERS-1
++#define PS_PAGE_BUFFERS (MAX_PS_BUFFERS - 1)
+
+ /* only works for sizes that are powers of 2 */
+ #define E1000_ROUNDUP(i, size) ((i) = (((i) + (size) - 1) & ~((size) - 1)))
+@@ -206,6 +207,7 @@ struct iegbe_tx_ring {
+ spinlock_t tx_lock;
+ uint16_t tdh;
+ uint16_t tdt;
++ boolean_t last_tx_tso;
+ uint64_t pkt;
+ };
+
+@@ -228,6 +230,9 @@ struct iegbe_rx_ring {
+ struct iegbe_ps_page *ps_page;
+ struct iegbe_ps_page_dma *ps_page_dma;
+
++ /* cpu for rx queue */
++ int cpu;
++
+ uint16_t rdh;
+ uint16_t rdt;
+ uint64_t pkt;
+@@ -252,10 +257,8 @@ struct iegbe_adapter {
+ struct timer_list tx_fifo_stall_timer;
+ struct timer_list watchdog_timer;
+ struct timer_list phy_info_timer;
+-#ifdef NETIF_F_HW_VLAN_TX
+ struct vlan_group *vlgrp;
+ uint16_t mng_vlan_id;
+-#endif
+ uint32_t bd_number;
+ uint32_t rx_buffer_len;
+ uint32_t part_num;
+@@ -265,8 +268,18 @@ struct iegbe_adapter {
+ uint16_t link_speed;
+ uint16_t link_duplex;
+ spinlock_t stats_lock;
+- atomic_t irq_sem;
+- struct work_struct tx_timeout_task;
++ spinlock_t tx_queue_lock;
++ unsigned int total_tx_bytes;
++ unsigned int total_tx_packets;
++ unsigned int total_rx_bytes;
++ unsigned int total_rx_packets;
++ /* Interrupt Throttle Rate */
++ uint32_t itr;
++ uint32_t itr_setting;
++ uint16_t tx_itr;
++ uint16_t rx_itr;
++
++ struct work_struct reset_task;
+ uint8_t fc_autoneg;
+
+ #ifdef ETHTOOL_PHYS_ID
+@@ -276,9 +289,8 @@ struct iegbe_adapter {
+
+ /* TX */
+ struct iegbe_tx_ring *tx_ring; /* One per active queue */
+-#ifdef CONFIG_E1000_MQ
+- struct iegbe_tx_ring **cpu_tx_ring; /* per-cpu */
+-#endif
++ unsigned int restart_queue;
++ unsigned long tx_queue_len;
+ uint32_t txd_cmd;
+ uint32_t tx_int_delay;
+ uint32_t tx_abs_int_delay;
+@@ -286,46 +298,33 @@ struct iegbe_adapter {
+ uint64_t gotcl_old;
+ uint64_t tpt_old;
+ uint64_t colc_old;
++ uint32_t tx_timeout_count;
+ uint32_t tx_fifo_head;
+ uint32_t tx_head_addr;
+ uint32_t tx_fifo_size;
++ uint8_t tx_timeout_factor;
+ atomic_t tx_fifo_stall;
+ boolean_t pcix_82544;
+ boolean_t detect_tx_hung;
+
+ /* RX */
+-#ifdef CONFIG_E1000_NAPI
+- boolean_t (*clean_rx) (struct iegbe_adapter *adapter,
++ bool (*clean_rx)(struct iegbe_adapter *adapter,
+ struct iegbe_rx_ring *rx_ring,
+ int *work_done, int work_to_do);
+-#else
+- boolean_t (*clean_rx) (struct iegbe_adapter *adapter,
+- struct iegbe_rx_ring *rx_ring);
+-#endif
+-
+-#ifdef IEGBE_GBE_WORKAROUND
+ void (*alloc_rx_buf) (struct iegbe_adapter *adapter,
+- struct iegbe_rx_ring *rx_ring,
+- int cleaned_count);
+-#else
+- void (*alloc_rx_buf) (struct iegbe_adapter *adapter,
+- struct iegbe_rx_ring *rx_ring);
+-#endif
+-
++ struct iegbe_rx_ring *rx_ring,
++ int cleaned_count);
+ struct iegbe_rx_ring *rx_ring; /* One per active queue */
+-#ifdef CONFIG_E1000_NAPI
++ struct napi_struct napi;
+ struct net_device *polling_netdev; /* One per active queue */
+-#endif
+-#ifdef CONFIG_E1000_MQ
+- struct net_device **cpu_netdev; /* per-cpu */
+- struct call_async_data_struct rx_sched_call_data;
+- int cpu_for_queue[4];
+-#endif
+- int num_queues;
++
++ int num_tx_queues;
++ int num_rx_queues;
+
+ uint64_t hw_csum_err;
+ uint64_t hw_csum_good;
+ uint64_t rx_hdr_split;
++ uint32_t alloc_rx_buff_failed;
+ uint32_t rx_int_delay;
+ uint32_t rx_abs_int_delay;
+ boolean_t rx_csum;
+@@ -334,8 +333,6 @@ struct iegbe_adapter {
+ uint64_t gorcl_old;
+ uint16_t rx_ps_bsize0;
+
+- /* Interrupt Throttle Rate */
+- uint32_t itr;
+
+ /* OS defined structs */
+ struct net_device *netdev;
+@@ -378,7 +375,21 @@ struct iegbe_adapter {
+ #ifdef CONFIG_PCI_MSI
+ boolean_t have_msi;
+ #endif
+-#define IEGBE_INTD_DISABLE 0x0400
++ /* to not mess up cache alignment, always add to the bottom */
++ boolean_t tso_force;
++ boolean_t smart_power_down; /* phy smart power down */
++ boolean_t quad_port_a;
++ unsigned long flags;
++ uint32_t eeprom_wol;
++ int bars;
++ int need_ioport;
+ };
++
++enum iegbe_state_t {
++ __E1000_TESTING,
++ __E1000_RESETTING,
++ __E1000_DOWN
++};
++#define IEGBE_INTD_DISABLE 0x0400
+ #endif /* _IEGBE_H_ */
+
+--- a/Embedded/src/GbE/iegbe_hw.c
++++ b/Embedded/src/GbE/iegbe_hw.c
+@@ -2,7 +2,7 @@
+
+ GPL LICENSE SUMMARY
+
+- Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
++ Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of version 2 of the GNU General Public License as
+@@ -22,7 +22,7 @@ GPL LICENSE SUMMARY
+ Contact Information:
+ Intel Corporation
+
+- version: Embedded.L.1.0.34
++ version: Embedded.Release.Patch.L.1.0.7-5
+
+ Contact Information:
+
+@@ -2115,7 +2115,7 @@ iegbe_config_mac_to_phy(struct iegbe_hw
+
+ ret_val = iegbe_oem_set_trans_gasket(hw);
+ if(ret_val){
+- return ret_val;
++ return ret_val;
+ }
+ ret_val = iegbe_oem_phy_is_full_duplex(
+ hw, (int *) &is_FullDuplex);
+@@ -2164,7 +2164,7 @@ iegbe_config_mac_to_phy(struct iegbe_hw
+ }
+ /* Write the configured values back to the Device Control Reg. */
+ E1000_WRITE_REG(hw, CTRL, ctrl);
+- return E1000_SUCCESS;
++ return ret_val;
+ }
+
+ /*****************************************************************************
+@@ -2684,7 +2684,7 @@ iegbe_check_for_link(struct iegbe_hw *hw
+
+ if(hw->autoneg_failed == 0) {
+ hw->autoneg_failed = 1;
+- return 0;
++ return E1000_SUCCESS;
+ }
+ DEBUGOUT("NOT RXing /C/, disable AutoNeg and force link.\r\n");
+
+@@ -5875,7 +5875,7 @@ iegbe_get_cable_length(struct iegbe_hw *
+ max_agc = cur_agc;
+ }
+ }
+-
++
+ /* This is to fix a Klockwork defect, that the array index might
+ * be out of bounds. 113 is table size */
+ if (cur_agc < 0x71){
+--- a/Embedded/src/GbE/iegbe_hw.h
++++ b/Embedded/src/GbE/iegbe_hw.h
+@@ -2,7 +2,7 @@
+
+ GPL LICENSE SUMMARY
+
+- Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
++ Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of version 2 of the GNU General Public License as
+@@ -22,7 +22,7 @@ GPL LICENSE SUMMARY
+ Contact Information:
+ Intel Corporation
+
+- version: Embedded.L.1.0.34
++ version: Embedded.Release.Patch.L.1.0.7-5
+
+ Contact Information:
+
+@@ -299,7 +299,7 @@ void iegbe_set_media_type(struct iegbe_h
+ /* Link Configuration */
+ int32_t iegbe_setup_link(struct iegbe_hw *hw);
+ int32_t iegbe_phy_setup_autoneg(struct iegbe_hw *hw);
+-void iegbe_config_collision_dist(struct iegbe_hw *hw);
++void iegbe_config_collision_dist(struct iegbe_hw *hw);
+ int32_t iegbe_config_fc_after_link_up(struct iegbe_hw *hw);
+ int32_t iegbe_check_for_link(struct iegbe_hw *hw);
+ int32_t iegbe_get_speed_and_duplex(struct iegbe_hw *hw, uint16_t * speed, uint16_t * duplex);
+@@ -588,14 +588,6 @@ uint8_t iegbe_arc_subsystem_valid(struct
+ * o LSC = Link Status Change
+ */
+
+-#ifdef IEGBE_GBE_WORKAROUND
+-#define IMS_ENABLE_MASK ( \
+- E1000_IMS_RXT0 | \
+- E1000_IMS_TXQE | \
+- E1000_IMS_RXDMT0 | \
+- E1000_IMS_RXSEQ | \
+- E1000_IMS_LSC)
+-#else
+ #define IMS_ENABLE_MASK ( \
+ E1000_IMS_RXT0 | \
+ E1000_IMS_TXDW | \
+@@ -606,8 +598,7 @@ uint8_t iegbe_arc_subsystem_valid(struct
+ E1000_ICR_PB | \
+ E1000_ICR_CPP_TARGET | \
+ E1000_ICR_CPP_MASTER | \
+- E1000_IMS_LSC)
+-#endif
++ E1000_ICR_LSC)
+
+ /* Number of high/low register pairs in the RAR. The RAR (Receive Address
+ * Registers) holds the directed and multicast addresses that we monitor. We
+@@ -923,10 +914,15 @@ struct iegbe_ffvt_entry {
+ #define E1000_ICS 0x000C8 /* Interrupt Cause Set - WO */
+ #define E1000_IMS 0x000D0 /* Interrupt Mask Set - RW */
+ #define E1000_IMC 0x000D8 /* Interrupt Mask Clear - WO */
+-// Register conflict, does not exist for ICP_xxxx hardware
+-// #define E1000_IAM 0x000E0 /* Interrupt Acknowledge Auto Mask */
+ #define E1000_CTRL_AUX 0x000E0 /* Aux Control -RW */
++#define E1000_IAM 0x000E0 /* Interrupt Acknowledge Auto Mask */
+ #define E1000_RCTL 0x00100 /* RX Control - RW */
++#define E1000_RDTR1 0x02820 /* RX Delay Timer (1) - RW */
++#define E1000_RDBAL1 0x02900 /* RX Descriptor Base Address Low (1) - RW */
++#define E1000_RDBAH1 0x02904 /* RX Descriptor Base Address High (1) - RW */
++#define E1000_RDLEN1 0x02908 /* RX Descriptor Length (1) - RW */
++#define E1000_RDH1 0x02910 /* RX Descriptor Head (1) - RW */
++#define E1000_RDT1 0x02918 /* RX Descriptor Tail (1) - RW */
+ #define E1000_FCTTV 0x00170 /* Flow Control Transmit Timer Value - RW */
+ #define E1000_TXCW 0x00178 /* TX Configuration Word - RW */
+ #define E1000_RXCW 0x00180 /* RX Configuration Word - RO */
+@@ -1282,8 +1278,6 @@ struct iegbe_ffvt_entry {
+ #define E1000_82542_FFMT E1000_FFMT
+ #define E1000_82542_FFVT E1000_FFVT
+ #define E1000_82542_HOST_IF E1000_HOST_IF
+-// Register conflict with ICP_xxxx hardware, no IAM
+-// #define E1000_82542_IAM E1000_IAM
+ #define E1000_82542_EEMNGCTL E1000_EEMNGCTL
+ #define E1000_82542_PSRCTL E1000_PSRCTL
+ #define E1000_82542_RAID E1000_RAID
+@@ -1329,6 +1323,7 @@ struct iegbe_hw_stats {
+ uint64_t algnerrc;
+ uint64_t symerrs;
+ uint64_t rxerrc;
++ uint64_t txerrc;
+ uint64_t mpc;
+ uint64_t scc;
+ uint64_t ecol;
+@@ -1363,6 +1358,7 @@ struct iegbe_hw_stats {
+ uint64_t ruc;
+ uint64_t rfc;
+ uint64_t roc;
++ uint64_t rlerrc;
+ uint64_t rjc;
+ uint64_t mgprc;
+ uint64_t mgpdc;
+@@ -1392,19 +1388,6 @@ struct iegbe_hw_stats {
+ uint64_t ictxqmtc;
+ uint64_t icrxdmtc;
+ uint64_t icrxoc;
+-#ifdef IEGBE_GBE_WORKAROUND
+- u64 txqec;
+- u64 tx_next_to_clean;
+- u64 tx_next_to_use;
+- u64 cc_gt_num_rx;
+- u64 tx_hnet;
+- u64 tx_hnentu;
+- u64 num_tx_queues;
+-
+- u64 num_rx_buf_alloc;
+- u64 rx_next_to_clean;
+- u64 rx_next_to_use;
+-#endif
+ };
+
+ /* Structure containing variables used by the shared code (iegbe_hw.c) */
+@@ -1484,6 +1467,7 @@ struct iegbe_hw {
+ boolean_t ifs_params_forced;
+ boolean_t in_ifs_mode;
+ boolean_t mng_reg_access_disabled;
++ boolean_t rx_needs_kicking;
+ boolean_t icp_xxxx_is_link_up;
+ };
+
+@@ -2358,17 +2342,23 @@ struct iegbe_host_command_info {
+ #define E1000_EXTCNF_SIZE_EXT_PHY_LENGTH 0x000000FF
+ #define E1000_EXTCNF_SIZE_EXT_DOCK_LENGTH 0x0000FF00
+ #define E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH 0x00FF0000
++#define E1000_EXTCNF_CTRL_LCD_WRITE_ENABLE 0x00000001
++#define E1000_EXTCNF_CTRL_SWFLAG 0x00000020
+
+ /* PBA constants */
++#define E1000_PBA_8K 0x0008 /* 8KB, default Rx allocation */
+ #define E1000_PBA_12K 0x000C /* 12KB, default Rx allocation */
+ #define E1000_PBA_16K 0x0010 /* 16KB, default TX allocation */
++#define E1000_PBA_20K 0x0014
+ #define E1000_PBA_22K 0x0016
+ #define E1000_PBA_24K 0x0018
+ #define E1000_PBA_30K 0x001E
+ #define E1000_PBA_32K 0x0020
++#define E1000_PBA_34K 0x0022
+ #define E1000_PBA_38K 0x0026
+ #define E1000_PBA_40K 0x0028
+ #define E1000_PBA_48K 0x0030 /* 48KB, default RX allocation */
++#define E1000_PBS_16K E1000_PBA_16K
+
+ /* Flow Control Constants */
+ #define FLOW_CONTROL_ADDRESS_LOW 0x00C28001
+@@ -2899,7 +2889,7 @@ struct iegbe_host_command_info {
+ #define M88E1000_14_PHY_ID M88E1000_E_PHY_ID
+ #define M88E1011_I_REV_4 0x04
+ #define M88E1111_I_PHY_ID 0x01410CC2
+-#define M88E1141_E_PHY_ID 0x01410CD4
++#define M88E1141_E_PHY_ID 0x01410CD0
+ #define L1LXT971A_PHY_ID 0x001378E0
+
+ /* Miscellaneous PHY bit definitions. */
+--- a/Embedded/src/GbE/iegbe_main.c
++++ b/Embedded/src/GbE/iegbe_main.c
+@@ -2,7 +2,7 @@
+
+ GPL LICENSE SUMMARY
+
+- Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
++ Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of version 2 of the GNU General Public License as
+@@ -22,7 +22,7 @@ GPL LICENSE SUMMARY
+ Contact Information:
+ Intel Corporation
+
+- version: Embedded.L.1.0.34
++ version: Embedded.Release.Patch.L.1.0.7-5
+
+ Contact Information:
+
+@@ -42,103 +42,15 @@ GPL LICENSE SUMMARY
+
+ #include "iegbe.h"
+ #include "gcu_if.h"
+-
+-/* Change Log
+- * 6.0.58 4/20/05
+- * o iegbe_set_spd_dplx tests for compatible speed/duplex specification
+- * for fiber adapters
+- * 6.0.57 4/19/05
+- * o Added code to fix register test failure for devices >= 82571
+- *
+- * 6.0.52 3/15/05
+- * o Added stats_lock around iegbe_read_phy_reg commands to avoid concurrent
+- * calls, one from mii_ioctl and other from within update_stats while
+- * processing MIIREG ioctl.
+- *
+- * 6.1.2 4/13/05
+- * o Fixed ethtool diagnostics
+- * o Enabled flow control to take default eeprom settings
+- * o Added stats_lock around iegbe_read_phy_reg commands to avoid concurrent
+- * calls, one from mii_ioctl and other from within update_stats while processing
+- * MIIREG ioctl.
+- * 6.0.55 3/23/05
+- * o Support for MODULE_VERSION
+- * o Fix APM setting for 82544 based adapters
+- * 6.0.54 3/26/05
+- * o Added a timer to expire packets that were deferred for cleanup
+- * 6.0.52 3/15/05
+- * o Added stats_lock around iegbe_read_phy_reg commands to avoid concurrent
+- * calls, one from mii_ioctl and other from within update_stats while
+- * processing MIIREG ioctl.
+- * 6.0.47 3/2/05
+- * o Added enhanced functionality to the loopback diags to wrap the
+- * descriptor rings
+- * o Added manageability vlan filtering workaround.
+- *
+- * 6.0.44+ 2/15/05
+- * o Added code to handle raw packet based DHCP packets
+- * o Added code to fix the errata 10 buffer overflow issue
+- * o Sync up with WR01-05
+- * o applied Anton's patch to resolve tx hang in hardware
+- * o iegbe timeouts with early writeback patch
+- * o Removed Queensport IDs
+- * o fixed driver panic if MAC receives a bad large packets when packet
+- * split is enabled
+- * o Applied Andrew Mortons patch - iegbe stops working after resume
+- * 5.2.29 12/24/03
+- * o Bug fix: Endianess issue causing ethtool diags to fail on ppc.
+- * o Bug fix: Use pdev->irq instead of netdev->irq for MSI support.
+- * o Report driver message on user override of InterruptThrottleRate module
+- * parameter.
+- * o Bug fix: Change I/O address storage from uint32_t to unsigned long.
+- * o Feature: Added ethtool RINGPARAM support.
+- * o Feature: Added netpoll support.
+- * o Bug fix: Race between Tx queue and Tx clean fixed with a spin lock.
+- * o Bug fix: Allow 1000/Full setting for autoneg param for fiber connections.
+- * Jon D Mason [jonmason@us.ibm.com].
+- *
+- * 5.2.22 10/15/03
+- * o Bug fix: SERDES devices might be connected to a back-plane switch that
+- * doesn't support auto-neg, so add the capability to force 1000/Full.
+- * Also, since forcing 1000/Full, sample RxSynchronize bit to detect link
+- * state.
+- * o Bug fix: Flow control settings for hi/lo watermark didn't consider
+- * changes in the RX FIFO size, which could occur with Jumbo Frames or with
+- * the reduced FIFO in 82547.
+- * o Bug fix: Better propagation of error codes.
+- * [Janice Girouard (janiceg -a-t- us.ibm.com)]
+- * o Bug fix: hang under heavy Tx stress when running out of Tx descriptors;
+- * wasn't clearing context descriptor when backing out of send because of
+- * no-resource condition.
+- * o Bug fix: check netif_running in dev->poll so we don't have to hang in
+- * dev->close until all polls are finished. [Rober Olsson
+- * (robert.olsson@data.slu.se)].
+- * o Revert TxDescriptor ring size back to 256 since change to 1024 wasn't
+- * accepted into the kernel.
+- *
+- * 5.2.16 8/8/03
+- */
+-
+-#ifdef IEGBE_GBE_WORKAROUND
+-#define IEGBE_GBE_WORKAROUND_NUM_RX_DESCRIPTORS 1
+-#endif
++#include <linux/ipv6.h>
++#include <net/ip6_checksum.h>
+
+ char iegbe_driver_name[] = "iegbe";
+ char iegbe_driver_string[] = "Gigabit Ethernet Controller Driver";
+-#ifndef CONFIG_E1000_NAPI
+-#define DRIVERNAPI
+-#else
+-#define DRIVERNAPI "-NAPI"
+-#endif
+-#define DRV_VERSION "0.8.0"DRIVERNAPI
++#define DRV_VERSION "1.0.0-K28-NAPI"
+ char iegbe_driver_version[] = DRV_VERSION;
+-char iegbe_copyright[] = "Copyright (c) 1999-2007 Intel Corporation.";
++char iegbe_copyright[] = "Copyright (c) 1999-2009 Intel Corporation.";
+
+-#define E1000_FIFO_HDR 0x10
+-#define E1000_82547_PAD_LEN 0x3E0
+-#define MINIMUM_DHCP_PACKET_SIZE 282
+-#define TXD_USE_COUNT(S, X) (((S) >> (X)) + 1 )
+-#define E1000_CTRL_EN_PHY_PWR_MGMT 0x00200000
+
+ /* iegbe_pci_tbl - PCI Device ID Table
+ *
+@@ -148,95 +60,48 @@ char iegbe_copyright[] = "Copyright (c)
+ * {PCI_DEVICE(PCI_VENDOR_ID_INTEL, device_id)}
+ */
+ static struct pci_device_id iegbe_pci_tbl[] = {
+-/* INTEL_E1000_ETHERNET_DEVICE(0x1000), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x1001), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x1004), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x1008), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x1009), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x100C), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x100D), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x100E), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x100F), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x1010), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x1011), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x1012), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x1013), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x1014), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x1015), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x1016), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x1017), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x1018), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x1019), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x101A), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x101D), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x101E), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x1026), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x1027), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x1028), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x105E), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x105F), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x1060), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x1075), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x1076), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x1077), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x1078), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x1079), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x107A), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x107B), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x107C), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x107D), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x107E), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x107F), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x108A), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x108B), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x108C), */
+-/* INTEL_E1000_ETHERNET_DEVICE(0x109A), */
+- INTEL_E1000_ETHERNET_DEVICE(0x5040),
+- INTEL_E1000_ETHERNET_DEVICE(0x5041),
+- INTEL_E1000_ETHERNET_DEVICE(0x5042),
+- INTEL_E1000_ETHERNET_DEVICE(0x5043),
+- INTEL_E1000_ETHERNET_DEVICE(0x5044),
+- INTEL_E1000_ETHERNET_DEVICE(0x5045),
+- INTEL_E1000_ETHERNET_DEVICE(0x5046),
+- INTEL_E1000_ETHERNET_DEVICE(0x5047),
+- INTEL_E1000_ETHERNET_DEVICE(0x5048),
+- INTEL_E1000_ETHERNET_DEVICE(0x5049),
+- INTEL_E1000_ETHERNET_DEVICE(0x504A),
+- INTEL_E1000_ETHERNET_DEVICE(0x504B),
+- /* required last entry */
++ INTEL_E1000_ETHERNET_DEVICE(0x5040),
++ INTEL_E1000_ETHERNET_DEVICE(0x5041),
++ INTEL_E1000_ETHERNET_DEVICE(0x5042),
++ INTEL_E1000_ETHERNET_DEVICE(0x5043),
++ INTEL_E1000_ETHERNET_DEVICE(0x5044),
++ INTEL_E1000_ETHERNET_DEVICE(0x5045),
++ INTEL_E1000_ETHERNET_DEVICE(0x5046),
++ INTEL_E1000_ETHERNET_DEVICE(0x5047),
++ INTEL_E1000_ETHERNET_DEVICE(0x5048),
++ INTEL_E1000_ETHERNET_DEVICE(0x5049),
++ INTEL_E1000_ETHERNET_DEVICE(0x504A),
++ INTEL_E1000_ETHERNET_DEVICE(0x504B),
++ /* required last entry */
+ {0,}
+ };
+
+ MODULE_DEVICE_TABLE(pci, iegbe_pci_tbl);
+
+-DEFINE_SPINLOCK(print_lock);
+
+ int iegbe_up(struct iegbe_adapter *adapter);
+ void iegbe_down(struct iegbe_adapter *adapter);
++void iegbe_reinit_locked(struct iegbe_adapter *adapter);
+ void iegbe_reset(struct iegbe_adapter *adapter);
+ int iegbe_set_spd_dplx(struct iegbe_adapter *adapter, uint16_t spddplx);
+ int iegbe_setup_all_tx_resources(struct iegbe_adapter *adapter);
+ int iegbe_setup_all_rx_resources(struct iegbe_adapter *adapter);
+ void iegbe_free_all_tx_resources(struct iegbe_adapter *adapter);
+ void iegbe_free_all_rx_resources(struct iegbe_adapter *adapter);
+-int iegbe_setup_tx_resources(struct iegbe_adapter *adapter,
++static int iegbe_setup_tx_resources(struct iegbe_adapter *adapter,
+ struct iegbe_tx_ring *txdr);
+-int iegbe_setup_rx_resources(struct iegbe_adapter *adapter,
++static int iegbe_setup_rx_resources(struct iegbe_adapter *adapter,
+ struct iegbe_rx_ring *rxdr);
+-void iegbe_free_tx_resources(struct iegbe_adapter *adapter,
++static void iegbe_free_tx_resources(struct iegbe_adapter *adapter,
+ struct iegbe_tx_ring *tx_ring);
+-void iegbe_free_rx_resources(struct iegbe_adapter *adapter,
++static void iegbe_free_rx_resources(struct iegbe_adapter *adapter,
+ struct iegbe_rx_ring *rx_ring);
+ void iegbe_update_stats(struct iegbe_adapter *adapter);
+-
+ static int iegbe_init_module(void);
+ static void iegbe_exit_module(void);
+ static int iegbe_probe(struct pci_dev *pdev, const struct pci_device_id *ent);
+ static void __devexit iegbe_remove(struct pci_dev *pdev);
+ static int iegbe_alloc_queues(struct iegbe_adapter *adapter);
+-#ifdef CONFIG_E1000_MQ
+-static void iegbe_setup_queue_mapping(struct iegbe_adapter *adapter);
+-#endif
+ static int iegbe_sw_init(struct iegbe_adapter *adapter);
+ static int iegbe_open(struct net_device *netdev);
+ static int iegbe_close(struct net_device *netdev);
+@@ -249,7 +114,8 @@ static void iegbe_clean_tx_ring(struct i
+ struct iegbe_tx_ring *tx_ring);
+ static void iegbe_clean_rx_ring(struct iegbe_adapter *adapter,
+ struct iegbe_rx_ring *rx_ring);
+-static void iegbe_set_multi(struct net_device *netdev);
++
++static void iegbe_set_rx_mode(struct net_device *netdev);
+ static void iegbe_update_phy_info(unsigned long data);
+ static void iegbe_watchdog(unsigned long data);
+ static void iegbe_82547_tx_fifo_stall(unsigned long data);
+@@ -257,66 +123,46 @@ static int iegbe_xmit_frame(struct sk_bu
+ static struct net_device_stats * iegbe_get_stats(struct net_device *netdev);
+ static int iegbe_change_mtu(struct net_device *netdev, int new_mtu);
+ static int iegbe_set_mac(struct net_device *netdev, void *p);
+-static irqreturn_t iegbe_intr(int irq, void *data, struct pt_regs *regs);
++static irqreturn_t iegbe_intr(int irq, void *data);
+
+-void iegbe_tasklet(unsigned long);
++static irqreturn_t iegbe_intr_msi(int irq, void *data);
+
+-#ifndef IEGBE_GBE_WORKAROUND
+-static boolean_t iegbe_clean_tx_irq(struct iegbe_adapter *adapter,
++static bool iegbe_clean_tx_irq(struct iegbe_adapter *adapter,
+ struct iegbe_tx_ring *tx_ring);
+-#endif
+-
+-#ifdef CONFIG_E1000_NAPI
+-static int iegbe_clean(struct net_device *poll_dev, int *budget);
+-static boolean_t iegbe_clean_rx_irq(struct iegbe_adapter *adapter,
++static int iegbe_clean(struct napi_struct *napi, int budget);
++static bool iegbe_clean_rx_irq(struct iegbe_adapter *adapter,
+ struct iegbe_rx_ring *rx_ring,
+ int *work_done, int work_to_do);
+-static boolean_t iegbe_clean_rx_irq_ps(struct iegbe_adapter *adapter,
++static bool iegbe_clean_rx_irq_ps(struct iegbe_adapter *adapter,
+ struct iegbe_rx_ring *rx_ring,
+ int *work_done, int work_to_do);
+-#else
+-static boolean_t iegbe_clean_rx_irq(struct iegbe_adapter *adapter,
+- struct iegbe_rx_ring *rx_ring);
+-static boolean_t iegbe_clean_rx_irq_ps(struct iegbe_adapter *adapter,
+- struct iegbe_rx_ring *rx_ring);
+-#endif
+
+-#ifdef IEGBE_GBE_WORKAROUND
++
+ static void iegbe_alloc_rx_buffers(struct iegbe_adapter *adapter,
+ struct iegbe_rx_ring *rx_ring,
+ int cleaned_count);
+ static void iegbe_alloc_rx_buffers_ps(struct iegbe_adapter *adapter,
+ struct iegbe_rx_ring *rx_ring,
+ int cleaned_count);
+-#else
+-static void iegbe_alloc_rx_buffers(struct iegbe_adapter *adapter,
+- struct iegbe_rx_ring *rx_ring);
+-static void iegbe_alloc_rx_buffers_ps(struct iegbe_adapter *adapter,
+- struct iegbe_rx_ring *rx_ring);
+-#endif
++
+
+ static int iegbe_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd);
+-#ifdef SIOCGMIIPHY
+ static int iegbe_mii_ioctl(struct net_device *netdev, struct ifreq *ifr,
+- int cmd);
+-#endif
++ int cmd);
+ void set_ethtool_ops(struct net_device *netdev);
+ extern int ethtool_ioctl(struct ifreq *ifr);
+ static void iegbe_enter_82542_rst(struct iegbe_adapter *adapter);
+ static void iegbe_leave_82542_rst(struct iegbe_adapter *adapter);
+ static void iegbe_tx_timeout(struct net_device *dev);
+-static void iegbe_tx_timeout_task(struct net_device *dev);
++static void iegbe_reset_task(struct work_struct *work);
+ static void iegbe_smartspeed(struct iegbe_adapter *adapter);
+ static inline int iegbe_82547_fifo_workaround(struct iegbe_adapter *adapter,
+- struct sk_buff *skb);
++ struct sk_buff *skb);
+
+-#ifdef NETIF_F_HW_VLAN_TX
+-static void iegbe_vlan_rx_register(struct net_device *netdev,
+- struct vlan_group *grp);
++static void iegbe_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp);
+ static void iegbe_vlan_rx_add_vid(struct net_device *netdev, uint16_t vid);
+ static void iegbe_vlan_rx_kill_vid(struct net_device *netdev, uint16_t vid);
+ static void iegbe_restore_vlan(struct iegbe_adapter *adapter);
+-#endif
+
+ static int iegbe_notify_reboot(struct notifier_block *,
+ unsigned long event,
+@@ -331,15 +177,17 @@ static int iegbe_resume(struct pci_dev *
+ static void iegbe_netpoll (struct net_device *netdev);
+ #endif
+
+-#ifdef CONFIG_E1000_MQ
+-/* for multiple Rx queues */
++#define COPYBREAK_DEFAULT 256
++static unsigned int copybreak __read_mostly = COPYBREAK_DEFAULT;
++module_param(copybreak, uint, 0644);
++MODULE_PARM_DESC(copybreak,
++ "Maximum size of packet that is copied to a new buffer on receive");
+ void iegbe_rx_schedule(void *data);
+-#endif
+
+ struct notifier_block iegbe_notifier_reboot = {
+- .notifier_call = iegbe_notify_reboot,
+- .next = NULL,
+- .priority = 0
++ .notifier_call = iegbe_notify_reboot,
++ .next = NULL,
++ .priority = 0
+ };
+
+ /* Exported from other modules */
+@@ -347,14 +195,14 @@ struct notifier_block iegbe_notifier_reb
+ extern void iegbe_check_options(struct iegbe_adapter *adapter);
+
+ static struct pci_driver iegbe_driver = {
+- .name = iegbe_driver_name,
+- .id_table = iegbe_pci_tbl,
+- .probe = iegbe_probe,
+- .remove = __devexit_p(iegbe_remove),
+- /* Power Managment Hooks */
++ .name = iegbe_driver_name,
++ .id_table = iegbe_pci_tbl,
++ .probe = iegbe_probe,
++ .remove = __devexit_p(iegbe_remove),
++ /* Power Managment Hooks */
+ #ifdef CONFIG_PM
+- .suspend = iegbe_suspend,
+- .resume = iegbe_resume
++ .suspend = iegbe_suspend,
++ .resume = iegbe_resume
+ #endif
+ };
+
+@@ -364,46 +212,17 @@ MODULE_LICENSE("GPL");
+ MODULE_VERSION(DRV_VERSION);
+
+ static int debug = NETIF_MSG_DRV | NETIF_MSG_PROBE;
+-module_param(debug, int, 0);
++module_param(debug, int, 0x0);
+ MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)");
+
+-static uint8_t gcu_suspend = 0;
+-static uint8_t gcu_resume = 0;
++static uint8_t gcu_suspend = 0x0;
++static uint8_t gcu_resume = 0x0;
+ struct pci_dev *gcu = NULL;
+
+-unsigned long tasklet_data;
+-DECLARE_TASKLET(iegbe_reset_tasklet, iegbe_tasklet, (unsigned long) &tasklet_data);
+
+ /**
+ * iegbe_iegbe_tasklet -*
+ **/
+-void iegbe_tasklet(unsigned long data)
+-{
+- char* err_msg = "TEST";
+- uint32_t *icr = (uint32_t*) data;
+- uint32_t gbe = *icr & 0x000000FF;
+- if( *icr & E1000_ICR_RX_DESC_FIFO_PAR) { /* 21 */
+- err_msg = "DMA Transmit Descriptor 2-bit ECC Error!";
+- }
+- if( *icr & E1000_ICR_TX_DESC_FIFO_PAR) { /* 20 */
+- err_msg = "DMA Receive Descriptor 2-bit ECC Error!";
+- }
+- if( *icr & E1000_ICR_PB) { /* 23 */
+- err_msg = "DMA Packet Buffer 2-bit ECC Error!";
+- }
+- if( *icr & E1000_ICR_CPP_TARGET) { /* 27 */
+- err_msg = "Statistic Register ECC Error!";
+- }
+- if( *icr & E1000_ICR_CPP_MASTER) {
+- err_msg = "CPP Error!";
+- }
+- spin_lock(&print_lock);
+- printk("IEGBE%d: System Reset due to: %s\n", gbe, err_msg);
+- dump_stack();
+- spin_unlock(&print_lock);
+- panic(err_msg);
+- return;
+-}
+ /**
+ * iegbe_init_module - Driver Registration Routine
+ *
+@@ -411,21 +230,24 @@ void iegbe_tasklet(unsigned long data)
+ * loaded. All it does is register with the PCI subsystem.
+ **/
+
+-static int __init
+-iegbe_init_module(void)
++static int __init iegbe_init_module(void)
+ {
+- int ret;
++ int ret;
+
+ printk(KERN_INFO "%s - version %s\n",
+- iegbe_driver_string, iegbe_driver_version);
++ iegbe_driver_string, iegbe_driver_version);
+
+- printk(KERN_INFO "%s\n", iegbe_copyright);
++ printk(KERN_INFO "%s\n", iegbe_copyright);
+
+- ret = pci_module_init(&iegbe_driver);
+- if(ret >= 0) {
+- register_reboot_notifier(&iegbe_notifier_reboot);
+- }
+- return ret;
++ ret = pci_register_driver(&iegbe_driver);
++ if (copybreak != COPYBREAK_DEFAULT) {
++ if (copybreak == 0)
++ printk(KERN_INFO "iegbe: copybreak disabled\n");
++ else
++ printk(KERN_INFO "iegbe: copybreak enabled for "
++ "packets <= %u bytes\n", copybreak);
++ }
++ return ret;
+ }
+
+ module_init(iegbe_init_module);
+@@ -437,29 +259,51 @@ module_init(iegbe_init_module);
+ * from memory.
+ **/
+
+-static void __exit
+-iegbe_exit_module(void)
++static void __exit iegbe_exit_module(void)
+ {
+-
+- unregister_reboot_notifier(&iegbe_notifier_reboot);
+- pci_unregister_driver(&iegbe_driver);
++ pci_unregister_driver(&iegbe_driver);
+ }
+
+ module_exit(iegbe_exit_module);
+
++static int iegbe_request_irq(struct iegbe_adapter *adapter)
++{
++ struct net_device *netdev = adapter->netdev;
++ irq_handler_t handler = iegbe_intr;
++ int irq_flags = IRQF_SHARED;
++ int err;
++ adapter->have_msi = !pci_enable_msi(adapter->pdev);
++ if (adapter->have_msi) {
++ handler = iegbe_intr_msi;
++ irq_flags = 0;
++ }
++ err = request_irq(adapter->pdev->irq, handler, irq_flags, netdev->name,
++ netdev);
++ if (err) {
++ if (adapter->have_msi)
++ pci_disable_msi(adapter->pdev);
++ DPRINTK(PROBE, ERR,
++ "Unable to allocate interrupt Error: %d\n", err);
++ }
++ return err;
++}
++static void iegbe_free_irq(struct iegbe_adapter *adapter)
++{
++ struct net_device *netdev = adapter->netdev;
++ free_irq(adapter->pdev->irq, netdev);
++ if (adapter->have_msi)
++ pci_disable_msi(adapter->pdev);
++}
+ /**
+ * iegbe_irq_disable - Mask off interrupt generation on the NIC
+ * @adapter: board private structure
+ **/
+
+-static inline void
+-iegbe_irq_disable(struct iegbe_adapter *adapter)
++static void iegbe_irq_disable(struct iegbe_adapter *adapter)
+ {
+-
+- atomic_inc(&adapter->irq_sem);
+- E1000_WRITE_REG(&adapter->hw, IMC, ~0);
+- E1000_WRITE_FLUSH(&adapter->hw);
+- synchronize_irq(adapter->pdev->irq);
++ E1000_WRITE_REG(&adapter->hw, IMC, ~0);
++ E1000_WRITE_FLUSH(&adapter->hw);
++ synchronize_irq(adapter->pdev->irq);
+ }
+
+ /**
+@@ -470,244 +314,414 @@ iegbe_irq_disable(struct iegbe_adapter *
+ static inline void
+ iegbe_irq_enable(struct iegbe_adapter *adapter)
+ {
+-
+- if(likely(atomic_dec_and_test(&adapter->irq_sem))) {
+- E1000_WRITE_REG(&adapter->hw, IMS, IMS_ENABLE_MASK);
+- E1000_WRITE_FLUSH(&adapter->hw);
+- }
++ E1000_WRITE_REG(&adapter->hw, IMS, IMS_ENABLE_MASK);
++ E1000_WRITE_FLUSH(&adapter->hw);
+ }
+-#ifdef NETIF_F_HW_VLAN_TX
+-void
+-iegbe_update_mng_vlan(struct iegbe_adapter *adapter)
+-{
+- struct net_device *netdev = adapter->netdev;
+- uint16_t vid = adapter->hw.mng_cookie.vlan_id;
+- uint16_t old_vid = adapter->mng_vlan_id;
+
+- if(adapter->vlgrp) {
+- if(!adapter->vlgrp->vlan_devices[vid]) {
+- if(adapter->hw.mng_cookie.status &
+- E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) {
+- iegbe_vlan_rx_add_vid(netdev, vid);
+- adapter->mng_vlan_id = vid;
+- } else {
+- adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
+- }
+- if((old_vid != (uint16_t)E1000_MNG_VLAN_NONE) &&
+- (vid != old_vid) &&
+- !adapter->vlgrp->vlan_devices[old_vid]) {
+- iegbe_vlan_rx_kill_vid(netdev, old_vid);
+- }
+- }
+-}
++static void iegbe_update_mng_vlan(struct iegbe_adapter *adapter)
++{
++ struct iegbe_hw *hw = &adapter->hw;
++ struct net_device *netdev = adapter->netdev;
++ u16 vid = hw->mng_cookie.vlan_id;
++ u16 old_vid = adapter->mng_vlan_id;
++ if (adapter->vlgrp) {
++ if (!vlan_group_get_device(adapter->vlgrp, vid)) {
++ if (hw->mng_cookie.status &
++ E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) {
++ iegbe_vlan_rx_add_vid(netdev, vid);
++ adapter->mng_vlan_id = vid;
++ } else
++ adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
++
++ if ((old_vid != (u16)E1000_MNG_VLAN_NONE) &&
++ (vid != old_vid) &&
++ !vlan_group_get_device(adapter->vlgrp, old_vid))
++ iegbe_vlan_rx_kill_vid(netdev, old_vid);
++ } else
++ adapter->mng_vlan_id = vid;
++ }
+ }
+-#endif
+
+-int
+-iegbe_up(struct iegbe_adapter *adapter)
++/**
++ * iegbe_configure - configure the hardware for RX and TX
++ * @adapter = private board structure
++ **/
++static void iegbe_configure(struct iegbe_adapter *adapter)
+ {
+ struct net_device *netdev = adapter->netdev;
+- int i, err;
+- uint16_t pci_cmd;
+-
+- /* hardware has been reset, we need to reload some things */
+-
+- /* Reset the PHY if it was previously powered down */
+- if(adapter->hw.media_type == iegbe_media_type_copper
+- || (adapter->hw.media_type == iegbe_media_type_oem
+- && iegbe_oem_phy_is_copper(&adapter->hw))) {
+- uint16_t mii_reg;
+- iegbe_read_phy_reg(&adapter->hw, PHY_CTRL, &mii_reg);
+- if(mii_reg & MII_CR_POWER_DOWN){
+- iegbe_phy_reset(&adapter->hw);
+- }
+- }
++ int i;
+
+- iegbe_set_multi(netdev);
++ iegbe_set_rx_mode(netdev);
+
+-#ifdef NETIF_F_HW_VLAN_TX
+ iegbe_restore_vlan(adapter);
+-#endif
+
+ iegbe_configure_tx(adapter);
+ iegbe_setup_rctl(adapter);
+ iegbe_configure_rx(adapter);
++ /* call E1000_DESC_UNUSED which always leaves
++ * at least 1 descriptor unused to make sure
++ * next_to_use != next_to_clean */
++ for (i = 0; i < adapter->num_rx_queues; i++) {
++ struct iegbe_rx_ring *ring = &adapter->rx_ring[i];
++ adapter->alloc_rx_buf(adapter, ring,
++ E1000_DESC_UNUSED(ring));
++ }
+
+-#ifdef IEGBE_GBE_WORKAROUND
+- for (i = 0; i < adapter->num_queues; i++)
+- adapter->alloc_rx_buf(adapter, &adapter->rx_ring[i],
+- IEGBE_GBE_WORKAROUND_NUM_RX_DESCRIPTORS + 1);
+-#else
+- for (i = 0; i < adapter->num_queues; i++)
+- adapter->alloc_rx_buf(adapter, &adapter->rx_ring[i]);
+-#endif
++ adapter->tx_queue_len = netdev->tx_queue_len;
++}
+
+-#ifdef CONFIG_PCI_MSI
+- if(adapter->hw.mac_type > iegbe_82547_rev_2
+- || adapter->hw.mac_type == iegbe_icp_xxxx) {
+- adapter->have_msi = TRUE;
+- if((err = pci_enable_msi(adapter->pdev))) {
+- DPRINTK(PROBE, ERR,
+- "Unable to allocate MSI interrupt Error: %d\n", err);
+- adapter->have_msi = FALSE;
+- }
+- }
+- pci_read_config_word(adapter->pdev, PCI_COMMAND, &pci_cmd);
+- pci_write_config_word(adapter->pdev, PCI_COMMAND, pci_cmd | IEGBE_INTD_DISABLE);
++int iegbe_up(struct iegbe_adapter *adapter)
++{
++ /* hardware has been reset, we need to reload some things */
++ iegbe_configure(adapter);
+
+-#endif
+- if((err = request_irq(adapter->pdev->irq, &iegbe_intr,
+- SA_SHIRQ | SA_SAMPLE_RANDOM,
+- netdev->name, netdev))) {
+- DPRINTK(PROBE, ERR,
+- "Unable to allocate interrupt Error: %d\n", err);
+- return err;
+- }
++ clear_bit(__E1000_DOWN, &adapter->flags);
+
+- mod_timer(&adapter->watchdog_timer, jiffies);
++ napi_enable(&adapter->napi);
+
+-#ifdef CONFIG_E1000_NAPI
+- netif_poll_enable(netdev);
+-#endif
+ iegbe_irq_enable(adapter);
+
++ adapter->hw.get_link_status = 0x1;
+ return 0;
+ }
+
+-void
+-iegbe_down(struct iegbe_adapter *adapter)
+-{
+- struct net_device *netdev = adapter->netdev;
+-
+- iegbe_irq_disable(adapter);
+-#ifdef CONFIG_E1000_MQ
+- while (atomic_read(&adapter->rx_sched_call_data.count) != 0) { };
+-#endif
+- free_irq(adapter->pdev->irq, netdev);
+-#ifdef CONFIG_PCI_MSI
+- if((adapter->hw.mac_type > iegbe_82547_rev_2
+- || adapter->hw.mac_type == iegbe_icp_xxxx)
+- && adapter->have_msi == TRUE) {
+- pci_disable_msi(adapter->pdev);
+- }
+-#endif
+- del_timer_sync(&adapter->tx_fifo_stall_timer);
+- del_timer_sync(&adapter->watchdog_timer);
+- del_timer_sync(&adapter->phy_info_timer);
++/**
++ * iegbe_power_up_phy - restore link in case the phy was powered down
++ * @adapter: address of board private structure
++ *
++ * The phy may be powered down to save power and turn off link when the
++ * driver is unloaded and wake on lan is not enabled (among others)
++ * *** this routine MUST be followed by a call to iegbe_reset ***
++ *
++ **/
+
+-#ifdef CONFIG_E1000_NAPI
+- netif_poll_disable(netdev);
+-#endif
+- adapter->link_speed = 0;
+- adapter->link_duplex = 0;
+- netif_carrier_off(netdev);
+- netif_stop_queue(netdev);
++void iegbe_power_up_phy(struct iegbe_adapter *adapter)
++{
++ struct iegbe_hw *hw = &adapter->hw;
++ u16 mii_reg = 0;
+
+- iegbe_reset(adapter);
+- iegbe_clean_all_tx_rings(adapter);
+- iegbe_clean_all_rx_rings(adapter);
++ /* Just clear the power down bit to wake the phy back up */
++ if (hw->media_type == iegbe_media_type_copper) {
++ /* according to the manual, the phy will retain its
++ * settings across a power-down/up cycle */
++ iegbe_read_phy_reg(hw, PHY_CTRL, &mii_reg);
++ mii_reg &= ~MII_CR_POWER_DOWN;
++ iegbe_write_phy_reg(hw, PHY_CTRL, mii_reg);
++ }
++}
+
+- /* If WoL is not enabled and management mode is not IAMT
+- * or if WoL is not enabled and OEM PHY is copper based,
+- * power down the PHY so no link is implied when interface is down */
+- if(!adapter->wol
+- && ((adapter->hw.mac_type >= iegbe_82540
+- && adapter->hw.media_type == iegbe_media_type_copper
+- && !iegbe_check_mng_mode(&adapter->hw)
+- && !(E1000_READ_REG(&adapter->hw, MANC) & E1000_MANC_SMBUS_EN))
+- || (adapter->hw.media_type == iegbe_media_type_oem
+- && iegbe_oem_phy_is_copper(&adapter->hw)))){
++static void iegbe_power_down_phy(struct iegbe_adapter *adapter)
++{
++ struct iegbe_hw *hw = &adapter->hw;
+
+- uint16_t mii_reg;
+- iegbe_read_phy_reg(&adapter->hw, PHY_CTRL, &mii_reg);
++ /* Power down the PHY so no link is implied when interface is down *
++ * The PHY cannot be powered down if any of the following is true *
++ * (a) WoL is enabled
++ * (b) AMT is active
++ * (c) SoL/IDER session is active */
++ if (!adapter->wol && hw->mac_type >= iegbe_82540 &&
++ hw->media_type == iegbe_media_type_copper) {
++ u16 mii_reg = 0;
++
++ switch (hw->mac_type) {
++ case iegbe_82540:
++ case iegbe_82545:
++ case iegbe_82545_rev_3:
++ case iegbe_82546:
++ case iegbe_82546_rev_3:
++ case iegbe_82541:
++ case iegbe_82541_rev_2:
++ case iegbe_82547:
++ case iegbe_82547_rev_2:
++ if (E1000_READ_REG(&adapter->hw, MANC) & E1000_MANC_SMBUS_EN)
++ goto out;
++ break;
++ case iegbe_82571:
++ case iegbe_82572:
++ case iegbe_82573:
++ if (iegbe_check_mng_mode(hw) ||
++ iegbe_check_phy_reset_block(hw))
++ goto out;
++ break;
++ default:
++ goto out;
++ }
++ iegbe_read_phy_reg(hw, PHY_CTRL, &mii_reg);
+ mii_reg |= MII_CR_POWER_DOWN;
+- iegbe_write_phy_reg(&adapter->hw, PHY_CTRL, mii_reg);
++ iegbe_write_phy_reg(hw, PHY_CTRL, mii_reg);
+ mdelay(1);
+ }
++out:
++ return;
+ }
+
+-void
+-iegbe_reset(struct iegbe_adapter *adapter)
++void iegbe_down(struct iegbe_adapter *adapter)
+ {
+- struct net_device *netdev = adapter->netdev;
+- uint32_t pba, manc;
+- uint16_t fc_high_water_mark = E1000_FC_HIGH_DIFF;
+- uint16_t fc_low_water_mark = E1000_FC_LOW_DIFF;
++ struct net_device *netdev = adapter->netdev;
+
++ /* signal that we're down so the interrupt handler does not
++ * reschedule our watchdog timer */
++ set_bit(__E1000_DOWN, &adapter->flags);
+
+- /* Repartition Pba for greater than 9k mtu
+- * To take effect CTRL.RST is required.
+- */
++ napi_disable(&adapter->napi);
+
+- switch (adapter->hw.mac_type) {
+- case iegbe_82547:
+- case iegbe_82547_rev_2:
+- pba = E1000_PBA_30K;
+- break;
+- case iegbe_82571:
+- case iegbe_82572:
+- pba = E1000_PBA_38K;
+- break;
+- case iegbe_82573:
+- pba = E1000_PBA_12K;
++ iegbe_irq_disable(adapter);
++
++ del_timer_sync(&adapter->tx_fifo_stall_timer);
++ del_timer_sync(&adapter->watchdog_timer);
++ del_timer_sync(&adapter->phy_info_timer);
++
++ netdev->tx_queue_len = adapter->tx_queue_len;
++ adapter->link_speed = 0;
++ adapter->link_duplex = 0;
++ netif_carrier_off(netdev);
++ netif_stop_queue(netdev);
++
++ iegbe_reset(adapter);
++ iegbe_clean_all_tx_rings(adapter);
++ iegbe_clean_all_rx_rings(adapter);
++}
++void iegbe_reinit_locked(struct iegbe_adapter *adapter)
++{
++ WARN_ON(in_interrupt());
++ while (test_and_set_bit(__E1000_RESETTING, &adapter->flags))
++ msleep(1);
++ iegbe_down(adapter);
++ iegbe_up(adapter);
++ clear_bit(__E1000_RESETTING, &adapter->flags);
++}
++
++void iegbe_reset(struct iegbe_adapter *adapter)
++{
++ struct iegbe_hw *hw = &adapter->hw;
++ u32 pba = 0, tx_space, min_tx_space, min_rx_space;
++ u16 fc_high_water_mark = E1000_FC_HIGH_DIFF;
++ bool legacy_pba_adjust = false;
++
++ /* Repartition Pba for greater than 9k mtu
++ * To take effect CTRL.RST is required.
++ */
++
++ switch (hw->mac_type) {
++ case iegbe_82542_rev2_0:
++ case iegbe_82542_rev2_1:
++ case iegbe_82543:
++ case iegbe_82544:
++ case iegbe_82540:
++ case iegbe_82541:
++ case iegbe_82541_rev_2:
++ case iegbe_icp_xxxx:
++ legacy_pba_adjust = true;
++ pba = E1000_PBA_48K;
+ break;
+- default:
++ case iegbe_82545:
++ case iegbe_82545_rev_3:
++ case iegbe_82546:
++ case iegbe_82546_rev_3:
+ pba = E1000_PBA_48K;
+ break;
+- }
++ case iegbe_82547:
++ case iegbe_82573:
++ case iegbe_82547_rev_2:
++ legacy_pba_adjust = true;
++ pba = E1000_PBA_30K;
++ break;
++ case iegbe_82571:
++ case iegbe_82572:
++ case iegbe_undefined:
++ case iegbe_num_macs:
++ break;
++ }
++
++ if (legacy_pba_adjust) {
++ if (adapter->netdev->mtu > E1000_RXBUFFER_8192)
++ pba -= 8; /* allocate more FIFO for Tx */
++ /* send an XOFF when there is enough space in the
++ * Rx FIFO to hold one extra full size Rx packet
++ */
+
+- if((adapter->hw.mac_type != iegbe_82573) &&
+- (adapter->rx_buffer_len > E1000_RXBUFFER_8192)) {
+- pba -= 0x8; /* allocate more FIFO for Tx */
+- /* send an XOFF when there is enough space in the
+- * Rx FIFO to hold one extra full size Rx packet
+- */
+- fc_high_water_mark = netdev->mtu + ENET_HEADER_SIZE +
+- ETHERNET_FCS_SIZE + 0x1;
+- fc_low_water_mark = fc_high_water_mark + 0x8;
+- }
+
++ if (hw->mac_type == iegbe_82547) {
++ adapter->tx_fifo_head = 0;
++ adapter->tx_head_addr = pba << E1000_TX_HEAD_ADDR_SHIFT;
++ adapter->tx_fifo_size =
++ (E1000_PBA_40K - pba) << E1000_PBA_BYTES_SHIFT;
++ atomic_set(&adapter->tx_fifo_stall, 0);
++ }
++ } else if (hw->max_frame_size > MAXIMUM_ETHERNET_FRAME_SIZE) {
++ E1000_WRITE_REG(&adapter->hw, PBA, pba);
++
++ /* To maintain wire speed transmits, the Tx FIFO should be
++ * large enough to accomodate two full transmit packets,
++ * rounded up to the next 1KB and expressed in KB. Likewise,
++ * the Rx FIFO should be large enough to accomodate at least
++ * one full receive packet and is similarly rounded up and
++ * expressed in KB. */
++ pba = E1000_READ_REG(&adapter->hw, PBA);
++ /* upper 16 bits has Tx packet buffer allocation size in KB */
++ tx_space = pba >> 16;
++ /* lower 16 bits has Rx packet buffer allocation size in KB */
++ pba &= 0xffff;
++ /* don't include ethernet FCS because hardware appends/strips */
++ min_rx_space = adapter->netdev->mtu + ENET_HEADER_SIZE +
++ VLAN_TAG_SIZE;
++ min_tx_space = min_rx_space;
++ min_tx_space *= 2;
++ min_tx_space = ALIGN(min_tx_space, 1024);
++ min_tx_space >>= 10;
++ min_rx_space = ALIGN(min_rx_space, 1024);
++ min_rx_space >>= 10;
++
++ /* If current Tx allocation is less than the min Tx FIFO size,
++ * and the min Tx FIFO size is less than the current Rx FIFO
++ * allocation, take space away from current Rx allocation */
++ if (tx_space < min_tx_space &&
++ ((min_tx_space - tx_space) < pba)) {
++ pba = pba - (min_tx_space - tx_space);
++
++ /* PCI/PCIx hardware has PBA alignment constraints */
++ switch (hw->mac_type) {
++ case iegbe_82545 ... iegbe_82546_rev_3:
++ pba &= ~(E1000_PBA_8K - 1);
++ break;
++ default:
++ break;
++ }
+
+- if(adapter->hw.mac_type == iegbe_82547) {
+- adapter->tx_fifo_head = 0;
+- adapter->tx_head_addr = pba << E1000_TX_HEAD_ADDR_SHIFT;
+- adapter->tx_fifo_size =
+- (E1000_PBA_40K - pba) << E1000_PBA_BYTES_SHIFT;
+- atomic_set(&adapter->tx_fifo_stall, 0);
++ /* if short on rx space, rx wins and must trump tx
++ * adjustment or use Early Receive if available */
++ if (pba < min_rx_space) {
++ switch (hw->mac_type) {
++ case iegbe_82573:
++ /* ERT enabled in iegbe_configure_rx */
++ break;
++ default:
++ pba = min_rx_space;
++ break;
++ }
++ }
++ }
+ }
+
+ E1000_WRITE_REG(&adapter->hw, PBA, pba);
+
+ /* flow control settings */
+- adapter->hw.fc_high_water = (pba << E1000_PBA_BYTES_SHIFT) -
+- fc_high_water_mark;
+- adapter->hw.fc_low_water = (pba << E1000_PBA_BYTES_SHIFT) -
+- fc_low_water_mark;
+- adapter->hw.fc_pause_time = E1000_FC_PAUSE_TIME;
+- adapter->hw.fc_send_xon = 1;
+- adapter->hw.fc = adapter->hw.original_fc;
++ /* Set the FC high water mark to 90% of the FIFO size.
++ * Required to clear last 3 LSB */
++ fc_high_water_mark = ((pba * 9216)/10) & 0xFFF8;
++ /* We can't use 90% on small FIFOs because the remainder
++ * would be less than 1 full frame. In this case, we size
++ * it to allow at least a full frame above the high water
++ * mark. */
++ if (pba < E1000_PBA_16K)
++ fc_high_water_mark = (pba * 1024) - 1600;
++
++ hw->fc_high_water = fc_high_water_mark;
++ hw->fc_low_water = fc_high_water_mark - 8;
++ hw->fc_pause_time = E1000_FC_PAUSE_TIME;
++ hw->fc_send_xon = 1;
++ hw->fc = hw->original_fc;
+
+ /* Allow time for pending master requests to run */
+- iegbe_reset_hw(&adapter->hw);
+- if(adapter->hw.mac_type >= iegbe_82544){
++ iegbe_reset_hw(hw);
++ if (hw->mac_type >= iegbe_82544)
+ E1000_WRITE_REG(&adapter->hw, WUC, 0);
+- }
+- if(iegbe_init_hw(&adapter->hw)) {
++
++ if (iegbe_init_hw(hw))
+ DPRINTK(PROBE, ERR, "Hardware Error\n");
+- }
+-#ifdef NETIF_F_HW_VLAN_TX
+ iegbe_update_mng_vlan(adapter);
+-#endif
++
++ /* if (adapter->hwflags & HWFLAGS_PHY_PWR_BIT) { */
++ if (hw->mac_type >= iegbe_82544 &&
++ hw->mac_type <= iegbe_82547_rev_2 &&
++ hw->autoneg == 1 &&
++ hw->autoneg_advertised == ADVERTISE_1000_FULL) {
++ u32 ctrl = E1000_READ_REG(&adapter->hw, CTRL);
++ /* clear phy power management bit if we are in gig only mode,
++ * which if enabled will attempt negotiation to 100Mb, which
++ * can cause a loss of link at power off or driver unload */
++ ctrl &= ~E1000_CTRL_SWDPIN3;
++ E1000_WRITE_REG(&adapter->hw, CTRL, ctrl);
++ }
++
+ /* Enable h/w to recognize an 802.1Q VLAN Ethernet packet */
+ E1000_WRITE_REG(&adapter->hw, VET, ETHERNET_IEEE_VLAN_TYPE);
+
+- iegbe_reset_adaptive(&adapter->hw);
+- iegbe_phy_get_info(&adapter->hw, &adapter->phy_info);
+- if(adapter->en_mng_pt) {
+- manc = E1000_READ_REG(&adapter->hw, MANC);
+- manc |= (E1000_MANC_ARP_EN | E1000_MANC_EN_MNG2HOST);
+- E1000_WRITE_REG(&adapter->hw, MANC, manc);
++ iegbe_reset_adaptive(hw);
++ iegbe_phy_get_info(hw, &adapter->phy_info);
++
++ if (!adapter->smart_power_down &&
++ (hw->mac_type == iegbe_82571 ||
++ hw->mac_type == iegbe_82572)) {
++ u16 phy_data = 0;
++ /* speed up time to link by disabling smart power down, ignore
++ * the return value of this function because there is nothing
++ * different we would do if it failed */
++ iegbe_read_phy_reg(hw, IGP02E1000_PHY_POWER_MGMT,
++ &phy_data);
++ phy_data &= ~IGP02E1000_PM_SPD;
++ iegbe_write_phy_reg(hw, IGP02E1000_PHY_POWER_MGMT,
++ phy_data);
++ }
++
++}
++
++/**
++ * Dump the eeprom for users having checksum issues
++ **/
++static void iegbe_dump_eeprom(struct iegbe_adapter *adapter)
++{
++ struct net_device *netdev = adapter->netdev;
++ struct ethtool_eeprom eeprom;
++ const struct ethtool_ops *ops = netdev->ethtool_ops;
++ u8 *data;
++ int i;
++ u16 csum_old, csum_new = 0;
++
++ eeprom.len = ops->get_eeprom_len(netdev);
++ eeprom.offset = 0;
++
++ data = kmalloc(eeprom.len, GFP_KERNEL);
++ if (!data) {
++ printk(KERN_ERR "Unable to allocate memory to dump EEPROM"
++ " data\n");
++ return;
+ }
++
++ ops->get_eeprom(netdev, &eeprom, data);
++
++ csum_old = (data[EEPROM_CHECKSUM_REG * 2]) +
++ (data[EEPROM_CHECKSUM_REG * 2 + 1] << 8);
++ for (i = 0; i < EEPROM_CHECKSUM_REG * 2; i += 2)
++ csum_new += data[i] + (data[i + 1] << 8);
++ csum_new = EEPROM_SUM - csum_new;
++
++ printk(KERN_ERR "/*********************/\n");
++ printk(KERN_ERR "Current EEPROM Checksum : 0x%04x\n", csum_old);
++ printk(KERN_ERR "Calculated : 0x%04x\n", csum_new);
++
++ printk(KERN_ERR "Offset Values\n");
++ printk(KERN_ERR "======== ======\n");
++ print_hex_dump(KERN_ERR, "", DUMP_PREFIX_OFFSET, 16, 1, data, 128, 0);
++
++ printk(KERN_ERR "Include this output when contacting your support "
++ "provider.\n");
++ printk(KERN_ERR "This is not a software error! Something bad "
++ "happened to your hardware or\n");
++ printk(KERN_ERR "EEPROM image. Ignoring this "
++ "problem could result in further problems,\n");
++ printk(KERN_ERR "possibly loss of data, corruption or system hangs!\n");
++ printk(KERN_ERR "The MAC Address will be reset to 00:00:00:00:00:00, "
++ "which is invalid\n");
++ printk(KERN_ERR "and requires you to set the proper MAC "
++ "address manually before continuing\n");
++ printk(KERN_ERR "to enable this network device.\n");
++ printk(KERN_ERR "Please inspect the EEPROM dump and report the issue "
++ "to your hardware vendor\n");
++ printk(KERN_ERR "or Intel Customer Support.\n");
++ printk(KERN_ERR "/*********************/\n");
++
++ kfree(data);
+ }
+
+ /**
+@@ -721,184 +735,166 @@ iegbe_reset(struct iegbe_adapter *adapte
+ * The OS initialization, configuring of the adapter private structure,
+ * and a hardware reset occur.
+ **/
+-
+-static int __devinit
+-iegbe_probe(struct pci_dev *pdev,
++static int __devinit iegbe_probe(struct pci_dev *pdev,
+ const struct pci_device_id *ent)
+ {
+- struct net_device *netdev;
+- struct iegbe_adapter *adapter;
+- unsigned long mmio_start, mmio_len;
+- uint32_t ctrl_ext;
+- uint32_t swsm;
++ struct net_device *netdev;
++ struct iegbe_adapter *adapter;
++ struct iegbe_hw *hw;
+
+ static int cards_found = 0;
++ int i, err, pci_using_dac;
++ u16 eeprom_data = 0;
++ u16 eeprom_apme_mask = E1000_EEPROM_APME;
++ int bars;
++ DECLARE_MAC_BUF(mac);
+
+- int i, err, pci_using_dac;
+- uint16_t eeprom_data = 0;
+- uint16_t eeprom_apme_mask = E1000_EEPROM_APME;
++ bars = pci_select_bars(pdev, IORESOURCE_MEM);
++ err = pci_enable_device(pdev);
+
++ if (err)
++ return err;
+
+- if((err = pci_enable_device(pdev))) {
+- return err;
+- }
+- if(!(err = pci_set_dma_mask(pdev, PCI_DMA_64BIT))) {
++ if (!pci_set_dma_mask(pdev, DMA_64BIT_MASK) &&
++ !pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK)) {
+ pci_using_dac = 1;
+- } else {
+- if((err = pci_set_dma_mask(pdev, PCI_DMA_32BIT))) {
+- E1000_ERR("No usable DMA configuration, aborting\n");
+- return err;
+- }
++ } else {
++ err = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
++ if (err) {
++ err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
++ if (err) {
++ E1000_ERR("No usable DMA configuration, "
++ "aborting\n");
++ goto err_dma;
++ }
++ }
+ pci_using_dac = 0;
+- }
+-
+- if((err = pci_request_regions(pdev, iegbe_driver_name))) {
+- return err;
+ }
+- pci_set_master(pdev);
+
+- netdev = alloc_etherdev(sizeof(struct iegbe_adapter));
+- if(!netdev) {
+- err = -ENOMEM;
+- goto err_alloc_etherdev;
+- }
++ err = pci_request_selected_regions(pdev, bars, iegbe_driver_name);
++ if (err)
++ goto err_pci_reg;
++
++ pci_set_master(pdev);
++
++ err = -ENOMEM;
++ netdev = alloc_etherdev(sizeof(struct iegbe_adapter));
++ if (!netdev)
++ goto err_alloc_etherdev;
+
+- SET_MODULE_OWNER(netdev);
+ SET_NETDEV_DEV(netdev, &pdev->dev);
+
+- pci_set_drvdata(pdev, netdev);
+- adapter = netdev_priv(netdev);
+- adapter->netdev = netdev;
+- adapter->pdev = pdev;
+- adapter->hw.back = adapter;
+- adapter->msg_enable = (0x1 << debug) - 0x1;
+-
+- mmio_start = pci_resource_start(pdev, BAR_0);
+- mmio_len = pci_resource_len(pdev, BAR_0);
+-
+- adapter->hw.hw_addr = ioremap(mmio_start, mmio_len);
+- if(!adapter->hw.hw_addr) {
+- err = -EIO;
+- goto err_ioremap;
+- }
+-
+- for(i = BAR_1; i <= BAR_5; i++) {
+- if(pci_resource_len(pdev, i) == 0) {
+- continue;
+- }
+- if(pci_resource_flags(pdev, i) & IORESOURCE_IO) {
+- adapter->hw.io_base = pci_resource_start(pdev, i);
+- break;
+- }
+- }
+-
+- netdev->open = &iegbe_open;
+- netdev->stop = &iegbe_close;
+- netdev->hard_start_xmit = &iegbe_xmit_frame;
+- netdev->get_stats = &iegbe_get_stats;
+- netdev->set_multicast_list = &iegbe_set_multi;
++ pci_set_drvdata(pdev, netdev);
++ adapter = netdev_priv(netdev);
++ adapter->netdev = netdev;
++ adapter->pdev = pdev;
++ adapter->msg_enable = (1 << debug) - 1;
++ adapter->bars = bars;
++
++ hw = &adapter->hw;
++ hw->back = adapter;
++
++ err = -EIO;
++ hw->hw_addr = ioremap(pci_resource_start(pdev, BAR_0),
++ pci_resource_len(pdev, BAR_0));
++ if (!hw->hw_addr)
++ goto err_ioremap;
++
++ netdev->open = &iegbe_open;
++ netdev->stop = &iegbe_close;
++ netdev->hard_start_xmit = &iegbe_xmit_frame;
++ netdev->get_stats = &iegbe_get_stats;
++ netdev->set_rx_mode = &iegbe_set_rx_mode;
+ netdev->set_mac_address = &iegbe_set_mac;
+- netdev->change_mtu = &iegbe_change_mtu;
+- netdev->do_ioctl = &iegbe_ioctl;
++ netdev->change_mtu = &iegbe_change_mtu;
++ netdev->do_ioctl = &iegbe_ioctl;
+ set_ethtool_ops(netdev);
+-#ifdef HAVE_TX_TIMEOUT
+- netdev->tx_timeout = &iegbe_tx_timeout;
+- netdev->watchdog_timeo = 0x5 * HZ;
+-#endif
+-#ifdef CONFIG_E1000_NAPI
+- netdev->poll = &iegbe_clean;
+- netdev->weight = 0x40;
+-#endif
+-#ifdef NETIF_F_HW_VLAN_TX
+- netdev->vlan_rx_register = iegbe_vlan_rx_register;
+- netdev->vlan_rx_add_vid = iegbe_vlan_rx_add_vid;
+- netdev->vlan_rx_kill_vid = iegbe_vlan_rx_kill_vid;
+-#endif
++ netdev->tx_timeout = &iegbe_tx_timeout;
++ netdev->watchdog_timeo = 5 * HZ;
++ netif_napi_add(netdev, &adapter->napi, iegbe_clean, 64);
++ netdev->vlan_rx_register = iegbe_vlan_rx_register;
++ netdev->vlan_rx_add_vid = iegbe_vlan_rx_add_vid;
++ netdev->vlan_rx_kill_vid = iegbe_vlan_rx_kill_vid;
+ #ifdef CONFIG_NET_POLL_CONTROLLER
+- netdev->poll_controller = iegbe_netpoll;
++ netdev->poll_controller = iegbe_netpoll;
+ #endif
+- strcpy(netdev->name, pci_name(pdev));
++ strncpy(netdev->name, pci_name(pdev), sizeof(netdev->name) - 1);
+
+- netdev->mem_start = mmio_start;
+- netdev->mem_end = mmio_start + mmio_len;
+- netdev->base_addr = adapter->hw.io_base;
+
+- adapter->bd_number = cards_found;
++ adapter->bd_number = cards_found;
+
+- /* setup the private structure */
++ /* setup the private structure */
+
+- if((err = iegbe_sw_init(adapter))) {
+- goto err_sw_init;
+- }
+- if((err = iegbe_check_phy_reset_block(&adapter->hw))) {
+- DPRINTK(PROBE, INFO, "PHY reset is blocked due to SOL/IDER session.\n");
+- }
+-#ifdef MAX_SKB_FRAGS
+- if(adapter->hw.mac_type >= iegbe_82543) {
+-#ifdef NETIF_F_HW_VLAN_TX
+- netdev->features = NETIF_F_SG |
+- NETIF_F_HW_CSUM |
+- NETIF_F_HW_VLAN_TX |
+- NETIF_F_HW_VLAN_RX |
+- NETIF_F_HW_VLAN_FILTER;
+-#else
+- netdev->features = NETIF_F_SG | NETIF_F_HW_CSUM;
+-#endif
+- }
++ err = iegbe_sw_init(adapter);
++ if (err)
++ goto err_sw_init;
++ err = -EIO;
++ if (iegbe_check_phy_reset_block(hw))
++ DPRINTK(PROBE, INFO, "PHY reset is blocked due to SOL/IDER session.\n");
+
+-#ifdef NETIF_F_TSO
+- if((adapter->hw.mac_type >= iegbe_82544) &&
+- (adapter->hw.mac_type != iegbe_82547)) {
+- netdev->features |= NETIF_F_TSO;
+- }
+-#ifdef NETIF_F_TSO_IPV6
+- if(adapter->hw.mac_type > iegbe_82547_rev_2) {
+- netdev->features |= NETIF_F_TSO_IPV6;
+- }
+-#endif
+-#endif
+- if(pci_using_dac) {
+- netdev->features |= NETIF_F_HIGHDMA;
++ if (hw->mac_type >= iegbe_82543) {
++ netdev->features = NETIF_F_SG |
++ NETIF_F_HW_CSUM |
++ NETIF_F_HW_VLAN_TX |
++ NETIF_F_HW_VLAN_RX |
++ NETIF_F_HW_VLAN_FILTER;
+ }
+-#endif
+-#ifdef NETIF_F_LLTX
+- netdev->features |= NETIF_F_LLTX;
+-#endif
+
+- adapter->en_mng_pt = iegbe_enable_mng_pass_thru(&adapter->hw);
++ if ((hw->mac_type >= iegbe_82544) &&
++ (hw->mac_type != iegbe_82547))
++ netdev->features |= NETIF_F_TSO;
+
+- /* before reading the EEPROM, reset the controller to
+- * put the device in a known good starting state */
++ if (hw->mac_type > iegbe_82547_rev_2)
++ netdev->features |= NETIF_F_TSO6;
++ if (pci_using_dac)
++ netdev->features |= NETIF_F_HIGHDMA;
++
++ netdev->features |= NETIF_F_LLTX;
+
+- iegbe_reset_hw(&adapter->hw);
++ adapter->en_mng_pt = iegbe_enable_mng_pass_thru(hw);
+
+- /* make sure the EEPROM is good */
+- if(iegbe_validate_eeprom_checksum(&adapter->hw) < 0) {
+- DPRINTK(PROBE, ERR, "The EEPROM Checksum Is Not Valid\n");
+- err = -EIO;
++ /* initialize eeprom parameters */
++
++ if (iegbe_init_eeprom_params(hw)) {
++ E1000_ERR("EEPROM initialization failed\n");
+ goto err_eeprom;
+ }
+
+- /* copy the MAC address out of the EEPROM */
++ /* before reading the EEPROM, reset the controller to
++ * put the device in a known good starting state */
+
+- if(iegbe_read_mac_addr(&adapter->hw)) {
+- DPRINTK(PROBE, ERR, "EEPROM Read Error\n");
+- }
+- memcpy(netdev->dev_addr, adapter->hw.mac_addr, netdev->addr_len);
++ iegbe_reset_hw(hw);
+
+- if(!is_valid_ether_addr(netdev->dev_addr)) {
+- DPRINTK(PROBE, ERR, "Invalid MAC Address\n");
+- err = -EIO;
+- goto err_eeprom;
+- }
++ /* make sure the EEPROM is good */
++ if (iegbe_validate_eeprom_checksum(hw) < 0) {
++ DPRINTK(PROBE, ERR, "The EEPROM Checksum Is Not Valid\n");
++ iegbe_dump_eeprom(adapter);
++ /*
++ * set MAC address to all zeroes to invalidate and temporary
++ * disable this device for the user. This blocks regular
++ * traffic while still permitting ethtool ioctls from reaching
++ * the hardware as well as allowing the user to run the
++ * interface after manually setting a hw addr using
++ * `ip set address`
++ */
++ memset(hw->mac_addr, 0, netdev->addr_len);
++ } else {
++ /* copy the MAC address out of the EEPROM */
++ if (iegbe_read_mac_addr(hw))
++ DPRINTK(PROBE, ERR, "EEPROM Read Error\n");
++ }
++ /* don't block initalization here due to bad MAC address */
++ memcpy(netdev->dev_addr, hw->mac_addr, netdev->addr_len);
++ memcpy(netdev->perm_addr, hw->mac_addr, netdev->addr_len);
+
+- iegbe_read_part_num(&adapter->hw, &(adapter->part_num));
++ if (!is_valid_ether_addr(netdev->perm_addr))
++ DPRINTK(PROBE, ERR, "Invalid MAC Address\n");
+
+- iegbe_get_bus_info(&adapter->hw);
++ iegbe_get_bus_info(hw);
+
+ init_timer(&adapter->tx_fifo_stall_timer);
+ adapter->tx_fifo_stall_timer.function = &iegbe_82547_tx_fifo_stall;
+- adapter->tx_fifo_stall_timer.data = (unsigned long) adapter;
++ adapter->tx_fifo_stall_timer.data = (unsigned long)adapter;
+
+ init_timer(&adapter->watchdog_timer);
+ adapter->watchdog_timer.function = &iegbe_watchdog;
+@@ -906,75 +902,50 @@ iegbe_probe(struct pci_dev *pdev,
+
+ init_timer(&adapter->phy_info_timer);
+ adapter->phy_info_timer.function = &iegbe_update_phy_info;
+- adapter->phy_info_timer.data = (unsigned long) adapter;
+-
+- INIT_WORK(&adapter->tx_timeout_task,
+- (void (*)(void *))iegbe_tx_timeout_task, netdev);
++ adapter->phy_info_timer.data = (unsigned long)adapter;
+
+- /* we're going to reset, so assume we have no link for now */
+-
+- netif_carrier_off(netdev);
+- netif_stop_queue(netdev);
++ INIT_WORK(&adapter->reset_task, iegbe_reset_task);
+
+- iegbe_check_options(adapter);
++ iegbe_check_options(adapter);
+
+- /* Initial Wake on LAN setting
+- * If APM wake is enabled in the EEPROM,
+- * enable the ACPI Magic Packet filter
+- */
++ /* Initial Wake on LAN setting
++ * If APM wake is enabled in the EEPROM,
++ * enable the ACPI Magic Packet filter
++ */
+
+- switch(adapter->hw.mac_type) {
+- case iegbe_82542_rev2_0:
+- case iegbe_82542_rev2_1:
+- case iegbe_82543:
+- break;
+- case iegbe_82544:
+- iegbe_read_eeprom(&adapter->hw,
+- EEPROM_INIT_CONTROL2_REG, 1, &eeprom_data);
+- eeprom_apme_mask = E1000_EEPROM_82544_APM;
+- break;
++ switch(adapter->hw.mac_type) {
++ case iegbe_82542_rev2_0:
++ case iegbe_82542_rev2_1:
++ case iegbe_82543:
++ break;
++ case iegbe_82544:
++ iegbe_read_eeprom(&adapter->hw,
++ EEPROM_INIT_CONTROL2_REG, 1, &eeprom_data);
++ eeprom_apme_mask = E1000_EEPROM_82544_APM;
++ break;
+ case iegbe_icp_xxxx:
+- iegbe_read_eeprom(&adapter->hw,
+- EEPROM_INIT_CONTROL3_ICP_xxxx(adapter->bd_number),
+- 1, &eeprom_data);
+- eeprom_apme_mask = EEPROM_CTRL3_APME_ICP_xxxx;
+- break;
+- case iegbe_82546:
+- case iegbe_82546_rev_3:
+- if((E1000_READ_REG(&adapter->hw, STATUS) & E1000_STATUS_FUNC_1)
+- && (adapter->hw.media_type == iegbe_media_type_copper)) {
+- iegbe_read_eeprom(&adapter->hw,
+- EEPROM_INIT_CONTROL3_PORT_B, 1, &eeprom_data);
+- break;
+- }
+- /* Fall Through */
+- default:
+- iegbe_read_eeprom(&adapter->hw,
+- EEPROM_INIT_CONTROL3_PORT_A, 1, &eeprom_data);
+- break;
+- }
++ iegbe_read_eeprom(&adapter->hw,
++ EEPROM_INIT_CONTROL3_ICP_xxxx(adapter->bd_number),
++ 1, &eeprom_data);
++ eeprom_apme_mask = EEPROM_CTRL3_APME_ICP_xxxx;
++ break;
++ case iegbe_82546:
++ case iegbe_82546_rev_3:
++ if((E1000_READ_REG(&adapter->hw, STATUS) & E1000_STATUS_FUNC_1)
++ && (adapter->hw.media_type == iegbe_media_type_copper)) {
++ iegbe_read_eeprom(&adapter->hw,
++ EEPROM_INIT_CONTROL3_PORT_B, 1, &eeprom_data);
++ break;
++ }
++ /* Fall Through */
++ default:
++ iegbe_read_eeprom(&adapter->hw,
++ EEPROM_INIT_CONTROL3_PORT_A, 1, &eeprom_data);
++ break;
++ }
+ if(eeprom_data & eeprom_apme_mask) {
+- adapter->wol |= E1000_WUFC_MAG;
++ adapter->wol |= E1000_WUFC_MAG;
+ }
+- /* reset the hardware with the new settings */
+- iegbe_reset(adapter);
+-
+- /* Let firmware know the driver has taken over */
+- switch(adapter->hw.mac_type) {
+- case iegbe_82571:
+- case iegbe_82572:
+- ctrl_ext = E1000_READ_REG(&adapter->hw, CTRL_EXT);
+- E1000_WRITE_REG(&adapter->hw, CTRL_EXT,
+- ctrl_ext | E1000_CTRL_EXT_DRV_LOAD);
+- break;
+- case iegbe_82573:
+- swsm = E1000_READ_REG(&adapter->hw, SWSM);
+- E1000_WRITE_REG(&adapter->hw, SWSM,
+- swsm | E1000_SWSM_DRV_LOAD);
+- break;
+- default:
+- break;
+- }
+
+ /* The ICP_xxxx device has multiple, duplicate interrupt
+ * registers, so disable all but the first one
+@@ -987,24 +958,40 @@ iegbe_probe(struct pci_dev *pdev,
+ E1000_WRITE_REG(&adapter->hw, IMC2, ~0UL);
+ }
+
+- strcpy(netdev->name, "eth%d");
+- if((err = register_netdev(netdev))) {
+- goto err_register;
+- }
++ iegbe_reset(adapter);
++ netif_carrier_off(netdev);
++ netif_stop_queue(netdev);
++ strcpy(netdev->name, "eth%d");
++ err = register_netdev(netdev);
++ if (err)
++ goto err_register;
++
+ DPRINTK(PROBE, INFO, "Intel(R) PRO/1000 Network Connection\n");
+
+- cards_found++;
+- return 0;
++ cards_found++;
++ return 0;
+
+ err_register:
+-err_sw_init:
+ err_eeprom:
+- iounmap(adapter->hw.hw_addr);
++ if (!iegbe_check_phy_reset_block(hw))
++ iegbe_phy_hw_reset(hw);
++ if (hw->flash_address)
++ iounmap(hw->flash_address);
++ for (i = 0; i < adapter->num_rx_queues; i++)
++ dev_put(&adapter->polling_netdev[i]);
++ kfree(adapter->tx_ring);
++ kfree(adapter->rx_ring);
++ kfree(adapter->polling_netdev);
++err_sw_init:
++ iounmap(hw->hw_addr);
+ err_ioremap:
+- free_netdev(netdev);
++ free_netdev(netdev);
+ err_alloc_etherdev:
+- pci_release_regions(pdev);
+- return err;
++ pci_release_selected_regions(pdev, bars);
++err_pci_reg:
++err_dma:
++ pci_disable_device(pdev);
++ return err;
+ }
+
+ /**
+@@ -1020,64 +1007,36 @@ err_alloc_etherdev:
+ static void __devexit
+ iegbe_remove(struct pci_dev *pdev)
+ {
+- struct net_device *netdev = pci_get_drvdata(pdev);
+- struct iegbe_adapter *adapter = netdev_priv(netdev);
+- uint32_t ctrl_ext;
+- uint32_t manc, swsm;
+-#ifdef CONFIG_E1000_NAPI
+- int i;
+-#endif
+-
+- if(adapter->hw.mac_type >= iegbe_82540
+- && adapter->hw.mac_type != iegbe_icp_xxxx
+- && adapter->hw.media_type == iegbe_media_type_copper) {
+- manc = E1000_READ_REG(&adapter->hw, MANC);
+- if(manc & E1000_MANC_SMBUS_EN) {
+- manc |= E1000_MANC_ARP_EN;
+- E1000_WRITE_REG(&adapter->hw, MANC, manc);
+- }
+- }
+-
+- switch(adapter->hw.mac_type) {
+- case iegbe_82571:
+- case iegbe_82572:
+- ctrl_ext = E1000_READ_REG(&adapter->hw, CTRL_EXT);
+- E1000_WRITE_REG(&adapter->hw, CTRL_EXT,
+- ctrl_ext & ~E1000_CTRL_EXT_DRV_LOAD);
+- break;
+- case iegbe_82573:
+- swsm = E1000_READ_REG(&adapter->hw, SWSM);
+- E1000_WRITE_REG(&adapter->hw, SWSM,
+- swsm & ~E1000_SWSM_DRV_LOAD);
+- break;
+-
+- default:
+- break;
+- }
++ struct net_device *netdev = pci_get_drvdata(pdev);
++ struct iegbe_adapter *adapter = netdev_priv(netdev);
++ uint32_t manc;
++ int i;
++
++ if(adapter->hw.mac_type >= iegbe_82540
++ && adapter->hw.mac_type != iegbe_icp_xxxx
++ && adapter->hw.media_type == iegbe_media_type_copper) {
++ manc = E1000_READ_REG(&adapter->hw, MANC);
++ if(manc & E1000_MANC_SMBUS_EN) {
++ manc |= E1000_MANC_ARP_EN;
++ E1000_WRITE_REG(&adapter->hw, MANC, manc);
++ }
++ }
+
+- unregister_netdev(netdev);
+-#ifdef CONFIG_E1000_NAPI
+- for (i = 0; i < adapter->num_queues; i++)
++ unregister_netdev(netdev);
++ for (i = 0x0; i < adapter->num_rx_queues; i++)
+ dev_put(&adapter->polling_netdev[i]);
+-#endif
+
+ if(!iegbe_check_phy_reset_block(&adapter->hw)) {
+- iegbe_phy_hw_reset(&adapter->hw);
++ iegbe_phy_hw_reset(&adapter->hw);
+ }
+- kfree(adapter->tx_ring);
+- kfree(adapter->rx_ring);
+-#ifdef CONFIG_E1000_NAPI
+- kfree(adapter->polling_netdev);
+-#endif
++ kfree(adapter->tx_ring);
++ kfree(adapter->rx_ring);
++ kfree(adapter->polling_netdev);
+
+- iounmap(adapter->hw.hw_addr);
+- pci_release_regions(pdev);
++ iounmap(adapter->hw.hw_addr);
++ pci_release_regions(pdev);
+
+-#ifdef CONFIG_E1000_MQ
+- free_percpu(adapter->cpu_netdev);
+- free_percpu(adapter->cpu_tx_ring);
+-#endif
+- free_netdev(netdev);
++ free_netdev(netdev);
+ }
+
+ /**
+@@ -1092,118 +1051,78 @@ iegbe_remove(struct pci_dev *pdev)
+ static int __devinit
+ iegbe_sw_init(struct iegbe_adapter *adapter)
+ {
+- struct iegbe_hw *hw = &adapter->hw;
+- struct net_device *netdev = adapter->netdev;
+- struct pci_dev *pdev = adapter->pdev;
+-#ifdef CONFIG_E1000_NAPI
+- int i;
+-#endif
++ struct iegbe_hw *hw = &adapter->hw;
++ struct net_device *netdev = adapter->netdev;
++ struct pci_dev *pdev = adapter->pdev;
++ int i;
+
+- /* PCI config space info */
++ /* PCI config space info */
+
+- hw->vendor_id = pdev->vendor;
+- hw->device_id = pdev->device;
+- hw->subsystem_vendor_id = pdev->subsystem_vendor;
+- hw->subsystem_id = pdev->subsystem_device;
++ hw->vendor_id = pdev->vendor;
++ hw->device_id = pdev->device;
++ hw->subsystem_vendor_id = pdev->subsystem_vendor;
++ hw->subsystem_id = pdev->subsystem_device;
+
+- pci_read_config_byte(pdev, PCI_REVISION_ID, &hw->revision_id);
++ pci_read_config_byte(pdev, PCI_REVISION_ID, &hw->revision_id);
+
+- pci_read_config_word(pdev, PCI_COMMAND, &hw->pci_cmd_word);
++ pci_read_config_word(pdev, PCI_COMMAND, &hw->pci_cmd_word);
+
+- adapter->rx_buffer_len = E1000_RXBUFFER_2048;
+- adapter->rx_ps_bsize0 = E1000_RXBUFFER_256;
+- hw->max_frame_size = netdev->mtu +
+- ENET_HEADER_SIZE + ETHERNET_FCS_SIZE;
+- hw->min_frame_size = MINIMUM_ETHERNET_FRAME_SIZE;
++ adapter->rx_buffer_len = E1000_RXBUFFER_2048;
++ adapter->rx_ps_bsize0 = E1000_RXBUFFER_256;
++ hw->max_frame_size = netdev->mtu +
++ ENET_HEADER_SIZE + ETHERNET_FCS_SIZE;
++ hw->min_frame_size = MINIMUM_ETHERNET_FRAME_SIZE;
+
+- /* identify the MAC */
++ /* identify the MAC */
+
+- if(iegbe_set_mac_type(hw)) {
++ if (iegbe_set_mac_type(hw)) {
+ DPRINTK(PROBE, ERR, "Unknown MAC Type\n");
+ return -EIO;
+ }
+
+- /* initialize eeprom parameters */
+-
+- if(iegbe_init_eeprom_params(hw)) {
+- E1000_ERR("EEPROM initialization failed\n");
+- return -EIO;
+- }
+-
+- switch(hw->mac_type) {
+- default:
+- break;
+- case iegbe_82541:
+- case iegbe_82547:
+- case iegbe_82541_rev_2:
+- case iegbe_82547_rev_2:
+- hw->phy_init_script = 0x1;
+- break;
+- }
+-
+- iegbe_set_media_type(hw);
++ iegbe_set_media_type(hw);
+
+- hw->wait_autoneg_complete = FALSE;
+- hw->tbi_compatibility_en = TRUE;
+- hw->adaptive_ifs = TRUE;
++ hw->wait_autoneg_complete = FALSE;
++ hw->tbi_compatibility_en = TRUE;
++ hw->adaptive_ifs = TRUE;
+
+- /* Copper options */
++ /* Copper options */
+
+- if(hw->media_type == iegbe_media_type_copper
++ if(hw->media_type == iegbe_media_type_copper
+ || (hw->media_type == iegbe_media_type_oem
+ && iegbe_oem_phy_is_copper(&adapter->hw))) {
+- hw->mdix = AUTO_ALL_MODES;
+- hw->disable_polarity_correction = FALSE;
+- hw->master_slave = E1000_MASTER_SLAVE;
+- }
++ hw->mdix = AUTO_ALL_MODES;
++ hw->disable_polarity_correction = FALSE;
++ hw->master_slave = E1000_MASTER_SLAVE;
++ }
+
+-#ifdef CONFIG_E1000_MQ
+- /* Number of supported queues */
+- switch (hw->mac_type) {
+- case iegbe_82571:
+- case iegbe_82572:
+- adapter->num_queues = 0x2;
+- break;
+- default:
+- adapter->num_queues = 0x1;
+- break;
+- }
+- adapter->num_queues = min(adapter->num_queues, num_online_cpus());
+-#else
+- adapter->num_queues = 0x1;
+-#endif
++ adapter->num_tx_queues = 0x1;
++ adapter->num_rx_queues = 0x1;
+
+ if (iegbe_alloc_queues(adapter)) {
+ DPRINTK(PROBE, ERR, "Unable to allocate memory for queues\n");
+ return -ENOMEM;
+ }
+
+-#ifdef CONFIG_E1000_NAPI
+- for (i = 0; i < adapter->num_queues; i++) {
++ for (i = 0; i < adapter->num_rx_queues; i++) {
+ adapter->polling_netdev[i].priv = adapter;
+- adapter->polling_netdev[i].poll = &iegbe_clean;
+- adapter->polling_netdev[i].weight = 0x40;
+ dev_hold(&adapter->polling_netdev[i]);
+ set_bit(__LINK_STATE_START, &adapter->polling_netdev[i].state);
+ }
+-#endif
+-
+-#ifdef CONFIG_E1000_MQ
+- iegbe_setup_queue_mapping(adapter);
+-#endif
++ spin_lock_init(&adapter->tx_queue_lock);
+
+ /*
+- * for ICP_XXXX style controllers, it is necessary to keep
+- * track of the last known state of the link to determine if
+- * the link experienced a change in state when iegbe_watchdog
+- * fires
+- */
+- adapter->hw.icp_xxxx_is_link_up = FALSE;
++ * for ICP_XXXX style controllers, it is necessary to keep
++ * track of the last known state of the link to determine if
++ * the link experienced a change in state when iegbe_watchdog
++ * fires
++ */
++ adapter->hw.icp_xxxx_is_link_up = FALSE;
+
+- atomic_set(&adapter->irq_sem, 1);
+- spin_lock_init(&adapter->stats_lock);
++ spin_lock_init(&adapter->stats_lock);
+
+- return 0;
++ set_bit(__E1000_DOWN, &adapter->flags);
++ return 0x0;
+ }
+
+ /**
+@@ -1218,71 +1137,31 @@ iegbe_sw_init(struct iegbe_adapter *adap
+ static int __devinit
+ iegbe_alloc_queues(struct iegbe_adapter *adapter)
+ {
+- int size;
+
+- size = sizeof(struct iegbe_tx_ring) * adapter->num_queues;
+- adapter->tx_ring = kmalloc(size, GFP_KERNEL);
+- if (!adapter->tx_ring){
++
++ adapter->tx_ring = kcalloc(adapter->num_tx_queues,
++ sizeof(struct iegbe_tx_ring), GFP_KERNEL);
++ if (!adapter->tx_ring)
+ return -ENOMEM;
+- }
+- memset(adapter->tx_ring, 0, size);
+
+- size = sizeof(struct iegbe_rx_ring) * adapter->num_queues;
+- adapter->rx_ring = kmalloc(size, GFP_KERNEL);
++ adapter->rx_ring = kcalloc(adapter->num_rx_queues,
++ sizeof(struct iegbe_rx_ring), GFP_KERNEL);
+ if (!adapter->rx_ring) {
+ kfree(adapter->tx_ring);
+ return -ENOMEM;
+ }
+- memset(adapter->rx_ring, 0, size);
+
+-#ifdef CONFIG_E1000_NAPI
+- size = sizeof(struct net_device) * adapter->num_queues;
+- adapter->polling_netdev = kmalloc(size, GFP_KERNEL);
++ adapter->polling_netdev = kcalloc(adapter->num_rx_queues,
++ sizeof(struct net_device),
++ GFP_KERNEL);
+ if (!adapter->polling_netdev) {
+ kfree(adapter->tx_ring);
+ kfree(adapter->rx_ring);
+ return -ENOMEM;
+ }
+- memset(adapter->polling_netdev, 0, size);
+-#endif
+-
+- return E1000_SUCCESS;
+-}
+
+-#ifdef CONFIG_E1000_MQ
+-static void __devinit
+-iegbe_setup_queue_mapping(struct iegbe_adapter *adapter)
+-{
+- int i, cpu;
+-
+- adapter->rx_sched_call_data.func = iegbe_rx_schedule;
+- adapter->rx_sched_call_data.info = adapter->netdev;
+- cpus_clear(adapter->rx_sched_call_data.cpumask);
+-
+- adapter->cpu_netdev = alloc_percpu(struct net_device *);
+- adapter->cpu_tx_ring = alloc_percpu(struct iegbe_tx_ring *);
+-
+- lock_cpu_hotplug();
+- i = 0;
+- for_each_online_cpu(cpu) {
+- *per_cpu_ptr(adapter->cpu_tx_ring, cpu) =
+- &adapter->tx_ring[i % adapter->num_queues];
+- /* This is incomplete because we'd like to assign separate
+- * physical cpus to these netdev polling structures and
+- * avoid saturating a subset of cpus.
+- */
+- if (i < adapter->num_queues) {
+- *per_cpu_ptr(adapter->cpu_netdev, cpu) =
+- &adapter->polling_netdev[i];
+- adapter->cpu_for_queue[i] = cpu;
+- } else {
+- *per_cpu_ptr(adapter->cpu_netdev, cpu) = NULL;
+- }
+- i++;
+- }
+- unlock_cpu_hotplug();
++ return E1000_SUCCESS;
+ }
+-#endif
+
+ /**
+ * iegbe_open - Called when a network interface is made active
+@@ -1300,40 +1179,62 @@ iegbe_setup_queue_mapping(struct iegbe_a
+ static int
+ iegbe_open(struct net_device *netdev)
+ {
+- struct iegbe_adapter *adapter = netdev_priv(netdev);
+- int err;
++ struct iegbe_adapter *adapter = netdev_priv(netdev);
++ struct iegbe_hw *hw = &adapter->hw;
++ int err;
++
+
++ /* allocate receive descriptors */
++ if (test_bit(__E1000_TESTING, &adapter->flags))
++ return -EBUSY;
+
+- /* allocate receive descriptors */
++ /* allocate transmit descriptors */
++ err = iegbe_setup_all_tx_resources(adapter);
++ if (err)
++ goto err_setup_tx;
+
+- if ((err = iegbe_setup_all_rx_resources(adapter))) {
++ err = iegbe_setup_all_rx_resources(adapter);
++ if (err)
+ goto err_setup_rx;
+- }
+- /* allocate transmit descriptors */
+- if ((err = iegbe_setup_all_tx_resources(adapter))) {
+- goto err_setup_tx;
+- }
+- if ((err = iegbe_up(adapter))) {
+- goto err_up;
+- }
+-#ifdef NETIF_F_HW_VLAN_TX
+- adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
+- if ((adapter->hw.mng_cookie.status &
+- E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT)) {
+- iegbe_update_mng_vlan(adapter);
+- }
+-#endif
+
+- return E1000_SUCCESS;
++ iegbe_power_up_phy(adapter);
++ adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
++ if ((hw->mng_cookie.status &
++ E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT)) {
++ iegbe_update_mng_vlan(adapter);
++ }
++
++ /* before we allocate an interrupt, we must be ready to handle it.
++ * Setting DEBUG_SHIRQ in the kernel makes it fire an interrupt
++ * as soon as we call pci_request_irq, so we have to setup our
++ * clean_rx handler before we do so. */
++ iegbe_configure(adapter);
++ err = iegbe_request_irq(adapter);
++ if (err)
++ goto err_req_irq;
+
+-err_up:
+- iegbe_free_all_tx_resources(adapter);
+-err_setup_tx:
+- iegbe_free_all_rx_resources(adapter);
++ /* From here on the code is the same as iegbe_up() */
++ clear_bit(__E1000_DOWN, &adapter->flags);
++
++ napi_enable(&adapter->napi);
++
++ iegbe_irq_enable(adapter);
++
++ netif_start_queue(netdev);
++
++ /* fire a link status change interrupt to start the watchdog */
++
++ return E1000_SUCCESS;
++
++err_req_irq:
++ iegbe_power_down_phy(adapter);
++ iegbe_free_all_rx_resources(adapter);
+ err_setup_rx:
+- iegbe_reset(adapter);
++ iegbe_free_all_tx_resources(adapter);
++err_setup_tx:
++ iegbe_reset(adapter);
+
+- return err;
++ return err;
+ }
+
+ /**
+@@ -1348,22 +1249,25 @@ err_setup_rx:
+ * hardware, and all transmit and receive resources are freed.
+ **/
+
+-static int
+-iegbe_close(struct net_device *netdev)
++static int iegbe_close(struct net_device *netdev)
+ {
+- struct iegbe_adapter *adapter = netdev_priv(netdev);
+-
+- iegbe_down(adapter);
+-
+- iegbe_free_all_tx_resources(adapter);
+- iegbe_free_all_rx_resources(adapter);
++ struct iegbe_adapter *adapter = netdev_priv(netdev);
++ struct iegbe_hw *hw = &adapter->hw;
+
+-#ifdef NETIF_F_HW_VLAN_TX
+- if((adapter->hw.mng_cookie.status &
+- E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT)) {
++ WARN_ON(test_bit(__E1000_RESETTING, &adapter->flags));
++ iegbe_down(adapter);
++ iegbe_power_down_phy(adapter);
++ iegbe_free_irq(adapter);
++
++ iegbe_free_all_tx_resources(adapter);
++ iegbe_free_all_rx_resources(adapter);
++
++ if ((hw->mng_cookie.status &
++ E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) &&
++ !(adapter->vlgrp &&
++ vlan_group_get_device(adapter->vlgrp, adapter->mng_vlan_id))) {
+ iegbe_vlan_rx_kill_vid(netdev, adapter->mng_vlan_id);
+ }
+-#endif
+ return 0;
+ }
+
+@@ -1375,19 +1279,19 @@ iegbe_close(struct net_device *netdev)
+ **/
+ static inline boolean_t
+ iegbe_check_64k_bound(struct iegbe_adapter *adapter,
+- void *start, unsigned long len)
++ void *start, unsigned long len)
+ {
+- unsigned long begin = (unsigned long) start;
+- unsigned long end = begin + len;
++ unsigned long begin = (unsigned long) start;
++ unsigned long end = begin + len;
+
+- /* First rev 82545 and 82546 need to not allow any memory
+- * write location to cross 64k boundary due to errata 23 */
+- if(adapter->hw.mac_type == iegbe_82545 ||
+- adapter->hw.mac_type == iegbe_82546) {
+- return ((begin ^ (end - 1)) >> 0x10) != 0 ? FALSE : TRUE;
+- }
++ /* First rev 82545 and 82546 need to not allow any memory
++ * write location to cross 64k boundary due to errata 23 */
++ if(adapter->hw.mac_type == iegbe_82545 ||
++ adapter->hw.mac_type == iegbe_82546) {
++ return ((begin ^ (end - 1)) >> 0x10) != 0x0 ? FALSE : TRUE;
++ }
+
+- return TRUE;
++ return TRUE;
+ }
+
+ /**
+@@ -1398,102 +1302,98 @@ iegbe_check_64k_bound(struct iegbe_adapt
+ * Return 0 on success, negative on failure
+ **/
+
+-int
+-iegbe_setup_tx_resources(struct iegbe_adapter *adapter,
++static int iegbe_setup_tx_resources(struct iegbe_adapter *adapter,
+ struct iegbe_tx_ring *txdr)
+ {
+- struct pci_dev *pdev = adapter->pdev;
+- int size;
++ struct pci_dev *pdev = adapter->pdev;
++ int size;
+
+- size = sizeof(struct iegbe_buffer) * txdr->count;
+- txdr->buffer_info = vmalloc(size);
+- if (!txdr->buffer_info) {
+- DPRINTK(PROBE, ERR,
+- "Unable to allocate memory for the transmit descriptor ring\n");
+- return -ENOMEM;
+- }
++ size = sizeof(struct iegbe_buffer) * txdr->count;
++ txdr->buffer_info = vmalloc(size);
++ if (!txdr->buffer_info) {
++ DPRINTK(PROBE, ERR,
++ "Unable to allocate memory for the transmit descriptor ring\n");
++ return -ENOMEM;
++ }
+ memset(txdr->buffer_info, 0, size);
+- memset(&txdr->previous_buffer_info, 0, sizeof(struct iegbe_buffer));
+
+- /* round up to nearest 4K */
++ /* round up to nearest 4K */
+
+- txdr->size = txdr->count * sizeof(struct iegbe_tx_desc);
+- E1000_ROUNDUP(txdr->size, 0x1000);
++ txdr->size = txdr->count * sizeof(struct iegbe_tx_desc);
++ txdr->size = ALIGN(txdr->size, 4096);
+
+- txdr->desc = pci_alloc_consistent(pdev, txdr->size, &txdr->dma);
+- if (!txdr->desc) {
++ txdr->desc = pci_alloc_consistent(pdev, txdr->size, &txdr->dma);
++ if (!txdr->desc) {
+ setup_tx_desc_die:
+- vfree(txdr->buffer_info);
+- DPRINTK(PROBE, ERR,
+- "Unable to allocate memory for the transmit descriptor ring\n");
+- return -ENOMEM;
+- }
+-
+- /* Fix for errata 23, can't cross 64kB boundary */
+- if (!iegbe_check_64k_bound(adapter, txdr->desc, txdr->size)) {
+- void *olddesc = txdr->desc;
+- dma_addr_t olddma = txdr->dma;
+- DPRINTK(TX_ERR, ERR, "txdr align check failed: %u bytes "
+- "at %p\n", txdr->size, txdr->desc);
+- /* Try again, without freeing the previous */
+- txdr->desc = pci_alloc_consistent(pdev, txdr->size, &txdr->dma);
+- /* Failed allocation, critical failure */
+- if (!txdr->desc) {
+- pci_free_consistent(pdev, txdr->size, olddesc, olddma);
+- goto setup_tx_desc_die;
+- }
++ vfree(txdr->buffer_info);
++ DPRINTK(PROBE, ERR,
++ "Unable to allocate memory for the transmit descriptor ring\n");
++ return -ENOMEM;
++ }
++
++ /* Fix for errata 23, can't cross 64kB boundary */
++ if (!iegbe_check_64k_bound(adapter, txdr->desc, txdr->size)) {
++ void *olddesc = txdr->desc;
++ dma_addr_t olddma = txdr->dma;
++ DPRINTK(TX_ERR, ERR, "txdr align check failed: %u bytes "
++ "at %p\n", txdr->size, txdr->desc);
++ /* Try again, without freeing the previous */
++ txdr->desc = pci_alloc_consistent(pdev, txdr->size, &txdr->dma);
++ /* Failed allocation, critical failure */
++ if (!txdr->desc) {
++ pci_free_consistent(pdev, txdr->size, olddesc, olddma);
++ goto setup_tx_desc_die;
++ }
+
+- if (!iegbe_check_64k_bound(adapter, txdr->desc, txdr->size)) {
+- /* give up */
+- pci_free_consistent(pdev, txdr->size, txdr->desc,
+- txdr->dma);
+- pci_free_consistent(pdev, txdr->size, olddesc, olddma);
+- DPRINTK(PROBE, ERR,
+- "Unable to allocate aligned memory "
+- "for the transmit descriptor ring\n");
+- vfree(txdr->buffer_info);
+- return -ENOMEM;
+- } else {
+- /* Free old allocation, new allocation was successful */
+- pci_free_consistent(pdev, txdr->size, olddesc, olddma);
+- }
+- }
++ if (!iegbe_check_64k_bound(adapter, txdr->desc, txdr->size)) {
++ /* give up */
++ pci_free_consistent(pdev, txdr->size, txdr->desc,
++ txdr->dma);
++ pci_free_consistent(pdev, txdr->size, olddesc, olddma);
++ DPRINTK(PROBE, ERR,
++ "Unable to allocate aligned memory "
++ "for the transmit descriptor ring\n");
++ vfree(txdr->buffer_info);
++ return -ENOMEM;
++ } else {
++ /* Free old allocation, new allocation was successful */
++ pci_free_consistent(pdev, txdr->size, olddesc, olddma);
++ }
++ }
+ memset(txdr->desc, 0, txdr->size);
+
+ txdr->next_to_use = 0;
+ txdr->next_to_clean = 0;
+- spin_lock_init(&txdr->tx_lock);
++ spin_lock_init(&txdr->tx_lock);
+
+ return 0;
+ }
+
+ /**
+ * iegbe_setup_all_tx_resources - wrapper to allocate Tx resources
+- * (Descriptors) for all queues
++ * (Descriptors) for all queues
+ * @adapter: board private structure
+ *
+- * If this function returns with an error, then it's possible one or
+- * more of the rings is populated (while the rest are not). It is the
+- * callers duty to clean those orphaned rings.
+- *
+ * Return 0 on success, negative on failure
+ **/
+
+-int
+-iegbe_setup_all_tx_resources(struct iegbe_adapter *adapter)
++int iegbe_setup_all_tx_resources(struct iegbe_adapter *adapter)
+ {
+ int i, err = 0;
+
+- for (i = 0; i < adapter->num_queues; i++) {
++ for (i = 0; i < adapter->num_tx_queues; i++) {
+ err = iegbe_setup_tx_resources(adapter, &adapter->tx_ring[i]);
+ if (err) {
+ DPRINTK(PROBE, ERR,
+ "Allocation for Tx Queue %u failed\n", i);
++ for (i-- ; i >= 0; i--)
++ iegbe_free_tx_resources(adapter,
++ &adapter->tx_ring[i]);
+ break;
+ }
+ }
+
+- return err;
++ return err;
+ }
+
+ /**
+@@ -1512,113 +1412,108 @@ iegbe_configure_tx(struct iegbe_adapter
+
+ /* Setup the HW Tx Head and Tail descriptor pointers */
+
+- switch (adapter->num_queues) {
++ switch (adapter->num_tx_queues) {
+ case 0x2:
+ tdba = adapter->tx_ring[0x1].dma;
+ tdlen = adapter->tx_ring[0x1].count *
+- sizeof(struct iegbe_tx_desc);
+- E1000_WRITE_REG(hw, TDBAL1, (tdba & 0x00000000ffffffffULL));
++ sizeof(struct iegbe_tx_desc);
++ E1000_WRITE_REG(hw, TDBAL1, (tdba & 0x00000000ffffffffULL));
+ E1000_WRITE_REG(hw, TDBAH1, (tdba >> 0x20));
+- E1000_WRITE_REG(hw, TDLEN1, tdlen);
+- E1000_WRITE_REG(hw, TDH1, 0);
+- E1000_WRITE_REG(hw, TDT1, 0);
++ E1000_WRITE_REG(hw, TDLEN1, tdlen);
++ E1000_WRITE_REG(hw, TDH1, 0x0);
++ E1000_WRITE_REG(hw, TDT1, 0x0);
+ adapter->tx_ring[0x1].tdh = E1000_TDH1;
+ adapter->tx_ring[0x1].tdt = E1000_TDT1;
+- /* Fall Through */
++ /* Fall Through */
+ case 0x1:
+- default:
+- tdba = adapter->tx_ring[0].dma;
+- tdlen = adapter->tx_ring[0].count *
+- sizeof(struct iegbe_tx_desc);
+- E1000_WRITE_REG(hw, TDBAL, (tdba & 0x00000000ffffffffULL));
++ default:
++ tdba = adapter->tx_ring[0x0].dma;
++ tdlen = adapter->tx_ring[0x0].count *
++ sizeof(struct iegbe_tx_desc);
++ E1000_WRITE_REG(hw, TDBAL, (tdba & 0x00000000ffffffffULL));
+ E1000_WRITE_REG(hw, TDBAH, (tdba >> 0x20));
+- E1000_WRITE_REG(hw, TDLEN, tdlen);
+- E1000_WRITE_REG(hw, TDH, 0);
+- E1000_WRITE_REG(hw, TDT, 0);
+- adapter->tx_ring[0].tdh = E1000_TDH;
+- adapter->tx_ring[0].tdt = E1000_TDT;
+- break;
+- }
+-
+- /* Set the default values for the Tx Inter Packet Gap timer */
+-
+- switch (hw->mac_type) {
+- case iegbe_82542_rev2_0:
+- case iegbe_82542_rev2_1:
+- tipg = DEFAULT_82542_TIPG_IPGT;
+- tipg |= DEFAULT_82542_TIPG_IPGR1 << E1000_TIPG_IPGR1_SHIFT;
+- tipg |= DEFAULT_82542_TIPG_IPGR2 << E1000_TIPG_IPGR2_SHIFT;
+- break;
+- default:
+- switch(hw->media_type) {
+- case iegbe_media_type_fiber:
+- case iegbe_media_type_internal_serdes:
+- tipg = DEFAULT_82543_TIPG_IPGT_FIBER;
+- break;
+- case iegbe_media_type_copper:
+- tipg = DEFAULT_82543_TIPG_IPGT_COPPER;
+- break;
+- case iegbe_media_type_oem:
+- default:
++ E1000_WRITE_REG(hw, TDLEN, tdlen);
++ E1000_WRITE_REG(hw, TDH, 0x0);
++ E1000_WRITE_REG(hw, TDT, 0x0);
++ adapter->tx_ring[0x0].tdh = E1000_TDH;
++ adapter->tx_ring[0x0].tdt = E1000_TDT;
++ break;
++ }
++
++ /* Set the default values for the Tx Inter Packet Gap timer */
++
++ switch (hw->mac_type) {
++ case iegbe_82542_rev2_0:
++ case iegbe_82542_rev2_1:
++ tipg = DEFAULT_82542_TIPG_IPGT;
++ tipg |= DEFAULT_82542_TIPG_IPGR1 << E1000_TIPG_IPGR1_SHIFT;
++ tipg |= DEFAULT_82542_TIPG_IPGR2 << E1000_TIPG_IPGR2_SHIFT;
++ break;
++ default:
++ switch(hw->media_type) {
++ case iegbe_media_type_fiber:
++ case iegbe_media_type_internal_serdes:
++ tipg = DEFAULT_82543_TIPG_IPGT_FIBER;
++ break;
++ case iegbe_media_type_copper:
++ tipg = DEFAULT_82543_TIPG_IPGT_COPPER;
++ break;
++ case iegbe_media_type_oem:
++ default:
+ tipg = (0xFFFFFFFFUL >> (sizeof(tipg)*0x8 -
+ E1000_TIPG_IPGR1_SHIFT))
+- & iegbe_oem_get_tipg(&adapter->hw);
+- break;
+- }
+- tipg |= DEFAULT_82543_TIPG_IPGR1 << E1000_TIPG_IPGR1_SHIFT;
+- tipg |= DEFAULT_82543_TIPG_IPGR2 << E1000_TIPG_IPGR2_SHIFT;
+- }
+- E1000_WRITE_REG(hw, TIPG, tipg);
++ & iegbe_oem_get_tipg(&adapter->hw);
++ break;
++ }
++ tipg |= DEFAULT_82543_TIPG_IPGR1 << E1000_TIPG_IPGR1_SHIFT;
++ tipg |= DEFAULT_82543_TIPG_IPGR2 << E1000_TIPG_IPGR2_SHIFT;
++ }
++ E1000_WRITE_REG(hw, TIPG, tipg);
+
+- /* Set the Tx Interrupt Delay register */
++ /* Set the Tx Interrupt Delay register */
+
+- E1000_WRITE_REG(hw, TIDV, adapter->tx_int_delay);
++ E1000_WRITE_REG(hw, TIDV, adapter->tx_int_delay);
+ if (hw->mac_type >= iegbe_82540) {
+- E1000_WRITE_REG(hw, TADV, adapter->tx_abs_int_delay);
++ E1000_WRITE_REG(hw, TADV, adapter->tx_abs_int_delay);
+ }
+- /* Program the Transmit Control Register */
++ /* Program the Transmit Control Register */
+
+- tctl = E1000_READ_REG(hw, TCTL);
++ tctl = E1000_READ_REG(hw, TCTL);
+
+- tctl &= ~E1000_TCTL_CT;
+- tctl |= E1000_TCTL_EN | E1000_TCTL_PSP | E1000_TCTL_RTLC |
+- (E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT);
++ tctl &= ~E1000_TCTL_CT;
++ tctl |= E1000_TCTL_EN | E1000_TCTL_PSP | E1000_TCTL_RTLC |
++ (E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT);
+
+- E1000_WRITE_REG(hw, TCTL, tctl);
++ E1000_WRITE_REG(hw, TCTL, tctl);
+
+- if (hw->mac_type == iegbe_82571 || hw->mac_type == iegbe_82572) {
+- tarc = E1000_READ_REG(hw, TARC0);
++ if (hw->mac_type == iegbe_82571 || hw->mac_type == iegbe_82572) {
++ tarc = E1000_READ_REG(hw, TARC0);
+ tarc |= ((0x1 << 0x19) | (0x1 << 0x15));
+- E1000_WRITE_REG(hw, TARC0, tarc);
+- tarc = E1000_READ_REG(hw, TARC1);
++ E1000_WRITE_REG(hw, TARC0, tarc);
++ tarc = E1000_READ_REG(hw, TARC1);
+ tarc |= (0x1 << 0x19);
+ if (tctl & E1000_TCTL_MULR) {
+ tarc &= ~(0x1 << 0x1c);
+ } else {
+ tarc |= (0x1 << 0x1c);
+ }
+- E1000_WRITE_REG(hw, TARC1, tarc);
+- }
++ E1000_WRITE_REG(hw, TARC1, tarc);
++ }
+
+- iegbe_config_collision_dist(hw);
++ iegbe_config_collision_dist(hw);
+
+- /* Setup Transmit Descriptor Settings for eop descriptor */
+- adapter->txd_cmd = E1000_TXD_CMD_IDE | E1000_TXD_CMD_EOP |
+- E1000_TXD_CMD_IFCS;
++ /* Setup Transmit Descriptor Settings for eop descriptor */
++ adapter->txd_cmd = E1000_TXD_CMD_IDE | E1000_TXD_CMD_EOP |
++ E1000_TXD_CMD_IFCS;
+
+ if (hw->mac_type < iegbe_82543) {
+- adapter->txd_cmd |= E1000_TXD_CMD_RPS;
++ adapter->txd_cmd |= E1000_TXD_CMD_RPS;
+ } else {
+-#ifdef IEGBE_GBE_WORKAROUND
+- /* Disable the RS bit in the Tx descriptor */
+- adapter->txd_cmd &= ~E1000_TXD_CMD_RS;
+-#else
+- adapter->txd_cmd |= E1000_TXD_CMD_RS;
+-#endif
++ adapter->txd_cmd |= E1000_TXD_CMD_RS;
+ }
+- /* Cache if we're 82544 running in PCI-X because we'll
+- * need this to apply a workaround later in the send path. */
+- if (hw->mac_type == iegbe_82544 &&
++ /* Cache if we're 82544 running in PCI-X because we'll
++ * need this to apply a workaround later in the send path. */
++ if (hw->mac_type == iegbe_82544 &&
+ hw->bus_type == iegbe_bus_type_pcix) {
+ adapter->pcix_82544 = 0x1;
+ }
+@@ -1632,96 +1527,95 @@ iegbe_configure_tx(struct iegbe_adapter
+ * Returns 0 on success, negative on failure
+ **/
+
+-int
+-iegbe_setup_rx_resources(struct iegbe_adapter *adapter,
++static int iegbe_setup_rx_resources(struct iegbe_adapter *adapter,
+ struct iegbe_rx_ring *rxdr)
+ {
+- struct pci_dev *pdev = adapter->pdev;
+- int size, desc_len;
+-
+- size = sizeof(struct iegbe_buffer) * rxdr->count;
+- rxdr->buffer_info = vmalloc(size);
+- if (!rxdr->buffer_info) {
+- DPRINTK(PROBE, ERR,
+- "Unable to allocate memory for the receive descriptor ring\n");
+- return -ENOMEM;
+- }
+- memset(rxdr->buffer_info, 0, size);
+-
+- size = sizeof(struct iegbe_ps_page) * rxdr->count;
+- rxdr->ps_page = kmalloc(size, GFP_KERNEL);
+- if (!rxdr->ps_page) {
+- vfree(rxdr->buffer_info);
+- DPRINTK(PROBE, ERR,
+- "Unable to allocate memory for the receive descriptor ring\n");
+- return -ENOMEM;
+- }
+- memset(rxdr->ps_page, 0, size);
+-
+- size = sizeof(struct iegbe_ps_page_dma) * rxdr->count;
+- rxdr->ps_page_dma = kmalloc(size, GFP_KERNEL);
+- if (!rxdr->ps_page_dma) {
+- vfree(rxdr->buffer_info);
+- kfree(rxdr->ps_page);
+- DPRINTK(PROBE, ERR,
+- "Unable to allocate memory for the receive descriptor ring\n");
+- return -ENOMEM;
+- }
+- memset(rxdr->ps_page_dma, 0, size);
++ struct iegbe_hw *hw = &adapter->hw;
++ struct pci_dev *pdev = adapter->pdev;
++ int size, desc_len;
+
+- if (adapter->hw.mac_type <= iegbe_82547_rev_2) {
+- desc_len = sizeof(struct iegbe_rx_desc);
+- } else {
+- desc_len = sizeof(union iegbe_rx_desc_packet_split);
++ size = sizeof(struct iegbe_buffer) * rxdr->count;
++ rxdr->buffer_info = vmalloc(size);
++ if (!rxdr->buffer_info) {
++ DPRINTK(PROBE, ERR,
++ "Unable to allocate memory for the receive descriptor ring\n");
++ return -ENOMEM;
+ }
+- /* Round up to nearest 4K */
+-
+- rxdr->size = rxdr->count * desc_len;
+- E1000_ROUNDUP(rxdr->size, 0x1000);
+-
+- rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma);
++ memset(rxdr->buffer_info, 0, size);
+
+- if (!rxdr->desc) {
+- DPRINTK(PROBE, ERR,
+- "Unable to allocate memory for the receive descriptor ring\n");
++ rxdr->ps_page = kcalloc(rxdr->count, sizeof(struct iegbe_ps_page),
++ GFP_KERNEL);
++ if (!rxdr->ps_page) {
++ vfree(rxdr->buffer_info);
++ DPRINTK(PROBE, ERR,
++ "Unable to allocate memory for the receive descriptor ring\n");
++ return -ENOMEM;
++ }
++
++ rxdr->ps_page_dma = kcalloc(rxdr->count,
++ sizeof(struct iegbe_ps_page_dma),
++ GFP_KERNEL);
++ if (!rxdr->ps_page_dma) {
++ vfree(rxdr->buffer_info);
++ kfree(rxdr->ps_page);
++ DPRINTK(PROBE, ERR,
++ "Unable to allocate memory for the receive descriptor ring\n");
++ return -ENOMEM;
++ }
++
++ if (hw->mac_type <= iegbe_82547_rev_2)
++ desc_len = sizeof(struct iegbe_rx_desc);
++ else
++ desc_len = sizeof(union iegbe_rx_desc_packet_split);
++
++ /* Round up to nearest 4K */
++
++ rxdr->size = rxdr->count * desc_len;
++ rxdr->size = ALIGN(rxdr->size, 4096);
++
++ rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma);
++
++ if (!rxdr->desc) {
++ DPRINTK(PROBE, ERR,
++ "Unable to allocate memory for the receive descriptor ring\n");
+ setup_rx_desc_die:
+- vfree(rxdr->buffer_info);
+- kfree(rxdr->ps_page);
+- kfree(rxdr->ps_page_dma);
+- return -ENOMEM;
+- }
+-
+- /* Fix for errata 23, can't cross 64kB boundary */
+- if (!iegbe_check_64k_bound(adapter, rxdr->desc, rxdr->size)) {
+- void *olddesc = rxdr->desc;
+- dma_addr_t olddma = rxdr->dma;
+- DPRINTK(RX_ERR, ERR, "rxdr align check failed: %u bytes "
+- "at %p\n", rxdr->size, rxdr->desc);
+- /* Try again, without freeing the previous */
+- rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma);
+- /* Failed allocation, critical failure */
+- if (!rxdr->desc) {
+- pci_free_consistent(pdev, rxdr->size, olddesc, olddma);
+- DPRINTK(PROBE, ERR,
+- "Unable to allocate memory "
+- "for the receive descriptor ring\n");
+- goto setup_rx_desc_die;
+- }
++ vfree(rxdr->buffer_info);
++ kfree(rxdr->ps_page);
++ kfree(rxdr->ps_page_dma);
++ return -ENOMEM;
++ }
++
++ /* Fix for errata 23, can't cross 64kB boundary */
++ if (!iegbe_check_64k_bound(adapter, rxdr->desc, rxdr->size)) {
++ void *olddesc = rxdr->desc;
++ dma_addr_t olddma = rxdr->dma;
++ DPRINTK(RX_ERR, ERR, "rxdr align check failed: %u bytes "
++ "at %p\n", rxdr->size, rxdr->desc);
++ /* Try again, without freeing the previous */
++ rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma);
++ /* Failed allocation, critical failure */
++ if (!rxdr->desc) {
++ pci_free_consistent(pdev, rxdr->size, olddesc, olddma);
++ DPRINTK(PROBE, ERR,
++ "Unable to allocate memory "
++ "for the receive descriptor ring\n");
++ goto setup_rx_desc_die;
++ }
+
+- if (!iegbe_check_64k_bound(adapter, rxdr->desc, rxdr->size)) {
+- /* give up */
+- pci_free_consistent(pdev, rxdr->size, rxdr->desc,
+- rxdr->dma);
+- pci_free_consistent(pdev, rxdr->size, olddesc, olddma);
+- DPRINTK(PROBE, ERR,
+- "Unable to allocate aligned memory "
+- "for the receive descriptor ring\n");
+- goto setup_rx_desc_die;
+- } else {
+- /* Free old allocation, new allocation was successful */
+- pci_free_consistent(pdev, rxdr->size, olddesc, olddma);
+- }
+- }
++ if (!iegbe_check_64k_bound(adapter, rxdr->desc, rxdr->size)) {
++ /* give up */
++ pci_free_consistent(pdev, rxdr->size, rxdr->desc,
++ rxdr->dma);
++ pci_free_consistent(pdev, rxdr->size, olddesc, olddma);
++ DPRINTK(PROBE, ERR,
++ "Unable to allocate aligned memory "
++ "for the receive descriptor ring\n");
++ goto setup_rx_desc_die;
++ } else {
++ /* Free old allocation, new allocation was successful */
++ pci_free_consistent(pdev, rxdr->size, olddesc, olddma);
++ }
++ }
+ memset(rxdr->desc, 0, rxdr->size);
+
+ rxdr->next_to_clean = 0;
+@@ -1732,7 +1626,7 @@ setup_rx_desc_die:
+
+ /**
+ * iegbe_setup_all_rx_resources - wrapper to allocate Rx resources
+- * (Descriptors) for all queues
++ * (Descriptors) for all queues
+ * @adapter: board private structure
+ *
+ * If this function returns with an error, then it's possible one or
+@@ -1742,21 +1636,23 @@ setup_rx_desc_die:
+ * Return 0 on success, negative on failure
+ **/
+
+-int
+-iegbe_setup_all_rx_resources(struct iegbe_adapter *adapter)
++int iegbe_setup_all_rx_resources(struct iegbe_adapter *adapter)
+ {
+ int i, err = 0;
+
+- for (i = 0; i < adapter->num_queues; i++) {
++ for (i = 0; i < adapter->num_rx_queues; i++) {
+ err = iegbe_setup_rx_resources(adapter, &adapter->rx_ring[i]);
+ if (err) {
+ DPRINTK(PROBE, ERR,
+ "Allocation for Rx Queue %u failed\n", i);
++ for (i-- ; i >= 0; i--)
++ iegbe_free_rx_resources(adapter,
++ &adapter->rx_ring[i]);
+ break;
+ }
+ }
+
+- return err;
++ return err;
+ }
+
+ /**
+@@ -1765,105 +1661,104 @@ iegbe_setup_all_rx_resources(struct iegb
+ **/
+ #define PAGE_USE_COUNT(S) (((S) >> PAGE_SHIFT) + \
+ (((S) & (PAGE_SIZE - 1)) ? 1 : 0))
+-static void
+-iegbe_setup_rctl(struct iegbe_adapter *adapter)
++static void iegbe_setup_rctl(struct iegbe_adapter *adapter)
+ {
+- uint32_t rctl, rfctl;
+- uint32_t psrctl = 0;
+-#ifdef CONFIG_E1000_PACKET_SPLIT
+- uint32_t pages = 0;
+-#endif
+-
+- rctl = E1000_READ_REG(&adapter->hw, RCTL);
+-
+- rctl &= ~(0x3 << E1000_RCTL_MO_SHIFT);
+-
+- rctl |= E1000_RCTL_EN | E1000_RCTL_BAM |
+- E1000_RCTL_LBM_NO | E1000_RCTL_RDMTS_HALF |
+- (adapter->hw.mc_filter_type << E1000_RCTL_MO_SHIFT);
+-
+- if(adapter->hw.tbi_compatibility_on == 0x1) {
+- rctl |= E1000_RCTL_SBP;
+- } else {
+- rctl &= ~E1000_RCTL_SBP;
+- }
+- if(adapter->netdev->mtu <= ETH_DATA_LEN) {
+- rctl &= ~E1000_RCTL_LPE;
+- } else {
+- rctl |= E1000_RCTL_LPE;
+- }
+- /* Setup buffer sizes */
+- if(adapter->hw.mac_type >= iegbe_82571) {
+- /* We can now specify buffers in 1K increments.
+- * BSIZE and BSEX are ignored in this case. */
+- rctl |= adapter->rx_buffer_len << 0x11;
+- } else {
+- rctl &= ~E1000_RCTL_SZ_4096;
+- rctl |= E1000_RCTL_BSEX;
+- switch (adapter->rx_buffer_len) {
+- case E1000_RXBUFFER_2048:
+- default:
+- rctl |= E1000_RCTL_SZ_2048;
++ struct iegbe_hw *hw = &adapter->hw;
++ u32 rctl, rfctl;
++ u32 psrctl = 0;
++#ifndef CONFIG_E1000_DISABLE_PACKET_SPLIT
++ u32 pages = 0;
++#endif
++
++ rctl = E1000_READ_REG(&adapter->hw, RCTL);
++
++ rctl &= ~(3 << E1000_RCTL_MO_SHIFT);
++
++ rctl |= E1000_RCTL_EN | E1000_RCTL_BAM |
++ E1000_RCTL_LBM_NO | E1000_RCTL_RDMTS_HALF |
++ (hw->mc_filter_type << E1000_RCTL_MO_SHIFT);
++
++ if (hw->tbi_compatibility_on == 1)
++ rctl |= E1000_RCTL_SBP;
++ else
++ rctl &= ~E1000_RCTL_SBP;
++
++ if (adapter->netdev->mtu <= ETH_DATA_LEN)
++ rctl &= ~E1000_RCTL_LPE;
++ else
++ rctl |= E1000_RCTL_LPE;
++
++ /* Setup buffer sizes */
++ /* We can now specify buffers in 1K increments.
++ * BSIZE and BSEX are ignored in this case. */
++ rctl &= ~E1000_RCTL_SZ_4096;
++ rctl |= E1000_RCTL_BSEX;
++ switch (adapter->rx_buffer_len) {
++ case E1000_RXBUFFER_256:
++ rctl |= E1000_RCTL_SZ_256;
+ rctl &= ~E1000_RCTL_BSEX;
+ break;
+- case E1000_RXBUFFER_4096:
+- rctl |= E1000_RCTL_SZ_4096;
+- break;
+- case E1000_RXBUFFER_8192:
+- rctl |= E1000_RCTL_SZ_8192;
+- break;
+- case E1000_RXBUFFER_16384:
+- rctl |= E1000_RCTL_SZ_16384;
+- break;
+- }
+- }
++ case E1000_RXBUFFER_2048:
++ default:
++ rctl |= E1000_RCTL_SZ_2048;
++ rctl &= ~E1000_RCTL_BSEX;
++ break;
++ case E1000_RXBUFFER_4096:
++ rctl |= E1000_RCTL_SZ_4096;
++ break;
++ case E1000_RXBUFFER_8192:
++ rctl |= E1000_RCTL_SZ_8192;
++ break;
++ case E1000_RXBUFFER_16384:
++ rctl |= E1000_RCTL_SZ_16384;
++ break;
++ }
+
+-#ifdef CONFIG_E1000_PACKET_SPLIT
+- /* 82571 and greater support packet-split where the protocol
+- * header is placed in skb->data and the packet data is
+- * placed in pages hanging off of skb_shinfo(skb)->nr_frags.
+- * In the case of a non-split, skb->data is linearly filled,
+- * followed by the page buffers. Therefore, skb->data is
+- * sized to hold the largest protocol header.
+- */
+- pages = PAGE_USE_COUNT(adapter->netdev->mtu);
+- if ((adapter->hw.mac_type > iegbe_82547_rev_2) && (pages <= 0x3) &&
+- PAGE_SIZE <= 0x4000) {
+- adapter->rx_ps_pages = pages;
+- } else {
++#ifndef CONFIG_E1000_DISABLE_PACKET_SPLIT
++ /* 82571 and greater support packet-split where the protocol
++ * header is placed in skb->data and the packet data is
++ * placed in pages hanging off of skb_shinfo(skb)->nr_frags.
++ * In the case of a non-split, skb->data is linearly filled,
++ * followed by the page buffers. Therefore, skb->data is
++ * sized to hold the largest protocol header.
++ */
++ pages = PAGE_USE_COUNT(adapter->netdev->mtu);
++ if ((hw->mac_type >= iegbe_82571) && (pages <= 3) &&
++ PAGE_SIZE <= 16384 && (rctl & E1000_RCTL_LPE))
++ adapter->rx_ps_pages = pages;
++ else
+ adapter->rx_ps_pages = 0;
+- }
+ #endif
+- if (adapter->rx_ps_pages) {
+- /* Configure extra packet-split registers */
+- rfctl = E1000_READ_REG(&adapter->hw, RFCTL);
+- rfctl |= E1000_RFCTL_EXTEN;
+- /* disable IPv6 packet split support */
+- rfctl |= E1000_RFCTL_IPV6_DIS;
+- E1000_WRITE_REG(&adapter->hw, RFCTL, rfctl);
+-
+- rctl |= E1000_RCTL_DTYP_PS | E1000_RCTL_SECRC;
+-
+- psrctl |= adapter->rx_ps_bsize0 >>
+- E1000_PSRCTL_BSIZE0_SHIFT;
+-
+- switch (adapter->rx_ps_pages) {
+- case 0x3:
+- psrctl |= PAGE_SIZE <<
+- E1000_PSRCTL_BSIZE3_SHIFT;
+- case 0x2:
+- psrctl |= PAGE_SIZE <<
+- E1000_PSRCTL_BSIZE2_SHIFT;
+- case 0x1:
+- psrctl |= PAGE_SIZE >>
+- E1000_PSRCTL_BSIZE1_SHIFT;
+- break;
+- }
++ if (adapter->rx_ps_pages) {
++ /* Configure extra packet-split registers */
++ rfctl = E1000_READ_REG(&adapter->hw, RFCTL);
++ rfctl |= E1000_RFCTL_EXTEN;
++ /* disable IPv6 packet split support */
++ rfctl |= (E1000_RFCTL_IPV6_EX_DIS |
++ E1000_RFCTL_NEW_IPV6_EXT_DIS);
++
++ rctl |= E1000_RCTL_DTYP_PS;
++
++ psrctl |= adapter->rx_ps_bsize0 >>
++ E1000_PSRCTL_BSIZE0_SHIFT;
++
++ switch (adapter->rx_ps_pages) {
++ case 3:
++ psrctl |= PAGE_SIZE <<
++ E1000_PSRCTL_BSIZE3_SHIFT;
++ case 2:
++ psrctl |= PAGE_SIZE <<
++ E1000_PSRCTL_BSIZE2_SHIFT;
++ case 1:
++ psrctl |= PAGE_SIZE >>
++ E1000_PSRCTL_BSIZE1_SHIFT;
++ break;
++ }
+
+- E1000_WRITE_REG(&adapter->hw, PSRCTL, psrctl);
+- }
++ E1000_WRITE_REG(&adapter->hw, PSRCTL, psrctl);
++ }
+
+- E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
++ E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
+ }
+
+ /**
+@@ -1873,145 +1768,87 @@ iegbe_setup_rctl(struct iegbe_adapter *a
+ * Configure the Rx unit of the MAC after a reset.
+ **/
+
+-static void
+-iegbe_configure_rx(struct iegbe_adapter *adapter)
++static void iegbe_configure_rx(struct iegbe_adapter *adapter)
+ {
+- uint64_t rdba;
+- struct iegbe_hw *hw = &adapter->hw;
+- uint32_t rdlen, rctl, rxcsum, ctrl_ext;
+-#ifdef CONFIG_E1000_MQ
+- uint32_t reta, mrqc;
+- int i;
+-#endif
++ u64 rdba;
++ struct iegbe_hw *hw = &adapter->hw;
++ u32 rdlen, rctl, rxcsum, ctrl_ext;
+
+- if (adapter->rx_ps_pages) {
++ if (adapter->rx_ps_pages) {
+ rdlen = adapter->rx_ring[0].count *
+- sizeof(union iegbe_rx_desc_packet_split);
+- adapter->clean_rx = iegbe_clean_rx_irq_ps;
+- adapter->alloc_rx_buf = iegbe_alloc_rx_buffers_ps;
+- } else {
++ sizeof(union iegbe_rx_desc_packet_split);
++ adapter->clean_rx = iegbe_clean_rx_irq_ps;
++ adapter->alloc_rx_buf = iegbe_alloc_rx_buffers_ps;
++ } else {
+ rdlen = adapter->rx_ring[0].count *
+- sizeof(struct iegbe_rx_desc);
+- adapter->clean_rx = iegbe_clean_rx_irq;
+- adapter->alloc_rx_buf = iegbe_alloc_rx_buffers;
+- }
++ sizeof(struct iegbe_rx_desc);
++ adapter->clean_rx = iegbe_clean_rx_irq;
++ adapter->alloc_rx_buf = iegbe_alloc_rx_buffers;
++ }
+
+- /* disable receives while setting up the descriptors */
+- rctl = E1000_READ_REG(hw, RCTL);
+- E1000_WRITE_REG(hw, RCTL, rctl & ~E1000_RCTL_EN);
++ /* disable receives while setting up the descriptors */
++ rctl = E1000_READ_REG(hw, RCTL);
++ E1000_WRITE_REG(hw, RCTL, rctl & ~E1000_RCTL_EN);
+
+- /* set the Receive Delay Timer Register */
+- E1000_WRITE_REG(hw, RDTR, adapter->rx_int_delay);
++ /* set the Receive Delay Timer Register */
++ E1000_WRITE_REG(hw, RDTR, adapter->rx_int_delay);
+
+- if (hw->mac_type >= iegbe_82540) {
+- E1000_WRITE_REG(hw, RADV, adapter->rx_abs_int_delay);
+- if(adapter->itr > 0x1) {
+- E1000_WRITE_REG(hw, ITR,
+- 0x3b9aca00 / (adapter->itr * 0x100));
++ if (hw->mac_type >= iegbe_82540) {
++ E1000_WRITE_REG(hw, RADV, adapter->rx_abs_int_delay);
++ if (adapter->itr_setting != 0)
++ E1000_WRITE_REG(&adapter->hw, ITR, 1000000000 / (adapter->itr * 256));
+ }
+- }
+
+- if (hw->mac_type >= iegbe_82571) {
+- /* Reset delay timers after every interrupt */
+- ctrl_ext = E1000_READ_REG(hw, CTRL_EXT);
+- ctrl_ext |= E1000_CTRL_EXT_CANC;
+- E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext);
+- E1000_WRITE_FLUSH(hw);
+- }
++ if (hw->mac_type >= iegbe_82571) {
++ /* Reset delay timers after every interrupt */
++ ctrl_ext = E1000_READ_REG(hw, CTRL_EXT);
++ ctrl_ext |= E1000_CTRL_EXT_CANC;
++ E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext);
++ E1000_WRITE_FLUSH(hw);
++ }
+
+ /* Setup the HW Rx Head and Tail Descriptor Pointers and
+ * the Base and Length of the Rx Descriptor Ring */
+- switch (adapter->num_queues) {
+-#ifdef CONFIG_E1000_MQ
+- case 0x2:
+- rdba = adapter->rx_ring[0x1].dma;
+- E1000_WRITE_REG(hw, RDBAL1, (rdba & 0x00000000ffffffffULL));
+- E1000_WRITE_REG(hw, RDBAH1, (rdba >> 0x20));
+- E1000_WRITE_REG(hw, RDLEN1, rdlen);
+- E1000_WRITE_REG(hw, RDH1, 0);
+- E1000_WRITE_REG(hw, RDT1, 0);
+- adapter->rx_ring[1].rdh = E1000_RDH1;
+- adapter->rx_ring[1].rdt = E1000_RDT1;
+- /* Fall Through */
+-#endif
+- case 0x1:
+- default:
++ switch (adapter->num_rx_queues) {
++ case 1:
++ default:
+ rdba = adapter->rx_ring[0].dma;
+- E1000_WRITE_REG(hw, RDBAL, (rdba & 0x00000000ffffffffULL));
++ E1000_WRITE_REG(hw, RDBAL, (rdba & 0x00000000ffffffffULL));
+ E1000_WRITE_REG(hw, RDBAH, (rdba >> 0x20));
+- E1000_WRITE_REG(hw, RDLEN, rdlen);
+- E1000_WRITE_REG(hw, RDH, 0);
+- E1000_WRITE_REG(hw, RDT, 0);
+- adapter->rx_ring[0].rdh = E1000_RDH;
+- adapter->rx_ring[0].rdt = E1000_RDT;
+- break;
+- }
++ E1000_WRITE_REG(hw, RDLEN, rdlen);
++ adapter->rx_ring[0].rdh = ((hw->mac_type >= iegbe_82543) ? E1000_RDH : E1000_82542_RDH);
++ adapter->rx_ring[0].rdt = ((hw->mac_type >= iegbe_82543) ? E1000_RDT : E1000_82542_RDT);
++ break;
++ }
+
+-#ifdef CONFIG_E1000_MQ
+- if (adapter->num_queues > 0x1) {
+- uint32_t random[0xa];
+-
+- get_random_bytes(&random[0], FORTY);
+-
+- if (hw->mac_type <= iegbe_82572) {
+- E1000_WRITE_REG(hw, RSSIR, 0);
+- E1000_WRITE_REG(hw, RSSIM, 0);
+- }
+
+- switch (adapter->num_queues) {
+- case 0x2:
+- default:
+- reta = 0x00800080;
+- mrqc = E1000_MRQC_ENABLE_RSS_2Q;
+- break;
+- }
+-
+- /* Fill out redirection table */
+- for (i = 0; i < 0x20; i++)
+- E1000_WRITE_REG_ARRAY(hw, RETA, i, reta);
+- /* Fill out hash function seeds */
+- for (i = 0; i < 0xa; i++)
+- E1000_WRITE_REG_ARRAY(hw, RSSRK, i, random[i]);
+-
+- mrqc |= (E1000_MRQC_RSS_FIELD_IPV4 |
+- E1000_MRQC_RSS_FIELD_IPV4_TCP);
+- E1000_WRITE_REG(hw, MRQC, mrqc);
+- }
+-
+- /* Multiqueue and packet checksumming are mutually exclusive. */
+- if (hw->mac_type >= iegbe_82571) {
+- rxcsum = E1000_READ_REG(hw, RXCSUM);
+- rxcsum |= E1000_RXCSUM_PCSD;
+- E1000_WRITE_REG(hw, RXCSUM, rxcsum);
+- }
+-
+-#else
++ /* Enable 82543 Receive Checksum Offload for TCP and UDP */
++ if (hw->mac_type >= iegbe_82543) {
++ rxcsum = E1000_READ_REG(hw, RXCSUM);
++ if(adapter->rx_csum == TRUE) {
++ rxcsum |= E1000_RXCSUM_TUOFL;
++
++ /* Enable 82571 IPv4 payload checksum for UDP fragments
++ * Must be used in conjunction with packet-split. */
++ if ((hw->mac_type >= iegbe_82571) &&
++ (adapter->rx_ps_pages)) {
++ rxcsum |= E1000_RXCSUM_IPPCSE;
++ }
++ } else {
++ rxcsum &= ~E1000_RXCSUM_TUOFL;
++ /* don't need to clear IPPCSE as it defaults to 0 */
++ }
++ E1000_WRITE_REG(hw, RXCSUM, rxcsum);
++ }
+
+- /* Enable 82543 Receive Checksum Offload for TCP and UDP */
+- if (hw->mac_type >= iegbe_82543) {
+- rxcsum = E1000_READ_REG(hw, RXCSUM);
+- if(adapter->rx_csum == TRUE) {
+- rxcsum |= E1000_RXCSUM_TUOFL;
+-
+- /* Enable 82571 IPv4 payload checksum for UDP fragments
+- * Must be used in conjunction with packet-split. */
+- if ((hw->mac_type >= iegbe_82571) &&
+- (adapter->rx_ps_pages)) {
+- rxcsum |= E1000_RXCSUM_IPPCSE;
+- }
+- } else {
+- rxcsum &= ~E1000_RXCSUM_TUOFL;
+- /* don't need to clear IPPCSE as it defaults to 0 */
+- }
+- E1000_WRITE_REG(hw, RXCSUM, rxcsum);
+- }
+-#endif /* CONFIG_E1000_MQ */
++ /* enable early receives on 82573, only takes effect if using > 2048
++ * byte total frame size. for example only for jumbo frames */
++#define E1000_ERT_2048 0x100
++ if (hw->mac_type == iegbe_82573)
++ E1000_WRITE_REG(&adapter->hw, ERT, E1000_ERT_2048);
+
+- if (hw->mac_type == iegbe_82573) {
+- E1000_WRITE_REG(hw, ERT, 0x0100);
+- }
+ /* Enable Receives */
+- E1000_WRITE_REG(hw, RCTL, rctl);
++ E1000_WRITE_REG(hw, RCTL, rctl);
+ }
+
+ /**
+@@ -2022,20 +1859,19 @@ iegbe_configure_rx(struct iegbe_adapter
+ * Free all transmit software resources
+ **/
+
+-void
+-iegbe_free_tx_resources(struct iegbe_adapter *adapter,
++static void iegbe_free_tx_resources(struct iegbe_adapter *adapter,
+ struct iegbe_tx_ring *tx_ring)
+ {
+- struct pci_dev *pdev = adapter->pdev;
++ struct pci_dev *pdev = adapter->pdev;
+
+- iegbe_clean_tx_ring(adapter, tx_ring);
++ iegbe_clean_tx_ring(adapter, tx_ring);
+
+- vfree(tx_ring->buffer_info);
+- tx_ring->buffer_info = NULL;
++ vfree(tx_ring->buffer_info);
++ tx_ring->buffer_info = NULL;
+
+- pci_free_consistent(pdev, tx_ring->size, tx_ring->desc, tx_ring->dma);
++ pci_free_consistent(pdev, tx_ring->size, tx_ring->desc, tx_ring->dma);
+
+- tx_ring->desc = NULL;
++ tx_ring->desc = NULL;
+ }
+
+ /**
+@@ -2048,85 +1884,29 @@ iegbe_free_tx_resources(struct iegbe_ada
+ void
+ iegbe_free_all_tx_resources(struct iegbe_adapter *adapter)
+ {
+- int i;
++ int i;
+
+- for (i = 0; i < adapter->num_queues; i++)
++ for (i = 0x0; i < adapter->num_tx_queues; i++)
+ iegbe_free_tx_resources(adapter, &adapter->tx_ring[i]);
+ }
+
+ static inline void
+ iegbe_unmap_and_free_tx_resource(struct iegbe_adapter *adapter,
+- struct iegbe_buffer *buffer_info)
+-{
+- if(buffer_info->dma) {
+- pci_unmap_page(adapter->pdev,
+- buffer_info->dma,
+- buffer_info->length,
+- PCI_DMA_TODEVICE);
+- buffer_info->dma = 0;
+- }
+- if(buffer_info->skb) {
+- dev_kfree_skb_any(buffer_info->skb);
+- buffer_info->skb = NULL;
+- }
+-}
+-
+-#ifdef IEGBE_GBE_WORKAROUND
+-/**
+- * iegbe_clean_tx_ring_partial - Free Tx Buffers without using the DD
+- * bit in the descriptor
+- * @adapter: board private structure
+- * @tx_ring: ring to be cleaned
+- **/
+-static void iegbe_clean_tx_ring_partial(struct iegbe_adapter *adapter,
+- struct iegbe_tx_ring *tx_ring)
++ struct iegbe_buffer *buffer_info)
+ {
+- struct iegbe_buffer *buffer_info;
+- struct iegbe_tx_desc *tx_desc;
+- struct net_device *netdev = adapter->netdev;
+- unsigned int i;
+- unsigned tail;
+- unsigned head;
+- int cleaned = FALSE;
+-
+- tail = readl(adapter->hw.hw_addr + tx_ring->tdt);
+- head = readl(adapter->hw.hw_addr + tx_ring->tdh);
+-
+- if (head != tail) {
+- adapter->stats.tx_hnet++;
+- }
+- if (head != tx_ring->next_to_use) {
+- adapter->stats.tx_hnentu++;
+- }
+- /* Free all the Tx ring sk_buffs from next_to_clean up until
+- * the current head pointer
+- */
+- i = tx_ring->next_to_clean;
+- while(i != head) {
+- cleaned = TRUE;
+- tx_desc = E1000_TX_DESC(*tx_ring, i);
+-
+- buffer_info = &tx_ring->buffer_info[i];
+- iegbe_unmap_and_free_tx_resource(adapter, buffer_info);
+-
+- tx_desc->upper.data = 0;
+-
+- if (unlikely(++i == tx_ring->count)) { i = 0; }
+-
+- }
+- tx_ring->next_to_clean = head;
+-
+- spin_lock(&tx_ring->tx_lock);
+-
+- /* Wake up the queue if it's currently stopped */
+- if (unlikely(cleaned && netif_queue_stopped(netdev) &&
+- netif_carrier_ok(netdev))) {
+- netif_wake_queue(netdev);
++ if(buffer_info->dma) {
++ pci_unmap_page(adapter->pdev,
++ buffer_info->dma,
++ buffer_info->length,
++ PCI_DMA_TODEVICE);
++ buffer_info->dma = 0x0;
++ }
++ if(buffer_info->skb) {
++ dev_kfree_skb_any(buffer_info->skb);
++ buffer_info->skb = NULL;
+ }
+-
+- spin_unlock(&tx_ring->tx_lock);
+ }
+-#endif
++
+
+ /**
+ * iegbe_clean_tx_ring - Free Tx Buffers
+@@ -2134,38 +1914,34 @@ static void iegbe_clean_tx_ring_partial(
+ * @tx_ring: ring to be cleaned
+ **/
+
+-static void
+-iegbe_clean_tx_ring(struct iegbe_adapter *adapter,
++static void iegbe_clean_tx_ring(struct iegbe_adapter *adapter,
+ struct iegbe_tx_ring *tx_ring)
+ {
+- struct iegbe_buffer *buffer_info;
+- unsigned long size;
+- unsigned int i;
+-
+- /* Free all the Tx ring sk_buffs */
++ struct iegbe_hw *hw = &adapter->hw;
++ struct iegbe_buffer *buffer_info;
++ unsigned long size;
++ unsigned int i;
+
+- if (likely(tx_ring->previous_buffer_info.skb != NULL)) {
+- iegbe_unmap_and_free_tx_resource(adapter,
+- &tx_ring->previous_buffer_info);
+- }
++ /* Free all the Tx ring sk_buffs */
+
+ for (i = 0; i < tx_ring->count; i++) {
+- buffer_info = &tx_ring->buffer_info[i];
+- iegbe_unmap_and_free_tx_resource(adapter, buffer_info);
+- }
++ buffer_info = &tx_ring->buffer_info[i];
++ iegbe_unmap_and_free_tx_resource(adapter, buffer_info);
++ }
+
+- size = sizeof(struct iegbe_buffer) * tx_ring->count;
++ size = sizeof(struct iegbe_buffer) * tx_ring->count;
+ memset(tx_ring->buffer_info, 0, size);
+
+- /* Zero out the descriptor ring */
++ /* Zero out the descriptor ring */
+
+ memset(tx_ring->desc, 0, tx_ring->size);
+
+ tx_ring->next_to_use = 0;
+ tx_ring->next_to_clean = 0;
++ tx_ring->last_tx_tso = 0;
+
+- writel(0, adapter->hw.hw_addr + tx_ring->tdh);
+- writel(0, adapter->hw.hw_addr + tx_ring->tdt);
++ writel(0, hw->hw_addr + tx_ring->tdh);
++ writel(0, hw->hw_addr + tx_ring->tdt);
+ }
+
+ /**
+@@ -2173,12 +1949,11 @@ iegbe_clean_tx_ring(struct iegbe_adapter
+ * @adapter: board private structure
+ **/
+
+-static void
+-iegbe_clean_all_tx_rings(struct iegbe_adapter *adapter)
++static void iegbe_clean_all_tx_rings(struct iegbe_adapter *adapter)
+ {
+- int i;
++ int i;
+
+- for (i = 0; i < adapter->num_queues; i++)
++ for (i = 0; i < adapter->num_tx_queues; i++)
+ iegbe_clean_tx_ring(adapter, &adapter->tx_ring[i]);
+ }
+
+@@ -2190,24 +1965,23 @@ iegbe_clean_all_tx_rings(struct iegbe_ad
+ * Free all receive software resources
+ **/
+
+-void
+-iegbe_free_rx_resources(struct iegbe_adapter *adapter,
++static void iegbe_free_rx_resources(struct iegbe_adapter *adapter,
+ struct iegbe_rx_ring *rx_ring)
+ {
+- struct pci_dev *pdev = adapter->pdev;
++ struct pci_dev *pdev = adapter->pdev;
+
+- iegbe_clean_rx_ring(adapter, rx_ring);
++ iegbe_clean_rx_ring(adapter, rx_ring);
+
+- vfree(rx_ring->buffer_info);
+- rx_ring->buffer_info = NULL;
+- kfree(rx_ring->ps_page);
+- rx_ring->ps_page = NULL;
+- kfree(rx_ring->ps_page_dma);
+- rx_ring->ps_page_dma = NULL;
++ vfree(rx_ring->buffer_info);
++ rx_ring->buffer_info = NULL;
++ kfree(rx_ring->ps_page);
++ rx_ring->ps_page = NULL;
++ kfree(rx_ring->ps_page_dma);
++ rx_ring->ps_page_dma = NULL;
+
+- pci_free_consistent(pdev, rx_ring->size, rx_ring->desc, rx_ring->dma);
++ pci_free_consistent(pdev, rx_ring->size, rx_ring->desc, rx_ring->dma);
+
+- rx_ring->desc = NULL;
++ rx_ring->desc = NULL;
+ }
+
+ /**
+@@ -2217,12 +1991,11 @@ iegbe_free_rx_resources(struct iegbe_ada
+ * Free all receive software resources
+ **/
+
+-void
+-iegbe_free_all_rx_resources(struct iegbe_adapter *adapter)
++void iegbe_free_all_rx_resources(struct iegbe_adapter *adapter)
+ {
+- int i;
++ int i;
+
+- for (i = 0; i < adapter->num_queues; i++)
++ for (i = 0; i < adapter->num_rx_queues; i++)
+ iegbe_free_rx_resources(adapter, &adapter->rx_ring[i]);
+ }
+
+@@ -2232,60 +2005,59 @@ iegbe_free_all_rx_resources(struct iegbe
+ * @rx_ring: ring to free buffers from
+ **/
+
+-static void
+-iegbe_clean_rx_ring(struct iegbe_adapter *adapter,
++static void iegbe_clean_rx_ring(struct iegbe_adapter *adapter,
+ struct iegbe_rx_ring *rx_ring)
+ {
+- struct iegbe_buffer *buffer_info;
+- struct iegbe_ps_page *ps_page;
+- struct iegbe_ps_page_dma *ps_page_dma;
+- struct pci_dev *pdev = adapter->pdev;
+- unsigned long size;
+- unsigned int i, j;
+-
+- /* Free all the Rx ring sk_buffs */
++ struct iegbe_hw *hw = &adapter->hw;
++ struct iegbe_buffer *buffer_info;
++ struct iegbe_ps_page *ps_page;
++ struct iegbe_ps_page_dma *ps_page_dma;
++ struct pci_dev *pdev = adapter->pdev;
++ unsigned long size;
++ unsigned int i, j;
++
++ /* Free all the Rx ring sk_buffs */
++
++ for (i = 0; i < rx_ring->count; i++) {
++ buffer_info = &rx_ring->buffer_info[i];
++ if(buffer_info->skb) {
++ pci_unmap_single(pdev,
++ buffer_info->dma,
++ buffer_info->length,
++ PCI_DMA_FROMDEVICE);
+
+- for(i = 0; i < rx_ring->count; i++) {
+- buffer_info = &rx_ring->buffer_info[i];
+- if(buffer_info->skb) {
+- ps_page = &rx_ring->ps_page[i];
+- ps_page_dma = &rx_ring->ps_page_dma[i];
+- pci_unmap_single(pdev,
+- buffer_info->dma,
+- buffer_info->length,
+- PCI_DMA_FROMDEVICE);
+-
+- dev_kfree_skb(buffer_info->skb);
+- buffer_info->skb = NULL;
+-
+- for(j = 0; j < adapter->rx_ps_pages; j++) {
+- if(!ps_page->ps_page[j]) { break; }
+- pci_unmap_single(pdev,
+- ps_page_dma->ps_page_dma[j],
+- PAGE_SIZE, PCI_DMA_FROMDEVICE);
+- ps_page_dma->ps_page_dma[j] = 0;
+- put_page(ps_page->ps_page[j]);
+- ps_page->ps_page[j] = NULL;
+- }
++ dev_kfree_skb(buffer_info->skb);
++ buffer_info->skb = NULL;
+ }
+- }
++ ps_page = &rx_ring->ps_page[i];
++ ps_page_dma = &rx_ring->ps_page_dma[i];
++ for (j = 0; j < adapter->rx_ps_pages; j++) {
++ if (!ps_page->ps_page[j]) break;
++ pci_unmap_page(pdev,
++ ps_page_dma->ps_page_dma[j],
++ PAGE_SIZE, PCI_DMA_FROMDEVICE);
++ ps_page_dma->ps_page_dma[j] = 0;
++ put_page(ps_page->ps_page[j]);
++ ps_page->ps_page[j] = NULL;
++ }
++ }
+
+- size = sizeof(struct iegbe_buffer) * rx_ring->count;
++ size = sizeof(struct iegbe_buffer) * rx_ring->count;
+ memset(rx_ring->buffer_info, 0, size);
+- size = sizeof(struct iegbe_ps_page) * rx_ring->count;
++ size = sizeof(struct iegbe_ps_page) * rx_ring->count;
+ memset(rx_ring->ps_page, 0, size);
+- size = sizeof(struct iegbe_ps_page_dma) * rx_ring->count;
++ size = sizeof(struct iegbe_ps_page_dma) * rx_ring->count;
+ memset(rx_ring->ps_page_dma, 0, size);
+
+- /* Zero out the descriptor ring */
++ /* Zero out the descriptor ring */
+
+ memset(rx_ring->desc, 0, rx_ring->size);
+
+ rx_ring->next_to_clean = 0;
+ rx_ring->next_to_use = 0;
+
+- writel(0, adapter->hw.hw_addr + rx_ring->rdh);
+- writel(0, adapter->hw.hw_addr + rx_ring->rdt);
++ writel(0, hw->hw_addr + rx_ring->rdh);
++ writel(0, hw->hw_addr + rx_ring->rdt);
+ }
+
+ /**
+@@ -2293,60 +2065,54 @@ iegbe_clean_rx_ring(struct iegbe_adapter
+ * @adapter: board private structure
+ **/
+
+-static void
+-iegbe_clean_all_rx_rings(struct iegbe_adapter *adapter)
++static void iegbe_clean_all_rx_rings(struct iegbe_adapter *adapter)
+ {
+- int i;
++ int i;
+
+- for (i = 0; i < adapter->num_queues; i++)
++ for (i = 0; i < adapter->num_rx_queues; i++)
+ iegbe_clean_rx_ring(adapter, &adapter->rx_ring[i]);
+ }
+
+ /* The 82542 2.0 (revision 2) needs to have the receive unit in reset
+ * and memory write and invalidate disabled for certain operations
+ */
+-static void
+-iegbe_enter_82542_rst(struct iegbe_adapter *adapter)
++static void iegbe_enter_82542_rst(struct iegbe_adapter *adapter)
+ {
+- struct net_device *netdev = adapter->netdev;
+- uint32_t rctl;
++ struct net_device *netdev = adapter->netdev;
++ uint32_t rctl;
+
+- iegbe_pci_clear_mwi(&adapter->hw);
++ iegbe_pci_clear_mwi(&adapter->hw);
+
+- rctl = E1000_READ_REG(&adapter->hw, RCTL);
+- rctl |= E1000_RCTL_RST;
+- E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
+- E1000_WRITE_FLUSH(&adapter->hw);
++ rctl = E1000_READ_REG(&adapter->hw, RCTL);
++ rctl |= E1000_RCTL_RST;
++ E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
++ E1000_WRITE_FLUSH(&adapter->hw);
+ mdelay(0x5);
+
+ if(netif_running(netdev)) {
+- iegbe_clean_all_rx_rings(adapter);
+-}
++ iegbe_clean_all_rx_rings(adapter);
++ }
+ }
+
+ static void
+ iegbe_leave_82542_rst(struct iegbe_adapter *adapter)
+ {
+- struct net_device *netdev = adapter->netdev;
+- uint32_t rctl;
++ struct net_device *netdev = adapter->netdev;
++ uint32_t rctl;
+
+- rctl = E1000_READ_REG(&adapter->hw, RCTL);
+- rctl &= ~E1000_RCTL_RST;
+- E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
+- E1000_WRITE_FLUSH(&adapter->hw);
++ rctl = E1000_READ_REG(&adapter->hw, RCTL);
++ rctl &= ~E1000_RCTL_RST;
++ E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
++ E1000_WRITE_FLUSH(&adapter->hw);
+ mdelay(0x5);
+
+ if(adapter->hw.pci_cmd_word & PCI_COMMAND_INVALIDATE) {
+- iegbe_pci_set_mwi(&adapter->hw);
++ iegbe_pci_set_mwi(&adapter->hw);
+ }
+ if(netif_running(netdev)) {
++ struct iegbe_rx_ring *ring = &adapter->rx_ring[0x0];
+ iegbe_configure_rx(adapter);
+-#ifdef IEGBE_GBE_WORKAROUND
+- iegbe_alloc_rx_buffers(adapter, &adapter->rx_ring[0],
+- IEGBE_GBE_WORKAROUND_NUM_RX_DESCRIPTORS + 1);
+-#else
+- iegbe_alloc_rx_buffers(adapter, &adapter->rx_ring[0]);
+-#endif
++ adapter->alloc_rx_buf(adapter, ring, E1000_DESC_UNUSED(ring));
+ }
+ }
+
+@@ -2358,133 +2124,153 @@ iegbe_leave_82542_rst(struct iegbe_adapt
+ * Returns 0 on success, negative on failure
+ **/
+
+-static int
+-iegbe_set_mac(struct net_device *netdev, void *p)
++static int iegbe_set_mac(struct net_device *netdev, void *p)
+ {
+- struct iegbe_adapter *adapter = netdev_priv(netdev);
+- struct sockaddr *addr = p;
++ struct iegbe_adapter *adapter = netdev_priv(netdev);
++ struct sockaddr *addr = p;
+
+ if(!is_valid_ether_addr(addr->sa_data)) {
+- return -EADDRNOTAVAIL;
++ return -EADDRNOTAVAIL;
+ }
+- /* 82542 2.0 needs to be in reset to write receive address registers */
++ /* 82542 2.0 needs to be in reset to write receive address registers */
+
+ if(adapter->hw.mac_type == iegbe_82542_rev2_0) {
+- iegbe_enter_82542_rst(adapter);
++ iegbe_enter_82542_rst(adapter);
+ }
+- memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
+- memcpy(adapter->hw.mac_addr, addr->sa_data, netdev->addr_len);
++ memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
++ memcpy(adapter->hw.mac_addr, addr->sa_data, netdev->addr_len);
+
+- iegbe_rar_set(&adapter->hw, adapter->hw.mac_addr, 0);
++ iegbe_rar_set(&adapter->hw, adapter->hw.mac_addr, 0x0);
+
+- /* With 82571 controllers, LAA may be overwritten (with the default)
+- * due to controller reset from the other port. */
+- if (adapter->hw.mac_type == iegbe_82571) {
+- /* activate the work around */
++ /* With 82571 controllers, LAA may be overwritten (with the default)
++ * due to controller reset from the other port. */
++ if (adapter->hw.mac_type == iegbe_82571) {
++ /* activate the work around */
+ adapter->hw.laa_is_present = 0x1;
+
+- /* Hold a copy of the LAA in RAR[14] This is done so that
+- * between the time RAR[0] gets clobbered and the time it
+- * gets fixed (in iegbe_watchdog), the actual LAA is in one
+- * of the RARs and no incoming packets directed to this port
+- * are dropped. Eventaully the LAA will be in RAR[0] and
+- * RAR[14] */
+- iegbe_rar_set(&adapter->hw, adapter->hw.mac_addr,
++ /* Hold a copy of the LAA in RAR[14] This is done so that
++ * between the time RAR[0] gets clobbered and the time it
++ * gets fixed (in iegbe_watchdog), the actual LAA is in one
++ * of the RARs and no incoming packets directed to this port
++ * are dropped. Eventaully the LAA will be in RAR[0] and
++ * RAR[14] */
++ iegbe_rar_set(&adapter->hw, adapter->hw.mac_addr,
+ E1000_RAR_ENTRIES - 0x1);
+- }
++ }
+
+ if(adapter->hw.mac_type == iegbe_82542_rev2_0) {
+- iegbe_leave_82542_rst(adapter);
++ iegbe_leave_82542_rst(adapter);
+ }
+- return 0;
++ return 0x0;
+ }
+
+ /**
+- * iegbe_set_multi - Multicast and Promiscuous mode set
++ * iegbe_set_rx_mode - Secondary Unicast, Multicast and Promiscuous mode set
+ * @netdev: network interface device structure
+ *
+- * The set_multi entry point is called whenever the multicast address
+- * list or the network interface flags are updated. This routine is
+- * responsible for configuring the hardware for proper multicast,
++ * The set_rx_mode entry point is called whenever the unicast or multicast
++ * address lists or the network interface flags are updated. This routine is
++ * responsible for configuring the hardware for proper unicast, multicast,
+ * promiscuous mode, and all-multi behavior.
+ **/
+
+-static void
+-iegbe_set_multi(struct net_device *netdev)
++static void iegbe_set_rx_mode(struct net_device *netdev)
+ {
+ struct iegbe_adapter *adapter = netdev_priv(netdev);
+ struct iegbe_hw *hw = &adapter->hw;
+- struct dev_mc_list *mc_ptr;
+- uint32_t rctl;
+- uint32_t hash_value;
++ struct dev_addr_list *uc_ptr;
++ struct dev_addr_list *mc_ptr;
++ u32 rctl;
++ u32 hash_value;
+ int i, rar_entries = E1000_RAR_ENTRIES;
++int mta_reg_count = E1000_NUM_MTA_REGISTERS;
+
+ /* reserve RAR[14] for LAA over-write work-around */
+- if (adapter->hw.mac_type == iegbe_82571) {
++ if (hw->mac_type == iegbe_82571)
+ rar_entries--;
+- }
++
+ /* Check for Promiscuous and All Multicast modes */
+
+- rctl = E1000_READ_REG(hw, RCTL);
++ rctl = E1000_READ_REG(&adapter->hw, RCTL);
+
+ if (netdev->flags & IFF_PROMISC) {
+ rctl |= (E1000_RCTL_UPE | E1000_RCTL_MPE);
+- } else if (netdev->flags & IFF_ALLMULTI) {
+- rctl |= E1000_RCTL_MPE;
+- rctl &= ~E1000_RCTL_UPE;
++ rctl &= ~E1000_RCTL_VFE;
+ } else {
+- rctl &= ~(E1000_RCTL_UPE | E1000_RCTL_MPE);
++ if (netdev->flags & IFF_ALLMULTI) {
++ rctl |= E1000_RCTL_MPE;
++ } else {
++ rctl &= ~E1000_RCTL_MPE;
++ }
++ }
++
++ uc_ptr = NULL;
++ if (netdev->uc_count > rar_entries - 1) {
++ rctl |= E1000_RCTL_UPE;
++ } else if (!(netdev->flags & IFF_PROMISC)) {
++ rctl &= ~E1000_RCTL_UPE;
++ uc_ptr = netdev->uc_list;
+ }
+
+- E1000_WRITE_REG(hw, RCTL, rctl);
++ E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
+
+ /* 82542 2.0 needs to be in reset to write receive address registers */
+
+- if (hw->mac_type == iegbe_82542_rev2_0) {
++ if (hw->mac_type == iegbe_82542_rev2_0)
+ iegbe_enter_82542_rst(adapter);
+- }
+- /* load the first 14 multicast address into the exact filters 1-14
++
++ /* load the first 14 addresses into the exact filters 1-14. Unicast
++ * addresses take precedence to avoid disabling unicast filtering
++ * when possible.
++ *
+ * RAR 0 is used for the station MAC adddress
+ * if there are not 14 addresses, go ahead and clear the filters
+ * -- with 82571 controllers only 0-13 entries are filled here
+ */
+ mc_ptr = netdev->mc_list;
+
+- for (i = 0x1; i < rar_entries; i++) {
+- if (mc_ptr) {
+- iegbe_rar_set(hw, mc_ptr->dmi_addr, i);
++ for (i = 1; i < rar_entries; i++) {
++ if (uc_ptr) {
++ iegbe_rar_set(hw, uc_ptr->da_addr, i);
++ uc_ptr = uc_ptr->next;
++ } else if (mc_ptr) {
++ iegbe_rar_set(hw, mc_ptr->da_addr, i);
+ mc_ptr = mc_ptr->next;
+ } else {
+- E1000_WRITE_REG_ARRAY(hw, RA, i << 0x1, 0);
+- E1000_WRITE_REG_ARRAY(hw, RA, (i << 0x1) + 0x1, 0);
++ E1000_WRITE_REG_ARRAY(hw, RA, i << 1, 0);
++ E1000_WRITE_FLUSH(&adapter->hw);
++ E1000_WRITE_REG_ARRAY(hw, RA, (i << 1) + 1, 0);
++ E1000_WRITE_FLUSH(&adapter->hw);
+ }
+ }
++ WARN_ON(uc_ptr != NULL);
+
+ /* clear the old settings from the multicast hash table */
+
+- for (i = 0; i < E1000_NUM_MTA_REGISTERS; i++)
++ for (i = 0; i < mta_reg_count; i++) {
+ E1000_WRITE_REG_ARRAY(hw, MTA, i, 0);
++ E1000_WRITE_FLUSH(&adapter->hw);
++ }
+
+ /* load any remaining addresses into the hash table */
+
+ for (; mc_ptr; mc_ptr = mc_ptr->next) {
+- hash_value = iegbe_hash_mc_addr(hw, mc_ptr->dmi_addr);
++ hash_value = iegbe_hash_mc_addr(hw, mc_ptr->da_addr);
+ iegbe_mta_set(hw, hash_value);
+ }
+
+- if (hw->mac_type == iegbe_82542_rev2_0) {
++ if (hw->mac_type == iegbe_82542_rev2_0)
+ iegbe_leave_82542_rst(adapter);
+ }
+-}
+
+ /* Need to wait a few seconds after link up to get diagnostic information from
+ * the phy */
+
+-static void
+-iegbe_update_phy_info(unsigned long data)
++static void iegbe_update_phy_info(unsigned long data)
+ {
+- struct iegbe_adapter *adapter = (struct iegbe_adapter *) data;
+- iegbe_phy_get_info(&adapter->hw, &adapter->phy_info);
++ struct iegbe_adapter *adapter = (struct iegbe_adapter *) data;
++ struct iegbe_hw *hw = &adapter->hw;
++ iegbe_phy_get_info(hw, &adapter->phy_info);
+ }
+
+ /**
+@@ -2492,54 +2278,54 @@ iegbe_update_phy_info(unsigned long data
+ * @data: pointer to adapter cast into an unsigned long
+ **/
+
+-static void
+-iegbe_82547_tx_fifo_stall(unsigned long data)
++static void iegbe_82547_tx_fifo_stall(unsigned long data)
+ {
+- struct iegbe_adapter *adapter = (struct iegbe_adapter *) data;
+- struct net_device *netdev = adapter->netdev;
+- uint32_t tctl;
++ struct iegbe_adapter *adapter = (struct iegbe_adapter *) data;
++ struct net_device *netdev = adapter->netdev;
++ u32 tctl;
+
+- if(atomic_read(&adapter->tx_fifo_stall)) {
+- if((E1000_READ_REG(&adapter->hw, TDT) ==
+- E1000_READ_REG(&adapter->hw, TDH)) &&
+- (E1000_READ_REG(&adapter->hw, TDFT) ==
+- E1000_READ_REG(&adapter->hw, TDFH)) &&
+- (E1000_READ_REG(&adapter->hw, TDFTS) ==
+- E1000_READ_REG(&adapter->hw, TDFHS))) {
+- tctl = E1000_READ_REG(&adapter->hw, TCTL);
+- E1000_WRITE_REG(&adapter->hw, TCTL,
+- tctl & ~E1000_TCTL_EN);
+- E1000_WRITE_REG(&adapter->hw, TDFT,
+- adapter->tx_head_addr);
+- E1000_WRITE_REG(&adapter->hw, TDFH,
+- adapter->tx_head_addr);
+- E1000_WRITE_REG(&adapter->hw, TDFTS,
+- adapter->tx_head_addr);
+- E1000_WRITE_REG(&adapter->hw, TDFHS,
+- adapter->tx_head_addr);
+- E1000_WRITE_REG(&adapter->hw, TCTL, tctl);
+- E1000_WRITE_FLUSH(&adapter->hw);
+-
+- adapter->tx_fifo_head = 0;
+- atomic_set(&adapter->tx_fifo_stall, 0);
+- netif_wake_queue(netdev);
+- } else {
++ if(atomic_read(&adapter->tx_fifo_stall)) {
++ if((E1000_READ_REG(&adapter->hw, TDT) ==
++ E1000_READ_REG(&adapter->hw, TDH)) &&
++ (E1000_READ_REG(&adapter->hw, TDFT) ==
++ E1000_READ_REG(&adapter->hw, TDFH)) &&
++ (E1000_READ_REG(&adapter->hw, TDFTS) ==
++ E1000_READ_REG(&adapter->hw, TDFHS))) {
++ tctl = E1000_READ_REG(&adapter->hw, TCTL);
++ E1000_WRITE_REG(&adapter->hw, TCTL,
++ tctl & ~E1000_TCTL_EN);
++ E1000_WRITE_REG(&adapter->hw, TDFT,
++ adapter->tx_head_addr);
++ E1000_WRITE_REG(&adapter->hw, TDFH,
++ adapter->tx_head_addr);
++ E1000_WRITE_REG(&adapter->hw, TDFTS,
++ adapter->tx_head_addr);
++ E1000_WRITE_REG(&adapter->hw, TDFHS,
++ adapter->tx_head_addr);
++ E1000_WRITE_REG(&adapter->hw, TCTL, tctl);
++ E1000_WRITE_FLUSH(&adapter->hw);
++
++ adapter->tx_fifo_head = 0x0;
++ atomic_set(&adapter->tx_fifo_stall, 0x0);
++ netif_wake_queue(netdev);
++ } else {
+ mod_timer(&adapter->tx_fifo_stall_timer, jiffies + 0x1);
+- }
+- }
++ }
++ }
+ }
+
++
+ /**
+ * iegbe_watchdog - Timer Call-back
+ * @data: pointer to adapter cast into an unsigned long
+ **/
+-static void
+-iegbe_watchdog(unsigned long data)
++static void iegbe_watchdog(unsigned long data)
+ {
+- struct iegbe_adapter *adapter = (struct iegbe_adapter *) data;
+- struct net_device *netdev = adapter->netdev;
+- struct iegbe_tx_ring *txdr = &adapter->tx_ring[0];
+- uint32_t link;
++ struct iegbe_adapter *adapter = (struct iegbe_adapter *) data;
++ struct iegbe_hw *hw = &adapter->hw;
++ struct net_device *netdev = adapter->netdev;
++ struct iegbe_tx_ring *txdr = adapter->tx_ring;
++ u32 link, tctl;
+
+ /*
+ * Test the PHY for link status on icp_xxxx MACs.
+@@ -2547,123 +2333,305 @@ iegbe_watchdog(unsigned long data)
+ * in the adapter->hw structure, then set hw->get_link_status = 1
+ */
+ if(adapter->hw.mac_type == iegbe_icp_xxxx) {
+- int isUp = 0;
++ int isUp = 0x0;
+ int32_t ret_val;
+
+ ret_val = iegbe_oem_phy_is_link_up(&adapter->hw, &isUp);
+ if(ret_val != E1000_SUCCESS) {
+- isUp = 0;
+- }
++ isUp = 0x0;
++ }
+ if(isUp != adapter->hw.icp_xxxx_is_link_up) {
+ adapter->hw.get_link_status = 0x1;
+ }
+ }
+
+- iegbe_check_for_link(&adapter->hw);
+- if (adapter->hw.mac_type == iegbe_82573) {
+- iegbe_enable_tx_pkt_filtering(&adapter->hw);
++ iegbe_check_for_link(&adapter->hw);
++ if (adapter->hw.mac_type == iegbe_82573) {
++ iegbe_enable_tx_pkt_filtering(&adapter->hw);
+ #ifdef NETIF_F_HW_VLAN_TX
+ if (adapter->mng_vlan_id != adapter->hw.mng_cookie.vlan_id) {
+- iegbe_update_mng_vlan(adapter);
++ iegbe_update_mng_vlan(adapter);
+ }
+ #endif
+- }
++ }
+
+- if ((adapter->hw.media_type == iegbe_media_type_internal_serdes) &&
+- !(E1000_READ_REG(&adapter->hw, TXCW) & E1000_TXCW_ANE)) {
+- link = !adapter->hw.serdes_link_down;
+- } else {
++ if ((adapter->hw.media_type == iegbe_media_type_internal_serdes) &&
++ !(E1000_READ_REG(&adapter->hw, TXCW) & E1000_TXCW_ANE)) {
++ link = !adapter->hw.serdes_link_down;
++ } else {
+
+- if(adapter->hw.mac_type != iegbe_icp_xxxx) {
+- link = E1000_READ_REG(&adapter->hw, STATUS) & E1000_STATUS_LU;
+- } else {
+- int isUp = 0;
++ if(adapter->hw.mac_type != iegbe_icp_xxxx) {
++ link = E1000_READ_REG(&adapter->hw, STATUS) & E1000_STATUS_LU;
++ } else {
++ int isUp = 0x0;
+ if(iegbe_oem_phy_is_link_up(&adapter->hw, &isUp) != E1000_SUCCESS) {
+- isUp = 0;
++ isUp = 0x0;
+ }
+- link = isUp;
+- }
+- }
++ link = isUp;
++ }
++ }
+
+- if (link) {
+- if (!netif_carrier_ok(netdev)) {
+- iegbe_get_speed_and_duplex(&adapter->hw,
+- &adapter->link_speed,
+- &adapter->link_duplex);
+-
+- DPRINTK(LINK, INFO, "NIC Link is Up %d Mbps %s\n",
+- adapter->link_speed,
+- adapter->link_duplex == FULL_DUPLEX ?
+- "Full Duplex" : "Half Duplex");
++ if (link) {
++ if (!netif_carrier_ok(netdev)) {
++ u32 ctrl;
++ bool txb2b = true;
++ iegbe_get_speed_and_duplex(hw,
++ &adapter->link_speed,
++ &adapter->link_duplex);
+
+- netif_carrier_on(netdev);
+- netif_wake_queue(netdev);
+- mod_timer(&adapter->phy_info_timer, jiffies + 0x2 * HZ);
++ ctrl = E1000_READ_REG(&adapter->hw, CTRL);
++ DPRINTK(LINK, INFO, "NIC Link is Up %d Mbps %s, "
++ "Flow Control: %s\n",
++ adapter->link_speed,
++ adapter->link_duplex == FULL_DUPLEX ?
++ "Full Duplex" : "Half Duplex",
++ ((ctrl & E1000_CTRL_TFCE) && (ctrl &
++ E1000_CTRL_RFCE)) ? "RX/TX" : ((ctrl &
++ E1000_CTRL_RFCE) ? "RX" : ((ctrl &
++ E1000_CTRL_TFCE) ? "TX" : "None" )));
++
++ /* tweak tx_queue_len according to speed/duplex
++ * and adjust the timeout factor */
++ netdev->tx_queue_len = adapter->tx_queue_len;
++ adapter->tx_timeout_factor = 1;
++ switch (adapter->link_speed) {
++ case SPEED_10:
++ txb2b = false;
++ netdev->tx_queue_len = 10;
++ adapter->tx_timeout_factor = 8;
++ break;
++ case SPEED_100:
++ txb2b = false;
++ netdev->tx_queue_len = 100;
++ break;
++ }
++ if ((hw->mac_type == iegbe_82571 ||
++ hw->mac_type == iegbe_82572) &&
++ !txb2b) {
++ u32 tarc0;
++ tarc0 = E1000_READ_REG(&adapter->hw, TARC0);
++ tarc0 &= ~(1 << 21);
++ E1000_WRITE_REG(&adapter->hw, TARC0, tarc0);
++ }
++ /* disable TSO for pcie and 10/100 speeds, to avoid
++ * some hardware issues */
++ if (!adapter->tso_force &&
++ hw->bus_type == iegbe_bus_type_pci_express){
++ switch (adapter->link_speed) {
++ case SPEED_10:
++ case SPEED_100:
++ DPRINTK(PROBE,INFO,
++ "10/100 speed: disabling TSO\n");
++ netdev->features &= ~NETIF_F_TSO;
++ netdev->features &= ~NETIF_F_TSO6;
++ break;
++ case SPEED_1000:
++ netdev->features |= NETIF_F_TSO;
++ netdev->features |= NETIF_F_TSO6;
++ break;
++ default:
++ break;
++ }
++ }
++ tctl = E1000_READ_REG(&adapter->hw, TCTL);
++ tctl |= E1000_TCTL_EN;
++ E1000_WRITE_REG(&adapter->hw, TCTL, tctl);
++ netif_carrier_on(netdev);
++ netif_wake_queue(netdev);
++ mod_timer(&adapter->phy_info_timer, round_jiffies(jiffies + 2 * HZ));
+ adapter->smartspeed = 0;
++ } else {
++ if (hw->rx_needs_kicking) {
++ u32 rctl = E1000_READ_REG(&adapter->hw, RCTL);
++ E1000_WRITE_REG(&adapter->hw, RCTL, rctl | E1000_RCTL_EN);
++ }
+ }
+- } else {
+- if (netif_carrier_ok(netdev)) {
++ } else {
++ if (netif_carrier_ok(netdev)) {
+ adapter->link_speed = 0;
+ adapter->link_duplex = 0;
+- DPRINTK(LINK, INFO, "NIC Link is Down\n");
+- netif_carrier_off(netdev);
+- netif_stop_queue(netdev);
+- mod_timer(&adapter->phy_info_timer, jiffies + 0x2 * HZ);
+- }
++ DPRINTK(LINK, INFO, "NIC Link is Down\n");
++ netif_carrier_off(netdev);
++ netif_stop_queue(netdev);
++ mod_timer(&adapter->phy_info_timer, round_jiffies(jiffies + 2 * HZ));
++ }
+
+- iegbe_smartspeed(adapter);
+- }
++ iegbe_smartspeed(adapter);
++ }
++
++ iegbe_update_stats(adapter);
++
++ hw->tx_packet_delta = adapter->stats.tpt - adapter->tpt_old;
++ adapter->tpt_old = adapter->stats.tpt;
++ hw->collision_delta = adapter->stats.colc - adapter->colc_old;
++ adapter->colc_old = adapter->stats.colc;
++
++ adapter->gorcl = adapter->stats.gorcl - adapter->gorcl_old;
++ adapter->gorcl_old = adapter->stats.gorcl;
++ adapter->gotcl = adapter->stats.gotcl - adapter->gotcl_old;
++ adapter->gotcl_old = adapter->stats.gotcl;
++
++ iegbe_update_adaptive(hw);
++
++ if (!netif_carrier_ok(netdev)) {
++ if (E1000_DESC_UNUSED(txdr) + 1 < txdr->count) {
++ /* We've lost link, so the controller stops DMA,
++ * but we've got queued Tx work that's never going
++ * to get done, so reset controller to flush Tx.
++ * (Do the reset outside of interrupt context). */
++ adapter->tx_timeout_count++;
++ schedule_work(&adapter->reset_task);
++ }
++ }
++
++ /* Cause software interrupt to ensure rx ring is cleaned */
++ E1000_WRITE_REG(&adapter->hw, ICS, E1000_ICS_RXDMT0);
++
++ /* Force detection of hung controller every watchdog period */
++ adapter->detect_tx_hung = TRUE;
++
++ /* With 82571 controllers, LAA may be overwritten due to controller
++ * reset from the other port. Set the appropriate LAA in RAR[0] */
++ if (adapter->hw.mac_type == iegbe_82571 && adapter->hw.laa_is_present) {
++ iegbe_rar_set(&adapter->hw, adapter->hw.mac_addr, 0x0);
++ }
++ /* Reset the timer */
++ mod_timer(&adapter->watchdog_timer, round_jiffies(jiffies + 2 * HZ));
++}
++
++enum latency_range {
++ lowest_latency = 0,
++ low_latency = 1,
++ bulk_latency = 2,
++ latency_invalid = 255
++};
+
+- iegbe_update_stats(adapter);
++/**
++ * iegbe_update_itr - update the dynamic ITR value based on statistics
++ * Stores a new ITR value based on packets and byte
++ * counts during the last interrupt. The advantage of per interrupt
++ * computation is faster updates and more accurate ITR for the current
++ * traffic pattern. Constants in this function were computed
++ * based on theoretical maximum wire speed and thresholds were set based
++ * on testing data as well as attempting to minimize response time
++ * while increasing bulk throughput.
++ * this functionality is controlled by the InterruptThrottleRate module
++ * parameter (see iegbe_param.c)
++ * @adapter: pointer to adapter
++ * @itr_setting: current adapter->itr
++ * @packets: the number of packets during this measurement interval
++ * @bytes: the number of bytes during this measurement interval
++ **/
++static unsigned int iegbe_update_itr(struct iegbe_adapter *adapter,
++ u16 itr_setting, int packets, int bytes)
++{
++ unsigned int retval = itr_setting;
++ struct iegbe_hw *hw = &adapter->hw;
+
+- adapter->hw.tx_packet_delta = adapter->stats.tpt - adapter->tpt_old;
+- adapter->tpt_old = adapter->stats.tpt;
+- adapter->hw.collision_delta = adapter->stats.colc - adapter->colc_old;
+- adapter->colc_old = adapter->stats.colc;
+-
+- adapter->gorcl = adapter->stats.gorcl - adapter->gorcl_old;
+- adapter->gorcl_old = adapter->stats.gorcl;
+- adapter->gotcl = adapter->stats.gotcl - adapter->gotcl_old;
+- adapter->gotcl_old = adapter->stats.gotcl;
+-
+- iegbe_update_adaptive(&adapter->hw);
+-
+- if (adapter->num_queues == 0x1 && !netif_carrier_ok(netdev)) {
+- if (E1000_DESC_UNUSED(txdr) + 0x1 < txdr->count) {
+- /* We've lost link, so the controller stops DMA,
+- * but we've got queued Tx work that's never going
+- * to get done, so reset controller to flush Tx.
+- * (Do the reset outside of interrupt context). */
+- schedule_work(&adapter->tx_timeout_task);
++ if (unlikely(hw->mac_type < iegbe_82540))
++ goto update_itr_done;
++
++ if (packets == 0)
++ goto update_itr_done;
++
++ switch (itr_setting) {
++ case lowest_latency:
++ /* jumbo frames get bulk treatment*/
++ if (bytes/packets > 8000)
++ retval = bulk_latency;
++ else if ((packets < 5) && (bytes > 512))
++ retval = low_latency;
++ break;
++ case low_latency: /* 50 usec aka 20000 ints/s */
++ if (bytes > 10000) {
++ /* jumbo frames need bulk latency setting */
++ if (bytes/packets > 8000)
++ retval = bulk_latency;
++ else if ((packets < 10) || ((bytes/packets) > 1200))
++ retval = bulk_latency;
++ else if ((packets > 35))
++ retval = lowest_latency;
++ } else if (bytes/packets > 2000)
++ retval = bulk_latency;
++ else if (packets <= 2 && bytes < 512)
++ retval = lowest_latency;
++ break;
++ case bulk_latency: /* 250 usec aka 4000 ints/s */
++ if (bytes > 25000) {
++ if (packets > 35)
++ retval = low_latency;
++ } else if (bytes < 6000) {
++ retval = low_latency;
+ }
++ break;
+ }
+
+- /* Dynamic mode for Interrupt Throttle Rate (ITR) */
+- if (adapter->hw.mac_type >= iegbe_82540 && adapter->itr == 0x1) {
+- /* Symmetric Tx/Rx gets a reduced ITR=2000; Total
+- * asymmetrical Tx or Rx gets ITR=8000; everyone
+- * else is between 2000-8000. */
+- uint32_t goc = (adapter->gotcl + adapter->gorcl) / 0x2710;
+- uint32_t dif = (adapter->gotcl > adapter->gorcl ?
+- adapter->gotcl - adapter->gorcl :
+- adapter->gorcl - adapter->gotcl) / 0x2710;
+- uint32_t itr = goc > 0 ? (dif * 0x1770 / goc + 0x7d0) : 0x1f40;
+- E1000_WRITE_REG(&adapter->hw, ITR, 0x3b9aca00 / (itr * 0x100));
+- }
++update_itr_done:
++ return retval;
++}
+
+- /* Cause software interrupt to ensure rx ring is cleaned */
+- E1000_WRITE_REG(&adapter->hw, ICS, E1000_ICS_RXDMT0);
++static void iegbe_set_itr(struct iegbe_adapter *adapter)
++{
++ struct iegbe_hw *hw = &adapter->hw;
++ u16 current_itr;
++ u32 new_itr = adapter->itr;
+
+- /* Force detection of hung controller every watchdog period */
+- adapter->detect_tx_hung = TRUE;
++ if (unlikely(hw->mac_type < iegbe_82540))
++ return;
+
+- /* With 82571 controllers, LAA may be overwritten due to controller
+- * reset from the other port. Set the appropriate LAA in RAR[0] */
+- if (adapter->hw.mac_type == iegbe_82571 && adapter->hw.laa_is_present) {
+- iegbe_rar_set(&adapter->hw, adapter->hw.mac_addr, 0);
+- }
+- /* Reset the timer */
+- mod_timer(&adapter->watchdog_timer, jiffies + 0x2 * HZ);
++ /* for non-gigabit speeds, just fix the interrupt rate at 4000 */
++ if (unlikely(adapter->link_speed != SPEED_1000)) {
++ current_itr = 0;
++ new_itr = 4000;
++ goto set_itr_now;
++ }
++
++ adapter->tx_itr = iegbe_update_itr(adapter,
++ adapter->tx_itr,
++ adapter->total_tx_packets,
++ adapter->total_tx_bytes);
++ /* conservative mode (itr 3) eliminates the lowest_latency setting */
++ if (adapter->itr_setting == 3 && adapter->tx_itr == lowest_latency)
++ adapter->tx_itr = low_latency;
++
++ adapter->rx_itr = iegbe_update_itr(adapter,
++ adapter->rx_itr,
++ adapter->total_rx_packets,
++ adapter->total_rx_bytes);
++ /* conservative mode (itr 3) eliminates the lowest_latency setting */
++ if (adapter->itr_setting == 3 && adapter->rx_itr == lowest_latency)
++ adapter->rx_itr = low_latency;
++
++ current_itr = max(adapter->rx_itr, adapter->tx_itr);
++
++ switch (current_itr) {
++ /* counts and packets in update_itr are dependent on these numbers */
++ case lowest_latency:
++ new_itr = 70000;
++ break;
++ case low_latency:
++ new_itr = 20000; /* aka hwitr = ~200 */
++ break;
++ case bulk_latency:
++ new_itr = 4000;
++ break;
++ default:
++ break;
++ }
++
++set_itr_now:
++ if (new_itr != adapter->itr) {
++ /* this attempts to bias the interrupt rate towards Bulk
++ * by adding intermediate steps when interrupt rate is
++ * increasing */
++ new_itr = new_itr > adapter->itr ?
++ min(adapter->itr + (new_itr >> 2), new_itr) :
++ new_itr;
++ adapter->itr = new_itr;
++ E1000_WRITE_REG(&adapter->hw, ITR, 1000000000 / (new_itr * 256));
++ }
++
++ return;
+ }
+
+ #define E1000_TX_FLAGS_CSUM 0x00000001
+@@ -2673,55 +2641,48 @@ iegbe_watchdog(unsigned long data)
+ #define E1000_TX_FLAGS_VLAN_MASK 0xffff0000
+ #define E1000_TX_FLAGS_VLAN_SHIFT 16
+
+-static inline int
+-iegbe_tso(struct iegbe_adapter *adapter, struct iegbe_tx_ring *tx_ring,
+- struct sk_buff *skb)
++static int iegbe_tso(struct iegbe_adapter *adapter,
++ struct iegbe_tx_ring *tx_ring, struct sk_buff *skb)
+ {
+-#ifdef NETIF_F_TSO
+ struct iegbe_context_desc *context_desc;
++ struct iegbe_buffer *buffer_info;
+ unsigned int i;
+- uint32_t cmd_length = 0;
+- uint16_t ipcse = 0, tucse, mss;
+- uint8_t ipcss, ipcso, tucss, tucso, hdr_len;
++ u32 cmd_length = 0;
++ u16 ipcse = 0, tucse, mss;
++ u8 ipcss, ipcso, tucss, tucso, hdr_len;
+ int err;
+
+ if (skb_is_gso(skb)) {
+ if (skb_header_cloned(skb)) {
+ err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC);
+- if (err) {
++ if (err)
+ return err;
+ }
+- }
+
+- hdr_len = ((skb->h.raw - skb->data) + (skb->h.th->doff << 0x2));
++ hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
+ mss = skb_shinfo(skb)->gso_size;
+ if (skb->protocol == htons(ETH_P_IP)) {
+- skb->nh.iph->tot_len = 0;
+- skb->nh.iph->check = 0;
+- skb->h.th->check =
+- ~csum_tcpudp_magic(skb->nh.iph->saddr,
+- skb->nh.iph->daddr,
+- 0,
+- IPPROTO_TCP,
+- 0);
++ struct iphdr *iph = ip_hdr(skb);
++ iph->tot_len = 0;
++ iph->check = 0;
++ tcp_hdr(skb)->check = ~csum_tcpudp_magic(iph->saddr,
++ iph->daddr, 0,
++ IPPROTO_TCP,
++ 0);
+ cmd_length = E1000_TXD_CMD_IP;
+- ipcse = skb->h.raw - skb->data - 0x1;
+-#ifdef NETIF_F_TSO_IPV6
+- } else if (skb->protocol == ntohs(ETH_P_IPV6)) {
+- skb->nh.ipv6h->payload_len = 0;
+- skb->h.th->check =
+- ~csum_ipv6_magic(&skb->nh.ipv6h->saddr,
+- &skb->nh.ipv6h->daddr,
+- 0,
+- IPPROTO_TCP,
+- 0);
++ ipcse = skb_transport_offset(skb) - 1;
++ } else if (skb->protocol == htons(ETH_P_IPV6)) {
++ ipv6_hdr(skb)->payload_len = 0;
++ tcp_hdr(skb)->check =
++ ~csum_ipv6_magic(&ipv6_hdr(skb)->saddr,
++ &ipv6_hdr(skb)->daddr,
++ 0, IPPROTO_TCP, 0);
+ ipcse = 0;
+-#endif
+ }
+- ipcss = skb->nh.raw - skb->data;
+- ipcso = (void *)&(skb->nh.iph->check) - (void *)skb->data;
+- tucss = skb->h.raw - skb->data;
+- tucso = (void *)&(skb->h.th->check) - (void *)skb->data;
++ ipcss = skb_network_offset(skb);
++ ipcso = (void *)&(ip_hdr(skb)->check) - (void *)skb->data;
++ tucss = skb_transport_offset(skb);
++ tucso = (void *)&(tcp_hdr(skb)->check) - (void *)skb->data;
+ tucse = 0;
+
+ cmd_length |= (E1000_TXD_CMD_DEXT | E1000_TXD_CMD_TSE |
+@@ -2729,6 +2690,7 @@ iegbe_tso(struct iegbe_adapter *adapter,
+
+ i = tx_ring->next_to_use;
+ context_desc = E1000_CONTEXT_DESC(*tx_ring, i);
++ buffer_info = &tx_ring->buffer_info[i];
+
+ context_desc->lower_setup.ip_fields.ipcss = ipcss;
+ context_desc->lower_setup.ip_fields.ipcso = ipcso;
+@@ -2740,205 +2702,218 @@ iegbe_tso(struct iegbe_adapter *adapter,
+ context_desc->tcp_seg_setup.fields.hdr_len = hdr_len;
+ context_desc->cmd_and_length = cpu_to_le32(cmd_length);
+
+- if (++i == tx_ring->count) { i = 0; }
++ buffer_info->time_stamp = jiffies;
++ buffer_info->next_to_watch = i;
++
++ if (++i == tx_ring->count) i = 0;
+ tx_ring->next_to_use = i;
+
+- return TRUE;
++ return true;
+ }
+-#endif
+-
+- return FALSE;
++ return false;
+ }
+
+-static inline boolean_t
+-iegbe_tx_csum(struct iegbe_adapter *adapter, struct iegbe_tx_ring *tx_ring,
+- struct sk_buff *skb)
++static bool iegbe_tx_csum(struct iegbe_adapter *adapter,
++ struct iegbe_tx_ring *tx_ring, struct sk_buff *skb)
+ {
+ struct iegbe_context_desc *context_desc;
++ struct iegbe_buffer *buffer_info;
+ unsigned int i;
+- uint8_t css;
++ u8 css;
+
+- if (likely(skb->ip_summed == CHECKSUM_HW)) {
+- css = skb->h.raw - skb->data;
++ if (likely(skb->ip_summed == CHECKSUM_PARTIAL)) {
++ css = skb_transport_offset(skb);
+
+- i = tx_ring->next_to_use;
+- context_desc = E1000_CONTEXT_DESC(*tx_ring, i);
++ i = tx_ring->next_to_use;
++ buffer_info = &tx_ring->buffer_info[i];
++ context_desc = E1000_CONTEXT_DESC(*tx_ring, i);
+
++ context_desc->lower_setup.ip_config = 0;
+ context_desc->upper_setup.tcp_fields.tucss = css;
+- context_desc->upper_setup.tcp_fields.tucso = css + skb->csum;
++ context_desc->upper_setup.tcp_fields.tucso =
++ css + skb->csum_offset;
+ context_desc->upper_setup.tcp_fields.tucse = 0;
+ context_desc->tcp_seg_setup.data = 0;
+ context_desc->cmd_and_length = cpu_to_le32(E1000_TXD_CMD_DEXT);
+
+- if (unlikely(++i == tx_ring->count)) { i = 0; }
++ buffer_info->time_stamp = jiffies;
++ buffer_info->next_to_watch = i;
++
++ if (unlikely(++i == tx_ring->count)) i = 0;
+ tx_ring->next_to_use = i;
+
+- return TRUE;
++ return true;
+ }
+
+- return FALSE;
++ return false;
+ }
+
+-#define E1000_MAX_TXD_PWR 12
+-#define E1000_MAX_DATA_PER_TXD (1<<E1000_MAX_TXD_PWR)
++#define E1000_MAX_TXD_PWR 12
++#define E1000_MAX_DATA_PER_TXD (1<<E1000_MAX_TXD_PWR)
+
+-static inline int
+-iegbe_tx_map(struct iegbe_adapter *adapter, struct iegbe_tx_ring *tx_ring,
+- struct sk_buff *skb, unsigned int first, unsigned int max_per_txd,
+- unsigned int nr_frags, unsigned int mss)
++static int iegbe_tx_map(struct iegbe_adapter *adapter,
++ struct iegbe_tx_ring *tx_ring,
++ struct sk_buff *skb, unsigned int first,
++ unsigned int max_per_txd, unsigned int nr_frags,
++ unsigned int mss)
+ {
+- struct iegbe_buffer *buffer_info;
+- unsigned int len = skb->len;
++ struct iegbe_hw *hw = &adapter->hw;
++ struct iegbe_buffer *buffer_info;
++ unsigned int len = skb->len;
+ unsigned int offset = 0, size, count = 0, i;
+-#ifdef MAX_SKB_FRAGS
+- unsigned int f;
+- len -= skb->data_len;
+-#endif
++ unsigned int f;
++ len -= skb->data_len;
+
+- i = tx_ring->next_to_use;
++ i = tx_ring->next_to_use;
++
++ while(len) {
++ buffer_info = &tx_ring->buffer_info[i];
++ size = min(len, max_per_txd);
++ /* Workaround for Controller erratum --
++ * descriptor for non-tso packet in a linear SKB that follows a
++ * tso gets written back prematurely before the data is fully
++ * DMA'd to the controller */
++ if (!skb->data_len && tx_ring->last_tx_tso &&
++ !skb_is_gso(skb)) {
++ tx_ring->last_tx_tso = 0;
++ size -= 4;
++ }
+
+- while(len) {
+- buffer_info = &tx_ring->buffer_info[i];
+- size = min(len, max_per_txd);
+-#ifdef NETIF_F_TSO
+ /* Workaround for premature desc write-backs
+ * in TSO mode. Append 4-byte sentinel desc */
+- if(unlikely(mss && !nr_frags && size == len && size > 0x8)) {
+- size -= 0x4;
++ if (unlikely(mss && !nr_frags && size == len && size > 8))
++ size -= 4;
++ /* work-around for errata 10 and it applies
++ * to all controllers in PCI-X mode
++ * The fix is to make sure that the first descriptor of a
++ * packet is smaller than 2048 - 16 - 16 (or 2016) bytes
++ */
++ if (unlikely((hw->bus_type == iegbe_bus_type_pcix) &&
++ (size > 2015) && count == 0))
++ size = 2015;
++
++ /* Workaround for potential 82544 hang in PCI-X. Avoid
++ * terminating buffers within evenly-aligned dwords. */
++ if(unlikely(adapter->pcix_82544 &&
++ !((unsigned long)(skb->data + offset + size - 1) & 4) &&
++ size > 4))
++ size -= 4;
++
++ buffer_info->length = size;
++ buffer_info->dma =
++ pci_map_single(adapter->pdev,
++ skb->data + offset,
++ size,
++ PCI_DMA_TODEVICE);
++ buffer_info->time_stamp = jiffies;
++ buffer_info->next_to_watch = i;
++
++ len -= size;
++ offset += size;
++ count++;
++ if (unlikely(++i == tx_ring->count)) i = 0;
++ }
++
++ for (f = 0; f < nr_frags; f++) {
++ struct skb_frag_struct *frag;
++
++ frag = &skb_shinfo(skb)->frags[f];
++ len = frag->size;
++ offset = frag->page_offset;
++
++ while(len) {
++ buffer_info = &tx_ring->buffer_info[i];
++ size = min(len, max_per_txd);
++ /* Workaround for premature desc write-backs
++ * in TSO mode. Append 4-byte sentinel desc */
++ if (unlikely(mss && f == (nr_frags-1) && size == len && size > 8))
++ size -= 4;
++ /* Workaround for potential 82544 hang in PCI-X.
++ * Avoid terminating buffers within evenly-aligned
++ * dwords. */
++ if(unlikely(adapter->pcix_82544 &&
++ !((unsigned long)(frag->page+offset+size-1) & 4) &&
++ size > 4))
++ size -= 4;
++
++ buffer_info->length = size;
++ buffer_info->dma =
++ pci_map_page(adapter->pdev,
++ frag->page,
++ offset,
++ size,
++ PCI_DMA_TODEVICE);
++ buffer_info->time_stamp = jiffies;
++ buffer_info->next_to_watch = i;
++
++ len -= size;
++ offset += size;
++ count++;
++ if (unlikely(++i == tx_ring->count)) i = 0;
+ }
+-#endif
+- /* work-around for errata 10 and it applies
+- * to all controllers in PCI-X mode
+- * The fix is to make sure that the first descriptor of a
+- * packet is smaller than 2048 - 16 - 16 (or 2016) bytes
+- */
+- if(unlikely((adapter->hw.bus_type == iegbe_bus_type_pcix) &&
+- (size > 0x7df) && count == 0)) {
+- size = 0x7df;
+- }
+- /* Workaround for potential 82544 hang in PCI-X. Avoid
+- * terminating buffers within evenly-aligned dwords. */
+- if(unlikely(adapter->pcix_82544 &&
+- !((unsigned long)(skb->data + offset + size - 0x8) & 0x4) &&
+- size > 0x4)) {
+- size -= 0x4;
+- }
+- buffer_info->length = size;
+- buffer_info->dma =
+- pci_map_single(adapter->pdev,
+- skb->data + offset,
+- size,
+- PCI_DMA_TODEVICE);
+- buffer_info->time_stamp = jiffies;
+-
+- len -= size;
+- offset += size;
+- count++;
+- if(unlikely(++i == tx_ring->count)) { i = 0; }
+- }
+-
+-#ifdef MAX_SKB_FRAGS
+- for(f = 0; f < nr_frags; f++) {
+- struct skb_frag_struct *frag;
+-
+- frag = &skb_shinfo(skb)->frags[f];
+- len = frag->size;
+- offset = frag->page_offset;
+-
+- while(len) {
+- buffer_info = &tx_ring->buffer_info[i];
+- size = min(len, max_per_txd);
+-#ifdef NETIF_F_TSO
+- /* Workaround for premature desc write-backs
+- * in TSO mode. Append 4-byte sentinel desc */
+- if(unlikely(mss && f == (nr_frags-0x1) &&
+- size == len && size > 0x8)) {
+- size -= 0x4;
+- }
+-#endif
+- /* Workaround for potential 82544 hang in PCI-X.
+- * Avoid terminating buffers within evenly-aligned
+- * dwords. */
+- if(unlikely(adapter->pcix_82544 &&
+- !((unsigned long)(frag->page+offset+size-0x1) & 0x4) &&
+- size > 0x4)) {
+- size -= 0x4;
+- }
+- buffer_info->length = size;
+- buffer_info->dma =
+- pci_map_page(adapter->pdev,
+- frag->page,
+- offset,
+- size,
+- PCI_DMA_TODEVICE);
+- buffer_info->time_stamp = jiffies;
+-
+- len -= size;
+- offset += size;
+- count++;
+- if(unlikely(++i == tx_ring->count)) { i = 0; }
+- }
+- }
+-#endif
++ }
+
+- i = (i == 0) ? tx_ring->count - 0x1 : i - 0x1;
+- tx_ring->buffer_info[i].skb = skb;
+- tx_ring->buffer_info[first].next_to_watch = i;
++ i = (i == 0) ? tx_ring->count - 1 : i - 1;
++ tx_ring->buffer_info[i].skb = skb;
++ tx_ring->buffer_info[first].next_to_watch = i;
+
+- return count;
++ return count;
+ }
+
+-static inline void
+-iegbe_tx_queue(struct iegbe_adapter *adapter, struct iegbe_tx_ring *tx_ring,
+- int tx_flags, int count)
++static void iegbe_tx_queue(struct iegbe_adapter *adapter,
++ struct iegbe_tx_ring *tx_ring, int tx_flags,
++ int count)
+ {
++ struct iegbe_hw *hw = &adapter->hw;
+ struct iegbe_tx_desc *tx_desc = NULL;
+ struct iegbe_buffer *buffer_info;
+- uint32_t txd_upper = 0, txd_lower = E1000_TXD_CMD_IFCS;
++ u32 txd_upper = 0, txd_lower = E1000_TXD_CMD_IFCS;
+ unsigned int i;
+
+- if(likely(tx_flags & E1000_TX_FLAGS_TSO)) {
++ if (likely(tx_flags & E1000_TX_FLAGS_TSO)) {
+ txd_lower |= E1000_TXD_CMD_DEXT | E1000_TXD_DTYP_D |
+ E1000_TXD_CMD_TSE;
+- txd_upper |= E1000_TXD_POPTS_TXSM << 0x8;
++ txd_upper |= E1000_TXD_POPTS_TXSM << 8;
+
+- if(likely(tx_flags & E1000_TX_FLAGS_IPV4)) {
+- txd_upper |= E1000_TXD_POPTS_IXSM << 0x8;
+- }
++ if (likely(tx_flags & E1000_TX_FLAGS_IPV4))
++ txd_upper |= E1000_TXD_POPTS_IXSM << 8;
+ }
+
+- if(likely(tx_flags & E1000_TX_FLAGS_CSUM)) {
++ if (likely(tx_flags & E1000_TX_FLAGS_CSUM)) {
+ txd_lower |= E1000_TXD_CMD_DEXT | E1000_TXD_DTYP_D;
+- txd_upper |= E1000_TXD_POPTS_TXSM << 0x8;
+- }
+-
+- if(unlikely(tx_flags & E1000_TX_FLAGS_VLAN)) {
+- txd_lower |= E1000_TXD_CMD_VLE;
+- txd_upper |= (tx_flags & E1000_TX_FLAGS_VLAN_MASK);
++ txd_upper |= E1000_TXD_POPTS_TXSM << 8;
+ }
+
+- i = tx_ring->next_to_use;
++ if(unlikely(tx_flags & E1000_TX_FLAGS_VLAN)) {
++ txd_lower |= E1000_TXD_CMD_VLE;
++ txd_upper |= (tx_flags & E1000_TX_FLAGS_VLAN_MASK);
++ }
+
+- while(count--) {
+- buffer_info = &tx_ring->buffer_info[i];
+- tx_desc = E1000_TX_DESC(*tx_ring, i);
+- tx_desc->buffer_addr = cpu_to_le64(buffer_info->dma);
+- tx_desc->lower.data =
+- cpu_to_le32(txd_lower | buffer_info->length);
+- tx_desc->upper.data = cpu_to_le32(txd_upper);
+- if(unlikely(++i == tx_ring->count)) { i = 0; }
+- }
+- if(tx_desc != NULL) {
+- tx_desc->lower.data |= cpu_to_le32(adapter->txd_cmd);
+- }
+- /* Force memory writes to complete before letting h/w
+- * know there are new descriptors to fetch. (Only
+- * applicable for weak-ordered memory model archs,
+- * such as IA-64). */
+- wmb();
++ i = tx_ring->next_to_use;
+
+- tx_ring->next_to_use = i;
+- writel(i, adapter->hw.hw_addr + tx_ring->tdt);
++ while(count--) {
++ buffer_info = &tx_ring->buffer_info[i];
++ tx_desc = E1000_TX_DESC(*tx_ring, i);
++ tx_desc->buffer_addr = cpu_to_le64(buffer_info->dma);
++ tx_desc->lower.data =
++ cpu_to_le32(txd_lower | buffer_info->length);
++ tx_desc->upper.data = cpu_to_le32(txd_upper);
++ if (unlikely(++i == tx_ring->count)) i = 0;
++ }
++
++ tx_desc->lower.data |= cpu_to_le32(adapter->txd_cmd);
++
++ /* Force memory writes to complete before letting h/w
++ * know there are new descriptors to fetch. (Only
++ * applicable for weak-ordered memory model archs,
++ * such as IA-64). */
++ wmb();
++
++ tx_ring->next_to_use = i;
++ writel(i, hw->hw_addr + tx_ring->tdt);
++ /* we need this if more than one processor can write to our tail
++ * at a time, it syncronizes IO on IA64/Altix systems */
++ mmiowb();
+ }
+
+ /**
+@@ -2950,113 +2925,132 @@ iegbe_tx_queue(struct iegbe_adapter *ada
+ * to the beginning of the Tx FIFO.
+ **/
+
+-static inline int
+-iegbe_82547_fifo_workaround(struct iegbe_adapter *adapter, struct sk_buff *skb)
++#define E1000_FIFO_HDR 0x10
++#define E1000_82547_PAD_LEN 0x3E0
++static int iegbe_82547_fifo_workaround(struct iegbe_adapter *adapter,
++ struct sk_buff *skb)
+ {
+- uint32_t fifo_space = adapter->tx_fifo_size - adapter->tx_fifo_head;
+- uint32_t skb_fifo_len = skb->len + E1000_FIFO_HDR;
++ u32 fifo_space = adapter->tx_fifo_size - adapter->tx_fifo_head;
++ u32 skb_fifo_len = skb->len + E1000_FIFO_HDR;
+
+- E1000_ROUNDUP(skb_fifo_len, E1000_FIFO_HDR);
++ skb_fifo_len = ALIGN(skb_fifo_len, E1000_FIFO_HDR);
+
+- if(adapter->link_duplex != HALF_DUPLEX) {
+- goto no_fifo_stall_required;
+- }
+- if(atomic_read(&adapter->tx_fifo_stall)) {
+- return 1;
++ if (adapter->link_duplex != HALF_DUPLEX)
++ goto no_fifo_stall_required;
++
++ if (atomic_read(&adapter->tx_fifo_stall))
++ return 1;
++
++ if(skb_fifo_len >= (E1000_82547_PAD_LEN + fifo_space)) {
++ atomic_set(&adapter->tx_fifo_stall, 1);
++ return 1;
+ }
+- if(skb_fifo_len >= (E1000_82547_PAD_LEN + fifo_space)) {
+- atomic_set(&adapter->tx_fifo_stall, 0x1);
+- return 1;
+- }
+
+ no_fifo_stall_required:
+- adapter->tx_fifo_head += skb_fifo_len;
+- if(adapter->tx_fifo_head >= adapter->tx_fifo_size) {
+- adapter->tx_fifo_head -= adapter->tx_fifo_size;
+- }
++ adapter->tx_fifo_head += skb_fifo_len;
++ if (adapter->tx_fifo_head >= adapter->tx_fifo_size)
++ adapter->tx_fifo_head -= adapter->tx_fifo_size;
+ return 0;
+ }
+
+-static inline int
+-iegbe_transfer_dhcp_info(struct iegbe_adapter *adapter, struct sk_buff *skb)
++#define MINIMUM_DHCP_PACKET_SIZE 282
++static int iegbe_transfer_dhcp_info(struct iegbe_adapter *adapter,
++ struct sk_buff *skb)
+ {
+ struct iegbe_hw *hw = &adapter->hw;
+- uint16_t length, offset;
+-#ifdef NETIF_F_HW_VLAN_TX
+- if(vlan_tx_tag_present(skb)) {
+- if(!((vlan_tx_tag_get(skb) == adapter->hw.mng_cookie.vlan_id) &&
+- ( adapter->hw.mng_cookie.status &
+- E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT)) ) {
++ u16 length, offset;
++ if (vlan_tx_tag_present(skb)) {
++ if (!((vlan_tx_tag_get(skb) == hw->mng_cookie.vlan_id) &&
++ ( hw->mng_cookie.status &
++ E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT)) )
+ return 0;
+ }
+- }
+-#endif
+- if(htons(ETH_P_IP) == skb->protocol) {
+- const struct iphdr *ip = skb->nh.iph;
+- if(IPPROTO_UDP == ip->protocol) {
+- struct udphdr *udp = (struct udphdr *)(skb->h.uh);
+- if(ntohs(udp->dest) == 0x43) { /* 0x43 = 67 */
+- offset = (uint8_t *)udp + 0x8 - skb->data;
+- length = skb->len - offset;
+-
+- return iegbe_mng_write_dhcp_info(hw,
+- (uint8_t *)udp + 0x8, length);
+- }
+- }
+- } else if((skb->len > MINIMUM_DHCP_PACKET_SIZE) && (!skb->protocol)) {
+- struct ethhdr *eth = (struct ethhdr *) skb->data;
+- if((htons(ETH_P_IP) == eth->h_proto)) {
++ if (skb->len > MINIMUM_DHCP_PACKET_SIZE) {
++ struct ethhdr *eth = (struct ethhdr *)skb->data;
++ if ((htons(ETH_P_IP) == eth->h_proto)) {
+ const struct iphdr *ip =
+- (struct iphdr *)((uint8_t *)skb->data+0xe);
+- if(IPPROTO_UDP == ip->protocol) {
++ (struct iphdr *)((u8 *)skb->data+14);
++ if (IPPROTO_UDP == ip->protocol) {
+ struct udphdr *udp =
+- (struct udphdr *)((uint8_t *)ip +
+- (ip->ihl << 0x2));
+- if(ntohs(udp->dest) == 0x43) {
+- offset = (uint8_t *)udp + 0x8 - skb->data;
++ (struct udphdr *)((u8 *)ip +
++ (ip->ihl << 2));
++ if (ntohs(udp->dest) == 67) {
++ offset = (u8 *)udp + 8 - skb->data;
+ length = skb->len - offset;
+
+ return iegbe_mng_write_dhcp_info(hw,
+- (uint8_t *)udp + 0x8,
++ (u8 *)udp + 8,
+ length);
+- }
++ }
+ }
+ }
+ }
+ return 0;
+ }
+
+-static int
+-iegbe_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
++static int __iegbe_maybe_stop_tx(struct net_device *netdev, int size)
++{
++ struct iegbe_adapter *adapter = netdev_priv(netdev);
++ struct iegbe_tx_ring *tx_ring = adapter->tx_ring;
++
++ netif_stop_queue(netdev);
++ /* Herbert's original patch had:
++ * smp_mb__after_netif_stop_queue();
++ * but since that doesn't exist yet, just open code it. */
++ smp_mb();
++
++ /* We need to check again in a case another CPU has just
++ * made room available. */
++ if (likely(E1000_DESC_UNUSED(tx_ring) < size))
++ return -EBUSY;
++
++ /* A reprieve! */
++ netif_start_queue(netdev);
++ ++adapter->restart_queue;
++ return 0;
++}
++
++static int iegbe_maybe_stop_tx(struct net_device *netdev,
++ struct iegbe_tx_ring *tx_ring, int size)
++{
++ if (likely(E1000_DESC_UNUSED(tx_ring) >= size))
++ return 0;
++ return __iegbe_maybe_stop_tx(netdev, size);
++}
++
++#define TXD_USE_COUNT(S, X) (((S) >> (X)) + 1 )
++static int iegbe_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
+ {
+ struct iegbe_adapter *adapter = netdev_priv(netdev);
++ struct iegbe_hw *hw = &adapter->hw;
+ struct iegbe_tx_ring *tx_ring;
+ unsigned int first, max_per_txd = E1000_MAX_DATA_PER_TXD;
+ unsigned int max_txd_pwr = E1000_MAX_TXD_PWR;
+ unsigned int tx_flags = 0;
+- unsigned int len = skb->len;
++ unsigned int len = skb->len - skb->data_len;
+ unsigned long flags = 0;
+- unsigned int nr_frags = 0;
+- unsigned int mss = 0;
++ unsigned int nr_frags;
++ unsigned int mss;
+ int count = 0;
+- int tso;
+-#ifdef MAX_SKB_FRAGS
++ int tso;
+ unsigned int f;
+- len -= skb->data_len;
+-#endif
+
+-#ifdef CONFIG_E1000_MQ
+- tx_ring = *per_cpu_ptr(adapter->cpu_tx_ring, smp_processor_id());
+-#else
++ /* This goes back to the question of how to logically map a tx queue
++ * to a flow. Right now, performance is impacted slightly negatively
++ * if using multiple tx queues. If the stack breaks away from a
++ * single qdisc implementation, we can look at this again. */
+ tx_ring = adapter->tx_ring;
+-#endif
+
+ if (unlikely(skb->len <= 0)) {
+ dev_kfree_skb_any(skb);
+ return NETDEV_TX_OK;
+ }
+
+-#ifdef NETIF_F_TSO
++ /* 82571 and newer doesn't need the workaround that limited descriptor
++ * length to 4kB */
++ if (hw->mac_type >= iegbe_82571)
++ max_per_txd = 8192;
++
+ mss = skb_shinfo(skb)->gso_size;
+ /* The controller does a simple calculation to
+ * make sure there is enough room in the FIFO before
+@@ -3064,164 +3058,150 @@ iegbe_xmit_frame(struct sk_buff *skb, st
+ * 4 = ceil(buffer len/mss). To make sure we don't
+ * overrun the FIFO, adjust the max buffer len if mss
+ * drops. */
+- if(mss) {
+- max_per_txd = min(mss << 0x2, max_per_txd);
+- max_txd_pwr = fls(max_per_txd) - 0x1;
++ if (mss) {
++ u8 hdr_len;
++ max_per_txd = min(mss << 2, max_per_txd);
++ max_txd_pwr = fls(max_per_txd) - 1;
++
++ /* TSO Workaround for 82571/2/3 Controllers -- if skb->data
++ * points to just header, pull a few bytes of payload from
++ * frags into skb->data */
++ hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
++ if (skb->data_len && hdr_len == len) {
++ switch (hw->mac_type) {
++ case iegbe_82544:
++ /* Make sure we have room to chop off 4 bytes,
++ * and that the end alignment will work out to
++ * this hardware's requirements
++ * NOTE: this is a TSO only workaround
++ * if end byte alignment not correct move us
++ * into the next dword */
++ break;
++ /* fall through */
++ case iegbe_82571:
++ case iegbe_82572:
++ case iegbe_82573:
++ break;
++ default:
++ /* do nothing */
++ break;
++ }
++ }
+ }
+
+- if((mss) || (skb->ip_summed == CHECKSUM_HW)) {
++ /* reserve a descriptor for the offload context */
++ if ((mss) || (skb->ip_summed == CHECKSUM_PARTIAL))
+ count++;
+- }
+ count++;
+-#else
+- if(skb->ip_summed == CHECKSUM_HW) {
++
++ /* Controller Erratum workaround */
++ if (!skb->data_len && tx_ring->last_tx_tso && !skb_is_gso(skb))
+ count++;
+- {
+-#endif
++
+ count += TXD_USE_COUNT(len, max_txd_pwr);
+
+- if(adapter->pcix_82544) {
++ if (adapter->pcix_82544)
+ count++;
+- }
++
+ /* work-around for errata 10 and it applies to all controllers
+ * in PCI-X mode, so add one more descriptor to the count
+ */
+- if(unlikely((adapter->hw.bus_type == iegbe_bus_type_pcix) &&
+- (len > 0x7df))) {
++ if (unlikely((hw->bus_type == iegbe_bus_type_pcix) &&
++ (len > 2015)))
+ count++;
+- }
+-#ifdef MAX_SKB_FRAGS
++
+ nr_frags = skb_shinfo(skb)->nr_frags;
+- for(f = 0; f < nr_frags; f++)
++ for (f = 0; f < nr_frags; f++)
+ count += TXD_USE_COUNT(skb_shinfo(skb)->frags[f].size,
+ max_txd_pwr);
+- if(adapter->pcix_82544) {
++ if (adapter->pcix_82544)
+ count += nr_frags;
+- }
+-#ifdef NETIF_F_TSO
+- /* TSO Workaround for 82571/2 Controllers -- if skb->data
+- * points to just header, pull a few bytes of payload from
+- * frags into skb->data */
+- if (skb_is_gso(skb)) {
+- uint8_t hdr_len;
+- hdr_len = ((skb->h.raw - skb->data) + (skb->h.th->doff << 0x2));
+- if (skb->data_len && (hdr_len < (skb->len - skb->data_len)) &&
+- (adapter->hw.mac_type == iegbe_82571 ||
+- adapter->hw.mac_type == iegbe_82572)) {
+- unsigned int pull_size;
+- pull_size = min((unsigned int)0x4, skb->data_len);
+- if (!__pskb_pull_tail(skb, pull_size)) {
+- printk(KERN_ERR "__pskb_pull_tail failed.\n");
+- dev_kfree_skb_any(skb);
+- return -EFAULT;
+- }
+- }
+- }
+-#endif
+-#endif
+
+- if(adapter->hw.tx_pkt_filtering && (adapter->hw.mac_type == iegbe_82573) ) {
++
++ if (hw->tx_pkt_filtering &&
++ (hw->mac_type == iegbe_82573))
+ iegbe_transfer_dhcp_info(adapter, skb);
+- }
+-#ifdef NETIF_F_LLTX
+- local_irq_save(flags);
+- if (!spin_trylock(&tx_ring->tx_lock)) {
++
++ if (!spin_trylock_irqsave(&tx_ring->tx_lock, flags))
+ /* Collision - tell upper layer to requeue */
+- local_irq_restore(flags);
+ return NETDEV_TX_LOCKED;
+- }
+-#else
+- spin_lock_irqsave(&tx_ring->tx_lock, flags);
+-#endif
+
+ /* need: count + 2 desc gap to keep tail from touching
+ * head, otherwise try next time */
+- if (unlikely(E1000_DESC_UNUSED(tx_ring) < count + 0x2)) {
+- netif_stop_queue(netdev);
++ if (unlikely(iegbe_maybe_stop_tx(netdev, tx_ring, count + 2))) {
+ spin_unlock_irqrestore(&tx_ring->tx_lock, flags);
+ return NETDEV_TX_BUSY;
+ }
+
+- if(unlikely(adapter->hw.mac_type == iegbe_82547)) {
+- if(unlikely(iegbe_82547_fifo_workaround(adapter, skb))) {
++ if (unlikely(hw->mac_type == iegbe_82547)) {
++ if (unlikely(iegbe_82547_fifo_workaround(adapter, skb))) {
+ netif_stop_queue(netdev);
+- mod_timer(&adapter->tx_fifo_stall_timer, jiffies);
++ mod_timer(&adapter->tx_fifo_stall_timer, jiffies + 1);
+ spin_unlock_irqrestore(&tx_ring->tx_lock, flags);
+ return NETDEV_TX_BUSY;
+ }
+ }
+
+-#ifndef NETIF_F_LLTX
+- spin_unlock_irqrestore(&tx_ring->tx_lock, flags);
+-#endif
+-
+-#ifdef NETIF_F_HW_VLAN_TX
+- if(unlikely(adapter->vlgrp && vlan_tx_tag_present(skb))) {
++ if (unlikely(adapter->vlgrp && vlan_tx_tag_present(skb))) {
+ tx_flags |= E1000_TX_FLAGS_VLAN;
+ tx_flags |= (vlan_tx_tag_get(skb) << E1000_TX_FLAGS_VLAN_SHIFT);
+ }
+-#endif
+
+ first = tx_ring->next_to_use;
+
+ tso = iegbe_tso(adapter, tx_ring, skb);
+ if (tso < 0) {
+ dev_kfree_skb_any(skb);
+-#ifdef NETIF_F_LLTX
+ spin_unlock_irqrestore(&tx_ring->tx_lock, flags);
+-#endif
+ return NETDEV_TX_OK;
+ }
+
+- if (likely(tso)) {
++ if (likely(tso)) {
++ tx_ring->last_tx_tso = 1;
+ tx_flags |= E1000_TX_FLAGS_TSO;
+- } else if (likely(iegbe_tx_csum(adapter, tx_ring, skb))) {
++ } else if (likely(iegbe_tx_csum(adapter, tx_ring, skb)))
+ tx_flags |= E1000_TX_FLAGS_CSUM;
+- }
++
+ /* Old method was to assume IPv4 packet by default if TSO was enabled.
+ * 82571 hardware supports TSO capabilities for IPv6 as well...
+ * no longer assume, we must. */
+- if (likely(skb->protocol == ntohs(ETH_P_IP))) {
++ if (likely(skb->protocol == htons(ETH_P_IP)))
+ tx_flags |= E1000_TX_FLAGS_IPV4;
+- }
++
+ iegbe_tx_queue(adapter, tx_ring, tx_flags,
+ iegbe_tx_map(adapter, tx_ring, skb, first,
+ max_per_txd, nr_frags, mss));
+
+ netdev->trans_start = jiffies;
+
+-#ifdef NETIF_F_LLTX
+ /* Make sure there is space in the ring for the next send. */
+- if (unlikely(E1000_DESC_UNUSED(tx_ring) < MAX_SKB_FRAGS + 0x2)) {
+- netif_stop_queue(netdev);
+- }
+- spin_unlock_irqrestore(&tx_ring->tx_lock, flags);
+-#endif
++ iegbe_maybe_stop_tx(netdev, tx_ring, MAX_SKB_FRAGS + 2);
+
++ spin_unlock_irqrestore(&tx_ring->tx_lock, flags);
+ return NETDEV_TX_OK;
+ }
+
++
+ /**
+ * iegbe_tx_timeout - Respond to a Tx Hang
+ * @netdev: network interface device structure
+ **/
+
+-static void
+-iegbe_tx_timeout(struct net_device *netdev)
++static void iegbe_tx_timeout(struct net_device *netdev)
+ {
+- struct iegbe_adapter *adapter = netdev_priv(netdev);
++ struct iegbe_adapter *adapter = netdev_priv(netdev);
+
+- /* Do the reset outside of interrupt context */
+- schedule_work(&adapter->tx_timeout_task);
++ /* Do the reset outside of interrupt context */
++ adapter->tx_timeout_count++;
++ schedule_work(&adapter->reset_task);
+ }
+
+-static void
+-iegbe_tx_timeout_task(struct net_device *netdev)
++static void iegbe_reset_task(struct work_struct *work)
+ {
+- struct iegbe_adapter *adapter = netdev_priv(netdev);
++ struct iegbe_adapter *adapter =
++ container_of(work, struct iegbe_adapter, reset_task);
+
+- iegbe_down(adapter);
+- iegbe_up(adapter);
++ iegbe_reinit_locked(adapter);
+ }
+
+ /**
+@@ -3232,13 +3212,12 @@ iegbe_tx_timeout_task(struct net_device
+ * The statistics are actually updated from the timer callback.
+ **/
+
+-static struct net_device_stats *
+-iegbe_get_stats(struct net_device *netdev)
++static struct net_device_stats *iegbe_get_stats(struct net_device *netdev)
+ {
+- struct iegbe_adapter *adapter = netdev_priv(netdev);
++ struct iegbe_adapter *adapter = netdev_priv(netdev);
+
+- iegbe_update_stats(adapter);
+- return &adapter->net_stats;
++ /* only return the current stats */
++ return &adapter->net_stats;
+ }
+
+ /**
+@@ -3249,67 +3228,55 @@ iegbe_get_stats(struct net_device *netde
+ * Returns 0 on success, negative on failure
+ **/
+
+-static int
+-iegbe_change_mtu(struct net_device *netdev, int new_mtu)
++static int iegbe_change_mtu(struct net_device *netdev, int new_mtu)
+ {
+- struct iegbe_adapter *adapter = netdev_priv(netdev);
+- int max_frame = new_mtu + ENET_HEADER_SIZE + ETHERNET_FCS_SIZE;
++ struct iegbe_adapter *adapter = netdev_priv(netdev);
++ struct iegbe_hw *hw = &adapter->hw;
++ int max_frame = new_mtu + ENET_HEADER_SIZE + ETHERNET_FCS_SIZE;
+
+- if((max_frame < MINIMUM_ETHERNET_FRAME_SIZE) ||
+- (max_frame > MAX_JUMBO_FRAME_SIZE)) {
+- DPRINTK(PROBE, ERR, "Invalid MTU setting\n");
+- return -EINVAL;
+- }
++ if((max_frame < MINIMUM_ETHERNET_FRAME_SIZE) ||
++ (max_frame > MAX_JUMBO_FRAME_SIZE)) {
++ DPRINTK(PROBE, ERR, "Invalid MTU setting\n");
++ return -EINVAL;
++ }
+
++ /* Adapter-specific max frame size limits. */
++ switch (hw->mac_type) {
++ case iegbe_undefined ... iegbe_82542_rev2_1:
++ if (max_frame > MAXIMUM_ETHERNET_FRAME_SIZE) {
++ DPRINTK(PROBE, ERR, "Jumbo Frames not supported.\n");
++ return -EINVAL;
++ }
++ break;
++ case iegbe_82571:
++ case iegbe_82572:
+ #define MAX_STD_JUMBO_FRAME_SIZE 9234
+- /* might want this to be bigger enum check... */
+- /* 82571 controllers limit jumbo frame size to 10500 bytes */
+- if ((adapter->hw.mac_type == iegbe_82571 ||
+- adapter->hw.mac_type == iegbe_82572) &&
+- max_frame > MAX_STD_JUMBO_FRAME_SIZE) {
+- DPRINTK(PROBE, ERR, "MTU > 9216 bytes not supported "
+- "on 82571 and 82572 controllers.\n");
+- return -EINVAL;
+- }
+-
+- if(adapter->hw.mac_type == iegbe_82573 &&
+- max_frame > MAXIMUM_ETHERNET_FRAME_SIZE) {
+- DPRINTK(PROBE, ERR, "Jumbo Frames not supported "
+- "on 82573\n");
+- return -EINVAL;
+- }
+-
+- if(adapter->hw.mac_type > iegbe_82547_rev_2) {
+- adapter->rx_buffer_len = max_frame;
+- E1000_ROUNDUP(adapter->rx_buffer_len, 0x1024);
+- } else {
+- if(unlikely((adapter->hw.mac_type < iegbe_82543) &&
+- (max_frame > MAXIMUM_ETHERNET_FRAME_SIZE))) {
+- DPRINTK(PROBE, ERR, "Jumbo Frames not supported "
+- "on 82542\n");
+- return -EINVAL;
+-
+- } else {
+- if(max_frame <= E1000_RXBUFFER_2048) {
+- adapter->rx_buffer_len = E1000_RXBUFFER_2048;
+- } else if(max_frame <= E1000_RXBUFFER_4096) {
+- adapter->rx_buffer_len = E1000_RXBUFFER_4096;
+- } else if(max_frame <= E1000_RXBUFFER_8192) {
+- adapter->rx_buffer_len = E1000_RXBUFFER_8192;
+- } else if(max_frame <= E1000_RXBUFFER_16384) {
+- adapter->rx_buffer_len = E1000_RXBUFFER_16384;
+- }
++ if (max_frame > MAX_STD_JUMBO_FRAME_SIZE) {
++ DPRINTK(PROBE, ERR, "MTU > 9216 not supported.\n");
++ return -EINVAL;
+ }
++ break;
++ default:
++ break;
+ }
++ if (max_frame <= E1000_RXBUFFER_256)
++ adapter->rx_buffer_len = E1000_RXBUFFER_256;
++ else if (max_frame <= E1000_RXBUFFER_2048)
++ adapter->rx_buffer_len = E1000_RXBUFFER_2048;
++ else if (max_frame <= E1000_RXBUFFER_4096)
++ adapter->rx_buffer_len = E1000_RXBUFFER_4096;
++ else if (max_frame <= E1000_RXBUFFER_8192)
++ adapter->rx_buffer_len = E1000_RXBUFFER_8192;
++ else if (max_frame <= E1000_RXBUFFER_16384)
++ adapter->rx_buffer_len = E1000_RXBUFFER_16384;
+
+- netdev->mtu = new_mtu;
++ /* adjust allocation if LPE protects us, and we aren't using SBP */
+
+- if(netif_running(netdev)) {
+- iegbe_down(adapter);
+- iegbe_up(adapter);
+- }
++ netdev->mtu = new_mtu;
++ hw->max_frame_size = max_frame;
+
+- adapter->hw.max_frame_size = max_frame;
++ if (netif_running(netdev))
++ iegbe_reinit_locked(adapter);
+
+ return 0;
+ }
+@@ -3319,224 +3286,189 @@ iegbe_change_mtu(struct net_device *netd
+ * @adapter: board private structure
+ **/
+
+-void
+-iegbe_update_stats(struct iegbe_adapter *adapter)
++void iegbe_update_stats(struct iegbe_adapter *adapter)
+ {
+- struct iegbe_hw *hw = &adapter->hw;
+- unsigned long flags = 0;
+- uint16_t phy_tmp;
++ struct iegbe_hw *hw = &adapter->hw;
++ unsigned long flags = 0x0;
++ uint16_t phy_tmp;
+
+ #define PHY_IDLE_ERROR_COUNT_MASK 0x00FF
+
+- spin_lock_irqsave(&adapter->stats_lock, flags);
++ spin_lock_irqsave(&adapter->stats_lock, flags);
+
+- /* these counters are modified from iegbe_adjust_tbi_stats,
+- * called from the interrupt context, so they must only
+- * be written while holding adapter->stats_lock
+- */
++ /* these counters are modified from iegbe_adjust_tbi_stats,
++ * called from the interrupt context, so they must only
++ * be written while holding adapter->stats_lock
++ */
+
+- adapter->stats.crcerrs += E1000_READ_REG(hw, CRCERRS);
+- adapter->stats.gprc += E1000_READ_REG(hw, GPRC);
+- adapter->stats.gorcl += E1000_READ_REG(hw, GORCL);
+- adapter->stats.gorch += E1000_READ_REG(hw, GORCH);
+- adapter->stats.bprc += E1000_READ_REG(hw, BPRC);
+- adapter->stats.mprc += E1000_READ_REG(hw, MPRC);
+- adapter->stats.roc += E1000_READ_REG(hw, ROC);
+- adapter->stats.prc64 += E1000_READ_REG(hw, PRC64);
+- adapter->stats.prc127 += E1000_READ_REG(hw, PRC127);
+- adapter->stats.prc255 += E1000_READ_REG(hw, PRC255);
+- adapter->stats.prc511 += E1000_READ_REG(hw, PRC511);
+- adapter->stats.prc1023 += E1000_READ_REG(hw, PRC1023);
+- adapter->stats.prc1522 += E1000_READ_REG(hw, PRC1522);
+-
+- adapter->stats.symerrs += E1000_READ_REG(hw, SYMERRS);
+- adapter->stats.mpc += E1000_READ_REG(hw, MPC);
+- adapter->stats.scc += E1000_READ_REG(hw, SCC);
+- adapter->stats.ecol += E1000_READ_REG(hw, ECOL);
+- adapter->stats.mcc += E1000_READ_REG(hw, MCC);
+- adapter->stats.latecol += E1000_READ_REG(hw, LATECOL);
+- adapter->stats.dc += E1000_READ_REG(hw, DC);
+- adapter->stats.sec += E1000_READ_REG(hw, SEC);
+- adapter->stats.rlec += E1000_READ_REG(hw, RLEC);
+- adapter->stats.xonrxc += E1000_READ_REG(hw, XONRXC);
+- adapter->stats.xontxc += E1000_READ_REG(hw, XONTXC);
+- adapter->stats.xoffrxc += E1000_READ_REG(hw, XOFFRXC);
+- adapter->stats.xofftxc += E1000_READ_REG(hw, XOFFTXC);
+- adapter->stats.fcruc += E1000_READ_REG(hw, FCRUC);
+- adapter->stats.gptc += E1000_READ_REG(hw, GPTC);
+- adapter->stats.gotcl += E1000_READ_REG(hw, GOTCL);
+- adapter->stats.gotch += E1000_READ_REG(hw, GOTCH);
+- adapter->stats.rnbc += E1000_READ_REG(hw, RNBC);
+- adapter->stats.ruc += E1000_READ_REG(hw, RUC);
+- adapter->stats.rfc += E1000_READ_REG(hw, RFC);
+- adapter->stats.rjc += E1000_READ_REG(hw, RJC);
+- adapter->stats.torl += E1000_READ_REG(hw, TORL);
+- adapter->stats.torh += E1000_READ_REG(hw, TORH);
+- adapter->stats.totl += E1000_READ_REG(hw, TOTL);
+- adapter->stats.toth += E1000_READ_REG(hw, TOTH);
+- adapter->stats.tpr += E1000_READ_REG(hw, TPR);
+- adapter->stats.ptc64 += E1000_READ_REG(hw, PTC64);
+- adapter->stats.ptc127 += E1000_READ_REG(hw, PTC127);
+- adapter->stats.ptc255 += E1000_READ_REG(hw, PTC255);
+- adapter->stats.ptc511 += E1000_READ_REG(hw, PTC511);
+- adapter->stats.ptc1023 += E1000_READ_REG(hw, PTC1023);
+- adapter->stats.ptc1522 += E1000_READ_REG(hw, PTC1522);
+- adapter->stats.mptc += E1000_READ_REG(hw, MPTC);
+- adapter->stats.bptc += E1000_READ_REG(hw, BPTC);
+-
+- /* used for adaptive IFS */
+-
+- hw->tx_packet_delta = E1000_READ_REG(hw, TPT);
+- adapter->stats.tpt += hw->tx_packet_delta;
+- hw->collision_delta = E1000_READ_REG(hw, COLC);
+- adapter->stats.colc += hw->collision_delta;
+-
+- if(hw->mac_type >= iegbe_82543) {
+- adapter->stats.algnerrc += E1000_READ_REG(hw, ALGNERRC);
+- adapter->stats.rxerrc += E1000_READ_REG(hw, RXERRC);
+- adapter->stats.tncrs += E1000_READ_REG(hw, TNCRS);
+- adapter->stats.cexterr += E1000_READ_REG(hw, CEXTERR);
+- adapter->stats.tsctc += E1000_READ_REG(hw, TSCTC);
+- adapter->stats.tsctfc += E1000_READ_REG(hw, TSCTFC);
+- }
+- if(hw->mac_type > iegbe_82547_rev_2) {
+- adapter->stats.iac += E1000_READ_REG(hw, IAC);
+- adapter->stats.icrxoc += E1000_READ_REG(hw, ICRXOC);
+- adapter->stats.icrxptc += E1000_READ_REG(hw, ICRXPTC);
+- adapter->stats.icrxatc += E1000_READ_REG(hw, ICRXATC);
+- adapter->stats.ictxptc += E1000_READ_REG(hw, ICTXPTC);
+- adapter->stats.ictxatc += E1000_READ_REG(hw, ICTXATC);
+- adapter->stats.ictxqec += E1000_READ_REG(hw, ICTXQEC);
+- adapter->stats.ictxqmtc += E1000_READ_REG(hw, ICTXQMTC);
+- adapter->stats.icrxdmtc += E1000_READ_REG(hw, ICRXDMTC);
+- }
+-
+- /* Fill out the OS statistics structure */
+-
+- adapter->net_stats.rx_packets = adapter->stats.gprc;
+- adapter->net_stats.tx_packets = adapter->stats.gptc;
+- adapter->net_stats.rx_bytes = adapter->stats.gorcl;
+- adapter->net_stats.tx_bytes = adapter->stats.gotcl;
+- adapter->net_stats.multicast = adapter->stats.mprc;
+- adapter->net_stats.collisions = adapter->stats.colc;
+-
+- /* Rx Errors */
+-
+- adapter->net_stats.rx_errors = adapter->stats.rxerrc +
+- adapter->stats.crcerrs + adapter->stats.algnerrc +
+- adapter->stats.rlec + adapter->stats.mpc +
+- adapter->stats.cexterr;
+- adapter->net_stats.rx_dropped = adapter->stats.mpc;
+- adapter->net_stats.rx_length_errors = adapter->stats.rlec;
+- adapter->net_stats.rx_crc_errors = adapter->stats.crcerrs;
+- adapter->net_stats.rx_frame_errors = adapter->stats.algnerrc;
+- adapter->net_stats.rx_fifo_errors = adapter->stats.mpc;
+- adapter->net_stats.rx_missed_errors = adapter->stats.mpc;
+-
+- /* Tx Errors */
+-
+- adapter->net_stats.tx_errors = adapter->stats.ecol +
+- adapter->stats.latecol;
+- adapter->net_stats.tx_aborted_errors = adapter->stats.ecol;
+- adapter->net_stats.tx_window_errors = adapter->stats.latecol;
+- adapter->net_stats.tx_carrier_errors = adapter->stats.tncrs;
++ adapter->stats.crcerrs += E1000_READ_REG(hw, CRCERRS);
++ adapter->stats.gprc += E1000_READ_REG(hw, GPRC);
++ adapter->stats.gorcl += E1000_READ_REG(hw, GORCL);
++ adapter->stats.gorch += E1000_READ_REG(hw, GORCH);
++ adapter->stats.bprc += E1000_READ_REG(hw, BPRC);
++ adapter->stats.mprc += E1000_READ_REG(hw, MPRC);
++ adapter->stats.roc += E1000_READ_REG(hw, ROC);
++ adapter->stats.prc64 += E1000_READ_REG(hw, PRC64);
++ adapter->stats.prc127 += E1000_READ_REG(hw, PRC127);
++ adapter->stats.prc255 += E1000_READ_REG(hw, PRC255);
++ adapter->stats.prc511 += E1000_READ_REG(hw, PRC511);
++ adapter->stats.prc1023 += E1000_READ_REG(hw, PRC1023);
++ adapter->stats.prc1522 += E1000_READ_REG(hw, PRC1522);
++
++ adapter->stats.symerrs += E1000_READ_REG(hw, SYMERRS);
++ adapter->stats.mpc += E1000_READ_REG(hw, MPC);
++ adapter->stats.scc += E1000_READ_REG(hw, SCC);
++ adapter->stats.ecol += E1000_READ_REG(hw, ECOL);
++ adapter->stats.mcc += E1000_READ_REG(hw, MCC);
++ adapter->stats.latecol += E1000_READ_REG(hw, LATECOL);
++ adapter->stats.dc += E1000_READ_REG(hw, DC);
++ adapter->stats.sec += E1000_READ_REG(hw, SEC);
++ adapter->stats.rlec += E1000_READ_REG(hw, RLEC);
++ adapter->stats.xonrxc += E1000_READ_REG(hw, XONRXC);
++ adapter->stats.xontxc += E1000_READ_REG(hw, XONTXC);
++ adapter->stats.xoffrxc += E1000_READ_REG(hw, XOFFRXC);
++ adapter->stats.xofftxc += E1000_READ_REG(hw, XOFFTXC);
++ adapter->stats.fcruc += E1000_READ_REG(hw, FCRUC);
++ adapter->stats.gptc += E1000_READ_REG(hw, GPTC);
++ adapter->stats.gotcl += E1000_READ_REG(hw, GOTCL);
++ adapter->stats.gotch += E1000_READ_REG(hw, GOTCH);
++ adapter->stats.rnbc += E1000_READ_REG(hw, RNBC);
++ adapter->stats.ruc += E1000_READ_REG(hw, RUC);
++ adapter->stats.rfc += E1000_READ_REG(hw, RFC);
++ adapter->stats.rjc += E1000_READ_REG(hw, RJC);
++ adapter->stats.torl += E1000_READ_REG(hw, TORL);
++ adapter->stats.torh += E1000_READ_REG(hw, TORH);
++ adapter->stats.totl += E1000_READ_REG(hw, TOTL);
++ adapter->stats.toth += E1000_READ_REG(hw, TOTH);
++ adapter->stats.tpr += E1000_READ_REG(hw, TPR);
++ adapter->stats.ptc64 += E1000_READ_REG(hw, PTC64);
++ adapter->stats.ptc127 += E1000_READ_REG(hw, PTC127);
++ adapter->stats.ptc255 += E1000_READ_REG(hw, PTC255);
++ adapter->stats.ptc511 += E1000_READ_REG(hw, PTC511);
++ adapter->stats.ptc1023 += E1000_READ_REG(hw, PTC1023);
++ adapter->stats.ptc1522 += E1000_READ_REG(hw, PTC1522);
++ adapter->stats.mptc += E1000_READ_REG(hw, MPTC);
++ adapter->stats.bptc += E1000_READ_REG(hw, BPTC);
++
++ /* used for adaptive IFS */
++
++ hw->tx_packet_delta = E1000_READ_REG(hw, TPT);
++ adapter->stats.tpt += hw->tx_packet_delta;
++ hw->collision_delta = E1000_READ_REG(hw, COLC);
++ adapter->stats.colc += hw->collision_delta;
++
++ if(hw->mac_type >= iegbe_82543) {
++ adapter->stats.algnerrc += E1000_READ_REG(hw, ALGNERRC);
++ adapter->stats.rxerrc += E1000_READ_REG(hw, RXERRC);
++ adapter->stats.tncrs += E1000_READ_REG(hw, TNCRS);
++ adapter->stats.cexterr += E1000_READ_REG(hw, CEXTERR);
++ adapter->stats.tsctc += E1000_READ_REG(hw, TSCTC);
++ adapter->stats.tsctfc += E1000_READ_REG(hw, TSCTFC);
++ }
++ if(hw->mac_type > iegbe_82547_rev_2) {
++ adapter->stats.iac += E1000_READ_REG(hw, IAC);
++ adapter->stats.icrxoc += E1000_READ_REG(hw, ICRXOC);
++ adapter->stats.icrxptc += E1000_READ_REG(hw, ICRXPTC);
++ adapter->stats.icrxatc += E1000_READ_REG(hw, ICRXATC);
++ adapter->stats.ictxptc += E1000_READ_REG(hw, ICTXPTC);
++ adapter->stats.ictxatc += E1000_READ_REG(hw, ICTXATC);
++ adapter->stats.ictxqec += E1000_READ_REG(hw, ICTXQEC);
++ adapter->stats.ictxqmtc += E1000_READ_REG(hw, ICTXQMTC);
++ adapter->stats.icrxdmtc += E1000_READ_REG(hw, ICRXDMTC);
++ }
++
++ /* Fill out the OS statistics structure */
++
++ adapter->net_stats.rx_packets = adapter->stats.gprc;
++ adapter->net_stats.tx_packets = adapter->stats.gptc;
++ adapter->net_stats.rx_bytes = adapter->stats.gorcl;
++ adapter->net_stats.tx_bytes = adapter->stats.gotcl;
++ adapter->net_stats.multicast = adapter->stats.mprc;
++ adapter->net_stats.collisions = adapter->stats.colc;
++
++ /* Rx Errors */
++
++ adapter->net_stats.rx_errors = adapter->stats.rxerrc +
++ adapter->stats.crcerrs + adapter->stats.algnerrc +
++ adapter->stats.rlec + adapter->stats.mpc +
++ adapter->stats.cexterr;
++ adapter->net_stats.rx_dropped = adapter->stats.mpc;
++ adapter->net_stats.rx_length_errors = adapter->stats.rlec;
++ adapter->net_stats.rx_crc_errors = adapter->stats.crcerrs;
++ adapter->net_stats.rx_frame_errors = adapter->stats.algnerrc;
++ adapter->net_stats.rx_fifo_errors = adapter->stats.mpc;
++ adapter->net_stats.rx_missed_errors = adapter->stats.mpc;
++
++ /* Tx Errors */
++
++ adapter->net_stats.tx_errors = adapter->stats.ecol +
++ adapter->stats.latecol;
++ adapter->net_stats.tx_aborted_errors = adapter->stats.ecol;
++ adapter->net_stats.tx_window_errors = adapter->stats.latecol;
++ adapter->net_stats.tx_carrier_errors = adapter->stats.tncrs;
+
+- /* Tx Dropped needs to be maintained elsewhere */
++ /* Tx Dropped needs to be maintained elsewhere */
+
+- /* Phy Stats */
++ /* Phy Stats */
+
+- if(hw->media_type == iegbe_media_type_copper
++ if(hw->media_type == iegbe_media_type_copper
+ || (hw->media_type == iegbe_media_type_oem
+ && iegbe_oem_phy_is_copper(&adapter->hw))) {
+- if((adapter->link_speed == SPEED_1000) &&
+- (!iegbe_read_phy_reg(hw, PHY_1000T_STATUS, &phy_tmp))) {
+- phy_tmp &= PHY_IDLE_ERROR_COUNT_MASK;
+- adapter->phy_stats.idle_errors += phy_tmp;
+- }
++ if((adapter->link_speed == SPEED_1000) &&
++ (!iegbe_read_phy_reg(hw, PHY_1000T_STATUS, &phy_tmp))) {
++ phy_tmp &= PHY_IDLE_ERROR_COUNT_MASK;
++ adapter->phy_stats.idle_errors += phy_tmp;
++ }
+
+- if((hw->mac_type <= iegbe_82546) &&
+- (hw->phy_type == iegbe_phy_m88) &&
++ if((hw->mac_type <= iegbe_82546) &&
++ (hw->phy_type == iegbe_phy_m88) &&
+ !iegbe_read_phy_reg(hw, M88E1000_RX_ERR_CNTR, &phy_tmp)) {
+- adapter->phy_stats.receive_errors += phy_tmp;
+- }
++ adapter->phy_stats.receive_errors += phy_tmp;
++ }
+ }
+
+- spin_unlock_irqrestore(&adapter->stats_lock, flags);
++ spin_unlock_irqrestore(&adapter->stats_lock, flags);
+ }
+
+-#ifdef CONFIG_E1000_MQ
+-void
+-iegbe_rx_schedule(void *data)
++/**
++ * iegbe_intr_msi - Interrupt Handler
++ * @irq: interrupt number
++ * @data: pointer to a network interface device structure
++ **/
++
++static irqreturn_t iegbe_intr_msi(int irq, void *data)
+ {
+- struct net_device *poll_dev, *netdev = data;
+- struct iegbe_adapter *adapter = netdev->priv;
+- int this_cpu = get_cpu();
+-
+- poll_dev = *per_cpu_ptr(adapter->cpu_netdev, this_cpu);
+- if (poll_dev == NULL) {
+- put_cpu();
+- return;
++ struct net_device *netdev = data;
++ struct iegbe_adapter *adapter = netdev_priv(netdev);
++ struct iegbe_hw *hw = &adapter->hw;
++ u32 icr = E1000_READ_REG(&adapter->hw, ICR);
++ if (icr & (E1000_ICR_RXSEQ | E1000_ICR_LSC)) {
++ hw->get_link_status = 1;
++ if (!test_bit(__E1000_DOWN, &adapter->flags))
++ mod_timer(&adapter->watchdog_timer, jiffies + 1);
+ }
+
+- if (likely(netif_rx_schedule_prep(poll_dev))) {
+- __netif_rx_schedule(poll_dev);
+- } else {
+- iegbe_irq_enable(adapter);
+- }
+- put_cpu();
+-}
+-#endif
+-
+-#ifdef IEGBE_GBE_WORKAROUND
+-/*
+- * Check for tx hang condition. This is the condition where a
+- * decsriptor is in the hardware and hasn't been processed for a
+- * while. This code is similar to the check in iegbe_clean_rx_irq()
+- */
+-static void
+-iegbe_tx_hang_check(struct iegbe_adapter *adapter,
+- struct iegbe_tx_ring *tx_ring)
+-{
+- struct net_device *netdev = adapter->netdev;
+- unsigned int i;
++ if(unlikely(icr & (E1000_ICR_RX_DESC_FIFO_PAR
++ | E1000_ICR_TX_DESC_FIFO_PAR
++ | E1000_ICR_PB
++ | E1000_ICR_CPP_TARGET
++ | E1000_ICR_CPP_MASTER ))) {
+
+- /* Check for a hang condition using the buffer currently at the Tx
+- head pointer */
+- i = readl(adapter->hw.hw_addr + tx_ring->tdh);
+-
+- if (adapter->detect_tx_hung) {
+- /* Detect a transmit hang in hardware, this serializes the
+- * check with the clearing of time_stamp and movement of i */
+- adapter->detect_tx_hung = FALSE;
+-
+- if (tx_ring->buffer_info[i].dma &&
+- time_after(jiffies, tx_ring->buffer_info[i].time_stamp + HZ)
+- && !(E1000_READ_REG(&adapter->hw, STATUS) &
+- E1000_STATUS_TXOFF)) {
+-
+- /* detected Tx unit hang */
+- DPRINTK(DRV, ERR, "Detected Tx Unit Hang\n"
+- " TDH <%x>\n"
+- " TDT <%x>\n"
+- " next_to_use <%x>\n"
+- " next_to_clean <%x>\n"
+- "buffer_info[tdh]\n"
+- " dma <%zx>\n"
+- " time_stamp <%lx>\n"
+- " jiffies <%lx>\n",
+- readl(adapter->hw.hw_addr + tx_ring->tdh),
+- readl(adapter->hw.hw_addr + tx_ring->tdt),
+- tx_ring->next_to_use,
+- tx_ring->next_to_clean,
+- (size_t)tx_ring->buffer_info[i].dma,
+- tx_ring->buffer_info[i].time_stamp,
+- jiffies);
+- netif_stop_queue(netdev);
+- }
++ iegbe_irq_disable(adapter);
++ printk("Critical error! ICR = 0x%x\n", icr);
++ return IRQ_HANDLED;
+ }
+-}
++ if (likely(netif_rx_schedule_prep(netdev, &adapter->napi))) {
++ adapter->total_tx_bytes = 0;
++ adapter->total_tx_packets = 0;
++ adapter->total_rx_bytes = 0;
++ adapter->total_rx_packets = 0;
++ __netif_rx_schedule(netdev, &adapter->napi);
++ } else
++ iegbe_irq_enable(adapter);
+
+-#endif
++ return IRQ_HANDLED;
++}
+
+ /**
+ * iegbe_intr - Interrupt Handler
+@@ -3546,364 +3478,208 @@ iegbe_tx_hang_check(struct iegbe_adapter
+ **/
+
+ static irqreturn_t
+-iegbe_intr(int irq, void *data, struct pt_regs *regs)
++iegbe_intr(int irq, void *data)
+ {
+- struct net_device *netdev = data;
+- struct iegbe_adapter *adapter = netdev_priv(netdev);
+- struct iegbe_hw *hw = &adapter->hw;
+- uint32_t rctl, tctl;
+- uint32_t icr = E1000_READ_REG(hw, ICR);
+-#ifndef CONFIG_E1000_NAPI
+- uint32_t i;
+-#ifdef IEGBE_GBE_WORKAROUND
+- int rx_cleaned;
+-#endif
+-#endif
++ struct net_device *netdev = data;
++ struct iegbe_adapter *adapter = netdev_priv(netdev);
++ struct iegbe_hw *hw = &adapter->hw;
++ u32 icr = E1000_READ_REG(&adapter->hw, ICR);
+
+- if(unlikely(!icr)) {
++ if (unlikely(!icr))
+ return IRQ_NONE; /* Not our interrupt */
+- }
++
++ /* IMS will not auto-mask if INT_ASSERTED is not set, and if it is
++ * not set, then the adapter didn't send an interrupt */
++ if (unlikely(hw->mac_type >= iegbe_82571 &&
++ !(icr & E1000_ICR_INT_ASSERTED)))
++ return IRQ_NONE;
++
++
+ if(unlikely(icr & (E1000_ICR_RX_DESC_FIFO_PAR
+- | E1000_ICR_TX_DESC_FIFO_PAR
+- | E1000_ICR_PB
+- | E1000_ICR_CPP_TARGET
+- | E1000_ICR_CPP_MASTER ))) {
++ | E1000_ICR_TX_DESC_FIFO_PAR
++ | E1000_ICR_PB
++ | E1000_ICR_CPP_TARGET
++ | E1000_ICR_CPP_MASTER ))) {
+
+ iegbe_irq_disable(adapter);
+- tctl = E1000_READ_REG(&adapter->hw, TCTL);
+- rctl = E1000_READ_REG(&adapter->hw, RCTL);
+- E1000_WRITE_REG(&adapter->hw, RCTL, rctl & ~E1000_TCTL_EN);
+- E1000_WRITE_REG(&adapter->hw, RCTL, rctl & ~E1000_RCTL_EN);
+-
+- tasklet_data = (unsigned long) (icr + adapter->bd_number);
+- tasklet_schedule(&iegbe_reset_tasklet);
+-
+- return IRQ_HANDLED;
+- }
+-
+-#ifdef CONFIG_E1000_NAPI
+- atomic_inc(&adapter->irq_sem);
+-#ifdef IEGBE_GBE_WORKAROUND
+- /* Ensure that the TXQE interrupt is enabled in NAPI mode */
+- E1000_WRITE_REG(hw, IMC, ~E1000_IMS_TXQE);
+-#else
+- E1000_WRITE_REG(hw, IMC, ~0);
+-#endif
+- E1000_WRITE_FLUSH(hw);
+-#ifdef CONFIG_E1000_MQ
+- if (atomic_read(&adapter->rx_sched_call_data.count) == 0) {
+- cpu_set(adapter->cpu_for_queue[0],
+- adapter->rx_sched_call_data.cpumask);
+- for (i = 1; i < adapter->num_queues; i++) {
+- cpu_set(adapter->cpu_for_queue[i],
+- adapter->rx_sched_call_data.cpumask);
+- atomic_inc(&adapter->irq_sem);
+- }
+- atomic_set(&adapter->rx_sched_call_data.count, i);
+- smp_call_async_mask(&adapter->rx_sched_call_data);
+- } else {
+- DEBUGOUT("call_data.count == %u\n",
+- atomic_read(&adapter->rx_sched_call_data.count));
++ printk("Critical error! ICR = 0x%x\n", icr);
++ return IRQ_HANDLED;
+ }
+-#else
+- if (likely(netif_rx_schedule_prep(&adapter->polling_netdev[0]))) {
+- __netif_rx_schedule(&adapter->polling_netdev[0]);
+- } else {
+- iegbe_irq_enable(adapter);
+- }
+-#endif
+-
+-#ifdef IEGBE_GBE_WORKAROUND
+- /* Clean the Tx ring */
+- for (i = 0; i < E1000_MAX_INTR; i++) {
+- adapter->stats.rx_next_to_clean = adapter->rx_ring->next_to_clean;
+- adapter->stats.rx_next_to_use = adapter->rx_ring->next_to_use;
+-
+- adapter->stats.tx_next_to_clean = adapter->tx_ring->next_to_clean;
+- adapter->stats.tx_next_to_use = adapter->tx_ring->next_to_use;
+-
+- /* Only clean Tx descriptors for a TXQE interrupt */
+- if(icr & E1000_ICR_TXQE) {
+- adapter->stats.txqec++;
+- iegbe_clean_tx_ring_partial(adapter, adapter->tx_ring);
+- }
+- else {
+- iegbe_tx_hang_check(adapter, adapter->tx_ring);
+- }
+- }
+
+-#endif /*IEGBE_GBE_WORKAROUND */
+-
+-#else
+- /* Writing IMC and IMS is needed for 82547.
+- * Due to Hub Link bus being occupied, an interrupt
+- * de-assertion message is not able to be sent.
+- * When an interrupt assertion message is generated later,
+- * two messages are re-ordered and sent out.
+- * That causes APIC to think 82547 is in de-assertion
+- * state, while 82547 is in assertion state, resulting
+- * in dead lock. Writing IMC forces 82547 into
+- * de-assertion state.
+- */
+- if (hw->mac_type == iegbe_82547 || hw->mac_type == iegbe_82547_rev_2) {
+- atomic_inc(&adapter->irq_sem);
+- E1000_WRITE_REG(hw, IMC, ~0);
+- }
+-
+-#ifdef IEGBE_GBE_WORKAROUND
+-
+- for (i = 0; i < E1000_MAX_INTR; i++) {
+- rx_cleaned = adapter->clean_rx(adapter, adapter->rx_ring);
+- adapter->stats.rx_next_to_clean = adapter->rx_ring->next_to_clean;
+- adapter->stats.rx_next_to_use = adapter->rx_ring->next_to_use;
+-
+- adapter->stats.tx_next_to_clean = adapter->tx_ring->next_to_clean;
+- adapter->stats.tx_next_to_use = adapter->tx_ring->next_to_use;
+-
+- /* Only clean Tx descriptors for a TXQE interrupt */
+- if(icr & E1000_ICR_TXQE) {
+- adapter->stats.txqec++;
+- iegbe_clean_tx_ring_partial(adapter, adapter->tx_ring);
+- }
+- else {
+- iegbe_tx_hang_check(adapter, adapter->tx_ring);
+- }
+- if(!rx_cleaned) {
+- break;
+- }
++ /* Interrupt Auto-Mask...upon reading ICR, interrupts are masked. No
++ * need for the IMC write */
++ if (unlikely(icr & (E1000_ICR_RXSEQ | E1000_ICR_LSC))) {
++ hw->get_link_status = 1;
++ /* guard against interrupt when we're going down */
++ if (!test_bit(__E1000_DOWN, &adapter->flags))
++ mod_timer(&adapter->watchdog_timer, jiffies + 1);
++
+ }
+
+-#else
+- for (i = 0; i < E1000_MAX_INTR; i++)
+- if(unlikely(!adapter->clean_rx(adapter, adapter->rx_ring) &
+- !iegbe_clean_tx_irq(adapter, adapter->tx_ring))) {
+- break;
+- }
+-#endif
+-
+- if (hw->mac_type == iegbe_82547 || hw->mac_type == iegbe_82547_rev_2) {
+- iegbe_irq_enable(adapter);
+- }
+-#endif
+-#ifdef E1000_COUNT_ICR
+- adapter->icr_txdw += icr & 0x01UL;
+- icr >>= 0x1;
+- adapter->icr_txqe += icr & 0x01UL;
+- icr >>= 0x1;
+- adapter->icr_lsc += icr & 0x01UL;
+- icr >>= 0x1;
+- adapter->icr_rxseq += icr & 0x01UL;
+- icr >>= 0x1;
+- adapter->icr_rxdmt += icr & 0x01UL;
+- icr >>= 0x1;
+- adapter->icr_rxo += icr & 0x01UL;
+- icr >>= 0x1;
+- adapter->icr_rxt += icr & 0x01UL;
+- if(hw->mac_type != iegbe_icp_xxxx) {
+- icr >>= 0x2;
+- adapter->icr_mdac += icr & 0x01UL;
+- icr >>= 0x1;
+- adapter->icr_rxcfg += icr & 0x01UL;
+- icr >>= 0x1;
+- adapter->icr_gpi += icr & 0x01UL;
+- } else {
+- icr >>= 0x4;
+- }
+- if(hw->mac_type == iegbe_icp_xxxx) {
+- icr >>= 0xc;
+- adapter->icr_pb += icr & 0x01UL;
+- icr >>= 0x3;
+- adapter->icr_intmem_icp_xxxx += icr & 0x01UL;
+- icr >>= 0x1;
+- adapter->icr_cpp_target += icr & 0x01UL;
+- icr >>= 0x1;
+- adapter->icr_cpp_master += icr & 0x01UL;
+- icr >>= 0x1;
+- adapter->icr_stat += icr & 0x01UL;
++ if (unlikely(hw->mac_type < iegbe_82571)) {
++ E1000_WRITE_REG(&adapter->hw, IMC, ~0);
++ E1000_WRITE_FLUSH(&adapter->hw);
+ }
+-#endif
++ if (likely(netif_rx_schedule_prep(netdev, &adapter->napi))) {
++ adapter->total_tx_bytes = 0;
++ adapter->total_tx_packets = 0;
++ adapter->total_rx_bytes = 0;
++ adapter->total_rx_packets = 0;
++ __netif_rx_schedule(netdev, &adapter->napi);
++ } else
++ /* this really should not happen! if it does it is basically a
++ * bug, but not a hard error, so enable ints and continue */
++ iegbe_irq_enable(adapter);
+
+ return IRQ_HANDLED;
+ }
+
+-#ifdef CONFIG_E1000_NAPI
+ /**
+ * iegbe_clean - NAPI Rx polling callback
+ * @adapter: board private structure
+ **/
+-
+-static int
+-iegbe_clean(struct net_device *poll_dev, int *budget)
++static int iegbe_clean(struct napi_struct *napi, int budget)
+ {
+- struct iegbe_adapter *adapter;
+- int work_to_do = min(*budget, poll_dev->quota);
+- int tx_cleaned, i = 0, work_done = 0;
++ struct iegbe_adapter *adapter = container_of(napi, struct iegbe_adapter, napi);
++ struct net_device *poll_dev = adapter->netdev;
++ int tx_cleaned = 0, work_done = 0;
+
+ /* Must NOT use netdev_priv macro here. */
+ adapter = poll_dev->priv;
+
+- /* Keep link state information with original netdev */
+- if (!netif_carrier_ok(adapter->netdev)) {
+- goto quit_polling;
+- }
+- while (poll_dev != &adapter->polling_netdev[i]) {
+- i++;
+- if (unlikely(i == adapter->num_queues)) {
+- BUG();
+- }
+- }
+-
+-#ifdef IEGBE_GBE_WORKAROUND
+- /* Tx descriptors are cleaned in iegbe_intr(). No need to clean
+- them here */
+- tx_cleaned = FALSE;
+-#else
+- tx_cleaned = iegbe_clean_tx_irq(adapter, &adapter->tx_ring[i]);
+-#endif
+- adapter->clean_rx(adapter, &adapter->rx_ring[i],
+- &work_done, work_to_do);
+-
+- *budget -= work_done;
+- poll_dev->quota -= work_done;
+-
+- /* If no Tx and not enough Rx work done, exit the polling mode */
+- if((!tx_cleaned && (work_done == 0)) ||
+- !netif_running(adapter->netdev)) {
+-quit_polling:
+- netif_rx_complete(poll_dev);
++ /* iegbe_clean is called per-cpu. This lock protects
++ * tx_ring[0] from being cleaned by multiple cpus
++ * simultaneously. A failure obtaining the lock means
++ * tx_ring[0] is currently being cleaned anyway. */
++ if (spin_trylock(&adapter->tx_queue_lock)) {
++ tx_cleaned = iegbe_clean_tx_irq(adapter,
++ &adapter->tx_ring[0]);
++ spin_unlock(&adapter->tx_queue_lock);
++ }
++
++ adapter->clean_rx(adapter, &adapter->rx_ring[0],
++ &work_done, budget);
++
++ if (tx_cleaned)
++ work_done = budget;
++
++ /* If budget not fully consumed, exit the polling mode */
++ if (work_done < budget) {
++ if (likely(adapter->itr_setting & 3))
++ iegbe_set_itr(adapter);
++ netif_rx_complete(poll_dev, napi);
+ iegbe_irq_enable(adapter);
+- return 0;
+ }
+
+- return 1;
++ return work_done;
+ }
+
+-#endif
+-
+-
+-#ifndef IEGBE_GBE_WORKAROUND
+ /**
+ * iegbe_clean_tx_irq - Reclaim resources after transmit completes
+ * @adapter: board private structure
+ **/
+-
+-static boolean_t
+-iegbe_clean_tx_irq(struct iegbe_adapter *adapter,
++static bool iegbe_clean_tx_irq(struct iegbe_adapter *adapter,
+ struct iegbe_tx_ring *tx_ring)
+ {
+- struct net_device *netdev = adapter->netdev;
+- struct iegbe_tx_desc *tx_desc, *eop_desc;
+- struct iegbe_buffer *buffer_info;
+- unsigned int i, eop;
+- boolean_t cleaned = FALSE;
++ struct iegbe_hw *hw = &adapter->hw;
++ struct net_device *netdev = adapter->netdev;
++ struct iegbe_tx_desc *tx_desc, *eop_desc;
++ struct iegbe_buffer *buffer_info;
++ unsigned int i, eop;
++ unsigned int count = 0;
++ bool cleaned = false;
++ unsigned int total_tx_bytes=0, total_tx_packets=0;
+
+- i = tx_ring->next_to_clean;
+- eop = tx_ring->buffer_info[i].next_to_watch;
+- eop_desc = E1000_TX_DESC(*tx_ring, eop);
++ i = tx_ring->next_to_clean;
++ eop = tx_ring->buffer_info[i].next_to_watch;
++ eop_desc = E1000_TX_DESC(*tx_ring, eop);
+
+ while (eop_desc->upper.data & cpu_to_le32(E1000_TXD_STAT_DD)) {
+- /* Premature writeback of Tx descriptors clear (free buffers
+- * and unmap pci_mapping) previous_buffer_info */
+- if (likely(tx_ring->previous_buffer_info.skb != NULL)) {
+- iegbe_unmap_and_free_tx_resource(adapter,
+- &tx_ring->previous_buffer_info);
+- }
+-
+- for (cleaned = FALSE; !cleaned; ) {
+- tx_desc = E1000_TX_DESC(*tx_ring, i);
+- buffer_info = &tx_ring->buffer_info[i];
+- cleaned = (i == eop);
+-
+-#ifdef NETIF_F_TSO
+- if (!(netdev->features & NETIF_F_TSO)) {
+-#endif
+- iegbe_unmap_and_free_tx_resource(adapter,
+- buffer_info);
+-#ifdef NETIF_F_TSO
+- } else {
+- if (cleaned) {
+- memcpy(&tx_ring->previous_buffer_info,
+- buffer_info,
+- sizeof(struct iegbe_buffer));
+- memset(buffer_info, 0,
+- sizeof(struct iegbe_buffer));
+- } else {
+- iegbe_unmap_and_free_tx_resource(
+- adapter, buffer_info);
+- }
+- }
+-#endif
+-
+- tx_desc->buffer_addr = 0;
+- tx_desc->lower.data = 0;
++ for (cleaned = false; !cleaned; ) {
++ tx_desc = E1000_TX_DESC(*tx_ring, i);
++ buffer_info = &tx_ring->buffer_info[i];
++ cleaned = (i == eop);
++
++ if (cleaned) {
++ struct sk_buff *skb = buffer_info->skb;
++ unsigned int segs = 0, bytecount;
++ segs = skb_shinfo(skb)->gso_segs ?: 1;
++ bytecount = ((segs - 1) * skb_headlen(skb)) +
++ skb->len;
++ total_tx_packets += segs;
++ total_tx_bytes += bytecount;
++ }
++ iegbe_unmap_and_free_tx_resource(adapter, buffer_info);
+ tx_desc->upper.data = 0;
+
+- if (unlikely(++i == tx_ring->count)) { i = 0; }
+- }
+-
+- tx_ring->pkt++;
++ if (unlikely(++i == tx_ring->count)) i = 0;
++ }
+
+- eop = tx_ring->buffer_info[i].next_to_watch;
+- eop_desc = E1000_TX_DESC(*tx_ring, eop);
+- }
++ eop = tx_ring->buffer_info[i].next_to_watch;
++ eop_desc = E1000_TX_DESC(*tx_ring, eop);
++#define E1000_TX_WEIGHT 64
++ /* weight of a sort for tx, to avoid endless transmit cleanup */
++ if (count++ == E1000_TX_WEIGHT)
++ break;
++ }
+
+ tx_ring->next_to_clean = i;
+
+- spin_lock(&tx_ring->tx_lock);
++#define TX_WAKE_THRESHOLD 32
+
+- if (unlikely(cleaned && netif_queue_stopped(netdev) &&
+- netif_carrier_ok(netdev))) {
+- netif_wake_queue(netdev);
+- }
+- spin_unlock(&tx_ring->tx_lock);
+-
+- if (adapter->detect_tx_hung) {
+- /* Detect a transmit hang in hardware, this serializes the
+- * check with the clearing of time_stamp and movement of i */
+- adapter->detect_tx_hung = FALSE;
+-
+- if (tx_ring->buffer_info[i].dma &&
+- time_after(jiffies, tx_ring->buffer_info[i].time_stamp + HZ)
+- && !(E1000_READ_REG(&adapter->hw, STATUS) &
+- E1000_STATUS_TXOFF)) {
+-
+- /* detected Tx unit hang */
+- i = tx_ring->next_to_clean;
+- eop = tx_ring->buffer_info[i].next_to_watch;
+- eop_desc = E1000_TX_DESC(*tx_ring, eop);
+- DPRINTK(DRV, ERR, "Detected Tx Unit Hang\n"
+- " TDH <%x>\n"
+- " TDT <%x>\n"
+- " next_to_use <%x>\n"
+- " next_to_clean <%x>\n"
+- "buffer_info[next_to_clean]\n"
+- " dma <%zx>\n"
+- " time_stamp <%lx>\n"
+- " next_to_watch <%x>\n"
+- " jiffies <%lx>\n"
+- " next_to_watch.status <%x>\n",
+- readl(adapter->hw.hw_addr + tx_ring->tdh),
+- readl(adapter->hw.hw_addr + tx_ring->tdt),
+- tx_ring->next_to_use,
+- i,
+- (size_t)tx_ring->buffer_info[i].dma,
+- tx_ring->buffer_info[i].time_stamp,
+- eop,
+- jiffies,
+- eop_desc->upper.fields.status);
+- netif_stop_queue(netdev);
++ if (unlikely(cleaned && netif_carrier_ok(netdev) &&
++ E1000_DESC_UNUSED(tx_ring) >= TX_WAKE_THRESHOLD)) {
++ /* Make sure that anybody stopping the queue after this
++ * sees the new next_to_clean.
++ */
++ smp_mb();
++ if (netif_queue_stopped(netdev)) {
++ netif_wake_queue(netdev);
++ ++adapter->restart_queue;
+ }
+ }
+-#ifdef NETIF_F_TSO
+- if (unlikely(!(eop_desc->upper.data & cpu_to_le32(E1000_TXD_STAT_DD)) &&
+- time_after(jiffies, tx_ring->previous_buffer_info.time_stamp + HZ))) {
+- iegbe_unmap_and_free_tx_resource(
+- adapter, &tx_ring->previous_buffer_info);
++
++ if (adapter->detect_tx_hung) {
++ /* Detect a transmit hang in hardware, this serializes the
++ * check with the clearing of time_stamp and movement of i */
++ adapter->detect_tx_hung = false;
++
++ if (tx_ring->buffer_info[eop].dma &&
++ time_after(jiffies, tx_ring->buffer_info[eop].time_stamp +
++ (adapter->tx_timeout_factor * HZ))
++ && !(E1000_READ_REG(hw, STATUS) & E1000_STATUS_TXOFF)) {
++
++ /* detected Tx unit hang */
++ DPRINTK(DRV, ERR, "Detected Tx Unit Hang\n"
++ " Tx Queue <%lu>\n"
++ " TDH <%x>\n"
++ " TDT <%x>\n"
++ " next_to_use <%x>\n"
++ " next_to_clean <%x>\n"
++ "buffer_info[next_to_clean]\n"
++ " time_stamp <%lx>\n"
++ " next_to_watch <%x>\n"
++ " jiffies <%lx>\n"
++ " next_to_watch.status <%x>\n",
++ (unsigned long)((tx_ring - adapter->tx_ring) /
++ sizeof(struct iegbe_tx_ring)),
++ readl(hw->hw_addr + tx_ring->tdh),
++ readl(hw->hw_addr + tx_ring->tdt),
++ tx_ring->next_to_use,
++ tx_ring->next_to_clean,
++ tx_ring->buffer_info[eop].time_stamp,
++ eop,
++ jiffies,
++ eop_desc->upper.fields.status);
++ netif_stop_queue(netdev);
++ }
+ }
+-#endif
+- return cleaned;
++ adapter->total_tx_bytes += total_tx_bytes;
++ adapter->total_tx_packets += total_tx_packets;
++ adapter->net_stats.tx_bytes += total_tx_bytes;
++ adapter->net_stats.tx_packets += total_tx_packets;
++ return cleaned;
+ }
+-#endif
+
+ /**
+ * iegbe_rx_checksum - Receive Checksum Offload for 82543
+@@ -3913,192 +3689,193 @@ iegbe_clean_tx_irq(struct iegbe_adapter
+ * @sk_buff: socket buffer with received data
+ **/
+
+-static inline void
+-iegbe_rx_checksum(struct iegbe_adapter *adapter,
+- uint32_t status_err, uint32_t csum,
+- struct sk_buff *skb)
++static void iegbe_rx_checksum(struct iegbe_adapter *adapter, u32 status_err,
++ u32 csum, struct sk_buff *skb)
+ {
+- uint16_t status = (uint16_t)status_err;
+- uint8_t errors = (uint8_t)(status_err >> 0x18);
++ struct iegbe_hw *hw = &adapter->hw;
++ u16 status = (u16)status_err;
++ u8 errors = (u8)(status_err >> 24);
+ skb->ip_summed = CHECKSUM_NONE;
+
+- /* 82543 or newer only */
+- if(unlikely(adapter->hw.mac_type < iegbe_82543)) { return; }
+- /* Ignore Checksum bit is set */
+- if(unlikely(status & E1000_RXD_STAT_IXSM)) { return; }
+- /* TCP/UDP checksum error bit is set */
+- if(unlikely(errors & E1000_RXD_ERR_TCPE)) {
+- /* let the stack verify checksum errors */
+- adapter->hw_csum_err++;
+- return;
+- }
+- /* TCP/UDP Checksum has not been calculated */
+- if(adapter->hw.mac_type <= iegbe_82547_rev_2) {
+- if(!(status & E1000_RXD_STAT_TCPCS)) {
+- return;
++ /* 82543 or newer only */
++ if (unlikely(hw->mac_type < iegbe_82543)) return;
++ /* Ignore Checksum bit is set */
++ if (unlikely(status & E1000_RXD_STAT_IXSM)) return;
++ /* TCP/UDP checksum error bit is set */
++ if(unlikely(errors & E1000_RXD_ERR_TCPE)) {
++ /* let the stack verify checksum errors */
++ adapter->hw_csum_err++;
++ return;
++ }
++ /* TCP/UDP Checksum has not been calculated */
++ if (hw->mac_type <= iegbe_82547_rev_2) {
++ if (!(status & E1000_RXD_STAT_TCPCS))
++ return;
++ } else {
++ if (!(status & (E1000_RXD_STAT_TCPCS | E1000_RXD_STAT_UDPCS)))
++ return;
+ }
+- } else {
+- if(!(status & (E1000_RXD_STAT_TCPCS | E1000_RXD_STAT_UDPCS))) {
+- return;
+- }
++ /* It must be a TCP or UDP packet with a valid checksum */
++ if(likely(status & E1000_RXD_STAT_TCPCS)) {
++ /* TCP checksum is good */
++ skb->ip_summed = CHECKSUM_UNNECESSARY;
++ } else if (hw->mac_type > iegbe_82547_rev_2) {
++ /* IP fragment with UDP payload */
++ /* Hardware complements the payload checksum, so we undo it
++ * and then put the value in host order for further stack use.
++ */
++ __sum16 sum = (__force __sum16)htons(csum);
++ skb->csum = csum_unfold(~sum);
++ skb->ip_summed = CHECKSUM_COMPLETE;
+ }
+- /* It must be a TCP or UDP packet with a valid checksum */
+- if(likely(status & E1000_RXD_STAT_TCPCS)) {
+- /* TCP checksum is good */
+- skb->ip_summed = CHECKSUM_UNNECESSARY;
+- } else if(adapter->hw.mac_type > iegbe_82547_rev_2) {
+- /* IP fragment with UDP payload */
+- /* Hardware complements the payload checksum, so we undo it
+- * and then put the value in host order for further stack use.
+- */
+- csum = ntohl(csum ^ 0xFFFF);
+- skb->csum = csum;
+- skb->ip_summed = CHECKSUM_HW;
+- }
+- adapter->hw_csum_good++;
++ adapter->hw_csum_good++;
+ }
+
+ /**
+ * iegbe_clean_rx_irq - Send received data up the network stack; legacy
+ * @adapter: board private structure
+ **/
+-
+-static boolean_t
+-#ifdef CONFIG_E1000_NAPI
+-iegbe_clean_rx_irq(struct iegbe_adapter *adapter,
++static bool iegbe_clean_rx_irq(struct iegbe_adapter *adapter,
+ struct iegbe_rx_ring *rx_ring,
+ int *work_done, int work_to_do)
+-#else
+-iegbe_clean_rx_irq(struct iegbe_adapter *adapter,
+- struct iegbe_rx_ring *rx_ring)
+-#endif
+ {
+- struct net_device *netdev = adapter->netdev;
+- struct pci_dev *pdev = adapter->pdev;
+- struct iegbe_rx_desc *rx_desc;
+- struct iegbe_buffer *buffer_info;
+- struct sk_buff *skb;
+- unsigned long flags = 0;
+- uint32_t length;
+- uint8_t last_byte;
+- unsigned int i;
+- boolean_t cleaned = FALSE;
+-
+-#ifdef IEGBE_GBE_WORKAROUND
+- /* Need to keep track of the amount of Rx descriptors that we
+- cleaned to ensure that we don't supply too many back to the
+- hardware */
+- int cleaned_count = 0;
+-#endif
+-
+- i = rx_ring->next_to_clean;
+- rx_desc = E1000_RX_DESC(*rx_ring, i);
+-
+- while(rx_desc->status & E1000_RXD_STAT_DD) {
+- buffer_info = &rx_ring->buffer_info[i];
+-#ifdef CONFIG_E1000_NAPI
+- if(*work_done >= work_to_do) {
+- break;
+- }
+- (*work_done)++;
+-#endif
+- cleaned = TRUE;
++ struct iegbe_hw *hw = &adapter->hw;
++ struct net_device *netdev = adapter->netdev;
++ struct pci_dev *pdev = adapter->pdev;
++ struct iegbe_rx_desc *rx_desc, *next_rxd;
++ struct iegbe_buffer *buffer_info, *next_buffer;
++ unsigned long flags;
++ u32 length;
++ u8 last_byte;
++ unsigned int i;
++ int cleaned_count = 0;
++ bool cleaned = false;
++ unsigned int total_rx_bytes=0, total_rx_packets=0;
+
+-#ifdef IEGBE_GBE_WORKAROUND
+- cleaned_count++;
+-#endif
++ i = rx_ring->next_to_clean;
++ rx_desc = E1000_RX_DESC(*rx_ring, i);
++ buffer_info = &rx_ring->buffer_info[i];
+
+- pci_unmap_single(pdev,
+- buffer_info->dma,
+- buffer_info->length,
+- PCI_DMA_FROMDEVICE);
++ while(rx_desc->status & E1000_RXD_STAT_DD) {
++ struct sk_buff *skb;
++ u8 status;
++ if (*work_done >= work_to_do)
++ break;
++ (*work_done)++;
+
++ status = rx_desc->status;
+ skb = buffer_info->skb;
+- length = le16_to_cpu(rx_desc->length);
++ buffer_info->skb = NULL;
++ prefetch(skb->data - NET_IP_ALIGN);
++ if (++i == rx_ring->count) i = 0;
++ next_rxd = E1000_RX_DESC(*rx_ring, i);
++ prefetch(next_rxd);
++ next_buffer = &rx_ring->buffer_info[i];
++ cleaned = true;
++ cleaned_count++;
++ pci_unmap_single(pdev,
++ buffer_info->dma,
++ buffer_info->length,
++ PCI_DMA_FROMDEVICE);
++
++ length = le16_to_cpu(rx_desc->length);
++
++ if (unlikely(!(status & E1000_RXD_STAT_EOP))) {
++ /* All receives must fit into a single buffer */
++ E1000_DBG("%s: Receive packet consumed multiple"
++ " buffers\n", netdev->name);
++ buffer_info->skb = skb;
++ goto next_desc;
++ }
+
+- if(unlikely(!(rx_desc->status & E1000_RXD_STAT_EOP))) {
+- /* All receives must fit into a single buffer */
+- E1000_DBG("%s: Receive packet consumed multiple"
+- " buffers\n", netdev->name);
+- dev_kfree_skb_irq(skb);
+- goto next_desc;
+- }
++ if(unlikely(rx_desc->errors & E1000_RXD_ERR_FRAME_ERR_MASK)) {
++ last_byte = *(skb->data + length - 1);
++ if (TBI_ACCEPT(hw, status, rx_desc->errors, length,
++ last_byte)) {
++ spin_lock_irqsave(&adapter->stats_lock, flags);
++ iegbe_tbi_adjust_stats(hw, &adapter->stats,
++ length, skb->data);
++ spin_unlock_irqrestore(&adapter->stats_lock,
++ flags);
++ length--;
++ } else {
++ buffer_info->skb = skb;
++ goto next_desc;
++ }
++ }
+
+- if(unlikely(rx_desc->errors & E1000_RXD_ERR_FRAME_ERR_MASK)) {
+- last_byte = *(skb->data + length - 0x1);
+- if(TBI_ACCEPT(&adapter->hw, rx_desc->status,
+- rx_desc->errors, length, last_byte)) {
+- spin_lock_irqsave(&adapter->stats_lock, flags);
+- iegbe_tbi_adjust_stats(&adapter->hw,
+- &adapter->stats,
+- length, skb->data);
+- spin_unlock_irqrestore(&adapter->stats_lock,
+- flags);
+- length--;
+- } else {
+- dev_kfree_skb_irq(skb);
+- goto next_desc;
++ /* adjust length to remove Ethernet CRC, this must be
++ * done after the TBI_ACCEPT workaround above */
++ length -= 4;
++
++ /* probably a little skewed due to removing CRC */
++ total_rx_bytes += length;
++ total_rx_packets++;
++
++ /* code added for copybreak, this should improve
++ * performance for small packets with large amounts
++ * of reassembly being done in the stack */
++ if (length < copybreak) {
++ struct sk_buff *new_skb =
++ netdev_alloc_skb(netdev, length + NET_IP_ALIGN);
++ if (new_skb) {
++ skb_reserve(new_skb, NET_IP_ALIGN);
++ skb_copy_to_linear_data_offset(new_skb,
++ -NET_IP_ALIGN,
++ (skb->data -
++ NET_IP_ALIGN),
++ (length +
++ NET_IP_ALIGN));
++ /* save the skb in buffer_info as good */
++ buffer_info->skb = skb;
++ skb = new_skb;
+ }
++ /* else just continue with the old one */
+ }
+-
+- /* Good Receive */
+- skb_put(skb, length - ETHERNET_FCS_SIZE);
++ /* Good Receive */
++ skb_put(skb, length);
+
+ /* Receive Checksum Offload */
+ iegbe_rx_checksum(adapter,
+- (uint32_t)(rx_desc->status) |
+- ((uint32_t)(rx_desc->errors) << 0x18),
+- rx_desc->csum, skb);
++ (u32)(status) |
++ ((u32)(rx_desc->errors) << 24),
++ le16_to_cpu(rx_desc->csum), skb);
++
+ skb->protocol = eth_type_trans(skb, netdev);
+-#ifdef CONFIG_E1000_NAPI
+-#ifdef NETIF_F_HW_VLAN_TX
+- if(unlikely(adapter->vlgrp &&
+- (rx_desc->status & E1000_RXD_STAT_VP))) {
++
++ if (unlikely(adapter->vlgrp &&
++ (status & E1000_RXD_STAT_VP))) {
+ vlan_hwaccel_receive_skb(skb, adapter->vlgrp,
+- le16_to_cpu(rx_desc->special) &
+- E1000_RXD_SPC_VLAN_MASK);
++ le16_to_cpu(rx_desc->special));
+ } else {
+ netif_receive_skb(skb);
+ }
+-#else
+- netif_receive_skb(skb);
+-#endif
+-#else /* CONFIG_E1000_NAPI */
+-#ifdef NETIF_F_HW_VLAN_TX
+- if(unlikely(adapter->vlgrp &&
+- (rx_desc->status & E1000_RXD_STAT_VP))) {
+- vlan_hwaccel_rx(skb, adapter->vlgrp,
+- le16_to_cpu(rx_desc->special) &
+- E1000_RXD_SPC_VLAN_MASK);
+- } else {
+- netif_rx(skb);
+- }
+-#else
+- netif_rx(skb);
+-#endif
+-#endif /* CONFIG_E1000_NAPI */
++
+ netdev->last_rx = jiffies;
+- rx_ring->pkt++;
+
+ next_desc:
+ rx_desc->status = 0;
+- buffer_info->skb = NULL;
+- if(unlikely(++i == rx_ring->count)) { i = 0; }
+
+- rx_desc = E1000_RX_DESC(*rx_ring, i);
++ /* return some buffers to hardware, one at a time is too slow */
++ if (unlikely(cleaned_count >= E1000_RX_BUFFER_WRITE)) {
++ adapter->alloc_rx_buf(adapter, rx_ring, cleaned_count);
++ cleaned_count = 0;
++ }
++
++ /* use prefetched values */
++ rx_desc = next_rxd;
++ buffer_info = next_buffer;
+ }
+ rx_ring->next_to_clean = i;
+
+-#ifdef IEGBE_GBE_WORKAROUND
+- /* Only allocate the number of buffers that we have actually
+- cleaned! */
+- if (cleaned_count) {
+- adapter->alloc_rx_buf(adapter, rx_ring, cleaned_count);
+- }
+-#else
+- adapter->alloc_rx_buf(adapter, rx_ring);
+-#endif
+-
++ cleaned_count = E1000_DESC_UNUSED(rx_ring);
++ if (cleaned_count)
++ adapter->alloc_rx_buf(adapter, rx_ring, cleaned_count);
++
++ adapter->total_rx_packets += total_rx_packets;
++ adapter->total_rx_bytes += total_rx_bytes;
++ adapter->net_stats.rx_bytes += total_rx_bytes;
++ adapter->net_stats.rx_packets += total_rx_packets;
+ return cleaned;
+ }
+
+@@ -4107,161 +3884,153 @@ next_desc:
+ * @adapter: board private structure
+ **/
+
+-static boolean_t
+-#ifdef CONFIG_E1000_NAPI
+-iegbe_clean_rx_irq_ps(struct iegbe_adapter *adapter,
++static bool iegbe_clean_rx_irq_ps(struct iegbe_adapter *adapter,
+ struct iegbe_rx_ring *rx_ring,
+ int *work_done, int work_to_do)
+-#else
+-iegbe_clean_rx_irq_ps(struct iegbe_adapter *adapter,
+- struct iegbe_rx_ring *rx_ring)
+-#endif
+ {
+- union iegbe_rx_desc_packet_split *rx_desc;
+- struct net_device *netdev = adapter->netdev;
+- struct pci_dev *pdev = adapter->pdev;
+- struct iegbe_buffer *buffer_info;
+- struct iegbe_ps_page *ps_page;
+- struct iegbe_ps_page_dma *ps_page_dma;
+- struct sk_buff *skb;
+- unsigned int i, j;
+- uint32_t length, staterr;
+- boolean_t cleaned = FALSE;
+-
+-#ifdef IEGBE_GBE_WORKAROUND
+- /* Need to keep track of the amount of Rx descriptors that we
+- cleaned to ensure that we don't supply too many back to the
+- hardware */
+- int cleaned_count = 0;
+-#endif
+-
+- i = rx_ring->next_to_clean;
+- rx_desc = E1000_RX_DESC_PS(*rx_ring, i);
+- staterr = le32_to_cpu(rx_desc->wb.middle.status_error);
+-
+- while(staterr & E1000_RXD_STAT_DD) {
+- buffer_info = &rx_ring->buffer_info[i];
+- ps_page = &rx_ring->ps_page[i];
+- ps_page_dma = &rx_ring->ps_page_dma[i];
+-#ifdef CONFIG_E1000_NAPI
+- if(unlikely(*work_done >= work_to_do)) {
+- break;
+- }
+- (*work_done)++;
+-#endif
+- cleaned = TRUE;
+-
+-#ifdef IEGBE_GBE_WORKAROUND
+- cleaned_count++;
+-#endif
++ union iegbe_rx_desc_packet_split *rx_desc, *next_rxd;
++ struct net_device *netdev = adapter->netdev;
++ struct pci_dev *pdev = adapter->pdev;
++ struct iegbe_buffer *buffer_info, *next_buffer;
++ struct iegbe_ps_page *ps_page;
++ struct iegbe_ps_page_dma *ps_page_dma;
++ struct sk_buff *skb;
++ unsigned int i, j;
++ u32 length, staterr;
++ int cleaned_count = 0;
++ bool cleaned = false;
++ unsigned int total_rx_bytes=0, total_rx_packets=0;
++
++ i = rx_ring->next_to_clean;
++ rx_desc = E1000_RX_DESC_PS(*rx_ring, i);
++ staterr = le32_to_cpu(rx_desc->wb.middle.status_error);
++ buffer_info = &rx_ring->buffer_info[i];
+
+- pci_unmap_single(pdev, buffer_info->dma,
+- buffer_info->length,
+- PCI_DMA_FROMDEVICE);
++ while(staterr & E1000_RXD_STAT_DD) {
++ ps_page = &rx_ring->ps_page[i];
++ ps_page_dma = &rx_ring->ps_page_dma[i];
++
++ if (unlikely(*work_done >= work_to_do))
++ break;
++ (*work_done)++;
+
+ skb = buffer_info->skb;
++ prefetch(skb->data - NET_IP_ALIGN);
++ if (++i == rx_ring->count) i = 0;
++ next_rxd = E1000_RX_DESC_PS(*rx_ring, i);
++ prefetch(next_rxd);
++ next_buffer = &rx_ring->buffer_info[i];
++ cleaned = true;
++ cleaned_count++;
++ pci_unmap_single(pdev, buffer_info->dma,
++ buffer_info->length,
++ PCI_DMA_FROMDEVICE);
++
++ if(unlikely(!(staterr & E1000_RXD_STAT_EOP))) {
++ E1000_DBG("%s: Packet Split buffers didn't pick up"
++ " the full packet\n", netdev->name);
++ dev_kfree_skb_irq(skb);
++ goto next_desc;
++ }
+
+- if(unlikely(!(staterr & E1000_RXD_STAT_EOP))) {
+- E1000_DBG("%s: Packet Split buffers didn't pick up"
+- " the full packet\n", netdev->name);
+- dev_kfree_skb_irq(skb);
+- goto next_desc;
+- }
+-
+- if(unlikely(staterr & E1000_RXDEXT_ERR_FRAME_ERR_MASK)) {
+- dev_kfree_skb_irq(skb);
+- goto next_desc;
+- }
+-
+- length = le16_to_cpu(rx_desc->wb.middle.length0);
++ if(unlikely(staterr & E1000_RXDEXT_ERR_FRAME_ERR_MASK)) {
++ dev_kfree_skb_irq(skb);
++ goto next_desc;
++ }
+
+- if(unlikely(!length)) {
+- E1000_DBG("%s: Last part of the packet spanning"
+- " multiple descriptors\n", netdev->name);
+- dev_kfree_skb_irq(skb);
+- goto next_desc;
+- }
++ length = le16_to_cpu(rx_desc->wb.middle.length0);
+
+- /* Good Receive */
+- skb_put(skb, length);
+-
+- for(j = 0; j < adapter->rx_ps_pages; j++) {
+- if(!(length = le16_to_cpu(rx_desc->wb.upper.length[j]))) {
+- break;
+- }
+- pci_unmap_page(pdev, ps_page_dma->ps_page_dma[j],
+- PAGE_SIZE, PCI_DMA_FROMDEVICE);
+- ps_page_dma->ps_page_dma[j] = 0;
+- skb_shinfo(skb)->frags[j].page =
+- ps_page->ps_page[j];
+- ps_page->ps_page[j] = NULL;
+- skb_shinfo(skb)->frags[j].page_offset = 0;
+- skb_shinfo(skb)->frags[j].size = length;
+- skb_shinfo(skb)->nr_frags++;
+- skb->len += length;
+- skb->data_len += length;
+- }
++ if(unlikely(!length)) {
++ E1000_DBG("%s: Last part of the packet spanning"
++ " multiple descriptors\n", netdev->name);
++ dev_kfree_skb_irq(skb);
++ goto next_desc;
++ }
+
+- iegbe_rx_checksum(adapter, staterr,
+- rx_desc->wb.lower.hi_dword.csum_ip.csum, skb);
+- skb->protocol = eth_type_trans(skb, netdev);
++ /* Good Receive */
++ skb_put(skb, length);
+
+- if(likely(rx_desc->wb.upper.header_status &
+- E1000_RXDPS_HDRSTAT_HDRSP)) {
+- adapter->rx_hdr_split++;
+-#ifdef HAVE_RX_ZERO_COPY
+- skb_shinfo(skb)->zero_copy = TRUE;
+-#endif
+- }
+-#ifdef CONFIG_E1000_NAPI
+-#ifdef NETIF_F_HW_VLAN_TX
+- if(unlikely(adapter->vlgrp && (staterr & E1000_RXD_STAT_VP))) {
+- vlan_hwaccel_receive_skb(skb, adapter->vlgrp,
+- le16_to_cpu(rx_desc->wb.middle.vlan) &
+- E1000_RXD_SPC_VLAN_MASK);
+- } else {
+- netif_receive_skb(skb);
+- }
+-#else
+- netif_receive_skb(skb);
+-#endif
+-#else /* CONFIG_E1000_NAPI */
+-#ifdef NETIF_F_HW_VLAN_TX
+- if(unlikely(adapter->vlgrp && (staterr & E1000_RXD_STAT_VP))) {
+- vlan_hwaccel_rx(skb, adapter->vlgrp,
+- le16_to_cpu(rx_desc->wb.middle.vlan) &
+- E1000_RXD_SPC_VLAN_MASK);
+- } else {
+- netif_rx(skb);
+- }
+-#else
+- netif_rx(skb);
+-#endif
+-#endif /* CONFIG_E1000_NAPI */
+- netdev->last_rx = jiffies;
+- rx_ring->pkt++;
++ {
++ int l1 = le16_to_cpu(rx_desc->wb.upper.length[0]);
++ if (l1 && (l1 <= copybreak) && ((length + l1) <= adapter->rx_ps_bsize0)) {
++ u8 *vaddr;
++ pci_dma_sync_single_for_cpu(pdev,
++ ps_page_dma->ps_page_dma[0],
++ PAGE_SIZE,
++ PCI_DMA_FROMDEVICE);
++ vaddr = kmap_atomic(ps_page->ps_page[0],
++ KM_SKB_DATA_SOFTIRQ);
++ memcpy(skb_tail_pointer(skb), vaddr, l1);
++ kunmap_atomic(vaddr, KM_SKB_DATA_SOFTIRQ);
++ pci_dma_sync_single_for_device(pdev,
++ ps_page_dma->ps_page_dma[0],
++ PAGE_SIZE, PCI_DMA_FROMDEVICE);
++ l1 -= 4;
++ skb_put(skb, l1);
++ goto copydone;
++ } /* if */
++ }
++ for (j = 0; j < adapter->rx_ps_pages; j++) {
++ length = le16_to_cpu(rx_desc->wb.upper.length[j]);
++ if (!length)
++ break;
++ pci_unmap_page(pdev, ps_page_dma->ps_page_dma[j],
++ PAGE_SIZE, PCI_DMA_FROMDEVICE);
++ ps_page_dma->ps_page_dma[j] = 0;
++ skb_fill_page_desc(skb, j, ps_page->ps_page[j], 0,
++ length);
++ ps_page->ps_page[j] = NULL;
++ skb->len += length;
++ skb->data_len += length;
++ skb->truesize += length;
++ }
+
+-next_desc:
+- rx_desc->wb.middle.status_error &= ~0xFF;
+- buffer_info->skb = NULL;
+- if(unlikely(++i == rx_ring->count)) { i = 0; }
++ pskb_trim(skb, skb->len - 4);
++copydone:
++ total_rx_bytes += skb->len;
++ total_rx_packets++;
++ iegbe_rx_checksum(adapter, staterr,
++ le16_to_cpu(rx_desc->wb.lower.hi_dword.csum_ip.csum), skb);
++ skb->protocol = eth_type_trans(skb, netdev);
++
++ if(likely(rx_desc->wb.upper.header_status &
++ cpu_to_le16(E1000_RXDPS_HDRSTAT_HDRSP)))
++ adapter->rx_hdr_split++;
++
++ if(unlikely(adapter->vlgrp && (staterr & E1000_RXD_STAT_VP))) {
++ vlan_hwaccel_receive_skb(skb, adapter->vlgrp,
++ le16_to_cpu(rx_desc->wb.middle.vlan));
++ } else {
++ netif_receive_skb(skb);
++ }
+
+- rx_desc = E1000_RX_DESC_PS(*rx_ring, i);
+- staterr = le32_to_cpu(rx_desc->wb.middle.status_error);
+- }
+- rx_ring->next_to_clean = i;
++ netdev->last_rx = jiffies;
+
+-#ifdef IEGBE_GBE_WORKAROUND
+- /* Only allocate the number of buffers that we have actually
+- cleaned! */
+- if (cleaned_count) {
+- adapter->alloc_rx_buf(adapter, rx_ring, cleaned_count);
+- }
+-#else
+- adapter->alloc_rx_buf(adapter, rx_ring);
+-#endif
++next_desc:
++ rx_desc->wb.middle.status_error &= cpu_to_le32(~0xFF);
++ buffer_info->skb = NULL;
+
+- return cleaned;
++ if (unlikely(cleaned_count >= E1000_RX_BUFFER_WRITE)) {
++ adapter->alloc_rx_buf(adapter, rx_ring, cleaned_count);
++ cleaned_count = 0;
++ }
++
++ /* use prefetched values */
++ rx_desc = next_rxd;
++ buffer_info = next_buffer;
++ staterr = le32_to_cpu(rx_desc->wb.middle.status_error);
++ }
++ rx_ring->next_to_clean = i;
++
++ cleaned_count = E1000_DESC_UNUSED(rx_ring);
++ if (cleaned_count)
++ adapter->alloc_rx_buf(adapter, rx_ring, cleaned_count);
++
++ adapter->total_rx_packets += total_rx_packets;
++ adapter->total_rx_bytes += total_rx_bytes;
++ adapter->net_stats.rx_bytes += total_rx_bytes;
++ adapter->net_stats.rx_packets += total_rx_packets;
++ return cleaned;
+ }
+
+ /**
+@@ -4269,142 +4038,115 @@ next_desc:
+ * @adapter: address of board private structure
+ **/
+
+-#ifdef IEGBE_GBE_WORKAROUND
+-static void
+-iegbe_alloc_rx_buffers(struct iegbe_adapter *adapter,
++
++static void iegbe_alloc_rx_buffers(struct iegbe_adapter *adapter,
+ struct iegbe_rx_ring *rx_ring,
+ int cleaned_count)
+-#else
+-static void
+-iegbe_alloc_rx_buffers(struct iegbe_adapter *adapter,
+- struct iegbe_rx_ring *rx_ring)
+-#endif
+ {
+- struct net_device *netdev = adapter->netdev;
+- struct pci_dev *pdev = adapter->pdev;
+- struct iegbe_rx_desc *rx_desc;
+- struct iegbe_buffer *buffer_info;
+- struct sk_buff *skb;
+- unsigned int i;
+- unsigned int bufsz = adapter->rx_buffer_len + NET_IP_ALIGN;
+-
+- i = rx_ring->next_to_use;
+- buffer_info = &rx_ring->buffer_info[i];
++ struct iegbe_hw *hw = &adapter->hw;
++ struct net_device *netdev = adapter->netdev;
++ struct pci_dev *pdev = adapter->pdev;
++ struct iegbe_rx_desc *rx_desc;
++ struct iegbe_buffer *buffer_info;
++ struct sk_buff *skb;
++ unsigned int i;
++ unsigned int bufsz = adapter->rx_buffer_len + NET_IP_ALIGN;
+
+-#ifdef IEGBE_GBE_WORKAROUND
+- if (cleaned_count > IEGBE_GBE_WORKAROUND_NUM_RX_DESCRIPTORS) {
+- adapter->stats.cc_gt_num_rx++;
+- }
+- while(cleaned_count-- && !buffer_info->skb) {
+-#else
+- while(!buffer_info->skb) {
+-#endif
+- skb = dev_alloc_skb(bufsz);
++ i = rx_ring->next_to_use;
++ buffer_info = &rx_ring->buffer_info[i];
+
+- if(unlikely(!skb)) {
+- /* Better luck next round */
+- break;
+- }
++ while (cleaned_count--) {
++ skb = buffer_info->skb;
++ if (skb) {
++ skb_trim(skb, 0);
++ goto map_skb;
++ }
++ skb = netdev_alloc_skb(netdev, bufsz);
++
++ if(unlikely(!skb)) {
++ /* Better luck next round */
++ adapter->alloc_rx_buff_failed++;
++ break;
++ }
+
+- /* Fix for errata 23, can't cross 64kB boundary */
+- if(!iegbe_check_64k_bound(adapter, skb->data, bufsz)) {
+- struct sk_buff *oldskb = skb;
+- DPRINTK(RX_ERR, ERR, "skb align check failed: %u bytes "
+- "at %p\n", bufsz, skb->data);
+- /* Try again, without freeing the previous */
+- skb = dev_alloc_skb(bufsz);
+- /* Failed allocation, critical failure */
+- if(!skb) {
+- dev_kfree_skb(oldskb);
+- break;
+- }
++ /* Fix for errata 23, can't cross 64kB boundary */
++ if(!iegbe_check_64k_bound(adapter, skb->data, bufsz)) {
++ struct sk_buff *oldskb = skb;
++ DPRINTK(RX_ERR, ERR, "skb align check failed: %u bytes "
++ "at %p\n", bufsz, skb->data);
++ /* Try again, without freeing the previous */
++ skb = netdev_alloc_skb(netdev, bufsz);
++ /* Failed allocation, critical failure */
++ if(!skb) {
++ dev_kfree_skb(oldskb);
++ break;
++ }
+
+- if(!iegbe_check_64k_bound(adapter, skb->data, bufsz)) {
+- /* give up */
+- dev_kfree_skb(skb);
+- dev_kfree_skb(oldskb);
+- break; /* while !buffer_info->skb */
+- } else {
+- /* Use new allocation */
+- dev_kfree_skb(oldskb);
++ if(!iegbe_check_64k_bound(adapter, skb->data, bufsz)) {
++ /* give up */
++ dev_kfree_skb(skb);
++ dev_kfree_skb(oldskb);
++ break; /* while !buffer_info->skb */
+ }
+- }
+- /* Make buffer alignment 2 beyond a 16 byte boundary
+- * this will result in a 16 byte aligned IP header after
+- * the 14 byte MAC header is removed
+- */
+- skb_reserve(skb, NET_IP_ALIGN);
+-
+- skb->dev = netdev;
+-
+- buffer_info->skb = skb;
+- buffer_info->length = adapter->rx_buffer_len;
+- buffer_info->dma = pci_map_single(pdev,
+- skb->data,
+- adapter->rx_buffer_len,
+- PCI_DMA_FROMDEVICE);
+-
+- /* Fix for errata 23, can't cross 64kB boundary */
+- if(!iegbe_check_64k_bound(adapter,
+- (void *)(unsigned long)buffer_info->dma,
+- adapter->rx_buffer_len)) {
+- DPRINTK(RX_ERR, ERR,
+- "dma align check failed: %u bytes at %p\n",
+- adapter->rx_buffer_len,
+- (void *)(unsigned long)buffer_info->dma);
+- dev_kfree_skb(skb);
+- buffer_info->skb = NULL;
+-
+- pci_unmap_single(pdev, buffer_info->dma,
+- adapter->rx_buffer_len,
+- PCI_DMA_FROMDEVICE);
+-
+- break; /* while !buffer_info->skb */
+- }
+- rx_desc = E1000_RX_DESC(*rx_ring, i);
+- rx_desc->buffer_addr = cpu_to_le64(buffer_info->dma);
+-
+-#ifdef IEGBE_GBE_WORKAROUND_DISABLED
+- adapter->stats.num_rx_buf_alloc++;
++ /* Use new allocation */
++ dev_kfree_skb(oldskb);
++ }
++ /* Make buffer alignment 2 beyond a 16 byte boundary
++ * this will result in a 16 byte aligned IP header after
++ * the 14 byte MAC header is removed
++ */
++ skb_reserve(skb, NET_IP_ALIGN);
++
++
++ buffer_info->skb = skb;
++ buffer_info->length = adapter->rx_buffer_len;
++map_skb:
++ buffer_info->dma = pci_map_single(pdev,
++ skb->data,
++ adapter->rx_buffer_len,
++ PCI_DMA_FROMDEVICE);
++
++ /* Fix for errata 23, can't cross 64kB boundary */
++ if(!iegbe_check_64k_bound(adapter,
++ (void *)(unsigned long)buffer_info->dma,
++ adapter->rx_buffer_len)) {
++ DPRINTK(RX_ERR, ERR,
++ "dma align check failed: %u bytes at %p\n",
++ adapter->rx_buffer_len,
++ (void *)(unsigned long)buffer_info->dma);
++ dev_kfree_skb(skb);
++ buffer_info->skb = NULL;
++
++ pci_unmap_single(pdev, buffer_info->dma,
++ adapter->rx_buffer_len,
++ PCI_DMA_FROMDEVICE);
+
+- /* Force memory writes to complete before letting h/w
+- * know there are new descriptors to fetch. (Only
+- * applicable for weak-ordered memory model archs,
+- * such as IA-64). */
+- wmb();
+- writel(i, adapter->hw.hw_addr + rx_ring->rdt);
++ break; /* while !buffer_info->skb */
++ }
++ rx_desc = E1000_RX_DESC(*rx_ring, i);
++ rx_desc->buffer_addr = cpu_to_le64(buffer_info->dma);
+
+-#endif
+-#ifndef IEGBE_GBE_WORKAROUND
+- if(unlikely((i & ~(E1000_RX_BUFFER_WRITE - 0x1)) == i)) {
+- /* Force memory writes to complete before letting h/w
+- * know there are new descriptors to fetch. (Only
+- * applicable for weak-ordered memory model archs,
+- * such as IA-64). */
+- wmb();
+- writel(i, adapter->hw.hw_addr + rx_ring->rdt);
+- }
+-#endif
+- if(unlikely(++i == rx_ring->count)) { i = 0; }
+- buffer_info = &rx_ring->buffer_info[i];
+- }
++ /* Force memory writes to complete before letting h/w
++ * know there are new descriptors to fetch. (Only
++ * applicable for weak-ordered memory model archs,
++ * such as IA-64). */
++ if (unlikely(++i == rx_ring->count))
++ i = 0;
++ buffer_info = &rx_ring->buffer_info[i];
++ }
+
+-#ifdef IEGBE_GBE_WORKAROUND
+ if (likely(rx_ring->next_to_use != i)) {
+- rx_ring->next_to_use = i;
+- if (unlikely(i-- == 0)) {
+- i = (rx_ring->count - 0x1);
+- }
++ rx_ring->next_to_use = i;
++ if (unlikely(i-- == 0))
++ i = (rx_ring->count - 1);
++
+ /* Force memory writes to complete before letting h/w
+ * know there are new descriptors to fetch. (Only
+ * applicable for weak-ordered memory model archs,
+ * such as IA-64). */
+ wmb();
+- writel(i, adapter->hw.hw_addr + rx_ring->rdt);
++ writel(i, hw->hw_addr + rx_ring->rdt);
+ }
+-#else
+- rx_ring->next_to_use = i;
+-#endif
+ }
+
+ /**
+@@ -4412,49 +4154,41 @@ iegbe_alloc_rx_buffers(struct iegbe_adap
+ * @adapter: address of board private structure
+ **/
+
+-#ifdef IEGBE_GBE_WORKAROUND
+-static void
+-iegbe_alloc_rx_buffers_ps(struct iegbe_adapter *adapter,
++
++static void iegbe_alloc_rx_buffers_ps(struct iegbe_adapter *adapter,
+ struct iegbe_rx_ring *rx_ring,
+ int cleaned_count)
+-#else
+-static void
+-iegbe_alloc_rx_buffers_ps(struct iegbe_adapter *adapter,
+- struct iegbe_rx_ring *rx_ring)
+-#endif
+ {
+- struct net_device *netdev = adapter->netdev;
+- struct pci_dev *pdev = adapter->pdev;
+- union iegbe_rx_desc_packet_split *rx_desc;
+- struct iegbe_buffer *buffer_info;
+- struct iegbe_ps_page *ps_page;
+- struct iegbe_ps_page_dma *ps_page_dma;
+- struct sk_buff *skb;
+- unsigned int i, j;
+-
+- i = rx_ring->next_to_use;
+- buffer_info = &rx_ring->buffer_info[i];
+- ps_page = &rx_ring->ps_page[i];
+- ps_page_dma = &rx_ring->ps_page_dma[i];
++ struct iegbe_hw *hw = &adapter->hw;
++ struct net_device *netdev = adapter->netdev;
++ struct pci_dev *pdev = adapter->pdev;
++ union iegbe_rx_desc_packet_split *rx_desc;
++ struct iegbe_buffer *buffer_info;
++ struct iegbe_ps_page *ps_page;
++ struct iegbe_ps_page_dma *ps_page_dma;
++ struct sk_buff *skb;
++ unsigned int i, j;
++
++ i = rx_ring->next_to_use;
++ buffer_info = &rx_ring->buffer_info[i];
++ ps_page = &rx_ring->ps_page[i];
++ ps_page_dma = &rx_ring->ps_page_dma[i];
+
+-#ifdef IEGBE_GBE_WORKAROUND
+- while(cleaned_count-- && !buffer_info->skb) {
+-#else
+- while(!buffer_info->skb) {
+-#endif
+- rx_desc = E1000_RX_DESC_PS(*rx_ring, i);
++ while (cleaned_count--) {
++ rx_desc = E1000_RX_DESC_PS(*rx_ring, i);
+
+ for (j = 0; j < PS_PAGE_BUFFERS; j++) {
+- if (j < adapter->rx_ps_pages) {
+- if (likely(!ps_page->ps_page[j])) {
+- ps_page->ps_page[j] =
+- alloc_page(GFP_ATOMIC);
++ if (j < adapter->rx_ps_pages) {
++ if (likely(!ps_page->ps_page[j])) {
++ ps_page->ps_page[j] =
++ alloc_page(GFP_ATOMIC);
+ if (unlikely(!ps_page->ps_page[j])) {
+- goto no_buffers;
++ adapter->alloc_rx_buff_failed++;
++ goto no_buffers;
+ }
+- ps_page_dma->ps_page_dma[j] =
+- pci_map_page(pdev,
+- ps_page->ps_page[j],
++ ps_page_dma->ps_page_dma[j] =
++ pci_map_page(pdev,
++ ps_page->ps_page[j],
+ 0, PAGE_SIZE,
+ PCI_DMA_FROMDEVICE);
+ }
+@@ -4462,26 +4196,26 @@ iegbe_alloc_rx_buffers_ps(struct iegbe_a
+ * change because each write-back erases
+ * this info.
+ */
+- rx_desc->read.buffer_addr[j+0x1] =
++ rx_desc->read.buffer_addr[j+1] =
+ cpu_to_le64(ps_page_dma->ps_page_dma[j]);
+- } else {
+- rx_desc->read.buffer_addr[j+0x1] = ~0;
+- }
++ } else
++ rx_desc->read.buffer_addr[j+1] = ~cpu_to_le64(0);
+ }
+
+- skb = dev_alloc_skb(adapter->rx_ps_bsize0 + NET_IP_ALIGN);
++ skb = netdev_alloc_skb(netdev,
++ adapter->rx_ps_bsize0 + NET_IP_ALIGN);
+
+- if (unlikely(!skb)) {
++ if (unlikely(!skb)) {
++ adapter->alloc_rx_buff_failed++;
+ break;
+- }
++ }
++
+ /* Make buffer alignment 2 beyond a 16 byte boundary
+ * this will result in a 16 byte aligned IP header after
+ * the 14 byte MAC header is removed
+ */
+ skb_reserve(skb, NET_IP_ALIGN);
+
+- skb->dev = netdev;
+-
+ buffer_info->skb = skb;
+ buffer_info->length = adapter->rx_ps_bsize0;
+ buffer_info->dma = pci_map_single(pdev, skb->data,
+@@ -4490,27 +4224,28 @@ iegbe_alloc_rx_buffers_ps(struct iegbe_a
+
+ rx_desc->read.buffer_addr[0] = cpu_to_le64(buffer_info->dma);
+
+- if (unlikely((i & ~(E1000_RX_BUFFER_WRITE - 0x1)) == i)) {
+- /* Force memory writes to complete before letting h/w
+- * know there are new descriptors to fetch. (Only
+- * applicable for weak-ordered memory model archs,
+- * such as IA-64). */
+- wmb();
+- /* Hardware increments by 16 bytes, but packet split
+- * descriptors are 32 bytes...so we increment tail
+- * twice as much.
+- */
+- writel(i<<1, adapter->hw.hw_addr + rx_ring->rdt);
+- }
+-
+- if (unlikely(++i == rx_ring->count)) { i = 0; }
++ if (unlikely(++i == rx_ring->count)) i = 0;
+ buffer_info = &rx_ring->buffer_info[i];
+ ps_page = &rx_ring->ps_page[i];
+ ps_page_dma = &rx_ring->ps_page_dma[i];
+ }
+
+ no_buffers:
+- rx_ring->next_to_use = i;
++ if (likely(rx_ring->next_to_use != i)) {
++ rx_ring->next_to_use = i;
++ if (unlikely(i-- == 0)) i = (rx_ring->count - 1);
++
++ /* Force memory writes to complete before letting h/w
++ * know there are new descriptors to fetch. (Only
++ * applicable for weak-ordered memory model archs,
++ * such as IA-64). */
++ wmb();
++ /* Hardware increments by 16 bytes, but packet split
++ * descriptors are 32 bytes...so we increment tail
++ * twice as much.
++ */
++ writel(i<<1, hw->hw_addr + rx_ring->rdt);
++ }
+ }
+
+ /**
+@@ -4521,52 +4256,52 @@ no_buffers:
+ static void
+ iegbe_smartspeed(struct iegbe_adapter *adapter)
+ {
+- uint16_t phy_status;
+- uint16_t phy_ctrl;
++ uint16_t phy_status;
++ uint16_t phy_ctrl;
+
+- if((adapter->hw.phy_type != iegbe_phy_igp) || !adapter->hw.autoneg ||
++ if((adapter->hw.phy_type != iegbe_phy_igp) || !adapter->hw.autoneg ||
+ !(adapter->hw.autoneg_advertised & ADVERTISE_1000_FULL)) {
+- return;
++ return;
+ }
+- if(adapter->smartspeed == 0) {
+- /* If Master/Slave config fault is asserted twice,
+- * we assume back-to-back */
+- iegbe_read_phy_reg(&adapter->hw, PHY_1000T_STATUS, &phy_status);
++ if(adapter->smartspeed == 0x0) {
++ /* If Master/Slave config fault is asserted twice,
++ * we assume back-to-back */
++ iegbe_read_phy_reg(&adapter->hw, PHY_1000T_STATUS, &phy_status);
+ if(!(phy_status & SR_1000T_MS_CONFIG_FAULT)) { return; }
+- iegbe_read_phy_reg(&adapter->hw, PHY_1000T_STATUS, &phy_status);
++ iegbe_read_phy_reg(&adapter->hw, PHY_1000T_STATUS, &phy_status);
+ if(!(phy_status & SR_1000T_MS_CONFIG_FAULT)) { return; }
+- iegbe_read_phy_reg(&adapter->hw, PHY_1000T_CTRL, &phy_ctrl);
+- if(phy_ctrl & CR_1000T_MS_ENABLE) {
+- phy_ctrl &= ~CR_1000T_MS_ENABLE;
+- iegbe_write_phy_reg(&adapter->hw, PHY_1000T_CTRL,
+- phy_ctrl);
+- adapter->smartspeed++;
+- if(!iegbe_phy_setup_autoneg(&adapter->hw) &&
+- !iegbe_read_phy_reg(&adapter->hw, PHY_CTRL,
+- &phy_ctrl)) {
+- phy_ctrl |= (MII_CR_AUTO_NEG_EN |
+- MII_CR_RESTART_AUTO_NEG);
+- iegbe_write_phy_reg(&adapter->hw, PHY_CTRL,
+- phy_ctrl);
+- }
+- }
+- return;
+- } else if(adapter->smartspeed == E1000_SMARTSPEED_DOWNSHIFT) {
+- /* If still no link, perhaps using 2/3 pair cable */
+- iegbe_read_phy_reg(&adapter->hw, PHY_1000T_CTRL, &phy_ctrl);
+- phy_ctrl |= CR_1000T_MS_ENABLE;
+- iegbe_write_phy_reg(&adapter->hw, PHY_1000T_CTRL, phy_ctrl);
+- if(!iegbe_phy_setup_autoneg(&adapter->hw) &&
+- !iegbe_read_phy_reg(&adapter->hw, PHY_CTRL, &phy_ctrl)) {
+- phy_ctrl |= (MII_CR_AUTO_NEG_EN |
+- MII_CR_RESTART_AUTO_NEG);
+- iegbe_write_phy_reg(&adapter->hw, PHY_CTRL, phy_ctrl);
+- }
+- }
+- /* Restart process after E1000_SMARTSPEED_MAX iterations */
++ iegbe_read_phy_reg(&adapter->hw, PHY_1000T_CTRL, &phy_ctrl);
++ if(phy_ctrl & CR_1000T_MS_ENABLE) {
++ phy_ctrl &= ~CR_1000T_MS_ENABLE;
++ iegbe_write_phy_reg(&adapter->hw, PHY_1000T_CTRL,
++ phy_ctrl);
++ adapter->smartspeed++;
++ if(!iegbe_phy_setup_autoneg(&adapter->hw) &&
++ !iegbe_read_phy_reg(&adapter->hw, PHY_CTRL,
++ &phy_ctrl)) {
++ phy_ctrl |= (MII_CR_AUTO_NEG_EN |
++ MII_CR_RESTART_AUTO_NEG);
++ iegbe_write_phy_reg(&adapter->hw, PHY_CTRL,
++ phy_ctrl);
++ }
++ }
++ return;
++ } else if(adapter->smartspeed == E1000_SMARTSPEED_DOWNSHIFT) {
++ /* If still no link, perhaps using 2/3 pair cable */
++ iegbe_read_phy_reg(&adapter->hw, PHY_1000T_CTRL, &phy_ctrl);
++ phy_ctrl |= CR_1000T_MS_ENABLE;
++ iegbe_write_phy_reg(&adapter->hw, PHY_1000T_CTRL, phy_ctrl);
++ if(!iegbe_phy_setup_autoneg(&adapter->hw) &&
++ !iegbe_read_phy_reg(&adapter->hw, PHY_CTRL, &phy_ctrl)) {
++ phy_ctrl |= (MII_CR_AUTO_NEG_EN |
++ MII_CR_RESTART_AUTO_NEG);
++ iegbe_write_phy_reg(&adapter->hw, PHY_CTRL, phy_ctrl);
++ }
++ }
++ /* Restart process after E1000_SMARTSPEED_MAX iterations */
+ if(adapter->smartspeed++ == E1000_SMARTSPEED_MAX) {
+- adapter->smartspeed = 0;
+-}
++ adapter->smartspeed = 0x0;
++ }
+ }
+
+ /**
+@@ -4576,23 +4311,22 @@ iegbe_smartspeed(struct iegbe_adapter *a
+ * @cmd:
+ **/
+
+-static int
+-iegbe_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
++static int iegbe_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
+ {
+- switch (cmd) {
++ switch (cmd) {
+ #ifdef SIOCGMIIPHY
+- case SIOCGMIIPHY:
+- case SIOCGMIIREG:
+- case SIOCSMIIREG:
+- return iegbe_mii_ioctl(netdev, ifr, cmd);
++ case SIOCGMIIPHY:
++ case SIOCGMIIREG:
++ case SIOCSMIIREG:
++ return iegbe_mii_ioctl(netdev, ifr, cmd);
+ #endif
+ #ifdef ETHTOOL_OPS_COMPAT
+- case SIOCETHTOOL:
+- return ethtool_ioctl(ifr);
++ case SIOCETHTOOL:
++ return ethtool_ioctl(ifr);
+ #endif
+- default:
+- return -EOPNOTSUPP;
+- }
++ default:
++ return -EOPNOTSUPP;
++ }
+ }
+
+ #ifdef SIOCGMIIPHY
+@@ -4603,534 +4337,510 @@ iegbe_ioctl(struct net_device *netdev, s
+ * @cmd:
+ **/
+
+-static int
+-iegbe_mii_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
++static int iegbe_mii_ioctl(struct net_device *netdev, struct ifreq *ifr,
++ int cmd)
+ {
+- struct iegbe_adapter *adapter = netdev_priv(netdev);
+- struct mii_ioctl_data *data = if_mii(ifr);
+- int retval;
+- uint16_t mii_reg;
+- uint16_t spddplx;
+- unsigned long flags;
+-
+- if((adapter->hw.media_type == iegbe_media_type_oem &&
+- !iegbe_oem_phy_is_copper(&adapter->hw)) ||
+- adapter->hw.media_type == iegbe_media_type_fiber ||
+- adapter->hw.media_type == iegbe_media_type_internal_serdes ) {
+- return -EOPNOTSUPP;
+- }
+- switch (cmd) {
+- case SIOCGMIIPHY:
+- data->phy_id = adapter->hw.phy_addr;
+- break;
+- case SIOCGMIIREG:
++ struct iegbe_adapter *adapter = netdev_priv(netdev);
++ struct mii_ioctl_data *data = if_mii(ifr);
++ int retval;
++ uint16_t mii_reg;
++ uint16_t spddplx;
++ unsigned long flags = 0;
++
++ if((adapter->hw.media_type == iegbe_media_type_oem
++ && !iegbe_oem_phy_is_copper(&adapter->hw))
++ ||adapter->hw.media_type != iegbe_media_type_copper) {
++ return -EOPNOTSUPP;
++ }
++ switch (cmd) {
++ case SIOCGMIIPHY:
++ data->phy_id = adapter->hw.phy_addr;
++ break;
++ case SIOCGMIIREG:
+ if(!capable(CAP_NET_ADMIN)) {
+- return -EPERM;
++ return -EPERM;
+ }
+- spin_lock_irqsave(&adapter->stats_lock, flags);
+- if(iegbe_read_phy_reg(&adapter->hw, data->reg_num & 0x1F,
+- &data->val_out)) {
+- spin_unlock_irqrestore(&adapter->stats_lock, flags);
+- return -EIO;
+- }
+- spin_unlock_irqrestore(&adapter->stats_lock, flags);
+- break;
+- case SIOCSMIIREG:
++ spin_lock_irqsave(&adapter->stats_lock, flags);
++ if(iegbe_read_phy_reg(&adapter->hw, data->reg_num & 0x1F,
++ &data->val_out)) {
++ spin_unlock_irqrestore(&adapter->stats_lock, flags);
++ return -EIO;
++ }
++ spin_unlock_irqrestore(&adapter->stats_lock, flags);
++ break;
++ case SIOCSMIIREG:
+ if(!capable(CAP_NET_ADMIN)){
+- return -EPERM;
++ return -EPERM;
+ }
+ if(data->reg_num & ~(0x1F)) {
+- return -EFAULT;
++ return -EFAULT;
+ }
+- mii_reg = data->val_in;
+- spin_lock_irqsave(&adapter->stats_lock, flags);
+- if(iegbe_write_phy_reg(&adapter->hw, data->reg_num,
+- mii_reg)) {
+- spin_unlock_irqrestore(&adapter->stats_lock, flags);
+- return -EIO;
+- }
+- switch(adapter->hw.phy_type) {
+- case iegbe_phy_m88:
+- switch (data->reg_num) {
+- case PHY_CTRL:
++ mii_reg = data->val_in;
++ spin_lock_irqsave(&adapter->stats_lock, flags);
++ if(iegbe_write_phy_reg(&adapter->hw, data->reg_num,
++ mii_reg)) {
++ spin_unlock_irqrestore(&adapter->stats_lock, flags);
++ return -EIO;
++ }
++ switch(adapter->hw.phy_type) {
++ case iegbe_phy_m88:
++ switch (data->reg_num) {
++ case PHY_CTRL:
+ if(mii_reg & MII_CR_POWER_DOWN) {
+- break;
++ break;
+ }
+- if(mii_reg & MII_CR_AUTO_NEG_EN) {
+- adapter->hw.autoneg = 1;
+- adapter->hw.autoneg_advertised = 0x2F;
+- } else {
++ if(mii_reg & MII_CR_AUTO_NEG_EN) {
++ adapter->hw.autoneg = 1;
++ adapter->hw.autoneg_advertised = 0x2F;
++ } else {
+ if(mii_reg & 0x40){
+- spddplx = SPEED_1000;
++ spddplx = SPEED_1000;
+ } else if(mii_reg & 0x2000) {
+- spddplx = SPEED_100;
++ spddplx = SPEED_100;
+ } else {
+- spddplx = SPEED_10;
++ spddplx = SPEED_10;
+ }
+- spddplx += (mii_reg & 0x100)
+- ? FULL_DUPLEX :
+- HALF_DUPLEX;
+- retval = iegbe_set_spd_dplx(adapter,
+- spddplx);
+- if(retval) {
+- spin_unlock_irqrestore(
+- &adapter->stats_lock,
+- flags);
+- return retval;
+- }
+- }
+- if(netif_running(adapter->netdev)) {
+- iegbe_down(adapter);
+- iegbe_up(adapter);
++ spddplx += (mii_reg & 0x100)
++ ? FULL_DUPLEX :
++ HALF_DUPLEX;
++ retval = iegbe_set_spd_dplx(adapter,
++ spddplx);
++ if(retval) {
++ spin_unlock_irqrestore(
++ &adapter->stats_lock,
++ flags);
++ return retval;
++ }
++ }
++ if(netif_running(adapter->netdev)) {
++ iegbe_down(adapter);
++ iegbe_up(adapter);
+ } else {
+- iegbe_reset(adapter);
++ iegbe_reset(adapter);
+ }
+- break;
+- case M88E1000_PHY_SPEC_CTRL:
+- case M88E1000_EXT_PHY_SPEC_CTRL:
+- if(iegbe_phy_reset(&adapter->hw)) {
+- spin_unlock_irqrestore(
+- &adapter->stats_lock, flags);
+- return -EIO;
+- }
+- break;
+- }
+- break;
++ break;
++ case M88E1000_PHY_SPEC_CTRL:
++ case M88E1000_EXT_PHY_SPEC_CTRL:
++ if(iegbe_phy_reset(&adapter->hw)) {
++ spin_unlock_irqrestore(
++ &adapter->stats_lock, flags);
++ return -EIO;
++ }
++ break;
++ }
++ break;
+
+- case iegbe_phy_oem:
+- retval = iegbe_oem_mii_ioctl(adapter, flags, ifr, cmd);
+- if(retval) {
+- spin_unlock_irqrestore(
+- &adapter->stats_lock, flags);
+- return retval;
+- }
+- break;
++ case iegbe_phy_oem:
++ retval = iegbe_oem_mii_ioctl(adapter, flags, ifr, cmd);
++ if(retval) {
++ spin_unlock_irqrestore(
++ &adapter->stats_lock, flags);
++ return retval;
++ }
++ break;
+
+- default:
+- switch (data->reg_num) {
+- case PHY_CTRL:
++ default:
++ switch (data->reg_num) {
++ case PHY_CTRL:
+ if(mii_reg & MII_CR_POWER_DOWN) {
+- break;
++ break;
+ }
+- if(netif_running(adapter->netdev)) {
+- iegbe_down(adapter);
+- iegbe_up(adapter);
++ if(netif_running(adapter->netdev)) {
++ iegbe_down(adapter);
++ iegbe_up(adapter);
+ } else {
+- iegbe_reset(adapter);
++ iegbe_reset(adapter);
+ }
+- break;
+- }
+- }
+- spin_unlock_irqrestore(&adapter->stats_lock, flags);
+- break;
+- default:
+- return -EOPNOTSUPP;
+- }
+- return E1000_SUCCESS;
++ break;
++ }
++ }
++ spin_unlock_irqrestore(&adapter->stats_lock, flags);
++ break;
++ default:
++ return -EOPNOTSUPP;
++ }
++ return E1000_SUCCESS;
+ }
+ #endif
+
+-void
+-iegbe_pci_set_mwi(struct iegbe_hw *hw)
++void iegbe_pci_set_mwi(struct iegbe_hw *hw)
+ {
+- struct iegbe_adapter *adapter = hw->back;
+-#ifdef HAVE_PCI_SET_MWI
+- int ret_val = pci_set_mwi(adapter->pdev);
+-
+- if(ret_val) {
+- DPRINTK(PROBE, ERR, "Error in setting MWI\n");
+- }
+-#else
+- pci_write_config_word(adapter->pdev, PCI_COMMAND,
+- adapter->hw.pci_cmd_word |
+- PCI_COMMAND_INVALIDATE);
+-#endif
++ struct iegbe_adapter *adapter = hw->back;
++ int ret_val = pci_set_mwi(adapter->pdev);
++
++ if (ret_val)
++ DPRINTK(PROBE, ERR, "Error in setting MWI\n");
+ }
+
+-void
+-iegbe_pci_clear_mwi(struct iegbe_hw *hw)
++void iegbe_pci_clear_mwi(struct iegbe_hw *hw)
+ {
+- struct iegbe_adapter *adapter = hw->back;
++ struct iegbe_adapter *adapter = hw->back;
+
+-#ifdef HAVE_PCI_SET_MWI
+- pci_clear_mwi(adapter->pdev);
+-#else
+- pci_write_config_word(adapter->pdev, PCI_COMMAND,
+- adapter->hw.pci_cmd_word &
+- ~PCI_COMMAND_INVALIDATE);
+-#endif
++ pci_clear_mwi(adapter->pdev);
+ }
+
+ void
+ iegbe_read_pci_cfg(struct iegbe_hw *hw, uint32_t reg, uint16_t *value)
+ {
+- struct iegbe_adapter *adapter = hw->back;
++ struct iegbe_adapter *adapter = hw->back;
+
+- pci_read_config_word(adapter->pdev, reg, value);
++ pci_read_config_word(adapter->pdev, reg, value);
+ }
+
+ void
+ iegbe_write_pci_cfg(struct iegbe_hw *hw, uint32_t reg, uint16_t *value)
+ {
+- struct iegbe_adapter *adapter = hw->back;
++ struct iegbe_adapter *adapter = hw->back;
+
+- pci_write_config_word(adapter->pdev, reg, *value);
++ pci_write_config_word(adapter->pdev, reg, *value);
+ }
+
+ uint32_t
+ iegbe_io_read(struct iegbe_hw *hw, unsigned long port)
+ {
+- return inl(port);
++ return inl(port);
+ }
+
+ void
+ iegbe_io_write(struct iegbe_hw *hw, unsigned long port, uint32_t value)
+ {
+- outl(value, port);
++ outl(value, port);
+ }
+
+-#ifdef NETIF_F_HW_VLAN_TX
+-static void
+-iegbe_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp)
++static void iegbe_vlan_rx_register(struct net_device *netdev,
++ struct vlan_group *grp)
+ {
+- struct iegbe_adapter *adapter = netdev_priv(netdev);
+- uint32_t ctrl, rctl;
+-
+- iegbe_irq_disable(adapter);
+- adapter->vlgrp = grp;
+-
+- if(grp) {
+- /* enable VLAN tag insert/strip */
+- ctrl = E1000_READ_REG(&adapter->hw, CTRL);
+- ctrl |= E1000_CTRL_VME;
+- E1000_WRITE_REG(&adapter->hw, CTRL, ctrl);
+-
+- /* enable VLAN receive filtering */
+- rctl = E1000_READ_REG(&adapter->hw, RCTL);
+- rctl |= E1000_RCTL_VFE;
+- rctl &= ~E1000_RCTL_CFIEN;
+- E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
+- iegbe_update_mng_vlan(adapter);
+- } else {
+- /* disable VLAN tag insert/strip */
+- ctrl = E1000_READ_REG(&adapter->hw, CTRL);
+- ctrl &= ~E1000_CTRL_VME;
+- E1000_WRITE_REG(&adapter->hw, CTRL, ctrl);
++ struct iegbe_adapter *adapter = netdev_priv(netdev);
++ uint32_t ctrl, rctl;
+
+- /* disable VLAN filtering */
+- rctl = E1000_READ_REG(&adapter->hw, RCTL);
+- rctl &= ~E1000_RCTL_VFE;
+- E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
+- if(adapter->mng_vlan_id != (uint16_t)E1000_MNG_VLAN_NONE) {
+- iegbe_vlan_rx_kill_vid(netdev, adapter->mng_vlan_id);
+- adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
+- }
+- }
++ if (!test_bit(__E1000_DOWN, &adapter->flags))
++ iegbe_irq_disable(adapter);
++ adapter->vlgrp = grp;
++
++ if(grp) {
++ /* enable VLAN tag insert/strip */
++ ctrl = E1000_READ_REG(&adapter->hw, CTRL);
++ ctrl |= E1000_CTRL_VME;
++ E1000_WRITE_REG(&adapter->hw, CTRL, ctrl);
++
++ /* enable VLAN receive filtering */
++ rctl = E1000_READ_REG(&adapter->hw, RCTL);
++ rctl |= E1000_RCTL_VFE;
++ rctl &= ~E1000_RCTL_CFIEN;
++ E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
++ iegbe_update_mng_vlan(adapter);
++ } else {
++ /* disable VLAN tag insert/strip */
++ ctrl = E1000_READ_REG(&adapter->hw, CTRL);
++ ctrl &= ~E1000_CTRL_VME;
++ E1000_WRITE_REG(&adapter->hw, CTRL, ctrl);
++
++ /* disable VLAN filtering */
++ rctl = E1000_READ_REG(&adapter->hw, RCTL);
++ rctl &= ~E1000_RCTL_VFE;
++ E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
++ if(adapter->mng_vlan_id != (uint16_t)E1000_MNG_VLAN_NONE) {
++ iegbe_vlan_rx_kill_vid(netdev, adapter->mng_vlan_id);
++ adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
++ }
++ }
+
+- iegbe_irq_enable(adapter);
++ if (!test_bit(__E1000_DOWN, &adapter->flags))
++ iegbe_irq_enable(adapter);
+ }
+
+-static void
+-iegbe_vlan_rx_add_vid(struct net_device *netdev, uint16_t vid)
++static void iegbe_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
+ {
+- struct iegbe_adapter *adapter = netdev_priv(netdev);
+- uint32_t vfta, index;
+- if((adapter->hw.mng_cookie.status &
+- E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) &&
++ struct iegbe_adapter *adapter = netdev_priv(netdev);
++ uint32_t vfta, index;
++ if((adapter->hw.mng_cookie.status &
++ E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) &&
+ (vid == adapter->mng_vlan_id)) {
+- return;
++ return;
+ }
+- /* add VID to filter table */
++ /* add VID to filter table */
+ index = (vid >> 0x5) & 0x7F;
+- vfta = E1000_READ_REG_ARRAY(&adapter->hw, VFTA, index);
++ vfta = E1000_READ_REG_ARRAY(&adapter->hw, VFTA, index);
+ vfta |= (0x1 << (vid & 0x1F));
+- iegbe_write_vfta(&adapter->hw, index, vfta);
++ iegbe_write_vfta(&adapter->hw, index, vfta);
+ }
+
+-static void
+-iegbe_vlan_rx_kill_vid(struct net_device *netdev, uint16_t vid)
++static void iegbe_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
+ {
+ struct iegbe_adapter *adapter = netdev_priv(netdev);
+- uint32_t vfta, index;
++ u32 vfta, index;
+
++ if (!test_bit(__E1000_DOWN, &adapter->flags))
+ iegbe_irq_disable(adapter);
+-
+- if(adapter->vlgrp) {
+- adapter->vlgrp->vlan_devices[vid] = NULL;
+- }
++ vlan_group_set_device(adapter->vlgrp, vid, NULL);
++ if (!test_bit(__E1000_DOWN, &adapter->flags))
+ iegbe_irq_enable(adapter);
+
+- if((adapter->hw.mng_cookie.status &
+- E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) &&
+- (vid == adapter->mng_vlan_id)) {
+- return;
+- }
+ /* remove VID from filter table */
+- index = (vid >> 0x5) & 0x7F;
++ index = (vid >> 0x5) & 0x7F;
+ vfta = E1000_READ_REG_ARRAY(&adapter->hw, VFTA, index);
+- vfta &= ~(0x1 << (vid & 0x1F));
++ vfta &= ~(0x1 << (vid & 0x1F));
+ iegbe_write_vfta(&adapter->hw, index, vfta);
+ }
+
+-static void
+-iegbe_restore_vlan(struct iegbe_adapter *adapter)
++static void iegbe_restore_vlan(struct iegbe_adapter *adapter)
+ {
+ iegbe_vlan_rx_register(adapter->netdev, adapter->vlgrp);
+
+- if(adapter->vlgrp) {
+- uint16_t vid;
+- for(vid = 0; vid < VLAN_GROUP_ARRAY_LEN; vid++) {
+- if(!adapter->vlgrp->vlan_devices[vid]) {
++ if (adapter->vlgrp) {
++ u16 vid;
++ for (vid = 0x0; vid < VLAN_GROUP_ARRAY_LEN; vid++) {
++ if (!vlan_group_get_device(adapter->vlgrp, vid))
+ continue;
+- }
+ iegbe_vlan_rx_add_vid(adapter->netdev, vid);
+ }
+ }
+ }
+-#endif
+
+-int
+-iegbe_set_spd_dplx(struct iegbe_adapter *adapter, uint16_t spddplx)
++
++int iegbe_set_spd_dplx(struct iegbe_adapter *adapter, u16 spddplx)
+ {
+- adapter->hw.autoneg = 0;
++ adapter->hw.autoneg = 0x0;
+
+- /* Fiber NICs only allow 1000 gbps Full duplex */
+- if((adapter->hw.media_type == iegbe_media_type_fiber
++ /* Fiber NICs only allow 1000 gbps Full duplex */
++ if((adapter->hw.media_type == iegbe_media_type_fiber
+ || (adapter->hw.media_type == iegbe_media_type_oem
+ && !iegbe_oem_phy_is_copper(&adapter->hw)))
+- && spddplx != (SPEED_1000 + FULL_DUPLEX)) {
+- DPRINTK(PROBE, ERR, "Unsupported Speed/Duplex configuration\n");
+- return -EINVAL;
+- }
+-
+- switch(spddplx) {
+- case SPEED_10 + HALF_DUPLEX:
+- adapter->hw.forced_speed_duplex = iegbe_10_half;
+- break;
+- case SPEED_10 + FULL_DUPLEX:
+- adapter->hw.forced_speed_duplex = iegbe_10_full;
+- break;
+- case SPEED_100 + HALF_DUPLEX:
+- adapter->hw.forced_speed_duplex = iegbe_100_half;
+- break;
+- case SPEED_100 + FULL_DUPLEX:
+- adapter->hw.forced_speed_duplex = iegbe_100_full;
+- break;
+- case SPEED_1000 + FULL_DUPLEX:
++ && spddplx != (SPEED_1000 + DUPLEX_FULL)) {
++ DPRINTK(PROBE, ERR, "Unsupported Speed/Duplex configuration\n");
++ return -EINVAL;
++ }
++
++ switch(spddplx) {
++ case SPEED_10 + DUPLEX_HALF:
++ adapter->hw.forced_speed_duplex = iegbe_10_half;
++ break;
++ case SPEED_10 + DUPLEX_FULL:
++ adapter->hw.forced_speed_duplex = iegbe_10_full;
++ break;
++ case SPEED_100 + DUPLEX_HALF:
++ adapter->hw.forced_speed_duplex = iegbe_100_half;
++ break;
++ case SPEED_100 + DUPLEX_FULL:
++ adapter->hw.forced_speed_duplex = iegbe_100_full;
++ break;
++ case SPEED_1000 + DUPLEX_FULL:
+ adapter->hw.autoneg = 0x1;
+- adapter->hw.autoneg_advertised = ADVERTISE_1000_FULL;
+- break;
+- case SPEED_1000 + HALF_DUPLEX: /* not supported */
+- default:
+- DPRINTK(PROBE, ERR, "Unsupported Speed/Duplex configuration\n");
+- return -EINVAL;
+- }
+- return 0;
++ adapter->hw.autoneg_advertised = ADVERTISE_1000_FULL;
++ break;
++ case SPEED_1000 + DUPLEX_HALF: /* not supported */
++ default:
++ DPRINTK(PROBE, ERR, "Unsupported Speed/Duplex configuration\n");
++ return -EINVAL;
++ }
++ return 0x0;
+ }
+
+ static int
+ iegbe_notify_reboot(struct notifier_block *nb, unsigned long event, void *p)
+ {
+- struct pci_dev *pdev = NULL;
++ struct pci_dev *pdev = NULL;
+ pm_message_t state = {0x3};
+
+
+- switch(event) {
+- case SYS_DOWN:
+- case SYS_HALT:
+- case SYS_POWER_OFF:
+- while((pdev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pdev))) {
++ switch(event) {
++ case SYS_DOWN:
++ case SYS_HALT:
++ case SYS_POWER_OFF:
++ while((pdev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pdev))) {
+ if(pci_dev_driver(pdev) == &iegbe_driver) {
+- iegbe_suspend(pdev, state);
+- }
+- }
++ iegbe_suspend(pdev, state);
++ }
++ }
+ }
+- return NOTIFY_DONE;
++ return NOTIFY_DONE;
+ }
+
+ static int
+ iegbe_suspend(struct pci_dev *pdev, pm_message_t state)
+ {
+- struct net_device *netdev = pci_get_drvdata(pdev);
+- struct iegbe_adapter *adapter = netdev_priv(netdev);
+- uint32_t ctrl, ctrl_ext, rctl, manc, status, swsm;
+- uint32_t wufc = adapter->wol;
+- uint16_t cmd_word;
++ struct net_device *netdev = pci_get_drvdata(pdev);
++ struct iegbe_adapter *adapter = netdev_priv(netdev);
++ uint32_t ctrl, ctrl_ext, rctl, manc, status, swsm;
++ uint32_t wufc = adapter->wol;
++ uint16_t cmd_word;
+
+- netif_device_detach(netdev);
++ netif_device_detach(netdev);
+
+ if(netif_running(netdev)) {
+- iegbe_down(adapter);
++ WARN_ON(test_bit(__E1000_RESETTING, &adapter->flags));
++ iegbe_down(adapter);
+ }
+- /*
+- * ICP_XXXX style MACs do not have a link up bit in
+- * the STATUS register, query the PHY directly
+- */
+- if(adapter->hw.mac_type != iegbe_icp_xxxx) {
+- status = E1000_READ_REG(&adapter->hw, STATUS);
++ /*
++ * ICP_XXXX style MACs do not have a link up bit in
++ * the STATUS register, query the PHY directly
++ */
++ if(adapter->hw.mac_type != iegbe_icp_xxxx) {
++ status = E1000_READ_REG(&adapter->hw, STATUS);
+ if(status & E1000_STATUS_LU) {
+- wufc &= ~E1000_WUFC_LNKC;
++ wufc &= ~E1000_WUFC_LNKC;
+ }
+- } else {
+- int isUp = 0;
++ } else {
++ int isUp = 0x0;
+ if(iegbe_oem_phy_is_link_up(&adapter->hw, &isUp) != E1000_SUCCESS) {
+- isUp = 0;
++ isUp = 0x0;
+ }
+ if(isUp) {
+- wufc &= ~E1000_WUFC_LNKC;
+- }
++ wufc &= ~E1000_WUFC_LNKC;
++ }
+ }
+
+- if(wufc) {
+- iegbe_setup_rctl(adapter);
+- iegbe_set_multi(netdev);
+-
+- /* turn on all-multi mode if wake on multicast is enabled */
+- if(adapter->wol & E1000_WUFC_MC) {
+- rctl = E1000_READ_REG(&adapter->hw, RCTL);
+- rctl |= E1000_RCTL_MPE;
+- E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
+- }
++ if(wufc) {
++ iegbe_setup_rctl(adapter);
++ iegbe_set_rx_mode(netdev);
++
++ /* turn on all-multi mode if wake on multicast is enabled */
++ if(adapter->wol & E1000_WUFC_MC) {
++ rctl = E1000_READ_REG(&adapter->hw, RCTL);
++ rctl |= E1000_RCTL_MPE;
++ E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
++ }
+
+- if(adapter->hw.mac_type >= iegbe_82540) {
+- ctrl = E1000_READ_REG(&adapter->hw, CTRL);
+- /* advertise wake from D3Cold */
+- #define E1000_CTRL_ADVD3WUC 0x00100000
+- /* phy power management enable */
+- ctrl |= E1000_CTRL_ADVD3WUC |
+- (adapter->hw.mac_type != iegbe_icp_xxxx
+- ? E1000_CTRL_EN_PHY_PWR_MGMT : 0);
++ if(adapter->hw.mac_type >= iegbe_82540) {
++ ctrl = E1000_READ_REG(&adapter->hw, CTRL);
++ /* advertise wake from D3Cold */
++ #define E1000_CTRL_ADVD3WUC 0x00100000
++ /* phy power management enable */
++ #define E1000_CTRL_EN_PHY_PWR_MGMT 0x00200000
++ ctrl |= E1000_CTRL_ADVD3WUC |
++ (adapter->hw.mac_type != iegbe_icp_xxxx
++ ? E1000_CTRL_EN_PHY_PWR_MGMT : 0x0);
+
+- E1000_WRITE_REG(&adapter->hw, CTRL, ctrl);
+- }
++ E1000_WRITE_REG(&adapter->hw, CTRL, ctrl);
++ }
+
+- if(adapter->hw.media_type == iegbe_media_type_fiber ||
+- adapter->hw.media_type == iegbe_media_type_internal_serdes) {
+- /* keep the laser running in D3 */
+- ctrl_ext = E1000_READ_REG(&adapter->hw, CTRL_EXT);
+- ctrl_ext |= E1000_CTRL_EXT_SDP7_DATA;
+- E1000_WRITE_REG(&adapter->hw, CTRL_EXT, ctrl_ext);
+- }
++ if(adapter->hw.media_type == iegbe_media_type_fiber ||
++ adapter->hw.media_type == iegbe_media_type_internal_serdes) {
++ /* keep the laser running in D3 */
++ ctrl_ext = E1000_READ_REG(&adapter->hw, CTRL_EXT);
++ ctrl_ext |= E1000_CTRL_EXT_SDP7_DATA;
++ E1000_WRITE_REG(&adapter->hw, CTRL_EXT, ctrl_ext);
++ }
+
+ /* Allow OEM PHYs (if any exist) to keep the laser
+ *running in D3 */
+ iegbe_oem_fiber_live_in_suspend(&adapter->hw);
+
+- /* Allow time for pending master requests to run */
+- iegbe_disable_pciex_master(&adapter->hw);
++ /* Allow time for pending master requests to run */
++ iegbe_disable_pciex_master(&adapter->hw);
+
+- E1000_WRITE_REG(&adapter->hw, WUC, E1000_WUC_PME_EN);
+- E1000_WRITE_REG(&adapter->hw, WUFC, wufc);
++ E1000_WRITE_REG(&adapter->hw, WUC, E1000_WUC_PME_EN);
++ E1000_WRITE_REG(&adapter->hw, WUFC, wufc);
+ pci_enable_wake(pdev, 0x3, 0x1);
+ pci_enable_wake(pdev, 0x4, 0x1); /* 4 == D3 cold */
+- } else {
+- E1000_WRITE_REG(&adapter->hw, WUC, 0);
+- E1000_WRITE_REG(&adapter->hw, WUFC, 0);
+- pci_enable_wake(pdev, 0x3, 0);
+- pci_enable_wake(pdev, 0x4, 0); /* 4 == D3 cold */
+- }
++ } else {
++ E1000_WRITE_REG(&adapter->hw, WUC, 0x0);
++ E1000_WRITE_REG(&adapter->hw, WUFC, 0x0);
++ pci_enable_wake(pdev, 0x3, 0x0);
++ pci_enable_wake(pdev, 0x4, 0x0); /* 4 == D3 cold */
++ }
+
+- pci_save_state(pdev);
+-
+- if(adapter->hw.mac_type >= iegbe_82540
+- && adapter->hw.mac_type != iegbe_icp_xxxx
+- && adapter->hw.media_type == iegbe_media_type_copper) {
+- manc = E1000_READ_REG(&adapter->hw, MANC);
+- if(manc & E1000_MANC_SMBUS_EN) {
+- manc |= E1000_MANC_ARP_EN;
+- E1000_WRITE_REG(&adapter->hw, MANC, manc);
++ pci_save_state(pdev);
++
++ if(adapter->hw.mac_type >= iegbe_82540
++ && adapter->hw.mac_type != iegbe_icp_xxxx
++ && adapter->hw.media_type == iegbe_media_type_copper) {
++ manc = E1000_READ_REG(&adapter->hw, MANC);
++ if(manc & E1000_MANC_SMBUS_EN) {
++ manc |= E1000_MANC_ARP_EN;
++ E1000_WRITE_REG(&adapter->hw, MANC, manc);
+ pci_enable_wake(pdev, 0x3, 0x1);
+ pci_enable_wake(pdev, 0x4, 0x1); /* 4 == D3 cold */
+- }
+- }
++ }
++ }
+
+- switch(adapter->hw.mac_type) {
+- case iegbe_82571:
+- case iegbe_82572:
+- ctrl_ext = E1000_READ_REG(&adapter->hw, CTRL_EXT);
+- E1000_WRITE_REG(&adapter->hw, CTRL_EXT,
+- ctrl_ext & ~E1000_CTRL_EXT_DRV_LOAD);
+- break;
+- case iegbe_82573:
+- swsm = E1000_READ_REG(&adapter->hw, SWSM);
+- E1000_WRITE_REG(&adapter->hw, SWSM,
+- swsm & ~E1000_SWSM_DRV_LOAD);
+- break;
+- default:
+- break;
+- }
++ switch(adapter->hw.mac_type) {
++ case iegbe_82571:
++ case iegbe_82572:
++ ctrl_ext = E1000_READ_REG(&adapter->hw, CTRL_EXT);
++ E1000_WRITE_REG(&adapter->hw, CTRL_EXT,
++ ctrl_ext & ~E1000_CTRL_EXT_DRV_LOAD);
++ break;
++ case iegbe_82573:
++ swsm = E1000_READ_REG(&adapter->hw, SWSM);
++ E1000_WRITE_REG(&adapter->hw, SWSM,
++ swsm & ~E1000_SWSM_DRV_LOAD);
++ break;
++ default:
++ break;
++ }
+
+- pci_disable_device(pdev);
+- if(adapter->hw.mac_type == iegbe_icp_xxxx) {
+- /*
+- * ICP xxxx devices are not true PCI devices, in the context
+- * of power management, disabling the bus mastership is not
+- * sufficient to disable the device, it is also necessary to
+- * disable IO, Memory, and Interrupts if they are enabled.
+- */
+- pci_read_config_word(pdev, PCI_COMMAND, &cmd_word);
++ pci_disable_device(pdev);
++ if(adapter->hw.mac_type == iegbe_icp_xxxx) {
++ /*
++ * ICP xxxx devices are not true PCI devices, in the context
++ * of power management, disabling the bus mastership is not
++ * sufficient to disable the device, it is also necessary to
++ * disable IO, Memory, and Interrupts if they are enabled.
++ */
++ pci_read_config_word(pdev, PCI_COMMAND, &cmd_word);
+ if(cmd_word & PCI_COMMAND_IO) {
+- cmd_word &= ~PCI_COMMAND_IO;
++ cmd_word &= ~PCI_COMMAND_IO;
+ }
+ if(cmd_word & PCI_COMMAND_MEMORY) {
+- cmd_word &= ~PCI_COMMAND_MEMORY;
++ cmd_word &= ~PCI_COMMAND_MEMORY;
+ }
+ if(cmd_word & PCI_COMMAND_INTX_DISABLE) {
+- cmd_word &= ~PCI_COMMAND_INTX_DISABLE;
++ cmd_word &= ~PCI_COMMAND_INTX_DISABLE;
+ }
+- pci_write_config_word(pdev, PCI_COMMAND, cmd_word);
+- }
++ pci_write_config_word(pdev, PCI_COMMAND, cmd_word);
++ }
+
+- state.event = (state.event > 0) ? 0x3 : 0;
+- pci_set_power_state(pdev, state.event);
+- if(gcu_suspend == 0)
++ state.event = (state.event > 0x0) ? 0x3 : 0x0;
++ pci_set_power_state(pdev, state.event);
++ if(gcu_suspend == 0x0)
+ {
+ if(gcu == NULL) {
+- gcu = pci_find_device(PCI_VENDOR_ID_INTEL, GCU_DEVID, NULL);
+- }
++ gcu = pci_get_device(PCI_VENDOR_ID_INTEL, GCU_DEVID, NULL);
++ }
+ gcu_iegbe_suspend(gcu, 0x3);
+- gcu_suspend = 1;
+- gcu_resume = 0;
++ gcu_suspend = 0x1;
++ gcu_resume = 0x0;
+ }
+- return 0;
++ return 0x0;
+ }
+
+ #ifdef CONFIG_PM
+ static int
+ iegbe_resume(struct pci_dev *pdev)
+ {
+- struct net_device *netdev = pci_get_drvdata(pdev);
+- struct iegbe_adapter *adapter = netdev_priv(netdev);
+- uint32_t manc, ret_val, swsm;
+- uint32_t ctrl_ext;
++ struct net_device *netdev = pci_get_drvdata(pdev);
++ struct iegbe_adapter *adapter = netdev_priv(netdev);
++ uint32_t manc, ret_val, swsm;
++ uint32_t ctrl_ext;
+ int offset;
+ uint32_t vdid;
+
+- if(gcu_resume == 0)
++ if(gcu_resume == 0x0)
+ {
+ if(gcu == NULL) {
+- gcu = pci_find_device(PCI_VENDOR_ID_INTEL, GCU_DEVID, NULL);
++ gcu = pci_get_device(PCI_VENDOR_ID_INTEL, GCU_DEVID, NULL);
+ pci_read_config_dword(gcu, 0x00, &vdid);
+- }
+-
++ }
++
+ if(gcu) {
+ gcu_iegbe_resume(gcu);
+- gcu_resume = 1;
+- gcu_suspend = 0;
++ gcu_resume = 0x1;
++ gcu_suspend = 0x0;
+ } else {
+ printk("Unable to resume GCU!\n");
+- }
++ }
+ }
+ pci_set_power_state(pdev, 0x0);
+- pci_restore_state(pdev);
+- ret_val = pci_enable_device(pdev);
+- pci_set_master(pdev);
++ pci_restore_state(pdev);
++ ret_val = pci_enable_device(pdev);
++ pci_set_master(pdev);
+
+ pci_enable_wake(pdev, 0x3, 0x0);
+ pci_enable_wake(pdev, 0x4, 0x0); /* 4 == D3 cold */
+
+- iegbe_reset(adapter);
+- E1000_WRITE_REG(&adapter->hw, WUS, ~0);
++ iegbe_reset(adapter);
++ E1000_WRITE_REG(&adapter->hw, WUS, ~0);
+ offset = pci_find_capability(adapter->pdev, PCI_CAP_ID_ST)
+ + PCI_ST_SMIA_OFFSET;
+ pci_write_config_dword(adapter->pdev, offset, 0x00000006);
+@@ -5138,51 +4848,52 @@ iegbe_resume(struct pci_dev *pdev)
+ E1000_WRITE_REG(&adapter->hw, IMC2, ~0UL);
+
+ if(netif_running(netdev)) {
+- iegbe_up(adapter);
++ iegbe_up(adapter);
+ }
+- netif_device_attach(netdev);
+-
+- if(adapter->hw.mac_type >= iegbe_82540
+- && adapter->hw.mac_type != iegbe_icp_xxxx
+- && adapter->hw.media_type == iegbe_media_type_copper) {
+- manc = E1000_READ_REG(&adapter->hw, MANC);
+- manc &= ~(E1000_MANC_ARP_EN);
+- E1000_WRITE_REG(&adapter->hw, MANC, manc);
+- }
++ netif_device_attach(netdev);
+
+- switch(adapter->hw.mac_type) {
+- case iegbe_82571:
+- case iegbe_82572:
+- ctrl_ext = E1000_READ_REG(&adapter->hw, CTRL_EXT);
+- E1000_WRITE_REG(&adapter->hw, CTRL_EXT,
+- ctrl_ext | E1000_CTRL_EXT_DRV_LOAD);
+- break;
+- case iegbe_82573:
+- swsm = E1000_READ_REG(&adapter->hw, SWSM);
+- E1000_WRITE_REG(&adapter->hw, SWSM,
+- swsm | E1000_SWSM_DRV_LOAD);
+- break;
+- default:
+- break;
+- }
++ if(adapter->hw.mac_type >= iegbe_82540
++ && adapter->hw.mac_type != iegbe_icp_xxxx
++ && adapter->hw.media_type == iegbe_media_type_copper) {
++ manc = E1000_READ_REG(&adapter->hw, MANC);
++ manc &= ~(E1000_MANC_ARP_EN);
++ E1000_WRITE_REG(&adapter->hw, MANC, manc);
++ }
++
++ switch(adapter->hw.mac_type) {
++ case iegbe_82571:
++ case iegbe_82572:
++ ctrl_ext = E1000_READ_REG(&adapter->hw, CTRL_EXT);
++ E1000_WRITE_REG(&adapter->hw, CTRL_EXT,
++ ctrl_ext | E1000_CTRL_EXT_DRV_LOAD);
++ break;
++ case iegbe_82573:
++ swsm = E1000_READ_REG(&adapter->hw, SWSM);
++ E1000_WRITE_REG(&adapter->hw, SWSM,
++ swsm | E1000_SWSM_DRV_LOAD);
++ break;
++ default:
++ break;
++ }
++#endif
+
+- return 0;
++ return 0x0;
+ }
+-#endif
++
+ #ifdef CONFIG_NET_POLL_CONTROLLER
+ /*
+ * Polling 'interrupt' - used by things like netconsole to send skbs
+ * without having to re-enable interrupts. It's not called while
+ * the interrupt routine is executing.
+ */
+-static void
+-iegbe_netpoll(struct net_device *netdev)
++static void iegbe_netpoll(struct net_device *netdev)
+ {
+- struct iegbe_adapter *adapter = netdev_priv(netdev);
+- disable_irq(adapter->pdev->irq);
+- iegbe_intr(adapter->pdev->irq, netdev, NULL);
+- enable_irq(adapter->pdev->irq);
++ struct iegbe_adapter *adapter = netdev_priv(netdev);
++ disable_irq(adapter->pdev->irq);
++ iegbe_intr(adapter->pdev->irq, netdev);
++ enable_irq(adapter->pdev->irq);
+ }
+ #endif
+
++
+ /* iegbe_main.c */
+--- a/Embedded/src/GbE/iegbe_oem_phy.c
++++ b/Embedded/src/GbE/iegbe_oem_phy.c
+@@ -2,31 +2,31 @@
+
+ GPL LICENSE SUMMARY
+
+- Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
++ Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
+
+- This program is free software; you can redistribute it and/or modify
++ This program is free software; you can redistribute it and/or modify
+ it under the terms of version 2 of the GNU General Public License as
+ published by the Free Software Foundation.
+
+- 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
++ 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; if not, write to the Free Software
++ 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., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+- The full GNU General Public License is included in this distribution
++ The full GNU General Public License is included in this distribution
+ in the file called LICENSE.GPL.
+
+ Contact Information:
+ Intel Corporation
+
+- version: Embedded.L.1.0.34
++ version: Embedded.Release.Patch.L.1.0.7-5
+
+ Contact Information:
+
+- Intel Corporation, 5000 W Chandler Blvd, Chandler, AZ 85226
++ Intel Corporation, 5000 W Chandler Blvd, Chandler, AZ 85226
+
+ *****************************************************************************/
+ /**************************************************************************
+@@ -65,11 +65,6 @@ static int32_t iegbe_oem_link_m88_setup(
+ static int32_t iegbe_oem_set_phy_mode(struct iegbe_hw *hw);
+ static int32_t iegbe_oem_detect_phy(struct iegbe_hw *hw);
+
+-/* Define specific BCM functions */
+-static int32_t iegbe_oem_link_bcm5481_setup(struct iegbe_hw *hw);
+-static int32_t bcm5481_read_18sv (struct iegbe_hw *hw, int sv, uint16_t *data);
+-static int32_t oi_phy_setup (struct iegbe_hw *hw);
+-
+ /**
+ * iegbe_oem_setup_link
+ * @hw: iegbe_hw struct containing device specific information
+@@ -84,7 +79,7 @@ iegbe_oem_setup_link(struct iegbe_hw *hw
+ {
+ #ifdef EXTERNAL_MDIO
+
+- /*
++ /*
+ * see iegbe_setup_copper_link() as the primary example. Look at both
+ * the M88 and IGP functions that are called for ideas, possibly for
+ * power management.
+@@ -102,14 +97,14 @@ iegbe_oem_setup_link(struct iegbe_hw *hw
+ }
+ /* AFU: add test to exit out if improper phy type
+ */
+- /* relevent parts of iegbe_copper_link_preconfig */
+- ctrl = E1000_READ_REG(hw, CTRL);
+- ctrl |= E1000_CTRL_SLU;
+- ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
+- E1000_WRITE_REG(hw, CTRL, ctrl);
+-
++ /* relevent parts of iegbe_copper_link_preconfig */
++ ctrl = E1000_READ_REG(hw, CTRL);
++ ctrl |= E1000_CTRL_SLU;
++ ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
++ E1000_WRITE_REG(hw, CTRL, ctrl);
++
+ /* this is required for *hw init */
+- ret_val = iegbe_oem_detect_phy(hw);
++ ret_val = iegbe_oem_detect_phy(hw);
+ if(ret_val) {
+ return ret_val;
+ }
+@@ -119,23 +114,13 @@ iegbe_oem_setup_link(struct iegbe_hw *hw
+ }
+
+ switch (hw->phy_id) {
+- case BCM5395S_PHY_ID:
+- return E1000_SUCCESS;
+- break;
+-
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+ ret_val = iegbe_oem_link_m88_setup(hw);
+- if(ret_val) {
+- return ret_val;
+- }
+- break;
+- case BCM5481_PHY_ID:
+- ret_val = iegbe_oem_link_bcm5481_setup(hw);
+- if(ret_val) {
+- return ret_val;
++ if(ret_val) {
++ return ret_val;
+ }
+- break;
++ break;
+ default:
+ DEBUGOUT("Invalid PHY ID\n");
+ return -E1000_ERR_PHY_TYPE;
+@@ -143,16 +128,16 @@ iegbe_oem_setup_link(struct iegbe_hw *hw
+
+ if(hw->autoneg) {
+ ret_val = iegbe_copper_link_autoneg(hw);
+- if(ret_val) {
+- return ret_val;
+- }
++ if(ret_val) {
++ return ret_val;
+ }
++ }
+ else {
+ DEBUGOUT("Forcing speed and duplex\n");
+ ret_val = iegbe_phy_force_speed_duplex(hw);
+ }
+-
+- /*
++
++ /*
+ * Check link status. Wait up to 100 microseconds for link to become
+ * valid.
+ */
+@@ -194,51 +179,6 @@ iegbe_oem_setup_link(struct iegbe_hw *hw
+ #endif /* ifdef EXTERNAL_MDIO */
+ }
+
+-/**
+- * iegbe_oem_link_bcm5481_setup
+- * @hw: iegbe_hw struct containing device specific information
+- *
+- * Returns E1000_SUCCESS, negative E1000 error code on failure
+- *
+- * copied verbatim from iegbe_oem_link_m88_setup
+- **/
+-static int32_t
+-iegbe_oem_link_bcm5481_setup(struct iegbe_hw *hw)
+-{
+- int32_t ret_val;
+- uint16_t phy_data;
+-
+- //DEBUGFUNC(__func__);
+-
+- if(!hw)
+- return -1;
+-
+- /* phy_reset_disable is set in iegbe_oem_set_phy_mode */
+- if(hw->phy_reset_disable)
+- return E1000_SUCCESS;
+-
+- // Enable MDIX in extended control reg.
+- ret_val = iegbe_oem_read_phy_reg_ex(hw, BCM5481_ECTRL, &phy_data);
+- if(ret_val)
+- {
+- DEBUGOUT("Unable to read BCM5481_ECTRL register\n");
+- return ret_val;
+- }
+-
+- phy_data &= ~BCM5481_ECTRL_DISMDIX;
+- ret_val = iegbe_oem_write_phy_reg_ex(hw, BCM5481_ECTRL, phy_data);
+- if(ret_val)
+- {
+- DEBUGOUT("Unable to write BCM5481_ECTRL register\n");
+- return ret_val;
+- }
+-
+- ret_val = oi_phy_setup (hw);
+- if (ret_val)
+- return ret_val;
+-
+- return E1000_SUCCESS;
+-}
+
+ /**
+ * iegbe_oem_link_m88_setup
+@@ -253,7 +193,7 @@ static int32_t
+ iegbe_oem_link_m88_setup(struct iegbe_hw *hw)
+ {
+ int32_t ret_val;
+- uint16_t phy_data;
++ uint16_t phy_data = 0;
+
+ DEBUGFUNC1("%s",__func__);
+
+@@ -261,7 +201,7 @@ iegbe_oem_link_m88_setup(struct iegbe_hw
+ return -1;
+ }
+
+- ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_CTRL,
++ ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_CTRL,
+ &phy_data);
+ phy_data |= 0x00000008;
+ ret_val = iegbe_oem_write_phy_reg_ex(hw, M88E1000_PHY_SPEC_CTRL, phy_data);
+@@ -279,7 +219,7 @@ iegbe_oem_link_m88_setup(struct iegbe_hw
+
+ phy_data &= ~M88E1000_PSCR_ASSERT_CRS_ON_TX;
+
+- /*
++ /*
+ * Options:
+ * MDI/MDI-X = 0 (default)
+ * 0 - Auto for all speeds
+@@ -305,7 +245,7 @@ iegbe_oem_link_m88_setup(struct iegbe_hw
+ break;
+ }
+
+- /*
++ /*
+ * Options:
+ * disable_polarity_correction = 0 (default)
+ * Automatic Correction for Reversed Cable Polarity
+@@ -316,25 +256,25 @@ iegbe_oem_link_m88_setup(struct iegbe_hw
+
+ if(hw->disable_polarity_correction == 1) {
+ phy_data |= M88E1000_PSCR_POLARITY_REVERSAL;
+- }
++ }
+ ret_val = iegbe_oem_write_phy_reg_ex(hw, M88E1000_PHY_SPEC_CTRL, phy_data);
+ if(ret_val) {
+ DEBUGOUT("Unable to write M88E1000_PHY_SPEC_CTRL register\n");
+ return ret_val;
+ }
+
+- /*
++ /*
+ * Force TX_CLK in the Extended PHY Specific Control Register
+ * to 25MHz clock.
+ */
+- ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_EXT_PHY_SPEC_CTRL,
++ ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_EXT_PHY_SPEC_CTRL,
+ &phy_data);
+ if(ret_val) {
+ DEBUGOUT("Unable to read M88E1000_EXT_PHY_SPEC_CTRL register\n");
+ return ret_val;
+ }
+
+- /*
++ /*
+ * For Truxton, it is necessary to add RGMII tx and rx
+ * timing delay though the EXT_PHY_SPEC_CTRL register
+ */
+@@ -350,13 +290,13 @@ iegbe_oem_link_m88_setup(struct iegbe_hw
+ phy_data |= (M88E1000_EPSCR_MASTER_DOWNSHIFT_1X |
+ M88E1000_EPSCR_SLAVE_DOWNSHIFT_1X);
+ }
+- ret_val = iegbe_oem_write_phy_reg_ex(hw, M88E1000_EXT_PHY_SPEC_CTRL,
++ ret_val = iegbe_oem_write_phy_reg_ex(hw, M88E1000_EXT_PHY_SPEC_CTRL,
+ phy_data);
+ if(ret_val) {
+ DEBUGOUT("Unable to read M88E1000_EXT_PHY_SPEC_CTRL register\n");
+ return ret_val;
+ }
+-
++
+
+ /* SW Reset the PHY so all changes take effect */
+ ret_val = iegbe_phy_hw_reset(hw);
+@@ -371,7 +311,7 @@ iegbe_oem_link_m88_setup(struct iegbe_hw
+ /**
+ * iegbe_oem_force_mdi
+ * @hw: iegbe_hw struct containing device specific information
+- * @resetPhy: returns true if after calling this function the
++ * @resetPhy: returns true if after calling this function the
+ * PHY requires a reset
+ *
+ * Returns E1000_SUCCESS, negative E1000 error code on failure
+@@ -379,7 +319,7 @@ iegbe_oem_link_m88_setup(struct iegbe_hw
+ * This is called from iegbe_phy_force_speed_duplex, which is
+ * called from iegbe_oem_setup_link.
+ **/
+-int32_t
++int32_t
+ iegbe_oem_force_mdi(struct iegbe_hw *hw, int *resetPhy)
+ {
+ #ifdef EXTERNAL_MDIO
+@@ -393,35 +333,30 @@ iegbe_oem_force_mdi(struct iegbe_hw *hw,
+ return -1;
+ }
+
+- /*
++ /*
+ * a boolean to indicate if the phy needs to be reset
+- *
++ *
+ * Make note that the M88 phy is what'll be used on Truxton
+ * see iegbe_phy_force_speed_duplex, which does the following for M88
+ */
+ switch (hw->phy_id) {
+- case BCM5395S_PHY_ID:
+- case BCM5481_PHY_ID:
+- DEBUGOUT("WARNING: An empty iegbe_oem_force_mdi() has been called!\n");
+- break;
+-
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+- ret_val = iegbe_oem_read_phy_reg_ex(hw,
+- M88E1000_PHY_SPEC_CTRL,
++ ret_val = iegbe_oem_read_phy_reg_ex(hw,
++ M88E1000_PHY_SPEC_CTRL,
+ &phy_data);
+ if(ret_val) {
+ DEBUGOUT("Unable to read M88E1000_PHY_SPEC_CTRL register\n");
+ return ret_val;
+ }
+-
++
+ /*
+- * Clear Auto-Crossover to force MDI manually. M88E1000 requires
++ * Clear Auto-Crossover to force MDI manually. M88E1000 requires
+ * MDI forced whenever speed are duplex are forced.
+ */
+-
++
+ phy_data &= ~M88E1000_PSCR_AUTO_X_MODE;
+- ret_val = iegbe_oem_write_phy_reg_ex(hw, M88E1000_PHY_SPEC_CTRL,
++ ret_val = iegbe_oem_write_phy_reg_ex(hw, M88E1000_PHY_SPEC_CTRL,
+ phy_data);
+ if(ret_val) {
+ DEBUGOUT("Unable to write M88E1000_PHY_SPEC_CTRL register\n");
+@@ -458,7 +393,7 @@ iegbe_oem_force_mdi(struct iegbe_hw *hw,
+ * This is called from iegbe_phy_force_speed_duplex, which is
+ * called from iegbe_oem_setup_link.
+ **/
+-int32_t
++int32_t
+ iegbe_oem_phy_reset_dsp(struct iegbe_hw *hw)
+ {
+ #ifdef EXTERNAL_MDIO
+@@ -478,10 +413,8 @@ iegbe_oem_phy_reset_dsp(struct iegbe_hw
+ * no-op.
+ */
+ switch (hw->phy_id) {
+- case M88E1000_I_PHY_ID:
+- case M88E1141_E_PHY_ID:
+- case BCM5481_PHY_ID:
+- case BCM5395S_PHY_ID:
++ case M88E1000_I_PHY_ID:
++ case M88E1141_E_PHY_ID:
+ DEBUGOUT("No DSP to reset on OEM PHY\n");
+ break;
+ default:
+@@ -508,7 +441,7 @@ iegbe_oem_phy_reset_dsp(struct iegbe_hw
+ * This is called from iegbe_phy_force_speed_duplex, which is
+ * called from iegbe_oem_setup_link.
+ **/
+-int32_t
++int32_t
+ iegbe_oem_cleanup_after_phy_reset(struct iegbe_hw *hw)
+ {
+ #ifdef EXTERNAL_MDIO
+@@ -520,29 +453,24 @@ iegbe_oem_cleanup_after_phy_reset(struct
+
+ if(!hw) {
+ return -1;
+- }
++ }
+
+- /*
++ /*
+ * Make note that the M88 phy is what'll be used on Truxton.
+ * see iegbe_phy_force_speed_duplex, which does the following for M88
+ */
+ switch (hw->phy_id) {
+- case BCM5395S_PHY_ID:
+- case BCM5481_PHY_ID:
+- DEBUGOUT("WARNING: An empty iegbe_oem_cleanup_after_phy_reset() has been called!\n");
+- break;
+-
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+ /*
+- * Because we reset the PHY above, we need to re-force
++ * Because we reset the PHY above, we need to re-force
+ * TX_CLK in the Extended PHY Specific Control Register to
+ * 25MHz clock. This value defaults back to a 2.5MHz clock
+ * when the PHY is reset.
+ */
+
+ ret_val = iegbe_oem_read_phy_reg_ex(hw,
+- M88E1000_EXT_PHY_SPEC_CTRL,
++ M88E1000_EXT_PHY_SPEC_CTRL,
+ &phy_data);
+ if(ret_val) {
+ DEBUGOUT("Unable to read M88E1000_EXT_SPEC_CTRL register\n");
+@@ -550,22 +478,23 @@ iegbe_oem_cleanup_after_phy_reset(struct
+ }
+
+ phy_data |= M88E1000_EPSCR_TX_CLK_25;
+- ret_val = iegbe_oem_write_phy_reg_ex(hw,
+- M88E1000_EXT_PHY_SPEC_CTRL,
++ ret_val = iegbe_oem_write_phy_reg_ex(hw,
++ M88E1000_EXT_PHY_SPEC_CTRL,
+ phy_data);
+ if(ret_val) {
+- DEBUGOUT("Unable to write M88E1000_EXT_PHY_SPEC_CTRL register\n");
++ DEBUGOUT("Unable to write M88E1000_EXT_PHY_SPEC_CTRL "
++ "register\n");
+ return ret_val;
+ }
+
+ /*
+ * In addition, because of the s/w reset above, we need to enable
+- * CRX on TX. This must be set for both full and half duplex
++ * CRX on TX. This must be set for both full and half duplex
+ * operation.
+ */
+
+- ret_val = iegbe_oem_read_phy_reg_ex(hw,
+- M88E1000_PHY_SPEC_CTRL,
++ ret_val = iegbe_oem_read_phy_reg_ex(hw,
++ M88E1000_PHY_SPEC_CTRL,
+ &phy_data);
+ if(ret_val) {
+ DEBUGOUT("Unable to read M88E1000_PHY_SPEC_CTRL register\n");
+@@ -573,12 +502,12 @@ iegbe_oem_cleanup_after_phy_reset(struct
+ }
+
+ phy_data &= ~M88E1000_PSCR_ASSERT_CRS_ON_TX;
+- ret_val = iegbe_oem_write_phy_reg_ex(hw, M88E1000_PHY_SPEC_CTRL,
++ ret_val = iegbe_oem_write_phy_reg_ex(hw, M88E1000_PHY_SPEC_CTRL,
+ phy_data);
+ if(ret_val) {
+ DEBUGOUT("Unable to write M88E1000_PHY_SPEC_CTRL register\n");
+ return ret_val;
+- }
++ }
+ break;
+ default:
+ DEBUGOUT("Invalid PHY ID\n");
+@@ -604,12 +533,12 @@ iegbe_oem_cleanup_after_phy_reset(struct
+ * This is called from iegbe_oem_setup_link which is
+ * called from iegbe_setup_link.
+ **/
+-static int32_t
++static int32_t
+ iegbe_oem_set_phy_mode(struct iegbe_hw *hw)
+ {
+ /*
+ * it is unclear if it is necessary to set the phy mode. Right now only
+- * one MAC 82545 Rev 3 does it, but the other MACs like Tolapai do not.
++ * one MAC 82545 Rev 3 does it, but the other MACs like tola do not.
+ * Leave the functionality off for now until it is determined that Tolapai
+ * needs it as well.
+ */
+@@ -638,41 +567,37 @@ iegbe_oem_set_phy_mode(struct iegbe_hw *
+ #ifndef skip_set_mode
+ DEBUGOUT("No need to call oem_set_phy_mode on Truxton\n");
+ #else
+- /*
++ /*
+ * Make note that the M88 phy is what'll be used on Truxton.
+ *
+ * use iegbe_set_phy_mode as example
+ */
+ switch (hw->phy_id) {
+- case BCM5395S_PHY_ID:
+- case BCM5481_PHY_ID:
+- DEBUGOUT("WARNING: An empty iegbe_oem_set_phy_mode() has been called!\n");
+- break;
+-
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+- ret_val = iegbe_read_eeprom(hw,
+- EEPROM_PHY_CLASS_WORD,
+- 1,
++ ret_val = iegbe_read_eeprom(hw,
++ EEPROM_PHY_CLASS_WORD,
++ 1,
+ &eeprom_data);
+ if(ret_val) {
+ return ret_val;
+ }
+
+- if((eeprom_data != EEPROM_RESERVED_WORD) &&
+- (eeprom_data & EEPROM_PHY_CLASS_A))
++ if((eeprom_data != EEPROM_RESERVED_WORD) &&
++ (eeprom_data & EEPROM_PHY_CLASS_A))
+ {
+- ret_val = iegbe_oem_write_phy_reg_ex(hw,
+- M88E1000_PHY_PAGE_SELECT,
+- 0x000B);
++ ret_val = iegbe_oem_write_phy_reg_ex(hw,
++ M88E1000_PHY_PAGE_SELECT,
++ 0x000B);
+ if(ret_val) {
+- DEBUGOUT("Unable to write to M88E1000_PHY_PAGE_SELECT register on PHY\n");
++ DEBUGOUT("Unable to write to M88E1000_PHY_PAGE_SELECT "
++ "register on PHY\n");
+ return ret_val;
+ }
+
+- ret_val = iegbe_oem_write_phy_reg_ex(hw,
+- M88E1000_PHY_GEN_CONTROL,
+- 0x8104);
++ ret_val = iegbe_oem_write_phy_reg_ex(hw,
++ M88E1000_PHY_GEN_CONTROL,
++ 0x8104);
+ if(ret_val) {
+ DEBUGOUT("Unable to write to M88E1000_PHY_GEN_CONTROL"
+ "register on PHY\n");
+@@ -687,11 +612,12 @@ iegbe_oem_set_phy_mode(struct iegbe_hw *
+ return -E1000_ERR_PHY_TYPE;
+ }
+ #endif
+-
++
+ return E1000_SUCCESS;
+
+ }
+
++
+ /**
+ * iegbe_oem_detect_phy
+ * @hw: iegbe_hw struct containing device specific information
+@@ -702,7 +628,7 @@ iegbe_oem_set_phy_mode(struct iegbe_hw *
+ *
+ * This borrows heavily from iegbe_detect_gig_phy
+ **/
+-static int32_t
++static int32_t
+ iegbe_oem_detect_phy(struct iegbe_hw *hw)
+ {
+ int32_t ret_val;
+@@ -715,33 +641,20 @@ iegbe_oem_detect_phy(struct iegbe_hw *hw
+ }
+ hw->phy_type = iegbe_phy_oem;
+
+-{
+- // If MAC2 (BCM5395 switch), manually detect the phy
+- struct iegbe_adapter *adapter;
+- uint32_t device_number;
+- adapter = (struct iegbe_adapter *) hw->back;
+- device_number = PCI_SLOT(adapter->pdev->devfn);
+- if (device_number == ICP_XXXX_MAC_2) {
+- hw->phy_id = BCM5395S_PHY_ID;
+- hw->phy_revision = 0;
+- return E1000_SUCCESS;
+- }
+-}
+-
+-
+ ret_val = iegbe_oem_read_phy_reg_ex(hw, PHY_ID1, &phy_id_high);
+ if(ret_val) {
+ DEBUGOUT("Unable to read PHY register PHY_ID1\n");
+ return ret_val;
+ }
+-
++
+ usec_delay(0x14);
+ ret_val = iegbe_oem_read_phy_reg_ex(hw, PHY_ID2, &phy_id_low);
+ if(ret_val) {
+ DEBUGOUT("Unable to read PHY register PHY_ID2\n");
+ return ret_val;
+ }
+- hw->phy_id = (uint32_t) ((phy_id_high << 0x10) + phy_id_low);
++ hw->phy_id = (uint32_t) ((phy_id_high << 0x10) +
++ (phy_id_low & PHY_REVISION_MASK));
+ hw->phy_revision = (uint32_t) phy_id_low & ~PHY_REVISION_MASK;
+
+ return E1000_SUCCESS;
+@@ -753,15 +666,15 @@ iegbe_oem_detect_phy(struct iegbe_hw *hw
+ * @hw: iegbe_hw struct containing device specific information
+ *
+ * Returns the value of the Inter Packet Gap (IPG) Transmit Time (IPGT) in the
+- * Transmit IPG register appropriate for the given PHY. This field is only 10
++ * Transmit IPG register appropriate for the given PHY. This field is only 10
+ * bits wide.
+ *
+ * In the original iegbe code, only the IPGT field varied between media types.
+- * If the OEM phy requires setting IPG Receive Time 1 & 2 Registers, it would
++ * If the OEM phy requires setting IPG Receive Time 1 & 2 Registers, it would
+ * be required to modify the iegbe_config_tx() function to accomdate the change
+ *
+ **/
+-uint32_t
++uint32_t
+ iegbe_oem_get_tipg(struct iegbe_hw *hw)
+ {
+ #ifdef EXTERNAL_MDIO
+@@ -777,15 +690,13 @@ iegbe_oem_get_tipg(struct iegbe_hw *hw)
+ switch (hw->phy_id) {
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+- case BCM5481_PHY_ID:
+- case BCM5395S_PHY_ID:
+ phy_num = DEFAULT_ICP_XXXX_TIPG_IPGT;
+ break;
+ default:
+ DEBUGOUT("Invalid PHY ID\n");
+ return DEFAULT_ICP_XXXX_TIPG_IPGT;
+ }
+-
++
+ return phy_num;
+
+ #else /* ifdef EXTERNAL_MDIO */
+@@ -803,15 +714,15 @@ iegbe_oem_get_tipg(struct iegbe_hw *hw)
+ * iegbe_oem_phy_is_copper
+ * @hw: iegbe_hw struct containing device specific information
+ *
+- * Test for media type within the iegbe driver is common, so this is a simple
+- * test for copper PHYs. The ICP_XXXX family of controllers initially only
+- * supported copper interconnects (no TBI (ten bit interface) for Fiber
+- * existed). If future revs support either Fiber or an internal SERDES, it
+- * may become necessary to evaluate where this function is used to go beyond
++ * Test for media type within the iegbe driver is common, so this is a simple
++ * test for copper PHYs. The ICP_XXXX family of controllers initially only
++ * supported copper interconnects (no TBI (ten bit interface) for Fiber
++ * existed). If future revs support either Fiber or an internal SERDES, it
++ * may become necessary to evaluate where this function is used to go beyond
+ * determining whether or not media type is just copper.
+ *
+ **/
+-int
++int
+ iegbe_oem_phy_is_copper(struct iegbe_hw *hw)
+ {
+ #ifdef EXTERNAL_MDIO
+@@ -827,23 +738,21 @@ iegbe_oem_phy_is_copper(struct iegbe_hw
+ switch (hw->phy_id) {
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+- case BCM5481_PHY_ID:
+- case BCM5395S_PHY_ID:
+ isCopper = TRUE;
+ break;
+ default:
+ DEBUGOUT("Invalid PHY ID\n");
+ return -E1000_ERR_PHY_TYPE;
+ }
+-
++
+ return isCopper;
+
+ #else /* ifdef EXTERNAL_MDIO */
+
+- /*
++ /*
+ * caught between returning true or false. True allows it to
+ * be entered into && statements w/o ill effect, but false
+- * would make more sense
++ * would make more sense
+ */
+ DEBUGOUT("Invalid value for transceiver type, return FALSE\n");
+ return FALSE;
+@@ -856,19 +765,19 @@ iegbe_oem_phy_is_copper(struct iegbe_hw
+ * iegbe_oem_get_phy_dev_number
+ * @hw: iegbe_hw struct containing device specific information
+ *
+- * For ICP_XXXX family of devices, there are 3 MACs, each of which may
+- * have a different PHY (and indeed a different media interface). This
+- * function is used to indicate which of the MAC/PHY pairs we are interested
++ * For ICP_XXXX family of devices, there are 3 MACs, each of which may
++ * have a different PHY (and indeed a different media interface). This
++ * function is used to indicate which of the MAC/PHY pairs we are interested
+ * in.
+- *
++ *
+ **/
+-uint32_t
++uint32_t
+ iegbe_oem_get_phy_dev_number(struct iegbe_hw *hw)
+ {
+ #ifdef EXTERNAL_MDIO
+
+- /*
+- * for ICP_XXXX family of devices, the three network interfaces are
++ /*
++ * for ICP_XXXX family of devices, the three network interfaces are
+ * differentiated by their PCI device number, where the three share
+ * the same PCI bus
+ */
+@@ -886,15 +795,15 @@ iegbe_oem_get_phy_dev_number(struct iegb
+
+ switch(device_number)
+ {
+- case ICP_XXXX_MAC_0:
++ case ICP_XXXX_MAC_0:
++ hw->phy_addr = 0x00;
++ break;
++ case ICP_XXXX_MAC_1:
+ hw->phy_addr = 0x01;
+ break;
+- case ICP_XXXX_MAC_1:
++ case ICP_XXXX_MAC_2:
+ hw->phy_addr = 0x02;
+ break;
+- case ICP_XXXX_MAC_2:
+- hw->phy_addr = 0x00;
+- break;
+ default: hw->phy_addr = 0x00;
+ }
+ return hw->phy_addr;
+@@ -915,7 +824,7 @@ iegbe_oem_get_phy_dev_number(struct iegb
+ * @cmd: the original IOCTL command that instigated the call chain.
+ *
+ * This function abstracts out the code necessary to service the
+- * SIOCSMIIREG case within the iegbe_mii_ioctl() for oem PHYs.
++ * SIOCSMIIREG case within the iegbe_mii_ioctl() for oem PHYs.
+ * iegbe_mii_ioctl() was implemented for copper phy's only and this
+ * function will only be called if iegbe_oem_phy_is_copper() returns true for
+ * a given MAC. Note that iegbe_mii_ioctl() has a compile flag
+@@ -924,14 +833,14 @@ iegbe_oem_get_phy_dev_number(struct iegb
+ * NOTE: a spinlock is in effect for the duration of this call. It is
+ * imperative that a negative value be returned on any error, so
+ * the spinlock can be released properly.
+- *
++ *
+ **/
+ int
+ iegbe_oem_mii_ioctl(struct iegbe_adapter *adapter, unsigned long flags,
+ struct ifreq *ifr, int cmd)
+ {
+ #ifdef EXTERNAL_MDIO
+-
++
+ struct mii_ioctl_data *data = if_mii(ifr);
+ uint16_t mii_reg = data->val_in;
+ uint16_t spddplx;
+@@ -942,12 +851,6 @@ iegbe_oem_mii_ioctl(struct iegbe_adapter
+ if(!adapter || !ifr) {
+ return -1;
+ }
+-
+- // If MAC2 (BCM5395 switch) then leave now
+- if ((PCI_SLOT(adapter->pdev->devfn)) == ICP_XXXX_MAC_2) {
+- return -1;
+- }
+-
+ switch (data->reg_num) {
+ case PHY_CTRL:
+ if(mii_reg & MII_CR_POWER_DOWN) {
+@@ -956,7 +859,7 @@ iegbe_oem_mii_ioctl(struct iegbe_adapter
+ if(mii_reg & MII_CR_AUTO_NEG_EN) {
+ adapter->hw.autoneg = 1;
+ adapter->hw.autoneg_advertised = ICP_XXXX_AUTONEG_ADV_DEFAULT;
+- }
++ }
+ else {
+ if(mii_reg & 0x40) {
+ spddplx = SPEED_1000;
+@@ -976,7 +879,7 @@ iegbe_oem_mii_ioctl(struct iegbe_adapter
+ if(netif_running(adapter->netdev)) {
+ iegbe_down(adapter);
+ iegbe_up(adapter);
+- }
++ }
+ else {
+ iegbe_reset(adapter);
+ }
+@@ -1043,10 +946,10 @@ void iegbe_oem_fiber_live_in_suspend(str
+ * Note: The call to iegbe_get_regs() assumed an array of 24 elements
+ * where the last 11 are passed to this function. If the array
+ * that is passed to the calling function has its size or element
+- * defintions changed, this function becomes broken.
++ * defintions changed, this function becomes broken.
+ *
+ **/
+-void iegbe_oem_get_phy_regs(struct iegbe_adapter *adapter, uint32_t *data,
++void iegbe_oem_get_phy_regs(struct iegbe_adapter *adapter, uint32_t *data,
+ uint32_t data_len)
+ {
+ #define EXPECTED_ARRAY_LEN 11
+@@ -1062,13 +965,13 @@ void iegbe_oem_get_phy_regs(struct iegbe
+ * Use the corrected_length variable to make sure we don't exceed that
+ * length
+ */
+- corrected_len = data_len>EXPECTED_ARRAY_LEN
++ corrected_len = data_len>EXPECTED_ARRAY_LEN
+ ? EXPECTED_ARRAY_LEN : data_len;
+ memset(data, 0, corrected_len*sizeof(uint32_t));
+
+ #ifdef EXTERNAL_MDIO
+
+- /*
++ /*
+ * Fill data[] with...
+ *
+ * [0] = cable length
+@@ -1084,16 +987,11 @@ void iegbe_oem_get_phy_regs(struct iegbe
+ * [10] = mdix mode
+ */
+ switch (adapter->hw.phy_id) {
+- case BCM5395S_PHY_ID:
+- case BCM5481_PHY_ID:
+- DEBUGOUT("WARNING: An empty iegbe_oem_get_phy_regs() has been called!\n");
+- break;
+-
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+ if(corrected_len > 0) {
+- iegbe_oem_read_phy_reg_ex(&adapter->hw,
+- M88E1000_PHY_SPEC_STATUS,
++ iegbe_oem_read_phy_reg_ex(&adapter->hw,
++ M88E1000_PHY_SPEC_STATUS,
+ (uint16_t *) &data[0]);
+ }
+ if(corrected_len > 0x1){
+@@ -1106,7 +1004,7 @@ void iegbe_oem_get_phy_regs(struct iegbe
+ data[0x3] = 0x0; /* Dummy (to align w/ IGP phy reg dump) */
+ }
+ if(corrected_len > 0x4) {
+- iegbe_oem_read_phy_reg_ex(&adapter->hw, M88E1000_PHY_SPEC_CTRL,
++ iegbe_oem_read_phy_reg_ex(&adapter->hw, M88E1000_PHY_SPEC_CTRL,
+ (uint16_t *) &data[0x4]);
+ }
+ if(corrected_len > 0x5) {
+@@ -1144,7 +1042,7 @@ void iegbe_oem_get_phy_regs(struct iegbe
+ * This is called from iegbe_set_phy_loopback in response from call from
+ * ethtool to place the PHY into loopback mode.
+ **/
+-int
++int
+ iegbe_oem_phy_loopback(struct iegbe_adapter *adapter)
+ {
+ #ifdef EXTERNAL_MDIO
+@@ -1165,23 +1063,18 @@ iegbe_oem_phy_loopback(struct iegbe_adap
+ * was that nonintegrated called iegbe_phy_reset_clk_and_crs(),
+ * hopefully this won't matter as CRS required for half-duplex
+ * operation and this is set to full duplex.
+- *
++ *
+ * Make note that the M88 phy is what'll be used on Truxton
+ * Loopback configuration is the same for each of the supported PHYs.
+ */
+ switch (adapter->hw.phy_id) {
+- case BCM5395S_PHY_ID:
+- DEBUGOUT("WARNING: An empty iegbe_oem_phy_loopback() has been called!\n");
+- break;
+-
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+- case BCM5481_PHY_ID:
+
+ adapter->hw.autoneg = FALSE;
+
+ /* turn off Auto-MDI/MDIX */
+- /*ret_val = iegbe_oem_write_phy_reg_ex(&adapter->hw,
++ /*ret_val = iegbe_oem_write_phy_reg_ex(&adapter->hw,
+ M88E1000_PHY_SPEC_CTRL, 0x0808);
+ if(ret_val)
+ {
+@@ -1206,10 +1099,10 @@ iegbe_oem_phy_loopback(struct iegbe_adap
+ DEBUGOUT("Unable to write to register PHY_CTRL\n");
+ return ret_val;
+ }
+-
+-
++
++
+ /* force 1000, set loopback */
+- /*ret_val =
++ /*ret_val =
+ iegbe_oem_write_phy_reg_ex(&adapter->hw, PHY_CTRL, 0x4140); */
+ ret_val = iegbe_oem_write_phy_reg_ex(&adapter->hw, PHY_CTRL, 0x6100);
+ if(ret_val) {
+@@ -1228,21 +1121,21 @@ iegbe_oem_phy_loopback(struct iegbe_adap
+ E1000_WRITE_REG(&adapter->hw, CTRL, ctrl_reg);
+
+ /*
+- * Write out to PHY registers 29 and 30 to disable the Receiver.
++ * Write out to PHY registers 29 and 30 to disable the Receiver.
+ * This directly lifted from iegbe_phy_disable_receiver().
+- *
++ *
+ * The code is currently commented out as for the M88 used in
+ * Truxton, registers 29 and 30 are unutilized. Leave in, just
+- * in case we are on the receiving end of an 'undocumented'
++ * in case we are on the receiving end of an 'undocumented'
+ * feature
+ */
+- /*
++ /*
+ * iegbe_oem_write_phy_reg_ex(&adapter->hw, 29, 0x001F);
+ * iegbe_oem_write_phy_reg_ex(&adapter->hw, 30, 0x8FFC);
+ * iegbe_oem_write_phy_reg_ex(&adapter->hw, 29, 0x001A);
+ * iegbe_oem_write_phy_reg_ex(&adapter->hw, 30, 0x8FF0);
+ */
+-
++
+ break;
+ default:
+ DEBUGOUT("Invalid PHY ID\n");
+@@ -1268,15 +1161,15 @@ iegbe_oem_phy_loopback(struct iegbe_adap
+ * ethtool to place the PHY out of loopback mode. This handles the OEM
+ * specific part of loopback cleanup.
+ **/
+-void
++void
+ iegbe_oem_loopback_cleanup(struct iegbe_adapter *adapter)
+ {
+ #ifdef EXTERNAL_MDIO
+
+- /*
+- * This borrows liberally from iegbe_loopback_cleanup().
++ /*
++ * This borrows liberally from iegbe_loopback_cleanup().
+ * making note that the M88 phy is what'll be used on Truxton
+- *
++ *
+ * Loopback cleanup is the same for all supported PHYs.
+ */
+ int32_t ret_val;
+@@ -1289,38 +1182,32 @@ iegbe_oem_loopback_cleanup(struct iegbe_
+ }
+
+ switch (adapter->hw.phy_id) {
+- case BCM5395S_PHY_ID:
+- DEBUGOUT("WARNING: An empty iegbe_oem_loopback_cleanup() has been called!\n");
+- return;
+- break;
+-
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+- case BCM5481_PHY_ID:
+ default:
+ adapter->hw.autoneg = TRUE;
+-
+- ret_val = iegbe_oem_read_phy_reg_ex(&adapter->hw, PHY_CTRL,
++
++ ret_val = iegbe_oem_read_phy_reg_ex(&adapter->hw, PHY_CTRL,
+ &phy_reg);
+ if(ret_val) {
+ DEBUGOUT("Unable to read to register PHY_CTRL\n");
+ return;
+ }
+-
++
+ if(phy_reg & MII_CR_LOOPBACK) {
+ phy_reg &= ~MII_CR_LOOPBACK;
+-
+- ret_val = iegbe_oem_write_phy_reg_ex(&adapter->hw, PHY_CTRL,
++
++ ret_val = iegbe_oem_write_phy_reg_ex(&adapter->hw, PHY_CTRL,
+ phy_reg);
+ if(ret_val) {
+ DEBUGOUT("Unable to write to register PHY_CTRL\n");
+ return;
+ }
+-
++
+ iegbe_phy_reset(&adapter->hw);
+ }
+ }
+-
++
+ #endif /* ifdef EXTERNAL_MDIO */
+ return;
+
+@@ -1336,7 +1223,7 @@ iegbe_oem_loopback_cleanup(struct iegbe_
+ * Called by iegbe_check_downshift(), checks the PHY to see if it running
+ * at as speed slower than its maximum.
+ **/
+-uint32_t
++uint32_t
+ iegbe_oem_phy_speed_downgraded(struct iegbe_hw *hw, uint16_t *isDowngraded)
+ {
+ #ifdef EXTERNAL_MDIO
+@@ -1356,24 +1243,19 @@ iegbe_oem_phy_speed_downgraded(struct ie
+ */
+
+ switch (hw->phy_id) {
+- case BCM5395S_PHY_ID:
+- case BCM5481_PHY_ID:
+- *isDowngraded = 0;
+- break;
+-
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+- ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_STATUS,
++ ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_STATUS,
+ &phy_data);
+ if(ret_val) {
+ DEBUGOUT("Unable to read register M88E1000_PHY_SPEC_STATUS\n");
+ return ret_val;
+ }
+-
+- *isDowngraded = (phy_data & M88E1000_PSSR_DOWNSHIFT)
++
++ *isDowngraded = (phy_data & M88E1000_PSSR_DOWNSHIFT)
+ >> M88E1000_PSSR_DOWNSHIFT_SHIFT;
+-
+- break;
++
++ break;
+ default:
+ DEBUGOUT("Invalid PHY ID\n");
+ return 1;
+@@ -1388,7 +1270,7 @@ iegbe_oem_phy_speed_downgraded(struct ie
+ }
+
+ *isDowngraded = 0;
+- return 0;
++ return 0;
+
+ #endif /* ifdef EXTERNAL_MDIO */
+ }
+@@ -1403,7 +1285,7 @@ iegbe_oem_phy_speed_downgraded(struct ie
+ * Called by iegbe_check_downshift(), checks the PHY to see if it running
+ * at as speed slower than its maximum.
+ **/
+-int32_t
++int32_t
+ iegbe_oem_check_polarity(struct iegbe_hw *hw, uint16_t *polarity)
+ {
+ #ifdef EXTERNAL_MDIO
+@@ -1417,33 +1299,27 @@ iegbe_oem_check_polarity(struct iegbe_hw
+ return -1;
+ }
+
+- /*
++ /*
+ * borrow liberally from iegbe_check_polarity.
+ * Make note that the M88 phy is what'll be used on Truxton
+ */
+
+ switch (hw->phy_id) {
+- case BCM5395S_PHY_ID:
+- case BCM5481_PHY_ID:
+- *polarity = 0;
+- break;
+-
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+ /* return the Polarity bit in the Status register. */
+- ret_val = iegbe_oem_read_phy_reg_ex(hw,
+- M88E1000_PHY_SPEC_STATUS,
++ ret_val = iegbe_oem_read_phy_reg_ex(hw,
++ M88E1000_PHY_SPEC_STATUS,
+ &phy_data);
+ if(ret_val) {
+ DEBUGOUT("Unable to read register M88E1000_PHY_SPEC_STATUS\n");
+ return ret_val;
+ }
+
+- *polarity = (phy_data & M88E1000_PSSR_REV_POLARITY)
++ *polarity = (phy_data & M88E1000_PSSR_REV_POLARITY)
+ >> M88E1000_PSSR_REV_POLARITY_SHIFT;
+-
+- break;
+-
++
++ break;
+ default:
+ DEBUGOUT("Invalid PHY ID\n");
+ return -E1000_ERR_PHY_TYPE;
+@@ -1472,7 +1348,7 @@ iegbe_oem_check_polarity(struct iegbe_hw
+ * the MAC with the PHY. It turns out on ICP_XXXX, this is not
+ * done automagically.
+ **/
+-int32_t
++int32_t
+ iegbe_oem_phy_is_full_duplex(struct iegbe_hw *hw, int *isFD)
+ {
+ #ifdef EXTERNAL_MDIO
+@@ -1485,40 +1361,22 @@ iegbe_oem_phy_is_full_duplex(struct iegb
+ if(!hw || !isFD) {
+ return -1;
+ }
+- /*
++ /*
+ * Make note that the M88 phy is what'll be used on Truxton
+ * see iegbe_config_mac_to_phy
+ */
+-
++
+ switch (hw->phy_id) {
+- case BCM5395S_PHY_ID:
+- /* Always full duplex */
+- *isFD = 1;
+- break;
+-
+- case BCM5481_PHY_ID:
+- ret_val = iegbe_read_phy_reg(hw, BCM5481_ASTAT, &phy_data);
+- if(ret_val) return ret_val;
+-
+- switch (BCM5481_ASTAT_HCD(phy_data)) {
+- case BCM5481_ASTAT_1KBTFD:
+- case BCM5481_ASTAT_100BTXFD:
+- *isFD = 1;
+- break;
+- default:
+- *isFD = 0;
+- }
+- break;
+-
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+- ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_STATUS, &phy_data);
+- if(ret_val) {
+- DEBUGOUT("Unable to read register M88E1000_PHY_SPEC_STATUS\n");
+- return ret_val;
+- }
++ ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_STATUS,
++ &phy_data);
++ if(ret_val) {
++ DEBUGOUT("Unable to read register M88E1000_PHY_SPEC_STATUS\n");
++ return ret_val;
++ }
+ *isFD = (phy_data & M88E1000_PSSR_DPLX) != 0;
+-
++
+ break;
+ default:
+ DEBUGOUT("Invalid PHY ID\n");
+@@ -1546,7 +1404,7 @@ iegbe_oem_phy_is_full_duplex(struct iegb
+ * the MAC with the PHY. It turns out on ICP_XXXX, this is not
+ * done automagically.
+ **/
+-int32_t
++int32_t
+ iegbe_oem_phy_is_speed_1000(struct iegbe_hw *hw, int *is1000)
+ {
+ #ifdef EXTERNAL_MDIO
+@@ -1565,28 +1423,10 @@ iegbe_oem_phy_is_speed_1000(struct iegbe
+ */
+
+ switch (hw->phy_id) {
+- case BCM5395S_PHY_ID:
+- /* Always 1000mb */
+- *is1000 = 1;
+- break;
+-
+- case BCM5481_PHY_ID:
+- ret_val = iegbe_read_phy_reg(hw, BCM5481_ASTAT, &phy_data);
+- if(ret_val) return ret_val;
+-
+- switch (BCM5481_ASTAT_HCD(phy_data)) {
+- case BCM5481_ASTAT_1KBTFD:
+- case BCM5481_ASTAT_1KBTHD:
+- *is1000 = 1;
+- break;
+- default:
+- *is1000 = 0;
+- }
+- break;
+-
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+- ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_STATUS, &phy_data);
++ ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_STATUS,
++ &phy_data);
+ if(ret_val) {
+ DEBUGOUT("Unable to read register M88E1000_PHY_SPEC_STATUS\n");
+ return ret_val;
+@@ -1638,28 +1478,9 @@ iegbe_oem_phy_is_speed_100(struct iegbe_
+ * see iegbe_config_mac_to_phy
+ */
+ switch (hw->phy_id) {
+- case BCM5395S_PHY_ID:
+- /* Always 1000Mb, never 100mb */
+- *is100 = 0;
+- break;
+-
+- case BCM5481_PHY_ID:
+- ret_val = iegbe_read_phy_reg(hw, BCM5481_ASTAT, &phy_data);
+- if(ret_val) return ret_val;
+-
+- switch (BCM5481_ASTAT_HCD(phy_data)) {
+- case BCM5481_ASTAT_100BTXFD:
+- case BCM5481_ASTAT_100BTXHD:
+- *is100 = 1;
+- break;
+- default:
+- *is100 = 0;
+- }
+- break;
+-
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+- ret_val = iegbe_oem_read_phy_reg_ex(hw,
++ ret_val = iegbe_oem_read_phy_reg_ex(hw,
+ M88E1000_PHY_SPEC_STATUS,
+ &phy_data);
+ if(ret_val) {
+@@ -1714,29 +1535,24 @@ iegbe_oem_phy_get_info(struct iegbe_hw *
+ * see iegbe_phy_m88_get_info
+ */
+ switch (hw->phy_id) {
+- case BCM5395S_PHY_ID:
+- case BCM5481_PHY_ID:
+- DEBUGOUT("WARNING: An empty iegbe_oem_phy_get_info() has been called!\n");
+- break;
+-
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+- /* The downshift status is checked only once, after link is
+- * established and it stored in the hw->speed_downgraded parameter.*/
++ /* The downshift status is checked only once, after link is
++ * established and it stored in the hw->speed_downgraded parameter.*/
+ phy_info->downshift = (iegbe_downshift)hw->speed_downgraded;
+-
+- ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_CTRL,
++
++ ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_CTRL,
+ &phy_data);
+ if(ret_val) {
+ DEBUGOUT("Unable to read register M88E1000_PHY_SPEC_CTRL\n");
+ return ret_val;
+ }
+
+- phy_info->extended_10bt_distance =
+- (phy_data & M88E1000_PSCR_10BT_EXT_DIST_ENABLE)
++ phy_info->extended_10bt_distance =
++ (phy_data & M88E1000_PSCR_10BT_EXT_DIST_ENABLE)
+ >> M88E1000_PSCR_10BT_EXT_DIST_ENABLE_SHIFT;
+ phy_info->polarity_correction =
+- (phy_data & M88E1000_PSCR_POLARITY_REVERSAL)
++ (phy_data & M88E1000_PSCR_POLARITY_REVERSAL)
+ >> M88E1000_PSCR_POLARITY_REVERSAL_SHIFT;
+
+ /* Check polarity status */
+@@ -1747,11 +1563,11 @@ iegbe_oem_phy_get_info(struct iegbe_hw *
+
+ phy_info->cable_polarity = polarity;
+
+- ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_STATUS,
++ ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_STATUS,
+ &phy_data);
+ if(ret_val) {
+- DEBUGOUT("Unable to read register M88E1000_PHY_SPEC_STATUS\n");
+- return ret_val;
++ DEBUGOUT("Unable to read register M88E1000_PHY_SPEC_STATUS\n");
++ return ret_val;
+ }
+
+ phy_info->mdix_mode = (phy_data & M88E1000_PSSR_MDIX)
+@@ -1761,24 +1577,24 @@ iegbe_oem_phy_get_info(struct iegbe_hw *
+ /* Cable Length Estimation and Local/Remote Receiver Information
+ * are only valid at 1000 Mbps.
+ */
+- phy_info->cable_length =
++ phy_info->cable_length =
+ (phy_data & M88E1000_PSSR_CABLE_LENGTH)
+ >> M88E1000_PSSR_CABLE_LENGTH_SHIFT;
+
+- ret_val = iegbe_oem_read_phy_reg_ex(hw, PHY_1000T_STATUS,
++ ret_val = iegbe_oem_read_phy_reg_ex(hw, PHY_1000T_STATUS,
+ &phy_data);
+ if(ret_val) {
+ DEBUGOUT("Unable to read register PHY_1000T_STATUS\n");
+ return ret_val;
+ }
+
+- phy_info->local_rx = (phy_data & SR_1000T_LOCAL_RX_STATUS)
++ phy_info->local_rx = (phy_data & SR_1000T_LOCAL_RX_STATUS)
+ >> SR_1000T_LOCAL_RX_STATUS_SHIFT;
+-
+- phy_info->remote_rx = (phy_data & SR_1000T_REMOTE_RX_STATUS)
++
++ phy_info->remote_rx = (phy_data & SR_1000T_REMOTE_RX_STATUS)
+ >> SR_1000T_REMOTE_RX_STATUS_SHIFT;
+ }
+-
++
+ break;
+ default:
+ DEBUGOUT("Invalid PHY ID\n");
+@@ -1801,7 +1617,7 @@ iegbe_oem_phy_get_info(struct iegbe_hw *
+ * This function will perform a software initiated reset of
+ * the PHY
+ **/
+-int32_t
++int32_t
+ iegbe_oem_phy_hw_reset(struct iegbe_hw *hw)
+ {
+ #ifdef EXTERNAL_MDIO
+@@ -1815,18 +1631,13 @@ iegbe_oem_phy_hw_reset(struct iegbe_hw *
+ return -1;
+ }
+ /*
+- * This code pretty much copies the default case from
++ * This code pretty much copies the default case from
+ * iegbe_phy_reset() as that is what is appropriate for
+- * the M88 used in truxton.
++ * the M88 used in truxton.
+ */
+ switch (hw->phy_id) {
+- case BCM5395S_PHY_ID:
+- DEBUGOUT("WARNING: An empty iegbe_oem_phy_hw_reset() has been called!\n");
+- break;
+-
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+- case BCM5481_PHY_ID:
+ ret_val = iegbe_oem_read_phy_reg_ex(hw, PHY_CTRL, &phy_data);
+ if(ret_val) {
+ DEBUGOUT("Unable to read register PHY_CTRL\n");
+@@ -1864,7 +1675,7 @@ iegbe_oem_phy_hw_reset(struct iegbe_hw *
+ * to perform and post reset initialiation. Not all PHYs require
+ * this, which is why it was split off as a seperate function.
+ **/
+-void
++void
+ iegbe_oem_phy_init_script(struct iegbe_hw *hw)
+ {
+ #ifdef EXTERNAL_MDIO
+@@ -1877,19 +1688,17 @@ iegbe_oem_phy_init_script(struct iegbe_h
+
+ /* call the GCU func that can do any phy specific init
+ * functions after a reset
+- *
++ *
+ * Make note that the M88 phy is what'll be used on Truxton
+ *
+- * The closest thing is in iegbe_phy_init_script, however this is
++ * The closest thing is in iegbe_phy_init_script, however this is
+ * for the IGP style of phy. This is probably a no-op for truxton
+ * but may be needed by OEM's later on
+- *
++ *
+ */
+ switch (hw->phy_id) {
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+- case BCM5481_PHY_ID:
+- case BCM5395S_PHY_ID:
+ DEBUGOUT("Nothing to do for OEM PHY Init");
+ break;
+ default:
+@@ -1926,13 +1735,8 @@ iegbe_oem_read_phy_reg_ex(struct iegbe_h
+ return -1;
+ }
+
+- if (hw->phy_id == BCM5395S_PHY_ID) {
+- DEBUGOUT("WARNING: iegbe_oem_read_phy_reg_ex() has been unexpectedly called!\n");
+- return -1;
+- }
+-
+ /* call the GCU func that will read the phy
+- *
++ *
+ * Make note that the M88 phy is what'll be used on Truxton.
+ *
+ * The closest thing is in iegbe_read_phy_reg_ex.
+@@ -1940,7 +1744,7 @@ iegbe_oem_read_phy_reg_ex(struct iegbe_h
+ * NOTE: this is 1 (of 2) functions that is truly dependant on the
+ * gcu module
+ */
+-
++
+ ret_val = gcu_read_eth_phy(iegbe_oem_get_phy_dev_number(hw),
+ reg_addr, phy_data);
+ if(ret_val) {
+@@ -1962,10 +1766,10 @@ iegbe_oem_read_phy_reg_ex(struct iegbe_h
+ *
+ * Returns E1000_SUCCESS, negative E1000 error code on failure
+ *
+- * This is called from iegbe_config_mac_to_phy. Various supported
++ * This is called from iegbe_config_mac_to_phy. Various supported
+ * Phys may require the RGMII/RMII Translation gasket be set to RMII.
+ **/
+-int32_t
++int32_t
+ iegbe_oem_set_trans_gasket(struct iegbe_hw *hw)
+ {
+ #ifdef EXTERNAL_MDIO
+@@ -1978,17 +1782,12 @@ iegbe_oem_set_trans_gasket(struct iegbe_
+ }
+
+ switch (hw->phy_id) {
+- case BCM5395S_PHY_ID:
+- case BCM5481_PHY_ID:
+- DEBUGOUT("WARNING: An empty iegbe_oem_set_trans_gasket() has been called!\n");
+- break;
+-
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+ /* Gasket set correctly for Marvell Phys, so nothing to do */
+ break;
+ /* Add your PHY_ID here if your device requires an RMII interface
+- case YOUR_PHY_ID:
++ case YOUR_PHY_ID:
+ ctrl_aux_reg = E1000_READ_REG(hw, CTRL_AUX);
+ ctrl_aux_reg |= E1000_CTRL_AUX_ICP_xxxx_MII_TGS; // Set the RGMII_RMII bit
+ */
+@@ -2032,7 +1831,7 @@ iegbe_oem_write_phy_reg_ex(struct iegbe_
+ return -1;
+ }
+ /* call the GCU func that will write to the phy
+- *
++ *
+ * Make note that the M88 phy is what'll be used on Truxton.
+ *
+ * The closest thing is in iegbe_write_phy_reg_ex
+@@ -2062,11 +1861,11 @@ iegbe_oem_write_phy_reg_ex(struct iegbe_
+ * @hw struct iegbe_hw hardware specific data
+ *
+ * iegbe_reset_hw is called to reset the MAC. If, for
+- * some reason the PHY needs to be reset as well, this
++ * some reason the PHY needs to be reset as well, this
+ * should return TRUE and then iegbe_oem_phy_hw_reset()
+ * will be called.
+ **/
+-int
++int
+ iegbe_oem_phy_needs_reset_with_mac(struct iegbe_hw *hw)
+ {
+ #ifdef EXTERNAL_MDIO
+@@ -2079,16 +1878,14 @@ iegbe_oem_phy_needs_reset_with_mac(struc
+ return FALSE;
+ }
+
+- /*
++ /*
+ * From the original iegbe driver, the M88
+- * PHYs did not seem to need this reset,
++ * PHYs did not seem to need this reset,
+ * so returning FALSE.
+ */
+ switch (hw->phy_id) {
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+- case BCM5481_PHY_ID:
+- case BCM5395S_PHY_ID:
+ ret_val = FALSE;
+ break;
+ default:
+@@ -2116,7 +1913,7 @@ iegbe_oem_phy_needs_reset_with_mac(struc
+ * tweaking of the PHY, for PHYs that support a DSP.
+ *
+ **/
+-int32_t
++int32_t
+ iegbe_oem_config_dsp_after_link_change(struct iegbe_hw *hw,
+ int link_up)
+ {
+@@ -2138,8 +1935,6 @@ iegbe_oem_config_dsp_after_link_change(s
+ switch (hw->phy_id) {
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+- case BCM5481_PHY_ID:
+- case BCM5395S_PHY_ID:
+ DEBUGOUT("No DSP to configure on OEM PHY");
+ break;
+ default:
+@@ -2165,7 +1960,7 @@ iegbe_oem_config_dsp_after_link_change(s
+ *
+ *
+ **/
+-int32_t
++int32_t
+ iegbe_oem_get_cable_length(struct iegbe_hw *hw,
+ uint16_t *min_length,
+ uint16_t *max_length)
+@@ -2177,21 +1972,15 @@ iegbe_oem_get_cable_length(struct iegbe_
+ uint16_t phy_data;
+
+ DEBUGFUNC1("%s",__func__);
+-
++
+ if(!hw || !min_length || !max_length) {
+ return -1;
+ }
+
+ switch (hw->phy_id) {
+- case BCM5395S_PHY_ID:
+- case BCM5481_PHY_ID:
+- *min_length = 0;
+- *max_length = iegbe_igp_cable_length_150;
+- break;
+-
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+- ret_val = iegbe_oem_read_phy_reg_ex(hw,
++ ret_val = iegbe_oem_read_phy_reg_ex(hw,
+ M88E1000_PHY_SPEC_STATUS,
+ &phy_data);
+ if(ret_val) {
+@@ -2246,13 +2035,13 @@ iegbe_oem_get_cable_length(struct iegbe_
+ /**
+ * iegbe_oem_phy_is_link_up
+ * @hw iegbe_hw struct containing device specific information
+- * @isUp a boolean returning true if link is up
++ * @isUp a boolean returning true if link is up
+ *
+ * This is called as part of iegbe_config_mac_to_phy() to align
+ * the MAC with the PHY. It turns out on ICP_XXXX, this is not
+ * done automagically.
+ **/
+-int32_t
++int32_t
+ iegbe_oem_phy_is_link_up(struct iegbe_hw *hw, int *isUp)
+ {
+ #ifdef EXTERNAL_MDIO
+@@ -2266,35 +2055,19 @@ iegbe_oem_phy_is_link_up(struct iegbe_hw
+ if(!hw || !isUp) {
+ return -1;
+ }
+- /*
++ /*
+ * Make note that the M88 phy is what'll be used on Truxton
+ * see iegbe_config_mac_to_phy
+ */
+
+ switch (hw->phy_id) {
+- case BCM5395S_PHY_ID:
+- /* Link always up */
+- *isUp = TRUE;
+- return E1000_SUCCESS;
+- break;
+-
+- case BCM5481_PHY_ID:
+- iegbe_oem_read_phy_reg_ex(hw, BCM5481_ESTAT, &phy_data);
+- ret_val = iegbe_oem_read_phy_reg_ex(hw, BCM5481_ESTAT, &phy_data);
+- if(ret_val)
+- {
+- DEBUGOUT("Unable to read PHY register BCM5481_ESTAT\n");
+- return ret_val;
+- }
+- statusMask = BCM5481_ESTAT_LINK;
+- break;
+-
+- case M88E1000_I_PHY_ID:
++ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+- iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_STATUS, &phy_data);
+- ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_STATUS, &phy_data);
++ iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_STATUS, &phy_data);
++ ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_STATUS,
++ &phy_data);
+ statusMask = M88E1000_PSSR_LINK;
+- break;
++ break;
+ default:
+ DEBUGOUT("Invalid PHY ID\n");
+ return -E1000_ERR_PHY_TYPE;
+@@ -2319,213 +2092,3 @@ iegbe_oem_phy_is_link_up(struct iegbe_hw
+ #endif /* ifdef EXTERNAL_MDIO */
+ }
+
+-
+-
+-//-----
+-// Read BCM5481 expansion register
+-//
+-int32_t
+-bcm5481_read_ex (struct iegbe_hw *hw, uint16_t reg, uint16_t *data)
+-{
+- int ret;
+- uint16_t selector;
+- uint16_t reg_data;
+-
+- // Get the current value of bits 15:12
+- ret = iegbe_oem_read_phy_reg_ex (hw, 0x15, &selector);
+- if (ret)
+- return ret;
+-
+- // Select the expansion register
+- selector &= 0xf000;
+- selector |= (0xf << 8) | (reg);
+- iegbe_oem_write_phy_reg_ex (hw, 0x17, selector);
+-
+- // Read the expansion register
+- ret = iegbe_oem_read_phy_reg_ex (hw, 0x15, &reg_data);
+-
+- // De-select the expansion registers.
+- selector &= 0xf000;
+- iegbe_oem_write_phy_reg_ex (hw, 0x17, selector);
+-
+- if (ret)
+- return ret;
+-
+- *data = reg_data;
+- return ret;
+-}
+-
+-//-----
+-// Read reg 0x18 sub-register
+-//
+-static int32_t
+-bcm5481_read_18sv (struct iegbe_hw *hw, int sv, uint16_t *data)
+-{
+- int ret;
+- uint16_t tmp_data;
+-
+- // Select reg 0x18, sv
+- tmp_data = ((sv & BCM5481_R18H_SV_MASK) << 12) | BCM5481_R18H_SV_MCTRL;
+- ret = iegbe_oem_write_phy_reg_ex (hw, BCM5481_R18H, tmp_data);
+- if(ret)
+- return ret;
+-
+- // Read reg 0x18, sv
+- ret = iegbe_oem_read_phy_reg_ex (hw, BCM5481_R18H, &tmp_data);
+- if(ret)
+- return ret;
+-
+- *data = tmp_data;
+- return ret;
+-}
+-
+-//-----
+-// Read reg 0x1C sub-register
+-//
+-int32_t
+-bcm5481_read_1csv (struct iegbe_hw *hw, int sv, uint16_t *data)
+-{
+- int ret;
+- uint16_t tmp_data;
+-
+- // Select reg 0x1c, sv
+- tmp_data = ((sv & BCM5481_R1CH_SV_MASK) << BCM5481_R1CH_SV_SHIFT);
+-
+- ret = iegbe_oem_write_phy_reg_ex (hw, BCM5481_R1CH, tmp_data);
+- if(ret)
+- return ret;
+-
+- // Read reg 0x1c, sv
+- ret = iegbe_oem_read_phy_reg_ex (hw, BCM5481_R1CH, &tmp_data);
+- if(ret)
+- return ret;
+-
+- *data = tmp_data;
+- return ret;
+-}
+-
+-//-----
+-// Read-modify-write a 0x1C register.
+-//
+-// hw - hardware access info.
+-// reg - 0x1C register to modify.
+-// data - bits which should be set.
+-// mask - the '1' bits in this argument will be cleared in the data
+-// read from 'reg' then 'data' will be or'd in and the result
+-// will be written to 'reg'.
+-
+-int32_t
+-bcm5481_rmw_1csv (struct iegbe_hw *hw, uint16_t reg, uint16_t data, uint16_t mask)
+-{
+- int32_t ret;
+- uint16_t reg_data;
+-
+- ret = 0;
+-
+- ret = bcm5481_read_1csv (hw, reg, &reg_data);
+- if (ret)
+- {
+- DEBUGOUT("Unable to read BCM5481 1CH register\n");
+- printk (KERN_ERR "Unable to read BCM5481 1CH register [0x%x]\n", reg);
+- return ret;
+- }
+-
+- reg_data &= ~mask;
+- reg_data |= (BCM5481_R1CH_WE | data);
+-
+- ret = iegbe_oem_write_phy_reg_ex (hw, BCM5481_R1CH, reg_data);
+- if(ret)
+- {
+- DEBUGOUT("Unable to write BCM5481 1CH register\n");
+- printk (KERN_ERR "Unable to write BCM5481 1CH register\n");
+- return ret;
+- }
+-
+- return ret;
+-}
+-
+-int32_t
+-oi_phy_setup (struct iegbe_hw *hw)
+-{
+- int ret;
+- uint16_t pmii_data;
+- uint16_t mctrl_data;
+- uint16_t cacr_data;
+- uint16_t sc1_data;
+- uint16_t lctl_data;
+-
+- ret = 0;
+-
+- // Set low power mode via reg 0x18, sv010, bit 6
+- // Do a read-modify-write on reg 0x18, sv010 register to preserve existing bits.
+- ret = bcm5481_read_18sv (hw, BCM5481_R18H_SV_PMII, &pmii_data);
+- if (ret)
+- {
+- DEBUGOUT("Unable to read BCM5481_R18H_SV_PMII register\n");
+- printk (KERN_ERR "Unable to read BCM5481_R18H_SV_PMII register\n");
+- return ret;
+- }
+-
+- // Set the LPM bit in the data just read and write back to sv010
+- // The shadow register select bits [2:0] are set by reading the sv010
+- // register.
+- pmii_data |= BCM5481_R18H_SV010_LPM;
+- ret = iegbe_oem_write_phy_reg_ex (hw, BCM5481_R18H, pmii_data);
+- if(ret)
+- {
+- DEBUGOUT("Unable to write BCM5481_R18H register\n");
+- printk (KERN_ERR "Unable to write BCM5481_R18H register\n");
+- return ret;
+- }
+-
+-
+- // Set the RGMII RXD to RXC skew bit in reg 0x18, sv111
+-
+- if (bcm5481_read_18sv (hw, BCM5481_R18H_SV_MCTRL, &mctrl_data))
+- {
+- DEBUGOUT("Unable to read BCM5481_R18H_SV_MCTRL register\n");
+- printk (KERN_ERR "Unable to read BCM5481_R18H_SV_MCTRL register\n");
+- return ret;
+- }
+- mctrl_data |= (BCM5481_R18H_WE | BCM5481_R18H_SV111_SKEW);
+-
+- ret = iegbe_oem_write_phy_reg_ex (hw, BCM5481_R18H, mctrl_data);
+- if(ret)
+- {
+- DEBUGOUT("Unable to write BCM5481_R18H register\n");
+- printk (KERN_ERR "Unable to write BCM5481_R18H register\n");
+- return ret;
+- }
+-
+-
+- // Enable RGMII transmit clock delay in reg 0x1c, sv00011
+- ret = bcm5481_read_1csv (hw, BCM5481_R1CH_CACR, &cacr_data);
+- if (ret)
+- {
+- DEBUGOUT("Unable to read BCM5481_R1CH_CACR register\n");
+- printk (KERN_ERR "Unable to read BCM5481_R1CH_CACR register\n");
+- return ret;
+- }
+-
+- cacr_data |= (BCM5481_R1CH_WE | BCM5481_R1CH_CACR_TCD);
+-
+- ret = iegbe_oem_write_phy_reg_ex (hw, BCM5481_R1CH, cacr_data);
+- if(ret)
+- {
+- DEBUGOUT("Unable to write BCM5481_R1CH register\n");
+- printk (KERN_ERR "Unable to write BCM5481_R1CH register\n");
+- return ret;
+- }
+-
+- // Enable dual link speed indication (0x1c, sv 00010, bit 2)
+- ret = bcm5481_rmw_1csv (hw, BCM5481_R1CH_SC1, BCM5481_R1CH_SC1_LINK, BCM5481_R1CH_SC1_LINK);
+- if (ret)
+- return ret;
+-
+- // Enable link and activity on ACTIVITY LED (0x1c, sv 01001, bit 4=1, bit 3=0)
+- ret = bcm5481_rmw_1csv (hw, BCM5481_R1CH_LCTRL, BCM5481_R1CH_LCTRL_ALEN, BCM5481_R1CH_LCTRL_ALEN | BCM5481_R1CH_LCTRL_AEN);
+- if (ret)
+- return ret;
+-
+- return ret;
+-}
+--- a/Embedded/src/GbE/iegbe_oem_phy.h
++++ b/Embedded/src/GbE/iegbe_oem_phy.h
+@@ -2,31 +2,31 @@
+
+ GPL LICENSE SUMMARY
+
+- Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
++ Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
+
+- This program is free software; you can redistribute it and/or modify
++ This program is free software; you can redistribute it and/or modify
+ it under the terms of version 2 of the GNU General Public License as
+ published by the Free Software Foundation.
+
+- 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
++ 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; if not, write to the Free Software
++ 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., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+- The full GNU General Public License is included in this distribution
++ The full GNU General Public License is included in this distribution
+ in the file called LICENSE.GPL.
+
+ Contact Information:
+ Intel Corporation
+
+- version: Embedded.L.1.0.34
++ version: Embedded.Release.Patch.L.1.0.7-5
+
+ Contact Information:
+-
+- Intel Corporation, 5000 W Chandler Blvd, Chandler, AZ 85226
++
++ Intel Corporation, 5000 W Chandler Blvd, Chandler, AZ 85226
+
+ *******************************************************************************/
+ #ifndef _IEGBE_OEM_PHY_H_
+@@ -45,10 +45,10 @@ int32_t iegbe_oem_set_trans_gasket(struc
+ uint32_t iegbe_oem_get_tipg(struct iegbe_hw *hw);
+ int iegbe_oem_phy_is_copper(struct iegbe_hw *hw);
+ uint32_t iegbe_oem_get_phy_dev_number(struct iegbe_hw *hw);
+-int iegbe_oem_mii_ioctl(struct iegbe_adapter *adapter, unsigned long flags,
++int iegbe_oem_mii_ioctl(struct iegbe_adapter *adapter, unsigned long flags,
+ struct ifreq *ifr, int cmd);
+ void iegbe_oem_fiber_live_in_suspend(struct iegbe_hw *hw);
+-void iegbe_oem_get_phy_regs(struct iegbe_adapter *adapter, uint32_t *data,
++void iegbe_oem_get_phy_regs(struct iegbe_adapter *adapter, uint32_t *data,
+ uint32_t data_length);
+ int iegbe_oem_phy_loopback(struct iegbe_adapter *adapter);
+ void iegbe_oem_loopback_cleanup(struct iegbe_adapter *adapter);
+@@ -94,81 +94,14 @@ int32_t iegbe_oem_phy_is_link_up(struct
+ #define ICP_XXXX_MAC_2 2
+
+ #define DEFAULT_ICP_XXXX_TIPG_IPGT 8 /* Inter Packet Gap Transmit Time */
+-#define ICP_XXXX_TIPG_IPGT_MASK 0x000003FFUL
+-#define BCM5481_PHY_ID 0x0143BCA2
+-#define BCM5395S_PHY_ID 0x0143BCF0
++#define ICP_XXXX_TIPG_IPGT_MASK 0x000003FFUL
+
+ /* Miscellaneous defines */
+ #ifdef IEGBE_10_100_ONLY
+- #define ICP_XXXX_AUTONEG_ADV_DEFAULT 0x0F
++ #define ICP_XXXX_AUTONEG_ADV_DEFAULT 0x0F
+ #else
+ #define ICP_XXXX_AUTONEG_ADV_DEFAULT 0x2F
+ #endif
+
+-//-----
+-// BCM5481 specifics
+-
+-#define BCM5481_ECTRL (0x10)
+-#define BCM5481_ESTAT (0x11)
+-#define BCM5481_RXERR (0x12)
+-#define BCM5481_EXPRW (0x15)
+-#define BCM5481_EXPACC (0x17)
+-#define BCM5481_ASTAT (0x19)
+-#define BCM5481_R18H (0x18)
+-#define BCM5481_R1CH (0x1c)
+-
+-//-----
+-// indirect register access via register 18h
+-
+-#define BCM5481_R18H_SV_MASK (7) // Mask for SV bits.
+-#define BCM5481_R18H_SV_ACTRL (0) // SV000 Aux. control
+-#define BCM5481_R18H_SV_10BT (1) // SV001 10Base-T
+-#define BCM5481_R18H_SV_PMII (2) // SV010 Power/MII control
+-#define BCM5481_R18H_SV_MTEST (4) // SV100 Misc. test
+-#define BCM5481_R18H_SV_MCTRL (7) // SV111 Misc. control
+-
+-#define BCM5481_R18H_SV001_POL (1 << 13) // Polarity
+-#define BCM5481_R18H_SV010_LPM (1 << 6)
+-#define BCM5481_R18H_SV111_SKEW (1 << 8)
+-#define BCM5481_R18H_WE (1 << 15) // Write enable
+-
+-// 0x1c registers
+-#define BCM5481_R1CH_SV_SHIFT (10)
+-#define BCM5481_R1CH_SV_MASK (0x1f)
+-#define BCM5481_R1CH_SC1 (0x02) // sv00010 Spare control 1
+-#define BCM5481_R1CH_CACR (0x03) // sv00011 Clock alignment control
+-#define BCM5481_R1CH_LCTRL (0x09) // sv01001 LED control
+-#define BCM5481_R1CH_LEDS1 (0x0d) // sv01101 LED selector 1
+-
+-// 0x1c common
+-#define BCM5481_R1CH_WE (1 << 15) // Write enable
+-
+-// 0x1c, sv 00010
+-#define BCM5481_R1CH_SC1_LINK (1 << 2) // sv00010 Linkspeed
+-
+-// 0x1c, sv 00011
+-#define BCM5481_R1CH_CACR_TCD (1 << 9) // sv00011 RGMII tx clock delay
+-
+-// 0x1c, sv 01001
+-#define BCM5481_R1CH_LCTRL_ALEN (1 << 4) // Activity/Link enable on ACTIVITY LED
+-#define BCM5481_R1CH_LCTRL_AEN (1 << 3) // Activity enable on ACTIVITY LED
+-
+-
+-#define BCM5481_ECTRL_DISMDIX (1 <<14)
+-
+-#define BCM5481_MCTRL_AUTOMDIX (1 <<9)
+-
+-#define BCM5481_ESTAT_LINK (1 << 8)
+-
+-#define BCM5481_ASTAT_ANC (1 << 15)
+-#define BCM5481_ASTAT_ANHCD (7 << 8)
+-#define BCM5481_ASTAT_HCD(x) ((x >> 8) & 7)
+-#define BCM5481_ASTAT_1KBTFD (0x7)
+-#define BCM5481_ASTAT_1KBTHD (0x6)
+-#define BCM5481_ASTAT_100BTXFD (0x5)
+-#define BCM5481_ASTAT_100BTXHD (0x3)
+-
+-// end BCM5481 specifics
+-
+ #endif /* ifndef _IEGBE_OEM_PHY_H_ */
+-
++
+--- a/Embedded/src/GbE/iegbe_osdep.h
++++ b/Embedded/src/GbE/iegbe_osdep.h
+@@ -2,7 +2,7 @@
+
+ GPL LICENSE SUMMARY
+
+- Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
++ Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of version 2 of the GNU General Public License as
+@@ -22,7 +22,7 @@ GPL LICENSE SUMMARY
+ Contact Information:
+ Intel Corporation
+
+- version: Embedded.L.1.0.34
++ version: Embedded.Release.Patch.L.1.0.7-5
+
+ Contact Information:
+
+--- a/Embedded/src/GbE/iegbe_param.c
++++ b/Embedded/src/GbE/iegbe_param.c
+@@ -2,7 +2,7 @@
+
+ GPL LICENSE SUMMARY
+
+- Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
++ Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of version 2 of the GNU General Public License as
+@@ -22,7 +22,7 @@ GPL LICENSE SUMMARY
+ Contact Information:
+ Intel Corporation
+
+- version: Embedded.L.1.0.34
++ version: Embedded.Release.Patch.L.1.0.7-5
+
+ Contact Information:
+
+@@ -239,11 +239,7 @@ E1000_PARAM(InterruptThrottleRate, "Inte
+ #define MAX_TXABSDELAY 0xFFFF
+ #define MIN_TXABSDELAY 0
+
+-#ifdef IEGBE_GBE_WORKAROUND
+-#define DEFAULT_ITR 0
+-#else
+ #define DEFAULT_ITR 8000
+-#endif
+
+
+ #define MAX_ITR 100000
+@@ -373,7 +369,7 @@ iegbe_check_options(struct iegbe_adapter
+ tx_ring->count = opt.def;
+ }
+ #endif
+- for (i = 0; i < adapter->num_queues; i++)
++ for (i = 0; i < adapter->num_tx_queues; i++)
+ tx_ring[i].count = tx_ring->count;
+ }
+ { /* Receive Descriptor Count */
+@@ -403,7 +399,7 @@ iegbe_check_options(struct iegbe_adapter
+ rx_ring->count = opt.def;
+ }
+ #endif
+- for (i = 0; i < adapter->num_queues; i++)
++ for (i = 0; i < adapter->num_rx_queues; i++)
+ rx_ring[i].count = rx_ring->count;
+ }
+ { /* Checksum Offload Enable/Disable */
+--- a/Embedded/src/GbE/kcompat.c
++++ b/Embedded/src/GbE/kcompat.c
+@@ -1,8 +1,8 @@
+-/************************************************************
+-
++/************************************************************
++
+ GPL LICENSE SUMMARY
+
+- Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
++ Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of version 2 of the GNU General Public License as
+@@ -22,183 +22,192 @@ GPL LICENSE SUMMARY
+ Contact Information:
+ Intel Corporation
+
+- version: Embedded.L.1.0.34
+-
+- Contact Information:
+-
+- Intel Corporation, 5000 W Chandler Blvd, Chandler, AZ 85226
+-
+-**************************************************************/
+-/**************************************************************************
+- * @ingroup KCOMPAT_GENERAL
+- *
+- * @file kcompat.c
+- *
+- * @description
+- *
+- *
+- **************************************************************************/
+-#include "kcompat.h"
+-
+-/*************************************************************/
+-/* 2.4.13 => 2.4.3 */
+-#if ( LINUX_VERSION_CODE < KERNEL_VERSION(0x2,0x4,0xd) )
+-
+-/**************************************/
+-/* PCI DMA MAPPING */
+-
+-#if defined(CONFIG_HIGHMEM)
+-
+-#ifndef PCI_DRAM_OFFSET
+-#define PCI_DRAM_OFFSET 0
+-#endif
+-
+-u64 _kc_pci_map_page(struct pci_dev *dev,
+- struct page *page,
+- unsigned long offset,
+- size_t size,
+- int direction)
+-{
+- u64 ret_val;
+- ret_val = (((u64)(page - mem_map) << PAGE_SHIFT) + offset +
+- PCI_DRAM_OFFSET);
+- return ret_val;
+-}
+-
+-#else /* CONFIG_HIGHMEM */
+-
+-u64 _kc_pci_map_page(struct pci_dev *dev,
+- struct page *page,
+- unsigned long offset,
+- size_t size,
+- int direction)
+-{
+- return pci_map_single(dev, (void *)page_address(page) + offset,
+- size, direction);
+-}
+-
+-#endif /* CONFIG_HIGHMEM */
+-
+-void _kc_pci_unmap_page(struct pci_dev *dev,
+- u64 dma_addr,
+- size_t size,
+- int direction)
+-{
+- return pci_unmap_single(dev, dma_addr, size, direction);
+-}
+-
+-#endif /* 2.4.13 => 2.4.3 */
+-
+-
+-/*****************************************************************************/
+-/* 2.4.3 => 2.4.0 */
+-#if ( LINUX_VERSION_CODE < KERNEL_VERSION(0x2,0x4,0x3) )
+-
+-/**************************************/
+-/* PCI DRIVER API */
+-
+-int _kc_pci_set_dma_mask(struct pci_dev *dev, dma_addr_t mask)
+-{
+- if(!pci_dma_supported(dev, mask)) {
+- return -EIO;
+- }
+- dev->dma_mask = mask;
+- return 0;
+-}
+-
+-int _kc_pci_request_regions(struct pci_dev *dev, char *res_name)
+-{
+- int i;
+-
+- for (i = 0; i < 0x6; i++) {
+- if (pci_resource_len(dev, i) == 0) {
+- continue;
+- }
+- if (pci_resource_flags(dev, i) & IORESOURCE_IO) {
+- if (!request_region(pci_resource_start(dev, i),
+- pci_resource_len(dev, i), res_name)) {
+- pci_release_regions(dev);
+- return -EBUSY;
+- }
+- } else if (pci_resource_flags(dev, i) & IORESOURCE_MEM) {
+- if (!request_mem_region(pci_resource_start(dev, i),
+- pci_resource_len(dev, i),
+- res_name)) {
+- pci_release_regions(dev);
+- return -EBUSY;
+- }
+- }
+- }
+- return 0;
+-}
+-
+-void _kc_pci_release_regions(struct pci_dev *dev)
+-{
+- int i;
+-
+- for (i = 0; i < 0x6; i++) {
+- if (pci_resource_len(dev, i) == 0) {
+- continue;
+- }
+- if (pci_resource_flags(dev, i) & IORESOURCE_IO){
+- release_region(pci_resource_start(dev, i),
+- pci_resource_len(dev, i));
+- } else if (pci_resource_flags(dev, i) & IORESOURCE_MEM) {
+- release_mem_region(pci_resource_start(dev, i),
+- pci_resource_len(dev, i));
+- }
+- }
+-}
+-
+-/**************************************/
+-/* NETWORK DRIVER API */
+-
+-struct net_device * _kc_alloc_etherdev(int sizeof_priv)
+-{
+- struct net_device *dev;
+- int alloc_size;
+-
+- alloc_size = sizeof(*dev) + sizeof_priv + IFNAMSIZ + 0x1f;
+-
+- dev = kmalloc(alloc_size, GFP_KERNEL);
+-
+- if (!dev) { return NULL; }
+-
+- memset(dev, 0, alloc_size);
+-
+- if (sizeof_priv) {
+- dev->priv = (void *) (((unsigned long)(dev + 1) + 0x1f) & ~0x1f);
+- }
+- dev->name[0] = '\0';
+-
+- ether_setup(dev);
+-
+- return dev;
+-}
+-
+-int _kc_is_valid_ether_addr(u8 *addr)
+-{
+- const char zaddr[0x6] = {0,};
+-
+- return !(addr[0]&1) && memcmp( addr, zaddr, 0x6);
+-}
+-
+-#endif /* 2.4.3 => 2.4.0 */
+-
+-
+-/*****************************************************************/
+-/* 2.4.6 => 2.4.3 */
+-#if ( LINUX_VERSION_CODE < KERNEL_VERSION(0x2,0x4,0x6) )
+-
+-int _kc_pci_set_power_state(struct pci_dev *dev, int state)
+-{ return 0; }
+-int _kc_pci_save_state(struct pci_dev *dev, u32 *buffer)
+-{ return 0; }
+-int _kc_pci_restore_state(struct pci_dev *pdev, u32 *buffer)
+-{ return 0; }
+-int _kc_pci_enable_wake(struct pci_dev *pdev, u32 state, int enable)
+-{ return 0; }
+-
+-#endif /* 2.4.6 => 2.4.3 */
+-
+-
++ version: Embedded.Release.Patch.L.1.0.7-5
++
++ Contact Information:
++
++ Intel Corporation, 5000 W Chandler Blvd, Chandler, AZ 85226
++
++**************************************************************/
++/**************************************************************************
++ * @ingroup KCOMPAT_GENERAL
++ *
++ * @file kcompat.c
++ *
++ * @description
++ *
++ *
++ **************************************************************************/
++#include "kcompat.h"
++
++/*************************************************************/
++/* 2.4.13 => 2.4.3 */
++#if ( LINUX_VERSION_CODE < KERNEL_VERSION(0x2,0x4,0xd) )
++
++/**************************************/
++/* PCI DMA MAPPING */
++
++#if defined(CONFIG_HIGHMEM)
++
++#ifndef PCI_DRAM_OFFSET
++#define PCI_DRAM_OFFSET 0
++#endif
++
++u64 _kc_pci_map_page(struct pci_dev *dev,
++ struct page *page,
++ unsigned long offset,
++ size_t size,
++ int direction)
++{
++ u64 ret_val;
++ ret_val = (((u64)(page - mem_map) << PAGE_SHIFT) + offset +
++ PCI_DRAM_OFFSET);
++ return ret_val;
++}
++
++#else /* CONFIG_HIGHMEM */
++
++u64 _kc_pci_map_page(struct pci_dev *dev,
++ struct page *page,
++ unsigned long offset,
++ size_t size,
++ int direction)
++{
++ return pci_map_single(dev, (void *)page_address(page) + offset,
++ size, direction);
++}
++
++#endif /* CONFIG_HIGHMEM */
++
++void _kc_pci_unmap_page(struct pci_dev *dev,
++ u64 dma_addr,
++ size_t size,
++ int direction)
++{
++ return pci_unmap_single(dev, dma_addr, size, direction);
++}
++
++#endif /* 2.4.13 => 2.4.3 */
++
++
++/*****************************************************************************/
++/* 2.4.3 => 2.4.0 */
++#if ( LINUX_VERSION_CODE < KERNEL_VERSION(0x2,0x4,0x3) )
++
++/**************************************/
++/* PCI DRIVER API */
++
++int _kc_pci_set_dma_mask(struct pci_dev *dev, dma_addr_t mask)
++{
++ if(!pci_dma_supported(dev, mask)) {
++ return -EIO;
++ }
++ dev->dma_mask = mask;
++ return 0;
++}
++
++int _kc_pci_request_regions(struct pci_dev *dev, char *res_name)
++{
++ int i;
++
++ for (i = 0; i < 0x6; i++) {
++ if (pci_resource_len(dev, i) == 0) {
++ continue;
++ }
++ if (pci_resource_flags(dev, i) & IORESOURCE_IO) {
++ if (!request_region(pci_resource_start(dev, i),
++ pci_resource_len(dev, i), res_name)) {
++ pci_release_regions(dev);
++ return -EBUSY;
++ }
++ } else if (pci_resource_flags(dev, i) & IORESOURCE_MEM) {
++ if (!request_mem_region(pci_resource_start(dev, i),
++ pci_resource_len(dev, i),
++ res_name)) {
++ pci_release_regions(dev);
++ return -EBUSY;
++ }
++ }
++ }
++ return 0;
++}
++
++void _kc_pci_release_regions(struct pci_dev *dev)
++{
++ int i;
++
++ for (i = 0; i < 0x6; i++) {
++ if (pci_resource_len(dev, i) == 0) {
++ continue;
++ }
++ if (pci_resource_flags(dev, i) & IORESOURCE_IO){
++ release_region(pci_resource_start(dev, i),
++ pci_resource_len(dev, i));
++ } else if (pci_resource_flags(dev, i) & IORESOURCE_MEM) {
++ release_mem_region(pci_resource_start(dev, i),
++ pci_resource_len(dev, i));
++ }
++ }
++}
++
++/**************************************/
++/* NETWORK DRIVER API */
++
++struct net_device * _kc_alloc_etherdev(int sizeof_priv)
++{
++ struct net_device *dev;
++ int alloc_size;
++
++ alloc_size = sizeof(*dev) + sizeof_priv + IFNAMSIZ + 0x1f;
++
++ dev = kmalloc(alloc_size, GFP_KERNEL);
++
++ if (!dev) { return NULL; }
++
++ memset(dev, 0, alloc_size);
++
++ if (sizeof_priv) {
++ dev->priv = (void *) (((unsigned long)(dev + 1) + 0x1f) & ~0x1f);
++ }
++ dev->name[0] = '\0';
++
++ ether_setup(dev);
++
++ return dev;
++}
++
++int _kc_is_valid_ether_addr(u8 *addr)
++{
++ const char zaddr[0x6] = {0,};
++
++ return !(addr[0]&1) && memcmp( addr, zaddr, 0x6);
++}
++
++#endif /* 2.4.3 => 2.4.0 */
++
++
++/*****************************************************************/
++/* 2.4.6 => 2.4.3 */
++#if ( LINUX_VERSION_CODE < KERNEL_VERSION(0x2,0x4,0x6) )
++
++int _kc_pci_set_power_state(struct pci_dev *dev, int state)
++{ return 0; }
++int _kc_pci_save_state(struct pci_dev *dev, u32 *buffer)
++{ return 0; }
++int _kc_pci_restore_state(struct pci_dev *pdev, u32 *buffer)
++{ return 0; }
++int _kc_pci_enable_wake(struct pci_dev *pdev, u32 state, int enable)
++{ return 0; }
++
++#endif /* 2.4.6 => 2.4.3 */
++
++
++
++#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,24) )
++
++void dump_stack(void)
++{
++}
++
++#endif /* 2.4.24 */
++
+--- a/Embedded/src/GbE/kcompat_ethtool.c
++++ b/Embedded/src/GbE/kcompat_ethtool.c
+@@ -2,7 +2,7 @@
+ /*
+ * GPL LICENSE SUMMARY
+ *
+- * Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
++ * Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+@@ -22,7 +22,7 @@
+ * Contact Information:
+ * Intel Corporation
+ *
+- * version: Embedded.L.1.0.34
++ * version: Embedded.Release.Patch.L.1.0.7-5
+ */
+
+ /**************************************************************************
+@@ -779,6 +779,7 @@ static int ethtool_get_stats(struct net_
+ }
+
+ /* The main entry point in this file. Called from net/core/dev.c */
++
+ #define ETHTOOL_OPS_COMPAT
+ int ethtool_ioctl(struct ifreq *ifr)
+ {
+--- a/Embedded/src/GbE/kcompat.h
++++ b/Embedded/src/GbE/kcompat.h
+@@ -2,7 +2,7 @@
+
+ GPL LICENSE SUMMARY
+
+- Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
++ Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of version 2 of the GNU General Public License as
+@@ -22,7 +22,7 @@ GPL LICENSE SUMMARY
+ Contact Information:
+ Intel Corporation
+
+- version: Embedded.L.1.0.34
++ version: Embedded.Release.Patch.L.1.0.7-5
+
+ Contact Information:
+
+@@ -69,15 +69,6 @@ GPL LICENSE SUMMARY
+ #define CONFIG_NET_POLL_CONTROLLER
+ #endif
+
+-#ifdef E1000_NAPI
+-#undef CONFIG_E1000_NAPI
+-#define CONFIG_E1000_NAPI
+-#endif
+-
+-#ifdef E1000_NO_NAPI
+-#undef CONFIG_E1000_NAPI
+-#endif
+-
+ #ifndef module_param
+ #define module_param(v,t,p) MODULE_PARM(v, "i");
+ #endif
+@@ -554,35 +545,14 @@ extern void _kc_pci_unmap_page(struct pc
+ #endif
+
+ /*****************************************************************************/
+-/* 2.4.23 => 2.4.22 */
+-#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,23) )
+-#ifdef CONFIG_E1000_NAPI
+-#ifndef netif_poll_disable
+-#define netif_poll_disable(x) _kc_netif_poll_disable(x)
+-static inline void _kc_netif_poll_disable(struct net_device *netdev)
+-{
+- while (test_and_set_bit(__LINK_STATE_RX_SCHED, &netdev->state)) {
+- /* No hurry */
+- current->state = TASK_INTERRUPTIBLE;
+- schedule_timeout(1);
+- }
+-}
+-#endif
+-#ifndef netif_poll_enable
+-#define netif_poll_enable(x) _kc_netif_poll_enable(x)
+-static inline void _kc_netif_poll_enable(struct net_device *netdev)
+-{
+- clear_bit(__LINK_STATE_RX_SCHED, &netdev->state);
+-}
+-#endif
+-#endif
+-#endif
+-
+-/*****************************************************************************/
+ /* 2.5.28 => 2.4.23 */
+ #if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,5,28) )
+
++#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,23) )
++static inline void _kc_synchronize_irq(void) { barrier(); }
++#else
+ static inline void _kc_synchronize_irq() { synchronize_irq(); }
++#endif /* 2.4.23 */
+ #undef synchronize_irq
+ #define synchronize_irq(X) _kc_synchronize_irq()
+
+@@ -747,6 +717,37 @@ static inline struct mii_ioctl_data *_kc
+ #define skb_header_cloned(x) 0
+ #endif /* SKB_DATAREF_SHIFT not defined */
+
++#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10) )
++
++#define ioread32(addr) readl(addr)
++#define iowrite32(val,addr) writel(val,addr)
++
++#endif /* 2.6.10 */
++
++#ifndef DEFINE_SPINLOCK
++#define DEFINE_SPINLOCK(s) spinlock_t s = SPIN_LOCK_UNLOCKED
++#endif /* DEFINE_SPINLOCK */
++
++#ifndef PCI_COMMAND_INTX_DISABLE
++#define PCI_COMMAND_INTX_DISABLE 0x400 /* INTx Emulation Disable */
++#endif /* PCI_COMMAND_INTX_DISABLE */
++
++#ifndef ETH_GSTRING_LEN
++#define ETH_GSTRING_LEN 32
++#endif /* ETH_GSTRING_LEN */
++
++#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,24) )
++
++extern void dump_stack(void);
++
++#undef register_reboot_notifier
++#define register_reboot_notifier(a)
++
++#undef unregister_reboot_notifier
++#define unregister_reboot_notifier(a)
++
++#endif /* 2.4.24 */
++
+ #endif /* _KCOMPAT_H_ */
+
+
+--- a/Embedded/src/GbE/Makefile
++++ b/Embedded/src/GbE/Makefile
+@@ -1,6 +1,6 @@
+ # GPL LICENSE SUMMARY
+ #
+-# Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
++# Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
+ #
+ # This program is free software; you can redistribute it and/or modify
+ # it under the terms of version 2 of the GNU General Public License as
+@@ -20,7 +20,7 @@
+ # Contact Information:
+ # Intel Corporation
+ #
+-# version: Embedded.L.1.0.34
++# version: Embedded.Release.Patch.L.1.0.7-5
+
+ ###########################################################################
+ # Driver files
+@@ -35,6 +35,8 @@ MDIO_PHONY_CFILES = gcu.c
+ MDIO_CFILES = gcu_main.c gcu_if.c
+ MDIO_HFILES = gcu.h gcu_if.h gcu_reg.h kcompat.h
+
++KVER=$(shell uname -r)
++
+ #
+ # Variables:
+ # KSRC (path to kernel source to build against)
+@@ -50,45 +52,16 @@ MDIO_HFILES = gcu.h gcu_if.h gcu_reg.h k
+
+ # set KSRC, KOBJ, and EXTERNAL_MDIO to default values of not already set
+ #
+-KOBJ ?= /usr/src/kernels/linux
+-KSRC ?= /usr/src/kernels/linux
++#KOBJ=/usr/src/kernels/linux
++#KSRC=/usr/src/kernels/linux
++#KSRC=$(KOBJ)
+ EXTERNAL_MDIO ?= 1
+ GBE_NAME = iegbe
+ GCU_NAME = gcu
+
+-# By default the workaround for the IEGBE writeback issue is enabled
+-#
+-IEGBE_GBE_WORKAROUND ?= 0
+-
+-# If the platform only supports 10/100 this variable needs to be set
+-# so the default advertisement is set appropriately.
+-# By default, this variable will be disabled.
+-#
+-IEGBE_10_100_ONLY ?= 0
+-
+-# check for version.h and autoconf.h for running kernel in /boot (SUSE)
+-ifneq (,$(wildcard /boot/vmlinuz.version.h))
+- VERSION_FILE := /boot/vmlinuz.version.h
+- CONFIG_FILE := /boot/vmlinuz.autoconf.h
+- KVER := $(shell $(CC) $(CFLAGS) -E -dM $(VERSION_FILE) | \
+- grep UTS_RELEASE | awk '{ print $$3 }' | sed 's/\"//g')
+- ifeq ($(KVER),$(shell uname -r))
+- # set up include path to override headers from kernel source
+- x:=$(shell rm -rf include)
+- x:=$(shell mkdir -p include/linux)
+- x:=$(shell cp /boot/vmlinuz.version.h include/linux/version.h)
+- x:=$(shell cp /boot/vmlinuz.autoconf.h include/linux/autoconf.h)
+- CFLAGS += -I./include
+- else
+- VERSION_FILE := $(KOBJ)/include/linux/version.h
+- UTS_REL_FILE := $(KSRC)/include/linux/utsrelease.h
+- CONFIG_FILE := $(KOBJ)/include/linux/autoconf.h
+- endif
+-else
+- VERSION_FILE := $(KOBJ)/include/linux/version.h
+- UTS_REL_FILE := $(KSRC)/include/linux/utsrelease.h
+- CONFIG_FILE := $(KOBJ)/include/linux/autoconf.h
+-endif
++VERSION_FILE := $(KSRC)/include/linux/version.h
++UTS_REL_FILE := $(KSRC)/include/linux/utsrelease.h
++CONFIG_FILE := $(KSRC)/include/linux/autoconf.h
+
+ ifeq (,$(wildcard $(VERSION_FILE)))
+ $(error Linux kernel source not configured - missing version.h)
+@@ -98,83 +71,8 @@ ifeq (,$(wildcard $(CONFIG_FILE)))
+ $(error Linux kernel source not configured - missing autoconf.h)
+ endif
+
+-# as of 2.6.16, kernel define UTS_RELEASE has been moved to utsrelease.h
+-# so check that file for kernel version string instead of version.h
+-USE_UTS_REL := $(shell [ -f $(UTS_REL_FILE) ] && echo "1")
+-
+-# pick a compiler
+-ifneq (,$(findstring egcs-2.91.66, $(shell cat /proc/version)))
+- CC := kgcc gcc cc
+-else
+- CC := gcc cc
+-endif
+-test_cc = $(shell $(cc) --version > /dev/null 2>&1 && echo $(cc))
+-CC := $(foreach cc, $(CC), $(test_cc))
+-CC := $(firstword $(CC))
+-ifeq (,$(CC))
+- $(error Compiler not found)
+-endif
+-
+-# we need to know what platform the driver is being built on
+-# some additional features are only built on Intel platforms
+-ARCH := $(shell uname -m | sed 's/i.86/i386/')
+-ifeq ($(ARCH),alpha)
+- CFLAGS += -ffixed-8 -mno-fp-regs
+-endif
+-ifeq ($(ARCH),x86_64)
+- CFLAGS += -mcmodel=kernel -mno-red-zone
+-endif
+-ifeq ($(ARCH),ppc)
+- CFLAGS += -msoft-float
+-endif
+-ifeq ($(ARCH),ppc64)
+- CFLAGS += -m64 -msoft-float
+- LDFLAGS += -melf64ppc
+-endif
+-
+-# standard flags for module builds
+-CFLAGS += -DLINUX -D__KERNEL__ -DMODULE -O2 -pipe -Wall
+-CFLAGS += -I$(KSRC)/include -I.
+-CFLAGS += $(shell [ -f $(KSRC)/include/linux/modversions.h ] && \
+- echo "-DMODVERSIONS -DEXPORT_SYMTAB \
+- -include $(KSRC)/include/linux/modversions.h")
+-
+-ifeq ($(IEGBE_GBE_WORKAROUND), 1)
+-CFLAGS += -DIEGBE_GBE_WORKAROUND -DE1000_NO_NAPI
+-endif
+-
+-ifeq ($(IEGBE_10_100_ONLY), 1)
+-CFLAGS += -DIEGBE_10_100_ONLY
+-endif
+-
+-CFLAGS += $(CFLAGS_EXTRA)
+-#ifeq (,$(shell echo $(CFLAGS_EXTRA) | grep NAPI))
+-#CFLAGS += -DE1000_NO_NAPI
+-#CFLAGS_EXTRA += -DE1000_NO_NAPI
+-#endif
+-
+-RHC := $(KSRC)/include/linux/rhconfig.h
+-ifneq (,$(wildcard $(RHC)))
+- # 7.3 typo in rhconfig.h
+- ifneq (,$(shell $(CC) $(CFLAGS) -E -dM $(RHC) | grep __module__bigmem))
+- CFLAGS += -D__module_bigmem
+- endif
+-endif
+-
+-# get the kernel version - we use this to find the correct install path
+-ifeq ($(USE_UTS_REL), 1)
+- KVER := $(shell $(CC) $(CFLAGS) -E -dM $(UTS_REL_FILE) | grep UTS_RELEASE | \
+- awk '{ print $$3 }' | sed 's/\"//g')
+-else
+- KVER := $(shell $(CC) $(CFLAGS) -E -dM $(VERSION_FILE) | grep UTS_RELEASE | \
+- awk '{ print $$3 }' | sed 's/\"//g')
+-endif
+-
+-KKVER := $(shell echo $(KVER) | \
+- awk '{ if ($$0 ~ /2\.[6-9]\./) print "1"; else print "0"}')
+-ifeq ($(KKVER), 0)
+- $(error *** Aborting the build. \
+- *** This driver is not supported on kernel versions older than 2.6.18)
++ifeq (,$(wildcard $(UTS_REL_FILE)))
++ $(error Linux kernel source not configured - missing utsrelease.h)
+ endif
+
+ # set the install path
+@@ -202,11 +100,11 @@ ifneq ($(SMP),$(shell uname -a | grep SM
+ endif
+
+ ifeq ($(SMP),1)
+- CFLAGS += -D__SMP__
++ EXTRA_CFLAGS += -D__SMP__
+ endif
+
+ ifeq ($(EXTERNAL_MDIO), 1)
+- CFLAGS += -DEXTERNAL_MDIO
++ EXTRA_CFLAGS += -DEXTERNAL_MDIO
+ endif
+
+ ###########################################################################
+@@ -223,7 +121,6 @@ MANSECTION = 7
+ MANFILE = $(TARGET:.ko=.$(MANSECTION))
+
+ ifneq ($(PATCHLEVEL),)
+- EXTRA_CFLAGS += $(CFLAGS_EXTRA)
+ obj-m += $(TARGET:.ko=.o)
+ iegbe-objs := $(CFILES:.c=.o)
+ ifeq ($(EXTERNAL_MDIO),1)
+--- a/filelist
++++ b/filelist
+@@ -1,41 +1,3 @@
+-Embedded/Makefile
+-Embedded/environment.mk
+-Embedded/src/1588/1588.c
+-Embedded/src/1588/1588.h
+-Embedded/src/1588/IxTimeSyncAcc_p.h
+-Embedded/src/1588/Makefile
+-Embedded/src/1588/ixtimesyncacc.c
+-Embedded/src/1588/ixtimesyncacc.h
+-Embedded/src/1588/linux_ioctls.h
+-Embedded/src/CAN/Makefile
+-Embedded/src/CAN/can_fifo.c
+-Embedded/src/CAN/can_fifo.h
+-Embedded/src/CAN/can_ioctl.h
+-Embedded/src/CAN/can_main.c
+-Embedded/src/CAN/can_main.h
+-Embedded/src/CAN/can_port.h
+-Embedded/src/CAN/icp_can.c
+-Embedded/src/CAN/icp_can.h
+-Embedded/src/CAN/icp_can_regs.h
+-Embedded/src/CAN/icp_can_types.h
+-Embedded/src/CAN/icp_can_user.h
+-Embedded/src/EDMA/Makefile
+-Embedded/src/EDMA/dma.h
+-Embedded/src/EDMA/dma_api.h
+-Embedded/src/EDMA/dma_client_api.c
+-Embedded/src/EDMA/dma_common.c
+-Embedded/src/EDMA/dma_internals.h
+-Embedded/src/EDMA/dma_linux.c
+-Embedded/src/EDMA/os/os.c
+-Embedded/src/EDMA/os/os.h
+-Embedded/src/EDMA/os/os_list.c
+-Embedded/src/EDMA/os/os_list.h
+-Embedded/src/EDMA/os/os_types.h
+-Embedded/src/GPIO/Makefile
+-Embedded/src/GPIO/common.h
+-Embedded/src/GPIO/gpio.h
+-Embedded/src/GPIO/gpio_ref.c
+-Embedded/src/GPIO/linux_ioctls.h
+ Embedded/src/GbE/Makefile
+ Embedded/src/GbE/gcu.h
+ Embedded/src/GbE/gcu_if.c
+@@ -55,16 +17,6 @@ Embedded/src/GbE/iegbe_param.c
+ Embedded/src/GbE/kcompat.c
+ Embedded/src/GbE/kcompat.h
+ Embedded/src/GbE/kcompat_ethtool.c
+-Embedded/src/WDT/Makefile
+-Embedded/src/WDT/iwdt.c
+-Embedded/src/WDT/iwdt.h
+-Embedded/src/patches/Intel_EP80579_RHEL5.patch
+-Embedded/src/patches/pci.ids_RHEL5.patch
+ LICENSE.GPL
+-build_system/build_files/Core/ia.mk
+-build_system/build_files/OS/linux_2.6.mk
+-build_system/build_files/OS/linux_2.6_kernel_space_rules.mk
+-build_system/build_files/common.mk
+-build_system/build_files/rules.mk
+ filelist
+ versionfile
+--- a/versionfile
++++ b/versionfile
+@@ -1,4 +1,4 @@
+-PACKAGE_TYPE=Embedded
++PACKAGE_TYPE=Embedded.Release.Patch
+
+ PACKAGE_OS=L
+
+@@ -6,4 +6,6 @@ PACKAGE_VERSION_MAJOR_NUMBER=1
+
+ PACKAGE_VERSION_MINOR_NUMBER=0
+
+-PACKAGE_VERSION_PATCH_NUMBER=34
++PACKAGE_VERSION_PATCH_NUMBER=7
++
++PACKAGE_VERSION_BUILD_NUMBER=5
diff --git a/package/system/ep80579-drivers/patches/002-cflags_cleanup.patch b/package/system/ep80579-drivers/patches/002-cflags_cleanup.patch
new file mode 100644
index 0000000..f897527
--- /dev/null
+++ b/package/system/ep80579-drivers/patches/002-cflags_cleanup.patch
@@ -0,0 +1,22 @@
+--- a/build_system/build_files/common.mk
++++ b/build_system/build_files/common.mk
+@@ -122,7 +122,7 @@ CC=$(COMPILER)
+ LD=$(LINKER)
+ AR=$(ARCHIVER)
+
+-CFLAGS+=-O2
++#CFLAGS+=-O2
+
+
+ PWD= $(shell pwd)
+--- a/build_system/build_files/OS/linux_2.6.mk
++++ b/build_system/build_files/OS/linux_2.6.mk
+@@ -80,7 +80,7 @@ endif
+
+
+ ifeq ($(OS_LEVEL), kernel_space)
+-CFLAGS+=
++#CFLAGS+=
+ endif
+
+
diff --git a/package/system/ep80579-drivers/patches/003-new_irqf_constants.patch b/package/system/ep80579-drivers/patches/003-new_irqf_constants.patch
new file mode 100644
index 0000000..af231f2
--- /dev/null
+++ b/package/system/ep80579-drivers/patches/003-new_irqf_constants.patch
@@ -0,0 +1,53 @@
+--- a/Embedded/src/1588/1588.c
++++ b/Embedded/src/1588/1588.c
+@@ -291,7 +291,7 @@ int pci_probe(struct pci_dev *dev, const
+
+ }
+
+- if ( request_irq(dev->irq, &timesync_isr, SA_SHIRQ, DRIVERNAME,
++ if ( request_irq(dev->irq, &timesync_isr, IRQF_SHARED, DRIVERNAME,
+ &g_drvr_data) )
+ {
+ printk("%s-pci_probe: irq\n", DRIVERNAME);
+--- a/Embedded/src/CAN/can_main.c
++++ b/Embedded/src/CAN/can_main.c
+@@ -424,7 +424,7 @@ int can_open(struct inode *inode, struct
+ err = request_irq(
+ can_os->irq,
+ can_irq_handler,
+- SA_SHIRQ,
++ IRQF_SHARED,
+ iminor(can_os->inode) ? CAN_PROC_1 : CAN_PROC_0,
+ &(g_can_os[iminor(can_os->inode)])
+ );
+--- a/Embedded/src/EDMA/dma_linux.c
++++ b/Embedded/src/EDMA/dma_linux.c
+@@ -367,7 +367,7 @@ int32_t edma_resume(struct pci_dev *dev)
+ return -ENODEV;
+ }
+
+- if (request_irq(dev->irq, &edma_irq_handler, SA_SHIRQ,
++ if (request_irq(dev->irq, &edma_irq_handler, IRQF_SHARED,
+ g_char_drvr_name, dev) )
+ {
+
+@@ -829,7 +829,7 @@ int32_t edma_probe(struct pci_dev * dev,
+ /*
+ * Obtain a (shared) Interrupt Request (IRQ) Line from the OS.
+ */
+- if (request_irq(dev->irq, &edma_irq_handler, SA_SHIRQ,
++ if (request_irq(dev->irq, &edma_irq_handler, IRQF_SHARED,
+ g_char_drvr_name, dev) )
+ {
+
+--- a/Embedded/src/WDT/iwdt.c
++++ b/Embedded/src/WDT/iwdt.c
+@@ -1461,7 +1461,7 @@ static int __init wdt_init_one(struct pc
+
+ /* Request irq only if wdt_irq is other than 0 */
+ if (wdt_irq) {
+- if (request_irq(wdt_irq, wdt_isr, SA_INTERRUPT | SA_SHIRQ,
++ if (request_irq(wdt_irq, wdt_isr, IRQF_DISABLED | IRQF_SHARED,
+ "iwdt", &wdt_miscdev)) {
+ printk("IRQ %d is not free.\n", wdt_irq);
+ return -EIO;
diff --git a/package/system/ep80579-drivers/patches/100-iegbe_netdev_ops.patch b/package/system/ep80579-drivers/patches/100-iegbe_netdev_ops.patch
new file mode 100644
index 0000000..162449c
--- /dev/null
+++ b/package/system/ep80579-drivers/patches/100-iegbe_netdev_ops.patch
@@ -0,0 +1,56 @@
+--- a/Embedded/src/GbE/iegbe_main.c
++++ b/Embedded/src/GbE/iegbe_main.c
+@@ -724,6 +724,26 @@ static void iegbe_dump_eeprom(struct ieg
+ kfree(data);
+ }
+
++static const struct net_device_ops iegbe_netdev_ops = {
++ .ndo_open = iegbe_open,
++ .ndo_stop = iegbe_close,
++ .ndo_start_xmit = iegbe_xmit_frame,
++ .ndo_get_stats = iegbe_get_stats,
++ .ndo_set_rx_mode = iegbe_set_rx_mode,
++ .ndo_set_mac_address = iegbe_set_mac,
++ .ndo_tx_timeout = iegbe_tx_timeout,
++ .ndo_change_mtu = iegbe_change_mtu,
++ .ndo_do_ioctl = iegbe_ioctl,
++ .ndo_validate_addr = eth_validate_addr,
++
++ .ndo_vlan_rx_register = iegbe_vlan_rx_register,
++ .ndo_vlan_rx_add_vid = iegbe_vlan_rx_add_vid,
++ .ndo_vlan_rx_kill_vid = iegbe_vlan_rx_kill_vid,
++#ifdef CONFIG_NET_POLL_CONTROLLER
++ .ndo_poll_controller = iegbe_netpoll,
++#endif
++};
++
+ /**
+ * iegbe_probe - Device Initialization Routine
+ * @pdev: PCI device information struct
+@@ -800,24 +820,11 @@ static int __devinit iegbe_probe(struct
+ if (!hw->hw_addr)
+ goto err_ioremap;
+
+- netdev->open = &iegbe_open;
+- netdev->stop = &iegbe_close;
+- netdev->hard_start_xmit = &iegbe_xmit_frame;
+- netdev->get_stats = &iegbe_get_stats;
+- netdev->set_rx_mode = &iegbe_set_rx_mode;
+- netdev->set_mac_address = &iegbe_set_mac;
+- netdev->change_mtu = &iegbe_change_mtu;
+- netdev->do_ioctl = &iegbe_ioctl;
++ netdev->netdev_ops = &iegbe_netdev_ops;
+ set_ethtool_ops(netdev);
+- netdev->tx_timeout = &iegbe_tx_timeout;
+ netdev->watchdog_timeo = 5 * HZ;
+ netif_napi_add(netdev, &adapter->napi, iegbe_clean, 64);
+- netdev->vlan_rx_register = iegbe_vlan_rx_register;
+- netdev->vlan_rx_add_vid = iegbe_vlan_rx_add_vid;
+- netdev->vlan_rx_kill_vid = iegbe_vlan_rx_kill_vid;
+-#ifdef CONFIG_NET_POLL_CONTROLLER
+- netdev->poll_controller = iegbe_netpoll;
+-#endif
++
+ strncpy(netdev->name, pci_name(pdev), sizeof(netdev->name) - 1);
+
+
diff --git a/package/system/ep80579-drivers/patches/101-iegbe_fix_napi_interface.patch b/package/system/ep80579-drivers/patches/101-iegbe_fix_napi_interface.patch
new file mode 100644
index 0000000..921d464
--- /dev/null
+++ b/package/system/ep80579-drivers/patches/101-iegbe_fix_napi_interface.patch
@@ -0,0 +1,41 @@
+--- a/Embedded/src/GbE/iegbe_main.c
++++ b/Embedded/src/GbE/iegbe_main.c
+@@ -3465,12 +3465,12 @@ static irqreturn_t iegbe_intr_msi(int ir
+ printk("Critical error! ICR = 0x%x\n", icr);
+ return IRQ_HANDLED;
+ }
+- if (likely(netif_rx_schedule_prep(netdev, &adapter->napi))) {
++ if (likely(napi_schedule_prep(&adapter->napi))) {
+ adapter->total_tx_bytes = 0;
+ adapter->total_tx_packets = 0;
+ adapter->total_rx_bytes = 0;
+ adapter->total_rx_packets = 0;
+- __netif_rx_schedule(netdev, &adapter->napi);
++ __napi_schedule(&adapter->napi);
+ } else
+ iegbe_irq_enable(adapter);
+
+@@ -3527,12 +3527,12 @@ iegbe_intr(int irq, void *data)
+ E1000_WRITE_REG(&adapter->hw, IMC, ~0);
+ E1000_WRITE_FLUSH(&adapter->hw);
+ }
+- if (likely(netif_rx_schedule_prep(netdev, &adapter->napi))) {
++ if (likely(napi_schedule_prep(&adapter->napi))) {
+ adapter->total_tx_bytes = 0;
+ adapter->total_tx_packets = 0;
+ adapter->total_rx_bytes = 0;
+ adapter->total_rx_packets = 0;
+- __netif_rx_schedule(netdev, &adapter->napi);
++ __napi_schedule(&adapter->napi);
+ } else
+ /* this really should not happen! if it does it is basically a
+ * bug, but not a hard error, so enable ints and continue */
+@@ -3574,7 +3574,7 @@ static int iegbe_clean(struct napi_struc
+ if (work_done < budget) {
+ if (likely(adapter->itr_setting & 3))
+ iegbe_set_itr(adapter);
+- netif_rx_complete(poll_dev, napi);
++ napi_complete(napi);
+ iegbe_irq_enable(adapter);
+ }
+
diff --git a/package/system/ep80579-drivers/patches/102-iegbe_nuke_polling_netdev.patch b/package/system/ep80579-drivers/patches/102-iegbe_nuke_polling_netdev.patch
new file mode 100644
index 0000000..f7ca627
--- /dev/null
+++ b/package/system/ep80579-drivers/patches/102-iegbe_nuke_polling_netdev.patch
@@ -0,0 +1,103 @@
+--- a/Embedded/src/GbE/iegbe.h
++++ b/Embedded/src/GbE/iegbe.h
+@@ -316,7 +316,6 @@ struct iegbe_adapter {
+ int cleaned_count);
+ struct iegbe_rx_ring *rx_ring; /* One per active queue */
+ struct napi_struct napi;
+- struct net_device *polling_netdev; /* One per active queue */
+
+ int num_tx_queues;
+ int num_rx_queues;
+--- a/Embedded/src/GbE/iegbe_main.c
++++ b/Embedded/src/GbE/iegbe_main.c
+@@ -763,7 +763,7 @@ static int __devinit iegbe_probe(struct
+ struct iegbe_hw *hw;
+
+ static int cards_found = 0;
+- int i, err, pci_using_dac;
++ int err, pci_using_dac;
+ u16 eeprom_data = 0;
+ u16 eeprom_apme_mask = E1000_EEPROM_APME;
+ int bars;
+@@ -984,11 +984,8 @@ err_eeprom:
+ iegbe_phy_hw_reset(hw);
+ if (hw->flash_address)
+ iounmap(hw->flash_address);
+- for (i = 0; i < adapter->num_rx_queues; i++)
+- dev_put(&adapter->polling_netdev[i]);
+ kfree(adapter->tx_ring);
+ kfree(adapter->rx_ring);
+- kfree(adapter->polling_netdev);
+ err_sw_init:
+ iounmap(hw->hw_addr);
+ err_ioremap:
+@@ -1017,7 +1014,6 @@ iegbe_remove(struct pci_dev *pdev)
+ struct net_device *netdev = pci_get_drvdata(pdev);
+ struct iegbe_adapter *adapter = netdev_priv(netdev);
+ uint32_t manc;
+- int i;
+
+ if(adapter->hw.mac_type >= iegbe_82540
+ && adapter->hw.mac_type != iegbe_icp_xxxx
+@@ -1030,15 +1026,11 @@ iegbe_remove(struct pci_dev *pdev)
+ }
+
+ unregister_netdev(netdev);
+- for (i = 0x0; i < adapter->num_rx_queues; i++)
+- dev_put(&adapter->polling_netdev[i]);
+-
+ if(!iegbe_check_phy_reset_block(&adapter->hw)) {
+ iegbe_phy_hw_reset(&adapter->hw);
+ }
+ kfree(adapter->tx_ring);
+ kfree(adapter->rx_ring);
+- kfree(adapter->polling_netdev);
+
+ iounmap(adapter->hw.hw_addr);
+ pci_release_regions(pdev);
+@@ -1061,7 +1053,6 @@ iegbe_sw_init(struct iegbe_adapter *adap
+ struct iegbe_hw *hw = &adapter->hw;
+ struct net_device *netdev = adapter->netdev;
+ struct pci_dev *pdev = adapter->pdev;
+- int i;
+
+ /* PCI config space info */
+
+@@ -1111,11 +1102,6 @@ iegbe_sw_init(struct iegbe_adapter *adap
+ return -ENOMEM;
+ }
+
+- for (i = 0; i < adapter->num_rx_queues; i++) {
+- adapter->polling_netdev[i].priv = adapter;
+- dev_hold(&adapter->polling_netdev[i]);
+- set_bit(__LINK_STATE_START, &adapter->polling_netdev[i].state);
+- }
+ spin_lock_init(&adapter->tx_queue_lock);
+
+ /*
+@@ -1137,8 +1123,7 @@ iegbe_sw_init(struct iegbe_adapter *adap
+ * @adapter: board private structure to initialize
+ *
+ * We allocate one ring per queue at run-time since we don't know the
+- * number of queues at compile-time. The polling_netdev array is
+- * intended for Multiqueue, but should work fine with a single queue.
++ * number of queues at compile-time.
+ **/
+
+ static int __devinit
+@@ -1158,15 +1143,6 @@ iegbe_alloc_queues(struct iegbe_adapter
+ return -ENOMEM;
+ }
+
+- adapter->polling_netdev = kcalloc(adapter->num_rx_queues,
+- sizeof(struct net_device),
+- GFP_KERNEL);
+- if (!adapter->polling_netdev) {
+- kfree(adapter->tx_ring);
+- kfree(adapter->rx_ring);
+- return -ENOMEM;
+- }
+-
+ return E1000_SUCCESS;
+ }
+
diff --git a/package/system/ep80579-drivers/patches/103-iegbe_convert_unicast_addr_list.patch b/package/system/ep80579-drivers/patches/103-iegbe_convert_unicast_addr_list.patch
new file mode 100644
index 0000000..71d2d54
--- /dev/null
+++ b/package/system/ep80579-drivers/patches/103-iegbe_convert_unicast_addr_list.patch
@@ -0,0 +1,60 @@
+--- a/Embedded/src/GbE/iegbe_main.c
++++ b/Embedded/src/GbE/iegbe_main.c
+@@ -2161,7 +2161,8 @@ static void iegbe_set_rx_mode(struct net
+ {
+ struct iegbe_adapter *adapter = netdev_priv(netdev);
+ struct iegbe_hw *hw = &adapter->hw;
+- struct dev_addr_list *uc_ptr;
++ struct netdev_hw_addr *ha;
++ bool use_uc = false;
+ struct dev_addr_list *mc_ptr;
+ u32 rctl;
+ u32 hash_value;
+@@ -2187,12 +2188,11 @@ int mta_reg_count = E1000_NUM_MTA_REGIST
+ }
+ }
+
+- uc_ptr = NULL;
+ if (netdev->uc_count > rar_entries - 1) {
+ rctl |= E1000_RCTL_UPE;
+ } else if (!(netdev->flags & IFF_PROMISC)) {
+ rctl &= ~E1000_RCTL_UPE;
+- uc_ptr = netdev->uc_list;
++ use_uc = true;
+ }
+
+ E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
+@@ -2210,13 +2210,20 @@ int mta_reg_count = E1000_NUM_MTA_REGIST
+ * if there are not 14 addresses, go ahead and clear the filters
+ * -- with 82571 controllers only 0-13 entries are filled here
+ */
++ i = 1;
++ if (use_uc)
++ list_for_each_entry(ha, &netdev->uc_list, list) {
++ if (i == rar_entries)
++ break;
++ iegbe_rar_set(hw, ha->addr, i++);
++ }
++
++ WARN_ON(i == rar_entries);
++
+ mc_ptr = netdev->mc_list;
+
+- for (i = 1; i < rar_entries; i++) {
+- if (uc_ptr) {
+- iegbe_rar_set(hw, uc_ptr->da_addr, i);
+- uc_ptr = uc_ptr->next;
+- } else if (mc_ptr) {
++ for (; i < rar_entries; i++) {
++ if (mc_ptr) {
+ iegbe_rar_set(hw, mc_ptr->da_addr, i);
+ mc_ptr = mc_ptr->next;
+ } else {
+@@ -2226,7 +2233,6 @@ int mta_reg_count = E1000_NUM_MTA_REGIST
+ E1000_WRITE_FLUSH(&adapter->hw);
+ }
+ }
+- WARN_ON(uc_ptr != NULL);
+
+ /* clear the old settings from the multicast hash table */
+
diff --git a/package/system/ep80579-drivers/patches/104-iegbe_group_address_list_and_its_count.patch b/package/system/ep80579-drivers/patches/104-iegbe_group_address_list_and_its_count.patch
new file mode 100644
index 0000000..c6eced6
--- /dev/null
+++ b/package/system/ep80579-drivers/patches/104-iegbe_group_address_list_and_its_count.patch
@@ -0,0 +1,20 @@
+--- a/Embedded/src/GbE/iegbe_main.c
++++ b/Embedded/src/GbE/iegbe_main.c
+@@ -2188,7 +2188,7 @@ int mta_reg_count = E1000_NUM_MTA_REGIST
+ }
+ }
+
+- if (netdev->uc_count > rar_entries - 1) {
++ if (netdev->uc.count > rar_entries - 1) {
+ rctl |= E1000_RCTL_UPE;
+ } else if (!(netdev->flags & IFF_PROMISC)) {
+ rctl &= ~E1000_RCTL_UPE;
+@@ -2212,7 +2212,7 @@ int mta_reg_count = E1000_NUM_MTA_REGIST
+ */
+ i = 1;
+ if (use_uc)
+- list_for_each_entry(ha, &netdev->uc_list, list) {
++ list_for_each_entry(ha, &netdev->uc.list, list) {
+ if (i == rar_entries)
+ break;
+ iegbe_rar_set(hw, ha->addr, i++);
diff --git a/package/system/ep80579-drivers/patches/105-iegbe_new_dma_masks.patch b/package/system/ep80579-drivers/patches/105-iegbe_new_dma_masks.patch
new file mode 100644
index 0000000..d5fc46f
--- /dev/null
+++ b/package/system/ep80579-drivers/patches/105-iegbe_new_dma_masks.patch
@@ -0,0 +1,20 @@
+--- a/Embedded/src/GbE/iegbe_main.c
++++ b/Embedded/src/GbE/iegbe_main.c
+@@ -775,13 +775,13 @@ static int __devinit iegbe_probe(struct
+ if (err)
+ return err;
+
+- if (!pci_set_dma_mask(pdev, DMA_64BIT_MASK) &&
+- !pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK)) {
++ if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64)) &&
++ !pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64))) {
+ pci_using_dac = 1;
+ } else {
+- err = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
++ err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
+ if (err) {
+- err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
++ err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
+ if (err) {
+ E1000_ERR("No usable DMA configuration, "
+ "aborting\n");
diff --git a/package/system/ep80579-drivers/patches/106-iegbe_new_irqf_constant.patch b/package/system/ep80579-drivers/patches/106-iegbe_new_irqf_constant.patch
new file mode 100644
index 0000000..a08e8c7
--- /dev/null
+++ b/package/system/ep80579-drivers/patches/106-iegbe_new_irqf_constant.patch
@@ -0,0 +1,12 @@
+--- a/Embedded/src/GbE/iegbe_ethtool.c
++++ b/Embedded/src/GbE/iegbe_ethtool.c
+@@ -944,7 +944,8 @@ iegbe_intr_test(struct iegbe_adapter *ad
+ *data = 0;
+
+ /* Hook up test interrupt handler just for this test */
+- if(!request_irq(irq, &iegbe_test_intr, 0, netdev->name, netdev)) {
++ if(!request_irq(irq, &iegbe_test_intr, IRQF_PROBE_SHARED, netdev->name,
++ netdev)) {
+ shared_int = FALSE;
+ } else if(request_irq(irq, &iegbe_test_intr, IRQF_SHARED,
+ netdev->name, netdev)){
diff --git a/package/system/ep80579-drivers/patches/150-ocracoke_island.patch b/package/system/ep80579-drivers/patches/150-ocracoke_island.patch
new file mode 100644
index 0000000..ae74e0c
--- /dev/null
+++ b/package/system/ep80579-drivers/patches/150-ocracoke_island.patch
@@ -0,0 +1,747 @@
+--- a/Embedded/src/GbE/iegbe_oem_phy.c
++++ b/Embedded/src/GbE/iegbe_oem_phy.c
+@@ -65,6 +65,10 @@ static int32_t iegbe_oem_link_m88_setup(
+ static int32_t iegbe_oem_set_phy_mode(struct iegbe_hw *hw);
+ static int32_t iegbe_oem_detect_phy(struct iegbe_hw *hw);
+
++static int32_t iegbe_oem_link_bcm5481_setup(struct iegbe_hw *hw);
++static int32_t bcm5481_read_18sv (struct iegbe_hw *hw, int sv, uint16_t *data);
++static int32_t oi_phy_setup (struct iegbe_hw *hw);
++
+ /**
+ * iegbe_oem_setup_link
+ * @hw: iegbe_hw struct containing device specific information
+@@ -114,6 +118,10 @@ iegbe_oem_setup_link(struct iegbe_hw *hw
+ }
+
+ switch (hw->phy_id) {
++ case BCM5395S_PHY_ID:
++ return E1000_SUCCESS;
++ break;
++
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+ ret_val = iegbe_oem_link_m88_setup(hw);
+@@ -121,6 +129,12 @@ iegbe_oem_setup_link(struct iegbe_hw *hw
+ return ret_val;
+ }
+ break;
++ case BCM5481_PHY_ID:
++ ret_val = iegbe_oem_link_bcm5481_setup(hw);
++ if(ret_val) {
++ return ret_val;
++ }
++ break;
+ default:
+ DEBUGOUT("Invalid PHY ID\n");
+ return -E1000_ERR_PHY_TYPE;
+@@ -179,6 +193,51 @@ iegbe_oem_setup_link(struct iegbe_hw *hw
+ #endif /* ifdef EXTERNAL_MDIO */
+ }
+
++/**
++ * iegbe_oem_link_bcm5481_setup
++ * @hw: iegbe_hw struct containing device specific information
++ *
++ * Returns E1000_SUCCESS, negative E1000 error code on failure
++ *
++ * copied verbatim from iegbe_oem_link_m88_setup
++ **/
++static int32_t
++iegbe_oem_link_bcm5481_setup(struct iegbe_hw *hw)
++{
++ int32_t ret_val;
++ uint16_t phy_data;
++
++ //DEBUGFUNC(__func__);
++
++ if(!hw)
++ return -1;
++
++ /* phy_reset_disable is set in iegbe_oem_set_phy_mode */
++ if(hw->phy_reset_disable)
++ return E1000_SUCCESS;
++
++ // Enable MDIX in extended control reg.
++ ret_val = iegbe_oem_read_phy_reg_ex(hw, BCM5481_ECTRL, &phy_data);
++ if(ret_val)
++ {
++ DEBUGOUT("Unable to read BCM5481_ECTRL register\n");
++ return ret_val;
++ }
++
++ phy_data &= ~BCM5481_ECTRL_DISMDIX;
++ ret_val = iegbe_oem_write_phy_reg_ex(hw, BCM5481_ECTRL, phy_data);
++ if(ret_val)
++ {
++ DEBUGOUT("Unable to write BCM5481_ECTRL register\n");
++ return ret_val;
++ }
++
++ ret_val = oi_phy_setup (hw);
++ if (ret_val)
++ return ret_val;
++
++ return E1000_SUCCESS;
++}
+
+ /**
+ * iegbe_oem_link_m88_setup
+@@ -340,6 +399,11 @@ iegbe_oem_force_mdi(struct iegbe_hw *hw,
+ * see iegbe_phy_force_speed_duplex, which does the following for M88
+ */
+ switch (hw->phy_id) {
++ case BCM5395S_PHY_ID:
++ case BCM5481_PHY_ID:
++ DEBUGOUT("WARNING: An empty iegbe_oem_force_mdi() has been called!\n");
++ break;
++
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+ ret_val = iegbe_oem_read_phy_reg_ex(hw,
+@@ -415,6 +479,8 @@ iegbe_oem_phy_reset_dsp(struct iegbe_hw
+ switch (hw->phy_id) {
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
++ case BCM5481_PHY_ID:
++ case BCM5395S_PHY_ID:
+ DEBUGOUT("No DSP to reset on OEM PHY\n");
+ break;
+ default:
+@@ -460,6 +526,11 @@ iegbe_oem_cleanup_after_phy_reset(struct
+ * see iegbe_phy_force_speed_duplex, which does the following for M88
+ */
+ switch (hw->phy_id) {
++ case BCM5395S_PHY_ID:
++ case BCM5481_PHY_ID:
++ DEBUGOUT("WARNING: An empty iegbe_oem_cleanup_after_phy_reset() has been called!\n");
++ break;
++
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+ /*
+@@ -573,6 +644,11 @@ iegbe_oem_set_phy_mode(struct iegbe_hw *
+ * use iegbe_set_phy_mode as example
+ */
+ switch (hw->phy_id) {
++ case BCM5395S_PHY_ID:
++ case BCM5481_PHY_ID:
++ DEBUGOUT("WARNING: An empty iegbe_oem_set_phy_mode() has been called!\n");
++ break;
++
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+ ret_val = iegbe_read_eeprom(hw,
+@@ -641,6 +717,19 @@ iegbe_oem_detect_phy(struct iegbe_hw *hw
+ }
+ hw->phy_type = iegbe_phy_oem;
+
++{
++ // If MAC2 (BCM5395 switch), manually detect the phy
++ struct iegbe_adapter *adapter;
++ uint32_t device_number;
++ adapter = (struct iegbe_adapter *) hw->back;
++ device_number = PCI_SLOT(adapter->pdev->devfn);
++ if (device_number == ICP_XXXX_MAC_2) {
++ hw->phy_id = BCM5395S_PHY_ID;
++ hw->phy_revision = 0;
++ return E1000_SUCCESS;
++ }
++}
++
+ ret_val = iegbe_oem_read_phy_reg_ex(hw, PHY_ID1, &phy_id_high);
+ if(ret_val) {
+ DEBUGOUT("Unable to read PHY register PHY_ID1\n");
+@@ -690,6 +779,8 @@ iegbe_oem_get_tipg(struct iegbe_hw *hw)
+ switch (hw->phy_id) {
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
++ case BCM5481_PHY_ID:
++ case BCM5395S_PHY_ID:
+ phy_num = DEFAULT_ICP_XXXX_TIPG_IPGT;
+ break;
+ default:
+@@ -738,6 +829,8 @@ iegbe_oem_phy_is_copper(struct iegbe_hw
+ switch (hw->phy_id) {
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
++ case BCM5481_PHY_ID:
++ case BCM5395S_PHY_ID:
+ isCopper = TRUE;
+ break;
+ default:
+@@ -796,13 +889,13 @@ iegbe_oem_get_phy_dev_number(struct iegb
+ switch(device_number)
+ {
+ case ICP_XXXX_MAC_0:
+- hw->phy_addr = 0x00;
++ hw->phy_addr = 0x01;
+ break;
+ case ICP_XXXX_MAC_1:
+- hw->phy_addr = 0x01;
++ hw->phy_addr = 0x02;
+ break;
+ case ICP_XXXX_MAC_2:
+- hw->phy_addr = 0x02;
++ hw->phy_addr = 0x00;
+ break;
+ default: hw->phy_addr = 0x00;
+ }
+@@ -851,6 +944,12 @@ iegbe_oem_mii_ioctl(struct iegbe_adapter
+ if(!adapter || !ifr) {
+ return -1;
+ }
++
++ // If MAC2 (BCM5395 switch) then leave now
++ if ((PCI_SLOT(adapter->pdev->devfn)) == ICP_XXXX_MAC_2) {
++ return -1;
++ }
++
+ switch (data->reg_num) {
+ case PHY_CTRL:
+ if(mii_reg & MII_CR_POWER_DOWN) {
+@@ -987,6 +1086,11 @@ void iegbe_oem_get_phy_regs(struct iegbe
+ * [10] = mdix mode
+ */
+ switch (adapter->hw.phy_id) {
++ case BCM5395S_PHY_ID:
++ case BCM5481_PHY_ID:
++ DEBUGOUT("WARNING: An empty iegbe_oem_get_phy_regs() has been called!\n");
++ break;
++
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+ if(corrected_len > 0) {
+@@ -1068,8 +1172,13 @@ iegbe_oem_phy_loopback(struct iegbe_adap
+ * Loopback configuration is the same for each of the supported PHYs.
+ */
+ switch (adapter->hw.phy_id) {
++ case BCM5395S_PHY_ID:
++ DEBUGOUT("WARNING: An empty iegbe_oem_phy_loopback() has been called!\n");
++ break;
++
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
++ case BCM5481_PHY_ID:
+
+ adapter->hw.autoneg = FALSE;
+
+@@ -1182,8 +1291,14 @@ iegbe_oem_loopback_cleanup(struct iegbe_
+ }
+
+ switch (adapter->hw.phy_id) {
++ case BCM5395S_PHY_ID:
++ DEBUGOUT("WARNING: An empty iegbe_oem_loopback_cleanup() has been called!\n");
++ return;
++ break;
++
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
++ case BCM5481_PHY_ID:
+ default:
+ adapter->hw.autoneg = TRUE;
+
+@@ -1243,6 +1358,11 @@ iegbe_oem_phy_speed_downgraded(struct ie
+ */
+
+ switch (hw->phy_id) {
++ case BCM5395S_PHY_ID:
++ case BCM5481_PHY_ID:
++ *isDowngraded = 0;
++ break;
++
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+ ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_STATUS,
+@@ -1305,6 +1425,11 @@ iegbe_oem_check_polarity(struct iegbe_hw
+ */
+
+ switch (hw->phy_id) {
++ case BCM5395S_PHY_ID:
++ case BCM5481_PHY_ID:
++ *polarity = 0;
++ break;
++
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+ /* return the Polarity bit in the Status register. */
+@@ -1367,6 +1492,25 @@ iegbe_oem_phy_is_full_duplex(struct iegb
+ */
+
+ switch (hw->phy_id) {
++ case BCM5395S_PHY_ID:
++ /* Always full duplex */
++ *isFD = 1;
++ break;
++
++ case BCM5481_PHY_ID:
++ ret_val = iegbe_read_phy_reg(hw, BCM5481_ASTAT, &phy_data);
++ if(ret_val) return ret_val;
++
++ switch (BCM5481_ASTAT_HCD(phy_data)) {
++ case BCM5481_ASTAT_1KBTFD:
++ case BCM5481_ASTAT_100BTXFD:
++ *isFD = 1;
++ break;
++ default:
++ *isFD = 0;
++ }
++ break;
++
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+ ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_STATUS,
+@@ -1423,6 +1567,25 @@ iegbe_oem_phy_is_speed_1000(struct iegbe
+ */
+
+ switch (hw->phy_id) {
++ case BCM5395S_PHY_ID:
++ /* Always 1000mb */
++ *is1000 = 1;
++ break;
++
++ case BCM5481_PHY_ID:
++ ret_val = iegbe_read_phy_reg(hw, BCM5481_ASTAT, &phy_data);
++ if(ret_val) return ret_val;
++
++ switch (BCM5481_ASTAT_HCD(phy_data)) {
++ case BCM5481_ASTAT_1KBTFD:
++ case BCM5481_ASTAT_1KBTHD:
++ *is1000 = 1;
++ break;
++ default:
++ *is1000 = 0;
++ }
++ break;
++
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+ ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_STATUS,
+@@ -1478,6 +1641,25 @@ iegbe_oem_phy_is_speed_100(struct iegbe_
+ * see iegbe_config_mac_to_phy
+ */
+ switch (hw->phy_id) {
++ case BCM5395S_PHY_ID:
++ /* Always 1000Mb, never 100mb */
++ *is100 = 0;
++ break;
++
++ case BCM5481_PHY_ID:
++ ret_val = iegbe_read_phy_reg(hw, BCM5481_ASTAT, &phy_data);
++ if(ret_val) return ret_val;
++
++ switch (BCM5481_ASTAT_HCD(phy_data)) {
++ case BCM5481_ASTAT_100BTXFD:
++ case BCM5481_ASTAT_100BTXHD:
++ *is100 = 1;
++ break;
++ default:
++ *is100 = 0;
++ }
++ break;
++
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+ ret_val = iegbe_oem_read_phy_reg_ex(hw,
+@@ -1535,6 +1717,11 @@ iegbe_oem_phy_get_info(struct iegbe_hw *
+ * see iegbe_phy_m88_get_info
+ */
+ switch (hw->phy_id) {
++ case BCM5395S_PHY_ID:
++ case BCM5481_PHY_ID:
++ DEBUGOUT("WARNING: An empty iegbe_oem_phy_get_info() has been called!\n");
++ break;
++
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+ /* The downshift status is checked only once, after link is
+@@ -1636,8 +1823,13 @@ iegbe_oem_phy_hw_reset(struct iegbe_hw *
+ * the M88 used in truxton.
+ */
+ switch (hw->phy_id) {
++ case BCM5395S_PHY_ID:
++ DEBUGOUT("WARNING: An empty iegbe_oem_phy_hw_reset() has been called!\n");
++ break;
++
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
++ case BCM5481_PHY_ID:
+ ret_val = iegbe_oem_read_phy_reg_ex(hw, PHY_CTRL, &phy_data);
+ if(ret_val) {
+ DEBUGOUT("Unable to read register PHY_CTRL\n");
+@@ -1699,6 +1891,8 @@ iegbe_oem_phy_init_script(struct iegbe_h
+ switch (hw->phy_id) {
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
++ case BCM5481_PHY_ID:
++ case BCM5395S_PHY_ID:
+ DEBUGOUT("Nothing to do for OEM PHY Init");
+ break;
+ default:
+@@ -1735,6 +1929,11 @@ iegbe_oem_read_phy_reg_ex(struct iegbe_h
+ return -1;
+ }
+
++ if (hw->phy_id == BCM5395S_PHY_ID) {
++ DEBUGOUT("WARNING: iegbe_oem_read_phy_reg_ex() has been unexpectedly called!\n");
++ return -1;
++ }
++
+ /* call the GCU func that will read the phy
+ *
+ * Make note that the M88 phy is what'll be used on Truxton.
+@@ -1782,6 +1981,11 @@ iegbe_oem_set_trans_gasket(struct iegbe_
+ }
+
+ switch (hw->phy_id) {
++ case BCM5395S_PHY_ID:
++ case BCM5481_PHY_ID:
++ DEBUGOUT("WARNING: An empty iegbe_oem_set_trans_gasket() has been called!\n");
++ break;
++
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+ /* Gasket set correctly for Marvell Phys, so nothing to do */
+@@ -1886,6 +2090,8 @@ iegbe_oem_phy_needs_reset_with_mac(struc
+ switch (hw->phy_id) {
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
++ case BCM5481_PHY_ID:
++ case BCM5395S_PHY_ID:
+ ret_val = FALSE;
+ break;
+ default:
+@@ -1935,6 +2141,8 @@ iegbe_oem_config_dsp_after_link_change(s
+ switch (hw->phy_id) {
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
++ case BCM5481_PHY_ID:
++ case BCM5395S_PHY_ID:
+ DEBUGOUT("No DSP to configure on OEM PHY");
+ break;
+ default:
+@@ -1978,6 +2186,12 @@ iegbe_oem_get_cable_length(struct iegbe_
+ }
+
+ switch (hw->phy_id) {
++ case BCM5395S_PHY_ID:
++ case BCM5481_PHY_ID:
++ *min_length = 0;
++ *max_length = iegbe_igp_cable_length_150;
++ break;
++
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+ ret_val = iegbe_oem_read_phy_reg_ex(hw,
+@@ -2061,6 +2275,23 @@ iegbe_oem_phy_is_link_up(struct iegbe_hw
+ */
+
+ switch (hw->phy_id) {
++ case BCM5395S_PHY_ID:
++ /* Link always up */
++ *isUp = TRUE;
++ return E1000_SUCCESS;
++ break;
++
++ case BCM5481_PHY_ID:
++ iegbe_oem_read_phy_reg_ex(hw, BCM5481_ESTAT, &phy_data);
++ ret_val = iegbe_oem_read_phy_reg_ex(hw, BCM5481_ESTAT, &phy_data);
++ if(ret_val)
++ {
++ DEBUGOUT("Unable to read PHY register BCM5481_ESTAT\n");
++ return ret_val;
++ }
++ statusMask = BCM5481_ESTAT_LINK;
++ break;
++
+ case M88E1000_I_PHY_ID:
+ case M88E1141_E_PHY_ID:
+ iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_STATUS, &phy_data);
+@@ -2092,3 +2323,210 @@ iegbe_oem_phy_is_link_up(struct iegbe_hw
+ #endif /* ifdef EXTERNAL_MDIO */
+ }
+
++
++
++//-----
++// Read BCM5481 expansion register
++//
++int32_t
++bcm5481_read_ex (struct iegbe_hw *hw, uint16_t reg, uint16_t *data)
++{
++ int ret;
++ uint16_t selector;
++ uint16_t reg_data;
++
++ // Get the current value of bits 15:12
++ ret = iegbe_oem_read_phy_reg_ex (hw, 0x15, &selector);
++ if (ret)
++ return ret;
++
++ // Select the expansion register
++ selector &= 0xf000;
++ selector |= (0xf << 8) | (reg);
++ iegbe_oem_write_phy_reg_ex (hw, 0x17, selector);
++
++ // Read the expansion register
++ ret = iegbe_oem_read_phy_reg_ex (hw, 0x15, &reg_data);
++
++ // De-select the expansion registers.
++ selector &= 0xf000;
++ iegbe_oem_write_phy_reg_ex (hw, 0x17, selector);
++
++ if (ret)
++ return ret;
++
++ *data = reg_data;
++ return ret;
++}
++
++//-----
++// Read reg 0x18 sub-register
++//
++static int32_t
++bcm5481_read_18sv (struct iegbe_hw *hw, int sv, uint16_t *data)
++{
++ int ret;
++ uint16_t tmp_data;
++
++ // Select reg 0x18, sv
++ tmp_data = ((sv & BCM5481_R18H_SV_MASK) << 12) | BCM5481_R18H_SV_MCTRL;
++ ret = iegbe_oem_write_phy_reg_ex (hw, BCM5481_R18H, tmp_data);
++ if(ret)
++ return ret;
++
++ // Read reg 0x18, sv
++ ret = iegbe_oem_read_phy_reg_ex (hw, BCM5481_R18H, &tmp_data);
++ if(ret)
++ return ret;
++
++ *data = tmp_data;
++ return ret;
++}
++
++//-----
++// Read reg 0x1C sub-register
++//
++int32_t
++bcm5481_read_1csv (struct iegbe_hw *hw, int sv, uint16_t *data)
++{
++ int ret;
++ uint16_t tmp_data;
++
++ // Select reg 0x1c, sv
++ tmp_data = ((sv & BCM5481_R1CH_SV_MASK) << BCM5481_R1CH_SV_SHIFT);
++
++ ret = iegbe_oem_write_phy_reg_ex (hw, BCM5481_R1CH, tmp_data);
++ if(ret)
++ return ret;
++
++ // Read reg 0x1c, sv
++ ret = iegbe_oem_read_phy_reg_ex (hw, BCM5481_R1CH, &tmp_data);
++ if(ret)
++ return ret;
++
++ *data = tmp_data;
++ return ret;
++}
++
++//-----
++// Read-modify-write a 0x1C register.
++//
++// hw - hardware access info.
++// reg - 0x1C register to modify.
++// data - bits which should be set.
++// mask - the '1' bits in this argument will be cleared in the data
++// read from 'reg' then 'data' will be or'd in and the result
++// will be written to 'reg'.
++
++int32_t
++bcm5481_rmw_1csv (struct iegbe_hw *hw, uint16_t reg, uint16_t data, uint16_t mask)
++{
++ int32_t ret;
++ uint16_t reg_data;
++
++ ret = 0;
++
++ ret = bcm5481_read_1csv (hw, reg, &reg_data);
++ if (ret)
++ {
++ DEBUGOUT("Unable to read BCM5481 1CH register\n");
++ printk (KERN_ERR "Unable to read BCM5481 1CH register [0x%x]\n", reg);
++ return ret;
++ }
++
++ reg_data &= ~mask;
++ reg_data |= (BCM5481_R1CH_WE | data);
++
++ ret = iegbe_oem_write_phy_reg_ex (hw, BCM5481_R1CH, reg_data);
++ if(ret)
++ {
++ DEBUGOUT("Unable to write BCM5481 1CH register\n");
++ printk (KERN_ERR "Unable to write BCM5481 1CH register\n");
++ return ret;
++ }
++
++ return ret;
++}
++
++int32_t
++oi_phy_setup (struct iegbe_hw *hw)
++{
++ int ret;
++ uint16_t pmii_data;
++ uint16_t mctrl_data;
++ uint16_t cacr_data;
++
++ ret = 0;
++
++ // Set low power mode via reg 0x18, sv010, bit 6
++ // Do a read-modify-write on reg 0x18, sv010 register to preserve existing bits.
++ ret = bcm5481_read_18sv (hw, BCM5481_R18H_SV_PMII, &pmii_data);
++ if (ret)
++ {
++ DEBUGOUT("Unable to read BCM5481_R18H_SV_PMII register\n");
++ printk (KERN_ERR "Unable to read BCM5481_R18H_SV_PMII register\n");
++ return ret;
++ }
++
++ // Set the LPM bit in the data just read and write back to sv010
++ // The shadow register select bits [2:0] are set by reading the sv010
++ // register.
++ pmii_data |= BCM5481_R18H_SV010_LPM;
++ ret = iegbe_oem_write_phy_reg_ex (hw, BCM5481_R18H, pmii_data);
++ if(ret)
++ {
++ DEBUGOUT("Unable to write BCM5481_R18H register\n");
++ printk (KERN_ERR "Unable to write BCM5481_R18H register\n");
++ return ret;
++ }
++
++
++ // Set the RGMII RXD to RXC skew bit in reg 0x18, sv111
++
++ if (bcm5481_read_18sv (hw, BCM5481_R18H_SV_MCTRL, &mctrl_data))
++ {
++ DEBUGOUT("Unable to read BCM5481_R18H_SV_MCTRL register\n");
++ printk (KERN_ERR "Unable to read BCM5481_R18H_SV_MCTRL register\n");
++ return ret;
++ }
++ mctrl_data |= (BCM5481_R18H_WE | BCM5481_R18H_SV111_SKEW);
++
++ ret = iegbe_oem_write_phy_reg_ex (hw, BCM5481_R18H, mctrl_data);
++ if(ret)
++ {
++ DEBUGOUT("Unable to write BCM5481_R18H register\n");
++ printk (KERN_ERR "Unable to write BCM5481_R18H register\n");
++ return ret;
++ }
++
++ // Enable RGMII transmit clock delay in reg 0x1c, sv00011
++ ret = bcm5481_read_1csv (hw, BCM5481_R1CH_CACR, &cacr_data);
++ if (ret)
++ {
++ DEBUGOUT("Unable to read BCM5481_R1CH_CACR register\n");
++ printk (KERN_ERR "Unable to read BCM5481_R1CH_CACR register\n");
++ return ret;
++ }
++
++ cacr_data |= (BCM5481_R1CH_WE | BCM5481_R1CH_CACR_TCD);
++
++ ret = iegbe_oem_write_phy_reg_ex (hw, BCM5481_R1CH, cacr_data);
++ if(ret)
++ {
++ DEBUGOUT("Unable to write BCM5481_R1CH register\n");
++ printk (KERN_ERR "Unable to write BCM5481_R1CH register\n");
++ return ret;
++ }
++
++ // Enable dual link speed indication (0x1c, sv 00010, bit 2)
++ ret = bcm5481_rmw_1csv (hw, BCM5481_R1CH_SC1, BCM5481_R1CH_SC1_LINK, BCM5481_R1CH_SC1_LINK);
++ if (ret)
++ return ret;
++
++ // Enable link and activity on ACTIVITY LED (0x1c, sv 01001, bit 4=1, bit 3=0)
++ ret = bcm5481_rmw_1csv (hw, BCM5481_R1CH_LCTRL, BCM5481_R1CH_LCTRL_ALEN, BCM5481_R1CH_LCTRL_ALEN | BCM5481_R1CH_LCTRL_AEN);
++ if (ret)
++ return ret;
++
++ return ret;
++}
+--- a/Embedded/src/GbE/iegbe_oem_phy.h
++++ b/Embedded/src/GbE/iegbe_oem_phy.h
+@@ -95,6 +95,8 @@ int32_t iegbe_oem_phy_is_link_up(struct
+
+ #define DEFAULT_ICP_XXXX_TIPG_IPGT 8 /* Inter Packet Gap Transmit Time */
+ #define ICP_XXXX_TIPG_IPGT_MASK 0x000003FFUL
++#define BCM5481_PHY_ID 0x0143BCA0
++#define BCM5395S_PHY_ID 0x0143BCF0
+
+ /* Miscellaneous defines */
+ #ifdef IEGBE_10_100_ONLY
+@@ -103,5 +105,65 @@ int32_t iegbe_oem_phy_is_link_up(struct
+ #define ICP_XXXX_AUTONEG_ADV_DEFAULT 0x2F
+ #endif
+
++/* BCM5481 specifics */
++
++#define BCM5481_ECTRL (0x10)
++#define BCM5481_ESTAT (0x11)
++#define BCM5481_RXERR (0x12)
++#define BCM5481_EXPRW (0x15)
++#define BCM5481_EXPACC (0x17)
++#define BCM5481_ASTAT (0x19)
++#define BCM5481_R18H (0x18)
++#define BCM5481_R1CH (0x1c)
++
++/* indirect register access via register 18h */
++
++#define BCM5481_R18H_SV_MASK (7) // Mask for SV bits.
++#define BCM5481_R18H_SV_ACTRL (0) // SV000 Aux. control
++#define BCM5481_R18H_SV_10BT (1) // SV001 10Base-T
++#define BCM5481_R18H_SV_PMII (2) // SV010 Power/MII control
++#define BCM5481_R18H_SV_MTEST (4) // SV100 Misc. test
++#define BCM5481_R18H_SV_MCTRL (7) // SV111 Misc. control
++
++#define BCM5481_R18H_SV001_POL (1 << 13) // Polarity
++#define BCM5481_R18H_SV010_LPM (1 << 6)
++#define BCM5481_R18H_SV111_SKEW (1 << 8)
++#define BCM5481_R18H_WE (1 << 15) // Write enable
++
++// 0x1c registers
++#define BCM5481_R1CH_SV_SHIFT (10)
++#define BCM5481_R1CH_SV_MASK (0x1f)
++#define BCM5481_R1CH_SC1 (0x02) // sv00010 Spare control 1
++#define BCM5481_R1CH_CACR (0x03) // sv00011 Clock alignment control
++#define BCM5481_R1CH_LCTRL (0x09) // sv01001 LED control
++#define BCM5481_R1CH_LEDS1 (0x0d) // sv01101 LED selector 1
++
++// 0x1c common
++#define BCM5481_R1CH_WE (1 << 15) // Write enable
++
++// 0x1c, sv 00010
++#define BCM5481_R1CH_SC1_LINK (1 << 2) // sv00010 Linkspeed
++
++// 0x1c, sv 00011
++#define BCM5481_R1CH_CACR_TCD (1 << 9) // sv00011 RGMII tx clock delay
++
++// 0x1c, sv 01001
++#define BCM5481_R1CH_LCTRL_ALEN (1 << 4) // Activity/Link enable on ACTIVITY LED
++#define BCM5481_R1CH_LCTRL_AEN (1 << 3) // Activity enable on ACTIVITY LED
++
++#define BCM5481_ECTRL_DISMDIX (1 <<14)
++
++#define BCM5481_MCTRL_AUTOMDIX (1 <<9)
++
++#define BCM5481_ESTAT_LINK (1 << 8)
++
++#define BCM5481_ASTAT_ANC (1 << 15)
++#define BCM5481_ASTAT_ANHCD (7 << 8)
++#define BCM5481_ASTAT_HCD(x) ((x >> 8) & 7)
++#define BCM5481_ASTAT_1KBTFD (0x7)
++#define BCM5481_ASTAT_1KBTHD (0x6)
++#define BCM5481_ASTAT_100BTXFD (0x5)
++#define BCM5481_ASTAT_100BTXHD (0x3)
++
+ #endif /* ifndef _IEGBE_OEM_PHY_H_ */
+
diff --git a/package/system/ep80579-drivers/patches/200-can_fix_ioctl_numbers.patch b/package/system/ep80579-drivers/patches/200-can_fix_ioctl_numbers.patch
new file mode 100644
index 0000000..2919466
--- /dev/null
+++ b/package/system/ep80579-drivers/patches/200-can_fix_ioctl_numbers.patch
@@ -0,0 +1,11 @@
+--- a/Embedded/src/CAN/icp_can_user.h
++++ b/Embedded/src/CAN/icp_can_user.h
+@@ -63,6 +63,8 @@
+ #ifndef __ICP_CAN_USER_H__
+ #define __ICP_CAN_USER_H__
+
++#include <linux/ioctl.h>
++
+ /*****************************************************************************
+ * Device IO control codes.
+ *****************************************************************************/
diff --git a/package/system/ep80579-drivers/patches/210-can_include_linux_fs_h.patch b/package/system/ep80579-drivers/patches/210-can_include_linux_fs_h.patch
new file mode 100644
index 0000000..26c53dc
--- /dev/null
+++ b/package/system/ep80579-drivers/patches/210-can_include_linux_fs_h.patch
@@ -0,0 +1,11 @@
+--- a/Embedded/src/CAN/can_main.c
++++ b/Embedded/src/CAN/can_main.c
+@@ -70,6 +70,8 @@
+
+ #include "can_main.h"
+ #include "can_ioctl.h"
++#include <linux/fs.h>
++
+
+ MODULE_AUTHOR("Intel(R) Corporation");
+ MODULE_DESCRIPTION("Controller Area Network Driver");
diff --git a/package/system/ep80579-drivers/patches/220-can_fix_irq_request.patch b/package/system/ep80579-drivers/patches/220-can_fix_irq_request.patch
new file mode 100644
index 0000000..2950cc7
--- /dev/null
+++ b/package/system/ep80579-drivers/patches/220-can_fix_irq_request.patch
@@ -0,0 +1,23 @@
+--- a/Embedded/src/CAN/can_main.c
++++ b/Embedded/src/CAN/can_main.c
+@@ -654,7 +654,7 @@ int can_dev_io(struct inode *inode, stru
+ /*****************************************************************************
+ * Interrupt handler.
+ *****************************************************************************/
+-irqreturn_t can_irq_handler(int irq, void *dev_id, struct pt_regs *regs)
++irqreturn_t can_irq_handler(int irq, void *dev_id)
+ {
+ can_os_t *can_os = (can_os_t *) dev_id;
+ unsigned int int_status;
+--- a/Embedded/src/CAN/can_main.h
++++ b/Embedded/src/CAN/can_main.h
+@@ -165,8 +165,7 @@ int can_dev_io(
+
+ irqreturn_t can_irq_handler(
+ int irq,
+- void *dev_id,
+- struct pt_regs *regs);
++ void *dev_id);
+
+ void can_tasklet(
+ unsigned long arg
diff --git a/package/system/ep80579-drivers/patches/230-can_remove_driver_data_direct_access.patch b/package/system/ep80579-drivers/patches/230-can_remove_driver_data_direct_access.patch
new file mode 100644
index 0000000..19dbb7e
--- /dev/null
+++ b/package/system/ep80579-drivers/patches/230-can_remove_driver_data_direct_access.patch
@@ -0,0 +1,40 @@
+--- a/Embedded/src/CAN/can_main.c
++++ b/Embedded/src/CAN/can_main.c
+@@ -214,8 +214,8 @@ int can_pci_probe(struct pci_dev *dev, c
+ spin_lock_init(&(g_can_os[can_num].int_spinlock));
+ spin_lock_init(&(g_can_os[can_num].open_spinlock));
+
+- dev->dev.driver_data = (void *) &(g_can_os[can_num]);
+- if (!dev->dev.driver_data)
++ dev_set_drvdata(&dev->dev, (void *) &(g_can_os[can_num]));
++ if (!dev_get_drvdata(&dev->dev))
+ {
+ printk("Couldn't create CAN device %d. Exiting.\n",
+ dev->device);
+@@ -237,7 +237,7 @@ int can_pci_probe(struct pci_dev *dev, c
+ *****************************************************************************/
+ void can_pci_remove(struct pci_dev *dev)
+ {
+- can_os_t *can_os = dev->dev.driver_data;
++ can_os_t *can_os = dev_get_drvdata(&dev->dev);
+
+ iounmap(can_os->pci_remap);
+ icp_can_destroy(can_os->can);
+@@ -251,7 +251,7 @@ int can_pci_suspend(struct pci_dev *dev,
+ {
+ unsigned int i;
+ unsigned int int_status;
+- can_os_t *can_os = dev->dev.driver_data;
++ can_os_t *can_os = dev_get_drvdata(&dev->dev);
+ int err;
+
+ /* Indicate that we are suspending */
+@@ -322,7 +322,7 @@ int can_pci_suspend(struct pci_dev *dev,
+ int can_pci_resume(struct pci_dev *dev)
+ {
+ unsigned int i;
+- can_os_t *can_os = dev->dev.driver_data;
++ can_os_t *can_os = dev_get_drvdata(&dev->dev);
+
+ /* Restore PCI CFG space */
+ pci_restore_state(dev);
diff --git a/package/system/ep80579-drivers/patches/300-wdt_compile_fix.patch b/package/system/ep80579-drivers/patches/300-wdt_compile_fix.patch
new file mode 100644
index 0000000..59242b8
--- /dev/null
+++ b/package/system/ep80579-drivers/patches/300-wdt_compile_fix.patch
@@ -0,0 +1,59 @@
+--- a/Embedded/src/WDT/iwdt.c
++++ b/Embedded/src/WDT/iwdt.c
+@@ -180,19 +180,19 @@ MODULE_PARM_DESC(wdt_scale, "Intel WDT s
+ module_param(wdt_intr_type, byte, WDT_INT_TYPE_IRQ);
+ MODULE_PARM_DESC(wdt_intr_type, "Intel WDT interrupt type (default SERIRQ).");
+
+-module_param(wdt_margin1, uint, TIMER_MARGIN);
++module_param(wdt_margin1, uint, 0);
+ MODULE_PARM_DESC(wdt_margin1, "First stage Intel WDT timeout in steps of 1 ms by default.");
+
+-module_param(wdt_margin2, uint, TIMER_MARGIN);
++module_param(wdt_margin2, uint, 0);
+ MODULE_PARM_DESC(wdt_margin2, "Second stage Intel WDT timeout in steps of 1 ms by default.");
+
+ module_param(nowayout, int, 0);
+ MODULE_PARM_DESC(nowayout, "Intel WDT can't be stopped once started (default=0)");
+
+-module_param(wdt_index_port, int, 0x4E);
++module_param(wdt_index_port, int, 0);
+ MODULE_PARM_DESC(wdt_index_port, "WDT Index Port (default 0x4e)");
+
+-module_param(wdt_data_port, int, 0x4E);
++module_param(wdt_data_port, int, 0);
+ MODULE_PARM_DESC(wdt_data_port, "WDT Data Port (default 0x4f)");
+
+ static int wdt_get_iobase(struct pci_dev *dev, u16 *iobase, int *irq);
+@@ -218,7 +218,7 @@ static ssize_t wdt_write(struct file *fi
+ size_t count, loff_t * pos);
+ static int wdt_ioctl(struct inode *inode, struct file *file,
+ unsigned int cmd, unsigned long arg);
+-static irqreturn_t wdt_isr(int irq, void *dev_id, struct pt_regs *regs);
++static irqreturn_t wdt_isr(int irq, void *dev_id);
+ static void __exit wdt_cleanup(void);
+ static int __init wdt_init(void);
+ static int __init wdt_init_one(struct pci_dev *dev,
+@@ -255,7 +255,7 @@ static struct pci_driver wdt_driver = {
+ name: "iwdt",
+ id_table: lpc_pci_tbl,
+ probe: wdt_init_one,
+- remove: __devexit(wdt_remove_one),
++ remove: __devexit_p(wdt_remove_one),
+ suspend: wdt_pci_suspend,
+ resume: wdt_pci_resume,
+ };
+@@ -1393,12 +1393,12 @@ static int wdt_ioctl(struct inode *inode
+
+ /*
+ * Function Name: wdt_isr()
+- * Parameter: int irq - irq number, void *dev_id, struct pt_regs *regs
++ * Parameter: int irq - irq number, void *dev_id
+ * Return Value:: IRQ_NONE - if the interrupt is not for wdt.
+ * IRQ_HANDLED - if it is for wdt.
+ * Description: This is the interrupt service routine of the WDT.
+ */
+-static irqreturn_t wdt_isr(int irq, void *dev_id, struct pt_regs *regs)
++static irqreturn_t wdt_isr(int irq, void *dev_id)
+ {
+ u8 val;
+
diff --git a/package/system/ep80579-drivers/patches/400-edma_fix_irq_request_warning.patch b/package/system/ep80579-drivers/patches/400-edma_fix_irq_request_warning.patch
new file mode 100644
index 0000000..d858aff
--- /dev/null
+++ b/package/system/ep80579-drivers/patches/400-edma_fix_irq_request_warning.patch
@@ -0,0 +1,22 @@
+--- a/Embedded/src/EDMA/dma_linux.c
++++ b/Embedded/src/EDMA/dma_linux.c
+@@ -149,8 +149,7 @@ int32_t edma_suspend (struct pci_dev *de
+ int32_t edma_resume(struct pci_dev *dev);
+ int32_t initialize_edma_device(struct edma_device *device);
+
+-static irqreturn_t edma_irq_handler(int32_t irq, void * dev_id,
+- struct pt_regs * regs);
++static irqreturn_t edma_irq_handler(int32_t irq, void * dev_id);
+
+ /* Prototypes - Misc. */
+
+@@ -429,8 +428,7 @@ int32_t edma_release(struct inode * inod
+ * Return Values: HANDLED = 1, NOT_HANDLED = 0
+ *****************************************************************************/
+
+-static irqreturn_t edma_irq_handler(int32_t irq, void * dev_id,
+- struct pt_regs * regs)
++static irqreturn_t edma_irq_handler(int32_t irq, void * dev_id)
+ {
+
+ uint32_t clear_bits;
diff --git a/package/system/ep80579-drivers/patches/500-1588_fix_irq_request_warning.patch b/package/system/ep80579-drivers/patches/500-1588_fix_irq_request_warning.patch
new file mode 100644
index 0000000..f3f9acb
--- /dev/null
+++ b/package/system/ep80579-drivers/patches/500-1588_fix_irq_request_warning.patch
@@ -0,0 +1,22 @@
+--- a/Embedded/src/1588/1588.c
++++ b/Embedded/src/1588/1588.c
+@@ -631,7 +631,7 @@ int restore_interrupts(void)
+ IRQ_NONE => this device did not interrupt
+
+ ******************************************************************************/
+-irqreturn_t timesync_isr(int irq, void *dev_id, struct pt_regs *regs)
++irqreturn_t timesync_isr(int irq, void *dev_id)
+ {
+ if ( !ixTimeSyncAccEventAmmsFlagGet() && !ixTimeSyncAccEventAsmsFlagGet()&&
+ !ixTimeSyncAccEventAtmFlagGet() && !ixTimeSyncAccEventPpsmFlagGet()&&
+--- a/Embedded/src/1588/1588.h
++++ b/Embedded/src/1588/1588.h
+@@ -128,7 +128,7 @@ int pci_suspend(struct pci_dev *dev, pm_
+ int pci_resume(struct pci_dev *dev);
+ int pci_probe(struct pci_dev *dev, const struct pci_device_id *id);
+ void pci_remove(struct pci_dev *dev);
+-irqreturn_t timesync_isr(int irq, void *dev_id, struct pt_regs *regs);
++irqreturn_t timesync_isr(int irq, void *dev_id);
+
+ // private functions
+ int save_reg_state(void);
diff --git a/package/system/ep80579-drivers/patches/600-2.6.27_includes.patch b/package/system/ep80579-drivers/patches/600-2.6.27_includes.patch
new file mode 100644
index 0000000..c11275e
--- /dev/null
+++ b/package/system/ep80579-drivers/patches/600-2.6.27_includes.patch
@@ -0,0 +1,22 @@
+--- a/Embedded/src/CAN/can_main.h
++++ b/Embedded/src/CAN/can_main.h
+@@ -65,7 +65,7 @@
+
+ #include <linux/interrupt.h>
+ #include <linux/pci.h>
+-#include <asm/semaphore.h>
++#include <linux/semaphore.h>
+ #include <linux/spinlock.h>
+ #include <linux/cdev.h>
+ #include <asm/uaccess.h>
+--- a/Embedded/src/EDMA/dma_linux.c
++++ b/Embedded/src/EDMA/dma_linux.c
+@@ -87,7 +87,7 @@
+ #include <linux/fcntl.h> /* O_ACCMODE */
+ #include <asm/system.h> /* cli, *_flags */
+ #include <asm/uaccess.h> /* copy_to_user */
+-#include <asm/semaphore.h>
++#include <linux/semaphore.h>
+ #include <asm/io.h> /* inb(), outb() */
+ #include <linux/kmod.h>
+ #include <linux/ioport.h> /* request_region */
diff --git a/package/system/ep80579-drivers/patches/601-2.6.32_includes.patch b/package/system/ep80579-drivers/patches/601-2.6.32_includes.patch
new file mode 100644
index 0000000..291fb0a
--- /dev/null
+++ b/package/system/ep80579-drivers/patches/601-2.6.32_includes.patch
@@ -0,0 +1,30 @@
+--- a/Embedded/src/1588/1588.c
++++ b/Embedded/src/1588/1588.c
+@@ -72,6 +72,7 @@
+ *
+ ****************************************************************************/
+
++#include <linux/sched.h>
+ #include "1588.h"
+
+ MODULE_AUTHOR("Intel(R) Corporation");
+--- a/Embedded/src/CAN/can_main.c
++++ b/Embedded/src/CAN/can_main.c
+@@ -68,6 +68,7 @@
+ *
+ **************************************************************************/
+
++#include <linux/sched.h>
+ #include "can_main.h"
+ #include "can_ioctl.h"
+ #include <linux/fs.h>
+--- a/Embedded/src/WDT/iwdt.c
++++ b/Embedded/src/WDT/iwdt.c
+@@ -137,6 +137,7 @@
+ #include <linux/watchdog.h>
+ #include <linux/miscdevice.h>
+ #include <linux/interrupt.h>
++#include <linux/sched.h>
+ #include "iwdt.h"
+
+ MODULE_AUTHOR("Intel(R) Corporation");
diff --git a/package/system/ep80579-drivers/patches/700-iegbe_kcompat_2.6.30.patch b/package/system/ep80579-drivers/patches/700-iegbe_kcompat_2.6.30.patch
new file mode 100644
index 0000000..ca8c1bb
--- /dev/null
+++ b/package/system/ep80579-drivers/patches/700-iegbe_kcompat_2.6.30.patch
@@ -0,0 +1,31 @@
+--- a/Embedded/src/GbE/kcompat.h
++++ b/Embedded/src/GbE/kcompat.h
+@@ -46,12 +46,6 @@ GPL LICENSE SUMMARY
+ #include <linux/sched.h>
+ #include <asm/io.h>
+
+-#ifndef IRQ_HANDLED
+-#define irqreturn_t void
+-#define IRQ_HANDLED
+-#define IRQ_NONE
+-#endif
+-
+ #ifndef SET_NETDEV_DEV
+ #define SET_NETDEV_DEV(net, pdev)
+ #endif
+@@ -748,6 +742,15 @@ extern void dump_stack(void);
+
+ #endif /* 2.4.24 */
+
++/*****************************************************************************/
++#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30) )
++#ifndef IRQ_HANDLED
++#define irqreturn_t void
++#define IRQ_HANDLED
++#define IRQ_NONE
++#endif
++#endif /* < 2.6.30 */
++
+ #endif /* _KCOMPAT_H_ */
+
+
diff --git a/package/system/ep80579-drivers/patches/701-iegbe_poll_dev.patch b/package/system/ep80579-drivers/patches/701-iegbe_poll_dev.patch
new file mode 100644
index 0000000..63a1326
--- /dev/null
+++ b/package/system/ep80579-drivers/patches/701-iegbe_poll_dev.patch
@@ -0,0 +1,11 @@
+--- a/Embedded/src/GbE/iegbe_main.c
++++ b/Embedded/src/GbE/iegbe_main.c
+@@ -3534,7 +3534,7 @@ static int iegbe_clean(struct napi_struc
+ int tx_cleaned = 0, work_done = 0;
+
+ /* Must NOT use netdev_priv macro here. */
+- adapter = poll_dev->priv;
++ adapter = netdev_priv(poll_dev);
+
+ /* iegbe_clean is called per-cpu. This lock protects
+ * tx_ring[0] from being cleaned by multiple cpus
diff --git a/package/system/ep80579-drivers/patches/710-3.3-fix-generated-header-locations.patch b/package/system/ep80579-drivers/patches/710-3.3-fix-generated-header-locations.patch
new file mode 100644
index 0000000..793d08d
--- /dev/null
+++ b/package/system/ep80579-drivers/patches/710-3.3-fix-generated-header-locations.patch
@@ -0,0 +1,91 @@
+--- a/Embedded/src/GbE/Makefile
++++ b/Embedded/src/GbE/Makefile
+@@ -60,19 +60,19 @@ GBE_NAME = iegbe
+ GCU_NAME = gcu
+
+ VERSION_FILE := $(KSRC)/include/linux/version.h
+-UTS_REL_FILE := $(KSRC)/include/linux/utsrelease.h
+-CONFIG_FILE := $(KSRC)/include/linux/autoconf.h
++UTS_REL_FILE := $(KSRC)/include/generated/utsrelease.h
++CONFIG_FILE := $(KSRC)/include/generated/autoconf.h
+
+ ifeq (,$(wildcard $(VERSION_FILE)))
+ $(error Linux kernel source not configured - missing version.h)
+ endif
+
+ ifeq (,$(wildcard $(CONFIG_FILE)))
+- $(error Linux kernel source not configured - missing autoconf.h)
++ $(error Linux kernel source not configured - missing autoconf.h)
+ endif
+
+ ifeq (,$(wildcard $(UTS_REL_FILE)))
+- $(error Linux kernel source not configured - missing utsrelease.h)
++ $(error Linux kernel source not configured - missing utsrelease.h)
+ endif
+
+ # set the install path
+--- a/Embedded/src/1588/Makefile
++++ b/Embedded/src/1588/Makefile
+@@ -97,8 +97,8 @@ OUTPUT_PATH ?= /
+ EXTRA_LDFLAGS += -whole-archive
+
+ VERSION_FILE := $(KOBJ)/include/linux/version.h
+-UTS_REL_FILE := $(KSRC)/include/linux/utsrelease.h
+-CONFIG_FILE := $(KOBJ)/include/linux/autoconf.h
++UTS_REL_FILE := $(KSRC)/include/generated/utsrelease.h
++CONFIG_FILE := $(KOBJ)/include/generated/autoconf.h
+
+
+ # as of 2.6.16, kernel define UTS_RELEASE has been moved to utsrelease.h
+--- a/Embedded/src/CAN/Makefile
++++ b/Embedded/src/CAN/Makefile
+@@ -100,8 +100,8 @@ OUTPUT_PATH ?= /
+ EXTRA_LDFLAGS += -whole-archive
+
+ VERSION_FILE := $(KOBJ)/include/linux/version.h
+-UTS_REL_FILE := $(KSRC)/include/linux/utsrelease.h
+-CONFIG_FILE := $(KOBJ)/include/linux/autoconf.h
++UTS_REL_FILE := $(KSRC)/include/generated/utsrelease.h
++CONFIG_FILE := $(KOBJ)/include/generated/autoconf.h
+
+
+ # as of 2.6.16, kernel define UTS_RELEASE has been moved to utsrelease.h
+--- a/Embedded/src/EDMA/Makefile
++++ b/Embedded/src/EDMA/Makefile
+@@ -114,8 +114,8 @@ OUTPUT_PATH ?= /
+ EXTRA_LDFLAGS += -whole-archive
+
+ VERSION_FILE := $(KOBJ)/include/linux/version.h
+-UTS_REL_FILE := $(KSRC)/include/linux/utsrelease.h
+-CONFIG_FILE := $(KOBJ)/include/linux/autoconf.h
++UTS_REL_FILE := $(KSRC)/include/generated/utsrelease.h
++CONFIG_FILE := $(KOBJ)/include/generated/autoconf.h
+
+
+ # as of 2.6.16, kernel define UTS_RELEASE has been moved to utsrelease.h
+--- a/Embedded/src/GPIO/Makefile
++++ b/Embedded/src/GPIO/Makefile
+@@ -97,8 +97,8 @@ OUTPUT_PATH ?= /
+ EXTRA_LDFLAGS += -whole-archive
+
+ VERSION_FILE := $(KOBJ)/include/linux/version.h
+-UTS_REL_FILE := $(KSRC)/include/linux/utsrelease.h
+-CONFIG_FILE := $(KOBJ)/include/linux/autoconf.h
++UTS_REL_FILE := $(KSRC)/include/generated/utsrelease.h
++CONFIG_FILE := $(KOBJ)/include/generated/autoconf.h
+
+
+ # as of 2.6.16, kernel define UTS_RELEASE has been moved to utsrelease.h
+--- a/Embedded/src/WDT/Makefile
++++ b/Embedded/src/WDT/Makefile
+@@ -99,8 +99,8 @@ OUTPUT_PATH ?= /
+ EXTRA_LDFLAGS += -whole-archive
+
+ VERSION_FILE := $(KOBJ)/include/linux/version.h
+-UTS_REL_FILE := $(KSRC)/include/linux/utsrelease.h
+-CONFIG_FILE := $(KOBJ)/include/linux/autoconf.h
++UTS_REL_FILE := $(KSRC)/include/generated/utsrelease.h
++CONFIG_FILE := $(KOBJ)/include/generated/autoconf.h
+
+
+ # as of 2.6.16, kernel define UTS_RELEASE has been moved to utsrelease.h
diff --git a/package/system/ep80579-drivers/patches/711-3.3-gbe-fixes.patch b/package/system/ep80579-drivers/patches/711-3.3-gbe-fixes.patch
new file mode 100644
index 0000000..7b2df63
--- /dev/null
+++ b/package/system/ep80579-drivers/patches/711-3.3-gbe-fixes.patch
@@ -0,0 +1,392 @@
+--- a/Embedded/src/GbE/kcompat.h
++++ b/Embedded/src/GbE/kcompat.h
+@@ -590,6 +590,10 @@ static inline void _kc_synchronize_irq()
+ #define ETHTOOL_OPS_COMPAT
+ #endif
+
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
++#define HAVE_NETIF_MSG 1
++#endif
++
+ #ifndef HAVE_NETIF_MSG
+ #define HAVE_NETIF_MSG 1
+ enum {
+--- a/Embedded/src/GbE/iegbe_main.c
++++ b/Embedded/src/GbE/iegbe_main.c
+@@ -159,9 +159,9 @@ static void iegbe_smartspeed(struct iegb
+ static inline int iegbe_82547_fifo_workaround(struct iegbe_adapter *adapter,
+ struct sk_buff *skb);
+
+-static void iegbe_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp);
+-static void iegbe_vlan_rx_add_vid(struct net_device *netdev, uint16_t vid);
+-static void iegbe_vlan_rx_kill_vid(struct net_device *netdev, uint16_t vid);
++static bool iegbe_vlan_used(struct iegbe_adapter *adapter);
++static int iegbe_vlan_rx_add_vid(struct net_device *netdev, uint16_t vid);
++static int iegbe_vlan_rx_kill_vid(struct net_device *netdev, uint16_t vid);
+ static void iegbe_restore_vlan(struct iegbe_adapter *adapter);
+
+ static int iegbe_notify_reboot(struct notifier_block *,
+@@ -324,8 +324,8 @@ static void iegbe_update_mng_vlan(struct
+ struct net_device *netdev = adapter->netdev;
+ u16 vid = hw->mng_cookie.vlan_id;
+ u16 old_vid = adapter->mng_vlan_id;
+- if (adapter->vlgrp) {
+- if (!vlan_group_get_device(adapter->vlgrp, vid)) {
++ if (iegbe_vlan_used(adapter)) {
++ if (!test_bit(old_vid, adapter->active_vlans)) {
+ if (hw->mng_cookie.status &
+ E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) {
+ iegbe_vlan_rx_add_vid(netdev, vid);
+@@ -335,7 +335,7 @@ static void iegbe_update_mng_vlan(struct
+
+ if ((old_vid != (u16)E1000_MNG_VLAN_NONE) &&
+ (vid != old_vid) &&
+- !vlan_group_get_device(adapter->vlgrp, old_vid))
++ !test_bit(old_vid, adapter->active_vlans))
+ iegbe_vlan_rx_kill_vid(netdev, old_vid);
+ } else
+ adapter->mng_vlan_id = vid;
+@@ -736,7 +736,6 @@ static const struct net_device_ops iegbe
+ .ndo_do_ioctl = iegbe_ioctl,
+ .ndo_validate_addr = eth_validate_addr,
+
+- .ndo_vlan_rx_register = iegbe_vlan_rx_register,
+ .ndo_vlan_rx_add_vid = iegbe_vlan_rx_add_vid,
+ .ndo_vlan_rx_kill_vid = iegbe_vlan_rx_kill_vid,
+ #ifdef CONFIG_NET_POLL_CONTROLLER
+@@ -767,7 +766,6 @@ static int __devinit iegbe_probe(struct
+ u16 eeprom_data = 0;
+ u16 eeprom_apme_mask = E1000_EEPROM_APME;
+ int bars;
+- DECLARE_MAC_BUF(mac);
+
+ bars = pci_select_bars(pdev, IORESOURCE_MEM);
+ err = pci_enable_device(pdev);
+@@ -1247,8 +1245,7 @@ static int iegbe_close(struct net_device
+
+ if ((hw->mng_cookie.status &
+ E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) &&
+- !(adapter->vlgrp &&
+- vlan_group_get_device(adapter->vlgrp, adapter->mng_vlan_id))) {
++ !test_bit(adapter->mng_vlan_id, adapter->active_vlans)) {
+ iegbe_vlan_rx_kill_vid(netdev, adapter->mng_vlan_id);
+ }
+ return 0;
+@@ -2163,11 +2160,13 @@ static void iegbe_set_rx_mode(struct net
+ struct iegbe_hw *hw = &adapter->hw;
+ struct netdev_hw_addr *ha;
+ bool use_uc = false;
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
+ struct dev_addr_list *mc_ptr;
+- u32 rctl;
+ u32 hash_value;
+- int i, rar_entries = E1000_RAR_ENTRIES;
+ int mta_reg_count = E1000_NUM_MTA_REGISTERS;
++#endif
++ u32 rctl;
++ int i, rar_entries = E1000_RAR_ENTRIES;
+
+ /* reserve RAR[14] for LAA over-write work-around */
+ if (hw->mac_type == iegbe_82571)
+@@ -2220,6 +2219,7 @@ int mta_reg_count = E1000_NUM_MTA_REGIST
+
+ WARN_ON(i == rar_entries);
+
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
+ mc_ptr = netdev->mc_list;
+
+ for (; i < rar_entries; i++) {
+@@ -2247,6 +2247,7 @@ int mta_reg_count = E1000_NUM_MTA_REGIST
+ hash_value = iegbe_hash_mc_addr(hw, mc_ptr->da_addr);
+ iegbe_mta_set(hw, hash_value);
+ }
++#endif
+
+ if (hw->mac_type == iegbe_82542_rev2_0)
+ iegbe_leave_82542_rst(adapter);
+@@ -2821,14 +2822,14 @@ static int iegbe_tx_map(struct iegbe_ada
+ * Avoid terminating buffers within evenly-aligned
+ * dwords. */
+ if(unlikely(adapter->pcix_82544 &&
+- !((unsigned long)(frag->page+offset+size-1) & 4) &&
++ !((unsigned long)(frag->page.p+offset+size-1) & 4) &&
+ size > 4))
+ size -= 4;
+
+ buffer_info->length = size;
+ buffer_info->dma =
+ pci_map_page(adapter->pdev,
+- frag->page,
++ frag->page.p,
+ offset,
+ size,
+ PCI_DMA_TODEVICE);
+@@ -3131,7 +3132,7 @@ static int iegbe_xmit_frame(struct sk_bu
+ }
+ }
+
+- if (unlikely(adapter->vlgrp && vlan_tx_tag_present(skb))) {
++ if (unlikely(iegbe_vlan_used(adapter) && vlan_tx_tag_present(skb))) {
+ tx_flags |= E1000_TX_FLAGS_VLAN;
+ tx_flags |= (vlan_tx_tag_get(skb) << E1000_TX_FLAGS_VLAN_SHIFT);
+ }
+@@ -3832,10 +3833,12 @@ static bool iegbe_clean_rx_irq(struct ie
+
+ skb->protocol = eth_type_trans(skb, netdev);
+
+- if (unlikely(adapter->vlgrp &&
++ if (unlikely(iegbe_vlan_used(adapter) &&
+ (status & E1000_RXD_STAT_VP))) {
+- vlan_hwaccel_receive_skb(skb, adapter->vlgrp,
+- le16_to_cpu(rx_desc->special));
++ u16 vid;
++
++ vid = le16_to_cpu(rx_desc->special);
++ __vlan_hwaccel_put_tag(skb, vid);
+ } else {
+ netif_receive_skb(skb);
+ }
+@@ -3986,9 +3989,10 @@ copydone:
+ cpu_to_le16(E1000_RXDPS_HDRSTAT_HDRSP)))
+ adapter->rx_hdr_split++;
+
+- if(unlikely(adapter->vlgrp && (staterr & E1000_RXD_STAT_VP))) {
+- vlan_hwaccel_receive_skb(skb, adapter->vlgrp,
+- le16_to_cpu(rx_desc->wb.middle.vlan));
++ if(unlikely(iegbe_vlan_used(adapter) && (staterr & E1000_RXD_STAT_VP))) {
++ u16 vid;
++ vid = le16_to_cpu(rx_desc->wb.middle.vlan);
++ __vlan_hwaccel_put_tag(skb, vid);
+ } else {
+ netif_receive_skb(skb);
+ }
+@@ -4496,17 +4500,25 @@ iegbe_io_write(struct iegbe_hw *hw, unsi
+ outl(value, port);
+ }
+
+-static void iegbe_vlan_rx_register(struct net_device *netdev,
+- struct vlan_group *grp)
++static bool iegbe_vlan_used(struct iegbe_adapter *adapter)
++{
++ u16 vid;
++
++ for_each_set_bit(vid, adapter->active_vlans, VLAN_N_VID)
++ return true;
++
++ return false;
++}
++
++static void iegbe_vlan_mode(struct net_device *netdev, bool vlan_on)
+ {
+ struct iegbe_adapter *adapter = netdev_priv(netdev);
+ uint32_t ctrl, rctl;
+
+ if (!test_bit(__E1000_DOWN, &adapter->flags))
+ iegbe_irq_disable(adapter);
+- adapter->vlgrp = grp;
+
+- if(grp) {
++ if(vlan_on) {
+ /* enable VLAN tag insert/strip */
+ ctrl = E1000_READ_REG(&adapter->hw, CTRL);
+ ctrl |= E1000_CTRL_VME;
+@@ -4538,30 +4550,37 @@ static void iegbe_vlan_rx_register(struc
+ iegbe_irq_enable(adapter);
+ }
+
+-static void iegbe_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
++static int iegbe_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
+ {
+ struct iegbe_adapter *adapter = netdev_priv(netdev);
+ uint32_t vfta, index;
+ if((adapter->hw.mng_cookie.status &
+ E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) &&
+ (vid == adapter->mng_vlan_id)) {
+- return;
++ return 0;
+ }
++
++ if (!iegbe_vlan_used(adapter))
++ iegbe_vlan_mode(netdev, true);
++
+ /* add VID to filter table */
+ index = (vid >> 0x5) & 0x7F;
+ vfta = E1000_READ_REG_ARRAY(&adapter->hw, VFTA, index);
+ vfta |= (0x1 << (vid & 0x1F));
+ iegbe_write_vfta(&adapter->hw, index, vfta);
++
++ set_bit(vid, adapter->active_vlans);
++
++ return 0;
+ }
+
+-static void iegbe_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
++static int iegbe_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
+ {
+ struct iegbe_adapter *adapter = netdev_priv(netdev);
+ u32 vfta, index;
+
+ if (!test_bit(__E1000_DOWN, &adapter->flags))
+ iegbe_irq_disable(adapter);
+- vlan_group_set_device(adapter->vlgrp, vid, NULL);
+ if (!test_bit(__E1000_DOWN, &adapter->flags))
+ iegbe_irq_enable(adapter);
+
+@@ -4570,21 +4589,26 @@ static void iegbe_vlan_rx_kill_vid(struc
+ vfta = E1000_READ_REG_ARRAY(&adapter->hw, VFTA, index);
+ vfta &= ~(0x1 << (vid & 0x1F));
+ iegbe_write_vfta(&adapter->hw, index, vfta);
++
++ clear_bit(vid, adapter->active_vlans);
++
++ if (!iegbe_vlan_used(adapter))
++ iegbe_vlan_mode(netdev, false);
++
++ return 0;
+ }
+
+ static void iegbe_restore_vlan(struct iegbe_adapter *adapter)
+ {
+- iegbe_vlan_rx_register(adapter->netdev, adapter->vlgrp);
+-
+- if (adapter->vlgrp) {
+ u16 vid;
+- for (vid = 0x0; vid < VLAN_GROUP_ARRAY_LEN; vid++) {
+- if (!vlan_group_get_device(adapter->vlgrp, vid))
+- continue;
++
++ if (!iegbe_vlan_used(adapter))
++ return;
++
++ iegbe_vlan_mode(adapter->netdev, true);
++ for_each_set_bit(vid, adapter->active_vlans, VLAN_N_VID)
+ iegbe_vlan_rx_add_vid(adapter->netdev, vid);
+ }
+- }
+-}
+
+
+ int iegbe_set_spd_dplx(struct iegbe_adapter *adapter, u16 spddplx)
+@@ -4864,10 +4888,11 @@ iegbe_resume(struct pci_dev *pdev)
+ default:
+ break;
+ }
+-#endif
+
+ return 0x0;
+ }
++#endif
++
+
+ #ifdef CONFIG_NET_POLL_CONTROLLER
+ /*
+--- a/Embedded/src/GbE/iegbe_ethtool.c
++++ b/Embedded/src/GbE/iegbe_ethtool.c
+@@ -327,6 +327,7 @@ iegbe_set_pauseparam(struct net_device *
+ return 0;
+ }
+
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
+ static uint32_t
+ iegbe_get_rx_csum(struct net_device *netdev)
+ {
+@@ -392,6 +393,7 @@ iegbe_set_tso(struct net_device *netdev,
+ return 0;
+ }
+ #endif /* NETIF_F_TSO */
++#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0)) */
+
+ static uint32_t
+ iegbe_get_msglevel(struct net_device *netdev)
+@@ -807,6 +809,7 @@ err_setup_rx:
+ E1000_82542_##R : E1000_##R; \
+ return 1; } }
+
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
+ static int
+ iegbe_reg_test(struct iegbe_adapter *adapter, uint64_t *data)
+ {
+@@ -1710,6 +1713,7 @@ iegbe_diag_test(struct net_device *netde
+ }
+ msleep_interruptible(0xfa0);
+ }
++#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0)) */
+
+ static void
+ iegbe_get_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
+@@ -1812,6 +1816,7 @@ iegbe_set_wol(struct net_device *netdev,
+ /* bit defines for adapter->led_status */
+ #define E1000_LED_ON 0
+
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
+ static void
+ iegbe_led_blink_callback(unsigned long data)
+ {
+@@ -1864,6 +1869,7 @@ iegbe_phys_id(struct net_device *netdev,
+
+ return 0;
+ }
++#endif
+
+ static int
+ iegbe_nway_reset(struct net_device *netdev)
+@@ -1876,11 +1882,13 @@ iegbe_nway_reset(struct net_device *netd
+ return 0;
+ }
+
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
+ static int
+ iegbe_get_stats_count(struct net_device *netdev)
+ {
+ return E1000_STATS_LEN;
+ }
++#endif
+
+ static void
+ iegbe_get_ethtool_stats(struct net_device *netdev,
+@@ -1936,6 +1944,8 @@ struct ethtool_ops iegbe_ethtool_ops = {
+ .set_ringparam = iegbe_set_ringparam,
+ .get_pauseparam = iegbe_get_pauseparam,
+ .set_pauseparam = iegbe_set_pauseparam,
++
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
+ .get_rx_csum = iegbe_get_rx_csum,
+ .set_rx_csum = iegbe_set_rx_csum,
+ .get_tx_csum = iegbe_get_tx_csum,
+@@ -1946,11 +1956,13 @@ struct ethtool_ops iegbe_ethtool_ops = {
+ .get_tso = ethtool_op_get_tso,
+ .set_tso = iegbe_set_tso,
+ #endif
++
+ .self_test_count = iegbe_diag_test_count,
+ .self_test = iegbe_diag_test,
+- .get_strings = iegbe_get_strings,
+ .phys_id = iegbe_phys_id,
+ .get_stats_count = iegbe_get_stats_count,
++#endif
++ .get_strings = iegbe_get_strings,
+ .get_ethtool_stats = iegbe_get_ethtool_stats,
+ };
+
+--- a/Embedded/src/GbE/gcu_main.c
++++ b/Embedded/src/GbE/gcu_main.c
+@@ -93,7 +93,7 @@ static struct pci_driver gcu_driver = {
+ };
+
+ static struct gcu_adapter *global_adapter = 0;
+-static spinlock_t global_adapter_spinlock = SPIN_LOCK_UNLOCKED;
++static DEFINE_SPINLOCK(global_adapter_spinlock);
+ static unsigned long g_intflags = 0;
+
+ MODULE_AUTHOR("Intel(R) Corporation");
+--- a/Embedded/src/GbE/iegbe.h
++++ b/Embedded/src/GbE/iegbe.h
+@@ -257,7 +257,7 @@ struct iegbe_adapter {
+ struct timer_list tx_fifo_stall_timer;
+ struct timer_list watchdog_timer;
+ struct timer_list phy_info_timer;
+- struct vlan_group *vlgrp;
++ unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
+ uint16_t mng_vlan_id;
+ uint32_t bd_number;
+ uint32_t rx_buffer_len;
diff --git a/package/system/ep80579-drivers/patches/712-3.3-can-fixes.patch b/package/system/ep80579-drivers/patches/712-3.3-can-fixes.patch
new file mode 100644
index 0000000..f46f900
--- /dev/null
+++ b/package/system/ep80579-drivers/patches/712-3.3-can-fixes.patch
@@ -0,0 +1,41 @@
+--- a/Embedded/src/CAN/can_main.c
++++ b/Embedded/src/CAN/can_main.c
+@@ -72,6 +72,7 @@
+ #include "can_main.h"
+ #include "can_ioctl.h"
+ #include <linux/fs.h>
++#include <linux/module.h>
+
+
+ MODULE_AUTHOR("Intel(R) Corporation");
+@@ -110,7 +111,7 @@ struct file_operations file_ops = {
+ .owner = THIS_MODULE,
+ .read = can_read,
+ .write = can_write,
+- .ioctl = can_dev_io,
++ .unlocked_ioctl = can_dev_io,
+ .open = can_open,
+ .release = can_release
+ };
+@@ -594,8 +595,7 @@ int icp_can_reset(can_os_t *can_os)
+ /*****************************************************************************
+ * Device IO control function. Used by user apps to configure CAN device.
+ *****************************************************************************/
+-int can_dev_io(struct inode *inode, struct file *filp, unsigned int cmd,
+- unsigned long arg)
++long can_dev_io(struct file *filp, unsigned int cmd, unsigned long arg)
+ {
+ can_os_t *can_os;
+ unsigned int err=0;
+--- a/Embedded/src/CAN/can_main.h
++++ b/Embedded/src/CAN/can_main.h
+@@ -157,8 +157,7 @@ ssize_t can_write(
+ int icp_can_reset(
+ can_os_t *can_os);
+
+-int can_dev_io(
+- struct inode *inode,
++long can_dev_io(
+ struct file *filp,
+ unsigned int cmd,
+ unsigned long arg);
diff --git a/package/system/ep80579-drivers/patches/713-3.3-gpio-fixes.patch b/package/system/ep80579-drivers/patches/713-3.3-gpio-fixes.patch
new file mode 100644
index 0000000..47fb920
--- /dev/null
+++ b/package/system/ep80579-drivers/patches/713-3.3-gpio-fixes.patch
@@ -0,0 +1,33 @@
+--- a/Embedded/src/GPIO/gpio.h
++++ b/Embedded/src/GPIO/gpio.h
+@@ -121,8 +121,7 @@ int gpio_init(void);
+ void gpio_close(void);
+ int gpio_open(struct inode *inode, struct file *filp);
+ int gpio_release(struct inode *inode, struct file *filp);
+-int gpio_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
+- unsigned long arg);
++long gpio_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
+
+ // private driver functions
+ int gpio_getpininfo(int Signal, char *pBuff);
+@@ -134,7 +133,7 @@ struct file_operations file_ops =
+ .owner = THIS_MODULE,
+ .open = gpio_open,
+ .release = gpio_release,
+- .ioctl = gpio_ioctl,
++ .unlocked_ioctl = gpio_ioctl,
+ };
+
+ #endif
+--- a/Embedded/src/GPIO/gpio_ref.c
++++ b/Embedded/src/GPIO/gpio_ref.c
+@@ -251,8 +251,7 @@ int gpio_release(struct inode *inode, st
+ 0 => success
+ < 0 => error
+ ******************************************************************************/
+-int gpio_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
+- unsigned long arg)
++long gpio_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
+ {
+ gpio_ioctl_t Info;
+ u_int bitstr = 0;
diff --git a/package/system/ep80579-drivers/patches/714-3.3-wdt-fixes.patch b/package/system/ep80579-drivers/patches/714-3.3-wdt-fixes.patch
new file mode 100644
index 0000000..60cc4ae
--- /dev/null
+++ b/package/system/ep80579-drivers/patches/714-3.3-wdt-fixes.patch
@@ -0,0 +1,31 @@
+--- a/Embedded/src/WDT/iwdt.c
++++ b/Embedded/src/WDT/iwdt.c
+@@ -217,8 +217,7 @@ static int wdt_open(struct inode *inode,
+ static int wdt_release(struct inode *inode, struct file *file);
+ static ssize_t wdt_write(struct file *file, const char *data,
+ size_t count, loff_t * pos);
+-static int wdt_ioctl(struct inode *inode, struct file *file,
+- unsigned int cmd, unsigned long arg);
++static long wdt_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
+ static irqreturn_t wdt_isr(int irq, void *dev_id);
+ static void __exit wdt_cleanup(void);
+ static int __init wdt_init(void);
+@@ -243,7 +242,7 @@ static struct pci_device_id lpc_pci_tbl[
+ static struct file_operations wdt_fops = {
+ owner: THIS_MODULE,
+ write: wdt_write,
+- ioctl: wdt_ioctl,
++ unlocked_ioctl: wdt_ioctl,
+ open: wdt_open,
+ release: wdt_release,
+ };
+@@ -1201,8 +1200,7 @@ char *wdt_get_ioctl_string(unsigned int
+ * Return Value: 0 - successful, negative value - failed.
+ * Description: This function is used to provide IO interface.
+ */
+-static int wdt_ioctl(struct inode *inode, struct file *file,
+- unsigned int cmd, unsigned long arg)
++static long wdt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+ {
+ u8 mode=0, scale=0, int_type=0;
+ u32 u_margin=0, dcount=0;
diff --git a/package/system/ep80579-drivers/patches/715-3.3-1588-fixes.patch b/package/system/ep80579-drivers/patches/715-3.3-1588-fixes.patch
new file mode 100644
index 0000000..ac5dd1f
--- /dev/null
+++ b/package/system/ep80579-drivers/patches/715-3.3-1588-fixes.patch
@@ -0,0 +1,33 @@
+--- a/Embedded/src/1588/1588.c
++++ b/Embedded/src/1588/1588.c
+@@ -664,8 +664,7 @@ irqreturn_t timesync_isr(int irq, void *
+ 0 => success
+ < 0 => error
+ ******************************************************************************/
+-int timesync_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
+- unsigned long arg)
++long timesync_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
+ {
+ wait_queue_head_t *event = NULL;
+ unsigned int bytes_ret = 0;
+--- a/Embedded/src/1588/1588.h
++++ b/Embedded/src/1588/1588.h
+@@ -121,8 +121,7 @@ MODULE_DEVICE_TABLE(pci, pci_ids);
+ // Linux functions
+ int timesync_open(struct inode *inode, struct file *filp);
+ int timesync_release(struct inode *inode, struct file *filp);
+-int timesync_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
+- unsigned long arg);
++long timesync_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
+ void timesync_close(void);
+ int pci_suspend(struct pci_dev *dev, pm_message_t state);
+ int pci_resume(struct pci_dev *dev);
+@@ -142,7 +141,7 @@ struct file_operations file_ops =
+ .owner = THIS_MODULE,
+ .open = timesync_open,
+ .release = timesync_release,
+- .ioctl = timesync_ioctl,
++ .unlocked_ioctl = timesync_ioctl,
+ };
+
+ // Linux pci operations
diff --git a/package/system/gpio-button-hotplug/.svn/entries b/package/system/gpio-button-hotplug/.svn/entries
new file mode 100644
index 0000000..a9df471
--- /dev/null
+++ b/package/system/gpio-button-hotplug/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/system/gpio-button-hotplug
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-27T21:17:38.011676Z
+35335
+hauke
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+src
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+6b77e1a5554ca86e2c5c945032c59e54
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+963
+
diff --git a/package/system/gpio-button-hotplug/.svn/text-base/Makefile.svn-base b/package/system/gpio-button-hotplug/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..adb9a45
--- /dev/null
+++ b/package/system/gpio-button-hotplug/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,44 @@
+#
+# Copyright (C) 2008-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=gpio-button-hotplug
+PKG_RELEASE:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/gpio-button-hotplug
+ SUBMENU:=Other modules
+ TITLE:=Simple GPIO Button Hotplug driver
+ FILES:=$(PKG_BUILD_DIR)/gpio-button-hotplug.ko
+ AUTOLOAD:=$(call AutoLoad,30,gpio-button-hotplug)
+ KCONFIG:=
+endef
+
+define KernelPackage/button-hotplug/description
+ Kernel module to generate GPIO button hotplug events
+endef
+
+MAKE_OPTS:= \
+ ARCH="$(LINUX_KARCH)" \
+ CROSS_COMPILE="$(TARGET_CROSS)" \
+ SUBDIRS="$(PKG_BUILD_DIR)"
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+define Build/Compile
+ $(MAKE) -C "$(LINUX_DIR)" \
+ $(MAKE_OPTS) \
+ modules
+endef
+
+$(eval $(call KernelPackage,gpio-button-hotplug))
diff --git a/package/system/gpio-button-hotplug/Makefile b/package/system/gpio-button-hotplug/Makefile
new file mode 100644
index 0000000..adb9a45
--- /dev/null
+++ b/package/system/gpio-button-hotplug/Makefile
@@ -0,0 +1,44 @@
+#
+# Copyright (C) 2008-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=gpio-button-hotplug
+PKG_RELEASE:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/gpio-button-hotplug
+ SUBMENU:=Other modules
+ TITLE:=Simple GPIO Button Hotplug driver
+ FILES:=$(PKG_BUILD_DIR)/gpio-button-hotplug.ko
+ AUTOLOAD:=$(call AutoLoad,30,gpio-button-hotplug)
+ KCONFIG:=
+endef
+
+define KernelPackage/button-hotplug/description
+ Kernel module to generate GPIO button hotplug events
+endef
+
+MAKE_OPTS:= \
+ ARCH="$(LINUX_KARCH)" \
+ CROSS_COMPILE="$(TARGET_CROSS)" \
+ SUBDIRS="$(PKG_BUILD_DIR)"
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+define Build/Compile
+ $(MAKE) -C "$(LINUX_DIR)" \
+ $(MAKE_OPTS) \
+ modules
+endef
+
+$(eval $(call KernelPackage,gpio-button-hotplug))
diff --git a/package/system/gpio-button-hotplug/src/.svn/entries b/package/system/gpio-button-hotplug/src/.svn/entries
new file mode 100644
index 0000000..e008e98
--- /dev/null
+++ b/package/system/gpio-button-hotplug/src/.svn/entries
@@ -0,0 +1,96 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/system/gpio-button-hotplug/src
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-27T21:17:38.011676Z
+35335
+hauke
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+gpio-button-hotplug.c
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+d5cdf11525e0012db14cdf53b8b9b4ed
+2013-01-27T21:17:38.011676Z
+35335
+hauke
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+12715
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+a0992feed36dccf24419e6fcd49cc648
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+31
+
diff --git a/package/system/gpio-button-hotplug/src/.svn/text-base/Makefile.svn-base b/package/system/gpio-button-hotplug/src/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..e968865
--- /dev/null
+++ b/package/system/gpio-button-hotplug/src/.svn/text-base/Makefile.svn-base
@@ -0,0 +1 @@
+obj-m += gpio-button-hotplug.o
diff --git a/package/system/gpio-button-hotplug/src/.svn/text-base/gpio-button-hotplug.c.svn-base b/package/system/gpio-button-hotplug/src/.svn/text-base/gpio-button-hotplug.c.svn-base
new file mode 100644
index 0000000..9d91b57
--- /dev/null
+++ b/package/system/gpio-button-hotplug/src/.svn/text-base/gpio-button-hotplug.c.svn-base
@@ -0,0 +1,564 @@
+/*
+ * GPIO Button Hotplug driver
+ *
+ * Copyright (C) 2012 Felix Fietkau <nbd@openwrt.org>
+ * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
+ *
+ * Based on the diag.c - GPIO interface driver for Broadcom boards
+ * Copyright (C) 2006 Mike Baker <mbm@openwrt.org>,
+ * Copyright (C) 2006-2007 Felix Fietkau <nbd@openwrt.org>
+ * Copyright (C) 2008 Andy Boyett <agb@openwrt.org>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ */
+
+#include <linux/module.h>
+#include <linux/version.h>
+#include <linux/kmod.h>
+
+#include <linux/workqueue.h>
+#include <linux/skbuff.h>
+#include <linux/netlink.h>
+#include <linux/kobject.h>
+#include <linux/input.h>
+#include <linux/platform_device.h>
+#include <linux/of_gpio.h>
+#include <linux/gpio_keys.h>
+
+#define DRV_NAME "gpio-keys-polled"
+
+#define BH_SKB_SIZE 2048
+
+#define PFX DRV_NAME ": "
+
+#undef BH_DEBUG
+
+#ifdef BH_DEBUG
+#define BH_DBG(fmt, args...) printk(KERN_DEBUG "%s: " fmt, DRV_NAME, ##args )
+#else
+#define BH_DBG(fmt, args...) do {} while (0)
+#endif
+
+#define BH_ERR(fmt, args...) printk(KERN_ERR "%s: " fmt, DRV_NAME, ##args )
+
+struct bh_priv {
+ unsigned long seen;
+};
+
+struct bh_event {
+ const char *name;
+ char *action;
+ unsigned long seen;
+
+ struct sk_buff *skb;
+ struct work_struct work;
+};
+
+struct bh_map {
+ unsigned int code;
+ const char *name;
+};
+
+struct gpio_keys_button_data {
+ struct delayed_work work;
+ struct bh_priv bh;
+ int last_state;
+ int count;
+ int threshold;
+ int can_sleep;
+};
+
+extern u64 uevent_next_seqnum(void);
+
+#define BH_MAP(_code, _name) \
+ { \
+ .code = (_code), \
+ .name = (_name), \
+ }
+
+static struct bh_map button_map[] = {
+ BH_MAP(BTN_0, "BTN_0"),
+ BH_MAP(BTN_1, "BTN_1"),
+ BH_MAP(BTN_2, "BTN_2"),
+ BH_MAP(BTN_3, "BTN_3"),
+ BH_MAP(BTN_4, "BTN_4"),
+ BH_MAP(BTN_5, "BTN_5"),
+ BH_MAP(BTN_6, "BTN_6"),
+ BH_MAP(BTN_7, "BTN_7"),
+ BH_MAP(BTN_8, "BTN_8"),
+ BH_MAP(BTN_9, "BTN_9"),
+ BH_MAP(KEY_RESTART, "reset"),
+ BH_MAP(KEY_RFKILL, "rfkill"),
+#ifdef KEY_WPS_BUTTON
+ BH_MAP(KEY_WPS_BUTTON, "wps"),
+#endif /* KEY_WPS_BUTTON */
+};
+
+/* -------------------------------------------------------------------------*/
+
+static int bh_event_add_var(struct bh_event *event, int argv,
+ const char *format, ...)
+{
+ static char buf[128];
+ char *s;
+ va_list args;
+ int len;
+
+ if (argv)
+ return 0;
+
+ va_start(args, format);
+ len = vsnprintf(buf, sizeof(buf), format, args);
+ va_end(args);
+
+ if (len >= sizeof(buf)) {
+ BH_ERR("buffer size too small\n");
+ WARN_ON(1);
+ return -ENOMEM;
+ }
+
+ s = skb_put(event->skb, len + 1);
+ strcpy(s, buf);
+
+ BH_DBG("added variable '%s'\n", s);
+
+ return 0;
+}
+
+static int button_hotplug_fill_event(struct bh_event *event)
+{
+ int ret;
+
+ ret = bh_event_add_var(event, 0, "HOME=%s", "/");
+ if (ret)
+ return ret;
+
+ ret = bh_event_add_var(event, 0, "PATH=%s",
+ "/sbin:/bin:/usr/sbin:/usr/bin");
+ if (ret)
+ return ret;
+
+ ret = bh_event_add_var(event, 0, "SUBSYSTEM=%s", "button");
+ if (ret)
+ return ret;
+
+ ret = bh_event_add_var(event, 0, "ACTION=%s", event->action);
+ if (ret)
+ return ret;
+
+ ret = bh_event_add_var(event, 0, "BUTTON=%s", event->name);
+ if (ret)
+ return ret;
+
+ ret = bh_event_add_var(event, 0, "SEEN=%ld", event->seen);
+ if (ret)
+ return ret;
+
+ ret = bh_event_add_var(event, 0, "SEQNUM=%llu", uevent_next_seqnum());
+
+ return ret;
+}
+
+static void button_hotplug_work(struct work_struct *work)
+{
+ struct bh_event *event = container_of(work, struct bh_event, work);
+ int ret = 0;
+
+ event->skb = alloc_skb(BH_SKB_SIZE, GFP_KERNEL);
+ if (!event->skb)
+ goto out_free_event;
+
+ ret = bh_event_add_var(event, 0, "%s@", event->action);
+ if (ret)
+ goto out_free_skb;
+
+ ret = button_hotplug_fill_event(event);
+ if (ret)
+ goto out_free_skb;
+
+ NETLINK_CB(event->skb).dst_group = 1;
+ broadcast_uevent(event->skb, 0, 1, GFP_KERNEL);
+
+ out_free_skb:
+ if (ret) {
+ BH_ERR("work error %d\n", ret);
+ kfree_skb(event->skb);
+ }
+ out_free_event:
+ kfree(event);
+}
+
+static int button_hotplug_create_event(const char *name, unsigned long seen,
+ int pressed)
+{
+ struct bh_event *event;
+
+ BH_DBG("create event, name=%s, seen=%lu, pressed=%d\n",
+ name, seen, pressed);
+
+ event = kzalloc(sizeof(*event), GFP_KERNEL);
+ if (!event)
+ return -ENOMEM;
+
+ event->name = name;
+ event->seen = seen;
+ event->action = pressed ? "pressed" : "released";
+
+ INIT_WORK(&event->work, (void *)(void *)button_hotplug_work);
+ schedule_work(&event->work);
+
+ return 0;
+}
+
+/* -------------------------------------------------------------------------*/
+
+#ifdef CONFIG_HOTPLUG
+static int button_get_index(unsigned int code)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(button_map); i++)
+ if (button_map[i].code == code)
+ return i;
+
+ return -1;
+}
+static void button_hotplug_event(struct gpio_keys_button_data *data,
+ unsigned int type, unsigned int code, int value)
+{
+ struct bh_priv *priv = &data->bh;
+ unsigned long seen = jiffies;
+ int btn;
+
+ BH_DBG("event type=%u, code=%u, value=%d\n", type, code, value);
+
+ if (type != EV_KEY)
+ return;
+
+ btn = button_get_index(code);
+ if (btn < 0)
+ return;
+
+ button_hotplug_create_event(button_map[btn].name,
+ (seen - priv->seen) / HZ, value);
+ priv->seen = seen;
+}
+#else
+static void button_hotplug_event(struct gpio_keys_button_data *data,
+ unsigned int type, unsigned int code, int value)
+{
+}
+#endif /* CONFIG_HOTPLUG */
+
+struct gpio_keys_polled_dev {
+ struct delayed_work work;
+
+ struct device *dev;
+ struct gpio_keys_platform_data *pdata;
+ struct gpio_keys_button_data data[0];
+};
+
+static void gpio_keys_polled_check_state(struct gpio_keys_button *button,
+ struct gpio_keys_button_data *bdata)
+{
+ int state;
+
+ if (bdata->can_sleep)
+ state = !!gpio_get_value_cansleep(button->gpio);
+ else
+ state = !!gpio_get_value(button->gpio);
+
+ state = !!(state ^ button->active_low);
+ if (state != bdata->last_state) {
+ unsigned int type = button->type ?: EV_KEY;
+
+ button_hotplug_event(bdata, type, button->code, state);
+ bdata->count = 0;
+ bdata->last_state = state;
+ }
+}
+
+static void gpio_keys_polled_queue_work(struct gpio_keys_polled_dev *bdev)
+{
+ struct gpio_keys_platform_data *pdata = bdev->pdata;
+ unsigned long delay = msecs_to_jiffies(pdata->poll_interval);
+
+ if (delay >= HZ)
+ delay = round_jiffies_relative(delay);
+ schedule_delayed_work(&bdev->work, delay);
+}
+
+static void gpio_keys_polled_poll(struct work_struct *work)
+{
+ struct gpio_keys_polled_dev *bdev =
+ container_of(work, struct gpio_keys_polled_dev, work.work);
+ struct gpio_keys_platform_data *pdata = bdev->pdata;
+ int i;
+
+ for (i = 0; i < bdev->pdata->nbuttons; i++) {
+ struct gpio_keys_button_data *bdata = &bdev->data[i];
+
+ if (bdata->count < bdata->threshold)
+ bdata->count++;
+ else
+ gpio_keys_polled_check_state(&pdata->buttons[i], bdata);
+ }
+ gpio_keys_polled_queue_work(bdev);
+}
+
+static void gpio_keys_polled_open(struct gpio_keys_polled_dev *bdev)
+{
+ struct gpio_keys_platform_data *pdata = bdev->pdata;
+ int i;
+
+ if (pdata->enable)
+ pdata->enable(bdev->dev);
+
+ /* report initial state of the buttons */
+ for (i = 0; i < pdata->nbuttons; i++)
+ gpio_keys_polled_check_state(&pdata->buttons[i], &bdev->data[i]);
+
+ gpio_keys_polled_queue_work(bdev);
+}
+
+#ifdef CONFIG_OF
+static struct gpio_keys_platform_data *
+gpio_keys_polled_get_devtree_pdata(struct device *dev)
+{
+ struct device_node *node, *pp;
+ struct gpio_keys_platform_data *pdata;
+ struct gpio_keys_button *button;
+ int error;
+ int nbuttons;
+ int i;
+
+ node = dev->of_node;
+ if (!node)
+ return NULL;
+
+ nbuttons = of_get_child_count(node);
+ if (nbuttons == 0)
+ return NULL;
+
+ pdata = kzalloc(sizeof(*pdata) + nbuttons * (sizeof *button),
+ GFP_KERNEL);
+ if (!pdata) {
+ error = -ENOMEM;
+ goto err_out;
+ }
+
+ pdata->buttons = (struct gpio_keys_button *)(pdata + 1);
+ pdata->nbuttons = nbuttons;
+
+ pdata->rep = !!of_get_property(node, "autorepeat", NULL);
+ of_property_read_u32(node, "poll-interval", &pdata->poll_interval);
+
+ i = 0;
+ for_each_child_of_node(node, pp) {
+ enum of_gpio_flags flags;
+
+ if (!of_find_property(pp, "gpios", NULL)) {
+ pdata->nbuttons--;
+ dev_warn(dev, "Found button without gpios\n");
+ continue;
+ }
+
+ button = &pdata->buttons[i++];
+
+ button->gpio = of_get_gpio_flags(pp, 0, &flags);
+ button->active_low = flags & OF_GPIO_ACTIVE_LOW;
+
+ if (of_property_read_u32(pp, "linux,code", &button->code)) {
+ dev_err(dev, "Button without keycode: 0x%x\n",
+ button->gpio);
+ error = -EINVAL;
+ goto err_free_pdata;
+ }
+
+ button->desc = of_get_property(pp, "label", NULL);
+
+ if (of_property_read_u32(pp, "linux,input-type", &button->type))
+ button->type = EV_KEY;
+
+ button->wakeup = !!of_get_property(pp, "gpio-key,wakeup", NULL);
+
+ if (of_property_read_u32(pp, "debounce-interval",
+ &button->debounce_interval))
+ button->debounce_interval = 5;
+ }
+
+ if (pdata->nbuttons == 0) {
+ error = -EINVAL;
+ goto err_free_pdata;
+ }
+
+ return pdata;
+
+err_free_pdata:
+ kfree(pdata);
+err_out:
+ return ERR_PTR(error);
+}
+
+static struct of_device_id gpio_keys_polled_of_match[] = {
+ { .compatible = "gpio-keys-polled", },
+ { },
+};
+MODULE_DEVICE_TABLE(of, gpio_keys_polled_of_match);
+
+#else
+
+static inline struct gpio_keys_platform_data *
+gpio_keys_polled_get_devtree_pdata(struct device *dev)
+{
+ return NULL;
+}
+#endif
+
+static void gpio_keys_polled_close(struct gpio_keys_polled_dev *bdev)
+{
+ struct gpio_keys_platform_data *pdata = bdev->pdata;
+
+ cancel_delayed_work_sync(&bdev->work);
+
+ if (pdata->disable)
+ pdata->disable(bdev->dev);
+}
+
+static int gpio_keys_polled_probe(struct platform_device *pdev)
+{
+ struct gpio_keys_platform_data *pdata = pdev->dev.platform_data;
+ struct device *dev = &pdev->dev;
+ struct gpio_keys_polled_dev *bdev;
+ int error;
+ int i;
+
+ if (!pdata) {
+ pdata = gpio_keys_polled_get_devtree_pdata(dev);
+ if (IS_ERR(pdata))
+ return PTR_ERR(pdata);
+ if (!pdata) {
+ dev_err(dev, "missing platform data\n");
+ return -EINVAL;
+ }
+ }
+
+ if (!pdata->poll_interval) {
+ dev_err(dev, "missing poll_interval value\n");
+ error = -EINVAL;
+ goto err_free_pdata;
+ }
+
+ bdev = kzalloc(sizeof(struct gpio_keys_polled_dev) +
+ pdata->nbuttons * sizeof(struct gpio_keys_button_data),
+ GFP_KERNEL);
+ if (!bdev) {
+ dev_err(dev, "no memory for private data\n");
+ return -ENOMEM;
+ }
+
+ for (i = 0; i < pdata->nbuttons; i++) {
+ struct gpio_keys_button *button = &pdata->buttons[i];
+ struct gpio_keys_button_data *bdata = &bdev->data[i];
+ unsigned int gpio = button->gpio;
+
+ if (button->wakeup) {
+ dev_err(dev, DRV_NAME " does not support wakeup\n");
+ error = -EINVAL;
+ goto err_free_gpio;
+ }
+
+ error = gpio_request(gpio,
+ button->desc ? button->desc : DRV_NAME);
+ if (error) {
+ dev_err(dev, "unable to claim gpio %u, err=%d\n",
+ gpio, error);
+ goto err_free_gpio;
+ }
+
+ error = gpio_direction_input(gpio);
+ if (error) {
+ dev_err(dev,
+ "unable to set direction on gpio %u, err=%d\n",
+ gpio, error);
+ goto err_free_gpio;
+ }
+
+ bdata->can_sleep = gpio_cansleep(gpio);
+ bdata->last_state = 0;
+ bdata->threshold = DIV_ROUND_UP(button->debounce_interval,
+ pdata->poll_interval);
+ }
+
+ bdev->dev = &pdev->dev;
+ bdev->pdata = pdata;
+ platform_set_drvdata(pdev, bdev);
+
+ INIT_DELAYED_WORK(&bdev->work, gpio_keys_polled_poll);
+
+ gpio_keys_polled_open(bdev);
+
+ return 0;
+
+err_free_gpio:
+ while (--i >= 0)
+ gpio_free(pdata->buttons[i].gpio);
+
+ kfree(bdev);
+ platform_set_drvdata(pdev, NULL);
+
+err_free_pdata:
+ /* If we have no platform_data, we allocated pdata dynamically. */
+ if (!dev_get_platdata(&pdev->dev))
+ kfree(pdata);
+
+ return error;
+}
+
+static int gpio_keys_polled_remove(struct platform_device *pdev)
+{
+ struct gpio_keys_polled_dev *bdev = platform_get_drvdata(pdev);
+ struct gpio_keys_platform_data *pdata = bdev->pdata;
+ int i = pdata->nbuttons;
+
+ gpio_keys_polled_close(bdev);
+
+ while (--i >= 0)
+ gpio_free(pdata->buttons[i].gpio);
+
+ kfree(bdev);
+ platform_set_drvdata(pdev, NULL);
+
+ return 0;
+}
+
+static struct platform_driver gpio_keys_polled_driver = {
+ .probe = gpio_keys_polled_probe,
+ .remove = gpio_keys_polled_remove,
+ .driver = {
+ .name = DRV_NAME,
+ .owner = THIS_MODULE,
+ .of_match_table = of_match_ptr(gpio_keys_polled_of_match),
+ },
+};
+
+static int __init gpio_keys_polled_init(void)
+{
+ return platform_driver_register(&gpio_keys_polled_driver);
+}
+
+static void __exit gpio_keys_polled_exit(void)
+{
+ platform_driver_unregister(&gpio_keys_polled_driver);
+}
+
+module_init(gpio_keys_polled_init);
+module_exit(gpio_keys_polled_exit);
+
+MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
+MODULE_AUTHOR("Felix Fietkau <nbd@openwrt.org>");
+MODULE_DESCRIPTION("Polled GPIO Buttons hotplug driver");
+MODULE_LICENSE("GPL v2");
+MODULE_ALIAS("platform:" DRV_NAME);
diff --git a/package/system/gpio-button-hotplug/src/Makefile b/package/system/gpio-button-hotplug/src/Makefile
new file mode 100644
index 0000000..e968865
--- /dev/null
+++ b/package/system/gpio-button-hotplug/src/Makefile
@@ -0,0 +1 @@
+obj-m += gpio-button-hotplug.o
diff --git a/package/system/gpio-button-hotplug/src/gpio-button-hotplug.c b/package/system/gpio-button-hotplug/src/gpio-button-hotplug.c
new file mode 100644
index 0000000..9d91b57
--- /dev/null
+++ b/package/system/gpio-button-hotplug/src/gpio-button-hotplug.c
@@ -0,0 +1,564 @@
+/*
+ * GPIO Button Hotplug driver
+ *
+ * Copyright (C) 2012 Felix Fietkau <nbd@openwrt.org>
+ * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
+ *
+ * Based on the diag.c - GPIO interface driver for Broadcom boards
+ * Copyright (C) 2006 Mike Baker <mbm@openwrt.org>,
+ * Copyright (C) 2006-2007 Felix Fietkau <nbd@openwrt.org>
+ * Copyright (C) 2008 Andy Boyett <agb@openwrt.org>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ */
+
+#include <linux/module.h>
+#include <linux/version.h>
+#include <linux/kmod.h>
+
+#include <linux/workqueue.h>
+#include <linux/skbuff.h>
+#include <linux/netlink.h>
+#include <linux/kobject.h>
+#include <linux/input.h>
+#include <linux/platform_device.h>
+#include <linux/of_gpio.h>
+#include <linux/gpio_keys.h>
+
+#define DRV_NAME "gpio-keys-polled"
+
+#define BH_SKB_SIZE 2048
+
+#define PFX DRV_NAME ": "
+
+#undef BH_DEBUG
+
+#ifdef BH_DEBUG
+#define BH_DBG(fmt, args...) printk(KERN_DEBUG "%s: " fmt, DRV_NAME, ##args )
+#else
+#define BH_DBG(fmt, args...) do {} while (0)
+#endif
+
+#define BH_ERR(fmt, args...) printk(KERN_ERR "%s: " fmt, DRV_NAME, ##args )
+
+struct bh_priv {
+ unsigned long seen;
+};
+
+struct bh_event {
+ const char *name;
+ char *action;
+ unsigned long seen;
+
+ struct sk_buff *skb;
+ struct work_struct work;
+};
+
+struct bh_map {
+ unsigned int code;
+ const char *name;
+};
+
+struct gpio_keys_button_data {
+ struct delayed_work work;
+ struct bh_priv bh;
+ int last_state;
+ int count;
+ int threshold;
+ int can_sleep;
+};
+
+extern u64 uevent_next_seqnum(void);
+
+#define BH_MAP(_code, _name) \
+ { \
+ .code = (_code), \
+ .name = (_name), \
+ }
+
+static struct bh_map button_map[] = {
+ BH_MAP(BTN_0, "BTN_0"),
+ BH_MAP(BTN_1, "BTN_1"),
+ BH_MAP(BTN_2, "BTN_2"),
+ BH_MAP(BTN_3, "BTN_3"),
+ BH_MAP(BTN_4, "BTN_4"),
+ BH_MAP(BTN_5, "BTN_5"),
+ BH_MAP(BTN_6, "BTN_6"),
+ BH_MAP(BTN_7, "BTN_7"),
+ BH_MAP(BTN_8, "BTN_8"),
+ BH_MAP(BTN_9, "BTN_9"),
+ BH_MAP(KEY_RESTART, "reset"),
+ BH_MAP(KEY_RFKILL, "rfkill"),
+#ifdef KEY_WPS_BUTTON
+ BH_MAP(KEY_WPS_BUTTON, "wps"),
+#endif /* KEY_WPS_BUTTON */
+};
+
+/* -------------------------------------------------------------------------*/
+
+static int bh_event_add_var(struct bh_event *event, int argv,
+ const char *format, ...)
+{
+ static char buf[128];
+ char *s;
+ va_list args;
+ int len;
+
+ if (argv)
+ return 0;
+
+ va_start(args, format);
+ len = vsnprintf(buf, sizeof(buf), format, args);
+ va_end(args);
+
+ if (len >= sizeof(buf)) {
+ BH_ERR("buffer size too small\n");
+ WARN_ON(1);
+ return -ENOMEM;
+ }
+
+ s = skb_put(event->skb, len + 1);
+ strcpy(s, buf);
+
+ BH_DBG("added variable '%s'\n", s);
+
+ return 0;
+}
+
+static int button_hotplug_fill_event(struct bh_event *event)
+{
+ int ret;
+
+ ret = bh_event_add_var(event, 0, "HOME=%s", "/");
+ if (ret)
+ return ret;
+
+ ret = bh_event_add_var(event, 0, "PATH=%s",
+ "/sbin:/bin:/usr/sbin:/usr/bin");
+ if (ret)
+ return ret;
+
+ ret = bh_event_add_var(event, 0, "SUBSYSTEM=%s", "button");
+ if (ret)
+ return ret;
+
+ ret = bh_event_add_var(event, 0, "ACTION=%s", event->action);
+ if (ret)
+ return ret;
+
+ ret = bh_event_add_var(event, 0, "BUTTON=%s", event->name);
+ if (ret)
+ return ret;
+
+ ret = bh_event_add_var(event, 0, "SEEN=%ld", event->seen);
+ if (ret)
+ return ret;
+
+ ret = bh_event_add_var(event, 0, "SEQNUM=%llu", uevent_next_seqnum());
+
+ return ret;
+}
+
+static void button_hotplug_work(struct work_struct *work)
+{
+ struct bh_event *event = container_of(work, struct bh_event, work);
+ int ret = 0;
+
+ event->skb = alloc_skb(BH_SKB_SIZE, GFP_KERNEL);
+ if (!event->skb)
+ goto out_free_event;
+
+ ret = bh_event_add_var(event, 0, "%s@", event->action);
+ if (ret)
+ goto out_free_skb;
+
+ ret = button_hotplug_fill_event(event);
+ if (ret)
+ goto out_free_skb;
+
+ NETLINK_CB(event->skb).dst_group = 1;
+ broadcast_uevent(event->skb, 0, 1, GFP_KERNEL);
+
+ out_free_skb:
+ if (ret) {
+ BH_ERR("work error %d\n", ret);
+ kfree_skb(event->skb);
+ }
+ out_free_event:
+ kfree(event);
+}
+
+static int button_hotplug_create_event(const char *name, unsigned long seen,
+ int pressed)
+{
+ struct bh_event *event;
+
+ BH_DBG("create event, name=%s, seen=%lu, pressed=%d\n",
+ name, seen, pressed);
+
+ event = kzalloc(sizeof(*event), GFP_KERNEL);
+ if (!event)
+ return -ENOMEM;
+
+ event->name = name;
+ event->seen = seen;
+ event->action = pressed ? "pressed" : "released";
+
+ INIT_WORK(&event->work, (void *)(void *)button_hotplug_work);
+ schedule_work(&event->work);
+
+ return 0;
+}
+
+/* -------------------------------------------------------------------------*/
+
+#ifdef CONFIG_HOTPLUG
+static int button_get_index(unsigned int code)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(button_map); i++)
+ if (button_map[i].code == code)
+ return i;
+
+ return -1;
+}
+static void button_hotplug_event(struct gpio_keys_button_data *data,
+ unsigned int type, unsigned int code, int value)
+{
+ struct bh_priv *priv = &data->bh;
+ unsigned long seen = jiffies;
+ int btn;
+
+ BH_DBG("event type=%u, code=%u, value=%d\n", type, code, value);
+
+ if (type != EV_KEY)
+ return;
+
+ btn = button_get_index(code);
+ if (btn < 0)
+ return;
+
+ button_hotplug_create_event(button_map[btn].name,
+ (seen - priv->seen) / HZ, value);
+ priv->seen = seen;
+}
+#else
+static void button_hotplug_event(struct gpio_keys_button_data *data,
+ unsigned int type, unsigned int code, int value)
+{
+}
+#endif /* CONFIG_HOTPLUG */
+
+struct gpio_keys_polled_dev {
+ struct delayed_work work;
+
+ struct device *dev;
+ struct gpio_keys_platform_data *pdata;
+ struct gpio_keys_button_data data[0];
+};
+
+static void gpio_keys_polled_check_state(struct gpio_keys_button *button,
+ struct gpio_keys_button_data *bdata)
+{
+ int state;
+
+ if (bdata->can_sleep)
+ state = !!gpio_get_value_cansleep(button->gpio);
+ else
+ state = !!gpio_get_value(button->gpio);
+
+ state = !!(state ^ button->active_low);
+ if (state != bdata->last_state) {
+ unsigned int type = button->type ?: EV_KEY;
+
+ button_hotplug_event(bdata, type, button->code, state);
+ bdata->count = 0;
+ bdata->last_state = state;
+ }
+}
+
+static void gpio_keys_polled_queue_work(struct gpio_keys_polled_dev *bdev)
+{
+ struct gpio_keys_platform_data *pdata = bdev->pdata;
+ unsigned long delay = msecs_to_jiffies(pdata->poll_interval);
+
+ if (delay >= HZ)
+ delay = round_jiffies_relative(delay);
+ schedule_delayed_work(&bdev->work, delay);
+}
+
+static void gpio_keys_polled_poll(struct work_struct *work)
+{
+ struct gpio_keys_polled_dev *bdev =
+ container_of(work, struct gpio_keys_polled_dev, work.work);
+ struct gpio_keys_platform_data *pdata = bdev->pdata;
+ int i;
+
+ for (i = 0; i < bdev->pdata->nbuttons; i++) {
+ struct gpio_keys_button_data *bdata = &bdev->data[i];
+
+ if (bdata->count < bdata->threshold)
+ bdata->count++;
+ else
+ gpio_keys_polled_check_state(&pdata->buttons[i], bdata);
+ }
+ gpio_keys_polled_queue_work(bdev);
+}
+
+static void gpio_keys_polled_open(struct gpio_keys_polled_dev *bdev)
+{
+ struct gpio_keys_platform_data *pdata = bdev->pdata;
+ int i;
+
+ if (pdata->enable)
+ pdata->enable(bdev->dev);
+
+ /* report initial state of the buttons */
+ for (i = 0; i < pdata->nbuttons; i++)
+ gpio_keys_polled_check_state(&pdata->buttons[i], &bdev->data[i]);
+
+ gpio_keys_polled_queue_work(bdev);
+}
+
+#ifdef CONFIG_OF
+static struct gpio_keys_platform_data *
+gpio_keys_polled_get_devtree_pdata(struct device *dev)
+{
+ struct device_node *node, *pp;
+ struct gpio_keys_platform_data *pdata;
+ struct gpio_keys_button *button;
+ int error;
+ int nbuttons;
+ int i;
+
+ node = dev->of_node;
+ if (!node)
+ return NULL;
+
+ nbuttons = of_get_child_count(node);
+ if (nbuttons == 0)
+ return NULL;
+
+ pdata = kzalloc(sizeof(*pdata) + nbuttons * (sizeof *button),
+ GFP_KERNEL);
+ if (!pdata) {
+ error = -ENOMEM;
+ goto err_out;
+ }
+
+ pdata->buttons = (struct gpio_keys_button *)(pdata + 1);
+ pdata->nbuttons = nbuttons;
+
+ pdata->rep = !!of_get_property(node, "autorepeat", NULL);
+ of_property_read_u32(node, "poll-interval", &pdata->poll_interval);
+
+ i = 0;
+ for_each_child_of_node(node, pp) {
+ enum of_gpio_flags flags;
+
+ if (!of_find_property(pp, "gpios", NULL)) {
+ pdata->nbuttons--;
+ dev_warn(dev, "Found button without gpios\n");
+ continue;
+ }
+
+ button = &pdata->buttons[i++];
+
+ button->gpio = of_get_gpio_flags(pp, 0, &flags);
+ button->active_low = flags & OF_GPIO_ACTIVE_LOW;
+
+ if (of_property_read_u32(pp, "linux,code", &button->code)) {
+ dev_err(dev, "Button without keycode: 0x%x\n",
+ button->gpio);
+ error = -EINVAL;
+ goto err_free_pdata;
+ }
+
+ button->desc = of_get_property(pp, "label", NULL);
+
+ if (of_property_read_u32(pp, "linux,input-type", &button->type))
+ button->type = EV_KEY;
+
+ button->wakeup = !!of_get_property(pp, "gpio-key,wakeup", NULL);
+
+ if (of_property_read_u32(pp, "debounce-interval",
+ &button->debounce_interval))
+ button->debounce_interval = 5;
+ }
+
+ if (pdata->nbuttons == 0) {
+ error = -EINVAL;
+ goto err_free_pdata;
+ }
+
+ return pdata;
+
+err_free_pdata:
+ kfree(pdata);
+err_out:
+ return ERR_PTR(error);
+}
+
+static struct of_device_id gpio_keys_polled_of_match[] = {
+ { .compatible = "gpio-keys-polled", },
+ { },
+};
+MODULE_DEVICE_TABLE(of, gpio_keys_polled_of_match);
+
+#else
+
+static inline struct gpio_keys_platform_data *
+gpio_keys_polled_get_devtree_pdata(struct device *dev)
+{
+ return NULL;
+}
+#endif
+
+static void gpio_keys_polled_close(struct gpio_keys_polled_dev *bdev)
+{
+ struct gpio_keys_platform_data *pdata = bdev->pdata;
+
+ cancel_delayed_work_sync(&bdev->work);
+
+ if (pdata->disable)
+ pdata->disable(bdev->dev);
+}
+
+static int gpio_keys_polled_probe(struct platform_device *pdev)
+{
+ struct gpio_keys_platform_data *pdata = pdev->dev.platform_data;
+ struct device *dev = &pdev->dev;
+ struct gpio_keys_polled_dev *bdev;
+ int error;
+ int i;
+
+ if (!pdata) {
+ pdata = gpio_keys_polled_get_devtree_pdata(dev);
+ if (IS_ERR(pdata))
+ return PTR_ERR(pdata);
+ if (!pdata) {
+ dev_err(dev, "missing platform data\n");
+ return -EINVAL;
+ }
+ }
+
+ if (!pdata->poll_interval) {
+ dev_err(dev, "missing poll_interval value\n");
+ error = -EINVAL;
+ goto err_free_pdata;
+ }
+
+ bdev = kzalloc(sizeof(struct gpio_keys_polled_dev) +
+ pdata->nbuttons * sizeof(struct gpio_keys_button_data),
+ GFP_KERNEL);
+ if (!bdev) {
+ dev_err(dev, "no memory for private data\n");
+ return -ENOMEM;
+ }
+
+ for (i = 0; i < pdata->nbuttons; i++) {
+ struct gpio_keys_button *button = &pdata->buttons[i];
+ struct gpio_keys_button_data *bdata = &bdev->data[i];
+ unsigned int gpio = button->gpio;
+
+ if (button->wakeup) {
+ dev_err(dev, DRV_NAME " does not support wakeup\n");
+ error = -EINVAL;
+ goto err_free_gpio;
+ }
+
+ error = gpio_request(gpio,
+ button->desc ? button->desc : DRV_NAME);
+ if (error) {
+ dev_err(dev, "unable to claim gpio %u, err=%d\n",
+ gpio, error);
+ goto err_free_gpio;
+ }
+
+ error = gpio_direction_input(gpio);
+ if (error) {
+ dev_err(dev,
+ "unable to set direction on gpio %u, err=%d\n",
+ gpio, error);
+ goto err_free_gpio;
+ }
+
+ bdata->can_sleep = gpio_cansleep(gpio);
+ bdata->last_state = 0;
+ bdata->threshold = DIV_ROUND_UP(button->debounce_interval,
+ pdata->poll_interval);
+ }
+
+ bdev->dev = &pdev->dev;
+ bdev->pdata = pdata;
+ platform_set_drvdata(pdev, bdev);
+
+ INIT_DELAYED_WORK(&bdev->work, gpio_keys_polled_poll);
+
+ gpio_keys_polled_open(bdev);
+
+ return 0;
+
+err_free_gpio:
+ while (--i >= 0)
+ gpio_free(pdata->buttons[i].gpio);
+
+ kfree(bdev);
+ platform_set_drvdata(pdev, NULL);
+
+err_free_pdata:
+ /* If we have no platform_data, we allocated pdata dynamically. */
+ if (!dev_get_platdata(&pdev->dev))
+ kfree(pdata);
+
+ return error;
+}
+
+static int gpio_keys_polled_remove(struct platform_device *pdev)
+{
+ struct gpio_keys_polled_dev *bdev = platform_get_drvdata(pdev);
+ struct gpio_keys_platform_data *pdata = bdev->pdata;
+ int i = pdata->nbuttons;
+
+ gpio_keys_polled_close(bdev);
+
+ while (--i >= 0)
+ gpio_free(pdata->buttons[i].gpio);
+
+ kfree(bdev);
+ platform_set_drvdata(pdev, NULL);
+
+ return 0;
+}
+
+static struct platform_driver gpio_keys_polled_driver = {
+ .probe = gpio_keys_polled_probe,
+ .remove = gpio_keys_polled_remove,
+ .driver = {
+ .name = DRV_NAME,
+ .owner = THIS_MODULE,
+ .of_match_table = of_match_ptr(gpio_keys_polled_of_match),
+ },
+};
+
+static int __init gpio_keys_polled_init(void)
+{
+ return platform_driver_register(&gpio_keys_polled_driver);
+}
+
+static void __exit gpio_keys_polled_exit(void)
+{
+ platform_driver_unregister(&gpio_keys_polled_driver);
+}
+
+module_init(gpio_keys_polled_init);
+module_exit(gpio_keys_polled_exit);
+
+MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
+MODULE_AUTHOR("Felix Fietkau <nbd@openwrt.org>");
+MODULE_DESCRIPTION("Polled GPIO Buttons hotplug driver");
+MODULE_LICENSE("GPL v2");
+MODULE_ALIAS("platform:" DRV_NAME);
diff --git a/package/system/hostap-driver/.svn/entries b/package/system/hostap-driver/.svn/entries
new file mode 100644
index 0000000..850d88f
--- /dev/null
+++ b/package/system/hostap-driver/.svn/entries
@@ -0,0 +1,68 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/system/hostap-driver
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+files
+dir
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+84a904d1db4aff47b9f9889acd1f4660
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3361
+
diff --git a/package/system/hostap-driver/.svn/prop-base/Makefile.svn-base b/package/system/hostap-driver/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..8e522ae
--- /dev/null
+++ b/package/system/hostap-driver/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:copyright
+V 30
+Copyright (C) 2006 OpenWrt.org
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/system/hostap-driver/.svn/text-base/Makefile.svn-base b/package/system/hostap-driver/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..d08fd9c
--- /dev/null
+++ b/package/system/hostap-driver/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,117 @@
+#
+# Copyright (C) 2006-2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=hostap-driver
+PKG_VERSION:=0.4.9
+PKG_RELEASE:=2
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://hostap.epitest.fi/releases/
+PKG_MD5SUM:=c7534dc040ab90218257a78488ecd378
+
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/hostap/Default
+ VERSION:=$(LINUX_VERSION)-$(BOARD)-$(PKG_RELEASE)
+ SUBMENU:=Wireless Drivers
+ URL:=http://hostap.epitest.fi/
+endef
+
+define KernelPackage/hostap/Default/description
+ Host AP is a driver for 802.11b wireless cards based on Intersil
+ Prism2/2.5/3 chipset. It supports so called Host AP mode that allows the
+ card to act as an IEEE 802.11 access point.
+endef
+
+
+define KernelPackage/hostap
+$(call KernelPackage/hostap/Default)
+ TITLE:=Host AP support for Prism2/2.5/3
+ DEPENDS:=@PCI_SUPPORT||PCMCIA_SUPPORT +kmod-lib80211 +wireless-tools
+ KCONFIG:=CONFIG_HOSTAP CONFIG_HOSTAP_FIRMWARE=y CONFIG_HOSTAP_FIRMWARE_NVRAM=y
+ FILES:=$(LINUX_DIR)/drivers/net/wireless/hostap/hostap.ko
+ AUTOLOAD:=$(call AutoLoad,60,hostap)
+endef
+
+define KernelPackage/hostap/description
+$(call KernelPackage/hostap/Default/description)
+ This package contains the base Host AP driver code that is shared by
+ different hardware models. You will also need to enable support for
+ PLX/PCI/CS version of the driver to actually use the driver.
+endef
+
+
+define KernelPackage/hostap-cs
+$(call KernelPackage/hostap/Default)
+ TITLE:=Host AP driver for PCMCIA adaptors
+ DEPENDS:=@PCMCIA_SUPPORT +kmod-hostap +kmod-pcmcia-core
+ KCONFIG:=CONFIG_HOSTAP_CS
+ FILES:=$(LINUX_DIR)/drivers/net/wireless/hostap/hostap_cs.ko
+ AUTOLOAD:=$(call AutoLoad,60,hostap_cs)
+endef
+
+define KernelPackage/hostap-cs/description
+$(call KernelPackage/hostap/Default/description)
+ This package contains the Host AP driver for Prism2/2.5/3 PC cards.
+endef
+
+
+define KernelPackage/hostap-pci
+$(call KernelPackage/hostap/Default)
+ TITLE:=Host AP driver for PCI adaptors
+ DEPENDS:=@PCI_SUPPORT +kmod-hostap
+ KCONFIG:=CONFIG_HOSTAP_PCI
+ FILES:=$(LINUX_DIR)/drivers/net/wireless/hostap/hostap_pci.ko
+ AUTOLOAD:=$(call AutoLoad,60,hostap_pci)
+endef
+
+define KernelPackage/hostap-pci/description
+$(call KernelPackage/hostap/Default/description)
+ This package contains the Host AP driver for Prism2.5 PCI adaptors.
+endef
+
+
+define KernelPackage/hostap-plx
+$(call KernelPackage/hostap/Default)
+ TITLE:=Host AP driver for PLX9052 based PCI adaptors
+ DEPENDS:=@PCI_SUPPORT +kmod-hostap
+ KCONFIG:=CONFIG_HOSTAP_PLX
+ FILES:=$(LINUX_DIR)/drivers/net/wireless/hostap/hostap_plx.ko
+ AUTOLOAD:=$(call AutoLoad,60,hostap_plx)
+endef
+
+define KernelPackage/hostap-plx/description
+$(call KernelPackage/hostap/Default/description)
+ This package contains the Host AP driver for Prism2/2.5/3 in PLX9052
+ based PCI adaptors.
+endef
+
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+endef
+
+define Build/Configure
+
+endef
+
+define Build/Compile
+
+endef
+
+define KernelPackage/hostap/install
+ $(INSTALL_DIR) $(1)/lib/wifi
+ $(INSTALL_DATA) ./files/lib/wifi/hostap.sh $(1)/lib/wifi
+endef
+
+$(eval $(call KernelPackage,hostap))
+$(eval $(call KernelPackage,hostap-cs))
+$(eval $(call KernelPackage,hostap-pci))
+$(eval $(call KernelPackage,hostap-plx))
diff --git a/package/system/hostap-driver/Makefile b/package/system/hostap-driver/Makefile
new file mode 100644
index 0000000..d08fd9c
--- /dev/null
+++ b/package/system/hostap-driver/Makefile
@@ -0,0 +1,117 @@
+#
+# Copyright (C) 2006-2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=hostap-driver
+PKG_VERSION:=0.4.9
+PKG_RELEASE:=2
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://hostap.epitest.fi/releases/
+PKG_MD5SUM:=c7534dc040ab90218257a78488ecd378
+
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/hostap/Default
+ VERSION:=$(LINUX_VERSION)-$(BOARD)-$(PKG_RELEASE)
+ SUBMENU:=Wireless Drivers
+ URL:=http://hostap.epitest.fi/
+endef
+
+define KernelPackage/hostap/Default/description
+ Host AP is a driver for 802.11b wireless cards based on Intersil
+ Prism2/2.5/3 chipset. It supports so called Host AP mode that allows the
+ card to act as an IEEE 802.11 access point.
+endef
+
+
+define KernelPackage/hostap
+$(call KernelPackage/hostap/Default)
+ TITLE:=Host AP support for Prism2/2.5/3
+ DEPENDS:=@PCI_SUPPORT||PCMCIA_SUPPORT +kmod-lib80211 +wireless-tools
+ KCONFIG:=CONFIG_HOSTAP CONFIG_HOSTAP_FIRMWARE=y CONFIG_HOSTAP_FIRMWARE_NVRAM=y
+ FILES:=$(LINUX_DIR)/drivers/net/wireless/hostap/hostap.ko
+ AUTOLOAD:=$(call AutoLoad,60,hostap)
+endef
+
+define KernelPackage/hostap/description
+$(call KernelPackage/hostap/Default/description)
+ This package contains the base Host AP driver code that is shared by
+ different hardware models. You will also need to enable support for
+ PLX/PCI/CS version of the driver to actually use the driver.
+endef
+
+
+define KernelPackage/hostap-cs
+$(call KernelPackage/hostap/Default)
+ TITLE:=Host AP driver for PCMCIA adaptors
+ DEPENDS:=@PCMCIA_SUPPORT +kmod-hostap +kmod-pcmcia-core
+ KCONFIG:=CONFIG_HOSTAP_CS
+ FILES:=$(LINUX_DIR)/drivers/net/wireless/hostap/hostap_cs.ko
+ AUTOLOAD:=$(call AutoLoad,60,hostap_cs)
+endef
+
+define KernelPackage/hostap-cs/description
+$(call KernelPackage/hostap/Default/description)
+ This package contains the Host AP driver for Prism2/2.5/3 PC cards.
+endef
+
+
+define KernelPackage/hostap-pci
+$(call KernelPackage/hostap/Default)
+ TITLE:=Host AP driver for PCI adaptors
+ DEPENDS:=@PCI_SUPPORT +kmod-hostap
+ KCONFIG:=CONFIG_HOSTAP_PCI
+ FILES:=$(LINUX_DIR)/drivers/net/wireless/hostap/hostap_pci.ko
+ AUTOLOAD:=$(call AutoLoad,60,hostap_pci)
+endef
+
+define KernelPackage/hostap-pci/description
+$(call KernelPackage/hostap/Default/description)
+ This package contains the Host AP driver for Prism2.5 PCI adaptors.
+endef
+
+
+define KernelPackage/hostap-plx
+$(call KernelPackage/hostap/Default)
+ TITLE:=Host AP driver for PLX9052 based PCI adaptors
+ DEPENDS:=@PCI_SUPPORT +kmod-hostap
+ KCONFIG:=CONFIG_HOSTAP_PLX
+ FILES:=$(LINUX_DIR)/drivers/net/wireless/hostap/hostap_plx.ko
+ AUTOLOAD:=$(call AutoLoad,60,hostap_plx)
+endef
+
+define KernelPackage/hostap-plx/description
+$(call KernelPackage/hostap/Default/description)
+ This package contains the Host AP driver for Prism2/2.5/3 in PLX9052
+ based PCI adaptors.
+endef
+
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+endef
+
+define Build/Configure
+
+endef
+
+define Build/Compile
+
+endef
+
+define KernelPackage/hostap/install
+ $(INSTALL_DIR) $(1)/lib/wifi
+ $(INSTALL_DATA) ./files/lib/wifi/hostap.sh $(1)/lib/wifi
+endef
+
+$(eval $(call KernelPackage,hostap))
+$(eval $(call KernelPackage,hostap-cs))
+$(eval $(call KernelPackage,hostap-pci))
+$(eval $(call KernelPackage,hostap-plx))
diff --git a/package/system/hostap-driver/files/.svn/entries b/package/system/hostap-driver/files/.svn/entries
new file mode 100644
index 0000000..f09e58e
--- /dev/null
+++ b/package/system/hostap-driver/files/.svn/entries
@@ -0,0 +1,31 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/system/hostap-driver/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+lib
+dir
+
diff --git a/package/system/hostap-driver/files/lib/.svn/entries b/package/system/hostap-driver/files/lib/.svn/entries
new file mode 100644
index 0000000..79a977b
--- /dev/null
+++ b/package/system/hostap-driver/files/lib/.svn/entries
@@ -0,0 +1,31 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/system/hostap-driver/files/lib
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+wifi
+dir
+
diff --git a/package/system/hostap-driver/files/lib/wifi/.svn/entries b/package/system/hostap-driver/files/lib/wifi/.svn/entries
new file mode 100644
index 0000000..17b4c6f
--- /dev/null
+++ b/package/system/hostap-driver/files/lib/wifi/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/system/hostap-driver/files/lib/wifi
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+hostap.sh
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+fafb9cf5a69a0003bad0b3cfc7799766
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+6450
+
diff --git a/package/system/hostap-driver/files/lib/wifi/.svn/prop-base/hostap.sh.svn-base b/package/system/hostap-driver/files/lib/wifi/.svn/prop-base/hostap.sh.svn-base
new file mode 100644
index 0000000..869ac71
--- /dev/null
+++ b/package/system/hostap-driver/files/lib/wifi/.svn/prop-base/hostap.sh.svn-base
@@ -0,0 +1,5 @@
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/system/hostap-driver/files/lib/wifi/.svn/text-base/hostap.sh.svn-base b/package/system/hostap-driver/files/lib/wifi/.svn/text-base/hostap.sh.svn-base
new file mode 100644
index 0000000..62d2e7e
--- /dev/null
+++ b/package/system/hostap-driver/files/lib/wifi/.svn/text-base/hostap.sh.svn-base
@@ -0,0 +1,270 @@
+#!/bin/sh
+append DRIVERS "prism2"
+
+find_prism2_phy() {
+ local device="$1"
+
+ local macaddr="$(config_get "$device" macaddr | tr 'A-Z' 'a-z')"
+ config_get phy "$device" phy
+ [ -z "$phy" -a -n "$macaddr" ] && {
+ cd /proc/net/hostap
+ for phy in $(ls -d wlan* 2>&-); do
+ [ "$macaddr" = "$(cat /sys/class/net/${phy}/address)" ] || continue
+ config_set "$device" phy "$phy"
+ break
+ done
+ config_get phy "$device" phy
+ }
+ [ -n "$phy" -a -d "/proc/net/hostap/$phy" ] || {
+ echo "phy for wifi device $1 not found"
+ return 1
+ }
+ [ -z "$macaddr" ] && {
+ config_set "$device" macaddr "$(cat /sys/class/net/${phy}/address)"
+ }
+ return 0
+}
+
+scan_prism2() {
+ local device="$1"
+ local mainvif
+ local wds
+
+ [ ${device%[0-9]} = "wlan" ] && config_set "$device" phy "$device" || find_prism2_phy "$device" || {
+ config_unset "$device" vifs
+ return 0
+ }
+ config_get phy "$device" phy
+
+ config_get vifs "$device" vifs
+ local _c=0
+ for vif in $vifs; do
+ config_get_bool disabled "$vif" disabled 0
+ [ $disabled = 0 ] || continue
+
+ config_get mode "$vif" mode
+ case "$mode" in
+ adhoc|sta|ap|monitor)
+ # Only one vif is allowed on AP, station, Ad-hoc or monitor mode
+ [ -z "$mainvif" ] && {
+ mainvif="$vif"
+ config_set "$vif" ifname "$phy"
+ }
+ ;;
+ wds)
+ config_get ssid "$vif" ssid
+ [ -z "$ssid" ] && continue
+ config_set "$vif" ifname "${phy}wds${_c}"
+ _c=$(($_c + 1))
+ addr="$ssid"
+ ${addr:+append wds "$vif"}
+ ;;
+ *) echo "$device($vif): Invalid mode, ignored."; continue;;
+ esac
+ done
+ config_set "$device" vifs "${mainvif:+$mainvif }${wds:+$wds}"
+}
+
+disable_prism2() (
+ local device="$1"
+
+ find_prism2_phy "$device" || return 0
+ config_get phy "$device" phy
+
+ set_wifi_down "$device"
+
+ include /lib/network
+ while read line < /proc/net/hostap/${phy}/wds; do
+ set $line
+ [ -f "/var/run/wifi-${1}.pid" ] &&
+ kill "$(cat "/var/run/wifi-${1}.pid")"
+ ifconfig "$1" down
+ unbridge "$1"
+ iwpriv "$phy" wds_del "$2"
+ done
+ unbridge "$phy"
+ return 0
+)
+
+enable_prism2() {
+ local device="$1"
+
+ find_prism2_phy "$device" || return 0
+ config_get phy "$device" phy
+
+ config_get rxantenna "$device" rxantenna
+ config_get txantenna "$device" txantenna
+ config_get_bool diversity "$device" diversity
+ [ -n "$diversity" ] && {
+ rxantenna="1"
+ txantenna="1"
+ }
+ [ -n "$rxantenna" ] && iwpriv "$phy" antsel_rx "$rxantenna"
+ [ -n "$txantenna" ] && iwpriv "$phy" antsel_tx "$txantenna"
+
+ config_get channel "$device" channel
+ [ -n "$channel" ] && iwconfig "$phy" channel "$channel" >/dev/null 2>/dev/null
+
+ config_get txpower "$device" txpower
+ [ -n "$txpower" ] && iwconfig "$phy" txpower "${txpower%%.*}"
+
+ config_get vifs "$device" vifs
+ local first=1
+ for vif in $vifs; do
+ config_get ifname "$vif" ifname
+ config_get ssid "$vif" ssid
+ config_get mode "$vif" mode
+
+ [ "$mode" = "wds" ] || iwconfig "$phy" essid ${ssid:+-- }"${ssid:-any}"
+
+ case "$mode" in
+ sta)
+ iwconfig "$phy" mode managed
+ config_get addr "$device" bssid
+ [ -z "$addr" ] || {
+ iwconfig "$phy" ap "$addr"
+ }
+ ;;
+ ap) iwconfig "$phy" mode master;;
+ wds) iwpriv "$phy" wds_add "$ssid";;
+ adhoc) iwconfig "$phy" mode ad-hoc;;
+ *) iwconfig "$phy" mode "$mode";;
+ esac
+
+ [ "$first" = 1 ] && {
+ config_get rate "$vif" rate
+ [ -n "$rate" ] && iwconfig "$phy" rate "${rate%%.*}"
+
+ config_get_bool hidden "$vif" hidden 0
+ iwpriv "$phy" enh_sec "$hidden"
+
+ config_get frag "$vif" frag
+ [ -n "$frag" ] && iwconfig "$phy" frag "${frag%%.*}"
+
+ config_get rts "$vif" rts
+ [ -n "$rts" ] && iwconfig "$phy" rts "${rts%%.*}"
+
+ config_get maclist "$vif" maclist
+ [ -n "$maclist" ] && {
+ # flush MAC list
+ iwpriv "$phy" maccmd 3
+ for mac in $maclist; do
+ iwpriv "$phy" addmac "$mac"
+ done
+ }
+ config_get macpolicy "$vif" macpolicy
+ case "$macpolicy" in
+ allow)
+ iwpriv "$phy" maccmd 2
+ ;;
+ deny)
+ iwpriv "$phy" maccmd 1
+ ;;
+ *)
+ # default deny policy if mac list exists
+ [ -n "$maclist" ] && iwpriv "$phy" maccmd 1
+ ;;
+ esac
+ # kick all stations if we have policy explicitly set
+ [ -n "$macpolicy" ] && iwpriv "$phy" maccmd 4
+ }
+
+ config_get enc "$vif" encryption
+ case "$enc" in
+ WEP|wep)
+ for idx in 1 2 3 4; do
+ config_get key "$vif" "key${idx}"
+ iwconfig "$ifname" enc "[$idx]" "${key:-off}"
+ done
+ config_get key "$vif" key
+ key="${key:-1}"
+ case "$key" in
+ [1234]) iwconfig "$ifname" enc "[$key]";;
+ *) iwconfig "$ifname" enc "$key";;
+ esac
+ ;;
+ psk*|wpa*)
+ start_hostapd=1
+ config_get key "$vif" key
+ ;;
+ esac
+
+ local net_cfg bridge
+ net_cfg="$(find_net_config "$vif")"
+ [ -z "$net_cfg" ] || {
+ bridge="$(bridge_interface "$net_cfg")"
+ config_set "$vif" bridge "$bridge"
+ start_net "$ifname" "$net_cfg"
+ }
+ set_wifi_up "$vif" "$ifname"
+
+ case "$mode" in
+ ap)
+ if [ -n "$start_hostapd" ] && eval "type hostapd_setup_vif" 2>/dev/null >/dev/null; then
+ hostapd_setup_vif "$vif" hostap || {
+ echo "enable_prism2($device): Failed to set up hostapd for interface $ifname" >&2
+ # make sure this wifi interface won't accidentally stay open without encryption
+ ifconfig "$ifname" down
+ continue
+ }
+ fi
+ ;;
+ wds|sta)
+ if eval "type wpa_supplicant_setup_vif" 2>/dev/null >/dev/null; then
+ wpa_supplicant_setup_vif "$vif" wext || {
+ echo "enable_prism2($device): Failed to set up wpa_supplicant for interface $ifname" >&2
+ ifconfig "$ifname" down
+ continue
+ }
+ fi
+ ;;
+ esac
+ first=0
+ done
+
+}
+
+check_prism2_device() {
+ [ ${1%[0-9]} = "wlan" ] && config_set "$1" phy "$1"
+ config_get phy "$1" phy
+ [ -z "$phy" ] && {
+ find_prism2_phy "$1" >/dev/null || return 0
+ config_get phy "$1" phy
+ }
+ [ "$phy" = "$dev" ] && found=1
+}
+
+detect_prism2() {
+ devidx=0
+ config_load wireless
+ while :; do
+ config_get type "radio$devidx" type
+ [ -n "$type" ] || break
+ devidx=$(($devidx + 1))
+ done
+ cd /proc/net/hostap
+ [ -d wlan* ] || return
+ for dev in $(ls -d wlan* 2>&-); do
+ found=0
+ config_foreach check_prism2_device wifi-device
+ [ "$found" -gt 0 ] && continue
+ cat <<EOF
+config wifi-device radio$devidx
+ option type prism2
+ option channel 11
+ option macaddr $(cat /sys/class/net/${dev}/address)
+
+ # REMOVE THIS LINE TO ENABLE WIFI:
+ option disabled 1
+
+config wifi-iface
+ option device radio$devidx
+ option network lan
+ option mode ap
+ option ssid OpenWrt
+ option encryption none
+
+EOF
+ devidx=$(($devidx + 1))
+ done
+}
diff --git a/package/system/hostap-driver/files/lib/wifi/hostap.sh b/package/system/hostap-driver/files/lib/wifi/hostap.sh
new file mode 100755
index 0000000..62d2e7e
--- /dev/null
+++ b/package/system/hostap-driver/files/lib/wifi/hostap.sh
@@ -0,0 +1,270 @@
+#!/bin/sh
+append DRIVERS "prism2"
+
+find_prism2_phy() {
+ local device="$1"
+
+ local macaddr="$(config_get "$device" macaddr | tr 'A-Z' 'a-z')"
+ config_get phy "$device" phy
+ [ -z "$phy" -a -n "$macaddr" ] && {
+ cd /proc/net/hostap
+ for phy in $(ls -d wlan* 2>&-); do
+ [ "$macaddr" = "$(cat /sys/class/net/${phy}/address)" ] || continue
+ config_set "$device" phy "$phy"
+ break
+ done
+ config_get phy "$device" phy
+ }
+ [ -n "$phy" -a -d "/proc/net/hostap/$phy" ] || {
+ echo "phy for wifi device $1 not found"
+ return 1
+ }
+ [ -z "$macaddr" ] && {
+ config_set "$device" macaddr "$(cat /sys/class/net/${phy}/address)"
+ }
+ return 0
+}
+
+scan_prism2() {
+ local device="$1"
+ local mainvif
+ local wds
+
+ [ ${device%[0-9]} = "wlan" ] && config_set "$device" phy "$device" || find_prism2_phy "$device" || {
+ config_unset "$device" vifs
+ return 0
+ }
+ config_get phy "$device" phy
+
+ config_get vifs "$device" vifs
+ local _c=0
+ for vif in $vifs; do
+ config_get_bool disabled "$vif" disabled 0
+ [ $disabled = 0 ] || continue
+
+ config_get mode "$vif" mode
+ case "$mode" in
+ adhoc|sta|ap|monitor)
+ # Only one vif is allowed on AP, station, Ad-hoc or monitor mode
+ [ -z "$mainvif" ] && {
+ mainvif="$vif"
+ config_set "$vif" ifname "$phy"
+ }
+ ;;
+ wds)
+ config_get ssid "$vif" ssid
+ [ -z "$ssid" ] && continue
+ config_set "$vif" ifname "${phy}wds${_c}"
+ _c=$(($_c + 1))
+ addr="$ssid"
+ ${addr:+append wds "$vif"}
+ ;;
+ *) echo "$device($vif): Invalid mode, ignored."; continue;;
+ esac
+ done
+ config_set "$device" vifs "${mainvif:+$mainvif }${wds:+$wds}"
+}
+
+disable_prism2() (
+ local device="$1"
+
+ find_prism2_phy "$device" || return 0
+ config_get phy "$device" phy
+
+ set_wifi_down "$device"
+
+ include /lib/network
+ while read line < /proc/net/hostap/${phy}/wds; do
+ set $line
+ [ -f "/var/run/wifi-${1}.pid" ] &&
+ kill "$(cat "/var/run/wifi-${1}.pid")"
+ ifconfig "$1" down
+ unbridge "$1"
+ iwpriv "$phy" wds_del "$2"
+ done
+ unbridge "$phy"
+ return 0
+)
+
+enable_prism2() {
+ local device="$1"
+
+ find_prism2_phy "$device" || return 0
+ config_get phy "$device" phy
+
+ config_get rxantenna "$device" rxantenna
+ config_get txantenna "$device" txantenna
+ config_get_bool diversity "$device" diversity
+ [ -n "$diversity" ] && {
+ rxantenna="1"
+ txantenna="1"
+ }
+ [ -n "$rxantenna" ] && iwpriv "$phy" antsel_rx "$rxantenna"
+ [ -n "$txantenna" ] && iwpriv "$phy" antsel_tx "$txantenna"
+
+ config_get channel "$device" channel
+ [ -n "$channel" ] && iwconfig "$phy" channel "$channel" >/dev/null 2>/dev/null
+
+ config_get txpower "$device" txpower
+ [ -n "$txpower" ] && iwconfig "$phy" txpower "${txpower%%.*}"
+
+ config_get vifs "$device" vifs
+ local first=1
+ for vif in $vifs; do
+ config_get ifname "$vif" ifname
+ config_get ssid "$vif" ssid
+ config_get mode "$vif" mode
+
+ [ "$mode" = "wds" ] || iwconfig "$phy" essid ${ssid:+-- }"${ssid:-any}"
+
+ case "$mode" in
+ sta)
+ iwconfig "$phy" mode managed
+ config_get addr "$device" bssid
+ [ -z "$addr" ] || {
+ iwconfig "$phy" ap "$addr"
+ }
+ ;;
+ ap) iwconfig "$phy" mode master;;
+ wds) iwpriv "$phy" wds_add "$ssid";;
+ adhoc) iwconfig "$phy" mode ad-hoc;;
+ *) iwconfig "$phy" mode "$mode";;
+ esac
+
+ [ "$first" = 1 ] && {
+ config_get rate "$vif" rate
+ [ -n "$rate" ] && iwconfig "$phy" rate "${rate%%.*}"
+
+ config_get_bool hidden "$vif" hidden 0
+ iwpriv "$phy" enh_sec "$hidden"
+
+ config_get frag "$vif" frag
+ [ -n "$frag" ] && iwconfig "$phy" frag "${frag%%.*}"
+
+ config_get rts "$vif" rts
+ [ -n "$rts" ] && iwconfig "$phy" rts "${rts%%.*}"
+
+ config_get maclist "$vif" maclist
+ [ -n "$maclist" ] && {
+ # flush MAC list
+ iwpriv "$phy" maccmd 3
+ for mac in $maclist; do
+ iwpriv "$phy" addmac "$mac"
+ done
+ }
+ config_get macpolicy "$vif" macpolicy
+ case "$macpolicy" in
+ allow)
+ iwpriv "$phy" maccmd 2
+ ;;
+ deny)
+ iwpriv "$phy" maccmd 1
+ ;;
+ *)
+ # default deny policy if mac list exists
+ [ -n "$maclist" ] && iwpriv "$phy" maccmd 1
+ ;;
+ esac
+ # kick all stations if we have policy explicitly set
+ [ -n "$macpolicy" ] && iwpriv "$phy" maccmd 4
+ }
+
+ config_get enc "$vif" encryption
+ case "$enc" in
+ WEP|wep)
+ for idx in 1 2 3 4; do
+ config_get key "$vif" "key${idx}"
+ iwconfig "$ifname" enc "[$idx]" "${key:-off}"
+ done
+ config_get key "$vif" key
+ key="${key:-1}"
+ case "$key" in
+ [1234]) iwconfig "$ifname" enc "[$key]";;
+ *) iwconfig "$ifname" enc "$key";;
+ esac
+ ;;
+ psk*|wpa*)
+ start_hostapd=1
+ config_get key "$vif" key
+ ;;
+ esac
+
+ local net_cfg bridge
+ net_cfg="$(find_net_config "$vif")"
+ [ -z "$net_cfg" ] || {
+ bridge="$(bridge_interface "$net_cfg")"
+ config_set "$vif" bridge "$bridge"
+ start_net "$ifname" "$net_cfg"
+ }
+ set_wifi_up "$vif" "$ifname"
+
+ case "$mode" in
+ ap)
+ if [ -n "$start_hostapd" ] && eval "type hostapd_setup_vif" 2>/dev/null >/dev/null; then
+ hostapd_setup_vif "$vif" hostap || {
+ echo "enable_prism2($device): Failed to set up hostapd for interface $ifname" >&2
+ # make sure this wifi interface won't accidentally stay open without encryption
+ ifconfig "$ifname" down
+ continue
+ }
+ fi
+ ;;
+ wds|sta)
+ if eval "type wpa_supplicant_setup_vif" 2>/dev/null >/dev/null; then
+ wpa_supplicant_setup_vif "$vif" wext || {
+ echo "enable_prism2($device): Failed to set up wpa_supplicant for interface $ifname" >&2
+ ifconfig "$ifname" down
+ continue
+ }
+ fi
+ ;;
+ esac
+ first=0
+ done
+
+}
+
+check_prism2_device() {
+ [ ${1%[0-9]} = "wlan" ] && config_set "$1" phy "$1"
+ config_get phy "$1" phy
+ [ -z "$phy" ] && {
+ find_prism2_phy "$1" >/dev/null || return 0
+ config_get phy "$1" phy
+ }
+ [ "$phy" = "$dev" ] && found=1
+}
+
+detect_prism2() {
+ devidx=0
+ config_load wireless
+ while :; do
+ config_get type "radio$devidx" type
+ [ -n "$type" ] || break
+ devidx=$(($devidx + 1))
+ done
+ cd /proc/net/hostap
+ [ -d wlan* ] || return
+ for dev in $(ls -d wlan* 2>&-); do
+ found=0
+ config_foreach check_prism2_device wifi-device
+ [ "$found" -gt 0 ] && continue
+ cat <<EOF
+config wifi-device radio$devidx
+ option type prism2
+ option channel 11
+ option macaddr $(cat /sys/class/net/${dev}/address)
+
+ # REMOVE THIS LINE TO ENABLE WIFI:
+ option disabled 1
+
+config wifi-iface
+ option device radio$devidx
+ option network lan
+ option mode ap
+ option ssid OpenWrt
+ option encryption none
+
+EOF
+ devidx=$(($devidx + 1))
+ done
+}
diff --git a/package/system/hostap-driver/patches/.svn/entries b/package/system/hostap-driver/patches/.svn/entries
new file mode 100644
index 0000000..6b2e792
--- /dev/null
+++ b/package/system/hostap-driver/patches/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/system/hostap-driver/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+001-fix-txpower.patch
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+d9fadaa4dc0cdcf3ff89259baa9fb152
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+7007
+
diff --git a/package/system/hostap-driver/patches/.svn/text-base/001-fix-txpower.patch.svn-base b/package/system/hostap-driver/patches/.svn/text-base/001-fix-txpower.patch.svn-base
new file mode 100644
index 0000000..94ca344
--- /dev/null
+++ b/package/system/hostap-driver/patches/.svn/text-base/001-fix-txpower.patch.svn-base
@@ -0,0 +1,175 @@
+diff -Naur hostap-driver-0.3.7/driver/modules/hostap.c hostap-driver-0.3.7-patched/driver/modules/hostap.c
+--- hostap-driver-0.3.7/driver/modules/hostap.c 2004-08-28 06:26:46.000000000 +0300
++++ hostap-driver-0.3.7-patched/driver/modules/hostap.c 2005-04-20 17:20:56.000000000 +0300
+@@ -1164,6 +1164,36 @@
+ return ret;
+ }
+
++/* BUG FIX: Restore power setting value when lost due to F/W bug */
++
++int hostap_restore_power(struct net_device *dev)
++{
++ struct hostap_interface *iface = dev->priv;
++ local_info_t *local = iface->local;
++
++ u16 val;
++ int ret = 0;
++
++ if (local->txpower_type == PRISM2_TXPOWER_OFF) {
++ val = 0xff; /* use all standby and sleep modes */
++ ret = local->func->cmd(dev, HFA384X_CMDCODE_WRITEMIF,
++ HFA386X_CR_A_D_TEST_MODES2,
++ &val, NULL);
++ }
++
++#ifdef RAW_TXPOWER_SETTING
++ if (local->txpower_type == PRISM2_TXPOWER_FIXED) {
++ val = HFA384X_TEST_CFG_BIT_ALC;
++ local->func->cmd(dev, HFA384X_CMDCODE_TEST |
++ (HFA384X_TEST_CFG_BITS << 8), 0, &val, NULL);
++ val = prism2_txpower_dBm_to_hfa386x(local->txpower);
++ ret = (local->func->cmd(dev, HFA384X_CMDCODE_WRITEMIF,
++ HFA386X_CR_MANUAL_TX_POWER, &val, NULL));
++ }
++#endif /* RAW_TXPOWER_SETTING */
++ return (ret ? -EOPNOTSUPP : 0);
++}
++
+
+ struct proc_dir_entry *hostap_proc;
+
+@@ -1214,6 +1244,7 @@
+ EXPORT_SYMBOL(hostap_set_hostapd_sta);
+ EXPORT_SYMBOL(hostap_add_interface);
+ EXPORT_SYMBOL(hostap_remove_interface);
++EXPORT_SYMBOL(hostap_restore_power);
+ EXPORT_SYMBOL(prism2_update_comms_qual);
+
+ module_init(hostap_init);
+diff -Naur hostap-driver-0.3.7/driver/modules/hostap.h hostap-driver-0.3.7-patched/driver/modules/hostap.h
+--- hostap-driver-0.3.7/driver/modules/hostap.h 2003-11-30 04:14:26.000000000 +0200
++++ hostap-driver-0.3.7-patched/driver/modules/hostap.h 2005-04-20 17:21:23.000000000 +0300
+@@ -36,6 +36,7 @@
+ const char *prefix, const char *name);
+ void hostap_remove_interface(struct net_device *dev, int rtnl_locked,
+ int remove_from_list);
++int hostap_restore_power(struct net_device *dev);
+ int prism2_update_comms_qual(struct net_device *dev);
+ int prism2_sta_send_mgmt(local_info_t *local, u8 *dst, u8 stype,
+ u8 *body, size_t bodylen);
+diff -Naur hostap-driver-0.3.7/driver/modules/hostap_ap.c hostap-driver-0.3.7-patched/driver/modules/hostap_ap.c
+--- hostap-driver-0.3.7/driver/modules/hostap_ap.c 2005-01-24 04:52:00.000000000 +0200
++++ hostap-driver-0.3.7-patched/driver/modules/hostap_ap.c 2005-04-21 20:06:12.000000000 +0300
+@@ -2346,13 +2346,13 @@
+ addr[count].sa_family = ARPHRD_ETHER;
+ memcpy(addr[count].sa_data, sta->addr, ETH_ALEN);
+ if (sta->last_rx_silence == 0)
+- qual[count].qual = sta->last_rx_signal < 27 ?
+- 0 : (sta->last_rx_signal - 27) * 92 / 127;
++ qual[count].qual = (sta->last_rx_signal - 156) == 0 ?
++ 0 : (sta->last_rx_signal - 156) * 92 / 64;
+ else
+- qual[count].qual = sta->last_rx_signal -
+- sta->last_rx_silence - 35;
+- qual[count].level = HFA384X_LEVEL_TO_dBm(sta->last_rx_signal);
+- qual[count].noise = HFA384X_LEVEL_TO_dBm(sta->last_rx_silence);
++ qual[count].qual = (sta->last_rx_signal -
++ sta->last_rx_silence) * 92 / 64;
++ qual[count].level = sta->last_rx_signal;
++ qual[count].noise = sta->last_rx_silence;
+ qual[count].updated = sta->last_rx_updated;
+
+ sta->last_rx_updated = 0;
+@@ -2413,13 +2413,13 @@
+ memset(&iwe, 0, sizeof(iwe));
+ iwe.cmd = IWEVQUAL;
+ if (sta->last_rx_silence == 0)
+- iwe.u.qual.qual = sta->last_rx_signal < 27 ?
+- 0 : (sta->last_rx_signal - 27) * 92 / 127;
++ iwe.u.qual.qual = (sta->last_rx_signal -156) == 0 ?
++ 0 : (sta->last_rx_signal - 156) * 92 / 64;
+ else
+- iwe.u.qual.qual = sta->last_rx_signal -
+- sta->last_rx_silence - 35;
+- iwe.u.qual.level = HFA384X_LEVEL_TO_dBm(sta->last_rx_signal);
+- iwe.u.qual.noise = HFA384X_LEVEL_TO_dBm(sta->last_rx_silence);
++ iwe.u.qual.qual = (sta->last_rx_signal -
++ sta->last_rx_silence) * 92 / 64;
++ iwe.u.qual.level = sta->last_rx_signal;
++ iwe.u.qual.noise = sta->last_rx_silence;
+ iwe.u.qual.updated = sta->last_rx_updated;
+ iwe.len = IW_EV_QUAL_LEN;
+ current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe,
+diff -Naur hostap-driver-0.3.7/driver/modules/hostap_config.h hostap-driver-0.3.7-patched/driver/modules/hostap_config.h
+--- hostap-driver-0.3.7/driver/modules/hostap_config.h 2005-02-12 18:12:56.000000000 +0200
++++ hostap-driver-0.3.7-patched/driver/modules/hostap_config.h 2005-04-20 17:25:23.000000000 +0300
+@@ -94,6 +94,12 @@
+ */
+ /* #define PRISM2_NO_STATION_MODES */
+
++/* Enable TX power Setting functions
++ * (min att = -128 , max att = 127)
++ */
++
++#define RAW_TXPOWER_SETTING
++
+ /* Use Linux crypto API instead of own encryption implementation whenever
+ * possible. */
+ /* #define HOSTAP_USE_CRYPTO_API */
+diff -Naur hostap-driver-0.3.7/driver/modules/hostap_hw.c hostap-driver-0.3.7-patched/driver/modules/hostap_hw.c
+--- hostap-driver-0.3.7/driver/modules/hostap_hw.c 2005-02-05 09:20:09.000000000 +0200
++++ hostap-driver-0.3.7-patched/driver/modules/hostap_hw.c 2005-04-20 17:25:55.000000000 +0300
+@@ -1039,6 +1039,7 @@
+ dev->name, local->fragm_threshold);
+ }
+
++ hostap_restore_power(dev);
+ return res;
+ }
+
+diff -Naur hostap-driver-0.3.7/driver/modules/hostap_info.c hostap-driver-0.3.7-patched/driver/modules/hostap_info.c
+--- hostap-driver-0.3.7/driver/modules/hostap_info.c 2004-02-29 20:05:44.000000000 +0200
++++ hostap-driver-0.3.7-patched/driver/modules/hostap_info.c 2005-04-20 17:26:36.000000000 +0300
+@@ -418,6 +418,11 @@
+ }
+
+ /* Get BSSID if we have a valid AP address */
++
++ if ( val == HFA384X_LINKSTATUS_CONNECTED ||
++ val == HFA384X_LINKSTATUS_DISCONNECTED )
++ hostap_restore_power(local->dev);
++
+ if (connected) {
+ netif_carrier_on(local->dev);
+ netif_carrier_on(local->ddev);
+diff -Naur hostap-driver-0.3.7/driver/modules/hostap_ioctl.c hostap-driver-0.3.7-patched/driver/modules/hostap_ioctl.c
+--- hostap-driver-0.3.7/driver/modules/hostap_ioctl.c 2004-11-22 08:03:05.000000000 +0200
++++ hostap-driver-0.3.7-patched/driver/modules/hostap_ioctl.c 2005-04-20 17:42:41.000000000 +0300
+@@ -1453,23 +1453,20 @@
+ val = 255;
+
+ tmp = val;
+- tmp >>= 2;
+
+- return -12 - tmp;
++ return tmp;
+ }
+
+ static u16 prism2_txpower_dBm_to_hfa386x(int val)
+ {
+ signed char tmp;
+
+- if (val > 20)
+- return 128;
+- else if (val < -43)
++ if (val > 127)
+ return 127;
++ else if (val < -128)
++ return 128;
+
+ tmp = val;
+- tmp = -12 - tmp;
+- tmp <<= 2;
+
+ return (unsigned char) tmp;
+ }
diff --git a/package/system/hostap-driver/patches/001-fix-txpower.patch b/package/system/hostap-driver/patches/001-fix-txpower.patch
new file mode 100644
index 0000000..94ca344
--- /dev/null
+++ b/package/system/hostap-driver/patches/001-fix-txpower.patch
@@ -0,0 +1,175 @@
+diff -Naur hostap-driver-0.3.7/driver/modules/hostap.c hostap-driver-0.3.7-patched/driver/modules/hostap.c
+--- hostap-driver-0.3.7/driver/modules/hostap.c 2004-08-28 06:26:46.000000000 +0300
++++ hostap-driver-0.3.7-patched/driver/modules/hostap.c 2005-04-20 17:20:56.000000000 +0300
+@@ -1164,6 +1164,36 @@
+ return ret;
+ }
+
++/* BUG FIX: Restore power setting value when lost due to F/W bug */
++
++int hostap_restore_power(struct net_device *dev)
++{
++ struct hostap_interface *iface = dev->priv;
++ local_info_t *local = iface->local;
++
++ u16 val;
++ int ret = 0;
++
++ if (local->txpower_type == PRISM2_TXPOWER_OFF) {
++ val = 0xff; /* use all standby and sleep modes */
++ ret = local->func->cmd(dev, HFA384X_CMDCODE_WRITEMIF,
++ HFA386X_CR_A_D_TEST_MODES2,
++ &val, NULL);
++ }
++
++#ifdef RAW_TXPOWER_SETTING
++ if (local->txpower_type == PRISM2_TXPOWER_FIXED) {
++ val = HFA384X_TEST_CFG_BIT_ALC;
++ local->func->cmd(dev, HFA384X_CMDCODE_TEST |
++ (HFA384X_TEST_CFG_BITS << 8), 0, &val, NULL);
++ val = prism2_txpower_dBm_to_hfa386x(local->txpower);
++ ret = (local->func->cmd(dev, HFA384X_CMDCODE_WRITEMIF,
++ HFA386X_CR_MANUAL_TX_POWER, &val, NULL));
++ }
++#endif /* RAW_TXPOWER_SETTING */
++ return (ret ? -EOPNOTSUPP : 0);
++}
++
+
+ struct proc_dir_entry *hostap_proc;
+
+@@ -1214,6 +1244,7 @@
+ EXPORT_SYMBOL(hostap_set_hostapd_sta);
+ EXPORT_SYMBOL(hostap_add_interface);
+ EXPORT_SYMBOL(hostap_remove_interface);
++EXPORT_SYMBOL(hostap_restore_power);
+ EXPORT_SYMBOL(prism2_update_comms_qual);
+
+ module_init(hostap_init);
+diff -Naur hostap-driver-0.3.7/driver/modules/hostap.h hostap-driver-0.3.7-patched/driver/modules/hostap.h
+--- hostap-driver-0.3.7/driver/modules/hostap.h 2003-11-30 04:14:26.000000000 +0200
++++ hostap-driver-0.3.7-patched/driver/modules/hostap.h 2005-04-20 17:21:23.000000000 +0300
+@@ -36,6 +36,7 @@
+ const char *prefix, const char *name);
+ void hostap_remove_interface(struct net_device *dev, int rtnl_locked,
+ int remove_from_list);
++int hostap_restore_power(struct net_device *dev);
+ int prism2_update_comms_qual(struct net_device *dev);
+ int prism2_sta_send_mgmt(local_info_t *local, u8 *dst, u8 stype,
+ u8 *body, size_t bodylen);
+diff -Naur hostap-driver-0.3.7/driver/modules/hostap_ap.c hostap-driver-0.3.7-patched/driver/modules/hostap_ap.c
+--- hostap-driver-0.3.7/driver/modules/hostap_ap.c 2005-01-24 04:52:00.000000000 +0200
++++ hostap-driver-0.3.7-patched/driver/modules/hostap_ap.c 2005-04-21 20:06:12.000000000 +0300
+@@ -2346,13 +2346,13 @@
+ addr[count].sa_family = ARPHRD_ETHER;
+ memcpy(addr[count].sa_data, sta->addr, ETH_ALEN);
+ if (sta->last_rx_silence == 0)
+- qual[count].qual = sta->last_rx_signal < 27 ?
+- 0 : (sta->last_rx_signal - 27) * 92 / 127;
++ qual[count].qual = (sta->last_rx_signal - 156) == 0 ?
++ 0 : (sta->last_rx_signal - 156) * 92 / 64;
+ else
+- qual[count].qual = sta->last_rx_signal -
+- sta->last_rx_silence - 35;
+- qual[count].level = HFA384X_LEVEL_TO_dBm(sta->last_rx_signal);
+- qual[count].noise = HFA384X_LEVEL_TO_dBm(sta->last_rx_silence);
++ qual[count].qual = (sta->last_rx_signal -
++ sta->last_rx_silence) * 92 / 64;
++ qual[count].level = sta->last_rx_signal;
++ qual[count].noise = sta->last_rx_silence;
+ qual[count].updated = sta->last_rx_updated;
+
+ sta->last_rx_updated = 0;
+@@ -2413,13 +2413,13 @@
+ memset(&iwe, 0, sizeof(iwe));
+ iwe.cmd = IWEVQUAL;
+ if (sta->last_rx_silence == 0)
+- iwe.u.qual.qual = sta->last_rx_signal < 27 ?
+- 0 : (sta->last_rx_signal - 27) * 92 / 127;
++ iwe.u.qual.qual = (sta->last_rx_signal -156) == 0 ?
++ 0 : (sta->last_rx_signal - 156) * 92 / 64;
+ else
+- iwe.u.qual.qual = sta->last_rx_signal -
+- sta->last_rx_silence - 35;
+- iwe.u.qual.level = HFA384X_LEVEL_TO_dBm(sta->last_rx_signal);
+- iwe.u.qual.noise = HFA384X_LEVEL_TO_dBm(sta->last_rx_silence);
++ iwe.u.qual.qual = (sta->last_rx_signal -
++ sta->last_rx_silence) * 92 / 64;
++ iwe.u.qual.level = sta->last_rx_signal;
++ iwe.u.qual.noise = sta->last_rx_silence;
+ iwe.u.qual.updated = sta->last_rx_updated;
+ iwe.len = IW_EV_QUAL_LEN;
+ current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe,
+diff -Naur hostap-driver-0.3.7/driver/modules/hostap_config.h hostap-driver-0.3.7-patched/driver/modules/hostap_config.h
+--- hostap-driver-0.3.7/driver/modules/hostap_config.h 2005-02-12 18:12:56.000000000 +0200
++++ hostap-driver-0.3.7-patched/driver/modules/hostap_config.h 2005-04-20 17:25:23.000000000 +0300
+@@ -94,6 +94,12 @@
+ */
+ /* #define PRISM2_NO_STATION_MODES */
+
++/* Enable TX power Setting functions
++ * (min att = -128 , max att = 127)
++ */
++
++#define RAW_TXPOWER_SETTING
++
+ /* Use Linux crypto API instead of own encryption implementation whenever
+ * possible. */
+ /* #define HOSTAP_USE_CRYPTO_API */
+diff -Naur hostap-driver-0.3.7/driver/modules/hostap_hw.c hostap-driver-0.3.7-patched/driver/modules/hostap_hw.c
+--- hostap-driver-0.3.7/driver/modules/hostap_hw.c 2005-02-05 09:20:09.000000000 +0200
++++ hostap-driver-0.3.7-patched/driver/modules/hostap_hw.c 2005-04-20 17:25:55.000000000 +0300
+@@ -1039,6 +1039,7 @@
+ dev->name, local->fragm_threshold);
+ }
+
++ hostap_restore_power(dev);
+ return res;
+ }
+
+diff -Naur hostap-driver-0.3.7/driver/modules/hostap_info.c hostap-driver-0.3.7-patched/driver/modules/hostap_info.c
+--- hostap-driver-0.3.7/driver/modules/hostap_info.c 2004-02-29 20:05:44.000000000 +0200
++++ hostap-driver-0.3.7-patched/driver/modules/hostap_info.c 2005-04-20 17:26:36.000000000 +0300
+@@ -418,6 +418,11 @@
+ }
+
+ /* Get BSSID if we have a valid AP address */
++
++ if ( val == HFA384X_LINKSTATUS_CONNECTED ||
++ val == HFA384X_LINKSTATUS_DISCONNECTED )
++ hostap_restore_power(local->dev);
++
+ if (connected) {
+ netif_carrier_on(local->dev);
+ netif_carrier_on(local->ddev);
+diff -Naur hostap-driver-0.3.7/driver/modules/hostap_ioctl.c hostap-driver-0.3.7-patched/driver/modules/hostap_ioctl.c
+--- hostap-driver-0.3.7/driver/modules/hostap_ioctl.c 2004-11-22 08:03:05.000000000 +0200
++++ hostap-driver-0.3.7-patched/driver/modules/hostap_ioctl.c 2005-04-20 17:42:41.000000000 +0300
+@@ -1453,23 +1453,20 @@
+ val = 255;
+
+ tmp = val;
+- tmp >>= 2;
+
+- return -12 - tmp;
++ return tmp;
+ }
+
+ static u16 prism2_txpower_dBm_to_hfa386x(int val)
+ {
+ signed char tmp;
+
+- if (val > 20)
+- return 128;
+- else if (val < -43)
++ if (val > 127)
+ return 127;
++ else if (val < -128)
++ return 128;
+
+ tmp = val;
+- tmp = -12 - tmp;
+- tmp <<= 2;
+
+ return (unsigned char) tmp;
+ }
diff --git a/package/system/i2c-gpio-custom/.svn/entries b/package/system/i2c-gpio-custom/.svn/entries
new file mode 100644
index 0000000..8f47fc5
--- /dev/null
+++ b/package/system/i2c-gpio-custom/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/system/i2c-gpio-custom
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+src
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+aa2b03b764978c7d2e21c11f8280ae3c
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1240
+
diff --git a/package/system/i2c-gpio-custom/.svn/prop-base/Makefile.svn-base b/package/system/i2c-gpio-custom/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/system/i2c-gpio-custom/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/system/i2c-gpio-custom/.svn/text-base/Makefile.svn-base b/package/system/i2c-gpio-custom/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..8585a5a
--- /dev/null
+++ b/package/system/i2c-gpio-custom/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,53 @@
+#
+# Copyright (C) 2008 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=i2c-gpio-custom
+PKG_RELEASE:=2
+
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/i2c-gpio-custom
+ SUBMENU:=I2C support
+ TITLE:=Custom GPIO-based I2C device
+ DEPENDS:=@GPIO_SUPPORT +kmod-i2c-core +kmod-i2c-gpio
+ FILES:=$(PKG_BUILD_DIR)/i2c-gpio-custom.ko
+ KCONFIG:=
+endef
+
+define KernelPackage/i2c-gpio-custom/description
+ Kernel module for register a custom i2c-gpio platform device.
+endef
+
+EXTRA_KCONFIG:= \
+ CONFIG_I2C_GPIO_CUSTOM=m
+
+EXTRA_CFLAGS:= \
+ $(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=m,%,$(filter %=m,$(EXTRA_KCONFIG)))) \
+ $(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=y,%,$(filter %=y,$(EXTRA_KCONFIG)))) \
+
+MAKE_OPTS:= \
+ ARCH="$(LINUX_KARCH)" \
+ CROSS_COMPILE="$(TARGET_CROSS)" \
+ SUBDIRS="$(PKG_BUILD_DIR)" \
+ EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \
+ $(EXTRA_KCONFIG)
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+define Build/Compile
+ $(MAKE) -C "$(LINUX_DIR)" \
+ $(MAKE_OPTS) \
+ modules
+endef
+
+$(eval $(call KernelPackage,i2c-gpio-custom))
diff --git a/package/system/i2c-gpio-custom/Makefile b/package/system/i2c-gpio-custom/Makefile
new file mode 100644
index 0000000..8585a5a
--- /dev/null
+++ b/package/system/i2c-gpio-custom/Makefile
@@ -0,0 +1,53 @@
+#
+# Copyright (C) 2008 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=i2c-gpio-custom
+PKG_RELEASE:=2
+
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/i2c-gpio-custom
+ SUBMENU:=I2C support
+ TITLE:=Custom GPIO-based I2C device
+ DEPENDS:=@GPIO_SUPPORT +kmod-i2c-core +kmod-i2c-gpio
+ FILES:=$(PKG_BUILD_DIR)/i2c-gpio-custom.ko
+ KCONFIG:=
+endef
+
+define KernelPackage/i2c-gpio-custom/description
+ Kernel module for register a custom i2c-gpio platform device.
+endef
+
+EXTRA_KCONFIG:= \
+ CONFIG_I2C_GPIO_CUSTOM=m
+
+EXTRA_CFLAGS:= \
+ $(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=m,%,$(filter %=m,$(EXTRA_KCONFIG)))) \
+ $(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=y,%,$(filter %=y,$(EXTRA_KCONFIG)))) \
+
+MAKE_OPTS:= \
+ ARCH="$(LINUX_KARCH)" \
+ CROSS_COMPILE="$(TARGET_CROSS)" \
+ SUBDIRS="$(PKG_BUILD_DIR)" \
+ EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \
+ $(EXTRA_KCONFIG)
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+define Build/Compile
+ $(MAKE) -C "$(LINUX_DIR)" \
+ $(MAKE_OPTS) \
+ modules
+endef
+
+$(eval $(call KernelPackage,i2c-gpio-custom))
diff --git a/package/system/i2c-gpio-custom/src/.svn/entries b/package/system/i2c-gpio-custom/src/.svn/entries
new file mode 100644
index 0000000..d8c9110
--- /dev/null
+++ b/package/system/i2c-gpio-custom/src/.svn/entries
@@ -0,0 +1,130 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/system/i2c-gpio-custom/src
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+Kconfig
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+64b7bc91d43aa394fb19fb44c7bdacb3
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+296
+
+i2c-gpio-custom.c
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+51399b920dc8ac4d36754b6841ba7388
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5050
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+8823a9c4db1f2c88ce8e6e0290b1a374
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+50
+
diff --git a/package/system/i2c-gpio-custom/src/.svn/prop-base/Makefile.svn-base b/package/system/i2c-gpio-custom/src/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/system/i2c-gpio-custom/src/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/system/i2c-gpio-custom/src/.svn/prop-base/i2c-gpio-custom.c.svn-base b/package/system/i2c-gpio-custom/src/.svn/prop-base/i2c-gpio-custom.c.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/system/i2c-gpio-custom/src/.svn/prop-base/i2c-gpio-custom.c.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/system/i2c-gpio-custom/src/.svn/text-base/Kconfig.svn-base b/package/system/i2c-gpio-custom/src/.svn/text-base/Kconfig.svn-base
new file mode 100644
index 0000000..e2e3a68
--- /dev/null
+++ b/package/system/i2c-gpio-custom/src/.svn/text-base/Kconfig.svn-base
@@ -0,0 +1,10 @@
+config I2C_GPIO_CUSTOM
+ tristate "Custom GPIO-based I2C driver"
+ depends on GENERIC_GPIO
+ select I2C_GPIO
+ help
+ This is an I2C driver to register 1 to 4 custom I2C buses using
+ GPIO lines.
+
+ This support is also available as a module. If so, the module
+ will be called i2c-gpio-custom.
diff --git a/package/system/i2c-gpio-custom/src/.svn/text-base/Makefile.svn-base b/package/system/i2c-gpio-custom/src/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..dcb2e2a
--- /dev/null
+++ b/package/system/i2c-gpio-custom/src/.svn/text-base/Makefile.svn-base
@@ -0,0 +1 @@
+obj-${CONFIG_I2C_GPIO_CUSTOM} += i2c-gpio-custom.o \ No newline at end of file
diff --git a/package/system/i2c-gpio-custom/src/.svn/text-base/i2c-gpio-custom.c.svn-base b/package/system/i2c-gpio-custom/src/.svn/text-base/i2c-gpio-custom.c.svn-base
new file mode 100644
index 0000000..76ab5f3
--- /dev/null
+++ b/package/system/i2c-gpio-custom/src/.svn/text-base/i2c-gpio-custom.c.svn-base
@@ -0,0 +1,198 @@
+/*
+ * Custom GPIO-based I2C driver
+ *
+ * Copyright (C) 2007-2008 Gabor Juhos <juhosg@openwrt.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * ---------------------------------------------------------------------------
+ *
+ * The behaviour of this driver can be altered by setting some parameters
+ * from the insmod command line.
+ *
+ * The following parameters are adjustable:
+ *
+ * bus0 These four arguments can be arrays of
+ * bus1 1-8 unsigned integers as follows:
+ * bus2
+ * bus3 <id>,<sda>,<scl>,<udelay>,<timeout>,<sda_od>,<scl_od>,<scl_oo>
+ *
+ * where:
+ *
+ * <id> ID to used as device_id for the corresponding bus (required)
+ * <sda> GPIO pin ID to used for SDA (required)
+ * <scl> GPIO pin ID to used for SCL (required)
+ * <udelay> signal toggle delay.
+ * <timeout> clock stretching timeout.
+ * <sda_od> SDA is configured as open drain.
+ * <scl_od> SCL is configured as open drain.
+ * <scl_oo> SCL output drivers cannot be turned off.
+ *
+ * See include/i2c-gpio.h for more information about the parameters.
+ *
+ * If this driver is built into the kernel, you can use the following kernel
+ * command line parameters, with the same values as the corresponding module
+ * parameters listed above:
+ *
+ * i2c-gpio-custom.bus0
+ * i2c-gpio-custom.bus1
+ * i2c-gpio-custom.bus2
+ * i2c-gpio-custom.bus3
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+
+#include <linux/i2c-gpio.h>
+
+#define DRV_NAME "i2c-gpio-custom"
+#define DRV_DESC "Custom GPIO-based I2C driver"
+#define DRV_VERSION "0.1.1"
+
+#define PFX DRV_NAME ": "
+
+#define BUS_PARAM_ID 0
+#define BUS_PARAM_SDA 1
+#define BUS_PARAM_SCL 2
+#define BUS_PARAM_UDELAY 3
+#define BUS_PARAM_TIMEOUT 4
+#define BUS_PARAM_SDA_OD 5
+#define BUS_PARAM_SCL_OD 6
+#define BUS_PARAM_SCL_OO 7
+
+#define BUS_PARAM_REQUIRED 3
+#define BUS_PARAM_COUNT 8
+#define BUS_COUNT_MAX 4
+
+static unsigned int bus0[BUS_PARAM_COUNT] __initdata;
+static unsigned int bus1[BUS_PARAM_COUNT] __initdata;
+static unsigned int bus2[BUS_PARAM_COUNT] __initdata;
+static unsigned int bus3[BUS_PARAM_COUNT] __initdata;
+
+static unsigned int bus_nump[BUS_COUNT_MAX] __initdata;
+
+#define BUS_PARM_DESC \
+ " config -> id,sda,scl[,udelay,timeout,sda_od,scl_od,scl_oo]"
+
+module_param_array(bus0, uint, &bus_nump[0], 0);
+MODULE_PARM_DESC(bus0, "bus0" BUS_PARM_DESC);
+module_param_array(bus1, uint, &bus_nump[1], 0);
+MODULE_PARM_DESC(bus1, "bus1" BUS_PARM_DESC);
+module_param_array(bus2, uint, &bus_nump[2], 0);
+MODULE_PARM_DESC(bus2, "bus2" BUS_PARM_DESC);
+module_param_array(bus3, uint, &bus_nump[3], 0);
+MODULE_PARM_DESC(bus3, "bus3" BUS_PARM_DESC);
+
+static struct platform_device *devices[BUS_COUNT_MAX];
+static unsigned int nr_devices;
+
+static void i2c_gpio_custom_cleanup(void)
+{
+ int i;
+
+ for (i = 0; i < nr_devices; i++)
+ if (devices[i])
+ platform_device_put(devices[i]);
+}
+
+static int __init i2c_gpio_custom_add_one(unsigned int id, unsigned int *params)
+{
+ struct platform_device *pdev;
+ struct i2c_gpio_platform_data pdata;
+ int err;
+
+ if (!bus_nump[id])
+ return 0;
+
+ if (bus_nump[id] < BUS_PARAM_REQUIRED) {
+ printk(KERN_ERR PFX "not enough parameters for bus%d\n", id);
+ err = -EINVAL;
+ goto err;
+ }
+
+ pdev = platform_device_alloc("i2c-gpio", params[BUS_PARAM_ID]);
+ if (!pdev) {
+ err = -ENOMEM;
+ goto err;
+ }
+
+ pdata.sda_pin = params[BUS_PARAM_SDA];
+ pdata.scl_pin = params[BUS_PARAM_SCL];
+ pdata.udelay = params[BUS_PARAM_UDELAY];
+ pdata.timeout = params[BUS_PARAM_TIMEOUT];
+ pdata.sda_is_open_drain = params[BUS_PARAM_SDA_OD] != 0;
+ pdata.scl_is_open_drain = params[BUS_PARAM_SCL_OD] != 0;
+ pdata.scl_is_output_only = params[BUS_PARAM_SCL_OO] != 0;
+
+ err = platform_device_add_data(pdev, &pdata, sizeof(pdata));
+ if (err)
+ goto err_put;
+
+ err = platform_device_add(pdev);
+ if (err)
+ goto err_put;
+
+ devices[nr_devices++] = pdev;
+ return 0;
+
+err_put:
+ platform_device_put(pdev);
+err:
+ return err;
+}
+
+static int __init i2c_gpio_custom_probe(void)
+{
+ int err;
+
+ printk(KERN_INFO DRV_DESC " version " DRV_VERSION "\n");
+
+ err = i2c_gpio_custom_add_one(0, bus0);
+ if (err) goto err;
+
+ err = i2c_gpio_custom_add_one(1, bus1);
+ if (err) goto err;
+
+ err = i2c_gpio_custom_add_one(2, bus2);
+ if (err) goto err;
+
+ err = i2c_gpio_custom_add_one(3, bus3);
+ if (err) goto err;
+
+ if (!nr_devices) {
+ printk(KERN_ERR PFX "no bus parameter(s) specified\n");
+ err = -ENODEV;
+ goto err;
+ }
+
+ return 0;
+
+err:
+ i2c_gpio_custom_cleanup();
+ return err;
+}
+
+#ifdef MODULE
+static int __init i2c_gpio_custom_init(void)
+{
+ return i2c_gpio_custom_probe();
+}
+module_init(i2c_gpio_custom_init);
+
+static void __exit i2c_gpio_custom_exit(void)
+{
+ i2c_gpio_custom_cleanup();
+}
+module_exit(i2c_gpio_custom_exit);
+#else
+subsys_initcall(i2c_gpio_custom_probe);
+#endif /* MODULE*/
+
+MODULE_LICENSE("GPL v2");
+MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org >");
+MODULE_DESCRIPTION(DRV_DESC);
+MODULE_VERSION(DRV_VERSION);
diff --git a/package/system/i2c-gpio-custom/src/Kconfig b/package/system/i2c-gpio-custom/src/Kconfig
new file mode 100644
index 0000000..e2e3a68
--- /dev/null
+++ b/package/system/i2c-gpio-custom/src/Kconfig
@@ -0,0 +1,10 @@
+config I2C_GPIO_CUSTOM
+ tristate "Custom GPIO-based I2C driver"
+ depends on GENERIC_GPIO
+ select I2C_GPIO
+ help
+ This is an I2C driver to register 1 to 4 custom I2C buses using
+ GPIO lines.
+
+ This support is also available as a module. If so, the module
+ will be called i2c-gpio-custom.
diff --git a/package/system/i2c-gpio-custom/src/Makefile b/package/system/i2c-gpio-custom/src/Makefile
new file mode 100644
index 0000000..dcb2e2a
--- /dev/null
+++ b/package/system/i2c-gpio-custom/src/Makefile
@@ -0,0 +1 @@
+obj-${CONFIG_I2C_GPIO_CUSTOM} += i2c-gpio-custom.o \ No newline at end of file
diff --git a/package/system/i2c-gpio-custom/src/i2c-gpio-custom.c b/package/system/i2c-gpio-custom/src/i2c-gpio-custom.c
new file mode 100644
index 0000000..76ab5f3
--- /dev/null
+++ b/package/system/i2c-gpio-custom/src/i2c-gpio-custom.c
@@ -0,0 +1,198 @@
+/*
+ * Custom GPIO-based I2C driver
+ *
+ * Copyright (C) 2007-2008 Gabor Juhos <juhosg@openwrt.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * ---------------------------------------------------------------------------
+ *
+ * The behaviour of this driver can be altered by setting some parameters
+ * from the insmod command line.
+ *
+ * The following parameters are adjustable:
+ *
+ * bus0 These four arguments can be arrays of
+ * bus1 1-8 unsigned integers as follows:
+ * bus2
+ * bus3 <id>,<sda>,<scl>,<udelay>,<timeout>,<sda_od>,<scl_od>,<scl_oo>
+ *
+ * where:
+ *
+ * <id> ID to used as device_id for the corresponding bus (required)
+ * <sda> GPIO pin ID to used for SDA (required)
+ * <scl> GPIO pin ID to used for SCL (required)
+ * <udelay> signal toggle delay.
+ * <timeout> clock stretching timeout.
+ * <sda_od> SDA is configured as open drain.
+ * <scl_od> SCL is configured as open drain.
+ * <scl_oo> SCL output drivers cannot be turned off.
+ *
+ * See include/i2c-gpio.h for more information about the parameters.
+ *
+ * If this driver is built into the kernel, you can use the following kernel
+ * command line parameters, with the same values as the corresponding module
+ * parameters listed above:
+ *
+ * i2c-gpio-custom.bus0
+ * i2c-gpio-custom.bus1
+ * i2c-gpio-custom.bus2
+ * i2c-gpio-custom.bus3
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+
+#include <linux/i2c-gpio.h>
+
+#define DRV_NAME "i2c-gpio-custom"
+#define DRV_DESC "Custom GPIO-based I2C driver"
+#define DRV_VERSION "0.1.1"
+
+#define PFX DRV_NAME ": "
+
+#define BUS_PARAM_ID 0
+#define BUS_PARAM_SDA 1
+#define BUS_PARAM_SCL 2
+#define BUS_PARAM_UDELAY 3
+#define BUS_PARAM_TIMEOUT 4
+#define BUS_PARAM_SDA_OD 5
+#define BUS_PARAM_SCL_OD 6
+#define BUS_PARAM_SCL_OO 7
+
+#define BUS_PARAM_REQUIRED 3
+#define BUS_PARAM_COUNT 8
+#define BUS_COUNT_MAX 4
+
+static unsigned int bus0[BUS_PARAM_COUNT] __initdata;
+static unsigned int bus1[BUS_PARAM_COUNT] __initdata;
+static unsigned int bus2[BUS_PARAM_COUNT] __initdata;
+static unsigned int bus3[BUS_PARAM_COUNT] __initdata;
+
+static unsigned int bus_nump[BUS_COUNT_MAX] __initdata;
+
+#define BUS_PARM_DESC \
+ " config -> id,sda,scl[,udelay,timeout,sda_od,scl_od,scl_oo]"
+
+module_param_array(bus0, uint, &bus_nump[0], 0);
+MODULE_PARM_DESC(bus0, "bus0" BUS_PARM_DESC);
+module_param_array(bus1, uint, &bus_nump[1], 0);
+MODULE_PARM_DESC(bus1, "bus1" BUS_PARM_DESC);
+module_param_array(bus2, uint, &bus_nump[2], 0);
+MODULE_PARM_DESC(bus2, "bus2" BUS_PARM_DESC);
+module_param_array(bus3, uint, &bus_nump[3], 0);
+MODULE_PARM_DESC(bus3, "bus3" BUS_PARM_DESC);
+
+static struct platform_device *devices[BUS_COUNT_MAX];
+static unsigned int nr_devices;
+
+static void i2c_gpio_custom_cleanup(void)
+{
+ int i;
+
+ for (i = 0; i < nr_devices; i++)
+ if (devices[i])
+ platform_device_put(devices[i]);
+}
+
+static int __init i2c_gpio_custom_add_one(unsigned int id, unsigned int *params)
+{
+ struct platform_device *pdev;
+ struct i2c_gpio_platform_data pdata;
+ int err;
+
+ if (!bus_nump[id])
+ return 0;
+
+ if (bus_nump[id] < BUS_PARAM_REQUIRED) {
+ printk(KERN_ERR PFX "not enough parameters for bus%d\n", id);
+ err = -EINVAL;
+ goto err;
+ }
+
+ pdev = platform_device_alloc("i2c-gpio", params[BUS_PARAM_ID]);
+ if (!pdev) {
+ err = -ENOMEM;
+ goto err;
+ }
+
+ pdata.sda_pin = params[BUS_PARAM_SDA];
+ pdata.scl_pin = params[BUS_PARAM_SCL];
+ pdata.udelay = params[BUS_PARAM_UDELAY];
+ pdata.timeout = params[BUS_PARAM_TIMEOUT];
+ pdata.sda_is_open_drain = params[BUS_PARAM_SDA_OD] != 0;
+ pdata.scl_is_open_drain = params[BUS_PARAM_SCL_OD] != 0;
+ pdata.scl_is_output_only = params[BUS_PARAM_SCL_OO] != 0;
+
+ err = platform_device_add_data(pdev, &pdata, sizeof(pdata));
+ if (err)
+ goto err_put;
+
+ err = platform_device_add(pdev);
+ if (err)
+ goto err_put;
+
+ devices[nr_devices++] = pdev;
+ return 0;
+
+err_put:
+ platform_device_put(pdev);
+err:
+ return err;
+}
+
+static int __init i2c_gpio_custom_probe(void)
+{
+ int err;
+
+ printk(KERN_INFO DRV_DESC " version " DRV_VERSION "\n");
+
+ err = i2c_gpio_custom_add_one(0, bus0);
+ if (err) goto err;
+
+ err = i2c_gpio_custom_add_one(1, bus1);
+ if (err) goto err;
+
+ err = i2c_gpio_custom_add_one(2, bus2);
+ if (err) goto err;
+
+ err = i2c_gpio_custom_add_one(3, bus3);
+ if (err) goto err;
+
+ if (!nr_devices) {
+ printk(KERN_ERR PFX "no bus parameter(s) specified\n");
+ err = -ENODEV;
+ goto err;
+ }
+
+ return 0;
+
+err:
+ i2c_gpio_custom_cleanup();
+ return err;
+}
+
+#ifdef MODULE
+static int __init i2c_gpio_custom_init(void)
+{
+ return i2c_gpio_custom_probe();
+}
+module_init(i2c_gpio_custom_init);
+
+static void __exit i2c_gpio_custom_exit(void)
+{
+ i2c_gpio_custom_cleanup();
+}
+module_exit(i2c_gpio_custom_exit);
+#else
+subsys_initcall(i2c_gpio_custom_probe);
+#endif /* MODULE*/
+
+MODULE_LICENSE("GPL v2");
+MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org >");
+MODULE_DESCRIPTION(DRV_DESC);
+MODULE_VERSION(DRV_VERSION);
diff --git a/package/system/ixp4xx-microcode/.svn/entries b/package/system/ixp4xx-microcode/.svn/entries
new file mode 100644
index 0000000..b23001b
--- /dev/null
+++ b/package/system/ixp4xx-microcode/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/system/ixp4xx-microcode
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+src
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+c514bce8daef031870bceff6885c36a1
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1634
+
diff --git a/package/system/ixp4xx-microcode/.svn/text-base/Makefile.svn-base b/package/system/ixp4xx-microcode/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..52b44f3
--- /dev/null
+++ b/package/system/ixp4xx-microcode/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,57 @@
+#
+# Copyright (C) 2007 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=ixp4xx-microcode
+PKG_VERSION:=2.4
+PKG_RELEASE:=2
+
+PKG_SOURCE:=IPL_ixp400NpeLibraryWithCrypto-2_4.zip
+PKG_SOURCE_URL:=http://downloads.openwrt.org/sources
+PKG_MD5SUM:=dd5f6482e625ecb334469958bcd54b37
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/ixp4xx-microcode
+ SECTION:=net
+ CATEGORY:=Network
+ TITLE:=Microcode for the IXP4xx network engines
+ DEPENDS:=@TARGET_ixp4xx
+endef
+
+define Package/ixp4xx-microcode/description
+ This package contains the microcode needed to use the network engines in IXP4xx CPUs
+endef
+
+define Build/Prepare
+ rm -rf $(PKG_BUILD_DIR)
+ mkdir -p $(PKG_BUILD_DIR)
+ unzip -d $(PKG_BUILD_DIR)/ $(DL_DIR)/$(PKG_SOURCE)
+ mv $(PKG_BUILD_DIR)/ixp400_xscale_sw/src/npeDl/IxNpeMicrocode.c $(PKG_BUILD_DIR)/
+ rm -rf $(PKG_BUILD_DIR)/ixp400_xscale_sw
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+define Build/Compile
+ (cd $(PKG_BUILD_DIR); \
+ $(HOSTCC) -Wall -I$(STAGING_DIR_HOST)/include IxNpeMicrocode.c -o IxNpeMicrocode; \
+ ./IxNpeMicrocode -be \
+ )
+endef
+
+define Package/ixp4xx-microcode/install
+ $(INSTALL_DIR) $(1)/lib/firmware
+ $(INSTALL_DIR) $(1)/usr/share/doc
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/NPE-A $(1)/lib/firmware/
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/NPE-A-HSS $(1)/lib/firmware/
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/NPE-B $(1)/lib/firmware/
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/NPE-C $(1)/lib/firmware/
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/LICENSE.IPL $(1)/usr/share/doc/
+endef
+
+$(eval $(call BuildPackage,ixp4xx-microcode))
diff --git a/package/system/ixp4xx-microcode/Makefile b/package/system/ixp4xx-microcode/Makefile
new file mode 100644
index 0000000..52b44f3
--- /dev/null
+++ b/package/system/ixp4xx-microcode/Makefile
@@ -0,0 +1,57 @@
+#
+# Copyright (C) 2007 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=ixp4xx-microcode
+PKG_VERSION:=2.4
+PKG_RELEASE:=2
+
+PKG_SOURCE:=IPL_ixp400NpeLibraryWithCrypto-2_4.zip
+PKG_SOURCE_URL:=http://downloads.openwrt.org/sources
+PKG_MD5SUM:=dd5f6482e625ecb334469958bcd54b37
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/ixp4xx-microcode
+ SECTION:=net
+ CATEGORY:=Network
+ TITLE:=Microcode for the IXP4xx network engines
+ DEPENDS:=@TARGET_ixp4xx
+endef
+
+define Package/ixp4xx-microcode/description
+ This package contains the microcode needed to use the network engines in IXP4xx CPUs
+endef
+
+define Build/Prepare
+ rm -rf $(PKG_BUILD_DIR)
+ mkdir -p $(PKG_BUILD_DIR)
+ unzip -d $(PKG_BUILD_DIR)/ $(DL_DIR)/$(PKG_SOURCE)
+ mv $(PKG_BUILD_DIR)/ixp400_xscale_sw/src/npeDl/IxNpeMicrocode.c $(PKG_BUILD_DIR)/
+ rm -rf $(PKG_BUILD_DIR)/ixp400_xscale_sw
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+define Build/Compile
+ (cd $(PKG_BUILD_DIR); \
+ $(HOSTCC) -Wall -I$(STAGING_DIR_HOST)/include IxNpeMicrocode.c -o IxNpeMicrocode; \
+ ./IxNpeMicrocode -be \
+ )
+endef
+
+define Package/ixp4xx-microcode/install
+ $(INSTALL_DIR) $(1)/lib/firmware
+ $(INSTALL_DIR) $(1)/usr/share/doc
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/NPE-A $(1)/lib/firmware/
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/NPE-A-HSS $(1)/lib/firmware/
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/NPE-B $(1)/lib/firmware/
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/NPE-C $(1)/lib/firmware/
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/LICENSE.IPL $(1)/usr/share/doc/
+endef
+
+$(eval $(call BuildPackage,ixp4xx-microcode))
diff --git a/package/system/ixp4xx-microcode/src/.svn/entries b/package/system/ixp4xx-microcode/src/.svn/entries
new file mode 100644
index 0000000..4afd14c
--- /dev/null
+++ b/package/system/ixp4xx-microcode/src/.svn/entries
@@ -0,0 +1,96 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/system/ixp4xx-microcode/src
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+LICENSE.IPL
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+14c77d6b4f43db3498a508070fa816bb
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1893
+
+IxNpeMicrocode.h
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+2810ed63f6f0c7f9b103aeda9c137528
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4767
+
diff --git a/package/system/ixp4xx-microcode/src/.svn/text-base/IxNpeMicrocode.h.svn-base b/package/system/ixp4xx-microcode/src/.svn/text-base/IxNpeMicrocode.h.svn-base
new file mode 100644
index 0000000..4a843db
--- /dev/null
+++ b/package/system/ixp4xx-microcode/src/.svn/text-base/IxNpeMicrocode.h.svn-base
@@ -0,0 +1,148 @@
+/*
+ * IxNpeMicrocode.h - Headerfile for compiling the Intel microcode C file
+ *
+ * Copyright (C) 2006 Christian Hohnstaedt <chohnstaedt@innominate.com>
+ *
+ * This file is released under the GPLv2
+ *
+ *
+ * compile with
+ *
+ * gcc -Wall IxNpeMicrocode.c -o IxNpeMicrocode
+ *
+ * Executing the resulting binary on your build-host creates the
+ * "NPE-[ABC].xxxxxxxx" files containing the selected microcode
+ *
+ * fetch the IxNpeMicrocode.c from the Intel Access Library.
+ * It will include this header.
+ *
+ * select Images for every NPE from the following
+ * (used C++ comments for easy uncommenting ....)
+ */
+
+// #define IX_NPEDL_NPEIMAGE_NPEA_ETH_SPAN_MASK_FIREWALL_VLAN_QOS_HDR_CONV_EXTMIB
+// #define IX_NPEDL_NPEIMAGE_NPEA_ETH_SPAN_VLAN_QOS_HDR_CONV_EXTMIB
+// #define IX_NPEDL_NPEIMAGE_NPEA_ETH_LEARN_FILTER_SPAN_MASK_FIREWALL_VLAN_QOS_EXTMIB
+// #define IX_NPEDL_NPEIMAGE_NPEA_HSS_TSLOT_SWITCH
+#define IX_NPEDL_NPEIMAGE_NPEA_ETH_SPAN_FIREWALL_VLAN_QOS_HDR_CONV
+// #define IX_NPEDL_NPEIMAGE_NPEA_ETH_LEARN_FILTER_SPAN_FIREWALL_VLAN_QOS
+// #define IX_NPEDL_NPEIMAGE_NPEA_ETH_LEARN_FILTER_SPAN_FIREWALL
+#define IX_NPEDL_NPEIMAGE_NPEA_HSS_2_PORT
+// #define IX_NPEDL_NPEIMAGE_NPEA_DMA
+// #define IX_NPEDL_NPEIMAGE_NPEA_ATM_MPHY_12_PORT
+// #define IX_NPEDL_NPEIMAGE_NPEA_HSS0_ATM_MPHY_1_PORT
+// #define IX_NPEDL_NPEIMAGE_NPEA_HSS0_ATM_SPHY_1_PORT
+// #define IX_NPEDL_NPEIMAGE_NPEA_HSS0
+// #define IX_NPEDL_NPEIMAGE_NPEA_WEP
+
+
+// #define IX_NPEDL_NPEIMAGE_NPEB_ETH_SPAN_MASK_FIREWALL_VLAN_QOS_HDR_CONV_EXTMIB
+// #define IX_NPEDL_NPEIMAGE_NPEB_ETH_SPAN_VLAN_QOS_HDR_CONV_EXTMIB
+// #define IX_NPEDL_NPEIMAGE_NPEB_ETH_LEARN_FILTER_SPAN_MASK_FIREWALL_VLAN_QOS_EXTMIB
+// #define IX_NPEDL_NPEIMAGE_NPEB_DMA
+#define IX_NPEDL_NPEIMAGE_NPEB_ETH_SPAN_FIREWALL_VLAN_QOS_HDR_CONV
+// #define IX_NPEDL_NPEIMAGE_NPEB_ETH_LEARN_FILTER_SPAN_FIREWALL_VLAN_QOS
+// #define IX_NPEDL_NPEIMAGE_NPEB_ETH_LEARN_FILTER_SPAN_FIREWALL
+
+
+// #define IX_NPEDL_NPEIMAGE_NPEC_ETH_SPAN_MASK_FIREWALL_VLAN_QOS_HDR_CONV_EXTMIB
+// #define IX_NPEDL_NPEIMAGE_NPEC_ETH_SPAN_VLAN_QOS_HDR_CONV_EXTMIB
+// #define IX_NPEDL_NPEIMAGE_NPEC_ETH_LEARN_FILTER_SPAN_MASK_FIREWALL_VLAN_QOS_EXTMIB
+// #define IX_NPEDL_NPEIMAGE_NPEC_DMA
+// #define IX_NPEDL_NPEIMAGE_NPEC_CRYPTO_AES_ETH_LEARN_FILTER_SPAN
+// #define IX_NPEDL_NPEIMAGE_NPEC_CRYPTO_AES_ETH_LEARN_FILTER_FIREWALL
+#define IX_NPEDL_NPEIMAGE_NPEC_CRYPTO_AES_CCM_ETH
+// #define IX_NPEDL_NPEIMAGE_NPEC_CRYPTO_AES_CCM_EXTSHA_ETH
+// #define IX_NPEDL_NPEIMAGE_NPEC_CRYPTO_ETH_LEARN_FILTER_SPAN_FIREWALL
+// #define IX_NPEDL_NPEIMAGE_NPEC_ETH_SPAN_FIREWALL_VLAN_QOS_HDR_CONV
+// #define IX_NPEDL_NPEIMAGE_NPEC_ETH_LEARN_FILTER_SPAN_FIREWALL_VLAN_QOS
+// #define IX_NPEDL_NPEIMAGE_NPEC_ETH_LEARN_FILTER_SPAN_FIREWALL
+
+
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <netinet/in.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <endian.h>
+#include <byteswap.h>
+#include <string.h>
+
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+#define to_le32(x) (x)
+#define to_be32(x) bswap_32(x)
+#else
+#define to_be32(x) (x)
+#define to_le32(x) bswap_32(x)
+#endif
+
+struct dl_image {
+ unsigned magic;
+ unsigned id;
+ unsigned size;
+ unsigned data[0];
+};
+
+const unsigned IxNpeMicrocode_array[];
+
+int main(int argc, char *argv[])
+{
+ struct dl_image *image = (struct dl_image *)IxNpeMicrocode_array;
+ int imgsiz, i, fd, cnt;
+ const unsigned *arrayptr = IxNpeMicrocode_array;
+ const char *names[] = { "IXP425", "IXP465", "unknown" };
+ int bigendian = 1;
+
+ if (argc > 1) {
+ if (!strcmp(argv[1], "-le"))
+ bigendian = 0;
+ else if (!strcmp(argv[1], "-be"))
+ bigendian = 1;
+ else {
+ printf("Usage: %s <-le|-be>\n", argv[0]);
+ return EXIT_FAILURE;
+ }
+ }
+
+ for (image = (struct dl_image *)arrayptr, cnt=0;
+ (image->id != 0xfeedf00d) && (image->magic == 0xfeedf00d);
+ image = (struct dl_image *)(arrayptr), cnt++)
+ {
+ unsigned char field[4];
+ imgsiz = image->size + 3;
+ *(unsigned*)field = to_be32(image->id);
+ char filename[40], slnk[10];
+
+ sprintf(filename, "NPE-%c.%08x", (field[0] & 0xf) + 'A',
+ image->id);
+ if (image->id == 0x00090000)
+ sprintf(slnk, "NPE-%c-HSS", (field[0] & 0xf) + 'A');
+ else
+ sprintf(slnk, "NPE-%c", (field[0] & 0xf) + 'A');
+
+ printf("Writing image: %s.NPE_%c Func: %2x Rev: %02x.%02x "
+ "Size: %5d to: '%s'\n",
+ names[field[0] >> 4], (field[0] & 0xf) + 'A',
+ field[1], field[2], field[3], imgsiz*4, filename);
+ fd = open(filename, O_CREAT | O_RDWR | O_TRUNC, 0644);
+ if (fd >= 0) {
+ for (i=0; i<imgsiz; i++) {
+ *(unsigned*)field = bigendian ?
+ to_be32(arrayptr[i]) :
+ to_le32(arrayptr[i]);
+ write(fd, field, sizeof(field));
+ }
+ close(fd);
+ unlink(slnk);
+ symlink(filename, slnk);
+ } else {
+ perror(filename);
+ }
+ arrayptr += imgsiz;
+ }
+ close(fd);
+ return 0;
+}
diff --git a/package/system/ixp4xx-microcode/src/.svn/text-base/LICENSE.IPL.svn-base b/package/system/ixp4xx-microcode/src/.svn/text-base/LICENSE.IPL.svn-base
new file mode 100644
index 0000000..dad2566
--- /dev/null
+++ b/package/system/ixp4xx-microcode/src/.svn/text-base/LICENSE.IPL.svn-base
@@ -0,0 +1,27 @@
+INTEL(R) SOFTWARE LICENSE AGREEMENT
+
+Copyright (c) 2007, Intel Corporation.
+All rights reserved.
+
+Redistribution. Redistribution and use in binary form, without modification, are permitted
+provided that the following conditions are met:
+o Redistributions must reproduce the above copyright notice and the following disclaimer in the
+documentation and/or other materials provided with the distribution.
+o Neither the name of Intel Corporation nor the names of its suppliers may be used to endorse
+or promote products derived from this software without specific prior written permission.
+o No reverse engineering, decompilation, or disassembly of this software is permitted.
+
+Limited patent license. Intel Corporation grants a world-wide, royalty-free, non-exclusive
+license under patents it now or hereafter owns or controls to make, have made, use, import,
+offer to sell and sell (.Utilize.) this software, but solely to the extent that any such patent is
+necessary to Utilize the software alone. The patent license shall not apply to any combinations
+which include this software. No hardware per se is licensed hereunder.
+DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+OF SUCH DAMAGE.
diff --git a/package/system/ixp4xx-microcode/src/IxNpeMicrocode.h b/package/system/ixp4xx-microcode/src/IxNpeMicrocode.h
new file mode 100644
index 0000000..4a843db
--- /dev/null
+++ b/package/system/ixp4xx-microcode/src/IxNpeMicrocode.h
@@ -0,0 +1,148 @@
+/*
+ * IxNpeMicrocode.h - Headerfile for compiling the Intel microcode C file
+ *
+ * Copyright (C) 2006 Christian Hohnstaedt <chohnstaedt@innominate.com>
+ *
+ * This file is released under the GPLv2
+ *
+ *
+ * compile with
+ *
+ * gcc -Wall IxNpeMicrocode.c -o IxNpeMicrocode
+ *
+ * Executing the resulting binary on your build-host creates the
+ * "NPE-[ABC].xxxxxxxx" files containing the selected microcode
+ *
+ * fetch the IxNpeMicrocode.c from the Intel Access Library.
+ * It will include this header.
+ *
+ * select Images for every NPE from the following
+ * (used C++ comments for easy uncommenting ....)
+ */
+
+// #define IX_NPEDL_NPEIMAGE_NPEA_ETH_SPAN_MASK_FIREWALL_VLAN_QOS_HDR_CONV_EXTMIB
+// #define IX_NPEDL_NPEIMAGE_NPEA_ETH_SPAN_VLAN_QOS_HDR_CONV_EXTMIB
+// #define IX_NPEDL_NPEIMAGE_NPEA_ETH_LEARN_FILTER_SPAN_MASK_FIREWALL_VLAN_QOS_EXTMIB
+// #define IX_NPEDL_NPEIMAGE_NPEA_HSS_TSLOT_SWITCH
+#define IX_NPEDL_NPEIMAGE_NPEA_ETH_SPAN_FIREWALL_VLAN_QOS_HDR_CONV
+// #define IX_NPEDL_NPEIMAGE_NPEA_ETH_LEARN_FILTER_SPAN_FIREWALL_VLAN_QOS
+// #define IX_NPEDL_NPEIMAGE_NPEA_ETH_LEARN_FILTER_SPAN_FIREWALL
+#define IX_NPEDL_NPEIMAGE_NPEA_HSS_2_PORT
+// #define IX_NPEDL_NPEIMAGE_NPEA_DMA
+// #define IX_NPEDL_NPEIMAGE_NPEA_ATM_MPHY_12_PORT
+// #define IX_NPEDL_NPEIMAGE_NPEA_HSS0_ATM_MPHY_1_PORT
+// #define IX_NPEDL_NPEIMAGE_NPEA_HSS0_ATM_SPHY_1_PORT
+// #define IX_NPEDL_NPEIMAGE_NPEA_HSS0
+// #define IX_NPEDL_NPEIMAGE_NPEA_WEP
+
+
+// #define IX_NPEDL_NPEIMAGE_NPEB_ETH_SPAN_MASK_FIREWALL_VLAN_QOS_HDR_CONV_EXTMIB
+// #define IX_NPEDL_NPEIMAGE_NPEB_ETH_SPAN_VLAN_QOS_HDR_CONV_EXTMIB
+// #define IX_NPEDL_NPEIMAGE_NPEB_ETH_LEARN_FILTER_SPAN_MASK_FIREWALL_VLAN_QOS_EXTMIB
+// #define IX_NPEDL_NPEIMAGE_NPEB_DMA
+#define IX_NPEDL_NPEIMAGE_NPEB_ETH_SPAN_FIREWALL_VLAN_QOS_HDR_CONV
+// #define IX_NPEDL_NPEIMAGE_NPEB_ETH_LEARN_FILTER_SPAN_FIREWALL_VLAN_QOS
+// #define IX_NPEDL_NPEIMAGE_NPEB_ETH_LEARN_FILTER_SPAN_FIREWALL
+
+
+// #define IX_NPEDL_NPEIMAGE_NPEC_ETH_SPAN_MASK_FIREWALL_VLAN_QOS_HDR_CONV_EXTMIB
+// #define IX_NPEDL_NPEIMAGE_NPEC_ETH_SPAN_VLAN_QOS_HDR_CONV_EXTMIB
+// #define IX_NPEDL_NPEIMAGE_NPEC_ETH_LEARN_FILTER_SPAN_MASK_FIREWALL_VLAN_QOS_EXTMIB
+// #define IX_NPEDL_NPEIMAGE_NPEC_DMA
+// #define IX_NPEDL_NPEIMAGE_NPEC_CRYPTO_AES_ETH_LEARN_FILTER_SPAN
+// #define IX_NPEDL_NPEIMAGE_NPEC_CRYPTO_AES_ETH_LEARN_FILTER_FIREWALL
+#define IX_NPEDL_NPEIMAGE_NPEC_CRYPTO_AES_CCM_ETH
+// #define IX_NPEDL_NPEIMAGE_NPEC_CRYPTO_AES_CCM_EXTSHA_ETH
+// #define IX_NPEDL_NPEIMAGE_NPEC_CRYPTO_ETH_LEARN_FILTER_SPAN_FIREWALL
+// #define IX_NPEDL_NPEIMAGE_NPEC_ETH_SPAN_FIREWALL_VLAN_QOS_HDR_CONV
+// #define IX_NPEDL_NPEIMAGE_NPEC_ETH_LEARN_FILTER_SPAN_FIREWALL_VLAN_QOS
+// #define IX_NPEDL_NPEIMAGE_NPEC_ETH_LEARN_FILTER_SPAN_FIREWALL
+
+
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <netinet/in.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <endian.h>
+#include <byteswap.h>
+#include <string.h>
+
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+#define to_le32(x) (x)
+#define to_be32(x) bswap_32(x)
+#else
+#define to_be32(x) (x)
+#define to_le32(x) bswap_32(x)
+#endif
+
+struct dl_image {
+ unsigned magic;
+ unsigned id;
+ unsigned size;
+ unsigned data[0];
+};
+
+const unsigned IxNpeMicrocode_array[];
+
+int main(int argc, char *argv[])
+{
+ struct dl_image *image = (struct dl_image *)IxNpeMicrocode_array;
+ int imgsiz, i, fd, cnt;
+ const unsigned *arrayptr = IxNpeMicrocode_array;
+ const char *names[] = { "IXP425", "IXP465", "unknown" };
+ int bigendian = 1;
+
+ if (argc > 1) {
+ if (!strcmp(argv[1], "-le"))
+ bigendian = 0;
+ else if (!strcmp(argv[1], "-be"))
+ bigendian = 1;
+ else {
+ printf("Usage: %s <-le|-be>\n", argv[0]);
+ return EXIT_FAILURE;
+ }
+ }
+
+ for (image = (struct dl_image *)arrayptr, cnt=0;
+ (image->id != 0xfeedf00d) && (image->magic == 0xfeedf00d);
+ image = (struct dl_image *)(arrayptr), cnt++)
+ {
+ unsigned char field[4];
+ imgsiz = image->size + 3;
+ *(unsigned*)field = to_be32(image->id);
+ char filename[40], slnk[10];
+
+ sprintf(filename, "NPE-%c.%08x", (field[0] & 0xf) + 'A',
+ image->id);
+ if (image->id == 0x00090000)
+ sprintf(slnk, "NPE-%c-HSS", (field[0] & 0xf) + 'A');
+ else
+ sprintf(slnk, "NPE-%c", (field[0] & 0xf) + 'A');
+
+ printf("Writing image: %s.NPE_%c Func: %2x Rev: %02x.%02x "
+ "Size: %5d to: '%s'\n",
+ names[field[0] >> 4], (field[0] & 0xf) + 'A',
+ field[1], field[2], field[3], imgsiz*4, filename);
+ fd = open(filename, O_CREAT | O_RDWR | O_TRUNC, 0644);
+ if (fd >= 0) {
+ for (i=0; i<imgsiz; i++) {
+ *(unsigned*)field = bigendian ?
+ to_be32(arrayptr[i]) :
+ to_le32(arrayptr[i]);
+ write(fd, field, sizeof(field));
+ }
+ close(fd);
+ unlink(slnk);
+ symlink(filename, slnk);
+ } else {
+ perror(filename);
+ }
+ arrayptr += imgsiz;
+ }
+ close(fd);
+ return 0;
+}
diff --git a/package/system/ixp4xx-microcode/src/LICENSE.IPL b/package/system/ixp4xx-microcode/src/LICENSE.IPL
new file mode 100644
index 0000000..dad2566
--- /dev/null
+++ b/package/system/ixp4xx-microcode/src/LICENSE.IPL
@@ -0,0 +1,27 @@
+INTEL(R) SOFTWARE LICENSE AGREEMENT
+
+Copyright (c) 2007, Intel Corporation.
+All rights reserved.
+
+Redistribution. Redistribution and use in binary form, without modification, are permitted
+provided that the following conditions are met:
+o Redistributions must reproduce the above copyright notice and the following disclaimer in the
+documentation and/or other materials provided with the distribution.
+o Neither the name of Intel Corporation nor the names of its suppliers may be used to endorse
+or promote products derived from this software without specific prior written permission.
+o No reverse engineering, decompilation, or disassembly of this software is permitted.
+
+Limited patent license. Intel Corporation grants a world-wide, royalty-free, non-exclusive
+license under patents it now or hereafter owns or controls to make, have made, use, import,
+offer to sell and sell (.Utilize.) this software, but solely to the extent that any such patent is
+necessary to Utilize the software alone. The patent license shall not apply to any combinations
+which include this software. No hardware per se is licensed hereunder.
+DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+OF SUCH DAMAGE.
diff --git a/package/system/mmc_over_gpio/.svn/entries b/package/system/mmc_over_gpio/.svn/entries
new file mode 100644
index 0000000..437031a
--- /dev/null
+++ b/package/system/mmc_over_gpio/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/system/mmc_over_gpio
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-03T18:04:04.533584Z
+34998
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+files
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+c5ba4549a2052662848e2025d7c7efde
+2013-01-03T18:04:04.533584Z
+34998
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1897
+
diff --git a/package/system/mmc_over_gpio/.svn/text-base/Makefile.svn-base b/package/system/mmc_over_gpio/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..8525887
--- /dev/null
+++ b/package/system/mmc_over_gpio/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,77 @@
+#
+# Copyright (C) 2008 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=mmc-over-gpio
+PKG_RELEASE:=4
+
+include $(INCLUDE_DIR)/package.mk
+
+
+define KernelPackage/mmc-over-gpio
+ SUBMENU:=Other modules
+ DEPENDS:=@GPIO_SUPPORT +kmod-mmc-spi +kmod-spi-gpio-old +kmod-fs-configfs
+ KCONFIG:=CONFIG_GPIOMMC
+ TITLE:=MMC/SD card over GPIO support
+ FILES:=$(LINUX_DIR)/drivers/mmc/host/gpiommc.ko
+ AUTOLOAD:=$(call AutoLoad,93,gpiommc)
+ MENU:=1
+endef
+
+define Package/kmod-mmc-over-gpio/config
+ menu "Configuration"
+ depends PACKAGE_kmod-mmc-over-gpio
+
+ config KMOD_MMC_OVER_GPIO_DI_PIN
+ int "GPIO DI (Data-In) pin"
+ default 1
+
+ config KMOD_MMC_OVER_GPIO_DO_PIN
+ int "GPIO DO (Data-Out) pin"
+ default 3
+
+ config KMOD_MMC_OVER_GPIO_CLK_PIN
+ int "GPIO CLK (Clock) pin"
+ default 4
+
+ config KMOD_MMC_OVER_GPIO_CS_PIN
+ int "GPIO CS (Chip-Select) pin"
+ default 7
+
+ endmenu
+endef
+
+define KernelPackage/mmc-over-gpio/description
+ Support for driving an MMC/SD card over GPIO pins via SPI.
+endef
+
+define KernelPackage/mmc-over-gpio/conffiles
+/etc/config/mmc_over_gpio
+endef
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+endef
+
+define Build/Compile
+endef
+
+define KernelPackage/mmc-over-gpio/install
+ $(INSTALL_DIR) $(1)/etc/config
+ $(INSTALL_DATA) ./files/mmc_over_gpio.config $(1)/etc/config/mmc_over_gpio
+ $(INSTALL_DIR) $(1)/etc/init.d
+ $(INSTALL_BIN) ./files/mmc_over_gpio.init $(1)/etc/init.d/mmc_over_gpio
+
+ $(SED) 's,@GPIO_DI_PIN@,$(CONFIG_KMOD_MMC_OVER_GPIO_DI_PIN),g' \
+ -e 's,@GPIO_DO_PIN@,$(CONFIG_KMOD_MMC_OVER_GPIO_DO_PIN),g' \
+ -e 's,@GPIO_CLK_PIN@,$(CONFIG_KMOD_MMC_OVER_GPIO_CLK_PIN),g' \
+ -e 's,@GPIO_CS_PIN@,$(CONFIG_KMOD_MMC_OVER_GPIO_CS_PIN),g' \
+ $(1)/etc/config/mmc_over_gpio
+endef
+
+$(eval $(call KernelPackage,mmc-over-gpio))
diff --git a/package/system/mmc_over_gpio/Makefile b/package/system/mmc_over_gpio/Makefile
new file mode 100644
index 0000000..8525887
--- /dev/null
+++ b/package/system/mmc_over_gpio/Makefile
@@ -0,0 +1,77 @@
+#
+# Copyright (C) 2008 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=mmc-over-gpio
+PKG_RELEASE:=4
+
+include $(INCLUDE_DIR)/package.mk
+
+
+define KernelPackage/mmc-over-gpio
+ SUBMENU:=Other modules
+ DEPENDS:=@GPIO_SUPPORT +kmod-mmc-spi +kmod-spi-gpio-old +kmod-fs-configfs
+ KCONFIG:=CONFIG_GPIOMMC
+ TITLE:=MMC/SD card over GPIO support
+ FILES:=$(LINUX_DIR)/drivers/mmc/host/gpiommc.ko
+ AUTOLOAD:=$(call AutoLoad,93,gpiommc)
+ MENU:=1
+endef
+
+define Package/kmod-mmc-over-gpio/config
+ menu "Configuration"
+ depends PACKAGE_kmod-mmc-over-gpio
+
+ config KMOD_MMC_OVER_GPIO_DI_PIN
+ int "GPIO DI (Data-In) pin"
+ default 1
+
+ config KMOD_MMC_OVER_GPIO_DO_PIN
+ int "GPIO DO (Data-Out) pin"
+ default 3
+
+ config KMOD_MMC_OVER_GPIO_CLK_PIN
+ int "GPIO CLK (Clock) pin"
+ default 4
+
+ config KMOD_MMC_OVER_GPIO_CS_PIN
+ int "GPIO CS (Chip-Select) pin"
+ default 7
+
+ endmenu
+endef
+
+define KernelPackage/mmc-over-gpio/description
+ Support for driving an MMC/SD card over GPIO pins via SPI.
+endef
+
+define KernelPackage/mmc-over-gpio/conffiles
+/etc/config/mmc_over_gpio
+endef
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+endef
+
+define Build/Compile
+endef
+
+define KernelPackage/mmc-over-gpio/install
+ $(INSTALL_DIR) $(1)/etc/config
+ $(INSTALL_DATA) ./files/mmc_over_gpio.config $(1)/etc/config/mmc_over_gpio
+ $(INSTALL_DIR) $(1)/etc/init.d
+ $(INSTALL_BIN) ./files/mmc_over_gpio.init $(1)/etc/init.d/mmc_over_gpio
+
+ $(SED) 's,@GPIO_DI_PIN@,$(CONFIG_KMOD_MMC_OVER_GPIO_DI_PIN),g' \
+ -e 's,@GPIO_DO_PIN@,$(CONFIG_KMOD_MMC_OVER_GPIO_DO_PIN),g' \
+ -e 's,@GPIO_CLK_PIN@,$(CONFIG_KMOD_MMC_OVER_GPIO_CLK_PIN),g' \
+ -e 's,@GPIO_CS_PIN@,$(CONFIG_KMOD_MMC_OVER_GPIO_CS_PIN),g' \
+ $(1)/etc/config/mmc_over_gpio
+endef
+
+$(eval $(call KernelPackage,mmc-over-gpio))
diff --git a/package/system/mmc_over_gpio/files/.svn/entries b/package/system/mmc_over_gpio/files/.svn/entries
new file mode 100644
index 0000000..f07c761
--- /dev/null
+++ b/package/system/mmc_over_gpio/files/.svn/entries
@@ -0,0 +1,96 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/system/mmc_over_gpio/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+mmc_over_gpio.init
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+4b2eb8331a91c5c22816d0c4b4f4dffb
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1779
+
+mmc_over_gpio.config
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+981b307bbd9e9b6ce6b9d268683530cb
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+223
+
diff --git a/package/system/mmc_over_gpio/files/.svn/text-base/mmc_over_gpio.config.svn-base b/package/system/mmc_over_gpio/files/.svn/text-base/mmc_over_gpio.config.svn-base
new file mode 100644
index 0000000..23f0084
--- /dev/null
+++ b/package/system/mmc_over_gpio/files/.svn/text-base/mmc_over_gpio.config.svn-base
@@ -0,0 +1,8 @@
+config 'mmc_over_gpio'
+ option 'name' 'default'
+ option 'enabled' '0'
+ option 'DI_pin' '@GPIO_DI_PIN@'
+ option 'DO_pin' '@GPIO_DO_PIN@'
+ option 'CLK_pin' '@GPIO_CLK_PIN@'
+ option 'CS_pin' '@GPIO_CS_PIN@'
+ option 'mode' '0'
diff --git a/package/system/mmc_over_gpio/files/.svn/text-base/mmc_over_gpio.init.svn-base b/package/system/mmc_over_gpio/files/.svn/text-base/mmc_over_gpio.init.svn-base
new file mode 100644
index 0000000..121c803
--- /dev/null
+++ b/package/system/mmc_over_gpio/files/.svn/text-base/mmc_over_gpio.init.svn-base
@@ -0,0 +1,83 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2008 OpenWrt.org
+START=90
+
+CONFIGFS_DIR="/config/gpiommc"
+
+# add_device(name, DI_pin, DO_pin, CLK_pin, CS_pin, mode)
+add_device() {
+ local dir="$CONFIGFS_DIR/$1"
+
+ mkdir -p $dir
+ [ $? -eq 0 ] || return 1
+ echo $2 > $dir/gpio_data_in
+ [ $? -eq 0 ] || return 1
+ echo $3 > $dir/gpio_data_out
+ [ $? -eq 0 ] || return 1
+ echo $4 > $dir/gpio_clock
+ [ $? -eq 0 ] || return 1
+ echo $5 > $dir/gpio_chipselect
+ [ $? -eq 0 ] || return 1
+ echo $6 > $dir/spi_mode
+ [ $? -eq 0 ] || return 1
+ # XXX We have more config options available. Use defaults for now.
+
+ echo 1 > $dir/register
+ [ $? -eq 0 ] || return 1
+
+ return 0
+}
+
+# remove_device(name)
+remove_device() {
+ local dir="$CONFIGFS_DIR/$1"
+
+ rmdir $dir
+}
+
+mount_configfs() {
+ # FIXME: This should probably be done somewhere else.
+ mount | grep configfs
+ if [ $? -eq 0 ]; then
+ # already mounted
+ return 0
+ fi
+ mkdir -p /config
+ [ $? -eq 0 ] || return 1
+ mount configfs -t configfs /config
+ [ $? -eq 0 ] || return 1
+
+ return 0
+}
+
+start_service() {
+ local section="$1"
+ config_get "name" "$section" "name"
+ config_get "DI_pin" "$section" "DI_pin"
+ config_get "DO_pin" "$section" "DO_pin"
+ config_get "CLK_pin" "$section" "CLK_pin"
+ config_get "CS_pin" "$section" "CS_pin"
+ config_get "mode" "$section" "mode"
+ config_get_bool "enabled" "$section" "enabled" '1'
+ [ "$enabled" -gt 0 ] && add_device "$name" $DI_pin $DO_pin $CLK_pin $CS_pin $mode &
+}
+
+stop_service() {
+ local section="$1"
+ config_get "name" "$section" "name"
+ remove_device "$name"
+}
+
+start() {
+ # Make sure configfs is mounted
+ mount_configfs
+ [ $? -eq 0 ] || return 1
+
+ config_load "mmc_over_gpio"
+ config_foreach start_service "mmc_over_gpio"
+}
+
+stop() {
+ config_load "mmc_over_gpio"
+ config_foreach stop_service "mmc_over_gpio"
+}
diff --git a/package/system/mmc_over_gpio/files/mmc_over_gpio.config b/package/system/mmc_over_gpio/files/mmc_over_gpio.config
new file mode 100644
index 0000000..23f0084
--- /dev/null
+++ b/package/system/mmc_over_gpio/files/mmc_over_gpio.config
@@ -0,0 +1,8 @@
+config 'mmc_over_gpio'
+ option 'name' 'default'
+ option 'enabled' '0'
+ option 'DI_pin' '@GPIO_DI_PIN@'
+ option 'DO_pin' '@GPIO_DO_PIN@'
+ option 'CLK_pin' '@GPIO_CLK_PIN@'
+ option 'CS_pin' '@GPIO_CS_PIN@'
+ option 'mode' '0'
diff --git a/package/system/mmc_over_gpio/files/mmc_over_gpio.init b/package/system/mmc_over_gpio/files/mmc_over_gpio.init
new file mode 100644
index 0000000..121c803
--- /dev/null
+++ b/package/system/mmc_over_gpio/files/mmc_over_gpio.init
@@ -0,0 +1,83 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2008 OpenWrt.org
+START=90
+
+CONFIGFS_DIR="/config/gpiommc"
+
+# add_device(name, DI_pin, DO_pin, CLK_pin, CS_pin, mode)
+add_device() {
+ local dir="$CONFIGFS_DIR/$1"
+
+ mkdir -p $dir
+ [ $? -eq 0 ] || return 1
+ echo $2 > $dir/gpio_data_in
+ [ $? -eq 0 ] || return 1
+ echo $3 > $dir/gpio_data_out
+ [ $? -eq 0 ] || return 1
+ echo $4 > $dir/gpio_clock
+ [ $? -eq 0 ] || return 1
+ echo $5 > $dir/gpio_chipselect
+ [ $? -eq 0 ] || return 1
+ echo $6 > $dir/spi_mode
+ [ $? -eq 0 ] || return 1
+ # XXX We have more config options available. Use defaults for now.
+
+ echo 1 > $dir/register
+ [ $? -eq 0 ] || return 1
+
+ return 0
+}
+
+# remove_device(name)
+remove_device() {
+ local dir="$CONFIGFS_DIR/$1"
+
+ rmdir $dir
+}
+
+mount_configfs() {
+ # FIXME: This should probably be done somewhere else.
+ mount | grep configfs
+ if [ $? -eq 0 ]; then
+ # already mounted
+ return 0
+ fi
+ mkdir -p /config
+ [ $? -eq 0 ] || return 1
+ mount configfs -t configfs /config
+ [ $? -eq 0 ] || return 1
+
+ return 0
+}
+
+start_service() {
+ local section="$1"
+ config_get "name" "$section" "name"
+ config_get "DI_pin" "$section" "DI_pin"
+ config_get "DO_pin" "$section" "DO_pin"
+ config_get "CLK_pin" "$section" "CLK_pin"
+ config_get "CS_pin" "$section" "CS_pin"
+ config_get "mode" "$section" "mode"
+ config_get_bool "enabled" "$section" "enabled" '1'
+ [ "$enabled" -gt 0 ] && add_device "$name" $DI_pin $DO_pin $CLK_pin $CS_pin $mode &
+}
+
+stop_service() {
+ local section="$1"
+ config_get "name" "$section" "name"
+ remove_device "$name"
+}
+
+start() {
+ # Make sure configfs is mounted
+ mount_configfs
+ [ $? -eq 0 ] || return 1
+
+ config_load "mmc_over_gpio"
+ config_foreach start_service "mmc_over_gpio"
+}
+
+stop() {
+ config_load "mmc_over_gpio"
+ config_foreach stop_service "mmc_over_gpio"
+}
diff --git a/package/system/om-watchdog/.svn/entries b/package/system/om-watchdog/.svn/entries
new file mode 100644
index 0000000..9c5e3a1
--- /dev/null
+++ b/package/system/om-watchdog/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/system/om-watchdog
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-02-01T15:50:49.759805Z
+35431
+juhosg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+files
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+f3512935c92b24e281ebd68bd64b2ff6
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+868
+
diff --git a/package/system/om-watchdog/.svn/prop-base/Makefile.svn-base b/package/system/om-watchdog/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/system/om-watchdog/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/system/om-watchdog/.svn/text-base/Makefile.svn-base b/package/system/om-watchdog/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..7d517a1
--- /dev/null
+++ b/package/system/om-watchdog/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,45 @@
+#
+# Copyright (C) 2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=om-watchdog
+PKG_RELEASE:=1
+PKG_VERSION:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/om-watchdog
+ SECTION:=base
+ CATEGORY:=Base system
+ TITLE:=om watchdog
+ URL:=http://openwrt.org/
+endef
+
+define Package/om-watchdog/description
+ This package contains the hw watchdog script for the OM1P and OM2P device.
+endef
+
+define Build/Prepare
+endef
+
+define Build/Compile
+endef
+
+define Build/Compile
+endef
+
+define Package/om-watchdog/install
+ $(INSTALL_DIR) $(1)/etc/init.d/
+ $(INSTALL_DIR) $(1)/sbin/
+ $(INSTALL_BIN) ./files/om-watchdog.init $(1)/etc/init.d/om-watchdog
+ $(INSTALL_BIN) ./files/om-watchdog $(1)/sbin/om-watchdog
+endef
+
+
+$(eval $(call BuildPackage,om-watchdog))
+
diff --git a/package/system/om-watchdog/Makefile b/package/system/om-watchdog/Makefile
new file mode 100644
index 0000000..7d517a1
--- /dev/null
+++ b/package/system/om-watchdog/Makefile
@@ -0,0 +1,45 @@
+#
+# Copyright (C) 2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=om-watchdog
+PKG_RELEASE:=1
+PKG_VERSION:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/om-watchdog
+ SECTION:=base
+ CATEGORY:=Base system
+ TITLE:=om watchdog
+ URL:=http://openwrt.org/
+endef
+
+define Package/om-watchdog/description
+ This package contains the hw watchdog script for the OM1P and OM2P device.
+endef
+
+define Build/Prepare
+endef
+
+define Build/Compile
+endef
+
+define Build/Compile
+endef
+
+define Package/om-watchdog/install
+ $(INSTALL_DIR) $(1)/etc/init.d/
+ $(INSTALL_DIR) $(1)/sbin/
+ $(INSTALL_BIN) ./files/om-watchdog.init $(1)/etc/init.d/om-watchdog
+ $(INSTALL_BIN) ./files/om-watchdog $(1)/sbin/om-watchdog
+endef
+
+
+$(eval $(call BuildPackage,om-watchdog))
+
diff --git a/package/system/om-watchdog/files/.svn/entries b/package/system/om-watchdog/files/.svn/entries
new file mode 100644
index 0000000..006394e
--- /dev/null
+++ b/package/system/om-watchdog/files/.svn/entries
@@ -0,0 +1,96 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/system/om-watchdog/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-02-01T15:50:49.759805Z
+35431
+juhosg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+om-watchdog
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+decf0059225f31c6825e11cb3a37c6ca
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+251
+
+om-watchdog.init
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+333ea5be837246ced8c832a4acf17b5e
+2013-02-01T15:50:49.759805Z
+35431
+juhosg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+488
+
diff --git a/package/system/om-watchdog/files/.svn/text-base/om-watchdog.init.svn-base b/package/system/om-watchdog/files/.svn/text-base/om-watchdog.init.svn-base
new file mode 100644
index 0000000..0298bce
--- /dev/null
+++ b/package/system/om-watchdog/files/.svn/text-base/om-watchdog.init.svn-base
@@ -0,0 +1,30 @@
+#!/bin/sh /etc/rc.common
+#
+# Copyright (C) 2011 OpenWrt.org
+#
+
+START=11
+
+SERVICE_DAEMONIZE=1
+
+boot() {
+ if [ -r /lib/ar71xx.sh ]; then
+ . /lib/ar71xx.sh
+ local board=$(ar71xx_board_name)
+
+ case "$board" in
+ "om2p"|"om2p-hs")
+ service_start /sbin/om-watchdog 12
+ ;;
+ "om2p-lc")
+ service_start /sbin/om-watchdog 26
+ ;;
+ "mr600v2")
+ service_start /sbin/om-watchdog 15
+ ;;
+ esac
+ else
+ #we assume it is om1p in this case
+ service_start /sbin/om-watchdog 3
+ fi
+}
diff --git a/package/system/om-watchdog/files/.svn/text-base/om-watchdog.svn-base b/package/system/om-watchdog/files/.svn/text-base/om-watchdog.svn-base
new file mode 100644
index 0000000..d730c68
--- /dev/null
+++ b/package/system/om-watchdog/files/.svn/text-base/om-watchdog.svn-base
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+GPIO=$1
+
+trap "" INT HUP
+
+echo $GPIO > /sys/class/gpio/export
+echo out > /sys/class/gpio/gpio${GPIO}/direction
+
+while true; do
+ echo 1 > /sys/class/gpio/gpio${GPIO}/value
+ sleep 1
+ echo 0 > /sys/class/gpio/gpio${GPIO}/value
+ sleep 180
+done
diff --git a/package/system/om-watchdog/files/om-watchdog b/package/system/om-watchdog/files/om-watchdog
new file mode 100644
index 0000000..d730c68
--- /dev/null
+++ b/package/system/om-watchdog/files/om-watchdog
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+GPIO=$1
+
+trap "" INT HUP
+
+echo $GPIO > /sys/class/gpio/export
+echo out > /sys/class/gpio/gpio${GPIO}/direction
+
+while true; do
+ echo 1 > /sys/class/gpio/gpio${GPIO}/value
+ sleep 1
+ echo 0 > /sys/class/gpio/gpio${GPIO}/value
+ sleep 180
+done
diff --git a/package/system/om-watchdog/files/om-watchdog.init b/package/system/om-watchdog/files/om-watchdog.init
new file mode 100644
index 0000000..0298bce
--- /dev/null
+++ b/package/system/om-watchdog/files/om-watchdog.init
@@ -0,0 +1,30 @@
+#!/bin/sh /etc/rc.common
+#
+# Copyright (C) 2011 OpenWrt.org
+#
+
+START=11
+
+SERVICE_DAEMONIZE=1
+
+boot() {
+ if [ -r /lib/ar71xx.sh ]; then
+ . /lib/ar71xx.sh
+ local board=$(ar71xx_board_name)
+
+ case "$board" in
+ "om2p"|"om2p-hs")
+ service_start /sbin/om-watchdog 12
+ ;;
+ "om2p-lc")
+ service_start /sbin/om-watchdog 26
+ ;;
+ "mr600v2")
+ service_start /sbin/om-watchdog 15
+ ;;
+ esac
+ else
+ #we assume it is om1p in this case
+ service_start /sbin/om-watchdog 3
+ fi
+}
diff --git a/package/system/rotary-gpio-custom/.svn/entries b/package/system/rotary-gpio-custom/.svn/entries
new file mode 100644
index 0000000..d25d4ac
--- /dev/null
+++ b/package/system/rotary-gpio-custom/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/system/rotary-gpio-custom
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+src
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+b9dfdf664c415e4ffb8a320908958db1
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1282
+
diff --git a/package/system/rotary-gpio-custom/.svn/text-base/Makefile.svn-base b/package/system/rotary-gpio-custom/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..315ec31
--- /dev/null
+++ b/package/system/rotary-gpio-custom/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,53 @@
+#
+# Copyright (C) 2008-2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=rotary-gpio-custom
+PKG_RELEASE:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/rotary-gpio-custom
+ SUBMENU:=Other modules
+ TITLE:=Custom GPIO-based rotary encoder device
+ DEPENDS:=@GPIO_SUPPORT +kmod-input-gpio-encoder
+ FILES:=$(PKG_BUILD_DIR)/rotary-gpio-custom.ko
+ KCONFIG:=
+endef
+
+define KernelPackage/rotary-gpio-custom/description
+ Kernel module for register a custom rotary-gpio-encoder platform device.
+endef
+
+EXTRA_KCONFIG:= \
+ CONFIG_ROTARY_GPIO_CUSTOM=m
+
+EXTRA_CFLAGS:= \
+ $(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=m,%,$(filter %=m,$(EXTRA_KCONFIG)))) \
+ $(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=y,%,$(filter %=y,$(EXTRA_KCONFIG)))) \
+
+MAKE_OPTS:= \
+ ARCH="$(LINUX_KARCH)" \
+ CROSS_COMPILE="$(TARGET_CROSS)" \
+ SUBDIRS="$(PKG_BUILD_DIR)" \
+ EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \
+ $(EXTRA_KCONFIG)
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+define Build/Compile
+ $(MAKE) -C "$(LINUX_DIR)" \
+ $(MAKE_OPTS) \
+ modules
+endef
+
+$(eval $(call KernelPackage,rotary-gpio-custom))
diff --git a/package/system/rotary-gpio-custom/Makefile b/package/system/rotary-gpio-custom/Makefile
new file mode 100644
index 0000000..315ec31
--- /dev/null
+++ b/package/system/rotary-gpio-custom/Makefile
@@ -0,0 +1,53 @@
+#
+# Copyright (C) 2008-2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=rotary-gpio-custom
+PKG_RELEASE:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/rotary-gpio-custom
+ SUBMENU:=Other modules
+ TITLE:=Custom GPIO-based rotary encoder device
+ DEPENDS:=@GPIO_SUPPORT +kmod-input-gpio-encoder
+ FILES:=$(PKG_BUILD_DIR)/rotary-gpio-custom.ko
+ KCONFIG:=
+endef
+
+define KernelPackage/rotary-gpio-custom/description
+ Kernel module for register a custom rotary-gpio-encoder platform device.
+endef
+
+EXTRA_KCONFIG:= \
+ CONFIG_ROTARY_GPIO_CUSTOM=m
+
+EXTRA_CFLAGS:= \
+ $(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=m,%,$(filter %=m,$(EXTRA_KCONFIG)))) \
+ $(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=y,%,$(filter %=y,$(EXTRA_KCONFIG)))) \
+
+MAKE_OPTS:= \
+ ARCH="$(LINUX_KARCH)" \
+ CROSS_COMPILE="$(TARGET_CROSS)" \
+ SUBDIRS="$(PKG_BUILD_DIR)" \
+ EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \
+ $(EXTRA_KCONFIG)
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+define Build/Compile
+ $(MAKE) -C "$(LINUX_DIR)" \
+ $(MAKE_OPTS) \
+ modules
+endef
+
+$(eval $(call KernelPackage,rotary-gpio-custom))
diff --git a/package/system/rotary-gpio-custom/src/.svn/entries b/package/system/rotary-gpio-custom/src/.svn/entries
new file mode 100644
index 0000000..380542c
--- /dev/null
+++ b/package/system/rotary-gpio-custom/src/.svn/entries
@@ -0,0 +1,130 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/system/rotary-gpio-custom/src
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+Kconfig
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+8f84c6cc020253167ec5ff28a7d43a67
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+288
+
+rotary-gpio-custom.c
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+0296ba1c975bee29c3727baad3f3779a
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4562
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+fb847d7dc4f2ba5b920ca6d4736b017f
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+57
+
diff --git a/package/system/rotary-gpio-custom/src/.svn/text-base/Kconfig.svn-base b/package/system/rotary-gpio-custom/src/.svn/text-base/Kconfig.svn-base
new file mode 100644
index 0000000..b4d55d5
--- /dev/null
+++ b/package/system/rotary-gpio-custom/src/.svn/text-base/Kconfig.svn-base
@@ -0,0 +1,9 @@
+config ROTARY_GPIO_CUSTOM
+ tristate "Custom GPIO-based rotary driver"
+ depends on GENERIC_GPIO
+ help
+ This is a driver to register 1 to 4 custom rotary encoder using
+ GPIO lines.
+
+ This support is also available as a module. If so, the module
+ will be called rotary-gpio-custom.
diff --git a/package/system/rotary-gpio-custom/src/.svn/text-base/Makefile.svn-base b/package/system/rotary-gpio-custom/src/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..1336726
--- /dev/null
+++ b/package/system/rotary-gpio-custom/src/.svn/text-base/Makefile.svn-base
@@ -0,0 +1 @@
+obj-${CONFIG_ROTARY_GPIO_CUSTOM} += rotary-gpio-custom.o
diff --git a/package/system/rotary-gpio-custom/src/.svn/text-base/rotary-gpio-custom.c.svn-base b/package/system/rotary-gpio-custom/src/.svn/text-base/rotary-gpio-custom.c.svn-base
new file mode 100644
index 0000000..8cd8ef1
--- /dev/null
+++ b/package/system/rotary-gpio-custom/src/.svn/text-base/rotary-gpio-custom.c.svn-base
@@ -0,0 +1,188 @@
+/*
+ * Custom GPIO-based rotary driver
+ *
+ * Copyright (C) 2010 Claudio Mignanti <c.mignanti@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Strongly based on Custom GPIO-based I2C driver by:
+ * Copyright (C) 2007-2008 Gabor Juhos <juhosg@openwrt.org>
+ *
+ * ---------------------------------------------------------------------------
+ *
+ * The behaviour of this driver can be altered by setting some parameters
+ * from the insmod command line.
+ *
+ * The following parameters are adjustable:
+ *
+ * bus0 These four arguments can be arrays of
+ * bus1 1-8 unsigned integers as follows:
+ * bus2
+ * bus3 <id>,<steps>,<axis>,<gpioa>,<gpiob>,<inverted>
+ *
+ *
+ * If this driver is built into the kernel, you can use the following kernel
+ * command line parameters, with the same values as the corresponding module
+ * parameters listed above:
+ *
+ * rotary-gpio-custom.bus0
+ * rotary-gpio-custom.bus1
+ * rotary-gpio-custom.bus2
+ * rotary-gpio-custom.bus3
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/input.h>
+#include <linux/platform_device.h>
+#include <linux/rotary_encoder.h>
+
+#define DRV_NAME "rotary-gpio-custom"
+#define DRV_DESC "Custom GPIO-based rotary driver"
+#define DRV_VERSION "0.1.0"
+
+#define PFX DRV_NAME ": "
+
+#define BUS_PARAM_REQUIRED 5
+#define BUS_PARAM_COUNT 6
+#define BUS_COUNT_MAX 4
+
+static unsigned int bus0[BUS_PARAM_COUNT] __initdata;
+static unsigned int bus1[BUS_PARAM_COUNT] __initdata;
+static unsigned int bus2[BUS_PARAM_COUNT] __initdata;
+static unsigned int bus3[BUS_PARAM_COUNT] __initdata;
+
+static unsigned int bus_nump[BUS_COUNT_MAX] __initdata;
+
+#define BUS_PARM_DESC \
+ " config -> id,steps,axis,gpioa,gpiob[,inverted]"
+
+module_param_array(bus0, uint, &bus_nump[0], 0);
+MODULE_PARM_DESC(bus0, "bus0" BUS_PARM_DESC);
+module_param_array(bus1, uint, &bus_nump[1], 0);
+MODULE_PARM_DESC(bus1, "bus1" BUS_PARM_DESC);
+module_param_array(bus2, uint, &bus_nump[2], 0);
+MODULE_PARM_DESC(bus2, "bus2" BUS_PARM_DESC);
+module_param_array(bus3, uint, &bus_nump[3], 0);
+MODULE_PARM_DESC(bus3, "bus3" BUS_PARM_DESC);
+
+static struct platform_device *devices[BUS_COUNT_MAX];
+static unsigned int nr_devices;
+
+static void rotary_gpio_custom_cleanup(void)
+{
+ int i;
+
+ for (i = 0; i < nr_devices; i++)
+ if (devices[i])
+ platform_device_put(devices[i]);
+}
+
+static int __init rotary_gpio_custom_add_one(unsigned int id, unsigned int *params)
+{
+ struct platform_device *pdev;
+ struct rotary_encoder_platform_data pdata;
+ int err;
+
+ if (!bus_nump[id])
+ return 0;
+
+ if (bus_nump[id] < BUS_PARAM_REQUIRED) {
+ printk(KERN_ERR PFX "not enough parameters for bus%d\n", id);
+ err = -EINVAL;
+ goto err;
+ }
+
+ pdev = platform_device_alloc("rotary-gpio", params[0]);
+ if (!pdev) {
+ err = -ENOMEM;
+ goto err;
+ }
+
+ pdata.steps = params[1];
+ pdata.axis = params[2];
+ pdata.relative_axis = false;
+ pdata.rollover = false;
+ pdata.gpio_a = params[3];
+ pdata.gpio_b = params[4];
+
+ if (params[5] == 1) {
+ pdata.inverted_a = 1;
+ pdata.inverted_b = 1;
+ } else {
+ pdata.inverted_a = 0;
+ pdata.inverted_b = 0;
+ }
+
+ err = platform_device_add_data(pdev, &pdata, sizeof(pdata));
+ if (err)
+ goto err_put;
+
+ err = platform_device_add(pdev);
+ if (err)
+ goto err_put;
+
+ devices[nr_devices++] = pdev;
+ return 0;
+
+err_put:
+ platform_device_put(pdev);
+err:
+ return err;
+}
+
+static int __init rotary_gpio_custom_probe(void)
+{
+ int err;
+
+ printk(KERN_INFO DRV_DESC " version " DRV_VERSION "\n");
+
+ err = rotary_gpio_custom_add_one(0, bus0);
+ if (err) goto err;
+
+ err = rotary_gpio_custom_add_one(1, bus1);
+ if (err) goto err;
+
+ err = rotary_gpio_custom_add_one(2, bus2);
+ if (err) goto err;
+
+ err = rotary_gpio_custom_add_one(3, bus3);
+ if (err) goto err;
+
+ if (!nr_devices) {
+ printk(KERN_ERR PFX "no bus parameter(s) specified\n");
+ err = -ENODEV;
+ goto err;
+ }
+
+ return 0;
+
+err:
+ rotary_gpio_custom_cleanup();
+ return err;
+}
+
+#ifdef MODULE
+static int __init rotary_gpio_custom_init(void)
+{
+ return rotary_gpio_custom_probe();
+}
+module_init(rotary_gpio_custom_init);
+
+static void __exit rotary_gpio_custom_exit(void)
+{
+ rotary_gpio_custom_cleanup();
+}
+module_exit(rotary_gpio_custom_exit);
+#else
+subsys_initcall(rotary_gpio_custom_probe);
+#endif /* MODULE*/
+
+MODULE_LICENSE("GPL v2");
+MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org >");
+MODULE_AUTHOR("Claudio Mignanti <c.mignanti@gmail.com>");
+MODULE_DESCRIPTION(DRV_DESC);
+MODULE_VERSION(DRV_VERSION);
diff --git a/package/system/rotary-gpio-custom/src/Kconfig b/package/system/rotary-gpio-custom/src/Kconfig
new file mode 100644
index 0000000..b4d55d5
--- /dev/null
+++ b/package/system/rotary-gpio-custom/src/Kconfig
@@ -0,0 +1,9 @@
+config ROTARY_GPIO_CUSTOM
+ tristate "Custom GPIO-based rotary driver"
+ depends on GENERIC_GPIO
+ help
+ This is a driver to register 1 to 4 custom rotary encoder using
+ GPIO lines.
+
+ This support is also available as a module. If so, the module
+ will be called rotary-gpio-custom.
diff --git a/package/system/rotary-gpio-custom/src/Makefile b/package/system/rotary-gpio-custom/src/Makefile
new file mode 100644
index 0000000..1336726
--- /dev/null
+++ b/package/system/rotary-gpio-custom/src/Makefile
@@ -0,0 +1 @@
+obj-${CONFIG_ROTARY_GPIO_CUSTOM} += rotary-gpio-custom.o
diff --git a/package/system/rotary-gpio-custom/src/rotary-gpio-custom.c b/package/system/rotary-gpio-custom/src/rotary-gpio-custom.c
new file mode 100644
index 0000000..8cd8ef1
--- /dev/null
+++ b/package/system/rotary-gpio-custom/src/rotary-gpio-custom.c
@@ -0,0 +1,188 @@
+/*
+ * Custom GPIO-based rotary driver
+ *
+ * Copyright (C) 2010 Claudio Mignanti <c.mignanti@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Strongly based on Custom GPIO-based I2C driver by:
+ * Copyright (C) 2007-2008 Gabor Juhos <juhosg@openwrt.org>
+ *
+ * ---------------------------------------------------------------------------
+ *
+ * The behaviour of this driver can be altered by setting some parameters
+ * from the insmod command line.
+ *
+ * The following parameters are adjustable:
+ *
+ * bus0 These four arguments can be arrays of
+ * bus1 1-8 unsigned integers as follows:
+ * bus2
+ * bus3 <id>,<steps>,<axis>,<gpioa>,<gpiob>,<inverted>
+ *
+ *
+ * If this driver is built into the kernel, you can use the following kernel
+ * command line parameters, with the same values as the corresponding module
+ * parameters listed above:
+ *
+ * rotary-gpio-custom.bus0
+ * rotary-gpio-custom.bus1
+ * rotary-gpio-custom.bus2
+ * rotary-gpio-custom.bus3
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/input.h>
+#include <linux/platform_device.h>
+#include <linux/rotary_encoder.h>
+
+#define DRV_NAME "rotary-gpio-custom"
+#define DRV_DESC "Custom GPIO-based rotary driver"
+#define DRV_VERSION "0.1.0"
+
+#define PFX DRV_NAME ": "
+
+#define BUS_PARAM_REQUIRED 5
+#define BUS_PARAM_COUNT 6
+#define BUS_COUNT_MAX 4
+
+static unsigned int bus0[BUS_PARAM_COUNT] __initdata;
+static unsigned int bus1[BUS_PARAM_COUNT] __initdata;
+static unsigned int bus2[BUS_PARAM_COUNT] __initdata;
+static unsigned int bus3[BUS_PARAM_COUNT] __initdata;
+
+static unsigned int bus_nump[BUS_COUNT_MAX] __initdata;
+
+#define BUS_PARM_DESC \
+ " config -> id,steps,axis,gpioa,gpiob[,inverted]"
+
+module_param_array(bus0, uint, &bus_nump[0], 0);
+MODULE_PARM_DESC(bus0, "bus0" BUS_PARM_DESC);
+module_param_array(bus1, uint, &bus_nump[1], 0);
+MODULE_PARM_DESC(bus1, "bus1" BUS_PARM_DESC);
+module_param_array(bus2, uint, &bus_nump[2], 0);
+MODULE_PARM_DESC(bus2, "bus2" BUS_PARM_DESC);
+module_param_array(bus3, uint, &bus_nump[3], 0);
+MODULE_PARM_DESC(bus3, "bus3" BUS_PARM_DESC);
+
+static struct platform_device *devices[BUS_COUNT_MAX];
+static unsigned int nr_devices;
+
+static void rotary_gpio_custom_cleanup(void)
+{
+ int i;
+
+ for (i = 0; i < nr_devices; i++)
+ if (devices[i])
+ platform_device_put(devices[i]);
+}
+
+static int __init rotary_gpio_custom_add_one(unsigned int id, unsigned int *params)
+{
+ struct platform_device *pdev;
+ struct rotary_encoder_platform_data pdata;
+ int err;
+
+ if (!bus_nump[id])
+ return 0;
+
+ if (bus_nump[id] < BUS_PARAM_REQUIRED) {
+ printk(KERN_ERR PFX "not enough parameters for bus%d\n", id);
+ err = -EINVAL;
+ goto err;
+ }
+
+ pdev = platform_device_alloc("rotary-gpio", params[0]);
+ if (!pdev) {
+ err = -ENOMEM;
+ goto err;
+ }
+
+ pdata.steps = params[1];
+ pdata.axis = params[2];
+ pdata.relative_axis = false;
+ pdata.rollover = false;
+ pdata.gpio_a = params[3];
+ pdata.gpio_b = params[4];
+
+ if (params[5] == 1) {
+ pdata.inverted_a = 1;
+ pdata.inverted_b = 1;
+ } else {
+ pdata.inverted_a = 0;
+ pdata.inverted_b = 0;
+ }
+
+ err = platform_device_add_data(pdev, &pdata, sizeof(pdata));
+ if (err)
+ goto err_put;
+
+ err = platform_device_add(pdev);
+ if (err)
+ goto err_put;
+
+ devices[nr_devices++] = pdev;
+ return 0;
+
+err_put:
+ platform_device_put(pdev);
+err:
+ return err;
+}
+
+static int __init rotary_gpio_custom_probe(void)
+{
+ int err;
+
+ printk(KERN_INFO DRV_DESC " version " DRV_VERSION "\n");
+
+ err = rotary_gpio_custom_add_one(0, bus0);
+ if (err) goto err;
+
+ err = rotary_gpio_custom_add_one(1, bus1);
+ if (err) goto err;
+
+ err = rotary_gpio_custom_add_one(2, bus2);
+ if (err) goto err;
+
+ err = rotary_gpio_custom_add_one(3, bus3);
+ if (err) goto err;
+
+ if (!nr_devices) {
+ printk(KERN_ERR PFX "no bus parameter(s) specified\n");
+ err = -ENODEV;
+ goto err;
+ }
+
+ return 0;
+
+err:
+ rotary_gpio_custom_cleanup();
+ return err;
+}
+
+#ifdef MODULE
+static int __init rotary_gpio_custom_init(void)
+{
+ return rotary_gpio_custom_probe();
+}
+module_init(rotary_gpio_custom_init);
+
+static void __exit rotary_gpio_custom_exit(void)
+{
+ rotary_gpio_custom_cleanup();
+}
+module_exit(rotary_gpio_custom_exit);
+#else
+subsys_initcall(rotary_gpio_custom_probe);
+#endif /* MODULE*/
+
+MODULE_LICENSE("GPL v2");
+MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org >");
+MODULE_AUTHOR("Claudio Mignanti <c.mignanti@gmail.com>");
+MODULE_DESCRIPTION(DRV_DESC);
+MODULE_VERSION(DRV_VERSION);
diff --git a/package/system/rtc-rv5c386a/.svn/entries b/package/system/rtc-rv5c386a/.svn/entries
new file mode 100644
index 0000000..32decf4
--- /dev/null
+++ b/package/system/rtc-rv5c386a/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/system/rtc-rv5c386a
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-03T01:53:30.992116Z
+34988
+hauke
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+src
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+d9a3489d25391e47c0886bff0b7451f4
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+842
+
diff --git a/package/system/rtc-rv5c386a/.svn/text-base/Makefile.svn-base b/package/system/rtc-rv5c386a/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..e13ead5
--- /dev/null
+++ b/package/system/rtc-rv5c386a/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,38 @@
+#
+# Copyright (C) 2006-2009 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=rtc-rv5c386a
+PKG_RELEASE:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/rtc-rv5c386a
+ SUBMENU:=Other modules
+ DEPENDS:=@TARGET_brcm47xx
+ TITLE:=Driver for RTC RV5C386A (used in WL-700gE and WL-HDD)
+ AUTOLOAD:=$(call AutoLoad,70,rtc)
+ FILES:=$(PKG_BUILD_DIR)/rtc.ko
+endef
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+define Build/Compile
+ $(MAKE) -C "$(LINUX_DIR)" \
+ CROSS_COMPILE="$(TARGET_CROSS)" \
+ ARCH="$(LINUX_KARCH)" \
+ SUBDIRS="$(PKG_BUILD_DIR)" \
+ EXTRA_CFLAGS="$(BUILDFLAGS)" \
+ modules
+endef
+
+$(eval $(call KernelPackage,rtc-rv5c386a))
diff --git a/package/system/rtc-rv5c386a/Makefile b/package/system/rtc-rv5c386a/Makefile
new file mode 100644
index 0000000..e13ead5
--- /dev/null
+++ b/package/system/rtc-rv5c386a/Makefile
@@ -0,0 +1,38 @@
+#
+# Copyright (C) 2006-2009 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=rtc-rv5c386a
+PKG_RELEASE:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/rtc-rv5c386a
+ SUBMENU:=Other modules
+ DEPENDS:=@TARGET_brcm47xx
+ TITLE:=Driver for RTC RV5C386A (used in WL-700gE and WL-HDD)
+ AUTOLOAD:=$(call AutoLoad,70,rtc)
+ FILES:=$(PKG_BUILD_DIR)/rtc.ko
+endef
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+define Build/Compile
+ $(MAKE) -C "$(LINUX_DIR)" \
+ CROSS_COMPILE="$(TARGET_CROSS)" \
+ ARCH="$(LINUX_KARCH)" \
+ SUBDIRS="$(PKG_BUILD_DIR)" \
+ EXTRA_CFLAGS="$(BUILDFLAGS)" \
+ modules
+endef
+
+$(eval $(call KernelPackage,rtc-rv5c386a))
diff --git a/package/system/rtc-rv5c386a/src/.svn/entries b/package/system/rtc-rv5c386a/src/.svn/entries
new file mode 100644
index 0000000..55e197c
--- /dev/null
+++ b/package/system/rtc-rv5c386a/src/.svn/entries
@@ -0,0 +1,96 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/system/rtc-rv5c386a/src
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-03T01:53:30.992116Z
+34988
+hauke
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+rtc.c
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+91387aa5b1668a499d4a45dddf6db61c
+2013-01-03T01:53:30.992116Z
+34988
+hauke
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+13222
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+9d3bae3e4a8c958fe5e2a83b9d099ff9
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+428
+
diff --git a/package/system/rtc-rv5c386a/src/.svn/text-base/Makefile.svn-base b/package/system/rtc-rv5c386a/src/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..eeb0430
--- /dev/null
+++ b/package/system/rtc-rv5c386a/src/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,18 @@
+# $Id$
+#
+# Makefile for Real Time Clock driver for WL-HDD
+#
+# Copyright (C) 2007 Andreas Engel
+#
+# 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 of the License, or (at your option) any later version.
+#
+
+obj-m := rtc.o
+
+ifeq ($(MAKING_MODULES),1)
+
+-include $(TOPDIR)/Rules.make
+endif
diff --git a/package/system/rtc-rv5c386a/src/.svn/text-base/rtc.c.svn-base b/package/system/rtc-rv5c386a/src/.svn/text-base/rtc.c.svn-base
new file mode 100644
index 0000000..2fc6f09
--- /dev/null
+++ b/package/system/rtc-rv5c386a/src/.svn/text-base/rtc.c.svn-base
@@ -0,0 +1,613 @@
+/*
+ * Real Time Clock driver for WL-HDD
+ *
+ * Copyright (C) 2007 Andreas Engel
+ *
+ * Hacked together mostly by copying the relevant code parts from:
+ * drivers/i2c/i2c-bcm5365.c
+ * drivers/i2c/i2c-algo-bit.c
+ * drivers/char/rtc.c
+ *
+ * Note 1:
+ * This module uses the standard char device (10,135), while the Asus module
+ * rtcdrv.o uses (12,0). So, both can coexist which might be handy during
+ * development (but see the comment in rtc_open()).
+ *
+ * Note 2:
+ * You might need to set the clock once after loading the driver the first
+ * time because the driver switches the chip into 24h mode if it is running
+ * in 12h mode.
+ *
+ * Usage:
+ * For compatibility reasons with the original asus driver, the time can be
+ * read and set via the /dev/rtc device entry. The only accepted data format
+ * is "YYYY:MM:DD:W:HH:MM:SS\n". See OpenWrt wiki for a script which handles
+ * this format.
+ *
+ * In addition, this driver supports the standard ioctl() calls for setting
+ * and reading the hardware clock, so the ordinary hwclock utility can also
+ * be used.
+ *
+ * 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 of the License, or (at your option) any later version.
+ *
+ * TODO:
+ * - add a /proc/driver/rtc interface?
+ * - make the battery failure bit available through the /proc interface?
+ *
+ * $Id: rtc.c 7 2007-05-25 19:37:01Z ae $
+ */
+
+#include <linux/module.h>
+#include <linux/kmod.h>
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <linux/miscdevice.h>
+#include <linux/ioport.h>
+#include <linux/fcntl.h>
+#include <linux/mc146818rtc.h>
+#include <linux/init.h>
+#include <linux/spinlock.h>
+#include <linux/rtc.h>
+#include <linux/delay.h>
+#include <linux/version.h>
+#include <linux/gpio.h>
+#include <linux/uaccess.h>
+
+#include <asm/current.h>
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)
+#include <asm/system.h>
+#endif
+
+#include <bcm47xx.h>
+#include <bcm47xx_nvram.h>
+
+#define RTC_IS_OPEN 0x01 /* Means /dev/rtc is in use. */
+
+/* Can be changed via a module parameter. */
+static int rtc_debug = 0;
+
+static unsigned long rtc_status = 0; /* Bitmapped status byte. */
+
+/* These settings are platform dependents. */
+unsigned int sda_index = 0;
+unsigned int scl_index = 0;
+
+#define I2C_READ_MASK 1
+#define I2C_WRITE_MASK 0
+
+#define I2C_ACK 1
+#define I2C_NAK 0
+
+#define RTC_EPOCH 1900
+#define RTC_I2C_ADDRESS (0x32 << 1)
+#define RTC_24HOUR_MODE_MASK 0x20
+#define RTC_PM_MASK 0x20
+#define RTC_VDET_MASK 0x40
+#define RTC_Y2K_MASK 0x80
+
+/*
+ * Delay in microseconds for generating the pulses on the I2C bus. We use
+ * a rather conservative setting here. See datasheet of the RTC chip.
+ */
+#define ADAP_DELAY 50
+
+/* Avoid spurious compiler warnings. */
+#define UNUSED __attribute__((unused))
+
+MODULE_AUTHOR("Andreas Engel");
+MODULE_LICENSE("GPL");
+
+/* Test stolen from switch-adm.c. */
+module_param(rtc_debug, int, 0);
+
+static inline void sdalo(void)
+{
+ gpio_direction_output(sda_index, 1);
+ udelay(ADAP_DELAY);
+}
+
+static inline void sdahi(void)
+{
+ gpio_direction_input(sda_index);
+ udelay(ADAP_DELAY);
+}
+
+static inline void scllo(void)
+{
+ gpio_direction_output(scl_index, 1);
+ udelay(ADAP_DELAY);
+}
+
+static inline int getscl(void)
+{
+ return (gpio_get_value(scl_index));
+}
+
+static inline int getsda(void)
+{
+ return (gpio_get_value(sda_index));
+}
+
+/*
+ * We shouldn't simply set the SCL pin to high. Like SDA, the SCL line is
+ * bidirectional too. According to the I2C spec, the slave is allowed to
+ * pull down the SCL line to slow down the clock, so we need to check this.
+ * Generally, we'd need a timeout here, but in our case, we just check the
+ * line, assuming the RTC chip behaves well.
+ */
+static int sclhi(void)
+{
+ gpio_direction_input(scl_index);
+ udelay(ADAP_DELAY);
+ if (!getscl()) {
+ printk(KERN_ERR "SCL pin should be low\n");
+ return -ETIMEDOUT;
+ }
+ return 0;
+}
+
+static void i2c_start(void)
+{
+ sdalo();
+ scllo();
+}
+
+static void i2c_stop(void)
+{
+ sdalo();
+ sclhi();
+ sdahi();
+}
+
+static int i2c_outb(int c)
+{
+ int i;
+ int ack;
+
+ /* assert: scl is low */
+ for (i = 7; i >= 0; i--) {
+ if (c & ( 1 << i )) {
+ sdahi();
+ } else {
+ sdalo();
+ }
+ if (sclhi() < 0) { /* timed out */
+ sdahi(); /* we don't want to block the net */
+ return -ETIMEDOUT;
+ };
+ scllo();
+ }
+ sdahi();
+ if (sclhi() < 0) {
+ return -ETIMEDOUT;
+ };
+ /* read ack: SDA should be pulled down by slave */
+ ack = getsda() == 0; /* ack: sda is pulled low ->success. */
+ scllo();
+
+ if (rtc_debug)
+ printk(KERN_DEBUG "i2c_outb(0x%02x) -> %s\n",
+ c, ack ? "ACK": "NAK");
+
+ return ack; /* return 1 if device acked */
+ /* assert: scl is low (sda undef) */
+}
+
+static int i2c_inb(int ack)
+{
+ int i;
+ unsigned int indata = 0;
+
+ /* assert: scl is low */
+
+ sdahi();
+ for (i = 0; i < 8; i++) {
+ if (sclhi() < 0) {
+ return -ETIMEDOUT;
+ };
+ indata *= 2;
+ if (getsda())
+ indata |= 0x01;
+ scllo();
+ }
+ if (ack) {
+ sdalo();
+ } else {
+ sdahi();
+ }
+
+ if (sclhi() < 0) {
+ sdahi();
+ return -ETIMEDOUT;
+ }
+ scllo();
+ sdahi();
+
+ if (rtc_debug)
+ printk(KERN_DEBUG "i2c_inb() -> 0x%02x\n", indata);
+
+ /* assert: scl is low */
+ return indata & 0xff;
+}
+
+static void i2c_init(void)
+{
+ /* no gpio_control for EXTIF */
+ // ssb_gpio_control(&ssb, sda_mask | scl_mask, 0);
+
+ gpio_set_value(sda_index, 0);
+ gpio_set_value(scl_index, 0);
+ sdahi();
+ sclhi();
+}
+
+static int rtc_open(UNUSED struct inode *inode, UNUSED struct file *filp)
+{
+ spin_lock_irq(&rtc_lock);
+
+ if (rtc_status & RTC_IS_OPEN) {
+ spin_unlock_irq(&rtc_lock);
+ return -EBUSY;
+ }
+
+ rtc_status |= RTC_IS_OPEN;
+
+ /*
+ * The following call is only necessary if we use both this driver and
+ * the proprietary one from asus at the same time (which, b.t.w. only
+ * makes sense during development). Otherwise, each access via the asus
+ * driver will make access via this driver impossible.
+ */
+ i2c_init();
+
+ spin_unlock_irq(&rtc_lock);
+
+ return 0;
+}
+
+static int rtc_release(UNUSED struct inode *inode, UNUSED struct file *filp)
+{
+ /* No need for locking here. */
+ rtc_status &= ~RTC_IS_OPEN;
+ return 0;
+}
+
+static int from_bcd(int bcdnum)
+{
+ int fac, num = 0;
+
+ for (fac = 1; bcdnum; fac *= 10) {
+ num += (bcdnum % 16) * fac;
+ bcdnum /= 16;
+ }
+
+ return num;
+}
+
+static int to_bcd(int decnum)
+{
+ int fac, num = 0;
+
+ for (fac = 1; decnum; fac *= 16) {
+ num += (decnum % 10) * fac;
+ decnum /= 10;
+ }
+
+ return num;
+}
+
+static void get_rtc_time(struct rtc_time *rtc_tm)
+{
+ int cr2;
+
+ /*
+ * Read date and time from the RTC. We use read method (3).
+ */
+
+ spin_lock_irq(&rtc_lock);
+ i2c_start();
+ i2c_outb(RTC_I2C_ADDRESS | I2C_READ_MASK);
+ cr2 = i2c_inb(I2C_ACK);
+ rtc_tm->tm_sec = i2c_inb(I2C_ACK);
+ rtc_tm->tm_min = i2c_inb(I2C_ACK);
+ rtc_tm->tm_hour = i2c_inb(I2C_ACK);
+ rtc_tm->tm_wday = i2c_inb(I2C_ACK);
+ rtc_tm->tm_mday = i2c_inb(I2C_ACK);
+ rtc_tm->tm_mon = i2c_inb(I2C_ACK);
+ rtc_tm->tm_year = i2c_inb(I2C_NAK);
+ i2c_stop();
+ spin_unlock_irq(&rtc_lock);
+
+ if (cr2 & RTC_VDET_MASK) {
+ printk(KERN_WARNING "***RTC BATTERY FAILURE***\n");
+ }
+
+ /* Handle century bit */
+ if (rtc_tm->tm_mon & RTC_Y2K_MASK) {
+ rtc_tm->tm_mon &= ~RTC_Y2K_MASK;
+ rtc_tm->tm_year += 0x100;
+ }
+
+ rtc_tm->tm_sec = from_bcd(rtc_tm->tm_sec);
+ rtc_tm->tm_min = from_bcd(rtc_tm->tm_min);
+ rtc_tm->tm_hour = from_bcd(rtc_tm->tm_hour);
+ rtc_tm->tm_mday = from_bcd(rtc_tm->tm_mday);
+ rtc_tm->tm_mon = from_bcd(rtc_tm->tm_mon) - 1;
+ rtc_tm->tm_year = from_bcd(rtc_tm->tm_year);
+
+ rtc_tm->tm_isdst = -1; /* DST not known */
+}
+
+static void set_rtc_time(struct rtc_time *rtc_tm)
+{
+ rtc_tm->tm_sec = to_bcd(rtc_tm->tm_sec);
+ rtc_tm->tm_min = to_bcd(rtc_tm->tm_min);
+ rtc_tm->tm_hour = to_bcd(rtc_tm->tm_hour);
+ rtc_tm->tm_mday = to_bcd(rtc_tm->tm_mday);
+ rtc_tm->tm_mon = to_bcd(rtc_tm->tm_mon + 1);
+ rtc_tm->tm_year = to_bcd(rtc_tm->tm_year);
+
+ if (rtc_tm->tm_year >= 0x100) {
+ rtc_tm->tm_year -= 0x100;
+ rtc_tm->tm_mon |= RTC_Y2K_MASK;
+ }
+
+ spin_lock_irq(&rtc_lock);
+ i2c_start();
+ i2c_outb(RTC_I2C_ADDRESS | I2C_WRITE_MASK);
+ i2c_outb(0x00); /* set starting register to 0 (=seconds) */
+ i2c_outb(rtc_tm->tm_sec);
+ i2c_outb(rtc_tm->tm_min);
+ i2c_outb(rtc_tm->tm_hour);
+ i2c_outb(rtc_tm->tm_wday);
+ i2c_outb(rtc_tm->tm_mday);
+ i2c_outb(rtc_tm->tm_mon);
+ i2c_outb(rtc_tm->tm_year);
+ i2c_stop();
+ spin_unlock_irq(&rtc_lock);
+}
+
+static ssize_t rtc_write(UNUSED struct file *filp, const char *buf,
+ size_t count, loff_t *ppos)
+{
+ struct rtc_time rtc_tm;
+ char buffer[23];
+ char *p;
+
+ if (!capable(CAP_SYS_TIME))
+ return -EACCES;
+
+ if (ppos != &filp->f_pos)
+ return -ESPIPE;
+
+ /*
+ * For simplicity, the only acceptable format is:
+ * YYYY:MM:DD:W:HH:MM:SS\n
+ */
+
+ if (count != 22)
+ goto err_out;
+
+ if (copy_from_user(buffer, buf, count))
+ return -EFAULT;
+
+ buffer[sizeof(buffer)-1] = '\0';
+
+ p = &buffer[0];
+
+ rtc_tm.tm_year = simple_strtoul(p, &p, 10);
+ if (*p++ != ':') goto err_out;
+
+ rtc_tm.tm_mon = simple_strtoul(p, &p, 10) - 1;
+ if (*p++ != ':') goto err_out;
+
+ rtc_tm.tm_mday = simple_strtoul(p, &p, 10);
+ if (*p++ != ':') goto err_out;
+
+ rtc_tm.tm_wday = simple_strtoul(p, &p, 10);
+ if (*p++ != ':') goto err_out;
+
+ rtc_tm.tm_hour = simple_strtoul(p, &p, 10);
+ if (*p++ != ':') goto err_out;
+
+ rtc_tm.tm_min = simple_strtoul(p, &p, 10);
+ if (*p++ != ':') goto err_out;
+
+ rtc_tm.tm_sec = simple_strtoul(p, &p, 10);
+ if (*p != '\n') goto err_out;
+
+ rtc_tm.tm_year -= RTC_EPOCH;
+
+ set_rtc_time(&rtc_tm);
+
+ *ppos += count;
+
+ return count;
+
+ err_out:
+ printk(KERN_ERR "invalid format: use YYYY:MM:DD:W:HH:MM:SS\\n\n");
+ return -EINVAL;
+}
+
+
+static ssize_t rtc_read(UNUSED struct file *filp, char *buf, size_t count,
+ loff_t *ppos)
+{
+ char wbuf[23];
+ struct rtc_time tm;
+ ssize_t len;
+
+ if (count == 0 || *ppos != 0)
+ return 0;
+
+ get_rtc_time(&tm);
+
+ len = sprintf(wbuf, "%04d:%02d:%02d:%d:%02d:%02d:%02d\n",
+ tm.tm_year + RTC_EPOCH,
+ tm.tm_mon + 1,
+ tm.tm_mday,
+ tm.tm_wday,
+ tm.tm_hour,
+ tm.tm_min,
+ tm.tm_sec);
+
+ if (len > (ssize_t)count)
+ len = count;
+
+ if (copy_to_user(buf, wbuf, len))
+ return -EFAULT;
+
+ *ppos += len;
+
+ return len;
+}
+
+static int rtc_do_ioctl(unsigned int cmd, unsigned long arg)
+{
+ struct rtc_time rtc_tm;
+
+ switch (cmd) {
+ case RTC_RD_TIME:
+ memset(&rtc_tm, 0, sizeof(struct rtc_time));
+ get_rtc_time(&rtc_tm);
+ if (copy_to_user((void *)arg, &rtc_tm, sizeof(rtc_tm)))
+ return -EFAULT;
+ break;
+
+ case RTC_SET_TIME:
+ if (!capable(CAP_SYS_TIME))
+ return -EACCES;
+
+ if (copy_from_user(&rtc_tm, (struct rtc_time *)arg,
+ sizeof(struct rtc_time)))
+ return -EFAULT;
+
+ set_rtc_time(&rtc_tm);
+ break;
+
+ default:
+ return -ENOTTY;
+ }
+
+ return 0;
+}
+
+static long rtc_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+ long ret;
+ ret = rtc_do_ioctl(cmd, arg);
+ return ret;
+}
+
+static const struct file_operations rtc_fops = {
+ .owner = THIS_MODULE,
+ .llseek = no_llseek,
+ .read = rtc_read,
+ .write = rtc_write,
+ .unlocked_ioctl = rtc_ioctl,
+ .open = rtc_open,
+ .release = rtc_release,
+};
+
+static struct miscdevice rtc_dev = {
+ .minor = RTC_MINOR,
+ .name = "rtc",
+ .fops = &rtc_fops,
+};
+
+/* Savagely ripped from diag.c. */
+static inline int startswith (char *source, char *cmp)
+{
+ return !strncmp(source, cmp, strlen(cmp));
+}
+
+static void platform_detect(void)
+{
+ char buf[20];
+ int et0phyaddr, et1phyaddr;
+
+ /* Based on "model_no". */
+ if (bcm47xx_nvram_getenv("model_no", buf, sizeof(buf)) >= 0) {
+ if (startswith(buf, "WL700")) { /* WL700* */
+ sda_index = 2;
+ scl_index = 5;
+ return;
+ }
+ }
+
+ if (bcm47xx_nvram_getenv("et0phyaddr", buf, sizeof(buf)) >= 0 )
+ et0phyaddr = simple_strtoul(buf, NULL, 0);
+ if (bcm47xx_nvram_getenv("et1phyaddr", buf, sizeof(buf)) >= 0 )
+ et1phyaddr = simple_strtoul(buf, NULL, 0);
+
+ if (bcm47xx_nvram_getenv("hardware_version", buf, sizeof(buf)) >= 0) {
+ /* Either WL-300g or WL-HDD, do more extensive checks */
+ if (startswith(buf, "WL300-") && et0phyaddr == 0 && et1phyaddr == 1) {
+ sda_index = 4;
+ scl_index = 5;
+ return;
+ }
+ }
+ /* not found */
+}
+
+static int __init rtc_init(void)
+{
+ int cr1;
+
+ platform_detect();
+
+ if (sda_index == scl_index) {
+ printk(KERN_ERR "RTC-RV5C386A: unrecognized platform!\n");
+ return -ENODEV;
+ }
+
+ i2c_init();
+
+ /*
+ * Switch RTC to 24h mode
+ */
+ spin_lock_irq(&rtc_lock);
+ i2c_start();
+ i2c_outb(RTC_I2C_ADDRESS | I2C_WRITE_MASK);
+ i2c_outb(0xE4); /* start at address 0xE, transmission mode 4 */
+ cr1 = i2c_inb(I2C_NAK);
+ i2c_stop();
+ spin_unlock_irq(&rtc_lock);
+ if ((cr1 & RTC_24HOUR_MODE_MASK) == 0) {
+ /* RTC is running in 12h mode */
+ printk(KERN_INFO "rtc.o: switching to 24h mode\n");
+ spin_lock_irq(&rtc_lock);
+ i2c_start();
+ i2c_outb(RTC_I2C_ADDRESS | I2C_WRITE_MASK);
+ i2c_outb(0xE0);
+ i2c_outb(cr1 | RTC_24HOUR_MODE_MASK);
+ i2c_stop();
+ spin_unlock_irq(&rtc_lock);
+ }
+
+ misc_register(&rtc_dev);
+
+ printk(KERN_INFO "RV5C386A Real Time Clock Driver loaded\n");
+
+ return 0;
+}
+
+static void __exit rtc_exit (void)
+{
+ misc_deregister(&rtc_dev);
+ printk(KERN_INFO "Successfully removed RTC RV5C386A driver\n");
+}
+
+module_init(rtc_init);
+module_exit(rtc_exit);
+
+/*
+ * Local Variables:
+ * indent-tabs-mode:t
+ * c-basic-offset:8
+ * End:
+ */
diff --git a/package/system/rtc-rv5c386a/src/Makefile b/package/system/rtc-rv5c386a/src/Makefile
new file mode 100644
index 0000000..eeb0430
--- /dev/null
+++ b/package/system/rtc-rv5c386a/src/Makefile
@@ -0,0 +1,18 @@
+# $Id$
+#
+# Makefile for Real Time Clock driver for WL-HDD
+#
+# Copyright (C) 2007 Andreas Engel
+#
+# 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 of the License, or (at your option) any later version.
+#
+
+obj-m := rtc.o
+
+ifeq ($(MAKING_MODULES),1)
+
+-include $(TOPDIR)/Rules.make
+endif
diff --git a/package/system/rtc-rv5c386a/src/rtc.c b/package/system/rtc-rv5c386a/src/rtc.c
new file mode 100644
index 0000000..2fc6f09
--- /dev/null
+++ b/package/system/rtc-rv5c386a/src/rtc.c
@@ -0,0 +1,613 @@
+/*
+ * Real Time Clock driver for WL-HDD
+ *
+ * Copyright (C) 2007 Andreas Engel
+ *
+ * Hacked together mostly by copying the relevant code parts from:
+ * drivers/i2c/i2c-bcm5365.c
+ * drivers/i2c/i2c-algo-bit.c
+ * drivers/char/rtc.c
+ *
+ * Note 1:
+ * This module uses the standard char device (10,135), while the Asus module
+ * rtcdrv.o uses (12,0). So, both can coexist which might be handy during
+ * development (but see the comment in rtc_open()).
+ *
+ * Note 2:
+ * You might need to set the clock once after loading the driver the first
+ * time because the driver switches the chip into 24h mode if it is running
+ * in 12h mode.
+ *
+ * Usage:
+ * For compatibility reasons with the original asus driver, the time can be
+ * read and set via the /dev/rtc device entry. The only accepted data format
+ * is "YYYY:MM:DD:W:HH:MM:SS\n". See OpenWrt wiki for a script which handles
+ * this format.
+ *
+ * In addition, this driver supports the standard ioctl() calls for setting
+ * and reading the hardware clock, so the ordinary hwclock utility can also
+ * be used.
+ *
+ * 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 of the License, or (at your option) any later version.
+ *
+ * TODO:
+ * - add a /proc/driver/rtc interface?
+ * - make the battery failure bit available through the /proc interface?
+ *
+ * $Id: rtc.c 7 2007-05-25 19:37:01Z ae $
+ */
+
+#include <linux/module.h>
+#include <linux/kmod.h>
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <linux/miscdevice.h>
+#include <linux/ioport.h>
+#include <linux/fcntl.h>
+#include <linux/mc146818rtc.h>
+#include <linux/init.h>
+#include <linux/spinlock.h>
+#include <linux/rtc.h>
+#include <linux/delay.h>
+#include <linux/version.h>
+#include <linux/gpio.h>
+#include <linux/uaccess.h>
+
+#include <asm/current.h>
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)
+#include <asm/system.h>
+#endif
+
+#include <bcm47xx.h>
+#include <bcm47xx_nvram.h>
+
+#define RTC_IS_OPEN 0x01 /* Means /dev/rtc is in use. */
+
+/* Can be changed via a module parameter. */
+static int rtc_debug = 0;
+
+static unsigned long rtc_status = 0; /* Bitmapped status byte. */
+
+/* These settings are platform dependents. */
+unsigned int sda_index = 0;
+unsigned int scl_index = 0;
+
+#define I2C_READ_MASK 1
+#define I2C_WRITE_MASK 0
+
+#define I2C_ACK 1
+#define I2C_NAK 0
+
+#define RTC_EPOCH 1900
+#define RTC_I2C_ADDRESS (0x32 << 1)
+#define RTC_24HOUR_MODE_MASK 0x20
+#define RTC_PM_MASK 0x20
+#define RTC_VDET_MASK 0x40
+#define RTC_Y2K_MASK 0x80
+
+/*
+ * Delay in microseconds for generating the pulses on the I2C bus. We use
+ * a rather conservative setting here. See datasheet of the RTC chip.
+ */
+#define ADAP_DELAY 50
+
+/* Avoid spurious compiler warnings. */
+#define UNUSED __attribute__((unused))
+
+MODULE_AUTHOR("Andreas Engel");
+MODULE_LICENSE("GPL");
+
+/* Test stolen from switch-adm.c. */
+module_param(rtc_debug, int, 0);
+
+static inline void sdalo(void)
+{
+ gpio_direction_output(sda_index, 1);
+ udelay(ADAP_DELAY);
+}
+
+static inline void sdahi(void)
+{
+ gpio_direction_input(sda_index);
+ udelay(ADAP_DELAY);
+}
+
+static inline void scllo(void)
+{
+ gpio_direction_output(scl_index, 1);
+ udelay(ADAP_DELAY);
+}
+
+static inline int getscl(void)
+{
+ return (gpio_get_value(scl_index));
+}
+
+static inline int getsda(void)
+{
+ return (gpio_get_value(sda_index));
+}
+
+/*
+ * We shouldn't simply set the SCL pin to high. Like SDA, the SCL line is
+ * bidirectional too. According to the I2C spec, the slave is allowed to
+ * pull down the SCL line to slow down the clock, so we need to check this.
+ * Generally, we'd need a timeout here, but in our case, we just check the
+ * line, assuming the RTC chip behaves well.
+ */
+static int sclhi(void)
+{
+ gpio_direction_input(scl_index);
+ udelay(ADAP_DELAY);
+ if (!getscl()) {
+ printk(KERN_ERR "SCL pin should be low\n");
+ return -ETIMEDOUT;
+ }
+ return 0;
+}
+
+static void i2c_start(void)
+{
+ sdalo();
+ scllo();
+}
+
+static void i2c_stop(void)
+{
+ sdalo();
+ sclhi();
+ sdahi();
+}
+
+static int i2c_outb(int c)
+{
+ int i;
+ int ack;
+
+ /* assert: scl is low */
+ for (i = 7; i >= 0; i--) {
+ if (c & ( 1 << i )) {
+ sdahi();
+ } else {
+ sdalo();
+ }
+ if (sclhi() < 0) { /* timed out */
+ sdahi(); /* we don't want to block the net */
+ return -ETIMEDOUT;
+ };
+ scllo();
+ }
+ sdahi();
+ if (sclhi() < 0) {
+ return -ETIMEDOUT;
+ };
+ /* read ack: SDA should be pulled down by slave */
+ ack = getsda() == 0; /* ack: sda is pulled low ->success. */
+ scllo();
+
+ if (rtc_debug)
+ printk(KERN_DEBUG "i2c_outb(0x%02x) -> %s\n",
+ c, ack ? "ACK": "NAK");
+
+ return ack; /* return 1 if device acked */
+ /* assert: scl is low (sda undef) */
+}
+
+static int i2c_inb(int ack)
+{
+ int i;
+ unsigned int indata = 0;
+
+ /* assert: scl is low */
+
+ sdahi();
+ for (i = 0; i < 8; i++) {
+ if (sclhi() < 0) {
+ return -ETIMEDOUT;
+ };
+ indata *= 2;
+ if (getsda())
+ indata |= 0x01;
+ scllo();
+ }
+ if (ack) {
+ sdalo();
+ } else {
+ sdahi();
+ }
+
+ if (sclhi() < 0) {
+ sdahi();
+ return -ETIMEDOUT;
+ }
+ scllo();
+ sdahi();
+
+ if (rtc_debug)
+ printk(KERN_DEBUG "i2c_inb() -> 0x%02x\n", indata);
+
+ /* assert: scl is low */
+ return indata & 0xff;
+}
+
+static void i2c_init(void)
+{
+ /* no gpio_control for EXTIF */
+ // ssb_gpio_control(&ssb, sda_mask | scl_mask, 0);
+
+ gpio_set_value(sda_index, 0);
+ gpio_set_value(scl_index, 0);
+ sdahi();
+ sclhi();
+}
+
+static int rtc_open(UNUSED struct inode *inode, UNUSED struct file *filp)
+{
+ spin_lock_irq(&rtc_lock);
+
+ if (rtc_status & RTC_IS_OPEN) {
+ spin_unlock_irq(&rtc_lock);
+ return -EBUSY;
+ }
+
+ rtc_status |= RTC_IS_OPEN;
+
+ /*
+ * The following call is only necessary if we use both this driver and
+ * the proprietary one from asus at the same time (which, b.t.w. only
+ * makes sense during development). Otherwise, each access via the asus
+ * driver will make access via this driver impossible.
+ */
+ i2c_init();
+
+ spin_unlock_irq(&rtc_lock);
+
+ return 0;
+}
+
+static int rtc_release(UNUSED struct inode *inode, UNUSED struct file *filp)
+{
+ /* No need for locking here. */
+ rtc_status &= ~RTC_IS_OPEN;
+ return 0;
+}
+
+static int from_bcd(int bcdnum)
+{
+ int fac, num = 0;
+
+ for (fac = 1; bcdnum; fac *= 10) {
+ num += (bcdnum % 16) * fac;
+ bcdnum /= 16;
+ }
+
+ return num;
+}
+
+static int to_bcd(int decnum)
+{
+ int fac, num = 0;
+
+ for (fac = 1; decnum; fac *= 16) {
+ num += (decnum % 10) * fac;
+ decnum /= 10;
+ }
+
+ return num;
+}
+
+static void get_rtc_time(struct rtc_time *rtc_tm)
+{
+ int cr2;
+
+ /*
+ * Read date and time from the RTC. We use read method (3).
+ */
+
+ spin_lock_irq(&rtc_lock);
+ i2c_start();
+ i2c_outb(RTC_I2C_ADDRESS | I2C_READ_MASK);
+ cr2 = i2c_inb(I2C_ACK);
+ rtc_tm->tm_sec = i2c_inb(I2C_ACK);
+ rtc_tm->tm_min = i2c_inb(I2C_ACK);
+ rtc_tm->tm_hour = i2c_inb(I2C_ACK);
+ rtc_tm->tm_wday = i2c_inb(I2C_ACK);
+ rtc_tm->tm_mday = i2c_inb(I2C_ACK);
+ rtc_tm->tm_mon = i2c_inb(I2C_ACK);
+ rtc_tm->tm_year = i2c_inb(I2C_NAK);
+ i2c_stop();
+ spin_unlock_irq(&rtc_lock);
+
+ if (cr2 & RTC_VDET_MASK) {
+ printk(KERN_WARNING "***RTC BATTERY FAILURE***\n");
+ }
+
+ /* Handle century bit */
+ if (rtc_tm->tm_mon & RTC_Y2K_MASK) {
+ rtc_tm->tm_mon &= ~RTC_Y2K_MASK;
+ rtc_tm->tm_year += 0x100;
+ }
+
+ rtc_tm->tm_sec = from_bcd(rtc_tm->tm_sec);
+ rtc_tm->tm_min = from_bcd(rtc_tm->tm_min);
+ rtc_tm->tm_hour = from_bcd(rtc_tm->tm_hour);
+ rtc_tm->tm_mday = from_bcd(rtc_tm->tm_mday);
+ rtc_tm->tm_mon = from_bcd(rtc_tm->tm_mon) - 1;
+ rtc_tm->tm_year = from_bcd(rtc_tm->tm_year);
+
+ rtc_tm->tm_isdst = -1; /* DST not known */
+}
+
+static void set_rtc_time(struct rtc_time *rtc_tm)
+{
+ rtc_tm->tm_sec = to_bcd(rtc_tm->tm_sec);
+ rtc_tm->tm_min = to_bcd(rtc_tm->tm_min);
+ rtc_tm->tm_hour = to_bcd(rtc_tm->tm_hour);
+ rtc_tm->tm_mday = to_bcd(rtc_tm->tm_mday);
+ rtc_tm->tm_mon = to_bcd(rtc_tm->tm_mon + 1);
+ rtc_tm->tm_year = to_bcd(rtc_tm->tm_year);
+
+ if (rtc_tm->tm_year >= 0x100) {
+ rtc_tm->tm_year -= 0x100;
+ rtc_tm->tm_mon |= RTC_Y2K_MASK;
+ }
+
+ spin_lock_irq(&rtc_lock);
+ i2c_start();
+ i2c_outb(RTC_I2C_ADDRESS | I2C_WRITE_MASK);
+ i2c_outb(0x00); /* set starting register to 0 (=seconds) */
+ i2c_outb(rtc_tm->tm_sec);
+ i2c_outb(rtc_tm->tm_min);
+ i2c_outb(rtc_tm->tm_hour);
+ i2c_outb(rtc_tm->tm_wday);
+ i2c_outb(rtc_tm->tm_mday);
+ i2c_outb(rtc_tm->tm_mon);
+ i2c_outb(rtc_tm->tm_year);
+ i2c_stop();
+ spin_unlock_irq(&rtc_lock);
+}
+
+static ssize_t rtc_write(UNUSED struct file *filp, const char *buf,
+ size_t count, loff_t *ppos)
+{
+ struct rtc_time rtc_tm;
+ char buffer[23];
+ char *p;
+
+ if (!capable(CAP_SYS_TIME))
+ return -EACCES;
+
+ if (ppos != &filp->f_pos)
+ return -ESPIPE;
+
+ /*
+ * For simplicity, the only acceptable format is:
+ * YYYY:MM:DD:W:HH:MM:SS\n
+ */
+
+ if (count != 22)
+ goto err_out;
+
+ if (copy_from_user(buffer, buf, count))
+ return -EFAULT;
+
+ buffer[sizeof(buffer)-1] = '\0';
+
+ p = &buffer[0];
+
+ rtc_tm.tm_year = simple_strtoul(p, &p, 10);
+ if (*p++ != ':') goto err_out;
+
+ rtc_tm.tm_mon = simple_strtoul(p, &p, 10) - 1;
+ if (*p++ != ':') goto err_out;
+
+ rtc_tm.tm_mday = simple_strtoul(p, &p, 10);
+ if (*p++ != ':') goto err_out;
+
+ rtc_tm.tm_wday = simple_strtoul(p, &p, 10);
+ if (*p++ != ':') goto err_out;
+
+ rtc_tm.tm_hour = simple_strtoul(p, &p, 10);
+ if (*p++ != ':') goto err_out;
+
+ rtc_tm.tm_min = simple_strtoul(p, &p, 10);
+ if (*p++ != ':') goto err_out;
+
+ rtc_tm.tm_sec = simple_strtoul(p, &p, 10);
+ if (*p != '\n') goto err_out;
+
+ rtc_tm.tm_year -= RTC_EPOCH;
+
+ set_rtc_time(&rtc_tm);
+
+ *ppos += count;
+
+ return count;
+
+ err_out:
+ printk(KERN_ERR "invalid format: use YYYY:MM:DD:W:HH:MM:SS\\n\n");
+ return -EINVAL;
+}
+
+
+static ssize_t rtc_read(UNUSED struct file *filp, char *buf, size_t count,
+ loff_t *ppos)
+{
+ char wbuf[23];
+ struct rtc_time tm;
+ ssize_t len;
+
+ if (count == 0 || *ppos != 0)
+ return 0;
+
+ get_rtc_time(&tm);
+
+ len = sprintf(wbuf, "%04d:%02d:%02d:%d:%02d:%02d:%02d\n",
+ tm.tm_year + RTC_EPOCH,
+ tm.tm_mon + 1,
+ tm.tm_mday,
+ tm.tm_wday,
+ tm.tm_hour,
+ tm.tm_min,
+ tm.tm_sec);
+
+ if (len > (ssize_t)count)
+ len = count;
+
+ if (copy_to_user(buf, wbuf, len))
+ return -EFAULT;
+
+ *ppos += len;
+
+ return len;
+}
+
+static int rtc_do_ioctl(unsigned int cmd, unsigned long arg)
+{
+ struct rtc_time rtc_tm;
+
+ switch (cmd) {
+ case RTC_RD_TIME:
+ memset(&rtc_tm, 0, sizeof(struct rtc_time));
+ get_rtc_time(&rtc_tm);
+ if (copy_to_user((void *)arg, &rtc_tm, sizeof(rtc_tm)))
+ return -EFAULT;
+ break;
+
+ case RTC_SET_TIME:
+ if (!capable(CAP_SYS_TIME))
+ return -EACCES;
+
+ if (copy_from_user(&rtc_tm, (struct rtc_time *)arg,
+ sizeof(struct rtc_time)))
+ return -EFAULT;
+
+ set_rtc_time(&rtc_tm);
+ break;
+
+ default:
+ return -ENOTTY;
+ }
+
+ return 0;
+}
+
+static long rtc_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+ long ret;
+ ret = rtc_do_ioctl(cmd, arg);
+ return ret;
+}
+
+static const struct file_operations rtc_fops = {
+ .owner = THIS_MODULE,
+ .llseek = no_llseek,
+ .read = rtc_read,
+ .write = rtc_write,
+ .unlocked_ioctl = rtc_ioctl,
+ .open = rtc_open,
+ .release = rtc_release,
+};
+
+static struct miscdevice rtc_dev = {
+ .minor = RTC_MINOR,
+ .name = "rtc",
+ .fops = &rtc_fops,
+};
+
+/* Savagely ripped from diag.c. */
+static inline int startswith (char *source, char *cmp)
+{
+ return !strncmp(source, cmp, strlen(cmp));
+}
+
+static void platform_detect(void)
+{
+ char buf[20];
+ int et0phyaddr, et1phyaddr;
+
+ /* Based on "model_no". */
+ if (bcm47xx_nvram_getenv("model_no", buf, sizeof(buf)) >= 0) {
+ if (startswith(buf, "WL700")) { /* WL700* */
+ sda_index = 2;
+ scl_index = 5;
+ return;
+ }
+ }
+
+ if (bcm47xx_nvram_getenv("et0phyaddr", buf, sizeof(buf)) >= 0 )
+ et0phyaddr = simple_strtoul(buf, NULL, 0);
+ if (bcm47xx_nvram_getenv("et1phyaddr", buf, sizeof(buf)) >= 0 )
+ et1phyaddr = simple_strtoul(buf, NULL, 0);
+
+ if (bcm47xx_nvram_getenv("hardware_version", buf, sizeof(buf)) >= 0) {
+ /* Either WL-300g or WL-HDD, do more extensive checks */
+ if (startswith(buf, "WL300-") && et0phyaddr == 0 && et1phyaddr == 1) {
+ sda_index = 4;
+ scl_index = 5;
+ return;
+ }
+ }
+ /* not found */
+}
+
+static int __init rtc_init(void)
+{
+ int cr1;
+
+ platform_detect();
+
+ if (sda_index == scl_index) {
+ printk(KERN_ERR "RTC-RV5C386A: unrecognized platform!\n");
+ return -ENODEV;
+ }
+
+ i2c_init();
+
+ /*
+ * Switch RTC to 24h mode
+ */
+ spin_lock_irq(&rtc_lock);
+ i2c_start();
+ i2c_outb(RTC_I2C_ADDRESS | I2C_WRITE_MASK);
+ i2c_outb(0xE4); /* start at address 0xE, transmission mode 4 */
+ cr1 = i2c_inb(I2C_NAK);
+ i2c_stop();
+ spin_unlock_irq(&rtc_lock);
+ if ((cr1 & RTC_24HOUR_MODE_MASK) == 0) {
+ /* RTC is running in 12h mode */
+ printk(KERN_INFO "rtc.o: switching to 24h mode\n");
+ spin_lock_irq(&rtc_lock);
+ i2c_start();
+ i2c_outb(RTC_I2C_ADDRESS | I2C_WRITE_MASK);
+ i2c_outb(0xE0);
+ i2c_outb(cr1 | RTC_24HOUR_MODE_MASK);
+ i2c_stop();
+ spin_unlock_irq(&rtc_lock);
+ }
+
+ misc_register(&rtc_dev);
+
+ printk(KERN_INFO "RV5C386A Real Time Clock Driver loaded\n");
+
+ return 0;
+}
+
+static void __exit rtc_exit (void)
+{
+ misc_deregister(&rtc_dev);
+ printk(KERN_INFO "Successfully removed RTC RV5C386A driver\n");
+}
+
+module_init(rtc_init);
+module_exit(rtc_exit);
+
+/*
+ * Local Variables:
+ * indent-tabs-mode:t
+ * c-basic-offset:8
+ * End:
+ */
diff --git a/package/system/spi-ks8995/.svn/entries b/package/system/spi-ks8995/.svn/entries
new file mode 100644
index 0000000..e3f99ba
--- /dev/null
+++ b/package/system/spi-ks8995/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/system/spi-ks8995
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-27T21:17:38.011676Z
+35335
+hauke
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+src
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+7e6b212b53d9c2b22a9e23d0f38df082
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1243
+
diff --git a/package/system/spi-ks8995/.svn/prop-base/Makefile.svn-base b/package/system/spi-ks8995/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/system/spi-ks8995/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/system/spi-ks8995/.svn/text-base/Makefile.svn-base b/package/system/spi-ks8995/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..0be9fe3
--- /dev/null
+++ b/package/system/spi-ks8995/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,54 @@
+#
+# Copyright (C) 2008 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=spi-ks8995
+PKG_RELEASE:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/spi-ks8995
+ SUBMENU:=SPI Support
+ TITLE:=Micrel/Kendin KS8995 Ethernet switch control
+ FILES:=$(PKG_BUILD_DIR)/spi_ks8995.ko
+ KCONFIG:=CONFIG_SPI=y \
+ CONFIG_SPI_MASTER=y
+ AUTOLOAD:=$(call AutoLoad,50,spi_ks8995)
+endef
+
+define KernelPackage/spi-ks8995/description
+ Kernel module for Micrel/Kendin KS8995 ethernet switch
+endef
+
+EXTRA_KCONFIG:= \
+ CONFIG_SPI_KS8995=m
+
+EXTRA_CFLAGS:= \
+ $(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=m,%,$(filter %=m,$(EXTRA_KCONFIG)))) \
+ $(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=y,%,$(filter %=y,$(EXTRA_KCONFIG)))) \
+
+MAKE_OPTS:= \
+ ARCH="$(LINUX_KARCH)" \
+ CROSS_COMPILE="$(TARGET_CROSS)" \
+ SUBDIRS="$(PKG_BUILD_DIR)" \
+ EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \
+ $(EXTRA_KCONFIG)
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+define Build/Compile
+ $(MAKE) -C "$(LINUX_DIR)" \
+ $(MAKE_OPTS) \
+ modules
+endef
+
+$(eval $(call KernelPackage,spi-ks8995))
diff --git a/package/system/spi-ks8995/Makefile b/package/system/spi-ks8995/Makefile
new file mode 100644
index 0000000..0be9fe3
--- /dev/null
+++ b/package/system/spi-ks8995/Makefile
@@ -0,0 +1,54 @@
+#
+# Copyright (C) 2008 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=spi-ks8995
+PKG_RELEASE:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/spi-ks8995
+ SUBMENU:=SPI Support
+ TITLE:=Micrel/Kendin KS8995 Ethernet switch control
+ FILES:=$(PKG_BUILD_DIR)/spi_ks8995.ko
+ KCONFIG:=CONFIG_SPI=y \
+ CONFIG_SPI_MASTER=y
+ AUTOLOAD:=$(call AutoLoad,50,spi_ks8995)
+endef
+
+define KernelPackage/spi-ks8995/description
+ Kernel module for Micrel/Kendin KS8995 ethernet switch
+endef
+
+EXTRA_KCONFIG:= \
+ CONFIG_SPI_KS8995=m
+
+EXTRA_CFLAGS:= \
+ $(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=m,%,$(filter %=m,$(EXTRA_KCONFIG)))) \
+ $(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=y,%,$(filter %=y,$(EXTRA_KCONFIG)))) \
+
+MAKE_OPTS:= \
+ ARCH="$(LINUX_KARCH)" \
+ CROSS_COMPILE="$(TARGET_CROSS)" \
+ SUBDIRS="$(PKG_BUILD_DIR)" \
+ EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \
+ $(EXTRA_KCONFIG)
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+define Build/Compile
+ $(MAKE) -C "$(LINUX_DIR)" \
+ $(MAKE_OPTS) \
+ modules
+endef
+
+$(eval $(call KernelPackage,spi-ks8995))
diff --git a/package/system/spi-ks8995/src/.svn/entries b/package/system/spi-ks8995/src/.svn/entries
new file mode 100644
index 0000000..381c8c6
--- /dev/null
+++ b/package/system/spi-ks8995/src/.svn/entries
@@ -0,0 +1,130 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/system/spi-ks8995/src
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-27T21:17:38.011676Z
+35335
+hauke
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+Kconfig
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+50f3e187686b78a939d54a26984b2ffb
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+83
+
+spi_ks8995.c
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+8ffb8fd061c53bdd3f89e2af79dd6e94
+2013-01-27T21:17:38.011676Z
+35335
+hauke
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+10272
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+3b0b5a155ec2d709446f6e0786e8faee
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+40
+
diff --git a/package/system/spi-ks8995/src/.svn/prop-base/Makefile.svn-base b/package/system/spi-ks8995/src/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/system/spi-ks8995/src/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/system/spi-ks8995/src/.svn/prop-base/spi_ks8995.c.svn-base b/package/system/spi-ks8995/src/.svn/prop-base/spi_ks8995.c.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/system/spi-ks8995/src/.svn/prop-base/spi_ks8995.c.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/system/spi-ks8995/src/.svn/text-base/Kconfig.svn-base b/package/system/spi-ks8995/src/.svn/text-base/Kconfig.svn-base
new file mode 100644
index 0000000..7859be1
--- /dev/null
+++ b/package/system/spi-ks8995/src/.svn/text-base/Kconfig.svn-base
@@ -0,0 +1,3 @@
+config SPI_KS8995
+ tristate "Micrel/Kendin KS8995 Ethernet switch"
+ depends on SPI
diff --git a/package/system/spi-ks8995/src/.svn/text-base/Makefile.svn-base b/package/system/spi-ks8995/src/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..810c3bd
--- /dev/null
+++ b/package/system/spi-ks8995/src/.svn/text-base/Makefile.svn-base
@@ -0,0 +1 @@
+obj-${CONFIG_SPI_KS8995} += spi_ks8995.o \ No newline at end of file
diff --git a/package/system/spi-ks8995/src/.svn/text-base/spi_ks8995.c.svn-base b/package/system/spi-ks8995/src/.svn/text-base/spi_ks8995.c.svn-base
new file mode 100644
index 0000000..dc42b5d
--- /dev/null
+++ b/package/system/spi-ks8995/src/.svn/text-base/spi_ks8995.c.svn-base
@@ -0,0 +1,419 @@
+/*
+ * SPI driver for Micrel/Kendin KS8995M ethernet switch
+ *
+ * Copyright (C) 2008 Gabor Juhos <juhosg at openwrt.org>
+ *
+ * This file was based on: drivers/spi/at25.c
+ * Copyright (C) 2006 David Brownell
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ */
+
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/delay.h>
+#include <linux/device.h>
+
+#include <linux/spi/spi.h>
+
+#define DRV_VERSION "0.1.1"
+#define DRV_DESC "Micrel/Kendin KS8995 Ethernet switch SPI driver"
+
+/*-------------------------------------------------------------------------*/
+
+#define KS8995_REG_ID0 0x00 /* Chip ID0 */
+#define KS8995_REG_ID1 0x01 /* Chip ID1 */
+
+#define KS8995_REG_GC0 0x02 /* Global Control 0 */
+#define KS8995_REG_GC1 0x03 /* Global Control 1 */
+#define KS8995_REG_GC2 0x04 /* Global Control 2 */
+#define KS8995_REG_GC3 0x05 /* Global Control 3 */
+#define KS8995_REG_GC4 0x06 /* Global Control 4 */
+#define KS8995_REG_GC5 0x07 /* Global Control 5 */
+#define KS8995_REG_GC6 0x08 /* Global Control 6 */
+#define KS8995_REG_GC7 0x09 /* Global Control 7 */
+#define KS8995_REG_GC8 0x0a /* Global Control 8 */
+#define KS8995_REG_GC9 0x0b /* Global Control 9 */
+
+#define KS8995_REG_PC(p,r) ((0x10 * p) + r) /* Port Control */
+#define KS8995_REG_PS(p,r) ((0x10 * p) + r + 0xe) /* Port Status */
+
+#define KS8995_REG_TPC0 0x60 /* TOS Priority Control 0 */
+#define KS8995_REG_TPC1 0x61 /* TOS Priority Control 1 */
+#define KS8995_REG_TPC2 0x62 /* TOS Priority Control 2 */
+#define KS8995_REG_TPC3 0x63 /* TOS Priority Control 3 */
+#define KS8995_REG_TPC4 0x64 /* TOS Priority Control 4 */
+#define KS8995_REG_TPC5 0x65 /* TOS Priority Control 5 */
+#define KS8995_REG_TPC6 0x66 /* TOS Priority Control 6 */
+#define KS8995_REG_TPC7 0x67 /* TOS Priority Control 7 */
+
+#define KS8995_REG_MAC0 0x68 /* MAC address 0 */
+#define KS8995_REG_MAC1 0x69 /* MAC address 1 */
+#define KS8995_REG_MAC2 0x6a /* MAC address 2 */
+#define KS8995_REG_MAC3 0x6b /* MAC address 3 */
+#define KS8995_REG_MAC4 0x6c /* MAC address 4 */
+#define KS8995_REG_MAC5 0x6d /* MAC address 5 */
+
+#define KS8995_REG_IAC0 0x6e /* Indirect Access Control 0 */
+#define KS8995_REG_IAC1 0x6f /* Indirect Access Control 0 */
+
+#define KS8995_REG_IAD7 0x70 /* Indirect Access Data 7 */
+#define KS8995_REG_IAD6 0x71 /* Indirect Access Data 6 */
+#define KS8995_REG_IAD5 0x72 /* Indirect Access Data 5 */
+#define KS8995_REG_IAD4 0x73 /* Indirect Access Data 4 */
+#define KS8995_REG_IAD3 0x74 /* Indirect Access Data 3 */
+#define KS8995_REG_IAD2 0x75 /* Indirect Access Data 2 */
+#define KS8995_REG_IAD1 0x76 /* Indirect Access Data 1 */
+#define KS8995_REG_IAD0 0x77 /* Indirect Access Data 0 */
+
+#define KS8995_REGS_SIZE 0x80
+
+#define ID1_CHIPID_M 0xf
+#define ID1_CHIPID_S 4
+#define ID1_REVISION_M 0x7
+#define ID1_REVISION_S 1
+#define ID1_START_SW 1 /* start the switch */
+
+#define FAMILY_KS8995 0x95
+#define CHIPID_M 0
+
+#define KS8995_CMD_WRITE 0x02U
+#define KS8995_CMD_READ 0x03U
+
+#define KS8995_RESET_DELAY 10 /* usec */
+
+/*-------------------------------------------------------------------------*/
+
+struct ks8995_pdata {
+ /* not yet implemented */
+};
+
+struct ks8995_switch {
+ struct spi_device *spi;
+ struct mutex lock;
+ struct ks8995_pdata *pdata;
+};
+
+/*-------------------------------------------------------------------------*/
+
+static inline u8 get_chip_id(u8 val)
+{
+ return ((val >> ID1_CHIPID_S) & ID1_CHIPID_M);
+}
+
+static inline u8 get_chip_rev(u8 val)
+{
+ return ((val >> ID1_REVISION_S) & ID1_REVISION_M);
+}
+
+/*-------------------------------------------------------------------------*/
+
+static int ks8995_read(struct ks8995_switch *ks, char *buf,
+ unsigned offset, size_t count)
+{
+ u8 cmd[2];
+ struct spi_transfer t[2];
+ struct spi_message m;
+ int err;
+
+ spi_message_init(&m);
+
+ memset(&t, 0, sizeof(t));
+
+ t[0].tx_buf = cmd;
+ t[0].len = sizeof(cmd);
+ spi_message_add_tail(&t[0], &m);
+
+ t[1].rx_buf = buf;
+ t[1].len = count;
+ spi_message_add_tail(&t[1], &m);
+
+ cmd[0] = KS8995_CMD_READ;
+ cmd[1] = offset;
+
+ mutex_lock(&ks->lock);
+ err = spi_sync(ks->spi, &m);
+ mutex_unlock(&ks->lock);
+
+ return err ? err : count;
+}
+
+
+static int ks8995_write(struct ks8995_switch *ks, char *buf,
+ unsigned offset, size_t count)
+{
+ u8 cmd[2];
+ struct spi_transfer t[2];
+ struct spi_message m;
+ int err;
+
+ spi_message_init(&m);
+
+ memset(&t, 0, sizeof(t));
+
+ t[0].tx_buf = cmd;
+ t[0].len = sizeof(cmd);
+ spi_message_add_tail(&t[0], &m);
+
+ t[1].tx_buf = buf;
+ t[1].len = count;
+ spi_message_add_tail(&t[1], &m);
+
+ cmd[0] = KS8995_CMD_WRITE;
+ cmd[1] = offset;
+
+ mutex_lock(&ks->lock);
+ err = spi_sync(ks->spi, &m);
+ mutex_unlock(&ks->lock);
+
+ return err ? err : count;
+}
+
+static inline int ks8995_read_reg(struct ks8995_switch *ks, u8 addr, u8 *buf)
+{
+ return (ks8995_read(ks, buf, addr, 1) != 1);
+}
+
+static inline int ks8995_write_reg(struct ks8995_switch *ks, u8 addr, u8 val)
+{
+ char buf = val;
+
+ return (ks8995_write(ks, &buf, addr, 1) != 1);
+}
+
+/*-------------------------------------------------------------------------*/
+
+#if 0
+static int ks8995_setup(struct spi_device *spi)
+{
+ struct ks8995_switch *ks;
+ u8 t;
+
+ ks = dev_get_drvdata(&spi->dev);
+
+ ks8995_write_reg(ks, KS8995_REG_GC0, 0x4c);
+ ks8995_write_reg(ks, KS8995_REG_GC1, 0x05);
+
+ ks8995_read_reg(ks, KS8995_REG_GC2, &t);
+ ks8995_write_reg(ks, KS8995_REG_GC2, t | 1);
+
+ ks8995_write_reg(ks, KS8995_REG_GC4, 0x20);
+
+ ks8995_write_reg(ks, KS8995_REG_PC(1,0), 0x61);
+ ks8995_write_reg(ks, KS8995_REG_PC(2,0), 0x61);
+ ks8995_write_reg(ks, KS8995_REG_PC(3,0), 0x61);
+ ks8995_write_reg(ks, KS8995_REG_PC(4,0), 0x61);
+ ks8995_write_reg(ks, KS8995_REG_PC(5,0), 0x61);
+
+ ks8995_write_reg(ks, KS8995_REG_PC(5,11), 0x18);
+
+ ks8995_write_reg(ks, KS8995_REG_TPC0, 0xff);
+ ks8995_write_reg(ks, KS8995_REG_TPC1, 0xff);
+ ks8995_write_reg(ks, KS8995_REG_TPC2, 0xff);
+ ks8995_write_reg(ks, KS8995_REG_TPC3, 0xff);
+ ks8995_write_reg(ks, KS8995_REG_TPC4, 0xff);
+ ks8995_write_reg(ks, KS8995_REG_TPC5, 0xff);
+ ks8995_write_reg(ks, KS8995_REG_TPC6, 0xff);
+ ks8995_write_reg(ks, KS8995_REG_TPC7, 0xfe);
+
+ return 0;
+}
+#endif
+
+static int ks8995_stop(struct ks8995_switch *ks)
+{
+ return ks8995_write_reg(ks, KS8995_REG_ID1, 0);
+}
+
+static int ks8995_start(struct ks8995_switch *ks)
+{
+ return ks8995_write_reg(ks, KS8995_REG_ID1, 1);
+}
+
+static int ks8995_reset(struct ks8995_switch *ks)
+{
+ int err;
+
+ err = ks8995_stop(ks);
+ if (err)
+ return err;
+
+ udelay(KS8995_RESET_DELAY);
+
+ return ks8995_start(ks);
+}
+
+/*-------------------------------------------------------------------------*/
+
+static int ks8995_registers_read(struct kobject *kobj,
+ struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count)
+{
+ struct device *dev;
+ struct ks8995_switch *ks8995;
+
+ dev = container_of(kobj, struct device, kobj);
+ ks8995 = dev_get_drvdata(dev);
+
+ if (unlikely(off > KS8995_REGS_SIZE))
+ return 0;
+
+ if ((off + count) > KS8995_REGS_SIZE)
+ count = KS8995_REGS_SIZE - off;
+
+ if (unlikely(!count))
+ return count;
+
+ return ks8995_read(ks8995, buf, off, count);
+}
+
+
+static int ks8995_registers_write(struct kobject *kobj,
+ struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count)
+{
+ struct device *dev;
+ struct ks8995_switch *ks8995;
+
+ dev = container_of(kobj, struct device, kobj);
+ ks8995 = dev_get_drvdata(dev);
+
+ if (unlikely(off >= KS8995_REGS_SIZE))
+ return -EFBIG;
+
+ if ((off + count) > KS8995_REGS_SIZE)
+ count = KS8995_REGS_SIZE - off;
+
+ if (unlikely(!count))
+ return count;
+
+ return ks8995_write(ks8995, buf, off, count);
+}
+
+
+static struct bin_attribute ks8995_registers_attr = {
+ .attr = {
+ .name = "registers",
+ .mode = S_IRUSR | S_IWUSR,
+ },
+ .size = KS8995_REGS_SIZE,
+ .read = ks8995_registers_read,
+ .write = ks8995_registers_write,
+};
+
+/*-------------------------------------------------------------------------*/
+
+static int ks8995_probe(struct spi_device *spi)
+{
+ struct ks8995_switch *ks;
+ struct ks8995_pdata *pdata;
+ u8 ids[2];
+ int err;
+
+ /* Chip description */
+ pdata = spi->dev.platform_data;
+
+ ks = kzalloc(sizeof(*ks), GFP_KERNEL);
+ if (!ks) {
+ dev_err(&spi->dev, "no memory for private data\n");
+ return-ENOMEM;
+ }
+
+ mutex_init(&ks->lock);
+ ks->pdata = pdata;
+ ks->spi = spi_dev_get(spi);
+ dev_set_drvdata(&spi->dev, ks);
+
+ spi->mode = SPI_MODE_0;
+ spi->bits_per_word = 8;
+ err = spi_setup(spi);
+ if (err) {
+ dev_err(&spi->dev, "spi_setup failed, err=%d \n", err);
+ goto err_drvdata;
+ }
+
+ err = ks8995_read(ks, ids, KS8995_REG_ID0, sizeof(ids));
+ if (err < 0) {
+ dev_err(&spi->dev, "unable to read id registers, err=%d \n",
+ err);
+ goto err_drvdata;
+ }
+
+ switch (ids[0]) {
+ case FAMILY_KS8995:
+ break;
+ default:
+ dev_err(&spi->dev, "unknown family id:%02x\n", ids[0]);
+ err = -ENODEV;
+ goto err_drvdata;
+ }
+
+ err = ks8995_reset(ks);
+ if (err)
+ goto err_drvdata;
+
+ err = sysfs_create_bin_file(&spi->dev.kobj, &ks8995_registers_attr);
+ if (err) {
+ dev_err(&spi->dev, "unable to create sysfs file, err=%d\n",
+ err);
+ goto err_drvdata;
+ }
+
+ dev_info(&spi->dev, "KS89%02X device found, Chip ID:%01x, "
+ "Revision:%01x\n", ids[0],
+ get_chip_id(ids[1]), get_chip_rev(ids[1]));
+
+ return 0;
+
+err_drvdata:
+ dev_set_drvdata(&spi->dev, NULL);
+ kfree(ks);
+ return err;
+}
+
+static int ks8995_remove(struct spi_device *spi)
+{
+ struct ks8995_data *ks8995;
+
+ ks8995 = dev_get_drvdata(&spi->dev);
+ sysfs_remove_bin_file(&spi->dev.kobj, &ks8995_registers_attr);
+
+ dev_set_drvdata(&spi->dev, NULL);
+ kfree(ks8995);
+
+ return 0;
+}
+
+/*-------------------------------------------------------------------------*/
+
+static struct spi_driver ks8995_driver = {
+ .driver = {
+ .name = "spi-ks8995",
+ .bus = &spi_bus_type,
+ .owner = THIS_MODULE,
+ },
+ .probe = ks8995_probe,
+ .remove = ks8995_remove,
+};
+
+static int __init ks8995_init(void)
+{
+ printk(KERN_INFO DRV_DESC " version " DRV_VERSION"\n");
+
+ return spi_register_driver(&ks8995_driver);
+}
+module_init(ks8995_init);
+
+static void __exit ks8995_exit(void)
+{
+ spi_unregister_driver(&ks8995_driver);
+}
+module_exit(ks8995_exit);
+
+MODULE_DESCRIPTION(DRV_DESC);
+MODULE_VERSION(DRV_VERSION);
+MODULE_AUTHOR("Gabor Juhos <juhosg at openwrt.org>");
+MODULE_LICENSE("GPL v2");
+
diff --git a/package/system/spi-ks8995/src/Kconfig b/package/system/spi-ks8995/src/Kconfig
new file mode 100644
index 0000000..7859be1
--- /dev/null
+++ b/package/system/spi-ks8995/src/Kconfig
@@ -0,0 +1,3 @@
+config SPI_KS8995
+ tristate "Micrel/Kendin KS8995 Ethernet switch"
+ depends on SPI
diff --git a/package/system/spi-ks8995/src/Makefile b/package/system/spi-ks8995/src/Makefile
new file mode 100644
index 0000000..810c3bd
--- /dev/null
+++ b/package/system/spi-ks8995/src/Makefile
@@ -0,0 +1 @@
+obj-${CONFIG_SPI_KS8995} += spi_ks8995.o \ No newline at end of file
diff --git a/package/system/spi-ks8995/src/spi_ks8995.c b/package/system/spi-ks8995/src/spi_ks8995.c
new file mode 100644
index 0000000..dc42b5d
--- /dev/null
+++ b/package/system/spi-ks8995/src/spi_ks8995.c
@@ -0,0 +1,419 @@
+/*
+ * SPI driver for Micrel/Kendin KS8995M ethernet switch
+ *
+ * Copyright (C) 2008 Gabor Juhos <juhosg at openwrt.org>
+ *
+ * This file was based on: drivers/spi/at25.c
+ * Copyright (C) 2006 David Brownell
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ */
+
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/delay.h>
+#include <linux/device.h>
+
+#include <linux/spi/spi.h>
+
+#define DRV_VERSION "0.1.1"
+#define DRV_DESC "Micrel/Kendin KS8995 Ethernet switch SPI driver"
+
+/*-------------------------------------------------------------------------*/
+
+#define KS8995_REG_ID0 0x00 /* Chip ID0 */
+#define KS8995_REG_ID1 0x01 /* Chip ID1 */
+
+#define KS8995_REG_GC0 0x02 /* Global Control 0 */
+#define KS8995_REG_GC1 0x03 /* Global Control 1 */
+#define KS8995_REG_GC2 0x04 /* Global Control 2 */
+#define KS8995_REG_GC3 0x05 /* Global Control 3 */
+#define KS8995_REG_GC4 0x06 /* Global Control 4 */
+#define KS8995_REG_GC5 0x07 /* Global Control 5 */
+#define KS8995_REG_GC6 0x08 /* Global Control 6 */
+#define KS8995_REG_GC7 0x09 /* Global Control 7 */
+#define KS8995_REG_GC8 0x0a /* Global Control 8 */
+#define KS8995_REG_GC9 0x0b /* Global Control 9 */
+
+#define KS8995_REG_PC(p,r) ((0x10 * p) + r) /* Port Control */
+#define KS8995_REG_PS(p,r) ((0x10 * p) + r + 0xe) /* Port Status */
+
+#define KS8995_REG_TPC0 0x60 /* TOS Priority Control 0 */
+#define KS8995_REG_TPC1 0x61 /* TOS Priority Control 1 */
+#define KS8995_REG_TPC2 0x62 /* TOS Priority Control 2 */
+#define KS8995_REG_TPC3 0x63 /* TOS Priority Control 3 */
+#define KS8995_REG_TPC4 0x64 /* TOS Priority Control 4 */
+#define KS8995_REG_TPC5 0x65 /* TOS Priority Control 5 */
+#define KS8995_REG_TPC6 0x66 /* TOS Priority Control 6 */
+#define KS8995_REG_TPC7 0x67 /* TOS Priority Control 7 */
+
+#define KS8995_REG_MAC0 0x68 /* MAC address 0 */
+#define KS8995_REG_MAC1 0x69 /* MAC address 1 */
+#define KS8995_REG_MAC2 0x6a /* MAC address 2 */
+#define KS8995_REG_MAC3 0x6b /* MAC address 3 */
+#define KS8995_REG_MAC4 0x6c /* MAC address 4 */
+#define KS8995_REG_MAC5 0x6d /* MAC address 5 */
+
+#define KS8995_REG_IAC0 0x6e /* Indirect Access Control 0 */
+#define KS8995_REG_IAC1 0x6f /* Indirect Access Control 0 */
+
+#define KS8995_REG_IAD7 0x70 /* Indirect Access Data 7 */
+#define KS8995_REG_IAD6 0x71 /* Indirect Access Data 6 */
+#define KS8995_REG_IAD5 0x72 /* Indirect Access Data 5 */
+#define KS8995_REG_IAD4 0x73 /* Indirect Access Data 4 */
+#define KS8995_REG_IAD3 0x74 /* Indirect Access Data 3 */
+#define KS8995_REG_IAD2 0x75 /* Indirect Access Data 2 */
+#define KS8995_REG_IAD1 0x76 /* Indirect Access Data 1 */
+#define KS8995_REG_IAD0 0x77 /* Indirect Access Data 0 */
+
+#define KS8995_REGS_SIZE 0x80
+
+#define ID1_CHIPID_M 0xf
+#define ID1_CHIPID_S 4
+#define ID1_REVISION_M 0x7
+#define ID1_REVISION_S 1
+#define ID1_START_SW 1 /* start the switch */
+
+#define FAMILY_KS8995 0x95
+#define CHIPID_M 0
+
+#define KS8995_CMD_WRITE 0x02U
+#define KS8995_CMD_READ 0x03U
+
+#define KS8995_RESET_DELAY 10 /* usec */
+
+/*-------------------------------------------------------------------------*/
+
+struct ks8995_pdata {
+ /* not yet implemented */
+};
+
+struct ks8995_switch {
+ struct spi_device *spi;
+ struct mutex lock;
+ struct ks8995_pdata *pdata;
+};
+
+/*-------------------------------------------------------------------------*/
+
+static inline u8 get_chip_id(u8 val)
+{
+ return ((val >> ID1_CHIPID_S) & ID1_CHIPID_M);
+}
+
+static inline u8 get_chip_rev(u8 val)
+{
+ return ((val >> ID1_REVISION_S) & ID1_REVISION_M);
+}
+
+/*-------------------------------------------------------------------------*/
+
+static int ks8995_read(struct ks8995_switch *ks, char *buf,
+ unsigned offset, size_t count)
+{
+ u8 cmd[2];
+ struct spi_transfer t[2];
+ struct spi_message m;
+ int err;
+
+ spi_message_init(&m);
+
+ memset(&t, 0, sizeof(t));
+
+ t[0].tx_buf = cmd;
+ t[0].len = sizeof(cmd);
+ spi_message_add_tail(&t[0], &m);
+
+ t[1].rx_buf = buf;
+ t[1].len = count;
+ spi_message_add_tail(&t[1], &m);
+
+ cmd[0] = KS8995_CMD_READ;
+ cmd[1] = offset;
+
+ mutex_lock(&ks->lock);
+ err = spi_sync(ks->spi, &m);
+ mutex_unlock(&ks->lock);
+
+ return err ? err : count;
+}
+
+
+static int ks8995_write(struct ks8995_switch *ks, char *buf,
+ unsigned offset, size_t count)
+{
+ u8 cmd[2];
+ struct spi_transfer t[2];
+ struct spi_message m;
+ int err;
+
+ spi_message_init(&m);
+
+ memset(&t, 0, sizeof(t));
+
+ t[0].tx_buf = cmd;
+ t[0].len = sizeof(cmd);
+ spi_message_add_tail(&t[0], &m);
+
+ t[1].tx_buf = buf;
+ t[1].len = count;
+ spi_message_add_tail(&t[1], &m);
+
+ cmd[0] = KS8995_CMD_WRITE;
+ cmd[1] = offset;
+
+ mutex_lock(&ks->lock);
+ err = spi_sync(ks->spi, &m);
+ mutex_unlock(&ks->lock);
+
+ return err ? err : count;
+}
+
+static inline int ks8995_read_reg(struct ks8995_switch *ks, u8 addr, u8 *buf)
+{
+ return (ks8995_read(ks, buf, addr, 1) != 1);
+}
+
+static inline int ks8995_write_reg(struct ks8995_switch *ks, u8 addr, u8 val)
+{
+ char buf = val;
+
+ return (ks8995_write(ks, &buf, addr, 1) != 1);
+}
+
+/*-------------------------------------------------------------------------*/
+
+#if 0
+static int ks8995_setup(struct spi_device *spi)
+{
+ struct ks8995_switch *ks;
+ u8 t;
+
+ ks = dev_get_drvdata(&spi->dev);
+
+ ks8995_write_reg(ks, KS8995_REG_GC0, 0x4c);
+ ks8995_write_reg(ks, KS8995_REG_GC1, 0x05);
+
+ ks8995_read_reg(ks, KS8995_REG_GC2, &t);
+ ks8995_write_reg(ks, KS8995_REG_GC2, t | 1);
+
+ ks8995_write_reg(ks, KS8995_REG_GC4, 0x20);
+
+ ks8995_write_reg(ks, KS8995_REG_PC(1,0), 0x61);
+ ks8995_write_reg(ks, KS8995_REG_PC(2,0), 0x61);
+ ks8995_write_reg(ks, KS8995_REG_PC(3,0), 0x61);
+ ks8995_write_reg(ks, KS8995_REG_PC(4,0), 0x61);
+ ks8995_write_reg(ks, KS8995_REG_PC(5,0), 0x61);
+
+ ks8995_write_reg(ks, KS8995_REG_PC(5,11), 0x18);
+
+ ks8995_write_reg(ks, KS8995_REG_TPC0, 0xff);
+ ks8995_write_reg(ks, KS8995_REG_TPC1, 0xff);
+ ks8995_write_reg(ks, KS8995_REG_TPC2, 0xff);
+ ks8995_write_reg(ks, KS8995_REG_TPC3, 0xff);
+ ks8995_write_reg(ks, KS8995_REG_TPC4, 0xff);
+ ks8995_write_reg(ks, KS8995_REG_TPC5, 0xff);
+ ks8995_write_reg(ks, KS8995_REG_TPC6, 0xff);
+ ks8995_write_reg(ks, KS8995_REG_TPC7, 0xfe);
+
+ return 0;
+}
+#endif
+
+static int ks8995_stop(struct ks8995_switch *ks)
+{
+ return ks8995_write_reg(ks, KS8995_REG_ID1, 0);
+}
+
+static int ks8995_start(struct ks8995_switch *ks)
+{
+ return ks8995_write_reg(ks, KS8995_REG_ID1, 1);
+}
+
+static int ks8995_reset(struct ks8995_switch *ks)
+{
+ int err;
+
+ err = ks8995_stop(ks);
+ if (err)
+ return err;
+
+ udelay(KS8995_RESET_DELAY);
+
+ return ks8995_start(ks);
+}
+
+/*-------------------------------------------------------------------------*/
+
+static int ks8995_registers_read(struct kobject *kobj,
+ struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count)
+{
+ struct device *dev;
+ struct ks8995_switch *ks8995;
+
+ dev = container_of(kobj, struct device, kobj);
+ ks8995 = dev_get_drvdata(dev);
+
+ if (unlikely(off > KS8995_REGS_SIZE))
+ return 0;
+
+ if ((off + count) > KS8995_REGS_SIZE)
+ count = KS8995_REGS_SIZE - off;
+
+ if (unlikely(!count))
+ return count;
+
+ return ks8995_read(ks8995, buf, off, count);
+}
+
+
+static int ks8995_registers_write(struct kobject *kobj,
+ struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count)
+{
+ struct device *dev;
+ struct ks8995_switch *ks8995;
+
+ dev = container_of(kobj, struct device, kobj);
+ ks8995 = dev_get_drvdata(dev);
+
+ if (unlikely(off >= KS8995_REGS_SIZE))
+ return -EFBIG;
+
+ if ((off + count) > KS8995_REGS_SIZE)
+ count = KS8995_REGS_SIZE - off;
+
+ if (unlikely(!count))
+ return count;
+
+ return ks8995_write(ks8995, buf, off, count);
+}
+
+
+static struct bin_attribute ks8995_registers_attr = {
+ .attr = {
+ .name = "registers",
+ .mode = S_IRUSR | S_IWUSR,
+ },
+ .size = KS8995_REGS_SIZE,
+ .read = ks8995_registers_read,
+ .write = ks8995_registers_write,
+};
+
+/*-------------------------------------------------------------------------*/
+
+static int ks8995_probe(struct spi_device *spi)
+{
+ struct ks8995_switch *ks;
+ struct ks8995_pdata *pdata;
+ u8 ids[2];
+ int err;
+
+ /* Chip description */
+ pdata = spi->dev.platform_data;
+
+ ks = kzalloc(sizeof(*ks), GFP_KERNEL);
+ if (!ks) {
+ dev_err(&spi->dev, "no memory for private data\n");
+ return-ENOMEM;
+ }
+
+ mutex_init(&ks->lock);
+ ks->pdata = pdata;
+ ks->spi = spi_dev_get(spi);
+ dev_set_drvdata(&spi->dev, ks);
+
+ spi->mode = SPI_MODE_0;
+ spi->bits_per_word = 8;
+ err = spi_setup(spi);
+ if (err) {
+ dev_err(&spi->dev, "spi_setup failed, err=%d \n", err);
+ goto err_drvdata;
+ }
+
+ err = ks8995_read(ks, ids, KS8995_REG_ID0, sizeof(ids));
+ if (err < 0) {
+ dev_err(&spi->dev, "unable to read id registers, err=%d \n",
+ err);
+ goto err_drvdata;
+ }
+
+ switch (ids[0]) {
+ case FAMILY_KS8995:
+ break;
+ default:
+ dev_err(&spi->dev, "unknown family id:%02x\n", ids[0]);
+ err = -ENODEV;
+ goto err_drvdata;
+ }
+
+ err = ks8995_reset(ks);
+ if (err)
+ goto err_drvdata;
+
+ err = sysfs_create_bin_file(&spi->dev.kobj, &ks8995_registers_attr);
+ if (err) {
+ dev_err(&spi->dev, "unable to create sysfs file, err=%d\n",
+ err);
+ goto err_drvdata;
+ }
+
+ dev_info(&spi->dev, "KS89%02X device found, Chip ID:%01x, "
+ "Revision:%01x\n", ids[0],
+ get_chip_id(ids[1]), get_chip_rev(ids[1]));
+
+ return 0;
+
+err_drvdata:
+ dev_set_drvdata(&spi->dev, NULL);
+ kfree(ks);
+ return err;
+}
+
+static int ks8995_remove(struct spi_device *spi)
+{
+ struct ks8995_data *ks8995;
+
+ ks8995 = dev_get_drvdata(&spi->dev);
+ sysfs_remove_bin_file(&spi->dev.kobj, &ks8995_registers_attr);
+
+ dev_set_drvdata(&spi->dev, NULL);
+ kfree(ks8995);
+
+ return 0;
+}
+
+/*-------------------------------------------------------------------------*/
+
+static struct spi_driver ks8995_driver = {
+ .driver = {
+ .name = "spi-ks8995",
+ .bus = &spi_bus_type,
+ .owner = THIS_MODULE,
+ },
+ .probe = ks8995_probe,
+ .remove = ks8995_remove,
+};
+
+static int __init ks8995_init(void)
+{
+ printk(KERN_INFO DRV_DESC " version " DRV_VERSION"\n");
+
+ return spi_register_driver(&ks8995_driver);
+}
+module_init(ks8995_init);
+
+static void __exit ks8995_exit(void)
+{
+ spi_unregister_driver(&ks8995_driver);
+}
+module_exit(ks8995_exit);
+
+MODULE_DESCRIPTION(DRV_DESC);
+MODULE_VERSION(DRV_VERSION);
+MODULE_AUTHOR("Gabor Juhos <juhosg at openwrt.org>");
+MODULE_LICENSE("GPL v2");
+
diff --git a/package/system/spidev_test/.svn/entries b/package/system/spidev_test/.svn/entries
new file mode 100644
index 0000000..566a0cb
--- /dev/null
+++ b/package/system/spidev_test/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/system/spidev_test
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+ba89b1dc8b637374b7ee314c8a26c8a6
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+955
+
diff --git a/package/system/spidev_test/.svn/text-base/Makefile.svn-base b/package/system/spidev_test/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..807039a
--- /dev/null
+++ b/package/system/spidev_test/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,43 @@
+#
+# Copyright (C) 2009 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=spidev-test
+PKG_RELEASE:=$(LINUX_VERSION)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/spidev-test
+ SECTION:=utils
+ CATEGORY:=Utilities
+ DEPENDS:=+kmod-spi-dev
+ TITLE:=SPI testing utility
+ VERSION:=$(LINUX_VERSION)-$(PKG_RELEASE)
+ URL:=http://www.kernel.org
+ MAINTAINER:=Florian Fainelli <florian@openwrt.org>
+endef
+
+define Package/spidev-test/description
+ SPI testing utility.
+endef
+
+define Build/Prepare
+endef
+
+define Build/Compile
+ $(TARGET_CC) $(TARGET_CFLAGS) -o $(PKG_BUILD_DIR)/spidev_test \
+ $(LINUX_DIR)/Documentation/spi/spidev_test.c
+endef
+
+define Package/spidev-test/install
+ $(INSTALL_DIR) $(1)/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/spidev_test $(1)/sbin/
+endef
+
+$(eval $(call BuildPackage,spidev-test))
diff --git a/package/system/spidev_test/Makefile b/package/system/spidev_test/Makefile
new file mode 100644
index 0000000..807039a
--- /dev/null
+++ b/package/system/spidev_test/Makefile
@@ -0,0 +1,43 @@
+#
+# Copyright (C) 2009 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=spidev-test
+PKG_RELEASE:=$(LINUX_VERSION)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/spidev-test
+ SECTION:=utils
+ CATEGORY:=Utilities
+ DEPENDS:=+kmod-spi-dev
+ TITLE:=SPI testing utility
+ VERSION:=$(LINUX_VERSION)-$(PKG_RELEASE)
+ URL:=http://www.kernel.org
+ MAINTAINER:=Florian Fainelli <florian@openwrt.org>
+endef
+
+define Package/spidev-test/description
+ SPI testing utility.
+endef
+
+define Build/Prepare
+endef
+
+define Build/Compile
+ $(TARGET_CC) $(TARGET_CFLAGS) -o $(PKG_BUILD_DIR)/spidev_test \
+ $(LINUX_DIR)/Documentation/spi/spidev_test.c
+endef
+
+define Package/spidev-test/install
+ $(INSTALL_DIR) $(1)/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/spidev_test $(1)/sbin/
+endef
+
+$(eval $(call BuildPackage,spidev-test))
diff --git a/package/system/utils/.svn/entries b/package/system/utils/.svn/entries
new file mode 100644
index 0000000..b82dc9a
--- /dev/null
+++ b/package/system/utils/.svn/entries
@@ -0,0 +1,55 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/system/utils
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-29T12:27:17.572122Z
+35381
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+robocfg
+dir
+
+nvram
+dir
+
+fbtest
+dir
+
+e2fsprogs
+dir
+
+usbutils
+dir
+
+xfsprogs
+dir
+
+hostap-utils
+dir
+
+usbreset
+dir
+
+usb-modeswitch
+dir
+
diff --git a/package/system/utils/e2fsprogs/.svn/entries b/package/system/utils/e2fsprogs/.svn/entries
new file mode 100644
index 0000000..ba2702f
--- /dev/null
+++ b/package/system/utils/e2fsprogs/.svn/entries
@@ -0,0 +1,68 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/system/utils/e2fsprogs
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-29T10:48:46.063504Z
+35375
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+files
+dir
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+3ac35001dad0e6e0606d7471659ae848
+2013-01-29T10:48:46.063504Z
+35375
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4163
+
diff --git a/package/system/utils/e2fsprogs/.svn/prop-base/Makefile.svn-base b/package/system/utils/e2fsprogs/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..ca3abc5
--- /dev/null
+++ b/package/system/utils/e2fsprogs/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,17 @@
+K 9
+copyright
+V 30
+Copyright (C) 2006 OpenWrt.org
+K 7
+licence
+V 5
+GPLv2
+K 13
+svn:copyright
+V 30
+Copyright (C) 2006 OpenWrt.org
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/system/utils/e2fsprogs/.svn/text-base/Makefile.svn-base b/package/system/utils/e2fsprogs/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..ebc21c9
--- /dev/null
+++ b/package/system/utils/e2fsprogs/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,169 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+# Copyright 2010 Vertical Communications
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=e2fsprogs
+PKG_VERSION:=1.42.4
+PKG_MD5SUM:=b6e296f210d642361b7394437ff0f318
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=@SF/e2fsprogs
+
+PKG_BUILD_DEPENDS:=util-linux
+PKG_INSTALL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/e2fsprogs/Default
+ URL:=http://e2fsprogs.sourceforge.net/
+ SUBMENU:=Filesystem
+endef
+
+define Package/e2fsprogs
+$(call Package/e2fsprogs/Default)
+ SECTION:=utils
+ CATEGORY:=Utilities
+ TITLE:=Ext2/3/4 filesystem utilities
+ DEPENDS:=+libblkid +libuuid +libext2fs
+endef
+
+define Package/e2fsprogs/description
+ This package contains essential ext2 filesystem utilities which consists of
+ e2fsck, mke2fs, tune2fs, and most of the other core ext2
+ filesystem utilities.
+endef
+
+define Package/libext2fs
+$(call Package/e2fsprogs/Default)
+ DEPENDS:=+libcom_err
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=ext2/3/4 filesystem library
+endef
+
+define Package/libext2fs/description
+ libext2fs is a library which can access ext2, ext3 and ext4 filesystems.
+endef
+
+define Package/libcom_err
+$(call Package/e2fsprogs/Default)
+ DEPENDS:=+libpthread
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=Common error description library
+endef
+
+define Package/libcom_err/description
+ libcom_err is a library providing common error descriptions
+endef
+
+define Package/tune2fs
+$(call Package/e2fsprogs)
+ TITLE:=Ext2 Filesystem tune utility
+ DEPENDS:= +e2fsprogs
+endef
+
+define Package/resize2fs
+$(call Package/e2fsprogs)
+ TITLE:=Ext2 Filesystem resize utility
+ DEPENDS:= +e2fsprogs
+endef
+
+define Package/badblocks
+$(call Package/e2fsprogs)
+ TITLE:=Ext2 Filesystem badblocks utility
+ DEPENDS:= +e2fsprogs
+endef
+
+TARGET_CFLAGS += $(FPIC)
+
+CONFIGURE_ARGS += \
+ --enable-elf-shlibs \
+ --disable-libuuid \
+ --disable-libblkid \
+ --disable-uuidd \
+ --disable-tls \
+ --disable-nls \
+ --disable-rpath
+
+define Build/Prepare
+ $(call Build/Prepare/Default)
+ $(CP) $(SCRIPT_DIR)/config.{guess,sub} $(PKG_BUILD_DIR)/config/
+endef
+
+define Build/Compile
+ $(MAKE) -C $(PKG_BUILD_DIR)/util \
+ BUILDCC="$(HOSTCC)" \
+ CFLAGS="" \
+ CPPFLAGS="" \
+ LDFLAGS="" \
+ subst
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ BUILDCC="$(HOSTCC)" \
+ DESTDIR="$(PKG_INSTALL_DIR)" \
+ all
+endef
+
+define Build/InstallDev
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ BUILDCC="$(HOSTCC)" \
+ DESTDIR="$(1)" \
+ install-libs
+ $(MAKE) -C $(PKG_BUILD_DIR)/lib/ext2fs \
+ BUILDCC="$(HOSTCC)" \
+ DESTDIR="$(1)" \
+ install
+endef
+
+define Package/e2fsprogs/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/e2fsck $(1)/usr/sbin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/mke2fs $(1)/usr/sbin/
+ ln -sf mke2fs $(1)/usr/sbin/mkfs.ext2
+ ln -sf mke2fs $(1)/usr/sbin/mkfs.ext3
+ ln -sf mke2fs $(1)/usr/sbin/mkfs.ext4
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libe2p.so.* $(1)/usr/lib/
+ $(INSTALL_DIR) $(1)/etc/init.d
+ $(INSTALL_DIR) $(1)/lib/functions/fsck
+ $(INSTALL_DATA) ./files/e2fsck.sh $(1)/lib/functions/fsck/
+ $(INSTALL_DATA) ./files/e2fsck.conf $(1)/etc/e2fsck.conf
+endef
+
+define Package/libcom_err/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libcom_err.so.* $(1)/usr/lib/
+endef
+
+define Package/libext2fs/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libext2fs.so.* $(1)/usr/lib/
+endef
+
+define Package/tune2fs/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/tune2fs $(1)/usr/sbin/
+endef
+
+define Package/resize2fs/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/resize2fs $(1)/usr/sbin/
+endef
+
+define Package/badblocks/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/badblocks $(1)/usr/sbin/
+endef
+
+$(eval $(call BuildPackage,e2fsprogs))
+$(eval $(call BuildPackage,libext2fs))
+$(eval $(call BuildPackage,libcom_err))
+$(eval $(call BuildPackage,tune2fs))
+$(eval $(call BuildPackage,resize2fs))
+$(eval $(call BuildPackage,badblocks))
diff --git a/package/system/utils/e2fsprogs/Makefile b/package/system/utils/e2fsprogs/Makefile
new file mode 100644
index 0000000..ebc21c9
--- /dev/null
+++ b/package/system/utils/e2fsprogs/Makefile
@@ -0,0 +1,169 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+# Copyright 2010 Vertical Communications
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=e2fsprogs
+PKG_VERSION:=1.42.4
+PKG_MD5SUM:=b6e296f210d642361b7394437ff0f318
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=@SF/e2fsprogs
+
+PKG_BUILD_DEPENDS:=util-linux
+PKG_INSTALL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/e2fsprogs/Default
+ URL:=http://e2fsprogs.sourceforge.net/
+ SUBMENU:=Filesystem
+endef
+
+define Package/e2fsprogs
+$(call Package/e2fsprogs/Default)
+ SECTION:=utils
+ CATEGORY:=Utilities
+ TITLE:=Ext2/3/4 filesystem utilities
+ DEPENDS:=+libblkid +libuuid +libext2fs
+endef
+
+define Package/e2fsprogs/description
+ This package contains essential ext2 filesystem utilities which consists of
+ e2fsck, mke2fs, tune2fs, and most of the other core ext2
+ filesystem utilities.
+endef
+
+define Package/libext2fs
+$(call Package/e2fsprogs/Default)
+ DEPENDS:=+libcom_err
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=ext2/3/4 filesystem library
+endef
+
+define Package/libext2fs/description
+ libext2fs is a library which can access ext2, ext3 and ext4 filesystems.
+endef
+
+define Package/libcom_err
+$(call Package/e2fsprogs/Default)
+ DEPENDS:=+libpthread
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=Common error description library
+endef
+
+define Package/libcom_err/description
+ libcom_err is a library providing common error descriptions
+endef
+
+define Package/tune2fs
+$(call Package/e2fsprogs)
+ TITLE:=Ext2 Filesystem tune utility
+ DEPENDS:= +e2fsprogs
+endef
+
+define Package/resize2fs
+$(call Package/e2fsprogs)
+ TITLE:=Ext2 Filesystem resize utility
+ DEPENDS:= +e2fsprogs
+endef
+
+define Package/badblocks
+$(call Package/e2fsprogs)
+ TITLE:=Ext2 Filesystem badblocks utility
+ DEPENDS:= +e2fsprogs
+endef
+
+TARGET_CFLAGS += $(FPIC)
+
+CONFIGURE_ARGS += \
+ --enable-elf-shlibs \
+ --disable-libuuid \
+ --disable-libblkid \
+ --disable-uuidd \
+ --disable-tls \
+ --disable-nls \
+ --disable-rpath
+
+define Build/Prepare
+ $(call Build/Prepare/Default)
+ $(CP) $(SCRIPT_DIR)/config.{guess,sub} $(PKG_BUILD_DIR)/config/
+endef
+
+define Build/Compile
+ $(MAKE) -C $(PKG_BUILD_DIR)/util \
+ BUILDCC="$(HOSTCC)" \
+ CFLAGS="" \
+ CPPFLAGS="" \
+ LDFLAGS="" \
+ subst
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ BUILDCC="$(HOSTCC)" \
+ DESTDIR="$(PKG_INSTALL_DIR)" \
+ all
+endef
+
+define Build/InstallDev
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ BUILDCC="$(HOSTCC)" \
+ DESTDIR="$(1)" \
+ install-libs
+ $(MAKE) -C $(PKG_BUILD_DIR)/lib/ext2fs \
+ BUILDCC="$(HOSTCC)" \
+ DESTDIR="$(1)" \
+ install
+endef
+
+define Package/e2fsprogs/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/e2fsck $(1)/usr/sbin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/mke2fs $(1)/usr/sbin/
+ ln -sf mke2fs $(1)/usr/sbin/mkfs.ext2
+ ln -sf mke2fs $(1)/usr/sbin/mkfs.ext3
+ ln -sf mke2fs $(1)/usr/sbin/mkfs.ext4
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libe2p.so.* $(1)/usr/lib/
+ $(INSTALL_DIR) $(1)/etc/init.d
+ $(INSTALL_DIR) $(1)/lib/functions/fsck
+ $(INSTALL_DATA) ./files/e2fsck.sh $(1)/lib/functions/fsck/
+ $(INSTALL_DATA) ./files/e2fsck.conf $(1)/etc/e2fsck.conf
+endef
+
+define Package/libcom_err/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libcom_err.so.* $(1)/usr/lib/
+endef
+
+define Package/libext2fs/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libext2fs.so.* $(1)/usr/lib/
+endef
+
+define Package/tune2fs/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/tune2fs $(1)/usr/sbin/
+endef
+
+define Package/resize2fs/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/resize2fs $(1)/usr/sbin/
+endef
+
+define Package/badblocks/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/badblocks $(1)/usr/sbin/
+endef
+
+$(eval $(call BuildPackage,e2fsprogs))
+$(eval $(call BuildPackage,libext2fs))
+$(eval $(call BuildPackage,libcom_err))
+$(eval $(call BuildPackage,tune2fs))
+$(eval $(call BuildPackage,resize2fs))
+$(eval $(call BuildPackage,badblocks))
diff --git a/package/system/utils/e2fsprogs/files/.svn/entries b/package/system/utils/e2fsprogs/files/.svn/entries
new file mode 100644
index 0000000..b1253f7
--- /dev/null
+++ b/package/system/utils/e2fsprogs/files/.svn/entries
@@ -0,0 +1,96 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/system/utils/e2fsprogs/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-29T10:48:46.063504Z
+35375
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+e2fsck.conf
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+feb48bdf416ced071d3d69a153ca0dd6
+2013-01-29T10:48:46.063504Z
+35375
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+38
+
+e2fsck.sh
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+d1b65dd91268e8988822b1a8df1e49ad
+2013-01-29T10:48:46.063504Z
+35375
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+784
+
diff --git a/package/system/utils/e2fsprogs/files/.svn/text-base/e2fsck.conf.svn-base b/package/system/utils/e2fsprogs/files/.svn/text-base/e2fsck.conf.svn-base
new file mode 100644
index 0000000..9c96b49
--- /dev/null
+++ b/package/system/utils/e2fsprogs/files/.svn/text-base/e2fsck.conf.svn-base
@@ -0,0 +1,3 @@
+[options]
+broken_system_clock = true
+
diff --git a/package/system/utils/e2fsprogs/files/.svn/text-base/e2fsck.sh.svn-base b/package/system/utils/e2fsprogs/files/.svn/text-base/e2fsck.sh.svn-base
new file mode 100644
index 0000000..22031ed
--- /dev/null
+++ b/package/system/utils/e2fsprogs/files/.svn/text-base/e2fsck.sh.svn-base
@@ -0,0 +1,38 @@
+#!/bin/sh
+# Copyright 2010 Vertical Communications
+# Copyright 2012 OpenWrt.org
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+fsck_e2fsck() {
+ set -o pipefail
+ e2fsck -p "$device" 2>&1 | logger -t "fstab: e2fsck ($device)"
+ local status="$?"
+ set +o pipefail
+ case "$status" in
+ 0|1) ;; #success
+ 2) reboot;;
+ 4) echo "e2fsck ($device): Warning! Uncorrected errors."| logger -t fstab
+ return 1
+ ;;
+ *) echo "e2fsck ($device): Error $status. Check not complete."| logger -t fstab;;
+ esac
+ return 0
+}
+
+fsck_ext2() {
+ fsck_e2fsck "$@"
+}
+
+fsck_ext3() {
+ fsck_e2fsck "$@"
+}
+
+fsck_ext4() {
+ fsck_e2fsck "$@"
+}
+
+append libmount_known_fsck "ext2"
+append libmount_known_fsck "ext3"
+append libmount_known_fsck "ext4"
diff --git a/package/system/utils/e2fsprogs/files/e2fsck.conf b/package/system/utils/e2fsprogs/files/e2fsck.conf
new file mode 100644
index 0000000..9c96b49
--- /dev/null
+++ b/package/system/utils/e2fsprogs/files/e2fsck.conf
@@ -0,0 +1,3 @@
+[options]
+broken_system_clock = true
+
diff --git a/package/system/utils/e2fsprogs/files/e2fsck.sh b/package/system/utils/e2fsprogs/files/e2fsck.sh
new file mode 100644
index 0000000..22031ed
--- /dev/null
+++ b/package/system/utils/e2fsprogs/files/e2fsck.sh
@@ -0,0 +1,38 @@
+#!/bin/sh
+# Copyright 2010 Vertical Communications
+# Copyright 2012 OpenWrt.org
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+fsck_e2fsck() {
+ set -o pipefail
+ e2fsck -p "$device" 2>&1 | logger -t "fstab: e2fsck ($device)"
+ local status="$?"
+ set +o pipefail
+ case "$status" in
+ 0|1) ;; #success
+ 2) reboot;;
+ 4) echo "e2fsck ($device): Warning! Uncorrected errors."| logger -t fstab
+ return 1
+ ;;
+ *) echo "e2fsck ($device): Error $status. Check not complete."| logger -t fstab;;
+ esac
+ return 0
+}
+
+fsck_ext2() {
+ fsck_e2fsck "$@"
+}
+
+fsck_ext3() {
+ fsck_e2fsck "$@"
+}
+
+fsck_ext4() {
+ fsck_e2fsck "$@"
+}
+
+append libmount_known_fsck "ext2"
+append libmount_known_fsck "ext3"
+append libmount_known_fsck "ext4"
diff --git a/package/system/utils/e2fsprogs/patches/.svn/entries b/package/system/utils/e2fsprogs/patches/.svn/entries
new file mode 100644
index 0000000..df7e90a
--- /dev/null
+++ b/package/system/utils/e2fsprogs/patches/.svn/entries
@@ -0,0 +1,96 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/system/utils/e2fsprogs/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-29T10:48:46.063504Z
+35375
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+002-no_malloc_h.patch
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+db14c4a8661c5baca981364df0acc46b
+2013-01-29T10:48:46.063504Z
+35375
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+195
+
+001-link-against-libuuid.patch
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+4bee56cfb835cafa926d833ba45e73fc
+2013-01-29T10:48:46.063504Z
+35375
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1424
+
diff --git a/package/system/utils/e2fsprogs/patches/.svn/text-base/001-link-against-libuuid.patch.svn-base b/package/system/utils/e2fsprogs/patches/.svn/text-base/001-link-against-libuuid.patch.svn-base
new file mode 100644
index 0000000..e0564dc
--- /dev/null
+++ b/package/system/utils/e2fsprogs/patches/.svn/text-base/001-link-against-libuuid.patch.svn-base
@@ -0,0 +1,38 @@
+--- a/configure
++++ b/configure
+@@ -5038,7 +5038,7 @@ if test "${ac_cv_lib_blkid_blkid_get_cac
+ $as_echo_n "(cached) " >&6
+ else
+ ac_check_lib_save_LIBS=$LIBS
+-LIBS="-lblkid $LIBBLKID $LIBS"
++LIBS="-lblkid $LIBBLKID $LIBUUID $LIBS"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h. */
+
+--- a/misc/Makefile.in
++++ b/misc/Makefile.in
+@@ -146,10 +146,10 @@ partinfo: partinfo.o
+ $(E) " LD $@"
+ $(Q) $(CC) $(ALL_LDFLAGS) -o partinfo partinfo.o
+
+-e2initrd_helper: e2initrd_helper.o $(DEPLIBS) $(DEPLIBBLKID) $(LIBEXT2FS)
++e2initrd_helper: e2initrd_helper.o $(DEPLIBS) $(DEPLIBBLKID) $(DEPLIBUUID) $(LIBEXT2FS)
+ $(E) " LD $@"
+ $(Q) $(CC) $(ALL_LDFLAGS) -o e2initrd_helper e2initrd_helper.o $(LIBS) \
+- $(LIBBLKID) $(LIBEXT2FS) $(LIBINTL)
++ $(LIBBLKID) $(LIBUUID) $(LIBEXT2FS) $(LIBINTL)
+
+ tune2fs: $(TUNE2FS_OBJS) $(DEPLIBS) $(DEPLIBS_E2P) $(DEPLIBBLKID) \
+ $(DEPLIBUUID) $(DEPLIBQUOTA) $(LIBEXT2FS)
+@@ -289,9 +289,9 @@ dumpe2fs.profiled: $(PROFILED_DUMPE2FS_O
+ $(PROFILED_DUMPE2FS_OBJS) $(PROFILED_LIBS) \
+ $(PROFILED_LIBE2P) $(PROFILED_LIBUUID) $(LIBINTL)
+
+-fsck: $(FSCK_OBJS) $(DEPLIBBLKID)
++fsck: $(FSCK_OBJS) $(DEPLIBBLKID) $(DEPLIBUUID)
+ $(E) " LD $@"
+- $(Q) $(CC) $(ALL_LDFLAGS) -o fsck $(FSCK_OBJS) $(LIBBLKID) $(LIBINTL)
++ $(Q) $(CC) $(ALL_LDFLAGS) -o fsck $(FSCK_OBJS) $(LIBBLKID) $(LIBUUID) $(LIBINTL)
+
+ fsck.profiled: $(PROFILED_FSCK_OBJS) $(PROFILED_DEPLIBBLKID)
+ $(E) " LD $@"
diff --git a/package/system/utils/e2fsprogs/patches/.svn/text-base/002-no_malloc_h.patch.svn-base b/package/system/utils/e2fsprogs/patches/.svn/text-base/002-no_malloc_h.patch.svn-base
new file mode 100644
index 0000000..209b47c
--- /dev/null
+++ b/package/system/utils/e2fsprogs/patches/.svn/text-base/002-no_malloc_h.patch.svn-base
@@ -0,0 +1,10 @@
+--- a/util/symlinks.c
++++ b/util/symlinks.c
+@@ -8,7 +8,6 @@
+ #endif
+ #include <stdio.h>
+ #include <stdlib.h>
+-#include <malloc.h>
+ #include <string.h>
+ #include <fcntl.h>
+ #include <sys/param.h>
diff --git a/package/system/utils/e2fsprogs/patches/001-link-against-libuuid.patch b/package/system/utils/e2fsprogs/patches/001-link-against-libuuid.patch
new file mode 100644
index 0000000..e0564dc
--- /dev/null
+++ b/package/system/utils/e2fsprogs/patches/001-link-against-libuuid.patch
@@ -0,0 +1,38 @@
+--- a/configure
++++ b/configure
+@@ -5038,7 +5038,7 @@ if test "${ac_cv_lib_blkid_blkid_get_cac
+ $as_echo_n "(cached) " >&6
+ else
+ ac_check_lib_save_LIBS=$LIBS
+-LIBS="-lblkid $LIBBLKID $LIBS"
++LIBS="-lblkid $LIBBLKID $LIBUUID $LIBS"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h. */
+
+--- a/misc/Makefile.in
++++ b/misc/Makefile.in
+@@ -146,10 +146,10 @@ partinfo: partinfo.o
+ $(E) " LD $@"
+ $(Q) $(CC) $(ALL_LDFLAGS) -o partinfo partinfo.o
+
+-e2initrd_helper: e2initrd_helper.o $(DEPLIBS) $(DEPLIBBLKID) $(LIBEXT2FS)
++e2initrd_helper: e2initrd_helper.o $(DEPLIBS) $(DEPLIBBLKID) $(DEPLIBUUID) $(LIBEXT2FS)
+ $(E) " LD $@"
+ $(Q) $(CC) $(ALL_LDFLAGS) -o e2initrd_helper e2initrd_helper.o $(LIBS) \
+- $(LIBBLKID) $(LIBEXT2FS) $(LIBINTL)
++ $(LIBBLKID) $(LIBUUID) $(LIBEXT2FS) $(LIBINTL)
+
+ tune2fs: $(TUNE2FS_OBJS) $(DEPLIBS) $(DEPLIBS_E2P) $(DEPLIBBLKID) \
+ $(DEPLIBUUID) $(DEPLIBQUOTA) $(LIBEXT2FS)
+@@ -289,9 +289,9 @@ dumpe2fs.profiled: $(PROFILED_DUMPE2FS_O
+ $(PROFILED_DUMPE2FS_OBJS) $(PROFILED_LIBS) \
+ $(PROFILED_LIBE2P) $(PROFILED_LIBUUID) $(LIBINTL)
+
+-fsck: $(FSCK_OBJS) $(DEPLIBBLKID)
++fsck: $(FSCK_OBJS) $(DEPLIBBLKID) $(DEPLIBUUID)
+ $(E) " LD $@"
+- $(Q) $(CC) $(ALL_LDFLAGS) -o fsck $(FSCK_OBJS) $(LIBBLKID) $(LIBINTL)
++ $(Q) $(CC) $(ALL_LDFLAGS) -o fsck $(FSCK_OBJS) $(LIBBLKID) $(LIBUUID) $(LIBINTL)
+
+ fsck.profiled: $(PROFILED_FSCK_OBJS) $(PROFILED_DEPLIBBLKID)
+ $(E) " LD $@"
diff --git a/package/system/utils/e2fsprogs/patches/002-no_malloc_h.patch b/package/system/utils/e2fsprogs/patches/002-no_malloc_h.patch
new file mode 100644
index 0000000..209b47c
--- /dev/null
+++ b/package/system/utils/e2fsprogs/patches/002-no_malloc_h.patch
@@ -0,0 +1,10 @@
+--- a/util/symlinks.c
++++ b/util/symlinks.c
+@@ -8,7 +8,6 @@
+ #endif
+ #include <stdio.h>
+ #include <stdlib.h>
+-#include <malloc.h>
+ #include <string.h>
+ #include <fcntl.h>
+ #include <sys/param.h>
diff --git a/package/system/utils/fbtest/.svn/entries b/package/system/utils/fbtest/.svn/entries
new file mode 100644
index 0000000..38f04ea
--- /dev/null
+++ b/package/system/utils/fbtest/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/system/utils/fbtest
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-29T10:48:46.063504Z
+35375
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+src
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+9d7e82003cd9c9abf90a757e03e934cb
+2013-01-29T10:48:46.063504Z
+35375
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+852
+
diff --git a/package/system/utils/fbtest/.svn/text-base/Makefile.svn-base b/package/system/utils/fbtest/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..05e67cb
--- /dev/null
+++ b/package/system/utils/fbtest/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,44 @@
+#
+# Copyright (C) 2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=fbtest
+PKG_RELEASE:=1
+
+PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/fbtest
+ SECTION:=utils
+ CATEGORY:=Utilities
+ TITLE:=Frame buffer device testing tool
+ DEPENDS:=@DISPLAY_SUPPORT
+endef
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ CC="$(TARGET_CC)" \
+ CFLAGS="$(TARGET_CFLAGS) -Wall" \
+ LDFLAGS="$(TARGET_LDFLAGS)"
+endef
+
+define Package/fbtest/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/fbtest $(1)/usr/sbin/
+endef
+
+$(eval $(call BuildPackage,fbtest))
diff --git a/package/system/utils/fbtest/Makefile b/package/system/utils/fbtest/Makefile
new file mode 100644
index 0000000..05e67cb
--- /dev/null
+++ b/package/system/utils/fbtest/Makefile
@@ -0,0 +1,44 @@
+#
+# Copyright (C) 2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=fbtest
+PKG_RELEASE:=1
+
+PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/fbtest
+ SECTION:=utils
+ CATEGORY:=Utilities
+ TITLE:=Frame buffer device testing tool
+ DEPENDS:=@DISPLAY_SUPPORT
+endef
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ CC="$(TARGET_CC)" \
+ CFLAGS="$(TARGET_CFLAGS) -Wall" \
+ LDFLAGS="$(TARGET_LDFLAGS)"
+endef
+
+define Package/fbtest/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/fbtest $(1)/usr/sbin/
+endef
+
+$(eval $(call BuildPackage,fbtest))
diff --git a/package/system/utils/fbtest/src/.svn/entries b/package/system/utils/fbtest/src/.svn/entries
new file mode 100644
index 0000000..bedc1b9
--- /dev/null
+++ b/package/system/utils/fbtest/src/.svn/entries
@@ -0,0 +1,96 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/system/utils/fbtest/src
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-29T10:48:46.063504Z
+35375
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+fbtest.c
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+a7cbc5a962814ab5b4f8d1d99ad2f6a2
+2013-01-29T10:48:46.063504Z
+35375
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+13344
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+5064fd2bdeaf6969c127941df6faafc9
+2013-01-29T10:48:46.063504Z
+35375
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+155
+
diff --git a/package/system/utils/fbtest/src/.svn/text-base/Makefile.svn-base b/package/system/utils/fbtest/src/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..075bc0e
--- /dev/null
+++ b/package/system/utils/fbtest/src/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,14 @@
+CC = gcc
+CFLAGS = -Wall
+OBJS = fbtest.o
+
+all: fbtest
+
+%.o: %.c
+ $(CC) $(CFLAGS) -c -o $@ $<
+
+fbtest: $(OBJS)
+ $(CC) -o $@ $(OBJS)
+
+clean:
+ rm -f rbcfg *.o
diff --git a/package/system/utils/fbtest/src/.svn/text-base/fbtest.c.svn-base b/package/system/utils/fbtest/src/.svn/text-base/fbtest.c.svn-base
new file mode 100644
index 0000000..6e9c2f8
--- /dev/null
+++ b/package/system/utils/fbtest/src/.svn/text-base/fbtest.c.svn-base
@@ -0,0 +1,448 @@
+/******************************************************************************
+ * fbtest - fbtest.c
+ * test program for the tuxbox-framebuffer device
+ * tests all GTX/eNX supported modes
+ *
+ * (c) 2003 Carsten Juttner (carjay@gmx.net)
+ *
+ * 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 of the License, 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; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ ******************************************************************************
+ * $Id: fbtest.c,v 1.5 2005/01/14 23:14:41 carjay Exp $
+ ******************************************************************************/
+
+// TODO: - should restore the colour map and mode to what it was before
+// - is colour map handled correctly?
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <fcntl.h>
+
+#include <linux/fb.h>
+
+#include <error.h>
+
+#define FBDEV "/dev/fb0"
+
+struct vidsize{
+ int width;
+ int height;
+};
+static
+const struct vidsize vidsizetable[]={ // all supported sizes
+ {720,576},{720,480},{720,288},{720,240},
+ {640,576},{640,480},{640,288},{640,240},
+ {360,576},{360,480},{360,288},{360,240},
+ {320,576},{320,480},{320,288},{320,240}
+};
+#define VIDSIZENUM (sizeof(vidsizetable)/sizeof(struct vidsize))
+
+enum pixenum{ // keep in sync with pixname !
+ CLUT4=0,
+ CLUT8,
+ RGB565,
+ ARGB1555,
+ ARGB
+};
+const char *pixname[] = {
+ "CLUT4",
+ "CLUT8",
+ "RGB565",
+ "ARGB1555",
+ "ARGB"
+};
+
+struct pixelformat{
+ char *name;
+ struct fb_bitfield red;
+ struct fb_bitfield green;
+ struct fb_bitfield blue;
+ struct fb_bitfield transp;
+ char bpp;
+ char pixenum;
+};
+
+static // so far these are all modes supported by the eNX (only partially by GTX)
+const struct pixelformat pixelformattable[] = {
+ { .name = "CLUT4 ARGB8888", // CLUT4 (ARGB8888)
+ .bpp = 4, .pixenum = CLUT4,
+ .red = { .offset = 0, .length=8, .msb_right =0 },
+ .green = { .offset = 0, .length=8, .msb_right =0 },
+ .blue = { .offset = 0, .length=8, .msb_right =0 },
+ .transp= { .offset = 0, .length=8, .msb_right =0 }
+ },
+ { .name = "CLUT4 ARGB1555", // CLUT4 (ARGB1555)
+ .bpp = 4, .pixenum = CLUT4,
+ .red = { .offset = 0, .length=5, .msb_right =0 },
+ .green = { .offset = 0, .length=5, .msb_right =0 },
+ .blue = { .offset = 0, .length=5, .msb_right =0 },
+ .transp= { .offset = 0, .length=1, .msb_right =0 }
+ },
+ { .name = "CLUT8 ARGB8888", // CLUT8 (ARGB8888)
+ .bpp = 8, .pixenum = CLUT8,
+ .red = { .offset = 0, .length=8, .msb_right =0 },
+ .green = { .offset = 0, .length=8, .msb_right =0 },
+ .blue = { .offset = 0, .length=8, .msb_right =0 },
+ .transp= { .offset = 0, .length=8, .msb_right =0 }
+ },
+ { .name = "CLUT8 ARGB1555", // CLUT8 (ARGB1555)
+ .bpp = 8, .pixenum = CLUT8,
+ .red = { .offset = 0, .length=5, .msb_right =0 },
+ .green = { .offset = 0, .length=5, .msb_right =0 },
+ .blue = { .offset = 0, .length=5, .msb_right =0 },
+ .transp= { .offset = 0, .length=1, .msb_right =0 }
+ },
+ { .name = "ARGB1555", // ARGB1555
+ .bpp = 16, .pixenum = ARGB1555,
+ .red = { .offset = 10, .length=5, .msb_right =0 },
+ .green = { .offset = 5, .length=5, .msb_right =0 },
+ .blue = { .offset = 0, .length=5, .msb_right =0 },
+ .transp= { .offset = 15, .length=1, .msb_right =0 }
+ },
+ { .name = "RGB565", // RGB565
+ .bpp = 16, .pixenum = RGB565,
+ .red = { .offset = 11, .length=5, .msb_right =0 },
+ .green = { .offset = 5, .length=6, .msb_right =0 },
+ .blue = { .offset = 0, .length=5, .msb_right =0 },
+ .transp= { .offset = 0, .length=0, .msb_right =0 }
+ },
+ { .name = "ARGB", // 32 f*cking bits, the real McCoy :)
+ .bpp = 32, .pixenum = ARGB,
+ .red = { .offset = 16, .length=8, .msb_right =0 },
+ .green = { .offset = 8, .length=8, .msb_right =0 },
+ .blue = { .offset = 0, .length=8, .msb_right =0 },
+ .transp= { .offset = 24, .length=8, .msb_right =0 }
+ }
+};
+#define PIXELFORMATNUM (sizeof(pixelformattable)/sizeof(struct pixelformat))
+
+struct colour {
+ __u16 r;
+ __u16 g;
+ __u16 b;
+ __u16 a;
+};
+static
+struct colour colourtable[] = {
+ {.r =0xffff, .g = 0xffff, .b=0xffff, .a=0xffff}, // fully transparent white
+ {.r =0xffff, .g = 0x0000, .b=0x0000, .a=0x0000}, // red
+ {.r =0x0000, .g = 0xffff, .b=0x0000, .a=0x0000}, // green
+ {.r =0x0000, .g = 0x0000, .b=0xffff, .a=0x0000}, // blue
+ {.r =0x0000, .g = 0x0000, .b=0x0000, .a=0x0000} // black
+};
+#define COLOURNUM (sizeof(colourtable)/sizeof(struct colour))
+
+struct rect{
+ int x;
+ int y;
+ int width;
+ int height;
+ const struct colour *col;
+};
+struct pixel{ // up to 32 bits of pixel information
+ char byte[4];
+};
+
+void col2pixel (struct pixel *pix, const struct pixelformat *pixf, const struct colour *col){
+ switch (pixf->pixenum){
+ case RGB565:
+ pix->byte[0]=(col->r&0xf8)|(col->g&0xfc)>>5;
+ pix->byte[1]=(col->g&0xfc)<<3|(col->b&0xf8)>>3;
+ break;
+ case ARGB1555:
+ pix->byte[0]=(col->a&0x80)|(col->r&0xf8)>>1|(col->g&0xf8)>>6;
+ pix->byte[1]=(col->g&0xf8)<<2|(col->b&0xf8)>>3;
+ break;
+ case ARGB:
+ pix->byte[0]=col->a;
+ pix->byte[1]=col->r;
+ pix->byte[2]=col->g;
+ pix->byte[3]=col->b;
+ break;
+ default:
+ printf ("unknown pixelformat\n");
+ exit(1);
+ }
+}
+
+int setmode(int fbd, const struct pixelformat *pixf,const struct vidsize *vids){
+ struct fb_var_screeninfo var;
+ int stat;
+ stat = ioctl (fbd, FBIOGET_VSCREENINFO,&var);
+ if (stat<0) return -2;
+
+ var.xres= vids->width;
+ var.xres_virtual = vids->width;
+ var.yres= vids->height;
+ var.yres_virtual = vids->height;
+
+ var.bits_per_pixel = pixf->bpp;
+ var.red = pixf->red;
+ var.green = pixf->green;
+ var.blue = pixf->blue;
+ var.transp = pixf->transp;
+
+ stat = ioctl (fbd, FBIOPUT_VSCREENINFO,&var);
+ if (stat<0) return -1;
+ return 0;
+}
+
+// unefficient implementation, do NOT use it for your next ego shooter, please :)
+// for 4-Bit only rectangles with even width are supported
+// CLUT-modes use value of red component as index
+void drawrect(void *videoram, struct rect *r, const struct pixelformat *pixf, const struct vidsize *vids){
+ int x,y,corwidth, bpp = 0, tocopy = 1;
+ struct pixel pix;
+ unsigned char *pmem = videoram;
+ corwidth = r->width; // actually only "corrected" for 4 Bit
+
+ if (pixf->pixenum!=CLUT4&&pixf->pixenum!=CLUT8){
+ switch (pixf->pixenum){
+ case ARGB1555:
+ case RGB565:
+ bpp = 16;
+ tocopy = 2;
+ break;
+ case ARGB:
+ bpp = 32;
+ tocopy = 4;
+ break;
+ default:
+ printf ("drawrect: unknown pixelformat(%d) bpp:%d\n",pixf->pixenum,pixf->bpp);
+ exit(1);
+ }
+ col2pixel(&pix,pixf,r->col);
+ } else {
+ switch (pixf->pixenum){ // CLUT = Colour LookUp Table (palette)
+ case CLUT4: // take red value as index in this case
+ pix.byte[0]=(r->col->r)<<4|(r->col->r&0xf); // slightly cryptic... "rect->colour->red"
+ corwidth>>=1; // we copy bytes
+ bpp=4;
+ tocopy=1;
+ break;
+ case CLUT8:
+ pix.byte[0]=(r->col->r&0xff);
+ bpp=8;
+ tocopy=1;
+ break;
+ }
+ }
+ pmem=videoram+((((r->y*vids->width)+r->x)*bpp)>>3);
+ for (y=0;y<r->height;y++){
+ int offset = 0;
+ for (x=0;x<corwidth;x++){
+ memcpy (pmem+offset,pix.byte,tocopy);
+ offset+=tocopy;
+ }
+ pmem +=((vids->width*bpp)>>3); // skip one whole line, actually should be taken from "fix-info"
+ }
+}
+
+// create quick little test image, 4 colours from table
+void draw4field(void *videoram, const struct pixelformat *pixf, const struct vidsize *vids){
+ struct rect r;
+ struct colour c;
+ int height, width;
+ c.r = 1; // only used for the indexed modes, r is taken as index
+ height = vids->height;
+ width = vids->width;
+
+ r.height = height>>1;
+ r.width = width>>1;
+ r.x = 0; r.y = 0;
+ if (pixf->pixenum==CLUT4||pixf->pixenum==CLUT8) r.col = &c;
+ else r.col = &colourtable[1];
+ drawrect (videoram, &r, pixf, vids);
+
+ r.x = width/2; r.y = 0;
+ if (pixf->pixenum==CLUT4||pixf->pixenum==CLUT8) c.r = 2;
+ else r.col = &colourtable[2];
+ drawrect (videoram, &r, pixf, vids);
+
+ r.x = 0; r.y = height/2;
+ if (pixf->pixenum==CLUT4||pixf->pixenum==CLUT8) c.r = 3;
+ else r.col = &colourtable[3];
+ drawrect (videoram, &r, pixf, vids);
+
+ r.x = width/2; r.y = height/2;
+ if (pixf->pixenum==CLUT4||pixf->pixenum==CLUT8) c.r = 0;
+ else r.col = &colourtable[0];
+ drawrect (videoram, &r, pixf, vids);
+}
+
+void usage(char *name){
+ printf ("Usage: %s [options]\n"
+ "Options: -f<pixelformat>\n"
+ " where format is one of:\n"
+ " CLUT4,CLUT8,ARGB1555,RGB565,ARGB\n"
+ " -s<width>x<heigth>\n"
+ " where width is either 720,640,360,320\n"
+ " and height is either 288,240,480,576\n"
+ " -n\n"
+ " disables clearing the framebuffer after drawing\n"
+ " the testimage. This can be useful to keep the last\n"
+ " drawn image onscreen.\n"
+ "\nExample: %s -fRGB322\n",name,name);
+ exit(0);
+}
+
+int main (int argc,char **argv){
+ struct fb_fix_screeninfo fix;
+ struct fb_var_screeninfo var;
+ struct fb_cmap cmap;
+ struct rect r;
+ int fbd;
+ unsigned char *pfb;
+ int stat;
+ int optchar,fmode=-1,smode=-1,clear=1;
+ int i_cmap,i_size,i_pix;
+ extern char *optarg;
+
+ if (argc!=0&&argc>4) usage(argv[0]);
+ while ( (optchar = getopt (argc,argv,"f:s:n"))!= -1){
+ int i,height,width;
+ switch (optchar){
+ case 'f':
+ for (i=0;i<(sizeof(pixname)/sizeof(char*));i++){
+ if (!strncmp (optarg,pixname[i],strlen(pixname[i]))){
+ fmode=i;
+ printf ("displaying only %s-modes\n",pixname[i]);
+ break;
+ }
+ }
+ if (fmode==-1){
+ printf ("unknown pixelformat\n");
+ exit(0);
+ }
+ break;
+ case 's':
+ if (sscanf (optarg,"%dx%d",&width,&height)!=2){
+ printf ("parsing size failed\n");
+ exit(0);
+ } else {
+ printf ("requested size %dx%d\n",width,height);
+ for (i=0;i<VIDSIZENUM;i++){
+ if (vidsizetable[i].width == width &&
+ vidsizetable[i].height == height){
+ smode = i;
+ break;
+ }
+ }
+ if (smode==-1){
+ printf ("this size is not supported\n");
+ exit(0);
+ }
+ }
+ break;
+ case 'n':
+ clear = 0;
+ printf ("clearing framebuffer after drawing is disabled\n");
+ break;
+ case '?':
+ usage (argv[0]);
+ }
+ }
+
+ fbd = open (FBDEV, O_RDWR);
+ if (fbd<0){
+ perror ("Error opening framebuffer device");
+ return 1;
+ }
+ stat = ioctl (fbd, FBIOGET_FSCREENINFO,&fix);
+ if (stat<0){
+ perror ("Error getting fix screeninfo");
+ return 1;
+ }
+ stat = ioctl (fbd, FBIOGET_VSCREENINFO,&var);
+ if (stat<0){
+ perror ("Error getting var screeninfo");
+ return 1;
+ }
+ stat = ioctl (fbd, FBIOPUT_VSCREENINFO,&var);
+ if (stat<0){
+ perror ("Error setting mode");
+ return 1;
+ }
+ pfb = mmap (0, fix.smem_len, PROT_READ|PROT_WRITE, MAP_SHARED, fbd, 0);
+ if (pfb == MAP_FAILED){
+ perror ("Error mmap'ing framebuffer device");
+ return 1;
+ }
+
+ // iterate over all modes
+ for (i_pix=0;i_pix<PIXELFORMATNUM;i_pix++){
+ if (fmode!=-1 && pixelformattable[i_pix].pixenum != fmode) continue;
+ printf ("testing: %s",pixelformattable[i_pix].name);
+ printf (" for sizes: \n");
+ for (i_size=0;i_size<VIDSIZENUM;i_size++){
+ if (smode!=-1 && i_size!=smode) continue;
+ printf ("%dx%d ",vidsizetable[i_size].width,vidsizetable[i_size].height);
+ fflush(stdout);
+ if ((i_size%4)==3) printf ("\n");
+
+ // try to set mode
+ stat = setmode(fbd,&pixelformattable[i_pix],&vidsizetable[i_size]);
+ if (stat==-2) perror ("fbtest: could not get fb_var-screeninfo from fb-device");
+ else if (stat==-1){
+ printf ("\nCould not set mode %s (%dx%d), possible reasons:\n"
+ "- you have a GTX (soz m8)\n"
+ "- your configuration does not have enough graphics RAM\n"
+ "- you found a bug\n"
+ "choose your poison accordingly...\n",
+ pixelformattable[i_pix].name,vidsizetable[i_size].width,vidsizetable[i_size].height);
+ continue;
+ }
+ // fill cmap;
+ cmap.len = 1;
+ if ((pixelformattable[i_pix].bpp==4)||
+ ((pixelformattable[i_pix].bpp==8)&&(pixelformattable[i_pix].red.length!=3))){
+ for (i_cmap=0;i_cmap<COLOURNUM;i_cmap++){
+ cmap.start=i_cmap;
+ cmap.red=&colourtable[i_cmap].r;
+ cmap.green=&colourtable[i_cmap].g;
+ cmap.blue=&colourtable[i_cmap].b;
+ cmap.transp=&colourtable[i_cmap].a;
+ stat = ioctl (fbd, FBIOPUTCMAP, &cmap);
+ if (stat<0) printf ("setting colourmap failed\n");
+ }
+ }
+ // create the test image
+ draw4field(pfb,&pixelformattable[i_pix],&vidsizetable[i_size]);
+ usleep (500000);
+ // clear screen
+ if (clear){
+ r.x=r.y=0;r.width = vidsizetable[i_size].width; r.height = vidsizetable[i_size].height;
+ r.col = &colourtable[4];
+ drawrect(pfb,&r,&pixelformattable[i_pix],&vidsizetable[i_size]);
+ }
+ }
+ printf ("\n");
+ }
+
+ stat = munmap (pfb,fix.smem_len);
+ if (stat<0){
+ perror ("Error munmap'ing framebuffer device");
+ return 1;
+ }
+ close (fbd);
+ return 0;
+}
diff --git a/package/system/utils/fbtest/src/Makefile b/package/system/utils/fbtest/src/Makefile
new file mode 100644
index 0000000..075bc0e
--- /dev/null
+++ b/package/system/utils/fbtest/src/Makefile
@@ -0,0 +1,14 @@
+CC = gcc
+CFLAGS = -Wall
+OBJS = fbtest.o
+
+all: fbtest
+
+%.o: %.c
+ $(CC) $(CFLAGS) -c -o $@ $<
+
+fbtest: $(OBJS)
+ $(CC) -o $@ $(OBJS)
+
+clean:
+ rm -f rbcfg *.o
diff --git a/package/system/utils/fbtest/src/fbtest.c b/package/system/utils/fbtest/src/fbtest.c
new file mode 100644
index 0000000..6e9c2f8
--- /dev/null
+++ b/package/system/utils/fbtest/src/fbtest.c
@@ -0,0 +1,448 @@
+/******************************************************************************
+ * fbtest - fbtest.c
+ * test program for the tuxbox-framebuffer device
+ * tests all GTX/eNX supported modes
+ *
+ * (c) 2003 Carsten Juttner (carjay@gmx.net)
+ *
+ * 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 of the License, 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; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ ******************************************************************************
+ * $Id: fbtest.c,v 1.5 2005/01/14 23:14:41 carjay Exp $
+ ******************************************************************************/
+
+// TODO: - should restore the colour map and mode to what it was before
+// - is colour map handled correctly?
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <fcntl.h>
+
+#include <linux/fb.h>
+
+#include <error.h>
+
+#define FBDEV "/dev/fb0"
+
+struct vidsize{
+ int width;
+ int height;
+};
+static
+const struct vidsize vidsizetable[]={ // all supported sizes
+ {720,576},{720,480},{720,288},{720,240},
+ {640,576},{640,480},{640,288},{640,240},
+ {360,576},{360,480},{360,288},{360,240},
+ {320,576},{320,480},{320,288},{320,240}
+};
+#define VIDSIZENUM (sizeof(vidsizetable)/sizeof(struct vidsize))
+
+enum pixenum{ // keep in sync with pixname !
+ CLUT4=0,
+ CLUT8,
+ RGB565,
+ ARGB1555,
+ ARGB
+};
+const char *pixname[] = {
+ "CLUT4",
+ "CLUT8",
+ "RGB565",
+ "ARGB1555",
+ "ARGB"
+};
+
+struct pixelformat{
+ char *name;
+ struct fb_bitfield red;
+ struct fb_bitfield green;
+ struct fb_bitfield blue;
+ struct fb_bitfield transp;
+ char bpp;
+ char pixenum;
+};
+
+static // so far these are all modes supported by the eNX (only partially by GTX)
+const struct pixelformat pixelformattable[] = {
+ { .name = "CLUT4 ARGB8888", // CLUT4 (ARGB8888)
+ .bpp = 4, .pixenum = CLUT4,
+ .red = { .offset = 0, .length=8, .msb_right =0 },
+ .green = { .offset = 0, .length=8, .msb_right =0 },
+ .blue = { .offset = 0, .length=8, .msb_right =0 },
+ .transp= { .offset = 0, .length=8, .msb_right =0 }
+ },
+ { .name = "CLUT4 ARGB1555", // CLUT4 (ARGB1555)
+ .bpp = 4, .pixenum = CLUT4,
+ .red = { .offset = 0, .length=5, .msb_right =0 },
+ .green = { .offset = 0, .length=5, .msb_right =0 },
+ .blue = { .offset = 0, .length=5, .msb_right =0 },
+ .transp= { .offset = 0, .length=1, .msb_right =0 }
+ },
+ { .name = "CLUT8 ARGB8888", // CLUT8 (ARGB8888)
+ .bpp = 8, .pixenum = CLUT8,
+ .red = { .offset = 0, .length=8, .msb_right =0 },
+ .green = { .offset = 0, .length=8, .msb_right =0 },
+ .blue = { .offset = 0, .length=8, .msb_right =0 },
+ .transp= { .offset = 0, .length=8, .msb_right =0 }
+ },
+ { .name = "CLUT8 ARGB1555", // CLUT8 (ARGB1555)
+ .bpp = 8, .pixenum = CLUT8,
+ .red = { .offset = 0, .length=5, .msb_right =0 },
+ .green = { .offset = 0, .length=5, .msb_right =0 },
+ .blue = { .offset = 0, .length=5, .msb_right =0 },
+ .transp= { .offset = 0, .length=1, .msb_right =0 }
+ },
+ { .name = "ARGB1555", // ARGB1555
+ .bpp = 16, .pixenum = ARGB1555,
+ .red = { .offset = 10, .length=5, .msb_right =0 },
+ .green = { .offset = 5, .length=5, .msb_right =0 },
+ .blue = { .offset = 0, .length=5, .msb_right =0 },
+ .transp= { .offset = 15, .length=1, .msb_right =0 }
+ },
+ { .name = "RGB565", // RGB565
+ .bpp = 16, .pixenum = RGB565,
+ .red = { .offset = 11, .length=5, .msb_right =0 },
+ .green = { .offset = 5, .length=6, .msb_right =0 },
+ .blue = { .offset = 0, .length=5, .msb_right =0 },
+ .transp= { .offset = 0, .length=0, .msb_right =0 }
+ },
+ { .name = "ARGB", // 32 f*cking bits, the real McCoy :)
+ .bpp = 32, .pixenum = ARGB,
+ .red = { .offset = 16, .length=8, .msb_right =0 },
+ .green = { .offset = 8, .length=8, .msb_right =0 },
+ .blue = { .offset = 0, .length=8, .msb_right =0 },
+ .transp= { .offset = 24, .length=8, .msb_right =0 }
+ }
+};
+#define PIXELFORMATNUM (sizeof(pixelformattable)/sizeof(struct pixelformat))
+
+struct colour {
+ __u16 r;
+ __u16 g;
+ __u16 b;
+ __u16 a;
+};
+static
+struct colour colourtable[] = {
+ {.r =0xffff, .g = 0xffff, .b=0xffff, .a=0xffff}, // fully transparent white
+ {.r =0xffff, .g = 0x0000, .b=0x0000, .a=0x0000}, // red
+ {.r =0x0000, .g = 0xffff, .b=0x0000, .a=0x0000}, // green
+ {.r =0x0000, .g = 0x0000, .b=0xffff, .a=0x0000}, // blue
+ {.r =0x0000, .g = 0x0000, .b=0x0000, .a=0x0000} // black
+};
+#define COLOURNUM (sizeof(colourtable)/sizeof(struct colour))
+
+struct rect{
+ int x;
+ int y;
+ int width;
+ int height;
+ const struct colour *col;
+};
+struct pixel{ // up to 32 bits of pixel information
+ char byte[4];
+};
+
+void col2pixel (struct pixel *pix, const struct pixelformat *pixf, const struct colour *col){
+ switch (pixf->pixenum){
+ case RGB565:
+ pix->byte[0]=(col->r&0xf8)|(col->g&0xfc)>>5;
+ pix->byte[1]=(col->g&0xfc)<<3|(col->b&0xf8)>>3;
+ break;
+ case ARGB1555:
+ pix->byte[0]=(col->a&0x80)|(col->r&0xf8)>>1|(col->g&0xf8)>>6;
+ pix->byte[1]=(col->g&0xf8)<<2|(col->b&0xf8)>>3;
+ break;
+ case ARGB:
+ pix->byte[0]=col->a;
+ pix->byte[1]=col->r;
+ pix->byte[2]=col->g;
+ pix->byte[3]=col->b;
+ break;
+ default:
+ printf ("unknown pixelformat\n");
+ exit(1);
+ }
+}
+
+int setmode(int fbd, const struct pixelformat *pixf,const struct vidsize *vids){
+ struct fb_var_screeninfo var;
+ int stat;
+ stat = ioctl (fbd, FBIOGET_VSCREENINFO,&var);
+ if (stat<0) return -2;
+
+ var.xres= vids->width;
+ var.xres_virtual = vids->width;
+ var.yres= vids->height;
+ var.yres_virtual = vids->height;
+
+ var.bits_per_pixel = pixf->bpp;
+ var.red = pixf->red;
+ var.green = pixf->green;
+ var.blue = pixf->blue;
+ var.transp = pixf->transp;
+
+ stat = ioctl (fbd, FBIOPUT_VSCREENINFO,&var);
+ if (stat<0) return -1;
+ return 0;
+}
+
+// unefficient implementation, do NOT use it for your next ego shooter, please :)
+// for 4-Bit only rectangles with even width are supported
+// CLUT-modes use value of red component as index
+void drawrect(void *videoram, struct rect *r, const struct pixelformat *pixf, const struct vidsize *vids){
+ int x,y,corwidth, bpp = 0, tocopy = 1;
+ struct pixel pix;
+ unsigned char *pmem = videoram;
+ corwidth = r->width; // actually only "corrected" for 4 Bit
+
+ if (pixf->pixenum!=CLUT4&&pixf->pixenum!=CLUT8){
+ switch (pixf->pixenum){
+ case ARGB1555:
+ case RGB565:
+ bpp = 16;
+ tocopy = 2;
+ break;
+ case ARGB:
+ bpp = 32;
+ tocopy = 4;
+ break;
+ default:
+ printf ("drawrect: unknown pixelformat(%d) bpp:%d\n",pixf->pixenum,pixf->bpp);
+ exit(1);
+ }
+ col2pixel(&pix,pixf,r->col);
+ } else {
+ switch (pixf->pixenum){ // CLUT = Colour LookUp Table (palette)
+ case CLUT4: // take red value as index in this case
+ pix.byte[0]=(r->col->r)<<4|(r->col->r&0xf); // slightly cryptic... "rect->colour->red"
+ corwidth>>=1; // we copy bytes
+ bpp=4;
+ tocopy=1;
+ break;
+ case CLUT8:
+ pix.byte[0]=(r->col->r&0xff);
+ bpp=8;
+ tocopy=1;
+ break;
+ }
+ }
+ pmem=videoram+((((r->y*vids->width)+r->x)*bpp)>>3);
+ for (y=0;y<r->height;y++){
+ int offset = 0;
+ for (x=0;x<corwidth;x++){
+ memcpy (pmem+offset,pix.byte,tocopy);
+ offset+=tocopy;
+ }
+ pmem +=((vids->width*bpp)>>3); // skip one whole line, actually should be taken from "fix-info"
+ }
+}
+
+// create quick little test image, 4 colours from table
+void draw4field(void *videoram, const struct pixelformat *pixf, const struct vidsize *vids){
+ struct rect r;
+ struct colour c;
+ int height, width;
+ c.r = 1; // only used for the indexed modes, r is taken as index
+ height = vids->height;
+ width = vids->width;
+
+ r.height = height>>1;
+ r.width = width>>1;
+ r.x = 0; r.y = 0;
+ if (pixf->pixenum==CLUT4||pixf->pixenum==CLUT8) r.col = &c;
+ else r.col = &colourtable[1];
+ drawrect (videoram, &r, pixf, vids);
+
+ r.x = width/2; r.y = 0;
+ if (pixf->pixenum==CLUT4||pixf->pixenum==CLUT8) c.r = 2;
+ else r.col = &colourtable[2];
+ drawrect (videoram, &r, pixf, vids);
+
+ r.x = 0; r.y = height/2;
+ if (pixf->pixenum==CLUT4||pixf->pixenum==CLUT8) c.r = 3;
+ else r.col = &colourtable[3];
+ drawrect (videoram, &r, pixf, vids);
+
+ r.x = width/2; r.y = height/2;
+ if (pixf->pixenum==CLUT4||pixf->pixenum==CLUT8) c.r = 0;
+ else r.col = &colourtable[0];
+ drawrect (videoram, &r, pixf, vids);
+}
+
+void usage(char *name){
+ printf ("Usage: %s [options]\n"
+ "Options: -f<pixelformat>\n"
+ " where format is one of:\n"
+ " CLUT4,CLUT8,ARGB1555,RGB565,ARGB\n"
+ " -s<width>x<heigth>\n"
+ " where width is either 720,640,360,320\n"
+ " and height is either 288,240,480,576\n"
+ " -n\n"
+ " disables clearing the framebuffer after drawing\n"
+ " the testimage. This can be useful to keep the last\n"
+ " drawn image onscreen.\n"
+ "\nExample: %s -fRGB322\n",name,name);
+ exit(0);
+}
+
+int main (int argc,char **argv){
+ struct fb_fix_screeninfo fix;
+ struct fb_var_screeninfo var;
+ struct fb_cmap cmap;
+ struct rect r;
+ int fbd;
+ unsigned char *pfb;
+ int stat;
+ int optchar,fmode=-1,smode=-1,clear=1;
+ int i_cmap,i_size,i_pix;
+ extern char *optarg;
+
+ if (argc!=0&&argc>4) usage(argv[0]);
+ while ( (optchar = getopt (argc,argv,"f:s:n"))!= -1){
+ int i,height,width;
+ switch (optchar){
+ case 'f':
+ for (i=0;i<(sizeof(pixname)/sizeof(char*));i++){
+ if (!strncmp (optarg,pixname[i],strlen(pixname[i]))){
+ fmode=i;
+ printf ("displaying only %s-modes\n",pixname[i]);
+ break;
+ }
+ }
+ if (fmode==-1){
+ printf ("unknown pixelformat\n");
+ exit(0);
+ }
+ break;
+ case 's':
+ if (sscanf (optarg,"%dx%d",&width,&height)!=2){
+ printf ("parsing size failed\n");
+ exit(0);
+ } else {
+ printf ("requested size %dx%d\n",width,height);
+ for (i=0;i<VIDSIZENUM;i++){
+ if (vidsizetable[i].width == width &&
+ vidsizetable[i].height == height){
+ smode = i;
+ break;
+ }
+ }
+ if (smode==-1){
+ printf ("this size is not supported\n");
+ exit(0);
+ }
+ }
+ break;
+ case 'n':
+ clear = 0;
+ printf ("clearing framebuffer after drawing is disabled\n");
+ break;
+ case '?':
+ usage (argv[0]);
+ }
+ }
+
+ fbd = open (FBDEV, O_RDWR);
+ if (fbd<0){
+ perror ("Error opening framebuffer device");
+ return 1;
+ }
+ stat = ioctl (fbd, FBIOGET_FSCREENINFO,&fix);
+ if (stat<0){
+ perror ("Error getting fix screeninfo");
+ return 1;
+ }
+ stat = ioctl (fbd, FBIOGET_VSCREENINFO,&var);
+ if (stat<0){
+ perror ("Error getting var screeninfo");
+ return 1;
+ }
+ stat = ioctl (fbd, FBIOPUT_VSCREENINFO,&var);
+ if (stat<0){
+ perror ("Error setting mode");
+ return 1;
+ }
+ pfb = mmap (0, fix.smem_len, PROT_READ|PROT_WRITE, MAP_SHARED, fbd, 0);
+ if (pfb == MAP_FAILED){
+ perror ("Error mmap'ing framebuffer device");
+ return 1;
+ }
+
+ // iterate over all modes
+ for (i_pix=0;i_pix<PIXELFORMATNUM;i_pix++){
+ if (fmode!=-1 && pixelformattable[i_pix].pixenum != fmode) continue;
+ printf ("testing: %s",pixelformattable[i_pix].name);
+ printf (" for sizes: \n");
+ for (i_size=0;i_size<VIDSIZENUM;i_size++){
+ if (smode!=-1 && i_size!=smode) continue;
+ printf ("%dx%d ",vidsizetable[i_size].width,vidsizetable[i_size].height);
+ fflush(stdout);
+ if ((i_size%4)==3) printf ("\n");
+
+ // try to set mode
+ stat = setmode(fbd,&pixelformattable[i_pix],&vidsizetable[i_size]);
+ if (stat==-2) perror ("fbtest: could not get fb_var-screeninfo from fb-device");
+ else if (stat==-1){
+ printf ("\nCould not set mode %s (%dx%d), possible reasons:\n"
+ "- you have a GTX (soz m8)\n"
+ "- your configuration does not have enough graphics RAM\n"
+ "- you found a bug\n"
+ "choose your poison accordingly...\n",
+ pixelformattable[i_pix].name,vidsizetable[i_size].width,vidsizetable[i_size].height);
+ continue;
+ }
+ // fill cmap;
+ cmap.len = 1;
+ if ((pixelformattable[i_pix].bpp==4)||
+ ((pixelformattable[i_pix].bpp==8)&&(pixelformattable[i_pix].red.length!=3))){
+ for (i_cmap=0;i_cmap<COLOURNUM;i_cmap++){
+ cmap.start=i_cmap;
+ cmap.red=&colourtable[i_cmap].r;
+ cmap.green=&colourtable[i_cmap].g;
+ cmap.blue=&colourtable[i_cmap].b;
+ cmap.transp=&colourtable[i_cmap].a;
+ stat = ioctl (fbd, FBIOPUTCMAP, &cmap);
+ if (stat<0) printf ("setting colourmap failed\n");
+ }
+ }
+ // create the test image
+ draw4field(pfb,&pixelformattable[i_pix],&vidsizetable[i_size]);
+ usleep (500000);
+ // clear screen
+ if (clear){
+ r.x=r.y=0;r.width = vidsizetable[i_size].width; r.height = vidsizetable[i_size].height;
+ r.col = &colourtable[4];
+ drawrect(pfb,&r,&pixelformattable[i_pix],&vidsizetable[i_size]);
+ }
+ }
+ printf ("\n");
+ }
+
+ stat = munmap (pfb,fix.smem_len);
+ if (stat<0){
+ perror ("Error munmap'ing framebuffer device");
+ return 1;
+ }
+ close (fbd);
+ return 0;
+}
diff --git a/package/system/utils/hostap-utils/.svn/entries b/package/system/utils/hostap-utils/.svn/entries
new file mode 100644
index 0000000..2cd1975
--- /dev/null
+++ b/package/system/utils/hostap-utils/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/system/utils/hostap-utils
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-29T10:48:46.063504Z
+35375
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+463e5393756bb4489a083691a9c91b06
+2013-01-29T10:48:46.063504Z
+35375
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1222
+
diff --git a/package/system/utils/hostap-utils/.svn/prop-base/Makefile.svn-base b/package/system/utils/hostap-utils/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..8e522ae
--- /dev/null
+++ b/package/system/utils/hostap-utils/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:copyright
+V 30
+Copyright (C) 2006 OpenWrt.org
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/system/utils/hostap-utils/.svn/text-base/Makefile.svn-base b/package/system/utils/hostap-utils/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..1d7b221
--- /dev/null
+++ b/package/system/utils/hostap-utils/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,44 @@
+# Copyright (C) 2006 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=hostap-utils
+PKG_VERSION:=0.4.7
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://hostap.epitest.fi/releases/
+PKG_MD5SUM:=afe041581b8f01666e353bec20917c85
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/hostap-utils
+ SECTION:=net
+ CATEGORY:=Network
+ DEPENDS:=kmod-hostap
+ TITLE:=Host AP driver utility programs
+ URL:=http://hostap.epitest.fi/
+endef
+
+define Build/Compile
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ $(TARGET_CONFIGURE_OPTS) \
+ CFLAGS="$(TARGET_CFLAGS) $(TARGET_CPPFLAGS) -Wall" \
+ all
+endef
+
+define Package/hostap-utils/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/hostap_crypt_conf $(1)/usr/sbin/
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/hostap_diag $(1)/usr/sbin/
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/hostap_io_debug $(1)/usr/sbin/
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/hostap_rid $(1)/usr/sbin/
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/prism2_srec $(1)/usr/sbin/
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/split_combined_hex $(1)/usr/sbin/
+endef
+
+$(eval $(call BuildPackage,hostap-utils))
diff --git a/package/system/utils/hostap-utils/Makefile b/package/system/utils/hostap-utils/Makefile
new file mode 100644
index 0000000..1d7b221
--- /dev/null
+++ b/package/system/utils/hostap-utils/Makefile
@@ -0,0 +1,44 @@
+# Copyright (C) 2006 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=hostap-utils
+PKG_VERSION:=0.4.7
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://hostap.epitest.fi/releases/
+PKG_MD5SUM:=afe041581b8f01666e353bec20917c85
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/hostap-utils
+ SECTION:=net
+ CATEGORY:=Network
+ DEPENDS:=kmod-hostap
+ TITLE:=Host AP driver utility programs
+ URL:=http://hostap.epitest.fi/
+endef
+
+define Build/Compile
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ $(TARGET_CONFIGURE_OPTS) \
+ CFLAGS="$(TARGET_CFLAGS) $(TARGET_CPPFLAGS) -Wall" \
+ all
+endef
+
+define Package/hostap-utils/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/hostap_crypt_conf $(1)/usr/sbin/
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/hostap_diag $(1)/usr/sbin/
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/hostap_io_debug $(1)/usr/sbin/
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/hostap_rid $(1)/usr/sbin/
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/prism2_srec $(1)/usr/sbin/
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/split_combined_hex $(1)/usr/sbin/
+endef
+
+$(eval $(call BuildPackage,hostap-utils))
diff --git a/package/system/utils/nvram/.svn/entries b/package/system/utils/nvram/.svn/entries
new file mode 100644
index 0000000..c64a29f
--- /dev/null
+++ b/package/system/utils/nvram/.svn/entries
@@ -0,0 +1,68 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/system/utils/nvram
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-29T10:48:46.063504Z
+35375
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+files
+dir
+
+src
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+23e358399ad70e12dead29ca90b84a59
+2013-01-29T10:48:46.063504Z
+35375
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1500
+
diff --git a/package/system/utils/nvram/.svn/text-base/Makefile.svn-base b/package/system/utils/nvram/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..81cff03
--- /dev/null
+++ b/package/system/utils/nvram/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,60 @@
+#
+# Copyright (C) 2009-2010 Jo-Philipp Wich <xm@subsignal.org>
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=nvram
+PKG_RELEASE:=9
+
+PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/nvram
+ SECTION:=utils
+ CATEGORY:=Base system
+ TITLE:=Userspace port of the Broadcom NVRAM manipulation tool
+ MAINTAINER:=Jo-Philipp Wich <xm@subsignal.org>
+ DEPENDS:=@TARGET_brcm47xx||@TARGET_ar71xx
+endef
+
+define Package/nvram/description
+ This package contains an utility to manipulate NVRAM on Broadcom based devices.
+ It works on bcm47xx (Linux 2.6) without using the kernel api.
+endef
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ CC="$(TARGET_CC)" \
+ CFLAGS="$(TARGET_CFLAGS) -Wall" \
+ LDFLAGS="$(TARGET_LDFLAGS)"
+endef
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/libnvram.so.0.1 $(1)/usr/lib/
+ ln -s libnvram.so.0.1 $(1)/usr/lib/libnvram.so
+endef
+
+define Package/nvram/install
+ $(INSTALL_DIR) $(1)/etc/init.d
+ $(INSTALL_BIN) ./files/nvram.init $(1)/etc/init.d/nvram
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/nvram $(1)/usr/sbin/
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/libnvram.so.0.1 $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,nvram))
diff --git a/package/system/utils/nvram/Makefile b/package/system/utils/nvram/Makefile
new file mode 100644
index 0000000..81cff03
--- /dev/null
+++ b/package/system/utils/nvram/Makefile
@@ -0,0 +1,60 @@
+#
+# Copyright (C) 2009-2010 Jo-Philipp Wich <xm@subsignal.org>
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=nvram
+PKG_RELEASE:=9
+
+PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/nvram
+ SECTION:=utils
+ CATEGORY:=Base system
+ TITLE:=Userspace port of the Broadcom NVRAM manipulation tool
+ MAINTAINER:=Jo-Philipp Wich <xm@subsignal.org>
+ DEPENDS:=@TARGET_brcm47xx||@TARGET_ar71xx
+endef
+
+define Package/nvram/description
+ This package contains an utility to manipulate NVRAM on Broadcom based devices.
+ It works on bcm47xx (Linux 2.6) without using the kernel api.
+endef
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ CC="$(TARGET_CC)" \
+ CFLAGS="$(TARGET_CFLAGS) -Wall" \
+ LDFLAGS="$(TARGET_LDFLAGS)"
+endef
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/libnvram.so.0.1 $(1)/usr/lib/
+ ln -s libnvram.so.0.1 $(1)/usr/lib/libnvram.so
+endef
+
+define Package/nvram/install
+ $(INSTALL_DIR) $(1)/etc/init.d
+ $(INSTALL_BIN) ./files/nvram.init $(1)/etc/init.d/nvram
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/nvram $(1)/usr/sbin/
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/libnvram.so.0.1 $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,nvram))
diff --git a/package/system/utils/nvram/files/.svn/entries b/package/system/utils/nvram/files/.svn/entries
new file mode 100644
index 0000000..a75fe7f
--- /dev/null
+++ b/package/system/utils/nvram/files/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/system/utils/nvram/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-29T10:48:46.063504Z
+35375
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+nvram.init
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+43e91cba2ad72e0ead0e24caa80ba66e
+2013-01-29T10:48:46.063504Z
+35375
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2991
+
diff --git a/package/system/utils/nvram/files/.svn/prop-base/nvram.init.svn-base b/package/system/utils/nvram/files/.svn/prop-base/nvram.init.svn-base
new file mode 100644
index 0000000..869ac71
--- /dev/null
+++ b/package/system/utils/nvram/files/.svn/prop-base/nvram.init.svn-base
@@ -0,0 +1,5 @@
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/system/utils/nvram/files/.svn/text-base/nvram.init.svn-base b/package/system/utils/nvram/files/.svn/text-base/nvram.init.svn-base
new file mode 100644
index 0000000..467ab28
--- /dev/null
+++ b/package/system/utils/nvram/files/.svn/text-base/nvram.init.svn-base
@@ -0,0 +1,98 @@
+#!/bin/sh /etc/rc.common
+# NVRAM setup
+#
+# This file handles the NVRAM quirks of various hardware.
+
+START=02
+alias debug=${DEBUG:-:}
+
+nvram_default() {
+ [ -z "$(nvram get $1)" ] && nvram set "$1=$2"
+}
+
+nvram_set() { # for the linksys fixup part
+ [ "$(nvram get "$1")" = "$2" -a "$2" != "" ] || {
+ COMMIT=1
+ /usr/sbin/nvram set "$1=$2"
+ }
+}
+
+fixup_linksys() {
+ # work around braindead CFE defaults in linksys routers
+ boardtype=$(nvram get boardtype)
+ boardnum=$(nvram get boardnum)
+ boardflags=$(($(nvram get boardflags)))
+ adm_switch="$(( ($boardflags & 0x80) >> 7 ))"
+
+ [ -n "$(nvram get vxkilled)" ] && boardtype=0 # don't mess with the ram settings on the hacked cfe
+ case "$(( $boardtype ))" in
+ "1800") #0x708
+ if [ "$adm_switch" = 0 ]; then
+ nvram_set sdram_init "$(printf 0x%04x $(( $(/usr/sbin/nvram get sdram_init) | 0x0100 )))"
+ [ "$COMMIT" = 1 ] && {
+ nvram_set clkfreq 216
+ nvram_set sdram_ncdl 0x0
+ nvram_set pa0itssit 62
+ nvram_set pa0b0 0x15eb
+ nvram_set pa0b1 0xfa82
+ nvram_set pa0b2 0xfe66
+ nvram_set pa0maxpwr 0x4e
+ }
+ fi
+ ;;
+ "1127") #0x467
+ nvram_set sdram_init "$(printf 0x%04x $(( $(/usr/sbin/nvram get sdram_init) | 0x0100 )))"
+ [ "$COMMIT" = 1 ] && {
+ nvram_set sdram_ncdl 0x0
+ nvram_set pa0itssit 62
+ nvram_set pa0b0 0x168b
+ nvram_set pa0b1 0xfabf
+ nvram_set pa0b2 0xfeaf
+ nvram_set pa0maxpwr 0x4e
+ }
+ ;;
+ "1071") #0x042f
+ # do sanity check first! max 0x0011 = 128mb
+ SDRAM_INIT=$(printf %d $(/usr/sbin/nvram get sdram_init))
+ [ "$SDRAM_INIT" -lt "9" -o "$SDRAM_INIT" -gt "17" ] && {
+ # set this to default: 0x09 only if value is invaild like 16MB on Asus WL-500GP
+ echo "sdram_init is invaild: $(printf 0x%04x $SDRAM_INIT), force to default!"
+ nvram_set sdram_init 0x0009
+ }
+ # on WRT54G3GV2 set flag, so checksum errors of firmware image 2 don't stop the boot process
+ noset_try_flag=$(nvram get noset_try_flag)
+ [ "$noset_try_flag" = 0 ] && {
+ echo "setting noset_try_flag to 1."
+ nvram_set noset_try_flag 1
+ }
+ [ "$COMMIT" = 1 ] && {
+ nvram_set sdram_ncdl 0x0
+ }
+ esac
+}
+
+start() {
+ # Don't do any fixups on the WGT634U
+ [ "$(cat /proc/diag/model)" = "Netgear WGT634U" ] && return
+
+ fixup_linksys
+
+ # OFDM Power Offset is set incorrectly on many boards.
+ # Setting it to 0 will increase the tx power to normal levels.
+ nvram_set opo 0x0
+
+ [ "$(nvram get il0macaddr)" = "00:90:4c:5f:00:2a" ] && {
+ # if default wifi mac, set two higher than the lan mac
+ nvram set il0macaddr=$(nvram get et0macaddr|
+ awk '{OFS=FS=":";for(x=7,y=2;--x;){$x=sprintf("%02x",(y+="0x"$x)%256);y/=256}print}')
+ }
+
+ [ "$(nvram get et0macaddr)" = "00:90:4c:c0:00:08" ] && {
+ # OvisLink WL-1600GL mac workaround
+ nvram set et0macaddr=$(hexdump -n 6 -s 130976 -e '5/1 "%02x:" "%02x" ' /dev/mtd/0)
+ nvram set il0macaddr=$(nvram get et0macaddr|
+ awk '{OFS=FS=":";for(x=7,y=2;--x;){$x=sprintf("%02x",(y+="0x"$x)%256);y/=256}print}')
+ }
+
+ [ "$COMMIT" = "1" ] && nvram commit
+}
diff --git a/package/system/utils/nvram/files/nvram.init b/package/system/utils/nvram/files/nvram.init
new file mode 100755
index 0000000..467ab28
--- /dev/null
+++ b/package/system/utils/nvram/files/nvram.init
@@ -0,0 +1,98 @@
+#!/bin/sh /etc/rc.common
+# NVRAM setup
+#
+# This file handles the NVRAM quirks of various hardware.
+
+START=02
+alias debug=${DEBUG:-:}
+
+nvram_default() {
+ [ -z "$(nvram get $1)" ] && nvram set "$1=$2"
+}
+
+nvram_set() { # for the linksys fixup part
+ [ "$(nvram get "$1")" = "$2" -a "$2" != "" ] || {
+ COMMIT=1
+ /usr/sbin/nvram set "$1=$2"
+ }
+}
+
+fixup_linksys() {
+ # work around braindead CFE defaults in linksys routers
+ boardtype=$(nvram get boardtype)
+ boardnum=$(nvram get boardnum)
+ boardflags=$(($(nvram get boardflags)))
+ adm_switch="$(( ($boardflags & 0x80) >> 7 ))"
+
+ [ -n "$(nvram get vxkilled)" ] && boardtype=0 # don't mess with the ram settings on the hacked cfe
+ case "$(( $boardtype ))" in
+ "1800") #0x708
+ if [ "$adm_switch" = 0 ]; then
+ nvram_set sdram_init "$(printf 0x%04x $(( $(/usr/sbin/nvram get sdram_init) | 0x0100 )))"
+ [ "$COMMIT" = 1 ] && {
+ nvram_set clkfreq 216
+ nvram_set sdram_ncdl 0x0
+ nvram_set pa0itssit 62
+ nvram_set pa0b0 0x15eb
+ nvram_set pa0b1 0xfa82
+ nvram_set pa0b2 0xfe66
+ nvram_set pa0maxpwr 0x4e
+ }
+ fi
+ ;;
+ "1127") #0x467
+ nvram_set sdram_init "$(printf 0x%04x $(( $(/usr/sbin/nvram get sdram_init) | 0x0100 )))"
+ [ "$COMMIT" = 1 ] && {
+ nvram_set sdram_ncdl 0x0
+ nvram_set pa0itssit 62
+ nvram_set pa0b0 0x168b
+ nvram_set pa0b1 0xfabf
+ nvram_set pa0b2 0xfeaf
+ nvram_set pa0maxpwr 0x4e
+ }
+ ;;
+ "1071") #0x042f
+ # do sanity check first! max 0x0011 = 128mb
+ SDRAM_INIT=$(printf %d $(/usr/sbin/nvram get sdram_init))
+ [ "$SDRAM_INIT" -lt "9" -o "$SDRAM_INIT" -gt "17" ] && {
+ # set this to default: 0x09 only if value is invaild like 16MB on Asus WL-500GP
+ echo "sdram_init is invaild: $(printf 0x%04x $SDRAM_INIT), force to default!"
+ nvram_set sdram_init 0x0009
+ }
+ # on WRT54G3GV2 set flag, so checksum errors of firmware image 2 don't stop the boot process
+ noset_try_flag=$(nvram get noset_try_flag)
+ [ "$noset_try_flag" = 0 ] && {
+ echo "setting noset_try_flag to 1."
+ nvram_set noset_try_flag 1
+ }
+ [ "$COMMIT" = 1 ] && {
+ nvram_set sdram_ncdl 0x0
+ }
+ esac
+}
+
+start() {
+ # Don't do any fixups on the WGT634U
+ [ "$(cat /proc/diag/model)" = "Netgear WGT634U" ] && return
+
+ fixup_linksys
+
+ # OFDM Power Offset is set incorrectly on many boards.
+ # Setting it to 0 will increase the tx power to normal levels.
+ nvram_set opo 0x0
+
+ [ "$(nvram get il0macaddr)" = "00:90:4c:5f:00:2a" ] && {
+ # if default wifi mac, set two higher than the lan mac
+ nvram set il0macaddr=$(nvram get et0macaddr|
+ awk '{OFS=FS=":";for(x=7,y=2;--x;){$x=sprintf("%02x",(y+="0x"$x)%256);y/=256}print}')
+ }
+
+ [ "$(nvram get et0macaddr)" = "00:90:4c:c0:00:08" ] && {
+ # OvisLink WL-1600GL mac workaround
+ nvram set et0macaddr=$(hexdump -n 6 -s 130976 -e '5/1 "%02x:" "%02x" ' /dev/mtd/0)
+ nvram set il0macaddr=$(nvram get et0macaddr|
+ awk '{OFS=FS=":";for(x=7,y=2;--x;){$x=sprintf("%02x",(y+="0x"$x)%256);y/=256}print}')
+ }
+
+ [ "$COMMIT" = "1" ] && nvram commit
+}
diff --git a/package/system/utils/nvram/src/.svn/entries b/package/system/utils/nvram/src/.svn/entries
new file mode 100644
index 0000000..afd57ce
--- /dev/null
+++ b/package/system/utils/nvram/src/.svn/entries
@@ -0,0 +1,232 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/system/utils/nvram/src
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-29T10:48:46.063504Z
+35375
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+nvram.c
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+93c64e0ea0c176df619a6f016f862c25
+2013-01-29T10:48:46.063504Z
+35375
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+11668
+
+sdinitvals.h
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+0d05c390dddfd5388697366df98abf69
+2013-01-29T10:48:46.063504Z
+35375
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+990
+
+cli.c
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+49c3376418f6f4f0a439c63818fe49bd
+2013-01-29T10:48:46.063504Z
+35375
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5310
+
+crc.c
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+c50555cc8549d4057b3851a4fe03abe9
+2013-01-29T10:48:46.063504Z
+35375
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2872
+
+nvram.h
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+5bb2089ed80288b189935d680d0c739f
+2013-01-29T10:48:46.063504Z
+35375
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3131
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:16.000000Z
+3c6305eb4ce2d3d2b3c0337b124e4e17
+2013-01-29T10:48:46.063504Z
+35375
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+769
+
diff --git a/package/system/utils/nvram/src/.svn/text-base/Makefile.svn-base b/package/system/utils/nvram/src/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..4872728
--- /dev/null
+++ b/package/system/utils/nvram/src/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,33 @@
+CLI_FILENAME = nvram
+
+LIB_VERMAJOR = 0
+LIB_VERMINOR = 1
+LIB_FILENAME = libnvram.so
+
+LIB_CFLAGS = $(CFLAGS) -shared -fPIC
+LIB_LDFLAGS = $(LDFLAGS) -Wl,-soname,$(LIB_FILENAME).$(LIB_VERMAJOR).$(LIB_VERMINOR)
+
+CLI_CFLAGS = $(CFLAGS)
+CLI_LDFLAGS = $(LDFLAGS)
+
+CLI_OBJ = cli.o
+LIB_OBJ = crc.o nvram.o
+
+all: cli libnvram
+
+cli: libnvram
+ $(CC) $(CLI_CFLAGS) -c -o cli.o cli.c
+ $(CC) -o $(CLI_FILENAME) $(CLI_LDFLAGS) $(CLI_OBJ) \
+ $(LIB_FILENAME).$(LIB_VERMAJOR).$(LIB_VERMINOR)
+
+cli.o: cli.c
+ $(CC) $(CLI_CFLAGS) -c -o $@ $<
+
+libnvram:
+ $(CC) $(LIB_CFLAGS) -c -o crc.o crc.c
+ $(CC) $(LIB_CFLAGS) -c -o nvram.o nvram.c
+ $(CC) $(LIB_CFLAGS) $(LIB_LDFLAGS) \
+ -o $(LIB_FILENAME).$(LIB_VERMAJOR).$(LIB_VERMINOR) $(LIB_OBJ)
+
+clean:
+ rm -f $(CLI_FILENAME) $(LIB_FILENAME)* *.o
diff --git a/package/system/utils/nvram/src/.svn/text-base/cli.c.svn-base b/package/system/utils/nvram/src/.svn/text-base/cli.c.svn-base
new file mode 100644
index 0000000..66ef904
--- /dev/null
+++ b/package/system/utils/nvram/src/.svn/text-base/cli.c.svn-base
@@ -0,0 +1,246 @@
+/*
+ * Command line interface for libnvram
+ *
+ * Copyright 2009, Jo-Philipp Wich <xm@subsignal.org>
+ *
+ * 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
+ * of the License, 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ *
+ * The libnvram code is based on Broadcom code for Linux 2.4.x .
+ *
+ */
+
+#include "nvram.h"
+
+
+static nvram_handle_t * nvram_open_rdonly(void)
+{
+ const char *file = nvram_find_staging();
+
+ if( file == NULL )
+ file = nvram_find_mtd();
+
+ if( file != NULL )
+ return nvram_open(file, NVRAM_RO);
+
+ return NULL;
+}
+
+static nvram_handle_t * nvram_open_staging(void)
+{
+ if( nvram_find_staging() != NULL || nvram_to_staging() == 0 )
+ return nvram_open(NVRAM_STAGING, NVRAM_RW);
+
+ return NULL;
+}
+
+static int do_show(nvram_handle_t *nvram)
+{
+ nvram_tuple_t *t;
+ int stat = 1;
+
+ if( (t = nvram_getall(nvram)) != NULL )
+ {
+ while( t )
+ {
+ printf("%s=%s\n", t->name, t->value);
+ t = t->next;
+ }
+
+ stat = 0;
+ }
+
+ return stat;
+}
+
+static int do_get(nvram_handle_t *nvram, const char *var)
+{
+ const char *val;
+ int stat = 1;
+
+ if( (val = nvram_get(nvram, var)) != NULL )
+ {
+ printf("%s\n", val);
+ stat = 0;
+ }
+
+ return stat;
+}
+
+static int do_unset(nvram_handle_t *nvram, const char *var)
+{
+ return nvram_unset(nvram, var);
+}
+
+static int do_set(nvram_handle_t *nvram, const char *pair)
+{
+ char *val = strstr(pair, "=");
+ char var[strlen(pair)];
+ int stat = 1;
+
+ if( val != NULL )
+ {
+ memset(var, 0, sizeof(var));
+ strncpy(var, pair, (int)(val-pair));
+ stat = nvram_set(nvram, var, (char *)(val + 1));
+ }
+
+ return stat;
+}
+
+static int do_info(nvram_handle_t *nvram)
+{
+ nvram_header_t *hdr = nvram_header(nvram);
+
+ /* CRC8 over the last 11 bytes of the header and data bytes */
+ uint8_t crc = hndcrc8((unsigned char *) &hdr[0] + NVRAM_CRC_START_POSITION,
+ hdr->len - NVRAM_CRC_START_POSITION, 0xff);
+
+ /* Show info */
+ printf("Magic: 0x%08X\n", hdr->magic);
+ printf("Length: 0x%08X\n", hdr->len);
+ printf("Offset: 0x%08X\n", nvram->offset);
+
+ printf("CRC8: 0x%02X (calculated: 0x%02X)\n",
+ hdr->crc_ver_init & 0xFF, crc);
+
+ printf("Version: 0x%02X\n", (hdr->crc_ver_init >> 8) & 0xFF);
+ printf("SDRAM init: 0x%04X\n", (hdr->crc_ver_init >> 16) & 0xFFFF);
+ printf("SDRAM config: 0x%04X\n", hdr->config_refresh & 0xFFFF);
+ printf("SDRAM refresh: 0x%04X\n", (hdr->config_refresh >> 16) & 0xFFFF);
+ printf("NCDL values: 0x%08X\n\n", hdr->config_ncdl);
+
+ printf("%i bytes used / %i bytes available (%.2f%%)\n",
+ hdr->len, NVRAM_SPACE - hdr->len,
+ (100.00 / (double)NVRAM_SPACE) * (double)hdr->len);
+
+ return 0;
+}
+
+
+int main( int argc, const char *argv[] )
+{
+ nvram_handle_t *nvram;
+ int commit = 0;
+ int write = 0;
+ int stat = 1;
+ int done = 0;
+ int i;
+
+ /* Ugly... iterate over arguments to see whether we can expect a write */
+ for( i = 1; i < argc; i++ )
+ if( ( !strcmp(argv[i], "set") && ++i < argc ) ||
+ ( !strcmp(argv[i], "unset") && ++i < argc ) ||
+ !strcmp(argv[i], "commit") )
+ {
+ write = 1;
+ break;
+ }
+
+
+ nvram = write ? nvram_open_staging() : nvram_open_rdonly();
+
+ if( nvram != NULL && argc > 1 )
+ {
+ for( i = 1; i < argc; i++ )
+ {
+ if( !strcmp(argv[i], "show") )
+ {
+ stat = do_show(nvram);
+ done++;
+ }
+ else if( !strcmp(argv[i], "info") )
+ {
+ stat = do_info(nvram);
+ done++;
+ }
+ else if( !strcmp(argv[i], "get") || !strcmp(argv[i], "unset") || !strcmp(argv[i], "set") )
+ {
+ if( (i+1) < argc )
+ {
+ switch(argv[i++][0])
+ {
+ case 'g':
+ stat = do_get(nvram, argv[i]);
+ break;
+
+ case 'u':
+ stat = do_unset(nvram, argv[i]);
+ break;
+
+ case 's':
+ stat = do_set(nvram, argv[i]);
+ break;
+ }
+ done++;
+ }
+ else
+ {
+ fprintf(stderr, "Command '%s' requires an argument!\n", argv[i]);
+ done = 0;
+ break;
+ }
+ }
+ else if( !strcmp(argv[i], "commit") )
+ {
+ commit = 1;
+ done++;
+ }
+ else
+ {
+ fprintf(stderr, "Unknown option '%s' !\n", argv[i]);
+ done = 0;
+ break;
+ }
+ }
+
+ if( write )
+ stat = nvram_commit(nvram);
+
+ nvram_close(nvram);
+
+ if( commit )
+ stat = staging_to_nvram();
+ }
+
+ if( !nvram )
+ {
+ fprintf(stderr,
+ "Could not open nvram! Possible reasons are:\n"
+ " - No device found (/proc not mounted or no nvram present)\n"
+ " - Insufficient permissions to open mtd device\n"
+ " - Insufficient memory to complete operation\n"
+ " - Memory mapping failed or not supported\n"
+ );
+
+ stat = 1;
+ }
+ else if( !done )
+ {
+ fprintf(stderr,
+ "Usage:\n"
+ " nvram show\n"
+ " nvram info\n"
+ " nvram get variable\n"
+ " nvram set variable=value [set ...]\n"
+ " nvram unset variable [unset ...]\n"
+ " nvram commit\n"
+ );
+
+ stat = 1;
+ }
+
+ return stat;
+}
diff --git a/package/system/utils/nvram/src/.svn/text-base/crc.c.svn-base b/package/system/utils/nvram/src/.svn/text-base/crc.c.svn-base
new file mode 100644
index 0000000..22a3665
--- /dev/null
+++ b/package/system/utils/nvram/src/.svn/text-base/crc.c.svn-base
@@ -0,0 +1,69 @@
+#include "nvram.h"
+
+/*******************************************************************************
+ * crc8
+ *
+ * Computes a crc8 over the input data using the polynomial:
+ *
+ * x^8 + x^7 +x^6 + x^4 + x^2 + 1
+ *
+ * The caller provides the initial value (either CRC8_INIT_VALUE
+ * or the previous returned value) to allow for processing of
+ * discontiguous blocks of data. When generating the CRC the
+ * caller is responsible for complementing the final return value
+ * and inserting it into the byte stream. When checking, a final
+ * return value of CRC8_GOOD_VALUE indicates a valid CRC.
+ *
+ * Reference: Dallas Semiconductor Application Note 27
+ * Williams, Ross N., "A Painless Guide to CRC Error Detection Algorithms",
+ * ver 3, Aug 1993, ross@guest.adelaide.edu.au, Rocksoft Pty Ltd.,
+ * ftp://ftp.rocksoft.com/clients/rocksoft/papers/crc_v3.txt
+ *
+ * ****************************************************************************
+ */
+
+static const uint8_t crc8_table[256] = {
+ 0x00, 0xF7, 0xB9, 0x4E, 0x25, 0xD2, 0x9C, 0x6B,
+ 0x4A, 0xBD, 0xF3, 0x04, 0x6F, 0x98, 0xD6, 0x21,
+ 0x94, 0x63, 0x2D, 0xDA, 0xB1, 0x46, 0x08, 0xFF,
+ 0xDE, 0x29, 0x67, 0x90, 0xFB, 0x0C, 0x42, 0xB5,
+ 0x7F, 0x88, 0xC6, 0x31, 0x5A, 0xAD, 0xE3, 0x14,
+ 0x35, 0xC2, 0x8C, 0x7B, 0x10, 0xE7, 0xA9, 0x5E,
+ 0xEB, 0x1C, 0x52, 0xA5, 0xCE, 0x39, 0x77, 0x80,
+ 0xA1, 0x56, 0x18, 0xEF, 0x84, 0x73, 0x3D, 0xCA,
+ 0xFE, 0x09, 0x47, 0xB0, 0xDB, 0x2C, 0x62, 0x95,
+ 0xB4, 0x43, 0x0D, 0xFA, 0x91, 0x66, 0x28, 0xDF,
+ 0x6A, 0x9D, 0xD3, 0x24, 0x4F, 0xB8, 0xF6, 0x01,
+ 0x20, 0xD7, 0x99, 0x6E, 0x05, 0xF2, 0xBC, 0x4B,
+ 0x81, 0x76, 0x38, 0xCF, 0xA4, 0x53, 0x1D, 0xEA,
+ 0xCB, 0x3C, 0x72, 0x85, 0xEE, 0x19, 0x57, 0xA0,
+ 0x15, 0xE2, 0xAC, 0x5B, 0x30, 0xC7, 0x89, 0x7E,
+ 0x5F, 0xA8, 0xE6, 0x11, 0x7A, 0x8D, 0xC3, 0x34,
+ 0xAB, 0x5C, 0x12, 0xE5, 0x8E, 0x79, 0x37, 0xC0,
+ 0xE1, 0x16, 0x58, 0xAF, 0xC4, 0x33, 0x7D, 0x8A,
+ 0x3F, 0xC8, 0x86, 0x71, 0x1A, 0xED, 0xA3, 0x54,
+ 0x75, 0x82, 0xCC, 0x3B, 0x50, 0xA7, 0xE9, 0x1E,
+ 0xD4, 0x23, 0x6D, 0x9A, 0xF1, 0x06, 0x48, 0xBF,
+ 0x9E, 0x69, 0x27, 0xD0, 0xBB, 0x4C, 0x02, 0xF5,
+ 0x40, 0xB7, 0xF9, 0x0E, 0x65, 0x92, 0xDC, 0x2B,
+ 0x0A, 0xFD, 0xB3, 0x44, 0x2F, 0xD8, 0x96, 0x61,
+ 0x55, 0xA2, 0xEC, 0x1B, 0x70, 0x87, 0xC9, 0x3E,
+ 0x1F, 0xE8, 0xA6, 0x51, 0x3A, 0xCD, 0x83, 0x74,
+ 0xC1, 0x36, 0x78, 0x8F, 0xE4, 0x13, 0x5D, 0xAA,
+ 0x8B, 0x7C, 0x32, 0xC5, 0xAE, 0x59, 0x17, 0xE0,
+ 0x2A, 0xDD, 0x93, 0x64, 0x0F, 0xF8, 0xB6, 0x41,
+ 0x60, 0x97, 0xD9, 0x2E, 0x45, 0xB2, 0xFC, 0x0B,
+ 0xBE, 0x49, 0x07, 0xF0, 0x9B, 0x6C, 0x22, 0xD5,
+ 0xF4, 0x03, 0x4D, 0xBA, 0xD1, 0x26, 0x68, 0x9F
+};
+
+uint8_t hndcrc8 (
+ uint8_t * pdata, /* pointer to array of data to process */
+ uint32_t nbytes, /* number of input data bytes to process */
+ uint8_t crc /* either CRC8_INIT_VALUE or previous return value */
+) {
+ while (nbytes-- > 0)
+ crc = crc8_table[(crc ^ *pdata++) & 0xff];
+
+ return crc;
+}
diff --git a/package/system/utils/nvram/src/.svn/text-base/nvram.c.svn-base b/package/system/utils/nvram/src/.svn/text-base/nvram.c.svn-base
new file mode 100644
index 0000000..a0bc006
--- /dev/null
+++ b/package/system/utils/nvram/src/.svn/text-base/nvram.c.svn-base
@@ -0,0 +1,556 @@
+/*
+ * NVRAM variable manipulation (common)
+ *
+ * Copyright 2004, Broadcom Corporation
+ * Copyright 2009-2010, OpenWrt.org
+ * All Rights Reserved.
+ *
+ * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
+ * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
+ * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
+ * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
+ *
+ */
+
+#include "nvram.h"
+
+#define TRACE(msg) \
+ printf("%s(%i) in %s(): %s\n", \
+ __FILE__, __LINE__, __FUNCTION__, msg ? msg : "?")
+
+size_t nvram_erase_size = 0;
+
+
+/*
+ * -- Helper functions --
+ */
+
+/* String hash */
+static uint32_t hash(const char *s)
+{
+ uint32_t hash = 0;
+
+ while (*s)
+ hash = 31 * hash + *s++;
+
+ return hash;
+}
+
+/* Free all tuples. */
+static void _nvram_free(nvram_handle_t *h)
+{
+ uint32_t i;
+ nvram_tuple_t *t, *next;
+
+ /* Free hash table */
+ for (i = 0; i < NVRAM_ARRAYSIZE(h->nvram_hash); i++) {
+ for (t = h->nvram_hash[i]; t; t = next) {
+ next = t->next;
+ free(t);
+ }
+ h->nvram_hash[i] = NULL;
+ }
+
+ /* Free dead table */
+ for (t = h->nvram_dead; t; t = next) {
+ next = t->next;
+ free(t);
+ }
+
+ h->nvram_dead = NULL;
+}
+
+/* (Re)allocate NVRAM tuples. */
+static nvram_tuple_t * _nvram_realloc( nvram_handle_t *h, nvram_tuple_t *t,
+ const char *name, const char *value )
+{
+ if ((strlen(value) + 1) > NVRAM_SPACE)
+ return NULL;
+
+ if (!t) {
+ if (!(t = malloc(sizeof(nvram_tuple_t) + strlen(name) + 1)))
+ return NULL;
+
+ /* Copy name */
+ t->name = (char *) &t[1];
+ strcpy(t->name, name);
+
+ t->value = NULL;
+ }
+
+ /* Copy value */
+ if (!t->value || strcmp(t->value, value))
+ {
+ if(!(t->value = (char *) realloc(t->value, strlen(value)+1)))
+ return NULL;
+
+ strcpy(t->value, value);
+ t->value[strlen(value)] = '\0';
+ }
+
+ return t;
+}
+
+/* (Re)initialize the hash table. */
+static int _nvram_rehash(nvram_handle_t *h)
+{
+ nvram_header_t *header = nvram_header(h);
+ char buf[] = "0xXXXXXXXX", *name, *value, *eq;
+
+ /* (Re)initialize hash table */
+ _nvram_free(h);
+
+ /* Parse and set "name=value\0 ... \0\0" */
+ name = (char *) &header[1];
+
+ for (; *name; name = value + strlen(value) + 1) {
+ if (!(eq = strchr(name, '=')))
+ break;
+ *eq = '\0';
+ value = eq + 1;
+ nvram_set(h, name, value);
+ *eq = '=';
+ }
+
+ /* Set special SDRAM parameters */
+ if (!nvram_get(h, "sdram_init")) {
+ sprintf(buf, "0x%04X", (uint16_t)(header->crc_ver_init >> 16));
+ nvram_set(h, "sdram_init", buf);
+ }
+ if (!nvram_get(h, "sdram_config")) {
+ sprintf(buf, "0x%04X", (uint16_t)(header->config_refresh & 0xffff));
+ nvram_set(h, "sdram_config", buf);
+ }
+ if (!nvram_get(h, "sdram_refresh")) {
+ sprintf(buf, "0x%04X",
+ (uint16_t)((header->config_refresh >> 16) & 0xffff));
+ nvram_set(h, "sdram_refresh", buf);
+ }
+ if (!nvram_get(h, "sdram_ncdl")) {
+ sprintf(buf, "0x%08X", header->config_ncdl);
+ nvram_set(h, "sdram_ncdl", buf);
+ }
+
+ return 0;
+}
+
+
+/*
+ * -- Public functions --
+ */
+
+/* Get nvram header. */
+nvram_header_t * nvram_header(nvram_handle_t *h)
+{
+ return (nvram_header_t *) &h->mmap[h->offset];
+}
+
+/* Get the value of an NVRAM variable. */
+char * nvram_get(nvram_handle_t *h, const char *name)
+{
+ uint32_t i;
+ nvram_tuple_t *t;
+ char *value;
+
+ if (!name)
+ return NULL;
+
+ /* Hash the name */
+ i = hash(name) % NVRAM_ARRAYSIZE(h->nvram_hash);
+
+ /* Find the associated tuple in the hash table */
+ for (t = h->nvram_hash[i]; t && strcmp(t->name, name); t = t->next);
+
+ value = t ? t->value : NULL;
+
+ return value;
+}
+
+/* Set the value of an NVRAM variable. */
+int nvram_set(nvram_handle_t *h, const char *name, const char *value)
+{
+ uint32_t i;
+ nvram_tuple_t *t, *u, **prev;
+
+ /* Hash the name */
+ i = hash(name) % NVRAM_ARRAYSIZE(h->nvram_hash);
+
+ /* Find the associated tuple in the hash table */
+ for (prev = &h->nvram_hash[i], t = *prev;
+ t && strcmp(t->name, name); prev = &t->next, t = *prev);
+
+ /* (Re)allocate tuple */
+ if (!(u = _nvram_realloc(h, t, name, value)))
+ return -12; /* -ENOMEM */
+
+ /* Value reallocated */
+ if (t && t == u)
+ return 0;
+
+ /* Move old tuple to the dead table */
+ if (t) {
+ *prev = t->next;
+ t->next = h->nvram_dead;
+ h->nvram_dead = t;
+ }
+
+ /* Add new tuple to the hash table */
+ u->next = h->nvram_hash[i];
+ h->nvram_hash[i] = u;
+
+ return 0;
+}
+
+/* Unset the value of an NVRAM variable. */
+int nvram_unset(nvram_handle_t *h, const char *name)
+{
+ uint32_t i;
+ nvram_tuple_t *t, **prev;
+
+ if (!name)
+ return 0;
+
+ /* Hash the name */
+ i = hash(name) % NVRAM_ARRAYSIZE(h->nvram_hash);
+
+ /* Find the associated tuple in the hash table */
+ for (prev = &h->nvram_hash[i], t = *prev;
+ t && strcmp(t->name, name); prev = &t->next, t = *prev);
+
+ /* Move it to the dead table */
+ if (t) {
+ *prev = t->next;
+ t->next = h->nvram_dead;
+ h->nvram_dead = t;
+ }
+
+ return 0;
+}
+
+/* Get all NVRAM variables. */
+nvram_tuple_t * nvram_getall(nvram_handle_t *h)
+{
+ int i;
+ nvram_tuple_t *t, *l, *x;
+
+ l = NULL;
+
+ for (i = 0; i < NVRAM_ARRAYSIZE(h->nvram_hash); i++) {
+ for (t = h->nvram_hash[i]; t; t = t->next) {
+ if( (x = (nvram_tuple_t *) malloc(sizeof(nvram_tuple_t))) != NULL )
+ {
+ x->name = t->name;
+ x->value = t->value;
+ x->next = l;
+ l = x;
+ }
+ else
+ {
+ break;
+ }
+ }
+ }
+
+ return l;
+}
+
+/* Regenerate NVRAM. */
+int nvram_commit(nvram_handle_t *h)
+{
+ nvram_header_t *header = nvram_header(h);
+ char *init, *config, *refresh, *ncdl;
+ char *ptr, *end;
+ int i;
+ nvram_tuple_t *t;
+ nvram_header_t tmp;
+ uint8_t crc;
+
+ /* Regenerate header */
+ header->magic = NVRAM_MAGIC;
+ header->crc_ver_init = (NVRAM_VERSION << 8);
+ if (!(init = nvram_get(h, "sdram_init")) ||
+ !(config = nvram_get(h, "sdram_config")) ||
+ !(refresh = nvram_get(h, "sdram_refresh")) ||
+ !(ncdl = nvram_get(h, "sdram_ncdl"))) {
+ header->crc_ver_init |= SDRAM_INIT << 16;
+ header->config_refresh = SDRAM_CONFIG;
+ header->config_refresh |= SDRAM_REFRESH << 16;
+ header->config_ncdl = 0;
+ } else {
+ header->crc_ver_init |= (strtoul(init, NULL, 0) & 0xffff) << 16;
+ header->config_refresh = strtoul(config, NULL, 0) & 0xffff;
+ header->config_refresh |= (strtoul(refresh, NULL, 0) & 0xffff) << 16;
+ header->config_ncdl = strtoul(ncdl, NULL, 0);
+ }
+
+ /* Clear data area */
+ ptr = (char *) header + sizeof(nvram_header_t);
+ memset(ptr, 0xFF, NVRAM_SPACE - sizeof(nvram_header_t));
+ memset(&tmp, 0, sizeof(nvram_header_t));
+
+ /* Leave space for a double NUL at the end */
+ end = (char *) header + NVRAM_SPACE - 2;
+
+ /* Write out all tuples */
+ for (i = 0; i < NVRAM_ARRAYSIZE(h->nvram_hash); i++) {
+ for (t = h->nvram_hash[i]; t; t = t->next) {
+ if ((ptr + strlen(t->name) + 1 + strlen(t->value) + 1) > end)
+ break;
+ ptr += sprintf(ptr, "%s=%s", t->name, t->value) + 1;
+ }
+ }
+
+ /* End with a double NULL and pad to 4 bytes */
+ *ptr = '\0';
+ ptr++;
+
+ if( (int)ptr % 4 )
+ memset(ptr, 0, 4 - ((int)ptr % 4));
+
+ ptr++;
+
+ /* Set new length */
+ header->len = NVRAM_ROUNDUP(ptr - (char *) header, 4);
+
+ /* Little-endian CRC8 over the last 11 bytes of the header */
+ tmp.crc_ver_init = header->crc_ver_init;
+ tmp.config_refresh = header->config_refresh;
+ tmp.config_ncdl = header->config_ncdl;
+ crc = hndcrc8((unsigned char *) &tmp + NVRAM_CRC_START_POSITION,
+ sizeof(nvram_header_t) - NVRAM_CRC_START_POSITION, 0xff);
+
+ /* Continue CRC8 over data bytes */
+ crc = hndcrc8((unsigned char *) &header[0] + sizeof(nvram_header_t),
+ header->len - sizeof(nvram_header_t), crc);
+
+ /* Set new CRC8 */
+ header->crc_ver_init |= crc;
+
+ /* Write out */
+ msync(h->mmap, h->length, MS_SYNC);
+ fsync(h->fd);
+
+ /* Reinitialize hash table */
+ return _nvram_rehash(h);
+}
+
+/* Open NVRAM and obtain a handle. */
+nvram_handle_t * nvram_open(const char *file, int rdonly)
+{
+ int i;
+ int fd;
+ char *mtd = NULL;
+ nvram_handle_t *h;
+ nvram_header_t *header;
+ int offset = -1;
+
+ /* If erase size or file are undefined then try to define them */
+ if( (nvram_erase_size == 0) || (file == NULL) )
+ {
+ /* Finding the mtd will set the appropriate erase size */
+ if( (mtd = nvram_find_mtd()) == NULL || nvram_erase_size == 0 )
+ {
+ free(mtd);
+ return NULL;
+ }
+ }
+
+ if( (fd = open(file ? file : mtd, O_RDWR)) > -1 )
+ {
+ char *mmap_area = (char *) mmap(
+ NULL, nvram_erase_size, PROT_READ | PROT_WRITE,
+ (( rdonly == NVRAM_RO ) ? MAP_PRIVATE : MAP_SHARED) | MAP_LOCKED, fd, 0);
+
+ if( mmap_area != MAP_FAILED )
+ {
+ for( i = 0; i <= ((nvram_erase_size - NVRAM_SPACE) / sizeof(uint32_t)); i++ )
+ {
+ if( ((uint32_t *)mmap_area)[i] == NVRAM_MAGIC )
+ {
+ offset = i * sizeof(uint32_t);
+ break;
+ }
+ }
+
+ if( offset < 0 )
+ {
+ free(mtd);
+ return NULL;
+ }
+ else if( (h = malloc(sizeof(nvram_handle_t))) != NULL )
+ {
+ memset(h, 0, sizeof(nvram_handle_t));
+
+ h->fd = fd;
+ h->mmap = mmap_area;
+ h->length = nvram_erase_size;
+ h->offset = offset;
+
+ header = nvram_header(h);
+
+ if( header->magic == NVRAM_MAGIC )
+ {
+ _nvram_rehash(h);
+ free(mtd);
+ return h;
+ }
+ else
+ {
+ munmap(h->mmap, h->length);
+ free(h);
+ }
+ }
+ }
+ }
+
+ free(mtd);
+ return NULL;
+}
+
+/* Close NVRAM and free memory. */
+int nvram_close(nvram_handle_t *h)
+{
+ _nvram_free(h);
+ munmap(h->mmap, h->length);
+ close(h->fd);
+ free(h);
+
+ return 0;
+}
+
+/* Determine NVRAM device node. */
+char * nvram_find_mtd(void)
+{
+ FILE *fp;
+ int i, esz;
+ char dev[PATH_MAX];
+ char *path = NULL;
+ struct stat s;
+ int supported = 1;
+
+ /* Refuse any operation on the WGT634U */
+ if( (fp = fopen("/proc/diag/model", "r")) )
+ {
+ if( fgets(dev, sizeof(dev), fp) && !strncmp(dev, "Netgear WGT634U", 15) )
+ supported = 0;
+
+ fclose(fp);
+ }
+
+ if( supported && (fp = fopen("/proc/mtd", "r")) )
+ {
+ while( fgets(dev, sizeof(dev), fp) )
+ {
+ if( strstr(dev, "nvram") && sscanf(dev, "mtd%d: %08x", &i, &esz) )
+ {
+ nvram_erase_size = esz;
+
+ sprintf(dev, "/dev/mtdblock/%d", i);
+ if( stat(dev, &s) > -1 && (s.st_mode & S_IFBLK) )
+ {
+ if( (path = (char *) malloc(strlen(dev)+1)) != NULL )
+ {
+ strncpy(path, dev, strlen(dev)+1);
+ break;
+ }
+ }
+ else
+ {
+ sprintf(dev, "/dev/mtdblock%d", i);
+ if( stat(dev, &s) > -1 && (s.st_mode & S_IFBLK) )
+ {
+ if( (path = (char *) malloc(strlen(dev)+1)) != NULL )
+ {
+ strncpy(path, dev, strlen(dev)+1);
+ break;
+ }
+ }
+ }
+ }
+ }
+ fclose(fp);
+ }
+
+ return path;
+}
+
+/* Check NVRAM staging file. */
+char * nvram_find_staging(void)
+{
+ struct stat s;
+
+ if( (stat(NVRAM_STAGING, &s) > -1) && (s.st_mode & S_IFREG) )
+ {
+ return NVRAM_STAGING;
+ }
+
+ return NULL;
+}
+
+/* Copy NVRAM contents to staging file. */
+int nvram_to_staging(void)
+{
+ int fdmtd, fdstg, stat;
+ char *mtd = nvram_find_mtd();
+ char buf[nvram_erase_size];
+
+ stat = -1;
+
+ if( (mtd != NULL) && (nvram_erase_size > 0) )
+ {
+ if( (fdmtd = open(mtd, O_RDONLY)) > -1 )
+ {
+ if( read(fdmtd, buf, sizeof(buf)) == sizeof(buf) )
+ {
+ if((fdstg = open(NVRAM_STAGING, O_WRONLY | O_CREAT, 0600)) > -1)
+ {
+ write(fdstg, buf, sizeof(buf));
+ fsync(fdstg);
+ close(fdstg);
+
+ stat = 0;
+ }
+ }
+
+ close(fdmtd);
+ }
+ }
+
+ free(mtd);
+ return stat;
+}
+
+/* Copy staging file to NVRAM device. */
+int staging_to_nvram(void)
+{
+ int fdmtd, fdstg, stat;
+ char *mtd = nvram_find_mtd();
+ char buf[nvram_erase_size];
+
+ stat = -1;
+
+ if( (mtd != NULL) && (nvram_erase_size > 0) )
+ {
+ if( (fdstg = open(NVRAM_STAGING, O_RDONLY)) > -1 )
+ {
+ if( read(fdstg, buf, sizeof(buf)) == sizeof(buf) )
+ {
+ if( (fdmtd = open(mtd, O_WRONLY | O_SYNC)) > -1 )
+ {
+ write(fdmtd, buf, sizeof(buf));
+ fsync(fdmtd);
+ close(fdmtd);
+ stat = 0;
+ }
+ }
+
+ close(fdstg);
+
+ if( !stat )
+ stat = unlink(NVRAM_STAGING) ? 1 : 0;
+ }
+ }
+
+ free(mtd);
+ return stat;
+}
diff --git a/package/system/utils/nvram/src/.svn/text-base/nvram.h.svn-base b/package/system/utils/nvram/src/.svn/text-base/nvram.h.svn-base
new file mode 100644
index 0000000..c72f67e
--- /dev/null
+++ b/package/system/utils/nvram/src/.svn/text-base/nvram.h.svn-base
@@ -0,0 +1,123 @@
+/*
+ * NVRAM variable manipulation
+ *
+ * Copyright 2007, Broadcom Corporation
+ * Copyright 2009, OpenWrt.org
+ * All Rights Reserved.
+ *
+ * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
+ * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
+ * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
+ * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
+ *
+ */
+
+#ifndef _nvram_h_
+#define _nvram_h_
+
+#include <stdint.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <errno.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <linux/limits.h>
+
+#include "sdinitvals.h"
+
+
+struct nvram_header {
+ uint32_t magic;
+ uint32_t len;
+ uint32_t crc_ver_init; /* 0:7 crc, 8:15 ver, 16:31 sdram_init */
+ uint32_t config_refresh; /* 0:15 sdram_config, 16:31 sdram_refresh */
+ uint32_t config_ncdl; /* ncdl values for memc */
+} __attribute__((__packed__));
+
+struct nvram_tuple {
+ char *name;
+ char *value;
+ struct nvram_tuple *next;
+};
+
+struct nvram_handle {
+ int fd;
+ char *mmap;
+ unsigned int length;
+ unsigned int offset;
+ struct nvram_tuple *nvram_hash[257];
+ struct nvram_tuple *nvram_dead;
+};
+
+typedef struct nvram_handle nvram_handle_t;
+typedef struct nvram_header nvram_header_t;
+typedef struct nvram_tuple nvram_tuple_t;
+
+
+/* Get nvram header. */
+nvram_header_t * nvram_header(nvram_handle_t *h);
+
+/* Set the value of an NVRAM variable */
+int nvram_set(nvram_handle_t *h, const char *name, const char *value);
+
+/* Get the value of an NVRAM variable. */
+char * nvram_get(nvram_handle_t *h, const char *name);
+
+/* Unset the value of an NVRAM variable. */
+int nvram_unset(nvram_handle_t *h, const char *name);
+
+/* Get all NVRAM variables. */
+nvram_tuple_t * nvram_getall(nvram_handle_t *h);
+
+/* Regenerate NVRAM. */
+int nvram_commit(nvram_handle_t *h);
+
+/* Open NVRAM and obtain a handle. */
+nvram_handle_t * nvram_open(const char *file, int rdonly);
+
+/* Close NVRAM and free memory. */
+int nvram_close(nvram_handle_t *h);
+
+/* Get the value of an NVRAM variable in a safe way, use "" instead of NULL. */
+#define nvram_safe_get(h, name) (nvram_get(h, name) ? : "")
+
+/* Computes a crc8 over the input data. */
+uint8_t hndcrc8 (uint8_t * pdata, uint32_t nbytes, uint8_t crc);
+
+/* Returns the crc value of the nvram. */
+uint8_t nvram_calc_crc(nvram_header_t * nvh);
+
+/* Determine NVRAM device node. */
+char * nvram_find_mtd(void);
+
+/* Copy NVRAM contents to staging file. */
+int nvram_to_staging(void);
+
+/* Copy staging file to NVRAM device. */
+int staging_to_nvram(void);
+
+/* Check NVRAM staging file. */
+char * nvram_find_staging(void);
+
+
+/* Staging file for NVRAM */
+#define NVRAM_STAGING "/tmp/.nvram"
+#define NVRAM_RO 1
+#define NVRAM_RW 0
+
+/* Helper macros */
+#define NVRAM_ARRAYSIZE(a) sizeof(a)/sizeof(a[0])
+#define NVRAM_ROUNDUP(x, y) ((((x)+((y)-1))/(y))*(y))
+
+/* NVRAM constants */
+#define NVRAM_SPACE 0x8000
+#define NVRAM_MAGIC 0x48534C46 /* 'FLSH' */
+#define NVRAM_VERSION 1
+
+#define NVRAM_CRC_START_POSITION 9 /* magic, len, crc8 to be skipped */
+
+
+#endif /* _nvram_h_ */
diff --git a/package/system/utils/nvram/src/.svn/text-base/sdinitvals.h.svn-base b/package/system/utils/nvram/src/.svn/text-base/sdinitvals.h.svn-base
new file mode 100644
index 0000000..5a289ad
--- /dev/null
+++ b/package/system/utils/nvram/src/.svn/text-base/sdinitvals.h.svn-base
@@ -0,0 +1,30 @@
+/*
+ * SDRAM init values
+ *
+ * Copyright 2007, Broadcom Corporation
+ * Copyright 2009, OpenWrt.org
+ * All Rights Reserved.
+ *
+ * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
+ * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
+ * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
+ * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
+ *
+ */
+
+#ifndef _sdinitvals_h_
+#define _sdinitvals_h_
+
+/* SDRAM refresh control (refresh) register bits */
+#define SDRAM_REF(p) (((p)&0xff) | SDRAM_REF_EN) /* Refresh period */
+#define SDRAM_REF_EN 0x8000 /* Writing 1 enables periodic refresh */
+
+/* SDRAM Core default Init values (OCP ID 0x803) */
+#define MEM4MX16X2 0x419 /* 16 MB */
+
+#define SDRAM_INIT MEM4MX16X2
+#define SDRAM_BURSTFULL 0x0000 /* Use full page bursts */
+#define SDRAM_CONFIG SDRAM_BURSTFULL
+#define SDRAM_REFRESH SDRAM_REF(0x40)
+
+#endif /* _sdinitvals_h_ */
diff --git a/package/system/utils/nvram/src/Makefile b/package/system/utils/nvram/src/Makefile
new file mode 100644
index 0000000..4872728
--- /dev/null
+++ b/package/system/utils/nvram/src/Makefile
@@ -0,0 +1,33 @@
+CLI_FILENAME = nvram
+
+LIB_VERMAJOR = 0
+LIB_VERMINOR = 1
+LIB_FILENAME = libnvram.so
+
+LIB_CFLAGS = $(CFLAGS) -shared -fPIC
+LIB_LDFLAGS = $(LDFLAGS) -Wl,-soname,$(LIB_FILENAME).$(LIB_VERMAJOR).$(LIB_VERMINOR)
+
+CLI_CFLAGS = $(CFLAGS)
+CLI_LDFLAGS = $(LDFLAGS)
+
+CLI_OBJ = cli.o
+LIB_OBJ = crc.o nvram.o
+
+all: cli libnvram
+
+cli: libnvram
+ $(CC) $(CLI_CFLAGS) -c -o cli.o cli.c
+ $(CC) -o $(CLI_FILENAME) $(CLI_LDFLAGS) $(CLI_OBJ) \
+ $(LIB_FILENAME).$(LIB_VERMAJOR).$(LIB_VERMINOR)
+
+cli.o: cli.c
+ $(CC) $(CLI_CFLAGS) -c -o $@ $<
+
+libnvram:
+ $(CC) $(LIB_CFLAGS) -c -o crc.o crc.c
+ $(CC) $(LIB_CFLAGS) -c -o nvram.o nvram.c
+ $(CC) $(LIB_CFLAGS) $(LIB_LDFLAGS) \
+ -o $(LIB_FILENAME).$(LIB_VERMAJOR).$(LIB_VERMINOR) $(LIB_OBJ)
+
+clean:
+ rm -f $(CLI_FILENAME) $(LIB_FILENAME)* *.o
diff --git a/package/system/utils/nvram/src/cli.c b/package/system/utils/nvram/src/cli.c
new file mode 100644
index 0000000..66ef904
--- /dev/null
+++ b/package/system/utils/nvram/src/cli.c
@@ -0,0 +1,246 @@
+/*
+ * Command line interface for libnvram
+ *
+ * Copyright 2009, Jo-Philipp Wich <xm@subsignal.org>
+ *
+ * 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
+ * of the License, 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ *
+ * The libnvram code is based on Broadcom code for Linux 2.4.x .
+ *
+ */
+
+#include "nvram.h"
+
+
+static nvram_handle_t * nvram_open_rdonly(void)
+{
+ const char *file = nvram_find_staging();
+
+ if( file == NULL )
+ file = nvram_find_mtd();
+
+ if( file != NULL )
+ return nvram_open(file, NVRAM_RO);
+
+ return NULL;
+}
+
+static nvram_handle_t * nvram_open_staging(void)
+{
+ if( nvram_find_staging() != NULL || nvram_to_staging() == 0 )
+ return nvram_open(NVRAM_STAGING, NVRAM_RW);
+
+ return NULL;
+}
+
+static int do_show(nvram_handle_t *nvram)
+{
+ nvram_tuple_t *t;
+ int stat = 1;
+
+ if( (t = nvram_getall(nvram)) != NULL )
+ {
+ while( t )
+ {
+ printf("%s=%s\n", t->name, t->value);
+ t = t->next;
+ }
+
+ stat = 0;
+ }
+
+ return stat;
+}
+
+static int do_get(nvram_handle_t *nvram, const char *var)
+{
+ const char *val;
+ int stat = 1;
+
+ if( (val = nvram_get(nvram, var)) != NULL )
+ {
+ printf("%s\n", val);
+ stat = 0;
+ }
+
+ return stat;
+}
+
+static int do_unset(nvram_handle_t *nvram, const char *var)
+{
+ return nvram_unset(nvram, var);
+}
+
+static int do_set(nvram_handle_t *nvram, const char *pair)
+{
+ char *val = strstr(pair, "=");
+ char var[strlen(pair)];
+ int stat = 1;
+
+ if( val != NULL )
+ {
+ memset(var, 0, sizeof(var));
+ strncpy(var, pair, (int)(val-pair));
+ stat = nvram_set(nvram, var, (char *)(val + 1));
+ }
+
+ return stat;
+}
+
+static int do_info(nvram_handle_t *nvram)
+{
+ nvram_header_t *hdr = nvram_header(nvram);
+
+ /* CRC8 over the last 11 bytes of the header and data bytes */
+ uint8_t crc = hndcrc8((unsigned char *) &hdr[0] + NVRAM_CRC_START_POSITION,
+ hdr->len - NVRAM_CRC_START_POSITION, 0xff);
+
+ /* Show info */
+ printf("Magic: 0x%08X\n", hdr->magic);
+ printf("Length: 0x%08X\n", hdr->len);
+ printf("Offset: 0x%08X\n", nvram->offset);
+
+ printf("CRC8: 0x%02X (calculated: 0x%02X)\n",
+ hdr->crc_ver_init & 0xFF, crc);
+
+ printf("Version: 0x%02X\n", (hdr->crc_ver_init >> 8) & 0xFF);
+ printf("SDRAM init: 0x%04X\n", (hdr->crc_ver_init >> 16) & 0xFFFF);
+ printf("SDRAM config: 0x%04X\n", hdr->config_refresh & 0xFFFF);
+ printf("SDRAM refresh: 0x%04X\n", (hdr->config_refresh >> 16) & 0xFFFF);
+ printf("NCDL values: 0x%08X\n\n", hdr->config_ncdl);
+
+ printf("%i bytes used / %i bytes available (%.2f%%)\n",
+ hdr->len, NVRAM_SPACE - hdr->len,
+ (100.00 / (double)NVRAM_SPACE) * (double)hdr->len);
+
+ return 0;
+}
+
+
+int main( int argc, const char *argv[] )
+{
+ nvram_handle_t *nvram;
+ int commit = 0;
+ int write = 0;
+ int stat = 1;
+ int done = 0;
+ int i;
+
+ /* Ugly... iterate over arguments to see whether we can expect a write */
+ for( i = 1; i < argc; i++ )
+ if( ( !strcmp(argv[i], "set") && ++i < argc ) ||
+ ( !strcmp(argv[i], "unset") && ++i < argc ) ||
+ !strcmp(argv[i], "commit") )
+ {
+ write = 1;
+ break;
+ }
+
+
+ nvram = write ? nvram_open_staging() : nvram_open_rdonly();
+
+ if( nvram != NULL && argc > 1 )
+ {
+ for( i = 1; i < argc; i++ )
+ {
+ if( !strcmp(argv[i], "show") )
+ {
+ stat = do_show(nvram);
+ done++;
+ }
+ else if( !strcmp(argv[i], "info") )
+ {
+ stat = do_info(nvram);
+ done++;
+ }
+ else if( !strcmp(argv[i], "get") || !strcmp(argv[i], "unset") || !strcmp(argv[i], "set") )
+ {
+ if( (i+1) < argc )
+ {
+ switch(argv[i++][0])
+ {
+ case 'g':
+ stat = do_get(nvram, argv[i]);
+ break;
+
+ case 'u':
+ stat = do_unset(nvram, argv[i]);
+ break;
+
+ case 's':
+ stat = do_set(nvram, argv[i]);
+ break;
+ }
+ done++;
+ }
+ else
+ {
+ fprintf(stderr, "Command '%s' requires an argument!\n", argv[i]);
+ done = 0;
+ break;
+ }
+ }
+ else if( !strcmp(argv[i], "commit") )
+ {
+ commit = 1;
+ done++;
+ }
+ else
+ {
+ fprintf(stderr, "Unknown option '%s' !\n", argv[i]);
+ done = 0;
+ break;
+ }
+ }
+
+ if( write )
+ stat = nvram_commit(nvram);
+
+ nvram_close(nvram);
+
+ if( commit )
+ stat = staging_to_nvram();
+ }
+
+ if( !nvram )
+ {
+ fprintf(stderr,
+ "Could not open nvram! Possible reasons are:\n"
+ " - No device found (/proc not mounted or no nvram present)\n"
+ " - Insufficient permissions to open mtd device\n"
+ " - Insufficient memory to complete operation\n"
+ " - Memory mapping failed or not supported\n"
+ );
+
+ stat = 1;
+ }
+ else if( !done )
+ {
+ fprintf(stderr,
+ "Usage:\n"
+ " nvram show\n"
+ " nvram info\n"
+ " nvram get variable\n"
+ " nvram set variable=value [set ...]\n"
+ " nvram unset variable [unset ...]\n"
+ " nvram commit\n"
+ );
+
+ stat = 1;
+ }
+
+ return stat;
+}
diff --git a/package/system/utils/nvram/src/crc.c b/package/system/utils/nvram/src/crc.c
new file mode 100644
index 0000000..22a3665
--- /dev/null
+++ b/package/system/utils/nvram/src/crc.c
@@ -0,0 +1,69 @@
+#include "nvram.h"
+
+/*******************************************************************************
+ * crc8
+ *
+ * Computes a crc8 over the input data using the polynomial:
+ *
+ * x^8 + x^7 +x^6 + x^4 + x^2 + 1
+ *
+ * The caller provides the initial value (either CRC8_INIT_VALUE
+ * or the previous returned value) to allow for processing of
+ * discontiguous blocks of data. When generating the CRC the
+ * caller is responsible for complementing the final return value
+ * and inserting it into the byte stream. When checking, a final
+ * return value of CRC8_GOOD_VALUE indicates a valid CRC.
+ *
+ * Reference: Dallas Semiconductor Application Note 27
+ * Williams, Ross N., "A Painless Guide to CRC Error Detection Algorithms",
+ * ver 3, Aug 1993, ross@guest.adelaide.edu.au, Rocksoft Pty Ltd.,
+ * ftp://ftp.rocksoft.com/clients/rocksoft/papers/crc_v3.txt
+ *
+ * ****************************************************************************
+ */
+
+static const uint8_t crc8_table[256] = {
+ 0x00, 0xF7, 0xB9, 0x4E, 0x25, 0xD2, 0x9C, 0x6B,
+ 0x4A, 0xBD, 0xF3, 0x04, 0x6F, 0x98, 0xD6, 0x21,
+ 0x94, 0x63, 0x2D, 0xDA, 0xB1, 0x46, 0x08, 0xFF,
+ 0xDE, 0x29, 0x67, 0x90, 0xFB, 0x0C, 0x42, 0xB5,
+ 0x7F, 0x88, 0xC6, 0x31, 0x5A, 0xAD, 0xE3, 0x14,
+ 0x35, 0xC2, 0x8C, 0x7B, 0x10, 0xE7, 0xA9, 0x5E,
+ 0xEB, 0x1C, 0x52, 0xA5, 0xCE, 0x39, 0x77, 0x80,
+ 0xA1, 0x56, 0x18, 0xEF, 0x84, 0x73, 0x3D, 0xCA,
+ 0xFE, 0x09, 0x47, 0xB0, 0xDB, 0x2C, 0x62, 0x95,
+ 0xB4, 0x43, 0x0D, 0xFA, 0x91, 0x66, 0x28, 0xDF,
+ 0x6A, 0x9D, 0xD3, 0x24, 0x4F, 0xB8, 0xF6, 0x01,
+ 0x20, 0xD7, 0x99, 0x6E, 0x05, 0xF2, 0xBC, 0x4B,
+ 0x81, 0x76, 0x38, 0xCF, 0xA4, 0x53, 0x1D, 0xEA,
+ 0xCB, 0x3C, 0x72, 0x85, 0xEE, 0x19, 0x57, 0xA0,
+ 0x15, 0xE2, 0xAC, 0x5B, 0x30, 0xC7, 0x89, 0x7E,
+ 0x5F, 0xA8, 0xE6, 0x11, 0x7A, 0x8D, 0xC3, 0x34,
+ 0xAB, 0x5C, 0x12, 0xE5, 0x8E, 0x79, 0x37, 0xC0,
+ 0xE1, 0x16, 0x58, 0xAF, 0xC4, 0x33, 0x7D, 0x8A,
+ 0x3F, 0xC8, 0x86, 0x71, 0x1A, 0xED, 0xA3, 0x54,
+ 0x75, 0x82, 0xCC, 0x3B, 0x50, 0xA7, 0xE9, 0x1E,
+ 0xD4, 0x23, 0x6D, 0x9A, 0xF1, 0x06, 0x48, 0xBF,
+ 0x9E, 0x69, 0x27, 0xD0, 0xBB, 0x4C, 0x02, 0xF5,
+ 0x40, 0xB7, 0xF9, 0x0E, 0x65, 0x92, 0xDC, 0x2B,
+ 0x0A, 0xFD, 0xB3, 0x44, 0x2F, 0xD8, 0x96, 0x61,
+ 0x55, 0xA2, 0xEC, 0x1B, 0x70, 0x87, 0xC9, 0x3E,
+ 0x1F, 0xE8, 0xA6, 0x51, 0x3A, 0xCD, 0x83, 0x74,
+ 0xC1, 0x36, 0x78, 0x8F, 0xE4, 0x13, 0x5D, 0xAA,
+ 0x8B, 0x7C, 0x32, 0xC5, 0xAE, 0x59, 0x17, 0xE0,
+ 0x2A, 0xDD, 0x93, 0x64, 0x0F, 0xF8, 0xB6, 0x41,
+ 0x60, 0x97, 0xD9, 0x2E, 0x45, 0xB2, 0xFC, 0x0B,
+ 0xBE, 0x49, 0x07, 0xF0, 0x9B, 0x6C, 0x22, 0xD5,
+ 0xF4, 0x03, 0x4D, 0xBA, 0xD1, 0x26, 0x68, 0x9F
+};
+
+uint8_t hndcrc8 (
+ uint8_t * pdata, /* pointer to array of data to process */
+ uint32_t nbytes, /* number of input data bytes to process */
+ uint8_t crc /* either CRC8_INIT_VALUE or previous return value */
+) {
+ while (nbytes-- > 0)
+ crc = crc8_table[(crc ^ *pdata++) & 0xff];
+
+ return crc;
+}
diff --git a/package/system/utils/nvram/src/nvram.c b/package/system/utils/nvram/src/nvram.c
new file mode 100644
index 0000000..a0bc006
--- /dev/null
+++ b/package/system/utils/nvram/src/nvram.c
@@ -0,0 +1,556 @@
+/*
+ * NVRAM variable manipulation (common)
+ *
+ * Copyright 2004, Broadcom Corporation
+ * Copyright 2009-2010, OpenWrt.org
+ * All Rights Reserved.
+ *
+ * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
+ * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
+ * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
+ * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
+ *
+ */
+
+#include "nvram.h"
+
+#define TRACE(msg) \
+ printf("%s(%i) in %s(): %s\n", \
+ __FILE__, __LINE__, __FUNCTION__, msg ? msg : "?")
+
+size_t nvram_erase_size = 0;
+
+
+/*
+ * -- Helper functions --
+ */
+
+/* String hash */
+static uint32_t hash(const char *s)
+{
+ uint32_t hash = 0;
+
+ while (*s)
+ hash = 31 * hash + *s++;
+
+ return hash;
+}
+
+/* Free all tuples. */
+static void _nvram_free(nvram_handle_t *h)
+{
+ uint32_t i;
+ nvram_tuple_t *t, *next;
+
+ /* Free hash table */
+ for (i = 0; i < NVRAM_ARRAYSIZE(h->nvram_hash); i++) {
+ for (t = h->nvram_hash[i]; t; t = next) {
+ next = t->next;
+ free(t);
+ }
+ h->nvram_hash[i] = NULL;
+ }
+
+ /* Free dead table */
+ for (t = h->nvram_dead; t; t = next) {
+ next = t->next;
+ free(t);
+ }
+
+ h->nvram_dead = NULL;
+}
+
+/* (Re)allocate NVRAM tuples. */
+static nvram_tuple_t * _nvram_realloc( nvram_handle_t *h, nvram_tuple_t *t,
+ const char *name, const char *value )
+{
+ if ((strlen(value) + 1) > NVRAM_SPACE)
+ return NULL;
+
+ if (!t) {
+ if (!(t = malloc(sizeof(nvram_tuple_t) + strlen(name) + 1)))
+ return NULL;
+
+ /* Copy name */
+ t->name = (char *) &t[1];
+ strcpy(t->name, name);
+
+ t->value = NULL;
+ }
+
+ /* Copy value */
+ if (!t->value || strcmp(t->value, value))
+ {
+ if(!(t->value = (char *) realloc(t->value, strlen(value)+1)))
+ return NULL;
+
+ strcpy(t->value, value);
+ t->value[strlen(value)] = '\0';
+ }
+
+ return t;
+}
+
+/* (Re)initialize the hash table. */
+static int _nvram_rehash(nvram_handle_t *h)
+{
+ nvram_header_t *header = nvram_header(h);
+ char buf[] = "0xXXXXXXXX", *name, *value, *eq;
+
+ /* (Re)initialize hash table */
+ _nvram_free(h);
+
+ /* Parse and set "name=value\0 ... \0\0" */
+ name = (char *) &header[1];
+
+ for (; *name; name = value + strlen(value) + 1) {
+ if (!(eq = strchr(name, '=')))
+ break;
+ *eq = '\0';
+ value = eq + 1;
+ nvram_set(h, name, value);
+ *eq = '=';
+ }
+
+ /* Set special SDRAM parameters */
+ if (!nvram_get(h, "sdram_init")) {
+ sprintf(buf, "0x%04X", (uint16_t)(header->crc_ver_init >> 16));
+ nvram_set(h, "sdram_init", buf);
+ }
+ if (!nvram_get(h, "sdram_config")) {
+ sprintf(buf, "0x%04X", (uint16_t)(header->config_refresh & 0xffff));
+ nvram_set(h, "sdram_config", buf);
+ }
+ if (!nvram_get(h, "sdram_refresh")) {
+ sprintf(buf, "0x%04X",
+ (uint16_t)((header->config_refresh >> 16) & 0xffff));
+ nvram_set(h, "sdram_refresh", buf);
+ }
+ if (!nvram_get(h, "sdram_ncdl")) {
+ sprintf(buf, "0x%08X", header->config_ncdl);
+ nvram_set(h, "sdram_ncdl", buf);
+ }
+
+ return 0;
+}
+
+
+/*
+ * -- Public functions --
+ */
+
+/* Get nvram header. */
+nvram_header_t * nvram_header(nvram_handle_t *h)
+{
+ return (nvram_header_t *) &h->mmap[h->offset];
+}
+
+/* Get the value of an NVRAM variable. */
+char * nvram_get(nvram_handle_t *h, const char *name)
+{
+ uint32_t i;
+ nvram_tuple_t *t;
+ char *value;
+
+ if (!name)
+ return NULL;
+
+ /* Hash the name */
+ i = hash(name) % NVRAM_ARRAYSIZE(h->nvram_hash);
+
+ /* Find the associated tuple in the hash table */
+ for (t = h->nvram_hash[i]; t && strcmp(t->name, name); t = t->next);
+
+ value = t ? t->value : NULL;
+
+ return value;
+}
+
+/* Set the value of an NVRAM variable. */
+int nvram_set(nvram_handle_t *h, const char *name, const char *value)
+{
+ uint32_t i;
+ nvram_tuple_t *t, *u, **prev;
+
+ /* Hash the name */
+ i = hash(name) % NVRAM_ARRAYSIZE(h->nvram_hash);
+
+ /* Find the associated tuple in the hash table */
+ for (prev = &h->nvram_hash[i], t = *prev;
+ t && strcmp(t->name, name); prev = &t->next, t = *prev);
+
+ /* (Re)allocate tuple */
+ if (!(u = _nvram_realloc(h, t, name, value)))
+ return -12; /* -ENOMEM */
+
+ /* Value reallocated */
+ if (t && t == u)
+ return 0;
+
+ /* Move old tuple to the dead table */
+ if (t) {
+ *prev = t->next;
+ t->next = h->nvram_dead;
+ h->nvram_dead = t;
+ }
+
+ /* Add new tuple to the hash table */
+ u->next = h->nvram_hash[i];
+ h->nvram_hash[i] = u;
+
+ return 0;
+}
+
+/* Unset the value of an NVRAM variable. */
+int nvram_unset(nvram_handle_t *h, const char *name)
+{
+ uint32_t i;
+ nvram_tuple_t *t, **prev;
+
+ if (!name)
+ return 0;
+
+ /* Hash the name */
+ i = hash(name) % NVRAM_ARRAYSIZE(h->nvram_hash);
+
+ /* Find the associated tuple in the hash table */
+ for (prev = &h->nvram_hash[i], t = *prev;
+ t && strcmp(t->name, name); prev = &t->next, t = *prev);
+
+ /* Move it to the dead table */
+ if (t) {
+ *prev = t->next;
+ t->next = h->nvram_dead;
+ h->nvram_dead = t;
+ }
+
+ return 0;
+}
+
+/* Get all NVRAM variables. */
+nvram_tuple_t * nvram_getall(nvram_handle_t *h)
+{
+ int i;
+ nvram_tuple_t *t, *l, *x;
+
+ l = NULL;
+
+ for (i = 0; i < NVRAM_ARRAYSIZE(h->nvram_hash); i++) {
+ for (t = h->nvram_hash[i]; t; t = t->next) {
+ if( (x = (nvram_tuple_t *) malloc(sizeof(nvram_tuple_t))) != NULL )
+ {
+ x->name = t->name;
+ x->value = t->value;
+ x->next = l;
+ l = x;
+ }
+ else
+ {
+ break;
+ }
+ }
+ }
+
+ return l;
+}
+
+/* Regenerate NVRAM. */
+int nvram_commit(nvram_handle_t *h)
+{
+ nvram_header_t *header = nvram_header(h);
+ char *init, *config, *refresh, *ncdl;
+ char *ptr, *end;
+ int i;
+ nvram_tuple_t *t;
+ nvram_header_t tmp;
+ uint8_t crc;
+
+ /* Regenerate header */
+ header->magic = NVRAM_MAGIC;
+ header->crc_ver_init = (NVRAM_VERSION << 8);
+ if (!(init = nvram_get(h, "sdram_init")) ||
+ !(config = nvram_get(h, "sdram_config")) ||
+ !(refresh = nvram_get(h, "sdram_refresh")) ||
+ !(ncdl = nvram_get(h, "sdram_ncdl"))) {
+ header->crc_ver_init |= SDRAM_INIT << 16;
+ header->config_refresh = SDRAM_CONFIG;
+ header->config_refresh |= SDRAM_REFRESH << 16;
+ header->config_ncdl = 0;
+ } else {
+ header->crc_ver_init |= (strtoul(init, NULL, 0) & 0xffff) << 16;
+ header->config_refresh = strtoul(config, NULL, 0) & 0xffff;
+ header->config_refresh |= (strtoul(refresh, NULL, 0) & 0xffff) << 16;
+ header->config_ncdl = strtoul(ncdl, NULL, 0);
+ }
+
+ /* Clear data area */
+ ptr = (char *) header + sizeof(nvram_header_t);
+ memset(ptr, 0xFF, NVRAM_SPACE - sizeof(nvram_header_t));
+ memset(&tmp, 0, sizeof(nvram_header_t));
+
+ /* Leave space for a double NUL at the end */
+ end = (char *) header + NVRAM_SPACE - 2;
+
+ /* Write out all tuples */
+ for (i = 0; i < NVRAM_ARRAYSIZE(h->nvram_hash); i++) {
+ for (t = h->nvram_hash[i]; t; t = t->next) {
+ if ((ptr + strlen(t->name) + 1 + strlen(t->value) + 1) > end)
+ break;
+ ptr += sprintf(ptr, "%s=%s", t->name, t->value) + 1;
+ }
+ }
+
+ /* End with a double NULL and pad to 4 bytes */
+ *ptr = '\0';
+ ptr++;
+
+ if( (int)ptr % 4 )
+ memset(ptr, 0, 4 - ((int)ptr % 4));
+
+ ptr++;
+
+ /* Set new length */
+ header->len = NVRAM_ROUNDUP(ptr - (char *) header, 4);
+
+ /* Little-endian CRC8 over the last 11 bytes of the header */
+ tmp.crc_ver_init = header->crc_ver_init;
+ tmp.config_refresh = header->config_refresh;
+ tmp.config_ncdl = header->config_ncdl;
+ crc = hndcrc8((unsigned char *) &tmp + NVRAM_CRC_START_POSITION,
+ sizeof(nvram_header_t) - NVRAM_CRC_START_POSITION, 0xff);
+
+ /* Continue CRC8 over data bytes */
+ crc = hndcrc8((unsigned char *) &header[0] + sizeof(nvram_header_t),
+ header->len - sizeof(nvram_header_t), crc);
+
+ /* Set new CRC8 */
+ header->crc_ver_init |= crc;
+
+ /* Write out */
+ msync(h->mmap, h->length, MS_SYNC);
+ fsync(h->fd);
+
+ /* Reinitialize hash table */
+ return _nvram_rehash(h);
+}
+
+/* Open NVRAM and obtain a handle. */
+nvram_handle_t * nvram_open(const char *file, int rdonly)
+{
+ int i;
+ int fd;
+ char *mtd = NULL;
+ nvram_handle_t *h;
+ nvram_header_t *header;
+ int offset = -1;
+
+ /* If erase size or file are undefined then try to define them */
+ if( (nvram_erase_size == 0) || (file == NULL) )
+ {
+ /* Finding the mtd will set the appropriate erase size */
+ if( (mtd = nvram_find_mtd()) == NULL || nvram_erase_size == 0 )
+ {
+ free(mtd);
+ return NULL;
+ }
+ }
+
+ if( (fd = open(file ? file : mtd, O_RDWR)) > -1 )
+ {
+ char *mmap_area = (char *) mmap(
+ NULL, nvram_erase_size, PROT_READ | PROT_WRITE,
+ (( rdonly == NVRAM_RO ) ? MAP_PRIVATE : MAP_SHARED) | MAP_LOCKED, fd, 0);
+
+ if( mmap_area != MAP_FAILED )
+ {
+ for( i = 0; i <= ((nvram_erase_size - NVRAM_SPACE) / sizeof(uint32_t)); i++ )
+ {
+ if( ((uint32_t *)mmap_area)[i] == NVRAM_MAGIC )
+ {
+ offset = i * sizeof(uint32_t);
+ break;
+ }
+ }
+
+ if( offset < 0 )
+ {
+ free(mtd);
+ return NULL;
+ }
+ else if( (h = malloc(sizeof(nvram_handle_t))) != NULL )
+ {
+ memset(h, 0, sizeof(nvram_handle_t));
+
+ h->fd = fd;
+ h->mmap = mmap_area;
+ h->length = nvram_erase_size;
+ h->offset = offset;
+
+ header = nvram_header(h);
+
+ if( header->magic == NVRAM_MAGIC )
+ {
+ _nvram_rehash(h);
+ free(mtd);
+ return h;
+ }
+ else
+ {
+ munmap(h->mmap, h->length);
+ free(h);
+ }
+ }
+ }
+ }
+
+ free(mtd);
+ return NULL;
+}
+
+/* Close NVRAM and free memory. */
+int nvram_close(nvram_handle_t *h)
+{
+ _nvram_free(h);
+ munmap(h->mmap, h->length);
+ close(h->fd);
+ free(h);
+
+ return 0;
+}
+
+/* Determine NVRAM device node. */
+char * nvram_find_mtd(void)
+{
+ FILE *fp;
+ int i, esz;
+ char dev[PATH_MAX];
+ char *path = NULL;
+ struct stat s;
+ int supported = 1;
+
+ /* Refuse any operation on the WGT634U */
+ if( (fp = fopen("/proc/diag/model", "r")) )
+ {
+ if( fgets(dev, sizeof(dev), fp) && !strncmp(dev, "Netgear WGT634U", 15) )
+ supported = 0;
+
+ fclose(fp);
+ }
+
+ if( supported && (fp = fopen("/proc/mtd", "r")) )
+ {
+ while( fgets(dev, sizeof(dev), fp) )
+ {
+ if( strstr(dev, "nvram") && sscanf(dev, "mtd%d: %08x", &i, &esz) )
+ {
+ nvram_erase_size = esz;
+
+ sprintf(dev, "/dev/mtdblock/%d", i);
+ if( stat(dev, &s) > -1 && (s.st_mode & S_IFBLK) )
+ {
+ if( (path = (char *) malloc(strlen(dev)+1)) != NULL )
+ {
+ strncpy(path, dev, strlen(dev)+1);
+ break;
+ }
+ }
+ else
+ {
+ sprintf(dev, "/dev/mtdblock%d", i);
+ if( stat(dev, &s) > -1 && (s.st_mode & S_IFBLK) )
+ {
+ if( (path = (char *) malloc(strlen(dev)+1)) != NULL )
+ {
+ strncpy(path, dev, strlen(dev)+1);
+ break;
+ }
+ }
+ }
+ }
+ }
+ fclose(fp);
+ }
+
+ return path;
+}
+
+/* Check NVRAM staging file. */
+char * nvram_find_staging(void)
+{
+ struct stat s;
+
+ if( (stat(NVRAM_STAGING, &s) > -1) && (s.st_mode & S_IFREG) )
+ {
+ return NVRAM_STAGING;
+ }
+
+ return NULL;
+}
+
+/* Copy NVRAM contents to staging file. */
+int nvram_to_staging(void)
+{
+ int fdmtd, fdstg, stat;
+ char *mtd = nvram_find_mtd();
+ char buf[nvram_erase_size];
+
+ stat = -1;
+
+ if( (mtd != NULL) && (nvram_erase_size > 0) )
+ {
+ if( (fdmtd = open(mtd, O_RDONLY)) > -1 )
+ {
+ if( read(fdmtd, buf, sizeof(buf)) == sizeof(buf) )
+ {
+ if((fdstg = open(NVRAM_STAGING, O_WRONLY | O_CREAT, 0600)) > -1)
+ {
+ write(fdstg, buf, sizeof(buf));
+ fsync(fdstg);
+ close(fdstg);
+
+ stat = 0;
+ }
+ }
+
+ close(fdmtd);
+ }
+ }
+
+ free(mtd);
+ return stat;
+}
+
+/* Copy staging file to NVRAM device. */
+int staging_to_nvram(void)
+{
+ int fdmtd, fdstg, stat;
+ char *mtd = nvram_find_mtd();
+ char buf[nvram_erase_size];
+
+ stat = -1;
+
+ if( (mtd != NULL) && (nvram_erase_size > 0) )
+ {
+ if( (fdstg = open(NVRAM_STAGING, O_RDONLY)) > -1 )
+ {
+ if( read(fdstg, buf, sizeof(buf)) == sizeof(buf) )
+ {
+ if( (fdmtd = open(mtd, O_WRONLY | O_SYNC)) > -1 )
+ {
+ write(fdmtd, buf, sizeof(buf));
+ fsync(fdmtd);
+ close(fdmtd);
+ stat = 0;
+ }
+ }
+
+ close(fdstg);
+
+ if( !stat )
+ stat = unlink(NVRAM_STAGING) ? 1 : 0;
+ }
+ }
+
+ free(mtd);
+ return stat;
+}
diff --git a/package/system/utils/nvram/src/nvram.h b/package/system/utils/nvram/src/nvram.h
new file mode 100644
index 0000000..c72f67e
--- /dev/null
+++ b/package/system/utils/nvram/src/nvram.h
@@ -0,0 +1,123 @@
+/*
+ * NVRAM variable manipulation
+ *
+ * Copyright 2007, Broadcom Corporation
+ * Copyright 2009, OpenWrt.org
+ * All Rights Reserved.
+ *
+ * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
+ * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
+ * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
+ * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
+ *
+ */
+
+#ifndef _nvram_h_
+#define _nvram_h_
+
+#include <stdint.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <errno.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <linux/limits.h>
+
+#include "sdinitvals.h"
+
+
+struct nvram_header {
+ uint32_t magic;
+ uint32_t len;
+ uint32_t crc_ver_init; /* 0:7 crc, 8:15 ver, 16:31 sdram_init */
+ uint32_t config_refresh; /* 0:15 sdram_config, 16:31 sdram_refresh */
+ uint32_t config_ncdl; /* ncdl values for memc */
+} __attribute__((__packed__));
+
+struct nvram_tuple {
+ char *name;
+ char *value;
+ struct nvram_tuple *next;
+};
+
+struct nvram_handle {
+ int fd;
+ char *mmap;
+ unsigned int length;
+ unsigned int offset;
+ struct nvram_tuple *nvram_hash[257];
+ struct nvram_tuple *nvram_dead;
+};
+
+typedef struct nvram_handle nvram_handle_t;
+typedef struct nvram_header nvram_header_t;
+typedef struct nvram_tuple nvram_tuple_t;
+
+
+/* Get nvram header. */
+nvram_header_t * nvram_header(nvram_handle_t *h);
+
+/* Set the value of an NVRAM variable */
+int nvram_set(nvram_handle_t *h, const char *name, const char *value);
+
+/* Get the value of an NVRAM variable. */
+char * nvram_get(nvram_handle_t *h, const char *name);
+
+/* Unset the value of an NVRAM variable. */
+int nvram_unset(nvram_handle_t *h, const char *name);
+
+/* Get all NVRAM variables. */
+nvram_tuple_t * nvram_getall(nvram_handle_t *h);
+
+/* Regenerate NVRAM. */
+int nvram_commit(nvram_handle_t *h);
+
+/* Open NVRAM and obtain a handle. */
+nvram_handle_t * nvram_open(const char *file, int rdonly);
+
+/* Close NVRAM and free memory. */
+int nvram_close(nvram_handle_t *h);
+
+/* Get the value of an NVRAM variable in a safe way, use "" instead of NULL. */
+#define nvram_safe_get(h, name) (nvram_get(h, name) ? : "")
+
+/* Computes a crc8 over the input data. */
+uint8_t hndcrc8 (uint8_t * pdata, uint32_t nbytes, uint8_t crc);
+
+/* Returns the crc value of the nvram. */
+uint8_t nvram_calc_crc(nvram_header_t * nvh);
+
+/* Determine NVRAM device node. */
+char * nvram_find_mtd(void);
+
+/* Copy NVRAM contents to staging file. */
+int nvram_to_staging(void);
+
+/* Copy staging file to NVRAM device. */
+int staging_to_nvram(void);
+
+/* Check NVRAM staging file. */
+char * nvram_find_staging(void);
+
+
+/* Staging file for NVRAM */
+#define NVRAM_STAGING "/tmp/.nvram"
+#define NVRAM_RO 1
+#define NVRAM_RW 0
+
+/* Helper macros */
+#define NVRAM_ARRAYSIZE(a) sizeof(a)/sizeof(a[0])
+#define NVRAM_ROUNDUP(x, y) ((((x)+((y)-1))/(y))*(y))
+
+/* NVRAM constants */
+#define NVRAM_SPACE 0x8000
+#define NVRAM_MAGIC 0x48534C46 /* 'FLSH' */
+#define NVRAM_VERSION 1
+
+#define NVRAM_CRC_START_POSITION 9 /* magic, len, crc8 to be skipped */
+
+
+#endif /* _nvram_h_ */
diff --git a/package/system/utils/nvram/src/sdinitvals.h b/package/system/utils/nvram/src/sdinitvals.h
new file mode 100644
index 0000000..5a289ad
--- /dev/null
+++ b/package/system/utils/nvram/src/sdinitvals.h
@@ -0,0 +1,30 @@
+/*
+ * SDRAM init values
+ *
+ * Copyright 2007, Broadcom Corporation
+ * Copyright 2009, OpenWrt.org
+ * All Rights Reserved.
+ *
+ * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
+ * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
+ * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
+ * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
+ *
+ */
+
+#ifndef _sdinitvals_h_
+#define _sdinitvals_h_
+
+/* SDRAM refresh control (refresh) register bits */
+#define SDRAM_REF(p) (((p)&0xff) | SDRAM_REF_EN) /* Refresh period */
+#define SDRAM_REF_EN 0x8000 /* Writing 1 enables periodic refresh */
+
+/* SDRAM Core default Init values (OCP ID 0x803) */
+#define MEM4MX16X2 0x419 /* 16 MB */
+
+#define SDRAM_INIT MEM4MX16X2
+#define SDRAM_BURSTFULL 0x0000 /* Use full page bursts */
+#define SDRAM_CONFIG SDRAM_BURSTFULL
+#define SDRAM_REFRESH SDRAM_REF(0x40)
+
+#endif /* _sdinitvals_h_ */
diff --git a/package/system/utils/robocfg/.svn/entries b/package/system/utils/robocfg/.svn/entries
new file mode 100644
index 0000000..535958d
--- /dev/null
+++ b/package/system/utils/robocfg/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/system/utils/robocfg
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-29T10:48:46.063504Z
+35375
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+src
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+d1a244eb11bd13730616508fb8e5faa0
+2013-01-29T10:48:46.063504Z
+35375
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+804
+
diff --git a/package/system/utils/robocfg/.svn/prop-base/Makefile.svn-base b/package/system/utils/robocfg/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..8e522ae
--- /dev/null
+++ b/package/system/utils/robocfg/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:copyright
+V 30
+Copyright (C) 2006 OpenWrt.org
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/system/utils/robocfg/.svn/text-base/Makefile.svn-base b/package/system/utils/robocfg/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..4bc72f5
--- /dev/null
+++ b/package/system/utils/robocfg/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,39 @@
+#
+# Copyright (C) 2006 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=robocfg
+PKG_VERSION:=0.01
+PKG_RELEASE:=1
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/robocfg
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/robocfg
+ SECTION:=utils
+ CATEGORY:=Utilities
+ TITLE:=BCM5325E/536x switch configuration utility
+endef
+
+define Package/robocfg/description
+ This package contains an utility for configuring the Broadcom BCM5325E/536x
+ based switches.
+endef
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+define Package/robocfg/install
+ $(INSTALL_DIR) $(1)/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/robocfg $(1)/sbin/
+endef
+
+$(eval $(call BuildPackage,robocfg))
diff --git a/package/system/utils/robocfg/Makefile b/package/system/utils/robocfg/Makefile
new file mode 100644
index 0000000..4bc72f5
--- /dev/null
+++ b/package/system/utils/robocfg/Makefile
@@ -0,0 +1,39 @@
+#
+# Copyright (C) 2006 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=robocfg
+PKG_VERSION:=0.01
+PKG_RELEASE:=1
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/robocfg
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/robocfg
+ SECTION:=utils
+ CATEGORY:=Utilities
+ TITLE:=BCM5325E/536x switch configuration utility
+endef
+
+define Package/robocfg/description
+ This package contains an utility for configuring the Broadcom BCM5325E/536x
+ based switches.
+endef
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+define Package/robocfg/install
+ $(INSTALL_DIR) $(1)/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/robocfg $(1)/sbin/
+endef
+
+$(eval $(call BuildPackage,robocfg))
diff --git a/package/system/utils/robocfg/src/.svn/entries b/package/system/utils/robocfg/src/.svn/entries
new file mode 100644
index 0000000..57958c9
--- /dev/null
+++ b/package/system/utils/robocfg/src/.svn/entries
@@ -0,0 +1,130 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/system/utils/robocfg/src
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-29T10:48:46.063504Z
+35375
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+robocfg.c
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+fb4cce6dd0f612b20d916ab2cddaadec
+2013-01-29T10:48:46.063504Z
+35375
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+17107
+
+etc53xx.h
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+3e6733ba40bcb0f66b516432806d7d49
+2013-01-29T10:48:46.063504Z
+35375
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+30828
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+69ea3956996292cfb4a1fb03756feacc
+2013-01-29T10:48:46.063504Z
+35375
+nbd
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+132
+
diff --git a/package/system/utils/robocfg/src/.svn/prop-base/Makefile.svn-base b/package/system/utils/robocfg/src/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/system/utils/robocfg/src/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/system/utils/robocfg/src/.svn/prop-base/etc53xx.h.svn-base b/package/system/utils/robocfg/src/.svn/prop-base/etc53xx.h.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/system/utils/robocfg/src/.svn/prop-base/etc53xx.h.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/system/utils/robocfg/src/.svn/prop-base/robocfg.c.svn-base b/package/system/utils/robocfg/src/.svn/prop-base/robocfg.c.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/system/utils/robocfg/src/.svn/prop-base/robocfg.c.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/system/utils/robocfg/src/.svn/text-base/Makefile.svn-base b/package/system/utils/robocfg/src/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..e11acb0
--- /dev/null
+++ b/package/system/utils/robocfg/src/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,11 @@
+
+all: robocfg
+
+%.o: %.c
+ $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $^
+
+robocfg: robocfg.o
+ $(CC) -o $@ $^
+
+clean:
+ rm -f *.o robocfg
diff --git a/package/system/utils/robocfg/src/.svn/text-base/etc53xx.h.svn-base b/package/system/utils/robocfg/src/.svn/text-base/etc53xx.h.svn-base
new file mode 100644
index 0000000..d5b1310
--- /dev/null
+++ b/package/system/utils/robocfg/src/.svn/text-base/etc53xx.h.svn-base
@@ -0,0 +1,619 @@
+/*
+ * Broadcom Home Gateway Reference Design
+ * BCM53xx Register definitions
+ *
+ * Copyright 2004, Broadcom Corporation
+ * All Rights Reserved.
+ *
+ * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
+ * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
+ * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
+ * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
+ */
+
+#ifndef __BCM535M_H_
+#define __BCM535M_H_
+
+/* ROBO embedded device type */
+#define ROBO_DEV_5380 1
+#define ROBO_DEV_5365 2
+#define ROBO_DEV_5350 3
+
+/* BCM5325m GLOBAL PAGE REGISTER MAP */
+#ifndef _CFE_
+#pragma pack(1)
+#endif
+
+/* BCM5325m Serial Management Port (SMP) Page offsets */
+#define ROBO_CTRL_PAGE 0x00 /* Control registers */
+#define ROBO_STAT_PAGE 0x01 /* Status register */
+#define ROBO_MGMT_PAGE 0x02 /* Management Mode registers */
+#define ROBO_MIB_AC_PAGE 0x03 /* MIB Autocast registers */
+#define ROBO_ARLCTRL_PAGE 0x04 /* ARL Control Registers */
+#define ROBO_ARLIO_PAGE 0x05 /* ARL Access Registers */
+#define ROBO_FRAMEBUF_PAGE 0x06 /* Management frame access registers */
+#define ROBO_MEM_ACCESS_PAGE 0x08 /* Memory access registers */
+
+/* PHY Registers */
+#define ROBO_PORT0_MII_PAGE 0x10 /* Port 0 MII Registers */
+#define ROBO_PORT1_MII_PAGE 0x11 /* Port 1 MII Registers */
+#define ROBO_PORT2_MII_PAGE 0x12 /* Port 2 MII Registers */
+#define ROBO_PORT3_MII_PAGE 0x13 /* Port 3 MII Registers */
+#define ROBO_PORT4_MII_PAGE 0x14 /* Port 4 MII Registers */
+/* (start) registers only for BCM5380 */
+#define ROBO_PORT5_MII_PAGE 0x15 /* Port 5 MII Registers */
+#define ROBO_PORT6_MII_PAGE 0x16 /* Port 6 MII Registers */
+#define ROBO_PORT7_MII_PAGE 0x17 /* Port 7 MII Registers */
+/* (end) registers only for BCM5380 */
+#define ROBO_IM_PORT_PAGE 0x18 /* Inverse MII Port (to EMAC) */
+#define ROBO_ALL_PORT_PAGE 0x19 /* All ports MII Registers (broadcast)*/
+
+/* MAC Statistics registers */
+#define ROBO_PORT0_MIB_PAGE 0x20 /* Port 0 10/100 MIB Statistics */
+#define ROBO_PORT1_MIB_PAGE 0x21 /* Port 1 10/100 MIB Statistics */
+#define ROBO_PORT2_MIB_PAGE 0x22 /* Port 2 10/100 MIB Statistics */
+#define ROBO_PORT3_MIB_PAGE 0x23 /* Port 3 10/100 MIB Statistics */
+#define ROBO_PORT4_MIB_PAGE 0x24 /* Port 4 10/100 MIB Statistics */
+/* (start) registers only for BCM5380 */
+#define ROBO_PORT5_MIB_PAGE 0x25 /* Port 5 10/100 MIB Statistics */
+#define ROBO_PORT6_MIB_PAGE 0x26 /* Port 6 10/100 MIB Statistics */
+#define ROBO_PORT7_MIB_PAGE 0x27 /* Port 7 10/100 MIB Statistics */
+/* (end) registers only for BCM5380 */
+#define ROBO_IM_PORT_MIB_PAGE 0x28 /* Inverse MII Port MIB Statistics */
+
+/* Quality of Service (QoS) Registers */
+#define ROBO_QOS_PAGE 0x30 /* QoS Registers */
+
+/* VLAN Registers */
+#define ROBO_VLAN_PAGE 0x34 /* VLAN Registers */
+
+/* Note SPI Data/IO Registers not used */
+#define ROBO_SPI_DATA_IO_0_PAGE 0xf0 /* SPI Data I/O 0 */
+#define ROBO_SPI_DATA_IO_1_PAGE 0xf1 /* SPI Data I/O 1 */
+#define ROBO_SPI_DATA_IO_2_PAGE 0xf2 /* SPI Data I/O 2 */
+#define ROBO_SPI_DATA_IO_3_PAGE 0xf3 /* SPI Data I/O 3 */
+#define ROBO_SPI_DATA_IO_4_PAGE 0xf4 /* SPI Data I/O 4 */
+#define ROBO_SPI_DATA_IO_5_PAGE 0xf5 /* SPI Data I/O 5 */
+#define ROBO_SPI_DATA_IO_6_PAGE 0xf6 /* SPI Data I/O 6 */
+#define ROBO_SPI_DATA_IO_7_PAGE 0xf7 /* SPI Data I/O 7 */
+
+#define ROBO_SPI_STATUS_PAGE 0xfe /* SPI Status Registers */
+#define ROBO_PAGE_PAGE 0xff /* Page Registers */
+
+
+/* BCM5325m CONTROL PAGE (0x00) REGISTER MAP : 8bit (byte) registers */
+typedef struct _ROBO_PORT_CTRL_STRUC
+{
+ unsigned char rx_disable:1; /* rx disable */
+ unsigned char tx_disable:1; /* tx disable */
+ unsigned char rsvd:3; /* reserved */
+ unsigned char stp_state:3; /* spanning tree state */
+} ROBO_PORT_CTRL_STRUC;
+
+#define ROBO_PORT0_CTRL 0x00 /* 10/100 Port 0 Control */
+#define ROBO_PORT1_CTRL 0x01 /* 10/100 Port 1 Control */
+#define ROBO_PORT2_CTRL 0x02 /* 10/100 Port 2 Control */
+#define ROBO_PORT3_CTRL 0x03 /* 10/100 Port 3 Control */
+#define ROBO_PORT4_CTRL 0x04 /* 10/100 Port 4 Control */
+/* (start) registers only for BCM5380 */
+#define ROBO_PORT5_CTRL 0x05 /* 10/100 Port 5 Control */
+#define ROBO_PORT6_CTRL 0x06 /* 10/100 Port 6 Control */
+#define ROBO_PORT7_CTRL 0x07 /* 10/100 Port 7 Control */
+/* (end) registers only for BCM5380 */
+#define ROBO_IM_PORT_CTRL 0x08 /* 10/100 Port 8 Control */
+#define ROBO_SMP_CTRL 0x0a /* SMP Control register */
+#define ROBO_SWITCH_MODE 0x0b /* Switch Mode Control */
+#define ROBO_PORT_OVERRIDE_CTRL 0x0e /* Port state override */
+#define ROBO_PORT_OVERRIDE_RVMII (1<<4) /* Bit 4 enables RvMII */
+#define ROBO_PD_MODE_CTRL 0x0f /* Power-down mode control */
+#define ROBO_IP_MULTICAST_CTRL 0x21 /* IP Multicast control */
+
+/* BCM5325m STATUS PAGE (0x01) REGISTER MAP : 16bit/48bit registers */
+#define ROBO_HALF_DUPLEX 0
+#define ROBO_FULL_DUPLEX 1
+
+#define ROBO_LINK_STAT_SUMMARY 0x00 /* Link Status Summary: 16bit */
+#define ROBO_LINK_STAT_CHANGE 0x02 /* Link Status Change: 16bit */
+#define ROBO_SPEED_STAT_SUMMARY 0x04 /* Port Speed Summary: 16bit*/
+#define ROBO_DUPLEX_STAT_SUMMARY 0x06 /* Duplex Status Summary: 16bit */
+#define ROBO_PAUSE_STAT_SUMMARY 0x08 /* PAUSE Status Summary: 16bit */
+#define ROBO_SOURCE_ADDR_CHANGE 0x0C /* Source Address Change: 16bit */
+#define ROBO_LSA_PORT0 0x10 /* Last Source Addr, Port 0: 48bits*/
+#define ROBO_LSA_PORT1 0x16 /* Last Source Addr, Port 1: 48bits*/
+#define ROBO_LSA_PORT2 0x1c /* Last Source Addr, Port 2: 48bits*/
+#define ROBO_LSA_PORT3 0x22 /* Last Source Addr, Port 3: 48bits*/
+#define ROBO_LSA_PORT4 0x28 /* Last Source Addr, Port 4: 48bits*/
+#define ROBO_LSA_IM_PORT 0x40 /* Last Source Addr, IM Port: 48bits*/
+
+/* BCM5325m MANAGEMENT MODE REGISTERS (0x02) REGISTER MAP: 8/48 bit regs*/
+typedef struct _ROBO_GLOBAL_CONFIG_STRUC
+{
+ unsigned char resetMIB:1; /* reset MIB counters */
+ unsigned char rxBPDU:1; /* receive BDPU enable */
+ unsigned char rsvd1:2; /* reserved */
+ unsigned char MIBacHdrCtrl:1; /* MIB autocast header control */
+ unsigned char MIBac:1; /* MIB autocast enable */
+ unsigned char frameMgmtPort:2; /* frame management port */
+} ROBO_GLOBAL_CONFIG_STRUC;
+#define ROBO_GLOBAL_CONFIG 0x00 /* Global Management Config: 8bit*/
+#define ROBO_MGMT_PORT_ID 0x02 /* Management Port ID: 8bit*/
+#define ROBO_RMON_MIB_STEER 0x04 /* RMON Mib Steering: 16bit */
+#define ROBO_MIB_MODE_SELECT 0x04 /* MIB Mode select: 16bit (BCM5350) */
+#define ROBO_AGE_TIMER_CTRL 0x06 /* Age time control: 32bit */
+#define ROBO_MIRROR_CAP_CTRL 0x10 /* Mirror Capture : 16bit */
+#define ROBO_MIRROR_ING_CTRL 0x12 /* Mirror Ingress Control: 16bit */
+#define ROBO_MIRROR_ING_DIV_CTRL 0x14 /* Mirror Ingress Divider: 16bit */
+#define ROBO_MIRROR_ING_MAC_ADDR 0x16 /* Ingress Mirror MAC Addr: 48bit*/
+#define ROBO_MIRROR_EGR_CTRL 0x1c /* Mirror Egress Control: 16bit */
+#define ROBO_MIRROR_EGR_DIV_CTRL 0x1e /* Mirror Egress Divider: 16bit */
+#define ROBO_MIRROR_EGR_MAC_ADDR 0x20 /* Egress Mirror MAC Addr: 48bit*/
+
+/* BCM5325m MIB AUTOCAST REGISTERS (0x03) REGISTER MAP: 8/16/48 bit regs */
+#define ROBO_MIB_AC_PORT 0x00 /* MIB Autocast Port: 16bit */
+#define ROBO_MIB_AC_HDR_PTR 0x02 /* MIB Autocast Header pointer:16bit*/
+#define ROBO_MIB_AC_HDR_LEN 0x04 /* MIB Autocast Header Len: 16bit */
+#define ROBO_MIB_AC_DA 0x06 /* MIB Autocast DA: 48bit */
+#define ROBO_MIB_AC_SA 0x0c /* MIB Autocast SA: 48bit */
+#define ROBO_MIB_AC_TYPE 0x12 /* MIB Autocast Type: 16bit */
+#define ROBO_MIB_AC_RATE 0x14 /* MIB Autocast Rate: 8bit */
+#define ROBO_GET_AC_RATE(secs) ((secs)*10)
+#define ROBO_AC_RATE_MAX 0xff
+#define ROBO_AC_RATE_DEFAULT 0x64 /* 10 secs */
+typedef struct _ROBO_MIB_AC_STRUCT
+{
+ unsigned char opcode:4; /* Tx MIB Autocast opcode */
+ unsigned char portno:4; /* zero-based port no. */
+ unsigned char portstate:8; /* port state */
+ unsigned long long TxOctets;
+ unsigned int TxDropPkts;
+ unsigned int rsvd;
+ unsigned int TxBroadcastPkts;
+ unsigned int TxMulticastPkts;
+ unsigned int TxUnicastPkts;
+ unsigned int TxCollisions;
+ unsigned int TxSingleCollision;
+ unsigned int TxMultiCollision;
+ unsigned int TxDeferredTransmit;
+ unsigned int TxLateCollision;
+ unsigned int TxExcessiveCollision;
+ unsigned int TxFrameInDiscards;
+ unsigned int TxPausePkts;
+ unsigned int rsvd1[2];
+ unsigned long long RxOctets;
+ unsigned int RxUndersizePkts;
+ unsigned int RxPausePkts;
+ unsigned int RxPkts64Octets;
+ unsigned int RxPkts64to127Octets;
+ unsigned int RxPkts128to255Octets;
+ unsigned int RxPkts256to511Octets;
+ unsigned int RxPkts512to1023Octets;
+ unsigned int RxPkts1024to1522Octets;
+ unsigned int RxOversizePkts;
+ unsigned int RxJabbers;
+ unsigned int RxAlignmentErrors;
+ unsigned int RxFCSErrors;
+ unsigned long long RxGoodOctets;
+ unsigned int RxDropPkts;
+ unsigned int RxUnicastPkts;
+ unsigned int RxMulticastPkts;
+ unsigned int RxBroadcastPkts;
+ unsigned int RxSAChanges;
+ unsigned int RxFragments;
+ unsigned int RxExcessSizeDisc;
+ unsigned int RxSymbolError;
+} ROBO_MIB_AC_STRUCT;
+
+/* BCM5325m ARL CONTROL REGISTERS (0x04) REGISTER MAP: 8/16/48/64 bit regs */
+#define ROBO_ARL_CONFIG 0x00 /* ARL Global Configuration: 8bit*/
+#define ROBO_BPDU_MC_ADDR_REG 0x04 /* BPDU Multicast Address Reg:64bit*/
+#define ROBO_MULTIPORT_ADDR_1 0x10 /* Multiport Address 1: 48 bits*/
+#define ROBO_MULTIPORT_VECTOR_1 0x16 /* Multiport Vector 1: 16 bits */
+#define ROBO_MULTIPORT_ADDR_2 0x20 /* Multiport Address 2: 48 bits*/
+#define ROBO_MULTIPORT_VECTOR_2 0x26 /* Multiport Vector 2: 16 bits */
+#define ROBO_SECURE_SRC_PORT_MASK 0x30 /* Secure Source Port Mask: 16 bits*/
+#define ROBO_SECURE_DST_PORT_MASK 0x32 /* Secure Dest Port Mask: 16 bits */
+
+
+/* BCM5325m ARL IO REGISTERS (0x05) REGISTER MAP: 8/16/48/64 bit regs */
+#define ARL_TABLE_WRITE 0 /* for read/write state in control reg */
+#define ARL_TABLE_READ 1 /* for read/write state in control reg */
+#ifdef BCM5380
+#define ARL_VID_BYTES 2 /* number of bytes for VID */
+#else
+#define ARL_VID_BYTES 1 /* number of bytes for VID */
+#endif
+typedef struct _ROBO_ARL_RW_CTRL_STRUC
+{
+ unsigned char ARLrw:1; /* ARL read/write (1=read) */
+ unsigned char rsvd:6; /* reserved */
+ unsigned char ARLStart:1; /* ARL start/done (1=start) */
+} ROBO_ARL_RW_CTRL_STRUC;
+typedef struct _ROBO_ARL_SEARCH_CTRL_STRUC
+{
+ unsigned char valid:1; /* ARL search result valid */
+ unsigned char rsvd:6; /* reserved */
+ unsigned char ARLStart:1; /* ARL start/done (1=start) */
+} ROBO_ARL_SEARCH_CTRL_STRUC;
+typedef struct _ROBO_ARL_ENTRY_CTRL_STRUC
+{
+ unsigned char portID:4; /* port id */
+ unsigned char chipID:2; /* chip id */
+ unsigned char rsvd:5; /* reserved */
+ unsigned char prio:2; /* priority */
+ unsigned char age:1; /* age */
+ unsigned char staticEn:1; /* static */
+ unsigned char valid:1; /* valid */
+} ROBO_ARL_ENTRY_CTRL_STRUC;
+typedef struct _ROBO_ARL_SEARCH_RESULT_CTRL_STRUC
+{
+ unsigned char portID:4; /* port id */
+ unsigned char rsvd:1; /* reserved */
+ unsigned char vid:8; /* vlan id */
+ unsigned char age:1; /* age */
+ unsigned char staticEn:1; /* static */
+ unsigned char valid:1; /* valid */
+} ROBO_ARL_SEARCH_RESULT_CTRL_STRUC;
+typedef struct _ROBO_ARL_ENTRY_MAC_STRUC
+{
+ unsigned char macBytes[6]; /* MAC address */
+} ROBO_ARL_ENTRY_MAC_STRUC;
+
+typedef struct _ROBO_ARL_ENTRY_STRUC
+{
+ ROBO_ARL_ENTRY_MAC_STRUC mac; /* MAC address */
+ ROBO_ARL_ENTRY_CTRL_STRUC ctrl; /* control bits */
+} ROBO_ARL_ENTRY_STRUC;
+
+typedef struct _ROBO_ARL_SEARCH_RESULT_STRUC
+{
+ ROBO_ARL_ENTRY_MAC_STRUC mac; /* MAC address */
+ ROBO_ARL_SEARCH_RESULT_CTRL_STRUC ctrl; /* control bits */
+} ROBO_ARL_SEARCH_RESULT_STRUC;
+
+/* multicast versions of ARL entry structs */
+typedef struct _ROBO_ARL_ENTRY_MCAST_CTRL_STRUC
+{
+ unsigned int portMask:12;/* multicast port mask */
+ unsigned char prio:1; /* priority */
+ unsigned char gigPort:1; /* gigabit port 1 mask */
+ unsigned char staticEn:1; /* static */
+ unsigned char valid:1; /* valid */
+} ROBO_ARL_ENTRY_MCAST_CTRL_STRUC;
+typedef struct _ROBO_ARL_SEARCH_RESULT_MCAST_CTRL_STRUC
+{
+ unsigned int portMask:13; /* multicast port mask */
+ unsigned char age:1; /* age */
+ unsigned char staticEn:1; /* static */
+ unsigned char valid:1; /* valid */
+} ROBO_ARL_SEARCH_RESULT_MCAST_CTRL_STRUC;
+/* BCM5350 extension register */
+typedef struct _ROBO_ARL_SEARCH_RESULT_EXTENSION
+{
+ unsigned int prio:2; /* priority */
+ unsigned int portMask:1; /* MSB (MII) of port mask for multicast */
+ unsigned int reserved:5;
+} ROBO_ARL_SEARCH_RESULT_EXTENSION;
+
+typedef struct _ROBO_ARL_ENTRY_MCAST_STRUC
+{
+ ROBO_ARL_ENTRY_MAC_STRUC mac; /* MAC address */
+ ROBO_ARL_ENTRY_MCAST_CTRL_STRUC ctrl; /* control bits */
+} ROBO_ARL_ENTRY_MCAST_STRUC;
+typedef struct _ROBO_ARL_SEARCH_RESULT_MCAST_STRUC
+{
+ ROBO_ARL_ENTRY_MAC_STRUC mac; /* MAC address */
+ ROBO_ARL_SEARCH_RESULT_MCAST_CTRL_STRUC ctrl; /* control bits */
+} ROBO_ARL_SEARCH_RESULT_MCAST_STRUC;
+
+#define ROBO_ARL_RW_CTRL 0x00 /* ARL Read/Write Control : 8bit */
+#define ROBO_ARL_MAC_ADDR_IDX 0x02 /* MAC Address Index: 48bit */
+#define ROBO_ARL_VID_TABLE_IDX 0x08 /* VID Table Address Index: 8bit */
+#define ROBO_ARL_ENTRY0 0x10 /* ARL Entry 0 : 64 bit */
+#define ROBO_ARL_ENTRY1 0x18 /* ARL Entry 1 : 64 bit */
+#define ROBO_ARL_SEARCH_CTRL 0x20 /* ARL Search Control: 8bit */
+#define ROBO_ARL_SEARCH_ADDR 0x22 /* ARL Search Address: 16bit */
+#define ROBO_ARL_SEARCH_RESULT 0x24 /* ARL Search Result: 64bit */
+#define ROBO_ARL_SEARCH_RESULT_EXT 0x2c /* ARL Search Result Extension (5350): 8bit */
+#define ROBO_ARL_VID_ENTRY0 0x30 /* ARL VID Entry 0: 64bit */
+#define ROBO_ARL_VID_ENTRY1 0x32 /* ARL VID Entry 1: 64bit */
+
+/* BCM5325m MANAGEMENT FRAME REGISTERS (0x6) REGISTER MAP: 8/16 bit regs */
+#define ROBO_MGMT_FRAME_RD_DATA 0x00 /* Management Frame Read Data :8bit*/
+#define ROBO_MGMT_FRAME_WR_DATA 0x01 /* Management Frame Write Data:8bit*/
+#define ROBO_MGMT_FRAME_WR_CTRL 0x02 /* Write Control: 16bit */
+#define ROBO_MGMT_FRAME_RD_STAT 0x04 /* Read Status: 16bit */
+
+/* BCM5325m MEMORY ACCESS REGISTERS (Page 0x08) REGISTER MAP: 32 bit regs */
+#define MEM_TABLE_READ 1 /* for read/write state in mem access reg */
+#define MEM_TABLE_WRITE 0 /* for read/write state in mem access reg */
+#define MEM_TABLE_ACCESS_START 1 /* for mem access read/write start */
+#define MEM_TABLE_ACCESS_DONE 0 /* for mem access read/write done */
+#define VLAN_TABLE_ADDR 0x3800 /* BCM5380 only */
+#ifdef BCM5380
+#define NUM_ARL_TABLE_ENTRIES 4096 /* number of entries in ARL table */
+#define NUM_VLAN_TABLE_ENTRIES 2048 /* number of entries in VLAN table */
+#define ARL_TABLE_ADDR 0 /* offset of ARL table start */
+#else
+#define NUM_ARL_TABLE_ENTRIES 2048 /* number of entries in ARL table */
+#define NUM_VLAN_TABLE_ENTRIES 256 /* number of entries in VLAN table */
+#define ARL_TABLE_ADDR 0x3800 /* offset of ARL table start */
+/* corresponding values for 5350 */
+#define NUM_ARL_TABLE_ENTRIES_5350 1024 /* number of entries in ARL table (5350) */
+#define NUM_VLAN_TABLE_ENTRIES_5350 16 /* number of entries in VLAN table */
+#define ARL_TABLE_ADDR_5350 0x1c00 /* offset of ARL table start (5350) */
+#endif
+typedef struct _ROBO_MEM_ACCESS_CTRL_STRUC
+{
+ unsigned int memAddr:14; /* 64-bit memory address */
+ unsigned char rsvd:4; /* reserved */
+ unsigned char readEn:1; /* read enable (0 == write) */
+ unsigned char startDone:1;/* memory access start/done */
+ unsigned int rsvd1:12; /* reserved */
+} ROBO_MEM_ACCESS_CTRL_STRUC;
+typedef struct _ROBO_MEM_ACCESS_DATA_STRUC
+{
+ unsigned int memData[2]; /* 64-bit data */
+ unsigned short rsvd; /* reserved */
+} ROBO_MEM_ACCESS_DATA_STRUC;
+
+#ifdef BCM5380
+typedef struct _ROBO_ARL_TABLE_DATA_STRUC
+{
+ unsigned char MACaddr[6]; /* MAC addr */
+ unsigned int portID:4; /* port ID */
+ unsigned int chipID:2; /* chip ID */
+ unsigned int rsvd:6; /* reserved */
+ unsigned int highPrio:1; /* high priority address */
+ unsigned int age:1; /* entry accessed/learned since ageing process */
+ unsigned int staticAddr:1;/* entry is static */
+ unsigned int valid:1; /* entry is valid */
+ unsigned int vid:12; /* vlan id */
+ unsigned int rsvd2:4; /* reserved */
+} ROBO_ARL_TABLE_DATA_STRUC;
+#else
+typedef struct _ROBO_ARL_TABLE_DATA_STRUC
+{
+ unsigned char MACaddr[6]; /* MAC addr */
+ unsigned int portID:4; /* port ID */
+ unsigned int chipID:2; /* chip ID */
+ unsigned int rsvd:7; /* reserved */
+ unsigned int age:1; /* entry accessed/learned since ageing process */
+ unsigned int staticAddr:1;/* entry is static */
+ unsigned int valid:1; /* entry is valid */
+} ROBO_ARL_TABLE_DATA_STRUC;
+#endif
+
+/* multicast format*/
+typedef struct _ROBO_ARL_TABLE_MCAST_DATA_STRUC
+{
+ unsigned char MACaddr[6]; /* MAC addr */
+ unsigned int portMask:12;/* multicast port mask */
+ unsigned char prio:1; /* priority */
+ unsigned char gigPort:1; /* gigabit port 1 mask */
+ unsigned char staticEn:1; /* static */
+ unsigned char valid:1; /* valid */
+ unsigned int vid:12; /* vlan id */
+ unsigned int rsvd2:4; /* reserved */
+} ROBO_ARL_TABLE_MCAST_DATA_STRUC;
+#define ROBO_MEM_ACCESS_CTRL 0x00 /* Memory Read/Write Control :32bit*/
+#define ROBO_MEM_ACCESS_DATA 0x04 /* Memory Read/Write Data:64bit*/
+
+/* BCM5325m SWITCH PORT (0x10-18) REGISTER MAP: 8/16 bit regs */
+typedef struct _ROBO_MII_CTRL_STRUC
+{
+ unsigned char rsvd:8; /* reserved */
+ unsigned char duplex:1; /* duplex mode */
+ unsigned char restartAN:1;/* restart auto-negotiation */
+ unsigned char rsvd1:1; /* reserved */
+ unsigned char powerDown:1;/* power down */
+ unsigned char ANenable:1; /* auto-negotiation enable */
+ unsigned char speed:1; /* forced speed selection */
+ unsigned char loopback:1; /* loopback */
+ unsigned char reset:1; /* reset */
+} ROBO_MII_CTRL_STRUC;
+typedef struct _ROBO_MII_AN_ADVERT_STRUC
+{
+ unsigned char selector:5; /* advertise selector field */
+ unsigned char T10BaseT:1; /* advertise 10BaseT */
+ unsigned char T10BaseTFull:1; /* advertise 10BaseT, full duplex */
+ unsigned char T100BaseX:1; /* advertise 100BaseX */
+ unsigned char T100BaseXFull:1;/* advertise 100BaseX full duplex */
+ unsigned char noT4:1; /* do not advertise T4 */
+ unsigned char pause:1; /* advertise pause for full duplex */
+ unsigned char rsvd:2; /* reserved */
+ unsigned char remoteFault:1; /* transmit remote fault */
+ unsigned char rsvd1:1; /* reserved */
+ unsigned char nextPage:1; /* nex page operation supported */
+} ROBO_MII_AN_ADVERT_STRUC;
+#define ROBO_MII_CTRL 0x00 /* Port MII Control */
+#define ROBO_MII_STAT 0x02 /* Port MII Status */
+/* Fields of link status register */
+#define ROBO_MII_STAT_JABBER (1<<1) /* Jabber detected */
+#define ROBO_MII_STAT_LINK (1<<2) /* Link status */
+
+#define ROBO_MII_PHYID_HI 0x04 /* Port PHY ID High */
+#define ROBO_MII_PHYID_LO 0x06 /* Port PHY ID Low */
+#define ROBO_MII_ANA_REG 0x08 /* MII Auto-Neg Advertisement */
+#define ROBO_MII_ANP_REG 0x0a /* MII Auto-Neg Partner Ability */
+#define ROBO_MII_AN_EXP_REG 0x0c /* MII Auto-Neg Expansion */
+#define ROBO_MII_AN_NP_REG 0x0e /* MII next page */
+#define ROBO_MII_ANP_NP_REG 0x10 /* MII Partner next page */
+#define ROBO_MII_100BX_AUX_CTRL 0x20 /* 100BASE-X Auxiliary Control */
+#define ROBO_MII_100BX_AUX_STAT 0x22 /* 100BASE-X Auxiliary Status */
+#define ROBO_MII_100BX_RCV_ERR_CTR 0x24 /* 100BASE-X Receive Error Ctr */
+#define ROBO_MII_100BX_RCV_FS_ERR 0x26 /* 100BASE-X Rcv False Sense Ctr */
+#define ROBO_MII_AUX_CTRL 0x30 /* Auxiliary Control/Status */
+/* Fields of Auxiliary control register */
+#define ROBO_MII_AUX_CTRL_FD (1<<0) /* Full duplex link detected*/
+#define ROBO_MII_AUX_CTRL_SP100 (1<<1) /* Speed 100 indication */
+#define ROBO_MII_AUX_STATUS 0x32 /* Aux Status Summary */
+#define ROBO_MII_CONN_STATUS 0x34 /* Aux Connection Status */
+#define ROBO_MII_AUX_MODE2 0x36 /* Aux Mode 2 */
+#define ROBO_MII_AUX_ERR_STATUS 0x38 /* Aux Error and General Status */
+#define ROBO_MII_AUX_MULTI_PHY 0x3c /* Aux Multiple PHY Register*/
+#define ROBO_MII_BROADCOM_TEST 0x3e /* Broadcom Test Register */
+
+
+/* BCM5325m PORT MIB REGISTERS (Pages 0x20-0x24,0x28) REGISTER MAP: 64/32 */
+/* Tranmit Statistics */
+#define ROBO_MIB_TX_OCTETS 0x00 /* 64b: TxOctets */
+#define ROBO_MIB_TX_DROP_PKTS 0x08 /* 32b: TxDropPkts */
+#define ROBO_MIB_TX_BC_PKTS 0x10 /* 32b: TxBroadcastPkts */
+#define ROBO_MIB_TX_MC_PKTS 0x14 /* 32b: TxMulticastPkts */
+#define ROBO_MIB_TX_UC_PKTS 0x18 /* 32b: TxUnicastPkts */
+#define ROBO_MIB_TX_COLLISIONS 0x1c /* 32b: TxCollisions */
+#define ROBO_MIB_TX_SINGLE_COLLISIONS 0x20 /* 32b: TxSingleCollision */
+#define ROBO_MIB_TX_MULTI_COLLISIONS 0x24 /* 32b: TxMultiCollision */
+#define ROBO_MIB_TX_DEFER_TX 0x28 /* 32b: TxDeferred Transmit */
+#define ROBO_MIB_TX_LATE_COLLISIONS 0x2c /* 32b: TxLateCollision */
+#define ROBO_MIB_EXCESS_COLLISIONS 0x30 /* 32b: TxExcessiveCollision*/
+#define ROBO_MIB_FRAME_IN_DISCARDS 0x34 /* 32b: TxFrameInDiscards */
+#define ROBO_MIB_TX_PAUSE_PKTS 0x38 /* 32b: TxPausePkts */
+
+/* Receive Statistics */
+#define ROBO_MIB_RX_OCTETS 0x44 /* 64b: RxOctets */
+#define ROBO_MIB_RX_UNDER_SIZE_PKTS 0x4c /* 32b: RxUndersizePkts(runts)*/
+#define ROBO_MIB_RX_PAUSE_PKTS 0x50 /* 32b: RxPausePkts */
+#define ROBO_MIB_RX_PKTS_64 0x54 /* 32b: RxPkts64Octets */
+#define ROBO_MIB_RX_PKTS_65_TO_127 0x58 /* 32b: RxPkts64to127Octets*/
+#define ROBO_MIB_RX_PKTS_128_TO_255 0x5c /* 32b: RxPkts128to255Octets*/
+#define ROBO_MIB_RX_PKTS_256_TO_511 0x60 /* 32b: RxPkts256to511Octets*/
+#define ROBO_MIB_RX_PKTS_512_TO_1023 0x64 /* 32b: RxPkts512to1023Octets*/
+#define ROBO_MIB_RX_PKTS_1024_TO_1522 0x68 /* 32b: RxPkts1024to1522Octets*/
+#define ROBO_MIB_RX_OVER_SIZE_PKTS 0x6c /* 32b: RxOversizePkts*/
+#define ROBO_MIB_RX_JABBERS 0x70 /* 32b: RxJabbers*/
+#define ROBO_MIB_RX_ALIGNMENT_ERRORS 0x74 /* 32b: RxAlignmentErrors*/
+#define ROBO_MIB_RX_FCS_ERRORS 0x78 /* 32b: RxFCSErrors */
+#define ROBO_MIB_RX_GOOD_OCTETS 0x7c /* 32b: RxGoodOctets */
+#define ROBO_MIB_RX_DROP_PKTS 0x84 /* 32b: RxDropPkts */
+#define ROBO_MIB_RX_UC_PKTS 0x88 /* 32b: RxUnicastPkts */
+#define ROBO_MIB_RX_MC_PKTS 0x8c /* 32b: RxMulticastPkts */
+#define ROBO_MIB_RX_BC_PKTS 0x90 /* 32b: RxBroadcastPkts */
+#define ROBO_MIB_RX_SA_CHANGES 0x94 /* 32b: RxSAChanges */
+#define ROBO_MIB_RX_FRAGMENTS 0x98 /* 32b: RxFragments */
+#define ROBO_MIB_RX_EXCESS_SZ_DISC 0x9c /* 32b: RxExcessSizeDisc*/
+#define ROBO_MIB_RX_SYMBOL_ERROR 0xa0 /* 32b: RxSymbolError */
+
+/* BCM5350 MIB Statistics */
+/* Group 0 */
+#define ROBO_MIB_TX_GOOD_PKTS 0x00 /* 16b: TxGoodPkts */
+#define ROBO_MIB_TX_UNICAST_PKTS 0x02 /* 16b: TxUnicastPkts */
+#define ROBO_MIB_RX_GOOD_PKTS 0x04 /* 16b: RxGoodPkts */
+#define ROBO_MIB_RX_GOOD_UNICAST_PKTS 0x06 /* 16b: RxGoodUnicastPkts */
+/* Group 1 */
+#define ROBO_MIB_TX_COLLISION 0x00 /* 16b: TxCollision */
+#define ROBO_MIB_TX_OCTETS_5350 0x02 /* 16b: TxOctets */
+#define ROBO_MIB_RX_FCS_ERRORS_5350 0x04 /* 16b: RxFCSErrors */
+#define ROBO_MIB_RX_GOOD_OCTETS_5350 0x06 /* 16b: RxGoodOctets */
+
+/* BCM5325m QoS REGISTERS (Page 0x30) REGISTER MAP: 8/16 */
+#define ROBO_QOS_CTRL 0x00 /* 16b: QoS Control Register */
+#define ROBO_QOS_LOCAL_WEIGHT_CTRL 0x10 /* 8b: Local HQ/LQ Weight Register*/
+#define ROBO_QOS_CPU_WEIGHT_CTRL 0x12 /* 8b: CPU HQ/LQ Weight Register*/
+#define ROBO_QOS_PAUSE_ENA 0x13 /* 16b: Qos Pause Enable Register*/
+#define ROBO_QOS_PRIO_THRESHOLD 0x15 /* 8b: Priority Threshold Register*/
+#define ROBO_QOS_RESERVED 0x16 /* 8b: Qos Reserved Register */
+
+/* BCM5325m VLAN REGISTERS (Page 0x34) REGISTER MAP: 8/16bit */
+typedef struct _ROBO_VLAN_CTRL0_STRUC
+{
+ unsigned char frameControlP:2; /* 802.1P frame control */
+ unsigned char frameControlQ:2; /* 802.1Q frame control */
+ unsigned char dropMissedVID:1; /* enable drop missed VID packet */
+ unsigned char vidMacHash:1; /* VID_MAC hash enable */
+ unsigned char vidMacCheck:1; /* VID_MAC check enable */
+ unsigned char VLANen:1; /* 802.1Q VLAN enable */
+} ROBO_VLAN_CTRL0_STRUC;
+#define VLAN_TABLE_WRITE 1 /* for read/write state in table access reg */
+#define VLAN_TABLE_READ 0 /* for read/write state in table access reg */
+#define VLAN_ID_HIGH_BITS 0 /* static high bits in table access reg */
+#define VLAN_ID_MAX 255 /* max VLAN id */
+#define VLAN_ID_MAX5350 15 /* max VLAN id (5350) */
+#define VLAN_ID_MASK VLAN_ID_MAX /* VLAN id mask */
+#ifdef BCM5380
+#define VLAN_UNTAG_SHIFT 13 /* for postioning untag bits in write reg */
+#define VLAN_VALID 0x4000000 /* valid bit in write reg */
+#else
+#define VLAN_UNTAG_SHIFT 7 /* for postioning untag bits in write reg */
+#define VLAN_VALID 0x4000 /* valid bit in write reg */
+/* corresponding values for 5350 */
+#define VLAN_UNTAG_SHIFT_5350 6 /* for postioning untag bits in write reg */
+#define VLAN_VALID_5350 0x00100000 /* valid bit in write reg */
+#endif
+typedef struct _ROBO_VLAN_TABLE_ACCESS_STRUC
+{
+ unsigned char VLANid:8; /* VLAN ID (low 8 bits) */
+ unsigned char VLANidHi:4; /* VLAN ID (fixed upper portion) */
+ unsigned char readWriteState:1; /* read/write state (write = 1) */
+ volatile unsigned char readWriteEnable:1; /* table read/write enable */
+ unsigned char rsvd:2; /* reserved */
+} ROBO_VLAN_TABLE_ACCESS_STRUC;
+#ifdef BCM5380
+typedef struct _ROBO_VLAN_READ_WRITE_STRUC
+{
+ unsigned int VLANgroup:13;/* VLAN group mask */
+ unsigned int VLANuntag:13;/* VLAN untag enable mask */
+ unsigned char valid:1; /* valid */
+ unsigned char rsvd:5; /* reserved */
+} ROBO_VLAN_READ_WRITE_STRUC;
+#else
+typedef struct _ROBO_VLAN_READ_WRITE_STRUC
+{
+ unsigned char VLANgroup:7; /* VLAN group mask */
+ unsigned char VLANuntag:7; /* VLAN untag enable mask */
+ unsigned char valid:1; /* valid */
+ unsigned char rsvd:1; /* reserved */
+} ROBO_VLAN_READ_WRITE_STRUC;
+typedef struct _ROBO_VLAN_READ_WRITE_STRUC_5350
+{
+ unsigned char VLANgroup:6; /* VLAN group mask */
+ unsigned char VLANuntag:6; /* VLAN untag enable mask */
+ unsigned char highVID:8; /* upper bits of vid */
+ unsigned char valid:1; /* valid */
+ unsigned int rsvd:11; /* reserved */
+} ROBO_VLAN_READ_WRITE_STRUC_5350;
+#endif
+#define ROBO_VLAN_CTRL0 0x00 /* 8b: VLAN Control 0 Register */
+#define ROBO_VLAN_CTRL1 0x01 /* 8b: VLAN Control 1 Register */
+#define ROBO_VLAN_CTRL2 0x02 /* 8b: VLAN Control 2 Register */
+#define ROBO_VLAN_CTRL3 0x03 /* 8b: VLAN Control 3 Register */
+#define ROBO_VLAN_CTRL4 0x04 /* 8b: VLAN Control 4 Register */
+#define ROBO_VLAN_CTRL5 0x05 /* 8b: VLAN Control 5 Register */
+#define ROBO_VLAN_TABLE_ACCESS 0x08 /* 14b: VLAN Table Access Register */
+#define ROBO_VLAN_TABLE_ACCESS_5350 0x06 /* 14b: VLAN Table Access Register (5350) */
+#define ROBO_VLAN_WRITE 0x0a /* 15b: VLAN Write Register */
+#define ROBO_VLAN_WRITE_5350 0x08 /* 15b: VLAN Write Register (5350) */
+#define ROBO_VLAN_READ 0x0c /* 15b: VLAN Read Register */
+#define ROBO_VLAN_PORT0_DEF_TAG 0x10 /* 16b: VLAN Port 0 Default Tag Register */
+#define ROBO_VLAN_PORT1_DEF_TAG 0x12 /* 16b: VLAN Port 1 Default Tag Register */
+#define ROBO_VLAN_PORT2_DEF_TAG 0x14 /* 16b: VLAN Port 2 Default Tag Register */
+#define ROBO_VLAN_PORT3_DEF_TAG 0x16 /* 16b: VLAN Port 3 Default Tag Register */
+#define ROBO_VLAN_PORT4_DEF_TAG 0x18 /* 16b: VLAN Port 4 Default Tag Register */
+#define ROBO_VLAN_PORTMII_DEF_TAG 0x1a /* 16b: VLAN Port MII Default Tag Register */
+/* 5380 only */
+#define ROBO_VLAN_PORT5_DEF_TAG 0x1a /* 16b: VLAN Port 5 Default Tag Register */
+#define ROBO_VLAN_PORT6_DEF_TAG 0x1c /* 16b: VLAN Port 6 Default Tag Register */
+#define ROBO_VLAN_PORT7_DEF_TAG 0x1e /* 16b: VLAN Port 7 Default Tag Register */
+
+/* obsolete */
+#define ROBO_VLAN_PORT0_CTRL 0x00 /* 16b: Port 0 VLAN Register */
+#define ROBO_VLAN_PORT1_CTRL 0x02 /* 16b: Port 1 VLAN Register */
+#define ROBO_VLAN_PORT2_CTRL 0x04 /* 16b: Port 2 VLAN Register */
+#define ROBO_VLAN_PORT3_CTRL 0x06 /* 16b: Port 3 VLAN Register */
+#define ROBO_VLAN_PORT4_CTRL 0x08 /* 16b: Port 4 VLAN Register */
+#define ROBO_VLAN_IM_PORT_CTRL 0x10 /* 16b: Inverse MII Port VLAN Reg */
+#define ROBO_VLAN_SMP_PORT_CTRL 0x12 /* 16b: Serial Port VLAN Register */
+#define ROBO_VLAN_PORTSPI_DEF_TAG 0x1c /* 16b: VLAN Port SPI Default Tag Register */
+#define ROBO_VLAN_PRIORITY_REMAP 0x20 /* 24b: VLAN Priority Re-Map Register */
+
+#ifndef _CFE_
+#pragma pack()
+#endif
+
+
+#endif /* !__BCM535M_H_ */
+
+
+
+
+
diff --git a/package/system/utils/robocfg/src/.svn/text-base/robocfg.c.svn-base b/package/system/utils/robocfg/src/.svn/text-base/robocfg.c.svn-base
new file mode 100644
index 0000000..7a4094d
--- /dev/null
+++ b/package/system/utils/robocfg/src/.svn/text-base/robocfg.c.svn-base
@@ -0,0 +1,581 @@
+/*
+ * Broadcom BCM5325E/536x switch configuration utility
+ *
+ * Copyright (C) 2005 Oleg I. Vdovikin
+ *
+ * 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
+ * of the License, 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; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/param.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+
+/* linux stuff */
+typedef u_int64_t u64;
+typedef u_int32_t u32;
+typedef u_int16_t u16;
+typedef u_int8_t u8;
+
+#include <linux/if.h>
+#include <linux/sockios.h>
+#include <linux/ethtool.h>
+#include <linux/mii.h>
+
+#include "etc53xx.h"
+#define ROBO_PHY_ADDR 0x1E /* robo switch phy address */
+
+/* MII registers */
+#define REG_MII_PAGE 0x10 /* MII Page register */
+#define REG_MII_ADDR 0x11 /* MII Address register */
+#define REG_MII_DATA0 0x18 /* MII Data register 0 */
+
+#define REG_MII_PAGE_ENABLE 1
+#define REG_MII_ADDR_WRITE 1
+#define REG_MII_ADDR_READ 2
+
+/* Private et.o ioctls */
+#define SIOCGETCPHYRD (SIOCDEVPRIVATE + 9)
+#define SIOCSETCPHYWR (SIOCDEVPRIVATE + 10)
+
+typedef struct {
+ struct ifreq ifr;
+ int fd;
+ int et; /* use private ioctls */
+} robo_t;
+
+static u16 mdio_read(robo_t *robo, u16 phy_id, u8 reg)
+{
+ if (robo->et) {
+ int args[2] = { reg };
+
+ if (phy_id != ROBO_PHY_ADDR) {
+ fprintf(stderr,
+ "Access to real 'phy' registers unavaliable.\n"
+ "Upgrade kernel driver.\n");
+
+ return 0xffff;
+ }
+
+ robo->ifr.ifr_data = (caddr_t) args;
+ if (ioctl(robo->fd, SIOCGETCPHYRD, (caddr_t)&robo->ifr) < 0) {
+ perror("SIOCGETCPHYRD");
+ exit(1);
+ }
+
+ return args[1];
+ } else {
+ struct mii_ioctl_data *mii = (struct mii_ioctl_data *)&robo->ifr.ifr_data;
+ mii->phy_id = phy_id;
+ mii->reg_num = reg;
+ if (ioctl(robo->fd, SIOCGMIIREG, &robo->ifr) < 0) {
+ perror("SIOCGMIIREG");
+ exit(1);
+ }
+ return mii->val_out;
+ }
+}
+
+static void mdio_write(robo_t *robo, u16 phy_id, u8 reg, u16 val)
+{
+ if (robo->et) {
+ int args[2] = { reg, val };
+
+ if (phy_id != ROBO_PHY_ADDR) {
+ fprintf(stderr,
+ "Access to real 'phy' registers unavaliable.\n"
+ "Upgrade kernel driver.\n");
+ return;
+ }
+
+ robo->ifr.ifr_data = (caddr_t) args;
+ if (ioctl(robo->fd, SIOCSETCPHYWR, (caddr_t)&robo->ifr) < 0) {
+ perror("SIOCGETCPHYWR");
+ exit(1);
+ }
+ } else {
+ struct mii_ioctl_data *mii = (struct mii_ioctl_data *)&robo->ifr.ifr_data;
+ mii->phy_id = phy_id;
+ mii->reg_num = reg;
+ mii->val_in = val;
+ if (ioctl(robo->fd, SIOCSMIIREG, &robo->ifr) < 0) {
+ perror("SIOCSMIIREG");
+ exit(1);
+ }
+ }
+}
+
+static int robo_reg(robo_t *robo, u8 page, u8 reg, u8 op)
+{
+ int i = 3;
+
+ /* set page number */
+ mdio_write(robo, ROBO_PHY_ADDR, REG_MII_PAGE,
+ (page << 8) | REG_MII_PAGE_ENABLE);
+
+ /* set register address */
+ mdio_write(robo, ROBO_PHY_ADDR, REG_MII_ADDR,
+ (reg << 8) | op);
+
+ /* check if operation completed */
+ while (i--) {
+ if ((mdio_read(robo, ROBO_PHY_ADDR, REG_MII_ADDR) & 3) == 0)
+ return 0;
+ }
+
+ fprintf(stderr, "robo_reg: timeout\n");
+ exit(1);
+
+ return 0;
+}
+
+static void robo_read(robo_t *robo, u8 page, u8 reg, u16 *val, int count)
+{
+ int i;
+
+ robo_reg(robo, page, reg, REG_MII_ADDR_READ);
+
+ for (i = 0; i < count; i++)
+ val[i] = mdio_read(robo, ROBO_PHY_ADDR, REG_MII_DATA0 + i);
+}
+
+static u16 robo_read16(robo_t *robo, u8 page, u8 reg)
+{
+ robo_reg(robo, page, reg, REG_MII_ADDR_READ);
+
+ return mdio_read(robo, ROBO_PHY_ADDR, REG_MII_DATA0);
+}
+
+static u32 robo_read32(robo_t *robo, u8 page, u8 reg)
+{
+ robo_reg(robo, page, reg, REG_MII_ADDR_READ);
+
+ return mdio_read(robo, ROBO_PHY_ADDR, REG_MII_DATA0) +
+ (mdio_read(robo, ROBO_PHY_ADDR, REG_MII_DATA0 + 1) << 16);
+}
+
+static void robo_write16(robo_t *robo, u8 page, u8 reg, u16 val16)
+{
+ /* write data */
+ mdio_write(robo, ROBO_PHY_ADDR, REG_MII_DATA0, val16);
+
+ robo_reg(robo, page, reg, REG_MII_ADDR_WRITE);
+}
+
+static void robo_write32(robo_t *robo, u8 page, u8 reg, u32 val32)
+{
+ /* write data */
+ mdio_write(robo, ROBO_PHY_ADDR, REG_MII_DATA0, val32 & 65535);
+ mdio_write(robo, ROBO_PHY_ADDR, REG_MII_DATA0 + 1, val32 >> 16);
+
+ robo_reg(robo, page, reg, REG_MII_ADDR_WRITE);
+}
+
+/* checks that attached switch is 5325E/5350 */
+static int robo_vlan5350(robo_t *robo)
+{
+ /* set vlan access id to 15 and read it back */
+ u16 val16 = 15;
+ robo_write16(robo, ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS_5350, val16);
+
+ /* 5365 will refuse this as it does not have this reg */
+ return (robo_read16(robo, ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS_5350) == val16);
+}
+
+u8 port[6] = { 0, 1, 2, 3, 4, 8 };
+char ports[6] = { 'W', '4', '3', '2', '1', 'C' };
+char *rxtx[4] = { "enabled", "rx_disabled", "tx_disabled", "disabled" };
+char *stp[8] = { "none", "disable", "block", "listen", "learn", "forward", "6", "7" };
+
+struct {
+ char *name;
+ u16 bmcr;
+} media[5] = { { "auto", BMCR_ANENABLE | BMCR_ANRESTART },
+ { "10HD", 0 }, { "10FD", BMCR_FULLDPLX },
+ { "100HD", BMCR_SPEED100 }, { "100FD", BMCR_SPEED100 | BMCR_FULLDPLX } };
+
+struct {
+ char *name;
+ u16 value;
+} mdix[3] = { { "auto", 0x0000 }, { "on", 0x1800 }, { "off", 0x0800 } };
+
+void usage()
+{
+ fprintf(stderr, "Broadcom BCM5325E/536x switch configuration utility\n"
+ "Copyright (C) 2005 Oleg I. Vdovikin\n\n"
+ "This program is distributed in the hope that it will be useful,\n"
+ "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
+ "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
+ "GNU General Public License for more details.\n\n");
+
+ fprintf(stderr, "Usage: robocfg <op> ... <op>\n"
+ "Operations are as below:\n"
+ "\tshow\n"
+ "\tswitch <enable|disable>\n"
+ "\tport <port_number> [state <%s|%s|%s|%s>]\n\t\t[stp %s|%s|%s|%s|%s|%s] [tag <vlan_tag>]\n"
+ "\t\t[media %s|%s|%s|%s|%s] [mdi-x %s|%s|%s]\n"
+ "\tvlan <vlan_number> [ports <ports_list>]\n"
+ "\tvlans <enable|disable|reset>\n\n"
+ "\tports_list should be one argument, space separated, quoted if needed,\n"
+ "\tport number could be followed by 't' to leave packet vlan tagged (CPU \n"
+ "\tport default) or by 'u' to untag packet (other ports default) before \n"
+ "\tbringing it to the port, '*' is ignored\n"
+ "\nSamples:\n"
+ "1) ASUS WL-500g Deluxe stock config (eth0 is WAN, eth0.1 is LAN):\n"
+ "robocfg switch disable vlans enable reset vlan 0 ports \"0 5u\" vlan 1 ports \"1 2 3 4 5t\""
+ " port 0 state enabled stp none switch enable\n"
+ "2) WRT54g, WL-500g Deluxe OpenWRT config (vlan0 is LAN, vlan1 is WAN):\n"
+ "robocfg switch disable vlans enable reset vlan 0 ports \"1 2 3 4 5t\" vlan 1 ports \"0 5t\""
+ " port 0 state enabled stp none switch enable\n",
+ rxtx[0], rxtx[1], rxtx[2], rxtx[3], stp[0], stp[1], stp[2], stp[3], stp[4], stp[5],
+ media[0].name, media[1].name, media[2].name, media[3].name, media[4].name,
+ mdix[0].name, mdix[1].name, mdix[2].name);
+}
+
+static robo_t robo;
+int bcm53xx_probe(const char *dev)
+{
+ struct ethtool_drvinfo info;
+ unsigned int phyid;
+ int ret;
+
+ fprintf(stderr, "probing %s\n", dev);
+
+ strcpy(robo.ifr.ifr_name, dev);
+ memset(&info, 0, sizeof(info));
+ info.cmd = ETHTOOL_GDRVINFO;
+ robo.ifr.ifr_data = (caddr_t)&info;
+ ret = ioctl(robo.fd, SIOCETHTOOL, (caddr_t)&robo.ifr);
+ if (ret < 0) {
+ perror("SIOCETHTOOL");
+ return ret;
+ }
+
+ if ( strcmp(info.driver, "et0") &&
+ strcmp(info.driver, "b44") &&
+ strcmp(info.driver, "bcm63xx_enet") ) {
+ fprintf(stderr, "driver not supported %s\n", info.driver);
+ return -ENOSYS;
+ }
+
+ /* try access using MII ioctls - get phy address */
+ robo.et = 0;
+ if (ioctl(robo.fd, SIOCGMIIPHY, &robo.ifr) < 0)
+ robo.et = 1;
+
+ if (robo.et) {
+ unsigned int args[2] = { 2 };
+
+ robo.ifr.ifr_data = (caddr_t) args;
+ ret = ioctl(robo.fd, SIOCGETCPHYRD, (caddr_t)&robo.ifr);
+ if (ret < 0) {
+ perror("SIOCGETCPHYRD");
+ return ret;
+ }
+ phyid = args[1] & 0xffff;
+
+ args[0] = 3;
+ robo.ifr.ifr_data = (caddr_t) args;
+ ret = ioctl(robo.fd, SIOCGETCPHYRD, (caddr_t)&robo.ifr);
+ if (ret < 0) {
+ perror("SIOCGETCPHYRD");
+ return ret;
+ }
+ phyid |= args[1] << 16;
+ } else {
+ struct mii_ioctl_data *mii = (struct mii_ioctl_data *)&robo.ifr.ifr_data;
+ mii->phy_id = ROBO_PHY_ADDR;
+ mii->reg_num = 2;
+ ret = ioctl(robo.fd, SIOCGMIIREG, &robo.ifr);
+ if (ret < 0) {
+ perror("SIOCGMIIREG");
+ return ret;
+ }
+ phyid = mii->val_out & 0xffff;
+
+ mii->phy_id = ROBO_PHY_ADDR;
+ mii->reg_num = 3;
+ ret = ioctl(robo.fd, SIOCGMIIREG, &robo.ifr);
+ if (ret < 0) {
+ perror("SIOCGMIIREG");
+ return ret;
+ }
+ phyid |= mii->val_out << 16;
+ }
+
+ if (phyid == 0xffffffff || phyid == 0x55210022) {
+ perror("phyid");
+ return -EIO;
+ }
+
+ return 0;
+}
+
+int
+main(int argc, char *argv[])
+{
+ u16 val16;
+ u16 mac[3];
+ int i = 0, j;
+ int robo5350 = 0;
+ u32 phyid;
+
+ if ((robo.fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
+ perror("socket");
+ exit(1);
+ }
+
+ if (bcm53xx_probe("eth1")) {
+ if (bcm53xx_probe("eth0")) {
+ perror("bcm53xx_probe");
+ exit(1);
+ }
+ }
+
+ robo5350 = robo_vlan5350(&robo);
+
+ for (i = 1; i < argc;) {
+ if (strcasecmp(argv[i], "port") == 0 && (i + 1) < argc)
+ {
+ int index = atoi(argv[++i]);
+ /* read port specs */
+ while (++i < argc) {
+ if (strcasecmp(argv[i], "state") == 0 && ++i < argc) {
+ for (j = 0; j < 4 && strcasecmp(argv[i], rxtx[j]); j++);
+ if (j < 4) {
+ /* change state */
+ robo_write16(&robo,ROBO_CTRL_PAGE, port[index],
+ (robo_read16(&robo, ROBO_CTRL_PAGE, port[index]) & ~(3 << 0)) | (j << 0));
+ } else {
+ fprintf(stderr, "Invalid state '%s'.\n", argv[i]);
+ exit(1);
+ }
+ } else
+ if (strcasecmp(argv[i], "stp") == 0 && ++i < argc) {
+ for (j = 0; j < 8 && strcasecmp(argv[i], stp[j]); j++);
+ if (j < 8) {
+ /* change stp */
+ robo_write16(&robo,ROBO_CTRL_PAGE, port[index],
+ (robo_read16(&robo, ROBO_CTRL_PAGE, port[index]) & ~(7 << 5)) | (j << 5));
+ } else {
+ fprintf(stderr, "Invalid stp '%s'.\n", argv[i]);
+ exit(1);
+ }
+ } else
+ if (strcasecmp(argv[i], "media") == 0 && ++i < argc) {
+ for (j = 0; j < 5 && strcasecmp(argv[i], media[j].name); j++);
+ if (j < 5) {
+ mdio_write(&robo, port[index], MII_BMCR, media[j].bmcr);
+ } else {
+ fprintf(stderr, "Invalid media '%s'.\n", argv[i]);
+ exit(1);
+ }
+ } else
+ if (strcasecmp(argv[i], "mdi-x") == 0 && ++i < argc) {
+ for (j = 0; j < 3 && strcasecmp(argv[i], mdix[j].name); j++);
+ if (j < 3) {
+ mdio_write(&robo, port[index], 0x1c, mdix[j].value |
+ (mdio_read(&robo, port[index], 0x1c) & ~0x1800));
+ } else {
+ fprintf(stderr, "Invalid mdi-x '%s'.\n", argv[i]);
+ exit(1);
+ }
+ } else
+ if (strcasecmp(argv[i], "tag") == 0 && ++i < argc) {
+ j = atoi(argv[i]);
+ /* change vlan tag */
+ robo_write16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_PORT0_DEF_TAG + (index << 1), j);
+ } else break;
+ }
+ } else
+ if (strcasecmp(argv[i], "vlan") == 0 && (i + 1) < argc)
+ {
+ int index = atoi(argv[++i]);
+ while (++i < argc) {
+ if (strcasecmp(argv[i], "ports") == 0 && ++i < argc) {
+ char *ports = argv[i];
+ int untag = 0;
+ int member = 0;
+
+ while (*ports >= '0' && *ports <= '9') {
+ j = *ports++ - '0';
+ member |= 1 << j;
+
+ /* untag if needed, CPU port requires special handling */
+ if (*ports == 'u' || (j != 5 && (*ports == ' ' || *ports == 0)))
+ {
+ untag |= 1 << j;
+ if (*ports) ports++;
+ /* change default vlan tag */
+ robo_write16(&robo, ROBO_VLAN_PAGE,
+ ROBO_VLAN_PORT0_DEF_TAG + (j << 1), index);
+ } else
+ if (*ports == '*' || *ports == 't' || *ports == ' ') ports++;
+ else break;
+
+ while (*ports == ' ') ports++;
+ }
+
+ if (*ports) {
+ fprintf(stderr, "Invalid ports '%s'.\n", argv[i]);
+ exit(1);
+ } else {
+ /* write config now */
+ val16 = (index) /* vlan */ | (1 << 12) /* write */ | (1 << 13) /* enable */;
+ if (robo5350) {
+ robo_write32(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_WRITE_5350,
+ (1 << 20) /* valid */ | (untag << 6) | member);
+ robo_write16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS_5350, val16);
+ } else {
+ robo_write16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_WRITE,
+ (1 << 14) /* valid */ | (untag << 7) | member);
+ robo_write16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS, val16);
+ }
+ }
+ } else break;
+ }
+ } else
+ if (strcasecmp(argv[i], "switch") == 0 && (i + 1) < argc)
+ {
+ /* enable/disable switching */
+ robo_write16(&robo, ROBO_CTRL_PAGE, ROBO_SWITCH_MODE,
+ (robo_read16(&robo, ROBO_CTRL_PAGE, ROBO_SWITCH_MODE) & ~2) |
+ (*argv[++i] == 'e' ? 2 : 0));
+ i++;
+ } else
+ if (strcasecmp(argv[i], "vlans") == 0 && (i + 1) < argc)
+ {
+ while (++i < argc) {
+ if (strcasecmp(argv[i], "reset") == 0) {
+ /* reset vlan validity bit */
+ for (j = 0; j <= (robo5350 ? VLAN_ID_MAX5350 : VLAN_ID_MAX); j++)
+ {
+ /* write config now */
+ val16 = (j) /* vlan */ | (1 << 12) /* write */ | (1 << 13) /* enable */;
+ if (robo5350) {
+ robo_write32(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_WRITE_5350, 0);
+ robo_write16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS_5350, val16);
+ } else {
+ robo_write16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_WRITE, 0);
+ robo_write16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS, val16);
+ }
+ }
+ } else
+ if (strcasecmp(argv[i], "enable") == 0 || strcasecmp(argv[i], "disable") == 0)
+ {
+ int disable = (*argv[i] == 'd') || (*argv[i] == 'D');
+ /* enable/disable vlans */
+ robo_write16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_CTRL0, disable ? 0 :
+ (1 << 7) /* 802.1Q VLAN */ | (3 << 5) /* mac check and hash */);
+
+ robo_write16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_CTRL1, disable ? 0 :
+ (1 << 1) | (1 << 2) | (1 << 3) /* RSV multicast */);
+
+ robo_write16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_CTRL4, disable ? 0 :
+ (1 << 6) /* drop invalid VID frames */);
+
+ robo_write16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_CTRL5, disable ? 0 :
+ (1 << 3) /* drop miss V table frames */);
+
+ } else break;
+ }
+ } else
+ if (strcasecmp(argv[i], "show") == 0)
+ {
+ break;
+ } else {
+ fprintf(stderr, "Invalid option %s\n", argv[i]);
+ usage();
+ exit(1);
+ }
+ }
+
+ if (i == argc) {
+ if (argc == 1) usage();
+ return 0;
+ }
+
+ /* show config */
+
+ printf("Switch: %sabled\n", robo_read16(&robo, ROBO_CTRL_PAGE, ROBO_SWITCH_MODE) & 2 ? "en" : "dis");
+
+ for (i = 0; i < 6; i++) {
+ printf(robo_read16(&robo, ROBO_STAT_PAGE, ROBO_LINK_STAT_SUMMARY) & (1 << port[i]) ?
+ "Port %d(%c): %s%s " : "Port %d(%c): DOWN ", i, ports[i],
+ robo_read16(&robo, ROBO_STAT_PAGE, ROBO_SPEED_STAT_SUMMARY) & (1 << port[i]) ? "100" : " 10",
+ robo_read16(&robo, ROBO_STAT_PAGE, ROBO_DUPLEX_STAT_SUMMARY) & (1 << port[i]) ? "FD" : "HD");
+
+ val16 = robo_read16(&robo, ROBO_CTRL_PAGE, port[i]);
+
+ printf("%s stp: %s vlan: %d ", rxtx[val16 & 3], stp[(val16 >> 5) & 7],
+ robo_read16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_PORT0_DEF_TAG + (i << 1)));
+
+ robo_read(&robo, ROBO_STAT_PAGE, ROBO_LSA_PORT0 + port[i] * 6, mac, 3);
+
+ printf("mac: %02x:%02x:%02x:%02x:%02x:%02x\n",
+ mac[2] >> 8, mac[2] & 255, mac[1] >> 8, mac[1] & 255, mac[0] >> 8, mac[0] & 255);
+ }
+
+ val16 = robo_read16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_CTRL0);
+
+ printf("VLANs: %s %sabled%s%s\n",
+ robo5350 ? "BCM5325/535x" : "BCM536x",
+ (val16 & (1 << 7)) ? "en" : "dis",
+ (val16 & (1 << 6)) ? " mac_check" : "",
+ (val16 & (1 << 5)) ? " mac_hash" : "");
+
+ /* scan VLANs */
+ for (i = 0; i <= (robo5350 ? VLAN_ID_MAX5350 : VLAN_ID_MAX); i++) {
+ /* issue read */
+ val16 = (i) /* vlan */ | (0 << 12) /* read */ | (1 << 13) /* enable */;
+
+ if (robo5350) {
+ u32 val32;
+ robo_write16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS_5350, val16);
+ /* actual read */
+ val32 = robo_read32(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_READ);
+ if ((val32 & (1 << 20)) /* valid */) {
+ printf("vlan%d:", i);
+ for (j = 0; j < 6; j++) {
+ if (val32 & (1 << j)) {
+ printf(" %d%s", j, (val32 & (1 << (j + 6))) ?
+ (j == 5 ? "u" : "") : "t");
+ }
+ }
+ printf("\n");
+ }
+ } else {
+ robo_write16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS, val16);
+ /* actual read */
+ val16 = robo_read16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_READ);
+ if ((val16 & (1 << 14)) /* valid */) {
+ printf("vlan%d:", i);
+ for (j = 0; j < 6; j++) {
+ if (val16 & (1 << j)) {
+ printf(" %d%s", j, (val16 & (1 << (j + 7))) ?
+ (j == 5 ? "u" : "") : "t");
+ }
+ }
+ printf("\n");
+ }
+ }
+ }
+
+ return (0);
+}
diff --git a/package/system/utils/robocfg/src/Makefile b/package/system/utils/robocfg/src/Makefile
new file mode 100644
index 0000000..e11acb0
--- /dev/null
+++ b/package/system/utils/robocfg/src/Makefile
@@ -0,0 +1,11 @@
+
+all: robocfg
+
+%.o: %.c
+ $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $^
+
+robocfg: robocfg.o
+ $(CC) -o $@ $^
+
+clean:
+ rm -f *.o robocfg
diff --git a/package/system/utils/robocfg/src/etc53xx.h b/package/system/utils/robocfg/src/etc53xx.h
new file mode 100644
index 0000000..d5b1310
--- /dev/null
+++ b/package/system/utils/robocfg/src/etc53xx.h
@@ -0,0 +1,619 @@
+/*
+ * Broadcom Home Gateway Reference Design
+ * BCM53xx Register definitions
+ *
+ * Copyright 2004, Broadcom Corporation
+ * All Rights Reserved.
+ *
+ * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
+ * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
+ * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
+ * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
+ */
+
+#ifndef __BCM535M_H_
+#define __BCM535M_H_
+
+/* ROBO embedded device type */
+#define ROBO_DEV_5380 1
+#define ROBO_DEV_5365 2
+#define ROBO_DEV_5350 3
+
+/* BCM5325m GLOBAL PAGE REGISTER MAP */
+#ifndef _CFE_
+#pragma pack(1)
+#endif
+
+/* BCM5325m Serial Management Port (SMP) Page offsets */
+#define ROBO_CTRL_PAGE 0x00 /* Control registers */
+#define ROBO_STAT_PAGE 0x01 /* Status register */
+#define ROBO_MGMT_PAGE 0x02 /* Management Mode registers */
+#define ROBO_MIB_AC_PAGE 0x03 /* MIB Autocast registers */
+#define ROBO_ARLCTRL_PAGE 0x04 /* ARL Control Registers */
+#define ROBO_ARLIO_PAGE 0x05 /* ARL Access Registers */
+#define ROBO_FRAMEBUF_PAGE 0x06 /* Management frame access registers */
+#define ROBO_MEM_ACCESS_PAGE 0x08 /* Memory access registers */
+
+/* PHY Registers */
+#define ROBO_PORT0_MII_PAGE 0x10 /* Port 0 MII Registers */
+#define ROBO_PORT1_MII_PAGE 0x11 /* Port 1 MII Registers */
+#define ROBO_PORT2_MII_PAGE 0x12 /* Port 2 MII Registers */
+#define ROBO_PORT3_MII_PAGE 0x13 /* Port 3 MII Registers */
+#define ROBO_PORT4_MII_PAGE 0x14 /* Port 4 MII Registers */
+/* (start) registers only for BCM5380 */
+#define ROBO_PORT5_MII_PAGE 0x15 /* Port 5 MII Registers */
+#define ROBO_PORT6_MII_PAGE 0x16 /* Port 6 MII Registers */
+#define ROBO_PORT7_MII_PAGE 0x17 /* Port 7 MII Registers */
+/* (end) registers only for BCM5380 */
+#define ROBO_IM_PORT_PAGE 0x18 /* Inverse MII Port (to EMAC) */
+#define ROBO_ALL_PORT_PAGE 0x19 /* All ports MII Registers (broadcast)*/
+
+/* MAC Statistics registers */
+#define ROBO_PORT0_MIB_PAGE 0x20 /* Port 0 10/100 MIB Statistics */
+#define ROBO_PORT1_MIB_PAGE 0x21 /* Port 1 10/100 MIB Statistics */
+#define ROBO_PORT2_MIB_PAGE 0x22 /* Port 2 10/100 MIB Statistics */
+#define ROBO_PORT3_MIB_PAGE 0x23 /* Port 3 10/100 MIB Statistics */
+#define ROBO_PORT4_MIB_PAGE 0x24 /* Port 4 10/100 MIB Statistics */
+/* (start) registers only for BCM5380 */
+#define ROBO_PORT5_MIB_PAGE 0x25 /* Port 5 10/100 MIB Statistics */
+#define ROBO_PORT6_MIB_PAGE 0x26 /* Port 6 10/100 MIB Statistics */
+#define ROBO_PORT7_MIB_PAGE 0x27 /* Port 7 10/100 MIB Statistics */
+/* (end) registers only for BCM5380 */
+#define ROBO_IM_PORT_MIB_PAGE 0x28 /* Inverse MII Port MIB Statistics */
+
+/* Quality of Service (QoS) Registers */
+#define ROBO_QOS_PAGE 0x30 /* QoS Registers */
+
+/* VLAN Registers */
+#define ROBO_VLAN_PAGE 0x34 /* VLAN Registers */
+
+/* Note SPI Data/IO Registers not used */
+#define ROBO_SPI_DATA_IO_0_PAGE 0xf0 /* SPI Data I/O 0 */
+#define ROBO_SPI_DATA_IO_1_PAGE 0xf1 /* SPI Data I/O 1 */
+#define ROBO_SPI_DATA_IO_2_PAGE 0xf2 /* SPI Data I/O 2 */
+#define ROBO_SPI_DATA_IO_3_PAGE 0xf3 /* SPI Data I/O 3 */
+#define ROBO_SPI_DATA_IO_4_PAGE 0xf4 /* SPI Data I/O 4 */
+#define ROBO_SPI_DATA_IO_5_PAGE 0xf5 /* SPI Data I/O 5 */
+#define ROBO_SPI_DATA_IO_6_PAGE 0xf6 /* SPI Data I/O 6 */
+#define ROBO_SPI_DATA_IO_7_PAGE 0xf7 /* SPI Data I/O 7 */
+
+#define ROBO_SPI_STATUS_PAGE 0xfe /* SPI Status Registers */
+#define ROBO_PAGE_PAGE 0xff /* Page Registers */
+
+
+/* BCM5325m CONTROL PAGE (0x00) REGISTER MAP : 8bit (byte) registers */
+typedef struct _ROBO_PORT_CTRL_STRUC
+{
+ unsigned char rx_disable:1; /* rx disable */
+ unsigned char tx_disable:1; /* tx disable */
+ unsigned char rsvd:3; /* reserved */
+ unsigned char stp_state:3; /* spanning tree state */
+} ROBO_PORT_CTRL_STRUC;
+
+#define ROBO_PORT0_CTRL 0x00 /* 10/100 Port 0 Control */
+#define ROBO_PORT1_CTRL 0x01 /* 10/100 Port 1 Control */
+#define ROBO_PORT2_CTRL 0x02 /* 10/100 Port 2 Control */
+#define ROBO_PORT3_CTRL 0x03 /* 10/100 Port 3 Control */
+#define ROBO_PORT4_CTRL 0x04 /* 10/100 Port 4 Control */
+/* (start) registers only for BCM5380 */
+#define ROBO_PORT5_CTRL 0x05 /* 10/100 Port 5 Control */
+#define ROBO_PORT6_CTRL 0x06 /* 10/100 Port 6 Control */
+#define ROBO_PORT7_CTRL 0x07 /* 10/100 Port 7 Control */
+/* (end) registers only for BCM5380 */
+#define ROBO_IM_PORT_CTRL 0x08 /* 10/100 Port 8 Control */
+#define ROBO_SMP_CTRL 0x0a /* SMP Control register */
+#define ROBO_SWITCH_MODE 0x0b /* Switch Mode Control */
+#define ROBO_PORT_OVERRIDE_CTRL 0x0e /* Port state override */
+#define ROBO_PORT_OVERRIDE_RVMII (1<<4) /* Bit 4 enables RvMII */
+#define ROBO_PD_MODE_CTRL 0x0f /* Power-down mode control */
+#define ROBO_IP_MULTICAST_CTRL 0x21 /* IP Multicast control */
+
+/* BCM5325m STATUS PAGE (0x01) REGISTER MAP : 16bit/48bit registers */
+#define ROBO_HALF_DUPLEX 0
+#define ROBO_FULL_DUPLEX 1
+
+#define ROBO_LINK_STAT_SUMMARY 0x00 /* Link Status Summary: 16bit */
+#define ROBO_LINK_STAT_CHANGE 0x02 /* Link Status Change: 16bit */
+#define ROBO_SPEED_STAT_SUMMARY 0x04 /* Port Speed Summary: 16bit*/
+#define ROBO_DUPLEX_STAT_SUMMARY 0x06 /* Duplex Status Summary: 16bit */
+#define ROBO_PAUSE_STAT_SUMMARY 0x08 /* PAUSE Status Summary: 16bit */
+#define ROBO_SOURCE_ADDR_CHANGE 0x0C /* Source Address Change: 16bit */
+#define ROBO_LSA_PORT0 0x10 /* Last Source Addr, Port 0: 48bits*/
+#define ROBO_LSA_PORT1 0x16 /* Last Source Addr, Port 1: 48bits*/
+#define ROBO_LSA_PORT2 0x1c /* Last Source Addr, Port 2: 48bits*/
+#define ROBO_LSA_PORT3 0x22 /* Last Source Addr, Port 3: 48bits*/
+#define ROBO_LSA_PORT4 0x28 /* Last Source Addr, Port 4: 48bits*/
+#define ROBO_LSA_IM_PORT 0x40 /* Last Source Addr, IM Port: 48bits*/
+
+/* BCM5325m MANAGEMENT MODE REGISTERS (0x02) REGISTER MAP: 8/48 bit regs*/
+typedef struct _ROBO_GLOBAL_CONFIG_STRUC
+{
+ unsigned char resetMIB:1; /* reset MIB counters */
+ unsigned char rxBPDU:1; /* receive BDPU enable */
+ unsigned char rsvd1:2; /* reserved */
+ unsigned char MIBacHdrCtrl:1; /* MIB autocast header control */
+ unsigned char MIBac:1; /* MIB autocast enable */
+ unsigned char frameMgmtPort:2; /* frame management port */
+} ROBO_GLOBAL_CONFIG_STRUC;
+#define ROBO_GLOBAL_CONFIG 0x00 /* Global Management Config: 8bit*/
+#define ROBO_MGMT_PORT_ID 0x02 /* Management Port ID: 8bit*/
+#define ROBO_RMON_MIB_STEER 0x04 /* RMON Mib Steering: 16bit */
+#define ROBO_MIB_MODE_SELECT 0x04 /* MIB Mode select: 16bit (BCM5350) */
+#define ROBO_AGE_TIMER_CTRL 0x06 /* Age time control: 32bit */
+#define ROBO_MIRROR_CAP_CTRL 0x10 /* Mirror Capture : 16bit */
+#define ROBO_MIRROR_ING_CTRL 0x12 /* Mirror Ingress Control: 16bit */
+#define ROBO_MIRROR_ING_DIV_CTRL 0x14 /* Mirror Ingress Divider: 16bit */
+#define ROBO_MIRROR_ING_MAC_ADDR 0x16 /* Ingress Mirror MAC Addr: 48bit*/
+#define ROBO_MIRROR_EGR_CTRL 0x1c /* Mirror Egress Control: 16bit */
+#define ROBO_MIRROR_EGR_DIV_CTRL 0x1e /* Mirror Egress Divider: 16bit */
+#define ROBO_MIRROR_EGR_MAC_ADDR 0x20 /* Egress Mirror MAC Addr: 48bit*/
+
+/* BCM5325m MIB AUTOCAST REGISTERS (0x03) REGISTER MAP: 8/16/48 bit regs */
+#define ROBO_MIB_AC_PORT 0x00 /* MIB Autocast Port: 16bit */
+#define ROBO_MIB_AC_HDR_PTR 0x02 /* MIB Autocast Header pointer:16bit*/
+#define ROBO_MIB_AC_HDR_LEN 0x04 /* MIB Autocast Header Len: 16bit */
+#define ROBO_MIB_AC_DA 0x06 /* MIB Autocast DA: 48bit */
+#define ROBO_MIB_AC_SA 0x0c /* MIB Autocast SA: 48bit */
+#define ROBO_MIB_AC_TYPE 0x12 /* MIB Autocast Type: 16bit */
+#define ROBO_MIB_AC_RATE 0x14 /* MIB Autocast Rate: 8bit */
+#define ROBO_GET_AC_RATE(secs) ((secs)*10)
+#define ROBO_AC_RATE_MAX 0xff
+#define ROBO_AC_RATE_DEFAULT 0x64 /* 10 secs */
+typedef struct _ROBO_MIB_AC_STRUCT
+{
+ unsigned char opcode:4; /* Tx MIB Autocast opcode */
+ unsigned char portno:4; /* zero-based port no. */
+ unsigned char portstate:8; /* port state */
+ unsigned long long TxOctets;
+ unsigned int TxDropPkts;
+ unsigned int rsvd;
+ unsigned int TxBroadcastPkts;
+ unsigned int TxMulticastPkts;
+ unsigned int TxUnicastPkts;
+ unsigned int TxCollisions;
+ unsigned int TxSingleCollision;
+ unsigned int TxMultiCollision;
+ unsigned int TxDeferredTransmit;
+ unsigned int TxLateCollision;
+ unsigned int TxExcessiveCollision;
+ unsigned int TxFrameInDiscards;
+ unsigned int TxPausePkts;
+ unsigned int rsvd1[2];
+ unsigned long long RxOctets;
+ unsigned int RxUndersizePkts;
+ unsigned int RxPausePkts;
+ unsigned int RxPkts64Octets;
+ unsigned int RxPkts64to127Octets;
+ unsigned int RxPkts128to255Octets;
+ unsigned int RxPkts256to511Octets;
+ unsigned int RxPkts512to1023Octets;
+ unsigned int RxPkts1024to1522Octets;
+ unsigned int RxOversizePkts;
+ unsigned int RxJabbers;
+ unsigned int RxAlignmentErrors;
+ unsigned int RxFCSErrors;
+ unsigned long long RxGoodOctets;
+ unsigned int RxDropPkts;
+ unsigned int RxUnicastPkts;
+ unsigned int RxMulticastPkts;
+ unsigned int RxBroadcastPkts;
+ unsigned int RxSAChanges;
+ unsigned int RxFragments;
+ unsigned int RxExcessSizeDisc;
+ unsigned int RxSymbolError;
+} ROBO_MIB_AC_STRUCT;
+
+/* BCM5325m ARL CONTROL REGISTERS (0x04) REGISTER MAP: 8/16/48/64 bit regs */
+#define ROBO_ARL_CONFIG 0x00 /* ARL Global Configuration: 8bit*/
+#define ROBO_BPDU_MC_ADDR_REG 0x04 /* BPDU Multicast Address Reg:64bit*/
+#define ROBO_MULTIPORT_ADDR_1 0x10 /* Multiport Address 1: 48 bits*/
+#define ROBO_MULTIPORT_VECTOR_1 0x16 /* Multiport Vector 1: 16 bits */
+#define ROBO_MULTIPORT_ADDR_2 0x20 /* Multiport Address 2: 48 bits*/
+#define ROBO_MULTIPORT_VECTOR_2 0x26 /* Multiport Vector 2: 16 bits */
+#define ROBO_SECURE_SRC_PORT_MASK 0x30 /* Secure Source Port Mask: 16 bits*/
+#define ROBO_SECURE_DST_PORT_MASK 0x32 /* Secure Dest Port Mask: 16 bits */
+
+
+/* BCM5325m ARL IO REGISTERS (0x05) REGISTER MAP: 8/16/48/64 bit regs */
+#define ARL_TABLE_WRITE 0 /* for read/write state in control reg */
+#define ARL_TABLE_READ 1 /* for read/write state in control reg */
+#ifdef BCM5380
+#define ARL_VID_BYTES 2 /* number of bytes for VID */
+#else
+#define ARL_VID_BYTES 1 /* number of bytes for VID */
+#endif
+typedef struct _ROBO_ARL_RW_CTRL_STRUC
+{
+ unsigned char ARLrw:1; /* ARL read/write (1=read) */
+ unsigned char rsvd:6; /* reserved */
+ unsigned char ARLStart:1; /* ARL start/done (1=start) */
+} ROBO_ARL_RW_CTRL_STRUC;
+typedef struct _ROBO_ARL_SEARCH_CTRL_STRUC
+{
+ unsigned char valid:1; /* ARL search result valid */
+ unsigned char rsvd:6; /* reserved */
+ unsigned char ARLStart:1; /* ARL start/done (1=start) */
+} ROBO_ARL_SEARCH_CTRL_STRUC;
+typedef struct _ROBO_ARL_ENTRY_CTRL_STRUC
+{
+ unsigned char portID:4; /* port id */
+ unsigned char chipID:2; /* chip id */
+ unsigned char rsvd:5; /* reserved */
+ unsigned char prio:2; /* priority */
+ unsigned char age:1; /* age */
+ unsigned char staticEn:1; /* static */
+ unsigned char valid:1; /* valid */
+} ROBO_ARL_ENTRY_CTRL_STRUC;
+typedef struct _ROBO_ARL_SEARCH_RESULT_CTRL_STRUC
+{
+ unsigned char portID:4; /* port id */
+ unsigned char rsvd:1; /* reserved */
+ unsigned char vid:8; /* vlan id */
+ unsigned char age:1; /* age */
+ unsigned char staticEn:1; /* static */
+ unsigned char valid:1; /* valid */
+} ROBO_ARL_SEARCH_RESULT_CTRL_STRUC;
+typedef struct _ROBO_ARL_ENTRY_MAC_STRUC
+{
+ unsigned char macBytes[6]; /* MAC address */
+} ROBO_ARL_ENTRY_MAC_STRUC;
+
+typedef struct _ROBO_ARL_ENTRY_STRUC
+{
+ ROBO_ARL_ENTRY_MAC_STRUC mac; /* MAC address */
+ ROBO_ARL_ENTRY_CTRL_STRUC ctrl; /* control bits */
+} ROBO_ARL_ENTRY_STRUC;
+
+typedef struct _ROBO_ARL_SEARCH_RESULT_STRUC
+{
+ ROBO_ARL_ENTRY_MAC_STRUC mac; /* MAC address */
+ ROBO_ARL_SEARCH_RESULT_CTRL_STRUC ctrl; /* control bits */
+} ROBO_ARL_SEARCH_RESULT_STRUC;
+
+/* multicast versions of ARL entry structs */
+typedef struct _ROBO_ARL_ENTRY_MCAST_CTRL_STRUC
+{
+ unsigned int portMask:12;/* multicast port mask */
+ unsigned char prio:1; /* priority */
+ unsigned char gigPort:1; /* gigabit port 1 mask */
+ unsigned char staticEn:1; /* static */
+ unsigned char valid:1; /* valid */
+} ROBO_ARL_ENTRY_MCAST_CTRL_STRUC;
+typedef struct _ROBO_ARL_SEARCH_RESULT_MCAST_CTRL_STRUC
+{
+ unsigned int portMask:13; /* multicast port mask */
+ unsigned char age:1; /* age */
+ unsigned char staticEn:1; /* static */
+ unsigned char valid:1; /* valid */
+} ROBO_ARL_SEARCH_RESULT_MCAST_CTRL_STRUC;
+/* BCM5350 extension register */
+typedef struct _ROBO_ARL_SEARCH_RESULT_EXTENSION
+{
+ unsigned int prio:2; /* priority */
+ unsigned int portMask:1; /* MSB (MII) of port mask for multicast */
+ unsigned int reserved:5;
+} ROBO_ARL_SEARCH_RESULT_EXTENSION;
+
+typedef struct _ROBO_ARL_ENTRY_MCAST_STRUC
+{
+ ROBO_ARL_ENTRY_MAC_STRUC mac; /* MAC address */
+ ROBO_ARL_ENTRY_MCAST_CTRL_STRUC ctrl; /* control bits */
+} ROBO_ARL_ENTRY_MCAST_STRUC;
+typedef struct _ROBO_ARL_SEARCH_RESULT_MCAST_STRUC
+{
+ ROBO_ARL_ENTRY_MAC_STRUC mac; /* MAC address */
+ ROBO_ARL_SEARCH_RESULT_MCAST_CTRL_STRUC ctrl; /* control bits */
+} ROBO_ARL_SEARCH_RESULT_MCAST_STRUC;
+
+#define ROBO_ARL_RW_CTRL 0x00 /* ARL Read/Write Control : 8bit */
+#define ROBO_ARL_MAC_ADDR_IDX 0x02 /* MAC Address Index: 48bit */
+#define ROBO_ARL_VID_TABLE_IDX 0x08 /* VID Table Address Index: 8bit */
+#define ROBO_ARL_ENTRY0 0x10 /* ARL Entry 0 : 64 bit */
+#define ROBO_ARL_ENTRY1 0x18 /* ARL Entry 1 : 64 bit */
+#define ROBO_ARL_SEARCH_CTRL 0x20 /* ARL Search Control: 8bit */
+#define ROBO_ARL_SEARCH_ADDR 0x22 /* ARL Search Address: 16bit */
+#define ROBO_ARL_SEARCH_RESULT 0x24 /* ARL Search Result: 64bit */
+#define ROBO_ARL_SEARCH_RESULT_EXT 0x2c /* ARL Search Result Extension (5350): 8bit */
+#define ROBO_ARL_VID_ENTRY0 0x30 /* ARL VID Entry 0: 64bit */
+#define ROBO_ARL_VID_ENTRY1 0x32 /* ARL VID Entry 1: 64bit */
+
+/* BCM5325m MANAGEMENT FRAME REGISTERS (0x6) REGISTER MAP: 8/16 bit regs */
+#define ROBO_MGMT_FRAME_RD_DATA 0x00 /* Management Frame Read Data :8bit*/
+#define ROBO_MGMT_FRAME_WR_DATA 0x01 /* Management Frame Write Data:8bit*/
+#define ROBO_MGMT_FRAME_WR_CTRL 0x02 /* Write Control: 16bit */
+#define ROBO_MGMT_FRAME_RD_STAT 0x04 /* Read Status: 16bit */
+
+/* BCM5325m MEMORY ACCESS REGISTERS (Page 0x08) REGISTER MAP: 32 bit regs */
+#define MEM_TABLE_READ 1 /* for read/write state in mem access reg */
+#define MEM_TABLE_WRITE 0 /* for read/write state in mem access reg */
+#define MEM_TABLE_ACCESS_START 1 /* for mem access read/write start */
+#define MEM_TABLE_ACCESS_DONE 0 /* for mem access read/write done */
+#define VLAN_TABLE_ADDR 0x3800 /* BCM5380 only */
+#ifdef BCM5380
+#define NUM_ARL_TABLE_ENTRIES 4096 /* number of entries in ARL table */
+#define NUM_VLAN_TABLE_ENTRIES 2048 /* number of entries in VLAN table */
+#define ARL_TABLE_ADDR 0 /* offset of ARL table start */
+#else
+#define NUM_ARL_TABLE_ENTRIES 2048 /* number of entries in ARL table */
+#define NUM_VLAN_TABLE_ENTRIES 256 /* number of entries in VLAN table */
+#define ARL_TABLE_ADDR 0x3800 /* offset of ARL table start */
+/* corresponding values for 5350 */
+#define NUM_ARL_TABLE_ENTRIES_5350 1024 /* number of entries in ARL table (5350) */
+#define NUM_VLAN_TABLE_ENTRIES_5350 16 /* number of entries in VLAN table */
+#define ARL_TABLE_ADDR_5350 0x1c00 /* offset of ARL table start (5350) */
+#endif
+typedef struct _ROBO_MEM_ACCESS_CTRL_STRUC
+{
+ unsigned int memAddr:14; /* 64-bit memory address */
+ unsigned char rsvd:4; /* reserved */
+ unsigned char readEn:1; /* read enable (0 == write) */
+ unsigned char startDone:1;/* memory access start/done */
+ unsigned int rsvd1:12; /* reserved */
+} ROBO_MEM_ACCESS_CTRL_STRUC;
+typedef struct _ROBO_MEM_ACCESS_DATA_STRUC
+{
+ unsigned int memData[2]; /* 64-bit data */
+ unsigned short rsvd; /* reserved */
+} ROBO_MEM_ACCESS_DATA_STRUC;
+
+#ifdef BCM5380
+typedef struct _ROBO_ARL_TABLE_DATA_STRUC
+{
+ unsigned char MACaddr[6]; /* MAC addr */
+ unsigned int portID:4; /* port ID */
+ unsigned int chipID:2; /* chip ID */
+ unsigned int rsvd:6; /* reserved */
+ unsigned int highPrio:1; /* high priority address */
+ unsigned int age:1; /* entry accessed/learned since ageing process */
+ unsigned int staticAddr:1;/* entry is static */
+ unsigned int valid:1; /* entry is valid */
+ unsigned int vid:12; /* vlan id */
+ unsigned int rsvd2:4; /* reserved */
+} ROBO_ARL_TABLE_DATA_STRUC;
+#else
+typedef struct _ROBO_ARL_TABLE_DATA_STRUC
+{
+ unsigned char MACaddr[6]; /* MAC addr */
+ unsigned int portID:4; /* port ID */
+ unsigned int chipID:2; /* chip ID */
+ unsigned int rsvd:7; /* reserved */
+ unsigned int age:1; /* entry accessed/learned since ageing process */
+ unsigned int staticAddr:1;/* entry is static */
+ unsigned int valid:1; /* entry is valid */
+} ROBO_ARL_TABLE_DATA_STRUC;
+#endif
+
+/* multicast format*/
+typedef struct _ROBO_ARL_TABLE_MCAST_DATA_STRUC
+{
+ unsigned char MACaddr[6]; /* MAC addr */
+ unsigned int portMask:12;/* multicast port mask */
+ unsigned char prio:1; /* priority */
+ unsigned char gigPort:1; /* gigabit port 1 mask */
+ unsigned char staticEn:1; /* static */
+ unsigned char valid:1; /* valid */
+ unsigned int vid:12; /* vlan id */
+ unsigned int rsvd2:4; /* reserved */
+} ROBO_ARL_TABLE_MCAST_DATA_STRUC;
+#define ROBO_MEM_ACCESS_CTRL 0x00 /* Memory Read/Write Control :32bit*/
+#define ROBO_MEM_ACCESS_DATA 0x04 /* Memory Read/Write Data:64bit*/
+
+/* BCM5325m SWITCH PORT (0x10-18) REGISTER MAP: 8/16 bit regs */
+typedef struct _ROBO_MII_CTRL_STRUC
+{
+ unsigned char rsvd:8; /* reserved */
+ unsigned char duplex:1; /* duplex mode */
+ unsigned char restartAN:1;/* restart auto-negotiation */
+ unsigned char rsvd1:1; /* reserved */
+ unsigned char powerDown:1;/* power down */
+ unsigned char ANenable:1; /* auto-negotiation enable */
+ unsigned char speed:1; /* forced speed selection */
+ unsigned char loopback:1; /* loopback */
+ unsigned char reset:1; /* reset */
+} ROBO_MII_CTRL_STRUC;
+typedef struct _ROBO_MII_AN_ADVERT_STRUC
+{
+ unsigned char selector:5; /* advertise selector field */
+ unsigned char T10BaseT:1; /* advertise 10BaseT */
+ unsigned char T10BaseTFull:1; /* advertise 10BaseT, full duplex */
+ unsigned char T100BaseX:1; /* advertise 100BaseX */
+ unsigned char T100BaseXFull:1;/* advertise 100BaseX full duplex */
+ unsigned char noT4:1; /* do not advertise T4 */
+ unsigned char pause:1; /* advertise pause for full duplex */
+ unsigned char rsvd:2; /* reserved */
+ unsigned char remoteFault:1; /* transmit remote fault */
+ unsigned char rsvd1:1; /* reserved */
+ unsigned char nextPage:1; /* nex page operation supported */
+} ROBO_MII_AN_ADVERT_STRUC;
+#define ROBO_MII_CTRL 0x00 /* Port MII Control */
+#define ROBO_MII_STAT 0x02 /* Port MII Status */
+/* Fields of link status register */
+#define ROBO_MII_STAT_JABBER (1<<1) /* Jabber detected */
+#define ROBO_MII_STAT_LINK (1<<2) /* Link status */
+
+#define ROBO_MII_PHYID_HI 0x04 /* Port PHY ID High */
+#define ROBO_MII_PHYID_LO 0x06 /* Port PHY ID Low */
+#define ROBO_MII_ANA_REG 0x08 /* MII Auto-Neg Advertisement */
+#define ROBO_MII_ANP_REG 0x0a /* MII Auto-Neg Partner Ability */
+#define ROBO_MII_AN_EXP_REG 0x0c /* MII Auto-Neg Expansion */
+#define ROBO_MII_AN_NP_REG 0x0e /* MII next page */
+#define ROBO_MII_ANP_NP_REG 0x10 /* MII Partner next page */
+#define ROBO_MII_100BX_AUX_CTRL 0x20 /* 100BASE-X Auxiliary Control */
+#define ROBO_MII_100BX_AUX_STAT 0x22 /* 100BASE-X Auxiliary Status */
+#define ROBO_MII_100BX_RCV_ERR_CTR 0x24 /* 100BASE-X Receive Error Ctr */
+#define ROBO_MII_100BX_RCV_FS_ERR 0x26 /* 100BASE-X Rcv False Sense Ctr */
+#define ROBO_MII_AUX_CTRL 0x30 /* Auxiliary Control/Status */
+/* Fields of Auxiliary control register */
+#define ROBO_MII_AUX_CTRL_FD (1<<0) /* Full duplex link detected*/
+#define ROBO_MII_AUX_CTRL_SP100 (1<<1) /* Speed 100 indication */
+#define ROBO_MII_AUX_STATUS 0x32 /* Aux Status Summary */
+#define ROBO_MII_CONN_STATUS 0x34 /* Aux Connection Status */
+#define ROBO_MII_AUX_MODE2 0x36 /* Aux Mode 2 */
+#define ROBO_MII_AUX_ERR_STATUS 0x38 /* Aux Error and General Status */
+#define ROBO_MII_AUX_MULTI_PHY 0x3c /* Aux Multiple PHY Register*/
+#define ROBO_MII_BROADCOM_TEST 0x3e /* Broadcom Test Register */
+
+
+/* BCM5325m PORT MIB REGISTERS (Pages 0x20-0x24,0x28) REGISTER MAP: 64/32 */
+/* Tranmit Statistics */
+#define ROBO_MIB_TX_OCTETS 0x00 /* 64b: TxOctets */
+#define ROBO_MIB_TX_DROP_PKTS 0x08 /* 32b: TxDropPkts */
+#define ROBO_MIB_TX_BC_PKTS 0x10 /* 32b: TxBroadcastPkts */
+#define ROBO_MIB_TX_MC_PKTS 0x14 /* 32b: TxMulticastPkts */
+#define ROBO_MIB_TX_UC_PKTS 0x18 /* 32b: TxUnicastPkts */
+#define ROBO_MIB_TX_COLLISIONS 0x1c /* 32b: TxCollisions */
+#define ROBO_MIB_TX_SINGLE_COLLISIONS 0x20 /* 32b: TxSingleCollision */
+#define ROBO_MIB_TX_MULTI_COLLISIONS 0x24 /* 32b: TxMultiCollision */
+#define ROBO_MIB_TX_DEFER_TX 0x28 /* 32b: TxDeferred Transmit */
+#define ROBO_MIB_TX_LATE_COLLISIONS 0x2c /* 32b: TxLateCollision */
+#define ROBO_MIB_EXCESS_COLLISIONS 0x30 /* 32b: TxExcessiveCollision*/
+#define ROBO_MIB_FRAME_IN_DISCARDS 0x34 /* 32b: TxFrameInDiscards */
+#define ROBO_MIB_TX_PAUSE_PKTS 0x38 /* 32b: TxPausePkts */
+
+/* Receive Statistics */
+#define ROBO_MIB_RX_OCTETS 0x44 /* 64b: RxOctets */
+#define ROBO_MIB_RX_UNDER_SIZE_PKTS 0x4c /* 32b: RxUndersizePkts(runts)*/
+#define ROBO_MIB_RX_PAUSE_PKTS 0x50 /* 32b: RxPausePkts */
+#define ROBO_MIB_RX_PKTS_64 0x54 /* 32b: RxPkts64Octets */
+#define ROBO_MIB_RX_PKTS_65_TO_127 0x58 /* 32b: RxPkts64to127Octets*/
+#define ROBO_MIB_RX_PKTS_128_TO_255 0x5c /* 32b: RxPkts128to255Octets*/
+#define ROBO_MIB_RX_PKTS_256_TO_511 0x60 /* 32b: RxPkts256to511Octets*/
+#define ROBO_MIB_RX_PKTS_512_TO_1023 0x64 /* 32b: RxPkts512to1023Octets*/
+#define ROBO_MIB_RX_PKTS_1024_TO_1522 0x68 /* 32b: RxPkts1024to1522Octets*/
+#define ROBO_MIB_RX_OVER_SIZE_PKTS 0x6c /* 32b: RxOversizePkts*/
+#define ROBO_MIB_RX_JABBERS 0x70 /* 32b: RxJabbers*/
+#define ROBO_MIB_RX_ALIGNMENT_ERRORS 0x74 /* 32b: RxAlignmentErrors*/
+#define ROBO_MIB_RX_FCS_ERRORS 0x78 /* 32b: RxFCSErrors */
+#define ROBO_MIB_RX_GOOD_OCTETS 0x7c /* 32b: RxGoodOctets */
+#define ROBO_MIB_RX_DROP_PKTS 0x84 /* 32b: RxDropPkts */
+#define ROBO_MIB_RX_UC_PKTS 0x88 /* 32b: RxUnicastPkts */
+#define ROBO_MIB_RX_MC_PKTS 0x8c /* 32b: RxMulticastPkts */
+#define ROBO_MIB_RX_BC_PKTS 0x90 /* 32b: RxBroadcastPkts */
+#define ROBO_MIB_RX_SA_CHANGES 0x94 /* 32b: RxSAChanges */
+#define ROBO_MIB_RX_FRAGMENTS 0x98 /* 32b: RxFragments */
+#define ROBO_MIB_RX_EXCESS_SZ_DISC 0x9c /* 32b: RxExcessSizeDisc*/
+#define ROBO_MIB_RX_SYMBOL_ERROR 0xa0 /* 32b: RxSymbolError */
+
+/* BCM5350 MIB Statistics */
+/* Group 0 */
+#define ROBO_MIB_TX_GOOD_PKTS 0x00 /* 16b: TxGoodPkts */
+#define ROBO_MIB_TX_UNICAST_PKTS 0x02 /* 16b: TxUnicastPkts */
+#define ROBO_MIB_RX_GOOD_PKTS 0x04 /* 16b: RxGoodPkts */
+#define ROBO_MIB_RX_GOOD_UNICAST_PKTS 0x06 /* 16b: RxGoodUnicastPkts */
+/* Group 1 */
+#define ROBO_MIB_TX_COLLISION 0x00 /* 16b: TxCollision */
+#define ROBO_MIB_TX_OCTETS_5350 0x02 /* 16b: TxOctets */
+#define ROBO_MIB_RX_FCS_ERRORS_5350 0x04 /* 16b: RxFCSErrors */
+#define ROBO_MIB_RX_GOOD_OCTETS_5350 0x06 /* 16b: RxGoodOctets */
+
+/* BCM5325m QoS REGISTERS (Page 0x30) REGISTER MAP: 8/16 */
+#define ROBO_QOS_CTRL 0x00 /* 16b: QoS Control Register */
+#define ROBO_QOS_LOCAL_WEIGHT_CTRL 0x10 /* 8b: Local HQ/LQ Weight Register*/
+#define ROBO_QOS_CPU_WEIGHT_CTRL 0x12 /* 8b: CPU HQ/LQ Weight Register*/
+#define ROBO_QOS_PAUSE_ENA 0x13 /* 16b: Qos Pause Enable Register*/
+#define ROBO_QOS_PRIO_THRESHOLD 0x15 /* 8b: Priority Threshold Register*/
+#define ROBO_QOS_RESERVED 0x16 /* 8b: Qos Reserved Register */
+
+/* BCM5325m VLAN REGISTERS (Page 0x34) REGISTER MAP: 8/16bit */
+typedef struct _ROBO_VLAN_CTRL0_STRUC
+{
+ unsigned char frameControlP:2; /* 802.1P frame control */
+ unsigned char frameControlQ:2; /* 802.1Q frame control */
+ unsigned char dropMissedVID:1; /* enable drop missed VID packet */
+ unsigned char vidMacHash:1; /* VID_MAC hash enable */
+ unsigned char vidMacCheck:1; /* VID_MAC check enable */
+ unsigned char VLANen:1; /* 802.1Q VLAN enable */
+} ROBO_VLAN_CTRL0_STRUC;
+#define VLAN_TABLE_WRITE 1 /* for read/write state in table access reg */
+#define VLAN_TABLE_READ 0 /* for read/write state in table access reg */
+#define VLAN_ID_HIGH_BITS 0 /* static high bits in table access reg */
+#define VLAN_ID_MAX 255 /* max VLAN id */
+#define VLAN_ID_MAX5350 15 /* max VLAN id (5350) */
+#define VLAN_ID_MASK VLAN_ID_MAX /* VLAN id mask */
+#ifdef BCM5380
+#define VLAN_UNTAG_SHIFT 13 /* for postioning untag bits in write reg */
+#define VLAN_VALID 0x4000000 /* valid bit in write reg */
+#else
+#define VLAN_UNTAG_SHIFT 7 /* for postioning untag bits in write reg */
+#define VLAN_VALID 0x4000 /* valid bit in write reg */
+/* corresponding values for 5350 */
+#define VLAN_UNTAG_SHIFT_5350 6 /* for postioning untag bits in write reg */
+#define VLAN_VALID_5350 0x00100000 /* valid bit in write reg */
+#endif
+typedef struct _ROBO_VLAN_TABLE_ACCESS_STRUC
+{
+ unsigned char VLANid:8; /* VLAN ID (low 8 bits) */
+ unsigned char VLANidHi:4; /* VLAN ID (fixed upper portion) */
+ unsigned char readWriteState:1; /* read/write state (write = 1) */
+ volatile unsigned char readWriteEnable:1; /* table read/write enable */
+ unsigned char rsvd:2; /* reserved */
+} ROBO_VLAN_TABLE_ACCESS_STRUC;
+#ifdef BCM5380
+typedef struct _ROBO_VLAN_READ_WRITE_STRUC
+{
+ unsigned int VLANgroup:13;/* VLAN group mask */
+ unsigned int VLANuntag:13;/* VLAN untag enable mask */
+ unsigned char valid:1; /* valid */
+ unsigned char rsvd:5; /* reserved */
+} ROBO_VLAN_READ_WRITE_STRUC;
+#else
+typedef struct _ROBO_VLAN_READ_WRITE_STRUC
+{
+ unsigned char VLANgroup:7; /* VLAN group mask */
+ unsigned char VLANuntag:7; /* VLAN untag enable mask */
+ unsigned char valid:1; /* valid */
+ unsigned char rsvd:1; /* reserved */
+} ROBO_VLAN_READ_WRITE_STRUC;
+typedef struct _ROBO_VLAN_READ_WRITE_STRUC_5350
+{
+ unsigned char VLANgroup:6; /* VLAN group mask */
+ unsigned char VLANuntag:6; /* VLAN untag enable mask */
+ unsigned char highVID:8; /* upper bits of vid */
+ unsigned char valid:1; /* valid */
+ unsigned int rsvd:11; /* reserved */
+} ROBO_VLAN_READ_WRITE_STRUC_5350;
+#endif
+#define ROBO_VLAN_CTRL0 0x00 /* 8b: VLAN Control 0 Register */
+#define ROBO_VLAN_CTRL1 0x01 /* 8b: VLAN Control 1 Register */
+#define ROBO_VLAN_CTRL2 0x02 /* 8b: VLAN Control 2 Register */
+#define ROBO_VLAN_CTRL3 0x03 /* 8b: VLAN Control 3 Register */
+#define ROBO_VLAN_CTRL4 0x04 /* 8b: VLAN Control 4 Register */
+#define ROBO_VLAN_CTRL5 0x05 /* 8b: VLAN Control 5 Register */
+#define ROBO_VLAN_TABLE_ACCESS 0x08 /* 14b: VLAN Table Access Register */
+#define ROBO_VLAN_TABLE_ACCESS_5350 0x06 /* 14b: VLAN Table Access Register (5350) */
+#define ROBO_VLAN_WRITE 0x0a /* 15b: VLAN Write Register */
+#define ROBO_VLAN_WRITE_5350 0x08 /* 15b: VLAN Write Register (5350) */
+#define ROBO_VLAN_READ 0x0c /* 15b: VLAN Read Register */
+#define ROBO_VLAN_PORT0_DEF_TAG 0x10 /* 16b: VLAN Port 0 Default Tag Register */
+#define ROBO_VLAN_PORT1_DEF_TAG 0x12 /* 16b: VLAN Port 1 Default Tag Register */
+#define ROBO_VLAN_PORT2_DEF_TAG 0x14 /* 16b: VLAN Port 2 Default Tag Register */
+#define ROBO_VLAN_PORT3_DEF_TAG 0x16 /* 16b: VLAN Port 3 Default Tag Register */
+#define ROBO_VLAN_PORT4_DEF_TAG 0x18 /* 16b: VLAN Port 4 Default Tag Register */
+#define ROBO_VLAN_PORTMII_DEF_TAG 0x1a /* 16b: VLAN Port MII Default Tag Register */
+/* 5380 only */
+#define ROBO_VLAN_PORT5_DEF_TAG 0x1a /* 16b: VLAN Port 5 Default Tag Register */
+#define ROBO_VLAN_PORT6_DEF_TAG 0x1c /* 16b: VLAN Port 6 Default Tag Register */
+#define ROBO_VLAN_PORT7_DEF_TAG 0x1e /* 16b: VLAN Port 7 Default Tag Register */
+
+/* obsolete */
+#define ROBO_VLAN_PORT0_CTRL 0x00 /* 16b: Port 0 VLAN Register */
+#define ROBO_VLAN_PORT1_CTRL 0x02 /* 16b: Port 1 VLAN Register */
+#define ROBO_VLAN_PORT2_CTRL 0x04 /* 16b: Port 2 VLAN Register */
+#define ROBO_VLAN_PORT3_CTRL 0x06 /* 16b: Port 3 VLAN Register */
+#define ROBO_VLAN_PORT4_CTRL 0x08 /* 16b: Port 4 VLAN Register */
+#define ROBO_VLAN_IM_PORT_CTRL 0x10 /* 16b: Inverse MII Port VLAN Reg */
+#define ROBO_VLAN_SMP_PORT_CTRL 0x12 /* 16b: Serial Port VLAN Register */
+#define ROBO_VLAN_PORTSPI_DEF_TAG 0x1c /* 16b: VLAN Port SPI Default Tag Register */
+#define ROBO_VLAN_PRIORITY_REMAP 0x20 /* 24b: VLAN Priority Re-Map Register */
+
+#ifndef _CFE_
+#pragma pack()
+#endif
+
+
+#endif /* !__BCM535M_H_ */
+
+
+
+
+
diff --git a/package/system/utils/robocfg/src/robocfg.c b/package/system/utils/robocfg/src/robocfg.c
new file mode 100644
index 0000000..7a4094d
--- /dev/null
+++ b/package/system/utils/robocfg/src/robocfg.c
@@ -0,0 +1,581 @@
+/*
+ * Broadcom BCM5325E/536x switch configuration utility
+ *
+ * Copyright (C) 2005 Oleg I. Vdovikin
+ *
+ * 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
+ * of the License, 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; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/param.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+
+/* linux stuff */
+typedef u_int64_t u64;
+typedef u_int32_t u32;
+typedef u_int16_t u16;
+typedef u_int8_t u8;
+
+#include <linux/if.h>
+#include <linux/sockios.h>
+#include <linux/ethtool.h>
+#include <linux/mii.h>
+
+#include "etc53xx.h"
+#define ROBO_PHY_ADDR 0x1E /* robo switch phy address */
+
+/* MII registers */
+#define REG_MII_PAGE 0x10 /* MII Page register */
+#define REG_MII_ADDR 0x11 /* MII Address register */
+#define REG_MII_DATA0 0x18 /* MII Data register 0 */
+
+#define REG_MII_PAGE_ENABLE 1
+#define REG_MII_ADDR_WRITE 1
+#define REG_MII_ADDR_READ 2
+
+/* Private et.o ioctls */
+#define SIOCGETCPHYRD (SIOCDEVPRIVATE + 9)
+#define SIOCSETCPHYWR (SIOCDEVPRIVATE + 10)
+
+typedef struct {
+ struct ifreq ifr;
+ int fd;
+ int et; /* use private ioctls */
+} robo_t;
+
+static u16 mdio_read(robo_t *robo, u16 phy_id, u8 reg)
+{
+ if (robo->et) {
+ int args[2] = { reg };
+
+ if (phy_id != ROBO_PHY_ADDR) {
+ fprintf(stderr,
+ "Access to real 'phy' registers unavaliable.\n"
+ "Upgrade kernel driver.\n");
+
+ return 0xffff;
+ }
+
+ robo->ifr.ifr_data = (caddr_t) args;
+ if (ioctl(robo->fd, SIOCGETCPHYRD, (caddr_t)&robo->ifr) < 0) {
+ perror("SIOCGETCPHYRD");
+ exit(1);
+ }
+
+ return args[1];
+ } else {
+ struct mii_ioctl_data *mii = (struct mii_ioctl_data *)&robo->ifr.ifr_data;
+ mii->phy_id = phy_id;
+ mii->reg_num = reg;
+ if (ioctl(robo->fd, SIOCGMIIREG, &robo->ifr) < 0) {
+ perror("SIOCGMIIREG");
+ exit(1);
+ }
+ return mii->val_out;
+ }
+}
+
+static void mdio_write(robo_t *robo, u16 phy_id, u8 reg, u16 val)
+{
+ if (robo->et) {
+ int args[2] = { reg, val };
+
+ if (phy_id != ROBO_PHY_ADDR) {
+ fprintf(stderr,
+ "Access to real 'phy' registers unavaliable.\n"
+ "Upgrade kernel driver.\n");
+ return;
+ }
+
+ robo->ifr.ifr_data = (caddr_t) args;
+ if (ioctl(robo->fd, SIOCSETCPHYWR, (caddr_t)&robo->ifr) < 0) {
+ perror("SIOCGETCPHYWR");
+ exit(1);
+ }
+ } else {
+ struct mii_ioctl_data *mii = (struct mii_ioctl_data *)&robo->ifr.ifr_data;
+ mii->phy_id = phy_id;
+ mii->reg_num = reg;
+ mii->val_in = val;
+ if (ioctl(robo->fd, SIOCSMIIREG, &robo->ifr) < 0) {
+ perror("SIOCSMIIREG");
+ exit(1);
+ }
+ }
+}
+
+static int robo_reg(robo_t *robo, u8 page, u8 reg, u8 op)
+{
+ int i = 3;
+
+ /* set page number */
+ mdio_write(robo, ROBO_PHY_ADDR, REG_MII_PAGE,
+ (page << 8) | REG_MII_PAGE_ENABLE);
+
+ /* set register address */
+ mdio_write(robo, ROBO_PHY_ADDR, REG_MII_ADDR,
+ (reg << 8) | op);
+
+ /* check if operation completed */
+ while (i--) {
+ if ((mdio_read(robo, ROBO_PHY_ADDR, REG_MII_ADDR) & 3) == 0)
+ return 0;
+ }
+
+ fprintf(stderr, "robo_reg: timeout\n");
+ exit(1);
+
+ return 0;
+}
+
+static void robo_read(robo_t *robo, u8 page, u8 reg, u16 *val, int count)
+{
+ int i;
+
+ robo_reg(robo, page, reg, REG_MII_ADDR_READ);
+
+ for (i = 0; i < count; i++)
+ val[i] = mdio_read(robo, ROBO_PHY_ADDR, REG_MII_DATA0 + i);
+}
+
+static u16 robo_read16(robo_t *robo, u8 page, u8 reg)
+{
+ robo_reg(robo, page, reg, REG_MII_ADDR_READ);
+
+ return mdio_read(robo, ROBO_PHY_ADDR, REG_MII_DATA0);
+}
+
+static u32 robo_read32(robo_t *robo, u8 page, u8 reg)
+{
+ robo_reg(robo, page, reg, REG_MII_ADDR_READ);
+
+ return mdio_read(robo, ROBO_PHY_ADDR, REG_MII_DATA0) +
+ (mdio_read(robo, ROBO_PHY_ADDR, REG_MII_DATA0 + 1) << 16);
+}
+
+static void robo_write16(robo_t *robo, u8 page, u8 reg, u16 val16)
+{
+ /* write data */
+ mdio_write(robo, ROBO_PHY_ADDR, REG_MII_DATA0, val16);
+
+ robo_reg(robo, page, reg, REG_MII_ADDR_WRITE);
+}
+
+static void robo_write32(robo_t *robo, u8 page, u8 reg, u32 val32)
+{
+ /* write data */
+ mdio_write(robo, ROBO_PHY_ADDR, REG_MII_DATA0, val32 & 65535);
+ mdio_write(robo, ROBO_PHY_ADDR, REG_MII_DATA0 + 1, val32 >> 16);
+
+ robo_reg(robo, page, reg, REG_MII_ADDR_WRITE);
+}
+
+/* checks that attached switch is 5325E/5350 */
+static int robo_vlan5350(robo_t *robo)
+{
+ /* set vlan access id to 15 and read it back */
+ u16 val16 = 15;
+ robo_write16(robo, ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS_5350, val16);
+
+ /* 5365 will refuse this as it does not have this reg */
+ return (robo_read16(robo, ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS_5350) == val16);
+}
+
+u8 port[6] = { 0, 1, 2, 3, 4, 8 };
+char ports[6] = { 'W', '4', '3', '2', '1', 'C' };
+char *rxtx[4] = { "enabled", "rx_disabled", "tx_disabled", "disabled" };
+char *stp[8] = { "none", "disable", "block", "listen", "learn", "forward", "6", "7" };
+
+struct {
+ char *name;
+ u16 bmcr;
+} media[5] = { { "auto", BMCR_ANENABLE | BMCR_ANRESTART },
+ { "10HD", 0 }, { "10FD", BMCR_FULLDPLX },
+ { "100HD", BMCR_SPEED100 }, { "100FD", BMCR_SPEED100 | BMCR_FULLDPLX } };
+
+struct {
+ char *name;
+ u16 value;
+} mdix[3] = { { "auto", 0x0000 }, { "on", 0x1800 }, { "off", 0x0800 } };
+
+void usage()
+{
+ fprintf(stderr, "Broadcom BCM5325E/536x switch configuration utility\n"
+ "Copyright (C) 2005 Oleg I. Vdovikin\n\n"
+ "This program is distributed in the hope that it will be useful,\n"
+ "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
+ "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
+ "GNU General Public License for more details.\n\n");
+
+ fprintf(stderr, "Usage: robocfg <op> ... <op>\n"
+ "Operations are as below:\n"
+ "\tshow\n"
+ "\tswitch <enable|disable>\n"
+ "\tport <port_number> [state <%s|%s|%s|%s>]\n\t\t[stp %s|%s|%s|%s|%s|%s] [tag <vlan_tag>]\n"
+ "\t\t[media %s|%s|%s|%s|%s] [mdi-x %s|%s|%s]\n"
+ "\tvlan <vlan_number> [ports <ports_list>]\n"
+ "\tvlans <enable|disable|reset>\n\n"
+ "\tports_list should be one argument, space separated, quoted if needed,\n"
+ "\tport number could be followed by 't' to leave packet vlan tagged (CPU \n"
+ "\tport default) or by 'u' to untag packet (other ports default) before \n"
+ "\tbringing it to the port, '*' is ignored\n"
+ "\nSamples:\n"
+ "1) ASUS WL-500g Deluxe stock config (eth0 is WAN, eth0.1 is LAN):\n"
+ "robocfg switch disable vlans enable reset vlan 0 ports \"0 5u\" vlan 1 ports \"1 2 3 4 5t\""
+ " port 0 state enabled stp none switch enable\n"
+ "2) WRT54g, WL-500g Deluxe OpenWRT config (vlan0 is LAN, vlan1 is WAN):\n"
+ "robocfg switch disable vlans enable reset vlan 0 ports \"1 2 3 4 5t\" vlan 1 ports \"0 5t\""
+ " port 0 state enabled stp none switch enable\n",
+ rxtx[0], rxtx[1], rxtx[2], rxtx[3], stp[0], stp[1], stp[2], stp[3], stp[4], stp[5],
+ media[0].name, media[1].name, media[2].name, media[3].name, media[4].name,
+ mdix[0].name, mdix[1].name, mdix[2].name);
+}
+
+static robo_t robo;
+int bcm53xx_probe(const char *dev)
+{
+ struct ethtool_drvinfo info;
+ unsigned int phyid;
+ int ret;
+
+ fprintf(stderr, "probing %s\n", dev);
+
+ strcpy(robo.ifr.ifr_name, dev);
+ memset(&info, 0, sizeof(info));
+ info.cmd = ETHTOOL_GDRVINFO;
+ robo.ifr.ifr_data = (caddr_t)&info;
+ ret = ioctl(robo.fd, SIOCETHTOOL, (caddr_t)&robo.ifr);
+ if (ret < 0) {
+ perror("SIOCETHTOOL");
+ return ret;
+ }
+
+ if ( strcmp(info.driver, "et0") &&
+ strcmp(info.driver, "b44") &&
+ strcmp(info.driver, "bcm63xx_enet") ) {
+ fprintf(stderr, "driver not supported %s\n", info.driver);
+ return -ENOSYS;
+ }
+
+ /* try access using MII ioctls - get phy address */
+ robo.et = 0;
+ if (ioctl(robo.fd, SIOCGMIIPHY, &robo.ifr) < 0)
+ robo.et = 1;
+
+ if (robo.et) {
+ unsigned int args[2] = { 2 };
+
+ robo.ifr.ifr_data = (caddr_t) args;
+ ret = ioctl(robo.fd, SIOCGETCPHYRD, (caddr_t)&robo.ifr);
+ if (ret < 0) {
+ perror("SIOCGETCPHYRD");
+ return ret;
+ }
+ phyid = args[1] & 0xffff;
+
+ args[0] = 3;
+ robo.ifr.ifr_data = (caddr_t) args;
+ ret = ioctl(robo.fd, SIOCGETCPHYRD, (caddr_t)&robo.ifr);
+ if (ret < 0) {
+ perror("SIOCGETCPHYRD");
+ return ret;
+ }
+ phyid |= args[1] << 16;
+ } else {
+ struct mii_ioctl_data *mii = (struct mii_ioctl_data *)&robo.ifr.ifr_data;
+ mii->phy_id = ROBO_PHY_ADDR;
+ mii->reg_num = 2;
+ ret = ioctl(robo.fd, SIOCGMIIREG, &robo.ifr);
+ if (ret < 0) {
+ perror("SIOCGMIIREG");
+ return ret;
+ }
+ phyid = mii->val_out & 0xffff;
+
+ mii->phy_id = ROBO_PHY_ADDR;
+ mii->reg_num = 3;
+ ret = ioctl(robo.fd, SIOCGMIIREG, &robo.ifr);
+ if (ret < 0) {
+ perror("SIOCGMIIREG");
+ return ret;
+ }
+ phyid |= mii->val_out << 16;
+ }
+
+ if (phyid == 0xffffffff || phyid == 0x55210022) {
+ perror("phyid");
+ return -EIO;
+ }
+
+ return 0;
+}
+
+int
+main(int argc, char *argv[])
+{
+ u16 val16;
+ u16 mac[3];
+ int i = 0, j;
+ int robo5350 = 0;
+ u32 phyid;
+
+ if ((robo.fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
+ perror("socket");
+ exit(1);
+ }
+
+ if (bcm53xx_probe("eth1")) {
+ if (bcm53xx_probe("eth0")) {
+ perror("bcm53xx_probe");
+ exit(1);
+ }
+ }
+
+ robo5350 = robo_vlan5350(&robo);
+
+ for (i = 1; i < argc;) {
+ if (strcasecmp(argv[i], "port") == 0 && (i + 1) < argc)
+ {
+ int index = atoi(argv[++i]);
+ /* read port specs */
+ while (++i < argc) {
+ if (strcasecmp(argv[i], "state") == 0 && ++i < argc) {
+ for (j = 0; j < 4 && strcasecmp(argv[i], rxtx[j]); j++);
+ if (j < 4) {
+ /* change state */
+ robo_write16(&robo,ROBO_CTRL_PAGE, port[index],
+ (robo_read16(&robo, ROBO_CTRL_PAGE, port[index]) & ~(3 << 0)) | (j << 0));
+ } else {
+ fprintf(stderr, "Invalid state '%s'.\n", argv[i]);
+ exit(1);
+ }
+ } else
+ if (strcasecmp(argv[i], "stp") == 0 && ++i < argc) {
+ for (j = 0; j < 8 && strcasecmp(argv[i], stp[j]); j++);
+ if (j < 8) {
+ /* change stp */
+ robo_write16(&robo,ROBO_CTRL_PAGE, port[index],
+ (robo_read16(&robo, ROBO_CTRL_PAGE, port[index]) & ~(7 << 5)) | (j << 5));
+ } else {
+ fprintf(stderr, "Invalid stp '%s'.\n", argv[i]);
+ exit(1);
+ }
+ } else
+ if (strcasecmp(argv[i], "media") == 0 && ++i < argc) {
+ for (j = 0; j < 5 && strcasecmp(argv[i], media[j].name); j++);
+ if (j < 5) {
+ mdio_write(&robo, port[index], MII_BMCR, media[j].bmcr);
+ } else {
+ fprintf(stderr, "Invalid media '%s'.\n", argv[i]);
+ exit(1);
+ }
+ } else
+ if (strcasecmp(argv[i], "mdi-x") == 0 && ++i < argc) {
+ for (j = 0; j < 3 && strcasecmp(argv[i], mdix[j].name); j++);
+ if (j < 3) {
+ mdio_write(&robo, port[index], 0x1c, mdix[j].value |
+ (mdio_read(&robo, port[index], 0x1c) & ~0x1800));
+ } else {
+ fprintf(stderr, "Invalid mdi-x '%s'.\n", argv[i]);
+ exit(1);
+ }
+ } else
+ if (strcasecmp(argv[i], "tag") == 0 && ++i < argc) {
+ j = atoi(argv[i]);
+ /* change vlan tag */
+ robo_write16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_PORT0_DEF_TAG + (index << 1), j);
+ } else break;
+ }
+ } else
+ if (strcasecmp(argv[i], "vlan") == 0 && (i + 1) < argc)
+ {
+ int index = atoi(argv[++i]);
+ while (++i < argc) {
+ if (strcasecmp(argv[i], "ports") == 0 && ++i < argc) {
+ char *ports = argv[i];
+ int untag = 0;
+ int member = 0;
+
+ while (*ports >= '0' && *ports <= '9') {
+ j = *ports++ - '0';
+ member |= 1 << j;
+
+ /* untag if needed, CPU port requires special handling */
+ if (*ports == 'u' || (j != 5 && (*ports == ' ' || *ports == 0)))
+ {
+ untag |= 1 << j;
+ if (*ports) ports++;
+ /* change default vlan tag */
+ robo_write16(&robo, ROBO_VLAN_PAGE,
+ ROBO_VLAN_PORT0_DEF_TAG + (j << 1), index);
+ } else
+ if (*ports == '*' || *ports == 't' || *ports == ' ') ports++;
+ else break;
+
+ while (*ports == ' ') ports++;
+ }
+
+ if (*ports) {
+ fprintf(stderr, "Invalid ports '%s'.\n", argv[i]);
+ exit(1);
+ } else {
+ /* write config now */
+ val16 = (index) /* vlan */ | (1 << 12) /* write */ | (1 << 13) /* enable */;
+ if (robo5350) {
+ robo_write32(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_WRITE_5350,
+ (1 << 20) /* valid */ | (untag << 6) | member);
+ robo_write16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS_5350, val16);
+ } else {
+ robo_write16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_WRITE,
+ (1 << 14) /* valid */ | (untag << 7) | member);
+ robo_write16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS, val16);
+ }
+ }
+ } else break;
+ }
+ } else
+ if (strcasecmp(argv[i], "switch") == 0 && (i + 1) < argc)
+ {
+ /* enable/disable switching */
+ robo_write16(&robo, ROBO_CTRL_PAGE, ROBO_SWITCH_MODE,
+ (robo_read16(&robo, ROBO_CTRL_PAGE, ROBO_SWITCH_MODE) & ~2) |
+ (*argv[++i] == 'e' ? 2 : 0));
+ i++;
+ } else
+ if (strcasecmp(argv[i], "vlans") == 0 && (i + 1) < argc)
+ {
+ while (++i < argc) {
+ if (strcasecmp(argv[i], "reset") == 0) {
+ /* reset vlan validity bit */
+ for (j = 0; j <= (robo5350 ? VLAN_ID_MAX5350 : VLAN_ID_MAX); j++)
+ {
+ /* write config now */
+ val16 = (j) /* vlan */ | (1 << 12) /* write */ | (1 << 13) /* enable */;
+ if (robo5350) {
+ robo_write32(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_WRITE_5350, 0);
+ robo_write16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS_5350, val16);
+ } else {
+ robo_write16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_WRITE, 0);
+ robo_write16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS, val16);
+ }
+ }
+ } else
+ if (strcasecmp(argv[i], "enable") == 0 || strcasecmp(argv[i], "disable") == 0)
+ {
+ int disable = (*argv[i] == 'd') || (*argv[i] == 'D');
+ /* enable/disable vlans */
+ robo_write16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_CTRL0, disable ? 0 :
+ (1 << 7) /* 802.1Q VLAN */ | (3 << 5) /* mac check and hash */);
+
+ robo_write16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_CTRL1, disable ? 0 :
+ (1 << 1) | (1 << 2) | (1 << 3) /* RSV multicast */);
+
+ robo_write16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_CTRL4, disable ? 0 :
+ (1 << 6) /* drop invalid VID frames */);
+
+ robo_write16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_CTRL5, disable ? 0 :
+ (1 << 3) /* drop miss V table frames */);
+
+ } else break;
+ }
+ } else
+ if (strcasecmp(argv[i], "show") == 0)
+ {
+ break;
+ } else {
+ fprintf(stderr, "Invalid option %s\n", argv[i]);
+ usage();
+ exit(1);
+ }
+ }
+
+ if (i == argc) {
+ if (argc == 1) usage();
+ return 0;
+ }
+
+ /* show config */
+
+ printf("Switch: %sabled\n", robo_read16(&robo, ROBO_CTRL_PAGE, ROBO_SWITCH_MODE) & 2 ? "en" : "dis");
+
+ for (i = 0; i < 6; i++) {
+ printf(robo_read16(&robo, ROBO_STAT_PAGE, ROBO_LINK_STAT_SUMMARY) & (1 << port[i]) ?
+ "Port %d(%c): %s%s " : "Port %d(%c): DOWN ", i, ports[i],
+ robo_read16(&robo, ROBO_STAT_PAGE, ROBO_SPEED_STAT_SUMMARY) & (1 << port[i]) ? "100" : " 10",
+ robo_read16(&robo, ROBO_STAT_PAGE, ROBO_DUPLEX_STAT_SUMMARY) & (1 << port[i]) ? "FD" : "HD");
+
+ val16 = robo_read16(&robo, ROBO_CTRL_PAGE, port[i]);
+
+ printf("%s stp: %s vlan: %d ", rxtx[val16 & 3], stp[(val16 >> 5) & 7],
+ robo_read16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_PORT0_DEF_TAG + (i << 1)));
+
+ robo_read(&robo, ROBO_STAT_PAGE, ROBO_LSA_PORT0 + port[i] * 6, mac, 3);
+
+ printf("mac: %02x:%02x:%02x:%02x:%02x:%02x\n",
+ mac[2] >> 8, mac[2] & 255, mac[1] >> 8, mac[1] & 255, mac[0] >> 8, mac[0] & 255);
+ }
+
+ val16 = robo_read16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_CTRL0);
+
+ printf("VLANs: %s %sabled%s%s\n",
+ robo5350 ? "BCM5325/535x" : "BCM536x",
+ (val16 & (1 << 7)) ? "en" : "dis",
+ (val16 & (1 << 6)) ? " mac_check" : "",
+ (val16 & (1 << 5)) ? " mac_hash" : "");
+
+ /* scan VLANs */
+ for (i = 0; i <= (robo5350 ? VLAN_ID_MAX5350 : VLAN_ID_MAX); i++) {
+ /* issue read */
+ val16 = (i) /* vlan */ | (0 << 12) /* read */ | (1 << 13) /* enable */;
+
+ if (robo5350) {
+ u32 val32;
+ robo_write16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS_5350, val16);
+ /* actual read */
+ val32 = robo_read32(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_READ);
+ if ((val32 & (1 << 20)) /* valid */) {
+ printf("vlan%d:", i);
+ for (j = 0; j < 6; j++) {
+ if (val32 & (1 << j)) {
+ printf(" %d%s", j, (val32 & (1 << (j + 6))) ?
+ (j == 5 ? "u" : "") : "t");
+ }
+ }
+ printf("\n");
+ }
+ } else {
+ robo_write16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS, val16);
+ /* actual read */
+ val16 = robo_read16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_READ);
+ if ((val16 & (1 << 14)) /* valid */) {
+ printf("vlan%d:", i);
+ for (j = 0; j < 6; j++) {
+ if (val16 & (1 << j)) {
+ printf(" %d%s", j, (val16 & (1 << (j + 7))) ?
+ (j == 5 ? "u" : "") : "t");
+ }
+ }
+ printf("\n");
+ }
+ }
+ }
+
+ return (0);
+}
diff --git a/package/system/utils/usb-modeswitch/.svn/entries b/package/system/utils/usb-modeswitch/.svn/entries
new file mode 100644
index 0000000..e3010d2
--- /dev/null
+++ b/package/system/utils/usb-modeswitch/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/system/utils/usb-modeswitch
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-29T12:27:17.572122Z
+35381
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+files
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+56a0a31781f5f099ee19aa50821746c8
+2013-01-29T12:27:17.572122Z
+35381
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2306
+
diff --git a/package/system/utils/usb-modeswitch/.svn/text-base/Makefile.svn-base b/package/system/utils/usb-modeswitch/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..d82a83c
--- /dev/null
+++ b/package/system/utils/usb-modeswitch/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,82 @@
+#
+# Copyright (C) 2008-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=usb-modeswitch
+PKG_VERSION:=1.2.5
+PKG_DATA_VERSION:=20121109
+PKG_RELEASE:=1
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=http://www.draisberghof.de/usb_modeswitch
+PKG_MD5SUM:=c393603908eceab95444c5bde790f6f0
+
+PKG_DATA_PATH:=usb-modeswitch-data-$(PKG_DATA_VERSION)
+PKG_DATA_FILENAME:=$(PKG_DATA_PATH).tar.bz2
+
+PKG_MAINTAINER := Felix Fietkau <nbd@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/usb-modeswitch
+ SECTION:=utils
+ CATEGORY:=Utilities
+ DEPENDS:=+libusb-compat
+ TITLE:=USB ModeSwitch
+ URL:=http://www.draisberghof.de/usb_modeswitch/
+endef
+
+define Package/usb-modeswitch/description
+ A mode switching tool for controlling
+ "flip flop" (multiple device) USB gear.
+endef
+
+define Package/usb-modeswitch-data
+ SECTION:=utils
+ CATEGORY:=Utilities
+ DEPENDS:=usb-modeswitch
+ VERSION:=$(PKG_DATA_VERSION)
+ TITLE:=USB ModeSwitch - Dongle configuration database
+ URL:=http://www.draisberghof.de/usb_modeswitch/
+endef
+
+define Package/usb-modeswitch-data/description
+ Configuration database for usb-modeswitch.
+ Contains definitions for many USB devices required to
+ autoswitch "flip flop" gear.
+endef
+
+define Download/data
+ FILE:=$(PKG_DATA_FILENAME)
+ URL:=$(PKG_SOURCE_URL)
+ MD5SUM:=a7d23a03157871013a0d708ab2b1b6df
+endef
+$(eval $(call Download,data))
+
+define Build/Compile
+ tar xvfj $(DL_DIR)/$(PKG_DATA_FILENAME) -C $(PKG_BUILD_DIR)
+ $(TARGET_CC) $(TARGET_CFLAGS) $(TARGET_CPPFLAGS) $(TARGET_LDFLAGS) \
+ -lusb \
+ -o $(PKG_BUILD_DIR)/usb_modeswitch-OpenWrt \
+ $(PKG_BUILD_DIR)/usb_modeswitch.c
+endef
+
+define Package/usb-modeswitch/install
+ $(INSTALL_DIR) $(1)/usr/bin $(1)/etc/hotplug.d/usb
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/usb_modeswitch-OpenWrt $(1)/usr/bin/usb_modeswitch
+ $(INSTALL_DATA) ./files/modeswitch.hotplug $(1)/etc/hotplug.d/usb/20-modeswitch
+endef
+
+define Package/usb-modeswitch-data/install
+ $(INSTALL_DIR) $(1)/etc
+ $(CP) $(PKG_BUILD_DIR)/$(PKG_DATA_PATH)/usb_modeswitch.d $(1)/etc/
+endef
+
+$(eval $(call BuildPackage,usb-modeswitch))
+$(eval $(call BuildPackage,usb-modeswitch-data))
diff --git a/package/system/utils/usb-modeswitch/Makefile b/package/system/utils/usb-modeswitch/Makefile
new file mode 100644
index 0000000..d82a83c
--- /dev/null
+++ b/package/system/utils/usb-modeswitch/Makefile
@@ -0,0 +1,82 @@
+#
+# Copyright (C) 2008-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=usb-modeswitch
+PKG_VERSION:=1.2.5
+PKG_DATA_VERSION:=20121109
+PKG_RELEASE:=1
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=http://www.draisberghof.de/usb_modeswitch
+PKG_MD5SUM:=c393603908eceab95444c5bde790f6f0
+
+PKG_DATA_PATH:=usb-modeswitch-data-$(PKG_DATA_VERSION)
+PKG_DATA_FILENAME:=$(PKG_DATA_PATH).tar.bz2
+
+PKG_MAINTAINER := Felix Fietkau <nbd@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/usb-modeswitch
+ SECTION:=utils
+ CATEGORY:=Utilities
+ DEPENDS:=+libusb-compat
+ TITLE:=USB ModeSwitch
+ URL:=http://www.draisberghof.de/usb_modeswitch/
+endef
+
+define Package/usb-modeswitch/description
+ A mode switching tool for controlling
+ "flip flop" (multiple device) USB gear.
+endef
+
+define Package/usb-modeswitch-data
+ SECTION:=utils
+ CATEGORY:=Utilities
+ DEPENDS:=usb-modeswitch
+ VERSION:=$(PKG_DATA_VERSION)
+ TITLE:=USB ModeSwitch - Dongle configuration database
+ URL:=http://www.draisberghof.de/usb_modeswitch/
+endef
+
+define Package/usb-modeswitch-data/description
+ Configuration database for usb-modeswitch.
+ Contains definitions for many USB devices required to
+ autoswitch "flip flop" gear.
+endef
+
+define Download/data
+ FILE:=$(PKG_DATA_FILENAME)
+ URL:=$(PKG_SOURCE_URL)
+ MD5SUM:=a7d23a03157871013a0d708ab2b1b6df
+endef
+$(eval $(call Download,data))
+
+define Build/Compile
+ tar xvfj $(DL_DIR)/$(PKG_DATA_FILENAME) -C $(PKG_BUILD_DIR)
+ $(TARGET_CC) $(TARGET_CFLAGS) $(TARGET_CPPFLAGS) $(TARGET_LDFLAGS) \
+ -lusb \
+ -o $(PKG_BUILD_DIR)/usb_modeswitch-OpenWrt \
+ $(PKG_BUILD_DIR)/usb_modeswitch.c
+endef
+
+define Package/usb-modeswitch/install
+ $(INSTALL_DIR) $(1)/usr/bin $(1)/etc/hotplug.d/usb
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/usb_modeswitch-OpenWrt $(1)/usr/bin/usb_modeswitch
+ $(INSTALL_DATA) ./files/modeswitch.hotplug $(1)/etc/hotplug.d/usb/20-modeswitch
+endef
+
+define Package/usb-modeswitch-data/install
+ $(INSTALL_DIR) $(1)/etc
+ $(CP) $(PKG_BUILD_DIR)/$(PKG_DATA_PATH)/usb_modeswitch.d $(1)/etc/
+endef
+
+$(eval $(call BuildPackage,usb-modeswitch))
+$(eval $(call BuildPackage,usb-modeswitch-data))
diff --git a/package/system/utils/usb-modeswitch/files/.svn/entries b/package/system/utils/usb-modeswitch/files/.svn/entries
new file mode 100644
index 0000000..f809162
--- /dev/null
+++ b/package/system/utils/usb-modeswitch/files/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/system/utils/usb-modeswitch/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-29T12:02:10.199677Z
+35379
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+modeswitch.hotplug
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+b72c264f2a28f8da63f1a7b6621c18a5
+2013-01-29T12:02:10.199677Z
+35379
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3073
+
diff --git a/package/system/utils/usb-modeswitch/files/.svn/text-base/modeswitch.hotplug.svn-base b/package/system/utils/usb-modeswitch/files/.svn/text-base/modeswitch.hotplug.svn-base
new file mode 100644
index 0000000..eb71b30
--- /dev/null
+++ b/package/system/utils/usb-modeswitch/files/.svn/text-base/modeswitch.hotplug.svn-base
@@ -0,0 +1,140 @@
+#!/bin/sh
+
+local uVid uPid uMa uPr uSe
+local sVe sMo sRe
+
+local modeswitch="/usr/bin/usb_modeswitch"
+
+
+log() {
+ logger -t "usb-modeswitch" "$@"
+}
+
+sanitize() {
+ sed -e 's/[[:space:]]\+$//; s/[[:space:]]\+/_/g' "$@"
+}
+
+find_scsi_attrs() {
+ [ -n "$DEVPATH" ] && [ -d /sys/$DEVPATH/host* ] && {
+ log "$DEVICENAME is a SCSI device, waiting for it to settle..."
+ local timeout=20
+ while [ $((--timeout)) -ge 0 ]; do
+ [ -d /sys/$DEVPATH/host*/target* ] && {
+ local scsi_dir
+ for scsi_dir in /sys/$DEVPATH/host*/target*/*; do
+ [ -d "$scsi_dir" ] || break
+ case "$scsi_dir" in
+ */host*/target*/*:*:*:*)
+ sVe=$(sanitize "$scsi_dir/vendor")
+ sMo=$(sanitize "$scsi_dir/model")
+ sRe=$(sanitize "$scsi_dir/rev")
+
+ log "$DEVICENAME: Vendor=${sVe:-?} Model=${sMo:-?} Revision=${sRe:-?}"
+ return 0
+ ;;
+ esac
+ done
+ } || {
+ sleep 1
+ }
+ done
+ log "$DEVICENAME: Failed to get SCSI attributes!"
+ }
+
+ return 1
+}
+
+find_usb_attrs() {
+ local usb_dir="/sys/$DEVPATH"
+ [ -f "$usb_dir/idVendor" ] || usb_dir="${usb_dir%/*}"
+
+ uVid=$(cat "$usb_dir/idVendor")
+ uPid=$(cat "$usb_dir/idProduct")
+ uMa=$(sanitize "$usb_dir/manufacturer")
+ uPr=$(sanitize "$usb_dir/product")
+ uSe=$(sanitize "$usb_dir/serial")
+
+ log "$DEVICENAME: Manufacturer=${uMa:-?} Product=${uPr:-?} Serial=${uSe:-?}"
+}
+
+match_config_tag() {
+ local conf="$1"
+ local tag="$2"
+
+ case "${conf##*/}" in
+ *:*$tag=*)
+ local cmp; eval "cmp=\$$tag"
+ local pat="${conf#*:$tag=}"; pat="${pat%%:*}"
+ case "$cmp" in
+ *$pat*) return 0 ;;
+ *) return 1 ;;
+ esac
+ ;;
+ esac
+
+ return 0
+}
+
+match_config() {
+ local conf="$1"
+ local tag
+
+ for tag in uMa uPr uSe sVe sMo sRe; do
+ match_config_tag "$conf" "$tag" || return 1
+ done
+
+ return 0
+}
+
+
+
+if [ "$ACTION" = add ]; then
+ [ -d "/etc/usb_modeswitch.d" ] && [ -x "$modeswitch" ] && {
+ case "$DEVICENAME" in
+ *-*:*.*) : ;;
+ *) exit 0 ;;
+ esac
+
+ find_usb_attrs
+
+ local candidates=0
+ local conf configs
+ for conf in /etc/usb_modeswitch.d/$uVid:$uPid*; do
+ [ -f "$conf" ] || break
+ configs="${configs:+$configs }$conf"
+ $((candidates++))
+ done
+
+ # Found more than one candidate, read SCSI attributes and find the best match
+ [ $candidates -gt 1 ] && {
+ find_scsi_attrs
+ for conf in $configs; do
+ match_config "$conf" && {
+ configs="$conf"
+ candidates=1
+ break
+ }
+ done
+ }
+
+ # If a candidate is remaining, start usb-modeswitch
+ [ -n "$configs" ] && {
+ log "$DEVICENAME: Selecting ${configs%% *} for mode switching"
+ # ugly workaround, but working for all hw we got for testing
+ switching_done=0
+ switching_tries=0
+ local usb_dir="/sys/$DEVPATH"
+ [ -f "$usb_dir/idVendor" ] || usb_dir="${usb_dir%/*}"
+ while [ $switching_done -lt 1 -a $switching_tries -le 6 ]; do
+ $modeswitch -v $uVid -p $uPid -I -D -n -s 30 -c "${configs%% *}"
+ if [ $(sanitize "$usb_dir/idProduct") = $uPid ]; then
+ log "$DEVICENAME: Switching seemingly failed"
+ sleep 1
+ else
+ switching_done=1
+ fi
+ switching_tries=$(( $switching_tries + 1 ))
+ done
+ }
+ }
+fi
diff --git a/package/system/utils/usb-modeswitch/files/modeswitch.hotplug b/package/system/utils/usb-modeswitch/files/modeswitch.hotplug
new file mode 100644
index 0000000..eb71b30
--- /dev/null
+++ b/package/system/utils/usb-modeswitch/files/modeswitch.hotplug
@@ -0,0 +1,140 @@
+#!/bin/sh
+
+local uVid uPid uMa uPr uSe
+local sVe sMo sRe
+
+local modeswitch="/usr/bin/usb_modeswitch"
+
+
+log() {
+ logger -t "usb-modeswitch" "$@"
+}
+
+sanitize() {
+ sed -e 's/[[:space:]]\+$//; s/[[:space:]]\+/_/g' "$@"
+}
+
+find_scsi_attrs() {
+ [ -n "$DEVPATH" ] && [ -d /sys/$DEVPATH/host* ] && {
+ log "$DEVICENAME is a SCSI device, waiting for it to settle..."
+ local timeout=20
+ while [ $((--timeout)) -ge 0 ]; do
+ [ -d /sys/$DEVPATH/host*/target* ] && {
+ local scsi_dir
+ for scsi_dir in /sys/$DEVPATH/host*/target*/*; do
+ [ -d "$scsi_dir" ] || break
+ case "$scsi_dir" in
+ */host*/target*/*:*:*:*)
+ sVe=$(sanitize "$scsi_dir/vendor")
+ sMo=$(sanitize "$scsi_dir/model")
+ sRe=$(sanitize "$scsi_dir/rev")
+
+ log "$DEVICENAME: Vendor=${sVe:-?} Model=${sMo:-?} Revision=${sRe:-?}"
+ return 0
+ ;;
+ esac
+ done
+ } || {
+ sleep 1
+ }
+ done
+ log "$DEVICENAME: Failed to get SCSI attributes!"
+ }
+
+ return 1
+}
+
+find_usb_attrs() {
+ local usb_dir="/sys/$DEVPATH"
+ [ -f "$usb_dir/idVendor" ] || usb_dir="${usb_dir%/*}"
+
+ uVid=$(cat "$usb_dir/idVendor")
+ uPid=$(cat "$usb_dir/idProduct")
+ uMa=$(sanitize "$usb_dir/manufacturer")
+ uPr=$(sanitize "$usb_dir/product")
+ uSe=$(sanitize "$usb_dir/serial")
+
+ log "$DEVICENAME: Manufacturer=${uMa:-?} Product=${uPr:-?} Serial=${uSe:-?}"
+}
+
+match_config_tag() {
+ local conf="$1"
+ local tag="$2"
+
+ case "${conf##*/}" in
+ *:*$tag=*)
+ local cmp; eval "cmp=\$$tag"
+ local pat="${conf#*:$tag=}"; pat="${pat%%:*}"
+ case "$cmp" in
+ *$pat*) return 0 ;;
+ *) return 1 ;;
+ esac
+ ;;
+ esac
+
+ return 0
+}
+
+match_config() {
+ local conf="$1"
+ local tag
+
+ for tag in uMa uPr uSe sVe sMo sRe; do
+ match_config_tag "$conf" "$tag" || return 1
+ done
+
+ return 0
+}
+
+
+
+if [ "$ACTION" = add ]; then
+ [ -d "/etc/usb_modeswitch.d" ] && [ -x "$modeswitch" ] && {
+ case "$DEVICENAME" in
+ *-*:*.*) : ;;
+ *) exit 0 ;;
+ esac
+
+ find_usb_attrs
+
+ local candidates=0
+ local conf configs
+ for conf in /etc/usb_modeswitch.d/$uVid:$uPid*; do
+ [ -f "$conf" ] || break
+ configs="${configs:+$configs }$conf"
+ $((candidates++))
+ done
+
+ # Found more than one candidate, read SCSI attributes and find the best match
+ [ $candidates -gt 1 ] && {
+ find_scsi_attrs
+ for conf in $configs; do
+ match_config "$conf" && {
+ configs="$conf"
+ candidates=1
+ break
+ }
+ done
+ }
+
+ # If a candidate is remaining, start usb-modeswitch
+ [ -n "$configs" ] && {
+ log "$DEVICENAME: Selecting ${configs%% *} for mode switching"
+ # ugly workaround, but working for all hw we got for testing
+ switching_done=0
+ switching_tries=0
+ local usb_dir="/sys/$DEVPATH"
+ [ -f "$usb_dir/idVendor" ] || usb_dir="${usb_dir%/*}"
+ while [ $switching_done -lt 1 -a $switching_tries -le 6 ]; do
+ $modeswitch -v $uVid -p $uPid -I -D -n -s 30 -c "${configs%% *}"
+ if [ $(sanitize "$usb_dir/idProduct") = $uPid ]; then
+ log "$DEVICENAME: Switching seemingly failed"
+ sleep 1
+ else
+ switching_done=1
+ fi
+ switching_tries=$(( $switching_tries + 1 ))
+ done
+ }
+ }
+fi
diff --git a/package/system/utils/usbreset/.svn/entries b/package/system/utils/usbreset/.svn/entries
new file mode 100644
index 0000000..2e8a39d
--- /dev/null
+++ b/package/system/utils/usbreset/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/system/utils/usbreset
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-29T10:48:46.063504Z
+35375
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+src
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+b79a6eedc148f6b7698065e55db23947
+2013-01-29T10:48:46.063504Z
+35375
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1059
+
diff --git a/package/system/utils/usbreset/.svn/text-base/Makefile.svn-base b/package/system/utils/usbreset/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..75bfd85
--- /dev/null
+++ b/package/system/utils/usbreset/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,44 @@
+#
+# Copyright (C) 2011-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=usbreset
+PKG_RELEASE:=2
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/usbreset
+ SECTION:=utils
+ CATEGORY:=Utilities
+ TITLE:=Utility to send a USB port reset to a USB device
+ MAINTAINER:=Jo-Philipp Wich <xm@subsignal.org>
+endef
+
+define Package/usbreset/description
+ This package contains the small usbreset utility which
+ can be used to send a USB port reset to a USB device -
+ useful for debugging or to force re-detection of particular
+ devices.
+endef
+
+define Build/Prepare
+ $(INSTALL_DIR) $(PKG_BUILD_DIR)
+ $(INSTALL_DATA) ./src/usbreset.c $(PKG_BUILD_DIR)/
+endef
+
+define Build/Compile
+ $(TARGET_CC) $(TARGET_CFLAGS) -Wall \
+ -o $(PKG_BUILD_DIR)/usbreset $(PKG_BUILD_DIR)/usbreset.c
+endef
+
+define Package/usbreset/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/usbreset $(1)/usr/bin/
+endef
+
+$(eval $(call BuildPackage,usbreset))
diff --git a/package/system/utils/usbreset/Makefile b/package/system/utils/usbreset/Makefile
new file mode 100644
index 0000000..75bfd85
--- /dev/null
+++ b/package/system/utils/usbreset/Makefile
@@ -0,0 +1,44 @@
+#
+# Copyright (C) 2011-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=usbreset
+PKG_RELEASE:=2
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/usbreset
+ SECTION:=utils
+ CATEGORY:=Utilities
+ TITLE:=Utility to send a USB port reset to a USB device
+ MAINTAINER:=Jo-Philipp Wich <xm@subsignal.org>
+endef
+
+define Package/usbreset/description
+ This package contains the small usbreset utility which
+ can be used to send a USB port reset to a USB device -
+ useful for debugging or to force re-detection of particular
+ devices.
+endef
+
+define Build/Prepare
+ $(INSTALL_DIR) $(PKG_BUILD_DIR)
+ $(INSTALL_DATA) ./src/usbreset.c $(PKG_BUILD_DIR)/
+endef
+
+define Build/Compile
+ $(TARGET_CC) $(TARGET_CFLAGS) -Wall \
+ -o $(PKG_BUILD_DIR)/usbreset $(PKG_BUILD_DIR)/usbreset.c
+endef
+
+define Package/usbreset/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/usbreset $(1)/usr/bin/
+endef
+
+$(eval $(call BuildPackage,usbreset))
diff --git a/package/system/utils/usbreset/src/.svn/entries b/package/system/utils/usbreset/src/.svn/entries
new file mode 100644
index 0000000..1597827
--- /dev/null
+++ b/package/system/utils/usbreset/src/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/system/utils/usbreset/src
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-29T10:48:46.063504Z
+35375
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+usbreset.c
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+9e2d48df3096e3b2f3c05502404db59e
+2013-01-29T10:48:46.063504Z
+35375
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4890
+
diff --git a/package/system/utils/usbreset/src/.svn/text-base/usbreset.c.svn-base b/package/system/utils/usbreset/src/.svn/text-base/usbreset.c.svn-base
new file mode 100644
index 0000000..087a14c
--- /dev/null
+++ b/package/system/utils/usbreset/src/.svn/text-base/usbreset.c.svn-base
@@ -0,0 +1,253 @@
+/* usbreset -- send a USB port reset to a USB device */
+
+/*
+
+http://marc.info/?l=linux-usb-users&m=116827193506484&w=2
+
+and needs mounted usbfs filesystem
+
+ sudo mount -t usbfs none /proc/bus/usb
+
+There is a way to suspend a USB device. In order to use it,
+you must have a kernel with CONFIG_PM_SYSFS_DEPRECATED turned on. To
+suspend a device, do (as root):
+
+ echo -n 2 >/sys/bus/usb/devices/.../power/state
+
+where the "..." is the ID for your device. To unsuspend, do the same
+thing but with a "0" instead of the "2" above.
+
+Note that this mechanism is slated to be removed from the kernel within
+the next year. Hopefully some other mechanism will take its place.
+
+> To reset a
+> device?
+
+Here's a program to do it. You invoke it as either
+
+ usbreset /proc/bus/usb/BBB/DDD
+or
+ usbreset /dev/usbB.D
+
+depending on how your system is set up, where BBB and DDD are the bus and
+device address numbers.
+
+Alan Stern
+
+*/
+
+#include <stdio.h>
+#include <stdbool.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <string.h>
+#include <sys/ioctl.h>
+
+#include <linux/usbdevice_fs.h>
+
+
+static char *usbfs = NULL;
+
+struct usbentry {
+ int bus_num;
+ int dev_num;
+ int vendor_id;
+ int product_id;
+ char vendor_name[128];
+ char product_name[128];
+};
+
+
+static bool find_usbfs(void)
+{
+ FILE *mtab;
+
+ char buf[1024], type[32];
+ static char path[1024];
+
+ if ((mtab = fopen("/proc/mounts", "r")) != NULL)
+ {
+ while (fgets(buf, sizeof(buf), mtab))
+ {
+ if (sscanf(buf, "%*s %1023s %31s ", path, type) == 2 &&
+ !strncmp(type, "usbfs", 5))
+ {
+ usbfs = path;
+ break;
+ }
+ }
+
+ fclose(mtab);
+ }
+
+ return !!usbfs;
+}
+
+static FILE * open_devlist(void)
+{
+ char buf[1024];
+ snprintf(buf, sizeof(buf), "%s/devices", usbfs);
+ return fopen(buf, "r");
+}
+
+static void close_devlist(FILE *devs)
+{
+ fclose(devs);
+}
+
+static struct usbentry * parse_devlist(FILE *devs)
+{
+ char buf[1024];
+ static struct usbentry dev;
+
+ memset(&dev, 0, sizeof(dev));
+
+ while (fgets(buf, sizeof(buf), devs))
+ {
+ buf[strlen(buf)-1] = 0;
+
+ switch (buf[0])
+ {
+ case 'T':
+ sscanf(buf, "T: Bus=%d Lev=%*d Prnt=%*d Port=%*d Cnt=%*d Dev#=%d",
+ &dev.bus_num, &dev.dev_num);
+ break;
+
+ case 'P':
+ sscanf(buf, "P: Vendor=%x ProdID=%x",
+ &dev.vendor_id, &dev.product_id);
+ break;
+
+ case 'S':
+ if (!strncmp(buf, "S: Manufacturer=", 17))
+ snprintf(dev.vendor_name, sizeof(dev.vendor_name),
+ "%s", buf+17);
+ else if (!strncmp(buf, "S: Product=", 12))
+ snprintf(dev.product_name, sizeof(dev.product_name),
+ "%s", buf+12);
+ break;
+ }
+
+ if (dev.product_name[0])
+ return &dev;
+ }
+
+ return NULL;
+}
+
+static void list_devices(void)
+{
+ FILE *devs = open_devlist();
+ struct usbentry *dev;
+
+ if (!devs)
+ return;
+
+ while ((dev = parse_devlist(devs)) != NULL)
+ {
+ printf(" Number %03d/%03d ID %04x:%04x %s\n",
+ dev->bus_num, dev->dev_num,
+ dev->vendor_id, dev->product_id,
+ dev->product_name);
+ }
+
+ close_devlist(devs);
+}
+
+struct usbentry * find_device(int *bus, int *dev,
+ int *vid, int *pid,
+ const char *product)
+{
+ FILE *devs = open_devlist();
+
+ struct usbentry *e, *match = NULL;
+
+ if (!devs)
+ return NULL;
+
+ while ((e = parse_devlist(devs)) != NULL)
+ {
+ if ((bus && (e->bus_num == *bus) && (e->dev_num == *dev)) ||
+ (vid && (e->vendor_id == *vid) && (e->product_id == *pid)) ||
+ (product && !strcasecmp(e->product_name, product)))
+ {
+ match = e;
+ break;
+ }
+ }
+
+ close_devlist(devs);
+
+ return match;
+}
+
+static void reset_device(struct usbentry *dev)
+{
+ int fd;
+ char path[1024];
+
+ snprintf(path, sizeof(path), "%s/%03d/%03d",
+ usbfs, dev->bus_num, dev->dev_num);
+
+ printf("Resetting %s ... ", dev->product_name);
+
+ if ((fd = open(path, O_WRONLY)) > -1)
+ {
+ if (ioctl(fd, USBDEVFS_RESET, 0) < 0)
+ printf("failed [%s]\n", strerror(errno));
+ else
+ printf("ok\n");
+
+ close(fd);
+ }
+ else
+ {
+ printf("can't open [%s]\n", strerror(errno));
+ }
+}
+
+
+int main(int argc, char **argv)
+{
+ int id1, id2;
+ struct usbentry *dev;
+
+ if (!find_usbfs())
+ {
+ fprintf(stderr, "Unable to find usbfs, is it mounted?\n");
+ return 1;
+ }
+
+ if ((argc == 2) && (sscanf(argv[1], "%3d/%3d", &id1, &id2) == 2))
+ {
+ dev = find_device(&id1, &id2, NULL, NULL, NULL);
+ }
+ else if ((argc == 2) && (sscanf(argv[1], "%4x:%4x", &id1, &id2) == 2))
+ {
+ dev = find_device(NULL, NULL, &id1, &id2, NULL);
+ }
+ else if ((argc == 2) && strlen(argv[1]) < 128)
+ {
+ dev = find_device(NULL, NULL, NULL, NULL, argv[1]);
+ }
+ else
+ {
+ printf("Usage:\n"
+ " usbreset PPPP:VVVV - reset by product and vendor id\n"
+ " usbreset BBB/DDD - reset by bus and device number\n"
+ " usbreset \"Product\" - reset by product name\n\n"
+ "Devices:\n");
+ list_devices();
+ return 1;
+ }
+
+ if (!dev)
+ {
+ fprintf(stderr, "No such device found\n");
+ return 1;
+ }
+
+ reset_device(dev);
+ return 0;
+}
diff --git a/package/system/utils/usbreset/src/usbreset.c b/package/system/utils/usbreset/src/usbreset.c
new file mode 100644
index 0000000..087a14c
--- /dev/null
+++ b/package/system/utils/usbreset/src/usbreset.c
@@ -0,0 +1,253 @@
+/* usbreset -- send a USB port reset to a USB device */
+
+/*
+
+http://marc.info/?l=linux-usb-users&m=116827193506484&w=2
+
+and needs mounted usbfs filesystem
+
+ sudo mount -t usbfs none /proc/bus/usb
+
+There is a way to suspend a USB device. In order to use it,
+you must have a kernel with CONFIG_PM_SYSFS_DEPRECATED turned on. To
+suspend a device, do (as root):
+
+ echo -n 2 >/sys/bus/usb/devices/.../power/state
+
+where the "..." is the ID for your device. To unsuspend, do the same
+thing but with a "0" instead of the "2" above.
+
+Note that this mechanism is slated to be removed from the kernel within
+the next year. Hopefully some other mechanism will take its place.
+
+> To reset a
+> device?
+
+Here's a program to do it. You invoke it as either
+
+ usbreset /proc/bus/usb/BBB/DDD
+or
+ usbreset /dev/usbB.D
+
+depending on how your system is set up, where BBB and DDD are the bus and
+device address numbers.
+
+Alan Stern
+
+*/
+
+#include <stdio.h>
+#include <stdbool.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <string.h>
+#include <sys/ioctl.h>
+
+#include <linux/usbdevice_fs.h>
+
+
+static char *usbfs = NULL;
+
+struct usbentry {
+ int bus_num;
+ int dev_num;
+ int vendor_id;
+ int product_id;
+ char vendor_name[128];
+ char product_name[128];
+};
+
+
+static bool find_usbfs(void)
+{
+ FILE *mtab;
+
+ char buf[1024], type[32];
+ static char path[1024];
+
+ if ((mtab = fopen("/proc/mounts", "r")) != NULL)
+ {
+ while (fgets(buf, sizeof(buf), mtab))
+ {
+ if (sscanf(buf, "%*s %1023s %31s ", path, type) == 2 &&
+ !strncmp(type, "usbfs", 5))
+ {
+ usbfs = path;
+ break;
+ }
+ }
+
+ fclose(mtab);
+ }
+
+ return !!usbfs;
+}
+
+static FILE * open_devlist(void)
+{
+ char buf[1024];
+ snprintf(buf, sizeof(buf), "%s/devices", usbfs);
+ return fopen(buf, "r");
+}
+
+static void close_devlist(FILE *devs)
+{
+ fclose(devs);
+}
+
+static struct usbentry * parse_devlist(FILE *devs)
+{
+ char buf[1024];
+ static struct usbentry dev;
+
+ memset(&dev, 0, sizeof(dev));
+
+ while (fgets(buf, sizeof(buf), devs))
+ {
+ buf[strlen(buf)-1] = 0;
+
+ switch (buf[0])
+ {
+ case 'T':
+ sscanf(buf, "T: Bus=%d Lev=%*d Prnt=%*d Port=%*d Cnt=%*d Dev#=%d",
+ &dev.bus_num, &dev.dev_num);
+ break;
+
+ case 'P':
+ sscanf(buf, "P: Vendor=%x ProdID=%x",
+ &dev.vendor_id, &dev.product_id);
+ break;
+
+ case 'S':
+ if (!strncmp(buf, "S: Manufacturer=", 17))
+ snprintf(dev.vendor_name, sizeof(dev.vendor_name),
+ "%s", buf+17);
+ else if (!strncmp(buf, "S: Product=", 12))
+ snprintf(dev.product_name, sizeof(dev.product_name),
+ "%s", buf+12);
+ break;
+ }
+
+ if (dev.product_name[0])
+ return &dev;
+ }
+
+ return NULL;
+}
+
+static void list_devices(void)
+{
+ FILE *devs = open_devlist();
+ struct usbentry *dev;
+
+ if (!devs)
+ return;
+
+ while ((dev = parse_devlist(devs)) != NULL)
+ {
+ printf(" Number %03d/%03d ID %04x:%04x %s\n",
+ dev->bus_num, dev->dev_num,
+ dev->vendor_id, dev->product_id,
+ dev->product_name);
+ }
+
+ close_devlist(devs);
+}
+
+struct usbentry * find_device(int *bus, int *dev,
+ int *vid, int *pid,
+ const char *product)
+{
+ FILE *devs = open_devlist();
+
+ struct usbentry *e, *match = NULL;
+
+ if (!devs)
+ return NULL;
+
+ while ((e = parse_devlist(devs)) != NULL)
+ {
+ if ((bus && (e->bus_num == *bus) && (e->dev_num == *dev)) ||
+ (vid && (e->vendor_id == *vid) && (e->product_id == *pid)) ||
+ (product && !strcasecmp(e->product_name, product)))
+ {
+ match = e;
+ break;
+ }
+ }
+
+ close_devlist(devs);
+
+ return match;
+}
+
+static void reset_device(struct usbentry *dev)
+{
+ int fd;
+ char path[1024];
+
+ snprintf(path, sizeof(path), "%s/%03d/%03d",
+ usbfs, dev->bus_num, dev->dev_num);
+
+ printf("Resetting %s ... ", dev->product_name);
+
+ if ((fd = open(path, O_WRONLY)) > -1)
+ {
+ if (ioctl(fd, USBDEVFS_RESET, 0) < 0)
+ printf("failed [%s]\n", strerror(errno));
+ else
+ printf("ok\n");
+
+ close(fd);
+ }
+ else
+ {
+ printf("can't open [%s]\n", strerror(errno));
+ }
+}
+
+
+int main(int argc, char **argv)
+{
+ int id1, id2;
+ struct usbentry *dev;
+
+ if (!find_usbfs())
+ {
+ fprintf(stderr, "Unable to find usbfs, is it mounted?\n");
+ return 1;
+ }
+
+ if ((argc == 2) && (sscanf(argv[1], "%3d/%3d", &id1, &id2) == 2))
+ {
+ dev = find_device(&id1, &id2, NULL, NULL, NULL);
+ }
+ else if ((argc == 2) && (sscanf(argv[1], "%4x:%4x", &id1, &id2) == 2))
+ {
+ dev = find_device(NULL, NULL, &id1, &id2, NULL);
+ }
+ else if ((argc == 2) && strlen(argv[1]) < 128)
+ {
+ dev = find_device(NULL, NULL, NULL, NULL, argv[1]);
+ }
+ else
+ {
+ printf("Usage:\n"
+ " usbreset PPPP:VVVV - reset by product and vendor id\n"
+ " usbreset BBB/DDD - reset by bus and device number\n"
+ " usbreset \"Product\" - reset by product name\n\n"
+ "Devices:\n");
+ list_devices();
+ return 1;
+ }
+
+ if (!dev)
+ {
+ fprintf(stderr, "No such device found\n");
+ return 1;
+ }
+
+ reset_device(dev);
+ return 0;
+}
diff --git a/package/system/utils/usbutils/.svn/entries b/package/system/utils/usbutils/.svn/entries
new file mode 100644
index 0000000..62b4f1f
--- /dev/null
+++ b/package/system/utils/usbutils/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/system/utils/usbutils
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-29T10:48:41.046519Z
+35374
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+1048d4be38eab419bbbdb411fa22b16f
+2013-01-29T10:48:41.046519Z
+35374
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1445
+
diff --git a/package/system/utils/usbutils/.svn/text-base/Makefile.svn-base b/package/system/utils/usbutils/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..2cd59ae
--- /dev/null
+++ b/package/system/utils/usbutils/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,57 @@
+#
+# Copyright (C) 2007-2013 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=usbutils
+PKG_VERSION:=006
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=@KERNEL/linux/utils/usb/usbutils
+PKG_MD5SUM:=9d13954981f4adbe3fd02aae6dbfafa9
+
+USB_IDS_VERSION:=2013-01-16
+USB_IDS_MD5SUM:=2a2344907b6344f0935c86efaf9de620
+USB_IDS_FILE:=usb.ids.$(USB_IDS_VERSION).gz
+
+PKG_BUILD_PARALLEL:=1
+PKG_INSTALL:=1
+
+PKG_MAINTAINER := Felix Fietkau <nbd@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/usbutils
+ SECTION:=utils
+ CATEGORY:=Utilities
+ DEPENDS:=+libusb-1.0 +zlib +librt +libpthread
+ TITLE:=USB devices listing utilities
+ URL:=http://www.linux-usb.org/
+endef
+
+define Download/usb_ids
+ FILE:=$(USB_IDS_FILE)
+ URL:=http://mirror2.openwrt.org/sources
+ MD5SUM:=$(USB_IDS_MD5SUM)
+endef
+$(eval $(call Download,usb_ids))
+
+define Build/Prepare
+ $(Build/Prepare/Default)
+ echo '#!/bin/sh' > $(PKG_BUILD_DIR)/update-usbids.sh.in
+ echo 'cp $(DL_DIR)/$(USB_IDS_FILE) usb.ids.gz' >> $(PKG_BUILD_DIR)/update-usbids.sh.in
+endef
+
+define Package/usbutils/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/lsusb $(1)/usr/bin/
+ $(INSTALL_DIR) $(1)/usr/share
+ $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/share/usb.ids.gz $(1)/usr/share/
+endef
+
+$(eval $(call BuildPackage,usbutils))
diff --git a/package/system/utils/usbutils/Makefile b/package/system/utils/usbutils/Makefile
new file mode 100644
index 0000000..2cd59ae
--- /dev/null
+++ b/package/system/utils/usbutils/Makefile
@@ -0,0 +1,57 @@
+#
+# Copyright (C) 2007-2013 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=usbutils
+PKG_VERSION:=006
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=@KERNEL/linux/utils/usb/usbutils
+PKG_MD5SUM:=9d13954981f4adbe3fd02aae6dbfafa9
+
+USB_IDS_VERSION:=2013-01-16
+USB_IDS_MD5SUM:=2a2344907b6344f0935c86efaf9de620
+USB_IDS_FILE:=usb.ids.$(USB_IDS_VERSION).gz
+
+PKG_BUILD_PARALLEL:=1
+PKG_INSTALL:=1
+
+PKG_MAINTAINER := Felix Fietkau <nbd@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/usbutils
+ SECTION:=utils
+ CATEGORY:=Utilities
+ DEPENDS:=+libusb-1.0 +zlib +librt +libpthread
+ TITLE:=USB devices listing utilities
+ URL:=http://www.linux-usb.org/
+endef
+
+define Download/usb_ids
+ FILE:=$(USB_IDS_FILE)
+ URL:=http://mirror2.openwrt.org/sources
+ MD5SUM:=$(USB_IDS_MD5SUM)
+endef
+$(eval $(call Download,usb_ids))
+
+define Build/Prepare
+ $(Build/Prepare/Default)
+ echo '#!/bin/sh' > $(PKG_BUILD_DIR)/update-usbids.sh.in
+ echo 'cp $(DL_DIR)/$(USB_IDS_FILE) usb.ids.gz' >> $(PKG_BUILD_DIR)/update-usbids.sh.in
+endef
+
+define Package/usbutils/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/lsusb $(1)/usr/bin/
+ $(INSTALL_DIR) $(1)/usr/share
+ $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/share/usb.ids.gz $(1)/usr/share/
+endef
+
+$(eval $(call BuildPackage,usbutils))
diff --git a/package/system/utils/xfsprogs/.svn/entries b/package/system/utils/xfsprogs/.svn/entries
new file mode 100644
index 0000000..45de23b
--- /dev/null
+++ b/package/system/utils/xfsprogs/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/system/utils/xfsprogs
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-29T10:48:46.063504Z
+35375
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+17315445cbd9b85633605c5dd2f84d17
+2013-01-29T10:48:46.063504Z
+35375
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2177
+
diff --git a/package/system/utils/xfsprogs/.svn/text-base/Makefile.svn-base b/package/system/utils/xfsprogs/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..a7a865a
--- /dev/null
+++ b/package/system/utils/xfsprogs/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,87 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=xfsprogs
+PKG_RELEASE:=1
+PKG_VERSION:=3.1.7
+PKG_SOURCE_URL:=ftp://oss.sgi.com/projects/xfs/previous/
+PKG_MD5SUM:=049cf9873794ea49d0bb3f12d45748a4
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_INSTALL:=1
+PKG_FIXUP:=autoreconf
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/nls.mk
+
+define Package/xfsprogs/default
+ SECTION:=utils
+ CATEGORY:=Utilities
+ DEPENDS:=+libuuid +libpthread +librt
+ URL:=http://oss.sgi.com/projects/xfs
+endef
+
+define Package/xfs-mkfs
+$(call Package/xfsprogs/default)
+ TITLE:=Utility for creating XFS filesystems
+endef
+
+define Package/xfs-fsck
+$(call Package/xfsprogs/default)
+ TITLE:=Utilities for checking and repairing XFS filesystems
+endef
+
+define Package/xfs-growfs
+$(call Package/xfsprogs/default)
+ TITLE:=Utility for increasing the size of XFS filesystems
+endef
+
+CONFIGURE_ARGS += \
+ --enable-gettext=no \
+ --enable-lib64=no
+
+TARGET_CFLAGS += \
+ -I$(STAGING_DIR)/usr/include \
+ -D_LARGEFILE64_SOURCE \
+ -D_FILE_OFFSET_BITS=64 \
+ -D_GNU_SOURCE
+
+MAKE_FLAGS += \
+ DEBUG= Q= \
+ PCFLAGS="-Wall" \
+ PKG_PLATFORM=linux \
+ ENABLE_GETTEXT=no \
+ prefix=$(PKG_INSTALL_DIR)/usr \
+ exec_prefix=$(PKG_INSTALL_DIR)/usr \
+ PKG_SBIN_DIR=$(PKG_INSTALL_DIR)/usr/sbin \
+ PKG_ROOT_SBIN_DIR=$(PKG_INSTALL_DIR)/sbin \
+ PKG_MAN_DIR=$(PKG_INSTALL_DIR)/usr/man \
+ PKG_LOCALE_DIR=$(PKG_INSTALL_DIR)/usr/share/locale \
+ PKG_ROOT_LIB_DIR=$(PKG_INSTALL_DIR)/lib \
+ PKG_DOC_DIR=$(PKG_INSTALL_DIR)/usr/share/doc/xfsprogs
+
+define Package/xfs-mkfs/install
+ mkdir -p $(1)/sbin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/sbin/mkfs.xfs $(1)/sbin
+endef
+
+define Package/xfs-fsck/install
+ mkdir -p $(1)/sbin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/sbin/xfs_repair $(1)/sbin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/xfs_db $(1)/sbin
+endef
+
+define Package/xfs-growfs/install
+ mkdir -p $(1)/sbin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/xfs_growfs $(1)/sbin
+endef
+
+$(eval $(call BuildPackage,xfs-mkfs))
+$(eval $(call BuildPackage,xfs-fsck))
+$(eval $(call BuildPackage,xfs-growfs))
diff --git a/package/system/utils/xfsprogs/Makefile b/package/system/utils/xfsprogs/Makefile
new file mode 100644
index 0000000..a7a865a
--- /dev/null
+++ b/package/system/utils/xfsprogs/Makefile
@@ -0,0 +1,87 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=xfsprogs
+PKG_RELEASE:=1
+PKG_VERSION:=3.1.7
+PKG_SOURCE_URL:=ftp://oss.sgi.com/projects/xfs/previous/
+PKG_MD5SUM:=049cf9873794ea49d0bb3f12d45748a4
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_INSTALL:=1
+PKG_FIXUP:=autoreconf
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/nls.mk
+
+define Package/xfsprogs/default
+ SECTION:=utils
+ CATEGORY:=Utilities
+ DEPENDS:=+libuuid +libpthread +librt
+ URL:=http://oss.sgi.com/projects/xfs
+endef
+
+define Package/xfs-mkfs
+$(call Package/xfsprogs/default)
+ TITLE:=Utility for creating XFS filesystems
+endef
+
+define Package/xfs-fsck
+$(call Package/xfsprogs/default)
+ TITLE:=Utilities for checking and repairing XFS filesystems
+endef
+
+define Package/xfs-growfs
+$(call Package/xfsprogs/default)
+ TITLE:=Utility for increasing the size of XFS filesystems
+endef
+
+CONFIGURE_ARGS += \
+ --enable-gettext=no \
+ --enable-lib64=no
+
+TARGET_CFLAGS += \
+ -I$(STAGING_DIR)/usr/include \
+ -D_LARGEFILE64_SOURCE \
+ -D_FILE_OFFSET_BITS=64 \
+ -D_GNU_SOURCE
+
+MAKE_FLAGS += \
+ DEBUG= Q= \
+ PCFLAGS="-Wall" \
+ PKG_PLATFORM=linux \
+ ENABLE_GETTEXT=no \
+ prefix=$(PKG_INSTALL_DIR)/usr \
+ exec_prefix=$(PKG_INSTALL_DIR)/usr \
+ PKG_SBIN_DIR=$(PKG_INSTALL_DIR)/usr/sbin \
+ PKG_ROOT_SBIN_DIR=$(PKG_INSTALL_DIR)/sbin \
+ PKG_MAN_DIR=$(PKG_INSTALL_DIR)/usr/man \
+ PKG_LOCALE_DIR=$(PKG_INSTALL_DIR)/usr/share/locale \
+ PKG_ROOT_LIB_DIR=$(PKG_INSTALL_DIR)/lib \
+ PKG_DOC_DIR=$(PKG_INSTALL_DIR)/usr/share/doc/xfsprogs
+
+define Package/xfs-mkfs/install
+ mkdir -p $(1)/sbin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/sbin/mkfs.xfs $(1)/sbin
+endef
+
+define Package/xfs-fsck/install
+ mkdir -p $(1)/sbin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/sbin/xfs_repair $(1)/sbin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/xfs_db $(1)/sbin
+endef
+
+define Package/xfs-growfs/install
+ mkdir -p $(1)/sbin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/xfs_growfs $(1)/sbin
+endef
+
+$(eval $(call BuildPackage,xfs-mkfs))
+$(eval $(call BuildPackage,xfs-fsck))
+$(eval $(call BuildPackage,xfs-growfs))
diff --git a/package/system/utils/xfsprogs/patches/.svn/entries b/package/system/utils/xfsprogs/patches/.svn/entries
new file mode 100644
index 0000000..38ca0ec
--- /dev/null
+++ b/package/system/utils/xfsprogs/patches/.svn/entries
@@ -0,0 +1,232 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/system/utils/xfsprogs/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-29T10:48:46.063504Z
+35375
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+100-no_aio.patch
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+5030b93d2959ce125f814bb1c6ed1a40
+2013-01-29T10:48:46.063504Z
+35375
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+494
+
+120-portability.patch
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+78be2e00362660495fdbd4aa9fbfe8ad
+2013-01-29T10:48:46.063504Z
+35375
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+981
+
+001-automake-compat.patch
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+64f825f935392452004a8005fe4ade7e
+2013-01-29T10:48:46.063504Z
+35375
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2749
+
+110-uclibc_no_ustat.patch
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+3470c211e42c6533c86835534f131eee
+2013-01-29T10:48:46.063504Z
+35375
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+908
+
+140-no_po.patch
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+23df9fa23732f78ae3897488a91a4f9a
+2013-01-29T10:48:46.063504Z
+35375
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+700
+
+130-uclibc_no_xattr.patch
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+e7421678d2bd7b6dab26f2545922334a
+2013-01-29T10:48:46.063504Z
+35375
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+717
+
diff --git a/package/system/utils/xfsprogs/patches/.svn/text-base/001-automake-compat.patch.svn-base b/package/system/utils/xfsprogs/patches/.svn/text-base/001-automake-compat.patch.svn-base
new file mode 100644
index 0000000..3003d6d
--- /dev/null
+++ b/package/system/utils/xfsprogs/patches/.svn/text-base/001-automake-compat.patch.svn-base
@@ -0,0 +1,84 @@
+commit 2222aa77e11b959e0e5a0ded3482e56799593bc2
+Author: Jens Muecke <jens@nons.de>
+Date: Thu Jan 26 00:34:15 2012 +0100
+
+ 001-automake-compat
+
+diff --git a/configure.in b/configure.in
+index 664c0e9..d91b6ec 100644
+--- a/configure.in
++++ b/configure.in
+@@ -2,7 +2,8 @@ AC_INIT(include/libxfs.h)
+ AC_PREREQ(2.50)
+ AC_CONFIG_AUX_DIR([.])
+ AC_CONFIG_MACRO_DIR([m4])
+-AC_CONFIG_HEADER(include/platform_defs.h)
++# Put a dummy here (http://www.mail-archive.com/automake@gnu.org/msg09241.html)
++AC_CONFIG_HEADERS([doesnotexist.h include/platform_defs.h])
+ AC_PREFIX_DEFAULT(/usr)
+
+ AC_PROG_LIBTOOL
+diff --git a/include/builddefs.in b/include/builddefs.in
+index 81ebfcd..5a4a0e8 100644
+--- a/include/builddefs.in
++++ b/include/builddefs.in
+@@ -20,6 +20,8 @@
+ ifndef _BUILDDEFS_INCLUDED_
+ _BUILDDEFS_INCLUDED_ = 1
+
++SHELL = @SHELL@
++
+ DEBUG = @debug_build@
+ OPTIMIZER = @opt_build@
+ MALLOCLIB = @malloc_lib@
+diff --git a/m4/package_types.m4 b/m4/package_types.m4
+index 0a0e087..66a136a 100644
+--- a/m4/package_types.m4
++++ b/m4/package_types.m4
+@@ -9,7 +9,7 @@ AC_DEFUN([AC_TYPE_PSINT],
+ #include <stddef.h>
+ ], [
+ __psint_t psint;
+- ], AC_DEFINE(HAVE___PSINT_T) AC_MSG_RESULT(yes) , AC_MSG_RESULT(no))
++ ], AC_DEFINE([HAVE___PSINT_T], [1], [Define if __psint_t exists]) AC_MSG_RESULT(yes) , AC_MSG_RESULT(no))
+ ])
+
+ #
+@@ -23,7 +23,7 @@ AC_DEFUN([AC_TYPE_PSUNSIGNED],
+ #include <stddef.h>
+ ], [
+ __psunsigned_t psuint;
+- ], AC_DEFINE(HAVE___PSUNSIGNED_T) AC_MSG_RESULT(yes) , AC_MSG_RESULT(no))
++ ], AC_DEFINE([HAVE___PSUNSIGNED_T], [1], [Define if __psunsigned_t exists]) AC_MSG_RESULT(yes) , AC_MSG_RESULT(no))
+ ])
+
+ #
+@@ -37,7 +37,7 @@ AC_DEFUN([AC_TYPE_U32],
+ #include <stddef.h>
+ ], [
+ __u32 u32;
+- ], AC_DEFINE(HAVE___U32) AC_MSG_RESULT(yes) , AC_MSG_RESULT(no))
++ ], AC_DEFINE([HAVE___U32], [1], [Define if __u32 exists]) AC_MSG_RESULT(yes) , AC_MSG_RESULT(no))
+ ])
+
+ #
+@@ -50,15 +50,15 @@ AC_DEFUN([AC_SIZEOF_POINTERS_AND_LONG],
+ AC_CHECK_SIZEOF(long, 4)
+ AC_CHECK_SIZEOF(char *, 4)
+ if test $ac_cv_sizeof_long -eq 4 -o $ac_cv_sizeof_long -eq 0; then
+- AC_DEFINE(HAVE_32BIT_LONG)
++ AC_DEFINE([HAVE_32BIT_LONG], [1], [Define if long is 32bit])
+ fi
+ if test $ac_cv_sizeof_long -eq 8; then
+- AC_DEFINE(HAVE_64BIT_LONG)
++ AC_DEFINE([HAVE_64BIT_LONG], [1], [Define if long is 64bit])
+ fi
+ if test $ac_cv_sizeof_char_p -eq 4 -o $ac_cv_sizeof_char_p -eq 0; then
+- AC_DEFINE(HAVE_32BIT_PTR)
++ AC_DEFINE([HAVE_32BIT_PTR], [1], [Define if char* is 32bit])
+ fi
+ if test $ac_cv_sizeof_char_p -eq 8; then
+- AC_DEFINE(HAVE_64BIT_PTR)
++ AC_DEFINE([HAVE_64BIT_PTR], [1], [Define if char* is 64bit])
+ fi
+ ])
diff --git a/package/system/utils/xfsprogs/patches/.svn/text-base/100-no_aio.patch.svn-base b/package/system/utils/xfsprogs/patches/.svn/text-base/100-no_aio.patch.svn-base
new file mode 100644
index 0000000..30d36b4
--- /dev/null
+++ b/package/system/utils/xfsprogs/patches/.svn/text-base/100-no_aio.patch.svn-base
@@ -0,0 +1,21 @@
+commit e72b7bd12fdef06c3494b919376bfe886aa8bb4d
+Author: Jens Muecke <jens@nons.de>
+Date: Thu Jan 26 00:35:43 2012 +0100
+
+ 100-no_aio
+
+diff --git a/configure.in b/configure.in
+index d91b6ec..8dc8b4a 100644
+--- a/configure.in
++++ b/configure.in
+@@ -92,8 +92,8 @@ AC_PACKAGE_GLOBALS(xfsprogs)
+ AC_PACKAGE_UTILITIES(xfsprogs)
+ AC_MULTILIB($enable_lib64)
+
+-AC_PACKAGE_NEED_AIO_H
+-AC_PACKAGE_NEED_LIO_LISTIO
++librt="-lrt"
++AC_SUBST(librt)
+
+ AC_PACKAGE_NEED_UUID_H
+ AC_PACKAGE_NEED_UUIDCOMPARE
diff --git a/package/system/utils/xfsprogs/patches/.svn/text-base/110-uclibc_no_ustat.patch.svn-base b/package/system/utils/xfsprogs/patches/.svn/text-base/110-uclibc_no_ustat.patch.svn-base
new file mode 100644
index 0000000..c46e802
--- /dev/null
+++ b/package/system/utils/xfsprogs/patches/.svn/text-base/110-uclibc_no_ustat.patch.svn-base
@@ -0,0 +1,36 @@
+commit 7b1d0a98e779170232c0a81b4749ab934ec67a7e
+Author: Jens Muecke <jens@nons.de>
+Date: Thu Jan 26 00:36:42 2012 +0100
+
+ 110-uclibc_no_ustat
+
+diff --git a/libxfs/linux.c b/libxfs/linux.c
+index 2e07d54..6a6c905 100644
+--- a/libxfs/linux.c
++++ b/libxfs/linux.c
+@@ -21,7 +21,9 @@
+ #include <mntent.h>
+ #include <sys/stat.h>
+ #undef ustat
++#ifndef __UCLIBC__
+ #include <sys/ustat.h>
++#endif
+ #include <sys/mount.h>
+ #include <sys/ioctl.h>
+ #include <sys/sysinfo.h>
+@@ -49,6 +51,7 @@ static int max_block_alignment;
+ int
+ platform_check_ismounted(char *name, char *block, struct stat64 *s, int verbose)
+ {
++#ifndef __UCLIBC__
+ /* Pad ust; pre-2.6.28 linux copies out too much in 32bit compat mode */
+ struct ustat ust[2];
+ struct stat64 st;
+@@ -68,6 +71,7 @@ platform_check_ismounted(char *name, char *block, struct stat64 *s, int verbose)
+ progname, name);
+ return 1;
+ }
++#endif
+ return 0;
+ }
+
diff --git a/package/system/utils/xfsprogs/patches/.svn/text-base/120-portability.patch.svn-base b/package/system/utils/xfsprogs/patches/.svn/text-base/120-portability.patch.svn-base
new file mode 100644
index 0000000..1e9b533
--- /dev/null
+++ b/package/system/utils/xfsprogs/patches/.svn/text-base/120-portability.patch.svn-base
@@ -0,0 +1,47 @@
+commit d2aef8b3967e53fe58178f5af50fef488ee0faed
+Author: Jens Muecke <jens@nons.de>
+Date: Thu Jan 26 00:37:52 2012 +0100
+
+ 120-portability
+
+diff --git a/copy/xfs_copy.c b/copy/xfs_copy.c
+index c01e0b9..2e2f320 100644
+--- a/copy/xfs_copy.c
++++ b/copy/xfs_copy.c
+@@ -463,6 +463,15 @@ read_ag_header(int fd, xfs_agnumber_t agno, wbuf *buf, ag_header_t *ag,
+ }
+
+
++static void sig_mask(int type)
++{
++ sigset_t mask;
++ sigemptyset(&mask);
++ sigaddset(&mask, SIGCHLD);
++ sigprocmask(type, &mask, NULL);
++}
++
++
+ void
+ write_wbuf(void)
+ {
+@@ -478,9 +487,9 @@ write_wbuf(void)
+ if (target[i].state != INACTIVE)
+ pthread_mutex_unlock(&targ[i].wait); /* wake up */
+
+- sigrelse(SIGCHLD);
++ sig_mask(SIG_UNBLOCK);
+ pthread_mutex_lock(&mainwait);
+- sighold(SIGCHLD);
++ sig_mask(SIG_BLOCK);
+ }
+
+
+@@ -847,7 +856,7 @@ main(int argc, char **argv)
+ /* set up sigchild signal handler */
+
+ signal(SIGCHLD, handler);
+- sighold(SIGCHLD);
++ sig_mask(SIG_BLOCK);
+
+ /* make children */
+
diff --git a/package/system/utils/xfsprogs/patches/.svn/text-base/130-uclibc_no_xattr.patch.svn-base b/package/system/utils/xfsprogs/patches/.svn/text-base/130-uclibc_no_xattr.patch.svn-base
new file mode 100644
index 0000000..b1ecda7
--- /dev/null
+++ b/package/system/utils/xfsprogs/patches/.svn/text-base/130-uclibc_no_xattr.patch.svn-base
@@ -0,0 +1,36 @@
+commit 10d6058b24f18cb31889154f830b191849f45106
+Author: Jens Muecke <jens@nons.de>
+Date: Thu Jan 26 00:38:27 2012 +0100
+
+ 130-uclibc_no_xattr
+
+diff --git a/fsr/xfs_fsr.c b/fsr/xfs_fsr.c
+index 40c2e6f..4f54059 100644
+--- a/fsr/xfs_fsr.c
++++ b/fsr/xfs_fsr.c
+@@ -35,7 +35,9 @@
+ #include <sys/wait.h>
+ #include <sys/vfs.h>
+ #include <sys/statvfs.h>
++#ifndef __UCLIBC__
+ #include <sys/xattr.h>
++#endif
+
+
+ #ifndef XFS_XFLAG_NODEFRAG
+@@ -990,6 +992,7 @@ fsr_setup_attr_fork(
+ int tfd,
+ xfs_bstat_t *bstatp)
+ {
++#ifndef __UCLIBC__
+ struct stat64 tstatbuf;
+ int i;
+ int last_forkoff = 0;
+@@ -1108,6 +1111,7 @@ fsr_setup_attr_fork(
+ out:
+ if (dflag)
+ fsrprintf(_("set temp attr\n"));
++#endif
+ return 0;
+ }
+
diff --git a/package/system/utils/xfsprogs/patches/.svn/text-base/140-no_po.patch.svn-base b/package/system/utils/xfsprogs/patches/.svn/text-base/140-no_po.patch.svn-base
new file mode 100644
index 0000000..f915a9c
--- /dev/null
+++ b/package/system/utils/xfsprogs/patches/.svn/text-base/140-no_po.patch.svn-base
@@ -0,0 +1,20 @@
+diff -urN xfsprogs-3.1.7/Makefile xfsprogs-3.1.7.new/Makefile
+--- xfsprogs-3.1.7/Makefile 2011-11-18 00:30:24.000000000 +0100
++++ xfsprogs-3.1.7.new/Makefile 2012-04-20 14:15:48.641722955 +0200
+@@ -41,7 +41,7 @@
+
+ LIB_SUBDIRS = libxfs libxlog libxcmd libhandle libdisk
+ TOOL_SUBDIRS = copy db estimate fsck fsr growfs io logprint mkfs quota \
+- mdrestore repair rtcp m4 man doc po debian
++ mdrestore repair rtcp m4 man doc debian
+
+ SUBDIRS = include $(LIB_SUBDIRS) $(TOOL_SUBDIRS)
+
+@@ -135,7 +135,6 @@
+ $(Q)$(MAKE) $(MAKEOPTS) -C . $@
+ else
+ $(Q)$(MAKE) $(MAKEOPTS) $(SRCDIR)
+- $(Q)$(MAKE) $(MAKEOPTS) -C po
+ $(Q)$(MAKE) $(MAKEOPTS) source-link
+ $(Q)cd $(SRCDIR) && dpkg-buildpackage
+ endif
diff --git a/package/system/utils/xfsprogs/patches/001-automake-compat.patch b/package/system/utils/xfsprogs/patches/001-automake-compat.patch
new file mode 100644
index 0000000..3003d6d
--- /dev/null
+++ b/package/system/utils/xfsprogs/patches/001-automake-compat.patch
@@ -0,0 +1,84 @@
+commit 2222aa77e11b959e0e5a0ded3482e56799593bc2
+Author: Jens Muecke <jens@nons.de>
+Date: Thu Jan 26 00:34:15 2012 +0100
+
+ 001-automake-compat
+
+diff --git a/configure.in b/configure.in
+index 664c0e9..d91b6ec 100644
+--- a/configure.in
++++ b/configure.in
+@@ -2,7 +2,8 @@ AC_INIT(include/libxfs.h)
+ AC_PREREQ(2.50)
+ AC_CONFIG_AUX_DIR([.])
+ AC_CONFIG_MACRO_DIR([m4])
+-AC_CONFIG_HEADER(include/platform_defs.h)
++# Put a dummy here (http://www.mail-archive.com/automake@gnu.org/msg09241.html)
++AC_CONFIG_HEADERS([doesnotexist.h include/platform_defs.h])
+ AC_PREFIX_DEFAULT(/usr)
+
+ AC_PROG_LIBTOOL
+diff --git a/include/builddefs.in b/include/builddefs.in
+index 81ebfcd..5a4a0e8 100644
+--- a/include/builddefs.in
++++ b/include/builddefs.in
+@@ -20,6 +20,8 @@
+ ifndef _BUILDDEFS_INCLUDED_
+ _BUILDDEFS_INCLUDED_ = 1
+
++SHELL = @SHELL@
++
+ DEBUG = @debug_build@
+ OPTIMIZER = @opt_build@
+ MALLOCLIB = @malloc_lib@
+diff --git a/m4/package_types.m4 b/m4/package_types.m4
+index 0a0e087..66a136a 100644
+--- a/m4/package_types.m4
++++ b/m4/package_types.m4
+@@ -9,7 +9,7 @@ AC_DEFUN([AC_TYPE_PSINT],
+ #include <stddef.h>
+ ], [
+ __psint_t psint;
+- ], AC_DEFINE(HAVE___PSINT_T) AC_MSG_RESULT(yes) , AC_MSG_RESULT(no))
++ ], AC_DEFINE([HAVE___PSINT_T], [1], [Define if __psint_t exists]) AC_MSG_RESULT(yes) , AC_MSG_RESULT(no))
+ ])
+
+ #
+@@ -23,7 +23,7 @@ AC_DEFUN([AC_TYPE_PSUNSIGNED],
+ #include <stddef.h>
+ ], [
+ __psunsigned_t psuint;
+- ], AC_DEFINE(HAVE___PSUNSIGNED_T) AC_MSG_RESULT(yes) , AC_MSG_RESULT(no))
++ ], AC_DEFINE([HAVE___PSUNSIGNED_T], [1], [Define if __psunsigned_t exists]) AC_MSG_RESULT(yes) , AC_MSG_RESULT(no))
+ ])
+
+ #
+@@ -37,7 +37,7 @@ AC_DEFUN([AC_TYPE_U32],
+ #include <stddef.h>
+ ], [
+ __u32 u32;
+- ], AC_DEFINE(HAVE___U32) AC_MSG_RESULT(yes) , AC_MSG_RESULT(no))
++ ], AC_DEFINE([HAVE___U32], [1], [Define if __u32 exists]) AC_MSG_RESULT(yes) , AC_MSG_RESULT(no))
+ ])
+
+ #
+@@ -50,15 +50,15 @@ AC_DEFUN([AC_SIZEOF_POINTERS_AND_LONG],
+ AC_CHECK_SIZEOF(long, 4)
+ AC_CHECK_SIZEOF(char *, 4)
+ if test $ac_cv_sizeof_long -eq 4 -o $ac_cv_sizeof_long -eq 0; then
+- AC_DEFINE(HAVE_32BIT_LONG)
++ AC_DEFINE([HAVE_32BIT_LONG], [1], [Define if long is 32bit])
+ fi
+ if test $ac_cv_sizeof_long -eq 8; then
+- AC_DEFINE(HAVE_64BIT_LONG)
++ AC_DEFINE([HAVE_64BIT_LONG], [1], [Define if long is 64bit])
+ fi
+ if test $ac_cv_sizeof_char_p -eq 4 -o $ac_cv_sizeof_char_p -eq 0; then
+- AC_DEFINE(HAVE_32BIT_PTR)
++ AC_DEFINE([HAVE_32BIT_PTR], [1], [Define if char* is 32bit])
+ fi
+ if test $ac_cv_sizeof_char_p -eq 8; then
+- AC_DEFINE(HAVE_64BIT_PTR)
++ AC_DEFINE([HAVE_64BIT_PTR], [1], [Define if char* is 64bit])
+ fi
+ ])
diff --git a/package/system/utils/xfsprogs/patches/100-no_aio.patch b/package/system/utils/xfsprogs/patches/100-no_aio.patch
new file mode 100644
index 0000000..30d36b4
--- /dev/null
+++ b/package/system/utils/xfsprogs/patches/100-no_aio.patch
@@ -0,0 +1,21 @@
+commit e72b7bd12fdef06c3494b919376bfe886aa8bb4d
+Author: Jens Muecke <jens@nons.de>
+Date: Thu Jan 26 00:35:43 2012 +0100
+
+ 100-no_aio
+
+diff --git a/configure.in b/configure.in
+index d91b6ec..8dc8b4a 100644
+--- a/configure.in
++++ b/configure.in
+@@ -92,8 +92,8 @@ AC_PACKAGE_GLOBALS(xfsprogs)
+ AC_PACKAGE_UTILITIES(xfsprogs)
+ AC_MULTILIB($enable_lib64)
+
+-AC_PACKAGE_NEED_AIO_H
+-AC_PACKAGE_NEED_LIO_LISTIO
++librt="-lrt"
++AC_SUBST(librt)
+
+ AC_PACKAGE_NEED_UUID_H
+ AC_PACKAGE_NEED_UUIDCOMPARE
diff --git a/package/system/utils/xfsprogs/patches/110-uclibc_no_ustat.patch b/package/system/utils/xfsprogs/patches/110-uclibc_no_ustat.patch
new file mode 100644
index 0000000..c46e802
--- /dev/null
+++ b/package/system/utils/xfsprogs/patches/110-uclibc_no_ustat.patch
@@ -0,0 +1,36 @@
+commit 7b1d0a98e779170232c0a81b4749ab934ec67a7e
+Author: Jens Muecke <jens@nons.de>
+Date: Thu Jan 26 00:36:42 2012 +0100
+
+ 110-uclibc_no_ustat
+
+diff --git a/libxfs/linux.c b/libxfs/linux.c
+index 2e07d54..6a6c905 100644
+--- a/libxfs/linux.c
++++ b/libxfs/linux.c
+@@ -21,7 +21,9 @@
+ #include <mntent.h>
+ #include <sys/stat.h>
+ #undef ustat
++#ifndef __UCLIBC__
+ #include <sys/ustat.h>
++#endif
+ #include <sys/mount.h>
+ #include <sys/ioctl.h>
+ #include <sys/sysinfo.h>
+@@ -49,6 +51,7 @@ static int max_block_alignment;
+ int
+ platform_check_ismounted(char *name, char *block, struct stat64 *s, int verbose)
+ {
++#ifndef __UCLIBC__
+ /* Pad ust; pre-2.6.28 linux copies out too much in 32bit compat mode */
+ struct ustat ust[2];
+ struct stat64 st;
+@@ -68,6 +71,7 @@ platform_check_ismounted(char *name, char *block, struct stat64 *s, int verbose)
+ progname, name);
+ return 1;
+ }
++#endif
+ return 0;
+ }
+
diff --git a/package/system/utils/xfsprogs/patches/120-portability.patch b/package/system/utils/xfsprogs/patches/120-portability.patch
new file mode 100644
index 0000000..1e9b533
--- /dev/null
+++ b/package/system/utils/xfsprogs/patches/120-portability.patch
@@ -0,0 +1,47 @@
+commit d2aef8b3967e53fe58178f5af50fef488ee0faed
+Author: Jens Muecke <jens@nons.de>
+Date: Thu Jan 26 00:37:52 2012 +0100
+
+ 120-portability
+
+diff --git a/copy/xfs_copy.c b/copy/xfs_copy.c
+index c01e0b9..2e2f320 100644
+--- a/copy/xfs_copy.c
++++ b/copy/xfs_copy.c
+@@ -463,6 +463,15 @@ read_ag_header(int fd, xfs_agnumber_t agno, wbuf *buf, ag_header_t *ag,
+ }
+
+
++static void sig_mask(int type)
++{
++ sigset_t mask;
++ sigemptyset(&mask);
++ sigaddset(&mask, SIGCHLD);
++ sigprocmask(type, &mask, NULL);
++}
++
++
+ void
+ write_wbuf(void)
+ {
+@@ -478,9 +487,9 @@ write_wbuf(void)
+ if (target[i].state != INACTIVE)
+ pthread_mutex_unlock(&targ[i].wait); /* wake up */
+
+- sigrelse(SIGCHLD);
++ sig_mask(SIG_UNBLOCK);
+ pthread_mutex_lock(&mainwait);
+- sighold(SIGCHLD);
++ sig_mask(SIG_BLOCK);
+ }
+
+
+@@ -847,7 +856,7 @@ main(int argc, char **argv)
+ /* set up sigchild signal handler */
+
+ signal(SIGCHLD, handler);
+- sighold(SIGCHLD);
++ sig_mask(SIG_BLOCK);
+
+ /* make children */
+
diff --git a/package/system/utils/xfsprogs/patches/130-uclibc_no_xattr.patch b/package/system/utils/xfsprogs/patches/130-uclibc_no_xattr.patch
new file mode 100644
index 0000000..b1ecda7
--- /dev/null
+++ b/package/system/utils/xfsprogs/patches/130-uclibc_no_xattr.patch
@@ -0,0 +1,36 @@
+commit 10d6058b24f18cb31889154f830b191849f45106
+Author: Jens Muecke <jens@nons.de>
+Date: Thu Jan 26 00:38:27 2012 +0100
+
+ 130-uclibc_no_xattr
+
+diff --git a/fsr/xfs_fsr.c b/fsr/xfs_fsr.c
+index 40c2e6f..4f54059 100644
+--- a/fsr/xfs_fsr.c
++++ b/fsr/xfs_fsr.c
+@@ -35,7 +35,9 @@
+ #include <sys/wait.h>
+ #include <sys/vfs.h>
+ #include <sys/statvfs.h>
++#ifndef __UCLIBC__
+ #include <sys/xattr.h>
++#endif
+
+
+ #ifndef XFS_XFLAG_NODEFRAG
+@@ -990,6 +992,7 @@ fsr_setup_attr_fork(
+ int tfd,
+ xfs_bstat_t *bstatp)
+ {
++#ifndef __UCLIBC__
+ struct stat64 tstatbuf;
+ int i;
+ int last_forkoff = 0;
+@@ -1108,6 +1111,7 @@ fsr_setup_attr_fork(
+ out:
+ if (dflag)
+ fsrprintf(_("set temp attr\n"));
++#endif
+ return 0;
+ }
+
diff --git a/package/system/utils/xfsprogs/patches/140-no_po.patch b/package/system/utils/xfsprogs/patches/140-no_po.patch
new file mode 100644
index 0000000..f915a9c
--- /dev/null
+++ b/package/system/utils/xfsprogs/patches/140-no_po.patch
@@ -0,0 +1,20 @@
+diff -urN xfsprogs-3.1.7/Makefile xfsprogs-3.1.7.new/Makefile
+--- xfsprogs-3.1.7/Makefile 2011-11-18 00:30:24.000000000 +0100
++++ xfsprogs-3.1.7.new/Makefile 2012-04-20 14:15:48.641722955 +0200
+@@ -41,7 +41,7 @@
+
+ LIB_SUBDIRS = libxfs libxlog libxcmd libhandle libdisk
+ TOOL_SUBDIRS = copy db estimate fsck fsr growfs io logprint mkfs quota \
+- mdrestore repair rtcp m4 man doc po debian
++ mdrestore repair rtcp m4 man doc debian
+
+ SUBDIRS = include $(LIB_SUBDIRS) $(TOOL_SUBDIRS)
+
+@@ -135,7 +135,6 @@
+ $(Q)$(MAKE) $(MAKEOPTS) -C . $@
+ else
+ $(Q)$(MAKE) $(MAKEOPTS) $(SRCDIR)
+- $(Q)$(MAKE) $(MAKEOPTS) -C po
+ $(Q)$(MAKE) $(MAKEOPTS) source-link
+ $(Q)cd $(SRCDIR) && dpkg-buildpackage
+ endif
diff --git a/package/system/vsc73x5-ucode/.svn/entries b/package/system/vsc73x5-ucode/.svn/entries
new file mode 100644
index 0000000..1b4f3c3
--- /dev/null
+++ b/package/system/vsc73x5-ucode/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/system/vsc73x5-ucode
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+files
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+88c588fa93fd2c3a254cbf408b35f971
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2686
+
diff --git a/package/system/vsc73x5-ucode/.svn/text-base/Makefile.svn-base b/package/system/vsc73x5-ucode/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..3a07121
--- /dev/null
+++ b/package/system/vsc73x5-ucode/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,94 @@
+#
+# Copyright (C) 2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=vsc73x5-ucode
+PKG_RELEASE:=1
+
+PKG_SOURCE_URL:=http://mirror2.openwrt.org/sources
+
+PKG_SOURCE:=vsc73x5-ucode.tar.bz2
+PKG_BUILD_DIR:=$(BUILD_DIR)/vsc73x5-ucode
+
+PKG_MD5SUM:=b32e3debcd118f263c79199a7b5afa68
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/vsc73x5-defaults
+ SECTION:=net
+ CATEGORY:=Network
+ DEPENDS:=@TARGET_ar71xx
+ DEFAULT:=n
+ TITLE:=$(1)
+endef
+
+define Package/vsc73x5/install
+ $(INSTALL_DIR) $(1)/lib/firmware
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/$(2) $(1)/lib/firmware/$(3)
+endef
+
+define Package/vsc7385-ucode-ap83
+ $(call Package/vsc73x5-defaults,Vitesse VSC7385 microcode for the Atheros AP83 boards)
+endef
+
+define Package/vsc7385-ucode-ap83/description
+ This package contains the Atheros AP83 board specific microcode for
+ the Vitesse VSC7385 ethernet switch.
+endef
+
+define Package/vsc7385-ucode-ap83/install
+ $(call Package/vsc73x5/install,$(1),g5_Plus1_2_31_unmanaged_Atheros_v3.bin,vsc7385_ucode_ap83.bin)
+endef
+
+define Package/vsc7395-ucode-ap83
+ $(call Package/vsc73x5-defaults, Vitesse VSC7395 microcode for the Atheros AP83 boards)
+endef
+
+define Package/vsc7395-ucode-ap83/description
+ This package contains the Atheros AP83 board specific microcode for
+ the Vitesse VSC7395 ethernet switch.
+endef
+
+define Package/vsc7395-ucode-ap83/install
+ $(call Package/vsc73x5/install,$(1),g5_Plus1_2_31_unmanaged_Atheros_v4.bin,vsc7395_ucode_ap83.bin)
+endef
+
+define Package/vsc7385-ucode-pb44
+ $(call Package/vsc73x5-defaults, Vitesse VSC7395 microcode for the Atheros PB44 boards)
+endef
+
+define Package/vsc7385-ucode-pb44/description
+ This package contains the Atheros PB44 board specific microcode for
+ the Vitesse VSC7385 ethernet switch.
+endef
+
+define Package/vsc7385-ucode-pb44/install
+ $(call Package/vsc73x5/install,$(1),g5_Plus1_2_29b_unmanaged_Atheros_v5.bin,vsc7385_ucode_pb44.bin)
+endef
+
+define Package/vsc7395-ucode-pb44
+ $(call Package/vsc73x5-defaults, Vitesse VSC7395 microcode for the Atheros PB44 boards)
+endef
+
+define Package/vsc7395-ucode-pb44/description
+ This package contains the Atheros AP83 board specific microcode for
+ the Vitesse VSC7395 ethernet switch.
+endef
+
+define Package/vsc7395-ucode-pb44/install
+ $(call Package/vsc73x5/install,$(1),g5e_Plus1_2_29a_unmanaged_Atheros_v3.bin,vsc7395_ucode_pb44.bin)
+endef
+
+define Build/Compile
+
+endef
+
+$(eval $(call BuildPackage,vsc7385-ucode-ap83))
+$(eval $(call BuildPackage,vsc7395-ucode-ap83))
+$(eval $(call BuildPackage,vsc7385-ucode-pb44))
+$(eval $(call BuildPackage,vsc7395-ucode-pb44))
diff --git a/package/system/vsc73x5-ucode/Makefile b/package/system/vsc73x5-ucode/Makefile
new file mode 100644
index 0000000..3a07121
--- /dev/null
+++ b/package/system/vsc73x5-ucode/Makefile
@@ -0,0 +1,94 @@
+#
+# Copyright (C) 2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=vsc73x5-ucode
+PKG_RELEASE:=1
+
+PKG_SOURCE_URL:=http://mirror2.openwrt.org/sources
+
+PKG_SOURCE:=vsc73x5-ucode.tar.bz2
+PKG_BUILD_DIR:=$(BUILD_DIR)/vsc73x5-ucode
+
+PKG_MD5SUM:=b32e3debcd118f263c79199a7b5afa68
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/vsc73x5-defaults
+ SECTION:=net
+ CATEGORY:=Network
+ DEPENDS:=@TARGET_ar71xx
+ DEFAULT:=n
+ TITLE:=$(1)
+endef
+
+define Package/vsc73x5/install
+ $(INSTALL_DIR) $(1)/lib/firmware
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/$(2) $(1)/lib/firmware/$(3)
+endef
+
+define Package/vsc7385-ucode-ap83
+ $(call Package/vsc73x5-defaults,Vitesse VSC7385 microcode for the Atheros AP83 boards)
+endef
+
+define Package/vsc7385-ucode-ap83/description
+ This package contains the Atheros AP83 board specific microcode for
+ the Vitesse VSC7385 ethernet switch.
+endef
+
+define Package/vsc7385-ucode-ap83/install
+ $(call Package/vsc73x5/install,$(1),g5_Plus1_2_31_unmanaged_Atheros_v3.bin,vsc7385_ucode_ap83.bin)
+endef
+
+define Package/vsc7395-ucode-ap83
+ $(call Package/vsc73x5-defaults, Vitesse VSC7395 microcode for the Atheros AP83 boards)
+endef
+
+define Package/vsc7395-ucode-ap83/description
+ This package contains the Atheros AP83 board specific microcode for
+ the Vitesse VSC7395 ethernet switch.
+endef
+
+define Package/vsc7395-ucode-ap83/install
+ $(call Package/vsc73x5/install,$(1),g5_Plus1_2_31_unmanaged_Atheros_v4.bin,vsc7395_ucode_ap83.bin)
+endef
+
+define Package/vsc7385-ucode-pb44
+ $(call Package/vsc73x5-defaults, Vitesse VSC7395 microcode for the Atheros PB44 boards)
+endef
+
+define Package/vsc7385-ucode-pb44/description
+ This package contains the Atheros PB44 board specific microcode for
+ the Vitesse VSC7385 ethernet switch.
+endef
+
+define Package/vsc7385-ucode-pb44/install
+ $(call Package/vsc73x5/install,$(1),g5_Plus1_2_29b_unmanaged_Atheros_v5.bin,vsc7385_ucode_pb44.bin)
+endef
+
+define Package/vsc7395-ucode-pb44
+ $(call Package/vsc73x5-defaults, Vitesse VSC7395 microcode for the Atheros PB44 boards)
+endef
+
+define Package/vsc7395-ucode-pb44/description
+ This package contains the Atheros AP83 board specific microcode for
+ the Vitesse VSC7395 ethernet switch.
+endef
+
+define Package/vsc7395-ucode-pb44/install
+ $(call Package/vsc73x5/install,$(1),g5e_Plus1_2_29a_unmanaged_Atheros_v3.bin,vsc7395_ucode_pb44.bin)
+endef
+
+define Build/Compile
+
+endef
+
+$(eval $(call BuildPackage,vsc7385-ucode-ap83))
+$(eval $(call BuildPackage,vsc7395-ucode-ap83))
+$(eval $(call BuildPackage,vsc7385-ucode-pb44))
+$(eval $(call BuildPackage,vsc7395-ucode-pb44))
diff --git a/package/system/vsc73x5-ucode/files/.svn/entries b/package/system/vsc73x5-ucode/files/.svn/entries
new file mode 100644
index 0000000..aec1e67
--- /dev/null
+++ b/package/system/vsc73x5-ucode/files/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/system/vsc73x5-ucode/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+fe68b93ef8a3297479e2e782174fd31c
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+451
+
diff --git a/package/system/vsc73x5-ucode/files/.svn/text-base/Makefile.svn-base b/package/system/vsc73x5-ucode/files/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..550f51d
--- /dev/null
+++ b/package/system/vsc73x5-ucode/files/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,20 @@
+#
+# Copyright (C) 2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+CC:=gcc
+OBJCOPY:=objcopy
+
+all: g5_Plus1_2_31_unmanaged_Atheros_v3.bin \
+ g5_Plus1_2_31_unmanaged_Atheros_v4.bin \
+ g5_Plus1_2_29b_unmanaged_Atheros_v5.bin \
+ g5e_Plus1_2_29a_unmanaged_Atheros_v3.bin
+
+%.o: %.c
+ $(CC) $(CFLAGS) -c $^ -o $@
+
+%.bin: %.o
+ $(OBJCOPY) -O binary -j .data $^ $@
diff --git a/package/system/vsc73x5-ucode/files/Makefile b/package/system/vsc73x5-ucode/files/Makefile
new file mode 100644
index 0000000..550f51d
--- /dev/null
+++ b/package/system/vsc73x5-ucode/files/Makefile
@@ -0,0 +1,20 @@
+#
+# Copyright (C) 2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+CC:=gcc
+OBJCOPY:=objcopy
+
+all: g5_Plus1_2_31_unmanaged_Atheros_v3.bin \
+ g5_Plus1_2_31_unmanaged_Atheros_v4.bin \
+ g5_Plus1_2_29b_unmanaged_Atheros_v5.bin \
+ g5e_Plus1_2_29a_unmanaged_Atheros_v3.bin
+
+%.o: %.c
+ $(CC) $(CFLAGS) -c $^ -o $@
+
+%.bin: %.o
+ $(OBJCOPY) -O binary -j .data $^ $@
diff --git a/package/system/w1-gpio-custom/.svn/entries b/package/system/w1-gpio-custom/.svn/entries
new file mode 100644
index 0000000..a23b21f
--- /dev/null
+++ b/package/system/w1-gpio-custom/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/system/w1-gpio-custom
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+src
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+61896fa8f0da6b573f46834500c3072d
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1230
+
diff --git a/package/system/w1-gpio-custom/.svn/prop-base/Makefile.svn-base b/package/system/w1-gpio-custom/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/system/w1-gpio-custom/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/system/w1-gpio-custom/.svn/text-base/Makefile.svn-base b/package/system/w1-gpio-custom/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..bf50d1a
--- /dev/null
+++ b/package/system/w1-gpio-custom/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,54 @@
+#
+# Copyright (C) 2008-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=w1-gpio-custom
+PKG_RELEASE:=3
+
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/w1-gpio-custom
+ SUBMENU:=W1 support
+ TITLE:=Custom GPIO-based 1-wire device
+ DEPENDS:=kmod-w1 +kmod-w1-master-gpio
+ FILES:=$(PKG_BUILD_DIR)/w1-gpio-custom.ko
+ KCONFIG:=
+endef
+
+define KernelPackage/w1-gpio-custom/description
+ Kernel module to register a custom w1-gpio platform device.
+endef
+
+EXTRA_KCONFIG:= \
+ CONFIG_W1_MASTER_GPIO_CUSTOM=m
+
+EXTRA_CFLAGS:= \
+ $(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=m,%,$(filter %=m,$(EXTRA_KCONFIG)))) \
+ $(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=y,%,$(filter %=y,$(EXTRA_KCONFIG))))
+
+MAKE_OPTS:= \
+ ARCH="$(LINUX_KARCH)" \
+ CROSS_COMPILE="$(TARGET_CROSS)" \
+ SUBDIRS="$(PKG_BUILD_DIR)" \
+ EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \
+ $(EXTRA_KCONFIG)
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+define Build/Compile
+ $(MAKE) -C "$(LINUX_DIR)" \
+ $(MAKE_OPTS) \
+ modules
+endef
+
+$(eval $(call KernelPackage,w1-gpio-custom))
+
diff --git a/package/system/w1-gpio-custom/Makefile b/package/system/w1-gpio-custom/Makefile
new file mode 100644
index 0000000..bf50d1a
--- /dev/null
+++ b/package/system/w1-gpio-custom/Makefile
@@ -0,0 +1,54 @@
+#
+# Copyright (C) 2008-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=w1-gpio-custom
+PKG_RELEASE:=3
+
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/w1-gpio-custom
+ SUBMENU:=W1 support
+ TITLE:=Custom GPIO-based 1-wire device
+ DEPENDS:=kmod-w1 +kmod-w1-master-gpio
+ FILES:=$(PKG_BUILD_DIR)/w1-gpio-custom.ko
+ KCONFIG:=
+endef
+
+define KernelPackage/w1-gpio-custom/description
+ Kernel module to register a custom w1-gpio platform device.
+endef
+
+EXTRA_KCONFIG:= \
+ CONFIG_W1_MASTER_GPIO_CUSTOM=m
+
+EXTRA_CFLAGS:= \
+ $(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=m,%,$(filter %=m,$(EXTRA_KCONFIG)))) \
+ $(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=y,%,$(filter %=y,$(EXTRA_KCONFIG))))
+
+MAKE_OPTS:= \
+ ARCH="$(LINUX_KARCH)" \
+ CROSS_COMPILE="$(TARGET_CROSS)" \
+ SUBDIRS="$(PKG_BUILD_DIR)" \
+ EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \
+ $(EXTRA_KCONFIG)
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+define Build/Compile
+ $(MAKE) -C "$(LINUX_DIR)" \
+ $(MAKE_OPTS) \
+ modules
+endef
+
+$(eval $(call KernelPackage,w1-gpio-custom))
+
diff --git a/package/system/w1-gpio-custom/src/.svn/entries b/package/system/w1-gpio-custom/src/.svn/entries
new file mode 100644
index 0000000..01d0b51
--- /dev/null
+++ b/package/system/w1-gpio-custom/src/.svn/entries
@@ -0,0 +1,130 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/system/w1-gpio-custom/src
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+Kconfig
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+3647f69ea1590802a71d93353ffc7e53
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+109
+
+w1-gpio-custom.c
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+bce0fe005af86361059cdcb9e19bd73e
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4427
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:15.000000Z
+32b89ed5802ec0431f10434b635aa90d
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+55
+
diff --git a/package/system/w1-gpio-custom/src/.svn/prop-base/Makefile.svn-base b/package/system/w1-gpio-custom/src/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/system/w1-gpio-custom/src/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/system/w1-gpio-custom/src/.svn/prop-base/w1-gpio-custom.c.svn-base b/package/system/w1-gpio-custom/src/.svn/prop-base/w1-gpio-custom.c.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/system/w1-gpio-custom/src/.svn/prop-base/w1-gpio-custom.c.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/system/w1-gpio-custom/src/.svn/text-base/Kconfig.svn-base b/package/system/w1-gpio-custom/src/.svn/text-base/Kconfig.svn-base
new file mode 100644
index 0000000..74b9226
--- /dev/null
+++ b/package/system/w1-gpio-custom/src/.svn/text-base/Kconfig.svn-base
@@ -0,0 +1,4 @@
+config W1_MASTER_GPIO_CUSTOM
+ tristate "Custom GPIO-based W1 driver"
+ depends on GENERIC_GPIO
+ select W1_GPIO \ No newline at end of file
diff --git a/package/system/w1-gpio-custom/src/.svn/text-base/Makefile.svn-base b/package/system/w1-gpio-custom/src/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..6a52743
--- /dev/null
+++ b/package/system/w1-gpio-custom/src/.svn/text-base/Makefile.svn-base
@@ -0,0 +1 @@
+obj-${CONFIG_W1_MASTER_GPIO_CUSTOM} += w1-gpio-custom.o \ No newline at end of file
diff --git a/package/system/w1-gpio-custom/src/.svn/text-base/w1-gpio-custom.c.svn-base b/package/system/w1-gpio-custom/src/.svn/text-base/w1-gpio-custom.c.svn-base
new file mode 100644
index 0000000..96cfcab
--- /dev/null
+++ b/package/system/w1-gpio-custom/src/.svn/text-base/w1-gpio-custom.c.svn-base
@@ -0,0 +1,185 @@
+/*
+ * Custom GPIO-based W1 driver
+ *
+ * Copyright (C) 2007 Gabor Juhos <juhosg at openwrt.org>
+ * Copyright (C) 2008 Bifferos <bifferos at yahoo.co.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * ---------------------------------------------------------------------------
+ *
+ * The behaviour of this driver can be altered by setting some parameters
+ * from the insmod command line.
+ *
+ * The following parameters are adjustable:
+ *
+ * bus0 These four arguments must be arrays of
+ * bus1 3 unsigned integers as follows:
+ * bus2
+ * bus3 <id>,<pin>,<od>
+ *
+ * where:
+ *
+ * <id> ID to used as device_id for the corresponding bus (required)
+ * <sda> GPIO pin ID of data pin (required)
+ * <od> Pin is configured as open drain.
+ *
+ * See include/w1-gpio.h for more information about the parameters.
+ *
+ * If this driver is built into the kernel, you can use the following kernel
+ * command line parameters, with the same values as the corresponding module
+ * parameters listed above:
+ *
+ * w1-gpio-custom.bus0
+ * w1-gpio-custom.bus1
+ * w1-gpio-custom.bus2
+ * w1-gpio-custom.bus3
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+
+#include <linux/w1-gpio.h>
+
+#define DRV_NAME "w1-gpio-custom"
+#define DRV_DESC "Custom GPIO-based W1 driver"
+#define DRV_VERSION "0.1.1"
+
+#define PFX DRV_NAME ": "
+
+#define BUS_PARAM_ID 0
+#define BUS_PARAM_PIN 1
+#define BUS_PARAM_OD 2
+
+#define BUS_PARAM_REQUIRED 3
+#define BUS_PARAM_COUNT 3
+#define BUS_COUNT_MAX 4
+
+static unsigned int bus0[BUS_PARAM_COUNT] __initdata;
+static unsigned int bus1[BUS_PARAM_COUNT] __initdata;
+static unsigned int bus2[BUS_PARAM_COUNT] __initdata;
+static unsigned int bus3[BUS_PARAM_COUNT] __initdata;
+
+static unsigned int bus_nump[BUS_COUNT_MAX] __initdata;
+
+#define BUS_PARM_DESC " config -> id,pin,od"
+
+module_param_array(bus0, uint, &bus_nump[0], 0);
+MODULE_PARM_DESC(bus0, "bus0" BUS_PARM_DESC);
+module_param_array(bus1, uint, &bus_nump[1], 0);
+MODULE_PARM_DESC(bus1, "bus1" BUS_PARM_DESC);
+module_param_array(bus2, uint, &bus_nump[2], 0);
+MODULE_PARM_DESC(bus2, "bus2" BUS_PARM_DESC);
+module_param_array(bus3, uint, &bus_nump[3], 0);
+MODULE_PARM_DESC(bus3, "bus3" BUS_PARM_DESC);
+
+static struct platform_device *devices[BUS_COUNT_MAX];
+static unsigned int nr_devices;
+
+static void w1_gpio_custom_cleanup(void)
+{
+ int i;
+
+ for (i = 0; i < nr_devices; i++)
+ if (devices[i])
+ platform_device_put(devices[i]);
+}
+
+static int __init w1_gpio_custom_add_one(unsigned int id, unsigned int *params)
+{
+ struct platform_device *pdev;
+ struct w1_gpio_platform_data pdata;
+ int err;
+
+ if (!bus_nump[id])
+ return 0;
+
+ if (bus_nump[id] < BUS_PARAM_REQUIRED) {
+ printk(KERN_ERR PFX "not enough parameters for bus%d\n", id);
+ err = -EINVAL;
+ goto err;
+ }
+
+ pdev = platform_device_alloc("w1-gpio", params[BUS_PARAM_ID]);
+ if (!pdev) {
+ err = -ENOMEM;
+ goto err;
+ }
+
+ pdata.pin = params[BUS_PARAM_PIN];
+ pdata.is_open_drain = params[BUS_PARAM_OD] ? 1:0;
+ pdata.enable_external_pullup = NULL;
+
+ err = platform_device_add_data(pdev, &pdata, sizeof(pdata));
+ if (err)
+ goto err_put;
+
+ err = platform_device_add(pdev);
+ if (err)
+ goto err_put;
+
+ devices[nr_devices++] = pdev;
+ return 0;
+
+ err_put:
+ platform_device_put(pdev);
+ err:
+ return err;
+}
+
+static int __init w1_gpio_custom_probe(void)
+{
+ int err;
+
+ nr_devices = 0;
+ printk(KERN_INFO DRV_DESC " version " DRV_VERSION "\n");
+
+ err = w1_gpio_custom_add_one(0, bus0);
+ if (err) goto err;
+
+ err = w1_gpio_custom_add_one(1, bus1);
+ if (err) goto err;
+
+ err = w1_gpio_custom_add_one(2, bus2);
+ if (err) goto err;
+
+ err = w1_gpio_custom_add_one(3, bus3);
+ if (err) goto err;
+
+ if (!nr_devices) {
+ printk(KERN_ERR PFX "no bus parameter(s) specified\n");
+ err = -ENODEV;
+ goto err;
+ }
+
+ return 0;
+
+err:
+ w1_gpio_custom_cleanup();
+ return err;
+}
+
+#ifdef MODULE
+static int __init w1_gpio_custom_init(void)
+{
+ return w1_gpio_custom_probe();
+}
+module_init(w1_gpio_custom_init);
+
+static void __exit w1_gpio_custom_exit(void)
+{
+ w1_gpio_custom_cleanup();
+}
+module_exit(w1_gpio_custom_exit);
+#else
+subsys_initcall(w1_gpio_custom_probe);
+#endif /* MODULE*/
+
+MODULE_LICENSE("GPL v2");
+MODULE_AUTHOR("Bifferos <bifferos at yahoo.co.uk >");
+MODULE_DESCRIPTION(DRV_DESC);
+MODULE_VERSION(DRV_VERSION);
diff --git a/package/system/w1-gpio-custom/src/Kconfig b/package/system/w1-gpio-custom/src/Kconfig
new file mode 100644
index 0000000..74b9226
--- /dev/null
+++ b/package/system/w1-gpio-custom/src/Kconfig
@@ -0,0 +1,4 @@
+config W1_MASTER_GPIO_CUSTOM
+ tristate "Custom GPIO-based W1 driver"
+ depends on GENERIC_GPIO
+ select W1_GPIO \ No newline at end of file
diff --git a/package/system/w1-gpio-custom/src/Makefile b/package/system/w1-gpio-custom/src/Makefile
new file mode 100644
index 0000000..6a52743
--- /dev/null
+++ b/package/system/w1-gpio-custom/src/Makefile
@@ -0,0 +1 @@
+obj-${CONFIG_W1_MASTER_GPIO_CUSTOM} += w1-gpio-custom.o \ No newline at end of file
diff --git a/package/system/w1-gpio-custom/src/w1-gpio-custom.c b/package/system/w1-gpio-custom/src/w1-gpio-custom.c
new file mode 100644
index 0000000..96cfcab
--- /dev/null
+++ b/package/system/w1-gpio-custom/src/w1-gpio-custom.c
@@ -0,0 +1,185 @@
+/*
+ * Custom GPIO-based W1 driver
+ *
+ * Copyright (C) 2007 Gabor Juhos <juhosg at openwrt.org>
+ * Copyright (C) 2008 Bifferos <bifferos at yahoo.co.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * ---------------------------------------------------------------------------
+ *
+ * The behaviour of this driver can be altered by setting some parameters
+ * from the insmod command line.
+ *
+ * The following parameters are adjustable:
+ *
+ * bus0 These four arguments must be arrays of
+ * bus1 3 unsigned integers as follows:
+ * bus2
+ * bus3 <id>,<pin>,<od>
+ *
+ * where:
+ *
+ * <id> ID to used as device_id for the corresponding bus (required)
+ * <sda> GPIO pin ID of data pin (required)
+ * <od> Pin is configured as open drain.
+ *
+ * See include/w1-gpio.h for more information about the parameters.
+ *
+ * If this driver is built into the kernel, you can use the following kernel
+ * command line parameters, with the same values as the corresponding module
+ * parameters listed above:
+ *
+ * w1-gpio-custom.bus0
+ * w1-gpio-custom.bus1
+ * w1-gpio-custom.bus2
+ * w1-gpio-custom.bus3
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+
+#include <linux/w1-gpio.h>
+
+#define DRV_NAME "w1-gpio-custom"
+#define DRV_DESC "Custom GPIO-based W1 driver"
+#define DRV_VERSION "0.1.1"
+
+#define PFX DRV_NAME ": "
+
+#define BUS_PARAM_ID 0
+#define BUS_PARAM_PIN 1
+#define BUS_PARAM_OD 2
+
+#define BUS_PARAM_REQUIRED 3
+#define BUS_PARAM_COUNT 3
+#define BUS_COUNT_MAX 4
+
+static unsigned int bus0[BUS_PARAM_COUNT] __initdata;
+static unsigned int bus1[BUS_PARAM_COUNT] __initdata;
+static unsigned int bus2[BUS_PARAM_COUNT] __initdata;
+static unsigned int bus3[BUS_PARAM_COUNT] __initdata;
+
+static unsigned int bus_nump[BUS_COUNT_MAX] __initdata;
+
+#define BUS_PARM_DESC " config -> id,pin,od"
+
+module_param_array(bus0, uint, &bus_nump[0], 0);
+MODULE_PARM_DESC(bus0, "bus0" BUS_PARM_DESC);
+module_param_array(bus1, uint, &bus_nump[1], 0);
+MODULE_PARM_DESC(bus1, "bus1" BUS_PARM_DESC);
+module_param_array(bus2, uint, &bus_nump[2], 0);
+MODULE_PARM_DESC(bus2, "bus2" BUS_PARM_DESC);
+module_param_array(bus3, uint, &bus_nump[3], 0);
+MODULE_PARM_DESC(bus3, "bus3" BUS_PARM_DESC);
+
+static struct platform_device *devices[BUS_COUNT_MAX];
+static unsigned int nr_devices;
+
+static void w1_gpio_custom_cleanup(void)
+{
+ int i;
+
+ for (i = 0; i < nr_devices; i++)
+ if (devices[i])
+ platform_device_put(devices[i]);
+}
+
+static int __init w1_gpio_custom_add_one(unsigned int id, unsigned int *params)
+{
+ struct platform_device *pdev;
+ struct w1_gpio_platform_data pdata;
+ int err;
+
+ if (!bus_nump[id])
+ return 0;
+
+ if (bus_nump[id] < BUS_PARAM_REQUIRED) {
+ printk(KERN_ERR PFX "not enough parameters for bus%d\n", id);
+ err = -EINVAL;
+ goto err;
+ }
+
+ pdev = platform_device_alloc("w1-gpio", params[BUS_PARAM_ID]);
+ if (!pdev) {
+ err = -ENOMEM;
+ goto err;
+ }
+
+ pdata.pin = params[BUS_PARAM_PIN];
+ pdata.is_open_drain = params[BUS_PARAM_OD] ? 1:0;
+ pdata.enable_external_pullup = NULL;
+
+ err = platform_device_add_data(pdev, &pdata, sizeof(pdata));
+ if (err)
+ goto err_put;
+
+ err = platform_device_add(pdev);
+ if (err)
+ goto err_put;
+
+ devices[nr_devices++] = pdev;
+ return 0;
+
+ err_put:
+ platform_device_put(pdev);
+ err:
+ return err;
+}
+
+static int __init w1_gpio_custom_probe(void)
+{
+ int err;
+
+ nr_devices = 0;
+ printk(KERN_INFO DRV_DESC " version " DRV_VERSION "\n");
+
+ err = w1_gpio_custom_add_one(0, bus0);
+ if (err) goto err;
+
+ err = w1_gpio_custom_add_one(1, bus1);
+ if (err) goto err;
+
+ err = w1_gpio_custom_add_one(2, bus2);
+ if (err) goto err;
+
+ err = w1_gpio_custom_add_one(3, bus3);
+ if (err) goto err;
+
+ if (!nr_devices) {
+ printk(KERN_ERR PFX "no bus parameter(s) specified\n");
+ err = -ENODEV;
+ goto err;
+ }
+
+ return 0;
+
+err:
+ w1_gpio_custom_cleanup();
+ return err;
+}
+
+#ifdef MODULE
+static int __init w1_gpio_custom_init(void)
+{
+ return w1_gpio_custom_probe();
+}
+module_init(w1_gpio_custom_init);
+
+static void __exit w1_gpio_custom_exit(void)
+{
+ w1_gpio_custom_cleanup();
+}
+module_exit(w1_gpio_custom_exit);
+#else
+subsys_initcall(w1_gpio_custom_probe);
+#endif /* MODULE*/
+
+MODULE_LICENSE("GPL v2");
+MODULE_AUTHOR("Bifferos <bifferos at yahoo.co.uk >");
+MODULE_DESCRIPTION(DRV_DESC);
+MODULE_VERSION(DRV_VERSION);
diff --git a/package/system/wrt55agv2-spidevs/.svn/entries b/package/system/wrt55agv2-spidevs/.svn/entries
new file mode 100644
index 0000000..2c55c39
--- /dev/null
+++ b/package/system/wrt55agv2-spidevs/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/system/wrt55agv2-spidevs
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+src
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+f93a095da9552d8f9533827406df813f
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1354
+
diff --git a/package/system/wrt55agv2-spidevs/.svn/prop-base/Makefile.svn-base b/package/system/wrt55agv2-spidevs/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/system/wrt55agv2-spidevs/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/system/wrt55agv2-spidevs/.svn/text-base/Makefile.svn-base b/package/system/wrt55agv2-spidevs/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..236c9a3
--- /dev/null
+++ b/package/system/wrt55agv2-spidevs/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,53 @@
+#
+# Copyright (C) 2008 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=wrt55agv2-spidevs
+PKG_RELEASE:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/wrt55agv2-spidevs
+ SUBMENU:=Other modules
+ TITLE:=WRT55AG v2 SPI devices support
+ DEPENDS:=@TARGET_atheros +kmod-spi-gpio-old +kmod-spi-ks8995
+ FILES:=$(PKG_BUILD_DIR)/wrt55agv2_spidevs.ko
+endef
+
+define KernelPackage/wrt55agv2-spidevs/description
+ Kernel module for the SPI devices on the WRT55AG v2 board.
+endef
+
+EXTRA_KCONFIG:= \
+ CONFIG_WRT55AGV2_SPIDEVS=m
+
+EXTRA_CFLAGS:= \
+ $(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=m,%,$(filter %=m,$(EXTRA_KCONFIG)))) \
+ $(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=y,%,$(filter %=y,$(EXTRA_KCONFIG)))) \
+
+MAKE_OPTS:= \
+ ARCH="$(LINUX_KARCH)" \
+ CROSS_COMPILE="$(TARGET_CROSS)" \
+ SUBDIRS="$(PKG_BUILD_DIR)" \
+ EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \
+ LINUXINCLUDE="-I$(LINUX_DIR)/include -I$(LINUX_DIR)/arch/mips/include -include generated/autoconf.h" \
+ $(EXTRA_KCONFIG)
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+define Build/Compile
+ $(MAKE) -C "$(LINUX_DIR)" \
+ $(MAKE_OPTS) \
+ modules
+endef
+
+$(eval $(call KernelPackage,wrt55agv2-spidevs))
diff --git a/package/system/wrt55agv2-spidevs/Makefile b/package/system/wrt55agv2-spidevs/Makefile
new file mode 100644
index 0000000..236c9a3
--- /dev/null
+++ b/package/system/wrt55agv2-spidevs/Makefile
@@ -0,0 +1,53 @@
+#
+# Copyright (C) 2008 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=wrt55agv2-spidevs
+PKG_RELEASE:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/wrt55agv2-spidevs
+ SUBMENU:=Other modules
+ TITLE:=WRT55AG v2 SPI devices support
+ DEPENDS:=@TARGET_atheros +kmod-spi-gpio-old +kmod-spi-ks8995
+ FILES:=$(PKG_BUILD_DIR)/wrt55agv2_spidevs.ko
+endef
+
+define KernelPackage/wrt55agv2-spidevs/description
+ Kernel module for the SPI devices on the WRT55AG v2 board.
+endef
+
+EXTRA_KCONFIG:= \
+ CONFIG_WRT55AGV2_SPIDEVS=m
+
+EXTRA_CFLAGS:= \
+ $(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=m,%,$(filter %=m,$(EXTRA_KCONFIG)))) \
+ $(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=y,%,$(filter %=y,$(EXTRA_KCONFIG)))) \
+
+MAKE_OPTS:= \
+ ARCH="$(LINUX_KARCH)" \
+ CROSS_COMPILE="$(TARGET_CROSS)" \
+ SUBDIRS="$(PKG_BUILD_DIR)" \
+ EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \
+ LINUXINCLUDE="-I$(LINUX_DIR)/include -I$(LINUX_DIR)/arch/mips/include -include generated/autoconf.h" \
+ $(EXTRA_KCONFIG)
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+define Build/Compile
+ $(MAKE) -C "$(LINUX_DIR)" \
+ $(MAKE_OPTS) \
+ modules
+endef
+
+$(eval $(call KernelPackage,wrt55agv2-spidevs))
diff --git a/package/system/wrt55agv2-spidevs/src/.svn/entries b/package/system/wrt55agv2-spidevs/src/.svn/entries
new file mode 100644
index 0000000..84f65d8
--- /dev/null
+++ b/package/system/wrt55agv2-spidevs/src/.svn/entries
@@ -0,0 +1,130 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/system/wrt55agv2-spidevs/src
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+Kconfig
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+cc2b38746a4558f5946fe2f35253f5c2
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+113
+
+wrt55agv2_spidevs.c
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+698788550fb6262e591945acd04228f0
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2736
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:14.000000Z
+8c38679fa1cd6e0f1436b410d782e68f
+2012-10-17T22:45:58.668189Z
+33830
+blogic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+54
+
diff --git a/package/system/wrt55agv2-spidevs/src/.svn/prop-base/Makefile.svn-base b/package/system/wrt55agv2-spidevs/src/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/system/wrt55agv2-spidevs/src/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/system/wrt55agv2-spidevs/src/.svn/prop-base/wrt55agv2_spidevs.c.svn-base b/package/system/wrt55agv2-spidevs/src/.svn/prop-base/wrt55agv2_spidevs.c.svn-base
new file mode 100644
index 0000000..bdbd305
--- /dev/null
+++ b/package/system/wrt55agv2-spidevs/src/.svn/prop-base/wrt55agv2_spidevs.c.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/system/wrt55agv2-spidevs/src/.svn/text-base/Kconfig.svn-base b/package/system/wrt55agv2-spidevs/src/.svn/text-base/Kconfig.svn-base
new file mode 100644
index 0000000..75e8242
--- /dev/null
+++ b/package/system/wrt55agv2-spidevs/src/.svn/text-base/Kconfig.svn-base
@@ -0,0 +1,3 @@
+config WRT55AGV2_SPIDEVS
+ tristate "SPI device support for the WRT55AG v2 board"
+ depends on SPI && MIPS_ATHEROS
diff --git a/package/system/wrt55agv2-spidevs/src/.svn/text-base/Makefile.svn-base b/package/system/wrt55agv2-spidevs/src/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..7f2ddb4
--- /dev/null
+++ b/package/system/wrt55agv2-spidevs/src/.svn/text-base/Makefile.svn-base
@@ -0,0 +1 @@
+obj-${CONFIG_WRT55AGV2_SPIDEVS} += wrt55agv2_spidevs.o \ No newline at end of file
diff --git a/package/system/wrt55agv2-spidevs/src/.svn/text-base/wrt55agv2_spidevs.c.svn-base b/package/system/wrt55agv2-spidevs/src/.svn/text-base/wrt55agv2_spidevs.c.svn-base
new file mode 100644
index 0000000..dfb7f6a
--- /dev/null
+++ b/package/system/wrt55agv2-spidevs/src/.svn/text-base/wrt55agv2_spidevs.c.svn-base
@@ -0,0 +1,114 @@
+/*
+ * SPI driver for the Linksys WRT55AG v2 board.
+ *
+ * Copyright (C) 2008 Gabor Juhos <juhosg at openwrt.org>
+ *
+ * This file was based on the mmc_over_gpio driver:
+ * Copyright 2008 Michael Buesch <mb@bu3sch.de>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ */
+
+#include <linux/platform_device.h>
+#include <linux/spi/spi_gpio_old.h>
+#include <linux/module.h>
+
+#define DRV_NAME "wrt55agv2-spidevs"
+#define DRV_DESC "SPI driver for the WRT55AG v2 board"
+#define DRV_VERSION "0.1.0"
+#define PFX DRV_NAME ": "
+
+#define GPIO_PIN_MISO 1
+#define GPIO_PIN_CS 2
+#define GPIO_PIN_CLK 3
+#define GPIO_PIN_MOSI 4
+
+static struct platform_device *spi_gpio_dev;
+
+static int __init boardinfo_setup(struct spi_board_info *bi,
+ struct spi_master *master, void *data)
+{
+
+ strlcpy(bi->modalias, "spi-ks8995", sizeof(bi->modalias));
+
+ bi->max_speed_hz = 5000000 /* Hz */;
+ bi->bus_num = master->bus_num;
+ bi->mode = SPI_MODE_0;
+
+ return 0;
+}
+
+static int __init wrt55agv2_spidevs_init(void)
+{
+ struct spi_gpio_platform_data pdata;
+ int err;
+
+ spi_gpio_dev = platform_device_alloc("spi-gpio", 0);
+ if (!spi_gpio_dev) {
+ printk(KERN_ERR PFX "no memory for spi-gpio device\n");
+ return -ENOMEM;
+ }
+
+ memset(&pdata, 0, sizeof(pdata));
+ pdata.pin_miso = GPIO_PIN_MISO;
+ pdata.pin_cs = GPIO_PIN_CS;
+ pdata.pin_clk = GPIO_PIN_CLK;
+ pdata.pin_mosi = GPIO_PIN_MOSI;
+ pdata.cs_activelow = 1;
+ pdata.no_spi_delay = 1;
+ pdata.boardinfo_setup = boardinfo_setup;
+ pdata.boardinfo_setup_data = NULL;
+
+ err = platform_device_add_data(spi_gpio_dev, &pdata, sizeof(pdata));
+ if (err)
+ goto err_free_dev;
+
+ err = platform_device_register(spi_gpio_dev);
+ if (err) {
+ printk(KERN_ERR PFX "unable to register device\n");
+ goto err_free_pdata;
+ }
+
+ return 0;
+
+err_free_pdata:
+ kfree(spi_gpio_dev->dev.platform_data);
+ spi_gpio_dev->dev.platform_data = NULL;
+
+err_free_dev:
+ platform_device_put(spi_gpio_dev);
+ return err;
+}
+
+static void __exit wrt55agv2_spidevs_cleanup(void)
+{
+ if (!spi_gpio_dev)
+ return;
+
+ platform_device_unregister(spi_gpio_dev);
+
+ kfree(spi_gpio_dev->dev.platform_data);
+ spi_gpio_dev->dev.platform_data = NULL;
+ platform_device_put(spi_gpio_dev);
+}
+
+static int __init wrt55agv2_spidevs_modinit(void)
+{
+ printk(KERN_INFO DRV_DESC " version " DRV_VERSION "\n");
+ return wrt55agv2_spidevs_init();
+}
+module_init(wrt55agv2_spidevs_modinit);
+
+static void __exit wrt55agv2_spidevs_modexit(void)
+{
+ wrt55agv2_spidevs_cleanup();
+}
+module_exit(wrt55agv2_spidevs_modexit);
+
+MODULE_DESCRIPTION(DRV_DESC);
+MODULE_VERSION(DRV_VERSION);
+MODULE_AUTHOR("Gabor Juhos <juhosg at openwrt.org>");
+MODULE_LICENSE("GPL v2");
+
diff --git a/package/system/wrt55agv2-spidevs/src/Kconfig b/package/system/wrt55agv2-spidevs/src/Kconfig
new file mode 100644
index 0000000..75e8242
--- /dev/null
+++ b/package/system/wrt55agv2-spidevs/src/Kconfig
@@ -0,0 +1,3 @@
+config WRT55AGV2_SPIDEVS
+ tristate "SPI device support for the WRT55AG v2 board"
+ depends on SPI && MIPS_ATHEROS
diff --git a/package/system/wrt55agv2-spidevs/src/Makefile b/package/system/wrt55agv2-spidevs/src/Makefile
new file mode 100644
index 0000000..7f2ddb4
--- /dev/null
+++ b/package/system/wrt55agv2-spidevs/src/Makefile
@@ -0,0 +1 @@
+obj-${CONFIG_WRT55AGV2_SPIDEVS} += wrt55agv2_spidevs.o \ No newline at end of file
diff --git a/package/system/wrt55agv2-spidevs/src/wrt55agv2_spidevs.c b/package/system/wrt55agv2-spidevs/src/wrt55agv2_spidevs.c
new file mode 100644
index 0000000..dfb7f6a
--- /dev/null
+++ b/package/system/wrt55agv2-spidevs/src/wrt55agv2_spidevs.c
@@ -0,0 +1,114 @@
+/*
+ * SPI driver for the Linksys WRT55AG v2 board.
+ *
+ * Copyright (C) 2008 Gabor Juhos <juhosg at openwrt.org>
+ *
+ * This file was based on the mmc_over_gpio driver:
+ * Copyright 2008 Michael Buesch <mb@bu3sch.de>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ */
+
+#include <linux/platform_device.h>
+#include <linux/spi/spi_gpio_old.h>
+#include <linux/module.h>
+
+#define DRV_NAME "wrt55agv2-spidevs"
+#define DRV_DESC "SPI driver for the WRT55AG v2 board"
+#define DRV_VERSION "0.1.0"
+#define PFX DRV_NAME ": "
+
+#define GPIO_PIN_MISO 1
+#define GPIO_PIN_CS 2
+#define GPIO_PIN_CLK 3
+#define GPIO_PIN_MOSI 4
+
+static struct platform_device *spi_gpio_dev;
+
+static int __init boardinfo_setup(struct spi_board_info *bi,
+ struct spi_master *master, void *data)
+{
+
+ strlcpy(bi->modalias, "spi-ks8995", sizeof(bi->modalias));
+
+ bi->max_speed_hz = 5000000 /* Hz */;
+ bi->bus_num = master->bus_num;
+ bi->mode = SPI_MODE_0;
+
+ return 0;
+}
+
+static int __init wrt55agv2_spidevs_init(void)
+{
+ struct spi_gpio_platform_data pdata;
+ int err;
+
+ spi_gpio_dev = platform_device_alloc("spi-gpio", 0);
+ if (!spi_gpio_dev) {
+ printk(KERN_ERR PFX "no memory for spi-gpio device\n");
+ return -ENOMEM;
+ }
+
+ memset(&pdata, 0, sizeof(pdata));
+ pdata.pin_miso = GPIO_PIN_MISO;
+ pdata.pin_cs = GPIO_PIN_CS;
+ pdata.pin_clk = GPIO_PIN_CLK;
+ pdata.pin_mosi = GPIO_PIN_MOSI;
+ pdata.cs_activelow = 1;
+ pdata.no_spi_delay = 1;
+ pdata.boardinfo_setup = boardinfo_setup;
+ pdata.boardinfo_setup_data = NULL;
+
+ err = platform_device_add_data(spi_gpio_dev, &pdata, sizeof(pdata));
+ if (err)
+ goto err_free_dev;
+
+ err = platform_device_register(spi_gpio_dev);
+ if (err) {
+ printk(KERN_ERR PFX "unable to register device\n");
+ goto err_free_pdata;
+ }
+
+ return 0;
+
+err_free_pdata:
+ kfree(spi_gpio_dev->dev.platform_data);
+ spi_gpio_dev->dev.platform_data = NULL;
+
+err_free_dev:
+ platform_device_put(spi_gpio_dev);
+ return err;
+}
+
+static void __exit wrt55agv2_spidevs_cleanup(void)
+{
+ if (!spi_gpio_dev)
+ return;
+
+ platform_device_unregister(spi_gpio_dev);
+
+ kfree(spi_gpio_dev->dev.platform_data);
+ spi_gpio_dev->dev.platform_data = NULL;
+ platform_device_put(spi_gpio_dev);
+}
+
+static int __init wrt55agv2_spidevs_modinit(void)
+{
+ printk(KERN_INFO DRV_DESC " version " DRV_VERSION "\n");
+ return wrt55agv2_spidevs_init();
+}
+module_init(wrt55agv2_spidevs_modinit);
+
+static void __exit wrt55agv2_spidevs_modexit(void)
+{
+ wrt55agv2_spidevs_cleanup();
+}
+module_exit(wrt55agv2_spidevs_modexit);
+
+MODULE_DESCRIPTION(DRV_DESC);
+MODULE_VERSION(DRV_VERSION);
+MODULE_AUTHOR("Gabor Juhos <juhosg at openwrt.org>");
+MODULE_LICENSE("GPL v2");
+
diff --git a/package/toolchain/.svn/entries b/package/toolchain/.svn/entries
new file mode 100644
index 0000000..2f1bd20
--- /dev/null
+++ b/package/toolchain/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/toolchain
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-02-26T16:40:02.784273Z
+35810
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+eglibc-files
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+dcb13ddad32b372190137ff52593561f
+2013-02-26T16:40:02.784273Z
+35810
+florian
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+15728
+
diff --git a/package/toolchain/.svn/prop-base/Makefile.svn-base b/package/toolchain/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..8e522ae
--- /dev/null
+++ b/package/toolchain/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:copyright
+V 30
+Copyright (C) 2006 OpenWrt.org
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/toolchain/.svn/text-base/Makefile.svn-base b/package/toolchain/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..b9d582e
--- /dev/null
+++ b/package/toolchain/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,596 @@
+#
+# Copyright (C) 2007-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+PKG_NAME:=toolchain
+PKG_RELEASE:=1
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+
+ifneq ($(DUMP),1)
+ LIBGCC_VERSION:=$(GCC_VERSION)
+else
+ LIBC_VERSION:=<LIBC_VERSION>
+ LIBGCC_VERSION:=<LIBGCC_VERSION>
+endif
+
+define Package/gcc/Default
+ SECTION:=libs
+ CATEGORY:=Base system
+ URL:=http://gcc.gnu.org/
+ VERSION:=$(LIBGCC_VERSION)-$(PKG_RELEASE)
+endef
+
+define Package/libgcc
+$(call Package/gcc/Default)
+ TITLE:=GCC support library
+endef
+
+define Package/libgcc/config
+ menu "Configuration"
+ depends EXTERNAL_TOOLCHAIN && PACKAGE_libgcc
+
+ config LIBGCC_ROOT_DIR
+ string
+ prompt "libgcc shared library base directory"
+ depends EXTERNAL_TOOLCHAIN && PACKAGE_libgcc
+ default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
+ default "/" if NATIVE_TOOLCHAIN
+
+ config LIBGCC_FILE_SPEC
+ string
+ prompt "libgcc shared library files (use wildcards)"
+ depends EXTERNAL_TOOLCHAIN && PACKAGE_libgcc
+ default "./lib/libgcc_s.so.*"
+
+ endmenu
+endef
+
+
+define Package/libssp
+$(call Package/gcc/Default)
+ DEPENDS+=@SSP_SUPPORT
+ TITLE:=GCC support library
+endef
+
+define Package/libssp/config
+ menu "Configuration"
+ depends EXTERNAL_TOOLCHAIN && PACKAGE_libssp
+
+ config LIBSSP_ROOT_DIR
+ string
+ prompt "libssp shared library base directory"
+ depends EXTERNAL_TOOLCHAIN && PACKAGE_libssp
+ default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
+ default "/" if NATIVE_TOOLCHAIN
+
+ config LIBSSP_FILE_SPEC
+ string
+ prompt "libssp shared library files (use wildcards)"
+ depends EXTERNAL_TOOLCHAIN && PACKAGE_libssp
+ default "./lib/libssp.so.*"
+
+ endmenu
+endef
+
+
+define Package/libstdcpp
+$(call Package/gcc/Default)
+ NAME:=libstdc++
+ TITLE:=GNU Standard C++ Library v3
+ DEPENDS+=@INSTALL_LIBSTDCPP
+endef
+
+define Package/libstdcpp/config
+ menu "Configuration"
+ depends EXTERNAL_TOOLCHAIN && PACKAGE_libstdcpp
+
+ config LIBSTDCPP_ROOT_DIR
+ string
+ prompt "libstdcpp shared library base directory"
+ depends EXTERNAL_TOOLCHAIN && PACKAGE_libstdcpp
+ default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
+ default "/" if NATIVE_TOOLCHAIN
+
+ config LIBSTDCPP_FILE_SPEC
+ string
+ prompt "libstdc++ shared library files (use wildcards)"
+ depends EXTERNAL_TOOLCHAIN && PACKAGE_libstdcpp
+ default "./lib/libstdc++.so.*"
+
+ endmenu
+endef
+
+
+define Package/libc/Default
+ SECTION:=libs
+ CATEGORY:=Base system
+ VERSION:=$(LIBC_VERSION)-$(PKG_RELEASE)
+ DEPENDS:=+libgcc
+ URL:=$(LIBC_URL)
+ PKG_FLAGS:=hold essential
+endef
+
+
+define Package/libc
+$(call Package/libc/Default)
+ TITLE:=C library
+endef
+
+define Package/libc/config
+ menu "Configuration"
+ depends EXTERNAL_TOOLCHAIN && PACKAGE_libc
+
+ config LIBC_ROOT_DIR
+ string
+ prompt "libc shared library base directory"
+ depends EXTERNAL_TOOLCHAIN && PACKAGE_libc
+ default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
+ default "/" if NATIVE_TOOLCHAIN
+
+ config LIBC_FILE_SPEC
+ string
+ prompt "libc shared library files (use wildcards)"
+ depends EXTERNAL_TOOLCHAIN && PACKAGE_libc
+ default "./lib/ld{-*.so,-linux*.so.*} ./lib/lib{anl,c,cidn,crypt,dl,m,nsl,nss_dns,nss_files,resolv,util}{-*.so,.so.*}"
+
+ endmenu
+endef
+
+
+define Package/libpthread
+$(call Package/libc/Default)
+ TITLE:=POSIX thread library
+endef
+
+define Package/libpthread/config
+ menu "Configuration"
+ depends EXTERNAL_TOOLCHAIN && PACKAGE_libpthread
+
+ config LIBPTHREAD_ROOT_DIR
+ string
+ prompt "libpthread shared library base directory"
+ depends EXTERNAL_TOOLCHAIN && PACKAGE_libpthread
+ default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
+ default "/" if NATIVE_TOOLCHAIN
+
+ config LIBPTHREAD_FILE_SPEC
+ string
+ prompt "libpthread shared library files (use wildcards)"
+ depends EXTERNAL_TOOLCHAIN && PACKAGE_libpthread
+ default "./lib/libpthread{-*.so,.so.*}"
+
+ endmenu
+endef
+
+
+define Package/libthread-db
+$(call Package/libc/Default)
+ DEPENDS:=@!USE_MUSL
+ TITLE:=POSIX thread library debugging support
+endef
+
+define Package/librt
+$(call Package/libc/Default)
+ TITLE:=POSIX.1b RealTime extension library
+ DEPENDS:=+libpthread
+endef
+
+define Package/librt/config
+ menu "Configuration"
+ depends EXTERNAL_TOOLCHAIN && PACKAGE_librt
+
+ config LIBRT_ROOT_DIR
+ string
+ prompt "librt shared library base directory"
+ depends EXTERNAL_TOOLCHAIN && PACKAGE_librt
+ default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
+ default "/" if NATIVE_TOOLCHAIN
+
+ config LIBRT_FILE_SPEC
+ string
+ prompt "librt shared library files (use wildcards)"
+ depends EXTERNAL_TOOLCHAIN && PACKAGE_librt
+ default "./lib/librt{-*.so,.so.*}"
+
+ endmenu
+endef
+
+
+define Package/libgfortran
+$(call Package/gcc/Default)
+ TITLE:=GFortran support library
+ DEPENDS+=@INSTALL_GFORTRAN
+endef
+
+define Package/libgfortran/config
+ menu "Configuration"
+ depends EXTERNAL_TOOLCHAIN && PACKAGE_libgfortran
+
+ config LIBGFORTRAN_ROOT_DIR
+ string
+ prompt "libgfortran shared library base directory"
+ depends EXTERNAL_TOOLCHAIN && PACKAGE_libgfortran
+ default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
+ default "/" if NATIVE_TOOLCHAIN
+
+ config LIBGFORTRAN_FILE_SPEC
+ string
+ prompt "libgfortran shared library files (use wildcards)"
+ depends EXTERNAL_TOOLCHAIN && PACKAGE_libgfortran
+ default "./usr/lib/libgfortran.so.*"
+
+ endmenu
+endef
+
+define Package/ldd
+$(call Package/libc/Default)
+ DEPENDS:=@!USE_MUSL
+ SECTION:=utils
+ CATEGORY:=Utilities
+ TITLE:=LDD trace utility
+endef
+
+define Package/ldd/config
+ menu "Configuration"
+ depends EXTERNAL_TOOLCHAIN && PACKAGE_ldd
+
+ config LDD_ROOT_DIR
+ string
+ prompt "ldd trace utility base directory"
+ depends EXTERNAL_TOOLCHAIN && PACKAGE_ldd
+ default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
+ default "/" if NATIVE_TOOLCHAIN
+
+ config LDD_FILE_SPEC
+ string
+ prompt "ldd trace utility file"
+ depends EXTERNAL_TOOLCHAIN && PACKAGE_ldd
+ default "./usr/bin/ldd"
+
+ endmenu
+endef
+
+
+define Package/ldconfig
+$(call Package/libc/Default)
+ DEPENDS:=@!USE_MUSL
+ SECTION:=utils
+ CATEGORY:=Utilities
+ TITLE:=Shared library path configuration
+endef
+
+define Package/ldconfig/config
+ menu "Configuration"
+ depends EXTERNAL_TOOLCHAIN && PACKAGE_ldconfig
+
+ config LDCONFIG_ROOT_DIR
+ string
+ prompt "ldconfig base directory"
+ depends EXTERNAL_TOOLCHAIN && PACKAGE_ldconfig
+ default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
+ default "/" if NATIVE_TOOLCHAIN
+
+ config LDCONFIG_FILE_SPEC
+ string
+ prompt "ldconfig file"
+ depends EXTERNAL_TOOLCHAIN && PACKAGE_ldconfig
+ default "./sbin/ldconfig"
+
+ endmenu
+endef
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+endef
+
+LIBGCC_A=$(wildcard $(TOOLCHAIN_DIR)/lib/gcc/*/*/libgcc_pic.a)
+LIBGCC_MAP=$(wildcard $(TOOLCHAIN_DIR)/lib/gcc/*/*/libgcc.map)
+LIBGCC_SO=$(wildcard $(TOOLCHAIN_DIR)/lib/libgcc_s.so.*)
+ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),)
+ ifneq ($(if $(CONFIG_USE_UCLIBC),$(CONFIG_GCC_VERSION_LINARO)),)
+ BUILD_LIBGCC:=$(if $(CONFIG_avr32)$(CONFIG_m68k)$(CONFIG_powerpc),,$(PKG_BUILD_DIR)/libgcc_s.so.*)
+ endif
+endif
+
+ifneq ($(BUILD_LIBGCC),)
+ define Build/Compile/uClibc
+ $(SCRIPT_DIR)/relink-lib.sh \
+ "$(TARGET_CROSS)" \
+ "$(wildcard $(TOOLCHAIN_DIR)/lib/libc_so.a)" \
+ "$(wildcard $(TOOLCHAIN_DIR)/lib/libc_so.a)" \
+ "$(patsubst $(TOOLCHAIN_DIR)/lib/%,$(PKG_BUILD_DIR)/%,$(wildcard $(TOOLCHAIN_DIR)/lib/libuClibc-*.so))" \
+ -Wl,-init,__uClibc_init -Wl,-soname=libc.so.0 \
+ $(BUILD_LIBGCC)
+ $(SCRIPT_DIR)/relink-lib.sh \
+ "$(TARGET_CROSS)" \
+ "$(wildcard $(TOOLCHAIN_DIR)/lib/libcrypt-*.so)" \
+ "$(wildcard $(TOOLCHAIN_DIR)/lib/libcrypt_pic.a)" \
+ "$(patsubst $(TOOLCHAIN_DIR)/lib/%,$(PKG_BUILD_DIR)/%,$(wildcard $(TOOLCHAIN_DIR)/lib/libcrypt-*.so))" \
+ $(BUILD_LIBGCC) \
+ -Wl,-soname=libcrypt.so.0
+ $(SCRIPT_DIR)/relink-lib.sh \
+ "$(TARGET_CROSS)" \
+ "$(wildcard $(TOOLCHAIN_DIR)/lib/libm-*.so)" \
+ "$(wildcard $(TOOLCHAIN_DIR)/lib/libm_pic.a)" \
+ "$(patsubst $(TOOLCHAIN_DIR)/lib/%,$(PKG_BUILD_DIR)/%,$(wildcard $(TOOLCHAIN_DIR)/lib/libm-*.so))" \
+ $(BUILD_LIBGCC) \
+ -Wl,-soname=libm.so.0
+ $(SCRIPT_DIR)/relink-lib.sh \
+ "$(TARGET_CROSS)" \
+ "$(wildcard $(TOOLCHAIN_DIR)/lib/libpthread-*.so)" \
+ "$(wildcard $(TOOLCHAIN_DIR)/lib/libpthread_so.a)" \
+ "$(patsubst $(TOOLCHAIN_DIR)/lib/%,$(PKG_BUILD_DIR)/%,$(wildcard $(TOOLCHAIN_DIR)/lib/libpthread-*.so))" \
+ -Wl,-z,nodelete,-z,initfirst,-init=__pthread_initialize_minimal_internal \
+ -ldl -lc $(BUILD_LIBGCC) \
+ -Wl,-soname=libpthread.so.0
+ endef
+ define Build/Compile/libgcc
+ $(SCRIPT_DIR)/relink-lib.sh \
+ "$(TARGET_CROSS)" \
+ "$(LIBGCC_SO)" \
+ "$(LIBGCC_A)" \
+ "$(patsubst $(TOOLCHAIN_DIR)/lib/%,$(PKG_BUILD_DIR)/%,$(LIBGCC_SO))" \
+ -Wl,--version-script=$(LIBGCC_MAP) -Wl,-soname=libgcc_s.so.1
+ endef
+else
+ define Build/Compile/uClibc
+ $(CP) \
+ $(TOOLCHAIN_DIR)/lib/libuClibc-*.so \
+ $(TOOLCHAIN_DIR)/lib/libcrypt-*.so \
+ $(TOOLCHAIN_DIR)/lib/libm-*.so \
+ $(TOOLCHAIN_DIR)/lib/libpthread-*.so \
+ $(PKG_BUILD_DIR)/
+ endef
+ ifneq ($(LIBGCC_SO),)
+ define Build/Compile/libgcc
+ $(CP) $(LIBGCC_SO) $(PKG_BUILD_DIR)/
+ endef
+ endif
+endif
+
+define Build/Compile/Default
+ $(call Build/Compile/libgcc)
+ $(call Build/Compile/$(LIBC))
+endef
+Build/Compile = $(Build/Compile/Default)
+
+ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),)
+
+ define Package/libgcc/install
+ $(INSTALL_DIR) $(1)/lib
+ $(if $(CONFIG_TARGET_avr32)$(CONFIG_TARGET_coldfire),,$(CP) $(TOOLCHAIN_DIR)/lib/libgcc_s.so.* $(1)/lib/)
+ endef
+
+ define Package/libgfortran/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(if $(CONFIG_TARGET_avr32)$(CONFIG_TARGET_coldfire),,$(CP) $(TOOLCHAIN_DIR)/lib/libgfortran.so.* $(1)/usr/lib/)
+ endef
+
+ define Package/libssp/install
+ $(INSTALL_DIR) $(1)/lib
+ $(CP) $(TOOLCHAIN_DIR)/lib/libssp.so.* $(1)/lib/
+ endef
+
+ define Package/libstdcpp/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(TOOLCHAIN_DIR)/lib/libstdc++.so.* $(1)/usr/lib/
+ endef
+
+ use_libutil=$(if $(CONFIG_EGLIBC_OPTION_EGLIBC_UTMP),libutil)
+ use_libnsl=$(if $(CONFIG_EGLIBC_OPTION_EGLIBC_NIS),libnsl)
+ use_nsswitch=$(if $(CONFIG_EGLIBC_OPTION_EGLIBC_NSSWITCH),libnss_dns libnss_files)
+
+ define Package/eglibc/install
+ $(CP) ./eglibc-files/* $(1)/
+ rm -f $(1)/etc/localtime
+ ln -sf /tmp/localtime $(1)/etc/localtime
+ $(INSTALL_DIR) $(1)/lib
+ $(CP) \
+ $(TOOLCHAIN_DIR)/lib/ld*.so.* \
+ $(TOOLCHAIN_DIR)/lib/ld-$(LIBC_SO_VERSION).so \
+ $(1)/lib/
+ for file in libanl libc libcidn libcrypt libdl libm $(use_libnsl) $(use_nsswitch) libresolv $(use_libutil); do \
+ for file in $(TOOLCHAIN_DIR)/lib/$$$$file.so.* $(TOOLCHAIN_DIR)/lib/$$$$file-$(LIBC_SO_VERSION).so; do \
+ if [ -e "$$$$file" ]; then \
+ $(CP) $$$$file $(1)/lib/; \
+ fi; \
+ done; \
+ done
+ endef
+
+ define Package/uClibc/install
+ $(INSTALL_DIR) $(1)/lib
+ $(CP) \
+ $(TOOLCHAIN_DIR)/lib/ld*-uClibc.so.* \
+ $(TOOLCHAIN_DIR)/lib/ld*-uClibc-$(LIBC_SO_VERSION).so \
+ $(1)/lib/
+ $(CP) \
+ $(TOOLCHAIN_DIR)/lib/libc.so.* \
+ $(TOOLCHAIN_DIR)/lib/libuClibc-$(LIBC_SO_VERSION).so \
+ $(1)/lib/
+ for file in libcrypt libdl libm libutil; do \
+ $(CP) \
+ $(TOOLCHAIN_DIR)/lib/$$$$file.so.* \
+ $(TOOLCHAIN_DIR)/lib/$$$$file-$(LIBC_SO_VERSION).so \
+ $(1)/lib/; \
+ done
+
+ $(CP) \
+ $(PKG_BUILD_DIR)/libuClibc-* \
+ $(PKG_BUILD_DIR)/libm-* \
+ $(PKG_BUILD_DIR)/libcrypt-* \
+ $(1)/lib/
+ endef
+
+ define Package/musl/install
+ $(INSTALL_DIR) $(1)/lib
+ $(CP) \
+ $(TOOLCHAIN_DIR)/lib/ld-musl-*.so* \
+ $(1)/lib/
+ $(CP) \
+ $(TOOLCHAIN_DIR)/lib/libc.so* \
+ $(1)/lib/
+ endef
+
+ define Package/libc/install
+ $(call Package/$(LIBC)/install,$1)
+ endef
+
+ define Package/libc/install_lib
+ $(CP) $(filter-out %/libdl_pic.a %/libpthread_pic.a %/libresolv_pic.a,$(wildcard $(TOOLCHAIN_DIR)/lib/lib*.a)) $(1)/lib/
+ $(if $(wildcard $(TOOLCHAIN_DIR)/lib/libc_so.a),$(CP) $(TOOLCHAIN_DIR)/lib/libc_so.a $(1)/lib/libc_pic.a)
+ $(if $(LIBGCC_MAP), \
+ $(CP) $(LIBGCC_A) $(1)/lib/libgcc_s_pic.a; \
+ $(CP) $(LIBGCC_MAP) $(1)/lib/libgcc_s_pic.map \
+ )
+ endef
+
+ define Package/libpthread/install
+ $(INSTALL_DIR) $(1)/lib
+ ifneq ($(CONFIG_USE_MUSL),y)
+ $(CP) \
+ $(TOOLCHAIN_DIR)/lib/libpthread.so.* \
+ $(if $(BUILD_LIBGCC),\
+ $(PKG_BUILD_DIR)/libpthread-$(LIBC_SO_VERSION).so, \
+ $(TOOLCHAIN_DIR)/lib/libpthread-$(LIBC_SO_VERSION).so \
+ ) \
+ $(1)/lib/
+ endif
+ endef
+
+ define Package/libthread-db/install
+ $(INSTALL_DIR) $(1)/lib
+ $(CP) \
+ $(TOOLCHAIN_DIR)/lib/libthread_db.so.* $(1)/lib
+ ifeq ($(USE_UCLIBC),y)
+ $(CP) \
+ $(TOOLCHAIN_DIR)/lib/libthread_db-$(LIBC_SO_VERSION).so \
+ $(1)/lib/
+ endif
+ endef
+
+ define Package/libpthread/install_lib
+ $(if $(wildcard $(TOOLCHAIN_DIR)/lib/libpthread_so.a),$(CP) $(TOOLCHAIN_DIR)/lib/libpthread_so.a $(1)/lib/libpthread_pic.a)
+ endef
+
+ define Package/librt/install
+ $(INSTALL_DIR) $(1)/lib
+ ifneq ($(CONFIG_USE_MUSL),y)
+ $(CP) \
+ $(TOOLCHAIN_DIR)/lib/librt.so.* \
+ $(TOOLCHAIN_DIR)/lib/librt-$(LIBC_SO_VERSION).so \
+ $(1)/lib/
+ endif
+ endef
+
+ define Package/ldd/install
+ $(INSTALL_DIR) $(1)/usr/bin/
+ $(CP) $(TOOLCHAIN_DIR)/bin/ldd $(1)/usr/bin/
+ endef
+
+ define Package/ldconfig/install
+ $(INSTALL_DIR) $(1)/sbin/
+ $(CP) $(TOOLCHAIN_DIR)/sbin/ldconfig $(1)/sbin/
+ endef
+
+else
+
+ define Package/libgcc/install
+ for file in $(call qstrip,$(CONFIG_LIBGCC_FILE_SPEC)); do \
+ dir=`dirname $$$$file` ; \
+ $(INSTALL_DIR) $(1)/$$$$dir ; \
+ $(CP) $(call qstrip,$(CONFIG_LIBGCC_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
+ done ; \
+ exit 0
+ endef
+
+ define Package/libgfortran/install
+ for file in $(call qstrip,$(CONFIG_LIBGFORTRAN_FILE_SPEC)); do \
+ dir=`dirname $$$$file` ; \
+ $(INSTALL_DIR) $(1)/$$$$dir ; \
+ $(CP) $(call qstrip,$(CONFIG_LIBGFORTRAN_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
+ done
+ endef
+
+ define Package/libssp/install
+ for file in $(call qstrip,$(CONFIG_LIBSSP_FILE_SPEC)); do \
+ dir=`dirname $$$$file` ; \
+ $(INSTALL_DIR) $(1)/$$$$dir ; \
+ $(CP) $(call qstrip,$(CONFIG_LIBSSP_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
+ done ; \
+ exit 0
+ endef
+
+ define Package/libstdcpp/install
+ for file in $(call qstrip,$(CONFIG_LIBSTDCPP_FILE_SPEC)); do \
+ dir=`dirname $$$$file` ; \
+ $(INSTALL_DIR) $(1)/$$$$dir ; \
+ $(CP) $(call qstrip,$(CONFIG_LIBSTDCPP_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
+ done ; \
+ exit 0
+ endef
+
+ define Package/libc/install
+ for file in $(call qstrip,$(CONFIG_LIBC_FILE_SPEC)); do \
+ dir=`dirname $$$$file` ; \
+ $(INSTALL_DIR) $(1)/$$$$dir ; \
+ $(CP) $(call qstrip,$(CONFIG_LIBC_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
+ done ; \
+ exit 0
+ endef
+
+ define Package/libpthread/install
+ for file in $(call qstrip,$(CONFIG_LIBPTHREAD_FILE_SPEC)); do \
+ dir=`dirname $$$$file` ; \
+ $(INSTALL_DIR) $(1)/$$$$dir ; \
+ $(CP) $(call qstrip,$(CONFIG_LIBPTHREAD_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
+ done ; \
+ exit 0
+ endef
+
+ define Package/librt/install
+ for file in $(call qstrip,$(CONFIG_LIBRT_FILE_SPEC)); do \
+ dir=`dirname $$$$file` ; \
+ $(INSTALL_DIR) $(1)/$$$$dir ; \
+ $(CP) $(call qstrip,$(CONFIG_LIBRT_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
+ done ; \
+ exit 0
+ endef
+
+ define Package/ldd/install
+ for file in $(call qstrip,$(CONFIG_LDD_FILE_SPEC)); do \
+ dir=`dirname $$$$file` ; \
+ $(INSTALL_DIR) $(1)/$$$$dir ; \
+ $(CP) $(call qstrip,$(CONFIG_LDD_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
+ done ; \
+ exit 0
+ endef
+
+ define Package/ldconfig/install
+ for file in $(call qstrip,$(CONFIG_LDCONFIG_FILE_SPEC)); do \
+ dir=`dirname $$$$file` ; \
+ $(INSTALL_DIR) $(1)/$$$$dir ; \
+ $(CP) $(call qstrip,$(CONFIG_LDCONFIG_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
+ done ; \
+ exit 0
+ endef
+
+endif
+
+$(eval $(call BuildPackage,libc))
+$(eval $(call BuildPackage,libgcc))
+$(eval $(call BuildPackage,libssp))
+$(eval $(call BuildPackage,libstdcpp))
+$(eval $(call BuildPackage,libpthread))
+$(eval $(call BuildPackage,libthread-db))
+$(eval $(call BuildPackage,librt))
+$(eval $(call BuildPackage,libgfortran))
+$(eval $(call BuildPackage,ldd))
+$(eval $(call BuildPackage,ldconfig))
diff --git a/package/toolchain/Makefile b/package/toolchain/Makefile
new file mode 100644
index 0000000..b9d582e
--- /dev/null
+++ b/package/toolchain/Makefile
@@ -0,0 +1,596 @@
+#
+# Copyright (C) 2007-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+PKG_NAME:=toolchain
+PKG_RELEASE:=1
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+
+ifneq ($(DUMP),1)
+ LIBGCC_VERSION:=$(GCC_VERSION)
+else
+ LIBC_VERSION:=<LIBC_VERSION>
+ LIBGCC_VERSION:=<LIBGCC_VERSION>
+endif
+
+define Package/gcc/Default
+ SECTION:=libs
+ CATEGORY:=Base system
+ URL:=http://gcc.gnu.org/
+ VERSION:=$(LIBGCC_VERSION)-$(PKG_RELEASE)
+endef
+
+define Package/libgcc
+$(call Package/gcc/Default)
+ TITLE:=GCC support library
+endef
+
+define Package/libgcc/config
+ menu "Configuration"
+ depends EXTERNAL_TOOLCHAIN && PACKAGE_libgcc
+
+ config LIBGCC_ROOT_DIR
+ string
+ prompt "libgcc shared library base directory"
+ depends EXTERNAL_TOOLCHAIN && PACKAGE_libgcc
+ default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
+ default "/" if NATIVE_TOOLCHAIN
+
+ config LIBGCC_FILE_SPEC
+ string
+ prompt "libgcc shared library files (use wildcards)"
+ depends EXTERNAL_TOOLCHAIN && PACKAGE_libgcc
+ default "./lib/libgcc_s.so.*"
+
+ endmenu
+endef
+
+
+define Package/libssp
+$(call Package/gcc/Default)
+ DEPENDS+=@SSP_SUPPORT
+ TITLE:=GCC support library
+endef
+
+define Package/libssp/config
+ menu "Configuration"
+ depends EXTERNAL_TOOLCHAIN && PACKAGE_libssp
+
+ config LIBSSP_ROOT_DIR
+ string
+ prompt "libssp shared library base directory"
+ depends EXTERNAL_TOOLCHAIN && PACKAGE_libssp
+ default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
+ default "/" if NATIVE_TOOLCHAIN
+
+ config LIBSSP_FILE_SPEC
+ string
+ prompt "libssp shared library files (use wildcards)"
+ depends EXTERNAL_TOOLCHAIN && PACKAGE_libssp
+ default "./lib/libssp.so.*"
+
+ endmenu
+endef
+
+
+define Package/libstdcpp
+$(call Package/gcc/Default)
+ NAME:=libstdc++
+ TITLE:=GNU Standard C++ Library v3
+ DEPENDS+=@INSTALL_LIBSTDCPP
+endef
+
+define Package/libstdcpp/config
+ menu "Configuration"
+ depends EXTERNAL_TOOLCHAIN && PACKAGE_libstdcpp
+
+ config LIBSTDCPP_ROOT_DIR
+ string
+ prompt "libstdcpp shared library base directory"
+ depends EXTERNAL_TOOLCHAIN && PACKAGE_libstdcpp
+ default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
+ default "/" if NATIVE_TOOLCHAIN
+
+ config LIBSTDCPP_FILE_SPEC
+ string
+ prompt "libstdc++ shared library files (use wildcards)"
+ depends EXTERNAL_TOOLCHAIN && PACKAGE_libstdcpp
+ default "./lib/libstdc++.so.*"
+
+ endmenu
+endef
+
+
+define Package/libc/Default
+ SECTION:=libs
+ CATEGORY:=Base system
+ VERSION:=$(LIBC_VERSION)-$(PKG_RELEASE)
+ DEPENDS:=+libgcc
+ URL:=$(LIBC_URL)
+ PKG_FLAGS:=hold essential
+endef
+
+
+define Package/libc
+$(call Package/libc/Default)
+ TITLE:=C library
+endef
+
+define Package/libc/config
+ menu "Configuration"
+ depends EXTERNAL_TOOLCHAIN && PACKAGE_libc
+
+ config LIBC_ROOT_DIR
+ string
+ prompt "libc shared library base directory"
+ depends EXTERNAL_TOOLCHAIN && PACKAGE_libc
+ default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
+ default "/" if NATIVE_TOOLCHAIN
+
+ config LIBC_FILE_SPEC
+ string
+ prompt "libc shared library files (use wildcards)"
+ depends EXTERNAL_TOOLCHAIN && PACKAGE_libc
+ default "./lib/ld{-*.so,-linux*.so.*} ./lib/lib{anl,c,cidn,crypt,dl,m,nsl,nss_dns,nss_files,resolv,util}{-*.so,.so.*}"
+
+ endmenu
+endef
+
+
+define Package/libpthread
+$(call Package/libc/Default)
+ TITLE:=POSIX thread library
+endef
+
+define Package/libpthread/config
+ menu "Configuration"
+ depends EXTERNAL_TOOLCHAIN && PACKAGE_libpthread
+
+ config LIBPTHREAD_ROOT_DIR
+ string
+ prompt "libpthread shared library base directory"
+ depends EXTERNAL_TOOLCHAIN && PACKAGE_libpthread
+ default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
+ default "/" if NATIVE_TOOLCHAIN
+
+ config LIBPTHREAD_FILE_SPEC
+ string
+ prompt "libpthread shared library files (use wildcards)"
+ depends EXTERNAL_TOOLCHAIN && PACKAGE_libpthread
+ default "./lib/libpthread{-*.so,.so.*}"
+
+ endmenu
+endef
+
+
+define Package/libthread-db
+$(call Package/libc/Default)
+ DEPENDS:=@!USE_MUSL
+ TITLE:=POSIX thread library debugging support
+endef
+
+define Package/librt
+$(call Package/libc/Default)
+ TITLE:=POSIX.1b RealTime extension library
+ DEPENDS:=+libpthread
+endef
+
+define Package/librt/config
+ menu "Configuration"
+ depends EXTERNAL_TOOLCHAIN && PACKAGE_librt
+
+ config LIBRT_ROOT_DIR
+ string
+ prompt "librt shared library base directory"
+ depends EXTERNAL_TOOLCHAIN && PACKAGE_librt
+ default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
+ default "/" if NATIVE_TOOLCHAIN
+
+ config LIBRT_FILE_SPEC
+ string
+ prompt "librt shared library files (use wildcards)"
+ depends EXTERNAL_TOOLCHAIN && PACKAGE_librt
+ default "./lib/librt{-*.so,.so.*}"
+
+ endmenu
+endef
+
+
+define Package/libgfortran
+$(call Package/gcc/Default)
+ TITLE:=GFortran support library
+ DEPENDS+=@INSTALL_GFORTRAN
+endef
+
+define Package/libgfortran/config
+ menu "Configuration"
+ depends EXTERNAL_TOOLCHAIN && PACKAGE_libgfortran
+
+ config LIBGFORTRAN_ROOT_DIR
+ string
+ prompt "libgfortran shared library base directory"
+ depends EXTERNAL_TOOLCHAIN && PACKAGE_libgfortran
+ default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
+ default "/" if NATIVE_TOOLCHAIN
+
+ config LIBGFORTRAN_FILE_SPEC
+ string
+ prompt "libgfortran shared library files (use wildcards)"
+ depends EXTERNAL_TOOLCHAIN && PACKAGE_libgfortran
+ default "./usr/lib/libgfortran.so.*"
+
+ endmenu
+endef
+
+define Package/ldd
+$(call Package/libc/Default)
+ DEPENDS:=@!USE_MUSL
+ SECTION:=utils
+ CATEGORY:=Utilities
+ TITLE:=LDD trace utility
+endef
+
+define Package/ldd/config
+ menu "Configuration"
+ depends EXTERNAL_TOOLCHAIN && PACKAGE_ldd
+
+ config LDD_ROOT_DIR
+ string
+ prompt "ldd trace utility base directory"
+ depends EXTERNAL_TOOLCHAIN && PACKAGE_ldd
+ default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
+ default "/" if NATIVE_TOOLCHAIN
+
+ config LDD_FILE_SPEC
+ string
+ prompt "ldd trace utility file"
+ depends EXTERNAL_TOOLCHAIN && PACKAGE_ldd
+ default "./usr/bin/ldd"
+
+ endmenu
+endef
+
+
+define Package/ldconfig
+$(call Package/libc/Default)
+ DEPENDS:=@!USE_MUSL
+ SECTION:=utils
+ CATEGORY:=Utilities
+ TITLE:=Shared library path configuration
+endef
+
+define Package/ldconfig/config
+ menu "Configuration"
+ depends EXTERNAL_TOOLCHAIN && PACKAGE_ldconfig
+
+ config LDCONFIG_ROOT_DIR
+ string
+ prompt "ldconfig base directory"
+ depends EXTERNAL_TOOLCHAIN && PACKAGE_ldconfig
+ default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
+ default "/" if NATIVE_TOOLCHAIN
+
+ config LDCONFIG_FILE_SPEC
+ string
+ prompt "ldconfig file"
+ depends EXTERNAL_TOOLCHAIN && PACKAGE_ldconfig
+ default "./sbin/ldconfig"
+
+ endmenu
+endef
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+endef
+
+LIBGCC_A=$(wildcard $(TOOLCHAIN_DIR)/lib/gcc/*/*/libgcc_pic.a)
+LIBGCC_MAP=$(wildcard $(TOOLCHAIN_DIR)/lib/gcc/*/*/libgcc.map)
+LIBGCC_SO=$(wildcard $(TOOLCHAIN_DIR)/lib/libgcc_s.so.*)
+ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),)
+ ifneq ($(if $(CONFIG_USE_UCLIBC),$(CONFIG_GCC_VERSION_LINARO)),)
+ BUILD_LIBGCC:=$(if $(CONFIG_avr32)$(CONFIG_m68k)$(CONFIG_powerpc),,$(PKG_BUILD_DIR)/libgcc_s.so.*)
+ endif
+endif
+
+ifneq ($(BUILD_LIBGCC),)
+ define Build/Compile/uClibc
+ $(SCRIPT_DIR)/relink-lib.sh \
+ "$(TARGET_CROSS)" \
+ "$(wildcard $(TOOLCHAIN_DIR)/lib/libc_so.a)" \
+ "$(wildcard $(TOOLCHAIN_DIR)/lib/libc_so.a)" \
+ "$(patsubst $(TOOLCHAIN_DIR)/lib/%,$(PKG_BUILD_DIR)/%,$(wildcard $(TOOLCHAIN_DIR)/lib/libuClibc-*.so))" \
+ -Wl,-init,__uClibc_init -Wl,-soname=libc.so.0 \
+ $(BUILD_LIBGCC)
+ $(SCRIPT_DIR)/relink-lib.sh \
+ "$(TARGET_CROSS)" \
+ "$(wildcard $(TOOLCHAIN_DIR)/lib/libcrypt-*.so)" \
+ "$(wildcard $(TOOLCHAIN_DIR)/lib/libcrypt_pic.a)" \
+ "$(patsubst $(TOOLCHAIN_DIR)/lib/%,$(PKG_BUILD_DIR)/%,$(wildcard $(TOOLCHAIN_DIR)/lib/libcrypt-*.so))" \
+ $(BUILD_LIBGCC) \
+ -Wl,-soname=libcrypt.so.0
+ $(SCRIPT_DIR)/relink-lib.sh \
+ "$(TARGET_CROSS)" \
+ "$(wildcard $(TOOLCHAIN_DIR)/lib/libm-*.so)" \
+ "$(wildcard $(TOOLCHAIN_DIR)/lib/libm_pic.a)" \
+ "$(patsubst $(TOOLCHAIN_DIR)/lib/%,$(PKG_BUILD_DIR)/%,$(wildcard $(TOOLCHAIN_DIR)/lib/libm-*.so))" \
+ $(BUILD_LIBGCC) \
+ -Wl,-soname=libm.so.0
+ $(SCRIPT_DIR)/relink-lib.sh \
+ "$(TARGET_CROSS)" \
+ "$(wildcard $(TOOLCHAIN_DIR)/lib/libpthread-*.so)" \
+ "$(wildcard $(TOOLCHAIN_DIR)/lib/libpthread_so.a)" \
+ "$(patsubst $(TOOLCHAIN_DIR)/lib/%,$(PKG_BUILD_DIR)/%,$(wildcard $(TOOLCHAIN_DIR)/lib/libpthread-*.so))" \
+ -Wl,-z,nodelete,-z,initfirst,-init=__pthread_initialize_minimal_internal \
+ -ldl -lc $(BUILD_LIBGCC) \
+ -Wl,-soname=libpthread.so.0
+ endef
+ define Build/Compile/libgcc
+ $(SCRIPT_DIR)/relink-lib.sh \
+ "$(TARGET_CROSS)" \
+ "$(LIBGCC_SO)" \
+ "$(LIBGCC_A)" \
+ "$(patsubst $(TOOLCHAIN_DIR)/lib/%,$(PKG_BUILD_DIR)/%,$(LIBGCC_SO))" \
+ -Wl,--version-script=$(LIBGCC_MAP) -Wl,-soname=libgcc_s.so.1
+ endef
+else
+ define Build/Compile/uClibc
+ $(CP) \
+ $(TOOLCHAIN_DIR)/lib/libuClibc-*.so \
+ $(TOOLCHAIN_DIR)/lib/libcrypt-*.so \
+ $(TOOLCHAIN_DIR)/lib/libm-*.so \
+ $(TOOLCHAIN_DIR)/lib/libpthread-*.so \
+ $(PKG_BUILD_DIR)/
+ endef
+ ifneq ($(LIBGCC_SO),)
+ define Build/Compile/libgcc
+ $(CP) $(LIBGCC_SO) $(PKG_BUILD_DIR)/
+ endef
+ endif
+endif
+
+define Build/Compile/Default
+ $(call Build/Compile/libgcc)
+ $(call Build/Compile/$(LIBC))
+endef
+Build/Compile = $(Build/Compile/Default)
+
+ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),)
+
+ define Package/libgcc/install
+ $(INSTALL_DIR) $(1)/lib
+ $(if $(CONFIG_TARGET_avr32)$(CONFIG_TARGET_coldfire),,$(CP) $(TOOLCHAIN_DIR)/lib/libgcc_s.so.* $(1)/lib/)
+ endef
+
+ define Package/libgfortran/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(if $(CONFIG_TARGET_avr32)$(CONFIG_TARGET_coldfire),,$(CP) $(TOOLCHAIN_DIR)/lib/libgfortran.so.* $(1)/usr/lib/)
+ endef
+
+ define Package/libssp/install
+ $(INSTALL_DIR) $(1)/lib
+ $(CP) $(TOOLCHAIN_DIR)/lib/libssp.so.* $(1)/lib/
+ endef
+
+ define Package/libstdcpp/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(TOOLCHAIN_DIR)/lib/libstdc++.so.* $(1)/usr/lib/
+ endef
+
+ use_libutil=$(if $(CONFIG_EGLIBC_OPTION_EGLIBC_UTMP),libutil)
+ use_libnsl=$(if $(CONFIG_EGLIBC_OPTION_EGLIBC_NIS),libnsl)
+ use_nsswitch=$(if $(CONFIG_EGLIBC_OPTION_EGLIBC_NSSWITCH),libnss_dns libnss_files)
+
+ define Package/eglibc/install
+ $(CP) ./eglibc-files/* $(1)/
+ rm -f $(1)/etc/localtime
+ ln -sf /tmp/localtime $(1)/etc/localtime
+ $(INSTALL_DIR) $(1)/lib
+ $(CP) \
+ $(TOOLCHAIN_DIR)/lib/ld*.so.* \
+ $(TOOLCHAIN_DIR)/lib/ld-$(LIBC_SO_VERSION).so \
+ $(1)/lib/
+ for file in libanl libc libcidn libcrypt libdl libm $(use_libnsl) $(use_nsswitch) libresolv $(use_libutil); do \
+ for file in $(TOOLCHAIN_DIR)/lib/$$$$file.so.* $(TOOLCHAIN_DIR)/lib/$$$$file-$(LIBC_SO_VERSION).so; do \
+ if [ -e "$$$$file" ]; then \
+ $(CP) $$$$file $(1)/lib/; \
+ fi; \
+ done; \
+ done
+ endef
+
+ define Package/uClibc/install
+ $(INSTALL_DIR) $(1)/lib
+ $(CP) \
+ $(TOOLCHAIN_DIR)/lib/ld*-uClibc.so.* \
+ $(TOOLCHAIN_DIR)/lib/ld*-uClibc-$(LIBC_SO_VERSION).so \
+ $(1)/lib/
+ $(CP) \
+ $(TOOLCHAIN_DIR)/lib/libc.so.* \
+ $(TOOLCHAIN_DIR)/lib/libuClibc-$(LIBC_SO_VERSION).so \
+ $(1)/lib/
+ for file in libcrypt libdl libm libutil; do \
+ $(CP) \
+ $(TOOLCHAIN_DIR)/lib/$$$$file.so.* \
+ $(TOOLCHAIN_DIR)/lib/$$$$file-$(LIBC_SO_VERSION).so \
+ $(1)/lib/; \
+ done
+
+ $(CP) \
+ $(PKG_BUILD_DIR)/libuClibc-* \
+ $(PKG_BUILD_DIR)/libm-* \
+ $(PKG_BUILD_DIR)/libcrypt-* \
+ $(1)/lib/
+ endef
+
+ define Package/musl/install
+ $(INSTALL_DIR) $(1)/lib
+ $(CP) \
+ $(TOOLCHAIN_DIR)/lib/ld-musl-*.so* \
+ $(1)/lib/
+ $(CP) \
+ $(TOOLCHAIN_DIR)/lib/libc.so* \
+ $(1)/lib/
+ endef
+
+ define Package/libc/install
+ $(call Package/$(LIBC)/install,$1)
+ endef
+
+ define Package/libc/install_lib
+ $(CP) $(filter-out %/libdl_pic.a %/libpthread_pic.a %/libresolv_pic.a,$(wildcard $(TOOLCHAIN_DIR)/lib/lib*.a)) $(1)/lib/
+ $(if $(wildcard $(TOOLCHAIN_DIR)/lib/libc_so.a),$(CP) $(TOOLCHAIN_DIR)/lib/libc_so.a $(1)/lib/libc_pic.a)
+ $(if $(LIBGCC_MAP), \
+ $(CP) $(LIBGCC_A) $(1)/lib/libgcc_s_pic.a; \
+ $(CP) $(LIBGCC_MAP) $(1)/lib/libgcc_s_pic.map \
+ )
+ endef
+
+ define Package/libpthread/install
+ $(INSTALL_DIR) $(1)/lib
+ ifneq ($(CONFIG_USE_MUSL),y)
+ $(CP) \
+ $(TOOLCHAIN_DIR)/lib/libpthread.so.* \
+ $(if $(BUILD_LIBGCC),\
+ $(PKG_BUILD_DIR)/libpthread-$(LIBC_SO_VERSION).so, \
+ $(TOOLCHAIN_DIR)/lib/libpthread-$(LIBC_SO_VERSION).so \
+ ) \
+ $(1)/lib/
+ endif
+ endef
+
+ define Package/libthread-db/install
+ $(INSTALL_DIR) $(1)/lib
+ $(CP) \
+ $(TOOLCHAIN_DIR)/lib/libthread_db.so.* $(1)/lib
+ ifeq ($(USE_UCLIBC),y)
+ $(CP) \
+ $(TOOLCHAIN_DIR)/lib/libthread_db-$(LIBC_SO_VERSION).so \
+ $(1)/lib/
+ endif
+ endef
+
+ define Package/libpthread/install_lib
+ $(if $(wildcard $(TOOLCHAIN_DIR)/lib/libpthread_so.a),$(CP) $(TOOLCHAIN_DIR)/lib/libpthread_so.a $(1)/lib/libpthread_pic.a)
+ endef
+
+ define Package/librt/install
+ $(INSTALL_DIR) $(1)/lib
+ ifneq ($(CONFIG_USE_MUSL),y)
+ $(CP) \
+ $(TOOLCHAIN_DIR)/lib/librt.so.* \
+ $(TOOLCHAIN_DIR)/lib/librt-$(LIBC_SO_VERSION).so \
+ $(1)/lib/
+ endif
+ endef
+
+ define Package/ldd/install
+ $(INSTALL_DIR) $(1)/usr/bin/
+ $(CP) $(TOOLCHAIN_DIR)/bin/ldd $(1)/usr/bin/
+ endef
+
+ define Package/ldconfig/install
+ $(INSTALL_DIR) $(1)/sbin/
+ $(CP) $(TOOLCHAIN_DIR)/sbin/ldconfig $(1)/sbin/
+ endef
+
+else
+
+ define Package/libgcc/install
+ for file in $(call qstrip,$(CONFIG_LIBGCC_FILE_SPEC)); do \
+ dir=`dirname $$$$file` ; \
+ $(INSTALL_DIR) $(1)/$$$$dir ; \
+ $(CP) $(call qstrip,$(CONFIG_LIBGCC_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
+ done ; \
+ exit 0
+ endef
+
+ define Package/libgfortran/install
+ for file in $(call qstrip,$(CONFIG_LIBGFORTRAN_FILE_SPEC)); do \
+ dir=`dirname $$$$file` ; \
+ $(INSTALL_DIR) $(1)/$$$$dir ; \
+ $(CP) $(call qstrip,$(CONFIG_LIBGFORTRAN_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
+ done
+ endef
+
+ define Package/libssp/install
+ for file in $(call qstrip,$(CONFIG_LIBSSP_FILE_SPEC)); do \
+ dir=`dirname $$$$file` ; \
+ $(INSTALL_DIR) $(1)/$$$$dir ; \
+ $(CP) $(call qstrip,$(CONFIG_LIBSSP_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
+ done ; \
+ exit 0
+ endef
+
+ define Package/libstdcpp/install
+ for file in $(call qstrip,$(CONFIG_LIBSTDCPP_FILE_SPEC)); do \
+ dir=`dirname $$$$file` ; \
+ $(INSTALL_DIR) $(1)/$$$$dir ; \
+ $(CP) $(call qstrip,$(CONFIG_LIBSTDCPP_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
+ done ; \
+ exit 0
+ endef
+
+ define Package/libc/install
+ for file in $(call qstrip,$(CONFIG_LIBC_FILE_SPEC)); do \
+ dir=`dirname $$$$file` ; \
+ $(INSTALL_DIR) $(1)/$$$$dir ; \
+ $(CP) $(call qstrip,$(CONFIG_LIBC_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
+ done ; \
+ exit 0
+ endef
+
+ define Package/libpthread/install
+ for file in $(call qstrip,$(CONFIG_LIBPTHREAD_FILE_SPEC)); do \
+ dir=`dirname $$$$file` ; \
+ $(INSTALL_DIR) $(1)/$$$$dir ; \
+ $(CP) $(call qstrip,$(CONFIG_LIBPTHREAD_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
+ done ; \
+ exit 0
+ endef
+
+ define Package/librt/install
+ for file in $(call qstrip,$(CONFIG_LIBRT_FILE_SPEC)); do \
+ dir=`dirname $$$$file` ; \
+ $(INSTALL_DIR) $(1)/$$$$dir ; \
+ $(CP) $(call qstrip,$(CONFIG_LIBRT_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
+ done ; \
+ exit 0
+ endef
+
+ define Package/ldd/install
+ for file in $(call qstrip,$(CONFIG_LDD_FILE_SPEC)); do \
+ dir=`dirname $$$$file` ; \
+ $(INSTALL_DIR) $(1)/$$$$dir ; \
+ $(CP) $(call qstrip,$(CONFIG_LDD_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
+ done ; \
+ exit 0
+ endef
+
+ define Package/ldconfig/install
+ for file in $(call qstrip,$(CONFIG_LDCONFIG_FILE_SPEC)); do \
+ dir=`dirname $$$$file` ; \
+ $(INSTALL_DIR) $(1)/$$$$dir ; \
+ $(CP) $(call qstrip,$(CONFIG_LDCONFIG_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
+ done ; \
+ exit 0
+ endef
+
+endif
+
+$(eval $(call BuildPackage,libc))
+$(eval $(call BuildPackage,libgcc))
+$(eval $(call BuildPackage,libssp))
+$(eval $(call BuildPackage,libstdcpp))
+$(eval $(call BuildPackage,libpthread))
+$(eval $(call BuildPackage,libthread-db))
+$(eval $(call BuildPackage,librt))
+$(eval $(call BuildPackage,libgfortran))
+$(eval $(call BuildPackage,ldd))
+$(eval $(call BuildPackage,ldconfig))
diff --git a/package/toolchain/eglibc-files/.svn/entries b/package/toolchain/eglibc-files/.svn/entries
new file mode 100644
index 0000000..4f69214
--- /dev/null
+++ b/package/toolchain/eglibc-files/.svn/entries
@@ -0,0 +1,31 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/toolchain/eglibc-files
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-06-20T13:45:01.119490Z
+32467
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+etc
+dir
+
diff --git a/package/toolchain/eglibc-files/etc/.svn/entries b/package/toolchain/eglibc-files/etc/.svn/entries
new file mode 100644
index 0000000..de3364d
--- /dev/null
+++ b/package/toolchain/eglibc-files/etc/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/toolchain/eglibc-files/etc
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-06-20T13:45:01.119490Z
+32467
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+nsswitch.conf
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+662001b324a098eb2bf976fd168cd783
+2012-06-20T13:45:01.119490Z
+32467
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+185
+
diff --git a/package/toolchain/eglibc-files/etc/.svn/text-base/nsswitch.conf.svn-base b/package/toolchain/eglibc-files/etc/.svn/text-base/nsswitch.conf.svn-base
new file mode 100644
index 0000000..981c425
--- /dev/null
+++ b/package/toolchain/eglibc-files/etc/.svn/text-base/nsswitch.conf.svn-base
@@ -0,0 +1,13 @@
+passwd:files
+shadow:files
+group:files
+hosts:dns files
+bootparams:files
+ethers:files
+netmasks:files
+networks:files
+protocols:files
+rpc:files
+services:files
+automount:files
+aliases:files
diff --git a/package/toolchain/eglibc-files/etc/nsswitch.conf b/package/toolchain/eglibc-files/etc/nsswitch.conf
new file mode 100644
index 0000000..981c425
--- /dev/null
+++ b/package/toolchain/eglibc-files/etc/nsswitch.conf
@@ -0,0 +1,13 @@
+passwd:files
+shadow:files
+group:files
+hosts:dns files
+bootparams:files
+ethers:files
+netmasks:files
+networks:files
+protocols:files
+rpc:files
+services:files
+automount:files
+aliases:files
diff --git a/package/trelay/.svn/entries b/package/trelay/.svn/entries
new file mode 100644
index 0000000..8921981
--- /dev/null
+++ b/package/trelay/.svn/entries
@@ -0,0 +1,68 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/trelay
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-05-06T20:43:17.377831Z
+31634
+hauke
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+files
+dir
+
+src
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+c3076d4047cb5b5878c4dfe60fd69eb0
+2012-05-06T20:43:17.377831Z
+31634
+hauke
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1409
+
diff --git a/package/trelay/.svn/text-base/Makefile.svn-base b/package/trelay/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..82c4101
--- /dev/null
+++ b/package/trelay/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,50 @@
+#
+# Copyright (C) 2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=trelay
+PKG_VERSION:=0.1
+PKG_RELEASE:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/trelay
+ SUBMENU:=Network Support
+ TITLE:=Trivial Ethernet Relay
+ FILES:=$(PKG_BUILD_DIR)/trelay.ko
+ AUTOLOAD:=$(call AutoLoad,50,trelay)
+endef
+
+define KernelPackage/trelay/description
+trelay relays ethernet packets between two devices (similar to a bridge), but
+without any MAC address checks. This makes it possible to bridge client mode
+or ad-hoc mode wifi devices to ethernet VLANs, assuming the remote end uses
+the same source MAC address as the device that packets are supposed to exit
+from.
+endef
+
+include $(INCLUDE_DIR)/kernel-defaults.mk
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+ cp src/Makefile src/trelay.c $(PKG_BUILD_DIR)/
+endef
+
+define Build/Compile
+ $(MAKE) $(KERNEL_MAKEOPTS) SUBDIRS="$(PKG_BUILD_DIR)" modules
+endef
+
+define KernelPackage/trelay/install
+ $(INSTALL_DIR) $(1)/etc/hotplug.d/net $(1)/etc/init.d $(1)/etc/config
+ $(INSTALL_DATA) ./files/trelay.hotplug $(1)/etc/hotplug.d/net/50-trelay
+ $(INSTALL_BIN) ./files/trelay.init $(1)/etc/init.d/trelay
+ $(INSTALL_DATA) ./files/trelay.config $(1)/etc/config/trelay
+endef
+
+$(eval $(call KernelPackage,trelay))
diff --git a/package/trelay/Makefile b/package/trelay/Makefile
new file mode 100644
index 0000000..82c4101
--- /dev/null
+++ b/package/trelay/Makefile
@@ -0,0 +1,50 @@
+#
+# Copyright (C) 2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=trelay
+PKG_VERSION:=0.1
+PKG_RELEASE:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/trelay
+ SUBMENU:=Network Support
+ TITLE:=Trivial Ethernet Relay
+ FILES:=$(PKG_BUILD_DIR)/trelay.ko
+ AUTOLOAD:=$(call AutoLoad,50,trelay)
+endef
+
+define KernelPackage/trelay/description
+trelay relays ethernet packets between two devices (similar to a bridge), but
+without any MAC address checks. This makes it possible to bridge client mode
+or ad-hoc mode wifi devices to ethernet VLANs, assuming the remote end uses
+the same source MAC address as the device that packets are supposed to exit
+from.
+endef
+
+include $(INCLUDE_DIR)/kernel-defaults.mk
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+ cp src/Makefile src/trelay.c $(PKG_BUILD_DIR)/
+endef
+
+define Build/Compile
+ $(MAKE) $(KERNEL_MAKEOPTS) SUBDIRS="$(PKG_BUILD_DIR)" modules
+endef
+
+define KernelPackage/trelay/install
+ $(INSTALL_DIR) $(1)/etc/hotplug.d/net $(1)/etc/init.d $(1)/etc/config
+ $(INSTALL_DATA) ./files/trelay.hotplug $(1)/etc/hotplug.d/net/50-trelay
+ $(INSTALL_BIN) ./files/trelay.init $(1)/etc/init.d/trelay
+ $(INSTALL_DATA) ./files/trelay.config $(1)/etc/config/trelay
+endef
+
+$(eval $(call KernelPackage,trelay))
diff --git a/package/trelay/files/.svn/entries b/package/trelay/files/.svn/entries
new file mode 100644
index 0000000..7424f11
--- /dev/null
+++ b/package/trelay/files/.svn/entries
@@ -0,0 +1,130 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/trelay/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-03-28T11:02:38.742123Z
+31122
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+trelay.hotplug
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+e33fc6f10f1b4efb3577f8e23aca1139
+2012-03-28T11:02:38.742123Z
+31122
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+102
+
+trelay.init
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+2fab40623dff69816c43806c4caeb2bd
+2012-03-28T11:02:38.742123Z
+31122
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+688
+
+trelay.config
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+58b3a5bc99fa45c2d22b7e17dc17e3d0
+2012-03-28T11:02:38.742123Z
+31122
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+69
+
diff --git a/package/trelay/files/.svn/text-base/trelay.config.svn-base b/package/trelay/files/.svn/text-base/trelay.config.svn-base
new file mode 100644
index 0000000..eb05013
--- /dev/null
+++ b/package/trelay/files/.svn/text-base/trelay.config.svn-base
@@ -0,0 +1,4 @@
+config trelay
+ option enabled 0
+ option dev1 eth0
+ option dev2 wlan0
diff --git a/package/trelay/files/.svn/text-base/trelay.hotplug.svn-base b/package/trelay/files/.svn/text-base/trelay.hotplug.svn-base
new file mode 100644
index 0000000..31f7378
--- /dev/null
+++ b/package/trelay/files/.svn/text-base/trelay.hotplug.svn-base
@@ -0,0 +1,5 @@
+case "$ACTION" in
+ add|register)
+ [ -f /var/run/trelay.active ] && /etc/init.d/trelay start
+ ;;
+esac
diff --git a/package/trelay/files/.svn/text-base/trelay.init.svn-base b/package/trelay/files/.svn/text-base/trelay.init.svn-base
new file mode 100644
index 0000000..c812e12
--- /dev/null
+++ b/package/trelay/files/.svn/text-base/trelay.init.svn-base
@@ -0,0 +1,32 @@
+#!/bin/sh /etc/rc.common
+START=80
+
+check_relay() {
+ local cfg="$1"
+
+ config_get_bool enabled "$cfg" enabled 1
+ [ "$enabled" -gt 0 ] || return
+
+ config_get dev1 "$cfg" dev1
+ config_get dev2 "$cfg" dev2
+
+ [ -d "/sys/kernel/debug/trelay/${dev1}-${dev2}" ] && return
+ [ -d "/sys/class/net/${dev1}" -a -d "/sys/class/net/${dev2}" ] || return
+
+ ifconfig "$dev1" up
+ ifconfig "$dev2" up
+ echo "${dev1}-${dev2},${dev1},${dev2}" > /sys/kernel/debug/trelay/add
+}
+
+start() {
+ config_load trelay
+ config_foreach check_relay trelay
+ touch /var/run/trelay.active
+}
+
+stop() {
+ rm -f /var/run/trelay.active
+ for relay in /sys/kernel/debug/trelay/*; do
+ [ -d "$relay" ] && echo > "$relay/remove"
+ done
+}
diff --git a/package/trelay/files/trelay.config b/package/trelay/files/trelay.config
new file mode 100644
index 0000000..eb05013
--- /dev/null
+++ b/package/trelay/files/trelay.config
@@ -0,0 +1,4 @@
+config trelay
+ option enabled 0
+ option dev1 eth0
+ option dev2 wlan0
diff --git a/package/trelay/files/trelay.hotplug b/package/trelay/files/trelay.hotplug
new file mode 100644
index 0000000..31f7378
--- /dev/null
+++ b/package/trelay/files/trelay.hotplug
@@ -0,0 +1,5 @@
+case "$ACTION" in
+ add|register)
+ [ -f /var/run/trelay.active ] && /etc/init.d/trelay start
+ ;;
+esac
diff --git a/package/trelay/files/trelay.init b/package/trelay/files/trelay.init
new file mode 100644
index 0000000..c812e12
--- /dev/null
+++ b/package/trelay/files/trelay.init
@@ -0,0 +1,32 @@
+#!/bin/sh /etc/rc.common
+START=80
+
+check_relay() {
+ local cfg="$1"
+
+ config_get_bool enabled "$cfg" enabled 1
+ [ "$enabled" -gt 0 ] || return
+
+ config_get dev1 "$cfg" dev1
+ config_get dev2 "$cfg" dev2
+
+ [ -d "/sys/kernel/debug/trelay/${dev1}-${dev2}" ] && return
+ [ -d "/sys/class/net/${dev1}" -a -d "/sys/class/net/${dev2}" ] || return
+
+ ifconfig "$dev1" up
+ ifconfig "$dev2" up
+ echo "${dev1}-${dev2},${dev1},${dev2}" > /sys/kernel/debug/trelay/add
+}
+
+start() {
+ config_load trelay
+ config_foreach check_relay trelay
+ touch /var/run/trelay.active
+}
+
+stop() {
+ rm -f /var/run/trelay.active
+ for relay in /sys/kernel/debug/trelay/*; do
+ [ -d "$relay" ] && echo > "$relay/remove"
+ done
+}
diff --git a/package/trelay/src/.svn/entries b/package/trelay/src/.svn/entries
new file mode 100644
index 0000000..88f3058
--- /dev/null
+++ b/package/trelay/src/.svn/entries
@@ -0,0 +1,96 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/trelay/src
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-03-28T11:02:38.742123Z
+31122
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+trelay.c
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+e0ac02f4291139b4dbc7fb766bfb2c12
+2012-03-28T11:02:38.742123Z
+31122
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5373
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:21.000000Z
+557e9bd57728735b8235ddf26e57fd75
+2012-03-28T11:02:38.742123Z
+31122
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+20
+
diff --git a/package/trelay/src/.svn/text-base/Makefile.svn-base b/package/trelay/src/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..e6bde89
--- /dev/null
+++ b/package/trelay/src/.svn/text-base/Makefile.svn-base
@@ -0,0 +1 @@
+obj-m := trelay.o
diff --git a/package/trelay/src/.svn/text-base/trelay.c.svn-base b/package/trelay/src/.svn/text-base/trelay.c.svn-base
new file mode 100644
index 0000000..8fa4374
--- /dev/null
+++ b/package/trelay/src/.svn/text-base/trelay.c.svn-base
@@ -0,0 +1,272 @@
+/*
+ * trelay.c: Trivial Ethernet Relay
+ *
+ * Copyright (C) 2012 Felix Fietkau <nbd@openwrt.org>
+ *
+ * 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
+ * of the License, 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.
+ */
+#include <linux/module.h>
+#include <linux/list.h>
+#include <linux/mutex.h>
+#include <linux/netdevice.h>
+#include <linux/rtnetlink.h>
+#include <linux/debugfs.h>
+
+static LIST_HEAD(trelay_devs);
+static struct dentry *debugfs_dir;
+
+struct trelay {
+ struct list_head list;
+ struct net_device *dev1, *dev2;
+ struct dentry *debugfs;
+ char name[];
+};
+
+rx_handler_result_t trelay_handle_frame(struct sk_buff **pskb)
+{
+ struct net_device *dev;
+ struct sk_buff *skb = *pskb;
+
+ dev = rcu_dereference(skb->dev->rx_handler_data);
+ if (!dev)
+ return RX_HANDLER_PASS;
+
+ if (skb->protocol == htons(ETH_P_PAE))
+ return RX_HANDLER_PASS;
+
+ skb_push(skb, ETH_HLEN);
+ skb->dev = dev;
+ skb_forward_csum(skb);
+ dev_queue_xmit(skb);
+
+ return RX_HANDLER_CONSUMED;
+}
+
+static int trelay_open(struct inode *inode, struct file *file)
+{
+ file->private_data = inode->i_private;
+ return 0;
+}
+
+static int trelay_do_remove(struct trelay *tr)
+{
+ list_del(&tr->list);
+
+ dev_put(tr->dev1);
+ dev_put(tr->dev2);
+
+ netdev_rx_handler_unregister(tr->dev1);
+ netdev_rx_handler_unregister(tr->dev2);
+
+ debugfs_remove_recursive(tr->debugfs);
+ kfree(tr);
+
+ return 0;
+}
+
+static struct trelay *trelay_find(struct net_device *dev)
+{
+ struct trelay *tr;
+
+ list_for_each_entry(tr, &trelay_devs, list) {
+ if (tr->dev1 == dev || tr->dev2 == dev)
+ return tr;
+ }
+ return NULL;
+}
+
+static int tr_device_event(struct notifier_block *unused, unsigned long event,
+ void *ptr)
+{
+ struct net_device *dev = ptr;
+ struct trelay *tr;
+
+ if (event != NETDEV_UNREGISTER)
+ goto out;
+
+ tr = trelay_find(dev);
+ if (!tr)
+ goto out;
+
+ trelay_do_remove(tr);
+
+out:
+ return NOTIFY_DONE;
+}
+
+static ssize_t trelay_remove_write(struct file *file, const char __user *ubuf,
+ size_t count, loff_t *ppos)
+{
+ struct trelay *tr = file->private_data;
+ int ret;
+
+ rtnl_lock();
+ ret = trelay_do_remove(tr);
+ rtnl_unlock();
+
+ if (ret < 0)
+ return ret;
+
+ return count;
+}
+
+static const struct file_operations fops_remove = {
+ .owner = THIS_MODULE,
+ .open = trelay_open,
+ .write = trelay_remove_write,
+ .llseek = default_llseek,
+};
+
+
+static int trelay_do_add(char *name, char *devn1, char *devn2)
+{
+ struct net_device *dev1, *dev2;
+ struct trelay *tr, *tr1;
+ int ret;
+
+ tr = kzalloc(sizeof(*tr) + strlen(name) + 1, GFP_KERNEL);
+ if (!tr)
+ return -ENOMEM;
+
+ rtnl_lock();
+ rcu_read_lock();
+
+ ret = -EEXIST;
+ list_for_each_entry(tr1, &trelay_devs, list) {
+ if (!strcmp(tr1->name, name))
+ goto out;
+ }
+
+ ret = -ENOENT;
+ dev1 = dev_get_by_name_rcu(&init_net, devn1);
+ dev2 = dev_get_by_name_rcu(&init_net, devn2);
+ if (!dev1 || !dev2)
+ goto out;
+
+ ret = netdev_rx_handler_register(dev1, trelay_handle_frame, dev2);
+ if (ret < 0)
+ goto out;
+
+ ret = netdev_rx_handler_register(dev2, trelay_handle_frame, dev1);
+ if (ret < 0) {
+ netdev_rx_handler_unregister(dev1);
+ goto out;
+ }
+
+ dev_hold(dev1);
+ dev_hold(dev2);
+
+ strcpy(tr->name, name);
+ tr->dev1 = dev1;
+ tr->dev2 = dev2;
+ list_add_tail(&tr->list, &trelay_devs);
+
+ tr->debugfs = debugfs_create_dir(name, debugfs_dir);
+ debugfs_create_file("remove", S_IWUSR, tr->debugfs, tr, &fops_remove);
+ ret = 0;
+
+out:
+ rcu_read_unlock();
+ rtnl_unlock();
+ if (ret < 0)
+ kfree(tr);
+
+ return ret;
+}
+
+static ssize_t trelay_add_write(struct file *file, const char __user *ubuf,
+ size_t count, loff_t *ppos)
+{
+ char buf[256];
+ char *dev1, *dev2, *tmp;
+ ssize_t len, ret;
+
+ len = min(count, sizeof(buf) - 1);
+ if (copy_from_user(buf, ubuf, len))
+ return -EFAULT;
+
+ buf[len] = 0;
+
+ if ((tmp = strchr(buf, '\n')))
+ *tmp = 0;
+
+ dev1 = strchr(buf, ',');
+ if (!dev1)
+ return -EINVAL;
+
+ *(dev1++) = 0;
+
+ dev2 = strchr(dev1, ',');
+ if (!dev2)
+ return -EINVAL;
+
+ *(dev2++) = 0;
+ if (strchr(dev2, ','))
+ return -EINVAL;
+
+ if (!strlen(buf) || !strlen(dev1) || !strlen(dev2))
+ return -EINVAL;
+
+ ret = trelay_do_add(buf, dev1, dev2);
+ if (ret < 0)
+ return ret;
+
+ return count;
+}
+
+static const struct file_operations fops_add = {
+ .owner = THIS_MODULE,
+ .write = trelay_add_write,
+ .llseek = default_llseek,
+};
+
+static struct notifier_block tr_dev_notifier = {
+ .notifier_call = tr_device_event
+};
+
+static int __init trelay_init(void)
+{
+ int ret;
+
+ debugfs_dir = debugfs_create_dir("trelay", NULL);
+ if (!debugfs_dir)
+ return -ENOMEM;
+
+ debugfs_create_file("add", S_IWUSR, debugfs_dir, NULL, &fops_add);
+
+ ret = register_netdevice_notifier(&tr_dev_notifier);
+ if (ret < 0)
+ goto error;
+
+ return 0;
+
+error:
+ debugfs_remove_recursive(debugfs_dir);
+ return ret;
+}
+
+static void __exit trelay_exit(void)
+{
+ struct trelay *tr, *tmp;
+
+ unregister_netdevice_notifier(&tr_dev_notifier);
+
+ rtnl_lock();
+ list_for_each_entry_safe(tr, tmp, &trelay_devs, list)
+ trelay_do_remove(tr);
+ rtnl_unlock();
+
+ debugfs_remove_recursive(debugfs_dir);
+}
+
+module_init(trelay_init);
+module_exit(trelay_exit);
+MODULE_LICENSE("GPL");
diff --git a/package/trelay/src/Makefile b/package/trelay/src/Makefile
new file mode 100644
index 0000000..e6bde89
--- /dev/null
+++ b/package/trelay/src/Makefile
@@ -0,0 +1 @@
+obj-m := trelay.o
diff --git a/package/trelay/src/trelay.c b/package/trelay/src/trelay.c
new file mode 100644
index 0000000..8fa4374
--- /dev/null
+++ b/package/trelay/src/trelay.c
@@ -0,0 +1,272 @@
+/*
+ * trelay.c: Trivial Ethernet Relay
+ *
+ * Copyright (C) 2012 Felix Fietkau <nbd@openwrt.org>
+ *
+ * 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
+ * of the License, 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.
+ */
+#include <linux/module.h>
+#include <linux/list.h>
+#include <linux/mutex.h>
+#include <linux/netdevice.h>
+#include <linux/rtnetlink.h>
+#include <linux/debugfs.h>
+
+static LIST_HEAD(trelay_devs);
+static struct dentry *debugfs_dir;
+
+struct trelay {
+ struct list_head list;
+ struct net_device *dev1, *dev2;
+ struct dentry *debugfs;
+ char name[];
+};
+
+rx_handler_result_t trelay_handle_frame(struct sk_buff **pskb)
+{
+ struct net_device *dev;
+ struct sk_buff *skb = *pskb;
+
+ dev = rcu_dereference(skb->dev->rx_handler_data);
+ if (!dev)
+ return RX_HANDLER_PASS;
+
+ if (skb->protocol == htons(ETH_P_PAE))
+ return RX_HANDLER_PASS;
+
+ skb_push(skb, ETH_HLEN);
+ skb->dev = dev;
+ skb_forward_csum(skb);
+ dev_queue_xmit(skb);
+
+ return RX_HANDLER_CONSUMED;
+}
+
+static int trelay_open(struct inode *inode, struct file *file)
+{
+ file->private_data = inode->i_private;
+ return 0;
+}
+
+static int trelay_do_remove(struct trelay *tr)
+{
+ list_del(&tr->list);
+
+ dev_put(tr->dev1);
+ dev_put(tr->dev2);
+
+ netdev_rx_handler_unregister(tr->dev1);
+ netdev_rx_handler_unregister(tr->dev2);
+
+ debugfs_remove_recursive(tr->debugfs);
+ kfree(tr);
+
+ return 0;
+}
+
+static struct trelay *trelay_find(struct net_device *dev)
+{
+ struct trelay *tr;
+
+ list_for_each_entry(tr, &trelay_devs, list) {
+ if (tr->dev1 == dev || tr->dev2 == dev)
+ return tr;
+ }
+ return NULL;
+}
+
+static int tr_device_event(struct notifier_block *unused, unsigned long event,
+ void *ptr)
+{
+ struct net_device *dev = ptr;
+ struct trelay *tr;
+
+ if (event != NETDEV_UNREGISTER)
+ goto out;
+
+ tr = trelay_find(dev);
+ if (!tr)
+ goto out;
+
+ trelay_do_remove(tr);
+
+out:
+ return NOTIFY_DONE;
+}
+
+static ssize_t trelay_remove_write(struct file *file, const char __user *ubuf,
+ size_t count, loff_t *ppos)
+{
+ struct trelay *tr = file->private_data;
+ int ret;
+
+ rtnl_lock();
+ ret = trelay_do_remove(tr);
+ rtnl_unlock();
+
+ if (ret < 0)
+ return ret;
+
+ return count;
+}
+
+static const struct file_operations fops_remove = {
+ .owner = THIS_MODULE,
+ .open = trelay_open,
+ .write = trelay_remove_write,
+ .llseek = default_llseek,
+};
+
+
+static int trelay_do_add(char *name, char *devn1, char *devn2)
+{
+ struct net_device *dev1, *dev2;
+ struct trelay *tr, *tr1;
+ int ret;
+
+ tr = kzalloc(sizeof(*tr) + strlen(name) + 1, GFP_KERNEL);
+ if (!tr)
+ return -ENOMEM;
+
+ rtnl_lock();
+ rcu_read_lock();
+
+ ret = -EEXIST;
+ list_for_each_entry(tr1, &trelay_devs, list) {
+ if (!strcmp(tr1->name, name))
+ goto out;
+ }
+
+ ret = -ENOENT;
+ dev1 = dev_get_by_name_rcu(&init_net, devn1);
+ dev2 = dev_get_by_name_rcu(&init_net, devn2);
+ if (!dev1 || !dev2)
+ goto out;
+
+ ret = netdev_rx_handler_register(dev1, trelay_handle_frame, dev2);
+ if (ret < 0)
+ goto out;
+
+ ret = netdev_rx_handler_register(dev2, trelay_handle_frame, dev1);
+ if (ret < 0) {
+ netdev_rx_handler_unregister(dev1);
+ goto out;
+ }
+
+ dev_hold(dev1);
+ dev_hold(dev2);
+
+ strcpy(tr->name, name);
+ tr->dev1 = dev1;
+ tr->dev2 = dev2;
+ list_add_tail(&tr->list, &trelay_devs);
+
+ tr->debugfs = debugfs_create_dir(name, debugfs_dir);
+ debugfs_create_file("remove", S_IWUSR, tr->debugfs, tr, &fops_remove);
+ ret = 0;
+
+out:
+ rcu_read_unlock();
+ rtnl_unlock();
+ if (ret < 0)
+ kfree(tr);
+
+ return ret;
+}
+
+static ssize_t trelay_add_write(struct file *file, const char __user *ubuf,
+ size_t count, loff_t *ppos)
+{
+ char buf[256];
+ char *dev1, *dev2, *tmp;
+ ssize_t len, ret;
+
+ len = min(count, sizeof(buf) - 1);
+ if (copy_from_user(buf, ubuf, len))
+ return -EFAULT;
+
+ buf[len] = 0;
+
+ if ((tmp = strchr(buf, '\n')))
+ *tmp = 0;
+
+ dev1 = strchr(buf, ',');
+ if (!dev1)
+ return -EINVAL;
+
+ *(dev1++) = 0;
+
+ dev2 = strchr(dev1, ',');
+ if (!dev2)
+ return -EINVAL;
+
+ *(dev2++) = 0;
+ if (strchr(dev2, ','))
+ return -EINVAL;
+
+ if (!strlen(buf) || !strlen(dev1) || !strlen(dev2))
+ return -EINVAL;
+
+ ret = trelay_do_add(buf, dev1, dev2);
+ if (ret < 0)
+ return ret;
+
+ return count;
+}
+
+static const struct file_operations fops_add = {
+ .owner = THIS_MODULE,
+ .write = trelay_add_write,
+ .llseek = default_llseek,
+};
+
+static struct notifier_block tr_dev_notifier = {
+ .notifier_call = tr_device_event
+};
+
+static int __init trelay_init(void)
+{
+ int ret;
+
+ debugfs_dir = debugfs_create_dir("trelay", NULL);
+ if (!debugfs_dir)
+ return -ENOMEM;
+
+ debugfs_create_file("add", S_IWUSR, debugfs_dir, NULL, &fops_add);
+
+ ret = register_netdevice_notifier(&tr_dev_notifier);
+ if (ret < 0)
+ goto error;
+
+ return 0;
+
+error:
+ debugfs_remove_recursive(debugfs_dir);
+ return ret;
+}
+
+static void __exit trelay_exit(void)
+{
+ struct trelay *tr, *tmp;
+
+ unregister_netdevice_notifier(&tr_dev_notifier);
+
+ rtnl_lock();
+ list_for_each_entry_safe(tr, tmp, &trelay_devs, list)
+ trelay_do_remove(tr);
+ rtnl_unlock();
+
+ debugfs_remove_recursive(debugfs_dir);
+}
+
+module_init(trelay_init);
+module_exit(trelay_exit);
+MODULE_LICENSE("GPL");
diff --git a/package/ubus/.svn/entries b/package/ubus/.svn/entries
new file mode 100644
index 0000000..1a9ecfe
--- /dev/null
+++ b/package/ubus/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/ubus
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-03-13T15:45:41.452776Z
+35997
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+files
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+5cdfe877ce315f5b5c6c66738f529b5d
+2013-03-13T15:45:41.452776Z
+35997
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1870
+
diff --git a/package/ubus/.svn/text-base/Makefile.svn-base b/package/ubus/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..3092a0b
--- /dev/null
+++ b/package/ubus/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,84 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=ubus
+PKG_VERSION:=2013-03-06
+PKG_RELEASE=$(PKG_SOURCE_VERSION)
+
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL:=git://nbd.name/luci2/ubus.git
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE_VERSION:=495f4608189049495c7b4f6c5198bba556d6e9b0
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
+PKG_MIRROR_MD5SUM:=23b9c14fff1d39fc34e7eca80fb936a2
+CMAKE_INSTALL:=1
+
+PKG_LICENSE:=LGPLv2.1
+PKG_LICENSE_FILES:=
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/cmake.mk
+
+define Package/ubus
+ SECTION:=luci2
+ CATEGORY:=LuCI2
+ SUBMENU:=System
+ DEPENDS:=+libubus +libblobmsg-json +ubusd
+ TITLE:=OpenWrt RPC client utility
+endef
+
+define Package/ubusd
+ SECTION:=luci2
+ CATEGORY:=LuCI2
+ SUBMENU:=System
+ TITLE:=OpenWrt RPC daemon
+ DEPENDS:=+libubox
+endef
+
+define Package/libubus
+ SECTION:=luci2
+ CATEGORY:=LuCI2
+ SUBMENU:=Libraries
+ DEPENDS:=+libubox
+ TITLE:=OpenWrt RPC client library
+endef
+
+define Package/libubus-lua
+ SECTION:=luci2
+ CATEGORY:=LuCI2
+ SUBMENU:=Libraries
+ DEPENDS:=+libubus +liblua
+ TITLE:=Lua binding for the OpenWrt RPC client
+endef
+
+TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include
+
+CMAKE_OPTIONS = \
+ -DLUAPATH=/usr/lib/lua
+
+define Package/ubus/install
+ $(INSTALL_DIR) $(1)/bin
+ $(CP) $(PKG_INSTALL_DIR)/usr/bin/ubus $(1)/bin/
+endef
+
+define Package/ubusd/install
+ $(INSTALL_DIR) $(1)/sbin
+ $(CP) $(PKG_INSTALL_DIR)/usr/sbin/ubusd $(1)/sbin/
+endef
+
+define Package/libubus/install
+ $(INSTALL_DIR) $(1)/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/* $(1)/lib/
+endef
+
+define Package/libubus-lua/install
+ $(INSTALL_DIR) $(1)/usr/lib/lua
+ $(CP) $(PKG_BUILD_DIR)/lua/ubus.so $(1)/usr/lib/lua/
+endef
+
+$(eval $(call BuildPackage,ubus))
+$(eval $(call BuildPackage,ubusd))
+$(eval $(call BuildPackage,libubus))
+$(eval $(call BuildPackage,libubus-lua))
+
diff --git a/package/ubus/Makefile b/package/ubus/Makefile
new file mode 100644
index 0000000..3092a0b
--- /dev/null
+++ b/package/ubus/Makefile
@@ -0,0 +1,84 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=ubus
+PKG_VERSION:=2013-03-06
+PKG_RELEASE=$(PKG_SOURCE_VERSION)
+
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL:=git://nbd.name/luci2/ubus.git
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE_VERSION:=495f4608189049495c7b4f6c5198bba556d6e9b0
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
+PKG_MIRROR_MD5SUM:=23b9c14fff1d39fc34e7eca80fb936a2
+CMAKE_INSTALL:=1
+
+PKG_LICENSE:=LGPLv2.1
+PKG_LICENSE_FILES:=
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/cmake.mk
+
+define Package/ubus
+ SECTION:=luci2
+ CATEGORY:=LuCI2
+ SUBMENU:=System
+ DEPENDS:=+libubus +libblobmsg-json +ubusd
+ TITLE:=OpenWrt RPC client utility
+endef
+
+define Package/ubusd
+ SECTION:=luci2
+ CATEGORY:=LuCI2
+ SUBMENU:=System
+ TITLE:=OpenWrt RPC daemon
+ DEPENDS:=+libubox
+endef
+
+define Package/libubus
+ SECTION:=luci2
+ CATEGORY:=LuCI2
+ SUBMENU:=Libraries
+ DEPENDS:=+libubox
+ TITLE:=OpenWrt RPC client library
+endef
+
+define Package/libubus-lua
+ SECTION:=luci2
+ CATEGORY:=LuCI2
+ SUBMENU:=Libraries
+ DEPENDS:=+libubus +liblua
+ TITLE:=Lua binding for the OpenWrt RPC client
+endef
+
+TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include
+
+CMAKE_OPTIONS = \
+ -DLUAPATH=/usr/lib/lua
+
+define Package/ubus/install
+ $(INSTALL_DIR) $(1)/bin
+ $(CP) $(PKG_INSTALL_DIR)/usr/bin/ubus $(1)/bin/
+endef
+
+define Package/ubusd/install
+ $(INSTALL_DIR) $(1)/sbin
+ $(CP) $(PKG_INSTALL_DIR)/usr/sbin/ubusd $(1)/sbin/
+endef
+
+define Package/libubus/install
+ $(INSTALL_DIR) $(1)/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/* $(1)/lib/
+endef
+
+define Package/libubus-lua/install
+ $(INSTALL_DIR) $(1)/usr/lib/lua
+ $(CP) $(PKG_BUILD_DIR)/lua/ubus.so $(1)/usr/lib/lua/
+endef
+
+$(eval $(call BuildPackage,ubus))
+$(eval $(call BuildPackage,ubusd))
+$(eval $(call BuildPackage,libubus))
+$(eval $(call BuildPackage,libubus-lua))
+
diff --git a/package/ubus/files/.svn/entries b/package/ubus/files/.svn/entries
new file mode 100644
index 0000000..579a7fd
--- /dev/null
+++ b/package/ubus/files/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/ubus/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2011-11-07T22:59:01.540795Z
+28840
+nico
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+ubus.init
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+73b1d679b3d79484e7671d77c91deaf4
+2011-11-07T22:59:01.540795Z
+28840
+nico
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+154
+
diff --git a/package/ubus/files/.svn/prop-base/ubus.init.svn-base b/package/ubus/files/.svn/prop-base/ubus.init.svn-base
new file mode 100644
index 0000000..869ac71
--- /dev/null
+++ b/package/ubus/files/.svn/prop-base/ubus.init.svn-base
@@ -0,0 +1,5 @@
+K 14
+svn:executable
+V 1
+*
+END
diff --git a/package/ubus/files/.svn/text-base/ubus.init.svn-base b/package/ubus/files/.svn/text-base/ubus.init.svn-base
new file mode 100644
index 0000000..70fe21c
--- /dev/null
+++ b/package/ubus/files/.svn/text-base/ubus.init.svn-base
@@ -0,0 +1,14 @@
+#!/bin/sh /etc/rc.common
+
+START=11
+
+SERVICE_DAEMONIZE=1
+SERVICE_WRITE_PID=1
+
+start() {
+ service_start /sbin/ubusd
+}
+
+stop() {
+ service_stop /sbin/ubusd
+}
diff --git a/package/ubus/files/ubus.init b/package/ubus/files/ubus.init
new file mode 100755
index 0000000..70fe21c
--- /dev/null
+++ b/package/ubus/files/ubus.init
@@ -0,0 +1,14 @@
+#!/bin/sh /etc/rc.common
+
+START=11
+
+SERVICE_DAEMONIZE=1
+SERVICE_WRITE_PID=1
+
+start() {
+ service_start /sbin/ubusd
+}
+
+stop() {
+ service_stop /sbin/ubusd
+}
diff --git a/package/uci/.svn/entries b/package/uci/.svn/entries
new file mode 100644
index 0000000..1c49a52
--- /dev/null
+++ b/package/uci/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/uci
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-04T16:10:17.906229Z
+35013
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+files
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+e4e2b59e756694e7348c116820aaf11a
+2013-01-04T16:10:17.906229Z
+35013
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2156
+
diff --git a/package/uci/.svn/text-base/Makefile.svn-base b/package/uci/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..029e636
--- /dev/null
+++ b/package/uci/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,92 @@
+#
+# Copyright (C) 2008-2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+UCI_VERSION=2013-01-04
+UCI_RELEASE=1
+
+PKG_NAME:=uci
+PKG_VERSION:=$(UCI_VERSION)$(if $(UCI_RELEASE),.$(UCI_RELEASE))
+PKG_RELEASE:=1
+PKG_REV:=e4516d01a7d2b0a5a8def7b5791c7d4032138287
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=git://nbd.name/uci.git
+PKG_SOURCE_SUBDIR:=uci-$(PKG_VERSION)
+PKG_SOURCE_VERSION:=$(PKG_REV)
+PKG_SOURCE_PROTO:=git
+PKG_MIRROR_MD5SUM:=c7c4fd6723b607ae7fa039a1078fe7d5
+
+PKG_LICENSE:=LGPLv2.1 GPLv2
+PKG_LICENSE_FILES:=
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+
+PKG_BUILD_PARALLEL:=0
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/cmake.mk
+
+# set to 1 to enable debugging
+DEBUG=
+
+define Package/libuci
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=C library for the Unified Configuration Interface (UCI)
+endef
+
+define Package/uci
+ SECTION:=base
+ CATEGORY:=Base system
+ DEPENDS:=+libuci
+ TITLE:=Utility for the Unified Configuration Interface (UCI)
+endef
+
+define Package/libuci-lua
+ SECTION=libs
+ CATEGORY=Libraries
+ DEPENDS:=+libuci +liblua
+ TITLE:=Lua plugin for UCI
+endef
+
+TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include
+TARGET_LDFLAGS += -L$(STAGING_DIR)/usr/lib
+
+CMAKE_OPTIONS = \
+ -DLUAPATH=/usr/lib/lua \
+ $(if $(DEBUG),-DUCI_DEBUG=ON)
+
+define Package/libuci/install
+ $(INSTALL_DIR) $(1)/lib
+ $(CP) $(PKG_BUILD_DIR)/libuci.so* $(1)/lib/
+endef
+
+define Package/libuci-lua/install
+ $(INSTALL_DIR) $(1)/usr/lib/lua
+ $(CP) $(PKG_BUILD_DIR)/lua/uci.so $(1)/usr/lib/lua/
+endef
+
+define Package/uci/install
+ $(INSTALL_DIR) $(1)/etc/uci-defaults
+ $(INSTALL_DIR) $(1)/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/uci $(1)/sbin/
+ $(CP) ./files/* $(1)/
+endef
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include
+ $(CP) $(PKG_BUILD_DIR)/uci{,_config,map}.h $(1)/usr/include
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_BUILD_DIR)/libuci.so* $(1)/usr/lib
+ $(CP) $(PKG_BUILD_DIR)/libucimap.a $(1)/usr/lib
+endef
+
+$(eval $(call BuildPackage,uci))
+$(eval $(call BuildPackage,libuci))
+$(eval $(call BuildPackage,libuci-lua))
diff --git a/package/uci/Makefile b/package/uci/Makefile
new file mode 100644
index 0000000..029e636
--- /dev/null
+++ b/package/uci/Makefile
@@ -0,0 +1,92 @@
+#
+# Copyright (C) 2008-2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+UCI_VERSION=2013-01-04
+UCI_RELEASE=1
+
+PKG_NAME:=uci
+PKG_VERSION:=$(UCI_VERSION)$(if $(UCI_RELEASE),.$(UCI_RELEASE))
+PKG_RELEASE:=1
+PKG_REV:=e4516d01a7d2b0a5a8def7b5791c7d4032138287
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=git://nbd.name/uci.git
+PKG_SOURCE_SUBDIR:=uci-$(PKG_VERSION)
+PKG_SOURCE_VERSION:=$(PKG_REV)
+PKG_SOURCE_PROTO:=git
+PKG_MIRROR_MD5SUM:=c7c4fd6723b607ae7fa039a1078fe7d5
+
+PKG_LICENSE:=LGPLv2.1 GPLv2
+PKG_LICENSE_FILES:=
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+
+PKG_BUILD_PARALLEL:=0
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/cmake.mk
+
+# set to 1 to enable debugging
+DEBUG=
+
+define Package/libuci
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=C library for the Unified Configuration Interface (UCI)
+endef
+
+define Package/uci
+ SECTION:=base
+ CATEGORY:=Base system
+ DEPENDS:=+libuci
+ TITLE:=Utility for the Unified Configuration Interface (UCI)
+endef
+
+define Package/libuci-lua
+ SECTION=libs
+ CATEGORY=Libraries
+ DEPENDS:=+libuci +liblua
+ TITLE:=Lua plugin for UCI
+endef
+
+TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include
+TARGET_LDFLAGS += -L$(STAGING_DIR)/usr/lib
+
+CMAKE_OPTIONS = \
+ -DLUAPATH=/usr/lib/lua \
+ $(if $(DEBUG),-DUCI_DEBUG=ON)
+
+define Package/libuci/install
+ $(INSTALL_DIR) $(1)/lib
+ $(CP) $(PKG_BUILD_DIR)/libuci.so* $(1)/lib/
+endef
+
+define Package/libuci-lua/install
+ $(INSTALL_DIR) $(1)/usr/lib/lua
+ $(CP) $(PKG_BUILD_DIR)/lua/uci.so $(1)/usr/lib/lua/
+endef
+
+define Package/uci/install
+ $(INSTALL_DIR) $(1)/etc/uci-defaults
+ $(INSTALL_DIR) $(1)/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/uci $(1)/sbin/
+ $(CP) ./files/* $(1)/
+endef
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include
+ $(CP) $(PKG_BUILD_DIR)/uci{,_config,map}.h $(1)/usr/include
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_BUILD_DIR)/libuci.so* $(1)/usr/lib
+ $(CP) $(PKG_BUILD_DIR)/libucimap.a $(1)/usr/lib
+endef
+
+$(eval $(call BuildPackage,uci))
+$(eval $(call BuildPackage,libuci))
+$(eval $(call BuildPackage,libuci-lua))
diff --git a/package/uci/files/.svn/entries b/package/uci/files/.svn/entries
new file mode 100644
index 0000000..2d8eeb6
--- /dev/null
+++ b/package/uci/files/.svn/entries
@@ -0,0 +1,31 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/uci/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2011-07-15T14:52:38.130445Z
+27614
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+lib
+dir
+
diff --git a/package/uci/files/lib/.svn/entries b/package/uci/files/lib/.svn/entries
new file mode 100644
index 0000000..ffc58cd
--- /dev/null
+++ b/package/uci/files/lib/.svn/entries
@@ -0,0 +1,31 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/uci/files/lib
+svn://svn.openwrt.org/openwrt
+
+
+
+2011-07-15T14:52:38.130445Z
+27614
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+config
+dir
+
diff --git a/package/uci/files/lib/config/.svn/entries b/package/uci/files/lib/config/.svn/entries
new file mode 100644
index 0000000..ad7f074
--- /dev/null
+++ b/package/uci/files/lib/config/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/uci/files/lib/config
+svn://svn.openwrt.org/openwrt
+
+
+
+2011-07-15T14:52:38.130445Z
+27614
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+uci.sh
+file
+
+
+
+
+2013-03-17T12:13:22.000000Z
+3212c1b6b13f6c5628165a36ec50b46f
+2011-07-15T14:52:38.130445Z
+27614
+jow
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3646
+
diff --git a/package/uci/files/lib/config/.svn/text-base/uci.sh.svn-base b/package/uci/files/lib/config/.svn/text-base/uci.sh.svn-base
new file mode 100644
index 0000000..db84c83
--- /dev/null
+++ b/package/uci/files/lib/config/.svn/text-base/uci.sh.svn-base
@@ -0,0 +1,137 @@
+#!/bin/sh
+# Shell script compatibility wrappers for /sbin/uci
+#
+# Copyright (C) 2008-2010 OpenWrt.org
+# Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
+#
+# 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 of the License, 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; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+CONFIG_APPEND=
+uci_load() {
+ local PACKAGE="$1"
+ local DATA
+ local RET
+ local VAR
+
+ _C=0
+ if [ -z "$CONFIG_APPEND" ]; then
+ for VAR in $CONFIG_LIST_STATE; do
+ export ${NO_EXPORT:+-n} CONFIG_${VAR}=
+ export ${NO_EXPORT:+-n} CONFIG_${VAR}_LENGTH=
+ done
+ export ${NO_EXPORT:+-n} CONFIG_LIST_STATE=
+ export ${NO_EXPORT:+-n} CONFIG_SECTIONS=
+ export ${NO_EXPORT:+-n} CONFIG_NUM_SECTIONS=0
+ export ${NO_EXPORT:+-n} CONFIG_SECTION=
+ fi
+
+ DATA="$(/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} ${LOAD_STATE:+-P /var/state} -S -n export "$PACKAGE" 2>/dev/null)"
+ RET="$?"
+ [ "$RET" != 0 -o -z "$DATA" ] || eval "$DATA"
+ unset DATA
+
+ ${CONFIG_SECTION:+config_cb}
+ return "$RET"
+}
+
+uci_set_default() {
+ local PACKAGE="$1"
+ /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q show "$PACKAGE" > /dev/null && return 0
+ /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} import "$PACKAGE"
+ /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit "$PACKAGE"
+}
+
+uci_revert_state() {
+ local PACKAGE="$1"
+ local CONFIG="$2"
+ local OPTION="$3"
+
+ /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -P /var/state revert "$PACKAGE${CONFIG:+.$CONFIG}${OPTION:+.$OPTION}"
+}
+
+uci_set_state() {
+ local PACKAGE="$1"
+ local CONFIG="$2"
+ local OPTION="$3"
+ local VALUE="$4"
+
+ [ "$#" = 4 ] || return 0
+ /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -P /var/state set "$PACKAGE.$CONFIG${OPTION:+.$OPTION}=$VALUE"
+}
+
+uci_toggle_state() {
+ uci_revert_state "$1" "$2" "$3"
+ uci_set_state "$1" "$2" "$3" "$4"
+}
+
+uci_set() {
+ local PACKAGE="$1"
+ local CONFIG="$2"
+ local OPTION="$3"
+ local VALUE="$4"
+
+ /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set "$PACKAGE.$CONFIG.$OPTION=$VALUE"
+}
+
+uci_get_state() {
+ uci_get "$1" "$2" "$3" "$4" "/var/state"
+}
+
+uci_get() {
+ local PACKAGE="$1"
+ local CONFIG="$2"
+ local OPTION="$3"
+ local DEFAULT="$4"
+ local STATE="$5"
+
+ /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} ${STATE:+-P $STATE} -q get "$PACKAGE${CONFIG:+.$CONFIG}${OPTION:+.$OPTION}"
+ RET="$?"
+ [ "$RET" -ne 0 ] && [ -n "$DEFAULT" ] && echo "$DEFAULT"
+ return "$RET"
+}
+
+uci_add() {
+ local PACKAGE="$1"
+ local TYPE="$2"
+ local CONFIG="$3"
+
+ if [ -z "$CONFIG" ]; then
+ export ${NO_EXPORT:+-n} CONFIG_SECTION="$(/sbin/uci add "$PACKAGE" "$TYPE")"
+ else
+ /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set "$PACKAGE.$CONFIG=$TYPE"
+ export ${NO_EXPORT:+-n} CONFIG_SECTION="$CONFIG"
+ fi
+}
+
+uci_rename() {
+ local PACKAGE="$1"
+ local CONFIG="$2"
+ local VALUE="$3"
+
+ /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} rename "$PACKAGE.$CONFIG=$VALUE"
+}
+
+uci_remove() {
+ local PACKAGE="$1"
+ local CONFIG="$2"
+ local OPTION="$3"
+
+ /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} del "$PACKAGE.$CONFIG${OPTION:+.$OPTION}"
+}
+
+uci_commit() {
+ local PACKAGE="$1"
+ /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit $PACKAGE
+}
diff --git a/package/uci/files/lib/config/uci.sh b/package/uci/files/lib/config/uci.sh
new file mode 100644
index 0000000..db84c83
--- /dev/null
+++ b/package/uci/files/lib/config/uci.sh
@@ -0,0 +1,137 @@
+#!/bin/sh
+# Shell script compatibility wrappers for /sbin/uci
+#
+# Copyright (C) 2008-2010 OpenWrt.org
+# Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
+#
+# 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 of the License, 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; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+CONFIG_APPEND=
+uci_load() {
+ local PACKAGE="$1"
+ local DATA
+ local RET
+ local VAR
+
+ _C=0
+ if [ -z "$CONFIG_APPEND" ]; then
+ for VAR in $CONFIG_LIST_STATE; do
+ export ${NO_EXPORT:+-n} CONFIG_${VAR}=
+ export ${NO_EXPORT:+-n} CONFIG_${VAR}_LENGTH=
+ done
+ export ${NO_EXPORT:+-n} CONFIG_LIST_STATE=
+ export ${NO_EXPORT:+-n} CONFIG_SECTIONS=
+ export ${NO_EXPORT:+-n} CONFIG_NUM_SECTIONS=0
+ export ${NO_EXPORT:+-n} CONFIG_SECTION=
+ fi
+
+ DATA="$(/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} ${LOAD_STATE:+-P /var/state} -S -n export "$PACKAGE" 2>/dev/null)"
+ RET="$?"
+ [ "$RET" != 0 -o -z "$DATA" ] || eval "$DATA"
+ unset DATA
+
+ ${CONFIG_SECTION:+config_cb}
+ return "$RET"
+}
+
+uci_set_default() {
+ local PACKAGE="$1"
+ /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q show "$PACKAGE" > /dev/null && return 0
+ /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} import "$PACKAGE"
+ /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit "$PACKAGE"
+}
+
+uci_revert_state() {
+ local PACKAGE="$1"
+ local CONFIG="$2"
+ local OPTION="$3"
+
+ /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -P /var/state revert "$PACKAGE${CONFIG:+.$CONFIG}${OPTION:+.$OPTION}"
+}
+
+uci_set_state() {
+ local PACKAGE="$1"
+ local CONFIG="$2"
+ local OPTION="$3"
+ local VALUE="$4"
+
+ [ "$#" = 4 ] || return 0
+ /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -P /var/state set "$PACKAGE.$CONFIG${OPTION:+.$OPTION}=$VALUE"
+}
+
+uci_toggle_state() {
+ uci_revert_state "$1" "$2" "$3"
+ uci_set_state "$1" "$2" "$3" "$4"
+}
+
+uci_set() {
+ local PACKAGE="$1"
+ local CONFIG="$2"
+ local OPTION="$3"
+ local VALUE="$4"
+
+ /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set "$PACKAGE.$CONFIG.$OPTION=$VALUE"
+}
+
+uci_get_state() {
+ uci_get "$1" "$2" "$3" "$4" "/var/state"
+}
+
+uci_get() {
+ local PACKAGE="$1"
+ local CONFIG="$2"
+ local OPTION="$3"
+ local DEFAULT="$4"
+ local STATE="$5"
+
+ /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} ${STATE:+-P $STATE} -q get "$PACKAGE${CONFIG:+.$CONFIG}${OPTION:+.$OPTION}"
+ RET="$?"
+ [ "$RET" -ne 0 ] && [ -n "$DEFAULT" ] && echo "$DEFAULT"
+ return "$RET"
+}
+
+uci_add() {
+ local PACKAGE="$1"
+ local TYPE="$2"
+ local CONFIG="$3"
+
+ if [ -z "$CONFIG" ]; then
+ export ${NO_EXPORT:+-n} CONFIG_SECTION="$(/sbin/uci add "$PACKAGE" "$TYPE")"
+ else
+ /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set "$PACKAGE.$CONFIG=$TYPE"
+ export ${NO_EXPORT:+-n} CONFIG_SECTION="$CONFIG"
+ fi
+}
+
+uci_rename() {
+ local PACKAGE="$1"
+ local CONFIG="$2"
+ local VALUE="$3"
+
+ /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} rename "$PACKAGE.$CONFIG=$VALUE"
+}
+
+uci_remove() {
+ local PACKAGE="$1"
+ local CONFIG="$2"
+ local OPTION="$3"
+
+ /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} del "$PACKAGE.$CONFIG${OPTION:+.$OPTION}"
+}
+
+uci_commit() {
+ local PACKAGE="$1"
+ /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit $PACKAGE
+}
diff --git a/package/udev/.svn/entries b/package/udev/.svn/entries
new file mode 100644
index 0000000..06d88b3
--- /dev/null
+++ b/package/udev/.svn/entries
@@ -0,0 +1,99 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/udev
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-02-21T23:12:17.523992Z
+35741
+geoff
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+patches
+dir
+
+Config.in
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+55c9c9908fde18f6b5abaadd43278d3f
+2011-08-25T10:49:29.640068Z
+28085
+florian
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2581
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+9626382fab7ee9d5560c1477db5826d0
+2013-02-21T23:12:17.523992Z
+35741
+geoff
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4701
+
diff --git a/package/udev/.svn/prop-base/Config.in.svn-base b/package/udev/.svn/prop-base/Config.in.svn-base
new file mode 100644
index 0000000..3160658
--- /dev/null
+++ b/package/udev/.svn/prop-base/Config.in.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:mergeinfo
+V 0
+
+END
diff --git a/package/udev/.svn/prop-base/Makefile.svn-base b/package/udev/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..8e522ae
--- /dev/null
+++ b/package/udev/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1,9 @@
+K 13
+svn:copyright
+V 30
+Copyright (C) 2006 OpenWrt.org
+K 13
+svn:eol-style
+V 6
+native
+END
diff --git a/package/udev/.svn/text-base/Config.in.svn-base b/package/udev/.svn/text-base/Config.in.svn-base
new file mode 100644
index 0000000..56033d8
--- /dev/null
+++ b/package/udev/.svn/text-base/Config.in.svn-base
@@ -0,0 +1,118 @@
+# udev package config
+
+menu "Configuration"
+ depends on PACKAGE_udev
+
+config UDEV_DISABLE_LOGGING
+ bool "Disable udev logging to syslog"
+ default n
+ help
+ Disable logging of udev messages to the syslog. If
+ unsure, choose the default N.
+
+config UDEV_ENABLE_DEBUG
+ bool "Enable debug build of the udev package"
+ default n
+ help
+ Compile in udev debug messages. If unsure, choose
+ the default N.
+
+config UDEV_EXTRA_accelerometer
+ bool "Install udev acceleroometer callout"
+ default y
+ help
+ accelerometer - udev callout to export device orientation
+ through property
+
+config UDEV_EXTRA_ata_id
+ bool "Install udev ata_id callout"
+ default y
+ help
+ ata_id - udev callout to read product/serial number
+ from ATA drives
+
+config UDEV_EXTRA_cdrom_id
+ bool "Install udev cdrom_id callout"
+ default y
+ help
+ cdrom_id - udev callout to determine the capabilities
+ of optical drives and media
+
+config UDEV_EXTRA_collect
+ bool "Install udev collect"
+ default n
+ help
+ Adds ID to the list governed by <checkpoint>
+
+config UDEV_EXTRA_edd_id
+ bool "Install udev edd_id callout"
+ default n
+ help
+ edd_id - udev callout to identify BIOS disk drives
+ via EDD
+
+config UDEV_EXTRA_firmware
+ bool "Install firmware support"
+ default n
+ help
+ udev firmware loader
+ via EDD
+
+config UDEV_EXTRA_floppy
+ bool "Install create_floppy_devices callout"
+ default n
+ help
+ create_floppy_devices - udev callout to create all
+ possible floppy device based on the CMOS type
+
+config UDEV_EXTRA_input_id
+ bool "Install input_id callout"
+ default y
+ help
+ input_id - udev callout to classify input devices
+
+config UDEV_EXTRA_mtd_probe
+ bool "Install mtd_probe callout"
+ default y
+ help
+ mtd_probe - udev callout to probe mtd devices
+
+config UDEV_EXTRA_path_id
+ bool "Install udev path_id callout"
+ default y
+ help
+ path_id - udev callout to create a device path based
+ unique name for a device to implement the Linux
+ Persistent Device Naming scheme
+
+config UDEV_EXTRA_qemu
+ bool "Install qemu specific rules"
+ default y
+ help
+ Install rules for autosuspension of QEMU emulated
+ USB HID devices
+
+config UDEV_EXTRA_rule_generator
+ bool "Install udev rule_generator"
+ default y
+ help
+
+config UDEV_EXTRA_scsi_id
+ bool "Install udev scsi_id callout"
+ default y
+ help
+ scsi_id - retrieve and generate a unique SCSI identifier
+
+config UDEV_EXTRA_usb_id
+ bool "Install udev usb_id callout"
+ default y
+ help
+ usb_id - can find the unique id of USB devices
+
+config UDEV_EXTRA_v4l_id
+ bool "Install udev v4l_id callout"
+ default y
+ help
+ v4l_id - udev callout to identify Video4Linux devices
+
+endmenu
diff --git a/package/udev/.svn/text-base/Makefile.svn-base b/package/udev/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..4679917
--- /dev/null
+++ b/package/udev/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,156 @@
+#
+# Copyright (C) 2006-2008 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=udev
+PKG_VERSION:=173
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=@KERNEL/linux/utils/kernel/hotplug/
+PKG_MD5SUM:=91a88a359b60bbd074b024883cc0dbde
+
+include $(INCLUDE_DIR)/package.mk
+
+PKG_INSTALL=1
+
+define Package/udev
+ SECTION:=base
+ CATEGORY:=Base system
+ TITLE:=Dynamic device management subsystem
+ URL:=http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev.html
+ MAINTAINER:=Geoff Levand <geoff@infradead.org>
+ MENU:=1
+ DEPENDS:=+librt
+endef
+
+define Package/udev/description
+ udev allows Linux users to have a dynamic /dev directory and it
+ provides the ability to have persistent device names.
+endef
+
+define Package/udev/conffiles
+/etc/udev/udev.conf
+endef
+
+define Package/udev/config
+ source "$(SOURCE)/Config.in"
+endef
+
+udev-args-$(CONFIG_UDEV_DISABLE_LOGGING) += --disable-logging
+udev-args-$(CONFIG_UDEV_ENABLE_DEBUG) += --enable-debug
+udev-args-$(CONFIG_UDEV_EXTRA_edd_id) += --enable-edd
+udev-args-$(CONFIG_UDEV_EXTRA_floppy) += --enable-floppy
+
+# TODO: make hwdb and introspection work
+
+CONFIGURE_ARGS += --prefix=/usr --exec-prefix= --sysconfdir=/etc \
+ --disable-hwdb --disable-keymap --disable-gudev --disable-introspection \
+ --libexecdir=/lib/udev --disable-gtk-doc-html \
+ --sbindir=/sbin $(udev-args-y)
+
+udev-extra-lib-bin-$(CONFIG_UDEV_EXTRA_accelerometer) += accelerometer
+udev-extra-rules-$(CONFIG_UDEV_EXTRA_accelerometer) += 61-accelerometer.rules
+
+udev-extra-lib-bin-$(CONFIG_UDEV_EXTRA_ata_id) += ata_id
+
+udev-extra-lib-bin-$(CONFIG_UDEV_EXTRA_cdrom_id) += cdrom_id
+udev-extra-rules-$(CONFIG_UDEV_EXTRA_cdrom_id) += 60-cdrom_id.rules
+
+udev-extra-lib-bin-$(CONFIG_UDEV_EXTRA_collect) += collect
+
+udev-extra-lib-bin-$(CONFIG_UDEV_EXTRA_edd_id) += edd_id
+udev-extra-rules-$(CONFIG_UDEV_EXTRA_edd_id) += 61-persistent-storage-edd.rules
+
+udev-extra-lib-bin-$(CONFIG_UDEV_EXTRA_firmware) += firmware
+udev-extra-rules-$(CONFIG_UDEV_EXTRA_firmware) += 50-firmware.rules
+
+udev-extra-lib-bin-$(CONFIG_UDEV_EXTRA_floppy) += create_floppy_devices
+
+# TODO: make gudev work
+
+udev-extra-lib-bin-$(CONFIG_UDEV_EXTRA_input_id) += input_id
+
+# TODO: make keymap work
+
+udev-extra-lib-bin-$(CONFIG_UDEV_EXTRA_mtd_probe) += mtd_probe
+udev-extra-rules-$(CONFIG_UDEV_EXTRA_mtd_probe) += 75-probe_mtd.rules
+
+udev-extra-lib-bin-$(CONFIG_UDEV_EXTRA_path_id) += path_id
+
+udev-extra-rules-$(CONFIG_UDEV_EXTRA_qemu) += 42-qemu-usb.rules
+
+udev-extra-lib-bin-$(CONFIG_UDEV_EXTRA_rule_generator) += \
+ write_cd_rules write_net_rules
+udev-extra-lib-data-$(CONFIG_UDEV_EXTRA_rule_generator) += \
+ rule_generator.functions
+udev-extra-rules-$(CONFIG_UDEV_EXTRA_rule_generator) += \
+ 75-cd-aliases-generator.rules 75-persistent-net-generator.rules
+
+udev-extra-lib-bin-$(CONFIG_UDEV_EXTRA_scsi_id) += scsi_id
+
+# TODO: make udev-acl work
+
+udev-extra-lib-bin-$(CONFIG_UDEV_EXTRA_usb_id) += usb_id
+
+udev-extra-lib-bin-$(CONFIG_UDEV_EXTRA_v4l_id) += v4l_id
+udev-extra-rules-$(CONFIG_UDEV_EXTRA_v4l_id) += 60-persistent-v4l.rules
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include
+ $(CP) $(PKG_INSTALL_DIR)/usr/include/libudev.h $(1)/usr/include
+ $(INSTALL_DIR) $(1)/usr/share/pkgconfig
+ $(CP) $(PKG_INSTALL_DIR)/usr/share/pkgconfig/udev.pc $(1)/usr/share/pkgconfig
+ $(INSTALL_DIR) $(1)/lib
+ $(CP) $(PKG_INSTALL_DIR)/lib/libudev.so* $(1)/lib
+ $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
+ $(CP) $(PKG_INSTALL_DIR)/lib/pkgconfig/libudev.pc $(1)/usr/lib/pkgconfig
+endef
+
+define Package/udev/install
+ $(INSTALL_DIR) $(1)/etc/udev/rules.d
+ $(INSTALL_DATA) $(PKG_INSTALL_DIR)/etc/udev/udev.conf $(1)/etc/udev
+
+ $(INSTALL_DIR) $(1)/sbin
+ $(INSTALL_BIN) \
+ $(PKG_INSTALL_DIR)/sbin/udevadm \
+ $(PKG_INSTALL_DIR)/sbin/udevd \
+ $(1)/sbin
+
+ $(INSTALL_DIR) $(1)/lib/udev/rules.d
+ $(INSTALL_DATA) \
+ $(addprefix $(PKG_INSTALL_DIR)/lib/udev/rules.d/, \
+ $(udev-extra-rules-y)) \
+ $(addprefix $(PKG_INSTALL_DIR)/lib/udev/rules.d/, \
+ 50-udev-default.rules \
+ 60-persistent-input.rules \
+ 60-persistent-serial.rules \
+ 60-persistent-storage.rules \
+ 80-drivers.rules \
+ 95-udev-late.rules) \
+ $(1)/lib/udev/rules.d
+
+ $(INSTALL_DIR) $(1)/lib
+ $(CP) $(PKG_INSTALL_DIR)/lib/libudev.so* $(1)/lib
+
+ $(INSTALL_DIR) $(1)/lib/udev
+ifneq ($(udev-extra-lib-bin-y),)
+ $(INSTALL_BIN) \
+ $(addprefix $(PKG_INSTALL_DIR)/lib/udev/, \
+ $(udev-extra-lib-bin-y)) \
+ $(1)/lib/udev/
+endif
+ifneq ($(udev-extra-lib-data-y),)
+ $(INSTALL_DATA) \
+ $(addprefix $(PKG_INSTALL_DIR)/lib/udev/, \
+ $(udev-extra-lib-data-y)) \
+ $(1)/lib/udev/
+endif
+endef
+
+$(eval $(call BuildPackage,udev))
diff --git a/package/udev/Config.in b/package/udev/Config.in
new file mode 100644
index 0000000..56033d8
--- /dev/null
+++ b/package/udev/Config.in
@@ -0,0 +1,118 @@
+# udev package config
+
+menu "Configuration"
+ depends on PACKAGE_udev
+
+config UDEV_DISABLE_LOGGING
+ bool "Disable udev logging to syslog"
+ default n
+ help
+ Disable logging of udev messages to the syslog. If
+ unsure, choose the default N.
+
+config UDEV_ENABLE_DEBUG
+ bool "Enable debug build of the udev package"
+ default n
+ help
+ Compile in udev debug messages. If unsure, choose
+ the default N.
+
+config UDEV_EXTRA_accelerometer
+ bool "Install udev acceleroometer callout"
+ default y
+ help
+ accelerometer - udev callout to export device orientation
+ through property
+
+config UDEV_EXTRA_ata_id
+ bool "Install udev ata_id callout"
+ default y
+ help
+ ata_id - udev callout to read product/serial number
+ from ATA drives
+
+config UDEV_EXTRA_cdrom_id
+ bool "Install udev cdrom_id callout"
+ default y
+ help
+ cdrom_id - udev callout to determine the capabilities
+ of optical drives and media
+
+config UDEV_EXTRA_collect
+ bool "Install udev collect"
+ default n
+ help
+ Adds ID to the list governed by <checkpoint>
+
+config UDEV_EXTRA_edd_id
+ bool "Install udev edd_id callout"
+ default n
+ help
+ edd_id - udev callout to identify BIOS disk drives
+ via EDD
+
+config UDEV_EXTRA_firmware
+ bool "Install firmware support"
+ default n
+ help
+ udev firmware loader
+ via EDD
+
+config UDEV_EXTRA_floppy
+ bool "Install create_floppy_devices callout"
+ default n
+ help
+ create_floppy_devices - udev callout to create all
+ possible floppy device based on the CMOS type
+
+config UDEV_EXTRA_input_id
+ bool "Install input_id callout"
+ default y
+ help
+ input_id - udev callout to classify input devices
+
+config UDEV_EXTRA_mtd_probe
+ bool "Install mtd_probe callout"
+ default y
+ help
+ mtd_probe - udev callout to probe mtd devices
+
+config UDEV_EXTRA_path_id
+ bool "Install udev path_id callout"
+ default y
+ help
+ path_id - udev callout to create a device path based
+ unique name for a device to implement the Linux
+ Persistent Device Naming scheme
+
+config UDEV_EXTRA_qemu
+ bool "Install qemu specific rules"
+ default y
+ help
+ Install rules for autosuspension of QEMU emulated
+ USB HID devices
+
+config UDEV_EXTRA_rule_generator
+ bool "Install udev rule_generator"
+ default y
+ help
+
+config UDEV_EXTRA_scsi_id
+ bool "Install udev scsi_id callout"
+ default y
+ help
+ scsi_id - retrieve and generate a unique SCSI identifier
+
+config UDEV_EXTRA_usb_id
+ bool "Install udev usb_id callout"
+ default y
+ help
+ usb_id - can find the unique id of USB devices
+
+config UDEV_EXTRA_v4l_id
+ bool "Install udev v4l_id callout"
+ default y
+ help
+ v4l_id - udev callout to identify Video4Linux devices
+
+endmenu
diff --git a/package/udev/Makefile b/package/udev/Makefile
new file mode 100644
index 0000000..4679917
--- /dev/null
+++ b/package/udev/Makefile
@@ -0,0 +1,156 @@
+#
+# Copyright (C) 2006-2008 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=udev
+PKG_VERSION:=173
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=@KERNEL/linux/utils/kernel/hotplug/
+PKG_MD5SUM:=91a88a359b60bbd074b024883cc0dbde
+
+include $(INCLUDE_DIR)/package.mk
+
+PKG_INSTALL=1
+
+define Package/udev
+ SECTION:=base
+ CATEGORY:=Base system
+ TITLE:=Dynamic device management subsystem
+ URL:=http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev.html
+ MAINTAINER:=Geoff Levand <geoff@infradead.org>
+ MENU:=1
+ DEPENDS:=+librt
+endef
+
+define Package/udev/description
+ udev allows Linux users to have a dynamic /dev directory and it
+ provides the ability to have persistent device names.
+endef
+
+define Package/udev/conffiles
+/etc/udev/udev.conf
+endef
+
+define Package/udev/config
+ source "$(SOURCE)/Config.in"
+endef
+
+udev-args-$(CONFIG_UDEV_DISABLE_LOGGING) += --disable-logging
+udev-args-$(CONFIG_UDEV_ENABLE_DEBUG) += --enable-debug
+udev-args-$(CONFIG_UDEV_EXTRA_edd_id) += --enable-edd
+udev-args-$(CONFIG_UDEV_EXTRA_floppy) += --enable-floppy
+
+# TODO: make hwdb and introspection work
+
+CONFIGURE_ARGS += --prefix=/usr --exec-prefix= --sysconfdir=/etc \
+ --disable-hwdb --disable-keymap --disable-gudev --disable-introspection \
+ --libexecdir=/lib/udev --disable-gtk-doc-html \
+ --sbindir=/sbin $(udev-args-y)
+
+udev-extra-lib-bin-$(CONFIG_UDEV_EXTRA_accelerometer) += accelerometer
+udev-extra-rules-$(CONFIG_UDEV_EXTRA_accelerometer) += 61-accelerometer.rules
+
+udev-extra-lib-bin-$(CONFIG_UDEV_EXTRA_ata_id) += ata_id
+
+udev-extra-lib-bin-$(CONFIG_UDEV_EXTRA_cdrom_id) += cdrom_id
+udev-extra-rules-$(CONFIG_UDEV_EXTRA_cdrom_id) += 60-cdrom_id.rules
+
+udev-extra-lib-bin-$(CONFIG_UDEV_EXTRA_collect) += collect
+
+udev-extra-lib-bin-$(CONFIG_UDEV_EXTRA_edd_id) += edd_id
+udev-extra-rules-$(CONFIG_UDEV_EXTRA_edd_id) += 61-persistent-storage-edd.rules
+
+udev-extra-lib-bin-$(CONFIG_UDEV_EXTRA_firmware) += firmware
+udev-extra-rules-$(CONFIG_UDEV_EXTRA_firmware) += 50-firmware.rules
+
+udev-extra-lib-bin-$(CONFIG_UDEV_EXTRA_floppy) += create_floppy_devices
+
+# TODO: make gudev work
+
+udev-extra-lib-bin-$(CONFIG_UDEV_EXTRA_input_id) += input_id
+
+# TODO: make keymap work
+
+udev-extra-lib-bin-$(CONFIG_UDEV_EXTRA_mtd_probe) += mtd_probe
+udev-extra-rules-$(CONFIG_UDEV_EXTRA_mtd_probe) += 75-probe_mtd.rules
+
+udev-extra-lib-bin-$(CONFIG_UDEV_EXTRA_path_id) += path_id
+
+udev-extra-rules-$(CONFIG_UDEV_EXTRA_qemu) += 42-qemu-usb.rules
+
+udev-extra-lib-bin-$(CONFIG_UDEV_EXTRA_rule_generator) += \
+ write_cd_rules write_net_rules
+udev-extra-lib-data-$(CONFIG_UDEV_EXTRA_rule_generator) += \
+ rule_generator.functions
+udev-extra-rules-$(CONFIG_UDEV_EXTRA_rule_generator) += \
+ 75-cd-aliases-generator.rules 75-persistent-net-generator.rules
+
+udev-extra-lib-bin-$(CONFIG_UDEV_EXTRA_scsi_id) += scsi_id
+
+# TODO: make udev-acl work
+
+udev-extra-lib-bin-$(CONFIG_UDEV_EXTRA_usb_id) += usb_id
+
+udev-extra-lib-bin-$(CONFIG_UDEV_EXTRA_v4l_id) += v4l_id
+udev-extra-rules-$(CONFIG_UDEV_EXTRA_v4l_id) += 60-persistent-v4l.rules
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include
+ $(CP) $(PKG_INSTALL_DIR)/usr/include/libudev.h $(1)/usr/include
+ $(INSTALL_DIR) $(1)/usr/share/pkgconfig
+ $(CP) $(PKG_INSTALL_DIR)/usr/share/pkgconfig/udev.pc $(1)/usr/share/pkgconfig
+ $(INSTALL_DIR) $(1)/lib
+ $(CP) $(PKG_INSTALL_DIR)/lib/libudev.so* $(1)/lib
+ $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
+ $(CP) $(PKG_INSTALL_DIR)/lib/pkgconfig/libudev.pc $(1)/usr/lib/pkgconfig
+endef
+
+define Package/udev/install
+ $(INSTALL_DIR) $(1)/etc/udev/rules.d
+ $(INSTALL_DATA) $(PKG_INSTALL_DIR)/etc/udev/udev.conf $(1)/etc/udev
+
+ $(INSTALL_DIR) $(1)/sbin
+ $(INSTALL_BIN) \
+ $(PKG_INSTALL_DIR)/sbin/udevadm \
+ $(PKG_INSTALL_DIR)/sbin/udevd \
+ $(1)/sbin
+
+ $(INSTALL_DIR) $(1)/lib/udev/rules.d
+ $(INSTALL_DATA) \
+ $(addprefix $(PKG_INSTALL_DIR)/lib/udev/rules.d/, \
+ $(udev-extra-rules-y)) \
+ $(addprefix $(PKG_INSTALL_DIR)/lib/udev/rules.d/, \
+ 50-udev-default.rules \
+ 60-persistent-input.rules \
+ 60-persistent-serial.rules \
+ 60-persistent-storage.rules \
+ 80-drivers.rules \
+ 95-udev-late.rules) \
+ $(1)/lib/udev/rules.d
+
+ $(INSTALL_DIR) $(1)/lib
+ $(CP) $(PKG_INSTALL_DIR)/lib/libudev.so* $(1)/lib
+
+ $(INSTALL_DIR) $(1)/lib/udev
+ifneq ($(udev-extra-lib-bin-y),)
+ $(INSTALL_BIN) \
+ $(addprefix $(PKG_INSTALL_DIR)/lib/udev/, \
+ $(udev-extra-lib-bin-y)) \
+ $(1)/lib/udev/
+endif
+ifneq ($(udev-extra-lib-data-y),)
+ $(INSTALL_DATA) \
+ $(addprefix $(PKG_INSTALL_DIR)/lib/udev/, \
+ $(udev-extra-lib-data-y)) \
+ $(1)/lib/udev/
+endif
+endef
+
+$(eval $(call BuildPackage,udev))
diff --git a/package/udev/patches/.svn/entries b/package/udev/patches/.svn/entries
new file mode 100644
index 0000000..ee2d19e
--- /dev/null
+++ b/package/udev/patches/.svn/entries
@@ -0,0 +1,130 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/udev/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2011-10-14T11:42:40.881296Z
+28453
+hcg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+0001-build-don-t-use-gc-sections.patch
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+77a37f7dc2cb20fff999f9db9605da85
+2011-08-25T10:49:29.640068Z
+28085
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+710
+
+0002-udevd-add-lrt-for-message-queue-symbols.patch
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+f3df7e563a912343ab8b653a426c5f30
+2011-08-25T10:49:29.640068Z
+28085
+florian
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+664
+
+0003-add_btn_trigger_happy_define.patch
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+675e55e72161d3430ff2bdcc18badc8a
+2011-10-14T11:42:40.881296Z
+28453
+hcg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+363
+
diff --git a/package/udev/patches/.svn/text-base/0001-build-don-t-use-gc-sections.patch.svn-base b/package/udev/patches/.svn/text-base/0001-build-don-t-use-gc-sections.patch.svn-base
new file mode 100644
index 0000000..f01a5ae
--- /dev/null
+++ b/package/udev/patches/.svn/text-base/0001-build-don-t-use-gc-sections.patch.svn-base
@@ -0,0 +1,31 @@
+From 971a09345f108189ed899b236784a5440e43c8b6 Mon Sep 17 00:00:00 2001
+From: Daniel Mierswa <impulze@impulze.org>
+Date: Sun, 31 Jul 2011 23:51:49 +0000
+Subject: [PATCH 1/2] build: don't use --gc-sections
+
+somehow won't work with the wrt toolchain
+---
+ Makefile.am | 5 +----
+ 1 files changed, 1 insertions(+), 4 deletions(-)
+
+diff --git a/Makefile.am b/Makefile.am
+index a0c007a..3d8ce92 100644
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -18,12 +18,9 @@ AM_CPPFLAGS = \
+ -DLIBEXECDIR=\""$(libexecdir)"\"
+
+ AM_CFLAGS = \
+- -fvisibility=hidden \
+- -ffunction-sections \
+- -fdata-sections
++ -fvisibility=hidden
+
+ AM_LDFLAGS = \
+- -Wl,--gc-sections \
+ -Wl,--as-needed
+
+ DISTCHECK_CONFIGURE_FLAGS = \
+--
+1.7.6
+
diff --git a/package/udev/patches/.svn/text-base/0002-udevd-add-lrt-for-message-queue-symbols.patch.svn-base b/package/udev/patches/.svn/text-base/0002-udevd-add-lrt-for-message-queue-symbols.patch.svn-base
new file mode 100644
index 0000000..55466bc
--- /dev/null
+++ b/package/udev/patches/.svn/text-base/0002-udevd-add-lrt-for-message-queue-symbols.patch.svn-base
@@ -0,0 +1,25 @@
+From ae90737100d901723af9890e69798bd1dac9a86d Mon Sep 17 00:00:00 2001
+From: Daniel Mierswa <impulze@impulze.org>
+Date: Sun, 31 Jul 2011 23:53:21 +0000
+Subject: [PATCH 2/2] udevd: add -lrt for message queue symbols
+
+---
+ Makefile.am | 2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/Makefile.am b/Makefile.am
+index 3d8ce92..7d8a4b6 100644
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -164,7 +164,7 @@ udev_udevd_SOURCES = \
+ udev/udevd.c \
+ udev/sd-daemon.h \
+ udev/sd-daemon.c
+-udev_udevd_LDADD = libudev/libudev-private.la
++udev_udevd_LDADD = libudev/libudev-private.la -lrt
+
+ udev_udevadm_SOURCES = \
+ $(udev_common_sources) \
+--
+1.7.6
+
diff --git a/package/udev/patches/.svn/text-base/0003-add_btn_trigger_happy_define.patch.svn-base b/package/udev/patches/.svn/text-base/0003-add_btn_trigger_happy_define.patch.svn-base
new file mode 100644
index 0000000..77eaf13
--- /dev/null
+++ b/package/udev/patches/.svn/text-base/0003-add_btn_trigger_happy_define.patch.svn-base
@@ -0,0 +1,13 @@
+--- a/extras/input_id/input_id.c
++++ b/extras/input_id/input_id.c
+@@ -30,6 +30,10 @@
+ #include "libudev.h"
+ #include "libudev-private.h"
+
++#ifndef BTN_TRIGGER_HAPPY
++#define BTN_TRIGGER_HAPPY 0x2c0
++#endif
++
+ /* we must use this kernel-compatible implementation */
+ #define BITS_PER_LONG (sizeof(unsigned long) * 8)
+ #define NBITS(x) ((((x)-1)/BITS_PER_LONG)+1)
diff --git a/package/udev/patches/0001-build-don-t-use-gc-sections.patch b/package/udev/patches/0001-build-don-t-use-gc-sections.patch
new file mode 100644
index 0000000..f01a5ae
--- /dev/null
+++ b/package/udev/patches/0001-build-don-t-use-gc-sections.patch
@@ -0,0 +1,31 @@
+From 971a09345f108189ed899b236784a5440e43c8b6 Mon Sep 17 00:00:00 2001
+From: Daniel Mierswa <impulze@impulze.org>
+Date: Sun, 31 Jul 2011 23:51:49 +0000
+Subject: [PATCH 1/2] build: don't use --gc-sections
+
+somehow won't work with the wrt toolchain
+---
+ Makefile.am | 5 +----
+ 1 files changed, 1 insertions(+), 4 deletions(-)
+
+diff --git a/Makefile.am b/Makefile.am
+index a0c007a..3d8ce92 100644
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -18,12 +18,9 @@ AM_CPPFLAGS = \
+ -DLIBEXECDIR=\""$(libexecdir)"\"
+
+ AM_CFLAGS = \
+- -fvisibility=hidden \
+- -ffunction-sections \
+- -fdata-sections
++ -fvisibility=hidden
+
+ AM_LDFLAGS = \
+- -Wl,--gc-sections \
+ -Wl,--as-needed
+
+ DISTCHECK_CONFIGURE_FLAGS = \
+--
+1.7.6
+
diff --git a/package/udev/patches/0002-udevd-add-lrt-for-message-queue-symbols.patch b/package/udev/patches/0002-udevd-add-lrt-for-message-queue-symbols.patch
new file mode 100644
index 0000000..55466bc
--- /dev/null
+++ b/package/udev/patches/0002-udevd-add-lrt-for-message-queue-symbols.patch
@@ -0,0 +1,25 @@
+From ae90737100d901723af9890e69798bd1dac9a86d Mon Sep 17 00:00:00 2001
+From: Daniel Mierswa <impulze@impulze.org>
+Date: Sun, 31 Jul 2011 23:53:21 +0000
+Subject: [PATCH 2/2] udevd: add -lrt for message queue symbols
+
+---
+ Makefile.am | 2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/Makefile.am b/Makefile.am
+index 3d8ce92..7d8a4b6 100644
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -164,7 +164,7 @@ udev_udevd_SOURCES = \
+ udev/udevd.c \
+ udev/sd-daemon.h \
+ udev/sd-daemon.c
+-udev_udevd_LDADD = libudev/libudev-private.la
++udev_udevd_LDADD = libudev/libudev-private.la -lrt
+
+ udev_udevadm_SOURCES = \
+ $(udev_common_sources) \
+--
+1.7.6
+
diff --git a/package/udev/patches/0003-add_btn_trigger_happy_define.patch b/package/udev/patches/0003-add_btn_trigger_happy_define.patch
new file mode 100644
index 0000000..77eaf13
--- /dev/null
+++ b/package/udev/patches/0003-add_btn_trigger_happy_define.patch
@@ -0,0 +1,13 @@
+--- a/extras/input_id/input_id.c
++++ b/extras/input_id/input_id.c
+@@ -30,6 +30,10 @@
+ #include "libudev.h"
+ #include "libudev-private.h"
+
++#ifndef BTN_TRIGGER_HAPPY
++#define BTN_TRIGGER_HAPPY 0x2c0
++#endif
++
+ /* we must use this kernel-compatible implementation */
+ #define BITS_PER_LONG (sizeof(unsigned long) * 8)
+ #define NBITS(x) ((((x)-1)/BITS_PER_LONG)+1)
diff --git a/package/util-linux/.svn/entries b/package/util-linux/.svn/entries
new file mode 100644
index 0000000..9848f52
--- /dev/null
+++ b/package/util-linux/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/util-linux
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-12-19T16:07:42.017614Z
+34791
+mirko
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+patches
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+4dda64a9b38ab575dca3c952c4fa4b8f
+2012-12-19T16:07:42.017614Z
+34791
+mirko
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+16373
+
diff --git a/package/util-linux/.svn/text-base/Makefile.svn-base b/package/util-linux/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..7deb77d
--- /dev/null
+++ b/package/util-linux/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,594 @@
+#
+# Copyright (C) 2007-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=util-linux
+PKG_VERSION:=2.21.2
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
+PKG_SOURCE_URL:=@KERNEL/linux/utils/$(PKG_NAME)/v2.21
+PKG_MD5SUM:=54ba880f1d66782c2287ee2c898520e9
+
+PKG_LICENSE:=GPLv2 LGPLv2.1 BSD-3c
+PKG_LICENSE_FILES:=COPYING getopt/COPYING libblkid/COPYING libmount/COPYING Documentation/licenses/COPYING.GPLv2 Documentation/licenses/COPYING.LGPLv2.1 libuuid/COPYING Documentation/licenses/COPYING.BSD-3
+
+PKG_BUILD_PARALLEL:=1
+PKG_BUILD_DEPENDS:=libncurses
+PKG_FIXUP:=autoreconf
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/util-linux/Default
+ SECTION:=utils
+ CATEGORY:=Utilities
+ URL:=http://www.kernel.org/pub/linux/utils/util-linux/
+endef
+
+CONFIGURE_ARGS += \
+ --enable-new-mount \
+ --with-ncurses \
+ --disable-nls \
+ --disable-tls \
+ --without-udev
+
+TARGET_CFLAGS += $(FPIC)
+
+define Build/InstallDev
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ BUILDCC="$(HOSTCC)" \
+ DESTDIR="$(1)" \
+ installdirs install-data
+
+ $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
+ $(CP) $(PKG_BUILD_DIR)/libblkid/blkid.pc $(1)/usr/lib/pkgconfig
+ $(CP) $(PKG_BUILD_DIR)/libmount/mount.pc $(1)/usr/lib/pkgconfig
+ $(CP) $(PKG_BUILD_DIR)/libuuid/uuid.pc $(1)/usr/lib/pkgconfig
+
+ $(INSTALL_DIR) $(1)/usr/include/blkid
+ $(CP) $(PKG_BUILD_DIR)/libblkid/src/blkid.h $(1)/usr/include/blkid
+ $(INSTALL_DIR) $(1)/usr/include/libmount
+ $(CP) $(PKG_BUILD_DIR)/libmount/src/libmount.h $(1)/usr/include/libmount
+ $(INSTALL_DIR) $(1)/usr/include/uuid
+ $(CP) $(PKG_BUILD_DIR)/libuuid/src/uuid.h $(1)/usr/include/uuid
+
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_BUILD_DIR)/libblkid/src/.libs/libblkid.{a,so.*} $(1)/usr/lib
+ $(CP) $(PKG_BUILD_DIR)/libmount/src/.libs/libmount.{a,so.*} $(1)/usr/lib
+ $(CP) $(PKG_BUILD_DIR)/libuuid/src/.libs/libuuid.{a,so.*} $(1)/usr/lib
+endef
+
+define Package/libblkid
+$(call Package/util-linux/Default)
+ DEPENDS:=+libuuid
+ TITLE:=block device id library
+ SECTION:=libs
+ CATEGORY:=Libraries
+endef
+
+define Package/libblkid/description
+ The libblkid library is used to identify block devices (disks) as to their
+ content (e.g. filesystem type, partitions) as well as extracting additional
+ information such as filesystem labels/volume names, partitions, unique
+ identifiers/serial numbers...
+endef
+
+define Package/libmount
+$(call Package/util-linux/Default)
+ DEPENDS:=+libblkid
+ TITLE:=mount library
+ SECTION:=libs
+ CATEGORY:=Libraries
+endef
+
+define Package/libmount/description
+ The libmount library is used to parse /etc/fstab, /etc/mtab and
+ /proc/self/mountinfo files, manage the mtab file, evaluate mount options...
+endef
+
+define Package/libuuid
+$(call Package/util-linux/Default)
+ TITLE:=DCE compatible Universally Unique Identifier library
+ SECTION:=libs
+ CATEGORY:=Libraries
+endef
+
+define Package/libuuid/description
+ The UUID library is used to generate unique identifiers for objects
+ that may be accessible beyond the local system. This library
+ generates UUIDs compatible with those created by the Open Software
+ Foundation (OSF) Distributed Computing Environment (DCE) utility.
+endef
+
+define Package/agetty
+$(call Package/util-linux/Default)
+ TITLE:=alternative Linux getty
+ SUBMENU=Terminal
+endef
+
+define Package/agetty/description
+ agetty opens a tty port, prompts for a login name and invokes the
+ /bin/login command
+endef
+
+define Package/blkid
+$(call Package/util-linux/Default)
+ TITLE:=locate/print block device attributes
+ DEPENDS:= +libblkid
+ SUBMENU=disc
+endef
+
+define Package/blkid/description
+ The blkid program is the command-line interface to working with the libblkid
+ library.
+endef
+
+define Package/cal
+$(call Package/util-linux/Default)
+ TITLE:=display a calendar
+ DEPENDS:= +libncurses
+endef
+
+define Package/cal/description
+ cal displays a simple calendar
+endef
+
+define Package/cfdisk
+$(call Package/util-linux/Default)
+ TITLE:=display or manipulate disk partition table
+ DEPENDS:= +libblkid +libncurses
+ SUBMENU:=disc
+endef
+
+define Package/cfdisk/description
+ cfdisk is a curses-based program for partitioning any hard disk drive
+endef
+
+define Package/dmesg
+$(call Package/util-linux/Default)
+ TITLE:=print or control the kernel ring buffer
+endef
+
+define Package/dmesg/description
+ dmesg is used to examine or control the kernel ring buffer
+endef
+
+define Package/fdisk
+$(call Package/util-linux/Default)
+ TITLE:=manipulate disk partition table
+ DEPENDS:= +libblkid
+ SUBMENU=disc
+endef
+
+define Package/fdisk/description
+ a menu-driven program for creation and manipulation of partition tables
+endef
+
+define Package/findfs
+$(call Package/util-linux/Default)
+ TITLE:=find a filesystem by label or UUID
+ DEPENDS:= +libblkid
+ SUBMENU=disc
+endef
+
+define Package/findfs/description
+ findfs will search the disks in the system looking for a filesystem which has
+ a label matching label or a UUID equal to uuid
+endef
+
+define Package/flock
+$(call Package/util-linux/Default)
+ TITLE:=manage locks from shell scripts
+endef
+
+define Package/flock/description
+ manages flock locks from within shell scripts or the command line
+endef
+
+define Package/getopt
+$(call Package/util-linux/Default)
+ TITLE:=parse command options (enhanced)
+endef
+
+define Package/getopt/description
+ getopt is used to break up (parse) options in command lines for easy parsing
+ by shell procedures, and to check for legal options
+endef
+
+define Package/hwclock
+$(call Package/util-linux/Default)
+ TITLE:=query or set the hardware clock
+endef
+
+define Package/hwclock/description
+ hwclock is a tool for accessing the Hardware Clock
+endef
+
+define Package/logger
+$(call Package/util-linux/Default)
+ TITLE:=a shell command interface to the syslog system log module
+endef
+
+define Package/logger/description
+ logger makes entries in the system log, it provides a shell command interface
+ to the syslog system log module
+endef
+
+define Package/look
+$(call Package/util-linux/Default)
+ TITLE:=display lines beginning with a given string
+endef
+
+define Package/look/description
+ look utility displays any lines in file which contain string
+endef
+
+define Package/losetup
+$(call Package/util-linux/Default)
+ TITLE:=set up and control loop devices
+endef
+
+define Package/losetup/description
+ losetup is used to associate loop devices with regular files or block devices,
+ to detach loop devices and to query the status of a loop device
+endef
+
+define Package/lsblk
+$(call Package/util-linux/Default)
+ TITLE:=list block devices
+ DEPENDS:= +libblkid
+ SUBMENU=disc
+endef
+
+define Package/lsblk/description
+ lsblk lists information about all or the specified block devices
+endef
+
+define Package/mcookie
+$(call Package/util-linux/Default)
+ TITLE:=generate magic cookies for xauth
+endef
+
+define Package/mcookie/description
+ mcookie generates a 128-bit random hexadecimal number for use with the X
+ authority system
+endef
+
+define Package/mount-utils
+$(call Package/util-linux/Default)
+ TITLE:=related (u)mount utilities
+ DEPENDS+= +libmount
+endef
+
+define Package/mount-utils/description
+ contains: mount, umount, findmnt
+endef
+
+define Package/namei
+$(call Package/util-linux/Default)
+ TITLE:=follow a pathname until a terminal point is found
+endef
+
+define Package/namei/description
+ namei uses its arguments as pathnames to any type of Unix file (symlinks,
+ files, directories, and so forth)
+endef
+
+define Package/rename
+$(call Package/util-linux/Default)
+ TITLE:=rename files
+endef
+
+define Package/rename/description
+ rename will rename the specified files by replacing the first occurrence of
+ expression in their name by replacement
+endef
+
+define Package/partx-utils
+$(call Package/util-linux/Default)
+ TITLE:=inform kernel about the presence and numbering of on-disk partitions
+ DEPENDS:= +libblkid
+ SUBMENU=disc
+endef
+
+define Package/partx-utils/description
+ contains partx, addpart, delpart
+endef
+
+define Package/script-utils
+$(call Package/util-linux/Default)
+ TITLE:=make and replay typescript of terminal session
+ SUBMENU=Terminal
+endef
+
+define Package/script-utils/description
+ contains: script, scriptreplay
+endef
+
+define Package/setterm
+$(call Package/util-linux/Default)
+ TITLE:=set terminal attributes
+ DEPENDS:= +libncurses
+ SUBMENU:=Terminal
+endef
+
+define Package/setterm/description
+ setterm writes to standard output a character string that will invoke the
+ specified terminal capabilities
+endef
+
+define Package/sfdisk
+$(call Package/util-linux/Default)
+ TITLE:=partition table manipulator for Linux
+ SUBMENU=disc
+endef
+
+define Package/sfdisk/description
+ list the size of a partition, list the partitions on a device, check the
+ partitions on a device and repartition a device
+endef
+
+define Package/swap-utils
+$(call Package/util-linux/Default)
+ TITLE:=swap space management utilities
+ DEPENDS+= +libblkid
+ SUBMENU:=disc
+endef
+
+define Package/swap-utils/description
+ contains: mkswap, swaplabel, swapon, swapoff
+endef
+
+define Package/uuidd
+$(call Package/util-linux/Default)
+ TITLE:=UUID generation daemon
+ DEPENDS:= +libuuid
+endef
+
+define Package/uuidd/description
+ The uuidd daemon is used by the UUID library to generate universally unique
+ identifiers (UUIDs), especially time-based UUIDs, in a secure and
+ guaranteed-unique fashion, even in the face of large numbers of threads
+ running on different CPUs trying to grab UUIDs.
+endef
+
+define Package/uuidgen
+$(call Package/util-linux/Default)
+ TITLE:=create a new UUID value
+ DEPENDS:= +libuuid
+endef
+
+define Package/uuidgen/description
+ The uuidgen program creates (and prints) a new universally unique identifier
+ (UUID) using the libuuid library. The new UUID can reasonably be considered
+ unique among all UUIDs created on the local system, and among UUIDs created on
+ other systems in the past and in the future.
+endef
+
+define Package/wall
+$(call Package/util-linux/Default)
+ TITLE:=send a message to everybody's terminal
+ SUBMENU=Terminal
+endef
+
+define Package/wall/description
+ wall sends a message to everybody logged in with their mesg permission
+ set to yes
+endef
+
+define Package/whereis
+$(call Package/util-linux/Default)
+ TITLE:=locate the binary, source, and manual page files for a command
+endef
+
+define Package/whereis/description
+ whereis locates source/binary and manuals sections for specified files
+endef
+
+define Package/wipefs
+$(call Package/util-linux/Default)
+ TITLE:=wipe a signature from a device
+ DEPENDS:= +libblkid
+ SUBMENU:=disc
+endef
+
+define Package/wipefs/description
+ wipefs can erase filesystem, raid or partition table signatures (magic
+ strings) from the specified device to make the signature invisible for
+ libblkid.
+endef
+
+define Package/libblkid/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_BUILD_DIR)/libblkid/src/.libs/libblkid.so.* $(1)/usr/lib/
+endef
+
+define Package/libmount/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_BUILD_DIR)/libmount/src/.libs/libmount.so.* $(1)/usr/lib/
+endef
+
+define Package/libuuid/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_BUILD_DIR)/libuuid/src/.libs/libuuid.so.* $(1)/usr/lib/
+endef
+
+define Package/agetty/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/term-utils/agetty $(1)/usr/sbin/
+endef
+
+define Package/blkid/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc-utils/.libs/blkid $(1)/usr/sbin/
+endef
+
+define Package/cal/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc-utils/cal $(1)/usr/bin/
+endef
+
+define Package/cfdisk/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/fdisk/.libs/cfdisk $(1)/usr/sbin/
+endef
+
+define Package/fdisk/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/fdisk/.libs/fdisk $(1)/usr/sbin/
+endef
+
+define Package/findfs/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc-utils/.libs/findfs $(1)/usr/sbin/
+endef
+
+define Package/flock/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/sys-utils/flock $(1)/usr/bin/
+endef
+
+define Package/getopt/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/getopt/getopt $(1)/usr/bin/
+endef
+
+define Package/hwclock/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/hwclock/hwclock $(1)/usr/sbin/
+endef
+
+define Package/logger/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc-utils/logger $(1)/usr/bin/
+endef
+
+define Package/look/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc-utils/look $(1)/usr/bin/
+endef
+
+define Package/losetup/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/sys-utils/losetup $(1)/usr/sbin/
+endef
+
+define Package/lsblk/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc-utils/.libs/lsblk $(1)/usr/bin/
+endef
+
+define Package/mcookie/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc-utils/mcookie $(1)/usr/bin/
+endef
+
+define Package/mount-utils/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/sys-utils/.libs/{u,}mount $(1)/usr/bin/
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/sys-utils/.libs/mountpoint $(1)/usr/bin/
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc-utils/.libs/findmnt $(1)/usr/bin/
+endef
+
+define Package/namei/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc-utils/namei $(1)/usr/bin/
+endef
+
+define Package/rename/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc-utils/rename $(1)/usr/bin/
+endef
+
+define Package/partx-utils/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/partx/.libs/partx $(1)/usr/sbin/
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/partx/addpart $(1)/usr/sbin/
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/partx/delpart $(1)/usr/sbin/
+endef
+
+define Package/script-utils/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/term-utils/script $(1)/usr/bin/
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/term-utils/scriptreplay $(1)/usr/bin/
+endef
+
+define Package/setterm/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/term-utils/setterm $(1)/usr/bin/
+endef
+
+define Package/sfdisk/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/fdisk/sfdisk $(1)/usr/sbin/
+endef
+
+define Package/swap-utils/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/disk-utils/.libs/mkswap $(1)/usr/sbin/
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/disk-utils/.libs/swaplabel $(1)/usr/sbin/
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/sys-utils/.libs/swapon $(1)/usr/sbin/
+ ln -sf swapon $(1)/usr/sbin/swapoff
+endef
+
+define Package/uuidd/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc-utils/.libs/uuidd $(1)/usr/sbin/
+endef
+
+define Package/uuidgen/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc-utils/.libs/uuidgen $(1)/usr/bin/
+endef
+
+define Package/wall/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/term-utils/wall $(1)/usr/bin/
+endef
+
+define Package/whereis/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc-utils/whereis $(1)/usr/bin/
+endef
+
+define Package/wipefs/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc-utils/.libs/wipefs $(1)/usr/sbin/
+endef
+
+$(eval $(call BuildPackage,libblkid))
+$(eval $(call BuildPackage,libmount))
+$(eval $(call BuildPackage,libuuid))
+$(eval $(call BuildPackage,agetty))
+$(eval $(call BuildPackage,blkid))
+$(eval $(call BuildPackage,cal))
+$(eval $(call BuildPackage,cfdisk))
+$(eval $(call BuildPackage,dmesg))
+$(eval $(call BuildPackage,fdisk))
+$(eval $(call BuildPackage,findfs))
+$(eval $(call BuildPackage,flock))
+$(eval $(call BuildPackage,getopt))
+$(eval $(call BuildPackage,hwclock))
+$(eval $(call BuildPackage,logger))
+$(eval $(call BuildPackage,look))
+$(eval $(call BuildPackage,losetup))
+$(eval $(call BuildPackage,lsblk))
+$(eval $(call BuildPackage,mcookie))
+$(eval $(call BuildPackage,mount-utils))
+$(eval $(call BuildPackage,namei))
+$(eval $(call BuildPackage,rename))
+$(eval $(call BuildPackage,partx-utils))
+$(eval $(call BuildPackage,script-utils))
+$(eval $(call BuildPackage,setterm))
+$(eval $(call BuildPackage,sfdisk))
+$(eval $(call BuildPackage,swap-utils))
+$(eval $(call BuildPackage,uuidd))
+$(eval $(call BuildPackage,uuidgen))
+$(eval $(call BuildPackage,wall))
+$(eval $(call BuildPackage,whereis))
+$(eval $(call BuildPackage,wipefs))
diff --git a/package/util-linux/Makefile b/package/util-linux/Makefile
new file mode 100644
index 0000000..7deb77d
--- /dev/null
+++ b/package/util-linux/Makefile
@@ -0,0 +1,594 @@
+#
+# Copyright (C) 2007-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=util-linux
+PKG_VERSION:=2.21.2
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
+PKG_SOURCE_URL:=@KERNEL/linux/utils/$(PKG_NAME)/v2.21
+PKG_MD5SUM:=54ba880f1d66782c2287ee2c898520e9
+
+PKG_LICENSE:=GPLv2 LGPLv2.1 BSD-3c
+PKG_LICENSE_FILES:=COPYING getopt/COPYING libblkid/COPYING libmount/COPYING Documentation/licenses/COPYING.GPLv2 Documentation/licenses/COPYING.LGPLv2.1 libuuid/COPYING Documentation/licenses/COPYING.BSD-3
+
+PKG_BUILD_PARALLEL:=1
+PKG_BUILD_DEPENDS:=libncurses
+PKG_FIXUP:=autoreconf
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/util-linux/Default
+ SECTION:=utils
+ CATEGORY:=Utilities
+ URL:=http://www.kernel.org/pub/linux/utils/util-linux/
+endef
+
+CONFIGURE_ARGS += \
+ --enable-new-mount \
+ --with-ncurses \
+ --disable-nls \
+ --disable-tls \
+ --without-udev
+
+TARGET_CFLAGS += $(FPIC)
+
+define Build/InstallDev
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ BUILDCC="$(HOSTCC)" \
+ DESTDIR="$(1)" \
+ installdirs install-data
+
+ $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
+ $(CP) $(PKG_BUILD_DIR)/libblkid/blkid.pc $(1)/usr/lib/pkgconfig
+ $(CP) $(PKG_BUILD_DIR)/libmount/mount.pc $(1)/usr/lib/pkgconfig
+ $(CP) $(PKG_BUILD_DIR)/libuuid/uuid.pc $(1)/usr/lib/pkgconfig
+
+ $(INSTALL_DIR) $(1)/usr/include/blkid
+ $(CP) $(PKG_BUILD_DIR)/libblkid/src/blkid.h $(1)/usr/include/blkid
+ $(INSTALL_DIR) $(1)/usr/include/libmount
+ $(CP) $(PKG_BUILD_DIR)/libmount/src/libmount.h $(1)/usr/include/libmount
+ $(INSTALL_DIR) $(1)/usr/include/uuid
+ $(CP) $(PKG_BUILD_DIR)/libuuid/src/uuid.h $(1)/usr/include/uuid
+
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_BUILD_DIR)/libblkid/src/.libs/libblkid.{a,so.*} $(1)/usr/lib
+ $(CP) $(PKG_BUILD_DIR)/libmount/src/.libs/libmount.{a,so.*} $(1)/usr/lib
+ $(CP) $(PKG_BUILD_DIR)/libuuid/src/.libs/libuuid.{a,so.*} $(1)/usr/lib
+endef
+
+define Package/libblkid
+$(call Package/util-linux/Default)
+ DEPENDS:=+libuuid
+ TITLE:=block device id library
+ SECTION:=libs
+ CATEGORY:=Libraries
+endef
+
+define Package/libblkid/description
+ The libblkid library is used to identify block devices (disks) as to their
+ content (e.g. filesystem type, partitions) as well as extracting additional
+ information such as filesystem labels/volume names, partitions, unique
+ identifiers/serial numbers...
+endef
+
+define Package/libmount
+$(call Package/util-linux/Default)
+ DEPENDS:=+libblkid
+ TITLE:=mount library
+ SECTION:=libs
+ CATEGORY:=Libraries
+endef
+
+define Package/libmount/description
+ The libmount library is used to parse /etc/fstab, /etc/mtab and
+ /proc/self/mountinfo files, manage the mtab file, evaluate mount options...
+endef
+
+define Package/libuuid
+$(call Package/util-linux/Default)
+ TITLE:=DCE compatible Universally Unique Identifier library
+ SECTION:=libs
+ CATEGORY:=Libraries
+endef
+
+define Package/libuuid/description
+ The UUID library is used to generate unique identifiers for objects
+ that may be accessible beyond the local system. This library
+ generates UUIDs compatible with those created by the Open Software
+ Foundation (OSF) Distributed Computing Environment (DCE) utility.
+endef
+
+define Package/agetty
+$(call Package/util-linux/Default)
+ TITLE:=alternative Linux getty
+ SUBMENU=Terminal
+endef
+
+define Package/agetty/description
+ agetty opens a tty port, prompts for a login name and invokes the
+ /bin/login command
+endef
+
+define Package/blkid
+$(call Package/util-linux/Default)
+ TITLE:=locate/print block device attributes
+ DEPENDS:= +libblkid
+ SUBMENU=disc
+endef
+
+define Package/blkid/description
+ The blkid program is the command-line interface to working with the libblkid
+ library.
+endef
+
+define Package/cal
+$(call Package/util-linux/Default)
+ TITLE:=display a calendar
+ DEPENDS:= +libncurses
+endef
+
+define Package/cal/description
+ cal displays a simple calendar
+endef
+
+define Package/cfdisk
+$(call Package/util-linux/Default)
+ TITLE:=display or manipulate disk partition table
+ DEPENDS:= +libblkid +libncurses
+ SUBMENU:=disc
+endef
+
+define Package/cfdisk/description
+ cfdisk is a curses-based program for partitioning any hard disk drive
+endef
+
+define Package/dmesg
+$(call Package/util-linux/Default)
+ TITLE:=print or control the kernel ring buffer
+endef
+
+define Package/dmesg/description
+ dmesg is used to examine or control the kernel ring buffer
+endef
+
+define Package/fdisk
+$(call Package/util-linux/Default)
+ TITLE:=manipulate disk partition table
+ DEPENDS:= +libblkid
+ SUBMENU=disc
+endef
+
+define Package/fdisk/description
+ a menu-driven program for creation and manipulation of partition tables
+endef
+
+define Package/findfs
+$(call Package/util-linux/Default)
+ TITLE:=find a filesystem by label or UUID
+ DEPENDS:= +libblkid
+ SUBMENU=disc
+endef
+
+define Package/findfs/description
+ findfs will search the disks in the system looking for a filesystem which has
+ a label matching label or a UUID equal to uuid
+endef
+
+define Package/flock
+$(call Package/util-linux/Default)
+ TITLE:=manage locks from shell scripts
+endef
+
+define Package/flock/description
+ manages flock locks from within shell scripts or the command line
+endef
+
+define Package/getopt
+$(call Package/util-linux/Default)
+ TITLE:=parse command options (enhanced)
+endef
+
+define Package/getopt/description
+ getopt is used to break up (parse) options in command lines for easy parsing
+ by shell procedures, and to check for legal options
+endef
+
+define Package/hwclock
+$(call Package/util-linux/Default)
+ TITLE:=query or set the hardware clock
+endef
+
+define Package/hwclock/description
+ hwclock is a tool for accessing the Hardware Clock
+endef
+
+define Package/logger
+$(call Package/util-linux/Default)
+ TITLE:=a shell command interface to the syslog system log module
+endef
+
+define Package/logger/description
+ logger makes entries in the system log, it provides a shell command interface
+ to the syslog system log module
+endef
+
+define Package/look
+$(call Package/util-linux/Default)
+ TITLE:=display lines beginning with a given string
+endef
+
+define Package/look/description
+ look utility displays any lines in file which contain string
+endef
+
+define Package/losetup
+$(call Package/util-linux/Default)
+ TITLE:=set up and control loop devices
+endef
+
+define Package/losetup/description
+ losetup is used to associate loop devices with regular files or block devices,
+ to detach loop devices and to query the status of a loop device
+endef
+
+define Package/lsblk
+$(call Package/util-linux/Default)
+ TITLE:=list block devices
+ DEPENDS:= +libblkid
+ SUBMENU=disc
+endef
+
+define Package/lsblk/description
+ lsblk lists information about all or the specified block devices
+endef
+
+define Package/mcookie
+$(call Package/util-linux/Default)
+ TITLE:=generate magic cookies for xauth
+endef
+
+define Package/mcookie/description
+ mcookie generates a 128-bit random hexadecimal number for use with the X
+ authority system
+endef
+
+define Package/mount-utils
+$(call Package/util-linux/Default)
+ TITLE:=related (u)mount utilities
+ DEPENDS+= +libmount
+endef
+
+define Package/mount-utils/description
+ contains: mount, umount, findmnt
+endef
+
+define Package/namei
+$(call Package/util-linux/Default)
+ TITLE:=follow a pathname until a terminal point is found
+endef
+
+define Package/namei/description
+ namei uses its arguments as pathnames to any type of Unix file (symlinks,
+ files, directories, and so forth)
+endef
+
+define Package/rename
+$(call Package/util-linux/Default)
+ TITLE:=rename files
+endef
+
+define Package/rename/description
+ rename will rename the specified files by replacing the first occurrence of
+ expression in their name by replacement
+endef
+
+define Package/partx-utils
+$(call Package/util-linux/Default)
+ TITLE:=inform kernel about the presence and numbering of on-disk partitions
+ DEPENDS:= +libblkid
+ SUBMENU=disc
+endef
+
+define Package/partx-utils/description
+ contains partx, addpart, delpart
+endef
+
+define Package/script-utils
+$(call Package/util-linux/Default)
+ TITLE:=make and replay typescript of terminal session
+ SUBMENU=Terminal
+endef
+
+define Package/script-utils/description
+ contains: script, scriptreplay
+endef
+
+define Package/setterm
+$(call Package/util-linux/Default)
+ TITLE:=set terminal attributes
+ DEPENDS:= +libncurses
+ SUBMENU:=Terminal
+endef
+
+define Package/setterm/description
+ setterm writes to standard output a character string that will invoke the
+ specified terminal capabilities
+endef
+
+define Package/sfdisk
+$(call Package/util-linux/Default)
+ TITLE:=partition table manipulator for Linux
+ SUBMENU=disc
+endef
+
+define Package/sfdisk/description
+ list the size of a partition, list the partitions on a device, check the
+ partitions on a device and repartition a device
+endef
+
+define Package/swap-utils
+$(call Package/util-linux/Default)
+ TITLE:=swap space management utilities
+ DEPENDS+= +libblkid
+ SUBMENU:=disc
+endef
+
+define Package/swap-utils/description
+ contains: mkswap, swaplabel, swapon, swapoff
+endef
+
+define Package/uuidd
+$(call Package/util-linux/Default)
+ TITLE:=UUID generation daemon
+ DEPENDS:= +libuuid
+endef
+
+define Package/uuidd/description
+ The uuidd daemon is used by the UUID library to generate universally unique
+ identifiers (UUIDs), especially time-based UUIDs, in a secure and
+ guaranteed-unique fashion, even in the face of large numbers of threads
+ running on different CPUs trying to grab UUIDs.
+endef
+
+define Package/uuidgen
+$(call Package/util-linux/Default)
+ TITLE:=create a new UUID value
+ DEPENDS:= +libuuid
+endef
+
+define Package/uuidgen/description
+ The uuidgen program creates (and prints) a new universally unique identifier
+ (UUID) using the libuuid library. The new UUID can reasonably be considered
+ unique among all UUIDs created on the local system, and among UUIDs created on
+ other systems in the past and in the future.
+endef
+
+define Package/wall
+$(call Package/util-linux/Default)
+ TITLE:=send a message to everybody's terminal
+ SUBMENU=Terminal
+endef
+
+define Package/wall/description
+ wall sends a message to everybody logged in with their mesg permission
+ set to yes
+endef
+
+define Package/whereis
+$(call Package/util-linux/Default)
+ TITLE:=locate the binary, source, and manual page files for a command
+endef
+
+define Package/whereis/description
+ whereis locates source/binary and manuals sections for specified files
+endef
+
+define Package/wipefs
+$(call Package/util-linux/Default)
+ TITLE:=wipe a signature from a device
+ DEPENDS:= +libblkid
+ SUBMENU:=disc
+endef
+
+define Package/wipefs/description
+ wipefs can erase filesystem, raid or partition table signatures (magic
+ strings) from the specified device to make the signature invisible for
+ libblkid.
+endef
+
+define Package/libblkid/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_BUILD_DIR)/libblkid/src/.libs/libblkid.so.* $(1)/usr/lib/
+endef
+
+define Package/libmount/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_BUILD_DIR)/libmount/src/.libs/libmount.so.* $(1)/usr/lib/
+endef
+
+define Package/libuuid/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_BUILD_DIR)/libuuid/src/.libs/libuuid.so.* $(1)/usr/lib/
+endef
+
+define Package/agetty/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/term-utils/agetty $(1)/usr/sbin/
+endef
+
+define Package/blkid/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc-utils/.libs/blkid $(1)/usr/sbin/
+endef
+
+define Package/cal/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc-utils/cal $(1)/usr/bin/
+endef
+
+define Package/cfdisk/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/fdisk/.libs/cfdisk $(1)/usr/sbin/
+endef
+
+define Package/fdisk/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/fdisk/.libs/fdisk $(1)/usr/sbin/
+endef
+
+define Package/findfs/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc-utils/.libs/findfs $(1)/usr/sbin/
+endef
+
+define Package/flock/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/sys-utils/flock $(1)/usr/bin/
+endef
+
+define Package/getopt/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/getopt/getopt $(1)/usr/bin/
+endef
+
+define Package/hwclock/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/hwclock/hwclock $(1)/usr/sbin/
+endef
+
+define Package/logger/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc-utils/logger $(1)/usr/bin/
+endef
+
+define Package/look/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc-utils/look $(1)/usr/bin/
+endef
+
+define Package/losetup/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/sys-utils/losetup $(1)/usr/sbin/
+endef
+
+define Package/lsblk/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc-utils/.libs/lsblk $(1)/usr/bin/
+endef
+
+define Package/mcookie/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc-utils/mcookie $(1)/usr/bin/
+endef
+
+define Package/mount-utils/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/sys-utils/.libs/{u,}mount $(1)/usr/bin/
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/sys-utils/.libs/mountpoint $(1)/usr/bin/
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc-utils/.libs/findmnt $(1)/usr/bin/
+endef
+
+define Package/namei/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc-utils/namei $(1)/usr/bin/
+endef
+
+define Package/rename/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc-utils/rename $(1)/usr/bin/
+endef
+
+define Package/partx-utils/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/partx/.libs/partx $(1)/usr/sbin/
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/partx/addpart $(1)/usr/sbin/
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/partx/delpart $(1)/usr/sbin/
+endef
+
+define Package/script-utils/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/term-utils/script $(1)/usr/bin/
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/term-utils/scriptreplay $(1)/usr/bin/
+endef
+
+define Package/setterm/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/term-utils/setterm $(1)/usr/bin/
+endef
+
+define Package/sfdisk/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/fdisk/sfdisk $(1)/usr/sbin/
+endef
+
+define Package/swap-utils/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/disk-utils/.libs/mkswap $(1)/usr/sbin/
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/disk-utils/.libs/swaplabel $(1)/usr/sbin/
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/sys-utils/.libs/swapon $(1)/usr/sbin/
+ ln -sf swapon $(1)/usr/sbin/swapoff
+endef
+
+define Package/uuidd/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc-utils/.libs/uuidd $(1)/usr/sbin/
+endef
+
+define Package/uuidgen/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc-utils/.libs/uuidgen $(1)/usr/bin/
+endef
+
+define Package/wall/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/term-utils/wall $(1)/usr/bin/
+endef
+
+define Package/whereis/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc-utils/whereis $(1)/usr/bin/
+endef
+
+define Package/wipefs/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc-utils/.libs/wipefs $(1)/usr/sbin/
+endef
+
+$(eval $(call BuildPackage,libblkid))
+$(eval $(call BuildPackage,libmount))
+$(eval $(call BuildPackage,libuuid))
+$(eval $(call BuildPackage,agetty))
+$(eval $(call BuildPackage,blkid))
+$(eval $(call BuildPackage,cal))
+$(eval $(call BuildPackage,cfdisk))
+$(eval $(call BuildPackage,dmesg))
+$(eval $(call BuildPackage,fdisk))
+$(eval $(call BuildPackage,findfs))
+$(eval $(call BuildPackage,flock))
+$(eval $(call BuildPackage,getopt))
+$(eval $(call BuildPackage,hwclock))
+$(eval $(call BuildPackage,logger))
+$(eval $(call BuildPackage,look))
+$(eval $(call BuildPackage,losetup))
+$(eval $(call BuildPackage,lsblk))
+$(eval $(call BuildPackage,mcookie))
+$(eval $(call BuildPackage,mount-utils))
+$(eval $(call BuildPackage,namei))
+$(eval $(call BuildPackage,rename))
+$(eval $(call BuildPackage,partx-utils))
+$(eval $(call BuildPackage,script-utils))
+$(eval $(call BuildPackage,setterm))
+$(eval $(call BuildPackage,sfdisk))
+$(eval $(call BuildPackage,swap-utils))
+$(eval $(call BuildPackage,uuidd))
+$(eval $(call BuildPackage,uuidgen))
+$(eval $(call BuildPackage,wall))
+$(eval $(call BuildPackage,whereis))
+$(eval $(call BuildPackage,wipefs))
diff --git a/package/util-linux/patches/.svn/entries b/package/util-linux/patches/.svn/entries
new file mode 100644
index 0000000..2a92fc9
--- /dev/null
+++ b/package/util-linux/patches/.svn/entries
@@ -0,0 +1,96 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/util-linux/patches
+svn://svn.openwrt.org/openwrt
+
+
+
+2012-08-24T10:01:01.196917Z
+33270
+juhosg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+001-no-printf-alloc.patch
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+90d4562be94b3058ae17f5dd09fc6014
+2012-08-24T10:01:01.196917Z
+33270
+juhosg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2449
+
+000-compile.patch
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+3217a521428efa419f84adfd9d008ffd
+2012-06-09T17:37:29.925978Z
+32141
+luka
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1471
+
diff --git a/package/util-linux/patches/.svn/text-base/000-compile.patch.svn-base b/package/util-linux/patches/.svn/text-base/000-compile.patch.svn-base
new file mode 100644
index 0000000..b7cc18b
--- /dev/null
+++ b/package/util-linux/patches/.svn/text-base/000-compile.patch.svn-base
@@ -0,0 +1,44 @@
+--- a/misc-utils/cal.c
++++ b/misc-utils/cal.c
+@@ -291,41 +291,6 @@ main(int argc, char **argv) {
+ }
+ #endif
+
+-/*
+- * The traditional Unix cal utility starts the week at Sunday,
+- * while ISO 8601 starts at Monday. We read the start day from
+- * the locale database, which can be overridden with the
+- * -s (Sunday) or -m (Monday) options.
+- */
+-#if HAVE_DECL__NL_TIME_WEEK_1STDAY
+- /*
+- * You need to use 2 locale variables to get the first day of the week.
+- * This is needed to support first_weekday=2 and first_workday=1 for
+- * the rare case where working days span across 2 weeks.
+- * This shell script shows the combinations and calculations involved:
+- *
+- * for LANG in en_US ru_RU fr_FR csb_PL POSIX; do
+- * printf "%s:\t%s + %s -1 = " $LANG $(locale week-1stday first_weekday)
+- * date -d"$(locale week-1stday) +$(($(locale first_weekday)-1))day" +%w
+- * done
+- *
+- * en_US: 19971130 + 1 -1 = 0 #0 = sunday
+- * ru_RU: 19971130 + 2 -1 = 1
+- * fr_FR: 19971201 + 1 -1 = 1
+- * csb_PL: 19971201 + 2 -1 = 2
+- * POSIX: 19971201 + 7 -1 = 0
+- */
+- {
+- int wfd;
+- union { unsigned int word; char *string; } val;
+- val.string = nl_langinfo(_NL_TIME_WEEK_1STDAY);
+-
+- wfd = val.word;
+- wfd = day_in_week(wfd % 100, (wfd / 100) % 100, wfd / (100 * 100));
+- weekstart = (wfd + *nl_langinfo(_NL_TIME_FIRST_WEEKDAY) - 1) % 7;
+- }
+-#endif
+-
+ yflag = 0;
+ while ((ch = getopt_long(argc, argv, "13mjsyVh", longopts, NULL)) != -1)
+ switch(ch) {
diff --git a/package/util-linux/patches/.svn/text-base/001-no-printf-alloc.patch.svn-base b/package/util-linux/patches/.svn/text-base/001-no-printf-alloc.patch.svn-base
new file mode 100644
index 0000000..e3f048a
--- /dev/null
+++ b/package/util-linux/patches/.svn/text-base/001-no-printf-alloc.patch.svn-base
@@ -0,0 +1,108 @@
+for systems that don't support latest POSIX standard: %as
+
+https://bugs.gentoo.org/406303
+
+--- a/configure.ac
++++ b/configure.ac
+@@ -688,7 +688,6 @@ AC_ARG_ENABLE([libmount],
+ UL_BUILD_INIT([libmount])
+ UL_REQUIRES_LINUX([libmount])
+ UL_REQUIRES_BUILD([libmount], [libblkid])
+-UL_REQUIRES_HAVE([libmount], [scanf_alloc_modifier], [scanf string alloc modifier])
+ AM_CONDITIONAL(BUILD_LIBMOUNT, test "x$build_libmount" = xyes)
+
+ AC_SUBST([LIBMOUNT_VERSION])
+--- a/libmount/src/tab_parse.c
++++ b/libmount/src/tab_parse.c
+@@ -22,6 +22,10 @@
+ #include "pathnames.h"
+ #include "strutils.h"
+
++#ifndef HAVE_SCANF_MS_MODIFIER
++# define UL_SCNsA "%s"
++#endif
++
+ static inline char *skip_spaces(char *s)
+ {
+ assert(s);
+@@ -61,16 +65,31 @@ static int mnt_parse_table_line(struct l
+ int rc, n = 0, xrc;
+ char *src = NULL, *fstype = NULL, *optstr = NULL;
+
++#ifndef HAVE_SCANF_MS_MODIFIER
++ size_t len = strlen(s) + 1;
++ src = malloc(len);
++ fstype = malloc(len);
++ fs->target = malloc(len);
++ optstr = malloc(len);
++#endif
++
+ rc = sscanf(s, UL_SCNsA" " /* (1) source */
+ UL_SCNsA" " /* (2) target */
+ UL_SCNsA" " /* (3) FS type */
+ UL_SCNsA" " /* (4) options */
+ "%n", /* byte count */
+
++#ifdef HAVE_SCANF_MS_MODIFIER
+ &src,
+ &fs->target,
+ &fstype,
+ &optstr,
++#else
++ src,
++ fs->target,
++ fstype,
++ optstr,
++#endif
+ &n);
+ xrc = rc;
+
+@@ -136,6 +155,16 @@ static int mnt_parse_mountinfo_line(stru
+ unsigned int maj, min;
+ char *fstype = NULL, *src = NULL, *p;
+
++#ifndef HAVE_SCANF_MS_MODIFIER
++ size_t len = strlen(s) + 1;
++ fs->root = malloc(len);
++ fs->target = malloc(len);
++ fs->vfs_optstr = malloc(len);
++ fs->fs_optstr = malloc(len);
++ fstype = malloc(len);
++ src = malloc(len);
++#endif
++
+ rc = sscanf(s, "%u " /* (1) id */
+ "%u " /* (2) parent */
+ "%u:%u " /* (3) maj:min */
+@@ -147,9 +176,15 @@ static int mnt_parse_mountinfo_line(stru
+ &fs->id,
+ &fs->parent,
+ &maj, &min,
++#ifdef HAVE_SCANF_MS_MODIFIER
+ &fs->root,
+ &fs->target,
+ &fs->vfs_optstr,
++#else
++ fs->root,
++ fs->target,
++ fs->vfs_optstr,
++#endif
+ &end);
+
+ if (rc >= 7 && end > 0)
+@@ -167,9 +202,15 @@ static int mnt_parse_mountinfo_line(stru
+ UL_SCNsA" " /* (9) source */
+ UL_SCNsA, /* (10) fs options (fs specific) */
+
++#ifdef HAVE_SCANF_MS_MODIFIER
+ &fstype,
+ &src,
+ &fs->fs_optstr);
++#else
++ fstype,
++ src,
++ fs->fs_optstr);
++#endif
+
+ if (rc >= 10) {
+ fs->flags |= MNT_FS_KERNEL;
diff --git a/package/util-linux/patches/000-compile.patch b/package/util-linux/patches/000-compile.patch
new file mode 100644
index 0000000..b7cc18b
--- /dev/null
+++ b/package/util-linux/patches/000-compile.patch
@@ -0,0 +1,44 @@
+--- a/misc-utils/cal.c
++++ b/misc-utils/cal.c
+@@ -291,41 +291,6 @@ main(int argc, char **argv) {
+ }
+ #endif
+
+-/*
+- * The traditional Unix cal utility starts the week at Sunday,
+- * while ISO 8601 starts at Monday. We read the start day from
+- * the locale database, which can be overridden with the
+- * -s (Sunday) or -m (Monday) options.
+- */
+-#if HAVE_DECL__NL_TIME_WEEK_1STDAY
+- /*
+- * You need to use 2 locale variables to get the first day of the week.
+- * This is needed to support first_weekday=2 and first_workday=1 for
+- * the rare case where working days span across 2 weeks.
+- * This shell script shows the combinations and calculations involved:
+- *
+- * for LANG in en_US ru_RU fr_FR csb_PL POSIX; do
+- * printf "%s:\t%s + %s -1 = " $LANG $(locale week-1stday first_weekday)
+- * date -d"$(locale week-1stday) +$(($(locale first_weekday)-1))day" +%w
+- * done
+- *
+- * en_US: 19971130 + 1 -1 = 0 #0 = sunday
+- * ru_RU: 19971130 + 2 -1 = 1
+- * fr_FR: 19971201 + 1 -1 = 1
+- * csb_PL: 19971201 + 2 -1 = 2
+- * POSIX: 19971201 + 7 -1 = 0
+- */
+- {
+- int wfd;
+- union { unsigned int word; char *string; } val;
+- val.string = nl_langinfo(_NL_TIME_WEEK_1STDAY);
+-
+- wfd = val.word;
+- wfd = day_in_week(wfd % 100, (wfd / 100) % 100, wfd / (100 * 100));
+- weekstart = (wfd + *nl_langinfo(_NL_TIME_FIRST_WEEKDAY) - 1) % 7;
+- }
+-#endif
+-
+ yflag = 0;
+ while ((ch = getopt_long(argc, argv, "13mjsyVh", longopts, NULL)) != -1)
+ switch(ch) {
diff --git a/package/util-linux/patches/001-no-printf-alloc.patch b/package/util-linux/patches/001-no-printf-alloc.patch
new file mode 100644
index 0000000..e3f048a
--- /dev/null
+++ b/package/util-linux/patches/001-no-printf-alloc.patch
@@ -0,0 +1,108 @@
+for systems that don't support latest POSIX standard: %as
+
+https://bugs.gentoo.org/406303
+
+--- a/configure.ac
++++ b/configure.ac
+@@ -688,7 +688,6 @@ AC_ARG_ENABLE([libmount],
+ UL_BUILD_INIT([libmount])
+ UL_REQUIRES_LINUX([libmount])
+ UL_REQUIRES_BUILD([libmount], [libblkid])
+-UL_REQUIRES_HAVE([libmount], [scanf_alloc_modifier], [scanf string alloc modifier])
+ AM_CONDITIONAL(BUILD_LIBMOUNT, test "x$build_libmount" = xyes)
+
+ AC_SUBST([LIBMOUNT_VERSION])
+--- a/libmount/src/tab_parse.c
++++ b/libmount/src/tab_parse.c
+@@ -22,6 +22,10 @@
+ #include "pathnames.h"
+ #include "strutils.h"
+
++#ifndef HAVE_SCANF_MS_MODIFIER
++# define UL_SCNsA "%s"
++#endif
++
+ static inline char *skip_spaces(char *s)
+ {
+ assert(s);
+@@ -61,16 +65,31 @@ static int mnt_parse_table_line(struct l
+ int rc, n = 0, xrc;
+ char *src = NULL, *fstype = NULL, *optstr = NULL;
+
++#ifndef HAVE_SCANF_MS_MODIFIER
++ size_t len = strlen(s) + 1;
++ src = malloc(len);
++ fstype = malloc(len);
++ fs->target = malloc(len);
++ optstr = malloc(len);
++#endif
++
+ rc = sscanf(s, UL_SCNsA" " /* (1) source */
+ UL_SCNsA" " /* (2) target */
+ UL_SCNsA" " /* (3) FS type */
+ UL_SCNsA" " /* (4) options */
+ "%n", /* byte count */
+
++#ifdef HAVE_SCANF_MS_MODIFIER
+ &src,
+ &fs->target,
+ &fstype,
+ &optstr,
++#else
++ src,
++ fs->target,
++ fstype,
++ optstr,
++#endif
+ &n);
+ xrc = rc;
+
+@@ -136,6 +155,16 @@ static int mnt_parse_mountinfo_line(stru
+ unsigned int maj, min;
+ char *fstype = NULL, *src = NULL, *p;
+
++#ifndef HAVE_SCANF_MS_MODIFIER
++ size_t len = strlen(s) + 1;
++ fs->root = malloc(len);
++ fs->target = malloc(len);
++ fs->vfs_optstr = malloc(len);
++ fs->fs_optstr = malloc(len);
++ fstype = malloc(len);
++ src = malloc(len);
++#endif
++
+ rc = sscanf(s, "%u " /* (1) id */
+ "%u " /* (2) parent */
+ "%u:%u " /* (3) maj:min */
+@@ -147,9 +176,15 @@ static int mnt_parse_mountinfo_line(stru
+ &fs->id,
+ &fs->parent,
+ &maj, &min,
++#ifdef HAVE_SCANF_MS_MODIFIER
+ &fs->root,
+ &fs->target,
+ &fs->vfs_optstr,
++#else
++ fs->root,
++ fs->target,
++ fs->vfs_optstr,
++#endif
+ &end);
+
+ if (rc >= 7 && end > 0)
+@@ -167,9 +202,15 @@ static int mnt_parse_mountinfo_line(stru
+ UL_SCNsA" " /* (9) source */
+ UL_SCNsA, /* (10) fs options (fs specific) */
+
++#ifdef HAVE_SCANF_MS_MODIFIER
+ &fstype,
+ &src,
+ &fs->fs_optstr);
++#else
++ fstype,
++ src,
++ fs->fs_optstr);
++#endif
+
+ if (rc >= 10) {
+ fs->flags |= MNT_FS_KERNEL;
diff --git a/package/zram-swap/.svn/entries b/package/zram-swap/.svn/entries
new file mode 100644
index 0000000..7a5b045
--- /dev/null
+++ b/package/zram-swap/.svn/entries
@@ -0,0 +1,65 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/zram-swap
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-07T12:01:11.988661Z
+35033
+acinonyx
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+files
+dir
+
+Makefile
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+24f86ea544fd4f4e5f7f581dfa5ce78f
+2013-01-07T12:01:11.988661Z
+35033
+acinonyx
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+953
+
diff --git a/package/zram-swap/.svn/text-base/Makefile.svn-base b/package/zram-swap/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..bded5f3
--- /dev/null
+++ b/package/zram-swap/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,46 @@
+#
+# Copyright (C) 2013 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=zram-swap
+PKG_VERSION:=1
+PKG_RELEASE:=2
+
+PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/zram-swap
+ SECTION:=utils
+ CATEGORY:=Base system
+ DEPENDS:=+kmod-zram +!(BUSYBOX_CONFIG_MKSWAP&&BUSYBOX_CONFIG_SWAPONOFF):swap-utils
+ TITLE:=ZRAM swap scripts
+ PKGARCH:=all
+endef
+
+define Package/zram-swap/description
+ A script to activate swaping on a compressed zram partition. This
+ could be used to increase the available memory, by using compressed
+ memory.
+endef
+
+define Build/Prepare
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+endef
+
+define Package/zram-swap/install
+ $(INSTALL_DIR) $(1)/etc/init.d
+ $(INSTALL_BIN) ./files/zram.init $(1)/etc/init.d/zram
+endef
+
+$(eval $(call BuildPackage,zram-swap))
diff --git a/package/zram-swap/Makefile b/package/zram-swap/Makefile
new file mode 100644
index 0000000..bded5f3
--- /dev/null
+++ b/package/zram-swap/Makefile
@@ -0,0 +1,46 @@
+#
+# Copyright (C) 2013 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=zram-swap
+PKG_VERSION:=1
+PKG_RELEASE:=2
+
+PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/zram-swap
+ SECTION:=utils
+ CATEGORY:=Base system
+ DEPENDS:=+kmod-zram +!(BUSYBOX_CONFIG_MKSWAP&&BUSYBOX_CONFIG_SWAPONOFF):swap-utils
+ TITLE:=ZRAM swap scripts
+ PKGARCH:=all
+endef
+
+define Package/zram-swap/description
+ A script to activate swaping on a compressed zram partition. This
+ could be used to increase the available memory, by using compressed
+ memory.
+endef
+
+define Build/Prepare
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+endef
+
+define Package/zram-swap/install
+ $(INSTALL_DIR) $(1)/etc/init.d
+ $(INSTALL_BIN) ./files/zram.init $(1)/etc/init.d/zram
+endef
+
+$(eval $(call BuildPackage,zram-swap))
diff --git a/package/zram-swap/files/.svn/entries b/package/zram-swap/files/.svn/entries
new file mode 100644
index 0000000..ef1fc6f
--- /dev/null
+++ b/package/zram-swap/files/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+36060
+svn://svn.openwrt.org/openwrt/trunk/package/zram-swap/files
+svn://svn.openwrt.org/openwrt
+
+
+
+2013-01-07T12:01:11.988661Z
+35033
+acinonyx
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+zram.init
+file
+
+
+
+
+2013-03-17T12:13:10.000000Z
+b15701f54746d054e108d9279a3d437c
+2013-01-07T12:01:11.988661Z
+35033
+acinonyx
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2512
+
diff --git a/package/zram-swap/files/.svn/text-base/zram.init.svn-base b/package/zram-swap/files/.svn/text-base/zram.init.svn-base
new file mode 100644
index 0000000..23de915
--- /dev/null
+++ b/package/zram-swap/files/.svn/text-base/zram.init.svn-base
@@ -0,0 +1,123 @@
+#!/bin/sh /etc/rc.common
+
+START=15
+
+ram_size()
+{
+ local line
+
+ while read line; do case "$line" in MemTotal:*) set $line; echo "$2"; break ;; esac; done </proc/meminfo
+}
+
+zram_size() # in megabytes
+{
+ local zram_size="$( uci -q get system.@system[0].zram_size_mb )"
+ local ram_size="$( ram_size )"
+
+ if [ -z "$zram_size" ]; then
+ # e.g. 6mb for 16mb-routers or 61mb for 128mb-routers
+ echo $(( $ram_size / 2048 ))
+ else
+ echo "$zram_size"
+ fi
+}
+
+zram_applicable()
+{
+ local zram_dev="$1"
+
+ grep -sq ^"$zram_dev " /proc/swaps && {
+ logger -s -t zram_applicable -p daemon.notice "[OK] '$zram_dev' already active"
+ return 1
+ }
+
+ [ -e "$zram_dev" ] || {
+ logger -s -t zram_applicable -p daemon.crit "[ERROR] device '$zram_dev' not found"
+ return 1
+ }
+
+ which mkswap >/dev/null || {
+ logger -s -t zram_applicable -p daemon.err "[ERROR] 'mkswap' not installed"
+ return 1
+ }
+
+ which swapon >/dev/null || {
+ logger -s -t zram_applicable -p daemon.err "[ERROR] 'swapon' not installed"
+ return 1
+ }
+
+ which swapoff >/dev/null || {
+ logger -s -t zram_applicable -p daemon.err "[ERROR] 'swapoff' not installed"
+ return 1
+ }
+}
+
+zram_dev()
+{
+ local core="$1"
+
+ echo "/dev/zram${core:-0}"
+}
+
+zram_reset()
+{
+ local dev="$1"
+ local message="$2"
+ local proc_entry="/sys/block/$( basename "$dev" )/reset"
+
+ logger -s -t zram_reset -p daemon.debug "$message via $proc_entry"
+ echo "1" >"$proc_entry"
+}
+
+list_cpu_idx()
+{
+ local line i=0
+
+ while read line; do {
+ case "$line" in
+ [Pp]rocessor*)
+ echo $i
+ i=$(( $i + 1 ))
+ ;;
+ esac
+ } done <"/proc/cpuinfo"
+}
+
+start()
+{
+ # http://shmilyxbq-compcache.googlecode.com/hg/README
+ # if >1 cpu_core, reinit kmodule with e.g. num_devices=4
+
+ local zram_size="$( zram_size )"
+ local zram_dev core
+
+ for core in $( list_cpu_idx ); do {
+ zram_dev="$( zram_dev "$core" )"
+ zram_applicable "$zram_dev" || return 1
+
+ logger -s -t zram_start -p daemon.debug "activating '$zram_dev' for swapping ($zram_size MegaBytes)"
+
+ zram_reset "$zram_dev" "enforcing defaults"
+ echo $(( $zram_size * 1024 * 1024 )) >"/sys/block/$( basename $zram_dev )/disksize"
+ mkswap "$zram_dev"
+ swapon "$zram_dev"
+ } done
+}
+
+stop()
+{
+ local zram_dev proc_entry
+
+ for core in $( list_cpu_idx ); do {
+ zram_dev="$( zram_dev "$core" )"
+ proc_entry="/sys/block/$( basename "$zram_dev" )/reset"
+
+ grep -sq ^"$zram_dev " /proc/swaps && {
+ logger -s -t zram_stop -p daemon.debug "deactivate swap $zram_dev"
+ swapoff "$zram_dev"
+ }
+
+ zram_reset "$zram_dev" "claiming memory back"
+ } done
+}
+
diff --git a/package/zram-swap/files/zram.init b/package/zram-swap/files/zram.init
new file mode 100644
index 0000000..23de915
--- /dev/null
+++ b/package/zram-swap/files/zram.init
@@ -0,0 +1,123 @@
+#!/bin/sh /etc/rc.common
+
+START=15
+
+ram_size()
+{
+ local line
+
+ while read line; do case "$line" in MemTotal:*) set $line; echo "$2"; break ;; esac; done </proc/meminfo
+}
+
+zram_size() # in megabytes
+{
+ local zram_size="$( uci -q get system.@system[0].zram_size_mb )"
+ local ram_size="$( ram_size )"
+
+ if [ -z "$zram_size" ]; then
+ # e.g. 6mb for 16mb-routers or 61mb for 128mb-routers
+ echo $(( $ram_size / 2048 ))
+ else
+ echo "$zram_size"
+ fi
+}
+
+zram_applicable()
+{
+ local zram_dev="$1"
+
+ grep -sq ^"$zram_dev " /proc/swaps && {
+ logger -s -t zram_applicable -p daemon.notice "[OK] '$zram_dev' already active"
+ return 1
+ }
+
+ [ -e "$zram_dev" ] || {
+ logger -s -t zram_applicable -p daemon.crit "[ERROR] device '$zram_dev' not found"
+ return 1
+ }
+
+ which mkswap >/dev/null || {
+ logger -s -t zram_applicable -p daemon.err "[ERROR] 'mkswap' not installed"
+ return 1
+ }
+
+ which swapon >/dev/null || {
+ logger -s -t zram_applicable -p daemon.err "[ERROR] 'swapon' not installed"
+ return 1
+ }
+
+ which swapoff >/dev/null || {
+ logger -s -t zram_applicable -p daemon.err "[ERROR] 'swapoff' not installed"
+ return 1
+ }
+}
+
+zram_dev()
+{
+ local core="$1"
+
+ echo "/dev/zram${core:-0}"
+}
+
+zram_reset()
+{
+ local dev="$1"
+ local message="$2"
+ local proc_entry="/sys/block/$( basename "$dev" )/reset"
+
+ logger -s -t zram_reset -p daemon.debug "$message via $proc_entry"
+ echo "1" >"$proc_entry"
+}
+
+list_cpu_idx()
+{
+ local line i=0
+
+ while read line; do {
+ case "$line" in
+ [Pp]rocessor*)
+ echo $i
+ i=$(( $i + 1 ))
+ ;;
+ esac
+ } done <"/proc/cpuinfo"
+}
+
+start()
+{
+ # http://shmilyxbq-compcache.googlecode.com/hg/README
+ # if >1 cpu_core, reinit kmodule with e.g. num_devices=4
+
+ local zram_size="$( zram_size )"
+ local zram_dev core
+
+ for core in $( list_cpu_idx ); do {
+ zram_dev="$( zram_dev "$core" )"
+ zram_applicable "$zram_dev" || return 1
+
+ logger -s -t zram_start -p daemon.debug "activating '$zram_dev' for swapping ($zram_size MegaBytes)"
+
+ zram_reset "$zram_dev" "enforcing defaults"
+ echo $(( $zram_size * 1024 * 1024 )) >"/sys/block/$( basename $zram_dev )/disksize"
+ mkswap "$zram_dev"
+ swapon "$zram_dev"
+ } done
+}
+
+stop()
+{
+ local zram_dev proc_entry
+
+ for core in $( list_cpu_idx ); do {
+ zram_dev="$( zram_dev "$core" )"
+ proc_entry="/sys/block/$( basename "$zram_dev" )/reset"
+
+ grep -sq ^"$zram_dev " /proc/swaps && {
+ logger -s -t zram_stop -p daemon.debug "deactivate swap $zram_dev"
+ swapoff "$zram_dev"
+ }
+
+ zram_reset "$zram_dev" "claiming memory back"
+ } done
+}
+